From ec5f5c739e60ddde701b89fd7484faf867bb347f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Apr 2012 18:48:48 +0200 Subject: WINTERMUTE: Add in the engine-shell from the ScummVM-wiki --- engines/configure.engines | 1 + engines/engines.mk | 5 ++ engines/plugins_table.h | 3 + engines/wintermute/detection.cpp | 117 ++++++++++++++++++++++++++++++++++++++ engines/wintermute/module.mk | 16 ++++++ engines/wintermute/wintermute.cpp | 108 +++++++++++++++++++++++++++++++++++ engines/wintermute/wintermute.h | 65 +++++++++++++++++++++ 7 files changed, 315 insertions(+) create mode 100644 engines/wintermute/detection.cpp create mode 100644 engines/wintermute/module.mk create mode 100644 engines/wintermute/wintermute.cpp create mode 100644 engines/wintermute/wintermute.h (limited to 'engines') diff --git a/engines/configure.engines b/engines/configure.engines index 8eaee730cc..3809aca656 100644 --- a/engines/configure.engines +++ b/engines/configure.engines @@ -45,3 +45,4 @@ add_engine toon "Toonstruck" yes add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes add_engine tsage "TsAGE" yes add_engine tucker "Bud Tucker in Double Trouble" yes +add_engine wintermute "Wintermute" yes diff --git a/engines/engines.mk b/engines/engines.mk index 9939506b86..d5d912f8b7 100644 --- a/engines/engines.mk +++ b/engines/engines.mk @@ -216,3 +216,8 @@ ifdef ENABLE_TUCKER DEFINES += -DENABLE_TUCKER=$(ENABLE_TUCKER) MODULES += engines/tucker endif + +ifdef ENABLE_WINTERMUTE +DEFINES += -DENABLE_WINTERMUTE=$(ENABLE_WINTERMUTE) +MODULES += engines/wintermute +endif diff --git a/engines/plugins_table.h b/engines/plugins_table.h index fac956755e..fb35969b0b 100644 --- a/engines/plugins_table.h +++ b/engines/plugins_table.h @@ -101,3 +101,6 @@ LINK_PLUGIN(TOUCHE) #if PLUGIN_ENABLED_STATIC(TUCKER) LINK_PLUGIN(TUCKER) #endif +#if PLUGIN_ENABLED_STATIC(WINTERMUTE) +LINK_PLUGIN(WINTERMUTE) +#endif diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp new file mode 100644 index 0000000000..b3a756f6c3 --- /dev/null +++ b/engines/wintermute/detection.cpp @@ -0,0 +1,117 @@ +/* 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. + * + */ + +#include "engines/wintermute/wintermute.h" + +#include "common/config-manager.h" +#include "common/error.h" +#include "common/fs.h" + +#include "engines/metaengine.h" + +static const PlainGameDescriptor WinterMute_setting[] = { + { "WinterMute", "WinterMute - Unspecified game" }, + { 0, 0 } +}; + +class WinterMuteMetaEngine : public MetaEngine { +public: + virtual const char *getName() const { + return "WinterMute Lite"; + } + + virtual const char *getOriginalCopyright() const { + return "Copyright (c) 2011 Jan Nedoma"; + } + + virtual GameList getSupportedGames() const { + GameList games; + const PlainGameDescriptor *g = WinterMute_setting; + while (g->gameid) { + games.push_back(*g); + g++; + } + + return games; + } + + virtual GameDescriptor findGame(const char *gameid) const { + const PlainGameDescriptor *g = WinterMute_setting; + while (g->gameid) { + if (0 == scumm_stricmp(gameid, g->gameid)) + break; + g++; + } + return GameDescriptor(g->gameid, g->description); + } + + virtual GameList detectGames(const Common::FSList &fslist) const { + GameList detectedGames; + + // Iterate over all files in the given directory + for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { + if (!file->isDirectory()) { + const char *gameName = file->getName().c_str(); + + if (0 == scumm_stricmp("README", gameName)) { + // You could check the contents of the file now if you need to. + detectedGames.push_back(WinterMute_setting[0]); + break; + } + } + } + return detectedGames; + } + + virtual Common::Error createInstance(OSystem *syst, Engine **engine) const { + assert(syst); + assert(engine); + + // Scan the target directory for files (error out if it does not exist) + Common::FSList fslist; + Common::FSNode dir(ConfMan.get("path")); + if (!dir.getChildren(fslist, Common::FSNode::kListAll)) { + return Common::kNoGameDataFoundError; + } + + // Invoke the detector + Common::String gameid = ConfMan.get("gameid"); + GameList detectedGames = detectGames(fslist); + + for (uint i = 0; i < detectedGames.size(); i++) { + if (detectedGames[i].gameid() == gameid) { + // At this point you may want to perform additional sanity checks. + *engine = new WinterMute::WinterMuteEngine(syst); + return Common::kNoError; + } + } + + // Failed to find any game data + return Common::kNoGameDataFoundError; + } +}; + +#if PLUGIN_ENABLED_DYNAMIC(WINTERMUTE) +REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); +#else +REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); +#endif \ No newline at end of file diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk new file mode 100644 index 0000000000..4096e8d8e6 --- /dev/null +++ b/engines/wintermute/module.mk @@ -0,0 +1,16 @@ +MODULE := engines/wintermute + +MODULE_OBJS := \ + detection.o \ + wintermute.o + +MODULE_DIRS += \ + engines/wintermute + +# This module can be built as a plugin +ifeq ($(ENABLE_WINTERMUTE), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk \ No newline at end of file diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp new file mode 100644 index 0000000000..393e6c4888 --- /dev/null +++ b/engines/wintermute/wintermute.cpp @@ -0,0 +1,108 @@ +/* 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. + * + */ + +#include "common/scummsys.h" + +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/error.h" +#include "common/EventRecorder.h" +#include "common/file.h" +#include "common/fs.h" + +#include "engines/util.h" + +#include "WinterMute/WinterMute.h" + +namespace WinterMute { + + WinterMuteEngine::WinterMuteEngine(OSystem *syst) + : Engine(syst) { + // Put your engine in a sane state, but do nothing big yet; + // in particular, do not load data from files; rather, if you + // need to do such things, do them from init(). + + // Do not initialize graphics here + + // However this is the place to specify all default directories + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); + + // Here is the right place to set up the engine specific debug channels + DebugMan.addDebugChannel(kWinterMuteDebugExample, "example", "this is just an example for a engine specific debug channel"); + DebugMan.addDebugChannel(kWinterMuteDebugExample2, "example2", "also an example"); + + // Don't forget to register your random source + _rnd = new Common::RandomSource("WinterMute"); + + debug("WinterMuteEngine::WinterMuteEngine"); + } + + WinterMuteEngine::~WinterMuteEngine() { + debug("WinterMuteEngine::~WinterMuteEngine"); + + // Dispose your resources here + delete _rnd; + + // Remove all of our debug levels here + DebugMan.clearAllDebugChannels(); + } + + Common::Error WinterMuteEngine::run() { + // Initialize graphics using following: + initGraphics(320, 200, false); + + // You could use backend transactions directly as an alternative, + // but it isn't recommended, until you want to handle the error values + // from OSystem::endGFXTransaction yourself. + // This is just an example template: + //_system->beginGFXTransaction(); + // // This setup the graphics mode according to users seetings + // initCommonGFX(false); + // + // // Specify dimensions of game graphics window. + // // In this example: 320x200 + // _system->initSize(320, 200); + //FIXME: You really want to handle + //OSystem::kTransactionSizeChangeFailed here + //_system->endGFXTransaction(); + + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); + + // Additional setup. + debug("WinterMuteEngine::init"); + + // Your main even loop should be (invoked from) here. + debug("WinterMuteEngine::go: Hello, World!"); + + // This test will show up if -d1 and --debugflags=example are specified on the commandline + debugC(1, kWinterMuteDebugExample, "Example debug call"); + + // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline + debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); + + return Common::kNoError; + } + +} // End of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h new file mode 100644 index 0000000000..33ed2892ff --- /dev/null +++ b/engines/wintermute/wintermute.h @@ -0,0 +1,65 @@ +/* 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. + * + */ + +#ifndef WINTERMUTE_H +#define WINTERMUTE_H + +#include "common/random.h" +#include "engines/engine.h" +#include "gui/debugger.h" + +namespace WinterMute { + + class Console; + + // our engine debug channels + enum { + kWinterMuteDebugExample = 1 << 0, + kWinterMuteDebugExample2 = 1 << 1 + // next new channel must be 1 << 2 (4) + // the current limitation is 32 debug channels (1 << 31 is the last one) + }; + + class WinterMuteEngine : public Engine { + public: + WinterMuteEngine(OSystem *syst); + ~WinterMuteEngine(); + + virtual Common::Error run(); + + private: + Console *_console; + + // We need random numbers + Common::RandomSource *_rnd; + }; + + // Example console class + class Console : public GUI::Debugger { + public: + Console(WinterMuteEngine *vm) {} + virtual ~Console(void) {} + }; + +} // End of namespace Wintermute + +#endif \ No newline at end of file -- cgit v1.2.3 From 997c5df43000b7db5b73aa883343d00df92c6cd0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 00:29:08 +0100 Subject: WINTERMUTE: Add BBase and BParser, and make them compile. --- engines/wintermute/BBase.cpp | 173 +++++ engines/wintermute/BBase.h | 61 ++ engines/wintermute/BDynBuffer.h | 66 ++ engines/wintermute/BGame.h | 384 +++++++++++ engines/wintermute/BObject.cpp | 1122 +++++++++++++++++++++++++++++++ engines/wintermute/BObject.h | 144 ++++ engines/wintermute/BParser.cpp | 435 ++++++++++++ engines/wintermute/BParser.h | 88 +++ engines/wintermute/BPersistMgr.cpp | 517 ++++++++++++++ engines/wintermute/BPersistMgr.h | 89 +++ engines/wintermute/BScriptHolder.h | 81 +++ engines/wintermute/PlatformSDL.h | 92 +++ engines/wintermute/SysClass.cpp | 203 ++++++ engines/wintermute/SysClass.h | 101 +++ engines/wintermute/SysClassRegistry.cpp | 287 ++++++++ engines/wintermute/SysClassRegistry.h | 89 +++ engines/wintermute/SysInstance.cpp | 48 ++ engines/wintermute/SysInstance.h | 68 ++ engines/wintermute/coll_templ.h | 372 ++++++++++ engines/wintermute/dcgf.h | 62 ++ engines/wintermute/dctypes.h | 181 +++++ engines/wintermute/module.mk | 6 +- engines/wintermute/persistent.h | 89 +++ engines/wintermute/wintypes.h | 117 ++++ 24 files changed, 4874 insertions(+), 1 deletion(-) create mode 100644 engines/wintermute/BBase.cpp create mode 100644 engines/wintermute/BBase.h create mode 100644 engines/wintermute/BDynBuffer.h create mode 100644 engines/wintermute/BGame.h create mode 100644 engines/wintermute/BObject.cpp create mode 100644 engines/wintermute/BObject.h create mode 100644 engines/wintermute/BParser.cpp create mode 100644 engines/wintermute/BParser.h create mode 100644 engines/wintermute/BPersistMgr.cpp create mode 100644 engines/wintermute/BPersistMgr.h create mode 100644 engines/wintermute/BScriptHolder.h create mode 100644 engines/wintermute/PlatformSDL.h create mode 100644 engines/wintermute/SysClass.cpp create mode 100644 engines/wintermute/SysClass.h create mode 100644 engines/wintermute/SysClassRegistry.cpp create mode 100644 engines/wintermute/SysClassRegistry.h create mode 100644 engines/wintermute/SysInstance.cpp create mode 100644 engines/wintermute/SysInstance.h create mode 100644 engines/wintermute/coll_templ.h create mode 100644 engines/wintermute/dcgf.h create mode 100644 engines/wintermute/dctypes.h create mode 100644 engines/wintermute/persistent.h create mode 100644 engines/wintermute/wintypes.h (limited to 'engines') diff --git a/engines/wintermute/BBase.cpp b/engines/wintermute/BBase.cpp new file mode 100644 index 0000000000..845543c351 --- /dev/null +++ b/engines/wintermute/BBase.cpp @@ -0,0 +1,173 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BBase.h" +#include "BGame.h" +#include "BParser.h" +#include "BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *GameOwner) { + Game = GameOwner; + m_Persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + Game = NULL; + m_Persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + m_EditorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { + m_EditorPropsIter = m_EditorProps.find(PropName); + if (m_EditorPropsIter != m_EditorProps.end()) return m_EditorPropsIter->second.c_str(); + else return InitVal; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::SetEditorProp(const char *PropName, const char *PropValue) { + if (PropName == NULL) return E_FAIL; + + if (PropValue == NULL) { + m_EditorProps.erase(PropName); + } else { + m_EditorProps[PropName] = PropValue; + } + return S_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!Game->m_EditorMode) return S_OK; + + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + char *PropName = NULL; + char *PropValue = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] PropName; + PropName = new char[strlen((char *)params) + 1]; + if (PropName) strcpy(PropName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] PropValue; + PropValue = new char[strlen((char *)params) + 1]; + if (PropValue) strcpy(PropValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return E_FAIL; + } + + + SetEditorProp(PropName, PropValue); + + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { + m_EditorPropsIter = m_EditorProps.begin(); + while (m_EditorPropsIter != m_EditorProps.end()) { + Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); + Buffer->PutTextIndent(Indent, "{\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->first.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->second.c_str()); + Buffer->PutTextIndent(Indent, "}\n\n"); + + m_EditorPropsIter++; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BBase.h b/engines/wintermute/BBase.h new file mode 100644 index 0000000000..ba228bc572 --- /dev/null +++ b/engines/wintermute/BBase.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "wintypes.h" +#include "dctypes.h" +#include +#include + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool m_Persistable; + HRESULT SetEditorProp(const char *PropName, const char *PropValue); + const char *GetEditorProp(const char *PropName, const char *InitVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + HRESULT ParseEditorProperty(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + CBBase(); + CBGame *Game; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + std::map m_EditorProps; + std::map::iterator m_EditorPropsIter; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BDynBuffer.h b/engines/wintermute/BDynBuffer.h new file mode 100644 index 0000000000..7ef970fcd3 --- /dev/null +++ b/engines/wintermute/BDynBuffer.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "BBase.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool m_Initialized; + void PutText(LPCSTR fmt, ...); + void PutTextIndent(int Indent, LPCSTR fmt, ...); + uint32 GetDWORD(); + void PutDWORD(uint32 Val); + char *GetString(); + void PutString(const char *Val); + HRESULT GetBytes(byte *Buffer, uint32 Size); + HRESULT PutBytes(byte *Buffer, uint32 Size); + uint32 GetSize(); + HRESULT Init(uint32 InitSize = 0); + void Cleanup(); + uint32 m_Size; + byte *m_Buffer; + CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 m_RealSize; + uint32 m_GrowBy; + uint32 m_InitSize; + uint32 m_Offset; + void PutTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h new file mode 100644 index 0000000000..199417ede6 --- /dev/null +++ b/engines/wintermute/BGame.h @@ -0,0 +1,384 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +//#include "BDebugger.h" +//#include "BSaveThumbHelper.h" +//#include "BFader.h" +//#include "BRenderer.h" +//#include "BSurfaceStorage.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/persistent.h" +#include "coll_templ.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, HRESULT Result, void *Data); + +class CBSoundMgr; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRegistry; +class CSXStore; +class CSXMath; +class CBKeyboardState; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) +#if 0 + virtual HRESULT OnScriptShutdown(CScScript *Script); + + virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); + virtual HRESULT OnMouseLeftDown(); + virtual HRESULT OnMouseLeftUp(); + virtual HRESULT OnMouseLeftDblClick(); + virtual HRESULT OnMouseRightDblClick(); + virtual HRESULT OnMouseRightDown(); + virtual HRESULT OnMouseRightUp(); + virtual HRESULT OnMouseMiddleDown(); + virtual HRESULT OnMouseMiddleUp(); + virtual HRESULT OnPaint(); + virtual HRESULT OnWindowClose(); + + bool IsLeftDoubleClick(); + bool IsRightDoubleClick(); +#endif + bool m_AutorunDisabled; + + uint32 m_LastMiniUpdate; + bool m_MiniUpdateEnabled; + + virtual HRESULT MiniUpdate() {} // <- TODO Unstub +#if 0 + virtual HRESULT MiniUpdate(); + + void GetMousePos(POINT *Pos); + RECT m_MouseLockRect; + + bool m_ShuttingDown; + + virtual HRESULT DisplayDebugInfo(); + bool m_DEBUG_ShowFPS; + + bool m_SuspendedRendering; + int m_SoundBufferSizeSec; + + TTextEncoding m_TextEncoding; + bool m_TextRTL; + + CBSprite *m_LoadingIcon; + int m_LoadingIconX; + int m_LoadingIconY; + int m_LoadingIconPersistent; + + virtual HRESULT ResetContent(); + + void DEBUG_DumpClassRegistry(); + HRESULT SetWaitCursor(char *Filename); + + char *m_LocalSaveDir; + bool m_SaveDirChecked; + + + bool m_IndicatorDisplay; + uint32 m_IndicatorColor; + int m_IndicatorProgress; + int m_IndicatorX; + int m_IndicatorY; + int m_IndicatorWidth; + int m_IndicatorHeight; + + bool m_RichSavedGames; + char *m_SavedGameExt; + + char *m_LoadImageName; + char *m_SaveImageName; + int m_SaveImageX; + int m_SaveImageY; + int m_LoadImageX; + int m_LoadImageY; + CBSurface *m_SaveLoadImage; + + HRESULT DisplayIndicator(); + + int m_ThumbnailWidth; + int m_ThumbnailHeight; + + bool m_ReportTextureFormat; + HMODULE m_ResourceModule; + void SetResourceModule(HMODULE ResModule); + + void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); + ENGINE_LOG_CALLBACK m_EngineLogCallback; + void *m_EngineLogCallbackData; +#endif + bool m_EditorMode; +#if 0 + bool m_DoNotExpandStrings; + void GetOffset(int *OffsetX, int *OffsetY); + void SetOffset(int OffsetX, int OffsetY); + int GetSequence(); + int m_OffsetY; + int m_OffsetX; + float m_OffsetPercentX; + float m_OffsetPercentY; + CBObject *m_MainObject; + HRESULT InitInput(HINSTANCE hInst, HWND hWnd); + HRESULT InitLoop(); + uint32 m_CurrentTime; + uint32 m_DeltaTime; + CBFont *m_SystemFont; + CBFont *m_VideoFont; + HRESULT Initialize1(); + HRESULT Initialize2(); + HRESULT Initialize3(); + CBFileManager *m_FileManager; + CBTransitionMgr *m_TransMgr; + CBDebugger *GetDebugMgr(); +#endif //TODO: STUB + void LOG(HRESULT res, LPCSTR fmt, ...) {} +#if 0 + CBRenderer *m_Renderer; + CBSoundMgr *m_SoundMgr; + CScEngine *m_ScEngine; + CSXMath *m_MathClass; + CSXStore *m_Store; + CBSurfaceStorage *m_SurfaceStorage; + CBFontStorage *m_FontStorage; + CBGame(); + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *Filename = NULL); + bool m_DEBUG_DebugMode; + bool m_DEBUG_AbsolutePathWarning; + FILE *m_DEBUG_LogFile; + int m_Sequence; + virtual HRESULT LoadFile(const char *Filename); + virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CBArray m_QuickMessages; + CBArray m_Windows; + CBArray m_ViewportStack; + int m_ViewportSP; + bool m_MouseLeftDown; + bool m_MouseRightDown; + bool m_MouseMidlleDown; + CBStringTable *m_StringTable; + + int m_SettingsResWidth; + int m_SettingsResHeight; + bool m_SettingsRequireAcceleration; + bool m_SettingsAllowWindowed; + bool m_SettingsAllowAdvanced; + bool m_SettingsAllowAccessTab; + bool m_SettingsAllowAboutTab; + bool m_SettingsRequireSound; + bool m_SettingsAllowDesktopRes; + int m_SettingsTLMode; + char *m_SettingsGameFile; + CBFader *m_Fader; + bool m_SuppressScriptErrors; + + virtual HRESULT InvalidateDeviceObjects(); + virtual HRESULT RestoreDeviceObjects(); + + virtual void PublishNatives(); + virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + + // compatibility bits + bool m_CompatKillMethodThreads; + +private: + // FPS stuff + uint32 m_LastTime; + uint32 m_FpsTime; + uint32 m_FramesRendered; + +public: + uint32 m_SurfaceGCCycleTime; + bool m_SmartCache; + bool m_VideoSubtitles; + bool m_Subtitles; + uint32 m_MusicStartTime[NUM_MUSIC_CHANNELS]; + bool m_CompressedSavegames; + int m_ScheduledLoadSlot; + bool m_Loading; + bool m_PersonalizedSave; + HRESULT EmptySaveSlot(int Slot); + bool IsSaveSlotUsed(int Slot); + HRESULT GetSaveSlotDescription(int Slot, char *Buffer); + HRESULT GetSaveSlotFilename(int Slot, char *Buffer); + void SetWindowTitle(); + virtual bool HandleMouseWheel(int Delta); + bool m_Quitting; + virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); + virtual bool HandleKeypress(SDL_Event *event); + int m_FreezeLevel; + HRESULT Unfreeze(); + HRESULT Freeze(bool IncludingMusic = true); + HRESULT FocusWindow(CUIWindow *Window); + bool m_LoadInProgress; + CUIWindow *m_FocusedWindow; + bool m_EditorForceScripts; + static void AfterLoadRegion(void *Region, void *Data); + static void AfterLoadSubFrame(void *Subframe, void *Data); + static void AfterLoadSound(void *Sound, void *Data); + static void AfterLoadFont(void *Font, void *Data); + static void AfterLoadScript(void *script, void *data); + static void InvalidateValues(void *Value, void *Data); + HRESULT LoadSettings(char *Filename); + HRESULT ResumeMusic(int Channel); + HRESULT SetMusicStartTime(int Channel, uint32 Time); + HRESULT PauseMusic(int Channel); + HRESULT StopMusic(int Channel); + HRESULT PlayMusic(int Channel, char *Filename, bool Looping = true, uint32 LoopStart = 0); + CBSound *m_Music[NUM_MUSIC_CHANNELS]; + bool m_MusicCrossfadeRunning; + bool m_MusicCrossfadeSwap; + uint32 m_MusicCrossfadeStartTime; + uint32 m_MusicCrossfadeLength; + int m_MusicCrossfadeChannel1; + int m_MusicCrossfadeChannel2; + HRESULT DisplayWindows(bool InGame = false); + CBRegistry *m_Registry; + bool m_UseD3D; + virtual HRESULT Cleanup(); + virtual HRESULT LoadGame(int Slot); + virtual HRESULT LoadGame(char *Filename); + virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); + virtual HRESULT ShowCursor(); + CBSprite *m_CursorNoninteractive; + CBObject *m_ActiveObject; + CBKeyboardState *m_KeyboardState; + bool m_Interactive; + TGameState m_State; + TGameState m_OrigState; + bool m_OrigInteractive; + uint32 m_Timer; + uint32 m_TimerDelta; + uint32 m_TimerLast; + + uint32 m_LiveTimer; + uint32 m_LiveTimerDelta; + uint32 m_LiveTimerLast; + + CBObject *m_CapturedObject; + POINT m_MousePos; + bool ValidObject(CBObject *Object); + HRESULT UnregisterObject(CBObject *Object); + HRESULT RegisterObject(CBObject *Object); + void QuickMessage(char *Text); + void QuickMessageForm(LPSTR fmt, ...); + HRESULT DisplayQuickMsg(); + uint32 m_Fps; + HRESULT UpdateMusicCrossfade(); + + CBArray m_RegObjects; + +public: + virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); + virtual HRESULT DisplayContentSimple(); + bool m_ForceNonStreamedSounds; + void ResetMousePos(); + int m_SubtitlesSpeed; + void SetInteractive(bool State); + virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); + HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); + HRESULT PopViewport(); + HRESULT PushViewport(CBViewport *Viewport); + HRESULT SetActiveObject(CBObject *Obj); + + CBSprite *m_LastCursor; + HRESULT DrawCursor(CBSprite *Cursor); + + virtual HRESULT InitAfterLoad(); + + CBSaveThumbHelper *m_CachedThumbnail; + + AnsiString GetDataDir(); + + void AddMem(int bytes); + + bool m_TouchInterface; + bool m_ConstrainedMemory; + AnsiString GetDeviceType() const; + +private: + CBDebugger *m_DebugMgr; + + struct LastClickInfo { + LastClickInfo() { + PosX = PosY = 0; + Time = 0; + } + + int PosX; + int PosY; + uint32 Time; + }; + + LastClickInfo m_LastClick[2]; + bool IsDoubleClick(int buttonIndex); + uint32 m_UsedMem; + + + +protected: + // WME Lite specific + bool m_AutoSaveOnExit; + int m_AutoSaveSlot; + bool m_CursorHidden; + +public: + void AutoSaveOnExit(); +#endif + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp new file mode 100644 index 0000000000..3bb94046a4 --- /dev/null +++ b/engines/wintermute/BObject.cpp @@ -0,0 +1,1122 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BObject.h" +#include "BParser.h" +#include "ScValue.h" +#include "ScStack.h" +#include "BSound.h" +#include "BSoundMgr.h" +#include "BGame.h" +#include "BStringTable.h" +#include "BSprite.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + m_PosX = m_PosY = 0; + m_Movable = true; + m_Zoomable = true; + m_Registrable = true; + m_Shadowable = true; + m_Rotatable = false; + m_Is3D = false; + + m_AlphaColor = 0; + m_Scale = -1; + m_RelativeScale = 0; + + m_ScaleX = -1; + m_ScaleY = -1; + + m_Ready = true; + + m_SoundEvent = NULL; + + m_ID = Game->GetSequence(); + + CBPlatform::SetRectEmpty(&m_Rect); + m_RectSet = false; + + m_Cursor = NULL; + m_ActiveCursor = NULL; + m_SharedCursors = false; + + m_SFX = NULL; + m_SFXStart = 0; + m_SFXVolume = 100; + m_AutoSoundPanning = true; + + m_EditorAlwaysRegister = false; + m_EditorSelected = false; + + m_EditorOnly = false; + + m_Rotate = 0.0f; + m_RotateValid = false; + m_RelativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) m_Caption[i] = NULL; + m_SaveState = true; + + m_NonIntMouseEvents = false; + + // sound FX + m_SFXType = SFX_NONE; + m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + + m_BlendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Cleanup() { + if (Game && Game->m_ActiveObject == this) Game->m_ActiveObject = NULL; + + CBScriptHolder::Cleanup(); + delete[] m_SoundEvent; + m_SoundEvent = NULL; + + if (!m_SharedCursors) { + delete m_Cursor; + delete m_ActiveCursor; + m_Cursor = NULL; + m_ActiveCursor = NULL; + } + delete m_SFX; + m_SFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] m_Caption[i]; + m_Caption[i] = NULL; + } + + m_SFXType = SFX_NONE; + m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::SetCaption(char *Caption, int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7) return; + + delete[] m_Caption[Case - 1]; + m_Caption[Case - 1] = new char[strlen(Caption) + 1]; + if (m_Caption[Case - 1]) { + strcpy(m_Caption[Case - 1], Caption); + Game->m_StringTable->Expand(&m_Caption[Case - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBObject::GetCaption(int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7 || m_Caption[Case - 1] == NULL) return ""; + else return m_Caption[Case - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SkipTo") == 0) { + Stack->CorrectParams(2); + m_PosX = Stack->Pop()->GetInt(); + m_PosY = Stack->Pop()->GetInt(); + AfterMove(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + Stack->CorrectParams(1); + Stack->PushString(GetCaption(Stack->Pop()->GetInt())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveCursor") == 0) { + Stack->CorrectParams(0); + if (!m_SharedCursors) { + delete m_Cursor; + m_Cursor = NULL; + } else { + m_Cursor = NULL; + + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCursor") == 0) { + Stack->CorrectParams(0); + if (!m_Cursor || !m_Cursor->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_Cursor->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCursorObject") == 0) { + Stack->CorrectParams(0); + if (!m_Cursor) Stack->PushNULL(); + else Stack->PushNative(m_Cursor, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasCursor") == 0) { + Stack->CorrectParams(0); + + if (m_Cursor) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCaption") == 0) { + Stack->CorrectParams(2); + SetCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadSound") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + if (SUCCEEDED(PlaySFX(Filename, false, false))) + Stack->PushBool(true); + else + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlaySound") == 0) { + Stack->CorrectParams(3); + + char *Filename; + bool Looping; + uint32 LoopStart; + + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + CScValue *val3 = Stack->Pop(); + + if (val1->m_Type == VAL_BOOL) { + Filename = NULL; + Looping = val1->GetBool(); + LoopStart = val2->GetInt(); + } else { + if (val1->IsNULL()) Filename = NULL; + else Filename = val1->GetString(); + Looping = val2->IsNULL() ? false : val2->GetBool(); + LoopStart = val3->GetInt(); + } + + if (FAILED(PlaySFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlaySoundEvent") == 0) { + Stack->CorrectParams(2); + + char *Filename; + char *EventName; + + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + + if (val2->IsNULL()) { + Filename = NULL; + EventName = val1->GetString(); + } else { + Filename = val1->GetString(); + EventName = val2->GetString(); + } + + if (FAILED(PlaySFX(Filename, false, true, EventName))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(StopSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(PauseSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(ResumeSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsSoundPlaying") == 0) { + Stack->CorrectParams(0); + + if (m_SFX && m_SFX->IsPlaying()) Stack->PushBool(true); + else Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSoundPosition") == 0) { + Stack->CorrectParams(1); + + uint32 Time = Stack->Pop()->GetInt(); + if (FAILED(SetSFXTime(Time))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundPosition") == 0) { + Stack->CorrectParams(0); + + if (!m_SFX) Stack->PushInt(0); + else Stack->PushInt(m_SFX->GetPositionTime()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSoundVolume") == 0) { + Stack->CorrectParams(1); + + int Volume = Stack->Pop()->GetInt(); + if (FAILED(SetSFXVolume(Volume))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundVolume") == 0) { + Stack->CorrectParams(0); + + if (!m_SFX) Stack->PushInt(m_SFXVolume); + else Stack->PushInt(m_SFX->GetVolume()); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXNone") == 0) { + Stack->CorrectParams(0); + m_SFXType = SFX_NONE; + m_SFXParam1 = 0; + m_SFXParam2 = 0; + m_SFXParam3 = 0; + m_SFXParam4 = 0; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXEcho") == 0) { + Stack->CorrectParams(4); + m_SFXType = SFX_ECHO; + m_SFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) + m_SFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) + m_SFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) + m_SFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXReverb") == 0) { + Stack->CorrectParams(4); + m_SFXType = SFX_REVERB; + m_SFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) + m_SFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) + m_SFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + m_SFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + Stack->PushNULL(); + + return S_OK; + } + + else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("object"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + m_ScValue->SetString(GetCaption(1)); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + m_ScValue->SetInt(m_PosX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + m_ScValue->SetInt(m_PosY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_ScValue->SetInt(GetHeight()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Ready") == 0) { + m_ScValue->SetBool(m_Ready); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Movable") == 0) { + m_ScValue->SetBool(m_Movable); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + m_ScValue->SetBool(m_Registrable); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + m_ScValue->SetBool(m_Zoomable); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotatable") == 0) { + m_ScValue->SetBool(m_Rotatable); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + m_ScValue->SetInt((int)m_AlphaColor); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "BlendMode") == 0) { + m_ScValue->SetInt((int)m_BlendMode); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + if (m_Scale < 0) m_ScValue->SetNULL(); + else m_ScValue->SetFloat((double)m_Scale); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleX") == 0) { + if (m_ScaleX < 0) m_ScValue->SetNULL(); + else m_ScValue->SetFloat((double)m_ScaleX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleY") == 0) { + if (m_ScaleY < 0) m_ScValue->SetNULL(); + else m_ScValue->SetFloat((double)m_ScaleY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeScale") == 0) { + m_ScValue->SetFloat((double)m_RelativeScale); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotate") == 0) { + if (!m_RotateValid) m_ScValue->SetNULL(); + else m_ScValue->SetFloat((double)m_Rotate); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeRotate") == 0) { + m_ScValue->SetFloat((double)m_RelativeRotate); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Colorable") == 0) { + m_ScValue->SetBool(m_Shadowable); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundPanning") == 0) { + m_ScValue->SetBool(m_AutoSoundPanning); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveState") == 0) { + m_ScValue->SetBool(m_SaveState); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NonIntMouseEvents") == 0) { + m_ScValue->SetBool(m_NonIntMouseEvents); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccCaption") == 0) { + m_ScValue->SetNULL(); + return m_ScValue; + } + + else return CBScriptHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Caption") == 0) { + SetCaption(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + m_PosX = Value->GetInt(); + AfterMove(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + m_PosY = Value->GetInt(); + AfterMove(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Movable") == 0) { + m_Movable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + m_Registrable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + m_Zoomable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotatable") == 0) { + m_Rotatable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + m_AlphaColor = (uint32)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "BlendMode") == 0) { + int i = Value->GetInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + m_BlendMode = (TSpriteBlendMode)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + if (Value->IsNULL()) m_Scale = -1; + else m_Scale = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleX") == 0) { + if (Value->IsNULL()) m_ScaleX = -1; + else m_ScaleX = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleY") == 0) { + if (Value->IsNULL()) m_ScaleY = -1; + else m_ScaleY = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeScale") == 0) { + m_RelativeScale = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotate") == 0) { + if (Value->IsNULL()) { + m_Rotate = 0.0f; + m_RotateValid = false; + } else { + m_Rotate = (float)Value->GetFloat(); + m_RotateValid = true; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeRotate") == 0) { + m_RelativeRotate = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Colorable") == 0) { + m_Shadowable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundPanning") == 0) { + m_AutoSoundPanning = Value->GetBool(); + if (!m_AutoSoundPanning) ResetSoundPan(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveState") == 0) { + m_SaveState = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NonIntMouseEvents") == 0) { + m_NonIntMouseEvents = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccCaption") == 0) { + return S_OK; + } + + else return CBScriptHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBObject::ScToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ShowCursor() { + if (m_Cursor) return Game->DrawCursor(m_Cursor); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { + CBScriptHolder::Persist(PersistMgr); + + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(m_Caption[i])); + PersistMgr->Transfer(TMEMBER(m_ActiveCursor)); + PersistMgr->Transfer(TMEMBER(m_AlphaColor)); + PersistMgr->Transfer(TMEMBER(m_AutoSoundPanning)); + PersistMgr->Transfer(TMEMBER(m_Cursor)); + PersistMgr->Transfer(TMEMBER(m_SharedCursors)); + PersistMgr->Transfer(TMEMBER(m_EditorAlwaysRegister)); + PersistMgr->Transfer(TMEMBER(m_EditorOnly)); + PersistMgr->Transfer(TMEMBER(m_EditorSelected)); + PersistMgr->Transfer(TMEMBER(m_ID)); + PersistMgr->Transfer(TMEMBER(m_Is3D)); + PersistMgr->Transfer(TMEMBER(m_Movable)); + PersistMgr->Transfer(TMEMBER(m_PosX)); + PersistMgr->Transfer(TMEMBER(m_PosY)); + PersistMgr->Transfer(TMEMBER(m_RelativeScale)); + PersistMgr->Transfer(TMEMBER(m_Rotatable)); + PersistMgr->Transfer(TMEMBER(m_Scale)); + PersistMgr->Transfer(TMEMBER(m_SFX)); + PersistMgr->Transfer(TMEMBER(m_SFXStart)); + PersistMgr->Transfer(TMEMBER(m_SFXVolume)); + PersistMgr->Transfer(TMEMBER(m_Ready)); + PersistMgr->Transfer(TMEMBER(m_Rect)); + PersistMgr->Transfer(TMEMBER(m_RectSet)); + PersistMgr->Transfer(TMEMBER(m_Registrable)); + PersistMgr->Transfer(TMEMBER(m_Shadowable)); + PersistMgr->Transfer(TMEMBER(m_SoundEvent)); + PersistMgr->Transfer(TMEMBER(m_Zoomable)); + + PersistMgr->Transfer(TMEMBER(m_ScaleX)); + PersistMgr->Transfer(TMEMBER(m_ScaleY)); + + PersistMgr->Transfer(TMEMBER(m_Rotate)); + PersistMgr->Transfer(TMEMBER(m_RotateValid)); + PersistMgr->Transfer(TMEMBER(m_RelativeRotate)); + + PersistMgr->Transfer(TMEMBER(m_SaveState)); + PersistMgr->Transfer(TMEMBER(m_NonIntMouseEvents)); + + PersistMgr->Transfer(TMEMBER_INT(m_SFXType)); + PersistMgr->Transfer(TMEMBER(m_SFXParam1)); + PersistMgr->Transfer(TMEMBER(m_SFXParam2)); + PersistMgr->Transfer(TMEMBER(m_SFXParam3)); + PersistMgr->Transfer(TMEMBER(m_SFXParam4)); + + + PersistMgr->Transfer(TMEMBER_INT(m_BlendMode)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetCursor(char *Filename) { + if (!m_SharedCursors) { + delete m_Cursor; + m_Cursor = NULL; + } + + m_SharedCursors = false; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile(Filename))) { + delete m_Cursor; + m_Cursor = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetActiveCursor(char *Filename) { + delete m_ActiveCursor; + m_ActiveCursor = new CBSprite(Game); + if (!m_ActiveCursor || FAILED(m_ActiveCursor->LoadFile(Filename))) { + delete m_ActiveCursor; + m_ActiveCursor = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::GetHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::HandleKeypress(SDL_Event *event) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::HandleMouseWheel(int Delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::PlaySFX(char *Filename, bool Looping, bool PlayNow, char *EventName, uint32 LoopStart) { + // just play loaded sound + if (Filename == NULL && m_SFX) { + if (Game->m_EditorMode || m_SFXStart) { + m_SFX->SetVolume(m_SFXVolume); + m_SFX->SetPositionTime(m_SFXStart); + if (!Game->m_EditorMode) m_SFXStart = 0; + } + if (PlayNow) { + SetSoundEvent(EventName); + if (LoopStart) m_SFX->SetLoopStart(LoopStart); + return m_SFX->Play(Looping); + } else return S_OK; + } + + if (Filename == NULL) return E_FAIL; + + // create new sound + delete m_SFX; + + m_SFX = new CBSound(Game); + if (m_SFX && SUCCEEDED(m_SFX->SetSound(Filename, SOUND_SFX, true))) { + m_SFX->SetVolume(m_SFXVolume); + if (m_SFXStart) { + m_SFX->SetPositionTime(m_SFXStart); + m_SFXStart = 0; + } + m_SFX->ApplyFX(m_SFXType, m_SFXParam1, m_SFXParam2, m_SFXParam3, m_SFXParam4); + if (PlayNow) { + SetSoundEvent(EventName); + if (LoopStart) m_SFX->SetLoopStart(LoopStart); + return m_SFX->Play(Looping); + } else return S_OK; + } else { + delete m_SFX; + m_SFX = NULL; + return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::StopSFX(bool DeleteSound) { + if (m_SFX) { + m_SFX->Stop(); + if (DeleteSound) { + delete m_SFX; + m_SFX = NULL; + } + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::PauseSFX() { + if (m_SFX) return m_SFX->Pause(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ResumeSFX() { + if (m_SFX) return m_SFX->Resume(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetSFXTime(uint32 Time) { + m_SFXStart = Time; + if (m_SFX && m_SFX->IsPlaying()) return m_SFX->SetPositionTime(Time); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetSFXVolume(int Volume) { + m_SFXVolume = Volume; + if (m_SFX) return m_SFX->SetVolume(Volume); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::UpdateSounds() { + if (m_SoundEvent) { + if (m_SFX && !m_SFX->IsPlaying()) { + ApplyEvent(m_SoundEvent); + SetSoundEvent(NULL); + } + } + + if (m_SFX) UpdateOneSound(m_SFX); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::UpdateOneSound(CBSound *Sound) { + HRESULT Ret = S_OK; + + if (Sound) { + if (m_AutoSoundPanning) + Ret = Sound->SetPan(Game->m_SoundMgr->PosToPan(m_PosX - Game->m_OffsetX, m_PosY - Game->m_OffsetY)); + + Ret = Sound->ApplyFX(m_SFXType, m_SFXParam1, m_SFXParam2, m_SFXParam3, m_SFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ResetSoundPan() { + if (!m_SFX) return S_OK; + else { + return m_SFX->SetPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::GetExtendedFlag(char *FlagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::IsReady() { + return m_Ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::SetSoundEvent(char *EventName) { + delete[] m_SoundEvent; + m_SoundEvent = NULL; + if (EventName) { + m_SoundEvent = new char[strlen(EventName) + 1]; + if (m_SoundEvent) strcpy(m_SoundEvent, EventName); + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::AfterMove() { + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h new file mode 100644 index 0000000000..064cc78fc4 --- /dev/null +++ b/engines/wintermute/BObject.h @@ -0,0 +1,144 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "SDL.h" +#include "BScriptHolder.h" +#include "persistent.h" + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode m_BlendMode; + virtual HRESULT AfterMove(); + float m_RelativeRotate; + bool m_RotateValid; + float m_Rotate; + void SetSoundEvent(char *EventName); + bool m_Rotatable; + uint32 m_AlphaColor; + float m_Scale; + float m_ScaleX; + float m_ScaleY; + float m_RelativeScale; + virtual bool IsReady(); + virtual bool GetExtendedFlag(char *FlagName); + virtual HRESULT ResetSoundPan(); + virtual HRESULT UpdateSounds(); + HRESULT UpdateOneSound(CBSound *Sound); + bool m_AutoSoundPanning; + uint32 m_SFXStart; + int m_SFXVolume; + HRESULT SetSFXTime(uint32 Time); + HRESULT SetSFXVolume(int Volume); + HRESULT ResumeSFX(); + HRESULT PauseSFX(); + HRESULT StopSFX(bool DeleteSound = true); + HRESULT PlaySFX(char *Filename, bool Looping = false, bool PlayNow = true, char *EventName = NULL, uint32 LoopStart = 0); + CBSound *m_SFX; + + TSFXType m_SFXType; + float m_SFXParam1; + float m_SFXParam2; + float m_SFXParam3; + float m_SFXParam4; + + virtual bool HandleMouseWheel(int Delta); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + virtual bool HandleKeypress(SDL_Event *event); + virtual int GetHeight(); + HRESULT SetCursor(char *Filename); + HRESULT SetActiveCursor(char *Filename); + HRESULT Cleanup(); + char *GetCaption(int Case = 1); + void SetCaption(char *Caption, int Case = 1); + bool m_EditorSelected; + bool m_EditorAlwaysRegister; + bool m_EditorOnly; + bool m_Is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual HRESULT ShowCursor(); + CBSprite *m_Cursor; + bool m_SharedCursors; + CBSprite *m_ActiveCursor; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + bool m_Ready; + bool m_Registrable; + bool m_Zoomable; + bool m_Shadowable; + RECT m_Rect; + bool m_RectSet; + int m_ID; + bool m_Movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *m_Caption[7]; + char *m_SoundEvent; + int m_PosY; + int m_PosX; + bool m_SaveState; + + // base + virtual HRESULT Update() { + return E_FAIL; + }; + virtual HRESULT Display() { + return E_FAIL; + }; + virtual HRESULT InvalidateDeviceObjects() { + return S_OK; + }; + virtual HRESULT RestoreDeviceObjects() { + return S_OK; + }; + bool m_NonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp new file mode 100644 index 0000000000..de8dd140d2 --- /dev/null +++ b/engines/wintermute/BParser.cpp @@ -0,0 +1,435 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BParser.h" +#include "BGame.h" +#include "PlatformSDL.h" +#include "common/str.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + m_WhiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(m_WhiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (m_WhiteSpace != NULL) delete [] m_WhiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetLastOffender() { + return m_LastOffender; +} + + +////////////////////////////////////////////////////////////////////// +long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { + SkipCharacters(buf, m_WhiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + m_ParserLine++; + SkipCharacters(buf, m_WhiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(m_LastOffender, *buf, MIN(255, p - *buf)); + } else strcpy(m_LastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + SkipCharacters(buf, m_WhiteSpace); + + // get optional name + *name = GetSubText(buf, '\'', '\''); // single quotes + SkipCharacters(buf, m_WhiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = GetAssignmentText(buf); + else + *data = GetSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + Game->MiniUpdate(); + char *name; + return GetObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::SkipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') m_ParserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetAssignmentText(char **buf) { + ++*buf; // skip the '=' + SkipCharacters(buf, m_WhiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = GetSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::GetToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::GetTokenFloat(char **buf) { + char *t = GetToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::GetTokenInt(char **buf) { + char *t = GetToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::SkipToken(char **buf, char *tok, char * /*msg*/) { + char *t = GetToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::ScanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BParser.h b/engines/wintermute/BParser.h new file mode 100644 index 0000000000..6e4282c833 --- /dev/null +++ b/engines/wintermute/BParser.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "BBase.h" +#include "coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + long id; + const char *token; + }; + +public: + int ScanStr(const char *in, const char *format, ...); + char *GetLastOffender(); + void SkipToken(char **buf, char *tok, char *msg = NULL); + int GetTokenInt(char **buf); + float GetTokenFloat(char **buf); + char *GetToken(char **buf); + char *GetAssignmentText(char **buf); + char *GetSubText(char **buf, char open, char close); + void SkipCharacters(char **buf, const char *toSkip); + long GetCommand(char **buf, TokenDesc *tokens, char **params); + long GetObject(char **buf, TokenDesc *tokens, char **name, char **data); + int m_ParserLine; + char m_LastOffender[255]; + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); + char *m_WhiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp new file mode 100644 index 0000000000..e4002d9299 --- /dev/null +++ b/engines/wintermute/BPersistMgr.cpp @@ -0,0 +1,517 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFileManager.h" +#include "BGame.h" +#include "BPersistMgr.h" +#include "BSaveThumbHelper.h" +#include "PlatformSDL.h" +#include "Vector2.h" +#include "StringUtil.h" +#include "BImage.h" +#include "BSound.h" +#include "common/str.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { + m_Saving = false; + m_Buffer = NULL; + m_BufferSize = 0; + m_Offset = 0; + + m_RichBuffer = NULL; + m_RichBufferSize = 0; + + m_SavedDescription = NULL; + m_SavedTimestamp = 0; + m_SavedVerMajor = m_SavedVerMinor = m_SavedVerBuild = 0; + m_SavedExtMajor = m_SavedExtMinor = 0; + + m_ThumbnailDataSize = 0; + m_ThumbnailData = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::Cleanup() { + if (m_Buffer) { + if (m_Saving) free(m_Buffer); + else delete [] m_Buffer; // allocated by file manager + } + m_Buffer = NULL; + + m_BufferSize = 0; + m_Offset = 0; + + delete[] m_RichBuffer; + m_RichBuffer = NULL; + m_RichBufferSize = 0; + + m_SavedDescription = NULL; // ref to buffer + m_SavedTimestamp = 0; + m_SavedVerMajor = m_SavedVerMinor = m_SavedVerBuild = 0; + m_SavedExtMajor = m_SavedExtMinor = 0; + + m_ThumbnailDataSize = 0; + if (m_ThumbnailData) { + delete [] m_ThumbnailData; + m_ThumbnailData = NULL; + } +} + +// TODO: This is not at all endian-safe +uint32 makeUint32(byte first, byte second, byte third, byte fourth) { + uint32 retVal = first; + retVal = retVal & second << 8 & third << 16 & fourth << 24; + return retVal; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::InitSave(char *Desc) { + if (!Desc) return E_FAIL; + + HRESULT res; + + Cleanup(); + m_Saving = true; + + m_Buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); + if (m_Buffer) { + m_BufferSize = SAVE_BUFFER_INIT_SIZE; + res = S_OK; + } else res = E_FAIL; + + + if (SUCCEEDED(res)) { + // get thumbnails + if (!Game->m_CachedThumbnail) { + Game->m_CachedThumbnail = new CBSaveThumbHelper(Game); + if (FAILED(Game->m_CachedThumbnail->StoreThumbnail(true))) { + delete Game->m_CachedThumbnail; + Game->m_CachedThumbnail = NULL; + } + } + + + uint32 magic = DCGF_MAGIC; + PutDWORD(magic); + + magic = SAVE_MAGIC_2; + PutDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + uint32 Version = makeUint32(VerMajor, VerMinor, ExtMajor, ExtMinor); + PutDWORD(Version); + + // new in ver 2 + PutDWORD((uint32)DCGF_VER_BUILD); + PutString(Game->m_Name); + + // thumbnail data size + bool ThumbnailOK = false; + + if (Game->m_CachedThumbnail) { + if (Game->m_CachedThumbnail->m_Thumbnail) { + uint32 Size = 0; + byte *Buffer = Game->m_CachedThumbnail->m_Thumbnail->CreateBMPBuffer(&Size); + + PutDWORD(Size); + if (Size > 0) PutBytes(Buffer, Size); + + delete [] Buffer; + ThumbnailOK = true; + } + } + if (!ThumbnailOK) PutDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete Game->m_CachedThumbnail; + Game->m_CachedThumbnail = NULL; + + uint32 DataOffset = m_Offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(Desc) + 1 + // description + sizeof(uint32); // timestamp + + PutDWORD(DataOffset); + PutString(Desc); + + time_t Timestamp; + time(&Timestamp); + PutDWORD((uint32)Timestamp); + } + return res; +} +// TODO: Do this properly, this is just a quickfix, that probably doesnt even work. +// The main point of which is ditching BASS completely. +byte getLowByte(uint16 word) { + uint16 mask = 0xff; + return word & mask; +} + +byte getHighByte(uint16 word) { + uint16 mask = 0xff << 8; + word = word & mask; + return word >> 8; +} + +uint16 getLowWord(uint32 dword) { + uint32 mask = 0xffff; + return dword & mask; +} + +uint16 getHighWord(uint32 dword) { + uint32 mask = 0xffff << 16; + dword = dword & mask; + return dword >> 16; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::InitLoad(char *Filename) { + Cleanup(); + + m_Saving = false; + + m_Buffer = Game->m_FileManager->ReadWholeFile(Filename, &m_BufferSize); + if (m_Buffer) { + uint32 Magic; + Magic = GetDWORD(); + if (Magic != DCGF_MAGIC) goto init_fail; + + Magic = GetDWORD(); + + if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { + uint32 Version = GetDWORD(); + m_SavedVerMajor = getLowByte(getLowWord(Version)); + m_SavedVerMinor = getHighByte(getLowWord(Version)); + m_SavedExtMajor = getLowByte(getHighWord(Version)); + m_SavedExtMinor = getHighByte(getHighWord(Version)); + + if (Magic == SAVE_MAGIC_2) { + m_SavedVerBuild = (byte )GetDWORD(); + char *SavedName = GetString(); + if (SavedName == NULL || scumm_stricmp(SavedName, Game->m_Name) != 0) { + Game->LOG(0, "ERROR: Saved game name doesn't match current game"); + goto init_fail; + } + + // load thumbnail + m_ThumbnailDataSize = GetDWORD(); + if (m_ThumbnailDataSize > 0) { + m_ThumbnailData = new byte[m_ThumbnailDataSize]; + if (m_ThumbnailData) { + GetBytes(m_ThumbnailData, m_ThumbnailDataSize); + } else m_ThumbnailDataSize = 0; + } + } else m_SavedVerBuild = 35; // last build with ver1 savegames + + + // if save is newer version than we are, fail + if (m_SavedVerMajor > DCGF_VER_MAJOR || + (m_SavedVerMajor == DCGF_VER_MAJOR && m_SavedVerMinor > DCGF_VER_MINOR) || + (m_SavedVerMajor == DCGF_VER_MAJOR && m_SavedVerMinor == DCGF_VER_MINOR && m_SavedVerBuild > DCGF_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game version is newer than current game"); + goto init_fail; + } + + // if save is older than the minimal version we support + if (m_SavedVerMajor < SAVEGAME_VER_MAJOR || + (m_SavedVerMajor == SAVEGAME_VER_MAJOR && m_SavedVerMinor < SAVEGAME_VER_MINOR) || + (m_SavedVerMajor == SAVEGAME_VER_MAJOR && m_SavedVerMinor == SAVEGAME_VER_MINOR && m_SavedVerBuild < SAVEGAME_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + goto init_fail; + } + + /* + if( m_SavedVerMajor != DCGF_VER_MAJOR || m_SavedVerMinor != DCGF_VER_MINOR) + { + Game->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + } else goto init_fail; + + + uint32 DataOffset = GetDWORD(); + + m_SavedDescription = GetString(); + m_SavedTimestamp = (time_t)GetDWORD(); + + m_Offset = DataOffset; + + return S_OK; + } + +init_fail: + Cleanup(); + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::SaveFile(char *Filename) { + return Game->m_FileManager->SaveFile(Filename, m_Buffer, m_Offset, Game->m_CompressedSavegames, m_RichBuffer, m_RichBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { + while (m_Offset + Size > m_BufferSize) { + m_BufferSize += SAVE_BUFFER_GROW_BY; + m_Buffer = (byte *)realloc(m_Buffer, m_BufferSize); + if (!m_Buffer) { + Game->LOG(0, "Error reallocating save buffer to %d bytes", m_BufferSize); + return E_FAIL; + } + } + + memcpy(m_Buffer + m_Offset, Buffer, Size); + m_Offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { + if (m_Offset + Size > m_BufferSize) { + Game->LOG(0, "Fatal: Save buffer underflow"); + return E_FAIL; + } + + memcpy(Buffer, m_Buffer + m_Offset, Size); + m_Offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::PutDWORD(uint32 Val) { + PutBytes((byte *)&Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::GetDWORD() { + uint32 ret; + GetBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::PutString(const char *Val) { + if (!Val) PutString("(null)"); + else { + PutDWORD(strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::GetString() { + uint32 len = GetDWORD(); + char *ret = (char *)(m_Buffer + m_Offset); + m_Offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + +////////////////////////////////////////////////////////////////////////// +// bool +HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(bool)); + else return GetBytes((byte *)Val, sizeof(bool)); +} + + +////////////////////////////////////////////////////////////////////////// +// int +HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(int)); + else return GetBytes((byte *)Val, sizeof(int)); +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(uint32)); + else return GetBytes((byte *)Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +// float +HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(float)); + else return GetBytes((byte *)Val, sizeof(float)); +} + + +////////////////////////////////////////////////////////////////////////// +// double +HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(double)); + else return GetBytes((byte *)Val, sizeof(double)); +} + + +////////////////////////////////////////////////////////////////////////// +// char* +HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { + if (m_Saving) { + PutString(*Val); + return S_OK; + } else { + char *str = GetString(); + if (str) { + + *Val = new char[strlen(str) + 1]; + strcpy(*Val, str); + } else *Val = NULL; + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { + size_t size; + + if (m_Saving) { + size = Val.size(); + PutBytes((byte *)&size, sizeof(size_t)); + + for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { + PutString((*it).c_str()); + } + } else { + Val.clear(); + GetBytes((byte *)&size, sizeof(size_t)); + + for (size_t i = 0; i < size; i++) { + char *str = GetString(); + if (str) Val.push_back(str); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(byte )); + else return GetBytes((byte *)Val, sizeof(byte )); +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(RECT)); + else return GetBytes((byte *)Val, sizeof(RECT)); +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(POINT)); + else return GetBytes((byte *)Val, sizeof(POINT)); +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { + if (m_Saving) return PutBytes((byte *)Val, sizeof(Vector2)); + else return GetBytes((byte *)Val, sizeof(Vector2)); +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { + int ClassID = -1, InstanceID = -1; + + if (m_Saving) { + CSysClassRegistry::GetInstance()->GetPointerID(*(void **)Val, &ClassID, &InstanceID); + if (*(void **)Val != NULL && (ClassID == -1 || InstanceID == -1)) { + Game->LOG(0, "Warning: invalid instance '%s'", Name); + } + + PutDWORD(ClassID); + PutDWORD(InstanceID); + } else { + ClassID = GetDWORD(); + InstanceID = GetDWORD(); + + *(void **)Val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild) { + if (m_Saving) return true; + + // it's ok if we are same or newer than the saved game + if (VerMajor > m_SavedVerMajor || + (VerMajor == m_SavedVerMajor && VerMinor > m_SavedVerMinor) || + (VerMajor == m_SavedVerMajor && VerMinor == m_SavedVerMinor && VerBuild > m_SavedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h new file mode 100644 index 0000000000..6a1e42da8a --- /dev/null +++ b/engines/wintermute/BPersistMgr.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "BBase.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *m_SavedDescription; + time_t m_SavedTimestamp; + byte m_SavedVerMajor; + byte m_SavedVerMinor; + byte m_SavedVerBuild; + byte m_SavedExtMajor; + byte m_SavedExtMinor; + HRESULT SaveFile(char *Filename); + uint32 GetDWORD(); + void PutDWORD(uint32 Val); + char *GetString(); + void PutString(const char *Val); + void Cleanup(); + HRESULT InitLoad(char *Filename); + HRESULT InitSave(char *Desc); + HRESULT GetBytes(byte *Buffer, uint32 Size); + HRESULT PutBytes(byte *Buffer, uint32 Size); + uint32 m_Offset; + uint32 m_BufferSize; + byte *m_Buffer; + bool m_Saving; + + uint32 m_RichBufferSize; + byte *m_RichBuffer; + + HRESULT Transfer(const char *Name, void *Val); + HRESULT Transfer(const char *Name, int *Val); + HRESULT Transfer(const char *Name, uint32 *Val); + HRESULT Transfer(const char *Name, float *Val); + HRESULT Transfer(const char *Name, double *Val); + HRESULT Transfer(const char *Name, bool *Val); + HRESULT Transfer(const char *Name, byte *Val); + HRESULT Transfer(const char *Name, RECT *Val); + HRESULT Transfer(const char *Name, POINT *Val); + HRESULT Transfer(const char *Name, char **Val); + HRESULT Transfer(const char *Name, Vector2 *Val); + HRESULT Transfer(const char *Name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL); + virtual ~CBPersistMgr(); + bool CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild); + + uint32 m_ThumbnailDataSize; + byte *m_ThumbnailData; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h new file mode 100644 index 0000000000..aaa5176bcf --- /dev/null +++ b/engines/wintermute/BScriptHolder.h @@ -0,0 +1,81 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "coll_templ.h" +#include "persistent.h" +// TODO: Reinclude any of this. +//#include "BScriptable.h" + +namespace WinterMute { + +//class CBScriptHolder : public CBScriptable { +class CBScriptHolder : CBBase { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBBase) // <- TODO, quickfix for compile +#if 0 + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + + virtual CScScript *InvokeMethodThread(char *MethodName); + virtual void MakeFreezable(bool Freezable); + bool CanHandleEvent(char *EventName); + virtual bool CanHandleMethod(char *EventMethod); + HRESULT Cleanup(); + HRESULT RemoveScript(CScScript *Script); + HRESULT AddScript(char *Filename); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); + void SetFilename(char *Filename); + HRESULT ParseProperty(byte *Buffer, bool Complete = true); + + char *m_Filename; + bool m_Freezable; + bool m_Ready; + CBArray m_Scripts; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + virtual void ScDebuggerDesc(char *Buf, int BufSize); +#endif + // IWmeObject +public: + virtual bool SendEvent(const char *EventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h new file mode 100644 index 0000000000..029902fab9 --- /dev/null +++ b/engines/wintermute/PlatformSDL.h @@ -0,0 +1,92 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PLATFORMSDL_H +#define WINTERMUTE_PLATFORMSDL_H + +#include "dctypes.h" + +#include "wintypes.h" + +union SDL_Event; + +namespace WinterMute { + +class CBGame; + + +////////////////////////////////////////////////////////////////////////// +class CBPlatform { +public: + static int Initialize(CBGame *inGame, int argc, char *argv[]); + static int MessageLoop(); + static void HandleEvent(SDL_Event *event); + + static AnsiString GetSystemFontPath(); + static AnsiString GetPlatformName(); + + // Win32 API bindings + static HINSTANCE ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd); + static void OutputDebugString(LPCSTR lpOutputString); + static uint32 GetTime(); + static BOOL GetCursorPos(LPPOINT lpPoint); + static BOOL SetCursorPos(int X, int Y); + static BOOL ShowWindow(HWND hWnd, int nCmdShow); + static bool DeleteFile(const char *lpFileName); + static bool CopyFile(const char *from, const char *to, bool failIfExists); + static HWND SetCapture(HWND hWnd); + static BOOL ReleaseCapture(); + static BOOL SetForegroundWindow(HWND hWnd); + + static BOOL SetRectEmpty(LPRECT lprc); + static BOOL IsRectEmpty(const LPRECT lprc); + static BOOL PtInRect(LPRECT lprc, POINT p); + static BOOL SetRect(LPRECT lprc, int left, int top, int right, int bottom); + static BOOL IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); + static BOOL UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); + static BOOL CopyRect(LPRECT lprcDst, RECT *lprcSrc); + static BOOL OffsetRect(LPRECT lprc, int dx, int dy); + static BOOL EqualRect(LPRECT rect1, LPRECT rect2); + + + // string functions +// static int stricmp(const char *str1, const char *str2); +// static int strnicmp(const char *str1, const char *str2, size_t maxCount); + static char *strupr(char *string); + static char *strlwr(char *string); + + // sdl event callback + static int SDLEventWatcher(void *userdata, SDL_Event *event); + +private: + static CBGame *Game; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp new file mode 100644 index 0000000000..a673943b57 --- /dev/null +++ b/engines/wintermute/SysClass.cpp @@ -0,0 +1,203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "persistent.h" +#include "SysInstance.h" +#include "SysClass.h" +#include "SysClassRegistry.h" +#include "BGame.h" +#include "BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { + m_Name = name; + + m_Build = build; + m_Load = load; + m_Next = NULL; + m_SavedID = -1; + m_Persistent = persistent_class; + m_NumInst = 0; + + CSysClassRegistry::GetInstance()->RegisterClass(this); +} + + +////////////////////////////////////////////////////////////////////////// +CSysClass::~CSysClass() { + CSysClassRegistry::GetInstance()->UnregisterClass(this); + RemoveAllInstances(); +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::RemoveAllInstances() { + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + delete(*it); + } + m_Instances.clear(); + m_InstanceMap.clear(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { + CSysInstance *inst = new CSysInstance(instance, id, this); + inst->SetSavedID(savedId); + m_Instances.insert(inst); + + m_InstanceMap[instance] = inst; + + CSysClassRegistry::GetInstance()->AddInstanceToTable(inst, instance); + + return inst; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::RemoveInstance(void *instance) { + InstanceMap::iterator mapIt = m_InstanceMap.find(instance); + if (mapIt == m_InstanceMap.end()) return false; + + Instances::iterator it = m_Instances.find((*mapIt).second); + if (it != m_Instances.end()) { + delete(*it); + m_Instances.erase(it); + } + + m_InstanceMap.erase(mapIt); + + return false; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::GetInstanceID(void *pointer) { + InstanceMap::iterator mapIt = m_InstanceMap.find(pointer); + if (mapIt == m_InstanceMap.end()) return -1; + else return (*mapIt).second->GetID(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClass::IDToPointer(int savedID) { + //slow + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::GetNumInstances() { + return m_Instances.size(); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::Dump(FILE *stream) { + fprintf(stream, "%03d %c %-20s instances: %d\n", m_ID, m_Persistent ? 'p' : ' ', m_Name.c_str(), GetNumInstances()); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { + PersistMgr->PutString(m_Name.c_str()); + PersistMgr->PutDWORD(m_ID); + PersistMgr->PutDWORD(m_Instances.size()); + + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + PersistMgr->PutDWORD((*it)->GetID()); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { + m_SavedID = PersistMgr->GetDWORD(); + int numInstances = PersistMgr->GetDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (m_Persistent) { + int instId = PersistMgr->GetDWORD(); + + if (i > 0) { + Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", m_Name.c_str(), numInstances); + continue; + } + + Instances::iterator it = m_Instances.begin(); + if (it != m_Instances.end()) { + (*it)->SetSavedID(instId); + CSysClassRegistry::GetInstance()->AddInstanceToTable((*it), (*it)->GetInstance()); + } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, m_Name.c_str()); + } + // normal instances, create empty objects + else { + void *emptyObject = m_Build(); + AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); + } + + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + // write instace header + PersistMgr->PutDWORD(m_ID); + PersistMgr->PutDWORD((*it)->GetID()); + + m_Load((*it)->GetInstance(), PersistMgr); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { + m_Load(instance, PersistMgr); +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClass::ResetSavedIDs() { + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + (*it)->SetSavedID(-1); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { + Instances::iterator it; + for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + lpCallback((*it)->GetInstance(), lpData); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h new file mode 100644 index 0000000000..21d4acd594 --- /dev/null +++ b/engines/wintermute/SysClass.h @@ -0,0 +1,101 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeSysClass_H__ +#define __WmeSysClass_H__ + +#include "persistent.h" +#include +#include +#include "dctypes.h" + +namespace WinterMute { +class CSysInstance; +class CBGame; +class CBPersistMgr; +class CSysClass { +public: + CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); + ~CSysClass(); + + int GetNumInstances(); + bool RemoveInstance(void *instance); + CSysInstance *AddInstance(void *instance, int id, int savedId = -1); + bool RemoveAllInstances(); + + int GetInstanceID(void *pointer); + void *IDToPointer(int savedID); + + void SetID(int id) { + m_ID = id; + } + int GetID() const { + return m_ID; + } + + int GetSavedID() const { + return m_SavedID; + } + + bool IsPersistent() const { + return m_Persistent; + } + + AnsiString GetName() const { + return m_Name; + } + + void SaveTable(CBGame *Game, CBPersistMgr *PersistMgr); + void LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); + + void SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr); + void LoadInstance(void *instance, CBPersistMgr *PersistMgr); + + void InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + + void ResetSavedIDs(); + + void Dump(FILE *stream); + +private: + int m_NumInst; + bool m_Persistent; + CSysClass *m_Next; + int m_ID; + int m_SavedID; + AnsiString m_Name; + PERSISTBUILD m_Build; + PERSISTLOAD m_Load; + + typedef std::set Instances; + Instances m_Instances; + + typedef std::map InstanceMap; + InstanceMap m_InstanceMap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp new file mode 100644 index 0000000000..72740a79cf --- /dev/null +++ b/engines/wintermute/SysClassRegistry.cpp @@ -0,0 +1,287 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "BGame.h" +#include "PlatformSDL.h" +#include "SysInstance.h" +#include "SysClassRegistry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::CSysClassRegistry() { +} + + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::~CSysClassRegistry() { + +} + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry *CSysClassRegistry::GetInstance() { + static CSysClassRegistry classReg; + return &classReg; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { + classObj->SetID(m_Count++); + m_Classes.insert(classObj); + + m_NameMap[classObj->GetName()] = classObj; + m_IdMap[classObj->GetID()] = classObj; + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { + + Classes::iterator it = m_Classes.find(classObj); + if (it == m_Classes.end()) return false; + + if (classObj->GetNumInstances() != 0) { + char str[MAX_PATH]; + sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->GetName().c_str(), classObj->GetNumInstances()); + CBPlatform::OutputDebugString(str); + } + m_Classes.erase(it); + + NameMap::iterator mapIt = m_NameMap.find(classObj->GetName()); + if (mapIt != m_NameMap.end()) m_NameMap.erase(mapIt); + + IdMap::iterator idIt = m_IdMap.find(classObj->GetID()); + if (idIt != m_IdMap.end()) m_IdMap.erase(idIt); + + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) { + if (m_Disabled) return true; + + NameMap::iterator mapIt = m_NameMap.find(className); + if (mapIt == m_NameMap.end()) return false; + + CSysInstance *inst = (*mapIt).second->AddInstance(instance, m_Count++); + return (inst != NULL); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::AddInstanceToTable(CSysInstance *instance, void *pointer) { + m_InstanceMap[pointer] = instance; + + if (instance->GetSavedID() >= 0) + m_SavedInstanceMap[instance->GetSavedID()] = instance; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClassRegistry::GetNextID() { + return m_Count++; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { + NameMap::iterator mapIt = m_NameMap.find(className); + if (mapIt == m_NameMap.end()) return false; + (*mapIt).second->RemoveInstance(instance); + + InstanceMap::iterator instIt = m_InstanceMap.find(instance); + if (instIt != m_InstanceMap.end()) { + m_InstanceMap.erase(instIt); + return true; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceID) { + if (pointer == NULL) return true; + + InstanceMap::iterator it = m_InstanceMap.find(pointer); + if (it == m_InstanceMap.end()) return false; + + + CSysInstance *inst = (*it).second; + *instanceID = inst->GetID(); + *classID = inst->GetClass()->GetID(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { + SavedInstanceMap::iterator it = m_SavedInstanceMap.find(instanceID); + if (it == m_SavedInstanceMap.end()) return NULL; + else return (*it).second->GetInstance(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { + PersistMgr->PutDWORD(m_Classes.size()); + + int counter = 0; + + Classes::iterator it; + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + counter++; + + if (!quickSave) { + Game->m_IndicatorProgress = 50.0f / (float)((float)m_Classes.size() / (float)counter); + Game->DisplayContent(false); + Game->m_Renderer->Flip(); + } + + (*it)->SaveTable(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { + Classes::iterator it; + + // reset SavedID of current instances + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + (*it)->ResetSavedIDs(); + } + + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + if ((*it)->IsPersistent()) continue; + (*it)->RemoveAllInstances(); + } + + m_InstanceMap.clear(); + + + int numClasses = PersistMgr->GetDWORD(); + + for (int i = 0; i < numClasses; i++) { + Game->m_IndicatorProgress = 50.0f / (float)((float)numClasses / (float)i); + Game->DisplayContentSimple(); + Game->m_Renderer->Flip(); + + char *className = PersistMgr->GetString(); + NameMap::iterator mapIt = m_NameMap.find(className); + if (mapIt != m_NameMap.end())(*mapIt).second->LoadTable(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { + + Classes::iterator it; + + // count total instances + int numInstances = 0; + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + numInstances += (*it)->GetNumInstances(); + } + + PersistMgr->PutDWORD(numInstances); + + int counter = 0; + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + counter++; + + if (!quickSave) { + if (counter % 20 == 0) { + Game->m_IndicatorProgress = 50 + 50.0f / (float)((float)m_Classes.size() / (float)counter); + Game->DisplayContent(false); + Game->m_Renderer->Flip(); + } + } + Game->MiniUpdate(); + + (*it)->SaveInstances(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) { + // get total instances + int numInstances = PersistMgr->GetDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (i % 20 == 0) { + Game->m_IndicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); + Game->DisplayContentSimple(); + Game->m_Renderer->Flip(); + } + + int classID = PersistMgr->GetDWORD(); + int instanceID = PersistMgr->GetDWORD(); + void *instance = IDToPointer(classID, instanceID); + + + Classes::iterator it; + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + if ((*it)->GetSavedID() == classID) { + (*it)->LoadInstance(instance, PersistMgr); + } + } + } + + m_SavedInstanceMap.clear(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { + NameMap::iterator mapIt = m_NameMap.find(className); + if (mapIt == m_NameMap.end()) return E_FAIL; + + (*mapIt).second->InstanceCallback(lpCallback, lpData); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::DumpClasses(FILE *stream) { + Classes::iterator it; + for (it = m_Classes.begin(); it != m_Classes.end(); ++it) + (*it)->Dump(stream); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h new file mode 100644 index 0000000000..1a73f28010 --- /dev/null +++ b/engines/wintermute/SysClassRegistry.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASSREGISTRY_H +#define WINTERMUTE_SYSCLASSREGISTRY_H + +#include "wintypes.h" +#include "dctypes.h" +#include "persistent.h" +#include +#include + +namespace WinterMute { + +class CBGame; +class CBPersistMgr; +class CSysClass; +class CSysInstance; + +class CSysClassRegistry { +public: + static CSysClassRegistry *GetInstance(); + + HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + HRESULT LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + void *IDToPointer(int classID, int instanceID); + bool GetPointerID(void *pointer, int *classID, int *instanceID); + bool RegisterClass(CSysClass *classObj); + bool UnregisterClass(CSysClass *classObj); + bool RegisterInstance(const char *className, void *instance); + bool UnregisterInstance(const char *className, void *instance); + void DumpClasses(FILE *stream); + int GetNextID(); + void AddInstanceToTable(CSysInstance *instance, void *pointer); + + CSysClassRegistry(); + virtual ~CSysClassRegistry(); + + bool m_Disabled; + int m_Count; + + typedef std::set Classes; + Classes m_Classes; + + typedef std::map NameMap; + NameMap m_NameMap; + + typedef std::map IdMap; + IdMap m_IdMap; + + typedef std::map InstanceMap; + InstanceMap m_InstanceMap; + + typedef std::map SavedInstanceMap; + SavedInstanceMap m_SavedInstanceMap; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/SysInstance.cpp b/engines/wintermute/SysInstance.cpp new file mode 100644 index 0000000000..b937136706 --- /dev/null +++ b/engines/wintermute/SysInstance.cpp @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SysInstance.h" +#include "SysClass.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysInstance::CSysInstance(void *Instance, int ID, CSysClass *sysClass) { + m_Instance = Instance; + m_ID = ID; + m_SavedID = -1; + m_Class = sysClass; + + m_Used = false; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance::~CSysInstance() { +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/SysInstance.h b/engines/wintermute/SysInstance.h new file mode 100644 index 0000000000..0286204c8e --- /dev/null +++ b/engines/wintermute/SysInstance.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSINSTANCE_H +#define WINTERMUTE_SYSINSTANCE_H + +namespace WinterMute { + +class CSysClass; + +class CSysInstance { +public: + CSysInstance(void *Instance, int ID, CSysClass *sysClass); + virtual ~CSysInstance(); + + int GetID() const { + return m_ID; + } + int GetSavedID() const { + return m_SavedID; + } + void *GetInstance() const { + return m_Instance; + } + CSysClass *GetClass() const { + return m_Class; + } + + void SetSavedID(int id) { + m_SavedID = id; + } + +private: + bool m_Used; + int m_ID; + int m_SavedID; + void *m_Instance; + CSysClass *m_Class; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h new file mode 100644 index 0000000000..bcd11126a9 --- /dev/null +++ b/engines/wintermute/coll_templ.h @@ -0,0 +1,372 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_COLL_TEMPL_H +#define WINTERMUTE_COLL_TEMPL_H + + +#include +#include "BPersistMgr.h" + +namespace WinterMute { + +///////////////////////////////////////////////////////////////////////////// +template +inline void DCConstructElements(TYPE *pElements, int nCount) { + // first do bit-wise zero initialization + memset((void *)pElements, 0, nCount * sizeof(TYPE)); + + // then call the constructor(s) + for (; nCount--; pElements++) + ::new((void *)pElements) TYPE; +} + +///////////////////////////////////////////////////////////////////////////// +template +inline void DCDestructElements(TYPE *pElements, int nCount) { + // call the destructor(s) + for (; nCount--; pElements++) + pElements->~TYPE(); +} + +///////////////////////////////////////////////////////////////////////////// +template +inline void DCCopyElements(TYPE *pDest, const TYPE *pSrc, int nCount) { + // default is element-copy using assignment + while (nCount--) + *pDest++ = *pSrc++; +} + +///////////////////////////////////////////////////////////////////////////// +template +BOOL DCCompareElements(const TYPE *pElement1, const ARG_TYPE *pElement2) { + return *pElement1 == *pElement2; +} + +//class CBPersistMgr; + +///////////////////////////////////////////////////////////////////////////// +// CBArray +///////////////////////////////////////////////////////////////////////////// +template +class CBArray { +public: +// Construction + CBArray(); + +// Attributes + int GetSize() const; + int GetUpperBound() const; + void SetSize(int nNewSize, int nGrowBy = -1); + +// Operations + // Clean up + void FreeExtra(); + void RemoveAll(); + HRESULT Persist(CBPersistMgr *PersistMgr); + + // Accessing elements + TYPE GetAt(int nIndex) const; + void SetAt(int nIndex, ARG_TYPE newElement); + TYPE &ElementAt(int nIndex); + + // Direct Access to the element data (may return NULL) + const TYPE *GetData() const; + TYPE *GetData(); + + // Potentially growing the array + void SetAtGrow(int nIndex, ARG_TYPE newElement); + int Add(ARG_TYPE newElement); + int Append(const CBArray &src); + void Copy(const CBArray &src); + + // overloaded operator helpers + TYPE operator[](int nIndex) const; + TYPE &operator[](int nIndex); + + // Operations that move elements around + void InsertAt(int nIndex, ARG_TYPE newElement, int nCount = 1); + void RemoveAt(int nIndex, int nCount = 1); + void InsertAt(int nStartIndex, CBArray *pNewArray); + +// Implementation +protected: + TYPE *m_pData; // the actual array of data + int m_nSize; // # of elements (upperBound - 1) + int m_nMaxSize; // max allocated + int m_nGrowBy; // grow amount + +public: + ~CBArray(); +}; + +///////////////////////////////////////////////////////////////////////////// +// CBArray inline functions +///////////////////////////////////////////////////////////////////////////// +template +inline int CBArray::GetSize() const { + return m_nSize; +} +template +inline int CBArray::GetUpperBound() const { + return m_nSize - 1; +} +template +inline void CBArray::RemoveAll() { + SetSize(0, -1); +} +template +inline TYPE CBArray::GetAt(int nIndex) const { + return m_pData[nIndex]; +} +template +inline void CBArray::SetAt(int nIndex, ARG_TYPE newElement) { + m_pData[nIndex] = newElement; +} +template +inline TYPE &CBArray::ElementAt(int nIndex) { + return m_pData[nIndex]; +} +template +inline const TYPE *CBArray::GetData() const { + return (const TYPE *)m_pData; +} +template +inline TYPE *CBArray::GetData() { + return (TYPE *)m_pData; +} +template +inline int CBArray::Add(ARG_TYPE newElement) { + int nIndex = m_nSize; + SetAtGrow(nIndex, newElement); + return nIndex; +} +template +inline TYPE CBArray::operator[](int nIndex) const { + return GetAt(nIndex); +} +template +inline TYPE &CBArray::operator[](int nIndex) { + return ElementAt(nIndex); +} + +///////////////////////////////////////////////////////////////////////////// +// CBArray out-of-line functions +///////////////////////////////////////////////////////////////////////////// +template +CBArray::CBArray() { + m_pData = NULL; + m_nSize = m_nMaxSize = m_nGrowBy = 0; +} + +///////////////////////////////////////////////////////////////////////////// +template +CBArray::~CBArray() { + if (m_pData != NULL) { + DCDestructElements(m_pData, m_nSize); + delete[](byte *)m_pData; + } +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::SetSize(int nNewSize, int nGrowBy) { + if (nGrowBy != -1) + m_nGrowBy = nGrowBy; // set new size + + if (nNewSize == 0) { + // shrink to nothing + if (m_pData != NULL) { + DCDestructElements(m_pData, m_nSize); + delete[](byte *)m_pData; + m_pData = NULL; + } + m_nSize = m_nMaxSize = 0; + } else if (m_pData == NULL) { + // create one with exact size + m_pData = (TYPE *) new byte[nNewSize * sizeof(TYPE)]; + DCConstructElements(m_pData, nNewSize); + m_nSize = m_nMaxSize = nNewSize; + } else if (nNewSize <= m_nMaxSize) { + // it fits + if (nNewSize > m_nSize) { + // initialize the new elements + DCConstructElements(&m_pData[m_nSize], nNewSize - m_nSize); + } else if (m_nSize > nNewSize) { + // destroy the old elements + DCDestructElements(&m_pData[nNewSize], m_nSize - nNewSize); + } + m_nSize = nNewSize; + } else { + // otherwise, grow array + int nGrowBy = m_nGrowBy; + if (nGrowBy == 0) { + // heuristically determine growth when nGrowBy == 0 + // (this avoids heap fragmentation in many situations) + nGrowBy = m_nSize / 8; + nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy); + } + int nNewMax; + if (nNewSize < m_nMaxSize + nGrowBy) + nNewMax = m_nMaxSize + nGrowBy; // granularity + else + nNewMax = nNewSize; // no slush + + TYPE *pNewData = (TYPE *) new byte[nNewMax * sizeof(TYPE)]; + + // copy new data from old + memcpy(pNewData, m_pData, m_nSize * sizeof(TYPE)); + + // construct remaining elements + DCConstructElements(&pNewData[m_nSize], nNewSize - m_nSize); + + // get rid of old stuff (note: no destructors called) + delete[](byte *)m_pData; + m_pData = pNewData; + m_nSize = nNewSize; + m_nMaxSize = nNewMax; + } +} + +///////////////////////////////////////////////////////////////////////////// +template +int CBArray::Append(const CBArray &src) { + int nOldSize = m_nSize; + SetSize(m_nSize + src.m_nSize); + DCCopyElements(m_pData + nOldSize, src.m_pData, src.m_nSize); + return nOldSize; +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::Copy(const CBArray &src) { + SetSize(src.m_nSize); + DCCopyElements(m_pData, src.m_pData, src.m_nSize); +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::FreeExtra() { + if (m_nSize != m_nMaxSize) { + // shrink to desired size + TYPE *pNewData = NULL; + if (m_nSize != 0) { + pNewData = (TYPE *) new byte[m_nSize * sizeof(TYPE)]; + // copy new data from old + memcpy(pNewData, m_pData, m_nSize * sizeof(TYPE)); + } + + // get rid of old stuff (note: no destructors called) + delete[](byte *)m_pData; + m_pData = pNewData; + m_nMaxSize = m_nSize; + } +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::SetAtGrow(int nIndex, ARG_TYPE newElement) { + if (nIndex >= m_nSize) + SetSize(nIndex + 1, -1); + m_pData[nIndex] = newElement; +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::InsertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { + if (nIndex >= m_nSize) { + // adding after the end of the array + SetSize(nIndex + nCount, -1); // grow so nIndex is valid + } else { + // inserting in the middle of the array + int nOldSize = m_nSize; + SetSize(m_nSize + nCount, -1); // grow it to new size + // destroy intial data before copying over it + DCDestructElements(&m_pData[nOldSize], nCount); + // shift old data up to fill gap + memmove(&m_pData[nIndex + nCount], &m_pData[nIndex], + (nOldSize - nIndex) * sizeof(TYPE)); + + // re-init slots we copied from + DCConstructElements(&m_pData[nIndex], nCount); + } + + // insert new value in the gap + while (nCount--) + m_pData[nIndex++] = newElement; +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::RemoveAt(int nIndex, int nCount) { + // just remove a range + int nMoveCount = m_nSize - (nIndex + nCount); + DCDestructElements(&m_pData[nIndex], nCount); + if (nMoveCount) + memcpy(&m_pData[nIndex], &m_pData[nIndex + nCount], + nMoveCount * sizeof(TYPE)); + m_nSize -= nCount; +} + +///////////////////////////////////////////////////////////////////////////// +template +void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { + if (pNewArray->GetSize() > 0) { + InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize()); + for (int i = 0; i < pNewArray->GetSize(); i++) + SetAt(nStartIndex + i, pNewArray->GetAt(i)); + } +} + + +///////////////////////////////////////////////////////////////////////////// +template +HRESULT CBArray::Persist(CBPersistMgr *PersistMgr) { + int i, j; + if (PersistMgr->m_Saving) { + j = GetSize(); + PersistMgr->Transfer("ArraySize", &j); + for (i = 0; i < j; i++) { + ARG_TYPE obj = GetAt(i); + PersistMgr->Transfer("", &obj); + } + } else { + SetSize(0, -1); + PersistMgr->Transfer("ArraySize", &j); + for (i = 0; i < j; i++) { + ARG_TYPE obj; + PersistMgr->Transfer("", &obj); + Add(obj); + } + } + return S_OK; +} + +} // end of namespace WinterMute + +#endif // COLL_TEMPL_H diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h new file mode 100644 index 0000000000..8fba050f34 --- /dev/null +++ b/engines/wintermute/dcgf.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCGF_H +#define WINTERMUTE_DCGF_H + + +////////////////////////////////////////////////////////////////////////// +#define DCGF_VER_MAJOR 1 +#define DCGF_VER_MINOR 0 +#define DCGF_VER_BUILD 1 +#define DCGF_VER_SUFFIX "beta" +#define DCGF_VER_BETA true + +#define DCGF_NAME "WME Lite" +#define DCGF_MAGIC 0xDEC0ADDE + +// minimal saved game version we support +#define SAVEGAME_VER_MAJOR 1 +#define SAVEGAME_VER_MINOR 0 +#define SAVEGAME_VER_BUILD 0 +////////////////////////////////////////////////////////////////////////// + +#define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP + +#ifdef GetClassName +#undef GetClassName +#endif + +// macros +#define RELEASE(obj) if(obj) { obj->Release(); obj = NULL; } else 0 +#define SAFE_DELETE(obj) if(obj) { delete obj; obj = NULL; } else 0 +#define SAFE_DELETE_ARRAY(obj) if(obj) { delete [] obj; obj = NULL; } else 0 +#define DegToRad(_val) (_val*PI*(1.0f/180.0f)) +#define RadToDeg(_val) (_val*(180/PI)) + +#endif // _DCGF_H_ diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h new file mode 100644 index 0000000000..0ee5a6bf54 --- /dev/null +++ b/engines/wintermute/dctypes.h @@ -0,0 +1,181 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCTYPES_H +#define WINTERMUTE_DCTYPES_H + +#include +#include +#include + +namespace WinterMute { + +typedef std::string AnsiString; +typedef std::string Utf8String; +typedef std::wstring WideString; + + +typedef std::list WideStringList; +typedef std::list AnsiStringList; + +typedef std::vector WideStringArray; +typedef std::vector AnsiStringArray; + + +enum TGameState { + GAME_RUNNING, GAME_FROZEN, GAME_SEMI_FROZEN +}; + + +enum TImageType { IMG_PALETTED8, IMG_TRUECOLOR } ; + + +enum TTextAlign { + TAL_LEFT = 0, TAL_RIGHT, TAL_CENTER, NUM_TEXT_ALIGN +}; + + +enum TVerticalAlign { + VAL_TOP = 0, VAL_CENTER, VAL_BOTTOM, NUM_VERTICAL_ALIGN +}; + + +enum TDirection { + DI_UP = 0, DI_UPRIGHT = 1, DI_RIGHT = 2, DI_DOWNRIGHT = 3, DI_DOWN = 4, DI_DOWNLEFT = 5, DI_LEFT = 6, DI_UPLEFT = 7, NUM_DIRECTIONS = 8, DI_NONE = 9 +}; + + +enum TEventType { + EVENT_NONE = 0, + EVENT_INIT = 1, + EVENT_SHUTDOWN = 2, + EVENT_LEFT_CLICK = 3, + EVENT_RIGHT_CLICK = 4, + EVENT_MIDDLE_CLICK = 5, + EVENT_LEFT_DBLCLICK = 6, + EVENT_PRESS = 7, + EVENT_IDLE = 8, + EVENT_MOUSE_OVER = 9, + EVENT_LEFT_RELEASE = 10, + EVENT_RIGHT_RELEASE = 11, + EVENT_MIDDLE_RELEASE = 12, + NUM_EVENTS +}; + + +enum TUIObjectType { + UI_UNKNOWN, UI_BUTTON, UI_WINDOW, UI_STATIC, UI_EDIT, UI_HTML, UI_CUSTOM +}; + + +enum TRendererState { + RSTATE_3D, RSTATE_2D, RSTATE_LINES, RSTATE_NONE +}; + + +enum TDynamicConstructor { + DYNAMIC_CONSTRUCTOR +}; + +enum TSeek { + SEEK_TO_BEGIN = SEEK_SET, + SEEK_TO_CURRENT = SEEK_CUR, + SEEK_TO_END = SEEK_END +}; + +enum TSoundType { + SOUND_SFX, SOUND_MUSIC, SOUND_SPEECH +}; + +enum TVideoMode { + VIDEO_WINDOW, VIDEO_FULLSCREEN, VIDEO_ANY +}; + + +enum TVideoPlayback { + VID_PLAY_POS = 0, + VID_PLAY_STRETCH = 1, + VID_PLAY_CENTER = 2 +}; + + +enum TMouseEvent { + MOUSE_CLICK, MOUSE_RELEASE, MOUSE_DBLCLICK +}; + + +enum TMouseButton { + MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE +}; + + +enum TTransMgrState{ + TRANS_MGR_RUNNING, TRANS_MGR_READY +}; + + +enum TTransitionType{ + TRANSITION_NONE = 0, + TRANSITION_FADE_OUT = 1, + TRANSITION_FADE_IN = 2, + NUM_TRANSITION_TYPES +}; + + +enum TWindowMode { + WINDOW_NORMAL, WINDOW_EXCLUSIVE, WINDOW_SYSTEM_EXCLUSIVE +}; + +enum TSFXType { + SFX_NONE, SFX_ECHO, SFX_REVERB +}; + + +enum TSpriteCacheType { + CACHE_ALL, CACHE_HALF +}; + +enum TTextEncoding { + TEXT_ANSI = 0, TEXT_UTF8 = 1, NUM_TEXT_ENCODINGS +}; + +enum TSpriteBlendMode { + BLEND_UNKNOWN = -1, BLEND_NORMAL = 0, BLEND_ADDITIVE = 1, BLEND_SUBTRACTIVE = 2, NUM_BLEND_MODES +}; + +enum TTTSType { + TTS_CAPTION = 0, TTS_TALK, TTS_KEYPRESS +}; + +enum TShadowType { + SHADOW_NONE = 0, SHADOW_SIMPLE = 1, SHADOW_FLAT = 2, SHADOW_STENCIL = 3 +}; + +} // end of namespace WinterMute + +#endif // DCTYPES_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 4096e8d8e6..2eda176c75 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,7 +1,11 @@ MODULE := engines/wintermute MODULE_OBJS := \ + BBase.o \ + BParser.o \ detection.o \ + SysClass.o \ + SysInstance.o \ wintermute.o MODULE_DIRS += \ @@ -13,4 +17,4 @@ PLUGIN := 1 endif # Include common rules -include $(srcdir)/rules.mk \ No newline at end of file +include $(srcdir)/rules.mk diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h new file mode 100644 index 0000000000..2e1c9f3214 --- /dev/null +++ b/engines/wintermute/persistent.h @@ -0,0 +1,89 @@ +/* + This file is part of WME Lite. + http://dead-code.org/redir.php?target=wmelite + + Copyright (c) 2011 Jan Nedoma + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +#ifndef WINTERMUTE_PERSISTENT_H +#define WINTERMUTE_PERSISTENT_H + +#include "wintypes.h" + +namespace WinterMute { + + class CBPersistMgr; + + // persistence support + typedef void *(WINAPI *PERSISTBUILD)(void); + typedef HRESULT(WINAPI *PERSISTLOAD)(void *, CBPersistMgr *); + typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); +} // end of namespace WinterMute + +#include "SysClass.h" +#include "SysClassRegistry.h" +namespace WinterMute { + + +#define DECLARE_PERSISTENT(class_name, parent_class)\ +static const char m_ClassName[];\ +static void* WINAPI PersistBuild(void);\ +virtual const char* GetClassName();\ +static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ +class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ +virtual HRESULT Persist(CBPersistMgr* PersistMgr);\ +void* operator new (size_t size);\ +void operator delete(void* p);\ + + +#define IMPLEMENT_PERSISTENT(class_name, persistent_class)\ +const char class_name::m_ClassName[] = #class_name;\ +void* class_name::PersistBuild(){\ +return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ +}\ +\ +HRESULT class_name::PersistLoad(void* Instance, CBPersistMgr* PersistMgr){\ +return ((class_name*)Instance)->Persist(PersistMgr);\ +}\ +\ +const char* class_name::GetClassName(){\ +return #class_name;\ +}\ +\ +CSysClass Register##class_name(class_name::m_ClassName, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ +\ +void* class_name::operator new (size_t size){\ +void* ret = ::operator new(size);\ +CSysClassRegistry::GetInstance()->RegisterInstance(#class_name, ret);\ +return ret;\ +}\ +\ +void class_name::operator delete (void* p){\ +CSysClassRegistry::GetInstance()->UnregisterInstance(#class_name, p);\ +::operator delete(p);\ +}\ + +#define TMEMBER(member_name) #member_name, &member_name +#define TMEMBER_INT(member_name) #member_name, (int*)&member_name + +} // end of namespace WinterMute + +#endif // WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h new file mode 100644 index 0000000000..89c1ef6e53 --- /dev/null +++ b/engines/wintermute/wintypes.h @@ -0,0 +1,117 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeWintypes_H__ +#define __WmeWintypes_H__ + +#define FORBIDDEN_SYMBOL_ALLOW_ALL +#include "common/scummsys.h" + +//namespace WinterMute { +#include +#include +#ifndef __WIN32__ + +#define WINAPI +#define CALLBACK + +#ifndef __OBJC__ +typedef int BOOL; +#endif + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#define PI ((float) 3.141592653589793f) +#define DRGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) + +#define D3DCOLGetB(rgb) ((byte )(rgb)) +#define D3DCOLGetG(rgb) ((byte )(((WORD)(rgb)) >> 8)) +#define D3DCOLGetR(rgb) ((byte )((rgb)>>16)) +#define D3DCOLGetA(rgb) ((byte )((rgb)>>24)) + +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define CONST const + +#define MAX_PATH 512 + +typedef char CHAR; +typedef short SHORT; +typedef int32_t LONG; + +typedef uint16 WORD; +//typedef uint32 QWORD; // HACK for now +typedef int INT; +typedef unsigned int UINT; + +typedef CHAR *NPSTR, *LPSTR, *PSTR; +typedef PSTR *PZPSTR; +typedef const PSTR *PCZPSTR; +typedef const CHAR *LPCSTR, *PCSTR; +typedef PCSTR *PZPCSTR; + +typedef struct tagRECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT, *LPRECT; + + +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT, *LPPOINT; + + +typedef uint32 HINSTANCE; +typedef uint32 HMODULE; +typedef uint32 HWND; + +//typedef uint32 HRESULT; +typedef long HRESULT; + +#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) +#define FAILED(hr) (((HRESULT)(hr)) < 0) + +#define S_OK ((HRESULT)0) +//#define S_FALSE ((HRESULT)1) +#define E_FAIL ((HRESULT)-1) + + +#endif // !__WIN32__ + +//} // end of namespace WinterMute + +#endif // __WmeWintypes_H__ -- cgit v1.2.3 From 72a44cdc7b2040037a97f00c0c218b7f6bd9cd31 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 02:44:24 +0100 Subject: WINTERMUTE: Add the script-classes --- engines/wintermute/BDebugger.cpp | 200 +++ engines/wintermute/BDebugger.h | 90 ++ engines/wintermute/BGame.h | 17 +- engines/wintermute/BNamedObject.cpp | 64 + engines/wintermute/BNamedObject.h | 50 + engines/wintermute/BScriptHolder.h | 10 +- engines/wintermute/BScriptable.cpp | 188 +++ engines/wintermute/BScriptable.h | 80 ++ engines/wintermute/ConvertUTF.c | 612 +++++++++ engines/wintermute/ConvertUTF.h | 149 +++ engines/wintermute/StringUtil.cpp | 320 +++++ engines/wintermute/StringUtil.h | 67 + engines/wintermute/SysClass.h | 4 +- engines/wintermute/dcscript.h | 148 +++ engines/wintermute/module.mk | 9 + engines/wintermute/persistent.h | 44 +- engines/wintermute/scriptables/SXArray.cpp | 234 ++++ engines/wintermute/scriptables/SXArray.h | 54 + engines/wintermute/scriptables/SXDate.cpp | 264 ++++ engines/wintermute/scriptables/SXDate.h | 53 + engines/wintermute/scriptables/SXMath.cpp | 290 +++++ engines/wintermute/scriptables/SXMath.h | 53 + engines/wintermute/scriptables/SXMemBuffer.cpp | 475 +++++++ engines/wintermute/scriptables/SXMemBuffer.h | 59 + engines/wintermute/scriptables/ScEngine.cpp | 842 +++++++++++++ engines/wintermute/scriptables/ScEngine.h | 178 +++ engines/wintermute/scriptables/ScScript.cpp | 1600 ++++++++++++++++++++++++ engines/wintermute/scriptables/ScScript.h | 185 +++ engines/wintermute/scriptables/ScStack.cpp | 226 ++++ engines/wintermute/scriptables/ScStack.h | 66 + engines/wintermute/scriptables/ScValue.cpp | 1025 +++++++++++++++ engines/wintermute/scriptables/ScValue.h | 140 +++ engines/wintermute/utils.cpp | 340 +++++ engines/wintermute/utils.h | 68 + engines/wintermute/wintypes.h | 49 +- engines/wintermute/wme_debugger.h | 167 +++ 36 files changed, 8362 insertions(+), 58 deletions(-) create mode 100644 engines/wintermute/BDebugger.cpp create mode 100644 engines/wintermute/BDebugger.h create mode 100644 engines/wintermute/BNamedObject.cpp create mode 100644 engines/wintermute/BNamedObject.h create mode 100644 engines/wintermute/BScriptable.cpp create mode 100644 engines/wintermute/BScriptable.h create mode 100644 engines/wintermute/ConvertUTF.c create mode 100644 engines/wintermute/ConvertUTF.h create mode 100644 engines/wintermute/StringUtil.cpp create mode 100644 engines/wintermute/StringUtil.h create mode 100644 engines/wintermute/dcscript.h create mode 100644 engines/wintermute/scriptables/SXArray.cpp create mode 100644 engines/wintermute/scriptables/SXArray.h create mode 100644 engines/wintermute/scriptables/SXDate.cpp create mode 100644 engines/wintermute/scriptables/SXDate.h create mode 100644 engines/wintermute/scriptables/SXMath.cpp create mode 100644 engines/wintermute/scriptables/SXMath.h create mode 100644 engines/wintermute/scriptables/SXMemBuffer.cpp create mode 100644 engines/wintermute/scriptables/SXMemBuffer.h create mode 100644 engines/wintermute/scriptables/ScEngine.cpp create mode 100644 engines/wintermute/scriptables/ScEngine.h create mode 100644 engines/wintermute/scriptables/ScScript.cpp create mode 100644 engines/wintermute/scriptables/ScScript.h create mode 100644 engines/wintermute/scriptables/ScStack.cpp create mode 100644 engines/wintermute/scriptables/ScStack.h create mode 100644 engines/wintermute/scriptables/ScValue.cpp create mode 100644 engines/wintermute/scriptables/ScValue.h create mode 100644 engines/wintermute/utils.cpp create mode 100644 engines/wintermute/utils.h create mode 100644 engines/wintermute/wme_debugger.h (limited to 'engines') diff --git a/engines/wintermute/BDebugger.cpp b/engines/wintermute/BDebugger.cpp new file mode 100644 index 0000000000..8e5faa8db1 --- /dev/null +++ b/engines/wintermute/BDebugger.cpp @@ -0,0 +1,200 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "BDebugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + m_Enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::Initialize() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::Shutdown() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameInit() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameShutdown() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameTick() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnLog(unsigned int ErrorCode, const char *Text) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptInit(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptShutdown(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptChangeLine(CScScript *Script, int Line) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptChangeScope(CScScript *Script, CScValue *Scope) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptShutdownScope(CScScript *Script, CScValue *Scope) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *Value) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::AttachClient(IWmeDebugClient *Client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::DetachClient(IWmeDebugClient *Client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::QueryData(IWmeDebugClient *Client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::GetPropInt(const char *PropName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::GetPropFloat(const char *PropName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::GetPropString(const char *PropName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::GetPropBool(const char *PropName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, int PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, double PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, const char *PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, bool PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::AddBreakpoint(const char *ScriptFilename, int Line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::RemoveBreakpoint(const char *ScriptFilename, int Line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::ContinueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BDebugger.h b/engines/wintermute/BDebugger.h new file mode 100644 index 0000000000..28b37cee4f --- /dev/null +++ b/engines/wintermute/BDebugger.h @@ -0,0 +1,90 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeBDebugger_H__ +#define __WmeBDebugger_H__ + + +#include "BBase.h" +#include "wme_debugger.h" + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool m_Enabled; + HRESULT Initialize(); + HRESULT Shutdown(); + + // internal interface + HRESULT OnGameInit(); + HRESULT OnGameShutdown(); + HRESULT OnGameTick(); + HRESULT OnLog(unsigned int ErrorCode, const char *Text); + HRESULT OnScriptInit(CScScript *Script); + HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); + HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); + + HRESULT OnScriptShutdown(CScScript *Script); + HRESULT OnScriptChangeLine(CScScript *Script, int Line); + HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); + HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); + HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName); + HRESULT OnVariableChangeValue(CScValue *Var, CScValue *Value); + + HRESULT OnScriptHitBreakpoint(CScScript *Script); + + // IWmeDebugServer interface + virtual bool AttachClient(IWmeDebugClient *Client); + virtual bool DetachClient(IWmeDebugClient *Client); + virtual bool QueryData(IWmeDebugClient *Client); + + virtual int GetPropInt(const char *PropName); + virtual double GetPropFloat(const char *PropName); + virtual const char *GetPropString(const char *PropName); + virtual bool GetPropBool(const char *PropName); + + virtual bool SetProp(const char *PropName, int PropValue); + virtual bool SetProp(const char *PropName, double PropValue); + virtual bool SetProp(const char *PropName, const char *PropValue); + virtual bool SetProp(const char *PropName, bool PropValue); + + virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize); + + virtual bool AddBreakpoint(const char *ScriptFilename, int Line); + virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line); + + virtual bool ContinueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 199417ede6..a61ba1270d 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -//#include "BDebugger.h" +#include "BDebugger.h" //#include "BSaveThumbHelper.h" //#include "BFader.h" //#include "BRenderer.h" @@ -43,6 +43,7 @@ namespace WinterMute { typedef void (*ENGINE_LOG_CALLBACK)(char *Text, HRESULT Result, void *Data); class CBSoundMgr; +class CBFader; class CBFont; class CBFileManager; class CBTransitionMgr; @@ -171,8 +172,8 @@ public: HRESULT Initialize3(); CBFileManager *m_FileManager; CBTransitionMgr *m_TransMgr; - CBDebugger *GetDebugMgr(); #endif //TODO: STUB + CBDebugger *GetDebugMgr(); void LOG(HRESULT res, LPCSTR fmt, ...) {} #if 0 CBRenderer *m_Renderer; @@ -195,6 +196,7 @@ public: CBArray m_QuickMessages; CBArray m_Windows; CBArray m_ViewportStack; +#endif int m_ViewportSP; bool m_MouseLeftDown; bool m_MouseRightDown; @@ -214,13 +216,13 @@ public: char *m_SettingsGameFile; CBFader *m_Fader; bool m_SuppressScriptErrors; - +#if 0 virtual HRESULT InvalidateDeviceObjects(); virtual HRESULT RestoreDeviceObjects(); - +#endif virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); - +#if 0 // scripting interface virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); @@ -289,6 +291,7 @@ public: virtual HRESULT LoadGame(char *Filename); virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); virtual HRESULT ShowCursor(); +#endif CBSprite *m_CursorNoninteractive; CBObject *m_ActiveObject; CBKeyboardState *m_KeyboardState; @@ -303,13 +306,15 @@ public: uint32 m_LiveTimer; uint32 m_LiveTimerDelta; uint32 m_LiveTimerLast; - +#if 0 CBObject *m_CapturedObject; POINT m_MousePos; bool ValidObject(CBObject *Object); HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); +#endif void QuickMessage(char *Text); +#if 0 void QuickMessageForm(LPSTR fmt, ...); HRESULT DisplayQuickMsg(); uint32 m_Fps; diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp new file mode 100644 index 0000000000..0f2df63aea --- /dev/null +++ b/engines/wintermute/BNamedObject.cpp @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BNamedObject.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + m_Name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + m_Name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + m_Name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + SAFE_DELETE_ARRAY(m_Name); +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::SetName(char *Name) { + SAFE_DELETE_ARRAY(m_Name); + + m_Name = new char [strlen(Name) + 1]; + if (m_Name != NULL) strcpy(m_Name, Name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BNamedObject.h b/engines/wintermute/BNamedObject.h new file mode 100644 index 0000000000..6473748134 --- /dev/null +++ b/engines/wintermute/BNamedObject.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "BBase.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *m_Name; + void SetName(char *Name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index aaa5176bcf..6f37461431 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -31,18 +31,14 @@ #include "coll_templ.h" #include "persistent.h" -// TODO: Reinclude any of this. -//#include "BScriptable.h" +#include "BScriptable.h" namespace WinterMute { -//class CBScriptHolder : public CBScriptable { -class CBScriptHolder : CBBase { +class CBScriptHolder : public CBScriptable { public: - DECLARE_PERSISTENT(CBScriptHolder, CBBase) // <- TODO, quickfix for compile -#if 0 DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) - +#if 0 CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp new file mode 100644 index 0000000000..9b875eeffb --- /dev/null +++ b/engines/wintermute/BScriptable.cpp @@ -0,0 +1,188 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BScriptable.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool NoValue, bool Persistable): CBNamedObject(inGame) { + m_RefCount = 0; + + if (NoValue) m_ScValue = NULL; + else m_ScValue = new CScValue(Game); + + m_Persistable = Persistable; + + m_ScProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(m_RefCount>0) Game->LOG(0, "Warning: Destroying object, m_RefCount=%d", m_RefCount); + delete m_ScValue; + delete m_ScProp; + m_ScValue = NULL; + m_ScProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + /* + Stack->CorrectParams(0); + Stack->PushNULL(); + Script->RuntimeError("Call to undefined method '%s'.", Name); + + return S_OK; + */ + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::ScGetProperty(char *Name) { + if (!m_ScProp) m_ScProp = new CScValue(Game); + if (m_ScProp) return m_ScProp->GetProp(Name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::ScSetProperty(char *Name, CScValue *Value) { + if (!m_ScProp) m_ScProp = new CScValue(Game); + if (m_ScProp) return m_ScProp->SetProp(Name, Value); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBScriptable::ScToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::ScToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::ScToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::ScToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::ScToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetString(const char *Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetInt(int Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetFloat(double Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetBool(bool Val) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(m_RefCount)); + PersistMgr->Transfer(TMEMBER(m_ScProp)); + PersistMgr->Transfer(TMEMBER(m_ScValue)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::ScCompare(CBScriptable *Val) { + if (this < Val) return -1; + else if (this > Val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScDebuggerDesc(char *Buf, int BufSize) { + strcpy(Buf, ScToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::CanHandleMethod(char *EventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::InvokeMethodThread(char *MethodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::DbgGetNativeClass() { + return GetClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::DbgGetProperty(const char *Name) { + return ScGetProperty((char *)Name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h new file mode 100644 index 0000000000..2a87b9c305 --- /dev/null +++ b/engines/wintermute/BScriptable.h @@ -0,0 +1,80 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/BNamedObject.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *InvokeMethodThread(char *MethodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool NoValue = false, bool Persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool CanHandleMethod(char *EventMethod); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + virtual void *ScToMemBuffer(); + virtual int ScToInt(); + virtual double ScToFloat(); + virtual bool ScToBool(); + virtual void ScSetString(const char *Val); + virtual void ScSetInt(int Val); + virtual void ScSetFloat(double Val); + virtual void ScSetBool(bool Val); + virtual int ScCompare(CBScriptable *Val); + virtual void ScDebuggerDesc(char *Buf, int BufSize); + int m_RefCount; + CScValue *m_ScValue; + CScValue *m_ScProp; + +public: + // IWmeDebugObject + const char *DbgGetNativeClass(); + IWmeDebugProp *DbgGetProperty(const char *Name); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ConvertUTF.c b/engines/wintermute/ConvertUTF.c new file mode 100644 index 0000000000..8f7d6d2124 --- /dev/null +++ b/engines/wintermute/ConvertUTF.c @@ -0,0 +1,612 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "ConvertUTF.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; + break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF32 *target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; + break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG + if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); + } +#endif + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source + length; + switch (length) { + default: + return false; + /* Everything else falls through when "true"... */ + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) return false; + break; + case 0xED: + if (a > 0x9F) return false; + break; + case 0xF0: + if (a < 0x90) return false; + break; + case 0xF4: + if (a > 0x8F) return false; + break; + default: + if (a < 0x80) return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source] + 1; + if (source + length > sourceEnd) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 4: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF32 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; + case 4: + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up the source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_LEGAL_UTF32) { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = ch; + } + } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ diff --git a/engines/wintermute/ConvertUTF.h b/engines/wintermute/ConvertUTF.h new file mode 100644 index 0000000000..03a8bb2bae --- /dev/null +++ b/engines/wintermute/ConvertUTF.h @@ -0,0 +1,149 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that wchar_t has at least + 16 bits, so wchar_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + + ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp new file mode 100644 index 0000000000..6a42857615 --- /dev/null +++ b/engines/wintermute/StringUtil.cpp @@ -0,0 +1,320 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "dcgf.h" +#include +#include +#include +#include "common/tokenizer.h" +#include "StringUtil.h" +#include "ConvertUTF.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToLowerCase(AnsiString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::tolower); +} + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToLowerCase(WideString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::towlower); +} + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToUpperCase(AnsiString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); +} + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToUpperCase(WideString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::towupper); +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { + AnsiString str1lc = str1; + AnsiString str2lc = str2; + + ToLowerCase(str1lc); + ToLowerCase(str2lc); + + return (str1lc == str2lc); +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { + WideString str1lc = str1; + WideString str2lc = str2; + + ToLowerCase(str1lc); + ToLowerCase(str2lc); + + return (str1lc == str2lc); +} + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { + size_t WideSize = Utf8Str.length(); + + if (sizeof(wchar_t) == 2) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF16 *TargetStart = reinterpret_cast(WideStringNative); + UTF16 *TargetEnd = TargetStart + WideSize + 1; + + ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else if (sizeof(wchar_t) == 4) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF32 *TargetStart = reinterpret_cast(WideStringNative); + UTF32 *TargetEnd = TargetStart + WideSize; + + ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else { + return L""; + } +} + +////////////////////////////////////////////////////////////////////////// +Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { + size_t WideSize = WideStr.length(); + + if (sizeof(wchar_t) == 2) { + size_t Utf8Size = 3 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF16 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else if (sizeof(wchar_t) == 4) { + size_t Utf8Size = 4 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF32 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else { + return (Utf8String)""; + } +} + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::AnsiToWide(const AnsiString &str) { + // using default os locale! + setlocale(LC_CTYPE, ""); + size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; + wchar_t *wstr = new wchar_t[WideSize]; + mbstowcs(wstr, str.c_str(), WideSize); + WideString ResultString(wstr); + delete [] wstr; + return ResultString; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::WideToAnsi(const WideString &wstr) { + // using default os locale! + setlocale(LC_CTYPE, ""); + size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; + char *str = new char[WideSize]; + wcstombs(str, wstr.c_str(), WideSize); + AnsiString ResultString(str); + delete [] str; + return ResultString; +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + size_t strLength = str.length(); + size_t patternLength = pattern.length(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart = str.substr(0, patternLength); + + if (ignoreCase) return CompareNoCase(startPart, pattern); + else return (startPart == pattern); +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + size_t strLength = str.length(); + size_t patternLength = pattern.length(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString endPart = str.substr(strLength - patternLength, patternLength); + + if (ignoreCase) return CompareNoCase(endPart, pattern); + else return (endPart == pattern); +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::IsUtf8BOM(const byte *Buffer, uint32 BufferSize) { + if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; + else return false; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { + if (from.empty() || from == to) return str; + + AnsiString result = str; + size_t pos = 0; + + while (true) { + pos = result.find(from, pos); + if (pos == result.npos) break; + + result.replace(pos, from.size(), to); + pos += to.size(); + } + + return result; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { + AnsiString trimmedStr = str; + + if (fromRight) + trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); + if (fromLeft) + trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); + + return trimmedStr; +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + size_t pos = str.find(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos; +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + size_t pos = str.rfind(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(size_t val) { + std::ostringstream str; + str << val; + return str.str(); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(int val) { + std::ostringstream str; + str << val; + return str.str(); + +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(float val) { + std::ostringstream str; + str << val; + return str.str(); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(double val) { + std::ostringstream str; + str << val; + return str.str(); +} + + +////////////////////////////////////////////////////////////////////////// +void StringUtil::Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { + result.clear(); +//TODO: Verify this, wrt keepEmptyItems. + Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); + //typedef boost::char_separator separator_t; + //typedef boost::tokenizer tokenizer_t; + + //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); + //tokenizer_t tokens(list, del); + while (!tokenizer.empty()) { + std::string copy(tokenizer.nextToken().c_str()); + result.push_back(copy); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h new file mode 100644 index 0000000000..20758ed0cd --- /dev/null +++ b/engines/wintermute/StringUtil.h @@ -0,0 +1,67 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeStringUtil_H__ +#define __WmeStringUtil_H__ + +#include "PlatformSDL.h" + +namespace WinterMute { + +class StringUtil { +public: + static void ToLowerCase(AnsiString &str); + static void ToLowerCase(WideString &str); + static void ToUpperCase(AnsiString &str); + static void ToUpperCase(WideString &str); + static bool CompareNoCase(const AnsiString &str1, const AnsiString &str2); + static bool CompareNoCase(const WideString &str1, const WideString &str2); + static WideString Utf8ToWide(const Utf8String &Utf8Str); + static Utf8String WideToUtf8(const WideString &WideStr); + static WideString AnsiToWide(const AnsiString &str); + static AnsiString WideToAnsi(const WideString &str); + + static bool StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + static bool EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + + static bool IsUtf8BOM(const byte *buffer, uint32 bufferSize); + + static AnsiString Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); + static AnsiString Trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); + + static int IndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + static int LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + + static AnsiString ToString(size_t val); + static AnsiString ToString(int val); + static AnsiString ToString(float val); + static AnsiString ToString(double val); + + static void Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); +}; + +} // end of namespace WinterMute + +#endif // __WmeStringUtil_H__ diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index 21d4acd594..ede3d41c22 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef __WmeSysClass_H__ -#define __WmeSysClass_H__ +#ifndef WINTERMUTE_SYSCLASS_H +#define WINTERMUTE_SYSCLASS_H #include "persistent.h" #include diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h new file mode 100644 index 0000000000..98e4f74c53 --- /dev/null +++ b/engines/wintermute/dcscript.h @@ -0,0 +1,148 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCSCRIPT_H +#define WINTERMUTE_DCSCRIPT_H + +namespace WinterMute { + +#define SCRIPT_MAGIC 0xDEC0ADDE +#define SCRIPT_VERSION 0x0102 + +// value types +typedef enum { + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF +} TValType; + + +// script states +typedef enum { + SCRIPT_RUNNING, SCRIPT_WAITING, SCRIPT_SLEEPING, SCRIPT_FINISHED, SCRIPT_PERSISTENT, SCRIPT_ERROR, SCRIPT_PAUSED, SCRIPT_WAITING_SCRIPT, SCRIPT_THREAD_FINISHED +} TScriptState; + +// opcodes +typedef enum { + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR +} TInstruction; + +// external data types +typedef enum { + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER +} TExternalType; + + +// call types +typedef enum { + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL +} TCallType; + +// element types +typedef enum { + ELEMENT_STRING = 0 +} TElementType; + + + +// compiler interface +typedef byte *(WINAPI DLL_LOAD_FILE)(void *Data, char *Filename, uint32 *Size); +typedef void (WINAPI DLL_CLOSE_FILE)(void *Data, byte *Buffer); +typedef void (WINAPI DLL_ADD_ERROR)(void *Data, int Line, char *Text); +typedef void (WINAPI DLL_PARSE_ELEMENT)(void *Data, int Line, int Type, void *ElementData); + +typedef struct { + DLL_LOAD_FILE *Dll_LoadFile; + DLL_CLOSE_FILE *Dll_CloseFile; + DLL_ADD_ERROR *Dll_AddError; + DLL_PARSE_ELEMENT *Dll_ParseElement; +} CALLBACKS; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 2eda176c75..45708e2b84 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,8 +1,17 @@ MODULE := engines/wintermute MODULE_OBJS := \ + scriptables/ScScript.o \ + scriptables/ScStack.o \ + scriptables/ScValue.o \ + scriptables/SXArray.o \ + scriptables/SXDate.o \ + scriptables/SXMath.o \ + scriptables/SXMemBuffer.o \ BBase.o \ + BNamedObject.o \ BParser.o \ + BScriptable.o \ detection.o \ SysClass.o \ SysInstance.o \ diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 2e1c9f3214..5d0b7ee5fb 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -1,26 +1,30 @@ -/* - This file is part of WME Lite. - http://dead-code.org/redir.php?target=wmelite - - Copyright (c) 2011 Jan Nedoma +/* 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. - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: + * 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. - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. + * 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. */ #ifndef WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp new file mode 100644 index 0000000000..4a67cdfb5a --- /dev/null +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -0,0 +1,234 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/SysInstance.h" +#include "engines/wintermute/scriptables/SXArray.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + m_Length = 0; + m_Values = new CScValue(Game); + + int NumParams = Stack->Pop()->GetInt(0); + + if (NumParams == 1) m_Length = Stack->Pop()->GetInt(0); + else if (NumParams > 1) { + m_Length = NumParams; + char ParamName[20]; + for (int i = 0; i < NumParams; i++) { + sprintf(ParamName, "%d", i); + m_Values->SetProp(ParamName, Stack->Pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + m_Length = 0; + m_Values = new CScValue(Game); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete m_Values; + m_Values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CSXArray::ScToString() { + static char Dummy[32768]; + strcpy(Dummy, ""); + char PropName[20]; + for (int i = 0; i < m_Length; i++) { + sprintf(PropName, "%d", i); + CScValue *val = m_Values->GetProp(PropName); + if (val) { + if (strlen(Dummy) + strlen(val->GetString()) < 32768) { + strcat(Dummy, val->GetString()); + } + } + + if (i < m_Length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); + } + return Dummy; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Push") == 0) { + int NumParams = Stack->Pop()->GetInt(0); + char ParamName[20]; + + for (int i = 0; i < NumParams; i++) { + m_Length++; + sprintf(ParamName, "%d", m_Length - 1); + m_Values->SetProp(ParamName, Stack->Pop(), true); + } + Stack->PushInt(m_Length); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Pop") == 0) { + + Stack->CorrectParams(0); + + if (m_Length > 0) { + char ParamName[20]; + sprintf(ParamName, "%d", m_Length - 1); + Stack->Push(m_Values->GetProp(ParamName)); + m_Values->DeleteProp(ParamName); + m_Length--; + } else Stack->PushNULL(); + + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("array"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + m_ScValue->SetInt(m_Length); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (ValidNumber(Name, ParamName)) { + return m_Values->GetProp(ParamName); + } else return m_ScValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Length") == 0) { + int OrigLength = m_Length; + m_Length = std::max(Value->GetInt(0), 0); + + char PropName[20]; + if (m_Length < OrigLength) { + for (int i = m_Length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + m_Values->DeleteProp(PropName); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (ValidNumber(Name, ParamName)) { + int Index = atoi(ParamName); + if (Index >= m_Length) m_Length = Index + 1; + return m_Values->SetProp(ParamName, Value); + } else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Length)); + PersistMgr->Transfer(TMEMBER(m_Values)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { + bool IsNumber = true; + for (int i = 0; i < strlen(OrigStr); i++) { + if (!isdigit(OrigStr[i])) { + IsNumber = false; + break; + } + } + + if (IsNumber) { + int Index = atoi(OrigStr); + sprintf(OutStr, "%d", Index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::Push(CScValue *Val) { + char ParamName[20]; + m_Length++; + sprintf(ParamName, "%d", m_Length - 1); + m_Values->SetProp(ParamName, Val, true); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h new file mode 100644 index 0000000000..5283db2efb --- /dev/null +++ b/engines/wintermute/scriptables/SXArray.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + HRESULT Push(CScValue *Val); + bool ValidNumber(const char *OrigStr, char *OutStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *Stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *ScGetProperty(char *Name); + HRESULT ScSetProperty(char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + char *ScToString(); + int m_Length; + CScValue *m_Values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp new file mode 100644 index 0000000000..39b50da528 --- /dev/null +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -0,0 +1,264 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/SXDate.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(6); + + memset(&m_tm, 0, sizeof(m_tm)); + + CScValue *valYear = Stack->Pop(); + m_tm.tm_year = valYear->GetInt() - 1900; + m_tm.tm_mon = Stack->Pop()->GetInt() - 1; + m_tm.tm_mday = Stack->Pop()->GetInt(); + m_tm.tm_hour = Stack->Pop()->GetInt(); + m_tm.tm_min = Stack->Pop()->GetInt(); + m_tm.tm_sec = Stack->Pop()->GetInt(); + + if (valYear->IsNULL()) { + time_t TimeNow; + time(&TimeNow); + memcpy(&m_tm, localtime(&TimeNow), sizeof(m_tm)); + } + + mktime(&m_tm); +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + + +////////////////////////////////////////////////////////////////////////// +char *CSXDate::ScToString() { + return asctime(&m_tm); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetYear") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_year + 1900); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMonth") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_mon + 1); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDate") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_mday); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHours") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_hour); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMinutes") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_min); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSeconds") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_sec); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWeekday") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_tm.tm_wday); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetYear") == 0) { + Stack->CorrectParams(1); + m_tm.tm_year = Stack->Pop()->GetInt() - 1900; + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMonth") == 0) { + Stack->CorrectParams(1); + m_tm.tm_mon = Stack->Pop()->GetInt() - 1; + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDate") == 0) { + Stack->CorrectParams(1); + m_tm.tm_mday = Stack->Pop()->GetInt(); + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHours") == 0) { + Stack->CorrectParams(1); + m_tm.tm_hour = Stack->Pop()->GetInt(); + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMinutes") == 0) { + Stack->CorrectParams(1); + m_tm.tm_min = Stack->Pop()->GetInt(); + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSeconds") == 0) { + Stack->CorrectParams(1); + m_tm.tm_sec = Stack->Pop()->GetInt(); + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCurrentTime") == 0) { + Stack->CorrectParams(0); + time_t TimeNow; + time(&TimeNow); + memcpy(&m_tm, localtime(&TimeNow), sizeof(m_tm)); + mktime(&m_tm); + Stack->PushNULL(); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("date"); + return m_ScValue; + } + + else return m_ScValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::ScSetProperty(char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Name")==0){ + SetName(Value->GetString()); + return S_OK; + } + + else*/ return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + if (PersistMgr->m_Saving) + PersistMgr->PutBytes((byte *)&m_tm, sizeof(m_tm)); + else + PersistMgr->GetBytes((byte *)&m_tm, sizeof(m_tm)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXDate::ScCompare(CBScriptable *Value) { + time_t time1 = mktime(&m_tm); + time_t time2 = mktime(&((CSXDate *)Value)->m_tm); + + if (time1 < time2) return -1; + else if (time1 > time2) return 1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h new file mode 100644 index 0000000000..fe9191368d --- /dev/null +++ b/engines/wintermute/scriptables/SXDate.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int ScCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *ScGetProperty(char *Name); + HRESULT ScSetProperty(char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + char *ScToString(); + char *m_String; + struct tm m_tm; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SXMath.cpp b/engines/wintermute/scriptables/SXMath.cpp new file mode 100644 index 0000000000..48e722a02c --- /dev/null +++ b/engines/wintermute/scriptables/SXMath.cpp @@ -0,0 +1,290 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/scriptables/SXMath.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/persistent.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Abs") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(fabs(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Acos") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(acos(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Asin") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(asin(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Atan") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(atan(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Atan2") == 0) { + Stack->CorrectParams(2); + double y = Stack->Pop()->GetFloat(); + double x = Stack->Pop()->GetFloat(); + Stack->PushFloat(atan2(y, x)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Ceil") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(ceil(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Cos") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(cos(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Cosh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(cosh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exp") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(exp(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Floor") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(floor(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Log") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(log(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Log10") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(log10(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pow") == 0) { + Stack->CorrectParams(2); + double x = Stack->Pop()->GetFloat(); + double y = Stack->Pop()->GetFloat(); + + Stack->PushFloat(pow(x, y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sin") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sin(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sinh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sinh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Tan") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(tan(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Tanh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(tanh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sqrt") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sqrt(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DegToRad") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(DegreeToRadian(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RadToDeg") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(RadianToDegree(Stack->Pop()->GetFloat())); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("math"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PI") == 0) { + m_ScValue->SetFloat(PI); + return m_ScValue; + } + + else return m_ScValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::DegreeToRadian(double Value) { + return Value * (PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::RadianToDegree(double Value) { + return Value * (180.0f / PI); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMath::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXMath.h b/engines/wintermute/scriptables/SXMath.h new file mode 100644 index 0000000000..a8c34e954e --- /dev/null +++ b/engines/wintermute/scriptables/SXMath.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + +private: + double DegreeToRadian(double Value); + double RadianToDegree(double Value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp new file mode 100644 index 0000000000..38468757ea --- /dev/null +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -0,0 +1,475 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/BScriptable.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/SXMemBuffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(1); + m_Buffer = NULL; + m_Size = 0; + + int NewSize = Stack->Pop()->GetInt(); + Resize(std::max(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + m_Size = NULL; + m_Buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::ScToMemBuffer() { + return m_Buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::Cleanup() { + if (m_Size) free(m_Buffer); + m_Buffer = NULL; + m_Size = 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::Resize(int NewSize) { + int OldSize = m_Size; + + if (m_Size == 0) { + m_Buffer = malloc(NewSize); + if (m_Buffer) m_Size = NewSize; + } else { + void *NewBuf = realloc(m_Buffer, NewSize); + if (!NewBuf) { + if (NewSize == 0) { + m_Buffer = NewBuf; + m_Size = NewSize; + } else return E_FAIL; + } else { + m_Buffer = NewBuf; + m_Size = NewSize; + } + } + + if (m_Buffer && m_Size > OldSize) { + memset((byte *)m_Buffer + OldSize, 0, m_Size - OldSize); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { + if (m_Buffer == NULL) { + Script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (m_Size == 0) return true; + + if (Start < 0 || Length == 0 || Start + Length > m_Size) { + Script->RuntimeError("Set/Get method call is out of bounds"); + return false; + } else return true; +} + +////////////////////////////////////////////////////////////////////////// +char *CSXMemBuffer::ScToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSize") == 0) { + Stack->CorrectParams(1); + int NewSize = Stack->Pop()->GetInt(); + NewSize = std::max(0, NewSize); + if (SUCCEEDED(Resize(NewSize))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetBool") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); + else Stack->PushBool(*(bool *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetByte") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushNULL(); + else Stack->PushInt(*(byte *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetShort") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); + else Stack->PushInt(65536 + * (short *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInt") == 0 || strcmp(Name, "GetLong") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); + else Stack->PushInt(*(int *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFloat") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); + else Stack->PushFloat(*(float *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDouble") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); + else Stack->PushFloat(*(double *)((byte *)m_Buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetString") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + int Length = Stack->Pop()->GetInt(); + + // find end of string + if (Length == 0 && Start >= 0 && Start < m_Size) { + for (int i = Start; i < m_Size; i++) { + if (((char *)m_Buffer)[i] == '\0') { + Length = i - Start; + break; + } + } + } + + if (!CheckBounds(Script, Start, Length)) Stack->PushNULL(); + else { + char *Str = new char[Length + 1]; + strncpy(Str, (const char *)m_Buffer + Start, Length); + Str[Length] = '\0'; + Stack->PushString(Str); + delete [] Str; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPointer") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); + else { + void *Pointer = *(void **)((byte *)m_Buffer + Start); + CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); + Stack->PushNative(Buf, false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetBool") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + bool Val = Stack->Pop()->GetBool(); + + if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); + else { + *(bool *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetByte") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + byte Val = (byte )Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushBool(false); + else { + *(byte *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetShort") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + short Val = (short)Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); + else { + *(short *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInt") == 0 || strcmp(Name, "SetLong") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + int Val = Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); + else { + *(int *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFloat") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + float Val = (float)Stack->Pop()->GetFloat(); + + if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); + else { + *(float *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDouble") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + double Val = Stack->Pop()->GetFloat(); + + if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); + else { + *(double *)((byte *)m_Buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetString") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + char *Val = Stack->Pop()->GetString(); + + if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); + else { + memcpy((byte *)m_Buffer + Start, Val, strlen(Val) + 1); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPointer") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushBool(false); + else { + /* + int Pointer = (int)Val->GetMemBuffer(); + memcpy((byte *)m_Buffer+Start, &Pointer, sizeof(void*)); + Stack->PushBool(true); + */ + // TODO fix + Stack->PushBool(false); + + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DEBUG_Dump") == 0) { + Stack->CorrectParams(0); + if (m_Buffer && m_Size) { + FILE *f = fopen("c:\\!!buffer.bin", "wb"); + fwrite(m_Buffer, m_Size, 1, f); + fclose(f); + } + Stack->PushNULL(); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("membuffer"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Size") == 0) { + m_ScValue->SetInt(m_Size); + return m_ScValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::ScSetProperty(char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Length")==0){ + int OrigLength = m_Length; + m_Length = max(Value->GetInt(0), 0); + + char PropName[20]; + if(m_Length < OrigLength){ + for(int i=m_Length; iDeleteProp(PropName); + } + } + return S_OK; + } + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Size)); + + if (PersistMgr->m_Saving) { + if (m_Size > 0) PersistMgr->PutBytes((byte *)m_Buffer, m_Size); + } else { + if (m_Size > 0) { + m_Buffer = malloc(m_Size); + PersistMgr->GetBytes((byte *)m_Buffer, m_Size); + } else m_Buffer = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::ScCompare(CBScriptable *Val) { + if (m_Buffer == Val->ScToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h new file mode 100644 index 0000000000..e44761b723 --- /dev/null +++ b/engines/wintermute/scriptables/SXMemBuffer.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int ScCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *ScGetProperty(char *Name); + HRESULT ScSetProperty(char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + char *ScToString(); + CSXMemBuffer(CBGame *inGame, CScStack *Stack); + CSXMemBuffer(CBGame *inGame, void *Buffer); + virtual ~CSXMemBuffer(); + virtual void *ScToMemBuffer(); + int m_Size; +private: + HRESULT Resize(int NewSize); + void *m_Buffer; + void Cleanup(); + bool CheckBounds(CScScript *Script, int Start, int Length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp new file mode 100644 index 0000000000..ce3ac5a94f --- /dev/null +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -0,0 +1,842 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "ScEngine.h" +#include "StringUtil.h" +#include "ScValue.h" +#include "ScScript.h" +#include "ScStack.h" +#include "SXMath.h" +#include "BRegistry.h" +#include "BGame.h" +#include "BSound.h" +#include "BFileManager.h" +#include +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + Game->LOG(0, "Initializing scripting engine..."); + + +#ifdef __WIN32__ + char CompilerPath[MAX_PATH]; + strcpy(CompilerPath, COMPILER_DLL); + + m_CompilerDLL = ::LoadLibrary(CompilerPath); + if (m_CompilerDLL == NULL) { + char ModuleName[MAX_PATH]; + ::GetModuleFileName(NULL, ModuleName, MAX_PATH); + + // switch to exe's dir + char *ExeDir = CBUtils::GetPath(ModuleName); + sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); + m_CompilerDLL = ::LoadLibrary(CompilerPath); + + delete [] ExeDir; + } + if (m_CompilerDLL != NULL) { + // bind compiler's functionality + ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(m_CompilerDLL, "CompileBuffer"); + ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(m_CompilerDLL, "CompileFile"); + ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(m_CompilerDLL, "ReleaseBuffer"); + ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(m_CompilerDLL, "SetCallbacks"); + ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(m_CompilerDLL, "DefineFunction"); + ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(m_CompilerDLL, "DefineVariable"); + + if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { + m_CompilerAvailable = false; + ::FreeLibrary(m_CompilerDLL); + m_CompilerDLL = NULL; + } else { + /* + // publish external methods to the compiler + CALLBACKS c; + c.Dll_AddError = AddError; + c.Dll_CloseFile = CloseFile; + c.Dll_LoadFile = LoadFile; + ExtSetCallbacks(&c, Game); + */ + + m_CompilerAvailable = true; + } + } else m_CompilerAvailable = false; +#else + m_CompilerAvailable = false; + m_CompilerDLL = NULL; +#endif + + + if (m_CompilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); + else Game->LOG(0, " Script compiler is NOT available"); + + m_Globals = new CScValue(Game); + + + // register 'Game' as global variable + if (!m_Globals->PropExists("Game")) { + CScValue val(Game); + val.SetNative(Game, true); + m_Globals->SetProp("Game", &val); + } + + // register 'Math' as global variable + if (!m_Globals->PropExists("Math")) { + CScValue val(Game); + val.SetNative(Game->m_MathClass, true); + m_Globals->SetProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) m_CachedScripts[i] = NULL; + + m_CurrentScript = NULL; + + m_FileToCompile = NULL; + + m_CompileErrorCallback = NULL; + m_CompileErrorCallbackData = NULL; + + m_ParseElementCallback = NULL; + m_ParseElementCallbackData = NULL; + + m_IsProfiling = false; + m_ProfilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + Game->LOG(0, "Shutting down scripting engine"); + SaveBreakpoints(); + + DisableProfiling(); +#ifdef __WIN32__ + if (m_CompilerAvailable && m_CompilerDLL) ::FreeLibrary(m_CompilerDLL); +#endif + Cleanup(); + + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + SAFE_DELETE(m_Breakpoints[i]); + } + m_Breakpoints.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Cleanup() { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (!m_Scripts[i]->m_Thread && m_Scripts[i]->m_Owner) m_Scripts[i]->m_Owner->RemoveScript(m_Scripts[i]); + delete m_Scripts[i]; + m_Scripts.RemoveAt(i); + i--; + } + + m_Scripts.RemoveAll(); + + + SAFE_DELETE(m_Globals); + + EmptyScriptCache(); + + m_CurrentScript = NULL; // ref only + + SAFE_DELETE_ARRAY(m_FileToCompile); + + m_CompileErrorCallback = NULL; + m_CompileErrorCallbackData = NULL; + + m_ParseElementCallback = NULL; + m_ParseElementCallbackData = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { + CBGame *Game = (CBGame *)Data; + return Game->m_FileManager->ReadWholeFile(Filename, Size); +} + + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::CloseFile(void *Data, byte *Buffer) { + delete [] Buffer; +} + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::AddError(void *Data, int Line, char *Text) { + CBGame *Game = (CBGame *)Data; + + if (Game) { + if (Game->m_ScEngine && Game->m_ScEngine->m_FileToCompile) + Game->LOG(0, "Compiling script '%s'...", Game->m_ScEngine->m_FileToCompile); + Game->LOG(0, " Error@line %d: %s", Line, Text); + + + // redirect to an engine's own callback + if (Game->m_ScEngine && Game->m_ScEngine->m_CompileErrorCallback) { + Game->m_ScEngine->m_CompileErrorCallback(Line, Text, Game->m_ScEngine->m_CompileErrorCallbackData); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *ElementData) { + CBGame *Game = (CBGame *)Data; + + if (Game) { + // redirect to an engine's own callback + if (Game->m_ScEngine && Game->m_ScEngine->m_ParseElementCallback) { + Game->m_ScEngine->m_ParseElementCallback(Line, Type, ElementData, Game->m_ScEngine->m_CompileErrorCallbackData); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::RunScript(char *Filename, CBScriptHolder *Owner) { + byte *CompBuffer; + uint32 CompSize; + + // get script from cache + CompBuffer = GetCompiledScript(Filename, &CompSize); + if (!CompBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(Game, this); + HRESULT ret = script->Create(Filename, CompBuffer, CompSize, Owner); + if (FAILED(ret)) { + Game->LOG(ret, "Error running script '%s'...", Filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(Game); + if (Owner)val.SetNative(Owner, true); + else val.SetNULL(); + + script->m_Globals->SetProp("self", &val); + script->m_Globals->SetProp("this", &val); + + m_Scripts.Add(script); + Game->GetDebugMgr()->OnScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreCache) { + int i; + + // is script in cache? + if (!IgnoreCache) { + for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (m_CachedScripts[i] && scumm_stricmp(m_CachedScripts[i]->m_Filename, Filename) == 0) { + m_CachedScripts[i]->m_Timestamp = CBPlatform::GetTime(); + *OutSize = m_CachedScripts[i]->m_Size; + return m_CachedScripts[i]->m_Buffer; + } + } + } + + // nope, load it + byte *CompBuffer; + uint32 CompSize; + bool CompiledNow = false; + + uint32 Size; + + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename, &Size); + if (!Buffer) { + Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); + return NULL; + } + + // needs to be compiled? + if (*(uint32 *)Buffer == SCRIPT_MAGIC) { + CompBuffer = Buffer; + CompSize = Size; + } else { + if (!m_CompilerAvailable) { + Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", Filename); + delete [] Buffer; + return NULL; + } + + CompiledNow = true; + + // publish external methods to the compiler + CALLBACKS c; + c.Dll_AddError = AddError; + c.Dll_CloseFile = CloseFile; + c.Dll_LoadFile = LoadFile; + c.Dll_ParseElement = ParseElement; + ExtSetCallbacks(&c, Game); + + // publish native interfaces + Game->PublishNatives(); + + SetFileToCompile(Filename); + CompBuffer = ExtCompileFile(Filename, &CompSize); + if (!CompBuffer) { + Game->QuickMessage("Script compiler error. View log for details."); + delete [] Buffer; + return NULL; + } + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *CachedScript = new CScCachedScript(Filename, CompBuffer, CompSize); + if (CachedScript) { + int index; + uint32 MinTime = CBPlatform::GetTime(); + for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (m_CachedScripts[i] == NULL) { + index = i; + break; + } else if (m_CachedScripts[i]->m_Timestamp <= MinTime) { + MinTime = m_CachedScripts[i]->m_Timestamp; + index = i; + } + } + + if (m_CachedScripts[index] != NULL) delete m_CachedScripts[index]; + m_CachedScripts[index] = CachedScript; + + ret = CachedScript->m_Buffer; + *OutSize = CachedScript->m_Size; + } + + + // cleanup + delete [] Buffer; + if (CompiledNow) ExtReleaseBuffer(CompBuffer); + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Tick() { + int i; + + if (m_Scripts.GetSize() == 0) return S_OK; + + + // resolve waiting scripts + for (i = 0; i < m_Scripts.GetSize(); i++) { + + switch (m_Scripts[i]->m_State) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; jm_RegObjects.GetSize(); j++) + { + if(Game->m_RegObjects[j] == m_Scripts[i]->m_WaitObject) + { + if(Game->m_RegObjects[j]->IsReady()) m_Scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) m_Scripts[i]->Finish(); // m_WaitObject no longer exists + */ + if (Game->ValidObject(m_Scripts[i]->m_WaitObject)) { + if (m_Scripts[i]->m_WaitObject->IsReady()) m_Scripts[i]->Run(); + } else m_Scripts[i]->Finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (m_Scripts[i]->m_WaitFrozen) { + if (m_Scripts[i]->m_WaitTime <= CBPlatform::GetTime()) m_Scripts[i]->Run(); + } else { + if (m_Scripts[i]->m_WaitTime <= Game->m_Timer) m_Scripts[i]->Run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!IsValidScript(m_Scripts[i]->m_WaitScript) || m_Scripts[i]->m_WaitScript->m_State == SCRIPT_ERROR) { + // fake return value + m_Scripts[i]->m_Stack->PushNULL(); + m_Scripts[i]->m_WaitScript = NULL; + m_Scripts[i]->Run(); + } else { + if (m_Scripts[i]->m_WaitScript->m_State == SCRIPT_THREAD_FINISHED) { + // copy return value + m_Scripts[i]->m_Stack->Push(m_Scripts[i]->m_WaitScript->m_Stack->Pop()); + m_Scripts[i]->Run(); + m_Scripts[i]->m_WaitScript->Finish(); + m_Scripts[i]->m_WaitScript = NULL; + } + } + break; + } + } // switch + } // for each script + + + // execute scripts + for (i = 0; i < m_Scripts.GetSize(); i++) { + + // skip paused scripts + if (m_Scripts[i]->m_State == SCRIPT_PAUSED) continue; + + // time sliced script + if (m_Scripts[i]->m_TimeSlice > 0) { + uint32 StartTime = CBPlatform::GetTime(); + while (m_Scripts[i]->m_State == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < m_Scripts[i]->m_TimeSlice) { + m_CurrentScript = m_Scripts[i]; + m_Scripts[i]->ExecuteInstruction(); + } + if (m_IsProfiling && m_Scripts[i]->m_Filename) AddScriptTime(m_Scripts[i]->m_Filename, CBPlatform::GetTime() - StartTime); + } + + // normal script + else { + uint32 StartTime; + bool isProfiling = m_IsProfiling; + if (isProfiling) StartTime = CBPlatform::GetTime(); + + while (m_Scripts[i]->m_State == SCRIPT_RUNNING) { + m_CurrentScript = m_Scripts[i]; + m_Scripts[i]->ExecuteInstruction(); + } + if (isProfiling && m_Scripts[i]->m_Filename) AddScriptTime(m_Scripts[i]->m_Filename, CBPlatform::GetTime() - StartTime); + } + m_CurrentScript = NULL; + } + + RemoveFinishedScripts(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::TickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (!m_Scripts[i]->m_Unbreakable) continue; + + while (m_Scripts[i]->m_State == SCRIPT_RUNNING) { + m_CurrentScript = m_Scripts[i]; + m_Scripts[i]->ExecuteInstruction(); + } + m_Scripts[i]->Finish(); + m_CurrentScript = NULL; + } + RemoveFinishedScripts(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RemoveFinishedScripts() { + // remove finished scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_State == SCRIPT_FINISHED || m_Scripts[i]->m_State == SCRIPT_ERROR) { + if (!m_Scripts[i]->m_Thread && m_Scripts[i]->m_Owner) m_Scripts[i]->m_Owner->RemoveScript(m_Scripts[i]); + Game->GetDebugMgr()->OnScriptShutdown(m_Scripts[i]); + delete m_Scripts[i]; + m_Scripts.RemoveAt(i); + i--; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { + int running = 0, waiting = 0, persistent = 0, total = 0; + + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_State == SCRIPT_FINISHED) continue; + switch (m_Scripts[i]->m_State) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + running++; + break; + case SCRIPT_WAITING: + waiting++; + break; + case SCRIPT_PERSISTENT: + persistent++; + break; + } + total++; + } + if (Running) *Running = running; + if (Waiting) *Waiting = waiting; + if (Persistent) *Persistent = persistent; + + return total; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::EmptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (m_CachedScripts[i]) { + SAFE_DELETE(m_CachedScripts[i]); + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_State == SCRIPT_WAITING && m_Scripts[i]->m_WaitObject == Object) { + if (!Game->m_CompatKillMethodThreads) ResetScript(m_Scripts[i]); + + bool IsThread = m_Scripts[i]->m_MethodThread || m_Scripts[i]->m_Thread; + m_Scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResetScript(CScScript *Script) { + // terminate all scripts waiting for this script + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_State == SCRIPT_WAITING_SCRIPT && m_Scripts[i]->m_WaitScript == Script) { + m_Scripts[i]->Finish(); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->m_Saving) Cleanup(); + + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(m_CurrentScript)); + PersistMgr->Transfer(TMEMBER(m_FileToCompile)); + PersistMgr->Transfer(TMEMBER(m_Globals)); + m_Scripts.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::EditorCleanup() { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_Owner == NULL && (m_Scripts[i]->m_State == SCRIPT_FINISHED || m_Scripts[i]->m_State == SCRIPT_ERROR)) { + delete m_Scripts[i]; + m_Scripts.RemoveAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::PauseAll() { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i] != m_CurrentScript) m_Scripts[i]->Pause(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResumeAll() { + for (int i = 0; i < m_Scripts.GetSize(); i++) + m_Scripts[i]->Resume(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::SetFileToCompile(char *Filename) { + SAFE_DELETE_ARRAY(m_FileToCompile); + m_FileToCompile = new char[strlen(Filename) + 1]; + if (m_FileToCompile) { + strcpy(m_FileToCompile, Filename); + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data) { + m_CompileErrorCallback = Callback; + m_CompileErrorCallbackData = Data; +} + +////////////////////////////////////////////////////////////////////////// +void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data) { + m_ParseElementCallback = Callback; + m_ParseElementCallbackData = Data; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::IsValidScript(CScScript *Script) { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i] == Script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ClearGlobals(bool IncludingNatives) { + m_Globals->CleanProps(IncludingNatives); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { + // send global variables + m_Globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_Thread || m_Scripts[i]->m_MethodThread) continue; + m_Scripts[i]->DbgSendScript(Client); + } + + // and threads later + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i]->m_Thread || m_Scripts[i]->m_MethodThread) + m_Scripts[i]->DbgSendScript(Client); + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + CScBreakpoint *Bp = NULL; + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + if (scumm_stricmp(m_Breakpoints[i]->m_Filename, ScriptFilename) == 0) { + Bp = m_Breakpoints[i]; + break; + } + } + if (Bp == NULL) { + Bp = new CScBreakpoint(ScriptFilename); + m_Breakpoints.Add(Bp); + } + bool Found = false; + for (int i = 0; i < Bp->m_Lines.GetSize(); i++) { + if (Bp->m_Lines[i] == Line) return S_OK; + } + Bp->m_Lines.Add(Line); + + // refresh changes + RefreshScriptBreakpoints(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + if (scumm_stricmp(m_Breakpoints[i]->m_Filename, ScriptFilename) == 0) { + for (int j = 0; j < m_Breakpoints[i]->m_Lines.GetSize(); j++) { + if (m_Breakpoints[i]->m_Lines[j] == Line) { + m_Breakpoints[i]->m_Lines.RemoveAt(j); + if (m_Breakpoints[i]->m_Lines.GetSize() == 0) { + SAFE_DELETE(m_Breakpoints[i]); + m_Breakpoints.RemoveAt(i); + } + // refresh changes + RefreshScriptBreakpoints(); + + return S_OK; + } + } + break; + } + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RefreshScriptBreakpoints() { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + for (int i = 0; i < m_Scripts.GetSize(); i++) { + RefreshScriptBreakpoints(m_Scripts[i]); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + if (!Script || !Script->m_Filename) return E_FAIL; + + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + if (scumm_stricmp(m_Breakpoints[i]->m_Filename, Script->m_Filename) == 0) { + Script->m_Breakpoints.Copy(m_Breakpoints[i]->m_Lines); + return S_OK; + } + } + if (Script->m_Breakpoints.GetSize() > 0) Script->m_Breakpoints.RemoveAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::SaveBreakpoints() { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + + char Text[512]; + char Key[100]; + + int Count = 0; + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + for (int j = 0; j < m_Breakpoints[i]->m_Lines.GetSize(); j++) { + Count++; + sprintf(Key, "Breakpoint%d", Count); + sprintf(Text, "%s:%d", m_Breakpoints[i]->m_Filename, m_Breakpoints[i]->m_Lines[j]); + + Game->m_Registry->WriteString("Debug", Key, Text); + } + } + Game->m_Registry->WriteInt("Debug", "NumBreakpoints", Count); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::LoadBreakpoints() { + if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + + char Key[100]; + + int Count = Game->m_Registry->ReadInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= Count; i++) { + uint32 BufSize = 512; + sprintf(Key, "Breakpoint%d", i); + AnsiString breakpoint = Game->m_Registry->ReadString("Debug", Key, ""); + + char *Path = CBUtils::StrEntry(0, breakpoint.c_str(), ':'); + char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); + + if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); + SAFE_DELETE_ARRAY(Path); + SAFE_DELETE_ARRAY(Line); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { + if (!m_IsProfiling) return; + + AnsiString fileName = Filename; + StringUtil::ToLowerCase(fileName); + m_ScriptTimes[fileName] += Time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::EnableProfiling() { + if (m_IsProfiling) return; + + // destroy old data, if any + m_ScriptTimes.clear(); + + m_ProfilingStartTime = CBPlatform::GetTime(); + m_IsProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::DisableProfiling() { + if (!m_IsProfiling) return; + + DumpStats(); + m_IsProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::DumpStats() { + uint32 totalTime = CBPlatform::GetTime() - m_ProfilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = m_ScriptTimes.begin(); it != m_ScriptTimes.end(); it++) { + times.push_back(std::pair (it->second, it->first)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + Game->LOG(0, "***** Script profiling information: *****"); + Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h new file mode 100644 index 0000000000..54e590bdfe --- /dev/null +++ b/engines/wintermute/scriptables/ScEngine.h @@ -0,0 +1,178 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); +typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); +typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); +typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); +typedef int (*DLL_DEFINE_FUNCTION)(char *Name); +typedef int (*DLL_DEFINE_VARIABLE)(char *Name); + +typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); +typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(char *Filename, byte *Buffer, uint32 Size) { + m_Timestamp = CBPlatform::GetTime(); + m_Buffer = new byte[Size]; + if (m_Buffer) memcpy(m_Buffer, Buffer, Size); + m_Size = Size; + m_Filename = new char[strlen(Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Filename); + }; + + ~CScCachedScript() { + if (m_Buffer) delete [] m_Buffer; + if (m_Filename) delete [] m_Filename; + }; + + uint32 m_Timestamp; + byte *m_Buffer; + uint32 m_Size; + char *m_Filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *Filename) { + m_Filename = NULL; + CBUtils::SetString(&m_Filename, Filename); + } + + ~CScBreakpoint() { + if (m_Filename) delete [] m_Filename; + m_Lines.RemoveAll(); + } + + char *m_Filename; + CBArray m_Lines; + }; + + + + +public: + HRESULT DbgSendScripts(IWmeDebugClient *Client); + + CBArray m_Breakpoints; + HRESULT AddBreakpoint(char *ScriptFilename, int Line); + HRESULT RemoveBreakpoint(char *ScriptFilename, int Line); + HRESULT RefreshScriptBreakpoints(); + HRESULT RefreshScriptBreakpoints(CScScript *Script); + HRESULT SaveBreakpoints(); + HRESULT LoadBreakpoints(); + + HRESULT ClearGlobals(bool IncludingNatives = false); + HRESULT TickUnbreakable(); + HRESULT RemoveFinishedScripts(); + bool IsValidScript(CScScript *Script); + void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); + void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); + + COMPILE_ERROR_CALLBACK m_CompileErrorCallback; + void *m_CompileErrorCallbackData; + + PARSE_ELEMENT_CALLBACK m_ParseElementCallback; + void *m_ParseElementCallbackData; + + HRESULT SetFileToCompile(char *Filename); + char *m_FileToCompile; + CScScript *m_CurrentScript; + HRESULT ResumeAll(); + HRESULT PauseAll(); + void EditorCleanup(); + HRESULT ResetObject(CBObject *Object); + HRESULT ResetScript(CScScript *Script); + HRESULT EmptyScriptCache(); + byte *GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + HRESULT Cleanup(); + int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); + HRESULT Tick(); + CScValue *m_Globals; + CScScript *RunScript(char *Filename, CBScriptHolder *Owner = NULL); + bool m_CompilerAvailable; + HINSTANCE m_CompilerDLL; + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static void WINAPI AddError(void *Data, int Line, char *Text); + static byte *WINAPI LoadFile(void *Data, char *Filename, uint32 *Size); + static void WINAPI CloseFile(void *Data, byte *Buffer); + static void WINAPI ParseElement(void *Data, int Line, int Type, void *ElementData); + DLL_COMPILE_BUFFER ExtCompileBuffer; + DLL_COMPILE_FILE ExtCompileFile; + DLL_RELEASE_BUFFER ExtReleaseBuffer; + DLL_SET_CALLBACKS ExtSetCallbacks; + DLL_DEFINE_FUNCTION ExtDefineFunction; + DLL_DEFINE_VARIABLE ExtDefineVariable; + + CBArray m_Scripts; + + void EnableProfiling(); + void DisableProfiling(); + bool IsProfiling() { + return m_IsProfiling; + } + + void AddScriptTime(const char *Filename, uint32 Time); + void DumpStats(); + +private: + + CScCachedScript *m_CachedScripts[MAX_CACHED_SCRIPTS]; + bool m_IsProfiling; + uint32 m_ProfilingStartTime; + + typedef std::map ScriptTimes; + ScriptTimes m_ScriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp new file mode 100644 index 0000000000..e954fe9d9f --- /dev/null +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -0,0 +1,1600 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + m_Buffer = NULL; + m_BufferSize = m_IP = 0; + m_Filename = NULL; + m_CurrentLine = 0; + + m_Symbols = NULL; + m_NumSymbols = 0; + + m_Engine = Engine; + + m_Globals = NULL; + + m_ScopeStack = NULL; + m_CallStack = NULL; + m_ThisStack = NULL; + m_Stack = NULL; + + m_Operand = NULL; + m_Reg1 = NULL; + + m_Functions = NULL; + m_NumFunctions = 0; + + m_Methods = NULL; + m_NumMethods = 0; + + m_Events = NULL; + m_NumEvents = 0; + + m_Externals = NULL; + m_NumExternals = 0; + + m_State = SCRIPT_FINISHED; + m_OrigState = SCRIPT_FINISHED; + + m_WaitObject = NULL; + m_WaitTime = 0; + m_WaitFrozen = false; + m_WaitScript = NULL; + + m_TimeSlice = 0; + + m_Thread = false; + m_MethodThread = false; + m_ThreadEvent = NULL; + + m_Freezable = true; + m_Owner = NULL; + + m_Unbreakable = false; + m_ParentScript = NULL; + + m_TracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + Cleanup(); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::InitScript() { + TScriptHeader *Header = (TScriptHeader *)m_Buffer; + if (Header->magic != SCRIPT_MAGIC) { + Game->LOG(0, "File '%s' is not a valid compiled script", m_Filename); + Cleanup(); + return E_FAIL; + } + + if (Header->version > SCRIPT_VERSION) { + Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", m_Filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + Cleanup(); + return E_FAIL; + } + + InitTables(); + + // init stacks + m_ScopeStack = new CScStack(Game); + m_CallStack = new CScStack(Game); + m_ThisStack = new CScStack(Game); + m_Stack = new CScStack(Game); + + m_Operand = new CScValue(Game); + m_Reg1 = new CScValue(Game); + + + // skip to the beginning + m_IP = Header->code_start; + m_CurrentLine = 0; + + // init breakpoints + m_Engine->RefreshScriptBreakpoints(this); + + + // ready to rumble... + m_State = SCRIPT_RUNNING; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::InitTables() { + uint32 OrigIP = m_IP; + + TScriptHeader *Header = (TScriptHeader *)m_Buffer; + + uint32 i; + + // load symbol table + m_IP = Header->symbol_table; + + m_NumSymbols = GetDWORD(); + m_Symbols = new char*[m_NumSymbols]; + for (i = 0; i < m_NumSymbols; i++) { + uint32 index = GetDWORD(); + m_Symbols[index] = GetString(); + } + + // load functions table + m_IP = Header->func_table; + + m_NumFunctions = GetDWORD(); + m_Functions = new TFunctionPos[m_NumFunctions]; + for (i = 0; i < m_NumFunctions; i++) { + m_Functions[i].pos = GetDWORD(); + m_Functions[i].name = GetString(); + } + + + // load events table + m_IP = Header->event_table; + + m_NumEvents = GetDWORD(); + m_Events = new TEventPos[m_NumEvents]; + for (i = 0; i < m_NumEvents; i++) { + m_Events[i].pos = GetDWORD(); + m_Events[i].name = GetString(); + } + + + // load externals + if (Header->version >= 0x0101) { + m_IP = Header->externals_table; + + m_NumExternals = GetDWORD(); + m_Externals = new TExternalFunction[m_NumExternals]; + for (i = 0; i < m_NumExternals; i++) { + m_Externals[i].dll_name = GetString(); + m_Externals[i].name = GetString(); + m_Externals[i].call_type = (TCallType)GetDWORD(); + m_Externals[i].returns = (TExternalType)GetDWORD(); + m_Externals[i].num_params = GetDWORD(); + if (m_Externals[i].num_params > 0) { + m_Externals[i].params = new TExternalType[m_Externals[i].num_params]; + for (int j = 0; j < m_Externals[i].num_params; j++) { + m_Externals[i].params[j] = (TExternalType)GetDWORD(); + } + } + } + } + + // load method table + m_IP = Header->method_table; + + m_NumMethods = GetDWORD(); + m_Methods = new TMethodPos[m_NumMethods]; + for (i = 0; i < m_NumMethods; i++) { + m_Methods[i].pos = GetDWORD(); + m_Methods[i].name = GetString(); + } + + + m_IP = OrigIP; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { + Cleanup(); + + m_Thread = false; + m_MethodThread = false; + + delete[] m_ThreadEvent; + m_ThreadEvent = NULL; + + m_Filename = new char[strlen(Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Filename); + + m_Buffer = new byte [Size]; + if (!m_Buffer) return E_FAIL; + + memcpy(m_Buffer, Buffer, Size); + + m_BufferSize = Size; + + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // establish global variables table + m_Globals = new CScValue(Game); + + m_Owner = Owner; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { + Cleanup(); + + m_Thread = true; + m_MethodThread = false; + m_ThreadEvent = new char[strlen(EventName) + 1]; + if (m_ThreadEvent) strcpy(m_ThreadEvent, EventName); + + // copy filename + m_Filename = new char[strlen(Original->m_Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Original->m_Filename); + + // copy buffer + m_Buffer = new byte [Original->m_BufferSize]; + if (!m_Buffer) return E_FAIL; + + memcpy(m_Buffer, Original->m_Buffer, Original->m_BufferSize); + m_BufferSize = Original->m_BufferSize; + + // initialize + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // copy globals + m_Globals = Original->m_Globals; + + // skip to the beginning of the event + m_IP = InitIP; + + m_TimeSlice = Original->m_TimeSlice; + m_Freezable = Original->m_Freezable; + m_Owner = Original->m_Owner; + + m_Engine = Original->m_Engine; + m_ParentScript = Original; + + return S_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodName) { + uint32 IP = Original->GetMethodPos(MethodName); + if (IP == 0) return E_FAIL; + + Cleanup(); + + m_Thread = true; + m_MethodThread = true; + m_ThreadEvent = new char[strlen(MethodName) + 1]; + if (m_ThreadEvent) strcpy(m_ThreadEvent, MethodName); + + // copy filename + m_Filename = new char[strlen(Original->m_Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Original->m_Filename); + + // copy buffer + m_Buffer = new byte [Original->m_BufferSize]; + if (!m_Buffer) return E_FAIL; + + memcpy(m_Buffer, Original->m_Buffer, Original->m_BufferSize); + m_BufferSize = Original->m_BufferSize; + + // initialize + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // copy globals + m_Globals = Original->m_Globals; + + // skip to the beginning of the event + m_IP = IP; + + m_TimeSlice = Original->m_TimeSlice; + m_Freezable = Original->m_Freezable; + m_Owner = Original->m_Owner; + + m_Engine = Original->m_Engine; + m_ParentScript = Original; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::Cleanup() { + if (m_Buffer) delete [] m_Buffer; + m_Buffer = NULL; + + if (m_Filename) delete [] m_Filename; + m_Filename = NULL; + + if (m_Symbols) delete [] m_Symbols; + m_Symbols = NULL; + m_NumSymbols = 0; + + if (m_Globals && !m_Thread) delete m_Globals; + m_Globals = NULL; + + if (m_ScopeStack) delete m_ScopeStack; + m_ScopeStack = NULL; + + if (m_CallStack) delete m_CallStack; + m_CallStack = NULL; + + if (m_ThisStack) delete m_ThisStack; + m_ThisStack = NULL; + + if (m_Stack) delete m_Stack; + m_Stack = NULL; + + if (m_Functions) delete [] m_Functions; + m_Functions = NULL; + m_NumFunctions = 0; + + if (m_Methods) delete [] m_Methods; + m_Methods = NULL; + m_NumMethods = 0; + + if (m_Events) delete [] m_Events; + m_Events = NULL; + m_NumEvents = 0; + + + if (m_Externals) { + for (int i = 0; i < m_NumExternals; i++) { + if (m_Externals[i].num_params > 0) delete [] m_Externals[i].params; + } + delete [] m_Externals; + } + m_Externals = NULL; + m_NumExternals = 0; + + delete m_Operand; + delete m_Reg1; + m_Operand = NULL; + m_Reg1 = NULL; + + delete[] m_ThreadEvent; + m_ThreadEvent = NULL; + + m_State = SCRIPT_FINISHED; + + m_WaitObject = NULL; + m_WaitTime = 0; + m_WaitFrozen = false; + m_WaitScript = NULL; + + m_ParentScript = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetDWORD() { + uint32 ret = *(uint32 *)(m_Buffer + m_IP); + m_IP += sizeof(uint32); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +double CScScript::GetFloat() { + double ret = *(double *)(m_Buffer + m_IP); + m_IP += sizeof(double); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::GetString() { + char *ret = (char *)(m_Buffer + m_IP); + while (*(char *)(m_Buffer + m_IP) != '\0') m_IP++; + m_IP++; // string terminator + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::ExecuteInstruction() { + HRESULT ret = S_OK; + + uint32 dw; + char *str; + + //CScValue* op = new CScValue(Game); + m_Operand->Cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = GetDWORD(); + switch (inst) { + + case II_DEF_VAR: + m_Operand->SetNULL(); + dw = GetDWORD(); + if (m_ScopeStack->m_SP < 0) { + m_Globals->SetProp(m_Symbols[dw], m_Operand); + if (Game->GetDebugMgr()->m_Enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, m_Globals->GetProp(m_Symbols[dw]), m_Symbols[dw]); + } else { + m_ScopeStack->GetTop()->SetProp(m_Symbols[dw], m_Operand); + if (Game->GetDebugMgr()->m_Enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, m_ScopeStack->GetTop(), m_ScopeStack->GetTop()->GetProp(m_Symbols[dw]), m_Symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = GetDWORD(); + char *Temp = m_Symbols[dw]; // TODO delete + // only create global var if it doesn't exist + if (!m_Engine->m_Globals->PropExists(m_Symbols[dw])) { + m_Operand->SetNULL(); + m_Engine->m_Globals->SetProp(m_Symbols[dw], m_Operand, false, inst == II_DEF_CONST_VAR); + + if (Game->GetDebugMgr()->m_Enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, m_Engine->m_Globals->GetProp(m_Symbols[dw]), m_Symbols[dw]); + } + break; + } + + case II_RET: + if (m_ScopeStack->m_SP >= 0 && m_CallStack->m_SP >= 0) { + Game->GetDebugMgr()->OnScriptShutdownScope(this, m_ScopeStack->GetTop()); + + m_ScopeStack->Pop(); + m_IP = (uint32)m_CallStack->Pop()->GetInt(); + + if (m_ScopeStack->m_SP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, m_ScopeStack->GetTop()); + } else { + if (m_Thread) { + m_State = SCRIPT_THREAD_FINISHED; + } else { + if (m_NumEvents == 0 && m_NumMethods == 0) m_State = SCRIPT_FINISHED; + else m_State = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + m_State = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = GetDWORD(); + + m_Operand->SetInt(m_IP); + m_CallStack->Push(m_Operand); + + m_IP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = m_Stack->Pop()->GetString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = m_Stack->Pop(); + if (var->m_Type == VAL_VARIABLE_REF) var = var->m_ValRef; + + HRESULT res = E_FAIL; + bool TriedNative = false; + + // we are already calling this method, try native + if (m_Thread && m_MethodThread && strcmp(MethodName, m_ThreadEvent) == 0 && var->m_Type == VAL_NATIVE && m_Owner == var->GetNative()) { + TriedNative = true; + res = var->m_ValNative->ScCallMethod(this, m_Stack, m_ThisStack, MethodName); + } + + if (FAILED(res)) { + if (var->IsNative() && var->GetNative()->CanHandleMethod(MethodName)) { + if (!m_Unbreakable) { + m_WaitScript = var->GetNative()->InvokeMethodThread(MethodName); + if (!m_WaitScript) { + m_Stack->CorrectParams(0); + RuntimeError("Error invoking method '%s'.", MethodName); + m_Stack->PushNULL(); + } else { + m_State = SCRIPT_WAITING_SCRIPT; + m_WaitScript->CopyParameters(m_Stack); + } + } else { + // can call methods in unbreakable mode + m_Stack->CorrectParams(0); + RuntimeError("Cannot call method '%s'. Ignored.", MethodName); + m_Stack->PushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->GetProp(MethodName); + if(val){ + dw = GetFuncPos(val->GetString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->GetString()); + if(f){ + ExternalCall(m_Stack, m_ThisStack, f); + } + else{ + // not an internal nor external, try for native function + Game->ExternalCall(this, m_Stack, m_ThisStack, val->GetString()); + } + } + else{ + m_Operand->SetInt(m_IP); + m_CallStack->Push(m_Operand); + m_IP = dw; + } + } + */ + else { + res = E_FAIL; + if (var->m_Type == VAL_NATIVE && !TriedNative) res = var->m_ValNative->ScCallMethod(this, m_Stack, m_ThisStack, MethodName); + + if (FAILED(res)) { + m_Stack->CorrectParams(0); + RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); + m_Stack->PushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = GetDWORD(); + + TExternalFunction *f = GetExternal(m_Symbols[SymbolIndex]); + if (f) { + ExternalCall(m_Stack, m_ThisStack, f); + } else Game->ExternalCall(this, m_Stack, m_ThisStack, m_Symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + m_Operand->SetNULL(); + m_ScopeStack->Push(m_Operand); + + if (m_ScopeStack->m_SP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, m_ScopeStack->GetTop()); + + break; + + case II_CORRECT_STACK: + dw = GetDWORD(); // params expected + m_Stack->CorrectParams(dw); + break; + + case II_CREATE_OBJECT: + m_Operand->SetObject(); + m_Stack->Push(m_Operand); + break; + + case II_POP_EMPTY: + m_Stack->Pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = GetVar(m_Symbols[GetDWORD()]); + if (false && /*var->m_Type==VAL_OBJECT ||*/ var->m_Type == VAL_NATIVE) { + m_Operand->SetReference(var); + m_Stack->Push(m_Operand); + } else m_Stack->Push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = GetVar(m_Symbols[GetDWORD()]); + m_Operand->SetReference(var); + m_Stack->Push(m_Operand); + break; + } + + case II_POP_VAR: { + char *VarName = m_Symbols[GetDWORD()]; + CScValue *var = GetVar(VarName); + if (var) { + CScValue *val = m_Stack->Pop(); + if (!val) { + RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->SetNULL(); + } else { + if (val->GetType() == VAL_VARIABLE_REF) val = val->m_ValRef; + if (val->m_Type == VAL_NATIVE) var->SetValue(val); + else { + var->Copy(val); + } + } + + if (Game->GetDebugMgr()->m_Enabled) + Game->GetDebugMgr()->OnVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + m_Stack->Push(m_ThisStack->GetTop()); + break; + + case II_PUSH_INT: + m_Stack->PushInt((int)GetDWORD()); + break; + + case II_PUSH_FLOAT: + m_Stack->PushFloat(GetFloat()); + break; + + + case II_PUSH_BOOL: + m_Stack->PushBool(GetDWORD() != 0); + + break; + + case II_PUSH_STRING: + m_Stack->PushString(GetString()); + break; + + case II_PUSH_NULL: + m_Stack->PushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + m_Operand->SetReference(m_Stack->GetTop()); + m_ThisStack->Push(m_Operand); + break; + + case II_PUSH_THIS: + m_Operand->SetReference(GetVar(m_Symbols[GetDWORD()])); + m_ThisStack->Push(m_Operand); + break; + + case II_POP_THIS: + m_ThisStack->Pop(); + break; + + case II_PUSH_BY_EXP: { + str = m_Stack->Pop()->GetString(); + CScValue *val = m_Stack->Pop()->GetProp(str); + if (val) m_Stack->Push(val); + else m_Stack->PushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = m_Stack->Pop()->GetString(); + CScValue *var = m_Stack->Pop(); + CScValue *val = m_Stack->Pop(); + + if (val == NULL) { + RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->SetNULL(); + } else var->SetProp(str, val); + + if (Game->GetDebugMgr()->m_Enabled) + Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + m_Stack->Push(m_Reg1); + break; + + case II_POP_REG1: + m_Reg1->Copy(m_Stack->Pop()); + break; + + case II_JMP: + m_IP = GetDWORD(); + break; + + case II_JMP_FALSE: { + dw = GetDWORD(); + //if(!m_Stack->Pop()->GetBool()) m_IP = dw; + CScValue *Val = m_Stack->Pop(); + if (!Val) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!Val->GetBool()) m_IP = dw; + } + break; + } + + case II_ADD: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { + str = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; + strcpy(str, op1->GetString()); + strcat(str, op2->GetString()); + m_Operand->SetString(str); + delete [] str; + } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + m_Operand->SetInt(op1->GetInt() + op2->GetInt()); + else m_Operand->SetFloat(op1->GetFloat() + op2->GetFloat()); + + m_Stack->Push(m_Operand); + + break; + + case II_SUB: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + m_Operand->SetInt(op1->GetInt() - op2->GetInt()); + else m_Operand->SetFloat(op1->GetFloat() - op2->GetFloat()); + + m_Stack->Push(m_Operand); + + break; + + case II_MUL: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + m_Operand->SetInt(op1->GetInt() * op2->GetInt()); + else m_Operand->SetFloat(op1->GetFloat() * op2->GetFloat()); + + m_Stack->Push(m_Operand); + + break; + + case II_DIV: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); + + if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) m_Operand->SetNULL(); + else m_Operand->SetFloat(op1->GetFloat() / op2->GetFloat()); + + m_Stack->Push(m_Operand); + + break; + + case II_MODULO: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + if (op2->GetInt() == 0) RuntimeError("Division by zero."); + + if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) m_Operand->SetNULL(); + else m_Operand->SetInt(op1->GetInt() % op2->GetInt()); + + m_Stack->Push(m_Operand); + + break; + + case II_NOT: + op1 = m_Stack->Pop(); + //if(op1->IsNULL()) m_Operand->SetNULL(); + if (op1->IsNULL()) m_Operand->SetBool(true); + else m_Operand->SetBool(!op1->GetBool()); + m_Stack->Push(m_Operand); + + break; + + case II_AND: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + if (op1 == NULL || op2 == NULL) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + m_Operand->SetBool(false); + } else { + m_Operand->SetBool(op1->GetBool() && op2->GetBool()); + } + m_Stack->Push(m_Operand); + break; + + case II_OR: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + if (op1 == NULL || op2 == NULL) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + m_Operand->SetBool(false); + } else { + m_Operand->SetBool(op1->GetBool() || op2->GetBool()); + } + m_Stack->Push(m_Operand); + break; + + case II_CMP_EQ: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) m_Operand->SetBool(false); + else if(op1->IsNative() && op2->IsNative()){ + m_Operand->SetBool(op1->GetNative() == op2->GetNative()); + } + else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ + m_Operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); + } + else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() == op2->GetFloat()); + } + else{ + m_Operand->SetBool(op1->GetInt() == op2->GetInt()); + } + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) == 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_NE: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) m_Operand->SetBool(true); + else if(op1->IsNative() && op2->IsNative()){ + m_Operand->SetBool(op1->GetNative() != op2->GetNative()); + } + else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ + m_Operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); + } + else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() != op2->GetFloat()); + } + else{ + m_Operand->SetBool(op1->GetInt() != op2->GetInt()); + } + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) != 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_L: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() < op2->GetFloat()); + } + else m_Operand->SetBool(op1->GetInt() < op2->GetInt()); + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) < 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_G: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() > op2->GetFloat()); + } + else m_Operand->SetBool(op1->GetInt() > op2->GetInt()); + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) > 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_LE: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() <= op2->GetFloat()); + } + else m_Operand->SetBool(op1->GetInt() <= op2->GetInt()); + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) <= 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_GE: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + m_Operand->SetBool(op1->GetFloat() >= op2->GetFloat()); + } + else m_Operand->SetBool(op1->GetInt() >= op2->GetInt()); + */ + + m_Operand->SetBool(CScValue::Compare(op1, op2) >= 0); + m_Stack->Push(m_Operand); + break; + + case II_CMP_STRICT_EQ: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + //m_Operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); + m_Operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); + m_Stack->Push(m_Operand); + + break; + + case II_CMP_STRICT_NE: + op2 = m_Stack->Pop(); + op1 = m_Stack->Pop(); + + //m_Operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); + m_Operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); + m_Stack->Push(m_Operand); + break; + + case II_DBG_LINE: { + int NewLine = GetDWORD(); + if (NewLine != m_CurrentLine) { + m_CurrentLine = NewLine; + if (Game->GetDebugMgr()->m_Enabled) { + Game->GetDebugMgr()->OnScriptChangeLine(this, m_CurrentLine); + for (int i = 0; i < m_Breakpoints.GetSize(); i++) { + if (m_Breakpoints[i] == m_CurrentLine) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Sleep(0); + break; + } + } + if (m_TracingMode) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Sleep(0); + break; + } + } + } + break; + + } + default: + Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, m_Filename, m_CurrentLine, m_IP - sizeof(uint32)); + m_State = SCRIPT_FINISHED; + ret = E_FAIL; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetFuncPos(const char *Name) { + for (int i = 0; i < m_NumFunctions; i++) { + if (strcmp(Name, m_Functions[i].name) == 0) return m_Functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetMethodPos(const char *Name) { + for (int i = 0; i < m_NumMethods; i++) { + if (strcmp(Name, m_Methods[i].name) == 0) return m_Methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::GetVar(char *Name) { + CScValue *ret = NULL; + + // scope locals + if (m_ScopeStack->m_SP >= 0) { + if (m_ScopeStack->GetTop()->PropExists(Name)) ret = m_ScopeStack->GetTop()->GetProp(Name); + } + + // script globals + if (ret == NULL) { + if (m_Globals->PropExists(Name)) ret = m_Globals->GetProp(Name); + } + + // engine globals + if (ret == NULL) { + if (m_Engine->m_Globals->PropExists(Name)) ret = m_Engine->m_Globals->GetProp(Name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", Name); + Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, m_Filename, m_CurrentLine); + CScValue *Val = new CScValue(Game); + CScValue *Scope = m_ScopeStack->GetTop(); + if (Scope) { + Scope->SetProp(Name, Val); + ret = m_ScopeStack->GetTop()->GetProp(Name); + } else { + m_Globals->SetProp(Name, Val); + ret = m_Globals->GetProp(Name); + } + delete Val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::WaitFor(CBObject *Object) { + if (m_Unbreakable) { + RuntimeError("Script cannot be interrupted."); + return S_OK; + } + + m_State = SCRIPT_WAITING; + m_WaitObject = Object; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::WaitForExclusive(CBObject *Object) { + m_Engine->ResetObject(Object); + return WaitFor(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Sleep(uint32 Duration) { + if (m_Unbreakable) { + RuntimeError("Script cannot be interrupted."); + return S_OK; + } + + m_State = SCRIPT_SLEEPING; + if (Game->m_State == GAME_FROZEN) { + m_WaitTime = CBPlatform::GetTime() + Duration; + m_WaitFrozen = true; + } else { + m_WaitTime = Game->m_Timer + Duration; + m_WaitFrozen = false; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Finish(bool IncludingThreads) { + if (m_State != SCRIPT_FINISHED && IncludingThreads) { + m_State = SCRIPT_FINISHED; + FinishThreads(); + } else m_State = SCRIPT_FINISHED; + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Run() { + m_State = SCRIPT_RUNNING; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::RuntimeError(LPCSTR fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + Game->LOG(0, "Runtime error. Script '%s', line %d", m_Filename, m_CurrentLine); + Game->LOG(0, " %s", buff); + + if (!Game->m_SuppressScriptErrors) + Game->QuickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + // buffer + if (PersistMgr->m_Saving) { + if (m_State != SCRIPT_PERSISTENT && m_State != SCRIPT_FINISHED && m_State != SCRIPT_THREAD_FINISHED) { + PersistMgr->Transfer(TMEMBER(m_BufferSize)); + PersistMgr->PutBytes(m_Buffer, m_BufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + PersistMgr->Transfer(TMEMBER(bufferSize)); + } + } else { + PersistMgr->Transfer(TMEMBER(m_BufferSize)); + if (m_BufferSize > 0) { + m_Buffer = new byte[m_BufferSize]; + PersistMgr->GetBytes(m_Buffer, m_BufferSize); + InitTables(); + } else m_Buffer = NULL; + } + + PersistMgr->Transfer(TMEMBER(m_CallStack)); + PersistMgr->Transfer(TMEMBER(m_CurrentLine)); + PersistMgr->Transfer(TMEMBER(m_Engine)); + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_Freezable)); + PersistMgr->Transfer(TMEMBER(m_Globals)); + PersistMgr->Transfer(TMEMBER(m_IP)); + PersistMgr->Transfer(TMEMBER(m_ScopeStack)); + PersistMgr->Transfer(TMEMBER(m_Stack)); + PersistMgr->Transfer(TMEMBER_INT(m_State)); + PersistMgr->Transfer(TMEMBER(m_Operand)); + PersistMgr->Transfer(TMEMBER_INT(m_OrigState)); + PersistMgr->Transfer(TMEMBER(m_Owner)); + PersistMgr->Transfer(TMEMBER(m_Reg1)); + PersistMgr->Transfer(TMEMBER(m_Thread)); + PersistMgr->Transfer(TMEMBER(m_ThreadEvent)); + PersistMgr->Transfer(TMEMBER(m_ThisStack)); + PersistMgr->Transfer(TMEMBER(m_TimeSlice)); + PersistMgr->Transfer(TMEMBER(m_WaitObject)); + PersistMgr->Transfer(TMEMBER(m_WaitScript)); + PersistMgr->Transfer(TMEMBER(m_WaitTime)); + PersistMgr->Transfer(TMEMBER(m_WaitFrozen)); + + PersistMgr->Transfer(TMEMBER(m_MethodThread)); + PersistMgr->Transfer(TMEMBER(m_MethodThread)); + PersistMgr->Transfer(TMEMBER(m_Unbreakable)); + PersistMgr->Transfer(TMEMBER(m_ParentScript)); + + if (!PersistMgr->m_Saving) m_TracingMode = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable) { + //if(m_State!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = GetEventPos(EventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(Game, m_Engine); + if (thread) { + HRESULT ret = thread->CreateThread(this, pos, EventName); + if (SUCCEEDED(ret)) { + thread->m_Unbreakable = Unbreakable; + m_Engine->m_Scripts.Add(thread); + Game->GetDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetEventPos(const char *Name) { + for (int i = m_NumEvents - 1; i >= 0; i--) { + if (scumm_stricmp(Name, m_Events[i].name) == 0) return m_Events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::CanHandleEvent(char *EventName) { + return GetEventPos(EventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::CanHandleMethod(char *MethodName) { + return GetMethodPos(MethodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Pause() { + if (m_State == SCRIPT_PAUSED) { + Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", m_Filename, m_CurrentLine); + return E_FAIL; + } + + if (!m_Freezable || m_State == SCRIPT_PERSISTENT) return S_OK; + + m_OrigState = m_State; + m_State = SCRIPT_PAUSED; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Resume() { + if (m_State != SCRIPT_PAUSED) return S_OK; + + m_State = m_OrigState; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::GetExternal(char *Name) { + for (int i = 0; i < m_NumExternals; i++) { + if (strcmp(Name, m_Externals[i].name) == 0) return &m_Externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function) { + +#ifndef __WIN32__ + + Game->LOG(0, "External functions are not supported on this platform."); + Stack->CorrectParams(0); + Stack->PushNULL(); + return E_FAIL; + +#else + + bool Success = false; + HMODULE hDll = LoadLibrary(Function->dll_name); + + if (hDll) { + FARPROC pFunc = GetProcAddress(hDll, Function->name); + if (pFunc) { + int i; + Success = true; + Stack->CorrectParams(Function->num_params); + CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); + + for (i = 0; i < Function->num_params; i++) { + CScValue *Val = Stack->Pop(); + switch (Function->params[i]) { + case TYPE_BOOL: + Buffer->PutDWORD((uint32)Val->GetBool()); + break; + case TYPE_LONG: + Buffer->PutDWORD(Val->GetInt()); + break; + case TYPE_BYTE: + Buffer->PutDWORD((byte )Val->GetInt()); + break; + case TYPE_STRING: + if (Val->IsNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->GetString()); + break; + case TYPE_MEMBUFFER: + if (Val->IsNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->GetMemBuffer()); + break; + case TYPE_FLOAT: { + float f = Val->GetFloat(); + Buffer->PutDWORD(*((uint32 *)&f)); + break; + } + case TYPE_DOUBLE: { + double d = Val->GetFloat(); + uint32 *pd = (uint32 *)&d; + + Buffer->PutDWORD(pd[0]); + Buffer->PutDWORD(pd[1]); + break; + } + } + } + + // call + uint32 ret; + bool StackCorrupted = false; + switch (Function->call_type) { + case CALL_CDECL: + ret = Call_cdecl(Buffer->m_Buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + break; + default: + ret = Call_stdcall(Buffer->m_Buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + } + delete Buffer; + + // return + switch (Function->returns) { + case TYPE_BOOL: + Stack->PushBool((byte )ret != 0); + break; + case TYPE_LONG: + Stack->PushInt(ret); + break; + case TYPE_BYTE: + Stack->PushInt((byte )ret); + break; + break; + case TYPE_STRING: + Stack->PushString((char *)ret); + break; + case TYPE_MEMBUFFER: { + CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); + Stack->PushNative(Buf, false); + } + break; + case TYPE_FLOAT: { + uint32 dw = GetST0(); + Stack->PushFloat(*((float *)&dw)); + break; + } + case TYPE_DOUBLE: + Stack->PushFloat(GetST0Double()); + break; + + default: + Stack->PushNULL(); + } + + if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); + } else RuntimeError("Exported function '%s' not found in '%s'", Function->name, Function->dll_name); + } else RuntimeError("Error loading DLL '%s'", Function->dll_name); + + if (!Success) { + Stack->CorrectParams(0); + Stack->PushNULL(); + } + + if (hDll) FreeLibrary(hDll); + + return Success ? S_OK : E_FAIL; +#endif +} + +#ifdef __WIN32__ +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { + uint32 rc; // here's our return value... + uint32 OrigESP; + bool StkCorrupt = false; + __asm { + mov OrigESP, esp + mov ecx, sz // get size of buffer + mov esi, args // get buffer + sub esp, ecx // allocate stack space + mov edi, esp // start of destination stack frame + shr ecx, 2 // make it dwords + rep movsd // copy params to real stack + call [func] // call the function + mov rc, eax // save the return value + add esp, sz // restore the stack pointer + cmp esp, OrigESP + jz finish + mov esp, OrigESP + mov StkCorrupt, 1 + finish: + } + + if (StackCorrupt) *StackCorrupt = StkCorrupt; + return rc; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { + uint32 rc; // here's our return value... + uint32 OrigESP; + bool StkCorrupt = false; + + __asm { + mov OrigESP, esp + mov ecx, sz // get size of buffer + mov esi, args // get buffer + sub esp, ecx // allocate stack space + mov edi, esp // start of destination stack frame + shr ecx, 2 // make it dwords + rep movsd // copy it + call [func] // call the function + mov rc, eax // save the return value + cmp esp, OrigESP + jz finish + mov esp, OrigESP + mov StkCorrupt, 1 + finish: + } + + if (StackCorrupt) *StackCorrupt = StkCorrupt; + return rc; +} + + +////////////////////////////////////////////////////////////////////////// +__declspec(naked) uint32 CScScript::GetST0(void) { + uint32 f; // temp var + __asm { + fstp uint32 ptr [f] // pop ST0 into f + mov eax, uint32 ptr [f] // copy into eax + ret // done + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScScript::GetST0Double(void) { + double d; // temp var + __asm { + fstp qword ptr [d] // get ST0 into d + } + return d; +} +#endif + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CopyParameters(CScStack *Stack) { + int i; + int NumParams = Stack->Pop()->GetInt(); + for (i = NumParams - 1; i >= 0; i--) { + m_Stack->Push(Stack->GetAt(i)); + } + m_Stack->PushInt(NumParams); + + for (i = 0; i < NumParams; i++) Stack->Pop(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::FinishThreads() { + for (int i = 0; i < m_Engine->m_Scripts.GetSize(); i++) { + CScScript *Scr = m_Engine->m_Scripts[i]; + if (Scr->m_Thread && Scr->m_State != SCRIPT_FINISHED && Scr->m_Owner == m_Owner && scumm_stricmp(Scr->m_Filename, m_Filename) == 0) + Scr->Finish(true); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::DbgGetLine() { + return m_CurrentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::DbgGetFilename() { + return m_Filename; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { + if (m_MethodThread) Client->OnScriptMethodThreadInit(this, m_ParentScript, m_ThreadEvent); + else if (m_Thread) Client->OnScriptEventThreadInit(this, m_ParentScript, m_ThreadEvent); + else Client->OnScriptInit(this); + + return DbgSendVariables(Client); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { + // send script globals + m_Globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (m_ScopeStack->m_SP >= 0) { + for (int i = 0; i <= m_ScopeStack->m_SP; i++) { + CScValue *Scope = m_ScopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::DbgGetState() { + return m_State; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::DbgGetNumBreakpoints() { + return m_Breakpoints.GetSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::DbgGetBreakpoint(int Index) { + if (Index >= 0 && Index < m_Breakpoints.GetSize()) return m_Breakpoints[Index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::DbgSetTracingMode(bool IsTracing) { + m_TracingMode = IsTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::DbgGetTracingMode() { + return m_TracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::AfterLoad() { + if (m_Buffer == NULL) { + byte *buffer = m_Engine->GetCompiledScript(m_Filename, &m_BufferSize); + if (!buffer) { + Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", m_Filename); + m_State = SCRIPT_ERROR; + return; + } + + m_Buffer = new byte [m_BufferSize]; + memcpy(m_Buffer, buffer, m_BufferSize); + + InitTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScScript.h b/engines/wintermute/scriptables/ScScript.h new file mode 100644 index 0000000000..6f467437da --- /dev/null +++ b/engines/wintermute/scriptables/ScScript.h @@ -0,0 +1,185 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + HRESULT DbgSendScript(IWmeDebugClient *Client); + HRESULT DbgSendVariables(IWmeDebugClient *Client); + + CBArray m_Breakpoints; + bool m_TracingMode; + + CScScript *m_ParentScript; + bool m_Unbreakable; + HRESULT FinishThreads(); + HRESULT CopyParameters(CScStack *Stack); + + void AfterLoad(); + +#ifdef __WIN32__ + static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt); + static uint32 Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt); + static uint32 GetST0(void); + static double GetST0Double(void); +#endif + + CScValue *m_Operand; + CScValue *m_Reg1; + bool m_Freezable; + HRESULT Resume(); + HRESULT Pause(); + bool CanHandleEvent(char *EventName); + bool CanHandleMethod(char *MethodName); + HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); + HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); + CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); + uint32 m_TimeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void RuntimeError(LPCSTR fmt, ...); + HRESULT Run(); + HRESULT Finish(bool IncludingThreads = false); + HRESULT Sleep(uint32 Duration); + HRESULT WaitForExclusive(CBObject *Object); + HRESULT WaitFor(CBObject *Object); + uint32 m_WaitTime; + bool m_WaitFrozen; + CBObject *m_WaitObject; + CScScript *m_WaitScript; + TScriptState m_State; + TScriptState m_OrigState; + CScValue *GetVar(char *Name); + uint32 GetFuncPos(const char *Name); + uint32 GetEventPos(const char *Name); + uint32 GetMethodPos(const char *Name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int num_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *m_CallStack; + CScStack *m_ThisStack; + CScStack *m_ScopeStack; + CScStack *m_Stack; + CScValue *m_Globals; + CScEngine *m_Engine; + int m_CurrentLine; + HRESULT ExecuteInstruction(); + char *GetString(); + uint32 GetDWORD(); + double GetFloat(); + void Cleanup(); + HRESULT Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); + uint32 m_IP; + uint32 m_BufferSize; + byte *m_Buffer; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *m_Filename; + char **m_Symbols; + int m_NumSymbols; + TFunctionPos *m_Functions; + TMethodPos *m_Methods; + TEventPos *m_Events; + int m_NumExternals; + TExternalFunction *m_Externals; + int m_NumFunctions; + int m_NumMethods; + int m_NumEvents; + bool m_Thread; + bool m_MethodThread; + char *m_ThreadEvent; + CBScriptHolder *m_Owner; + CScScript::TExternalFunction *GetExternal(char *Name); + HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); +private: + HRESULT InitScript(); + HRESULT InitTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int DbgGetLine(); + virtual const char *DbgGetFilename(); + virtual TScriptState DbgGetState(); + virtual int DbgGetNumBreakpoints(); + virtual int DbgGetBreakpoint(int Index); + + virtual bool DbgSetTracingMode(bool IsTracing); + virtual bool DbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/ScStack.cpp b/engines/wintermute/scriptables/ScStack.cpp new file mode 100644 index 0000000000..7975223516 --- /dev/null +++ b/engines/wintermute/scriptables/ScStack.cpp @@ -0,0 +1,226 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + m_SP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //Game->LOG(0, "STAT: Stack size: %d, SP=%d", m_Values.GetSize(), m_SP); +#endif + + for (int i = 0; i < m_Values.GetSize(); i++) { + delete m_Values[i]; + } + m_Values.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::Pop() { + if (m_SP < 0) { + Game->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return m_Values[m_SP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::Push(CScValue *Val) { + m_SP++; + + if (m_SP < m_Values.GetSize()) { + m_Values[m_SP]->Cleanup(); + m_Values[m_SP]->Copy(Val); + } else { + CScValue *val = new CScValue(Game); + val->Copy(Val); + m_Values.Add(val); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetPushValue() { + m_SP++; + + if (m_SP >= m_Values.GetSize()) { + CScValue *val = new CScValue(Game); + m_Values.Add(val); + } + m_Values[m_SP]->Cleanup(); + return m_Values[m_SP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetTop() { + if (m_SP < 0 || m_SP >= m_Values.GetSize()) return NULL; + else return m_Values[m_SP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetAt(int Index) { + Index = m_SP - Index; + if (Index < 0 || Index >= m_Values.GetSize()) return NULL; + else return m_Values[Index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::CorrectParams(uint32 expected_params) { + int num_params = Pop()->GetInt(); + + if (expected_params < num_params) { // too many params + while (expected_params < num_params) { + //Pop(); + delete m_Values[m_SP - expected_params]; + m_Values.RemoveAt(m_SP - expected_params); + num_params--; + m_SP--; + } + } else if (expected_params > num_params) { // need more params + while (expected_params > num_params) { + //Push(null_val); + CScValue *null_val = new CScValue(Game); + null_val->SetNULL(); + m_Values.InsertAt(m_SP - num_params + 1, null_val); + num_params++; + m_SP++; + + if (m_Values.GetSize() > m_SP + 1) { + delete m_Values[m_Values.GetSize() - 1]; + m_Values.RemoveAt(m_Values.GetSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushNULL() { + /* + CScValue* val = new CScValue(Game); + val->SetNULL(); + Push(val); + delete val; + */ + GetPushValue()->SetNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushInt(int Val) { + /* + CScValue* val = new CScValue(Game); + val->SetInt(Val); + Push(val); + delete val; + */ + GetPushValue()->SetInt(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushFloat(double Val) { + /* + CScValue* val = new CScValue(Game); + val->SetFloat(Val); + Push(val); + delete val; + */ + GetPushValue()->SetFloat(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushBool(bool Val) { + /* + CScValue* val = new CScValue(Game); + val->SetBool(Val); + Push(val); + delete val; + */ + GetPushValue()->SetBool(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushString(const char *Val) { + /* + CScValue* val = new CScValue(Game); + val->SetString(Val); + Push(val); + delete val; + */ + GetPushValue()->SetString(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushNative(CBScriptable *Val, bool Persistent) { + /* + CScValue* val = new CScValue(Game); + val->SetNative(Val, Persistent); + Push(val); + delete val; + */ + + GetPushValue()->SetNative(Val, Persistent); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScStack::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_SP)); + m_Values.Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScStack.h b/engines/wintermute/scriptables/ScStack.h new file mode 100644 index 0000000000..70d54cbbe4 --- /dev/null +++ b/engines/wintermute/scriptables/ScStack.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *GetAt(int Index); + CScValue *GetPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void PushNative(CBScriptable *Val, bool Persistent); + void PushString(const char *Val); + void PushBool(bool Val); + void PushInt(int Val); + void PushFloat(double Val); + void PushNULL(); + void CorrectParams(uint32 expected_params); + CScValue *GetTop(); + void Push(CScValue *Val); + CScValue *Pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray m_Values; + int m_SP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp new file mode 100644 index 0000000000..387bf45b46 --- /dev/null +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -0,0 +1,1025 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + m_Type = VAL_NULL; + + m_ValBool = false; + m_ValInt = 0; + m_ValFloat = 0.0f; + m_ValNative = NULL; + m_ValString = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { + m_Type = VAL_BOOL; + m_ValBool = Val; + + m_ValInt = 0; + m_ValFloat = 0.0f; + m_ValNative = NULL; + m_ValString = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { + m_Type = VAL_INT; + m_ValInt = Val; + + m_ValFloat = 0.0f; + m_ValBool = false; + m_ValNative = NULL; + m_ValString = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { + m_Type = VAL_FLOAT; + m_ValFloat = Val; + + m_ValInt = 0; + m_ValBool = false; + m_ValNative = NULL; + m_ValString = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { + m_Type = VAL_STRING; + m_ValString = NULL; + SetStringVal(Val); + + m_ValBool = false; + m_ValInt = 0; + m_ValFloat = 0.0f; + m_ValNative = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::Cleanup(bool IgnoreNatives) { + DeleteProps(); + + if (m_ValString) delete [] m_ValString; + + if (!IgnoreNatives) { + if (m_ValNative && !m_Persistent) { + m_ValNative->m_RefCount--; + if (m_ValNative->m_RefCount <= 0) { + delete m_ValNative; + m_ValNative = NULL; + } + } + } + + + m_Type = VAL_NULL; + + m_ValBool = false; + m_ValInt = 0; + m_ValFloat = 0.0f; + m_ValNative = NULL; + m_ValString = NULL; + m_ValRef = NULL; + m_Persistent = false; + m_IsConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::GetProp(char *Name) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetProp(Name); + + if (m_Type == VAL_STRING && strcmp(Name, "Length") == 0) { + Game->m_ScValue->m_Type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (Game->m_TextEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + Game->m_ScValue->SetInt(strlen(m_ValString)); + } else { + WideString wstr = StringUtil::Utf8ToWide(m_ValString); + Game->m_ScValue->SetInt(wstr.length()); + } + + return Game->m_ScValue; + } + + CScValue *ret = NULL; + + if (m_Type == VAL_NATIVE && m_ValNative) ret = m_ValNative->ScGetProperty(Name); + + if (ret == NULL) { + m_ValIter = m_ValObject.find(Name); + if (m_ValIter != m_ValObject.end()) ret = m_ValIter->second; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::DeleteProp(char *Name) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->DeleteProp(Name); + + m_ValIter = m_ValObject.find(Name); + if (m_ValIter != m_ValObject.end()) { + delete m_ValIter->second; + m_ValIter->second = NULL; + } + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->SetProp(Name, Val); + + HRESULT ret = E_FAIL; + if (m_Type == VAL_NATIVE && m_ValNative) { + ret = m_ValNative->ScSetProperty(Name, Val); + } + + if (FAILED(ret)) { + CScValue *val = NULL; + + m_ValIter = m_ValObject.find(Name); + if (m_ValIter != m_ValObject.end()) { + val = m_ValIter->second; + } + if (!val) val = new CScValue(Game); + else val->Cleanup(); + + val->Copy(Val, CopyWhole); + val->m_IsConstVar = SetAsConst; + m_ValObject[Name] = val; + + if (m_Type != VAL_NATIVE) m_Type = VAL_OBJECT; + + /* + m_ValIter = m_ValObject.find(Name); + if (m_ValIter != m_ValObject.end()){ + delete m_ValIter->second; + m_ValIter->second = NULL; + } + CScValue* val = new CScValue(Game); + val->Copy(Val, CopyWhole); + val->m_IsConstVar = SetAsConst; + m_ValObject[Name] = val; + + if(m_Type!=VAL_NATIVE) m_Type = VAL_OBJECT; + */ + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::PropExists(char *Name) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->PropExists(Name); + m_ValIter = m_ValObject.find(Name); + + return (m_ValIter != m_ValObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::DeleteProps() { + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + delete(CScValue *)m_ValIter->second; + m_ValIter++; + } + m_ValObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool IncludingNatives) { + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + if (!m_ValIter->second->m_IsConstVar && (!m_ValIter->second->IsNative() || IncludingNatives)) m_ValIter->second->SetNULL(); + m_ValIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsNULL() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsNULL(); + + return (m_Type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsNative() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsNative(); + + return (m_Type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsString() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsString(); + + return (m_Type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsFloat() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsFloat(); + + return (m_Type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsInt() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsInt(); + + return (m_Type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsBool() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsBool(); + + return (m_Type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsObject() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsObject(); + + return (m_Type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::GetTypeTolerant() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetType(); + + return m_Type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetBool(bool Val) { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetBool(Val); + return; + } + + if (m_Type == VAL_NATIVE) { + m_ValNative->ScSetBool(Val); + return; + } + + m_ValBool = Val; + m_Type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetInt(int Val) { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetInt(Val); + return; + } + + if (m_Type == VAL_NATIVE) { + m_ValNative->ScSetInt(Val); + return; + } + + m_ValInt = Val; + m_Type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetFloat(double Val) { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetFloat(Val); + return; + } + + if (m_Type == VAL_NATIVE) { + m_ValNative->ScSetFloat(Val); + return; + } + + m_ValFloat = Val; + m_Type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetString(const char *Val) { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetString(Val); + return; + } + + if (m_Type == VAL_NATIVE) { + m_ValNative->ScSetString(Val); + return; + } + + SetStringVal(Val); + if (m_ValString) m_Type = VAL_STRING; + else m_Type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetStringVal(const char *Val) { + if (m_ValString) delete [] m_ValString; + + if (Val == NULL) { + m_ValString = NULL; + return; + } + + m_ValString = new char [strlen(Val) + 1]; + if (m_ValString) { + strcpy(m_ValString, Val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetNULL() { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetNULL(); + return; + } + + if (m_ValNative && !m_Persistent) { + m_ValNative->m_RefCount--; + if (m_ValNative->m_RefCount <= 0) delete m_ValNative; + } + m_ValNative = NULL; + DeleteProps(); + + m_Type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetNative(CBScriptable *Val, bool Persistent) { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetNative(Val, Persistent); + return; + } + + if (Val == NULL) { + SetNULL(); + } else { + if (m_ValNative && !m_Persistent) { + m_ValNative->m_RefCount--; + if (m_ValNative->m_RefCount <= 0) { + if (m_ValNative != Val) delete m_ValNative; + m_ValNative = NULL; + } + } + + m_Type = VAL_NATIVE; + m_Persistent = Persistent; + + m_ValNative = Val; + if (m_ValNative && !m_Persistent) m_ValNative->m_RefCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetObject() { + if (m_Type == VAL_VARIABLE_REF) { + m_ValRef->SetObject(); + return; + } + + DeleteProps(); + m_Type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetReference(CScValue *Val) { + m_ValRef = Val; + m_Type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::GetBool(bool Default) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetBool(); + + switch (m_Type) { + case VAL_BOOL: + return m_ValBool; + + case VAL_NATIVE: + return m_ValNative->ScToBool(); + + case VAL_INT: + return (m_ValInt != 0); + + case VAL_FLOAT: + return (m_ValFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(m_ValString, "1") == 0 || scumm_stricmp(m_ValString, "yes") == 0 || scumm_stricmp(m_ValString, "true") == 0); + + default: + return Default; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::GetInt(int Default) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetInt(); + + switch (m_Type) { + case VAL_BOOL: + return m_ValBool ? 1 : 0; + + case VAL_NATIVE: + return m_ValNative->ScToInt(); + + case VAL_INT: + return m_ValInt; + + case VAL_FLOAT: + return (int)m_ValFloat; + + case VAL_STRING: + return atoi(m_ValString); + + default: + return Default; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::GetFloat(double Default) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetFloat(); + + switch (m_Type) { + case VAL_BOOL: + return m_ValBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return m_ValNative->ScToFloat(); + + case VAL_INT: + return (double)m_ValInt; + + case VAL_FLOAT: + return m_ValFloat; + + case VAL_STRING: + return atof(m_ValString); + + default: + return Default; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::GetMemBuffer() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetMemBuffer(); + + if (m_Type == VAL_NATIVE) return m_ValNative->ScToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScValue::GetString() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetString(); + + switch (m_Type) { + case VAL_OBJECT: + SetStringVal("[object]"); + break; + + case VAL_NULL: + SetStringVal("[null]"); + break; + + case VAL_NATIVE: { + char *StrVal = m_ValNative->ScToString(); + SetStringVal(StrVal); + return StrVal; + break; + } + + case VAL_BOOL: + SetStringVal(m_ValBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", m_ValInt); + SetStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", m_ValFloat); + SetStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + SetStringVal(""); + } + + return m_ValString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::GetNative() { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetNative(); + + if (m_Type == VAL_NATIVE) return m_ValNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::GetType() { + return m_Type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::Copy(CScValue *orig, bool CopyWhole) { + Game = orig->Game; + + if (m_ValNative && !m_Persistent) { + m_ValNative->m_RefCount--; + if (m_ValNative->m_RefCount <= 0) { + if (m_ValNative != orig->m_ValNative) delete m_ValNative; + m_ValNative = NULL; + } + } + + if (orig->m_Type == VAL_VARIABLE_REF && orig->m_ValRef && CopyWhole) orig = orig->m_ValRef; + + Cleanup(true); + + m_Type = orig->m_Type; + m_ValBool = orig->m_ValBool; + m_ValInt = orig->m_ValInt; + m_ValFloat = orig->m_ValFloat; + SetStringVal(orig->m_ValString); + + m_ValRef = orig->m_ValRef; + m_Persistent = orig->m_Persistent; + + m_ValNative = orig->m_ValNative; + if (m_ValNative && !m_Persistent) m_ValNative->m_RefCount++; +//!!!! ref->native++ + + // copy properties + if (orig->m_Type == VAL_OBJECT && orig->m_ValObject.size() > 0) { + orig->m_ValIter = orig->m_ValObject.begin(); + while (orig->m_ValIter != orig->m_ValObject.end()) { + m_ValObject[orig->m_ValIter->first] = new CScValue(Game); + m_ValObject[orig->m_ValIter->first]->Copy(orig->m_ValIter->second); + orig->m_ValIter++; + } + } else m_ValObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetValue(CScValue *Val) { + if (Val->m_Type == VAL_VARIABLE_REF) { + SetValue(Val->m_ValRef); + return; + } + + // if being assigned a simple type, preserve native state + if (m_Type == VAL_NATIVE && (Val->m_Type == VAL_INT || Val->m_Type == VAL_STRING || Val->m_Type == VAL_BOOL)) { + switch (Val->m_Type) { + case VAL_INT: + m_ValNative->ScSetInt(Val->GetInt()); + break; + case VAL_FLOAT: + m_ValNative->ScSetFloat(Val->GetFloat()); + break; + case VAL_BOOL: + m_ValNative->ScSetBool(Val->GetBool()); + break; + case VAL_STRING: + m_ValNative->ScSetString(Val->GetString()); + break; + } + } + // otherwise just copy everything + else Copy(Val); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_Persistent)); + PersistMgr->Transfer(TMEMBER(m_IsConstVar)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(m_ValBool)); + PersistMgr->Transfer(TMEMBER(m_ValFloat)); + PersistMgr->Transfer(TMEMBER(m_ValInt)); + PersistMgr->Transfer(TMEMBER(m_ValNative)); + + int size; + char *str; + if (PersistMgr->m_Saving) { + size = m_ValObject.size(); + PersistMgr->Transfer("", &size); + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + str = (char *)m_ValIter->first.c_str(); + PersistMgr->Transfer("", &str); + PersistMgr->Transfer("", &m_ValIter->second); + + m_ValIter++; + } + } else { + CScValue *val; + PersistMgr->Transfer("", &size); + for (int i = 0; i < size; i++) { + PersistMgr->Transfer("", &str); + PersistMgr->Transfer("", &val); + + m_ValObject[str] = val; + delete [] str; + } + } + + PersistMgr->Transfer(TMEMBER(m_ValRef)); + PersistMgr->Transfer(TMEMBER(m_ValString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(m_Type) + { + case VAL_STRING: + fprintf(f, "str %s\n", m_ValString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", m_ValInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", m_ValBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + Buffer->PutTextIndent(Indent, "PROPERTY {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_ValIter->first.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_ValIter->second->GetString()); + Buffer->PutTextIndent(Indent, "}\n\n"); + + m_ValIter++; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::Compare(CScValue *Val1, CScValue *Val2) { + // both natives? + if (Val1->IsNative() && Val2->IsNative()) { + // same class? + if (strcmp(Val1->GetNative()->GetClassName(), Val2->GetNative()->GetClassName()) == 0) { + return Val1->GetNative()->ScCompare(Val2->GetNative()); + } else return strcmp(Val1->GetString(), Val2->GetString()); + } + + // both objects? + if (Val1->IsObject() && Val2->IsObject()) return -1; + + + // null states + if (Val1->IsNULL() && !Val2->IsNULL()) return -1; + else if (!Val1->IsNULL() && Val2->IsNULL()) return 1; + else if (Val1->IsNULL() && Val2->IsNULL()) return 0; + + // one of them is string? convert both to string + if (Val1->IsString() || Val2->IsString()) return strcmp(Val1->GetString(), Val2->GetString()); + + // one of them is float? + if (Val1->IsFloat() || Val2->IsFloat()) { + if (Val1->GetFloat() < Val2->GetFloat()) return -1; + else if (Val1->GetFloat() > Val2->GetFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (Val1->GetInt() < Val2->GetInt()) return -1; + else if (Val1->GetInt() > Val2->GetInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { + if (Val1->GetTypeTolerant() != Val2->GetTypeTolerant()) return -1; + else return CScValue::Compare(Val1, Val2); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + Client->OnVariableInit(Type, Script, ScopeID, m_ValIter->second, m_ValIter->first.c_str()); + m_ValIter++; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, int Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + delete Val; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, const char *Value) { + CScValue *Val = new CScValue(Game, (char *)Value); + bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + delete Val; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, double Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, bool Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName) { + CScValue *Val = new CScValue(Game); + bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::DbgGetType() { + switch (GetType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::DbgGetValInt() { + return GetInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::DbgGetValFloat() { + return GetFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetValBool() { + return GetBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::DbgGetValString() { + return GetString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::DbgGetValNative() { + return GetNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(int Value) { + SetInt(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(double Value) { + SetFloat(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(bool Value) { + SetBool(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(const char *Value) { + SetString((char *)Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal() { + SetNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::DbgGetNumProperties() { + if (m_ValNative && m_ValNative->m_ScProp) return m_ValNative->m_ScProp->DbgGetNumProperties(); + else return m_ValObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) { + if (m_ValNative && m_ValNative->m_ScProp) return m_ValNative->m_ScProp->DbgGetProperty(Index, Name, Value); + else { + int Count = 0; + m_ValIter = m_ValObject.begin(); + while (m_ValIter != m_ValObject.end()) { + if (Count == Index) { + *Name = m_ValIter->first.c_str(); + *Value = m_ValIter->second; + return true; + } + m_ValIter++; + Count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetDescription(char *Buf, int BufSize) { + if (m_Type == VAL_VARIABLE_REF) return m_ValRef->DbgGetDescription(Buf, BufSize); + + if (m_Type == VAL_NATIVE) { + m_ValNative->ScDebuggerDesc(Buf, BufSize); + } else { + strncpy(Buf, GetString(), BufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h new file mode 100644 index 0000000000..40abe635ce --- /dev/null +++ b/engines/wintermute/scriptables/ScValue.h @@ -0,0 +1,140 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include +#include +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID); + + static int Compare(CScValue *Val1, CScValue *Val2); + static int CompareStrict(CScValue *Val1, CScValue *Val2); + TValType GetTypeTolerant(); + void Cleanup(bool IgnoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool m_IsConstVar; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + void SetValue(CScValue *Val); + bool m_Persistent; + bool PropExists(char *Name); + void Copy(CScValue *orig, bool CopyWhole = false); + void SetStringVal(const char *Val); + TValType GetType(); + bool GetBool(bool Default = false); + int GetInt(int Default = 0); + double GetFloat(double Default = 0.0f); + char *GetString(); + void *GetMemBuffer(); + CBScriptable *GetNative(); + HRESULT DeleteProp(char *Name); + void DeleteProps(); + void CleanProps(bool IncludingNatives); + void SetBool(bool Val); + void SetInt(int Val); + void SetFloat(double Val); + void SetString(const char *Val); + void SetNULL(); + void SetNative(CBScriptable *Val, bool Persistent = false); + void SetObject(); + void SetReference(CScValue *Val); + bool IsNULL(); + bool IsNative(); + bool IsString(); + bool IsBool(); + bool IsFloat(); + bool IsInt(); + bool IsObject(); + HRESULT SetProp(char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); + CScValue *GetProp(char *Name); + CBScriptable *m_ValNative; + CScValue *m_ValRef; + bool m_ValBool; + int m_ValInt; + double m_ValFloat; + char *m_ValString; + TValType m_Type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + std::map m_ValObject; + std::map::iterator m_ValIter; + + bool SetProperty(const char *PropName, int Value); + bool SetProperty(const char *PropName, const char *Value); + bool SetProperty(const char *PropName, double Value); + bool SetProperty(const char *PropName, bool Value); + bool SetProperty(const char *PropName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType DbgGetType(); + + // getters + virtual int DbgGetValInt(); + virtual double DbgGetValFloat(); + virtual bool DbgGetValBool(); + virtual const char *DbgGetValString(); + virtual IWmeDebugObject *DbgGetValNative(); + + // setters + virtual bool DbgSetVal(int Value); + virtual bool DbgSetVal(double Value); + virtual bool DbgSetVal(bool Value); + virtual bool DbgSetVal(const char *Value); + virtual bool DbgSetVal(); + + // properties + virtual int DbgGetNumProperties(); + virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); + + virtual bool DbgGetDescription(char *Buf, int BufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp new file mode 100644 index 0000000000..dd649d8afd --- /dev/null +++ b/engines/wintermute/utils.cpp @@ -0,0 +1,340 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "dcgf.h" +#include "utils.h" +#include "PlatformSDL.h" +#include "wintypes.h" +#include "PathUtil.h" +#include "BGame.h" +#include "common/str.h" +#include "common/textconsole.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +static inline unsigned Sqr(int x) { + return (x * x); +} + + +////////////////////////////////////////////////////////////////////////////////// +void CBUtils::Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect) { + // If it's partly off the right side of the screen + if (*DestX + (SrcRect->right - SrcRect->left) > DestRect->right) + SrcRect->right -= *DestX + (SrcRect->right - SrcRect->left) - DestRect->right; + + if (SrcRect->right < 0) SrcRect->right = 0; + + // Partly off the left side of the screen + if (*DestX < DestRect->left) { + SrcRect->left += DestRect->left - *DestX; + *DestX = DestRect->left; + } + + // Partly off the top of the screen + if (*DestY < DestRect->top) { + SrcRect->top += DestRect->top - *DestY; + *DestY = DestRect->top; + } + + // If it's partly off the bottom side of the screen + if (*DestY + (SrcRect->bottom - SrcRect->top) > DestRect->bottom) + SrcRect->bottom -= ((SrcRect->bottom - SrcRect->top) + *DestY) - DestRect->bottom; + + if (SrcRect->bottom < 0) SrcRect->bottom = 0; + + return; +} + +////////////////////////////////////////////////////////////////////////////////// +// Swap - swaps two integers +////////////////////////////////////////////////////////////////////////////////// +void CBUtils::Swap(int *a, int *b) { + int Temp = *a; + *a = *b; + *b = Temp; +} + +////////////////////////////////////////////////////////////////////////// +bool CBUtils::StrBeginsI(const char *String, const char *Fragment) { + return (scumm_strnicmp(String, Fragment, strlen(Fragment)) == 0); +} + + +////////////////////////////////////////////////////////////////////////// +float CBUtils::NormalizeAngle(float Angle) { + while (Angle > 360) Angle -= 360; + while (Angle < 0) Angle += 360; + + return Angle; +} + + +//////////////////////////////////////////////////////////////////////////////// +void CBUtils::CreatePath(const char *Path, bool PathOnly) { + AnsiString path; + + if (!PathOnly) path = PathUtil::GetDirectoryName(Path); + else path = Path; + +// try { + warning("CBUtils::CreatePath - not implemented: %s", Path); +// boost::filesystem::create_directories(path); +// } catch (...) { + return; +// } +} + + +////////////////////////////////////////////////////////////////////////// +void CBUtils::DebugMessage(HWND hWnd, const char *Text) { + //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::SetString(char **String, const char *Value) { + delete[] *String; + *String = new char[strlen(Value) + 1]; + if (*String) strcpy(*String, Value); + return *String; +} + +////////////////////////////////////////////////////////////////////////// +int CBUtils::StrNumEntries(const char *Str, const char Delim) { + int NumEntries = 1; + for (int i = 0; i < strlen(Str); i++) { + if (Str[i] == Delim) NumEntries++; + } + return NumEntries; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { + int NumEntries = 0; + + const char *Start = NULL; + int Len = 0; + + for (int i = 0; i <= strlen(Str); i++) { + if (NumEntries == Entry) { + if (!Start) Start = Str + i; + else Len++; + } + if (Str[i] == Delim || Str[i] == '\0') { + NumEntries++; + if (Start) { + char *Ret = new char[Len + 1]; + memset(Ret, 0, Len + 1); + strncpy(Ret, Start, Len); + return Ret; + } + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CBUtils::RandomInt(int From, int To) { + if (To < From) { + int i = To; + To = From; + From = i; + } + return (rand() % (To - From + 1)) + From; +} + +////////////////////////////////////////////////////////////////////////// +float CBUtils::RandomFloat(float From, float To) { + float RandNum = (float)rand() / (float)RAND_MAX; + return From + (To - From) * RandNum; +} + +////////////////////////////////////////////////////////////////////////// +float CBUtils::RandomAngle(float From, float To) { + while (To < From) { + To += 360; + } + return NormalizeAngle(RandomFloat(From, To)); +} + +////////////////////////////////////////////////////////////////////////// +bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { + char stringc, patternc; + + for (;; ++String) { + stringc = toupper(*String); + patternc = toupper(*Pattern++); + + switch (patternc) { + case 0: + return (stringc == 0); + + case '?': + if (stringc == 0) return false; + break; + + case '*': + if (!*Pattern) return true; + + if (*Pattern == '.') { + char *dot; + if (Pattern[1] == '*' && Pattern[2] == 0) return true; + dot = (char *)strchr(String, '.'); + if (Pattern[1] == 0) return (dot == NULL || dot[1] == 0); + if (dot != NULL) { + String = dot; + if (strpbrk(Pattern, "*?[") == NULL && strchr(String + 1, '.') == NULL) + return(scumm_stricmp(Pattern + 1, String + 1) == 0); + } + } + + while (*String) + if (CBUtils::MatchesPattern(Pattern, String++)) + return true; + return false; + + default: + if (patternc != stringc) + if (patternc == '.' && stringc == 0) + return(CBUtils::MatchesPattern(Pattern, String)); + else + return false; + break; + } + } +} + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::GetPath(char *Filename) { + AnsiString path = PathUtil::GetDirectoryName(Filename); + //path = boost::filesystem::system_complete(path).string(); + warning("CBUtils::GetPath: (%s), not implemented", Filename); + return Filename; + char *ret = new char[path.length() + 1]; + strcpy(ret, path.c_str()); + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::GetFilename(char *Filename) { + AnsiString path = PathUtil::GetFileName(Filename); + char *ret = new char[path.length() + 1]; + strcpy(ret, path.c_str()); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { + float var_R = (D3DCOLGetR(RGBColor) / 255.0f); + float var_G = (D3DCOLGetG(RGBColor) / 255.0f); + float var_B = (D3DCOLGetB(RGBColor) / 255.0f); + + //Min. value of RGB + float var_Min = std::min(var_R, var_G); + var_Min = std::min(var_Min, var_B); + + //Max. value of RGB + float var_Max = std::max(var_R, var_G); + var_Max = std::max(var_Max, var_B); + + //Delta RGB value + float del_Max = var_Max - var_Min; + + float H, S, L; + + L = (var_Max + var_Min) / 2.0f; + + //This is a gray, no chroma... + if (del_Max == 0) { + H = 0; + S = 0; + } + //Chromatic data... + else { + if (L < 0.5f) S = del_Max / (var_Max + var_Min); + else S = del_Max / (2.0f - var_Max - var_Min); + + float del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; + float del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; + float del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; + + if (var_R == var_Max) H = del_B - del_G; + else if (var_G == var_Max) H = (1.0f / 3.0f) + del_R - del_B; + else if (var_B == var_Max) H = (2.0f / 3.0f) + del_G - del_R; + + if (H < 0) H += 1; + if (H > 1) H -= 1; + } + + *OutH = H * 255; + *OutS = S * 255; + *OutL = L * 255; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { + float H = InH / 255.0f; + float S = InS / 255.0f; + float L = InL / 255.0f; + + byte R, G, B; + + + if (S == 0) { + R = L * 255; + G = L * 255; + B = L * 255; + } else { + float var_1, var_2; + + if (L < 0.5) var_2 = L * (1.0 + S); + else var_2 = (L + S) - (S * L); + + var_1 = 2.0f * L - var_2; + + R = 255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f)); + G = 255 * Hue2RGB(var_1, var_2, H); + B = 255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f)); + } + return DRGBA(255, R, G, B); +} + + +////////////////////////////////////////////////////////////////////////// +float CBUtils::Hue2RGB(float v1, float v2, float vH) { + if (vH < 0.0f) vH += 1.0f; + if (vH > 1.0f) vH -= 1.0f; + if ((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH); + if ((2.0f * vH) < 1.0f) return (v2); + if ((3.0f * vH) < 2.0f) return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f); + return (v1); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h new file mode 100644 index 0000000000..56d9876c5c --- /dev/null +++ b/engines/wintermute/utils.h @@ -0,0 +1,68 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeUtils_H__ +#define __WmeUtils_H__ + +#include "wintypes.h" + +namespace WinterMute { + +class CBGame; + +class CBUtils { +public: + static void Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); + static void Swap(int *a, int *b); + static bool StrBeginsI(const char *String, const char *Fragment); + static float NormalizeAngle(float Angle); + + static void CreatePath(const char *Path, bool PathOnly = false); + + static void DebugMessage(HWND hWnd, const char *Text); + static char *SetString(char **String, const char *Value); + + static int StrNumEntries(const char *Str, const char Delim = ','); + static char *StrEntry(int Entry, const char *Str, const char Delim = ','); + + static int RandomInt(int From, int To); + static float RandomFloat(float From, float To); + static float RandomAngle(float From, float To); + + static bool MatchesPattern(const char *pattern, const char *string); + + static char *GetPath(char *Filename); + static char *GetFilename(char *Filename); + + static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); + static uint32 HSLtoRGB(byte H, byte S, byte L); + +private: + static float Hue2RGB(float v1, float v2, float vH); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 89c1ef6e53..50d6dd16be 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #ifndef __WmeWintypes_H__ #define __WmeWintypes_H__ diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h new file mode 100644 index 0000000000..6774ab0768 --- /dev/null +++ b/engines/wintermute/wme_debugger.h @@ -0,0 +1,167 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WME_DEBUGGER_H +#define WME_DEBUGGER_H + +#ifdef SetProp +#undef SetProp +#endif + +#include "engines/wintermute/dcscript.h" + +namespace WinterMute { + +class IWmeDebugClient; +class IWmeDebugObject; + +////////////////////////////////////////////////////////////////////////// +typedef enum { + WME_DBGPROP_NULL = 0, + WME_DBGPROP_INT = 1, + WME_DBGPROP_FLOAT = 2, + WME_DBGPROP_BOOL = 3, + WME_DBGPROP_STRING = 4, + WME_DBGPROP_OBJECT = 5, + WME_DBGPROP_NATIVE = 6, + WME_DBGPROP_UNKNOWN = 7 +} +EWmeDebuggerPropType; + +////////////////////////////////////////////////////////////////////////// +typedef enum { + WME_DBGVAR_GLOBAL = 0, + WME_DBGVAR_SCRIPT = 1, + WME_DBGVAR_SCOPE = 2 +} +EWmeDebuggerVariableType; + +////////////////////////////////////////////////////////////////////////// +class IWmeDebugScript { +public: + virtual int DbgGetLine() = 0; + virtual const char *DbgGetFilename() = 0; + virtual TScriptState DbgGetState() = 0; + + virtual int DbgGetNumBreakpoints() = 0; + virtual int DbgGetBreakpoint(int Index) = 0; + + virtual bool DbgSetTracingMode(bool IsTracing) = 0; + virtual bool DbgGetTracingMode() = 0; +}; + +////////////////////////////////////////////////////////////////////////// +class IWmeDebugProp { +public: + virtual EWmeDebuggerPropType DbgGetType() = 0; + + // getters + virtual int DbgGetValInt() = 0; + virtual double DbgGetValFloat() = 0; + virtual bool DbgGetValBool() = 0; + virtual const char *DbgGetValString() = 0; + virtual IWmeDebugObject *DbgGetValNative() = 0; + + // setters + virtual bool DbgSetVal(int Value) = 0; + virtual bool DbgSetVal(double Value) = 0; + virtual bool DbgSetVal(bool Value) = 0; + virtual bool DbgSetVal(const char *Value) = 0; + virtual bool DbgSetVal() = 0; + + // properties + virtual int DbgGetNumProperties() = 0; + virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) = 0; + + virtual bool DbgGetDescription(char *Buf, int BufSize) = 0; +}; + +////////////////////////////////////////////////////////////////////////// +class IWmeDebugObject { +public: + virtual const char *DbgGetNativeClass() = 0; + virtual IWmeDebugProp *DbgGetProperty(const char *Name) = 0; +}; + +////////////////////////////////////////////////////////////////////////// +class IWmeDebugClient { +public: + virtual bool OnGameInit() = 0; + virtual bool OnGameShutdown() = 0; + + virtual bool OnGameTick() = 0; + + virtual bool OnLog(unsigned int ErrorCode, const char *Text) = 0; + + virtual bool OnScriptInit(IWmeDebugScript *Script) = 0; + virtual bool OnScriptEventThreadInit(IWmeDebugScript *Script, IWmeDebugScript *ParentScript, const char *EventName) = 0; + virtual bool OnScriptMethodThreadInit(IWmeDebugScript *Script, IWmeDebugScript *ParentScript, const char *MethodName) = 0; + virtual bool OnScriptShutdown(IWmeDebugScript *Script) = 0; + virtual bool OnScriptChangeLine(IWmeDebugScript *Script, int Line) = 0; + virtual bool OnScriptChangeScope(IWmeDebugScript *Script, unsigned int ScopeID) = 0; + virtual bool OnScriptShutdownScope(IWmeDebugScript *Script, unsigned int ScopeID) = 0; + + virtual bool OnVariableInit(EWmeDebuggerVariableType Type, IWmeDebugScript *Script, unsigned int ScopeID, IWmeDebugProp *Variable, const char *VariableName) = 0; + virtual bool OnVariableChangeValue(IWmeDebugProp *Variable, IWmeDebugProp *Value) = 0; + + virtual bool OnScriptHitBreakpoint(IWmeDebugScript *Script, int Line) = 0; +}; + +////////////////////////////////////////////////////////////////////////// +class IWmeDebugServer { +public: + virtual bool AttachClient(IWmeDebugClient *Client) = 0; + virtual bool DetachClient(IWmeDebugClient *Client) = 0; + + virtual bool QueryData(IWmeDebugClient *Client) = 0; + + virtual int GetPropInt(const char *PropName) = 0; + virtual double GetPropFloat(const char *PropName) = 0; + virtual const char *GetPropString(const char *PropName) = 0; + virtual bool GetPropBool(const char *PropName) = 0; + + virtual bool SetProp(const char *PropName, int PropValue) = 0; + virtual bool SetProp(const char *PropName, double PropValue) = 0; + virtual bool SetProp(const char *PropName, const char *PropValue) = 0; + virtual bool SetProp(const char *PropName, bool PropValue) = 0; + + virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) = 0; + + virtual bool AddBreakpoint(const char *ScriptFilename, int Line) = 0; + virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line) = 0; + + virtual bool ContinueExecution() = 0; +}; + + +typedef bool (*WMEDBG_INITIALIZE)(IWmeDebugServer *Server); +typedef bool (*WMEDBG_SHUTDOWN)(IWmeDebugServer *Server); + +} // end of namespace WinterMute + +#endif // WME_DEBUGGER_H \ No newline at end of file -- cgit v1.2.3 From b602b511607ac7bae911a5306bbe8301fdad4708 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 03:09:12 +0100 Subject: WINTERMUTE: Add the files for the rest of the B-classes. --- engines/wintermute/BActiveRect.cpp | 107 + engines/wintermute/BActiveRect.h | 59 + engines/wintermute/BDebugger.cpp | 49 +- engines/wintermute/BDebugger.h | 55 +- engines/wintermute/BDiskFile.cpp | 214 ++ engines/wintermute/BDiskFile.h | 59 + engines/wintermute/BDynBuffer.cpp | 192 ++ engines/wintermute/BEvent.cpp | 197 ++ engines/wintermute/BEvent.h | 56 + engines/wintermute/BFader.cpp | 175 ++ engines/wintermute/BFader.h | 62 + engines/wintermute/BFile.cpp | 69 + engines/wintermute/BFile.h | 65 + engines/wintermute/BFileEntry.cpp | 50 + engines/wintermute/BFileEntry.h | 57 + engines/wintermute/BFileManager.cpp | 743 +++++ engines/wintermute/BFileManager.h | 81 + engines/wintermute/BFont.cpp | 206 ++ engines/wintermute/BFont.h | 61 + engines/wintermute/BFontBitmap.cpp | 532 ++++ engines/wintermute/BFontBitmap.h | 72 + engines/wintermute/BFontStorage.cpp | 155 ++ engines/wintermute/BFontStorage.h | 66 + engines/wintermute/BFontTT.cpp | 853 ++++++ engines/wintermute/BFontTT.h | 188 ++ engines/wintermute/BFrame.cpp | 707 +++++ engines/wintermute/BFrame.h | 73 + engines/wintermute/BGame.cpp | 4462 +++++++++++++++++++++++++++++++ engines/wintermute/BGame.h | 20 +- engines/wintermute/BImage.cpp | 117 + engines/wintermute/BImage.h | 62 + engines/wintermute/BKeyboardState.cpp | 243 ++ engines/wintermute/BKeyboardState.h | 71 + engines/wintermute/BPackage.cpp | 102 + engines/wintermute/BPackage.h | 57 + engines/wintermute/BPkgFile.cpp | 228 ++ engines/wintermute/BPkgFile.h | 61 + engines/wintermute/BPoint.cpp | 64 + engines/wintermute/BPoint.h | 50 + engines/wintermute/BQuickMsg.cpp | 54 + engines/wintermute/BQuickMsg.h | 48 + engines/wintermute/BRegion.cpp | 508 ++++ engines/wintermute/BRegion.h | 68 + engines/wintermute/BRegistry.cpp | 227 ++ engines/wintermute/BRegistry.h | 76 + engines/wintermute/BRenderSDL.cpp | 408 +++ engines/wintermute/BRenderSDL.h | 95 + engines/wintermute/BRenderer.cpp | 259 ++ engines/wintermute/BRenderer.h | 124 + engines/wintermute/BResourceFile.cpp | 103 + engines/wintermute/BResourceFile.h | 50 + engines/wintermute/BResources.cpp | 2830 ++++++++++++++++++++ engines/wintermute/BResources.h | 41 + engines/wintermute/BSaveThumbFile.cpp | 146 + engines/wintermute/BSaveThumbFile.h | 51 + engines/wintermute/BSaveThumbHelper.cpp | 79 + engines/wintermute/BSaveThumbHelper.h | 50 + engines/wintermute/BScriptHolder.cpp | 470 ++++ engines/wintermute/BSound.cpp | 266 ++ engines/wintermute/BSound.h | 85 + engines/wintermute/BSoundBuffer.cpp | 384 +++ engines/wintermute/BSoundBuffer.h | 95 + engines/wintermute/BSoundMgr.cpp | 330 +++ engines/wintermute/BSoundMgr.h | 70 + engines/wintermute/BSprite.cpp | 753 ++++++ engines/wintermute/BSprite.h | 90 + engines/wintermute/BStringTable.cpp | 229 ++ engines/wintermute/BStringTable.h | 55 + engines/wintermute/BSubFrame.cpp | 588 ++++ engines/wintermute/BSubFrame.h | 85 + engines/wintermute/BSurface.cpp | 196 ++ engines/wintermute/BSurface.h | 93 + engines/wintermute/BSurfaceSDL.cpp | 402 +++ engines/wintermute/BSurfaceSDL.h | 79 + engines/wintermute/BSurfaceStorage.cpp | 192 ++ engines/wintermute/BSurfaceStorage.h | 58 + engines/wintermute/BTransitionMgr.cpp | 126 + engines/wintermute/BTransitionMgr.h | 54 + engines/wintermute/BViewport.cpp | 98 + engines/wintermute/BViewport.h | 55 + engines/wintermute/PathUtil.cpp | 196 ++ engines/wintermute/PathUtil.h | 56 + engines/wintermute/StringUtil.cpp | 49 +- engines/wintermute/StringUtil.h | 53 +- engines/wintermute/SysClass.h | 49 +- engines/wintermute/module.mk | 1 + engines/wintermute/persistent.h | 1 - engines/wintermute/utils.cpp | 49 +- engines/wintermute/utils.h | 55 +- 89 files changed, 21140 insertions(+), 179 deletions(-) create mode 100644 engines/wintermute/BActiveRect.cpp create mode 100644 engines/wintermute/BActiveRect.h create mode 100644 engines/wintermute/BDiskFile.cpp create mode 100644 engines/wintermute/BDiskFile.h create mode 100644 engines/wintermute/BDynBuffer.cpp create mode 100644 engines/wintermute/BEvent.cpp create mode 100644 engines/wintermute/BEvent.h create mode 100644 engines/wintermute/BFader.cpp create mode 100644 engines/wintermute/BFader.h create mode 100644 engines/wintermute/BFile.cpp create mode 100644 engines/wintermute/BFile.h create mode 100644 engines/wintermute/BFileEntry.cpp create mode 100644 engines/wintermute/BFileEntry.h create mode 100644 engines/wintermute/BFileManager.cpp create mode 100644 engines/wintermute/BFileManager.h create mode 100644 engines/wintermute/BFont.cpp create mode 100644 engines/wintermute/BFont.h create mode 100644 engines/wintermute/BFontBitmap.cpp create mode 100644 engines/wintermute/BFontBitmap.h create mode 100644 engines/wintermute/BFontStorage.cpp create mode 100644 engines/wintermute/BFontStorage.h create mode 100644 engines/wintermute/BFontTT.cpp create mode 100644 engines/wintermute/BFontTT.h create mode 100644 engines/wintermute/BFrame.cpp create mode 100644 engines/wintermute/BFrame.h create mode 100644 engines/wintermute/BGame.cpp create mode 100644 engines/wintermute/BImage.cpp create mode 100644 engines/wintermute/BImage.h create mode 100644 engines/wintermute/BKeyboardState.cpp create mode 100644 engines/wintermute/BKeyboardState.h create mode 100644 engines/wintermute/BPackage.cpp create mode 100644 engines/wintermute/BPackage.h create mode 100644 engines/wintermute/BPkgFile.cpp create mode 100644 engines/wintermute/BPkgFile.h create mode 100644 engines/wintermute/BPoint.cpp create mode 100644 engines/wintermute/BPoint.h create mode 100644 engines/wintermute/BQuickMsg.cpp create mode 100644 engines/wintermute/BQuickMsg.h create mode 100644 engines/wintermute/BRegion.cpp create mode 100644 engines/wintermute/BRegion.h create mode 100644 engines/wintermute/BRegistry.cpp create mode 100644 engines/wintermute/BRegistry.h create mode 100644 engines/wintermute/BRenderSDL.cpp create mode 100644 engines/wintermute/BRenderSDL.h create mode 100644 engines/wintermute/BRenderer.cpp create mode 100644 engines/wintermute/BRenderer.h create mode 100644 engines/wintermute/BResourceFile.cpp create mode 100644 engines/wintermute/BResourceFile.h create mode 100644 engines/wintermute/BResources.cpp create mode 100644 engines/wintermute/BResources.h create mode 100644 engines/wintermute/BSaveThumbFile.cpp create mode 100644 engines/wintermute/BSaveThumbFile.h create mode 100644 engines/wintermute/BSaveThumbHelper.cpp create mode 100644 engines/wintermute/BSaveThumbHelper.h create mode 100644 engines/wintermute/BScriptHolder.cpp create mode 100644 engines/wintermute/BSound.cpp create mode 100644 engines/wintermute/BSound.h create mode 100644 engines/wintermute/BSoundBuffer.cpp create mode 100644 engines/wintermute/BSoundBuffer.h create mode 100644 engines/wintermute/BSoundMgr.cpp create mode 100644 engines/wintermute/BSoundMgr.h create mode 100644 engines/wintermute/BSprite.cpp create mode 100644 engines/wintermute/BSprite.h create mode 100644 engines/wintermute/BStringTable.cpp create mode 100644 engines/wintermute/BStringTable.h create mode 100644 engines/wintermute/BSubFrame.cpp create mode 100644 engines/wintermute/BSubFrame.h create mode 100644 engines/wintermute/BSurface.cpp create mode 100644 engines/wintermute/BSurface.h create mode 100644 engines/wintermute/BSurfaceSDL.cpp create mode 100644 engines/wintermute/BSurfaceSDL.h create mode 100644 engines/wintermute/BSurfaceStorage.cpp create mode 100644 engines/wintermute/BSurfaceStorage.h create mode 100644 engines/wintermute/BTransitionMgr.cpp create mode 100644 engines/wintermute/BTransitionMgr.h create mode 100644 engines/wintermute/BViewport.cpp create mode 100644 engines/wintermute/BViewport.h create mode 100644 engines/wintermute/PathUtil.cpp create mode 100644 engines/wintermute/PathUtil.h (limited to 'engines') diff --git a/engines/wintermute/BActiveRect.cpp b/engines/wintermute/BActiveRect.cpp new file mode 100644 index 0000000000..5827cb8d61 --- /dev/null +++ b/engines/wintermute/BActiveRect.cpp @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BActiveRect.h" +#include "BGame.h" +#include "BRegion.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::SetRectEmpty(&m_Rect); + m_Owner = NULL; + m_Frame = NULL; + m_Region = NULL; + m_ZoomX = 100; + m_ZoomY = 100; + m_OffsetX = m_OffsetY = 0; + ClipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise): CBBase(inGame) { + m_Owner = Owner; + m_Frame = Frame; + CBPlatform::SetRect(&m_Rect, X, Y, X + Width, Y + Height); + m_ZoomX = ZoomX; + m_ZoomY = ZoomY; + m_Precise = Precise; + m_Region = NULL; + m_OffsetX = m_OffsetY = 0; + ClipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY): CBBase(inGame) { + m_Owner = Owner; + m_Region = Region; + CBPlatform::CopyRect(&m_Rect, &Region->m_Rect); + CBPlatform::OffsetRect(&m_Rect, -OffsetX, -OffsetY); + m_ZoomX = 100; + m_ZoomY = 100; + m_Precise = true; + m_Frame = NULL; + ClipRect(); + m_OffsetX = OffsetX; + m_OffsetY = OffsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + m_Owner = NULL; + m_Frame = NULL; + m_Region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::ClipRect() { + RECT rc; + bool CustomViewport; + Game->GetCurrentViewportRect(&rc, &CustomViewport); + CBRenderer *Rend = Game->m_Renderer; + + if (!CustomViewport) { + rc.left -= Rend->m_DrawOffsetX; + rc.right -= Rend->m_DrawOffsetX; + rc.top -= Rend->m_DrawOffsetY; + rc.bottom -= Rend->m_DrawOffsetY; + } + + if (rc.left > m_Rect.left) m_OffsetX = rc.left - m_Rect.left; + if (rc.top > m_Rect.top) m_OffsetY = rc.top - m_Rect.top; + + CBPlatform::IntersectRect(&m_Rect, &m_Rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BActiveRect.h b/engines/wintermute/BActiveRect.h new file mode 100644 index 0000000000..ee9bb8aea1 --- /dev/null +++ b/engines/wintermute/BActiveRect.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "BBase.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void ClipRect(); + bool m_Precise; + float m_ZoomX; + float m_ZoomY; + CBSubFrame *m_Frame; + CBObject *m_Owner; + CBRegion *m_Region; + int m_OffsetX; + int m_OffsetY; + RECT m_Rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX = 100, float ZoomY = 100, bool Precise = true); + CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BDebugger.cpp b/engines/wintermute/BDebugger.cpp index 8e5faa8db1..13eae9fd18 100644 --- a/engines/wintermute/BDebugger.cpp +++ b/engines/wintermute/BDebugger.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "BDebugger.h" diff --git a/engines/wintermute/BDebugger.h b/engines/wintermute/BDebugger.h index 28b37cee4f..21a7d308a9 100644 --- a/engines/wintermute/BDebugger.h +++ b/engines/wintermute/BDebugger.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmeBDebugger_H__ -#define __WmeBDebugger_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H #include "BBase.h" diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp new file mode 100644 index 0000000000..ea7a24a0a9 --- /dev/null +++ b/engines/wintermute/BDiskFile.cpp @@ -0,0 +1,214 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BGame.h" +#include "wintypes.h" +#include "BPkgFile.h" +#include "BDiskFile.h" +#include "common/stream.h" +#include "BFileManager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { + m_File = NULL; + m_Data = NULL; + m_Compressed = false; + m_PrefixSize = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::~CBDiskFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Open(Common::String Filename) { + Close(); + + char FullPath[MAX_PATH]; + + for (int i = 0; i < Game->m_FileManager->m_SinglePaths.GetSize(); i++) { + sprintf(FullPath, "%s%s", Game->m_FileManager->m_SinglePaths[i], Filename.c_str()); + CorrectSlashes(FullPath); + + m_File = Common::createFileStream(FullPath); + if (m_File != NULL) + break; + } + + // if we didn't find it in search paths, try to open directly + if (!m_File) { + strcpy(FullPath, Filename.c_str()); + CorrectSlashes(FullPath); + m_File = Common::createFileStream(FullPath); + } + + if (m_File) { + uint32 magic1, magic2; + magic1 = m_File->readUint32LE(); + magic2 = m_File->readUint32LE(); + + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) m_Compressed = true; + + if (m_Compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = m_File->readUint32LE(); + CompSize = m_File->readUint32LE(); + UncompSize = m_File->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); + Close(); + return E_FAIL; + } + + m_Data = new byte[UncompSize]; + if (!m_Data) { + Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + m_File->seek(DataOffset + m_PrefixSize, SEEK_SET); + m_File->read(CompBuffer, CompSize); + + if (uncompress(m_Data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { + Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + + delete [] CompBuffer; + m_Size = UncompSize; + m_Pos = 0; + delete m_File; + m_File = NULL; + } else { + m_Pos = 0; + m_File->seek(0, SEEK_END); + m_Size = m_File->pos() - m_PrefixSize; + m_File->seek(m_PrefixSize,SEEK_SET); + } + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Close() { + if (m_File) { + delete m_File; + } + m_File = NULL; + m_Pos = 0; + m_Size = 0; + + delete[] m_Data; + m_Data = NULL; + + m_Compressed = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { + if (m_Compressed) { + memcpy(Buffer, m_Data + m_Pos, Size); + m_Pos += Size; + return S_OK; + } else { + + if (m_File) { + size_t count = m_File->read(Buffer, Size); + m_Pos += count; + return S_OK; + } else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { + if (m_Compressed) { + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = m_Size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = m_Pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > m_Size) return E_FAIL; + else m_Pos = NewPos; + return S_OK; + } else { + if (!m_File) return E_FAIL; + int ret = 1; + + switch (Origin) { + case SEEK_TO_BEGIN: + ret = m_File->seek(m_PrefixSize + Pos, SEEK_SET); + break; + case SEEK_TO_END: + ret = m_File->seek(Pos, SEEK_END); + break; + case SEEK_TO_CURRENT: + ret = m_File->seek(Pos, SEEK_CUR); + break; + } + if (ret == 0) { + m_Pos = m_File->pos() - m_PrefixSize; + return S_OK; + } else return E_FAIL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBDiskFile::CorrectSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BDiskFile.h b/engines/wintermute/BDiskFile.h new file mode 100644 index 0000000000..7cb4a889aa --- /dev/null +++ b/engines/wintermute/BDiskFile.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + + +#include "BFile.h" + +namespace Common { + class SeekableReadStream; +} + +namespace WinterMute { + +class CBDiskFile : public CBFile { +public: + CBDiskFile(CBGame *inGame); + virtual ~CBDiskFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(Common::String Filename); +private: + void CorrectSlashes(char *fileName); + Common::SeekableReadStream *m_File; + byte *m_Data; + bool m_Compressed; + uint32 m_PrefixSize; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BDynBuffer.cpp b/engines/wintermute/BDynBuffer.cpp new file mode 100644 index 0000000000..3fe99faeb1 --- /dev/null +++ b/engines/wintermute/BDynBuffer.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "BGame.h" +#include "BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase(inGame) { + m_Buffer = NULL; + m_Size = 0; + m_RealSize = 0; + + m_Offset = 0; + m_InitSize = InitSize; + m_GrowBy = GrowBy; + + m_Initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::Cleanup() { + if (m_Buffer) free(m_Buffer); + m_Buffer = NULL; + m_Size = 0; + m_RealSize = 0; + m_Offset = 0; + m_Initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::GetSize() { + return m_Size; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::Init(uint32 InitSize) { + Cleanup(); + + if (InitSize == 0) InitSize = m_InitSize; + + m_Buffer = (byte *)malloc(InitSize); + if (!m_Buffer) { + Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); + return E_FAIL; + } + + m_RealSize = InitSize; + m_Initialized = true; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { + if (!m_Initialized) Init(); + + while (m_Offset + Size > m_RealSize) { + m_RealSize += m_GrowBy; + m_Buffer = (byte *)realloc(m_Buffer, m_RealSize); + if (!m_Buffer) { + Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", m_RealSize); + return E_FAIL; + } + } + + memcpy(m_Buffer + m_Offset, Buffer, Size); + m_Offset += Size; + m_Size += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { + if (!m_Initialized) Init(); + + if (m_Offset + Size > m_Size) { + Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return E_FAIL; + } + + memcpy(Buffer, m_Buffer + m_Offset, Size); + m_Offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutDWORD(uint32 Val) { + PutBytes((byte *)&Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::GetDWORD() { + uint32 ret; + GetBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutString(const char *Val) { + if (!Val) PutString("(null)"); + else { + PutDWORD(strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::GetString() { + uint32 len = GetDWORD(); + char *ret = (char *)(m_Buffer + m_Offset); + m_Offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutText(LPCSTR fmt, ...) { + va_list va; + + va_start(va, fmt); + PutTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { + va_list va; + + PutText("%*s", Indent, ""); + + va_start(va, fmt); + PutTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + PutBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp new file mode 100644 index 0000000000..fbeddacb39 --- /dev/null +++ b/engines/wintermute/BEvent.cpp @@ -0,0 +1,197 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "BGame.h" +#include "BFileManager.h" +#include "BEvent.h" +#include "BParser.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBEvent, false) + +////////////////////////////////////////////////////////////////////////// +CBEvent::CBEvent(CBGame *inGame): CBBase(inGame) { + m_Type = EVENT_NONE; + m_Script = NULL; + m_Name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBEvent::CBEvent(CBGame *inGame, TEventType Type, char *Script): CBBase(inGame) { + m_Type = Type; + m_Script = new char [strlen(Script) + 1]; + if (m_Script) strcpy(m_Script, Script); + m_Name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBEvent::~CBEvent() { + delete[] m_Script; + m_Script = NULL; + delete[] m_Name; + m_Name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBEvent::GetEventName(TEventType Type) { + switch (Type) { + case EVENT_INIT: + return "INIT"; + case EVENT_SHUTDOWN: + return "SHUTDOWN"; + case EVENT_LEFT_CLICK: + return "LEFT_CLICK"; + case EVENT_RIGHT_CLICK: + return "RIGHT_CLICK"; + case EVENT_MIDDLE_CLICK: + return "MIDDLE_CLICK"; + case EVENT_LEFT_DBLCLICK: + return "LEFT_DBLCLICK"; + case EVENT_PRESS: + return "PRESS"; + case EVENT_IDLE: + return "IDLE"; + case EVENT_MOUSE_OVER: + return "MOUSE_OVER"; + case EVENT_LEFT_RELEASE: + return "LEFT_RELEASE"; + case EVENT_RIGHT_RELEASE: + return "RIGHT_RELEASE"; + case EVENT_MIDDLE_RELEASE: + return "MIDDLE_RELEASE"; + + default: + return "NONE"; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBEvent::SetScript(char *Script) { + if (m_Script) delete [] m_Script; + + m_Script = new char [strlen(Script) + 1]; + if (m_Script) strcpy(m_Script, Script); +} + + +////////////////////////////////////////////////////////////////////////// +void CBEvent::SetName(char *Name) { + if (m_Name) delete [] m_Name; + + m_Name = new char [strlen(Name) + 1]; + if (m_Name) strcpy(m_Name, Name); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EVENT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(EVENT) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EVENT) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EVENT) { + Game->LOG(0, "'EVENT' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_SCRIPT: + SetScript((char *)params); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in EVENT definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_Script)); + PersistMgr->Transfer(TMEMBER(m_Name)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h new file mode 100644 index 0000000000..006e10706e --- /dev/null +++ b/engines/wintermute/BEvent.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BEVENT_H +#define WINTERMUTE_BEVENT_H + + +#include "BBase.h" +#include "dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CBEvent : public CBBase { +public: + DECLARE_PERSISTENT(CBEvent, CBBase) + void SetScript(char *Script); + void SetName(char *Name); + static const char *GetEventName(TEventType Type); + char *m_Script; + char *m_Name; + TEventType m_Type; + CBEvent(CBGame *inGame); + CBEvent(CBGame *inGame, TEventType Type, char *Script); + virtual ~CBEvent(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFader.cpp b/engines/wintermute/BFader.cpp new file mode 100644 index 0000000000..f64023a08d --- /dev/null +++ b/engines/wintermute/BFader.cpp @@ -0,0 +1,175 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFader.h" +#include "BGame.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + m_Active = false; + m_Red = m_Green = m_Blue = 0; + m_CurrentAlpha = 0x00; + m_SourceAlpha = 0; + m_TargetAlpha = 0; + m_Duration = 1000; + m_StartTime = 0; + m_System = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Update() { + if (!m_Active) return S_OK; + + int AlphaDelta = m_TargetAlpha - m_SourceAlpha; + + uint32 time; + + if (m_System) time = CBPlatform::GetTime() - m_StartTime; + else time = Game->m_Timer - m_StartTime; + + if (time >= m_Duration) m_CurrentAlpha = m_TargetAlpha; + else { + m_CurrentAlpha = m_SourceAlpha + (float)time / (float)m_Duration * AlphaDelta; + } + m_CurrentAlpha = MIN(255, std::max(m_CurrentAlpha, (byte )0)); + + m_Ready = time >= m_Duration; + if (m_Ready && m_CurrentAlpha == 0x00) m_Active = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Display() { + if (!m_Active) return S_OK; + + if (m_CurrentAlpha > 0x00) return Game->m_Renderer->FadeToColor(DRGBA(m_Red, m_Green, m_Blue, m_CurrentAlpha)); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Deactivate() { + m_Active = false; + m_Ready = true; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { + m_Ready = false; + m_Active = true; + + m_Red = D3DCOLGetR(SourceColor); + m_Green = D3DCOLGetG(SourceColor); + m_Blue = D3DCOLGetB(SourceColor); + + m_SourceAlpha = D3DCOLGetA(SourceColor); + m_TargetAlpha = 0; + + m_Duration = Duration; + m_System = System; + + if (m_System) m_StartTime = CBPlatform::GetTime(); + else m_StartTime = Game->m_Timer; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { + m_Ready = false; + m_Active = true; + + m_Red = D3DCOLGetR(TargetColor); + m_Green = D3DCOLGetG(TargetColor); + m_Blue = D3DCOLGetB(TargetColor); + + //m_SourceAlpha = 0; + m_SourceAlpha = m_CurrentAlpha; + m_TargetAlpha = D3DCOLGetA(TargetColor); + + m_Duration = Duration; + m_System = System; + + if (m_System) m_StartTime = CBPlatform::GetTime(); + else m_StartTime = Game->m_Timer; + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::GetCurrentColor() { + return DRGBA(m_Red, m_Green, m_Blue, m_CurrentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_Blue)); + PersistMgr->Transfer(TMEMBER(m_CurrentAlpha)); + PersistMgr->Transfer(TMEMBER(m_Duration)); + PersistMgr->Transfer(TMEMBER(m_Green)); + PersistMgr->Transfer(TMEMBER(m_Red)); + PersistMgr->Transfer(TMEMBER(m_SourceAlpha)); + PersistMgr->Transfer(TMEMBER(m_StartTime)); + PersistMgr->Transfer(TMEMBER(m_TargetAlpha)); + PersistMgr->Transfer(TMEMBER(m_System)); + + if (m_System && !PersistMgr->m_Saving) m_StartTime = 0; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFader.h b/engines/wintermute/BFader.h new file mode 100644 index 0000000000..44ce256826 --- /dev/null +++ b/engines/wintermute/BFader.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "BObject.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool m_System; + uint32 GetCurrentColor(); + HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); + HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); + HRESULT Deactivate(); + HRESULT Display(); + HRESULT Update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool m_Active; + byte m_Red; + byte m_Green; + byte m_Blue; + byte m_CurrentAlpha; + byte m_TargetAlpha; + byte m_SourceAlpha; + uint32 m_Duration; + uint32 m_StartTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFile.cpp b/engines/wintermute/BFile.cpp new file mode 100644 index 0000000000..f4d7da2c70 --- /dev/null +++ b/engines/wintermute/BFile.cpp @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFile.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + m_Pos = 0; + m_Size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::IsEOF() { + return m_Pos == m_Size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = GetPos(); + Seek(0); + byte *data = new byte[GetSize()]; + Read(data, GetSize()); + Seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFile.h b/engines/wintermute/BFile.h new file mode 100644 index 0000000000..db6a29d903 --- /dev/null +++ b/engines/wintermute/BFile.h @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "BBase.h" +#include "common/str.h" + +namespace Common { + class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +public: + uint32 m_Pos; + uint32 m_Size; + virtual uint32 GetSize() { + return m_Size; + }; + virtual uint32 GetPos() { + return m_Pos; + }; + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; + virtual HRESULT Read(void *Buffer, uint32 Size) = 0; + virtual HRESULT Close() = 0; + virtual HRESULT Open(Common::String Filename) = 0; + virtual bool IsEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFileEntry.cpp b/engines/wintermute/BFileEntry.cpp new file mode 100644 index 0000000000..18a15e37f9 --- /dev/null +++ b/engines/wintermute/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "dcgf.h" +#include "BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + m_Package = NULL; + m_Length = m_CompressedLength = m_Offset = m_Flags = 0; + m_Filename = ""; + + m_TimeDate1 = m_TimeDate2 = 0; + + m_JournalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + m_Package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFileEntry.h b/engines/wintermute/BFileEntry.h new file mode 100644 index 0000000000..cfad80926c --- /dev/null +++ b/engines/wintermute/BFileEntry.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 m_TimeDate2; + uint32 m_TimeDate1; + uint32 m_Flags; + uint32 m_JournalTime; + std::string m_Filename; + uint32 m_CompressedLength; + uint32 m_Length; + uint32 m_Offset; + CBPackage *m_Package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp new file mode 100644 index 0000000000..d679321598 --- /dev/null +++ b/engines/wintermute/BFileManager.cpp @@ -0,0 +1,743 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFileManager.h" +#include "StringUtil.h" +#include "PathUtil.h" +#include "BDiskFile.h" +#include "BResourceFile.h" +#include "BSaveThumbFile.h" +#include "BFileEntry.h" +#include "BPkgFile.h" +#include "BPackage.h" +#include "BRegistry.h" +#include "BGame.h" +#include "dcpackage.h" +#include "utils.h" +#include "PlatformSDL.h" +#include "common/str.h" +#include "common/textconsole.h" +#include + +#ifdef __WIN32__ +# include +#else +# include +#endif + +#ifdef __APPLE__ +# include +#endif + + +#if _DEBUG +#pragma comment(lib, "zlib_d.lib") +#else +#pragma comment(lib, "zlib.lib") +#endif + + +extern "C" +{ +#include "zlib.h" +} + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + m_BasePath = NULL; + + InitPaths(); + RegisterPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::Cleanup() { + int i; + + // delete registered paths + for (i = 0; i < m_SinglePaths.GetSize(); i++) + delete [] m_SinglePaths[i]; + m_SinglePaths.RemoveAll(); + + for (i = 0; i < m_PackagePaths.GetSize(); i++) + delete [] m_PackagePaths[i]; + m_PackagePaths.RemoveAll(); + + + // delete file entries + m_FilesIter = m_Files.begin(); + while (m_FilesIter != m_Files.end()) { + delete m_FilesIter->second; + m_FilesIter++; + } + m_Files.clear(); + + // close open files + for (i = 0; i < m_OpenFiles.GetSize(); i++) { + m_OpenFiles[i]->Close(); + delete m_OpenFiles[i]; + } + m_OpenFiles.RemoveAll(); + + + // delete packages + for (i = 0; i < m_Packages.GetSize(); i++) + delete m_Packages[i]; + m_Packages.RemoveAll(); + + delete[] m_BasePath; + m_BasePath = NULL; + + return S_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool MustExist) { + + byte *buffer = NULL; + + CBFile *File = OpenFile(Filename); + if (!File) { + if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename); + return NULL; + } + + /* + if(File->GetSize()>MAX_FILE_SIZE){ + Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[File->GetSize() + 1]; + if (buffer == NULL) { + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->GetSize() + 1); + CloseFile(File); + return NULL; + } + + if (FAILED(File->Read(buffer, File->GetSize()))) { + Game->LOG(0, "Error reading file '%s'", Filename); + CloseFile(File); + delete [] buffer; + return NULL; + }; + + buffer[File->GetSize()] = '\0'; + if (Size != NULL) *Size = File->GetSize(); + CloseFile(File); + + return buffer; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { + RestoreCurrentDir(); + + CBUtils::CreatePath(Filename, false); + + FILE *f = fopen(Filename, "wb"); + if (!f) { + Game->LOG(0, "Error opening file '%s' for writing.", Filename); + return E_FAIL; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + Game->LOG(0, "Error allocating compression buffer while saving '%s'", Filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + Game->LOG(0, "Error compressing data while saving '%s'", Filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { + // unmount all non-local packages + for (int i = 0; i < m_Packages.GetSize(); i++) { + if (m_Packages[i]->m_CD > 0) m_Packages[i]->Close(); + } + + + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { + if (Path == NULL || strlen(Path) < 1) return E_FAIL; + + bool slashed = (Path[strlen(Path) - 1] == '\\' || Path[strlen(Path) - 1] == '/'); + + char *buffer = new char [strlen(Path) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return E_FAIL; + + strcpy(buffer, Path); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (Type) { + case PATH_SINGLE: + m_SinglePaths.Add(buffer); + break; + case PATH_PACKAGE: + m_PackagePaths.Add(buffer); + break; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::ReloadPaths() { + // delete registered paths + for (int i = 0; i < m_SinglePaths.GetSize(); i++) + delete [] m_SinglePaths[i]; + m_SinglePaths.RemoveAll(); + + for (int i = 0; i < m_PackagePaths.GetSize(); i++) + delete [] m_PackagePaths[i]; + m_PackagePaths.RemoveAll(); + + return InitPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::InitPaths() { + RestoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = Game->m_Registry->ReadString("Resource", "CustomPaths", ""); + numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + AddPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + AddPath(PATH_SINGLE, ".\\"); + + + // package files paths + AddPath(PATH_PACKAGE, "./"); + +#ifdef __APPLE__ + // search .app path and Resources dir in the bundle + CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); + +#ifdef __IPHONE__ + AddPath(PATH_PACKAGE, pathPtr); + AddPath(PATH_SINGLE, pathPtr); +#else + char bundlePath[MAX_PATH]; + + sprintf(bundlePath, "%s/../", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); + + sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); + + + CFRelease(appUrlRef); + CFRelease(macPath); +#endif +#endif + + + pathList = Game->m_Registry->ReadString("Resource", "PackagePaths", ""); + numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + AddPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + AddPath(PATH_PACKAGE, "data"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackages() { + RestoreCurrentDir(); + + Game->LOG(0, "Scanning packages..."); + warning("Scanning packages"); + + AnsiString extension = AnsiString(".") + AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < m_PackagePaths.GetSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::system_complete(m_PackagePaths[i]); + + //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } + + + Game->LOG(0, " Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool SearchSignature) { + char Filename[MAX_PATH]; + sprintf(Filename, "%s%s", Path, Name); + + FILE *f = fopen(Filename, "rb"); + if (!f) { + Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename); + return S_OK; + } + + uint32 AbosulteOffset = 0; + bool BoundToExe = false; + + if (SearchSignature) { + uint32 Offset; + if (!FindPackageSignature(f, &Offset)) { + fclose(f); + return S_OK; + } else { + fseek(f, Offset, SEEK_SET); + AbosulteOffset = Offset; + BoundToExe = true; + } + } + + TPackageHeader hdr; + fread(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); + fclose(f); + return S_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 DirOffset; + fread(&DirOffset, sizeof(uint32), 1, f); + DirOffset += AbosulteOffset; + fseek(f, DirOffset, SEEK_SET); + } + + for (int i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(Game); + if (!pkg) return E_FAIL; + + pkg->m_BoundToExe = BoundToExe; + + // read package info + byte NameLength; + fread(&NameLength, sizeof(byte ), 1, f); + pkg->m_Name = new char[NameLength]; + fread(pkg->m_Name, NameLength, 1, f); + fread(&pkg->m_CD, sizeof(byte ), 1, f); + pkg->m_Priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->m_CD = 0; // override CD to fixed disk + m_Packages.Add(pkg); + + + // read file entries + uint32 NumFiles; + fread(&NumFiles, sizeof(uint32), 1, f); + + for (int j = 0; j < NumFiles; j++) { + char *Name; + uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; + + fread(&NameLength, sizeof(byte ), 1, f); + Name = new char[NameLength]; + fread(Name, NameLength, 1, f); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < NameLength; k++) { + ((byte *)Name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + Name[NameLength - 1] = '\0'; + + + CBPlatform::strupr(Name); + + fread(&Offset, sizeof(uint32), 1, f); + Offset += AbosulteOffset; + fread(&Length, sizeof(uint32), 1, f); + fread(&CompLength, sizeof(uint32), 1, f); + fread(&Flags, sizeof(uint32), 1, f); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + fread(&TimeDate1, sizeof(uint32), 1, f); + fread(&TimeDate2, sizeof(uint32), 1, f); + } + + m_FilesIter = m_Files.find(Name); + if (m_FilesIter == m_Files.end()) { + CBFileEntry *file = new CBFileEntry(Game); + file->m_Package = pkg; + file->m_Offset = Offset; + file->m_Length = Length; + file->m_CompressedLength = CompLength; + file->m_Flags = Flags; + + m_Files[Name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->m_CD < m_FilesIter->second->m_Package->m_CD || pkg->m_Priority > m_FilesIter->second->m_Package->m_Priority) { + m_FilesIter->second->m_Package = pkg; + m_FilesIter->second->m_Offset = Offset; + m_FilesIter->second->m_Length = Length; + m_FilesIter->second->m_CompressedLength = CompLength; + m_FilesIter->second->m_Flags = Flags; + } + } + delete [] Name; + } + } + + + fclose(f); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::GetFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::StartsWith(plainName, "xdevice_", true)) { + return StringUtil::CompareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +FILE *CBFileManager::OpenPackage(char *Name) { + RestoreCurrentDir(); + + FILE *ret = NULL; + char Filename[MAX_PATH]; + + for (int i = 0; i < m_PackagePaths.GetSize(); i++) { + sprintf(Filename, "%s%s.%s", m_PackagePaths[i], Name, PACKAGE_EXTENSION); + ret = fopen(Filename, "rb"); + if (ret != NULL) return ret; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +FILE *CBFileManager::OpenSingleFile(char *Name) { + RestoreCurrentDir(); + + FILE *ret = NULL; + char Filename[MAX_PATH]; + + for (int i = 0; i < m_SinglePaths.GetSize(); i++) { + sprintf(Filename, "%s%s", m_SinglePaths[i], Name); + ret = fopen(Filename, "rb"); + if (ret != NULL) return ret; + } + + // didn't find in search paths, try to open directly + return fopen(Name, "rb"); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::GetFullPath(char *Filename, char *Fullname) { + RestoreCurrentDir(); + + FILE *f = NULL; + bool found = false; + + for (int i = 0; i < m_SinglePaths.GetSize(); i++) { + sprintf(Fullname, "%s%s", m_SinglePaths[i], Filename); + f = fopen(Fullname, "rb"); + if (f) { + fclose(f); + found = true; + break; + } + } + + if (!found) { + f = fopen(Filename, "rb"); + if (f) { + fclose(f); + found = true; + strcpy(Fullname, Filename); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { + char *upc_name = new char[strlen(Filename) + 1]; + strcpy(upc_name, Filename); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + m_FilesIter = m_Files.find(upc_name); + if (m_FilesIter != m_Files.end()) ret = m_FilesIter->second; + + delete [] upc_name; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { + if (strcmp(Filename, "") == 0) return NULL; + //Game->LOG(0, "open file: %s", Filename); +#ifdef __WIN32__ + if (Game->m_DEBUG_DebugMode && Game->m_DEBUG_AbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(Filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); + } + } +#endif + + CBFile *File = OpenFileRaw(Filename); + if (File) m_OpenFiles.Add(File); + return File; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::CloseFile(CBFile *File) { + for (int i = 0; i < m_OpenFiles.GetSize(); i++) { + if (m_OpenFiles[i] == File) { + m_OpenFiles[i]->Close(); + delete m_OpenFiles[i]; + m_OpenFiles.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile *CBFileManager::OpenFileRaw(const char *Filename) { + RestoreCurrentDir(); + + if (scumm_strnicmp(Filename, "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); + if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile; + else { + delete SaveThumbFile; + return NULL; + } + } + + CBDiskFile *DiskFile = new CBDiskFile(Game); + if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; + + delete DiskFile; + + CBPkgFile *PkgFile = new CBPkgFile(Game); + if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; + + delete PkgFile; + + CBResourceFile *ResFile = new CBResourceFile(Game); + if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; + + delete ResFile; + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RestoreCurrentDir() { + if (!m_BasePath) return S_OK; + else { + if (!chdir(m_BasePath)) return S_OK; + else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::SetBasePath(char *Path) { + Cleanup(); + + if (Path) { + m_BasePath = new char[strlen(Path) + 1]; + strcpy(m_BasePath, Path); + } + + InitPaths(); + RegisterPackages(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::FindPackageSignature(FILE *f, uint32 *Offset) { + byte buf[32768]; + + byte Signature[8]; + ((uint32 *)Signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)Signature)[1] = PACKAGE_MAGIC_2; + + fseek(f, 0, SEEK_END); + uint32 FileSize = ftell(f); + + int StartPos = 1024 * 1024; + + int BytesRead = StartPos; + + while (BytesRead < FileSize - 16) { + int ToRead = MIN(32768, FileSize - BytesRead); + fseek(f, StartPos, SEEK_SET); + int ActuallyRead = fread(buf, 1, ToRead, f); + if (ActuallyRead != ToRead) return false; + + for (int i = 0; i < ToRead - 8; i++) + if (!memcmp(buf + i, Signature, 8)) { + *Offset = StartPos + i; + return true; + } + + BytesRead = BytesRead + ToRead - 16; + StartPos = StartPos + ToRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h new file mode 100644 index 0000000000..e585841a4a --- /dev/null +++ b/engines/wintermute/BFileManager.h @@ -0,0 +1,81 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + + +#include +#include "coll_templ.h" +#include "BFileEntry.h" +#include "common/archive.h" + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool FindPackageSignature(FILE *f, uint32 *Offset); + HRESULT Cleanup(); + HRESULT SetBasePath(char *Path); + HRESULT RestoreCurrentDir(); + char *m_BasePath; + bool GetFullPath(char *Filename, char *Fullname); + CBFile *OpenFileRaw(const char *Filename); + HRESULT CloseFile(CBFile *File); + CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); + CBFileEntry *GetPackageEntry(const char *Filename); + FILE *OpenSingleFile(char *Name); + FILE *OpenPackage(char *Name); + HRESULT RegisterPackages(); + HRESULT InitPaths(); + HRESULT ReloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + HRESULT AddPath(TPathType Type, const char *Path); + HRESULT RequestCD(int CD, char *PackageFile, char *Filename); + HRESULT SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); + byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + CBArray m_SinglePaths; + CBArray m_PackagePaths; + CBArray m_Packages; + CBArray m_OpenFiles; + + std::map m_Files; +private: + HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); + std::map::iterator m_FilesIter; + bool IsValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFont.cpp b/engines/wintermute/BFont.cpp new file mode 100644 index 0000000000..93d870875d --- /dev/null +++ b/engines/wintermute/BFont.cpp @@ -0,0 +1,206 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFont.h" +#include "BFontBitmap.h" +#include "BParser.h" +#include "BFileManager.h" +#include "BFontTT.h" +#include "BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::GetTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::GetTextWidth(byte *text, int MaxLenght) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +HRESULT CBFont::LoadFile(char * Filename) +{ + BYTE* Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if(Buffer==NULL){ + Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename)+1]; + strcpy(m_Filename, Filename); + + if(FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFont::LoadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(Game); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + Game->LOG(0, "'FONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custom_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + Game->LOG(0, "Syntax error in FONT definition"); + return E_FAIL; + } + + return S_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::GetLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFont::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::CreateFromFile(CBGame *Game, char *Filename) { + if (IsTrueType(Game, Filename)) { + CBFontTT *Font = new CBFontTT(Game); + if (Font) { + if (FAILED(Font->LoadFile(Filename))) { + delete Font; + return NULL; + } + } + return Font; + } else { + CBFontBitmap *Font = new CBFontBitmap(Game); + if (Font) { + if (FAILED(Font->LoadFile(Filename))) { + delete Font; + return NULL; + } + } + return Font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::IsTrueType(CBGame *Game, char *Filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) return false; + + byte *WorkBuffer = Buffer; + + char *params; + CBParser parser(Game); + + bool Ret = false; + if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + Ret = true; + + delete [] Buffer; + return Ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFont.h b/engines/wintermute/BFont.h new file mode 100644 index 0000000000..5ffba7ace4 --- /dev/null +++ b/engines/wintermute/BFont.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "BObject.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int GetTextWidth(byte *text, int MaxLenght = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + virtual void InitLoop() {}; + + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *CreateFromFile(CBGame *Game, char *Filename); + +private: + //HRESULT LoadBuffer(byte * Buffer); + //HRESULT LoadFile(char* Filename); + static bool IsTrueType(CBGame *Game, char *Filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp new file mode 100644 index 0000000000..e7a1466ed0 --- /dev/null +++ b/engines/wintermute/BFontBitmap.cpp @@ -0,0 +1,532 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFontBitmap.h" +#include "StringUtil.h" +#include "BParser.h" +#include "BFrame.h" +#include "BSurface.h" +#include "BGame.h" +#include "BSubFrame.h" +#include "BFrame.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + m_Subframe = NULL; + m_Sprite = NULL; + m_WidthsFrame = 0; + memset(m_Widths, 0, NUM_CHARACTERS); + m_TileWidth = m_TileHeight = m_NumColumns = 0; + m_FontextFix = false; + m_Freezable = false; + m_WholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + SAFE_DELETE(m_Subframe); + SAFE_DELETE(m_Sprite); +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { + TextHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetTextHeight(byte *text, int width) { + return TextHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { + AnsiString str; + + if (Game->m_TextEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); + str = StringUtil::WideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (MaxLength >= 0 && str.length() > MaxLength) str = str.substr(0, MaxLength); + + int TextWidth = 0; + for (size_t i = 0; i < str.length(); i++) { + TextWidth += GetCharWidth(str[i]); + } + + return TextWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { + if (MaxLenght == 0) return 0; + + if (text == NULL || text[0] == '\0') return m_TileHeight; + + + + AnsiString str; + + if (Game->m_TextEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); + str = StringUtil::WideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) Game->m_Renderer->StartSpriteBatch(); + + while (!done) { + if (max_height > 0 && (NumLines + 1)*m_TileHeight > max_height) { + if (draw) Game->m_Renderer->EndSpriteBatch(); + return NumLines * m_TileHeight; + } + + index++; + + if (str[index] == ' ' && (max_height < 0 || max_height / m_TileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + GetCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str[index + 1] == '\0' || (MaxLenght >= 0 && index == MaxLenght - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += GetCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += GetCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + } + for (i = start; i < end + 1; i++) { + if (draw) DrawChar(str[i], StartX, y); + StartX += GetCharWidth(str[i]); + } + y += m_TileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) Game->m_Renderer->EndSpriteBatch(); + + return NumLines * m_TileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::DrawChar(byte c, int x, int y) { + if (m_FontextFix) c--; + + int row, col; + + row = c / m_NumColumns; + col = c % m_NumColumns; + + RECT rect; + /* l t r b */ + int TileWidth; + if (m_WholeCell) TileWidth = m_TileWidth; + else TileWidth = m_Widths[c]; + + CBPlatform::SetRect(&rect, col * m_TileWidth, row * m_TileHeight, col * m_TileWidth + TileWidth, (row + 1)*m_TileHeight); + bool Handled = false; + if (m_Sprite) { + m_Sprite->GetCurrentFrame(); + if (m_Sprite->m_CurrentFrame >= 0 && m_Sprite->m_CurrentFrame < m_Sprite->m_Frames.GetSize() && m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]) { + if (m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]->m_Subframes.GetSize() > 0) { + m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]->m_Subframes[0]->m_Surface->DisplayTrans(x, y, rect); + } + Handled = true; + } + } + if (!Handled && m_Subframe) m_Subframe->m_Surface->DisplayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_FONT) { + Game->LOG(0, "'FONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int last_width = 0; + int i; + int r = 255, g = 255, b = 255; + bool custom_trans = false; + char *surface_file = NULL; + char *sprite_file = NULL; + + bool AutoWidth = false; + int SpaceWidth = 0; + int ExpandWidth = 0; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surface_file = (char *)params; + break; + + case TOKEN_SPRITE: + sprite_file = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custom_trans = true; + break; + + case TOKEN_WIDTHS: + parser.ScanStr(params, "%D", widths, &num); + for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { + m_Widths[last_width] = (byte )widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.ScanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.ScanStr(params, "%d", &m_WidthsFrame); + break; + + case TOKEN_COLUMNS: + parser.ScanStr(params, "%d", &m_NumColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.ScanStr(params, "%d", &m_TileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.ScanStr(params, "%d", &m_TileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.ScanStr(params, "%b", &AutoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.ScanStr(params, "%b", &m_FontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.ScanStr(params, "%b", &m_WholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.ScanStr(params, "%d", &SpaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.ScanStr(params, "%d", &ExpandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in FONT definition"); + return E_FAIL; + } + + if (sprite_file != NULL) { + SAFE_DELETE(m_Sprite); + m_Sprite = new CBSprite(Game, this); + if (!m_Sprite || FAILED(m_Sprite->LoadFile(sprite_file))) SAFE_DELETE(m_Sprite); + } + + if (surface_file != NULL && !m_Sprite) { + m_Subframe = new CBSubFrame(Game); + if (custom_trans) m_Subframe->SetSurface(surface_file, false, r, g, b); + else m_Subframe->SetSurface(surface_file); + } + + + if (((m_Subframe == NULL || m_Subframe->m_Surface == NULL) && m_Sprite == NULL) || m_NumColumns == 0 || m_TileWidth == 0 || m_TileHeight == 0) { + Game->LOG(0, "Incomplete font definition"); + return E_FAIL; + } + + if (AutoWidth) { + // calculate characters width + GetWidths(); + + // do we need to modify widths? + if (ExpandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)m_Widths[i] + ExpandWidth; + if (NewWidth < 0) NewWidth = 0; + + m_Widths[i] = (byte )NewWidth; + } + } + + // handle space character + char SpaceChar = ' '; + if (m_FontextFix) SpaceChar--; + + if (SpaceWidth != 0) m_Widths[SpaceChar] = SpaceWidth; + else { + if (m_Widths[SpaceChar] == ExpandWidth || m_Widths[SpaceChar] == 0) { + m_Widths[SpaceChar] = (m_Widths['m'] + m_Widths['i']) / 2; + } + } + } else { + for (i = last_width; i < NUM_CHARACTERS; i++) m_Widths[i] = default_width; + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { + + CBFont::Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_NumColumns)); + + PersistMgr->Transfer(TMEMBER(m_Subframe)); + PersistMgr->Transfer(TMEMBER(m_TileHeight)); + PersistMgr->Transfer(TMEMBER(m_TileWidth)); + PersistMgr->Transfer(TMEMBER(m_Sprite)); + PersistMgr->Transfer(TMEMBER(m_WidthsFrame)); + + if (PersistMgr->m_Saving) + PersistMgr->PutBytes(m_Widths, sizeof(m_Widths)); + else + PersistMgr->GetBytes(m_Widths, sizeof(m_Widths)); + + + PersistMgr->Transfer(TMEMBER(m_FontextFix)); + PersistMgr->Transfer(TMEMBER(m_WholeCell)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetCharWidth(byte Index) { + if (m_FontextFix) Index--; + return m_Widths[Index]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::GetWidths() { + CBSurface *surf = NULL; + + if (m_Sprite) { + if (m_WidthsFrame >= 0 && m_WidthsFrame < m_Sprite->m_Frames.GetSize()) { + if (m_Sprite->m_Frames[m_WidthsFrame] && m_Sprite->m_Frames[m_WidthsFrame]->m_Subframes.GetSize() > 0) { + surf = m_Sprite->m_Frames[m_WidthsFrame]->m_Subframes[0]->m_Surface; + } + } + } + if (surf == NULL && m_Subframe) surf = m_Subframe->m_Surface; + if (!surf || FAILED(surf->StartPixelOp())) return E_FAIL; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % m_NumColumns) * m_TileWidth; + int yyy = (i / m_NumColumns) * m_TileHeight; + + + int min_col = -1; + for (int row = 0; row < m_TileHeight; row++) { + for (int col = m_TileWidth - 1; col >= min_col + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; + if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + min_col = std::max(col, min_col); + break; + } + } + if (min_col == m_TileWidth - 1) break; + } + + m_Widths[i] = min_col + 1; + } + surf->EndPixelOp(); + /* + Game->LOG(0, "----- %s ------", m_Filename); + for(int j=0; j<16; j++) + { + Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", m_Widths[j*16+0], m_Widths[j*16+1], m_Widths[j*16+2], m_Widths[j*16+3], m_Widths[j*16+4], m_Widths[j*16+5], m_Widths[j*16+6], m_Widths[j*16+7], m_Widths[j*16+8], m_Widths[j*16+9], m_Widths[j*16+10], m_Widths[j*16+11], m_Widths[j*16+12], m_Widths[j*16+13], m_Widths[j*16+14], m_Widths[j*16+15]); + } + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetLetterHeight() { + return m_TileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFontBitmap.h b/engines/wintermute/BFontBitmap.h new file mode 100644 index 0000000000..c56c192e63 --- /dev/null +++ b/engines/wintermute/BFontBitmap.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "BFont.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + HRESULT LoadBuffer(byte *Buffer); + HRESULT LoadFile(char *Filename); + virtual int GetTextWidth(byte *text, int MaxLength = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + HRESULT GetWidths(); + CBSprite *m_Sprite; + int m_WidthsFrame; + bool m_FontextFix; + int m_NumColumns; + int m_TileHeight; + int m_TileWidth; + byte m_Widths[NUM_CHARACTERS]; + CBSubFrame *m_Subframe; + bool m_WholeCell; + +private: + int GetCharWidth(byte Index); + void DrawChar(byte c, int x, int y); + + int TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp new file mode 100644 index 0000000000..cb14714550 --- /dev/null +++ b/engines/wintermute/BFontStorage.cpp @@ -0,0 +1,155 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFontStorage.h" +#include "BGame.h" +#include "BFont.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { + m_FTLibrary = NULL; + InitFreeType(); +} + + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + Cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontStorage::InitFreeType() { + FT_Error error = FT_Init_FreeType(&m_FTLibrary); + if (error) { + Game->LOG(0, "Error initializing FreeType library."); + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::Cleanup(bool Warn) { + int i; + + for (i = 0; i < m_Fonts.GetSize(); i++) { + if (Warn) Game->LOG(0, "Removing orphan font '%s'", m_Fonts[i]->m_Filename); + delete m_Fonts[i]; + } + m_Fonts.RemoveAll(); + + + if (m_FTLibrary) FT_Done_FreeType(m_FTLibrary); + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::InitLoop() { + for (int i = 0; i < m_Fonts.GetSize(); i++) { + m_Fonts[i]->InitLoop(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::AddFont(char *Filename) { + if (!Filename) return NULL; + + for (int i = 0; i < m_Fonts.GetSize(); i++) { + if (scumm_stricmp(m_Fonts[i]->m_Filename, Filename) == 0) { + m_Fonts[i]->m_RefCount++; + return m_Fonts[i]; + } + } + + /* + CBFont* font = new CBFont(Game); + if(!font) return NULL; + + if(FAILED(font->LoadFile(Filename))){ + delete font; + return NULL; + } + else { + font->m_RefCount = 1; + m_Fonts.Add(font); + return font; + } + */ + CBFont *font = CBFont::CreateFromFile(Game, Filename); + if (font) { + font->m_RefCount = 1; + m_Fonts.Add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::RemoveFont(CBFont *Font) { + if (!Font) return E_FAIL; + + for (int i = 0; i < m_Fonts.GetSize(); i++) { + if (m_Fonts[i] == Font) { + m_Fonts[i]->m_RefCount--; + if (m_Fonts[i]->m_RefCount <= 0) { + delete m_Fonts[i]; + m_Fonts.RemoveAt(i); + } + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::Persist(CBPersistMgr *PersistMgr) { + + if (!PersistMgr->m_Saving) Cleanup(false); + + PersistMgr->Transfer(TMEMBER(Game)); + m_Fonts.Persist(PersistMgr); + + if (!PersistMgr->m_Saving) InitFreeType(); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h new file mode 100644 index 0000000000..6dc2273022 --- /dev/null +++ b/engines/wintermute/BFontStorage.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "BBase.h" +#include "persistent.h" +#include "coll_templ.h" + +#include +#include FT_FREETYPE_H + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + HRESULT Cleanup(bool Warn = false); + HRESULT RemoveFont(CBFont *Font); + CBFont *AddFont(char *Filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray m_Fonts; + HRESULT InitLoop(); + + FT_Library GetFTLibrary() const { + return m_FTLibrary; + } + +private: + void InitFreeType(); + FT_Library m_FTLibrary; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp new file mode 100644 index 0000000000..a1ca6577fa --- /dev/null +++ b/engines/wintermute/BFontTT.cpp @@ -0,0 +1,853 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include +#include FT_FREETYPE_H +#include "dcgf.h" +#include "BFile.h" +#include "BFontTT.h" +#include "FontGlyphCache.h" +#include "PathUtil.h" +#include "StringUtil.h" +#include "MathUtil.h" +#include "BRenderSDL.h" +#include "BSurfaceSDL.h" +#include "BParser.h" +#include "BGame.h" +#include "BFileManager.h" +#include "utils.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + m_FontHeight = 12; + m_IsBold = m_IsItalic = m_IsUnderline = m_IsStriked = false; + + m_FontFile = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) m_CachedTexts[i] = NULL; + + + m_FTFace = NULL; + m_FTStream = NULL; + + m_GlyphCache = NULL; + + m_Ascender = m_Descender = m_LineHeight = m_PointSize = m_UnderlinePos = 0; + m_HorDpi = m_VertDpi = 0; + m_MaxCharWidth = m_MaxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + ClearCache(); + + for (int i = 0; i < m_Layers.GetSize(); i++) { + delete m_Layers[i]; + } + m_Layers.RemoveAll(); + + delete[] m_FontFile; + m_FontFile = NULL; + + delete m_GlyphCache; + m_GlyphCache = NULL; + + if (m_FTFace) { + FT_Done_Face(m_FTFace); + m_FTFace = NULL; + } + delete[] m_FTStream; + m_FTStream = NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::ClearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (m_CachedTexts[i]) delete m_CachedTexts[i]; + m_CachedTexts[i] = NULL; + } + +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::InitLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (Game->m_ConstrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (m_CachedTexts[i] == NULL) continue; + + if (!m_CachedTexts[i]->m_Marked) { + delete m_CachedTexts[i]; + m_CachedTexts[i] = NULL; + } else m_CachedTexts[i]->m_Marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { + WideString text; + + if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); + + if (MaxLength >= 0 && text.length() > MaxLength) text = text.substr(0, MaxLength); + + int textWidth, textHeight; + MeasureText(text, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetTextHeight(byte *Text, int Width) { + WideString text; + + if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); + + + int textWidth, textHeight; + MeasureText(text, Width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { + if (Text == NULL || strcmp((char *)Text, "") == 0) return; + + WideString text; + + if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); + + if (MaxLength >= 0 && text.length() > MaxLength) text = text.substr(0, MaxLength); + + CBRenderSDL *m_Renderer = (CBRenderSDL *)Game->m_Renderer; + + // find cached surface, if exists + int MinPriority = INT_MAX; + int MinIndex = -1; + CBSurface *Surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (m_CachedTexts[i] == NULL) { + MinPriority = 0; + MinIndex = i; + } else { + if (m_CachedTexts[i]->m_Text == text && m_CachedTexts[i]->m_Align == Align && m_CachedTexts[i]->m_Width == Width && m_CachedTexts[i]->m_MaxHeight == MaxHeight && m_CachedTexts[i]->m_MaxLength == MaxLength) { + Surface = m_CachedTexts[i]->m_Surface; + textOffset = m_CachedTexts[i]->m_TextOffset; + m_CachedTexts[i]->m_Priority++; + m_CachedTexts[i]->m_Marked = true; + break; + } else { + if (m_CachedTexts[i]->m_Priority < MinPriority) { + MinPriority = m_CachedTexts[i]->m_Priority; + MinIndex = i; + } + } + } + } + + // not found, create one + if (!Surface) { + Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); + if (Surface) { + // write surface to cache + if (m_CachedTexts[MinIndex] != NULL) delete m_CachedTexts[MinIndex]; + m_CachedTexts[MinIndex] = new CBCachedTTFontText; + + m_CachedTexts[MinIndex]->m_Surface = Surface; + m_CachedTexts[MinIndex]->m_Align = Align; + m_CachedTexts[MinIndex]->m_Width = Width; + m_CachedTexts[MinIndex]->m_MaxHeight = MaxHeight; + m_CachedTexts[MinIndex]->m_MaxLength = MaxLength; + m_CachedTexts[MinIndex]->m_Priority = 1; + m_CachedTexts[MinIndex]->m_Text = text; + m_CachedTexts[MinIndex]->m_TextOffset = textOffset; + m_CachedTexts[MinIndex]->m_Marked = true; + } + } + + + // and paint it + if (Surface) { + RECT rc; + CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight()); + for (int i = 0; i < m_Layers.GetSize(); i++) { + uint32 Color = m_Layers[i]->m_Color; + uint32 OrigForceAlpha = m_Renderer->m_ForceAlphaColor; + if (m_Renderer->m_ForceAlphaColor != 0) { + Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(m_Renderer->m_ForceAlphaColor)); + m_Renderer->m_ForceAlphaColor = 0; + } + Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, m_Layers[i]->m_OffsetX, m_Layers[i]->m_OffsetY); + + m_Renderer->m_ForceAlphaColor = OrigForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + TextLineList lines; + WrapText(text, width, maxHeight, lines); + + + TextLineList::iterator it; + + int textHeight = lines.size() * (m_MaxCharHeight + m_Ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)m_Descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().length(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = std::max(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().length(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (m_IsUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(m_UnderlinePos + m_Ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); + if (SUCCEEDED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + Uint8 *srcBuf = (Uint8 *)src->pixels + y * src->pitch; + Uint8 *tgtBuf = (Uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + Uint32 *srcBuf32 = (Uint32 *)srcBuf; + Uint32 *tgtBuf32 = (Uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } + +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetLetterHeight() { + return GetLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::LoadBuffer(byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + Game->LOG(0, "'TTFONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.ScanStr(params, "%d", &m_FontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::SetString(&m_FontFile, params); + break; + + case TOKEN_BOLD: + parser.ScanStr(params, "%b", &m_IsBold); + break; + + case TOKEN_ITALIC: + parser.ScanStr(params, "%b", &m_IsItalic); + break; + + case TOKEN_UNDERLINE: + parser.ScanStr(params, "%b", &m_IsUnderline); + break; + + case TOKEN_STRIKE: + parser.ScanStr(params, "%b", &m_IsStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = DRGBA(r, g, b, D3DCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.ScanStr(params, "%d", &a); + BaseColor = DRGBA(D3DCOLGetR(BaseColor), D3DCOLGetG(BaseColor), D3DCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) m_Layers.Add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TTFONT definition"); + return E_FAIL; + } + + // create at least one layer + if (m_Layers.GetSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->m_Color = BaseColor; + m_Layers.Add(Layer); + } + + if (!m_FontFile) CBUtils::SetString(&m_FontFile, "arial.ttf"); + + return InitFont(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.ScanStr(params, "%d", &Layer->m_OffsetX); + break; + + case TOKEN_OFFSET_Y: + parser.ScanStr(params, "%d", &Layer->m_OffsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + Layer->m_Color = DRGBA(r, g, b, D3DCOLGetA(Layer->m_Color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.ScanStr(params, "%d", &a); + Layer->m_Color = DRGBA(D3DCOLGetR(Layer->m_Color), D3DCOLGetG(Layer->m_Color), D3DCOLGetB(Layer->m_Color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return E_FAIL; + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { + CBFont::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_IsBold)); + PersistMgr->Transfer(TMEMBER(m_IsItalic)); + PersistMgr->Transfer(TMEMBER(m_IsUnderline)); + PersistMgr->Transfer(TMEMBER(m_IsStriked)); + PersistMgr->Transfer(TMEMBER(m_FontHeight)); + PersistMgr->Transfer(TMEMBER(m_FontFile)); + + + // persist layers + int NumLayers; + if (PersistMgr->m_Saving) { + NumLayers = m_Layers.GetSize(); + PersistMgr->Transfer(TMEMBER(NumLayers)); + for (int i = 0; i < NumLayers; i++) m_Layers[i]->Persist(PersistMgr); + } else { + NumLayers = m_Layers.GetSize(); + PersistMgr->Transfer(TMEMBER(NumLayers)); + for (int i = 0; i < NumLayers; i++) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->Persist(PersistMgr); + m_Layers.Add(Layer); + } + } + + if (!PersistMgr->m_Saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) m_CachedTexts[i] = NULL; + m_GlyphCache = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::AfterLoad() { + InitFont(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::InitFont() { + if (!m_FontFile) return E_FAIL; + + CBFile *file = Game->m_FileManager->OpenFile(m_FontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(m_FontFile)); + file = Game->m_FileManager->OpenFile((char *)fontFileName.c_str(), false); + + if (!file) { + Game->LOG(0, "Error loading TrueType font '%s'", m_FontFile); + return E_FAIL; + } + } + + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + m_FTStream = (FT_Stream)new byte[sizeof(*m_FTStream)]; + memset(m_FTStream, 0, sizeof(*m_FTStream)); + + m_FTStream->read = CBFontTT::FTReadSeekProc; + m_FTStream->close = CBFontTT::FTCloseProc; + m_FTStream->descriptor.pointer = file; + m_FTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = m_FTStream; + + error = FT_Open_Face(Game->m_FontStorage->GetFTLibrary(), &args, 0, &m_FTFace); + if (error) { + SAFE_DELETE_ARRAY(m_FTStream); + Game->m_FileManager->CloseFile(file); + return E_FAIL; + } + + error = FT_Set_Char_Size(m_FTFace, 0, (FT_F26Dot6)(m_FontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(m_FTFace); + m_FTFace = NULL; + return E_FAIL; + } + + // http://en.wikipedia.org/wiki/Em_(typography) + float pixelsPerEm = (m_FontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / m_FTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = m_FTFace->bbox.xMin * pixelsPerUnit; + float xMax = m_FTFace->bbox.xMax * pixelsPerUnit; + float yMin = m_FTFace->bbox.yMin * pixelsPerUnit; + float yMax = m_FTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + m_Ascender = m_FTFace->ascender * pixelsPerUnit; + m_Descender = - m_FTFace->descender * pixelsPerUnit; + m_LineHeight = MathUtil::RoundUp(m_FTFace->height * pixelsPerUnit) + 2; + m_UnderlinePos = - m_FTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + m_MaxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + m_MaxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + m_GlyphCache = new FontGlyphCache(); + m_GlyphCache->Initialize(); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// I/O bridge between FreeType and WME file system +////////////////////////////////////////////////////////////////////////// +unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return 0; + + f->Seek(offset, SEEK_TO_BEGIN); + if (count) { + uint32 oldPos = f->GetPos(); + f->Read(buffer, count); + return f->GetPos() - oldPos; + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::FTCloseProc(FT_Stream stream) { + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return; + + CBGame *Game = f->Game; + + Game->m_FileManager->CloseFile(f); + stream->descriptor.pointer = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines) { + int currWidth = 0; + wchar_t prevChar = L'\0'; + int prevSpaceIndex = -1; + int prevSpaceWidth = 0; + int lineStartIndex = 0; + + PrepareGlyphs(text); + + for (size_t i = 0; i < text.length(); i++) { + wchar_t ch = text[i]; + + if (ch == L' ') { + prevSpaceIndex = i; + prevSpaceWidth = currWidth; + } + + int charWidth = 0; + + if (ch != L'\n') { + GlyphInfo *glyphInfo = GetGlyphCache()->GetGlyph(ch); + if (!glyphInfo) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + prevChar = ch; + + charWidth = (int)(glyphInfo->GetAdvanceX() + kerning); + } + + bool lineTooLong = maxWidth >= 0 && currWidth + charWidth > maxWidth; + bool breakOnSpace = false; + + // we can't fit even a single character + if (lineTooLong && currWidth == 0) break; + + + if (ch == L'\n' || i == text.length() - 1 || lineTooLong) { + int breakPoint, breakWidth; + + if (prevSpaceIndex >= 0 && lineTooLong) { + breakPoint = prevSpaceIndex; + breakWidth = prevSpaceWidth; + breakOnSpace = true; + } else { + breakPoint = i; + breakWidth = currWidth; + + breakOnSpace = (ch == L'\n'); + + // we're at the end + if (i == text.length() - 1) { + breakPoint++; + breakWidth += charWidth; + } + } + + if (maxHeight >= 0 && (lines.size() + 1) * GetLineHeight() > maxHeight) break; + + WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); + lines.push_back(new TextLine(line, breakWidth)); + + currWidth = 0; + prevChar = L'\0'; + prevSpaceIndex = -1; + + if (breakOnSpace) breakPoint++; + + lineStartIndex = breakPoint; + i = breakPoint - 1; + + continue; + } + + //if (ch == L' ' && currLine.empty()) continue; + currWidth += charWidth; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + TextLineList lines; + WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * GetLineHeight()); + textWidth = 0; + + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = std::max(textWidth, line->GetWidth()); + SAFE_DELETE(line); + } +} + + +////////////////////////////////////////////////////////////////////////// +float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { + GlyphInfo *infoLeft = m_GlyphCache->GetGlyph(leftChar); + GlyphInfo *infoRight = m_GlyphCache->GetGlyph(rightChar); + + if (!infoLeft || !infoRight) return 0; + + FT_Vector delta; + FT_Error error = FT_Get_Kerning(m_FTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); + if (error) return 0; + + return delta.x * (1.0f / 64.0f); +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::PrepareGlyphs(const WideString &text) { + // make sure we have all the glyphs we need + for (size_t i = 0; i < text.length(); i++) { + wchar_t ch = text[i]; + if (!m_GlyphCache->HasGlyph(ch)) CacheGlyph(ch); + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::CacheGlyph(wchar_t ch) { + FT_UInt glyphIndex = FT_Get_Char_Index(m_FTFace, ch); + if (!glyphIndex) return; + + FT_Error error = FT_Load_Glyph(m_FTFace, glyphIndex, FT_LOAD_DEFAULT); + if (error) return; + + error = FT_Render_Glyph(m_FTFace->glyph, FT_RENDER_MODE_NORMAL); + if (error) return; + + byte *pixels = m_FTFace->glyph->bitmap.buffer; + size_t stride = m_FTFace->glyph->bitmap.pitch; + + + // convert from monochrome to grayscale if needed + byte *tempBuffer = NULL; + if (pixels != NULL && m_FTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { + tempBuffer = new byte[m_FTFace->glyph->bitmap.width * m_FTFace->glyph->bitmap.rows]; + for (int j = 0; j < m_FTFace->glyph->bitmap.rows; j++) { + int rowOffset = stride * j; + for (int i = 0; i < m_FTFace->glyph->bitmap.width; i++) { + int byteOffset = i / 8; + int bitOffset = 7 - (i % 8); + byte bit = (pixels[rowOffset + byteOffset] & (1 << bitOffset)) >> bitOffset; + tempBuffer[m_FTFace->glyph->bitmap.width * j + i] = 255 * bit; + } + } + + pixels = tempBuffer; + stride = m_FTFace->glyph->bitmap.width; + } + + // add glyph to cache + m_GlyphCache->AddGlyph(ch, glyphIndex, m_FTFace->glyph, m_FTFace->glyph->bitmap.width, m_FTFace->glyph->bitmap.rows, pixels, stride); + + if (tempBuffer) delete [] tempBuffer; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h new file mode 100644 index 0000000000..6fbb019a27 --- /dev/null +++ b/engines/wintermute/BFontTT.h @@ -0,0 +1,188 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "BFontStorage.h" +#include "BFont.h" +#include "BSurface.h" + +#define NUM_CACHED_TEXTS 30 +class SDL_Surface; +namespace WinterMute { + +class FontGlyphCache; + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString m_Text; + int m_Width; + TTextAlign m_Align; + int m_MaxHeight; + int m_MaxLength; + CBSurface *m_Surface; + int m_Priority; + int m_TextOffset; + bool m_Marked; + + CBCachedTTFontText() { + m_Text = L""; + m_Width = m_MaxHeight = m_MaxLength = -1; + m_Align = TAL_LEFT; + m_Surface = NULL; + m_Priority = -1; + m_TextOffset = 0; + m_Marked = false; + } + + virtual ~CBCachedTTFontText() { + if (m_Surface) delete m_Surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + m_OffsetX = m_OffsetY = 0; + m_Color = 0x00000000; + } + + HRESULT Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_OffsetX)); + PersistMgr->Transfer(TMEMBER(m_OffsetY)); + PersistMgr->Transfer(TMEMBER(m_Color)); + return S_OK; + } + + int m_OffsetX; + int m_OffsetY; + uint32 m_Color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + m_Text = text; + m_Width = width; + } + + const WideString &GetText() const { + return m_Text; + } + int GetWidth() const { + return m_Width; + } + private: + WideString m_Text; + int m_Width; + }; + typedef std::list TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int GetTextWidth(byte *text, int MaxLenght = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + HRESULT LoadBuffer(byte *Buffer); + HRESULT LoadFile(char *Filename); + + static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); + static void FTCloseProc(FT_Stream stream); + + FontGlyphCache *GetGlyphCache() { + return m_GlyphCache; + } + + float GetLineHeight() const { + return m_LineHeight; + } + + void AfterLoad(); + void InitLoop(); + +private: + HRESULT ParseLayer(CBTTFontLayer *Layer, byte *Buffer); + + void WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + float GetKerning(wchar_t leftChar, wchar_t rightChar); + void PrepareGlyphs(const WideString &text); + void CacheGlyph(wchar_t ch); + + CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect); + + + CBCachedTTFontText *m_CachedTexts[NUM_CACHED_TEXTS]; + + HRESULT InitFont(); + FT_Stream m_FTStream; + FT_Face m_FTFace; + + FontGlyphCache *m_GlyphCache; + + float m_Ascender; + float m_Descender; + float m_LineHeight; + float m_UnderlinePos; + float m_PointSize; + float m_VertDpi; + float m_HorDpi; + + size_t m_MaxCharWidth; + size_t m_MaxCharHeight; + +public: + bool m_IsBold; + bool m_IsItalic; + bool m_IsUnderline; + bool m_IsStriked; + int m_FontHeight; + char *m_FontFile; + + CBArray m_Layers; + void ClearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp new file mode 100644 index 0000000000..4d8d557a2a --- /dev/null +++ b/engines/wintermute/BFrame.cpp @@ -0,0 +1,707 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BParser.h" +#include "BFrame.h" +#include "BGame.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "BSoundMgr.h" +#include "BSound.h" +#include "BSubFrame.h" +#include "ScScript.h" +#include "ScStack.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + m_Delay = 0; + m_MoveX = m_MoveY = 0; + + m_Sound = NULL; + m_KillSound = false; + + m_EditorExpanded = false; + m_Keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete m_Sound; + m_Sound = NULL; + + int i; + + for (i = 0; i < m_Subframes.GetSize(); i++) delete m_Subframes[i]; + m_Subframes.RemoveAll(); + + for (i = 0; i < m_ApplyEvent.GetSize(); i++) { + SAFE_DELETE_ARRAY(m_ApplyEvent[i]); + } + m_ApplyEvent.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { + HRESULT res; + + for (int i = 0; i < m_Subframes.GetSize(); i++) { + res = m_Subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); + if (FAILED(res)) return res; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { + if (m_Sound && !Muted) { + if (Owner) Owner->UpdateOneSound(m_Sound); + m_Sound->Play(); + /* + if(Game->m_State==GAME_FROZEN) + { + m_Sound->Pause(true); + } + */ + } + if (Owner) { + for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { + Owner->ApplyEvent(m_ApplyEvent[i]); + } + } + return S_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + RECT rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int HotspotX = 0, HotspotY = 0; + bool custom_trans = false; + bool editor_selected = false; + bool Is2DOnly = false; + bool Is3DOnly = false; + bool Decoration = false; + bool MirrorX = false; + bool MirrorY = false; + CBPlatform::SetRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.ScanStr(params, "%d", &m_Delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custom_trans = true; + break; + + case TOKEN_RECT: + parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.ScanStr(params, "%d,%d", &HotspotX, &HotspotY); + break; + + case TOKEN_MOVE: + parser.ScanStr(params, "%d,%d", &m_MoveX, &m_MoveY); + break; + + case TOKEN_2D_ONLY: + parser.ScanStr(params, "%b", &Is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.ScanStr(params, "%b", &Is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.ScanStr(params, "%b", &MirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.ScanStr(params, "%b", &MirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr(params, "%b", &editor_selected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.ScanStr(params, "%b", &m_EditorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.ScanStr(params, "%b", &m_KillSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(Game); + if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else m_Subframes.Add(subframe); + } + break; + + case TOKEN_SOUND: { + if (m_Sound) { + delete m_Sound; + m_Sound = NULL; + } + m_Sound = new CBSound(Game); + if (!m_Sound || FAILED(m_Sound->SetSound(params, SOUND_SFX, false))) { + if (Game->m_SoundMgr->m_SoundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); + delete m_Sound; + m_Sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + m_ApplyEvent.Add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.ScanStr(params, "%b", &m_Keyframe); + break; + + case TOKEN_DECORATION: + parser.ScanStr(params, "%b", &Decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in FRAME definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading FRAME definition"); + return E_FAIL; + } + + + CBSubFrame *sub = new CBSubFrame(Game); + if (surface_file != NULL) { + if (custom_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else sub->SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + + if (!sub->m_Surface) { + delete sub; + Game->LOG(0, "Error loading SUBFRAME"); + return E_FAIL; + } + + sub->m_Alpha = DRGBA(ar, ag, ab, alpha); + if (custom_trans) sub->m_Transparent = DRGBA(r, g, b, 0xFF); + } + + if (CBPlatform::IsRectEmpty(&rect)) sub->SetDefaultRect(); + else sub->m_Rect = rect; + + sub->m_HotspotX = HotspotX; + sub->m_HotspotY = HotspotY; + sub->m_2DOnly = Is2DOnly; + sub->m_3DOnly = Is3DOnly; + sub->m_Decoration = Decoration; + sub->m_MirrorX = MirrorX; + sub->m_MirrorY = MirrorY; + + + sub->m_EditorSelected = editor_selected; + m_Subframes.InsertAt(0, sub); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + CBPlatform::SetRectEmpty(Rect); + + RECT SubRect; + + for (int i = 0; i < m_Subframes.GetSize(); i++) { + m_Subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); + CBPlatform::UnionRect(Rect, Rect, &SubRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "FRAME {\n"); + Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", m_Delay); + + if (m_MoveX != 0 || m_MoveY != 0) + Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", m_MoveX, m_MoveY); + + if (m_Sound && m_Sound->m_SoundFilename) + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", m_Sound->m_SoundFilename); + + Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", m_Keyframe ? "TRUE" : "FALSE"); + + if (m_KillSound) + Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", m_KillSound ? "TRUE" : "FALSE"); + + if (m_EditorExpanded) + Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", m_EditorExpanded ? "TRUE" : "FALSE"); + + if (m_Subframes.GetSize() > 0) m_Subframes[0]->SaveAsText(Buffer, Indent, false); + + int i; + for (i = 1; i < m_Subframes.GetSize(); i++) { + m_Subframes[i]->SaveAsText(Buffer, Indent + 2); + } + + for (i = 0; i < m_ApplyEvent.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", m_ApplyEvent[i]); + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + m_ApplyEvent.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_Delay)); + PersistMgr->Transfer(TMEMBER(m_EditorExpanded)); + PersistMgr->Transfer(TMEMBER(m_Keyframe)); + PersistMgr->Transfer(TMEMBER(m_KillSound)); + PersistMgr->Transfer(TMEMBER(m_MoveX)); + PersistMgr->Transfer(TMEMBER(m_MoveY)); + PersistMgr->Transfer(TMEMBER(m_Sound)); + m_Subframes.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetSound") == 0) { + Stack->CorrectParams(0); + + if (m_Sound && m_Sound->m_SoundFilename) Stack->PushString(m_Sound->m_SoundFilename); + else Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSound") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + delete m_Sound; + m_Sound = NULL; + + if (!Val->IsNULL()) { + m_Sound = new CBSound(Game); + if (!m_Sound || FAILED(m_Sound->SetSound(Val->GetString(), SOUND_SFX, false))) { + Stack->PushBool(false); + delete m_Sound; + m_Sound = NULL; + } else Stack->PushBool(true); + } else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetSubframe") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= m_Subframes.GetSize()) { + Script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushNative(m_Subframes[Index], true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteSubframe") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (Val->IsInt()) { + int Index = Val->GetInt(-1); + if (Index < 0 || Index >= m_Subframes.GetSize()) { + Script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); + } + } else { + CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); + for (int i = 0; i < m_Subframes.GetSize(); i++) { + if (m_Subframes[i] == Sub) { + delete m_Subframes[i]; + m_Subframes.RemoveAt(i); + break; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSubframe") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBSubFrame *Sub = new CBSubFrame(Game); + if (Filename != NULL) { + Sub->SetSurface(Filename); + Sub->SetDefaultRect(); + } + m_Subframes.Add(Sub); + + Stack->PushNative(Sub, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertSubframe") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + if (Index < 0) Index = 0; + + CScValue *Val = Stack->Pop(); + char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBSubFrame *Sub = new CBSubFrame(Game); + if (Filename != NULL) { + Sub->SetSurface(Filename); + } + + if (Index >= m_Subframes.GetSize()) m_Subframes.Add(Sub); + else m_Subframes.InsertAt(Index, Sub); + + Stack->PushNative(Sub, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSubframe") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= m_ApplyEvent.GetSize()) { + Script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushString(m_ApplyEvent[Index]); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddEvent") == 0) { + Stack->CorrectParams(1); + char *Event = Stack->Pop()->GetString(); + for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { + if (scumm_stricmp(m_ApplyEvent[i], Event) == 0) { + Stack->PushNULL(); + return S_OK; + } + } + m_ApplyEvent.Add(Event); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteEvent") == 0) { + Stack->CorrectParams(1); + char *Event = Stack->Pop()->GetString(); + for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { + if (scumm_stricmp(m_ApplyEvent[i], Event) == 0) { + delete [] m_ApplyEvent[i]; + m_ApplyEvent.RemoveAt(i); + break; + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::ScGetProperty(char *Name) { + if (!m_ScValue) m_ScValue = new CScValue(Game); + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("frame"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Delay") == 0) { + m_ScValue->SetInt(m_Delay); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyframe") == 0) { + m_ScValue->SetBool(m_Keyframe); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KillSounds") == 0) { + m_ScValue->SetBool(m_KillSound); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveX") == 0) { + m_ScValue->SetInt(m_MoveX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveY") == 0) { + m_ScValue->SetInt(m_MoveY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumSubframes") == 0) { + m_ScValue->SetInt(m_Subframes.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumEvents") == 0) { + m_ScValue->SetInt(m_ApplyEvent.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScGetProperty(Name); + else return CBScriptable::ScGetProperty(Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Delay") == 0) { + m_Delay = std::max(0, Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyframe") == 0) { + m_Keyframe = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KillSounds") == 0) { + m_KillSound = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveX") == 0) { + m_MoveX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveY") == 0) { + m_MoveY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScSetProperty(Name, Value); + else return CBScriptable::ScSetProperty(Name, Value); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBFrame::ScToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h new file mode 100644 index 0000000000..9538305dd6 --- /dev/null +++ b/engines/wintermute/BFrame.h @@ -0,0 +1,73 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "BScriptable.h" +#include "coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool m_KillSound; + bool m_Keyframe; + HRESULT OneTimeDisplay(CBObject *Owner, bool Muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *m_Sound; + bool m_EditorExpanded; + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + int m_MoveY; + int m_MoveX; + uint32 m_Delay; + CBArray m_Subframes; + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray m_ApplyEvent; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp new file mode 100644 index 0000000000..2c58641c33 --- /dev/null +++ b/engines/wintermute/BGame.cpp @@ -0,0 +1,4462 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BGame.h" +#include "BFile.h" +#include "BRegistry.h" +#include "BRenderSDL.h" +#include "BSurfaceSDL.h" +#include "BQuickMsg.h" +#include "scriptables/SXString.h" +#include "scriptables/SXDate.h" +#include "scriptables/SXArray.h" +#include "SxObject.h" +#include "scriptables/SXMemBuffer.h" +#include "SXFile.h" +#include "SXMath.h" +#include "SXStore.h" +#include "PathUtil.h" +#include +#include "crc.h" +#include "StringUtil.h" +#include "BParser.h" +#include "BImage.h" +#include "BTransitionMgr.h" +#include "BKeyboardState.h" +#include "UIWindow.h" +#include "ScValue.h" +#include "BSoundMgr.h" +#include "BSound.h" +#include "BSubFrame.h" +#include "BViewport.h" +#include "BFontStorage.h" +#include "BFontTT.h" +#include "ScEngine.h" +#include "BStringTable.h" +#include "ScScript.h" +#include "BRegion.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "ScStack.h" +#include "common/textconsole.h" + +#ifdef __IPHONEOS__ +# include "ios_utils.h" +#endif + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + m_ShuttingDown = false; + + m_State = GAME_RUNNING; + m_OrigState = GAME_RUNNING; + m_FreezeLevel = 0; + + m_Interactive = true; + m_OrigInteractive = false; + + m_SurfaceStorage = NULL; + m_FontStorage = NULL; + m_Renderer = NULL; + m_SoundMgr = NULL; + m_FileManager = NULL; + m_TransMgr = NULL; + m_DebugMgr = NULL; + m_ScEngine = NULL; + m_KeyboardState = NULL; + + m_MathClass = NULL; + + m_DEBUG_LogFile = NULL; + m_DEBUG_DebugMode = false; + m_DEBUG_AbsolutePathWarning = true; + m_DEBUG_ShowFPS = false; + + m_SystemFont = NULL; + m_VideoFont = NULL; + + m_MainObject = NULL; + m_ActiveObject = NULL; + + m_Fader = NULL; + + m_OffsetX = m_OffsetY = 0; + m_OffsetPercentX = m_OffsetPercentY = 0.0f; + + m_Subtitles = true; + m_VideoSubtitles = true; + + m_Timer = 0; + m_TimerDelta = 0; + m_TimerLast = 0; + + m_LiveTimer = 0; + m_LiveTimerDelta = 0; + m_LiveTimerLast = 0; + + m_Sequence = 0; + + m_MousePos.x = m_MousePos.y = 0; + m_MouseLeftDown = m_MouseRightDown = m_MouseMidlleDown = false; + m_CapturedObject = NULL; + + // FPS counters + m_LastTime = m_FpsTime = m_DeltaTime = m_FramesRendered = m_Fps = 0; + + m_CursorNoninteractive = NULL; + + m_UseD3D = false; + + srand((unsigned)time(NULL)); + + m_Registry = new CBRegistry(this); + m_StringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + m_Music[i] = NULL; + m_MusicStartTime[i] = 0; + } + + m_SettingsResWidth = 800; + m_SettingsResHeight = 600; + m_SettingsRequireAcceleration = false; + m_SettingsRequireSound = false; + m_SettingsTLMode = 0; + m_SettingsAllowWindowed = true; + m_SettingsGameFile = NULL; + m_SettingsAllowAdvanced = false; + m_SettingsAllowAccessTab = true; + m_SettingsAllowAboutTab = true; + m_SettingsAllowDesktopRes = false; + + m_EditorForceScripts = false; + m_EditorAlwaysRegister = false; + + m_FocusedWindow = NULL; + + m_LoadInProgress = false; + + m_Quitting = false; + m_Loading = false; + m_ScheduledLoadSlot = -1; + + m_PersonalizedSave = false; + m_CompressedSavegames = true; + + m_EditorMode = false; + m_DoNotExpandStrings = false; + + m_EngineLogCallback = NULL; + m_EngineLogCallbackData = NULL; + + m_SmartCache = false; + m_SurfaceGCCycleTime = 10000; + + m_ReportTextureFormat = false; + + m_ViewportSP = -1; + + m_SubtitlesSpeed = 70; + + m_ResourceModule = NULL; + + m_ForceNonStreamedSounds = false; + + m_ThumbnailWidth = m_ThumbnailHeight = 0; + + m_IndicatorDisplay = false; + m_IndicatorColor = DRGBA(255, 0, 0, 128); + m_IndicatorProgress = 0; + m_IndicatorX = -1; + m_IndicatorY = -1; + m_IndicatorWidth = -1; + m_IndicatorHeight = 8; + m_RichSavedGames = false; + m_SavedGameExt = NULL; + CBUtils::SetString(&m_SavedGameExt, "dsv"); + + m_MusicCrossfadeRunning = false; + m_MusicCrossfadeStartTime = 0; + m_MusicCrossfadeLength = 0; + m_MusicCrossfadeChannel1 = -1; + m_MusicCrossfadeChannel2 = -1; + m_MusicCrossfadeSwap = false; + + m_LoadImageName = NULL; + m_SaveImageName = NULL; + m_SaveLoadImage = NULL; + + m_SaveImageX = m_SaveImageY = 0; + m_LoadImageX = m_LoadImageY = 0; + + m_LocalSaveDir = NULL; + CBUtils::SetString(&m_LocalSaveDir, "saves"); + m_SaveDirChecked = false; + + m_LoadingIcon = NULL; + m_LoadingIconX = m_LoadingIconY = 0; + m_LoadingIconPersistent = false; + + m_TextEncoding = TEXT_ANSI; + m_TextRTL = false; + + m_SoundBufferSizeSec = 3; + m_SuspendedRendering = false; + + m_LastCursor = NULL; + + + CBPlatform::SetRectEmpty(&m_MouseLockRect); + + m_SuppressScriptErrors = false; + m_LastMiniUpdate = 0; + m_MiniUpdateEnabled = false; + + m_CachedThumbnail = NULL; + + m_AutorunDisabled = false; + + // compatibility bits + m_CompatKillMethodThreads = false; + + m_UsedMem = 0; + + + m_AutoSaveOnExit = true; + m_AutoSaveSlot = 999; + m_CursorHidden = false; + +#ifdef __IPHONEOS__ + m_TouchInterface = true; + m_ConstrainedMemory = true; // TODO differentiate old and new iOS devices +#else + m_TouchInterface = false; + m_ConstrainedMemory = false; +#endif + + m_Store = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + m_ShuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + GetDebugMgr()->OnGameShutdown(); + + m_Registry->WriteBool("System", "LastRun", true); + + Cleanup(); + + delete[] m_LocalSaveDir; + delete[] m_SettingsGameFile; + delete[] m_SavedGameExt; + + delete m_CachedThumbnail; + + delete m_SaveLoadImage; + delete m_MathClass; + + delete m_TransMgr; + delete m_ScEngine; + delete m_FontStorage; + delete m_SurfaceStorage; + delete m_SoundMgr; + delete m_DebugMgr; + //SAFE_DELETE(m_KeyboardState); + + delete m_Renderer; + delete m_FileManager; + delete m_Registry; + delete m_StringTable; + + m_LocalSaveDir = NULL; + m_SettingsGameFile = NULL; + m_SavedGameExt = NULL; + + m_CachedThumbnail = NULL; + + m_SaveLoadImage = NULL; + m_MathClass = NULL; + + m_TransMgr = NULL; + m_ScEngine = NULL; + m_FontStorage = NULL; + m_SurfaceStorage = NULL; + m_SoundMgr = NULL; + m_DebugMgr = NULL; + + m_Renderer = NULL; + m_FileManager = NULL; + m_Registry = NULL; + m_StringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::OutputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Cleanup() { + int i; + + delete m_LoadingIcon; + m_LoadingIcon = NULL; + + m_EngineLogCallback = NULL; + m_EngineLogCallbackData = NULL; + + for (i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete m_Music[i]; + m_Music[i] = NULL; + m_MusicStartTime[i] = 0; + } + + UnregisterObject(m_Store); + m_Store = NULL; + + UnregisterObject(m_Fader); + m_Fader = NULL; + + for (i = 0; i < m_RegObjects.GetSize(); i++) { + delete m_RegObjects[i]; + m_RegObjects[i] = NULL; + } + m_RegObjects.RemoveAll(); + + m_Windows.RemoveAll(); // refs only + m_FocusedWindow = NULL; // ref only + + delete[] m_SaveImageName; + delete[] m_LoadImageName; + m_SaveImageName = NULL; + m_LoadImageName = NULL; + + delete m_CursorNoninteractive; + delete m_Cursor; + delete m_ActiveCursor; + m_CursorNoninteractive = NULL; + m_Cursor = NULL; + m_ActiveCursor = NULL; + + delete m_ScValue; + delete m_SFX; + m_ScValue = NULL; + m_SFX = NULL; + + for (i = 0; i < m_Scripts.GetSize(); i++) { + m_Scripts[i]->m_Owner = NULL; + m_Scripts[i]->Finish(); + } + m_Scripts.RemoveAll(); + + m_FontStorage->RemoveFont(m_SystemFont); + m_SystemFont = NULL; + + m_FontStorage->RemoveFont(m_VideoFont); + m_VideoFont = NULL; + + for (i = 0; i < m_QuickMessages.GetSize(); i++) delete m_QuickMessages[i]; + m_QuickMessages.RemoveAll(); + + m_ViewportStack.RemoveAll(); + m_ViewportSP = -1; + + delete[] m_Name; + delete[] m_Filename; + m_Name = NULL; + m_Filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] m_Caption[i]; + m_Caption[i] = NULL; + } + + m_LastCursor = NULL; + + delete m_KeyboardState; + m_KeyboardState = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize1() { + m_SurfaceStorage = new CBSurfaceStorage(this); + if (m_SurfaceStorage == NULL) goto init_fail; + + m_FontStorage = new CBFontStorage(this); + if (m_FontStorage == NULL) goto init_fail; + + m_FileManager = new CBFileManager(this); + if (m_FileManager == NULL) goto init_fail; + + m_SoundMgr = new CBSoundMgr(this); + if (m_SoundMgr == NULL) goto init_fail; + + m_DebugMgr = new CBDebugger(this); + if (m_DebugMgr == NULL) goto init_fail; + + m_MathClass = new CSXMath(this); + if (m_MathClass == NULL) goto init_fail; + + m_ScEngine = new CScEngine(this); + if (m_ScEngine == NULL) goto init_fail; + + m_TransMgr = new CBTransitionMgr(this); + if (m_TransMgr == NULL) goto init_fail; + + m_KeyboardState = new CBKeyboardState(this); + if (m_KeyboardState == NULL) goto init_fail; + + m_Fader = new CBFader(this); + if (m_Fader == NULL) goto init_fail; + RegisterObject(m_Fader); + + m_Store = new CSXStore(this); + if (m_Store == NULL) goto init_fail; + RegisterObject(m_Store); + + return S_OK; + +init_fail: + if (m_MathClass) delete m_MathClass; + if (m_Store) delete m_Store; + if (m_KeyboardState) delete m_KeyboardState; + if (m_TransMgr) delete m_TransMgr; + if (m_DebugMgr) delete m_DebugMgr; + if (m_SurfaceStorage) delete m_SurfaceStorage; + if (m_FontStorage) delete m_FontStorage; + if (m_SoundMgr) delete m_SoundMgr; + if (m_FileManager) delete m_FileManager; + if (m_ScEngine) delete m_ScEngine; + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize2() { // we know whether we are going to be accelerated + m_Renderer = new CBRenderSDL(this); + if (m_Renderer == NULL) goto init_fail; + + return S_OK; + +init_fail: + if (m_Renderer) delete m_Renderer; + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize3() { // renderer is initialized + m_PosX = m_Renderer->m_Width / 2; + m_PosY = m_Renderer->m_Height / 2; + + if (m_IndicatorY == -1) m_IndicatorY = m_Renderer->m_Height - m_IndicatorHeight; + if (m_IndicatorX == -1) m_IndicatorX = 0; + if (m_IndicatorWidth == -1) m_IndicatorWidth = m_Renderer->m_Width; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *Filename) { + m_DEBUG_DebugMode = true; + +#ifndef __IPHONEOS__ + if (Filename)m_DEBUG_LogFile = fopen(Filename, "a+"); + else m_DEBUG_LogFile = fopen("./zz_debug.log", "a+"); + + if (!m_DEBUG_LogFile) { + AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); + m_DEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); + } + + if (m_DEBUG_LogFile != NULL) fprintf(m_DEBUG_LogFile, "\n"); +#endif + + time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::GetPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (m_DEBUG_LogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + fclose(m_DEBUG_LogFile); + m_DEBUG_LogFile = NULL; + } + m_DEBUG_DebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { +#ifndef __IPHONEOS__ + if (!m_DEBUG_DebugMode) return; +#endif + time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + +#ifdef __IPHONEOS__ + printf("%02d:%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, buff); + fflush(stdout); +#else + if (m_DEBUG_LogFile == NULL) return; + + // redirect to an engine's own callback + if (m_EngineLogCallback) { + m_EngineLogCallback(buff, res, m_EngineLogCallbackData); + } + if (m_DebugMgr) m_DebugMgr->OnLog(res, buff); + + warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fprintf(m_DEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fflush(m_DEBUG_LogFile); +#endif + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback, void *Data) { + m_EngineLogCallback = Callback; + m_EngineLogCallbackData = Data; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitLoop() { + m_ViewportSP = -1; + + m_CurrentTime = CBPlatform::GetTime(); + + GetDebugMgr()->OnGameTick(); + m_Renderer->InitLoop(); + m_SoundMgr->InitLoop(); + UpdateMusicCrossfade(); + + m_SurfaceStorage->InitLoop(); + m_FontStorage->InitLoop(); + + + //m_ActiveObject = NULL; + + // count FPS + m_DeltaTime = m_CurrentTime - m_LastTime; + m_LastTime = m_CurrentTime; + m_FpsTime += m_DeltaTime; + + m_LiveTimerDelta = m_LiveTimer - m_LiveTimerLast; + m_LiveTimerLast = m_LiveTimer; + m_LiveTimer += MIN(1000, m_DeltaTime); + + if (m_State != GAME_FROZEN) { + m_TimerDelta = m_Timer - m_TimerLast; + m_TimerLast = m_Timer; + m_Timer += MIN(1000, m_DeltaTime); + } else m_TimerDelta = 0; + + m_FramesRendered++; + if (m_FpsTime > 1000) { + m_Fps = m_FramesRendered; + m_FramesRendered = 0; + m_FpsTime = 0; + } + //Game->LOG(0, "%d", m_Fps); + + GetMousePos(&m_MousePos); + + m_FocusedWindow = NULL; + for (int i = m_Windows.GetSize() - 1; i >= 0; i--) { + if (m_Windows[i]->m_Visible) { + m_FocusedWindow = m_Windows[i]; + break; + } + } + + UpdateSounds(); + + if (m_Fader) m_Fader->Update(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitInput(HINSTANCE hInst, HWND hWnd) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::GetSequence() { + return ++m_Sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetOffset(int OffsetX, int OffsetY) { + m_OffsetX = OffsetX; + m_OffsetY = OffsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::GetOffset(int *OffsetX, int *OffsetY) { + if (OffsetX != NULL) *OffsetX = m_OffsetX; + if (OffsetY != NULL) *OffsetY = m_OffsetY; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadFile(const char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_GAME) { + Game->LOG(0, "'GAME' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (m_SystemFont) m_FontStorage->RemoveFont(m_SystemFont); + m_SystemFont = NULL; + + m_SystemFont = Game->m_FontStorage->AddFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (m_VideoFont) m_FontStorage->RemoveFont(m_VideoFont); + m_VideoFont = NULL; + + m_VideoFont = Game->m_FontStorage->AddFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete m_ActiveCursor; + m_ActiveCursor = NULL; + m_ActiveCursor = new CBSprite(Game); + if (!m_ActiveCursor || FAILED(m_ActiveCursor->LoadFile((char *)params))) { + delete m_ActiveCursor; + m_ActiveCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete m_CursorNoninteractive; + m_CursorNoninteractive = new CBSprite(Game); + if (!m_CursorNoninteractive || FAILED(m_CursorNoninteractive->LoadFile((char *)params))) { + delete m_CursorNoninteractive; + m_CursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.ScanStr((char *)params, "%b", &m_PersonalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.ScanStr((char *)params, "%b", &m_Subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.ScanStr((char *)params, "%d", &m_SubtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.ScanStr((char *)params, "%b", &m_VideoSubtitles); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.ScanStr((char *)params, "%d", &m_ThumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_ThumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.ScanStr((char *)params, "%d", &m_IndicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.ScanStr((char *)params, "%d", &m_IndicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.ScanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + m_IndicatorColor = DRGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.ScanStr((char *)params, "%d", &m_IndicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_IndicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::SetString(&m_SaveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.ScanStr((char *)params, "%d", &m_SaveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.ScanStr((char *)params, "%d", &m_SaveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::SetString(&m_LoadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.ScanStr((char *)params, "%d", &m_LoadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.ScanStr((char *)params, "%d", &m_LoadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::SetString(&m_LocalSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.ScanStr((char *)params, "%b", &m_CompatKillMethodThreads); + break; + } + } + + if (!m_SystemFont) m_SystemFont = Game->m_FontStorage->AddFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in GAME definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading GAME definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LOG") == 0) { + Stack->CorrectParams(1); + LOG(0, Stack->Pop()->GetString()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + HRESULT res = CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + SetWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Msg") == 0) { + Stack->CorrectParams(1); + QuickMessage(Stack->Pop()->GetString()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RunScript") == 0) { + Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + Stack->CorrectParams(1); + if (FAILED(AddScript(Stack->Pop()->GetString()))) + Stack->PushBool(false); + else + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadStringTable") == 0) { + Stack->CorrectParams(2); + char *Filename = Stack->Pop()->GetString(); + CScValue *Val = Stack->Pop(); + + bool ClearOld; + if (Val->IsNULL()) ClearOld = true; + else ClearOld = Val->GetBool(); + + if (FAILED(m_StringTable->LoadFile(Filename, ClearOld))) + Stack->PushBool(false); + else + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ValidObject") == 0) { + Stack->CorrectParams(1); + CBScriptable *obj = Stack->Pop()->GetNative(); + if (ValidObject((CBObject *) obj)) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + ResetContent(); + Stack->PushNULL(); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CBObject *obj = (CBObject *)val->GetNative(); + UnregisterObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadWindow") == 0) { + Stack->CorrectParams(1); + CUIWindow *win = new CUIWindow(Game); + if (win && SUCCEEDED(win->LoadFile(Stack->Pop()->GetString()))) { + m_Windows.Add(win); + RegisterObject(win); + Stack->PushNative(win, true); + } else { + delete win; + win = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExpandString") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + char *str = new char[strlen(val->GetString()) + 1]; + strcpy(str, val->GetString()); + m_StringTable->Expand(&str); + Stack->PushString(str); + delete [] str; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayMusic") == 0 || strcmp(Name, "PlayMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "PlayMusic") == 0) Stack->CorrectParams(3); + else { + Stack->CorrectParams(4); + Channel = Stack->Pop()->GetInt(); + } + + char *Filename = Stack->Pop()->GetString(); + CScValue *ValLooping = Stack->Pop(); + bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); + + CScValue *ValLoopStart = Stack->Pop(); + uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); + + + if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopMusic") == 0 || strcmp(Name, "StopMusicChannel") == 0) { + int Channel = 0; + + if (strcmp(Name, "StopMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(StopMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0 || strcmp(Name, "PauseMusicChannel") == 0) { + int Channel = 0; + + if (strcmp(Name, "PauseMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(PauseMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeMusic") == 0 || strcmp(Name, "ResumeMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "ResumeMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(ResumeMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusic") == 0 || strcmp(Name, "GetMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) Stack->PushNULL(); + else { + if (!m_Music[Channel] || !m_Music[Channel]->m_SoundFilename) Stack->PushNULL(); + else Stack->PushString(m_Music[Channel]->m_SoundFilename); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMusicPosition") == 0 || strcmp(Name, "SetMusicChannelPosition") == 0 || strcmp(Name, "SetMusicPositionChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "SetMusicPosition") == 0) Stack->CorrectParams(1); + else { + Stack->CorrectParams(2); + Channel = Stack->Pop()->GetInt(); + } + + uint32 Time = Stack->Pop()->GetInt(); + + if (FAILED(SetMusicStartTime(Channel, Time))) Stack->PushBool(false); + else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusicPosition") == 0 || strcmp(Name, "GetMusicChannelPosition") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusicPosition") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushInt(0); + else Stack->PushInt(m_Music[Channel]->GetPositionTime()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsMusicPlaying") == 0 || strcmp(Name, "IsMusicChannelPlaying") == 0) { + int Channel = 0; + if (strcmp(Name, "IsMusicPlaying") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushBool(false); + else Stack->PushBool(m_Music[Channel]->IsPlaying()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMusicVolume") == 0 || strcmp(Name, "SetMusicChannelVolume") == 0) { + int Channel = 0; + if (strcmp(Name, "SetMusicVolume") == 0) Stack->CorrectParams(1); + else { + Stack->CorrectParams(2); + Channel = Stack->Pop()->GetInt(); + } + + int Volume = Stack->Pop()->GetInt(); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushBool(false); + else { + if (FAILED(m_Music[Channel]->SetVolume(Volume))) Stack->PushBool(false); + else Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusicVolume") == 0 || strcmp(Name, "GetMusicChannelVolume") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusicVolume") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushInt(0); + else Stack->PushInt(m_Music[Channel]->GetVolume()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicCrossfade") == 0) { + Stack->CorrectParams(4); + int Channel1 = Stack->Pop()->GetInt(0); + int Channel2 = Stack->Pop()->GetInt(0); + uint32 FadeLength = (uint32)Stack->Pop()->GetInt(0); + bool Swap = Stack->Pop()->GetBool(true); + + if (m_MusicCrossfadeRunning) { + Script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + Stack->PushBool(false); + return S_OK; + } + + m_MusicCrossfadeStartTime = m_LiveTimer; + m_MusicCrossfadeChannel1 = Channel1; + m_MusicCrossfadeChannel2 = Channel2; + m_MusicCrossfadeLength = FadeLength; + m_MusicCrossfadeSwap = Swap; + + m_MusicCrossfadeRunning = true; + + Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundLength") == 0) { + Stack->CorrectParams(1); + + int Length = 0; + char *Filename = Stack->Pop()->GetString(); + + CBSound *Sound = new CBSound(Game); + if (Sound && SUCCEEDED(Sound->SetSound(Filename, SOUND_MUSIC, true))) { + Length = Sound->GetLength(); + delete Sound; + Sound = NULL; + } + Stack->PushInt(Length); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMousePos") == 0) { + Stack->CorrectParams(2); + int x = Stack->Pop()->GetInt(); + int y = Stack->Pop()->GetInt(); + x = std::max(x, 0); + x = std::min(x, m_Renderer->m_Width); + y = std::max(y, 0); + y = std::min(y, m_Renderer->m_Height); + POINT p; + p.x = x + m_Renderer->m_DrawOffsetX; + p.y = y + m_Renderer->m_DrawOffsetY; + + CBPlatform::SetCursorPos(p.x, p.y); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LockMouseRect") == 0) { + Stack->CorrectParams(4); + int left = Stack->Pop()->GetInt(); + int top = Stack->Pop()->GetInt(); + int right = Stack->Pop()->GetInt(); + int bottom = Stack->Pop()->GetInt(); + + if (right < left) CBUtils::Swap(&left, &right); + if (bottom < top) CBUtils::Swap(&top, &bottom); + + CBPlatform::SetRect(&m_MouseLockRect, left, top, right, bottom); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayVideo") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "QuitGame") == 0) { + Stack->CorrectParams(0); + Stack->PushNULL(); + m_Quitting = true; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegWriteNumber") == 0) { + Stack->CorrectParams(2); + char *Key = Stack->Pop()->GetString(); + int Val = Stack->Pop()->GetInt(); + m_Registry->WriteInt("PrivateSettings", Key, Val); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegReadNumber") == 0) { + Stack->CorrectParams(2); + char *Key = Stack->Pop()->GetString(); + int InitVal = Stack->Pop()->GetInt(); + Stack->PushInt(m_Registry->ReadInt("PrivateSettings", Key, InitVal)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegWriteString") == 0) { + Stack->CorrectParams(2); + char *Key = Stack->Pop()->GetString(); + char *Val = Stack->Pop()->GetString(); + m_Registry->WriteString("PrivateSettings", Key, Val); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegReadString") == 0) { + Stack->CorrectParams(2); + char *Key = Stack->Pop()->GetString(); + char *InitVal = Stack->Pop()->GetString(); + AnsiString val = m_Registry->ReadString("PrivateSettings", Key, InitVal); + Stack->PushString((char *)val.c_str()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveGame") == 0) { + Stack->CorrectParams(3); + int Slot = Stack->Pop()->GetInt(); + char *xdesc = Stack->Pop()->GetString(); + bool quick = Stack->Pop()->GetBool(false); + + char *Desc = new char[strlen(xdesc) + 1]; + strcpy(Desc, xdesc); + Stack->PushBool(true); + if (FAILED(SaveGame(Slot, Desc, quick))) { + Stack->Pop(); + Stack->PushBool(false); + } + delete [] Desc; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadGame") == 0) { + Stack->CorrectParams(1); + m_ScheduledLoadSlot = Stack->Pop()->GetInt(); + m_Loading = true; + Stack->PushBool(false); + Script->Sleep(0); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsSaveSlotUsed") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + Stack->PushBool(IsSaveSlotUsed(Slot)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSaveSlotDescription") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + char Desc[512]; + Desc[0] = '\0'; + GetSaveSlotDescription(Slot, Desc); + Stack->PushString(Desc); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmptySaveSlot") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + EmptySaveSlot(Slot); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { + Stack->CorrectParams(1); + Game->m_SoundMgr->SetVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { + Stack->CorrectParams(1); + Game->m_SoundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { + Stack->CorrectParams(1); + Game->m_SoundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { + Stack->CorrectParams(1); + Game->m_SoundMgr->SetMasterVolumePercent((byte )Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_SFX)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_SPEECH)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_MUSIC)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_SoundMgr->GetMasterVolumePercent()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetActiveCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetActiveCursor") == 0) { + Stack->CorrectParams(0); + if (!m_ActiveCursor || !m_ActiveCursor->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ActiveCursor->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetActiveCursorObject") == 0) { + Stack->CorrectParams(0); + if (!m_ActiveCursor) Stack->PushNULL(); + else Stack->PushNative(m_ActiveCursor, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveActiveCursor") == 0) { + Stack->CorrectParams(0); + delete m_ActiveCursor; + m_ActiveCursor = NULL; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasActiveCursor") == 0) { + Stack->CorrectParams(0); + + if (m_ActiveCursor) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FileExists") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + + CBFile *File = m_FileManager->OpenFile(Filename, false); + if (!File) Stack->PushBool(false); + else { + m_FileManager->CloseFile(File); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0 || strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); + + m_Fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(m_Fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0 || strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); + + m_Fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(m_Fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFadeColor") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_Fader->GetCurrentColor()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Screenshot") == 0) { + Stack->CorrectParams(1); + char Filename[MAX_PATH]; + + CScValue *Val = Stack->Pop(); + + int FileNum = 0; + while (true) { + sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? m_Name : Val->GetString(), FileNum); + FILE *f = fopen(Filename, "rb"); + if (!f) break; + else fclose(f); + FileNum++; + } + + bool ret = false; + CBImage *Image = Game->m_Renderer->TakeScreenshot(); + if (Image) { + ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + delete Image; + } else ret = false; + + Stack->PushBool(ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenshotEx") == 0) { + Stack->CorrectParams(3); + char *Filename = Stack->Pop()->GetString(); + int SizeX = Stack->Pop()->GetInt(m_Renderer->m_Width); + int SizeY = Stack->Pop()->GetInt(m_Renderer->m_Height); + + bool ret = false; + CBImage *Image = Game->m_Renderer->TakeScreenshot(); + if (Image) { + ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); + if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + delete Image; + } else ret = false; + + Stack->PushBool(ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateWindow") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIWindow *Win = new CUIWindow(Game); + m_Windows.Add(Win); + RegisterObject(Win); + if (!Val->IsNULL()) Win->SetName(Val->GetString()); + Stack->PushNative(Win, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteWindow") == 0) { + Stack->CorrectParams(1); + CBObject *Obj = (CBObject *)Stack->Pop()->GetNative(); + for (int i = 0; i < m_Windows.GetSize(); i++) { + if (m_Windows[i] == Obj) { + UnregisterObject(m_Windows[i]); + Stack->PushBool(true); + return S_OK; + } + } + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OpenDocument") == 0) { +#ifdef __WIN32__ + Stack->CorrectParams(1); + if (!m_Renderer->m_Windowed) CBPlatform::ShowWindow(m_Renderer->m_Window, SW_MINIMIZE); + HINSTANCE i = CBPlatform::ShellExecute(m_Renderer->m_Window, "open", Stack->Pop()->GetString(), NULL, NULL, SW_MAXIMIZE); + Stack->PushBool((int)i > 32); +#else + Stack->CorrectParams(0); + Stack->PushNULL(); +#endif + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DEBUG_DumpClassRegistry") == 0) { + Stack->CorrectParams(0); + DEBUG_DumpClassRegistry(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetLoadingScreen") == 0) { + Stack->CorrectParams(3); + CScValue *Val = Stack->Pop(); + m_LoadImageX = Stack->Pop()->GetInt(); + m_LoadImageY = Stack->Pop()->GetInt(); + + if (Val->IsNULL()) { + delete[] m_LoadImageName; + m_LoadImageName = NULL; + } else { + CBUtils::SetString(&m_LoadImageName, Val->GetString()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSavingScreen") == 0) { + Stack->CorrectParams(3); + CScValue *Val = Stack->Pop(); + m_SaveImageX = Stack->Pop()->GetInt(); + m_SaveImageY = Stack->Pop()->GetInt(); + + if (Val->IsNULL()) { + delete[] m_SaveImageName; + m_SaveImageName = NULL; + } else { + CBUtils::SetString(&m_SaveImageName, Val->GetString()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetWaitCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetWaitCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveWaitCursor") == 0) { + Stack->CorrectParams(0); + delete m_CursorNoninteractive; + m_CursorNoninteractive = NULL; + + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaitCursor") == 0) { + Stack->CorrectParams(0); + if (!m_CursorNoninteractive || !m_CursorNoninteractive->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_CursorNoninteractive->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaitCursorObject") == 0) { + Stack->CorrectParams(0); + if (!m_CursorNoninteractive) Stack->PushNULL(); + else Stack->PushNative(m_CursorNoninteractive, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClearScriptCache") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(SUCCEEDED(m_ScEngine->EmptyScriptCache())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayLoadingIcon") == 0) { + Stack->CorrectParams(4); + + char *Filename = Stack->Pop()->GetString(); + m_LoadingIconX = Stack->Pop()->GetInt(); + m_LoadingIconY = Stack->Pop()->GetInt(); + m_LoadingIconPersistent = Stack->Pop()->GetBool(); + + delete m_LoadingIcon; + m_LoadingIcon = new CBSprite(this); + if (!m_LoadingIcon || FAILED(m_LoadingIcon->LoadFile(Filename))) { + delete m_LoadingIcon; + m_LoadingIcon = NULL; + } else { + DisplayContent(false, true); + Game->m_Renderer->Flip(); + Game->m_Renderer->InitLoop(); + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HideLoadingIcon") == 0) { + Stack->CorrectParams(0); + delete m_LoadingIcon; + m_LoadingIcon = NULL; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DumpTextureStats") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + + m_Renderer->DumpData(Filename); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccOutputText") == 0) { + Stack->CorrectParams(2); + char *Str = Stack->Pop()->GetString(); + int Type = Stack->Pop()->GetInt(); + // do nothing + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StoreSaveThumbnail") == 0) { + Stack->CorrectParams(0); + delete m_CachedThumbnail; + m_CachedThumbnail = new CBSaveThumbHelper(this); + if (FAILED(m_CachedThumbnail->StoreThumbnail())) { + delete m_CachedThumbnail; + m_CachedThumbnail = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteSaveThumbnail") == 0) { + Stack->CorrectParams(0); + delete m_CachedThumbnail; + m_CachedThumbnail = NULL; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFileChecksum") == 0) { + Stack->CorrectParams(2); + char *Filename = Stack->Pop()->GetString(); + bool AsHex = Stack->Pop()->GetBool(false); + + CBFile *File = m_FileManager->OpenFile(Filename, false); + if (File) { + crc remainder = crc_initialize(); + byte Buf[1024]; + int BytesRead = 0; + + while (BytesRead < File->GetSize()) { + int BufSize = MIN(1024, File->GetSize() - BytesRead); + BytesRead += BufSize; + + File->Read(Buf, BufSize); + for (int i = 0; i < BufSize; i++) { + remainder = crc_process_byte(Buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (AsHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + Stack->PushString(Hex); + } else + Stack->PushInt(checksum); + + m_FileManager->CloseFile(File); + File = NULL; + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EnableScriptProfiling") == 0) { + Stack->CorrectParams(0); + m_ScEngine->EnableProfiling(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisableScriptProfiling") == 0) { + Stack->CorrectParams(0); + m_ScEngine->DisableProfiling(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ShowStatusLine") == 0) { + Stack->CorrectParams(0); +#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HideStatusLine") == 0) { + Stack->CorrectParams(0); +#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif + Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("game"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Hwnd") == 0) { + m_ScValue->SetInt((int)m_Renderer->m_Window); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CurrentTime") == 0) { + m_ScValue->SetInt((int)m_Timer); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WindowsTime") == 0) { + m_ScValue->SetInt((int)CBPlatform::GetTime()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WindowedMode") == 0) { + m_ScValue->SetBool(m_Renderer->m_Windowed); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + m_ScValue->SetInt(m_MousePos.x); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + m_ScValue->SetInt(m_MousePos.y); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainObject") == 0) { + m_ScValue->SetNative(m_MainObject, true); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ActiveObject") == 0) { + m_ScValue->SetNative(m_ActiveObject, true); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenWidth") == 0) { + m_ScValue->SetInt(m_Renderer->m_Width); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenHeight") == 0) { + m_ScValue->SetInt(m_Renderer->m_Height); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Interactive") == 0) { + m_ScValue->SetBool(m_Interactive); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DebugMode") == 0) { + m_ScValue->SetBool(m_DEBUG_DebugMode); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundAvailable") == 0) { + m_ScValue->SetBool(m_SoundMgr->m_SoundAvailable); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SFXVolume") == 0) { + Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_SFX)); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SpeechVolume") == 0) { + Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_SPEECH)); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicVolume") == 0) { + Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_MUSIC)); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MasterVolume") == 0) { + Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + m_ScValue->SetInt(m_SoundMgr->GetMasterVolumePercent()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyboard") == 0) { + if (m_KeyboardState) m_ScValue->SetNative(m_KeyboardState, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtitles") == 0) { + m_ScValue->SetBool(m_Subtitles); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesSpeed") == 0) { + m_ScValue->SetInt(m_SubtitlesSpeed); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VideoSubtitles") == 0) { + m_ScValue->SetBool(m_VideoSubtitles); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FPS") == 0) { + m_ScValue->SetInt(m_Fps); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AcceleratedMode") == 0 || strcmp(Name, "Accelerated") == 0) { + m_ScValue->SetBool(m_UseD3D); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextEncoding") == 0) { + m_ScValue->SetInt(m_TextEncoding); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextRTL") == 0) { + m_ScValue->SetBool(m_TextRTL); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundBufferSize") == 0) { + m_ScValue->SetInt(m_SoundBufferSizeSec); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuspendedRendering") == 0) { + m_ScValue->SetBool(m_SuspendedRendering); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuppressScriptErrors") == 0) { + m_ScValue->SetBool(m_SuppressScriptErrors); + return m_ScValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Frozen") == 0) { + m_ScValue->SetBool(m_State == GAME_FROZEN); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSEnabled") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSTalk") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSCaptions") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSKeypress") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardEnabled") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardCursorSkip") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardPause") == 0) { + m_ScValue->SetBool(false); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutorunDisabled") == 0) { + m_ScValue->SetBool(m_AutorunDisabled); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveDirectory") == 0) { + AnsiString dataDir = GetDataDir(); + m_ScValue->SetString((char *)dataDir.c_str()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveOnExit") == 0) { + m_ScValue->SetBool(m_AutoSaveOnExit); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveSlot") == 0) { + m_ScValue->SetInt(m_AutoSaveSlot); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorHidden") == 0) { + m_ScValue->SetBool(m_CursorHidden); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Platform") == 0) { + m_ScValue->SetString(CBPlatform::GetPlatformName().c_str()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeviceType") == 0) { + m_ScValue->SetString(GetDeviceType().c_str()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MostRecentSaveSlot") == 0) { + m_ScValue->SetInt(m_Registry->ReadInt("System", "MostRecentSaveSlot", -1)); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Store") == 0) { + if (m_Store) m_ScValue->SetNative(m_Store, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + m_MousePos.x = Value->GetInt(); + ResetMousePos(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + m_MousePos.y = Value->GetInt(); + ResetMousePos(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + HRESULT res = CBObject::ScSetProperty(Name, Value); + SetWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainObject") == 0) { + CBScriptable *obj = Value->GetNative(); + if (obj == NULL || ValidObject((CBObject *)obj)) m_MainObject = (CBObject *)obj; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Interactive") == 0) { + SetInteractive(Value->GetBool()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SFXVolume") == 0) { + Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + Game->m_SoundMgr->SetVolumePercent(SOUND_SFX, (byte )Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SpeechVolume") == 0) { + Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + Game->m_SoundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicVolume") == 0) { + Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + Game->m_SoundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MasterVolume") == 0) { + Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + Game->m_SoundMgr->SetMasterVolumePercent((byte )Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtitles") == 0) { + m_Subtitles = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesSpeed") == 0) { + m_SubtitlesSpeed = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VideoSubtitles") == 0) { + m_VideoSubtitles = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextEncoding") == 0) { + int Enc = Value->GetInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + m_TextEncoding = (TTextEncoding)Enc; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextRTL") == 0) { + m_TextRTL = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundBufferSize") == 0) { + m_SoundBufferSizeSec = Value->GetInt(); + m_SoundBufferSizeSec = std::max(3, m_SoundBufferSizeSec); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuspendedRendering") == 0) { + m_SuspendedRendering = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuppressScriptErrors") == 0) { + m_SuppressScriptErrors = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutorunDisabled") == 0) { + m_AutorunDisabled = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveOnExit") == 0) { + m_AutoSaveOnExit = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveSlot") == 0) { + m_AutoSaveSlot = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorHidden") == 0) { + m_CursorHidden = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBGame::ScToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayQuickMsg() { + if (m_QuickMessages.GetSize() == 0 || !m_SystemFont) return S_OK; + + int i; + + // update + for (i = 0; i < m_QuickMessages.GetSize(); i++) { + if (m_CurrentTime - m_QuickMessages[i]->m_StartTime >= QUICK_MSG_DURATION) { + delete m_QuickMessages[i]; + m_QuickMessages.RemoveAt(i); + i--; + } + } + + int PosY = 20; + + // display + for (i = 0; i < m_QuickMessages.GetSize(); i++) { + m_SystemFont->DrawText((byte *)m_QuickMessages[i]->GetText(), 0, PosY, m_Renderer->m_Width); + PosY += m_SystemFont->GetTextHeight((byte *)m_QuickMessages[i]->GetText(), m_Renderer->m_Width); + } + return S_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::QuickMessage(char *Text) { + if (m_QuickMessages.GetSize() >= MAX_QUICK_MSG) { + delete m_QuickMessages[0]; + m_QuickMessages.RemoveAt(0); + } + m_QuickMessages.Add(new CBQuickMsg(Game, Text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::QuickMessageForm(LPSTR fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::RegisterObject(CBObject *Object) { + m_RegObjects.Add(Object); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::UnregisterObject(CBObject *Object) { + if (!Object) return S_OK; + + int i; + + // is it a window? + for (i = 0; i < m_Windows.GetSize(); i++) { + if ((CBObject *)m_Windows[i] == Object) { + m_Windows.RemoveAt(i); + + // get new focused window + if (m_FocusedWindow == Object) m_FocusedWindow = NULL; + + break; + } + } + + // is it active object? + if (m_ActiveObject == Object) m_ActiveObject = NULL; + + // is it main object? + if (m_MainObject == Object) m_MainObject = NULL; + + if (m_Store) m_Store->OnObjectDestroyed(Object); + + // destroy object + for (i = 0; i < m_RegObjects.GetSize(); i++) { + if (m_RegObjects[i] == Object) { + m_RegObjects.RemoveAt(i); + if (!m_LoadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); + delete Object; + return S_OK; + } + } + + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::InvalidateValues(void *Value, void *Data) { + CScValue *val = (CScValue *)Value; + if (val->IsNative() && val->GetNative() == Data) { + if (!val->m_Persistent && ((CBScriptable *)Data)->m_RefCount == 1) { + ((CBScriptable *)Data)->m_RefCount++; + } + val->SetNative(NULL); + val->SetNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ValidObject(CBObject *Object) { + if (!Object) return false; + if (Object == this) return true; + + for (int i = 0; i < m_RegObjects.GetSize(); i++) { + if (m_RegObjects[i] == Object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::PublishNatives() { + if (!m_ScEngine || !m_ScEngine->m_CompilerAvailable) return; + + m_ScEngine->ExtDefineFunction("LOG"); + m_ScEngine->ExtDefineFunction("String"); + m_ScEngine->ExtDefineFunction("MemBuffer"); + m_ScEngine->ExtDefineFunction("File"); + m_ScEngine->ExtDefineFunction("Date"); + m_ScEngine->ExtDefineFunction("Array"); + m_ScEngine->ExtDefineFunction("TcpClient"); + m_ScEngine->ExtDefineFunction("Object"); + //m_ScEngine->ExtDefineFunction("Game"); + m_ScEngine->ExtDefineFunction("Sleep"); + m_ScEngine->ExtDefineFunction("WaitFor"); + m_ScEngine->ExtDefineFunction("Random"); + m_ScEngine->ExtDefineFunction("SetScriptTimeSlice"); + m_ScEngine->ExtDefineFunction("MakeRGBA"); + m_ScEngine->ExtDefineFunction("MakeRGB"); + m_ScEngine->ExtDefineFunction("MakeHSL"); + m_ScEngine->ExtDefineFunction("RGB"); + m_ScEngine->ExtDefineFunction("GetRValue"); + m_ScEngine->ExtDefineFunction("GetGValue"); + m_ScEngine->ExtDefineFunction("GetBValue"); + m_ScEngine->ExtDefineFunction("GetAValue"); + m_ScEngine->ExtDefineFunction("GetHValue"); + m_ScEngine->ExtDefineFunction("GetSValue"); + m_ScEngine->ExtDefineFunction("GetLValue"); + m_ScEngine->ExtDefineFunction("Debug"); + + m_ScEngine->ExtDefineFunction("ToString"); + m_ScEngine->ExtDefineFunction("ToInt"); + m_ScEngine->ExtDefineFunction("ToBool"); + m_ScEngine->ExtDefineFunction("ToFloat"); + + m_ScEngine->ExtDefineVariable("Game"); + m_ScEngine->ExtDefineVariable("Math"); + m_ScEngine->ExtDefineVariable("Directory"); + m_ScEngine->ExtDefineVariable("self"); + m_ScEngine->ExtDefineVariable("this"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LOG") == 0) { + Stack->CorrectParams(1); + Game->LOG(0, "sc: %s", Stack->Pop()->GetString()); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "String") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXString(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MemBuffer") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXMemBuffer(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "File") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXFile(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Date") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXDate(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Array") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXArray(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Object") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXObject(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sleep") == 0) { + Stack->CorrectParams(1); + + Script->Sleep((uint32)Stack->Pop()->GetInt()); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WaitFor") == 0) { + Stack->CorrectParams(1); + + CBScriptable *obj = Stack->Pop()->GetNative(); + if (ValidObject((CBObject *)obj)) Script->WaitForExclusive((CBObject *)obj); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Random") == 0) { + Stack->CorrectParams(2); + + int from = Stack->Pop()->GetInt(); + int to = Stack->Pop()->GetInt(); + + Stack->PushInt(CBUtils::RandomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetScriptTimeSlice") == 0) { + Stack->CorrectParams(1); + + Script->m_TimeSlice = (uint32)Stack->Pop()->GetInt(); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MakeRGBA") == 0 || strcmp(Name, "MakeRGB") == 0 || strcmp(Name, "RGB") == 0) { + Stack->CorrectParams(4); + int r = Stack->Pop()->GetInt(); + int g = Stack->Pop()->GetInt(); + int b = Stack->Pop()->GetInt(); + int a; + CScValue *val = Stack->Pop(); + if (val->IsNULL()) a = 255; + else a = val->GetInt(); + + Stack->PushInt(DRGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MakeHSL") == 0) { + Stack->CorrectParams(3); + int h = Stack->Pop()->GetInt(); + int s = Stack->Pop()->GetInt(); + int l = Stack->Pop()->GetInt(); + + Stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetBValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetAValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetLValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Debug") == 0) { + Stack->CorrectParams(0); + + if (Game->GetDebugMgr()->m_Enabled) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(Script); + Script->Sleep(0); + } + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToString") == 0) { + Stack->CorrectParams(1); + char *Str = Stack->Pop()->GetString(); + char *Str2 = new char[strlen(Str) + 1]; + strcpy(Str2, Str); + Stack->PushString(Str2); + delete [] Str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToInt") == 0) { + Stack->CorrectParams(1); + int Val = Stack->Pop()->GetInt(); + Stack->PushInt(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToFloat") == 0) { + Stack->CorrectParams(1); + double Val = Stack->Pop()->GetFloat(); + Stack->PushFloat(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToBool") == 0) { + Stack->CorrectParams(1); + bool Val = Stack->Pop()->GetBool(); + Stack->PushBool(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + Script->RuntimeError("Call to undefined function '%s'. Ignored.", Name); + Stack->CorrectParams(0); + Stack->PushNULL(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ShowCursor() { + if (m_CursorHidden) return S_OK; + + if (!m_Interactive && Game->m_State == GAME_RUNNING) { + if (m_CursorNoninteractive) return DrawCursor(m_CursorNoninteractive); + } else { + if (m_ActiveObject && !FAILED(m_ActiveObject->ShowCursor())) return S_OK; + else { + if (m_ActiveObject && m_ActiveCursor && m_ActiveObject->GetExtendedFlag("usable")) return DrawCursor(m_ActiveCursor); + else if (m_Cursor) return DrawCursor(m_Cursor); + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SaveGame(int slot, char *desc, bool quickSave) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(slot, Filename); + + LOG(0, "Saving game '%s'...", Filename); + + Game->ApplyEvent("BeforeSave", true); + + HRESULT ret; + + m_IndicatorDisplay = true; + m_IndicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(Game); + if (FAILED(ret = pm->InitSave(desc))) goto save_finish; + + if (!quickSave) { + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + if (m_SaveImageName) { + m_SaveLoadImage = new CBSurfaceSDL(this); + + if (!m_SaveLoadImage || FAILED(m_SaveLoadImage->Create(m_SaveImageName, true, 0, 0, 0))) { + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + } + } + } + + if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveTable(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = pm->SaveFile(Filename))) goto save_finish; + + m_Registry->WriteInt("System", "MostRecentSaveSlot", slot); + +save_finish: + delete pm; + m_IndicatorDisplay = false; + + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadGame(int Slot) { + //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + m_Loading = false; + m_ScheduledLoadSlot = -1; + + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + return LoadGame(Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadGame(char *Filename) { + LOG(0, "Loading game '%s'...", Filename); + GetDebugMgr()->OnGameShutdown(); + + HRESULT ret; + + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + if (m_LoadImageName) { + m_SaveLoadImage = new CBSurfaceSDL(this); + + if (!m_SaveLoadImage || FAILED(m_SaveLoadImage->Create(m_LoadImageName, true, 0, 0, 0))) { + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + } + } + + + m_LoadInProgress = true; + m_IndicatorDisplay = true; + m_IndicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(Game); + m_DEBUG_AbsolutePathWarning = false; + if (FAILED(ret = pm->InitLoad(Filename))) goto load_finish; + + //if(FAILED(ret = Cleanup())) goto load_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadInstances(Game, pm))) goto load_finish; + + // data initialization after load + InitAfterLoad(); + + Game->ApplyEvent("AfterLoad", true); + + DisplayContent(true, false); + //m_Renderer->Flip(); + + GetDebugMgr()->OnGameInit(); + +load_finish: + m_DEBUG_AbsolutePathWarning = true; + + m_IndicatorDisplay = false; + delete pm; + m_LoadInProgress = false; + + delete m_SaveLoadImage; + m_SaveLoadImage = NULL; + + //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitAfterLoad() { + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSound, "CBSound", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); + + m_ScEngine->RefreshScriptBreakpoints(); + if (m_Store) m_Store->AfterLoad(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadRegion(void *Region, void *Data) { + ((CBRegion *)Region)->CreateRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { + ((CBSubFrame *)Subframe)->SetSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadSound(void *Sound, void *Data) { + ((CBSound *)Sound)->SetSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadFont(void *Font, void *Data) { + ((CBFontTT *)Font)->AfterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadScript(void *script, void *data) { + ((CScScript *)script)->AfterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayWindows(bool InGame) { + HRESULT res; + + int i; + + // did we lose focus? focus topmost window + if (m_FocusedWindow == NULL || !m_FocusedWindow->m_Visible || m_FocusedWindow->m_Disable) { + m_FocusedWindow = NULL; + for (i = m_Windows.GetSize() - 1; i >= 0; i--) { + if (m_Windows[i]->m_Visible && !m_Windows[i]->m_Disable) { + m_FocusedWindow = m_Windows[i]; + break; + } + } + } + + // display all windows + for (i = 0; i < m_Windows.GetSize(); i++) { + if (m_Windows[i]->m_Visible && m_Windows[i]->m_InGame == InGame) { + + res = m_Windows[i]->Display(); + if (FAILED(res)) return res; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PlayMusic(int Channel, char *Filename, bool Looping, uint32 LoopStart) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + delete m_Music[Channel]; + m_Music[Channel] = NULL; + + m_Music[Channel] = new CBSound(Game); + if (m_Music[Channel] && SUCCEEDED(m_Music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { + if (m_MusicStartTime[Channel]) { + m_Music[Channel]->SetPositionTime(m_MusicStartTime[Channel]); + m_MusicStartTime[Channel] = 0; + } + if (LoopStart) m_Music[Channel]->SetLoopStart(LoopStart); + return m_Music[Channel]->Play(Looping); + } else { + delete m_Music[Channel]; + m_Music[Channel] = NULL; + return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::StopMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (m_Music[Channel]) { + m_Music[Channel]->Stop(); + delete m_Music[Channel]; + m_Music[Channel] = NULL; + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PauseMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (m_Music[Channel]) return m_Music[Channel]->Pause(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ResumeMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (m_Music[Channel]) return m_Music[Channel]->Resume(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { + + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + m_MusicStartTime[Channel] = Time; + if (m_Music[Channel] && m_Music[Channel]->IsPlaying()) return m_Music[Channel]->SetPositionTime(Time); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadSettings(char *Filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *OrigBuffer = Game->m_FileManager->ReadWholeFile(Filename); + if (OrigBuffer == NULL) { + Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret = S_OK; + + byte *Buffer = OrigBuffer; + byte *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return E_FAIL; + } + Buffer = params; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + SAFE_DELETE_ARRAY(m_SettingsGameFile); + m_SettingsGameFile = new char[strlen((char *)params) + 1]; + if (m_SettingsGameFile) strcpy(m_SettingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (FAILED(m_StringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.ScanStr((char *)params, "%d,%d", &m_SettingsResWidth, &m_SettingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.ScanStr((char *)params, "%b", &m_SettingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.ScanStr((char *)params, "%b", &m_SettingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.ScanStr((char *)params, "%d", &m_SettingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.ScanStr((char *)params, "%b", &m_SettingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.ScanStr((char *)params, "%b", &m_SettingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.ScanStr((char *)params, "%b", &m_SettingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.ScanStr((char *)params, "%b", &m_SettingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.ScanStr((char *)params, "%b", &m_SettingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + m_Registry->SetBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.ScanStr((char *)params, "%b", &m_RichSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::SetString(&m_SavedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in game settings '%s'", Filename); + ret = E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading game settings '%s'", Filename); + ret = E_FAIL; + } + + m_SettingsAllowWindowed = m_Registry->ReadBool("Debug", "AllowWindowed", m_SettingsAllowWindowed); + m_CompressedSavegames = m_Registry->ReadBool("Debug", "CompressedSavegames", m_CompressedSavegames); + //m_CompressedSavegames = false; + + delete [] OrigBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->m_Saving) Cleanup(); + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_ActiveObject)); + PersistMgr->Transfer(TMEMBER(m_CapturedObject)); + PersistMgr->Transfer(TMEMBER(m_CursorNoninteractive)); + PersistMgr->Transfer(TMEMBER(m_DoNotExpandStrings)); + PersistMgr->Transfer(TMEMBER(m_EditorMode)); + PersistMgr->Transfer(TMEMBER(m_Fader)); + PersistMgr->Transfer(TMEMBER(m_FreezeLevel)); + PersistMgr->Transfer(TMEMBER(m_FocusedWindow)); + PersistMgr->Transfer(TMEMBER(m_FontStorage)); + PersistMgr->Transfer(TMEMBER(m_Interactive)); + PersistMgr->Transfer(TMEMBER(m_KeyboardState)); + PersistMgr->Transfer(TMEMBER(m_LastTime)); + PersistMgr->Transfer(TMEMBER(m_MainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + PersistMgr->Transfer(TMEMBER(m_Music[i])); + PersistMgr->Transfer(TMEMBER(m_MusicStartTime[i])); + } + + PersistMgr->Transfer(TMEMBER(m_OffsetX)); + PersistMgr->Transfer(TMEMBER(m_OffsetY)); + PersistMgr->Transfer(TMEMBER(m_OffsetPercentX)); + PersistMgr->Transfer(TMEMBER(m_OffsetPercentY)); + + PersistMgr->Transfer(TMEMBER(m_OrigInteractive)); + PersistMgr->Transfer(TMEMBER_INT(m_OrigState)); + PersistMgr->Transfer(TMEMBER(m_PersonalizedSave)); + PersistMgr->Transfer(TMEMBER(m_Quitting)); + + m_RegObjects.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_ScEngine)); + //PersistMgr->Transfer(TMEMBER(m_SoundMgr)); + PersistMgr->Transfer(TMEMBER_INT(m_State)); + //PersistMgr->Transfer(TMEMBER(m_SurfaceStorage)); + PersistMgr->Transfer(TMEMBER(m_Subtitles)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesSpeed)); + PersistMgr->Transfer(TMEMBER(m_SystemFont)); + PersistMgr->Transfer(TMEMBER(m_VideoFont)); + PersistMgr->Transfer(TMEMBER(m_VideoSubtitles)); + + PersistMgr->Transfer(TMEMBER(m_Timer)); + PersistMgr->Transfer(TMEMBER(m_TimerDelta)); + PersistMgr->Transfer(TMEMBER(m_TimerLast)); + + PersistMgr->Transfer(TMEMBER(m_LiveTimer)); + PersistMgr->Transfer(TMEMBER(m_LiveTimerDelta)); + PersistMgr->Transfer(TMEMBER(m_LiveTimerLast)); + + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeRunning)); + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeStartTime)); + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeLength)); + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeChannel1)); + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeChannel2)); + PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeSwap)); + + PersistMgr->Transfer(TMEMBER(m_LoadImageName)); + PersistMgr->Transfer(TMEMBER(m_SaveImageName)); + PersistMgr->Transfer(TMEMBER(m_SaveImageX)); + PersistMgr->Transfer(TMEMBER(m_SaveImageY)); + PersistMgr->Transfer(TMEMBER(m_LoadImageX)); + PersistMgr->Transfer(TMEMBER(m_LoadImageY)); + + PersistMgr->Transfer(TMEMBER_INT(m_TextEncoding)); + PersistMgr->Transfer(TMEMBER(m_TextRTL)); + + PersistMgr->Transfer(TMEMBER(m_SoundBufferSizeSec)); + PersistMgr->Transfer(TMEMBER(m_SuspendedRendering)); + + PersistMgr->Transfer(TMEMBER(m_MouseLockRect)); + + m_Windows.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_SuppressScriptErrors)); + PersistMgr->Transfer(TMEMBER(m_AutorunDisabled)); + + PersistMgr->Transfer(TMEMBER(m_AutoSaveOnExit)); + PersistMgr->Transfer(TMEMBER(m_AutoSaveSlot)); + PersistMgr->Transfer(TMEMBER(m_CursorHidden)); + + if (PersistMgr->CheckVersion(1, 0, 1)) + PersistMgr->Transfer(TMEMBER(m_Store)); + else + m_Store = NULL; + + if (!PersistMgr->m_Saving) m_Quitting = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::FocusWindow(CUIWindow *Window) { + CUIWindow *Prev = m_FocusedWindow; + + int i; + for (i = 0; i < m_Windows.GetSize(); i++) { + if (m_Windows[i] == Window) { + if (i < m_Windows.GetSize() - 1) { + m_Windows.RemoveAt(i); + m_Windows.Add(Window); + + Game->m_FocusedWindow = Window; + } + + if (Window->m_Mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->m_Mode == WINDOW_EXCLUSIVE || Prev->m_Mode == WINDOW_SYSTEM_EXCLUSIVE)) + return FocusWindow(Prev); + else return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Freeze(bool IncludingMusic) { + if (m_FreezeLevel == 0) { + m_ScEngine->PauseAll(); + m_SoundMgr->PauseAll(IncludingMusic); + m_OrigState = m_State; + m_OrigInteractive = m_Interactive; + m_Interactive = true; + } + m_State = GAME_FROZEN; + m_FreezeLevel++; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Unfreeze() { + if (m_FreezeLevel == 0) return S_OK; + + m_FreezeLevel--; + if (m_FreezeLevel == 0) { + m_State = m_OrigState; + m_Interactive = m_OrigInteractive; + m_ScEngine->ResumeAll(); + m_SoundMgr->ResumeAll(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::HandleKeypress(SDL_Event *event) { +#ifdef __WIN32__ + // handle Alt+F4 on windows + if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_F4 && (event->key.keysym.mod == KMOD_LALT || event->key.keysym.mod == KMOD_RALT)) { + OnWindowClose(); + return true; + } +#endif + + if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_RETURN && (event->key.keysym.mod == KMOD_LALT || event->key.keysym.mod == KMOD_RALT)) { + m_Renderer->SwitchFullscreen(); + return true; + } + + + + m_KeyboardState->ReadKey(event); + + if (m_FocusedWindow) { + if (!Game->m_FocusedWindow->HandleKeypress(event)) { + if (event->type != SDL_TEXTINPUT) { + if (Game->m_FocusedWindow->CanHandleEvent("Keypress")) + Game->m_FocusedWindow->ApplyEvent("Keypress"); + else + ApplyEvent("Keypress"); + } + } + return true; + } else if (event->type != SDL_TEXTINPUT) { + ApplyEvent("Keypress"); + return true; + } else return true; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::HandleMouseWheel(int Delta) { + bool Handled = false; + if (m_FocusedWindow) { + Handled = Game->m_FocusedWindow->HandleMouseWheel(Delta); + + if (!Handled) { + if (Delta < 0 && Game->m_FocusedWindow->CanHandleEvent("MouseWheelDown")) { + Game->m_FocusedWindow->ApplyEvent("MouseWheelDown"); + Handled = true; + } else if (Game->m_FocusedWindow->CanHandleEvent("MouseWheelUp")) { + Game->m_FocusedWindow->ApplyEvent("MouseWheelUp"); + Handled = true; + } + + } + } + + if (!Handled) { + if (Delta < 0) { + ApplyEvent("MouseWheelDown"); + } else { + ApplyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { + if (VerMajor) *VerMajor = DCGF_VER_MAJOR; + if (VerMinor) *VerMinor = DCGF_VER_MINOR; + + if (ExtMajor) *ExtMajor = 0; + if (ExtMinor) *ExtMinor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetWindowTitle() { + if (m_Renderer) { + char Title[512]; + strcpy(Title, m_Caption[0]); + if (Title[0] != '\0') strcat(Title, " - "); + strcat(Title, "WME Lite"); + + + Utf8String title; + if (m_TextEncoding == TEXT_UTF8) { + title = Utf8String(Title); + } else { + WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr); + } + + CBRenderSDL *renderer = static_cast(m_Renderer); + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { + AnsiString dataDir = GetDataDir(); + sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, m_SavedGameExt); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::GetDataDir() { + AnsiString userDir = PathUtil::GetUserDirectory(); +#ifdef __IPHONEOS__ + return userDir; +#else + AnsiString baseDir = m_Registry->GetBasePath(); + return PathUtil::Combine(userDir, baseDir); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { + Buffer[0] = '\0'; + + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + CBPersistMgr *pm = new CBPersistMgr(Game); + if (!pm) return E_FAIL; + + m_DEBUG_AbsolutePathWarning = false; + if (FAILED(pm->InitLoad(Filename))) { + m_DEBUG_AbsolutePathWarning = true; + delete pm; + return E_FAIL; + } + + m_DEBUG_AbsolutePathWarning = true; + strcpy(Buffer, pm->m_SavedDescription); + delete pm; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsSaveSlotUsed(int Slot) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + CBFile *File = m_FileManager->OpenFile(Filename, false); + if (!File) return false; + + m_FileManager->CloseFile(File); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::EmptySaveSlot(int Slot) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + CBPlatform::DeleteFile(Filename); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetActiveObject(CBObject *Obj) { + // not-active when game is frozen + if (Obj && !Game->m_Interactive && !Obj->m_NonIntMouseEvents) { + Obj = NULL; + } + + if (Obj == m_ActiveObject) return S_OK; + + if (m_ActiveObject) m_ActiveObject->ApplyEvent("MouseLeave"); + //if(ValidObject(m_ActiveObject)) m_ActiveObject->ApplyEvent("MouseLeave"); + m_ActiveObject = Obj; + if (m_ActiveObject) { + m_ActiveObject->ApplyEvent("MouseEntry"); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PushViewport(CBViewport *Viewport) { + m_ViewportSP++; + if (m_ViewportSP >= m_ViewportStack.GetSize()) m_ViewportStack.Add(Viewport); + else m_ViewportStack[m_ViewportSP] = Viewport; + + m_Renderer->SetViewport(Viewport->GetRect()); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PopViewport() { + m_ViewportSP--; + if (m_ViewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); + + if (m_ViewportSP >= 0 && m_ViewportSP < m_ViewportStack.GetSize()) m_Renderer->SetViewport(m_ViewportStack[m_ViewportSP]->GetRect()); + else m_Renderer->SetViewport(m_Renderer->m_DrawOffsetX, + m_Renderer->m_DrawOffsetY, + m_Renderer->m_Width + m_Renderer->m_DrawOffsetX, + m_Renderer->m_Height + m_Renderer->m_DrawOffsetY); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { + if (Rect == NULL) return E_FAIL; + else { + if (m_ViewportSP >= 0) { + CBPlatform::CopyRect(Rect, m_ViewportStack[m_ViewportSP]->GetRect()); + if (Custom) *Custom = true; + } else { + CBPlatform::SetRect(Rect, m_Renderer->m_DrawOffsetX, + m_Renderer->m_DrawOffsetY, + m_Renderer->m_Width + m_Renderer->m_DrawOffsetX, + m_Renderer->m_Height + m_Renderer->m_DrawOffsetY); + if (Custom) *Custom = false; + } + + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { + if (m_ViewportSP >= 0) { + if (OffsetX) *OffsetX = m_ViewportStack[m_ViewportSP]->m_OffsetX; + if (OffsetY) *OffsetY = m_ViewportStack[m_ViewportSP]->m_OffsetY; + } else { + if (OffsetX) *OffsetX = 0; + if (OffsetY) *OffsetY = 0; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetInteractive(bool State) { + m_Interactive = State; + if (m_TransMgr) m_TransMgr->m_OrigInteractive = State; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::ResetMousePos() { + POINT p; + p.x = m_MousePos.x + m_Renderer->m_DrawOffsetX; + p.y = m_MousePos.y + m_Renderer->m_DrawOffsetY; + + CBPlatform::SetCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetResourceModule(HMODULE ResModule) { + m_ResourceModule = ResModule; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayContent(bool Update, bool DisplayAll) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayContentSimple() { + // fill black + m_Renderer->Fill(0, 0, 0); + if (m_IndicatorDisplay) DisplayIndicator(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayIndicator() { + if (m_SaveLoadImage) { + RECT rc; + CBPlatform::SetRect(&rc, 0, 0, m_SaveLoadImage->GetWidth(), m_SaveLoadImage->GetHeight()); + if (m_LoadInProgress) m_SaveLoadImage->DisplayTrans(m_LoadImageX, m_LoadImageY, rc); + else m_SaveLoadImage->DisplayTrans(m_SaveImageX, m_SaveImageY, rc); + } + + if (!m_IndicatorDisplay && m_IndicatorWidth <= 0 || m_IndicatorHeight <= 0) return S_OK; + m_Renderer->SetupLines(); + for (int i = 0; i < m_IndicatorHeight; i++) + m_Renderer->DrawLine(m_IndicatorX, m_IndicatorY + i, m_IndicatorX + (int)(m_IndicatorWidth * (float)((float)m_IndicatorProgress / 100.0f)), m_IndicatorY + i, m_IndicatorColor); + + m_Renderer->Setup2D(); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::UpdateMusicCrossfade() { + byte GlobMusicVol = m_SoundMgr->GetVolumePercent(SOUND_MUSIC); + + if (!m_MusicCrossfadeRunning) return S_OK; + if (m_State == GAME_FROZEN) return S_OK; + + if (m_MusicCrossfadeChannel1 < 0 || m_MusicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !m_Music[m_MusicCrossfadeChannel1]) { + m_MusicCrossfadeRunning = false; + return S_OK; + } + if (m_MusicCrossfadeChannel2 < 0 || m_MusicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !m_Music[m_MusicCrossfadeChannel2]) { + m_MusicCrossfadeRunning = false; + return S_OK; + } + + if (!m_Music[m_MusicCrossfadeChannel1]->IsPlaying()) m_Music[m_MusicCrossfadeChannel1]->Play(); + if (!m_Music[m_MusicCrossfadeChannel2]->IsPlaying()) m_Music[m_MusicCrossfadeChannel2]->Play(); + + uint32 CurrentTime = Game->m_LiveTimer - m_MusicCrossfadeStartTime; + + if (CurrentTime >= m_MusicCrossfadeLength) { + m_MusicCrossfadeRunning = false; + //m_Music[m_MusicCrossfadeChannel2]->SetVolume(GlobMusicVol); + m_Music[m_MusicCrossfadeChannel2]->SetVolume(100); + + m_Music[m_MusicCrossfadeChannel1]->Stop(); + //m_Music[m_MusicCrossfadeChannel1]->SetVolume(GlobMusicVol); + m_Music[m_MusicCrossfadeChannel1]->SetVolume(100); + + + if (m_MusicCrossfadeSwap) { + // swap channels + CBSound *Dummy = m_Music[m_MusicCrossfadeChannel1]; + int DummyInt = m_MusicStartTime[m_MusicCrossfadeChannel1]; + + m_Music[m_MusicCrossfadeChannel1] = m_Music[m_MusicCrossfadeChannel2]; + m_MusicStartTime[m_MusicCrossfadeChannel1] = m_MusicStartTime[m_MusicCrossfadeChannel2]; + + m_Music[m_MusicCrossfadeChannel2] = Dummy; + m_MusicStartTime[m_MusicCrossfadeChannel2] = DummyInt; + } + } else { + //m_Music[m_MusicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)m_MusicCrossfadeLength * GlobMusicVol); + //m_Music[m_MusicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)m_MusicCrossfadeLength * GlobMusicVol); + m_Music[m_MusicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)m_MusicCrossfadeLength * 100); + m_Music[m_MusicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)m_MusicCrossfadeLength * 100); + + //Game->QuickMessageForm("%d %d", m_Music[m_MusicCrossfadeChannel1]->GetVolume(), m_Music[m_MusicCrossfadeChannel2]->GetVolume()); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ResetContent() { + m_ScEngine->ClearGlobals(); + //m_Timer = 0; + //m_LiveTimer = 0; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + FILE *f = fopen("./zz_class_reg_dump.log", "wt"); + + CSysClassRegistry::GetInstance()->DumpClasses(f); + + fclose(f); + Game->QuickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InvalidateDeviceObjects() { + for (int i = 0; i < m_RegObjects.GetSize(); i++) { + m_RegObjects[i]->InvalidateDeviceObjects(); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::RestoreDeviceObjects() { + for (int i = 0; i < m_RegObjects.GetSize(); i++) { + m_RegObjects[i]->RestoreDeviceObjects(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetWaitCursor(char *Filename) { + delete m_CursorNoninteractive; + m_CursorNoninteractive = NULL; + + m_CursorNoninteractive = new CBSprite(Game); + if (!m_CursorNoninteractive || FAILED(m_CursorNoninteractive->LoadFile(Filename))) { + delete m_CursorNoninteractive; + m_CursorNoninteractive = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DrawCursor(CBSprite *Cursor) { + if (!Cursor) return E_FAIL; + if (Cursor != m_LastCursor) { + Cursor->Reset(); + m_LastCursor = Cursor; + } + return Cursor->Draw(m_MousePos.x, m_MousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { + if (m_ShuttingDown || !m_Renderer) return S_OK; + + m_Renderer->m_Active = Activate; + + if (RefreshMouse) { + POINT p; + GetMousePos(&p); + SetActiveObject(m_Renderer->GetObjectAt(p.x, p.y)); + } + + if (Activate) m_SoundMgr->ResumeAll(); + else m_SoundMgr->PauseAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftDown() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftClick"); + } + } + + if (m_ActiveObject != NULL) m_CapturedObject = m_ActiveObject; + m_MouseLeftDown = true; + CBPlatform::SetCapture(m_Renderer->m_Window); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftUp() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::ReleaseCapture(); + m_CapturedObject = NULL; + m_MouseLeftDown = false; + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftDblClick() { + if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightDblClick() { + if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("RightDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightDown() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("RightClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightUp() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("RightRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseMiddleDown() { + if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("MiddleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseMiddleUp() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("MiddleRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnPaint() { + if (m_Renderer && m_Renderer->m_Windowed && m_Renderer->m_Ready) { + m_Renderer->InitLoop(); + DisplayContent(false, true); + DisplayDebugInfo(); + m_Renderer->WindowedBlt(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnWindowClose() { + if (CanHandleEvent("QuitGame")) { + if (m_State != GAME_FROZEN) Game->ApplyEvent("QuitGame"); + return S_OK; + } else return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayDebugInfo() { + char str[100]; + + if (m_DEBUG_ShowFPS) { + sprintf(str, "FPS: %d", Game->m_Fps); + m_SystemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (Game->m_DEBUG_DebugMode) { + if (!Game->m_Renderer->m_Windowed) + sprintf(str, "Mode: %dx%dx%d", m_Renderer->m_Width, m_Renderer->m_Height, m_Renderer->m_BPP); + else + sprintf(str, "Mode: %dx%d windowed", m_Renderer->m_Width, m_Renderer->m_Height); + + strcat(str, " ("); + strcat(str, m_Renderer->GetName()); + strcat(str, ")"); + m_SystemFont->DrawText((byte *)str, 0, 0, m_Renderer->m_Width, TAL_RIGHT); + + m_Renderer->DisplayDebugInfo(); + + int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; + ScrTotal = m_ScEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); + m_SystemFont->DrawText((byte *)str, 0, 70, m_Renderer->m_Width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", m_Timer); + Game->m_SystemFont->DrawText((byte *)str, 0, 130, m_Renderer->m_Width, TAL_RIGHT); + + if (m_ActiveObject != NULL) m_SystemFont->DrawText((byte *)m_ActiveObject->m_Name, 0, 150, m_Renderer->m_Width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", m_UsedMem / (1024 * 1024)); + m_SystemFont->DrawText((byte *)str, 0, 170, m_Renderer->m_Width, TAL_RIGHT); + + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::GetDebugMgr() { + if (!m_DebugMgr) m_DebugMgr = new CBDebugger(this); + return m_DebugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::GetMousePos(POINT *Pos) { + CBPlatform::GetCursorPos(Pos); + + Pos->x -= m_Renderer->m_DrawOffsetX; + Pos->y -= m_Renderer->m_DrawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if(m_Renderer->m_Windowed && ::IsZoomed(m_Renderer->m_Window)) + { + RECT rc; + ::GetClientRect(m_Renderer->m_Window, &rc); + Pos->x *= Game->m_Renderer->m_RealWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= Game->m_Renderer->m_RealHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (m_MouseLockRect.left != 0 && m_MouseLockRect.right != 0 && m_MouseLockRect.top != 0 && m_MouseLockRect.bottom != 0) { + if (!CBPlatform::PtInRect(&m_MouseLockRect, *Pos)) { + Pos->x = std::max(m_MouseLockRect.left, Pos->x); + Pos->y = std::max(m_MouseLockRect.top, Pos->y); + + Pos->x = std::min(m_MouseLockRect.right, Pos->x); + Pos->y = std::min(m_MouseLockRect.bottom, Pos->y); + + POINT NewPos = *Pos; + + NewPos.x += m_Renderer->m_DrawOffsetX; + NewPos.y += m_Renderer->m_DrawOffsetY; + + CBPlatform::SetCursorPos(NewPos.x, NewPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::MiniUpdate() { + if (!m_MiniUpdateEnabled) return S_OK; + + if (CBPlatform::GetTime() - m_LastMiniUpdate > 200) { + if (m_SoundMgr) m_SoundMgr->InitLoop(); + m_LastMiniUpdate = CBPlatform::GetTime(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnScriptShutdown(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsLeftDoubleClick() { + return IsDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsRightDoubleClick() { + return IsDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + +#if __WIN32__ + maxDoubleCLickTime = GetDoubleClickTime(); + maxMoveX = GetSystemMetrics(SM_CXDOUBLECLK); + maxMoveY = GetSystemMetrics(SM_CYDOUBLECLK); +#elif __IPHONEOS__ + maxMoveX = 16; + maxMoveY = 16; +#endif + + POINT pos; + CBPlatform::GetCursorPos(&pos); + + int moveX = abs(pos.x - m_LastClick[buttonIndex].PosX); + int moveY = abs(pos.y - m_LastClick[buttonIndex].PosY); + + + if (m_LastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - m_LastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + m_LastClick[buttonIndex].Time = CBPlatform::GetTime(); + m_LastClick[buttonIndex].PosX = pos.x; + m_LastClick[buttonIndex].PosY = pos.y; + return false; + } else { + m_LastClick[buttonIndex].Time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AutoSaveOnExit() { + m_SoundMgr->SaveSettings(); + m_Registry->SaveValues(); + + if (!m_AutoSaveOnExit) return; + if (m_State == GAME_FROZEN) return; + + SaveGame(m_AutoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AddMem(int bytes) { + m_UsedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::GetDeviceType() const { +#ifdef __IPHONEOS__ + char devType[128]; + IOS_GetDeviceType(devType); + return AnsiString(devType); +#else + return "computer"; +#endif +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index a61ba1270d..b3df2b3046 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -29,10 +29,10 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -#include "BDebugger.h" +#include "engines/wintermute/BDebugger.h" //#include "BSaveThumbHelper.h" //#include "BFader.h" -//#include "BRenderer.h" +#include "engines/wintermute/BRenderer.h" //#include "BSurfaceStorage.h" #include "engines/wintermute/BObject.h" #include "engines/wintermute/persistent.h" @@ -53,7 +53,9 @@ class CBStringTable; class CBQuickMsg; class CUIWindow; class CBViewport; +class CBRenderer; class CBRegistry; +class CBSurfaceStorage; class CSXStore; class CSXMath; class CBKeyboardState; @@ -63,7 +65,7 @@ class CBKeyboardState; class CBGame: public CBObject { public: DECLARE_PERSISTENT(CBGame, CBObject) -#if 0 + virtual HRESULT OnScriptShutdown(CScScript *Script); virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); @@ -80,7 +82,7 @@ public: bool IsLeftDoubleClick(); bool IsRightDoubleClick(); -#endif + bool m_AutorunDisabled; uint32 m_LastMiniUpdate; @@ -175,7 +177,7 @@ public: #endif //TODO: STUB CBDebugger *GetDebugMgr(); void LOG(HRESULT res, LPCSTR fmt, ...) {} -#if 0 + CBRenderer *m_Renderer; CBSoundMgr *m_SoundMgr; CScEngine *m_ScEngine; @@ -184,6 +186,7 @@ public: CBSurfaceStorage *m_SurfaceStorage; CBFontStorage *m_FontStorage; CBGame(); +#if 0 virtual ~CBGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *Filename = NULL); @@ -216,19 +219,17 @@ public: char *m_SettingsGameFile; CBFader *m_Fader; bool m_SuppressScriptErrors; -#if 0 + virtual HRESULT InvalidateDeviceObjects(); virtual HRESULT RestoreDeviceObjects(); -#endif + virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); -#if 0 // scripting interface virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); virtual char *ScToString(); - // compatibility bits bool m_CompatKillMethodThreads; @@ -248,6 +249,7 @@ public: int m_ScheduledLoadSlot; bool m_Loading; bool m_PersonalizedSave; +#if 0 HRESULT EmptySaveSlot(int Slot); bool IsSaveSlotUsed(int Slot); HRESULT GetSaveSlotDescription(int Slot, char *Buffer); diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp new file mode 100644 index 0000000000..6f0d0235aa --- /dev/null +++ b/engines/wintermute/BImage.cpp @@ -0,0 +1,117 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "dcgf.h" +#include "BImage.h" +//#include "FreeImage.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +#if 0 + m_Bitmap = bitmap; +#endif + m_Bitmap = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBImage::~CBImage() { +#if 0 + if (m_Bitmap) FreeImage_Unload(m_Bitmap); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::SaveBMPFile(char *Filename) { +#if 0 + if (!m_Bitmap) return E_FAIL; + + if (FreeImage_Save(FIF_BMP, m_Bitmap, Filename)) return S_OK; + else return E_FAIL; +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::Resize(int NewWidth, int NewHeight) { +#if 0 + if (!m_Bitmap) return E_FAIL; + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(m_Bitmap); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(m_Bitmap); + + + FIBITMAP *newImg = FreeImage_Rescale(m_Bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + if (newImg) { + FreeImage_Unload(m_Bitmap); + m_Bitmap = newImg; + return S_OK; + } else return E_FAIL; +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { + if (!m_Bitmap) return NULL; +#if 0 + FIMEMORY *fiMem = FreeImage_OpenMemory(); + FreeImage_SaveToMemory(FIF_PNG, m_Bitmap, fiMem); + uint32 size; + byte *data; + FreeImage_AcquireMemory(fiMem, &data, &size); + + + byte *Buffer = new byte[size]; + memcpy(Buffer, data, size); + + FreeImage_CloseMemory(fiMem); + + if (BufferSize) *BufferSize = size; + + return Buffer; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { +#if 0 + if (m_Bitmap) FreeImage_Unload(m_Bitmap); + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + + m_Bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); +#endif + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BImage.h b/engines/wintermute/BImage.h new file mode 100644 index 0000000000..a738fb418b --- /dev/null +++ b/engines/wintermute/BImage.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BIMAGE_H +#define WINTERMUTE_BIMAGE_H + + +//#include "FreeImage.h" +#include "BBase.h" +#include "common/endian.h" + +struct FIBITMAP; + +namespace WinterMute { + +class CBImage: CBBase { + +public: + CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); + ~CBImage(); + + + byte *CreateBMPBuffer(uint32 *BufferSize = NULL); + HRESULT Resize(int NewWidth, int NewHeight); + HRESULT SaveBMPFile(char *Filename); + HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); + + FIBITMAP *GetBitmap() const { + return m_Bitmap; + } +private: + FIBITMAP *m_Bitmap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp new file mode 100644 index 0000000000..7e89d9827c --- /dev/null +++ b/engines/wintermute/BKeyboardState.cpp @@ -0,0 +1,243 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BKeyboardState.h" +#include "ScValue.h" +#include "ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + m_CurrentPrintable = false; + m_CurrentCharCode = 0; + m_CurrentKeyData = 0; + + m_CurrentShift = false; + m_CurrentAlt = false; + m_CurrentControl = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "IsKeyDown") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + int vKey; + + if (val->m_Type == VAL_STRING && strlen(val->GetString()) > 0) { + char *str = val->GetString(); + if (str[0] >= 'A' && str[0] <= 'Z') str[0] += ('a' - 'A'); + vKey = (int)str[0]; + } else vKey = val->GetInt(); + + Uint8 *state = SDL_GetKeyboardState(NULL); + SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); + bool isDown = state[scanCode] > 0; + + Stack->PushBool(isDown); + return S_OK; + } + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("keyboard"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Key") == 0) { + if (m_CurrentPrintable) { + char key[2]; + key[0] = (char)m_CurrentCharCode; + key[1] = '\0'; + m_ScValue->SetString(key); + } else m_ScValue->SetString(""); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Printable") == 0) { + m_ScValue->SetBool(m_CurrentPrintable); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KeyCode") == 0) { + m_ScValue->SetInt(m_CurrentCharCode); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsShift") == 0) { + m_ScValue->SetBool(m_CurrentShift); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsAlt") == 0) { + m_ScValue->SetBool(m_CurrentAlt); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsControl") == 0) { + m_ScValue->SetBool(m_CurrentControl); + return m_ScValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ScSetProperty(char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Name")==0){ + SetName(Value->GetString()); + if(m_Renderer) SetWindowText(m_Renderer->m_Window, m_Name); + return S_OK; + } + + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBKeyboardState::ScToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ReadKey(SDL_Event *event) { + m_CurrentPrintable = (event->type == SDL_TEXTINPUT); + m_CurrentCharCode = KeyCodeToVKey(event); + //m_CurrentKeyData = KeyData; + + m_CurrentControl = IsControlDown(); + m_CurrentAlt = IsAltDown(); + m_CurrentShift = IsShiftDown(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { + //if(!PersistMgr->m_Saving) Cleanup(); + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_CurrentAlt)); + PersistMgr->Transfer(TMEMBER(m_CurrentCharCode)); + PersistMgr->Transfer(TMEMBER(m_CurrentControl)); + PersistMgr->Transfer(TMEMBER(m_CurrentKeyData)); + PersistMgr->Transfer(TMEMBER(m_CurrentPrintable)); + PersistMgr->Transfer(TMEMBER(m_CurrentShift)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsShiftDown() { + int mod = SDL_GetModState(); + return (mod & KMOD_LSHIFT) || (mod & KMOD_RSHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsControlDown() { + int mod = SDL_GetModState(); + return (mod & KMOD_LCTRL) || (mod & KMOD_RCTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsAltDown() { + int mod = SDL_GetModState(); + return (mod & KMOD_LALT) || (mod & KMOD_RALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::KeyCodeToVKey(SDL_Event *event) { + if (event->type != SDL_KEYDOWN) return 0; + + switch (event->key.keysym.sym) { + case SDLK_KP_ENTER: + return SDLK_RETURN; + default: + return event->key.keysym.sym; + } +} + +////////////////////////////////////////////////////////////////////////// +SDL_Keycode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { + // todo + return (SDL_Keycode)vkey; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h new file mode 100644 index 0000000000..f5ea56f055 --- /dev/null +++ b/engines/wintermute/BKeyboardState.h @@ -0,0 +1,71 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "BBase.h" +#include "BScriptable.h" +#include + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 m_CurrentKeyData; + uint32 m_CurrentCharCode; + bool m_CurrentPrintable; + + bool m_CurrentShift; + bool m_CurrentAlt; + bool m_CurrentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + HRESULT ReadKey(SDL_Event *event); + + static bool IsShiftDown(); + static bool IsControlDown(); + static bool IsAltDown(); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +private: + uint32 KeyCodeToVKey(SDL_Event *event); + SDL_Keycode VKeyToKeyCode(uint32 vkey); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp new file mode 100644 index 0000000000..d5ae12fa84 --- /dev/null +++ b/engines/wintermute/BPackage.cpp @@ -0,0 +1,102 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BPackage.h" +#include "BGame.h" +#include "BFileManager.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + m_File = NULL; + m_Name = NULL; + m_CD = 0; + m_Priority = 0; + m_BoundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (m_Name) delete [] m_Name; + CloseFilePointer(m_File); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Open() { + if (m_File) return S_OK; + else { + m_File = GetFilePointer(); + return m_File ? S_OK : E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Close() { + if (m_File) fclose(m_File); + m_File = NULL; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Read(FILE *file, uint32 offset, byte *buffer, uint32 size) { + HRESULT ret; + if (FAILED(ret = Open())) return ret; + else { + if (fseek(file, offset, SEEK_SET)) return E_FAIL; + if (fread(buffer, size, 1, file) != 1) return E_FAIL; + else return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +FILE *CBPackage::GetFilePointer() { + FILE *file = Game->m_FileManager->OpenPackage(m_Name); + if (!file) { + Game->m_FileManager->RequestCD(m_CD, m_Name, ""); + file = Game->m_FileManager->OpenPackage(m_Name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::CloseFilePointer(FILE*& file) { + if (file) fclose(file); + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h new file mode 100644 index 0000000000..54f2e04a6c --- /dev/null +++ b/engines/wintermute/BPackage.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "BBase.h" + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + FILE *GetFilePointer(); + void CloseFilePointer(FILE*& file); + + bool m_BoundToExe; + byte m_Priority; + HRESULT Read(FILE *file, uint32 offset, byte *buffer, uint32 size); + HRESULT Close(); + HRESULT Open(); + char *m_Name; + int m_CD; + FILE *m_File; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp new file mode 100644 index 0000000000..1210d90e24 --- /dev/null +++ b/engines/wintermute/BPkgFile.cpp @@ -0,0 +1,228 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BPackage.h" +#include "BPkgFile.h" +#include "BGame.h" +#include "BFileManager.h" + +#if _DEBUG +#pragma comment(lib, "zlib_d.lib") +#else +#pragma comment(lib, "zlib.lib") +#endif + + +extern "C" { +#include "zlib.h" +} + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { + m_FileEntry = NULL; + m_File = NULL; + m_Compressed = false; + + m_Stream.zalloc = (alloc_func)0; + m_Stream.zfree = (free_func)0; + m_Stream.opaque = (voidpf)0; + + m_InflateInit = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::~CBPkgFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Open(Common::String Filename) { + Close(); + + char fileName[MAX_PATH]; + strcpy(fileName, Filename.c_str()); + + // correct slashes + for (int i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '/') fileName[i] = '\\'; + } + + m_FileEntry = Game->m_FileManager->GetPackageEntry(fileName); + if (!m_FileEntry) return E_FAIL; + + m_File = m_FileEntry->m_Package->GetFilePointer(); + if (!m_File) return E_FAIL; + + + m_Compressed = (m_FileEntry->m_CompressedLength != 0); + m_Size = m_FileEntry->m_Length; + + SeekToPos(0); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Close() { + if (m_FileEntry) { + m_FileEntry->m_Package->CloseFilePointer(m_File); + m_FileEntry = NULL; + } + m_File = NULL; + + m_Pos = 0; + m_Size = 0; + + if (m_InflateInit) inflateEnd(&m_Stream); + m_InflateInit = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { + if (!m_FileEntry) return E_FAIL; + + HRESULT ret = S_OK; + + if (m_Pos + Size > m_Size) { + Size = m_Size - m_Pos; + if (Size == 0) return E_FAIL; + } + + if (m_Compressed) { + uint32 InitOut = m_Stream.total_out; + + m_Stream.avail_out = Size; + m_Stream.next_out = (byte *)Buffer; + + while (m_Stream.total_out - InitOut < Size && m_Stream.total_in < m_FileEntry->m_CompressedLength) { + // needs to read more data? + if (m_Stream.avail_in == 0) { + m_Stream.avail_in = MIN(COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); + m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); + m_Stream.next_in = m_CompBuffer; + } + + int res = inflate(&m_Stream, Z_SYNC_FLUSH); + if (res != Z_OK && res != Z_STREAM_END) { + Game->LOG(0, "zlib error: %d", res); + ret = E_FAIL; + break; + } + } + + + } else { + ret = m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Pos, (byte *)Buffer, Size); + } + + m_Pos += Size; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { + if (!m_FileEntry) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = m_Size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = m_Pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > m_Size) return E_FAIL; + + return SeekToPos(NewPos); +} + + +#define STREAM_BUFFER_SIZE 4096 +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { + HRESULT ret = S_OK; + + // seek compressed stream to NewPos + if (m_Compressed) { + byte StreamBuffer[STREAM_BUFFER_SIZE]; + if (m_InflateInit) inflateEnd(&m_Stream); + m_InflateInit = false; + + m_Stream.avail_in = 0; + m_Stream.next_in = m_CompBuffer; + m_Stream.avail_out = MIN(STREAM_BUFFER_SIZE, NewPos); + m_Stream.next_out = StreamBuffer; + inflateInit(&m_Stream); + m_InflateInit = true; + + while (m_Stream.total_out < NewPos && m_Stream.total_in < m_FileEntry->m_CompressedLength) { + // needs to read more data? + if (m_Stream.avail_in == 0) { + m_Stream.avail_in = MIN(COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); + m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); + m_Stream.next_in = m_CompBuffer; + } + + // needs more space? + if (m_Stream.avail_out == 0) { + m_Stream.next_out = StreamBuffer; + m_Stream.avail_out = MIN(STREAM_BUFFER_SIZE, NewPos - m_Stream.total_out); + } + + // stream on! + int res = inflate(&m_Stream, Z_SYNC_FLUSH); + if (res != Z_OK && res != Z_STREAM_END) { + ret = E_FAIL; + break; + } + } + + } + + m_Pos = NewPos; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h new file mode 100644 index 0000000000..a00c954860 --- /dev/null +++ b/engines/wintermute/BPkgFile.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPKGFILE_H +#define WINTERMUTE_BPKGFILE_H + + +#include "BFile.h" +#include "BFileEntry.h" +#include // Added by ClassView + +#define COMPRESSED_BUFFER_SIZE 4096 + +namespace WinterMute { + +class CBPkgFile : public CBFile { +public: + CBPkgFile(CBGame *inGame); + virtual ~CBPkgFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(Common::String Filename); +private: + bool m_InflateInit; + HRESULT SeekToPos(uint32 NewPos); + bool m_Compressed; + CBFileEntry *m_FileEntry; + z_stream m_Stream; + byte m_CompBuffer[COMPRESSED_BUFFER_SIZE]; + FILE *m_File; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BPoint.cpp b/engines/wintermute/BPoint.cpp new file mode 100644 index 0000000000..331e9252f4 --- /dev/null +++ b/engines/wintermute/BPoint.cpp @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BPoint.h" +#include "BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPoint::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(x)); + PersistMgr->Transfer(TMEMBER(y)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BPoint.h b/engines/wintermute/BPoint.h new file mode 100644 index 0000000000..6cd17653d9 --- /dev/null +++ b/engines/wintermute/BPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "persistent.h" +#include "BBase.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BQuickMsg.cpp b/engines/wintermute/BQuickMsg.cpp new file mode 100644 index 0000000000..0f8c54f030 --- /dev/null +++ b/engines/wintermute/BQuickMsg.cpp @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BQuickMsg.h" +#include "BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, char *Text): CBBase(inGame) { + m_Text = new char [strlen(Text) + 1]; + if (m_Text) strcpy(m_Text, Text); + m_StartTime = Game->m_CurrentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (m_Text) delete [] m_Text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::GetText() { + return m_Text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BQuickMsg.h b/engines/wintermute/BQuickMsg.h new file mode 100644 index 0000000000..67bb8cf8bf --- /dev/null +++ b/engines/wintermute/BQuickMsg.h @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "BBase.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *GetText(); + uint32 m_StartTime; + char *m_Text; + CBQuickMsg(CBGame *inGame, char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp new file mode 100644 index 0000000000..309d44edab --- /dev/null +++ b/engines/wintermute/BRegion.cpp @@ -0,0 +1,508 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BRegion.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "BGame.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + m_Active = true; + m_EditorSelectedPoint = -1; + m_LastMimicScale = -1; + m_LastMimicX = m_LastMimicY = INT_MIN; + + CBPlatform::SetRectEmpty(&m_Rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::Cleanup() { + for (int i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; + m_Points.RemoveAll(); + + CBPlatform::SetRectEmpty(&m_Rect); + m_EditorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::CreateRegion() { + return SUCCEEDED(GetBoundingRect(&m_Rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::PointInRegion(int X, int Y) { + if (m_Points.GetSize() < 3) return false; + + POINT pt; + pt.x = X; + pt.y = Y; + + RECT rect; + rect.left = X - 1; + rect.right = X + 2; + rect.top = Y - 1; + rect.bottom = Y + 2; + + if (CBPlatform::PtInRect(&m_Rect, pt)) return PtInPolygon(X, Y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + Game->LOG(0, "'REGION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int i; + + for (i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; + m_Points.RemoveAll(); + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &m_Active); + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + m_Points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in REGION definition"); + return E_FAIL; + } + + CreateRegion(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "AddPoint") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + m_Points.Add(new CBPoint(X, Y)); + CreateRegion(); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertPoint") == 0) { + Stack->CorrectParams(3); + int Index = Stack->Pop()->GetInt(); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < m_Points.GetSize()) { + m_Points.InsertAt(Index, new CBPoint(X, Y)); + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPoint") == 0) { + Stack->CorrectParams(3); + int Index = Stack->Pop()->GetInt(); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < m_Points.GetSize()) { + m_Points[Index]->x = X; + m_Points[Index]->y = Y; + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemovePoint") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < m_Points.GetSize()) { + delete m_Points[Index]; + m_Points[Index] = NULL; + + m_Points.RemoveAt(Index); + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPoint") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < m_Points.GetSize()) { + CScValue *Val = Stack->GetPushValue(); + if (Val) { + Val->SetProperty("X", m_Points[Index]->x); + Val->SetProperty("Y", m_Points[Index]->y); + } + } else Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("region"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + m_ScValue->SetBool(m_Active); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumPoints") == 0) { + m_ScValue->SetInt(m_Points.GetSize()); + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + m_Active = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegion::ScToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride) { + if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); + else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", m_EditorSelectedPoint); + + int i; + + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + for (i = 0; i < m_Points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + } + + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_EditorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(m_LastMimicScale)); + PersistMgr->Transfer(TMEMBER(m_LastMimicX)); + PersistMgr->Transfer(TMEMBER(m_LastMimicY)); + m_Points.Persist(PersistMgr); + + return S_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::PtInPolygon(int X, int Y) { + if (m_Points.GetSize() < 3) return false; + + int counter = 0; + int i; + double xinters; + dPoint p, p1, p2; + + p.x = (double)X; + p.y = (double)Y; + + p1.x = (double)m_Points[0]->x; + p1.y = (double)m_Points[0]->y; + + for (i = 1; i <= m_Points.GetSize(); i++) { + p2.x = (double)m_Points[i % m_Points.GetSize()]->x; + p2.y = (double)m_Points[i % m_Points.GetSize()]->y; + + if (p.y > std::min(p1.y, p2.y)) { + if (p.y <= std::max(p1.y, p2.y)) { + if (p.x <= std::max(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::GetBoundingRect(RECT *Rect) { + if (m_Points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < m_Points.GetSize(); i++) { + MinX = std::min(MinX, m_Points[i]->x); + MinY = std::min(MinY, m_Points[i]->y); + + MaxX = std::max(MaxX, m_Points[i]->x); + MaxY = std::max(MaxY, m_Points[i]->y); + } + CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { + if (Scale == m_LastMimicScale && X == m_LastMimicX && Y == m_LastMimicY) return S_OK; + + Cleanup(); + + for (int i = 0; i < Region->m_Points.GetSize(); i++) { + int x, y; + + x = (int)((float)Region->m_Points[i]->x * Scale / 100.0f); + y = (int)((float)Region->m_Points[i]->y * Scale / 100.0f); + + m_Points.Add(new CBPoint(x + X, y + Y)); + } + + m_LastMimicScale = Scale; + m_LastMimicX = X; + m_LastMimicY = Y; + + return CreateRegion() ? S_OK : E_FAIL; +} + +} // end of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h new file mode 100644 index 0000000000..94202ea8dd --- /dev/null +++ b/engines/wintermute/BRegion.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "BPoint.h" +#include "BObject.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float m_LastMimicScale; + int m_LastMimicX; + int m_LastMimicY; + void Cleanup(); + HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); + HRESULT GetBoundingRect(RECT *Rect); + bool PtInPolygon(int X, int Y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool m_Active; + int m_EditorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool PointInRegion(int X, int Y); + bool CreateRegion(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + RECT m_Rect; + CBArray m_Points; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride = NULL); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp new file mode 100644 index 0000000000..4d7b1b6d37 --- /dev/null +++ b/engines/wintermute/BRegistry.cpp @@ -0,0 +1,227 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include +#include "BGame.h" +#include "BRegistry.h" +#include "PathUtil.h" +#include "StringUtil.h" +#include "tinyxml.h" +#include "utils.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + m_IniName = NULL; + + SetIniName("./wme.ini"); + LoadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + SaveValues(); + delete[] m_IniName; + m_IniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + +#ifdef __WIN32__ + // check ini file first (so what we can use project files on windows) + char buffer[32768]; + GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, m_IniName); + ret = AnsiString(buffer); + + if (buffer != init) return ret; +#endif + + bool found = false; + ret = GetValue(m_LocalValues, subKey, key, found); + if (!found) ret = GetValue(m_Values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + m_Values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int init) { +#ifdef __WIN32__ + int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, m_IniName); + if (ret != init) return ret; +#endif + + AnsiString val = ReadString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteInt(const AnsiString &subKey, const AnsiString &key, int value) { + WriteString(subKey, key, StringUtil::ToString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::ReadBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (ReadInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return WriteInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SetIniName(char *Name) { + delete[] m_IniName; + m_IniName = NULL; + + if (strchr(Name, '\\') == NULL && strchr(Name, '/') == NULL) { + m_IniName = new char [strlen(Name) + 3]; + sprintf(m_IniName, "./%s", Name); + } else { + m_IniName = new char [strlen(Name) + 1]; + strcpy(m_IniName, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::GetIniName() { + return m_IniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::LoadValues(bool local) { + if (local) LoadXml("settings.xml", m_LocalValues); + else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), m_Values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SaveValues() { + SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), m_Values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SetBasePath(const char *basePath) { + m_BasePath = PathUtil::GetFileNameWithoutExtension(basePath); + + LoadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it).second; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt).second; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || rootElem->ValueStr() != "Settings") return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[pathElem->ValueStr()][keyElem->ValueStr()] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::CreatePath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = m_Values.begin(); pathIt != m_Values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt).first); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt).second; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt).first); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt).second)); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + std::ofstream stream; + stream.open(fileName.c_str()); + + if (!stream.is_open()) return; + else { + stream << printer.Str(); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h new file mode 100644 index 0000000000..48b88fd663 --- /dev/null +++ b/engines/wintermute/BRegistry.h @@ -0,0 +1,76 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "BBase.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void SetIniName(char *Name); + char *GetIniName(); + bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool WriteInt(const AnsiString &subKey, const AnsiString &key, int value); + int ReadInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void SetBasePath(const char *basePath); + AnsiString GetBasePath() const { + return m_BasePath; + } + + void LoadValues(bool local); + void SaveValues(); + +private: + char *m_IniName; + + typedef std::map KeyValuePair; + typedef std::map PathValueMap; + + PathValueMap m_LocalValues; + PathValueMap m_Values; + + AnsiString m_BasePath; + + void LoadXml(const AnsiString fileName, PathValueMap &values); + void SaveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp new file mode 100644 index 0000000000..312954097d --- /dev/null +++ b/engines/wintermute/BRenderSDL.cpp @@ -0,0 +1,408 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BRenderSDL.h" +#include "BRegistry.h" +#include "BSurfaceSDL.h" +#include "BImage.h" +#include "MathUtil.h" +#include "BGame.h" +#include "BSprite.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { + m_Renderer = NULL; + m_Win = NULL; + + m_BorderLeft = m_BorderRight = m_BorderTop = m_BorderBottom = 0; + m_RatioX = m_RatioY = 1.0f; +} + +////////////////////////////////////////////////////////////////////////// +CBRenderSDL::~CBRenderSDL() { + if (m_Renderer) SDL_DestroyRenderer(m_Renderer); + if (m_Win) SDL_DestroyWindow(m_Win); + + SDL_Quit(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { + if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; + + + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); + + + m_Width = width; + m_Height = height; + + m_RealWidth = width; + m_RealHeight = height; + + + // find suitable resolution +#ifdef __IPHONEOS__ + m_RealWidth = 480; + m_RealHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + m_RealWidth = mode.w; + m_RealHeight = mode.h; + break; + } + } +#else + m_RealWidth = Game->m_Registry->ReadInt("Debug", "ForceResWidth", m_Width); + m_RealHeight = Game->m_Registry->ReadInt("Debug", "ForceResHeight", m_Height); +#endif + + /* + m_RealWidth = 480; + m_RealHeight = 320; + */ + + + float origAspect = (float)m_Width / (float)m_Height; + float realAspect = (float)m_RealWidth / (float)m_RealHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)m_RealHeight / (float)m_Height; + } else { + // wide to normal + ratio = (float)m_RealWidth / (float)m_Width; + } + + m_BorderLeft = (m_RealWidth - (m_Width * ratio)) / 2; + m_BorderRight = m_RealWidth - (m_Width * ratio) - m_BorderLeft; + + m_BorderTop = (m_RealHeight - (m_Height * ratio)) / 2; + m_BorderBottom = m_RealHeight - (m_Height * ratio) - m_BorderTop; + + + + m_RatioX = (float)(m_RealWidth - m_BorderLeft - m_BorderRight) / (float)m_Width; + m_RatioY = (float)(m_RealHeight - m_BorderTop - m_BorderBottom) / (float)m_Height; + + + Uint32 flags = SDL_WINDOW_SHOWN; +#ifdef __IPHONEOS__ + flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; +#endif + + //m_Windowed = Game->m_Registry->ReadBool("Video", "Windowed", true); + if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + + + m_Win = SDL_CreateWindow("WME Lite", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + m_RealWidth, m_RealHeight, + flags); + + if (!m_Win) return E_FAIL; + + SDL_ShowCursor(SDL_DISABLE); + +#ifdef __IPHONEOS__ + // SDL defaults to OGL ES2, which doesn't work on old devices + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); +#else + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif + + m_Renderer = SDL_CreateRenderer(m_Win, -1, 0); + if (!m_Renderer) return E_FAIL; + + m_Active = true; + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Flip() { + +#ifdef __IPHONEOS__ + // hack: until viewports work correctly, we just paint black bars instead + SDL_SetRenderDrawColor(m_Renderer, 0x00, 0x00, 0x00, 0xFF); + + static bool firstRefresh = true; // prevents a weird color glitch + if (firstRefresh) { + firstRefresh = false; + } else { + SDL_Rect rect; + if (m_BorderLeft > 0) { + rect.x = 0; + rect.y = 0; + rect.w = m_BorderLeft; + rect.h = m_RealHeight; + SDL_RenderFillRect(m_Renderer, &rect); + } + if (m_BorderRight > 0) { + rect.x = (m_RealWidth - m_BorderRight); + rect.y = 0; + rect.w = m_BorderRight; + rect.h = m_RealHeight; + SDL_RenderFillRect(m_Renderer, &rect); + } + if (m_BorderTop > 0) { + rect.x = 0; + rect.y = 0; + rect.w = m_RealWidth; + rect.h = m_BorderTop; + SDL_RenderFillRect(m_Renderer, &rect); + } + if (m_BorderBottom > 0) { + rect.x = 0; + rect.y = m_RealHeight - m_BorderBottom; + rect.w = m_RealWidth; + rect.h = m_BorderBottom; + SDL_RenderFillRect(m_Renderer, &rect); + } + } +#endif + + + SDL_RenderPresent(m_Renderer); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { + SDL_SetRenderDrawColor(m_Renderer, r, g, b, 0xFF); + SDL_RenderClear(m_Renderer); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Fade(WORD Alpha) { + uint32 dwAlpha = 255 - Alpha; + return FadeToColor(dwAlpha << 24); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { + SDL_Rect fillRect; + + if (rect) { + fillRect.x = rect->left; + fillRect.y = rect->top; + fillRect.w = rect->right - rect->left; + fillRect.h = rect->bottom - rect->top; + } else { + RECT rc; + Game->GetCurrentViewportRect(&rc); + fillRect.x = rc.left; + fillRect.y = rc.top; + fillRect.w = rc.right - rc.left; + fillRect.h = rc.bottom - rc.top; + } + ModTargetRect(&fillRect); + + byte r = D3DCOLGetR(Color); + byte g = D3DCOLGetG(Color); + byte b = D3DCOLGetB(Color); + byte a = D3DCOLGetA(Color); + + SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); + SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); + SDL_RenderFillRect(m_Renderer, &fillRect); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { + byte r = D3DCOLGetR(Color); + byte g = D3DCOLGetG(Color); + byte b = D3DCOLGetB(Color); + byte a = D3DCOLGetA(Color); + + SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); + SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); + + POINT point1, point2; + point1.x = X1; + point1.y = Y1; + PointToScreen(&point1); + + point2.x = X2; + point2.y = Y2; + PointToScreen(&point2); + + + SDL_RenderDrawLine(m_Renderer, point1.x, point1.y, point2.x, point2.y); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderSDL::TakeScreenshot() { +// TODO: Fix this +#if 0 + SDL_Rect viewport; + + SDL_RenderGetViewport(m_Renderer, &viewport); + + SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); + if (!surface) return NULL; + + if (SDL_RenderReadPixels(m_Renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + + FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + + int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); + + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + byte *bits = FreeImage_GetScanLine(dib, y); + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + memcpy(bits, src, bytespp * viewport.w); + } + + return new CBImage(Game, dib); +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::SwitchFullscreen() { + if (m_Windowed) SDL_SetWindowFullscreen(m_Win, SDL_TRUE); + else SDL_SetWindowFullscreen(m_Win, SDL_FALSE); + + m_Windowed = !m_Windowed; + + Game->m_Registry->WriteBool("Video", "Windowed", m_Windowed); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBRenderSDL::GetName() { + if (m_Name.empty()) { + if (m_Renderer) { + SDL_RendererInfo info; + SDL_GetRendererInfo(m_Renderer, &info); + m_Name = AnsiString(info.name); + } + } + return m_Name.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { + SDL_Rect rect; + rect.x = left + m_BorderLeft; + rect.y = top + m_BorderTop; + rect.w = (right - left) * m_RatioX; + rect.h = (bottom - top) * m_RatioY; + + // TODO fix this once viewports work correctly in SDL/landscape +#ifndef __IPHONEOS__ + SDL_RenderSetViewport(GetSdlRenderer(), &rect); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::ModTargetRect(SDL_Rect *rect) { + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + rect->x = MathUtil::Round(rect->x * m_RatioX + m_BorderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * m_RatioY + m_BorderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * m_RatioX); + rect->h = MathUtil::RoundUp(rect->h * m_RatioY); +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::PointFromScreen(POINT *point) { + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = point->x / m_RatioX - m_BorderLeft / m_RatioX + viewportRect.x; + point->y = point->y / m_RatioY - m_BorderTop / m_RatioY + viewportRect.y; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::PointToScreen(POINT *point) { + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = MathUtil::RoundUp(point->x * m_RatioX) + m_BorderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * m_RatioY) + m_BorderTop - viewportRect.y; + +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::DumpData(char *Filename) { + FILE *f = fopen(Filename, "wt"); + if (!f) return; + + CBSurfaceStorage *Mgr = Game->m_SurfaceStorage; + + int TotalKB = 0; + int TotalLoss = 0; + fprintf(f, "Filename;Usage;Size;KBytes\n"); + for (int i = 0; i < Mgr->m_Surfaces.GetSize(); i++) { + CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->m_Surfaces[i]; + if (!Surf->m_Filename) continue; + if (!Surf->m_Valid) continue; + + fprintf(f, "%s;%d;", Surf->m_Filename, Surf->m_ReferenceCount); + fprintf(f, "%dx%d;", Surf->GetWidth(), Surf->GetHeight()); + + int kb = Surf->GetWidth() * Surf->GetHeight() * 4 / 1024; + + TotalKB += kb; + fprintf(f, "%d;", kb); + fprintf(f, "\n"); + } + fprintf(f, "Total %d;;;%d\n", Mgr->m_Surfaces.GetSize(), TotalKB); + + + fclose(f); + Game->LOG(0, "Texture Stats Dump completed."); + Game->QuickMessage("Texture Stats Dump completed."); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h new file mode 100644 index 0000000000..3489881e14 --- /dev/null +++ b/engines/wintermute/BRenderSDL.h @@ -0,0 +1,95 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_SDL_H +#define WINTERMUTE_BRENDERER_SDL_H + +#include "BRenderer.h" +#include "SDL.h" + +namespace WinterMute { + +class CBRenderSDL : public CBRenderer { +public: + CBRenderSDL(CBGame *inGame); + ~CBRenderSDL(); + + const char *GetName(); + + HRESULT InitRenderer(int width, int height, bool windowed); + HRESULT Flip(); + HRESULT Fill(byte r, byte g, byte b, RECT *rect); + + HRESULT Fade(WORD Alpha); + HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + + HRESULT SwitchFullscreen(); + + HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + + CBImage *TakeScreenshot(); + + SDL_Renderer *GetSdlRenderer() const { + return m_Renderer; + } + SDL_Window *GetSdlWindow() const { + return m_Win; + } + + HRESULT SetViewport(int left, int top, int right, int bottom); + + void ModTargetRect(SDL_Rect *rect); + void PointFromScreen(POINT *point); + void PointToScreen(POINT *point); + + void DumpData(char *Filename); + + float GetScaleRatioX() const { + return m_RatioX; + } + float GetScaleRatioY() const { + return m_RatioY; + } + +private: + SDL_Renderer *m_Renderer; + SDL_Window *m_Win; + AnsiString m_Name; + + int m_BorderLeft; + int m_BorderTop; + int m_BorderRight; + int m_BorderBottom; + + float m_RatioX; + float m_RatioY; +}; + +} // end of namespace WinterMute + +#endif // __WmeBRenderSDL_H__ diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp new file mode 100644 index 0000000000..aaaca902fa --- /dev/null +++ b/engines/wintermute/BRenderer.cpp @@ -0,0 +1,259 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BActiveRect.h" +#include "BRenderer.h" +#include "BSurface.h" +#include "BSubFrame.h" +#include "BRegion.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { + m_Instance = NULL; + m_Window = NULL; + m_ClipperWindow = NULL; + m_Active = false; + m_Ready = false; + m_Windowed = true; + m_ForceAlphaColor = 0x00; + + m_Width = m_Height = m_BPP = 0; + CBPlatform::SetRectEmpty(&m_MonitorRect); + + m_RealWidth = m_RealHeight = 0; + m_DrawOffsetX = m_DrawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBRenderer::~CBRenderer() { + DeleteRectList(); + UnclipCursor(); +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::InitLoop() { + DeleteRectList(); +} + + +////////////////////////////////////////////////////////////////////// +CBObject *CBRenderer::GetObjectAt(int X, int Y) { + POINT point; + point.x = X; + point.y = Y; + + for (int i = m_RectList.GetSize() - 1; i >= 0; i--) { + if (CBPlatform::PtInRect(&m_RectList[i]->m_Rect, point)) { + if (m_RectList[i]->m_Precise) { + // frame + if (m_RectList[i]->m_Frame) { + int XX = (int)((m_RectList[i]->m_Frame->m_Rect.left + X - m_RectList[i]->m_Rect.left + m_RectList[i]->m_OffsetX) / (float)((float)m_RectList[i]->m_ZoomX / (float)100)); + int YY = (int)((m_RectList[i]->m_Frame->m_Rect.top + Y - m_RectList[i]->m_Rect.top + m_RectList[i]->m_OffsetY) / (float)((float)m_RectList[i]->m_ZoomY / (float)100)); + + if (m_RectList[i]->m_Frame->m_MirrorX) { + int Width = m_RectList[i]->m_Frame->m_Rect.right - m_RectList[i]->m_Frame->m_Rect.left; + XX = Width - XX; + } + + if (m_RectList[i]->m_Frame->m_MirrorY) { + int Height = m_RectList[i]->m_Frame->m_Rect.bottom - m_RectList[i]->m_Frame->m_Rect.top; + YY = Height - YY; + } + + if (!m_RectList[i]->m_Frame->m_Surface->IsTransparentAt(XX, YY)) return m_RectList[i]->m_Owner; + } + // region + else if (m_RectList[i]->m_Region) { + if (m_RectList[i]->m_Region->PointInRegion(X + m_RectList[i]->m_OffsetX, Y + m_RectList[i]->m_OffsetY)) return m_RectList[i]->m_Owner; + } + } else return m_RectList[i]->m_Owner; + } + } + + return (CBObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderer::DeleteRectList() { + for (int i = 0; i < m_RectList.GetSize(); i++) { + delete m_RectList[i]; + } + m_RectList.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SwitchFullscreen() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Flip() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::InitRenderer(int width, int height, bool windowed) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::OnWindowChange() { +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Fill(byte r, byte g, byte b, RECT *rect) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::WindowedBlt() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Setup2D(bool Force) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetupLines() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { + for (int i = 0; i < Width; i++) { + DrawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up + DrawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down + + DrawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left + DrawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Fade(WORD Alpha) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::FadeToColor(uint32 Color, RECT *rect) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetScreenViewport() { + return SetViewport(m_DrawOffsetX, m_DrawOffsetY, m_Width + m_DrawOffsetX, m_Height + m_DrawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetViewport(RECT *Rect) { + return SetViewport(Rect->left + m_DrawOffsetX, + Rect->top + m_DrawOffsetY, + Rect->right + m_DrawOffsetX, + Rect->bottom + m_DrawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderer::TakeScreenshot() { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::ClipCursor() { + /* + if(!m_Windowed) + { + RECT rc; + GetWindowRect(m_Window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = m_DrawOffsetX; + rc.top = m_DrawOffsetY; + rc.right = rc.left + m_Width; + rc.bottom = rc.top + m_Height; + + ::ClipCursor(&rc); + } + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::UnclipCursor() { + /* + if(!m_Windowed) ::ClipCursor(NULL); + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::PointInViewport(POINT *P) { + if (P->x < m_DrawOffsetX) return false; + if (P->y < m_DrawOffsetY) return false; + if (P->x > m_DrawOffsetX + m_Width) return false; + if (P->y > m_DrawOffsetY + m_Height) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h new file mode 100644 index 0000000000..c1180a5ef5 --- /dev/null +++ b/engines/wintermute/BRenderer.h @@ -0,0 +1,124 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_H +#define WINTERMUTE_BRENDERER_H + + +#include "coll_templ.h" +#include "BBase.h" + +namespace WinterMute { + +class CBImage; +class CBActiveRect; +class CBObject; + +class CBRenderer: public CBBase { +public: + int m_RealWidth; + int m_RealHeight; + int m_DrawOffsetX; + int m_DrawOffsetY; + + virtual void DumpData(char *Filename) {}; + virtual CBImage *TakeScreenshot(); + virtual HRESULT SetViewport(int left, int top, int right, int bottom); + virtual HRESULT SetViewport(RECT *Rect); + virtual HRESULT SetScreenViewport(); + virtual HRESULT Fade(WORD Alpha); + virtual HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); + CBRenderer(CBGame *inGame = NULL); + virtual ~CBRenderer(); + virtual HRESULT SetProjection() { + return S_OK; + }; + + virtual HRESULT WindowedBlt(); + virtual HRESULT Fill(byte r, byte g, byte b, RECT *rect = NULL); + virtual void OnWindowChange(); + virtual HRESULT InitRenderer(int width, int height, bool windowed); + virtual HRESULT Flip(); + virtual void InitLoop(); + virtual HRESULT SwitchFullscreen(); + virtual HRESULT Setup2D(bool Force = false); + virtual HRESULT SetupLines(); + + virtual const char *GetName() { + return ""; + }; + virtual HRESULT DisplayDebugInfo() { + return E_FAIL; + }; + virtual HRESULT DrawShaderQuad() { + return E_FAIL; + } + + virtual float GetScaleRatioX() const { + return 1.0f; + } + virtual float GetScaleRatioY() const { + return 1.0f; + } + + HRESULT ClipCursor(); + HRESULT UnclipCursor(); + + CBObject *GetObjectAt(int X, int Y); + void DeleteRectList(); + + virtual HRESULT StartSpriteBatch() { + return S_OK; + }; + virtual HRESULT EndSpriteBatch() { + return S_OK; + }; + bool PointInViewport(POINT *P); + uint32 m_ForceAlphaColor; + HINSTANCE m_Instance; + HWND m_Window; + HWND m_ClipperWindow; + bool m_Active; + bool m_Ready; + bool m_Windowed; + RECT m_WindowRect; + RECT m_ViewportRect; + RECT m_ScreenRect; + RECT m_MonitorRect; + int m_BPP; + int m_Height; + int m_Width; + + CBArray m_RectList; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp new file mode 100644 index 0000000000..84811d0e73 --- /dev/null +++ b/engines/wintermute/BResourceFile.cpp @@ -0,0 +1,103 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BResourceFile.h" +#include "BResources.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { + m_Data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::~CBResourceFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Open(Common::String Filename) { + Close(); + + if (CBResources::GetFile(Filename.c_str(), m_Data, m_Size)) { + m_Pos = 0; + return S_OK; + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Close() { + m_Data = NULL; + m_Pos = 0; + m_Size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { + if (!m_Data || m_Pos + Size > m_Size) return E_FAIL; + + memcpy(Buffer, (byte *)m_Data + m_Pos, Size); + m_Pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { + if (!m_Data) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = m_Size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = m_Pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > m_Size) return E_FAIL; + else m_Pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BResourceFile.h b/engines/wintermute/BResourceFile.h new file mode 100644 index 0000000000..4d995d674d --- /dev/null +++ b/engines/wintermute/BResourceFile.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCEFILE_H +#define WINTERMUTE_BRESOURCEFILE_H + +#include "BFile.h" + +namespace WinterMute { + +class CBResourceFile : public CBFile { +public: + CBResourceFile(CBGame *inGame); + virtual ~CBResourceFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(Common::String Filename); +private: + byte *m_Data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BResources.cpp b/engines/wintermute/BResources.cpp new file mode 100644 index 0000000000..dceade0984 --- /dev/null +++ b/engines/wintermute/BResources.cpp @@ -0,0 +1,2830 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "PlatformSDL.h" +#include "BResources.h" +#include "common/str.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + + +////////////////////////////////////////////////////////////////////////// +bool CBResources::GetFile(const char *fileName, byte*& buffer, uint32 &size) { + // better! + if (scumm_stricmp(fileName, "invalid.bmp") == 0) { + buffer = invalid; + size = sizeof(invalid); + return true; + } else if (scumm_stricmp(fileName, "invalid_debug.bmp") == 0) { + buffer = invaliddebug; + size = sizeof(invaliddebug); + return true; + } else if (scumm_stricmp(fileName, "system_font.bmp") == 0) { + buffer = systemfont; + size = sizeof(systemfont); + return true; + } + + + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BResources.h b/engines/wintermute/BResources.h new file mode 100644 index 0000000000..ff8c050fa8 --- /dev/null +++ b/engines/wintermute/BResources.h @@ -0,0 +1,41 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +namespace WinterMute { + +class CBResources { +public: + static bool GetFile(const char *fileName, byte*& buffer, uint32 &size); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSaveThumbFile.cpp b/engines/wintermute/BSaveThumbFile.cpp new file mode 100644 index 0000000000..aeba924684 --- /dev/null +++ b/engines/wintermute/BSaveThumbFile.cpp @@ -0,0 +1,146 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BGame.h" +#include "BSaveThumbFile.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + m_Data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Open(Common::String Filename) { + Close(); + + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; + + char *TempFilename = new char[strlen(Filename.c_str()) - 8]; + strcpy(TempFilename, Filename.c_str() + 9); + for (int i = 0; i < strlen(TempFilename); i++) { + if (TempFilename[i] < '0' || TempFilename[i] > '9') { + TempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int Slot = atoi(TempFilename); + delete [] TempFilename; + + char SlotFilename[MAX_PATH + 1]; + Game->GetSaveSlotFilename(Slot, SlotFilename); + CBPersistMgr *pm = new CBPersistMgr(Game); + if (!pm) return E_FAIL; + + Game->m_DEBUG_AbsolutePathWarning = false; + if (FAILED(pm->InitLoad(SlotFilename))) { + Game->m_DEBUG_AbsolutePathWarning = true; + delete pm; + return E_FAIL; + } + Game->m_DEBUG_AbsolutePathWarning = true; + + HRESULT res; + + if (pm->m_ThumbnailDataSize != 0) { + m_Data = new byte[pm->m_ThumbnailDataSize]; + memcpy(m_Data, pm->m_ThumbnailData, pm->m_ThumbnailDataSize); + m_Size = pm->m_ThumbnailDataSize; + res = S_OK; + } else res = E_FAIL; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Close() { + delete[] m_Data; + m_Data = NULL; + + m_Pos = 0; + m_Size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { + if (!m_Data || m_Pos + Size > m_Size) return E_FAIL; + + memcpy(Buffer, (byte *)m_Data + m_Pos, Size); + m_Pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { + if (!m_Data) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = m_Size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = m_Pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > m_Size) return E_FAIL; + else m_Pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbFile.h b/engines/wintermute/BSaveThumbFile.h new file mode 100644 index 0000000000..7c22eda237 --- /dev/null +++ b/engines/wintermute/BSaveThumbFile.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "BFile.h" + +namespace WinterMute { + +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(Common::String Filename); +private: + byte *m_Data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSaveThumbHelper.cpp b/engines/wintermute/BSaveThumbHelper.cpp new file mode 100644 index 0000000000..3342f7aa3a --- /dev/null +++ b/engines/wintermute/BSaveThumbHelper.cpp @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BSaveThumbHelper.h" +#include "BImage.h" +#include "BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + m_Thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete m_Thumbnail; + m_Thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { + delete m_Thumbnail; + m_Thumbnail = NULL; + + if (Game->m_ThumbnailWidth > 0 && Game->m_ThumbnailHeight > 0) { + if (DoFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + Game->DisplayContent(false); + Game->m_Renderer->Flip(); + + Game->DisplayContent(false); + Game->m_Renderer->Flip(); + } + + CBImage *Screenshot = Game->m_Renderer->TakeScreenshot(); + if (!Screenshot) return E_FAIL; + + // normal thumbnail + if (Game->m_ThumbnailWidth > 0 && Game->m_ThumbnailHeight > 0) { + m_Thumbnail = new CBImage(Game); + m_Thumbnail->CopyFrom(Screenshot, Game->m_ThumbnailWidth, Game->m_ThumbnailHeight); + } + + + delete Screenshot; + Screenshot = NULL; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbHelper.h b/engines/wintermute/BSaveThumbHelper.h new file mode 100644 index 0000000000..6c1e411f5f --- /dev/null +++ b/engines/wintermute/BSaveThumbHelper.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "BBase.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + HRESULT StoreThumbnail(bool DoFlip = false); + + CBImage *m_Thumbnail; + CBImage *m_RichThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp new file mode 100644 index 0000000000..96ed14461c --- /dev/null +++ b/engines/wintermute/BScriptHolder.cpp @@ -0,0 +1,470 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "dcgf.h" +#include "AdGame.h" +#include "BScriptHolder.h" +#include "BParser.h" +#include "ScValue.h" +#include "ScEngine.h" +#include "ScScript.h" +#include "ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + SetName(""); + + m_Freezable = true; + m_Filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Cleanup() { + delete[] m_Filename; + m_Filename = NULL; + + int i; + + for (i = 0; i < m_Scripts.GetSize(); i++) { + m_Scripts[i]->Finish(true); + m_Scripts[i]->m_Owner = NULL; + } + m_Scripts.RemoveAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::SetFilename(char *Filename) { + if (m_Filename != NULL) delete [] m_Filename; + + m_Filename = new char [strlen(Filename) + 1]; + if (m_Filename != NULL) strcpy(m_Filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { + int NumHandlers = 0; + + HRESULT ret = E_FAIL; + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (!m_Scripts[i]->m_Thread) { + CScScript *handler = m_Scripts[i]->InvokeEventHandler(EventName, Unbreakable); + if (handler) { + //m_Scripts.Add(handler); + NumHandlers++; + ret = S_OK; + } + } + } + if (NumHandlers > 0 && Unbreakable) Game->m_ScEngine->TickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "DEBUG_CrashMe") == 0) { + Stack->CorrectParams(0); + byte *p = 0; + *p = 10; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ApplyEvent") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + HRESULT ret; + ret = ApplyEvent(val->GetString()); + + if (SUCCEEDED(ret)) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CanHandleEvent") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(CanHandleEvent(Stack->Pop()->GetString())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CanHandleMethod") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(CanHandleMethod(Stack->Pop()->GetString())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AttachScript") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(SUCCEEDED(AddScript(Stack->Pop()->GetString()))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DetachScript") == 0) { + Stack->CorrectParams(2); + char *Filename = Stack->Pop()->GetString(); + bool KillThreads = Stack->Pop()->GetBool(false); + bool ret = false; + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0) { + m_Scripts[i]->Finish(KillThreads); + ret = true; + break; + } + } + Stack->PushBool(ret); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsScriptRunning") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + bool ret = false; + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0 && m_Scripts[i]->m_State != SCRIPT_FINISHED && m_Scripts[i]->m_State != SCRIPT_ERROR) { + ret = true; + break; + } + } + Stack->PushBool(ret); + + return S_OK; + } else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("script_holder"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Filename") == 0) { + m_ScValue->SetString(m_Filename); + return m_ScValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } else return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBScriptHolder::ScToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return CBBase::SaveAsText(Buffer, Indent); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_Freezable)); + PersistMgr->Transfer(TMEMBER(m_Name)); + m_Scripts.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::AddScript(char *Filename) { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0) { + if (m_Scripts[i]->m_State != SCRIPT_FINISHED) { + Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, m_Name); + return S_OK; + } + } + } + + CScScript *scr = Game->m_ScEngine->RunScript(Filename, this); + if (!scr) { + if (Game->m_EditorForceScripts) { + // editor hack + scr = new CScScript(Game, Game->m_ScEngine); + scr->m_Filename = new char[strlen(Filename) + 1]; + strcpy(scr->m_Filename, Filename); + scr->m_State = SCRIPT_ERROR; + scr->m_Owner = this; + m_Scripts.Add(scr); + Game->m_ScEngine->m_Scripts.Add(scr); + Game->GetDebugMgr()->OnScriptInit(scr); + + return S_OK; + } + return E_FAIL; + } else { + scr->m_Freezable = m_Freezable; + m_Scripts.Add(scr); + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (m_Scripts[i] == Script) { + m_Scripts.RemoveAt(i); + break; + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::CanHandleEvent(char *EventName) { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (!m_Scripts[i]->m_Thread && m_Scripts[i]->CanHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::CanHandleMethod(char *MethodName) { + for (int i = 0; i < m_Scripts.GetSize(); i++) { + if (!m_Scripts[i]->m_Thread && m_Scripts[i]->CanHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + Game->LOG(0, "'PROPERTY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + char *PropName = NULL; + char *PropValue = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] PropName; + PropName = new char[strlen((char *)params) + 1]; + if (PropName) strcpy(PropName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] PropValue; + PropValue = new char[strlen((char *)params) + 1]; + if (PropValue) strcpy(PropValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Syntax error in PROPERTY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Error loading PROPERTY definition"); + return E_FAIL; + } + + + CScValue *val = new CScValue(Game); + val->SetString(PropValue); + ScSetProperty(PropName, val); + + delete val; + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::MakeFreezable(bool Freezable) { + m_Freezable = Freezable; + for (int i = 0; i < m_Scripts.GetSize(); i++) + m_Scripts[i]->m_Freezable = Freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::InvokeMethodThread(char *MethodName) { + for (int i = m_Scripts.GetSize() - 1; i >= 0; i--) { + if (m_Scripts[i]->CanHandleMethod(MethodName)) { + + CScScript *thread = new CScScript(Game, m_Scripts[i]->m_Engine); + if (thread) { + HRESULT ret = thread->CreateMethodThread(m_Scripts[i], MethodName); + if (SUCCEEDED(ret)) { + m_Scripts[i]->m_Engine->m_Scripts.Add(thread); + Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, m_Scripts[i], MethodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { + strcpy(Buf, ScToString()); + if (m_Name && strcmp(m_Name, "") != 0) { + strcat(Buf, " Name: "); + strcat(Buf, m_Name); + } + if (m_Filename) { + strcat(Buf, " File: "); + strcat(Buf, m_Filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::SendEvent(const char *EventName) { + return SUCCEEDED(ApplyEvent((char *)EventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp new file mode 100644 index 0000000000..b6261f8117 --- /dev/null +++ b/engines/wintermute/BSound.cpp @@ -0,0 +1,266 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "BSound.h" +#include "BGame.h" +#include "BSoundMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + m_Sound = NULL; + m_SoundFilename = NULL; + + m_SoundType = SOUND_SFX; + m_SoundStreamed = false; + m_SoundLooping = false; + m_SoundPlaying = false; + m_SoundPaused = false; + m_SoundFreezePaused = false; + m_SoundPosition = 0; + m_SoundPrivateVolume = 0; + m_SoundLoopStart = 0; + + m_SFXType = SFX_NONE; + m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (m_Sound) Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + + delete[] m_SoundFilename; + m_SoundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { + if (m_Sound) { + Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + } + delete[] m_SoundFilename; + m_SoundFilename = NULL; + + m_Sound = Game->m_SoundMgr->AddSound(Filename, Type, Streamed); + if (m_Sound) { + m_SoundFilename = new char[strlen(Filename) + 1]; + strcpy(m_SoundFilename, Filename); + + m_SoundType = Type; + m_SoundStreamed = Streamed; + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetSoundSimple() { + m_Sound = Game->m_SoundMgr->AddSound(m_SoundFilename, m_SoundType, m_SoundStreamed); + if (m_Sound) { + if (m_SoundPosition) m_Sound->SetPosition(m_SoundPosition); + m_Sound->SetLooping(m_SoundLooping); + m_Sound->SetPrivateVolume(m_SoundPrivateVolume); + m_Sound->SetLoopStart(m_SoundLoopStart); + m_Sound->m_FreezePaused = m_SoundFreezePaused; + if (m_SoundPlaying) return m_Sound->Resume(); + else return S_OK; + } else return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::GetLength() { + if (m_Sound) return m_Sound->GetLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Play(bool Looping) { + if (m_Sound) { + m_SoundPaused = false; + return m_Sound->Play(Looping, m_SoundPosition); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Stop() { + if (m_Sound) { + m_SoundPaused = false; + return m_Sound->Stop(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Pause(bool FreezePaused) { + if (m_Sound) { + m_SoundPaused = true; + if (FreezePaused) m_Sound->m_FreezePaused = true; + return m_Sound->Pause(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Resume() { + if (m_Sound && m_SoundPaused) { + m_SoundPaused = false; + return m_Sound->Resume(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { + if (PersistMgr->m_Saving && m_Sound) { + m_SoundPlaying = m_Sound->IsPlaying(); + m_SoundLooping = m_Sound->m_Looping; + m_SoundPrivateVolume = m_Sound->m_PrivateVolume; + if (m_SoundPlaying) m_SoundPosition = m_Sound->GetPosition(); + m_SoundLoopStart = m_Sound->m_LoopStart; + m_SoundFreezePaused = m_Sound->m_FreezePaused; + } + + if (PersistMgr->m_Saving) { + m_SFXType = SFX_NONE; + m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + } + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_SoundFilename)); + PersistMgr->Transfer(TMEMBER(m_SoundLooping)); + PersistMgr->Transfer(TMEMBER(m_SoundPaused)); + PersistMgr->Transfer(TMEMBER(m_SoundFreezePaused)); + PersistMgr->Transfer(TMEMBER(m_SoundPlaying)); + PersistMgr->Transfer(TMEMBER(m_SoundPosition)); + PersistMgr->Transfer(TMEMBER(m_SoundPrivateVolume)); + PersistMgr->Transfer(TMEMBER(m_SoundStreamed)); + PersistMgr->Transfer(TMEMBER_INT(m_SoundType)); + PersistMgr->Transfer(TMEMBER(m_SoundLoopStart)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::IsPlaying() { + return m_Sound && m_Sound->IsPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::IsPaused() { + return m_Sound && m_SoundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPositionTime(uint32 Time) { + if (!m_Sound) return E_FAIL; + m_SoundPosition = Time; + HRESULT ret = m_Sound->SetPosition(m_SoundPosition); + if (m_Sound->IsPlaying()) m_SoundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::GetPositionTime() { + if (!m_Sound) return 0; + + if (!m_Sound->IsPlaying()) return 0; + else return m_Sound->GetPosition(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetVolume(int Volume) { + if (!m_Sound) return E_FAIL; + else return m_Sound->SetPrivateVolume(Volume); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPrivateVolume(int Volume) { + if (!m_Sound) return E_FAIL; + else return m_Sound->m_PrivateVolume = Volume; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSound::GetVolume() { + if (!m_Sound) return 0; + else return m_Sound->m_PrivateVolume; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetLoopStart(uint32 Pos) { + if (!m_Sound) return E_FAIL; + else { + m_Sound->SetLoopStart(Pos); + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPan(float Pan) { + if (m_Sound) return m_Sound->SetPan(Pan); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { + if (!m_Sound) return S_OK; + + if (Type != m_SFXType || Param1 != m_SFXParam1 || Param2 != m_SFXParam2 || Param3 != m_SFXParam3 || Param4 != m_SFXParam4) { + HRESULT Ret = m_Sound->ApplyFX(Type, Param1, Param2, Param3, Param4); + + m_SFXType = Type; + m_SFXParam1 = Param1; + m_SFXParam2 = Param2; + m_SFXParam3 = Param3; + m_SFXParam4 = Param4; + + return Ret; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSound.h b/engines/wintermute/BSound.h new file mode 100644 index 0000000000..0320030c72 --- /dev/null +++ b/engines/wintermute/BSound.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "BBase.h" +#include "dctypes.h" // Added by ClassView +#include "BSoundBuffer.h" +#include "persistent.h" + +namespace WinterMute { + +class CBSound : public CBBase { +public: + HRESULT SetPan(float Pan); + int m_SoundPrivateVolume; + int GetVolume(); + HRESULT SetVolume(int Volume); + HRESULT SetPrivateVolume(int Volume); + HRESULT SetLoopStart(uint32 Pos); + uint32 GetPositionTime(); + HRESULT SetPositionTime(uint32 Time); + bool m_SoundPaused; + bool m_SoundFreezePaused; + bool IsPlaying(); + bool IsPaused(); + bool m_SoundPlaying; + bool m_SoundLooping; + uint32 m_SoundLoopStart; + uint32 m_SoundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + HRESULT Resume(); + HRESULT Pause(bool FreezePaused = false); + HRESULT Stop(); + HRESULT Play(bool Looping = false); + uint32 GetLength(); + bool m_SoundStreamed; + TSoundType m_SoundType; + char *m_SoundFilename; + HRESULT SetSoundSimple(); + HRESULT SetSound(char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + HRESULT ApplyFX(TSFXType Type = SFX_NONE, float Param1 = 0, float Param2 = 0, float Param3 = 0, float Param4 = 0); + +private: + TSFXType m_SFXType; + float m_SFXParam1; + float m_SFXParam2; + float m_SFXParam3; + float m_SFXParam4; + CBSoundBuffer *m_Sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp new file mode 100644 index 0000000000..48c63bf4d9 --- /dev/null +++ b/engines/wintermute/BSoundBuffer.cpp @@ -0,0 +1,384 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFile.h" +#include "BGame.h" +#include "BSoundMgr.h" +#include "BSoundBuffer.h" +#include "BFileManager.h" +#include "utils.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { +#if 0 + m_Stream = NULL; + m_Sync = NULL; + + m_Streamed = false; + m_Filename = NULL; + m_File = NULL; + m_PrivateVolume = 100; + + m_Looping = false; + m_LoopStart = 0; + + m_Type = SOUND_SFX; + + m_FreezePaused = false; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { +#if 0 + Stop(); + + if (m_Stream) { + BASS_StreamFree(m_Stream); + m_Stream = NULL; + } + + if (m_File) { + Game->m_FileManager->CloseFile(m_File); + m_File = NULL; + } + + SAFE_DELETE_ARRAY(m_Filename); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + m_Streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { +#if 0 + if (m_Stream) { + BASS_StreamFree(m_Stream); + m_Stream = NULL; + } + + if (m_File) Game->m_FileManager->CloseFile(m_File); + + m_File = Game->m_FileManager->OpenFile(Filename); + if (!m_File) { + Game->LOG(0, "Error opening sound file '%s'", Filename); + return E_FAIL; + } + + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + m_Stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)m_File); + if (!m_Stream) { + Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), Filename); + return E_FAIL; + } + + CBUtils::SetString(&m_Filename, Filename); + + /* + HRESULT res; + bool NewlyCreated = false; + + if(!m_SoundBuffer || ForceReload || m_Streamed){ + if(!m_File) m_File = Game->m_FileManager->OpenFile(Filename); + if(!m_File){ + Game->LOG(0, "Error opening sound file '%s'", Filename); + return E_FAIL; + } + // switch to streamed for big files + if(!m_Streamed && (m_File->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->m_ForceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!m_SoundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(m_File); + if(FAILED(res)){ + Game->LOG(res, "Error creating sound buffer for file '%s'", Filename); + return res; + } + } + + + + // store filename + if(!m_Filename){ + m_Filename = new char[strlen(Filename)+1]; + strcpy(m_Filename, Filename); + } + + // close file (if not streaming) + if(!m_Streamed && m_File){ + Game->m_FileManager->CloseFile(m_File); + m_File = NULL; + } + */ + + return S_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { +#if 0 + if (m_Stream) { + SetLooping(Looping); + BASS_ChannelPlay(m_Stream, TRUE); + } + return S_OK; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetLooping(bool looping) { +#if 0 + m_Looping = looping; + + if (m_Stream) { + BASS_ChannelFlags(m_Stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Resume() { +#if 0 + if (m_Stream) { + BASS_ChannelPlay(m_Stream, FALSE); + } + return S_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Stop() { +#if 0 + if (m_Stream) { + BASS_ChannelStop(m_Stream); + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Pause() { +#if 0 + if (m_Stream) { + BASS_ChannelPause(m_Stream); + } +#endif + return S_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::GetLength() { +#if 0 + QWORD len = BASS_ChannelGetLength(m_Stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(m_Stream, len); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetType(TSoundType Type) { + m_Type = Type; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetVolume(int Volume) { +#if 0 + if (m_Stream) { + BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { +#if 0 + m_PrivateVolume = Volume; + + switch (m_Type) { + case SOUND_SFX: + Volume = Game->m_SoundMgr->m_VolumeSFX; + break; + case SOUND_SPEECH: + Volume = Game->m_SoundMgr->m_VolumeSpeech; + break; + case SOUND_MUSIC: + Volume = Game->m_SoundMgr->m_VolumeMusic; + break; + } +#endif + return SetVolume(Volume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::IsPlaying() { +#if 0 + return m_FreezePaused || BASS_ChannelIsActive(m_Stream) == BASS_ACTIVE_PLAYING; +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::GetPosition() { +#if 0 + if (m_Stream) { + QWORD len = BASS_ChannelGetPosition(m_Stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(m_Stream, len); + } else return 0; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { +#if 0 + if (m_Stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(m_Stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(m_Stream, pos, BASS_POS_BYTE); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetLoopStart(uint32 Pos) { + m_LoopStart = Pos; +#if 0 + if (m_Stream) { + if (m_Sync) { + BASS_ChannelRemoveSync(m_Stream, m_Sync); + m_Sync = NULL; + } + if (m_LoopStart > 0) { + QWORD len = BASS_ChannelGetLength(m_Stream, BASS_POS_BYTE); + m_Sync = BASS_ChannelSetSync(m_Stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return S_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPan(float Pan) { +#if 0 + if (m_Stream) { + BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_PAN, Pan); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { +#if 0 + switch (Type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } +#endif + return S_OK; +} + +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::FileCloseProc(void *user) { + /* + CBFile* file = static_cast(user); + file->Game->m_FileManager->CloseFile(file); + */ +} + +////////////////////////////////////////////////////////////////////////// +QWORD CBSoundBuffer::FileLenProc(void *user) { + CBFile *file = static_cast(user); + return file->GetSize(); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::FileReadProc(void *buffer, uint32 length, void *user) { + CBFile *file = static_cast(user); + uint32 oldPos = file->GetPos(); + file->Read(buffer, length); + return file->GetPos() - oldPos; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBSoundBuffer::FileSeekProc(QWORD offset, void *user) { + CBFile *file = static_cast(user); + return SUCCEEDED(file->Seek(offset)); +} +#endif +} // end of namespace WinterMute diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h new file mode 100644 index 0000000000..4571612122 --- /dev/null +++ b/engines/wintermute/BSoundBuffer.h @@ -0,0 +1,95 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "BBase.h" +//#include "bass.h" + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + HRESULT Pause(); + HRESULT Play(bool Looping = false, uint32 StartSample = 0); + HRESULT Resume(); + HRESULT Stop(); + bool IsPlaying(); + + void SetLooping(bool looping); + + uint32 GetPosition(); + HRESULT SetPosition(uint32 Pos); + uint32 GetLength(); + + HRESULT SetLoopStart(uint32 Pos); + uint32 GetLoopStart() const { + return m_LoopStart; + } + + HRESULT SetPan(float Pan); + HRESULT SetPrivateVolume(int Volume); + HRESULT SetVolume(int Volume); + + void SetType(TSoundType Type); + + HRESULT LoadFromFile(const char *Filename, bool ForceReload = false); + void SetStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); + HRESULT ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); + + //HSTREAM m_Stream; + //HSYNC m_Sync; + + bool m_FreezePaused; + uint32 m_LoopStart; + TSoundType m_Type; + bool m_Looping; + CBFile *m_File; + char *m_Filename; + bool m_Streamed; + int m_PrivateVolume; + + /*static void CALLBACK LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user); + + static void CALLBACK FileCloseProc(void *user); + static QWORD CALLBACK FileLenProc(void *user); + static uint32 CALLBACK FileReadProc(void *buffer, uint32 length, void *user); + static BOOL CALLBACK FileSeekProc(QWORD offset, void *user);*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp new file mode 100644 index 0000000000..894a586ee4 --- /dev/null +++ b/engines/wintermute/BSoundMgr.cpp @@ -0,0 +1,330 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BSoundMgr.h" +#include "BRegistry.h" +#include "PathUtil.h" +#include "StringUtil.h" +#include "BGame.h" +#include "BFileManager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + m_SoundAvailable = false; + + m_VolumeSFX = m_VolumeSpeech = m_VolumeMusic = m_VolumeMaster = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + SaveSettings(); + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::Cleanup() { +#if 0 + for (int i = 0; i < m_Sounds.GetSize(); i++) delete m_Sounds[i]; + m_Sounds.RemoveAll(); + + BASS_Free(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::SaveSettings() { + if (m_SoundAvailable) { + Game->m_Registry->WriteInt("Audio", "MasterVolume", m_VolumeMaster); + + Game->m_Registry->WriteInt("Audio", "SFXVolume", m_VolumeSFX); + Game->m_Registry->WriteInt("Audio", "SpeechVolume", m_VolumeSpeech); + Game->m_Registry->WriteInt("Audio", "MusicVolume", m_VolumeMusic); + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::Initialize() { + m_SoundAvailable = false; +#if 0 + +#ifdef __IPHONEOS__ +#define BASS_CONFIG_IOS_MIXAUDIO 34 + BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); +#endif + + + if (HIWORD(BASS_GetVersion()) != BASSVERSION) { + Game->LOG(0, "An incorrect version of BASS was loaded"); + return E_FAIL; + } + + if (!BASS_Init(-1, 44100, 0, 0, NULL)) { + Game->LOG(0, "Can't initialize sound device"); + return E_FAIL; + } +#endif + + m_VolumeMaster = Game->m_Registry->ReadInt("Audio", "MasterVolume", 100); + + m_VolumeSFX = Game->m_Registry->ReadInt("Audio", "SFXVolume", 100); + m_VolumeSpeech = Game->m_Registry->ReadInt("Audio", "SpeechVolume", 100); + m_VolumeMusic = Game->m_Registry->ReadInt("Audio", "MusicVolume", 100); + +#if 0 + m_SoundAvailable = true; + SetMasterVolumePercent(m_VolumeMaster); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::InitLoop() { + if (!m_SoundAvailable) return S_OK; +#if 0 + + BASS_Update(500); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool Streamed) { + if (!m_SoundAvailable) return NULL; +#if 0 + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::GetExtension(Filename); + if (StringUtil::CompareNoCase(ext, ".wav")) { + AnsiString path = PathUtil::GetDirectoryName(Filename); + AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); + + AnsiString newFile = PathUtil::Combine(path, name + ".ogg"); + CBFile *file = Game->m_FileManager->OpenFile(newFile.c_str()); + if (file) { + Filename = newFile.c_str(); + Game->m_FileManager->CloseFile(file); + } + } + + sound = new CBSoundBuffer(Game); + if (!sound) return NULL; + + sound->SetStreaming(Streamed); + sound->SetType(Type); + + + HRESULT res = sound->LoadFromFile(Filename); + if (FAILED(res)) { + Game->LOG(res, "Error loading sound '%s'", Filename); + delete sound; + return NULL; + } + + // set volume appropriately + switch (Type) { + case SOUND_SFX: + sound->SetVolume(m_VolumeSFX); + break; + case SOUND_SPEECH: + sound->SetVolume(m_VolumeSpeech); + break; + case SOUND_MUSIC: + sound->SetVolume(m_VolumeMusic); + break; + } + + // register sound + m_Sounds.Add(sound); + + return sound; +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { + if (!Sound) return E_FAIL; +#if 0 + // set volume appropriately + switch (Type) { + case SOUND_SFX: + Sound->SetVolume(m_VolumeSFX); + break; + case SOUND_SPEECH: + Sound->SetVolume(m_VolumeSpeech); + break; + case SOUND_MUSIC: + Sound->SetVolume(m_VolumeMusic); + break; + } + + // register sound + m_Sounds.Add(Sound); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { +#if 0 + for (int i = 0; i < m_Sounds.GetSize(); i++) { + if (m_Sounds[i] == Sound) { + delete m_Sounds[i]; + m_Sounds.RemoveAt(i); + return S_OK; + } + } +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { + if (!m_SoundAvailable) return S_OK; +#if 0 + switch (Type) { + case SOUND_SFX: + m_VolumeSFX = Volume; + break; + case SOUND_SPEECH: + m_VolumeSpeech = Volume; + break; + case SOUND_MUSIC: + m_VolumeMusic = Volume; + break; + } + + for (int i = 0; i < m_Sounds.GetSize(); i++) { + if (m_Sounds[i]->m_Type == Type) m_Sounds[i]->SetVolume(Volume); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::SetVolumePercent(TSoundType Type, byte Percent) { + return SetVolume(Type, Percent); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::GetVolumePercent(TSoundType Type) { + int Volume; + switch (Type) { + case SOUND_SFX: + Volume = m_VolumeSFX; + break; + case SOUND_SPEECH: + Volume = m_VolumeSpeech; + break; + case SOUND_MUSIC: + Volume = m_VolumeMusic; + break; + } + + return (byte )Volume; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::SetMasterVolumePercent(byte Percent) { + m_VolumeMaster = Percent; +#if 0 + BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::GetMasterVolumePercent() { +#if 0 + uint32 val = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM); + return (float)val / 10000.0f * 100.0f; +#endif + return 0; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { +#if 0 + for (int i = 0; i < m_Sounds.GetSize(); i++) { + if (m_Sounds[i]->IsPlaying() && (m_Sounds[i]->m_Type != SOUND_MUSIC || IncludingMusic)) { + m_Sounds[i]->Pause(); + m_Sounds[i]->m_FreezePaused = true; + } + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::ResumeAll() { +#if 0 + for (int i = 0; i < m_Sounds.GetSize(); i++) { + if (m_Sounds[i]->m_FreezePaused) { + m_Sounds[i]->Resume(); + m_Sounds[i]->m_FreezePaused = false; + } + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::PosToPan(int X, int Y) { + float relPos = (float)X / ((float)Game->m_Renderer->m_Width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSoundMgr.h b/engines/wintermute/BSoundMgr.h new file mode 100644 index 0000000000..1ffc977211 --- /dev/null +++ b/engines/wintermute/BSoundMgr.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "coll_templ.h" +#include "BBase.h" +#include "BSoundBuffer.h" +//#include "bass.h" + +namespace WinterMute { + +class CBSoundMgr : public CBBase { +public: + float PosToPan(int X, int Y); + HRESULT ResumeAll(); + HRESULT PauseAll(bool IncludingMusic = true); + HRESULT Cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte GetMasterVolumePercent(); + HRESULT SetMasterVolumePercent(byte Percent); + byte GetVolumePercent(TSoundType Type); + HRESULT SetVolumePercent(TSoundType Type, byte Percent); + HRESULT SetVolume(TSoundType Type, int Volume); + uint32 m_VolumeOriginal; + int m_VolumeMaster; + int m_VolumeMusic; + int m_VolumeSpeech; + int m_VolumeSFX; + HRESULT RemoveSound(CBSoundBuffer *Sound); + CBSoundBuffer *AddSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + HRESULT AddSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); + HRESULT InitLoop(); + HRESULT Initialize(); + bool m_SoundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + CBArray m_Sounds; + void SaveSettings(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp new file mode 100644 index 0000000000..912fe18f99 --- /dev/null +++ b/engines/wintermute/BSprite.cpp @@ -0,0 +1,753 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BSprite.h" +#include "StringUtil.h" +#include "PathUtil.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "BSurface.h" +#include "BGame.h" +#include "BFrame.h" +#include "BSound.h" +#include "BSubFrame.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + m_EditorAllFrames = false; + m_Owner = Owner; + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::SetDefaults() { + m_CurrentFrame = -1; + m_Looping = false; + m_LastFrameTime = 0; + m_Filename = NULL; + m_Finished = false; + m_Changed = false; + m_Paused = false; + m_Continuous = false; + m_MoveX = m_MoveY = 0; + + m_EditorMuted = false; + m_EditorBgFile = NULL; + m_EditorBgOffsetX = m_EditorBgOffsetY = 0; + m_EditorBgAlpha = 0xFF; + m_Streamed = false; + m_StreamedKeepLoaded = false; + + SetName(""); + + m_Precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::Cleanup() { + CBScriptHolder::Cleanup(); + + for (int i = 0; i < m_Frames.GetSize(); i++) + delete m_Frames[i]; + m_Frames.RemoveAll(); + + SAFE_DELETE_ARRAY(m_EditorBgFile); + + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha) { + GetCurrentFrame(ZoomX, ZoomY); + if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return S_OK; + + // move owner if allowed to + if (m_Changed && m_Owner && m_Owner->m_Movable) { + m_Owner->m_PosX += m_MoveX; + m_Owner->m_PosY += m_MoveY; + m_Owner->AfterMove(); + + X = m_Owner->m_PosX; + Y = m_Owner->m_PosY; + } + + // draw frame + return Display(X, Y, Register, ZoomX, ZoomY, Alpha); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { + CBFile *File = Game->m_FileManager->OpenFile(Filename); + if (!File) { + Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); + if (Game->m_DEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); + else return LoadFile("invalid.bmp", LifeTime, CacheType); + } else { + Game->m_FileManager->CloseFile(File); + File = NULL; + } + + HRESULT ret; + + AnsiString ext = PathUtil::GetExtension(Filename); + if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, ".bmp") || StringUtil::CompareNoCase(ext, ".tga") || StringUtil::CompareNoCase(ext, ".png") || StringUtil::CompareNoCase(ext, ".jpg")) { + CBFrame *frame = new CBFrame(Game); + CBSubFrame *subframe = new CBSubFrame(Game); + subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); + if (subframe->m_Surface == NULL) { + Game->LOG(0, "Error loading simple sprite '%s'", Filename); + ret = E_FAIL; + delete frame; + delete subframe; + } else { + CBPlatform::SetRect(&subframe->m_Rect, 0, 0, subframe->m_Surface->GetWidth(), subframe->m_Surface->GetHeight()); + frame->m_Subframes.Add(subframe); + m_Frames.Add(frame); + m_CurrentFrame = 0; + ret = S_OK; + } + } else { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer) { + if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); + delete [] Buffer; + } + } + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + Cleanup(); + + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + Game->LOG(0, "'SPRITE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int frame_count = 1; + CBFrame *frame; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.ScanStr((char *)params, "%b", &m_Continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.ScanStr((char *)params, "%b", &m_EditorMuted); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.ScanStr((char *)params, "%b", &m_Looping); + break; + + case TOKEN_PRECISE: + parser.ScanStr((char *)params, "%b", &m_Precise); + break; + + case TOKEN_STREAMED: + parser.ScanStr((char *)params, "%b", &m_Streamed); + if (m_Streamed && LifeTime == -1) { + LifeTime = 500; + CacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.ScanStr((char *)params, "%b", &m_StreamedKeepLoaded); + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (Game->m_EditorMode) { + SAFE_DELETE_ARRAY(m_EditorBgFile); + m_EditorBgFile = new char[strlen((char *)params) + 1]; + if (m_EditorBgFile) strcpy(m_EditorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.ScanStr((char *)params, "%d", &m_EditorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.ScanStr((char *)params, "%d", &m_EditorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.ScanStr((char *)params, "%d", &m_EditorBgAlpha); + m_EditorBgAlpha = std::min(m_EditorBgAlpha, 255); + m_EditorBgAlpha = std::max(m_EditorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = LifeTime; + if (CacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(Game); + + if (FAILED(frame->LoadBuffer(params, FrameLifeTime, m_StreamedKeepLoaded))) { + delete frame; + Game->LOG(0, "Error parsing frame %d", frame_count); + return E_FAIL; + } + + m_Frames.Add(frame); + frame_count++; + if (m_CurrentFrame == -1) m_CurrentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SPRITE definition"); + return E_FAIL; + } + m_CanBreak = !m_Continuous; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::Reset() { + if (m_Frames.GetSize() > 0) m_CurrentFrame = 0; + else m_CurrentFrame = -1; + + KillAllSounds(); + + m_LastFrameTime = 0; + m_Finished = false; + m_MoveX = m_MoveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { + //if(m_Owner && m_Owner->m_Freezable && Game->m_State == GAME_FROZEN) return true; + + if (m_CurrentFrame == -1) return false; + + uint32 timer; + if (m_Owner && m_Owner->m_Freezable) timer = Game->m_Timer; + else timer = Game->m_LiveTimer; + + int LastFrame = m_CurrentFrame; + + // get current frame + if (!m_Paused && !m_Finished && timer >= m_LastFrameTime + m_Frames[m_CurrentFrame]->m_Delay && m_LastFrameTime != 0) { + if (m_CurrentFrame < m_Frames.GetSize() - 1) { + m_CurrentFrame++; + if (m_Continuous) m_CanBreak = (m_CurrentFrame == m_Frames.GetSize() - 1); + } else { + if (m_Looping) { + m_CurrentFrame = 0; + m_CanBreak = true; + } else { + m_Finished = true; + m_CanBreak = true; + } + } + + m_LastFrameTime = timer; + } + + m_Changed = (LastFrame != m_CurrentFrame || (m_Looping && m_Frames.GetSize() == 1)); + + if (m_LastFrameTime == 0) { + m_LastFrameTime = timer; + m_Changed = true; + if (m_Continuous) m_CanBreak = (m_CurrentFrame == m_Frames.GetSize() - 1); + } + + if (m_Changed) { + m_MoveX = m_Frames[m_CurrentFrame]->m_MoveX; + m_MoveY = m_Frames[m_CurrentFrame]->m_MoveY; + + if (ZoomX != 100 || ZoomY != 100) { + m_MoveX = (int)((float)m_MoveX * (float)(ZoomX / 100.0f)); + m_MoveY = (int)((float)m_MoveY * (float)(ZoomY / 100.0f)); + } + } + + return m_Changed; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return S_OK; + + // on change... + if (m_Changed) { + if (m_Frames[m_CurrentFrame]->m_KillSound) { + KillAllSounds(); + } + ApplyEvent("FrameChanged"); + m_Frames[m_CurrentFrame]->OneTimeDisplay(m_Owner, Game->m_EditorMode && m_EditorMuted); + } + + // draw frame + return m_Frames[m_CurrentFrame]->Draw(X - Game->m_OffsetX, Y - Game->m_OffsetY, Register, ZoomX, ZoomY, m_Precise, Alpha, m_EditorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::GetSurface() { + // only used for animated textures for 3D models + if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return NULL; + CBFrame *Frame = m_Frames[m_CurrentFrame]; + if (Frame && Frame->m_Subframes.GetSize() > 0) { + CBSubFrame *Subframe = Frame->m_Subframes[0]; + if (Subframe) return Subframe->m_Surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + + CBPlatform::SetRectEmpty(Rect); + for (int i = 0; i < m_Frames.GetSize(); i++) { + RECT frame; + RECT temp; + CBPlatform::CopyRect(&temp, Rect); + m_Frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); + CBPlatform::UnionRect(Rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SPRITE {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", m_Looping ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", m_Continuous ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", m_Precise ? "TRUE" : "FALSE"); + if (m_Streamed) { + Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", m_Streamed ? "TRUE" : "FALSE"); + + if (m_StreamedKeepLoaded) + Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", m_StreamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (m_EditorMuted) + Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", m_EditorMuted ? "TRUE" : "FALSE"); + + if (m_EditorBgFile) { + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", m_EditorBgFile); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", m_EditorBgOffsetX); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", m_EditorBgOffsetY); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", m_EditorBgAlpha); + } + + CBScriptHolder::SaveAsText(Buffer, Indent + 2); + + int i; + + // scripts + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + + for (i = 0; i < m_Frames.GetSize(); i++) { + m_Frames[i]->SaveAsText(Buffer, Indent + 2); + } + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { + CBScriptHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_CanBreak)); + PersistMgr->Transfer(TMEMBER(m_Changed)); + PersistMgr->Transfer(TMEMBER(m_Paused)); + PersistMgr->Transfer(TMEMBER(m_Continuous)); + PersistMgr->Transfer(TMEMBER(m_CurrentFrame)); + PersistMgr->Transfer(TMEMBER(m_EditorAllFrames)); + PersistMgr->Transfer(TMEMBER(m_EditorBgAlpha)); + PersistMgr->Transfer(TMEMBER(m_EditorBgFile)); + PersistMgr->Transfer(TMEMBER(m_EditorBgOffsetX)); + PersistMgr->Transfer(TMEMBER(m_EditorBgOffsetY)); + PersistMgr->Transfer(TMEMBER(m_EditorMuted)); + PersistMgr->Transfer(TMEMBER(m_Finished)); + + m_Frames.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_LastFrameTime)); + PersistMgr->Transfer(TMEMBER(m_Looping)); + PersistMgr->Transfer(TMEMBER(m_MoveX)); + PersistMgr->Transfer(TMEMBER(m_MoveY)); + PersistMgr->Transfer(TMEMBER(m_Owner)); + PersistMgr->Transfer(TMEMBER(m_Precise)); + PersistMgr->Transfer(TMEMBER(m_Streamed)); + PersistMgr->Transfer(TMEMBER(m_StreamedKeepLoaded)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetFrame") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= m_Frames.GetSize()) { + Script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushNative(m_Frames[Index], true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteFrame") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (Val->IsInt()) { + int Index = Val->GetInt(-1); + if (Index < 0 || Index >= m_Frames.GetSize()) { + Script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->GetNative(); + for (int i = 0; i < m_Frames.GetSize(); i++) { + if (m_Frames[i] == Frame) { + if (i == m_CurrentFrame) m_LastFrameTime = 0; + delete m_Frames[i]; + m_Frames.RemoveAt(i); + break; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + Reset(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddFrame") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBFrame *Frame = new CBFrame(Game); + if (Filename != NULL) { + CBSubFrame *Sub = new CBSubFrame(Game); + if (SUCCEEDED(Sub->SetSurface(Filename))) { + Sub->SetDefaultRect(); + Frame->m_Subframes.Add(Sub); + } else delete Sub; + } + m_Frames.Add(Frame); + + Stack->PushNative(Frame, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertFrame") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + if (Index < 0) Index = 0; + + CScValue *Val = Stack->Pop(); + char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBFrame *Frame = new CBFrame(Game); + if (Filename != NULL) { + CBSubFrame *Sub = new CBSubFrame(Game); + if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->m_Subframes.Add(Sub); + else delete Sub; + } + + if (Index >= m_Frames.GetSize()) m_Frames.Add(Frame); + else m_Frames.InsertAt(Index, Frame); + + Stack->PushNative(Frame, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pause") == 0) { + Stack->CorrectParams(0); + m_Paused = true; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Play") == 0) { + Stack->CorrectParams(0); + m_Paused = false; + Stack->PushNULL(); + return S_OK; + } + + else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("sprite"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumFrames") == 0) { + m_ScValue->SetInt(m_Frames.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CurrentFrame") == 0) { + m_ScValue->SetInt(m_CurrentFrame); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + m_ScValue->SetBool(m_Precise); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Looping") == 0) { + m_ScValue->SetBool(m_Looping); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Owner") == 0) { + if (m_Owner == NULL) m_ScValue->SetNULL(); + else m_ScValue->SetNative(m_Owner, true); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Finished") == 0) { + m_ScValue->SetBool(m_Finished); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Paused") == 0) { + m_ScValue->SetBool(m_Paused); + return m_ScValue; + } + + else return CBScriptHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "CurrentFrame") == 0) { + m_CurrentFrame = Value->GetInt(0); + if (m_CurrentFrame >= m_Frames.GetSize() || m_CurrentFrame < 0) { + m_CurrentFrame = -1; + } + m_LastFrameTime = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + m_Precise = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Looping") == 0) { + m_Looping = Value->GetBool(); + return S_OK; + } + + else return CBScriptHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBSprite::ScToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::KillAllSounds() { + for (int i = 0; i < m_Frames.GetSize(); i++) { + if (m_Frames[i]->m_Sound) m_Frames[i]->m_Sound->Stop(); + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h new file mode 100644 index 0000000000..01a89a6931 --- /dev/null +++ b/engines/wintermute/BSprite.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "coll_templ.h" +#include "BScriptHolder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + HRESULT KillAllSounds(); + CBSurface *GetSurface(); + char *m_EditorBgFile; + int m_EditorBgOffsetX; + int m_EditorBgOffsetY; + int m_EditorBgAlpha; + bool m_Streamed; + bool m_StreamedKeepLoaded; + void Cleanup(); + void SetDefaults(); + bool m_Precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool m_EditorAllFrames; + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + int m_MoveY; + int m_MoveX; + HRESULT Display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); + bool m_CanBreak; + bool m_EditorMuted; + bool m_Continuous; + void Reset(); + CBObject *m_Owner; + bool m_Changed; + bool m_Paused; + bool m_Finished; + HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + uint32 m_LastFrameTime; + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); + bool m_Looping; + int m_CurrentFrame; + HRESULT AddFrame(char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); + CBSprite(CBGame *inGame, CBObject *Owner = NULL); + virtual ~CBSprite(); + CBArray m_Frames; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp new file mode 100644 index 0000000000..e3bf2fd89b --- /dev/null +++ b/engines/wintermute/BStringTable.cpp @@ -0,0 +1,229 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "PlatformSDL.h" +#include "BFileManager.h" +#include "BGame.h" +#include "BStringTable.h" +#include "StringUtil.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + m_Strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDuplicities) { + if (Key == NULL || Val == NULL) return E_FAIL; + + if (scumm_stricmp(Key, "@right-to-left") == 0) { + Game->m_TextRTL = true; + return S_OK; + } + + std::string final_key = Key; + StringUtil::ToLowerCase(final_key); + + m_StringsIter = m_Strings.find(final_key); + if (m_StringsIter != m_Strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + + m_Strings[final_key] = Val; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::GetKey(const char *Str) { + if (Str == NULL || Str[0] != '/') return NULL; + + char *value = strchr((char *)Str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - Str]; + strncpy(key, Str + 1, value - Str - 1); + key[value - Str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + m_StringsIter = m_Strings.find(key); + if (m_StringsIter != m_Strings.end()) { + new_str = new char[m_StringsIter->second.length() + 1]; + strcpy(new_str, m_StringsIter->second.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = GetKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::Expand(char **Str, bool ForceExpand) { + if (Game->m_DoNotExpandStrings && !ForceExpand) return; + + if (Str == NULL || *Str == NULL || *Str[0] != '/') return; + + char *value = strchr(*Str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *Str]; + strncpy(key, *Str + 1, value - *Str - 1); + key[value - *Str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + m_StringsIter = m_Strings.find(key); + if (m_StringsIter != m_Strings.end()) { + new_str = new char[m_StringsIter->second.length() + 1]; + strcpy(new_str, m_StringsIter->second.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *Str; + *Str = new_str; + + if (strlen(*Str) > 0 && *Str[0] == '/') Expand(Str, ForceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { + if (Game->m_DoNotExpandStrings && !ForceExpand) return String; + + if (String == NULL || String[0] == '\0' || String[0] != '/') return String; + + const char *value = strchr(String + 1, '/'); + if (value == NULL) return String; + + char *key = new char[value - String]; + strncpy(key, String + 1, value - String - 1); + key[value - String - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + m_StringsIter = m_Strings.find(key); + if (m_StringsIter != m_Strings.end()) { + new_str = m_StringsIter->second.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return ExpandStatic(new_str, ForceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBStringTable::LoadFile(char *Filename, bool ClearOld) { + Game->LOG(0, "Loading string table..."); + + if (ClearOld) m_Strings.clear(); + + uint32 Size; + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename, &Size); + if (Buffer == NULL) { + Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + int Pos = 0; + + if (Size > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { + Pos += 3; + if (Game->m_TextEncoding != TEXT_UTF8) { + Game->m_TextEncoding = TEXT_UTF8; + //Game->m_TextEncoding = TEXT_ANSI; + Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else Game->m_TextEncoding = TEXT_ANSI; + + int LineLength = 0; + while (Pos < Size) { + LineLength = 0; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *line = new char[RealLength + 1]; + strncpy(line, (char *)&Buffer[Pos], RealLength); + line[RealLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (int i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + AddString(line, value, ClearOld); + } else if (line[0] != '\0') AddString(line, "", ClearOld); + } + + delete [] line; + Pos += LineLength + 1; + } + + delete [] Buffer; + + Game->LOG(0, " %d strings loaded", m_Strings.size()); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h new file mode 100644 index 0000000000..6b28f5307d --- /dev/null +++ b/engines/wintermute/BStringTable.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include +#include "BBase.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *ExpandStatic(const char *String, bool ForceExpand = false); + HRESULT LoadFile(char *Filename, bool DeleteAll = true); + void Expand(char **Str, bool ForceExpand = false); + HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + std::map m_Strings; + char *GetKey(const char *Str); +private: + std::map::iterator m_StringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp new file mode 100644 index 0000000000..415bcc7b52 --- /dev/null +++ b/engines/wintermute/BSubFrame.cpp @@ -0,0 +1,588 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BParser.h" +#include "BSubFrame.h" +#include "BActiveRect.h" +#include "BDynBuffer.h" +#include "BSurface.h" +#include "ScValue.h" +#include "ScStack.h" +#include "BGame.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + m_Surface = NULL; + m_HotspotX = m_HotspotY = 0; + m_Alpha = 0xFFFFFFFF; + m_Transparent = 0xFFFF00FF; + + CBPlatform::SetRectEmpty(&m_Rect); + + m_EditorSelected = false; + + m_SurfaceFilename = NULL; + m_CKDefault = true; + m_CKRed = m_CKBlue = m_CKGreen = 0; + m_LifeTime = -1; + m_KeepLoaded = false; + + m_2DOnly = m_3DOnly = false; + m_Decoration = false; + + m_MirrorX = m_MirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (m_Surface) Game->m_SurfaceStorage->RemoveSurface(m_Surface); + delete[] m_SurfaceFilename; + m_SurfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + RECT rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custom_trans = false; + CBPlatform::SetRectEmpty(&rect); + char *surface_file = NULL; + + delete m_Surface; + m_Surface = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custom_trans = true; + break; + + case TOKEN_RECT: + parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.ScanStr(params, "%d,%d", &m_HotspotX, &m_HotspotY); + break; + + case TOKEN_2D_ONLY: + parser.ScanStr(params, "%b", &m_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.ScanStr(params, "%b", &m_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.ScanStr(params, "%b", &m_MirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.ScanStr(params, "%b", &m_MirrorY); + break; + + case TOKEN_DECORATION: + parser.ScanStr(params, "%b", &m_Decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr(params, "%b", &m_EditorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SUBFRAME definition"); + return E_FAIL; + } + + if (surface_file != NULL) { + if (custom_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + } + + m_Alpha = DRGBA(ar, ag, ab, alpha); + if (custom_trans) m_Transparent = DRGBA(r, g, b, 0xFF); + + /* + if(m_Surface == NULL) + { + Game->LOG(0, "Error parsing sub-frame. Image not set."); + return E_FAIL; + } + */ + if (CBPlatform::IsRectEmpty(&rect)) SetDefaultRect(); + else m_Rect = rect; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (!m_Surface) return S_OK; + + if (Register != NULL && !m_Decoration) { + if (ZoomX == 100 && ZoomY == 100) { + Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, Register, this, X - m_HotspotX + m_Rect.left, Y - m_HotspotY + m_Rect.top, m_Rect.right - m_Rect.left, m_Rect.bottom - m_Rect.top, ZoomX, ZoomY, Precise)); + } else { + Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (m_HotspotX + m_Rect.left) * (ZoomX / 100)), (int)(Y - (m_HotspotY + m_Rect.top) * (ZoomY / 100)), (int)((m_Rect.right - m_Rect.left) * (ZoomX / 100)), (int)((m_Rect.bottom - m_Rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); + } + } + if (Game->m_SuspendedRendering) return S_OK; + + HRESULT res; + + //if(Alpha==0xFFFFFFFF) Alpha = m_Alpha; // TODO: better (combine owner's and self alpha) + if (m_Alpha != 0xFFFFFFFF) Alpha = m_Alpha; + + if (Rotate != 0.0f) { + res = m_Surface->DisplayTransform((int)(X - m_HotspotX * (ZoomX / 100)), (int)(Y - m_HotspotY * (ZoomY / 100)), m_HotspotX, m_HotspotY, m_Rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, m_MirrorX, m_MirrorY); + } else { + if (ZoomX == 100 && ZoomY == 100) res = m_Surface->DisplayTrans(X - m_HotspotX, Y - m_HotspotY, m_Rect, Alpha, BlendMode, m_MirrorX, m_MirrorY); + else res = m_Surface->DisplayTransZoom((int)(X - m_HotspotX * (ZoomX / 100)), (int)(Y - m_HotspotY * (ZoomY / 100)), m_Rect, ZoomX, ZoomY, Alpha, BlendMode, m_MirrorX, m_MirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + + float RatioX = ScaleX / 100.0f; + float RatioY = ScaleY / 100.0f; + + CBPlatform::SetRect(Rect, + X - m_HotspotX * RatioX, + Y - m_HotspotY * RatioY, + X - m_HotspotX * RatioX + (m_Rect.right - m_Rect.left)*RatioX, + Y - m_HotspotY * RatioY + (m_Rect.bottom - m_Rect.top)*RatioY); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { + if (Complete) + Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); + + if (m_Surface && m_Surface->m_Filename != NULL) + Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", m_Surface->m_Filename); + + if (m_Transparent != 0xFFFF00FF) + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(m_Transparent), D3DCOLGetG(m_Transparent), D3DCOLGetB(m_Transparent)); + + RECT rect; + CBPlatform::SetRectEmpty(&rect); + if (m_Surface) CBPlatform::SetRect(&rect, 0, 0, m_Surface->GetWidth(), m_Surface->GetHeight()); + if (!CBPlatform::EqualRect(&rect, &m_Rect)) + Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", m_Rect.left, m_Rect.top, m_Rect.right, m_Rect.bottom); + + if (m_HotspotX != 0 || m_HotspotY != 0) + Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", m_HotspotX, m_HotspotY); + + if (m_Alpha != 0xFFFFFFFF) { + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_Alpha), D3DCOLGetG(m_Alpha), D3DCOLGetB(m_Alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_Alpha)); + } + + if (m_MirrorX) + Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", m_MirrorX ? "TRUE" : "FALSE"); + + if (m_MirrorY) + Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", m_MirrorY ? "TRUE" : "FALSE"); + + if (m_2DOnly) + Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", m_2DOnly ? "TRUE" : "FALSE"); + + if (m_3DOnly) + Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", m_3DOnly ? "TRUE" : "FALSE"); + + if (m_Decoration) + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", m_Decoration ? "TRUE" : "FALSE"); + + if (m_EditorSelected) + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + + if (Complete) + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::SetDefaultRect() { + if (m_Surface) { + CBPlatform::SetRect(&m_Rect, 0, 0, m_Surface->GetWidth(), m_Surface->GetHeight()); + } else CBPlatform::SetRectEmpty(&m_Rect); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_2DOnly)); + PersistMgr->Transfer(TMEMBER(m_3DOnly)); + PersistMgr->Transfer(TMEMBER(m_Alpha)); + PersistMgr->Transfer(TMEMBER(m_Decoration)); + PersistMgr->Transfer(TMEMBER(m_EditorSelected)); + PersistMgr->Transfer(TMEMBER(m_HotspotX)); + PersistMgr->Transfer(TMEMBER(m_HotspotY)); + PersistMgr->Transfer(TMEMBER(m_Rect)); + + PersistMgr->Transfer(TMEMBER(m_SurfaceFilename)); + PersistMgr->Transfer(TMEMBER(m_CKDefault)); + PersistMgr->Transfer(TMEMBER(m_CKRed)); + PersistMgr->Transfer(TMEMBER(m_CKGreen)); + PersistMgr->Transfer(TMEMBER(m_CKBlue)); + PersistMgr->Transfer(TMEMBER(m_LifeTime)); + + PersistMgr->Transfer(TMEMBER(m_KeepLoaded)); + PersistMgr->Transfer(TMEMBER(m_MirrorX)); + PersistMgr->Transfer(TMEMBER(m_MirrorY)); + PersistMgr->Transfer(TMEMBER(m_Transparent)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetImage") == 0) { + Stack->CorrectParams(0); + + if (!m_SurfaceFilename) Stack->PushNULL(); + else Stack->PushString(m_SurfaceFilename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetImage") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsNULL()) { + if (m_Surface) Game->m_SurfaceStorage->RemoveSurface(m_Surface); + delete[] m_SurfaceFilename; + m_SurfaceFilename = NULL; + Stack->PushBool(true); + } else { + char *Filename = Val->GetString(); + if (SUCCEEDED(SetSurface(Filename))) { + SetDefaultRect(); + Stack->PushBool(true); + } else Stack->PushBool(false); + } + + return S_OK; + } + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::ScGetProperty(char *Name) { + if (!m_ScValue) m_ScValue = new CScValue(Game); + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("subframe"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + + m_ScValue->SetInt((int)m_Alpha); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TransparentColor") == 0) { + m_ScValue->SetInt((int)m_Transparent); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is2DOnly") == 0) { + m_ScValue->SetBool(m_2DOnly); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is3DOnly") == 0) { + m_ScValue->SetBool(m_3DOnly); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorX") == 0) { + m_ScValue->SetBool(m_MirrorX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorY") == 0) { + m_ScValue->SetBool(m_MirrorY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + m_ScValue->SetBool(m_Decoration); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotX") == 0) { + m_ScValue->SetInt(m_HotspotX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotY") == 0) { + m_ScValue->SetInt(m_HotspotY); + return m_ScValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "AlphaColor") == 0) { + m_Alpha = (uint32)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is2DOnly") == 0) { + m_2DOnly = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is3DOnly") == 0) { + m_3DOnly = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorX") == 0) { + m_MirrorX = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorY") == 0) { + m_MirrorY = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + m_Decoration = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotX") == 0) { + m_HotspotX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotY") == 0) { + m_HotspotY = Value->GetInt(); + return S_OK; + } + + else return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBSubFrame::ScToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SetSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + if (m_Surface) { + Game->m_SurfaceStorage->RemoveSurface(m_Surface); + m_Surface = NULL; + } + + delete[] m_SurfaceFilename; + m_SurfaceFilename = NULL; + + m_Surface = Game->m_SurfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + if (m_Surface) { + m_SurfaceFilename = new char[strlen(Filename) + 1]; + strcpy(m_SurfaceFilename, Filename); + + m_CKDefault = default_ck; + m_CKRed = ck_red; + m_CKGreen = ck_green; + m_CKBlue = ck_blue; + m_LifeTime = LifeTime; + m_KeepLoaded = KeepLoaded; + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SetSurfaceSimple() { + if (!m_SurfaceFilename) { + m_Surface = NULL; + return S_OK; + } + m_Surface = Game->m_SurfaceStorage->AddSurface(m_SurfaceFilename, m_CKDefault, m_CKRed, m_CKGreen, m_CKBlue, m_LifeTime, m_KeepLoaded); + if (m_Surface) return S_OK; + else return E_FAIL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h new file mode 100644 index 0000000000..6147b75811 --- /dev/null +++ b/engines/wintermute/BSubFrame.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "BBase.h" +#include "BScriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool m_MirrorX; + bool m_MirrorY; + bool m_Decoration; + HRESULT SetSurface(char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT SetSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void SetDefaultRect(); + uint32 m_Transparent; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); + bool m_EditorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + + int m_HotspotX; + int m_HotspotY; + uint32 m_Alpha; + RECT m_Rect; + + bool m_CKDefault; + byte m_CKRed; + byte m_CKGreen; + byte m_CKBlue; + int m_LifeTime; + bool m_KeepLoaded; + char *m_SurfaceFilename; + + bool m_2DOnly; + bool m_3DOnly; + + CBSurface *m_Surface; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSurface.cpp b/engines/wintermute/BSurface.cpp new file mode 100644 index 0000000000..16deda3c59 --- /dev/null +++ b/engines/wintermute/BSurface.cpp @@ -0,0 +1,196 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "wintypes.h" +#include "BGame.h" +#include "BSurface.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { + m_ReferenceCount = 0; + + m_Width = m_Height = 0; + + m_Filename = NULL; + + m_PixelOpReady = false; + + m_CKDefault = true; + m_CKRed = m_CKGreen = m_CKBlue = 0; + m_LifeTime = 0; + m_KeepLoaded = false; + + m_LastUsedTime = 0; + m_Valid = false; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface::~CBSurface() { + if (m_PixelOpReady) EndPixelOp(); + if (m_Filename) delete [] m_Filename; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Restore() { + return E_FAIL; +} + + + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::IsTransparentAt(int X, int Y) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayHalfTrans(int X, int Y, RECT rect) { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DisplayTransZoom(X, Y, Rect, ZoomX, ZoomY, Alpha, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Create(int Width, int Height) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::StartPixelOp() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::EndPixelOp() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::PutPixel(int X, int Y, byte R, byte G, byte B, int A) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::ComparePixel(int X, int Y, byte R, byte G, byte B, int A) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::IsTransparentAtLite(int X, int Y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Invalidate() { + return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::PrepareToDraw() { + m_LastUsedTime = Game->m_LiveTimer; + + if (!m_Valid) { + //Game->LOG(0, "Reviving: %s", m_Filename); + return Create(m_Filename, m_CKDefault, m_CKRed, m_CKGreen, m_CKBlue, m_LifeTime, m_KeepLoaded); + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSurface::SetFilename(const char *Filename) { + delete[] m_Filename; + m_Filename = NULL; + if (!Filename) return; + + m_Filename = new char[strlen(Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Filename); +} + +////////////////////////////////////////////////////////////////////////// +void CBSurface::SetSize(int Width, int Height) { + m_Width = Width; + m_Height = Height; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSurface.h b/engines/wintermute/BSurface.h new file mode 100644 index 0000000000..5fa355fcfa --- /dev/null +++ b/engines/wintermute/BSurface.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACE_H +#define WINTERMUTE_BSURFACE_H + +#include "BBase.h" + +namespace WinterMute { + +class CBSurface: public CBBase { +public: + virtual HRESULT Invalidate(); + virtual HRESULT PrepareToDraw(); + bool m_CKDefault; + byte m_CKRed; + byte m_CKGreen; + byte m_CKBlue; + + uint32 m_LastUsedTime; + bool m_Valid; + int m_LifeTime; + bool m_KeepLoaded; + + bool m_PixelOpReady; + CBSurface(CBGame *inGame); + virtual ~CBSurface(); + + virtual HRESULT DisplayHalfTrans(int X, int Y, RECT rect); + virtual bool IsTransparentAt(int X, int Y); + virtual HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); + virtual HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT Restore(); + virtual HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + virtual HRESULT Create(int Width, int Height); + virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); + virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); + virtual bool ComparePixel(int X, int Y, byte R, byte G, byte B, int A = -1); + virtual HRESULT StartPixelOp(); + virtual HRESULT EndPixelOp(); + virtual bool IsTransparentAtLite(int X, int Y); + void SetFilename(const char *Filename); + void SetSize(int Width, int Height); + + int m_ReferenceCount; + char *m_Filename; + + int GetWidth() { + return m_Width; + } + int GetHeight() { + return m_Height; + } + //void SetWidth(int Width){ m_Width = Width; } + //void SetHeight(int Height){ m_Height = Height; } +protected: + int m_Height; + int m_Width; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp new file mode 100644 index 0000000000..66c9256cf0 --- /dev/null +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -0,0 +1,402 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BFile.h" +#include "BGame.h" +#include "BSurfaceSDL.h" +#include "BRenderSDL.h" +#include "SdlUtil.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "stream.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { + m_Texture = NULL; + m_AlphaMask = NULL; + + m_LockPixels = NULL; + m_LockPitch = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBSurfaceSDL::~CBSurfaceSDL() { + if (m_Texture) SDL_DestroyTexture(m_Texture); + delete[] m_AlphaMask; + m_AlphaMask = NULL; + + Game->AddMem(-m_Width * m_Height * 4); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + Common::String strFileName(Filename); + + Graphics::ImageDecoder *imgDecoder; + + if (strFileName.hasSuffix(".png")) { + imgDecoder = new Graphics::PNGDecoder(); + } else if (strFileName.hasSuffix(".bmp")) { + imgDecoder = new Graphics::BitmapDecoder(); + } else { + error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); + } + + CBFile *file = Game->m_FileManager->OpenFile(Filename); + if (!file) return E_FAIL; + + imgDecoder->loadStream(*file->getMemStream()); + const Graphics::Surface *surface = imgDecoder->getSurface(); + Game->m_FileManager->CloseFile(file); + + if (default_ck) { + ck_red = 255; + ck_green = 0; + ck_blue = 255; + } + + m_Width = surface->w; + m_Height = surface->h; + + bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); +/* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ + } + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) +/* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { + FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + } else { + FreeImage_Unload(img); + return -1; + } + } + + FreeImage_FlipVertical(img);*/ + + //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: + uint32 rmask = surface->format.rMax() << surface->format.rShift; + uint32 gmask = surface->format.gMax() << surface->format.gShift; + uint32 bmask = surface->format.bMax() << surface->format.bShift; + uint32 amask = surface->format.aMax(); + + SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, m_Width, m_Height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); + + // no alpha, set color key + if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue)); + + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); + //m_Texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!m_Texture) { + SDL_FreeSurface(surf); + delete imgDecoder; + return E_FAIL; + } + + GenAlphaMask(surf); + + SDL_FreeSurface(surf); + delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. + + m_CKDefault = default_ck; + m_CKRed = ck_red; + m_CKGreen = ck_green; + m_CKBlue = ck_blue; + + + if (!m_Filename || scumm_stricmp(m_Filename, Filename) != 0) { + SetFilename(Filename); + } + + if (m_LifeTime == 0 || LifeTime == -1 || LifeTime > m_LifeTime) + m_LifeTime = LifeTime; + + m_KeepLoaded = KeepLoaded; + if (m_KeepLoaded) m_LifeTime = -1; + + m_Valid = true; + + Game->AddMem(m_Width * m_Height * 4); + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { + delete[] m_AlphaMask; + m_AlphaMask = NULL; + if (!surface) return; + + SDL_LockSurface(surface); + + bool hasColorKey; + Uint32 colorKey; + Uint8 ckRed, ckGreen, ckBlue; + if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + + m_AlphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + Uint32 pixel = GetPixel(surface, x, y); + + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + a = 0; + + m_AlphaMask[y * surface->w + x] = a; + if (a < 255) hasTransparency = true; + } + } + + SDL_UnlockSurface(surface); + + if (!hasTransparency) { + delete[] m_AlphaMask; + m_AlphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) { + int bpp = surface->format->BytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(Uint16 *)p; + break; + + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; + else + return p[0] | p[1] << 8 | p[2] << 16; + break; + + case 4: + return *(Uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Create(int Width, int Height) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + m_Texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); + + m_Width = Width; + m_Height = Height; + + Game->AddMem(m_Width * m_Height * 4); + + m_Valid = true; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); + + m_Width = surface->w; + m_Height = surface->h; + + Game->AddMem(m_Width * m_Height * 4); + + m_Valid = true; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { + int access; + int width, height; + SDL_QueryTexture(m_Texture, NULL, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + + StartPixelOp(); + bool ret = IsTransparentAtLite(X, Y); + EndPixelOp(); + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { + //if (!m_LockPixels) return false; + + Uint32 format; + int access; + int width, height; + SDL_QueryTexture(m_Texture, &format, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + if (!m_AlphaMask) return false; + else return m_AlphaMask[Y * width + X] <= 128; + + /* + Uint32* dst = (Uint32*)((Uint8*)m_LockPixels + Y * m_LockPitch); + Uint32 pixel = dst[X]; + + SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); + SDL_FreeFormat(pixelFormat); + + return a <= 128; + */ +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::StartPixelOp() { + //SDL_LockTexture(m_Texture, NULL, &m_LockPixels, &m_LockPitch); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::EndPixelOp() { + //SDL_UnlockTexture(m_Texture); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, 100, 100, 0xFFFFFFFF, true, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, !Transparent, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &Rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + + if (renderer->m_ForceAlphaColor != 0) Alpha = renderer->m_ForceAlphaColor; + + byte r = D3DCOLGetR(Alpha); + byte g = D3DCOLGetG(Alpha); + byte b = D3DCOLGetB(Alpha); + byte a = D3DCOLGetA(Alpha); + + SDL_SetTextureColorMod(m_Texture, r, g, b); + SDL_SetTextureAlphaMod(m_Texture, a); + + if (AlphaDisable) + SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_NONE); + else + SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_BLEND); + + SDL_Rect srcRect; + srcRect.x = Rect->left; + srcRect.y = Rect->top; + srcRect.w = Rect->right - Rect->left; + srcRect.h = Rect->bottom - Rect->top; + + SDL_Rect position; + position.x = X; + position.y = Y; + position.w = (float)srcRect.w * ZoomX / 100.f; + position.h = (float)srcRect.h * ZoomX / 100.f; + + renderer->ModTargetRect(&position); + + position.x += offsetX; + position.y += offsetY; + + SDL_RenderCopy(renderer->GetSdlRenderer(), m_Texture, &srcRect, &position); + + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h new file mode 100644 index 0000000000..e32bec90b1 --- /dev/null +++ b/engines/wintermute/BSurfaceSDL.h @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESDL_H +#define WINTERMUTE_BSURFACESDL_H + +#include "BSurface.h" +class SDL_Texture; +class SDL_Surface; +namespace WinterMute { + +class CBSurfaceSDL : public CBSurface { +public: + CBSurfaceSDL(CBGame *inGame); + ~CBSurfaceSDL(); + + HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + HRESULT Create(int Width, int Height); + + HRESULT CreateFromSDLSurface(SDL_Surface *surface); + + bool IsTransparentAt(int X, int Y); + bool IsTransparentAtLite(int X, int Y); + + HRESULT StartPixelOp(); + HRESULT EndPixelOp(); + + + HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); + HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + +/* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + +private: + SDL_Texture *m_Texture; + + HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); + void GenAlphaMask(SDL_Surface *surface); + uint32 GetPixel(SDL_Surface *surface, int x, int y); + + void *m_LockPixels; + int m_LockPitch; + byte *m_AlphaMask; +}; + +} // end of namespace WinterMute + +#endif // __WmeBSurfaceSDL_H__ diff --git a/engines/wintermute/BSurfaceStorage.cpp b/engines/wintermute/BSurfaceStorage.cpp new file mode 100644 index 0000000000..45f70db8f6 --- /dev/null +++ b/engines/wintermute/BSurfaceStorage.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BSurfaceStorage.h" +#include "BSurfaceSDL.h" +#include "BGame.h" +#include "BFileManager.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + m_LastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + Cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::Cleanup(bool Warn) { + for (int i = 0; i < m_Surfaces.GetSize(); i++) { + if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", m_Surfaces[i]->m_Filename, m_Surfaces[i]->m_ReferenceCount); + delete m_Surfaces[i]; + } + m_Surfaces.RemoveAll(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::InitLoop() { + if (Game->m_SmartCache && Game->m_LiveTimer - m_LastCleanupTime >= Game->m_SurfaceGCCycleTime) { + m_LastCleanupTime = Game->m_LiveTimer; + SortSurfaces(); + for (int i = 0; i < m_Surfaces.GetSize(); i++) { + if (m_Surfaces[i]->m_LifeTime <= 0) break; + + if (m_Surfaces[i]->m_LifeTime > 0 && m_Surfaces[i]->m_Valid && Game->m_LiveTimer - m_Surfaces[i]->m_LastUsedTime >= m_Surfaces[i]->m_LifeTime) { + //Game->QuickMessageForm("Invalidating: %s", m_Surfaces[i]->m_Filename); + m_Surfaces[i]->Invalidate(); + } + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { + for (int i = 0; i < m_Surfaces.GetSize(); i++) { + if (m_Surfaces[i] == surface) { + m_Surfaces[i]->m_ReferenceCount--; + if (m_Surfaces[i]->m_ReferenceCount <= 0) { + delete m_Surfaces[i]; + m_Surfaces.RemoveAt(i); + } + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::AddSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + for (int i = 0; i < m_Surfaces.GetSize(); i++) { + if (scumm_stricmp(m_Surfaces[i]->m_Filename, Filename) == 0) { + m_Surfaces[i]->m_ReferenceCount++; + return m_Surfaces[i]; + } + } + + CBFile *File = Game->m_FileManager->OpenFile(Filename); + if (!File) { + if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); + if (Game->m_DEBUG_DebugMode) + return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + else + return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + } else Game->m_FileManager->CloseFile(File); + + + CBSurface *surface; + surface = new CBSurfaceSDL(Game); + + + if (!surface) return NULL; + + if (FAILED(surface->Create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { + delete surface; + return NULL; + } else { + surface->m_ReferenceCount = 1; + m_Surfaces.Add(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::RestoreAll() { + HRESULT ret; + for (int i = 0; i < m_Surfaces.GetSize(); i++) { + ret = m_Surfaces[i]->Restore(); + if (ret != S_OK) { + Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return S_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) +{ + + if(!PersistMgr->m_Saving) Cleanup(false); + + PersistMgr->Transfer(TMEMBER(Game)); + + //m_Surfaces.Persist(PersistMgr); + + return S_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::SortSurfaces() { + qsort(m_Surfaces.GetData(), m_Surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::SurfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->m_LifeTime <= 0 && s2->m_LifeTime > 0) return 1; + else if (s1->m_LifeTime > 0 && s2->m_LifeTime <= 0) return -1; + + + // sort by validity + if (s1->m_Valid && !s2->m_Valid) return -1; + else if (!s1->m_Valid && s2->m_Valid) return 1; + + // sort by time + else if (s1->m_LastUsedTime > s2->m_LastUsedTime) return 1; + else if (s1->m_LastUsedTime < s2->m_LastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BSurfaceStorage.h b/engines/wintermute/BSurfaceStorage.h new file mode 100644 index 0000000000..5ebfe3c7d7 --- /dev/null +++ b/engines/wintermute/BSurfaceStorage.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + + +#include "coll_templ.h" +#include "BBase.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 m_LastCleanupTime; + HRESULT InitLoop(); + HRESULT SortSurfaces(); + static int SurfaceSortCB(const void *arg1, const void *arg2); + HRESULT Cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + HRESULT RestoreAll(); + CBSurface *AddSurface(char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT RemoveSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + CBArray m_Surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp new file mode 100644 index 0000000000..56703b3336 --- /dev/null +++ b/engines/wintermute/BTransitionMgr.cpp @@ -0,0 +1,126 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BTransitionMgr.h" +#include "BGame.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + m_State = TRANS_MGR_READY; + m_Type = TRANSITION_NONE; + m_OrigInteractive = false; + m_PreserveInteractive = false; + m_LastTime = 0; + m_Started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::IsReady() { + return (m_State == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { + if (m_State != TRANS_MGR_READY) return S_OK; + + if (Type == TRANSITION_NONE || Type >= NUM_TRANSITION_TYPES) { + m_State = TRANS_MGR_READY; + return S_OK; + } + + if (NonInteractive) { + m_PreserveInteractive = true; + m_OrigInteractive = Game->m_Interactive; + Game->m_Interactive = false; + } else m_PreserveInteractive; + + m_Type = Type; + m_State = TRANS_MGR_RUNNING; + m_Started = false; + + return S_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +HRESULT CBTransitionMgr::Update() { + if (IsReady()) return S_OK; + + if (!m_Started) { + m_Started = true; + m_LastTime = CBPlatform::GetTime(); + } + + switch (m_Type) { + case TRANSITION_NONE: + m_State = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::GetTime() - m_LastTime; + int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; + Alpha = std::min(255, std::max(Alpha, 0)); + Game->m_Renderer->Fade((WORD)Alpha); + + if (time > FADE_DURATION) m_State = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::GetTime() - m_LastTime; + int Alpha = (float)time / (float)FADE_DURATION * 255; + Alpha = std::min(255, std::max(Alpha, 0)); + Game->m_Renderer->Fade((WORD)Alpha); + + if (time > FADE_DURATION) m_State = TRANS_MGR_READY; + } + break; + + } + + if (IsReady()) { + if (m_PreserveInteractive) Game->m_Interactive = m_OrigInteractive; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BTransitionMgr.h b/engines/wintermute/BTransitionMgr.h new file mode 100644 index 0000000000..6bcf3ea89b --- /dev/null +++ b/engines/wintermute/BTransitionMgr.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "BBase.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool m_Started; + uint32 m_LastTime; + bool m_OrigInteractive; + bool m_PreserveInteractive; + HRESULT Update(); + HRESULT Start(TTransitionType Type, bool NonInteractive = false); + bool IsReady(); + TTransMgrState m_State; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType m_Type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/BViewport.cpp b/engines/wintermute/BViewport.cpp new file mode 100644 index 0000000000..bb2f5b6b29 --- /dev/null +++ b/engines/wintermute/BViewport.cpp @@ -0,0 +1,98 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "BGame.h" +#include "PlatformSDL.h" +#include "BViewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::SetRectEmpty(&m_Rect); + m_MainObject = NULL; + m_OffsetX = m_OffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_MainObject)); + PersistMgr->Transfer(TMEMBER(m_OffsetX)); + PersistMgr->Transfer(TMEMBER(m_OffsetY)); + PersistMgr->Transfer(TMEMBER(m_Rect)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoCheck) { + if (!NoCheck) { + left = std::max(left, 0); + top = std::max(top, 0); + right = std::min(right, Game->m_Renderer->m_Width); + bottom = std::min(bottom, Game->m_Renderer->m_Height); + } + + CBPlatform::SetRect(&m_Rect, left, top, right, bottom); + m_OffsetX = left; + m_OffsetY = top; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +RECT *CBViewport::GetRect() { + return &m_Rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::GetWidth() { + return m_Rect.right - m_Rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::GetHeight() { + return m_Rect.bottom - m_Rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/BViewport.h b/engines/wintermute/BViewport.h new file mode 100644 index 0000000000..06a5a1952f --- /dev/null +++ b/engines/wintermute/BViewport.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "BBase.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int GetHeight(); + int GetWidth(); + RECT *GetRect(); + HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int m_OffsetY; + int m_OffsetX; + CBObject *m_MainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + RECT m_Rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/PathUtil.cpp b/engines/wintermute/PathUtil.cpp new file mode 100644 index 0000000000..d7d632f398 --- /dev/null +++ b/engines/wintermute/PathUtil.cpp @@ -0,0 +1,196 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include +#include +#include "PathUtil.h" +#include "StringUtil.h" + + +#ifdef __WIN32__ +# include +#endif + +#ifdef __MACOSX__ +# include +#endif + +#ifdef __IPHONEOS__ +# include "ios_utils.h" +#endif + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::UnifySeparators(const AnsiString &path) { + AnsiString newPath = path; + + std::replace(newPath.begin(), newPath.end(), L'\\', L'/'); + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::NormalizeFileName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + StringUtil::ToLowerCase(newPath); + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::Combine(const AnsiString &path1, const AnsiString &path2) { + AnsiString newPath1 = UnifySeparators(path1); + AnsiString newPath2 = UnifySeparators(path2); + + if (!StringUtil::EndsWith(newPath1, "/", true) && !StringUtil::StartsWith(newPath2, "/", true)) + newPath1 += "/"; + + return newPath1 + newPath2; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetDirectoryName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + + size_t pos = newPath.find_last_of(L'/'); + + if (pos == AnsiString::npos) return ""; + else return newPath.substr(0, pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetFileName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + + size_t pos = newPath.find_last_of(L'/'); + + if (pos == AnsiString::npos) return path; + else return newPath.substr(pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { + AnsiString fileName = GetFileName(path); + + size_t pos = fileName.find_last_of('.'); + + if (pos == AnsiString::npos) return fileName; + else return fileName.substr(0, pos); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetExtension(const AnsiString &path) { + AnsiString fileName = GetFileName(path); + + size_t pos = fileName.find_last_of('.'); + + if (pos == AnsiString::npos) return ""; + else return fileName.substr(pos); +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetSafeLogFileName() { + AnsiString logFileName = GetUserDirectory(); + +#ifdef __WIN32__ + char moduleName[MAX_PATH]; + ::GetModuleFileName(NULL, moduleName, MAX_PATH); + + AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; + fileName = Combine("/Wintermute Engine/Logs/", fileName); + logFileName = Combine(logFileName, fileName); + +#else + // !PORTME + logFileName = Combine(logFileName, "/Wintermute Engine/wme.log"); +#endif + + CreateDirectory(GetDirectoryName(logFileName)); + return logFileName; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::CreateDirectory(const AnsiString &path) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::FileExists(const AnsiString &fileName) { + std::ifstream stream; + + stream.open(fileName.c_str()); + bool ret = stream.is_open(); + stream.close(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetUserDirectory() { + AnsiString userDir = "./"; + +#ifdef __WIN32__ + char buffer[MAX_PATH]; + buffer[0] = '\0'; + LPITEMIDLIST pidl = NULL; + LPMALLOC pMalloc; + if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); + if (pidl) { + SHGetPathFromIDList(pidl, buffer); + } + pMalloc->Free(pidl); + userDir = AnsiString(buffer); + } +#elif __MACOSX__ + FSRef fileRef; + OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); + if (error == noErr) { + char buffer[MAX_PATH]; + error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); + if (error == noErr) + userDir = buffer; + + } +#elif __IPHONEOS__ + char path[MAX_PATH]; + IOS_GetDataDir(path); + userDir = AnsiString(path); +#endif + + return userDir; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/PathUtil.h b/engines/wintermute/PathUtil.h new file mode 100644 index 0000000000..72dcf806b1 --- /dev/null +++ b/engines/wintermute/PathUtil.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPATHUTILS_H +#define WINTERMUTE_BPATHUTILS_H + +#include "PlatformSDL.h" + +namespace WinterMute { + +class PathUtil { +public: + static AnsiString UnifySeparators(const AnsiString &path); + static AnsiString NormalizeFileName(const AnsiString &path); + static AnsiString Combine(const AnsiString &path1, const AnsiString &path2); + static AnsiString GetDirectoryName(const AnsiString &path); + static AnsiString GetFileName(const AnsiString &path); + static AnsiString GetFileNameWithoutExtension(const AnsiString &path); + static AnsiString GetExtension(const AnsiString &path); + static bool CreateDirectory(const AnsiString &path); + static bool MatchesMask(const AnsiString &fileName, const AnsiString &mask); + + static bool FileExists(const AnsiString &fileName); + + static AnsiString GetSafeLogFileName(); + static AnsiString GetUserDirectory(); +}; + +} // end of namespace WinterMute + +#endif // __WmePathUtils_H__ diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index 6a42857615..f3b4e0c0db 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "dcgf.h" #include diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h index 20758ed0cd..80c95ced03 100644 --- a/engines/wintermute/StringUtil.h +++ b/engines/wintermute/StringUtil.h @@ -1,30 +1,33 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ -#ifndef __WmeStringUtil_H__ -#define __WmeStringUtil_H__ +#ifndef WINTERMUTE_STRINGUTIL_H +#define WINTERMUTE_STRINGUTIL_H #include "PlatformSDL.h" diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index ede3d41c22..48d7a2626e 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #ifndef WINTERMUTE_SYSCLASS_H #define WINTERMUTE_SYSCLASS_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 45708e2b84..a33861cd19 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -12,6 +12,7 @@ MODULE_OBJS := \ BNamedObject.o \ BParser.o \ BScriptable.o \ + BViewport.o \ detection.o \ SysClass.o \ SysInstance.o \ diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 5d0b7ee5fb..130e080e79 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -24,7 +24,6 @@ * This file is based on WME Lite. * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma - */ #ifndef WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index dd649d8afd..c69a0068b6 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "dcgf.h" #include "utils.h" diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h index 56d9876c5c..6fdac018ce 100644 --- a/engines/wintermute/utils.h +++ b/engines/wintermute/utils.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmeUtils_H__ -#define __WmeUtils_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UTILS_H +#define WINTERMUTE_UTILS_H #include "wintypes.h" -- cgit v1.2.3 From c609c778cceeaa6a70cf147451d7d894d76e40e7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 03:59:28 +0100 Subject: WINTERMUTE: Add most of the B-classes to module.mk --- engines/wintermute/BFrame.cpp | 24 ++++++------ engines/wintermute/BGame.cpp | 56 +++++++++++++-------------- engines/wintermute/BGame.h | 28 +++++++++----- engines/wintermute/BKeyboardState.cpp | 4 +- engines/wintermute/BRegion.cpp | 20 +++++----- engines/wintermute/BRegion.h | 4 +- engines/wintermute/BScriptHolder.h | 9 +++-- engines/wintermute/BSprite.cpp | 32 ++++++++-------- engines/wintermute/BSprite.h | 4 +- engines/wintermute/BSubFrame.cpp | 21 +++++----- engines/wintermute/Vector2.cpp | 52 +++++++++++++++++++++++++ engines/wintermute/Vector2.h | 72 +++++++++++++++++++++++++++++++++++ engines/wintermute/module.mk | 27 +++++++++++++ 13 files changed, 257 insertions(+), 96 deletions(-) create mode 100644 engines/wintermute/Vector2.cpp create mode 100644 engines/wintermute/Vector2.h (limited to 'engines') diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index 4d8d557a2a..4778a2f4b8 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -26,18 +26,18 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BParser.h" -#include "BFrame.h" -#include "BGame.h" -#include "BDynBuffer.h" -#include "ScValue.h" -#include "BSoundMgr.h" -#include "BSound.h" -#include "BSubFrame.h" -#include "ScScript.h" -#include "ScStack.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BFrame.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BSoundMgr.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 2c58641c33..319e0c5316 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -26,44 +26,44 @@ * Copyright (c) 2011 Jan Nedoma */ +#include #include "dcgf.h" #include "BGame.h" #include "BFile.h" -#include "BRegistry.h" -#include "BRenderSDL.h" -#include "BSurfaceSDL.h" -#include "BQuickMsg.h" -#include "scriptables/SXString.h" -#include "scriptables/SXDate.h" -#include "scriptables/SXArray.h" -#include "SxObject.h" -#include "scriptables/SXMemBuffer.h" -#include "SXFile.h" -#include "SXMath.h" -#include "SXStore.h" -#include "PathUtil.h" -#include -#include "crc.h" -#include "StringUtil.h" -#include "BParser.h" +#include "BFileManager.h" +#include "BFontTT.h" +#include "BFontStorage.h" #include "BImage.h" -#include "BTransitionMgr.h" #include "BKeyboardState.h" -#include "UIWindow.h" -#include "ScValue.h" -#include "BSoundMgr.h" +#include "BParser.h" +#include "BQuickMsg.h" +#include "BRegistry.h" +#include "BRenderSDL.h" #include "BSound.h" +#include "BSoundMgr.h" +#include "BSprite.h" #include "BSubFrame.h" +#include "BSurfaceSDL.h" +#include "BTransitionMgr.h" #include "BViewport.h" -#include "BFontStorage.h" -#include "BFontTT.h" -#include "ScEngine.h" #include "BStringTable.h" -#include "ScScript.h" #include "BRegion.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "ScStack.h" +#include "crc.h" +#include "PathUtil.h" +#include "StringUtil.h" +#include "UIWindow.h" +#include "scriptables/ScValue.h" +#include "scriptables/ScEngine.h" +#include "scriptables/ScStack.h" +#include "scriptables/ScScript.h" +#include "scriptables/SXArray.h" +#include "scriptables/SXDate.h" +#include "scriptables/SXString.h" +#include "scriptables/SXMemBuffer.h" +#include "scriptables/SxObject.h" +#include "scriptables/SXFile.h" +#include "scriptables/SXMath.h" +#include "scriptables/SXStore.h" #include "common/textconsole.h" #ifdef __IPHONEOS__ diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index b3df2b3046..2af7d834b1 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -55,6 +55,7 @@ class CUIWindow; class CBViewport; class CBRenderer; class CBRegistry; +class CBSaveThumbHelper; class CBSurfaceStorage; class CSXStore; class CSXMath; @@ -94,7 +95,7 @@ public: void GetMousePos(POINT *Pos); RECT m_MouseLockRect; - +#endif bool m_ShuttingDown; virtual HRESULT DisplayDebugInfo(); @@ -102,7 +103,7 @@ public: bool m_SuspendedRendering; int m_SoundBufferSizeSec; - +#if 0 TTextEncoding m_TextEncoding; bool m_TextRTL; @@ -153,7 +154,7 @@ public: void *m_EngineLogCallbackData; #endif bool m_EditorMode; -#if 0 + bool m_DoNotExpandStrings; void GetOffset(int *OffsetX, int *OffsetY); void SetOffset(int OffsetX, int OffsetY); @@ -163,19 +164,23 @@ public: float m_OffsetPercentX; float m_OffsetPercentY; CBObject *m_MainObject; +#if 0 HRESULT InitInput(HINSTANCE hInst, HWND hWnd); HRESULT InitLoop(); +#endif uint32 m_CurrentTime; uint32 m_DeltaTime; +#if 0 CBFont *m_SystemFont; CBFont *m_VideoFont; +#endif HRESULT Initialize1(); HRESULT Initialize2(); HRESULT Initialize3(); CBFileManager *m_FileManager; CBTransitionMgr *m_TransMgr; -#endif //TODO: STUB CBDebugger *GetDebugMgr(); +//TODO: STUB void LOG(HRESULT res, LPCSTR fmt, ...) {} CBRenderer *m_Renderer; @@ -186,12 +191,13 @@ public: CBSurfaceStorage *m_SurfaceStorage; CBFontStorage *m_FontStorage; CBGame(); -#if 0 + virtual ~CBGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *Filename = NULL); bool m_DEBUG_DebugMode; bool m_DEBUG_AbsolutePathWarning; +#if 0 FILE *m_DEBUG_LogFile; int m_Sequence; virtual HRESULT LoadFile(const char *Filename); @@ -249,7 +255,6 @@ public: int m_ScheduledLoadSlot; bool m_Loading; bool m_PersonalizedSave; -#if 0 HRESULT EmptySaveSlot(int Slot); bool IsSaveSlotUsed(int Slot); HRESULT GetSaveSlotDescription(int Slot, char *Buffer); @@ -258,6 +263,7 @@ public: virtual bool HandleMouseWheel(int Delta); bool m_Quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); +#if 0 virtual bool HandleKeypress(SDL_Event *event); int m_FreezeLevel; HRESULT Unfreeze(); @@ -286,6 +292,7 @@ public: int m_MusicCrossfadeChannel1; int m_MusicCrossfadeChannel2; HRESULT DisplayWindows(bool InGame = false); +#endif CBRegistry *m_Registry; bool m_UseD3D; virtual HRESULT Cleanup(); @@ -293,7 +300,7 @@ public: virtual HRESULT LoadGame(char *Filename); virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); virtual HRESULT ShowCursor(); -#endif + CBSprite *m_CursorNoninteractive; CBObject *m_ActiveObject; CBKeyboardState *m_KeyboardState; @@ -333,19 +340,20 @@ public: void SetInteractive(bool State); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); +#endif HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); HRESULT PopViewport(); HRESULT PushViewport(CBViewport *Viewport); HRESULT SetActiveObject(CBObject *Obj); - +#if 0 CBSprite *m_LastCursor; HRESULT DrawCursor(CBSprite *Cursor); virtual HRESULT InitAfterLoad(); - +#endif CBSaveThumbHelper *m_CachedThumbnail; - +#if 0 AnsiString GetDataDir(); void AddMem(int bytes); diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 7e89d9827c..055b2cf8c5 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -28,8 +28,8 @@ #include "dcgf.h" #include "BKeyboardState.h" -#include "ScValue.h" -#include "ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 309d44edab..699e60c60f 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -26,16 +26,16 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BRegion.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "ScValue.h" -#include "BGame.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BFileManager.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index 94202ea8dd..a218e6874a 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_BREGION_H #define WINTERMUTE_BREGION_H -#include "BPoint.h" -#include "BObject.h" +#include "engines/wintermute/BPoint.h" +#include "engines/wintermute/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index 6f37461431..cece043b88 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -38,14 +38,15 @@ namespace WinterMute { class CBScriptHolder : public CBScriptable { public: DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) -#if 0 + CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); - +#if 0 virtual CScScript *InvokeMethodThread(char *MethodName); virtual void MakeFreezable(bool Freezable); bool CanHandleEvent(char *EventName); virtual bool CanHandleMethod(char *EventMethod); +#endif HRESULT Cleanup(); HRESULT RemoveScript(CScScript *Script); HRESULT AddScript(char *Filename); @@ -54,12 +55,12 @@ public: HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); void SetFilename(char *Filename); HRESULT ParseProperty(byte *Buffer, bool Complete = true); - char *m_Filename; bool m_Freezable; bool m_Ready; - CBArray m_Scripts; + CBArray m_Scripts; +#if 0 // scripting interface virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index 912fe18f99..06ac69494b 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -26,22 +26,22 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BSprite.h" -#include "StringUtil.h" -#include "PathUtil.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "ScValue.h" -#include "BSurface.h" -#include "BGame.h" -#include "BFrame.h" -#include "BSound.h" -#include "BSubFrame.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BFileManager.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BSurface.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFrame.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index 01a89a6931..dd09fe0be1 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -30,8 +30,8 @@ #define WINTERMUTE_BSPRITE_H -#include "coll_templ.h" -#include "BScriptHolder.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/BScriptHolder.h" namespace WinterMute { class CBFrame; diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index 415bcc7b52..85f45156a0 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -26,16 +26,17 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BParser.h" -#include "BSubFrame.h" -#include "BActiveRect.h" -#include "BDynBuffer.h" -#include "BSurface.h" -#include "ScValue.h" -#include "ScStack.h" -#include "BGame.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BSurface.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/Vector2.cpp b/engines/wintermute/Vector2.cpp new file mode 100644 index 0000000000..6c8d0ae168 --- /dev/null +++ b/engines/wintermute/Vector2.cpp @@ -0,0 +1,52 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "Vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2() { + x = y = 0.0f; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2(float x, float y) { + this->x = x; + this->y = y; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::~Vector2() { +} + + +////////////////////////////////////////////////////////////////////////// +float Vector2::Length() const { + return sqrt(x * x + y * y); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Vector2.h b/engines/wintermute/Vector2.h new file mode 100644 index 0000000000..032a6f270b --- /dev/null +++ b/engines/wintermute/Vector2.h @@ -0,0 +1,72 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeVector2_H__ +#define __WmeVector2_H__ + +namespace WinterMute { + +class Vector2 { +public: + Vector2(); + Vector2(float x, float y); + ~Vector2(); + + float Length() const; + + inline Vector2 &operator= (const Vector2 &other) { + x = other.x; + y = other.y; + + return *this; + } + + inline Vector2 operator+ (const Vector2 &other) const { + return Vector2(x + other.x, y + other.y); + } + + inline Vector2 operator- (const Vector2 &other) const { + return Vector2(x - other.x, y - other.y); + } + + inline Vector2 operator* (const float scalar) const { + return Vector2(x * scalar, y * scalar); + } + + inline Vector2 &operator+= (const Vector2 &other) { + x += other.x; + y += other.y; + + return *this; + } + + + float x; + float y; +}; + +} // end of namespace WinterMute + +#endif // __WmeVector2_H__ diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index a33861cd19..e6847eb585 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -8,14 +8,41 @@ MODULE_OBJS := \ scriptables/SXDate.o \ scriptables/SXMath.o \ scriptables/SXMemBuffer.o \ + BActiveRect.o \ + BDebugger.o \ + BDynBuffer.o \ BBase.o \ + BFader.o \ + BFile.o \ + BFileEntry.o \ + BFrame.o \ + BImage.o \ BNamedObject.o \ + BPackage.o \ BParser.o \ + BPersistMgr.o \ + BPoint.o \ + BQuickMsg.o \ + BRegion.o \ + BResources.o \ + BResourceFile.o \ + BSaveThumbFile.o \ BScriptable.o \ + BSound.o \ + BSoundBuffer.o \ + BSoundMgr.o \ + BSprite.o \ + BSubFrame.o \ + BSurfaceStorage.o \ + BTransitionMgr.o \ BViewport.o \ + ConvertUTF.o \ detection.o \ + PathUtil.o \ + StringUtil.o \ SysClass.o \ SysInstance.o \ + utils.o \ wintermute.o MODULE_DIRS += \ -- cgit v1.2.3 From 5a2cf6f36ff5f8a75b1e34b00bd5444619eb4615 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 04:26:55 +0100 Subject: WINTERMUTE: Add the UI-classes. --- engines/wintermute/AdEntity.h | 67 ++ engines/wintermute/AdObject.h | 123 ++++ engines/wintermute/AdTalkHolder.h | 57 ++ engines/wintermute/AdTypes.h | 93 +++ engines/wintermute/BGame.h | 10 +- engines/wintermute/BScriptHolder.h | 2 - engines/wintermute/PartEmitter.h | 136 ++++ engines/wintermute/PartForce.h | 54 ++ engines/wintermute/PartParticle.h | 86 +++ engines/wintermute/UIButton.cpp | 1043 ++++++++++++++++++++++++++++ engines/wintermute/UIButton.h | 79 +++ engines/wintermute/UIEdit.cpp | 856 +++++++++++++++++++++++ engines/wintermute/UIEdit.h | 71 ++ engines/wintermute/UIEntity.cpp | 339 +++++++++ engines/wintermute/UIEntity.h | 58 ++ engines/wintermute/UIObject.cpp | 589 ++++++++++++++++ engines/wintermute/UIObject.h | 83 +++ engines/wintermute/UIText.cpp | 484 +++++++++++++ engines/wintermute/UIText.h | 59 ++ engines/wintermute/UITiledImage.cpp | 368 ++++++++++ engines/wintermute/UITiledImage.h | 62 ++ engines/wintermute/UIWindow.cpp | 1309 +++++++++++++++++++++++++++++++++++ engines/wintermute/UIWindow.h | 92 +++ engines/wintermute/module.mk | 4 + 24 files changed, 6118 insertions(+), 6 deletions(-) create mode 100644 engines/wintermute/AdEntity.h create mode 100644 engines/wintermute/AdObject.h create mode 100644 engines/wintermute/AdTalkHolder.h create mode 100644 engines/wintermute/AdTypes.h create mode 100644 engines/wintermute/PartEmitter.h create mode 100644 engines/wintermute/PartForce.h create mode 100644 engines/wintermute/PartParticle.h create mode 100644 engines/wintermute/UIButton.cpp create mode 100644 engines/wintermute/UIButton.h create mode 100644 engines/wintermute/UIEdit.cpp create mode 100644 engines/wintermute/UIEdit.h create mode 100644 engines/wintermute/UIEntity.cpp create mode 100644 engines/wintermute/UIEntity.h create mode 100644 engines/wintermute/UIObject.cpp create mode 100644 engines/wintermute/UIObject.h create mode 100644 engines/wintermute/UIText.cpp create mode 100644 engines/wintermute/UIText.h create mode 100644 engines/wintermute/UITiledImage.cpp create mode 100644 engines/wintermute/UITiledImage.h create mode 100644 engines/wintermute/UIWindow.cpp create mode 100644 engines/wintermute/UIWindow.h (limited to 'engines') diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h new file mode 100644 index 0000000000..b85cc123c6 --- /dev/null +++ b/engines/wintermute/AdEntity.h @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADENTITY_H +#define WINTERMUTE_ADENTITY_H + +#include "AdTalkHolder.h" + +namespace WinterMute { + +class CAdEntity : public CAdTalkHolder { +public: + HRESULT SetSprite(char *Filename); + int m_WalkToX; + int m_WalkToY; + TDirection m_WalkToDir; + void SetItem(char *ItemName); + char *m_Item; + DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) + void UpdatePosition(); + virtual int GetHeight(); + CBRegion *m_Region; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Update(); + virtual HRESULT Display(); + CAdEntity(CBGame *inGame); + virtual ~CAdEntity(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + TEntityType m_Subtype; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h new file mode 100644 index 0000000000..e5cb39e6b4 --- /dev/null +++ b/engines/wintermute/AdObject.h @@ -0,0 +1,123 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADOBJECT_H +#define WINTERMUTE_ADOBJECT_H + +#include "AdTypes.h" +#include "PartEmitter.h" + +namespace WinterMute { + +class CAdWaypointGroup; +class CAdRegion; +class CAdSentence; +class CBFont; +class CBRegion; +class CAdInventory; + +#define MAX_NUM_REGIONS 10 + +class CAdObject : public CBObject { +public: + CPartEmitter *m_PartEmitter; + virtual CPartEmitter *CreateParticleEmitter(bool FollowParent = false, int OffsetX = 0, int OffsetY = 0); + virtual HRESULT UpdatePartEmitter(); + bool m_PartFollowParent; + int m_PartOffsetX; + int m_PartOffsetY; + + HRESULT InvalidateCurrRegions(); + bool m_SubtitlesModRelative; + bool m_SubtitlesModXCenter; + int m_SubtitlesModX; + int m_SubtitlesModY; + int m_SubtitlesWidth; + CAdRegion *m_StickRegion; + bool m_SceneIndependent; + bool m_IgnoreItems; + HRESULT UpdateBlockRegion(); + bool m_ForcedTalkAnimUsed; + char *m_ForcedTalkAnimName; + virtual bool GetExtendedFlag(char *FlagName); + virtual HRESULT ResetSoundPan(); + virtual HRESULT UpdateSounds(); + HRESULT Reset(); + DECLARE_PERSISTENT(CAdObject, CBObject) + virtual void Talk(char *Text, char *Sound = NULL, uint32 Duration = 0, char *Stances = NULL, TTextAlign Align = TAL_CENTER); + virtual int GetHeight(); + CAdSentence *m_Sentence; + HRESULT SetFont(char *Filename); + virtual HRESULT Update(); + virtual HRESULT Display(); + bool m_Drawn; + bool m_Active; + virtual HRESULT PlayAnim(char *Filename); + CBSprite *m_AnimSprite; + CBSprite *m_CurrentSprite; + TObjectState m_State; + TObjectState m_NextState; + TObjectType m_Type; + CAdObject(CBGame *inGame); + virtual ~CAdObject(); + CBFont *m_Font; + CBSprite *m_TempSprite2; + CBRegion *m_BlockRegion; + CAdWaypointGroup *m_WptGroup; + CBRegion *m_CurrentBlockRegion; + CAdWaypointGroup *m_CurrentWptGroup; + CAdInventory *GetInventory(); + + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + virtual HRESULT AfterMove(); + CAdRegion *m_CurrentRegions[MAX_NUM_REGIONS]; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + + CBArray m_AttachmentsPre; + CBArray m_AttachmentsPost; + + HRESULT UpdateSpriteAttachments(); + HRESULT DisplaySpriteAttachments(bool PreDisplay); + CAdObject *m_RegisterAlias; +private: + HRESULT DisplaySpriteAttachment(CAdObject *Attachment); + CAdInventory *m_Inventory; + +protected: + HRESULT GetScale(float *ScaleX, float *ScaleY); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h new file mode 100644 index 0000000000..7eb07a8f66 --- /dev/null +++ b/engines/wintermute/AdTalkHolder.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKHOLDER_H +#define WINTERMUTE_ADTALKHOLDER_H + +#include "AdObject.h" + +namespace WinterMute { + +class CAdTalkHolder : public CAdObject { +public: + DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) + virtual CBSprite *GetTalkStance(char *Stance); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + CBSprite *m_Sprite; + CBArray m_TalkSprites; + CBArray m_TalkSpritesEx; + CAdTalkHolder(CBGame *inGame); + virtual ~CAdTalkHolder(); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdTypes.h b/engines/wintermute/AdTypes.h new file mode 100644 index 0000000000..8e77f289bc --- /dev/null +++ b/engines/wintermute/AdTypes.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTYPES_H +#define WINTERMUTE_ADTYPES_H + +namespace WinterMute { + +typedef enum { + GAME_NORMAL, GAME_WAITING_RESPONSE +} TGameStateEx; + + +typedef enum { + OBJECT_ENTITY, OBJECT_REGION, OBJECT_ACTOR, OBJECT_NONE +} TObjectType; + + +typedef enum { + ENTITY_NORMAL, ENTITY_SOUND +} TEntityType; + + +typedef enum { + STATE_NONE, + STATE_IDLE, + STATE_PLAYING_ANIM, + STATE_READY, + STATE_FOLLOWING_PATH, + STATE_SEARCHING_PATH, + STATE_WAITING_PATH, + STATE_TURNING_LEFT, + STATE_TURNING_RIGHT, + STATE_TURNING, + STATE_TALKING, + STATE_DIRECT_CONTROL, + STATE_PLAYING_ANIM_SET +} TObjectState; + +typedef enum { + DIRECT_WALK_NONE, DIRECT_WALK_FW, DIRECT_WALK_BK +} TDirectWalkMode; + +typedef enum { + DIRECT_TURN_NONE, DIRECT_TURN_CW, DIRECT_TURN_CCW +} TDirectTurnMode; + +typedef enum { + RESPONSE_TEXT, RESPONSE_ICON +} TResponseStyle; + +typedef enum { + RESPONSE_ALWAYS, RESPONSE_ONCE, RESPONSE_ONCE_GAME +} TResponseType; + + +typedef enum { + TALK_SKIP_LEFT = 0, TALK_SKIP_RIGHT = 1, TALK_SKIP_BOTH = 2, TALK_SKIP_NONE = 3 +} TTalkSkipButton; + + +typedef enum { + GEOM_WAYPOINT, GEOM_WALKPLANE, GEOM_BLOCKED, GEOM_GENERIC +} TGeomNodeType; + +} // end of namespace WinterMute + +#endif // __WmeAdTypes_H__ diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 2af7d834b1..a13144d325 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -170,10 +170,8 @@ public: #endif uint32 m_CurrentTime; uint32 m_DeltaTime; -#if 0 CBFont *m_SystemFont; CBFont *m_VideoFont; -#endif HRESULT Initialize1(); HRESULT Initialize2(); HRESULT Initialize3(); @@ -265,10 +263,12 @@ public: virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); #if 0 virtual bool HandleKeypress(SDL_Event *event); +#endif int m_FreezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); + bool m_LoadInProgress; CUIWindow *m_FocusedWindow; bool m_EditorForceScripts; @@ -278,6 +278,7 @@ public: static void AfterLoadFont(void *Font, void *Data); static void AfterLoadScript(void *script, void *data); static void InvalidateValues(void *Value, void *Data); +#if 0 HRESULT LoadSettings(char *Filename); HRESULT ResumeMusic(int Channel); HRESULT SetMusicStartTime(int Channel, uint32 Time); @@ -315,13 +316,14 @@ public: uint32 m_LiveTimer; uint32 m_LiveTimerDelta; uint32 m_LiveTimerLast; -#if 0 + CBObject *m_CapturedObject; +#if 0 POINT m_MousePos; +#endif bool ValidObject(CBObject *Object); HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); -#endif void QuickMessage(char *Text); #if 0 void QuickMessageForm(LPSTR fmt, ...); diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index cece043b88..84a1e73c46 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -41,12 +41,10 @@ public: CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); -#if 0 virtual CScScript *InvokeMethodThread(char *MethodName); virtual void MakeFreezable(bool Freezable); bool CanHandleEvent(char *EventName); virtual bool CanHandleMethod(char *EventMethod); -#endif HRESULT Cleanup(); HRESULT RemoveScript(CScScript *Script); HRESULT AddScript(char *Filename); diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h new file mode 100644 index 0000000000..d23b4db488 --- /dev/null +++ b/engines/wintermute/PartEmitter.h @@ -0,0 +1,136 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmePartEmitter_H__ +#define __WmePartEmitter_H__ + + +#include "BObject.h" +#include "PartParticle.h" +#include "PartForce.h" + +namespace WinterMute { +class CBRegion; + +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int m_Width; + int m_Height; + + int m_Angle1; + int m_Angle2; + + float m_Rotation1; + float m_Rotation2; + + float m_AngVelocity1; + float m_AngVelocity2; + + float m_GrowthRate1; + float m_GrowthRate2; + bool m_ExponentialGrowth; + + float m_Velocity1; + float m_Velocity2; + bool m_VelocityZBased; + + float m_Scale1; + float m_Scale2; + bool m_ScaleZBased; + + int m_MaxParticles; + + int m_LifeTime1; + int m_LifeTime2; + bool m_LifeTimeZBased; + + int m_GenInterval; + int m_GenAmount; + + bool m_Running; + int m_OverheadTime; + + int m_MaxBatches; + int m_BatchesGenerated; + + RECT m_Border; + int m_BorderThicknessLeft; + int m_BorderThicknessRight; + int m_BorderThicknessTop; + int m_BorderThicknessBottom; + + int m_FadeInTime; + int m_FadeOutTime; + + int m_Alpha1; + int m_Alpha2; + bool m_AlphaTimeBased; + + bool m_UseRegion; + + char *m_EmitEvent; + CBScriptHolder *m_Owner; + + HRESULT Start(); + + HRESULT Update(); + HRESULT Display(CBRegion *Region = NULL); + + HRESULT SortParticlesByZ(); + HRESULT AddSprite(char *Filename); + HRESULT RemoveSprite(char *Filename); + HRESULT SetBorder(int X, int Y, int Width, int Height); + HRESULT SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); + + HRESULT AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT RemoveForce(char *Name); + + CBArray m_Forces; + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + + +private: + CPartForce *AddForceByName(char *Name); + int static CompareZ(const void *Obj1, const void *Obj2); + HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); + HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); + uint32 m_LastGenTime; + CBArray m_Particles; + CBArray m_Sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/PartForce.h b/engines/wintermute/PartForce.h new file mode 100644 index 0000000000..140174eb4f --- /dev/null +++ b/engines/wintermute/PartForce.h @@ -0,0 +1,54 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmePartForce_H__ +#define __WmePartForce_H__ + + +#include "BBase.h" +#include "BNamedObject.h" +#include "Vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 m_Pos; + Vector2 m_Direction; + TForceType m_Type; + + HRESULT Persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/PartParticle.h b/engines/wintermute/PartParticle.h new file mode 100644 index 0000000000..eec3862b72 --- /dev/null +++ b/engines/wintermute/PartParticle.h @@ -0,0 +1,86 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmePartParticle_H__ +#define __WmePartParticle_H__ + + +#include "BBase.h" +#include "Vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float m_GrowthRate; + bool m_ExponentialGrowth; + + float m_Rotation; + float m_AngVelocity; + + int m_Alpha1; + int m_Alpha2; + + RECT m_Border; + Vector2 m_Pos; + float m_PosZ; + Vector2 m_Velocity; + float m_Scale; + CBSprite *m_Sprite; + uint32 m_CreationTime; + int m_LifeTime; + bool m_IsDead; + TParticleState m_State; + + HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); + HRESULT Display(CPartEmitter *Emitter); + + HRESULT SetSprite(char *Filename); + + HRESULT FadeIn(uint32 CurrentTime, int FadeTime); + HRESULT FadeOut(uint32 CurrentTime, int FadeTime); + + HRESULT Persist(CBPersistMgr *PersistMgr); +private: + uint32 m_FadeStart; + int m_FadeTime; + int m_CurrentAlpha; + int m_FadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp new file mode 100644 index 0000000000..1053cec166 --- /dev/null +++ b/engines/wintermute/UIButton.cpp @@ -0,0 +1,1043 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/UIButton.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIButton, false) + +////////////////////////////////////////////////////////////////////////// +CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { + m_BackPress = m_BackHover = m_BackDisable = m_BackFocus = NULL; + + m_FontHover = m_FontPress = m_FontDisable = m_FontFocus = NULL; + + m_ImageDisable = m_ImagePress = m_ImageHover = m_ImageFocus = NULL; + + m_Align = TAL_CENTER; + + m_Hover = m_Press = false; + + m_Type = UI_BUTTON; + + m_CanFocus = false; + m_StayPressed = false; + + m_OneTimePress = false; + m_CenterImage = false; + + m_PixelPerfect = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIButton::~CUIButton() { + if (m_BackPress) delete m_BackPress; + if (m_BackHover) delete m_BackHover; + if (m_BackDisable) delete m_BackDisable; + if (m_BackFocus) delete m_BackFocus; + + if (!m_SharedFonts) { + if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); + if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); + if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); + } + + if (!m_SharedImages) { + if (m_ImageHover) delete m_ImageHover; + if (m_ImagePress) delete m_ImagePress; + if (m_ImageDisable) delete m_ImageDisable; + if (m_ImageFocus) delete m_ImageFocus; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(BUTTON) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(FOCUSABLE) +TOKEN_DEF(BACK_HOVER) +TOKEN_DEF(BACK_PRESS) +TOKEN_DEF(BACK_DISABLE) +TOKEN_DEF(BACK_FOCUS) +TOKEN_DEF(BACK) +TOKEN_DEF(CENTER_IMAGE) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE_PRESS) +TOKEN_DEF(IMAGE_DISABLE) +TOKEN_DEF(IMAGE_FOCUS) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT_PRESS) +TOKEN_DEF(FONT_DISABLE) +TOKEN_DEF(FONT_FOCUS) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(PRESSED) +TOKEN_DEF(PIXEL_PERFECT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(FOCUSABLE) + TOKEN_TABLE(BACK_HOVER) + TOKEN_TABLE(BACK_PRESS) + TOKEN_TABLE(BACK_DISABLE) + TOKEN_TABLE(BACK_FOCUS) + TOKEN_TABLE(BACK) + TOKEN_TABLE(CENTER_IMAGE) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE_PRESS) + TOKEN_TABLE(IMAGE_DISABLE) + TOKEN_TABLE(IMAGE_FOCUS) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT_PRESS) + TOKEN_TABLE(FONT_DISABLE) + TOKEN_TABLE(FONT_FOCUS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(PRESSED) + TOKEN_TABLE(PIXEL_PERFECT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + Game->LOG(0, "'BUTTON' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + delete m_Back; + m_Back = new CUITiledImage(Game); + if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { + delete m_Back; + m_Back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_HOVER: + delete m_BackHover; + m_BackHover = new CUITiledImage(Game); + if (!m_BackHover || FAILED(m_BackHover->LoadFile((char *)params))) { + delete m_BackHover; + m_BackHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_PRESS: + delete m_BackPress; + m_BackPress = new CUITiledImage(Game); + if (!m_BackPress || FAILED(m_BackPress->LoadFile((char *)params))) { + delete m_BackPress; + m_BackPress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_DISABLE: + delete m_BackDisable; + m_BackDisable = new CUITiledImage(Game); + if (!m_BackDisable || FAILED(m_BackDisable->LoadFile((char *)params))) { + delete m_BackDisable; + m_BackDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_FOCUS: + delete m_BackFocus; + m_BackFocus = new CUITiledImage(Game); + if (!m_BackFocus || FAILED(m_BackFocus->LoadFile((char *)params))) { + delete m_BackFocus; + m_BackFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete m_Image; + m_Image = new CBSprite(Game); + if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { + delete m_Image; + m_Image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + delete m_ImageHover; + m_ImageHover = new CBSprite(Game); + if (!m_ImageHover || FAILED(m_ImageHover->LoadFile((char *)params))) { + delete m_ImageHover; + m_ImageHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_PRESS: + delete m_ImagePress; + m_ImagePress = new CBSprite(Game); + if (!m_ImagePress || FAILED(m_ImagePress->LoadFile((char *)params))) { + delete m_ImagePress; + m_ImagePress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_DISABLE: + delete m_ImageDisable; + m_ImageDisable = new CBSprite(Game); + if (!m_ImageDisable || FAILED(m_ImageDisable->LoadFile((char *)params))) { + delete m_ImageDisable; + m_ImageDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_FOCUS: + delete m_ImageFocus; + m_ImageFocus = new CBSprite(Game); + if (!m_ImageFocus || FAILED(m_ImageFocus->LoadFile((char *)params))) { + delete m_ImageFocus; + m_ImageFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont((char *)params); + if (!m_Font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + m_FontHover = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_PRESS: + if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); + m_FontPress = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontPress) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_DISABLE: + if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); + m_FontDisable = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontDisable) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_FOCUS: + if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); + m_FontFocus = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontFocus) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->m_StringTable->Expand(&m_Text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) m_Align = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) m_Align = TAL_RIGHT; + else m_Align = TAL_CENTER; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &m_Width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_Height); + break; + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &m_ParentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &m_Disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &m_Visible); + break; + + case TOKEN_FOCUSABLE: + parser.ScanStr((char *)params, "%b", &m_CanFocus); + break; + + case TOKEN_CENTER_IMAGE: + parser.ScanStr((char *)params, "%b", &m_CenterImage); + break; + + case TOKEN_PRESSED: + parser.ScanStr((char *)params, "%b", &m_StayPressed); + break; + + case TOKEN_PIXEL_PERFECT: + parser.ScanStr((char *)params, "%b", &m_PixelPerfect); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in BUTTON definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading BUTTON definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "BUTTON\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Back && m_Back->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + if (m_BackHover && m_BackHover->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", m_BackHover->m_Filename); + if (m_BackPress && m_BackPress->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", m_BackPress->m_Filename); + if (m_BackDisable && m_BackDisable->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", m_BackDisable->m_Filename); + if (m_BackFocus && m_BackFocus->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", m_BackFocus->m_Filename); + + if (m_Image && m_Image->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + if (m_ImageHover && m_ImageHover->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", m_ImageHover->m_Filename); + if (m_ImagePress && m_ImagePress->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", m_ImagePress->m_Filename); + if (m_ImageDisable && m_ImageDisable->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", m_ImageDisable->m_Filename); + if (m_ImageFocus && m_ImageFocus->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", m_ImageFocus->m_Filename); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (m_FontHover && m_FontHover->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", m_FontHover->m_Filename); + if (m_FontPress && m_FontPress->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", m_FontPress->m_Filename); + if (m_FontDisable && m_FontDisable->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", m_FontDisable->m_Filename); + if (m_FontFocus && m_FontFocus->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", m_FontFocus->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + + switch (m_Align) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", m_CanFocus ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", m_CenterImage ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", m_StayPressed ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", m_PixelPerfect ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUIButton::CorrectSize() { + RECT rect; + + CBSprite *img = NULL; + if (m_Image) img = m_Image; + else if (m_ImageDisable) img = m_ImageDisable; + else if (m_ImageHover) img = m_ImageHover; + else if (m_ImagePress) img = m_ImagePress; + else if (m_ImageFocus) img = m_ImageFocus; + + if (m_Width <= 0) { + if (img) { + img->GetBoundingRect(&rect, 0, 0); + m_Width = rect.right - rect.left; + } else m_Width = 100; + } + + if (m_Height <= 0) { + if (img) { + img->GetBoundingRect(&rect, 0, 0); + m_Height = rect.bottom - rect.top; + } + } + + if (m_Text) { + int text_height; + if (m_Font) text_height = m_Font->GetTextHeight((byte *)m_Text, m_Width); + else text_height = Game->m_SystemFont->GetTextHeight((byte *)m_Text, m_Width); + + if (text_height > m_Height) m_Height = text_height; + } + + if (m_Height <= 0) m_Height = 100; + + if (m_Back) m_Back->CorrectSize(&m_Width, &m_Height); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::Display(int OffsetX, int OffsetY) { + if (!m_Visible) return S_OK; + + CUITiledImage *back = NULL; + CBSprite *image = NULL; + CBFont *font = 0; + + //RECT rect; + //CBPlatform::SetRect(&rect, OffsetX + m_PosX, OffsetY + m_PosY, OffsetX+m_PosX+m_Width, OffsetY+m_PosY+m_Height); + //m_Hover = (!m_Disable && CBPlatform::PtInRect(&rect, Game->m_MousePos)!=FALSE); + m_Hover = (!m_Disable && Game->m_ActiveObject == this && (Game->m_Interactive || Game->m_State == GAME_SEMI_FROZEN)); + + if ((m_Press && m_Hover && !Game->m_MouseLeftDown) || + m_OneTimePress && CBPlatform::GetTime() - m_OneTimePressTime >= 100) Press(); + + + if (m_Disable) { + if (m_BackDisable) back = m_BackDisable; + if (m_ImageDisable) image = m_ImageDisable; + if (m_Text && m_FontDisable) font = m_FontDisable; + } else if (m_Press || m_OneTimePress || m_StayPressed) { + if (m_BackPress) back = m_BackPress; + if (m_ImagePress) image = m_ImagePress; + if (m_Text && m_FontPress) font = m_FontPress; + } else if (m_Hover) { + if (m_BackHover) back = m_BackHover; + if (m_ImageHover) image = m_ImageHover; + if (m_Text && m_FontHover) font = m_FontHover; + } else if (m_CanFocus && IsFocused()) { + if (m_BackFocus) back = m_BackFocus; + if (m_ImageFocus) image = m_ImageFocus; + if (m_Text && m_FontFocus) font = m_FontFocus; + } + + if (!back && m_Back) back = m_Back; + if (!image && m_Image) image = m_Image; + if (m_Text && !font) { + if (m_Font) font = m_Font; + else font = Game->m_SystemFont; + } + + int ImageX = OffsetX + m_PosX; + int ImageY = OffsetY + m_PosY; + + if (image && m_CenterImage) { + RECT rc; + image->GetBoundingRect(&rc, 0, 0); + ImageX += (m_Width - (rc.right - rc.left)) / 2; + ImageY += (m_Height - (rc.bottom - rc.top)) / 2; + } + + if (back) back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); + //if(image) image->Draw(ImageX +((m_Press||m_OneTimePress)&&back?1:0), ImageY +((m_Press||m_OneTimePress)&&back?1:0), NULL); + if (image) image->Draw(ImageX + ((m_Press || m_OneTimePress) && back ? 1 : 0), ImageY + ((m_Press || m_OneTimePress) && back ? 1 : 0), m_PixelPerfect ? this : NULL); + + if (font && m_Text) { + int text_offset = (m_Height - font->GetTextHeight((byte *)m_Text, m_Width)) / 2; + font->DrawText((byte *)m_Text, OffsetX + m_PosX + ((m_Press || m_OneTimePress) ? 1 : 0), OffsetY + m_PosY + text_offset + ((m_Press || m_OneTimePress) ? 1 : 0), m_Width, m_Align); + } + + if (!m_PixelPerfect || !m_Image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + + // reset unused sprites + if (m_Image && m_Image != image) m_Image->Reset(); + if (m_ImageDisable && m_ImageDisable != image) m_ImageDisable->Reset(); + if (m_ImageFocus && m_ImageFocus != image) m_ImageFocus->Reset(); + if (m_ImagePress && m_ImagePress != image) m_ImagePress->Reset(); + if (m_ImageHover && m_ImageHover != image) m_ImageHover->Reset(); + + m_Press = m_Hover && Game->m_MouseLeftDown && Game->m_CapturedObject == this; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIButton::Press() { + ApplyEvent("Press"); + if (m_ListenerObject) m_ListenerObject->Listen(m_ListenerParamObject, m_ListenerParamDWORD); + if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + + m_OneTimePress = false; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetDisabledFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetDisabledFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); + if (Val->IsNULL()) { + m_FontDisable = NULL; + Stack->PushBool(true); + } else { + m_FontDisable = Game->m_FontStorage->AddFont(Val->GetString()); + Stack->PushBool(m_FontDisable != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHoverFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + if (Val->IsNULL()) { + m_FontHover = NULL; + Stack->PushBool(true); + } else { + m_FontHover = Game->m_FontStorage->AddFont(Val->GetString()); + Stack->PushBool(m_FontHover != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPressedFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); + if (Val->IsNULL()) { + m_FontPress = NULL; + Stack->PushBool(true); + } else { + m_FontPress = Game->m_FontStorage->AddFont(Val->GetString()); + Stack->PushBool(m_FontPress != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFocusedFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); + if (Val->IsNULL()) { + m_FontFocus = NULL; + Stack->PushBool(true); + } else { + m_FontFocus = Game->m_FontStorage->AddFont(Val->GetString()); + Stack->PushBool(m_FontFocus != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDisabledImage") == 0) { + Stack->CorrectParams(1); + + delete m_ImageDisable; + m_ImageDisable = new CBSprite(Game); + char *Filename = Stack->Pop()->GetString(); + if (!m_ImageDisable || FAILED(m_ImageDisable->LoadFile(Filename))) { + delete m_ImageDisable; + m_ImageDisable = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDisabledImage") == 0) { + Stack->CorrectParams(0); + if (!m_ImageDisable || !m_ImageDisable->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ImageDisable->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDisabledImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_ImageDisable) Stack->PushNULL(); + else Stack->PushNative(m_ImageDisable, true); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHoverImage") == 0) { + Stack->CorrectParams(1); + + delete m_ImageHover; + m_ImageHover = new CBSprite(Game); + char *Filename = Stack->Pop()->GetString(); + if (!m_ImageHover || FAILED(m_ImageHover->LoadFile(Filename))) { + delete m_ImageHover; + m_ImageHover = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverImage") == 0) { + Stack->CorrectParams(0); + if (!m_ImageHover || !m_ImageHover->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ImageHover->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_ImageHover) Stack->PushNULL(); + else Stack->PushNative(m_ImageHover, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPressedImage") == 0) { + Stack->CorrectParams(1); + + delete m_ImagePress; + m_ImagePress = new CBSprite(Game); + char *Filename = Stack->Pop()->GetString(); + if (!m_ImagePress || FAILED(m_ImagePress->LoadFile(Filename))) { + delete m_ImagePress; + m_ImagePress = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPressedImage") == 0) { + Stack->CorrectParams(0); + if (!m_ImagePress || !m_ImagePress->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ImagePress->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPressedImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_ImagePress) Stack->PushNULL(); + else Stack->PushNative(m_ImagePress, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFocusedImage") == 0) { + Stack->CorrectParams(1); + + delete m_ImageFocus; + m_ImageFocus = new CBSprite(Game); + char *Filename = Stack->Pop()->GetString(); + if (!m_ImageFocus || FAILED(m_ImageFocus->LoadFile(Filename))) { + delete m_ImageFocus; + m_ImageFocus = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFocusedImage") == 0) { + Stack->CorrectParams(0); + if (!m_ImageFocus || !m_ImageFocus->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ImageFocus->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFocusedImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_ImageFocus) Stack->PushNULL(); + else Stack->PushNative(m_ImageFocus, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Press + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Press") == 0) { + Stack->CorrectParams(0); + + if (m_Visible && !m_Disable) { + m_OneTimePress = true; + m_OneTimePressTime = CBPlatform::GetTime(); + } + Stack->PushNULL(); + + return S_OK; + } + + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIButton::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("button"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextAlign") == 0) { + m_ScValue->SetInt(m_Align); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focusable") == 0) { + m_ScValue->SetBool(m_CanFocus); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pressed") == 0) { + m_ScValue->SetBool(m_StayPressed); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + m_ScValue->SetBool(m_PixelPerfect); + return m_ScValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "TextAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + m_Align = (TTextAlign)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focusable") == 0) { + m_CanFocus = Value->GetBool(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pressed") == 0) { + m_StayPressed = Value->GetBool(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + m_PixelPerfect = Value->GetBool(); + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIButton::ScToString() { + return "[button]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER_INT(m_Align)); + PersistMgr->Transfer(TMEMBER(m_BackDisable)); + PersistMgr->Transfer(TMEMBER(m_BackFocus)); + PersistMgr->Transfer(TMEMBER(m_BackHover)); + PersistMgr->Transfer(TMEMBER(m_BackPress)); + PersistMgr->Transfer(TMEMBER(m_CenterImage)); + PersistMgr->Transfer(TMEMBER(m_FontDisable)); + PersistMgr->Transfer(TMEMBER(m_FontFocus)); + PersistMgr->Transfer(TMEMBER(m_FontHover)); + PersistMgr->Transfer(TMEMBER(m_FontPress)); + PersistMgr->Transfer(TMEMBER(m_Hover)); + PersistMgr->Transfer(TMEMBER(m_Image)); + PersistMgr->Transfer(TMEMBER(m_ImageDisable)); + PersistMgr->Transfer(TMEMBER(m_ImageFocus)); + PersistMgr->Transfer(TMEMBER(m_ImageHover)); + PersistMgr->Transfer(TMEMBER(m_ImagePress)); + PersistMgr->Transfer(TMEMBER(m_PixelPerfect)); + PersistMgr->Transfer(TMEMBER(m_Press)); + PersistMgr->Transfer(TMEMBER(m_StayPressed)); + + if (!PersistMgr->m_Saving) { + m_OneTimePress = false; + m_OneTimePressTime = 0; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h new file mode 100644 index 0000000000..aa4b7f8b78 --- /dev/null +++ b/engines/wintermute/UIButton.h @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIBUTTON_H +#define WINTERMUTE_UIBUTTON_H + + +#include "UIObject.h" +#include "dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUIButton : public CUIObject { +public: + bool m_PixelPerfect; + bool m_StayPressed; + bool m_CenterImage; + bool m_OneTimePress; + uint32 m_OneTimePressTime; + DECLARE_PERSISTENT(CUIButton, CUIObject) + void Press(); + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + bool m_Press; + bool m_Hover; + void CorrectSize(); + TTextAlign m_Align; + CBSprite *m_ImageHover; + CBSprite *m_ImagePress; + CBSprite *m_ImageDisable; + CBSprite *m_ImageFocus; + CBFont *m_FontDisable; + CBFont *m_FontPress; + CBFont *m_FontHover; + CBFont *m_FontFocus; + CUITiledImage *m_BackPress; + CUITiledImage *m_BackHover; + CUITiledImage *m_BackDisable; + CUITiledImage *m_BackFocus; + CUIButton(CBGame *inGame = NULL); + virtual ~CUIButton(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp new file mode 100644 index 0000000000..af214c50dd --- /dev/null +++ b/engines/wintermute/UIEdit.cpp @@ -0,0 +1,856 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/UIEdit.h" +#include "engines/wintermute/UIObject.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BKeyboardState.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEdit, false) + +////////////////////////////////////////////////////////////////////////// +CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { + m_Type = UI_EDIT; + + m_FontSelected = NULL; + + m_SelStart = m_SelEnd = 10000; + m_ScrollOffset = 0; + + m_CursorChar = NULL; + SetCursorChar("|"); + +#ifdef __WIN32__ + m_CursorBlinkRate = GetCaretBlinkTime(); +#else + m_CursorBlinkRate = 600; +#endif + m_FrameWidth = 0; + + SetText(""); + + m_LastBlinkTime = 0; + m_CursorVisible = true; + + m_MaxLength = -1; + + m_CanFocus = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEdit::~CUIEdit() { + if (!m_SharedFonts) { + if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); + } + + delete[] m_CursorChar; + m_CursorChar = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_SELECTED) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR_BLINK_RATE) +TOKEN_DEF(CURSOR) +TOKEN_DEF(FRAME_WIDTH) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MAX_LENGTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF(CAPTION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_SELECTED) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR_BLINK_RATE) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(FRAME_WIDTH) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MAX_LENGTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + Game->LOG(0, "'EDIT' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_BACK: + delete m_Back; + m_Back = new CUITiledImage(Game); + if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { + delete m_Back; + m_Back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete m_Image; + m_Image = new CBSprite(Game); + if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { + delete m_Image; + m_Image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont((char *)params); + if (!m_Font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_SELECTED: + if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); + m_FontSelected = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontSelected) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->m_StringTable->Expand(&m_Text); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &m_Width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_Height); + break; + + case TOKEN_MAX_LENGTH: + parser.ScanStr((char *)params, "%d", &m_MaxLength); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_BLINK_RATE: + parser.ScanStr((char *)params, "%d", &m_CursorBlinkRate); + break; + + case TOKEN_FRAME_WIDTH: + parser.ScanStr((char *)params, "%d", &m_FrameWidth); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &m_ParentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &m_Disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &m_Visible); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in EDIT definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading EDIT definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "EDIT\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Back && m_Back->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + + if (m_Image && m_Image->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (m_FontSelected && m_FontSelected->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", m_FontSelected->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", m_MaxLength); + Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", m_CursorBlinkRate); + Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", m_FrameWidth); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + + // scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSelectedFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSelectedFont") == 0) { + Stack->CorrectParams(1); + + if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); + m_FontSelected = Game->m_FontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(m_FontSelected != NULL); + + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEdit::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("editor"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelStart") == 0) { + m_ScValue->SetInt(m_SelStart); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelEnd") == 0) { + m_ScValue->SetInt(m_SelEnd); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorBlinkRate") == 0) { + m_ScValue->SetInt(m_CursorBlinkRate); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorChar") == 0) { + m_ScValue->SetString(m_CursorChar); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FrameWidth") == 0) { + m_ScValue->SetInt(m_FrameWidth); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxLength") == 0) { + m_ScValue->SetInt(m_MaxLength); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + if (Game->m_TextEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::AnsiToWide(m_Text); + m_ScValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); + } else { + m_ScValue->SetString(m_Text); + } + return m_ScValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SelStart") == 0) { + m_SelStart = Value->GetInt(); + m_SelStart = MAX(m_SelStart, 0); + m_SelStart = MIN(m_SelStart, strlen(m_Text)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelEnd") == 0) { + m_SelEnd = Value->GetInt(); + m_SelEnd = MAX(m_SelEnd, 0); + m_SelEnd = MIN(m_SelEnd, strlen(m_Text)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorBlinkRate") == 0) { + m_CursorBlinkRate = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorChar") == 0) { + SetCursorChar(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FrameWidth") == 0) { + m_FrameWidth = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxLength") == 0) { + m_MaxLength = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + if (Game->m_TextEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); + SetText(StringUtil::WideToAnsi(wstr).c_str()); + } else { + SetText(Value->GetString()); + } + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIEdit::ScToString() { + return "[edit]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIEdit::SetCursorChar(char *Char) { + if (!Char) return; + delete[] m_CursorChar; + m_CursorChar = new char [strlen(Char) + 1]; + if (m_CursorChar) strcpy(m_CursorChar, Char); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { + if (!m_Visible) return S_OK; + + + // hack! + TTextEncoding OrigEncoding = Game->m_TextEncoding; + Game->m_TextEncoding = TEXT_ANSI; + + if (m_Back) m_Back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); + if (m_Image) m_Image->Draw(OffsetX + m_PosX, OffsetY + m_PosY, NULL); + + // prepare fonts + CBFont *font; + CBFont *sfont; + + if (m_Font) font = m_Font; + else font = Game->m_SystemFont; + + if (m_FontSelected) sfont = m_FontSelected; + else sfont = font; + + bool focused = IsFocused(); + + m_SelStart = MAX(m_SelStart, 0); + m_SelEnd = MAX(m_SelEnd, 0); + + m_SelStart = MIN(m_SelStart, strlen(m_Text)); + m_SelEnd = MIN(m_SelEnd, strlen(m_Text)); + + //int CursorWidth = font->GetCharWidth(m_CursorChar[0]); + int CursorWidth = font->GetTextWidth((byte *)m_CursorChar); + + int s1, s2; + bool CurFirst; + // modify scroll offset + if (m_SelStart >= m_SelEnd) { + while (font->GetTextWidth((byte *)m_Text + m_ScrollOffset, std::max(0, m_SelEnd - m_ScrollOffset)) > m_Width - CursorWidth - 2 * m_FrameWidth) { + m_ScrollOffset++; + if (m_ScrollOffset >= strlen(m_Text)) break; + } + + m_ScrollOffset = std::min(m_ScrollOffset, m_SelEnd); + + s1 = m_SelEnd; + s2 = m_SelStart; + CurFirst = true; + } else { + while (font->GetTextWidth((byte *)m_Text + m_ScrollOffset, std::max(0, m_SelStart - m_ScrollOffset)) + + sfont->GetTextWidth((byte *)(m_Text + std::max(m_ScrollOffset, m_SelStart)), m_SelEnd - std::max(m_ScrollOffset, m_SelStart)) + + > m_Width - CursorWidth - 2 * m_FrameWidth) { + m_ScrollOffset++; + if (m_ScrollOffset >= strlen(m_Text)) break; + } + + m_ScrollOffset = std::min(m_ScrollOffset, m_SelEnd); + + s1 = m_SelStart; + s2 = m_SelEnd; + CurFirst = false; + } + + + int AlignOffset = 0; + + for (int Count = 0; Count < 2; Count++) { + // draw text + int xxx, yyy, width, height; + + xxx = m_PosX + m_FrameWidth + OffsetX; + yyy = m_PosY + m_FrameWidth + OffsetY; + + width = m_PosX + m_Width + OffsetX - m_FrameWidth; + height = std::max(font->GetLetterHeight(), sfont->GetLetterHeight()); + + if (Game->m_TextRTL) xxx += AlignOffset; + + TTextAlign Align = TAL_LEFT; + + + // unselected 1 + if (s1 > m_ScrollOffset) { + if (Count) font->DrawText((byte *)m_Text + m_ScrollOffset, xxx, yyy, width - xxx, Align, height, s1 - m_ScrollOffset); + xxx += font->GetTextWidth((byte *)m_Text + m_ScrollOffset, s1 - m_ScrollOffset); + AlignOffset += font->GetTextWidth((byte *)m_Text + m_ScrollOffset, s1 - m_ScrollOffset); + } + + // cursor + if (focused && CurFirst) { + if (Count) { + if (CBPlatform::GetTime() - m_LastBlinkTime >= m_CursorBlinkRate) { + m_LastBlinkTime = CBPlatform::GetTime(); + m_CursorVisible = !m_CursorVisible; + } + if (m_CursorVisible) + font->DrawText((byte *)m_CursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += CursorWidth; + AlignOffset += CursorWidth; + } + + // selected + int s3 = std::max(s1, m_ScrollOffset); + + if (s2 - s3 > 0) { + if (Count) sfont->DrawText((byte *)m_Text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->GetTextWidth((byte *)m_Text + s3, s2 - s3); + AlignOffset += sfont->GetTextWidth((byte *)m_Text + s3, s2 - s3); + } + + // cursor + if (focused && !CurFirst) { + if (Count) { + if (CBPlatform::GetTime() - m_LastBlinkTime >= m_CursorBlinkRate) { + m_LastBlinkTime = CBPlatform::GetTime(); + m_CursorVisible = !m_CursorVisible; + } + if (m_CursorVisible) + font->DrawText((byte *)m_CursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += CursorWidth; + AlignOffset += CursorWidth; + } + + // unselected 2 + if (Count) font->DrawText((byte *)m_Text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->GetTextWidth((byte *)m_Text + s2); + + AlignOffset = (m_Width - 2 * m_FrameWidth) - AlignOffset; + if (AlignOffset < 0) AlignOffset = 0; + } + + + Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + + + Game->m_TextEncoding = OrigEncoding; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::HandleKeypress(SDL_Event *event) { + bool Handled = false; + + if (event->type == SDL_KEYDOWN) { + switch (event->key.keysym.sym) { + case SDLK_ESCAPE: + case SDLK_TAB: + case SDLK_RETURN: + return false; + + // ctrl+A + case SDLK_a: + if (CBKeyboardState::IsControlDown()) { + m_SelStart = 0; + m_SelEnd = strlen(m_Text); + Handled = true; + } + break; + + case SDLK_BACKSPACE: + if (m_SelStart == m_SelEnd) { + if (Game->m_TextRTL) DeleteChars(m_SelStart, m_SelStart + 1); + else DeleteChars(m_SelStart - 1, m_SelStart); + } else DeleteChars(m_SelStart, m_SelEnd); + if (m_SelEnd >= m_SelStart) m_SelEnd -= std::max(1, m_SelEnd - m_SelStart); + m_SelStart = m_SelEnd; + + Handled = true; + break; + + case SDLK_LEFT: + case SDLK_UP: + m_SelEnd--; + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + Handled = true; + break; + + case SDLK_RIGHT: + case SDLK_DOWN: + m_SelEnd++; + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + Handled = true; + break; + + case SDLK_HOME: + if (Game->m_TextRTL) { + m_SelEnd = strlen(m_Text); + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + } else { + m_SelEnd = 0; + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + } + Handled = true; + break; + + case SDLK_END: + if (Game->m_TextRTL) { + m_SelEnd = 0; + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + } else { + m_SelEnd = strlen(m_Text); + if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + } + Handled = true; + break; + + case SDLK_DELETE: + if (m_SelStart == m_SelEnd) { + if (Game->m_TextRTL) { + DeleteChars(m_SelStart - 1, m_SelStart); + m_SelEnd--; + if (m_SelEnd < 0) m_SelEnd = 0; + } else DeleteChars(m_SelStart, m_SelStart + 1); + } else DeleteChars(m_SelStart, m_SelEnd); + if (m_SelEnd > m_SelStart) m_SelEnd -= (m_SelEnd - m_SelStart); + + m_SelStart = m_SelEnd; + Handled = true; + break; + } + return Handled; + } + + else if (event->type == SDL_TEXTINPUT) { + if (m_SelStart != m_SelEnd) DeleteChars(m_SelStart, m_SelEnd); + + WideString wstr = StringUtil::Utf8ToWide(event->text.text); + m_SelEnd += InsertChars(m_SelEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + + if (Game->m_TextRTL) m_SelEnd = m_SelStart; + else m_SelStart = m_SelEnd; + + return true; + } + + return false; +} + + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::DeleteChars(int Start, int End) { + if (Start > End) CBUtils::Swap(&Start, &End); + + Start = MAX(Start, 0); + End = MIN(End, strlen(m_Text)); + + char *str = new char[strlen(m_Text) - (End - Start) + 1]; + if (str) { + if (Start > 0) memcpy(str, m_Text, Start); + memcpy(str + std::max(0, Start), m_Text + End, strlen(m_Text) - End + 1); + + delete[] m_Text; + m_Text = str; + } + if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + + return End - Start; +} + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { + if (strlen(m_Text) + Num > m_MaxLength) { + Num -= (strlen(m_Text) + Num - m_MaxLength); + } + + Pos = MAX(Pos, 0); + Pos = MIN(Pos, strlen(m_Text)); + + char *str = new char[strlen(m_Text) + Num + 1]; + if (str) { + if (Pos > 0) memcpy(str, m_Text, Pos); + memcpy(str + Pos + Num, m_Text + Pos, strlen(m_Text) - Pos + 1); + + memcpy(str + Pos, Chars, Num); + + delete[] m_Text; + m_Text = str; + } + if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + + return Num; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_CursorBlinkRate)); + PersistMgr->Transfer(TMEMBER(m_CursorChar)); + PersistMgr->Transfer(TMEMBER(m_FontSelected)); + PersistMgr->Transfer(TMEMBER(m_FrameWidth)); + PersistMgr->Transfer(TMEMBER(m_MaxLength)); + PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); + PersistMgr->Transfer(TMEMBER(m_SelEnd)); + PersistMgr->Transfer(TMEMBER(m_SelStart)); + + if (!PersistMgr->m_Saving) { + m_CursorVisible = false; + m_LastBlinkTime = 0; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h new file mode 100644 index 0000000000..134218c877 --- /dev/null +++ b/engines/wintermute/UIEdit.h @@ -0,0 +1,71 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIEDIT_H +#define WINTERMUTE_UIEDIT_H + +#include "persistent.h" +#include "UIObject.h" + +namespace WinterMute { +class CBFont; +class CUIEdit : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEdit, CUIObject) + int m_MaxLength; + int InsertChars(int Pos, byte *Chars, int Num); + int DeleteChars(int Start, int End); + bool m_CursorVisible; + uint32 m_LastBlinkTime; + virtual HRESULT Display(int OffsetX, int OffsetY); + virtual bool HandleKeypress(SDL_Event *event); + int m_ScrollOffset; + int m_FrameWidth; + uint32 m_CursorBlinkRate; + void SetCursorChar(char *Char); + char *m_CursorChar; + int m_SelEnd; + int m_SelStart; + CBFont *m_FontSelected; + CUIEdit(CBGame *inGame); + virtual ~CUIEdit(); + + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp new file mode 100644 index 0000000000..2cf7a3096f --- /dev/null +++ b/engines/wintermute/UIEntity.cpp @@ -0,0 +1,339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/AdEntity.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/UIEntity.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEntity, false) + +////////////////////////////////////////////////////////////////////////// +CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { + m_Type = UI_CUSTOM; + m_Entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEntity::~CUIEntity() { + if (m_Entity) Game->UnregisterObject(m_Entity); + m_Entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(NAME) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &m_Disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &m_Visible); + break; + + case TOKEN_ENTITY: + if (FAILED(SetEntity((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); + return E_FAIL; + } + + CorrectSize(); + + if (Game->m_EditorMode) { + m_Width = 50; + m_Height = 50; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + + if (m_Entity && m_Entity->m_Filename) + Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", m_Entity->m_Filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::SetEntity(char *Filename) { + if (m_Entity) Game->UnregisterObject(m_Entity); + m_Entity = new CAdEntity(Game); + if (!m_Entity || FAILED(m_Entity->LoadFile(Filename))) { + delete m_Entity; + m_Entity = NULL; + return E_FAIL; + } else { + m_Entity->m_NonIntMouseEvents = true; + m_Entity->m_SceneIndependent = true; + m_Entity->MakeFreezable(false); + Game->RegisterObject(m_Entity); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { + if (!m_Visible) return S_OK; + + if (m_Entity) { + m_Entity->m_PosX = OffsetX + m_PosX; + m_Entity->m_PosY = OffsetY + m_PosY; + if (m_Entity->m_Scale < 0) m_Entity->m_Zoomable = false; + m_Entity->m_Shadowable = false; + + m_Entity->Update(); + + bool OrigReg = m_Entity->m_Registrable; + + if (m_Entity->m_Registrable && m_Disable) m_Entity->m_Registrable = false; + + m_Entity->Display(); + m_Entity->m_Registrable = OrigReg; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetEntity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetEntity") == 0) { + Stack->CorrectParams(0); + + if (m_Entity) Stack->PushNative(m_Entity, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetEntity") == 0) { + Stack->CorrectParams(1); + + char *Filename = Stack->Pop()->GetString(); + + if (SUCCEEDED(SetEntity(Filename))) + Stack->PushBool(true); + else + Stack->PushBool(false); + + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEntity::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("entity container"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Freezable") == 0) { + if (m_Entity) m_ScValue->SetBool(m_Entity->m_Freezable); + else m_ScValue->SetBool(false); + return m_ScValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Freezable") == 0) { + if (m_Entity) m_Entity->MakeFreezable(Value->GetBool()); + return S_OK; + } else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIEntity::ScToString() { + return "[entity container]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Entity)); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h new file mode 100644 index 0000000000..f3c9385b7b --- /dev/null +++ b/engines/wintermute/UIEntity.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIENTITY_H +#define WINTERMUTE_UIENTITY_H + +#include "UIObject.h" + +namespace WinterMute { +class CAdEntity; +class CUIEntity : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEntity, CUIObject) + CUIEntity(CBGame *inGame); + virtual ~CUIEntity(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + CAdEntity *m_Entity; + HRESULT SetEntity(char *Filename); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp new file mode 100644 index 0000000000..4ff0952bd7 --- /dev/null +++ b/engines/wintermute/UIObject.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/UIObject.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BFontStorage.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIObject, false) + +////////////////////////////////////////////////////////////////////////// +CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { + m_Back = NULL; + m_Image = NULL; + m_Font = NULL; + m_Text = NULL; + m_SharedFonts = m_SharedImages = false; + + m_Width = m_Height = 0; + + m_ListenerObject = NULL; + m_ListenerParamObject = NULL; + m_ListenerParamDWORD = 0; + + m_Disable = false; + m_Visible = true; + + m_Type = UI_UNKNOWN; + m_Parent = NULL; + + m_ParentNotify = false; + + m_FocusedWidget = NULL; + + m_CanFocus = false; + m_NonIntMouseEvents = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIObject::~CUIObject() { + if (!Game->m_LoadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); + + if (m_Back) delete m_Back; + if (m_Font && !m_SharedFonts) Game->m_FontStorage->RemoveFont(m_Font); + + if (m_Image && !m_SharedImages) delete m_Image; + + if (m_Text) delete [] m_Text; + + m_FocusedWidget = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::SetText(const char *Text) { + if (m_Text) delete [] m_Text; + m_Text = new char [strlen(Text) + 1]; + if (m_Text) { + strcpy(m_Text, Text); + for (int i = 0; i < strlen(m_Text); i++) { + if (m_Text[i] == '|') m_Text[i] = '\n'; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Display(int OffsetX, int OffsetY) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { + m_ListenerObject = Object; + m_ListenerParamObject = ListenerObject; + m_ListenerParamDWORD = ListenerParam; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::CorrectSize() { + RECT rect; + + if (m_Width <= 0) { + if (m_Image) { + m_Image->GetBoundingRect(&rect, 0, 0); + m_Width = rect.right - rect.left; + } else m_Width = 100; + } + + if (m_Height <= 0) { + if (m_Image) { + m_Image->GetBoundingRect(&rect, 0, 0); + m_Height = rect.bottom - rect.top; + } + } + + if (m_Back) m_Back->CorrectSize(&m_Width, &m_Height); +} + + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (Val->IsNULL()) { + m_Font = NULL; + Stack->PushBool(true); + } else { + m_Font = Game->m_FontStorage->AddFont(Val->GetString()); + Stack->PushBool(m_Font != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetImage") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + char *Filename = Val->GetString(); + + delete m_Image; + m_Image = NULL; + if (Val->IsNULL()) { + Stack->PushBool(true); + return S_OK; + } + + m_Image = new CBSprite(Game); + if (!m_Image || FAILED(m_Image->LoadFile(Val->GetString()))) { + delete m_Image; + m_Image = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetImage") == 0) { + Stack->CorrectParams(0); + if (!m_Image || !m_Image->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_Image->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_Image) Stack->PushNULL(); + else Stack->PushNative(m_Image, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focus + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focus") == 0) { + Stack->CorrectParams(0); + Focus(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveAfter / MoveBefore + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveAfter") == 0 || strcmp(Name, "MoveBefore") == 0) { + Stack->CorrectParams(1); + + if (m_Parent && m_Parent->m_Type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)m_Parent; + + int i; + bool found = false; + CScValue *val = Stack->Pop(); + // find directly + if (val->IsNative()) { + CUIObject *widget = (CUIObject *)val->GetNative(); + for (i = 0; i < win->m_Widgets.GetSize(); i++) { + if (win->m_Widgets[i] == widget) { + found = true; + break; + } + } + } + // find by name + else { + char *name = val->GetString(); + for (i = 0; i < win->m_Widgets.GetSize(); i++) { + if (scumm_stricmp(win->m_Widgets[i]->m_Name, name) == 0) { + found = true; + break; + } + } + } + + if (found) { + bool done = false; + for (int j = 0; j < win->m_Widgets.GetSize(); j++) { + if (win->m_Widgets[j] == this) { + if (strcmp(Name, "MoveAfter") == 0) i++; + if (j >= i) j++; + + win->m_Widgets.InsertAt(i, this); + win->m_Widgets.RemoveAt(j); + + done = true; + Stack->PushBool(true); + break; + } + } + if (!done) Stack->PushBool(false); + } else Stack->PushBool(false); + + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToBottom + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveToBottom") == 0) { + Stack->CorrectParams(0); + + if (m_Parent && m_Parent->m_Type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)m_Parent; + for (int i = 0; i < win->m_Widgets.GetSize(); i++) { + if (win->m_Widgets[i] == this) { + win->m_Widgets.RemoveAt(i); + win->m_Widgets.InsertAt(0, this); + break; + } + } + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToTop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveToTop") == 0) { + Stack->CorrectParams(0); + + if (m_Parent && m_Parent->m_Type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)m_Parent; + for (int i = 0; i < win->m_Widgets.GetSize(); i++) { + if (win->m_Widgets[i] == this) { + win->m_Widgets.RemoveAt(i); + win->m_Widgets.Add(this); + break; + } + } + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIObject::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("ui_object"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Parent (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Parent") == 0) { + m_ScValue->SetNative(m_Parent, true); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParentNotify") == 0) { + m_ScValue->SetBool(m_ParentNotify); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_ScValue->SetInt(m_Width); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_ScValue->SetInt(m_Height); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Visible") == 0) { + m_ScValue->SetBool(m_Visible); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Disabled") == 0) { + m_ScValue->SetBool(m_Disable); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + m_ScValue->SetString(m_Text); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NextSibling (RO) / PrevSibling (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NextSibling") == 0 || strcmp(Name, "PrevSibling") == 0) { + m_ScValue->SetNULL(); + if (m_Parent && m_Parent->m_Type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)m_Parent; + for (int i = 0; i < win->m_Widgets.GetSize(); i++) { + if (win->m_Widgets[i] == this) { + if (strcmp(Name, "NextSibling") == 0) { + if (i < win->m_Widgets.GetSize() - 1) m_ScValue->SetNative(win->m_Widgets[i + 1], true); + } else { + if (i > 0) m_ScValue->SetNative(win->m_Widgets[i - 1], true); + } + break; + } + } + } + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParentNotify") == 0) { + m_ParentNotify = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_Width = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_Height = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Visible") == 0) { + m_Visible = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Disabled") == 0) { + m_Disable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + SetText(Value->GetString()); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIObject::ScToString() { + return "[ui_object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::IsFocused() { + if (!Game->m_FocusedWindow) return false; + if (Game->m_FocusedWindow == this) return true; + + CUIObject *obj = Game->m_FocusedWindow; + while (obj) { + if (obj == this) return true; + else obj = obj->m_FocusedWidget; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { + // handle focus change + if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { + Focus(); + } + return CBObject::HandleMouse(Event, Button); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Focus() { + CUIObject *obj = this; + bool disabled = false; + while (obj) { + if (obj->m_Disable && obj->m_Type == UI_WINDOW) { + disabled = true; + break; + } + obj = obj->m_Parent; + } + if (!disabled) { + obj = this; + while (obj) { + if (obj->m_Parent) { + if (!obj->m_Disable && obj->m_CanFocus) obj->m_Parent->m_FocusedWidget = obj; + } else { + if (obj->m_Type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); + } + + obj = obj->m_Parent; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { + int OffX = 0, OffY = 0; + + CUIObject *obj = m_Parent; + while (obj) { + OffX += obj->m_PosX; + OffY += obj->m_PosY; + + obj = obj->m_Parent; + } + if (OffsetX) *OffsetX = OffX; + if (OffsetY) *OffsetY = OffY; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Back)); + PersistMgr->Transfer(TMEMBER(m_CanFocus)); + PersistMgr->Transfer(TMEMBER(m_Disable)); + PersistMgr->Transfer(TMEMBER(m_FocusedWidget)); + PersistMgr->Transfer(TMEMBER(m_Font)); + PersistMgr->Transfer(TMEMBER(m_Height)); + PersistMgr->Transfer(TMEMBER(m_Image)); + PersistMgr->Transfer(TMEMBER(m_ListenerObject)); + PersistMgr->Transfer(TMEMBER(m_ListenerParamObject)); + PersistMgr->Transfer(TMEMBER(m_ListenerParamDWORD)); + PersistMgr->Transfer(TMEMBER(m_Parent)); + PersistMgr->Transfer(TMEMBER(m_ParentNotify)); + PersistMgr->Transfer(TMEMBER(m_SharedFonts)); + PersistMgr->Transfer(TMEMBER(m_SharedImages)); + PersistMgr->Transfer(TMEMBER(m_Text)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(m_Visible)); + PersistMgr->Transfer(TMEMBER(m_Width)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return E_FAIL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h new file mode 100644 index 0000000000..9742307504 --- /dev/null +++ b/engines/wintermute/UIObject.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIOBJECT_H +#define WINTERMUTE_UIOBJECT_H + + +#include "BObject.h" +#include "dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUITiledImage; +class CBFont; +class CUIObject : public CBObject { +public: + + HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); + bool m_CanFocus; + HRESULT Focus(); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + bool IsFocused(); + bool m_ParentNotify; + DECLARE_PERSISTENT(CUIObject, CBObject) + CUIObject *m_Parent; + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual void CorrectSize(); + bool m_SharedFonts; + bool m_SharedImages; + void SetText(const char *Text); + char *m_Text; + CBFont *m_Font; + bool m_Visible; + CUITiledImage *m_Back; + bool m_Disable; + CUIObject(CBGame *inGame = NULL); + virtual ~CUIObject(); + int m_Width; + int m_Height; + TUIObjectType m_Type; + CBSprite *m_Image; + void SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); + CBScriptHolder *m_ListenerParamObject; + uint32 m_ListenerParamDWORD; + CBScriptHolder *m_ListenerObject; + CUIObject *m_FocusedWidget; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp new file mode 100644 index 0000000000..7a0b206cec --- /dev/null +++ b/engines/wintermute/UIText.cpp @@ -0,0 +1,484 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BDynBuffer.h" +#include "UIText.h" +#include "UITiledImage.h" +#include "BGame.h" +#include "BParser.h" +#include "ScValue.h" +#include "BFont.h" +#include "BFontStorage.h" +#include "BStringTable.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIText, false) + +////////////////////////////////////////////////////////////////////////// +CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { + m_TextAlign = TAL_LEFT; + m_VerticalAlign = VAL_CENTER; + m_Type = UI_STATIC; + m_CanFocus = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIText::~CUIText() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::Display(int OffsetX, int OffsetY) { + if (!m_Visible) return S_OK; + + + CBFont *font = m_Font; + if (!font) font = Game->m_SystemFont; + + if (m_Back) m_Back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); + if (m_Image) m_Image->Draw(OffsetX + m_PosX, OffsetY + m_PosY, NULL); + + if (font && m_Text) { + int text_offset; + switch (m_VerticalAlign) { + case VAL_TOP: + text_offset = 0; + break; + case VAL_BOTTOM: + text_offset = m_Height - font->GetTextHeight((byte *)m_Text, m_Width); + break; + default: + text_offset = (m_Height - font->GetTextHeight((byte *)m_Text, m_Width)) / 2; + } + font->DrawText((byte *)m_Text, OffsetX + m_PosX, OffsetY + m_PosY + text_offset, m_Width, m_TextAlign, m_Height); + } + + //Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(STATIC) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + Game->LOG(0, "'STATIC' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + delete m_Back; + m_Back = new CUITiledImage(Game); + if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { + delete m_Back; + m_Back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete m_Image; + m_Image = new CBSprite(Game); + if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { + delete m_Image; + m_Image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont((char *)params); + if (!m_Font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->m_StringTable->Expand(&m_Text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) m_TextAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) m_TextAlign = TAL_RIGHT; + else m_TextAlign = TAL_CENTER; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) m_VerticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "bottom") == 0) m_VerticalAlign = VAL_BOTTOM; + else m_VerticalAlign = VAL_CENTER; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &m_Width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_Height); + break; + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &m_ParentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &m_Disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &m_Visible); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in STATIC definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading STATIC definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "STATIC\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Back && m_Back->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + + if (m_Image && m_Image->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + if (m_Text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + + switch (m_TextAlign) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + } + + switch (m_VerticalAlign) { + case VAL_TOP: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SizeToFit + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SizeToFit") == 0) { + Stack->CorrectParams(0); + SizeToFit(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HeightToFit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HeightToFit") == 0) { + Stack->CorrectParams(0); + if (m_Font && m_Text) m_Height = m_Font->GetTextHeight((byte *)m_Text, m_Width); + Stack->PushNULL(); + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIText::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("static"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextAlign") == 0) { + m_ScValue->SetInt(m_TextAlign); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VerticalAlign") == 0) { + m_ScValue->SetInt(m_VerticalAlign); + return m_ScValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "TextAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + m_TextAlign = (TTextAlign)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VerticalAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; + m_VerticalAlign = (TVerticalAlign)i; + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIText::ScToString() { + return "[static]"; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(m_TextAlign)); + PersistMgr->Transfer(TMEMBER_INT(m_VerticalAlign)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::SizeToFit() { + if (m_Font && m_Text) { + m_Width = m_Font->GetTextWidth((byte *)m_Text); + m_Height = m_Font->GetTextHeight((byte *)m_Text, m_Width); + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h new file mode 100644 index 0000000000..74158cb636 --- /dev/null +++ b/engines/wintermute/UIText.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITEXT_H +#define WINTERMUTE_UITEXT_H + + +#include "UIObject.h" + +namespace WinterMute { + +class CUIText : public CUIObject { +public: + HRESULT SizeToFit(); + virtual HRESULT Display(int OffsetX, int OffsetY); + DECLARE_PERSISTENT(CUIText, CUIObject) + CUIText(CBGame *inGame = NULL); + virtual ~CUIText(); + TTextAlign m_TextAlign; + TVerticalAlign m_VerticalAlign; + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp new file mode 100644 index 0000000000..488c1bdd7b --- /dev/null +++ b/engines/wintermute/UITiledImage.cpp @@ -0,0 +1,368 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/BSurface.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUITiledImage, false) + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { + m_Image = NULL; + + CBPlatform::SetRectEmpty(&m_UpLeft); + CBPlatform::SetRectEmpty(&m_UpMiddle); + CBPlatform::SetRectEmpty(&m_UpRight); + CBPlatform::SetRectEmpty(&m_MiddleLeft); + CBPlatform::SetRectEmpty(&m_MiddleMiddle); + CBPlatform::SetRectEmpty(&m_MiddleRight); + CBPlatform::SetRectEmpty(&m_DownLeft); + CBPlatform::SetRectEmpty(&m_DownMiddle); + CBPlatform::SetRectEmpty(&m_DownRight); +} + + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::~CUITiledImage() { + SAFE_DELETE(m_Image); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { + if (!m_Image) return E_FAIL; + + int tile_width = m_MiddleMiddle.right - m_MiddleMiddle.left; + int tile_height = m_MiddleMiddle.bottom - m_MiddleMiddle.top; + + int num_columns = (Width - (m_MiddleLeft.right - m_MiddleLeft.left) - (m_MiddleRight.right - m_MiddleRight.left)) / tile_width; + int num_rows = (Height - (m_UpMiddle.bottom - m_UpMiddle.top) - (m_DownMiddle.bottom - m_DownMiddle.top)) / tile_height; + + int col, row; + + Game->m_Renderer->StartSpriteBatch(); + + // top left/right + m_Image->m_Surface->DisplayTrans(X, Y, m_UpLeft); + m_Image->m_Surface->DisplayTrans(X + (m_UpLeft.right - m_UpLeft.left) + num_columns * tile_width, Y, m_UpRight); + + // bottom left/right + m_Image->m_Surface->DisplayTrans(X, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownLeft); + m_Image->m_Surface->DisplayTrans(X + (m_UpLeft.right - m_UpLeft.left) + num_columns * tile_width, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownRight); + + // left/right + int yyy = Y + (m_UpMiddle.bottom - m_UpMiddle.top); + for (row = 0; row < num_rows; row++) { + m_Image->m_Surface->DisplayTrans(X, yyy, m_MiddleLeft); + m_Image->m_Surface->DisplayTrans(X + (m_MiddleLeft.right - m_MiddleLeft.left) + num_columns * tile_width, yyy, m_MiddleRight); + yyy += tile_width; + } + + // top/bottom + int xxx = X + (m_UpLeft.right - m_UpLeft.left); + for (col = 0; col < num_columns; col++) { + m_Image->m_Surface->DisplayTrans(xxx, Y, m_UpMiddle); + m_Image->m_Surface->DisplayTrans(xxx, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownMiddle); + xxx += tile_width; + } + + // tiles + yyy = Y + (m_UpMiddle.bottom - m_UpMiddle.top); + for (row = 0; row < num_rows; row++) { + xxx = X + (m_UpLeft.right - m_UpLeft.left); + for (col = 0; col < num_columns; col++) { + m_Image->m_Surface->DisplayTrans(xxx, yyy, m_MiddleMiddle); + xxx += tile_width; + } + yyy += tile_width; + } + + Game->m_Renderer->EndSpriteBatch(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TILED_IMAGE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(UP_MIDDLE) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(DOWN_MIDDLE) +TOKEN_DEF(MIDDLE_LEFT) +TOKEN_DEF(MIDDLE_RIGHT) +TOKEN_DEF(MIDDLE_MIDDLE) +TOKEN_DEF(VERTICAL_TILES) +TOKEN_DEF(HORIZONTAL_TILES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TILED_IMAGE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(UP_MIDDLE) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(DOWN_MIDDLE) + TOKEN_TABLE(MIDDLE_LEFT) + TOKEN_TABLE(MIDDLE_RIGHT) + TOKEN_TABLE(MIDDLE_MIDDLE) + TOKEN_TABLE(VERTICAL_TILES) + TOKEN_TABLE(HORIZONTAL_TILES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + bool HTiles = false, VTiles = false; + int H1 = 0, H2 = 0, H3 = 0; + int V1 = 0, V2 = 0, V3 = 0; + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + Game->LOG(0, "'TILED_IMAGE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_IMAGE: + SAFE_DELETE(m_Image); + m_Image = new CBSubFrame(Game); + if (!m_Image || FAILED(m_Image->SetSurface((char *)params))) { + SAFE_DELETE(m_Image); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_UP_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpLeft.left, &m_UpLeft.top, &m_UpLeft.right, &m_UpLeft.bottom); + break; + + case TOKEN_UP_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpRight.left, &m_UpRight.top, &m_UpRight.right, &m_UpRight.bottom); + break; + + case TOKEN_UP_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpMiddle.left, &m_UpMiddle.top, &m_UpMiddle.right, &m_UpMiddle.bottom); + break; + + case TOKEN_DOWN_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownLeft.left, &m_DownLeft.top, &m_DownLeft.right, &m_DownLeft.bottom); + break; + + case TOKEN_DOWN_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownRight.left, &m_DownRight.top, &m_DownRight.right, &m_DownRight.bottom); + break; + + case TOKEN_DOWN_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownMiddle.left, &m_DownMiddle.top, &m_DownMiddle.right, &m_DownMiddle.bottom); + break; + + case TOKEN_MIDDLE_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleLeft.left, &m_MiddleLeft.top, &m_MiddleLeft.right, &m_MiddleLeft.bottom); + break; + + case TOKEN_MIDDLE_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleRight.left, &m_MiddleRight.top, &m_MiddleRight.right, &m_MiddleRight.bottom); + break; + + case TOKEN_MIDDLE_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleMiddle.left, &m_MiddleMiddle.top, &m_MiddleMiddle.right, &m_MiddleMiddle.bottom); + break; + + case TOKEN_HORIZONTAL_TILES: + parser.ScanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); + HTiles = true; + break; + + case TOKEN_VERTICAL_TILES: + parser.ScanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); + VTiles = true; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TILED_IMAGE definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading TILED_IMAGE definition"); + return E_FAIL; + } + + if (VTiles && HTiles) { + // up row + CBPlatform::SetRect(&m_UpLeft, 0, 0, H1, V1); + CBPlatform::SetRect(&m_UpMiddle, H1, 0, H1 + H2, V1); + CBPlatform::SetRect(&m_UpRight, H1 + H2, 0, H1 + H2 + H3, V1); + + // middle row + CBPlatform::SetRect(&m_MiddleLeft, 0, V1, H1, V1 + V2); + CBPlatform::SetRect(&m_MiddleMiddle, H1, V1, H1 + H2, V1 + V2); + CBPlatform::SetRect(&m_MiddleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); + + // down row + CBPlatform::SetRect(&m_DownLeft, 0, V1 + V2, H1, V1 + V2 + V3); + CBPlatform::SetRect(&m_DownMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); + CBPlatform::SetRect(&m_DownRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); + } + + // default + if (m_Image && m_Image->m_Surface) { + int Width = m_Image->m_Surface->GetWidth() / 3; + int Height = m_Image->m_Surface->GetHeight() / 3; + + if (CBPlatform::IsRectEmpty(&m_UpLeft)) CBPlatform::SetRect(&m_UpLeft, 0, 0, Width, Height); + if (CBPlatform::IsRectEmpty(&m_UpMiddle)) CBPlatform::SetRect(&m_UpMiddle, Width, 0, 2 * Width, Height); + if (CBPlatform::IsRectEmpty(&m_UpRight)) CBPlatform::SetRect(&m_UpRight, 2 * Width, 0, 3 * Width, Height); + + if (CBPlatform::IsRectEmpty(&m_MiddleLeft)) CBPlatform::SetRect(&m_MiddleLeft, 0, Height, Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&m_MiddleMiddle)) CBPlatform::SetRect(&m_MiddleMiddle, Width, Height, 2 * Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&m_MiddleRight)) CBPlatform::SetRect(&m_MiddleRight, 2 * Width, Height, 3 * Width, 2 * Height); + + if (CBPlatform::IsRectEmpty(&m_DownLeft)) CBPlatform::SetRect(&m_DownLeft, 0, 2 * Height, Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&m_DownMiddle)) CBPlatform::SetRect(&m_DownMiddle, Width, 2 * Height, 2 * Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&m_DownRight)) CBPlatform::SetRect(&m_DownRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + if (m_Image && m_Image->m_SurfaceFilename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_SurfaceFilename); + + int H1, H2, H3; + int V1, V2, V3; + + H1 = m_UpLeft.right; + H2 = m_UpMiddle.right - m_UpMiddle.left; + H3 = m_UpRight.right - m_UpRight.left; + + V1 = m_UpLeft.bottom; + V2 = m_MiddleLeft.bottom - m_MiddleLeft.top; + V3 = m_DownLeft.bottom - m_DownLeft.top; + + + Buffer->PutTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); + Buffer->PutTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUITiledImage::CorrectSize(int *Width, int *Height) { + int tile_width = m_MiddleMiddle.right - m_MiddleMiddle.left; + int tile_height = m_MiddleMiddle.bottom - m_MiddleMiddle.top; + + int num_columns = (*Width - (m_MiddleLeft.right - m_MiddleLeft.left) - (m_MiddleRight.right - m_MiddleRight.left)) / tile_width; + int num_rows = (*Height - (m_UpMiddle.bottom - m_UpMiddle.top) - (m_DownMiddle.bottom - m_DownMiddle.top)) / tile_height; + + *Width = (m_MiddleLeft.right - m_MiddleLeft.left) + (m_MiddleRight.right - m_MiddleRight.left) + num_columns * tile_width; + *Height = (m_UpMiddle.bottom - m_UpMiddle.top) + (m_DownMiddle.bottom - m_DownMiddle.top) + num_rows * tile_height; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_DownLeft)); + PersistMgr->Transfer(TMEMBER(m_DownMiddle)); + PersistMgr->Transfer(TMEMBER(m_DownRight)); + PersistMgr->Transfer(TMEMBER(m_Image)); + PersistMgr->Transfer(TMEMBER(m_MiddleLeft)); + PersistMgr->Transfer(TMEMBER(m_MiddleMiddle)); + PersistMgr->Transfer(TMEMBER(m_MiddleRight)); + PersistMgr->Transfer(TMEMBER(m_UpLeft)); + PersistMgr->Transfer(TMEMBER(m_UpMiddle)); + PersistMgr->Transfer(TMEMBER(m_UpRight)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UITiledImage.h b/engines/wintermute/UITiledImage.h new file mode 100644 index 0000000000..e97b27f59e --- /dev/null +++ b/engines/wintermute/UITiledImage.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITILEDIMAGE_H +#define WINTERMUTE_UITILEDIMAGE_H + + +#include "UIObject.h" + +namespace WinterMute { +class CBSubFrame; +class CUITiledImage : public CBObject { +public: + DECLARE_PERSISTENT(CUITiledImage, CBObject) + void CorrectSize(int *Width, int *Height); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + HRESULT Display(int X, int Y, int Width, int Height); + CUITiledImage(CBGame *inGame = NULL); + virtual ~CUITiledImage(); + CBSubFrame *m_Image; + RECT m_UpLeft; + RECT m_UpMiddle; + RECT m_UpRight; + RECT m_MiddleLeft; + RECT m_MiddleMiddle; + RECT m_MiddleRight; + RECT m_DownLeft; + RECT m_DownMiddle; + RECT m_DownRight; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp new file mode 100644 index 0000000000..b68f788fcc --- /dev/null +++ b/engines/wintermute/UIWindow.cpp @@ -0,0 +1,1309 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "UIWindow.h" +#include "BGame.h" +#include "BParser.h" +#include "BActiveRect.h" +#include "BDynBuffer.h" +#include "BKeyboardState.h" +#include "ScValue.h" +#include "UIButton.h" +#include "UIEdit.h" +#include "UIText.h" +#include "UITiledImage.h" +#include "BViewport.h" +#include "BFontStorage.h" +#include "BFont.h" +#include "BStringTable.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIWindow, false) + +////////////////////////////////////////////////////////////////////////// +CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { + CBPlatform::SetRectEmpty(&m_TitleRect); + CBPlatform::SetRectEmpty(&m_DragRect); + m_TitleAlign = TAL_LEFT; + m_Transparent = false; + + m_BackInactive = NULL; + m_FontInactive = NULL; + m_ImageInactive = NULL; + + m_Type = UI_WINDOW; + m_CanFocus = true; + + m_Dragging = false; + m_DragFrom.x = m_DragFrom.y = 0; + + m_Mode = WINDOW_NORMAL; + m_ShieldWindow = NULL; + m_ShieldButton = NULL; + + m_FadeColor = 0x00000000; + m_FadeBackground = false; + + m_Ready = true; + m_IsMenu = false; + m_InGame = false; + + m_ClipContents = false; + m_Viewport = NULL; + + m_PauseMusic = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIWindow::~CUIWindow() { + Close(); + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::Cleanup() { + delete m_ShieldWindow; + delete m_ShieldButton; + delete m_Viewport; + m_ShieldWindow = NULL; + m_ShieldButton = NULL; + m_Viewport = NULL; + + if (m_BackInactive) delete m_BackInactive; + if (!m_SharedFonts && m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); + if (!m_SharedImages && m_ImageInactive) delete m_ImageInactive; + + for (int i = 0; i < m_Widgets.GetSize(); i++) delete m_Widgets[i]; + m_Widgets.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { + // go exclusive + if (m_Mode == WINDOW_EXCLUSIVE || m_Mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (!m_ShieldWindow) m_ShieldWindow = new CUIWindow(Game); + if (m_ShieldWindow) { + m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; + m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; + m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; + + m_ShieldWindow->Display(); + } + } else if (m_IsMenu) { + if (!m_ShieldButton) { + m_ShieldButton = new CUIButton(Game); + m_ShieldButton->SetName("close"); + m_ShieldButton->SetListener(this, m_ShieldButton, 0); + m_ShieldButton->m_Parent = this; + } + if (m_ShieldButton) { + m_ShieldButton->m_PosX = m_ShieldButton->m_PosY = 0; + m_ShieldButton->m_Width = Game->m_Renderer->m_Width; + m_ShieldButton->m_Height = Game->m_Renderer->m_Height; + + m_ShieldButton->Display(); + } + } + + if (!m_Visible) return S_OK; + + if (m_FadeBackground) Game->m_Renderer->FadeToColor(m_FadeColor); + + if (m_Dragging) { + m_PosX += (Game->m_MousePos.x - m_DragFrom.x); + m_PosY += (Game->m_MousePos.y - m_DragFrom.y); + + m_DragFrom.x = Game->m_MousePos.x; + m_DragFrom.y = Game->m_MousePos.y; + } + + if (!m_FocusedWidget || (!m_FocusedWidget->m_CanFocus || m_FocusedWidget->m_Disable || !m_FocusedWidget->m_Visible)) { + MoveFocus(); + } + + bool PopViewport = false; + if (m_ClipContents) { + if (!m_Viewport) m_Viewport = new CBViewport(Game); + if (m_Viewport) { + m_Viewport->SetRect(m_PosX + OffsetX, m_PosY + OffsetY, m_PosX + m_Width + OffsetX, m_PosY + m_Height + OffsetY); + Game->PushViewport(m_Viewport); + PopViewport = true; + } + } + + + CUITiledImage *back = m_Back; + CBSprite *image = m_Image; + CBFont *font = m_Font; + + if (!IsFocused()) { + if (m_BackInactive) back = m_BackInactive; + if (m_ImageInactive) image = m_ImageInactive; + if (m_FontInactive) font = m_FontInactive; + } + + if (m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = m_AlphaColor; + if (back) back->Display(m_PosX + OffsetX, m_PosY + OffsetY, m_Width, m_Height); + if (image) image->Draw(m_PosX + OffsetX, m_PosY + OffsetY, m_Transparent ? NULL : this); + + if (!CBPlatform::IsRectEmpty(&m_TitleRect) && font && m_Text) { + font->DrawText((byte *)m_Text, m_PosX + OffsetX + m_TitleRect.left, m_PosY + OffsetY + m_TitleRect.top, m_TitleRect.right - m_TitleRect.left, m_TitleAlign, m_TitleRect.bottom - m_TitleRect.top); + } + + if (!m_Transparent && !image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, m_PosX + OffsetX, m_PosY + OffsetY, m_Width, m_Height, 100, 100, false)); + + for (int i = 0; i < m_Widgets.GetSize(); i++) { + m_Widgets[i]->Display(m_PosX + OffsetX, m_PosY + OffsetY); + } + + if (m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = 0; + + if (PopViewport) Game->PopViewport(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WINDOW) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK_INACTIVE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE_INACTIVE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_INACTIVE) +TOKEN_DEF(FONT) +TOKEN_DEF(TITLE_ALIGN) +TOKEN_DEF(TITLE_RECT) +TOKEN_DEF(TITLE) +TOKEN_DEF(DRAG_RECT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(FADE_ALPHA) +TOKEN_DEF(FADE_COLOR) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(BUTTON) +TOKEN_DEF(STATIC) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MENU) +TOKEN_DEF(IN_GAME) +TOKEN_DEF(CLIP_CONTENTS) +TOKEN_DEF(PAUSE_MUSIC) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK_INACTIVE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE_INACTIVE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_INACTIVE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TITLE_ALIGN) + TOKEN_TABLE(TITLE_RECT) + TOKEN_TABLE(TITLE) + TOKEN_TABLE(DRAG_RECT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(FADE_ALPHA) + TOKEN_TABLE(FADE_COLOR) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MENU) + TOKEN_TABLE(IN_GAME) + TOKEN_TABLE(CLIP_CONTENTS) + TOKEN_TABLE(PAUSE_MUSIC) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + int FadeR = 0, FadeG = 0, FadeB = 0, FadeA = 0; + int ar = 0, ag = 0, ab = 0, alpha = 0; + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + Game->LOG(0, "'WINDOW' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + SAFE_DELETE(m_Back); + m_Back = new CUITiledImage(Game); + if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { + SAFE_DELETE(m_Back); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_INACTIVE: + SAFE_DELETE(m_BackInactive); + m_BackInactive = new CUITiledImage(Game); + if (!m_BackInactive || FAILED(m_BackInactive->LoadFile((char *)params))) { + SAFE_DELETE(m_BackInactive); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + SAFE_DELETE(m_Image); + m_Image = new CBSprite(Game); + if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { + SAFE_DELETE(m_Image); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_INACTIVE: + SAFE_DELETE(m_ImageInactive), + m_ImageInactive = new CBSprite(Game); + if (!m_ImageInactive || FAILED(m_ImageInactive->LoadFile((char *)params))) { + SAFE_DELETE(m_ImageInactive); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont((char *)params); + if (!m_Font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_INACTIVE: + if (m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); + m_FontInactive = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontInactive) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TITLE: + SetText((char *)params); + Game->m_StringTable->Expand(&m_Text); + break; + + case TOKEN_TITLE_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) m_TitleAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) m_TitleAlign = TAL_RIGHT; + else m_TitleAlign = TAL_CENTER; + break; + + case TOKEN_TITLE_RECT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_TitleRect.left, &m_TitleRect.top, &m_TitleRect.right, &m_TitleRect.bottom); + break; + + case TOKEN_DRAG_RECT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DragRect.left, &m_DragRect.top, &m_DragRect.right, &m_DragRect.bottom); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &m_Width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_Height); + break; + + case TOKEN_CURSOR: + SAFE_DELETE(m_Cursor); + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + SAFE_DELETE(m_Cursor); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BUTTON: { + CUIButton *btn = new CUIButton(Game); + if (!btn || FAILED(btn->LoadBuffer(params, false))) { + SAFE_DELETE(btn); + cmd = PARSERR_GENERIC; + } else { + btn->m_Parent = this; + m_Widgets.Add(btn); + } + } + break; + + case TOKEN_STATIC: { + CUIText *text = new CUIText(Game); + if (!text || FAILED(text->LoadBuffer(params, false))) { + SAFE_DELETE(text); + cmd = PARSERR_GENERIC; + } else { + text->m_Parent = this; + m_Widgets.Add(text); + } + } + break; + + case TOKEN_EDIT: { + CUIEdit *edit = new CUIEdit(Game); + if (!edit || FAILED(edit->LoadBuffer(params, false))) { + SAFE_DELETE(edit); + cmd = PARSERR_GENERIC; + } else { + edit->m_Parent = this; + m_Widgets.Add(edit); + } + } + break; + + case TOKEN_WINDOW: { + CUIWindow *win = new CUIWindow(Game); + if (!win || FAILED(win->LoadBuffer(params, false))) { + SAFE_DELETE(win); + cmd = PARSERR_GENERIC; + } else { + win->m_Parent = this; + m_Widgets.Add(win); + } + } + break; + + + case TOKEN_TRANSPARENT: + parser.ScanStr((char *)params, "%b", &m_Transparent); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &m_ParentNotify); + break; + + case TOKEN_PAUSE_MUSIC: + parser.ScanStr((char *)params, "%b", &m_PauseMusic); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &m_Disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &m_Visible); + break; + + case TOKEN_MENU: + parser.ScanStr((char *)params, "%b", &m_IsMenu); + break; + + case TOKEN_IN_GAME: + parser.ScanStr((char *)params, "%b", &m_InGame); + break; + + case TOKEN_CLIP_CONTENTS: + parser.ScanStr((char *)params, "%b", &m_ClipContents); + break; + + case TOKEN_FADE_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); + m_FadeBackground = true; + break; + + case TOKEN_FADE_ALPHA: + parser.ScanStr((char *)params, "%d", &FadeA); + m_FadeBackground = true; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + + default: + if (FAILED(Game->WindowLoadHook(this, (char **)&Buffer, (char **)params))) { + cmd = PARSERR_GENERIC; + } + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in WINDOW definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading WINDOW definition"); + return E_FAIL; + } + + CorrectSize(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + m_AlphaColor = DRGBA(ar, ag, ab, alpha); + + if (m_FadeBackground) m_FadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); + + m_FocusedWidget = NULL; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "WINDOW\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Back && m_Back->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + if (m_BackInactive && m_BackInactive->m_Filename) + Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", m_BackInactive->m_Filename); + + if (m_Image && m_Image->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + if (m_ImageInactive && m_ImageInactive->m_Filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", m_ImageInactive->m_Filename); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (m_FontInactive && m_FontInactive->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", m_FontInactive->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_Text) + Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", m_Text); + + switch (m_TitleAlign) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + break; + } + + if (!CBPlatform::IsRectEmpty(&m_TitleRect)) { + Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", m_TitleRect.left, m_TitleRect.top, m_TitleRect.right, m_TitleRect.bottom); + } + + if (!CBPlatform::IsRectEmpty(&m_DragRect)) { + Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", m_DragRect.left, m_DragRect.top, m_DragRect.right, m_DragRect.bottom); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", m_Transparent ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", m_PauseMusic ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", m_IsMenu ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", m_InGame ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", m_ClipContents ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (m_FadeBackground) { + Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_FadeColor), D3DCOLGetG(m_FadeColor), D3DCOLGetB(m_FadeColor)); + Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(m_FadeColor)); + } + + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_AlphaColor), D3DCOLGetG(m_AlphaColor), D3DCOLGetB(m_AlphaColor)); + Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(m_AlphaColor)); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + // controls + for (int i = 0; i < m_Widgets.GetSize(); i++) + m_Widgets[i]->SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::EnableWidget(char *Name, bool Enable) { + for (int i = 0; i < m_Widgets.GetSize(); i++) { + if (scumm_stricmp(m_Widgets[i]->m_Name, Name) == 0) m_Widgets[i]->m_Disable = !Enable; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ShowWidget(char *Name, bool Visible) { + for (int i = 0; i < m_Widgets.GetSize(); i++) { + if (scumm_stricmp(m_Widgets[i]->m_Name, Name) == 0) m_Widgets[i]->m_Visible = Visible; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetWidget / GetControl + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetWidget") == 0 || strcmp(Name, "GetControl") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + if (val->GetType() == VAL_INT) { + int widget = val->GetInt(); + if (widget < 0 || widget >= m_Widgets.GetSize()) Stack->PushNULL(); + else Stack->PushNative(m_Widgets[widget], true); + } else { + for (int i = 0; i < m_Widgets.GetSize(); i++) { + if (scumm_stricmp(m_Widgets[i]->m_Name, val->GetString()) == 0) { + Stack->PushNative(m_Widgets[i], true); + return S_OK; + } + } + Stack->PushNULL(); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInactiveFont") == 0) { + Stack->CorrectParams(1); + + if (m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); + m_FontInactive = Game->m_FontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(m_FontInactive != NULL); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInactiveImage") == 0) { + Stack->CorrectParams(1); + + delete m_ImageInactive; + m_ImageInactive = new CBSprite(Game); + char *Filename = Stack->Pop()->GetString(); + if (!m_ImageInactive || FAILED(m_ImageInactive->LoadFile(Filename))) { + delete m_ImageInactive; + m_ImageInactive = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInactiveImage") == 0) { + Stack->CorrectParams(0); + if (!m_ImageInactive || !m_ImageInactive->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_ImageInactive->m_Filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInactiveImageObject") == 0) { + Stack->CorrectParams(0); + if (!m_ImageInactive) Stack->PushNULL(); + else Stack->PushNative(m_ImageInactive, true); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Close") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(SUCCEEDED(Close())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoExclusive") == 0) { + Stack->CorrectParams(0); + GoExclusive(); + Script->WaitFor(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoSystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoSystemExclusive") == 0) { + Stack->CorrectParams(0); + GoSystemExclusive(); + Script->WaitFor(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Center + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Center") == 0) { + Stack->CorrectParams(0); + m_PosX = (Game->m_Renderer->m_Width - m_Width) / 2; + m_PosY = (Game->m_Renderer->m_Height - m_Height) / 2; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadFromFile + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadFromFile") == 0) { + Stack->CorrectParams(1); + + CScValue *Val = Stack->Pop(); + Cleanup(); + if (!Val->IsNULL()) { + Stack->PushBool(SUCCEEDED(LoadFile(Val->GetString()))); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateButton") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIButton *Btn = new CUIButton(Game); + if (!Val->IsNULL()) Btn->SetName(Val->GetString()); + Stack->PushNative(Btn, true); + + Btn->m_Parent = this; + m_Widgets.Add(Btn); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateStatic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateStatic") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIText *Sta = new CUIText(Game); + if (!Val->IsNULL()) Sta->SetName(Val->GetString()); + Stack->PushNative(Sta, true); + + Sta->m_Parent = this; + m_Widgets.Add(Sta); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEditor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEditor") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIEdit *Edi = new CUIEdit(Game); + if (!Val->IsNULL()) Edi->SetName(Val->GetString()); + Stack->PushNative(Edi, true); + + Edi->m_Parent = this; + m_Widgets.Add(Edi); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateWindow") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIWindow *Win = new CUIWindow(Game); + if (!Val->IsNULL()) Win->SetName(Val->GetString()); + Stack->PushNative(Win, true); + + Win->m_Parent = this; + m_Widgets.Add(Win); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteControl") == 0 || strcmp(Name, "DeleteButton") == 0 || strcmp(Name, "DeleteStatic") == 0 || strcmp(Name, "DeleteEditor") == 0 || strcmp(Name, "DeleteWindow") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CUIObject *obj = (CUIObject *)val->GetNative(); + + for (int i = 0; i < m_Widgets.GetSize(); i++) { + if (m_Widgets[i] == obj) { + delete m_Widgets[i]; + m_Widgets.RemoveAt(i); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + } + } + Stack->PushNULL(); + return S_OK; + } else if SUCCEEDED(Game->WindowScriptMethodHook(this, Script, Stack, Name)) return S_OK; + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIWindow::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("window"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWidgets / NumControls (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumWidgets") == 0 || strcmp(Name, "NumControls") == 0) { + m_ScValue->SetInt(m_Widgets.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exclusive") == 0) { + m_ScValue->SetBool(m_Mode == WINDOW_EXCLUSIVE); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SystemExclusive") == 0) { + m_ScValue->SetBool(m_Mode == WINDOW_SYSTEM_EXCLUSIVE); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Menu") == 0) { + m_ScValue->SetBool(m_IsMenu); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InGame") == 0) { + m_ScValue->SetBool(m_InGame); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0) { + m_ScValue->SetBool(m_PauseMusic); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClipContents") == 0) { + m_ScValue->SetBool(m_ClipContents); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Transparent") == 0) { + m_ScValue->SetBool(m_Transparent); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeColor") == 0) { + m_ScValue->SetInt((int)m_FadeColor); + return m_ScValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Menu") == 0) { + m_IsMenu = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InGame") == 0) { + m_InGame = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0) { + m_PauseMusic = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClipContents") == 0) { + m_ClipContents = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Transparent") == 0) { + m_Transparent = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeColor") == 0) { + m_FadeColor = (uint32)Value->GetInt(); + m_FadeBackground = (m_FadeColor != 0); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exclusive") == 0) { + if (Value->GetBool()) + GoExclusive(); + else { + Close(); + m_Visible = true; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SystemExclusive") == 0) { + if (Value->GetBool()) + GoSystemExclusive(); + else { + Close(); + m_Visible = true; + } + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CUIWindow::ScToString() { + return "[window]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::HandleKeypress(SDL_Event *event) { + + if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { + return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); + } else { + if (m_FocusedWidget) return m_FocusedWidget->HandleKeypress(event); + else return false; + } + + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::HandleMouseWheel(int Delta) { + if (m_FocusedWidget) return m_FocusedWidget->HandleMouseWheel(Delta); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { + HRESULT res = CUIObject::HandleMouse(Event, Button); + + // handle window dragging + if (!CBPlatform::IsRectEmpty(&m_DragRect)) { + // start drag + if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { + RECT DragRect = m_DragRect; + int OffsetX, OffsetY; + GetTotalOffset(&OffsetX, &OffsetY); + CBPlatform::OffsetRect(&DragRect, m_PosX + OffsetX, m_PosY + OffsetY); + + if (CBPlatform::PtInRect(&DragRect, Game->m_MousePos)) { + m_DragFrom.x = Game->m_MousePos.x; + m_DragFrom.y = Game->m_MousePos.y; + m_Dragging = true; + } + } + // end drag + else if (m_Dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { + m_Dragging = false; + } + } + + return res; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_BackInactive)); + PersistMgr->Transfer(TMEMBER(m_ClipContents)); + PersistMgr->Transfer(TMEMBER(m_DragFrom)); + PersistMgr->Transfer(TMEMBER(m_Dragging)); + PersistMgr->Transfer(TMEMBER(m_DragRect)); + PersistMgr->Transfer(TMEMBER(m_FadeBackground)); + PersistMgr->Transfer(TMEMBER(m_FadeColor)); + PersistMgr->Transfer(TMEMBER(m_FontInactive)); + PersistMgr->Transfer(TMEMBER(m_ImageInactive)); + PersistMgr->Transfer(TMEMBER(m_InGame)); + PersistMgr->Transfer(TMEMBER(m_IsMenu)); + PersistMgr->Transfer(TMEMBER_INT(m_Mode)); + PersistMgr->Transfer(TMEMBER(m_ShieldButton)); + PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); + PersistMgr->Transfer(TMEMBER_INT(m_TitleAlign)); + PersistMgr->Transfer(TMEMBER(m_TitleRect)); + PersistMgr->Transfer(TMEMBER(m_Transparent)); + PersistMgr->Transfer(TMEMBER(m_Viewport)); + PersistMgr->Transfer(TMEMBER(m_PauseMusic)); + + m_Widgets.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::MoveFocus(bool Forward) { + int i; + bool found = false; + for (i = 0; i < m_Widgets.GetSize(); i++) { + if (m_Widgets[i] == m_FocusedWidget) { + found = true; + break; + } + } + if (!found) m_FocusedWidget = NULL; + + if (!m_FocusedWidget) { + if (m_Widgets.GetSize() > 0) i = 0; + else return S_OK; + } + + int NumTries = 0; + bool done = false; + + while (NumTries <= m_Widgets.GetSize()) { + if (m_Widgets[i] != m_FocusedWidget && m_Widgets[i]->m_CanFocus && m_Widgets[i]->m_Visible && !m_Widgets[i]->m_Disable) { + m_FocusedWidget = m_Widgets[i]; + done = true; + break; + } + + if (Forward) { + i++; + if (i >= m_Widgets.GetSize()) i = 0; + } else { + i--; + if (i < 0) i = m_Widgets.GetSize() - 1; + } + NumTries++; + } + + return done ? S_OK : E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GoExclusive() { + if (m_Mode == WINDOW_EXCLUSIVE) return S_OK; + + if (m_Mode == WINDOW_NORMAL) { + m_Ready = false; + m_Mode = WINDOW_EXCLUSIVE; + m_Visible = true; + m_Disable = false; + Game->FocusWindow(this); + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GoSystemExclusive() { + if (m_Mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; + + MakeFreezable(false); + + m_Mode = WINDOW_SYSTEM_EXCLUSIVE; + m_Ready = false; + m_Visible = true; + m_Disable = false; + Game->FocusWindow(this); + + Game->Freeze(m_PauseMusic); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Close() { + if (m_Mode == WINDOW_SYSTEM_EXCLUSIVE) { + Game->Unfreeze(); + } + + m_Mode = WINDOW_NORMAL; + m_Visible = false; + m_Ready = true; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->m_Type) { + case UI_BUTTON: + if (scumm_stricmp(obj->m_Name, "close") == 0) Close(); + else return CBObject::Listen(param1, param2); + break; + default: + return CBObject::Listen(param1, param2); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::MakeFreezable(bool Freezable) { + for (int i = 0; i < m_Widgets.GetSize(); i++) + m_Widgets[i]->MakeFreezable(Freezable); + + CBObject::MakeFreezable(Freezable); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GetWindowObjects(CBArray& Objects, bool InteractiveOnly) { + for (int i = 0; i < m_Widgets.GetSize(); i++) { + CUIObject *Control = m_Widgets[i]; + if (Control->m_Disable && InteractiveOnly) continue; + + switch (Control->m_Type) { + case UI_WINDOW: + ((CUIWindow *)Control)->GetWindowObjects(Objects, InteractiveOnly); + break; + + case UI_BUTTON: + case UI_EDIT: + Objects.Add(Control); + break; + + default: + if (!InteractiveOnly) Objects.Add(Control); + } + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h new file mode 100644 index 0000000000..b8adc2f27f --- /dev/null +++ b/engines/wintermute/UIWindow.h @@ -0,0 +1,92 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIWINDOW_H +#define WINTERMUTE_UIWINDOW_H + + +#include "UIObject.h" + +namespace WinterMute { + +class CUIButton; +class CBViewport; +class CUIWindow : public CUIObject { +public: + HRESULT GetWindowObjects(CBArray& Objects, bool InteractiveOnly); + + bool m_PauseMusic; + void Cleanup(); + virtual void MakeFreezable(bool Freezable); + CBViewport *m_Viewport; + bool m_ClipContents; + bool m_InGame; + bool m_IsMenu; + bool m_FadeBackground; + uint32 m_FadeColor; + virtual bool HandleMouseWheel(int Delta); + CUIWindow *m_ShieldWindow; + CUIButton *m_ShieldButton; + HRESULT Close(); + HRESULT GoSystemExclusive(); + HRESULT GoExclusive(); + TWindowMode m_Mode; + HRESULT MoveFocus(bool Forward = true); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + POINT m_DragFrom; + bool m_Dragging; + DECLARE_PERSISTENT(CUIWindow, CUIObject) + bool m_Transparent; + HRESULT ShowWidget(char *Name, bool Visible = true); + HRESULT EnableWidget(char *Name, bool Enable = true); + RECT m_TitleRect; + RECT m_DragRect; + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + CUIWindow(CBGame *inGame); + virtual ~CUIWindow(); + virtual bool HandleKeypress(SDL_Event *event); + CBArray m_Widgets; + TTextAlign m_TitleAlign; + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CUITiledImage *m_BackInactive; + CBFont *m_FontInactive; + CBSprite *m_ImageInactive; + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index e6847eb585..a7bac98891 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -42,6 +42,10 @@ MODULE_OBJS := \ StringUtil.o \ SysClass.o \ SysInstance.o \ + UIButton.o \ + UIEntity.o \ + UIObject.o \ + UITiledImage.o \ utils.o \ wintermute.o -- cgit v1.2.3 From 2b586a768f7ef486f64b36a93993809beea184f7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 04:34:46 +0100 Subject: WINTERMUTE: Add the AD-classfiles --- engines/wintermute/AdActor.cpp | 1339 +++++++++++++++ engines/wintermute/AdActor.h | 107 ++ engines/wintermute/AdActorDir.cpp | 52 + engines/wintermute/AdActorDir.h | 46 + engines/wintermute/AdEntity.cpp | 959 +++++++++++ engines/wintermute/AdGame.cpp | 2062 ++++++++++++++++++++++ engines/wintermute/AdGame.h | 162 ++ engines/wintermute/AdInventory.cpp | 119 ++ engines/wintermute/AdInventory.h | 52 + engines/wintermute/AdInventoryBox.cpp | 368 ++++ engines/wintermute/AdInventoryBox.h | 63 + engines/wintermute/AdItem.cpp | 754 ++++++++ engines/wintermute/AdItem.h | 70 + engines/wintermute/AdLayer.cpp | 535 ++++++ engines/wintermute/AdLayer.h | 58 + engines/wintermute/AdNodeState.cpp | 169 ++ engines/wintermute/AdNodeState.h | 58 + engines/wintermute/AdObject.cpp | 1190 +++++++++++++ engines/wintermute/AdPath.cpp | 112 ++ engines/wintermute/AdPath.h | 56 + engines/wintermute/AdPathPoint.cpp | 75 + engines/wintermute/AdPathPoint.h | 50 + engines/wintermute/AdRegion.cpp | 394 +++++ engines/wintermute/AdRegion.h | 58 + engines/wintermute/AdResponse.cpp | 143 ++ engines/wintermute/AdResponse.h | 61 + engines/wintermute/AdResponseBox.cpp | 631 +++++++ engines/wintermute/AdResponseBox.h | 85 + engines/wintermute/AdResponseContext.cpp | 70 + engines/wintermute/AdResponseContext.h | 50 + engines/wintermute/AdRotLevel.cpp | 159 ++ engines/wintermute/AdRotLevel.h | 49 + engines/wintermute/AdScaleLevel.cpp | 157 ++ engines/wintermute/AdScaleLevel.h | 50 + engines/wintermute/AdScene.cpp | 2760 ++++++++++++++++++++++++++++++ engines/wintermute/AdScene.h | 181 ++ engines/wintermute/AdSceneNode.cpp | 83 + engines/wintermute/AdSceneNode.h | 54 + engines/wintermute/AdSceneState.cpp | 87 + engines/wintermute/AdSceneState.h | 51 + engines/wintermute/AdSentence.cpp | 317 ++++ engines/wintermute/AdSentence.h | 83 + engines/wintermute/AdSpriteSet.cpp | 312 ++++ engines/wintermute/AdSpriteSet.h | 54 + engines/wintermute/AdTalkDef.cpp | 260 +++ engines/wintermute/AdTalkDef.h | 58 + engines/wintermute/AdTalkHolder.cpp | 355 ++++ engines/wintermute/AdTalkNode.cpp | 263 +++ engines/wintermute/AdTalkNode.h | 63 + engines/wintermute/AdWaypointGroup.cpp | 260 +++ engines/wintermute/AdWaypointGroup.h | 58 + 51 files changed, 15662 insertions(+) create mode 100644 engines/wintermute/AdActor.cpp create mode 100644 engines/wintermute/AdActor.h create mode 100644 engines/wintermute/AdActorDir.cpp create mode 100644 engines/wintermute/AdActorDir.h create mode 100644 engines/wintermute/AdEntity.cpp create mode 100644 engines/wintermute/AdGame.cpp create mode 100644 engines/wintermute/AdGame.h create mode 100644 engines/wintermute/AdInventory.cpp create mode 100644 engines/wintermute/AdInventory.h create mode 100644 engines/wintermute/AdInventoryBox.cpp create mode 100644 engines/wintermute/AdInventoryBox.h create mode 100644 engines/wintermute/AdItem.cpp create mode 100644 engines/wintermute/AdItem.h create mode 100644 engines/wintermute/AdLayer.cpp create mode 100644 engines/wintermute/AdLayer.h create mode 100644 engines/wintermute/AdNodeState.cpp create mode 100644 engines/wintermute/AdNodeState.h create mode 100644 engines/wintermute/AdObject.cpp create mode 100644 engines/wintermute/AdPath.cpp create mode 100644 engines/wintermute/AdPath.h create mode 100644 engines/wintermute/AdPathPoint.cpp create mode 100644 engines/wintermute/AdPathPoint.h create mode 100644 engines/wintermute/AdRegion.cpp create mode 100644 engines/wintermute/AdRegion.h create mode 100644 engines/wintermute/AdResponse.cpp create mode 100644 engines/wintermute/AdResponse.h create mode 100644 engines/wintermute/AdResponseBox.cpp create mode 100644 engines/wintermute/AdResponseBox.h create mode 100644 engines/wintermute/AdResponseContext.cpp create mode 100644 engines/wintermute/AdResponseContext.h create mode 100644 engines/wintermute/AdRotLevel.cpp create mode 100644 engines/wintermute/AdRotLevel.h create mode 100644 engines/wintermute/AdScaleLevel.cpp create mode 100644 engines/wintermute/AdScaleLevel.h create mode 100644 engines/wintermute/AdScene.cpp create mode 100644 engines/wintermute/AdScene.h create mode 100644 engines/wintermute/AdSceneNode.cpp create mode 100644 engines/wintermute/AdSceneNode.h create mode 100644 engines/wintermute/AdSceneState.cpp create mode 100644 engines/wintermute/AdSceneState.h create mode 100644 engines/wintermute/AdSentence.cpp create mode 100644 engines/wintermute/AdSentence.h create mode 100644 engines/wintermute/AdSpriteSet.cpp create mode 100644 engines/wintermute/AdSpriteSet.h create mode 100644 engines/wintermute/AdTalkDef.cpp create mode 100644 engines/wintermute/AdTalkDef.h create mode 100644 engines/wintermute/AdTalkHolder.cpp create mode 100644 engines/wintermute/AdTalkNode.cpp create mode 100644 engines/wintermute/AdTalkNode.h create mode 100644 engines/wintermute/AdWaypointGroup.cpp create mode 100644 engines/wintermute/AdWaypointGroup.h (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp new file mode 100644 index 0000000000..a5d269e13a --- /dev/null +++ b/engines/wintermute/AdActor.cpp @@ -0,0 +1,1339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "dctypes.h" +#include "persistent.h" +#include "BObject.h" +#include "AdActor.h" +#include "AdGame.h" +#include "BParser.h" +#include "ScValue.h" +#include "ScStack.h" +#include "BObject.h" +#include "BSound.h" +#include "AdScene.h" +#include "AdEntity.h" +#include "AdSpriteSet.h" +#include "AdWaypointGroup.h" +#include "AdPath.h" +#include "AdSentence.h" +#include "AdPath.h" +#include "ScScript.h" +#include "BRegion.h" +#include "BFileManager.h" +#include "AdPath.h" +#include "utils.h" +#include "PlatformSDL.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActor, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { + m_Path = new CAdPath(Game); + + m_Type = OBJECT_ACTOR; + m_Dir = DI_LEFT; + + m_WalkSprite = NULL; + m_StandSprite = NULL; + m_TurnLeftSprite = NULL; + m_TurnRightSprite = NULL; + + m_TargetPoint = new CBPoint; + m_AfterWalkDir = DI_NONE; + + m_AnimSprite2 = NULL; + + SetDefaultAnimNames(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::SetDefaultAnimNames() { + m_TalkAnimName = NULL; + CBUtils::SetString(&m_TalkAnimName, "talk"); + + m_IdleAnimName = NULL; + CBUtils::SetString(&m_IdleAnimName, "idle"); + + m_WalkAnimName = NULL; + CBUtils::SetString(&m_WalkAnimName, "walk"); + + m_TurnLeftAnimName = NULL; + CBUtils::SetString(&m_TurnLeftAnimName, "turnleft"); + + m_TurnRightAnimName = NULL; + CBUtils::SetString(&m_TurnRightAnimName, "turnright"); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdActor::~CAdActor() { + delete m_Path; + delete m_TargetPoint; + m_Path = NULL; + m_TargetPoint = NULL; + + delete m_WalkSprite; + delete m_StandSprite; + delete m_TurnLeftSprite; + delete m_TurnRightSprite; + m_WalkSprite = NULL; + m_StandSprite = NULL; + m_TurnLeftSprite = NULL; + m_TurnRightSprite = NULL; + + m_AnimSprite2 = NULL; // ref only + + for (int i = 0; i < m_TalkSprites.GetSize(); i++) { + delete m_TalkSprites[i]; + } + m_TalkSprites.RemoveAll(); + + for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + delete m_TalkSpritesEx[i]; + } + m_TalkSpritesEx.RemoveAll(); + + + delete[] m_TalkAnimName; + delete[] m_IdleAnimName; + delete[] m_WalkAnimName; + delete[] m_TurnLeftAnimName; + delete[] m_TurnRightAnimName; + m_TalkAnimName = NULL; + m_IdleAnimName = NULL; + m_WalkAnimName = NULL; + m_TurnLeftAnimName = NULL; + m_TurnRightAnimName = NULL; + + for (int i = 0; i < m_Anims.GetSize(); i++) { + delete m_Anims[i]; + m_Anims[i] = NULL; + } + m_Anims.RemoveAll(); + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ACTOR) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(WALK) +TOKEN_DEF(STAND) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(TURN_LEFT) +TOKEN_DEF(TURN_RIGHT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ANIMATION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTOR) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(WALK) + TOKEN_TABLE(STAND) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TURN_LEFT) + TOKEN_TABLE(TURN_RIGHT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + Game->LOG(0, "'ACTOR' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CAdGame *AdGame = (CAdGame *)Game; + CAdSpriteSet *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.ScanStr((char *)params, "%b", &m_Zoomable); + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.ScanStr((char *)params, "%b", &m_Rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.ScanStr((char *)params, "%b", &m_Registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.ScanStr((char *)params, "%b", &m_Shadowable); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &m_Active); + break; + + case TOKEN_WALK: + delete m_WalkSprite; + m_WalkSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + else m_WalkSprite = spr; + break; + + case TOKEN_TALK: + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSprites.Add(spr); + break; + + case TOKEN_TALK_SPECIAL: + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSpritesEx.Add(spr); + break; + + case TOKEN_STAND: + delete m_StandSprite; + m_StandSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexStandLifeTime))) cmd = PARSERR_GENERIC; + else m_StandSprite = spr; + break; + + case TOKEN_TURN_LEFT: + delete m_TurnLeftSprite; + m_TurnLeftSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + else m_TurnLeftSprite = spr; + break; + + case TOKEN_TURN_RIGHT: + delete m_TurnRightSprite; + m_TurnRightSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + else m_TurnRightSprite = spr; + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SOUND_VOLUME: + parser.ScanStr((char *)params, "%d", &m_SFXVolume); + break; + + case TOKEN_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + m_Scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + m_RelativeScale = (float)s; + + } + break; + + case TOKEN_SOUND_PANNING: + parser.ScanStr((char *)params, "%b", &m_AutoSoundPanning); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_BLOCKED_REGION: { + delete m_BlockRegion; + delete m_CurrentBlockRegion; + m_BlockRegion = NULL; + m_CurrentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(Game); + CBRegion *crgn = new CBRegion(Game); + if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + delete m_BlockRegion; + delete m_CurrentBlockRegion; + m_BlockRegion = NULL; + m_CurrentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + m_BlockRegion = rgn; + m_CurrentBlockRegion = crgn; + m_CurrentBlockRegion->Mimic(m_BlockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete m_WptGroup; + delete m_CurrentWptGroup; + m_WptGroup = NULL; + m_CurrentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + delete m_WptGroup; + delete m_CurrentWptGroup; + m_WptGroup = NULL; + m_CurrentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + m_WptGroup = wpt; + m_CurrentWptGroup = cwpt; + m_CurrentWptGroup->Mimic(m_WptGroup); + } + } + break; + + case TOKEN_IGNORE_ITEMS: + parser.ScanStr((char *)params, "%b", &m_IgnoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + if (!Anim || FAILED(Anim->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + else m_Anims.Add(Anim); + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ACTOR definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + if (spr) delete spr; + Game->LOG(0, "Error loading ACTOR definition"); + return E_FAIL; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + m_AlphaColor = DRGBA(ar, ag, ab, alpha); + m_State = m_NextState = STATE_READY; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::TurnTo(TDirection dir) { + int delta1, delta2, delta3, delta; + + delta1 = dir - m_Dir; + delta2 = dir + NUM_DIRECTIONS - m_Dir; + delta3 = dir - NUM_DIRECTIONS - m_Dir; + + delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; + delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; + + // already there? + if (abs(delta) < 2) { + m_Dir = dir; + m_State = m_NextState; + m_NextState = STATE_READY; + return; + } + + m_TargetDir = dir; + m_State = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; + + m_TempSprite2 = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { + m_AfterWalkDir = AfterWalkDir; + if (X == m_TargetPoint->x && Y == m_TargetPoint->y && m_State == STATE_FOLLOWING_PATH) return; + + m_Path->Reset(); + m_Path->SetReady(false); + + m_TargetPoint->x = X; + m_TargetPoint->y = Y; + + ((CAdGame *)Game)->m_Scene->CorrectTargetPoint(m_PosX, m_PosY, &m_TargetPoint->x, &m_TargetPoint->y, true, this); + + m_State = STATE_SEARCHING_PATH; + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Display() { + if (m_Active) UpdateSounds(); + + uint32 Alpha; + if (m_AlphaColor != 0) Alpha = m_AlphaColor; + else Alpha = m_Shadowable ? ((CAdGame *)Game)->m_Scene->GetAlphaAt(m_PosX, m_PosY, true) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + + float Rotate; + if (m_Rotatable) { + if (m_RotateValid) Rotate = m_Rotate; + else Rotate = ((CAdGame *)Game)->m_Scene->GetRotationAt(m_PosX, m_PosY) + m_RelativeRotate; + } else Rotate = 0.0f; + + if (m_Active) DisplaySpriteAttachments(true); + + if (m_CurrentSprite && m_Active) { + bool Reg = m_Registrable; + if (m_IgnoreItems && ((CAdGame *)Game)->m_SelectedItem) Reg = false; + + m_CurrentSprite->Display(m_PosX, + m_PosY, + Reg ? m_RegisterAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + m_BlendMode); + + } + + if (m_Active) DisplaySpriteAttachments(false); + if (m_Active && m_PartEmitter) m_PartEmitter->Display(); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Update() { + m_CurrentSprite = NULL; + + if (m_State == STATE_READY) { + if (m_AnimSprite) { + delete m_AnimSprite; + m_AnimSprite = NULL; + } + if (m_AnimSprite2) { + m_AnimSprite2 = NULL; + } + } + + // finished playing animation? + if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { + m_State = m_NextState; + m_NextState = STATE_READY; + m_CurrentSprite = m_AnimSprite; + } + + if (m_State == STATE_PLAYING_ANIM_SET && m_AnimSprite2 != NULL && m_AnimSprite2->m_Finished) { + m_State = m_NextState; + m_NextState = STATE_READY; + m_CurrentSprite = m_AnimSprite2; + } + + if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + + // default: stand animation + if (!m_CurrentSprite) { + if (m_Sprite) m_CurrentSprite = m_Sprite; + else { + if (m_StandSprite) { + m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); + if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + } + } + } + + bool already_moved = false; + + switch (m_State) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + m_CurrentSprite = m_AnimSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM_SET: + m_CurrentSprite = m_AnimSprite2; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_LEFT: + if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished) { + if (m_Dir > 0) m_Dir = (TDirection)(m_Dir - 1); + else m_Dir = (TDirection)(NUM_DIRECTIONS - 1); + + if (m_Dir == m_TargetDir) { + m_TempSprite2 = NULL; + m_State = m_NextState; + m_NextState = STATE_READY; + } else { + if (m_TurnLeftSprite) { + m_TempSprite2 = m_TurnLeftSprite->GetSprite(m_Dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(m_TurnLeftAnimName); + if (Anim) m_TempSprite2 = Anim->GetSprite(m_Dir); + } + + if (m_TempSprite2) { + m_TempSprite2->Reset(); + if (m_TempSprite2->m_Looping) m_TempSprite2->m_Looping = false; + } + m_CurrentSprite = m_TempSprite2; + } + } else m_CurrentSprite = m_TempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_RIGHT: + if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished) { + m_Dir = (TDirection)(m_Dir + 1); + + if ((int)m_Dir >= (int)NUM_DIRECTIONS) m_Dir = (TDirection)(0); + + if (m_Dir == m_TargetDir) { + m_TempSprite2 = NULL; + m_State = m_NextState; + m_NextState = STATE_READY; + } else { + if (m_TurnRightSprite) { + m_TempSprite2 = m_TurnRightSprite->GetSprite(m_Dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(m_TurnRightAnimName); + if (Anim) m_TempSprite2 = Anim->GetSprite(m_Dir); + } + + if (m_TempSprite2) { + m_TempSprite2->Reset(); + if (m_TempSprite2->m_Looping) m_TempSprite2->m_Looping = false; + } + m_CurrentSprite = m_TempSprite2; + } + } else m_CurrentSprite = m_TempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_SEARCHING_PATH: + // keep asking scene for the path + if (((CAdGame *)Game)->m_Scene->GetPath(CBPoint(m_PosX, m_PosY), *m_TargetPoint, m_Path, this)) + m_State = STATE_WAITING_PATH; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_WAITING_PATH: + // wait until the scene finished the path + if (m_Path->m_Ready) FollowPath(); + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_FOLLOWING_PATH: + GetNextStep(); + already_moved = true; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + m_Sentence->Update(m_Dir); + if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + + bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); + if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + m_Sentence->Finish(); + m_TempSprite2 = NULL; + m_State = m_NextState; + m_NextState = STATE_READY; + } else { + m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); + if (m_TempSprite2) { + m_TempSprite2->Reset(); + m_CurrentSprite = m_TempSprite2; + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } + } else { + m_CurrentSprite = m_TempSprite2; + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!m_AnimSprite && !m_AnimSprite2) { + if (m_Sprite) m_CurrentSprite = m_Sprite; + else { + if (m_StandSprite) { + m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); + if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + } + } + } + break; + } + + + if (m_CurrentSprite && !already_moved) { + m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100, m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); + if (m_CurrentSprite->m_Changed) { + m_PosX += m_CurrentSprite->m_MoveX; + m_PosY += m_CurrentSprite->m_MoveY; + AfterMove(); + } + } + + //Game->QuickMessageForm("%s", m_CurrentSprite->m_Filename); + + UpdateBlockRegion(); + m_Ready = (m_State == STATE_READY); + + UpdatePartEmitter(); + UpdateSpriteAttachments(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::FollowPath() { + // skip current position + m_Path->GetFirst(); + while (m_Path->GetCurrent() != NULL) { + if (m_Path->GetCurrent()->x != m_PosX || m_Path->GetCurrent()->y != m_PosY) break; + m_Path->GetNext(); + } + + // are there points to follow? + if (m_Path->GetCurrent() != NULL) { + m_State = STATE_FOLLOWING_PATH;; + InitLine(CBPoint(m_PosX, m_PosY), *m_Path->GetCurrent()); + } else { + if (m_AfterWalkDir != DI_NONE) TurnTo(m_AfterWalkDir); + else m_State = STATE_READY; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::GetNextStep() { + if (m_WalkSprite) { + m_CurrentSprite = m_WalkSprite->GetSprite(m_Dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(m_WalkAnimName); + if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + } + + if (!m_CurrentSprite) return; + + m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100, m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); + if (!m_CurrentSprite->m_Changed) return; + + + int MaxStepX, MaxStepY; + MaxStepX = abs(m_CurrentSprite->m_MoveX); + MaxStepY = abs(m_CurrentSprite->m_MoveY); + + MaxStepX = std::max(MaxStepX, MaxStepY); + MaxStepX = std::max(MaxStepX, 1); + + while (m_PFCount > 0 && MaxStepX >= 0) { + m_PFX += m_PFStepX; + m_PFY += m_PFStepY; + + m_PFCount--; + MaxStepX--; + } + + if (((CAdGame *)Game)->m_Scene->IsBlockedAt(m_PFX, m_PFY, true, this)) { + if (m_PFCount == 0) { + m_State = m_NextState; + m_NextState = STATE_READY; + return; + } + GoTo(m_TargetPoint->x, m_TargetPoint->y); + return; + } + + + m_PosX = (int)m_PFX; + m_PosY = (int)m_PFY; + + AfterMove(); + + + if (m_PFCount == 0) { + if (m_Path->GetNext() == NULL) { + m_PosX = m_TargetPoint->x; + m_PosY = m_TargetPoint->y; + + m_Path->Reset(); + if (m_AfterWalkDir != DI_NONE) TurnTo(m_AfterWalkDir); + else { + m_State = m_NextState; + m_NextState = STATE_READY; + } + } else InitLine(CBPoint(m_PosX, m_PosY), *m_Path->GetCurrent()); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { + m_PFCount = std::max((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); + + m_PFStepX = (double)(EndPt.x - StartPt.x) / m_PFCount; + m_PFStepY = (double)(EndPt.y - StartPt.y) / m_PFCount; + + m_PFX = StartPt.x; + m_PFY = StartPt.y; + + int angle = (int)(atan2((double)(EndPt.y - StartPt.y), (double)(EndPt.x - StartPt.x)) * (180 / 3.14)); + + m_NextState = STATE_FOLLOWING_PATH; + + TurnTo(AngleToDirection(angle)); +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GoTo / GoToAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GoTo") == 0 || strcmp(Name, "GoToAsync") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + GoTo(X, Y); + if (strcmp(Name, "GoToAsync") != 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoToObject / GoToObjectAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoToObject") == 0 || strcmp(Name, "GoToObjectAsync") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (!Val->IsNative()) { + Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Stack->PushNULL(); + return S_OK; + } + CAdObject *Obj = (CAdObject *)Val->GetNative(); + if (!Obj || Obj->m_Type != OBJECT_ENTITY) { + Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Stack->PushNULL(); + return S_OK; + } + CAdEntity *Ent = (CAdEntity *)Obj; + if (Ent->m_WalkToX == 0 && Ent->m_WalkToY == 0) GoTo(Ent->m_PosX, Ent->m_PosY); + else GoTo(Ent->m_WalkToX, Ent->m_WalkToY, Ent->m_WalkToDir); + if (strcmp(Name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnTo / TurnToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnTo") == 0 || strcmp(Name, "TurnToAsync") == 0) { + Stack->CorrectParams(1); + int dir; + CScValue *val = Stack->Pop(); + + // turn to object? + if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { + CBObject *obj = (CBObject *)val->GetNative(); + int angle = (int)(atan2((double)(obj->m_PosY - m_PosY), (double)(obj->m_PosX - m_PosX)) * (180 / 3.14)); + dir = (int)AngleToDirection(angle); + } + // otherwise turn to direction + else dir = val->GetInt(); + + if (dir >= 0 && dir < NUM_DIRECTIONS) { + TurnTo((TDirection)dir); + if (strcmp(Name, "TurnToAsync") != 0) Script->WaitForExclusive(this); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsWalking") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(m_State == STATE_FOLLOWING_PATH); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MergeAnims + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MergeAnims") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(SUCCEEDED(MergeAnims(Stack->Pop()->GetString()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadAnim") == 0) { + Stack->CorrectParams(1); + char *AnimName = Stack->Pop()->GetString(); + + bool Found = false; + for (int i = 0; i < m_Anims.GetSize(); i++) { + if (scumm_stricmp(m_Anims[i]->m_Name, AnimName) == 0) { + // invalidate sprites in use + if (m_Anims[i]->ContainsSprite(m_TempSprite2)) m_TempSprite2 = NULL; + if (m_Anims[i]->ContainsSprite(m_CurrentSprite)) m_CurrentSprite = NULL; + if (m_Anims[i]->ContainsSprite(m_AnimSprite2)) m_AnimSprite2 = NULL; + + delete m_Anims[i]; + m_Anims[i] = NULL; + m_Anims.RemoveAt(i); + i--; + Found = true; + } + } + Stack->PushBool(Found); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasAnim") == 0) { + Stack->CorrectParams(1); + char *AnimName = Stack->Pop()->GetString(); + Stack->PushBool(GetAnimByName(AnimName) != NULL); + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdActor::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Direction") == 0) { + m_ScValue->SetInt(m_Dir); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("actor"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkAnimName") == 0) { + m_ScValue->SetString(m_TalkAnimName); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkAnimName") == 0) { + m_ScValue->SetString(m_WalkAnimName); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IdleAnimName") == 0) { + m_ScValue->SetString(m_IdleAnimName); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnLeftAnimName") == 0) { + m_ScValue->SetString(m_TurnLeftAnimName); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnRightAnimName") == 0) { + m_ScValue->SetString(m_TurnRightAnimName); + return m_ScValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Direction") == 0) { + int dir = Value->GetInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) m_Dir = (TDirection)dir; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&m_TalkAnimName, "talk"); + else CBUtils::SetString(&m_TalkAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&m_WalkAnimName, "walk"); + else CBUtils::SetString(&m_WalkAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IdleAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&m_IdleAnimName, "idle"); + else CBUtils::SetString(&m_IdleAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnLeftAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&m_TurnLeftAnimName, "turnleft"); + else CBUtils::SetString(&m_TurnLeftAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnRightAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&m_TurnRightAnimName, "turnright"); + else CBUtils::SetString(&m_TurnRightAnimName, Value->GetString()); + return S_OK; + } + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdActor::ScToString() { + return "[actor object]"; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::GetTalkStance(char *Stance) { + // forced stance? + if (m_ForcedTalkAnimName && !m_ForcedTalkAnimUsed) { + m_ForcedTalkAnimUsed = true; + delete m_AnimSprite; + m_AnimSprite = new CBSprite(Game, this); + if (m_AnimSprite) { + HRESULT res = m_AnimSprite->LoadFile(m_ForcedTalkAnimName); + if (FAILED(res)) { + Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", m_Name, m_ForcedTalkAnimName); + delete m_AnimSprite; + m_AnimSprite = NULL; + } else return m_AnimSprite; + } + } + + // old way + if (m_TalkSprites.GetSize() > 0 || m_TalkSpritesEx.GetSize() > 0) + return GetTalkStanceOld(Stance); + + // new way + CBSprite *Ret = NULL; + + // do we have an animation with this name? + CAdSpriteSet *Anim = GetAnimByName(Stance); + if (Anim) Ret = Anim->GetSprite(m_Dir); + + // not - get a random talk + if (!Ret) { + CBArray TalkAnims; + for (int i = 0; i < m_Anims.GetSize(); i++) { + if (scumm_stricmp(m_Anims[i]->m_Name, m_TalkAnimName) == 0) + TalkAnims.Add(m_Anims[i]); + } + + if (TalkAnims.GetSize() > 0) { + int rnd = rand() % TalkAnims.GetSize(); + Ret = TalkAnims[rnd]->GetSprite(m_Dir); + } else { + if (m_StandSprite) Ret = m_StandSprite->GetSprite(m_Dir); + else { + Anim = GetAnimByName(m_IdleAnimName); + if (Anim) Ret = Anim->GetSprite(m_Dir); + } + } + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::GetTalkStanceOld(char *Stance) { + CBSprite *ret = NULL; + + if (Stance != NULL) { + // search special stances + for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(m_TalkSpritesEx[i]->m_Name, Stance) == 0) { + ret = m_TalkSpritesEx[i]->GetSprite(m_Dir); + break; + } + } + if (ret == NULL) { + // search generic stances + for (int i = 0; i < m_TalkSprites.GetSize(); i++) { + if (scumm_stricmp(m_TalkSprites[i]->m_Name, Stance) == 0) { + ret = m_TalkSprites[i]->GetSprite(m_Dir); + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (m_TalkSprites.GetSize() < 1) ret = m_StandSprite->GetSprite(m_Dir); + else { + // TODO: remember last + int rnd = rand() % m_TalkSprites.GetSize(); + ret = m_TalkSprites[rnd]->GetSprite(m_Dir); + } + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Persist(CBPersistMgr *PersistMgr) { + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER_INT(m_Dir)); + PersistMgr->Transfer(TMEMBER(m_Path)); + PersistMgr->Transfer(TMEMBER(m_PFCount)); + PersistMgr->Transfer(TMEMBER(m_PFStepX)); + PersistMgr->Transfer(TMEMBER(m_PFStepY)); + PersistMgr->Transfer(TMEMBER(m_PFX)); + PersistMgr->Transfer(TMEMBER(m_PFY)); + PersistMgr->Transfer(TMEMBER(m_StandSprite)); + m_TalkSprites.Persist(PersistMgr); + m_TalkSpritesEx.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(m_TargetDir)); + PersistMgr->Transfer(TMEMBER_INT(m_AfterWalkDir)); + PersistMgr->Transfer(TMEMBER(m_TargetPoint)); + PersistMgr->Transfer(TMEMBER(m_TurnLeftSprite)); + PersistMgr->Transfer(TMEMBER(m_TurnRightSprite)); + PersistMgr->Transfer(TMEMBER(m_WalkSprite)); + + PersistMgr->Transfer(TMEMBER(m_AnimSprite2)); + PersistMgr->Transfer(TMEMBER(m_TalkAnimName)); + PersistMgr->Transfer(TMEMBER(m_IdleAnimName)); + PersistMgr->Transfer(TMEMBER(m_WalkAnimName)); + PersistMgr->Transfer(TMEMBER(m_TurnLeftAnimName)); + PersistMgr->Transfer(TMEMBER(m_TurnRightAnimName)); + + m_Anims.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TDirection CAdActor::AngleToDirection(int Angle) { + TDirection ret = DI_DOWN;; + + if (Angle > -112 && Angle <= -67) ret = DI_UP; + else if (Angle > -67 && Angle <= -22) ret = DI_UPRIGHT; + else if (Angle > -22 && Angle <= 22) ret = DI_RIGHT; + else if (Angle > 22 && Angle <= 67) ret = DI_DOWNRIGHT; + else if (Angle > 67 && Angle <= 112) ret = DI_DOWN; + else if (Angle > 112 && Angle <= 157) ret = DI_DOWNLEFT; + else if ((Angle > 157 && Angle <= 180) || (Angle >= -180 && Angle <= -157)) ret = DI_LEFT; + else if (Angle > -157 && Angle <= -112) ret = DI_UPLEFT; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdActor::GetHeight() { + // if no current sprite is set, set some + if (m_CurrentSprite == NULL) { + if (m_StandSprite) m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + else { + CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); + if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + } + } + // and get height + return CAdTalkHolder::GetHeight(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet *CAdActor::GetAnimByName(char *AnimName) { + if (!AnimName) return NULL; + + for (int i = 0; i < m_Anims.GetSize(); i++) { + if (scumm_stricmp(m_Anims[i]->m_Name, AnimName) == 0) return m_Anims[i]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::MergeAnims(char *AnimsFilename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + + byte *FileBuffer = Game->m_FileManager->ReadWholeFile(AnimsFilename); + if (FileBuffer == NULL) { + Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); + return E_FAIL; + } + + byte *Buffer = FileBuffer; + byte *params; + int cmd; + CBParser parser(Game); + + HRESULT Ret = S_OK; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + if (!Anim || FAILED(Anim->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + Ret = E_FAIL; + } else m_Anims.Add(Anim); + } + break; + } + } + delete [] FileBuffer; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::PlayAnim(char *Filename) { + // if we have an anim with this name, use it + CAdSpriteSet *Anim = GetAnimByName(Filename); + if (Anim) { + m_AnimSprite2 = Anim->GetSprite(m_Dir); + if (m_AnimSprite2) { + m_AnimSprite2->Reset(); + m_State = STATE_PLAYING_ANIM_SET; + return S_OK; + } + } + // otherwise call the standard handler + return CAdTalkHolder::PlayAnim(Filename); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h new file mode 100644 index 0000000000..fa6f771a35 --- /dev/null +++ b/engines/wintermute/AdActor.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdActor_H__ +#define __WmeAdActor_H__ + + +#include "dctypes.h" // Added by ClassView +#include "AdTypes.h" // Added by ClassView +#include "AdTalkHolder.h" +#include "BPoint.h" // Added by ClassView +#include "persistent.h" +#include "common/str.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +namespace WinterMute { +class CAdSpriteSet; +class CAdPath; +class CAdActor : public CAdTalkHolder { +public: + TDirection AngleToDirection(int Angle); + DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) + virtual int GetHeight(); + CBSprite *GetTalkStance(char *Stance); + virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); + CBPoint *m_TargetPoint; + virtual HRESULT Update(); + virtual HRESULT Display(); + TDirection m_TargetDir; + TDirection m_AfterWalkDir; + virtual void TurnTo(TDirection dir); + CAdPath *m_Path; + CAdSpriteSet *m_WalkSprite; + CAdSpriteSet *m_StandSprite; + CAdSpriteSet *m_TurnLeftSprite; + CAdSpriteSet *m_TurnRightSprite; + CBArray m_TalkSprites; + CBArray m_TalkSpritesEx; + TDirection m_Dir; + CAdActor(CBGame *inGame/*=NULL*/); + virtual ~CAdActor(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + // new anim system + char *m_TalkAnimName; + char *m_IdleAnimName; + char *m_WalkAnimName; + char *m_TurnLeftAnimName; + char *m_TurnRightAnimName; + CBArray m_Anims; + virtual HRESULT PlayAnim(char *Filename); + CAdSpriteSet *GetAnimByName(char *AnimName); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + +private: + HRESULT SetDefaultAnimNames(); + CBSprite *GetTalkStanceOld(char *Stance); + HRESULT MergeAnims(char *AnimsFilename); + CBSprite *m_AnimSprite2; + + void InitLine(CBPoint StartPt, CBPoint EndPt); + void GetNextStep(); + void FollowPath(); + double m_PFStepX; + double m_PFStepY; + double m_PFX; + double m_PFY; + int m_PFCount; +}; + +} // end of namespace WinterMute + +#endif // __WmeAdActor_H__ diff --git a/engines/wintermute/AdActorDir.cpp b/engines/wintermute/AdActorDir.cpp new file mode 100644 index 0000000000..bd888ccb03 --- /dev/null +++ b/engines/wintermute/AdActorDir.cpp @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "AdActorDir.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActorDir, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActorDir::CAdActorDir(CBGame *inGame): CBBase(inGame) { +} + + +////////////////////////////////////////////////////////////////////////// +CAdActorDir::~CAdActorDir(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActorDir::Persist(CBPersistMgr *PersistMgr) { + //PersistMgr->Transfer(TMEMBER(x)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdActorDir.h b/engines/wintermute/AdActorDir.h new file mode 100644 index 0000000000..6690796e5c --- /dev/null +++ b/engines/wintermute/AdActorDir.h @@ -0,0 +1,46 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdActorDir_H__ +#define __WmeAdActorDir_H__ + +#include "persistent.h" +#include "BBase.h" + +namespace WinterMute { + +class CAdActorDir : public CBBase { +public: + DECLARE_PERSISTENT(CAdActorDir, CBBase) + CAdActorDir(CBGame *inGame); + virtual ~CAdActorDir(void); +}; + +} // end of namespace WinterMute + +#endif // __WmeAdActorDir_H__ \ No newline at end of file diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp new file mode 100644 index 0000000000..c4827cfeed --- /dev/null +++ b/engines/wintermute/AdEntity.cpp @@ -0,0 +1,959 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdEntity.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "BActiveRect.h" +#include "BSurfaceStorage.h" +#include "ScValue.h" +#include "BGame.h" +#include "AdGame.h" +#include "AdScene.h" +#include "BSound.h" +#include "AdWaypointGroup.h" +#include "BFontStorage.h" +#include "BFont.h" +#include "AdSentence.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BRegion.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "PlatformSDL.h" +#include "utils.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdEntity, false) + +////////////////////////////////////////////////////////////////////////// +CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { + m_Type = OBJECT_ENTITY; + m_Subtype = ENTITY_NORMAL; + m_Region = NULL; + m_Item = NULL; + + m_WalkToX = m_WalkToY = 0; + m_WalkToDir = DI_NONE; +} + + +////////////////////////////////////////////////////////////////////////// +CAdEntity::~CAdEntity() { + Game->UnregisterObject(m_Region); + + delete[] m_Item; + m_Item = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(CURSOR) +TOKEN_DEF(REGION) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_START_TIME) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(SOUND) +TOKEN_DEF(SUBTYPE) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ITEM) +TOKEN_DEF(WALK_TO_X) +TOKEN_DEF(WALK_TO_Y) +TOKEN_DEF(WALK_TO_DIR) +TOKEN_DEF(SAVE_STATE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(REGION) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_START_TIME) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(SUBTYPE) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(WALK_TO_X) + TOKEN_TABLE(WALK_TO_Y) + TOKEN_TABLE(WALK_TO_DIR) + TOKEN_TABLE(SAVE_STATE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + Game->LOG(0, "'ENTITY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CAdGame *AdGame = (CAdGame *)Game; + CBSprite *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_SPRITE: { + SAFE_DELETE(m_Sprite); + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + else m_Sprite = spr; + } + break; + + case TOKEN_TALK: { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSprites.Add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSpritesEx.Add(spr); + } + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_ITEM: + SetItem((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.ScanStr((char *)params, "%b", &m_Zoomable); + break; + + case TOKEN_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + m_Scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + m_RelativeScale = (float)s; + + } + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.ScanStr((char *)params, "%b", &m_Rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.ScanStr((char *)params, "%b", &m_Registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.ScanStr((char *)params, "%b", &m_Shadowable); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &m_Active); + break; + + case TOKEN_CURSOR: + SAFE_DELETE(m_Cursor); + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + SAFE_DELETE(m_Cursor); + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &m_EditorSelected); + break; + + case TOKEN_REGION: { + if (m_Region) Game->UnregisterObject(m_Region); + m_Region = NULL; + CBRegion *rgn = new CBRegion(Game); + if (!rgn || FAILED(rgn->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + else { + m_Region = rgn; + Game->RegisterObject(m_Region); + } + } + break; + + case TOKEN_BLOCKED_REGION: { + SAFE_DELETE(m_BlockRegion); + SAFE_DELETE(m_CurrentBlockRegion); + CBRegion *rgn = new CBRegion(Game); + CBRegion *crgn = new CBRegion(Game); + if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + SAFE_DELETE(m_BlockRegion); + SAFE_DELETE(m_CurrentBlockRegion); + cmd = PARSERR_GENERIC; + } else { + m_BlockRegion = rgn; + m_CurrentBlockRegion = crgn; + m_CurrentBlockRegion->Mimic(m_BlockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + SAFE_DELETE(m_WptGroup); + SAFE_DELETE(m_CurrentWptGroup); + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + SAFE_DELETE(m_WptGroup); + SAFE_DELETE(m_CurrentWptGroup); + cmd = PARSERR_GENERIC; + } else { + m_WptGroup = wpt; + m_CurrentWptGroup = cwpt; + m_CurrentWptGroup->Mimic(m_WptGroup); + } + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_SUBTYPE: { + if (scumm_stricmp((char *)params, "sound") == 0) { + SAFE_DELETE(m_Sprite); + if (Game->m_EditorMode) { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + else m_Sprite = spr; + } + if (Game->m_EditorMode) m_EditorOnly = true; + m_Zoomable = false; + m_Rotatable = false; + m_Registrable = Game->m_EditorMode; + m_Shadowable = false; + m_Subtype = ENTITY_SOUND; + } + } + break; + + case TOKEN_SOUND: + PlaySFX((char *)params, false, false); + break; + + case TOKEN_SOUND_START_TIME: + parser.ScanStr((char *)params, "%d", &m_SFXStart); + break; + + case TOKEN_SOUND_VOLUME: + parser.ScanStr((char *)params, "%d", &m_SFXVolume); + break; + + case TOKEN_SOUND_PANNING: + parser.ScanStr((char *)params, "%b", &m_AutoSoundPanning); + break; + + case TOKEN_SAVE_STATE: + parser.ScanStr((char *)params, "%b", &m_SaveState); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_IGNORE_ITEMS: + parser.ScanStr((char *)params, "%b", &m_IgnoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_WALK_TO_X: + parser.ScanStr((char *)params, "%d", &m_WalkToX); + break; + + case TOKEN_WALK_TO_Y: + parser.ScanStr((char *)params, "%d", &m_WalkToY); + break; + + case TOKEN_WALK_TO_DIR: { + int i; + parser.ScanStr((char *)params, "%d", &i); + if (i < 0) i = 0; + if (i >= NUM_DIRECTIONS) i = DI_NONE; + m_WalkToDir = (TDirection)i; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ENTITY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ENTITY definition"); + if (spr) delete spr; + return E_FAIL; + } + + if (m_Region && m_Sprite) { + Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", m_Name); + } + + UpdatePosition(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + m_AlphaColor = DRGBA(ar, ag, ab, alpha); + m_State = STATE_READY; + + if (m_Item && ((CAdGame *)Game)->IsItemTaken(m_Item)) m_Active = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Display() { + if (m_Active) { + UpdateSounds(); + + uint32 Alpha; + if (m_AlphaColor != 0) Alpha = m_AlphaColor; + else Alpha = m_Shadowable ? ((CAdGame *)Game)->m_Scene->GetAlphaAt(m_PosX, m_PosY) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + float Rotate; + if (m_Rotatable) { + if (m_RotateValid) Rotate = m_Rotate; + else Rotate = ((CAdGame *)Game)->m_Scene->GetRotationAt(m_PosX, m_PosY) + m_RelativeRotate; + } else Rotate = 0.0f; + + + bool Reg = m_Registrable; + if (m_IgnoreItems && ((CAdGame *)Game)->m_SelectedItem) Reg = false; + + if (m_Region && (Reg || m_EditorAlwaysRegister)) { + Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, m_RegisterAlias, m_Region, Game->m_OffsetX, Game->m_OffsetY)); + } + + DisplaySpriteAttachments(true); + if (m_CurrentSprite) { + m_CurrentSprite->Display(m_PosX, + m_PosY, + (Reg || m_EditorAlwaysRegister) ? m_RegisterAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + m_BlendMode); + } + DisplaySpriteAttachments(false); + + if (m_PartEmitter) m_PartEmitter->Display(m_Region); + + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Update() { + m_CurrentSprite = NULL; + + if (m_State == STATE_READY && m_AnimSprite) { + SAFE_DELETE(m_AnimSprite); + } + + // finished playing animation? + if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { + m_State = STATE_READY; + m_CurrentSprite = m_AnimSprite; + } + + if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + + // default: stand animation + if (!m_CurrentSprite) m_CurrentSprite = m_Sprite; + + switch (m_State) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + m_CurrentSprite = m_AnimSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!m_AnimSprite) + m_CurrentSprite = m_Sprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + m_Sentence->Update(); + if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + + bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); + if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + m_Sentence->Finish(); + m_TempSprite2 = NULL; + m_State = STATE_READY; + } else { + m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); + if (m_TempSprite2) { + m_TempSprite2->Reset(); + m_CurrentSprite = m_TempSprite2; + } + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } else { + m_CurrentSprite = m_TempSprite2; + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } + break; + } + + + if (m_CurrentSprite) { + m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); + if (m_CurrentSprite->m_Changed) { + m_PosX += m_CurrentSprite->m_MoveX; + m_PosY += m_CurrentSprite->m_MoveY; + } + } + + UpdateBlockRegion(); + m_Ready = (m_State == STATE_READY); + + + UpdatePartEmitter(); + UpdateSpriteAttachments(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "StopSound") == 0 && m_Subtype == ENTITY_SOUND) { + Stack->CorrectParams(0); + + if (FAILED(StopSFX(false))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTheoraPlaying") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPaused + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTheoraPaused") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // CreateRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateRegion") == 0) { + Stack->CorrectParams(0); + if (!m_Region) { + m_Region = new CBRegion(Game); + Game->RegisterObject(m_Region); + } + if (m_Region) Stack->PushNative(m_Region, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteRegion") == 0) { + Stack->CorrectParams(0); + if (m_Region) { + Game->UnregisterObject(m_Region); + m_Region = NULL; + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdEntity::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("entity"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Item") == 0) { + if (m_Item) m_ScValue->SetString(m_Item); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtype (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtype") == 0) { + if (m_Subtype == ENTITY_SOUND) + m_ScValue->SetString("sound"); + else + m_ScValue->SetString("normal"); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToX") == 0) { + m_ScValue->SetInt(m_WalkToX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToY") == 0) { + m_ScValue->SetInt(m_WalkToY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToDirection") == 0) { + m_ScValue->SetInt((int)m_WalkToDir); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Region (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Region") == 0) { + if (m_Region) m_ScValue->SetNative(m_Region, true); + else m_ScValue->SetNULL(); + return m_ScValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::ScSetProperty(char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Item") == 0) { + SetItem(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToX") == 0) { + m_WalkToX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToY") == 0) { + m_WalkToY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToDirection") == 0) { + int Dir = Value->GetInt(); + if (Dir >= 0 && Dir < NUM_DIRECTIONS) m_WalkToDir = (TDirection)Dir; + return S_OK; + } + + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdEntity::ScToString() { + return "[entity object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ENTITY {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + if (m_Subtype == ENTITY_SOUND) + Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", m_Zoomable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", m_Registrable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", m_Shadowable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + if (m_IgnoreItems) + Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", m_IgnoreItems ? "TRUE" : "FALSE"); + if (m_Rotatable) + Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", m_Rotatable ? "TRUE" : "FALSE"); + + if (!m_AutoSoundPanning) + Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", m_AutoSoundPanning ? "TRUE" : "FALSE"); + + if (!m_SaveState) + Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", m_SaveState ? "TRUE" : "FALSE"); + + if (m_Item && m_Item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", m_Item); + + Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", m_WalkToX); + Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", m_WalkToY); + if (m_WalkToDir != DI_NONE) + Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)m_WalkToDir); + + int i; + + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + if (m_Subtype == ENTITY_NORMAL && m_Sprite && m_Sprite->m_Filename) + Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", m_Sprite->m_Filename); + + if (m_Subtype == ENTITY_SOUND && m_SFX && m_SFX->m_SoundFilename) { + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", m_SFX->m_SoundFilename); + Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", m_SFXStart); + Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", m_SFXVolume); + } + + + if (D3DCOLGetR(m_AlphaColor) != 0 || D3DCOLGetG(m_AlphaColor) != 0 || D3DCOLGetB(m_AlphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_AlphaColor), D3DCOLGetG(m_AlphaColor), D3DCOLGetB(m_AlphaColor)); + + if (D3DCOLGetA(m_AlphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_AlphaColor)); + + if (m_Scale >= 0) + Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)m_Scale); + + if (m_RelativeScale != 0) + Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)m_RelativeScale); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + CAdTalkHolder::SaveAsText(Buffer, Indent + 2); + + if (m_Region) m_Region->SaveAsText(Buffer, Indent + 2); + + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + + CAdObject::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdEntity::GetHeight() { + if (m_Region && !m_Sprite) { + return m_Region->m_Rect.bottom - m_Region->m_Rect.top; + } else { + if (m_CurrentSprite == NULL) m_CurrentSprite = m_Sprite; + return CAdObject::GetHeight(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::UpdatePosition() { + if (m_Region && !m_Sprite) { + m_PosX = m_Region->m_Rect.left + (m_Region->m_Rect.right - m_Region->m_Rect.left) / 2; + m_PosY = m_Region->m_Rect.bottom; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Item)); + PersistMgr->Transfer(TMEMBER(m_Region)); + //PersistMgr->Transfer(TMEMBER(m_Sprite)); + PersistMgr->Transfer(TMEMBER_INT(m_Subtype)); + m_TalkSprites.Persist(PersistMgr); + m_TalkSpritesEx.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_WalkToX)); + PersistMgr->Transfer(TMEMBER(m_WalkToY)); + PersistMgr->Transfer(TMEMBER_INT(m_WalkToDir)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::SetItem(char *ItemName) { + CBUtils::SetString(&m_Item, ItemName); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::SetSprite(char *Filename) { + bool SetCurrent = false; + if (m_CurrentSprite == m_Sprite) { + m_CurrentSprite = NULL; + SetCurrent = true; + } + + SAFE_DELETE(m_Sprite); + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + SAFE_DELETE(m_Sprite); + return E_FAIL; + } else { + m_Sprite = spr; + m_CurrentSprite = m_Sprite; + return S_OK; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp new file mode 100644 index 0000000000..b5e8518e30 --- /dev/null +++ b/engines/wintermute/AdGame.cpp @@ -0,0 +1,2062 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdGame.h" +#include "AdResponseBox.h" +#include "AdInventoryBox.h" +#include "AdSceneState.h" +#include "PartEmitter.h" +#include "BParser.h" +#include "BSurfaceStorage.h" +#include "BTransitionMgr.h" +#include "BObject.h" +#include "BSound.h" +#include "UIWindow.h" +#include "ScValue.h" +#include "UIEntity.h" +#include "AdScene.h" +#include "AdEntity.h" +#include "AdActor.h" +#include "AdInventory.h" +#include "AdResponseContext.h" +#include "AdItem.h" +#include "BViewport.h" +#include "BFont.h" +#include "ScEngine.h" +#include "BStringTable.h" +#include "AdSentence.h" +#include "AdResponse.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "utils.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdGame, true) + +////////////////////////////////////////////////////////////////////////// +CAdGame::CAdGame(): CBGame() { + m_ResponseBox = NULL; + m_InventoryBox = NULL; + + m_Scene = new CAdScene(Game); + m_Scene->SetName(""); + RegisterObject(m_Scene); + + m_PrevSceneName = NULL; + m_PrevSceneFilename = NULL; + m_ScheduledScene = NULL; + m_ScheduledFadeIn = false; + + + m_StateEx = GAME_NORMAL; + + m_SelectedItem = NULL; + + + m_TexItemLifeTime = 10000; + m_TexWalkLifeTime = 10000; + m_TexStandLifeTime = 10000; + m_TexTalkLifeTime = 10000; + + m_TalkSkipButton = TALK_SKIP_LEFT; + + m_SceneViewport = NULL; + + m_InitialScene = true; + m_DebugStartupScene = NULL; + m_StartupScene = NULL; + + m_InvObject = new CAdObject(this); + m_InventoryOwner = m_InvObject; + + m_TempDisableSaveState = false; + m_ItemsFile = NULL; + + m_SmartItemCursor = false; + + AddSpeechDir("speech"); +} + + +////////////////////////////////////////////////////////////////////////// +CAdGame::~CAdGame() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::Cleanup() { + int i; + + for (i = 0; i < m_Objects.GetSize(); i++) { + UnregisterObject(m_Objects[i]); + m_Objects[i] = NULL; + } + m_Objects.RemoveAll(); + + + for (i = 0; i < m_DlgPendingBranches.GetSize(); i++) { + delete [] m_DlgPendingBranches[i]; + } + m_DlgPendingBranches.RemoveAll(); + + for (i = 0; i < m_SpeechDirs.GetSize(); i++) { + delete [] m_SpeechDirs[i]; + } + m_SpeechDirs.RemoveAll(); + + + UnregisterObject(m_Scene); + m_Scene = NULL; + + // remove items + for (i = 0; i < m_Items.GetSize(); i++) Game->UnregisterObject(m_Items[i]); + m_Items.RemoveAll(); + + + // clear remaining inventories + delete m_InvObject; + m_InvObject = NULL; + + for (i = 0; i < m_Inventories.GetSize(); i++) { + delete m_Inventories[i]; + } + m_Inventories.RemoveAll(); + + + if (m_ResponseBox) { + Game->UnregisterObject(m_ResponseBox); + m_ResponseBox = NULL; + } + + if (m_InventoryBox) { + Game->UnregisterObject(m_InventoryBox); + m_InventoryBox = NULL; + } + + delete[] m_PrevSceneName; + delete[] m_PrevSceneFilename; + delete[] m_ScheduledScene; + delete[] m_DebugStartupScene; + delete[] m_ItemsFile; + m_PrevSceneName = NULL; + m_PrevSceneFilename = NULL; + m_ScheduledScene = NULL; + m_DebugStartupScene = NULL; + m_StartupScene = NULL; + m_ItemsFile = NULL; + + delete m_SceneViewport; + m_SceneViewport = NULL; + + for (i = 0; i < m_SceneStates.GetSize(); i++) delete m_SceneStates[i]; + m_SceneStates.RemoveAll(); + + for (i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; + m_ResponsesBranch.RemoveAll(); + + for (i = 0; i < m_ResponsesGame.GetSize(); i++) delete m_ResponsesGame[i]; + m_ResponsesGame.RemoveAll(); + + return CBGame::Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::InitLoop() { + if (m_ScheduledScene && m_TransMgr->IsReady()) { + ChangeScene(m_ScheduledScene, m_ScheduledFadeIn); + SAFE_DELETE_ARRAY(m_ScheduledScene); + + Game->m_ActiveObject = NULL; + } + + + HRESULT res; + res = CBGame::InitLoop(); + if (FAILED(res)) return res; + + if (m_Scene) res = m_Scene->InitLoop(); + + m_Sentences.RemoveAll(); + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddObject(CAdObject *Object) { + m_Objects.Add(Object); + return RegisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RemoveObject(CAdObject *Object) { + // in case the user called Scene.CreateXXX() and Game.DeleteXXX() + if (m_Scene) { + HRESULT Res = m_Scene->RemoveObject(Object); + if (SUCCEEDED(Res)) return Res; + } + + for (int i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i] == Object) { + m_Objects.RemoveAt(i); + break; + } + } + return UnregisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ChangeScene(char *Filename, bool FadeIn) { + if (m_Scene == NULL) { + m_Scene = new CAdScene(Game); + RegisterObject(m_Scene); + } else { + m_Scene->ApplyEvent("SceneShutdown", true); + + SetPrevSceneName(m_Scene->m_Name); + SetPrevSceneFilename(m_Scene->m_Filename); + + if (!m_TempDisableSaveState) m_Scene->SaveState(); + m_TempDisableSaveState = false; + } + + if (m_Scene) { + // reset objects + for (int i = 0; i < m_Objects.GetSize(); i++) m_Objects[i]->Reset(); + + // reset scene properties + m_Scene->m_SFXVolume = 100; + if (m_Scene->m_ScProp) m_Scene->m_ScProp->Cleanup(); + + HRESULT ret; + if (m_InitialScene && m_DEBUG_DebugMode && m_DebugStartupScene) { + m_InitialScene = false; + ret = m_Scene->LoadFile(m_DebugStartupScene); + } else ret = m_Scene->LoadFile(Filename); + + if (SUCCEEDED(ret)) { + // invalidate references to the original scene + for (int i = 0; i < m_Objects.GetSize(); i++) { + m_Objects[i]->InvalidateCurrRegions(); + m_Objects[i]->m_StickRegion = NULL; + } + + m_Scene->LoadState(); + } + if (FadeIn) Game->m_TransMgr->Start(TRANSITION_FADE_IN); + return ret; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::AddSentence(CAdSentence *Sentence) { + m_Sentences.Add(Sentence); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplaySentences(bool Frozen) { + for (int i = 0; i < m_Sentences.GetSize(); i++) { + if (Frozen && m_Sentences[i]->m_Freezable) continue; + else m_Sentences[i]->Display(); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::FinishSentences() { + for (int i = 0; i < m_Sentences.GetSize(); i++) { + if (m_Sentences[i]->CanSkip()) { + m_Sentences[i]->m_Duration = 0; + if (m_Sentences[i]->m_Sound) m_Sentences[i]->m_Sound->Stop(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // ChangeScene + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "ChangeScene") == 0) { + Stack->CorrectParams(3); + char *Filename = Stack->Pop()->GetString(); + CScValue *valFadeOut = Stack->Pop(); + CScValue *valFadeIn = Stack->Pop(); + + bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); + bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); + + ScheduleChangeScene(Filename, TransIn); + if (TransOut) m_TransMgr->Start(TRANSITION_FADE_OUT, true); + Stack->PushNULL(); + + + //HRESULT ret = ChangeScene(Stack->Pop()->GetString()); + //if(FAILED(ret)) Stack->PushBool(false); + //else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadActor") == 0) { + Stack->CorrectParams(1); + CAdActor *act = new CAdActor(Game); + if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + AddObject(act); + Stack->PushNative(act, true); + } else { + delete act; + act = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadEntity") == 0) { + Stack->CorrectParams(1); + CAdEntity *ent = new CAdEntity(Game); + if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + AddObject(ent); + Stack->PushNative(ent, true); + } else { + delete ent; + ent = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "DeleteEntity") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CAdObject *obj = (CAdObject *)val->GetNative(); + RemoveObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdEntity *Ent = new CAdEntity(Game); + AddObject(Ent); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = new CAdItem(Game); + AddItem(Item); + if (!Val->IsNULL()) Item->SetName(Val->GetString()); + Stack->PushNative(Item, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = NULL; + if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); + else Item = GetItemByName(Val->GetString()); + + if (Item) { + DeleteItem(Item); + } + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QueryItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "QueryItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + if (Index >= 0 && Index < m_Items.GetSize()) Item = m_Items[Index]; + } else { + Item = GetItemByName(Val->GetString()); + } + + if (Item) Stack->PushNative(Item, true); + else Stack->PushNULL(); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // AddResponse/AddResponseOnce/AddResponseOnceGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddResponse") == 0 || strcmp(Name, "AddResponseOnce") == 0 || strcmp(Name, "AddResponseOnceGame") == 0) { + Stack->CorrectParams(6); + int id = Stack->Pop()->GetInt(); + char *text = Stack->Pop()->GetString(); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + CScValue *val3 = Stack->Pop(); + CScValue *val4 = Stack->Pop(); + + if (m_ResponseBox) { + CAdResponse *res = new CAdResponse(Game); + if (res) { + res->m_ID = id; + res->SetText(text); + m_StringTable->Expand(&res->m_Text); + if (!val1->IsNULL()) res->SetIcon(val1->GetString()); + if (!val2->IsNULL()) res->SetIconHover(val2->GetString()); + if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); + if (!val4->IsNULL()) res->SetFont(val4->GetString()); + + if (strcmp(Name, "AddResponseOnce") == 0) res->m_ResponseType = RESPONSE_ONCE; + else if (strcmp(Name, "AddResponseOnceGame") == 0) res->m_ResponseType = RESPONSE_ONCE_GAME; + + m_ResponseBox->m_Responses.Add(res); + } + } else { + Script->RuntimeError("Game.AddResponse: response box is not defined"); + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResetResponse") == 0) { + Stack->CorrectParams(1); + int ID = Stack->Pop()->GetInt(-1); + ResetResponse(ID); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClearResponses") == 0) { + Stack->CorrectParams(0); + m_ResponseBox->ClearResponses(); + m_ResponseBox->ClearButtons(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetResponse") == 0) { + Stack->CorrectParams(1); + bool AutoSelectLast = Stack->Pop()->GetBool(); + + if (m_ResponseBox) { + m_ResponseBox->WeedResponses(); + + if (m_ResponseBox->m_Responses.GetSize() == 0) { + Stack->PushNULL(); + return S_OK; + } + + + if (m_ResponseBox->m_Responses.GetSize() == 1 && AutoSelectLast) { + Stack->PushInt(m_ResponseBox->m_Responses[0]->m_ID); + m_ResponseBox->HandleResponse(m_ResponseBox->m_Responses[0]); + m_ResponseBox->ClearResponses(); + return S_OK; + } + + m_ResponseBox->CreateButtons(); + m_ResponseBox->m_WaitingScript = Script; + Script->WaitForExclusive(m_ResponseBox); + m_State = GAME_SEMI_FROZEN; + m_StateEx = GAME_WAITING_RESPONSE; + } else { + Script->RuntimeError("Game.GetResponse: response box is not defined"); + Stack->PushNULL(); + } + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // GetNumResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNumResponses") == 0) { + Stack->CorrectParams(0); + if (m_ResponseBox) { + m_ResponseBox->WeedResponses(); + Stack->PushInt(m_ResponseBox->m_Responses.GetSize()); + } else { + Script->RuntimeError("Game.GetNumResponses: response box is not defined"); + Stack->PushNULL(); + } + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // StartDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartDlgBranch") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + char *BranchName = NULL; + bool DeleteName = false; + if (Val->IsNULL()) { + BranchName = new char[20]; + sprintf(BranchName, "line%d", Script->m_CurrentLine); + DeleteName = true; + } else BranchName = Val->GetString(); + + StartDlgBranch(BranchName, Script->m_Filename == NULL ? "" : Script->m_Filename, Script->m_ThreadEvent == NULL ? "" : Script->m_ThreadEvent); + Stack->PushNULL(); + if (DeleteName) delete[] BranchName; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EndDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EndDlgBranch") == 0) { + Stack->CorrectParams(1); + + char *BranchName = NULL; + CScValue *Val = Stack->Pop(); + if (!Val->IsNULL()) BranchName = Val->GetString(); + EndDlgBranch(BranchName, Script->m_Filename == NULL ? "" : Script->m_Filename, Script->m_ThreadEvent == NULL ? "" : Script->m_ThreadEvent); + + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCurrentDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCurrentDlgBranch") == 0) { + Stack->CorrectParams(0); + + if (m_DlgPendingBranches.GetSize() > 0) { + Stack->PushString(m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1]); + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TakeItem") == 0) { + return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DropItem") == 0) { + return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetItem") == 0) { + return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasItem") == 0) { + return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // IsItemTaken + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsItemTaken") == 0) { + Stack->CorrectParams(1); + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + for (int i = 0; i < m_Inventories.GetSize(); i++) { + CAdInventory *Inv = m_Inventories[i]; + + for (int j = 0; j < Inv->m_TakenItems.GetSize(); j++) { + if (val->GetNative() == Inv->m_TakenItems[j]) { + Stack->PushBool(true); + return S_OK; + } else if (scumm_stricmp(val->GetString(), Inv->m_TakenItems[j]->m_Name) == 0) { + Stack->PushBool(true); + return S_OK; + } + } + } + } else Script->RuntimeError("Game.IsItemTaken: item name expected"); + + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInventoryWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInventoryWindow") == 0) { + Stack->CorrectParams(0); + if (m_InventoryBox && m_InventoryBox->m_Window) + Stack->PushNative(m_InventoryBox->m_Window, true); + else + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponsesWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetResponsesWindow") == 0 || strcmp(Name, "GetResponseWindow") == 0) { + Stack->CorrectParams(0); + if (m_ResponseBox && m_ResponseBox->m_Window) + Stack->PushNative(m_ResponseBox->m_Window, true); + else + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadResponseBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadResponseBox") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + + Game->UnregisterObject(m_ResponseBox); + m_ResponseBox = new CAdResponseBox(Game); + if (m_ResponseBox && !FAILED(m_ResponseBox->LoadFile(Filename))) { + RegisterObject(m_ResponseBox); + Stack->PushBool(true); + } else { + SAFE_DELETE(m_ResponseBox); + Stack->PushBool(false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadInventoryBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadInventoryBox") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + + Game->UnregisterObject(m_InventoryBox); + m_InventoryBox = new CAdInventoryBox(Game); + if (m_InventoryBox && !FAILED(m_InventoryBox->LoadFile(Filename))) { + RegisterObject(m_InventoryBox); + Stack->PushBool(true); + } else { + delete m_InventoryBox; + m_InventoryBox = NULL; + Stack->PushBool(false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadItems") == 0) { + Stack->CorrectParams(2); + char *Filename = Stack->Pop()->GetString(); + bool Merge = Stack->Pop()->GetBool(false); + + HRESULT Ret = LoadItemsFile(Filename, Merge); + Stack->PushBool(SUCCEEDED(Ret)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSpeechDir") == 0) { + Stack->CorrectParams(1); + char *Dir = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveSpeechDir") == 0) { + Stack->CorrectParams(1); + char *Dir = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSceneViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSceneViewport") == 0) { + Stack->CorrectParams(4); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + int Width = Stack->Pop()->GetInt(); + int Height = Stack->Pop()->GetInt(); + + if (Width <= 0) Width = m_Renderer->m_Width; + if (Height <= 0) Height = m_Renderer->m_Height; + + if (!m_SceneViewport) m_SceneViewport = new CBViewport(Game); + if (m_SceneViewport) m_SceneViewport->SetRect(X, Y, X + Width, Y + Height); + + Stack->PushBool(true); + + return S_OK; + } + + + else return CBGame::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdGame::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("game"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scene") == 0) { + if (m_Scene) m_ScValue->SetNative(m_Scene, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelectedItem") == 0) { + //if(m_SelectedItem) m_ScValue->SetString(m_SelectedItem->m_Name); + if (m_SelectedItem) m_ScValue->SetNative(m_SelectedItem, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumItems") == 0) { + return m_InvObject->ScGetProperty(Name); + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SmartItemCursor") == 0) { + m_ScValue->SetBool(m_SmartItemCursor); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryVisible") == 0) { + m_ScValue->SetBool(m_InventoryBox && m_InventoryBox->m_Visible); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryScrollOffset") == 0) { + if (m_InventoryBox) m_ScValue->SetInt(m_InventoryBox->m_ScrollOffset); + else m_ScValue->SetInt(0); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ResponsesVisible (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResponsesVisible") == 0) { + m_ScValue->SetBool(m_StateEx == GAME_WAITING_RESPONSE); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevScene / PreviousScene (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PrevScene") == 0 || strcmp(Name, "PreviousScene") == 0) { + if (!m_PrevSceneName) m_ScValue->SetString(""); + else m_ScValue->SetString(m_PrevSceneName); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevSceneFilename / PreviousSceneFilename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PrevSceneFilename") == 0 || strcmp(Name, "PreviousSceneFilename") == 0) { + if (!m_PrevSceneFilename) m_ScValue->SetString(""); + else m_ScValue->SetString(m_PrevSceneFilename); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponse (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LastResponse") == 0) { + if (!m_ResponseBox || !m_ResponseBox->m_LastResponseText) m_ScValue->SetString(""); + else m_ScValue->SetString(m_ResponseBox->m_LastResponseText); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponseOrig (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LastResponseOrig") == 0) { + if (!m_ResponseBox || !m_ResponseBox->m_LastResponseTextOrig) m_ScValue->SetString(""); + else m_ScValue->SetString(m_ResponseBox->m_LastResponseTextOrig); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryObject") == 0) { + if (m_InventoryOwner == m_InvObject) m_ScValue->SetNative(this, true); + else m_ScValue->SetNative(m_InventoryOwner, true); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TotalNumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TotalNumItems") == 0) { + m_ScValue->SetInt(m_Items.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkSkipButton") == 0) { + m_ScValue->SetInt(m_TalkSkipButton); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ChangingScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ChangingScene") == 0) { + m_ScValue->SetBool(m_ScheduledScene != NULL); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartupScene") == 0) { + if (!m_StartupScene) m_ScValue->SetNULL(); + else m_ScValue->SetString(m_StartupScene); + return m_ScValue; + } + + else return CBGame::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SelectedItem") == 0) { + if (Value->IsNULL()) m_SelectedItem = NULL; + else { + if (Value->IsNative()) { + m_SelectedItem = NULL; + for (int i = 0; i < m_Items.GetSize(); i++) { + if (m_Items[i] == Value->GetNative()) { + m_SelectedItem = (CAdItem *)Value->GetNative(); + break; + } + } + } else { + // try to get by name + m_SelectedItem = GetItemByName(Value->GetString()); + } + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SmartItemCursor") == 0) { + m_SmartItemCursor = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryVisible") == 0) { + if (m_InventoryBox) m_InventoryBox->m_Visible = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryObject") == 0) { + if (m_InventoryOwner && m_InventoryBox) m_InventoryOwner->GetInventory()->m_ScrollOffset = m_InventoryBox->m_ScrollOffset; + + if (Value->IsNULL()) m_InventoryOwner = m_InvObject; + else { + CBObject *Obj = (CBObject *)Value->GetNative(); + if (Obj == this) m_InventoryOwner = m_InvObject; + else if (Game->ValidObject(Obj)) m_InventoryOwner = (CAdObject *)Obj; + } + + if (m_InventoryOwner && m_InventoryBox) m_InventoryBox->m_ScrollOffset = m_InventoryOwner->GetInventory()->m_ScrollOffset; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryScrollOffset") == 0) { + if (m_InventoryBox) m_InventoryBox->m_ScrollOffset = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkSkipButton") == 0) { + int Val = Value->GetInt(); + if (Val < 0) Val = 0; + if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; + m_TalkSkipButton = (TTalkSkipButton)Val; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartupScene") == 0) { + if (Value == NULL) { + delete[] m_StartupScene; + m_StartupScene = NULL; + } else CBUtils::SetString(&m_StartupScene, Value->GetString()); + + return S_OK; + } + + else return CBGame::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::PublishNatives() { + if (!m_ScEngine || !m_ScEngine->m_CompilerAvailable) return; + + CBGame::PublishNatives(); + + m_ScEngine->ExtDefineFunction("Actor"); + m_ScEngine->ExtDefineFunction("Entity"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // Actor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Actor") == 0) { + Stack->CorrectParams(0); + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CAdActor(Game)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Entity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Entity") == 0) { + Stack->CorrectParams(0); + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CAdEntity(Game)); + Stack->PushNULL(); + } + + + ////////////////////////////////////////////////////////////////////////// + // call parent + else return CBGame::ExternalCall(Script, Stack, ThisStack, Name); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ShowCursor() { + if (m_CursorHidden) return S_OK; + + if (m_SelectedItem && Game->m_State == GAME_RUNNING && m_StateEx == GAME_NORMAL && m_Interactive) { + if (m_SelectedItem->m_CursorCombined) { + CBSprite *OrigLastCursor = m_LastCursor; + CBGame::ShowCursor(); + m_LastCursor = OrigLastCursor; + } + if (m_ActiveObject && m_SelectedItem->m_CursorHover && m_ActiveObject->GetExtendedFlag("usable")) { + if (!m_SmartItemCursor || m_ActiveObject->CanHandleEvent(m_SelectedItem->m_Name)) + return DrawCursor(m_SelectedItem->m_CursorHover); + else + return DrawCursor(m_SelectedItem->m_CursorNormal); + } else return DrawCursor(m_SelectedItem->m_CursorNormal); + } else return CBGame::ShowCursor(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadFile(const char *Filename) { + byte *Buffer = m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(AD_GAME) +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(ITEMS) +TOKEN_DEF(ITEM) +TOKEN_DEF(TALK_SKIP_BUTTON) +TOKEN_DEF(SCENE_VIEWPORT) +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(STARTUP_SCENE) +TOKEN_DEF(DEBUG_STARTUP_SCENE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(AD_GAME) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(ITEMS) + TOKEN_TABLE(TALK_SKIP_BUTTON) + TOKEN_TABLE(SCENE_VIEWPORT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(STARTUP_SCENE) + TOKEN_TABLE(DEBUG_STARTUP_SCENE) + TOKEN_TABLE_END + + byte *params; + byte *params2; + int cmd = 1; + CBParser parser(Game); + + bool ItemFound = false, ItemsFound = false; + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + if (FAILED(CBGame::LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AD_GAME: + while (cmd > 0 && (cmd = parser.GetCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + switch (cmd) { + case TOKEN_RESPONSE_BOX: + delete m_ResponseBox; + m_ResponseBox = new CAdResponseBox(Game); + if (m_ResponseBox && !FAILED(m_ResponseBox->LoadFile((char *)params2))) + RegisterObject(m_ResponseBox); + else { + delete m_ResponseBox; + m_ResponseBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_INVENTORY_BOX: + delete m_InventoryBox; + m_InventoryBox = new CAdInventoryBox(Game); + if (m_InventoryBox && !FAILED(m_InventoryBox->LoadFile((char *)params2))) + RegisterObject(m_InventoryBox); + else { + delete m_InventoryBox; + m_InventoryBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ITEMS: + ItemsFound = true; + CBUtils::SetString(&m_ItemsFile, (char *)params2); + if (FAILED(LoadItemsFile(m_ItemsFile))) { + delete[] m_ItemsFile; + m_ItemsFile = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_TALK_SKIP_BUTTON: + if (scumm_stricmp((char *)params2, "right") == 0) m_TalkSkipButton = TALK_SKIP_RIGHT; + else if (scumm_stricmp((char *)params2, "both") == 0) m_TalkSkipButton = TALK_SKIP_BOTH; + else m_TalkSkipButton = TALK_SKIP_LEFT; + break; + + case TOKEN_SCENE_VIEWPORT: { + RECT rc; + parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!m_SceneViewport) m_SceneViewport = new CBViewport(Game); + if (m_SceneViewport) m_SceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params2, false); + break; + + case TOKEN_STARTUP_SCENE: + CBUtils::SetString(&m_StartupScene, (char *)params2); + break; + + case TOKEN_DEBUG_STARTUP_SCENE: + CBUtils::SetString(&m_DebugStartupScene, (char *)params2); + break; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in GAME definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading GAME definition"); + return E_FAIL; + } + + if (ItemFound && !ItemsFound) { + Game->LOG(0, "**Warning** Please put the items definition to a separate file."); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->m_Saving) Cleanup(); + CBGame::Persist(PersistMgr); + + m_DlgPendingBranches.Persist(PersistMgr); + + m_Inventories.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_InventoryBox)); + + m_Objects.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_PrevSceneName)); + PersistMgr->Transfer(TMEMBER(m_PrevSceneFilename)); + + PersistMgr->Transfer(TMEMBER(m_ResponseBox)); + m_ResponsesBranch.Persist(PersistMgr); + m_ResponsesGame.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_Scene)); + m_SceneStates.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_ScheduledFadeIn)); + PersistMgr->Transfer(TMEMBER(m_ScheduledScene)); + PersistMgr->Transfer(TMEMBER(m_SelectedItem)); + PersistMgr->Transfer(TMEMBER_INT(m_TalkSkipButton)); + + m_Sentences.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_SceneViewport)); + PersistMgr->Transfer(TMEMBER_INT(m_StateEx)); + PersistMgr->Transfer(TMEMBER(m_InitialScene)); + PersistMgr->Transfer(TMEMBER(m_DebugStartupScene)); + + PersistMgr->Transfer(TMEMBER(m_InvObject)); + PersistMgr->Transfer(TMEMBER(m_InventoryOwner)); + PersistMgr->Transfer(TMEMBER(m_TempDisableSaveState)); + m_Items.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_ItemsFile)); + + m_SpeechDirs.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_SmartItemCursor)); + + if (!PersistMgr->m_Saving) m_InitialScene = false; + + PersistMgr->Transfer(TMEMBER(m_StartupScene)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadGame(char *Filename) { + HRESULT ret = CBGame::LoadGame(Filename); + if (SUCCEEDED(ret)) CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CAdRegion", NULL); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::InitAfterLoad() { + CBGame::InitAfterLoad(); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScene, "CAdScene", NULL); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdGame::AfterLoadScene(void *Scene, void *Data) { + ((CAdScene *)Scene)->AfterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::SetPrevSceneName(char *Name) { + delete[] m_PrevSceneName; + m_PrevSceneName = NULL; + if (Name) { + m_PrevSceneName = new char[strlen(Name) + 1]; + if (m_PrevSceneName) strcpy(m_PrevSceneName, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::SetPrevSceneFilename(char *Name) { + delete[] m_PrevSceneFilename; + m_PrevSceneFilename = NULL; + if (Name) { + m_PrevSceneFilename = new char[strlen(Name) + 1]; + if (m_PrevSceneFilename) strcpy(m_PrevSceneFilename, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScheduleChangeScene(char *Filename, bool FadeIn) { + delete[] m_ScheduledScene; + m_ScheduledScene = NULL; + + if (m_Scene && !m_Scene->m_Initialized) return ChangeScene(Filename, FadeIn); + else { + m_ScheduledScene = new char [strlen(Filename) + 1]; + strcpy(m_ScheduledScene, Filename); + + m_ScheduledFadeIn = FadeIn; + + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { + CBGame::GetVersion(VerMajor, VerMinor, NULL, NULL); + + if (ExtMajor) *ExtMajor = 0; + if (ExtMinor) *ExtMinor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadItemsFile(char *Filename, bool Merge) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + //m_Filename = new char [strlen(Filename)+1]; + //strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadItemsBuffer(Buffer, Merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (!Merge) { + while (m_Items.GetSize() > 0) DeleteItem(m_Items[0]); + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ITEM: { + CAdItem *item = new CAdItem(Game); + if (item && !FAILED(item->LoadBuffer(params, false))) { + // delete item with the same name, if exists + if (Merge) { + CAdItem *PrevItem = GetItemByName(item->m_Name); + if (PrevItem) DeleteItem(PrevItem); + } + AddItem(item); + } else { + delete item; + item = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ITEMS definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ITEMS definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState *CAdGame::GetSceneState(char *Filename, bool Saving) { + char *FilenameCor = new char[strlen(Filename) + 1]; + strcpy(FilenameCor, Filename); + for (int i = 0; i < strlen(FilenameCor); i++) { + if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; + } + + for (int i = 0; i < m_SceneStates.GetSize(); i++) { + if (scumm_stricmp(m_SceneStates[i]->m_Filename, FilenameCor) == 0) { + delete [] FilenameCor; + return m_SceneStates[i]; + } + } + + if (Saving) { + CAdSceneState *ret = new CAdSceneState(Game); + ret->SetFilename(FilenameCor); + + m_SceneStates.Add(ret); + + delete [] FilenameCor; + return ret; + } else { + delete [] FilenameCor; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE_END + + int cmd = PARSERR_GENERIC; + CBParser parser(Game); + + cmd = parser.GetCommand(Buffer, commands, params); + switch (cmd) { + case TOKEN_ENTITY_CONTAINER: { + CUIEntity *ent = new CUIEntity(Game); + if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { + delete ent; + ent = NULL; + cmd = PARSERR_GENERIC; + } else { + ent->m_Parent = Win; + Win->m_Widgets.Add(ent); + } + } + break; + } + + if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { + return E_FAIL; + } + + return S_OK; + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name) { + if (strcmp(Name, "CreateEntityContainer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIEntity *Ent = new CUIEntity(Game); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + + Ent->m_Parent = Win; + Win->m_Widgets.Add(Ent); + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { + char *Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (Name) { + sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); + m_DlgPendingBranches.Add(Name); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { + char *Name = NULL; + bool DeleteName = false; + if (BranchName == NULL && m_DlgPendingBranches.GetSize() > 0) { + Name = m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1]; + } else { + if (BranchName != NULL) { + Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (Name) { + sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); + DeleteName = true; + } + } + } + + if (Name == NULL) return S_OK; + + + int StartIndex = -1; + int i; + for (i = m_DlgPendingBranches.GetSize() - 1; i >= 0; i--) { + if (scumm_stricmp(Name, m_DlgPendingBranches[i]) == 0) { + StartIndex = i; + break; + } + } + if (StartIndex >= 0) { + for (i = StartIndex; i < m_DlgPendingBranches.GetSize(); i++) { + //ClearBranchResponses(m_DlgPendingBranches[i]); + delete [] m_DlgPendingBranches[i]; + m_DlgPendingBranches[i] = NULL; + } + m_DlgPendingBranches.RemoveAt(StartIndex, m_DlgPendingBranches.GetSize() - StartIndex); + } + + // dialogue is over, forget selected responses + if (m_DlgPendingBranches.GetSize() == 0) { + for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; + m_ResponsesBranch.RemoveAll(); + } + + if (DeleteName) delete [] Name; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ClearBranchResponses(char *Name) { + for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) { + if (scumm_stricmp(Name, m_ResponsesBranch[i]->m_Context) == 0) { + delete m_ResponsesBranch[i]; + m_ResponsesBranch.RemoveAt(i); + i--; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddBranchResponse(int ID) { + if (BranchResponseUsed(ID)) return S_OK; + CAdResponseContext *r = new CAdResponseContext(Game); + r->m_ID = ID; + r->SetContext(m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL); + m_ResponsesBranch.Add(r); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::BranchResponseUsed(int ID) { + char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) { + if (m_ResponsesBranch[i]->m_ID == ID) { + if ((Context == NULL && m_ResponsesBranch[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesBranch[i]->m_Context) == 0) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddGameResponse(int ID) { + if (GameResponseUsed(ID)) return S_OK; + CAdResponseContext *r = new CAdResponseContext(Game); + r->m_ID = ID; + r->SetContext(m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL); + m_ResponsesGame.Add(r); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::GameResponseUsed(int ID) { + char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < m_ResponsesGame.GetSize(); i++) { + CAdResponseContext *RespContext = m_ResponsesGame[i]; + if (RespContext->m_ID == ID) { + if ((Context == NULL && RespContext->m_Context == NULL) || ((Context != NULL && RespContext->m_Context != NULL) && scumm_stricmp(Context, RespContext->m_Context) == 0)) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ResetResponse(int ID) { + char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; + + int i; + + for (i = 0; i < m_ResponsesGame.GetSize(); i++) { + if (m_ResponsesGame[i]->m_ID == ID) { + if ((Context == NULL && m_ResponsesGame[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesGame[i]->m_Context) == 0) { + delete m_ResponsesGame[i]; + m_ResponsesGame.RemoveAt(i); + break; + } + } + } + + for (i = 0; i < m_ResponsesBranch.GetSize(); i++) { + if (m_ResponsesBranch[i]->m_ID == ID) { + if ((Context == NULL && m_ResponsesBranch[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesBranch[i]->m_Context) == 0) { + delete m_ResponsesBranch[i]; + m_ResponsesBranch.RemoveAt(i); + break; + } + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { + // init + if (Update) InitLoop(); + + // fill black + m_Renderer->Fill(0, 0, 0); + if (!m_EditorMode) m_Renderer->SetScreenViewport(); + + // process scripts + if (Update) m_ScEngine->Tick(); + + POINT p; + GetMousePos(&p); + + m_Scene->Update(); + m_Scene->Display(); + + + // display in-game windows + DisplayWindows(true); + if (m_InventoryBox) m_InventoryBox->Display(); + if (m_StateEx == GAME_WAITING_RESPONSE) m_ResponseBox->Display(); + if (m_IndicatorDisplay) DisplayIndicator(); + + + if (Update || DisplayAll) { + // display normal windows + DisplayWindows(false); + + SetActiveObject(Game->m_Renderer->GetObjectAt(p.x, p.y)); + + // textual info + DisplaySentences(m_State == GAME_FROZEN); + + ShowCursor(); + + if (m_Fader) m_Fader->Display(); + m_TransMgr->Update(); + } + + + if (m_LoadingIcon) { + m_LoadingIcon->Display(m_LoadingIconX, m_LoadingIconY); + if (!m_LoadingIconPersistent) { + delete m_LoadingIcon; + m_LoadingIcon = NULL; + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RegisterInventory(CAdInventory *Inv) { + for (int i = 0; i < m_Inventories.GetSize(); i++) { + if (m_Inventories[i] == Inv) return S_OK; + } + RegisterObject(Inv); + m_Inventories.Add(Inv); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { + for (int i = 0; i < m_Inventories.GetSize(); i++) { + if (m_Inventories[i] == Inv) { + UnregisterObject(m_Inventories[i]); + m_Inventories.RemoveAt(i); + return S_OK; + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::IsItemTaken(char *ItemName) { + int i; + + for (i = 0; i < m_Inventories.GetSize(); i++) { + CAdInventory *Inv = m_Inventories[i]; + + for (int j = 0; j < Inv->m_TakenItems.GetSize(); j++) { + if (scumm_stricmp(ItemName, Inv->m_TakenItems[j]->m_Name) == 0) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +CAdItem *CAdGame::GetItemByName(char *Name) { + for (int i = 0; i < m_Items.GetSize(); i++) { + if (scumm_stricmp(m_Items[i]->m_Name, Name) == 0) return m_Items[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddItem(CAdItem *Item) { + m_Items.Add(Item); + return Game->RegisterObject(Item); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ResetContent() { + int i; + + // clear pending dialogs + for (i = 0; i < m_DlgPendingBranches.GetSize(); i++) { + delete [] m_DlgPendingBranches[i]; + } + m_DlgPendingBranches.RemoveAll(); + + + // clear inventories + for (i = 0; i < m_Inventories.GetSize(); i++) { + m_Inventories[i]->m_TakenItems.RemoveAll(); + } + + // clear scene states + for (i = 0; i < m_SceneStates.GetSize(); i++) delete m_SceneStates[i]; + m_SceneStates.RemoveAll(); + + // clear once responses + for (i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; + m_ResponsesBranch.RemoveAll(); + + // clear once game responses + for (i = 0; i < m_ResponsesGame.GetSize(); i++) delete m_ResponsesGame[i]; + m_ResponsesGame.RemoveAll(); + + // reload inventory items + if (m_ItemsFile) LoadItemsFile(m_ItemsFile); + + m_TempDisableSaveState = true; + + return CBGame::ResetContent(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DeleteItem(CAdItem *Item) { + if (!Item) return E_FAIL; + + if (m_SelectedItem == Item) m_SelectedItem = NULL; + m_Scene->HandleItemAssociations(Item->m_Name, false); + + // remove from all inventories + for (int i = 0; i < m_Inventories.GetSize(); i++) { + m_Inventories[i]->RemoveItem(Item); + } + + // remove object + for (int i = 0; i < m_Items.GetSize(); i++) { + if (m_Items[i] == Item) { + UnregisterObject(m_Items[i]); + m_Items.RemoveAt(i); + break; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddSpeechDir(const char *Dir) { + if (!Dir || Dir[0] == '\0') return E_FAIL; + + char *Temp = new char[strlen(Dir) + 2]; + strcpy(Temp, Dir); + if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') + strcat(Temp, "\\"); + + for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { + if (scumm_stricmp(m_SpeechDirs[i], Temp) == 0) { + delete [] Temp; + return S_OK; + } + } + m_SpeechDirs.Add(Temp); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RemoveSpeechDir(char *Dir) { + if (!Dir || Dir[0] == '\0') return E_FAIL; + + char *Temp = new char[strlen(Dir) + 2]; + strcpy(Temp, Dir); + if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') + strcat(Temp, "\\"); + + bool Found = false; + for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { + if (scumm_stricmp(m_SpeechDirs[i], Temp) == 0) { + delete [] m_SpeechDirs[i]; + m_SpeechDirs.RemoveAt(i); + Found = true; + break; + } + } + delete [] Temp; + + if (Found) return S_OK; + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdGame::FindSpeechFile(char *StringID) { + char *Ret = new char[MAX_PATH]; + + for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { + sprintf(Ret, "%s%s.ogg", m_SpeechDirs[i], StringID); + CBFile *File = m_FileManager->OpenFile(Ret); + if (File) { + m_FileManager->CloseFile(File); + return Ret; + } + + sprintf(Ret, "%s%s.wav", m_SpeechDirs[i], StringID); + File = m_FileManager->OpenFile(Ret); + if (File) { + m_FileManager->CloseFile(File); + return Ret; + } + } + delete [] Ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::ValidMouse() { + POINT Pos; + CBPlatform::GetCursorPos(&Pos); + + return m_Renderer->PointInViewport(&Pos); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftDown() { + if (!ValidMouse()) return S_OK; + if (m_State == GAME_RUNNING && !m_Interactive) { + if (m_TalkSkipButton == TALK_SKIP_LEFT || m_TalkSkipButton == TALK_SKIP_BOTH) { + FinishSentences(); + } + return S_OK; + } + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftClick"); + } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { + m_Scene->ApplyEvent("LeftClick"); + } + } + + if (m_ActiveObject != NULL) Game->m_CapturedObject = Game->m_ActiveObject; + m_MouseLeftDown = true; + CBPlatform::SetCapture(m_Renderer->m_Window); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftUp() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::ReleaseCapture(); + m_CapturedObject = NULL; + m_MouseLeftDown = false; + + bool Handled = /*m_State==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftRelease"); + } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { + m_Scene->ApplyEvent("LeftRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftDblClick() { + if (!ValidMouse()) return S_OK; + + if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("LeftDoubleClick"); + } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { + m_Scene->ApplyEvent("LeftDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseRightDown() { + if (!ValidMouse()) return S_OK; + if (m_State == GAME_RUNNING && !m_Interactive) { + if (m_TalkSkipButton == TALK_SKIP_RIGHT || m_TalkSkipButton == TALK_SKIP_BOTH) { + FinishSentences(); + } + return S_OK; + } + + if ((m_State == GAME_RUNNING && !m_Interactive) || m_StateEx == GAME_WAITING_RESPONSE) return S_OK; + + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("RightClick"); + } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { + m_Scene->ApplyEvent("RightClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseRightUp() { + if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + if (!Handled) { + if (m_ActiveObject != NULL) { + m_ActiveObject->ApplyEvent("RightRelease"); + } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { + m_Scene->ApplyEvent("RightRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplayDebugInfo() { + char str[100]; + if (Game->m_DEBUG_DebugMode) { + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", m_MousePos.x, m_MousePos.y, m_MousePos.x + m_Scene->GetOffsetLeft(), m_MousePos.y + m_Scene->GetOffsetTop()); + m_SystemFont->DrawText((byte *)str, 0, 90, m_Renderer->m_Width, TAL_RIGHT); + + sprintf(str, "Scene: %s (prev: %s)", (m_Scene && m_Scene->m_Name) ? m_Scene->m_Name : "???", m_PrevSceneName ? m_PrevSceneName : "???"); + m_SystemFont->DrawText((byte *)str, 0, 110, m_Renderer->m_Width, TAL_RIGHT); + } + return CBGame::DisplayDebugInfo(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnScriptShutdown(CScScript *Script) { + if (m_ResponseBox && m_ResponseBox->m_WaitingScript == Script) + m_ResponseBox->m_WaitingScript = NULL; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h new file mode 100644 index 0000000000..d879d9e045 --- /dev/null +++ b/engines/wintermute/AdGame.h @@ -0,0 +1,162 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef __WmeAdGame_H__ +#define __WmeAdGame_H__ + +#include "AdTypes.h" +#include "BGame.h" + +namespace WinterMute { +class CAdItem; +class CAdInventory; +class CAdSceneState; +class CAdScene; +class CAdItem; +class CAdObject; +class CAdSentence; +class CAdInventoryBox; +class CAdResponseContext; +class CAdResponseBox; +class CAdGame : public CBGame { +public: + virtual HRESULT OnScriptShutdown(CScScript *Script); + + virtual HRESULT OnMouseLeftDown(); + virtual HRESULT OnMouseLeftUp(); + virtual HRESULT OnMouseLeftDblClick(); + virtual HRESULT OnMouseRightDown(); + virtual HRESULT OnMouseRightUp(); + + virtual HRESULT DisplayDebugInfo(); + + + virtual HRESULT InitAfterLoad(); + static void AfterLoadScene(void *Scene, void *Data); + + bool m_SmartItemCursor; + + CBArray m_SpeechDirs; + HRESULT AddSpeechDir(const char *Dir); + HRESULT RemoveSpeechDir(char *Dir); + char *FindSpeechFile(char *StringID); + + HRESULT DeleteItem(CAdItem *Item); + char *m_ItemsFile; + bool m_TempDisableSaveState; + virtual HRESULT ResetContent(); + HRESULT AddItem(CAdItem *Item); + CAdItem *GetItemByName(char *Name); + CBArray m_Items; + CAdObject *m_InventoryOwner; + bool IsItemTaken(char *ItemName); + HRESULT RegisterInventory(CAdInventory *Inv); + HRESULT UnregisterInventory(CAdInventory *Inv); + + CAdObject *m_InvObject; + CBArray m_Inventories; + virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); + char *m_DebugStartupScene; + char *m_StartupScene; + bool m_InitialScene; + bool GameResponseUsed(int ID); + HRESULT AddGameResponse(int ID); + HRESULT ResetResponse(int ID); + + bool BranchResponseUsed(int ID); + HRESULT AddBranchResponse(int ID); + HRESULT ClearBranchResponses(char *Name); + HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); + HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); + virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); + + CAdSceneState *GetSceneState(char *Filename, bool Saving); + CBViewport *m_SceneViewport; + int m_TexItemLifeTime; + int m_TexWalkLifeTime; + int m_TexStandLifeTime; + int m_TexTalkLifeTime; + + TTalkSkipButton m_TalkSkipButton; + + virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); + HRESULT ScheduleChangeScene(char *Filename, bool FadeIn); + char *m_ScheduledScene; + bool m_ScheduledFadeIn; + void SetPrevSceneName(char *Name); + void SetPrevSceneFilename(char *Name); + char *m_PrevSceneName; + char *m_PrevSceneFilename; + virtual HRESULT LoadGame(char *Filename); + CAdItem *m_SelectedItem; + HRESULT Cleanup(); + DECLARE_PERSISTENT(CAdGame, CBGame) + + void FinishSentences(); + HRESULT ShowCursor(); + TGameStateEx m_StateEx; + CAdResponseBox *m_ResponseBox; + CAdInventoryBox *m_InventoryBox; + HRESULT DisplaySentences(bool Frozen); + void AddSentence(CAdSentence *Sentence); + HRESULT ChangeScene(char *Filename, bool FadeIn); + HRESULT RemoveObject(CAdObject *Object); + HRESULT AddObject(CAdObject *Object); + CAdScene *m_Scene; + HRESULT InitLoop(); + CAdGame(); + virtual ~CAdGame(); + CBArray m_Objects; + CBArray m_Sentences; + + CBArray m_SceneStates; + CBArray m_DlgPendingBranches; + + CBArray m_ResponsesBranch; + CBArray m_ResponsesGame; + + virtual HRESULT LoadFile(const char *Filename); + virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + HRESULT LoadItemsFile(char *Filename, bool Merge = false); + HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); + + + virtual void PublishNatives(); + virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + bool ValidMouse(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp new file mode 100644 index 0000000000..6723c6fe70 --- /dev/null +++ b/engines/wintermute/AdInventory.cpp @@ -0,0 +1,119 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "AdInventory.h" +#include "ADGame.h" +#include "AdItem.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventory, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { + m_ScrollOffset = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventory::~CAdInventory() { + m_TakenItems.RemoveAll(); // ref only +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::InsertItem(char *Name, char *InsertAfter) { + if (Name == NULL) return E_FAIL; + + CAdItem *item = ((CAdGame *)Game)->GetItemByName(Name); + if (item == NULL) return E_FAIL; + + int InsertIndex = -1; + for (int i = 0; i < m_TakenItems.GetSize(); i++) { + if (scumm_stricmp(m_TakenItems[i]->m_Name, Name) == 0) { + m_TakenItems.RemoveAt(i); + i--; + continue; + } + if (InsertAfter && scumm_stricmp(m_TakenItems[i]->m_Name, InsertAfter) == 0) InsertIndex = i + 1; + } + + + if (InsertIndex == -1) m_TakenItems.Add(item); + else m_TakenItems.InsertAt(InsertIndex, item); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::RemoveItem(char *Name) { + if (Name == NULL) return E_FAIL; + + for (int i = 0; i < m_TakenItems.GetSize(); i++) { + if (scumm_stricmp(m_TakenItems[i]->m_Name, Name) == 0) { + if (((CAdGame *)Game)->m_SelectedItem == m_TakenItems[i])((CAdGame *)Game)->m_SelectedItem = NULL; + m_TakenItems.RemoveAt(i); + return S_OK; + } + } + + return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::RemoveItem(CAdItem *Item) { + if (Item == NULL) return E_FAIL; + + for (int i = 0; i < m_TakenItems.GetSize(); i++) { + if (m_TakenItems[i] == Item) { + if (((CAdGame *)Game)->m_SelectedItem == m_TakenItems[i])((CAdGame *)Game)->m_SelectedItem = NULL; + m_TakenItems.RemoveAt(i); + return S_OK; + } + } + + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + m_TakenItems.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h new file mode 100644 index 0000000000..828c37e964 --- /dev/null +++ b/engines/wintermute/AdInventory.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdInventory_H__ +#define __WmeAdInventory_H__ + +#include "BObject.h" + +namespace WinterMute { + +class CAdItem; + +class CAdInventory : public CBObject { +public: + DECLARE_PERSISTENT(CAdInventory, CBObject) + HRESULT RemoveItem(char *Name); + HRESULT RemoveItem(CAdItem *Item); + HRESULT InsertItem(char *Name, char *InsertAfter = NULL); + CAdInventory(CBGame *inGame); + virtual ~CAdInventory(); + CBArray m_TakenItems; + int m_ScrollOffset; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp new file mode 100644 index 0000000000..afaa139a6a --- /dev/null +++ b/engines/wintermute/AdInventoryBox.cpp @@ -0,0 +1,368 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "dcgf.h" +#include "AdInventoryBox.h" +#include "AdInventory.h" +#include "BParser.h" +#include "UIButton.h" +#include "UIWindow.h" +#include "BDynBuffer.h" +#include "BGame.h" +#include "AdGame.h" +#include "AdItem.h" +#include "BViewport.h" +#include "BFileManager.h" +#include "PlatformSDL.h" +#include "common/str.h" +#include + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventoryBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { + CBPlatform::SetRectEmpty(&m_ItemsArea); + m_ScrollOffset = 0; + m_Spacing = 0; + m_ItemWidth = m_ItemHeight = 50; + m_ScrollBy = 1; + + m_Window = NULL; + m_CloseButton = NULL; + + m_HideSelected = false; + + m_Visible = false; + m_Exclusive = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::~CAdInventoryBox() { + Game->UnregisterObject(m_Window); + m_Window = NULL; + + SAFE_DELETE(m_CloseButton); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->m_Type) { + case UI_BUTTON: + if (scumm_stricmp(obj->m_Name, "close") == 0) { + m_Visible = false; + } else if (scumm_stricmp(obj->m_Name, "prev") == 0) { + m_ScrollOffset -= m_ScrollBy; + m_ScrollOffset = std::max(m_ScrollOffset, 0); + } else if (scumm_stricmp(obj->m_Name, "next") == 0) { + m_ScrollOffset += m_ScrollBy; + } else return CBObject::Listen(param1, param2); + break; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Display() { + CAdGame *AdGame = (CAdGame *)Game; + + if (!m_Visible) return S_OK; + + int ItemsX, ItemsY; + ItemsX = floor((float)((m_ItemsArea.right - m_ItemsArea.left + m_Spacing) / (m_ItemWidth + m_Spacing))); + ItemsY = floor((float)((m_ItemsArea.bottom - m_ItemsArea.top + m_Spacing) / (m_ItemHeight + m_Spacing))); + + if (m_Window) { + m_Window->EnableWidget("prev", m_ScrollOffset > 0); + m_Window->EnableWidget("next", m_ScrollOffset + ItemsX * ItemsY < AdGame->m_InventoryOwner->GetInventory()->m_TakenItems.GetSize()); + } + + + if (m_CloseButton) { + m_CloseButton->m_PosX = m_CloseButton->m_PosY = 0; + m_CloseButton->m_Width = Game->m_Renderer->m_Width; + m_CloseButton->m_Height = Game->m_Renderer->m_Height; + + m_CloseButton->Display(); + } + + + // display window + RECT rect = m_ItemsArea; + if (m_Window) { + CBPlatform::OffsetRect(&rect, m_Window->m_PosX, m_Window->m_PosY); + m_Window->Display(); + } + + // display items + if (m_Window && m_Window->m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = m_Window->m_AlphaColor; + int yyy = rect.top; + for (int j = 0; j < ItemsY; j++) { + int xxx = rect.left; + for (int i = 0; i < ItemsX; i++) { + int ItemIndex = m_ScrollOffset + j * ItemsX + i; + if (ItemIndex >= 0 && ItemIndex < AdGame->m_InventoryOwner->GetInventory()->m_TakenItems.GetSize()) { + CAdItem *item = AdGame->m_InventoryOwner->GetInventory()->m_TakenItems[ItemIndex]; + if (item != ((CAdGame *)Game)->m_SelectedItem || !m_HideSelected) { + item->Update(); + item->Display(xxx, yyy); + } + } + + xxx += (m_ItemWidth + m_Spacing); + } + yyy += (m_ItemHeight + m_Spacing); + } + if (m_Window && m_Window->m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(WINDOW) +TOKEN_DEF(EXCLUSIVE) +TOKEN_DEF(ALWAYS_VISIBLE) +TOKEN_DEF(AREA) +TOKEN_DEF(SPACING) +TOKEN_DEF(ITEM_WIDTH) +TOKEN_DEF(ITEM_HEIGHT) +TOKEN_DEF(SCROLL_BY) +TOKEN_DEF(NAME) +TOKEN_DEF(CAPTION) +TOKEN_DEF(HIDE_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(EXCLUSIVE) + TOKEN_TABLE(ALWAYS_VISIBLE) + TOKEN_TABLE(AREA) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(ITEM_WIDTH) + TOKEN_TABLE(ITEM_HEIGHT) + TOKEN_TABLE(SCROLL_BY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(HIDE_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + bool always_visible = false; + + m_Exclusive = false; + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + Game->LOG(0, "'INVENTORY_BOX' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_WINDOW: + SAFE_DELETE(m_Window); + m_Window = new CUIWindow(Game); + if (!m_Window || FAILED(m_Window->LoadBuffer(params, false))) { + SAFE_DELETE(m_Window); + cmd = PARSERR_GENERIC; + } else Game->RegisterObject(m_Window); + break; + + case TOKEN_AREA: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_ItemsArea.left, &m_ItemsArea.top, &m_ItemsArea.right, &m_ItemsArea.bottom); + break; + + case TOKEN_EXCLUSIVE: + parser.ScanStr((char *)params, "%b", &m_Exclusive); + break; + + case TOKEN_HIDE_SELECTED: + parser.ScanStr((char *)params, "%b", &m_HideSelected); + break; + + case TOKEN_ALWAYS_VISIBLE: + parser.ScanStr((char *)params, "%b", &always_visible); + break; + + case TOKEN_SPACING: + parser.ScanStr((char *)params, "%d", &m_Spacing); + break; + + case TOKEN_ITEM_WIDTH: + parser.ScanStr((char *)params, "%d", &m_ItemWidth); + break; + + case TOKEN_ITEM_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_ItemHeight); + break; + + case TOKEN_SCROLL_BY: + parser.ScanStr((char *)params, "%d", &m_ScrollBy); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in INVENTORY_BOX definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading INVENTORY_BOX definition"); + return E_FAIL; + } + + if (m_Exclusive) { + SAFE_DELETE(m_CloseButton); + m_CloseButton = new CUIButton(Game); + if (m_CloseButton) { + m_CloseButton->SetName("close"); + m_CloseButton->SetListener(this, m_CloseButton, 0); + m_CloseButton->m_Parent = m_Window; + } + } + + m_Visible = always_visible; + + if (m_Window) { + for (int i = 0; i < m_Window->m_Widgets.GetSize(); i++) { + if (!m_Window->m_Widgets[i]->m_ListenerObject) + m_Window->m_Widgets[i]->SetListener(this, m_Window->m_Widgets[i], 0); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", m_ItemsArea.left, m_ItemsArea.top, m_ItemsArea.right, m_ItemsArea.bottom); + + Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", m_Exclusive ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", m_HideSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", m_Spacing); + Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", m_ItemWidth); + Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", m_ItemHeight); + Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", m_ScrollBy); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // window + if (m_Window) m_Window->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_CloseButton)); + PersistMgr->Transfer(TMEMBER(m_HideSelected)); + PersistMgr->Transfer(TMEMBER(m_ItemHeight)); + PersistMgr->Transfer(TMEMBER(m_ItemsArea)); + PersistMgr->Transfer(TMEMBER(m_ItemWidth)); + PersistMgr->Transfer(TMEMBER(m_ScrollBy)); + PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); + PersistMgr->Transfer(TMEMBER(m_Spacing)); + PersistMgr->Transfer(TMEMBER(m_Visible)); + PersistMgr->Transfer(TMEMBER(m_Window)); + PersistMgr->Transfer(TMEMBER(m_Exclusive)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h new file mode 100644 index 0000000000..94cb40dbf6 --- /dev/null +++ b/engines/wintermute/AdInventoryBox.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdInventoryBox_H__ +#define __WmeAdInventoryBox_H__ + +#include "BObject.h" + +namespace WinterMute { +class CUIButton; +class CUIWindow; + +class CAdInventoryBox : public CBObject { +public: + bool m_HideSelected; + DECLARE_PERSISTENT(CAdInventoryBox, CBObject) + bool m_Exclusive; + int m_ScrollBy; + int m_ItemHeight; + int m_ItemWidth; + bool m_Visible; + virtual HRESULT Display(); + CUIButton *m_CloseButton; + int m_Spacing; + int m_ScrollOffset; + RECT m_ItemsArea; + HRESULT Listen(CBScriptHolder *param1, uint32 param2); + CUIWindow *m_Window; + CAdInventoryBox(CBGame *inGame); + virtual ~CAdInventoryBox(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp new file mode 100644 index 0000000000..5a2d4d7a58 --- /dev/null +++ b/engines/wintermute/AdItem.cpp @@ -0,0 +1,754 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdItem.h" +#include "BParser.h" +#include "ScValue.h" +#include "BGame.h" +#include "AdGame.h" +#include "BSound.h" +#include "BFontStorage.h" +#include "BFont.h" +#include "AdSentence.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "utils.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdItem, false) + +////////////////////////////////////////////////////////////////////////// +CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { + m_SpriteHover = NULL; + m_CursorNormal = m_CursorHover = NULL; + + m_CursorCombined = true; + m_InInventory = false; + + m_DisplayAmount = false; + m_Amount = 0; + m_AmountOffsetX = 0; + m_AmountOffsetY = 0; + m_AmountAlign = TAL_RIGHT; + m_AmountString = NULL; + + m_State = STATE_READY; + + m_Movable = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdItem::~CAdItem() { + delete m_SpriteHover; + delete m_CursorNormal; + delete m_CursorHover; + m_SpriteHover = NULL; + m_CursorNormal = NULL; + m_CursorHover = NULL; + + delete[] m_AmountString; + m_AmountString = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ITEM) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(CURSOR_HOVER) +TOKEN_DEF(CURSOR_COMBINED) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(FONT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(SPRITE_HOVER) +TOKEN_DEF(SPRITE) +TOKEN_DEF(DISPLAY_AMOUNT) +TOKEN_DEF(AMOUNT_OFFSET_X) +TOKEN_DEF(AMOUNT_OFFSET_Y) +TOKEN_DEF(AMOUNT_ALIGN) +TOKEN_DEF(AMOUNT_STRING) +TOKEN_DEF(AMOUNT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(CURSOR_HOVER) + TOKEN_TABLE(CURSOR_COMBINED) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(FONT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(SPRITE_HOVER) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(DISPLAY_AMOUNT) + TOKEN_TABLE(AMOUNT_OFFSET_X) + TOKEN_TABLE(AMOUNT_OFFSET_Y) + TOKEN_TABLE(AMOUNT_ALIGN) + TOKEN_TABLE(AMOUNT_STRING) + TOKEN_TABLE(AMOUNT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + Game->LOG(0, "'ITEM' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int ar = 0, ag = 0, ab = 0, alpha = 255; + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_IMAGE: + case TOKEN_SPRITE: + delete m_Sprite; + m_Sprite = new CBSprite(Game, this); + if (!m_Sprite || FAILED(m_Sprite->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { + delete m_Sprite; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + case TOKEN_SPRITE_HOVER: + delete m_SpriteHover; + m_SpriteHover = new CBSprite(Game, this); + if (!m_SpriteHover || FAILED(m_SpriteHover->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { + delete m_SpriteHover; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_AMOUNT: + parser.ScanStr((char *)params, "%d", &m_Amount); + break; + + case TOKEN_DISPLAY_AMOUNT: + parser.ScanStr((char *)params, "%b", &m_DisplayAmount); + break; + + case TOKEN_AMOUNT_OFFSET_X: + parser.ScanStr((char *)params, "%d", &m_AmountOffsetX); + break; + + case TOKEN_AMOUNT_OFFSET_Y: + parser.ScanStr((char *)params, "%d", &m_AmountOffsetY); + break; + + case TOKEN_AMOUNT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) m_AmountAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) m_AmountAlign = TAL_RIGHT; + else m_AmountAlign = TAL_CENTER; + break; + + case TOKEN_AMOUNT_STRING: + CBUtils::SetString(&m_AmountString, (char *)params); + break; + + case TOKEN_TALK: { + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSprites.Add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; + else m_TalkSpritesEx.Add(spr); + } + break; + + case TOKEN_CURSOR: + delete m_CursorNormal; + m_CursorNormal = new CBSprite(Game); + if (!m_CursorNormal || FAILED(m_CursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { + delete m_CursorNormal; + m_CursorNormal = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_HOVER: + delete m_CursorHover; + m_CursorHover = new CBSprite(Game); + if (!m_CursorHover || FAILED(m_CursorHover->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { + delete m_CursorHover; + m_CursorHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_COMBINED: + parser.ScanStr((char *)params, "%b", &m_CursorCombined); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ITEM definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ITEM definition"); + return E_FAIL; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + m_AlphaColor = DRGBA(ar, ag, ab, alpha); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Update() { + m_CurrentSprite = NULL; + + if (m_State == STATE_READY && m_AnimSprite) { + delete m_AnimSprite; + m_AnimSprite = NULL; + } + + // finished playing animation? + if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { + m_State = STATE_READY; + m_CurrentSprite = m_AnimSprite; + } + + if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + + // default: stand animation + if (!m_CurrentSprite) m_CurrentSprite = m_Sprite; + + switch (m_State) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + m_CurrentSprite = m_AnimSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!m_AnimSprite) { + if (Game->m_ActiveObject == this && m_SpriteHover) m_CurrentSprite = m_SpriteHover; + else m_CurrentSprite = m_Sprite; + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + m_Sentence->Update(); + if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + + bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); + if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + m_Sentence->Finish(); + m_TempSprite2 = NULL; + m_State = STATE_READY; + } else { + m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); + if (m_TempSprite2) { + m_TempSprite2->Reset(); + m_CurrentSprite = m_TempSprite2; + } + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } else { + m_CurrentSprite = m_TempSprite2; + ((CAdGame *)Game)->AddSentence(m_Sentence); + } + } + break; + } + m_Ready = (m_State == STATE_READY); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Display(int X, int Y) { + int Width = 0; + if (m_CurrentSprite) { + RECT rc; + m_CurrentSprite->GetBoundingRect(&rc, 0, 0); + Width = rc.right - rc.left; + } + + m_PosX = X + Width / 2; + m_PosY = Y; + + HRESULT ret; + if (m_CurrentSprite) ret = m_CurrentSprite->Draw(X, Y, this, 100, 100, m_AlphaColor); + else ret = S_OK; + + if (m_DisplayAmount) { + int AmountX = X; + int AmountY = Y + m_AmountOffsetY; + + if (m_AmountAlign == TAL_RIGHT) { + Width -= m_AmountOffsetX; + AmountX -= m_AmountOffsetX; + } + AmountX += m_AmountOffsetX; + + CBFont *Font = m_Font ? m_Font : Game->m_SystemFont; + if (Font) { + if (m_AmountString) Font->DrawText((byte *)m_AmountString, AmountX, AmountY, Width, m_AmountAlign); + else { + char Str[256]; + sprintf(Str, "%d", m_Amount); + Font->DrawText((byte *)Str, AmountX, AmountY, Width, m_AmountAlign); + } + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetHoverSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetHoverSprite") == 0) { + Stack->CorrectParams(1); + + bool SetCurrent = false; + if (m_CurrentSprite && m_CurrentSprite == m_SpriteHover) SetCurrent = true; + + char *Filename = Stack->Pop()->GetString(); + + delete m_SpriteHover; + m_SpriteHover = NULL; + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); + } else { + m_SpriteHover = spr; + if (SetCurrent) m_CurrentSprite = m_SpriteHover; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverSprite") == 0) { + Stack->CorrectParams(0); + + if (!m_SpriteHover || !m_SpriteHover->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_SpriteHover->m_Filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverSpriteObject") == 0) { + Stack->CorrectParams(0); + if (!m_SpriteHover) Stack->PushNULL(); + else Stack->PushNative(m_SpriteHover, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetNormalCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetNormalCursor") == 0) { + Stack->CorrectParams(1); + + char *Filename = Stack->Pop()->GetString(); + + delete m_CursorNormal; + m_CursorNormal = NULL; + CBSprite *spr = new CBSprite(Game); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); + } else { + m_CursorNormal = spr; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNormalCursor") == 0) { + Stack->CorrectParams(0); + + if (!m_CursorNormal || !m_CursorNormal->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_CursorNormal->m_Filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNormalCursorObject") == 0) { + Stack->CorrectParams(0); + + if (!m_CursorNormal) Stack->PushNULL(); + else Stack->PushNative(m_CursorNormal, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetHoverCursor") == 0) { + Stack->CorrectParams(1); + + char *Filename = Stack->Pop()->GetString(); + + delete m_CursorHover; + m_CursorHover = NULL; + CBSprite *spr = new CBSprite(Game); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); + } else { + m_CursorHover = spr; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverCursor") == 0) { + Stack->CorrectParams(0); + + if (!m_CursorHover || !m_CursorHover->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_CursorHover->m_Filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverCursorObject") == 0) { + Stack->CorrectParams(0); + + if (!m_CursorHover) Stack->PushNULL(); + else Stack->PushNative(m_CursorHover, true); + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdItem::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("item"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayAmount") == 0) { + m_ScValue->SetBool(m_DisplayAmount); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Amount") == 0) { + m_ScValue->SetInt(m_Amount); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetX") == 0) { + m_ScValue->SetInt(m_AmountOffsetX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetY") == 0) { + m_ScValue->SetInt(m_AmountOffsetY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountAlign") == 0) { + m_ScValue->SetInt(m_AmountAlign); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountString") == 0) { + if (!m_AmountString) m_ScValue->SetNULL(); + else m_ScValue->SetString(m_AmountString); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorCombined") == 0) { + m_ScValue->SetBool(m_CursorCombined); + return m_ScValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayAmount") == 0) { + m_DisplayAmount = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Amount") == 0) { + m_Amount = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetX") == 0) { + m_AmountOffsetX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetY") == 0) { + m_AmountOffsetY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountAlign") == 0) { + m_AmountAlign = (TTextAlign)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountString") == 0) { + if (Value->IsNULL()) SAFE_DELETE_ARRAY(m_AmountString); + else CBUtils::SetString(&m_AmountString, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorCombined") == 0) { + m_CursorCombined = Value->GetBool(); + return S_OK; + } + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdItem::ScToString() { + return "[item]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { + + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_CursorCombined)); + PersistMgr->Transfer(TMEMBER(m_CursorHover)); + PersistMgr->Transfer(TMEMBER(m_CursorNormal)); + PersistMgr->Transfer(TMEMBER(m_SpriteHover)); + PersistMgr->Transfer(TMEMBER(m_InInventory)); + PersistMgr->Transfer(TMEMBER(m_DisplayAmount)); + PersistMgr->Transfer(TMEMBER(m_Amount)); + PersistMgr->Transfer(TMEMBER(m_AmountOffsetX)); + PersistMgr->Transfer(TMEMBER(m_AmountOffsetY)); + PersistMgr->Transfer(TMEMBER_INT(m_AmountAlign)); + PersistMgr->Transfer(TMEMBER(m_AmountString)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::GetExtendedFlag(char *FlagName) { + if (!FlagName) return false; + else if (strcmp(FlagName, "usable") == 0) return true; + else return CAdObject::GetExtendedFlag(FlagName); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h new file mode 100644 index 0000000000..8bb9cd46a0 --- /dev/null +++ b/engines/wintermute/AdItem.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdItem_H__ +#define __WmeAdItem_H__ + + +#include "AdTalkHolder.h" + +namespace WinterMute { + +class CAdItem : public CAdTalkHolder { +public: + bool m_DisplayAmount; + int m_Amount; + int m_AmountOffsetX; + int m_AmountOffsetY; + TTextAlign m_AmountAlign; + char *m_AmountString; + + + HRESULT Update(); + DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) + HRESULT Display(int X, int Y); + bool GetExtendedFlag(char *FlagName); + bool m_InInventory; + bool m_CursorCombined; + CBSprite *m_SpriteHover; + CBSprite *m_CursorNormal; + CBSprite *m_CursorHover; + CAdItem(CBGame *inGame); + virtual ~CAdItem(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp new file mode 100644 index 0000000000..6fc53ede7e --- /dev/null +++ b/engines/wintermute/AdLayer.cpp @@ -0,0 +1,535 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BGame.h" +#include "AdLayer.h" +#include "AdSceneNode.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BFileManager.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdLayer, false) + +////////////////////////////////////////////////////////////////////////// +CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { + m_Main = false; + m_Width = m_Height = 0; + m_Active = true; + m_CloseUp = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdLayer::~CAdLayer() { + for (int i = 0; i < m_Nodes.GetSize(); i++) + delete m_Nodes[i]; + m_Nodes.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(LAYER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(MAIN) +TOKEN_DEF(ENTITY) +TOKEN_DEF(REGION) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(CLOSE_UP) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(MAIN) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(REGION) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(CLOSE_UP) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + Game->LOG(0, "'LAYER' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_MAIN: + parser.ScanStr((char *)params, "%b", &m_Main); + break; + + case TOKEN_CLOSE_UP: + parser.ScanStr((char *)params, "%b", &m_CloseUp); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &m_Width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &m_Height); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &m_Active); + break; + + case TOKEN_REGION: { + CAdRegion *region = new CAdRegion(Game); + CAdSceneNode *node = new CAdSceneNode(Game); + if (!region || !node || FAILED(region->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete region; + delete node; + region = NULL; + node = NULL; + } else { + node->SetRegion(region); + m_Nodes.Add(node); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(Game); + CAdSceneNode *node = new CAdSceneNode(Game); + if (entity) entity->m_Zoomable = false; // scene entites default to NOT zoom + if (!entity || !node || FAILED(entity->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + delete node; + entity = NULL; + node = NULL; + } else { + node->SetEntity(entity); + m_Nodes.Add(node); + } + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &m_EditorSelected); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in LAYER definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetNode") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + int node = -1; + + if (val->m_Type == VAL_INT) node = val->GetInt(); + else { // get by name + for (int i = 0; i < m_Nodes.GetSize(); i++) { + if ((m_Nodes[i]->m_Type == OBJECT_ENTITY && scumm_stricmp(m_Nodes[i]->m_Entity->m_Name, val->GetString()) == 0) || + (m_Nodes[i]->m_Type == OBJECT_REGION && scumm_stricmp(m_Nodes[i]->m_Region->m_Name, val->GetString()) == 0)) { + node = i; + break; + } + } + } + + if (node < 0 || node >= m_Nodes.GetSize()) Stack->PushNULL(); + else { + switch (m_Nodes[node]->m_Type) { + case OBJECT_ENTITY: + Stack->PushNative(m_Nodes[node]->m_Entity, true); + break; + case OBJECT_REGION: + Stack->PushNative(m_Nodes[node]->m_Region, true); + break; + default: + Stack->PushNULL(); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddRegion / AddEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddRegion") == 0 || strcmp(Name, "AddEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *Node = new CAdSceneNode(Game); + if (strcmp(Name, "AddRegion") == 0) { + CAdRegion *Region = new CAdRegion(Game); + if (!Val->IsNULL()) Region->SetName(Val->GetString()); + Node->SetRegion(Region); + Stack->PushNative(Region, true); + } else { + CAdEntity *Entity = new CAdEntity(Game); + if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + Node->SetEntity(Entity); + Stack->PushNative(Entity, true); + } + m_Nodes.Add(Node); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertRegion / InsertEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertRegion") == 0 || strcmp(Name, "InsertEntity") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *Node = new CAdSceneNode(Game); + if (strcmp(Name, "InsertRegion") == 0) { + CAdRegion *Region = new CAdRegion(Game); + if (!Val->IsNULL()) Region->SetName(Val->GetString()); + Node->SetRegion(Region); + Stack->PushNative(Region, true); + } else { + CAdEntity *Entity = new CAdEntity(Game); + if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + Node->SetEntity(Entity); + Stack->PushNative(Entity, true); + } + if (Index < 0) Index = 0; + if (Index <= m_Nodes.GetSize() - 1) m_Nodes.InsertAt(Index, Node); + else m_Nodes.Add(Node); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteNode") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *ToDelete = NULL; + if (Val->IsNative()) { + CBScriptable *Temp = Val->GetNative(); + for (int i = 0; i < m_Nodes.GetSize(); i++) { + if (m_Nodes[i]->m_Region == Temp || m_Nodes[i]->m_Entity == Temp) { + ToDelete = m_Nodes[i]; + break; + } + } + } else { + int Index = Val->GetInt(); + if (Index >= 0 && Index < m_Nodes.GetSize()) { + ToDelete = m_Nodes[Index]; + } + } + if (ToDelete == NULL) { + Stack->PushBool(false); + return S_OK; + } + + for (int i = 0; i < m_Nodes.GetSize(); i++) { + if (m_Nodes[i] == ToDelete) { + delete m_Nodes[i]; + m_Nodes[i] = NULL; + m_Nodes.RemoveAt(i); + break; + } + } + Stack->PushBool(true); + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdLayer::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("layer"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumNodes") == 0) { + m_ScValue->SetInt(m_Nodes.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_ScValue->SetInt(m_Width); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_ScValue->SetInt(m_Height); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Main (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Main") == 0) { + m_ScValue->SetBool(m_Main); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CloseUp") == 0) { + m_ScValue->SetBool(m_CloseUp); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + m_ScValue->SetBool(m_Active); + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CloseUp") == 0) { + m_CloseUp = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_Width = Value->GetInt(); + if (m_Width < 0) m_Width = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_Height = Value->GetInt(); + if (m_Height < 0) m_Height = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + bool b = Value->GetBool(); + if (b == false && m_Main) { + Game->LOG(0, "Warning: cannot deactivate scene's main layer"); + } else m_Active = b; + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdLayer::ScToString() { + return "[layer]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "LAYER {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", m_Main ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + if (m_CloseUp) + Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", m_CloseUp ? "TRUE" : "FALSE"); + + int i; + + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + + for (i = 0; i < m_Nodes.GetSize(); i++) { + switch (m_Nodes[i]->m_Type) { + case OBJECT_ENTITY: + m_Nodes[i]->m_Entity->SaveAsText(Buffer, Indent + 2); + break; + case OBJECT_REGION: + m_Nodes[i]->m_Region->SaveAsText(Buffer, Indent + 2); + break; + } + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_CloseUp)); + PersistMgr->Transfer(TMEMBER(m_Height)); + PersistMgr->Transfer(TMEMBER(m_Main)); + m_Nodes.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_Width)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h new file mode 100644 index 0000000000..eda3e6f272 --- /dev/null +++ b/engines/wintermute/AdLayer.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdLayer_H__ +#define __WmeAdLayer_H__ + +namespace WinterMute { +class CAdSceneNode; +class CAdLayer : public CBObject { +public: + bool m_CloseUp; + DECLARE_PERSISTENT(CAdLayer, CBObject) + bool m_Active; + int m_Height; + int m_Width; + bool m_Main; + CAdLayer(CBGame *inGame); + virtual ~CAdLayer(); + CBArray m_Nodes; + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp new file mode 100644 index 0000000000..da2f4a39b9 --- /dev/null +++ b/engines/wintermute/AdNodeState.cpp @@ -0,0 +1,169 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "BGame.h" +#include "AdNodeState.h" +#include "AdEntity.h" +#include "BStringTable.h" +#include "BSprite.h" +#include "utils.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdNodeState, false) + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { + m_Name = NULL; + m_Active = false; + for (int i = 0; i < 7; i++) m_Caption[i] = NULL; + m_AlphaColor = 0; + m_Filename = NULL; + m_Cursor = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::~CAdNodeState() { + delete[] m_Name; + delete[] m_Filename; + delete[] m_Cursor; + m_Name = NULL; + m_Filename = NULL; + m_Cursor = NULL; + for (int i = 0; i < 7; i++) { + delete[] m_Caption[i]; + m_Caption[i] = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetName(char *Name) { + delete[] m_Name; + m_Name = NULL; + CBUtils::SetString(&m_Name, Name); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetFilename(char *Filename) { + delete[] m_Filename; + m_Filename = NULL; + CBUtils::SetString(&m_Filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetCursor(char *Filename) { + delete[] m_Cursor; + m_Cursor = NULL; + CBUtils::SetString(&m_Cursor, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_Name)); + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_Cursor)); + PersistMgr->Transfer(TMEMBER(m_AlphaColor)); + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(m_Caption[i])); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetCaption(char *Caption, int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7) return; + + delete[] m_Caption[Case - 1]; + m_Caption[Case - 1] = new char[strlen(Caption) + 1]; + if (m_Caption[Case - 1]) { + strcpy(m_Caption[Case - 1], Caption); + Game->m_StringTable->Expand(&m_Caption[Case - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdNodeState::GetCaption(int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7 || m_Caption[Case - 1] == NULL) return ""; + else return m_Caption[Case - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving) { + if (!Entity) return E_FAIL; + + // hack! + if (this->Game != Entity->Game) this->Game = Entity->Game; + + if (Saving) { + for (int i = 0; i < 7; i++) { + if (Entity->m_Caption[i]) SetCaption(Entity->m_Caption[i], i); + } + if (!Entity->m_Region && Entity->m_Sprite && Entity->m_Sprite->m_Filename) { + if (IncludingSprites) SetFilename(Entity->m_Sprite->m_Filename); + else SetFilename(""); + } + if (Entity->m_Cursor && Entity->m_Cursor->m_Filename) SetCursor(Entity->m_Cursor->m_Filename); + m_AlphaColor = Entity->m_AlphaColor; + m_Active = Entity->m_Active; + } else { + for (int i = 0; i < 7; i++) { + if (m_Caption[i]) Entity->SetCaption(m_Caption[i], i); + } + if (m_Filename && !Entity->m_Region && IncludingSprites && strcmp(m_Filename, "") != 0) { + if (!Entity->m_Sprite || !Entity->m_Sprite->m_Filename || scumm_stricmp(Entity->m_Sprite->m_Filename, m_Filename) != 0) + Entity->SetSprite(m_Filename); + } + if (m_Cursor) { + if (!Entity->m_Cursor || !Entity->m_Cursor->m_Filename || scumm_stricmp(Entity->m_Cursor->m_Filename, m_Cursor) != 0) + Entity->SetCursor(m_Cursor); + } + + Entity->m_Active = m_Active; + Entity->m_AlphaColor = m_AlphaColor; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h new file mode 100644 index 0000000000..722d880c33 --- /dev/null +++ b/engines/wintermute/AdNodeState.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdNodeState_H__ +#define __WmeAdNodeState_H__ + +namespace WinterMute { + +class CAdEntity; + +class CAdNodeState : public CBBase { +public: + HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); + void SetName(char *Name); + void SetFilename(char *Filename); + void SetCursor(char *Filename); + DECLARE_PERSISTENT(CAdNodeState, CBBase) + CAdNodeState(CBGame *inGame); + virtual ~CAdNodeState(); + char *m_Name; + bool m_Active; + char *m_Caption[7]; + void SetCaption(char *Caption, int Case); + char *GetCaption(int Case); + uint32 m_AlphaColor; + char *m_Filename; + char *m_Cursor; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp new file mode 100644 index 0000000000..4454d1d0f6 --- /dev/null +++ b/engines/wintermute/AdObject.cpp @@ -0,0 +1,1190 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdObject.h" +#include "AdScene.h" +#include "BGame.h" +#include "BFrame.h" +#include "BSound.h" +#include "BSurfaceStorage.h" +#include "ScValue.h" +#include "AdGame.h" +#include "AdLayer.h" +#include "AdSceneNode.h" +#include "AdInventory.h" +#include "AdWaypointGroup.h" +#include "AdItem.h" +#include "BSubFrame.h" +#include "BFont.h" +#include "BFontStorage.h" +#include "ScEngine.h" +#include "BStringTable.h" +#include "AdSentence.h" +#include "ScScript.h" +#include "BSprite.h" +#include "ScStack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdObject, false) + +////////////////////////////////////////////////////////////////////////// +CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { + m_Type = OBJECT_NONE; + m_State = m_NextState = STATE_NONE; + + m_Active = true; + m_Drawn = false; + + m_CurrentSprite = NULL; + m_AnimSprite = NULL; + m_TempSprite2 = NULL; + + m_Font = NULL; + + m_Sentence = NULL; + + m_ForcedTalkAnimName = NULL; + m_ForcedTalkAnimUsed = false; + + m_BlockRegion = NULL; + m_WptGroup = NULL; + + m_CurrentBlockRegion = NULL; + m_CurrentWptGroup = NULL; + + m_IgnoreItems = false; + m_SceneIndependent = false; + + m_StickRegion = NULL; + + m_SubtitlesModRelative = true; + m_SubtitlesModX = 0; + m_SubtitlesModY = 0; + m_SubtitlesWidth = 0; + m_SubtitlesModXCenter = true; + + m_Inventory = NULL; + + for (int i = 0; i < MAX_NUM_REGIONS; i++) m_CurrentRegions[i] = NULL; + + m_PartEmitter = NULL; + m_PartFollowParent = false; + m_PartOffsetX = m_PartOffsetY = 0; + + m_RegisterAlias = this; +} + + +////////////////////////////////////////////////////////////////////////// +CAdObject::~CAdObject() { + m_CurrentSprite = NULL; // reference only, don't delete + SAFE_DELETE(m_AnimSprite); + SAFE_DELETE(m_Sentence); + SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); + + SAFE_DELETE(m_BlockRegion); + SAFE_DELETE(m_WptGroup); + + SAFE_DELETE(m_CurrentBlockRegion); + SAFE_DELETE(m_CurrentWptGroup); + + + m_TempSprite2 = NULL; // reference only + m_StickRegion = NULL; + + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + + if (m_Inventory) { + ((CAdGame *)Game)->UnregisterInventory(m_Inventory); + m_Inventory = NULL; + } + + if (m_PartEmitter) + Game->UnregisterObject(m_PartEmitter); + + + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + Game->UnregisterObject(m_AttachmentsPre[i]); + } + m_AttachmentsPre.RemoveAll(); + + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + Game->UnregisterObject(m_AttachmentsPost[i]); + } + m_AttachmentsPost.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::PlayAnim(char *Filename) { + SAFE_DELETE(m_AnimSprite); + m_AnimSprite = new CBSprite(Game, this); + if (!m_AnimSprite) { + Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", m_Name, Filename); + return E_FAIL; + } + HRESULT res = m_AnimSprite->LoadFile(Filename); + if (FAILED(res)) { + Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", m_Name, Filename); + SAFE_DELETE(m_AnimSprite); + return res; + } + m_State = STATE_PLAYING_ANIM; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Display() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Update() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // PlayAnim / PlayAnimAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "PlayAnim") == 0 || strcmp(Name, "PlayAnimAsync") == 0) { + Stack->CorrectParams(1); + if (FAILED(PlayAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); + else { + if (strcmp(Name, "PlayAnimAsync") != 0) Script->WaitFor(this); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + Reset(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTalking") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(m_State == STATE_TALKING); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTalk / StopTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { + Stack->CorrectParams(0); + if (m_Sentence) m_Sentence->Finish(); + if (m_State == STATE_TALKING) { + m_State = m_NextState; + m_NextState = STATE_READY; + Stack->PushBool(true); + } else Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ForceTalkAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ForceTalkAnim") == 0) { + Stack->CorrectParams(1); + char *AnimName = Stack->Pop()->GetString(); + SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); + m_ForcedTalkAnimName = new char[strlen(AnimName) + 1]; + strcpy(m_ForcedTalkAnimName, AnimName); + m_ForcedTalkAnimUsed = false; + Stack->PushBool(true); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Talk / TalkAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Talk") == 0 || strcmp(Name, "TalkAsync") == 0) { + Stack->CorrectParams(5); + + char *Text = Stack->Pop()->GetString(); + CScValue *SoundVal = Stack->Pop(); + int Duration = Stack->Pop()->GetInt(); + CScValue *ValStances = Stack->Pop(); + + char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); + + int Align; + CScValue *val = Stack->Pop(); + if (val->IsNULL()) Align = TAL_CENTER; + else Align = val->GetInt(); + + Align = std::min(std::max(0, Align), NUM_TEXT_ALIGN - 1); + + char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); + + Talk(Text, Sound, Duration, Stances, (TTextAlign)Align); + if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StickToRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StickToRegion") == 0) { + Stack->CorrectParams(1); + + CAdLayer *Main = ((CAdGame *)Game)->m_Scene->m_MainLayer; + bool RegFound = false; + + int i; + CScValue *Val = Stack->Pop(); + if (Val->IsNULL() || !Main) { + m_StickRegion = NULL; + RegFound = true; + } else if (Val->IsString()) { + char *RegionName = Val->GetString(); + for (i = 0; i < Main->m_Nodes.GetSize(); i++) { + if (Main->m_Nodes[i]->m_Type == OBJECT_REGION && Main->m_Nodes[i]->m_Region->m_Name && scumm_stricmp(Main->m_Nodes[i]->m_Region->m_Name, RegionName) == 0) { + m_StickRegion = Main->m_Nodes[i]->m_Region; + RegFound = true; + break; + } + } + } else if (Val->IsNative()) { + CBScriptable *Obj = Val->GetNative(); + + for (i = 0; i < Main->m_Nodes.GetSize(); i++) { + if (Main->m_Nodes[i]->m_Type == OBJECT_REGION && Main->m_Nodes[i]->m_Region == Obj) { + m_StickRegion = Main->m_Nodes[i]->m_Region; + RegFound = true; + break; + } + } + + } + + if (!RegFound) m_StickRegion = NULL; + Stack->PushBool(RegFound); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsNULL()) SetFont(NULL); + else SetFont(Val->GetString()); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFont") == 0) { + Stack->CorrectParams(0); + if (m_Font && m_Font->m_Filename) Stack->PushString(m_Font->m_Filename); + else Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TakeItem") == 0) { + Stack->CorrectParams(2); + + if (!m_Inventory) { + m_Inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(m_Inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + char *ItemName = val->GetString(); + val = Stack->Pop(); + char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); + if (FAILED(m_Inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + else { + // hide associated entities + ((CAdGame *)Game)->m_Scene->HandleItemAssociations(ItemName, false); + } + + } else Script->RuntimeError("TakeItem: item name expected"); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DropItem") == 0) { + Stack->CorrectParams(1); + + if (!m_Inventory) { + m_Inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(m_Inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + if (FAILED(m_Inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); + else { + // show associated entities + ((CAdGame *)Game)->m_Scene->HandleItemAssociations(val->GetString(), true); + } + } else Script->RuntimeError("DropItem: item name expected"); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetItem") == 0) { + Stack->CorrectParams(1); + + if (!m_Inventory) { + m_Inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(m_Inventory); + } + + CScValue *val = Stack->Pop(); + if (val->m_Type == VAL_STRING) { + CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); + if (item) Stack->PushNative(item, true); + else Stack->PushNULL(); + } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= m_Inventory->m_TakenItems.GetSize()) + Stack->PushNULL(); + else + Stack->PushNative(m_Inventory->m_TakenItems[val->GetInt()], true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasItem") == 0) { + Stack->CorrectParams(1); + + if (!m_Inventory) { + m_Inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(m_Inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + for (int i = 0; i < m_Inventory->m_TakenItems.GetSize(); i++) { + if (val->GetNative() == m_Inventory->m_TakenItems[i]) { + Stack->PushBool(true); + return S_OK; + } else if (scumm_stricmp(val->GetString(), m_Inventory->m_TakenItems[i]->m_Name) == 0) { + Stack->PushBool(true); + return S_OK; + } + } + } else Script->RuntimeError("HasItem: item name expected"); + + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateParticleEmitter") == 0) { + Stack->CorrectParams(3); + bool FollowParent = Stack->Pop()->GetBool(); + int OffsetX = Stack->Pop()->GetInt(); + int OffsetY = Stack->Pop()->GetInt(); + + CPartEmitter *Emitter = CreateParticleEmitter(FollowParent, OffsetX, OffsetY); + if (Emitter) Stack->PushNative(m_PartEmitter, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteParticleEmitter") == 0) { + Stack->CorrectParams(0); + if (m_PartEmitter) { + Game->UnregisterObject(m_PartEmitter); + m_PartEmitter = NULL; + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddAttachment") == 0) { + Stack->CorrectParams(4); + char *Filename = Stack->Pop()->GetString(); + bool PreDisplay = Stack->Pop()->GetBool(true); + int OffsetX = Stack->Pop()->GetInt(); + int OffsetY = Stack->Pop()->GetInt(); + + HRESULT res; + CAdEntity *Ent = new CAdEntity(Game); + if (FAILED(res = Ent->LoadFile(Filename))) { + SAFE_DELETE(Ent); + Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); + Stack->PushBool(false); + } else { + Game->RegisterObject(Ent); + + Ent->m_PosX = OffsetX; + Ent->m_PosY = OffsetY; + Ent->m_Active = true; + + if (PreDisplay) m_AttachmentsPre.Add(Ent); + else m_AttachmentsPost.Add(Ent); + + Stack->PushBool(true); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveAttachment") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + bool Found = false; + if (Val->IsNative()) { + CBScriptable *Obj = Val->GetNative(); + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + if (m_AttachmentsPre[i] == Obj) { + Found = true; + Game->UnregisterObject(m_AttachmentsPre[i]); + m_AttachmentsPre.RemoveAt(i); + i--; + } + } + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + if (m_AttachmentsPost[i] == Obj) { + Found = true; + Game->UnregisterObject(m_AttachmentsPost[i]); + m_AttachmentsPost.RemoveAt(i); + i--; + } + } + } else { + char *Name = Val->GetString(); + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + if (m_AttachmentsPre[i]->m_Name && scumm_stricmp(m_AttachmentsPre[i]->m_Name, Name) == 0) { + Found = true; + Game->UnregisterObject(m_AttachmentsPre[i]); + m_AttachmentsPre.RemoveAt(i); + i--; + } + } + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + if (m_AttachmentsPost[i]->m_Name && scumm_stricmp(m_AttachmentsPost[i]->m_Name, Name) == 0) { + Found = true; + Game->UnregisterObject(m_AttachmentsPost[i]); + m_AttachmentsPost.RemoveAt(i); + i--; + } + } + } + Stack->PushBool(Found); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetAttachment") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdObject *Ret = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + int CurrIndex = 0; + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + if (CurrIndex == Index) Ret = m_AttachmentsPre[i]; + CurrIndex++; + } + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + if (CurrIndex == Index) Ret = m_AttachmentsPost[i]; + CurrIndex++; + } + } else { + char *Name = Val->GetString(); + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + if (m_AttachmentsPre[i]->m_Name && scumm_stricmp(m_AttachmentsPre[i]->m_Name, Name) == 0) { + Ret = m_AttachmentsPre[i]; + break; + } + } + if (!Ret) { + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + if (m_AttachmentsPost[i]->m_Name && scumm_stricmp(m_AttachmentsPost[i]->m_Name, Name) == 0) { + Ret = m_AttachmentsPre[i]; + break; + } + } + } + } + + if (Ret != NULL) Stack->PushNative(Ret, true); + else Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdObject::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("object"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + m_ScValue->SetBool(m_Active); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IgnoreItems") == 0) { + m_ScValue->SetBool(m_IgnoreItems); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SceneIndependent") == 0) { + m_ScValue->SetBool(m_SceneIndependent); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesWidth") == 0) { + m_ScValue->SetInt(m_SubtitlesWidth); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + m_ScValue->SetBool(m_SubtitlesModRelative); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosX") == 0) { + m_ScValue->SetInt(m_SubtitlesModX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosY") == 0) { + m_ScValue->SetInt(m_SubtitlesModY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + m_ScValue->SetBool(m_SubtitlesModXCenter); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumItems (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumItems") == 0) { + m_ScValue->SetInt(GetInventory()->m_TakenItems.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParticleEmitter (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParticleEmitter") == 0) { + if (m_PartEmitter) m_ScValue->SetNative(m_PartEmitter, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumAttachments (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumAttachments") == 0) { + m_ScValue->SetInt(m_AttachmentsPre.GetSize() + m_AttachmentsPost.GetSize()); + return m_ScValue; + } + + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Active") == 0) { + m_Active = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IgnoreItems") == 0) { + m_IgnoreItems = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SceneIndependent") == 0) { + m_SceneIndependent = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesWidth") == 0) { + m_SubtitlesWidth = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + m_SubtitlesModRelative = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosX") == 0) { + m_SubtitlesModX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosY") == 0) { + m_SubtitlesModY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + m_SubtitlesModXCenter = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdObject::ScToString() { + return "[ad object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::SetFont(char *Filename) { + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (Filename) { + m_Font = Game->m_FontStorage->AddFont(Filename); + return m_Font == NULL ? E_FAIL : S_OK; + } else { + m_Font = NULL; + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CAdObject::GetHeight() { + if (!m_CurrentSprite) return 0; + else { + CBFrame *frame = m_CurrentSprite->m_Frames[m_CurrentSprite->m_CurrentFrame]; + int ret = 0; + for (int i = 0; i < frame->m_Subframes.GetSize(); i++) { + ret = std::max(ret, frame->m_Subframes[i]->m_HotspotY); + } + + if (m_Zoomable) { + float zoom = ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY); + ret = ret * zoom / 100; + } + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TTextAlign Align) { + if (!m_Sentence) m_Sentence = new CAdSentence(Game); + if (!m_Sentence) return; + + if (m_ForcedTalkAnimName && m_ForcedTalkAnimUsed) { + SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); + m_ForcedTalkAnimUsed = false; + } + + SAFE_DELETE(m_Sentence->m_Sound); + + m_Sentence->SetText(Text); + Game->m_StringTable->Expand(&m_Sentence->m_Text); + m_Sentence->SetStances(Stances); + m_Sentence->m_Duration = Duration; + m_Sentence->m_Align = Align; + m_Sentence->m_StartTime = Game->m_Timer; + m_Sentence->m_CurrentStance = -1; + m_Sentence->m_Font = m_Font == NULL ? Game->m_SystemFont : m_Font; + m_Sentence->m_Freezable = m_Freezable; + + // try to locate speech file automatically + bool DeleteSound = false; + if (!Sound) { + char *Key = Game->m_StringTable->GetKey(Text); + if (Key) { + Sound = ((CAdGame *)Game)->FindSpeechFile(Key); + delete [] Key; + + if (Sound) DeleteSound = true; + } + } + + // load sound and set duration appropriately + if (Sound) { + CBSound *snd = new CBSound(Game); + if (snd && SUCCEEDED(snd->SetSound(Sound, SOUND_SPEECH, true))) { + m_Sentence->SetSound(snd); + if (m_Sentence->m_Duration <= 0) { + uint32 Length = snd->GetLength(); + if (Length != 0) m_Sentence->m_Duration = Length; + } + } else delete snd; + } + + // set duration by text length + if (m_Sentence->m_Duration <= 0) { + m_Sentence->m_Duration = MAX(1000, Game->m_SubtitlesSpeed * strlen(m_Sentence->m_Text)); + } + + + int x, y, width, height; + + x = m_PosX; + y = m_PosY; + + if (!m_SceneIndependent && m_SubtitlesModRelative) { + x -= ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); + y -= ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + } + + + if (m_SubtitlesWidth > 0) width = m_SubtitlesWidth; + else { + if ((x < Game->m_Renderer->m_Width / 4 || x > Game->m_Renderer->m_Width * 0.75) && !Game->m_TouchInterface) { + width = std::max(Game->m_Renderer->m_Width / 4, std::min(x * 2, (Game->m_Renderer->m_Width - x) * 2)); + } else width = Game->m_Renderer->m_Width / 2; + } + + height = m_Sentence->m_Font->GetTextHeight((byte *)m_Sentence->m_Text, width); + + y = y - height - GetHeight() - 5; + if (m_SubtitlesModRelative) { + x += m_SubtitlesModX; + y += m_SubtitlesModY; + } else { + x = m_SubtitlesModX; + y = m_SubtitlesModY; + } + if (m_SubtitlesModXCenter) + x = x - width / 2; + + + x = std::min(std::max(0, x), Game->m_Renderer->m_Width - width); + y = std::min(std::max(0, y), Game->m_Renderer->m_Height - height); + + m_Sentence->m_Width = width; + + + m_Sentence->m_Pos.x = x; + m_Sentence->m_Pos.y = y; + + + if (m_SubtitlesModRelative) { + m_Sentence->m_Pos.x += ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); + m_Sentence->m_Pos.y += ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + } + + m_Sentence->m_FixedPos = !m_SubtitlesModRelative; + + + m_Sentence->SetupTalkFile(Sound); + + m_State = STATE_TALKING; + + if (DeleteSound) delete [] Sound; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Reset() { + if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL) { + SAFE_DELETE(m_AnimSprite); + } else if (m_State == STATE_TALKING && m_Sentence) { + m_Sentence->Finish(); + } + + m_State = m_NextState = STATE_READY; + + Game->m_ScEngine->ResetObject(this); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_BlockRegion)); + PersistMgr->Transfer(TMEMBER(m_CurrentBlockRegion)); + PersistMgr->Transfer(TMEMBER(m_CurrentWptGroup)); + PersistMgr->Transfer(TMEMBER(m_CurrentSprite)); + PersistMgr->Transfer(TMEMBER(m_Drawn)); + PersistMgr->Transfer(TMEMBER(m_Font)); + PersistMgr->Transfer(TMEMBER(m_IgnoreItems)); + PersistMgr->Transfer(TMEMBER_INT(m_NextState)); + PersistMgr->Transfer(TMEMBER(m_Sentence)); + PersistMgr->Transfer(TMEMBER_INT(m_State)); + PersistMgr->Transfer(TMEMBER(m_AnimSprite)); + PersistMgr->Transfer(TMEMBER(m_SceneIndependent)); + PersistMgr->Transfer(TMEMBER(m_ForcedTalkAnimName)); + PersistMgr->Transfer(TMEMBER(m_ForcedTalkAnimUsed)); + PersistMgr->Transfer(TMEMBER(m_TempSprite2)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(m_WptGroup)); + PersistMgr->Transfer(TMEMBER(m_StickRegion)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesModRelative)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesModX)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesModY)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesModXCenter)); + PersistMgr->Transfer(TMEMBER(m_SubtitlesWidth)); + PersistMgr->Transfer(TMEMBER(m_Inventory)); + PersistMgr->Transfer(TMEMBER(m_PartEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(m_CurrentRegions[i])); + + m_AttachmentsPre.Persist(PersistMgr); + m_AttachmentsPost.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_RegisterAlias)); + + PersistMgr->Transfer(TMEMBER(m_PartFollowParent)); + PersistMgr->Transfer(TMEMBER(m_PartOffsetX)); + PersistMgr->Transfer(TMEMBER(m_PartOffsetY)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateSounds() { + if (m_Sentence && m_Sentence->m_Sound) + UpdateOneSound(m_Sentence->m_Sound); + + return CBObject::UpdateSounds(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ResetSoundPan() { + if (m_Sentence && m_Sentence->m_Sound) { + m_Sentence->m_Sound->SetPan(0.0f); + } + return CBObject::ResetSoundPan(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::GetExtendedFlag(char *FlagName) { + if (!FlagName) return false; + else if (strcmp(FlagName, "usable") == 0) return true; + + else return CBObject::GetExtendedFlag(FlagName); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + if (m_BlockRegion) m_BlockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); + if (m_WptGroup) m_WptGroup->SaveAsText(Buffer, Indent + 2); + + CBBase::SaveAsText(Buffer, Indent + 2); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateBlockRegion() { + CAdGame *AdGame = (CAdGame *)Game; + if (AdGame->m_Scene) { + if (m_BlockRegion && m_CurrentBlockRegion) + m_CurrentBlockRegion->Mimic(m_BlockRegion, m_Zoomable ? AdGame->m_Scene->GetScaleAt(m_PosY) : 100.0f, m_PosX, m_PosY); + + if (m_WptGroup && m_CurrentWptGroup) + m_CurrentWptGroup->Mimic(m_WptGroup, m_Zoomable ? AdGame->m_Scene->GetScaleAt(m_PosY) : 100.0f, m_PosX, m_PosY); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdInventory *CAdObject::GetInventory() { + if (!m_Inventory) { + m_Inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(m_Inventory); + } + return m_Inventory; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::AfterMove() { + CAdRegion *NewRegions[MAX_NUM_REGIONS]; + + ((CAdGame *)Game)->m_Scene->GetRegionsAt(m_PosX, m_PosY, NewRegions, MAX_NUM_REGIONS); + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (!NewRegions[i]) break; + bool RegFound = false; + for (int j = 0; j < MAX_NUM_REGIONS; j++) { + if (m_CurrentRegions[j] == NewRegions[i]) { + m_CurrentRegions[j] = NULL; + RegFound = true; + break; + } + } + if (!RegFound) NewRegions[i]->ApplyEvent("ActorEntry"); + } + + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (m_CurrentRegions[i] && Game->ValidObject(m_CurrentRegions[i])) { + m_CurrentRegions[i]->ApplyEvent("ActorLeave"); + } + m_CurrentRegions[i] = NewRegions[i]; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::InvalidateCurrRegions() { + for (int i = 0; i < MAX_NUM_REGIONS; i++) m_CurrentRegions[i] = NULL; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { + if (m_Zoomable) { + if (m_ScaleX >= 0 || m_ScaleY >= 0) { + *ScaleX = m_ScaleX < 0 ? 100 : m_ScaleX; + *ScaleY = m_ScaleY < 0 ? 100 : m_ScaleY; + } else if (m_Scale >= 0) *ScaleX = *ScaleY = m_Scale; + else *ScaleX = *ScaleY = ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) + m_RelativeScale; + } else { + *ScaleX = *ScaleY = 100; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateSpriteAttachments() { + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + m_AttachmentsPre[i]->Update(); + } + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + m_AttachmentsPost[i]->Update(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { + if (PreDisplay) { + for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { + DisplaySpriteAttachment(m_AttachmentsPre[i]); + } + } else { + for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { + DisplaySpriteAttachment(m_AttachmentsPost[i]); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { + if (!Attachment->m_Active) return S_OK; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + int OrigX = Attachment->m_PosX; + int OrigY = Attachment->m_PosY; + + // inherit position from owner + Attachment->m_PosX = this->m_PosX + Attachment->m_PosX * ScaleX / 100.0f; + Attachment->m_PosY = this->m_PosY + Attachment->m_PosY * ScaleY / 100.0f; + + // inherit other props + Attachment->m_AlphaColor = this->m_AlphaColor; + Attachment->m_BlendMode = this->m_BlendMode; + + Attachment->m_Scale = this->m_Scale; + Attachment->m_RelativeScale = this->m_RelativeScale; + Attachment->m_ScaleX = this->m_ScaleX; + Attachment->m_ScaleY = this->m_ScaleY; + + Attachment->m_Rotate = this->m_Rotate; + Attachment->m_RelativeRotate = this->m_RelativeRotate; + Attachment->m_RotateValid = this->m_RotateValid; + + Attachment->m_RegisterAlias = this; + Attachment->m_Registrable = this->m_Registrable; + + HRESULT ret = Attachment->Display(); + + Attachment->m_PosX = OrigX; + Attachment->m_PosY = OrigY; + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { + m_PartFollowParent = FollowParent; + m_PartOffsetX = OffsetX; + m_PartOffsetY = OffsetY; + + if (!m_PartEmitter) { + m_PartEmitter = new CPartEmitter(Game, this); + if (m_PartEmitter) { + Game->RegisterObject(m_PartEmitter); + } + } + UpdatePartEmitter(); + return m_PartEmitter; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdatePartEmitter() { + if (!m_PartEmitter) return E_FAIL; + + if (m_PartFollowParent) { + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + m_PartEmitter->m_PosX = m_PosX + (ScaleX / 100.0f) * m_PartOffsetX; + m_PartEmitter->m_PosY = m_PosY + (ScaleY / 100.0f) * m_PartOffsetY; + } + return m_PartEmitter->Update(); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdPath.cpp b/engines/wintermute/AdPath.cpp new file mode 100644 index 0000000000..fb95f28450 --- /dev/null +++ b/engines/wintermute/AdPath.cpp @@ -0,0 +1,112 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdPath.h" +#include "BPoint.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPath, false) + +////////////////////////////////////////////////////////////////////////// +CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { + m_CurrIndex = -1; + m_Ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPath::~CAdPath() { + Reset(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::Reset() { + for (int i = 0; i < m_Points.GetSize(); i++) + delete m_Points[i]; + + m_Points.RemoveAll(); + m_CurrIndex = -1; + m_Ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetFirst() { + if (m_Points.GetSize() > 0) { + m_CurrIndex = 0; + return m_Points[m_CurrIndex]; + } else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetNext() { + m_CurrIndex++; + if (m_CurrIndex < m_Points.GetSize()) return m_Points[m_CurrIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetCurrent() { + if (m_CurrIndex >= 0 && m_CurrIndex < m_Points.GetSize()) return m_Points[m_CurrIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::AddPoint(CBPoint *point) { + m_Points.Add(point); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::SetReady(bool ready) { + bool orig = m_Ready; + m_Ready = ready; + + return orig; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdPath::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(m_CurrIndex)); + m_Points.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_Ready)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdPath.h b/engines/wintermute/AdPath.h new file mode 100644 index 0000000000..a5424fcd70 --- /dev/null +++ b/engines/wintermute/AdPath.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdPath_H__ +#define __WmeAdPath_H__ + +#include "persistent.h" +#include "coll_templ.h" +#include "BBase.h" + +namespace WinterMute { +class CBPoint; +class CAdPath : public CBBase { +public: + DECLARE_PERSISTENT(CAdPath, CBBase) + CBPoint *GetCurrent(); + bool SetReady(bool ready = true); + void AddPoint(CBPoint *point); + CBPoint *GetNext(); + CBPoint *GetFirst(); + void Reset(); + CAdPath(CBGame *inGame); + virtual ~CAdPath(); + CBArray m_Points; + int m_CurrIndex; + bool m_Ready; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdPathPoint.cpp b/engines/wintermute/AdPathPoint.cpp new file mode 100644 index 0000000000..3bffcd4c73 --- /dev/null +++ b/engines/wintermute/AdPathPoint.cpp @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "AdPathPoint.h" +#include "BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPathPoint, false) + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint() { + x = y = 0; + m_Distance = 0; + + m_Marked = false; + m_Origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { + x = initX; + y = initY; + m_Distance = initDistance; + + m_Marked = false; + m_Origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::~CAdPathPoint() { + m_Origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdPathPoint::Persist(CBPersistMgr *PersistMgr) { + + CBPoint::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Distance)); + PersistMgr->Transfer(TMEMBER(m_Marked)); + PersistMgr->Transfer(TMEMBER(m_Origin)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdPathPoint.h b/engines/wintermute/AdPathPoint.h new file mode 100644 index 0000000000..0196f42701 --- /dev/null +++ b/engines/wintermute/AdPathPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdPathPoint_H__ +#define __WmeAdPathPoint_H__ + +#include "persistent.h" +#include "BPoint.h" + +namespace WinterMute { + +class CAdPathPoint : public CBPoint { +public: + DECLARE_PERSISTENT(CAdPathPoint, CBPoint) + CAdPathPoint(int initX, int initY, int initDistance); + CAdPathPoint(); + virtual ~CAdPathPoint(); + CAdPathPoint *m_Origin; + bool m_Marked; + int m_Distance; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp new file mode 100644 index 0000000000..71a36cf636 --- /dev/null +++ b/engines/wintermute/AdRegion.cpp @@ -0,0 +1,394 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdRegion.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "ScScript.h" +#include "BGame.h" +#include "BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRegion, false) + +////////////////////////////////////////////////////////////////////////// +CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { + m_Blocked = false; + m_Decoration = false; + m_Zoom = 0; + m_Alpha = 0xFFFFFFFF; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRegion::~CAdRegion() { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(ZOOM) +TOKEN_DEF(SCALE) +TOKEN_DEF(BLOCKED) +TOKEN_DEF(DECORATION) +TOKEN_DEF(POINT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(ZOOM) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(BLOCKED) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(POINT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + Game->LOG(0, "'REGION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int i; + + for (i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; + m_Points.RemoveAll(); + + int ar = 255, ag = 255, ab = 255, alpha = 255; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &m_Active); + break; + + case TOKEN_BLOCKED: + parser.ScanStr((char *)params, "%b", &m_Blocked); + break; + + case TOKEN_DECORATION: + parser.ScanStr((char *)params, "%b", &m_Decoration); + break; + + case TOKEN_ZOOM: + case TOKEN_SCALE: { + int i; + parser.ScanStr((char *)params, "%d", &i); + m_Zoom = (float)i; + } + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + m_Points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &m_EditorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in REGION definition"); + return E_FAIL; + } + + CreateRegion(); + + m_Alpha = DRGBA(ar, ag, ab, alpha); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + /* + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "SkipTo")==0){ + Stack->CorrectParams(2); + m_PosX = Stack->Pop()->GetInt(); + m_PosY = Stack->Pop()->GetInt(); + Stack->PushNULL(); + + return S_OK; + } + + else*/ return CBRegion::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdRegion::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("ad region"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + m_ScValue->SetString(m_Name); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Blocked") == 0) { + m_ScValue->SetBool(m_Blocked); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + m_ScValue->SetBool(m_Decoration); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + m_ScValue->SetFloat(m_Zoom); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + m_ScValue->SetInt((int)m_Alpha); + return m_ScValue; + } + + else return CBRegion::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Blocked") == 0) { + m_Blocked = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + m_Decoration = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + m_Zoom = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + m_Alpha = (uint32)Value->GetInt(); + return S_OK; + } + + else return CBRegion::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdRegion::ScToString() { + return "[ad region]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "REGION {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", m_Blocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", m_Decoration ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)m_Zoom); + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_Alpha), D3DCOLGetG(m_Alpha), D3DCOLGetB(m_Alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_Alpha)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + + int i; + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + + for (i = 0; i < m_Points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::Persist(CBPersistMgr *PersistMgr) { + CBRegion::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Alpha)); + PersistMgr->Transfer(TMEMBER(m_Blocked)); + PersistMgr->Transfer(TMEMBER(m_Decoration)); + PersistMgr->Transfer(TMEMBER(m_Zoom)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h new file mode 100644 index 0000000000..61bb4d2a58 --- /dev/null +++ b/engines/wintermute/AdRegion.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdRegion_H__ +#define __WmeAdRegion_H__ + +#include "BRegion.h" + +namespace WinterMute { + +class CAdRegion : public CBRegion { +public: + DECLARE_PERSISTENT(CAdRegion, CBRegion) + uint32 m_Alpha; + float m_Zoom; + bool m_Blocked; + bool m_Decoration; + CAdRegion(CBGame *inGame); + virtual ~CAdRegion(); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdResponse.cpp b/engines/wintermute/AdResponse.cpp new file mode 100644 index 0000000000..e9a84b4bd4 --- /dev/null +++ b/engines/wintermute/AdResponse.cpp @@ -0,0 +1,143 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdResponse.h" +#include "BGame.h" +#include "BFontStorage.h" +#include "BSprite.h" +#include "utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponse, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { + m_Text = NULL; + m_TextOrig = NULL; + m_Icon = m_IconHover = m_IconPressed = NULL; + m_Font = NULL; + m_ID = 0; + m_ResponseType = RESPONSE_ALWAYS; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponse::~CAdResponse() { + delete[] m_Text; + delete[] m_TextOrig; + delete m_Icon; + delete m_IconHover; + delete m_IconPressed; + m_Text = NULL; + m_TextOrig = NULL; + m_Icon = NULL; + m_IconHover = NULL; + m_IconPressed = NULL; + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponse::SetText(char *Text) { + CBUtils::SetString(&m_Text, Text); + CBUtils::SetString(&m_TextOrig, Text); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIcon(char *Filename) { + delete m_Icon; + m_Icon = new CBSprite(Game); + if (!m_Icon || FAILED(m_Icon->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); + delete m_Icon; + m_Icon = NULL; + return E_FAIL; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetFont(char *Filename) { + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont(Filename); + if (!m_Font) { + Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", Filename); + return E_FAIL; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIconHover(char *Filename) { + delete m_IconHover; + m_IconHover = new CBSprite(Game); + if (!m_IconHover || FAILED(m_IconHover->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); + delete m_IconHover; + m_IconHover = NULL; + return E_FAIL; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIconPressed(char *Filename) { + delete m_IconPressed; + m_IconPressed = new CBSprite(Game); + if (!m_IconPressed || FAILED(m_IconPressed->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); + delete m_IconPressed; + m_IconPressed = NULL; + return E_FAIL; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Icon)); + PersistMgr->Transfer(TMEMBER(m_IconHover)); + PersistMgr->Transfer(TMEMBER(m_IconPressed)); + PersistMgr->Transfer(TMEMBER(m_ID)); + PersistMgr->Transfer(TMEMBER(m_Text)); + PersistMgr->Transfer(TMEMBER(m_TextOrig)); + PersistMgr->Transfer(TMEMBER_INT(m_ResponseType)); + PersistMgr->Transfer(TMEMBER(m_Font)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h new file mode 100644 index 0000000000..5c529f4b81 --- /dev/null +++ b/engines/wintermute/AdResponse.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdResponse_H__ +#define __WmeAdResponse_H__ + + +#include "BObject.h" +#include "AdTypes.h" + +namespace WinterMute { +class CBFont; +class CAdResponse : public CBObject { +public: + DECLARE_PERSISTENT(CAdResponse, CBObject) + HRESULT SetIcon(char *Filename); + HRESULT SetFont(char *Filename); + HRESULT SetIconHover(char *Filename); + HRESULT SetIconPressed(char *Filename); + void SetText(char *Text); + int m_ID; + CBSprite *m_Icon; + CBSprite *m_IconHover; + CBSprite *m_IconPressed; + CBFont *m_Font; + char *m_Text; + char *m_TextOrig; + CAdResponse(CBGame *inGame); + virtual ~CAdResponse(); + TResponseType m_ResponseType; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp new file mode 100644 index 0000000000..ff4407fcfc --- /dev/null +++ b/engines/wintermute/AdResponseBox.cpp @@ -0,0 +1,631 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdGame.h" +#include "AdResponseBox.h" +#include "BParser.h" +#include "BSurfaceStorage.h" +#include "UIButton.h" +#include "UIWindow.h" +#include "BDynBuffer.h" +#include "BFontStorage.h" +#include "BFont.h" +#include "AdResponse.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BSprite.h" +#include "BFileManager.h" +#include "utils.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { + m_Font = m_FontHover = NULL; + + m_Window = NULL; + m_ShieldWindow = new CUIWindow(Game); + + m_Horizontal = false; + CBPlatform::SetRectEmpty(&m_ResponseArea); + m_ScrollOffset = 0; + m_Spacing = 0; + + m_WaitingScript = NULL; + m_LastResponseText = NULL; + m_LastResponseTextOrig = NULL; + + m_VerticalAlign = VAL_BOTTOM; + m_Align = TAL_LEFT; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::~CAdResponseBox() { + + SAFE_DELETE(m_Window); + SAFE_DELETE(m_ShieldWindow); + SAFE_DELETE_ARRAY(m_LastResponseText); + SAFE_DELETE_ARRAY(m_LastResponseTextOrig); + + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + + ClearResponses(); + ClearButtons(); + + m_WaitingScript = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::ClearResponses() { + for (int i = 0; i < m_Responses.GetSize(); i++) { + delete m_Responses[i]; + } + m_Responses.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::ClearButtons() { + for (int i = 0; i < m_RespButtons.GetSize(); i++) { + delete m_RespButtons[i]; + } + m_RespButtons.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::InvalidateButtons() { + for (int i = 0; i < m_RespButtons.GetSize(); i++) { + m_RespButtons[i]->m_Image = NULL; + m_RespButtons[i]->m_Cursor = NULL; + m_RespButtons[i]->m_Font = NULL; + m_RespButtons[i]->m_FontHover = NULL; + m_RespButtons[i]->m_FontPress = NULL; + m_RespButtons[i]->SetText(""); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::CreateButtons() { + ClearButtons(); + + m_ScrollOffset = 0; + for (int i = 0; i < m_Responses.GetSize(); i++) { + CUIButton *btn = new CUIButton(Game); + if (btn) { + btn->m_Parent = m_Window; + btn->m_SharedFonts = btn->m_SharedImages = true; + btn->m_SharedCursors = true; + // iconic + if (m_Responses[i]->m_Icon) { + btn->m_Image = m_Responses[i]->m_Icon; + if (m_Responses[i]->m_IconHover) btn->m_ImageHover = m_Responses[i]->m_IconHover; + if (m_Responses[i]->m_IconPressed) btn->m_ImagePress = m_Responses[i]->m_IconPressed; + + btn->SetCaption(m_Responses[i]->m_Text); + if (m_Cursor) btn->m_Cursor = m_Cursor; + else if (Game->m_ActiveCursor) btn->m_Cursor = Game->m_ActiveCursor; + } + // textual + else { + btn->SetText(m_Responses[i]->m_Text); + btn->m_Font = (m_Font == NULL) ? Game->m_SystemFont : m_Font; + btn->m_FontHover = (m_FontHover == NULL) ? Game->m_SystemFont : m_FontHover; + btn->m_FontPress = btn->m_FontHover; + btn->m_Align = m_Align; + + if (Game->m_TouchInterface) + btn->m_FontHover = btn->m_Font; + + + if (m_Responses[i]->m_Font) btn->m_Font = m_Responses[i]->m_Font; + + btn->m_Width = m_ResponseArea.right - m_ResponseArea.left; + if (btn->m_Width <= 0) btn->m_Width = Game->m_Renderer->m_Width; + } + btn->SetName("response"); + btn->CorrectSize(); + + // make the responses touchable + if (Game->m_TouchInterface) + btn->m_Height = std::max(btn->m_Height, 50); + + //btn->SetListener(this, btn, m_Responses[i]->m_ID); + btn->SetListener(this, btn, i); + btn->m_Visible = false; + m_RespButtons.Add(btn); + + if (m_ResponseArea.bottom - m_ResponseArea.top < btn->m_Height) { + Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", m_Responses[i]->m_Text); + m_ResponseArea.bottom += (btn->m_Height - (m_ResponseArea.bottom - m_ResponseArea.top)); + } + } + } + m_Ready = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT) +TOKEN_DEF(AREA) +TOKEN_DEF(HORIZONTAL) +TOKEN_DEF(SPACING) +TOKEN_DEF(WINDOW) +TOKEN_DEF(CURSOR) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT) + TOKEN_TABLE(AREA) + TOKEN_TABLE(HORIZONTAL) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + Game->LOG(0, "'RESPONSE_BOX' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_WINDOW: + SAFE_DELETE(m_Window); + m_Window = new CUIWindow(Game); + if (!m_Window || FAILED(m_Window->LoadBuffer(params, false))) { + SAFE_DELETE(m_Window); + cmd = PARSERR_GENERIC; + } else if (m_ShieldWindow) m_ShieldWindow->m_Parent = m_Window; + break; + + case TOKEN_FONT: + if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + m_Font = Game->m_FontStorage->AddFont((char *)params); + if (!m_Font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + m_FontHover = Game->m_FontStorage->AddFont((char *)params); + if (!m_FontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AREA: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_ResponseArea.left, &m_ResponseArea.top, &m_ResponseArea.right, &m_ResponseArea.bottom); + break; + + case TOKEN_HORIZONTAL: + parser.ScanStr((char *)params, "%b", &m_Horizontal); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "center") == 0) m_Align = TAL_CENTER; + else if (scumm_stricmp((char *)params, "right") == 0) m_Align = TAL_RIGHT; + else m_Align = TAL_LEFT; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) m_VerticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "center") == 0) m_VerticalAlign = VAL_CENTER; + else m_VerticalAlign = VAL_BOTTOM; + break; + + case TOKEN_SPACING: + parser.ScanStr((char *)params, "%d", &m_Spacing); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_CURSOR: + SAFE_DELETE(m_Cursor); + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + SAFE_DELETE(m_Cursor); + cmd = PARSERR_GENERIC; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in RESPONSE_BOX definition"); + return E_FAIL; + } + + if (m_Window) { + for (int i = 0; i < m_Window->m_Widgets.GetSize(); i++) { + if (!m_Window->m_Widgets[i]->m_ListenerObject) + m_Window->m_Widgets[i]->SetListener(this, m_Window->m_Widgets[i], 0); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", m_ResponseArea.left, m_ResponseArea.top, m_ResponseArea.right, m_ResponseArea.bottom); + + if (m_Font && m_Font->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (m_FontHover && m_FontHover->m_Filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", m_FontHover->m_Filename); + + if (m_Cursor && m_Cursor->m_Filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + + Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", m_Horizontal ? "TRUE" : "FALSE"); + + switch (m_Align) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + } + + switch (m_VerticalAlign) { + case VAL_TOP: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + } + + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", m_Spacing); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // window + if (m_Window) m_Window->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Display() { + RECT rect = m_ResponseArea; + if (m_Window) { + CBPlatform::OffsetRect(&rect, m_Window->m_PosX, m_Window->m_PosY); + //m_Window->Display(); + } + + int xxx, yyy, i; + + xxx = rect.left; + yyy = rect.top; + + // shift down if needed + if (!m_Horizontal) { + int total_height = 0; + for (i = 0; i < m_RespButtons.GetSize(); i++) total_height += (m_RespButtons[i]->m_Height + m_Spacing); + total_height -= m_Spacing; + + switch (m_VerticalAlign) { + case VAL_BOTTOM: + if (yyy + total_height < rect.bottom) + yyy = rect.bottom - total_height; + break; + + case VAL_CENTER: + if (yyy + total_height < rect.bottom) + yyy += ((rect.bottom - rect.top) - total_height) / 2; + break; + + case VAL_TOP: + // do nothing + break; + } + } + + // prepare response buttons + bool scroll_needed = false; + for (i = m_ScrollOffset; i < m_RespButtons.GetSize(); i++) { + if ((m_Horizontal && xxx + m_RespButtons[i]->m_Width > rect.right) + || (!m_Horizontal && yyy + m_RespButtons[i]->m_Height > rect.bottom)) { + + scroll_needed = true; + m_RespButtons[i]->m_Visible = false; + break; + } + + m_RespButtons[i]->m_Visible = true; + m_RespButtons[i]->m_PosX = xxx; + m_RespButtons[i]->m_PosY = yyy; + + if (m_Horizontal) { + xxx += (m_RespButtons[i]->m_Width + m_Spacing); + } else { + yyy += (m_RespButtons[i]->m_Height + m_Spacing); + } + } + + // show appropriate scroll buttons + if (m_Window) { + m_Window->ShowWidget("prev", m_ScrollOffset > 0); + m_Window->ShowWidget("next", scroll_needed); + } + + // go exclusive + if (m_ShieldWindow) { + m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; + m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; + m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; + + m_ShieldWindow->Display(); + } + + // display window + if (m_Window) m_Window->Display(); + + + // display response buttons + for (i = m_ScrollOffset; i < m_RespButtons.GetSize(); i++) { + m_RespButtons[i]->Display(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->m_Type) { + case UI_BUTTON: + if (scumm_stricmp(obj->m_Name, "prev") == 0) { + m_ScrollOffset--; + } else if (scumm_stricmp(obj->m_Name, "next") == 0) { + m_ScrollOffset++; + } else if (scumm_stricmp(obj->m_Name, "response") == 0) { + if (m_WaitingScript) m_WaitingScript->m_Stack->PushInt(m_Responses[param2]->m_ID); + HandleResponse(m_Responses[param2]); + m_WaitingScript = NULL; + Game->m_State = GAME_RUNNING; + ((CAdGame *)Game)->m_StateEx = GAME_NORMAL; + m_Ready = true; + InvalidateButtons(); + ClearResponses(); + } else return CBObject::Listen(param1, param2); + break; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Font)); + PersistMgr->Transfer(TMEMBER(m_FontHover)); + PersistMgr->Transfer(TMEMBER(m_Horizontal)); + PersistMgr->Transfer(TMEMBER(m_LastResponseText)); + PersistMgr->Transfer(TMEMBER(m_LastResponseTextOrig)); + m_RespButtons.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_ResponseArea)); + m_Responses.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); + PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); + PersistMgr->Transfer(TMEMBER(m_Spacing)); + PersistMgr->Transfer(TMEMBER(m_WaitingScript)); + PersistMgr->Transfer(TMEMBER(m_Window)); + + PersistMgr->Transfer(TMEMBER_INT(m_VerticalAlign)); + PersistMgr->Transfer(TMEMBER_INT(m_Align)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::WeedResponses() { + CAdGame *AdGame = (CAdGame *)Game; + + for (int i = 0; i < m_Responses.GetSize(); i++) { + switch (m_Responses[i]->m_ResponseType) { + case RESPONSE_ONCE: + if (AdGame->BranchResponseUsed(m_Responses[i]->m_ID)) { + delete m_Responses[i]; + m_Responses.RemoveAt(i); + i--; + } + break; + + case RESPONSE_ONCE_GAME: + if (AdGame->GameResponseUsed(m_Responses[i]->m_ID)) { + delete m_Responses[i]; + m_Responses.RemoveAt(i); + i--; + } + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::SetLastResponseText(char *Text, char *TextOrig) { + CBUtils::SetString(&m_LastResponseText, Text); + CBUtils::SetString(&m_LastResponseTextOrig, TextOrig); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { + SetLastResponseText(Response->m_Text, Response->m_TextOrig); + + CAdGame *AdGame = (CAdGame *)Game; + + switch (Response->m_ResponseType) { + case RESPONSE_ONCE: + AdGame->AddBranchResponse(Response->m_ID); + break; + + case RESPONSE_ONCE_GAME: + AdGame->AddGameResponse(Response->m_ID); + break; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::GetNextAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = 0; i < Objects.GetSize(); i++) { + if (Objects[i] == CurrObject) { + if (i < Objects.GetSize() - 1) return Objects[i + 1]; + else break; + } + } + } + return Objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = Objects.GetSize() - 1; i >= 0; i--) { + if (Objects[i] == CurrObject) { + if (i > 0) return Objects[i - 1]; + else break; + } + } + } + return Objects[Objects.GetSize() - 1]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::GetObjects(CBArray& Objects, bool InteractiveOnly) { + for (int i = 0; i < m_RespButtons.GetSize(); i++) { + Objects.Add(m_RespButtons[i]); + } + if (m_Window) m_Window->GetWindowObjects(Objects, InteractiveOnly); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h new file mode 100644 index 0000000000..6abe9dc1a1 --- /dev/null +++ b/engines/wintermute/AdResponseBox.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdResponseBox_H__ +#define __WmeAdResponseBox_H__ + + +#include "BObject.h" + +namespace WinterMute { + +class CUIButton; +class CUIWindow; +class CUIObject; +class CAdResponse; +class CAdResponseBox : public CBObject { +public: + CBObject *GetNextAccessObject(CBObject *CurrObject); + CBObject *GetPrevAccessObject(CBObject *CurrObject); + HRESULT GetObjects(CBArray& Objects, bool InteractiveOnly); + + HRESULT HandleResponse(CAdResponse *Response); + void SetLastResponseText(char *Text, char *TextOrig); + char *m_LastResponseText; + char *m_LastResponseTextOrig; + DECLARE_PERSISTENT(CAdResponseBox, CBObject) + CScScript *m_WaitingScript; + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + typedef enum { + EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE + } TResponseEvent; + + HRESULT WeedResponses(); + HRESULT Display(); + int m_Spacing; + int m_ScrollOffset; + CBFont *m_FontHover; + CBFont *m_Font; + HRESULT CreateButtons(); + HRESULT InvalidateButtons(); + void ClearButtons(); + void ClearResponses(); + CAdResponseBox(CBGame *inGame); + virtual ~CAdResponseBox(); + CBArray m_Responses; + CBArray m_RespButtons; + CUIWindow *m_Window; + CUIWindow *m_ShieldWindow; + bool m_Horizontal; + RECT m_ResponseArea; + int m_VerticalAlign; + TTextAlign m_Align; + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdResponseContext.cpp b/engines/wintermute/AdResponseContext.cpp new file mode 100644 index 0000000000..1e6fad4967 --- /dev/null +++ b/engines/wintermute/AdResponseContext.cpp @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdResponseContext.h" +#include "BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseContext, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { + m_ID = 0; + m_Context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::~CAdResponseContext() { + delete[] m_Context; + m_Context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(m_Context)); + PersistMgr->Transfer(TMEMBER(m_ID)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdResponseContext::SetContext(char *Context) { + delete[] m_Context; + m_Context = NULL; + if (Context) { + m_Context = new char [strlen(Context) + 1]; + if (m_Context) strcpy(m_Context, Context); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h new file mode 100644 index 0000000000..de3e8c95fa --- /dev/null +++ b/engines/wintermute/AdResponseContext.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdResponseContext_H__ +#define __WmeAdResponseContext_H__ + +#include "persistent.h" +#include "BBase.h" + +namespace WinterMute { + +class CAdResponseContext : public CBBase { +public: + void SetContext(char *Context); + int m_ID; + char *m_Context; + DECLARE_PERSISTENT(CAdResponseContext, CBBase) + CAdResponseContext(CBGame *inGame); + virtual ~CAdResponseContext(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdRotLevel.cpp b/engines/wintermute/AdRotLevel.cpp new file mode 100644 index 0000000000..11bdb4dba0 --- /dev/null +++ b/engines/wintermute/AdRotLevel.cpp @@ -0,0 +1,159 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdRotLevel.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "BGame.h" +#include "BSprite.h" +#include "BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRotLevel, false) + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { + m_PosX = 0; + m_Rotation = 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::~CAdRotLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(X) +TOKEN_DEF(ROTATION) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(X) + TOKEN_TABLE(ROTATION) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &m_PosX); + break; + + case TOKEN_ROTATION: { + int i; + parser.ScanStr((char *)params, "%d", &i); + m_Rotation = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ROTATION_LEVEL definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); + Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)m_Rotation); + CBBase::SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Rotation)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h new file mode 100644 index 0000000000..91ddbef641 --- /dev/null +++ b/engines/wintermute/AdRotLevel.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdRotLevel_H__ +#define __WmeAdRotLevel_H__ + +#include "BObject.h" + +namespace WinterMute { + +class CAdRotLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdRotLevel, CBObject) + CAdRotLevel(CBGame *inGame); + virtual ~CAdRotLevel(); + float m_Rotation; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdScaleLevel.cpp b/engines/wintermute/AdScaleLevel.cpp new file mode 100644 index 0000000000..09c4a78062 --- /dev/null +++ b/engines/wintermute/AdScaleLevel.cpp @@ -0,0 +1,157 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdScaleLevel.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "BGame.h" +#include "BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScaleLevel, false) + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { + m_PosY = 0; + m_Scale = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::~CAdScaleLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(Y) +TOKEN_DEF(SCALE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(Y) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + Game->LOG(0, "'SCALE_LEVEL' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &m_PosY); + break; + + case TOKEN_SCALE: { + int i; + parser.ScanStr((char *)params, "%d", &i); + m_Scale = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SCALE_LEVEL definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)m_Scale); + CBBase::SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Scale)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h new file mode 100644 index 0000000000..5fe1cafa6b --- /dev/null +++ b/engines/wintermute/AdScaleLevel.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdScaleLevel_H__ +#define __WmeAdScaleLevel_H__ + + +#include "BObject.h" + +namespace WinterMute { + +class CAdScaleLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdScaleLevel, CBObject) + float m_Scale; + CAdScaleLevel(CBGame *inGame); + virtual ~CAdScaleLevel(); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp new file mode 100644 index 0000000000..3fb13f5d61 --- /dev/null +++ b/engines/wintermute/AdScene.cpp @@ -0,0 +1,2760 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "AdScene.h" +#include "AdActor.h" +#include "AdEntity.h" +#include "AdGame.h" +#include "AdLayer.h" +#include "AdNodeState.h" +#include "AdObject.h" +#include "AdPath.h" +#include "AdPathPoint.h" +#include "AdRotLevel.h" +#include "AdScaleLevel.h" +#include "AdSceneNode.h" +#include "AdSceneState.h" +#include "AdSentence.h" +#include "AdWaypointGroup.h" +#include "BDynBuffer.h" +#include "BFileManager.h" +#include "BFont.h" +#include "BGame.h" +#include "BObject.h" +#include "BParser.h" +#include "BPoint.h" +#include "BRegion.h" +#include "BScriptable.h" +#include "BSprite.h" +#include "BViewport.h" +#include "PlatformSDL.h" +#include "ScStack.h" +#include "ScValue.h" +#include "ScScript.h" +#include "UIWindow.h" +#include "utils.h" +#include +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScene, false) + +////////////////////////////////////////////////////////////////////////// +CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { + m_PFTarget = new CBPoint; + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdScene::~CAdScene() { + Cleanup(); + Game->UnregisterObject(m_Fader); + delete m_PFTarget; + m_PFTarget = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SetDefaults() { + m_Initialized = false; + m_PFReady = true; + m_PFTargetPath = NULL; + m_PFRequester = NULL; + m_MainLayer = NULL; + + m_PFPointsNum = 0; + m_PersistentState = false; + m_PersistentStateSprites = true; + + m_AutoScroll = true; + m_OffsetLeft = m_OffsetTop = 0; + m_TargetOffsetLeft = m_TargetOffsetTop = 0; + + m_LastTimeH = m_LastTimeV = 0; + m_ScrollTimeH = m_ScrollTimeV = 10; + m_ScrollPixelsH = m_ScrollPixelsV = 1; + + m_PFMaxTime = 15; + + m_ParalaxScrolling = true; + + // editor settings + m_EditorMarginH = m_EditorMarginV = 100; + + m_EditorColFrame = 0xE0888888; + m_EditorColEntity = 0xFF008000; + m_EditorColRegion = 0xFF0000FF; + m_EditorColBlocked = 0xFF800080; + m_EditorColWaypoints = 0xFF0000FF; + m_EditorColEntitySel = 0xFFFF0000; + m_EditorColRegionSel = 0xFFFF0000; + m_EditorColBlockedSel = 0xFFFF0000; + m_EditorColWaypointsSel = 0xFFFF0000; + m_EditorColScale = 0xFF00FF00; + m_EditorColDecor = 0xFF00FFFF; + m_EditorColDecorSel = 0xFFFF0000; + + m_EditorShowRegions = true; + m_EditorShowBlocked = true; + m_EditorShowDecor = true; + m_EditorShowEntities = true; + m_EditorShowScale = true; + + m_ShieldWindow = NULL; + + m_Fader = new CBFader(Game); + Game->RegisterObject(m_Fader); + + m_Viewport = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::Cleanup() { + CBObject::Cleanup(); + + m_MainLayer = NULL; // reference only + + int i; + + delete m_ShieldWindow; + m_ShieldWindow = NULL; + + Game->UnregisterObject(m_Fader); + m_Fader = NULL; + + for (i = 0; i < m_Layers.GetSize(); i++) + Game->UnregisterObject(m_Layers[i]); + m_Layers.RemoveAll(); + + + for (i = 0; i < m_WaypointGroups.GetSize(); i++) + Game->UnregisterObject(m_WaypointGroups[i]); + m_WaypointGroups.RemoveAll(); + + for (i = 0; i < m_ScaleLevels.GetSize(); i++) + Game->UnregisterObject(m_ScaleLevels[i]); + m_ScaleLevels.RemoveAll(); + + for (i = 0; i < m_RotLevels.GetSize(); i++) + Game->UnregisterObject(m_RotLevels[i]); + m_RotLevels.RemoveAll(); + + + for (i = 0; i < m_PFPath.GetSize(); i++) + delete m_PFPath[i]; + m_PFPath.RemoveAll(); + m_PFPointsNum = 0; + + for (i = 0; i < m_Objects.GetSize(); i++) + Game->UnregisterObject(m_Objects[i]); + m_Objects.RemoveAll(); + + delete m_Viewport; + m_Viewport = NULL; + + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { + if (!m_PFReady) return false; + else { + m_PFReady = false; + *m_PFTarget = target; + m_PFTargetPath = path; + m_PFRequester = requester; + + m_PFTargetPath->Reset(); + m_PFTargetPath->SetReady(false); + + // prepare working path + int i; + PFPointsStart(); + + // first point + //m_PFPath.Add(new CAdPathPoint(source.x, source.y, 0)); + + // if we're one pixel stuck, get unstuck + int StartX = source.x; + int StartY = source.y; + int BestDistance = 1000; + if (IsBlockedAt(StartX, StartY, true, requester)) { + int Tolerance = 2; + for (int xxx = StartX - Tolerance; xxx <= StartX + Tolerance; xxx++) { + for (int yyy = StartY - Tolerance; yyy <= StartY + Tolerance; yyy++) { + if (IsWalkableAt(xxx, yyy, true, requester)) { + int Distance = abs(xxx - source.x) + abs(yyy - source.y); + if (Distance < BestDistance) { + StartX = xxx; + StartY = yyy; + + BestDistance = Distance; + } + } + } + } + } + + PFPointsAdd(StartX, StartY, 0); + + //CorrectTargetPoint(&target.x, &target.y); + + // last point + //m_PFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); + PFPointsAdd(target.x, target.y, INT_MAX); + + // active waypoints + for (i = 0; i < m_WaypointGroups.GetSize(); i++) { + if (m_WaypointGroups[i]->m_Active) { + PFAddWaypointGroup(m_WaypointGroups[i], requester); + } + } + + + // free waypoints + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && m_Objects[i] != requester && m_Objects[i]->m_CurrentWptGroup) { + PFAddWaypointGroup(m_Objects[i]->m_CurrentWptGroup, requester); + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != requester && AdGame->m_Objects[i]->m_CurrentWptGroup) { + PFAddWaypointGroup(AdGame->m_Objects[i]->m_CurrentWptGroup, requester); + } + } + + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { + if (!Wpt->m_Active) return; + + for (int i = 0; i < Wpt->m_Points.GetSize(); i++) { + if (IsBlockedAt(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, true, Requester)) continue; + + //m_PFPath.Add(new CAdPathPoint(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, INT_MAX)); + PFPointsAdd(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, INT_MAX); + } +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetZoomAt(int X, int Y) { + float ret = 100; + + bool found = false; + if (m_MainLayer) { + for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Blocked && Node->m_Region->PointInRegion(X, Y)) { + if (Node->m_Region->m_Zoom != 0) { + ret = Node->m_Region->m_Zoom; + found = true; + break; + } + } + } + } + if (!found) ret = GetScaleAt(Y); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { + if (!Game->m_DEBUG_DebugMode) ColorCheck = false; + + uint32 ret; + if (ColorCheck) ret = 0xFFFF0000; + else ret = 0xFFFFFFFF; + + if (m_MainLayer) { + for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && (ColorCheck || !Node->m_Region->m_Blocked) && Node->m_Region->PointInRegion(X, Y)) { + if (!Node->m_Region->m_Blocked) ret = Node->m_Region->m_Alpha; + break; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { + bool ret = true; + + + if (CheckFreeObjects) { + int i; + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && m_Objects[i] != Requester && m_Objects[i]->m_CurrentBlockRegion) { + if (m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return true; + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != Requester && AdGame->m_Objects[i]->m_CurrentBlockRegion) { + if (AdGame->m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return true; + } + } + } + + + if (m_MainLayer) { + for (int i = 0; i < m_MainLayer->m_Nodes.GetSize(); i++) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + /* + if(Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->m_Blocked && Node->m_Region->PointInRegion(X, Y)) + { + ret = true; + break; + } + */ + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Decoration && Node->m_Region->PointInRegion(X, Y)) { + if (Node->m_Region->m_Blocked) { + ret = true; + break; + } else ret = false; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { + bool ret = false; + + + if (CheckFreeObjects) { + int i; + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && m_Objects[i] != Requester && m_Objects[i]->m_CurrentBlockRegion) { + if (m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return false; + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != Requester && AdGame->m_Objects[i]->m_CurrentBlockRegion) { + if (AdGame->m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return false; + } + } + } + + + if (m_MainLayer) { + for (int i = 0; i < m_MainLayer->m_Nodes.GetSize(); i++) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Decoration && Node->m_Region->PointInRegion(X, Y)) { + if (Node->m_Region->m_Blocked) { + ret = false; + break; + } else ret = true; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { + double xStep, yStep, X, Y; + int xLength, yLength, xCount, yCount; + int X1, Y1, X2, Y2; + + X1 = p1.x; + Y1 = p1.y; + X2 = p2.x; + Y2 = p2.y; + + xLength = abs(X2 - X1); + yLength = abs(Y2 - Y1); + + if (xLength > yLength) { + if (X1 > X2) { + CBUtils::Swap(&X1, &X2); + CBUtils::Swap(&Y1, &Y2); + } + + yStep = (double)(Y2 - Y1) / (double)(X2 - X1); + Y = Y1; + + for (xCount = X1; xCount < X2; xCount++) { + if (IsBlockedAt(xCount, (int)Y, true, requester)) return -1; + Y += yStep; + } + } else { + if (Y1 > Y2) { + CBUtils::Swap(&X1, &X2); + CBUtils::Swap(&Y1, &Y2); + } + + xStep = (double)(X2 - X1) / (double)(Y2 - Y1); + X = X1; + + for (yCount = Y1; yCount < Y2; yCount++) { + if (IsBlockedAt((int)X, yCount, true, requester)) return -1; + X += xStep; + } + } + return std::max(xLength, yLength); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PathFinderStep() { + int i; + // get lowest unmarked + int lowest_dist = INT_MAX; + CAdPathPoint *lowest_pt = NULL; + + for (i = 0; i < m_PFPointsNum; i++) + if (!m_PFPath[i]->m_Marked && m_PFPath[i]->m_Distance < lowest_dist) { + lowest_dist = m_PFPath[i]->m_Distance; + lowest_pt = m_PFPath[i]; + } + + if (lowest_pt == NULL) { // no path -> terminate PathFinder + m_PFReady = true; + m_PFTargetPath->SetReady(true); + return; + } + + lowest_pt->m_Marked = true; + + // target point marked, generate path and terminate + if (lowest_pt->x == m_PFTarget->x && lowest_pt->y == m_PFTarget->y) { + while (lowest_pt != NULL) { + m_PFTargetPath->m_Points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); + lowest_pt = lowest_pt->m_Origin; + } + + m_PFReady = true; + m_PFTargetPath->SetReady(true); + return; + } + + // otherwise keep on searching + for (i = 0; i < m_PFPointsNum; i++) + if (!m_PFPath[i]->m_Marked) { + int j = GetPointsDist(*lowest_pt, *m_PFPath[i], m_PFRequester); + if (j != -1 && lowest_pt->m_Distance + j < m_PFPath[i]->m_Distance) { + m_PFPath[i]->m_Distance = lowest_pt->m_Distance + j; + m_PFPath[i]->m_Origin = lowest_pt; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::InitLoop() { +#ifdef _DEBUGxxxx + int num_steps = 0; + uint32 start = Game->m_CurrentTime; + while (!m_PFReady && CBPlatform::GetTime() - start <= m_PFMaxTime) { + PathFinderStep(); + num_steps++; + } + if (num_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) m_PFMaxTime=%d", num_steps, m_PFReady ? "finished" : "not yet done", m_PFMaxTime); +#else + uint32 start = Game->m_CurrentTime; + while (!m_PFReady && CBPlatform::GetTime() - start <= m_PFMaxTime) PathFinderStep(); +#endif + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + delete[] m_Filename; + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCENE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(LAYER) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(CAMERA) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(EDITOR_MARGIN_H) +TOKEN_DEF(EDITOR_MARGIN_V) +TOKEN_DEF(EDITOR_COLOR_FRAME) +TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION_SEL) +TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) +TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION) +TOKEN_DEF(EDITOR_COLOR_DECORATION) +TOKEN_DEF(EDITOR_COLOR_BLOCKED) +TOKEN_DEF(EDITOR_COLOR_ENTITY) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) +TOKEN_DEF(EDITOR_COLOR_SCALE) +TOKEN_DEF(EDITOR_SHOW_REGIONS) +TOKEN_DEF(EDITOR_SHOW_BLOCKED) +TOKEN_DEF(EDITOR_SHOW_DECORATION) +TOKEN_DEF(EDITOR_SHOW_ENTITIES) +TOKEN_DEF(EDITOR_SHOW_SCALE) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(VIEWPORT) +TOKEN_DEF(PERSISTENT_STATE_SPRITES) +TOKEN_DEF(PERSISTENT_STATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCENE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(CAMERA) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(EDITOR_MARGIN_H) + TOKEN_TABLE(EDITOR_MARGIN_V) + TOKEN_TABLE(EDITOR_COLOR_FRAME) + TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) + TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION) + TOKEN_TABLE(EDITOR_COLOR_DECORATION) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED) + TOKEN_TABLE(EDITOR_COLOR_ENTITY) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) + TOKEN_TABLE(EDITOR_COLOR_SCALE) + TOKEN_TABLE(EDITOR_SHOW_REGIONS) + TOKEN_TABLE(EDITOR_SHOW_DECORATION) + TOKEN_TABLE(EDITOR_SHOW_BLOCKED) + TOKEN_TABLE(EDITOR_SHOW_ENTITIES) + TOKEN_TABLE(EDITOR_SHOW_SCALE) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(VIEWPORT) + TOKEN_TABLE(PERSISTENT_STATE_SPRITES) + TOKEN_TABLE(PERSISTENT_STATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + Cleanup(); + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + Game->LOG(0, "'SCENE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int ar, ag, ab, aa; + char camera[MAX_PATH] = ""; + float WaypointHeight = -1.0f; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_LAYER: { + CAdLayer *layer = new CAdLayer(Game); + if (!layer || FAILED(layer->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete layer; + layer = NULL; + } else { + Game->RegisterObject(layer); + m_Layers.Add(layer); + if (layer->m_Main) { + m_MainLayer = layer; + m_Width = layer->m_Width; + m_Height = layer->m_Height; + } + } + } + break; + + case TOKEN_WAYPOINTS: { + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + if (!wpt || FAILED(wpt->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete wpt; + wpt = NULL; + } else { + Game->RegisterObject(wpt); + m_WaypointGroups.Add(wpt); + } + } + break; + + case TOKEN_SCALE_LEVEL: { + CAdScaleLevel *sl = new CAdScaleLevel(Game); + if (!sl || FAILED(sl->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete sl; + sl = NULL; + } else { + Game->RegisterObject(sl); + m_ScaleLevels.Add(sl); + } + } + break; + + case TOKEN_ROTATION_LEVEL: { + CAdRotLevel *rl = new CAdRotLevel(Game); + if (!rl || FAILED(rl->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete rl; + rl = NULL; + } else { + Game->RegisterObject(rl); + m_RotLevels.Add(rl); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(Game); + if (!entity || FAILED(entity->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + entity = NULL; + } else { + AddObject(entity); + } + } + break; + + case TOKEN_CURSOR: + delete m_Cursor; + m_Cursor = new CBSprite(Game); + if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { + delete m_Cursor; + m_Cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CAMERA: + strcpy(camera, (char *)params); + break; + + case TOKEN_EDITOR_MARGIN_H: + parser.ScanStr((char *)params, "%d", &m_EditorMarginH); + break; + + case TOKEN_EDITOR_MARGIN_V: + parser.ScanStr((char *)params, "%d", &m_EditorMarginV); + break; + + case TOKEN_EDITOR_COLOR_FRAME: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColFrame = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColEntity = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColEntitySel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColRegionSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColDecorSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColBlockedSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColWaypointsSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColRegion = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColDecor = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColBlocked = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColWaypoints = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_SCALE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + m_EditorColScale = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_SHOW_REGIONS: + parser.ScanStr((char *)params, "%b", &m_EditorShowRegions); + break; + + case TOKEN_EDITOR_SHOW_BLOCKED: + parser.ScanStr((char *)params, "%b", &m_EditorShowBlocked); + break; + + case TOKEN_EDITOR_SHOW_DECORATION: + parser.ScanStr((char *)params, "%b", &m_EditorShowDecor); + break; + + case TOKEN_EDITOR_SHOW_ENTITIES: + parser.ScanStr((char *)params, "%b", &m_EditorShowEntities); + break; + + case TOKEN_EDITOR_SHOW_SCALE: + parser.ScanStr((char *)params, "%b", &m_EditorShowScale); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_VIEWPORT: { + RECT rc; + parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!m_Viewport) m_Viewport = new CBViewport(Game); + if (m_Viewport) m_Viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); + } + + case TOKEN_PERSISTENT_STATE: + parser.ScanStr((char *)params, "%b", &m_PersistentState); + break; + + case TOKEN_PERSISTENT_STATE_SPRITES: + parser.ScanStr((char *)params, "%b", &m_PersistentStateSprites); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SCENE definition"); + return E_FAIL; + } + + if (m_MainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", m_Filename); + + + SortScaleLevels(); + SortRotLevels(); + + m_Initialized = true; + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::TraverseNodes(bool Update) { + if (!m_Initialized) return S_OK; + + int j, k; + CAdGame *AdGame = (CAdGame *)Game; + + + ////////////////////////////////////////////////////////////////////////// + // prepare viewport + bool PopViewport = false; + if (m_Viewport && !Game->m_EditorMode) { + Game->PushViewport(m_Viewport); + PopViewport = true; + } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { + Game->PushViewport(AdGame->m_SceneViewport); + PopViewport = true; + } + + + ////////////////////////////////////////////////////////////////////////// + // *** adjust scroll offset + if (Update) { + /* + if(m_AutoScroll && Game->m_MainObject != NULL) + { + ScrollToObject(Game->m_MainObject); + } + */ + + if (m_AutoScroll) { + // adjust horizontal scroll + if (Game->m_Timer - m_LastTimeH >= m_ScrollTimeH) { + m_LastTimeH = Game->m_Timer; + if (m_OffsetLeft < m_TargetOffsetLeft) { + m_OffsetLeft += m_ScrollPixelsH; + m_OffsetLeft = std::min(m_OffsetLeft, m_TargetOffsetLeft); + } else if (m_OffsetLeft > m_TargetOffsetLeft) { + m_OffsetLeft -= m_ScrollPixelsH; + m_OffsetLeft = std::max(m_OffsetLeft, m_TargetOffsetLeft); + } + } + + // adjust vertical scroll + if (Game->m_Timer - m_LastTimeV >= m_ScrollTimeV) { + m_LastTimeV = Game->m_Timer; + if (m_OffsetTop < m_TargetOffsetTop) { + m_OffsetTop += m_ScrollPixelsV; + m_OffsetTop = std::min(m_OffsetTop, m_TargetOffsetTop); + } else if (m_OffsetTop > m_TargetOffsetTop) { + m_OffsetTop -= m_ScrollPixelsV; + m_OffsetTop = std::max(m_OffsetTop, m_TargetOffsetTop); + } + } + + if (m_OffsetTop == m_TargetOffsetTop && m_OffsetLeft == m_TargetOffsetLeft) m_Ready = true; + } else m_Ready = true; // not scrolling, i.e. always ready + } + + + + + ////////////////////////////////////////////////////////////////////////// + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + int ViewportX, ViewportY; + GetViewportOffset(&ViewportX, &ViewportY); + + int ScrollableX = m_Width - ViewportWidth; + int ScrollableY = m_Height - ViewportHeight; + + double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(m_OffsetLeft) / (double)ScrollableX); + double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(m_OffsetTop) / (double)ScrollableY); + + int OrigX, OrigY; + Game->GetOffset(&OrigX, &OrigY); + + + + ////////////////////////////////////////////////////////////////////////// + // *** display/update everything + Game->m_Renderer->Setup2D(); + + // for each layer + int MainOffsetX = 0; + int MainOffsetY = 0; + + for (j = 0; j < m_Layers.GetSize(); j++) { + if (!m_Layers[j]->m_Active) continue; + + // make layer exclusive + if (!Update) { + if (m_Layers[j]->m_CloseUp && !Game->m_EditorMode) { + if (!m_ShieldWindow) m_ShieldWindow = new CUIWindow(Game); + if (m_ShieldWindow) { + m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; + m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; + m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; + m_ShieldWindow->Display(); + } + } + } + + if (m_ParalaxScrolling) { + int OffsetX = (int)(WidthRatio * (m_Layers[j]->m_Width - ViewportWidth) - ViewportX); + int OffsetY = (int)(HeightRatio * (m_Layers[j]->m_Height - ViewportHeight) - ViewportY); + Game->SetOffset(OffsetX, OffsetY); + + Game->m_OffsetPercentX = (float)OffsetX / ((float)m_Layers[j]->m_Width - ViewportWidth) * 100.0f; + Game->m_OffsetPercentY = (float)OffsetY / ((float)m_Layers[j]->m_Height - ViewportHeight) * 100.0f; + + //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->m_OffsetPercentX); + } else { + Game->SetOffset(m_OffsetLeft - ViewportX, m_OffsetTop - ViewportY); + + Game->m_OffsetPercentX = (float)(m_OffsetLeft - ViewportX) / ((float)m_Layers[j]->m_Width - ViewportWidth) * 100.0f; + Game->m_OffsetPercentY = (float)(m_OffsetTop - ViewportY) / ((float)m_Layers[j]->m_Height - ViewportHeight) * 100.0f; + } + + + // for each node + for (k = 0; k < m_Layers[j]->m_Nodes.GetSize(); k++) { + CAdSceneNode *Node = m_Layers[j]->m_Nodes[k]; + switch (Node->m_Type) { + case OBJECT_ENTITY: + if (Node->m_Entity->m_Active && (Game->m_EditorMode || !Node->m_Entity->m_EditorOnly)) { + Game->m_Renderer->Setup2D(); + + if (Update) Node->m_Entity->Update(); + else Node->m_Entity->Display(); + } + break; + + case OBJECT_REGION: { + if (Node->m_Region->m_Blocked) break; + if (Node->m_Region->m_Decoration) break; + + if (!Update) DisplayRegionContent(Node->m_Region); + } + break; + } // switch + } // each node + + // display/update all objects which are off-regions + if (m_Layers[j]->m_Main) { + if (Update) { + UpdateFreeObjects(); + } else { + DisplayRegionContent(NULL); + } + } + } // each layer + + + // restore state + Game->SetOffset(OrigX, OrigY); + Game->m_Renderer->Setup2D(); + + // display/update fader + if (m_Fader) { + if (Update) m_Fader->Update(); + else m_Fader->Display(); + } + + if (PopViewport) Game->PopViewport(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Display() { + return TraverseNodes(false); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::UpdateFreeObjects() { + CAdGame *AdGame = (CAdGame *)Game; + int i; + + bool Is3DSet; + + // *** update all active objects + Is3DSet = false; + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + if (!AdGame->m_Objects[i]->m_Active) continue; + + AdGame->m_Objects[i]->Update(); + AdGame->m_Objects[i]->m_Drawn = false; + } + + + for (i = 0; i < m_Objects.GetSize(); i++) { + if (!m_Objects[i]->m_Active) continue; + + m_Objects[i]->Update(); + m_Objects[i]->m_Drawn = false; + } + + + if (m_AutoScroll && Game->m_MainObject != NULL) { + ScrollToObject(Game->m_MainObject); + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { + CAdGame *AdGame = (CAdGame *)Game; + CBArray Objects; + CAdObject *Obj; + + int i; + + // global objects + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + Obj = AdGame->m_Objects[i]; + if (Obj->m_Active && !Obj->m_Drawn && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + Objects.Add(Obj); + } + } + + // scene objects + for (i = 0; i < m_Objects.GetSize(); i++) { + Obj = m_Objects[i]; + if (Obj->m_Active && !Obj->m_EditorOnly && !Obj->m_Drawn && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + Objects.Add(Obj); + } + } + + // sort by m_PosY + qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); + + // display them + for (i = 0; i < Objects.GetSize(); i++) { + Obj = Objects[i]; + + if (Display3DOnly && !Obj->m_Is3D) continue; + + Game->m_Renderer->Setup2D(); + + if (Game->m_EditorMode || !Obj->m_EditorOnly) Obj->Display(); + Obj->m_Drawn = true; + } + + + // display design only objects + if (!Display3DOnly) { + if (Game->m_EditorMode && Region == NULL) { + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && m_Objects[i]->m_EditorOnly) { + m_Objects[i]->Display(); + m_Objects[i]->m_Drawn = true; + } + } + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { + CAdObject *Object1 = *(CAdObject **)Obj1; + CAdObject *Object2 = *(CAdObject **)Obj2; + + if (Object1->m_PosY < Object2->m_PosY) return -1; + else if (Object1->m_PosY > Object2->m_PosY) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { + CAdGame *AdGame = (CAdGame *)Game; + CAdObject *obj; + int i; + + // display all objects in region sorted by m_PosY + do { + obj = NULL; + int minY = INT_MAX; + + // global objects + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + if (AdGame->m_Objects[i]->m_Active && !AdGame->m_Objects[i]->m_Drawn && AdGame->m_Objects[i]->m_PosY < minY && (AdGame->m_Objects[i]->m_StickRegion == Region || Region == NULL || (AdGame->m_Objects[i]->m_StickRegion == NULL && Region->PointInRegion(AdGame->m_Objects[i]->m_PosX, AdGame->m_Objects[i]->m_PosY)))) { + obj = AdGame->m_Objects[i]; + minY = AdGame->m_Objects[i]->m_PosY; + } + } + + // scene objects + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && !m_Objects[i]->m_EditorOnly && !m_Objects[i]->m_Drawn && m_Objects[i]->m_PosY < minY && (m_Objects[i]->m_StickRegion == Region || Region == NULL || (m_Objects[i]->m_StickRegion == NULL && Region->PointInRegion(m_Objects[i]->m_PosX, m_Objects[i]->m_PosY)))) { + obj = m_Objects[i]; + minY = m_Objects[i]->m_PosY; + } + } + + + if (obj != NULL) { + Game->m_Renderer->Setup2D(); + + if (Game->m_EditorMode || !obj->m_EditorOnly) obj->Display(); + obj->m_Drawn = true; + } + } while (obj != NULL); + + + // design only objects + if (Game->m_EditorMode && Region == NULL) { + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Active && m_Objects[i]->m_EditorOnly) { + m_Objects[i]->Display(); + m_Objects[i]->m_Drawn = true; + } + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Update() { + return TraverseNodes(true); +} + +////////////////////////////////////////////////////////////////////////// +void CAdScene::ScrollTo(int OffsetX, int OffsetY) { + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + int OrigOffsetLeft = m_TargetOffsetLeft; + int OrigOffsetTop = m_TargetOffsetTop; + + m_TargetOffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); + m_TargetOffsetLeft = std::min(m_TargetOffsetLeft, m_Width - ViewportWidth); + + m_TargetOffsetTop = std::max(0, OffsetY - ViewportHeight / 2); + m_TargetOffsetTop = std::min(m_TargetOffsetTop, m_Height - ViewportHeight); + + + if (Game->m_MainObject && Game->m_MainObject->m_Is3D) { + if (abs(OrigOffsetLeft - m_TargetOffsetLeft) < 5) m_TargetOffsetLeft = OrigOffsetLeft; + if (abs(OrigOffsetTop - m_TargetOffsetTop) < 5) m_TargetOffsetTop = OrigOffsetTop; + //m_TargetOffsetTop = 0; + } + + m_Ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::ScrollToObject(CBObject *Object) { + if (Object) ScrollTo(Object->m_PosX, Object->m_PosY - Object->GetHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SkipToObject(CBObject *Object) { + if (Object) SkipTo(Object->m_PosX, Object->m_PosY - Object->GetHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SkipTo(int OffsetX, int OffsetY) { + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + m_OffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); + m_OffsetLeft = std::min(m_OffsetLeft, m_Width - ViewportWidth); + + m_OffsetTop = std::max(0, OffsetY - ViewportHeight / 2); + m_OffsetTop = std::min(m_OffsetTop, m_Height - ViewportHeight); + + m_TargetOffsetLeft = m_OffsetLeft; + m_TargetOffsetTop = m_OffsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LoadActor") == 0) { + Stack->CorrectParams(1); + CAdActor *act = new CAdActor(Game); + if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + AddObject(act); + Stack->PushNative(act, true); + } else { + delete act; + act = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadEntity") == 0) { + Stack->CorrectParams(1); + CAdEntity *ent = new CAdEntity(Game); + if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + AddObject(ent); + Stack->PushNative(ent, true); + } else { + delete ent; + ent = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdEntity *Ent = new CAdEntity(Game); + AddObject(Ent); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "UnloadActor3D") == 0 || strcmp(Name, "DeleteEntity") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CAdObject *obj = (CAdObject *)val->GetNative(); + RemoveObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SkipTo") == 0) { + Stack->CorrectParams(2); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + if (val1->IsNative()) { + SkipToObject((CBObject *)val1->GetNative()); + } else { + SkipTo(val1->GetInt(), val2->GetInt()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollTo / ScrollToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollTo") == 0 || strcmp(Name, "ScrollToAsync") == 0) { + Stack->CorrectParams(2); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + if (val1->IsNative()) { + ScrollToObject((CBObject *)val1->GetNative()); + } else { + ScrollTo(val1->GetInt(), val2->GetInt()); + } + if (strcmp(Name, "ScrollTo") == 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetLayer") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + if (val->IsInt()) { + int layer = val->GetInt(); + if (layer < 0 || layer >= m_Layers.GetSize()) Stack->PushNULL(); + else Stack->PushNative(m_Layers[layer], true); + } else { + char *LayerName = val->GetString(); + bool LayerFound = false; + for (int i = 0; i < m_Layers.GetSize(); i++) { + if (scumm_stricmp(LayerName, m_Layers[i]->m_Name) == 0) { + Stack->PushNative(m_Layers[i], true); + LayerFound = true; + break; + } + } + if (!LayerFound) Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaypointGroup + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaypointGroup") == 0) { + Stack->CorrectParams(1); + int group = Stack->Pop()->GetInt(); + if (group < 0 || group >= m_WaypointGroups.GetSize()) Stack->PushNULL(); + else Stack->PushNative(m_WaypointGroups[group], true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNode") == 0) { + Stack->CorrectParams(1); + char *Name = Stack->Pop()->GetString(); + + CBObject *node = GetNodeByName(Name); + if (node) Stack->PushNative((CBScriptable *)node, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFreeNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFreeNode") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdObject *Ret = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + if (Index >= 0 && Index < m_Objects.GetSize()) Ret = m_Objects[Index]; + } else { + char *Name = Val->GetString(); + for (int i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i] && m_Objects[i]->m_Name && scumm_stricmp(m_Objects[i]->m_Name, Name) == 0) { + Ret = m_Objects[i]; + break; + } + } + } + if (Ret) Stack->PushNative(Ret, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRegionAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRegionAt") == 0) { + Stack->CorrectParams(3); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + bool IncludeDecors = false; + if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); + + if (m_MainLayer) { + for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->PointInRegion(X, Y)) { + if (Node->m_Region->m_Decoration && !IncludeDecors) continue; + + Stack->PushNative(Node->m_Region, true); + return S_OK; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsBlockedAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsBlockedAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushBool(IsBlockedAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalkableAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsWalkableAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushBool(IsWalkableAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetScaleAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetScaleAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushFloat(GetZoomAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRotationAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRotationAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushFloat(GetRotationAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScrolling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsScrolling") == 0) { + Stack->CorrectParams(0); + bool Ret = false; + if (m_AutoScroll) { + if (m_TargetOffsetLeft != m_OffsetLeft || m_TargetOffsetTop != m_OffsetTop) Ret = true; + } + + Stack->PushBool(Ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + m_Fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(m_Fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + m_Fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(m_Fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFadeColor") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(m_Fader->GetCurrentColor()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsPointInViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsPointInViewport") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + Stack->PushBool(PointInViewport(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetViewport") == 0) { + Stack->CorrectParams(4); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + int Width = Stack->Pop()->GetInt(); + int Height = Stack->Pop()->GetInt(); + + if (Width <= 0) Width = Game->m_Renderer->m_Width; + if (Height <= 0) Height = Game->m_Renderer->m_Height; + + if (!m_Viewport) m_Viewport = new CBViewport(Game); + if (m_Viewport) m_Viewport->SetRect(X, Y, X + Width, Y + Height); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddLayer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdLayer *Layer = new CAdLayer(Game); + if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (m_MainLayer) { + Layer->m_Width = m_MainLayer->m_Width; + Layer->m_Height = m_MainLayer->m_Height; + } + m_Layers.Add(Layer); + Game->RegisterObject(Layer); + + Stack->PushNative(Layer, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertLayer") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + CAdLayer *Layer = new CAdLayer(Game); + if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (m_MainLayer) { + Layer->m_Width = m_MainLayer->m_Width; + Layer->m_Height = m_MainLayer->m_Height; + } + if (Index < 0) Index = 0; + if (Index <= m_Layers.GetSize() - 1) m_Layers.InsertAt(Index, Layer); + else m_Layers.Add(Layer); + + Game->RegisterObject(Layer); + + Stack->PushNative(Layer, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteLayer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdLayer *ToDelete = NULL; + if (Val->IsNative()) { + CBScriptable *Temp = Val->GetNative(); + for (int i = 0; i < m_Layers.GetSize(); i++) { + if (m_Layers[i] == Temp) { + ToDelete = m_Layers[i]; + break; + } + } + } else { + int Index = Val->GetInt(); + if (Index >= 0 && Index < m_Layers.GetSize()) { + ToDelete = m_Layers[Index]; + } + } + if (ToDelete == NULL) { + Stack->PushBool(false); + return S_OK; + } + + if (ToDelete->m_Main) { + Script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); + Stack->PushBool(false); + return S_OK; + } + + for (int i = 0; i < m_Layers.GetSize(); i++) { + if (m_Layers[i] == ToDelete) { + m_Layers.RemoveAt(i); + Game->UnregisterObject(ToDelete); + break; + } + } + Stack->PushBool(true); + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdScene::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("scene"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumLayers (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumLayers") == 0) { + m_ScValue->SetInt(m_Layers.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWaypointGroups (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumWaypointGroups") == 0) { + m_ScValue->SetInt(m_WaypointGroups.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainLayer (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainLayer") == 0) { + if (m_MainLayer) m_ScValue->SetNative(m_MainLayer, true); + else m_ScValue->SetNULL(); + + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFreeNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumFreeNodes") == 0) { + m_ScValue->SetInt(m_Objects.GetSize()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + int ViewportX; + GetViewportOffset(&ViewportX); + + m_ScValue->SetInt(Game->m_MousePos.x + m_OffsetLeft - ViewportX); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + int ViewportY; + GetViewportOffset(NULL, &ViewportY); + + m_ScValue->SetInt(Game->m_MousePos.y + m_OffsetTop - ViewportY); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoScroll") == 0) { + m_ScValue->SetBool(m_AutoScroll); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentState") == 0) { + m_ScValue->SetBool(m_PersistentState); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentStateSprites") == 0) { + m_ScValue->SetBool(m_PersistentStateSprites); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsX") == 0) { + m_ScValue->SetInt(m_ScrollPixelsH); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsY") == 0) { + m_ScValue->SetInt(m_ScrollPixelsV); + return m_ScValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedX") == 0) { + m_ScValue->SetInt(m_ScrollTimeH); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedY") == 0) { + m_ScValue->SetInt(m_ScrollTimeV); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetX") == 0) { + m_ScValue->SetInt(m_OffsetLeft); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetY") == 0) { + m_ScValue->SetInt(m_OffsetTop); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + if (m_MainLayer) m_ScValue->SetInt(m_MainLayer->m_Width); + else m_ScValue->SetInt(0); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + if (m_MainLayer) m_ScValue->SetInt(m_MainLayer->m_Height); + else m_ScValue->SetInt(0); + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoScroll") == 0) { + m_AutoScroll = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentState") == 0) { + m_PersistentState = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentStateSprites") == 0) { + m_PersistentStateSprites = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsX") == 0) { + m_ScrollPixelsH = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsY") == 0) { + m_ScrollPixelsV = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedX") == 0) { + m_ScrollTimeH = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedY") == 0) { + m_ScrollTimeV = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetX") == 0) { + m_OffsetLeft = Value->GetInt(); + + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + m_OffsetLeft = std::max(0, m_OffsetLeft - ViewportWidth / 2); + m_OffsetLeft = std::min(m_OffsetLeft, m_Width - ViewportWidth); + m_TargetOffsetLeft = m_OffsetLeft; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetY") == 0) { + m_OffsetTop = Value->GetInt(); + + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + m_OffsetTop = std::max(0, m_OffsetTop - ViewportHeight / 2); + m_OffsetTop = std::min(m_OffsetTop, m_Height - ViewportHeight); + m_TargetOffsetTop = m_OffsetTop; + + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdScene::ScToString() { + return "[scene object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::AddObject(CAdObject *Object) { + m_Objects.Add(Object); + return Game->RegisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::RemoveObject(CAdObject *Object) { + for (int i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i] == Object) { + m_Objects.RemoveAt(i); + return Game->UnregisterObject(Object); + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { + int i; + + Buffer->PutTextIndent(Indent, "SCENE {\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + if (m_PersistentState) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", m_PersistentState ? "TRUE" : "FALSE"); + + if (!m_PersistentStateSprites) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", m_PersistentStateSprites ? "TRUE" : "FALSE"); + + + // scripts + for (i = 0; i < m_Scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // properties + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + + // viewport + if (m_Viewport) { + RECT *rc = m_Viewport->GetRect(); + Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + } + + + + // editor settings + Buffer->PutTextIndent(Indent + 2, "; ----- editor settings\n"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", m_EditorMarginH); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", m_EditorMarginV); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColFrame), D3DCOLGetG(m_EditorColFrame), D3DCOLGetB(m_EditorColFrame), D3DCOLGetA(m_EditorColFrame)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColEntitySel), D3DCOLGetG(m_EditorColEntitySel), D3DCOLGetB(m_EditorColEntitySel), D3DCOLGetA(m_EditorColEntitySel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColRegionSel), D3DCOLGetG(m_EditorColRegionSel), D3DCOLGetB(m_EditorColRegionSel), D3DCOLGetA(m_EditorColRegionSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColBlockedSel), D3DCOLGetG(m_EditorColBlockedSel), D3DCOLGetB(m_EditorColBlockedSel), D3DCOLGetA(m_EditorColBlockedSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColDecorSel), D3DCOLGetG(m_EditorColDecorSel), D3DCOLGetB(m_EditorColDecorSel), D3DCOLGetA(m_EditorColDecorSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColWaypointsSel), D3DCOLGetG(m_EditorColWaypointsSel), D3DCOLGetB(m_EditorColWaypointsSel), D3DCOLGetA(m_EditorColWaypointsSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColEntity), D3DCOLGetG(m_EditorColEntity), D3DCOLGetB(m_EditorColEntity), D3DCOLGetA(m_EditorColEntity)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColRegion), D3DCOLGetG(m_EditorColRegion), D3DCOLGetB(m_EditorColRegion), D3DCOLGetA(m_EditorColRegion)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColDecor), D3DCOLGetG(m_EditorColDecor), D3DCOLGetB(m_EditorColDecor), D3DCOLGetA(m_EditorColDecor)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColBlocked), D3DCOLGetG(m_EditorColBlocked), D3DCOLGetB(m_EditorColBlocked), D3DCOLGetA(m_EditorColBlocked)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColWaypoints), D3DCOLGetG(m_EditorColWaypoints), D3DCOLGetB(m_EditorColWaypoints), D3DCOLGetA(m_EditorColWaypoints)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColScale), D3DCOLGetG(m_EditorColScale), D3DCOLGetB(m_EditorColScale), D3DCOLGetA(m_EditorColScale)); + + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", m_EditorShowRegions ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", m_EditorShowBlocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", m_EditorShowDecor ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", m_EditorShowEntities ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", m_EditorShowScale ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + // waypoints + Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); + for (i = 0; i < m_WaypointGroups.GetSize(); i++) m_WaypointGroups[i]->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // layers + Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); + for (i = 0; i < m_Layers.GetSize(); i++) m_Layers[i]->SaveAsText(Buffer, Indent + 2); + + // scale levels + Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); + for (i = 0; i < m_ScaleLevels.GetSize(); i++) m_ScaleLevels[i]->SaveAsText(Buffer, Indent + 2); + + // rotation levels + Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); + for (i = 0; i < m_RotLevels.GetSize(); i++) m_RotLevels[i]->SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // free entities + Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Type == OBJECT_ENTITY) { + m_Objects[i]->SaveAsText(Buffer, Indent + 2); + + } + } + + + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SortScaleLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < m_ScaleLevels.GetSize() - 1; i++) { + if (m_ScaleLevels[i]->m_PosY > m_ScaleLevels[i + 1]->m_PosY) { + CAdScaleLevel *sl = m_ScaleLevels[i]; + m_ScaleLevels[i] = m_ScaleLevels[i + 1]; + m_ScaleLevels[i + 1] = sl; + + changed = true; + } + } + + } while (changed); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SortRotLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < m_RotLevels.GetSize() - 1; i++) { + if (m_RotLevels[i]->m_PosX > m_RotLevels[i + 1]->m_PosX) { + CAdRotLevel *rl = m_RotLevels[i]; + m_RotLevels[i] = m_RotLevels[i + 1]; + m_RotLevels[i + 1] = rl; + + changed = true; + } + } + + } while (changed); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetScaleAt(int Y) { + CAdScaleLevel *prev = NULL; + CAdScaleLevel *next = NULL; + + for (int i = 0; i < m_ScaleLevels.GetSize(); i++) { + CAdScaleLevel *xxx = m_ScaleLevels[i]; + int j = m_ScaleLevels.GetSize(); + if (m_ScaleLevels[i]->m_PosY < Y) prev = m_ScaleLevels[i]; + else { + next = m_ScaleLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 100; + + int delta_y = next->m_PosY - prev->m_PosY; + float delta_scale = next->m_Scale - prev->m_Scale; + Y -= prev->m_PosY; + + float percent = (float)Y / ((float)delta_y / 100.0f); + return prev->m_Scale + delta_scale / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_AutoScroll)); + PersistMgr->Transfer(TMEMBER(m_EditorColBlocked)); + PersistMgr->Transfer(TMEMBER(m_EditorColBlockedSel)); + PersistMgr->Transfer(TMEMBER(m_EditorColDecor)); + PersistMgr->Transfer(TMEMBER(m_EditorColDecorSel)); + PersistMgr->Transfer(TMEMBER(m_EditorColEntity)); + PersistMgr->Transfer(TMEMBER(m_EditorColEntitySel)); + PersistMgr->Transfer(TMEMBER(m_EditorColFrame)); + PersistMgr->Transfer(TMEMBER(m_EditorColRegion)); + PersistMgr->Transfer(TMEMBER(m_EditorColRegionSel)); + PersistMgr->Transfer(TMEMBER(m_EditorColScale)); + PersistMgr->Transfer(TMEMBER(m_EditorColWaypoints)); + PersistMgr->Transfer(TMEMBER(m_EditorColWaypointsSel)); + PersistMgr->Transfer(TMEMBER(m_EditorMarginH)); + PersistMgr->Transfer(TMEMBER(m_EditorMarginV)); + PersistMgr->Transfer(TMEMBER(m_EditorShowBlocked)); + PersistMgr->Transfer(TMEMBER(m_EditorShowDecor)); + PersistMgr->Transfer(TMEMBER(m_EditorShowEntities)); + PersistMgr->Transfer(TMEMBER(m_EditorShowRegions)); + PersistMgr->Transfer(TMEMBER(m_EditorShowScale)); + PersistMgr->Transfer(TMEMBER(m_Fader)); + PersistMgr->Transfer(TMEMBER(m_Height)); + PersistMgr->Transfer(TMEMBER(m_Initialized)); + PersistMgr->Transfer(TMEMBER(m_LastTimeH)); + PersistMgr->Transfer(TMEMBER(m_LastTimeV)); + m_Layers.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_MainLayer)); + m_Objects.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_OffsetLeft)); + PersistMgr->Transfer(TMEMBER(m_OffsetTop)); + PersistMgr->Transfer(TMEMBER(m_ParalaxScrolling)); + PersistMgr->Transfer(TMEMBER(m_PersistentState)); + PersistMgr->Transfer(TMEMBER(m_PersistentStateSprites)); + PersistMgr->Transfer(TMEMBER(m_PFMaxTime)); + m_PFPath.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_PFPointsNum)); + PersistMgr->Transfer(TMEMBER(m_PFReady)); + PersistMgr->Transfer(TMEMBER(m_PFRequester)); + PersistMgr->Transfer(TMEMBER(m_PFTarget)); + PersistMgr->Transfer(TMEMBER(m_PFTargetPath)); + m_RotLevels.Persist(PersistMgr); + m_ScaleLevels.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_ScrollPixelsH)); + PersistMgr->Transfer(TMEMBER(m_ScrollPixelsV)); + PersistMgr->Transfer(TMEMBER(m_ScrollTimeH)); + PersistMgr->Transfer(TMEMBER(m_ScrollTimeV)); + PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); + PersistMgr->Transfer(TMEMBER(m_TargetOffsetLeft)); + PersistMgr->Transfer(TMEMBER(m_TargetOffsetTop)); + m_WaypointGroups.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(m_Viewport)); + PersistMgr->Transfer(TMEMBER(m_Width)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::AfterLoad() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { + double xStep, yStep, X, Y; + int xLength, yLength, xCount, yCount; + int X1, Y1, X2, Y2; + + X1 = *TargetX; + Y1 = *TargetY; + X2 = StartX; + Y2 = StartY; + + + xLength = abs(X2 - X1); + yLength = abs(Y2 - Y1); + + if (xLength > yLength) { + /* + if(X1 > X2) + { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + yStep = fabs((double)(Y2 - Y1) / (double)(X2 - X1)); + Y = Y1; + + for (xCount = X1; xCount < X2; xCount++) { + if (IsWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { + *TargetX = xCount; + *TargetY = (int)Y; + return S_OK; + } + Y += yStep; + } + } else { + /* + if(Y1 > Y2) { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + xStep = fabs((double)(X2 - X1) / (double)(Y2 - Y1)); + X = X1; + + for (yCount = Y1; yCount < Y2; yCount++) { + if (IsWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { + *TargetX = (int)X; + *TargetY = yCount; + return S_OK; + } + X += xStep; + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { + int x = *X; + int y = *Y; + + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !m_MainLayer) { + return S_OK; + } + + // right + int length_right = 0; + bool found_right = false; + for (x = *X, y = *Y; x < m_MainLayer->m_Width; x++, length_right++) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { + found_right = true; + break; + } + } + + // left + int length_left = 0; + bool found_left = false; + for (x = *X, y = *Y; x >= 0; x--, length_left--) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { + found_left = true; + break; + } + } + + // up + int length_up = 0; + bool found_up = false; + for (x = *X, y = *Y; y >= 0; y--, length_up--) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { + found_up = true; + break; + } + } + + // down + int length_down = 0; + bool found_down = false; + for (x = *X, y = *Y; y < m_MainLayer->m_Height; y++, length_down++) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { + found_down = true; + break; + } + } + + if (!found_left && !found_right && !found_up && !found_down) { + return S_OK; + } + + int OffsetX = INT_MAX, OffsetY = INT_MAX; + + if (found_left && found_right) { + if (abs(length_left) < abs(length_right)) OffsetX = length_left; + else OffsetX = length_right; + } else if (found_left) OffsetX = length_left; + else if (found_right) OffsetX = length_right; + + if (found_up && found_down) { + if (abs(length_up) < abs(length_down)) OffsetY = length_up; + else OffsetY = length_down; + } else if (found_up) OffsetY = length_up; + else if (found_down) OffsetY = length_down; + + if (abs(OffsetX) < abs(OffsetY)) + *X = *X + OffsetX; + else + *Y = *Y + OffsetY; + + if (!IsWalkableAt(*X, *Y)) return CorrectTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFPointsStart() { + m_PFPointsNum = 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFPointsAdd(int X, int Y, int Distance) { + if (m_PFPointsNum >= m_PFPath.GetSize()) { + m_PFPath.Add(new CAdPathPoint(X, Y, Distance)); + } else { + m_PFPath[m_PFPointsNum]->x = X; + m_PFPath[m_PFPointsNum]->y = Y; + m_PFPath[m_PFPointsNum]->m_Distance = Distance; + m_PFPath[m_PFPointsNum]->m_Marked = false; + m_PFPath[m_PFPointsNum]->m_Origin = NULL; + } + + m_PFPointsNum++; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { + CAdGame *AdGame = (CAdGame *)Game; + if (m_Viewport && !Game->m_EditorMode) { + if (OffsetX) *OffsetX = m_Viewport->m_OffsetX; + if (OffsetY) *OffsetY = m_Viewport->m_OffsetY; + } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { + if (OffsetX) *OffsetX = AdGame->m_SceneViewport->m_OffsetX; + if (OffsetY) *OffsetY = AdGame->m_SceneViewport->m_OffsetY; + } else { + if (OffsetX) *OffsetX = 0; + if (OffsetY) *OffsetY = 0; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { + CAdGame *AdGame = (CAdGame *)Game; + if (m_Viewport && !Game->m_EditorMode) { + if (Width) *Width = m_Viewport->GetWidth(); + if (Height) *Height = m_Viewport->GetHeight(); + } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { + if (Width) *Width = AdGame->m_SceneViewport->GetWidth(); + if (Height) *Height = AdGame->m_SceneViewport->GetHeight(); + } else { + if (Width) *Width = Game->m_Renderer->m_Width; + if (Height) *Height = Game->m_Renderer->m_Height; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetOffsetLeft() { + int ViewportX; + GetViewportOffset(&ViewportX); + + return m_OffsetLeft - ViewportX; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetOffsetTop() { + int ViewportY; + GetViewportOffset(NULL, &ViewportY); + + return m_OffsetTop - ViewportY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::PointInViewport(int X, int Y) { + int Left, Top, Width, Height; + + GetViewportOffset(&Left, &Top); + GetViewportSize(&Width, &Height); + + return X >= Left && X <= Left + Width && Y >= Top && Y <= Top + Height; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { + m_OffsetLeft = OffsetLeft; + m_OffsetTop = OffsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetNodeByName(char *Name) { + int i; + CBObject *ret = NULL; + + // dependent objects + for (i = 0; i < m_Layers.GetSize(); i++) { + CAdLayer *layer = m_Layers[i]; + for (int j = 0; j < layer->m_Nodes.GetSize(); j++) { + CAdSceneNode *node = layer->m_Nodes[j]; + if ((node->m_Type == OBJECT_ENTITY && !scumm_stricmp(Name, node->m_Entity->m_Name)) || + (node->m_Type == OBJECT_REGION && !scumm_stricmp(Name, node->m_Region->m_Name))) { + switch (node->m_Type) { + case OBJECT_ENTITY: + ret = node->m_Entity; + break; + case OBJECT_REGION: + ret = node->m_Region; + break; + default: + ret = NULL; + } + return ret; + } + } + } + + // free entities + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Type == OBJECT_ENTITY && !scumm_stricmp(Name, m_Objects[i]->m_Name)) { + return m_Objects[i]; + } + } + + // waypoint groups + for (i = 0; i < m_WaypointGroups.GetSize(); i++) { + if (!scumm_stricmp(Name, m_WaypointGroups[i]->m_Name)) { + return m_WaypointGroups[i]; + } + } + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SaveState() { + return PersistState(true); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadState() { + return PersistState(false); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::PersistState(bool Saving) { + if (!m_PersistentState) return S_OK; + + CAdGame *AdGame = (CAdGame *)Game; + CAdSceneState *State = AdGame->GetSceneState(m_Filename, Saving); + if (!State) return S_OK; + + + int i; + CAdNodeState *NodeState; + + // dependent objects + for (i = 0; i < m_Layers.GetSize(); i++) { + CAdLayer *layer = m_Layers[i]; + for (int j = 0; j < layer->m_Nodes.GetSize(); j++) { + CAdSceneNode *node = layer->m_Nodes[j]; + switch (node->m_Type) { + case OBJECT_ENTITY: + if (!node->m_Entity->m_SaveState) continue; + NodeState = State->GetNodeState(node->m_Entity->m_Name, Saving); + if (NodeState) { + NodeState->TransferEntity(node->m_Entity, m_PersistentStateSprites, Saving); + //if(Saving) NodeState->m_Active = node->m_Entity->m_Active; + //else node->m_Entity->m_Active = NodeState->m_Active; + } + break; + case OBJECT_REGION: + if (!node->m_Region->m_SaveState) continue; + NodeState = State->GetNodeState(node->m_Region->m_Name, Saving); + if (NodeState) { + if (Saving) NodeState->m_Active = node->m_Region->m_Active; + else node->m_Region->m_Active = NodeState->m_Active; + } + break; + } + } + } + + // free entities + for (i = 0; i < m_Objects.GetSize(); i++) { + if (!m_Objects[i]->m_SaveState) continue; + if (m_Objects[i]->m_Type == OBJECT_ENTITY) { + NodeState = State->GetNodeState(m_Objects[i]->m_Name, Saving); + if (NodeState) { + NodeState->TransferEntity((CAdEntity *)m_Objects[i], m_PersistentStateSprites, Saving); + //if(Saving) NodeState->m_Active = m_Objects[i]->m_Active; + //else m_Objects[i]->m_Active = NodeState->m_Active; + } + } + } + + // waypoint groups + for (i = 0; i < m_WaypointGroups.GetSize(); i++) { + NodeState = State->GetNodeState(m_WaypointGroups[i]->m_Name, Saving); + if (NodeState) { + if (Saving) NodeState->m_Active = m_WaypointGroups[i]->m_Active; + else m_WaypointGroups[i]->m_Active = NodeState->m_Active; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetRotationAt(int X, int Y) { + CAdRotLevel *prev = NULL; + CAdRotLevel *next = NULL; + + for (int i = 0; i < m_RotLevels.GetSize(); i++) { + CAdRotLevel *xxx = m_RotLevels[i]; + int j = m_RotLevels.GetSize(); + if (m_RotLevels[i]->m_PosX < X) prev = m_RotLevels[i]; + else { + next = m_RotLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 0; + + int delta_x = next->m_PosX - prev->m_PosX; + float delta_rot = next->m_Rotation - prev->m_Rotation; + X -= prev->m_PosX; + + float percent = (float)X / ((float)delta_x / 100.0f); + return prev->m_Rotation + delta_rot / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::HandleItemAssociations(char *ItemName, bool Show) { + int i; + + for (i = 0; i < m_Layers.GetSize(); i++) { + CAdLayer *Layer = m_Layers[i]; + for (int j = 0; j < Layer->m_Nodes.GetSize(); j++) { + if (Layer->m_Nodes[j]->m_Type == OBJECT_ENTITY) { + CAdEntity *Ent = Layer->m_Nodes[j]->m_Entity; + + if (Ent->m_Item && strcmp(Ent->m_Item, ItemName) == 0) Ent->m_Active = Show; + } + } + } + + for (i = 0; i < m_Objects.GetSize(); i++) { + if (m_Objects[i]->m_Type == OBJECT_ENTITY) { + CAdEntity *Ent = (CAdEntity *)m_Objects[i]; + if (Ent->m_Item && strcmp(Ent->m_Item, ItemName) == 0) Ent->m_Active = Show; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { + int i; + int NumUsed = 0; + if (m_MainLayer) { + for (i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->PointInRegion(X, Y)) { + if (NumUsed < NumRegions - 1) { + RegionList[NumUsed] = Node->m_Region; + NumUsed++; + } else break; + } + } + } + for (i = NumUsed; i < NumRegions; i++) { + RegionList[i] = NULL; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::RestoreDeviceObjects() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetNextAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetSceneObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = 0; i < Objects.GetSize(); i++) { + if (Objects[i] == CurrObject) { + if (i < Objects.GetSize() - 1) return Objects[i + 1]; + else break; + } + } + } + return Objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetSceneObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = Objects.GetSize() - 1; i >= 0; i--) { + if (Objects[i] == CurrObject) { + if (i > 0) return Objects[i - 1]; + else break; + } + } + } + return Objects[Objects.GetSize() - 1]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetSceneObjects(CBArray& Objects, bool InteractiveOnly) { + for (int i = 0; i < m_Layers.GetSize(); i++) { + // close-up layer -> remove everything below it + if (InteractiveOnly && m_Layers[i]->m_CloseUp) Objects.RemoveAll(); + + + for (int j = 0; j < m_Layers[i]->m_Nodes.GetSize(); j++) { + CAdSceneNode *Node = m_Layers[i]->m_Nodes[j]; + switch (Node->m_Type) { + case OBJECT_ENTITY: { + CAdEntity *Ent = Node->m_Entity; + if (Ent->m_Active && (Ent->m_Registrable || !InteractiveOnly)) + Objects.Add(Ent); + } + break; + + case OBJECT_REGION: { + CBArray RegionObj; + GetRegionObjects(Node->m_Region, RegionObj, InteractiveOnly); + for (int New = 0; New < RegionObj.GetSize(); New++) { + bool Found = false; + for (int Old = 0; Old < Objects.GetSize(); Old++) { + if (Objects[Old] == RegionObj[New]) { + Found = true; + break; + } + } + if (!Found) Objects.Add(RegionObj[New]); + } + //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); + } + break; + } + } + } + + // objects outside any region + CBArray RegionObj; + GetRegionObjects(NULL, RegionObj, InteractiveOnly); + for (int New = 0; New < RegionObj.GetSize(); New++) { + bool Found = false; + for (int Old = 0; Old < Objects.GetSize(); Old++) { + if (Objects[Old] == RegionObj[New]) { + Found = true; + break; + } + } + if (!Found) Objects.Add(RegionObj[New]); + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray& Objects, bool InteractiveOnly) { + CAdGame *AdGame = (CAdGame *)Game; + CAdObject *Obj; + + int i; + + // global objects + for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { + Obj = AdGame->m_Objects[i]; + if (Obj->m_Active && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + if (InteractiveOnly && !Obj->m_Registrable) continue; + + Objects.Add(Obj); + } + } + + // scene objects + for (i = 0; i < m_Objects.GetSize(); i++) { + Obj = m_Objects[i]; + if (Obj->m_Active && !Obj->m_EditorOnly && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + if (InteractiveOnly && !Obj->m_Registrable) continue; + + Objects.Add(Obj); + } + } + + // sort by m_PosY + qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h new file mode 100644 index 0000000000..c3124cf814 --- /dev/null +++ b/engines/wintermute/AdScene.h @@ -0,0 +1,181 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdScene_H__ +#define __WmeAdScene_H__ + +#include "BFader.h" + +namespace WinterMute { + +class CUIWindow; +class CAdObject; +class CAdRegion; +class CBViewport; +class CAdLayer; +class CBPoint; +class CAdWaypointGroup; +class CAdPath; +class CAdScaleLevel; +class CAdRotLevel; +class CAdPathPoint; +class CAdScene : public CBObject { +public: + + CBObject *GetNextAccessObject(CBObject *CurrObject); + CBObject *GetPrevAccessObject(CBObject *CurrObject); + HRESULT GetSceneObjects(CBArray& Objects, bool InteractiveOnly); + HRESULT GetRegionObjects(CAdRegion *Region, CBArray& Objects, bool InteractiveOnly); + + HRESULT AfterLoad(); + + HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + HRESULT HandleItemAssociations(char *ItemName, bool Show); + CUIWindow *m_ShieldWindow; + float GetRotationAt(int X, int Y); + HRESULT LoadState(); + HRESULT SaveState(); + bool m_PersistentState; + bool m_PersistentStateSprites; + CBObject *GetNodeByName(char *Name); + void SetOffset(int OffsetLeft, int OffsetTop); + bool PointInViewport(int X, int Y); + int GetOffsetTop(); + int GetOffsetLeft(); + HRESULT GetViewportSize(int *Width = NULL, int *Height = NULL); + HRESULT GetViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + CBViewport *m_Viewport; + CBFader *m_Fader; + int m_PFPointsNum; + void PFPointsAdd(int X, int Y, int Distance); + void PFPointsStart(); + bool m_Initialized; + HRESULT CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + HRESULT CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + DECLARE_PERSISTENT(CAdScene, CBObject) + HRESULT DisplayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + HRESULT DisplayRegionContentOld(CAdRegion *Region = NULL); + static int CompareObjs(const void *Obj1, const void *Obj2); + + HRESULT UpdateFreeObjects(); + HRESULT TraverseNodes(bool Update = false); + float GetScaleAt(int Y); + HRESULT SortScaleLevels(); + HRESULT SortRotLevels(); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); + bool m_ParalaxScrolling; + void SkipTo(int OffsetX, int OffsetY); + void SetDefaults(); + void Cleanup(); + void SkipToObject(CBObject *Object); + void ScrollToObject(CBObject *Object); + void ScrollTo(int OffsetX, int OffsetY); + virtual HRESULT Update(); + bool m_AutoScroll; + int m_TargetOffsetTop; + int m_TargetOffsetLeft; + + int m_ScrollPixelsV; + uint32 m_ScrollTimeV; + uint32 m_LastTimeV; + + int m_ScrollPixelsH; + uint32 m_ScrollTimeH; + uint32 m_LastTimeH; + + virtual HRESULT Display(); + uint32 m_PFMaxTime; + HRESULT InitLoop(); + void PathFinderStep(); + bool IsBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool IsWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + CAdLayer *m_MainLayer; + float GetZoomAt(int X, int Y); + bool GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); + CAdScene(CBGame *inGame); + virtual ~CAdScene(); + CBArray m_Layers; + CBArray m_Objects; + CBArray m_WaypointGroups; + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + int m_Width; + int m_Height; + HRESULT AddObject(CAdObject *Object); + HRESULT RemoveObject(CAdObject *Object); + int m_EditorMarginH; + int m_EditorMarginV; + uint32 m_EditorColFrame; + uint32 m_EditorColEntity; + uint32 m_EditorColRegion; + uint32 m_EditorColBlocked; + uint32 m_EditorColWaypoints; + uint32 m_EditorColEntitySel; + uint32 m_EditorColRegionSel; + uint32 m_EditorColBlockedSel; + uint32 m_EditorColWaypointsSel; + uint32 m_EditorColScale; + uint32 m_EditorColDecor; + uint32 m_EditorColDecorSel; + + bool m_EditorShowRegions; + bool m_EditorShowBlocked; + bool m_EditorShowDecor; + bool m_EditorShowEntities; + bool m_EditorShowScale; + CBArray m_ScaleLevels; + CBArray m_RotLevels; + + virtual HRESULT RestoreDeviceObjects(); + int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + + // scripting interface + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual char *ScToString(); + + +private: + HRESULT PersistState(bool Saving = true); + void PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + bool m_PFReady; + CBPoint *m_PFTarget; + CAdPath *m_PFTargetPath; + CBObject *m_PFRequester; + CBArray m_PFPath; + + int m_OffsetTop; + int m_OffsetLeft; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdSceneNode.cpp b/engines/wintermute/AdSceneNode.cpp new file mode 100644 index 0000000000..4f20a47324 --- /dev/null +++ b/engines/wintermute/AdSceneNode.cpp @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdSceneNode.h" +#include "BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { + m_Type = OBJECT_NONE; + m_Region = NULL; + m_Entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::~CAdSceneNode() { + Game->UnregisterObject(m_Region); + m_Region = NULL; + + Game->UnregisterObject(m_Entity); + m_Entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { + m_Type = OBJECT_ENTITY; + m_Entity = Entity; + return Game->RegisterObject(Entity); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { + m_Type = OBJECT_REGION; + m_Region = Region; + return Game->RegisterObject(Region); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Entity)); + PersistMgr->Transfer(TMEMBER(m_Region)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdSceneNode.h b/engines/wintermute/AdSceneNode.h new file mode 100644 index 0000000000..94bd6f9aab --- /dev/null +++ b/engines/wintermute/AdSceneNode.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdSceneNode_H__ +#define __WmeAdSceneNode_H__ + + +#include "AdTypes.h" // Added by ClassView +#include "AdRegion.h" // Added by ClassView +#include "AdEntity.h" + +namespace WinterMute { + +class CAdSceneNode : public CBObject { +public: + DECLARE_PERSISTENT(CAdSceneNode, CBObject) + HRESULT SetRegion(CAdRegion *Region); + HRESULT SetEntity(CAdEntity *Entity); + CAdEntity *m_Entity; + CAdRegion *m_Region; + TObjectType m_Type; + CAdSceneNode(CBGame *inGame); + virtual ~CAdSceneNode(); + +}; + +} + +#endif diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp new file mode 100644 index 0000000000..7ed571a711 --- /dev/null +++ b/engines/wintermute/AdSceneState.cpp @@ -0,0 +1,87 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "persistent.h" +#include "AdSceneState.h" +#include "AdNodeState.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneState, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { + m_Filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::~CAdSceneState() { + SAFE_DELETE_ARRAY(m_Filename); + + for (int i = 0; i < m_NodeStates.GetSize(); i++) delete m_NodeStates[i]; + m_NodeStates.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_Filename)); + m_NodeStates.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSceneState::SetFilename(char *Filename) { + SAFE_DELETE_ARRAY(m_Filename); + m_Filename = new char [strlen(Filename) + 1]; + if (m_Filename) strcpy(m_Filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { + for (int i = 0; i < m_NodeStates.GetSize(); i++) { + if (scumm_stricmp(m_NodeStates[i]->m_Name, Name) == 0) return m_NodeStates[i]; + } + + if (Saving) { + CAdNodeState *ret = new CAdNodeState(Game); + ret->SetName(Name); + m_NodeStates.Add(ret); + + return ret; + } else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h new file mode 100644 index 0000000000..6abb5c9a7f --- /dev/null +++ b/engines/wintermute/AdSceneState.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdSceneState_H__ +#define __WmeAdSceneState_H__ + +#include "persistent.h" +#include "BBase.h" +#include "coll_templ.h" + +namespace WinterMute { +class CAdNodeState; +class CAdSceneState : public CBBase { +public: + CAdNodeState *GetNodeState(char *Name, bool Saving); + void SetFilename(char *Filename); + DECLARE_PERSISTENT(CAdSceneState, CBBase) + CAdSceneState(CBGame *inGame); + virtual ~CAdSceneState(); + char *m_Filename; + CBArray m_NodeStates; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp new file mode 100644 index 0000000000..f9574302ed --- /dev/null +++ b/engines/wintermute/AdSentence.cpp @@ -0,0 +1,317 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdSentence.h" +#include "AdTalkDef.h" +#include "AdTalkNode.h" +#include "AdGame.h" +#include "PathUtil.h" +#include "BGame.h" +#include "BSound.h" +#include "AdScene.h" +#include "BFont.h" +#include "BSprite.h" +#include "BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSentence, false) + +////////////////////////////////////////////////////////////////////////// +CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { + m_Text = NULL; + m_Stances = NULL; + m_TempStance = NULL; + + m_Duration = 0; + m_StartTime = 0; + m_CurrentStance = 0; + + m_Font = NULL; + + m_Pos.x = m_Pos.y = 0; + m_Width = Game->m_Renderer->m_Width; + + m_Align = (TTextAlign)TAL_CENTER; + + m_Sound = NULL; + m_SoundStarted = false; + + m_TalkDef = NULL; + m_CurrentSprite = NULL; + m_CurrentSkelAnim = NULL; + m_FixedPos = false; + m_Freezable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSentence::~CAdSentence() { + delete m_Sound; + delete[] m_Text; + delete[] m_Stances; + delete[] m_TempStance; + delete m_TalkDef; + m_Sound = NULL; + m_Text = NULL; + m_Stances = NULL; + m_TempStance = NULL; + m_TalkDef = NULL; + + m_CurrentSprite = NULL; // ref only + m_CurrentSkelAnim = NULL; + m_Font = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetText(char *Text) { + if (m_Text) delete [] m_Text; + m_Text = new char[strlen(Text) + 1]; + if (m_Text) strcpy(m_Text, Text); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetStances(char *Stances) { + if (m_Stances) delete [] m_Stances; + if (Stances) { + m_Stances = new char[strlen(Stances) + 1]; + if (m_Stances) strcpy(m_Stances, Stances); + } else m_Stances = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetCurrentStance() { + return GetStance(m_CurrentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetNextStance() { + m_CurrentStance++; + return GetStance(m_CurrentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetStance(int Stance) { + if (m_Stances == NULL) return NULL; + + if (m_TempStance) delete [] m_TempStance; + m_TempStance = NULL; + + char *start; + char *curr; + int pos; + + if (Stance == 0) start = m_Stances; + else { + pos = 0; + start = NULL; + curr = m_Stances; + while (pos < Stance) { + if (*curr == '\0') break; + if (*curr == ',') pos++; + curr++; + } + if (pos == Stance) start = curr; + } + + if (start == NULL) return NULL; + + while (*start == ' ' && *start != ',' && *start != '\0') start++; + + curr = start; + while (*curr != '\0' && *curr != ',') curr++; + + while (curr > start && *(curr - 1) == ' ') curr--; + + m_TempStance = new char [curr - start + 1]; + if (m_TempStance) { + m_TempStance[curr - start] = '\0'; + strncpy(m_TempStance, start, curr - start); + } + + return m_TempStance; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Display() { + if (!m_Font || !m_Text) return E_FAIL; + + if (m_Sound && !m_SoundStarted) { + m_Sound->Play(); + m_SoundStarted = true; + } + + if (Game->m_Subtitles) { + int x = m_Pos.x; + int y = m_Pos.y; + + if (!m_FixedPos) { + x = x - ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); + y = y - ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + } + + + x = std::max(x, 0); + x = std::min(x, Game->m_Renderer->m_Width - m_Width); + y = std::max(y, 0); + + m_Font->DrawText((byte *)m_Text, x, y, m_Width, m_Align); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetSound(CBSound *Sound) { + if (!Sound) return; + delete m_Sound; + m_Sound = Sound; + m_SoundStarted = false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Finish() { + if (m_Sound) m_Sound->Stop(); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER_INT(m_Align)); + PersistMgr->Transfer(TMEMBER(m_CurrentStance)); + PersistMgr->Transfer(TMEMBER(m_CurrentSprite)); + PersistMgr->Transfer(TMEMBER(m_CurrentSkelAnim)); + PersistMgr->Transfer(TMEMBER(m_Duration)); + PersistMgr->Transfer(TMEMBER(m_Font)); + PersistMgr->Transfer(TMEMBER(m_Pos)); + PersistMgr->Transfer(TMEMBER(m_Sound)); + PersistMgr->Transfer(TMEMBER(m_SoundStarted)); + PersistMgr->Transfer(TMEMBER(m_Stances)); + PersistMgr->Transfer(TMEMBER(m_StartTime)); + PersistMgr->Transfer(TMEMBER(m_TalkDef)); + PersistMgr->Transfer(TMEMBER(m_TempStance)); + PersistMgr->Transfer(TMEMBER(m_Text)); + PersistMgr->Transfer(TMEMBER(m_Width)); + PersistMgr->Transfer(TMEMBER(m_FixedPos)); + PersistMgr->Transfer(TMEMBER(m_Freezable)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::SetupTalkFile(char *SoundFilename) { + delete m_TalkDef; + m_TalkDef = NULL; + m_CurrentSprite = NULL; + + if (!SoundFilename) return S_OK; + + + AnsiString path = PathUtil::GetDirectoryName(SoundFilename); + AnsiString name = PathUtil::GetFileNameWithoutExtension(SoundFilename); + + AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); + + CBFile *file = Game->m_FileManager->OpenFile(talkDefFileName.c_str()); + if (file) { + Game->m_FileManager->CloseFile(file); + } else return S_OK; // no talk def file found + + + m_TalkDef = new CAdTalkDef(Game); + if (!m_TalkDef || FAILED(m_TalkDef->LoadFile(talkDefFileName.c_str()))) { + delete m_TalkDef; + m_TalkDef = NULL; + return E_FAIL; + } + //Game->LOG(0, "Using .talk file: %s", TalkDefFile); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Update(TDirection Dir) { + if (!m_TalkDef) return S_OK; + + uint32 CurrentTime; + // if sound is available, synchronize with sound, otherwise use timer + + /* + if(m_Sound) CurrentTime = m_Sound->GetPositionTime(); + else CurrentTime = Game->m_Timer - m_StartTime; + */ + CurrentTime = Game->m_Timer - m_StartTime; + + bool TalkNodeFound = false; + for (int i = 0; i < m_TalkDef->m_Nodes.GetSize(); i++) { + if (m_TalkDef->m_Nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { + TalkNodeFound = true; + + CBSprite *NewSprite = m_TalkDef->m_Nodes[i]->GetSprite(Dir); + if (NewSprite != m_CurrentSprite) NewSprite->Reset(); + m_CurrentSprite = NewSprite; + + if (!m_TalkDef->m_Nodes[i]->m_PlayToEnd) break; + } + } + + + // no talk node, try to use default sprite instead (if any) + if (!TalkNodeFound) { + CBSprite *NewSprite = m_TalkDef->GetDefaultSprite(Dir); + if (NewSprite) { + if (NewSprite != m_CurrentSprite) NewSprite->Reset(); + m_CurrentSprite = NewSprite; + } else m_CurrentSprite = NULL; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::CanSkip() { + // prevent accidental sentence skipping (TODO make configurable) + return (Game->m_Timer - m_StartTime) > 300; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h new file mode 100644 index 0000000000..863f5569f1 --- /dev/null +++ b/engines/wintermute/AdSentence.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdSentence_H__ +#define __WmeAdSentence_H__ + + +#include "BBase.h" +#include "persistent.h" +#include "dctypes.h" // Added by ClassView + +namespace WinterMute { +class CAdTalkDef; +class CBFont; +class CBSprite; +class CBSound; +class CAdSentence : public CBBase { +public: + bool m_Freezable; + bool m_FixedPos; + CBSprite *m_CurrentSprite; + char *m_CurrentSkelAnim; + HRESULT Update(TDirection Dir = DI_DOWN); + HRESULT SetupTalkFile(char *SoundFilename); + DECLARE_PERSISTENT(CAdSentence, CBBase) + HRESULT Finish(); + void SetSound(CBSound *Sound); + bool m_SoundStarted; + CBSound *m_Sound; + TTextAlign m_Align; + HRESULT Display(); + int m_Width; + POINT m_Pos; + CBFont *m_Font; + char *GetNextStance(); + char *GetCurrentStance(); + void SetStances(char *Stances); + void SetText(char *Text); + int m_CurrentStance; + uint32 m_StartTime; + char *m_Stances; + char *m_Text; + uint32 m_Duration; + CAdSentence(CBGame *inGame); + virtual ~CAdSentence(); + CAdTalkDef *m_TalkDef; + + bool CanSkip(); + +private: + char *m_TempStance; + char *GetStance(int Stance); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp new file mode 100644 index 0000000000..f5974c9662 --- /dev/null +++ b/engines/wintermute/AdSpriteSet.cpp @@ -0,0 +1,312 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdSpriteSet.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "BGame.h" +#include "BFileManager.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSpriteSet, false) + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *Owner): CBObject(inGame) { + m_Owner = Owner; + + for (int i = 0; i < NUM_DIRECTIONS; i++) + m_Sprites[i] = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::~CAdSpriteSet() { + for (int i = 0; i < NUM_DIRECTIONS; i++) { + delete m_Sprites[i]; + m_Sprites[i] = NULL; + } + + m_Owner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SPRITESET) +TOKEN_DEF(NAME) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(RIGHT) +TOKEN_DEF(UP) +TOKEN_DEF(DOWN) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(NAME) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(RIGHT) + TOKEN_TABLE(UP) + TOKEN_TABLE(DOWN) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + Game->LOG(0, "'SPRITESET' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CBSprite *spr = NULL; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_LEFT: + delete m_Sprites[DI_LEFT]; + m_Sprites[DI_LEFT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_LEFT] = spr; + break; + + case TOKEN_RIGHT: + delete m_Sprites[DI_RIGHT]; + m_Sprites[DI_RIGHT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_RIGHT] = spr; + break; + + case TOKEN_UP: + delete m_Sprites[DI_UP]; + m_Sprites[DI_UP] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_UP] = spr; + break; + + case TOKEN_DOWN: + delete m_Sprites[DI_DOWN]; + m_Sprites[DI_DOWN] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_DOWN] = spr; + break; + + case TOKEN_UP_LEFT: + delete m_Sprites[DI_UPLEFT]; + m_Sprites[DI_UPLEFT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_UPLEFT] = spr; + break; + + case TOKEN_UP_RIGHT: + delete m_Sprites[DI_UPRIGHT]; + m_Sprites[DI_UPRIGHT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_UPRIGHT] = spr; + break; + + case TOKEN_DOWN_LEFT: + delete m_Sprites[DI_DOWNLEFT]; + m_Sprites[DI_DOWNLEFT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_DOWNLEFT] = spr; + break; + + case TOKEN_DOWN_RIGHT: + delete m_Sprites[DI_DOWNRIGHT]; + m_Sprites[DI_DOWNRIGHT] = NULL; + spr = new CBSprite(Game, m_Owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else m_Sprites[DI_DOWNRIGHT] = spr; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SPRITESET definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading SPRITESET definition"); + if (spr) delete spr; + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Owner)); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + PersistMgr->Transfer("", &m_Sprites[i]); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { + int Dir = (int)Direction; + if (Dir < 0) Dir = 0; + if (Dir >= NUM_DIRECTIONS) Dir = NUM_DIRECTIONS - 1; + + CBSprite *ret = NULL; + + // find nearest set sprite + int i; + int NumSteps = 0; + for (i = Dir, NumSteps = 0; i >= 0; i--) { + if (m_Sprites[i] != NULL) { + ret = m_Sprites[i]; + NumSteps = Dir - i; + break; + } + } + + for (i = Dir; i < NUM_DIRECTIONS; i++) { + if (m_Sprites[i] != NULL) { + if (ret == NULL || NumSteps > i - Dir) return m_Sprites[i]; + else return ret; + } + } + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SPRITESET {\n"); + if (m_Name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (m_Sprites[i]) { + switch (i) { + case DI_UP: + Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_UPRIGHT: + Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_RIGHT: + Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_DOWNRIGHT: + Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_DOWN: + Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_DOWNLEFT: + Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_LEFT: + Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + case DI_UPLEFT: + Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + break; + } + } + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { + if (!Sprite) return NULL; + + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (m_Sprites[i] == Sprite) return true; + } + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h new file mode 100644 index 0000000000..08b1606962 --- /dev/null +++ b/engines/wintermute/AdSpriteSet.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdSpriteSet_H__ +#define __WmeAdSpriteSet_H__ + + +#include "BObject.h" +#include "BSprite.h" // Added by ClassView + +namespace WinterMute { + +class CAdSpriteSet : public CBObject { +public: + bool ContainsSprite(CBSprite *Sprite); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + CBSprite *GetSprite(TDirection Direction); + DECLARE_PERSISTENT(CAdSpriteSet, CBObject) + CBObject *m_Owner; + CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); + virtual ~CAdSpriteSet(); + HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + CBSprite *m_Sprites[NUM_DIRECTIONS]; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdTalkDef.cpp b/engines/wintermute/AdTalkDef.cpp new file mode 100644 index 0000000000..77a1c86769 --- /dev/null +++ b/engines/wintermute/AdTalkDef.cpp @@ -0,0 +1,260 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdTalkDef.h" +#include "AdTalkNode.h" +#include "BParser.h" +#include "BGame.h" +#include "BDynBuffer.h" +#include "BSprite.h" +#include "AdSpriteSet.h" +#include "BFileManager.h" +#include "utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkDef, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { + m_DefaultSpriteFilename = NULL; + m_DefaultSprite = NULL; + + m_DefaultSpriteSetFilename = NULL; + m_DefaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::~CAdTalkDef() { + for (int i = 0; i < m_Nodes.GetSize(); i++) delete m_Nodes[i]; + m_Nodes.RemoveAll(); + + delete[] m_DefaultSpriteFilename; + delete m_DefaultSprite; + m_DefaultSpriteFilename = NULL; + m_DefaultSprite = NULL; + + delete[] m_DefaultSpriteSetFilename; + delete m_DefaultSpriteSet; + m_DefaultSpriteSetFilename = NULL; + m_DefaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadFile(const char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + CBUtils::SetString(&m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TALK) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(ACTION) +TOKEN_DEF(DEFAULT_SPRITESET_FILE) +TOKEN_DEF(DEFAULT_SPRITESET) +TOKEN_DEF(DEFAULT_SPRITE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(DEFAULT_SPRITESET_FILE) + TOKEN_TABLE(DEFAULT_SPRITESET) + TOKEN_TABLE(DEFAULT_SPRITE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TALK) { + Game->LOG(0, "'TALK' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_ACTION: { + CAdTalkNode *Node = new CAdTalkNode(Game); + if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) m_Nodes.Add(Node); + else { + delete Node; + Node = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_DEFAULT_SPRITE: + CBUtils::SetString(&m_DefaultSpriteFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET_FILE: + CBUtils::SetString(&m_DefaultSpriteSetFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET: { + delete m_DefaultSpriteSet; + m_DefaultSpriteSet = new CAdSpriteSet(Game); + if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadBuffer(params, false))) { + delete m_DefaultSpriteSet; + m_DefaultSpriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TALK definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading TALK definition"); + return E_FAIL; + } + + delete m_DefaultSprite; + delete m_DefaultSpriteSet; + m_DefaultSprite = NULL; + m_DefaultSpriteSet = NULL; + + if (m_DefaultSpriteFilename) { + m_DefaultSprite = new CBSprite(Game); + if (!m_DefaultSprite || FAILED(m_DefaultSprite->LoadFile(m_DefaultSpriteFilename))) return E_FAIL; + } + + if (m_DefaultSpriteSetFilename) { + m_DefaultSpriteSet = new CAdSpriteSet(Game); + if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadFile(m_DefaultSpriteSetFilename))) return E_FAIL; + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_DefaultSprite)); + PersistMgr->Transfer(TMEMBER(m_DefaultSpriteFilename)); + PersistMgr->Transfer(TMEMBER(m_DefaultSpriteSet)); + PersistMgr->Transfer(TMEMBER(m_DefaultSpriteSetFilename)); + + m_Nodes.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "TALK {\n"); + if (m_DefaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", m_DefaultSpriteFilename); + + if (m_DefaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", m_DefaultSpriteSetFilename); + else if (m_DefaultSpriteSet) m_DefaultSpriteSet->SaveAsText(Buffer, Indent + 2); + + for (int i = 0; i < m_Nodes.GetSize(); i++) { + m_Nodes[i]->SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "\n"); + } + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadDefaultSprite() { + if (m_DefaultSpriteFilename && !m_DefaultSprite) { + m_DefaultSprite = new CBSprite(Game); + if (!m_DefaultSprite || FAILED(m_DefaultSprite->LoadFile(m_DefaultSpriteFilename))) { + delete m_DefaultSprite; + m_DefaultSprite = NULL; + return E_FAIL; + } else return S_OK; + } else if (m_DefaultSpriteSetFilename && !m_DefaultSpriteSet) { + m_DefaultSpriteSet = new CAdSpriteSet(Game); + if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadFile(m_DefaultSpriteSetFilename))) { + delete m_DefaultSpriteSet; + m_DefaultSpriteSet = NULL; + return E_FAIL; + } else return S_OK; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkDef::GetDefaultSprite(TDirection Dir) { + LoadDefaultSprite(); + if (m_DefaultSprite) return m_DefaultSprite; + else if (m_DefaultSpriteSet) return m_DefaultSpriteSet->GetSprite(Dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkDef.h b/engines/wintermute/AdTalkDef.h new file mode 100644 index 0000000000..4702a10fd6 --- /dev/null +++ b/engines/wintermute/AdTalkDef.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdTalkDef_H__ +#define __WmeAdTalkDef_H__ + +#include "coll_templ.h" +#include "BObject.h" + +namespace WinterMute { +class CAdTalkNode; +class CAdSpriteSet; +class CAdTalkDef : public CBObject { +public: + char *m_DefaultSpriteSetFilename; + CAdSpriteSet *m_DefaultSpriteSet; + CBSprite *GetDefaultSprite(TDirection Dir); + HRESULT LoadDefaultSprite(); + DECLARE_PERSISTENT(CAdTalkDef, CBObject) + + CAdTalkDef(CBGame *inGame); + virtual ~CAdTalkDef(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CBArray m_Nodes; + char *m_DefaultSpriteFilename; + CBSprite *m_DefaultSprite; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp new file mode 100644 index 0000000000..228fb77d03 --- /dev/null +++ b/engines/wintermute/AdTalkHolder.cpp @@ -0,0 +1,355 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdTalkHolder.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "ScScript.h" +#include "ScStack.h" +#include "BGame.h" +#include "BSprite.h" +#include "PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkHolder, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { + m_Sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::~CAdTalkHolder() { + delete m_Sprite; + m_Sprite = NULL; + + int i; + for (i = 0; i < m_TalkSprites.GetSize(); i++) delete m_TalkSprites[i]; + m_TalkSprites.RemoveAll(); + + for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) delete m_TalkSpritesEx[i]; + m_TalkSpritesEx.RemoveAll(); +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkHolder::GetTalkStance(char *Stance) { + CBSprite *ret = NULL; + + + // forced stance? + if (m_ForcedTalkAnimName && !m_ForcedTalkAnimUsed) { + m_ForcedTalkAnimUsed = true; + delete m_AnimSprite; + m_AnimSprite = new CBSprite(Game, this); + if (m_AnimSprite) { + HRESULT res = m_AnimSprite->LoadFile(m_ForcedTalkAnimName); + if (FAILED(res)) { + Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", m_Name, m_ForcedTalkAnimName); + delete m_AnimSprite; + m_AnimSprite = NULL; + } else return m_AnimSprite; + } + } + + + if (Stance != NULL) { + // search special talk stances + for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(m_TalkSpritesEx[i]->m_Name, Stance) == 0) { + ret = m_TalkSpritesEx[i]; + break; + } + } + if (ret == NULL) { + // serach generic talk stances + for (int i = 0; i < m_TalkSprites.GetSize(); i++) { + if (scumm_stricmp(m_TalkSprites[i]->m_Name, Stance) == 0) { + ret = m_TalkSprites[i]; + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (m_TalkSprites.GetSize() < 1) ret = m_Sprite; + else { + // TODO: remember last + int rnd = rand() % m_TalkSprites.GetSize(); + ret = m_TalkSprites[rnd]; + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSprite") == 0) { + Stack->CorrectParams(1); + + CScValue *Val = Stack->Pop(); + + bool SetCurrent = false; + if (m_CurrentSprite && m_CurrentSprite == m_Sprite) SetCurrent = true; + + delete m_Sprite; + m_Sprite = NULL; + + if (Val->IsNULL()) { + m_Sprite = NULL; + if (SetCurrent) m_CurrentSprite = NULL; + Stack->PushBool(true); + } else { + char *Filename = Val->GetString(); + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Script->RuntimeError("SetSprite method failed for file '%s'", Filename); + Stack->PushBool(false); + } else { + m_Sprite = spr; + if (SetCurrent) m_CurrentSprite = m_Sprite; + Stack->PushBool(true); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSprite") == 0) { + Stack->CorrectParams(0); + + if (!m_Sprite || !m_Sprite->m_Filename) Stack->PushNULL(); + else Stack->PushString(m_Sprite->m_Filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSpriteObject") == 0) { + Stack->CorrectParams(0); + + if (!m_Sprite) Stack->PushNULL(); + else Stack->PushNative(m_Sprite, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddTalkSprite") == 0) { + Stack->CorrectParams(2); + + char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); + } else { + if (Ex) m_TalkSpritesEx.Add(spr); + else m_TalkSprites.Add(spr); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveTalkSprite") == 0) { + Stack->CorrectParams(2); + + char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + int i; + + bool SetCurrent = false; + bool SetTemp2 = false; + + if (Ex) { + for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(m_TalkSpritesEx[i]->m_Filename, Filename) == 0) { + if (m_CurrentSprite == m_TalkSpritesEx[i]) SetCurrent = true; + if (m_TempSprite2 == m_TalkSpritesEx[i]) SetTemp2 = true; + delete m_TalkSpritesEx[i]; + m_TalkSpritesEx.RemoveAt(i); + break; + } + } + } else { + for (i = 0; i < m_TalkSprites.GetSize(); i++) { + if (scumm_stricmp(m_TalkSprites[i]->m_Filename, Filename) == 0) { + if (m_CurrentSprite == m_TalkSprites[i]) SetCurrent = true; + if (m_TempSprite2 == m_TalkSprites[i]) SetTemp2 = true; + delete m_TalkSprites[i]; + m_TalkSprites.RemoveAt(i); + break; + } + } + + } + + Stack->PushBool(true); + if (SetCurrent) m_CurrentSprite = m_Sprite; + if (SetTemp2) m_TempSprite2 = m_Sprite; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetTalkSprite") == 0) { + Stack->CorrectParams(2); + + char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + bool SetCurrent = false; + bool SetTemp2 = false; + + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); + } else { + + // delete current + int i; + if (Ex) { + for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + if (m_TalkSpritesEx[i] == m_CurrentSprite) SetCurrent = true; + if (m_TalkSpritesEx[i] == m_TempSprite2) SetTemp2 = true; + delete m_TalkSpritesEx[i]; + } + m_TalkSpritesEx.RemoveAll(); + } else { + for (i = 0; i < m_TalkSprites.GetSize(); i++) { + if (m_TalkSprites[i] == m_CurrentSprite) SetCurrent = true; + if (m_TalkSprites[i] == m_TempSprite2) SetTemp2 = true; + delete m_TalkSprites[i]; + } + m_TalkSprites.RemoveAll(); + } + + // set new + if (Ex) m_TalkSpritesEx.Add(spr); + else m_TalkSprites.Add(spr); + Stack->PushBool(true); + + if (SetCurrent) m_CurrentSprite = spr; + if (SetTemp2) m_TempSprite2 = spr; + } + return S_OK; + } + + else return CAdObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdTalkHolder::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("talk-holder"); + return m_ScValue; + } + + else return CAdObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::ScSetProperty(char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Item")==0){ + SetItem(Value->GetString()); + return S_OK; + } + + else*/ return CAdObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdTalkHolder::ScToString() { + return "[talk-holder object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { + int i; + for (i = 0; i < m_TalkSprites.GetSize(); i++) { + if (m_TalkSprites[i]->m_Filename) + Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", m_TalkSprites[i]->m_Filename); + } + + for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { + if (m_TalkSpritesEx[i]->m_Filename) + Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", m_TalkSpritesEx[i]->m_Filename); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::Persist(CBPersistMgr *PersistMgr) { + CAdObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Sprite)); + m_TalkSprites.Persist(PersistMgr); + m_TalkSpritesEx.Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkNode.cpp b/engines/wintermute/AdTalkNode.cpp new file mode 100644 index 0000000000..03c0d90609 --- /dev/null +++ b/engines/wintermute/AdTalkNode.cpp @@ -0,0 +1,263 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "dcgf.h" +#include "AdTalkNode.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "BGame.h" +#include "BSprite.h" +#include "AdSpriteSet.h" +#include "utils.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { + m_Sprite = NULL; + m_SpriteFilename = NULL; + m_SpriteSet = NULL; + m_SpriteSetFilename = NULL; + m_Comment = NULL; + + m_StartTime = m_EndTime = 0; + m_PlayToEnd = false; + m_PreCache = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::~CAdTalkNode() { + delete[] m_SpriteFilename; + delete m_Sprite; + delete[] m_SpriteSetFilename; + delete m_SpriteSet; + delete m_Comment; + m_SpriteFilename = NULL; + m_Sprite = NULL; + m_SpriteSetFilename = NULL; + m_SpriteSet = NULL; + m_Comment = NULL; +} + + + +TOKEN_DEF_START +TOKEN_DEF(ACTION) +TOKEN_DEF(SPRITESET_FILE) +TOKEN_DEF(SPRITESET) +TOKEN_DEF(SPRITE) +TOKEN_DEF(START_TIME) +TOKEN_DEF(END_TIME) +TOKEN_DEF(COMMENT) +TOKEN_DEF(PRECACHE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(SPRITESET_FILE) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(START_TIME) + TOKEN_TABLE(END_TIME) + TOKEN_TABLE(COMMENT) + TOKEN_TABLE(PRECACHE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + Game->LOG(0, "'ACTION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + m_EndTime = 0; + m_PlayToEnd = false; + m_PreCache = false; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SPRITE: + CBUtils::SetString(&m_SpriteFilename, (char *)params); + break; + + case TOKEN_SPRITESET_FILE: + CBUtils::SetString(&m_SpriteSetFilename, (char *)params); + break; + + case TOKEN_SPRITESET: { + delete m_SpriteSet; + m_SpriteSet = new CAdSpriteSet(Game); + if (!m_SpriteSet || FAILED(m_SpriteSet->LoadBuffer(params, false))) { + delete m_SpriteSet; + m_SpriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_START_TIME: + parser.ScanStr((char *)params, "%d", &m_StartTime); + break; + + case TOKEN_END_TIME: + parser.ScanStr((char *)params, "%d", &m_EndTime); + break; + + case TOKEN_PRECACHE: + parser.ScanStr((char *)params, "%b", &m_PreCache); + break; + + case TOKEN_COMMENT: + if (Game->m_EditorMode) CBUtils::SetString(&m_Comment, (char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ACTION definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ACTION definition"); + return E_FAIL; + } + + if (m_EndTime == 0) m_PlayToEnd = true; + else m_PlayToEnd = false; + + if (m_PreCache && m_SpriteFilename) { + delete m_Sprite; + m_Sprite = new CBSprite(Game); + if (!m_Sprite || FAILED(m_Sprite->LoadFile(m_SpriteFilename))) return E_FAIL; + } + + if (m_PreCache && m_SpriteSetFilename) { + delete m_SpriteSet; + m_SpriteSet = new CAdSpriteSet(Game); + if (!m_SpriteSet || FAILED(m_SpriteSet->LoadFile(m_SpriteSetFilename))) return E_FAIL; + } + + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_Comment)); + PersistMgr->Transfer(TMEMBER(m_StartTime)); + PersistMgr->Transfer(TMEMBER(m_EndTime)); + PersistMgr->Transfer(TMEMBER(m_PlayToEnd)); + PersistMgr->Transfer(TMEMBER(m_Sprite)); + PersistMgr->Transfer(TMEMBER(m_SpriteFilename)); + PersistMgr->Transfer(TMEMBER(m_SpriteSet)); + PersistMgr->Transfer(TMEMBER(m_SpriteSetFilename)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ACTION {\n"); + if (m_Comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", m_Comment); + Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", m_StartTime); + if (!m_PlayToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", m_EndTime); + if (m_SpriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", m_SpriteFilename); + if (m_SpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", m_SpriteSetFilename); + else if (m_SpriteSet) m_SpriteSet->SaveAsText(Buffer, Indent + 2); + if (m_PreCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", m_PreCache ? "TRUE" : "FALSE"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::LoadSprite() { + if (m_SpriteFilename && !m_Sprite) { + m_Sprite = new CBSprite(Game); + if (!m_Sprite || FAILED(m_Sprite->LoadFile(m_SpriteFilename))) { + delete m_Sprite; + m_Sprite = NULL; + return E_FAIL; + } else return S_OK; + } + + else if (m_SpriteSetFilename && !m_SpriteSet) { + m_SpriteSet = new CAdSpriteSet(Game); + if (!m_SpriteSet || FAILED(m_SpriteSet->LoadFile(m_SpriteSetFilename))) { + delete m_SpriteSet; + m_SpriteSet = NULL; + return E_FAIL; + } else return S_OK; + } + + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { + if (Time >= m_StartTime) { + if (m_PlayToEnd) { + if ((m_SpriteFilename && m_Sprite == NULL) || (m_Sprite && m_Sprite->m_Finished == false)) return true; + else if ((m_SpriteSetFilename && m_SpriteSet == NULL) || (m_SpriteSet && m_SpriteSet->GetSprite(Dir) && m_SpriteSet->GetSprite(Dir)->m_Finished == false)) return true; + else return false; + } else return m_EndTime >= Time; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkNode::GetSprite(TDirection Dir) { + LoadSprite(); + if (m_Sprite) return m_Sprite; + else if (m_SpriteSet) return m_SpriteSet->GetSprite(Dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkNode.h b/engines/wintermute/AdTalkNode.h new file mode 100644 index 0000000000..3587cdb57b --- /dev/null +++ b/engines/wintermute/AdTalkNode.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdTalkNode_H__ +#define __WmeAdTalkNode_H__ + +#include "persistent.h" +#include "BBase.h" + +namespace WinterMute { +class CAdSpriteSet; +class CBSprite; +class CAdTalkNode : public CBBase { +public: + char *m_SpriteSetFilename; + CAdSpriteSet *m_SpriteSet; + CBSprite *GetSprite(TDirection Dir); + bool IsInTimeInterval(uint32 Time, TDirection Dir); + HRESULT LoadSprite(); + DECLARE_PERSISTENT(CAdTalkNode, CBBase) + + CAdTalkNode(CBGame *inGame); + virtual ~CAdTalkNode(); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + char *m_SpriteFilename; + CBSprite *m_Sprite; + uint32 m_StartTime; + uint32 m_EndTime; + bool m_PlayToEnd; + bool m_PreCache; + char *m_Comment; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp new file mode 100644 index 0000000000..265612934f --- /dev/null +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -0,0 +1,260 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "AdWaypointGroup.h" +#include "BParser.h" +#include "BDynBuffer.h" +#include "ScValue.h" +#include "BGame.h" +#include "BRegion.h" +#include "BFileManager.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { + m_Active = true; + m_EditorSelectedPoint = -1; + m_LastMimicScale = -1; + m_LastMimicX = m_LastMimicY = INT_MIN; +} + + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::~CAdWaypointGroup() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdWaypointGroup::Cleanup() { + for (int i = 0; i < m_Points.GetSize(); i++) + delete m_Points[i]; + m_Points.RemoveAll(); + m_EditorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::LoadFile(char *Filename) { + byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + m_Filename = new char [strlen(Filename) + 1]; + strcpy(m_Filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(POINT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(POINT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + Game->LOG(0, "'WAYPOINTS' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + m_Points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &m_EditorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in WAYPOINTS definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", m_EditorSelectedPoint); + + if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + CBBase::SaveAsText(Buffer, Indent + 2); + + for (int i = 0; i < m_Points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + } + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Active)); + PersistMgr->Transfer(TMEMBER(m_EditorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(m_LastMimicScale)); + PersistMgr->Transfer(TMEMBER(m_LastMimicX)); + PersistMgr->Transfer(TMEMBER(m_LastMimicY)); + m_Points.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdWaypointGroup::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("waypoint-group"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + m_ScValue->SetBool(m_Active); + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Active") == 0) { + m_Active = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { + if (Scale == m_LastMimicScale && X == m_LastMimicX && Y == m_LastMimicY) return S_OK; + + Cleanup(); + + for (int i = 0; i < Wpt->m_Points.GetSize(); i++) { + int x, y; + + x = (int)((float)Wpt->m_Points[i]->x * Scale / 100.0f); + y = (int)((float)Wpt->m_Points[i]->y * Scale / 100.0f); + + m_Points.Add(new CBPoint(x + X, y + Y)); + } + + m_LastMimicScale = Scale; + m_LastMimicX = X; + m_LastMimicY = Y; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h new file mode 100644 index 0000000000..50992f1387 --- /dev/null +++ b/engines/wintermute/AdWaypointGroup.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeAdWaypointGroup_H__ +#define __WmeAdWaypointGroup_H__ + +#include "BObject.h" + +namespace WinterMute { +class CBPoint; +class CAdWaypointGroup : public CBObject { +public: + float m_LastMimicScale; + int m_LastMimicX; + int m_LastMimicY; + void Cleanup(); + HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); + DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + bool m_Active; + CAdWaypointGroup(CBGame *inGame); + HRESULT LoadFile(char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual ~CAdWaypointGroup(); + CBArray m_Points; + int m_EditorSelectedPoint; + virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(char *Name, CScValue *Value); +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From ff64c8d107b23178b790232a489eecf8924abccd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 04:53:30 +0100 Subject: WINTERMUTE: Add most of the Ad-Classes to module.mk --- engines/wintermute/AdActor.cpp | 46 ++++++++++++++++------------------ engines/wintermute/AdInventoryBox.cpp | 12 ++++----- engines/wintermute/AdItem.cpp | 32 +++++++++++------------ engines/wintermute/AdLayer.cpp | 6 ++--- engines/wintermute/AdObject.cpp | 8 +++--- engines/wintermute/AdRegion.cpp | 4 +-- engines/wintermute/AdResponseBox.cpp | 4 +-- engines/wintermute/AdScene.cpp | 6 ++--- engines/wintermute/AdSpriteSet.cpp | 1 + engines/wintermute/AdTalkHolder.cpp | 6 ++--- engines/wintermute/AdWaypointGroup.cpp | 2 +- engines/wintermute/BGame.h | 12 ++++----- engines/wintermute/module.mk | 24 ++++++++++++++++++ 13 files changed, 93 insertions(+), 70 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index a5d269e13a..12aa363df1 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -26,30 +26,28 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "dctypes.h" -#include "persistent.h" -#include "BObject.h" -#include "AdActor.h" -#include "AdGame.h" -#include "BParser.h" -#include "ScValue.h" -#include "ScStack.h" -#include "BObject.h" -#include "BSound.h" -#include "AdScene.h" -#include "AdEntity.h" -#include "AdSpriteSet.h" -#include "AdWaypointGroup.h" -#include "AdPath.h" -#include "AdSentence.h" -#include "AdPath.h" -#include "ScScript.h" -#include "BRegion.h" -#include "BFileManager.h" -#include "AdPath.h" -#include "utils.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/AdActor.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/AdScene.h" +#include "engines/wintermute/AdEntity.h" +#include "engines/wintermute/AdSpriteSet.h" +#include "engines/wintermute/AdWaypointGroup.h" +#include "engines/wintermute/AdPath.h" +#include "engines/wintermute/AdSentence.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" #include namespace WinterMute { diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index afaa139a6a..5af10d5f86 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -26,17 +26,17 @@ * Copyright (c) 2011 Jan Nedoma */ #include "dcgf.h" +#include "AdGame.h" #include "AdInventoryBox.h" #include "AdInventory.h" +#include "AdItem.h" +#include "BGame.h" #include "BParser.h" +#include "BFileManager.h" +#include "BViewport.h" +#include "BDynBuffer.h" #include "UIButton.h" #include "UIWindow.h" -#include "BDynBuffer.h" -#include "BGame.h" -#include "AdGame.h" -#include "AdItem.h" -#include "BViewport.h" -#include "BFileManager.h" #include "PlatformSDL.h" #include "common/str.h" #include diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index 5a2d4d7a58..a1cf0d5b01 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -26,22 +26,22 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "AdItem.h" -#include "BParser.h" -#include "ScValue.h" -#include "BGame.h" -#include "AdGame.h" -#include "BSound.h" -#include "BFontStorage.h" -#include "BFont.h" -#include "AdSentence.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "utils.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/AdItem.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/AdSentence.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 6fc53ede7e..6e55a24161 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -32,9 +32,9 @@ #include "AdSceneNode.h" #include "BParser.h" #include "BDynBuffer.h" -#include "ScValue.h" -#include "ScScript.h" -#include "ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "BFileManager.h" #include "PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 4454d1d0f6..11552b1488 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -33,7 +33,7 @@ #include "BFrame.h" #include "BSound.h" #include "BSurfaceStorage.h" -#include "ScValue.h" +#include "engines/wintermute/scriptables/ScValue.h" #include "AdGame.h" #include "AdLayer.h" #include "AdSceneNode.h" @@ -43,12 +43,12 @@ #include "BSubFrame.h" #include "BFont.h" #include "BFontStorage.h" -#include "ScEngine.h" +#include "engines/wintermute/scriptables/ScEngine.h" #include "BStringTable.h" #include "AdSentence.h" -#include "ScScript.h" +#include "engines/wintermute/scriptables/ScScript.h" #include "BSprite.h" -#include "ScStack.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index 71a36cf636..51b4070f28 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -30,8 +30,8 @@ #include "AdRegion.h" #include "BParser.h" #include "BDynBuffer.h" -#include "ScValue.h" -#include "ScScript.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" #include "BGame.h" #include "BFileManager.h" diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index ff4407fcfc..d2ff7db96f 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -37,8 +37,8 @@ #include "BFontStorage.h" #include "BFont.h" #include "AdResponse.h" -#include "ScScript.h" -#include "ScStack.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "BSprite.h" #include "BFileManager.h" #include "utils.h" diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index 3fb13f5d61..37d9fdeaa5 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -53,9 +53,9 @@ #include "BSprite.h" #include "BViewport.h" #include "PlatformSDL.h" -#include "ScStack.h" -#include "ScValue.h" -#include "ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" #include "UIWindow.h" #include "utils.h" #include diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp index f5974c9662..1940559330 100644 --- a/engines/wintermute/AdSpriteSet.cpp +++ b/engines/wintermute/AdSpriteSet.cpp @@ -32,6 +32,7 @@ #include "BDynBuffer.h" #include "BGame.h" #include "BFileManager.h" + namespace WinterMute { IMPLEMENT_PERSISTENT(CAdSpriteSet, false) diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 228fb77d03..74a089167a 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -29,9 +29,9 @@ #include "dcgf.h" #include "AdTalkHolder.h" #include "BDynBuffer.h" -#include "ScValue.h" -#include "ScScript.h" -#include "ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "BGame.h" #include "BSprite.h" #include "PlatformSDL.h" diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index 265612934f..bbd1cdb92a 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -29,7 +29,7 @@ #include "AdWaypointGroup.h" #include "BParser.h" #include "BDynBuffer.h" -#include "ScValue.h" +#include "engines/wintermute/scriptables/ScValue.h" #include "BGame.h" #include "BRegion.h" #include "BFileManager.h" diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index a13144d325..8b74b2d618 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -92,10 +92,10 @@ public: virtual HRESULT MiniUpdate() {} // <- TODO Unstub #if 0 virtual HRESULT MiniUpdate(); - +#endif void GetMousePos(POINT *Pos); RECT m_MouseLockRect; -#endif + bool m_ShuttingDown; virtual HRESULT DisplayDebugInfo(); @@ -318,9 +318,7 @@ public: uint32 m_LiveTimerLast; CBObject *m_CapturedObject; -#if 0 POINT m_MousePos; -#endif bool ValidObject(CBObject *Object); HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); @@ -332,7 +330,7 @@ public: HRESULT UpdateMusicCrossfade(); CBArray m_RegObjects; - +#endif public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); virtual HRESULT DisplayContentSimple(); @@ -340,6 +338,7 @@ public: void ResetMousePos(); int m_SubtitlesSpeed; void SetInteractive(bool State); +#if 0 virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); #endif @@ -357,11 +356,12 @@ public: CBSaveThumbHelper *m_CachedThumbnail; #if 0 AnsiString GetDataDir(); - +#endif void AddMem(int bytes); bool m_TouchInterface; bool m_ConstrainedMemory; +#if 0 AnsiString GetDeviceType() const; private: diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index a7bac98891..d376f3723a 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -8,6 +8,30 @@ MODULE_OBJS := \ scriptables/SXDate.o \ scriptables/SXMath.o \ scriptables/SXMemBuffer.o \ + AdActor.o \ + AdActorDir.o \ + AdInventory.o \ + AdInventoryBox.o \ + AdItem.o \ + AdLayer.o \ + AdNodeState.o \ + AdObject.o \ + AdPath.o \ + AdPathPoint.o \ + AdRegion.o \ + AdResponse.o \ + AdResponseBox.o \ + AdRotLevel.o \ + AdScaleLevel.o \ + AdScene.o \ + AdSceneNode.o \ + AdSceneState.o \ + AdSentence.o \ + AdSpriteSet.o \ + AdTalkDef.o \ + AdTalkHolder.o \ + AdTalkNode.o \ + AdWaypointGroup.o \ BActiveRect.o \ BDebugger.o \ BDynBuffer.o \ -- cgit v1.2.3 From d5b4474c36575fc5110da4ab850688d09419e27a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 05:43:20 +0100 Subject: WINTERMUTE: Make BGame almost compilable --- engines/wintermute/BGame.cpp | 77 +-- engines/wintermute/BGame.h | 32 +- engines/wintermute/BRenderSDL.h | 3 + engines/wintermute/BScriptHolder.h | 2 - engines/wintermute/crc.h | 81 ++++ engines/wintermute/scriptables/SXFile.cpp | 720 ++++++++++++++++++++++++++++ engines/wintermute/scriptables/SXFile.h | 60 +++ engines/wintermute/scriptables/SXStore.cpp | 508 ++++++++++++++++++++ engines/wintermute/scriptables/SXStore.h | 172 +++++++ engines/wintermute/scriptables/SXString.cpp | 387 +++++++++++++++ engines/wintermute/scriptables/SXString.h | 58 +++ engines/wintermute/scriptables/SxObject.cpp | 60 +++ engines/wintermute/scriptables/SxObject.h | 44 ++ 13 files changed, 2141 insertions(+), 63 deletions(-) create mode 100644 engines/wintermute/crc.h create mode 100644 engines/wintermute/scriptables/SXFile.cpp create mode 100644 engines/wintermute/scriptables/SXFile.h create mode 100644 engines/wintermute/scriptables/SXStore.cpp create mode 100644 engines/wintermute/scriptables/SXStore.h create mode 100644 engines/wintermute/scriptables/SXString.cpp create mode 100644 engines/wintermute/scriptables/SXString.h create mode 100644 engines/wintermute/scriptables/SxObject.cpp create mode 100644 engines/wintermute/scriptables/SxObject.h (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 319e0c5316..a076477b04 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -27,43 +27,46 @@ */ #include -#include "dcgf.h" -#include "BGame.h" -#include "BFile.h" -#include "BFileManager.h" -#include "BFontTT.h" -#include "BFontStorage.h" -#include "BImage.h" -#include "BKeyboardState.h" -#include "BParser.h" -#include "BQuickMsg.h" -#include "BRegistry.h" -#include "BRenderSDL.h" -#include "BSound.h" -#include "BSoundMgr.h" -#include "BSprite.h" -#include "BSubFrame.h" -#include "BSurfaceSDL.h" -#include "BTransitionMgr.h" -#include "BViewport.h" -#include "BStringTable.h" -#include "BRegion.h" -#include "crc.h" -#include "PathUtil.h" -#include "StringUtil.h" -#include "UIWindow.h" -#include "scriptables/ScValue.h" -#include "scriptables/ScEngine.h" -#include "scriptables/ScStack.h" -#include "scriptables/ScScript.h" -#include "scriptables/SXArray.h" -#include "scriptables/SXDate.h" -#include "scriptables/SXString.h" -#include "scriptables/SXMemBuffer.h" -#include "scriptables/SxObject.h" -#include "scriptables/SXFile.h" -#include "scriptables/SXMath.h" -#include "scriptables/SXStore.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFader.h" +#include "engines/wintermute/BFile.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BFontTT.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BImage.h" +#include "engines/wintermute/BKeyboardState.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BQuickMsg.h" +#include "engines/wintermute/BRegistry.h" +#include "engines/wintermute/BRenderSDL.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSoundMgr.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BSurfaceSDL.h" +#include "engines/wintermute/BTransitionMgr.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BSaveThumbHelper.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/crc.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/SXArray.h" +#include "engines/wintermute/scriptables/SXDate.h" +#include "engines/wintermute/scriptables/SXFile.h" +#include "engines/wintermute/scriptables/SXMemBuffer.h" +#include "engines/wintermute/scriptables/SxObject.h" +#include "engines/wintermute/scriptables/SXMath.h" +#include "engines/wintermute/scriptables/SXStore.h" +#include "engines/wintermute/scriptables/SXString.h" #include "common/textconsole.h" #ifdef __IPHONEOS__ diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 8b74b2d618..208b5b414b 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -89,10 +89,8 @@ public: uint32 m_LastMiniUpdate; bool m_MiniUpdateEnabled; - virtual HRESULT MiniUpdate() {} // <- TODO Unstub -#if 0 virtual HRESULT MiniUpdate(); -#endif + void GetMousePos(POINT *Pos); RECT m_MouseLockRect; @@ -103,7 +101,7 @@ public: bool m_SuspendedRendering; int m_SoundBufferSizeSec; -#if 0 + TTextEncoding m_TextEncoding; bool m_TextRTL; @@ -116,7 +114,6 @@ public: void DEBUG_DumpClassRegistry(); HRESULT SetWaitCursor(char *Filename); - char *m_LocalSaveDir; bool m_SaveDirChecked; @@ -152,7 +149,6 @@ public: void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); ENGINE_LOG_CALLBACK m_EngineLogCallback; void *m_EngineLogCallbackData; -#endif bool m_EditorMode; bool m_DoNotExpandStrings; @@ -164,10 +160,9 @@ public: float m_OffsetPercentX; float m_OffsetPercentY; CBObject *m_MainObject; -#if 0 + HRESULT InitInput(HINSTANCE hInst, HWND hWnd); HRESULT InitLoop(); -#endif uint32 m_CurrentTime; uint32 m_DeltaTime; CBFont *m_SystemFont; @@ -178,8 +173,8 @@ public: CBFileManager *m_FileManager; CBTransitionMgr *m_TransMgr; CBDebugger *GetDebugMgr(); -//TODO: STUB - void LOG(HRESULT res, LPCSTR fmt, ...) {} + + void LOG(HRESULT res, LPCSTR fmt, ...); CBRenderer *m_Renderer; CBSoundMgr *m_SoundMgr; @@ -195,7 +190,7 @@ public: void DEBUG_DebugEnable(const char *Filename = NULL); bool m_DEBUG_DebugMode; bool m_DEBUG_AbsolutePathWarning; -#if 0 + FILE *m_DEBUG_LogFile; int m_Sequence; virtual HRESULT LoadFile(const char *Filename); @@ -203,7 +198,7 @@ public: CBArray m_QuickMessages; CBArray m_Windows; CBArray m_ViewportStack; -#endif + int m_ViewportSP; bool m_MouseLeftDown; bool m_MouseRightDown; @@ -278,7 +273,7 @@ public: static void AfterLoadFont(void *Font, void *Data); static void AfterLoadScript(void *script, void *data); static void InvalidateValues(void *Value, void *Data); -#if 0 + HRESULT LoadSettings(char *Filename); HRESULT ResumeMusic(int Channel); HRESULT SetMusicStartTime(int Channel, uint32 Time); @@ -293,7 +288,6 @@ public: int m_MusicCrossfadeChannel1; int m_MusicCrossfadeChannel2; HRESULT DisplayWindows(bool InGame = false); -#endif CBRegistry *m_Registry; bool m_UseD3D; virtual HRESULT Cleanup(); @@ -323,14 +317,12 @@ public: HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); void QuickMessage(char *Text); -#if 0 void QuickMessageForm(LPSTR fmt, ...); HRESULT DisplayQuickMsg(); uint32 m_Fps; HRESULT UpdateMusicCrossfade(); CBArray m_RegObjects; -#endif public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); virtual HRESULT DisplayContentSimple(); @@ -338,30 +330,23 @@ public: void ResetMousePos(); int m_SubtitlesSpeed; void SetInteractive(bool State); -#if 0 virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); -#endif HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); HRESULT PopViewport(); HRESULT PushViewport(CBViewport *Viewport); HRESULT SetActiveObject(CBObject *Obj); -#if 0 CBSprite *m_LastCursor; HRESULT DrawCursor(CBSprite *Cursor); virtual HRESULT InitAfterLoad(); -#endif CBSaveThumbHelper *m_CachedThumbnail; -#if 0 AnsiString GetDataDir(); -#endif void AddMem(int bytes); bool m_TouchInterface; bool m_ConstrainedMemory; -#if 0 AnsiString GetDeviceType() const; private: @@ -392,7 +377,6 @@ protected: public: void AutoSaveOnExit(); -#endif }; diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 3489881e14..11a969946e 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -32,6 +32,9 @@ #include "BRenderer.h" #include "SDL.h" +class SDL_Window; +class SDL_Renderer; + namespace WinterMute { class CBRenderSDL : public CBRenderer { diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index 84a1e73c46..e4a4c0f6f6 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -58,14 +58,12 @@ public: bool m_Ready; CBArray m_Scripts; -#if 0 // scripting interface virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); virtual char *ScToString(); virtual void ScDebuggerDesc(char *Buf, int BufSize); -#endif // IWmeObject public: virtual bool SendEvent(const char *EventName); diff --git a/engines/wintermute/crc.h b/engines/wintermute/crc.h new file mode 100644 index 0000000000..578b423de8 --- /dev/null +++ b/engines/wintermute/crc.h @@ -0,0 +1,81 @@ +/********************************************************************** + * + * Filename: crc.h + * + * Description: A header file describing the various CRC standards. + * + * Notes: + * + * + * Copyright (c) 2000 by Michael Barr. This software is placed into + * the public domain and may be used for any purpose. However, this + * notice must not be changed or removed and no warranty is either + * expressed or implied by its publication or distribution. + **********************************************************************/ + +#ifndef _crc_h +#define _crc_h + +#ifndef TRUE +#define FALSE 0 +#define TRUE !FALSE +#endif + +/* + * Select the CRC standard from the list that follows. + */ +#define CRC32 + + +#if defined(CRC_CCITT) + +typedef unsigned short crc; + +#define CRC_NAME "CRC-CCITT" +#define POLYNOMIAL 0x1021 +#define INITIAL_REMAINDER 0xFFFF +#define FINAL_XOR_VALUE 0x0000 +#define REFLECT_DATA FALSE +#define REFLECT_REMAINDER FALSE +#define CHECK_VALUE 0x29B1 + +#elif defined(CRC16) + +typedef unsigned short crc; + +#define CRC_NAME "CRC-16" +#define POLYNOMIAL 0x8005 +#define INITIAL_REMAINDER 0x0000 +#define FINAL_XOR_VALUE 0x0000 +#define REFLECT_DATA TRUE +#define REFLECT_REMAINDER TRUE +#define CHECK_VALUE 0xBB3D + +#elif defined(CRC32) + +typedef unsigned long crc; + +#define CRC_NAME "CRC-32" +#define POLYNOMIAL 0x04C11DB7 +#define INITIAL_REMAINDER 0xFFFFFFFF +#define FINAL_XOR_VALUE 0xFFFFFFFF +#define REFLECT_DATA TRUE +#define REFLECT_REMAINDER TRUE +#define CHECK_VALUE 0xCBF43926 + +#else + +#error "One of CRC_CCITT, CRC16, or CRC32 must be #define'd." + +#endif + +void crcInit(void); +crc crcSlow(unsigned char const message[], int nBytes); +crc crcFast(unsigned char const message[], int nBytes); + +extern "C" crc crc_initialize(void); +extern "C" crc crc_process_byte(unsigned char byte, crc remainder); +extern "C" crc crc_finalize(crc remainder); + + +#endif /* _crc_h */ diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp new file mode 100644 index 0000000000..7615d3a01f --- /dev/null +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -0,0 +1,720 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "SysClassRegistry.h" +#include "SysClass.h" +#include "ScStack.h" +#include "ScValue.h" +#include "ScScript.h" +#include "utils.h" +#include "BGame.h" +#include "BFile.h" +#include "BFileManager.h" +#include "PlatformSDL.h" +#include "scriptables/SXFile.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + m_Filename = NULL; + if (!Val->IsNULL()) CBUtils::SetString(&m_Filename, Val->GetString()); + + m_ReadFile = NULL; + m_WriteFile = NULL; + + m_Mode = 0; + m_TextMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::Cleanup() { + delete[] m_Filename; + m_Filename = NULL; + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::Close() { + if (m_ReadFile) { + Game->m_FileManager->CloseFile(m_ReadFile); + m_ReadFile = NULL; + } + if (m_WriteFile) { + fclose(m_WriteFile); + m_WriteFile = NULL; + } + m_Mode = 0; + m_TextMode = false; +} + +////////////////////////////////////////////////////////////////////////// +char *CSXFile::ScToString() { + if (m_Filename) return m_Filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetFilename") == 0) { + Stack->CorrectParams(1); + char *Filename = Stack->Pop()->GetString(); + Cleanup(); + CBUtils::SetString(&m_Filename, Filename); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) { + Stack->CorrectParams(1); + Close(); + m_Mode = Stack->Pop()->GetInt(1); + if (m_Mode < 1 || m_Mode > 3) { + Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name); + m_Mode = 1; + } + if (m_Mode == 1) { + m_ReadFile = Game->m_FileManager->OpenFile(m_Filename); + if (!m_ReadFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, m_Filename); + Close(); + } else m_TextMode = strcmp(Name, "OpenAsText") == 0; + } else { + if (strcmp(Name, "OpenAsText") == 0) { + if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+"); + else m_WriteFile = fopen(m_Filename, "a+"); + } else { + if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+"); + else m_WriteFile = fopen(m_Filename, "ab+"); + } + + if (!m_WriteFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, m_Filename); + Close(); + } else m_TextMode = strcmp(Name, "OpenAsText") == 0; + } + + if (m_ReadFile || m_WriteFile) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Close") == 0) { + Stack->CorrectParams(0); + Close(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPosition") == 0) { + Stack->CorrectParams(1); + if (m_Mode == 0) { + Script->RuntimeError("File.%s: File is not open", Name); + Stack->PushBool(false); + } else { + int Pos = Stack->Pop()->GetInt(); + Stack->PushBool(SetPos(Pos)); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Delete") == 0) { + Stack->CorrectParams(0); + Close(); + Stack->PushBool(CBPlatform::DeleteFile(m_Filename) != FALSE); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Copy") == 0) { + Stack->CorrectParams(2); + char *Dest = Stack->Pop()->GetString(); + bool Overwrite = Stack->Pop()->GetBool(true); + + Close(); + Stack->PushBool(CBPlatform::CopyFile(m_Filename, Dest, !Overwrite) != FALSE); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadLine") == 0) { + Stack->CorrectParams(0); + if (!m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open in text mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 BufSize = FILE_BUFFER_SIZE; + byte *Buf = (byte *)malloc(BufSize); + uint32 Counter = 0; + byte b; + bool FoundNewLine = false; + HRESULT Ret = E_FAIL; + do { + Ret = m_ReadFile->Read(&b, 1); + if (FAILED(Ret)) break; + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + Buf[Counter] = '\0'; + FoundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + Buf[Counter] = b; + Counter++; + } + } while (SUCCEEDED(Ret)); + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + Buf[Counter] = '\0'; + + if (!FoundNewLine && Counter == 0) Stack->PushNULL(); + else Stack->PushString((char *)Buf); + + free(Buf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadText") == 0) { + Stack->CorrectParams(1); + int TextLen = Stack->Pop()->GetInt(); + + if (!m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open in text mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 BufSize = FILE_BUFFER_SIZE; + byte *Buf = (byte *)malloc(BufSize); + uint32 Counter = 0; + byte b; + + HRESULT Ret = E_FAIL; + while (Counter < TextLen) { + Ret = m_ReadFile->Read(&b, 1); + if (FAILED(Ret)) break; + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + Buf[Counter] = b; + Counter++; + } + } + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + Buf[Counter] = '\0'; + + if (TextLen > 0 && Counter == 0) Stack->PushNULL(); + else Stack->PushString((char *)Buf); + + free(Buf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { + Stack->CorrectParams(1); + char *Line = Stack->Pop()->GetString(); + if (!m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); + Stack->PushBool(false); + return S_OK; + } + if (strcmp(Name, "WriteLine") == 0) + fprintf(m_WriteFile, "%s\n", Line); + else + fprintf(m_WriteFile, "%s", Line); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadBool") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + bool Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadByte") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + byte Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadShort") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + short Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + int Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadFloat") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + float Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadDouble") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + double Val; + if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadString") == 0) { + Stack->CorrectParams(0); + if (m_TextMode || !m_ReadFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 Size; + if (SUCCEEDED(m_ReadFile->Read(&Size, sizeof(uint32)))) { + byte *Str = new byte[Size + 1]; + if (Str) { + if (SUCCEEDED(m_ReadFile->Read(Str, Size))) { + Str[Size] = '\0'; + Stack->PushString((char *)Str); + } + delete [] Str; + } else Stack->PushNULL(); + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteBool") == 0) { + Stack->CorrectParams(1); + bool Val = Stack->Pop()->GetBool(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteByte") == 0) { + Stack->CorrectParams(1); + byte Val = Stack->Pop()->GetInt(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteShort") == 0) { + Stack->CorrectParams(1); + short Val = Stack->Pop()->GetInt(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteInt") == 0 || strcmp(Name, "WriteLong") == 0) { + Stack->CorrectParams(1); + int Val = Stack->Pop()->GetInt(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteFloat") == 0) { + Stack->CorrectParams(1); + float Val = Stack->Pop()->GetFloat(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteDouble") == 0) { + Stack->CorrectParams(1); + double Val = Stack->Pop()->GetFloat(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, m_WriteFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteString") == 0) { + Stack->CorrectParams(1); + char *Val = Stack->Pop()->GetString(); + + if (m_TextMode || !m_WriteFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + + uint32 Size = strlen(Val); + fwrite(&Size, sizeof(Size), 1, m_WriteFile); + fwrite(Val, Size, 1, m_WriteFile); + + Stack->PushBool(true); + + return S_OK; + } + + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("file"); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Filename") == 0) { + m_ScValue->SetString(m_Filename); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Position") == 0) { + m_ScValue->SetInt(GetPos()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + m_ScValue->SetInt(GetLength()); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextMode") == 0) { + m_ScValue->SetBool(m_TextMode); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccessMode") == 0) { + m_ScValue->SetInt(m_Mode); + return m_ScValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Length")==0){ + int OrigLength = m_Length; + m_Length = max(Value->GetInt(0), 0); + + char PropName[20]; + if(m_Length < OrigLength){ + for(int i=m_Length; iDeleteProp(PropName); + } + } + return S_OK; + } + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::GetPos() { + if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetPos(); + else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return ftell(m_WriteFile); + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { + if (m_Mode == 1 && m_ReadFile) return SUCCEEDED(m_ReadFile->Seek(Pos, Origin)); + else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return fseek(m_WriteFile, Pos, (int)Origin) == 0; + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::GetLength() { + if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetSize(); + else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) { + uint32 CurrentPos = ftell(m_WriteFile); + fseek(m_WriteFile, 0, SEEK_END); + int Ret = ftell(m_WriteFile); + fseek(m_WriteFile, CurrentPos, SEEK_SET); + return Ret; + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_Mode)); + PersistMgr->Transfer(TMEMBER(m_TextMode)); + + uint32 Pos = 0; + if (PersistMgr->m_Saving) { + Pos = GetPos(); + PersistMgr->Transfer(TMEMBER(Pos)); + } else { + PersistMgr->Transfer(TMEMBER(Pos)); + + // try to re-open file if needed + m_WriteFile = NULL; + m_ReadFile = NULL; + + if (m_Mode != 0) { + // open for reading + if (m_Mode == 1) { + m_ReadFile = Game->m_FileManager->OpenFile(m_Filename); + if (!m_ReadFile) Close(); + } + // open for writing / appending + else { + if (m_TextMode) { + if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+"); + else m_WriteFile = fopen(m_Filename, "a+"); + } else { + if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+"); + else m_WriteFile = fopen(m_Filename, "ab+"); + } + if (m_WriteFile) Close(); + } + SetPos(Pos); + } + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h new file mode 100644 index 0000000000..0ab1acb32c --- /dev/null +++ b/engines/wintermute/scriptables/SXFile.h @@ -0,0 +1,60 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeSXFile_H__ +#define __WmeSXFile_H__ + + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *ScGetProperty(char *Name); + HRESULT ScSetProperty(char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + char *ScToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + CBFile *m_ReadFile; + FILE *m_WriteFile; + int m_Mode; // 0..none, 1..read, 2..write, 3..append + bool m_TextMode; + void Close(); + void Cleanup(); + uint32 GetPos(); + uint32 GetLength(); + bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + char *m_Filename; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp new file mode 100644 index 0000000000..50c970d41a --- /dev/null +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -0,0 +1,508 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "BGame.h" +#include "BRegistry.h" +#include "scriptables/SXStore.h" +#include "ScValue.h" +#include "ScScript.h" +#include "ScStack.h" +#include "StringUtil.h" + +#ifdef __IPHONEOS__ +# include "IOS_StoreKit_interface.h" +#endif + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXStore, false) + +////////////////////////////////////////////////////////////////////////// +CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { +#ifdef __IPHONEOS__ + StoreKit_SetExternalData((void *)this); +#endif + + m_EventsEnabled = false; + m_LastProductRequestOwner = NULL; + m_LastPurchaseOwner = NULL; + m_LastRestoreOwner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CSXStore::~CSXStore() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::Cleanup() { + SetEventsEnabled(NULL, false); + + for (int i = 0; i < m_ValidProducts.GetSize(); i++) { + delete m_ValidProducts[i]; + } + m_ValidProducts.RemoveAll(); + + + for (int i = 0; i < m_Transactions.GetSize(); i++) { + delete m_Transactions[i]; + } + m_Transactions.RemoveAll(); + + + m_LastProductRequestOwner = m_LastPurchaseOwner = m_LastRestoreOwner = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + ////////////////////////////////////////////////////////////////////////// + // EnableEvents + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "EnableEvents") == 0) { + stack->CorrectParams(0); + SetEventsEnabled(script, true); + stack->PushBool(GetEventsEnabled() == true); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // DisableEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableEvents") == 0) { + stack->CorrectParams(0); + SetEventsEnabled(script, false); + stack->PushBool(GetEventsEnabled() == false); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ValidateProducts + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidateProducts") == 0) { + stack->CorrectParams(1); + char *prodIdList = stack->Pop()->GetString(); + m_LastProductRequestOwner = script->m_Owner; + ValidateProducts(prodIdList); + stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetValidProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetValidProduct") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < m_ValidProducts.GetSize()) { + CScValue *prod = stack->GetPushValue(); + if (prod) { + prod->SetProperty("Id", m_ValidProducts[index]->GetId()); + prod->SetProperty("Name", m_ValidProducts[index]->GetName()); + prod->SetProperty("Description", m_ValidProducts[index]->GetDesc()); + prod->SetProperty("Price", m_ValidProducts[index]->GetPrice()); + } + } else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetInvalidProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInvalidProduct") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < m_InvalidProducts.size()) + stack->PushString(m_InvalidProducts[index].c_str()); + else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetTransaction + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetTransaction") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < m_Transactions.GetSize()) { + CScValue *trans = stack->GetPushValue(); + if (trans) { + trans->SetProperty("Id", m_Transactions[index]->GetId()); + trans->SetProperty("ProductId", m_Transactions[index]->GetProductId()); + trans->SetProperty("State", m_Transactions[index]->GetState()); + } + } else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Purchase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Purchase") == 0) { + stack->CorrectParams(1); + char *prodId = stack->Pop()->GetString(); + stack->PushBool(Purchase(script, prodId)); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FinishTransaction + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FinishTransaction") == 0) { + stack->CorrectParams(1); + char *transId = stack->Pop()->GetString(); + stack->PushBool(FinishTransaction(script, transId)); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RestoreTransactions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RestoreTransactions") == 0) { + stack->CorrectParams(0); + RestoreTransactions(script); + stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnlockProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnlockProduct") == 0) { + stack->CorrectParams(1); + char *prodId = stack->Pop()->GetString(); + + Game->m_Registry->WriteBool("Purchases", prodId, true); + Game->m_Registry->SaveValues(); + + stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsProductUnlocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsProductUnlocked") == 0) { + stack->CorrectParams(1); + char *prodId = stack->Pop()->GetString(); + + stack->PushBool(Game->m_Registry->ReadBool("Purchases", prodId, false)); + + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXStore::ScGetProperty(char *name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + m_ScValue->SetString("store"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Available (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Available") == 0) { + m_ScValue->SetBool(IsAvailable()); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // EventsEnabled (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EventsEnabled") == 0) { + m_ScValue->SetBool(GetEventsEnabled()); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumValidProducts (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumValidProducts") == 0) { + m_ScValue->SetInt(m_ValidProducts.GetSize()); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumInvalidProducts (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumInvalidProducts") == 0) { + m_ScValue->SetInt(m_InvalidProducts.size()); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumTransactions (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumTransactions") == 0) { + m_ScValue->SetInt(m_Transactions.GetSize()); + return m_ScValue; + } + + else return m_ScValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->m_Saving) Cleanup(); + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_EventsEnabled)); + PersistMgr->Transfer(TMEMBER(m_LastProductRequestOwner)); + PersistMgr->Transfer(TMEMBER(m_LastPurchaseOwner)); + PersistMgr->Transfer(TMEMBER(m_LastRestoreOwner)); + PersistMgr->Transfer(TMEMBER(m_InvalidProducts)); + + // persist valid products + int numProducts; + if (PersistMgr->m_Saving) { + numProducts = m_ValidProducts.GetSize(); + PersistMgr->Transfer(TMEMBER(numProducts)); + for (int i = 0; i < numProducts; i++) m_ValidProducts[i]->Persist(PersistMgr); + } else { + numProducts = m_ValidProducts.GetSize(); + PersistMgr->Transfer(TMEMBER(numProducts)); + for (int i = 0; i < numProducts; i++) { + CBStoreProduct *prod = new CBStoreProduct; + prod->Persist(PersistMgr); + m_ValidProducts.Add(prod); + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AfterLoad() { + if (m_EventsEnabled) { + SetEventsEnabled(NULL, true); + } +#ifdef __IPHONEOS__ + StoreKit_SetExternalData((void *)this); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { + if (m_LastProductRequestOwner == obj) m_LastProductRequestOwner = NULL; + if (m_LastPurchaseOwner == obj) m_LastPurchaseOwner = NULL; + if (m_LastRestoreOwner == obj) m_LastRestoreOwner = NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::SetEventsEnabled(CScScript *script, bool val) { + m_EventsEnabled = val; + + if (val) { + if (script) m_LastPurchaseOwner = script->m_Owner; +#ifdef __IPHONEOS__ + StoreKit_EnableEvents(); +#endif + } else { + m_LastPurchaseOwner = NULL; +#ifdef __IPHONEOS__ + StoreKit_DisableEvents(); +#endif + } +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ValidateProducts(const char *prodIdList) { +#ifdef __IPHONEOS__ + StoreKit_ValidateProducts(prodIdList); +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::IsAvailable() { +#ifdef __IPHONEOS__ + return StoreKit_IsStoreAvailable() > 0; +#else + return false; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveProductsStart() { + for (int i = 0; i < m_ValidProducts.GetSize(); i++) { + delete m_ValidProducts[i]; + } + m_ValidProducts.RemoveAll(); + + m_InvalidProducts.clear(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveProductsEnd() { + if (m_LastProductRequestOwner) m_LastProductRequestOwner->ApplyEvent("ProductsValidated"); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddValidProduct(const char *id, const char *name, const char *desc, const char *price) { + CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); + m_ValidProducts.Add(prod); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddInvalidProduct(const char *id) { + m_InvalidProducts.push_back(id); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveTransactionsStart() { + for (int i = 0; i < m_Transactions.GetSize(); i++) { + delete m_Transactions[i]; + } + m_Transactions.RemoveAll(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveTransactionsEnd() { + if (m_LastPurchaseOwner) m_LastPurchaseOwner->ApplyEvent("TransactionsUpdated"); + else Game->ApplyEvent("TransactionsUpdated"); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddTransaction(const char *id, const char *productId, const char *state) { + CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); + m_Transactions.Add(trans); +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::Purchase(CScScript *script, const char *productId) { + if (!productId) return false; + +#ifdef __IPHONEOS__ + for (int i = 0; i < m_ValidProducts.GetSize(); i++) { + if (strcmp(productId, m_ValidProducts[i]->GetId()) == 0) { + m_LastPurchaseOwner = script->m_Owner; + + StoreKit_Purchase(productId); + return true; + } + } +#endif + script->RuntimeError("Store.Purchase() - '%s' is not a valid product id", productId); + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { + if (!transId) return false; +#ifdef __IPHONEOS__ + for (int i = 0; i < m_Transactions.GetSize(); i++) { + if (strcmp(transId, m_Transactions[i]->GetId()) == 0) { + if (StoreKit_FinishTransaction(transId) > 0) { + SAFE_DELETE(m_Transactions[i]); + m_Transactions.RemoveAt(i); + return true; + } else return false; + } + } +#endif + script->RuntimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); + return false; +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::RestoreTransactions(CScScript *script) { + m_LastRestoreOwner = script->m_Owner; +#ifdef __IPHONEOS__ + StoreKit_RestoreTransactions(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::OnRestoreFinished(bool error) { + if (m_LastRestoreOwner) { + if (error) m_LastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); + else m_LastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); + } +} + + + +#ifdef __IPHONEOS__ + +////////////////////////////////////////////////////////////////////////// +// StoreKit callbacks (called from ObjC) +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddValidProductCallback(const char *id, const char *name, const char *desc, const char *price, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddValidProduct(id, name, desc, price); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddInvalidProductCallback(const char *id, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddInvalidProduct(id); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveProductsStartCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveProductsStart(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveProductsEndCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveProductsEnd(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddTransactionCallback(const char *id, const char *productId, const char *state, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddTransaction(id, productId, state); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveTransactionsStartCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveTransactionsStart(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveTransactionsEndCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveTransactionsEnd(); +} +////////////////////////////////////////////////////////////////////////// +void StoreKit_RestoreFinishedCallback(void *data, int error) { + CSXStore *store = static_cast(data); + if (store) store->OnRestoreFinished(error > 0); +} + +#endif // __IPHONEOS__ + +} // end of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/scriptables/SXStore.h b/engines/wintermute/scriptables/SXStore.h new file mode 100644 index 0000000000..f6a13e9eeb --- /dev/null +++ b/engines/wintermute/scriptables/SXStore.h @@ -0,0 +1,172 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeSXStore_H__ +#define __WmeSXStore_H__ +#include "engines/wintermute/BPersistMgr.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CSXStore : public CBObject { +public: + + ////////////////////////////////////////////////////////////////////////// + class CBStoreProduct { + public: + CBStoreProduct() { + m_Id = m_Name = m_Desc = m_Price = NULL; + } + + CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { + m_Id = m_Name = m_Desc = m_Price = NULL; + + CBUtils::SetString(&m_Id, id); + CBUtils::SetString(&m_Name, name); + CBUtils::SetString(&m_Desc, desc); + CBUtils::SetString(&m_Price, price); + } + + ~CBStoreProduct() { + delete [] m_Id; + delete [] m_Name; + delete [] m_Desc; + delete [] m_Price; + } + + HRESULT Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_Id)); + PersistMgr->Transfer(TMEMBER(m_Name)); + PersistMgr->Transfer(TMEMBER(m_Desc)); + PersistMgr->Transfer(TMEMBER(m_Price)); + return S_OK; + } + + const char *GetId() { + return m_Id; + } + const char *GetName() { + return m_Name; + } + const char *GetDesc() { + return m_Desc; + } + const char *GetPrice() { + return m_Price; + } + + private: + char *m_Id; + char *m_Name; + char *m_Desc; + char *m_Price; + }; + + ////////////////////////////////////////////////////////////////////////// + class CBStoreTransaction { + public: + CBStoreTransaction() { + m_Id = m_ProductId = m_State = NULL; + } + + CBStoreTransaction(const char *id, const char *productId, const char *state) { + m_Id = m_ProductId = m_State = NULL; + + CBUtils::SetString(&m_Id, id); + CBUtils::SetString(&m_ProductId, productId); + CBUtils::SetString(&m_State, state); + } + + ~CBStoreTransaction() { + delete [] m_Id; + delete [] m_ProductId; + delete [] m_State; + } + + const char *GetId() { + return m_Id; + } + const char *GetProductId() { + return m_ProductId; + } + const char *GetState() { + return m_State; + } + + private: + char *m_Id; + char *m_ProductId; + char *m_State; + }; + + + DECLARE_PERSISTENT(CSXStore, CBObject) + CSXStore(CBGame *inGame); + virtual ~CSXStore(); + virtual CScValue *ScGetProperty(char *name); + virtual HRESULT ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + + void AfterLoad(); + void OnObjectDestroyed(CBScriptHolder *obj); + + bool IsAvailable(); + void SetEventsEnabled(CScScript *script, bool val); + bool GetEventsEnabled() const { + return m_EventsEnabled; + } + void ValidateProducts(const char *prodIdList); + + void ReceiveTransactionsStart(); + void ReceiveTransactionsEnd(); + void AddTransaction(const char *id, const char *productId, const char *state); + + void ReceiveProductsStart(); + void ReceiveProductsEnd(); + void AddValidProduct(const char *id, const char *name, const char *desc, const char *price); + void AddInvalidProduct(const char *id); + + void OnRestoreFinished(bool error); + +private: + void Cleanup(); + bool Purchase(CScScript *script, const char *productId); + bool FinishTransaction(CScScript *script, const char *transId); + void RestoreTransactions(CScScript *script); + + bool m_EventsEnabled; + CBArray m_ValidProducts; + AnsiStringArray m_InvalidProducts; + CBScriptHolder *m_LastProductRequestOwner; + CBScriptHolder *m_LastPurchaseOwner; + CBScriptHolder *m_LastRestoreOwner; + + CBArray m_Transactions; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp new file mode 100644 index 0000000000..0283ee4895 --- /dev/null +++ b/engines/wintermute/scriptables/SXString.cpp @@ -0,0 +1,387 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "BGame.h" +#include "ScStack.h" +#include "ScValue.h" +#include "utils.h" +#include "scriptables/SXString.h" +#include "scriptables/SXArray.h" +#include "StringUtil.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsInt()) { + _capacity = std::max(0, Val->GetInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + SetStringVal(Val->GetString()); + } + + if (_capacity == 0) SetStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::SetStringVal(const char *Val) { + int Len = strlen(Val); + if (Len >= _capacity) { + _capacity = Len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, Val); +} + + +////////////////////////////////////////////////////////////////////////// +char *CSXString::ScToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::ScSetString(const char *Val) { + SetStringVal(Val); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Substring") == 0) { + Stack->CorrectParams(2); + int start = Stack->Pop()->GetInt(); + int end = Stack->Pop()->GetInt(); + + if (end < start) CBUtils::Swap(&start, &end); + + try { + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString subStr = str.substr(start, end - start + 1); + + if (Game->m_TextEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + } catch (std::exception &) { + Stack->PushNULL(); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Substr") == 0) { + Stack->CorrectParams(2); + int start = Stack->Pop()->GetInt(); + + CScValue *val = Stack->Pop(); + int len = val->GetInt(); + + if (!val->IsNULL() && len <= 0) { + Stack->PushString(""); + return S_OK; + } + + if (val->IsNULL()) len = strlen(_string) - start; + + try { + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString subStr = str.substr(start, len); + + if (Game->m_TextEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + } catch (std::exception &) { + Stack->PushNULL(); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToUpperCase") == 0) { + Stack->CorrectParams(0); + + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + StringUtil::ToUpperCase(str); + + if (Game->m_TextEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToLowerCase") == 0) { + Stack->CorrectParams(0); + + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + StringUtil::ToLowerCase(str); + + if (Game->m_TextEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IndexOf") == 0) { + Stack->CorrectParams(2); + + char *strToFind = Stack->Pop()->GetString(); + int index = Stack->Pop()->GetInt(); + + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString toFind; + if (Game->m_TextEncoding == TEXT_UTF8) + toFind = StringUtil::Utf8ToWide(strToFind); + else + toFind = StringUtil::AnsiToWide(strToFind); + + int indexOf = StringUtil::IndexOf(str, toFind, index); + Stack->PushInt(indexOf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Split") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + char Separators[MAX_PATH] = ","; + if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); + + CSXArray *Array = new CSXArray(Game); + if (!Array) { + Stack->PushNULL(); + return S_OK; + } + + + WideString str; + if (Game->m_TextEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString delims; + if (Game->m_TextEncoding == TEXT_UTF8) + delims = StringUtil::Utf8ToWide(Separators); + else + delims = StringUtil::AnsiToWide(Separators); + + std::vector parts; + + + size_t start, pos; + start = 0; + do { + pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == WideString::npos) { + parts.push_back(str.substr(start)); + break; + } else { + parts.push_back(str.substr(start, pos - start)); + start = pos + 1; + } + start = str.find_first_not_of(delims, start); + + } while (pos != WideString::npos); + + for (std::vector::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (Game->m_TextEncoding == TEXT_UTF8) + Val = new CScValue(Game, StringUtil::WideToUtf8(part).c_str()); + else + Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); + + Array->Push(Val); + delete[] Val; + Val = NULL; + } + + Stack->PushNative(Array, false); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("string"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + if (Game->m_TextEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(_string); + m_ScValue->SetInt(wstr.length()); + } else + m_ScValue->SetInt(strlen(_string)); + + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Capacity") == 0) { + m_ScValue->SetInt(_capacity); + return m_ScValue; + } + + else return m_ScValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Capacity") == 0) { + int NewCap = Value->GetInt(); + if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); + else if (NewCap != _capacity) { + char *NewStr = new char[NewCap]; + if (NewStr) { + memset(NewStr, 0, NewCap); + strcpy(NewStr, _string); + delete[] _string; + _string = NewStr; + _capacity = NewCap; + } + } + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_capacity)); + + if (PersistMgr->m_Saving) { + if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + PersistMgr->GetBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::ScCompare(CBScriptable *Val) { + return strcmp(_string, ((CSXString *)Val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h new file mode 100644 index 0000000000..1cd3a7f52c --- /dev/null +++ b/engines/wintermute/scriptables/SXString.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef __WmeSXString_H__ +#define __WmeSXString_H__ + + +#include "engines/wintermute/BScriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int ScCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *ScGetProperty(char *Name); + HRESULT ScSetProperty(char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + void ScSetString(const char *Val); + char *ScToString(); + void SetStringVal(const char *Val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/scriptables/SxObject.cpp b/engines/wintermute/scriptables/SxObject.cpp new file mode 100644 index 0000000000..738db08c53 --- /dev/null +++ b/engines/wintermute/scriptables/SxObject.cpp @@ -0,0 +1,60 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "SxObject.h" +#include "ScValue.h" +#include "ScStack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { + int NumParams = Stack->Pop()->GetInt(0); + for (int i = 0; i < NumParams; i++) { + AddScript(Stack->Pop()->GetString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXObject::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SxObject.h b/engines/wintermute/scriptables/SxObject.h new file mode 100644 index 0000000000..6a355a7288 --- /dev/null +++ b/engines/wintermute/scriptables/SxObject.h @@ -0,0 +1,44 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeSxObject_H__ +#define __WmeSxObject_H__ + + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 4b2b236abd6b30c977b1a2858cc1b90eaf85cb10 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 6 Mar 2012 17:29:40 +0100 Subject: WINTERMUTE: Add most of the missing classes to the build. --- engines/wintermute/AdEntity.cpp | 46 +- engines/wintermute/AdGame.cpp | 62 +- engines/wintermute/BFileManager.cpp | 6 +- engines/wintermute/BGame.cpp | 8 +- engines/wintermute/BGame.h | 3 +- engines/wintermute/BKeyboardState.h | 3 +- engines/wintermute/BObject.cpp | 22 +- engines/wintermute/BScriptHolder.cpp | 14 +- engines/wintermute/FontGlyphCache.cpp | 96 ++ engines/wintermute/FontGlyphCache.h | 120 +++ engines/wintermute/MathUtil.cpp | 45 + engines/wintermute/MathUtil.h | 39 + engines/wintermute/UIEdit.cpp | 4 +- engines/wintermute/UIText.cpp | 30 +- engines/wintermute/UIWindow.cpp | 45 +- engines/wintermute/dcpackage.h | 79 ++ engines/wintermute/module.mk | 24 +- engines/wintermute/tinyxml.cpp | 1888 +++++++++++++++++++++++++++++++++ engines/wintermute/tinyxml.h | 1803 +++++++++++++++++++++++++++++++ engines/wintermute/wintermute.cpp | 2 +- 20 files changed, 4220 insertions(+), 119 deletions(-) create mode 100644 engines/wintermute/FontGlyphCache.cpp create mode 100644 engines/wintermute/FontGlyphCache.h create mode 100644 engines/wintermute/MathUtil.cpp create mode 100644 engines/wintermute/MathUtil.h create mode 100644 engines/wintermute/dcpackage.h create mode 100644 engines/wintermute/tinyxml.cpp create mode 100644 engines/wintermute/tinyxml.h (limited to 'engines') diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index c4827cfeed..c0e07b958d 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -26,28 +26,30 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "AdEntity.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "BActiveRect.h" -#include "BSurfaceStorage.h" -#include "ScValue.h" -#include "BGame.h" -#include "AdGame.h" -#include "AdScene.h" -#include "BSound.h" -#include "AdWaypointGroup.h" -#include "BFontStorage.h" -#include "BFont.h" -#include "AdSentence.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BRegion.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "PlatformSDL.h" -#include "utils.h" + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/AdEntity.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/AdScene.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/AdWaypointGroup.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/AdSentence.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index b5e8518e30..cfcfd20085 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -26,37 +26,37 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "AdGame.h" -#include "AdResponseBox.h" -#include "AdInventoryBox.h" -#include "AdSceneState.h" -#include "PartEmitter.h" -#include "BParser.h" -#include "BSurfaceStorage.h" -#include "BTransitionMgr.h" -#include "BObject.h" -#include "BSound.h" -#include "UIWindow.h" -#include "ScValue.h" -#include "UIEntity.h" -#include "AdScene.h" -#include "AdEntity.h" -#include "AdActor.h" -#include "AdInventory.h" -#include "AdResponseContext.h" -#include "AdItem.h" -#include "BViewport.h" -#include "BFont.h" -#include "ScEngine.h" -#include "BStringTable.h" -#include "AdSentence.h" -#include "AdResponse.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "utils.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/AdResponseBox.h" +#include "engines/wintermute/AdInventoryBox.h" +#include "engines/wintermute/AdSceneState.h" +#include "engines/wintermute/PartEmitter.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BTransitionMgr.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/UIEntity.h" +#include "engines/wintermute/AdScene.h" +#include "engines/wintermute/AdEntity.h" +#include "engines/wintermute/AdActor.h" +#include "engines/wintermute/AdInventory.h" +#include "engines/wintermute/AdResponseContext.h" +#include "engines/wintermute/AdItem.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/AdSentence.h" +#include "engines/wintermute/AdResponse.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/utils.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index d679321598..ce0de04596 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -43,7 +43,7 @@ #include "PlatformSDL.h" #include "common/str.h" #include "common/textconsole.h" -#include +//#include #ifdef __WIN32__ # include @@ -356,7 +356,7 @@ HRESULT CBFileManager::RegisterPackages() { Game->LOG(0, "Scanning packages..."); warning("Scanning packages"); - +#if 0 AnsiString extension = AnsiString(".") + AnsiString(PACKAGE_EXTENSION); for (int i = 0; i < m_PackagePaths.GetSize(); i++) { @@ -386,7 +386,7 @@ HRESULT CBFileManager::RegisterPackages() { Game->LOG(0, " Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); - +#endif return S_OK; } diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index a076477b04..a4329fc5df 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -3712,7 +3712,8 @@ bool CBGame::HandleKeypress(SDL_Event *event) { m_KeyboardState->ReadKey(event); - +// TODO +#if 0 if (m_FocusedWindow) { if (!Game->m_FocusedWindow->HandleKeypress(event)) { if (event->type != SDL_TEXTINPUT) { @@ -3727,6 +3728,8 @@ bool CBGame::HandleKeypress(SDL_Event *event) { ApplyEvent("Keypress"); return true; } else return true; +#endif + return false; } @@ -3792,7 +3795,10 @@ void CBGame::SetWindowTitle() { } CBRenderSDL *renderer = static_cast(m_Renderer); + // TODO +#if 0 SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif } } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 208b5b414b..610915d154 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -256,9 +256,8 @@ public: virtual bool HandleMouseWheel(int Delta); bool m_Quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); -#if 0 + virtual bool HandleKeypress(SDL_Event *event); -#endif int m_FreezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index f5ea56f055..5d4a6bada6 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -32,6 +32,7 @@ #include "BBase.h" #include "BScriptable.h" +#include "common/keyboard.h" #include namespace WinterMute { @@ -63,7 +64,7 @@ public: private: uint32 KeyCodeToVKey(SDL_Event *event); - SDL_Keycode VKeyToKeyCode(uint32 vkey); + Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; } // end of namespace WinterMute diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 3bb94046a4..43fb347cc3 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -26,17 +26,17 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BObject.h" -#include "BParser.h" -#include "ScValue.h" -#include "ScStack.h" -#include "BSound.h" -#include "BSoundMgr.h" -#include "BGame.h" -#include "BStringTable.h" -#include "BSprite.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSoundMgr.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index 96ed14461c..674df198cd 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -24,13 +24,13 @@ THE SOFTWARE. */ #include "dcgf.h" -#include "AdGame.h" -#include "BScriptHolder.h" -#include "BParser.h" -#include "ScValue.h" -#include "ScEngine.h" -#include "ScScript.h" -#include "ScStack.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/BScriptHolder.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp new file mode 100644 index 0000000000..6181fb2704 --- /dev/null +++ b/engines/wintermute/FontGlyphCache.cpp @@ -0,0 +1,96 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "FontGlyphCache.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +FontGlyphCache::FontGlyphCache() { +} + +////////////////////////////////////////////////////////////////////////// +FontGlyphCache::~FontGlyphCache() { + GlyphInfoMap::iterator it; + + for (it = m_Glyphs.begin(); it != m_Glyphs.end(); ++it) { + delete it->second; + it->second = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +bool FontGlyphCache::HasGlyph(wchar_t ch) { + return (m_Glyphs.find(ch) != m_Glyphs.end()); +} + +////////////////////////////////////////////////////////////////////////// +void FontGlyphCache::Initialize() { +} + +////////////////////////////////////////////////////////////////////////// +GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { + GlyphInfoMap::const_iterator it; + it = m_Glyphs.find(ch); + if (it == m_Glyphs.end()) return NULL; + + return it->second; +} + +////////////////////////////////////////////////////////////////////////// +void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) { + if (stride == 0) stride = width; + + m_Glyphs[ch] = new GlyphInfo(glyphIndex); + m_Glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); + m_Glyphs[ch]->SetGlyphImage(width, height, stride, pixels); +} + + +////////////////////////////////////////////////////////////////////////// +void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) { + if (m_Image) SDL_FreeSurface(m_Image); + + m_Image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + SDL_LockSurface(m_Image); + + Uint8 *buf = (Uint8 *)m_Image->pixels; + + for (int y = 0; y < height; y++) { + Uint32 *buf32 = (Uint32 *)buf; + + for (int x = 0; x < width; x++) { + byte alpha = pixels[y * stride + x]; + Uint32 color = SDL_MapRGBA(m_Image->format, 255, 255, 255, alpha); + buf32[x] = color; + } + + buf += m_Image->pitch; + } + + SDL_UnlockSurface(m_Image); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h new file mode 100644 index 0000000000..50db962771 --- /dev/null +++ b/engines/wintermute/FontGlyphCache.h @@ -0,0 +1,120 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeFontGlyphCache_H__ +#define __WmeFontGlyphCache_H__ + + +#include "SDL.h" +#include "BFontStorage.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +class GlyphInfo { +public: + GlyphInfo(int glyphIndex) { + m_GlyphIndex = glyphIndex; + m_AdvanceX = m_AdvanceY = 0; + m_BearingX = m_BearingY = 0; + + m_Width = m_Height = 0; + + m_Image = NULL; + } + + ~GlyphInfo() { + if (m_Image) SDL_FreeSurface(m_Image); + } + + void SetGlyphInfo(float AdvanceX, float AdvanceY, int BearingX, int BearingY) { + m_AdvanceX = AdvanceX; + m_AdvanceY = AdvanceY; + m_BearingX = BearingX; + m_BearingY = BearingY; + } + + void SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels); + + int GetGlyphIndex() { + return m_GlyphIndex; + } + int GetWidth() { + return m_Width; + } + int GetHeight() { + return m_Height; + } + float GetAdvanceX() { + return m_AdvanceX; + } + float GetAdvanceY() { + return m_AdvanceY; + } + int GetBearingX() { + return m_BearingX; + } + int GetBearingY() { + return m_BearingY; + } + SDL_Surface *GetImage() { + return m_Image; + } + +private: + int m_GlyphIndex; + + float m_AdvanceX; + float m_AdvanceY; + int m_BearingX; + int m_BearingY; + + int m_Width; + int m_Height; + + SDL_Surface *m_Image; +}; + + + +////////////////////////////////////////////////////////////////////////// +class FontGlyphCache { +public: + FontGlyphCache(); + virtual ~FontGlyphCache(); + + void Initialize(); + bool HasGlyph(wchar_t ch); + GlyphInfo *GetGlyph(wchar_t ch); + void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0); + +private: + typedef std::map GlyphInfoMap; + GlyphInfoMap m_Glyphs; +}; + +} // end of namespace WinterMute + +#endif // __WmeFontGlyphCache_H__ \ No newline at end of file diff --git a/engines/wintermute/MathUtil.cpp b/engines/wintermute/MathUtil.cpp new file mode 100644 index 0000000000..bb85ea66fa --- /dev/null +++ b/engines/wintermute/MathUtil.cpp @@ -0,0 +1,45 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "MathUtil.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +float MathUtil::Round(float val) { + float result = floor(val); + if (val - result >= 0.5) result += 1.0; + return result; +} + +////////////////////////////////////////////////////////////////////////// +float MathUtil::RoundUp(float val) { + float result = floor(val); + if (val - result > 0) result += 1.0; + return result; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/MathUtil.h b/engines/wintermute/MathUtil.h new file mode 100644 index 0000000000..ded73a91d4 --- /dev/null +++ b/engines/wintermute/MathUtil.h @@ -0,0 +1,39 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeMathUtil_H__ +#define __WmeMathUtil_H__ + +namespace WinterMute { + +class MathUtil { +public: + static float Round(float val); + static float RoundUp(float val); +}; + +} // end of namespace WinterMute + +#endif // __WmeMathUtil_H__ diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index af214c50dd..58ac8ff13b 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -766,7 +766,7 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { } return Handled; } - +#if 0 else if (event->type == SDL_TEXTINPUT) { if (m_SelStart != m_SelEnd) DeleteChars(m_SelStart, m_SelEnd); @@ -778,7 +778,7 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { return true; } - +#endif return false; } diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 7a0b206cec..524d1eec91 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -26,21 +26,21 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BDynBuffer.h" -#include "UIText.h" -#include "UITiledImage.h" -#include "BGame.h" -#include "BParser.h" -#include "ScValue.h" -#include "BFont.h" -#include "BFontStorage.h" -#include "BStringTable.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "PlatformSDL.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/UIText.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index b68f788fcc..8ef0f6df15 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -27,26 +27,26 @@ */ #include "dcgf.h" -#include "UIWindow.h" -#include "BGame.h" -#include "BParser.h" -#include "BActiveRect.h" -#include "BDynBuffer.h" -#include "BKeyboardState.h" -#include "ScValue.h" -#include "UIButton.h" -#include "UIEdit.h" -#include "UIText.h" -#include "UITiledImage.h" -#include "BViewport.h" -#include "BFontStorage.h" -#include "BFont.h" -#include "BStringTable.h" -#include "ScScript.h" -#include "ScStack.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "PlatformSDL.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BKeyboardState.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/UIButton.h" +#include "engines/wintermute/UIEdit.h" +#include "engines/wintermute/UIText.h" +#include "engines/wintermute/UITiledImage.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { @@ -1090,14 +1090,15 @@ char *CUIWindow::ScToString() { ////////////////////////////////////////////////////////////////////////// bool CUIWindow::HandleKeypress(SDL_Event *event) { - +//TODO +#if 0 if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { if (m_FocusedWidget) return m_FocusedWidget->HandleKeypress(event); else return false; } - +#endif return false; } diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h new file mode 100644 index 0000000000..3987f56798 --- /dev/null +++ b/engines/wintermute/dcpackage.h @@ -0,0 +1,79 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef _DCPACKAGE_H_ +#define _DCPACKAGE_H_ + + +#define PACKAGE_MAGIC_1 0xDEC0ADDE +#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" +#define PACKAGE_VERSION 0x00000200 +#define PACKAGE_EXTENSION "dcp" + +#include + +namespace WinterMute { + +typedef struct { + uint32 Magic1; + uint32 Magic2; + uint32 PackageVersion; + uint32 GameVersion; + byte Priority; + byte CD; + bool MasterIndex; +#ifdef __WIN32__ + __time32_t CreationTime; +#else + time_t CreationTime; +#endif + char Desc[100]; + uint32 NumDirs; +} TPackageHeader; + +/* +v2: uint32 DirOffset + + +Dir: byte NameLength + char Name [NameLength] + byte CD; + uint32 NumEntries + + +Entry: byte NameLength + char Name [NameLength] + uint32 Offset + uint32 Length + uint32 CompLength + uint32 Flags +v2: uint32 TimeDate1 + uint32 TimeDate2 // not used + +*/ + +} // end of namespace WinterMute + +#endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index d376f3723a..2b5eca2c6a 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -10,6 +10,8 @@ MODULE_OBJS := \ scriptables/SXMemBuffer.o \ AdActor.o \ AdActorDir.o \ + AdEntity.o \ + AdGame.o \ AdInventory.o \ AdInventoryBox.o \ AdItem.o \ @@ -33,44 +35,64 @@ MODULE_OBJS := \ AdTalkNode.o \ AdWaypointGroup.o \ BActiveRect.o \ + BBase.o \ BDebugger.o \ BDynBuffer.o \ - BBase.o \ BFader.o \ BFile.o \ BFileEntry.o \ + BFileManager.o \ + BGame.o \ + BFont.o \ + BFontBitmap.o \ + BFontStorage.o \ + BFontTT.o \ BFrame.o \ BImage.o \ BNamedObject.o \ + BObject.o \ BPackage.o \ BParser.o \ BPersistMgr.o \ + BPkgFile.o \ BPoint.o \ BQuickMsg.o \ BRegion.o \ + BRegistry.o \ BResources.o \ BResourceFile.o \ BSaveThumbFile.o \ BScriptable.o \ + BScriptHolder.o \ BSound.o \ BSoundBuffer.o \ BSoundMgr.o \ BSprite.o \ + BStringTable.o \ BSubFrame.o \ + BSurface.o \ BSurfaceStorage.o \ BTransitionMgr.o \ BViewport.o \ ConvertUTF.o \ detection.o \ + FontGlyphCache.o \ + MathUtil.o \ PathUtil.o \ StringUtil.o \ SysClass.o \ + SysClassRegistry.o \ SysInstance.o \ + tinyxml.o \ UIButton.o \ + UIEdit.o \ UIEntity.o \ UIObject.o \ + UIText.o \ UITiledImage.o \ + UIWindow.o \ utils.o \ + Vector2.o \ wintermute.o MODULE_DIRS += \ diff --git a/engines/wintermute/tinyxml.cpp b/engines/wintermute/tinyxml.cpp new file mode 100644 index 0000000000..5de21f6dec --- /dev/null +++ b/engines/wintermute/tinyxml.cpp @@ -0,0 +1,1888 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include + +#ifdef TIXML_USE_STL +#include +#include +#endif + +#include "tinyxml.h" + + +bool TiXmlBase::condenseWhiteSpace = true; + +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) +{ + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; + #else + return fopen( filename, mode ); + #endif +} + +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) +{ + int i=0; + + while( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); + #else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + #endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } +} + + +TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() +{ + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; +} + + +TiXmlNode::~TiXmlNode() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } +} + + +void TiXmlNode::CopyTo( TiXmlNode* target ) const +{ + target->SetValue (value.c_str() ); + target->userData = userData; +} + + +void TiXmlNode::Clear() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } + + firstChild = 0; + lastChild = 0; +} + + +TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) +{ + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + node->parent = this; + + node->prev = lastChild; + node->next = 0; + + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. + + lastChild = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) +{ + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + + return LinkEndChild( node ); +} + + +TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) +{ + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) +{ + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; +} + + +TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) +{ + if ( replaceThis->parent != this ) + return 0; + + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; +} + + +bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) +{ + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; + + delete removeThis; + return true; +} + +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } +} + + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +void TiXmlElement::RemoveAttribute( const char * name ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); + #else + TiXmlAttribute* node = attributeSet.Find( name ); + #endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } +} + +const TiXmlElement* TiXmlNode::FirstChildElement() const +{ + const TiXmlNode* node; + + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement() const +{ + const TiXmlNode* node; + + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlDocument* TiXmlNode::GetDocument() const +{ + const TiXmlNode* node; + + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; +} + + +TiXmlElement::TiXmlElement (const char * _value) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} + + +#ifdef TIXML_USE_STL +TiXmlElement::TiXmlElement( const std::string& _value ) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} +#endif + + +TiXmlElement::TiXmlElement( const TiXmlElement& copy) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + copy.CopyTo( this ); +} + + +void TiXmlElement::operator=( const TiXmlElement& base ) +{ + ClearThis(); + base.CopyTo( this ); +} + + +TiXmlElement::~TiXmlElement() +{ + ClearThis(); +} + + +void TiXmlElement::ClearThis() +{ + Clear(); + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } +} + + +const char* TiXmlElement::Attribute( const char* name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return &node->ValueStr(); + return 0; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, int* i ) const +{ + const char* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s ); + } + else { + *i = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const +{ + const std::string* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s->c_str() ); + } + else { + *i = 0; + } + } + return s; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const char* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s ); + } + else { + *d = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const std::string* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s->c_str() ); + } + else { + *d = 0; + } + } + return s; +} +#endif + + +int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} +#endif + + +int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} +#endif + + +void TiXmlElement::SetAttribute( const char * name, int val ) +{ + char buf[64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); + #else + sprintf( buf, "%d", val ); + #endif + SetAttribute( name, buf ); +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + std::ostringstream oss; + oss << val; + SetAttribute( name, oss.str() ); +} +#endif + + +void TiXmlElement::SetDoubleAttribute( const char * name, double val ) +{ + char buf[256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); + #else + sprintf( buf, "%f", val ); + #endif + SetAttribute( name, buf ); +} + + +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING _name( cname ); + TIXML_STRING _value( cvalue ); + #else + const char* _name = cname; + const char* _value = cvalue; + #endif + + TiXmlAttribute* node = attributeSet.Find( _name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) +{ + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} +#endif + + +void TiXmlElement::Print( FILE* cfile, int depth ) const +{ + int i; + assert( cfile ); + for ( i=0; iNext() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a node + // 2) An element with only a text child is printed as text + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i", value.c_str() ); + } +} + + +void TiXmlElement::CopyTo( TiXmlElement* target ) const +{ + // superclass: + TiXmlNode::CopyTo( target ); + + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +TiXmlNode* TiXmlElement::Clone() const +{ + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; +} + + +TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); +} + +TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} + + +#ifdef TIXML_USE_STL +TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} +#endif + + +TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDocument::operator=( const TiXmlDocument& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) +{ + // See STL_STRING_BUG below. + //StringToBuffer buf( value ); + + return LoadFile( Value(), encoding ); +} + + +bool TiXmlDocument::SaveFile() const +{ + // See STL_STRING_BUG below. +// StringToBuffer buf( value ); +// +// if ( buf.buffer && SaveFile( buf.buffer ) ) +// return true; +// +// return false; + return SaveFile( Value() ); +} + +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) +{ + // There was a really terrifying little bug here. The code: + // value = filename + // in the STL case, cause the assignment method of the std::string to + // be called. What is strange, is that the std::string had the same + // address as it's c_str() method, and so bad things happen. Looks + // like a bug in the Microsoft STL implementation. + // Add an extra string to avoid the crash. + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} + +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // + // + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + const char* lastPos = buf; + const char* p = buf; + + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + if ( *p == 0xa ) { + // Newline character. No special rules for this. Append all the characters + // since the last string, and include the newline. + data.append( lastPos, (p-lastPos+1) ); // append, include the newline + ++p; // move past the newline + lastPos = p; // and point to the new buffer (may be 0) + assert( p <= (buf+length) ); + } + else if ( *p == 0xd ) { + // Carriage return. Append what we have so far, then + // handle moving forward in the buffer. + if ( (p-lastPos) > 0 ) { + data.append( lastPos, p-lastPos ); // do not add the CR + } + data += (char)0xa; // a proper newline + + if ( *(p+1) == 0xa ) { + // Carriage return - new line sequence + p += 2; + lastPos = p; + assert( p <= (buf+length) ); + } + else { + // it was followed by something else...that is presumably characters again. + ++p; + lastPos = p; + assert( p <= (buf+length) ); + } + } + else { + ++p; + } + } + // Handle any left over characters. + if ( p-lastPos ) { + data.append( lastPos, p-lastPos ); + } + delete [] buf; + buf = 0; + + Parse( data.c_str(), 0, encoding ); + + if ( Error() ) + return false; + else + return true; +} + + +bool TiXmlDocument::SaveFile( const char * filename ) const +{ + // The old c stuff lives on... + FILE* fp = TiXmlFOpen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; +} + + +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + +void TiXmlDocument::CopyTo( TiXmlDocument* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->error = error; + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + + +TiXmlNode* TiXmlDocument::Clone() const +{ + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlDocument::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } +} + + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +const TiXmlAttribute* TiXmlAttribute::Next() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} + +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ + +const TiXmlAttribute* TiXmlAttribute::Previous() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} + +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ + +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + TIXML_STRING n, v; + + EncodeString( name, &n ); + EncodeString( value, &v ); + + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } + } + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } + } +} + + +int TiXmlAttribute::QueryIntValue( int* ival ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +int TiXmlAttribute::QueryDoubleValue( double* dval ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +void TiXmlAttribute::SetIntValue( int _value ) +{ + char buf [64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); + #else + sprintf (buf, "%d", _value); + #endif + SetValue (buf); +} + +void TiXmlAttribute::SetDoubleValue( double _value ) +{ + char buf [256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); + #else + sprintf (buf, "%lf", _value); + #endif + SetValue (buf); +} + +int TiXmlAttribute::IntValue() const +{ + return atoi (value.c_str ()); +} + +double TiXmlAttribute::DoubleValue() const +{ + return atof (value.c_str ()); +} + + +TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlComment::operator=( const TiXmlComment& base ) +{ + Clear(); + base.CopyTo( this ); +} + + +void TiXmlComment::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlComment::CopyTo( TiXmlComment* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlComment::Clone() const +{ + TiXmlComment* clone = new TiXmlComment(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlText::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } +} + + +void TiXmlText::CopyTo( TiXmlText* target ) const +{ + TiXmlNode::CopyTo( target ); + target->cdata = cdata; +} + + +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlText::Clone() const +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlDeclaration::TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} + + +#ifdef TIXML_USE_STL +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} +#endif + + +TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + if ( cfile ) fprintf( cfile, "" ); + if ( str ) (*str) += "?>"; +} + + +void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->version = version; + target->encoding = encoding; + target->standalone = standalone; +} + + +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlDeclaration::Clone() const +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlUnknown::Print( FILE* cfile, int depth ) const +{ + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlUnknown::Clone() const +{ + TiXmlUnknown* clone = new TiXmlUnknown(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlAttributeSet::TiXmlAttributeSet() +{ + sentinel.next = &sentinel; + sentinel.prev = &sentinel; +} + + +TiXmlAttributeSet::~TiXmlAttributeSet() +{ + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); +} + + +void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) +{ + #ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. + #else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + #endif + + addMe->next = &sentinel; + addMe->prev = sentinel.prev; + + sentinel.prev->next = addMe; + sentinel.prev = addMe; +} + +void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) +{ + TiXmlAttribute* node; + + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. +} + + +#ifdef TIXML_USE_STL +const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const +{ + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} +*/ +#endif + + +const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} +*/ + +#ifdef TIXML_USE_STL +std::istream& operator>> (std::istream & in, TiXmlNode & base) +{ + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); + + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; +} +#endif + + +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + + return out; +} + + +std::string& operator<< (std::string& out, const TiXmlNode& base ) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; +} +#endif + + +TiXmlHandle TiXmlHandle::FirstChild() const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement() const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && iNextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && iNextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && iNextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && iNextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += ""; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += ""; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += ""; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff --git a/engines/wintermute/tinyxml.h b/engines/wintermute/tinyxml.h new file mode 100644 index 0000000000..ee73173932 --- /dev/null +++ b/engines/wintermute/tinyxml.h @@ -0,0 +1,1803 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#define TIXML_USE_STL + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include +#include +#include +#include +#include + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include + #include + #include + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SNSCANF _snscanf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SNSCANF _snscanf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SNSCANF snscanf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 5; +const int TIXML_PATCH_VERSION = 3; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + DOCUMENT, + ELEMENT, + COMMENT, + UNKNOWN, + TEXT, + DECLARATION, + TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + const TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* Find( const char* _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + #ifdef TIXML_USE_STL + const TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* Find( const std::string& _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + + #endif + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + void operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + /* + This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" + but template specialization is hard to get working cross-compiler. Leaving the bug for now. + + // The above will fail for std::string because the space character is used as a seperator. + // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string + template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + */ + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetDoubleAttribute( const char * name, double value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); + #ifdef TIXML_USE_STL + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif + + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; + + /// Creates a new Element and returns it - the returned element is a copy. + virtual TiXmlNode* Clone() const; + // Print the Element to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + + void CopyTo( TiXmlElement* target ) const; + void ClearThis(); // like clear, but initializes 'this' object as well + + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + +private: + + TiXmlAttributeSet attributeSet; +}; + + +/** An XML comment. +*/ +class TiXmlComment : public TiXmlNode +{ +public: + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { + SetValue( _value ); + } + TiXmlComment( const TiXmlComment& ); + void operator=( const TiXmlComment& base ); + + virtual ~TiXmlComment() {} + + /// Returns a copy of this Comment. + virtual TiXmlNode* Clone() const; + // Write this Comment to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlComment* target ) const; + + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif +// virtual void StreamOut( TIXML_OSTREAM * out ) const; + +private: + +}; + + +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class TiXmlText : public TiXmlNode +{ + friend class TiXmlElement; +public: + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + #endif + + TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } + void operator=( const TiXmlText& base ) { base.CopyTo( this ); } + + // Write this text object to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + /// [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + void CopyTo( TiXmlText* target ) const; + + bool Blank() const; // returns true if all white space and new lines + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + bool cdata; // true if this should be input and output as a CDATA style text element +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ +class TiXmlDeclaration : public TiXmlNode +{ +public: + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} + +#ifdef TIXML_USE_STL + /// Constructor. + TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ); +#endif + + /// Construct. + TiXmlDeclaration( const char* _version, + const char* _encoding, + const char* _standalone ); + + TiXmlDeclaration( const TiXmlDeclaration& copy ); + void operator=( const TiXmlDeclaration& copy ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return an empty string if none was found. + const char *Version() const { return version.c_str (); } + /// Encoding. Will return an empty string if none was found. + const char *Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char *Standalone() const { return standalone.c_str (); } + + /// Creates a copy of this Declaration and returns it. + virtual TiXmlNode* Clone() const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlDeclaration* target ) const; + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class TiXmlUnknown : public TiXmlNode +{ +public: + TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} + virtual ~TiXmlUnknown() {} + + TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } + void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } + + /// Creates a copy of this Unknown and returns it. + virtual TiXmlNode* Clone() const; + // Print this Unknown to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected: + void CopyTo( TiXmlUnknown* target ) const; + + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + +}; + + +/** Always the top level node. A document binds together all the + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ +class TiXmlDocument : public TiXmlNode +{ +public: + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ); + #endif + + TiXmlDocument( const TiXmlDocument& copy ); + void operator=( const TiXmlDocument& copy ); + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && LoadFile( f.buffer, encoding )); + return LoadFile( filename.c_str(), encoding ); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && SaveFile( f.buffer )); + return SaveFile( filename.c_str() ); + } + #endif + + /** Parse the given null terminated block of xml data. Passing in an encoding to this + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } + + /** If an error occurs, Error will be set to true. Also, + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + int ErrorId() const { return errorId; } + + /** Returns the location (if known) of the error. The first column is column 1, + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) + + @sa SetTabSize, Row, Column + */ + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. + + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. + + Note that row and column tracking is not supported when using operator>>. + + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim + + @sa Row, Column + */ + void SetTabSize( int _tabsize ) { tabsize = _tabsize; } + + int TabSize() const { return tabsize; } + + /** If you have handled the error, it can be reset with this call. The error + state is automatically cleared if you Parse a new XML block. + */ + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; + } + + /** Write the document to standard out using formatted printing ("pretty print"). */ + void Print() const { Print( stdout, 0 ); } + + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + + /// Print this Document to a FILE stream. + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + void CopyTo( TiXmlDocument* target ) const; + + bool error; + int errorId; + TIXML_STRING errorDesc; + int tabsize; + TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. +}; + + +/** + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ +class TiXmlHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } + /// Copy constructor + TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } + + /// Return a handle to the first child node. + TiXmlHandle FirstChild() const; + /// Return a handle to the first child node with the given name. + TiXmlHandle FirstChild( const char * value ) const; + /// Return a handle to the first child element. + TiXmlHandle FirstChildElement() const; + /// Return a handle to the first child element with the given name. + TiXmlHandle FirstChildElement( const char * value ) const; + + /** Return a handle to the "index" child with the given name. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( const char* value, int index ) const; + /** Return a handle to the "index" child. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( int index ) const; + /** Return a handle to the "index" child element with the given name. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( const char* value, int index ) const; + /** Return a handle to the "index" child element. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( int index ) const; + + #ifdef TIXML_USE_STL + TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + + TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + #endif + + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } + +private: + TiXmlNode* node; +}; + + +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; iLoadFile(sprite_file))) SAFE_DELETE(m_Sprite); } diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp index 0f2df63aea..161f479b81 100644 --- a/engines/wintermute/BNamedObject.cpp +++ b/engines/wintermute/BNamedObject.cpp @@ -49,13 +49,14 @@ CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { ////////////////////////////////////////////////////////////////////////// CBNamedObject::~CBNamedObject(void) { - SAFE_DELETE_ARRAY(m_Name); + delete[] m_Name; + m_Name = NULL; } ////////////////////////////////////////////////////////////////////// void CBNamedObject::SetName(char *Name) { - SAFE_DELETE_ARRAY(m_Name); + delete[] m_Name; m_Name = new char [strlen(Name) + 1]; if (m_Name != NULL) strcpy(m_Name, Name); diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp index 488c1bdd7b..c85ea38a5e 100644 --- a/engines/wintermute/UITiledImage.cpp +++ b/engines/wintermute/UITiledImage.cpp @@ -58,7 +58,8 @@ CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUITiledImage::~CUITiledImage() { - SAFE_DELETE(m_Image); + delete m_Image; + m_Image = NULL; } @@ -198,10 +199,11 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_IMAGE: - SAFE_DELETE(m_Image); + delete m_Image; m_Image = new CBSubFrame(Game); if (!m_Image || FAILED(m_Image->SetSurface((char *)params))) { - SAFE_DELETE(m_Image); + delete m_Image; + m_Image = NULL; cmd = PARSERR_GENERIC; } break; diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index 8ef0f6df15..86e3eada49 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -329,37 +329,41 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BACK: - SAFE_DELETE(m_Back); + delete m_Back; m_Back = new CUITiledImage(Game); if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { - SAFE_DELETE(m_Back); + delete m_Back; + m_Back = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_INACTIVE: - SAFE_DELETE(m_BackInactive); + delete m_BackInactive; m_BackInactive = new CUITiledImage(Game); if (!m_BackInactive || FAILED(m_BackInactive->LoadFile((char *)params))) { - SAFE_DELETE(m_BackInactive); + delete m_BackInactive; + m_BackInactive = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE: - SAFE_DELETE(m_Image); + delete m_Image; m_Image = new CBSprite(Game); if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { - SAFE_DELETE(m_Image); + delete m_Image; + m_Image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_INACTIVE: - SAFE_DELETE(m_ImageInactive), + delete m_ImageInactive, m_ImageInactive = new CBSprite(Game); if (!m_ImageInactive || FAILED(m_ImageInactive->LoadFile((char *)params))) { - SAFE_DELETE(m_ImageInactive); + delete m_ImageInactive; + m_ImageInactive = NULL; cmd = PARSERR_GENERIC; } break; @@ -412,10 +416,11 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - SAFE_DELETE(m_Cursor); + delete m_Cursor; m_Cursor = new CBSprite(Game); if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - SAFE_DELETE(m_Cursor); + delete m_Cursor; + m_Cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -423,7 +428,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BUTTON: { CUIButton *btn = new CUIButton(Game); if (!btn || FAILED(btn->LoadBuffer(params, false))) { - SAFE_DELETE(btn); + delete btn; + btn = NULL; cmd = PARSERR_GENERIC; } else { btn->m_Parent = this; @@ -435,7 +441,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_STATIC: { CUIText *text = new CUIText(Game); if (!text || FAILED(text->LoadBuffer(params, false))) { - SAFE_DELETE(text); + delete text; + text = NULL; cmd = PARSERR_GENERIC; } else { text->m_Parent = this; @@ -447,7 +454,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_EDIT: { CUIEdit *edit = new CUIEdit(Game); if (!edit || FAILED(edit->LoadBuffer(params, false))) { - SAFE_DELETE(edit); + delete edit; + edit = NULL; cmd = PARSERR_GENERIC; } else { edit->m_Parent = this; @@ -459,7 +467,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_WINDOW: { CUIWindow *win = new CUIWindow(Game); if (!win || FAILED(win->LoadBuffer(params, false))) { - SAFE_DELETE(win); + delete win; + win = NULL; cmd = PARSERR_GENERIC; } else { win->m_Parent = this; -- cgit v1.2.3 From afee4aeacccf66f52fefacbb0904049f0ce45227 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 04:57:25 +0100 Subject: WINTERMUTE: One big and ugly commit that resolves most of the forbidden-symbols. The StringUtils aren't complete or tested, and the SysClasses are a hack, and there are a few "FORBIDDEN_SYMBOL_EXCEPTIONS". Expect this commit to need a bunch of cleanup going forwards. --- engines/wintermute/AdObject.cpp | 43 ++-- engines/wintermute/BBase.cpp | 10 +- engines/wintermute/BBase.h | 13 +- engines/wintermute/BFader.cpp | 3 +- engines/wintermute/BFileEntry.h | 2 +- engines/wintermute/BFileManager.cpp | 20 +- engines/wintermute/BFileManager.h | 4 +- engines/wintermute/BFontBitmap.cpp | 6 +- engines/wintermute/BFontTT.cpp | 23 ++- engines/wintermute/BFontTT.h | 6 +- engines/wintermute/BGame.cpp | 15 +- engines/wintermute/BGame.h | 2 +- engines/wintermute/BObject.h | 4 +- engines/wintermute/BParser.cpp | 3 +- engines/wintermute/BPkgFile.cpp | 9 +- engines/wintermute/BRegistry.cpp | 21 +- engines/wintermute/BRegistry.h | 4 +- engines/wintermute/BStringTable.cpp | 12 +- engines/wintermute/BStringTable.h | 6 +- engines/wintermute/BTransitionMgr.cpp | 4 +- engines/wintermute/BViewport.cpp | 8 +- engines/wintermute/FontGlyphCache.cpp | 6 +- engines/wintermute/FontGlyphCache.h | 3 +- engines/wintermute/PathUtil.cpp | 40 ++-- engines/wintermute/StringUtil.cpp | 154 +++++++++++---- engines/wintermute/StringUtil.h | 6 +- engines/wintermute/SysClass.cpp | 70 ++++--- engines/wintermute/SysClass.h | 23 ++- engines/wintermute/SysClassRegistry.cpp | 35 ++-- engines/wintermute/SysClassRegistry.h | 34 +++- engines/wintermute/SysInstance.cpp | 1 + engines/wintermute/UIEdit.cpp | 17 +- engines/wintermute/dctypes.h | 29 +-- engines/wintermute/scriptables/ScEngine.h | 2 +- engines/wintermute/scriptables/ScValue.cpp | 2 +- engines/wintermute/tinystr.cpp | 111 +++++++++++ engines/wintermute/tinystr.h | 305 +++++++++++++++++++++++++++++ engines/wintermute/tinyxml.h | 2 +- engines/wintermute/utils.cpp | 12 +- engines/wintermute/wintermute.cpp | 4 +- engines/wintermute/wintypes.h | 4 +- 41 files changed, 826 insertions(+), 252 deletions(-) create mode 100644 engines/wintermute/tinystr.cpp create mode 100644 engines/wintermute/tinystr.h (limited to 'engines') diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 11552b1488..0e2a351ed4 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -27,29 +27,30 @@ */ #include "dcgf.h" -#include "AdObject.h" -#include "AdScene.h" -#include "BGame.h" -#include "BFrame.h" -#include "BSound.h" -#include "BSurfaceStorage.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "AdGame.h" -#include "AdLayer.h" -#include "AdSceneNode.h" -#include "AdInventory.h" -#include "AdWaypointGroup.h" -#include "AdItem.h" -#include "BSubFrame.h" -#include "BFont.h" -#include "BFontStorage.h" +#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/AdItem.h" +#include "engines/wintermute/AdObject.h" +#include "engines/wintermute/AdInventory.h" +#include "engines/wintermute/AdLayer.h" +#include "engines/wintermute/AdScene.h" +#include "engines/wintermute/AdSceneNode.h" +#include "engines/wintermute/AdSentence.h" +#include "engines/wintermute/AdWaypointGroup.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFrame.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BStringTable.h" #include "engines/wintermute/scriptables/ScEngine.h" -#include "BStringTable.h" -#include "AdSentence.h" #include "engines/wintermute/scriptables/ScScript.h" -#include "BSprite.h" #include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" #include "common/str.h" +#include "common/util.h" namespace WinterMute { @@ -860,8 +861,8 @@ void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TT } // set duration by text length - if (m_Sentence->m_Duration <= 0) { - m_Sentence->m_Duration = MAX(1000, Game->m_SubtitlesSpeed * strlen(m_Sentence->m_Text)); + if (m_Sentence->m_Duration <= 0) {// TODO: Avoid longs. + m_Sentence->m_Duration = MAX((unsigned long)1000, Game->m_SubtitlesSpeed * strlen(m_Sentence->m_Text)); } diff --git a/engines/wintermute/BBase.cpp b/engines/wintermute/BBase.cpp index 845543c351..536decb5f9 100644 --- a/engines/wintermute/BBase.cpp +++ b/engines/wintermute/BBase.cpp @@ -57,7 +57,9 @@ CBBase::~CBBase() { ////////////////////////////////////////////////////////////////////////// const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { m_EditorPropsIter = m_EditorProps.find(PropName); - if (m_EditorPropsIter != m_EditorProps.end()) return m_EditorPropsIter->second.c_str(); + if (m_EditorPropsIter != m_EditorProps.end()) + return m_EditorPropsIter->_value.c_str(); + //return m_EditorPropsIter->second.c_str(); // <- TODO Clean else return InitVal; } @@ -161,8 +163,10 @@ HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { while (m_EditorPropsIter != m_EditorProps.end()) { Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->first.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->second.c_str()); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->_value.c_str()); + //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->first.c_str()); // <- TODO, remove + //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->second.c_str()); // <- TODO, remove Buffer->PutTextIndent(Indent, "}\n\n"); m_EditorPropsIter++; diff --git a/engines/wintermute/BBase.h b/engines/wintermute/BBase.h index ba228bc572..c72d687eca 100644 --- a/engines/wintermute/BBase.h +++ b/engines/wintermute/BBase.h @@ -31,8 +31,11 @@ #include "wintypes.h" #include "dctypes.h" -#include -#include +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +//#include +//#include namespace WinterMute { @@ -52,8 +55,10 @@ public: CBBase(CBGame *GameOwner); virtual ~CBBase(); - std::map m_EditorProps; - std::map::iterator m_EditorPropsIter; + Common::HashMap m_EditorProps; + Common::HashMap::iterator m_EditorPropsIter; +/* std::map m_EditorProps; + std::map::iterator m_EditorPropsIter;*/ }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFader.cpp b/engines/wintermute/BFader.cpp index f64023a08d..955f0252f5 100644 --- a/engines/wintermute/BFader.cpp +++ b/engines/wintermute/BFader.cpp @@ -30,6 +30,7 @@ #include "BFader.h" #include "BGame.h" #include "PlatformSDL.h" +#include "common/util.h" namespace WinterMute { @@ -73,7 +74,7 @@ HRESULT CBFader::Update() { else { m_CurrentAlpha = m_SourceAlpha + (float)time / (float)m_Duration * AlphaDelta; } - m_CurrentAlpha = MIN(255, std::max(m_CurrentAlpha, (byte )0)); + m_CurrentAlpha = MIN((unsigned char)255, MAX(m_CurrentAlpha, (byte )0)); // TODO: clean m_Ready = time >= m_Duration; if (m_Ready && m_CurrentAlpha == 0x00) m_Active = false; diff --git a/engines/wintermute/BFileEntry.h b/engines/wintermute/BFileEntry.h index cfad80926c..2c555c8bfe 100644 --- a/engines/wintermute/BFileEntry.h +++ b/engines/wintermute/BFileEntry.h @@ -42,7 +42,7 @@ public: uint32 m_TimeDate1; uint32 m_Flags; uint32 m_JournalTime; - std::string m_Filename; + Common::String m_Filename; uint32 m_CompressedLength; uint32 m_Length; uint32 m_Offset; diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index ce0de04596..8763506e99 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -43,6 +43,7 @@ #include "PlatformSDL.h" #include "common/str.h" #include "common/textconsole.h" +#include "common/util.h" //#include #ifdef __WIN32__ @@ -106,7 +107,7 @@ HRESULT CBFileManager::Cleanup() { // delete file entries m_FilesIter = m_Files.begin(); while (m_FilesIter != m_Files.end()) { - delete m_FilesIter->second; + delete m_FilesIter->_value; m_FilesIter++; } m_Files.clear(); @@ -491,7 +492,6 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool fread(&TimeDate1, sizeof(uint32), 1, f); fread(&TimeDate2, sizeof(uint32), 1, f); } - m_FilesIter = m_Files.find(Name); if (m_FilesIter == m_Files.end()) { CBFileEntry *file = new CBFileEntry(Game); @@ -504,12 +504,12 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool m_Files[Name] = file; } else { // current package has lower CD number or higher priority, than the registered - if (pkg->m_CD < m_FilesIter->second->m_Package->m_CD || pkg->m_Priority > m_FilesIter->second->m_Package->m_Priority) { - m_FilesIter->second->m_Package = pkg; - m_FilesIter->second->m_Offset = Offset; - m_FilesIter->second->m_Length = Length; - m_FilesIter->second->m_CompressedLength = CompLength; - m_FilesIter->second->m_Flags = Flags; + if (pkg->m_CD < m_FilesIter->_value->m_Package->m_CD || pkg->m_Priority > m_FilesIter->_value->m_Package->m_Priority) { + m_FilesIter->_value->m_Package = pkg; + m_FilesIter->_value->m_Offset = Offset; + m_FilesIter->_value->m_Length = Length; + m_FilesIter->_value->m_CompressedLength = CompLength; + m_FilesIter->_value->m_Flags = Flags; } } delete [] Name; @@ -605,7 +605,7 @@ CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { CBFileEntry *ret = NULL; m_FilesIter = m_Files.find(upc_name); - if (m_FilesIter != m_Files.end()) ret = m_FilesIter->second; + if (m_FilesIter != m_Files.end()) ret = m_FilesIter->_value; delete [] upc_name; @@ -721,7 +721,7 @@ bool CBFileManager::FindPackageSignature(FILE *f, uint32 *Offset) { int BytesRead = StartPos; while (BytesRead < FileSize - 16) { - int ToRead = MIN(32768, FileSize - BytesRead); + int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); fseek(f, StartPos, SEEK_SET); int ActuallyRead = fread(buf, 1, ToRead, f); if (ActuallyRead != ToRead) return false; diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index e585841a4a..849a30bf8e 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -68,10 +68,10 @@ public: CBArray m_Packages; CBArray m_OpenFiles; - std::map m_Files; + Common::HashMap m_Files; private: HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); - std::map::iterator m_FilesIter; + Common::HashMap::iterator m_FilesIter; bool IsValidPackage(const AnsiString &fileName) const; }; diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 4b5b0c6199..9b49a84079 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -92,10 +92,12 @@ int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { str = AnsiString((char *)text); } - if (MaxLength >= 0 && str.length() > MaxLength) str = str.substr(0, MaxLength); + if (MaxLength >= 0 && str.size() > MaxLength) + str = Common::String(str.c_str(), MaxLength); + //str.substr(0, MaxLength); // TODO: Remove int TextWidth = 0; - for (size_t i = 0; i < str.length(); i++) { + for (size_t i = 0; i < str.size(); i++) { TextWidth += GetCharWidth(str[i]); } diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index a1ca6577fa..398d3bb1d9 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -124,7 +124,9 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text); - if (MaxLength >= 0 && text.length() > MaxLength) text = text.substr(0, MaxLength); + if (MaxLength >= 0 && text.size() > MaxLength) + text = Common::String(text.c_str(), MaxLength); + //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; MeasureText(text, -1, -1, textWidth, textHeight); @@ -156,7 +158,9 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text); - if (MaxLength >= 0 && text.length() > MaxLength) text = text.substr(0, MaxLength); + if (MaxLength >= 0 && text.size() > MaxLength) + text = Common::String(text.c_str(), MaxLength); + //text = text.substr(0, MaxLength); // TODO: Remove CBRenderSDL *m_Renderer = (CBRenderSDL *)Game->m_Renderer; @@ -258,7 +262,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex textOffset = 0; - for (size_t i = 0; i < line->GetText().length(); i++) { + for (size_t i = 0; i < line->GetText().size(); i++) { wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); @@ -271,7 +275,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex int origPosX = posX; wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().length(); i++) { + for (size_t i = 0; i < line->GetText().size(); i++) { wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); @@ -700,7 +704,7 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex PrepareGlyphs(text); - for (size_t i = 0; i < text.length(); i++) { + for (size_t i = 0; i < text.size(); i++) { wchar_t ch = text[i]; if (ch == L' ') { @@ -728,7 +732,7 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex if (lineTooLong && currWidth == 0) break; - if (ch == L'\n' || i == text.length() - 1 || lineTooLong) { + if (ch == L'\n' || i == text.size() - 1 || lineTooLong) { int breakPoint, breakWidth; if (prevSpaceIndex >= 0 && lineTooLong) { @@ -742,7 +746,7 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex breakOnSpace = (ch == L'\n'); // we're at the end - if (i == text.length() - 1) { + if (i == text.size() - 1) { breakPoint++; breakWidth += charWidth; } @@ -750,7 +754,8 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex if (maxHeight >= 0 && (lines.size() + 1) * GetLineHeight() > maxHeight) break; - WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); + //WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); // TODO: Remove + WideString line = Common::String(text.c_str() + lineStartIndex, breakPoint - lineStartIndex); lines.push_back(new TextLine(line, breakWidth)); currWidth = 0; @@ -805,7 +810,7 @@ float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { ////////////////////////////////////////////////////////////////////////// void CBFontTT::PrepareGlyphs(const WideString &text) { // make sure we have all the glyphs we need - for (size_t i = 0; i < text.length(); i++) { + for (size_t i = 0; i < text.size(); i++) { wchar_t ch = text[i]; if (!m_GlyphCache->HasGlyph(ch)) CacheGlyph(ch); } diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 6fbb019a27..5675cca5de 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -35,6 +35,7 @@ #define NUM_CACHED_TEXTS 30 class SDL_Surface; +class SDL_Rect; namespace WinterMute { class FontGlyphCache; @@ -55,7 +56,8 @@ private: bool m_Marked; CBCachedTTFontText() { - m_Text = L""; + //m_Text = L""; + m_Text = ""; m_Width = m_MaxHeight = m_MaxLength = -1; m_Align = TAL_LEFT; m_Surface = NULL; @@ -108,7 +110,7 @@ public: WideString m_Text; int m_Width; }; - typedef std::list TextLineList; + typedef Common::List TextLineList; public: diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index a4329fc5df..5cc048b48d 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -68,6 +68,7 @@ #include "engines/wintermute/scriptables/SXStore.h" #include "engines/wintermute/scriptables/SXString.h" #include "common/textconsole.h" +#include "common/util.h" #ifdef __IPHONEOS__ # include "ios_utils.h" @@ -514,7 +515,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { m_DEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); } - if (m_DEBUG_LogFile != NULL) fprintf(m_DEBUG_LogFile, "\n"); + if (m_DEBUG_LogFile != NULL) fprintf((FILE*)m_DEBUG_LogFile, "\n"); #endif time_t timeNow; @@ -540,7 +541,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { void CBGame::DEBUG_DebugDisable() { if (m_DEBUG_LogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - fclose(m_DEBUG_LogFile); + fclose((FILE*)m_DEBUG_LogFile); m_DEBUG_LogFile = NULL; } m_DEBUG_DebugMode = false; @@ -576,8 +577,8 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { if (m_DebugMgr) m_DebugMgr->OnLog(res, buff); warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fprintf(m_DEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fflush(m_DEBUG_LogFile); + fprintf((FILE*)m_DEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fflush((FILE*)m_DEBUG_LogFile); #endif //QuickMessage(buff); @@ -615,12 +616,12 @@ HRESULT CBGame::InitLoop() { m_LiveTimerDelta = m_LiveTimer - m_LiveTimerLast; m_LiveTimerLast = m_LiveTimer; - m_LiveTimer += MIN(1000, m_DeltaTime); + m_LiveTimer += MIN((uint32)1000, m_DeltaTime); if (m_State != GAME_FROZEN) { m_TimerDelta = m_Timer - m_TimerLast; m_TimerLast = m_Timer; - m_Timer += MIN(1000, m_DeltaTime); + m_Timer += MIN((uint32)1000, m_DeltaTime); } else m_TimerDelta = 0; m_FramesRendered++; @@ -2015,7 +2016,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS int BytesRead = 0; while (BytesRead < File->GetSize()) { - int BufSize = MIN(1024, File->GetSize() - BytesRead); + int BufSize = MIN((uint32)1024, File->GetSize() - BytesRead); BytesRead += BufSize; File->Read(Buf, BufSize); diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 610915d154..5de2beacc3 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -191,7 +191,7 @@ public: bool m_DEBUG_DebugMode; bool m_DEBUG_AbsolutePathWarning; - FILE *m_DEBUG_LogFile; + void *m_DEBUG_LogFile; int m_Sequence; virtual HRESULT LoadFile(const char *Filename); virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 064cc78fc4..3fd22fafcd 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -30,10 +30,12 @@ #define WINTERMUTE_BOBJECT_H -#include "SDL.h" +//#include "SDL.h" #include "BScriptHolder.h" #include "persistent.h" +union SDL_Event; + namespace WinterMute { class CBSprite; diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp index de8dd140d2..94de0771f9 100644 --- a/engines/wintermute/BParser.cpp +++ b/engines/wintermute/BParser.cpp @@ -31,6 +31,7 @@ #include "BGame.h" #include "PlatformSDL.h" #include "common/str.h" +#include "common/util.h" #define WHITESPACE " \t\n\r" @@ -88,7 +89,7 @@ long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data if (tokens->id == 0) { char *p = strchr(*buf, '\n'); if (p && p > *buf) { - strncpy(m_LastOffender, *buf, MIN(255, p - *buf)); + strncpy(m_LastOffender, *buf, MIN((long int)255, p - *buf)); // TODO, clean } else strcpy(m_LastOffender, ""); return PARSERR_TOKENNOTFOUND; diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index 1210d90e24..deac1c8817 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -31,6 +31,7 @@ #include "BPkgFile.h" #include "BGame.h" #include "BFileManager.h" +#include "common/util.h" #if _DEBUG #pragma comment(lib, "zlib_d.lib") @@ -131,7 +132,7 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { while (m_Stream.total_out - InitOut < Size && m_Stream.total_in < m_FileEntry->m_CompressedLength) { // needs to read more data? if (m_Stream.avail_in == 0) { - m_Stream.avail_in = MIN(COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); + m_Stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); // TODO: long unsigned int???? m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); m_Stream.next_in = m_CompBuffer; } @@ -192,7 +193,7 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { m_Stream.avail_in = 0; m_Stream.next_in = m_CompBuffer; - m_Stream.avail_out = MIN(STREAM_BUFFER_SIZE, NewPos); + m_Stream.avail_out = MIN((uint32)STREAM_BUFFER_SIZE, NewPos); //TODO: remove cast. m_Stream.next_out = StreamBuffer; inflateInit(&m_Stream); m_InflateInit = true; @@ -200,7 +201,7 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { while (m_Stream.total_out < NewPos && m_Stream.total_in < m_FileEntry->m_CompressedLength) { // needs to read more data? if (m_Stream.avail_in == 0) { - m_Stream.avail_in = MIN(COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); + m_Stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); // TODO: long unsigned int??? m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); m_Stream.next_in = m_CompBuffer; } @@ -208,7 +209,7 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { // needs more space? if (m_Stream.avail_out == 0) { m_Stream.next_out = StreamBuffer; - m_Stream.avail_out = MIN(STREAM_BUFFER_SIZE, NewPos - m_Stream.total_out); + m_Stream.avail_out = MIN((long unsigned int)STREAM_BUFFER_SIZE, NewPos - m_Stream.total_out); // TODO: long unsigned int???. } // stream on! diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp index 4d7b1b6d37..75b621d90f 100644 --- a/engines/wintermute/BRegistry.cpp +++ b/engines/wintermute/BRegistry.cpp @@ -159,26 +159,27 @@ AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, con PathValueMap::iterator it = values.find(path); if (it == values.end()) return ""; - KeyValuePair pairs = (*it).second; + KeyValuePair pairs = (*it)._value; KeyValuePair::iterator keyIt = pairs.find(key); if (keyIt == pairs.end()) return ""; else { found = true; - return (*keyIt).second; + return (*keyIt)._value; } } ////////////////////////////////////////////////////////////////////////// void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName); + TiXmlDocument doc(fileName.c_str()); if (!doc.LoadFile()) return; TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || rootElem->ValueStr() != "Settings") return; + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[pathElem->ValueStr()][keyElem->ValueStr()] = keyElem->GetText(); + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); } } } @@ -196,17 +197,17 @@ void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { PathValueMap::iterator pathIt; for (pathIt = m_Values.begin(); pathIt != m_Values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt).first); + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); root->LinkEndChild(pathElem); - KeyValuePair pairs = (*pathIt).second; + KeyValuePair pairs = (*pathIt)._value; KeyValuePair::iterator keyIt; for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt).first); + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); pathElem->LinkEndChild(keyElem); - keyElem->LinkEndChild(new TiXmlText((*keyIt).second)); + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); } } @@ -219,7 +220,7 @@ void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { if (!stream.is_open()) return; else { - stream << printer.Str(); + stream << printer.CStr(); stream.close(); } } diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h index 48b88fd663..2838d3794f 100644 --- a/engines/wintermute/BRegistry.h +++ b/engines/wintermute/BRegistry.h @@ -57,8 +57,8 @@ public: private: char *m_IniName; - typedef std::map KeyValuePair; - typedef std::map PathValueMap; + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; PathValueMap m_LocalValues; PathValueMap m_Values; diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp index e3bf2fd89b..fda4853115 100644 --- a/engines/wintermute/BStringTable.cpp +++ b/engines/wintermute/BStringTable.cpp @@ -58,7 +58,7 @@ HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDu return S_OK; } - std::string final_key = Key; + Common::String final_key = Key; StringUtil::ToLowerCase(final_key); m_StringsIter = m_Strings.find(final_key); @@ -85,8 +85,8 @@ char *CBStringTable::GetKey(const char *Str) { m_StringsIter = m_Strings.find(key); if (m_StringsIter != m_Strings.end()) { - new_str = new char[m_StringsIter->second.length() + 1]; - strcpy(new_str, m_StringsIter->second.c_str()); + new_str = new char[m_StringsIter->_value.size() + 1]; + strcpy(new_str, m_StringsIter->_value.c_str()); if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { delete [] key; char *Ret = GetKey(new_str); @@ -121,8 +121,8 @@ void CBStringTable::Expand(char **Str, bool ForceExpand) { m_StringsIter = m_Strings.find(key); if (m_StringsIter != m_Strings.end()) { - new_str = new char[m_StringsIter->second.length() + 1]; - strcpy(new_str, m_StringsIter->second.c_str()); + new_str = new char[m_StringsIter->_value.size() + 1]; + strcpy(new_str, m_StringsIter->_value.c_str()); } else { new_str = new char[strlen(value) + 1]; strcpy(new_str, value); @@ -156,7 +156,7 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { m_StringsIter = m_Strings.find(key); if (m_StringsIter != m_Strings.end()) { - new_str = m_StringsIter->second.c_str(); + new_str = m_StringsIter->_value.c_str(); } else { new_str = value; } diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h index 6b28f5307d..28617c8593 100644 --- a/engines/wintermute/BStringTable.h +++ b/engines/wintermute/BStringTable.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BSTRINGTABLE_H -#include +#include "common/hashmap.h" #include "BBase.h" namespace WinterMute { @@ -43,10 +43,10 @@ public: HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); - std::map m_Strings; + Common::HashMap m_Strings; char *GetKey(const char *Str); private: - std::map::iterator m_StringsIter; + Common::HashMap::iterator m_StringsIter; }; diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp index 56703b3336..78fd43c545 100644 --- a/engines/wintermute/BTransitionMgr.cpp +++ b/engines/wintermute/BTransitionMgr.cpp @@ -98,7 +98,7 @@ HRESULT CBTransitionMgr::Update() { case TRANSITION_FADE_OUT: { uint32 time = CBPlatform::GetTime() - m_LastTime; int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; - Alpha = std::min(255, std::max(Alpha, 0)); + Alpha = MIN(255, MAX(Alpha, 0)); Game->m_Renderer->Fade((WORD)Alpha); if (time > FADE_DURATION) m_State = TRANS_MGR_READY; @@ -108,7 +108,7 @@ HRESULT CBTransitionMgr::Update() { case TRANSITION_FADE_IN: { uint32 time = CBPlatform::GetTime() - m_LastTime; int Alpha = (float)time / (float)FADE_DURATION * 255; - Alpha = std::min(255, std::max(Alpha, 0)); + Alpha = MIN(255, MAX(Alpha, 0)); Game->m_Renderer->Fade((WORD)Alpha); if (time > FADE_DURATION) m_State = TRANS_MGR_READY; diff --git a/engines/wintermute/BViewport.cpp b/engines/wintermute/BViewport.cpp index bb2f5b6b29..57cb1bc02f 100644 --- a/engines/wintermute/BViewport.cpp +++ b/engines/wintermute/BViewport.cpp @@ -65,10 +65,10 @@ HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoCheck) { if (!NoCheck) { - left = std::max(left, 0); - top = std::max(top, 0); - right = std::min(right, Game->m_Renderer->m_Width); - bottom = std::min(bottom, Game->m_Renderer->m_Height); + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, Game->m_Renderer->m_Width); + bottom = MIN(bottom, Game->m_Renderer->m_Height); } CBPlatform::SetRect(&m_Rect, left, top, right, bottom); diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index 6181fb2704..04c7095dd1 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -36,8 +36,8 @@ FontGlyphCache::~FontGlyphCache() { GlyphInfoMap::iterator it; for (it = m_Glyphs.begin(); it != m_Glyphs.end(); ++it) { - delete it->second; - it->second = NULL; + delete it->_value; + it->_value = NULL; } } @@ -56,7 +56,7 @@ GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { it = m_Glyphs.find(ch); if (it == m_Glyphs.end()) return NULL; - return it->second; + return it->_value; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 50db962771..c30e0f92b8 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -111,7 +111,8 @@ public: void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0); private: - typedef std::map GlyphInfoMap; + //typedef Common::HashMap GlyphInfoMap; + typedef Common::HashMap GlyphInfoMap; // TODO GlyphInfoMap m_Glyphs; }; diff --git a/engines/wintermute/PathUtil.cpp b/engines/wintermute/PathUtil.cpp index d7d632f398..aea35e395f 100644 --- a/engines/wintermute/PathUtil.cpp +++ b/engines/wintermute/PathUtil.cpp @@ -77,40 +77,48 @@ AnsiString PathUtil::Combine(const AnsiString &path1, const AnsiString &path2) { AnsiString PathUtil::GetDirectoryName(const AnsiString &path) { AnsiString newPath = UnifySeparators(path); - size_t pos = newPath.find_last_of(L'/'); - - if (pos == AnsiString::npos) return ""; - else return newPath.substr(0, pos + 1); + //size_t pos = newPath.find_last_of(L'/'); + Common::String filename = GetFileName(path); + return Common::String(path.c_str(), path.size() - filename.size()); + //if (pos == AnsiString::npos) return ""; + //else return newPath.substr(0, pos + 1); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::GetFileName(const AnsiString &path) { AnsiString newPath = UnifySeparators(path); - size_t pos = newPath.find_last_of(L'/'); - - if (pos == AnsiString::npos) return path; - else return newPath.substr(pos + 1); + //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. + Common::String lastPart = Common::lastPathComponent(path,'/'); + if (lastPart[lastPart.size() - 1 ] != '/') + return lastPart; + else + return path; + //if (pos == AnsiString::npos) return path; + //else return newPath.substr(pos + 1); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { AnsiString fileName = GetFileName(path); - size_t pos = fileName.find_last_of('.'); - - if (pos == AnsiString::npos) return fileName; - else return fileName.substr(0, pos); + //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! + // TODO: Prettify this. + Common::String extension = Common::lastPathComponent(path, '.'); + Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); + return filename; + //if (pos == AnsiString::npos) return fileName; + //else return fileName.substr(0, pos); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::GetExtension(const AnsiString &path) { AnsiString fileName = GetFileName(path); - size_t pos = fileName.find_last_of('.'); - - if (pos == AnsiString::npos) return ""; - else return fileName.substr(pos); + //size_t pos = fileName.find_last_of('.'); + return Common::lastPathComponent(path, '.'); + //if (pos == AnsiString::npos) return ""; + //else return fileName.substr(pos); } diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index f3b4e0c0db..a8af7f25ec 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -42,9 +42,9 @@ void StringUtil::ToLowerCase(AnsiString &str) { } ////////////////////////////////////////////////////////////////////////// -void StringUtil::ToLowerCase(WideString &str) { +/*void StringUtil::ToLowerCase(WideString &str) { std::transform(str.begin(), str.end(), str.begin(), ::towlower); -} +}*/ ////////////////////////////////////////////////////////////////////////// void StringUtil::ToUpperCase(AnsiString &str) { @@ -52,9 +52,9 @@ void StringUtil::ToUpperCase(AnsiString &str) { } ////////////////////////////////////////////////////////////////////////// -void StringUtil::ToUpperCase(WideString &str) { +/*void StringUtil::ToUpperCase(WideString &str) { std::transform(str.begin(), str.end(), str.begin(), ::towupper); -} +}*/ ////////////////////////////////////////////////////////////////////////// bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { @@ -68,7 +68,7 @@ bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { } ////////////////////////////////////////////////////////////////////////// -bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { +/*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { WideString str1lc = str1; WideString str2lc = str2; @@ -76,11 +76,12 @@ bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { ToLowerCase(str2lc); return (str1lc == str2lc); -} +}*/ ////////////////////////////////////////////////////////////////////////// WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { - size_t WideSize = Utf8Str.length(); + error("WideString not supported yet"); +/* size_t WideSize = Utf8Str.size(); if (sizeof(wchar_t) == 2) { wchar_t *WideStringNative = new wchar_t[WideSize + 1]; @@ -122,12 +123,14 @@ WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { return ResultString; } else { return L""; - } + }*/ + return ""; } ////////////////////////////////////////////////////////////////////////// Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { - size_t WideSize = WideStr.length(); + error("Widestring not supported yet"); +/* size_t WideSize = WideStr.length(); if (sizeof(wchar_t) == 2) { size_t Utf8Size = 3 * WideSize + 1; @@ -169,37 +172,42 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { return ResultString; } else { return (Utf8String)""; - } + }*/ + return ""; } ////////////////////////////////////////////////////////////////////////// WideString StringUtil::AnsiToWide(const AnsiString &str) { // using default os locale! - setlocale(LC_CTYPE, ""); + error("WideString not supported yet"); +/* setlocale(LC_CTYPE, ""); size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; wchar_t *wstr = new wchar_t[WideSize]; mbstowcs(wstr, str.c_str(), WideSize); WideString ResultString(wstr); delete [] wstr; - return ResultString; + return ResultString;*/ + return ""; } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::WideToAnsi(const WideString &wstr) { // using default os locale! - setlocale(LC_CTYPE, ""); + error("WideString not supported yet"); +/* setlocale(LC_CTYPE, ""); size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; wcstombs(str, wstr.c_str(), WideSize); AnsiString ResultString(str); delete [] str; - return ResultString; + return ResultString;*/ + return ""; } ////////////////////////////////////////////////////////////////////////// bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - size_t strLength = str.length(); - size_t patternLength = pattern.length(); +/* size_t strLength = str.size(); + size_t patternLength = pattern.size(); if (strLength < patternLength || patternLength == 0) return false; @@ -207,13 +215,26 @@ bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bo AnsiString startPart = str.substr(0, patternLength); if (ignoreCase) return CompareNoCase(startPart, pattern); - else return (startPart == pattern); + else return (startPart == pattern);*/ + if (!ignoreCase) + return str.hasPrefix(pattern); + else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart(str.c_str(), patternLength); + uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + return (likeness == 0); + } } ////////////////////////////////////////////////////////////////////////// bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - size_t strLength = str.length(); - size_t patternLength = pattern.length(); +/* size_t strLength = str.size(); // TODO: Remove + size_t patternLength = pattern.size(); if (strLength < patternLength || patternLength == 0) return false; @@ -221,7 +242,20 @@ bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool AnsiString endPart = str.substr(strLength - patternLength, patternLength); if (ignoreCase) return CompareNoCase(endPart, pattern); - else return (endPart == pattern); + else return (endPart == pattern);*/ + if (!ignoreCase) { + return str.hasSuffix(pattern); + } else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + Common::String endPart(str.c_str(), strLength - patternLength); + uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + return (likeness == 0); + } } ////////////////////////////////////////////////////////////////////////// @@ -237,12 +271,20 @@ AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, co AnsiString result = str; size_t pos = 0; - while (true) { - pos = result.find(from, pos); + while (result.contains(from)) { + const char* startPtr = strstr(result.c_str(), from.c_str()); + uint32 index = startPtr - result.c_str(); + + Common::String tail(result.c_str() + index + to.size()); + result = Common::String(result.c_str(), index); + result += to; + result += tail; + +/* pos = result.find(from, pos); if (pos == result.npos) break; result.replace(pos, from.size(), to); - pos += to.size(); + pos += to.size();*/ } return result; @@ -252,55 +294,83 @@ AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, co AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { AnsiString trimmedStr = str; - if (fromRight) - trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); - if (fromLeft) - trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); - + if (fromRight) { + //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO + warning("fromRight-trim not implemented yet, %s", chars.c_str()); + } + if (fromLeft) { + uint32 lastOf = LastIndexOf(str, chars, 0); + trimmedStr = Common::String(trimmedStr.c_str() + lastOf); + //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); + } return trimmedStr; } ////////////////////////////////////////////////////////////////////////// int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - size_t pos = str.find(toFind, startFrom); + /*size_t pos = str.find(toFind, startFrom); if (pos == str.npos) return -1; - else return pos; + else return pos;*/ + const char* index = strstr(str.c_str(), toFind.c_str()); + if (index == NULL) + return -1; + else + return str.c_str() - index; } ////////////////////////////////////////////////////////////////////////// int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - size_t pos = str.rfind(toFind, startFrom); + /*size_t pos = str.rfind(toFind, startFrom); if (pos == str.npos) return -1; - else return pos; + else return pos;*/ + uint32 lastIndex = -1; + bool found = false; + for (int i = startFrom; i < str.size(); i++) { + found = false; + for (int j = 0; j < toFind.size(); j++) { + if (str[i+j] != toFind[j]) { + found = false; + break; + } else { + found = true; + } + } + if (found) + lastIndex = i; + } + return lastIndex; } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(size_t val) { - std::ostringstream str; +/* std::ostringstream str; str << val; - return str.str(); + return str.str();*/ + return Common::String::format("%u", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(int val) { - std::ostringstream str; +/* std::ostringstream str; str << val; - return str.str(); - + return str.str();*/ + return Common::String::format("%d", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(float val) { - std::ostringstream str; +/* std::ostringstream str; str << val; - return str.str(); + return str.str();*/ + return Common::String::format("%f", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(double val) { - std::ostringstream str; +/* std::ostringstream str; str << val; - return str.str(); + return str.str();*/ + return Common::String::format("%f", val); } @@ -315,7 +385,7 @@ void StringUtil::Split(const AnsiString &list, const AnsiString &delimiters, Ans //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); //tokenizer_t tokens(list, del); while (!tokenizer.empty()) { - std::string copy(tokenizer.nextToken().c_str()); + Common::String copy(tokenizer.nextToken().c_str()); result.push_back(copy); } } diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h index 80c95ced03..f62f82db9a 100644 --- a/engines/wintermute/StringUtil.h +++ b/engines/wintermute/StringUtil.h @@ -36,11 +36,11 @@ namespace WinterMute { class StringUtil { public: static void ToLowerCase(AnsiString &str); - static void ToLowerCase(WideString &str); + //static void ToLowerCase(WideString &str); static void ToUpperCase(AnsiString &str); - static void ToUpperCase(WideString &str); + //static void ToUpperCase(WideString &str); static bool CompareNoCase(const AnsiString &str1, const AnsiString &str2); - static bool CompareNoCase(const WideString &str1, const WideString &str2); + //static bool CompareNoCase(const WideString &str1, const WideString &str2); static WideString Utf8ToWide(const Utf8String &Utf8Str); static Utf8String WideToUtf8(const WideString &WideStr); static WideString AnsiToWide(const AnsiString &str); diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp index a673943b57..ebde28cdb1 100644 --- a/engines/wintermute/SysClass.cpp +++ b/engines/wintermute/SysClass.cpp @@ -35,6 +35,8 @@ namespace WinterMute { +// TODO: Note that the set was removed, this might have bizarre side-effects. + ////////////////////////////////////////////////////////////////////////// CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { m_Name = name; @@ -58,11 +60,11 @@ CSysClass::~CSysClass() { ////////////////////////////////////////////////////////////////////////// bool CSysClass::RemoveAllInstances() { - Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { - delete(*it); + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + delete(it->_value); } - m_Instances.clear(); + //m_Instances.clear(); m_InstanceMap.clear(); return true; @@ -72,7 +74,7 @@ bool CSysClass::RemoveAllInstances() { CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { CSysInstance *inst = new CSysInstance(instance, id, this); inst->SetSavedID(savedId); - m_Instances.insert(inst); + //m_Instances.insert(inst); m_InstanceMap[instance] = inst; @@ -86,13 +88,14 @@ CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { bool CSysClass::RemoveInstance(void *instance) { InstanceMap::iterator mapIt = m_InstanceMap.find(instance); if (mapIt == m_InstanceMap.end()) return false; - +/* Instances::iterator it = m_Instances.find((*mapIt).second); if (it != m_Instances.end()) { delete(*it); m_Instances.erase(it); - } + }*/ + delete mapIt->_value; m_InstanceMap.erase(mapIt); return false; @@ -102,39 +105,49 @@ bool CSysClass::RemoveInstance(void *instance) { int CSysClass::GetInstanceID(void *pointer) { InstanceMap::iterator mapIt = m_InstanceMap.find(pointer); if (mapIt == m_InstanceMap.end()) return -1; - else return (*mapIt).second->GetID(); + else return (*mapIt)._value->GetID(); } ////////////////////////////////////////////////////////////////////////// void *CSysClass::IDToPointer(int savedID) { //slow - Instances::iterator it; + /*Instances::iterator it; for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); + }*/ + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); } return NULL; } ////////////////////////////////////////////////////////////////////////// int CSysClass::GetNumInstances() { - return m_Instances.size(); + //return m_Instances.size(); + return m_InstanceMap.size(); // TODO: This might break, if we have multiple keys per value. } ////////////////////////////////////////////////////////////////////////// -void CSysClass::Dump(FILE *stream) { - fprintf(stream, "%03d %c %-20s instances: %d\n", m_ID, m_Persistent ? 'p' : ' ', m_Name.c_str(), GetNumInstances()); +void CSysClass::Dump(void *stream) { + fprintf((FILE*)stream, "%03d %c %-20s instances: %d\n", m_ID, m_Persistent ? 'p' : ' ', m_Name.c_str(), GetNumInstances()); } ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { PersistMgr->PutString(m_Name.c_str()); PersistMgr->PutDWORD(m_ID); - PersistMgr->PutDWORD(m_Instances.size()); + PersistMgr->PutDWORD(m_InstanceMap.size()); + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + PersistMgr->PutDWORD((it->_value)->GetID()); + } + /* Instances::iterator it; for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { PersistMgr->PutDWORD((*it)->GetID()); - } + }*/ } ////////////////////////////////////////////////////////////////////////// @@ -151,10 +164,11 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { continue; } - Instances::iterator it = m_Instances.begin(); - if (it != m_Instances.end()) { - (*it)->SetSavedID(instId); - CSysClassRegistry::GetInstance()->AddInstanceToTable((*it), (*it)->GetInstance()); + InstanceMap::iterator it = m_InstanceMap.begin(); +/* Instances::iterator it = m_Instances.begin();*/ + if (it != m_InstanceMap.end()) { + (it->_value)->SetSavedID(instId); + CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, m_Name.c_str()); } // normal instances, create empty objects @@ -168,13 +182,13 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { - Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { // write instace header PersistMgr->PutDWORD(m_ID); - PersistMgr->PutDWORD((*it)->GetID()); + PersistMgr->PutDWORD((it->_value)->GetID()); - m_Load((*it)->GetInstance(), PersistMgr); + m_Load((it->_value)->GetInstance(), PersistMgr); } } @@ -186,17 +200,17 @@ void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSysClass::ResetSavedIDs() { - Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { - (*it)->SetSavedID(-1); + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + (it->_value)->SetSavedID(-1); } } ////////////////////////////////////////////////////////////////////////// void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { - Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { - lpCallback((*it)->GetInstance(), lpData); + InstanceMap::iterator it; + for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + lpCallback((it->_value)->GetInstance(), lpData); } } diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index 48d7a2626e..bcd63cc5e4 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -30,10 +30,21 @@ #define WINTERMUTE_SYSCLASS_H #include "persistent.h" -#include -#include #include "dctypes.h" +//#include +//#include +#include "common/hashmap.h" +#include "common/func.h" +namespace Common { +template struct Hash; + +template<> struct Hash : public UnaryFunction { + uint operator()(void* val) const { return (uint)((size_t)val); } +}; + +} + namespace WinterMute { class CSysInstance; class CBGame; @@ -80,7 +91,7 @@ public: void ResetSavedIDs(); - void Dump(FILE *stream); + void Dump(void *stream); private: int m_NumInst; @@ -92,10 +103,10 @@ private: PERSISTBUILD m_Build; PERSISTLOAD m_Load; - typedef std::set Instances; - Instances m_Instances; + //typedef std::set Instances; + //Instances m_Instances; - typedef std::map InstanceMap; + typedef Common::HashMap InstanceMap; InstanceMap m_InstanceMap; }; diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp index 72740a79cf..1170921768 100644 --- a/engines/wintermute/SysClassRegistry.cpp +++ b/engines/wintermute/SysClassRegistry.cpp @@ -53,7 +53,8 @@ CSysClassRegistry *CSysClassRegistry::GetInstance() { ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { classObj->SetID(m_Count++); - m_Classes.insert(classObj); + //m_Classes.insert(classObj); + m_Classes[classObj] = classObj; m_NameMap[classObj->GetName()] = classObj; m_IdMap[classObj->GetID()] = classObj; @@ -93,7 +94,7 @@ bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) NameMap::iterator mapIt = m_NameMap.find(className); if (mapIt == m_NameMap.end()) return false; - CSysInstance *inst = (*mapIt).second->AddInstance(instance, m_Count++); + CSysInstance *inst = (*mapIt)._value->AddInstance(instance, m_Count++); return (inst != NULL); } @@ -114,7 +115,7 @@ int CSysClassRegistry::GetNextID() { bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { NameMap::iterator mapIt = m_NameMap.find(className); if (mapIt == m_NameMap.end()) return false; - (*mapIt).second->RemoveInstance(instance); + (*mapIt)._value->RemoveInstance(instance); InstanceMap::iterator instIt = m_InstanceMap.find(instance); if (instIt != m_InstanceMap.end()) { @@ -132,7 +133,7 @@ bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceI if (it == m_InstanceMap.end()) return false; - CSysInstance *inst = (*it).second; + CSysInstance *inst = (*it)._value; *instanceID = inst->GetID(); *classID = inst->GetClass()->GetID(); @@ -143,7 +144,7 @@ bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceI void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { SavedInstanceMap::iterator it = m_SavedInstanceMap.find(instanceID); if (it == m_SavedInstanceMap.end()) return NULL; - else return (*it).second->GetInstance(); + else return (*it)._value->GetInstance(); } @@ -163,7 +164,7 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, boo Game->m_Renderer->Flip(); } - (*it)->SaveTable(Game, PersistMgr); + (it->_value)->SaveTable(Game, PersistMgr); } return S_OK; @@ -176,12 +177,12 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { // reset SavedID of current instances for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { - (*it)->ResetSavedIDs(); + (it->_value)->ResetSavedIDs(); } for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { - if ((*it)->IsPersistent()) continue; - (*it)->RemoveAllInstances(); + if ((it->_value)->IsPersistent()) continue; + (it->_value)->RemoveAllInstances(); } m_InstanceMap.clear(); @@ -196,7 +197,7 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { char *className = PersistMgr->GetString(); NameMap::iterator mapIt = m_NameMap.find(className); - if (mapIt != m_NameMap.end())(*mapIt).second->LoadTable(Game, PersistMgr); + if (mapIt != m_NameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); } return S_OK; @@ -211,7 +212,7 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, // count total instances int numInstances = 0; for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { - numInstances += (*it)->GetNumInstances(); + numInstances += (it->_value)->GetNumInstances(); } PersistMgr->PutDWORD(numInstances); @@ -229,7 +230,7 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, } Game->MiniUpdate(); - (*it)->SaveInstances(Game, PersistMgr); + (it->_value)->SaveInstances(Game, PersistMgr); } return S_OK; @@ -255,8 +256,8 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) Classes::iterator it; for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { - if ((*it)->GetSavedID() == classID) { - (*it)->LoadInstance(instance, PersistMgr); + if ((it->_value)->GetSavedID() == classID) { + (it->_value)->LoadInstance(instance, PersistMgr); } } } @@ -272,16 +273,16 @@ HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const NameMap::iterator mapIt = m_NameMap.find(className); if (mapIt == m_NameMap.end()) return E_FAIL; - (*mapIt).second->InstanceCallback(lpCallback, lpData); + (*mapIt)._value->InstanceCallback(lpCallback, lpData); return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::DumpClasses(FILE *stream) { +void CSysClassRegistry::DumpClasses(void *stream) { Classes::iterator it; for (it = m_Classes.begin(); it != m_Classes.end(); ++it) - (*it)->Dump(stream); + (it->_value)->Dump(stream); } } // end of namespace WinterMute diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h index 1a73f28010..6d3367fc30 100644 --- a/engines/wintermute/SysClassRegistry.h +++ b/engines/wintermute/SysClassRegistry.h @@ -32,14 +32,30 @@ #include "wintypes.h" #include "dctypes.h" #include "persistent.h" -#include -#include +//#include +//#include +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/func.h" + +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + +namespace WinterMute { +class CSysClass; +} + +namespace Common { +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysClass* val) const { return (uint)((size_t)val); } +}; + +} namespace WinterMute { class CBGame; class CBPersistMgr; -class CSysClass; class CSysInstance; class CSysClassRegistry { @@ -57,7 +73,7 @@ public: bool UnregisterClass(CSysClass *classObj); bool RegisterInstance(const char *className, void *instance); bool UnregisterInstance(const char *className, void *instance); - void DumpClasses(FILE *stream); + void DumpClasses(void *stream); int GetNextID(); void AddInstanceToTable(CSysInstance *instance, void *pointer); @@ -67,19 +83,19 @@ public: bool m_Disabled; int m_Count; - typedef std::set Classes; + typedef Common::HashMap Classes; Classes m_Classes; - typedef std::map NameMap; + typedef Common::HashMap NameMap; NameMap m_NameMap; - typedef std::map IdMap; + typedef Common::HashMap IdMap; IdMap m_IdMap; - typedef std::map InstanceMap; + typedef Common::HashMap InstanceMap; InstanceMap m_InstanceMap; - typedef std::map SavedInstanceMap; + typedef Common::HashMap SavedInstanceMap; SavedInstanceMap m_SavedInstanceMap; }; diff --git a/engines/wintermute/SysInstance.cpp b/engines/wintermute/SysInstance.cpp index b937136706..857a857a45 100644 --- a/engines/wintermute/SysInstance.cpp +++ b/engines/wintermute/SysInstance.cpp @@ -27,6 +27,7 @@ */ #include "SysInstance.h" +#include "SysClassRegistry.h" #include "SysClass.h" namespace WinterMute { diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 58ac8ff13b..6d1018ec0a 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -45,6 +45,7 @@ #include "engines/wintermute/scriptables/ScStack.h" #include "engines/wintermute/scriptables/ScScript.h" #include "engines/wintermute/utils.h" +#include "common/util.h" namespace WinterMute { @@ -462,7 +463,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { if (strcmp(Name, "SelStart") == 0) { m_SelStart = Value->GetInt(); m_SelStart = MAX(m_SelStart, 0); - m_SelStart = MIN(m_SelStart, strlen(m_Text)); + m_SelStart = MIN((size_t)m_SelStart, strlen(m_Text)); return S_OK; } @@ -472,7 +473,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { else if (strcmp(Name, "SelEnd") == 0) { m_SelEnd = Value->GetInt(); m_SelEnd = MAX(m_SelEnd, 0); - m_SelEnd = MIN(m_SelEnd, strlen(m_Text)); + m_SelEnd = MIN((size_t)m_SelEnd, strlen(m_Text)); return S_OK; } @@ -567,8 +568,8 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { m_SelStart = MAX(m_SelStart, 0); m_SelEnd = MAX(m_SelEnd, 0); - m_SelStart = MIN(m_SelStart, strlen(m_Text)); - m_SelEnd = MIN(m_SelEnd, strlen(m_Text)); + m_SelStart = MIN((size_t)m_SelStart, strlen(m_Text)); + m_SelEnd = MIN((size_t)m_SelEnd, strlen(m_Text)); //int CursorWidth = font->GetCharWidth(m_CursorChar[0]); int CursorWidth = font->GetTextWidth((byte *)m_CursorChar); @@ -788,8 +789,8 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { int CUIEdit::DeleteChars(int Start, int End) { if (Start > End) CBUtils::Swap(&Start, &End); - Start = MAX(Start, 0); - End = MIN(End, strlen(m_Text)); + Start = MAX(Start, (int)0); + End = MIN((size_t)End, strlen(m_Text)); char *str = new char[strlen(m_Text) - (End - Start) + 1]; if (str) { @@ -811,8 +812,8 @@ int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { Num -= (strlen(m_Text) + Num - m_MaxLength); } - Pos = MAX(Pos, 0); - Pos = MIN(Pos, strlen(m_Text)); + Pos = MAX(Pos, (int)0); + Pos = MIN((size_t)Pos, strlen(m_Text)); char *str = new char[strlen(m_Text) + Num + 1]; if (str) { diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index 0ee5a6bf54..bd5ec3b6e5 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -29,22 +29,29 @@ #ifndef WINTERMUTE_DCTYPES_H #define WINTERMUTE_DCTYPES_H -#include -#include -#include +#define FORBIDDEN_SYMBOL_ALLOW_ALL -namespace WinterMute { +#include "common/str.h" +#include "common/list.h" +#include "common/array.h" +//#include +//#include +//#include -typedef std::string AnsiString; -typedef std::string Utf8String; -typedef std::wstring WideString; +namespace WinterMute { +//typedef std::string AnsiString; +//typedef std::string Utf8String; +//typedef std::wstring WideString; +typedef Common::String AnsiString; +typedef Common::String Utf8String; +typedef Common::String WideString; // NB: Not actually true I presume. -typedef std::list WideStringList; -typedef std::list AnsiStringList; +typedef Common::List WideStringList; +typedef Common::List AnsiStringList; -typedef std::vector WideStringArray; -typedef std::vector AnsiStringArray; +typedef Common::Array WideStringArray; +typedef Common::Array AnsiStringArray; enum TGameState { diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 54e590bdfe..13103f6d3c 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -168,7 +168,7 @@ private: bool m_IsProfiling; uint32 m_ProfilingStartTime; - typedef std::map ScriptTimes; + typedef Common::HashMap ScriptTimes; ScriptTimes m_ScriptTimes; }; diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 387bf45b46..186f4ff9d2 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -170,7 +170,7 @@ CScValue *CScValue::GetProp(char *Name) { Game->m_ScValue->SetInt(strlen(m_ValString)); } else { WideString wstr = StringUtil::Utf8ToWide(m_ValString); - Game->m_ScValue->SetInt(wstr.length()); + Game->m_ScValue->SetInt(wstr.size()); } return Game->m_ScValue; diff --git a/engines/wintermute/tinystr.cpp b/engines/wintermute/tinystr.cpp new file mode 100644 index 0000000000..0665768205 --- /dev/null +++ b/engines/wintermute/tinystr.cpp @@ -0,0 +1,111 @@ +/* +www.sourceforge.net/projects/tinyxml + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TIXML_USE_STL + +#include "tinystr.h" + +// Error value for find primitive +const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); + + +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; + + +void TiXmlString::reserve (size_type cap) +{ + if (cap > capacity()) + { + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); + } +} + + +TiXmlString& TiXmlString::assign(const char* str, size_type len) +{ + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; +} + + +TiXmlString& TiXmlString::append(const char* str, size_type len) +{ + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; +} + + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) +{ + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; +} + +TiXmlString operator + (const TiXmlString & a, const char* b) +{ + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; +} + +TiXmlString operator + (const char* a, const TiXmlString & b) +{ + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; +} + + +#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinystr.h b/engines/wintermute/tinystr.h new file mode 100644 index 0000000000..89cca33415 --- /dev/null +++ b/engines/wintermute/tinystr.h @@ -0,0 +1,305 @@ +/* +www.sourceforge.net/projects/tinyxml + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include +#include + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml.h b/engines/wintermute/tinyxml.h index ee73173932..a78e981deb 100644 --- a/engines/wintermute/tinyxml.h +++ b/engines/wintermute/tinyxml.h @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#define TIXML_USE_STL +//#define TIXML_USE_STL #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index c69a0068b6..6c5ddb5d40 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -238,7 +238,7 @@ char *CBUtils::GetPath(char *Filename) { //path = boost::filesystem::system_complete(path).string(); warning("CBUtils::GetPath: (%s), not implemented", Filename); return Filename; - char *ret = new char[path.length() + 1]; + char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); return ret; @@ -247,7 +247,7 @@ char *CBUtils::GetPath(char *Filename) { ////////////////////////////////////////////////////////////////////////// char *CBUtils::GetFilename(char *Filename) { AnsiString path = PathUtil::GetFileName(Filename); - char *ret = new char[path.length() + 1]; + char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); return ret; } @@ -259,12 +259,12 @@ void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { float var_B = (D3DCOLGetB(RGBColor) / 255.0f); //Min. value of RGB - float var_Min = std::min(var_R, var_G); - var_Min = std::min(var_Min, var_B); + float var_Min = MIN(var_R, var_G); + var_Min = MIN(var_Min, var_B); //Max. value of RGB - float var_Max = std::max(var_R, var_G); - var_Max = std::max(var_Max, var_B); + float var_Max = MAX(var_R, var_G); + var_Max = MAX(var_Max, var_B); //Delta RGB value float del_Max = var_Max - var_Min; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index c831baf19b..4f791cabd1 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,7 +31,7 @@ #include "common/fs.h" #include "engines/util.h" - +#include "engines/wintermute/BGame.h" #include "engines/wintermute/wintermute.h" namespace WinterMute { @@ -103,6 +103,8 @@ namespace WinterMute { debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); return Common::kNoError; + + CBGame game; } } // End of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 50d6dd16be..c722b92c51 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -33,8 +33,8 @@ #include "common/scummsys.h" //namespace WinterMute { -#include -#include +//#include +//#include #ifndef __WIN32__ #define WINAPI -- cgit v1.2.3 From a7c12a7bd1729e3fc77cfab78a53e606521b484c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 16:19:32 +0100 Subject: WINTERMUTE: Add simple detection for WinterMute --- engines/wintermute/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index b3a756f6c3..7c4da190dd 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -29,7 +29,7 @@ #include "engines/metaengine.h" static const PlainGameDescriptor WinterMute_setting[] = { - { "WinterMute", "WinterMute - Unspecified game" }, + { "wintermute", "WinterMute - Unspecified game" }, { 0, 0 } }; @@ -72,7 +72,7 @@ public: if (!file->isDirectory()) { const char *gameName = file->getName().c_str(); - if (0 == scumm_stricmp("README", gameName)) { + if (0 == scumm_stricmp("data.dcp", gameName)) { // You could check the contents of the file now if you need to. detectedGames.push_back(WinterMute_setting[0]); break; -- cgit v1.2.3 From 85adc3a3babd03d900dbeb70ec6faa7270d6e926 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 16:28:08 +0100 Subject: WINTERMUTE: Add ScEngine, ScValue, SXStore, SXString, SXFile and PlatformSDL to build --- engines/wintermute/AdObject.cpp | 10 +- engines/wintermute/BFrame.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 590 +++++++++++++++++++++++++ engines/wintermute/StringUtil.cpp | 2 +- engines/wintermute/module.mk | 5 + engines/wintermute/scriptables/SXArray.cpp | 2 +- engines/wintermute/scriptables/SXDate.cpp | 20 +- engines/wintermute/scriptables/SXDate.h | 2 +- engines/wintermute/scriptables/SXFile.cpp | 22 +- engines/wintermute/scriptables/SXMemBuffer.cpp | 4 +- engines/wintermute/scriptables/SXStore.cpp | 14 +- engines/wintermute/scriptables/SXString.cpp | 58 +-- engines/wintermute/scriptables/ScEngine.cpp | 52 ++- engines/wintermute/scriptables/ScValue.cpp | 30 +- engines/wintermute/scriptables/ScValue.h | 8 +- engines/wintermute/wintermute.cpp | 6 +- 16 files changed, 721 insertions(+), 106 deletions(-) create mode 100644 engines/wintermute/PlatformSDL.cpp (limited to 'engines') diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 0e2a351ed4..6e59b9b45c 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -260,7 +260,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (val->IsNULL()) Align = TAL_CENTER; else Align = val->GetInt(); - Align = std::min(std::max(0, Align), NUM_TEXT_ALIGN - 1); + Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); @@ -802,7 +802,7 @@ int CAdObject::GetHeight() { CBFrame *frame = m_CurrentSprite->m_Frames[m_CurrentSprite->m_CurrentFrame]; int ret = 0; for (int i = 0; i < frame->m_Subframes.GetSize(); i++) { - ret = std::max(ret, frame->m_Subframes[i]->m_HotspotY); + ret = MAX(ret, frame->m_Subframes[i]->m_HotspotY); } if (m_Zoomable) { @@ -880,7 +880,7 @@ void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TT if (m_SubtitlesWidth > 0) width = m_SubtitlesWidth; else { if ((x < Game->m_Renderer->m_Width / 4 || x > Game->m_Renderer->m_Width * 0.75) && !Game->m_TouchInterface) { - width = std::max(Game->m_Renderer->m_Width / 4, std::min(x * 2, (Game->m_Renderer->m_Width - x) * 2)); + width = MAX(Game->m_Renderer->m_Width / 4, MIN(x * 2, (Game->m_Renderer->m_Width - x) * 2)); } else width = Game->m_Renderer->m_Width / 2; } @@ -898,8 +898,8 @@ void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TT x = x - width / 2; - x = std::min(std::max(0, x), Game->m_Renderer->m_Width - width); - y = std::min(std::max(0, y), Game->m_Renderer->m_Height - height); + x = MIN(MAX(0, x), Game->m_Renderer->m_Width - width); + y = MIN(MAX(0, y), Game->m_Renderer->m_Height - height); m_Sentence->m_Width = width; diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index 4778a2f4b8..37b263d505 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -655,7 +655,7 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // Delay ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Delay") == 0) { - m_Delay = std::max(0, Value->GetInt()); + m_Delay = MAX(0, Value->GetInt()); return S_OK; } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp new file mode 100644 index 0000000000..1b55c1ca35 --- /dev/null +++ b/engines/wintermute/PlatformSDL.cpp @@ -0,0 +1,590 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BRenderSDL.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/BRegistry.h" +#include "engines/wintermute/BSoundMgr.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "common/str.h" +#include "common/textconsole.h" + +#ifdef __WIN32__ +# include +# include +#else +# include +#endif + + +namespace WinterMute { + +CBGame *CBPlatform::Game = NULL; + + +#define CLASS_NAME "GF_FRAME" +////////////////////////////////////////////////////////////////////////// +int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { + //setlocale(LC_CTYPE, ""); + + Game = inGame; + if (!Game) return 1; + + + bool windowedMode = true; + + + // parse command line + char *SaveGame = NULL; + char param[MAX_PATH]; + for (int i = 0; i < argc; i++) { + strcpy(param, argv[i]); + + if (scumm_stricmp(param, "-project") == 0) { + if (argc > i) strcpy(param, argv[i + 1]); + else param[0] = '\0'; + + if (strcmp(param, "") != 0) { + char *IniDir = CBUtils::GetPath(param); + char *IniName = CBUtils::GetFilename(param); + + // switch to ini's dir + chdir(IniDir); + + // set ini name + sprintf(param, "./%s", IniName); + Game->m_Registry->SetIniName(param); + + delete [] IniDir; + delete [] IniName; + } + } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; + } + + + if (Game->m_Registry->ReadBool("Debug", "DebugMode")) Game->DEBUG_DebugEnable("./wme.log"); + + Game->m_DEBUG_ShowFPS = Game->m_Registry->ReadBool("Debug", "ShowFPS"); + + if (Game->m_Registry->ReadBool("Debug", "DisableSmartCache")) { + Game->LOG(0, "Smart cache is DISABLED"); + Game->m_SmartCache = false; + } + + bool AllowDirectDraw = Game->m_Registry->ReadBool("Debug", "AllowDirectDraw", false); + + // load general game settings + Game->Initialize1(); + + + if (FAILED(Game->LoadSettings("startup.settings"))) { + Game->LOG(0, "Error loading game settings."); + delete Game; + Game = NULL; + +#ifdef __WIN32__ + ::MessageBox(NULL, "Some of the essential files are missing. Please reinstall.", NULL, MB_OK | MB_ICONERROR); +#endif + return 2; + } + + Game->Initialize2(); + + Game->GetDebugMgr()->OnGameInit(); + Game->m_ScEngine->LoadBreakpoints(); + + + + HRESULT ret; + + // initialize the renderer + ret = Game->m_Renderer->InitRenderer(Game->m_SettingsResWidth, Game->m_SettingsResHeight, windowedMode); + if (FAILED(ret)) { + Game->LOG(ret, "Error initializing renderer. Exiting."); + + delete Game; + Game = NULL; + return 3; + } + + Game->Initialize3(); + +#ifdef __IPHONEOS__ + SDL_AddEventWatch(CBPlatform::SDLEventWatcher, NULL); +#endif + + // initialize sound manager (non-fatal if we fail) + ret = Game->m_SoundMgr->Initialize(); + if (FAILED(ret)) { + Game->LOG(ret, "Sound is NOT available."); + } + + + // load game + uint32 DataInitStart = GetTime(); + + if (FAILED(Game->LoadFile(Game->m_SettingsGameFile ? Game->m_SettingsGameFile : "default.game"))) { + Game->LOG(ret, "Error loading game file. Exiting."); + delete Game; + Game = NULL; + return false; + } + Game->SetWindowTitle(); + Game->m_Renderer->m_Ready = true; + Game->m_MiniUpdateEnabled = true; + + Game->LOG(0, "Engine initialized in %d ms", GetTime() - DataInitStart); + Game->LOG(0, ""); + + + if (SaveGame) { + Game->LoadGame(SaveGame); + delete [] SaveGame; + } + + // all set, ready to go + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CBPlatform::MessageLoop() { + bool done = false; + + while (!done) { + SDL_Event event; + while (SDL_PollEvent(&event)) { + HandleEvent(&event); + } + + if (Game && Game->m_Renderer->m_Active && Game->m_Renderer->m_Ready) { + + Game->DisplayContent(); + Game->DisplayQuickMsg(); + + Game->DisplayDebugInfo(); + + // ***** flip + if (!Game->m_SuspendedRendering) Game->m_Renderer->Flip(); + if (Game->m_Loading) Game->LoadGame(Game->m_ScheduledLoadSlot); + } + if (Game->m_Quitting) break; + + } + + if (Game) { + // remember previous window position + /* + if(Game->m_Renderer && Game->m_Renderer->m_Windowed) + { + if(!::IsIconic(Game->m_Renderer->m_Window)) + { + int PosX = Game->m_Renderer->m_WindowRect.left; + int PosY = Game->m_Renderer->m_WindowRect.top; + PosX -= Game->m_Renderer->m_MonitorRect.left; + PosY -= Game->m_Renderer->m_MonitorRect.top; + + Game->m_Registry->WriteInt("Video", "WindowPosX", PosX); + Game->m_Registry->WriteInt("Video", "WindowPosY", PosY); + } + } + */ + + delete Game; + Game = NULL; + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBPlatform::HandleEvent(SDL_Event *event) { + switch (event->type) { + + case SDL_MOUSEBUTTONDOWN: + +#ifdef __IPHONEOS__ + { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + POINT p; + GetCursorPos(&p); + Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); + + if (Game->m_ActiveObject != NULL && strcmp(Game->m_ActiveObject->GetClassName(), "CUIButton") == 0) { + CUIButton *btn = static_cast(Game->m_ActiveObject); + if (btn->m_Visible && !btn->m_Disable) btn->m_Press = true; + } + } +#endif + switch (event->button.button) { + case SDL_BUTTON_LEFT: + if (Game) { + if (Game->IsLeftDoubleClick()) Game->OnMouseLeftDblClick(); + else Game->OnMouseLeftDown(); + } + break; + case SDL_BUTTON_RIGHT: + if (Game) { + if (Game->IsRightDoubleClick()) Game->OnMouseRightDblClick(); + else Game->OnMouseRightDown(); + } + break; + case SDL_BUTTON_MIDDLE: + if (Game) Game->OnMouseMiddleDown(); + break; + } + break; + + case SDL_MOUSEBUTTONUP: + switch (event->button.button) { + case SDL_BUTTON_LEFT: + if (Game) Game->OnMouseLeftUp(); + break; + case SDL_BUTTON_RIGHT: + if (Game) Game->OnMouseRightUp(); + break; + case SDL_BUTTON_MIDDLE: + if (Game) Game->OnMouseMiddleUp(); + break; + } + break; +//TODO +/* case SDL_MOUSEWHEEL: + if (Game) Game->HandleMouseWheel(event->wheel.y); + break; + + case SDL_KEYDOWN: + case SDL_TEXTINPUT: + if (Game) Game->HandleKeypress(event); + break; + + case SDL_WINDOWEVENT: + switch (event->window.event) { + case SDL_WINDOWEVENT_FOCUS_GAINED: + case SDL_WINDOWEVENT_RESTORED: + if (Game) Game->OnActivate(true, true); + SDL_ShowCursor(SDL_DISABLE); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + case SDL_WINDOWEVENT_MINIMIZED: +#ifndef __IPHONEOS__ + if (Game) Game->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); +#endif + break; + + case SDL_WINDOWEVENT_CLOSE: + break; + + } + break; +*/ + case SDL_QUIT: +#ifdef __IPHONEOS__ + if (Game) { + Game->AutoSaveOnExit(); + Game->m_Quitting = true; + } +#else + if (Game) Game->OnWindowClose(); +#endif + + break; + + } +} + +////////////////////////////////////////////////////////////////////////// +int CBPlatform::SDLEventWatcher(void *userdata, SDL_Event *event) { + //TODO +/* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + if (Game) Game->AutoSaveOnExit(); + if (Game) Game->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); + } +*/ + return 1; +} + + +////////////////////////////////////////////////////////////////////////// +// Win32 API bindings +////////////////////////////////////////////////////////////////////////// +HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd) { +#ifdef __WIN32__ + return ::ShellExecute(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd); +#else + return NULL; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBPlatform::OutputDebugString(LPCSTR lpOutputString) { +#ifdef __WIN32__ + ::OutputDebugString(lpOutputString); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPlatform::GetTime() { + return SDL_GetTicks(); +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + + int x, y; + SDL_GetMouseState(&x, &y); + lpPoint->x = x; + lpPoint->y = y; + + renderer->PointFromScreen(lpPoint); + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::SetCursorPos(int X, int Y) { + CBRenderSDL *renderer = static_cast(Game->m_Renderer); + + POINT p; + p.x = X; + p.y = Y; + renderer->PointToScreen(&p); +// TODO + //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::ShowWindow(HWND hWnd, int nCmdShow) { +#ifdef __WIN32__ + return ::ShowWindow(hWnd, nCmdShow); +#else + return FALSE; +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::DeleteFile(const char *lpFileName) { + return remove(lpFileName) ? true : false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::CopyFile(const char *from, const char *to, bool failIfExists) { +// try { + warning("CBPlatform::CopyFile(%s, %s, %d) - not implemented", from, to, failIfExists); + return false; +// if (failIfExists && boost::filesystem::exists(to)) return false; +// boost::filesystem::copy_file(from, to); +// return true; +// } catch (...) { +// return false; +// } +} + +////////////////////////////////////////////////////////////////////////// +HWND CBPlatform::SetCapture(HWND hWnd) { +#ifdef __WIN32__ + return ::SetCapture(hWnd); +#else + return NULL; +#endif +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::ReleaseCapture() { +#ifdef __WIN32__ + return ::ReleaseCapture(); +#else + return FALSE; +#endif +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::SetForegroundWindow(HWND hWnd) { +#ifdef __WIN32__ + return ::SetForegroundWindow(hWnd); +#else + return FALSE; +#endif +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::SetRectEmpty(LPRECT lprc) { + lprc->left = lprc->right = lprc->top = lprc->bottom = 0; + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::IsRectEmpty(const LPRECT lprc) { + return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::PtInRect(LPRECT lprc, POINT p) { + return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::SetRect(LPRECT lprc, int left, int top, int right, int bottom) { + lprc->left = left; + lprc->top = top; + lprc->right = right; + lprc->bottom = bottom; + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::IntersectRect(LPRECT lprcDst, CONST LPRECT lprcSrc1, CONST LPRECT lprcSrc2) { + if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) || + lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || + lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { + SetRectEmpty(lprcDst); + return FALSE; + } + lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); + lprcDst->right = MIN(lprcSrc1->right, lprcSrc2->right); + lprcDst->top = MAX(lprcSrc1->top, lprcSrc2->top); + lprcDst->bottom = MIN(lprcSrc1->bottom, lprcSrc2->bottom); + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { + if (IsRectEmpty(lprcSrc1)) { + if (IsRectEmpty(lprcSrc2)) { + SetRectEmpty(lprcDst); + return FALSE; + } else { + *lprcDst = *lprcSrc2; + } + } else { + if (IsRectEmpty(lprcSrc2)) { + *lprcDst = *lprcSrc1; + } else { + lprcDst->left = MIN(lprcSrc1->left, lprcSrc2->left); + lprcDst->top = MIN(lprcSrc1->top, lprcSrc2->top); + lprcDst->right = MAX(lprcSrc1->right, lprcSrc2->right); + lprcDst->bottom = MAX(lprcSrc1->bottom, lprcSrc2->bottom); + } + } + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::CopyRect(LPRECT lprcDst, RECT *lprcSrc) { + if (lprcDst == NULL || lprcSrc == NULL) return FALSE; + + *lprcDst = *lprcSrc; + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::OffsetRect(LPRECT lprc, int dx, int dy) { + if (lprc == NULL) return FALSE; + + lprc->left += dx; + lprc->top += dy; + lprc->right += dx; + lprc->bottom += dy; + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBPlatform::EqualRect(LPRECT rect1, LPRECT rect2) { + return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBPlatform::GetSystemFontPath() { +#ifdef __WIN32__ + // we're looking for something like "c:\windows\fonts\"; + char winDir[MAX_PATH + 1]; + winDir[MAX_PATH] = '\0'; + ::GetWindowsDirectory(winDir, MAX_PATH); + return PathUtil::Combine(AnsiString(winDir), "fonts"); +#else + // !PORTME + return "/Library/Fonts/"; +#endif +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBPlatform::GetPlatformName() { + // TODO: Should conform to the WME-spec. + //return AnsiString(SDL_GetPlatform()); + return AnsiString("ScummVM"); +} + +////////////////////////////////////////////////////////////////////////// +int scumm_stricmp(const char *str1, const char *str2) { +#ifdef __WIN32__ + return ::stricmp(str1, str2); +#else + return ::strcasecmp(str1, str2); +#endif +} + +////////////////////////////////////////////////////////////////////////// +int scumm_strnicmp(const char *str1, const char *str2, size_t maxCount) { +#ifdef __WIN32__ + return ::strnicmp(str1, str2, maxCount); +#else + return ::strncasecmp(str1, str2, maxCount); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +char *CBPlatform::strupr(char *string) { + if (string) { + for (size_t i = 0; i < strlen(string); ++i) { + string[i] = toupper(string[i]); + } + } + return string; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPlatform::strlwr(char *string) { + if (string) { + for (size_t i = 0; i < strlen(string); ++i) { + string[i] = tolower(string[i]); + } + } + return string; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index a8af7f25ec..3fcc156ffc 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -315,7 +315,7 @@ int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t if (index == NULL) return -1; else - return str.c_str() - index; + return index - str.c_str(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 2b5eca2c6a..2870ec47fe 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,6 +1,7 @@ MODULE := engines/wintermute MODULE_OBJS := \ + scriptables/ScEngine.o \ scriptables/ScScript.o \ scriptables/ScStack.o \ scriptables/ScValue.o \ @@ -8,6 +9,8 @@ MODULE_OBJS := \ scriptables/SXDate.o \ scriptables/SXMath.o \ scriptables/SXMemBuffer.o \ + scriptables/SXStore.o \ + scriptables/SXString.o \ AdActor.o \ AdActorDir.o \ AdEntity.o \ @@ -79,11 +82,13 @@ MODULE_OBJS := \ FontGlyphCache.o \ MathUtil.o \ PathUtil.o \ + PlatformSDL.o \ StringUtil.o \ SysClass.o \ SysClassRegistry.o \ SysInstance.o \ tinyxml.o \ + tinystr.o \ UIButton.o \ UIEdit.o \ UIEntity.o \ diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 4a67cdfb5a..5203945053 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -168,7 +168,7 @@ HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Length") == 0) { int OrigLength = m_Length; - m_Length = std::max(Value->GetInt(0), 0); + m_Length = MAX(Value->GetInt(0), 0); char PropName[20]; if (m_Length < OrigLength) { diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index 39b50da528..232f2beefd 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -34,7 +34,7 @@ IMPLEMENT_PERSISTENT(CSXDate, false) ////////////////////////////////////////////////////////////////////////// CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(6); - +#if 0 memset(&m_tm, 0, sizeof(m_tm)); CScValue *valYear = Stack->Pop(); @@ -52,6 +52,7 @@ CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { } mktime(&m_tm); +#endif } @@ -63,12 +64,16 @@ CSXDate::~CSXDate() { ////////////////////////////////////////////////////////////////////////// char *CSXDate::ScToString() { +#if 0 return asctime(&m_tm); +#endif + return ""; } ////////////////////////////////////////////////////////////////////////// HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +#if 0 ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// @@ -202,7 +207,9 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } - else return E_FAIL; + else +#endif + return E_FAIL; } @@ -241,24 +248,27 @@ HRESULT CSXDate::ScSetProperty(char *Name, CScValue *Value) { HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - +#if 0 if (PersistMgr->m_Saving) PersistMgr->PutBytes((byte *)&m_tm, sizeof(m_tm)); else PersistMgr->GetBytes((byte *)&m_tm, sizeof(m_tm)); - +#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// int CSXDate::ScCompare(CBScriptable *Value) { +#if 0 time_t time1 = mktime(&m_tm); time_t time2 = mktime(&((CSXDate *)Value)->m_tm); if (time1 < time2) return -1; else if (time1 > time2) return 1; - else return 0; + else +#endif + return 0; } } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h index fe9191368d..638816b6d1 100644 --- a/engines/wintermute/scriptables/SXDate.h +++ b/engines/wintermute/scriptables/SXDate.h @@ -45,7 +45,7 @@ public: HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); char *ScToString(); char *m_String; - struct tm m_tm; + //struct tm m_tm; // TODO! }; } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index 7615d3a01f..8e38e2608a 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -23,17 +23,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "SysClassRegistry.h" -#include "SysClass.h" -#include "ScStack.h" -#include "ScValue.h" -#include "ScScript.h" -#include "utils.h" -#include "BGame.h" -#include "BFile.h" -#include "BFileManager.h" -#include "PlatformSDL.h" -#include "scriptables/SXFile.h" +#include "engines/wintermute/SysClassRegistry.h" +#include "engines/wintermute/SysClass.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFile.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/SXFile.h" namespace WinterMute { diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 38468757ea..874aa2c9d1 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -43,7 +43,7 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame m_Size = 0; int NewSize = Stack->Pop()->GetInt(); - Resize(std::max(0, NewSize)); + Resize(MAX(0, NewSize)); } ////////////////////////////////////////////////////////////////////////// @@ -124,7 +124,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (strcmp(Name, "SetSize") == 0) { Stack->CorrectParams(1); int NewSize = Stack->Pop()->GetInt(); - NewSize = std::max(0, NewSize); + NewSize = MAX(0, NewSize); if (SUCCEEDED(Resize(NewSize))) Stack->PushBool(true); else Stack->PushBool(false); diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index 50c970d41a..cdd62599d4 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -23,13 +23,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "BGame.h" -#include "BRegistry.h" -#include "scriptables/SXStore.h" -#include "ScValue.h" -#include "ScScript.h" -#include "ScStack.h" -#include "StringUtil.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BRegistry.h" +#include "engines/wintermute/scriptables/SXStore.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/StringUtil.h" #ifdef __IPHONEOS__ # include "IOS_StoreKit_interface.h" diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index 0283ee4895..0e4daf02aa 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -23,13 +23,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "BGame.h" -#include "ScStack.h" -#include "ScValue.h" -#include "utils.h" -#include "scriptables/SXString.h" -#include "scriptables/SXArray.h" -#include "StringUtil.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/scriptables/SXString.h" +#include "engines/wintermute/scriptables/SXArray.h" +#include "engines/wintermute/StringUtil.h" namespace WinterMute { @@ -44,7 +44,7 @@ CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { CScValue *Val = Stack->Pop(); if (Val->IsInt()) { - _capacity = std::max(0, Val->GetInt()); + _capacity = MAX(0, Val->GetInt()); if (_capacity > 0) { _string = new char[_capacity]; memset(_string, 0, _capacity); @@ -102,22 +102,23 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (end < start) CBUtils::Swap(&start, &end); - try { + //try { WideString str; if (Game->m_TextEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); - WideString subStr = str.substr(start, end - start + 1); + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); if (Game->m_TextEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); - } catch (std::exception &) { - Stack->PushNULL(); - } + // } catch (std::exception &) { + // Stack->PushNULL(); + // } return S_OK; } @@ -139,22 +140,23 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (val->IsNULL()) len = strlen(_string) - start; - try { +// try { WideString str; if (Game->m_TextEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); - WideString subStr = str.substr(start, len); +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); if (Game->m_TextEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); - } catch (std::exception &) { - Stack->PushNULL(); - } +// } catch (std::exception &) { +// Stack->PushNULL(); +// } return S_OK; } @@ -258,27 +260,29 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else delims = StringUtil::AnsiToWide(Separators); - std::vector parts; + Common::Array parts; size_t start, pos; start = 0; do { - pos = str.find_first_of(delims, start); + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); if (pos == start) { start = pos + 1; - } else if (pos == WideString::npos) { - parts.push_back(str.substr(start)); + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); break; } else { - parts.push_back(str.substr(start, pos - start)); + parts.push_back(Common::String(str.c_str() + start, pos - start)); start = pos + 1; } - start = str.find_first_not_of(delims, start); + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - } while (pos != WideString::npos); + } while (pos != str.size()); - for (std::vector::iterator it = parts.begin(); it != parts.end(); ++it) { + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); if (Game->m_TextEncoding == TEXT_UTF8) @@ -316,7 +320,7 @@ CScValue *CSXString::ScGetProperty(char *Name) { else if (strcmp(Name, "Length") == 0) { if (Game->m_TextEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(_string); - m_ScValue->SetInt(wstr.length()); + m_ScValue->SetInt(wstr.size()); } else m_ScValue->SetInt(strlen(_string)); diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index ce3ac5a94f..24272766c2 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -26,17 +26,17 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "ScEngine.h" -#include "StringUtil.h" -#include "ScValue.h" -#include "ScScript.h" -#include "ScStack.h" -#include "SXMath.h" -#include "BRegistry.h" -#include "BGame.h" -#include "BSound.h" -#include "BFileManager.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/SXMath.h" +#include "engines/wintermute/BRegistry.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BFileManager.h" #include #include @@ -150,7 +150,8 @@ CScEngine::~CScEngine() { Cleanup(); for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - SAFE_DELETE(m_Breakpoints[i]); + delete m_Breakpoints[i]; + m_Breakpoints[i] = NULL; } m_Breakpoints.RemoveAll(); } @@ -167,14 +168,15 @@ HRESULT CScEngine::Cleanup() { m_Scripts.RemoveAll(); - - SAFE_DELETE(m_Globals); + delete m_Globals; + m_Globals = NULL; EmptyScriptCache(); m_CurrentScript = NULL; // ref only - SAFE_DELETE_ARRAY(m_FileToCompile); + delete[] m_FileToCompile; + m_FileToCompile = NULL; m_CompileErrorCallback = NULL; m_CompileErrorCallbackData = NULL; @@ -523,7 +525,8 @@ int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { HRESULT CScEngine::EmptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (m_CachedScripts[i]) { - SAFE_DELETE(m_CachedScripts[i]); + delete m_CachedScripts[i]; + m_CachedScripts[i] = NULL; } } return S_OK; @@ -602,7 +605,7 @@ HRESULT CScEngine::ResumeAll() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::SetFileToCompile(char *Filename) { - SAFE_DELETE_ARRAY(m_FileToCompile); + delete[] m_FileToCompile; m_FileToCompile = new char[strlen(Filename) + 1]; if (m_FileToCompile) { strcpy(m_FileToCompile, Filename); @@ -695,7 +698,7 @@ HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { if (m_Breakpoints[i]->m_Lines[j] == Line) { m_Breakpoints[i]->m_Lines.RemoveAt(j); if (m_Breakpoints[i]->m_Lines.GetSize() == 0) { - SAFE_DELETE(m_Breakpoints[i]); + delete m_Breakpoints[i]; m_Breakpoints.RemoveAt(i); } // refresh changes @@ -776,8 +779,10 @@ HRESULT CScEngine::LoadBreakpoints() { char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); - SAFE_DELETE_ARRAY(Path); - SAFE_DELETE_ARRAY(Line); + delete[] Path; + delete[] Line; + Path = NULL; + Line = NULL; } return S_OK; @@ -817,14 +822,15 @@ void CScEngine::DisableProfiling() { ////////////////////////////////////////////////////////////////////////// void CScEngine::DumpStats() { - uint32 totalTime = CBPlatform::GetTime() - m_ProfilingStartTime; + error("DumpStats not ported to ScummVM yet"); +/* uint32 totalTime = CBPlatform::GetTime() - m_ProfilingStartTime; typedef std::vector > TimeVector; TimeVector times; ScriptTimes::iterator it; for (it = m_ScriptTimes.begin(); it != m_ScriptTimes.end(); it++) { - times.push_back(std::pair (it->second, it->first)); + times.push_back(std::pair (it->_value, it->_key)); } std::sort(times.begin(), times.end()); @@ -836,7 +842,7 @@ void CScEngine::DumpStats() { for (tit = times.rbegin(); tit != times.rend(); tit++) { Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - } + }*/ } } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 186f4ff9d2..f42cbf6a30 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -182,7 +182,7 @@ CScValue *CScValue::GetProp(char *Name) { if (ret == NULL) { m_ValIter = m_ValObject.find(Name); - if (m_ValIter != m_ValObject.end()) ret = m_ValIter->second; + if (m_ValIter != m_ValObject.end()) ret = m_ValIter->_value; } return ret; } @@ -193,8 +193,8 @@ HRESULT CScValue::DeleteProp(char *Name) { m_ValIter = m_ValObject.find(Name); if (m_ValIter != m_ValObject.end()) { - delete m_ValIter->second; - m_ValIter->second = NULL; + delete m_ValIter->_value; + m_ValIter->_value = NULL; } return S_OK; @@ -216,7 +216,7 @@ HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsC m_ValIter = m_ValObject.find(Name); if (m_ValIter != m_ValObject.end()) { - val = m_ValIter->second; + val = m_ValIter->_value; } if (!val) val = new CScValue(Game); else val->Cleanup(); @@ -259,7 +259,7 @@ bool CScValue::PropExists(char *Name) { void CScValue::DeleteProps() { m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { - delete(CScValue *)m_ValIter->second; + delete(CScValue *)m_ValIter->_value; m_ValIter++; } m_ValObject.clear(); @@ -270,7 +270,7 @@ void CScValue::DeleteProps() { void CScValue::CleanProps(bool IncludingNatives) { m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { - if (!m_ValIter->second->m_IsConstVar && (!m_ValIter->second->IsNative() || IncludingNatives)) m_ValIter->second->SetNULL(); + if (!m_ValIter->_value->m_IsConstVar && (!m_ValIter->_value->IsNative() || IncludingNatives)) m_ValIter->_value->SetNULL(); m_ValIter++; } } @@ -671,8 +671,8 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { if (orig->m_Type == VAL_OBJECT && orig->m_ValObject.size() > 0) { orig->m_ValIter = orig->m_ValObject.begin(); while (orig->m_ValIter != orig->m_ValObject.end()) { - m_ValObject[orig->m_ValIter->first] = new CScValue(Game); - m_ValObject[orig->m_ValIter->first]->Copy(orig->m_ValIter->second); + m_ValObject[orig->m_ValIter->_key] = new CScValue(Game); + m_ValObject[orig->m_ValIter->_key]->Copy(orig->m_ValIter->_value); orig->m_ValIter++; } } else m_ValObject.clear(); @@ -727,9 +727,9 @@ HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer("", &size); m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { - str = (char *)m_ValIter->first.c_str(); + str = (char *)m_ValIter->_key.c_str(); PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &m_ValIter->second); + PersistMgr->Transfer("", &m_ValIter->_value); m_ValIter++; } @@ -797,8 +797,8 @@ HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { Buffer->PutTextIndent(Indent, "PROPERTY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_ValIter->first.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_ValIter->second->GetString()); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_ValIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_ValIter->_value->GetString()); Buffer->PutTextIndent(Indent, "}\n\n"); m_ValIter++; @@ -855,7 +855,7 @@ int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { - Client->OnVariableInit(Type, Script, ScopeID, m_ValIter->second, m_ValIter->first.c_str()); + Client->OnVariableInit(Type, Script, ScopeID, m_ValIter->_value, m_ValIter->_key.c_str()); m_ValIter++; } return S_OK; @@ -999,8 +999,8 @@ bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Valu m_ValIter = m_ValObject.begin(); while (m_ValIter != m_ValObject.end()) { if (Count == Index) { - *Name = m_ValIter->first.c_str(); - *Value = m_ValIter->second; + *Name = m_ValIter->_key.c_str(); + *Value = m_ValIter->_value; return true; } m_ValIter++; diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 40abe635ce..3d0c69d3f7 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -33,8 +33,8 @@ #include "engines/wintermute/BBase.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dcscript.h" // Added by ClassView -#include -#include +//#include +//#include #include "engines/wintermute/wme_debugger.h" #include "common/str.h" @@ -100,8 +100,8 @@ public: CScValue(CBGame *inGame, double Val); CScValue(CBGame *inGame, const char *Val); virtual ~CScValue(); - std::map m_ValObject; - std::map::iterator m_ValIter; + Common::HashMap m_ValObject; + Common::HashMap::iterator m_ValIter; bool SetProperty(const char *PropName, int Value); bool SetProperty(const char *PropName, const char *Value); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 4f791cabd1..39152acc5d 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -46,7 +46,7 @@ namespace WinterMute { // However this is the place to specify all default directories const Common::FSNode gameDataDir(ConfMan.get("path")); - SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); + //SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); // Here is the right place to set up the engine specific debug channels DebugMan.addDebugChannel(kWinterMuteDebugExample, "example", "this is just an example for a engine specific debug channel"); @@ -102,9 +102,9 @@ namespace WinterMute { // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); - return Common::kNoError; - CBGame game; + + return Common::kNoError; } } // End of namespace WinterMute \ No newline at end of file -- cgit v1.2.3 From 403839cd7062cda1d6e7e7de8b632f9da1947bc7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 16:59:29 +0100 Subject: WINTERMUTE: Add crc to the build --- engines/wintermute/crc.cpp | 234 +++++++++++++++++++++++++++++++++++++++++++ engines/wintermute/module.mk | 3 + 2 files changed, 237 insertions(+) create mode 100644 engines/wintermute/crc.cpp (limited to 'engines') diff --git a/engines/wintermute/crc.cpp b/engines/wintermute/crc.cpp new file mode 100644 index 0000000000..503f8242fa --- /dev/null +++ b/engines/wintermute/crc.cpp @@ -0,0 +1,234 @@ +/********************************************************************** + * + * Filename: crc.c + * + * Description: Slow and fast implementations of the CRC standards. + * + * Notes: The parameters for each supported CRC standard are + * defined in the header file crc.h. The implementations + * here should stand up to further additions to that list. + * + * + * Copyright (c) 2000 by Michael Barr. This software is placed into + * the public domain and may be used for any purpose. However, this + * notice must not be changed or removed and no warranty is either + * expressed or implied by its publication or distribution. + **********************************************************************/ + +#include "crc.h" + + +/* + * Derive parameters from the standard-specific parameters in crc.h. + */ +#define WIDTH (8 * sizeof(crc)) +#define TOPBIT (1 << (WIDTH - 1)) + +#if (REFLECT_DATA == TRUE) +#undef REFLECT_DATA +#define REFLECT_DATA(X) ((unsigned char) reflect((X), 8)) +#else +#undef REFLECT_DATA +#define REFLECT_DATA(X) (X) +#endif + +#if (REFLECT_REMAINDER == TRUE) +#undef REFLECT_REMAINDER +#define REFLECT_REMAINDER(X) ((crc) reflect((X), WIDTH)) +#else +#undef REFLECT_REMAINDER +#define REFLECT_REMAINDER(X) (X) +#endif + + +/********************************************************************* + * + * Function: reflect() + * + * Description: Reorder the bits of a binary sequence, by reflecting + * them about the middle position. + * + * Notes: No checking is done that nBits <= 32. + * + * Returns: The reflection of the original data. + * + *********************************************************************/ +static unsigned long +reflect(unsigned long data, unsigned char nBits) { + unsigned long reflection = 0x00000000; + unsigned char bit; + + /* + * Reflect the data about the center bit. + */ + for (bit = 0; bit < nBits; ++bit) { + /* + * If the LSB bit is set, set the reflection of it. + */ + if (data & 0x01) { + reflection |= (1 << ((nBits - 1) - bit)); + } + + data = (data >> 1); + } + + return (reflection); + +} /* reflect() */ + + +/********************************************************************* + * + * Function: crcSlow() + * + * Description: Compute the CRC of a given message. + * + * Notes: + * + * Returns: The CRC of the message. + * + *********************************************************************/ +crc +crcSlow(unsigned char const message[], int nBytes) { + crc remainder = INITIAL_REMAINDER; + int byte; + unsigned char bit; + + + /* + * Perform modulo-2 division, a byte at a time. + */ + for (byte = 0; byte < nBytes; ++byte) { + /* + * Bring the next byte into the remainder. + */ + remainder ^= (REFLECT_DATA(message[byte]) << (WIDTH - 8)); + + /* + * Perform modulo-2 division, a bit at a time. + */ + for (bit = 8; bit > 0; --bit) { + /* + * Try to divide the current data bit. + */ + if (remainder & TOPBIT) { + remainder = (remainder << 1) ^ POLYNOMIAL; + } else { + remainder = (remainder << 1); + } + } + } + + /* + * The final remainder is the CRC result. + */ + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); + +} /* crcSlow() */ + + +crc crcTable[256]; + + +/********************************************************************* + * + * Function: crcInit() + * + * Description: Populate the partial CRC lookup table. + * + * Notes: This function must be rerun any time the CRC standard + * is changed. If desired, it can be run "offline" and + * the table results stored in an embedded system's ROM. + * + * Returns: None defined. + * + *********************************************************************/ +void +crcInit(void) { + crc remainder; + int dividend; + unsigned char bit; + + + /* + * Compute the remainder of each possible dividend. + */ + for (dividend = 0; dividend < 256; ++dividend) { + /* + * Start with the dividend followed by zeros. + */ + remainder = dividend << (WIDTH - 8); + + /* + * Perform modulo-2 division, a bit at a time. + */ + for (bit = 8; bit > 0; --bit) { + /* + * Try to divide the current data bit. + */ + if (remainder & TOPBIT) { + remainder = (remainder << 1) ^ POLYNOMIAL; + } else { + remainder = (remainder << 1); + } + } + + /* + * Store the result into the table. + */ + crcTable[dividend] = remainder; + } + +} /* crcInit() */ + + +/********************************************************************* + * + * Function: crcFast() + * + * Description: Compute the CRC of a given message. + * + * Notes: crcInit() must be called first. + * + * Returns: The CRC of the message. + * + *********************************************************************/ +crc +crcFast(unsigned char const message[], int nBytes) { + crc remainder = INITIAL_REMAINDER; + unsigned char data; + int byte; + + + /* + * Divide the message by the polynomial, a byte at a time. + */ + for (byte = 0; byte < nBytes; ++byte) { + data = (unsigned char)(REFLECT_DATA(message[byte]) ^ (remainder >> (WIDTH - 8))); + remainder = crcTable[data] ^ (remainder << 8); + } + + /* + * The final remainder is the CRC. + */ + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); + +} /* crcFast() */ + + + +crc crc_initialize(void) { + crcInit(); + return INITIAL_REMAINDER; +} + +crc crc_process_byte(unsigned char byte, crc remainder) { + unsigned char data; + data = (unsigned char)(REFLECT_DATA(byte ) ^ (remainder >> (WIDTH - 8))); + remainder = crcTable[data] ^ (remainder << 8); + return remainder; +} + +crc crc_finalize(crc remainder) { + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); +} diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 2870ec47fe..06fff01eeb 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -7,7 +7,9 @@ MODULE_OBJS := \ scriptables/ScValue.o \ scriptables/SXArray.o \ scriptables/SXDate.o \ + scriptables/SXFile.o \ scriptables/SXMath.o \ + scriptables/SxObject.o \ scriptables/SXMemBuffer.o \ scriptables/SXStore.o \ scriptables/SXString.o \ @@ -78,6 +80,7 @@ MODULE_OBJS := \ BTransitionMgr.o \ BViewport.o \ ConvertUTF.o \ + crc.o \ detection.o \ FontGlyphCache.o \ MathUtil.o \ -- cgit v1.2.3 From f32d92401786667de96b9bcfb10517c05cd9bc0e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:08:02 +0100 Subject: WINTERMUTE: Add BSurfaceSDL to build --- engines/wintermute/BSurfaceSDL.cpp | 33 +++++++++++++++++++++++---------- engines/wintermute/module.mk | 1 + 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 66c9256cf0..fccea082a5 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -31,7 +31,7 @@ #include "BGame.h" #include "BSurfaceSDL.h" #include "BRenderSDL.h" -#include "SdlUtil.h" +//#include "SdlUtil.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/pixelformat.h" @@ -53,11 +53,14 @@ CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::~CBSurfaceSDL() { + //TODO +#if 0 if (m_Texture) SDL_DestroyTexture(m_Texture); delete[] m_AlphaMask; m_AlphaMask = NULL; Game->AddMem(-m_Width * m_Height * 4); +#endif } ////////////////////////////////////////////////////////////////////////// @@ -127,8 +130,10 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue)); - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //m_Texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + warning("Surface-textures not fully ported yet"); +#if 0 m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); if (!m_Texture) { SDL_FreeSurface(surf); @@ -160,7 +165,7 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte m_Valid = true; Game->AddMem(m_Width * m_Height * 4); - +#endif return S_OK; } @@ -176,11 +181,11 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { bool hasColorKey; Uint32 colorKey; Uint8 ckRed, ckGreen, ckBlue; - if (SDL_GetColorKey(surface, &colorKey) == 0) { +/* if (SDL_GetColorKey(surface, &colorKey) == 0) { hasColorKey = true; SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); } else hasColorKey = false; - +*/ //TODO m_AlphaMask = new byte[surface->w * surface->h]; bool hasTransparency = false; @@ -240,6 +245,8 @@ Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::Create(int Width, int Height) { + warning("SurfaceSDL::Create not ported yet"); //TODO +#if 0 CBRenderSDL *renderer = static_cast(Game->m_Renderer); m_Texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); @@ -249,12 +256,14 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) { Game->AddMem(m_Width * m_Height * 4); m_Valid = true; - +#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { + warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO +#if 0 CBRenderSDL *renderer = static_cast(Game->m_Renderer); m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); @@ -264,7 +273,7 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { Game->AddMem(m_Width * m_Height * 4); m_Valid = true; - +#endif return S_OK; } @@ -272,7 +281,8 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { int access; int width, height; - SDL_QueryTexture(m_Texture, NULL, &access, &width, &height); + warning("CBSurfaceSDL::IsTransparentAt not ported yet"); + //SDL_QueryTexture(m_Texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -291,7 +301,8 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { Uint32 format; int access; int width, height; - SDL_QueryTexture(m_Texture, &format, &access, &width, &height); + warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); + //SDL_QueryTexture(m_Texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -368,6 +379,8 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo byte b = D3DCOLGetB(Alpha); byte a = D3DCOLGetA(Alpha); + warning("CBSurfaceSDL::DrawSprite not ported yet"); // TODO. +#if 0 SDL_SetTextureColorMod(m_Texture, r, g, b); SDL_SetTextureAlphaMod(m_Texture, a); @@ -394,7 +407,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.y += offsetY; SDL_RenderCopy(renderer->GetSdlRenderer(), m_Texture, &srcRect, &position); - +#endif return S_OK; } diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 06fff01eeb..0ecfaebf03 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -76,6 +76,7 @@ MODULE_OBJS := \ BStringTable.o \ BSubFrame.o \ BSurface.o \ + BSurfaceSDL.o \ BSurfaceStorage.o \ BTransitionMgr.o \ BViewport.o \ -- cgit v1.2.3 From fd3e4b7a92297dcf5e3fbf507e57ed00271fd898 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:15:42 +0100 Subject: WINTERMUTE: Stub and add BRenderSDL to the build --- engines/wintermute/BRenderSDL.cpp | 71 +++++++++++++++++++++++---------------- engines/wintermute/module.mk | 2 ++ 2 files changed, 44 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 312954097d..d28bbc477f 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -26,17 +26,20 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" -#include "BRenderSDL.h" -#include "BRegistry.h" -#include "BSurfaceSDL.h" -#include "BImage.h" -#include "MathUtil.h" -#include "BGame.h" -#include "BSprite.h" +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BRenderSDL.h" +#include "engines/wintermute/BRegistry.h" +#include "engines/wintermute/BSurfaceSDL.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BImage.h" +#include "engines/wintermute/MathUtil.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSprite.h" namespace WinterMute { +// TODO: Redo everything here. + ////////////////////////////////////////////////////////////////////////// CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { m_Renderer = NULL; @@ -48,9 +51,10 @@ CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { ////////////////////////////////////////////////////////////////////////// CBRenderSDL::~CBRenderSDL() { +#if 0 if (m_Renderer) SDL_DestroyRenderer(m_Renderer); if (m_Win) SDL_DestroyWindow(m_Win); - +#endif SDL_Quit(); } @@ -58,10 +62,10 @@ CBRenderSDL::~CBRenderSDL() { HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; - +#if 0 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); - +#endif m_Width = width; m_Height = height; @@ -120,22 +124,23 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { m_RatioX = (float)(m_RealWidth - m_BorderLeft - m_BorderRight) / (float)m_Width; m_RatioY = (float)(m_RealHeight - m_BorderTop - m_BorderBottom) / (float)m_Height; - +#if 0 Uint32 flags = SDL_WINDOW_SHOWN; +#endif #ifdef __IPHONEOS__ flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; #endif //m_Windowed = Game->m_Registry->ReadBool("Video", "Windowed", true); - if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; - +// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; +#if 0 m_Win = SDL_CreateWindow("WME Lite", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_RealWidth, m_RealHeight, flags); - +#endif if (!m_Win) return E_FAIL; SDL_ShowCursor(SDL_DISABLE); @@ -146,8 +151,9 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { #else //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); #endif - +#if 0 m_Renderer = SDL_CreateRenderer(m_Win, -1, 0); +#endif if (!m_Renderer) return E_FAIL; m_Active = true; @@ -200,15 +206,15 @@ HRESULT CBRenderSDL::Flip() { #endif - SDL_RenderPresent(m_Renderer); + //SDL_RenderPresent(m_Renderer); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { - SDL_SetRenderDrawColor(m_Renderer, r, g, b, 0xFF); - SDL_RenderClear(m_Renderer); + //SDL_SetRenderDrawColor(m_Renderer, r, g, b, 0xFF); + //SDL_RenderClear(m_Renderer); return S_OK; } @@ -244,9 +250,9 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { byte b = D3DCOLGetB(Color); byte a = D3DCOLGetA(Color); - SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); - SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); - SDL_RenderFillRect(m_Renderer, &fillRect); + //SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(m_Renderer, &fillRect); return S_OK; } @@ -258,8 +264,8 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { byte b = D3DCOLGetB(Color); byte a = D3DCOLGetA(Color); - SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); - SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); + //SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); POINT point1, point2; point1.x = X1; @@ -271,7 +277,7 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { PointToScreen(&point2); - SDL_RenderDrawLine(m_Renderer, point1.x, point1.y, point2.x, point2.y); + //SDL_RenderDrawLine(m_Renderer, point1.x, point1.y, point2.x, point2.y); return S_OK; } @@ -305,11 +311,11 @@ CBImage *CBRenderSDL::TakeScreenshot() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::SwitchFullscreen() { - if (m_Windowed) SDL_SetWindowFullscreen(m_Win, SDL_TRUE); + /*if (m_Windowed) SDL_SetWindowFullscreen(m_Win, SDL_TRUE); else SDL_SetWindowFullscreen(m_Win, SDL_FALSE); m_Windowed = !m_Windowed; - +*/ Game->m_Registry->WriteBool("Video", "Windowed", m_Windowed); return S_OK; @@ -319,9 +325,11 @@ HRESULT CBRenderSDL::SwitchFullscreen() { const char *CBRenderSDL::GetName() { if (m_Name.empty()) { if (m_Renderer) { +#if 0 SDL_RendererInfo info; SDL_GetRendererInfo(m_Renderer, &info); m_Name = AnsiString(info.name); +#endif } } return m_Name.c_str(); @@ -337,13 +345,14 @@ HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { // TODO fix this once viewports work correctly in SDL/landscape #ifndef __IPHONEOS__ - SDL_RenderSetViewport(GetSdlRenderer(), &rect); + //SDL_RenderSetViewport(GetSdlRenderer(), &rect); #endif return S_OK; } ////////////////////////////////////////////////////////////////////////// void CBRenderSDL::ModTargetRect(SDL_Rect *rect) { +#if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -351,26 +360,30 @@ void CBRenderSDL::ModTargetRect(SDL_Rect *rect) { rect->y = MathUtil::Round(rect->y * m_RatioY + m_BorderTop - viewportRect.y); rect->w = MathUtil::RoundUp(rect->w * m_RatioX); rect->h = MathUtil::RoundUp(rect->h * m_RatioY); +#endif } ////////////////////////////////////////////////////////////////////////// void CBRenderSDL::PointFromScreen(POINT *point) { +#if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); point->x = point->x / m_RatioX - m_BorderLeft / m_RatioX + viewportRect.x; point->y = point->y / m_RatioY - m_BorderTop / m_RatioY + viewportRect.y; +#endif } ////////////////////////////////////////////////////////////////////////// void CBRenderSDL::PointToScreen(POINT *point) { +#if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); point->x = MathUtil::RoundUp(point->x * m_RatioX) + m_BorderLeft - viewportRect.x; point->y = MathUtil::RoundUp(point->y * m_RatioY) + m_BorderTop - viewportRect.y; - +#endif } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 0ecfaebf03..4adc6e9edd 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -64,6 +64,8 @@ MODULE_OBJS := \ BQuickMsg.o \ BRegion.o \ BRegistry.o \ + BRenderer.o \ + BRenderSDL.o \ BResources.o \ BResourceFile.o \ BSaveThumbFile.o \ -- cgit v1.2.3 From 46458bfc00f6822ab21875c8bffe7695eade7156 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:18:54 +0100 Subject: WINTERMUTE: Add BDiskFile to build --- engines/wintermute/BDiskFile.cpp | 8 +++++--- engines/wintermute/module.mk | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index ea7a24a0a9..df2db0003d 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -60,8 +60,9 @@ HRESULT CBDiskFile::Open(Common::String Filename) { for (int i = 0; i < Game->m_FileManager->m_SinglePaths.GetSize(); i++) { sprintf(FullPath, "%s%s", Game->m_FileManager->m_SinglePaths[i], Filename.c_str()); CorrectSlashes(FullPath); - - m_File = Common::createFileStream(FullPath); + + error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); + //m_File = Common::createFileStream(FullPath); if (m_File != NULL) break; } @@ -70,7 +71,8 @@ HRESULT CBDiskFile::Open(Common::String Filename) { if (!m_File) { strcpy(FullPath, Filename.c_str()); CorrectSlashes(FullPath); - m_File = Common::createFileStream(FullPath); + error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); + //m_File = Common::createFileStream(FullPath); } if (m_File) { diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 4adc6e9edd..0fba4a202f 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -42,6 +42,7 @@ MODULE_OBJS := \ BActiveRect.o \ BBase.o \ BDebugger.o \ + BDiskFile.o \ BDynBuffer.o \ BFader.o \ BFile.o \ -- cgit v1.2.3 From 5b01f6a284e9e6d21234603ade4557cada9982c0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:22:40 +0100 Subject: WINTERMUTE: Add BKeyboardState to build --- engines/wintermute/BKeyboardState.cpp | 15 ++++++++------- engines/wintermute/module.mk | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 055b2cf8c5..d15b800d8e 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -71,11 +71,12 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta vKey = (int)str[0]; } else vKey = val->GetInt(); - Uint8 *state = SDL_GetKeyboardState(NULL); - SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); - bool isDown = state[scanCode] > 0; + warning("BKeyboardState doesnt yet have state-support"); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); +// bool isDown = state[scanCode] > 0; - Stack->PushBool(isDown); +// Stack->PushBool(isDown); return S_OK; } @@ -177,7 +178,7 @@ char *CBKeyboardState::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBKeyboardState::ReadKey(SDL_Event *event) { - m_CurrentPrintable = (event->type == SDL_TEXTINPUT); + //m_CurrentPrintable = (event->type == SDL_TEXTINPUT); // TODO m_CurrentCharCode = KeyCodeToVKey(event); //m_CurrentKeyData = KeyData; @@ -235,9 +236,9 @@ uint32 CBKeyboardState::KeyCodeToVKey(SDL_Event *event) { } ////////////////////////////////////////////////////////////////////////// -SDL_Keycode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { +Common::KeyCode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { // todo - return (SDL_Keycode)vkey; + return (Common::KeyCode)vkey; } } // end of namespace WinterMute diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 0fba4a202f..80d599c8ff 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -55,6 +55,7 @@ MODULE_OBJS := \ BFontTT.o \ BFrame.o \ BImage.o \ + BKeyboardState.o \ BNamedObject.o \ BObject.o \ BPackage.o \ @@ -70,6 +71,7 @@ MODULE_OBJS := \ BResources.o \ BResourceFile.o \ BSaveThumbFile.o \ + BSaveThumbHelper.o \ BScriptable.o \ BScriptHolder.o \ BSound.o \ -- cgit v1.2.3 From f4b95a0d73e1e67a66236b69533dd673a897be78 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:24:18 +0100 Subject: WINTERMUTE: Remove STL from ScValue --- engines/wintermute/scriptables/ScValue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index f42cbf6a30..b843e2032c 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -230,8 +230,8 @@ HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsC /* m_ValIter = m_ValObject.find(Name); if (m_ValIter != m_ValObject.end()){ - delete m_ValIter->second; - m_ValIter->second = NULL; + delete m_ValIter->_value; + m_ValIter->_value = NULL; } CScValue* val = new CScValue(Game); val->Copy(Val, CopyWhole); -- cgit v1.2.3 From a5d992d513cc21c643a09410fdccbe26cbd8592f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 13 Mar 2012 17:32:06 +0100 Subject: WINTERMUTE: Add the missing TinyXML-parts --- engines/wintermute/module.mk | 2 + engines/wintermute/tinyxml.cpp | 2 +- engines/wintermute/tinyxml.h | 2 +- engines/wintermute/tinyxmlerror.cpp | 53 ++ engines/wintermute/tinyxmlparser.cpp | 1638 ++++++++++++++++++++++++++++++++++ 5 files changed, 1695 insertions(+), 2 deletions(-) create mode 100644 engines/wintermute/tinyxmlerror.cpp create mode 100644 engines/wintermute/tinyxmlparser.cpp (limited to 'engines') diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 80d599c8ff..fa7106c801 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -98,6 +98,8 @@ MODULE_OBJS := \ SysInstance.o \ tinyxml.o \ tinystr.o \ + tinyxmlparser.o \ + tinyxmlerror.o \ UIButton.o \ UIEdit.o \ UIEntity.o \ diff --git a/engines/wintermute/tinyxml.cpp b/engines/wintermute/tinyxml.cpp index 5de21f6dec..4ff47d1432 100644 --- a/engines/wintermute/tinyxml.cpp +++ b/engines/wintermute/tinyxml.cpp @@ -29,7 +29,7 @@ distribution. #include #endif -#include "tinyxml.h" +#include "engines/wintermute/tinyxml.h" bool TiXmlBase::condenseWhiteSpace = true; diff --git a/engines/wintermute/tinyxml.h b/engines/wintermute/tinyxml.h index a78e981deb..afb07cfbed 100644 --- a/engines/wintermute/tinyxml.h +++ b/engines/wintermute/tinyxml.h @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -//#define TIXML_USE_STL +#undef TIXML_USE_STL #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED diff --git a/engines/wintermute/tinyxmlerror.cpp b/engines/wintermute/tinyxmlerror.cpp new file mode 100644 index 0000000000..d24f63b2e5 --- /dev/null +++ b/engines/wintermute/tinyxmlerror.cpp @@ -0,0 +1,53 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "tinyxml.h" + +// The goal of the seperate error file is to make the first +// step towards localization. tinyxml (currently) only supports +// english error messages, but the could now be translated. +// +// It also cleans up the code a bit. +// + +const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = +{ + "No error", + "Error", + "Failed to open file", + "Memory allocation failed.", + "Error parsing Element.", + "Failed to read Element name", + "Error reading Element value.", + "Error reading Attributes.", + "Error: empty tag.", + "Error reading end tag.", + "Error parsing Unknown.", + "Error parsing Comment.", + "Error parsing Declaration.", + "Error document empty.", + "Error null (0) or unexpected EOF found in input stream.", + "Error parsing CDATA.", + "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", +}; diff --git a/engines/wintermute/tinyxmlparser.cpp b/engines/wintermute/tinyxmlparser.cpp new file mode 100644 index 0000000000..14fd7c8c79 --- /dev/null +++ b/engines/wintermute/tinyxmlparser.cpp @@ -0,0 +1,1638 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include +#include + +#include "tinyxml.h" + +//#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif + +// Note tha "PutString" hardcodes the same list. This +// is less flexible than it appears. Changing the entries +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = +{ + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } +}; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// Including the basic of this table, which determines the #bytes in the +// sequence from the lead byte. 1 placed for invalid sequences -- +// although the result will be junk, pass it through as much as possible. +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf + +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +const int TiXmlBase::utf8ByteTable[256] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid +}; + + +void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { *length = 0; return; } // This code won't covert this correctly anyway. + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } +} + + +/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalpha( anyByte ); +// } +} + + +/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalnum( anyByte ); +// } +} + + +class TiXmlParsingData +{ + friend class TiXmlDocument; + public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() { return cursor; } + + private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; +}; + + +void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) +{ + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { p +=3; ++col; } // A normal character. + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); +} + + +const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) +{ + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) + ++p; + } + + return p; +} + +#ifdef TIXML_USE_STL +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) +{ + for( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; + + *tag += (char) in->get(); + } +} + +/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) +{ + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; +} +#endif + +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// +const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) +{ + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } + return p; + } + return 0; +} + +const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) +{ + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for( i=0; iappend( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p ) + p += strlen( endTag ); + return p; +} + +#ifdef TIXML_USE_STL + +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); +} + +#endif + +const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) +{ + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; +} + +void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } +} + + +TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) +{ + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if( !p || !*p || *p != '<' ) + { + return 0; + } + + TiXmlDocument* doc = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: "; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p ) + p += strlen( endTag ); + + return p; +} + + +const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + +// int tabsize = 4; +// if ( document ) +// tabsize = document->TabSize(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } + } +} +#endif + +const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = ""; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } +} + +#ifdef TIXML_USE_STL +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + +const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) +{ + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; +} + +bool TiXmlText::Blank() const +{ + for ( unsigned i=0; im_FileManager->m_SinglePaths[i], Filename.c_str()); CorrectSlashes(FullPath); - error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); //m_File = Common::createFileStream(FullPath); - if (m_File != NULL) + Common::File *tempFile = new Common::File(); + if(tempFile->open(FullPath)) { + m_File = tempFile; + } else { + delete tempFile; + } +/* if (m_File != NULL) { + error("Tried to open %s, but failed", Filename.c_str()); break; + }*/ } // if we didn't find it in search paths, try to open directly if (!m_File) { strcpy(FullPath, Filename.c_str()); CorrectSlashes(FullPath); - error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); + //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); //m_File = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(FullPath)) { + m_File = tempFile; + } else { + delete tempFile; + } } + if (!m_File) { + warning("Couldn't load %s", Filename.c_str()); + } + if (m_File) { uint32 magic1, magic2; magic1 = m_File->readUint32LE(); diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 8763506e99..2e0e296eb0 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -26,6 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ + + #include "dcgf.h" #include "BFileManager.h" #include "StringUtil.h" @@ -44,6 +46,10 @@ #include "common/str.h" #include "common/textconsole.h" #include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" //#include #ifdef __WIN32__ @@ -178,6 +184,9 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { + // TODO + warning("Implement SaveFile"); +#if 0 RestoreCurrentDir(); CBUtils::CreatePath(Filename, false); @@ -224,7 +233,7 @@ HRESULT CBFileManager::SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, if (!Compressed) fwrite(Buffer, BufferSize, 1, f); fclose(f); - +#endif return S_OK; } @@ -357,6 +366,10 @@ HRESULT CBFileManager::RegisterPackages() { Game->LOG(0, "Scanning packages..."); warning("Scanning packages"); + +// TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. + RegisterPackage("data.dcp"); + RegisterPackage("english.dcp"); #if 0 AnsiString extension = AnsiString(".") + AnsiString(PACKAGE_EXTENSION); @@ -385,15 +398,144 @@ HRESULT CBFileManager::RegisterPackages() { } } - + warning(" Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); Game->LOG(0, " Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); #endif + warning(" Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); return S_OK; } - +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSignature) { +// FILE *f = fopen(Filename, "rb"); + Common::File *package = new Common::File(); + package->open(Filename); + if (!package->isOpen()) { + Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename.c_str()); + return S_OK; + } + + uint32 AbsoluteOffset = 0; + bool BoundToExe = false; + + if (SearchSignature) { + uint32 Offset; + if (!FindPackageSignature(package, &Offset)) { + delete package; + return S_OK; + } else { + package->seek(Offset, SEEK_SET); + AbsoluteOffset = Offset; + BoundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); + delete package; + return S_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 DirOffset; + DirOffset = package->readUint32LE(); + DirOffset += AbsoluteOffset; + package->seek(DirOffset, SEEK_SET); + } + + for (int i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(Game); + if (!pkg) return E_FAIL; + + pkg->m_BoundToExe = BoundToExe; + + // read package info + byte NameLength = package->readByte(); + pkg->m_Name = new char[NameLength]; + package->read(pkg->m_Name, NameLength); + pkg->m_CD = package->readByte(); + pkg->m_Priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->m_CD = 0; // override CD to fixed disk + m_Packages.Add(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (int j = 0; j < NumFiles; j++) { + char *Name; + uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; + + NameLength = package->readByte(); + Name = new char[NameLength]; + package->read(Name, NameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < NameLength; k++) { + ((byte *)Name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + Name[NameLength - 1] = '\0'; + + + CBPlatform::strupr(Name); + + Offset = package->readUint32LE(); + Offset += AbsoluteOffset; + Length = package->readUint32LE(); + CompLength = package->readUint32LE(); + Flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + TimeDate1 = package->readUint32LE(); + TimeDate2 = package->readUint32LE(); + } + m_FilesIter = m_Files.find(Name); + if (m_FilesIter == m_Files.end()) { + CBFileEntry *file = new CBFileEntry(Game); + file->m_Package = pkg; + file->m_Offset = Offset; + file->m_Length = Length; + file->m_CompressedLength = CompLength; + file->m_Flags = Flags; + + m_Files[Name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->m_CD < m_FilesIter->_value->m_Package->m_CD || pkg->m_Priority > m_FilesIter->_value->m_Package->m_Priority) { + m_FilesIter->_value->m_Package = pkg; + m_FilesIter->_value->m_Offset = Offset; + m_FilesIter->_value->m_Length = Length; + m_FilesIter->_value->m_CompressedLength = CompLength; + m_FilesIter->_value->m_Flags = Flags; + } + } + delete [] Name; + } + } + + + delete package; + return S_OK; +} ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool SearchSignature) { +// TODO + error("Implement RegisterPackage, this is the old one"); +#if 0 char Filename[MAX_PATH]; sprintf(Filename, "%s%s", Path, Name); @@ -403,7 +545,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool return S_OK; } - uint32 AbosulteOffset = 0; + uint32 AbsoluteOffset = 0; bool BoundToExe = false; if (SearchSignature) { @@ -413,7 +555,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool return S_OK; } else { fseek(f, Offset, SEEK_SET); - AbosulteOffset = Offset; + AbsoluteOffset = Offset; BoundToExe = true; } } @@ -434,7 +576,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool if (hdr.PackageVersion == PACKAGE_VERSION) { uint32 DirOffset; fread(&DirOffset, sizeof(uint32), 1, f); - DirOffset += AbosulteOffset; + DirOffset += AbsoluteOffset; fseek(f, DirOffset, SEEK_SET); } @@ -483,7 +625,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool CBPlatform::strupr(Name); fread(&Offset, sizeof(uint32), 1, f); - Offset += AbosulteOffset; + Offset += AbsoluteOffset; fread(&Length, sizeof(uint32), 1, f); fread(&CompLength, sizeof(uint32), 1, f); fread(&Flags, sizeof(uint32), 1, f); @@ -518,7 +660,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool fclose(f); - +#endif return S_OK; } @@ -534,36 +676,50 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -FILE *CBFileManager::OpenPackage(char *Name) { - RestoreCurrentDir(); +Common::File *CBFileManager::OpenPackage(char *Name) { + //TODO + warning("Implement OpenPackage %s", Name); + + //RestoreCurrentDir(); - FILE *ret = NULL; + Common::File *ret = new Common::File(); char Filename[MAX_PATH]; for (int i = 0; i < m_PackagePaths.GetSize(); i++) { sprintf(Filename, "%s%s.%s", m_PackagePaths[i], Name, PACKAGE_EXTENSION); - ret = fopen(Filename, "rb"); - if (ret != NULL) return ret; + //ret = fopen(Filename, "rb"); + ret->open(Filename); + if (ret->isOpen()) { + return ret; + } } + delete ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -FILE *CBFileManager::OpenSingleFile(char *Name) { +Common::File *CBFileManager::OpenSingleFile(char *Name) { RestoreCurrentDir(); - - FILE *ret = NULL; + + Common::File *ret = NULL; char Filename[MAX_PATH]; - + for (int i = 0; i < m_SinglePaths.GetSize(); i++) { sprintf(Filename, "%s%s", m_SinglePaths[i], Name); - ret = fopen(Filename, "rb"); - if (ret != NULL) return ret; + ret->open(Filename); + if (ret->isOpen()) + return ret; } - + // didn't find in search paths, try to open directly - return fopen(Name, "rb"); + ret->open(Name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } } @@ -706,15 +862,14 @@ HRESULT CBFileManager::SetBasePath(char *Path) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::FindPackageSignature(FILE *f, uint32 *Offset) { +bool CBFileManager::FindPackageSignature(Common::File *f, uint32 *Offset) { byte buf[32768]; byte Signature[8]; ((uint32 *)Signature)[0] = PACKAGE_MAGIC_1; ((uint32 *)Signature)[1] = PACKAGE_MAGIC_2; - fseek(f, 0, SEEK_END); - uint32 FileSize = ftell(f); + uint32 FileSize = f->size(); int StartPos = 1024 * 1024; @@ -722,8 +877,8 @@ bool CBFileManager::FindPackageSignature(FILE *f, uint32 *Offset) { while (BytesRead < FileSize - 16) { int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); - fseek(f, StartPos, SEEK_SET); - int ActuallyRead = fread(buf, 1, ToRead, f); + f->seek(StartPos, SEEK_SET); + int ActuallyRead = f->read(buf, ToRead); if (ActuallyRead != ToRead) return false; for (int i = 0; i < ToRead - 8; i++) diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index 849a30bf8e..bee43e696d 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -35,11 +35,15 @@ #include "BFileEntry.h" #include "common/archive.h" +namespace Common { + class File; +} + namespace WinterMute { class CBFile; class CBFileManager: CBBase { public: - bool FindPackageSignature(FILE *f, uint32 *Offset); + bool FindPackageSignature(Common::File *f, uint32 *Offset); HRESULT Cleanup(); HRESULT SetBasePath(char *Path); HRESULT RestoreCurrentDir(); @@ -49,8 +53,8 @@ public: HRESULT CloseFile(CBFile *File); CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); CBFileEntry *GetPackageEntry(const char *Filename); - FILE *OpenSingleFile(char *Name); - FILE *OpenPackage(char *Name); + Common::File *OpenSingleFile(char *Name); + Common::File *OpenPackage(char *Name); HRESULT RegisterPackages(); HRESULT InitPaths(); HRESULT ReloadPaths(); @@ -71,6 +75,7 @@ public: Common::HashMap m_Files; private: HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); + HRESULT RegisterPackage(Common::String Filename, bool SearchSignature = false); Common::HashMap::iterator m_FilesIter; bool IsValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp index d5ae12fa84..2193999e2c 100644 --- a/engines/wintermute/BPackage.cpp +++ b/engines/wintermute/BPackage.cpp @@ -30,6 +30,7 @@ #include "BPackage.h" #include "BGame.h" #include "BFileManager.h" +#include "common/file.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////// @@ -66,26 +67,26 @@ HRESULT CBPackage::Open() { ////////////////////////////////////////////////////////////////////////// HRESULT CBPackage::Close() { - if (m_File) fclose(m_File); + delete m_File; m_File = NULL; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Read(FILE *file, uint32 offset, byte *buffer, uint32 size) { +HRESULT CBPackage::Read(Common::File *file, uint32 offset, byte *buffer, uint32 size) { HRESULT ret; if (FAILED(ret = Open())) return ret; else { - if (fseek(file, offset, SEEK_SET)) return E_FAIL; - if (fread(buffer, size, 1, file) != 1) return E_FAIL; + if (file->seek(offset, SEEK_SET)) return E_FAIL; + if (file->read(buffer, size) != 1) return E_FAIL; else return S_OK; } } ////////////////////////////////////////////////////////////////////////// -FILE *CBPackage::GetFilePointer() { - FILE *file = Game->m_FileManager->OpenPackage(m_Name); +Common::File *CBPackage::GetFilePointer() { + Common::File *file = Game->m_FileManager->OpenPackage(m_Name); if (!file) { Game->m_FileManager->RequestCD(m_CD, m_Name, ""); file = Game->m_FileManager->OpenPackage(m_Name); @@ -94,8 +95,8 @@ FILE *CBPackage::GetFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::CloseFilePointer(FILE*& file) { - if (file) fclose(file); +void CBPackage::CloseFilePointer(Common::File*& file) { + delete file; file = NULL; } diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h index 54f2e04a6c..6f1c8e1561 100644 --- a/engines/wintermute/BPackage.h +++ b/engines/wintermute/BPackage.h @@ -32,21 +32,25 @@ #include "BBase.h" +namespace Common { + class File; +} + namespace WinterMute { class CBPackage : public CBBase { public: - FILE *GetFilePointer(); - void CloseFilePointer(FILE*& file); + Common::File *GetFilePointer(); + void CloseFilePointer(Common::File*& file); bool m_BoundToExe; byte m_Priority; - HRESULT Read(FILE *file, uint32 offset, byte *buffer, uint32 size); + HRESULT Read(Common::File *file, uint32 offset, byte *buffer, uint32 size); HRESULT Close(); HRESULT Open(); char *m_Name; int m_CD; - FILE *m_File; + Common::File *m_File; CBPackage(CBGame *inGame); virtual ~CBPackage(); diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h index a00c954860..d6aac57d1d 100644 --- a/engines/wintermute/BPkgFile.h +++ b/engines/wintermute/BPkgFile.h @@ -36,6 +36,10 @@ #define COMPRESSED_BUFFER_SIZE 4096 +namespace Common { + class File; +} + namespace WinterMute { class CBPkgFile : public CBFile { @@ -53,7 +57,7 @@ private: CBFileEntry *m_FileEntry; z_stream m_Stream; byte m_CompBuffer[COMPRESSED_BUFFER_SIZE]; - FILE *m_File; + Common::File *m_File; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Matrix4.cpp b/engines/wintermute/Matrix4.cpp new file mode 100644 index 0000000000..90a3f69f2c --- /dev/null +++ b/engines/wintermute/Matrix4.cpp @@ -0,0 +1,83 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/Matrix4.h" +#include "engines/wintermute/Vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Matrix4::Matrix4() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } +} + +////////////////////////////////////////////////////////////////////////// +Matrix4::~Matrix4() { +} + + +////////////////////////////////////////////////////////////////////////// +void Matrix4::Identity() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } + m[0][0] = 1.0f; + m[1][1] = 1.0f; + m[2][2] = 1.0f; + m[3][3] = 1.0f; + +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::RotationZ(float angle) { + Identity(); + + m[0][0] = cos(angle); + m[1][1] = cos(angle); + m[0][1] = sin(angle); + m[1][0] = -sin(angle); +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::TransformVector2(Vector2 &vec) { + float norm; + + norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; + + float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; + float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; + + vec.x = x; + vec.y = y; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Matrix4.h b/engines/wintermute/Matrix4.h new file mode 100644 index 0000000000..866d5cdf34 --- /dev/null +++ b/engines/wintermute/Matrix4.h @@ -0,0 +1,56 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __WmeMatrix4_H__ +#define __WmeMatrix4_H__ + +namespace WinterMute { + +class Vector2; + +class Matrix4 { +public: + Matrix4(); + ~Matrix4(); + + void Identity(); + void RotationZ(float angle); + void TransformVector2(Vector2 &vec); + +/* union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + };*/ + float m[4][4]; + //}; + +}; + +} // end of namespace WinterMute + +#endif // __WmeMatrix4_H__ \ No newline at end of file diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp new file mode 100644 index 0000000000..0e8f7ee1b7 --- /dev/null +++ b/engines/wintermute/PartEmitter.cpp @@ -0,0 +1,1194 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/PartEmitter.h" +#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/Matrix4.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + m_Width = m_Height = 0; + + CBPlatform::SetRectEmpty(&m_Border); + m_BorderThicknessLeft = m_BorderThicknessRight = m_BorderThicknessTop = m_BorderThicknessBottom = 0; + + m_Angle1 = m_Angle2 = 0; + + m_Velocity1 = m_Velocity2 = 0.0f; + m_VelocityZBased = false; + + m_Scale1 = m_Scale2 = 100.0f; + m_ScaleZBased = false; + + m_MaxParticles = 100; + + m_LifeTime1 = m_LifeTime2 = 1000; + m_LifeTimeZBased = false; + + m_LastGenTime = 0; + m_GenInterval = 0; + m_GenAmount = 1; + + m_OverheadTime = 0; + m_Running = false; + + m_MaxBatches = 0; + m_BatchesGenerated = 0; + + m_FadeInTime = m_FadeOutTime = 0; + + m_Alpha1 = m_Alpha2 = 255; + m_AlphaTimeBased = false; + + m_Rotation1 = m_Rotation2 = 0.0f; + m_AngVelocity1 = m_AngVelocity2 = 0.0f; + + m_GrowthRate1 = m_GrowthRate2 = 0.0f; + m_ExponentialGrowth = false; + + m_UseRegion = false; + + m_EmitEvent = NULL; + m_Owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < m_Particles.GetSize(); i++) { + delete m_Particles[i]; + } + m_Particles.RemoveAll(); + + for (int i = 0; i < m_Forces.GetSize(); i++) { + delete m_Forces[i]; + } + m_Forces.RemoveAll(); + + + for (int i = 0; i < m_Sprites.GetSize(); i++) { + delete [] m_Sprites[i]; + } + m_Sprites.RemoveAll(); + + delete[] m_EmitEvent; + m_EmitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::AddSprite(char *Filename) { + if (!Filename) return E_FAIL; + + // do we already have the file? + for (int i = 0; i < m_Sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, m_Sprites[i]) == 0) return S_OK; + } + + // check if file exists + CBFile *File = Game->m_FileManager->OpenFile(Filename); + if (!File) { + Game->LOG(0, "Sprite '%s' not found", Filename); + return E_FAIL; + } else Game->m_FileManager->CloseFile(File); + + char *Str = new char[strlen(Filename) + 1]; + strcpy(Str, Filename); + m_Sprites.Add(Str); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::RemoveSprite(char *Filename) { + for (int i = 0; i < m_Sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, m_Sprites[i]) == 0) { + delete [] m_Sprites[i]; + m_Sprites.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { + if (!Particle) return E_FAIL; + if (m_Sprites.GetSize() == 0) return E_FAIL; + + int PosX = CBUtils::RandomInt(m_PosX, m_PosX + m_Width); + int PosY = CBUtils::RandomInt(m_PosY, m_PosY + m_Height); + float PosZ = CBUtils::RandomFloat(0.0f, 100.0f); + + float Velocity; + if (m_VelocityZBased) Velocity = m_Velocity1 + PosZ * (m_Velocity2 - m_Velocity1) / 100; + else Velocity = CBUtils::RandomFloat(m_Velocity1, m_Velocity2); + + float Scale; + if (m_ScaleZBased) Scale = m_Scale1 + PosZ * (m_Scale2 - m_Scale1) / 100; + else Scale = CBUtils::RandomFloat(m_Scale1, m_Scale2); + + int LifeTime; + if (m_LifeTimeZBased) LifeTime = m_LifeTime2 - PosZ * (m_LifeTime2 - m_LifeTime1) / 100; + else LifeTime = CBUtils::RandomInt(m_LifeTime1, m_LifeTime2); + + float Angle = CBUtils::RandomAngle(m_Angle1, m_Angle2); + int SpriteIndex = CBUtils::RandomInt(0, m_Sprites.GetSize() - 1); + + float Rotation = CBUtils::RandomAngle(m_Rotation1, m_Rotation2); + float AngVelocity = CBUtils::RandomFloat(m_AngVelocity1, m_AngVelocity2); + float GrowthRate = CBUtils::RandomFloat(m_GrowthRate1, m_GrowthRate2); + + if (!CBPlatform::IsRectEmpty(&m_Border)) { + int ThicknessLeft = m_BorderThicknessLeft - (float)m_BorderThicknessLeft * PosZ / 100.0f; + int ThicknessRight = m_BorderThicknessRight - (float)m_BorderThicknessRight * PosZ / 100.0f; + int ThicknessTop = m_BorderThicknessTop - (float)m_BorderThicknessTop * PosZ / 100.0f; + int ThicknessBottom = m_BorderThicknessBottom - (float)m_BorderThicknessBottom * PosZ / 100.0f; + + Particle->m_Border = m_Border; + Particle->m_Border.left += ThicknessLeft; + Particle->m_Border.right -= ThicknessRight; + Particle->m_Border.top += ThicknessTop; + Particle->m_Border.bottom -= ThicknessBottom; + } + + Vector2 VecPos((float)PosX, (float)PosY); + Vector2 VecVel(0, Velocity); + + Matrix4 MatRot; + MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.TransformVector2(VecVel); + + if (m_AlphaTimeBased) { + Particle->m_Alpha1 = m_Alpha1; + Particle->m_Alpha2 = m_Alpha2; + } else { + int Alpha = CBUtils::RandomInt(m_Alpha1, m_Alpha2); + Particle->m_Alpha1 = Alpha; + Particle->m_Alpha2 = Alpha; + } + + Particle->m_CreationTime = CurrentTime; + Particle->m_Pos = VecPos; + Particle->m_PosZ = PosZ; + Particle->m_Velocity = VecVel; + Particle->m_Scale = Scale; + Particle->m_LifeTime = LifeTime; + Particle->m_Rotation = Rotation; + Particle->m_AngVelocity = AngVelocity; + Particle->m_GrowthRate = GrowthRate; + Particle->m_ExponentialGrowth = m_ExponentialGrowth; + Particle->m_IsDead = FAILED(Particle->SetSprite(m_Sprites[SpriteIndex])); + Particle->FadeIn(CurrentTime, m_FadeInTime); + + + if (Particle->m_IsDead) return E_FAIL; + else return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Update() { + if (!m_Running) return S_OK; + else return UpdateInternal(Game->m_Timer, Game->m_TimerDelta); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { + int NumLive = 0; + + for (int i = 0; i < m_Particles.GetSize(); i++) { + m_Particles[i]->Update(this, CurrentTime, TimerDelta); + + if (!m_Particles[i]->m_IsDead) NumLive++; + } + + + // we're understaffed + if (NumLive < m_MaxParticles) { + bool NeedsSort = false; + if (CurrentTime - m_LastGenTime > m_GenInterval) { + m_LastGenTime = CurrentTime; + m_BatchesGenerated++; + + if (m_MaxBatches > 0 && m_BatchesGenerated > m_MaxBatches) { + return S_OK; + } + + int ToGen = std::min(m_GenAmount, m_MaxParticles - NumLive); + while (ToGen > 0) { + int FirstDeadIndex = -1; + for (int i = 0; i < m_Particles.GetSize(); i++) { + if (m_Particles[i]->m_IsDead) { + FirstDeadIndex = i; + break; + } + } + + CPartParticle *Particle; + if (FirstDeadIndex >= 0) Particle = m_Particles[FirstDeadIndex]; + else { + Particle = new CPartParticle(Game); + m_Particles.Add(Particle); + } + InitParticle(Particle, CurrentTime, TimerDelta); + NeedsSort = true; + + ToGen--; + } + } + if (NeedsSort && (m_ScaleZBased || m_VelocityZBased || m_LifeTimeZBased)) + SortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (NeedsSort && m_OverheadTime == 0) { + if (m_Owner && m_EmitEvent) m_Owner->ApplyEvent(m_EmitEvent); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Display(CBRegion *Region) { + if (m_Sprites.GetSize() <= 1) Game->m_Renderer->StartSpriteBatch(); + + for (int i = 0; i < m_Particles.GetSize(); i++) { + if (Region != NULL && m_UseRegion) { + if (!Region->PointInRegion(m_Particles[i]->m_Pos.x, m_Particles[i]->m_Pos.y)) continue; + } + + m_Particles[i]->Display(this); + } + + if (m_Sprites.GetSize() <= 1) Game->m_Renderer->EndSpriteBatch(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Start() { + for (int i = 0; i < m_Particles.GetSize(); i++) { + m_Particles[i]->m_IsDead = true; + } + m_Running = true; + m_BatchesGenerated = 0; + + + if (m_OverheadTime > 0) { + uint32 Delta = 500; + int Steps = m_OverheadTime / Delta; + uint32 CurrentTime = Game->m_Timer - m_OverheadTime; + + for (int i = 0; i < Steps; i++) { + UpdateInternal(CurrentTime, Delta); + CurrentTime += Delta; + } + m_OverheadTime = 0; + } + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SortParticlesByZ() { + // sort particles by m_PosY + qsort(m_Particles.GetData(), m_Particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { + CPartParticle *P1 = *(CPartParticle **)Obj1; + CPartParticle *P2 = *(CPartParticle **)Obj2; + + if (P1->m_PosZ < P2->m_PosZ) return -1; + else if (P1->m_PosZ > P2->m_PosZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SetBorder(int X, int Y, int Width, int Height) { + CBPlatform::SetRect(&m_Border, X, Y, X + Width, Y + Height); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { + m_BorderThicknessLeft = ThicknessLeft; + m_BorderThicknessRight = ThicknessRight; + m_BorderThicknessTop = ThicknessTop; + m_BorderThicknessBottom = ThicknessBottom; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::AddForceByName(char *Name) { + CPartForce *Force = NULL; + + for (int i = 0; i < m_Forces.GetSize(); i++) { + if (scumm_stricmp(Name, m_Forces[i]->m_Name) == 0) { + Force = m_Forces[i]; + break; + } + } + if (!Force) { + Force = new CPartForce(Game); + if (Force) { + Force->SetName(Name); + m_Forces.Add(Force); + } + } + return Force; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { + CPartForce *Force = AddForceByName(Name); + if (!Force) return E_FAIL; + + Force->m_Type = Type; + Force->m_Pos = Vector2(PosX, PosY); + + Force->m_Direction = Vector2(0, Strength); + Matrix4 MatRot; + MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.TransformVector2(Force->m_Direction); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::RemoveForce(char *Name) { + for (int i = 0; i < m_Forces.GetSize(); i++) { + if (scumm_stricmp(Name, m_Forces[i]->m_Name) == 0) { + delete m_Forces[i]; + m_Forces.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetBorder") == 0) { + Stack->CorrectParams(4); + int BorderX = Stack->Pop()->GetInt(); + int BorderY = Stack->Pop()->GetInt(); + int BorderWidth = Stack->Pop()->GetInt(); + int BorderHeight = Stack->Pop()->GetInt(); + + Stack->PushBool(SUCCEEDED(SetBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetBorderThickness") == 0) { + Stack->CorrectParams(4); + int Left = Stack->Pop()->GetInt(); + int Right = Stack->Pop()->GetInt(); + int Top = Stack->Pop()->GetInt(); + int Bottom = Stack->Pop()->GetInt(); + + Stack->PushBool(SUCCEEDED(SetBorderThickness(Left, Right, Top, Bottom))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSprite") == 0) { + Stack->CorrectParams(1); + char *SpriteFile = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(AddSprite(SpriteFile))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveSprite") == 0) { + Stack->CorrectParams(1); + char *SpriteFile = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(RemoveSprite(SpriteFile))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Start") == 0) { + Stack->CorrectParams(1); + m_OverheadTime = Stack->Pop()->GetInt(); + Stack->PushBool(SUCCEEDED(Start())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Stop") == 0) { + Stack->CorrectParams(0); + + for (int i = 0; i < m_Particles.GetSize(); i++) { + delete m_Particles[i]; + } + m_Particles.RemoveAll(); + + m_Running = false; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pause") == 0) { + Stack->CorrectParams(0); + m_Running = false; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Resume") == 0) { + Stack->CorrectParams(0); + m_Running = true; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddGlobalForce") == 0) { + Stack->CorrectParams(3); + char *Name = Stack->Pop()->GetString(); + float Angle = Stack->Pop()->GetFloat(); + float Strength = Stack->Pop()->GetFloat(); + + Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddPointForce") == 0) { + Stack->CorrectParams(5); + char *Name = Stack->Pop()->GetString(); + int PosX = Stack->Pop()->GetInt(); + int PosY = Stack->Pop()->GetInt(); + float Angle = Stack->Pop()->GetFloat(); + float Strength = Stack->Pop()->GetFloat(); + + Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveForce") == 0) { + Stack->CorrectParams(1); + char *Name = Stack->Pop()->GetString(); + + Stack->PushBool(SUCCEEDED(RemoveForce(Name))); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::ScGetProperty(char *Name) { + m_ScValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + m_ScValue->SetString("particle-emitter"); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + m_ScValue->SetInt(m_PosX); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + m_ScValue->SetInt(m_PosY); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_ScValue->SetInt(m_Width); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_ScValue->SetInt(m_Height); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale1") == 0) { + m_ScValue->SetFloat(m_Scale1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale2") == 0) { + m_ScValue->SetFloat(m_Scale2); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleZBased") == 0) { + m_ScValue->SetBool(m_ScaleZBased); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity1") == 0) { + m_ScValue->SetFloat(m_Velocity1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity2") == 0) { + m_ScValue->SetFloat(m_Velocity2); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VelocityZBased") == 0) { + m_ScValue->SetBool(m_VelocityZBased); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime1") == 0) { + m_ScValue->SetInt(m_LifeTime1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime2") == 0) { + m_ScValue->SetInt(m_LifeTime2); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTimeZBased") == 0) { + m_ScValue->SetBool(m_LifeTimeZBased); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle1") == 0) { + m_ScValue->SetInt(m_Angle1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle2") == 0) { + m_ScValue->SetInt(m_Angle2); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity1") == 0) { + m_ScValue->SetFloat(m_AngVelocity1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity2") == 0) { + m_ScValue->SetFloat(m_AngVelocity2); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation1") == 0) { + m_ScValue->SetFloat(m_Rotation1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation2") == 0) { + m_ScValue->SetFloat(m_Rotation2); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha1") == 0) { + m_ScValue->SetInt(m_Alpha1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha2") == 0) { + m_ScValue->SetInt(m_Alpha2); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaTimeBased") == 0) { + m_ScValue->SetBool(m_AlphaTimeBased); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxParticles") == 0) { + m_ScValue->SetInt(m_MaxParticles); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumLiveParticles") == 0) { + int NumAlive = 0; + for (int i = 0; i < m_Particles.GetSize(); i++) { + if (m_Particles[i] && !m_Particles[i]->m_IsDead) NumAlive++; + } + m_ScValue->SetInt(NumAlive); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationInterval") == 0) { + m_ScValue->SetInt(m_GenInterval); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationAmount") == 0) { + m_ScValue->SetInt(m_GenAmount); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxBatches") == 0) { + m_ScValue->SetInt(m_MaxBatches); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeInTime") == 0) { + m_ScValue->SetInt(m_FadeInTime); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOutTime") == 0) { + m_ScValue->SetInt(m_FadeOutTime); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate1") == 0) { + m_ScValue->SetFloat(m_GrowthRate1); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate2") == 0) { + m_ScValue->SetFloat(m_GrowthRate2); + return m_ScValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExponentialGrowth") == 0) { + m_ScValue->SetBool(m_ExponentialGrowth); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UseRegion") == 0) { + m_ScValue->SetBool(m_UseRegion); + return m_ScValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmitEvent") == 0) { + if (!m_EmitEvent) m_ScValue->SetNULL(); + else m_ScValue->SetString(m_EmitEvent); + return m_ScValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "X") == 0) { + m_PosX = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + m_PosY = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + m_Width = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + m_Height = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale1") == 0) { + m_Scale1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale2") == 0) { + m_Scale2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleZBased") == 0) { + m_ScaleZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity1") == 0) { + m_Velocity1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity2") == 0) { + m_Velocity2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VelocityZBased") == 0) { + m_VelocityZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime1") == 0) { + m_LifeTime1 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime2") == 0) { + m_LifeTime2 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTimeZBased") == 0) { + m_LifeTimeZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle1") == 0) { + m_Angle1 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle2") == 0) { + m_Angle2 = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity1") == 0) { + m_AngVelocity1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity2") == 0) { + m_AngVelocity2 = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation1") == 0) { + m_Rotation1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation2") == 0) { + m_Rotation2 = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha1") == 0) { + m_Alpha1 = Value->GetInt(); + if (m_Alpha1 < 0) m_Alpha1 = 0; + if (m_Alpha1 > 255) m_Alpha1 = 255; + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha2") == 0) { + m_Alpha2 = Value->GetInt(); + if (m_Alpha2 < 0) m_Alpha2 = 0; + if (m_Alpha2 > 255) m_Alpha2 = 255; + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaTimeBased") == 0) { + m_AlphaTimeBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxParticles") == 0) { + m_MaxParticles = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationInterval") == 0) { + m_GenInterval = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationAmount") == 0) { + m_GenAmount = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxBatches") == 0) { + m_MaxBatches = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeInTime") == 0) { + m_FadeInTime = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOutTime") == 0) { + m_FadeOutTime = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate1") == 0) { + m_GrowthRate1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate2") == 0) { + m_GrowthRate2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExponentialGrowth") == 0) { + m_ExponentialGrowth = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UseRegion") == 0) { + m_UseRegion = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmitEvent") == 0) { + SAFE_DELETE_ARRAY(m_EmitEvent); + if (!Value->IsNULL()) CBUtils::SetString(&m_EmitEvent, Value->GetString()); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +char *CPartEmitter::ScToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(m_Width)); + PersistMgr->Transfer(TMEMBER(m_Height)); + + PersistMgr->Transfer(TMEMBER(m_Angle1)); + PersistMgr->Transfer(TMEMBER(m_Angle2)); + + PersistMgr->Transfer(TMEMBER(m_Velocity1)); + PersistMgr->Transfer(TMEMBER(m_Velocity2)); + PersistMgr->Transfer(TMEMBER(m_VelocityZBased)); + + PersistMgr->Transfer(TMEMBER(m_Scale1)); + PersistMgr->Transfer(TMEMBER(m_Scale2)); + PersistMgr->Transfer(TMEMBER(m_ScaleZBased)); + + PersistMgr->Transfer(TMEMBER(m_MaxParticles)); + + PersistMgr->Transfer(TMEMBER(m_LifeTime1)); + PersistMgr->Transfer(TMEMBER(m_LifeTime2)); + PersistMgr->Transfer(TMEMBER(m_LifeTimeZBased)); + + PersistMgr->Transfer(TMEMBER(m_GenInterval)); + PersistMgr->Transfer(TMEMBER(m_GenAmount)); + + PersistMgr->Transfer(TMEMBER(m_Running)); + PersistMgr->Transfer(TMEMBER(m_OverheadTime)); + + PersistMgr->Transfer(TMEMBER(m_Border)); + PersistMgr->Transfer(TMEMBER(m_BorderThicknessLeft)); + PersistMgr->Transfer(TMEMBER(m_BorderThicknessRight)); + PersistMgr->Transfer(TMEMBER(m_BorderThicknessTop)); + PersistMgr->Transfer(TMEMBER(m_BorderThicknessBottom)); + + PersistMgr->Transfer(TMEMBER(m_FadeInTime)); + PersistMgr->Transfer(TMEMBER(m_FadeOutTime)); + + PersistMgr->Transfer(TMEMBER(m_Alpha1)); + PersistMgr->Transfer(TMEMBER(m_Alpha2)); + PersistMgr->Transfer(TMEMBER(m_AlphaTimeBased)); + + PersistMgr->Transfer(TMEMBER(m_AngVelocity1)); + PersistMgr->Transfer(TMEMBER(m_AngVelocity2)); + + PersistMgr->Transfer(TMEMBER(m_Rotation1)); + PersistMgr->Transfer(TMEMBER(m_Rotation2)); + + PersistMgr->Transfer(TMEMBER(m_GrowthRate1)); + PersistMgr->Transfer(TMEMBER(m_GrowthRate2)); + PersistMgr->Transfer(TMEMBER(m_ExponentialGrowth)); + + PersistMgr->Transfer(TMEMBER(m_UseRegion)); + + PersistMgr->Transfer(TMEMBER_INT(m_MaxBatches)); + PersistMgr->Transfer(TMEMBER_INT(m_BatchesGenerated)); + + PersistMgr->Transfer(TMEMBER(m_EmitEvent)); + PersistMgr->Transfer(TMEMBER(m_Owner)); + + + m_Sprites.Persist(PersistMgr); + + int NumForces; + if (PersistMgr->m_Saving) { + NumForces = m_Forces.GetSize(); + PersistMgr->Transfer(TMEMBER(NumForces)); + for (int i = 0; i < m_Forces.GetSize(); i++) { + m_Forces[i]->Persist(PersistMgr); + } + } else { + PersistMgr->Transfer(TMEMBER(NumForces)); + for (int i = 0; i < NumForces; i++) { + CPartForce *Force = new CPartForce(Game); + Force->Persist(PersistMgr); + m_Forces.Add(Force); + } + } + + int NumParticles; + if (PersistMgr->m_Saving) { + NumParticles = m_Particles.GetSize(); + PersistMgr->Transfer(TMEMBER(NumParticles)); + for (int i = 0; i < m_Particles.GetSize(); i++) { + m_Particles[i]->Persist(PersistMgr); + } + } else { + PersistMgr->Transfer(TMEMBER(NumParticles)); + for (int i = 0; i < NumParticles; i++) { + CPartParticle *Particle = new CPartParticle(Game); + Particle->Persist(PersistMgr); + m_Particles.Add(Particle); + } + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/PartForce.cpp b/engines/wintermute/PartForce.cpp new file mode 100644 index 0000000000..06f5902ab6 --- /dev/null +++ b/engines/wintermute/PartForce.cpp @@ -0,0 +1,56 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/PartForce.h" +#include "engines/wintermute/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + m_Pos = Vector2(0.0f, 0.0f); + m_Direction = Vector2(0.0f, 0.0f); + m_Type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartForce::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_Name)); + PersistMgr->Transfer(TMEMBER(m_Pos)); + PersistMgr->Transfer(TMEMBER(m_Direction)); + PersistMgr->Transfer(TMEMBER_INT(m_Type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp new file mode 100644 index 0000000000..d1a892645b --- /dev/null +++ b/engines/wintermute/PartParticle.cpp @@ -0,0 +1,252 @@ +/* +This file is part of WME Lite. +http://dead-code.org/redir.php?target=wmelite + +Copyright (c) 2011 Jan Nedoma + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/PartParticle.h" +#include "engines/wintermute/PartEmitter.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + m_Pos = Vector2(0.0f, 0.0f); + m_PosZ = 0.0f; + m_Velocity = Vector2(0.0f, 0.0f); + m_Scale = 100.0f; + m_Sprite = NULL; + m_CreationTime = 0; + m_LifeTime = 0; + m_IsDead = true; + CBPlatform::SetRectEmpty(&m_Border); + + m_State = PARTICLE_NORMAL; + m_FadeStart = 0; + m_FadeTime = 0; + m_CurrentAlpha = 255; + + m_Alpha1 = m_Alpha2 = 255; + + m_Rotation = 0.0f; + m_AngVelocity = 0.0f; + + m_GrowthRate = 0.0f; + m_ExponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete m_Sprite; + m_Sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::SetSprite(char *Filename) { + if (m_Sprite && m_Sprite->m_Filename && scumm_stricmp(Filename, m_Sprite->m_Filename) == 0) { + m_Sprite->Reset(); + return S_OK; + } + + delete m_Sprite; + m_Sprite = NULL; + + CSysClassRegistry::GetInstance()->m_Disabled = true; + m_Sprite = new CBSprite(Game, Game); + if (m_Sprite && SUCCEEDED(m_Sprite->LoadFile(Filename))) { + CSysClassRegistry::GetInstance()->m_Disabled = false; + return S_OK; + } else { + delete m_Sprite; + m_Sprite = NULL; + CSysClassRegistry::GetInstance()->m_Disabled = false; + return E_FAIL; + } + +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { + if (m_State == PARTICLE_FADEIN) { + if (CurrentTime - m_FadeStart >= m_FadeTime) { + m_State = PARTICLE_NORMAL; + m_CurrentAlpha = m_Alpha1; + } else m_CurrentAlpha = ((float)CurrentTime - (float)m_FadeStart) / (float)m_FadeTime * m_Alpha1; + + return S_OK; + } else if (m_State == PARTICLE_FADEOUT) { + if (CurrentTime - m_FadeStart >= m_FadeTime) { + m_IsDead = true; + return S_OK; + } else m_CurrentAlpha = m_FadeStartAlpha - ((float)CurrentTime - (float)m_FadeStart) / (float)m_FadeTime * m_FadeStartAlpha; + + return S_OK; + } else { + // time is up + if (m_LifeTime > 0) { + if (CurrentTime - m_CreationTime >= m_LifeTime) { + if (Emitter->m_FadeOutTime > 0) + FadeOut(CurrentTime, Emitter->m_FadeOutTime); + else + m_IsDead = true; + } + } + + // particle hit the border + if (!m_IsDead && !CBPlatform::IsRectEmpty(&m_Border)) { + POINT p; + p.x = m_Pos.x; + p.y = m_Pos.y; + if (!CBPlatform::PtInRect(&m_Border, p)) FadeOut(CurrentTime, Emitter->m_FadeOutTime); + } + if (m_State != PARTICLE_NORMAL) return S_OK; + + // update alpha + if (m_LifeTime > 0) { + int Age = CurrentTime - m_CreationTime; + int AlphaDelta = m_Alpha2 - m_Alpha1; + + m_CurrentAlpha = m_Alpha1 + ((float)AlphaDelta / (float)m_LifeTime * (float)Age); + } + + // update position + float ElapsedTime = (float)TimerDelta / 1000.f; + + for (int i = 0; i < Emitter->m_Forces.GetSize(); i++) { + CPartForce *Force = Emitter->m_Forces[i]; + switch (Force->m_Type) { + case CPartForce::FORCE_GLOBAL: + m_Velocity += Force->m_Direction * ElapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 VecDist = Force->m_Pos - m_Pos; + float Dist = fabs(VecDist.Length()); + + Dist = 100.0f / Dist; + + m_Velocity += Force->m_Direction * Dist * ElapsedTime; + } + break; + } + } + m_Pos += m_Velocity * ElapsedTime; + + // update rotation + m_Rotation += m_AngVelocity * ElapsedTime; + m_Rotation = CBUtils::NormalizeAngle(m_Rotation); + + // update scale + if (m_ExponentialGrowth) + m_Scale += m_Scale / 100.0f * m_GrowthRate * ElapsedTime; + else + m_Scale += m_GrowthRate * ElapsedTime; + + if (m_Scale <= 0.0f) m_IsDead = true; + + + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Display(CPartEmitter *Emitter) { + if (!m_Sprite) return E_FAIL; + if (m_IsDead) return S_OK; + + m_Sprite->GetCurrentFrame(); + return m_Sprite->Display(m_Pos.x, m_Pos.y, + NULL, + m_Scale, m_Scale, + DRGBA(255, 255, 255, m_CurrentAlpha), + m_Rotation, + Emitter->m_BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { + m_CurrentAlpha = 0; + m_FadeStart = CurrentTime; + m_FadeTime = FadeTime; + m_State = PARTICLE_FADEIN; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { + //m_CurrentAlpha = 255; + m_FadeStartAlpha = m_CurrentAlpha; + m_FadeStart = CurrentTime; + m_FadeTime = FadeTime; + m_State = PARTICLE_FADEOUT; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(m_Alpha1)); + PersistMgr->Transfer(TMEMBER(m_Alpha2)); + PersistMgr->Transfer(TMEMBER(m_Border)); + PersistMgr->Transfer(TMEMBER(m_Pos)); + PersistMgr->Transfer(TMEMBER(m_PosZ)); + PersistMgr->Transfer(TMEMBER(m_Velocity)); + PersistMgr->Transfer(TMEMBER(m_Scale)); + PersistMgr->Transfer(TMEMBER(m_CreationTime)); + PersistMgr->Transfer(TMEMBER(m_LifeTime)); + PersistMgr->Transfer(TMEMBER(m_IsDead)); + PersistMgr->Transfer(TMEMBER_INT(m_State)); + PersistMgr->Transfer(TMEMBER(m_FadeStart)); + PersistMgr->Transfer(TMEMBER(m_FadeTime)); + PersistMgr->Transfer(TMEMBER(m_CurrentAlpha)); + PersistMgr->Transfer(TMEMBER(m_AngVelocity)); + PersistMgr->Transfer(TMEMBER(m_Rotation)); + PersistMgr->Transfer(TMEMBER(m_GrowthRate)); + PersistMgr->Transfer(TMEMBER(m_ExponentialGrowth)); + PersistMgr->Transfer(TMEMBER(m_FadeStartAlpha)); + + if (PersistMgr->m_Saving) { + PersistMgr->Transfer(TMEMBER(m_Sprite->m_Filename)); + } else { + char *Filename; + PersistMgr->Transfer(TMEMBER(Filename)); + CSysClassRegistry::GetInstance()->m_Disabled = true; + SetSprite(Filename); + CSysClassRegistry::GetInstance()->m_Disabled = false; + delete[] Filename; + Filename = NULL; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h index 3987f56798..f3ecb0d645 100644 --- a/engines/wintermute/dcpackage.h +++ b/engines/wintermute/dcpackage.h @@ -33,10 +33,11 @@ THE SOFTWARE. #define PACKAGE_EXTENSION "dcp" #include +#include "common/stream.h" namespace WinterMute { -typedef struct { +struct TPackageHeader { uint32 Magic1; uint32 Magic2; uint32 PackageVersion; @@ -51,7 +52,25 @@ typedef struct { #endif char Desc[100]; uint32 NumDirs; -} TPackageHeader; + // TODO: Move this out of the header. + void readFromStream(Common::ReadStream *stream) { + Magic1 = stream->readUint32LE(); + Magic2 = stream->readUint32LE(); + PackageVersion = stream->readUint32LE(); + + GameVersion = stream->readUint32LE(); + + Priority = stream->readByte(); + CD = stream->readByte(); + MasterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + CreationTime = stream->readUint32LE(); + + stream->read(Desc, 100); + NumDirs = stream->readUint32LE(); + } +}; /* v2: uint32 DirOffset diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index fa7106c801..3dc00b5a33 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -28,6 +28,7 @@ MODULE_OBJS := \ AdRegion.o \ AdResponse.o \ AdResponseBox.o \ + AdResponseContext.o \ AdRotLevel.o \ AdScaleLevel.o \ AdScene.o \ @@ -90,7 +91,11 @@ MODULE_OBJS := \ detection.o \ FontGlyphCache.o \ MathUtil.o \ + Matrix4.o \ PathUtil.o \ + PartParticle.o \ + PartEmitter.o \ + PartForce.o \ PlatformSDL.o \ StringUtil.o \ SysClass.o \ diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 39152acc5d..aa32ad8578 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,8 +31,9 @@ #include "common/fs.h" #include "engines/util.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/ADGame.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { @@ -102,7 +103,8 @@ namespace WinterMute { // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); - CBGame game; + CAdGame *game = new CAdGame; + CBPlatform::Initialize(game, NULL, 0); return Common::kNoError; } -- cgit v1.2.3 From 28c78b956dac6ee59d066f7ff2499569fe9877c7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 28 Apr 2012 01:00:14 +0300 Subject: WINTERMUTE: Mass rename m_FooBar -> _fooBar --- engines/wintermute/AdActor.cpp | 784 ++++----- engines/wintermute/AdActor.h | 46 +- engines/wintermute/AdEntity.cpp | 440 ++--- engines/wintermute/AdEntity.h | 12 +- engines/wintermute/AdGame.cpp | 968 +++++------ engines/wintermute/AdGame.h | 64 +- engines/wintermute/AdInventory.cpp | 36 +- engines/wintermute/AdInventory.h | 4 +- engines/wintermute/AdInventoryBox.cpp | 186 +-- engines/wintermute/AdInventoryBox.h | 22 +- engines/wintermute/AdItem.cpp | 324 ++-- engines/wintermute/AdItem.h | 26 +- engines/wintermute/AdLayer.cpp | 166 +- engines/wintermute/AdLayer.h | 12 +- engines/wintermute/AdNodeState.cpp | 102 +- engines/wintermute/AdNodeState.h | 12 +- engines/wintermute/AdObject.cpp | 674 ++++---- engines/wintermute/AdObject.h | 66 +- engines/wintermute/AdPath.cpp | 38 +- engines/wintermute/AdPath.h | 6 +- engines/wintermute/AdPathPoint.cpp | 20 +- engines/wintermute/AdPathPoint.h | 6 +- engines/wintermute/AdRegion.cpp | 106 +- engines/wintermute/AdRegion.h | 8 +- engines/wintermute/AdResponse.cpp | 90 +- engines/wintermute/AdResponse.h | 16 +- engines/wintermute/AdResponseBox.cpp | 362 ++-- engines/wintermute/AdResponseBox.h | 30 +- engines/wintermute/AdResponseContext.cpp | 20 +- engines/wintermute/AdResponseContext.h | 4 +- engines/wintermute/AdRotLevel.cpp | 20 +- engines/wintermute/AdRotLevel.h | 2 +- engines/wintermute/AdScaleLevel.cpp | 20 +- engines/wintermute/AdScaleLevel.h | 2 +- engines/wintermute/AdScene.cpp | 1308 +++++++-------- engines/wintermute/AdScene.h | 108 +- engines/wintermute/AdSceneNode.cpp | 28 +- engines/wintermute/AdSceneNode.h | 6 +- engines/wintermute/AdSceneState.cpp | 24 +- engines/wintermute/AdSceneState.h | 4 +- engines/wintermute/AdSentence.cpp | 216 +-- engines/wintermute/AdSentence.h | 34 +- engines/wintermute/AdSpriteSet.cpp | 110 +- engines/wintermute/AdSpriteSet.h | 4 +- engines/wintermute/AdTalkDef.cpp | 116 +- engines/wintermute/AdTalkDef.h | 10 +- engines/wintermute/AdTalkHolder.cpp | 158 +- engines/wintermute/AdTalkHolder.h | 6 +- engines/wintermute/AdTalkNode.cpp | 150 +- engines/wintermute/AdTalkNode.h | 18 +- engines/wintermute/AdWaypointGroup.cpp | 80 +- engines/wintermute/AdWaypointGroup.h | 12 +- engines/wintermute/BActiveRect.cpp | 72 +- engines/wintermute/BActiveRect.h | 18 +- engines/wintermute/BBase.cpp | 34 +- engines/wintermute/BBase.h | 10 +- engines/wintermute/BDebugger.cpp | 2 +- engines/wintermute/BDebugger.h | 2 +- engines/wintermute/BDiskFile.cpp | 116 +- engines/wintermute/BDiskFile.h | 8 +- engines/wintermute/BDynBuffer.cpp | 68 +- engines/wintermute/BDynBuffer.h | 14 +- engines/wintermute/BEvent.cpp | 42 +- engines/wintermute/BEvent.h | 6 +- engines/wintermute/BFader.cpp | 114 +- engines/wintermute/BFader.h | 20 +- engines/wintermute/BFile.cpp | 6 +- engines/wintermute/BFile.h | 8 +- engines/wintermute/BFileEntry.cpp | 12 +- engines/wintermute/BFileEntry.h | 18 +- engines/wintermute/BFileManager.cpp | 198 +-- engines/wintermute/BFileManager.h | 14 +- engines/wintermute/BFont.cpp | 10 +- engines/wintermute/BFontBitmap.cpp | 178 +- engines/wintermute/BFontBitmap.h | 18 +- engines/wintermute/BFontStorage.cpp | 52 +- engines/wintermute/BFontStorage.h | 6 +- engines/wintermute/BFontTT.cpp | 300 ++-- engines/wintermute/BFontTT.h | 110 +- engines/wintermute/BFrame.cpp | 262 +-- engines/wintermute/BFrame.h | 18 +- engines/wintermute/BGame.cpp | 2082 ++++++++++++------------ engines/wintermute/BGame.h | 286 ++-- engines/wintermute/BImage.cpp | 30 +- engines/wintermute/BImage.h | 4 +- engines/wintermute/BKeyboardState.cpp | 78 +- engines/wintermute/BKeyboardState.h | 12 +- engines/wintermute/BNamedObject.cpp | 16 +- engines/wintermute/BNamedObject.h | 2 +- engines/wintermute/BObject.cpp | 538 +++--- engines/wintermute/BObject.h | 80 +- engines/wintermute/BPackage.cpp | 30 +- engines/wintermute/BPackage.h | 10 +- engines/wintermute/BParser.cpp | 26 +- engines/wintermute/BParser.h | 6 +- engines/wintermute/BPersistMgr.cpp | 200 +-- engines/wintermute/BPersistMgr.h | 30 +- engines/wintermute/BPkgFile.cpp | 118 +- engines/wintermute/BPkgFile.h | 12 +- engines/wintermute/BQuickMsg.cpp | 10 +- engines/wintermute/BQuickMsg.h | 4 +- engines/wintermute/BRegion.cpp | 154 +- engines/wintermute/BRegion.h | 14 +- engines/wintermute/BRegistry.cpp | 40 +- engines/wintermute/BRegistry.h | 10 +- engines/wintermute/BRenderSDL.cpp | 186 +-- engines/wintermute/BRenderSDL.h | 26 +- engines/wintermute/BRenderer.cpp | 92 +- engines/wintermute/BRenderer.h | 40 +- engines/wintermute/BResourceFile.cpp | 28 +- engines/wintermute/BResourceFile.h | 2 +- engines/wintermute/BResources.cpp | 2 +- engines/wintermute/BSaveThumbFile.cpp | 40 +- engines/wintermute/BSaveThumbFile.h | 2 +- engines/wintermute/BSaveThumbHelper.cpp | 24 +- engines/wintermute/BSaveThumbHelper.h | 4 +- engines/wintermute/BScriptHolder.cpp | 134 +- engines/wintermute/BScriptHolder.h | 8 +- engines/wintermute/BScriptable.cpp | 34 +- engines/wintermute/BScriptable.h | 6 +- engines/wintermute/BSound.cpp | 196 +-- engines/wintermute/BSound.h | 32 +- engines/wintermute/BSoundBuffer.cpp | 156 +- engines/wintermute/BSoundBuffer.h | 24 +- engines/wintermute/BSoundMgr.cpp | 102 +- engines/wintermute/BSoundMgr.h | 14 +- engines/wintermute/BSprite.cpp | 374 ++--- engines/wintermute/BSprite.h | 42 +- engines/wintermute/BStringTable.cpp | 50 +- engines/wintermute/BStringTable.h | 4 +- engines/wintermute/BSubFrame.cpp | 296 ++-- engines/wintermute/BSubFrame.h | 38 +- engines/wintermute/BSurface.cpp | 44 +- engines/wintermute/BSurface.h | 34 +- engines/wintermute/BSurfaceSDL.cpp | 122 +- engines/wintermute/BSurfaceSDL.h | 8 +- engines/wintermute/BSurfaceStorage.cpp | 76 +- engines/wintermute/BSurfaceStorage.h | 4 +- engines/wintermute/BTransitionMgr.cpp | 56 +- engines/wintermute/BTransitionMgr.h | 12 +- engines/wintermute/BViewport.cpp | 30 +- engines/wintermute/BViewport.h | 8 +- engines/wintermute/FontGlyphCache.cpp | 28 +- engines/wintermute/FontGlyphCache.h | 54 +- engines/wintermute/PartEmitter.cpp | 636 ++++---- engines/wintermute/PartEmitter.h | 88 +- engines/wintermute/PartForce.cpp | 14 +- engines/wintermute/PartForce.h | 6 +- engines/wintermute/PartParticle.cpp | 224 +-- engines/wintermute/PartParticle.h | 46 +- engines/wintermute/PlatformSDL.cpp | 62 +- engines/wintermute/SysClass.cpp | 88 +- engines/wintermute/SysClass.h | 30 +- engines/wintermute/SysClassRegistry.cpp | 100 +- engines/wintermute/SysClassRegistry.h | 14 +- engines/wintermute/SysInstance.cpp | 10 +- engines/wintermute/SysInstance.h | 20 +- engines/wintermute/UIButton.cpp | 652 ++++---- engines/wintermute/UIButton.h | 40 +- engines/wintermute/UIEdit.cpp | 464 +++--- engines/wintermute/UIEdit.h | 20 +- engines/wintermute/UIEntity.cpp | 104 +- engines/wintermute/UIEntity.h | 2 +- engines/wintermute/UIObject.cpp | 284 ++-- engines/wintermute/UIObject.h | 36 +- engines/wintermute/UIText.cpp | 174 +- engines/wintermute/UIText.h | 4 +- engines/wintermute/UITiledImage.cpp | 198 +-- engines/wintermute/UITiledImage.h | 20 +- engines/wintermute/UIWindow.cpp | 642 ++++---- engines/wintermute/UIWindow.h | 40 +- engines/wintermute/coll_templ.h | 138 +- engines/wintermute/persistent.h | 6 +- engines/wintermute/scriptables/SXArray.cpp | 80 +- engines/wintermute/scriptables/SXArray.h | 4 +- engines/wintermute/scriptables/SXDate.cpp | 80 +- engines/wintermute/scriptables/SXDate.h | 4 +- engines/wintermute/scriptables/SXFile.cpp | 236 +-- engines/wintermute/scriptables/SXFile.h | 10 +- engines/wintermute/scriptables/SXMath.cpp | 12 +- engines/wintermute/scriptables/SXMemBuffer.cpp | 122 +- engines/wintermute/scriptables/SXMemBuffer.h | 4 +- engines/wintermute/scriptables/SXStore.cpp | 162 +- engines/wintermute/scriptables/SXStore.h | 88 +- engines/wintermute/scriptables/SXString.cpp | 48 +- engines/wintermute/scriptables/ScEngine.cpp | 428 ++--- engines/wintermute/scriptables/ScEngine.h | 68 +- engines/wintermute/scriptables/ScScript.cpp | 1006 ++++++------ engines/wintermute/scriptables/ScScript.h | 80 +- engines/wintermute/scriptables/ScStack.cpp | 78 +- engines/wintermute/scriptables/ScStack.h | 4 +- engines/wintermute/scriptables/ScValue.cpp | 560 +++---- engines/wintermute/scriptables/ScValue.h | 22 +- engines/wintermute/utils.cpp | 2 +- 194 files changed, 11153 insertions(+), 11153 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index 12aa363df1..2c945573ec 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -57,96 +57,96 @@ IMPLEMENT_PERSISTENT(CAdActor, false) ////////////////////////////////////////////////////////////////////////// CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - m_Path = new CAdPath(Game); + _path = new CAdPath(Game); - m_Type = OBJECT_ACTOR; - m_Dir = DI_LEFT; + _type = OBJECT_ACTOR; + _dir = DI_LEFT; - m_WalkSprite = NULL; - m_StandSprite = NULL; - m_TurnLeftSprite = NULL; - m_TurnRightSprite = NULL; + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; - m_TargetPoint = new CBPoint; - m_AfterWalkDir = DI_NONE; + _targetPoint = new CBPoint; + _afterWalkDir = DI_NONE; - m_AnimSprite2 = NULL; + _animSprite2 = NULL; SetDefaultAnimNames(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::SetDefaultAnimNames() { - m_TalkAnimName = NULL; - CBUtils::SetString(&m_TalkAnimName, "talk"); + _talkAnimName = NULL; + CBUtils::SetString(&_talkAnimName, "talk"); - m_IdleAnimName = NULL; - CBUtils::SetString(&m_IdleAnimName, "idle"); + _idleAnimName = NULL; + CBUtils::SetString(&_idleAnimName, "idle"); - m_WalkAnimName = NULL; - CBUtils::SetString(&m_WalkAnimName, "walk"); + _walkAnimName = NULL; + CBUtils::SetString(&_walkAnimName, "walk"); - m_TurnLeftAnimName = NULL; - CBUtils::SetString(&m_TurnLeftAnimName, "turnleft"); + _turnLeftAnimName = NULL; + CBUtils::SetString(&_turnLeftAnimName, "turnleft"); - m_TurnRightAnimName = NULL; - CBUtils::SetString(&m_TurnRightAnimName, "turnright"); + _turnRightAnimName = NULL; + CBUtils::SetString(&_turnRightAnimName, "turnright"); return S_OK; } ////////////////////////////////////////////////////////////////////////// CAdActor::~CAdActor() { - delete m_Path; - delete m_TargetPoint; - m_Path = NULL; - m_TargetPoint = NULL; - - delete m_WalkSprite; - delete m_StandSprite; - delete m_TurnLeftSprite; - delete m_TurnRightSprite; - m_WalkSprite = NULL; - m_StandSprite = NULL; - m_TurnLeftSprite = NULL; - m_TurnRightSprite = NULL; - - m_AnimSprite2 = NULL; // ref only - - for (int i = 0; i < m_TalkSprites.GetSize(); i++) { - delete m_TalkSprites[i]; + delete _path; + delete _targetPoint; + _path = NULL; + _targetPoint = NULL; + + delete _walkSprite; + delete _standSprite; + delete _turnLeftSprite; + delete _turnRightSprite; + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _animSprite2 = NULL; // ref only + + for (int i = 0; i < _talkSprites.GetSize(); i++) { + delete _talkSprites[i]; } - m_TalkSprites.RemoveAll(); + _talkSprites.RemoveAll(); - for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - delete m_TalkSpritesEx[i]; + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + delete _talkSpritesEx[i]; } - m_TalkSpritesEx.RemoveAll(); - - - delete[] m_TalkAnimName; - delete[] m_IdleAnimName; - delete[] m_WalkAnimName; - delete[] m_TurnLeftAnimName; - delete[] m_TurnRightAnimName; - m_TalkAnimName = NULL; - m_IdleAnimName = NULL; - m_WalkAnimName = NULL; - m_TurnLeftAnimName = NULL; - m_TurnRightAnimName = NULL; - - for (int i = 0; i < m_Anims.GetSize(); i++) { - delete m_Anims[i]; - m_Anims[i] = NULL; + _talkSpritesEx.RemoveAll(); + + + delete[] _talkAnimName; + delete[] _idleAnimName; + delete[] _walkAnimName; + delete[] _turnLeftAnimName; + delete[] _turnRightAnimName; + _talkAnimName = NULL; + _idleAnimName = NULL; + _walkAnimName = NULL; + _turnLeftAnimName = NULL; + _turnRightAnimName = NULL; + + for (int i = 0; i < _anims.GetSize(); i++) { + delete _anims[i]; + _anims[i] = NULL; } - m_Anims.RemoveAll(); + _anims.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -154,8 +154,8 @@ HRESULT CAdActor::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); @@ -267,11 +267,11 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_NAME: @@ -287,70 +287,70 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &m_Zoomable); + parser.ScanStr((char *)params, "%b", &_zoomable); break; case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &m_Rotatable); + parser.ScanStr((char *)params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &m_Registrable); + parser.ScanStr((char *)params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &m_Shadowable); + parser.ScanStr((char *)params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &m_Active); + parser.ScanStr((char *)params, "%b", &_active); break; case TOKEN_WALK: - delete m_WalkSprite; - m_WalkSprite = NULL; + delete _walkSprite; + _walkSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; - else m_WalkSprite = spr; + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + else _walkSprite = spr; break; case TOKEN_TALK: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSprites.Add(spr); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); break; case TOKEN_TALK_SPECIAL: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSpritesEx.Add(spr); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); break; case TOKEN_STAND: - delete m_StandSprite; - m_StandSprite = NULL; + delete _standSprite; + _standSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->m_TexStandLifeTime))) cmd = PARSERR_GENERIC; - else m_StandSprite = spr; + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + else _standSprite = spr; break; case TOKEN_TURN_LEFT: - delete m_TurnLeftSprite; - m_TurnLeftSprite = NULL; + delete _turnLeftSprite; + _turnLeftSprite = NULL; spr = new CAdSpriteSet(Game, this); if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; - else m_TurnLeftSprite = spr; + else _turnLeftSprite = spr; break; case TOKEN_TURN_RIGHT: - delete m_TurnRightSprite; - m_TurnRightSprite = NULL; + delete _turnRightSprite; + _turnRightSprite = NULL; spr = new CAdSpriteSet(Game, this); if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; - else m_TurnRightSprite = spr; + else _turnRightSprite = spr; break; case TOKEN_SCRIPT: @@ -358,23 +358,23 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &m_SFXVolume); + parser.ScanStr((char *)params, "%d", &_sFXVolume); break; case TOKEN_SCALE: { int s; parser.ScanStr((char *)params, "%d", &s); - m_Scale = (float)s; + _scale = (float)s; } break; @@ -382,13 +382,13 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_RELATIVE_SCALE: { int s; parser.ScanStr((char *)params, "%d", &s); - m_RelativeScale = (float)s; + _relativeScale = (float)s; } break; case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &m_AutoSoundPanning); + parser.ScanStr((char *)params, "%b", &_autoSoundPanning); break; case TOKEN_PROPERTY: @@ -396,49 +396,49 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BLOCKED_REGION: { - delete m_BlockRegion; - delete m_CurrentBlockRegion; - m_BlockRegion = NULL; - m_CurrentBlockRegion = NULL; + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { - delete m_BlockRegion; - delete m_CurrentBlockRegion; - m_BlockRegion = NULL; - m_CurrentBlockRegion = NULL; + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; cmd = PARSERR_GENERIC; } else { - m_BlockRegion = rgn; - m_CurrentBlockRegion = crgn; - m_CurrentBlockRegion->Mimic(m_BlockRegion); + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->Mimic(_blockRegion); } } break; case TOKEN_WAYPOINTS: { - delete m_WptGroup; - delete m_CurrentWptGroup; - m_WptGroup = NULL; - m_CurrentWptGroup = NULL; + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { - delete m_WptGroup; - delete m_CurrentWptGroup; - m_WptGroup = NULL; - m_CurrentWptGroup = NULL; + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; cmd = PARSERR_GENERIC; } else { - m_WptGroup = wpt; - m_CurrentWptGroup = cwpt; - m_CurrentWptGroup->Mimic(m_WptGroup); + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->Mimic(_wptGroup); } } break; case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &m_IgnoreItems); + parser.ScanStr((char *)params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: @@ -456,7 +456,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); if (!Anim || FAILED(Anim->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; - else m_Anims.Add(Anim); + else _anims.Add(Anim); } break; } @@ -474,8 +474,8 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - m_AlphaColor = DRGBA(ar, ag, ab, alpha); - m_State = m_NextState = STATE_READY; + _alphaColor = DRGBA(ar, ag, ab, alpha); + _state = _nextState = STATE_READY; return S_OK; } @@ -485,83 +485,83 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { void CAdActor::TurnTo(TDirection dir) { int delta1, delta2, delta3, delta; - delta1 = dir - m_Dir; - delta2 = dir + NUM_DIRECTIONS - m_Dir; - delta3 = dir - NUM_DIRECTIONS - m_Dir; + delta1 = dir - _dir; + delta2 = dir + NUM_DIRECTIONS - _dir; + delta3 = dir - NUM_DIRECTIONS - _dir; delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; // already there? if (abs(delta) < 2) { - m_Dir = dir; - m_State = m_NextState; - m_NextState = STATE_READY; + _dir = dir; + _state = _nextState; + _nextState = STATE_READY; return; } - m_TargetDir = dir; - m_State = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; + _targetDir = dir; + _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; - m_TempSprite2 = NULL; + _tempSprite2 = NULL; } ////////////////////////////////////////////////////////////////////////// void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { - m_AfterWalkDir = AfterWalkDir; - if (X == m_TargetPoint->x && Y == m_TargetPoint->y && m_State == STATE_FOLLOWING_PATH) return; + _afterWalkDir = AfterWalkDir; + if (X == _targetPoint->x && Y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; - m_Path->Reset(); - m_Path->SetReady(false); + _path->Reset(); + _path->SetReady(false); - m_TargetPoint->x = X; - m_TargetPoint->y = Y; + _targetPoint->x = X; + _targetPoint->y = Y; - ((CAdGame *)Game)->m_Scene->CorrectTargetPoint(m_PosX, m_PosY, &m_TargetPoint->x, &m_TargetPoint->y, true, this); + ((CAdGame *)Game)->_scene->CorrectTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); - m_State = STATE_SEARCHING_PATH; + _state = STATE_SEARCHING_PATH; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::Display() { - if (m_Active) UpdateSounds(); + if (_active) UpdateSounds(); uint32 Alpha; - if (m_AlphaColor != 0) Alpha = m_AlphaColor; - else Alpha = m_Shadowable ? ((CAdGame *)Game)->m_Scene->GetAlphaAt(m_PosX, m_PosY, true) : 0xFFFFFFFF; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); float Rotate; - if (m_Rotatable) { - if (m_RotateValid) Rotate = m_Rotate; - else Rotate = ((CAdGame *)Game)->m_Scene->GetRotationAt(m_PosX, m_PosY) + m_RelativeRotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; - if (m_Active) DisplaySpriteAttachments(true); + if (_active) DisplaySpriteAttachments(true); - if (m_CurrentSprite && m_Active) { - bool Reg = m_Registrable; - if (m_IgnoreItems && ((CAdGame *)Game)->m_SelectedItem) Reg = false; + if (_currentSprite && _active) { + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; - m_CurrentSprite->Display(m_PosX, - m_PosY, - Reg ? m_RegisterAlias : NULL, + _currentSprite->Display(_posX, + _posY, + Reg ? _registerAlias : NULL, ScaleX, ScaleY, Alpha, Rotate, - m_BlendMode); + _blendMode); } - if (m_Active) DisplaySpriteAttachments(false); - if (m_Active && m_PartEmitter) m_PartEmitter->Display(); + if (_active) DisplaySpriteAttachments(false); + if (_active && _partEmitter) _partEmitter->Display(); return S_OK; @@ -570,128 +570,128 @@ HRESULT CAdActor::Display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::Update() { - m_CurrentSprite = NULL; + _currentSprite = NULL; - if (m_State == STATE_READY) { - if (m_AnimSprite) { - delete m_AnimSprite; - m_AnimSprite = NULL; + if (_state == STATE_READY) { + if (_animSprite) { + delete _animSprite; + _animSprite = NULL; } - if (m_AnimSprite2) { - m_AnimSprite2 = NULL; + if (_animSprite2) { + _animSprite2 = NULL; } } // finished playing animation? - if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { - m_State = m_NextState; - m_NextState = STATE_READY; - m_CurrentSprite = m_AnimSprite; + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite; } - if (m_State == STATE_PLAYING_ANIM_SET && m_AnimSprite2 != NULL && m_AnimSprite2->m_Finished) { - m_State = m_NextState; - m_NextState = STATE_READY; - m_CurrentSprite = m_AnimSprite2; + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite2; } - if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); // default: stand animation - if (!m_CurrentSprite) { - if (m_Sprite) m_CurrentSprite = m_Sprite; + if (!_currentSprite) { + if (_sprite) _currentSprite = _sprite; else { - if (m_StandSprite) { - m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + if (_standSprite) { + _currentSprite = _standSprite->GetSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); - if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); } } } bool already_moved = false; - switch (m_State) { + switch (_state) { ////////////////////////////////////////////////////////////////////////// case STATE_PLAYING_ANIM: - m_CurrentSprite = m_AnimSprite; + _currentSprite = _animSprite; break; ////////////////////////////////////////////////////////////////////////// case STATE_PLAYING_ANIM_SET: - m_CurrentSprite = m_AnimSprite2; + _currentSprite = _animSprite2; break; ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_LEFT: - if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished) { - if (m_Dir > 0) m_Dir = (TDirection)(m_Dir - 1); - else m_Dir = (TDirection)(NUM_DIRECTIONS - 1); - - if (m_Dir == m_TargetDir) { - m_TempSprite2 = NULL; - m_State = m_NextState; - m_NextState = STATE_READY; + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_dir > 0) _dir = (TDirection)(_dir - 1); + else _dir = (TDirection)(NUM_DIRECTIONS - 1); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; } else { - if (m_TurnLeftSprite) { - m_TempSprite2 = m_TurnLeftSprite->GetSprite(m_Dir); + if (_turnLeftSprite) { + _tempSprite2 = _turnLeftSprite->GetSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(m_TurnLeftAnimName); - if (Anim) m_TempSprite2 = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_turnLeftAnimName); + if (Anim) _tempSprite2 = Anim->GetSprite(_dir); } - if (m_TempSprite2) { - m_TempSprite2->Reset(); - if (m_TempSprite2->m_Looping) m_TempSprite2->m_Looping = false; + if (_tempSprite2) { + _tempSprite2->Reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; } - m_CurrentSprite = m_TempSprite2; + _currentSprite = _tempSprite2; } - } else m_CurrentSprite = m_TempSprite2; + } else _currentSprite = _tempSprite2; break; ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_RIGHT: - if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished) { - m_Dir = (TDirection)(m_Dir + 1); + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + _dir = (TDirection)(_dir + 1); - if ((int)m_Dir >= (int)NUM_DIRECTIONS) m_Dir = (TDirection)(0); + if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); - if (m_Dir == m_TargetDir) { - m_TempSprite2 = NULL; - m_State = m_NextState; - m_NextState = STATE_READY; + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; } else { - if (m_TurnRightSprite) { - m_TempSprite2 = m_TurnRightSprite->GetSprite(m_Dir); + if (_turnRightSprite) { + _tempSprite2 = _turnRightSprite->GetSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(m_TurnRightAnimName); - if (Anim) m_TempSprite2 = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_turnRightAnimName); + if (Anim) _tempSprite2 = Anim->GetSprite(_dir); } - if (m_TempSprite2) { - m_TempSprite2->Reset(); - if (m_TempSprite2->m_Looping) m_TempSprite2->m_Looping = false; + if (_tempSprite2) { + _tempSprite2->Reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; } - m_CurrentSprite = m_TempSprite2; + _currentSprite = _tempSprite2; } - } else m_CurrentSprite = m_TempSprite2; + } else _currentSprite = _tempSprite2; break; ////////////////////////////////////////////////////////////////////////// case STATE_SEARCHING_PATH: // keep asking scene for the path - if (((CAdGame *)Game)->m_Scene->GetPath(CBPoint(m_PosX, m_PosY), *m_TargetPoint, m_Path, this)) - m_State = STATE_WAITING_PATH; + if (((CAdGame *)Game)->_scene->GetPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + _state = STATE_WAITING_PATH; break; ////////////////////////////////////////////////////////////////////////// case STATE_WAITING_PATH: // wait until the scene finished the path - if (m_Path->m_Ready) FollowPath(); + if (_path->_ready) FollowPath(); break; @@ -703,41 +703,41 @@ HRESULT CAdActor::Update() { ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - m_Sentence->Update(m_Dir); - if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + _sentence->Update(_dir); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); - if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - m_Sentence->Finish(); - m_TempSprite2 = NULL; - m_State = m_NextState; - m_NextState = STATE_READY; + _sentence->Finish(); + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; } else { - m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); - if (m_TempSprite2) { - m_TempSprite2->Reset(); - m_CurrentSprite = m_TempSprite2; - ((CAdGame *)Game)->AddSentence(m_Sentence); + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); } } } else { - m_CurrentSprite = m_TempSprite2; - ((CAdGame *)Game)->AddSentence(m_Sentence); + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); } } break; ////////////////////////////////////////////////////////////////////////// case STATE_READY: - if (!m_AnimSprite && !m_AnimSprite2) { - if (m_Sprite) m_CurrentSprite = m_Sprite; + if (!_animSprite && !_animSprite2) { + if (_sprite) _currentSprite = _sprite; else { - if (m_StandSprite) { - m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + if (_standSprite) { + _currentSprite = _standSprite->GetSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); - if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); } } } @@ -745,19 +745,19 @@ HRESULT CAdActor::Update() { } - if (m_CurrentSprite && !already_moved) { - m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100, m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); - if (m_CurrentSprite->m_Changed) { - m_PosX += m_CurrentSprite->m_MoveX; - m_PosY += m_CurrentSprite->m_MoveY; + if (_currentSprite && !already_moved) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; AfterMove(); } } - //Game->QuickMessageForm("%s", m_CurrentSprite->m_Filename); + //Game->QuickMessageForm("%s", _currentSprite->_filename); UpdateBlockRegion(); - m_Ready = (m_State == STATE_READY); + _ready = (_state == STATE_READY); UpdatePartEmitter(); UpdateSpriteAttachments(); @@ -769,99 +769,99 @@ HRESULT CAdActor::Update() { ////////////////////////////////////////////////////////////////////////// void CAdActor::FollowPath() { // skip current position - m_Path->GetFirst(); - while (m_Path->GetCurrent() != NULL) { - if (m_Path->GetCurrent()->x != m_PosX || m_Path->GetCurrent()->y != m_PosY) break; - m_Path->GetNext(); + _path->GetFirst(); + while (_path->GetCurrent() != NULL) { + if (_path->GetCurrent()->x != _posX || _path->GetCurrent()->y != _posY) break; + _path->GetNext(); } // are there points to follow? - if (m_Path->GetCurrent() != NULL) { - m_State = STATE_FOLLOWING_PATH;; - InitLine(CBPoint(m_PosX, m_PosY), *m_Path->GetCurrent()); + if (_path->GetCurrent() != NULL) { + _state = STATE_FOLLOWING_PATH;; + InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); } else { - if (m_AfterWalkDir != DI_NONE) TurnTo(m_AfterWalkDir); - else m_State = STATE_READY; + if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); + else _state = STATE_READY; } } ////////////////////////////////////////////////////////////////////////// void CAdActor::GetNextStep() { - if (m_WalkSprite) { - m_CurrentSprite = m_WalkSprite->GetSprite(m_Dir); + if (_walkSprite) { + _currentSprite = _walkSprite->GetSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(m_WalkAnimName); - if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_walkAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); } - if (!m_CurrentSprite) return; + if (!_currentSprite) return; - m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100, m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); - if (!m_CurrentSprite->m_Changed) return; + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (!_currentSprite->_changed) return; int MaxStepX, MaxStepY; - MaxStepX = abs(m_CurrentSprite->m_MoveX); - MaxStepY = abs(m_CurrentSprite->m_MoveY); + MaxStepX = abs(_currentSprite->_moveX); + MaxStepY = abs(_currentSprite->_moveY); MaxStepX = std::max(MaxStepX, MaxStepY); MaxStepX = std::max(MaxStepX, 1); - while (m_PFCount > 0 && MaxStepX >= 0) { - m_PFX += m_PFStepX; - m_PFY += m_PFStepY; + while (_pFCount > 0 && MaxStepX >= 0) { + _pFX += _pFStepX; + _pFY += _pFStepY; - m_PFCount--; + _pFCount--; MaxStepX--; } - if (((CAdGame *)Game)->m_Scene->IsBlockedAt(m_PFX, m_PFY, true, this)) { - if (m_PFCount == 0) { - m_State = m_NextState; - m_NextState = STATE_READY; + if (((CAdGame *)Game)->_scene->IsBlockedAt(_pFX, _pFY, true, this)) { + if (_pFCount == 0) { + _state = _nextState; + _nextState = STATE_READY; return; } - GoTo(m_TargetPoint->x, m_TargetPoint->y); + GoTo(_targetPoint->x, _targetPoint->y); return; } - m_PosX = (int)m_PFX; - m_PosY = (int)m_PFY; + _posX = (int)_pFX; + _posY = (int)_pFY; AfterMove(); - if (m_PFCount == 0) { - if (m_Path->GetNext() == NULL) { - m_PosX = m_TargetPoint->x; - m_PosY = m_TargetPoint->y; + if (_pFCount == 0) { + if (_path->GetNext() == NULL) { + _posX = _targetPoint->x; + _posY = _targetPoint->y; - m_Path->Reset(); - if (m_AfterWalkDir != DI_NONE) TurnTo(m_AfterWalkDir); + _path->Reset(); + if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); else { - m_State = m_NextState; - m_NextState = STATE_READY; + _state = _nextState; + _nextState = STATE_READY; } - } else InitLine(CBPoint(m_PosX, m_PosY), *m_Path->GetCurrent()); + } else InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); } } ////////////////////////////////////////////////////////////////////////// void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { - m_PFCount = std::max((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); + _pFCount = std::max((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); - m_PFStepX = (double)(EndPt.x - StartPt.x) / m_PFCount; - m_PFStepY = (double)(EndPt.y - StartPt.y) / m_PFCount; + _pFStepX = (double)(EndPt.x - StartPt.x) / _pFCount; + _pFStepY = (double)(EndPt.y - StartPt.y) / _pFCount; - m_PFX = StartPt.x; - m_PFY = StartPt.y; + _pFX = StartPt.x; + _pFY = StartPt.y; int angle = (int)(atan2((double)(EndPt.y - StartPt.y), (double)(EndPt.x - StartPt.x)) * (180 / 3.14)); - m_NextState = STATE_FOLLOWING_PATH; + _nextState = STATE_FOLLOWING_PATH; TurnTo(AngleToDirection(angle)); } @@ -896,14 +896,14 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } CAdObject *Obj = (CAdObject *)Val->GetNative(); - if (!Obj || Obj->m_Type != OBJECT_ENTITY) { + if (!Obj || Obj->_type != OBJECT_ENTITY) { Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); Stack->PushNULL(); return S_OK; } CAdEntity *Ent = (CAdEntity *)Obj; - if (Ent->m_WalkToX == 0 && Ent->m_WalkToY == 0) GoTo(Ent->m_PosX, Ent->m_PosY); - else GoTo(Ent->m_WalkToX, Ent->m_WalkToY, Ent->m_WalkToDir); + if (Ent->_walkToX == 0 && Ent->_walkToY == 0) GoTo(Ent->_posX, Ent->_posY); + else GoTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); if (strcmp(Name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); Stack->PushNULL(); return S_OK; @@ -920,7 +920,7 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // turn to object? if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { CBObject *obj = (CBObject *)val->GetNative(); - int angle = (int)(atan2((double)(obj->m_PosY - m_PosY), (double)(obj->m_PosX - m_PosX)) * (180 / 3.14)); + int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); dir = (int)AngleToDirection(angle); } // otherwise turn to direction @@ -939,7 +939,7 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsWalking") == 0) { Stack->CorrectParams(0); - Stack->PushBool(m_State == STATE_FOLLOWING_PATH); + Stack->PushBool(_state == STATE_FOLLOWING_PATH); return S_OK; } @@ -960,16 +960,16 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi char *AnimName = Stack->Pop()->GetString(); bool Found = false; - for (int i = 0; i < m_Anims.GetSize(); i++) { - if (scumm_stricmp(m_Anims[i]->m_Name, AnimName) == 0) { + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { // invalidate sprites in use - if (m_Anims[i]->ContainsSprite(m_TempSprite2)) m_TempSprite2 = NULL; - if (m_Anims[i]->ContainsSprite(m_CurrentSprite)) m_CurrentSprite = NULL; - if (m_Anims[i]->ContainsSprite(m_AnimSprite2)) m_AnimSprite2 = NULL; + if (_anims[i]->ContainsSprite(_tempSprite2)) _tempSprite2 = NULL; + if (_anims[i]->ContainsSprite(_currentSprite)) _currentSprite = NULL; + if (_anims[i]->ContainsSprite(_animSprite2)) _animSprite2 = NULL; - delete m_Anims[i]; - m_Anims[i] = NULL; - m_Anims.RemoveAt(i); + delete _anims[i]; + _anims[i] = NULL; + _anims.RemoveAt(i); i--; Found = true; } @@ -994,60 +994,60 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdActor::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Direction") == 0) { - m_ScValue->SetInt(m_Dir); - return m_ScValue; + _scValue->SetInt(_dir); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("actor"); - return m_ScValue; + _scValue->SetString("actor"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TalkAnimName") == 0) { - m_ScValue->SetString(m_TalkAnimName); - return m_ScValue; + _scValue->SetString(_talkAnimName); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkAnimName") == 0) { - m_ScValue->SetString(m_WalkAnimName); - return m_ScValue; + _scValue->SetString(_walkAnimName); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IdleAnimName") == 0) { - m_ScValue->SetString(m_IdleAnimName); - return m_ScValue; + _scValue->SetString(_idleAnimName); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnLeftAnimName") == 0) { - m_ScValue->SetString(m_TurnLeftAnimName); - return m_ScValue; + _scValue->SetString(_turnLeftAnimName); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnRightAnimName") == 0) { - m_ScValue->SetString(m_TurnRightAnimName); - return m_ScValue; + _scValue->SetString(_turnRightAnimName); + return _scValue; } else return CAdTalkHolder::ScGetProperty(Name); @@ -1061,7 +1061,7 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Direction") == 0) { int dir = Value->GetInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) m_Dir = (TDirection)dir; + if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; return S_OK; } @@ -1069,8 +1069,8 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&m_TalkAnimName, "talk"); - else CBUtils::SetString(&m_TalkAnimName, Value->GetString()); + if (Value->IsNULL()) CBUtils::SetString(&_talkAnimName, "talk"); + else CBUtils::SetString(&_talkAnimName, Value->GetString()); return S_OK; } @@ -1078,8 +1078,8 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&m_WalkAnimName, "walk"); - else CBUtils::SetString(&m_WalkAnimName, Value->GetString()); + if (Value->IsNULL()) CBUtils::SetString(&_walkAnimName, "walk"); + else CBUtils::SetString(&_walkAnimName, Value->GetString()); return S_OK; } @@ -1087,8 +1087,8 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IdleAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&m_IdleAnimName, "idle"); - else CBUtils::SetString(&m_IdleAnimName, Value->GetString()); + if (Value->IsNULL()) CBUtils::SetString(&_idleAnimName, "idle"); + else CBUtils::SetString(&_idleAnimName, Value->GetString()); return S_OK; } @@ -1096,8 +1096,8 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnLeftAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&m_TurnLeftAnimName, "turnleft"); - else CBUtils::SetString(&m_TurnLeftAnimName, Value->GetString()); + if (Value->IsNULL()) CBUtils::SetString(&_turnLeftAnimName, "turnleft"); + else CBUtils::SetString(&_turnLeftAnimName, Value->GetString()); return S_OK; } @@ -1105,8 +1105,8 @@ HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnRightAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&m_TurnRightAnimName, "turnright"); - else CBUtils::SetString(&m_TurnRightAnimName, Value->GetString()); + if (Value->IsNULL()) CBUtils::SetString(&_turnRightAnimName, "turnright"); + else CBUtils::SetString(&_turnRightAnimName, Value->GetString()); return S_OK; } @@ -1123,22 +1123,22 @@ char *CAdActor::ScToString() { ////////////////////////////////////////////////////////////////////////// CBSprite *CAdActor::GetTalkStance(char *Stance) { // forced stance? - if (m_ForcedTalkAnimName && !m_ForcedTalkAnimUsed) { - m_ForcedTalkAnimUsed = true; - delete m_AnimSprite; - m_AnimSprite = new CBSprite(Game, this); - if (m_AnimSprite) { - HRESULT res = m_AnimSprite->LoadFile(m_ForcedTalkAnimName); + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(Game, this); + if (_animSprite) { + HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); if (FAILED(res)) { - Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", m_Name, m_ForcedTalkAnimName); - delete m_AnimSprite; - m_AnimSprite = NULL; - } else return m_AnimSprite; + Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; } } // old way - if (m_TalkSprites.GetSize() > 0 || m_TalkSpritesEx.GetSize() > 0) + if (_talkSprites.GetSize() > 0 || _talkSpritesEx.GetSize() > 0) return GetTalkStanceOld(Stance); // new way @@ -1146,24 +1146,24 @@ CBSprite *CAdActor::GetTalkStance(char *Stance) { // do we have an animation with this name? CAdSpriteSet *Anim = GetAnimByName(Stance); - if (Anim) Ret = Anim->GetSprite(m_Dir); + if (Anim) Ret = Anim->GetSprite(_dir); // not - get a random talk if (!Ret) { CBArray TalkAnims; - for (int i = 0; i < m_Anims.GetSize(); i++) { - if (scumm_stricmp(m_Anims[i]->m_Name, m_TalkAnimName) == 0) - TalkAnims.Add(m_Anims[i]); + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, _talkAnimName) == 0) + TalkAnims.Add(_anims[i]); } if (TalkAnims.GetSize() > 0) { int rnd = rand() % TalkAnims.GetSize(); - Ret = TalkAnims[rnd]->GetSprite(m_Dir); + Ret = TalkAnims[rnd]->GetSprite(_dir); } else { - if (m_StandSprite) Ret = m_StandSprite->GetSprite(m_Dir); + if (_standSprite) Ret = _standSprite->GetSprite(_dir); else { - Anim = GetAnimByName(m_IdleAnimName); - if (Anim) Ret = Anim->GetSprite(m_Dir); + Anim = GetAnimByName(_idleAnimName); + if (Anim) Ret = Anim->GetSprite(_dir); } } } @@ -1176,17 +1176,17 @@ CBSprite *CAdActor::GetTalkStanceOld(char *Stance) { if (Stance != NULL) { // search special stances - for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(m_TalkSpritesEx[i]->m_Name, Stance) == 0) { - ret = m_TalkSpritesEx[i]->GetSprite(m_Dir); + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + ret = _talkSpritesEx[i]->GetSprite(_dir); break; } } if (ret == NULL) { // search generic stances - for (int i = 0; i < m_TalkSprites.GetSize(); i++) { - if (scumm_stricmp(m_TalkSprites[i]->m_Name, Stance) == 0) { - ret = m_TalkSprites[i]->GetSprite(m_Dir); + for (int i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + ret = _talkSprites[i]->GetSprite(_dir); break; } } @@ -1195,11 +1195,11 @@ CBSprite *CAdActor::GetTalkStanceOld(char *Stance) { // not a valid stance? get a random one if (ret == NULL) { - if (m_TalkSprites.GetSize() < 1) ret = m_StandSprite->GetSprite(m_Dir); + if (_talkSprites.GetSize() < 1) ret = _standSprite->GetSprite(_dir); else { // TODO: remember last - int rnd = rand() % m_TalkSprites.GetSize(); - ret = m_TalkSprites[rnd]->GetSprite(m_Dir); + int rnd = rand() % _talkSprites.GetSize(); + ret = _talkSprites[rnd]->GetSprite(_dir); } } @@ -1210,31 +1210,31 @@ CBSprite *CAdActor::GetTalkStanceOld(char *Stance) { HRESULT CAdActor::Persist(CBPersistMgr *PersistMgr) { CAdTalkHolder::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(m_Dir)); - PersistMgr->Transfer(TMEMBER(m_Path)); - PersistMgr->Transfer(TMEMBER(m_PFCount)); - PersistMgr->Transfer(TMEMBER(m_PFStepX)); - PersistMgr->Transfer(TMEMBER(m_PFStepY)); - PersistMgr->Transfer(TMEMBER(m_PFX)); - PersistMgr->Transfer(TMEMBER(m_PFY)); - PersistMgr->Transfer(TMEMBER(m_StandSprite)); - m_TalkSprites.Persist(PersistMgr); - m_TalkSpritesEx.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(m_TargetDir)); - PersistMgr->Transfer(TMEMBER_INT(m_AfterWalkDir)); - PersistMgr->Transfer(TMEMBER(m_TargetPoint)); - PersistMgr->Transfer(TMEMBER(m_TurnLeftSprite)); - PersistMgr->Transfer(TMEMBER(m_TurnRightSprite)); - PersistMgr->Transfer(TMEMBER(m_WalkSprite)); - - PersistMgr->Transfer(TMEMBER(m_AnimSprite2)); - PersistMgr->Transfer(TMEMBER(m_TalkAnimName)); - PersistMgr->Transfer(TMEMBER(m_IdleAnimName)); - PersistMgr->Transfer(TMEMBER(m_WalkAnimName)); - PersistMgr->Transfer(TMEMBER(m_TurnLeftAnimName)); - PersistMgr->Transfer(TMEMBER(m_TurnRightAnimName)); - - m_Anims.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(_dir)); + PersistMgr->Transfer(TMEMBER(_path)); + PersistMgr->Transfer(TMEMBER(_pFCount)); + PersistMgr->Transfer(TMEMBER(_pFStepX)); + PersistMgr->Transfer(TMEMBER(_pFStepY)); + PersistMgr->Transfer(TMEMBER(_pFX)); + PersistMgr->Transfer(TMEMBER(_pFY)); + PersistMgr->Transfer(TMEMBER(_standSprite)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(_targetDir)); + PersistMgr->Transfer(TMEMBER_INT(_afterWalkDir)); + PersistMgr->Transfer(TMEMBER(_targetPoint)); + PersistMgr->Transfer(TMEMBER(_turnLeftSprite)); + PersistMgr->Transfer(TMEMBER(_turnRightSprite)); + PersistMgr->Transfer(TMEMBER(_walkSprite)); + + PersistMgr->Transfer(TMEMBER(_animSprite2)); + PersistMgr->Transfer(TMEMBER(_talkAnimName)); + PersistMgr->Transfer(TMEMBER(_idleAnimName)); + PersistMgr->Transfer(TMEMBER(_walkAnimName)); + PersistMgr->Transfer(TMEMBER(_turnLeftAnimName)); + PersistMgr->Transfer(TMEMBER(_turnRightAnimName)); + + _anims.Persist(PersistMgr); return S_OK; } @@ -1260,11 +1260,11 @@ TDirection CAdActor::AngleToDirection(int Angle) { ////////////////////////////////////////////////////////////////////////// int CAdActor::GetHeight() { // if no current sprite is set, set some - if (m_CurrentSprite == NULL) { - if (m_StandSprite) m_CurrentSprite = m_StandSprite->GetSprite(m_Dir); + if (_currentSprite == NULL) { + if (_standSprite) _currentSprite = _standSprite->GetSprite(_dir); else { - CAdSpriteSet *Anim = GetAnimByName(m_IdleAnimName); - if (Anim) m_CurrentSprite = Anim->GetSprite(m_Dir); + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); } } // and get height @@ -1276,8 +1276,8 @@ int CAdActor::GetHeight() { CAdSpriteSet *CAdActor::GetAnimByName(char *AnimName) { if (!AnimName) return NULL; - for (int i = 0; i < m_Anims.GetSize(); i++) { - if (scumm_stricmp(m_Anims[i]->m_Name, AnimName) == 0) return m_Anims[i]; + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) return _anims[i]; } return NULL; } @@ -1289,7 +1289,7 @@ HRESULT CAdActor::MergeAnims(char *AnimsFilename) { TOKEN_TABLE_END - byte *FileBuffer = Game->m_FileManager->ReadWholeFile(AnimsFilename); + byte *FileBuffer = Game->_fileManager->ReadWholeFile(AnimsFilename); if (FileBuffer == NULL) { Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); return E_FAIL; @@ -1309,7 +1309,7 @@ HRESULT CAdActor::MergeAnims(char *AnimsFilename) { if (!Anim || FAILED(Anim->LoadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = E_FAIL; - } else m_Anims.Add(Anim); + } else _anims.Add(Anim); } break; } @@ -1323,10 +1323,10 @@ HRESULT CAdActor::PlayAnim(char *Filename) { // if we have an anim with this name, use it CAdSpriteSet *Anim = GetAnimByName(Filename); if (Anim) { - m_AnimSprite2 = Anim->GetSprite(m_Dir); - if (m_AnimSprite2) { - m_AnimSprite2->Reset(); - m_State = STATE_PLAYING_ANIM_SET; + _animSprite2 = Anim->GetSprite(_dir); + if (_animSprite2) { + _animSprite2->Reset(); + _state = STATE_PLAYING_ANIM_SET; return S_OK; } } diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index fa6f771a35..1e6b21884d 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -51,32 +51,32 @@ public: virtual int GetHeight(); CBSprite *GetTalkStance(char *Stance); virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); - CBPoint *m_TargetPoint; + CBPoint *_targetPoint; virtual HRESULT Update(); virtual HRESULT Display(); - TDirection m_TargetDir; - TDirection m_AfterWalkDir; + TDirection _targetDir; + TDirection _afterWalkDir; virtual void TurnTo(TDirection dir); - CAdPath *m_Path; - CAdSpriteSet *m_WalkSprite; - CAdSpriteSet *m_StandSprite; - CAdSpriteSet *m_TurnLeftSprite; - CAdSpriteSet *m_TurnRightSprite; - CBArray m_TalkSprites; - CBArray m_TalkSpritesEx; - TDirection m_Dir; + CAdPath *_path; + CAdSpriteSet *_walkSprite; + CAdSpriteSet *_standSprite; + CAdSpriteSet *_turnLeftSprite; + CAdSpriteSet *_turnRightSprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // new anim system - char *m_TalkAnimName; - char *m_IdleAnimName; - char *m_WalkAnimName; - char *m_TurnLeftAnimName; - char *m_TurnRightAnimName; - CBArray m_Anims; + char *_talkAnimName; + char *_idleAnimName; + char *_walkAnimName; + char *_turnLeftAnimName; + char *_turnRightAnimName; + CBArray _anims; virtual HRESULT PlayAnim(char *Filename); CAdSpriteSet *GetAnimByName(char *AnimName); @@ -90,16 +90,16 @@ private: HRESULT SetDefaultAnimNames(); CBSprite *GetTalkStanceOld(char *Stance); HRESULT MergeAnims(char *AnimsFilename); - CBSprite *m_AnimSprite2; + CBSprite *_animSprite2; void InitLine(CBPoint StartPt, CBPoint EndPt); void GetNextStep(); void FollowPath(); - double m_PFStepX; - double m_PFStepY; - double m_PFX; - double m_PFY; - int m_PFCount; + double _pFStepX; + double _pFStepY; + double _pFX; + double _pFY; + int _pFCount; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index c0e07b958d..a67cc2109a 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -58,28 +58,28 @@ IMPLEMENT_PERSISTENT(CAdEntity, false) ////////////////////////////////////////////////////////////////////////// CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { - m_Type = OBJECT_ENTITY; - m_Subtype = ENTITY_NORMAL; - m_Region = NULL; - m_Item = NULL; + _type = OBJECT_ENTITY; + _subtype = ENTITY_NORMAL; + _region = NULL; + _item = NULL; - m_WalkToX = m_WalkToY = 0; - m_WalkToDir = DI_NONE; + _walkToX = _walkToY = 0; + _walkToDir = DI_NONE; } ////////////////////////////////////////////////////////////////////////// CAdEntity::~CAdEntity() { - Game->UnregisterObject(m_Region); + Game->UnregisterObject(_region); - delete[] m_Item; - m_Item = NULL; + delete[] _item; + _item = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -87,8 +87,8 @@ HRESULT CAdEntity::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); @@ -212,32 +212,32 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_SPRITE: { - SAFE_DELETE(m_Sprite); + SAFE_DELETE(_sprite); spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; - else m_Sprite = spr; + else _sprite = spr; } break; case TOKEN_TALK: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSprites.Add(spr); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSpritesEx.Add(spr); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); } break; @@ -258,13 +258,13 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &m_Zoomable); + parser.ScanStr((char *)params, "%b", &_zoomable); break; case TOKEN_SCALE: { int s; parser.ScanStr((char *)params, "%d", &s); - m_Scale = (float)s; + _scale = (float)s; } break; @@ -272,85 +272,85 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_RELATIVE_SCALE: { int s; parser.ScanStr((char *)params, "%d", &s); - m_RelativeScale = (float)s; + _relativeScale = (float)s; } break; case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &m_Rotatable); + parser.ScanStr((char *)params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &m_Registrable); + parser.ScanStr((char *)params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &m_Shadowable); + parser.ScanStr((char *)params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &m_Active); + parser.ScanStr((char *)params, "%b", &_active); break; case TOKEN_CURSOR: - SAFE_DELETE(m_Cursor); - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - SAFE_DELETE(m_Cursor); + SAFE_DELETE(_cursor); + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + SAFE_DELETE(_cursor); cmd = PARSERR_GENERIC; } break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &m_EditorSelected); + parser.ScanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_REGION: { - if (m_Region) Game->UnregisterObject(m_Region); - m_Region = NULL; + if (_region) Game->UnregisterObject(_region); + _region = NULL; CBRegion *rgn = new CBRegion(Game); if (!rgn || FAILED(rgn->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; else { - m_Region = rgn; - Game->RegisterObject(m_Region); + _region = rgn; + Game->RegisterObject(_region); } } break; case TOKEN_BLOCKED_REGION: { - SAFE_DELETE(m_BlockRegion); - SAFE_DELETE(m_CurrentBlockRegion); + SAFE_DELETE(_blockRegion); + SAFE_DELETE(_currentBlockRegion); CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { - SAFE_DELETE(m_BlockRegion); - SAFE_DELETE(m_CurrentBlockRegion); + SAFE_DELETE(_blockRegion); + SAFE_DELETE(_currentBlockRegion); cmd = PARSERR_GENERIC; } else { - m_BlockRegion = rgn; - m_CurrentBlockRegion = crgn; - m_CurrentBlockRegion->Mimic(m_BlockRegion); + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->Mimic(_blockRegion); } } break; case TOKEN_WAYPOINTS: { - SAFE_DELETE(m_WptGroup); - SAFE_DELETE(m_CurrentWptGroup); + SAFE_DELETE(_wptGroup); + SAFE_DELETE(_currentWptGroup); CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { - SAFE_DELETE(m_WptGroup); - SAFE_DELETE(m_CurrentWptGroup); + SAFE_DELETE(_wptGroup); + SAFE_DELETE(_currentWptGroup); cmd = PARSERR_GENERIC; } else { - m_WptGroup = wpt; - m_CurrentWptGroup = cwpt; - m_CurrentWptGroup->Mimic(m_WptGroup); + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->Mimic(_wptGroup); } } break; @@ -361,18 +361,18 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SUBTYPE: { if (scumm_stricmp((char *)params, "sound") == 0) { - SAFE_DELETE(m_Sprite); - if (Game->m_EditorMode) { + SAFE_DELETE(_sprite); + if (Game->_editorMode) { spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; - else m_Sprite = spr; + else _sprite = spr; } - if (Game->m_EditorMode) m_EditorOnly = true; - m_Zoomable = false; - m_Rotatable = false; - m_Registrable = Game->m_EditorMode; - m_Shadowable = false; - m_Subtype = ENTITY_SOUND; + if (Game->_editorMode) _editorOnly = true; + _zoomable = false; + _rotatable = false; + _registrable = Game->_editorMode; + _shadowable = false; + _subtype = ENTITY_SOUND; } } break; @@ -382,19 +382,19 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SOUND_START_TIME: - parser.ScanStr((char *)params, "%d", &m_SFXStart); + parser.ScanStr((char *)params, "%d", &_sFXStart); break; case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &m_SFXVolume); + parser.ScanStr((char *)params, "%d", &_sFXVolume); break; case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &m_AutoSoundPanning); + parser.ScanStr((char *)params, "%b", &_autoSoundPanning); break; case TOKEN_SAVE_STATE: - parser.ScanStr((char *)params, "%b", &m_SaveState); + parser.ScanStr((char *)params, "%b", &_saveState); break; case TOKEN_PROPERTY: @@ -402,7 +402,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &m_IgnoreItems); + parser.ScanStr((char *)params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: @@ -418,11 +418,11 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WALK_TO_X: - parser.ScanStr((char *)params, "%d", &m_WalkToX); + parser.ScanStr((char *)params, "%d", &_walkToX); break; case TOKEN_WALK_TO_Y: - parser.ScanStr((char *)params, "%d", &m_WalkToY); + parser.ScanStr((char *)params, "%d", &_walkToY); break; case TOKEN_WALK_TO_DIR: { @@ -430,7 +430,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { parser.ScanStr((char *)params, "%d", &i); if (i < 0) i = 0; if (i >= NUM_DIRECTIONS) i = DI_NONE; - m_WalkToDir = (TDirection)i; + _walkToDir = (TDirection)i; } break; } @@ -445,8 +445,8 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (m_Region && m_Sprite) { - Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", m_Name); + if (_region && _sprite) { + Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); } UpdatePosition(); @@ -454,10 +454,10 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - m_AlphaColor = DRGBA(ar, ag, ab, alpha); - m_State = STATE_READY; + _alphaColor = DRGBA(ar, ag, ab, alpha); + _state = STATE_READY; - if (m_Item && ((CAdGame *)Game)->IsItemTaken(m_Item)) m_Active = false; + if (_item && ((CAdGame *)Game)->IsItemTaken(_item)) _active = false; return S_OK; } @@ -465,44 +465,44 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::Display() { - if (m_Active) { + if (_active) { UpdateSounds(); uint32 Alpha; - if (m_AlphaColor != 0) Alpha = m_AlphaColor; - else Alpha = m_Shadowable ? ((CAdGame *)Game)->m_Scene->GetAlphaAt(m_PosX, m_PosY) : 0xFFFFFFFF; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY) : 0xFFFFFFFF; float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); float Rotate; - if (m_Rotatable) { - if (m_RotateValid) Rotate = m_Rotate; - else Rotate = ((CAdGame *)Game)->m_Scene->GetRotationAt(m_PosX, m_PosY) + m_RelativeRotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; - bool Reg = m_Registrable; - if (m_IgnoreItems && ((CAdGame *)Game)->m_SelectedItem) Reg = false; + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; - if (m_Region && (Reg || m_EditorAlwaysRegister)) { - Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, m_RegisterAlias, m_Region, Game->m_OffsetX, Game->m_OffsetY)); + if (_region && (Reg || _editorAlwaysRegister)) { + Game->_renderer->_rectList.Add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); } DisplaySpriteAttachments(true); - if (m_CurrentSprite) { - m_CurrentSprite->Display(m_PosX, - m_PosY, - (Reg || m_EditorAlwaysRegister) ? m_RegisterAlias : NULL, + if (_currentSprite) { + _currentSprite->Display(_posX, + _posY, + (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, ScaleX, ScaleY, Alpha, Rotate, - m_BlendMode); + _blendMode); } DisplaySpriteAttachments(false); - if (m_PartEmitter) m_PartEmitter->Display(m_Region); + if (_partEmitter) _partEmitter->Display(_region); } return S_OK; @@ -511,73 +511,73 @@ HRESULT CAdEntity::Display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::Update() { - m_CurrentSprite = NULL; + _currentSprite = NULL; - if (m_State == STATE_READY && m_AnimSprite) { - SAFE_DELETE(m_AnimSprite); + if (_state == STATE_READY && _animSprite) { + SAFE_DELETE(_animSprite); } // finished playing animation? - if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { - m_State = STATE_READY; - m_CurrentSprite = m_AnimSprite; + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; } - if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); // default: stand animation - if (!m_CurrentSprite) m_CurrentSprite = m_Sprite; + if (!_currentSprite) _currentSprite = _sprite; - switch (m_State) { + switch (_state) { ////////////////////////////////////////////////////////////////////////// case STATE_PLAYING_ANIM: - m_CurrentSprite = m_AnimSprite; + _currentSprite = _animSprite; break; ////////////////////////////////////////////////////////////////////////// case STATE_READY: - if (!m_AnimSprite) - m_CurrentSprite = m_Sprite; + if (!_animSprite) + _currentSprite = _sprite; break; ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - m_Sentence->Update(); - if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + _sentence->Update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); - if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - m_Sentence->Finish(); - m_TempSprite2 = NULL; - m_State = STATE_READY; + _sentence->Finish(); + _tempSprite2 = NULL; + _state = STATE_READY; } else { - m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); - if (m_TempSprite2) { - m_TempSprite2->Reset(); - m_CurrentSprite = m_TempSprite2; + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->AddSentence(m_Sentence); + ((CAdGame *)Game)->AddSentence(_sentence); } } else { - m_CurrentSprite = m_TempSprite2; - ((CAdGame *)Game)->AddSentence(m_Sentence); + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); } } break; } - if (m_CurrentSprite) { - m_CurrentSprite->GetCurrentFrame(m_Zoomable ? ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) : 100); - if (m_CurrentSprite->m_Changed) { - m_PosX += m_CurrentSprite->m_MoveX; - m_PosY += m_CurrentSprite->m_MoveY; + if (_currentSprite) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; } } UpdateBlockRegion(); - m_Ready = (m_State == STATE_READY); + _ready = (_state == STATE_READY); UpdatePartEmitter(); @@ -594,7 +594,7 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "StopSound") == 0 && m_Subtype == ENTITY_SOUND) { + if (strcmp(Name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { Stack->CorrectParams(0); if (FAILED(StopSFX(false))) Stack->PushBool(false); @@ -668,11 +668,11 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CreateRegion") == 0) { Stack->CorrectParams(0); - if (!m_Region) { - m_Region = new CBRegion(Game); - Game->RegisterObject(m_Region); + if (!_region) { + _region = new CBRegion(Game); + Game->RegisterObject(_region); } - if (m_Region) Stack->PushNative(m_Region, true); + if (_region) Stack->PushNative(_region, true); else Stack->PushNULL(); return S_OK; @@ -683,9 +683,9 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DeleteRegion") == 0) { Stack->CorrectParams(0); - if (m_Region) { - Game->UnregisterObject(m_Region); - m_Region = NULL; + if (_region) { + Game->UnregisterObject(_region); + _region = NULL; Stack->PushBool(true); } else Stack->PushBool(false); @@ -698,69 +698,69 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CAdEntity::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("entity"); - return m_ScValue; + _scValue->SetString("entity"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Item") == 0) { - if (m_Item) m_ScValue->SetString(m_Item); - else m_ScValue->SetNULL(); + if (_item) _scValue->SetString(_item); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Subtype (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Subtype") == 0) { - if (m_Subtype == ENTITY_SOUND) - m_ScValue->SetString("sound"); + if (_subtype == ENTITY_SOUND) + _scValue->SetString("sound"); else - m_ScValue->SetString("normal"); + _scValue->SetString("normal"); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WalkToX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToX") == 0) { - m_ScValue->SetInt(m_WalkToX); - return m_ScValue; + _scValue->SetInt(_walkToX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WalkToY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToY") == 0) { - m_ScValue->SetInt(m_WalkToY); - return m_ScValue; + _scValue->SetInt(_walkToY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WalkToDirection ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToDirection") == 0) { - m_ScValue->SetInt((int)m_WalkToDir); - return m_ScValue; + _scValue->SetInt((int)_walkToDir); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Region (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Region") == 0) { - if (m_Region) m_ScValue->SetNative(m_Region, true); - else m_ScValue->SetNULL(); - return m_ScValue; + if (_region) _scValue->SetNative(_region, true); + else _scValue->SetNULL(); + return _scValue; } else return CAdTalkHolder::ScGetProperty(Name); @@ -782,7 +782,7 @@ HRESULT CAdEntity::ScSetProperty(char *Name, CScValue *Value) { // WalkToX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToX") == 0) { - m_WalkToX = Value->GetInt(); + _walkToX = Value->GetInt(); return S_OK; } @@ -790,7 +790,7 @@ HRESULT CAdEntity::ScSetProperty(char *Name, CScValue *Value) { // WalkToY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToY") == 0) { - m_WalkToY = Value->GetInt(); + _walkToY = Value->GetInt(); return S_OK; } @@ -799,7 +799,7 @@ HRESULT CAdEntity::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkToDirection") == 0) { int Dir = Value->GetInt(); - if (Dir >= 0 && Dir < NUM_DIRECTIONS) m_WalkToDir = (TDirection)Dir; + if (Dir >= 0 && Dir < NUM_DIRECTIONS) _walkToDir = (TDirection)Dir; return S_OK; } @@ -817,74 +817,74 @@ char *CAdEntity::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ENTITY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); - if (m_Subtype == ENTITY_SOUND) + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + if (_subtype == ENTITY_SOUND) Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", m_Zoomable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", m_Registrable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", m_Shadowable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); - if (m_IgnoreItems) - Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", m_IgnoreItems ? "TRUE" : "FALSE"); - if (m_Rotatable) - Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", m_Rotatable ? "TRUE" : "FALSE"); - - if (!m_AutoSoundPanning) - Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", m_AutoSoundPanning ? "TRUE" : "FALSE"); - - if (!m_SaveState) - Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", m_SaveState ? "TRUE" : "FALSE"); - - if (m_Item && m_Item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", m_Item); - - Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", m_WalkToX); - Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", m_WalkToY); - if (m_WalkToDir != DI_NONE) - Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)m_WalkToDir); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_ignoreItems) + Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + if (_rotatable) + Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + + if (!_autoSoundPanning) + Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + + if (!_saveState) + Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + + if (_item && _item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); + + Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); + Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); + if (_walkToDir != DI_NONE) + Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); int i; - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (m_Subtype == ENTITY_NORMAL && m_Sprite && m_Sprite->m_Filename) - Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", m_Sprite->m_Filename); + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) + Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); - if (m_Subtype == ENTITY_SOUND && m_SFX && m_SFX->m_SoundFilename) { - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", m_SFX->m_SoundFilename); - Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", m_SFXStart); - Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", m_SFXVolume); + if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); } - if (D3DCOLGetR(m_AlphaColor) != 0 || D3DCOLGetG(m_AlphaColor) != 0 || D3DCOLGetB(m_AlphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_AlphaColor), D3DCOLGetG(m_AlphaColor), D3DCOLGetB(m_AlphaColor)); + if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - if (D3DCOLGetA(m_AlphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_AlphaColor)); + if (D3DCOLGetA(_alphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); - if (m_Scale >= 0) - Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)m_Scale); + if (_scale >= 0) + Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); - if (m_RelativeScale != 0) - Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)m_RelativeScale); + if (_relativeScale != 0) + Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); CAdTalkHolder::SaveAsText(Buffer, Indent + 2); - if (m_Region) m_Region->SaveAsText(Buffer, Indent + 2); + if (_region) _region->SaveAsText(Buffer, Indent + 2); - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); CAdObject::SaveAsText(Buffer, Indent + 2); @@ -896,10 +896,10 @@ HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// int CAdEntity::GetHeight() { - if (m_Region && !m_Sprite) { - return m_Region->m_Rect.bottom - m_Region->m_Rect.top; + if (_region && !_sprite) { + return _region->_rect.bottom - _region->_rect.top; } else { - if (m_CurrentSprite == NULL) m_CurrentSprite = m_Sprite; + if (_currentSprite == NULL) _currentSprite = _sprite; return CAdObject::GetHeight(); } } @@ -907,9 +907,9 @@ int CAdEntity::GetHeight() { ////////////////////////////////////////////////////////////////////////// void CAdEntity::UpdatePosition() { - if (m_Region && !m_Sprite) { - m_PosX = m_Region->m_Rect.left + (m_Region->m_Rect.right - m_Region->m_Rect.left) / 2; - m_PosY = m_Region->m_Rect.bottom; + if (_region && !_sprite) { + _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; + _posY = _region->_rect.bottom; } } @@ -918,16 +918,16 @@ void CAdEntity::UpdatePosition() { HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { CAdTalkHolder::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Item)); - PersistMgr->Transfer(TMEMBER(m_Region)); - //PersistMgr->Transfer(TMEMBER(m_Sprite)); - PersistMgr->Transfer(TMEMBER_INT(m_Subtype)); - m_TalkSprites.Persist(PersistMgr); - m_TalkSpritesEx.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_item)); + PersistMgr->Transfer(TMEMBER(_region)); + //PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER_INT(_subtype)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_WalkToX)); - PersistMgr->Transfer(TMEMBER(m_WalkToY)); - PersistMgr->Transfer(TMEMBER_INT(m_WalkToDir)); + PersistMgr->Transfer(TMEMBER(_walkToX)); + PersistMgr->Transfer(TMEMBER(_walkToY)); + PersistMgr->Transfer(TMEMBER_INT(_walkToDir)); return S_OK; } @@ -935,25 +935,25 @@ HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CAdEntity::SetItem(char *ItemName) { - CBUtils::SetString(&m_Item, ItemName); + CBUtils::SetString(&_item, ItemName); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::SetSprite(char *Filename) { bool SetCurrent = false; - if (m_CurrentSprite == m_Sprite) { - m_CurrentSprite = NULL; + if (_currentSprite == _sprite) { + _currentSprite = NULL; SetCurrent = true; } - SAFE_DELETE(m_Sprite); + SAFE_DELETE(_sprite); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile(Filename))) { - SAFE_DELETE(m_Sprite); + SAFE_DELETE(_sprite); return E_FAIL; } else { - m_Sprite = spr; - m_CurrentSprite = m_Sprite; + _sprite = spr; + _currentSprite = _sprite; return S_OK; } } diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h index b85cc123c6..1677d3e097 100644 --- a/engines/wintermute/AdEntity.h +++ b/engines/wintermute/AdEntity.h @@ -36,15 +36,15 @@ namespace WinterMute { class CAdEntity : public CAdTalkHolder { public: HRESULT SetSprite(char *Filename); - int m_WalkToX; - int m_WalkToY; - TDirection m_WalkToDir; + int _walkToX; + int _walkToY; + TDirection _walkToDir; void SetItem(char *ItemName); - char *m_Item; + char *_item; DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) void UpdatePosition(); virtual int GetHeight(); - CBRegion *m_Region; + CBRegion *_region; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Update(); virtual HRESULT Display(); @@ -52,7 +52,7 @@ public: virtual ~CAdEntity(); HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - TEntityType m_Subtype; + TEntityType _subtype; // scripting interface virtual CScValue *ScGetProperty(char *Name); diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index cfcfd20085..e736ddc0e0 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -65,44 +65,44 @@ IMPLEMENT_PERSISTENT(CAdGame, true) ////////////////////////////////////////////////////////////////////////// CAdGame::CAdGame(): CBGame() { - m_ResponseBox = NULL; - m_InventoryBox = NULL; + _responseBox = NULL; + _inventoryBox = NULL; - m_Scene = new CAdScene(Game); - m_Scene->SetName(""); - RegisterObject(m_Scene); + _scene = new CAdScene(Game); + _scene->SetName(""); + RegisterObject(_scene); - m_PrevSceneName = NULL; - m_PrevSceneFilename = NULL; - m_ScheduledScene = NULL; - m_ScheduledFadeIn = false; + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _scheduledFadeIn = false; - m_StateEx = GAME_NORMAL; + _stateEx = GAME_NORMAL; - m_SelectedItem = NULL; + _selectedItem = NULL; - m_TexItemLifeTime = 10000; - m_TexWalkLifeTime = 10000; - m_TexStandLifeTime = 10000; - m_TexTalkLifeTime = 10000; + _texItemLifeTime = 10000; + _texWalkLifeTime = 10000; + _texStandLifeTime = 10000; + _texTalkLifeTime = 10000; - m_TalkSkipButton = TALK_SKIP_LEFT; + _talkSkipButton = TALK_SKIP_LEFT; - m_SceneViewport = NULL; + _sceneViewport = NULL; - m_InitialScene = true; - m_DebugStartupScene = NULL; - m_StartupScene = NULL; + _initialScene = true; + _debugStartupScene = NULL; + _startupScene = NULL; - m_InvObject = new CAdObject(this); - m_InventoryOwner = m_InvObject; + _invObject = new CAdObject(this); + _inventoryOwner = _invObject; - m_TempDisableSaveState = false; - m_ItemsFile = NULL; + _tempDisableSaveState = false; + _itemsFile = NULL; - m_SmartItemCursor = false; + _smartItemCursor = false; AddSpeechDir("speech"); } @@ -118,75 +118,75 @@ CAdGame::~CAdGame() { HRESULT CAdGame::Cleanup() { int i; - for (i = 0; i < m_Objects.GetSize(); i++) { - UnregisterObject(m_Objects[i]); - m_Objects[i] = NULL; + for (i = 0; i < _objects.GetSize(); i++) { + UnregisterObject(_objects[i]); + _objects[i] = NULL; } - m_Objects.RemoveAll(); + _objects.RemoveAll(); - for (i = 0; i < m_DlgPendingBranches.GetSize(); i++) { - delete [] m_DlgPendingBranches[i]; + for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + delete [] _dlgPendingBranches[i]; } - m_DlgPendingBranches.RemoveAll(); + _dlgPendingBranches.RemoveAll(); - for (i = 0; i < m_SpeechDirs.GetSize(); i++) { - delete [] m_SpeechDirs[i]; + for (i = 0; i < _speechDirs.GetSize(); i++) { + delete [] _speechDirs[i]; } - m_SpeechDirs.RemoveAll(); + _speechDirs.RemoveAll(); - UnregisterObject(m_Scene); - m_Scene = NULL; + UnregisterObject(_scene); + _scene = NULL; // remove items - for (i = 0; i < m_Items.GetSize(); i++) Game->UnregisterObject(m_Items[i]); - m_Items.RemoveAll(); + for (i = 0; i < _items.GetSize(); i++) Game->UnregisterObject(_items[i]); + _items.RemoveAll(); // clear remaining inventories - delete m_InvObject; - m_InvObject = NULL; + delete _invObject; + _invObject = NULL; - for (i = 0; i < m_Inventories.GetSize(); i++) { - delete m_Inventories[i]; + for (i = 0; i < _inventories.GetSize(); i++) { + delete _inventories[i]; } - m_Inventories.RemoveAll(); + _inventories.RemoveAll(); - if (m_ResponseBox) { - Game->UnregisterObject(m_ResponseBox); - m_ResponseBox = NULL; + if (_responseBox) { + Game->UnregisterObject(_responseBox); + _responseBox = NULL; } - if (m_InventoryBox) { - Game->UnregisterObject(m_InventoryBox); - m_InventoryBox = NULL; + if (_inventoryBox) { + Game->UnregisterObject(_inventoryBox); + _inventoryBox = NULL; } - delete[] m_PrevSceneName; - delete[] m_PrevSceneFilename; - delete[] m_ScheduledScene; - delete[] m_DebugStartupScene; - delete[] m_ItemsFile; - m_PrevSceneName = NULL; - m_PrevSceneFilename = NULL; - m_ScheduledScene = NULL; - m_DebugStartupScene = NULL; - m_StartupScene = NULL; - m_ItemsFile = NULL; + delete[] _prevSceneName; + delete[] _prevSceneFilename; + delete[] _scheduledScene; + delete[] _debugStartupScene; + delete[] _itemsFile; + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _debugStartupScene = NULL; + _startupScene = NULL; + _itemsFile = NULL; - delete m_SceneViewport; - m_SceneViewport = NULL; + delete _sceneViewport; + _sceneViewport = NULL; - for (i = 0; i < m_SceneStates.GetSize(); i++) delete m_SceneStates[i]; - m_SceneStates.RemoveAll(); + for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; + _sceneStates.RemoveAll(); - for (i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; - m_ResponsesBranch.RemoveAll(); + for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); - for (i = 0; i < m_ResponsesGame.GetSize(); i++) delete m_ResponsesGame[i]; - m_ResponsesGame.RemoveAll(); + for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; + _responsesGame.RemoveAll(); return CBGame::Cleanup(); } @@ -194,11 +194,11 @@ HRESULT CAdGame::Cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::InitLoop() { - if (m_ScheduledScene && m_TransMgr->IsReady()) { - ChangeScene(m_ScheduledScene, m_ScheduledFadeIn); - SAFE_DELETE_ARRAY(m_ScheduledScene); + if (_scheduledScene && _transMgr->IsReady()) { + ChangeScene(_scheduledScene, _scheduledFadeIn); + SAFE_DELETE_ARRAY(_scheduledScene); - Game->m_ActiveObject = NULL; + Game->_activeObject = NULL; } @@ -206,9 +206,9 @@ HRESULT CAdGame::InitLoop() { res = CBGame::InitLoop(); if (FAILED(res)) return res; - if (m_Scene) res = m_Scene->InitLoop(); + if (_scene) res = _scene->InitLoop(); - m_Sentences.RemoveAll(); + _sentences.RemoveAll(); return res; } @@ -216,7 +216,7 @@ HRESULT CAdGame::InitLoop() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::AddObject(CAdObject *Object) { - m_Objects.Add(Object); + _objects.Add(Object); return RegisterObject(Object); } @@ -224,14 +224,14 @@ HRESULT CAdGame::AddObject(CAdObject *Object) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::RemoveObject(CAdObject *Object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() - if (m_Scene) { - HRESULT Res = m_Scene->RemoveObject(Object); + if (_scene) { + HRESULT Res = _scene->RemoveObject(Object); if (SUCCEEDED(Res)) return Res; } - for (int i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i] == Object) { - m_Objects.RemoveAt(i); + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] == Object) { + _objects.RemoveAt(i); break; } } @@ -241,43 +241,43 @@ HRESULT CAdGame::RemoveObject(CAdObject *Object) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ChangeScene(char *Filename, bool FadeIn) { - if (m_Scene == NULL) { - m_Scene = new CAdScene(Game); - RegisterObject(m_Scene); + if (_scene == NULL) { + _scene = new CAdScene(Game); + RegisterObject(_scene); } else { - m_Scene->ApplyEvent("SceneShutdown", true); + _scene->ApplyEvent("SceneShutdown", true); - SetPrevSceneName(m_Scene->m_Name); - SetPrevSceneFilename(m_Scene->m_Filename); + SetPrevSceneName(_scene->_name); + SetPrevSceneFilename(_scene->_filename); - if (!m_TempDisableSaveState) m_Scene->SaveState(); - m_TempDisableSaveState = false; + if (!_tempDisableSaveState) _scene->SaveState(); + _tempDisableSaveState = false; } - if (m_Scene) { + if (_scene) { // reset objects - for (int i = 0; i < m_Objects.GetSize(); i++) m_Objects[i]->Reset(); + for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->Reset(); // reset scene properties - m_Scene->m_SFXVolume = 100; - if (m_Scene->m_ScProp) m_Scene->m_ScProp->Cleanup(); + _scene->_sFXVolume = 100; + if (_scene->_scProp) _scene->_scProp->Cleanup(); HRESULT ret; - if (m_InitialScene && m_DEBUG_DebugMode && m_DebugStartupScene) { - m_InitialScene = false; - ret = m_Scene->LoadFile(m_DebugStartupScene); - } else ret = m_Scene->LoadFile(Filename); + if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { + _initialScene = false; + ret = _scene->LoadFile(_debugStartupScene); + } else ret = _scene->LoadFile(Filename); if (SUCCEEDED(ret)) { // invalidate references to the original scene - for (int i = 0; i < m_Objects.GetSize(); i++) { - m_Objects[i]->InvalidateCurrRegions(); - m_Objects[i]->m_StickRegion = NULL; + for (int i = 0; i < _objects.GetSize(); i++) { + _objects[i]->InvalidateCurrRegions(); + _objects[i]->_stickRegion = NULL; } - m_Scene->LoadState(); + _scene->LoadState(); } - if (FadeIn) Game->m_TransMgr->Start(TRANSITION_FADE_IN); + if (FadeIn) Game->_transMgr->Start(TRANSITION_FADE_IN); return ret; } else return E_FAIL; } @@ -285,15 +285,15 @@ HRESULT CAdGame::ChangeScene(char *Filename, bool FadeIn) { ////////////////////////////////////////////////////////////////////////// void CAdGame::AddSentence(CAdSentence *Sentence) { - m_Sentences.Add(Sentence); + _sentences.Add(Sentence); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::DisplaySentences(bool Frozen) { - for (int i = 0; i < m_Sentences.GetSize(); i++) { - if (Frozen && m_Sentences[i]->m_Freezable) continue; - else m_Sentences[i]->Display(); + for (int i = 0; i < _sentences.GetSize(); i++) { + if (Frozen && _sentences[i]->_freezable) continue; + else _sentences[i]->Display(); } return S_OK; } @@ -301,10 +301,10 @@ HRESULT CAdGame::DisplaySentences(bool Frozen) { ////////////////////////////////////////////////////////////////////////// void CAdGame::FinishSentences() { - for (int i = 0; i < m_Sentences.GetSize(); i++) { - if (m_Sentences[i]->CanSkip()) { - m_Sentences[i]->m_Duration = 0; - if (m_Sentences[i]->m_Sound) m_Sentences[i]->m_Sound->Stop(); + for (int i = 0; i < _sentences.GetSize(); i++) { + if (_sentences[i]->CanSkip()) { + _sentences[i]->_duration = 0; + if (_sentences[i]->_sound) _sentences[i]->_sound->Stop(); } } } @@ -327,7 +327,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); ScheduleChangeScene(Filename, TransIn); - if (TransOut) m_TransMgr->Start(TRANSITION_FADE_OUT, true); + if (TransOut) _transMgr->Start(TRANSITION_FADE_OUT, true); Stack->PushNULL(); @@ -443,7 +443,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CAdItem *Item = NULL; if (Val->IsInt()) { int Index = Val->GetInt(); - if (Index >= 0 && Index < m_Items.GetSize()) Item = m_Items[Index]; + if (Index >= 0 && Index < _items.GetSize()) Item = _items[Index]; } else { Item = GetItemByName(Val->GetString()); } @@ -467,21 +467,21 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CScValue *val3 = Stack->Pop(); CScValue *val4 = Stack->Pop(); - if (m_ResponseBox) { + if (_responseBox) { CAdResponse *res = new CAdResponse(Game); if (res) { - res->m_ID = id; + res->_iD = id; res->SetText(text); - m_StringTable->Expand(&res->m_Text); + _stringTable->Expand(&res->_text); if (!val1->IsNULL()) res->SetIcon(val1->GetString()); if (!val2->IsNULL()) res->SetIconHover(val2->GetString()); if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); if (!val4->IsNULL()) res->SetFont(val4->GetString()); - if (strcmp(Name, "AddResponseOnce") == 0) res->m_ResponseType = RESPONSE_ONCE; - else if (strcmp(Name, "AddResponseOnceGame") == 0) res->m_ResponseType = RESPONSE_ONCE_GAME; + if (strcmp(Name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; + else if (strcmp(Name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; - m_ResponseBox->m_Responses.Add(res); + _responseBox->_responses.Add(res); } } else { Script->RuntimeError("Game.AddResponse: response box is not defined"); @@ -507,8 +507,8 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ClearResponses") == 0) { Stack->CorrectParams(0); - m_ResponseBox->ClearResponses(); - m_ResponseBox->ClearButtons(); + _responseBox->ClearResponses(); + _responseBox->ClearButtons(); Stack->PushNULL(); return S_OK; } @@ -520,27 +520,27 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); bool AutoSelectLast = Stack->Pop()->GetBool(); - if (m_ResponseBox) { - m_ResponseBox->WeedResponses(); + if (_responseBox) { + _responseBox->WeedResponses(); - if (m_ResponseBox->m_Responses.GetSize() == 0) { + if (_responseBox->_responses.GetSize() == 0) { Stack->PushNULL(); return S_OK; } - if (m_ResponseBox->m_Responses.GetSize() == 1 && AutoSelectLast) { - Stack->PushInt(m_ResponseBox->m_Responses[0]->m_ID); - m_ResponseBox->HandleResponse(m_ResponseBox->m_Responses[0]); - m_ResponseBox->ClearResponses(); + if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { + Stack->PushInt(_responseBox->_responses[0]->_iD); + _responseBox->HandleResponse(_responseBox->_responses[0]); + _responseBox->ClearResponses(); return S_OK; } - m_ResponseBox->CreateButtons(); - m_ResponseBox->m_WaitingScript = Script; - Script->WaitForExclusive(m_ResponseBox); - m_State = GAME_SEMI_FROZEN; - m_StateEx = GAME_WAITING_RESPONSE; + _responseBox->CreateButtons(); + _responseBox->_waitingScript = Script; + Script->WaitForExclusive(_responseBox); + _state = GAME_SEMI_FROZEN; + _stateEx = GAME_WAITING_RESPONSE; } else { Script->RuntimeError("Game.GetResponse: response box is not defined"); Stack->PushNULL(); @@ -554,9 +554,9 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetNumResponses") == 0) { Stack->CorrectParams(0); - if (m_ResponseBox) { - m_ResponseBox->WeedResponses(); - Stack->PushInt(m_ResponseBox->m_Responses.GetSize()); + if (_responseBox) { + _responseBox->WeedResponses(); + Stack->PushInt(_responseBox->_responses.GetSize()); } else { Script->RuntimeError("Game.GetNumResponses: response box is not defined"); Stack->PushNULL(); @@ -575,11 +575,11 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool DeleteName = false; if (Val->IsNULL()) { BranchName = new char[20]; - sprintf(BranchName, "line%d", Script->m_CurrentLine); + sprintf(BranchName, "line%d", Script->_currentLine); DeleteName = true; } else BranchName = Val->GetString(); - StartDlgBranch(BranchName, Script->m_Filename == NULL ? "" : Script->m_Filename, Script->m_ThreadEvent == NULL ? "" : Script->m_ThreadEvent); + StartDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); Stack->PushNULL(); if (DeleteName) delete[] BranchName; @@ -595,7 +595,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This char *BranchName = NULL; CScValue *Val = Stack->Pop(); if (!Val->IsNULL()) BranchName = Val->GetString(); - EndDlgBranch(BranchName, Script->m_Filename == NULL ? "" : Script->m_Filename, Script->m_ThreadEvent == NULL ? "" : Script->m_ThreadEvent); + EndDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); Stack->PushNULL(); @@ -608,8 +608,8 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetCurrentDlgBranch") == 0) { Stack->CorrectParams(0); - if (m_DlgPendingBranches.GetSize() > 0) { - Stack->PushString(m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1]); + if (_dlgPendingBranches.GetSize() > 0) { + Stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); } else Stack->PushNULL(); return S_OK; @@ -619,28 +619,28 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This // TakeItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TakeItem") == 0) { - return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // DropItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DropItem") == 0) { - return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // GetItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetItem") == 0) { - return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // HasItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HasItem") == 0) { - return m_InvObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// @@ -651,14 +651,14 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CScValue *val = Stack->Pop(); if (!val->IsNULL()) { - for (int i = 0; i < m_Inventories.GetSize(); i++) { - CAdInventory *Inv = m_Inventories[i]; + for (int i = 0; i < _inventories.GetSize(); i++) { + CAdInventory *Inv = _inventories[i]; - for (int j = 0; j < Inv->m_TakenItems.GetSize(); j++) { - if (val->GetNative() == Inv->m_TakenItems[j]) { + for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + if (val->GetNative() == Inv->_takenItems[j]) { Stack->PushBool(true); return S_OK; - } else if (scumm_stricmp(val->GetString(), Inv->m_TakenItems[j]->m_Name) == 0) { + } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { Stack->PushBool(true); return S_OK; } @@ -675,8 +675,8 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetInventoryWindow") == 0) { Stack->CorrectParams(0); - if (m_InventoryBox && m_InventoryBox->m_Window) - Stack->PushNative(m_InventoryBox->m_Window, true); + if (_inventoryBox && _inventoryBox->_window) + Stack->PushNative(_inventoryBox->_window, true); else Stack->PushNULL(); @@ -688,8 +688,8 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetResponsesWindow") == 0 || strcmp(Name, "GetResponseWindow") == 0) { Stack->CorrectParams(0); - if (m_ResponseBox && m_ResponseBox->m_Window) - Stack->PushNative(m_ResponseBox->m_Window, true); + if (_responseBox && _responseBox->_window) + Stack->PushNative(_responseBox->_window, true); else Stack->PushNULL(); @@ -703,13 +703,13 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); - Game->UnregisterObject(m_ResponseBox); - m_ResponseBox = new CAdResponseBox(Game); - if (m_ResponseBox && !FAILED(m_ResponseBox->LoadFile(Filename))) { - RegisterObject(m_ResponseBox); + Game->UnregisterObject(_responseBox); + _responseBox = new CAdResponseBox(Game); + if (_responseBox && !FAILED(_responseBox->LoadFile(Filename))) { + RegisterObject(_responseBox); Stack->PushBool(true); } else { - SAFE_DELETE(m_ResponseBox); + SAFE_DELETE(_responseBox); Stack->PushBool(false); } return S_OK; @@ -722,14 +722,14 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); - Game->UnregisterObject(m_InventoryBox); - m_InventoryBox = new CAdInventoryBox(Game); - if (m_InventoryBox && !FAILED(m_InventoryBox->LoadFile(Filename))) { - RegisterObject(m_InventoryBox); + Game->UnregisterObject(_inventoryBox); + _inventoryBox = new CAdInventoryBox(Game); + if (_inventoryBox && !FAILED(_inventoryBox->LoadFile(Filename))) { + RegisterObject(_inventoryBox); Stack->PushBool(true); } else { - delete m_InventoryBox; - m_InventoryBox = NULL; + delete _inventoryBox; + _inventoryBox = NULL; Stack->PushBool(false); } return S_OK; @@ -781,11 +781,11 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This int Width = Stack->Pop()->GetInt(); int Height = Stack->Pop()->GetInt(); - if (Width <= 0) Width = m_Renderer->m_Width; - if (Height <= 0) Height = m_Renderer->m_Height; + if (Width <= 0) Width = _renderer->_width; + if (Height <= 0) Height = _renderer->_height; - if (!m_SceneViewport) m_SceneViewport = new CBViewport(Game); - if (m_SceneViewport) m_SceneViewport->SetRect(X, Y, X + Width, Y + Height); + if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (_sceneViewport) _sceneViewport->SetRect(X, Y, X + Width, Y + Height); Stack->PushBool(true); @@ -799,152 +799,152 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CAdGame::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("game"); - return m_ScValue; + _scValue->SetString("game"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scene ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scene") == 0) { - if (m_Scene) m_ScValue->SetNative(m_Scene, true); - else m_ScValue->SetNULL(); + if (_scene) _scValue->SetNative(_scene, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SelectedItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SelectedItem") == 0) { - //if(m_SelectedItem) m_ScValue->SetString(m_SelectedItem->m_Name); - if (m_SelectedItem) m_ScValue->SetNative(m_SelectedItem, true); - else m_ScValue->SetNULL(); + //if(_selectedItem) _scValue->SetString(_selectedItem->_name); + if (_selectedItem) _scValue->SetNative(_selectedItem, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumItems") == 0) { - return m_InvObject->ScGetProperty(Name); + return _invObject->ScGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// // SmartItemCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SmartItemCursor") == 0) { - m_ScValue->SetBool(m_SmartItemCursor); - return m_ScValue; + _scValue->SetBool(_smartItemCursor); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryVisible") == 0) { - m_ScValue->SetBool(m_InventoryBox && m_InventoryBox->m_Visible); - return m_ScValue; + _scValue->SetBool(_inventoryBox && _inventoryBox->_visible); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryScrollOffset") == 0) { - if (m_InventoryBox) m_ScValue->SetInt(m_InventoryBox->m_ScrollOffset); - else m_ScValue->SetInt(0); + if (_inventoryBox) _scValue->SetInt(_inventoryBox->_scrollOffset); + else _scValue->SetInt(0); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ResponsesVisible (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ResponsesVisible") == 0) { - m_ScValue->SetBool(m_StateEx == GAME_WAITING_RESPONSE); - return m_ScValue; + _scValue->SetBool(_stateEx == GAME_WAITING_RESPONSE); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PrevScene / PreviousScene (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PrevScene") == 0 || strcmp(Name, "PreviousScene") == 0) { - if (!m_PrevSceneName) m_ScValue->SetString(""); - else m_ScValue->SetString(m_PrevSceneName); - return m_ScValue; + if (!_prevSceneName) _scValue->SetString(""); + else _scValue->SetString(_prevSceneName); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PrevSceneFilename / PreviousSceneFilename (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PrevSceneFilename") == 0 || strcmp(Name, "PreviousSceneFilename") == 0) { - if (!m_PrevSceneFilename) m_ScValue->SetString(""); - else m_ScValue->SetString(m_PrevSceneFilename); - return m_ScValue; + if (!_prevSceneFilename) _scValue->SetString(""); + else _scValue->SetString(_prevSceneFilename); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LastResponse") == 0) { - if (!m_ResponseBox || !m_ResponseBox->m_LastResponseText) m_ScValue->SetString(""); - else m_ScValue->SetString(m_ResponseBox->m_LastResponseText); - return m_ScValue; + if (!_responseBox || !_responseBox->_lastResponseText) _scValue->SetString(""); + else _scValue->SetString(_responseBox->_lastResponseText); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LastResponseOrig") == 0) { - if (!m_ResponseBox || !m_ResponseBox->m_LastResponseTextOrig) m_ScValue->SetString(""); - else m_ScValue->SetString(m_ResponseBox->m_LastResponseTextOrig); - return m_ScValue; + if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->SetString(""); + else _scValue->SetString(_responseBox->_lastResponseTextOrig); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryObject") == 0) { - if (m_InventoryOwner == m_InvObject) m_ScValue->SetNative(this, true); - else m_ScValue->SetNative(m_InventoryOwner, true); + if (_inventoryOwner == _invObject) _scValue->SetNative(this, true); + else _scValue->SetNative(_inventoryOwner, true); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TotalNumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TotalNumItems") == 0) { - m_ScValue->SetInt(m_Items.GetSize()); - return m_ScValue; + _scValue->SetInt(_items.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TalkSkipButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TalkSkipButton") == 0) { - m_ScValue->SetInt(m_TalkSkipButton); - return m_ScValue; + _scValue->SetInt(_talkSkipButton); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ChangingScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ChangingScene") == 0) { - m_ScValue->SetBool(m_ScheduledScene != NULL); - return m_ScValue; + _scValue->SetBool(_scheduledScene != NULL); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // StartupScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StartupScene") == 0) { - if (!m_StartupScene) m_ScValue->SetNULL(); - else m_ScValue->SetString(m_StartupScene); - return m_ScValue; + if (!_startupScene) _scValue->SetNULL(); + else _scValue->SetString(_startupScene); + return _scValue; } else return CBGame::ScGetProperty(Name); @@ -958,19 +958,19 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { // SelectedItem ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "SelectedItem") == 0) { - if (Value->IsNULL()) m_SelectedItem = NULL; + if (Value->IsNULL()) _selectedItem = NULL; else { if (Value->IsNative()) { - m_SelectedItem = NULL; - for (int i = 0; i < m_Items.GetSize(); i++) { - if (m_Items[i] == Value->GetNative()) { - m_SelectedItem = (CAdItem *)Value->GetNative(); + _selectedItem = NULL; + for (int i = 0; i < _items.GetSize(); i++) { + if (_items[i] == Value->GetNative()) { + _selectedItem = (CAdItem *)Value->GetNative(); break; } } } else { // try to get by name - m_SelectedItem = GetItemByName(Value->GetString()); + _selectedItem = GetItemByName(Value->GetString()); } } @@ -981,7 +981,7 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { // SmartItemCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SmartItemCursor") == 0) { - m_SmartItemCursor = Value->GetBool(); + _smartItemCursor = Value->GetBool(); return S_OK; } @@ -989,7 +989,7 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryVisible") == 0) { - if (m_InventoryBox) m_InventoryBox->m_Visible = Value->GetBool(); + if (_inventoryBox) _inventoryBox->_visible = Value->GetBool(); return S_OK; } @@ -997,16 +997,16 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryObject") == 0) { - if (m_InventoryOwner && m_InventoryBox) m_InventoryOwner->GetInventory()->m_ScrollOffset = m_InventoryBox->m_ScrollOffset; + if (_inventoryOwner && _inventoryBox) _inventoryOwner->GetInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - if (Value->IsNULL()) m_InventoryOwner = m_InvObject; + if (Value->IsNULL()) _inventoryOwner = _invObject; else { CBObject *Obj = (CBObject *)Value->GetNative(); - if (Obj == this) m_InventoryOwner = m_InvObject; - else if (Game->ValidObject(Obj)) m_InventoryOwner = (CAdObject *)Obj; + if (Obj == this) _inventoryOwner = _invObject; + else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } - if (m_InventoryOwner && m_InventoryBox) m_InventoryBox->m_ScrollOffset = m_InventoryOwner->GetInventory()->m_ScrollOffset; + if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->GetInventory()->_scrollOffset; return S_OK; } @@ -1015,7 +1015,7 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryScrollOffset") == 0) { - if (m_InventoryBox) m_InventoryBox->m_ScrollOffset = Value->GetInt(); + if (_inventoryBox) _inventoryBox->_scrollOffset = Value->GetInt(); return S_OK; } @@ -1026,7 +1026,7 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { int Val = Value->GetInt(); if (Val < 0) Val = 0; if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; - m_TalkSkipButton = (TTalkSkipButton)Val; + _talkSkipButton = (TTalkSkipButton)Val; return S_OK; } @@ -1035,9 +1035,9 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StartupScene") == 0) { if (Value == NULL) { - delete[] m_StartupScene; - m_StartupScene = NULL; - } else CBUtils::SetString(&m_StartupScene, Value->GetString()); + delete[] _startupScene; + _startupScene = NULL; + } else CBUtils::SetString(&_startupScene, Value->GetString()); return S_OK; } @@ -1048,12 +1048,12 @@ HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// void CAdGame::PublishNatives() { - if (!m_ScEngine || !m_ScEngine->m_CompilerAvailable) return; + if (!_scEngine || !_scEngine->_compilerAvailable) return; CBGame::PublishNatives(); - m_ScEngine->ExtDefineFunction("Actor"); - m_ScEngine->ExtDefineFunction("Entity"); + _scEngine->ExtDefineFunction("Actor"); + _scEngine->ExtDefineFunction("Entity"); } @@ -1095,27 +1095,27 @@ HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ShowCursor() { - if (m_CursorHidden) return S_OK; + if (_cursorHidden) return S_OK; - if (m_SelectedItem && Game->m_State == GAME_RUNNING && m_StateEx == GAME_NORMAL && m_Interactive) { - if (m_SelectedItem->m_CursorCombined) { - CBSprite *OrigLastCursor = m_LastCursor; + if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem->_cursorCombined) { + CBSprite *OrigLastCursor = _lastCursor; CBGame::ShowCursor(); - m_LastCursor = OrigLastCursor; + _lastCursor = OrigLastCursor; } - if (m_ActiveObject && m_SelectedItem->m_CursorHover && m_ActiveObject->GetExtendedFlag("usable")) { - if (!m_SmartItemCursor || m_ActiveObject->CanHandleEvent(m_SelectedItem->m_Name)) - return DrawCursor(m_SelectedItem->m_CursorHover); + if (_activeObject && _selectedItem->_cursorHover && _activeObject->GetExtendedFlag("usable")) { + if (!_smartItemCursor || _activeObject->CanHandleEvent(_selectedItem->_name)) + return DrawCursor(_selectedItem->_cursorHover); else - return DrawCursor(m_SelectedItem->m_CursorNormal); - } else return DrawCursor(m_SelectedItem->m_CursorNormal); + return DrawCursor(_selectedItem->_cursorNormal); + } else return DrawCursor(_selectedItem->_cursorNormal); } else return CBGame::ShowCursor(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadFile(const char *Filename) { - byte *Buffer = m_FileManager->ReadWholeFile(Filename); + byte *Buffer = _fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -1123,8 +1123,8 @@ HRESULT CAdGame::LoadFile(const char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); @@ -1181,50 +1181,50 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { switch (cmd) { case TOKEN_RESPONSE_BOX: - delete m_ResponseBox; - m_ResponseBox = new CAdResponseBox(Game); - if (m_ResponseBox && !FAILED(m_ResponseBox->LoadFile((char *)params2))) - RegisterObject(m_ResponseBox); + delete _responseBox; + _responseBox = new CAdResponseBox(Game); + if (_responseBox && !FAILED(_responseBox->LoadFile((char *)params2))) + RegisterObject(_responseBox); else { - delete m_ResponseBox; - m_ResponseBox = NULL; + delete _responseBox; + _responseBox = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_INVENTORY_BOX: - delete m_InventoryBox; - m_InventoryBox = new CAdInventoryBox(Game); - if (m_InventoryBox && !FAILED(m_InventoryBox->LoadFile((char *)params2))) - RegisterObject(m_InventoryBox); + delete _inventoryBox; + _inventoryBox = new CAdInventoryBox(Game); + if (_inventoryBox && !FAILED(_inventoryBox->LoadFile((char *)params2))) + RegisterObject(_inventoryBox); else { - delete m_InventoryBox; - m_InventoryBox = NULL; + delete _inventoryBox; + _inventoryBox = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_ITEMS: ItemsFound = true; - CBUtils::SetString(&m_ItemsFile, (char *)params2); - if (FAILED(LoadItemsFile(m_ItemsFile))) { - delete[] m_ItemsFile; - m_ItemsFile = NULL; + CBUtils::SetString(&_itemsFile, (char *)params2); + if (FAILED(LoadItemsFile(_itemsFile))) { + delete[] _itemsFile; + _itemsFile = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) m_TalkSkipButton = TALK_SKIP_RIGHT; - else if (scumm_stricmp((char *)params2, "both") == 0) m_TalkSkipButton = TALK_SKIP_BOTH; - else m_TalkSkipButton = TALK_SKIP_LEFT; + if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; + else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; + else _talkSkipButton = TALK_SKIP_LEFT; break; case TOKEN_SCENE_VIEWPORT: { RECT rc; parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!m_SceneViewport) m_SceneViewport = new CBViewport(Game); - if (m_SceneViewport) m_SceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); + if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (_sceneViewport) _sceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); } break; @@ -1233,11 +1233,11 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_STARTUP_SCENE: - CBUtils::SetString(&m_StartupScene, (char *)params2); + CBUtils::SetString(&_startupScene, (char *)params2); break; case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::SetString(&m_DebugStartupScene, (char *)params2); + CBUtils::SetString(&_debugStartupScene, (char *)params2); break; } } @@ -1264,49 +1264,49 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->m_Saving) Cleanup(); + if (!PersistMgr->_saving) Cleanup(); CBGame::Persist(PersistMgr); - m_DlgPendingBranches.Persist(PersistMgr); + _dlgPendingBranches.Persist(PersistMgr); - m_Inventories.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_InventoryBox)); + _inventories.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_inventoryBox)); - m_Objects.Persist(PersistMgr); + _objects.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_PrevSceneName)); - PersistMgr->Transfer(TMEMBER(m_PrevSceneFilename)); + PersistMgr->Transfer(TMEMBER(_prevSceneName)); + PersistMgr->Transfer(TMEMBER(_prevSceneFilename)); - PersistMgr->Transfer(TMEMBER(m_ResponseBox)); - m_ResponsesBranch.Persist(PersistMgr); - m_ResponsesGame.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Scene)); - m_SceneStates.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ScheduledFadeIn)); - PersistMgr->Transfer(TMEMBER(m_ScheduledScene)); - PersistMgr->Transfer(TMEMBER(m_SelectedItem)); - PersistMgr->Transfer(TMEMBER_INT(m_TalkSkipButton)); + PersistMgr->Transfer(TMEMBER(_responseBox)); + _responsesBranch.Persist(PersistMgr); + _responsesGame.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scene)); + _sceneStates.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scheduledFadeIn)); + PersistMgr->Transfer(TMEMBER(_scheduledScene)); + PersistMgr->Transfer(TMEMBER(_selectedItem)); + PersistMgr->Transfer(TMEMBER_INT(_talkSkipButton)); - m_Sentences.Persist(PersistMgr); + _sentences.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_SceneViewport)); - PersistMgr->Transfer(TMEMBER_INT(m_StateEx)); - PersistMgr->Transfer(TMEMBER(m_InitialScene)); - PersistMgr->Transfer(TMEMBER(m_DebugStartupScene)); + PersistMgr->Transfer(TMEMBER(_sceneViewport)); + PersistMgr->Transfer(TMEMBER_INT(_stateEx)); + PersistMgr->Transfer(TMEMBER(_initialScene)); + PersistMgr->Transfer(TMEMBER(_debugStartupScene)); - PersistMgr->Transfer(TMEMBER(m_InvObject)); - PersistMgr->Transfer(TMEMBER(m_InventoryOwner)); - PersistMgr->Transfer(TMEMBER(m_TempDisableSaveState)); - m_Items.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_invObject)); + PersistMgr->Transfer(TMEMBER(_inventoryOwner)); + PersistMgr->Transfer(TMEMBER(_tempDisableSaveState)); + _items.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ItemsFile)); + PersistMgr->Transfer(TMEMBER(_itemsFile)); - m_SpeechDirs.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_SmartItemCursor)); + _speechDirs.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_smartItemCursor)); - if (!PersistMgr->m_Saving) m_InitialScene = false; + if (!PersistMgr->_saving) _initialScene = false; - PersistMgr->Transfer(TMEMBER(m_StartupScene)); + PersistMgr->Transfer(TMEMBER(_startupScene)); return S_OK; @@ -1335,37 +1335,37 @@ void CAdGame::AfterLoadScene(void *Scene, void *Data) { ////////////////////////////////////////////////////////////////////////// void CAdGame::SetPrevSceneName(char *Name) { - delete[] m_PrevSceneName; - m_PrevSceneName = NULL; + delete[] _prevSceneName; + _prevSceneName = NULL; if (Name) { - m_PrevSceneName = new char[strlen(Name) + 1]; - if (m_PrevSceneName) strcpy(m_PrevSceneName, Name); + _prevSceneName = new char[strlen(Name) + 1]; + if (_prevSceneName) strcpy(_prevSceneName, Name); } } ////////////////////////////////////////////////////////////////////////// void CAdGame::SetPrevSceneFilename(char *Name) { - delete[] m_PrevSceneFilename; - m_PrevSceneFilename = NULL; + delete[] _prevSceneFilename; + _prevSceneFilename = NULL; if (Name) { - m_PrevSceneFilename = new char[strlen(Name) + 1]; - if (m_PrevSceneFilename) strcpy(m_PrevSceneFilename, Name); + _prevSceneFilename = new char[strlen(Name) + 1]; + if (_prevSceneFilename) strcpy(_prevSceneFilename, Name); } } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ScheduleChangeScene(char *Filename, bool FadeIn) { - delete[] m_ScheduledScene; - m_ScheduledScene = NULL; + delete[] _scheduledScene; + _scheduledScene = NULL; - if (m_Scene && !m_Scene->m_Initialized) return ChangeScene(Filename, FadeIn); + if (_scene && !_scene->_initialized) return ChangeScene(Filename, FadeIn); else { - m_ScheduledScene = new char [strlen(Filename) + 1]; - strcpy(m_ScheduledScene, Filename); + _scheduledScene = new char [strlen(Filename) + 1]; + strcpy(_scheduledScene, Filename); - m_ScheduledFadeIn = FadeIn; + _scheduledFadeIn = FadeIn; return S_OK; } @@ -1385,7 +1385,7 @@ HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byt ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadItemsFile(char *Filename, bool Merge) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); return E_FAIL; @@ -1393,8 +1393,8 @@ HRESULT CAdGame::LoadItemsFile(char *Filename, bool Merge) { HRESULT ret; - //m_Filename = new char [strlen(Filename)+1]; - //strcpy(m_Filename, Filename); + //_filename = new char [strlen(Filename)+1]; + //strcpy(_filename, Filename); if (FAILED(ret = LoadItemsBuffer(Buffer, Merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", Filename); @@ -1416,7 +1416,7 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { CBParser parser(Game); if (!Merge) { - while (m_Items.GetSize() > 0) DeleteItem(m_Items[0]); + while (_items.GetSize() > 0) DeleteItem(_items[0]); } while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { @@ -1426,7 +1426,7 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { if (item && !FAILED(item->LoadBuffer(params, false))) { // delete item with the same name, if exists if (Merge) { - CAdItem *PrevItem = GetItemByName(item->m_Name); + CAdItem *PrevItem = GetItemByName(item->_name); if (PrevItem) DeleteItem(PrevItem); } AddItem(item); @@ -1461,10 +1461,10 @@ CAdSceneState *CAdGame::GetSceneState(char *Filename, bool Saving) { if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; } - for (int i = 0; i < m_SceneStates.GetSize(); i++) { - if (scumm_stricmp(m_SceneStates[i]->m_Filename, FilenameCor) == 0) { + for (int i = 0; i < _sceneStates.GetSize(); i++) { + if (scumm_stricmp(_sceneStates[i]->_filename, FilenameCor) == 0) { delete [] FilenameCor; - return m_SceneStates[i]; + return _sceneStates[i]; } } @@ -1472,7 +1472,7 @@ CAdSceneState *CAdGame::GetSceneState(char *Filename, bool Saving) { CAdSceneState *ret = new CAdSceneState(Game); ret->SetFilename(FilenameCor); - m_SceneStates.Add(ret); + _sceneStates.Add(ret); delete [] FilenameCor; return ret; @@ -1501,8 +1501,8 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ent = NULL; cmd = PARSERR_GENERIC; } else { - ent->m_Parent = Win; - Win->m_Widgets.Add(ent); + ent->_parent = Win; + Win->_widgets.Add(ent); } } break; @@ -1527,8 +1527,8 @@ HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScSt if (!Val->IsNULL()) Ent->SetName(Val->GetString()); Stack->PushNative(Ent, true); - Ent->m_Parent = Win; - Win->m_Widgets.Add(Ent); + Ent->_parent = Win; + Win->_widgets.Add(Ent); return S_OK; } else return E_FAIL; @@ -1540,7 +1540,7 @@ HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, char *Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; if (Name) { sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); - m_DlgPendingBranches.Add(Name); + _dlgPendingBranches.Add(Name); } return S_OK; } @@ -1550,8 +1550,8 @@ HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { char *Name = NULL; bool DeleteName = false; - if (BranchName == NULL && m_DlgPendingBranches.GetSize() > 0) { - Name = m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1]; + if (BranchName == NULL && _dlgPendingBranches.GetSize() > 0) { + Name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; } else { if (BranchName != NULL) { Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; @@ -1567,25 +1567,25 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co int StartIndex = -1; int i; - for (i = m_DlgPendingBranches.GetSize() - 1; i >= 0; i--) { - if (scumm_stricmp(Name, m_DlgPendingBranches[i]) == 0) { + for (i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { + if (scumm_stricmp(Name, _dlgPendingBranches[i]) == 0) { StartIndex = i; break; } } if (StartIndex >= 0) { - for (i = StartIndex; i < m_DlgPendingBranches.GetSize(); i++) { - //ClearBranchResponses(m_DlgPendingBranches[i]); - delete [] m_DlgPendingBranches[i]; - m_DlgPendingBranches[i] = NULL; + for (i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { + //ClearBranchResponses(_dlgPendingBranches[i]); + delete [] _dlgPendingBranches[i]; + _dlgPendingBranches[i] = NULL; } - m_DlgPendingBranches.RemoveAt(StartIndex, m_DlgPendingBranches.GetSize() - StartIndex); + _dlgPendingBranches.RemoveAt(StartIndex, _dlgPendingBranches.GetSize() - StartIndex); } // dialogue is over, forget selected responses - if (m_DlgPendingBranches.GetSize() == 0) { - for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; - m_ResponsesBranch.RemoveAll(); + if (_dlgPendingBranches.GetSize() == 0) { + for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); } if (DeleteName) delete [] Name; @@ -1596,10 +1596,10 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ClearBranchResponses(char *Name) { - for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) { - if (scumm_stricmp(Name, m_ResponsesBranch[i]->m_Context) == 0) { - delete m_ResponsesBranch[i]; - m_ResponsesBranch.RemoveAt(i); + for (int i = 0; i < _responsesBranch.GetSize(); i++) { + if (scumm_stricmp(Name, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.RemoveAt(i); i--; } } @@ -1611,19 +1611,19 @@ HRESULT CAdGame::ClearBranchResponses(char *Name) { HRESULT CAdGame::AddBranchResponse(int ID) { if (BranchResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); - r->m_ID = ID; - r->SetContext(m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL); - m_ResponsesBranch.Add(r); + r->_iD = ID; + r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + _responsesBranch.Add(r); return S_OK; } ////////////////////////////////////////////////////////////////////////// bool CAdGame::BranchResponseUsed(int ID) { - char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < m_ResponsesBranch.GetSize(); i++) { - if (m_ResponsesBranch[i]->m_ID == ID) { - if ((Context == NULL && m_ResponsesBranch[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesBranch[i]->m_Context) == 0) return true; + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < _responsesBranch.GetSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; } } return false; @@ -1634,20 +1634,20 @@ bool CAdGame::BranchResponseUsed(int ID) { HRESULT CAdGame::AddGameResponse(int ID) { if (GameResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); - r->m_ID = ID; - r->SetContext(m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL); - m_ResponsesGame.Add(r); + r->_iD = ID; + r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + _responsesGame.Add(r); return S_OK; } ////////////////////////////////////////////////////////////////////////// bool CAdGame::GameResponseUsed(int ID) { - char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < m_ResponsesGame.GetSize(); i++) { - CAdResponseContext *RespContext = m_ResponsesGame[i]; - if (RespContext->m_ID == ID) { - if ((Context == NULL && RespContext->m_Context == NULL) || ((Context != NULL && RespContext->m_Context != NULL) && scumm_stricmp(Context, RespContext->m_Context) == 0)) return true; + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < _responsesGame.GetSize(); i++) { + CAdResponseContext *RespContext = _responsesGame[i]; + if (RespContext->_iD == ID) { + if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; } } return false; @@ -1656,25 +1656,25 @@ bool CAdGame::GameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ResetResponse(int ID) { - char *Context = m_DlgPendingBranches.GetSize() > 0 ? m_DlgPendingBranches[m_DlgPendingBranches.GetSize() - 1] : NULL; + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; int i; - for (i = 0; i < m_ResponsesGame.GetSize(); i++) { - if (m_ResponsesGame[i]->m_ID == ID) { - if ((Context == NULL && m_ResponsesGame[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesGame[i]->m_Context) == 0) { - delete m_ResponsesGame[i]; - m_ResponsesGame.RemoveAt(i); + for (i = 0; i < _responsesGame.GetSize(); i++) { + if (_responsesGame[i]->_iD == ID) { + if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { + delete _responsesGame[i]; + _responsesGame.RemoveAt(i); break; } } } - for (i = 0; i < m_ResponsesBranch.GetSize(); i++) { - if (m_ResponsesBranch[i]->m_ID == ID) { - if ((Context == NULL && m_ResponsesBranch[i]->m_Context == NULL) || scumm_stricmp(Context, m_ResponsesBranch[i]->m_Context) == 0) { - delete m_ResponsesBranch[i]; - m_ResponsesBranch.RemoveAt(i); + for (i = 0; i < _responsesBranch.GetSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.RemoveAt(i); break; } } @@ -1689,47 +1689,47 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { if (Update) InitLoop(); // fill black - m_Renderer->Fill(0, 0, 0); - if (!m_EditorMode) m_Renderer->SetScreenViewport(); + _renderer->Fill(0, 0, 0); + if (!_editorMode) _renderer->SetScreenViewport(); // process scripts - if (Update) m_ScEngine->Tick(); + if (Update) _scEngine->Tick(); POINT p; GetMousePos(&p); - m_Scene->Update(); - m_Scene->Display(); + _scene->Update(); + _scene->Display(); // display in-game windows DisplayWindows(true); - if (m_InventoryBox) m_InventoryBox->Display(); - if (m_StateEx == GAME_WAITING_RESPONSE) m_ResponseBox->Display(); - if (m_IndicatorDisplay) DisplayIndicator(); + if (_inventoryBox) _inventoryBox->Display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); + if (_indicatorDisplay) DisplayIndicator(); if (Update || DisplayAll) { // display normal windows DisplayWindows(false); - SetActiveObject(Game->m_Renderer->GetObjectAt(p.x, p.y)); + SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); // textual info - DisplaySentences(m_State == GAME_FROZEN); + DisplaySentences(_state == GAME_FROZEN); ShowCursor(); - if (m_Fader) m_Fader->Display(); - m_TransMgr->Update(); + if (_fader) _fader->Display(); + _transMgr->Update(); } - if (m_LoadingIcon) { - m_LoadingIcon->Display(m_LoadingIconX, m_LoadingIconY); - if (!m_LoadingIconPersistent) { - delete m_LoadingIcon; - m_LoadingIcon = NULL; + if (_loadingIcon) { + _loadingIcon->Display(_loadingIconX, _loadingIconY); + if (!_loadingIconPersistent) { + delete _loadingIcon; + _loadingIcon = NULL; } } @@ -1738,21 +1738,21 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::RegisterInventory(CAdInventory *Inv) { - for (int i = 0; i < m_Inventories.GetSize(); i++) { - if (m_Inventories[i] == Inv) return S_OK; + for (int i = 0; i < _inventories.GetSize(); i++) { + if (_inventories[i] == Inv) return S_OK; } RegisterObject(Inv); - m_Inventories.Add(Inv); + _inventories.Add(Inv); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { - for (int i = 0; i < m_Inventories.GetSize(); i++) { - if (m_Inventories[i] == Inv) { - UnregisterObject(m_Inventories[i]); - m_Inventories.RemoveAt(i); + for (int i = 0; i < _inventories.GetSize(); i++) { + if (_inventories[i] == Inv) { + UnregisterObject(_inventories[i]); + _inventories.RemoveAt(i); return S_OK; } } @@ -1763,11 +1763,11 @@ HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { bool CAdGame::IsItemTaken(char *ItemName) { int i; - for (i = 0; i < m_Inventories.GetSize(); i++) { - CAdInventory *Inv = m_Inventories[i]; + for (i = 0; i < _inventories.GetSize(); i++) { + CAdInventory *Inv = _inventories[i]; - for (int j = 0; j < Inv->m_TakenItems.GetSize(); j++) { - if (scumm_stricmp(ItemName, Inv->m_TakenItems[j]->m_Name) == 0) { + for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + if (scumm_stricmp(ItemName, Inv->_takenItems[j]->_name) == 0) { return true; } } @@ -1777,8 +1777,8 @@ bool CAdGame::IsItemTaken(char *ItemName) { ////////////////////////////////////////////////////////////////////////// CAdItem *CAdGame::GetItemByName(char *Name) { - for (int i = 0; i < m_Items.GetSize(); i++) { - if (scumm_stricmp(m_Items[i]->m_Name, Name) == 0) return m_Items[i]; + for (int i = 0; i < _items.GetSize(); i++) { + if (scumm_stricmp(_items[i]->_name, Name) == 0) return _items[i]; } return NULL; } @@ -1786,7 +1786,7 @@ CAdItem *CAdGame::GetItemByName(char *Name) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::AddItem(CAdItem *Item) { - m_Items.Add(Item); + _items.Add(Item); return Game->RegisterObject(Item); } @@ -1796,33 +1796,33 @@ HRESULT CAdGame::ResetContent() { int i; // clear pending dialogs - for (i = 0; i < m_DlgPendingBranches.GetSize(); i++) { - delete [] m_DlgPendingBranches[i]; + for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + delete [] _dlgPendingBranches[i]; } - m_DlgPendingBranches.RemoveAll(); + _dlgPendingBranches.RemoveAll(); // clear inventories - for (i = 0; i < m_Inventories.GetSize(); i++) { - m_Inventories[i]->m_TakenItems.RemoveAll(); + for (i = 0; i < _inventories.GetSize(); i++) { + _inventories[i]->_takenItems.RemoveAll(); } // clear scene states - for (i = 0; i < m_SceneStates.GetSize(); i++) delete m_SceneStates[i]; - m_SceneStates.RemoveAll(); + for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; + _sceneStates.RemoveAll(); // clear once responses - for (i = 0; i < m_ResponsesBranch.GetSize(); i++) delete m_ResponsesBranch[i]; - m_ResponsesBranch.RemoveAll(); + for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); // clear once game responses - for (i = 0; i < m_ResponsesGame.GetSize(); i++) delete m_ResponsesGame[i]; - m_ResponsesGame.RemoveAll(); + for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; + _responsesGame.RemoveAll(); // reload inventory items - if (m_ItemsFile) LoadItemsFile(m_ItemsFile); + if (_itemsFile) LoadItemsFile(_itemsFile); - m_TempDisableSaveState = true; + _tempDisableSaveState = true; return CBGame::ResetContent(); } @@ -1832,19 +1832,19 @@ HRESULT CAdGame::ResetContent() { HRESULT CAdGame::DeleteItem(CAdItem *Item) { if (!Item) return E_FAIL; - if (m_SelectedItem == Item) m_SelectedItem = NULL; - m_Scene->HandleItemAssociations(Item->m_Name, false); + if (_selectedItem == Item) _selectedItem = NULL; + _scene->HandleItemAssociations(Item->_name, false); // remove from all inventories - for (int i = 0; i < m_Inventories.GetSize(); i++) { - m_Inventories[i]->RemoveItem(Item); + for (int i = 0; i < _inventories.GetSize(); i++) { + _inventories[i]->RemoveItem(Item); } // remove object - for (int i = 0; i < m_Items.GetSize(); i++) { - if (m_Items[i] == Item) { - UnregisterObject(m_Items[i]); - m_Items.RemoveAt(i); + for (int i = 0; i < _items.GetSize(); i++) { + if (_items[i] == Item) { + UnregisterObject(_items[i]); + _items.RemoveAt(i); break; } } @@ -1862,13 +1862,13 @@ HRESULT CAdGame::AddSpeechDir(const char *Dir) { if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') strcat(Temp, "\\"); - for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { - if (scumm_stricmp(m_SpeechDirs[i], Temp) == 0) { + for (int i = 0; i < _speechDirs.GetSize(); i++) { + if (scumm_stricmp(_speechDirs[i], Temp) == 0) { delete [] Temp; return S_OK; } } - m_SpeechDirs.Add(Temp); + _speechDirs.Add(Temp); return S_OK; } @@ -1884,10 +1884,10 @@ HRESULT CAdGame::RemoveSpeechDir(char *Dir) { strcat(Temp, "\\"); bool Found = false; - for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { - if (scumm_stricmp(m_SpeechDirs[i], Temp) == 0) { - delete [] m_SpeechDirs[i]; - m_SpeechDirs.RemoveAt(i); + for (int i = 0; i < _speechDirs.GetSize(); i++) { + if (scumm_stricmp(_speechDirs[i], Temp) == 0) { + delete [] _speechDirs[i]; + _speechDirs.RemoveAt(i); Found = true; break; } @@ -1903,18 +1903,18 @@ HRESULT CAdGame::RemoveSpeechDir(char *Dir) { char *CAdGame::FindSpeechFile(char *StringID) { char *Ret = new char[MAX_PATH]; - for (int i = 0; i < m_SpeechDirs.GetSize(); i++) { - sprintf(Ret, "%s%s.ogg", m_SpeechDirs[i], StringID); - CBFile *File = m_FileManager->OpenFile(Ret); + for (int i = 0; i < _speechDirs.GetSize(); i++) { + sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); + CBFile *File = _fileManager->OpenFile(Ret); if (File) { - m_FileManager->CloseFile(File); + _fileManager->CloseFile(File); return Ret; } - sprintf(Ret, "%s%s.wav", m_SpeechDirs[i], StringID); - File = m_FileManager->OpenFile(Ret); + sprintf(Ret, "%s%s.wav", _speechDirs[i], StringID); + File = _fileManager->OpenFile(Ret); if (File) { - m_FileManager->CloseFile(File); + _fileManager->CloseFile(File); return Ret; } } @@ -1928,51 +1928,51 @@ bool CAdGame::ValidMouse() { POINT Pos; CBPlatform::GetCursorPos(&Pos); - return m_Renderer->PointInViewport(&Pos); + return _renderer->PointInViewport(&Pos); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseLeftDown() { if (!ValidMouse()) return S_OK; - if (m_State == GAME_RUNNING && !m_Interactive) { - if (m_TalkSkipButton == TALK_SKIP_LEFT || m_TalkSkipButton == TALK_SKIP_BOTH) { + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { FinishSentences(); } return S_OK; } - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftClick"); - } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { - m_Scene->ApplyEvent("LeftClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftClick"); } } - if (m_ActiveObject != NULL) Game->m_CapturedObject = Game->m_ActiveObject; - m_MouseLeftDown = true; - CBPlatform::SetCapture(m_Renderer->m_Window); + if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; + _mouseLeftDown = true; + CBPlatform::SetCapture(_renderer->_window); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseLeftUp() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); - m_CapturedObject = NULL; - m_MouseLeftDown = false; + _capturedObject = NULL; + _mouseLeftDown = false; - bool Handled = /*m_State==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); + bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftRelease"); - } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { - m_Scene->ApplyEvent("LeftRelease"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftRelease"); } } return S_OK; @@ -1982,16 +1982,16 @@ HRESULT CAdGame::OnMouseLeftUp() { HRESULT CAdGame::OnMouseLeftDblClick() { if (!ValidMouse()) return S_OK; - if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftDoubleClick"); - } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { - m_Scene->ApplyEvent("LeftDoubleClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftDoubleClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftDoubleClick"); } } return S_OK; @@ -2000,23 +2000,23 @@ HRESULT CAdGame::OnMouseLeftDblClick() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseRightDown() { if (!ValidMouse()) return S_OK; - if (m_State == GAME_RUNNING && !m_Interactive) { - if (m_TalkSkipButton == TALK_SKIP_RIGHT || m_TalkSkipButton == TALK_SKIP_BOTH) { + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { FinishSentences(); } return S_OK; } - if ((m_State == GAME_RUNNING && !m_Interactive) || m_StateEx == GAME_WAITING_RESPONSE) return S_OK; + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return S_OK; - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("RightClick"); - } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { - m_Scene->ApplyEvent("RightClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("RightClick"); } } return S_OK; @@ -2024,14 +2024,14 @@ HRESULT CAdGame::OnMouseRightDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseRightUp() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("RightRelease"); - } else if (m_State == GAME_RUNNING && m_Scene && m_Scene->PointInViewport(m_MousePos.x, m_MousePos.y)) { - m_Scene->ApplyEvent("RightRelease"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("RightRelease"); } } return S_OK; @@ -2040,12 +2040,12 @@ HRESULT CAdGame::OnMouseRightUp() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::DisplayDebugInfo() { char str[100]; - if (Game->m_DEBUG_DebugMode) { - sprintf(str, "Mouse: %d, %d (scene: %d, %d)", m_MousePos.x, m_MousePos.y, m_MousePos.x + m_Scene->GetOffsetLeft(), m_MousePos.y + m_Scene->GetOffsetTop()); - m_SystemFont->DrawText((byte *)str, 0, 90, m_Renderer->m_Width, TAL_RIGHT); + if (Game->_dEBUG_DebugMode) { + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->GetOffsetLeft(), _mousePos.y + _scene->GetOffsetTop()); + _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - sprintf(str, "Scene: %s (prev: %s)", (m_Scene && m_Scene->m_Name) ? m_Scene->m_Name : "???", m_PrevSceneName ? m_PrevSceneName : "???"); - m_SystemFont->DrawText((byte *)str, 0, 110, m_Renderer->m_Width, TAL_RIGHT); + sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); + _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } return CBGame::DisplayDebugInfo(); } @@ -2053,8 +2053,8 @@ HRESULT CAdGame::DisplayDebugInfo() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnScriptShutdown(CScScript *Script) { - if (m_ResponseBox && m_ResponseBox->m_WaitingScript == Script) - m_ResponseBox->m_WaitingScript = NULL; + if (_responseBox && _responseBox->_waitingScript == Script) + _responseBox->_waitingScript = NULL; return S_OK; } diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index d879d9e045..fd943f6fcf 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -58,31 +58,31 @@ public: virtual HRESULT InitAfterLoad(); static void AfterLoadScene(void *Scene, void *Data); - bool m_SmartItemCursor; + bool _smartItemCursor; - CBArray m_SpeechDirs; + CBArray _speechDirs; HRESULT AddSpeechDir(const char *Dir); HRESULT RemoveSpeechDir(char *Dir); char *FindSpeechFile(char *StringID); HRESULT DeleteItem(CAdItem *Item); - char *m_ItemsFile; - bool m_TempDisableSaveState; + char *_itemsFile; + bool _tempDisableSaveState; virtual HRESULT ResetContent(); HRESULT AddItem(CAdItem *Item); CAdItem *GetItemByName(char *Name); - CBArray m_Items; - CAdObject *m_InventoryOwner; + CBArray _items; + CAdObject *_inventoryOwner; bool IsItemTaken(char *ItemName); HRESULT RegisterInventory(CAdInventory *Inv); HRESULT UnregisterInventory(CAdInventory *Inv); - CAdObject *m_InvObject; - CBArray m_Inventories; + CAdObject *_invObject; + CBArray _inventories; virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); - char *m_DebugStartupScene; - char *m_StartupScene; - bool m_InitialScene; + char *_debugStartupScene; + char *_startupScene; + bool _initialScene; bool GameResponseUsed(int ID); HRESULT AddGameResponse(int ID); HRESULT ResetResponse(int ID); @@ -96,49 +96,49 @@ public: virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); CAdSceneState *GetSceneState(char *Filename, bool Saving); - CBViewport *m_SceneViewport; - int m_TexItemLifeTime; - int m_TexWalkLifeTime; - int m_TexStandLifeTime; - int m_TexTalkLifeTime; + CBViewport *_sceneViewport; + int _texItemLifeTime; + int _texWalkLifeTime; + int _texStandLifeTime; + int _texTalkLifeTime; - TTalkSkipButton m_TalkSkipButton; + TTalkSkipButton _talkSkipButton; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); HRESULT ScheduleChangeScene(char *Filename, bool FadeIn); - char *m_ScheduledScene; - bool m_ScheduledFadeIn; + char *_scheduledScene; + bool _scheduledFadeIn; void SetPrevSceneName(char *Name); void SetPrevSceneFilename(char *Name); - char *m_PrevSceneName; - char *m_PrevSceneFilename; + char *_prevSceneName; + char *_prevSceneFilename; virtual HRESULT LoadGame(char *Filename); - CAdItem *m_SelectedItem; + CAdItem *_selectedItem; HRESULT Cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) void FinishSentences(); HRESULT ShowCursor(); - TGameStateEx m_StateEx; - CAdResponseBox *m_ResponseBox; - CAdInventoryBox *m_InventoryBox; + TGameStateEx _stateEx; + CAdResponseBox *_responseBox; + CAdInventoryBox *_inventoryBox; HRESULT DisplaySentences(bool Frozen); void AddSentence(CAdSentence *Sentence); HRESULT ChangeScene(char *Filename, bool FadeIn); HRESULT RemoveObject(CAdObject *Object); HRESULT AddObject(CAdObject *Object); - CAdScene *m_Scene; + CAdScene *_scene; HRESULT InitLoop(); CAdGame(); virtual ~CAdGame(); - CBArray m_Objects; - CBArray m_Sentences; + CBArray _objects; + CBArray _sentences; - CBArray m_SceneStates; - CBArray m_DlgPendingBranches; + CBArray _sceneStates; + CBArray _dlgPendingBranches; - CBArray m_ResponsesBranch; - CBArray m_ResponsesGame; + CBArray _responsesBranch; + CBArray _responsesGame; virtual HRESULT LoadFile(const char *Filename); virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp index 6723c6fe70..a7024523a8 100644 --- a/engines/wintermute/AdInventory.cpp +++ b/engines/wintermute/AdInventory.cpp @@ -38,13 +38,13 @@ IMPLEMENT_PERSISTENT(CAdInventory, false) ////////////////////////////////////////////////////////////////////////// CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { - m_ScrollOffset = 0; + _scrollOffset = 0; } ////////////////////////////////////////////////////////////////////////// CAdInventory::~CAdInventory() { - m_TakenItems.RemoveAll(); // ref only + _takenItems.RemoveAll(); // ref only } @@ -56,18 +56,18 @@ HRESULT CAdInventory::InsertItem(char *Name, char *InsertAfter) { if (item == NULL) return E_FAIL; int InsertIndex = -1; - for (int i = 0; i < m_TakenItems.GetSize(); i++) { - if (scumm_stricmp(m_TakenItems[i]->m_Name, Name) == 0) { - m_TakenItems.RemoveAt(i); + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + _takenItems.RemoveAt(i); i--; continue; } - if (InsertAfter && scumm_stricmp(m_TakenItems[i]->m_Name, InsertAfter) == 0) InsertIndex = i + 1; + if (InsertAfter && scumm_stricmp(_takenItems[i]->_name, InsertAfter) == 0) InsertIndex = i + 1; } - if (InsertIndex == -1) m_TakenItems.Add(item); - else m_TakenItems.InsertAt(InsertIndex, item); + if (InsertIndex == -1) _takenItems.Add(item); + else _takenItems.InsertAt(InsertIndex, item); return S_OK; } @@ -77,10 +77,10 @@ HRESULT CAdInventory::InsertItem(char *Name, char *InsertAfter) { HRESULT CAdInventory::RemoveItem(char *Name) { if (Name == NULL) return E_FAIL; - for (int i = 0; i < m_TakenItems.GetSize(); i++) { - if (scumm_stricmp(m_TakenItems[i]->m_Name, Name) == 0) { - if (((CAdGame *)Game)->m_SelectedItem == m_TakenItems[i])((CAdGame *)Game)->m_SelectedItem = NULL; - m_TakenItems.RemoveAt(i); + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + _takenItems.RemoveAt(i); return S_OK; } } @@ -94,10 +94,10 @@ HRESULT CAdInventory::RemoveItem(char *Name) { HRESULT CAdInventory::RemoveItem(CAdItem *Item) { if (Item == NULL) return E_FAIL; - for (int i = 0; i < m_TakenItems.GetSize(); i++) { - if (m_TakenItems[i] == Item) { - if (((CAdGame *)Game)->m_SelectedItem == m_TakenItems[i])((CAdGame *)Game)->m_SelectedItem = NULL; - m_TakenItems.RemoveAt(i); + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (_takenItems[i] == Item) { + if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + _takenItems.RemoveAt(i); return S_OK; } } @@ -110,8 +110,8 @@ HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - m_TakenItems.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); + _takenItems.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); return S_OK; } diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h index 828c37e964..159886aa2f 100644 --- a/engines/wintermute/AdInventory.h +++ b/engines/wintermute/AdInventory.h @@ -43,8 +43,8 @@ public: HRESULT InsertItem(char *Name, char *InsertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); - CBArray m_TakenItems; - int m_ScrollOffset; + CBArray _takenItems; + int _scrollOffset; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index 5af10d5f86..5ab011c5dc 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -48,28 +48,28 @@ IMPLEMENT_PERSISTENT(CAdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - CBPlatform::SetRectEmpty(&m_ItemsArea); - m_ScrollOffset = 0; - m_Spacing = 0; - m_ItemWidth = m_ItemHeight = 50; - m_ScrollBy = 1; + CBPlatform::SetRectEmpty(&_itemsArea); + _scrollOffset = 0; + _spacing = 0; + _itemWidth = _itemHeight = 50; + _scrollBy = 1; - m_Window = NULL; - m_CloseButton = NULL; + _window = NULL; + _closeButton = NULL; - m_HideSelected = false; + _hideSelected = false; - m_Visible = false; - m_Exclusive = false; + _visible = false; + _exclusive = false; } ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::~CAdInventoryBox() { - Game->UnregisterObject(m_Window); - m_Window = NULL; + Game->UnregisterObject(_window); + _window = NULL; - SAFE_DELETE(m_CloseButton); + SAFE_DELETE(_closeButton); } @@ -77,15 +77,15 @@ CAdInventoryBox::~CAdInventoryBox() { HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; - switch (obj->m_Type) { + switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->m_Name, "close") == 0) { - m_Visible = false; - } else if (scumm_stricmp(obj->m_Name, "prev") == 0) { - m_ScrollOffset -= m_ScrollBy; - m_ScrollOffset = std::max(m_ScrollOffset, 0); - } else if (scumm_stricmp(obj->m_Name, "next") == 0) { - m_ScrollOffset += m_ScrollBy; + if (scumm_stricmp(obj->_name, "close") == 0) { + _visible = false; + } else if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset -= _scrollBy; + _scrollOffset = std::max(_scrollOffset, 0); + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset += _scrollBy; } else return CBObject::Listen(param1, param2); break; } @@ -98,54 +98,54 @@ HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { HRESULT CAdInventoryBox::Display() { CAdGame *AdGame = (CAdGame *)Game; - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; int ItemsX, ItemsY; - ItemsX = floor((float)((m_ItemsArea.right - m_ItemsArea.left + m_Spacing) / (m_ItemWidth + m_Spacing))); - ItemsY = floor((float)((m_ItemsArea.bottom - m_ItemsArea.top + m_Spacing) / (m_ItemHeight + m_Spacing))); + ItemsX = floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + ItemsY = floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); - if (m_Window) { - m_Window->EnableWidget("prev", m_ScrollOffset > 0); - m_Window->EnableWidget("next", m_ScrollOffset + ItemsX * ItemsY < AdGame->m_InventoryOwner->GetInventory()->m_TakenItems.GetSize()); + if (_window) { + _window->EnableWidget("prev", _scrollOffset > 0); + _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()); } - if (m_CloseButton) { - m_CloseButton->m_PosX = m_CloseButton->m_PosY = 0; - m_CloseButton->m_Width = Game->m_Renderer->m_Width; - m_CloseButton->m_Height = Game->m_Renderer->m_Height; + if (_closeButton) { + _closeButton->_posX = _closeButton->_posY = 0; + _closeButton->_width = Game->_renderer->_width; + _closeButton->_height = Game->_renderer->_height; - m_CloseButton->Display(); + _closeButton->Display(); } // display window - RECT rect = m_ItemsArea; - if (m_Window) { - CBPlatform::OffsetRect(&rect, m_Window->m_PosX, m_Window->m_PosY); - m_Window->Display(); + RECT rect = _itemsArea; + if (_window) { + CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + _window->Display(); } // display items - if (m_Window && m_Window->m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = m_Window->m_AlphaColor; + if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor; int yyy = rect.top; for (int j = 0; j < ItemsY; j++) { int xxx = rect.left; for (int i = 0; i < ItemsX; i++) { - int ItemIndex = m_ScrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < AdGame->m_InventoryOwner->GetInventory()->m_TakenItems.GetSize()) { - CAdItem *item = AdGame->m_InventoryOwner->GetInventory()->m_TakenItems[ItemIndex]; - if (item != ((CAdGame *)Game)->m_SelectedItem || !m_HideSelected) { + int ItemIndex = _scrollOffset + j * ItemsX + i; + if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()) { + CAdItem *item = AdGame->_inventoryOwner->GetInventory()->_takenItems[ItemIndex]; + if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { item->Update(); item->Display(xxx, yyy); } } - xxx += (m_ItemWidth + m_Spacing); + xxx += (_itemWidth + _spacing); } - yyy += (m_ItemHeight + m_Spacing); + yyy += (_itemHeight + _spacing); } - if (m_Window && m_Window->m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = 0; + if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; return S_OK; } @@ -153,7 +153,7 @@ HRESULT CAdInventoryBox::Display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdInventoryBox::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -161,8 +161,8 @@ HRESULT CAdInventoryBox::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); @@ -213,7 +213,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { CBParser parser(Game); bool always_visible = false; - m_Exclusive = false; + _exclusive = false; if (Complete) { if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { Game->LOG(0, "'INVENTORY_BOX' keyword expected."); @@ -237,24 +237,24 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WINDOW: - SAFE_DELETE(m_Window); - m_Window = new CUIWindow(Game); - if (!m_Window || FAILED(m_Window->LoadBuffer(params, false))) { - SAFE_DELETE(m_Window); + SAFE_DELETE(_window); + _window = new CUIWindow(Game); + if (!_window || FAILED(_window->LoadBuffer(params, false))) { + SAFE_DELETE(_window); cmd = PARSERR_GENERIC; - } else Game->RegisterObject(m_Window); + } else Game->RegisterObject(_window); break; case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_ItemsArea.left, &m_ItemsArea.top, &m_ItemsArea.right, &m_ItemsArea.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); break; case TOKEN_EXCLUSIVE: - parser.ScanStr((char *)params, "%b", &m_Exclusive); + parser.ScanStr((char *)params, "%b", &_exclusive); break; case TOKEN_HIDE_SELECTED: - parser.ScanStr((char *)params, "%b", &m_HideSelected); + parser.ScanStr((char *)params, "%b", &_hideSelected); break; case TOKEN_ALWAYS_VISIBLE: @@ -262,19 +262,19 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &m_Spacing); + parser.ScanStr((char *)params, "%d", &_spacing); break; case TOKEN_ITEM_WIDTH: - parser.ScanStr((char *)params, "%d", &m_ItemWidth); + parser.ScanStr((char *)params, "%d", &_itemWidth); break; case TOKEN_ITEM_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_ItemHeight); + parser.ScanStr((char *)params, "%d", &_itemHeight); break; case TOKEN_SCROLL_BY: - parser.ScanStr((char *)params, "%d", &m_ScrollBy); + parser.ScanStr((char *)params, "%d", &_scrollBy); break; case TOKEN_EDITOR_PROPERTY: @@ -291,22 +291,22 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (m_Exclusive) { - SAFE_DELETE(m_CloseButton); - m_CloseButton = new CUIButton(Game); - if (m_CloseButton) { - m_CloseButton->SetName("close"); - m_CloseButton->SetListener(this, m_CloseButton, 0); - m_CloseButton->m_Parent = m_Window; + if (_exclusive) { + SAFE_DELETE(_closeButton); + _closeButton = new CUIButton(Game); + if (_closeButton) { + _closeButton->SetName("close"); + _closeButton->SetListener(this, _closeButton, 0); + _closeButton->_parent = _window; } } - m_Visible = always_visible; + _visible = always_visible; - if (m_Window) { - for (int i = 0; i < m_Window->m_Widgets.GetSize(); i++) { - if (!m_Window->m_Widgets[i]->m_ListenerObject) - m_Window->m_Widgets[i]->SetListener(this, m_Window->m_Widgets[i], 0); + if (_window) { + for (int i = 0; i < _window->_widgets.GetSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); } } @@ -318,23 +318,23 @@ HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", m_ItemsArea.left, m_ItemsArea.top, m_ItemsArea.right, m_ItemsArea.bottom); + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", m_Exclusive ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", m_HideSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", m_Spacing); - Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", m_ItemWidth); - Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", m_ItemHeight); - Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", m_ScrollBy); + Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); Buffer->PutTextIndent(Indent + 2, "\n"); // window - if (m_Window) m_Window->SaveAsText(Buffer, Indent + 2); + if (_window) _window->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -350,17 +350,17 @@ HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CAdInventoryBox::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_CloseButton)); - PersistMgr->Transfer(TMEMBER(m_HideSelected)); - PersistMgr->Transfer(TMEMBER(m_ItemHeight)); - PersistMgr->Transfer(TMEMBER(m_ItemsArea)); - PersistMgr->Transfer(TMEMBER(m_ItemWidth)); - PersistMgr->Transfer(TMEMBER(m_ScrollBy)); - PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); - PersistMgr->Transfer(TMEMBER(m_Spacing)); - PersistMgr->Transfer(TMEMBER(m_Visible)); - PersistMgr->Transfer(TMEMBER(m_Window)); - PersistMgr->Transfer(TMEMBER(m_Exclusive)); + PersistMgr->Transfer(TMEMBER(_closeButton)); + PersistMgr->Transfer(TMEMBER(_hideSelected)); + PersistMgr->Transfer(TMEMBER(_itemHeight)); + PersistMgr->Transfer(TMEMBER(_itemsArea)); + PersistMgr->Transfer(TMEMBER(_itemWidth)); + PersistMgr->Transfer(TMEMBER(_scrollBy)); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_spacing)); + PersistMgr->Transfer(TMEMBER(_visible)); + PersistMgr->Transfer(TMEMBER(_window)); + PersistMgr->Transfer(TMEMBER(_exclusive)); return S_OK; } diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h index 94cb40dbf6..724a6298f4 100644 --- a/engines/wintermute/AdInventoryBox.h +++ b/engines/wintermute/AdInventoryBox.h @@ -37,20 +37,20 @@ class CUIWindow; class CAdInventoryBox : public CBObject { public: - bool m_HideSelected; + bool _hideSelected; DECLARE_PERSISTENT(CAdInventoryBox, CBObject) - bool m_Exclusive; - int m_ScrollBy; - int m_ItemHeight; - int m_ItemWidth; - bool m_Visible; + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; + bool _visible; virtual HRESULT Display(); - CUIButton *m_CloseButton; - int m_Spacing; - int m_ScrollOffset; - RECT m_ItemsArea; + CUIButton *_closeButton; + int _spacing; + int _scrollOffset; + RECT _itemsArea; HRESULT Listen(CBScriptHolder *param1, uint32 param2); - CUIWindow *m_Window; + CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); HRESULT LoadFile(char *Filename); diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index a1cf0d5b01..d4746015d8 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -50,42 +50,42 @@ IMPLEMENT_PERSISTENT(CAdItem, false) ////////////////////////////////////////////////////////////////////////// CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { - m_SpriteHover = NULL; - m_CursorNormal = m_CursorHover = NULL; + _spriteHover = NULL; + _cursorNormal = _cursorHover = NULL; - m_CursorCombined = true; - m_InInventory = false; + _cursorCombined = true; + _inInventory = false; - m_DisplayAmount = false; - m_Amount = 0; - m_AmountOffsetX = 0; - m_AmountOffsetY = 0; - m_AmountAlign = TAL_RIGHT; - m_AmountString = NULL; + _displayAmount = false; + _amount = 0; + _amountOffsetX = 0; + _amountOffsetY = 0; + _amountAlign = TAL_RIGHT; + _amountString = NULL; - m_State = STATE_READY; + _state = STATE_READY; - m_Movable = false; + _movable = false; } ////////////////////////////////////////////////////////////////////////// CAdItem::~CAdItem() { - delete m_SpriteHover; - delete m_CursorNormal; - delete m_CursorHover; - m_SpriteHover = NULL; - m_CursorNormal = NULL; - m_CursorHover = NULL; - - delete[] m_AmountString; - m_AmountString = NULL; + delete _spriteHover; + delete _cursorNormal; + delete _cursorHover; + _spriteHover = NULL; + _cursorNormal = NULL; + _cursorHover = NULL; + + delete[] _amountString; + _amountString = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdItem::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -93,8 +93,8 @@ HRESULT CAdItem::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); @@ -197,86 +197,86 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: case TOKEN_SPRITE: - delete m_Sprite; - m_Sprite = new CBSprite(Game, this); - if (!m_Sprite || FAILED(m_Sprite->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { - delete m_Sprite; + delete _sprite; + _sprite = new CBSprite(Game, this); + if (!_sprite || FAILED(_sprite->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _sprite; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_HOVER: case TOKEN_SPRITE_HOVER: - delete m_SpriteHover; - m_SpriteHover = new CBSprite(Game, this); - if (!m_SpriteHover || FAILED(m_SpriteHover->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { - delete m_SpriteHover; + delete _spriteHover; + _spriteHover = new CBSprite(Game, this); + if (!_spriteHover || FAILED(_spriteHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _spriteHover; cmd = PARSERR_GENERIC; } break; case TOKEN_AMOUNT: - parser.ScanStr((char *)params, "%d", &m_Amount); + parser.ScanStr((char *)params, "%d", &_amount); break; case TOKEN_DISPLAY_AMOUNT: - parser.ScanStr((char *)params, "%b", &m_DisplayAmount); + parser.ScanStr((char *)params, "%b", &_displayAmount); break; case TOKEN_AMOUNT_OFFSET_X: - parser.ScanStr((char *)params, "%d", &m_AmountOffsetX); + parser.ScanStr((char *)params, "%d", &_amountOffsetX); break; case TOKEN_AMOUNT_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &m_AmountOffsetY); + parser.ScanStr((char *)params, "%d", &_amountOffsetY); break; case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) m_AmountAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) m_AmountAlign = TAL_RIGHT; - else m_AmountAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; + else _amountAlign = TAL_CENTER; break; case TOKEN_AMOUNT_STRING: - CBUtils::SetString(&m_AmountString, (char *)params); + CBUtils::SetString(&_amountString, (char *)params); break; case TOKEN_TALK: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSprites.Add(spr); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->m_TexTalkLifeTime))) cmd = PARSERR_GENERIC; - else m_TalkSpritesEx.Add(spr); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); } break; case TOKEN_CURSOR: - delete m_CursorNormal; - m_CursorNormal = new CBSprite(Game); - if (!m_CursorNormal || FAILED(m_CursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { - delete m_CursorNormal; - m_CursorNormal = NULL; + delete _cursorNormal; + _cursorNormal = new CBSprite(Game); + if (!_cursorNormal || FAILED(_cursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _cursorNormal; + _cursorNormal = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_CURSOR_HOVER: - delete m_CursorHover; - m_CursorHover = new CBSprite(Game); - if (!m_CursorHover || FAILED(m_CursorHover->LoadFile((char *)params, ((CAdGame *)Game)->m_TexItemLifeTime))) { - delete m_CursorHover; - m_CursorHover = NULL; + delete _cursorHover; + _cursorHover = new CBSprite(Game); + if (!_cursorHover || FAILED(_cursorHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _cursorHover; + _cursorHover = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_CURSOR_COMBINED: - parser.ScanStr((char *)params, "%b", &m_CursorCombined); + parser.ScanStr((char *)params, "%b", &_cursorCombined); break; case TOKEN_SCRIPT: @@ -312,7 +312,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - m_AlphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = DRGBA(ar, ag, ab, alpha); return S_OK; } @@ -320,65 +320,65 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdItem::Update() { - m_CurrentSprite = NULL; + _currentSprite = NULL; - if (m_State == STATE_READY && m_AnimSprite) { - delete m_AnimSprite; - m_AnimSprite = NULL; + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; } // finished playing animation? - if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL && m_AnimSprite->m_Finished) { - m_State = STATE_READY; - m_CurrentSprite = m_AnimSprite; + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; } - if (m_Sentence && m_State != STATE_TALKING) m_Sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); // default: stand animation - if (!m_CurrentSprite) m_CurrentSprite = m_Sprite; + if (!_currentSprite) _currentSprite = _sprite; - switch (m_State) { + switch (_state) { ////////////////////////////////////////////////////////////////////////// case STATE_PLAYING_ANIM: - m_CurrentSprite = m_AnimSprite; + _currentSprite = _animSprite; break; ////////////////////////////////////////////////////////////////////////// case STATE_READY: - if (!m_AnimSprite) { - if (Game->m_ActiveObject == this && m_SpriteHover) m_CurrentSprite = m_SpriteHover; - else m_CurrentSprite = m_Sprite; + if (!_animSprite) { + if (Game->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; + else _currentSprite = _sprite; } break; ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - m_Sentence->Update(); - if (m_Sentence->m_CurrentSprite) m_TempSprite2 = m_Sentence->m_CurrentSprite; + _sentence->Update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (m_Sentence->m_Sound && m_Sentence->m_SoundStarted && (!m_Sentence->m_Sound->IsPlaying() && !m_Sentence->m_Sound->IsPaused())) || (!m_Sentence->m_Sound && m_Sentence->m_Duration <= Game->m_Timer - m_Sentence->m_StartTime); - if (m_TempSprite2 == NULL || m_TempSprite2->m_Finished || (/*m_TempSprite2->m_Looping &&*/ TimeIsUp)) { + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - m_Sentence->Finish(); - m_TempSprite2 = NULL; - m_State = STATE_READY; + _sentence->Finish(); + _tempSprite2 = NULL; + _state = STATE_READY; } else { - m_TempSprite2 = GetTalkStance(m_Sentence->GetNextStance()); - if (m_TempSprite2) { - m_TempSprite2->Reset(); - m_CurrentSprite = m_TempSprite2; + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->AddSentence(m_Sentence); + ((CAdGame *)Game)->AddSentence(_sentence); } } else { - m_CurrentSprite = m_TempSprite2; - ((CAdGame *)Game)->AddSentence(m_Sentence); + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); } } break; } - m_Ready = (m_State == STATE_READY); + _ready = (_state == STATE_READY); return S_OK; } @@ -387,36 +387,36 @@ HRESULT CAdItem::Update() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdItem::Display(int X, int Y) { int Width = 0; - if (m_CurrentSprite) { + if (_currentSprite) { RECT rc; - m_CurrentSprite->GetBoundingRect(&rc, 0, 0); + _currentSprite->GetBoundingRect(&rc, 0, 0); Width = rc.right - rc.left; } - m_PosX = X + Width / 2; - m_PosY = Y; + _posX = X + Width / 2; + _posY = Y; HRESULT ret; - if (m_CurrentSprite) ret = m_CurrentSprite->Draw(X, Y, this, 100, 100, m_AlphaColor); + if (_currentSprite) ret = _currentSprite->Draw(X, Y, this, 100, 100, _alphaColor); else ret = S_OK; - if (m_DisplayAmount) { + if (_displayAmount) { int AmountX = X; - int AmountY = Y + m_AmountOffsetY; + int AmountY = Y + _amountOffsetY; - if (m_AmountAlign == TAL_RIGHT) { - Width -= m_AmountOffsetX; - AmountX -= m_AmountOffsetX; + if (_amountAlign == TAL_RIGHT) { + Width -= _amountOffsetX; + AmountX -= _amountOffsetX; } - AmountX += m_AmountOffsetX; + AmountX += _amountOffsetX; - CBFont *Font = m_Font ? m_Font : Game->m_SystemFont; + CBFont *Font = _font ? _font : Game->_systemFont; if (Font) { - if (m_AmountString) Font->DrawText((byte *)m_AmountString, AmountX, AmountY, Width, m_AmountAlign); + if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); else { char Str[256]; - sprintf(Str, "%d", m_Amount); - Font->DrawText((byte *)Str, AmountX, AmountY, Width, m_AmountAlign); + sprintf(Str, "%d", _amount); + Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); } } } @@ -436,19 +436,19 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); bool SetCurrent = false; - if (m_CurrentSprite && m_CurrentSprite == m_SpriteHover) SetCurrent = true; + if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; char *Filename = Stack->Pop()->GetString(); - delete m_SpriteHover; - m_SpriteHover = NULL; + delete _spriteHover; + _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); } else { - m_SpriteHover = spr; - if (SetCurrent) m_CurrentSprite = m_SpriteHover; + _spriteHover = spr; + if (SetCurrent) _currentSprite = _spriteHover; Stack->PushBool(true); } return S_OK; @@ -460,8 +460,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetHoverSprite") == 0) { Stack->CorrectParams(0); - if (!m_SpriteHover || !m_SpriteHover->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_SpriteHover->m_Filename); + if (!_spriteHover || !_spriteHover->_filename) Stack->PushNULL(); + else Stack->PushString(_spriteHover->_filename); return S_OK; } @@ -470,8 +470,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetHoverSpriteObject") == 0) { Stack->CorrectParams(0); - if (!m_SpriteHover) Stack->PushNULL(); - else Stack->PushNative(m_SpriteHover, true); + if (!_spriteHover) Stack->PushNULL(); + else Stack->PushNative(_spriteHover, true); return S_OK; } @@ -483,14 +483,14 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This char *Filename = Stack->Pop()->GetString(); - delete m_CursorNormal; - m_CursorNormal = NULL; + delete _cursorNormal; + _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->LoadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); } else { - m_CursorNormal = spr; + _cursorNormal = spr; Stack->PushBool(true); } return S_OK; @@ -502,8 +502,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetNormalCursor") == 0) { Stack->CorrectParams(0); - if (!m_CursorNormal || !m_CursorNormal->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_CursorNormal->m_Filename); + if (!_cursorNormal || !_cursorNormal->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorNormal->_filename); return S_OK; } @@ -513,8 +513,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetNormalCursorObject") == 0) { Stack->CorrectParams(0); - if (!m_CursorNormal) Stack->PushNULL(); - else Stack->PushNative(m_CursorNormal, true); + if (!_cursorNormal) Stack->PushNULL(); + else Stack->PushNative(_cursorNormal, true); return S_OK; } @@ -526,14 +526,14 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This char *Filename = Stack->Pop()->GetString(); - delete m_CursorHover; - m_CursorHover = NULL; + delete _cursorHover; + _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->LoadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); } else { - m_CursorHover = spr; + _cursorHover = spr; Stack->PushBool(true); } return S_OK; @@ -545,8 +545,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetHoverCursor") == 0) { Stack->CorrectParams(0); - if (!m_CursorHover || !m_CursorHover->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_CursorHover->m_Filename); + if (!_cursorHover || !_cursorHover->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorHover->_filename); return S_OK; } @@ -556,8 +556,8 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetHoverCursorObject") == 0) { Stack->CorrectParams(0); - if (!m_CursorHover) Stack->PushNULL(); - else Stack->PushNative(m_CursorHover, true); + if (!_cursorHover) Stack->PushNULL(); + else Stack->PushNative(_cursorHover, true); return S_OK; } @@ -567,79 +567,79 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CAdItem::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("item"); - return m_ScValue; + _scValue->SetString("item"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // DisplayAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DisplayAmount") == 0) { - m_ScValue->SetBool(m_DisplayAmount); - return m_ScValue; + _scValue->SetBool(_displayAmount); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Amount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Amount") == 0) { - m_ScValue->SetInt(m_Amount); - return m_ScValue; + _scValue->SetInt(_amount); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AmountOffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountOffsetX") == 0) { - m_ScValue->SetInt(m_AmountOffsetX); - return m_ScValue; + _scValue->SetInt(_amountOffsetX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AmountOffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountOffsetY") == 0) { - m_ScValue->SetInt(m_AmountOffsetY); - return m_ScValue; + _scValue->SetInt(_amountOffsetY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AmountAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountAlign") == 0) { - m_ScValue->SetInt(m_AmountAlign); - return m_ScValue; + _scValue->SetInt(_amountAlign); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountString") == 0) { - if (!m_AmountString) m_ScValue->SetNULL(); - else m_ScValue->SetString(m_AmountString); - return m_ScValue; + if (!_amountString) _scValue->SetNULL(); + else _scValue->SetString(_amountString); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CursorCombined ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorCombined") == 0) { - m_ScValue->SetBool(m_CursorCombined); - return m_ScValue; + _scValue->SetBool(_cursorCombined); + return _scValue; } else return CAdTalkHolder::ScGetProperty(Name); @@ -660,7 +660,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // DisplayAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DisplayAmount") == 0) { - m_DisplayAmount = Value->GetBool(); + _displayAmount = Value->GetBool(); return S_OK; } @@ -668,7 +668,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // Amount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Amount") == 0) { - m_Amount = Value->GetInt(); + _amount = Value->GetInt(); return S_OK; } @@ -676,7 +676,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // AmountOffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountOffsetX") == 0) { - m_AmountOffsetX = Value->GetInt(); + _amountOffsetX = Value->GetInt(); return S_OK; } @@ -684,7 +684,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // AmountOffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountOffsetY") == 0) { - m_AmountOffsetY = Value->GetInt(); + _amountOffsetY = Value->GetInt(); return S_OK; } @@ -692,7 +692,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // AmountAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountAlign") == 0) { - m_AmountAlign = (TTextAlign)Value->GetInt(); + _amountAlign = (TTextAlign)Value->GetInt(); return S_OK; } @@ -700,8 +700,8 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountString") == 0) { - if (Value->IsNULL()) SAFE_DELETE_ARRAY(m_AmountString); - else CBUtils::SetString(&m_AmountString, Value->GetString()); + if (Value->IsNULL()) SAFE_DELETE_ARRAY(_amountString); + else CBUtils::SetString(&_amountString, Value->GetString()); return S_OK; } @@ -709,7 +709,7 @@ HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { // CursorCombined ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorCombined") == 0) { - m_CursorCombined = Value->GetBool(); + _cursorCombined = Value->GetBool(); return S_OK; } @@ -728,17 +728,17 @@ HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { CAdTalkHolder::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_CursorCombined)); - PersistMgr->Transfer(TMEMBER(m_CursorHover)); - PersistMgr->Transfer(TMEMBER(m_CursorNormal)); - PersistMgr->Transfer(TMEMBER(m_SpriteHover)); - PersistMgr->Transfer(TMEMBER(m_InInventory)); - PersistMgr->Transfer(TMEMBER(m_DisplayAmount)); - PersistMgr->Transfer(TMEMBER(m_Amount)); - PersistMgr->Transfer(TMEMBER(m_AmountOffsetX)); - PersistMgr->Transfer(TMEMBER(m_AmountOffsetY)); - PersistMgr->Transfer(TMEMBER_INT(m_AmountAlign)); - PersistMgr->Transfer(TMEMBER(m_AmountString)); + PersistMgr->Transfer(TMEMBER(_cursorCombined)); + PersistMgr->Transfer(TMEMBER(_cursorHover)); + PersistMgr->Transfer(TMEMBER(_cursorNormal)); + PersistMgr->Transfer(TMEMBER(_spriteHover)); + PersistMgr->Transfer(TMEMBER(_inInventory)); + PersistMgr->Transfer(TMEMBER(_displayAmount)); + PersistMgr->Transfer(TMEMBER(_amount)); + PersistMgr->Transfer(TMEMBER(_amountOffsetX)); + PersistMgr->Transfer(TMEMBER(_amountOffsetY)); + PersistMgr->Transfer(TMEMBER_INT(_amountAlign)); + PersistMgr->Transfer(TMEMBER(_amountString)); return S_OK; } diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index 8bb9cd46a0..c5144eff12 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdItem_H__ -#define __WmeAdItem_H__ +#ifndef __WmeAdIte_h__ +#define __WmeAdIte_h__ #include "AdTalkHolder.h" @@ -36,23 +36,23 @@ namespace WinterMute { class CAdItem : public CAdTalkHolder { public: - bool m_DisplayAmount; - int m_Amount; - int m_AmountOffsetX; - int m_AmountOffsetY; - TTextAlign m_AmountAlign; - char *m_AmountString; + bool _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; HRESULT Update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) HRESULT Display(int X, int Y); bool GetExtendedFlag(char *FlagName); - bool m_InInventory; - bool m_CursorCombined; - CBSprite *m_SpriteHover; - CBSprite *m_CursorNormal; - CBSprite *m_CursorHover; + bool _inInventory; + bool _cursorCombined; + CBSprite *_spriteHover; + CBSprite *_cursorNormal; + CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); HRESULT LoadFile(char *Filename); diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 6e55a24161..ea87cd3727 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -45,24 +45,24 @@ IMPLEMENT_PERSISTENT(CAdLayer, false) ////////////////////////////////////////////////////////////////////////// CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { - m_Main = false; - m_Width = m_Height = 0; - m_Active = true; - m_CloseUp = false; + _main = false; + _width = _height = 0; + _active = true; + _closeUp = false; } ////////////////////////////////////////////////////////////////////////// CAdLayer::~CAdLayer() { - for (int i = 0; i < m_Nodes.GetSize(); i++) - delete m_Nodes[i]; - m_Nodes.RemoveAll(); + for (int i = 0; i < _nodes.GetSize(); i++) + delete _nodes[i]; + _nodes.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdLayer::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -70,8 +70,8 @@ HRESULT CAdLayer::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); @@ -146,23 +146,23 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_MAIN: - parser.ScanStr((char *)params, "%b", &m_Main); + parser.ScanStr((char *)params, "%b", &_main); break; case TOKEN_CLOSE_UP: - parser.ScanStr((char *)params, "%b", &m_CloseUp); + parser.ScanStr((char *)params, "%b", &_closeUp); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &m_Width); + parser.ScanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_Height); + parser.ScanStr((char *)params, "%d", &_height); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &m_Active); + parser.ScanStr((char *)params, "%b", &_active); break; case TOKEN_REGION: { @@ -176,7 +176,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { node = NULL; } else { node->SetRegion(region); - m_Nodes.Add(node); + _nodes.Add(node); } } break; @@ -184,7 +184,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ENTITY: { CAdEntity *entity = new CAdEntity(Game); CAdSceneNode *node = new CAdSceneNode(Game); - if (entity) entity->m_Zoomable = false; // scene entites default to NOT zoom + if (entity) entity->_zoomable = false; // scene entites default to NOT zoom if (!entity || !node || FAILED(entity->LoadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; @@ -193,13 +193,13 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { node = NULL; } else { node->SetEntity(entity); - m_Nodes.Add(node); + _nodes.Add(node); } } break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &m_EditorSelected); + parser.ScanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_SCRIPT: @@ -236,25 +236,25 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *val = Stack->Pop(); int node = -1; - if (val->m_Type == VAL_INT) node = val->GetInt(); + if (val->_type == VAL_INT) node = val->GetInt(); else { // get by name - for (int i = 0; i < m_Nodes.GetSize(); i++) { - if ((m_Nodes[i]->m_Type == OBJECT_ENTITY && scumm_stricmp(m_Nodes[i]->m_Entity->m_Name, val->GetString()) == 0) || - (m_Nodes[i]->m_Type == OBJECT_REGION && scumm_stricmp(m_Nodes[i]->m_Region->m_Name, val->GetString()) == 0)) { + for (int i = 0; i < _nodes.GetSize(); i++) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->GetString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->GetString()) == 0)) { node = i; break; } } } - if (node < 0 || node >= m_Nodes.GetSize()) Stack->PushNULL(); + if (node < 0 || node >= _nodes.GetSize()) Stack->PushNULL(); else { - switch (m_Nodes[node]->m_Type) { + switch (_nodes[node]->_type) { case OBJECT_ENTITY: - Stack->PushNative(m_Nodes[node]->m_Entity, true); + Stack->PushNative(_nodes[node]->_entity, true); break; case OBJECT_REGION: - Stack->PushNative(m_Nodes[node]->m_Region, true); + Stack->PushNative(_nodes[node]->_region, true); break; default: Stack->PushNULL(); @@ -282,7 +282,7 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Node->SetEntity(Entity); Stack->PushNative(Entity, true); } - m_Nodes.Add(Node); + _nodes.Add(Node); return S_OK; } @@ -307,8 +307,8 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->PushNative(Entity, true); } if (Index < 0) Index = 0; - if (Index <= m_Nodes.GetSize() - 1) m_Nodes.InsertAt(Index, Node); - else m_Nodes.Add(Node); + if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); + else _nodes.Add(Node); return S_OK; } @@ -323,16 +323,16 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdSceneNode *ToDelete = NULL; if (Val->IsNative()) { CBScriptable *Temp = Val->GetNative(); - for (int i = 0; i < m_Nodes.GetSize(); i++) { - if (m_Nodes[i]->m_Region == Temp || m_Nodes[i]->m_Entity == Temp) { - ToDelete = m_Nodes[i]; + for (int i = 0; i < _nodes.GetSize(); i++) { + if (_nodes[i]->_region == Temp || _nodes[i]->_entity == Temp) { + ToDelete = _nodes[i]; break; } } } else { int Index = Val->GetInt(); - if (Index >= 0 && Index < m_Nodes.GetSize()) { - ToDelete = m_Nodes[Index]; + if (Index >= 0 && Index < _nodes.GetSize()) { + ToDelete = _nodes[Index]; } } if (ToDelete == NULL) { @@ -340,11 +340,11 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - for (int i = 0; i < m_Nodes.GetSize(); i++) { - if (m_Nodes[i] == ToDelete) { - delete m_Nodes[i]; - m_Nodes[i] = NULL; - m_Nodes.RemoveAt(i); + for (int i = 0; i < _nodes.GetSize(); i++) { + if (_nodes[i] == ToDelete) { + delete _nodes[i]; + _nodes[i] = NULL; + _nodes.RemoveAt(i); break; } } @@ -358,62 +358,62 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdLayer::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("layer"); - return m_ScValue; + _scValue->SetString("layer"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumNodes") == 0) { - m_ScValue->SetInt(m_Nodes.GetSize()); - return m_ScValue; + _scValue->SetInt(_nodes.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_ScValue->SetInt(m_Width); - return m_ScValue; + _scValue->SetInt(_width); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_ScValue->SetInt(m_Height); - return m_ScValue; + _scValue->SetInt(_height); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Main (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Main") == 0) { - m_ScValue->SetBool(m_Main); - return m_ScValue; + _scValue->SetBool(_main); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CloseUp ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CloseUp") == 0) { - m_ScValue->SetBool(m_CloseUp); - return m_ScValue; + _scValue->SetBool(_closeUp); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { - m_ScValue->SetBool(m_Active); - return m_ScValue; + _scValue->SetBool(_active); + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -434,7 +434,7 @@ HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { // CloseUp ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CloseUp") == 0) { - m_CloseUp = Value->GetBool(); + _closeUp = Value->GetBool(); return S_OK; } @@ -442,8 +442,8 @@ HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_Width = Value->GetInt(); - if (m_Width < 0) m_Width = 0; + _width = Value->GetInt(); + if (_width < 0) _width = 0; return S_OK; } @@ -451,8 +451,8 @@ HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_Height = Value->GetInt(); - if (m_Height < 0) m_Height = 0; + _height = Value->GetInt(); + if (_height < 0) _height = 0; return S_OK; } @@ -461,9 +461,9 @@ HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { bool b = Value->GetBool(); - if (b == false && m_Main) { + if (b == false && _main) { Game->LOG(0, "Warning: cannot deactivate scene's main layer"); - } else m_Active = b; + } else _active = b; return S_OK; } @@ -480,31 +480,31 @@ char *CAdLayer::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "LAYER {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", m_Main ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); - if (m_CloseUp) - Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", m_CloseUp ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_closeUp) + Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); int i; - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - for (i = 0; i < m_Nodes.GetSize(); i++) { - switch (m_Nodes[i]->m_Type) { + for (i = 0; i < _nodes.GetSize(); i++) { + switch (_nodes[i]->_type) { case OBJECT_ENTITY: - m_Nodes[i]->m_Entity->SaveAsText(Buffer, Indent + 2); + _nodes[i]->_entity->SaveAsText(Buffer, Indent + 2); break; case OBJECT_REGION: - m_Nodes[i]->m_Region->SaveAsText(Buffer, Indent + 2); + _nodes[i]->_region->SaveAsText(Buffer, Indent + 2); break; } } @@ -522,12 +522,12 @@ HRESULT CAdLayer::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_CloseUp)); - PersistMgr->Transfer(TMEMBER(m_Height)); - PersistMgr->Transfer(TMEMBER(m_Main)); - m_Nodes.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Width)); + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_closeUp)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_main)); + _nodes.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_width)); return S_OK; } diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index eda3e6f272..ad24759fa9 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -33,15 +33,15 @@ namespace WinterMute { class CAdSceneNode; class CAdLayer : public CBObject { public: - bool m_CloseUp; + bool _closeUp; DECLARE_PERSISTENT(CAdLayer, CBObject) - bool m_Active; - int m_Height; - int m_Width; - bool m_Main; + bool _active; + int _height; + int _width; + bool _main; CAdLayer(CBGame *inGame); virtual ~CAdLayer(); - CBArray m_Nodes; + CBArray _nodes; HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp index da2f4a39b9..5df3aa8b17 100644 --- a/engines/wintermute/AdNodeState.cpp +++ b/engines/wintermute/AdNodeState.cpp @@ -43,51 +43,51 @@ IMPLEMENT_PERSISTENT(CAdNodeState, false) ////////////////////////////////////////////////////////////////////////// CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { - m_Name = NULL; - m_Active = false; - for (int i = 0; i < 7; i++) m_Caption[i] = NULL; - m_AlphaColor = 0; - m_Filename = NULL; - m_Cursor = NULL; + _name = NULL; + _active = false; + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _alphaColor = 0; + _filename = NULL; + _cursor = NULL; } ////////////////////////////////////////////////////////////////////////// CAdNodeState::~CAdNodeState() { - delete[] m_Name; - delete[] m_Filename; - delete[] m_Cursor; - m_Name = NULL; - m_Filename = NULL; - m_Cursor = NULL; + delete[] _name; + delete[] _filename; + delete[] _cursor; + _name = NULL; + _filename = NULL; + _cursor = NULL; for (int i = 0; i < 7; i++) { - delete[] m_Caption[i]; - m_Caption[i] = NULL; + delete[] _caption[i]; + _caption[i] = NULL; } } ////////////////////////////////////////////////////////////////////////// void CAdNodeState::SetName(char *Name) { - delete[] m_Name; - m_Name = NULL; - CBUtils::SetString(&m_Name, Name); + delete[] _name; + _name = NULL; + CBUtils::SetString(&_name, Name); } ////////////////////////////////////////////////////////////////////////// void CAdNodeState::SetFilename(char *Filename) { - delete[] m_Filename; - m_Filename = NULL; - CBUtils::SetString(&m_Filename, Filename); + delete[] _filename; + _filename = NULL; + CBUtils::SetString(&_filename, Filename); } ////////////////////////////////////////////////////////////////////////// void CAdNodeState::SetCursor(char *Filename) { - delete[] m_Cursor; - m_Cursor = NULL; - CBUtils::SetString(&m_Cursor, Filename); + delete[] _cursor; + _cursor = NULL; + CBUtils::SetString(&_cursor, Filename); } @@ -95,12 +95,12 @@ void CAdNodeState::SetCursor(char *Filename) { HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_Name)); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_Cursor)); - PersistMgr->Transfer(TMEMBER(m_AlphaColor)); - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(m_Caption[i])); + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_cursor)); + PersistMgr->Transfer(TMEMBER(_alphaColor)); + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); return S_OK; } @@ -111,11 +111,11 @@ void CAdNodeState::SetCaption(char *Caption, int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; - delete[] m_Caption[Case - 1]; - m_Caption[Case - 1] = new char[strlen(Caption) + 1]; - if (m_Caption[Case - 1]) { - strcpy(m_Caption[Case - 1], Caption); - Game->m_StringTable->Expand(&m_Caption[Case - 1]); + delete[] _caption[Case - 1]; + _caption[Case - 1] = new char[strlen(Caption) + 1]; + if (_caption[Case - 1]) { + strcpy(_caption[Case - 1], Caption); + Game->_stringTable->Expand(&_caption[Case - 1]); } } @@ -123,8 +123,8 @@ void CAdNodeState::SetCaption(char *Caption, int Case) { ////////////////////////////////////////////////////////////////////////// char *CAdNodeState::GetCaption(int Case) { if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || m_Caption[Case - 1] == NULL) return ""; - else return m_Caption[Case - 1]; + if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; + else return _caption[Case - 1]; } @@ -137,30 +137,30 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b if (Saving) { for (int i = 0; i < 7; i++) { - if (Entity->m_Caption[i]) SetCaption(Entity->m_Caption[i], i); + if (Entity->_caption[i]) SetCaption(Entity->_caption[i], i); } - if (!Entity->m_Region && Entity->m_Sprite && Entity->m_Sprite->m_Filename) { - if (IncludingSprites) SetFilename(Entity->m_Sprite->m_Filename); + if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { + if (IncludingSprites) SetFilename(Entity->_sprite->_filename); else SetFilename(""); } - if (Entity->m_Cursor && Entity->m_Cursor->m_Filename) SetCursor(Entity->m_Cursor->m_Filename); - m_AlphaColor = Entity->m_AlphaColor; - m_Active = Entity->m_Active; + if (Entity->_cursor && Entity->_cursor->_filename) SetCursor(Entity->_cursor->_filename); + _alphaColor = Entity->_alphaColor; + _active = Entity->_active; } else { for (int i = 0; i < 7; i++) { - if (m_Caption[i]) Entity->SetCaption(m_Caption[i], i); + if (_caption[i]) Entity->SetCaption(_caption[i], i); } - if (m_Filename && !Entity->m_Region && IncludingSprites && strcmp(m_Filename, "") != 0) { - if (!Entity->m_Sprite || !Entity->m_Sprite->m_Filename || scumm_stricmp(Entity->m_Sprite->m_Filename, m_Filename) != 0) - Entity->SetSprite(m_Filename); + if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { + if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) + Entity->SetSprite(_filename); } - if (m_Cursor) { - if (!Entity->m_Cursor || !Entity->m_Cursor->m_Filename || scumm_stricmp(Entity->m_Cursor->m_Filename, m_Cursor) != 0) - Entity->SetCursor(m_Cursor); + if (_cursor) { + if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) + Entity->SetCursor(_cursor); } - Entity->m_Active = m_Active; - Entity->m_AlphaColor = m_AlphaColor; + Entity->_active = _active; + Entity->_alphaColor = _alphaColor; } return S_OK; diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h index 722d880c33..4c5b87fb89 100644 --- a/engines/wintermute/AdNodeState.h +++ b/engines/wintermute/AdNodeState.h @@ -42,14 +42,14 @@ public: DECLARE_PERSISTENT(CAdNodeState, CBBase) CAdNodeState(CBGame *inGame); virtual ~CAdNodeState(); - char *m_Name; - bool m_Active; - char *m_Caption[7]; + char *_name; + bool _active; + char *_caption[7]; void SetCaption(char *Caption, int Case); char *GetCaption(int Case); - uint32 m_AlphaColor; - char *m_Filename; - char *m_Cursor; + uint32 _alphaColor; + char *_filename; + char *_cursor; }; diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 6e59b9b45c..95b48b8401 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -58,107 +58,107 @@ IMPLEMENT_PERSISTENT(CAdObject, false) ////////////////////////////////////////////////////////////////////////// CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { - m_Type = OBJECT_NONE; - m_State = m_NextState = STATE_NONE; + _type = OBJECT_NONE; + _state = _nextState = STATE_NONE; - m_Active = true; - m_Drawn = false; + _active = true; + _drawn = false; - m_CurrentSprite = NULL; - m_AnimSprite = NULL; - m_TempSprite2 = NULL; + _currentSprite = NULL; + _animSprite = NULL; + _tempSprite2 = NULL; - m_Font = NULL; + _font = NULL; - m_Sentence = NULL; + _sentence = NULL; - m_ForcedTalkAnimName = NULL; - m_ForcedTalkAnimUsed = false; + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; - m_BlockRegion = NULL; - m_WptGroup = NULL; + _blockRegion = NULL; + _wptGroup = NULL; - m_CurrentBlockRegion = NULL; - m_CurrentWptGroup = NULL; + _currentBlockRegion = NULL; + _currentWptGroup = NULL; - m_IgnoreItems = false; - m_SceneIndependent = false; + _ignoreItems = false; + _sceneIndependent = false; - m_StickRegion = NULL; + _stickRegion = NULL; - m_SubtitlesModRelative = true; - m_SubtitlesModX = 0; - m_SubtitlesModY = 0; - m_SubtitlesWidth = 0; - m_SubtitlesModXCenter = true; + _subtitlesModRelative = true; + _subtitlesModX = 0; + _subtitlesModY = 0; + _subtitlesWidth = 0; + _subtitlesModXCenter = true; - m_Inventory = NULL; + _inventory = NULL; - for (int i = 0; i < MAX_NUM_REGIONS; i++) m_CurrentRegions[i] = NULL; + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - m_PartEmitter = NULL; - m_PartFollowParent = false; - m_PartOffsetX = m_PartOffsetY = 0; + _partEmitter = NULL; + _partFollowParent = false; + _partOffsetX = _partOffsetY = 0; - m_RegisterAlias = this; + _registerAlias = this; } ////////////////////////////////////////////////////////////////////////// CAdObject::~CAdObject() { - m_CurrentSprite = NULL; // reference only, don't delete - SAFE_DELETE(m_AnimSprite); - SAFE_DELETE(m_Sentence); - SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); + _currentSprite = NULL; // reference only, don't delete + SAFE_DELETE(_animSprite); + SAFE_DELETE(_sentence); + SAFE_DELETE_ARRAY(_forcedTalkAnimName); - SAFE_DELETE(m_BlockRegion); - SAFE_DELETE(m_WptGroup); + SAFE_DELETE(_blockRegion); + SAFE_DELETE(_wptGroup); - SAFE_DELETE(m_CurrentBlockRegion); - SAFE_DELETE(m_CurrentWptGroup); + SAFE_DELETE(_currentBlockRegion); + SAFE_DELETE(_currentWptGroup); - m_TempSprite2 = NULL; // reference only - m_StickRegion = NULL; + _tempSprite2 = NULL; // reference only + _stickRegion = NULL; - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (_font) Game->_fontStorage->RemoveFont(_font); - if (m_Inventory) { - ((CAdGame *)Game)->UnregisterInventory(m_Inventory); - m_Inventory = NULL; + if (_inventory) { + ((CAdGame *)Game)->UnregisterInventory(_inventory); + _inventory = NULL; } - if (m_PartEmitter) - Game->UnregisterObject(m_PartEmitter); + if (_partEmitter) + Game->UnregisterObject(_partEmitter); - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - Game->UnregisterObject(m_AttachmentsPre[i]); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + Game->UnregisterObject(_attachmentsPre[i]); } - m_AttachmentsPre.RemoveAll(); + _attachmentsPre.RemoveAll(); - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - Game->UnregisterObject(m_AttachmentsPost[i]); + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + Game->UnregisterObject(_attachmentsPost[i]); } - m_AttachmentsPost.RemoveAll(); + _attachmentsPost.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::PlayAnim(char *Filename) { - SAFE_DELETE(m_AnimSprite); - m_AnimSprite = new CBSprite(Game, this); - if (!m_AnimSprite) { - Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", m_Name, Filename); + SAFE_DELETE(_animSprite); + _animSprite = new CBSprite(Game, this); + if (!_animSprite) { + Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); return E_FAIL; } - HRESULT res = m_AnimSprite->LoadFile(Filename); + HRESULT res = _animSprite->LoadFile(Filename); if (FAILED(res)) { - Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", m_Name, Filename); - SAFE_DELETE(m_AnimSprite); + Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); + SAFE_DELETE(_animSprite); return res; } - m_State = STATE_PLAYING_ANIM; + _state = STATE_PLAYING_ANIM; return S_OK; } @@ -209,7 +209,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsTalking") == 0) { Stack->CorrectParams(0); - Stack->PushBool(m_State == STATE_TALKING); + Stack->PushBool(_state == STATE_TALKING); return S_OK; } @@ -218,10 +218,10 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { Stack->CorrectParams(0); - if (m_Sentence) m_Sentence->Finish(); - if (m_State == STATE_TALKING) { - m_State = m_NextState; - m_NextState = STATE_READY; + if (_sentence) _sentence->Finish(); + if (_state == STATE_TALKING) { + _state = _nextState; + _nextState = STATE_READY; Stack->PushBool(true); } else Stack->PushBool(false); return S_OK; @@ -233,10 +233,10 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "ForceTalkAnim") == 0) { Stack->CorrectParams(1); char *AnimName = Stack->Pop()->GetString(); - SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); - m_ForcedTalkAnimName = new char[strlen(AnimName) + 1]; - strcpy(m_ForcedTalkAnimName, AnimName); - m_ForcedTalkAnimUsed = false; + SAFE_DELETE_ARRAY(_forcedTalkAnimName); + _forcedTalkAnimName = new char[strlen(AnimName) + 1]; + strcpy(_forcedTalkAnimName, AnimName); + _forcedTalkAnimUsed = false; Stack->PushBool(true); return S_OK; } @@ -277,19 +277,19 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "StickToRegion") == 0) { Stack->CorrectParams(1); - CAdLayer *Main = ((CAdGame *)Game)->m_Scene->m_MainLayer; + CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; bool RegFound = false; int i; CScValue *Val = Stack->Pop(); if (Val->IsNULL() || !Main) { - m_StickRegion = NULL; + _stickRegion = NULL; RegFound = true; } else if (Val->IsString()) { char *RegionName = Val->GetString(); - for (i = 0; i < Main->m_Nodes.GetSize(); i++) { - if (Main->m_Nodes[i]->m_Type == OBJECT_REGION && Main->m_Nodes[i]->m_Region->m_Name && scumm_stricmp(Main->m_Nodes[i]->m_Region->m_Name, RegionName) == 0) { - m_StickRegion = Main->m_Nodes[i]->m_Region; + for (i = 0; i < Main->_nodes.GetSize(); i++) { + if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { + _stickRegion = Main->_nodes[i]->_region; RegFound = true; break; } @@ -297,9 +297,9 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } else if (Val->IsNative()) { CBScriptable *Obj = Val->GetNative(); - for (i = 0; i < Main->m_Nodes.GetSize(); i++) { - if (Main->m_Nodes[i]->m_Type == OBJECT_REGION && Main->m_Nodes[i]->m_Region == Obj) { - m_StickRegion = Main->m_Nodes[i]->m_Region; + for (i = 0; i < Main->_nodes.GetSize(); i++) { + if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region == Obj) { + _stickRegion = Main->_nodes[i]->_region; RegFound = true; break; } @@ -307,7 +307,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } - if (!RegFound) m_StickRegion = NULL; + if (!RegFound) _stickRegion = NULL; Stack->PushBool(RegFound); return S_OK; } @@ -331,7 +331,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFont") == 0) { Stack->CorrectParams(0); - if (m_Font && m_Font->m_Filename) Stack->PushString(m_Font->m_Filename); + if (_font && _font->_filename) Stack->PushString(_font->_filename); else Stack->PushNULL(); return S_OK; } @@ -342,9 +342,9 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "TakeItem") == 0) { Stack->CorrectParams(2); - if (!m_Inventory) { - m_Inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(m_Inventory); + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); } CScValue *val = Stack->Pop(); @@ -352,10 +352,10 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th char *ItemName = val->GetString(); val = Stack->Pop(); char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); - if (FAILED(m_Inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities - ((CAdGame *)Game)->m_Scene->HandleItemAssociations(ItemName, false); + ((CAdGame *)Game)->_scene->HandleItemAssociations(ItemName, false); } } else Script->RuntimeError("TakeItem: item name expected"); @@ -370,17 +370,17 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "DropItem") == 0) { Stack->CorrectParams(1); - if (!m_Inventory) { - m_Inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(m_Inventory); + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); } CScValue *val = Stack->Pop(); if (!val->IsNULL()) { - if (FAILED(m_Inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); + if (FAILED(_inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); else { // show associated entities - ((CAdGame *)Game)->m_Scene->HandleItemAssociations(val->GetString(), true); + ((CAdGame *)Game)->_scene->HandleItemAssociations(val->GetString(), true); } } else Script->RuntimeError("DropItem: item name expected"); @@ -394,20 +394,20 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "GetItem") == 0) { Stack->CorrectParams(1); - if (!m_Inventory) { - m_Inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(m_Inventory); + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); } CScValue *val = Stack->Pop(); - if (val->m_Type == VAL_STRING) { + if (val->_type == VAL_STRING) { CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); if (item) Stack->PushNative(item, true); else Stack->PushNULL(); - } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= m_Inventory->m_TakenItems.GetSize()) + } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) Stack->PushNULL(); else - Stack->PushNative(m_Inventory->m_TakenItems[val->GetInt()], true); + Stack->PushNative(_inventory->_takenItems[val->GetInt()], true); return S_OK; } @@ -418,18 +418,18 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "HasItem") == 0) { Stack->CorrectParams(1); - if (!m_Inventory) { - m_Inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(m_Inventory); + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); } CScValue *val = Stack->Pop(); if (!val->IsNULL()) { - for (int i = 0; i < m_Inventory->m_TakenItems.GetSize(); i++) { - if (val->GetNative() == m_Inventory->m_TakenItems[i]) { + for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { + if (val->GetNative() == _inventory->_takenItems[i]) { Stack->PushBool(true); return S_OK; - } else if (scumm_stricmp(val->GetString(), m_Inventory->m_TakenItems[i]->m_Name) == 0) { + } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { Stack->PushBool(true); return S_OK; } @@ -450,7 +450,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th int OffsetY = Stack->Pop()->GetInt(); CPartEmitter *Emitter = CreateParticleEmitter(FollowParent, OffsetX, OffsetY); - if (Emitter) Stack->PushNative(m_PartEmitter, true); + if (Emitter) Stack->PushNative(_partEmitter, true); else Stack->PushNULL(); return S_OK; @@ -461,9 +461,9 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DeleteParticleEmitter") == 0) { Stack->CorrectParams(0); - if (m_PartEmitter) { - Game->UnregisterObject(m_PartEmitter); - m_PartEmitter = NULL; + if (_partEmitter) { + Game->UnregisterObject(_partEmitter); + _partEmitter = NULL; } Stack->PushNULL(); @@ -489,12 +489,12 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } else { Game->RegisterObject(Ent); - Ent->m_PosX = OffsetX; - Ent->m_PosY = OffsetY; - Ent->m_Active = true; + Ent->_posX = OffsetX; + Ent->_posY = OffsetY; + Ent->_active = true; - if (PreDisplay) m_AttachmentsPre.Add(Ent); - else m_AttachmentsPost.Add(Ent); + if (PreDisplay) _attachmentsPre.Add(Ent); + else _attachmentsPost.Add(Ent); Stack->PushBool(true); } @@ -511,37 +511,37 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th bool Found = false; if (Val->IsNative()) { CBScriptable *Obj = Val->GetNative(); - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - if (m_AttachmentsPre[i] == Obj) { + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i] == Obj) { Found = true; - Game->UnregisterObject(m_AttachmentsPre[i]); - m_AttachmentsPre.RemoveAt(i); + Game->UnregisterObject(_attachmentsPre[i]); + _attachmentsPre.RemoveAt(i); i--; } } - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - if (m_AttachmentsPost[i] == Obj) { + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i] == Obj) { Found = true; - Game->UnregisterObject(m_AttachmentsPost[i]); - m_AttachmentsPost.RemoveAt(i); + Game->UnregisterObject(_attachmentsPost[i]); + _attachmentsPost.RemoveAt(i); i--; } } } else { char *Name = Val->GetString(); - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - if (m_AttachmentsPre[i]->m_Name && scumm_stricmp(m_AttachmentsPre[i]->m_Name, Name) == 0) { + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { Found = true; - Game->UnregisterObject(m_AttachmentsPre[i]); - m_AttachmentsPre.RemoveAt(i); + Game->UnregisterObject(_attachmentsPre[i]); + _attachmentsPre.RemoveAt(i); i--; } } - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - if (m_AttachmentsPost[i]->m_Name && scumm_stricmp(m_AttachmentsPost[i]->m_Name, Name) == 0) { + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { Found = true; - Game->UnregisterObject(m_AttachmentsPost[i]); - m_AttachmentsPost.RemoveAt(i); + Game->UnregisterObject(_attachmentsPost[i]); + _attachmentsPost.RemoveAt(i); i--; } } @@ -562,26 +562,26 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (Val->IsInt()) { int Index = Val->GetInt(); int CurrIndex = 0; - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - if (CurrIndex == Index) Ret = m_AttachmentsPre[i]; + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (CurrIndex == Index) Ret = _attachmentsPre[i]; CurrIndex++; } - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - if (CurrIndex == Index) Ret = m_AttachmentsPost[i]; + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (CurrIndex == Index) Ret = _attachmentsPost[i]; CurrIndex++; } } else { char *Name = Val->GetString(); - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - if (m_AttachmentsPre[i]->m_Name && scumm_stricmp(m_AttachmentsPre[i]->m_Name, Name) == 0) { - Ret = m_AttachmentsPre[i]; + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { + Ret = _attachmentsPre[i]; break; } } if (!Ret) { - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - if (m_AttachmentsPost[i]->m_Name && scumm_stricmp(m_AttachmentsPost[i]->m_Name, Name) == 0) { - Ret = m_AttachmentsPre[i]; + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { + Ret = _attachmentsPre[i]; break; } } @@ -600,104 +600,104 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CAdObject::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("object"); - return m_ScValue; + _scValue->SetString("object"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { - m_ScValue->SetBool(m_Active); - return m_ScValue; + _scValue->SetBool(_active); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // IgnoreItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IgnoreItems") == 0) { - m_ScValue->SetBool(m_IgnoreItems); - return m_ScValue; + _scValue->SetBool(_ignoreItems); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SceneIndependent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SceneIndependent") == 0) { - m_ScValue->SetBool(m_SceneIndependent); - return m_ScValue; + _scValue->SetBool(_sceneIndependent); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesWidth") == 0) { - m_ScValue->SetInt(m_SubtitlesWidth); - return m_ScValue; + _scValue->SetInt(_subtitlesWidth); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosRelative") == 0) { - m_ScValue->SetBool(m_SubtitlesModRelative); - return m_ScValue; + _scValue->SetBool(_subtitlesModRelative); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosX") == 0) { - m_ScValue->SetInt(m_SubtitlesModX); - return m_ScValue; + _scValue->SetInt(_subtitlesModX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosY") == 0) { - m_ScValue->SetInt(m_SubtitlesModY); - return m_ScValue; + _scValue->SetInt(_subtitlesModY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { - m_ScValue->SetBool(m_SubtitlesModXCenter); - return m_ScValue; + _scValue->SetBool(_subtitlesModXCenter); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumItems (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumItems") == 0) { - m_ScValue->SetInt(GetInventory()->m_TakenItems.GetSize()); - return m_ScValue; + _scValue->SetInt(GetInventory()->_takenItems.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ParticleEmitter (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ParticleEmitter") == 0) { - if (m_PartEmitter) m_ScValue->SetNative(m_PartEmitter, true); - else m_ScValue->SetNULL(); + if (_partEmitter) _scValue->SetNative(_partEmitter, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumAttachments") == 0) { - m_ScValue->SetInt(m_AttachmentsPre.GetSize() + m_AttachmentsPost.GetSize()); - return m_ScValue; + _scValue->SetInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); + return _scValue; } @@ -712,7 +712,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Active") == 0) { - m_Active = Value->GetBool(); + _active = Value->GetBool(); return S_OK; } @@ -720,7 +720,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // IgnoreItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IgnoreItems") == 0) { - m_IgnoreItems = Value->GetBool(); + _ignoreItems = Value->GetBool(); return S_OK; } @@ -728,7 +728,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SceneIndependent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SceneIndependent") == 0) { - m_SceneIndependent = Value->GetBool(); + _sceneIndependent = Value->GetBool(); return S_OK; } @@ -736,7 +736,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesWidth") == 0) { - m_SubtitlesWidth = Value->GetInt(); + _subtitlesWidth = Value->GetInt(); return S_OK; } @@ -744,7 +744,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosRelative") == 0) { - m_SubtitlesModRelative = Value->GetBool(); + _subtitlesModRelative = Value->GetBool(); return S_OK; } @@ -752,7 +752,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosX") == 0) { - m_SubtitlesModX = Value->GetInt(); + _subtitlesModX = Value->GetInt(); return S_OK; } @@ -760,7 +760,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosY") == 0) { - m_SubtitlesModY = Value->GetInt(); + _subtitlesModY = Value->GetInt(); return S_OK; } @@ -768,7 +768,7 @@ HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { - m_SubtitlesModXCenter = Value->GetBool(); + _subtitlesModXCenter = Value->GetBool(); return S_OK; } @@ -784,12 +784,12 @@ char *CAdObject::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::SetFont(char *Filename) { - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (_font) Game->_fontStorage->RemoveFont(_font); if (Filename) { - m_Font = Game->m_FontStorage->AddFont(Filename); - return m_Font == NULL ? E_FAIL : S_OK; + _font = Game->_fontStorage->AddFont(Filename); + return _font == NULL ? E_FAIL : S_OK; } else { - m_Font = NULL; + _font = NULL; return S_OK; } } @@ -797,16 +797,16 @@ HRESULT CAdObject::SetFont(char *Filename) { ////////////////////////////////////////////////////////////////////////// int CAdObject::GetHeight() { - if (!m_CurrentSprite) return 0; + if (!_currentSprite) return 0; else { - CBFrame *frame = m_CurrentSprite->m_Frames[m_CurrentSprite->m_CurrentFrame]; + CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; int ret = 0; - for (int i = 0; i < frame->m_Subframes.GetSize(); i++) { - ret = MAX(ret, frame->m_Subframes[i]->m_HotspotY); + for (int i = 0; i < frame->_subframes.GetSize(); i++) { + ret = MAX(ret, frame->_subframes[i]->_hotspotY); } - if (m_Zoomable) { - float zoom = ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY); + if (_zoomable) { + float zoom = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY); ret = ret * zoom / 100; } return ret; @@ -816,30 +816,30 @@ int CAdObject::GetHeight() { ////////////////////////////////////////////////////////////////////////// void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TTextAlign Align) { - if (!m_Sentence) m_Sentence = new CAdSentence(Game); - if (!m_Sentence) return; + if (!_sentence) _sentence = new CAdSentence(Game); + if (!_sentence) return; - if (m_ForcedTalkAnimName && m_ForcedTalkAnimUsed) { - SAFE_DELETE_ARRAY(m_ForcedTalkAnimName); - m_ForcedTalkAnimUsed = false; + if (_forcedTalkAnimName && _forcedTalkAnimUsed) { + SAFE_DELETE_ARRAY(_forcedTalkAnimName); + _forcedTalkAnimUsed = false; } - SAFE_DELETE(m_Sentence->m_Sound); + SAFE_DELETE(_sentence->_sound); - m_Sentence->SetText(Text); - Game->m_StringTable->Expand(&m_Sentence->m_Text); - m_Sentence->SetStances(Stances); - m_Sentence->m_Duration = Duration; - m_Sentence->m_Align = Align; - m_Sentence->m_StartTime = Game->m_Timer; - m_Sentence->m_CurrentStance = -1; - m_Sentence->m_Font = m_Font == NULL ? Game->m_SystemFont : m_Font; - m_Sentence->m_Freezable = m_Freezable; + _sentence->SetText(Text); + Game->_stringTable->Expand(&_sentence->_text); + _sentence->SetStances(Stances); + _sentence->_duration = Duration; + _sentence->_align = Align; + _sentence->_startTime = Game->_timer; + _sentence->_currentStance = -1; + _sentence->_font = _font == NULL ? Game->_systemFont : _font; + _sentence->_freezable = _freezable; // try to locate speech file automatically bool DeleteSound = false; if (!Sound) { - char *Key = Game->m_StringTable->GetKey(Text); + char *Key = Game->_stringTable->GetKey(Text); if (Key) { Sound = ((CAdGame *)Game)->FindSpeechFile(Key); delete [] Key; @@ -852,73 +852,73 @@ void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TT if (Sound) { CBSound *snd = new CBSound(Game); if (snd && SUCCEEDED(snd->SetSound(Sound, SOUND_SPEECH, true))) { - m_Sentence->SetSound(snd); - if (m_Sentence->m_Duration <= 0) { + _sentence->SetSound(snd); + if (_sentence->_duration <= 0) { uint32 Length = snd->GetLength(); - if (Length != 0) m_Sentence->m_Duration = Length; + if (Length != 0) _sentence->_duration = Length; } } else delete snd; } // set duration by text length - if (m_Sentence->m_Duration <= 0) {// TODO: Avoid longs. - m_Sentence->m_Duration = MAX((unsigned long)1000, Game->m_SubtitlesSpeed * strlen(m_Sentence->m_Text)); + if (_sentence->_duration <= 0) {// TODO: Avoid longs. + _sentence->_duration = MAX((unsigned long)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); } int x, y, width, height; - x = m_PosX; - y = m_PosY; + x = _posX; + y = _posY; - if (!m_SceneIndependent && m_SubtitlesModRelative) { - x -= ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); - y -= ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + if (!_sceneIndependent && _subtitlesModRelative) { + x -= ((CAdGame *)Game)->_scene->GetOffsetLeft(); + y -= ((CAdGame *)Game)->_scene->GetOffsetTop(); } - if (m_SubtitlesWidth > 0) width = m_SubtitlesWidth; + if (_subtitlesWidth > 0) width = _subtitlesWidth; else { - if ((x < Game->m_Renderer->m_Width / 4 || x > Game->m_Renderer->m_Width * 0.75) && !Game->m_TouchInterface) { - width = MAX(Game->m_Renderer->m_Width / 4, MIN(x * 2, (Game->m_Renderer->m_Width - x) * 2)); - } else width = Game->m_Renderer->m_Width / 2; + if ((x < Game->_renderer->_width / 4 || x > Game->_renderer->_width * 0.75) && !Game->_touchInterface) { + width = MAX(Game->_renderer->_width / 4, MIN(x * 2, (Game->_renderer->_width - x) * 2)); + } else width = Game->_renderer->_width / 2; } - height = m_Sentence->m_Font->GetTextHeight((byte *)m_Sentence->m_Text, width); + height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); y = y - height - GetHeight() - 5; - if (m_SubtitlesModRelative) { - x += m_SubtitlesModX; - y += m_SubtitlesModY; + if (_subtitlesModRelative) { + x += _subtitlesModX; + y += _subtitlesModY; } else { - x = m_SubtitlesModX; - y = m_SubtitlesModY; + x = _subtitlesModX; + y = _subtitlesModY; } - if (m_SubtitlesModXCenter) + if (_subtitlesModXCenter) x = x - width / 2; - x = MIN(MAX(0, x), Game->m_Renderer->m_Width - width); - y = MIN(MAX(0, y), Game->m_Renderer->m_Height - height); + x = MIN(MAX(0, x), Game->_renderer->_width - width); + y = MIN(MAX(0, y), Game->_renderer->_height - height); - m_Sentence->m_Width = width; + _sentence->_width = width; - m_Sentence->m_Pos.x = x; - m_Sentence->m_Pos.y = y; + _sentence->_pos.x = x; + _sentence->_pos.y = y; - if (m_SubtitlesModRelative) { - m_Sentence->m_Pos.x += ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); - m_Sentence->m_Pos.y += ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + if (_subtitlesModRelative) { + _sentence->_pos.x += ((CAdGame *)Game)->_scene->GetOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)Game)->_scene->GetOffsetTop(); } - m_Sentence->m_FixedPos = !m_SubtitlesModRelative; + _sentence->_fixedPos = !_subtitlesModRelative; - m_Sentence->SetupTalkFile(Sound); + _sentence->SetupTalkFile(Sound); - m_State = STATE_TALKING; + _state = STATE_TALKING; if (DeleteSound) delete [] Sound; } @@ -926,15 +926,15 @@ void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TT ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::Reset() { - if (m_State == STATE_PLAYING_ANIM && m_AnimSprite != NULL) { - SAFE_DELETE(m_AnimSprite); - } else if (m_State == STATE_TALKING && m_Sentence) { - m_Sentence->Finish(); + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + SAFE_DELETE(_animSprite); + } else if (_state == STATE_TALKING && _sentence) { + _sentence->Finish(); } - m_State = m_NextState = STATE_READY; + _state = _nextState = STATE_READY; - Game->m_ScEngine->ResetObject(this); + Game->_scEngine->ResetObject(this); return S_OK; } @@ -944,42 +944,42 @@ HRESULT CAdObject::Reset() { HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_BlockRegion)); - PersistMgr->Transfer(TMEMBER(m_CurrentBlockRegion)); - PersistMgr->Transfer(TMEMBER(m_CurrentWptGroup)); - PersistMgr->Transfer(TMEMBER(m_CurrentSprite)); - PersistMgr->Transfer(TMEMBER(m_Drawn)); - PersistMgr->Transfer(TMEMBER(m_Font)); - PersistMgr->Transfer(TMEMBER(m_IgnoreItems)); - PersistMgr->Transfer(TMEMBER_INT(m_NextState)); - PersistMgr->Transfer(TMEMBER(m_Sentence)); - PersistMgr->Transfer(TMEMBER_INT(m_State)); - PersistMgr->Transfer(TMEMBER(m_AnimSprite)); - PersistMgr->Transfer(TMEMBER(m_SceneIndependent)); - PersistMgr->Transfer(TMEMBER(m_ForcedTalkAnimName)); - PersistMgr->Transfer(TMEMBER(m_ForcedTalkAnimUsed)); - PersistMgr->Transfer(TMEMBER(m_TempSprite2)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); - PersistMgr->Transfer(TMEMBER(m_WptGroup)); - PersistMgr->Transfer(TMEMBER(m_StickRegion)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesModRelative)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesModX)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesModY)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesModXCenter)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesWidth)); - PersistMgr->Transfer(TMEMBER(m_Inventory)); - PersistMgr->Transfer(TMEMBER(m_PartEmitter)); - - for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(m_CurrentRegions[i])); - - m_AttachmentsPre.Persist(PersistMgr); - m_AttachmentsPost.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_RegisterAlias)); - - PersistMgr->Transfer(TMEMBER(m_PartFollowParent)); - PersistMgr->Transfer(TMEMBER(m_PartOffsetX)); - PersistMgr->Transfer(TMEMBER(m_PartOffsetY)); + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_blockRegion)); + PersistMgr->Transfer(TMEMBER(_currentBlockRegion)); + PersistMgr->Transfer(TMEMBER(_currentWptGroup)); + PersistMgr->Transfer(TMEMBER(_currentSprite)); + PersistMgr->Transfer(TMEMBER(_drawn)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_ignoreItems)); + PersistMgr->Transfer(TMEMBER_INT(_nextState)); + PersistMgr->Transfer(TMEMBER(_sentence)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_animSprite)); + PersistMgr->Transfer(TMEMBER(_sceneIndependent)); + PersistMgr->Transfer(TMEMBER(_forcedTalkAnimName)); + PersistMgr->Transfer(TMEMBER(_forcedTalkAnimUsed)); + PersistMgr->Transfer(TMEMBER(_tempSprite2)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_wptGroup)); + PersistMgr->Transfer(TMEMBER(_stickRegion)); + PersistMgr->Transfer(TMEMBER(_subtitlesModRelative)); + PersistMgr->Transfer(TMEMBER(_subtitlesModX)); + PersistMgr->Transfer(TMEMBER(_subtitlesModY)); + PersistMgr->Transfer(TMEMBER(_subtitlesModXCenter)); + PersistMgr->Transfer(TMEMBER(_subtitlesWidth)); + PersistMgr->Transfer(TMEMBER(_inventory)); + PersistMgr->Transfer(TMEMBER(_partEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(_currentRegions[i])); + + _attachmentsPre.Persist(PersistMgr); + _attachmentsPost.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_registerAlias)); + + PersistMgr->Transfer(TMEMBER(_partFollowParent)); + PersistMgr->Transfer(TMEMBER(_partOffsetX)); + PersistMgr->Transfer(TMEMBER(_partOffsetY)); return S_OK; } @@ -987,8 +987,8 @@ HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::UpdateSounds() { - if (m_Sentence && m_Sentence->m_Sound) - UpdateOneSound(m_Sentence->m_Sound); + if (_sentence && _sentence->_sound) + UpdateOneSound(_sentence->_sound); return CBObject::UpdateSounds(); } @@ -996,8 +996,8 @@ HRESULT CAdObject::UpdateSounds() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::ResetSoundPan() { - if (m_Sentence && m_Sentence->m_Sound) { - m_Sentence->m_Sound->SetPan(0.0f); + if (_sentence && _sentence->_sound) { + _sentence->_sound->SetPan(0.0f); } return CBObject::ResetSoundPan(); } @@ -1014,8 +1014,8 @@ bool CAdObject::GetExtendedFlag(char *FlagName) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { - if (m_BlockRegion) m_BlockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); - if (m_WptGroup) m_WptGroup->SaveAsText(Buffer, Indent + 2); + if (_blockRegion) _blockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->SaveAsText(Buffer, Indent + 2); CBBase::SaveAsText(Buffer, Indent + 2); @@ -1026,23 +1026,23 @@ HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::UpdateBlockRegion() { CAdGame *AdGame = (CAdGame *)Game; - if (AdGame->m_Scene) { - if (m_BlockRegion && m_CurrentBlockRegion) - m_CurrentBlockRegion->Mimic(m_BlockRegion, m_Zoomable ? AdGame->m_Scene->GetScaleAt(m_PosY) : 100.0f, m_PosX, m_PosY); + if (AdGame->_scene) { + if (_blockRegion && _currentBlockRegion) + _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); - if (m_WptGroup && m_CurrentWptGroup) - m_CurrentWptGroup->Mimic(m_WptGroup, m_Zoomable ? AdGame->m_Scene->GetScaleAt(m_PosY) : 100.0f, m_PosX, m_PosY); + if (_wptGroup && _currentWptGroup) + _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); } return S_OK; } ////////////////////////////////////////////////////////////////////////// CAdInventory *CAdObject::GetInventory() { - if (!m_Inventory) { - m_Inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(m_Inventory); + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); } - return m_Inventory; + return _inventory; } @@ -1050,13 +1050,13 @@ CAdInventory *CAdObject::GetInventory() { HRESULT CAdObject::AfterMove() { CAdRegion *NewRegions[MAX_NUM_REGIONS]; - ((CAdGame *)Game)->m_Scene->GetRegionsAt(m_PosX, m_PosY, NewRegions, MAX_NUM_REGIONS); + ((CAdGame *)Game)->_scene->GetRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (!NewRegions[i]) break; bool RegFound = false; for (int j = 0; j < MAX_NUM_REGIONS; j++) { - if (m_CurrentRegions[j] == NewRegions[i]) { - m_CurrentRegions[j] = NULL; + if (_currentRegions[j] == NewRegions[i]) { + _currentRegions[j] = NULL; RegFound = true; break; } @@ -1065,10 +1065,10 @@ HRESULT CAdObject::AfterMove() { } for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (m_CurrentRegions[i] && Game->ValidObject(m_CurrentRegions[i])) { - m_CurrentRegions[i]->ApplyEvent("ActorLeave"); + if (_currentRegions[i] && Game->ValidObject(_currentRegions[i])) { + _currentRegions[i]->ApplyEvent("ActorLeave"); } - m_CurrentRegions[i] = NewRegions[i]; + _currentRegions[i] = NewRegions[i]; } return S_OK; @@ -1076,19 +1076,19 @@ HRESULT CAdObject::AfterMove() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::InvalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) m_CurrentRegions[i] = NULL; + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { - if (m_Zoomable) { - if (m_ScaleX >= 0 || m_ScaleY >= 0) { - *ScaleX = m_ScaleX < 0 ? 100 : m_ScaleX; - *ScaleY = m_ScaleY < 0 ? 100 : m_ScaleY; - } else if (m_Scale >= 0) *ScaleX = *ScaleY = m_Scale; - else *ScaleX = *ScaleY = ((CAdGame *)Game)->m_Scene->GetZoomAt(m_PosX, m_PosY) + m_RelativeScale; + if (_zoomable) { + if (_scaleX >= 0 || _scaleY >= 0) { + *ScaleX = _scaleX < 0 ? 100 : _scaleX; + *ScaleY = _scaleY < 0 ? 100 : _scaleY; + } else if (_scale >= 0) *ScaleX = *ScaleY = _scale; + else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) + _relativeScale; } else { *ScaleX = *ScaleY = 100; } @@ -1097,11 +1097,11 @@ HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::UpdateSpriteAttachments() { - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - m_AttachmentsPre[i]->Update(); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + _attachmentsPre[i]->Update(); } - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - m_AttachmentsPost[i]->Update(); + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + _attachmentsPost[i]->Update(); } return S_OK; } @@ -1109,12 +1109,12 @@ HRESULT CAdObject::UpdateSpriteAttachments() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { if (PreDisplay) { - for (int i = 0; i < m_AttachmentsPre.GetSize(); i++) { - DisplaySpriteAttachment(m_AttachmentsPre[i]); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + DisplaySpriteAttachment(_attachmentsPre[i]); } } else { - for (int i = 0; i < m_AttachmentsPost.GetSize(); i++) { - DisplaySpriteAttachment(m_AttachmentsPost[i]); + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + DisplaySpriteAttachment(_attachmentsPost[i]); } } return S_OK; @@ -1122,70 +1122,70 @@ HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { - if (!Attachment->m_Active) return S_OK; + if (!Attachment->_active) return S_OK; float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); - int OrigX = Attachment->m_PosX; - int OrigY = Attachment->m_PosY; + int OrigX = Attachment->_posX; + int OrigY = Attachment->_posY; // inherit position from owner - Attachment->m_PosX = this->m_PosX + Attachment->m_PosX * ScaleX / 100.0f; - Attachment->m_PosY = this->m_PosY + Attachment->m_PosY * ScaleY / 100.0f; + Attachment->_posX = this->_posX + Attachment->_posX * ScaleX / 100.0f; + Attachment->_posY = this->_posY + Attachment->_posY * ScaleY / 100.0f; // inherit other props - Attachment->m_AlphaColor = this->m_AlphaColor; - Attachment->m_BlendMode = this->m_BlendMode; + Attachment->_alphaColor = this->_alphaColor; + Attachment->_blendMode = this->_blendMode; - Attachment->m_Scale = this->m_Scale; - Attachment->m_RelativeScale = this->m_RelativeScale; - Attachment->m_ScaleX = this->m_ScaleX; - Attachment->m_ScaleY = this->m_ScaleY; + Attachment->_scale = this->_scale; + Attachment->_relativeScale = this->_relativeScale; + Attachment->_scaleX = this->_scaleX; + Attachment->_scaleY = this->_scaleY; - Attachment->m_Rotate = this->m_Rotate; - Attachment->m_RelativeRotate = this->m_RelativeRotate; - Attachment->m_RotateValid = this->m_RotateValid; + Attachment->_rotate = this->_rotate; + Attachment->_relativeRotate = this->_relativeRotate; + Attachment->_rotateValid = this->_rotateValid; - Attachment->m_RegisterAlias = this; - Attachment->m_Registrable = this->m_Registrable; + Attachment->_registerAlias = this; + Attachment->_registrable = this->_registrable; HRESULT ret = Attachment->Display(); - Attachment->m_PosX = OrigX; - Attachment->m_PosY = OrigY; + Attachment->_posX = OrigX; + Attachment->_posY = OrigY; return ret; } ////////////////////////////////////////////////////////////////////////// CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { - m_PartFollowParent = FollowParent; - m_PartOffsetX = OffsetX; - m_PartOffsetY = OffsetY; - - if (!m_PartEmitter) { - m_PartEmitter = new CPartEmitter(Game, this); - if (m_PartEmitter) { - Game->RegisterObject(m_PartEmitter); + _partFollowParent = FollowParent; + _partOffsetX = OffsetX; + _partOffsetY = OffsetY; + + if (!_partEmitter) { + _partEmitter = new CPartEmitter(Game, this); + if (_partEmitter) { + Game->RegisterObject(_partEmitter); } } UpdatePartEmitter(); - return m_PartEmitter; + return _partEmitter; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::UpdatePartEmitter() { - if (!m_PartEmitter) return E_FAIL; + if (!_partEmitter) return E_FAIL; - if (m_PartFollowParent) { + if (_partFollowParent) { float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); - m_PartEmitter->m_PosX = m_PosX + (ScaleX / 100.0f) * m_PartOffsetX; - m_PartEmitter->m_PosY = m_PosY + (ScaleY / 100.0f) * m_PartOffsetY; + _partEmitter->_posX = _posX + (ScaleX / 100.0f) * _partOffsetX; + _partEmitter->_posY = _posY + (ScaleY / 100.0f) * _partOffsetY; } - return m_PartEmitter->Update(); + return _partEmitter->Update(); } } // end of namespace WinterMute diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index e5cb39e6b4..7e0e277edb 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -45,25 +45,25 @@ class CAdInventory; class CAdObject : public CBObject { public: - CPartEmitter *m_PartEmitter; + CPartEmitter *_partEmitter; virtual CPartEmitter *CreateParticleEmitter(bool FollowParent = false, int OffsetX = 0, int OffsetY = 0); virtual HRESULT UpdatePartEmitter(); - bool m_PartFollowParent; - int m_PartOffsetX; - int m_PartOffsetY; + bool _partFollowParent; + int _partOffsetX; + int _partOffsetY; HRESULT InvalidateCurrRegions(); - bool m_SubtitlesModRelative; - bool m_SubtitlesModXCenter; - int m_SubtitlesModX; - int m_SubtitlesModY; - int m_SubtitlesWidth; - CAdRegion *m_StickRegion; - bool m_SceneIndependent; - bool m_IgnoreItems; + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int _subtitlesModX; + int _subtitlesModY; + int _subtitlesWidth; + CAdRegion *_stickRegion; + bool _sceneIndependent; + bool _ignoreItems; HRESULT UpdateBlockRegion(); - bool m_ForcedTalkAnimUsed; - char *m_ForcedTalkAnimName; + bool _forcedTalkAnimUsed; + char *_forcedTalkAnimName; virtual bool GetExtendedFlag(char *FlagName); virtual HRESULT ResetSoundPan(); virtual HRESULT UpdateSounds(); @@ -71,32 +71,32 @@ public: DECLARE_PERSISTENT(CAdObject, CBObject) virtual void Talk(char *Text, char *Sound = NULL, uint32 Duration = 0, char *Stances = NULL, TTextAlign Align = TAL_CENTER); virtual int GetHeight(); - CAdSentence *m_Sentence; + CAdSentence *_sentence; HRESULT SetFont(char *Filename); virtual HRESULT Update(); virtual HRESULT Display(); - bool m_Drawn; - bool m_Active; + bool _drawn; + bool _active; virtual HRESULT PlayAnim(char *Filename); - CBSprite *m_AnimSprite; - CBSprite *m_CurrentSprite; - TObjectState m_State; - TObjectState m_NextState; - TObjectType m_Type; + CBSprite *_animSprite; + CBSprite *_currentSprite; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; CAdObject(CBGame *inGame); virtual ~CAdObject(); - CBFont *m_Font; - CBSprite *m_TempSprite2; - CBRegion *m_BlockRegion; - CAdWaypointGroup *m_WptGroup; - CBRegion *m_CurrentBlockRegion; - CAdWaypointGroup *m_CurrentWptGroup; + CBFont *_font; + CBSprite *_tempSprite2; + CBRegion *_blockRegion; + CAdWaypointGroup *_wptGroup; + CBRegion *_currentBlockRegion; + CAdWaypointGroup *_currentWptGroup; CAdInventory *GetInventory(); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT AfterMove(); - CAdRegion *m_CurrentRegions[MAX_NUM_REGIONS]; + CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface virtual CScValue *ScGetProperty(char *Name); @@ -104,15 +104,15 @@ public: virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); virtual char *ScToString(); - CBArray m_AttachmentsPre; - CBArray m_AttachmentsPost; + CBArray _attachmentsPre; + CBArray _attachmentsPost; HRESULT UpdateSpriteAttachments(); HRESULT DisplaySpriteAttachments(bool PreDisplay); - CAdObject *m_RegisterAlias; + CAdObject *_registerAlias; private: HRESULT DisplaySpriteAttachment(CAdObject *Attachment); - CAdInventory *m_Inventory; + CAdInventory *_inventory; protected: HRESULT GetScale(float *ScaleX, float *ScaleY); diff --git a/engines/wintermute/AdPath.cpp b/engines/wintermute/AdPath.cpp index fb95f28450..f5e3d8ecc7 100644 --- a/engines/wintermute/AdPath.cpp +++ b/engines/wintermute/AdPath.cpp @@ -36,8 +36,8 @@ IMPLEMENT_PERSISTENT(CAdPath, false) ////////////////////////////////////////////////////////////////////////// CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { - m_CurrIndex = -1; - m_Ready = false; + _currIndex = -1; + _ready = false; } @@ -49,49 +49,49 @@ CAdPath::~CAdPath() { ////////////////////////////////////////////////////////////////////////// void CAdPath::Reset() { - for (int i = 0; i < m_Points.GetSize(); i++) - delete m_Points[i]; + for (int i = 0; i < _points.GetSize(); i++) + delete _points[i]; - m_Points.RemoveAll(); - m_CurrIndex = -1; - m_Ready = false; + _points.RemoveAll(); + _currIndex = -1; + _ready = false; } ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::GetFirst() { - if (m_Points.GetSize() > 0) { - m_CurrIndex = 0; - return m_Points[m_CurrIndex]; + if (_points.GetSize() > 0) { + _currIndex = 0; + return _points[_currIndex]; } else return NULL; } ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::GetNext() { - m_CurrIndex++; - if (m_CurrIndex < m_Points.GetSize()) return m_Points[m_CurrIndex]; + _currIndex++; + if (_currIndex < _points.GetSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::GetCurrent() { - if (m_CurrIndex >= 0 && m_CurrIndex < m_Points.GetSize()) return m_Points[m_CurrIndex]; + if (_currIndex >= 0 && _currIndex < _points.GetSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// void CAdPath::AddPoint(CBPoint *point) { - m_Points.Add(point); + _points.Add(point); } ////////////////////////////////////////////////////////////////////////// bool CAdPath::SetReady(bool ready) { - bool orig = m_Ready; - m_Ready = ready; + bool orig = _ready; + _ready = ready; return orig; } @@ -102,9 +102,9 @@ HRESULT CAdPath::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_CurrIndex)); - m_Points.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Ready)); + PersistMgr->Transfer(TMEMBER(_currIndex)); + _points.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_ready)); return S_OK; } diff --git a/engines/wintermute/AdPath.h b/engines/wintermute/AdPath.h index a5424fcd70..372b5e1cd4 100644 --- a/engines/wintermute/AdPath.h +++ b/engines/wintermute/AdPath.h @@ -46,9 +46,9 @@ public: void Reset(); CAdPath(CBGame *inGame); virtual ~CAdPath(); - CBArray m_Points; - int m_CurrIndex; - bool m_Ready; + CBArray _points; + int _currIndex; + bool _ready; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdPathPoint.cpp b/engines/wintermute/AdPathPoint.cpp index 3bffcd4c73..6ebb5b9090 100644 --- a/engines/wintermute/AdPathPoint.cpp +++ b/engines/wintermute/AdPathPoint.cpp @@ -36,10 +36,10 @@ IMPLEMENT_PERSISTENT(CAdPathPoint, false) ////////////////////////////////////////////////////////////////////////// CAdPathPoint::CAdPathPoint() { x = y = 0; - m_Distance = 0; + _distance = 0; - m_Marked = false; - m_Origin = NULL; + _marked = false; + _origin = NULL; } @@ -47,16 +47,16 @@ CAdPathPoint::CAdPathPoint() { CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { x = initX; y = initY; - m_Distance = initDistance; + _distance = initDistance; - m_Marked = false; - m_Origin = NULL; + _marked = false; + _origin = NULL; } ////////////////////////////////////////////////////////////////////////// CAdPathPoint::~CAdPathPoint() { - m_Origin = NULL; + _origin = NULL; } @@ -65,9 +65,9 @@ HRESULT CAdPathPoint::Persist(CBPersistMgr *PersistMgr) { CBPoint::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Distance)); - PersistMgr->Transfer(TMEMBER(m_Marked)); - PersistMgr->Transfer(TMEMBER(m_Origin)); + PersistMgr->Transfer(TMEMBER(_distance)); + PersistMgr->Transfer(TMEMBER(_marked)); + PersistMgr->Transfer(TMEMBER(_origin)); return S_OK; } diff --git a/engines/wintermute/AdPathPoint.h b/engines/wintermute/AdPathPoint.h index 0196f42701..56dee7405c 100644 --- a/engines/wintermute/AdPathPoint.h +++ b/engines/wintermute/AdPathPoint.h @@ -40,9 +40,9 @@ public: CAdPathPoint(int initX, int initY, int initDistance); CAdPathPoint(); virtual ~CAdPathPoint(); - CAdPathPoint *m_Origin; - bool m_Marked; - int m_Distance; + CAdPathPoint *_origin; + bool _marked; + int _distance; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index 51b4070f28..cd8ab049f9 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -41,10 +41,10 @@ IMPLEMENT_PERSISTENT(CAdRegion, false) ////////////////////////////////////////////////////////////////////////// CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { - m_Blocked = false; - m_Decoration = false; - m_Zoom = 0; - m_Alpha = 0xFFFFFFFF; + _blocked = false; + _decoration = false; + _zoom = 0; + _alpha = 0xFFFFFFFF; } @@ -55,7 +55,7 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRegion::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -63,8 +63,8 @@ HRESULT CAdRegion::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); @@ -130,8 +130,8 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { int i; - for (i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; - m_Points.RemoveAll(); + for (i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -150,29 +150,29 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &m_Active); + parser.ScanStr((char *)params, "%b", &_active); break; case TOKEN_BLOCKED: - parser.ScanStr((char *)params, "%b", &m_Blocked); + parser.ScanStr((char *)params, "%b", &_blocked); break; case TOKEN_DECORATION: - parser.ScanStr((char *)params, "%b", &m_Decoration); + parser.ScanStr((char *)params, "%b", &_decoration); break; case TOKEN_ZOOM: case TOKEN_SCALE: { int i; parser.ScanStr((char *)params, "%d", &i); - m_Zoom = (float)i; + _zoom = (float)i; } break; case TOKEN_POINT: { int x, y; parser.ScanStr((char *)params, "%d,%d", &x, &y); - m_Points.Add(new CBPoint(x, y)); + _points.Add(new CBPoint(x, y)); } break; @@ -185,11 +185,11 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &m_EditorSelected); + parser.ScanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_SCRIPT: @@ -212,7 +212,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { CreateRegion(); - m_Alpha = DRGBA(ar, ag, ab, alpha); + _alpha = DRGBA(ar, ag, ab, alpha); return S_OK; } @@ -228,8 +228,8 @@ HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// if(strcmp(Name, "SkipTo")==0){ Stack->CorrectParams(2); - m_PosX = Stack->Pop()->GetInt(); - m_PosY = Stack->Pop()->GetInt(); + _posX = Stack->Pop()->GetInt(); + _posY = Stack->Pop()->GetInt(); Stack->PushNULL(); return S_OK; @@ -241,54 +241,54 @@ HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CAdRegion::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("ad region"); - return m_ScValue; + _scValue->SetString("ad region"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Blocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Blocked") == 0) { - m_ScValue->SetBool(m_Blocked); - return m_ScValue; + _scValue->SetBool(_blocked); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Decoration") == 0) { - m_ScValue->SetBool(m_Decoration); - return m_ScValue; + _scValue->SetBool(_decoration); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale") == 0) { - m_ScValue->SetFloat(m_Zoom); - return m_ScValue; + _scValue->SetFloat(_zoom); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaColor") == 0) { - m_ScValue->SetInt((int)m_Alpha); - return m_ScValue; + _scValue->SetInt((int)_alpha); + return _scValue; } else return CBRegion::ScGetProperty(Name); @@ -309,7 +309,7 @@ HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { // Blocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Blocked") == 0) { - m_Blocked = Value->GetBool(); + _blocked = Value->GetBool(); return S_OK; } @@ -317,7 +317,7 @@ HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Decoration") == 0) { - m_Decoration = Value->GetBool(); + _decoration = Value->GetBool(); return S_OK; } @@ -325,7 +325,7 @@ HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale") == 0) { - m_Zoom = Value->GetFloat(); + _zoom = Value->GetFloat(); return S_OK; } @@ -333,7 +333,7 @@ HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaColor") == 0) { - m_Alpha = (uint32)Value->GetInt(); + _alpha = (uint32)Value->GetInt(); return S_OK; } @@ -350,25 +350,25 @@ char *CAdRegion::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "REGION {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", m_Blocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", m_Decoration ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)m_Zoom); - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_Alpha), D3DCOLGetG(m_Alpha), D3DCOLGetB(m_Alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_Alpha)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); int i; - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - for (i = 0; i < m_Points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + for (i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } CBBase::SaveAsText(Buffer, Indent + 2); @@ -383,10 +383,10 @@ HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CAdRegion::Persist(CBPersistMgr *PersistMgr) { CBRegion::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Alpha)); - PersistMgr->Transfer(TMEMBER(m_Blocked)); - PersistMgr->Transfer(TMEMBER(m_Decoration)); - PersistMgr->Transfer(TMEMBER(m_Zoom)); + PersistMgr->Transfer(TMEMBER(_alpha)); + PersistMgr->Transfer(TMEMBER(_blocked)); + PersistMgr->Transfer(TMEMBER(_decoration)); + PersistMgr->Transfer(TMEMBER(_zoom)); return S_OK; } diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index 61bb4d2a58..b1e977155b 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -36,10 +36,10 @@ namespace WinterMute { class CAdRegion : public CBRegion { public: DECLARE_PERSISTENT(CAdRegion, CBRegion) - uint32 m_Alpha; - float m_Zoom; - bool m_Blocked; - bool m_Decoration; + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); HRESULT LoadFile(char *Filename); diff --git a/engines/wintermute/AdResponse.cpp b/engines/wintermute/AdResponse.cpp index e9a84b4bd4..c02b2832b5 100644 --- a/engines/wintermute/AdResponse.cpp +++ b/engines/wintermute/AdResponse.cpp @@ -39,46 +39,46 @@ IMPLEMENT_PERSISTENT(CAdResponse, false) ////////////////////////////////////////////////////////////////////////// CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { - m_Text = NULL; - m_TextOrig = NULL; - m_Icon = m_IconHover = m_IconPressed = NULL; - m_Font = NULL; - m_ID = 0; - m_ResponseType = RESPONSE_ALWAYS; + _text = NULL; + _textOrig = NULL; + _icon = _iconHover = _iconPressed = NULL; + _font = NULL; + _iD = 0; + _responseType = RESPONSE_ALWAYS; } ////////////////////////////////////////////////////////////////////////// CAdResponse::~CAdResponse() { - delete[] m_Text; - delete[] m_TextOrig; - delete m_Icon; - delete m_IconHover; - delete m_IconPressed; - m_Text = NULL; - m_TextOrig = NULL; - m_Icon = NULL; - m_IconHover = NULL; - m_IconPressed = NULL; - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + delete[] _text; + delete[] _textOrig; + delete _icon; + delete _iconHover; + delete _iconPressed; + _text = NULL; + _textOrig = NULL; + _icon = NULL; + _iconHover = NULL; + _iconPressed = NULL; + if (_font) Game->_fontStorage->RemoveFont(_font); } ////////////////////////////////////////////////////////////////////////// void CAdResponse::SetText(char *Text) { - CBUtils::SetString(&m_Text, Text); - CBUtils::SetString(&m_TextOrig, Text); + CBUtils::SetString(&_text, Text); + CBUtils::SetString(&_textOrig, Text); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponse::SetIcon(char *Filename) { - delete m_Icon; - m_Icon = new CBSprite(Game); - if (!m_Icon || FAILED(m_Icon->LoadFile(Filename))) { + delete _icon; + _icon = new CBSprite(Game); + if (!_icon || FAILED(_icon->LoadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); - delete m_Icon; - m_Icon = NULL; + delete _icon; + _icon = NULL; return E_FAIL; } return S_OK; @@ -86,9 +86,9 @@ HRESULT CAdResponse::SetIcon(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponse::SetFont(char *Filename) { - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont(Filename); - if (!m_Font) { + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont(Filename); + if (!_font) { Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", Filename); return E_FAIL; } @@ -97,12 +97,12 @@ HRESULT CAdResponse::SetFont(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponse::SetIconHover(char *Filename) { - delete m_IconHover; - m_IconHover = new CBSprite(Game); - if (!m_IconHover || FAILED(m_IconHover->LoadFile(Filename))) { + delete _iconHover; + _iconHover = new CBSprite(Game); + if (!_iconHover || FAILED(_iconHover->LoadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); - delete m_IconHover; - m_IconHover = NULL; + delete _iconHover; + _iconHover = NULL; return E_FAIL; } return S_OK; @@ -111,12 +111,12 @@ HRESULT CAdResponse::SetIconHover(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponse::SetIconPressed(char *Filename) { - delete m_IconPressed; - m_IconPressed = new CBSprite(Game); - if (!m_IconPressed || FAILED(m_IconPressed->LoadFile(Filename))) { + delete _iconPressed; + _iconPressed = new CBSprite(Game); + if (!_iconPressed || FAILED(_iconPressed->LoadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); - delete m_IconPressed; - m_IconPressed = NULL; + delete _iconPressed; + _iconPressed = NULL; return E_FAIL; } return S_OK; @@ -128,14 +128,14 @@ HRESULT CAdResponse::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Icon)); - PersistMgr->Transfer(TMEMBER(m_IconHover)); - PersistMgr->Transfer(TMEMBER(m_IconPressed)); - PersistMgr->Transfer(TMEMBER(m_ID)); - PersistMgr->Transfer(TMEMBER(m_Text)); - PersistMgr->Transfer(TMEMBER(m_TextOrig)); - PersistMgr->Transfer(TMEMBER_INT(m_ResponseType)); - PersistMgr->Transfer(TMEMBER(m_Font)); + PersistMgr->Transfer(TMEMBER(_icon)); + PersistMgr->Transfer(TMEMBER(_iconHover)); + PersistMgr->Transfer(TMEMBER(_iconPressed)); + PersistMgr->Transfer(TMEMBER(_iD)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER(_textOrig)); + PersistMgr->Transfer(TMEMBER_INT(_responseType)); + PersistMgr->Transfer(TMEMBER(_font)); return S_OK; } diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h index 5c529f4b81..97fe5bccb0 100644 --- a/engines/wintermute/AdResponse.h +++ b/engines/wintermute/AdResponse.h @@ -43,16 +43,16 @@ public: HRESULT SetIconHover(char *Filename); HRESULT SetIconPressed(char *Filename); void SetText(char *Text); - int m_ID; - CBSprite *m_Icon; - CBSprite *m_IconHover; - CBSprite *m_IconPressed; - CBFont *m_Font; - char *m_Text; - char *m_TextOrig; + int _iD; + CBSprite *_icon; + CBSprite *_iconHover; + CBSprite *_iconPressed; + CBFont *_font; + char *_text; + char *_textOrig; CAdResponse(CBGame *inGame); virtual ~CAdResponse(); - TResponseType m_ResponseType; + TResponseType _responseType; }; diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index d2ff7db96f..45b73ae148 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -51,70 +51,70 @@ IMPLEMENT_PERSISTENT(CAdResponseBox, false) ////////////////////////////////////////////////////////////////////////// CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { - m_Font = m_FontHover = NULL; + _font = _fontHover = NULL; - m_Window = NULL; - m_ShieldWindow = new CUIWindow(Game); + _window = NULL; + _shieldWindow = new CUIWindow(Game); - m_Horizontal = false; - CBPlatform::SetRectEmpty(&m_ResponseArea); - m_ScrollOffset = 0; - m_Spacing = 0; + _horizontal = false; + CBPlatform::SetRectEmpty(&_responseArea); + _scrollOffset = 0; + _spacing = 0; - m_WaitingScript = NULL; - m_LastResponseText = NULL; - m_LastResponseTextOrig = NULL; + _waitingScript = NULL; + _lastResponseText = NULL; + _lastResponseTextOrig = NULL; - m_VerticalAlign = VAL_BOTTOM; - m_Align = TAL_LEFT; + _verticalAlign = VAL_BOTTOM; + _align = TAL_LEFT; } ////////////////////////////////////////////////////////////////////////// CAdResponseBox::~CAdResponseBox() { - SAFE_DELETE(m_Window); - SAFE_DELETE(m_ShieldWindow); - SAFE_DELETE_ARRAY(m_LastResponseText); - SAFE_DELETE_ARRAY(m_LastResponseTextOrig); + SAFE_DELETE(_window); + SAFE_DELETE(_shieldWindow); + SAFE_DELETE_ARRAY(_lastResponseText); + SAFE_DELETE_ARRAY(_lastResponseTextOrig); - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + if (_font) Game->_fontStorage->RemoveFont(_font); + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); ClearResponses(); ClearButtons(); - m_WaitingScript = NULL; + _waitingScript = NULL; } ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::ClearResponses() { - for (int i = 0; i < m_Responses.GetSize(); i++) { - delete m_Responses[i]; + for (int i = 0; i < _responses.GetSize(); i++) { + delete _responses[i]; } - m_Responses.RemoveAll(); + _responses.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::ClearButtons() { - for (int i = 0; i < m_RespButtons.GetSize(); i++) { - delete m_RespButtons[i]; + for (int i = 0; i < _respButtons.GetSize(); i++) { + delete _respButtons[i]; } - m_RespButtons.RemoveAll(); + _respButtons.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::InvalidateButtons() { - for (int i = 0; i < m_RespButtons.GetSize(); i++) { - m_RespButtons[i]->m_Image = NULL; - m_RespButtons[i]->m_Cursor = NULL; - m_RespButtons[i]->m_Font = NULL; - m_RespButtons[i]->m_FontHover = NULL; - m_RespButtons[i]->m_FontPress = NULL; - m_RespButtons[i]->SetText(""); + for (int i = 0; i < _respButtons.GetSize(); i++) { + _respButtons[i]->_image = NULL; + _respButtons[i]->_cursor = NULL; + _respButtons[i]->_font = NULL; + _respButtons[i]->_fontHover = NULL; + _respButtons[i]->_fontPress = NULL; + _respButtons[i]->SetText(""); } return S_OK; } @@ -124,59 +124,59 @@ HRESULT CAdResponseBox::InvalidateButtons() { HRESULT CAdResponseBox::CreateButtons() { ClearButtons(); - m_ScrollOffset = 0; - for (int i = 0; i < m_Responses.GetSize(); i++) { + _scrollOffset = 0; + for (int i = 0; i < _responses.GetSize(); i++) { CUIButton *btn = new CUIButton(Game); if (btn) { - btn->m_Parent = m_Window; - btn->m_SharedFonts = btn->m_SharedImages = true; - btn->m_SharedCursors = true; + btn->_parent = _window; + btn->_sharedFonts = btn->_sharedImages = true; + btn->_sharedCursors = true; // iconic - if (m_Responses[i]->m_Icon) { - btn->m_Image = m_Responses[i]->m_Icon; - if (m_Responses[i]->m_IconHover) btn->m_ImageHover = m_Responses[i]->m_IconHover; - if (m_Responses[i]->m_IconPressed) btn->m_ImagePress = m_Responses[i]->m_IconPressed; - - btn->SetCaption(m_Responses[i]->m_Text); - if (m_Cursor) btn->m_Cursor = m_Cursor; - else if (Game->m_ActiveCursor) btn->m_Cursor = Game->m_ActiveCursor; + if (_responses[i]->_icon) { + btn->_image = _responses[i]->_icon; + if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; + if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; + + btn->SetCaption(_responses[i]->_text); + if (_cursor) btn->_cursor = _cursor; + else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor; } // textual else { - btn->SetText(m_Responses[i]->m_Text); - btn->m_Font = (m_Font == NULL) ? Game->m_SystemFont : m_Font; - btn->m_FontHover = (m_FontHover == NULL) ? Game->m_SystemFont : m_FontHover; - btn->m_FontPress = btn->m_FontHover; - btn->m_Align = m_Align; + btn->SetText(_responses[i]->_text); + btn->_font = (_font == NULL) ? Game->_systemFont : _font; + btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover; + btn->_fontPress = btn->_fontHover; + btn->_align = _align; - if (Game->m_TouchInterface) - btn->m_FontHover = btn->m_Font; + if (Game->_touchInterface) + btn->_fontHover = btn->_font; - if (m_Responses[i]->m_Font) btn->m_Font = m_Responses[i]->m_Font; + if (_responses[i]->_font) btn->_font = _responses[i]->_font; - btn->m_Width = m_ResponseArea.right - m_ResponseArea.left; - if (btn->m_Width <= 0) btn->m_Width = Game->m_Renderer->m_Width; + btn->_width = _responseArea.right - _responseArea.left; + if (btn->_width <= 0) btn->_width = Game->_renderer->_width; } btn->SetName("response"); btn->CorrectSize(); // make the responses touchable - if (Game->m_TouchInterface) - btn->m_Height = std::max(btn->m_Height, 50); + if (Game->_touchInterface) + btn->_height = std::max(btn->_height, 50); - //btn->SetListener(this, btn, m_Responses[i]->m_ID); + //btn->SetListener(this, btn, _responses[i]->_iD); btn->SetListener(this, btn, i); - btn->m_Visible = false; - m_RespButtons.Add(btn); + btn->_visible = false; + _respButtons.Add(btn); - if (m_ResponseArea.bottom - m_ResponseArea.top < btn->m_Height) { - Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", m_Responses[i]->m_Text); - m_ResponseArea.bottom += (btn->m_Height - (m_ResponseArea.bottom - m_ResponseArea.top)); + if (_responseArea.bottom - _responseArea.top < btn->_height) { + Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); + _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); } } } - m_Ready = false; + _ready = false; return S_OK; } @@ -184,7 +184,7 @@ HRESULT CAdResponseBox::CreateButtons() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -192,8 +192,8 @@ HRESULT CAdResponseBox::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); @@ -255,48 +255,48 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WINDOW: - SAFE_DELETE(m_Window); - m_Window = new CUIWindow(Game); - if (!m_Window || FAILED(m_Window->LoadBuffer(params, false))) { - SAFE_DELETE(m_Window); + SAFE_DELETE(_window); + _window = new CUIWindow(Game); + if (!_window || FAILED(_window->LoadBuffer(params, false))) { + SAFE_DELETE(_window); cmd = PARSERR_GENERIC; - } else if (m_ShieldWindow) m_ShieldWindow->m_Parent = m_Window; + } else if (_shieldWindow) _shieldWindow->_parent = _window; break; case TOKEN_FONT: - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont((char *)params); - if (!m_Font) cmd = PARSERR_GENERIC; + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); - m_FontHover = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontHover) cmd = PARSERR_GENERIC; + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + _fontHover = Game->_fontStorage->AddFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; break; case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_ResponseArea.left, &m_ResponseArea.top, &m_ResponseArea.right, &m_ResponseArea.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); break; case TOKEN_HORIZONTAL: - parser.ScanStr((char *)params, "%b", &m_Horizontal); + parser.ScanStr((char *)params, "%b", &_horizontal); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) m_Align = TAL_CENTER; - else if (scumm_stricmp((char *)params, "right") == 0) m_Align = TAL_RIGHT; - else m_Align = TAL_LEFT; + if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_LEFT; break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) m_VerticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "center") == 0) m_VerticalAlign = VAL_CENTER; - else m_VerticalAlign = VAL_BOTTOM; + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; + else _verticalAlign = VAL_BOTTOM; break; case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &m_Spacing); + parser.ScanStr((char *)params, "%d", &_spacing); break; case TOKEN_EDITOR_PROPERTY: @@ -304,10 +304,10 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - SAFE_DELETE(m_Cursor); - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - SAFE_DELETE(m_Cursor); + SAFE_DELETE(_cursor); + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + SAFE_DELETE(_cursor); cmd = PARSERR_GENERIC; } break; @@ -318,10 +318,10 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (m_Window) { - for (int i = 0; i < m_Window->m_Widgets.GetSize(); i++) { - if (!m_Window->m_Widgets[i]->m_ListenerObject) - m_Window->m_Widgets[i]->SetListener(this, m_Window->m_Widgets[i], 0); + if (_window) { + for (int i = 0; i < _window->_widgets.GetSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); } } @@ -333,19 +333,19 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", m_ResponseArea.left, m_ResponseArea.top, m_ResponseArea.right, m_ResponseArea.bottom); + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); - if (m_FontHover && m_FontHover->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", m_FontHover->m_Filename); + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", m_Horizontal ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); - switch (m_Align) { + switch (_align) { case TAL_LEFT: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; @@ -357,7 +357,7 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { break; } - switch (m_VerticalAlign) { + switch (_verticalAlign) { case VAL_TOP: Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; @@ -369,12 +369,12 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { break; } - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", m_Spacing); + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); Buffer->PutTextIndent(Indent + 2, "\n"); // window - if (m_Window) m_Window->SaveAsText(Buffer, Indent + 2); + if (_window) _window->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -388,10 +388,10 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::Display() { - RECT rect = m_ResponseArea; - if (m_Window) { - CBPlatform::OffsetRect(&rect, m_Window->m_PosX, m_Window->m_PosY); - //m_Window->Display(); + RECT rect = _responseArea; + if (_window) { + CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + //_window->Display(); } int xxx, yyy, i; @@ -400,12 +400,12 @@ HRESULT CAdResponseBox::Display() { yyy = rect.top; // shift down if needed - if (!m_Horizontal) { + if (!_horizontal) { int total_height = 0; - for (i = 0; i < m_RespButtons.GetSize(); i++) total_height += (m_RespButtons[i]->m_Height + m_Spacing); - total_height -= m_Spacing; + for (i = 0; i < _respButtons.GetSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + total_height -= _spacing; - switch (m_VerticalAlign) { + switch (_verticalAlign) { case VAL_BOTTOM: if (yyy + total_height < rect.bottom) yyy = rect.bottom - total_height; @@ -424,48 +424,48 @@ HRESULT CAdResponseBox::Display() { // prepare response buttons bool scroll_needed = false; - for (i = m_ScrollOffset; i < m_RespButtons.GetSize(); i++) { - if ((m_Horizontal && xxx + m_RespButtons[i]->m_Width > rect.right) - || (!m_Horizontal && yyy + m_RespButtons[i]->m_Height > rect.bottom)) { + for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) + || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { scroll_needed = true; - m_RespButtons[i]->m_Visible = false; + _respButtons[i]->_visible = false; break; } - m_RespButtons[i]->m_Visible = true; - m_RespButtons[i]->m_PosX = xxx; - m_RespButtons[i]->m_PosY = yyy; + _respButtons[i]->_visible = true; + _respButtons[i]->_posX = xxx; + _respButtons[i]->_posY = yyy; - if (m_Horizontal) { - xxx += (m_RespButtons[i]->m_Width + m_Spacing); + if (_horizontal) { + xxx += (_respButtons[i]->_width + _spacing); } else { - yyy += (m_RespButtons[i]->m_Height + m_Spacing); + yyy += (_respButtons[i]->_height + _spacing); } } // show appropriate scroll buttons - if (m_Window) { - m_Window->ShowWidget("prev", m_ScrollOffset > 0); - m_Window->ShowWidget("next", scroll_needed); + if (_window) { + _window->ShowWidget("prev", _scrollOffset > 0); + _window->ShowWidget("next", scroll_needed); } // go exclusive - if (m_ShieldWindow) { - m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; - m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; - m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; - m_ShieldWindow->Display(); + _shieldWindow->Display(); } // display window - if (m_Window) m_Window->Display(); + if (_window) _window->Display(); // display response buttons - for (i = m_ScrollOffset; i < m_RespButtons.GetSize(); i++) { - m_RespButtons[i]->Display(); + for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + _respButtons[i]->Display(); } return S_OK; @@ -476,19 +476,19 @@ HRESULT CAdResponseBox::Display() { HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; - switch (obj->m_Type) { + switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->m_Name, "prev") == 0) { - m_ScrollOffset--; - } else if (scumm_stricmp(obj->m_Name, "next") == 0) { - m_ScrollOffset++; - } else if (scumm_stricmp(obj->m_Name, "response") == 0) { - if (m_WaitingScript) m_WaitingScript->m_Stack->PushInt(m_Responses[param2]->m_ID); - HandleResponse(m_Responses[param2]); - m_WaitingScript = NULL; - Game->m_State = GAME_RUNNING; - ((CAdGame *)Game)->m_StateEx = GAME_NORMAL; - m_Ready = true; + if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset--; + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset++; + } else if (scumm_stricmp(obj->_name, "response") == 0) { + if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD); + HandleResponse(_responses[param2]); + _waitingScript = NULL; + Game->_state = GAME_RUNNING; + ((CAdGame *)Game)->_stateEx = GAME_NORMAL; + _ready = true; InvalidateButtons(); ClearResponses(); } else return CBObject::Listen(param1, param2); @@ -503,22 +503,22 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Font)); - PersistMgr->Transfer(TMEMBER(m_FontHover)); - PersistMgr->Transfer(TMEMBER(m_Horizontal)); - PersistMgr->Transfer(TMEMBER(m_LastResponseText)); - PersistMgr->Transfer(TMEMBER(m_LastResponseTextOrig)); - m_RespButtons.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ResponseArea)); - m_Responses.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); - PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); - PersistMgr->Transfer(TMEMBER(m_Spacing)); - PersistMgr->Transfer(TMEMBER(m_WaitingScript)); - PersistMgr->Transfer(TMEMBER(m_Window)); - - PersistMgr->Transfer(TMEMBER_INT(m_VerticalAlign)); - PersistMgr->Transfer(TMEMBER_INT(m_Align)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_fontHover)); + PersistMgr->Transfer(TMEMBER(_horizontal)); + PersistMgr->Transfer(TMEMBER(_lastResponseText)); + PersistMgr->Transfer(TMEMBER(_lastResponseTextOrig)); + _respButtons.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_responseArea)); + _responses.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER(_spacing)); + PersistMgr->Transfer(TMEMBER(_waitingScript)); + PersistMgr->Transfer(TMEMBER(_window)); + + PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); + PersistMgr->Transfer(TMEMBER_INT(_align)); return S_OK; } @@ -528,20 +528,20 @@ HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { HRESULT CAdResponseBox::WeedResponses() { CAdGame *AdGame = (CAdGame *)Game; - for (int i = 0; i < m_Responses.GetSize(); i++) { - switch (m_Responses[i]->m_ResponseType) { + for (int i = 0; i < _responses.GetSize(); i++) { + switch (_responses[i]->_responseType) { case RESPONSE_ONCE: - if (AdGame->BranchResponseUsed(m_Responses[i]->m_ID)) { - delete m_Responses[i]; - m_Responses.RemoveAt(i); + if (AdGame->BranchResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.RemoveAt(i); i--; } break; case RESPONSE_ONCE_GAME: - if (AdGame->GameResponseUsed(m_Responses[i]->m_ID)) { - delete m_Responses[i]; - m_Responses.RemoveAt(i); + if (AdGame->GameResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.RemoveAt(i); i--; } break; @@ -553,24 +553,24 @@ HRESULT CAdResponseBox::WeedResponses() { ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::SetLastResponseText(char *Text, char *TextOrig) { - CBUtils::SetString(&m_LastResponseText, Text); - CBUtils::SetString(&m_LastResponseTextOrig, TextOrig); + CBUtils::SetString(&_lastResponseText, Text); + CBUtils::SetString(&_lastResponseTextOrig, TextOrig); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { - SetLastResponseText(Response->m_Text, Response->m_TextOrig); + SetLastResponseText(Response->_text, Response->_textOrig); CAdGame *AdGame = (CAdGame *)Game; - switch (Response->m_ResponseType) { + switch (Response->_responseType) { case RESPONSE_ONCE: - AdGame->AddBranchResponse(Response->m_ID); + AdGame->AddBranchResponse(Response->_iD); break; case RESPONSE_ONCE_GAME: - AdGame->AddGameResponse(Response->m_ID); + AdGame->AddGameResponse(Response->_iD); break; } @@ -620,10 +620,10 @@ CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::GetObjects(CBArray& Objects, bool InteractiveOnly) { - for (int i = 0; i < m_RespButtons.GetSize(); i++) { - Objects.Add(m_RespButtons[i]); + for (int i = 0; i < _respButtons.GetSize(); i++) { + Objects.Add(_respButtons[i]); } - if (m_Window) m_Window->GetWindowObjects(Objects, InteractiveOnly); + if (_window) _window->GetWindowObjects(Objects, InteractiveOnly); return S_OK; } diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h index 6abe9dc1a1..be14a6f248 100644 --- a/engines/wintermute/AdResponseBox.h +++ b/engines/wintermute/AdResponseBox.h @@ -46,10 +46,10 @@ public: HRESULT HandleResponse(CAdResponse *Response); void SetLastResponseText(char *Text, char *TextOrig); - char *m_LastResponseText; - char *m_LastResponseTextOrig; + char *_lastResponseText; + char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) - CScScript *m_WaitingScript; + CScScript *_waitingScript; virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); typedef enum { EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE @@ -57,24 +57,24 @@ public: HRESULT WeedResponses(); HRESULT Display(); - int m_Spacing; - int m_ScrollOffset; - CBFont *m_FontHover; - CBFont *m_Font; + int _spacing; + int _scrollOffset; + CBFont *_fontHover; + CBFont *_font; HRESULT CreateButtons(); HRESULT InvalidateButtons(); void ClearButtons(); void ClearResponses(); CAdResponseBox(CBGame *inGame); virtual ~CAdResponseBox(); - CBArray m_Responses; - CBArray m_RespButtons; - CUIWindow *m_Window; - CUIWindow *m_ShieldWindow; - bool m_Horizontal; - RECT m_ResponseArea; - int m_VerticalAlign; - TTextAlign m_Align; + CBArray _responses; + CBArray _respButtons; + CUIWindow *_window; + CUIWindow *_shieldWindow; + bool _horizontal; + RECT _responseArea; + int _verticalAlign; + TTextAlign _align; HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/AdResponseContext.cpp b/engines/wintermute/AdResponseContext.cpp index 1e6fad4967..c984ad079c 100644 --- a/engines/wintermute/AdResponseContext.cpp +++ b/engines/wintermute/AdResponseContext.cpp @@ -36,34 +36,34 @@ IMPLEMENT_PERSISTENT(CAdResponseContext, false) ////////////////////////////////////////////////////////////////////////// CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { - m_ID = 0; - m_Context = NULL; + _iD = 0; + _context = NULL; } ////////////////////////////////////////////////////////////////////////// CAdResponseContext::~CAdResponseContext() { - delete[] m_Context; - m_Context = NULL; + delete[] _context; + _context = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_Context)); - PersistMgr->Transfer(TMEMBER(m_ID)); + PersistMgr->Transfer(TMEMBER(_context)); + PersistMgr->Transfer(TMEMBER(_iD)); return S_OK; } ////////////////////////////////////////////////////////////////////////// void CAdResponseContext::SetContext(char *Context) { - delete[] m_Context; - m_Context = NULL; + delete[] _context; + _context = NULL; if (Context) { - m_Context = new char [strlen(Context) + 1]; - if (m_Context) strcpy(m_Context, Context); + _context = new char [strlen(Context) + 1]; + if (_context) strcpy(_context, Context); } } diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h index de3e8c95fa..c4927a79e9 100644 --- a/engines/wintermute/AdResponseContext.h +++ b/engines/wintermute/AdResponseContext.h @@ -37,8 +37,8 @@ namespace WinterMute { class CAdResponseContext : public CBBase { public: void SetContext(char *Context); - int m_ID; - char *m_Context; + int _iD; + char *_context; DECLARE_PERSISTENT(CAdResponseContext, CBBase) CAdResponseContext(CBGame *inGame); virtual ~CAdResponseContext(); diff --git a/engines/wintermute/AdRotLevel.cpp b/engines/wintermute/AdRotLevel.cpp index 11bdb4dba0..1c2ba3ed65 100644 --- a/engines/wintermute/AdRotLevel.cpp +++ b/engines/wintermute/AdRotLevel.cpp @@ -41,8 +41,8 @@ IMPLEMENT_PERSISTENT(CAdRotLevel, false) ////////////////////////////////////////////////////////////////////////// CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { - m_PosX = 0; - m_Rotation = 0.0f; + _posX = 0; + _rotation = 0.0f; } @@ -54,7 +54,7 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRotLevel::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -62,8 +62,8 @@ HRESULT CAdRotLevel::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); @@ -110,13 +110,13 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_ROTATION: { int i; parser.ScanStr((char *)params, "%d", &i); - m_Rotation = (float)i; + _rotation = (float)i; } break; @@ -137,8 +137,8 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)m_Rotation); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); CBBase::SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); @@ -151,7 +151,7 @@ HRESULT CAdRotLevel::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Rotation)); + PersistMgr->Transfer(TMEMBER(_rotation)); return S_OK; } diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h index 91ddbef641..6033935349 100644 --- a/engines/wintermute/AdRotLevel.h +++ b/engines/wintermute/AdRotLevel.h @@ -38,7 +38,7 @@ public: DECLARE_PERSISTENT(CAdRotLevel, CBObject) CAdRotLevel(CBGame *inGame); virtual ~CAdRotLevel(); - float m_Rotation; + float _rotation; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); diff --git a/engines/wintermute/AdScaleLevel.cpp b/engines/wintermute/AdScaleLevel.cpp index 09c4a78062..4edb24eca1 100644 --- a/engines/wintermute/AdScaleLevel.cpp +++ b/engines/wintermute/AdScaleLevel.cpp @@ -39,8 +39,8 @@ IMPLEMENT_PERSISTENT(CAdScaleLevel, false) ////////////////////////////////////////////////////////////////////////// CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { - m_PosY = 0; - m_Scale = 100; + _posY = 0; + _scale = 100; } @@ -52,7 +52,7 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScaleLevel::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -60,8 +60,8 @@ HRESULT CAdScaleLevel::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); @@ -108,13 +108,13 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_SCALE: { int i; parser.ScanStr((char *)params, "%d", &i); - m_Scale = (float)i; + _scale = (float)i; } break; @@ -135,8 +135,8 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)m_Scale); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); CBBase::SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); @@ -149,7 +149,7 @@ HRESULT CAdScaleLevel::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Scale)); + PersistMgr->Transfer(TMEMBER(_scale)); return S_OK; } diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h index 5fe1cafa6b..fb0cd38264 100644 --- a/engines/wintermute/AdScaleLevel.h +++ b/engines/wintermute/AdScaleLevel.h @@ -37,7 +37,7 @@ namespace WinterMute { class CAdScaleLevel : public CBObject { public: DECLARE_PERSISTENT(CAdScaleLevel, CBObject) - float m_Scale; + float _scale; CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index 37d9fdeaa5..a35f2550a1 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -67,7 +67,7 @@ IMPLEMENT_PERSISTENT(CAdScene, false) ////////////////////////////////////////////////////////////////////////// CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - m_PFTarget = new CBPoint; + _pFTarget = new CBPoint; SetDefaults(); } @@ -75,64 +75,64 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdScene::~CAdScene() { Cleanup(); - Game->UnregisterObject(m_Fader); - delete m_PFTarget; - m_PFTarget = NULL; + Game->UnregisterObject(_fader); + delete _pFTarget; + _pFTarget = NULL; } ////////////////////////////////////////////////////////////////////////// void CAdScene::SetDefaults() { - m_Initialized = false; - m_PFReady = true; - m_PFTargetPath = NULL; - m_PFRequester = NULL; - m_MainLayer = NULL; + _initialized = false; + _pFReady = true; + _pFTargetPath = NULL; + _pFRequester = NULL; + _mainLayer = NULL; - m_PFPointsNum = 0; - m_PersistentState = false; - m_PersistentStateSprites = true; + _pFPointsNum = 0; + _persistentState = false; + _persistentStateSprites = true; - m_AutoScroll = true; - m_OffsetLeft = m_OffsetTop = 0; - m_TargetOffsetLeft = m_TargetOffsetTop = 0; + _autoScroll = true; + _offsetLeft = _offsetTop = 0; + _targetOffsetLeft = _targetOffsetTop = 0; - m_LastTimeH = m_LastTimeV = 0; - m_ScrollTimeH = m_ScrollTimeV = 10; - m_ScrollPixelsH = m_ScrollPixelsV = 1; + _lastTimeH = _lastTimeV = 0; + _scrollTimeH = _scrollTimeV = 10; + _scrollPixelsH = _scrollPixelsV = 1; - m_PFMaxTime = 15; + _pFMaxTime = 15; - m_ParalaxScrolling = true; + _paralaxScrolling = true; // editor settings - m_EditorMarginH = m_EditorMarginV = 100; - - m_EditorColFrame = 0xE0888888; - m_EditorColEntity = 0xFF008000; - m_EditorColRegion = 0xFF0000FF; - m_EditorColBlocked = 0xFF800080; - m_EditorColWaypoints = 0xFF0000FF; - m_EditorColEntitySel = 0xFFFF0000; - m_EditorColRegionSel = 0xFFFF0000; - m_EditorColBlockedSel = 0xFFFF0000; - m_EditorColWaypointsSel = 0xFFFF0000; - m_EditorColScale = 0xFF00FF00; - m_EditorColDecor = 0xFF00FFFF; - m_EditorColDecorSel = 0xFFFF0000; - - m_EditorShowRegions = true; - m_EditorShowBlocked = true; - m_EditorShowDecor = true; - m_EditorShowEntities = true; - m_EditorShowScale = true; - - m_ShieldWindow = NULL; - - m_Fader = new CBFader(Game); - Game->RegisterObject(m_Fader); - - m_Viewport = NULL; + _editorMarginH = _editorMarginV = 100; + + _editorColFrame = 0xE0888888; + _editorColEntity = 0xFF008000; + _editorColRegion = 0xFF0000FF; + _editorColBlocked = 0xFF800080; + _editorColWaypoints = 0xFF0000FF; + _editorColEntitySel = 0xFFFF0000; + _editorColRegionSel = 0xFFFF0000; + _editorColBlockedSel = 0xFFFF0000; + _editorColWaypointsSel = 0xFFFF0000; + _editorColScale = 0xFF00FF00; + _editorColDecor = 0xFF00FFFF; + _editorColDecorSel = 0xFFFF0000; + + _editorShowRegions = true; + _editorShowBlocked = true; + _editorShowDecor = true; + _editorShowEntities = true; + _editorShowScale = true; + + _shieldWindow = NULL; + + _fader = new CBFader(Game); + Game->RegisterObject(_fader); + + _viewport = NULL; } @@ -140,45 +140,45 @@ void CAdScene::SetDefaults() { void CAdScene::Cleanup() { CBObject::Cleanup(); - m_MainLayer = NULL; // reference only + _mainLayer = NULL; // reference only int i; - delete m_ShieldWindow; - m_ShieldWindow = NULL; + delete _shieldWindow; + _shieldWindow = NULL; - Game->UnregisterObject(m_Fader); - m_Fader = NULL; + Game->UnregisterObject(_fader); + _fader = NULL; - for (i = 0; i < m_Layers.GetSize(); i++) - Game->UnregisterObject(m_Layers[i]); - m_Layers.RemoveAll(); + for (i = 0; i < _layers.GetSize(); i++) + Game->UnregisterObject(_layers[i]); + _layers.RemoveAll(); - for (i = 0; i < m_WaypointGroups.GetSize(); i++) - Game->UnregisterObject(m_WaypointGroups[i]); - m_WaypointGroups.RemoveAll(); + for (i = 0; i < _waypointGroups.GetSize(); i++) + Game->UnregisterObject(_waypointGroups[i]); + _waypointGroups.RemoveAll(); - for (i = 0; i < m_ScaleLevels.GetSize(); i++) - Game->UnregisterObject(m_ScaleLevels[i]); - m_ScaleLevels.RemoveAll(); + for (i = 0; i < _scaleLevels.GetSize(); i++) + Game->UnregisterObject(_scaleLevels[i]); + _scaleLevels.RemoveAll(); - for (i = 0; i < m_RotLevels.GetSize(); i++) - Game->UnregisterObject(m_RotLevels[i]); - m_RotLevels.RemoveAll(); + for (i = 0; i < _rotLevels.GetSize(); i++) + Game->UnregisterObject(_rotLevels[i]); + _rotLevels.RemoveAll(); - for (i = 0; i < m_PFPath.GetSize(); i++) - delete m_PFPath[i]; - m_PFPath.RemoveAll(); - m_PFPointsNum = 0; + for (i = 0; i < _pFPath.GetSize(); i++) + delete _pFPath[i]; + _pFPath.RemoveAll(); + _pFPointsNum = 0; - for (i = 0; i < m_Objects.GetSize(); i++) - Game->UnregisterObject(m_Objects[i]); - m_Objects.RemoveAll(); + for (i = 0; i < _objects.GetSize(); i++) + Game->UnregisterObject(_objects[i]); + _objects.RemoveAll(); - delete m_Viewport; - m_Viewport = NULL; + delete _viewport; + _viewport = NULL; SetDefaults(); } @@ -186,22 +186,22 @@ void CAdScene::Cleanup() { ////////////////////////////////////////////////////////////////////////// bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { - if (!m_PFReady) return false; + if (!_pFReady) return false; else { - m_PFReady = false; - *m_PFTarget = target; - m_PFTargetPath = path; - m_PFRequester = requester; + _pFReady = false; + *_pFTarget = target; + _pFTargetPath = path; + _pFRequester = requester; - m_PFTargetPath->Reset(); - m_PFTargetPath->SetReady(false); + _pFTargetPath->Reset(); + _pFTargetPath->SetReady(false); // prepare working path int i; PFPointsStart(); // first point - //m_PFPath.Add(new CAdPathPoint(source.x, source.y, 0)); + //_pFPath.Add(new CAdPathPoint(source.x, source.y, 0)); // if we're one pixel stuck, get unstuck int StartX = source.x; @@ -229,27 +229,27 @@ bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * //CorrectTargetPoint(&target.x, &target.y); // last point - //m_PFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); + //_pFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); PFPointsAdd(target.x, target.y, INT_MAX); // active waypoints - for (i = 0; i < m_WaypointGroups.GetSize(); i++) { - if (m_WaypointGroups[i]->m_Active) { - PFAddWaypointGroup(m_WaypointGroups[i], requester); + for (i = 0; i < _waypointGroups.GetSize(); i++) { + if (_waypointGroups[i]->_active) { + PFAddWaypointGroup(_waypointGroups[i], requester); } } // free waypoints - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && m_Objects[i] != requester && m_Objects[i]->m_CurrentWptGroup) { - PFAddWaypointGroup(m_Objects[i]->m_CurrentWptGroup, requester); + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { + PFAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != requester && AdGame->m_Objects[i]->m_CurrentWptGroup) { - PFAddWaypointGroup(AdGame->m_Objects[i]->m_CurrentWptGroup, requester); + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != requester && AdGame->_objects[i]->_currentWptGroup) { + PFAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); } } @@ -260,13 +260,13 @@ bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * ////////////////////////////////////////////////////////////////////////// void CAdScene::PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { - if (!Wpt->m_Active) return; + if (!Wpt->_active) return; - for (int i = 0; i < Wpt->m_Points.GetSize(); i++) { - if (IsBlockedAt(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, true, Requester)) continue; + for (int i = 0; i < Wpt->_points.GetSize(); i++) { + if (IsBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; - //m_PFPath.Add(new CAdPathPoint(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, INT_MAX)); - PFPointsAdd(Wpt->m_Points[i]->x, Wpt->m_Points[i]->y, INT_MAX); + //_pFPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + PFPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); } } @@ -276,12 +276,12 @@ float CAdScene::GetZoomAt(int X, int Y) { float ret = 100; bool found = false; - if (m_MainLayer) { - for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Blocked && Node->m_Region->PointInRegion(X, Y)) { - if (Node->m_Region->m_Zoom != 0) { - ret = Node->m_Region->m_Zoom; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_zoom != 0) { + ret = Node->_region->_zoom; found = true; break; } @@ -296,17 +296,17 @@ float CAdScene::GetZoomAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { - if (!Game->m_DEBUG_DebugMode) ColorCheck = false; + if (!Game->_dEBUG_DebugMode) ColorCheck = false; uint32 ret; if (ColorCheck) ret = 0xFFFF0000; else ret = 0xFFFFFFFF; - if (m_MainLayer) { - for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && (ColorCheck || !Node->m_Region->m_Blocked) && Node->m_Region->PointInRegion(X, Y)) { - if (!Node->m_Region->m_Blocked) ret = Node->m_Region->m_Alpha; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && (ColorCheck || !Node->_region->_blocked) && Node->_region->PointInRegion(X, Y)) { + if (!Node->_region->_blocked) ret = Node->_region->_alpha; break; } } @@ -322,32 +322,32 @@ bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques if (CheckFreeObjects) { int i; - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && m_Objects[i] != Requester && m_Objects[i]->m_CurrentBlockRegion) { - if (m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return true; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; } } CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != Requester && AdGame->m_Objects[i]->m_CurrentBlockRegion) { - if (AdGame->m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return true; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { + if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; } } } - if (m_MainLayer) { - for (int i = 0; i < m_MainLayer->m_Nodes.GetSize(); i++) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; /* - if(Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->m_Blocked && Node->m_Region->PointInRegion(X, Y)) + if(Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { ret = true; break; } */ - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Decoration && Node->m_Region->PointInRegion(X, Y)) { - if (Node->m_Region->m_Blocked) { + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_blocked) { ret = true; break; } else ret = false; @@ -365,25 +365,25 @@ bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Reque if (CheckFreeObjects) { int i; - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && m_Objects[i] != Requester && m_Objects[i]->m_CurrentBlockRegion) { - if (m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return false; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; } } CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - if (AdGame->m_Objects[i]->m_Active && AdGame->m_Objects[i] != Requester && AdGame->m_Objects[i]->m_CurrentBlockRegion) { - if (AdGame->m_Objects[i]->m_CurrentBlockRegion->PointInRegion(X, Y)) return false; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { + if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; } } } - if (m_MainLayer) { - for (int i = 0; i < m_MainLayer->m_Nodes.GetSize(); i++) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && !Node->m_Region->m_Decoration && Node->m_Region->PointInRegion(X, Y)) { - if (Node->m_Region->m_Blocked) { + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_blocked) { ret = false; break; } else ret = true; @@ -446,39 +446,39 @@ void CAdScene::PathFinderStep() { int lowest_dist = INT_MAX; CAdPathPoint *lowest_pt = NULL; - for (i = 0; i < m_PFPointsNum; i++) - if (!m_PFPath[i]->m_Marked && m_PFPath[i]->m_Distance < lowest_dist) { - lowest_dist = m_PFPath[i]->m_Distance; - lowest_pt = m_PFPath[i]; + for (i = 0; i < _pFPointsNum; i++) + if (!_pFPath[i]->_marked && _pFPath[i]->_distance < lowest_dist) { + lowest_dist = _pFPath[i]->_distance; + lowest_pt = _pFPath[i]; } if (lowest_pt == NULL) { // no path -> terminate PathFinder - m_PFReady = true; - m_PFTargetPath->SetReady(true); + _pFReady = true; + _pFTargetPath->SetReady(true); return; } - lowest_pt->m_Marked = true; + lowest_pt->_marked = true; // target point marked, generate path and terminate - if (lowest_pt->x == m_PFTarget->x && lowest_pt->y == m_PFTarget->y) { + if (lowest_pt->x == _pFTarget->x && lowest_pt->y == _pFTarget->y) { while (lowest_pt != NULL) { - m_PFTargetPath->m_Points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); - lowest_pt = lowest_pt->m_Origin; + _pFTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); + lowest_pt = lowest_pt->_origin; } - m_PFReady = true; - m_PFTargetPath->SetReady(true); + _pFReady = true; + _pFTargetPath->SetReady(true); return; } // otherwise keep on searching - for (i = 0; i < m_PFPointsNum; i++) - if (!m_PFPath[i]->m_Marked) { - int j = GetPointsDist(*lowest_pt, *m_PFPath[i], m_PFRequester); - if (j != -1 && lowest_pt->m_Distance + j < m_PFPath[i]->m_Distance) { - m_PFPath[i]->m_Distance = lowest_pt->m_Distance + j; - m_PFPath[i]->m_Origin = lowest_pt; + for (i = 0; i < _pFPointsNum; i++) + if (!_pFPath[i]->_marked) { + int j = GetPointsDist(*lowest_pt, *_pFPath[i], _pFRequester); + if (j != -1 && lowest_pt->_distance + j < _pFPath[i]->_distance) { + _pFPath[i]->_distance = lowest_pt->_distance + j; + _pFPath[i]->_origin = lowest_pt; } } } @@ -487,16 +487,16 @@ void CAdScene::PathFinderStep() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::InitLoop() { #ifdef _DEBUGxxxx - int num_steps = 0; - uint32 start = Game->m_CurrentTime; - while (!m_PFReady && CBPlatform::GetTime() - start <= m_PFMaxTime) { + int nu_steps = 0; + uint32 start = Game->_currentTime; + while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) { PathFinderStep(); - num_steps++; + nu_steps++; } - if (num_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) m_PFMaxTime=%d", num_steps, m_PFReady ? "finished" : "not yet done", m_PFMaxTime); + if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pFMaxTime=%d", nu_steps, _pFReady ? "finished" : "not yet done", _pFMaxTime); #else - uint32 start = Game->m_CurrentTime; - while (!m_PFReady && CBPlatform::GetTime() - start <= m_PFMaxTime) PathFinderStep(); + uint32 start = Game->_currentTime; + while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) PathFinderStep(); #endif return S_OK; @@ -505,7 +505,7 @@ HRESULT CAdScene::InitLoop() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -513,14 +513,14 @@ HRESULT CAdScene::LoadFile(char *Filename) { HRESULT ret; - delete[] m_Filename; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + delete[] _filename; + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); delete [] Buffer; @@ -650,11 +650,11 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { layer = NULL; } else { Game->RegisterObject(layer); - m_Layers.Add(layer); - if (layer->m_Main) { - m_MainLayer = layer; - m_Width = layer->m_Width; - m_Height = layer->m_Height; + _layers.Add(layer); + if (layer->_main) { + _mainLayer = layer; + _width = layer->_width; + _height = layer->_height; } } } @@ -668,7 +668,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { wpt = NULL; } else { Game->RegisterObject(wpt); - m_WaypointGroups.Add(wpt); + _waypointGroups.Add(wpt); } } break; @@ -681,7 +681,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { sl = NULL; } else { Game->RegisterObject(sl); - m_ScaleLevels.Add(sl); + _scaleLevels.Add(sl); } } break; @@ -694,7 +694,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { rl = NULL; } else { Game->RegisterObject(rl); - m_RotLevels.Add(rl); + _rotLevels.Add(rl); } } break; @@ -712,11 +712,11 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -726,91 +726,91 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_MARGIN_H: - parser.ScanStr((char *)params, "%d", &m_EditorMarginH); + parser.ScanStr((char *)params, "%d", &_editorMarginH); break; case TOKEN_EDITOR_MARGIN_V: - parser.ScanStr((char *)params, "%d", &m_EditorMarginV); + parser.ScanStr((char *)params, "%d", &_editorMarginV); break; case TOKEN_EDITOR_COLOR_FRAME: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColFrame = DRGBA(ar, ag, ab, aa); + _editorColFrame = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColEntity = DRGBA(ar, ag, ab, aa); + _editorColEntity = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY_SEL: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColEntitySel = DRGBA(ar, ag, ab, aa); + _editorColEntitySel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION_SEL: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColRegionSel = DRGBA(ar, ag, ab, aa); + _editorColRegionSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION_SEL: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColDecorSel = DRGBA(ar, ag, ab, aa); + _editorColDecorSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED_SEL: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColBlockedSel = DRGBA(ar, ag, ab, aa); + _editorColBlockedSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColWaypointsSel = DRGBA(ar, ag, ab, aa); + _editorColWaypointsSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColRegion = DRGBA(ar, ag, ab, aa); + _editorColRegion = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColDecor = DRGBA(ar, ag, ab, aa); + _editorColDecor = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColBlocked = DRGBA(ar, ag, ab, aa); + _editorColBlocked = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColWaypoints = DRGBA(ar, ag, ab, aa); + _editorColWaypoints = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_SCALE: parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - m_EditorColScale = DRGBA(ar, ag, ab, aa); + _editorColScale = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_SHOW_REGIONS: - parser.ScanStr((char *)params, "%b", &m_EditorShowRegions); + parser.ScanStr((char *)params, "%b", &_editorShowRegions); break; case TOKEN_EDITOR_SHOW_BLOCKED: - parser.ScanStr((char *)params, "%b", &m_EditorShowBlocked); + parser.ScanStr((char *)params, "%b", &_editorShowBlocked); break; case TOKEN_EDITOR_SHOW_DECORATION: - parser.ScanStr((char *)params, "%b", &m_EditorShowDecor); + parser.ScanStr((char *)params, "%b", &_editorShowDecor); break; case TOKEN_EDITOR_SHOW_ENTITIES: - parser.ScanStr((char *)params, "%b", &m_EditorShowEntities); + parser.ScanStr((char *)params, "%b", &_editorShowEntities); break; case TOKEN_EDITOR_SHOW_SCALE: - parser.ScanStr((char *)params, "%b", &m_EditorShowScale); + parser.ScanStr((char *)params, "%b", &_editorShowScale); break; case TOKEN_SCRIPT: @@ -824,16 +824,16 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_VIEWPORT: { RECT rc; parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!m_Viewport) m_Viewport = new CBViewport(Game); - if (m_Viewport) m_Viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) _viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); } case TOKEN_PERSISTENT_STATE: - parser.ScanStr((char *)params, "%b", &m_PersistentState); + parser.ScanStr((char *)params, "%b", &_persistentState); break; case TOKEN_PERSISTENT_STATE_SPRITES: - parser.ScanStr((char *)params, "%b", &m_PersistentStateSprites); + parser.ScanStr((char *)params, "%b", &_persistentStateSprites); break; case TOKEN_EDITOR_PROPERTY: @@ -847,13 +847,13 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (m_MainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", m_Filename); + if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); SortScaleLevels(); SortRotLevels(); - m_Initialized = true; + _initialized = true; return S_OK; @@ -861,7 +861,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::TraverseNodes(bool Update) { - if (!m_Initialized) return S_OK; + if (!_initialized) return S_OK; int j, k; CAdGame *AdGame = (CAdGame *)Game; @@ -870,11 +870,11 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// // prepare viewport bool PopViewport = false; - if (m_Viewport && !Game->m_EditorMode) { - Game->PushViewport(m_Viewport); + if (_viewport && !Game->_editorMode) { + Game->PushViewport(_viewport); PopViewport = true; - } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { - Game->PushViewport(AdGame->m_SceneViewport); + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + Game->PushViewport(AdGame->_sceneViewport); PopViewport = true; } @@ -883,39 +883,39 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // *** adjust scroll offset if (Update) { /* - if(m_AutoScroll && Game->m_MainObject != NULL) + if(_autoScroll && Game->_mainObject != NULL) { - ScrollToObject(Game->m_MainObject); + ScrollToObject(Game->_mainObject); } */ - if (m_AutoScroll) { + if (_autoScroll) { // adjust horizontal scroll - if (Game->m_Timer - m_LastTimeH >= m_ScrollTimeH) { - m_LastTimeH = Game->m_Timer; - if (m_OffsetLeft < m_TargetOffsetLeft) { - m_OffsetLeft += m_ScrollPixelsH; - m_OffsetLeft = std::min(m_OffsetLeft, m_TargetOffsetLeft); - } else if (m_OffsetLeft > m_TargetOffsetLeft) { - m_OffsetLeft -= m_ScrollPixelsH; - m_OffsetLeft = std::max(m_OffsetLeft, m_TargetOffsetLeft); + if (Game->_timer - _lastTimeH >= _scrollTimeH) { + _lastTimeH = Game->_timer; + if (_offsetLeft < _targetOffsetLeft) { + _offsetLeft += _scrollPixelsH; + _offsetLeft = std::min(_offsetLeft, _targetOffsetLeft); + } else if (_offsetLeft > _targetOffsetLeft) { + _offsetLeft -= _scrollPixelsH; + _offsetLeft = std::max(_offsetLeft, _targetOffsetLeft); } } // adjust vertical scroll - if (Game->m_Timer - m_LastTimeV >= m_ScrollTimeV) { - m_LastTimeV = Game->m_Timer; - if (m_OffsetTop < m_TargetOffsetTop) { - m_OffsetTop += m_ScrollPixelsV; - m_OffsetTop = std::min(m_OffsetTop, m_TargetOffsetTop); - } else if (m_OffsetTop > m_TargetOffsetTop) { - m_OffsetTop -= m_ScrollPixelsV; - m_OffsetTop = std::max(m_OffsetTop, m_TargetOffsetTop); + if (Game->_timer - _lastTimeV >= _scrollTimeV) { + _lastTimeV = Game->_timer; + if (_offsetTop < _targetOffsetTop) { + _offsetTop += _scrollPixelsV; + _offsetTop = std::min(_offsetTop, _targetOffsetTop); + } else if (_offsetTop > _targetOffsetTop) { + _offsetTop -= _scrollPixelsV; + _offsetTop = std::max(_offsetTop, _targetOffsetTop); } } - if (m_OffsetTop == m_TargetOffsetTop && m_OffsetLeft == m_TargetOffsetLeft) m_Ready = true; - } else m_Ready = true; // not scrolling, i.e. always ready + if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; + } else _ready = true; // not scrolling, i.e. always ready } @@ -928,11 +928,11 @@ HRESULT CAdScene::TraverseNodes(bool Update) { int ViewportX, ViewportY; GetViewportOffset(&ViewportX, &ViewportY); - int ScrollableX = m_Width - ViewportWidth; - int ScrollableY = m_Height - ViewportHeight; + int ScrollableX = _width - ViewportWidth; + int ScrollableY = _height - ViewportHeight; - double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(m_OffsetLeft) / (double)ScrollableX); - double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(m_OffsetTop) / (double)ScrollableY); + double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)ScrollableX); + double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)ScrollableY); int OrigX, OrigY; Game->GetOffset(&OrigX, &OrigY); @@ -941,70 +941,70 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// // *** display/update everything - Game->m_Renderer->Setup2D(); + Game->_renderer->Setup2D(); // for each layer int MainOffsetX = 0; int MainOffsetY = 0; - for (j = 0; j < m_Layers.GetSize(); j++) { - if (!m_Layers[j]->m_Active) continue; + for (j = 0; j < _layers.GetSize(); j++) { + if (!_layers[j]->_active) continue; // make layer exclusive if (!Update) { - if (m_Layers[j]->m_CloseUp && !Game->m_EditorMode) { - if (!m_ShieldWindow) m_ShieldWindow = new CUIWindow(Game); - if (m_ShieldWindow) { - m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; - m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; - m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; - m_ShieldWindow->Display(); + if (_layers[j]->_closeUp && !Game->_editorMode) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; + _shieldWindow->Display(); } } } - if (m_ParalaxScrolling) { - int OffsetX = (int)(WidthRatio * (m_Layers[j]->m_Width - ViewportWidth) - ViewportX); - int OffsetY = (int)(HeightRatio * (m_Layers[j]->m_Height - ViewportHeight) - ViewportY); + if (_paralaxScrolling) { + int OffsetX = (int)(WidthRatio * (_layers[j]->_width - ViewportWidth) - ViewportX); + int OffsetY = (int)(HeightRatio * (_layers[j]->_height - ViewportHeight) - ViewportY); Game->SetOffset(OffsetX, OffsetY); - Game->m_OffsetPercentX = (float)OffsetX / ((float)m_Layers[j]->m_Width - ViewportWidth) * 100.0f; - Game->m_OffsetPercentY = (float)OffsetY / ((float)m_Layers[j]->m_Height - ViewportHeight) * 100.0f; + Game->_offsetPercentX = (float)OffsetX / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; + Game->_offsetPercentY = (float)OffsetY / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; - //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->m_OffsetPercentX); + //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); } else { - Game->SetOffset(m_OffsetLeft - ViewportX, m_OffsetTop - ViewportY); + Game->SetOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); - Game->m_OffsetPercentX = (float)(m_OffsetLeft - ViewportX) / ((float)m_Layers[j]->m_Width - ViewportWidth) * 100.0f; - Game->m_OffsetPercentY = (float)(m_OffsetTop - ViewportY) / ((float)m_Layers[j]->m_Height - ViewportHeight) * 100.0f; + Game->_offsetPercentX = (float)(_offsetLeft - ViewportX) / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; + Game->_offsetPercentY = (float)(_offsetTop - ViewportY) / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; } // for each node - for (k = 0; k < m_Layers[j]->m_Nodes.GetSize(); k++) { - CAdSceneNode *Node = m_Layers[j]->m_Nodes[k]; - switch (Node->m_Type) { + for (k = 0; k < _layers[j]->_nodes.GetSize(); k++) { + CAdSceneNode *Node = _layers[j]->_nodes[k]; + switch (Node->_type) { case OBJECT_ENTITY: - if (Node->m_Entity->m_Active && (Game->m_EditorMode || !Node->m_Entity->m_EditorOnly)) { - Game->m_Renderer->Setup2D(); + if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { + Game->_renderer->Setup2D(); - if (Update) Node->m_Entity->Update(); - else Node->m_Entity->Display(); + if (Update) Node->_entity->Update(); + else Node->_entity->Display(); } break; case OBJECT_REGION: { - if (Node->m_Region->m_Blocked) break; - if (Node->m_Region->m_Decoration) break; + if (Node->_region->_blocked) break; + if (Node->_region->_decoration) break; - if (!Update) DisplayRegionContent(Node->m_Region); + if (!Update) DisplayRegionContent(Node->_region); } break; } // switch } // each node // display/update all objects which are off-regions - if (m_Layers[j]->m_Main) { + if (_layers[j]->_main) { if (Update) { UpdateFreeObjects(); } else { @@ -1016,12 +1016,12 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // restore state Game->SetOffset(OrigX, OrigY); - Game->m_Renderer->Setup2D(); + Game->_renderer->Setup2D(); // display/update fader - if (m_Fader) { - if (Update) m_Fader->Update(); - else m_Fader->Display(); + if (_fader) { + if (Update) _fader->Update(); + else _fader->Display(); } if (PopViewport) Game->PopViewport(); @@ -1044,24 +1044,24 @@ HRESULT CAdScene::UpdateFreeObjects() { // *** update all active objects Is3DSet = false; - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - if (!AdGame->m_Objects[i]->m_Active) continue; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (!AdGame->_objects[i]->_active) continue; - AdGame->m_Objects[i]->Update(); - AdGame->m_Objects[i]->m_Drawn = false; + AdGame->_objects[i]->Update(); + AdGame->_objects[i]->_drawn = false; } - for (i = 0; i < m_Objects.GetSize(); i++) { - if (!m_Objects[i]->m_Active) continue; + for (i = 0; i < _objects.GetSize(); i++) { + if (!_objects[i]->_active) continue; - m_Objects[i]->Update(); - m_Objects[i]->m_Drawn = false; + _objects[i]->Update(); + _objects[i]->_drawn = false; } - if (m_AutoScroll && Game->m_MainObject != NULL) { - ScrollToObject(Game->m_MainObject); + if (_autoScroll && Game->_mainObject != NULL) { + ScrollToObject(Game->_mainObject); } @@ -1078,44 +1078,44 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { int i; // global objects - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - Obj = AdGame->m_Objects[i]; - if (Obj->m_Active && !Obj->m_Drawn && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + Obj = AdGame->_objects[i]; + if (Obj->_active && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { Objects.Add(Obj); } } // scene objects - for (i = 0; i < m_Objects.GetSize(); i++) { - Obj = m_Objects[i]; - if (Obj->m_Active && !Obj->m_EditorOnly && !Obj->m_Drawn && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { + for (i = 0; i < _objects.GetSize(); i++) { + Obj = _objects[i]; + if (Obj->_active && !Obj->_editorOnly && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { Objects.Add(Obj); } } - // sort by m_PosY + // sort by _posY qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); // display them for (i = 0; i < Objects.GetSize(); i++) { Obj = Objects[i]; - if (Display3DOnly && !Obj->m_Is3D) continue; + if (Display3DOnly && !Obj->_is3D) continue; - Game->m_Renderer->Setup2D(); + Game->_renderer->Setup2D(); - if (Game->m_EditorMode || !Obj->m_EditorOnly) Obj->Display(); - Obj->m_Drawn = true; + if (Game->_editorMode || !Obj->_editorOnly) Obj->Display(); + Obj->_drawn = true; } // display design only objects if (!Display3DOnly) { - if (Game->m_EditorMode && Region == NULL) { - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && m_Objects[i]->m_EditorOnly) { - m_Objects[i]->Display(); - m_Objects[i]->m_Drawn = true; + if (Game->_editorMode && Region == NULL) { + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->Display(); + _objects[i]->_drawn = true; } } } @@ -1129,8 +1129,8 @@ int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { CAdObject *Object1 = *(CAdObject **)Obj1; CAdObject *Object2 = *(CAdObject **)Obj2; - if (Object1->m_PosY < Object2->m_PosY) return -1; - else if (Object1->m_PosY > Object2->m_PosY) return 1; + if (Object1->_posY < Object2->_posY) return -1; + else if (Object1->_posY > Object2->_posY) return 1; else return 0; } @@ -1140,43 +1140,43 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { CAdObject *obj; int i; - // display all objects in region sorted by m_PosY + // display all objects in region sorted by _posY do { obj = NULL; int minY = INT_MAX; // global objects - for (i = 0; i < AdGame->m_Objects.GetSize(); i++) { - if (AdGame->m_Objects[i]->m_Active && !AdGame->m_Objects[i]->m_Drawn && AdGame->m_Objects[i]->m_PosY < minY && (AdGame->m_Objects[i]->m_StickRegion == Region || Region == NULL || (AdGame->m_Objects[i]->m_StickRegion == NULL && Region->PointInRegion(AdGame->m_Objects[i]->m_PosX, AdGame->m_Objects[i]->m_PosY)))) { - obj = AdGame->m_Objects[i]; - minY = AdGame->m_Objects[i]->m_PosY; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && !AdGame->_objects[i]->_drawn && AdGame->_objects[i]->_posY < minY && (AdGame->_objects[i]->_stickRegion == Region || Region == NULL || (AdGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(AdGame->_objects[i]->_posX, AdGame->_objects[i]->_posY)))) { + obj = AdGame->_objects[i]; + minY = AdGame->_objects[i]->_posY; } } // scene objects - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && !m_Objects[i]->m_EditorOnly && !m_Objects[i]->m_Drawn && m_Objects[i]->m_PosY < minY && (m_Objects[i]->m_StickRegion == Region || Region == NULL || (m_Objects[i]->m_StickRegion == NULL && Region->PointInRegion(m_Objects[i]->m_PosX, m_Objects[i]->m_PosY)))) { - obj = m_Objects[i]; - minY = m_Objects[i]->m_PosY; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == Region || Region == NULL || (_objects[i]->_stickRegion == NULL && Region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + obj = _objects[i]; + minY = _objects[i]->_posY; } } if (obj != NULL) { - Game->m_Renderer->Setup2D(); + Game->_renderer->Setup2D(); - if (Game->m_EditorMode || !obj->m_EditorOnly) obj->Display(); - obj->m_Drawn = true; + if (Game->_editorMode || !obj->_editorOnly) obj->Display(); + obj->_drawn = true; } } while (obj != NULL); // design only objects - if (Game->m_EditorMode && Region == NULL) { - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Active && m_Objects[i]->m_EditorOnly) { - m_Objects[i]->Display(); - m_Objects[i]->m_Drawn = true; + if (Game->_editorMode && Region == NULL) { + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->Display(); + _objects[i]->_drawn = true; } } } @@ -1195,35 +1195,35 @@ void CAdScene::ScrollTo(int OffsetX, int OffsetY) { int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - int OrigOffsetLeft = m_TargetOffsetLeft; - int OrigOffsetTop = m_TargetOffsetTop; + int OrigOffsetLeft = _targetOffsetLeft; + int OrigOffsetTop = _targetOffsetTop; - m_TargetOffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); - m_TargetOffsetLeft = std::min(m_TargetOffsetLeft, m_Width - ViewportWidth); + _targetOffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); + _targetOffsetLeft = std::min(_targetOffsetLeft, _width - ViewportWidth); - m_TargetOffsetTop = std::max(0, OffsetY - ViewportHeight / 2); - m_TargetOffsetTop = std::min(m_TargetOffsetTop, m_Height - ViewportHeight); + _targetOffsetTop = std::max(0, OffsetY - ViewportHeight / 2); + _targetOffsetTop = std::min(_targetOffsetTop, _height - ViewportHeight); - if (Game->m_MainObject && Game->m_MainObject->m_Is3D) { - if (abs(OrigOffsetLeft - m_TargetOffsetLeft) < 5) m_TargetOffsetLeft = OrigOffsetLeft; - if (abs(OrigOffsetTop - m_TargetOffsetTop) < 5) m_TargetOffsetTop = OrigOffsetTop; - //m_TargetOffsetTop = 0; + if (Game->_mainObject && Game->_mainObject->_is3D) { + if (abs(OrigOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = OrigOffsetLeft; + if (abs(OrigOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = OrigOffsetTop; + //_targetOffsetTop = 0; } - m_Ready = false; + _ready = false; } ////////////////////////////////////////////////////////////////////////// void CAdScene::ScrollToObject(CBObject *Object) { - if (Object) ScrollTo(Object->m_PosX, Object->m_PosY - Object->GetHeight() / 2); + if (Object) ScrollTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); } ////////////////////////////////////////////////////////////////////////// void CAdScene::SkipToObject(CBObject *Object) { - if (Object) SkipTo(Object->m_PosX, Object->m_PosY - Object->GetHeight() / 2); + if (Object) SkipTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); } @@ -1232,14 +1232,14 @@ void CAdScene::SkipTo(int OffsetX, int OffsetY) { int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - m_OffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); - m_OffsetLeft = std::min(m_OffsetLeft, m_Width - ViewportWidth); + _offsetLeft = std::max(0, OffsetX - ViewportWidth / 2); + _offsetLeft = std::min(_offsetLeft, _width - ViewportWidth); - m_OffsetTop = std::max(0, OffsetY - ViewportHeight / 2); - m_OffsetTop = std::min(m_OffsetTop, m_Height - ViewportHeight); + _offsetTop = std::max(0, OffsetY - ViewportHeight / 2); + _offsetTop = std::min(_offsetTop, _height - ViewportHeight); - m_TargetOffsetLeft = m_OffsetLeft; - m_TargetOffsetTop = m_OffsetTop; + _targetOffsetLeft = _offsetLeft; + _targetOffsetTop = _offsetTop; } @@ -1350,14 +1350,14 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *val = Stack->Pop(); if (val->IsInt()) { int layer = val->GetInt(); - if (layer < 0 || layer >= m_Layers.GetSize()) Stack->PushNULL(); - else Stack->PushNative(m_Layers[layer], true); + if (layer < 0 || layer >= _layers.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_layers[layer], true); } else { char *LayerName = val->GetString(); bool LayerFound = false; - for (int i = 0; i < m_Layers.GetSize(); i++) { - if (scumm_stricmp(LayerName, m_Layers[i]->m_Name) == 0) { - Stack->PushNative(m_Layers[i], true); + for (int i = 0; i < _layers.GetSize(); i++) { + if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { + Stack->PushNative(_layers[i], true); LayerFound = true; break; } @@ -1373,8 +1373,8 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "GetWaypointGroup") == 0) { Stack->CorrectParams(1); int group = Stack->Pop()->GetInt(); - if (group < 0 || group >= m_WaypointGroups.GetSize()) Stack->PushNULL(); - else Stack->PushNative(m_WaypointGroups[group], true); + if (group < 0 || group >= _waypointGroups.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_waypointGroups[group], true); return S_OK; } @@ -1402,12 +1402,12 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdObject *Ret = NULL; if (Val->IsInt()) { int Index = Val->GetInt(); - if (Index >= 0 && Index < m_Objects.GetSize()) Ret = m_Objects[Index]; + if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; } else { char *Name = Val->GetString(); - for (int i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i] && m_Objects[i]->m_Name && scumm_stricmp(m_Objects[i]->m_Name, Name) == 0) { - Ret = m_Objects[i]; + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, Name) == 0) { + Ret = _objects[i]; break; } } @@ -1430,13 +1430,13 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi bool IncludeDecors = false; if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); - if (m_MainLayer) { - for (int i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->PointInRegion(X, Y)) { - if (Node->m_Region->m_Decoration && !IncludeDecors) continue; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_decoration && !IncludeDecors) continue; - Stack->PushNative(Node->m_Region, true); + Stack->PushNative(Node->_region, true); return S_OK; } } @@ -1499,8 +1499,8 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "IsScrolling") == 0) { Stack->CorrectParams(0); bool Ret = false; - if (m_AutoScroll) { - if (m_TargetOffsetLeft != m_OffsetLeft || m_TargetOffsetTop != m_OffsetTop) Ret = true; + if (_autoScroll) { + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; } Stack->PushBool(Ret); @@ -1518,8 +1518,8 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi byte Blue = Stack->Pop()->GetInt(0); byte Alpha = Stack->Pop()->GetInt(0xFF); - m_Fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(m_Fader); + _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); return S_OK; @@ -1536,8 +1536,8 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi byte Blue = Stack->Pop()->GetInt(0); byte Alpha = Stack->Pop()->GetInt(0xFF); - m_Fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(m_Fader); + _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); return S_OK; @@ -1548,7 +1548,7 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFadeColor") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_Fader->GetCurrentColor()); + Stack->PushInt(_fader->GetCurrentColor()); return S_OK; } @@ -1573,11 +1573,11 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int Width = Stack->Pop()->GetInt(); int Height = Stack->Pop()->GetInt(); - if (Width <= 0) Width = Game->m_Renderer->m_Width; - if (Height <= 0) Height = Game->m_Renderer->m_Height; + if (Width <= 0) Width = Game->_renderer->_width; + if (Height <= 0) Height = Game->_renderer->_height; - if (!m_Viewport) m_Viewport = new CBViewport(Game); - if (m_Viewport) m_Viewport->SetRect(X, Y, X + Width, Y + Height); + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) _viewport->SetRect(X, Y, X + Width, Y + Height); Stack->PushBool(true); @@ -1593,11 +1593,11 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->SetName(Val->GetString()); - if (m_MainLayer) { - Layer->m_Width = m_MainLayer->m_Width; - Layer->m_Height = m_MainLayer->m_Height; + if (_mainLayer) { + Layer->_width = _mainLayer->_width; + Layer->_height = _mainLayer->_height; } - m_Layers.Add(Layer); + _layers.Add(Layer); Game->RegisterObject(Layer); Stack->PushNative(Layer, true); @@ -1614,13 +1614,13 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->SetName(Val->GetString()); - if (m_MainLayer) { - Layer->m_Width = m_MainLayer->m_Width; - Layer->m_Height = m_MainLayer->m_Height; + if (_mainLayer) { + Layer->_width = _mainLayer->_width; + Layer->_height = _mainLayer->_height; } if (Index < 0) Index = 0; - if (Index <= m_Layers.GetSize() - 1) m_Layers.InsertAt(Index, Layer); - else m_Layers.Add(Layer); + if (Index <= _layers.GetSize() - 1) _layers.InsertAt(Index, Layer); + else _layers.Add(Layer); Game->RegisterObject(Layer); @@ -1638,16 +1638,16 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdLayer *ToDelete = NULL; if (Val->IsNative()) { CBScriptable *Temp = Val->GetNative(); - for (int i = 0; i < m_Layers.GetSize(); i++) { - if (m_Layers[i] == Temp) { - ToDelete = m_Layers[i]; + for (int i = 0; i < _layers.GetSize(); i++) { + if (_layers[i] == Temp) { + ToDelete = _layers[i]; break; } } } else { int Index = Val->GetInt(); - if (Index >= 0 && Index < m_Layers.GetSize()) { - ToDelete = m_Layers[Index]; + if (Index >= 0 && Index < _layers.GetSize()) { + ToDelete = _layers[Index]; } } if (ToDelete == NULL) { @@ -1655,15 +1655,15 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - if (ToDelete->m_Main) { + if (ToDelete->_main) { Script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); Stack->PushBool(false); return S_OK; } - for (int i = 0; i < m_Layers.GetSize(); i++) { - if (m_Layers[i] == ToDelete) { - m_Layers.RemoveAt(i); + for (int i = 0; i < _layers.GetSize(); i++) { + if (_layers[i] == ToDelete) { + _layers.RemoveAt(i); Game->UnregisterObject(ToDelete); break; } @@ -1678,48 +1678,48 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdScene::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("scene"); - return m_ScValue; + _scValue->SetString("scene"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumLayers") == 0) { - m_ScValue->SetInt(m_Layers.GetSize()); - return m_ScValue; + _scValue->SetInt(_layers.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumWaypointGroups") == 0) { - m_ScValue->SetInt(m_WaypointGroups.GetSize()); - return m_ScValue; + _scValue->SetInt(_waypointGroups.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MainLayer (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MainLayer") == 0) { - if (m_MainLayer) m_ScValue->SetNative(m_MainLayer, true); - else m_ScValue->SetNULL(); + if (_mainLayer) _scValue->SetNative(_mainLayer, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumFreeNodes") == 0) { - m_ScValue->SetInt(m_Objects.GetSize()); - return m_ScValue; + _scValue->SetInt(_objects.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -1729,8 +1729,8 @@ CScValue *CAdScene::ScGetProperty(char *Name) { int ViewportX; GetViewportOffset(&ViewportX); - m_ScValue->SetInt(Game->m_MousePos.x + m_OffsetLeft - ViewportX); - return m_ScValue; + _scValue->SetInt(Game->_mousePos.x + _offsetLeft - ViewportX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -1740,48 +1740,48 @@ CScValue *CAdScene::ScGetProperty(char *Name) { int ViewportY; GetViewportOffset(NULL, &ViewportY); - m_ScValue->SetInt(Game->m_MousePos.y + m_OffsetTop - ViewportY); - return m_ScValue; + _scValue->SetInt(Game->_mousePos.y + _offsetTop - ViewportY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AutoScroll ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoScroll") == 0) { - m_ScValue->SetBool(m_AutoScroll); - return m_ScValue; + _scValue->SetBool(_autoScroll); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PersistentState ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PersistentState") == 0) { - m_ScValue->SetBool(m_PersistentState); - return m_ScValue; + _scValue->SetBool(_persistentState); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PersistentStateSprites") == 0) { - m_ScValue->SetBool(m_PersistentStateSprites); - return m_ScValue; + _scValue->SetBool(_persistentStateSprites); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollPixelsX") == 0) { - m_ScValue->SetInt(m_ScrollPixelsH); - return m_ScValue; + _scValue->SetInt(_scrollPixelsH); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollPixelsY") == 0) { - m_ScValue->SetInt(m_ScrollPixelsV); - return m_ScValue; + _scValue->SetInt(_scrollPixelsV); + return _scValue; } @@ -1789,50 +1789,50 @@ CScValue *CAdScene::ScGetProperty(char *Name) { // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollSpeedX") == 0) { - m_ScValue->SetInt(m_ScrollTimeH); - return m_ScValue; + _scValue->SetInt(_scrollTimeH); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollSpeedY") == 0) { - m_ScValue->SetInt(m_ScrollTimeV); - return m_ScValue; + _scValue->SetInt(_scrollTimeV); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // OffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "OffsetX") == 0) { - m_ScValue->SetInt(m_OffsetLeft); - return m_ScValue; + _scValue->SetInt(_offsetLeft); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // OffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "OffsetY") == 0) { - m_ScValue->SetInt(m_OffsetTop); - return m_ScValue; + _scValue->SetInt(_offsetTop); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - if (m_MainLayer) m_ScValue->SetInt(m_MainLayer->m_Width); - else m_ScValue->SetInt(0); - return m_ScValue; + if (_mainLayer) _scValue->SetInt(_mainLayer->_width); + else _scValue->SetInt(0); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - if (m_MainLayer) m_ScValue->SetInt(m_MainLayer->m_Height); - else m_ScValue->SetInt(0); - return m_ScValue; + if (_mainLayer) _scValue->SetInt(_mainLayer->_height); + else _scValue->SetInt(0); + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -1853,7 +1853,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // AutoScroll ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoScroll") == 0) { - m_AutoScroll = Value->GetBool(); + _autoScroll = Value->GetBool(); return S_OK; } @@ -1861,7 +1861,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // PersistentState ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PersistentState") == 0) { - m_PersistentState = Value->GetBool(); + _persistentState = Value->GetBool(); return S_OK; } @@ -1869,7 +1869,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PersistentStateSprites") == 0) { - m_PersistentStateSprites = Value->GetBool(); + _persistentStateSprites = Value->GetBool(); return S_OK; } @@ -1877,7 +1877,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollPixelsX") == 0) { - m_ScrollPixelsH = Value->GetInt(); + _scrollPixelsH = Value->GetInt(); return S_OK; } @@ -1885,7 +1885,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollPixelsY") == 0) { - m_ScrollPixelsV = Value->GetInt(); + _scrollPixelsV = Value->GetInt(); return S_OK; } @@ -1893,7 +1893,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollSpeedX") == 0) { - m_ScrollTimeH = Value->GetInt(); + _scrollTimeH = Value->GetInt(); return S_OK; } @@ -1901,7 +1901,7 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScrollSpeedY") == 0) { - m_ScrollTimeV = Value->GetInt(); + _scrollTimeV = Value->GetInt(); return S_OK; } @@ -1909,14 +1909,14 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // OffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "OffsetX") == 0) { - m_OffsetLeft = Value->GetInt(); + _offsetLeft = Value->GetInt(); int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - m_OffsetLeft = std::max(0, m_OffsetLeft - ViewportWidth / 2); - m_OffsetLeft = std::min(m_OffsetLeft, m_Width - ViewportWidth); - m_TargetOffsetLeft = m_OffsetLeft; + _offsetLeft = std::max(0, _offsetLeft - ViewportWidth / 2); + _offsetLeft = std::min(_offsetLeft, _width - ViewportWidth); + _targetOffsetLeft = _offsetLeft; return S_OK; } @@ -1925,14 +1925,14 @@ HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { // OffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "OffsetY") == 0) { - m_OffsetTop = Value->GetInt(); + _offsetTop = Value->GetInt(); int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - m_OffsetTop = std::max(0, m_OffsetTop - ViewportHeight / 2); - m_OffsetTop = std::min(m_OffsetTop, m_Height - ViewportHeight); - m_TargetOffsetTop = m_OffsetTop; + _offsetTop = std::max(0, _offsetTop - ViewportHeight / 2); + _offsetTop = std::min(_offsetTop, _height - ViewportHeight); + _targetOffsetTop = _offsetTop; return S_OK; } @@ -1949,16 +1949,16 @@ char *CAdScene::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::AddObject(CAdObject *Object) { - m_Objects.Add(Object); + _objects.Add(Object); return Game->RegisterObject(Object); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::RemoveObject(CAdObject *Object) { - for (int i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i] == Object) { - m_Objects.RemoveAt(i); + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] == Object) { + _objects.RemoveAt(i); return Game->UnregisterObject(Object); } } @@ -1972,29 +1972,29 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SCENE {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - if (m_PersistentState) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", m_PersistentState ? "TRUE" : "FALSE"); + if (_persistentState) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); - if (!m_PersistentStateSprites) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", m_PersistentStateSprites ? "TRUE" : "FALSE"); + if (!_persistentStateSprites) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); // scripts - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); // properties - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); // viewport - if (m_Viewport) { - RECT *rc = m_Viewport->GetRect(); + if (_viewport) { + RECT *rc = _viewport->GetRect(); Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } @@ -2002,26 +2002,26 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { // editor settings Buffer->PutTextIndent(Indent + 2, "; ----- editor settings\n"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", m_EditorMarginH); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", m_EditorMarginV); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColFrame), D3DCOLGetG(m_EditorColFrame), D3DCOLGetB(m_EditorColFrame), D3DCOLGetA(m_EditorColFrame)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColEntitySel), D3DCOLGetG(m_EditorColEntitySel), D3DCOLGetB(m_EditorColEntitySel), D3DCOLGetA(m_EditorColEntitySel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColRegionSel), D3DCOLGetG(m_EditorColRegionSel), D3DCOLGetB(m_EditorColRegionSel), D3DCOLGetA(m_EditorColRegionSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColBlockedSel), D3DCOLGetG(m_EditorColBlockedSel), D3DCOLGetB(m_EditorColBlockedSel), D3DCOLGetA(m_EditorColBlockedSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColDecorSel), D3DCOLGetG(m_EditorColDecorSel), D3DCOLGetB(m_EditorColDecorSel), D3DCOLGetA(m_EditorColDecorSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColWaypointsSel), D3DCOLGetG(m_EditorColWaypointsSel), D3DCOLGetB(m_EditorColWaypointsSel), D3DCOLGetA(m_EditorColWaypointsSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColEntity), D3DCOLGetG(m_EditorColEntity), D3DCOLGetB(m_EditorColEntity), D3DCOLGetA(m_EditorColEntity)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColRegion), D3DCOLGetG(m_EditorColRegion), D3DCOLGetB(m_EditorColRegion), D3DCOLGetA(m_EditorColRegion)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColDecor), D3DCOLGetG(m_EditorColDecor), D3DCOLGetB(m_EditorColDecor), D3DCOLGetA(m_EditorColDecor)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColBlocked), D3DCOLGetG(m_EditorColBlocked), D3DCOLGetB(m_EditorColBlocked), D3DCOLGetA(m_EditorColBlocked)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColWaypoints), D3DCOLGetG(m_EditorColWaypoints), D3DCOLGetB(m_EditorColWaypoints), D3DCOLGetA(m_EditorColWaypoints)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(m_EditorColScale), D3DCOLGetG(m_EditorColScale), D3DCOLGetB(m_EditorColScale), D3DCOLGetA(m_EditorColScale)); - - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", m_EditorShowRegions ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", m_EditorShowBlocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", m_EditorShowDecor ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", m_EditorShowEntities ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", m_EditorShowScale ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); + + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -2029,30 +2029,30 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { // waypoints Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); - for (i = 0; i < m_WaypointGroups.GetSize(); i++) m_WaypointGroups[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); // layers Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); - for (i = 0; i < m_Layers.GetSize(); i++) m_Layers[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _layers.GetSize(); i++) _layers[i]->SaveAsText(Buffer, Indent + 2); // scale levels Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); - for (i = 0; i < m_ScaleLevels.GetSize(); i++) m_ScaleLevels[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->SaveAsText(Buffer, Indent + 2); // rotation levels Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < m_RotLevels.GetSize(); i++) m_RotLevels[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); // free entities Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Type == OBJECT_ENTITY) { - m_Objects[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + _objects[i]->SaveAsText(Buffer, Indent + 2); } } @@ -2069,11 +2069,11 @@ HRESULT CAdScene::SortScaleLevels() { bool changed; do { changed = false; - for (int i = 0; i < m_ScaleLevels.GetSize() - 1; i++) { - if (m_ScaleLevels[i]->m_PosY > m_ScaleLevels[i + 1]->m_PosY) { - CAdScaleLevel *sl = m_ScaleLevels[i]; - m_ScaleLevels[i] = m_ScaleLevels[i + 1]; - m_ScaleLevels[i + 1] = sl; + for (int i = 0; i < _scaleLevels.GetSize() - 1; i++) { + if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { + CAdScaleLevel *sl = _scaleLevels[i]; + _scaleLevels[i] = _scaleLevels[i + 1]; + _scaleLevels[i + 1] = sl; changed = true; } @@ -2090,11 +2090,11 @@ HRESULT CAdScene::SortRotLevels() { bool changed; do { changed = false; - for (int i = 0; i < m_RotLevels.GetSize() - 1; i++) { - if (m_RotLevels[i]->m_PosX > m_RotLevels[i + 1]->m_PosX) { - CAdRotLevel *rl = m_RotLevels[i]; - m_RotLevels[i] = m_RotLevels[i + 1]; - m_RotLevels[i + 1] = rl; + for (int i = 0; i < _rotLevels.GetSize() - 1; i++) { + if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { + CAdRotLevel *rl = _rotLevels[i]; + _rotLevels[i] = _rotLevels[i + 1]; + _rotLevels[i + 1] = rl; changed = true; } @@ -2111,24 +2111,24 @@ float CAdScene::GetScaleAt(int Y) { CAdScaleLevel *prev = NULL; CAdScaleLevel *next = NULL; - for (int i = 0; i < m_ScaleLevels.GetSize(); i++) { - CAdScaleLevel *xxx = m_ScaleLevels[i]; - int j = m_ScaleLevels.GetSize(); - if (m_ScaleLevels[i]->m_PosY < Y) prev = m_ScaleLevels[i]; + for (int i = 0; i < _scaleLevels.GetSize(); i++) { + CAdScaleLevel *xxx = _scaleLevels[i]; + int j = _scaleLevels.GetSize(); + if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; else { - next = m_ScaleLevels[i]; + next = _scaleLevels[i]; break; } } if (prev == NULL || next == NULL) return 100; - int delta_y = next->m_PosY - prev->m_PosY; - float delta_scale = next->m_Scale - prev->m_Scale; - Y -= prev->m_PosY; + int delta_y = next->_posY - prev->_posY; + float delta_scale = next->_scale - prev->_scale; + Y -= prev->_posY; float percent = (float)Y / ((float)delta_y / 100.0f); - return prev->m_Scale + delta_scale / 100 * percent; + return prev->_scale + delta_scale / 100 * percent; } @@ -2136,58 +2136,58 @@ float CAdScene::GetScaleAt(int Y) { HRESULT CAdScene::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_AutoScroll)); - PersistMgr->Transfer(TMEMBER(m_EditorColBlocked)); - PersistMgr->Transfer(TMEMBER(m_EditorColBlockedSel)); - PersistMgr->Transfer(TMEMBER(m_EditorColDecor)); - PersistMgr->Transfer(TMEMBER(m_EditorColDecorSel)); - PersistMgr->Transfer(TMEMBER(m_EditorColEntity)); - PersistMgr->Transfer(TMEMBER(m_EditorColEntitySel)); - PersistMgr->Transfer(TMEMBER(m_EditorColFrame)); - PersistMgr->Transfer(TMEMBER(m_EditorColRegion)); - PersistMgr->Transfer(TMEMBER(m_EditorColRegionSel)); - PersistMgr->Transfer(TMEMBER(m_EditorColScale)); - PersistMgr->Transfer(TMEMBER(m_EditorColWaypoints)); - PersistMgr->Transfer(TMEMBER(m_EditorColWaypointsSel)); - PersistMgr->Transfer(TMEMBER(m_EditorMarginH)); - PersistMgr->Transfer(TMEMBER(m_EditorMarginV)); - PersistMgr->Transfer(TMEMBER(m_EditorShowBlocked)); - PersistMgr->Transfer(TMEMBER(m_EditorShowDecor)); - PersistMgr->Transfer(TMEMBER(m_EditorShowEntities)); - PersistMgr->Transfer(TMEMBER(m_EditorShowRegions)); - PersistMgr->Transfer(TMEMBER(m_EditorShowScale)); - PersistMgr->Transfer(TMEMBER(m_Fader)); - PersistMgr->Transfer(TMEMBER(m_Height)); - PersistMgr->Transfer(TMEMBER(m_Initialized)); - PersistMgr->Transfer(TMEMBER(m_LastTimeH)); - PersistMgr->Transfer(TMEMBER(m_LastTimeV)); - m_Layers.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_MainLayer)); - m_Objects.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_OffsetLeft)); - PersistMgr->Transfer(TMEMBER(m_OffsetTop)); - PersistMgr->Transfer(TMEMBER(m_ParalaxScrolling)); - PersistMgr->Transfer(TMEMBER(m_PersistentState)); - PersistMgr->Transfer(TMEMBER(m_PersistentStateSprites)); - PersistMgr->Transfer(TMEMBER(m_PFMaxTime)); - m_PFPath.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_PFPointsNum)); - PersistMgr->Transfer(TMEMBER(m_PFReady)); - PersistMgr->Transfer(TMEMBER(m_PFRequester)); - PersistMgr->Transfer(TMEMBER(m_PFTarget)); - PersistMgr->Transfer(TMEMBER(m_PFTargetPath)); - m_RotLevels.Persist(PersistMgr); - m_ScaleLevels.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ScrollPixelsH)); - PersistMgr->Transfer(TMEMBER(m_ScrollPixelsV)); - PersistMgr->Transfer(TMEMBER(m_ScrollTimeH)); - PersistMgr->Transfer(TMEMBER(m_ScrollTimeV)); - PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); - PersistMgr->Transfer(TMEMBER(m_TargetOffsetLeft)); - PersistMgr->Transfer(TMEMBER(m_TargetOffsetTop)); - m_WaypointGroups.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Viewport)); - PersistMgr->Transfer(TMEMBER(m_Width)); + PersistMgr->Transfer(TMEMBER(_autoScroll)); + PersistMgr->Transfer(TMEMBER(_editorColBlocked)); + PersistMgr->Transfer(TMEMBER(_editorColBlockedSel)); + PersistMgr->Transfer(TMEMBER(_editorColDecor)); + PersistMgr->Transfer(TMEMBER(_editorColDecorSel)); + PersistMgr->Transfer(TMEMBER(_editorColEntity)); + PersistMgr->Transfer(TMEMBER(_editorColEntitySel)); + PersistMgr->Transfer(TMEMBER(_editorColFrame)); + PersistMgr->Transfer(TMEMBER(_editorColRegion)); + PersistMgr->Transfer(TMEMBER(_editorColRegionSel)); + PersistMgr->Transfer(TMEMBER(_editorColScale)); + PersistMgr->Transfer(TMEMBER(_editorColWaypoints)); + PersistMgr->Transfer(TMEMBER(_editorColWaypointsSel)); + PersistMgr->Transfer(TMEMBER(_editorMarginH)); + PersistMgr->Transfer(TMEMBER(_editorMarginV)); + PersistMgr->Transfer(TMEMBER(_editorShowBlocked)); + PersistMgr->Transfer(TMEMBER(_editorShowDecor)); + PersistMgr->Transfer(TMEMBER(_editorShowEntities)); + PersistMgr->Transfer(TMEMBER(_editorShowRegions)); + PersistMgr->Transfer(TMEMBER(_editorShowScale)); + PersistMgr->Transfer(TMEMBER(_fader)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_initialized)); + PersistMgr->Transfer(TMEMBER(_lastTimeH)); + PersistMgr->Transfer(TMEMBER(_lastTimeV)); + _layers.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_mainLayer)); + _objects.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_offsetLeft)); + PersistMgr->Transfer(TMEMBER(_offsetTop)); + PersistMgr->Transfer(TMEMBER(_paralaxScrolling)); + PersistMgr->Transfer(TMEMBER(_persistentState)); + PersistMgr->Transfer(TMEMBER(_persistentStateSprites)); + PersistMgr->Transfer(TMEMBER(_pFMaxTime)); + _pFPath.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_pFPointsNum)); + PersistMgr->Transfer(TMEMBER(_pFReady)); + PersistMgr->Transfer(TMEMBER(_pFRequester)); + PersistMgr->Transfer(TMEMBER(_pFTarget)); + PersistMgr->Transfer(TMEMBER(_pFTargetPath)); + _rotLevels.Persist(PersistMgr); + _scaleLevels.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollPixelsH)); + PersistMgr->Transfer(TMEMBER(_scrollPixelsV)); + PersistMgr->Transfer(TMEMBER(_scrollTimeH)); + PersistMgr->Transfer(TMEMBER(_scrollTimeV)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER(_targetOffsetLeft)); + PersistMgr->Transfer(TMEMBER(_targetOffsetTop)); + _waypointGroups.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_viewport)); + PersistMgr->Transfer(TMEMBER(_width)); return S_OK; } @@ -2261,14 +2261,14 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo int x = *X; int y = *Y; - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !m_MainLayer) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { return S_OK; } // right int length_right = 0; bool found_right = false; - for (x = *X, y = *Y; x < m_MainLayer->m_Width; x++, length_right++) { + for (x = *X, y = *Y; x < _mainLayer->_width; x++, length_right++) { if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { found_right = true; break; @@ -2298,7 +2298,7 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo // down int length_down = 0; bool found_down = false; - for (x = *X, y = *Y; y < m_MainLayer->m_Height; y++, length_down++) { + for (x = *X, y = *Y; y < _mainLayer->_height; y++, length_down++) { if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { found_down = true; break; @@ -2335,35 +2335,35 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo ////////////////////////////////////////////////////////////////////////// void CAdScene::PFPointsStart() { - m_PFPointsNum = 0; + _pFPointsNum = 0; } ////////////////////////////////////////////////////////////////////////// void CAdScene::PFPointsAdd(int X, int Y, int Distance) { - if (m_PFPointsNum >= m_PFPath.GetSize()) { - m_PFPath.Add(new CAdPathPoint(X, Y, Distance)); + if (_pFPointsNum >= _pFPath.GetSize()) { + _pFPath.Add(new CAdPathPoint(X, Y, Distance)); } else { - m_PFPath[m_PFPointsNum]->x = X; - m_PFPath[m_PFPointsNum]->y = Y; - m_PFPath[m_PFPointsNum]->m_Distance = Distance; - m_PFPath[m_PFPointsNum]->m_Marked = false; - m_PFPath[m_PFPointsNum]->m_Origin = NULL; + _pFPath[_pFPointsNum]->x = X; + _pFPath[_pFPointsNum]->y = Y; + _pFPath[_pFPointsNum]->_distance = Distance; + _pFPath[_pFPointsNum]->_marked = false; + _pFPath[_pFPointsNum]->_origin = NULL; } - m_PFPointsNum++; + _pFPointsNum++; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { CAdGame *AdGame = (CAdGame *)Game; - if (m_Viewport && !Game->m_EditorMode) { - if (OffsetX) *OffsetX = m_Viewport->m_OffsetX; - if (OffsetY) *OffsetY = m_Viewport->m_OffsetY; - } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { - if (OffsetX) *OffsetX = AdGame->m_SceneViewport->m_OffsetX; - if (OffsetY) *OffsetY = AdGame->m_SceneViewport->m_OffsetY; + if (_viewport && !Game->_editorMode) { + if (OffsetX) *OffsetX = _viewport->_offsetX; + if (OffsetY) *OffsetY = _viewport->_offsetY; + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + if (OffsetX) *OffsetX = AdGame->_sceneViewport->_offsetX; + if (OffsetY) *OffsetY = AdGame->_sceneViewport->_offsetY; } else { if (OffsetX) *OffsetX = 0; if (OffsetY) *OffsetY = 0; @@ -2375,15 +2375,15 @@ HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { CAdGame *AdGame = (CAdGame *)Game; - if (m_Viewport && !Game->m_EditorMode) { - if (Width) *Width = m_Viewport->GetWidth(); - if (Height) *Height = m_Viewport->GetHeight(); - } else if (AdGame->m_SceneViewport && !Game->m_EditorMode) { - if (Width) *Width = AdGame->m_SceneViewport->GetWidth(); - if (Height) *Height = AdGame->m_SceneViewport->GetHeight(); + if (_viewport && !Game->_editorMode) { + if (Width) *Width = _viewport->GetWidth(); + if (Height) *Height = _viewport->GetHeight(); + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + if (Width) *Width = AdGame->_sceneViewport->GetWidth(); + if (Height) *Height = AdGame->_sceneViewport->GetHeight(); } else { - if (Width) *Width = Game->m_Renderer->m_Width; - if (Height) *Height = Game->m_Renderer->m_Height; + if (Width) *Width = Game->_renderer->_width; + if (Height) *Height = Game->_renderer->_height; } return S_OK; } @@ -2394,7 +2394,7 @@ int CAdScene::GetOffsetLeft() { int ViewportX; GetViewportOffset(&ViewportX); - return m_OffsetLeft - ViewportX; + return _offsetLeft - ViewportX; } @@ -2403,7 +2403,7 @@ int CAdScene::GetOffsetTop() { int ViewportY; GetViewportOffset(NULL, &ViewportY); - return m_OffsetTop - ViewportY; + return _offsetTop - ViewportY; } @@ -2420,8 +2420,8 @@ bool CAdScene::PointInViewport(int X, int Y) { ////////////////////////////////////////////////////////////////////////// void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { - m_OffsetLeft = OffsetLeft; - m_OffsetTop = OffsetTop; + _offsetLeft = OffsetLeft; + _offsetTop = OffsetTop; } @@ -2431,18 +2431,18 @@ CBObject *CAdScene::GetNodeByName(char *Name) { CBObject *ret = NULL; // dependent objects - for (i = 0; i < m_Layers.GetSize(); i++) { - CAdLayer *layer = m_Layers[i]; - for (int j = 0; j < layer->m_Nodes.GetSize(); j++) { - CAdSceneNode *node = layer->m_Nodes[j]; - if ((node->m_Type == OBJECT_ENTITY && !scumm_stricmp(Name, node->m_Entity->m_Name)) || - (node->m_Type == OBJECT_REGION && !scumm_stricmp(Name, node->m_Region->m_Name))) { - switch (node->m_Type) { + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.GetSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(Name, node->_entity->_name)) || + (node->_type == OBJECT_REGION && !scumm_stricmp(Name, node->_region->_name))) { + switch (node->_type) { case OBJECT_ENTITY: - ret = node->m_Entity; + ret = node->_entity; break; case OBJECT_REGION: - ret = node->m_Region; + ret = node->_region; break; default: ret = NULL; @@ -2453,16 +2453,16 @@ CBObject *CAdScene::GetNodeByName(char *Name) { } // free entities - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Type == OBJECT_ENTITY && !scumm_stricmp(Name, m_Objects[i]->m_Name)) { - return m_Objects[i]; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(Name, _objects[i]->_name)) { + return _objects[i]; } } // waypoint groups - for (i = 0; i < m_WaypointGroups.GetSize(); i++) { - if (!scumm_stricmp(Name, m_WaypointGroups[i]->m_Name)) { - return m_WaypointGroups[i]; + for (i = 0; i < _waypointGroups.GetSize(); i++) { + if (!scumm_stricmp(Name, _waypointGroups[i]->_name)) { + return _waypointGroups[i]; } } @@ -2484,10 +2484,10 @@ HRESULT CAdScene::LoadState() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::PersistState(bool Saving) { - if (!m_PersistentState) return S_OK; + if (!_persistentState) return S_OK; CAdGame *AdGame = (CAdGame *)Game; - CAdSceneState *State = AdGame->GetSceneState(m_Filename, Saving); + CAdSceneState *State = AdGame->GetSceneState(_filename, Saving); if (!State) return S_OK; @@ -2495,26 +2495,26 @@ HRESULT CAdScene::PersistState(bool Saving) { CAdNodeState *NodeState; // dependent objects - for (i = 0; i < m_Layers.GetSize(); i++) { - CAdLayer *layer = m_Layers[i]; - for (int j = 0; j < layer->m_Nodes.GetSize(); j++) { - CAdSceneNode *node = layer->m_Nodes[j]; - switch (node->m_Type) { + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.GetSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + switch (node->_type) { case OBJECT_ENTITY: - if (!node->m_Entity->m_SaveState) continue; - NodeState = State->GetNodeState(node->m_Entity->m_Name, Saving); + if (!node->_entity->_saveState) continue; + NodeState = State->GetNodeState(node->_entity->_name, Saving); if (NodeState) { - NodeState->TransferEntity(node->m_Entity, m_PersistentStateSprites, Saving); - //if(Saving) NodeState->m_Active = node->m_Entity->m_Active; - //else node->m_Entity->m_Active = NodeState->m_Active; + NodeState->TransferEntity(node->_entity, _persistentStateSprites, Saving); + //if(Saving) NodeState->_active = node->_entity->_active; + //else node->_entity->_active = NodeState->_active; } break; case OBJECT_REGION: - if (!node->m_Region->m_SaveState) continue; - NodeState = State->GetNodeState(node->m_Region->m_Name, Saving); + if (!node->_region->_saveState) continue; + NodeState = State->GetNodeState(node->_region->_name, Saving); if (NodeState) { - if (Saving) NodeState->m_Active = node->m_Region->m_Active; - else node->m_Region->m_Active = NodeState->m_Active; + if (Saving) NodeState->_active = node->_region->_active; + else node->_region->_active = NodeState->_active; } break; } @@ -2522,24 +2522,24 @@ HRESULT CAdScene::PersistState(bool Saving) { } // free entities - for (i = 0; i < m_Objects.GetSize(); i++) { - if (!m_Objects[i]->m_SaveState) continue; - if (m_Objects[i]->m_Type == OBJECT_ENTITY) { - NodeState = State->GetNodeState(m_Objects[i]->m_Name, Saving); + for (i = 0; i < _objects.GetSize(); i++) { + if (!_objects[i]->_saveState) continue; + if (_objects[i]->_type == OBJECT_ENTITY) { + NodeState = State->GetNodeState(_objects[i]->_name, Saving); if (NodeState) { - NodeState->TransferEntity((CAdEntity *)m_Objects[i], m_PersistentStateSprites, Saving); - //if(Saving) NodeState->m_Active = m_Objects[i]->m_Active; - //else m_Objects[i]->m_Active = NodeState->m_Active; + NodeState->TransferEntity((CAdEntity *)_objects[i], _persistentStateSprites, Saving); + //if(Saving) NodeState->_active = _objects[i]->_active; + //else _objects[i]->_active = NodeState->_active; } } } // waypoint groups - for (i = 0; i < m_WaypointGroups.GetSize(); i++) { - NodeState = State->GetNodeState(m_WaypointGroups[i]->m_Name, Saving); + for (i = 0; i < _waypointGroups.GetSize(); i++) { + NodeState = State->GetNodeState(_waypointGroups[i]->_name, Saving); if (NodeState) { - if (Saving) NodeState->m_Active = m_WaypointGroups[i]->m_Active; - else m_WaypointGroups[i]->m_Active = NodeState->m_Active; + if (Saving) NodeState->_active = _waypointGroups[i]->_active; + else _waypointGroups[i]->_active = NodeState->_active; } } @@ -2552,24 +2552,24 @@ float CAdScene::GetRotationAt(int X, int Y) { CAdRotLevel *prev = NULL; CAdRotLevel *next = NULL; - for (int i = 0; i < m_RotLevels.GetSize(); i++) { - CAdRotLevel *xxx = m_RotLevels[i]; - int j = m_RotLevels.GetSize(); - if (m_RotLevels[i]->m_PosX < X) prev = m_RotLevels[i]; + for (int i = 0; i < _rotLevels.GetSize(); i++) { + CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.GetSize(); + if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; else { - next = m_RotLevels[i]; + next = _rotLevels[i]; break; } } if (prev == NULL || next == NULL) return 0; - int delta_x = next->m_PosX - prev->m_PosX; - float delta_rot = next->m_Rotation - prev->m_Rotation; - X -= prev->m_PosX; + int delta_x = next->_posX - prev->_posX; + float delta_rot = next->_rotation - prev->_rotation; + X -= prev->_posX; float percent = (float)X / ((float)delta_x / 100.0f); - return prev->m_Rotation + delta_rot / 100 * percent; + return prev->_rotation + delta_rot / 100 * percent; } @@ -2577,21 +2577,21 @@ float CAdScene::GetRotationAt(int X, int Y) { HRESULT CAdScene::HandleItemAssociations(char *ItemName, bool Show) { int i; - for (i = 0; i < m_Layers.GetSize(); i++) { - CAdLayer *Layer = m_Layers[i]; - for (int j = 0; j < Layer->m_Nodes.GetSize(); j++) { - if (Layer->m_Nodes[j]->m_Type == OBJECT_ENTITY) { - CAdEntity *Ent = Layer->m_Nodes[j]->m_Entity; + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *Layer = _layers[i]; + for (int j = 0; j < Layer->_nodes.GetSize(); j++) { + if (Layer->_nodes[j]->_type == OBJECT_ENTITY) { + CAdEntity *Ent = Layer->_nodes[j]->_entity; - if (Ent->m_Item && strcmp(Ent->m_Item, ItemName) == 0) Ent->m_Active = Show; + if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; } } } - for (i = 0; i < m_Objects.GetSize(); i++) { - if (m_Objects[i]->m_Type == OBJECT_ENTITY) { - CAdEntity *Ent = (CAdEntity *)m_Objects[i]; - if (Ent->m_Item && strcmp(Ent->m_Item, ItemName) == 0) Ent->m_Active = Show; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + CAdEntity *Ent = (CAdEntity *)_objects[i]; + if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; } } @@ -2603,12 +2603,12 @@ HRESULT CAdScene::HandleItemAssociations(char *ItemName, bool Show) { HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { int i; int NumUsed = 0; - if (m_MainLayer) { - for (i = m_MainLayer->m_Nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = m_MainLayer->m_Nodes[i]; - if (Node->m_Type == OBJECT_REGION && Node->m_Region->m_Active && Node->m_Region->PointInRegion(X, Y)) { + if (_mainLayer) { + for (i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { if (NumUsed < NumRegions - 1) { - RegionList[NumUsed] = Node->m_Region; + RegionList[NumUsed] = Node->_region; NumUsed++; } else break; } @@ -2670,24 +2670,24 @@ CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::GetSceneObjects(CBArray& Objects, bool InteractiveOnly) { - for (int i = 0; i < m_Layers.GetSize(); i++) { + for (int i = 0; i < _layers.GetSize(); i++) { // close-up layer -> remove everything below it - if (InteractiveOnly && m_Layers[i]->m_CloseUp) Objects.RemoveAll(); + if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); - for (int j = 0; j < m_Layers[i]->m_Nodes.GetSize(); j++) { - CAdSceneNode *Node = m_Layers[i]->m_Nodes[j]; - switch (Node->m_Type) { + for (int j = 0; j < _layers[i]->_nodes.GetSize(); j++) { + CAdSceneNode *Node = _layers[i]->_nodes[j]; + switch (Node->_type) { case OBJECT_ENTITY: { - CAdEntity *Ent = Node->m_Entity; - if (Ent->m_Active && (Ent->m_Registrable || !InteractiveOnly)) + CAdEntity *Ent = Node->_entity; + if (Ent->_active && (Ent->_registrable || !InteractiveOnly)) Objects.Add(Ent); } break; case OBJECT_REGION: { CBArray RegionObj; - GetRegionObjects(Node->m_Region, RegionObj, InteractiveOnly); + GetRegionObjects(Node->_region, RegionObj, InteractiveOnly); for (int New = 0; New < RegionObj.GetSize(); New++) { bool Found = false; for (int Old = 0; Old < Objects.GetSize(); Old++) { @@ -2732,26 +2732,26 @@ HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArraym_Objects.GetSize(); i++) { - Obj = AdGame->m_Objects[i]; - if (Obj->m_Active && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { - if (InteractiveOnly && !Obj->m_Registrable) continue; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + Obj = AdGame->_objects[i]; + if (Obj->_active && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + if (InteractiveOnly && !Obj->_registrable) continue; Objects.Add(Obj); } } // scene objects - for (i = 0; i < m_Objects.GetSize(); i++) { - Obj = m_Objects[i]; - if (Obj->m_Active && !Obj->m_EditorOnly && (Obj->m_StickRegion == Region || Region == NULL || (Obj->m_StickRegion == NULL && Region->PointInRegion(Obj->m_PosX, Obj->m_PosY)))) { - if (InteractiveOnly && !Obj->m_Registrable) continue; + for (i = 0; i < _objects.GetSize(); i++) { + Obj = _objects[i]; + if (Obj->_active && !Obj->_editorOnly && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + if (InteractiveOnly && !Obj->_registrable) continue; Objects.Add(Obj); } } - // sort by m_PosY + // sort by _posY qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); return S_OK; diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index c3124cf814..874e05ac61 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -56,12 +56,12 @@ public: HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); HRESULT HandleItemAssociations(char *ItemName, bool Show); - CUIWindow *m_ShieldWindow; + CUIWindow *_shieldWindow; float GetRotationAt(int X, int Y); HRESULT LoadState(); HRESULT SaveState(); - bool m_PersistentState; - bool m_PersistentStateSprites; + bool _persistentState; + bool _persistentStateSprites; CBObject *GetNodeByName(char *Name); void SetOffset(int OffsetLeft, int OffsetTop); bool PointInViewport(int X, int Y); @@ -69,12 +69,12 @@ public: int GetOffsetLeft(); HRESULT GetViewportSize(int *Width = NULL, int *Height = NULL); HRESULT GetViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - CBViewport *m_Viewport; - CBFader *m_Fader; - int m_PFPointsNum; + CBViewport *_viewport; + CBFader *_fader; + int _pFPointsNum; void PFPointsAdd(int X, int Y, int Distance); void PFPointsStart(); - bool m_Initialized; + bool _initialized; HRESULT CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); HRESULT CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); DECLARE_PERSISTENT(CAdScene, CBObject) @@ -89,7 +89,7 @@ public: HRESULT SortRotLevels(); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); - bool m_ParalaxScrolling; + bool _paralaxScrolling; void SkipTo(int OffsetX, int OffsetY); void SetDefaults(); void Cleanup(); @@ -97,60 +97,60 @@ public: void ScrollToObject(CBObject *Object); void ScrollTo(int OffsetX, int OffsetY); virtual HRESULT Update(); - bool m_AutoScroll; - int m_TargetOffsetTop; - int m_TargetOffsetLeft; + bool _autoScroll; + int _targetOffsetTop; + int _targetOffsetLeft; - int m_ScrollPixelsV; - uint32 m_ScrollTimeV; - uint32 m_LastTimeV; + int _scrollPixelsV; + uint32 _scrollTimeV; + uint32 _lastTimeV; - int m_ScrollPixelsH; - uint32 m_ScrollTimeH; - uint32 m_LastTimeH; + int _scrollPixelsH; + uint32 _scrollTimeH; + uint32 _lastTimeH; virtual HRESULT Display(); - uint32 m_PFMaxTime; + uint32 _pFMaxTime; HRESULT InitLoop(); void PathFinderStep(); bool IsBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); bool IsWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - CAdLayer *m_MainLayer; + CAdLayer *_mainLayer; float GetZoomAt(int X, int Y); bool GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); CAdScene(CBGame *inGame); virtual ~CAdScene(); - CBArray m_Layers; - CBArray m_Objects; - CBArray m_WaypointGroups; + CBArray _layers; + CBArray _objects; + CBArray _waypointGroups; HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - int m_Width; - int m_Height; + int _width; + int _height; HRESULT AddObject(CAdObject *Object); HRESULT RemoveObject(CAdObject *Object); - int m_EditorMarginH; - int m_EditorMarginV; - uint32 m_EditorColFrame; - uint32 m_EditorColEntity; - uint32 m_EditorColRegion; - uint32 m_EditorColBlocked; - uint32 m_EditorColWaypoints; - uint32 m_EditorColEntitySel; - uint32 m_EditorColRegionSel; - uint32 m_EditorColBlockedSel; - uint32 m_EditorColWaypointsSel; - uint32 m_EditorColScale; - uint32 m_EditorColDecor; - uint32 m_EditorColDecorSel; - - bool m_EditorShowRegions; - bool m_EditorShowBlocked; - bool m_EditorShowDecor; - bool m_EditorShowEntities; - bool m_EditorShowScale; - CBArray m_ScaleLevels; - CBArray m_RotLevels; + int _editorMarginH; + int _editorMarginV; + uint32 _editorColFrame; + uint32 _editorColEntity; + uint32 _editorColRegion; + uint32 _editorColBlocked; + uint32 _editorColWaypoints; + uint32 _editorColEntitySel; + uint32 _editorColRegionSel; + uint32 _editorColBlockedSel; + uint32 _editorColWaypointsSel; + uint32 _editorColScale; + uint32 _editorColDecor; + uint32 _editorColDecorSel; + + bool _editorShowRegions; + bool _editorShowBlocked; + bool _editorShowDecor; + bool _editorShowEntities; + bool _editorShowScale; + CBArray _scaleLevels; + CBArray _rotLevels; virtual HRESULT RestoreDeviceObjects(); int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); @@ -165,14 +165,14 @@ public: private: HRESULT PersistState(bool Saving = true); void PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); - bool m_PFReady; - CBPoint *m_PFTarget; - CAdPath *m_PFTargetPath; - CBObject *m_PFRequester; - CBArray m_PFPath; - - int m_OffsetTop; - int m_OffsetLeft; + bool _pFReady; + CBPoint *_pFTarget; + CAdPath *_pFTargetPath; + CBObject *_pFRequester; + CBArray _pFPath; + + int _offsetTop; + int _offsetLeft; }; diff --git a/engines/wintermute/AdSceneNode.cpp b/engines/wintermute/AdSceneNode.cpp index 4f20a47324..4085eade56 100644 --- a/engines/wintermute/AdSceneNode.cpp +++ b/engines/wintermute/AdSceneNode.cpp @@ -36,34 +36,34 @@ IMPLEMENT_PERSISTENT(CAdSceneNode, false) ////////////////////////////////////////////////////////////////////////// CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { - m_Type = OBJECT_NONE; - m_Region = NULL; - m_Entity = NULL; + _type = OBJECT_NONE; + _region = NULL; + _entity = NULL; } ////////////////////////////////////////////////////////////////////////// CAdSceneNode::~CAdSceneNode() { - Game->UnregisterObject(m_Region); - m_Region = NULL; + Game->UnregisterObject(_region); + _region = NULL; - Game->UnregisterObject(m_Entity); - m_Entity = NULL; + Game->UnregisterObject(_entity); + _entity = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { - m_Type = OBJECT_ENTITY; - m_Entity = Entity; + _type = OBJECT_ENTITY; + _entity = Entity; return Game->RegisterObject(Entity); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { - m_Type = OBJECT_REGION; - m_Region = Region; + _type = OBJECT_REGION; + _region = Region; return Game->RegisterObject(Region); } @@ -73,9 +73,9 @@ HRESULT CAdSceneNode::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Entity)); - PersistMgr->Transfer(TMEMBER(m_Region)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(_entity)); + PersistMgr->Transfer(TMEMBER(_region)); + PersistMgr->Transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/AdSceneNode.h b/engines/wintermute/AdSceneNode.h index 94bd6f9aab..366e765cdd 100644 --- a/engines/wintermute/AdSceneNode.h +++ b/engines/wintermute/AdSceneNode.h @@ -41,9 +41,9 @@ public: DECLARE_PERSISTENT(CAdSceneNode, CBObject) HRESULT SetRegion(CAdRegion *Region); HRESULT SetEntity(CAdEntity *Entity); - CAdEntity *m_Entity; - CAdRegion *m_Region; - TObjectType m_Type; + CAdEntity *_entity; + CAdRegion *_region; + TObjectType _type; CAdSceneNode(CBGame *inGame); virtual ~CAdSceneNode(); diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp index 7ed571a711..2fd2648448 100644 --- a/engines/wintermute/AdSceneState.cpp +++ b/engines/wintermute/AdSceneState.cpp @@ -39,23 +39,23 @@ IMPLEMENT_PERSISTENT(CAdSceneState, false) ////////////////////////////////////////////////////////////////////////// CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { - m_Filename = NULL; + _filename = NULL; } ////////////////////////////////////////////////////////////////////////// CAdSceneState::~CAdSceneState() { - SAFE_DELETE_ARRAY(m_Filename); + SAFE_DELETE_ARRAY(_filename); - for (int i = 0; i < m_NodeStates.GetSize(); i++) delete m_NodeStates[i]; - m_NodeStates.RemoveAll(); + for (int i = 0; i < _nodeStates.GetSize(); i++) delete _nodeStates[i]; + _nodeStates.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_Filename)); - m_NodeStates.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_filename)); + _nodeStates.Persist(PersistMgr); return S_OK; } @@ -63,22 +63,22 @@ HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CAdSceneState::SetFilename(char *Filename) { - SAFE_DELETE_ARRAY(m_Filename); - m_Filename = new char [strlen(Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Filename); + SAFE_DELETE_ARRAY(_filename); + _filename = new char [strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); } ////////////////////////////////////////////////////////////////////////// CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { - for (int i = 0; i < m_NodeStates.GetSize(); i++) { - if (scumm_stricmp(m_NodeStates[i]->m_Name, Name) == 0) return m_NodeStates[i]; + for (int i = 0; i < _nodeStates.GetSize(); i++) { + if (scumm_stricmp(_nodeStates[i]->_name, Name) == 0) return _nodeStates[i]; } if (Saving) { CAdNodeState *ret = new CAdNodeState(Game); ret->SetName(Name); - m_NodeStates.Add(ret); + _nodeStates.Add(ret); return ret; } else return NULL; diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h index 6abb5c9a7f..a49f0ba5f7 100644 --- a/engines/wintermute/AdSceneState.h +++ b/engines/wintermute/AdSceneState.h @@ -42,8 +42,8 @@ public: DECLARE_PERSISTENT(CAdSceneState, CBBase) CAdSceneState(CBGame *inGame); virtual ~CAdSceneState(); - char *m_Filename; - CBArray m_NodeStates; + char *_filename; + CBArray _nodeStates; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp index f9574302ed..81bcfcf366 100644 --- a/engines/wintermute/AdSentence.cpp +++ b/engines/wintermute/AdSentence.cpp @@ -45,98 +45,98 @@ IMPLEMENT_PERSISTENT(CAdSentence, false) ////////////////////////////////////////////////////////////////////////// CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { - m_Text = NULL; - m_Stances = NULL; - m_TempStance = NULL; + _text = NULL; + _stances = NULL; + _tempStance = NULL; - m_Duration = 0; - m_StartTime = 0; - m_CurrentStance = 0; + _duration = 0; + _startTime = 0; + _currentStance = 0; - m_Font = NULL; + _font = NULL; - m_Pos.x = m_Pos.y = 0; - m_Width = Game->m_Renderer->m_Width; + _pos.x = _pos.y = 0; + _width = Game->_renderer->_width; - m_Align = (TTextAlign)TAL_CENTER; + _align = (TTextAlign)TAL_CENTER; - m_Sound = NULL; - m_SoundStarted = false; + _sound = NULL; + _soundStarted = false; - m_TalkDef = NULL; - m_CurrentSprite = NULL; - m_CurrentSkelAnim = NULL; - m_FixedPos = false; - m_Freezable = true; + _talkDef = NULL; + _currentSprite = NULL; + _currentSkelAnim = NULL; + _fixedPos = false; + _freezable = true; } ////////////////////////////////////////////////////////////////////////// CAdSentence::~CAdSentence() { - delete m_Sound; - delete[] m_Text; - delete[] m_Stances; - delete[] m_TempStance; - delete m_TalkDef; - m_Sound = NULL; - m_Text = NULL; - m_Stances = NULL; - m_TempStance = NULL; - m_TalkDef = NULL; - - m_CurrentSprite = NULL; // ref only - m_CurrentSkelAnim = NULL; - m_Font = NULL; // ref only + delete _sound; + delete[] _text; + delete[] _stances; + delete[] _tempStance; + delete _talkDef; + _sound = NULL; + _text = NULL; + _stances = NULL; + _tempStance = NULL; + _talkDef = NULL; + + _currentSprite = NULL; // ref only + _currentSkelAnim = NULL; + _font = NULL; // ref only } ////////////////////////////////////////////////////////////////////////// void CAdSentence::SetText(char *Text) { - if (m_Text) delete [] m_Text; - m_Text = new char[strlen(Text) + 1]; - if (m_Text) strcpy(m_Text, Text); + if (_text) delete [] _text; + _text = new char[strlen(Text) + 1]; + if (_text) strcpy(_text, Text); } ////////////////////////////////////////////////////////////////////////// void CAdSentence::SetStances(char *Stances) { - if (m_Stances) delete [] m_Stances; + if (_stances) delete [] _stances; if (Stances) { - m_Stances = new char[strlen(Stances) + 1]; - if (m_Stances) strcpy(m_Stances, Stances); - } else m_Stances = NULL; + _stances = new char[strlen(Stances) + 1]; + if (_stances) strcpy(_stances, Stances); + } else _stances = NULL; } ////////////////////////////////////////////////////////////////////////// char *CAdSentence::GetCurrentStance() { - return GetStance(m_CurrentStance); + return GetStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// char *CAdSentence::GetNextStance() { - m_CurrentStance++; - return GetStance(m_CurrentStance); + _currentStance++; + return GetStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// char *CAdSentence::GetStance(int Stance) { - if (m_Stances == NULL) return NULL; + if (_stances == NULL) return NULL; - if (m_TempStance) delete [] m_TempStance; - m_TempStance = NULL; + if (_tempStance) delete [] _tempStance; + _tempStance = NULL; char *start; char *curr; int pos; - if (Stance == 0) start = m_Stances; + if (Stance == 0) start = _stances; else { pos = 0; start = NULL; - curr = m_Stances; + curr = _stances; while (pos < Stance) { if (*curr == '\0') break; if (*curr == ',') pos++; @@ -154,40 +154,40 @@ char *CAdSentence::GetStance(int Stance) { while (curr > start && *(curr - 1) == ' ') curr--; - m_TempStance = new char [curr - start + 1]; - if (m_TempStance) { - m_TempStance[curr - start] = '\0'; - strncpy(m_TempStance, start, curr - start); + _tempStance = new char [curr - start + 1]; + if (_tempStance) { + _tempStance[curr - start] = '\0'; + strncpy(_tempStance, start, curr - start); } - return m_TempStance; + return _tempStance; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSentence::Display() { - if (!m_Font || !m_Text) return E_FAIL; + if (!_font || !_text) return E_FAIL; - if (m_Sound && !m_SoundStarted) { - m_Sound->Play(); - m_SoundStarted = true; + if (_sound && !_soundStarted) { + _sound->Play(); + _soundStarted = true; } - if (Game->m_Subtitles) { - int x = m_Pos.x; - int y = m_Pos.y; + if (Game->_subtitles) { + int x = _pos.x; + int y = _pos.y; - if (!m_FixedPos) { - x = x - ((CAdGame *)Game)->m_Scene->GetOffsetLeft(); - y = y - ((CAdGame *)Game)->m_Scene->GetOffsetTop(); + if (!_fixedPos) { + x = x - ((CAdGame *)Game)->_scene->GetOffsetLeft(); + y = y - ((CAdGame *)Game)->_scene->GetOffsetTop(); } x = std::max(x, 0); - x = std::min(x, Game->m_Renderer->m_Width - m_Width); + x = std::min(x, Game->_renderer->_width - _width); y = std::max(y, 0); - m_Font->DrawText((byte *)m_Text, x, y, m_Width, m_Align); + _font->DrawText((byte *)_text, x, y, _width, _align); } return S_OK; @@ -197,15 +197,15 @@ HRESULT CAdSentence::Display() { ////////////////////////////////////////////////////////////////////////// void CAdSentence::SetSound(CBSound *Sound) { if (!Sound) return; - delete m_Sound; - m_Sound = Sound; - m_SoundStarted = false; + delete _sound; + _sound = Sound; + _soundStarted = false; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSentence::Finish() { - if (m_Sound) m_Sound->Stop(); + if (_sound) _sound->Stop(); return S_OK; } @@ -215,23 +215,23 @@ HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER_INT(m_Align)); - PersistMgr->Transfer(TMEMBER(m_CurrentStance)); - PersistMgr->Transfer(TMEMBER(m_CurrentSprite)); - PersistMgr->Transfer(TMEMBER(m_CurrentSkelAnim)); - PersistMgr->Transfer(TMEMBER(m_Duration)); - PersistMgr->Transfer(TMEMBER(m_Font)); - PersistMgr->Transfer(TMEMBER(m_Pos)); - PersistMgr->Transfer(TMEMBER(m_Sound)); - PersistMgr->Transfer(TMEMBER(m_SoundStarted)); - PersistMgr->Transfer(TMEMBER(m_Stances)); - PersistMgr->Transfer(TMEMBER(m_StartTime)); - PersistMgr->Transfer(TMEMBER(m_TalkDef)); - PersistMgr->Transfer(TMEMBER(m_TempStance)); - PersistMgr->Transfer(TMEMBER(m_Text)); - PersistMgr->Transfer(TMEMBER(m_Width)); - PersistMgr->Transfer(TMEMBER(m_FixedPos)); - PersistMgr->Transfer(TMEMBER(m_Freezable)); + PersistMgr->Transfer(TMEMBER_INT(_align)); + PersistMgr->Transfer(TMEMBER(_currentStance)); + PersistMgr->Transfer(TMEMBER(_currentSprite)); + PersistMgr->Transfer(TMEMBER(_currentSkelAnim)); + PersistMgr->Transfer(TMEMBER(_duration)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_sound)); + PersistMgr->Transfer(TMEMBER(_soundStarted)); + PersistMgr->Transfer(TMEMBER(_stances)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_talkDef)); + PersistMgr->Transfer(TMEMBER(_tempStance)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER(_width)); + PersistMgr->Transfer(TMEMBER(_fixedPos)); + PersistMgr->Transfer(TMEMBER(_freezable)); return S_OK; } @@ -239,9 +239,9 @@ HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSentence::SetupTalkFile(char *SoundFilename) { - delete m_TalkDef; - m_TalkDef = NULL; - m_CurrentSprite = NULL; + delete _talkDef; + _talkDef = NULL; + _currentSprite = NULL; if (!SoundFilename) return S_OK; @@ -251,16 +251,16 @@ HRESULT CAdSentence::SetupTalkFile(char *SoundFilename) { AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); - CBFile *file = Game->m_FileManager->OpenFile(talkDefFileName.c_str()); + CBFile *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); if (file) { - Game->m_FileManager->CloseFile(file); + Game->_fileManager->CloseFile(file); } else return S_OK; // no talk def file found - m_TalkDef = new CAdTalkDef(Game); - if (!m_TalkDef || FAILED(m_TalkDef->LoadFile(talkDefFileName.c_str()))) { - delete m_TalkDef; - m_TalkDef = NULL; + _talkDef = new CAdTalkDef(Game); + if (!_talkDef || FAILED(_talkDef->LoadFile(talkDefFileName.c_str()))) { + delete _talkDef; + _talkDef = NULL; return E_FAIL; } //Game->LOG(0, "Using .talk file: %s", TalkDefFile); @@ -271,38 +271,38 @@ HRESULT CAdSentence::SetupTalkFile(char *SoundFilename) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSentence::Update(TDirection Dir) { - if (!m_TalkDef) return S_OK; + if (!_talkDef) return S_OK; uint32 CurrentTime; // if sound is available, synchronize with sound, otherwise use timer /* - if(m_Sound) CurrentTime = m_Sound->GetPositionTime(); - else CurrentTime = Game->m_Timer - m_StartTime; + if(_sound) CurrentTime = _sound->GetPositionTime(); + else CurrentTime = Game->_timer - _startTime; */ - CurrentTime = Game->m_Timer - m_StartTime; + CurrentTime = Game->_timer - _startTime; bool TalkNodeFound = false; - for (int i = 0; i < m_TalkDef->m_Nodes.GetSize(); i++) { - if (m_TalkDef->m_Nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { + for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { + if (_talkDef->_nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { TalkNodeFound = true; - CBSprite *NewSprite = m_TalkDef->m_Nodes[i]->GetSprite(Dir); - if (NewSprite != m_CurrentSprite) NewSprite->Reset(); - m_CurrentSprite = NewSprite; + CBSprite *NewSprite = _talkDef->_nodes[i]->GetSprite(Dir); + if (NewSprite != _currentSprite) NewSprite->Reset(); + _currentSprite = NewSprite; - if (!m_TalkDef->m_Nodes[i]->m_PlayToEnd) break; + if (!_talkDef->_nodes[i]->_playToEnd) break; } } // no talk node, try to use default sprite instead (if any) if (!TalkNodeFound) { - CBSprite *NewSprite = m_TalkDef->GetDefaultSprite(Dir); + CBSprite *NewSprite = _talkDef->GetDefaultSprite(Dir); if (NewSprite) { - if (NewSprite != m_CurrentSprite) NewSprite->Reset(); - m_CurrentSprite = NewSprite; - } else m_CurrentSprite = NULL; + if (NewSprite != _currentSprite) NewSprite->Reset(); + _currentSprite = NewSprite; + } else _currentSprite = NULL; } return S_OK; @@ -311,7 +311,7 @@ HRESULT CAdSentence::Update(TDirection Dir) { ////////////////////////////////////////////////////////////////////////// bool CAdSentence::CanSkip() { // prevent accidental sentence skipping (TODO make configurable) - return (Game->m_Timer - m_StartTime) > 300; + return (Game->_timer - _startTime) > 300; } } // end of namespace WinterMute diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h index 863f5569f1..ded17c83a7 100644 --- a/engines/wintermute/AdSentence.h +++ b/engines/wintermute/AdSentence.h @@ -41,39 +41,39 @@ class CBSprite; class CBSound; class CAdSentence : public CBBase { public: - bool m_Freezable; - bool m_FixedPos; - CBSprite *m_CurrentSprite; - char *m_CurrentSkelAnim; + bool _freezable; + bool _fixedPos; + CBSprite *_currentSprite; + char *_currentSkelAnim; HRESULT Update(TDirection Dir = DI_DOWN); HRESULT SetupTalkFile(char *SoundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) HRESULT Finish(); void SetSound(CBSound *Sound); - bool m_SoundStarted; - CBSound *m_Sound; - TTextAlign m_Align; + bool _soundStarted; + CBSound *_sound; + TTextAlign _align; HRESULT Display(); - int m_Width; - POINT m_Pos; - CBFont *m_Font; + int _width; + POINT _pos; + CBFont *_font; char *GetNextStance(); char *GetCurrentStance(); void SetStances(char *Stances); void SetText(char *Text); - int m_CurrentStance; - uint32 m_StartTime; - char *m_Stances; - char *m_Text; - uint32 m_Duration; + int _currentStance; + uint32 _startTime; + char *_stances; + char *_text; + uint32 _duration; CAdSentence(CBGame *inGame); virtual ~CAdSentence(); - CAdTalkDef *m_TalkDef; + CAdTalkDef *_talkDef; bool CanSkip(); private: - char *m_TempStance; + char *_tempStance; char *GetStance(int Stance); }; diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp index 1940559330..e65e701a85 100644 --- a/engines/wintermute/AdSpriteSet.cpp +++ b/engines/wintermute/AdSpriteSet.cpp @@ -39,27 +39,27 @@ IMPLEMENT_PERSISTENT(CAdSpriteSet, false) ////////////////////////////////////////////////////////////////////////// CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *Owner): CBObject(inGame) { - m_Owner = Owner; + _owner = Owner; for (int i = 0; i < NUM_DIRECTIONS; i++) - m_Sprites[i] = NULL; + _sprites[i] = NULL; } ////////////////////////////////////////////////////////////////////////// CAdSpriteSet::~CAdSpriteSet() { for (int i = 0; i < NUM_DIRECTIONS; i++) { - delete m_Sprites[i]; - m_Sprites[i] = NULL; + delete _sprites[i]; + _sprites[i] = NULL; } - m_Owner = NULL; + _owner = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdSpriteSet::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -130,67 +130,67 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp break; case TOKEN_LEFT: - delete m_Sprites[DI_LEFT]; - m_Sprites[DI_LEFT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_LEFT]; + _sprites[DI_LEFT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_LEFT] = spr; + else _sprites[DI_LEFT] = spr; break; case TOKEN_RIGHT: - delete m_Sprites[DI_RIGHT]; - m_Sprites[DI_RIGHT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_RIGHT]; + _sprites[DI_RIGHT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_RIGHT] = spr; + else _sprites[DI_RIGHT] = spr; break; case TOKEN_UP: - delete m_Sprites[DI_UP]; - m_Sprites[DI_UP] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_UP]; + _sprites[DI_UP] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_UP] = spr; + else _sprites[DI_UP] = spr; break; case TOKEN_DOWN: - delete m_Sprites[DI_DOWN]; - m_Sprites[DI_DOWN] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_DOWN]; + _sprites[DI_DOWN] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_DOWN] = spr; + else _sprites[DI_DOWN] = spr; break; case TOKEN_UP_LEFT: - delete m_Sprites[DI_UPLEFT]; - m_Sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_UPLEFT]; + _sprites[DI_UPLEFT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_UPLEFT] = spr; + else _sprites[DI_UPLEFT] = spr; break; case TOKEN_UP_RIGHT: - delete m_Sprites[DI_UPRIGHT]; - m_Sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_UPRIGHT]; + _sprites[DI_UPRIGHT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_UPRIGHT] = spr; + else _sprites[DI_UPRIGHT] = spr; break; case TOKEN_DOWN_LEFT: - delete m_Sprites[DI_DOWNLEFT]; - m_Sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_DOWNLEFT]; + _sprites[DI_DOWNLEFT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_DOWNLEFT] = spr; + else _sprites[DI_DOWNLEFT] = spr; break; case TOKEN_DOWN_RIGHT: - delete m_Sprites[DI_DOWNRIGHT]; - m_Sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(Game, m_Owner); + delete _sprites[DI_DOWNRIGHT]; + _sprites[DI_DOWNRIGHT] = NULL; + spr = new CBSprite(Game, _owner); if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else m_Sprites[DI_DOWNRIGHT] = spr; + else _sprites[DI_DOWNRIGHT] = spr; break; case TOKEN_EDITOR_PROPERTY: @@ -218,9 +218,9 @@ HRESULT CAdSpriteSet::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Owner)); + PersistMgr->Transfer(TMEMBER(_owner)); for (int i = 0; i < NUM_DIRECTIONS; i++) { - PersistMgr->Transfer("", &m_Sprites[i]); + PersistMgr->Transfer("", &_sprites[i]); } return S_OK; @@ -239,16 +239,16 @@ CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { int i; int NumSteps = 0; for (i = Dir, NumSteps = 0; i >= 0; i--) { - if (m_Sprites[i] != NULL) { - ret = m_Sprites[i]; + if (_sprites[i] != NULL) { + ret = _sprites[i]; NumSteps = Dir - i; break; } } for (i = Dir; i < NUM_DIRECTIONS; i++) { - if (m_Sprites[i] != NULL) { - if (ret == NULL || NumSteps > i - Dir) return m_Sprites[i]; + if (_sprites[i] != NULL) { + if (ret == NULL || NumSteps > i - Dir) return _sprites[i]; else return ret; } } @@ -261,33 +261,33 @@ CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SPRITESET {\n"); - if (m_Name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + if (_name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (m_Sprites[i]) { + if (_sprites[i]) { switch (i) { case DI_UP: - Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPRIGHT: - Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_RIGHT: - Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNRIGHT: - Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWN: - Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNLEFT: - Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_LEFT: - Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPLEFT: - Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", m_Sprites[i]->m_Filename); + Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); break; } } @@ -305,7 +305,7 @@ bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { if (!Sprite) return NULL; for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (m_Sprites[i] == Sprite) return true; + if (_sprites[i] == Sprite) return true; } return false; } diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h index 08b1606962..629978bff3 100644 --- a/engines/wintermute/AdSpriteSet.h +++ b/engines/wintermute/AdSpriteSet.h @@ -41,12 +41,12 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); CBSprite *GetSprite(TDirection Direction); DECLARE_PERSISTENT(CAdSpriteSet, CBObject) - CBObject *m_Owner; + CBObject *_owner; CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); virtual ~CAdSpriteSet(); HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - CBSprite *m_Sprites[NUM_DIRECTIONS]; + CBSprite *_sprites[NUM_DIRECTIONS]; }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkDef.cpp b/engines/wintermute/AdTalkDef.cpp index 77a1c86769..0545887cb3 100644 --- a/engines/wintermute/AdTalkDef.cpp +++ b/engines/wintermute/AdTalkDef.cpp @@ -43,34 +43,34 @@ IMPLEMENT_PERSISTENT(CAdTalkDef, false) ////////////////////////////////////////////////////////////////////////// CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { - m_DefaultSpriteFilename = NULL; - m_DefaultSprite = NULL; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; - m_DefaultSpriteSetFilename = NULL; - m_DefaultSpriteSet = NULL; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; } ////////////////////////////////////////////////////////////////////////// CAdTalkDef::~CAdTalkDef() { - for (int i = 0; i < m_Nodes.GetSize(); i++) delete m_Nodes[i]; - m_Nodes.RemoveAll(); - - delete[] m_DefaultSpriteFilename; - delete m_DefaultSprite; - m_DefaultSpriteFilename = NULL; - m_DefaultSprite = NULL; - - delete[] m_DefaultSpriteSetFilename; - delete m_DefaultSpriteSet; - m_DefaultSpriteSetFilename = NULL; - m_DefaultSpriteSet = NULL; + for (int i = 0; i < _nodes.GetSize(); i++) delete _nodes[i]; + _nodes.RemoveAll(); + + delete[] _defaultSpriteFilename; + delete _defaultSprite; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + delete[] _defaultSpriteSetFilename; + delete _defaultSpriteSet; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::LoadFile(const char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -78,7 +78,7 @@ HRESULT CAdTalkDef::LoadFile(const char *Filename) { HRESULT ret; - CBUtils::SetString(&m_Filename, Filename); + CBUtils::SetString(&_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); @@ -129,7 +129,7 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ACTION: { CAdTalkNode *Node = new CAdTalkNode(Game); - if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) m_Nodes.Add(Node); + if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) _nodes.Add(Node); else { delete Node; Node = NULL; @@ -139,19 +139,19 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_DEFAULT_SPRITE: - CBUtils::SetString(&m_DefaultSpriteFilename, (char *)params); + CBUtils::SetString(&_defaultSpriteFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::SetString(&m_DefaultSpriteSetFilename, (char *)params); + CBUtils::SetString(&_defaultSpriteSetFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET: { - delete m_DefaultSpriteSet; - m_DefaultSpriteSet = new CAdSpriteSet(Game); - if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadBuffer(params, false))) { - delete m_DefaultSpriteSet; - m_DefaultSpriteSet = NULL; + delete _defaultSpriteSet; + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadBuffer(params, false))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; cmd = PARSERR_GENERIC; } } @@ -173,19 +173,19 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - delete m_DefaultSprite; - delete m_DefaultSpriteSet; - m_DefaultSprite = NULL; - m_DefaultSpriteSet = NULL; + delete _defaultSprite; + delete _defaultSpriteSet; + _defaultSprite = NULL; + _defaultSpriteSet = NULL; - if (m_DefaultSpriteFilename) { - m_DefaultSprite = new CBSprite(Game); - if (!m_DefaultSprite || FAILED(m_DefaultSprite->LoadFile(m_DefaultSpriteFilename))) return E_FAIL; + if (_defaultSpriteFilename) { + _defaultSprite = new CBSprite(Game); + if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) return E_FAIL; } - if (m_DefaultSpriteSetFilename) { - m_DefaultSpriteSet = new CAdSpriteSet(Game); - if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadFile(m_DefaultSpriteSetFilename))) return E_FAIL; + if (_defaultSpriteSetFilename) { + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) return E_FAIL; } @@ -198,12 +198,12 @@ HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_DefaultSprite)); - PersistMgr->Transfer(TMEMBER(m_DefaultSpriteFilename)); - PersistMgr->Transfer(TMEMBER(m_DefaultSpriteSet)); - PersistMgr->Transfer(TMEMBER(m_DefaultSpriteSetFilename)); + PersistMgr->Transfer(TMEMBER(_defaultSprite)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteFilename)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteSet)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteSetFilename)); - m_Nodes.Persist(PersistMgr); + _nodes.Persist(PersistMgr); return S_OK; } @@ -212,13 +212,13 @@ HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "TALK {\n"); - if (m_DefaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", m_DefaultSpriteFilename); + if (_defaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - if (m_DefaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", m_DefaultSpriteSetFilename); - else if (m_DefaultSpriteSet) m_DefaultSpriteSet->SaveAsText(Buffer, Indent + 2); + if (_defaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + else if (_defaultSpriteSet) _defaultSpriteSet->SaveAsText(Buffer, Indent + 2); - for (int i = 0; i < m_Nodes.GetSize(); i++) { - m_Nodes[i]->SaveAsText(Buffer, Indent + 2); + for (int i = 0; i < _nodes.GetSize(); i++) { + _nodes[i]->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "\n"); } CBBase::SaveAsText(Buffer, Indent + 2); @@ -231,18 +231,18 @@ HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::LoadDefaultSprite() { - if (m_DefaultSpriteFilename && !m_DefaultSprite) { - m_DefaultSprite = new CBSprite(Game); - if (!m_DefaultSprite || FAILED(m_DefaultSprite->LoadFile(m_DefaultSpriteFilename))) { - delete m_DefaultSprite; - m_DefaultSprite = NULL; + if (_defaultSpriteFilename && !_defaultSprite) { + _defaultSprite = new CBSprite(Game); + if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) { + delete _defaultSprite; + _defaultSprite = NULL; return E_FAIL; } else return S_OK; - } else if (m_DefaultSpriteSetFilename && !m_DefaultSpriteSet) { - m_DefaultSpriteSet = new CAdSpriteSet(Game); - if (!m_DefaultSpriteSet || FAILED(m_DefaultSpriteSet->LoadFile(m_DefaultSpriteSetFilename))) { - delete m_DefaultSpriteSet; - m_DefaultSpriteSet = NULL; + } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; return E_FAIL; } else return S_OK; } else return S_OK; @@ -252,8 +252,8 @@ HRESULT CAdTalkDef::LoadDefaultSprite() { ////////////////////////////////////////////////////////////////////////// CBSprite *CAdTalkDef::GetDefaultSprite(TDirection Dir) { LoadDefaultSprite(); - if (m_DefaultSprite) return m_DefaultSprite; - else if (m_DefaultSpriteSet) return m_DefaultSpriteSet->GetSprite(Dir); + if (_defaultSprite) return _defaultSprite; + else if (_defaultSpriteSet) return _defaultSpriteSet->GetSprite(Dir); else return NULL; } diff --git a/engines/wintermute/AdTalkDef.h b/engines/wintermute/AdTalkDef.h index 4702a10fd6..2ead14540b 100644 --- a/engines/wintermute/AdTalkDef.h +++ b/engines/wintermute/AdTalkDef.h @@ -37,8 +37,8 @@ class CAdTalkNode; class CAdSpriteSet; class CAdTalkDef : public CBObject { public: - char *m_DefaultSpriteSetFilename; - CAdSpriteSet *m_DefaultSpriteSet; + char *_defaultSpriteSetFilename; + CAdSpriteSet *_defaultSpriteSet; CBSprite *GetDefaultSprite(TDirection Dir); HRESULT LoadDefaultSprite(); DECLARE_PERSISTENT(CAdTalkDef, CBObject) @@ -47,9 +47,9 @@ public: virtual ~CAdTalkDef(); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CBArray m_Nodes; - char *m_DefaultSpriteFilename; - CBSprite *m_DefaultSprite; + CBArray _nodes; + char *_defaultSpriteFilename; + CBSprite *_defaultSprite; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); }; diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 74a089167a..44ef2eddb7 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -43,21 +43,21 @@ IMPLEMENT_PERSISTENT(CAdTalkHolder, false) ////////////////////////////////////////////////////////////////////////// CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { - m_Sprite = NULL; + _sprite = NULL; } ////////////////////////////////////////////////////////////////////////// CAdTalkHolder::~CAdTalkHolder() { - delete m_Sprite; - m_Sprite = NULL; + delete _sprite; + _sprite = NULL; int i; - for (i = 0; i < m_TalkSprites.GetSize(); i++) delete m_TalkSprites[i]; - m_TalkSprites.RemoveAll(); + for (i = 0; i < _talkSprites.GetSize(); i++) delete _talkSprites[i]; + _talkSprites.RemoveAll(); - for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) delete m_TalkSpritesEx[i]; - m_TalkSpritesEx.RemoveAll(); + for (i = 0; i < _talkSpritesEx.GetSize(); i++) delete _talkSpritesEx[i]; + _talkSpritesEx.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// @@ -66,34 +66,34 @@ CBSprite *CAdTalkHolder::GetTalkStance(char *Stance) { // forced stance? - if (m_ForcedTalkAnimName && !m_ForcedTalkAnimUsed) { - m_ForcedTalkAnimUsed = true; - delete m_AnimSprite; - m_AnimSprite = new CBSprite(Game, this); - if (m_AnimSprite) { - HRESULT res = m_AnimSprite->LoadFile(m_ForcedTalkAnimName); + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(Game, this); + if (_animSprite) { + HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); if (FAILED(res)) { - Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", m_Name, m_ForcedTalkAnimName); - delete m_AnimSprite; - m_AnimSprite = NULL; - } else return m_AnimSprite; + Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; } } if (Stance != NULL) { // search special talk stances - for (int i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(m_TalkSpritesEx[i]->m_Name, Stance) == 0) { - ret = m_TalkSpritesEx[i]; + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + ret = _talkSpritesEx[i]; break; } } if (ret == NULL) { // serach generic talk stances - for (int i = 0; i < m_TalkSprites.GetSize(); i++) { - if (scumm_stricmp(m_TalkSprites[i]->m_Name, Stance) == 0) { - ret = m_TalkSprites[i]; + for (int i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + ret = _talkSprites[i]; break; } } @@ -102,11 +102,11 @@ CBSprite *CAdTalkHolder::GetTalkStance(char *Stance) { // not a valid stance? get a random one if (ret == NULL) { - if (m_TalkSprites.GetSize() < 1) ret = m_Sprite; + if (_talkSprites.GetSize() < 1) ret = _sprite; else { // TODO: remember last - int rnd = rand() % m_TalkSprites.GetSize(); - ret = m_TalkSprites[rnd]; + int rnd = rand() % _talkSprites.GetSize(); + ret = _talkSprites[rnd]; } } @@ -127,14 +127,14 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack CScValue *Val = Stack->Pop(); bool SetCurrent = false; - if (m_CurrentSprite && m_CurrentSprite == m_Sprite) SetCurrent = true; + if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; - delete m_Sprite; - m_Sprite = NULL; + delete _sprite; + _sprite = NULL; if (Val->IsNULL()) { - m_Sprite = NULL; - if (SetCurrent) m_CurrentSprite = NULL; + _sprite = NULL; + if (SetCurrent) _currentSprite = NULL; Stack->PushBool(true); } else { char *Filename = Val->GetString(); @@ -143,8 +143,8 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Script->RuntimeError("SetSprite method failed for file '%s'", Filename); Stack->PushBool(false); } else { - m_Sprite = spr; - if (SetCurrent) m_CurrentSprite = m_Sprite; + _sprite = spr; + if (SetCurrent) _currentSprite = _sprite; Stack->PushBool(true); } } @@ -157,8 +157,8 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "GetSprite") == 0) { Stack->CorrectParams(0); - if (!m_Sprite || !m_Sprite->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_Sprite->m_Filename); + if (!_sprite || !_sprite->_filename) Stack->PushNULL(); + else Stack->PushString(_sprite->_filename); return S_OK; } @@ -168,8 +168,8 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "GetSpriteObject") == 0) { Stack->CorrectParams(0); - if (!m_Sprite) Stack->PushNULL(); - else Stack->PushNative(m_Sprite, true); + if (!_sprite) Stack->PushNULL(); + else Stack->PushNative(_sprite, true); return S_OK; } @@ -187,8 +187,8 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->PushBool(false); Script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); } else { - if (Ex) m_TalkSpritesEx.Add(spr); - else m_TalkSprites.Add(spr); + if (Ex) _talkSpritesEx.Add(spr); + else _talkSprites.Add(spr); Stack->PushBool(true); } return S_OK; @@ -208,22 +208,22 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack bool SetTemp2 = false; if (Ex) { - for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(m_TalkSpritesEx[i]->m_Filename, Filename) == 0) { - if (m_CurrentSprite == m_TalkSpritesEx[i]) SetCurrent = true; - if (m_TempSprite2 == m_TalkSpritesEx[i]) SetTemp2 = true; - delete m_TalkSpritesEx[i]; - m_TalkSpritesEx.RemoveAt(i); + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_filename, Filename) == 0) { + if (_currentSprite == _talkSpritesEx[i]) SetCurrent = true; + if (_tempSprite2 == _talkSpritesEx[i]) SetTemp2 = true; + delete _talkSpritesEx[i]; + _talkSpritesEx.RemoveAt(i); break; } } } else { - for (i = 0; i < m_TalkSprites.GetSize(); i++) { - if (scumm_stricmp(m_TalkSprites[i]->m_Filename, Filename) == 0) { - if (m_CurrentSprite == m_TalkSprites[i]) SetCurrent = true; - if (m_TempSprite2 == m_TalkSprites[i]) SetTemp2 = true; - delete m_TalkSprites[i]; - m_TalkSprites.RemoveAt(i); + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_filename, Filename) == 0) { + if (_currentSprite == _talkSprites[i]) SetCurrent = true; + if (_tempSprite2 == _talkSprites[i]) SetTemp2 = true; + delete _talkSprites[i]; + _talkSprites.RemoveAt(i); break; } } @@ -231,8 +231,8 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack } Stack->PushBool(true); - if (SetCurrent) m_CurrentSprite = m_Sprite; - if (SetTemp2) m_TempSprite2 = m_Sprite; + if (SetCurrent) _currentSprite = _sprite; + if (SetTemp2) _tempSprite2 = _sprite; return S_OK; } @@ -257,28 +257,28 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack // delete current int i; if (Ex) { - for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - if (m_TalkSpritesEx[i] == m_CurrentSprite) SetCurrent = true; - if (m_TalkSpritesEx[i] == m_TempSprite2) SetTemp2 = true; - delete m_TalkSpritesEx[i]; + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (_talkSpritesEx[i] == _currentSprite) SetCurrent = true; + if (_talkSpritesEx[i] == _tempSprite2) SetTemp2 = true; + delete _talkSpritesEx[i]; } - m_TalkSpritesEx.RemoveAll(); + _talkSpritesEx.RemoveAll(); } else { - for (i = 0; i < m_TalkSprites.GetSize(); i++) { - if (m_TalkSprites[i] == m_CurrentSprite) SetCurrent = true; - if (m_TalkSprites[i] == m_TempSprite2) SetTemp2 = true; - delete m_TalkSprites[i]; + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (_talkSprites[i] == _currentSprite) SetCurrent = true; + if (_talkSprites[i] == _tempSprite2) SetTemp2 = true; + delete _talkSprites[i]; } - m_TalkSprites.RemoveAll(); + _talkSprites.RemoveAll(); } // set new - if (Ex) m_TalkSpritesEx.Add(spr); - else m_TalkSprites.Add(spr); + if (Ex) _talkSpritesEx.Add(spr); + else _talkSprites.Add(spr); Stack->PushBool(true); - if (SetCurrent) m_CurrentSprite = spr; - if (SetTemp2) m_TempSprite2 = spr; + if (SetCurrent) _currentSprite = spr; + if (SetTemp2) _tempSprite2 = spr; } return S_OK; } @@ -289,14 +289,14 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CAdTalkHolder::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("talk-holder"); - return m_ScValue; + _scValue->SetString("talk-holder"); + return _scValue; } else return CAdObject::ScGetProperty(Name); @@ -327,14 +327,14 @@ char *CAdTalkHolder::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { int i; - for (i = 0; i < m_TalkSprites.GetSize(); i++) { - if (m_TalkSprites[i]->m_Filename) - Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", m_TalkSprites[i]->m_Filename); + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (_talkSprites[i]->_filename) + Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); } - for (i = 0; i < m_TalkSpritesEx.GetSize(); i++) { - if (m_TalkSpritesEx[i]->m_Filename) - Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", m_TalkSpritesEx[i]->m_Filename); + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (_talkSpritesEx[i]->_filename) + Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); } return S_OK; @@ -345,9 +345,9 @@ HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CAdTalkHolder::Persist(CBPersistMgr *PersistMgr) { CAdObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Sprite)); - m_TalkSprites.Persist(PersistMgr); - m_TalkSpritesEx.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_sprite)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); return S_OK; } diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h index 7eb07a8f66..3b30779de8 100644 --- a/engines/wintermute/AdTalkHolder.h +++ b/engines/wintermute/AdTalkHolder.h @@ -38,9 +38,9 @@ public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) virtual CBSprite *GetTalkStance(char *Stance); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - CBSprite *m_Sprite; - CBArray m_TalkSprites; - CBArray m_TalkSpritesEx; + CBSprite *_sprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; CAdTalkHolder(CBGame *inGame); virtual ~CAdTalkHolder(); diff --git a/engines/wintermute/AdTalkNode.cpp b/engines/wintermute/AdTalkNode.cpp index 03c0d90609..17e1ca2a2b 100644 --- a/engines/wintermute/AdTalkNode.cpp +++ b/engines/wintermute/AdTalkNode.cpp @@ -40,30 +40,30 @@ IMPLEMENT_PERSISTENT(CAdTalkNode, false) ////////////////////////////////////////////////////////////////////////// CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { - m_Sprite = NULL; - m_SpriteFilename = NULL; - m_SpriteSet = NULL; - m_SpriteSetFilename = NULL; - m_Comment = NULL; - - m_StartTime = m_EndTime = 0; - m_PlayToEnd = false; - m_PreCache = false; + _sprite = NULL; + _spriteFilename = NULL; + _spriteSet = NULL; + _spriteSetFilename = NULL; + _comment = NULL; + + _startTime = _endTime = 0; + _playToEnd = false; + _preCache = false; } ////////////////////////////////////////////////////////////////////////// CAdTalkNode::~CAdTalkNode() { - delete[] m_SpriteFilename; - delete m_Sprite; - delete[] m_SpriteSetFilename; - delete m_SpriteSet; - delete m_Comment; - m_SpriteFilename = NULL; - m_Sprite = NULL; - m_SpriteSetFilename = NULL; - m_SpriteSet = NULL; - m_Comment = NULL; + delete[] _spriteFilename; + delete _sprite; + delete[] _spriteSetFilename; + delete _spriteSet; + delete _comment; + _spriteFilename = NULL; + _sprite = NULL; + _spriteSetFilename = NULL; + _spriteSet = NULL; + _comment = NULL; } @@ -105,45 +105,45 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { Buffer = params; } - m_EndTime = 0; - m_PlayToEnd = false; - m_PreCache = false; + _endTime = 0; + _playToEnd = false; + _preCache = false; while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: - CBUtils::SetString(&m_SpriteFilename, (char *)params); + CBUtils::SetString(&_spriteFilename, (char *)params); break; case TOKEN_SPRITESET_FILE: - CBUtils::SetString(&m_SpriteSetFilename, (char *)params); + CBUtils::SetString(&_spriteSetFilename, (char *)params); break; case TOKEN_SPRITESET: { - delete m_SpriteSet; - m_SpriteSet = new CAdSpriteSet(Game); - if (!m_SpriteSet || FAILED(m_SpriteSet->LoadBuffer(params, false))) { - delete m_SpriteSet; - m_SpriteSet = NULL; + delete _spriteSet; + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadBuffer(params, false))) { + delete _spriteSet; + _spriteSet = NULL; cmd = PARSERR_GENERIC; } } break; case TOKEN_START_TIME: - parser.ScanStr((char *)params, "%d", &m_StartTime); + parser.ScanStr((char *)params, "%d", &_startTime); break; case TOKEN_END_TIME: - parser.ScanStr((char *)params, "%d", &m_EndTime); + parser.ScanStr((char *)params, "%d", &_endTime); break; case TOKEN_PRECACHE: - parser.ScanStr((char *)params, "%b", &m_PreCache); + parser.ScanStr((char *)params, "%b", &_preCache); break; case TOKEN_COMMENT: - if (Game->m_EditorMode) CBUtils::SetString(&m_Comment, (char *)params); + if (Game->_editorMode) CBUtils::SetString(&_comment, (char *)params); break; case TOKEN_EDITOR_PROPERTY: @@ -161,19 +161,19 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (m_EndTime == 0) m_PlayToEnd = true; - else m_PlayToEnd = false; + if (_endTime == 0) _playToEnd = true; + else _playToEnd = false; - if (m_PreCache && m_SpriteFilename) { - delete m_Sprite; - m_Sprite = new CBSprite(Game); - if (!m_Sprite || FAILED(m_Sprite->LoadFile(m_SpriteFilename))) return E_FAIL; + if (_preCache && _spriteFilename) { + delete _sprite; + _sprite = new CBSprite(Game); + if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) return E_FAIL; } - if (m_PreCache && m_SpriteSetFilename) { - delete m_SpriteSet; - m_SpriteSet = new CAdSpriteSet(Game); - if (!m_SpriteSet || FAILED(m_SpriteSet->LoadFile(m_SpriteSetFilename))) return E_FAIL; + if (_preCache && _spriteSetFilename) { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) return E_FAIL; } @@ -184,14 +184,14 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_Comment)); - PersistMgr->Transfer(TMEMBER(m_StartTime)); - PersistMgr->Transfer(TMEMBER(m_EndTime)); - PersistMgr->Transfer(TMEMBER(m_PlayToEnd)); - PersistMgr->Transfer(TMEMBER(m_Sprite)); - PersistMgr->Transfer(TMEMBER(m_SpriteFilename)); - PersistMgr->Transfer(TMEMBER(m_SpriteSet)); - PersistMgr->Transfer(TMEMBER(m_SpriteSetFilename)); + PersistMgr->Transfer(TMEMBER(_comment)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_endTime)); + PersistMgr->Transfer(TMEMBER(_playToEnd)); + PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER(_spriteFilename)); + PersistMgr->Transfer(TMEMBER(_spriteSet)); + PersistMgr->Transfer(TMEMBER(_spriteSetFilename)); return S_OK; } @@ -200,13 +200,13 @@ HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ACTION {\n"); - if (m_Comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", m_Comment); - Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", m_StartTime); - if (!m_PlayToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", m_EndTime); - if (m_SpriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", m_SpriteFilename); - if (m_SpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", m_SpriteSetFilename); - else if (m_SpriteSet) m_SpriteSet->SaveAsText(Buffer, Indent + 2); - if (m_PreCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", m_PreCache ? "TRUE" : "FALSE"); + if (_comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); + Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + else if (_spriteSet) _spriteSet->SaveAsText(Buffer, Indent + 2); + if (_preCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); CBBase::SaveAsText(Buffer, Indent + 2); @@ -218,20 +218,20 @@ HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkNode::LoadSprite() { - if (m_SpriteFilename && !m_Sprite) { - m_Sprite = new CBSprite(Game); - if (!m_Sprite || FAILED(m_Sprite->LoadFile(m_SpriteFilename))) { - delete m_Sprite; - m_Sprite = NULL; + if (_spriteFilename && !_sprite) { + _sprite = new CBSprite(Game); + if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) { + delete _sprite; + _sprite = NULL; return E_FAIL; } else return S_OK; } - else if (m_SpriteSetFilename && !m_SpriteSet) { - m_SpriteSet = new CAdSpriteSet(Game); - if (!m_SpriteSet || FAILED(m_SpriteSet->LoadFile(m_SpriteSetFilename))) { - delete m_SpriteSet; - m_SpriteSet = NULL; + else if (_spriteSetFilename && !_spriteSet) { + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) { + delete _spriteSet; + _spriteSet = NULL; return E_FAIL; } else return S_OK; } @@ -242,12 +242,12 @@ HRESULT CAdTalkNode::LoadSprite() { ////////////////////////////////////////////////////////////////////////// bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { - if (Time >= m_StartTime) { - if (m_PlayToEnd) { - if ((m_SpriteFilename && m_Sprite == NULL) || (m_Sprite && m_Sprite->m_Finished == false)) return true; - else if ((m_SpriteSetFilename && m_SpriteSet == NULL) || (m_SpriteSet && m_SpriteSet->GetSprite(Dir) && m_SpriteSet->GetSprite(Dir)->m_Finished == false)) return true; + if (Time >= _startTime) { + if (_playToEnd) { + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->GetSprite(Dir) && _spriteSet->GetSprite(Dir)->_finished == false)) return true; else return false; - } else return m_EndTime >= Time; + } else return _endTime >= Time; } else return false; } @@ -255,8 +255,8 @@ bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { ////////////////////////////////////////////////////////////////////////// CBSprite *CAdTalkNode::GetSprite(TDirection Dir) { LoadSprite(); - if (m_Sprite) return m_Sprite; - else if (m_SpriteSet) return m_SpriteSet->GetSprite(Dir); + if (_sprite) return _sprite; + else if (_spriteSet) return _spriteSet->GetSprite(Dir); else return NULL; } diff --git a/engines/wintermute/AdTalkNode.h b/engines/wintermute/AdTalkNode.h index 3587cdb57b..d939847b70 100644 --- a/engines/wintermute/AdTalkNode.h +++ b/engines/wintermute/AdTalkNode.h @@ -37,8 +37,8 @@ class CAdSpriteSet; class CBSprite; class CAdTalkNode : public CBBase { public: - char *m_SpriteSetFilename; - CAdSpriteSet *m_SpriteSet; + char *_spriteSetFilename; + CAdSpriteSet *_spriteSet; CBSprite *GetSprite(TDirection Dir); bool IsInTimeInterval(uint32 Time, TDirection Dir); HRESULT LoadSprite(); @@ -48,13 +48,13 @@ public: virtual ~CAdTalkNode(); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); - char *m_SpriteFilename; - CBSprite *m_Sprite; - uint32 m_StartTime; - uint32 m_EndTime; - bool m_PlayToEnd; - bool m_PreCache; - char *m_Comment; + char *_spriteFilename; + CBSprite *_sprite; + uint32 _startTime; + uint32 _endTime; + bool _playToEnd; + bool _preCache; + char *_comment; }; diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index bbd1cdb92a..97a8056713 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -39,10 +39,10 @@ IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) ////////////////////////////////////////////////////////////////////////// CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { - m_Active = true; - m_EditorSelectedPoint = -1; - m_LastMimicScale = -1; - m_LastMimicX = m_LastMimicY = INT_MIN; + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; } @@ -54,16 +54,16 @@ CAdWaypointGroup::~CAdWaypointGroup() { ////////////////////////////////////////////////////////////////////////// void CAdWaypointGroup::Cleanup() { - for (int i = 0; i < m_Points.GetSize(); i++) - delete m_Points[i]; - m_Points.RemoveAll(); - m_EditorSelectedPoint = -1; + for (int i = 0; i < _points.GetSize(); i++) + delete _points[i]; + _points.RemoveAll(); + _editorSelectedPoint = -1; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -71,8 +71,8 @@ HRESULT CAdWaypointGroup::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); @@ -131,16 +131,16 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_POINT: { int x, y; parser.ScanStr((char *)params, "%d,%d", &x, &y); - m_Points.Add(new CBPoint(x, y)); + _points.Add(new CBPoint(x, y)); } break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &m_EditorSelected); + parser.ScanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: @@ -164,15 +164,15 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", m_EditorSelectedPoint); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); CBBase::SaveAsText(Buffer, Indent + 2); - for (int i = 0; i < m_Points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + for (int i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } Buffer->PutTextIndent(Indent, "}\n"); @@ -186,12 +186,12 @@ HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_EditorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(m_LastMimicScale)); - PersistMgr->Transfer(TMEMBER(m_LastMimicX)); - PersistMgr->Transfer(TMEMBER(m_LastMimicY)); - m_Points.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(_lastMimicScale)); + PersistMgr->Transfer(TMEMBER(_lastMimicX)); + PersistMgr->Transfer(TMEMBER(_lastMimicY)); + _points.Persist(PersistMgr); return S_OK; } @@ -199,22 +199,22 @@ HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// CScValue *CAdWaypointGroup::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("waypoint-group"); - return m_ScValue; + _scValue->SetString("waypoint-group"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { - m_ScValue->SetBool(m_Active); - return m_ScValue; + _scValue->SetBool(_active); + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -227,7 +227,7 @@ HRESULT CAdWaypointGroup::ScSetProperty(char *Name, CScValue *Value) { // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Active") == 0) { - m_Active = Value->GetBool(); + _active = Value->GetBool(); return S_OK; } @@ -237,22 +237,22 @@ HRESULT CAdWaypointGroup::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { - if (Scale == m_LastMimicScale && X == m_LastMimicX && Y == m_LastMimicY) return S_OK; + if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; Cleanup(); - for (int i = 0; i < Wpt->m_Points.GetSize(); i++) { + for (int i = 0; i < Wpt->_points.GetSize(); i++) { int x, y; - x = (int)((float)Wpt->m_Points[i]->x * Scale / 100.0f); - y = (int)((float)Wpt->m_Points[i]->y * Scale / 100.0f); + x = (int)((float)Wpt->_points[i]->x * Scale / 100.0f); + y = (int)((float)Wpt->_points[i]->y * Scale / 100.0f); - m_Points.Add(new CBPoint(x + X, y + Y)); + _points.Add(new CBPoint(x + X, y + Y)); } - m_LastMimicScale = Scale; - m_LastMimicX = X; - m_LastMimicY = Y; + _lastMimicScale = Scale; + _lastMimicX = X; + _lastMimicY = Y; return S_OK; } diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h index 50992f1387..e997e89663 100644 --- a/engines/wintermute/AdWaypointGroup.h +++ b/engines/wintermute/AdWaypointGroup.h @@ -35,20 +35,20 @@ namespace WinterMute { class CBPoint; class CAdWaypointGroup : public CBObject { public: - float m_LastMimicScale; - int m_LastMimicX; - int m_LastMimicY; + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; void Cleanup(); HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - bool m_Active; + bool _active; CAdWaypointGroup(CBGame *inGame); HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual ~CAdWaypointGroup(); - CBArray m_Points; - int m_EditorSelectedPoint; + CBArray _points; + int _editorSelectedPoint; virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); }; diff --git a/engines/wintermute/BActiveRect.cpp b/engines/wintermute/BActiveRect.cpp index 5827cb8d61..867b492a85 100644 --- a/engines/wintermute/BActiveRect.cpp +++ b/engines/wintermute/BActiveRect.cpp @@ -36,51 +36,51 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&m_Rect); - m_Owner = NULL; - m_Frame = NULL; - m_Region = NULL; - m_ZoomX = 100; - m_ZoomY = 100; - m_OffsetX = m_OffsetY = 0; + CBPlatform::SetRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; ClipRect(); } ////////////////////////////////////////////////////////////////////// CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise): CBBase(inGame) { - m_Owner = Owner; - m_Frame = Frame; - CBPlatform::SetRect(&m_Rect, X, Y, X + Width, Y + Height); - m_ZoomX = ZoomX; - m_ZoomY = ZoomY; - m_Precise = Precise; - m_Region = NULL; - m_OffsetX = m_OffsetY = 0; + _owner = Owner; + _frame = Frame; + CBPlatform::SetRect(&_rect, X, Y, X + Width, Y + Height); + _zoomX = ZoomX; + _zoomY = ZoomY; + _precise = Precise; + _region = NULL; + _offsetX = _offsetY = 0; ClipRect(); } ////////////////////////////////////////////////////////////////////// CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY): CBBase(inGame) { - m_Owner = Owner; - m_Region = Region; - CBPlatform::CopyRect(&m_Rect, &Region->m_Rect); - CBPlatform::OffsetRect(&m_Rect, -OffsetX, -OffsetY); - m_ZoomX = 100; - m_ZoomY = 100; - m_Precise = true; - m_Frame = NULL; + _owner = Owner; + _region = Region; + CBPlatform::CopyRect(&_rect, &Region->_rect); + CBPlatform::OffsetRect(&_rect, -OffsetX, -OffsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; ClipRect(); - m_OffsetX = OffsetX; - m_OffsetY = OffsetY; + _offsetX = OffsetX; + _offsetY = OffsetY; } ////////////////////////////////////////////////////////////////////// CBActiveRect::~CBActiveRect() { - m_Owner = NULL; - m_Frame = NULL; - m_Region = NULL; + _owner = NULL; + _frame = NULL; + _region = NULL; } @@ -89,19 +89,19 @@ void CBActiveRect::ClipRect() { RECT rc; bool CustomViewport; Game->GetCurrentViewportRect(&rc, &CustomViewport); - CBRenderer *Rend = Game->m_Renderer; + CBRenderer *Rend = Game->_renderer; if (!CustomViewport) { - rc.left -= Rend->m_DrawOffsetX; - rc.right -= Rend->m_DrawOffsetX; - rc.top -= Rend->m_DrawOffsetY; - rc.bottom -= Rend->m_DrawOffsetY; + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; } - if (rc.left > m_Rect.left) m_OffsetX = rc.left - m_Rect.left; - if (rc.top > m_Rect.top) m_OffsetY = rc.top - m_Rect.top; + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - CBPlatform::IntersectRect(&m_Rect, &m_Rect, &rc); + CBPlatform::IntersectRect(&_rect, &_rect, &rc); } } // end of namespace WinterMute diff --git a/engines/wintermute/BActiveRect.h b/engines/wintermute/BActiveRect.h index ee9bb8aea1..9143c1fa6e 100644 --- a/engines/wintermute/BActiveRect.h +++ b/engines/wintermute/BActiveRect.h @@ -38,15 +38,15 @@ class CBObject; class CBActiveRect: CBBase { public: void ClipRect(); - bool m_Precise; - float m_ZoomX; - float m_ZoomY; - CBSubFrame *m_Frame; - CBObject *m_Owner; - CBRegion *m_Region; - int m_OffsetX; - int m_OffsetY; - RECT m_Rect; + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + RECT _rect; CBActiveRect(CBGame *inGameOwner = NULL); CBActiveRect(CBGame *inGameOwner, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX = 100, float ZoomY = 100, bool Precise = true); CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY); diff --git a/engines/wintermute/BBase.cpp b/engines/wintermute/BBase.cpp index 536decb5f9..32d89cea7f 100644 --- a/engines/wintermute/BBase.cpp +++ b/engines/wintermute/BBase.cpp @@ -37,29 +37,29 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBBase::CBBase(CBGame *GameOwner) { Game = GameOwner; - m_Persistable = true; + _persistable = true; } ////////////////////////////////////////////////////////////////////////// CBBase::CBBase() { Game = NULL; - m_Persistable = true; + _persistable = true; } ////////////////////////////////////////////////////////////////////// CBBase::~CBBase() { - m_EditorProps.clear(); + _editorProps.clear(); } ////////////////////////////////////////////////////////////////////////// const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { - m_EditorPropsIter = m_EditorProps.find(PropName); - if (m_EditorPropsIter != m_EditorProps.end()) - return m_EditorPropsIter->_value.c_str(); - //return m_EditorPropsIter->second.c_str(); // <- TODO Clean + _editorPropsIter = _editorProps.find(PropName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean else return InitVal; } @@ -69,9 +69,9 @@ HRESULT CBBase::SetEditorProp(const char *PropName, const char *PropValue) { if (PropName == NULL) return E_FAIL; if (PropValue == NULL) { - m_EditorProps.erase(PropName); + _editorProps.erase(PropName); } else { - m_EditorProps[PropName] = PropValue; + _editorProps[PropName] = PropValue; } return S_OK; } @@ -92,7 +92,7 @@ HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { TOKEN_TABLE_END - if (!Game->m_EditorMode) return S_OK; + if (!Game->_editorMode) return S_OK; byte *params; @@ -159,17 +159,17 @@ HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { - m_EditorPropsIter = m_EditorProps.begin(); - while (m_EditorPropsIter != m_EditorProps.end()) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->_value.c_str()); - //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_EditorPropsIter->first.c_str()); // <- TODO, remove - //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_EditorPropsIter->second.c_str()); // <- TODO, remove + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove Buffer->PutTextIndent(Indent, "}\n\n"); - m_EditorPropsIter++; + _editorPropsIter++; } return S_OK; } diff --git a/engines/wintermute/BBase.h b/engines/wintermute/BBase.h index c72d687eca..423c9fef6a 100644 --- a/engines/wintermute/BBase.h +++ b/engines/wintermute/BBase.h @@ -44,7 +44,7 @@ class CBDynBuffer; class CBBase { public: - bool m_Persistable; + bool _persistable; HRESULT SetEditorProp(const char *PropName, const char *PropValue); const char *GetEditorProp(const char *PropName, const char *InitVal = NULL); CBBase(TDynamicConstructor, TDynamicConstructor) {}; @@ -55,10 +55,10 @@ public: CBBase(CBGame *GameOwner); virtual ~CBBase(); - Common::HashMap m_EditorProps; - Common::HashMap::iterator m_EditorPropsIter; -/* std::map m_EditorProps; - std::map::iterator m_EditorPropsIter;*/ + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; +/* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ }; } // end of namespace WinterMute diff --git a/engines/wintermute/BDebugger.cpp b/engines/wintermute/BDebugger.cpp index 13eae9fd18..5c26b6ae23 100644 --- a/engines/wintermute/BDebugger.cpp +++ b/engines/wintermute/BDebugger.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { - m_Enabled = false; + _enabled = false; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BDebugger.h b/engines/wintermute/BDebugger.h index 21a7d308a9..c443863af0 100644 --- a/engines/wintermute/BDebugger.h +++ b/engines/wintermute/BDebugger.h @@ -42,7 +42,7 @@ public: virtual ~CBDebugger(void); // initialization - bool m_Enabled; + bool _enabled; HRESULT Initialize(); HRESULT Shutdown(); diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index ed735c846d..24c25f3bed 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -39,10 +39,10 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { - m_File = NULL; - m_Data = NULL; - m_Compressed = false; - m_PrefixSize = 0; + _file = NULL; + _data = NULL; + _compressed = false; + _prefixSize = 0; } @@ -58,53 +58,53 @@ HRESULT CBDiskFile::Open(Common::String Filename) { char FullPath[MAX_PATH]; - for (int i = 0; i < Game->m_FileManager->m_SinglePaths.GetSize(); i++) { - sprintf(FullPath, "%s%s", Game->m_FileManager->m_SinglePaths[i], Filename.c_str()); + for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { + sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); CorrectSlashes(FullPath); - //m_File = Common::createFileStream(FullPath); + //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if(tempFile->open(FullPath)) { - m_File = tempFile; + _file = tempFile; } else { delete tempFile; } -/* if (m_File != NULL) { +/* if (_file != NULL) { error("Tried to open %s, but failed", Filename.c_str()); break; }*/ } // if we didn't find it in search paths, try to open directly - if (!m_File) { + if (!_file) { strcpy(FullPath, Filename.c_str()); CorrectSlashes(FullPath); //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); - //m_File = Common::createFileStream(FullPath); + //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if (tempFile->open(FullPath)) { - m_File = tempFile; + _file = tempFile; } else { delete tempFile; } } - if (!m_File) { + if (!_file) { warning("Couldn't load %s", Filename.c_str()); } - if (m_File) { + if (_file) { uint32 magic1, magic2; - magic1 = m_File->readUint32LE(); - magic2 = m_File->readUint32LE(); + magic1 = _file->readUint32LE(); + magic2 = _file->readUint32LE(); - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) m_Compressed = true; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; - if (m_Compressed) { + if (_compressed) { uint32 DataOffset, CompSize, UncompSize; - DataOffset = m_File->readUint32LE(); - CompSize = m_File->readUint32LE(); - UncompSize = m_File->readUint32LE(); + DataOffset = _file->readUint32LE(); + CompSize = _file->readUint32LE(); + UncompSize = _file->readUint32LE(); byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { @@ -113,17 +113,17 @@ HRESULT CBDiskFile::Open(Common::String Filename) { return E_FAIL; } - m_Data = new byte[UncompSize]; - if (!m_Data) { + _data = new byte[UncompSize]; + if (!_data) { Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); delete [] CompBuffer; Close(); return E_FAIL; } - m_File->seek(DataOffset + m_PrefixSize, SEEK_SET); - m_File->read(CompBuffer, CompSize); + _file->seek(DataOffset + _prefixSize, SEEK_SET); + _file->read(CompBuffer, CompSize); - if (uncompress(m_Data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { + if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); delete [] CompBuffer; Close(); @@ -131,15 +131,15 @@ HRESULT CBDiskFile::Open(Common::String Filename) { } delete [] CompBuffer; - m_Size = UncompSize; - m_Pos = 0; - delete m_File; - m_File = NULL; + _size = UncompSize; + _pos = 0; + delete _file; + _file = NULL; } else { - m_Pos = 0; - m_File->seek(0, SEEK_END); - m_Size = m_File->pos() - m_PrefixSize; - m_File->seek(m_PrefixSize,SEEK_SET); + _pos = 0; + _file->seek(0, SEEK_END); + _size = _file->pos() - _prefixSize; + _file->seek(_prefixSize,SEEK_SET); } return S_OK; @@ -149,17 +149,17 @@ HRESULT CBDiskFile::Open(Common::String Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDiskFile::Close() { - if (m_File) { - delete m_File; + if (_file) { + delete _file; } - m_File = NULL; - m_Pos = 0; - m_Size = 0; + _file = NULL; + _pos = 0; + _size = 0; - delete[] m_Data; - m_Data = NULL; + delete[] _data; + _data = NULL; - m_Compressed = false; + _compressed = false; return S_OK; } @@ -167,15 +167,15 @@ HRESULT CBDiskFile::Close() { ////////////////////////////////////////////////////////////////////////// HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { - if (m_Compressed) { - memcpy(Buffer, m_Data + m_Pos, Size); - m_Pos += Size; + if (_compressed) { + memcpy(Buffer, _data + _pos, Size); + _pos += Size; return S_OK; } else { - if (m_File) { - size_t count = m_File->read(Buffer, Size); - m_Pos += count; + if (_file) { + size_t count = _file->read(Buffer, Size); + _pos += count; return S_OK; } else return E_FAIL; } @@ -184,7 +184,7 @@ HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { - if (m_Compressed) { + if (_compressed) { uint32 NewPos = 0; switch (Origin) { @@ -192,33 +192,33 @@ HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { NewPos = Pos; break; case SEEK_TO_END: - NewPos = m_Size + Pos; + NewPos = _size + Pos; break; case SEEK_TO_CURRENT: - NewPos = m_Pos + Pos; + NewPos = _pos + Pos; break; } - if (NewPos < 0 || NewPos > m_Size) return E_FAIL; - else m_Pos = NewPos; + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; return S_OK; } else { - if (!m_File) return E_FAIL; + if (!_file) return E_FAIL; int ret = 1; switch (Origin) { case SEEK_TO_BEGIN: - ret = m_File->seek(m_PrefixSize + Pos, SEEK_SET); + ret = _file->seek(_prefixSize + Pos, SEEK_SET); break; case SEEK_TO_END: - ret = m_File->seek(Pos, SEEK_END); + ret = _file->seek(Pos, SEEK_END); break; case SEEK_TO_CURRENT: - ret = m_File->seek(Pos, SEEK_CUR); + ret = _file->seek(Pos, SEEK_CUR); break; } if (ret == 0) { - m_Pos = m_File->pos() - m_PrefixSize; + _pos = _file->pos() - _prefixSize; return S_OK; } else return E_FAIL; } diff --git a/engines/wintermute/BDiskFile.h b/engines/wintermute/BDiskFile.h index 7cb4a889aa..6991283437 100644 --- a/engines/wintermute/BDiskFile.h +++ b/engines/wintermute/BDiskFile.h @@ -48,10 +48,10 @@ public: virtual HRESULT Open(Common::String Filename); private: void CorrectSlashes(char *fileName); - Common::SeekableReadStream *m_File; - byte *m_Data; - bool m_Compressed; - uint32 m_PrefixSize; + Common::SeekableReadStream *_file; + byte *_data; + bool _compressed; + uint32 _prefixSize; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BDynBuffer.cpp b/engines/wintermute/BDynBuffer.cpp index 3fe99faeb1..68012f29f8 100644 --- a/engines/wintermute/BDynBuffer.cpp +++ b/engines/wintermute/BDynBuffer.cpp @@ -33,15 +33,15 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase(inGame) { - m_Buffer = NULL; - m_Size = 0; - m_RealSize = 0; + _buffer = NULL; + _size = 0; + _realSize = 0; - m_Offset = 0; - m_InitSize = InitSize; - m_GrowBy = GrowBy; + _offset = 0; + _initSize = InitSize; + _growBy = GrowBy; - m_Initialized = false; + _initialized = false; } @@ -53,18 +53,18 @@ CBDynBuffer::~CBDynBuffer() { ////////////////////////////////////////////////////////////////////////// void CBDynBuffer::Cleanup() { - if (m_Buffer) free(m_Buffer); - m_Buffer = NULL; - m_Size = 0; - m_RealSize = 0; - m_Offset = 0; - m_Initialized = false; + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; } ////////////////////////////////////////////////////////////////////////// uint32 CBDynBuffer::GetSize() { - return m_Size; + return _size; } @@ -72,16 +72,16 @@ uint32 CBDynBuffer::GetSize() { HRESULT CBDynBuffer::Init(uint32 InitSize) { Cleanup(); - if (InitSize == 0) InitSize = m_InitSize; + if (InitSize == 0) InitSize = _initSize; - m_Buffer = (byte *)malloc(InitSize); - if (!m_Buffer) { + _buffer = (byte *)malloc(InitSize); + if (!_buffer) { Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); return E_FAIL; } - m_RealSize = InitSize; - m_Initialized = true; + _realSize = InitSize; + _initialized = true; return S_OK; } @@ -89,20 +89,20 @@ HRESULT CBDynBuffer::Init(uint32 InitSize) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { - if (!m_Initialized) Init(); + if (!_initialized) Init(); - while (m_Offset + Size > m_RealSize) { - m_RealSize += m_GrowBy; - m_Buffer = (byte *)realloc(m_Buffer, m_RealSize); - if (!m_Buffer) { - Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", m_RealSize); + while (_offset + Size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return E_FAIL; } } - memcpy(m_Buffer + m_Offset, Buffer, Size); - m_Offset += Size; - m_Size += Size; + memcpy(_buffer + _offset, Buffer, Size); + _offset += Size; + _size += Size; return S_OK; } @@ -110,15 +110,15 @@ HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { - if (!m_Initialized) Init(); + if (!_initialized) Init(); - if (m_Offset + Size > m_Size) { + if (_offset + Size > _size) { Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); return E_FAIL; } - memcpy(Buffer, m_Buffer + m_Offset, Size); - m_Offset += Size; + memcpy(Buffer, _buffer + _offset, Size); + _offset += Size; return S_OK; } @@ -151,8 +151,8 @@ void CBDynBuffer::PutString(const char *Val) { ////////////////////////////////////////////////////////////////////////// char *CBDynBuffer::GetString() { uint32 len = GetDWORD(); - char *ret = (char *)(m_Buffer + m_Offset); - m_Offset += len; + char *ret = (char *)(_buffer + _offset); + _offset += len; if (!strcmp(ret, "(null)")) return NULL; else return ret; diff --git a/engines/wintermute/BDynBuffer.h b/engines/wintermute/BDynBuffer.h index 7ef970fcd3..4b05ee88ff 100644 --- a/engines/wintermute/BDynBuffer.h +++ b/engines/wintermute/BDynBuffer.h @@ -36,7 +36,7 @@ namespace WinterMute { class CBDynBuffer : public CBBase { public: - bool m_Initialized; + bool _initialized; void PutText(LPCSTR fmt, ...); void PutTextIndent(int Indent, LPCSTR fmt, ...); uint32 GetDWORD(); @@ -48,16 +48,16 @@ public: uint32 GetSize(); HRESULT Init(uint32 InitSize = 0); void Cleanup(); - uint32 m_Size; - byte *m_Buffer; + uint32 _size; + byte *_buffer; CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); virtual ~CBDynBuffer(); private: - uint32 m_RealSize; - uint32 m_GrowBy; - uint32 m_InitSize; - uint32 m_Offset; + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; void PutTextForm(const char *format, va_list argptr); }; diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp index fbeddacb39..977b965561 100644 --- a/engines/wintermute/BEvent.cpp +++ b/engines/wintermute/BEvent.cpp @@ -41,27 +41,27 @@ IMPLEMENT_PERSISTENT(CBEvent, false) ////////////////////////////////////////////////////////////////////////// CBEvent::CBEvent(CBGame *inGame): CBBase(inGame) { - m_Type = EVENT_NONE; - m_Script = NULL; - m_Name = NULL; + _type = EVENT_NONE; + _script = NULL; + _name = NULL; } ////////////////////////////////////////////////////////////////////////// CBEvent::CBEvent(CBGame *inGame, TEventType Type, char *Script): CBBase(inGame) { - m_Type = Type; - m_Script = new char [strlen(Script) + 1]; - if (m_Script) strcpy(m_Script, Script); - m_Name = NULL; + _type = Type; + _script = new char [strlen(Script) + 1]; + if (_script) strcpy(_script, Script); + _name = NULL; } ////////////////////////////////////////////////////////////////////////// CBEvent::~CBEvent() { - delete[] m_Script; - m_Script = NULL; - delete[] m_Name; - m_Name = NULL; + delete[] _script; + _script = NULL; + delete[] _name; + _name = NULL; } @@ -101,26 +101,26 @@ const char *CBEvent::GetEventName(TEventType Type) { ////////////////////////////////////////////////////////////////////////// void CBEvent::SetScript(char *Script) { - if (m_Script) delete [] m_Script; + if (_script) delete [] _script; - m_Script = new char [strlen(Script) + 1]; - if (m_Script) strcpy(m_Script, Script); + _script = new char [strlen(Script) + 1]; + if (_script) strcpy(_script, Script); } ////////////////////////////////////////////////////////////////////////// void CBEvent::SetName(char *Name) { - if (m_Name) delete [] m_Name; + if (_name) delete [] _name; - m_Name = new char [strlen(Name) + 1]; - if (m_Name) strcpy(m_Name, Name); + _name = new char [strlen(Name) + 1]; + if (_name) strcpy(_name, Name); } ////////////////////////////////////////////////////////////////////////// HRESULT CBEvent::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -187,9 +187,9 @@ HRESULT CBEvent::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_Script)); - PersistMgr->Transfer(TMEMBER(m_Name)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(_script)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h index 006e10706e..87d3de0e96 100644 --- a/engines/wintermute/BEvent.h +++ b/engines/wintermute/BEvent.h @@ -41,9 +41,9 @@ public: void SetScript(char *Script); void SetName(char *Name); static const char *GetEventName(TEventType Type); - char *m_Script; - char *m_Name; - TEventType m_Type; + char *_script; + char *_name; + TEventType _type; CBEvent(CBGame *inGame); CBEvent(CBGame *inGame, TEventType Type, char *Script); virtual ~CBEvent(); diff --git a/engines/wintermute/BFader.cpp b/engines/wintermute/BFader.cpp index 955f0252f5..b40582318a 100644 --- a/engines/wintermute/BFader.cpp +++ b/engines/wintermute/BFader.cpp @@ -42,14 +42,14 @@ IMPLEMENT_PERSISTENT(CBFader, false) ////////////////////////////////////////////////////////////////////////// CBFader::CBFader(CBGame *inGame): CBObject(inGame) { - m_Active = false; - m_Red = m_Green = m_Blue = 0; - m_CurrentAlpha = 0x00; - m_SourceAlpha = 0; - m_TargetAlpha = 0; - m_Duration = 1000; - m_StartTime = 0; - m_System = false; + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; } @@ -61,23 +61,23 @@ CBFader::~CBFader() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFader::Update() { - if (!m_Active) return S_OK; + if (!_active) return S_OK; - int AlphaDelta = m_TargetAlpha - m_SourceAlpha; + int AlphaDelta = _targetAlpha - _sourceAlpha; uint32 time; - if (m_System) time = CBPlatform::GetTime() - m_StartTime; - else time = Game->m_Timer - m_StartTime; + if (_system) time = CBPlatform::GetTime() - _startTime; + else time = Game->_timer - _startTime; - if (time >= m_Duration) m_CurrentAlpha = m_TargetAlpha; + if (time >= _duration) _currentAlpha = _targetAlpha; else { - m_CurrentAlpha = m_SourceAlpha + (float)time / (float)m_Duration * AlphaDelta; + _currentAlpha = _sourceAlpha + (float)time / (float)_duration * AlphaDelta; } - m_CurrentAlpha = MIN((unsigned char)255, MAX(m_CurrentAlpha, (byte )0)); // TODO: clean + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte )0)); // TODO: clean - m_Ready = time >= m_Duration; - if (m_Ready && m_CurrentAlpha == 0x00) m_Active = false; + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; return S_OK; } @@ -85,38 +85,38 @@ HRESULT CBFader::Update() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFader::Display() { - if (!m_Active) return S_OK; + if (!_active) return S_OK; - if (m_CurrentAlpha > 0x00) return Game->m_Renderer->FadeToColor(DRGBA(m_Red, m_Green, m_Blue, m_CurrentAlpha)); + if (_currentAlpha > 0x00) return Game->_renderer->FadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); else return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBFader::Deactivate() { - m_Active = false; - m_Ready = true; + _active = false; + _ready = true; return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { - m_Ready = false; - m_Active = true; + _ready = false; + _active = true; - m_Red = D3DCOLGetR(SourceColor); - m_Green = D3DCOLGetG(SourceColor); - m_Blue = D3DCOLGetB(SourceColor); + _red = D3DCOLGetR(SourceColor); + _green = D3DCOLGetG(SourceColor); + _blue = D3DCOLGetB(SourceColor); - m_SourceAlpha = D3DCOLGetA(SourceColor); - m_TargetAlpha = 0; + _sourceAlpha = D3DCOLGetA(SourceColor); + _targetAlpha = 0; - m_Duration = Duration; - m_System = System; + _duration = Duration; + _system = System; - if (m_System) m_StartTime = CBPlatform::GetTime(); - else m_StartTime = Game->m_Timer; + if (_system) _startTime = CBPlatform::GetTime(); + else _startTime = Game->_timer; return S_OK; } @@ -124,22 +124,22 @@ HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { - m_Ready = false; - m_Active = true; + _ready = false; + _active = true; - m_Red = D3DCOLGetR(TargetColor); - m_Green = D3DCOLGetG(TargetColor); - m_Blue = D3DCOLGetB(TargetColor); + _red = D3DCOLGetR(TargetColor); + _green = D3DCOLGetG(TargetColor); + _blue = D3DCOLGetB(TargetColor); - //m_SourceAlpha = 0; - m_SourceAlpha = m_CurrentAlpha; - m_TargetAlpha = D3DCOLGetA(TargetColor); + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = D3DCOLGetA(TargetColor); - m_Duration = Duration; - m_System = System; + _duration = Duration; + _system = System; - if (m_System) m_StartTime = CBPlatform::GetTime(); - else m_StartTime = Game->m_Timer; + if (_system) _startTime = CBPlatform::GetTime(); + else _startTime = Game->_timer; return S_OK; @@ -148,7 +148,7 @@ HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { ////////////////////////////////////////////////////////////////////////// uint32 CBFader::GetCurrentColor() { - return DRGBA(m_Red, m_Green, m_Blue, m_CurrentAlpha); + return DRGBA(_red, _green, _blue, _currentAlpha); } @@ -157,18 +157,18 @@ uint32 CBFader::GetCurrentColor() { HRESULT CBFader::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_Blue)); - PersistMgr->Transfer(TMEMBER(m_CurrentAlpha)); - PersistMgr->Transfer(TMEMBER(m_Duration)); - PersistMgr->Transfer(TMEMBER(m_Green)); - PersistMgr->Transfer(TMEMBER(m_Red)); - PersistMgr->Transfer(TMEMBER(m_SourceAlpha)); - PersistMgr->Transfer(TMEMBER(m_StartTime)); - PersistMgr->Transfer(TMEMBER(m_TargetAlpha)); - PersistMgr->Transfer(TMEMBER(m_System)); - - if (m_System && !PersistMgr->m_Saving) m_StartTime = 0; + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_blue)); + PersistMgr->Transfer(TMEMBER(_currentAlpha)); + PersistMgr->Transfer(TMEMBER(_duration)); + PersistMgr->Transfer(TMEMBER(_green)); + PersistMgr->Transfer(TMEMBER(_red)); + PersistMgr->Transfer(TMEMBER(_sourceAlpha)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_targetAlpha)); + PersistMgr->Transfer(TMEMBER(_system)); + + if (_system && !PersistMgr->_saving) _startTime = 0; return S_OK; } diff --git a/engines/wintermute/BFader.h b/engines/wintermute/BFader.h index 44ce256826..38ef8451ab 100644 --- a/engines/wintermute/BFader.h +++ b/engines/wintermute/BFader.h @@ -36,7 +36,7 @@ namespace WinterMute { class CBFader : public CBObject { public: - bool m_System; + bool _system; uint32 GetCurrentColor(); HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); @@ -46,15 +46,15 @@ public: DECLARE_PERSISTENT(CBFader, CBObject) CBFader(CBGame *inGame); virtual ~CBFader(); - bool m_Active; - byte m_Red; - byte m_Green; - byte m_Blue; - byte m_CurrentAlpha; - byte m_TargetAlpha; - byte m_SourceAlpha; - uint32 m_Duration; - uint32 m_StartTime; + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFile.cpp b/engines/wintermute/BFile.cpp index f4d7da2c70..e66990f571 100644 --- a/engines/wintermute/BFile.cpp +++ b/engines/wintermute/BFile.cpp @@ -39,8 +39,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - m_Pos = 0; - m_Size = 0; + _pos = 0; + _size = 0; } @@ -52,7 +52,7 @@ CBFile::~CBFile() { ////////////////////////////////////////////////////////////////////////// bool CBFile::IsEOF() { - return m_Pos == m_Size; + return _pos == _size; } Common::SeekableReadStream *CBFile::getMemStream() { diff --git a/engines/wintermute/BFile.h b/engines/wintermute/BFile.h index db6a29d903..7b077b34b9 100644 --- a/engines/wintermute/BFile.h +++ b/engines/wintermute/BFile.h @@ -41,13 +41,13 @@ namespace WinterMute { class CBFile : public CBBase { public: - uint32 m_Pos; - uint32 m_Size; + uint32 _pos; + uint32 _size; virtual uint32 GetSize() { - return m_Size; + return _size; }; virtual uint32 GetPos() { - return m_Pos; + return _pos; }; virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; virtual HRESULT Read(void *Buffer, uint32 Size) = 0; diff --git a/engines/wintermute/BFileEntry.cpp b/engines/wintermute/BFileEntry.cpp index 18a15e37f9..3b9a9fafa9 100644 --- a/engines/wintermute/BFileEntry.cpp +++ b/engines/wintermute/BFileEntry.cpp @@ -32,19 +32,19 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - m_Package = NULL; - m_Length = m_CompressedLength = m_Offset = m_Flags = 0; - m_Filename = ""; + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; - m_TimeDate1 = m_TimeDate2 = 0; + _timeDate1 = _timeDate2 = 0; - m_JournalTime = 0; + _journalTime = 0; } ////////////////////////////////////////////////////////////////////////// CBFileEntry::~CBFileEntry() { - m_Package = NULL; // ref only + _package = NULL; // ref only } } // end of namespace WinterMute diff --git a/engines/wintermute/BFileEntry.h b/engines/wintermute/BFileEntry.h index 2c555c8bfe..00e82f8640 100644 --- a/engines/wintermute/BFileEntry.h +++ b/engines/wintermute/BFileEntry.h @@ -38,15 +38,15 @@ class CBPackage; class CBFileEntry : public CBBase { public: - uint32 m_TimeDate2; - uint32 m_TimeDate1; - uint32 m_Flags; - uint32 m_JournalTime; - Common::String m_Filename; - uint32 m_CompressedLength; - uint32 m_Length; - uint32 m_Offset; - CBPackage *m_Package; + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; CBFileEntry(CBGame *inGame); virtual ~CBFileEntry(); diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 2e0e296eb0..fa491b62df 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -83,7 +83,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { - m_BasePath = NULL; + _basePath = NULL; InitPaths(); RegisterPackages(); @@ -101,38 +101,38 @@ HRESULT CBFileManager::Cleanup() { int i; // delete registered paths - for (i = 0; i < m_SinglePaths.GetSize(); i++) - delete [] m_SinglePaths[i]; - m_SinglePaths.RemoveAll(); + for (i = 0; i < _singlePaths.GetSize(); i++) + delete [] _singlePaths[i]; + _singlePaths.RemoveAll(); - for (i = 0; i < m_PackagePaths.GetSize(); i++) - delete [] m_PackagePaths[i]; - m_PackagePaths.RemoveAll(); + for (i = 0; i < _packagePaths.GetSize(); i++) + delete [] _packagePaths[i]; + _packagePaths.RemoveAll(); // delete file entries - m_FilesIter = m_Files.begin(); - while (m_FilesIter != m_Files.end()) { - delete m_FilesIter->_value; - m_FilesIter++; + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; } - m_Files.clear(); + _files.clear(); // close open files - for (i = 0; i < m_OpenFiles.GetSize(); i++) { - m_OpenFiles[i]->Close(); - delete m_OpenFiles[i]; + for (i = 0; i < _openFiles.GetSize(); i++) { + _openFiles[i]->Close(); + delete _openFiles[i]; } - m_OpenFiles.RemoveAll(); + _openFiles.RemoveAll(); // delete packages - for (i = 0; i < m_Packages.GetSize(); i++) - delete m_Packages[i]; - m_Packages.RemoveAll(); + for (i = 0; i < _packages.GetSize(); i++) + delete _packages[i]; + _packages.RemoveAll(); - delete[] m_BasePath; - m_BasePath = NULL; + delete[] _basePath; + _basePath = NULL; return S_OK; } @@ -241,8 +241,8 @@ HRESULT CBFileManager::SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { // unmount all non-local packages - for (int i = 0; i < m_Packages.GetSize(); i++) { - if (m_Packages[i]->m_CD > 0) m_Packages[i]->Close(); + for (int i = 0; i < _packages.GetSize(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->Close(); } @@ -265,10 +265,10 @@ HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { switch (Type) { case PATH_SINGLE: - m_SinglePaths.Add(buffer); + _singlePaths.Add(buffer); break; case PATH_PACKAGE: - m_PackagePaths.Add(buffer); + _packagePaths.Add(buffer); break; } @@ -278,13 +278,13 @@ HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::ReloadPaths() { // delete registered paths - for (int i = 0; i < m_SinglePaths.GetSize(); i++) - delete [] m_SinglePaths[i]; - m_SinglePaths.RemoveAll(); + for (int i = 0; i < _singlePaths.GetSize(); i++) + delete [] _singlePaths[i]; + _singlePaths.RemoveAll(); - for (int i = 0; i < m_PackagePaths.GetSize(); i++) - delete [] m_PackagePaths[i]; - m_PackagePaths.RemoveAll(); + for (int i = 0; i < _packagePaths.GetSize(); i++) + delete [] _packagePaths[i]; + _packagePaths.RemoveAll(); return InitPaths(); } @@ -299,7 +299,7 @@ HRESULT CBFileManager::InitPaths() { int numPaths; // single files paths - pathList = Game->m_Registry->ReadString("Resource", "CustomPaths", ""); + pathList = Game->_registry->ReadString("Resource", "CustomPaths", ""); numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { @@ -343,7 +343,7 @@ HRESULT CBFileManager::InitPaths() { #endif - pathList = Game->m_Registry->ReadString("Resource", "PackagePaths", ""); + pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { @@ -373,8 +373,8 @@ HRESULT CBFileManager::RegisterPackages() { #if 0 AnsiString extension = AnsiString(".") + AnsiString(PACKAGE_EXTENSION); - for (int i = 0; i < m_PackagePaths.GetSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::system_complete(m_PackagePaths[i]); + for (int i = 0; i < _packagePaths.GetSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); //printf("Scanning: %s\n", absPath.string().c_str()); @@ -398,10 +398,10 @@ HRESULT CBFileManager::RegisterPackages() { } } - warning(" Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); - Game->LOG(0, " Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); + warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); + Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); #endif - warning(" Registered %d files in %d package(s)", m_Files.size(), m_Packages.GetSize()); + warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); return S_OK; } @@ -455,17 +455,17 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign CBPackage *pkg = new CBPackage(Game); if (!pkg) return E_FAIL; - pkg->m_BoundToExe = BoundToExe; + pkg->_boundToExe = BoundToExe; // read package info byte NameLength = package->readByte(); - pkg->m_Name = new char[NameLength]; - package->read(pkg->m_Name, NameLength); - pkg->m_CD = package->readByte(); - pkg->m_Priority = hdr.Priority; + pkg->_name = new char[NameLength]; + package->read(pkg->_name, NameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; - if (!hdr.MasterIndex) pkg->m_CD = 0; // override CD to fixed disk - m_Packages.Add(pkg); + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.Add(pkg); // read file entries @@ -503,24 +503,24 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign TimeDate1 = package->readUint32LE(); TimeDate2 = package->readUint32LE(); } - m_FilesIter = m_Files.find(Name); - if (m_FilesIter == m_Files.end()) { + _filesIter = _files.find(Name); + if (_filesIter == _files.end()) { CBFileEntry *file = new CBFileEntry(Game); - file->m_Package = pkg; - file->m_Offset = Offset; - file->m_Length = Length; - file->m_CompressedLength = CompLength; - file->m_Flags = Flags; + file->_package = pkg; + file->_offset = Offset; + file->_length = Length; + file->_compressedLength = CompLength; + file->_flags = Flags; - m_Files[Name] = file; + _files[Name] = file; } else { // current package has lower CD number or higher priority, than the registered - if (pkg->m_CD < m_FilesIter->_value->m_Package->m_CD || pkg->m_Priority > m_FilesIter->_value->m_Package->m_Priority) { - m_FilesIter->_value->m_Package = pkg; - m_FilesIter->_value->m_Offset = Offset; - m_FilesIter->_value->m_Length = Length; - m_FilesIter->_value->m_CompressedLength = CompLength; - m_FilesIter->_value->m_Flags = Flags; + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = Offset; + _filesIter->_value->_length = Length; + _filesIter->_value->_compressedLength = CompLength; + _filesIter->_value->_flags = Flags; } } delete [] Name; @@ -584,18 +584,18 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool CBPackage *pkg = new CBPackage(Game); if (!pkg) return E_FAIL; - pkg->m_BoundToExe = BoundToExe; + pkg->_boundToExe = BoundToExe; // read package info byte NameLength; fread(&NameLength, sizeof(byte ), 1, f); - pkg->m_Name = new char[NameLength]; - fread(pkg->m_Name, NameLength, 1, f); - fread(&pkg->m_CD, sizeof(byte ), 1, f); - pkg->m_Priority = hdr.Priority; + pkg->_name = new char[NameLength]; + fread(pkg->_name, NameLength, 1, f); + fread(&pkg->_cD, sizeof(byte ), 1, f); + pkg->_priority = hdr.Priority; - if (!hdr.MasterIndex) pkg->m_CD = 0; // override CD to fixed disk - m_Packages.Add(pkg); + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.Add(pkg); // read file entries @@ -634,24 +634,24 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool fread(&TimeDate1, sizeof(uint32), 1, f); fread(&TimeDate2, sizeof(uint32), 1, f); } - m_FilesIter = m_Files.find(Name); - if (m_FilesIter == m_Files.end()) { + _filesIter = _files.find(Name); + if (_filesIter == _files.end()) { CBFileEntry *file = new CBFileEntry(Game); - file->m_Package = pkg; - file->m_Offset = Offset; - file->m_Length = Length; - file->m_CompressedLength = CompLength; - file->m_Flags = Flags; + file->_package = pkg; + file->_offset = Offset; + file->_length = Length; + file->_compressedLength = CompLength; + file->_flags = Flags; - m_Files[Name] = file; + _files[Name] = file; } else { // current package has lower CD number or higher priority, than the registered - if (pkg->m_CD < m_FilesIter->_value->m_Package->m_CD || pkg->m_Priority > m_FilesIter->_value->m_Package->m_Priority) { - m_FilesIter->_value->m_Package = pkg; - m_FilesIter->_value->m_Offset = Offset; - m_FilesIter->_value->m_Length = Length; - m_FilesIter->_value->m_CompressedLength = CompLength; - m_FilesIter->_value->m_Flags = Flags; + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = Offset; + _filesIter->_value->_length = Length; + _filesIter->_value->_compressedLength = CompLength; + _filesIter->_value->_flags = Flags; } } delete [] Name; @@ -685,8 +685,8 @@ Common::File *CBFileManager::OpenPackage(char *Name) { Common::File *ret = new Common::File(); char Filename[MAX_PATH]; - for (int i = 0; i < m_PackagePaths.GetSize(); i++) { - sprintf(Filename, "%s%s.%s", m_PackagePaths[i], Name, PACKAGE_EXTENSION); + for (int i = 0; i < _packagePaths.GetSize(); i++) { + sprintf(Filename, "%s%s.%s", _packagePaths[i], Name, PACKAGE_EXTENSION); //ret = fopen(Filename, "rb"); ret->open(Filename); if (ret->isOpen()) { @@ -705,8 +705,8 @@ Common::File *CBFileManager::OpenSingleFile(char *Name) { Common::File *ret = NULL; char Filename[MAX_PATH]; - for (int i = 0; i < m_SinglePaths.GetSize(); i++) { - sprintf(Filename, "%s%s", m_SinglePaths[i], Name); + for (int i = 0; i < _singlePaths.GetSize(); i++) { + sprintf(Filename, "%s%s", _singlePaths[i], Name); ret->open(Filename); if (ret->isOpen()) return ret; @@ -730,8 +730,8 @@ bool CBFileManager::GetFullPath(char *Filename, char *Fullname) { FILE *f = NULL; bool found = false; - for (int i = 0; i < m_SinglePaths.GetSize(); i++) { - sprintf(Fullname, "%s%s", m_SinglePaths[i], Filename); + for (int i = 0; i < _singlePaths.GetSize(); i++) { + sprintf(Fullname, "%s%s", _singlePaths[i], Filename); f = fopen(Fullname, "rb"); if (f) { fclose(f); @@ -760,8 +760,8 @@ CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { CBPlatform::strupr(upc_name); CBFileEntry *ret = NULL; - m_FilesIter = m_Files.find(upc_name); - if (m_FilesIter != m_Files.end()) ret = m_FilesIter->_value; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; delete [] upc_name; @@ -774,7 +774,7 @@ CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { if (strcmp(Filename, "") == 0) return NULL; //Game->LOG(0, "open file: %s", Filename); #ifdef __WIN32__ - if (Game->m_DEBUG_DebugMode && Game->m_DEBUG_AbsolutePathWarning && AbsPathWarning) { + if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { char Drive[_MAX_DRIVE]; _splitpath(Filename, Drive, NULL, NULL, NULL); if (Drive[0] != '\0') { @@ -784,18 +784,18 @@ CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { #endif CBFile *File = OpenFileRaw(Filename); - if (File) m_OpenFiles.Add(File); + if (File) _openFiles.Add(File); return File; } ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::CloseFile(CBFile *File) { - for (int i = 0; i < m_OpenFiles.GetSize(); i++) { - if (m_OpenFiles[i] == File) { - m_OpenFiles[i]->Close(); - delete m_OpenFiles[i]; - m_OpenFiles.RemoveAt(i); + for (int i = 0; i < _openFiles.GetSize(); i++) { + if (_openFiles[i] == File) { + _openFiles[i]->Close(); + delete _openFiles[i]; + _openFiles.RemoveAt(i); return S_OK; } } @@ -837,9 +837,9 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::RestoreCurrentDir() { - if (!m_BasePath) return S_OK; + if (!_basePath) return S_OK; else { - if (!chdir(m_BasePath)) return S_OK; + if (!chdir(_basePath)) return S_OK; else return E_FAIL; } } @@ -850,8 +850,8 @@ HRESULT CBFileManager::SetBasePath(char *Path) { Cleanup(); if (Path) { - m_BasePath = new char[strlen(Path) + 1]; - strcpy(m_BasePath, Path); + _basePath = new char[strlen(Path) + 1]; + strcpy(_basePath, Path); } InitPaths(); diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index bee43e696d..81b22ffef9 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -47,7 +47,7 @@ public: HRESULT Cleanup(); HRESULT SetBasePath(char *Path); HRESULT RestoreCurrentDir(); - char *m_BasePath; + char *_basePath; bool GetFullPath(char *Filename, char *Fullname); CBFile *OpenFileRaw(const char *Filename); HRESULT CloseFile(CBFile *File); @@ -67,16 +67,16 @@ public: byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); - CBArray m_SinglePaths; - CBArray m_PackagePaths; - CBArray m_Packages; - CBArray m_OpenFiles; + CBArray _singlePaths; + CBArray _packagePaths; + CBArray _packages; + CBArray _openFiles; - Common::HashMap m_Files; + Common::HashMap _files; private: HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); HRESULT RegisterPackage(Common::String Filename, bool SearchSignature = false); - Common::HashMap::iterator m_FilesIter; + Common::HashMap::iterator _filesIter; bool IsValidPackage(const AnsiString &fileName) const; }; diff --git a/engines/wintermute/BFont.cpp b/engines/wintermute/BFont.cpp index 93d870875d..92ce8595ae 100644 --- a/engines/wintermute/BFont.cpp +++ b/engines/wintermute/BFont.cpp @@ -73,7 +73,7 @@ int CBFont::GetTextWidth(byte *text, int MaxLenght) { ////////////////////////////////////////////////////////////////////// HRESULT CBFont::LoadFile(char * Filename) { - BYTE* Buffer = Game->m_FileManager->ReadWholeFile(Filename); + BYTE* Buffer = Game->_fileManager->ReadWholeFile(Filename); if(Buffer==NULL){ Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -81,8 +81,8 @@ HRESULT CBFont::LoadFile(char * Filename) HRESULT ret; - m_Filename = new char [strlen(Filename)+1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename)+1]; + strcpy(_filename, Filename); if(FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); @@ -122,7 +122,7 @@ HRESULT CBFont::LoadBuffer(byte * Buffer) case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custom_trans = true; + custo_trans = true; break; } @@ -187,7 +187,7 @@ bool CBFont::IsTrueType(CBGame *Game, char *Filename) { TOKEN_TABLE_END - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) return false; byte *WorkBuffer = Buffer; diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 9b49a84079..3bec9d5a20 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -49,23 +49,23 @@ IMPLEMENT_PERSISTENT(CBFontBitmap, false) ////////////////////////////////////////////////////////////////////// CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - m_Subframe = NULL; - m_Sprite = NULL; - m_WidthsFrame = 0; - memset(m_Widths, 0, NUM_CHARACTERS); - m_TileWidth = m_TileHeight = m_NumColumns = 0; - m_FontextFix = false; - m_Freezable = false; - m_WholeCell = false; + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; } ////////////////////////////////////////////////////////////////////// CBFontBitmap::~CBFontBitmap() { - delete m_Subframe; - delete m_Sprite; - m_Subframe = NULL; - m_Sprite = NULL; + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; } @@ -85,7 +85,7 @@ int CBFontBitmap::GetTextHeight(byte *text, int width) { int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { AnsiString str; - if (Game->m_TextEncoding == TEXT_UTF8) { + if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); str = StringUtil::WideToAnsi(wstr); } else { @@ -109,13 +109,13 @@ int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { if (MaxLenght == 0) return 0; - if (text == NULL || text[0] == '\0') return m_TileHeight; + if (text == NULL || text[0] == '\0') return _tileHeight; AnsiString str; - if (Game->m_TextEncoding == TEXT_UTF8) { + if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); str = StringUtil::WideToAnsi(wstr); } else { @@ -138,17 +138,17 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig bool new_line = false; bool long_line = false; - if (draw) Game->m_Renderer->StartSpriteBatch(); + if (draw) Game->_renderer->StartSpriteBatch(); while (!done) { - if (max_height > 0 && (NumLines + 1)*m_TileHeight > max_height) { - if (draw) Game->m_Renderer->EndSpriteBatch(); - return NumLines * m_TileHeight; + if (max_height > 0 && (NumLines + 1)*_tileHeight > max_height) { + if (draw) Game->_renderer->EndSpriteBatch(); + return NumLines * _tileHeight; } index++; - if (str[index] == ' ' && (max_height < 0 || max_height / m_TileHeight > 1)) { + if (str[index] == ' ' && (max_height < 0 || max_height / _tileHeight > 1)) { end = index - 1; RealLength = LineLength; } @@ -193,7 +193,7 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig if (draw) DrawChar(str[i], StartX, y); StartX += GetCharWidth(str[i]); } - y += m_TileHeight; + y += _tileHeight; last_end = end; if (long_line) end--; start = end + 2; @@ -205,45 +205,45 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig } } - if (draw) Game->m_Renderer->EndSpriteBatch(); + if (draw) Game->_renderer->EndSpriteBatch(); - return NumLines * m_TileHeight; + return NumLines * _tileHeight; } ////////////////////////////////////////////////////////////////////// void CBFontBitmap::DrawChar(byte c, int x, int y) { - if (m_FontextFix) c--; + if (_fontextFix) c--; int row, col; - row = c / m_NumColumns; - col = c % m_NumColumns; + row = c / _numColumns; + col = c % _numColumns; RECT rect; /* l t r b */ int TileWidth; - if (m_WholeCell) TileWidth = m_TileWidth; - else TileWidth = m_Widths[c]; + if (_wholeCell) TileWidth = _tileWidth; + else TileWidth = _widths[c]; - CBPlatform::SetRect(&rect, col * m_TileWidth, row * m_TileHeight, col * m_TileWidth + TileWidth, (row + 1)*m_TileHeight); + CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + TileWidth, (row + 1)*_tileHeight); bool Handled = false; - if (m_Sprite) { - m_Sprite->GetCurrentFrame(); - if (m_Sprite->m_CurrentFrame >= 0 && m_Sprite->m_CurrentFrame < m_Sprite->m_Frames.GetSize() && m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]) { - if (m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]->m_Subframes.GetSize() > 0) { - m_Sprite->m_Frames[m_Sprite->m_CurrentFrame]->m_Subframes[0]->m_Surface->DisplayTrans(x, y, rect); + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->DisplayTrans(x, y, rect); } Handled = true; } } - if (!Handled && m_Subframe) m_Subframe->m_Surface->DisplayTrans(x, y, rect); + if (!Handled && _subframe) _subframe->_surface->DisplayTrans(x, y, rect); } ////////////////////////////////////////////////////////////////////// HRESULT CBFontBitmap::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -251,8 +251,8 @@ HRESULT CBFontBitmap::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); @@ -316,7 +316,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { int last_width = 0; int i; int r = 255, g = 255, b = 255; - bool custom_trans = false; + bool custo_trans = false; char *surface_file = NULL; char *sprite_file = NULL; @@ -337,13 +337,13 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custom_trans = true; + custo_trans = true; break; case TOKEN_WIDTHS: parser.ScanStr(params, "%D", widths, &num); for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { - m_Widths[last_width] = (byte )widths[i]; + _widths[last_width] = (byte )widths[i]; } break; @@ -352,19 +352,19 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { break; case TOKEN_WIDTHS_FRAME: - parser.ScanStr(params, "%d", &m_WidthsFrame); + parser.ScanStr(params, "%d", &_widthsFrame); break; case TOKEN_COLUMNS: - parser.ScanStr(params, "%d", &m_NumColumns); + parser.ScanStr(params, "%d", &_numColumns); break; case TOKEN_TILE_WIDTH: - parser.ScanStr(params, "%d", &m_TileWidth); + parser.ScanStr(params, "%d", &_tileWidth); break; case TOKEN_TILE_HEIGHT: - parser.ScanStr(params, "%d", &m_TileHeight); + parser.ScanStr(params, "%d", &_tileHeight); break; case TOKEN_AUTO_WIDTH: @@ -372,11 +372,11 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { break; case TOKEN_FONTEXT_FIX: - parser.ScanStr(params, "%b", &m_FontextFix); + parser.ScanStr(params, "%b", &_fontextFix); break; case TOKEN_PAINT_WHOLE_CELL: - parser.ScanStr(params, "%b", &m_WholeCell); + parser.ScanStr(params, "%b", &_wholeCell); break; case TOKEN_SPACE_WIDTH: @@ -399,19 +399,19 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { } if (sprite_file != NULL) { - delete m_Sprite; - m_Sprite = new CBSprite(Game, this); - if (!m_Sprite || FAILED(m_Sprite->LoadFile(sprite_file))) SAFE_DELETE(m_Sprite); + delete _sprite; + _sprite = new CBSprite(Game, this); + if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) SAFE_DELETE(_sprite); } - if (surface_file != NULL && !m_Sprite) { - m_Subframe = new CBSubFrame(Game); - if (custom_trans) m_Subframe->SetSurface(surface_file, false, r, g, b); - else m_Subframe->SetSurface(surface_file); + if (surface_file != NULL && !_sprite) { + _subframe = new CBSubFrame(Game); + if (custo_trans) _subframe->SetSurface(surface_file, false, r, g, b); + else _subframe->SetSurface(surface_file); } - if (((m_Subframe == NULL || m_Subframe->m_Surface == NULL) && m_Sprite == NULL) || m_NumColumns == 0 || m_TileWidth == 0 || m_TileHeight == 0) { + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { Game->LOG(0, "Incomplete font definition"); return E_FAIL; } @@ -423,25 +423,25 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { // do we need to modify widths? if (ExpandWidth != 0) { for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)m_Widths[i] + ExpandWidth; + int NewWidth = (int)_widths[i] + ExpandWidth; if (NewWidth < 0) NewWidth = 0; - m_Widths[i] = (byte )NewWidth; + _widths[i] = (byte )NewWidth; } } // handle space character char SpaceChar = ' '; - if (m_FontextFix) SpaceChar--; + if (_fontextFix) SpaceChar--; - if (SpaceWidth != 0) m_Widths[SpaceChar] = SpaceWidth; + if (SpaceWidth != 0) _widths[SpaceChar] = SpaceWidth; else { - if (m_Widths[SpaceChar] == ExpandWidth || m_Widths[SpaceChar] == 0) { - m_Widths[SpaceChar] = (m_Widths['m'] + m_Widths['i']) / 2; + if (_widths[SpaceChar] == ExpandWidth || _widths[SpaceChar] == 0) { + _widths[SpaceChar] = (_widths['m'] + _widths['i']) / 2; } } } else { - for (i = last_width; i < NUM_CHARACTERS; i++) m_Widths[i] = default_width; + for (i = last_width; i < NUM_CHARACTERS; i++) _widths[i] = default_width; } @@ -453,22 +453,22 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { CBFont::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_NumColumns)); + PersistMgr->Transfer(TMEMBER(_numColumns)); - PersistMgr->Transfer(TMEMBER(m_Subframe)); - PersistMgr->Transfer(TMEMBER(m_TileHeight)); - PersistMgr->Transfer(TMEMBER(m_TileWidth)); - PersistMgr->Transfer(TMEMBER(m_Sprite)); - PersistMgr->Transfer(TMEMBER(m_WidthsFrame)); + PersistMgr->Transfer(TMEMBER(_subframe)); + PersistMgr->Transfer(TMEMBER(_tileHeight)); + PersistMgr->Transfer(TMEMBER(_tileWidth)); + PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER(_widthsFrame)); - if (PersistMgr->m_Saving) - PersistMgr->PutBytes(m_Widths, sizeof(m_Widths)); + if (PersistMgr->_saving) + PersistMgr->PutBytes(_widths, sizeof(_widths)); else - PersistMgr->GetBytes(m_Widths, sizeof(m_Widths)); + PersistMgr->GetBytes(_widths, sizeof(_widths)); - PersistMgr->Transfer(TMEMBER(m_FontextFix)); - PersistMgr->Transfer(TMEMBER(m_WholeCell)); + PersistMgr->Transfer(TMEMBER(_fontextFix)); + PersistMgr->Transfer(TMEMBER(_wholeCell)); return S_OK; @@ -477,8 +477,8 @@ HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// int CBFontBitmap::GetCharWidth(byte Index) { - if (m_FontextFix) Index--; - return m_Widths[Index]; + if (_fontextFix) Index--; + return _widths[Index]; } @@ -486,25 +486,25 @@ int CBFontBitmap::GetCharWidth(byte Index) { HRESULT CBFontBitmap::GetWidths() { CBSurface *surf = NULL; - if (m_Sprite) { - if (m_WidthsFrame >= 0 && m_WidthsFrame < m_Sprite->m_Frames.GetSize()) { - if (m_Sprite->m_Frames[m_WidthsFrame] && m_Sprite->m_Frames[m_WidthsFrame]->m_Subframes.GetSize() > 0) { - surf = m_Sprite->m_Frames[m_WidthsFrame]->m_Subframes[0]->m_Surface; + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.GetSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.GetSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; } } } - if (surf == NULL && m_Subframe) surf = m_Subframe->m_Surface; + if (surf == NULL && _subframe) surf = _subframe->_surface; if (!surf || FAILED(surf->StartPixelOp())) return E_FAIL; for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % m_NumColumns) * m_TileWidth; - int yyy = (i / m_NumColumns) * m_TileHeight; + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; int min_col = -1; - for (int row = 0; row < m_TileHeight; row++) { - for (int col = m_TileWidth - 1; col >= min_col + 1; col--) { + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= min_col + 1; col--) { if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; @@ -512,17 +512,17 @@ HRESULT CBFontBitmap::GetWidths() { break; } } - if (min_col == m_TileWidth - 1) break; + if (min_col == _tileWidth - 1) break; } - m_Widths[i] = min_col + 1; + _widths[i] = min_col + 1; } surf->EndPixelOp(); /* - Game->LOG(0, "----- %s ------", m_Filename); + Game->LOG(0, "----- %s ------", _filename); for(int j=0; j<16; j++) { - Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", m_Widths[j*16+0], m_Widths[j*16+1], m_Widths[j*16+2], m_Widths[j*16+3], m_Widths[j*16+4], m_Widths[j*16+5], m_Widths[j*16+6], m_Widths[j*16+7], m_Widths[j*16+8], m_Widths[j*16+9], m_Widths[j*16+10], m_Widths[j*16+11], m_Widths[j*16+12], m_Widths[j*16+13], m_Widths[j*16+14], m_Widths[j*16+15]); + Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); } */ return S_OK; @@ -530,7 +530,7 @@ HRESULT CBFontBitmap::GetWidths() { ////////////////////////////////////////////////////////////////////////// int CBFontBitmap::GetLetterHeight() { - return m_TileHeight; + return _tileHeight; } } // end of namespace WinterMute diff --git a/engines/wintermute/BFontBitmap.h b/engines/wintermute/BFontBitmap.h index c56c192e63..b194674b7c 100644 --- a/engines/wintermute/BFontBitmap.h +++ b/engines/wintermute/BFontBitmap.h @@ -49,15 +49,15 @@ public: HRESULT GetWidths(); - CBSprite *m_Sprite; - int m_WidthsFrame; - bool m_FontextFix; - int m_NumColumns; - int m_TileHeight; - int m_TileWidth; - byte m_Widths[NUM_CHARACTERS]; - CBSubFrame *m_Subframe; - bool m_WholeCell; + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; private: int GetCharWidth(byte Index); diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp index cb14714550..1ceb77cb1c 100644 --- a/engines/wintermute/BFontStorage.cpp +++ b/engines/wintermute/BFontStorage.cpp @@ -43,7 +43,7 @@ IMPLEMENT_PERSISTENT(CBFontStorage, true) ////////////////////////////////////////////////////////////////////////// CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { - m_FTLibrary = NULL; + _fTLibrary = NULL; InitFreeType(); } @@ -56,7 +56,7 @@ CBFontStorage::~CBFontStorage() { ////////////////////////////////////////////////////////////////////////// void CBFontStorage::InitFreeType() { - FT_Error error = FT_Init_FreeType(&m_FTLibrary); + FT_Error error = FT_Init_FreeType(&_fTLibrary); if (error) { Game->LOG(0, "Error initializing FreeType library."); } @@ -66,14 +66,14 @@ void CBFontStorage::InitFreeType() { HRESULT CBFontStorage::Cleanup(bool Warn) { int i; - for (i = 0; i < m_Fonts.GetSize(); i++) { - if (Warn) Game->LOG(0, "Removing orphan font '%s'", m_Fonts[i]->m_Filename); - delete m_Fonts[i]; + for (i = 0; i < _fonts.GetSize(); i++) { + if (Warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; } - m_Fonts.RemoveAll(); + _fonts.RemoveAll(); - if (m_FTLibrary) FT_Done_FreeType(m_FTLibrary); + if (_fTLibrary) FT_Done_FreeType(_fTLibrary); return S_OK; @@ -81,8 +81,8 @@ HRESULT CBFontStorage::Cleanup(bool Warn) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontStorage::InitLoop() { - for (int i = 0; i < m_Fonts.GetSize(); i++) { - m_Fonts[i]->InitLoop(); + for (int i = 0; i < _fonts.GetSize(); i++) { + _fonts[i]->InitLoop(); } return S_OK; } @@ -91,10 +91,10 @@ HRESULT CBFontStorage::InitLoop() { CBFont *CBFontStorage::AddFont(char *Filename) { if (!Filename) return NULL; - for (int i = 0; i < m_Fonts.GetSize(); i++) { - if (scumm_stricmp(m_Fonts[i]->m_Filename, Filename) == 0) { - m_Fonts[i]->m_RefCount++; - return m_Fonts[i]; + for (int i = 0; i < _fonts.GetSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, Filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; } } @@ -107,15 +107,15 @@ CBFont *CBFontStorage::AddFont(char *Filename) { return NULL; } else { - font->m_RefCount = 1; - m_Fonts.Add(font); + font->_refCount = 1; + _fonts.Add(font); return font; } */ CBFont *font = CBFont::CreateFromFile(Game, Filename); if (font) { - font->m_RefCount = 1; - m_Fonts.Add(font); + font->_refCount = 1; + _fonts.Add(font); } return font; } @@ -125,12 +125,12 @@ CBFont *CBFontStorage::AddFont(char *Filename) { HRESULT CBFontStorage::RemoveFont(CBFont *Font) { if (!Font) return E_FAIL; - for (int i = 0; i < m_Fonts.GetSize(); i++) { - if (m_Fonts[i] == Font) { - m_Fonts[i]->m_RefCount--; - if (m_Fonts[i]->m_RefCount <= 0) { - delete m_Fonts[i]; - m_Fonts.RemoveAt(i); + for (int i = 0; i < _fonts.GetSize(); i++) { + if (_fonts[i] == Font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.RemoveAt(i); } break; } @@ -142,12 +142,12 @@ HRESULT CBFontStorage::RemoveFont(CBFont *Font) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontStorage::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->m_Saving) Cleanup(false); + if (!PersistMgr->_saving) Cleanup(false); PersistMgr->Transfer(TMEMBER(Game)); - m_Fonts.Persist(PersistMgr); + _fonts.Persist(PersistMgr); - if (!PersistMgr->m_Saving) InitFreeType(); + if (!PersistMgr->_saving) InitFreeType(); return S_OK; } diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h index 6dc2273022..010d0a83c2 100644 --- a/engines/wintermute/BFontStorage.h +++ b/engines/wintermute/BFontStorage.h @@ -49,16 +49,16 @@ public: CBFont *AddFont(char *Filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); - CBArray m_Fonts; + CBArray _fonts; HRESULT InitLoop(); FT_Library GetFTLibrary() const { - return m_FTLibrary; + return _fTLibrary; } private: void InitFreeType(); - FT_Library m_FTLibrary; + FT_Library _fTLibrary; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 398d3bb1d9..5e4370d69f 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -49,45 +49,45 @@ IMPLEMENT_PERSISTENT(CBFontTT, false) ////////////////////////////////////////////////////////////////////////// CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - m_FontHeight = 12; - m_IsBold = m_IsItalic = m_IsUnderline = m_IsStriked = false; + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; - m_FontFile = NULL; + _fontFile = NULL; - for (int i = 0; i < NUM_CACHED_TEXTS; i++) m_CachedTexts[i] = NULL; + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - m_FTFace = NULL; - m_FTStream = NULL; + _fTFace = NULL; + _fTStream = NULL; - m_GlyphCache = NULL; + _glyphCache = NULL; - m_Ascender = m_Descender = m_LineHeight = m_PointSize = m_UnderlinePos = 0; - m_HorDpi = m_VertDpi = 0; - m_MaxCharWidth = m_MaxCharHeight = 0; + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; } ////////////////////////////////////////////////////////////////////////// CBFontTT::~CBFontTT(void) { ClearCache(); - for (int i = 0; i < m_Layers.GetSize(); i++) { - delete m_Layers[i]; + for (int i = 0; i < _layers.GetSize(); i++) { + delete _layers[i]; } - m_Layers.RemoveAll(); + _layers.RemoveAll(); - delete[] m_FontFile; - m_FontFile = NULL; + delete[] _fontFile; + _fontFile = NULL; - delete m_GlyphCache; - m_GlyphCache = NULL; + delete _glyphCache; + _glyphCache = NULL; - if (m_FTFace) { - FT_Done_Face(m_FTFace); - m_FTFace = NULL; + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; } - delete[] m_FTStream; - m_FTStream = NULL; + delete[] _fTStream; + _fTStream = NULL; } @@ -95,8 +95,8 @@ CBFontTT::~CBFontTT(void) { ////////////////////////////////////////////////////////////////////////// void CBFontTT::ClearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (m_CachedTexts[i]) delete m_CachedTexts[i]; - m_CachedTexts[i] = NULL; + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; } } @@ -104,15 +104,15 @@ void CBFontTT::ClearCache() { ////////////////////////////////////////////////////////////////////////// void CBFontTT::InitLoop() { // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (Game->m_ConstrainedMemory) { + if (Game->_constrainedMemory) { // purge all cached images not used in the last frame for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (m_CachedTexts[i] == NULL) continue; + if (_cachedTexts[i] == NULL) continue; - if (!m_CachedTexts[i]->m_Marked) { - delete m_CachedTexts[i]; - m_CachedTexts[i] = NULL; - } else m_CachedTexts[i]->m_Marked = false; + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; } } } @@ -121,7 +121,7 @@ void CBFontTT::InitLoop() { int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { WideString text; - if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text); if (MaxLength >= 0 && text.size() > MaxLength) @@ -138,7 +138,7 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { int CBFontTT::GetTextHeight(byte *Text, int Width) { WideString text; - if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text); @@ -155,14 +155,14 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, WideString text; - if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text); if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); //text = text.substr(0, MaxLength); // TODO: Remove - CBRenderSDL *m_Renderer = (CBRenderSDL *)Game->m_Renderer; + CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; // find cached surface, if exists int MinPriority = INT_MAX; @@ -171,19 +171,19 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int textOffset = 0; for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (m_CachedTexts[i] == NULL) { + if (_cachedTexts[i] == NULL) { MinPriority = 0; MinIndex = i; } else { - if (m_CachedTexts[i]->m_Text == text && m_CachedTexts[i]->m_Align == Align && m_CachedTexts[i]->m_Width == Width && m_CachedTexts[i]->m_MaxHeight == MaxHeight && m_CachedTexts[i]->m_MaxLength == MaxLength) { - Surface = m_CachedTexts[i]->m_Surface; - textOffset = m_CachedTexts[i]->m_TextOffset; - m_CachedTexts[i]->m_Priority++; - m_CachedTexts[i]->m_Marked = true; + if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == Align && _cachedTexts[i]->_width == Width && _cachedTexts[i]->_maxHeight == MaxHeight && _cachedTexts[i]->_maxLength == MaxLength) { + Surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; break; } else { - if (m_CachedTexts[i]->m_Priority < MinPriority) { - MinPriority = m_CachedTexts[i]->m_Priority; + if (_cachedTexts[i]->_priority < MinPriority) { + MinPriority = _cachedTexts[i]->_priority; MinIndex = i; } } @@ -195,18 +195,18 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); if (Surface) { // write surface to cache - if (m_CachedTexts[MinIndex] != NULL) delete m_CachedTexts[MinIndex]; - m_CachedTexts[MinIndex] = new CBCachedTTFontText; - - m_CachedTexts[MinIndex]->m_Surface = Surface; - m_CachedTexts[MinIndex]->m_Align = Align; - m_CachedTexts[MinIndex]->m_Width = Width; - m_CachedTexts[MinIndex]->m_MaxHeight = MaxHeight; - m_CachedTexts[MinIndex]->m_MaxLength = MaxLength; - m_CachedTexts[MinIndex]->m_Priority = 1; - m_CachedTexts[MinIndex]->m_Text = text; - m_CachedTexts[MinIndex]->m_TextOffset = textOffset; - m_CachedTexts[MinIndex]->m_Marked = true; + if (_cachedTexts[MinIndex] != NULL) delete _cachedTexts[MinIndex]; + _cachedTexts[MinIndex] = new CBCachedTTFontText; + + _cachedTexts[MinIndex]->_surface = Surface; + _cachedTexts[MinIndex]->_align = Align; + _cachedTexts[MinIndex]->_width = Width; + _cachedTexts[MinIndex]->_maxHeight = MaxHeight; + _cachedTexts[MinIndex]->_maxLength = MaxLength; + _cachedTexts[MinIndex]->_priority = 1; + _cachedTexts[MinIndex]->_text = text; + _cachedTexts[MinIndex]->_textOffset = textOffset; + _cachedTexts[MinIndex]->_marked = true; } } @@ -215,16 +215,16 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, if (Surface) { RECT rc; CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight()); - for (int i = 0; i < m_Layers.GetSize(); i++) { - uint32 Color = m_Layers[i]->m_Color; - uint32 OrigForceAlpha = m_Renderer->m_ForceAlphaColor; - if (m_Renderer->m_ForceAlphaColor != 0) { - Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(m_Renderer->m_ForceAlphaColor)); - m_Renderer->m_ForceAlphaColor = 0; + for (int i = 0; i < _layers.GetSize(); i++) { + uint32 Color = _layers[i]->_color; + uint32 OrigForceAlpha = _renderer->_forceAlphaColor; + if (_renderer->_forceAlphaColor != 0) { + Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(_renderer->_forceAlphaColor)); + _renderer->_forceAlphaColor = 0; } - Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, m_Layers[i]->m_OffsetX, m_Layers[i]->m_OffsetY); + Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - m_Renderer->m_ForceAlphaColor = OrigForceAlpha; + _renderer->_forceAlphaColor = OrigForceAlpha; } } @@ -239,12 +239,12 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex TextLineList::iterator it; - int textHeight = lines.size() * (m_MaxCharHeight + m_Ascender); + int textHeight = lines.size() * (_maxCharHeight + _ascender); SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); SDL_LockSurface(surface); - int posY = (int)GetLineHeight() - (int)m_Descender; + int posY = (int)GetLineHeight() - (int)_descender; for (it = lines.begin(); it != lines.end(); ++it) { TextLine *line = (*it); @@ -265,7 +265,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex for (size_t i = 0; i < line->GetText().size(); i++) { wchar_t ch = line->GetText()[i]; - GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); if (!glyph) continue; textOffset = std::max(textOffset, glyph->GetBearingY()); @@ -278,7 +278,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex for (size_t i = 0; i < line->GetText().size(); i++) { wchar_t ch = line->GetText()[i]; - GlyphInfo *glyph = m_GlyphCache->GetGlyph(ch); + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); if (!glyph) continue; float kerning = 0; @@ -303,9 +303,9 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex posY += (int)(glyph->GetAdvanceY()); } - if (m_IsUnderline) { + if (_isUnderline) { for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(m_UnderlinePos + m_Ascender) * surface->pitch; + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; Uint32 *buf32 = (Uint32 *)buf; buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); @@ -361,7 +361,7 @@ int CBFontTT::GetLetterHeight() { ////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -369,8 +369,8 @@ HRESULT CBFontTT::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); @@ -428,7 +428,7 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SIZE: - parser.ScanStr(params, "%d", &m_FontHeight); + parser.ScanStr(params, "%d", &_fontHeight); break; case TOKEN_FACE: @@ -436,23 +436,23 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { break; case TOKEN_FILENAME: - CBUtils::SetString(&m_FontFile, params); + CBUtils::SetString(&_fontFile, params); break; case TOKEN_BOLD: - parser.ScanStr(params, "%b", &m_IsBold); + parser.ScanStr(params, "%b", &_isBold); break; case TOKEN_ITALIC: - parser.ScanStr(params, "%b", &m_IsItalic); + parser.ScanStr(params, "%b", &_isItalic); break; case TOKEN_UNDERLINE: - parser.ScanStr(params, "%b", &m_IsUnderline); + parser.ScanStr(params, "%b", &_isUnderline); break; case TOKEN_STRIKE: - parser.ScanStr(params, "%b", &m_IsStriked); + parser.ScanStr(params, "%b", &_isStriked); break; case TOKEN_CHARSET: @@ -475,7 +475,7 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { case TOKEN_LAYER: { CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) m_Layers.Add(Layer); + if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); else { delete Layer; Layer = NULL; @@ -492,13 +492,13 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { } // create at least one layer - if (m_Layers.GetSize() == 0) { + if (_layers.GetSize() == 0) { CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->m_Color = BaseColor; - m_Layers.Add(Layer); + Layer->_color = BaseColor; + _layers.Add(Layer); } - if (!m_FontFile) CBUtils::SetString(&m_FontFile, "arial.ttf"); + if (!_fontFile) CBUtils::SetString(&_fontFile, "arial.ttf"); return InitFont(); } @@ -520,24 +520,24 @@ HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_OFFSET_X: - parser.ScanStr(params, "%d", &Layer->m_OffsetX); + parser.ScanStr(params, "%d", &Layer->_offsetX); break; case TOKEN_OFFSET_Y: - parser.ScanStr(params, "%d", &Layer->m_OffsetY); + parser.ScanStr(params, "%d", &Layer->_offsetY); break; case TOKEN_COLOR: { int r, g, b; parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - Layer->m_Color = DRGBA(r, g, b, D3DCOLGetA(Layer->m_Color)); + Layer->_color = DRGBA(r, g, b, D3DCOLGetA(Layer->_color)); } break; case TOKEN_ALPHA: { int a; parser.ScanStr(params, "%d", &a); - Layer->m_Color = DRGBA(D3DCOLGetR(Layer->m_Color), D3DCOLGetG(Layer->m_Color), D3DCOLGetB(Layer->m_Color), a); + Layer->_color = DRGBA(D3DCOLGetR(Layer->_color), D3DCOLGetG(Layer->_color), D3DCOLGetB(Layer->_color), a); } break; } @@ -551,33 +551,33 @@ HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { CBFont::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_IsBold)); - PersistMgr->Transfer(TMEMBER(m_IsItalic)); - PersistMgr->Transfer(TMEMBER(m_IsUnderline)); - PersistMgr->Transfer(TMEMBER(m_IsStriked)); - PersistMgr->Transfer(TMEMBER(m_FontHeight)); - PersistMgr->Transfer(TMEMBER(m_FontFile)); + PersistMgr->Transfer(TMEMBER(_isBold)); + PersistMgr->Transfer(TMEMBER(_isItalic)); + PersistMgr->Transfer(TMEMBER(_isUnderline)); + PersistMgr->Transfer(TMEMBER(_isStriked)); + PersistMgr->Transfer(TMEMBER(_fontHeight)); + PersistMgr->Transfer(TMEMBER(_fontFile)); // persist layers int NumLayers; - if (PersistMgr->m_Saving) { - NumLayers = m_Layers.GetSize(); + if (PersistMgr->_saving) { + NumLayers = _layers.GetSize(); PersistMgr->Transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) m_Layers[i]->Persist(PersistMgr); + for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(PersistMgr); } else { - NumLayers = m_Layers.GetSize(); + NumLayers = _layers.GetSize(); PersistMgr->Transfer(TMEMBER(NumLayers)); for (int i = 0; i < NumLayers; i++) { CBTTFontLayer *Layer = new CBTTFontLayer; Layer->Persist(PersistMgr); - m_Layers.Add(Layer); + _layers.Add(Layer); } } - if (!PersistMgr->m_Saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) m_CachedTexts[i] = NULL; - m_GlyphCache = NULL; + if (!PersistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _glyphCache = NULL; } return S_OK; @@ -591,16 +591,16 @@ void CBFontTT::AfterLoad() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::InitFont() { - if (!m_FontFile) return E_FAIL; + if (!_fontFile) return E_FAIL; - CBFile *file = Game->m_FileManager->OpenFile(m_FontFile); + CBFile *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(m_FontFile)); - file = Game->m_FileManager->OpenFile((char *)fontFileName.c_str(), false); + AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); + file = Game->_fileManager->OpenFile((char *)fontFileName.c_str(), false); if (!file) { - Game->LOG(0, "Error loading TrueType font '%s'", m_FontFile); + Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); return E_FAIL; } } @@ -611,55 +611,55 @@ HRESULT CBFontTT::InitFont() { float horDpi = 96.0; - m_FTStream = (FT_Stream)new byte[sizeof(*m_FTStream)]; - memset(m_FTStream, 0, sizeof(*m_FTStream)); + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); - m_FTStream->read = CBFontTT::FTReadSeekProc; - m_FTStream->close = CBFontTT::FTCloseProc; - m_FTStream->descriptor.pointer = file; - m_FTStream->size = file->GetSize(); + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); FT_Open_Args args; args.flags = FT_OPEN_STREAM; - args.stream = m_FTStream; + args.stream = _fTStream; - error = FT_Open_Face(Game->m_FontStorage->GetFTLibrary(), &args, 0, &m_FTFace); + error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); if (error) { - SAFE_DELETE_ARRAY(m_FTStream); - Game->m_FileManager->CloseFile(file); + SAFE_DELETE_ARRAY(_fTStream); + Game->_fileManager->CloseFile(file); return E_FAIL; } - error = FT_Set_Char_Size(m_FTFace, 0, (FT_F26Dot6)(m_FontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); if (error) { - FT_Done_Face(m_FTFace); - m_FTFace = NULL; + FT_Done_Face(_fTFace); + _fTFace = NULL; return E_FAIL; } - // http://en.wikipedia.org/wiki/Em_(typography) - float pixelsPerEm = (m_FontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / m_FTFace->units_per_EM; + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; float pixelsPerUnit = pixelsPerEm * EmsPerUnit; // bounding box in pixels - float xMin = m_FTFace->bbox.xMin * pixelsPerUnit; - float xMax = m_FTFace->bbox.xMax * pixelsPerUnit; - float yMin = m_FTFace->bbox.yMin * pixelsPerUnit; - float yMax = m_FTFace->bbox.yMax * pixelsPerUnit; + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; // metrics in pixels - m_Ascender = m_FTFace->ascender * pixelsPerUnit; - m_Descender = - m_FTFace->descender * pixelsPerUnit; - m_LineHeight = MathUtil::RoundUp(m_FTFace->height * pixelsPerUnit) + 2; - m_UnderlinePos = - m_FTFace->underline_position * pixelsPerUnit; + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; // max character size (used for texture grid) - m_MaxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - m_MaxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - m_GlyphCache = new FontGlyphCache(); - m_GlyphCache->Initialize(); + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); return S_OK; @@ -688,7 +688,7 @@ void CBFontTT::FTCloseProc(FT_Stream stream) { CBGame *Game = f->Game; - Game->m_FileManager->CloseFile(f); + Game->_fileManager->CloseFile(f); stream->descriptor.pointer = NULL; } @@ -794,13 +794,13 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, ////////////////////////////////////////////////////////////////////////// float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { - GlyphInfo *infoLeft = m_GlyphCache->GetGlyph(leftChar); - GlyphInfo *infoRight = m_GlyphCache->GetGlyph(rightChar); + GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); + GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); if (!infoLeft || !infoRight) return 0; FT_Vector delta; - FT_Error error = FT_Get_Kerning(m_FTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); + FT_Error error = FT_Get_Kerning(_fTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); if (error) return 0; return delta.x * (1.0f / 64.0f); @@ -812,45 +812,45 @@ void CBFontTT::PrepareGlyphs(const WideString &text) { // make sure we have all the glyphs we need for (size_t i = 0; i < text.size(); i++) { wchar_t ch = text[i]; - if (!m_GlyphCache->HasGlyph(ch)) CacheGlyph(ch); + if (!_glyphCache->HasGlyph(ch)) CacheGlyph(ch); } } ////////////////////////////////////////////////////////////////////////// void CBFontTT::CacheGlyph(wchar_t ch) { - FT_UInt glyphIndex = FT_Get_Char_Index(m_FTFace, ch); + FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); if (!glyphIndex) return; - FT_Error error = FT_Load_Glyph(m_FTFace, glyphIndex, FT_LOAD_DEFAULT); + FT_Error error = FT_Load_Glyph(_fTFace, glyphIndex, FT_LOAD_DEFAULT); if (error) return; - error = FT_Render_Glyph(m_FTFace->glyph, FT_RENDER_MODE_NORMAL); + error = FT_Render_Glyph(_fTFace->glyph, FT_RENDER_MODE_NORMAL); if (error) return; - byte *pixels = m_FTFace->glyph->bitmap.buffer; - size_t stride = m_FTFace->glyph->bitmap.pitch; + byte *pixels = _fTFace->glyph->bitmap.buffer; + size_t stride = _fTFace->glyph->bitmap.pitch; // convert from monochrome to grayscale if needed byte *tempBuffer = NULL; - if (pixels != NULL && m_FTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - tempBuffer = new byte[m_FTFace->glyph->bitmap.width * m_FTFace->glyph->bitmap.rows]; - for (int j = 0; j < m_FTFace->glyph->bitmap.rows; j++) { + if (pixels != NULL && _fTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { + tempBuffer = new byte[_fTFace->glyph->bitmap.width * _fTFace->glyph->bitmap.rows]; + for (int j = 0; j < _fTFace->glyph->bitmap.rows; j++) { int rowOffset = stride * j; - for (int i = 0; i < m_FTFace->glyph->bitmap.width; i++) { + for (int i = 0; i < _fTFace->glyph->bitmap.width; i++) { int byteOffset = i / 8; int bitOffset = 7 - (i % 8); byte bit = (pixels[rowOffset + byteOffset] & (1 << bitOffset)) >> bitOffset; - tempBuffer[m_FTFace->glyph->bitmap.width * j + i] = 255 * bit; + tempBuffer[_fTFace->glyph->bitmap.width * j + i] = 255 * bit; } } pixels = tempBuffer; - stride = m_FTFace->glyph->bitmap.width; + stride = _fTFace->glyph->bitmap.width; } // add glyph to cache - m_GlyphCache->AddGlyph(ch, glyphIndex, m_FTFace->glyph, m_FTFace->glyph->bitmap.width, m_FTFace->glyph->bitmap.rows, pixels, stride); + _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); if (tempBuffer) delete [] tempBuffer; } diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 5675cca5de..9dc3de1920 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -45,29 +45,29 @@ private: ////////////////////////////////////////////////////////////////////////// class CBCachedTTFontText { public: - WideString m_Text; - int m_Width; - TTextAlign m_Align; - int m_MaxHeight; - int m_MaxLength; - CBSurface *m_Surface; - int m_Priority; - int m_TextOffset; - bool m_Marked; + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; CBCachedTTFontText() { - //m_Text = L""; - m_Text = ""; - m_Width = m_MaxHeight = m_MaxLength = -1; - m_Align = TAL_LEFT; - m_Surface = NULL; - m_Priority = -1; - m_TextOffset = 0; - m_Marked = false; + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; } virtual ~CBCachedTTFontText() { - if (m_Surface) delete m_Surface; + if (_surface) delete _surface; } }; @@ -76,39 +76,39 @@ public: class CBTTFontLayer { public: CBTTFontLayer() { - m_OffsetX = m_OffsetY = 0; - m_Color = 0x00000000; + _offsetX = _offsetY = 0; + _color = 0x00000000; } HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_OffsetX)); - PersistMgr->Transfer(TMEMBER(m_OffsetY)); - PersistMgr->Transfer(TMEMBER(m_Color)); + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_color)); return S_OK; } - int m_OffsetX; - int m_OffsetY; - uint32 m_Color; + int _offsetX; + int _offsetY; + uint32 _color; }; ////////////////////////////////////////////////////////////////////////// class TextLine { public: TextLine(const WideString &text, int width) { - m_Text = text; - m_Width = width; + _text = text; + _width = width; } const WideString &GetText() const { - return m_Text; + return _text; } int GetWidth() const { - return m_Width; + return _width; } private: - WideString m_Text; - int m_Width; + WideString _text; + int _width; }; typedef Common::List TextLineList; @@ -130,11 +130,11 @@ public: static void FTCloseProc(FT_Stream stream); FontGlyphCache *GetGlyphCache() { - return m_GlyphCache; + return _glyphCache; } float GetLineHeight() const { - return m_LineHeight; + return _lineHeight; } void AfterLoad(); @@ -153,34 +153,34 @@ private: void BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect); - CBCachedTTFontText *m_CachedTexts[NUM_CACHED_TEXTS]; + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; HRESULT InitFont(); - FT_Stream m_FTStream; - FT_Face m_FTFace; + FT_Stream _fTStream; + FT_Face _fTFace; - FontGlyphCache *m_GlyphCache; + FontGlyphCache *_glyphCache; - float m_Ascender; - float m_Descender; - float m_LineHeight; - float m_UnderlinePos; - float m_PointSize; - float m_VertDpi; - float m_HorDpi; + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; - size_t m_MaxCharWidth; - size_t m_MaxCharHeight; + size_t _maxCharWidth; + size_t _maxCharHeight; public: - bool m_IsBold; - bool m_IsItalic; - bool m_IsUnderline; - bool m_IsStriked; - int m_FontHeight; - char *m_FontFile; - - CBArray m_Layers; + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; void ClearCache(); }; diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index 37b263d505..f04b35bfe2 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -46,31 +46,31 @@ IMPLEMENT_PERSISTENT(CBFrame, false) ////////////////////////////////////////////////////////////////////// CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { - m_Delay = 0; - m_MoveX = m_MoveY = 0; + _delay = 0; + _moveX = _moveY = 0; - m_Sound = NULL; - m_KillSound = false; + _sound = NULL; + _killSound = false; - m_EditorExpanded = false; - m_Keyframe = false; + _editorExpanded = false; + _keyframe = false; } ////////////////////////////////////////////////////////////////////// CBFrame::~CBFrame() { - delete m_Sound; - m_Sound = NULL; + delete _sound; + _sound = NULL; int i; - for (i = 0; i < m_Subframes.GetSize(); i++) delete m_Subframes[i]; - m_Subframes.RemoveAll(); + for (i = 0; i < _subframes.GetSize(); i++) delete _subframes[i]; + _subframes.RemoveAll(); - for (i = 0; i < m_ApplyEvent.GetSize(); i++) { - SAFE_DELETE_ARRAY(m_ApplyEvent[i]); + for (i = 0; i < _applyEvent.GetSize(); i++) { + SAFE_DELETE_ARRAY(_applyEvent[i]); } - m_ApplyEvent.RemoveAll(); + _applyEvent.RemoveAll(); } @@ -78,8 +78,8 @@ CBFrame::~CBFrame() { HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { HRESULT res; - for (int i = 0; i < m_Subframes.GetSize(); i++) { - res = m_Subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); + for (int i = 0; i < _subframes.GetSize(); i++) { + res = _subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); if (FAILED(res)) return res; } return S_OK; @@ -88,19 +88,19 @@ HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY ////////////////////////////////////////////////////////////////////////// HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { - if (m_Sound && !Muted) { - if (Owner) Owner->UpdateOneSound(m_Sound); - m_Sound->Play(); + if (_sound && !Muted) { + if (Owner) Owner->UpdateOneSound(_sound); + _sound->Play(); /* - if(Game->m_State==GAME_FROZEN) + if(Game->_state==GAME_FROZEN) { - m_Sound->Pause(true); + _sound->Pause(true); } */ } if (Owner) { - for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { - Owner->ApplyEvent(m_ApplyEvent[i]); + for (int i = 0; i < _applyEvent.GetSize(); i++) { + Owner->ApplyEvent(_applyEvent[i]); } } return S_OK; @@ -164,7 +164,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; int HotspotX = 0, HotspotY = 0; - bool custom_trans = false; + bool custo_trans = false; bool editor_selected = false; bool Is2DOnly = false; bool Is3DOnly = false; @@ -177,7 +177,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_DELAY: - parser.ScanStr(params, "%d", &m_Delay); + parser.ScanStr(params, "%d", &_delay); break; case TOKEN_IMAGE: @@ -186,7 +186,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custom_trans = true; + custo_trans = true; break; case TOKEN_RECT: @@ -198,7 +198,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_MOVE: - parser.ScanStr(params, "%d,%d", &m_MoveX, &m_MoveY); + parser.ScanStr(params, "%d,%d", &_moveX, &_moveY); break; case TOKEN_2D_ONLY: @@ -230,11 +230,11 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_EXPANDED: - parser.ScanStr(params, "%b", &m_EditorExpanded); + parser.ScanStr(params, "%b", &_editorExpanded); break; case TOKEN_KILL_SOUND: - parser.ScanStr(params, "%b", &m_KillSound); + parser.ScanStr(params, "%b", &_killSound); break; case TOKEN_SUBFRAME: { @@ -242,20 +242,20 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; - } else m_Subframes.Add(subframe); + } else _subframes.Add(subframe); } break; case TOKEN_SOUND: { - if (m_Sound) { - delete m_Sound; - m_Sound = NULL; + if (_sound) { + delete _sound; + _sound = NULL; } - m_Sound = new CBSound(Game); - if (!m_Sound || FAILED(m_Sound->SetSound(params, SOUND_SFX, false))) { - if (Game->m_SoundMgr->m_SoundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); - delete m_Sound; - m_Sound = NULL; + _sound = new CBSound(Game); + if (!_sound || FAILED(_sound->SetSound(params, SOUND_SFX, false))) { + if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; } } break; @@ -263,12 +263,12 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_APPLY_EVENT: { char *Event = new char[strlen(params) + 1]; strcpy(Event, params); - m_ApplyEvent.Add(Event); + _applyEvent.Add(Event); } break; case TOKEN_KEYFRAME: - parser.ScanStr(params, "%b", &m_Keyframe); + parser.ScanStr(params, "%b", &_keyframe); break; case TOKEN_DECORATION: @@ -293,33 +293,33 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { CBSubFrame *sub = new CBSubFrame(Game); if (surface_file != NULL) { - if (custom_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + if (custo_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); else sub->SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); - if (!sub->m_Surface) { + if (!sub->_surface) { delete sub; Game->LOG(0, "Error loading SUBFRAME"); return E_FAIL; } - sub->m_Alpha = DRGBA(ar, ag, ab, alpha); - if (custom_trans) sub->m_Transparent = DRGBA(r, g, b, 0xFF); + sub->_alpha = DRGBA(ar, ag, ab, alpha); + if (custo_trans) sub->_transparent = DRGBA(r, g, b, 0xFF); } if (CBPlatform::IsRectEmpty(&rect)) sub->SetDefaultRect(); - else sub->m_Rect = rect; + else sub->_rect = rect; - sub->m_HotspotX = HotspotX; - sub->m_HotspotY = HotspotY; - sub->m_2DOnly = Is2DOnly; - sub->m_3DOnly = Is3DOnly; - sub->m_Decoration = Decoration; - sub->m_MirrorX = MirrorX; - sub->m_MirrorY = MirrorY; + sub->_hotspotX = HotspotX; + sub->_hotspotY = HotspotY; + sub->_2DOnly = Is2DOnly; + sub->_3DOnly = Is3DOnly; + sub->_decoration = Decoration; + sub->_mirrorX = MirrorX; + sub->_mirrorY = MirrorY; - sub->m_EditorSelected = editor_selected; - m_Subframes.InsertAt(0, sub); + sub->_editorSelected = editor_selected; + _subframes.InsertAt(0, sub); return S_OK; } @@ -332,8 +332,8 @@ bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca RECT SubRect; - for (int i = 0; i < m_Subframes.GetSize(); i++) { - m_Subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); + for (int i = 0; i < _subframes.GetSize(); i++) { + _subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); CBPlatform::UnionRect(Rect, Rect, &SubRect); } return true; @@ -344,31 +344,31 @@ bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca ////////////////////////////////////////////////////////////////////////// HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "FRAME {\n"); - Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", m_Delay); + Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", _delay); - if (m_MoveX != 0 || m_MoveY != 0) - Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", m_MoveX, m_MoveY); + if (_moveX != 0 || _moveY != 0) + Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - if (m_Sound && m_Sound->m_SoundFilename) - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", m_Sound->m_SoundFilename); + if (_sound && _sound->_soundFilename) + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", m_Keyframe ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - if (m_KillSound) - Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", m_KillSound ? "TRUE" : "FALSE"); + if (_killSound) + Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - if (m_EditorExpanded) - Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", m_EditorExpanded ? "TRUE" : "FALSE"); + if (_editorExpanded) + Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - if (m_Subframes.GetSize() > 0) m_Subframes[0]->SaveAsText(Buffer, Indent, false); + if (_subframes.GetSize() > 0) _subframes[0]->SaveAsText(Buffer, Indent, false); int i; - for (i = 1; i < m_Subframes.GetSize(); i++) { - m_Subframes[i]->SaveAsText(Buffer, Indent + 2); + for (i = 1; i < _subframes.GetSize(); i++) { + _subframes[i]->SaveAsText(Buffer, Indent + 2); } - for (i = 0; i < m_ApplyEvent.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", m_ApplyEvent[i]); + for (i = 0; i < _applyEvent.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } CBBase::SaveAsText(Buffer, Indent + 2); @@ -384,15 +384,15 @@ HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - m_ApplyEvent.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Delay)); - PersistMgr->Transfer(TMEMBER(m_EditorExpanded)); - PersistMgr->Transfer(TMEMBER(m_Keyframe)); - PersistMgr->Transfer(TMEMBER(m_KillSound)); - PersistMgr->Transfer(TMEMBER(m_MoveX)); - PersistMgr->Transfer(TMEMBER(m_MoveY)); - PersistMgr->Transfer(TMEMBER(m_Sound)); - m_Subframes.Persist(PersistMgr); + _applyEvent.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_delay)); + PersistMgr->Transfer(TMEMBER(_editorExpanded)); + PersistMgr->Transfer(TMEMBER(_keyframe)); + PersistMgr->Transfer(TMEMBER(_killSound)); + PersistMgr->Transfer(TMEMBER(_moveX)); + PersistMgr->Transfer(TMEMBER(_moveY)); + PersistMgr->Transfer(TMEMBER(_sound)); + _subframes.Persist(PersistMgr); return S_OK; } @@ -409,7 +409,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "GetSound") == 0) { Stack->CorrectParams(0); - if (m_Sound && m_Sound->m_SoundFilename) Stack->PushString(m_Sound->m_SoundFilename); + if (_sound && _sound->_soundFilename) Stack->PushString(_sound->_soundFilename); else Stack->PushNULL(); return S_OK; } @@ -420,15 +420,15 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "SetSound") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - delete m_Sound; - m_Sound = NULL; + delete _sound; + _sound = NULL; if (!Val->IsNULL()) { - m_Sound = new CBSound(Game); - if (!m_Sound || FAILED(m_Sound->SetSound(Val->GetString(), SOUND_SFX, false))) { + _sound = new CBSound(Game); + if (!_sound || FAILED(_sound->SetSound(Val->GetString(), SOUND_SFX, false))) { Stack->PushBool(false); - delete m_Sound; - m_Sound = NULL; + delete _sound; + _sound = NULL; } else Stack->PushBool(true); } else Stack->PushBool(true); return S_OK; @@ -440,10 +440,10 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "GetSubframe") == 0) { Stack->CorrectParams(1); int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= m_Subframes.GetSize()) { + if (Index < 0 || Index >= _subframes.GetSize()) { Script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); Stack->PushNULL(); - } else Stack->PushNative(m_Subframes[Index], true); + } else Stack->PushNative(_subframes[Index], true); return S_OK; } @@ -456,15 +456,15 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CScValue *Val = Stack->Pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); - if (Index < 0 || Index >= m_Subframes.GetSize()) { + if (Index < 0 || Index >= _subframes.GetSize()) { Script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); } } else { CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); - for (int i = 0; i < m_Subframes.GetSize(); i++) { - if (m_Subframes[i] == Sub) { - delete m_Subframes[i]; - m_Subframes.RemoveAt(i); + for (int i = 0; i < _subframes.GetSize(); i++) { + if (_subframes[i] == Sub) { + delete _subframes[i]; + _subframes.RemoveAt(i); break; } } @@ -487,7 +487,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Sub->SetSurface(Filename); Sub->SetDefaultRect(); } - m_Subframes.Add(Sub); + _subframes.Add(Sub); Stack->PushNative(Sub, true); return S_OK; @@ -510,8 +510,8 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Sub->SetSurface(Filename); } - if (Index >= m_Subframes.GetSize()) m_Subframes.Add(Sub); - else m_Subframes.InsertAt(Index, Sub); + if (Index >= _subframes.GetSize()) _subframes.Add(Sub); + else _subframes.InsertAt(Index, Sub); Stack->PushNative(Sub, true); return S_OK; @@ -523,10 +523,10 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetSubframe") == 0) { Stack->CorrectParams(1); int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= m_ApplyEvent.GetSize()) { + if (Index < 0 || Index >= _applyEvent.GetSize()) { Script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); Stack->PushNULL(); - } else Stack->PushString(m_ApplyEvent[Index]); + } else Stack->PushString(_applyEvent[Index]); return S_OK; } @@ -536,13 +536,13 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "AddEvent") == 0) { Stack->CorrectParams(1); char *Event = Stack->Pop()->GetString(); - for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { - if (scumm_stricmp(m_ApplyEvent[i], Event) == 0) { + for (int i = 0; i < _applyEvent.GetSize(); i++) { + if (scumm_stricmp(_applyEvent[i], Event) == 0) { Stack->PushNULL(); return S_OK; } } - m_ApplyEvent.Add(Event); + _applyEvent.Add(Event); Stack->PushNULL(); return S_OK; } @@ -553,10 +553,10 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "DeleteEvent") == 0) { Stack->CorrectParams(1); char *Event = Stack->Pop()->GetString(); - for (int i = 0; i < m_ApplyEvent.GetSize(); i++) { - if (scumm_stricmp(m_ApplyEvent[i], Event) == 0) { - delete [] m_ApplyEvent[i]; - m_ApplyEvent.RemoveAt(i); + for (int i = 0; i < _applyEvent.GetSize(); i++) { + if (scumm_stricmp(_applyEvent[i], Event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.RemoveAt(i); break; } } @@ -566,7 +566,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else { - if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); + if (_subframes.GetSize() == 1) return _subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); } } @@ -574,76 +574,76 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CBFrame::ScGetProperty(char *Name) { - if (!m_ScValue) m_ScValue = new CScValue(Game); - m_ScValue->SetNULL(); + if (!_scValue) _scValue = new CScValue(Game); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("frame"); - return m_ScValue; + _scValue->SetString("frame"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Delay") == 0) { - m_ScValue->SetInt(m_Delay); - return m_ScValue; + _scValue->SetInt(_delay); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Keyframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Keyframe") == 0) { - m_ScValue->SetBool(m_Keyframe); - return m_ScValue; + _scValue->SetBool(_keyframe); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // KillSounds ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "KillSounds") == 0) { - m_ScValue->SetBool(m_KillSound); - return m_ScValue; + _scValue->SetBool(_killSound); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MoveX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MoveX") == 0) { - m_ScValue->SetInt(m_MoveX); - return m_ScValue; + _scValue->SetInt(_moveX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MoveY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MoveY") == 0) { - m_ScValue->SetInt(m_MoveY); - return m_ScValue; + _scValue->SetInt(_moveY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumSubframes") == 0) { - m_ScValue->SetInt(m_Subframes.GetSize()); - return m_ScValue; + _scValue->SetInt(_subframes.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumEvents") == 0) { - m_ScValue->SetInt(m_ApplyEvent.GetSize()); - return m_ScValue; + _scValue->SetInt(_applyEvent.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// else { - if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScGetProperty(Name); + if (_subframes.GetSize() == 1) return _subframes[0]->ScGetProperty(Name); else return CBScriptable::ScGetProperty(Name); } } @@ -655,7 +655,7 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // Delay ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Delay") == 0) { - m_Delay = MAX(0, Value->GetInt()); + _delay = MAX(0, Value->GetInt()); return S_OK; } @@ -663,7 +663,7 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // Keyframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Keyframe") == 0) { - m_Keyframe = Value->GetBool(); + _keyframe = Value->GetBool(); return S_OK; } @@ -671,7 +671,7 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // KillSounds ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "KillSounds") == 0) { - m_KillSound = Value->GetBool(); + _killSound = Value->GetBool(); return S_OK; } @@ -679,7 +679,7 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // MoveX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MoveX") == 0) { - m_MoveX = Value->GetInt(); + _moveX = Value->GetInt(); return S_OK; } @@ -687,13 +687,13 @@ HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { // MoveY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MoveY") == 0) { - m_MoveY = Value->GetInt(); + _moveY = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// else { - if (m_Subframes.GetSize() == 1) return m_Subframes[0]->ScSetProperty(Name, Value); + if (_subframes.GetSize() == 1) return _subframes[0]->ScSetProperty(Name, Value); else return CBScriptable::ScSetProperty(Name, Value); } } diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h index 9538305dd6..90a7c1b192 100644 --- a/engines/wintermute/BFrame.h +++ b/engines/wintermute/BFrame.h @@ -40,25 +40,25 @@ class CScScript; class CScStack; class CBFrame: public CBScriptable { public: - bool m_KillSound; - bool m_Keyframe; + bool _killSound; + bool _keyframe; HRESULT OneTimeDisplay(CBObject *Owner, bool Muted = false); DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *m_Sound; - bool m_EditorExpanded; + CBSound *_sound; + bool _editorExpanded; bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - int m_MoveY; - int m_MoveX; - uint32 m_Delay; - CBArray m_Subframes; + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); - CBArray m_ApplyEvent; + CBArray _applyEvent; // scripting interface virtual CScValue *ScGetProperty(char *Name); diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 5cc048b48d..7e2c0d316c 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -85,253 +85,253 @@ IMPLEMENT_PERSISTENT(CBGame, true) ////////////////////////////////////////////////////////////////////// CBGame::CBGame(): CBObject(this) { - m_ShuttingDown = false; + _shuttingDown = false; - m_State = GAME_RUNNING; - m_OrigState = GAME_RUNNING; - m_FreezeLevel = 0; + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; - m_Interactive = true; - m_OrigInteractive = false; + _interactive = true; + _origInteractive = false; - m_SurfaceStorage = NULL; - m_FontStorage = NULL; - m_Renderer = NULL; - m_SoundMgr = NULL; - m_FileManager = NULL; - m_TransMgr = NULL; - m_DebugMgr = NULL; - m_ScEngine = NULL; - m_KeyboardState = NULL; + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; - m_MathClass = NULL; + _mathClass = NULL; - m_DEBUG_LogFile = NULL; - m_DEBUG_DebugMode = false; - m_DEBUG_AbsolutePathWarning = true; - m_DEBUG_ShowFPS = false; + _dEBUG_LogFile = NULL; + _dEBUG_DebugMode = false; + _dEBUG_AbsolutePathWarning = true; + _dEBUG_ShowFPS = false; - m_SystemFont = NULL; - m_VideoFont = NULL; + _systemFont = NULL; + _videoFont = NULL; - m_MainObject = NULL; - m_ActiveObject = NULL; + _mainObject = NULL; + _activeObject = NULL; - m_Fader = NULL; + _fader = NULL; - m_OffsetX = m_OffsetY = 0; - m_OffsetPercentX = m_OffsetPercentY = 0.0f; + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; - m_Subtitles = true; - m_VideoSubtitles = true; + _subtitles = true; + _videoSubtitles = true; - m_Timer = 0; - m_TimerDelta = 0; - m_TimerLast = 0; + _timer = 0; + _timerDelta = 0; + _timerLast = 0; - m_LiveTimer = 0; - m_LiveTimerDelta = 0; - m_LiveTimerLast = 0; + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; - m_Sequence = 0; + _sequence = 0; - m_MousePos.x = m_MousePos.y = 0; - m_MouseLeftDown = m_MouseRightDown = m_MouseMidlleDown = false; - m_CapturedObject = NULL; + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; // FPS counters - m_LastTime = m_FpsTime = m_DeltaTime = m_FramesRendered = m_Fps = 0; + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - m_CursorNoninteractive = NULL; + _cursorNoninteractive = NULL; - m_UseD3D = false; + _useD3D = false; srand((unsigned)time(NULL)); - m_Registry = new CBRegistry(this); - m_StringTable = new CBStringTable(this); + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - m_Music[i] = NULL; - m_MusicStartTime[i] = 0; + _music[i] = NULL; + _musicStartTime[i] = 0; } - m_SettingsResWidth = 800; - m_SettingsResHeight = 600; - m_SettingsRequireAcceleration = false; - m_SettingsRequireSound = false; - m_SettingsTLMode = 0; - m_SettingsAllowWindowed = true; - m_SettingsGameFile = NULL; - m_SettingsAllowAdvanced = false; - m_SettingsAllowAccessTab = true; - m_SettingsAllowAboutTab = true; - m_SettingsAllowDesktopRes = false; + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; - m_EditorForceScripts = false; - m_EditorAlwaysRegister = false; + _editorForceScripts = false; + _editorAlwaysRegister = false; - m_FocusedWindow = NULL; + _focusedWindow = NULL; - m_LoadInProgress = false; + _loadInProgress = false; - m_Quitting = false; - m_Loading = false; - m_ScheduledLoadSlot = -1; + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; - m_PersonalizedSave = false; - m_CompressedSavegames = true; + _personalizedSave = false; + _compressedSavegames = true; - m_EditorMode = false; - m_DoNotExpandStrings = false; + _editorMode = false; + _doNotExpandStrings = false; - m_EngineLogCallback = NULL; - m_EngineLogCallbackData = NULL; + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; - m_SmartCache = false; - m_SurfaceGCCycleTime = 10000; + _smartCache = false; + _surfaceGCCycleTime = 10000; - m_ReportTextureFormat = false; + _reportTextureFormat = false; - m_ViewportSP = -1; + _viewportSP = -1; - m_SubtitlesSpeed = 70; + _subtitlesSpeed = 70; - m_ResourceModule = NULL; + _resourceModule = NULL; - m_ForceNonStreamedSounds = false; + _forceNonStreamedSounds = false; - m_ThumbnailWidth = m_ThumbnailHeight = 0; + _thumbnailWidth = _thumbnailHeight = 0; - m_IndicatorDisplay = false; - m_IndicatorColor = DRGBA(255, 0, 0, 128); - m_IndicatorProgress = 0; - m_IndicatorX = -1; - m_IndicatorY = -1; - m_IndicatorWidth = -1; - m_IndicatorHeight = 8; - m_RichSavedGames = false; - m_SavedGameExt = NULL; - CBUtils::SetString(&m_SavedGameExt, "dsv"); + _indicatorDisplay = false; + _indicatorColor = DRGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::SetString(&_savedGameExt, "dsv"); - m_MusicCrossfadeRunning = false; - m_MusicCrossfadeStartTime = 0; - m_MusicCrossfadeLength = 0; - m_MusicCrossfadeChannel1 = -1; - m_MusicCrossfadeChannel2 = -1; - m_MusicCrossfadeSwap = false; + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; - m_LoadImageName = NULL; - m_SaveImageName = NULL; - m_SaveLoadImage = NULL; + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; - m_SaveImageX = m_SaveImageY = 0; - m_LoadImageX = m_LoadImageY = 0; + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; - m_LocalSaveDir = NULL; - CBUtils::SetString(&m_LocalSaveDir, "saves"); - m_SaveDirChecked = false; + _localSaveDir = NULL; + CBUtils::SetString(&_localSaveDir, "saves"); + _saveDirChecked = false; - m_LoadingIcon = NULL; - m_LoadingIconX = m_LoadingIconY = 0; - m_LoadingIconPersistent = false; + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; - m_TextEncoding = TEXT_ANSI; - m_TextRTL = false; + _textEncoding = TEXT_ANSI; + _textRTL = false; - m_SoundBufferSizeSec = 3; - m_SuspendedRendering = false; + _soundBufferSizeSec = 3; + _suspendedRendering = false; - m_LastCursor = NULL; + _lastCursor = NULL; - CBPlatform::SetRectEmpty(&m_MouseLockRect); + CBPlatform::SetRectEmpty(&_mouseLockRect); - m_SuppressScriptErrors = false; - m_LastMiniUpdate = 0; - m_MiniUpdateEnabled = false; + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; - m_CachedThumbnail = NULL; + _cachedThumbnail = NULL; - m_AutorunDisabled = false; + _autorunDisabled = false; // compatibility bits - m_CompatKillMethodThreads = false; + _compatKillMethodThreads = false; - m_UsedMem = 0; + _usedMem = 0; - m_AutoSaveOnExit = true; - m_AutoSaveSlot = 999; - m_CursorHidden = false; + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; #ifdef __IPHONEOS__ - m_TouchInterface = true; - m_ConstrainedMemory = true; // TODO differentiate old and new iOS devices + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices #else - m_TouchInterface = false; - m_ConstrainedMemory = false; + _touchInterface = false; + _constrainedMemory = false; #endif - m_Store = NULL; + _store = NULL; } ////////////////////////////////////////////////////////////////////// CBGame::~CBGame() { - m_ShuttingDown = true; + _shuttingDown = true; LOG(0, ""); LOG(0, "Shutting down..."); GetDebugMgr()->OnGameShutdown(); - m_Registry->WriteBool("System", "LastRun", true); + _registry->WriteBool("System", "LastRun", true); Cleanup(); - delete[] m_LocalSaveDir; - delete[] m_SettingsGameFile; - delete[] m_SavedGameExt; + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; - delete m_CachedThumbnail; + delete _cachedThumbnail; - delete m_SaveLoadImage; - delete m_MathClass; + delete _saveLoadImage; + delete _mathClass; - delete m_TransMgr; - delete m_ScEngine; - delete m_FontStorage; - delete m_SurfaceStorage; - delete m_SoundMgr; - delete m_DebugMgr; - //SAFE_DELETE(m_KeyboardState); + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); - delete m_Renderer; - delete m_FileManager; - delete m_Registry; - delete m_StringTable; + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; - m_LocalSaveDir = NULL; - m_SettingsGameFile = NULL; - m_SavedGameExt = NULL; + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; - m_CachedThumbnail = NULL; + _cachedThumbnail = NULL; - m_SaveLoadImage = NULL; - m_MathClass = NULL; + _saveLoadImage = NULL; + _mathClass = NULL; - m_TransMgr = NULL; - m_ScEngine = NULL; - m_FontStorage = NULL; - m_SurfaceStorage = NULL; - m_SoundMgr = NULL; - m_DebugMgr = NULL; - - m_Renderer = NULL; - m_FileManager = NULL; - m_Registry = NULL; - m_StringTable = NULL; + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; DEBUG_DebugDisable(); CBPlatform::OutputDebugString("--- shutting down normally ---\n"); @@ -342,81 +342,81 @@ CBGame::~CBGame() { HRESULT CBGame::Cleanup() { int i; - delete m_LoadingIcon; - m_LoadingIcon = NULL; + delete _loadingIcon; + _loadingIcon = NULL; - m_EngineLogCallback = NULL; - m_EngineLogCallbackData = NULL; + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; for (i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete m_Music[i]; - m_Music[i] = NULL; - m_MusicStartTime[i] = 0; + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; } - UnregisterObject(m_Store); - m_Store = NULL; + UnregisterObject(_store); + _store = NULL; - UnregisterObject(m_Fader); - m_Fader = NULL; + UnregisterObject(_fader); + _fader = NULL; - for (i = 0; i < m_RegObjects.GetSize(); i++) { - delete m_RegObjects[i]; - m_RegObjects[i] = NULL; + for (i = 0; i < _regObjects.GetSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; } - m_RegObjects.RemoveAll(); + _regObjects.RemoveAll(); - m_Windows.RemoveAll(); // refs only - m_FocusedWindow = NULL; // ref only + _windows.RemoveAll(); // refs only + _focusedWindow = NULL; // ref only - delete[] m_SaveImageName; - delete[] m_LoadImageName; - m_SaveImageName = NULL; - m_LoadImageName = NULL; + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; - delete m_CursorNoninteractive; - delete m_Cursor; - delete m_ActiveCursor; - m_CursorNoninteractive = NULL; - m_Cursor = NULL; - m_ActiveCursor = NULL; + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; - delete m_ScValue; - delete m_SFX; - m_ScValue = NULL; - m_SFX = NULL; + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; - for (i = 0; i < m_Scripts.GetSize(); i++) { - m_Scripts[i]->m_Owner = NULL; - m_Scripts[i]->Finish(); + for (i = 0; i < _scripts.GetSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->Finish(); } - m_Scripts.RemoveAll(); + _scripts.RemoveAll(); - m_FontStorage->RemoveFont(m_SystemFont); - m_SystemFont = NULL; + _fontStorage->RemoveFont(_systemFont); + _systemFont = NULL; - m_FontStorage->RemoveFont(m_VideoFont); - m_VideoFont = NULL; + _fontStorage->RemoveFont(_videoFont); + _videoFont = NULL; - for (i = 0; i < m_QuickMessages.GetSize(); i++) delete m_QuickMessages[i]; - m_QuickMessages.RemoveAll(); + for (i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; + _quickMessages.RemoveAll(); - m_ViewportStack.RemoveAll(); - m_ViewportSP = -1; + _viewportStack.RemoveAll(); + _viewportSP = -1; - delete[] m_Name; - delete[] m_Filename; - m_Name = NULL; - m_Filename = NULL; + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; for (int i = 0; i < 7; i++) { - delete[] m_Caption[i]; - m_Caption[i] = NULL; + delete[] _caption[i]; + _caption[i] = NULL; } - m_LastCursor = NULL; + _lastCursor = NULL; - delete m_KeyboardState; - m_KeyboardState = NULL; + delete _keyboardState; + _keyboardState = NULL; return S_OK; } @@ -424,79 +424,79 @@ HRESULT CBGame::Cleanup() { ////////////////////////////////////////////////////////////////////// HRESULT CBGame::Initialize1() { - m_SurfaceStorage = new CBSurfaceStorage(this); - if (m_SurfaceStorage == NULL) goto init_fail; + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) goto init_fail; - m_FontStorage = new CBFontStorage(this); - if (m_FontStorage == NULL) goto init_fail; + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) goto init_fail; - m_FileManager = new CBFileManager(this); - if (m_FileManager == NULL) goto init_fail; + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) goto init_fail; - m_SoundMgr = new CBSoundMgr(this); - if (m_SoundMgr == NULL) goto init_fail; + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) goto init_fail; - m_DebugMgr = new CBDebugger(this); - if (m_DebugMgr == NULL) goto init_fail; + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) goto init_fail; - m_MathClass = new CSXMath(this); - if (m_MathClass == NULL) goto init_fail; + _mathClass = new CSXMath(this); + if (_mathClass == NULL) goto init_fail; - m_ScEngine = new CScEngine(this); - if (m_ScEngine == NULL) goto init_fail; + _scEngine = new CScEngine(this); + if (_scEngine == NULL) goto init_fail; - m_TransMgr = new CBTransitionMgr(this); - if (m_TransMgr == NULL) goto init_fail; + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) goto init_fail; - m_KeyboardState = new CBKeyboardState(this); - if (m_KeyboardState == NULL) goto init_fail; + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) goto init_fail; - m_Fader = new CBFader(this); - if (m_Fader == NULL) goto init_fail; - RegisterObject(m_Fader); + _fader = new CBFader(this); + if (_fader == NULL) goto init_fail; + RegisterObject(_fader); - m_Store = new CSXStore(this); - if (m_Store == NULL) goto init_fail; - RegisterObject(m_Store); + _store = new CSXStore(this); + if (_store == NULL) goto init_fail; + RegisterObject(_store); return S_OK; init_fail: - if (m_MathClass) delete m_MathClass; - if (m_Store) delete m_Store; - if (m_KeyboardState) delete m_KeyboardState; - if (m_TransMgr) delete m_TransMgr; - if (m_DebugMgr) delete m_DebugMgr; - if (m_SurfaceStorage) delete m_SurfaceStorage; - if (m_FontStorage) delete m_FontStorage; - if (m_SoundMgr) delete m_SoundMgr; - if (m_FileManager) delete m_FileManager; - if (m_ScEngine) delete m_ScEngine; + if (_mathClass) delete _mathClass; + if (_store) delete _store; + if (_keyboardState) delete _keyboardState; + if (_transMgr) delete _transMgr; + if (_debugMgr) delete _debugMgr; + if (_surfaceStorage) delete _surfaceStorage; + if (_fontStorage) delete _fontStorage; + if (_soundMgr) delete _soundMgr; + if (_fileManager) delete _fileManager; + if (_scEngine) delete _scEngine; return E_FAIL; } ////////////////////////////////////////////////////////////////////// HRESULT CBGame::Initialize2() { // we know whether we are going to be accelerated - m_Renderer = new CBRenderSDL(this); - if (m_Renderer == NULL) goto init_fail; + _renderer = new CBRenderSDL(this); + if (_renderer == NULL) goto init_fail; return S_OK; init_fail: - if (m_Renderer) delete m_Renderer; + if (_renderer) delete _renderer; return E_FAIL; } ////////////////////////////////////////////////////////////////////// HRESULT CBGame::Initialize3() { // renderer is initialized - m_PosX = m_Renderer->m_Width / 2; - m_PosY = m_Renderer->m_Height / 2; + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; - if (m_IndicatorY == -1) m_IndicatorY = m_Renderer->m_Height - m_IndicatorHeight; - if (m_IndicatorX == -1) m_IndicatorX = 0; - if (m_IndicatorWidth == -1) m_IndicatorWidth = m_Renderer->m_Width; + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; return S_OK; } @@ -504,18 +504,18 @@ HRESULT CBGame::Initialize3() { // renderer is initialized ////////////////////////////////////////////////////////////////////// void CBGame::DEBUG_DebugEnable(const char *Filename) { - m_DEBUG_DebugMode = true; + _dEBUG_DebugMode = true; #ifndef __IPHONEOS__ - if (Filename)m_DEBUG_LogFile = fopen(Filename, "a+"); - else m_DEBUG_LogFile = fopen("./zz_debug.log", "a+"); + if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); + else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); - if (!m_DEBUG_LogFile) { + if (!_dEBUG_LogFile) { AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); - m_DEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); + _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); } - if (m_DEBUG_LogFile != NULL) fprintf((FILE*)m_DEBUG_LogFile, "\n"); + if (_dEBUG_LogFile != NULL) fprintf((FILE*)_dEBUG_LogFile, "\n"); #endif time_t timeNow; @@ -539,19 +539,19 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { ////////////////////////////////////////////////////////////////////// void CBGame::DEBUG_DebugDisable() { - if (m_DEBUG_LogFile != NULL) { + if (_dEBUG_LogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - fclose((FILE*)m_DEBUG_LogFile); - m_DEBUG_LogFile = NULL; + fclose((FILE*)_dEBUG_LogFile); + _dEBUG_LogFile = NULL; } - m_DEBUG_DebugMode = false; + _dEBUG_DebugMode = false; } ////////////////////////////////////////////////////////////////////// void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { #ifndef __IPHONEOS__ - if (!m_DEBUG_DebugMode) return; + if (!_dEBUG_DebugMode) return; #endif time_t timeNow; time(&timeNow); @@ -568,17 +568,17 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { printf("%02d:%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, buff); fflush(stdout); #else - if (m_DEBUG_LogFile == NULL) return; + if (_dEBUG_LogFile == NULL) return; // redirect to an engine's own callback - if (m_EngineLogCallback) { - m_EngineLogCallback(buff, res, m_EngineLogCallbackData); + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); } - if (m_DebugMgr) m_DebugMgr->OnLog(res, buff); + if (_debugMgr) _debugMgr->OnLog(res, buff); warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fprintf((FILE*)m_DEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fflush((FILE*)m_DEBUG_LogFile); + fprintf((FILE*)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fflush((FILE*)_dEBUG_LogFile); #endif //QuickMessage(buff); @@ -587,64 +587,64 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback, void *Data) { - m_EngineLogCallback = Callback; - m_EngineLogCallbackData = Data; + _engineLogCallback = Callback; + _engineLogCallbackData = Data; } ////////////////////////////////////////////////////////////////////// HRESULT CBGame::InitLoop() { - m_ViewportSP = -1; + _viewportSP = -1; - m_CurrentTime = CBPlatform::GetTime(); + _currentTime = CBPlatform::GetTime(); GetDebugMgr()->OnGameTick(); - m_Renderer->InitLoop(); - m_SoundMgr->InitLoop(); + _renderer->InitLoop(); + _soundMgr->InitLoop(); UpdateMusicCrossfade(); - m_SurfaceStorage->InitLoop(); - m_FontStorage->InitLoop(); + _surfaceStorage->InitLoop(); + _fontStorage->InitLoop(); - //m_ActiveObject = NULL; + //_activeObject = NULL; // count FPS - m_DeltaTime = m_CurrentTime - m_LastTime; - m_LastTime = m_CurrentTime; - m_FpsTime += m_DeltaTime; - - m_LiveTimerDelta = m_LiveTimer - m_LiveTimerLast; - m_LiveTimerLast = m_LiveTimer; - m_LiveTimer += MIN((uint32)1000, m_DeltaTime); - - if (m_State != GAME_FROZEN) { - m_TimerDelta = m_Timer - m_TimerLast; - m_TimerLast = m_Timer; - m_Timer += MIN((uint32)1000, m_DeltaTime); - } else m_TimerDelta = 0; - - m_FramesRendered++; - if (m_FpsTime > 1000) { - m_Fps = m_FramesRendered; - m_FramesRendered = 0; - m_FpsTime = 0; - } - //Game->LOG(0, "%d", m_Fps); - - GetMousePos(&m_MousePos); - - m_FocusedWindow = NULL; - for (int i = m_Windows.GetSize() - 1; i >= 0; i--) { - if (m_Windows[i]->m_Visible) { - m_FocusedWindow = m_Windows[i]; + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //Game->LOG(0, "%d", _fps); + + GetMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.GetSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; break; } } UpdateSounds(); - if (m_Fader) m_Fader->Update(); + if (_fader) _fader->Update(); return S_OK; } @@ -658,26 +658,26 @@ HRESULT CBGame::InitInput(HINSTANCE hInst, HWND hWnd) { ////////////////////////////////////////////////////////////////////////// int CBGame::GetSequence() { - return ++m_Sequence; + return ++_sequence; } ////////////////////////////////////////////////////////////////////////// void CBGame::SetOffset(int OffsetX, int OffsetY) { - m_OffsetX = OffsetX; - m_OffsetY = OffsetY; + _offsetX = OffsetX; + _offsetY = OffsetY; } ////////////////////////////////////////////////////////////////////////// void CBGame::GetOffset(int *OffsetX, int *OffsetY) { - if (OffsetX != NULL) *OffsetX = m_OffsetX; - if (OffsetY != NULL) *OffsetY = m_OffsetY; + if (OffsetX != NULL) *OffsetX = _offsetX; + if (OffsetY != NULL) *OffsetY = _offsetY; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::LoadFile(const char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -685,8 +685,8 @@ HRESULT CBGame::LoadFile(const char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); @@ -810,47 +810,47 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SYSTEM_FONT: - if (m_SystemFont) m_FontStorage->RemoveFont(m_SystemFont); - m_SystemFont = NULL; + if (_systemFont) _fontStorage->RemoveFont(_systemFont); + _systemFont = NULL; - m_SystemFont = Game->m_FontStorage->AddFont((char *)params); + _systemFont = Game->_fontStorage->AddFont((char *)params); break; case TOKEN_VIDEO_FONT: - if (m_VideoFont) m_FontStorage->RemoveFont(m_VideoFont); - m_VideoFont = NULL; + if (_videoFont) _fontStorage->RemoveFont(_videoFont); + _videoFont = NULL; - m_VideoFont = Game->m_FontStorage->AddFont((char *)params); + _videoFont = Game->_fontStorage->AddFont((char *)params); break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_ACTIVE_CURSOR: - delete m_ActiveCursor; - m_ActiveCursor = NULL; - m_ActiveCursor = new CBSprite(Game); - if (!m_ActiveCursor || FAILED(m_ActiveCursor->LoadFile((char *)params))) { - delete m_ActiveCursor; - m_ActiveCursor = NULL; + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(Game); + if (!_activeCursor || FAILED(_activeCursor->LoadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_NONINTERACTIVE_CURSOR: - delete m_CursorNoninteractive; - m_CursorNoninteractive = new CBSprite(Game); - if (!m_CursorNoninteractive || FAILED(m_CursorNoninteractive->LoadFile((char *)params))) { - delete m_CursorNoninteractive; - m_CursorNoninteractive = NULL; + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(Game); + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; cmd = PARSERR_GENERIC; } break; @@ -860,19 +860,19 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PERSONAL_SAVEGAMES: - parser.ScanStr((char *)params, "%b", &m_PersonalizedSave); + parser.ScanStr((char *)params, "%b", &_personalizedSave); break; case TOKEN_SUBTITLES: - parser.ScanStr((char *)params, "%b", &m_Subtitles); + parser.ScanStr((char *)params, "%b", &_subtitles); break; case TOKEN_SUBTITLES_SPEED: - parser.ScanStr((char *)params, "%d", &m_SubtitlesSpeed); + parser.ScanStr((char *)params, "%d", &_subtitlesSpeed); break; case TOKEN_VIDEO_SUBTITLES: - parser.ScanStr((char *)params, "%b", &m_VideoSubtitles); + parser.ScanStr((char *)params, "%b", &_videoSubtitles); break; case TOKEN_PROPERTY: @@ -884,71 +884,71 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_THUMBNAIL_WIDTH: - parser.ScanStr((char *)params, "%d", &m_ThumbnailWidth); + parser.ScanStr((char *)params, "%d", &_thumbnailWidth); break; case TOKEN_THUMBNAIL_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_ThumbnailHeight); + parser.ScanStr((char *)params, "%d", &_thumbnailHeight); break; case TOKEN_INDICATOR_X: - parser.ScanStr((char *)params, "%d", &m_IndicatorX); + parser.ScanStr((char *)params, "%d", &_indicatorX); break; case TOKEN_INDICATOR_Y: - parser.ScanStr((char *)params, "%d", &m_IndicatorY); + parser.ScanStr((char *)params, "%d", &_indicatorY); break; case TOKEN_INDICATOR_COLOR: { int r, g, b, a; parser.ScanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - m_IndicatorColor = DRGBA(r, g, b, a); + _indicatorColor = DRGBA(r, g, b, a); } break; case TOKEN_INDICATOR_WIDTH: - parser.ScanStr((char *)params, "%d", &m_IndicatorWidth); + parser.ScanStr((char *)params, "%d", &_indicatorWidth); break; case TOKEN_INDICATOR_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_IndicatorHeight); + parser.ScanStr((char *)params, "%d", &_indicatorHeight); break; case TOKEN_SAVE_IMAGE: - CBUtils::SetString(&m_SaveImageName, (char *)params); + CBUtils::SetString(&_saveImageName, (char *)params); break; case TOKEN_SAVE_IMAGE_X: - parser.ScanStr((char *)params, "%d", &m_SaveImageX); + parser.ScanStr((char *)params, "%d", &_saveImageX); break; case TOKEN_SAVE_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &m_SaveImageY); + parser.ScanStr((char *)params, "%d", &_saveImageY); break; case TOKEN_LOAD_IMAGE: - CBUtils::SetString(&m_LoadImageName, (char *)params); + CBUtils::SetString(&_loadImageName, (char *)params); break; case TOKEN_LOAD_IMAGE_X: - parser.ScanStr((char *)params, "%d", &m_LoadImageX); + parser.ScanStr((char *)params, "%d", &_loadImageX); break; case TOKEN_LOAD_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &m_LoadImageY); + parser.ScanStr((char *)params, "%d", &_loadImageY); break; case TOKEN_LOCAL_SAVE_DIR: - CBUtils::SetString(&m_LocalSaveDir, (char *)params); + CBUtils::SetString(&_localSaveDir, (char *)params); break; case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.ScanStr((char *)params, "%b", &m_CompatKillMethodThreads); + parser.ScanStr((char *)params, "%b", &_compatKillMethodThreads); break; } } - if (!m_SystemFont) m_SystemFont = Game->m_FontStorage->AddFont("system_font.fnt"); + if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("syste_font.fnt"); if (cmd == PARSERR_TOKENNOTFOUND) { @@ -1023,7 +1023,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (Val->IsNULL()) ClearOld = true; else ClearOld = Val->GetBool(); - if (FAILED(m_StringTable->LoadFile(Filename, ClearOld))) + if (FAILED(_stringTable->LoadFile(Filename, ClearOld))) Stack->PushBool(false); else Stack->PushBool(true); @@ -1076,7 +1076,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); CUIWindow *win = new CUIWindow(Game); if (win && SUCCEEDED(win->LoadFile(Stack->Pop()->GetString()))) { - m_Windows.Add(win); + _windows.Add(win); RegisterObject(win); Stack->PushNative(win, true); } else { @@ -1095,7 +1095,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CScValue *val = Stack->Pop(); char *str = new char[strlen(val->GetString()) + 1]; strcpy(str, val->GetString()); - m_StringTable->Expand(&str); + _stringTable->Expand(&str); Stack->PushString(str); delete [] str; return S_OK; @@ -1187,8 +1187,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) Stack->PushNULL(); else { - if (!m_Music[Channel] || !m_Music[Channel]->m_SoundFilename) Stack->PushNULL(); - else Stack->PushString(m_Music[Channel]->m_SoundFilename); + if (!_music[Channel] || !_music[Channel]->_soundFilename) Stack->PushNULL(); + else Stack->PushString(_music[Channel]->_soundFilename); } return S_OK; } @@ -1223,8 +1223,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Channel = Stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushInt(0); - else Stack->PushInt(m_Music[Channel]->GetPositionTime()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); + else Stack->PushInt(_music[Channel]->GetPositionTime()); return S_OK; } @@ -1239,8 +1239,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Channel = Stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushBool(false); - else Stack->PushBool(m_Music[Channel]->IsPlaying()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); + else Stack->PushBool(_music[Channel]->IsPlaying()); return S_OK; } @@ -1256,9 +1256,9 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } int Volume = Stack->Pop()->GetInt(); - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushBool(false); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); else { - if (FAILED(m_Music[Channel]->SetVolume(Volume))) Stack->PushBool(false); + if (FAILED(_music[Channel]->SetVolume(Volume))) Stack->PushBool(false); else Stack->PushBool(true); } return S_OK; @@ -1275,8 +1275,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Channel = Stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !m_Music[Channel]) Stack->PushInt(0); - else Stack->PushInt(m_Music[Channel]->GetVolume()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); + else Stack->PushInt(_music[Channel]->GetVolume()); return S_OK; } @@ -1291,19 +1291,19 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS uint32 FadeLength = (uint32)Stack->Pop()->GetInt(0); bool Swap = Stack->Pop()->GetBool(true); - if (m_MusicCrossfadeRunning) { + if (_musicCrossfadeRunning) { Script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); Stack->PushBool(false); return S_OK; } - m_MusicCrossfadeStartTime = m_LiveTimer; - m_MusicCrossfadeChannel1 = Channel1; - m_MusicCrossfadeChannel2 = Channel2; - m_MusicCrossfadeLength = FadeLength; - m_MusicCrossfadeSwap = Swap; + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = Channel1; + _musicCrossfadeChannel2 = Channel2; + _musicCrossfadeLength = FadeLength; + _musicCrossfadeSwap = Swap; - m_MusicCrossfadeRunning = true; + _musicCrossfadeRunning = true; Stack->PushBool(true); return S_OK; @@ -1336,12 +1336,12 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS int x = Stack->Pop()->GetInt(); int y = Stack->Pop()->GetInt(); x = std::max(x, 0); - x = std::min(x, m_Renderer->m_Width); + x = std::min(x, _renderer->_width); y = std::max(y, 0); - y = std::min(y, m_Renderer->m_Height); + y = std::min(y, _renderer->_height); POINT p; - p.x = x + m_Renderer->m_DrawOffsetX; - p.y = y + m_Renderer->m_DrawOffsetY; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; CBPlatform::SetCursorPos(p.x, p.y); @@ -1362,7 +1362,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (right < left) CBUtils::Swap(&left, &right); if (bottom < top) CBUtils::Swap(&top, &bottom); - CBPlatform::SetRect(&m_MouseLockRect, left, top, right, bottom); + CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); Stack->PushNULL(); return S_OK; @@ -1394,7 +1394,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "QuitGame") == 0) { Stack->CorrectParams(0); Stack->PushNULL(); - m_Quitting = true; + _quitting = true; return S_OK; } @@ -1405,7 +1405,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(2); char *Key = Stack->Pop()->GetString(); int Val = Stack->Pop()->GetInt(); - m_Registry->WriteInt("PrivateSettings", Key, Val); + _registry->WriteInt("PrivateSettings", Key, Val); Stack->PushNULL(); return S_OK; } @@ -1417,7 +1417,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(2); char *Key = Stack->Pop()->GetString(); int InitVal = Stack->Pop()->GetInt(); - Stack->PushInt(m_Registry->ReadInt("PrivateSettings", Key, InitVal)); + Stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); return S_OK; } @@ -1428,7 +1428,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(2); char *Key = Stack->Pop()->GetString(); char *Val = Stack->Pop()->GetString(); - m_Registry->WriteString("PrivateSettings", Key, Val); + _registry->WriteString("PrivateSettings", Key, Val); Stack->PushNULL(); return S_OK; } @@ -1440,7 +1440,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(2); char *Key = Stack->Pop()->GetString(); char *InitVal = Stack->Pop()->GetString(); - AnsiString val = m_Registry->ReadString("PrivateSettings", Key, InitVal); + AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); Stack->PushString((char *)val.c_str()); return S_OK; } @@ -1470,8 +1470,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadGame") == 0) { Stack->CorrectParams(1); - m_ScheduledLoadSlot = Stack->Pop()->GetInt(); - m_Loading = true; + _scheduledLoadSlot = Stack->Pop()->GetInt(); + _loading = true; Stack->PushBool(false); Script->Sleep(0); return S_OK; @@ -1516,7 +1516,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { Stack->CorrectParams(1); - Game->m_SoundMgr->SetVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1526,7 +1526,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { Stack->CorrectParams(1); - Game->m_SoundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1536,7 +1536,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { Stack->CorrectParams(1); - Game->m_SoundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1546,7 +1546,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { Stack->CorrectParams(1); - Game->m_SoundMgr->SetMasterVolumePercent((byte )Stack->Pop()->GetInt()); + Game->_soundMgr->SetMasterVolumePercent((byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1556,7 +1556,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_SFX)); + Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_SFX)); return S_OK; } @@ -1565,7 +1565,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_SPEECH)); + Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_SPEECH)); return S_OK; } @@ -1574,7 +1574,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_SoundMgr->GetVolumePercent(SOUND_MUSIC)); + Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_MUSIC)); return S_OK; } @@ -1583,7 +1583,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_SoundMgr->GetMasterVolumePercent()); + Stack->PushInt(_soundMgr->GetMasterVolumePercent()); return S_OK; } @@ -1603,8 +1603,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetActiveCursor") == 0) { Stack->CorrectParams(0); - if (!m_ActiveCursor || !m_ActiveCursor->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ActiveCursor->m_Filename); + if (!_activeCursor || !_activeCursor->_filename) Stack->PushNULL(); + else Stack->PushString(_activeCursor->_filename); return S_OK; } @@ -1614,8 +1614,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetActiveCursorObject") == 0) { Stack->CorrectParams(0); - if (!m_ActiveCursor) Stack->PushNULL(); - else Stack->PushNative(m_ActiveCursor, true); + if (!_activeCursor) Stack->PushNULL(); + else Stack->PushNative(_activeCursor, true); return S_OK; } @@ -1625,8 +1625,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveActiveCursor") == 0) { Stack->CorrectParams(0); - delete m_ActiveCursor; - m_ActiveCursor = NULL; + delete _activeCursor; + _activeCursor = NULL; Stack->PushNULL(); return S_OK; @@ -1638,7 +1638,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "HasActiveCursor") == 0) { Stack->CorrectParams(0); - if (m_ActiveCursor) Stack->PushBool(true); + if (_activeCursor) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -1651,10 +1651,10 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); - CBFile *File = m_FileManager->OpenFile(Filename, false); + CBFile *File = _fileManager->OpenFile(Filename, false); if (!File) Stack->PushBool(false); else { - m_FileManager->CloseFile(File); + _fileManager->CloseFile(File); Stack->PushBool(true); } return S_OK; @@ -1673,8 +1673,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); - m_Fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(m_Fader); + _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); return S_OK; @@ -1693,8 +1693,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); - m_Fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(m_Fader); + _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); return S_OK; @@ -1705,7 +1705,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFadeColor") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_Fader->GetCurrentColor()); + Stack->PushInt(_fader->GetCurrentColor()); return S_OK; } @@ -1720,7 +1720,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS int FileNum = 0; while (true) { - sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? m_Name : Val->GetString(), FileNum); + sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); FILE *f = fopen(Filename, "rb"); if (!f) break; else fclose(f); @@ -1728,7 +1728,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } bool ret = false; - CBImage *Image = Game->m_Renderer->TakeScreenshot(); + CBImage *Image = Game->_renderer->TakeScreenshot(); if (Image) { ret = SUCCEEDED(Image->SaveBMPFile(Filename)); delete Image; @@ -1744,11 +1744,11 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "ScreenshotEx") == 0) { Stack->CorrectParams(3); char *Filename = Stack->Pop()->GetString(); - int SizeX = Stack->Pop()->GetInt(m_Renderer->m_Width); - int SizeY = Stack->Pop()->GetInt(m_Renderer->m_Height); + int SizeX = Stack->Pop()->GetInt(_renderer->_width); + int SizeY = Stack->Pop()->GetInt(_renderer->_height); bool ret = false; - CBImage *Image = Game->m_Renderer->TakeScreenshot(); + CBImage *Image = Game->_renderer->TakeScreenshot(); if (Image) { ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); @@ -1767,7 +1767,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CScValue *Val = Stack->Pop(); CUIWindow *Win = new CUIWindow(Game); - m_Windows.Add(Win); + _windows.Add(Win); RegisterObject(Win); if (!Val->IsNULL()) Win->SetName(Val->GetString()); Stack->PushNative(Win, true); @@ -1780,9 +1780,9 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "DeleteWindow") == 0) { Stack->CorrectParams(1); CBObject *Obj = (CBObject *)Stack->Pop()->GetNative(); - for (int i = 0; i < m_Windows.GetSize(); i++) { - if (m_Windows[i] == Obj) { - UnregisterObject(m_Windows[i]); + for (int i = 0; i < _windows.GetSize(); i++) { + if (_windows[i] == Obj) { + UnregisterObject(_windows[i]); Stack->PushBool(true); return S_OK; } @@ -1797,8 +1797,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "OpenDocument") == 0) { #ifdef __WIN32__ Stack->CorrectParams(1); - if (!m_Renderer->m_Windowed) CBPlatform::ShowWindow(m_Renderer->m_Window, SW_MINIMIZE); - HINSTANCE i = CBPlatform::ShellExecute(m_Renderer->m_Window, "open", Stack->Pop()->GetString(), NULL, NULL, SW_MAXIMIZE); + if (!_renderer->_windowed) CBPlatform::ShowWindow(_renderer->_window, SW_MINIMIZE); + HINSTANCE i = CBPlatform::ShellExecute(_renderer->_window, "open", Stack->Pop()->GetString(), NULL, NULL, SW_MAXIMIZE); Stack->PushBool((int)i > 32); #else Stack->CorrectParams(0); @@ -1823,14 +1823,14 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "SetLoadingScreen") == 0) { Stack->CorrectParams(3); CScValue *Val = Stack->Pop(); - m_LoadImageX = Stack->Pop()->GetInt(); - m_LoadImageY = Stack->Pop()->GetInt(); + _loadImageX = Stack->Pop()->GetInt(); + _loadImageY = Stack->Pop()->GetInt(); if (Val->IsNULL()) { - delete[] m_LoadImageName; - m_LoadImageName = NULL; + delete[] _loadImageName; + _loadImageName = NULL; } else { - CBUtils::SetString(&m_LoadImageName, Val->GetString()); + CBUtils::SetString(&_loadImageName, Val->GetString()); } Stack->PushNULL(); return S_OK; @@ -1842,14 +1842,14 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "SetSavingScreen") == 0) { Stack->CorrectParams(3); CScValue *Val = Stack->Pop(); - m_SaveImageX = Stack->Pop()->GetInt(); - m_SaveImageY = Stack->Pop()->GetInt(); + _saveImageX = Stack->Pop()->GetInt(); + _saveImageY = Stack->Pop()->GetInt(); if (Val->IsNULL()) { - delete[] m_SaveImageName; - m_SaveImageName = NULL; + delete[] _saveImageName; + _saveImageName = NULL; } else { - CBUtils::SetString(&m_SaveImageName, Val->GetString()); + CBUtils::SetString(&_saveImageName, Val->GetString()); } Stack->PushNULL(); return S_OK; @@ -1871,8 +1871,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveWaitCursor") == 0) { Stack->CorrectParams(0); - delete m_CursorNoninteractive; - m_CursorNoninteractive = NULL; + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; Stack->PushNULL(); @@ -1884,8 +1884,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetWaitCursor") == 0) { Stack->CorrectParams(0); - if (!m_CursorNoninteractive || !m_CursorNoninteractive->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_CursorNoninteractive->m_Filename); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorNoninteractive->_filename); return S_OK; } @@ -1895,8 +1895,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetWaitCursorObject") == 0) { Stack->CorrectParams(0); - if (!m_CursorNoninteractive) Stack->PushNULL(); - else Stack->PushNative(m_CursorNoninteractive, true); + if (!_cursorNoninteractive) Stack->PushNULL(); + else Stack->PushNative(_cursorNoninteractive, true); return S_OK; } @@ -1906,7 +1906,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ClearScriptCache") == 0) { Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(m_ScEngine->EmptyScriptCache())); + Stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); return S_OK; } @@ -1917,19 +1917,19 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(4); char *Filename = Stack->Pop()->GetString(); - m_LoadingIconX = Stack->Pop()->GetInt(); - m_LoadingIconY = Stack->Pop()->GetInt(); - m_LoadingIconPersistent = Stack->Pop()->GetBool(); - - delete m_LoadingIcon; - m_LoadingIcon = new CBSprite(this); - if (!m_LoadingIcon || FAILED(m_LoadingIcon->LoadFile(Filename))) { - delete m_LoadingIcon; - m_LoadingIcon = NULL; + _loadingIconX = Stack->Pop()->GetInt(); + _loadingIconY = Stack->Pop()->GetInt(); + _loadingIconPersistent = Stack->Pop()->GetBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || FAILED(_loadingIcon->LoadFile(Filename))) { + delete _loadingIcon; + _loadingIcon = NULL; } else { DisplayContent(false, true); - Game->m_Renderer->Flip(); - Game->m_Renderer->InitLoop(); + Game->_renderer->Flip(); + Game->_renderer->InitLoop(); } Stack->PushNULL(); @@ -1941,8 +1941,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HideLoadingIcon") == 0) { Stack->CorrectParams(0); - delete m_LoadingIcon; - m_LoadingIcon = NULL; + delete _loadingIcon; + _loadingIcon = NULL; Stack->PushNULL(); return S_OK; } @@ -1954,7 +1954,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); - m_Renderer->DumpData(Filename); + _renderer->DumpData(Filename); Stack->PushNULL(); return S_OK; @@ -1978,11 +1978,11 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StoreSaveThumbnail") == 0) { Stack->CorrectParams(0); - delete m_CachedThumbnail; - m_CachedThumbnail = new CBSaveThumbHelper(this); - if (FAILED(m_CachedThumbnail->StoreThumbnail())) { - delete m_CachedThumbnail; - m_CachedThumbnail = NULL; + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (FAILED(_cachedThumbnail->StoreThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -1994,8 +1994,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DeleteSaveThumbnail") == 0) { Stack->CorrectParams(0); - delete m_CachedThumbnail; - m_CachedThumbnail = NULL; + delete _cachedThumbnail; + _cachedThumbnail = NULL; Stack->PushNULL(); return S_OK; @@ -2009,7 +2009,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS char *Filename = Stack->Pop()->GetString(); bool AsHex = Stack->Pop()->GetBool(false); - CBFile *File = m_FileManager->OpenFile(Filename, false); + CBFile *File = _fileManager->OpenFile(Filename, false); if (File) { crc remainder = crc_initialize(); byte Buf[1024]; @@ -2033,7 +2033,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } else Stack->PushInt(checksum); - m_FileManager->CloseFile(File); + _fileManager->CloseFile(File); File = NULL; } else Stack->PushNULL(); @@ -2045,7 +2045,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "EnableScriptProfiling") == 0) { Stack->CorrectParams(0); - m_ScEngine->EnableProfiling(); + _scEngine->EnableProfiling(); Stack->PushNULL(); return S_OK; @@ -2056,7 +2056,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DisableScriptProfiling") == 0) { Stack->CorrectParams(0); - m_ScEngine->DisableProfiling(); + _scEngine->DisableProfiling(); Stack->PushNULL(); return S_OK; @@ -2094,124 +2094,124 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// CScValue *CBGame::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("game"); - return m_ScValue; + _scValue->SetString("game"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Hwnd (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Hwnd") == 0) { - m_ScValue->SetInt((int)m_Renderer->m_Window); - return m_ScValue; + _scValue->SetInt((int)_renderer->_window); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CurrentTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CurrentTime") == 0) { - m_ScValue->SetInt((int)m_Timer); - return m_ScValue; + _scValue->SetInt((int)_timer); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WindowsTime") == 0) { - m_ScValue->SetInt((int)CBPlatform::GetTime()); - return m_ScValue; + _scValue->SetInt((int)CBPlatform::GetTime()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // WindowedMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WindowedMode") == 0) { - m_ScValue->SetBool(m_Renderer->m_Windowed); - return m_ScValue; + _scValue->SetBool(_renderer->_windowed); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MouseX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseX") == 0) { - m_ScValue->SetInt(m_MousePos.x); - return m_ScValue; + _scValue->SetInt(_mousePos.x); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MouseY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseY") == 0) { - m_ScValue->SetInt(m_MousePos.y); - return m_ScValue; + _scValue->SetInt(_mousePos.y); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MainObject") == 0) { - m_ScValue->SetNative(m_MainObject, true); - return m_ScValue; + _scValue->SetNative(_mainObject, true); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ActiveObject (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ActiveObject") == 0) { - m_ScValue->SetNative(m_ActiveObject, true); - return m_ScValue; + _scValue->SetNative(_activeObject, true); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScreenWidth (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScreenWidth") == 0) { - m_ScValue->SetInt(m_Renderer->m_Width); - return m_ScValue; + _scValue->SetInt(_renderer->_width); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScreenHeight (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScreenHeight") == 0) { - m_ScValue->SetInt(m_Renderer->m_Height); - return m_ScValue; + _scValue->SetInt(_renderer->_height); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Interactive") == 0) { - m_ScValue->SetBool(m_Interactive); - return m_ScValue; + _scValue->SetBool(_interactive); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DebugMode") == 0) { - m_ScValue->SetBool(m_DEBUG_DebugMode); - return m_ScValue; + _scValue->SetBool(_dEBUG_DebugMode); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundAvailable (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundAvailable") == 0) { - m_ScValue->SetBool(m_SoundMgr->m_SoundAvailable); - return m_ScValue; + _scValue->SetBool(_soundMgr->_soundAvailable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -2219,8 +2219,8 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_SFX)); - return m_ScValue; + _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_SFX)); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -2228,8 +2228,8 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_SPEECH)); - return m_ScValue; + _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_SPEECH)); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -2237,8 +2237,8 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - m_ScValue->SetInt(m_SoundMgr->GetVolumePercent(SOUND_MUSIC)); - return m_ScValue; + _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_MUSIC)); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -2246,97 +2246,97 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - m_ScValue->SetInt(m_SoundMgr->GetMasterVolumePercent()); - return m_ScValue; + _scValue->SetInt(_soundMgr->GetMasterVolumePercent()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Keyboard") == 0) { - if (m_KeyboardState) m_ScValue->SetNative(m_KeyboardState, true); - else m_ScValue->SetNULL(); + if (_keyboardState) _scValue->SetNative(_keyboardState, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Subtitles") == 0) { - m_ScValue->SetBool(m_Subtitles); - return m_ScValue; + _scValue->SetBool(_subtitles); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesSpeed") == 0) { - m_ScValue->SetInt(m_SubtitlesSpeed); - return m_ScValue; + _scValue->SetInt(_subtitlesSpeed); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "VideoSubtitles") == 0) { - m_ScValue->SetBool(m_VideoSubtitles); - return m_ScValue; + _scValue->SetBool(_videoSubtitles); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // FPS (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FPS") == 0) { - m_ScValue->SetInt(m_Fps); - return m_ScValue; + _scValue->SetInt(_fps); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AcceleratedMode / Accelerated (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AcceleratedMode") == 0 || strcmp(Name, "Accelerated") == 0) { - m_ScValue->SetBool(m_UseD3D); - return m_ScValue; + _scValue->SetBool(_useD3D); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextEncoding") == 0) { - m_ScValue->SetInt(m_TextEncoding); - return m_ScValue; + _scValue->SetInt(_textEncoding); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TextRTL ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextRTL") == 0) { - m_ScValue->SetBool(m_TextRTL); - return m_ScValue; + _scValue->SetBool(_textRTL); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundBufferSize ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundBufferSize") == 0) { - m_ScValue->SetInt(m_SoundBufferSizeSec); - return m_ScValue; + _scValue->SetInt(_soundBufferSizeSec); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SuspendedRendering ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SuspendedRendering") == 0) { - m_ScValue->SetBool(m_SuspendedRendering); - return m_ScValue; + _scValue->SetBool(_suspendedRendering); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SuppressScriptErrors") == 0) { - m_ScValue->SetBool(m_SuppressScriptErrors); - return m_ScValue; + _scValue->SetBool(_suppressScriptErrors); + return _scValue; } @@ -2344,72 +2344,72 @@ CScValue *CBGame::ScGetProperty(char *Name) { // Frozen ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Frozen") == 0) { - m_ScValue->SetBool(m_State == GAME_FROZEN); - return m_ScValue; + _scValue->SetBool(_state == GAME_FROZEN); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccTTSEnabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccTTSEnabled") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccTTSTalk ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccTTSTalk") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccTTSCaptions ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccTTSCaptions") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccTTSKeypress ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccTTSKeypress") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccKeyboardEnabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccKeyboardEnabled") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccKeyboardCursorSkip ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccKeyboardCursorSkip") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccKeyboardPause ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccKeyboardPause") == 0) { - m_ScValue->SetBool(false); - return m_ScValue; + _scValue->SetBool(false); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AutorunDisabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutorunDisabled") == 0) { - m_ScValue->SetBool(m_AutorunDisabled); - return m_ScValue; + _scValue->SetBool(_autorunDisabled); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -2417,66 +2417,66 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SaveDirectory") == 0) { AnsiString dataDir = GetDataDir(); - m_ScValue->SetString((char *)dataDir.c_str()); - return m_ScValue; + _scValue->SetString((char *)dataDir.c_str()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoSaveOnExit") == 0) { - m_ScValue->SetBool(m_AutoSaveOnExit); - return m_ScValue; + _scValue->SetBool(_autoSaveOnExit); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoSaveSlot") == 0) { - m_ScValue->SetInt(m_AutoSaveSlot); - return m_ScValue; + _scValue->SetInt(_autoSaveSlot); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CursorHidden ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorHidden") == 0) { - m_ScValue->SetBool(m_CursorHidden); - return m_ScValue; + _scValue->SetBool(_cursorHidden); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Platform (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Platform") == 0) { - m_ScValue->SetString(CBPlatform::GetPlatformName().c_str()); - return m_ScValue; + _scValue->SetString(CBPlatform::GetPlatformName().c_str()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DeviceType") == 0) { - m_ScValue->SetString(GetDeviceType().c_str()); - return m_ScValue; + _scValue->SetString(GetDeviceType().c_str()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MostRecentSaveSlot") == 0) { - m_ScValue->SetInt(m_Registry->ReadInt("System", "MostRecentSaveSlot", -1)); - return m_ScValue; + _scValue->SetInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Store (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Store") == 0) { - if (m_Store) m_ScValue->SetNative(m_Store, true); - else m_ScValue->SetNULL(); + if (_store) _scValue->SetNative(_store, true); + else _scValue->SetNULL(); - return m_ScValue; + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -2498,7 +2498,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // MouseX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseX") == 0) { - m_MousePos.x = Value->GetInt(); + _mousePos.x = Value->GetInt(); ResetMousePos(); return S_OK; } @@ -2507,7 +2507,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // MouseY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseY") == 0) { - m_MousePos.y = Value->GetInt(); + _mousePos.y = Value->GetInt(); ResetMousePos(); return S_OK; } @@ -2526,7 +2526,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MainObject") == 0) { CBScriptable *obj = Value->GetNative(); - if (obj == NULL || ValidObject((CBObject *)obj)) m_MainObject = (CBObject *)obj; + if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; return S_OK; } @@ -2543,7 +2543,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->m_SoundMgr->SetVolumePercent(SOUND_SFX, (byte )Value->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_SFX, (byte )Value->GetInt()); return S_OK; } @@ -2552,7 +2552,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->m_SoundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); return S_OK; } @@ -2561,7 +2561,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->m_SoundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); + Game->_soundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); return S_OK; } @@ -2570,7 +2570,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->m_SoundMgr->SetMasterVolumePercent((byte )Value->GetInt()); + Game->_soundMgr->SetMasterVolumePercent((byte )Value->GetInt()); return S_OK; } @@ -2578,7 +2578,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // Subtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Subtitles") == 0) { - m_Subtitles = Value->GetBool(); + _subtitles = Value->GetBool(); return S_OK; } @@ -2586,7 +2586,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SubtitlesSpeed") == 0) { - m_SubtitlesSpeed = Value->GetInt(); + _subtitlesSpeed = Value->GetInt(); return S_OK; } @@ -2594,7 +2594,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // VideoSubtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "VideoSubtitles") == 0) { - m_VideoSubtitles = Value->GetBool(); + _videoSubtitles = Value->GetBool(); return S_OK; } @@ -2605,7 +2605,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { int Enc = Value->GetInt(); if (Enc < 0) Enc = 0; if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - m_TextEncoding = (TTextEncoding)Enc; + _textEncoding = (TTextEncoding)Enc; return S_OK; } @@ -2613,7 +2613,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // TextRTL ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextRTL") == 0) { - m_TextRTL = Value->GetBool(); + _textRTL = Value->GetBool(); return S_OK; } @@ -2621,8 +2621,8 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // SoundBufferSize ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundBufferSize") == 0) { - m_SoundBufferSizeSec = Value->GetInt(); - m_SoundBufferSizeSec = std::max(3, m_SoundBufferSizeSec); + _soundBufferSizeSec = Value->GetInt(); + _soundBufferSizeSec = std::max(3, _soundBufferSizeSec); return S_OK; } @@ -2630,7 +2630,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // SuspendedRendering ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SuspendedRendering") == 0) { - m_SuspendedRendering = Value->GetBool(); + _suspendedRendering = Value->GetBool(); return S_OK; } @@ -2638,7 +2638,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SuppressScriptErrors") == 0) { - m_SuppressScriptErrors = Value->GetBool(); + _suppressScriptErrors = Value->GetBool(); return S_OK; } @@ -2646,7 +2646,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // AutorunDisabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutorunDisabled") == 0) { - m_AutorunDisabled = Value->GetBool(); + _autorunDisabled = Value->GetBool(); return S_OK; } @@ -2654,7 +2654,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoSaveOnExit") == 0) { - m_AutoSaveOnExit = Value->GetBool(); + _autoSaveOnExit = Value->GetBool(); return S_OK; } @@ -2662,7 +2662,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AutoSaveSlot") == 0) { - m_AutoSaveSlot = Value->GetInt(); + _autoSaveSlot = Value->GetInt(); return S_OK; } @@ -2670,7 +2670,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { // CursorHidden ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorHidden") == 0) { - m_CursorHidden = Value->GetBool(); + _cursorHidden = Value->GetBool(); return S_OK; } @@ -2688,15 +2688,15 @@ char *CBGame::ScToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DisplayQuickMsg() { - if (m_QuickMessages.GetSize() == 0 || !m_SystemFont) return S_OK; + if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; int i; // update - for (i = 0; i < m_QuickMessages.GetSize(); i++) { - if (m_CurrentTime - m_QuickMessages[i]->m_StartTime >= QUICK_MSG_DURATION) { - delete m_QuickMessages[i]; - m_QuickMessages.RemoveAt(i); + for (i = 0; i < _quickMessages.GetSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.RemoveAt(i); i--; } } @@ -2704,9 +2704,9 @@ HRESULT CBGame::DisplayQuickMsg() { int PosY = 20; // display - for (i = 0; i < m_QuickMessages.GetSize(); i++) { - m_SystemFont->DrawText((byte *)m_QuickMessages[i]->GetText(), 0, PosY, m_Renderer->m_Width); - PosY += m_SystemFont->GetTextHeight((byte *)m_QuickMessages[i]->GetText(), m_Renderer->m_Width); + for (i = 0; i < _quickMessages.GetSize(); i++) { + _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); + PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); } return S_OK; } @@ -2715,11 +2715,11 @@ HRESULT CBGame::DisplayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// void CBGame::QuickMessage(char *Text) { - if (m_QuickMessages.GetSize() >= MAX_QUICK_MSG) { - delete m_QuickMessages[0]; - m_QuickMessages.RemoveAt(0); + if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.RemoveAt(0); } - m_QuickMessages.Add(new CBQuickMsg(Game, Text)); + _quickMessages.Add(new CBQuickMsg(Game, Text)); } @@ -2738,7 +2738,7 @@ void CBGame::QuickMessageForm(LPSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::RegisterObject(CBObject *Object) { - m_RegObjects.Add(Object); + _regObjects.Add(Object); return S_OK; } @@ -2750,30 +2750,30 @@ HRESULT CBGame::UnregisterObject(CBObject *Object) { int i; // is it a window? - for (i = 0; i < m_Windows.GetSize(); i++) { - if ((CBObject *)m_Windows[i] == Object) { - m_Windows.RemoveAt(i); + for (i = 0; i < _windows.GetSize(); i++) { + if ((CBObject *)_windows[i] == Object) { + _windows.RemoveAt(i); // get new focused window - if (m_FocusedWindow == Object) m_FocusedWindow = NULL; + if (_focusedWindow == Object) _focusedWindow = NULL; break; } } // is it active object? - if (m_ActiveObject == Object) m_ActiveObject = NULL; + if (_activeObject == Object) _activeObject = NULL; // is it main object? - if (m_MainObject == Object) m_MainObject = NULL; + if (_mainObject == Object) _mainObject = NULL; - if (m_Store) m_Store->OnObjectDestroyed(Object); + if (_store) _store->OnObjectDestroyed(Object); // destroy object - for (i = 0; i < m_RegObjects.GetSize(); i++) { - if (m_RegObjects[i] == Object) { - m_RegObjects.RemoveAt(i); - if (!m_LoadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); + for (i = 0; i < _regObjects.GetSize(); i++) { + if (_regObjects[i] == Object) { + _regObjects.RemoveAt(i); + if (!_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); delete Object; return S_OK; } @@ -2787,8 +2787,8 @@ HRESULT CBGame::UnregisterObject(CBObject *Object) { void CBGame::InvalidateValues(void *Value, void *Data) { CScValue *val = (CScValue *)Value; if (val->IsNative() && val->GetNative() == Data) { - if (!val->m_Persistent && ((CBScriptable *)Data)->m_RefCount == 1) { - ((CBScriptable *)Data)->m_RefCount++; + if (!val->_persistent && ((CBScriptable *)Data)->_refCount == 1) { + ((CBScriptable *)Data)->_refCount++; } val->SetNative(NULL); val->SetNULL(); @@ -2802,8 +2802,8 @@ bool CBGame::ValidObject(CBObject *Object) { if (!Object) return false; if (Object == this) return true; - for (int i = 0; i < m_RegObjects.GetSize(); i++) { - if (m_RegObjects[i] == Object) return true; + for (int i = 0; i < _regObjects.GetSize(); i++) { + if (_regObjects[i] == Object) return true; } return false; } @@ -2811,44 +2811,44 @@ bool CBGame::ValidObject(CBObject *Object) { ////////////////////////////////////////////////////////////////////////// void CBGame::PublishNatives() { - if (!m_ScEngine || !m_ScEngine->m_CompilerAvailable) return; - - m_ScEngine->ExtDefineFunction("LOG"); - m_ScEngine->ExtDefineFunction("String"); - m_ScEngine->ExtDefineFunction("MemBuffer"); - m_ScEngine->ExtDefineFunction("File"); - m_ScEngine->ExtDefineFunction("Date"); - m_ScEngine->ExtDefineFunction("Array"); - m_ScEngine->ExtDefineFunction("TcpClient"); - m_ScEngine->ExtDefineFunction("Object"); - //m_ScEngine->ExtDefineFunction("Game"); - m_ScEngine->ExtDefineFunction("Sleep"); - m_ScEngine->ExtDefineFunction("WaitFor"); - m_ScEngine->ExtDefineFunction("Random"); - m_ScEngine->ExtDefineFunction("SetScriptTimeSlice"); - m_ScEngine->ExtDefineFunction("MakeRGBA"); - m_ScEngine->ExtDefineFunction("MakeRGB"); - m_ScEngine->ExtDefineFunction("MakeHSL"); - m_ScEngine->ExtDefineFunction("RGB"); - m_ScEngine->ExtDefineFunction("GetRValue"); - m_ScEngine->ExtDefineFunction("GetGValue"); - m_ScEngine->ExtDefineFunction("GetBValue"); - m_ScEngine->ExtDefineFunction("GetAValue"); - m_ScEngine->ExtDefineFunction("GetHValue"); - m_ScEngine->ExtDefineFunction("GetSValue"); - m_ScEngine->ExtDefineFunction("GetLValue"); - m_ScEngine->ExtDefineFunction("Debug"); - - m_ScEngine->ExtDefineFunction("ToString"); - m_ScEngine->ExtDefineFunction("ToInt"); - m_ScEngine->ExtDefineFunction("ToBool"); - m_ScEngine->ExtDefineFunction("ToFloat"); - - m_ScEngine->ExtDefineVariable("Game"); - m_ScEngine->ExtDefineVariable("Math"); - m_ScEngine->ExtDefineVariable("Directory"); - m_ScEngine->ExtDefineVariable("self"); - m_ScEngine->ExtDefineVariable("this"); + if (!_scEngine || !_scEngine->_compilerAvailable) return; + + _scEngine->ExtDefineFunction("LOG"); + _scEngine->ExtDefineFunction("String"); + _scEngine->ExtDefineFunction("MemBuffer"); + _scEngine->ExtDefineFunction("File"); + _scEngine->ExtDefineFunction("Date"); + _scEngine->ExtDefineFunction("Array"); + _scEngine->ExtDefineFunction("TcpClient"); + _scEngine->ExtDefineFunction("Object"); + //_scEngine->ExtDefineFunction("Game"); + _scEngine->ExtDefineFunction("Sleep"); + _scEngine->ExtDefineFunction("WaitFor"); + _scEngine->ExtDefineFunction("Random"); + _scEngine->ExtDefineFunction("SetScriptTimeSlice"); + _scEngine->ExtDefineFunction("MakeRGBA"); + _scEngine->ExtDefineFunction("MakeRGB"); + _scEngine->ExtDefineFunction("MakeHSL"); + _scEngine->ExtDefineFunction("RGB"); + _scEngine->ExtDefineFunction("GetRValue"); + _scEngine->ExtDefineFunction("GetGValue"); + _scEngine->ExtDefineFunction("GetBValue"); + _scEngine->ExtDefineFunction("GetAValue"); + _scEngine->ExtDefineFunction("GetHValue"); + _scEngine->ExtDefineFunction("GetSValue"); + _scEngine->ExtDefineFunction("GetLValue"); + _scEngine->ExtDefineFunction("Debug"); + + _scEngine->ExtDefineFunction("ToString"); + _scEngine->ExtDefineFunction("ToInt"); + _scEngine->ExtDefineFunction("ToBool"); + _scEngine->ExtDefineFunction("ToFloat"); + + _scEngine->ExtDefineVariable("Game"); + _scEngine->ExtDefineVariable("Math"); + _scEngine->ExtDefineVariable("Directory"); + _scEngine->ExtDefineVariable("self"); + _scEngine->ExtDefineVariable("this"); } @@ -2964,7 +2964,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "SetScriptTimeSlice") == 0) { Stack->CorrectParams(1); - Script->m_TimeSlice = (uint32)Stack->Pop()->GetInt(); + Script->_timeSlice = (uint32)Stack->Pop()->GetInt(); Stack->PushNULL(); } @@ -3078,7 +3078,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "Debug") == 0) { Stack->CorrectParams(0); - if (Game->GetDebugMgr()->m_Enabled) { + if (Game->GetDebugMgr()->_enabled) { Game->GetDebugMgr()->OnScriptHitBreakpoint(Script); Script->Sleep(0); } @@ -3138,15 +3138,15 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::ShowCursor() { - if (m_CursorHidden) return S_OK; + if (_cursorHidden) return S_OK; - if (!m_Interactive && Game->m_State == GAME_RUNNING) { - if (m_CursorNoninteractive) return DrawCursor(m_CursorNoninteractive); + if (!_interactive && Game->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return DrawCursor(_cursorNoninteractive); } else { - if (m_ActiveObject && !FAILED(m_ActiveObject->ShowCursor())) return S_OK; + if (_activeObject && !FAILED(_activeObject->ShowCursor())) return S_OK; else { - if (m_ActiveObject && m_ActiveCursor && m_ActiveObject->GetExtendedFlag("usable")) return DrawCursor(m_ActiveCursor); - else if (m_Cursor) return DrawCursor(m_Cursor); + if (_activeObject && _activeCursor && _activeObject->GetExtendedFlag("usable")) return DrawCursor(_activeCursor); + else if (_cursor) return DrawCursor(_cursor); } } return E_FAIL; @@ -3164,20 +3164,20 @@ HRESULT CBGame::SaveGame(int slot, char *desc, bool quickSave) { HRESULT ret; - m_IndicatorDisplay = true; - m_IndicatorProgress = 0; + _indicatorDisplay = true; + _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); if (FAILED(ret = pm->InitSave(desc))) goto save_finish; if (!quickSave) { - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; - if (m_SaveImageName) { - m_SaveLoadImage = new CBSurfaceSDL(this); - - if (!m_SaveLoadImage || FAILED(m_SaveLoadImage->Create(m_SaveImageName, true, 0, 0, 0))) { - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = new CBSurfaceSDL(this); + + if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; } } } @@ -3186,14 +3186,14 @@ HRESULT CBGame::SaveGame(int slot, char *desc, bool quickSave) { if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; if (FAILED(ret = pm->SaveFile(Filename))) goto save_finish; - m_Registry->WriteInt("System", "MostRecentSaveSlot", slot); + _registry->WriteInt("System", "MostRecentSaveSlot", slot); save_finish: delete pm; - m_IndicatorDisplay = false; + _indicatorDisplay = false; - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; + delete _saveLoadImage; + _saveLoadImage = NULL; return ret; } @@ -3203,8 +3203,8 @@ save_finish: HRESULT CBGame::LoadGame(int Slot) { //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); - m_Loading = false; - m_ScheduledLoadSlot = -1; + _loading = false; + _scheduledLoadSlot = -1; char Filename[MAX_PATH + 1]; GetSaveSlotFilename(Slot, Filename); @@ -3220,23 +3220,23 @@ HRESULT CBGame::LoadGame(char *Filename) { HRESULT ret; - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; - if (m_LoadImageName) { - m_SaveLoadImage = new CBSurfaceSDL(this); + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = new CBSurfaceSDL(this); - if (!m_SaveLoadImage || FAILED(m_SaveLoadImage->Create(m_LoadImageName, true, 0, 0, 0))) { - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; + if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; } } - m_LoadInProgress = true; - m_IndicatorDisplay = true; - m_IndicatorProgress = 0; + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); - m_DEBUG_AbsolutePathWarning = false; + _dEBUG_AbsolutePathWarning = false; if (FAILED(ret = pm->InitLoad(Filename))) goto load_finish; //if(FAILED(ret = Cleanup())) goto load_finish; @@ -3249,19 +3249,19 @@ HRESULT CBGame::LoadGame(char *Filename) { Game->ApplyEvent("AfterLoad", true); DisplayContent(true, false); - //m_Renderer->Flip(); + //_renderer->Flip(); GetDebugMgr()->OnGameInit(); load_finish: - m_DEBUG_AbsolutePathWarning = true; + _dEBUG_AbsolutePathWarning = true; - m_IndicatorDisplay = false; + _indicatorDisplay = false; delete pm; - m_LoadInProgress = false; + _loadInProgress = false; - delete m_SaveLoadImage; - m_SaveLoadImage = NULL; + delete _saveLoadImage; + _saveLoadImage = NULL; //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); @@ -3277,8 +3277,8 @@ HRESULT CBGame::InitAfterLoad() { CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadFont, "CBFontTT", NULL); CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); - m_ScEngine->RefreshScriptBreakpoints(); - if (m_Store) m_Store->AfterLoad(); + _scEngine->RefreshScriptBreakpoints(); + if (_store) _store->AfterLoad(); return S_OK; } @@ -3318,21 +3318,21 @@ HRESULT CBGame::DisplayWindows(bool InGame) { int i; // did we lose focus? focus topmost window - if (m_FocusedWindow == NULL || !m_FocusedWindow->m_Visible || m_FocusedWindow->m_Disable) { - m_FocusedWindow = NULL; - for (i = m_Windows.GetSize() - 1; i >= 0; i--) { - if (m_Windows[i]->m_Visible && !m_Windows[i]->m_Disable) { - m_FocusedWindow = m_Windows[i]; + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (i = _windows.GetSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; break; } } } // display all windows - for (i = 0; i < m_Windows.GetSize(); i++) { - if (m_Windows[i]->m_Visible && m_Windows[i]->m_InGame == InGame) { + for (i = 0; i < _windows.GetSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == InGame) { - res = m_Windows[i]->Display(); + res = _windows[i]->Display(); if (FAILED(res)) return res; } } @@ -3348,20 +3348,20 @@ HRESULT CBGame::PlayMusic(int Channel, char *Filename, bool Looping, uint32 Loop return E_FAIL; } - delete m_Music[Channel]; - m_Music[Channel] = NULL; + delete _music[Channel]; + _music[Channel] = NULL; - m_Music[Channel] = new CBSound(Game); - if (m_Music[Channel] && SUCCEEDED(m_Music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { - if (m_MusicStartTime[Channel]) { - m_Music[Channel]->SetPositionTime(m_MusicStartTime[Channel]); - m_MusicStartTime[Channel] = 0; + _music[Channel] = new CBSound(Game); + if (_music[Channel] && SUCCEEDED(_music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { + if (_musicStartTime[Channel]) { + _music[Channel]->SetPositionTime(_musicStartTime[Channel]); + _musicStartTime[Channel] = 0; } - if (LoopStart) m_Music[Channel]->SetLoopStart(LoopStart); - return m_Music[Channel]->Play(Looping); + if (LoopStart) _music[Channel]->SetLoopStart(LoopStart); + return _music[Channel]->Play(Looping); } else { - delete m_Music[Channel]; - m_Music[Channel] = NULL; + delete _music[Channel]; + _music[Channel] = NULL; return E_FAIL; } } @@ -3374,10 +3374,10 @@ HRESULT CBGame::StopMusic(int Channel) { return E_FAIL; } - if (m_Music[Channel]) { - m_Music[Channel]->Stop(); - delete m_Music[Channel]; - m_Music[Channel] = NULL; + if (_music[Channel]) { + _music[Channel]->Stop(); + delete _music[Channel]; + _music[Channel] = NULL; return S_OK; } else return E_FAIL; } @@ -3390,7 +3390,7 @@ HRESULT CBGame::PauseMusic(int Channel) { return E_FAIL; } - if (m_Music[Channel]) return m_Music[Channel]->Pause(); + if (_music[Channel]) return _music[Channel]->Pause(); else return E_FAIL; } @@ -3402,7 +3402,7 @@ HRESULT CBGame::ResumeMusic(int Channel) { return E_FAIL; } - if (m_Music[Channel]) return m_Music[Channel]->Resume(); + if (_music[Channel]) return _music[Channel]->Resume(); else return E_FAIL; } @@ -3415,8 +3415,8 @@ HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { return E_FAIL; } - m_MusicStartTime[Channel] = Time; - if (m_Music[Channel] && m_Music[Channel]->IsPlaying()) return m_Music[Channel]->SetPositionTime(Time); + _musicStartTime[Channel] = Time; + if (_music[Channel] && _music[Channel]->IsPlaying()) return _music[Channel]->SetPositionTime(Time); else return S_OK; } @@ -3443,7 +3443,7 @@ HRESULT CBGame::LoadSettings(char *Filename) { TOKEN_TABLE_END - byte *OrigBuffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *OrigBuffer = Game->_fileManager->ReadWholeFile(Filename); if (OrigBuffer == NULL) { Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); return E_FAIL; @@ -3464,61 +3464,61 @@ HRESULT CBGame::LoadSettings(char *Filename) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - SAFE_DELETE_ARRAY(m_SettingsGameFile); - m_SettingsGameFile = new char[strlen((char *)params) + 1]; - if (m_SettingsGameFile) strcpy(m_SettingsGameFile, (char *)params); + SAFE_DELETE_ARRAY(_settingsGameFile); + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); break; case TOKEN_STRING_TABLE: - if (FAILED(m_StringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(_stringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_RESOLUTION: - parser.ScanStr((char *)params, "%d,%d", &m_SettingsResWidth, &m_SettingsResHeight); + parser.ScanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); break; case TOKEN_REQUIRE_3D_ACCELERATION: - parser.ScanStr((char *)params, "%b", &m_SettingsRequireAcceleration); + parser.ScanStr((char *)params, "%b", &_settingsRequireAcceleration); break; case TOKEN_REQUIRE_SOUND: - parser.ScanStr((char *)params, "%b", &m_SettingsRequireSound); + parser.ScanStr((char *)params, "%b", &_settingsRequireSound); break; case TOKEN_HWTL_MODE: - parser.ScanStr((char *)params, "%d", &m_SettingsTLMode); + parser.ScanStr((char *)params, "%d", &_settingsTLMode); break; case TOKEN_ALLOW_WINDOWED_MODE: - parser.ScanStr((char *)params, "%b", &m_SettingsAllowWindowed); + parser.ScanStr((char *)params, "%b", &_settingsAllowWindowed); break; case TOKEN_ALLOW_DESKTOP_RES: - parser.ScanStr((char *)params, "%b", &m_SettingsAllowDesktopRes); + parser.ScanStr((char *)params, "%b", &_settingsAllowDesktopRes); break; case TOKEN_ALLOW_ADVANCED: - parser.ScanStr((char *)params, "%b", &m_SettingsAllowAdvanced); + parser.ScanStr((char *)params, "%b", &_settingsAllowAdvanced); break; case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.ScanStr((char *)params, "%b", &m_SettingsAllowAccessTab); + parser.ScanStr((char *)params, "%b", &_settingsAllowAccessTab); break; case TOKEN_ALLOW_ABOUT_TAB: - parser.ScanStr((char *)params, "%b", &m_SettingsAllowAboutTab); + parser.ScanStr((char *)params, "%b", &_settingsAllowAboutTab); break; case TOKEN_REGISTRY_PATH: - m_Registry->SetBasePath((char *)params); + _registry->SetBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: - parser.ScanStr((char *)params, "%b", &m_RichSavedGames); + parser.ScanStr((char *)params, "%b", &_richSavedGames); break; case TOKEN_SAVED_GAME_EXT: - CBUtils::SetString(&m_SavedGameExt, (char *)params); + CBUtils::SetString(&_savedGameExt, (char *)params); break; case TOKEN_GUID: @@ -3534,9 +3534,9 @@ HRESULT CBGame::LoadSettings(char *Filename) { ret = E_FAIL; } - m_SettingsAllowWindowed = m_Registry->ReadBool("Debug", "AllowWindowed", m_SettingsAllowWindowed); - m_CompressedSavegames = m_Registry->ReadBool("Debug", "CompressedSavegames", m_CompressedSavegames); - //m_CompressedSavegames = false; + _settingsAllowWindowed = _registry->ReadBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->ReadBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; delete [] OrigBuffer; @@ -3546,95 +3546,95 @@ HRESULT CBGame::LoadSettings(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->m_Saving) Cleanup(); + if (!PersistMgr->_saving) Cleanup(); CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ActiveObject)); - PersistMgr->Transfer(TMEMBER(m_CapturedObject)); - PersistMgr->Transfer(TMEMBER(m_CursorNoninteractive)); - PersistMgr->Transfer(TMEMBER(m_DoNotExpandStrings)); - PersistMgr->Transfer(TMEMBER(m_EditorMode)); - PersistMgr->Transfer(TMEMBER(m_Fader)); - PersistMgr->Transfer(TMEMBER(m_FreezeLevel)); - PersistMgr->Transfer(TMEMBER(m_FocusedWindow)); - PersistMgr->Transfer(TMEMBER(m_FontStorage)); - PersistMgr->Transfer(TMEMBER(m_Interactive)); - PersistMgr->Transfer(TMEMBER(m_KeyboardState)); - PersistMgr->Transfer(TMEMBER(m_LastTime)); - PersistMgr->Transfer(TMEMBER(m_MainObject)); + PersistMgr->Transfer(TMEMBER(_activeObject)); + PersistMgr->Transfer(TMEMBER(_capturedObject)); + PersistMgr->Transfer(TMEMBER(_cursorNoninteractive)); + PersistMgr->Transfer(TMEMBER(_doNotExpandStrings)); + PersistMgr->Transfer(TMEMBER(_editorMode)); + PersistMgr->Transfer(TMEMBER(_fader)); + PersistMgr->Transfer(TMEMBER(_freezeLevel)); + PersistMgr->Transfer(TMEMBER(_focusedWindow)); + PersistMgr->Transfer(TMEMBER(_fontStorage)); + PersistMgr->Transfer(TMEMBER(_interactive)); + PersistMgr->Transfer(TMEMBER(_keyboardState)); + PersistMgr->Transfer(TMEMBER(_lastTime)); + PersistMgr->Transfer(TMEMBER(_mainObject)); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - PersistMgr->Transfer(TMEMBER(m_Music[i])); - PersistMgr->Transfer(TMEMBER(m_MusicStartTime[i])); + PersistMgr->Transfer(TMEMBER(_music[i])); + PersistMgr->Transfer(TMEMBER(_musicStartTime[i])); } - PersistMgr->Transfer(TMEMBER(m_OffsetX)); - PersistMgr->Transfer(TMEMBER(m_OffsetY)); - PersistMgr->Transfer(TMEMBER(m_OffsetPercentX)); - PersistMgr->Transfer(TMEMBER(m_OffsetPercentY)); + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_offsetPercentX)); + PersistMgr->Transfer(TMEMBER(_offsetPercentY)); - PersistMgr->Transfer(TMEMBER(m_OrigInteractive)); - PersistMgr->Transfer(TMEMBER_INT(m_OrigState)); - PersistMgr->Transfer(TMEMBER(m_PersonalizedSave)); - PersistMgr->Transfer(TMEMBER(m_Quitting)); + PersistMgr->Transfer(TMEMBER(_origInteractive)); + PersistMgr->Transfer(TMEMBER_INT(_origState)); + PersistMgr->Transfer(TMEMBER(_personalizedSave)); + PersistMgr->Transfer(TMEMBER(_quitting)); - m_RegObjects.Persist(PersistMgr); + _regObjects.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_ScEngine)); - //PersistMgr->Transfer(TMEMBER(m_SoundMgr)); - PersistMgr->Transfer(TMEMBER_INT(m_State)); - //PersistMgr->Transfer(TMEMBER(m_SurfaceStorage)); - PersistMgr->Transfer(TMEMBER(m_Subtitles)); - PersistMgr->Transfer(TMEMBER(m_SubtitlesSpeed)); - PersistMgr->Transfer(TMEMBER(m_SystemFont)); - PersistMgr->Transfer(TMEMBER(m_VideoFont)); - PersistMgr->Transfer(TMEMBER(m_VideoSubtitles)); + PersistMgr->Transfer(TMEMBER(_scEngine)); + //PersistMgr->Transfer(TMEMBER(_soundMgr)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + //PersistMgr->Transfer(TMEMBER(_surfaceStorage)); + PersistMgr->Transfer(TMEMBER(_subtitles)); + PersistMgr->Transfer(TMEMBER(_subtitlesSpeed)); + PersistMgr->Transfer(TMEMBER(_systemFont)); + PersistMgr->Transfer(TMEMBER(_videoFont)); + PersistMgr->Transfer(TMEMBER(_videoSubtitles)); - PersistMgr->Transfer(TMEMBER(m_Timer)); - PersistMgr->Transfer(TMEMBER(m_TimerDelta)); - PersistMgr->Transfer(TMEMBER(m_TimerLast)); + PersistMgr->Transfer(TMEMBER(_timer)); + PersistMgr->Transfer(TMEMBER(_timerDelta)); + PersistMgr->Transfer(TMEMBER(_timerLast)); - PersistMgr->Transfer(TMEMBER(m_LiveTimer)); - PersistMgr->Transfer(TMEMBER(m_LiveTimerDelta)); - PersistMgr->Transfer(TMEMBER(m_LiveTimerLast)); + PersistMgr->Transfer(TMEMBER(_liveTimer)); + PersistMgr->Transfer(TMEMBER(_liveTimerDelta)); + PersistMgr->Transfer(TMEMBER(_liveTimerLast)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeRunning)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeStartTime)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeLength)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeChannel1)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeChannel2)); - PersistMgr->Transfer(TMEMBER(m_MusicCrossfadeSwap)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeRunning)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeStartTime)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeLength)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel1)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel2)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeSwap)); - PersistMgr->Transfer(TMEMBER(m_LoadImageName)); - PersistMgr->Transfer(TMEMBER(m_SaveImageName)); - PersistMgr->Transfer(TMEMBER(m_SaveImageX)); - PersistMgr->Transfer(TMEMBER(m_SaveImageY)); - PersistMgr->Transfer(TMEMBER(m_LoadImageX)); - PersistMgr->Transfer(TMEMBER(m_LoadImageY)); + PersistMgr->Transfer(TMEMBER(_loadImageName)); + PersistMgr->Transfer(TMEMBER(_saveImageName)); + PersistMgr->Transfer(TMEMBER(_saveImageX)); + PersistMgr->Transfer(TMEMBER(_saveImageY)); + PersistMgr->Transfer(TMEMBER(_loadImageX)); + PersistMgr->Transfer(TMEMBER(_loadImageY)); - PersistMgr->Transfer(TMEMBER_INT(m_TextEncoding)); - PersistMgr->Transfer(TMEMBER(m_TextRTL)); + PersistMgr->Transfer(TMEMBER_INT(_textEncoding)); + PersistMgr->Transfer(TMEMBER(_textRTL)); - PersistMgr->Transfer(TMEMBER(m_SoundBufferSizeSec)); - PersistMgr->Transfer(TMEMBER(m_SuspendedRendering)); + PersistMgr->Transfer(TMEMBER(_soundBufferSizeSec)); + PersistMgr->Transfer(TMEMBER(_suspendedRendering)); - PersistMgr->Transfer(TMEMBER(m_MouseLockRect)); + PersistMgr->Transfer(TMEMBER(_mouseLockRect)); - m_Windows.Persist(PersistMgr); + _windows.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_SuppressScriptErrors)); - PersistMgr->Transfer(TMEMBER(m_AutorunDisabled)); + PersistMgr->Transfer(TMEMBER(_suppressScriptErrors)); + PersistMgr->Transfer(TMEMBER(_autorunDisabled)); - PersistMgr->Transfer(TMEMBER(m_AutoSaveOnExit)); - PersistMgr->Transfer(TMEMBER(m_AutoSaveSlot)); - PersistMgr->Transfer(TMEMBER(m_CursorHidden)); + PersistMgr->Transfer(TMEMBER(_autoSaveOnExit)); + PersistMgr->Transfer(TMEMBER(_autoSaveSlot)); + PersistMgr->Transfer(TMEMBER(_cursorHidden)); if (PersistMgr->CheckVersion(1, 0, 1)) - PersistMgr->Transfer(TMEMBER(m_Store)); + PersistMgr->Transfer(TMEMBER(_store)); else - m_Store = NULL; + _store = NULL; - if (!PersistMgr->m_Saving) m_Quitting = false; + if (!PersistMgr->_saving) _quitting = false; return S_OK; } @@ -3642,19 +3642,19 @@ HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::FocusWindow(CUIWindow *Window) { - CUIWindow *Prev = m_FocusedWindow; + CUIWindow *Prev = _focusedWindow; int i; - for (i = 0; i < m_Windows.GetSize(); i++) { - if (m_Windows[i] == Window) { - if (i < m_Windows.GetSize() - 1) { - m_Windows.RemoveAt(i); - m_Windows.Add(Window); + for (i = 0; i < _windows.GetSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.GetSize() - 1) { + _windows.RemoveAt(i); + _windows.Add(Window); - Game->m_FocusedWindow = Window; + Game->_focusedWindow = Window; } - if (Window->m_Mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->m_Mode == WINDOW_EXCLUSIVE || Prev->m_Mode == WINDOW_SYSTEM_EXCLUSIVE)) + if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) return FocusWindow(Prev); else return S_OK; } @@ -3665,15 +3665,15 @@ HRESULT CBGame::FocusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::Freeze(bool IncludingMusic) { - if (m_FreezeLevel == 0) { - m_ScEngine->PauseAll(); - m_SoundMgr->PauseAll(IncludingMusic); - m_OrigState = m_State; - m_OrigInteractive = m_Interactive; - m_Interactive = true; + if (_freezeLevel == 0) { + _scEngine->PauseAll(); + _soundMgr->PauseAll(IncludingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; } - m_State = GAME_FROZEN; - m_FreezeLevel++; + _state = GAME_FROZEN; + _freezeLevel++; return S_OK; } @@ -3681,14 +3681,14 @@ HRESULT CBGame::Freeze(bool IncludingMusic) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::Unfreeze() { - if (m_FreezeLevel == 0) return S_OK; + if (_freezeLevel == 0) return S_OK; - m_FreezeLevel--; - if (m_FreezeLevel == 0) { - m_State = m_OrigState; - m_Interactive = m_OrigInteractive; - m_ScEngine->ResumeAll(); - m_SoundMgr->ResumeAll(); + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->ResumeAll(); + _soundMgr->ResumeAll(); } return S_OK; @@ -3706,20 +3706,20 @@ bool CBGame::HandleKeypress(SDL_Event *event) { #endif if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_RETURN && (event->key.keysym.mod == KMOD_LALT || event->key.keysym.mod == KMOD_RALT)) { - m_Renderer->SwitchFullscreen(); + _renderer->SwitchFullscreen(); return true; } - m_KeyboardState->ReadKey(event); + _keyboardState->ReadKey(event); // TODO #if 0 - if (m_FocusedWindow) { - if (!Game->m_FocusedWindow->HandleKeypress(event)) { + if (_focusedWindow) { + if (!Game->_focusedWindow->HandleKeypress(event)) { if (event->type != SDL_TEXTINPUT) { - if (Game->m_FocusedWindow->CanHandleEvent("Keypress")) - Game->m_FocusedWindow->ApplyEvent("Keypress"); + if (Game->_focusedWindow->CanHandleEvent("Keypress")) + Game->_focusedWindow->ApplyEvent("Keypress"); else ApplyEvent("Keypress"); } @@ -3739,15 +3739,15 @@ bool CBGame::HandleKeypress(SDL_Event *event) { ////////////////////////////////////////////////////////////////////////// bool CBGame::HandleMouseWheel(int Delta) { bool Handled = false; - if (m_FocusedWindow) { - Handled = Game->m_FocusedWindow->HandleMouseWheel(Delta); + if (_focusedWindow) { + Handled = Game->_focusedWindow->HandleMouseWheel(Delta); if (!Handled) { - if (Delta < 0 && Game->m_FocusedWindow->CanHandleEvent("MouseWheelDown")) { - Game->m_FocusedWindow->ApplyEvent("MouseWheelDown"); + if (Delta < 0 && Game->_focusedWindow->CanHandleEvent("MouseWheelDown")) { + Game->_focusedWindow->ApplyEvent("MouseWheelDown"); Handled = true; - } else if (Game->m_FocusedWindow->CanHandleEvent("MouseWheelUp")) { - Game->m_FocusedWindow->ApplyEvent("MouseWheelUp"); + } else if (Game->_focusedWindow->CanHandleEvent("MouseWheelUp")) { + Game->_focusedWindow->ApplyEvent("MouseWheelUp"); Handled = true; } @@ -3780,22 +3780,22 @@ HRESULT CBGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte ////////////////////////////////////////////////////////////////////////// void CBGame::SetWindowTitle() { - if (m_Renderer) { + if (_renderer) { char Title[512]; - strcpy(Title, m_Caption[0]); + strcpy(Title, _caption[0]); if (Title[0] != '\0') strcat(Title, " - "); strcat(Title, "WME Lite"); Utf8String title; - if (m_TextEncoding == TEXT_UTF8) { + if (_textEncoding == TEXT_UTF8) { title = Utf8String(Title); } else { WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr); } - CBRenderSDL *renderer = static_cast(m_Renderer); + CBRenderSDL *renderer = static_cast(_renderer); // TODO #if 0 SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); @@ -3807,7 +3807,7 @@ void CBGame::SetWindowTitle() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { AnsiString dataDir = GetDataDir(); - sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, m_SavedGameExt); + sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); return S_OK; } @@ -3818,7 +3818,7 @@ AnsiString CBGame::GetDataDir() { #ifdef __IPHONEOS__ return userDir; #else - AnsiString baseDir = m_Registry->GetBasePath(); + AnsiString baseDir = _registry->GetBasePath(); return PathUtil::Combine(userDir, baseDir); #endif } @@ -3833,15 +3833,15 @@ HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; - m_DEBUG_AbsolutePathWarning = false; + _dEBUG_AbsolutePathWarning = false; if (FAILED(pm->InitLoad(Filename))) { - m_DEBUG_AbsolutePathWarning = true; + _dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; } - m_DEBUG_AbsolutePathWarning = true; - strcpy(Buffer, pm->m_SavedDescription); + _dEBUG_AbsolutePathWarning = true; + strcpy(Buffer, pm->_savedDescription); delete pm; return S_OK; @@ -3853,10 +3853,10 @@ bool CBGame::IsSaveSlotUsed(int Slot) { char Filename[MAX_PATH + 1]; GetSaveSlotFilename(Slot, Filename); - CBFile *File = m_FileManager->OpenFile(Filename, false); + CBFile *File = _fileManager->OpenFile(Filename, false); if (!File) return false; - m_FileManager->CloseFile(File); + _fileManager->CloseFile(File); return true; } @@ -3875,17 +3875,17 @@ HRESULT CBGame::EmptySaveSlot(int Slot) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::SetActiveObject(CBObject *Obj) { // not-active when game is frozen - if (Obj && !Game->m_Interactive && !Obj->m_NonIntMouseEvents) { + if (Obj && !Game->_interactive && !Obj->_nonIntMouseEvents) { Obj = NULL; } - if (Obj == m_ActiveObject) return S_OK; + if (Obj == _activeObject) return S_OK; - if (m_ActiveObject) m_ActiveObject->ApplyEvent("MouseLeave"); - //if(ValidObject(m_ActiveObject)) m_ActiveObject->ApplyEvent("MouseLeave"); - m_ActiveObject = Obj; - if (m_ActiveObject) { - m_ActiveObject->ApplyEvent("MouseEntry"); + if (_activeObject) _activeObject->ApplyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->ApplyEvent("MouseLeave"); + _activeObject = Obj; + if (_activeObject) { + _activeObject->ApplyEvent("MouseEntry"); } return S_OK; @@ -3894,11 +3894,11 @@ HRESULT CBGame::SetActiveObject(CBObject *Obj) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::PushViewport(CBViewport *Viewport) { - m_ViewportSP++; - if (m_ViewportSP >= m_ViewportStack.GetSize()) m_ViewportStack.Add(Viewport); - else m_ViewportStack[m_ViewportSP] = Viewport; + _viewportSP++; + if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); + else _viewportStack[_viewportSP] = Viewport; - m_Renderer->SetViewport(Viewport->GetRect()); + _renderer->SetViewport(Viewport->GetRect()); return S_OK; } @@ -3906,14 +3906,14 @@ HRESULT CBGame::PushViewport(CBViewport *Viewport) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::PopViewport() { - m_ViewportSP--; - if (m_ViewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); + _viewportSP--; + if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); - if (m_ViewportSP >= 0 && m_ViewportSP < m_ViewportStack.GetSize()) m_Renderer->SetViewport(m_ViewportStack[m_ViewportSP]->GetRect()); - else m_Renderer->SetViewport(m_Renderer->m_DrawOffsetX, - m_Renderer->m_DrawOffsetY, - m_Renderer->m_Width + m_Renderer->m_DrawOffsetX, - m_Renderer->m_Height + m_Renderer->m_DrawOffsetY); + if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->GetRect()); + else _renderer->SetViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); return S_OK; } @@ -3923,14 +3923,14 @@ HRESULT CBGame::PopViewport() { HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { if (Rect == NULL) return E_FAIL; else { - if (m_ViewportSP >= 0) { - CBPlatform::CopyRect(Rect, m_ViewportStack[m_ViewportSP]->GetRect()); + if (_viewportSP >= 0) { + CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->GetRect()); if (Custom) *Custom = true; } else { - CBPlatform::SetRect(Rect, m_Renderer->m_DrawOffsetX, - m_Renderer->m_DrawOffsetY, - m_Renderer->m_Width + m_Renderer->m_DrawOffsetX, - m_Renderer->m_Height + m_Renderer->m_DrawOffsetY); + CBPlatform::SetRect(Rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); if (Custom) *Custom = false; } @@ -3941,9 +3941,9 @@ HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { - if (m_ViewportSP >= 0) { - if (OffsetX) *OffsetX = m_ViewportStack[m_ViewportSP]->m_OffsetX; - if (OffsetY) *OffsetY = m_ViewportStack[m_ViewportSP]->m_OffsetY; + if (_viewportSP >= 0) { + if (OffsetX) *OffsetX = _viewportStack[_viewportSP]->_offsetX; + if (OffsetY) *OffsetY = _viewportStack[_viewportSP]->_offsetY; } else { if (OffsetX) *OffsetX = 0; if (OffsetY) *OffsetY = 0; @@ -3967,16 +3967,16 @@ HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScSta ////////////////////////////////////////////////////////////////////////// void CBGame::SetInteractive(bool State) { - m_Interactive = State; - if (m_TransMgr) m_TransMgr->m_OrigInteractive = State; + _interactive = State; + if (_transMgr) _transMgr->_origInteractive = State; } ////////////////////////////////////////////////////////////////////////// void CBGame::ResetMousePos() { POINT p; - p.x = m_MousePos.x + m_Renderer->m_DrawOffsetX; - p.y = m_MousePos.y + m_Renderer->m_DrawOffsetY; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; CBPlatform::SetCursorPos(p.x, p.y); } @@ -3984,7 +3984,7 @@ void CBGame::ResetMousePos() { ////////////////////////////////////////////////////////////////////////// void CBGame::SetResourceModule(HMODULE ResModule) { - m_ResourceModule = ResModule; + _resourceModule = ResModule; } @@ -3997,8 +3997,8 @@ HRESULT CBGame::DisplayContent(bool Update, bool DisplayAll) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DisplayContentSimple() { // fill black - m_Renderer->Fill(0, 0, 0); - if (m_IndicatorDisplay) DisplayIndicator(); + _renderer->Fill(0, 0, 0); + if (_indicatorDisplay) DisplayIndicator(); return S_OK; } @@ -4006,71 +4006,71 @@ HRESULT CBGame::DisplayContentSimple() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DisplayIndicator() { - if (m_SaveLoadImage) { + if (_saveLoadImage) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, m_SaveLoadImage->GetWidth(), m_SaveLoadImage->GetHeight()); - if (m_LoadInProgress) m_SaveLoadImage->DisplayTrans(m_LoadImageX, m_LoadImageY, rc); - else m_SaveLoadImage->DisplayTrans(m_SaveImageX, m_SaveImageY, rc); + CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->GetWidth(), _saveLoadImage->GetHeight()); + if (_loadInProgress) _saveLoadImage->DisplayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->DisplayTrans(_saveImageX, _saveImageY, rc); } - if (!m_IndicatorDisplay && m_IndicatorWidth <= 0 || m_IndicatorHeight <= 0) return S_OK; - m_Renderer->SetupLines(); - for (int i = 0; i < m_IndicatorHeight; i++) - m_Renderer->DrawLine(m_IndicatorX, m_IndicatorY + i, m_IndicatorX + (int)(m_IndicatorWidth * (float)((float)m_IndicatorProgress / 100.0f)), m_IndicatorY + i, m_IndicatorColor); + if (!_indicatorDisplay && _indicatorWidth <= 0 || _indicatorHeight <= 0) return S_OK; + _renderer->SetupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->DrawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - m_Renderer->Setup2D(); + _renderer->Setup2D(); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::UpdateMusicCrossfade() { - byte GlobMusicVol = m_SoundMgr->GetVolumePercent(SOUND_MUSIC); + byte GlobMusicVol = _soundMgr->GetVolumePercent(SOUND_MUSIC); - if (!m_MusicCrossfadeRunning) return S_OK; - if (m_State == GAME_FROZEN) return S_OK; + if (!_musicCrossfadeRunning) return S_OK; + if (_state == GAME_FROZEN) return S_OK; - if (m_MusicCrossfadeChannel1 < 0 || m_MusicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !m_Music[m_MusicCrossfadeChannel1]) { - m_MusicCrossfadeRunning = false; + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; return S_OK; } - if (m_MusicCrossfadeChannel2 < 0 || m_MusicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !m_Music[m_MusicCrossfadeChannel2]) { - m_MusicCrossfadeRunning = false; + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; return S_OK; } - if (!m_Music[m_MusicCrossfadeChannel1]->IsPlaying()) m_Music[m_MusicCrossfadeChannel1]->Play(); - if (!m_Music[m_MusicCrossfadeChannel2]->IsPlaying()) m_Music[m_MusicCrossfadeChannel2]->Play(); + if (!_music[_musicCrossfadeChannel1]->IsPlaying()) _music[_musicCrossfadeChannel1]->Play(); + if (!_music[_musicCrossfadeChannel2]->IsPlaying()) _music[_musicCrossfadeChannel2]->Play(); - uint32 CurrentTime = Game->m_LiveTimer - m_MusicCrossfadeStartTime; + uint32 CurrentTime = Game->_liveTimer - _musicCrossfadeStartTime; - if (CurrentTime >= m_MusicCrossfadeLength) { - m_MusicCrossfadeRunning = false; - //m_Music[m_MusicCrossfadeChannel2]->SetVolume(GlobMusicVol); - m_Music[m_MusicCrossfadeChannel2]->SetVolume(100); + if (CurrentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->SetVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->SetVolume(100); - m_Music[m_MusicCrossfadeChannel1]->Stop(); - //m_Music[m_MusicCrossfadeChannel1]->SetVolume(GlobMusicVol); - m_Music[m_MusicCrossfadeChannel1]->SetVolume(100); + _music[_musicCrossfadeChannel1]->Stop(); + //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->SetVolume(100); - if (m_MusicCrossfadeSwap) { + if (_musicCrossfadeSwap) { // swap channels - CBSound *Dummy = m_Music[m_MusicCrossfadeChannel1]; - int DummyInt = m_MusicStartTime[m_MusicCrossfadeChannel1]; + CBSound *Dummy = _music[_musicCrossfadeChannel1]; + int DummyInt = _musicStartTime[_musicCrossfadeChannel1]; - m_Music[m_MusicCrossfadeChannel1] = m_Music[m_MusicCrossfadeChannel2]; - m_MusicStartTime[m_MusicCrossfadeChannel1] = m_MusicStartTime[m_MusicCrossfadeChannel2]; + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - m_Music[m_MusicCrossfadeChannel2] = Dummy; - m_MusicStartTime[m_MusicCrossfadeChannel2] = DummyInt; + _music[_musicCrossfadeChannel2] = Dummy; + _musicStartTime[_musicCrossfadeChannel2] = DummyInt; } } else { - //m_Music[m_MusicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)m_MusicCrossfadeLength * GlobMusicVol); - //m_Music[m_MusicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)m_MusicCrossfadeLength * GlobMusicVol); - m_Music[m_MusicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)m_MusicCrossfadeLength * 100); - m_Music[m_MusicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)m_MusicCrossfadeLength * 100); + //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); - //Game->QuickMessageForm("%d %d", m_Music[m_MusicCrossfadeChannel1]->GetVolume(), m_Music[m_MusicCrossfadeChannel2]->GetVolume()); + //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } return S_OK; @@ -4079,9 +4079,9 @@ HRESULT CBGame::UpdateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::ResetContent() { - m_ScEngine->ClearGlobals(); - //m_Timer = 0; - //m_LiveTimer = 0; + _scEngine->ClearGlobals(); + //_timer = 0; + //_liveTimer = 0; return S_OK; } @@ -4099,8 +4099,8 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::InvalidateDeviceObjects() { - for (int i = 0; i < m_RegObjects.GetSize(); i++) { - m_RegObjects[i]->InvalidateDeviceObjects(); + for (int i = 0; i < _regObjects.GetSize(); i++) { + _regObjects[i]->InvalidateDeviceObjects(); } return S_OK; } @@ -4108,21 +4108,21 @@ HRESULT CBGame::InvalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::RestoreDeviceObjects() { - for (int i = 0; i < m_RegObjects.GetSize(); i++) { - m_RegObjects[i]->RestoreDeviceObjects(); + for (int i = 0; i < _regObjects.GetSize(); i++) { + _regObjects[i]->RestoreDeviceObjects(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::SetWaitCursor(char *Filename) { - delete m_CursorNoninteractive; - m_CursorNoninteractive = NULL; + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; - m_CursorNoninteractive = new CBSprite(Game); - if (!m_CursorNoninteractive || FAILED(m_CursorNoninteractive->LoadFile(Filename))) { - delete m_CursorNoninteractive; - m_CursorNoninteractive = NULL; + _cursorNoninteractive = new CBSprite(Game); + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile(Filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; return E_FAIL; } else return S_OK; } @@ -4131,63 +4131,63 @@ HRESULT CBGame::SetWaitCursor(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DrawCursor(CBSprite *Cursor) { if (!Cursor) return E_FAIL; - if (Cursor != m_LastCursor) { + if (Cursor != _lastCursor) { Cursor->Reset(); - m_LastCursor = Cursor; + _lastCursor = Cursor; } - return Cursor->Draw(m_MousePos.x, m_MousePos.y); + return Cursor->Draw(_mousePos.x, _mousePos.y); } ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { - if (m_ShuttingDown || !m_Renderer) return S_OK; + if (_shuttingDown || !_renderer) return S_OK; - m_Renderer->m_Active = Activate; + _renderer->_active = Activate; if (RefreshMouse) { POINT p; GetMousePos(&p); - SetActiveObject(m_Renderer->GetObjectAt(p.x, p.y)); + SetActiveObject(_renderer->GetObjectAt(p.x, p.y)); } - if (Activate) m_SoundMgr->ResumeAll(); - else m_SoundMgr->PauseAll(); + if (Activate) _soundMgr->ResumeAll(); + else _soundMgr->PauseAll(); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseLeftDown() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftClick"); } } - if (m_ActiveObject != NULL) m_CapturedObject = m_ActiveObject; - m_MouseLeftDown = true; - CBPlatform::SetCapture(m_Renderer->m_Window); + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::SetCapture(_renderer->_window); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseLeftUp() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); - m_CapturedObject = NULL; - m_MouseLeftDown = false; + _capturedObject = NULL; + _mouseLeftDown = false; - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftRelease"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftRelease"); } } return S_OK; @@ -4195,14 +4195,14 @@ HRESULT CBGame::OnMouseLeftUp() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseLeftDblClick() { - if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("LeftDoubleClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftDoubleClick"); } } return S_OK; @@ -4210,14 +4210,14 @@ HRESULT CBGame::OnMouseLeftDblClick() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseRightDblClick() { - if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("RightDoubleClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightDoubleClick"); } } return S_OK; @@ -4225,12 +4225,12 @@ HRESULT CBGame::OnMouseRightDblClick() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseRightDown() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("RightClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightClick"); } } return S_OK; @@ -4238,12 +4238,12 @@ HRESULT CBGame::OnMouseRightDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseRightUp() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("RightRelease"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightRelease"); } } return S_OK; @@ -4251,14 +4251,14 @@ HRESULT CBGame::OnMouseRightUp() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseMiddleDown() { - if (m_State == GAME_RUNNING && !m_Interactive) return S_OK; + if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("MiddleClick"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("MiddleClick"); } } return S_OK; @@ -4266,12 +4266,12 @@ HRESULT CBGame::OnMouseMiddleDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseMiddleUp() { - if (m_ActiveObject) m_ActiveObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - bool Handled = m_State == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); if (!Handled) { - if (m_ActiveObject != NULL) { - m_ActiveObject->ApplyEvent("MiddleRelease"); + if (_activeObject != NULL) { + _activeObject->ApplyEvent("MiddleRelease"); } } return S_OK; @@ -4279,11 +4279,11 @@ HRESULT CBGame::OnMouseMiddleUp() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnPaint() { - if (m_Renderer && m_Renderer->m_Windowed && m_Renderer->m_Ready) { - m_Renderer->InitLoop(); + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->InitLoop(); DisplayContent(false, true); DisplayDebugInfo(); - m_Renderer->WindowedBlt(); + _renderer->WindowedBlt(); } return S_OK; } @@ -4291,7 +4291,7 @@ HRESULT CBGame::OnPaint() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnWindowClose() { if (CanHandleEvent("QuitGame")) { - if (m_State != GAME_FROZEN) Game->ApplyEvent("QuitGame"); + if (_state != GAME_FROZEN) Game->ApplyEvent("QuitGame"); return S_OK; } else return E_FAIL; } @@ -4300,37 +4300,37 @@ HRESULT CBGame::OnWindowClose() { HRESULT CBGame::DisplayDebugInfo() { char str[100]; - if (m_DEBUG_ShowFPS) { - sprintf(str, "FPS: %d", Game->m_Fps); - m_SystemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); + if (_dEBUG_ShowFPS) { + sprintf(str, "FPS: %d", Game->_fps); + _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); } - if (Game->m_DEBUG_DebugMode) { - if (!Game->m_Renderer->m_Windowed) - sprintf(str, "Mode: %dx%dx%d", m_Renderer->m_Width, m_Renderer->m_Height, m_Renderer->m_BPP); + if (Game->_dEBUG_DebugMode) { + if (!Game->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); else - sprintf(str, "Mode: %dx%d windowed", m_Renderer->m_Width, m_Renderer->m_Height); + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); strcat(str, " ("); - strcat(str, m_Renderer->GetName()); + strcat(str, _renderer->GetName()); strcat(str, ")"); - m_SystemFont->DrawText((byte *)str, 0, 0, m_Renderer->m_Width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - m_Renderer->DisplayDebugInfo(); + _renderer->DisplayDebugInfo(); int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; - ScrTotal = m_ScEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); + ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); - m_SystemFont->DrawText((byte *)str, 0, 70, m_Renderer->m_Width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - sprintf(str, "Timer: %d", m_Timer); - Game->m_SystemFont->DrawText((byte *)str, 0, 130, m_Renderer->m_Width, TAL_RIGHT); + sprintf(str, "Timer: %d", _timer); + Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (m_ActiveObject != NULL) m_SystemFont->DrawText((byte *)m_ActiveObject->m_Name, 0, 150, m_Renderer->m_Width, TAL_RIGHT); + if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); - sprintf(str, "GfxMem: %dMB", m_UsedMem / (1024 * 1024)); - m_SystemFont->DrawText((byte *)str, 0, 170, m_Renderer->m_Width, TAL_RIGHT); + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); } @@ -4339,8 +4339,8 @@ HRESULT CBGame::DisplayDebugInfo() { ////////////////////////////////////////////////////////////////////////// CBDebugger *CBGame::GetDebugMgr() { - if (!m_DebugMgr) m_DebugMgr = new CBDebugger(this); - return m_DebugMgr; + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; } @@ -4348,35 +4348,35 @@ CBDebugger *CBGame::GetDebugMgr() { void CBGame::GetMousePos(POINT *Pos) { CBPlatform::GetCursorPos(Pos); - Pos->x -= m_Renderer->m_DrawOffsetX; - Pos->y -= m_Renderer->m_DrawOffsetY; + Pos->x -= _renderer->_drawOffsetX; + Pos->y -= _renderer->_drawOffsetY; /* // Windows can squish maximized window if it's larger than desktop // so we need to modify mouse position appropriately (tnx mRax) - if(m_Renderer->m_Windowed && ::IsZoomed(m_Renderer->m_Window)) + if(_renderer->_windowed && ::IsZoomed(_renderer->_window)) { RECT rc; - ::GetClientRect(m_Renderer->m_Window, &rc); - Pos->x *= Game->m_Renderer->m_RealWidth; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= Game->_renderer->_realWidth; Pos->x /= (rc.right - rc.left); - Pos->y *= Game->m_Renderer->m_RealHeight; + Pos->y *= Game->_renderer->_realHeight; Pos->y /= (rc.bottom - rc.top); } */ - if (m_MouseLockRect.left != 0 && m_MouseLockRect.right != 0 && m_MouseLockRect.top != 0 && m_MouseLockRect.bottom != 0) { - if (!CBPlatform::PtInRect(&m_MouseLockRect, *Pos)) { - Pos->x = std::max(m_MouseLockRect.left, Pos->x); - Pos->y = std::max(m_MouseLockRect.top, Pos->y); + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::PtInRect(&_mouseLockRect, *Pos)) { + Pos->x = std::max(_mouseLockRect.left, Pos->x); + Pos->y = std::max(_mouseLockRect.top, Pos->y); - Pos->x = std::min(m_MouseLockRect.right, Pos->x); - Pos->y = std::min(m_MouseLockRect.bottom, Pos->y); + Pos->x = std::min(_mouseLockRect.right, Pos->x); + Pos->y = std::min(_mouseLockRect.bottom, Pos->y); POINT NewPos = *Pos; - NewPos.x += m_Renderer->m_DrawOffsetX; - NewPos.y += m_Renderer->m_DrawOffsetY; + NewPos.x += _renderer->_drawOffsetX; + NewPos.y += _renderer->_drawOffsetY; CBPlatform::SetCursorPos(NewPos.x, NewPos.y); } @@ -4385,11 +4385,11 @@ void CBGame::GetMousePos(POINT *Pos) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::MiniUpdate() { - if (!m_MiniUpdateEnabled) return S_OK; + if (!_miniUpdateEnabled) return S_OK; - if (CBPlatform::GetTime() - m_LastMiniUpdate > 200) { - if (m_SoundMgr) m_SoundMgr->InitLoop(); - m_LastMiniUpdate = CBPlatform::GetTime(); + if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->InitLoop(); + _lastMiniUpdate = CBPlatform::GetTime(); } return S_OK; } @@ -4427,35 +4427,35 @@ bool CBGame::IsDoubleClick(int buttonIndex) { POINT pos; CBPlatform::GetCursorPos(&pos); - int moveX = abs(pos.x - m_LastClick[buttonIndex].PosX); - int moveY = abs(pos.y - m_LastClick[buttonIndex].PosY); + int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); + int moveY = abs(pos.y - _lastClick[buttonIndex].PosY); - if (m_LastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - m_LastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - m_LastClick[buttonIndex].Time = CBPlatform::GetTime(); - m_LastClick[buttonIndex].PosX = pos.x; - m_LastClick[buttonIndex].PosY = pos.y; + if (_lastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].Time = CBPlatform::GetTime(); + _lastClick[buttonIndex].PosX = pos.x; + _lastClick[buttonIndex].PosY = pos.y; return false; } else { - m_LastClick[buttonIndex].Time = 0; + _lastClick[buttonIndex].Time = 0; return true; } } ////////////////////////////////////////////////////////////////////////// void CBGame::AutoSaveOnExit() { - m_SoundMgr->SaveSettings(); - m_Registry->SaveValues(); + _soundMgr->SaveSettings(); + _registry->SaveValues(); - if (!m_AutoSaveOnExit) return; - if (m_State == GAME_FROZEN) return; + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; - SaveGame(m_AutoSaveSlot, "autosave", true); + SaveGame(_autoSaveSlot, "autosave", true); } ////////////////////////////////////////////////////////////////////////// void CBGame::AddMem(int bytes) { - m_UsedMem += bytes; + _usedMem += bytes; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 5de2beacc3..f783f2a967 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -84,140 +84,140 @@ public: bool IsLeftDoubleClick(); bool IsRightDoubleClick(); - bool m_AutorunDisabled; + bool _autorunDisabled; - uint32 m_LastMiniUpdate; - bool m_MiniUpdateEnabled; + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; virtual HRESULT MiniUpdate(); void GetMousePos(POINT *Pos); - RECT m_MouseLockRect; + RECT _mouseLockRect; - bool m_ShuttingDown; + bool _shuttingDown; virtual HRESULT DisplayDebugInfo(); - bool m_DEBUG_ShowFPS; + bool _dEBUG_ShowFPS; - bool m_SuspendedRendering; - int m_SoundBufferSizeSec; + bool _suspendedRendering; + int _soundBufferSizeSec; - TTextEncoding m_TextEncoding; - bool m_TextRTL; + TTextEncoding _textEncoding; + bool _textRTL; - CBSprite *m_LoadingIcon; - int m_LoadingIconX; - int m_LoadingIconY; - int m_LoadingIconPersistent; + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; virtual HRESULT ResetContent(); void DEBUG_DumpClassRegistry(); HRESULT SetWaitCursor(char *Filename); - char *m_LocalSaveDir; - bool m_SaveDirChecked; + char *_localSaveDir; + bool _saveDirChecked; - bool m_IndicatorDisplay; - uint32 m_IndicatorColor; - int m_IndicatorProgress; - int m_IndicatorX; - int m_IndicatorY; - int m_IndicatorWidth; - int m_IndicatorHeight; + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorProgress; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; - bool m_RichSavedGames; - char *m_SavedGameExt; + bool _richSavedGames; + char *_savedGameExt; - char *m_LoadImageName; - char *m_SaveImageName; - int m_SaveImageX; - int m_SaveImageY; - int m_LoadImageX; - int m_LoadImageY; - CBSurface *m_SaveLoadImage; + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + CBSurface *_saveLoadImage; HRESULT DisplayIndicator(); - int m_ThumbnailWidth; - int m_ThumbnailHeight; + int _thumbnailWidth; + int _thumbnailHeight; - bool m_ReportTextureFormat; - HMODULE m_ResourceModule; + bool _reportTextureFormat; + HMODULE _resourceModule; void SetResourceModule(HMODULE ResModule); void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); - ENGINE_LOG_CALLBACK m_EngineLogCallback; - void *m_EngineLogCallbackData; - bool m_EditorMode; + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; - bool m_DoNotExpandStrings; + bool _doNotExpandStrings; void GetOffset(int *OffsetX, int *OffsetY); void SetOffset(int OffsetX, int OffsetY); int GetSequence(); - int m_OffsetY; - int m_OffsetX; - float m_OffsetPercentX; - float m_OffsetPercentY; - CBObject *m_MainObject; + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; HRESULT InitInput(HINSTANCE hInst, HWND hWnd); HRESULT InitLoop(); - uint32 m_CurrentTime; - uint32 m_DeltaTime; - CBFont *m_SystemFont; - CBFont *m_VideoFont; + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; HRESULT Initialize1(); HRESULT Initialize2(); HRESULT Initialize3(); - CBFileManager *m_FileManager; - CBTransitionMgr *m_TransMgr; + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; CBDebugger *GetDebugMgr(); void LOG(HRESULT res, LPCSTR fmt, ...); - CBRenderer *m_Renderer; - CBSoundMgr *m_SoundMgr; - CScEngine *m_ScEngine; - CSXMath *m_MathClass; - CSXStore *m_Store; - CBSurfaceStorage *m_SurfaceStorage; - CBFontStorage *m_FontStorage; + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CSXStore *_store; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; CBGame(); virtual ~CBGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *Filename = NULL); - bool m_DEBUG_DebugMode; - bool m_DEBUG_AbsolutePathWarning; + bool _dEBUG_DebugMode; + bool _dEBUG_AbsolutePathWarning; - void *m_DEBUG_LogFile; - int m_Sequence; + void *_dEBUG_LogFile; + int _sequence; virtual HRESULT LoadFile(const char *Filename); virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CBArray m_QuickMessages; - CBArray m_Windows; - CBArray m_ViewportStack; - - int m_ViewportSP; - bool m_MouseLeftDown; - bool m_MouseRightDown; - bool m_MouseMidlleDown; - CBStringTable *m_StringTable; - - int m_SettingsResWidth; - int m_SettingsResHeight; - bool m_SettingsRequireAcceleration; - bool m_SettingsAllowWindowed; - bool m_SettingsAllowAdvanced; - bool m_SettingsAllowAccessTab; - bool m_SettingsAllowAboutTab; - bool m_SettingsRequireSound; - bool m_SettingsAllowDesktopRes; - int m_SettingsTLMode; - char *m_SettingsGameFile; - CBFader *m_Fader; - bool m_SuppressScriptErrors; + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + bool _mouseLeftDown; + bool _mouseRightDown; + bool _mouseMidlleDown; + CBStringTable *_stringTable; + + int _settingsResWidth; + int _settingsResHeight; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + char *_settingsGameFile; + CBFader *_fader; + bool _suppressScriptErrors; virtual HRESULT InvalidateDeviceObjects(); virtual HRESULT RestoreDeviceObjects(); @@ -230,42 +230,42 @@ public: virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); virtual char *ScToString(); // compatibility bits - bool m_CompatKillMethodThreads; + bool _compatKillMethodThreads; private: // FPS stuff - uint32 m_LastTime; - uint32 m_FpsTime; - uint32 m_FramesRendered; + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; public: - uint32 m_SurfaceGCCycleTime; - bool m_SmartCache; - bool m_VideoSubtitles; - bool m_Subtitles; - uint32 m_MusicStartTime[NUM_MUSIC_CHANNELS]; - bool m_CompressedSavegames; - int m_ScheduledLoadSlot; - bool m_Loading; - bool m_PersonalizedSave; + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; HRESULT EmptySaveSlot(int Slot); bool IsSaveSlotUsed(int Slot); HRESULT GetSaveSlotDescription(int Slot, char *Buffer); HRESULT GetSaveSlotFilename(int Slot, char *Buffer); void SetWindowTitle(); virtual bool HandleMouseWheel(int Delta); - bool m_Quitting; + bool _quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); virtual bool HandleKeypress(SDL_Event *event); - int m_FreezeLevel; + int _freezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); - bool m_LoadInProgress; - CUIWindow *m_FocusedWindow; - bool m_EditorForceScripts; + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; static void AfterLoadRegion(void *Region, void *Data); static void AfterLoadSubFrame(void *Subframe, void *Data); static void AfterLoadSound(void *Sound, void *Data); @@ -279,55 +279,55 @@ public: HRESULT PauseMusic(int Channel); HRESULT StopMusic(int Channel); HRESULT PlayMusic(int Channel, char *Filename, bool Looping = true, uint32 LoopStart = 0); - CBSound *m_Music[NUM_MUSIC_CHANNELS]; - bool m_MusicCrossfadeRunning; - bool m_MusicCrossfadeSwap; - uint32 m_MusicCrossfadeStartTime; - uint32 m_MusicCrossfadeLength; - int m_MusicCrossfadeChannel1; - int m_MusicCrossfadeChannel2; + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; HRESULT DisplayWindows(bool InGame = false); - CBRegistry *m_Registry; - bool m_UseD3D; + CBRegistry *_registry; + bool _useD3D; virtual HRESULT Cleanup(); virtual HRESULT LoadGame(int Slot); virtual HRESULT LoadGame(char *Filename); virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); virtual HRESULT ShowCursor(); - CBSprite *m_CursorNoninteractive; - CBObject *m_ActiveObject; - CBKeyboardState *m_KeyboardState; - bool m_Interactive; - TGameState m_State; - TGameState m_OrigState; - bool m_OrigInteractive; - uint32 m_Timer; - uint32 m_TimerDelta; - uint32 m_TimerLast; - - uint32 m_LiveTimer; - uint32 m_LiveTimerDelta; - uint32 m_LiveTimerLast; - - CBObject *m_CapturedObject; - POINT m_MousePos; + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + POINT _mousePos; bool ValidObject(CBObject *Object); HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); void QuickMessage(char *Text); void QuickMessageForm(LPSTR fmt, ...); HRESULT DisplayQuickMsg(); - uint32 m_Fps; + uint32 _fps; HRESULT UpdateMusicCrossfade(); - CBArray m_RegObjects; + CBArray _regObjects; public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); virtual HRESULT DisplayContentSimple(); - bool m_ForceNonStreamedSounds; + bool _forceNonStreamedSounds; void ResetMousePos(); - int m_SubtitlesSpeed; + int _subtitlesSpeed; void SetInteractive(bool State); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); @@ -336,20 +336,20 @@ public: HRESULT PopViewport(); HRESULT PushViewport(CBViewport *Viewport); HRESULT SetActiveObject(CBObject *Obj); - CBSprite *m_LastCursor; + CBSprite *_lastCursor; HRESULT DrawCursor(CBSprite *Cursor); virtual HRESULT InitAfterLoad(); - CBSaveThumbHelper *m_CachedThumbnail; + CBSaveThumbHelper *_cachedThumbnail; AnsiString GetDataDir(); void AddMem(int bytes); - bool m_TouchInterface; - bool m_ConstrainedMemory; + bool _touchInterface; + bool _constrainedMemory; AnsiString GetDeviceType() const; private: - CBDebugger *m_DebugMgr; + CBDebugger *_debugMgr; struct LastClickInfo { LastClickInfo() { @@ -362,17 +362,17 @@ private: uint32 Time; }; - LastClickInfo m_LastClick[2]; + LastClickInfo _lastClick[2]; bool IsDoubleClick(int buttonIndex); - uint32 m_UsedMem; + uint32 _usedMem; protected: // WME Lite specific - bool m_AutoSaveOnExit; - int m_AutoSaveSlot; - bool m_CursorHidden; + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; public: void AutoSaveOnExit(); diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp index 6f0d0235aa..a773bc00c9 100644 --- a/engines/wintermute/BImage.cpp +++ b/engines/wintermute/BImage.cpp @@ -32,16 +32,16 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { #if 0 - m_Bitmap = bitmap; + _bitmap = bitmap; #endif - m_Bitmap = NULL; + _bitmap = NULL; } ////////////////////////////////////////////////////////////////////// CBImage::~CBImage() { #if 0 - if (m_Bitmap) FreeImage_Unload(m_Bitmap); + if (_bitmap) FreeImage_Unload(_bitmap); #endif } @@ -49,9 +49,9 @@ CBImage::~CBImage() { ////////////////////////////////////////////////////////////////////////// HRESULT CBImage::SaveBMPFile(char *Filename) { #if 0 - if (!m_Bitmap) return E_FAIL; + if (!_bitmap) return E_FAIL; - if (FreeImage_Save(FIF_BMP, m_Bitmap, Filename)) return S_OK; + if (FreeImage_Save(FIF_BMP, _bitmap, Filename)) return S_OK; else return E_FAIL; #endif return E_FAIL; @@ -61,16 +61,16 @@ HRESULT CBImage::SaveBMPFile(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBImage::Resize(int NewWidth, int NewHeight) { #if 0 - if (!m_Bitmap) return E_FAIL; + if (!_bitmap) return E_FAIL; - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(m_Bitmap); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(m_Bitmap); + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); - FIBITMAP *newImg = FreeImage_Rescale(m_Bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); if (newImg) { - FreeImage_Unload(m_Bitmap); - m_Bitmap = newImg; + FreeImage_Unload(_bitmap); + _bitmap = newImg; return S_OK; } else return E_FAIL; #endif @@ -80,10 +80,10 @@ HRESULT CBImage::Resize(int NewWidth, int NewHeight) { ////////////////////////////////////////////////////////////////////////// byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { - if (!m_Bitmap) return NULL; + if (!_bitmap) return NULL; #if 0 FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, m_Bitmap, fiMem); + FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); uint32 size; byte *data; FreeImage_AcquireMemory(fiMem, &data, &size); @@ -104,12 +104,12 @@ byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { ////////////////////////////////////////////////////////////////////////// HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { #if 0 - if (m_Bitmap) FreeImage_Unload(m_Bitmap); + if (_bitmap) FreeImage_Unload(_bitmap); if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - m_Bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); + _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); #endif return S_OK; } diff --git a/engines/wintermute/BImage.h b/engines/wintermute/BImage.h index a738fb418b..98b6dfaac6 100644 --- a/engines/wintermute/BImage.h +++ b/engines/wintermute/BImage.h @@ -51,10 +51,10 @@ public: HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); FIBITMAP *GetBitmap() const { - return m_Bitmap; + return _bitmap; } private: - FIBITMAP *m_Bitmap; + FIBITMAP *_bitmap; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index d15b800d8e..6b68f4a2d3 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -37,13 +37,13 @@ IMPLEMENT_PERSISTENT(CBKeyboardState, false) ////////////////////////////////////////////////////////////////////////// CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { - m_CurrentPrintable = false; - m_CurrentCharCode = 0; - m_CurrentKeyData = 0; + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; - m_CurrentShift = false; - m_CurrentAlt = false; - m_CurrentControl = false; + _currentShift = false; + _currentAlt = false; + _currentControl = false; } @@ -65,7 +65,7 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta CScValue *val = Stack->Pop(); int vKey; - if (val->m_Type == VAL_STRING && strlen(val->GetString()) > 0) { + if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { char *str = val->GetString(); if (str[0] >= 'A' && str[0] <= 'Z') str[0] += ('a' - 'A'); vKey = (int)str[0]; @@ -86,68 +86,68 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta ////////////////////////////////////////////////////////////////////////// CScValue *CBKeyboardState::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("keyboard"); - return m_ScValue; + _scValue->SetString("keyboard"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Key ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Key") == 0) { - if (m_CurrentPrintable) { + if (_currentPrintable) { char key[2]; - key[0] = (char)m_CurrentCharCode; + key[0] = (char)_currentCharCode; key[1] = '\0'; - m_ScValue->SetString(key); - } else m_ScValue->SetString(""); + _scValue->SetString(key); + } else _scValue->SetString(""); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Printable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Printable") == 0) { - m_ScValue->SetBool(m_CurrentPrintable); - return m_ScValue; + _scValue->SetBool(_currentPrintable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // KeyCode ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "KeyCode") == 0) { - m_ScValue->SetInt(m_CurrentCharCode); - return m_ScValue; + _scValue->SetInt(_currentCharCode); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // IsShift ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsShift") == 0) { - m_ScValue->SetBool(m_CurrentShift); - return m_ScValue; + _scValue->SetBool(_currentShift); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // IsAlt ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsAlt") == 0) { - m_ScValue->SetBool(m_CurrentAlt); - return m_ScValue; + _scValue->SetBool(_currentAlt); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // IsControl ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsControl") == 0) { - m_ScValue->SetBool(m_CurrentControl); - return m_ScValue; + _scValue->SetBool(_currentControl); + return _scValue; } else return CBScriptable::ScGetProperty(Name); @@ -162,7 +162,7 @@ HRESULT CBKeyboardState::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// if(strcmp(Name, "Name")==0){ SetName(Value->GetString()); - if(m_Renderer) SetWindowText(m_Renderer->m_Window, m_Name); + if(_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } @@ -178,13 +178,13 @@ char *CBKeyboardState::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBKeyboardState::ReadKey(SDL_Event *event) { - //m_CurrentPrintable = (event->type == SDL_TEXTINPUT); // TODO - m_CurrentCharCode = KeyCodeToVKey(event); - //m_CurrentKeyData = KeyData; + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = KeyCodeToVKey(event); + //_currentKeyData = KeyData; - m_CurrentControl = IsControlDown(); - m_CurrentAlt = IsAltDown(); - m_CurrentShift = IsShiftDown(); + _currentControl = IsControlDown(); + _currentAlt = IsAltDown(); + _currentShift = IsShiftDown(); return S_OK; } @@ -192,15 +192,15 @@ HRESULT CBKeyboardState::ReadKey(SDL_Event *event) { ////////////////////////////////////////////////////////////////////////// HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { - //if(!PersistMgr->m_Saving) Cleanup(); + //if(!PersistMgr->_saving) Cleanup(); CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_CurrentAlt)); - PersistMgr->Transfer(TMEMBER(m_CurrentCharCode)); - PersistMgr->Transfer(TMEMBER(m_CurrentControl)); - PersistMgr->Transfer(TMEMBER(m_CurrentKeyData)); - PersistMgr->Transfer(TMEMBER(m_CurrentPrintable)); - PersistMgr->Transfer(TMEMBER(m_CurrentShift)); + PersistMgr->Transfer(TMEMBER(_currentAlt)); + PersistMgr->Transfer(TMEMBER(_currentCharCode)); + PersistMgr->Transfer(TMEMBER(_currentControl)); + PersistMgr->Transfer(TMEMBER(_currentKeyData)); + PersistMgr->Transfer(TMEMBER(_currentPrintable)); + PersistMgr->Transfer(TMEMBER(_currentShift)); return S_OK; } diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index 5d4a6bada6..9b43190382 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -39,13 +39,13 @@ namespace WinterMute { class CBKeyboardState : public CBScriptable { public: - uint32 m_CurrentKeyData; - uint32 m_CurrentCharCode; - bool m_CurrentPrintable; + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; - bool m_CurrentShift; - bool m_CurrentAlt; - bool m_CurrentControl; + bool _currentShift; + bool _currentAlt; + bool _currentControl; DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) CBKeyboardState(CBGame *inGame); diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp index 161f479b81..fb8526ddad 100644 --- a/engines/wintermute/BNamedObject.cpp +++ b/engines/wintermute/BNamedObject.cpp @@ -33,33 +33,33 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { - m_Name = NULL; + _name = NULL; } ////////////////////////////////////////////////////////////////////////// CBNamedObject::CBNamedObject() : CBBase() { - m_Name = NULL; + _name = NULL; } ////////////////////////////////////////////////////////////////////////// CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { - m_Name = NULL; + _name = NULL; } ////////////////////////////////////////////////////////////////////////// CBNamedObject::~CBNamedObject(void) { - delete[] m_Name; - m_Name = NULL; + delete[] _name; + _name = NULL; } ////////////////////////////////////////////////////////////////////// void CBNamedObject::SetName(char *Name) { - delete[] m_Name; + delete[] _name; - m_Name = new char [strlen(Name) + 1]; - if (m_Name != NULL) strcpy(m_Name, Name); + _name = new char [strlen(Name) + 1]; + if (_name != NULL) strcpy(_name, Name); } } // end of namespace WinterMute diff --git a/engines/wintermute/BNamedObject.h b/engines/wintermute/BNamedObject.h index 6473748134..c3b9abb7bc 100644 --- a/engines/wintermute/BNamedObject.h +++ b/engines/wintermute/BNamedObject.h @@ -41,7 +41,7 @@ public: virtual ~CBNamedObject(void); CBNamedObject(TDynamicConstructor, TDynamicConstructor); - char *m_Name; + char *_name; void SetName(char *Name); }; diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 43fb347cc3..3665341550 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -44,58 +44,58 @@ IMPLEMENT_PERSISTENT(CBObject, false) ////////////////////////////////////////////////////////////////////// CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { - m_PosX = m_PosY = 0; - m_Movable = true; - m_Zoomable = true; - m_Registrable = true; - m_Shadowable = true; - m_Rotatable = false; - m_Is3D = false; + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; - m_AlphaColor = 0; - m_Scale = -1; - m_RelativeScale = 0; + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; - m_ScaleX = -1; - m_ScaleY = -1; + _scaleX = -1; + _scaleY = -1; - m_Ready = true; + _ready = true; - m_SoundEvent = NULL; + _soundEvent = NULL; - m_ID = Game->GetSequence(); + _iD = Game->GetSequence(); - CBPlatform::SetRectEmpty(&m_Rect); - m_RectSet = false; + CBPlatform::SetRectEmpty(&_rect); + _rectSet = false; - m_Cursor = NULL; - m_ActiveCursor = NULL; - m_SharedCursors = false; + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; - m_SFX = NULL; - m_SFXStart = 0; - m_SFXVolume = 100; - m_AutoSoundPanning = true; + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; - m_EditorAlwaysRegister = false; - m_EditorSelected = false; + _editorAlwaysRegister = false; + _editorSelected = false; - m_EditorOnly = false; + _editorOnly = false; - m_Rotate = 0.0f; - m_RotateValid = false; - m_RelativeRotate = 0.0f; + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; - for (int i = 0; i < 7; i++) m_Caption[i] = NULL; - m_SaveState = true; + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _saveState = true; - m_NonIntMouseEvents = false; + _nonIntMouseEvents = false; // sound FX - m_SFXType = SFX_NONE; - m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - m_BlendMode = BLEND_NORMAL; + _blendMode = BLEND_NORMAL; } @@ -107,28 +107,28 @@ CBObject::~CBObject() { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::Cleanup() { - if (Game && Game->m_ActiveObject == this) Game->m_ActiveObject = NULL; + if (Game && Game->_activeObject == this) Game->_activeObject = NULL; CBScriptHolder::Cleanup(); - delete[] m_SoundEvent; - m_SoundEvent = NULL; + delete[] _soundEvent; + _soundEvent = NULL; - if (!m_SharedCursors) { - delete m_Cursor; - delete m_ActiveCursor; - m_Cursor = NULL; - m_ActiveCursor = NULL; + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; } - delete m_SFX; - m_SFX = NULL; + delete _sFX; + _sFX = NULL; for (int i = 0; i < 7; i++) { - delete[] m_Caption[i]; - m_Caption[i] = NULL; + delete[] _caption[i]; + _caption[i] = NULL; } - m_SFXType = SFX_NONE; - m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; return S_OK; } @@ -139,11 +139,11 @@ void CBObject::SetCaption(char *Caption, int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; - delete[] m_Caption[Case - 1]; - m_Caption[Case - 1] = new char[strlen(Caption) + 1]; - if (m_Caption[Case - 1]) { - strcpy(m_Caption[Case - 1], Caption); - Game->m_StringTable->Expand(&m_Caption[Case - 1]); + delete[] _caption[Case - 1]; + _caption[Case - 1] = new char[strlen(Caption) + 1]; + if (_caption[Case - 1]) { + strcpy(_caption[Case - 1], Caption); + Game->_stringTable->Expand(&_caption[Case - 1]); } } @@ -151,8 +151,8 @@ void CBObject::SetCaption(char *Caption, int Case) { ////////////////////////////////////////////////////////////////////////// char *CBObject::GetCaption(int Case) { if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || m_Caption[Case - 1] == NULL) return ""; - else return m_Caption[Case - 1]; + if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; + else return _caption[Case - 1]; } @@ -172,8 +172,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "SkipTo") == 0) { Stack->CorrectParams(2); - m_PosX = Stack->Pop()->GetInt(); - m_PosY = Stack->Pop()->GetInt(); + _posX = Stack->Pop()->GetInt(); + _posY = Stack->Pop()->GetInt(); AfterMove(); Stack->PushNULL(); @@ -206,11 +206,11 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveCursor") == 0) { Stack->CorrectParams(0); - if (!m_SharedCursors) { - delete m_Cursor; - m_Cursor = NULL; + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; } else { - m_Cursor = NULL; + _cursor = NULL; } Stack->PushNULL(); @@ -223,8 +223,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetCursor") == 0) { Stack->CorrectParams(0); - if (!m_Cursor || !m_Cursor->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_Cursor->m_Filename); + if (!_cursor || !_cursor->_filename) Stack->PushNULL(); + else Stack->PushString(_cursor->_filename); return S_OK; } @@ -234,8 +234,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetCursorObject") == 0) { Stack->CorrectParams(0); - if (!m_Cursor) Stack->PushNULL(); - else Stack->PushNative(m_Cursor, true); + if (!_cursor) Stack->PushNULL(); + else Stack->PushNative(_cursor, true); return S_OK; } @@ -246,7 +246,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "HasCursor") == 0) { Stack->CorrectParams(0); - if (m_Cursor) Stack->PushBool(true); + if (_cursor) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -291,7 +291,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *val2 = Stack->Pop(); CScValue *val3 = Stack->Pop(); - if (val1->m_Type == VAL_BOOL) { + if (val1->_type == VAL_BOOL) { Filename = NULL; Looping = val1->GetBool(); LoopStart = val2->GetInt(); @@ -371,7 +371,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "IsSoundPlaying") == 0) { Stack->CorrectParams(0); - if (m_SFX && m_SFX->IsPlaying()) Stack->PushBool(true); + if (_sFX && _sFX->IsPlaying()) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; } @@ -394,8 +394,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "GetSoundPosition") == 0) { Stack->CorrectParams(0); - if (!m_SFX) Stack->PushInt(0); - else Stack->PushInt(m_SFX->GetPositionTime()); + if (!_sFX) Stack->PushInt(0); + else Stack->PushInt(_sFX->GetPositionTime()); return S_OK; } @@ -417,8 +417,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "GetSoundVolume") == 0) { Stack->CorrectParams(0); - if (!m_SFX) Stack->PushInt(m_SFXVolume); - else Stack->PushInt(m_SFX->GetVolume()); + if (!_sFX) Stack->PushInt(_sFXVolume); + else Stack->PushInt(_sFX->GetVolume()); return S_OK; } @@ -428,11 +428,11 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundFXNone") == 0) { Stack->CorrectParams(0); - m_SFXType = SFX_NONE; - m_SFXParam1 = 0; - m_SFXParam2 = 0; - m_SFXParam3 = 0; - m_SFXParam4 = 0; + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; Stack->PushNULL(); return S_OK; @@ -443,11 +443,11 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundFXEcho") == 0) { Stack->CorrectParams(4); - m_SFXType = SFX_ECHO; - m_SFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) - m_SFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) - m_SFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) - m_SFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + _sFXType = SFX_ECHO; + _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) Stack->PushNULL(); return S_OK; @@ -458,11 +458,11 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundFXReverb") == 0) { Stack->CorrectParams(4); - m_SFXType = SFX_REVERB; - m_SFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) - m_SFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) - m_SFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - m_SFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + _sFXType = SFX_REVERB; + _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) Stack->PushNULL(); return S_OK; @@ -474,191 +474,191 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CBObject::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("object"); - return m_ScValue; + _scValue->SetString("object"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Caption") == 0) { - m_ScValue->SetString(GetCaption(1)); - return m_ScValue; + _scValue->SetString(GetCaption(1)); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "X") == 0) { - m_ScValue->SetInt(m_PosX); - return m_ScValue; + _scValue->SetInt(_posX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Y") == 0) { - m_ScValue->SetInt(m_PosY); - return m_ScValue; + _scValue->SetInt(_posY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_ScValue->SetInt(GetHeight()); - return m_ScValue; + _scValue->SetInt(GetHeight()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Ready (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Ready") == 0) { - m_ScValue->SetBool(m_Ready); - return m_ScValue; + _scValue->SetBool(_ready); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Movable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Movable") == 0) { - m_ScValue->SetBool(m_Movable); - return m_ScValue; + _scValue->SetBool(_movable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { - m_ScValue->SetBool(m_Registrable); - return m_ScValue; + _scValue->SetBool(_registrable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { - m_ScValue->SetBool(m_Zoomable); - return m_ScValue; + _scValue->SetBool(_zoomable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotatable") == 0) { - m_ScValue->SetBool(m_Rotatable); - return m_ScValue; + _scValue->SetBool(_rotatable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaColor") == 0) { - m_ScValue->SetInt((int)m_AlphaColor); - return m_ScValue; + _scValue->SetInt((int)_alphaColor); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // BlendMode ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "BlendMode") == 0) { - m_ScValue->SetInt((int)m_BlendMode); - return m_ScValue; + _scValue->SetInt((int)_blendMode); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale") == 0) { - if (m_Scale < 0) m_ScValue->SetNULL(); - else m_ScValue->SetFloat((double)m_Scale); - return m_ScValue; + if (_scale < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scale); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleX") == 0) { - if (m_ScaleX < 0) m_ScValue->SetNULL(); - else m_ScValue->SetFloat((double)m_ScaleX); - return m_ScValue; + if (_scaleX < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scaleX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleY") == 0) { - if (m_ScaleY < 0) m_ScValue->SetNULL(); - else m_ScValue->SetFloat((double)m_ScaleY); - return m_ScValue; + if (_scaleY < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scaleY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // RelativeScale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RelativeScale") == 0) { - m_ScValue->SetFloat((double)m_RelativeScale); - return m_ScValue; + _scValue->SetFloat((double)_relativeScale); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotate") == 0) { - if (!m_RotateValid) m_ScValue->SetNULL(); - else m_ScValue->SetFloat((double)m_Rotate); - return m_ScValue; + if (!_rotateValid) _scValue->SetNULL(); + else _scValue->SetFloat((double)_rotate); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // RelativeRotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RelativeRotate") == 0) { - m_ScValue->SetFloat((double)m_RelativeRotate); - return m_ScValue; + _scValue->SetFloat((double)_relativeRotate); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Colorable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Colorable") == 0) { - m_ScValue->SetBool(m_Shadowable); - return m_ScValue; + _scValue->SetBool(_shadowable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundPanning") == 0) { - m_ScValue->SetBool(m_AutoSoundPanning); - return m_ScValue; + _scValue->SetBool(_autoSoundPanning); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SaveState ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SaveState") == 0) { - m_ScValue->SetBool(m_SaveState); - return m_ScValue; + _scValue->SetBool(_saveState); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NonIntMouseEvents") == 0) { - m_ScValue->SetBool(m_NonIntMouseEvents); - return m_ScValue; + _scValue->SetBool(_nonIntMouseEvents); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccCaption") == 0) { - m_ScValue->SetNULL(); - return m_ScValue; + _scValue->SetNULL(); + return _scValue; } else return CBScriptHolder::ScGetProperty(Name); @@ -679,7 +679,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "X") == 0) { - m_PosX = Value->GetInt(); + _posX = Value->GetInt(); AfterMove(); return S_OK; } @@ -688,7 +688,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Y") == 0) { - m_PosY = Value->GetInt(); + _posY = Value->GetInt(); AfterMove(); return S_OK; } @@ -697,7 +697,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Movable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Movable") == 0) { - m_Movable = Value->GetBool(); + _movable = Value->GetBool(); return S_OK; } @@ -705,7 +705,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { - m_Registrable = Value->GetBool(); + _registrable = Value->GetBool(); return S_OK; } @@ -713,7 +713,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { - m_Zoomable = Value->GetBool(); + _zoomable = Value->GetBool(); return S_OK; } @@ -721,7 +721,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Rotatable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotatable") == 0) { - m_Rotatable = Value->GetBool(); + _rotatable = Value->GetBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaColor") == 0) { - m_AlphaColor = (uint32)Value->GetInt(); + _alphaColor = (uint32)Value->GetInt(); return S_OK; } @@ -739,7 +739,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { else if (strcmp(Name, "BlendMode") == 0) { int i = Value->GetInt(); if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; - m_BlendMode = (TSpriteBlendMode)i; + _blendMode = (TSpriteBlendMode)i; return S_OK; } @@ -747,8 +747,8 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale") == 0) { - if (Value->IsNULL()) m_Scale = -1; - else m_Scale = (float)Value->GetFloat(); + if (Value->IsNULL()) _scale = -1; + else _scale = (float)Value->GetFloat(); return S_OK; } @@ -756,8 +756,8 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleX") == 0) { - if (Value->IsNULL()) m_ScaleX = -1; - else m_ScaleX = (float)Value->GetFloat(); + if (Value->IsNULL()) _scaleX = -1; + else _scaleX = (float)Value->GetFloat(); return S_OK; } @@ -765,8 +765,8 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleY") == 0) { - if (Value->IsNULL()) m_ScaleY = -1; - else m_ScaleY = (float)Value->GetFloat(); + if (Value->IsNULL()) _scaleY = -1; + else _scaleY = (float)Value->GetFloat(); return S_OK; } @@ -774,7 +774,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // RelativeScale ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RelativeScale") == 0) { - m_RelativeScale = (float)Value->GetFloat(); + _relativeScale = (float)Value->GetFloat(); return S_OK; } @@ -783,11 +783,11 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotate") == 0) { if (Value->IsNULL()) { - m_Rotate = 0.0f; - m_RotateValid = false; + _rotate = 0.0f; + _rotateValid = false; } else { - m_Rotate = (float)Value->GetFloat(); - m_RotateValid = true; + _rotate = (float)Value->GetFloat(); + _rotateValid = true; } return S_OK; } @@ -796,7 +796,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // RelativeRotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RelativeRotate") == 0) { - m_RelativeRotate = (float)Value->GetFloat(); + _relativeRotate = (float)Value->GetFloat(); return S_OK; } @@ -804,7 +804,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // Colorable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Colorable") == 0) { - m_Shadowable = Value->GetBool(); + _shadowable = Value->GetBool(); return S_OK; } @@ -812,8 +812,8 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // SoundPanning ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundPanning") == 0) { - m_AutoSoundPanning = Value->GetBool(); - if (!m_AutoSoundPanning) ResetSoundPan(); + _autoSoundPanning = Value->GetBool(); + if (!_autoSoundPanning) ResetSoundPan(); return S_OK; } @@ -821,7 +821,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // SaveState ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SaveState") == 0) { - m_SaveState = Value->GetBool(); + _saveState = Value->GetBool(); return S_OK; } @@ -829,7 +829,7 @@ HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NonIntMouseEvents") == 0) { - m_NonIntMouseEvents = Value->GetBool(); + _nonIntMouseEvents = Value->GetBool(); return S_OK; } @@ -852,7 +852,7 @@ char *CBObject::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::ShowCursor() { - if (m_Cursor) return Game->DrawCursor(m_Cursor); + if (_cursor) return Game->DrawCursor(_cursor); else return E_FAIL; } @@ -867,52 +867,52 @@ HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { CBScriptHolder::Persist(PersistMgr); - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(m_Caption[i])); - PersistMgr->Transfer(TMEMBER(m_ActiveCursor)); - PersistMgr->Transfer(TMEMBER(m_AlphaColor)); - PersistMgr->Transfer(TMEMBER(m_AutoSoundPanning)); - PersistMgr->Transfer(TMEMBER(m_Cursor)); - PersistMgr->Transfer(TMEMBER(m_SharedCursors)); - PersistMgr->Transfer(TMEMBER(m_EditorAlwaysRegister)); - PersistMgr->Transfer(TMEMBER(m_EditorOnly)); - PersistMgr->Transfer(TMEMBER(m_EditorSelected)); - PersistMgr->Transfer(TMEMBER(m_ID)); - PersistMgr->Transfer(TMEMBER(m_Is3D)); - PersistMgr->Transfer(TMEMBER(m_Movable)); - PersistMgr->Transfer(TMEMBER(m_PosX)); - PersistMgr->Transfer(TMEMBER(m_PosY)); - PersistMgr->Transfer(TMEMBER(m_RelativeScale)); - PersistMgr->Transfer(TMEMBER(m_Rotatable)); - PersistMgr->Transfer(TMEMBER(m_Scale)); - PersistMgr->Transfer(TMEMBER(m_SFX)); - PersistMgr->Transfer(TMEMBER(m_SFXStart)); - PersistMgr->Transfer(TMEMBER(m_SFXVolume)); - PersistMgr->Transfer(TMEMBER(m_Ready)); - PersistMgr->Transfer(TMEMBER(m_Rect)); - PersistMgr->Transfer(TMEMBER(m_RectSet)); - PersistMgr->Transfer(TMEMBER(m_Registrable)); - PersistMgr->Transfer(TMEMBER(m_Shadowable)); - PersistMgr->Transfer(TMEMBER(m_SoundEvent)); - PersistMgr->Transfer(TMEMBER(m_Zoomable)); - - PersistMgr->Transfer(TMEMBER(m_ScaleX)); - PersistMgr->Transfer(TMEMBER(m_ScaleY)); - - PersistMgr->Transfer(TMEMBER(m_Rotate)); - PersistMgr->Transfer(TMEMBER(m_RotateValid)); - PersistMgr->Transfer(TMEMBER(m_RelativeRotate)); - - PersistMgr->Transfer(TMEMBER(m_SaveState)); - PersistMgr->Transfer(TMEMBER(m_NonIntMouseEvents)); - - PersistMgr->Transfer(TMEMBER_INT(m_SFXType)); - PersistMgr->Transfer(TMEMBER(m_SFXParam1)); - PersistMgr->Transfer(TMEMBER(m_SFXParam2)); - PersistMgr->Transfer(TMEMBER(m_SFXParam3)); - PersistMgr->Transfer(TMEMBER(m_SFXParam4)); - - - PersistMgr->Transfer(TMEMBER_INT(m_BlendMode)); + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); + PersistMgr->Transfer(TMEMBER(_activeCursor)); + PersistMgr->Transfer(TMEMBER(_alphaColor)); + PersistMgr->Transfer(TMEMBER(_autoSoundPanning)); + PersistMgr->Transfer(TMEMBER(_cursor)); + PersistMgr->Transfer(TMEMBER(_sharedCursors)); + PersistMgr->Transfer(TMEMBER(_editorAlwaysRegister)); + PersistMgr->Transfer(TMEMBER(_editorOnly)); + PersistMgr->Transfer(TMEMBER(_editorSelected)); + PersistMgr->Transfer(TMEMBER(_iD)); + PersistMgr->Transfer(TMEMBER(_is3D)); + PersistMgr->Transfer(TMEMBER(_movable)); + PersistMgr->Transfer(TMEMBER(_posX)); + PersistMgr->Transfer(TMEMBER(_posY)); + PersistMgr->Transfer(TMEMBER(_relativeScale)); + PersistMgr->Transfer(TMEMBER(_rotatable)); + PersistMgr->Transfer(TMEMBER(_scale)); + PersistMgr->Transfer(TMEMBER(_sFX)); + PersistMgr->Transfer(TMEMBER(_sFXStart)); + PersistMgr->Transfer(TMEMBER(_sFXVolume)); + PersistMgr->Transfer(TMEMBER(_ready)); + PersistMgr->Transfer(TMEMBER(_rect)); + PersistMgr->Transfer(TMEMBER(_rectSet)); + PersistMgr->Transfer(TMEMBER(_registrable)); + PersistMgr->Transfer(TMEMBER(_shadowable)); + PersistMgr->Transfer(TMEMBER(_soundEvent)); + PersistMgr->Transfer(TMEMBER(_zoomable)); + + PersistMgr->Transfer(TMEMBER(_scaleX)); + PersistMgr->Transfer(TMEMBER(_scaleY)); + + PersistMgr->Transfer(TMEMBER(_rotate)); + PersistMgr->Transfer(TMEMBER(_rotateValid)); + PersistMgr->Transfer(TMEMBER(_relativeRotate)); + + PersistMgr->Transfer(TMEMBER(_saveState)); + PersistMgr->Transfer(TMEMBER(_nonIntMouseEvents)); + + PersistMgr->Transfer(TMEMBER_INT(_sFXType)); + PersistMgr->Transfer(TMEMBER(_sFXParam1)); + PersistMgr->Transfer(TMEMBER(_sFXParam2)); + PersistMgr->Transfer(TMEMBER(_sFXParam3)); + PersistMgr->Transfer(TMEMBER(_sFXParam4)); + + + PersistMgr->Transfer(TMEMBER_INT(_blendMode)); return S_OK; } @@ -920,16 +920,16 @@ HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::SetCursor(char *Filename) { - if (!m_SharedCursors) { - delete m_Cursor; - m_Cursor = NULL; + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; } - m_SharedCursors = false; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile(Filename))) { - delete m_Cursor; - m_Cursor = NULL; + _sharedCursors = false; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile(Filename))) { + delete _cursor; + _cursor = NULL; return E_FAIL; } else return S_OK; } @@ -937,11 +937,11 @@ HRESULT CBObject::SetCursor(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::SetActiveCursor(char *Filename) { - delete m_ActiveCursor; - m_ActiveCursor = new CBSprite(Game); - if (!m_ActiveCursor || FAILED(m_ActiveCursor->LoadFile(Filename))) { - delete m_ActiveCursor; - m_ActiveCursor = NULL; + delete _activeCursor; + _activeCursor = new CBSprite(Game); + if (!_activeCursor || FAILED(_activeCursor->LoadFile(Filename))) { + delete _activeCursor; + _activeCursor = NULL; return E_FAIL; } else return S_OK; } @@ -974,40 +974,40 @@ bool CBObject::HandleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::PlaySFX(char *Filename, bool Looping, bool PlayNow, char *EventName, uint32 LoopStart) { // just play loaded sound - if (Filename == NULL && m_SFX) { - if (Game->m_EditorMode || m_SFXStart) { - m_SFX->SetVolume(m_SFXVolume); - m_SFX->SetPositionTime(m_SFXStart); - if (!Game->m_EditorMode) m_SFXStart = 0; + if (Filename == NULL && _sFX) { + if (Game->_editorMode || _sFXStart) { + _sFX->SetVolume(_sFXVolume); + _sFX->SetPositionTime(_sFXStart); + if (!Game->_editorMode) _sFXStart = 0; } if (PlayNow) { SetSoundEvent(EventName); - if (LoopStart) m_SFX->SetLoopStart(LoopStart); - return m_SFX->Play(Looping); + if (LoopStart) _sFX->SetLoopStart(LoopStart); + return _sFX->Play(Looping); } else return S_OK; } if (Filename == NULL) return E_FAIL; // create new sound - delete m_SFX; - - m_SFX = new CBSound(Game); - if (m_SFX && SUCCEEDED(m_SFX->SetSound(Filename, SOUND_SFX, true))) { - m_SFX->SetVolume(m_SFXVolume); - if (m_SFXStart) { - m_SFX->SetPositionTime(m_SFXStart); - m_SFXStart = 0; + delete _sFX; + + _sFX = new CBSound(Game); + if (_sFX && SUCCEEDED(_sFX->SetSound(Filename, SOUND_SFX, true))) { + _sFX->SetVolume(_sFXVolume); + if (_sFXStart) { + _sFX->SetPositionTime(_sFXStart); + _sFXStart = 0; } - m_SFX->ApplyFX(m_SFXType, m_SFXParam1, m_SFXParam2, m_SFXParam3, m_SFXParam4); + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (PlayNow) { SetSoundEvent(EventName); - if (LoopStart) m_SFX->SetLoopStart(LoopStart); - return m_SFX->Play(Looping); + if (LoopStart) _sFX->SetLoopStart(LoopStart); + return _sFX->Play(Looping); } else return S_OK; } else { - delete m_SFX; - m_SFX = NULL; + delete _sFX; + _sFX = NULL; return E_FAIL; } } @@ -1015,11 +1015,11 @@ HRESULT CBObject::PlaySFX(char *Filename, bool Looping, bool PlayNow, char *Even ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::StopSFX(bool DeleteSound) { - if (m_SFX) { - m_SFX->Stop(); + if (_sFX) { + _sFX->Stop(); if (DeleteSound) { - delete m_SFX; - m_SFX = NULL; + delete _sFX; + _sFX = NULL; } return S_OK; } else return E_FAIL; @@ -1028,44 +1028,44 @@ HRESULT CBObject::StopSFX(bool DeleteSound) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::PauseSFX() { - if (m_SFX) return m_SFX->Pause(); + if (_sFX) return _sFX->Pause(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::ResumeSFX() { - if (m_SFX) return m_SFX->Resume(); + if (_sFX) return _sFX->Resume(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::SetSFXTime(uint32 Time) { - m_SFXStart = Time; - if (m_SFX && m_SFX->IsPlaying()) return m_SFX->SetPositionTime(Time); + _sFXStart = Time; + if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(Time); else return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::SetSFXVolume(int Volume) { - m_SFXVolume = Volume; - if (m_SFX) return m_SFX->SetVolume(Volume); + _sFXVolume = Volume; + if (_sFX) return _sFX->SetVolume(Volume); else return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::UpdateSounds() { - if (m_SoundEvent) { - if (m_SFX && !m_SFX->IsPlaying()) { - ApplyEvent(m_SoundEvent); + if (_soundEvent) { + if (_sFX && !_sFX->IsPlaying()) { + ApplyEvent(_soundEvent); SetSoundEvent(NULL); } } - if (m_SFX) UpdateOneSound(m_SFX); + if (_sFX) UpdateOneSound(_sFX); return S_OK; } @@ -1075,19 +1075,19 @@ HRESULT CBObject::UpdateOneSound(CBSound *Sound) { HRESULT Ret = S_OK; if (Sound) { - if (m_AutoSoundPanning) - Ret = Sound->SetPan(Game->m_SoundMgr->PosToPan(m_PosX - Game->m_OffsetX, m_PosY - Game->m_OffsetY)); + if (_autoSoundPanning) + Ret = Sound->SetPan(Game->_soundMgr->PosToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); - Ret = Sound->ApplyFX(m_SFXType, m_SFXParam1, m_SFXParam2, m_SFXParam3, m_SFXParam4); + Ret = Sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } return Ret; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::ResetSoundPan() { - if (!m_SFX) return S_OK; + if (!_sFX) return S_OK; else { - return m_SFX->SetPan(0.0f); + return _sFX->SetPan(0.0f); } } @@ -1100,17 +1100,17 @@ bool CBObject::GetExtendedFlag(char *FlagName) { ////////////////////////////////////////////////////////////////////////// bool CBObject::IsReady() { - return m_Ready; + return _ready; } ////////////////////////////////////////////////////////////////////////// void CBObject::SetSoundEvent(char *EventName) { - delete[] m_SoundEvent; - m_SoundEvent = NULL; + delete[] _soundEvent; + _soundEvent = NULL; if (EventName) { - m_SoundEvent = new char[strlen(EventName) + 1]; - if (m_SoundEvent) strcpy(m_SoundEvent, EventName); + _soundEvent = new char[strlen(EventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, EventName); } } diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 3fd22fafcd..43fe719ae2 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -47,39 +47,39 @@ class CScStack; class CScScript; class CBObject : public CBScriptHolder { public: - TSpriteBlendMode m_BlendMode; + TSpriteBlendMode _blendMode; virtual HRESULT AfterMove(); - float m_RelativeRotate; - bool m_RotateValid; - float m_Rotate; + float _relativeRotate; + bool _rotateValid; + float _rotate; void SetSoundEvent(char *EventName); - bool m_Rotatable; - uint32 m_AlphaColor; - float m_Scale; - float m_ScaleX; - float m_ScaleY; - float m_RelativeScale; + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; virtual bool IsReady(); virtual bool GetExtendedFlag(char *FlagName); virtual HRESULT ResetSoundPan(); virtual HRESULT UpdateSounds(); HRESULT UpdateOneSound(CBSound *Sound); - bool m_AutoSoundPanning; - uint32 m_SFXStart; - int m_SFXVolume; + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; HRESULT SetSFXTime(uint32 Time); HRESULT SetSFXVolume(int Volume); HRESULT ResumeSFX(); HRESULT PauseSFX(); HRESULT StopSFX(bool DeleteSound = true); HRESULT PlaySFX(char *Filename, bool Looping = false, bool PlayNow = true, char *EventName = NULL, uint32 LoopStart = 0); - CBSound *m_SFX; + CBSound *_sFX; - TSFXType m_SFXType; - float m_SFXParam1; - float m_SFXParam2; - float m_SFXParam3; - float m_SFXParam4; + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; virtual bool HandleMouseWheel(int Delta); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); @@ -90,32 +90,32 @@ public: HRESULT Cleanup(); char *GetCaption(int Case = 1); void SetCaption(char *Caption, int Case = 1); - bool m_EditorSelected; - bool m_EditorAlwaysRegister; - bool m_EditorOnly; - bool m_Is3D; + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; DECLARE_PERSISTENT(CBObject, CBScriptHolder) virtual HRESULT ShowCursor(); - CBSprite *m_Cursor; - bool m_SharedCursors; - CBSprite *m_ActiveCursor; + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - bool m_Ready; - bool m_Registrable; - bool m_Zoomable; - bool m_Shadowable; - RECT m_Rect; - bool m_RectSet; - int m_ID; - bool m_Movable; + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + RECT _rect; + bool _rectSet; + int _iD; + bool _movable; CBObject(CBGame *inGame); virtual ~CBObject(); - char *m_Caption[7]; - char *m_SoundEvent; - int m_PosY; - int m_PosX; - bool m_SaveState; + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; // base virtual HRESULT Update() { @@ -130,7 +130,7 @@ public: virtual HRESULT RestoreDeviceObjects() { return S_OK; }; - bool m_NonIntMouseEvents; + bool _nonIntMouseEvents; public: diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp index 2193999e2c..64e19491d5 100644 --- a/engines/wintermute/BPackage.cpp +++ b/engines/wintermute/BPackage.cpp @@ -40,35 +40,35 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - m_File = NULL; - m_Name = NULL; - m_CD = 0; - m_Priority = 0; - m_BoundToExe = false; + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; } ////////////////////////////////////////////////////////////////////////// CBPackage::~CBPackage() { - if (m_Name) delete [] m_Name; - CloseFilePointer(m_File); + if (_name) delete [] _name; + CloseFilePointer(_file); } ////////////////////////////////////////////////////////////////////////// HRESULT CBPackage::Open() { - if (m_File) return S_OK; + if (_file) return S_OK; else { - m_File = GetFilePointer(); - return m_File ? S_OK : E_FAIL; + _file = GetFilePointer(); + return _file ? S_OK : E_FAIL; } } ////////////////////////////////////////////////////////////////////////// HRESULT CBPackage::Close() { - delete m_File; - m_File = NULL; + delete _file; + _file = NULL; return S_OK; } @@ -86,10 +86,10 @@ HRESULT CBPackage::Read(Common::File *file, uint32 offset, byte *buffer, uint32 ////////////////////////////////////////////////////////////////////////// Common::File *CBPackage::GetFilePointer() { - Common::File *file = Game->m_FileManager->OpenPackage(m_Name); + Common::File *file = Game->_fileManager->OpenPackage(_name); if (!file) { - Game->m_FileManager->RequestCD(m_CD, m_Name, ""); - file = Game->m_FileManager->OpenPackage(m_Name); + Game->_fileManager->RequestCD(_cD, _name, ""); + file = Game->_fileManager->OpenPackage(_name); } return file; } diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h index 6f1c8e1561..347582da4c 100644 --- a/engines/wintermute/BPackage.h +++ b/engines/wintermute/BPackage.h @@ -43,14 +43,14 @@ public: Common::File *GetFilePointer(); void CloseFilePointer(Common::File*& file); - bool m_BoundToExe; - byte m_Priority; + bool _boundToExe; + byte _priority; HRESULT Read(Common::File *file, uint32 offset, byte *buffer, uint32 size); HRESULT Close(); HRESULT Open(); - char *m_Name; - int m_CD; - Common::File *m_File; + char *_name; + int _cD; + Common::File *_file; CBPackage(CBGame *inGame); virtual ~CBPackage(); diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp index 94de0771f9..7f40cc8030 100644 --- a/engines/wintermute/BParser.cpp +++ b/engines/wintermute/BParser.cpp @@ -44,32 +44,32 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBParser::CBParser(CBGame *inGame): CBBase(inGame) { - m_WhiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(m_WhiteSpace, WHITESPACE); + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); } ////////////////////////////////////////////////////////////////////// CBParser::~CBParser() { - if (m_WhiteSpace != NULL) delete [] m_WhiteSpace; + if (_whiteSpace != NULL) delete [] _whiteSpace; } ////////////////////////////////////////////////////////////////////// char *CBParser::GetLastOffender() { - return m_LastOffender; + return _lastOffender; } ////////////////////////////////////////////////////////////////////// long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { - SkipCharacters(buf, m_WhiteSpace); + SkipCharacters(buf, _whiteSpace); // skip comment lines. while (**buf == ';') { *buf = strchr(*buf, '\n'); - m_ParserLine++; - SkipCharacters(buf, m_WhiteSpace); + _parserLine++; + SkipCharacters(buf, _whiteSpace); } if (! **buf) // at end of file @@ -89,18 +89,18 @@ long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data if (tokens->id == 0) { char *p = strchr(*buf, '\n'); if (p && p > *buf) { - strncpy(m_LastOffender, *buf, MIN((long int)255, p - *buf)); // TODO, clean - } else strcpy(m_LastOffender, ""); + strncpy(_lastOffender, *buf, MIN((long int)255, p - *buf)); // TODO, clean + } else strcpy(_lastOffender, ""); return PARSERR_TOKENNOTFOUND; } // skip the token *buf += strlen(tokens->token); - SkipCharacters(buf, m_WhiteSpace); + SkipCharacters(buf, _whiteSpace); // get optional name *name = GetSubText(buf, '\'', '\''); // single quotes - SkipCharacters(buf, m_WhiteSpace); + SkipCharacters(buf, _whiteSpace); // get optional data if (**buf == '=') // An assignment rather than a command/object. @@ -125,7 +125,7 @@ long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { void CBParser::SkipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { - if (ch == '\n') m_ParserLine++; + if (ch == '\n') _parserLine++; if (strchr(toSkip, ch) == NULL) return; ++*buf; // skip this character @@ -166,7 +166,7 @@ char *CBParser::GetSubText(char **buf, char open, char close) { ////////////////////////////////////////////////////////////////////// char *CBParser::GetAssignmentText(char **buf) { ++*buf; // skip the '=' - SkipCharacters(buf, m_WhiteSpace); + SkipCharacters(buf, _whiteSpace); char *result = *buf; diff --git a/engines/wintermute/BParser.h b/engines/wintermute/BParser.h index 6e4282c833..bf5edf7888 100644 --- a/engines/wintermute/BParser.h +++ b/engines/wintermute/BParser.h @@ -76,11 +76,11 @@ public: void SkipCharacters(char **buf, const char *toSkip); long GetCommand(char **buf, TokenDesc *tokens, char **params); long GetObject(char **buf, TokenDesc *tokens, char **name, char **data); - int m_ParserLine; - char m_LastOffender[255]; + int _parserLine; + char _lastOffender[255]; CBParser(CBGame *inGame = NULL); virtual ~CBParser(); - char *m_WhiteSpace; + char *_whiteSpace; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp index e4002d9299..e8b47441fc 100644 --- a/engines/wintermute/BPersistMgr.cpp +++ b/engines/wintermute/BPersistMgr.cpp @@ -48,21 +48,21 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { - m_Saving = false; - m_Buffer = NULL; - m_BufferSize = 0; - m_Offset = 0; + _saving = false; + _buffer = NULL; + _bufferSize = 0; + _offset = 0; - m_RichBuffer = NULL; - m_RichBufferSize = 0; + _richBuffer = NULL; + _richBufferSize = 0; - m_SavedDescription = NULL; - m_SavedTimestamp = 0; - m_SavedVerMajor = m_SavedVerMinor = m_SavedVerBuild = 0; - m_SavedExtMajor = m_SavedExtMinor = 0; + _savedDescription = NULL; + _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; - m_ThumbnailDataSize = 0; - m_ThumbnailData = NULL; + _thumbnailDataSize = 0; + _thumbnailData = NULL; } @@ -74,28 +74,28 @@ CBPersistMgr::~CBPersistMgr() { ////////////////////////////////////////////////////////////////////////// void CBPersistMgr::Cleanup() { - if (m_Buffer) { - if (m_Saving) free(m_Buffer); - else delete [] m_Buffer; // allocated by file manager + if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager } - m_Buffer = NULL; + _buffer = NULL; - m_BufferSize = 0; - m_Offset = 0; + _bufferSize = 0; + _offset = 0; - delete[] m_RichBuffer; - m_RichBuffer = NULL; - m_RichBufferSize = 0; + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; - m_SavedDescription = NULL; // ref to buffer - m_SavedTimestamp = 0; - m_SavedVerMajor = m_SavedVerMinor = m_SavedVerBuild = 0; - m_SavedExtMajor = m_SavedExtMinor = 0; + _savedDescription = NULL; // ref to buffer + _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; - m_ThumbnailDataSize = 0; - if (m_ThumbnailData) { - delete [] m_ThumbnailData; - m_ThumbnailData = NULL; + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; } } @@ -113,22 +113,22 @@ HRESULT CBPersistMgr::InitSave(char *Desc) { HRESULT res; Cleanup(); - m_Saving = true; + _saving = true; - m_Buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); - if (m_Buffer) { - m_BufferSize = SAVE_BUFFER_INIT_SIZE; + _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); + if (_buffer) { + _bufferSize = SAVE_BUFFER_INIT_SIZE; res = S_OK; } else res = E_FAIL; if (SUCCEEDED(res)) { // get thumbnails - if (!Game->m_CachedThumbnail) { - Game->m_CachedThumbnail = new CBSaveThumbHelper(Game); - if (FAILED(Game->m_CachedThumbnail->StoreThumbnail(true))) { - delete Game->m_CachedThumbnail; - Game->m_CachedThumbnail = NULL; + if (!Game->_cachedThumbnail) { + Game->_cachedThumbnail = new CBSaveThumbHelper(Game); + if (FAILED(Game->_cachedThumbnail->StoreThumbnail(true))) { + delete Game->_cachedThumbnail; + Game->_cachedThumbnail = NULL; } } @@ -147,15 +147,15 @@ HRESULT CBPersistMgr::InitSave(char *Desc) { // new in ver 2 PutDWORD((uint32)DCGF_VER_BUILD); - PutString(Game->m_Name); + PutString(Game->_name); // thumbnail data size bool ThumbnailOK = false; - if (Game->m_CachedThumbnail) { - if (Game->m_CachedThumbnail->m_Thumbnail) { + if (Game->_cachedThumbnail) { + if (Game->_cachedThumbnail->_thumbnail) { uint32 Size = 0; - byte *Buffer = Game->m_CachedThumbnail->m_Thumbnail->CreateBMPBuffer(&Size); + byte *Buffer = Game->_cachedThumbnail->_thumbnail->CreateBMPBuffer(&Size); PutDWORD(Size); if (Size > 0) PutBytes(Buffer, Size); @@ -167,10 +167,10 @@ HRESULT CBPersistMgr::InitSave(char *Desc) { if (!ThumbnailOK) PutDWORD(0); // in any case, destroy the cached thumbnail once used - delete Game->m_CachedThumbnail; - Game->m_CachedThumbnail = NULL; + delete Game->_cachedThumbnail; + Game->_cachedThumbnail = NULL; - uint32 DataOffset = m_Offset + + uint32 DataOffset = _offset + sizeof(uint32) + // data offset sizeof(uint32) + strlen(Desc) + 1 + // description sizeof(uint32); // timestamp @@ -212,10 +212,10 @@ uint16 getHighWord(uint32 dword) { HRESULT CBPersistMgr::InitLoad(char *Filename) { Cleanup(); - m_Saving = false; + _saving = false; - m_Buffer = Game->m_FileManager->ReadWholeFile(Filename, &m_BufferSize); - if (m_Buffer) { + _buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); + if (_buffer) { uint32 Magic; Magic = GetDWORD(); if (Magic != DCGF_MAGIC) goto init_fail; @@ -224,50 +224,50 @@ HRESULT CBPersistMgr::InitLoad(char *Filename) { if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { uint32 Version = GetDWORD(); - m_SavedVerMajor = getLowByte(getLowWord(Version)); - m_SavedVerMinor = getHighByte(getLowWord(Version)); - m_SavedExtMajor = getLowByte(getHighWord(Version)); - m_SavedExtMinor = getHighByte(getHighWord(Version)); + _savedVerMajor = getLowByte(getLowWord(Version)); + _savedVerMinor = getHighByte(getLowWord(Version)); + _savedExtMajor = getLowByte(getHighWord(Version)); + _savedExtMinor = getHighByte(getHighWord(Version)); if (Magic == SAVE_MAGIC_2) { - m_SavedVerBuild = (byte )GetDWORD(); + _savedVerBuild = (byte )GetDWORD(); char *SavedName = GetString(); - if (SavedName == NULL || scumm_stricmp(SavedName, Game->m_Name) != 0) { + if (SavedName == NULL || scumm_stricmp(SavedName, Game->_name) != 0) { Game->LOG(0, "ERROR: Saved game name doesn't match current game"); goto init_fail; } // load thumbnail - m_ThumbnailDataSize = GetDWORD(); - if (m_ThumbnailDataSize > 0) { - m_ThumbnailData = new byte[m_ThumbnailDataSize]; - if (m_ThumbnailData) { - GetBytes(m_ThumbnailData, m_ThumbnailDataSize); - } else m_ThumbnailDataSize = 0; + _thumbnailDataSize = GetDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + GetBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; } - } else m_SavedVerBuild = 35; // last build with ver1 savegames + } else _savedVerBuild = 35; // last build with ver1 savegames // if save is newer version than we are, fail - if (m_SavedVerMajor > DCGF_VER_MAJOR || - (m_SavedVerMajor == DCGF_VER_MAJOR && m_SavedVerMinor > DCGF_VER_MINOR) || - (m_SavedVerMajor == DCGF_VER_MAJOR && m_SavedVerMinor == DCGF_VER_MINOR && m_SavedVerBuild > DCGF_VER_BUILD) + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { Game->LOG(0, "ERROR: Saved game version is newer than current game"); goto init_fail; } // if save is older than the minimal version we support - if (m_SavedVerMajor < SAVEGAME_VER_MAJOR || - (m_SavedVerMajor == SAVEGAME_VER_MAJOR && m_SavedVerMinor < SAVEGAME_VER_MINOR) || - (m_SavedVerMajor == SAVEGAME_VER_MAJOR && m_SavedVerMinor == SAVEGAME_VER_MINOR && m_SavedVerBuild < SAVEGAME_VER_BUILD) + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); goto init_fail; } /* - if( m_SavedVerMajor != DCGF_VER_MAJOR || m_SavedVerMinor != DCGF_VER_MINOR) + if( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) { Game->LOG(0, "ERROR: Saved game is created by other WME version"); goto init_fail; @@ -278,10 +278,10 @@ HRESULT CBPersistMgr::InitLoad(char *Filename) { uint32 DataOffset = GetDWORD(); - m_SavedDescription = GetString(); - m_SavedTimestamp = (time_t)GetDWORD(); + _savedDescription = GetString(); + _savedTimestamp = (time_t)GetDWORD(); - m_Offset = DataOffset; + _offset = DataOffset; return S_OK; } @@ -294,23 +294,23 @@ init_fail: ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::SaveFile(char *Filename) { - return Game->m_FileManager->SaveFile(Filename, m_Buffer, m_Offset, Game->m_CompressedSavegames, m_RichBuffer, m_RichBufferSize); + return Game->_fileManager->SaveFile(Filename, _buffer, _offset, Game->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { - while (m_Offset + Size > m_BufferSize) { - m_BufferSize += SAVE_BUFFER_GROW_BY; - m_Buffer = (byte *)realloc(m_Buffer, m_BufferSize); - if (!m_Buffer) { - Game->LOG(0, "Error reallocating save buffer to %d bytes", m_BufferSize); + while (_offset + Size > _bufferSize) { + _bufferSize += SAVE_BUFFER_GROW_BY; + _buffer = (byte *)realloc(_buffer, _bufferSize); + if (!_buffer) { + Game->LOG(0, "Error reallocating save buffer to %d bytes", _bufferSize); return E_FAIL; } } - memcpy(m_Buffer + m_Offset, Buffer, Size); - m_Offset += Size; + memcpy(_buffer + _offset, Buffer, Size); + _offset += Size; return S_OK; } @@ -318,13 +318,13 @@ HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { - if (m_Offset + Size > m_BufferSize) { + if (_offset + Size > _bufferSize) { Game->LOG(0, "Fatal: Save buffer underflow"); return E_FAIL; } - memcpy(Buffer, m_Buffer + m_Offset, Size); - m_Offset += Size; + memcpy(Buffer, _buffer + _offset, Size); + _offset += Size; return S_OK; } @@ -357,8 +357,8 @@ void CBPersistMgr::PutString(const char *Val) { ////////////////////////////////////////////////////////////////////////// char *CBPersistMgr::GetString() { uint32 len = GetDWORD(); - char *ret = (char *)(m_Buffer + m_Offset); - m_Offset += len; + char *ret = (char *)(_buffer + _offset); + _offset += len; if (!strcmp(ret, "(null)")) return NULL; else return ret; @@ -367,7 +367,7 @@ char *CBPersistMgr::GetString() { ////////////////////////////////////////////////////////////////////////// // bool HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(bool)); + if (_saving) return PutBytes((byte *)Val, sizeof(bool)); else return GetBytes((byte *)Val, sizeof(bool)); } @@ -375,7 +375,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { ////////////////////////////////////////////////////////////////////////// // int HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(int)); + if (_saving) return PutBytes((byte *)Val, sizeof(int)); else return GetBytes((byte *)Val, sizeof(int)); } @@ -383,7 +383,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { ////////////////////////////////////////////////////////////////////////// // DWORD HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(uint32)); + if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); else return GetBytes((byte *)Val, sizeof(uint32)); } @@ -391,7 +391,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { ////////////////////////////////////////////////////////////////////////// // float HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(float)); + if (_saving) return PutBytes((byte *)Val, sizeof(float)); else return GetBytes((byte *)Val, sizeof(float)); } @@ -399,7 +399,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { ////////////////////////////////////////////////////////////////////////// // double HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(double)); + if (_saving) return PutBytes((byte *)Val, sizeof(double)); else return GetBytes((byte *)Val, sizeof(double)); } @@ -407,7 +407,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { ////////////////////////////////////////////////////////////////////////// // char* HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { - if (m_Saving) { + if (_saving) { PutString(*Val); return S_OK; } else { @@ -425,7 +425,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { size_t size; - if (m_Saving) { + if (_saving) { size = Val.size(); PutBytes((byte *)&size, sizeof(size_t)); @@ -448,7 +448,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { ////////////////////////////////////////////////////////////////////////// // BYTE HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(byte )); + if (_saving) return PutBytes((byte *)Val, sizeof(byte )); else return GetBytes((byte *)Val, sizeof(byte )); } @@ -456,7 +456,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { ////////////////////////////////////////////////////////////////////////// // RECT HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(RECT)); + if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); else return GetBytes((byte *)Val, sizeof(RECT)); } @@ -464,7 +464,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { ////////////////////////////////////////////////////////////////////////// // POINT HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(POINT)); + if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); else return GetBytes((byte *)Val, sizeof(POINT)); } @@ -472,7 +472,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { ////////////////////////////////////////////////////////////////////////// // Vector2 HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { - if (m_Saving) return PutBytes((byte *)Val, sizeof(Vector2)); + if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); else return GetBytes((byte *)Val, sizeof(Vector2)); } @@ -482,7 +482,7 @@ HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { int ClassID = -1, InstanceID = -1; - if (m_Saving) { + if (_saving) { CSysClassRegistry::GetInstance()->GetPointerID(*(void **)Val, &ClassID, &InstanceID); if (*(void **)Val != NULL && (ClassID == -1 || InstanceID == -1)) { Game->LOG(0, "Warning: invalid instance '%s'", Name); @@ -503,12 +503,12 @@ HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { ////////////////////////////////////////////////////////////////////////// bool CBPersistMgr::CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild) { - if (m_Saving) return true; + if (_saving) return true; // it's ok if we are same or newer than the saved game - if (VerMajor > m_SavedVerMajor || - (VerMajor == m_SavedVerMajor && VerMinor > m_SavedVerMinor) || - (VerMajor == m_SavedVerMajor && VerMinor == m_SavedVerMinor && VerBuild > m_SavedVerBuild) + if (VerMajor > _savedVerMajor || + (VerMajor == _savedVerMajor && VerMinor > _savedVerMinor) || + (VerMajor == _savedVerMajor && VerMinor == _savedVerMinor && VerBuild > _savedVerBuild) ) return false; return true; diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h index 6a1e42da8a..381308bcac 100644 --- a/engines/wintermute/BPersistMgr.h +++ b/engines/wintermute/BPersistMgr.h @@ -38,13 +38,13 @@ class Vector2; class CBPersistMgr : public CBBase { public: - char *m_SavedDescription; - time_t m_SavedTimestamp; - byte m_SavedVerMajor; - byte m_SavedVerMinor; - byte m_SavedVerBuild; - byte m_SavedExtMajor; - byte m_SavedExtMinor; + char *_savedDescription; + time_t _savedTimestamp; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; HRESULT SaveFile(char *Filename); uint32 GetDWORD(); void PutDWORD(uint32 Val); @@ -55,13 +55,13 @@ public: HRESULT InitSave(char *Desc); HRESULT GetBytes(byte *Buffer, uint32 Size); HRESULT PutBytes(byte *Buffer, uint32 Size); - uint32 m_Offset; - uint32 m_BufferSize; - byte *m_Buffer; - bool m_Saving; + uint32 _offset; + uint32 _bufferSize; + byte *_buffer; + bool _saving; - uint32 m_RichBufferSize; - byte *m_RichBuffer; + uint32 _richBufferSize; + byte *_richBuffer; HRESULT Transfer(const char *Name, void *Val); HRESULT Transfer(const char *Name, int *Val); @@ -79,8 +79,8 @@ public: virtual ~CBPersistMgr(); bool CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild); - uint32 m_ThumbnailDataSize; - byte *m_ThumbnailData; + uint32 _thumbnailDataSize; + byte *_thumbnailData; }; diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index deac1c8817..b8bd760ced 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -48,15 +48,15 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { - m_FileEntry = NULL; - m_File = NULL; - m_Compressed = false; + _fileEntry = NULL; + _file = NULL; + _compressed = false; - m_Stream.zalloc = (alloc_func)0; - m_Stream.zfree = (free_func)0; - m_Stream.opaque = (voidpf)0; + _stream.zalloc = (alloc_func)0; + _stream.zfree = (free_func)0; + _stream.opaque = (voidpf)0; - m_InflateInit = false; + _inflateInit = false; } @@ -78,15 +78,15 @@ HRESULT CBPkgFile::Open(Common::String Filename) { if (fileName[i] == '/') fileName[i] = '\\'; } - m_FileEntry = Game->m_FileManager->GetPackageEntry(fileName); - if (!m_FileEntry) return E_FAIL; + _fileEntry = Game->_fileManager->GetPackageEntry(fileName); + if (!_fileEntry) return E_FAIL; - m_File = m_FileEntry->m_Package->GetFilePointer(); - if (!m_File) return E_FAIL; + _file = _fileEntry->_package->GetFilePointer(); + if (!_file) return E_FAIL; - m_Compressed = (m_FileEntry->m_CompressedLength != 0); - m_Size = m_FileEntry->m_Length; + _compressed = (_fileEntry->_compressedLength != 0); + _size = _fileEntry->_length; SeekToPos(0); @@ -96,17 +96,17 @@ HRESULT CBPkgFile::Open(Common::String Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBPkgFile::Close() { - if (m_FileEntry) { - m_FileEntry->m_Package->CloseFilePointer(m_File); - m_FileEntry = NULL; + if (_fileEntry) { + _fileEntry->_package->CloseFilePointer(_file); + _fileEntry = NULL; } - m_File = NULL; + _file = NULL; - m_Pos = 0; - m_Size = 0; + _pos = 0; + _size = 0; - if (m_InflateInit) inflateEnd(&m_Stream); - m_InflateInit = false; + if (_inflateInit) inflateEnd(&_stream); + _inflateInit = false; return S_OK; } @@ -114,30 +114,30 @@ HRESULT CBPkgFile::Close() { ////////////////////////////////////////////////////////////////////////// HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { - if (!m_FileEntry) return E_FAIL; + if (!_fileEntry) return E_FAIL; HRESULT ret = S_OK; - if (m_Pos + Size > m_Size) { - Size = m_Size - m_Pos; + if (_pos + Size > _size) { + Size = _size - _pos; if (Size == 0) return E_FAIL; } - if (m_Compressed) { - uint32 InitOut = m_Stream.total_out; + if (_compressed) { + uint32 InitOut = _stream.total_out; - m_Stream.avail_out = Size; - m_Stream.next_out = (byte *)Buffer; + _stream.avail_out = Size; + _stream.next_out = (byte *)Buffer; - while (m_Stream.total_out - InitOut < Size && m_Stream.total_in < m_FileEntry->m_CompressedLength) { + while (_stream.total_out - InitOut < Size && _stream.total_in < _fileEntry->_compressedLength) { // needs to read more data? - if (m_Stream.avail_in == 0) { - m_Stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); // TODO: long unsigned int???? - m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); - m_Stream.next_in = m_CompBuffer; + if (_stream.avail_in == 0) { + _stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, _fileEntry->_compressedLength - _stream.total_in); // TODO: long unsigned int???? + _fileEntry->_package->Read(_file, _fileEntry->_offset + _stream.total_in, _compBuffer, _stream.avail_in); + _stream.next_in = _compBuffer; } - int res = inflate(&m_Stream, Z_SYNC_FLUSH); + int res = inflate(&_stream, Z_SYNC_FLUSH); if (res != Z_OK && res != Z_STREAM_END) { Game->LOG(0, "zlib error: %d", res); ret = E_FAIL; @@ -147,10 +147,10 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { } else { - ret = m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Pos, (byte *)Buffer, Size); + ret = _fileEntry->_package->Read(_file, _fileEntry->_offset + _pos, (byte *)Buffer, Size); } - m_Pos += Size; + _pos += Size; return ret; } @@ -158,7 +158,7 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { - if (!m_FileEntry) return E_FAIL; + if (!_fileEntry) return E_FAIL; uint32 NewPos = 0; @@ -167,14 +167,14 @@ HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { NewPos = Pos; break; case SEEK_TO_END: - NewPos = m_Size + Pos; + NewPos = _size + Pos; break; case SEEK_TO_CURRENT: - NewPos = m_Pos + Pos; + NewPos = _pos + Pos; break; } - if (NewPos < 0 || NewPos > m_Size) return E_FAIL; + if (NewPos < 0 || NewPos > _size) return E_FAIL; return SeekToPos(NewPos); } @@ -186,34 +186,34 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { HRESULT ret = S_OK; // seek compressed stream to NewPos - if (m_Compressed) { + if (_compressed) { byte StreamBuffer[STREAM_BUFFER_SIZE]; - if (m_InflateInit) inflateEnd(&m_Stream); - m_InflateInit = false; + if (_inflateInit) inflateEnd(&_stream); + _inflateInit = false; - m_Stream.avail_in = 0; - m_Stream.next_in = m_CompBuffer; - m_Stream.avail_out = MIN((uint32)STREAM_BUFFER_SIZE, NewPos); //TODO: remove cast. - m_Stream.next_out = StreamBuffer; - inflateInit(&m_Stream); - m_InflateInit = true; + _stream.avail_in = 0; + _stream.next_in = _compBuffer; + _stream.avail_out = MIN((uint32)STREAM_BUFFER_SIZE, NewPos); //TODO: remove cast. + _stream.next_out = StreamBuffer; + inflateInit(&_stream); + _inflateInit = true; - while (m_Stream.total_out < NewPos && m_Stream.total_in < m_FileEntry->m_CompressedLength) { + while (_stream.total_out < NewPos && _stream.total_in < _fileEntry->_compressedLength) { // needs to read more data? - if (m_Stream.avail_in == 0) { - m_Stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, m_FileEntry->m_CompressedLength - m_Stream.total_in); // TODO: long unsigned int??? - m_FileEntry->m_Package->Read(m_File, m_FileEntry->m_Offset + m_Stream.total_in, m_CompBuffer, m_Stream.avail_in); - m_Stream.next_in = m_CompBuffer; + if (_stream.avail_in == 0) { + _stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, _fileEntry->_compressedLength - _stream.total_in); // TODO: long unsigned int??? + _fileEntry->_package->Read(_file, _fileEntry->_offset + _stream.total_in, _compBuffer, _stream.avail_in); + _stream.next_in = _compBuffer; } // needs more space? - if (m_Stream.avail_out == 0) { - m_Stream.next_out = StreamBuffer; - m_Stream.avail_out = MIN((long unsigned int)STREAM_BUFFER_SIZE, NewPos - m_Stream.total_out); // TODO: long unsigned int???. + if (_stream.avail_out == 0) { + _stream.next_out = StreamBuffer; + _stream.avail_out = MIN((long unsigned int)STREAM_BUFFER_SIZE, NewPos - _stream.total_out); // TODO: long unsigned int???. } // stream on! - int res = inflate(&m_Stream, Z_SYNC_FLUSH); + int res = inflate(&_stream, Z_SYNC_FLUSH); if (res != Z_OK && res != Z_STREAM_END) { ret = E_FAIL; break; @@ -222,7 +222,7 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { } - m_Pos = NewPos; + _pos = NewPos; return ret; } diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h index d6aac57d1d..3d165c4097 100644 --- a/engines/wintermute/BPkgFile.h +++ b/engines/wintermute/BPkgFile.h @@ -51,13 +51,13 @@ public: virtual HRESULT Close(); virtual HRESULT Open(Common::String Filename); private: - bool m_InflateInit; + bool _inflateInit; HRESULT SeekToPos(uint32 NewPos); - bool m_Compressed; - CBFileEntry *m_FileEntry; - z_stream m_Stream; - byte m_CompBuffer[COMPRESSED_BUFFER_SIZE]; - Common::File *m_File; + bool _compressed; + CBFileEntry *_fileEntry; + z_stream _stream; + byte _compBuffer[COMPRESSED_BUFFER_SIZE]; + Common::File *_file; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BQuickMsg.cpp b/engines/wintermute/BQuickMsg.cpp index 0f8c54f030..1e406af1e8 100644 --- a/engines/wintermute/BQuickMsg.cpp +++ b/engines/wintermute/BQuickMsg.cpp @@ -34,21 +34,21 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBQuickMsg::CBQuickMsg(CBGame *inGame, char *Text): CBBase(inGame) { - m_Text = new char [strlen(Text) + 1]; - if (m_Text) strcpy(m_Text, Text); - m_StartTime = Game->m_CurrentTime; + _text = new char [strlen(Text) + 1]; + if (_text) strcpy(_text, Text); + _startTime = Game->_currentTime; } ////////////////////////////////////////////////////////////////////////// CBQuickMsg::~CBQuickMsg() { - if (m_Text) delete [] m_Text; + if (_text) delete [] _text; } ////////////////////////////////////////////////////////////////////////// char *CBQuickMsg::GetText() { - return m_Text; + return _text; } } // end of namespace WinterMute diff --git a/engines/wintermute/BQuickMsg.h b/engines/wintermute/BQuickMsg.h index 67bb8cf8bf..6349a6ae35 100644 --- a/engines/wintermute/BQuickMsg.h +++ b/engines/wintermute/BQuickMsg.h @@ -36,8 +36,8 @@ namespace WinterMute { class CBQuickMsg : public CBBase { public: char *GetText(); - uint32 m_StartTime; - char *m_Text; + uint32 _startTime; + char *_text; CBQuickMsg(CBGame *inGame, char *Text); virtual ~CBQuickMsg(); diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 699e60c60f..44df8dce44 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -43,12 +43,12 @@ IMPLEMENT_PERSISTENT(CBRegion, false) ////////////////////////////////////////////////////////////////////////// CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { - m_Active = true; - m_EditorSelectedPoint = -1; - m_LastMimicScale = -1; - m_LastMimicX = m_LastMimicY = INT_MIN; + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; - CBPlatform::SetRectEmpty(&m_Rect); + CBPlatform::SetRectEmpty(&_rect); } @@ -60,23 +60,23 @@ CBRegion::~CBRegion() { ////////////////////////////////////////////////////////////////////////// void CBRegion::Cleanup() { - for (int i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; - m_Points.RemoveAll(); + for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); - CBPlatform::SetRectEmpty(&m_Rect); - m_EditorSelectedPoint = -1; + CBPlatform::SetRectEmpty(&_rect); + _editorSelectedPoint = -1; } ////////////////////////////////////////////////////////////////////////// bool CBRegion::CreateRegion() { - return SUCCEEDED(GetBoundingRect(&m_Rect)); + return SUCCEEDED(GetBoundingRect(&_rect)); } ////////////////////////////////////////////////////////////////////////// bool CBRegion::PointInRegion(int X, int Y) { - if (m_Points.GetSize() < 3) return false; + if (_points.GetSize() < 3) return false; POINT pt; pt.x = X; @@ -88,14 +88,14 @@ bool CBRegion::PointInRegion(int X, int Y) { rect.top = Y - 1; rect.bottom = Y + 2; - if (CBPlatform::PtInRect(&m_Rect, pt)) return PtInPolygon(X, Y); + if (CBPlatform::PtInRect(&_rect, pt)) return PtInPolygon(X, Y); else return false; } ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -103,8 +103,8 @@ HRESULT CBRegion::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); @@ -154,8 +154,8 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { int i; - for (i = 0; i < m_Points.GetSize(); i++) delete m_Points[i]; - m_Points.RemoveAll(); + for (i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -172,13 +172,13 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &m_Active); + parser.ScanStr((char *)params, "%b", &_active); break; case TOKEN_POINT: { int x, y; parser.ScanStr((char *)params, "%d,%d", &x, &y); - m_Points.Add(new CBPoint(x, y)); + _points.Add(new CBPoint(x, y)); } break; @@ -187,7 +187,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &m_EditorSelectedPoint); + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: @@ -219,7 +219,7 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - m_Points.Add(new CBPoint(X, Y)); + _points.Add(new CBPoint(X, Y)); CreateRegion(); Stack->PushBool(true); @@ -236,8 +236,8 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - if (Index >= 0 && Index < m_Points.GetSize()) { - m_Points.InsertAt(Index, new CBPoint(X, Y)); + if (Index >= 0 && Index < _points.GetSize()) { + _points.InsertAt(Index, new CBPoint(X, Y)); CreateRegion(); Stack->PushBool(true); @@ -255,9 +255,9 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - if (Index >= 0 && Index < m_Points.GetSize()) { - m_Points[Index]->x = X; - m_Points[Index]->y = Y; + if (Index >= 0 && Index < _points.GetSize()) { + _points[Index]->x = X; + _points[Index]->y = Y; CreateRegion(); Stack->PushBool(true); @@ -273,11 +273,11 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); int Index = Stack->Pop()->GetInt(); - if (Index >= 0 && Index < m_Points.GetSize()) { - delete m_Points[Index]; - m_Points[Index] = NULL; + if (Index >= 0 && Index < _points.GetSize()) { + delete _points[Index]; + _points[Index] = NULL; - m_Points.RemoveAt(Index); + _points.RemoveAt(Index); CreateRegion(); Stack->PushBool(true); @@ -293,11 +293,11 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); int Index = Stack->Pop()->GetInt(); - if (Index >= 0 && Index < m_Points.GetSize()) { + if (Index >= 0 && Index < _points.GetSize()) { CScValue *Val = Stack->GetPushValue(); if (Val) { - Val->SetProperty("X", m_Points[Index]->x); - Val->SetProperty("Y", m_Points[Index]->y); + Val->SetProperty("X", _points[Index]->x); + Val->SetProperty("Y", _points[Index]->y); } } else Stack->PushNULL(); @@ -310,38 +310,38 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CBRegion::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("region"); - return m_ScValue; + _scValue->SetString("region"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { - m_ScValue->SetBool(m_Active); - return m_ScValue; + _scValue->SetBool(_active); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumPoints ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumPoints") == 0) { - m_ScValue->SetInt(m_Points.GetSize()); - return m_ScValue; + _scValue->SetInt(_points.GetSize()); + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -362,7 +362,7 @@ HRESULT CBRegion::ScSetProperty(char *Name, CScValue *Value) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Active") == 0) { - m_Active = Value->GetBool(); + _active = Value->GetBool(); return S_OK; } @@ -381,22 +381,22 @@ HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", m_EditorSelectedPoint); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); int i; - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < m_Points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y); + for (i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); @@ -409,12 +409,12 @@ HRESULT CBRegion::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Active)); - PersistMgr->Transfer(TMEMBER(m_EditorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(m_LastMimicScale)); - PersistMgr->Transfer(TMEMBER(m_LastMimicX)); - PersistMgr->Transfer(TMEMBER(m_LastMimicY)); - m_Points.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(_lastMimicScale)); + PersistMgr->Transfer(TMEMBER(_lastMimicX)); + PersistMgr->Transfer(TMEMBER(_lastMimicY)); + _points.Persist(PersistMgr); return S_OK; } @@ -426,7 +426,7 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool CBRegion::PtInPolygon(int X, int Y) { - if (m_Points.GetSize() < 3) return false; + if (_points.GetSize() < 3) return false; int counter = 0; int i; @@ -436,12 +436,12 @@ bool CBRegion::PtInPolygon(int X, int Y) { p.x = (double)X; p.y = (double)Y; - p1.x = (double)m_Points[0]->x; - p1.y = (double)m_Points[0]->y; + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; - for (i = 1; i <= m_Points.GetSize(); i++) { - p2.x = (double)m_Points[i % m_Points.GetSize()]->x; - p2.y = (double)m_Points[i % m_Points.GetSize()]->y; + for (i = 1; i <= _points.GetSize(); i++) { + p2.x = (double)_points[i % _points.GetSize()]->x; + p2.y = (double)_points[i % _points.GetSize()]->y; if (p.y > std::min(p1.y, p2.y)) { if (p.y <= std::max(p1.y, p2.y)) { @@ -466,16 +466,16 @@ bool CBRegion::PtInPolygon(int X, int Y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::GetBoundingRect(RECT *Rect) { - if (m_Points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); + if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - for (int i = 0; i < m_Points.GetSize(); i++) { - MinX = std::min(MinX, m_Points[i]->x); - MinY = std::min(MinY, m_Points[i]->y); + for (int i = 0; i < _points.GetSize(); i++) { + MinX = std::min(MinX, _points[i]->x); + MinY = std::min(MinY, _points[i]->y); - MaxX = std::max(MaxX, m_Points[i]->x); - MaxY = std::max(MaxY, m_Points[i]->y); + MaxX = std::max(MaxX, _points[i]->x); + MaxY = std::max(MaxY, _points[i]->y); } CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); } @@ -485,22 +485,22 @@ HRESULT CBRegion::GetBoundingRect(RECT *Rect) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { - if (Scale == m_LastMimicScale && X == m_LastMimicX && Y == m_LastMimicY) return S_OK; + if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; Cleanup(); - for (int i = 0; i < Region->m_Points.GetSize(); i++) { + for (int i = 0; i < Region->_points.GetSize(); i++) { int x, y; - x = (int)((float)Region->m_Points[i]->x * Scale / 100.0f); - y = (int)((float)Region->m_Points[i]->y * Scale / 100.0f); + x = (int)((float)Region->_points[i]->x * Scale / 100.0f); + y = (int)((float)Region->_points[i]->y * Scale / 100.0f); - m_Points.Add(new CBPoint(x + X, y + Y)); + _points.Add(new CBPoint(x + X, y + Y)); } - m_LastMimicScale = Scale; - m_LastMimicX = X; - m_LastMimicY = Y; + _lastMimicScale = Scale; + _lastMimicX = X; + _lastMimicY = Y; return CreateRegion() ? S_OK : E_FAIL; } diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index a218e6874a..914f77f7ae 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -36,24 +36,24 @@ namespace WinterMute { class CBRegion : public CBObject { public: - float m_LastMimicScale; - int m_LastMimicX; - int m_LastMimicY; + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; void Cleanup(); HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); HRESULT GetBoundingRect(RECT *Rect); bool PtInPolygon(int X, int Y); DECLARE_PERSISTENT(CBRegion, CBObject) - bool m_Active; - int m_EditorSelectedPoint; + bool _active; + int _editorSelectedPoint; CBRegion(CBGame *inGame); virtual ~CBRegion(); bool PointInRegion(int X, int Y); bool CreateRegion(); HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - RECT m_Rect; - CBArray m_Points; + RECT _rect; + CBArray _points; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride = NULL); // scripting interface diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp index 75b621d90f..72f34ef061 100644 --- a/engines/wintermute/BRegistry.cpp +++ b/engines/wintermute/BRegistry.cpp @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { - m_IniName = NULL; + _iniName = NULL; SetIniName("./wme.ini"); LoadValues(true); @@ -48,8 +48,8 @@ CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBRegistry::~CBRegistry() { SaveValues(); - delete[] m_IniName; - m_IniName = NULL; + delete[] _iniName; + _iniName = NULL; } @@ -61,15 +61,15 @@ AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &ke #ifdef __WIN32__ // check ini file first (so what we can use project files on windows) char buffer[32768]; - GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, m_IniName); + GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, _iniName); ret = AnsiString(buffer); if (buffer != init) return ret; #endif bool found = false; - ret = GetValue(m_LocalValues, subKey, key, found); - if (!found) ret = GetValue(m_Values, subKey, key, found); + ret = GetValue(_localValues, subKey, key, found); + if (!found) ret = GetValue(_values, subKey, key, found); if (!found) ret = init; return ret; @@ -78,7 +78,7 @@ AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &ke ////////////////////////////////////////////////////////////////////////// bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - m_Values[subKey][key] = value; + _values[subKey][key] = value; return true; } @@ -86,7 +86,7 @@ bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, co ////////////////////////////////////////////////////////////////////////// int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int init) { #ifdef __WIN32__ - int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, m_IniName); + int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName); if (ret != init) return ret; #endif @@ -117,38 +117,38 @@ bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool ////////////////////////////////////////////////////////////////////////// void CBRegistry::SetIniName(char *Name) { - delete[] m_IniName; - m_IniName = NULL; + delete[] _iniName; + _iniName = NULL; if (strchr(Name, '\\') == NULL && strchr(Name, '/') == NULL) { - m_IniName = new char [strlen(Name) + 3]; - sprintf(m_IniName, "./%s", Name); + _iniName = new char [strlen(Name) + 3]; + sprintf(_iniName, "./%s", Name); } else { - m_IniName = new char [strlen(Name) + 1]; - strcpy(m_IniName, Name); + _iniName = new char [strlen(Name) + 1]; + strcpy(_iniName, Name); } } ////////////////////////////////////////////////////////////////////////// char *CBRegistry::GetIniName() { - return m_IniName; + return _iniName; } ////////////////////////////////////////////////////////////////////////// void CBRegistry::LoadValues(bool local) { - if (local) LoadXml("settings.xml", m_LocalValues); - else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), m_Values); + if (local) LoadXml("settings.xml", _localValues); + else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::SaveValues() { - SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), m_Values); + SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::SetBasePath(const char *basePath) { - m_BasePath = PathUtil::GetFileNameWithoutExtension(basePath); + _basePath = PathUtil::GetFileNameWithoutExtension(basePath); LoadValues(false); } @@ -196,7 +196,7 @@ void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { doc.LinkEndChild(root); PathValueMap::iterator pathIt; - for (pathIt = m_Values.begin(); pathIt != m_Values.end(); ++pathIt) { + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); root->LinkEndChild(pathElem); diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h index 2838d3794f..0729374783 100644 --- a/engines/wintermute/BRegistry.h +++ b/engines/wintermute/BRegistry.h @@ -48,22 +48,22 @@ public: void SetBasePath(const char *basePath); AnsiString GetBasePath() const { - return m_BasePath; + return _basePath; } void LoadValues(bool local); void SaveValues(); private: - char *m_IniName; + char *_iniName; typedef Common::HashMap KeyValuePair; typedef Common::HashMap PathValueMap; - PathValueMap m_LocalValues; - PathValueMap m_Values; + PathValueMap _localValues; + PathValueMap _values; - AnsiString m_BasePath; + AnsiString _basePath; void LoadXml(const AnsiString fileName, PathValueMap &values); void SaveXml(const AnsiString fileName, PathValueMap &values); diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index d28bbc477f..c6684ec348 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -42,18 +42,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { - m_Renderer = NULL; - m_Win = NULL; + _renderer = NULL; + _win = NULL; - m_BorderLeft = m_BorderRight = m_BorderTop = m_BorderBottom = 0; - m_RatioX = m_RatioY = 1.0f; + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; } ////////////////////////////////////////////////////////////////////////// CBRenderSDL::~CBRenderSDL() { #if 0 - if (m_Renderer) SDL_DestroyRenderer(m_Renderer); - if (m_Win) SDL_DestroyWindow(m_Win); + if (_renderer) SDL_DestroyRenderer(_renderer); + if (_win) SDL_DestroyWindow(_win); #endif SDL_Quit(); } @@ -67,17 +67,17 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); #endif - m_Width = width; - m_Height = height; + _width = width; + _height = height; - m_RealWidth = width; - m_RealHeight = height; + _realWidth = width; + _realHeight = height; // find suitable resolution #ifdef __IPHONEOS__ - m_RealWidth = 480; - m_RealHeight = 320; + _realWidth = 480; + _realHeight = 320; int numModes = SDL_GetNumDisplayModes(0); for (int i = 0; i < numModes; i++) { @@ -85,44 +85,44 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { SDL_GetDisplayMode(0, i, &mode); if (mode.w > mode.h) { - m_RealWidth = mode.w; - m_RealHeight = mode.h; + _realWidth = mode.w; + _realHeight = mode.h; break; } } #else - m_RealWidth = Game->m_Registry->ReadInt("Debug", "ForceResWidth", m_Width); - m_RealHeight = Game->m_Registry->ReadInt("Debug", "ForceResHeight", m_Height); + _realWidth = Game->_registry->ReadInt("Debug", "ForceResWidth", _width); + _realHeight = Game->_registry->ReadInt("Debug", "ForceResHeight", _height); #endif /* - m_RealWidth = 480; - m_RealHeight = 320; + _realWidth = 480; + _realHeight = 320; */ - float origAspect = (float)m_Width / (float)m_Height; - float realAspect = (float)m_RealWidth / (float)m_RealHeight; + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; float ratio; if (origAspect < realAspect) { // normal to wide - ratio = (float)m_RealHeight / (float)m_Height; + ratio = (float)_realHeight / (float)_height; } else { // wide to normal - ratio = (float)m_RealWidth / (float)m_Width; + ratio = (float)_realWidth / (float)_width; } - m_BorderLeft = (m_RealWidth - (m_Width * ratio)) / 2; - m_BorderRight = m_RealWidth - (m_Width * ratio) - m_BorderLeft; + _borderLeft = (_realWidth - (_width * ratio)) / 2; + _borderRight = _realWidth - (_width * ratio) - _borderLeft; - m_BorderTop = (m_RealHeight - (m_Height * ratio)) / 2; - m_BorderBottom = m_RealHeight - (m_Height * ratio) - m_BorderTop; + _borderTop = (_realHeight - (_height * ratio)) / 2; + _borderBottom = _realHeight - (_height * ratio) - _borderTop; - m_RatioX = (float)(m_RealWidth - m_BorderLeft - m_BorderRight) / (float)m_Width; - m_RatioY = (float)(m_RealHeight - m_BorderTop - m_BorderBottom) / (float)m_Height; + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; #if 0 Uint32 flags = SDL_WINDOW_SHOWN; @@ -131,17 +131,17 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; #endif - //m_Windowed = Game->m_Registry->ReadBool("Video", "Windowed", true); + //_windowed = Game->_registry->ReadBool("Video", "Windowed", true); // if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; #if 0 - m_Win = SDL_CreateWindow("WME Lite", + _win = SDL_CreateWindow("WME Lite", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - m_RealWidth, m_RealHeight, + _realWidth, _realHeight, flags); #endif - if (!m_Win) return E_FAIL; + if (!_win) return E_FAIL; SDL_ShowCursor(SDL_DISABLE); @@ -152,11 +152,11 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); #endif #if 0 - m_Renderer = SDL_CreateRenderer(m_Win, -1, 0); + _renderer = SDL_CreateRenderer(_win, -1, 0); #endif - if (!m_Renderer) return E_FAIL; + if (!_renderer) return E_FAIL; - m_Active = true; + _active = true; return S_OK; @@ -167,54 +167,54 @@ HRESULT CBRenderSDL::Flip() { #ifdef __IPHONEOS__ // hack: until viewports work correctly, we just paint black bars instead - SDL_SetRenderDrawColor(m_Renderer, 0x00, 0x00, 0x00, 0xFF); + SDL_SetRenderDrawColor(_renderer, 0x00, 0x00, 0x00, 0xFF); static bool firstRefresh = true; // prevents a weird color glitch if (firstRefresh) { firstRefresh = false; } else { SDL_Rect rect; - if (m_BorderLeft > 0) { + if (_borderLeft > 0) { rect.x = 0; rect.y = 0; - rect.w = m_BorderLeft; - rect.h = m_RealHeight; - SDL_RenderFillRect(m_Renderer, &rect); + rect.w = _borderLeft; + rect.h = _realHeight; + SDL_RenderFillRect(_renderer, &rect); } - if (m_BorderRight > 0) { - rect.x = (m_RealWidth - m_BorderRight); + if (_borderRight > 0) { + rect.x = (_realWidth - _borderRight); rect.y = 0; - rect.w = m_BorderRight; - rect.h = m_RealHeight; - SDL_RenderFillRect(m_Renderer, &rect); + rect.w = _borderRight; + rect.h = _realHeight; + SDL_RenderFillRect(_renderer, &rect); } - if (m_BorderTop > 0) { + if (_borderTop > 0) { rect.x = 0; rect.y = 0; - rect.w = m_RealWidth; - rect.h = m_BorderTop; - SDL_RenderFillRect(m_Renderer, &rect); + rect.w = _realWidth; + rect.h = _borderTop; + SDL_RenderFillRect(_renderer, &rect); } - if (m_BorderBottom > 0) { + if (_borderBottom > 0) { rect.x = 0; - rect.y = m_RealHeight - m_BorderBottom; - rect.w = m_RealWidth; - rect.h = m_BorderBottom; - SDL_RenderFillRect(m_Renderer, &rect); + rect.y = _realHeight - _borderBottom; + rect.w = _realWidth; + rect.h = _borderBottom; + SDL_RenderFillRect(_renderer, &rect); } } #endif - //SDL_RenderPresent(m_Renderer); + //SDL_RenderPresent(_renderer); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { - //SDL_SetRenderDrawColor(m_Renderer, r, g, b, 0xFF); - //SDL_RenderClear(m_Renderer); + //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); + //SDL_RenderClear(_renderer); return S_OK; } @@ -250,9 +250,9 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { byte b = D3DCOLGetB(Color); byte a = D3DCOLGetA(Color); - //SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); - //SDL_RenderFillRect(m_Renderer, &fillRect); + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); return S_OK; } @@ -264,8 +264,8 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { byte b = D3DCOLGetB(Color); byte a = D3DCOLGetA(Color); - //SDL_SetRenderDrawColor(m_Renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(m_Renderer, SDL_BLENDMODE_BLEND); + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); POINT point1, point2; point1.x = X1; @@ -277,7 +277,7 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { PointToScreen(&point2); - //SDL_RenderDrawLine(m_Renderer, point1.x, point1.y, point2.x, point2.y); + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); return S_OK; } @@ -287,12 +287,12 @@ CBImage *CBRenderSDL::TakeScreenshot() { #if 0 SDL_Rect viewport; - SDL_RenderGetViewport(m_Renderer, &viewport); + SDL_RenderGetViewport(_renderer, &viewport); SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); if (!surface) return NULL; - if (SDL_RenderReadPixels(m_Renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -311,37 +311,37 @@ CBImage *CBRenderSDL::TakeScreenshot() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::SwitchFullscreen() { - /*if (m_Windowed) SDL_SetWindowFullscreen(m_Win, SDL_TRUE); - else SDL_SetWindowFullscreen(m_Win, SDL_FALSE); + /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); + else SDL_SetWindowFullscreen(_win, SDL_FALSE); - m_Windowed = !m_Windowed; + _windowed = !_windowed; */ - Game->m_Registry->WriteBool("Video", "Windowed", m_Windowed); + Game->_registry->WriteBool("Video", "Windowed", _windowed); return S_OK; } ////////////////////////////////////////////////////////////////////////// const char *CBRenderSDL::GetName() { - if (m_Name.empty()) { - if (m_Renderer) { + if (_name.empty()) { + if (_renderer) { #if 0 SDL_RendererInfo info; - SDL_GetRendererInfo(m_Renderer, &info); - m_Name = AnsiString(info.name); + SDL_GetRendererInfo(_renderer, &info); + _name = AnsiString(info.name); #endif } } - return m_Name.c_str(); + return _name.c_str(); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { SDL_Rect rect; - rect.x = left + m_BorderLeft; - rect.y = top + m_BorderTop; - rect.w = (right - left) * m_RatioX; - rect.h = (bottom - top) * m_RatioY; + rect.x = left + _borderLeft; + rect.y = top + _borderTop; + rect.w = (right - left) * _ratioX; + rect.h = (bottom - top) * _ratioY; // TODO fix this once viewports work correctly in SDL/landscape #ifndef __IPHONEOS__ @@ -356,10 +356,10 @@ void CBRenderSDL::ModTargetRect(SDL_Rect *rect) { SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - rect->x = MathUtil::Round(rect->x * m_RatioX + m_BorderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * m_RatioY + m_BorderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * m_RatioX); - rect->h = MathUtil::RoundUp(rect->h * m_RatioY); + rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * _ratioX); + rect->h = MathUtil::RoundUp(rect->h * _ratioY); #endif } @@ -369,8 +369,8 @@ void CBRenderSDL::PointFromScreen(POINT *point) { SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - point->x = point->x / m_RatioX - m_BorderLeft / m_RatioX + viewportRect.x; - point->y = point->y / m_RatioY - m_BorderTop / m_RatioY + viewportRect.y; + point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; + point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; #endif } @@ -381,8 +381,8 @@ void CBRenderSDL::PointToScreen(POINT *point) { SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - point->x = MathUtil::RoundUp(point->x * m_RatioX) + m_BorderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * m_RatioY) + m_BorderTop - viewportRect.y; + point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; #endif } @@ -391,17 +391,17 @@ void CBRenderSDL::DumpData(char *Filename) { FILE *f = fopen(Filename, "wt"); if (!f) return; - CBSurfaceStorage *Mgr = Game->m_SurfaceStorage; + CBSurfaceStorage *Mgr = Game->_surfaceStorage; int TotalKB = 0; int TotalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->m_Surfaces.GetSize(); i++) { - CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->m_Surfaces[i]; - if (!Surf->m_Filename) continue; - if (!Surf->m_Valid) continue; + for (int i = 0; i < Mgr->_surfaces.GetSize(); i++) { + CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->_surfaces[i]; + if (!Surf->_filename) continue; + if (!Surf->_valid) continue; - fprintf(f, "%s;%d;", Surf->m_Filename, Surf->m_ReferenceCount); + fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); fprintf(f, "%dx%d;", Surf->GetWidth(), Surf->GetHeight()); int kb = Surf->GetWidth() * Surf->GetHeight() * 4 / 1024; @@ -410,7 +410,7 @@ void CBRenderSDL::DumpData(char *Filename) { fprintf(f, "%d;", kb); fprintf(f, "\n"); } - fprintf(f, "Total %d;;;%d\n", Mgr->m_Surfaces.GetSize(), TotalKB); + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.GetSize(), TotalKB); fclose(f); diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 11a969946e..edcafdff96 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -58,10 +58,10 @@ public: CBImage *TakeScreenshot(); SDL_Renderer *GetSdlRenderer() const { - return m_Renderer; + return _renderer; } SDL_Window *GetSdlWindow() const { - return m_Win; + return _win; } HRESULT SetViewport(int left, int top, int right, int bottom); @@ -73,24 +73,24 @@ public: void DumpData(char *Filename); float GetScaleRatioX() const { - return m_RatioX; + return _ratioX; } float GetScaleRatioY() const { - return m_RatioY; + return _ratioY; } private: - SDL_Renderer *m_Renderer; - SDL_Window *m_Win; - AnsiString m_Name; + SDL_Renderer *_renderer; + SDL_Window *_win; + AnsiString _name; - int m_BorderLeft; - int m_BorderTop; - int m_BorderRight; - int m_BorderBottom; + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; - float m_RatioX; - float m_RatioY; + float _ratioX; + float _ratioY; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp index aaaca902fa..a0ebcdd1d3 100644 --- a/engines/wintermute/BRenderer.cpp +++ b/engines/wintermute/BRenderer.cpp @@ -38,19 +38,19 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - m_Instance = NULL; - m_Window = NULL; - m_ClipperWindow = NULL; - m_Active = false; - m_Ready = false; - m_Windowed = true; - m_ForceAlphaColor = 0x00; - - m_Width = m_Height = m_BPP = 0; - CBPlatform::SetRectEmpty(&m_MonitorRect); - - m_RealWidth = m_RealHeight = 0; - m_DrawOffsetX = m_DrawOffsetY = 0; + _instance = NULL; + _window = NULL; + _clipperWindow = NULL; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _width = _height = _bPP = 0; + CBPlatform::SetRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; } @@ -73,31 +73,31 @@ CBObject *CBRenderer::GetObjectAt(int X, int Y) { point.x = X; point.y = Y; - for (int i = m_RectList.GetSize() - 1; i >= 0; i--) { - if (CBPlatform::PtInRect(&m_RectList[i]->m_Rect, point)) { - if (m_RectList[i]->m_Precise) { + for (int i = _rectList.GetSize() - 1; i >= 0; i--) { + if (CBPlatform::PtInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { // frame - if (m_RectList[i]->m_Frame) { - int XX = (int)((m_RectList[i]->m_Frame->m_Rect.left + X - m_RectList[i]->m_Rect.left + m_RectList[i]->m_OffsetX) / (float)((float)m_RectList[i]->m_ZoomX / (float)100)); - int YY = (int)((m_RectList[i]->m_Frame->m_Rect.top + Y - m_RectList[i]->m_Rect.top + m_RectList[i]->m_OffsetY) / (float)((float)m_RectList[i]->m_ZoomY / (float)100)); + if (_rectList[i]->_frame) { + int XX = (int)((_rectList[i]->_frame->_rect.left + X - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int YY = (int)((_rectList[i]->_frame->_rect.top + Y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); - if (m_RectList[i]->m_Frame->m_MirrorX) { - int Width = m_RectList[i]->m_Frame->m_Rect.right - m_RectList[i]->m_Frame->m_Rect.left; + if (_rectList[i]->_frame->_mirrorX) { + int Width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; XX = Width - XX; } - if (m_RectList[i]->m_Frame->m_MirrorY) { - int Height = m_RectList[i]->m_Frame->m_Rect.bottom - m_RectList[i]->m_Frame->m_Rect.top; + if (_rectList[i]->_frame->_mirrorY) { + int Height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; YY = Height - YY; } - if (!m_RectList[i]->m_Frame->m_Surface->IsTransparentAt(XX, YY)) return m_RectList[i]->m_Owner; + if (!_rectList[i]->_frame->_surface->IsTransparentAt(XX, YY)) return _rectList[i]->_owner; } // region - else if (m_RectList[i]->m_Region) { - if (m_RectList[i]->m_Region->PointInRegion(X + m_RectList[i]->m_OffsetX, Y + m_RectList[i]->m_OffsetY)) return m_RectList[i]->m_Owner; + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->PointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; } - } else return m_RectList[i]->m_Owner; + } else return _rectList[i]->_owner; } } @@ -107,10 +107,10 @@ CBObject *CBRenderer::GetObjectAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// void CBRenderer::DeleteRectList() { - for (int i = 0; i < m_RectList.GetSize(); i++) { - delete m_RectList[i]; + for (int i = 0; i < _rectList.GetSize(); i++) { + delete _rectList[i]; } - m_RectList.RemoveAll(); + _rectList.RemoveAll(); } @@ -199,16 +199,16 @@ HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::SetScreenViewport() { - return SetViewport(m_DrawOffsetX, m_DrawOffsetY, m_Width + m_DrawOffsetX, m_Height + m_DrawOffsetY); + return SetViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::SetViewport(RECT *Rect) { - return SetViewport(Rect->left + m_DrawOffsetX, - Rect->top + m_DrawOffsetY, - Rect->right + m_DrawOffsetX, - Rect->bottom + m_DrawOffsetY); + return SetViewport(Rect->left + _drawOffsetX, + Rect->top + _drawOffsetY, + Rect->right + _drawOffsetX, + Rect->bottom + _drawOffsetY); } @@ -221,16 +221,16 @@ CBImage *CBRenderer::TakeScreenshot() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::ClipCursor() { /* - if(!m_Windowed) + if(!_windowed) { RECT rc; - GetWindowRect(m_Window, &rc); + GetWindowRect(_window, &rc); // if "maintain aspect ratio" is in effect, lock mouse to visible area - rc.left = m_DrawOffsetX; - rc.top = m_DrawOffsetY; - rc.right = rc.left + m_Width; - rc.bottom = rc.top + m_Height; + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; ::ClipCursor(&rc); } @@ -241,17 +241,17 @@ HRESULT CBRenderer::ClipCursor() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::UnclipCursor() { /* - if(!m_Windowed) ::ClipCursor(NULL); + if(!_windowed) ::ClipCursor(NULL); */ return S_OK; } ////////////////////////////////////////////////////////////////////////// bool CBRenderer::PointInViewport(POINT *P) { - if (P->x < m_DrawOffsetX) return false; - if (P->y < m_DrawOffsetY) return false; - if (P->x > m_DrawOffsetX + m_Width) return false; - if (P->y > m_DrawOffsetY + m_Height) return false; + if (P->x < _drawOffsetX) return false; + if (P->y < _drawOffsetY) return false; + if (P->x > _drawOffsetX + _width) return false; + if (P->y > _drawOffsetY + _height) return false; return true; } diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h index c1180a5ef5..de7731a3ad 100644 --- a/engines/wintermute/BRenderer.h +++ b/engines/wintermute/BRenderer.h @@ -41,10 +41,10 @@ class CBObject; class CBRenderer: public CBBase { public: - int m_RealWidth; - int m_RealHeight; - int m_DrawOffsetX; - int m_DrawOffsetY; + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; virtual void DumpData(char *Filename) {}; virtual CBImage *TakeScreenshot(); @@ -101,22 +101,22 @@ public: return S_OK; }; bool PointInViewport(POINT *P); - uint32 m_ForceAlphaColor; - HINSTANCE m_Instance; - HWND m_Window; - HWND m_ClipperWindow; - bool m_Active; - bool m_Ready; - bool m_Windowed; - RECT m_WindowRect; - RECT m_ViewportRect; - RECT m_ScreenRect; - RECT m_MonitorRect; - int m_BPP; - int m_Height; - int m_Width; - - CBArray m_RectList; + uint32 _forceAlphaColor; + HINSTANCE _instance; + HWND _window; + HWND _clipperWindow; + bool _active; + bool _ready; + bool _windowed; + RECT _windowRect; + RECT _viewportRect; + RECT _screenRect; + RECT _monitorRect; + int _bPP; + int _height; + int _width; + + CBArray _rectList; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp index 84811d0e73..c03868cde1 100644 --- a/engines/wintermute/BResourceFile.cpp +++ b/engines/wintermute/BResourceFile.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { - m_Data = NULL; + _data = NULL; } @@ -48,8 +48,8 @@ CBResourceFile::~CBResourceFile() { HRESULT CBResourceFile::Open(Common::String Filename) { Close(); - if (CBResources::GetFile(Filename.c_str(), m_Data, m_Size)) { - m_Pos = 0; + if (CBResources::GetFile(Filename.c_str(), _data, _size)) { + _pos = 0; return S_OK; } return E_FAIL; @@ -57,9 +57,9 @@ HRESULT CBResourceFile::Open(Common::String Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBResourceFile::Close() { - m_Data = NULL; - m_Pos = 0; - m_Size = 0; + _data = NULL; + _pos = 0; + _size = 0; return S_OK; } @@ -67,10 +67,10 @@ HRESULT CBResourceFile::Close() { ////////////////////////////////////////////////////////////////////////// HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { - if (!m_Data || m_Pos + Size > m_Size) return E_FAIL; + if (!_data || _pos + Size > _size) return E_FAIL; - memcpy(Buffer, (byte *)m_Data + m_Pos, Size); - m_Pos += Size; + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; return S_OK; } @@ -78,7 +78,7 @@ HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { - if (!m_Data) return E_FAIL; + if (!_data) return E_FAIL; uint32 NewPos = 0; @@ -87,15 +87,15 @@ HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { NewPos = Pos; break; case SEEK_TO_END: - NewPos = m_Size + Pos; + NewPos = _size + Pos; break; case SEEK_TO_CURRENT: - NewPos = m_Pos + Pos; + NewPos = _pos + Pos; break; } - if (NewPos < 0 || NewPos > m_Size) return E_FAIL; - else m_Pos = NewPos; + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; return S_OK; } diff --git a/engines/wintermute/BResourceFile.h b/engines/wintermute/BResourceFile.h index 4d995d674d..110f320d60 100644 --- a/engines/wintermute/BResourceFile.h +++ b/engines/wintermute/BResourceFile.h @@ -42,7 +42,7 @@ public: virtual HRESULT Close(); virtual HRESULT Open(Common::String Filename); private: - byte *m_Data; + byte *_data; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BResources.cpp b/engines/wintermute/BResources.cpp index dceade0984..f387d1848b 100644 --- a/engines/wintermute/BResources.cpp +++ b/engines/wintermute/BResources.cpp @@ -2817,7 +2817,7 @@ bool CBResources::GetFile(const char *fileName, byte*& buffer, uint32 &size) { buffer = invaliddebug; size = sizeof(invaliddebug); return true; - } else if (scumm_stricmp(fileName, "system_font.bmp") == 0) { + } else if (scumm_stricmp(fileName, "syste_font.bmp") == 0) { buffer = systemfont; size = sizeof(systemfont); return true; diff --git a/engines/wintermute/BSaveThumbFile.cpp b/engines/wintermute/BSaveThumbFile.cpp index aeba924684..4f698563d3 100644 --- a/engines/wintermute/BSaveThumbFile.cpp +++ b/engines/wintermute/BSaveThumbFile.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - m_Data = NULL; + _data = NULL; } @@ -74,20 +74,20 @@ HRESULT CBSaveThumbFile::Open(Common::String Filename) { CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; - Game->m_DEBUG_AbsolutePathWarning = false; + Game->_dEBUG_AbsolutePathWarning = false; if (FAILED(pm->InitLoad(SlotFilename))) { - Game->m_DEBUG_AbsolutePathWarning = true; + Game->_dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; } - Game->m_DEBUG_AbsolutePathWarning = true; + Game->_dEBUG_AbsolutePathWarning = true; HRESULT res; - if (pm->m_ThumbnailDataSize != 0) { - m_Data = new byte[pm->m_ThumbnailDataSize]; - memcpy(m_Data, pm->m_ThumbnailData, pm->m_ThumbnailDataSize); - m_Size = pm->m_ThumbnailDataSize; + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; res = S_OK; } else res = E_FAIL; delete pm; @@ -98,11 +98,11 @@ HRESULT CBSaveThumbFile::Open(Common::String Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSaveThumbFile::Close() { - delete[] m_Data; - m_Data = NULL; + delete[] _data; + _data = NULL; - m_Pos = 0; - m_Size = 0; + _pos = 0; + _size = 0; return S_OK; } @@ -110,10 +110,10 @@ HRESULT CBSaveThumbFile::Close() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { - if (!m_Data || m_Pos + Size > m_Size) return E_FAIL; + if (!_data || _pos + Size > _size) return E_FAIL; - memcpy(Buffer, (byte *)m_Data + m_Pos, Size); - m_Pos += Size; + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; return S_OK; } @@ -121,7 +121,7 @@ HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { - if (!m_Data) return E_FAIL; + if (!_data) return E_FAIL; uint32 NewPos = 0; @@ -130,15 +130,15 @@ HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { NewPos = Pos; break; case SEEK_TO_END: - NewPos = m_Size + Pos; + NewPos = _size + Pos; break; case SEEK_TO_CURRENT: - NewPos = m_Pos + Pos; + NewPos = _pos + Pos; break; } - if (NewPos < 0 || NewPos > m_Size) return E_FAIL; - else m_Pos = NewPos; + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; return S_OK; } diff --git a/engines/wintermute/BSaveThumbFile.h b/engines/wintermute/BSaveThumbFile.h index 7c22eda237..55596b7ecc 100644 --- a/engines/wintermute/BSaveThumbFile.h +++ b/engines/wintermute/BSaveThumbFile.h @@ -43,7 +43,7 @@ public: virtual HRESULT Close(); virtual HRESULT Open(Common::String Filename); private: - byte *m_Data; + byte *_data; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbHelper.cpp b/engines/wintermute/BSaveThumbHelper.cpp index 3342f7aa3a..ac8898c344 100644 --- a/engines/wintermute/BSaveThumbHelper.cpp +++ b/engines/wintermute/BSaveThumbHelper.cpp @@ -35,38 +35,38 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { - m_Thumbnail = NULL; + _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// CBSaveThumbHelper::~CBSaveThumbHelper(void) { - delete m_Thumbnail; - m_Thumbnail = NULL; + delete _thumbnail; + _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { - delete m_Thumbnail; - m_Thumbnail = NULL; + delete _thumbnail; + _thumbnail = NULL; - if (Game->m_ThumbnailWidth > 0 && Game->m_ThumbnailHeight > 0) { + if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { if (DoFlip) { // when using opengl on windows it seems to be necessary to do this twice // works normally for direct3d Game->DisplayContent(false); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); Game->DisplayContent(false); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); } - CBImage *Screenshot = Game->m_Renderer->TakeScreenshot(); + CBImage *Screenshot = Game->_renderer->TakeScreenshot(); if (!Screenshot) return E_FAIL; // normal thumbnail - if (Game->m_ThumbnailWidth > 0 && Game->m_ThumbnailHeight > 0) { - m_Thumbnail = new CBImage(Game); - m_Thumbnail->CopyFrom(Screenshot, Game->m_ThumbnailWidth, Game->m_ThumbnailHeight); + if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { + _thumbnail = new CBImage(Game); + _thumbnail->CopyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); } diff --git a/engines/wintermute/BSaveThumbHelper.h b/engines/wintermute/BSaveThumbHelper.h index 6c1e411f5f..fa42762367 100644 --- a/engines/wintermute/BSaveThumbHelper.h +++ b/engines/wintermute/BSaveThumbHelper.h @@ -41,8 +41,8 @@ public: virtual ~CBSaveThumbHelper(void); HRESULT StoreThumbnail(bool DoFlip = false); - CBImage *m_Thumbnail; - CBImage *m_RichThumbnail; + CBImage *_thumbnail; + CBImage *_richThumbnail; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index 674df198cd..ed7db2507b 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -40,8 +40,8 @@ IMPLEMENT_PERSISTENT(CBScriptHolder, false) CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { SetName(""); - m_Freezable = true; - m_Filename = NULL; + _freezable = true; + _filename = NULL; } @@ -53,26 +53,26 @@ CBScriptHolder::~CBScriptHolder() { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptHolder::Cleanup() { - delete[] m_Filename; - m_Filename = NULL; + delete[] _filename; + _filename = NULL; int i; - for (i = 0; i < m_Scripts.GetSize(); i++) { - m_Scripts[i]->Finish(true); - m_Scripts[i]->m_Owner = NULL; + for (i = 0; i < _scripts.GetSize(); i++) { + _scripts[i]->Finish(true); + _scripts[i]->_owner = NULL; } - m_Scripts.RemoveAll(); + _scripts.RemoveAll(); return S_OK; } ////////////////////////////////////////////////////////////////////// void CBScriptHolder::SetFilename(char *Filename) { - if (m_Filename != NULL) delete [] m_Filename; + if (_filename != NULL) delete [] _filename; - m_Filename = new char [strlen(Filename) + 1]; - if (m_Filename != NULL) strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + if (_filename != NULL) strcpy(_filename, Filename); } @@ -81,17 +81,17 @@ HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { int NumHandlers = 0; HRESULT ret = E_FAIL; - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (!m_Scripts[i]->m_Thread) { - CScScript *handler = m_Scripts[i]->InvokeEventHandler(EventName, Unbreakable); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->InvokeEventHandler(EventName, Unbreakable); if (handler) { - //m_Scripts.Add(handler); + //_scripts.Add(handler); NumHandlers++; ret = S_OK; } } } - if (NumHandlers > 0 && Unbreakable) Game->m_ScEngine->TickUnbreakable(); + if (NumHandlers > 0 && Unbreakable) Game->_scEngine->TickUnbreakable(); return ret; } @@ -172,9 +172,9 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac char *Filename = Stack->Pop()->GetString(); bool KillThreads = Stack->Pop()->GetBool(false); bool ret = false; - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0) { - m_Scripts[i]->Finish(KillThreads); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + _scripts[i]->Finish(KillThreads); ret = true; break; } @@ -191,8 +191,8 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); bool ret = false; - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0 && m_Scripts[i]->m_State != SCRIPT_FINISHED && m_Scripts[i]->m_State != SCRIPT_ERROR) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; } @@ -206,30 +206,30 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// CScValue *CBScriptHolder::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("script_holder"); - return m_ScValue; + _scValue->SetString("script_holder"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Filename") == 0) { - m_ScValue->SetString(m_Filename); - return m_ScValue; + _scValue->SetString(_filename); + return _scValue; } else return CBScriptable::ScGetProperty(Name); @@ -263,10 +263,10 @@ HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_Freezable)); - PersistMgr->Transfer(TMEMBER(m_Name)); - m_Scripts.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_freezable)); + PersistMgr->Transfer(TMEMBER(_name)); + _scripts.Persist(PersistMgr); return S_OK; } @@ -274,34 +274,34 @@ HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptHolder::AddScript(char *Filename) { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (scumm_stricmp(m_Scripts[i]->m_Filename, Filename) == 0) { - if (m_Scripts[i]->m_State != SCRIPT_FINISHED) { - Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, m_Name); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, _name); return S_OK; } } } - CScScript *scr = Game->m_ScEngine->RunScript(Filename, this); + CScScript *scr = Game->_scEngine->RunScript(Filename, this); if (!scr) { - if (Game->m_EditorForceScripts) { + if (Game->_editorForceScripts) { // editor hack - scr = new CScScript(Game, Game->m_ScEngine); - scr->m_Filename = new char[strlen(Filename) + 1]; - strcpy(scr->m_Filename, Filename); - scr->m_State = SCRIPT_ERROR; - scr->m_Owner = this; - m_Scripts.Add(scr); - Game->m_ScEngine->m_Scripts.Add(scr); + scr = new CScScript(Game, Game->_scEngine); + scr->_filename = new char[strlen(Filename) + 1]; + strcpy(scr->_filename, Filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.Add(scr); + Game->_scEngine->_scripts.Add(scr); Game->GetDebugMgr()->OnScriptInit(scr); return S_OK; } return E_FAIL; } else { - scr->m_Freezable = m_Freezable; - m_Scripts.Add(scr); + scr->_freezable = _freezable; + _scripts.Add(scr); return S_OK; } } @@ -309,9 +309,9 @@ HRESULT CBScriptHolder::AddScript(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i] == Script) { - m_Scripts.RemoveAt(i); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] == Script) { + _scripts.RemoveAt(i); break; } } @@ -320,8 +320,8 @@ HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::CanHandleEvent(char *EventName) { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (!m_Scripts[i]->m_Thread && m_Scripts[i]->CanHandleEvent(EventName)) return true; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->CanHandleEvent(EventName)) return true; } return false; } @@ -329,8 +329,8 @@ bool CBScriptHolder::CanHandleEvent(char *EventName) { ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::CanHandleMethod(char *MethodName) { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (!m_Scripts[i]->m_Thread && m_Scripts[i]->CanHandleMethod(MethodName)) return true; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->CanHandleMethod(MethodName)) return true; } return false; } @@ -416,24 +416,24 @@ HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// void CBScriptHolder::MakeFreezable(bool Freezable) { - m_Freezable = Freezable; - for (int i = 0; i < m_Scripts.GetSize(); i++) - m_Scripts[i]->m_Freezable = Freezable; + _freezable = Freezable; + for (int i = 0; i < _scripts.GetSize(); i++) + _scripts[i]->_freezable = Freezable; } ////////////////////////////////////////////////////////////////////////// CScScript *CBScriptHolder::InvokeMethodThread(char *MethodName) { - for (int i = m_Scripts.GetSize() - 1; i >= 0; i--) { - if (m_Scripts[i]->CanHandleMethod(MethodName)) { + for (int i = _scripts.GetSize() - 1; i >= 0; i--) { + if (_scripts[i]->CanHandleMethod(MethodName)) { - CScScript *thread = new CScScript(Game, m_Scripts[i]->m_Engine); + CScScript *thread = new CScScript(Game, _scripts[i]->_engine); if (thread) { - HRESULT ret = thread->CreateMethodThread(m_Scripts[i], MethodName); + HRESULT ret = thread->CreateMethodThread(_scripts[i], MethodName); if (SUCCEEDED(ret)) { - m_Scripts[i]->m_Engine->m_Scripts.Add(thread); - Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, m_Scripts[i], MethodName); + _scripts[i]->_engine->_scripts.Add(thread); + Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], MethodName); return thread; } else { @@ -449,13 +449,13 @@ CScScript *CBScriptHolder::InvokeMethodThread(char *MethodName) { ////////////////////////////////////////////////////////////////////////// void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { strcpy(Buf, ScToString()); - if (m_Name && strcmp(m_Name, "") != 0) { + if (_name && strcmp(_name, "") != 0) { strcat(Buf, " Name: "); - strcat(Buf, m_Name); + strcat(Buf, _name); } - if (m_Filename) { + if (_filename) { strcat(Buf, " File: "); - strcat(Buf, m_Filename); + strcat(Buf, _filename); } } diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index e4a4c0f6f6..cc54a983c2 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -53,11 +53,11 @@ public: HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); void SetFilename(char *Filename); HRESULT ParseProperty(byte *Buffer, bool Complete = true); - char *m_Filename; - bool m_Freezable; - bool m_Ready; + char *_filename; + bool _freezable; + bool _ready; - CBArray m_Scripts; + CBArray _scripts; // scripting interface virtual CScValue *ScGetProperty(char *Name); virtual HRESULT ScSetProperty(char *Name, CScValue *Value); diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index 9b875eeffb..e38ee061d8 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -37,24 +37,24 @@ IMPLEMENT_PERSISTENT(CBScriptable, false) ////////////////////////////////////////////////////////////////////////// CBScriptable::CBScriptable(CBGame *inGame, bool NoValue, bool Persistable): CBNamedObject(inGame) { - m_RefCount = 0; + _refCount = 0; - if (NoValue) m_ScValue = NULL; - else m_ScValue = new CScValue(Game); + if (NoValue) _scValue = NULL; + else _scValue = new CScValue(Game); - m_Persistable = Persistable; + _persistable = Persistable; - m_ScProp = NULL; + _scProp = NULL; } ////////////////////////////////////////////////////////////////////////// CBScriptable::~CBScriptable() { - //if(m_RefCount>0) Game->LOG(0, "Warning: Destroying object, m_RefCount=%d", m_RefCount); - delete m_ScValue; - delete m_ScProp; - m_ScValue = NULL; - m_ScProp = NULL; + //if(_refCount>0) Game->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; } @@ -75,16 +75,16 @@ HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CBScriptable::ScGetProperty(char *Name) { - if (!m_ScProp) m_ScProp = new CScValue(Game); - if (m_ScProp) return m_ScProp->GetProp(Name); + if (!_scProp) _scProp = new CScValue(Game); + if (_scProp) return _scProp->GetProp(Name); else return NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptable::ScSetProperty(char *Name, CScValue *Value) { - if (!m_ScProp) m_ScProp = new CScValue(Game); - if (m_ScProp) return m_ScProp->SetProp(Name, Value); + if (!_scProp) _scProp = new CScValue(Game); + if (_scProp) return _scProp->SetProp(Name, Value); else return E_FAIL; } @@ -141,9 +141,9 @@ void CBScriptable::ScSetBool(bool Val) { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptable::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_RefCount)); - PersistMgr->Transfer(TMEMBER(m_ScProp)); - PersistMgr->Transfer(TMEMBER(m_ScValue)); + PersistMgr->Transfer(TMEMBER(_refCount)); + PersistMgr->Transfer(TMEMBER(_scProp)); + PersistMgr->Transfer(TMEMBER(_scValue)); return S_OK; } diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index 2a87b9c305..71ce682a4b 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -64,9 +64,9 @@ public: virtual void ScSetBool(bool Val); virtual int ScCompare(CBScriptable *Val); virtual void ScDebuggerDesc(char *Buf, int BufSize); - int m_RefCount; - CScValue *m_ScValue; - CScValue *m_ScProp; + int _refCount; + CScValue *_scValue; + CScValue *_scProp; public: // IWmeDebugObject diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp index b6261f8117..46f7c5ce45 100644 --- a/engines/wintermute/BSound.cpp +++ b/engines/wintermute/BSound.cpp @@ -36,50 +36,50 @@ IMPLEMENT_PERSISTENT(CBSound, false) ////////////////////////////////////////////////////////////////////////// CBSound::CBSound(CBGame *inGame): CBBase(inGame) { - m_Sound = NULL; - m_SoundFilename = NULL; - - m_SoundType = SOUND_SFX; - m_SoundStreamed = false; - m_SoundLooping = false; - m_SoundPlaying = false; - m_SoundPaused = false; - m_SoundFreezePaused = false; - m_SoundPosition = 0; - m_SoundPrivateVolume = 0; - m_SoundLoopStart = 0; - - m_SFXType = SFX_NONE; - m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + _sound = NULL; + _soundFilename = NULL; + + _soundType = SOUND_SFX; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } ////////////////////////////////////////////////////////////////////////// CBSound::~CBSound() { - if (m_Sound) Game->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; + if (_sound) Game->_soundMgr->RemoveSound(_sound); + _sound = NULL; - delete[] m_SoundFilename; - m_SoundFilename = NULL; + delete[] _soundFilename; + _soundFilename = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { - if (m_Sound) { - Game->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; + if (_sound) { + Game->_soundMgr->RemoveSound(_sound); + _sound = NULL; } - delete[] m_SoundFilename; - m_SoundFilename = NULL; + delete[] _soundFilename; + _soundFilename = NULL; - m_Sound = Game->m_SoundMgr->AddSound(Filename, Type, Streamed); - if (m_Sound) { - m_SoundFilename = new char[strlen(Filename) + 1]; - strcpy(m_SoundFilename, Filename); + _sound = Game->_soundMgr->AddSound(Filename, Type, Streamed); + if (_sound) { + _soundFilename = new char[strlen(Filename) + 1]; + strcpy(_soundFilename, Filename); - m_SoundType = Type; - m_SoundStreamed = Streamed; + _soundType = Type; + _soundStreamed = Streamed; return S_OK; } else return E_FAIL; @@ -88,14 +88,14 @@ HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetSoundSimple() { - m_Sound = Game->m_SoundMgr->AddSound(m_SoundFilename, m_SoundType, m_SoundStreamed); - if (m_Sound) { - if (m_SoundPosition) m_Sound->SetPosition(m_SoundPosition); - m_Sound->SetLooping(m_SoundLooping); - m_Sound->SetPrivateVolume(m_SoundPrivateVolume); - m_Sound->SetLoopStart(m_SoundLoopStart); - m_Sound->m_FreezePaused = m_SoundFreezePaused; - if (m_SoundPlaying) return m_Sound->Resume(); + _sound = Game->_soundMgr->AddSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->SetPosition(_soundPosition); + _sound->SetLooping(_soundLooping); + _sound->SetPrivateVolume(_soundPrivateVolume); + _sound->SetLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->Resume(); else return S_OK; } else return E_FAIL; } @@ -104,76 +104,76 @@ HRESULT CBSound::SetSoundSimple() { ////////////////////////////////////////////////////////////////////////// uint32 CBSound::GetLength() { - if (m_Sound) return m_Sound->GetLength(); + if (_sound) return _sound->GetLength(); else return 0; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::Play(bool Looping) { - if (m_Sound) { - m_SoundPaused = false; - return m_Sound->Play(Looping, m_SoundPosition); + if (_sound) { + _soundPaused = false; + return _sound->Play(Looping, _soundPosition); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::Stop() { - if (m_Sound) { - m_SoundPaused = false; - return m_Sound->Stop(); + if (_sound) { + _soundPaused = false; + return _sound->Stop(); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::Pause(bool FreezePaused) { - if (m_Sound) { - m_SoundPaused = true; - if (FreezePaused) m_Sound->m_FreezePaused = true; - return m_Sound->Pause(); + if (_sound) { + _soundPaused = true; + if (FreezePaused) _sound->_freezePaused = true; + return _sound->Pause(); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::Resume() { - if (m_Sound && m_SoundPaused) { - m_SoundPaused = false; - return m_Sound->Resume(); + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->Resume(); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { - if (PersistMgr->m_Saving && m_Sound) { - m_SoundPlaying = m_Sound->IsPlaying(); - m_SoundLooping = m_Sound->m_Looping; - m_SoundPrivateVolume = m_Sound->m_PrivateVolume; - if (m_SoundPlaying) m_SoundPosition = m_Sound->GetPosition(); - m_SoundLoopStart = m_Sound->m_LoopStart; - m_SoundFreezePaused = m_Sound->m_FreezePaused; + if (PersistMgr->_saving && _sound) { + _soundPlaying = _sound->IsPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) _soundPosition = _sound->GetPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; } - if (PersistMgr->m_Saving) { - m_SFXType = SFX_NONE; - m_SFXParam1 = m_SFXParam2 = m_SFXParam3 = m_SFXParam4 = 0; + if (PersistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_SoundFilename)); - PersistMgr->Transfer(TMEMBER(m_SoundLooping)); - PersistMgr->Transfer(TMEMBER(m_SoundPaused)); - PersistMgr->Transfer(TMEMBER(m_SoundFreezePaused)); - PersistMgr->Transfer(TMEMBER(m_SoundPlaying)); - PersistMgr->Transfer(TMEMBER(m_SoundPosition)); - PersistMgr->Transfer(TMEMBER(m_SoundPrivateVolume)); - PersistMgr->Transfer(TMEMBER(m_SoundStreamed)); - PersistMgr->Transfer(TMEMBER_INT(m_SoundType)); - PersistMgr->Transfer(TMEMBER(m_SoundLoopStart)); + PersistMgr->Transfer(TMEMBER(_soundFilename)); + PersistMgr->Transfer(TMEMBER(_soundLooping)); + PersistMgr->Transfer(TMEMBER(_soundPaused)); + PersistMgr->Transfer(TMEMBER(_soundFreezePaused)); + PersistMgr->Transfer(TMEMBER(_soundPlaying)); + PersistMgr->Transfer(TMEMBER(_soundPosition)); + PersistMgr->Transfer(TMEMBER(_soundPrivateVolume)); + PersistMgr->Transfer(TMEMBER(_soundStreamed)); + PersistMgr->Transfer(TMEMBER_INT(_soundType)); + PersistMgr->Transfer(TMEMBER(_soundLoopStart)); return S_OK; } @@ -181,82 +181,82 @@ HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// bool CBSound::IsPlaying() { - return m_Sound && m_Sound->IsPlaying(); + return _sound && _sound->IsPlaying(); } ////////////////////////////////////////////////////////////////////////// bool CBSound::IsPaused() { - return m_Sound && m_SoundPaused; + return _sound && _soundPaused; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetPositionTime(uint32 Time) { - if (!m_Sound) return E_FAIL; - m_SoundPosition = Time; - HRESULT ret = m_Sound->SetPosition(m_SoundPosition); - if (m_Sound->IsPlaying()) m_SoundPosition = 0; + if (!_sound) return E_FAIL; + _soundPosition = Time; + HRESULT ret = _sound->SetPosition(_soundPosition); + if (_sound->IsPlaying()) _soundPosition = 0; return ret; } ////////////////////////////////////////////////////////////////////////// uint32 CBSound::GetPositionTime() { - if (!m_Sound) return 0; + if (!_sound) return 0; - if (!m_Sound->IsPlaying()) return 0; - else return m_Sound->GetPosition(); + if (!_sound->IsPlaying()) return 0; + else return _sound->GetPosition(); } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetVolume(int Volume) { - if (!m_Sound) return E_FAIL; - else return m_Sound->SetPrivateVolume(Volume); + if (!_sound) return E_FAIL; + else return _sound->SetPrivateVolume(Volume); } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetPrivateVolume(int Volume) { - if (!m_Sound) return E_FAIL; - else return m_Sound->m_PrivateVolume = Volume; + if (!_sound) return E_FAIL; + else return _sound->_privateVolume = Volume; } ////////////////////////////////////////////////////////////////////////// int CBSound::GetVolume() { - if (!m_Sound) return 0; - else return m_Sound->m_PrivateVolume; + if (!_sound) return 0; + else return _sound->_privateVolume; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetLoopStart(uint32 Pos) { - if (!m_Sound) return E_FAIL; + if (!_sound) return E_FAIL; else { - m_Sound->SetLoopStart(Pos); + _sound->SetLoopStart(Pos); return S_OK; } } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetPan(float Pan) { - if (m_Sound) return m_Sound->SetPan(Pan); + if (_sound) return _sound->SetPan(Pan); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { - if (!m_Sound) return S_OK; + if (!_sound) return S_OK; - if (Type != m_SFXType || Param1 != m_SFXParam1 || Param2 != m_SFXParam2 || Param3 != m_SFXParam3 || Param4 != m_SFXParam4) { - HRESULT Ret = m_Sound->ApplyFX(Type, Param1, Param2, Param3, Param4); + if (Type != _sFXType || Param1 != _sFXParam1 || Param2 != _sFXParam2 || Param3 != _sFXParam3 || Param4 != _sFXParam4) { + HRESULT Ret = _sound->ApplyFX(Type, Param1, Param2, Param3, Param4); - m_SFXType = Type; - m_SFXParam1 = Param1; - m_SFXParam2 = Param2; - m_SFXParam3 = Param3; - m_SFXParam4 = Param4; + _sFXType = Type; + _sFXParam1 = Param1; + _sFXParam2 = Param2; + _sFXParam3 = Param3; + _sFXParam4 = Param4; return Ret; } diff --git a/engines/wintermute/BSound.h b/engines/wintermute/BSound.h index 0320030c72..922992de7f 100644 --- a/engines/wintermute/BSound.h +++ b/engines/wintermute/BSound.h @@ -39,30 +39,30 @@ namespace WinterMute { class CBSound : public CBBase { public: HRESULT SetPan(float Pan); - int m_SoundPrivateVolume; + int _soundPrivateVolume; int GetVolume(); HRESULT SetVolume(int Volume); HRESULT SetPrivateVolume(int Volume); HRESULT SetLoopStart(uint32 Pos); uint32 GetPositionTime(); HRESULT SetPositionTime(uint32 Time); - bool m_SoundPaused; - bool m_SoundFreezePaused; + bool _soundPaused; + bool _soundFreezePaused; bool IsPlaying(); bool IsPaused(); - bool m_SoundPlaying; - bool m_SoundLooping; - uint32 m_SoundLoopStart; - uint32 m_SoundPosition; + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; DECLARE_PERSISTENT(CBSound, CBBase) HRESULT Resume(); HRESULT Pause(bool FreezePaused = false); HRESULT Stop(); HRESULT Play(bool Looping = false); uint32 GetLength(); - bool m_SoundStreamed; - TSoundType m_SoundType; - char *m_SoundFilename; + bool _soundStreamed; + TSoundType _soundType; + char *_soundFilename; HRESULT SetSoundSimple(); HRESULT SetSound(char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); CBSound(CBGame *inGame); @@ -71,12 +71,12 @@ public: HRESULT ApplyFX(TSFXType Type = SFX_NONE, float Param1 = 0, float Param2 = 0, float Param3 = 0, float Param4 = 0); private: - TSFXType m_SFXType; - float m_SFXParam1; - float m_SFXParam2; - float m_SFXParam3; - float m_SFXParam4; - CBSoundBuffer *m_Sound; + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; }; diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index 48c63bf4d9..7de8aec436 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -45,20 +45,20 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { #if 0 - m_Stream = NULL; - m_Sync = NULL; + _stream = NULL; + _sync = NULL; - m_Streamed = false; - m_Filename = NULL; - m_File = NULL; - m_PrivateVolume = 100; + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 100; - m_Looping = false; - m_LoopStart = 0; + _looping = false; + _loopStart = 0; - m_Type = SOUND_SFX; + _type = SOUND_SFX; - m_FreezePaused = false; + _freezePaused = false; #endif } @@ -68,39 +68,39 @@ CBSoundBuffer::~CBSoundBuffer() { #if 0 Stop(); - if (m_Stream) { - BASS_StreamFree(m_Stream); - m_Stream = NULL; + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; } - if (m_File) { - Game->m_FileManager->CloseFile(m_File); - m_File = NULL; + if (_file) { + Game->_fileManager->CloseFile(_file); + _file = NULL; } - SAFE_DELETE_ARRAY(m_Filename); + SAFE_DELETE_ARRAY(_filename); #endif } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { - m_Streamed = Streamed; + _streamed = Streamed; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { #if 0 - if (m_Stream) { - BASS_StreamFree(m_Stream); - m_Stream = NULL; + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; } - if (m_File) Game->m_FileManager->CloseFile(m_File); + if (_file) Game->_fileManager->CloseFile(_file); - m_File = Game->m_FileManager->OpenFile(Filename); - if (!m_File) { + _file = Game->_fileManager->OpenFile(Filename); + if (!_file) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } @@ -111,33 +111,33 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { fileProc.seek = CBSoundBuffer::FileSeekProc; fileProc.length = CBSoundBuffer::FileLenProc; - m_Stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)m_File); - if (!m_Stream) { + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), Filename); return E_FAIL; } - CBUtils::SetString(&m_Filename, Filename); + CBUtils::SetString(&_filename, Filename); /* HRESULT res; bool NewlyCreated = false; - if(!m_SoundBuffer || ForceReload || m_Streamed){ - if(!m_File) m_File = Game->m_FileManager->OpenFile(Filename); - if(!m_File){ + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = Game->_fileManager->OpenFile(Filename); + if(!_file){ Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } // switch to streamed for big files - if(!m_Streamed && (m_File->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->m_ForceNonStreamedSounds)) SetStreaming(true); + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true); } // create buffer - if(!m_SoundBuffer){ + if(!_soundBuffer){ NewlyCreated = true; - res = InitializeBuffer(m_File); + res = InitializeBuffer(_file); if(FAILED(res)){ Game->LOG(res, "Error creating sound buffer for file '%s'", Filename); return res; @@ -147,15 +147,15 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { // store filename - if(!m_Filename){ - m_Filename = new char[strlen(Filename)+1]; - strcpy(m_Filename, Filename); + if(!_filename){ + _filename = new char[strlen(Filename)+1]; + strcpy(_filename, Filename); } // close file (if not streaming) - if(!m_Streamed && m_File){ - Game->m_FileManager->CloseFile(m_File); - m_File = NULL; + if(!_streamed && _file){ + Game->_fileManager->CloseFile(_file); + _file = NULL; } */ @@ -167,9 +167,9 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { #if 0 - if (m_Stream) { + if (_stream) { SetLooping(Looping); - BASS_ChannelPlay(m_Stream, TRUE); + BASS_ChannelPlay(_stream, TRUE); } return S_OK; #endif @@ -178,10 +178,10 @@ HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetLooping(bool looping) { #if 0 - m_Looping = looping; + _looping = looping; - if (m_Stream) { - BASS_ChannelFlags(m_Stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); } #endif } @@ -189,8 +189,8 @@ void CBSoundBuffer::SetLooping(bool looping) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Resume() { #if 0 - if (m_Stream) { - BASS_ChannelPlay(m_Stream, FALSE); + if (_stream) { + BASS_ChannelPlay(_stream, FALSE); } return S_OK; #endif @@ -200,8 +200,8 @@ HRESULT CBSoundBuffer::Resume() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Stop() { #if 0 - if (m_Stream) { - BASS_ChannelStop(m_Stream); + if (_stream) { + BASS_ChannelStop(_stream); } #endif return S_OK; @@ -211,8 +211,8 @@ HRESULT CBSoundBuffer::Stop() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Pause() { #if 0 - if (m_Stream) { - BASS_ChannelPause(m_Stream); + if (_stream) { + BASS_ChannelPause(_stream); } #endif return S_OK; @@ -222,23 +222,23 @@ HRESULT CBSoundBuffer::Pause() { ////////////////////////////////////////////////////////////////////////// uint32 CBSoundBuffer::GetLength() { #if 0 - QWORD len = BASS_ChannelGetLength(m_Stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(m_Stream, len); + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(_stream, len); #endif } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetType(TSoundType Type) { - m_Type = Type; + _type = Type; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetVolume(int Volume) { #if 0 - if (m_Stream) { - BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); + if (_stream) { + BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); } #endif return S_OK; @@ -248,17 +248,17 @@ HRESULT CBSoundBuffer::SetVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { #if 0 - m_PrivateVolume = Volume; + _privateVolume = Volume; - switch (m_Type) { + switch (_type) { case SOUND_SFX: - Volume = Game->m_SoundMgr->m_VolumeSFX; + Volume = Game->_soundMgr->_volumeSFX; break; case SOUND_SPEECH: - Volume = Game->m_SoundMgr->m_VolumeSpeech; + Volume = Game->_soundMgr->_volumeSpeech; break; case SOUND_MUSIC: - Volume = Game->m_SoundMgr->m_VolumeMusic; + Volume = Game->_soundMgr->_volumeMusic; break; } #endif @@ -269,7 +269,7 @@ HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// bool CBSoundBuffer::IsPlaying() { #if 0 - return m_FreezePaused || BASS_ChannelIsActive(m_Stream) == BASS_ACTIVE_PLAYING; + return _freezePaused || BASS_ChannelIsActive(_stream) == BASS_ACTIVE_PLAYING; #endif return false; } @@ -278,9 +278,9 @@ bool CBSoundBuffer::IsPlaying() { ////////////////////////////////////////////////////////////////////////// uint32 CBSoundBuffer::GetPosition() { #if 0 - if (m_Stream) { - QWORD len = BASS_ChannelGetPosition(m_Stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(m_Stream, len); + if (_stream) { + QWORD len = BASS_ChannelGetPosition(_stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(_stream, len); } else return 0; #endif return 0; @@ -290,9 +290,9 @@ uint32 CBSoundBuffer::GetPosition() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { #if 0 - if (m_Stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(m_Stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(m_Stream, pos, BASS_POS_BYTE); + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); } #endif return S_OK; @@ -300,16 +300,16 @@ HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetLoopStart(uint32 Pos) { - m_LoopStart = Pos; + _loopStart = Pos; #if 0 - if (m_Stream) { - if (m_Sync) { - BASS_ChannelRemoveSync(m_Stream, m_Sync); - m_Sync = NULL; + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; } - if (m_LoopStart > 0) { - QWORD len = BASS_ChannelGetLength(m_Stream, BASS_POS_BYTE); - m_Sync = BASS_ChannelSetSync(m_Stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); } } #endif @@ -328,8 +328,8 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetPan(float Pan) { #if 0 - if (m_Stream) { - BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_PAN, Pan); + if (_stream) { + BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_PAN, Pan); } #endif return S_OK; @@ -357,7 +357,7 @@ HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float void CBSoundBuffer::FileCloseProc(void *user) { /* CBFile* file = static_cast(user); - file->Game->m_FileManager->CloseFile(file); + file->Game->_fileManager->CloseFile(file); */ } diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h index 4571612122..2a1016f7a9 100644 --- a/engines/wintermute/BSoundBuffer.h +++ b/engines/wintermute/BSoundBuffer.h @@ -57,7 +57,7 @@ public: HRESULT SetLoopStart(uint32 Pos); uint32 GetLoopStart() const { - return m_LoopStart; + return _loopStart; } HRESULT SetPan(float Pan); @@ -70,17 +70,17 @@ public: void SetStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); HRESULT ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); - //HSTREAM m_Stream; - //HSYNC m_Sync; - - bool m_FreezePaused; - uint32 m_LoopStart; - TSoundType m_Type; - bool m_Looping; - CBFile *m_File; - char *m_Filename; - bool m_Streamed; - int m_PrivateVolume; + //HSTREAM _stream; + //HSYNC _sync; + + bool _freezePaused; + uint32 _loopStart; + TSoundType _type; + bool _looping; + CBFile *_file; + char *_filename; + bool _streamed; + int _privateVolume; /*static void CALLBACK LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user); diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index 894a586ee4..3f2837b1db 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -44,9 +44,9 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { - m_SoundAvailable = false; + _soundAvailable = false; - m_VolumeSFX = m_VolumeSpeech = m_VolumeMusic = m_VolumeMaster = 100; + _volumeSFX = _volumeSpeech = _volumeMusic = _volumeMaster = 100; } @@ -60,8 +60,8 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::Cleanup() { #if 0 - for (int i = 0; i < m_Sounds.GetSize(); i++) delete m_Sounds[i]; - m_Sounds.RemoveAll(); + for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; + _sounds.RemoveAll(); BASS_Free(); #endif @@ -70,18 +70,18 @@ HRESULT CBSoundMgr::Cleanup() { ////////////////////////////////////////////////////////////////////////// void CBSoundMgr::SaveSettings() { - if (m_SoundAvailable) { - Game->m_Registry->WriteInt("Audio", "MasterVolume", m_VolumeMaster); + if (_soundAvailable) { + Game->_registry->WriteInt("Audio", "MasterVolume", _volumeMaster); - Game->m_Registry->WriteInt("Audio", "SFXVolume", m_VolumeSFX); - Game->m_Registry->WriteInt("Audio", "SpeechVolume", m_VolumeSpeech); - Game->m_Registry->WriteInt("Audio", "MusicVolume", m_VolumeMusic); + Game->_registry->WriteInt("Audio", "SFXVolume", _volumeSFX); + Game->_registry->WriteInt("Audio", "SpeechVolume", _volumeSpeech); + Game->_registry->WriteInt("Audio", "MusicVolume", _volumeMusic); } } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::Initialize() { - m_SoundAvailable = false; + _soundAvailable = false; #if 0 #ifdef __IPHONEOS__ @@ -101,15 +101,15 @@ HRESULT CBSoundMgr::Initialize() { } #endif - m_VolumeMaster = Game->m_Registry->ReadInt("Audio", "MasterVolume", 100); + _volumeMaster = Game->_registry->ReadInt("Audio", "MasterVolume", 100); - m_VolumeSFX = Game->m_Registry->ReadInt("Audio", "SFXVolume", 100); - m_VolumeSpeech = Game->m_Registry->ReadInt("Audio", "SpeechVolume", 100); - m_VolumeMusic = Game->m_Registry->ReadInt("Audio", "MusicVolume", 100); + _volumeSFX = Game->_registry->ReadInt("Audio", "SFXVolume", 100); + _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100); + _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); #if 0 - m_SoundAvailable = true; - SetMasterVolumePercent(m_VolumeMaster); + _soundAvailable = true; + SetMasterVolumePercent(_volumeMaster); #endif return S_OK; } @@ -117,7 +117,7 @@ HRESULT CBSoundMgr::Initialize() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::InitLoop() { - if (!m_SoundAvailable) return S_OK; + if (!_soundAvailable) return S_OK; #if 0 BASS_Update(500); @@ -128,7 +128,7 @@ HRESULT CBSoundMgr::InitLoop() { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool Streamed) { - if (!m_SoundAvailable) return NULL; + if (!_soundAvailable) return NULL; #if 0 CBSoundBuffer *sound; @@ -140,10 +140,10 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); AnsiString newFile = PathUtil::Combine(path, name + ".ogg"); - CBFile *file = Game->m_FileManager->OpenFile(newFile.c_str()); + CBFile *file = Game->_fileManager->OpenFile(newFile.c_str()); if (file) { Filename = newFile.c_str(); - Game->m_FileManager->CloseFile(file); + Game->_fileManager->CloseFile(file); } } @@ -164,18 +164,18 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool // set volume appropriately switch (Type) { case SOUND_SFX: - sound->SetVolume(m_VolumeSFX); + sound->SetVolume(_volumeSFX); break; case SOUND_SPEECH: - sound->SetVolume(m_VolumeSpeech); + sound->SetVolume(_volumeSpeech); break; case SOUND_MUSIC: - sound->SetVolume(m_VolumeMusic); + sound->SetVolume(_volumeMusic); break; } // register sound - m_Sounds.Add(sound); + _sounds.Add(sound); return sound; #endif @@ -189,18 +189,18 @@ HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { // set volume appropriately switch (Type) { case SOUND_SFX: - Sound->SetVolume(m_VolumeSFX); + Sound->SetVolume(_volumeSFX); break; case SOUND_SPEECH: - Sound->SetVolume(m_VolumeSpeech); + Sound->SetVolume(_volumeSpeech); break; case SOUND_MUSIC: - Sound->SetVolume(m_VolumeMusic); + Sound->SetVolume(_volumeMusic); break; } // register sound - m_Sounds.Add(Sound); + _sounds.Add(Sound); #endif return S_OK; } @@ -208,10 +208,10 @@ HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { #if 0 - for (int i = 0; i < m_Sounds.GetSize(); i++) { - if (m_Sounds[i] == Sound) { - delete m_Sounds[i]; - m_Sounds.RemoveAt(i); + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i] == Sound) { + delete _sounds[i]; + _sounds.RemoveAt(i); return S_OK; } } @@ -222,22 +222,22 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { - if (!m_SoundAvailable) return S_OK; + if (!_soundAvailable) return S_OK; #if 0 switch (Type) { case SOUND_SFX: - m_VolumeSFX = Volume; + _volumeSFX = Volume; break; case SOUND_SPEECH: - m_VolumeSpeech = Volume; + _volumeSpeech = Volume; break; case SOUND_MUSIC: - m_VolumeMusic = Volume; + _volumeMusic = Volume; break; } - for (int i = 0; i < m_Sounds.GetSize(); i++) { - if (m_Sounds[i]->m_Type == Type) m_Sounds[i]->SetVolume(Volume); + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume); } #endif return S_OK; @@ -254,13 +254,13 @@ byte CBSoundMgr::GetVolumePercent(TSoundType Type) { int Volume; switch (Type) { case SOUND_SFX: - Volume = m_VolumeSFX; + Volume = _volumeSFX; break; case SOUND_SPEECH: - Volume = m_VolumeSpeech; + Volume = _volumeSpeech; break; case SOUND_MUSIC: - Volume = m_VolumeMusic; + Volume = _volumeMusic; break; } @@ -270,7 +270,7 @@ byte CBSoundMgr::GetVolumePercent(TSoundType Type) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::SetMasterVolumePercent(byte Percent) { - m_VolumeMaster = Percent; + _volumeMaster = Percent; #if 0 BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); #endif @@ -292,10 +292,10 @@ byte CBSoundMgr::GetMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { #if 0 - for (int i = 0; i < m_Sounds.GetSize(); i++) { - if (m_Sounds[i]->IsPlaying() && (m_Sounds[i]->m_Type != SOUND_MUSIC || IncludingMusic)) { - m_Sounds[i]->Pause(); - m_Sounds[i]->m_FreezePaused = true; + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { + _sounds[i]->Pause(); + _sounds[i]->_freezePaused = true; } } #endif @@ -306,10 +306,10 @@ HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::ResumeAll() { #if 0 - for (int i = 0; i < m_Sounds.GetSize(); i++) { - if (m_Sounds[i]->m_FreezePaused) { - m_Sounds[i]->Resume(); - m_Sounds[i]->m_FreezePaused = false; + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->Resume(); + _sounds[i]->_freezePaused = false; } } #endif @@ -319,7 +319,7 @@ HRESULT CBSoundMgr::ResumeAll() { ////////////////////////////////////////////////////////////////////////// float CBSoundMgr::PosToPan(int X, int Y) { - float relPos = (float)X / ((float)Game->m_Renderer->m_Width); + float relPos = (float)X / ((float)Game->_renderer->_width); float minPan = -0.7f; float maxPan = 0.7f; diff --git a/engines/wintermute/BSoundMgr.h b/engines/wintermute/BSoundMgr.h index 1ffc977211..de74f6c4df 100644 --- a/engines/wintermute/BSoundMgr.h +++ b/engines/wintermute/BSoundMgr.h @@ -48,20 +48,20 @@ public: byte GetVolumePercent(TSoundType Type); HRESULT SetVolumePercent(TSoundType Type, byte Percent); HRESULT SetVolume(TSoundType Type, int Volume); - uint32 m_VolumeOriginal; - int m_VolumeMaster; - int m_VolumeMusic; - int m_VolumeSpeech; - int m_VolumeSFX; + uint32 _volumeOriginal; + int _volumeMaster; + int _volumeMusic; + int _volumeSpeech; + int _volumeSFX; HRESULT RemoveSound(CBSoundBuffer *Sound); CBSoundBuffer *AddSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); HRESULT AddSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); HRESULT InitLoop(); HRESULT Initialize(); - bool m_SoundAvailable; + bool _soundAvailable; CBSoundMgr(CBGame *inGame); virtual ~CBSoundMgr(); - CBArray m_Sounds; + CBArray _sounds; void SaveSettings(); }; diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index 06ac69494b..d951f25461 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -49,8 +49,8 @@ IMPLEMENT_PERSISTENT(CBSprite, false) ////////////////////////////////////////////////////////////////////// CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { - m_EditorAllFrames = false; - m_Owner = Owner; + _editorAllFrames = false; + _owner = Owner; SetDefaults(); } @@ -63,26 +63,26 @@ CBSprite::~CBSprite() { ////////////////////////////////////////////////////////////////////////// void CBSprite::SetDefaults() { - m_CurrentFrame = -1; - m_Looping = false; - m_LastFrameTime = 0; - m_Filename = NULL; - m_Finished = false; - m_Changed = false; - m_Paused = false; - m_Continuous = false; - m_MoveX = m_MoveY = 0; - - m_EditorMuted = false; - m_EditorBgFile = NULL; - m_EditorBgOffsetX = m_EditorBgOffsetY = 0; - m_EditorBgAlpha = 0xFF; - m_Streamed = false; - m_StreamedKeepLoaded = false; + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; SetName(""); - m_Precise = true; + _precise = true; } @@ -90,11 +90,11 @@ void CBSprite::SetDefaults() { void CBSprite::Cleanup() { CBScriptHolder::Cleanup(); - for (int i = 0; i < m_Frames.GetSize(); i++) - delete m_Frames[i]; - m_Frames.RemoveAll(); + for (int i = 0; i < _frames.GetSize(); i++) + delete _frames[i]; + _frames.RemoveAll(); - SAFE_DELETE_ARRAY(m_EditorBgFile); + SAFE_DELETE_ARRAY(_editorBgFile); SetDefaults(); } @@ -103,16 +103,16 @@ void CBSprite::Cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha) { GetCurrentFrame(ZoomX, ZoomY); - if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return S_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; // move owner if allowed to - if (m_Changed && m_Owner && m_Owner->m_Movable) { - m_Owner->m_PosX += m_MoveX; - m_Owner->m_PosY += m_MoveY; - m_Owner->AfterMove(); + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->AfterMove(); - X = m_Owner->m_PosX; - Y = m_Owner->m_PosY; + X = _owner->_posX; + Y = _owner->_posY; } // draw frame @@ -122,13 +122,13 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// HRESULT CBSprite::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { - CBFile *File = Game->m_FileManager->OpenFile(Filename); + CBFile *File = Game->_fileManager->OpenFile(Filename); if (!File) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); - if (Game->m_DEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); + if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); else return LoadFile("invalid.bmp", LifeTime, CacheType); } else { - Game->m_FileManager->CloseFile(File); + Game->_fileManager->CloseFile(File); File = NULL; } @@ -139,28 +139,28 @@ HRESULT CBSprite::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheT CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); - if (subframe->m_Surface == NULL) { + if (subframe->_surface == NULL) { Game->LOG(0, "Error loading simple sprite '%s'", Filename); ret = E_FAIL; delete frame; delete subframe; } else { - CBPlatform::SetRect(&subframe->m_Rect, 0, 0, subframe->m_Surface->GetWidth(), subframe->m_Surface->GetHeight()); - frame->m_Subframes.Add(subframe); - m_Frames.Add(frame); - m_CurrentFrame = 0; + CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->GetWidth(), subframe->_surface->GetHeight()); + frame->_subframes.Add(subframe); + _frames.Add(frame); + _currentFrame = 0; ret = S_OK; } } else { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer) { if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); delete [] Buffer; } } - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); return ret; @@ -225,11 +225,11 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: - parser.ScanStr((char *)params, "%b", &m_Continuous); + parser.ScanStr((char *)params, "%b", &_continuous); break; case TOKEN_EDITOR_MUTED: - parser.ScanStr((char *)params, "%b", &m_EditorMuted); + parser.ScanStr((char *)params, "%b", &_editorMuted); break; case TOKEN_SCRIPT: @@ -237,23 +237,23 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_LOOPING: - parser.ScanStr((char *)params, "%b", &m_Looping); + parser.ScanStr((char *)params, "%b", &_looping); break; case TOKEN_PRECISE: - parser.ScanStr((char *)params, "%b", &m_Precise); + parser.ScanStr((char *)params, "%b", &_precise); break; case TOKEN_STREAMED: - parser.ScanStr((char *)params, "%b", &m_Streamed); - if (m_Streamed && LifeTime == -1) { + parser.ScanStr((char *)params, "%b", &_streamed); + if (_streamed && LifeTime == -1) { LifeTime = 500; CacheType = CACHE_ALL; } break; case TOKEN_STREAMED_KEEP_LOADED: - parser.ScanStr((char *)params, "%b", &m_StreamedKeepLoaded); + parser.ScanStr((char *)params, "%b", &_streamedKeepLoaded); break; case TOKEN_NAME: @@ -261,25 +261,25 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_EDITOR_BG_FILE: - if (Game->m_EditorMode) { - SAFE_DELETE_ARRAY(m_EditorBgFile); - m_EditorBgFile = new char[strlen((char *)params) + 1]; - if (m_EditorBgFile) strcpy(m_EditorBgFile, (char *)params); + if (Game->_editorMode) { + SAFE_DELETE_ARRAY(_editorBgFile); + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); } break; case TOKEN_EDITOR_BG_OFFSET_X: - parser.ScanStr((char *)params, "%d", &m_EditorBgOffsetX); + parser.ScanStr((char *)params, "%d", &_editorBgOffsetX); break; case TOKEN_EDITOR_BG_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &m_EditorBgOffsetY); + parser.ScanStr((char *)params, "%d", &_editorBgOffsetY); break; case TOKEN_EDITOR_BG_ALPHA: - parser.ScanStr((char *)params, "%d", &m_EditorBgAlpha); - m_EditorBgAlpha = std::min(m_EditorBgAlpha, 255); - m_EditorBgAlpha = std::max(m_EditorBgAlpha, 0); + parser.ScanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = std::min(_editorBgAlpha, 255); + _editorBgAlpha = std::max(_editorBgAlpha, 0); break; case TOKEN_FRAME: { @@ -288,15 +288,15 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite frame = new CBFrame(Game); - if (FAILED(frame->LoadBuffer(params, FrameLifeTime, m_StreamedKeepLoaded))) { + if (FAILED(frame->LoadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; Game->LOG(0, "Error parsing frame %d", frame_count); return E_FAIL; } - m_Frames.Add(frame); + _frames.Add(frame); frame_count++; - if (m_CurrentFrame == -1) m_CurrentFrame = 0; + if (_currentFrame == -1) _currentFrame = 0; } break; @@ -310,7 +310,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite Game->LOG(0, "Syntax error in SPRITE definition"); return E_FAIL; } - m_CanBreak = !m_Continuous; + _canBreak = !_continuous; return S_OK; } @@ -318,95 +318,95 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite ////////////////////////////////////////////////////////////////////// void CBSprite::Reset() { - if (m_Frames.GetSize() > 0) m_CurrentFrame = 0; - else m_CurrentFrame = -1; + if (_frames.GetSize() > 0) _currentFrame = 0; + else _currentFrame = -1; KillAllSounds(); - m_LastFrameTime = 0; - m_Finished = false; - m_MoveX = m_MoveY = 0; + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; } ////////////////////////////////////////////////////////////////////// bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { - //if(m_Owner && m_Owner->m_Freezable && Game->m_State == GAME_FROZEN) return true; + //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true; - if (m_CurrentFrame == -1) return false; + if (_currentFrame == -1) return false; uint32 timer; - if (m_Owner && m_Owner->m_Freezable) timer = Game->m_Timer; - else timer = Game->m_LiveTimer; + if (_owner && _owner->_freezable) timer = Game->_timer; + else timer = Game->_liveTimer; - int LastFrame = m_CurrentFrame; + int LastFrame = _currentFrame; // get current frame - if (!m_Paused && !m_Finished && timer >= m_LastFrameTime + m_Frames[m_CurrentFrame]->m_Delay && m_LastFrameTime != 0) { - if (m_CurrentFrame < m_Frames.GetSize() - 1) { - m_CurrentFrame++; - if (m_Continuous) m_CanBreak = (m_CurrentFrame == m_Frames.GetSize() - 1); + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.GetSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); } else { - if (m_Looping) { - m_CurrentFrame = 0; - m_CanBreak = true; + if (_looping) { + _currentFrame = 0; + _canBreak = true; } else { - m_Finished = true; - m_CanBreak = true; + _finished = true; + _canBreak = true; } } - m_LastFrameTime = timer; + _lastFrameTime = timer; } - m_Changed = (LastFrame != m_CurrentFrame || (m_Looping && m_Frames.GetSize() == 1)); + _changed = (LastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); - if (m_LastFrameTime == 0) { - m_LastFrameTime = timer; - m_Changed = true; - if (m_Continuous) m_CanBreak = (m_CurrentFrame == m_Frames.GetSize() - 1); + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); } - if (m_Changed) { - m_MoveX = m_Frames[m_CurrentFrame]->m_MoveX; - m_MoveY = m_Frames[m_CurrentFrame]->m_MoveY; + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; if (ZoomX != 100 || ZoomY != 100) { - m_MoveX = (int)((float)m_MoveX * (float)(ZoomX / 100.0f)); - m_MoveY = (int)((float)m_MoveY * (float)(ZoomY / 100.0f)); + _moveX = (int)((float)_moveX * (float)(ZoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(ZoomY / 100.0f)); } } - return m_Changed; + return _changed; } ////////////////////////////////////////////////////////////////////// HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return S_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; // on change... - if (m_Changed) { - if (m_Frames[m_CurrentFrame]->m_KillSound) { + if (_changed) { + if (_frames[_currentFrame]->_killSound) { KillAllSounds(); } ApplyEvent("FrameChanged"); - m_Frames[m_CurrentFrame]->OneTimeDisplay(m_Owner, Game->m_EditorMode && m_EditorMuted); + _frames[_currentFrame]->OneTimeDisplay(_owner, Game->_editorMode && _editorMuted); } // draw frame - return m_Frames[m_CurrentFrame]->Draw(X - Game->m_OffsetX, Y - Game->m_OffsetY, Register, ZoomX, ZoomY, m_Precise, Alpha, m_EditorAllFrames, Rotate, BlendMode); + return _frames[_currentFrame]->Draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); } ////////////////////////////////////////////////////////////////////////// CBSurface *CBSprite::GetSurface() { // only used for animated textures for 3D models - if (m_CurrentFrame < 0 || m_CurrentFrame >= m_Frames.GetSize()) return NULL; - CBFrame *Frame = m_Frames[m_CurrentFrame]; - if (Frame && Frame->m_Subframes.GetSize() > 0) { - CBSubFrame *Subframe = Frame->m_Subframes[0]; - if (Subframe) return Subframe->m_Surface; + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.GetSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; else return NULL; } else return NULL; } @@ -416,11 +416,11 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc if (!Rect) return false; CBPlatform::SetRectEmpty(Rect); - for (int i = 0; i < m_Frames.GetSize(); i++) { + for (int i = 0; i < _frames.GetSize(); i++) { RECT frame; RECT temp; CBPlatform::CopyRect(&temp, Rect); - m_Frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); + _frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); CBPlatform::UnionRect(Rect, &temp, &frame); } return true; @@ -429,25 +429,25 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc ////////////////////////////////////////////////////////////////////////// HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SPRITE {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); - Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", m_Looping ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", m_Continuous ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", m_Precise ? "TRUE" : "FALSE"); - if (m_Streamed) { - Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", m_Streamed ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - if (m_StreamedKeepLoaded) - Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", m_StreamedKeepLoaded ? "TRUE" : "FALSE"); + if (_streamedKeepLoaded) + Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); } - if (m_EditorMuted) - Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", m_EditorMuted ? "TRUE" : "FALSE"); + if (_editorMuted) + Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - if (m_EditorBgFile) { - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", m_EditorBgFile); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", m_EditorBgOffsetX); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", m_EditorBgOffsetY); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", m_EditorBgAlpha); + if (_editorBgFile) { + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } CBScriptHolder::SaveAsText(Buffer, Indent + 2); @@ -455,13 +455,13 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { int i; // scripts - for (i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < m_Frames.GetSize(); i++) { - m_Frames[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _frames.GetSize(); i++) { + _frames[i]->SaveAsText(Buffer, Indent + 2); } Buffer->PutTextIndent(Indent, "}\n\n"); @@ -474,29 +474,29 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { CBScriptHolder::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_CanBreak)); - PersistMgr->Transfer(TMEMBER(m_Changed)); - PersistMgr->Transfer(TMEMBER(m_Paused)); - PersistMgr->Transfer(TMEMBER(m_Continuous)); - PersistMgr->Transfer(TMEMBER(m_CurrentFrame)); - PersistMgr->Transfer(TMEMBER(m_EditorAllFrames)); - PersistMgr->Transfer(TMEMBER(m_EditorBgAlpha)); - PersistMgr->Transfer(TMEMBER(m_EditorBgFile)); - PersistMgr->Transfer(TMEMBER(m_EditorBgOffsetX)); - PersistMgr->Transfer(TMEMBER(m_EditorBgOffsetY)); - PersistMgr->Transfer(TMEMBER(m_EditorMuted)); - PersistMgr->Transfer(TMEMBER(m_Finished)); - - m_Frames.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(m_LastFrameTime)); - PersistMgr->Transfer(TMEMBER(m_Looping)); - PersistMgr->Transfer(TMEMBER(m_MoveX)); - PersistMgr->Transfer(TMEMBER(m_MoveY)); - PersistMgr->Transfer(TMEMBER(m_Owner)); - PersistMgr->Transfer(TMEMBER(m_Precise)); - PersistMgr->Transfer(TMEMBER(m_Streamed)); - PersistMgr->Transfer(TMEMBER(m_StreamedKeepLoaded)); + PersistMgr->Transfer(TMEMBER(_canBreak)); + PersistMgr->Transfer(TMEMBER(_changed)); + PersistMgr->Transfer(TMEMBER(_paused)); + PersistMgr->Transfer(TMEMBER(_continuous)); + PersistMgr->Transfer(TMEMBER(_currentFrame)); + PersistMgr->Transfer(TMEMBER(_editorAllFrames)); + PersistMgr->Transfer(TMEMBER(_editorBgAlpha)); + PersistMgr->Transfer(TMEMBER(_editorBgFile)); + PersistMgr->Transfer(TMEMBER(_editorBgOffsetX)); + PersistMgr->Transfer(TMEMBER(_editorBgOffsetY)); + PersistMgr->Transfer(TMEMBER(_editorMuted)); + PersistMgr->Transfer(TMEMBER(_finished)); + + _frames.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_lastFrameTime)); + PersistMgr->Transfer(TMEMBER(_looping)); + PersistMgr->Transfer(TMEMBER(_moveX)); + PersistMgr->Transfer(TMEMBER(_moveY)); + PersistMgr->Transfer(TMEMBER(_owner)); + PersistMgr->Transfer(TMEMBER(_precise)); + PersistMgr->Transfer(TMEMBER(_streamed)); + PersistMgr->Transfer(TMEMBER(_streamedKeepLoaded)); return S_OK; @@ -513,10 +513,10 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (strcmp(Name, "GetFrame") == 0) { Stack->CorrectParams(1); int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= m_Frames.GetSize()) { + if (Index < 0 || Index >= _frames.GetSize()) { Script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); Stack->PushNULL(); - } else Stack->PushNative(m_Frames[Index], true); + } else Stack->PushNative(_frames[Index], true); return S_OK; } @@ -528,16 +528,16 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *Val = Stack->Pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); - if (Index < 0 || Index >= m_Frames.GetSize()) { + if (Index < 0 || Index >= _frames.GetSize()) { Script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { CBFrame *Frame = (CBFrame *)Val->GetNative(); - for (int i = 0; i < m_Frames.GetSize(); i++) { - if (m_Frames[i] == Frame) { - if (i == m_CurrentFrame) m_LastFrameTime = 0; - delete m_Frames[i]; - m_Frames.RemoveAt(i); + for (int i = 0; i < _frames.GetSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.RemoveAt(i); break; } } @@ -570,10 +570,10 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CBSubFrame *Sub = new CBSubFrame(Game); if (SUCCEEDED(Sub->SetSurface(Filename))) { Sub->SetDefaultRect(); - Frame->m_Subframes.Add(Sub); + Frame->_subframes.Add(Sub); } else delete Sub; } - m_Frames.Add(Frame); + _frames.Add(Frame); Stack->PushNative(Frame, true); return S_OK; @@ -594,12 +594,12 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CBFrame *Frame = new CBFrame(Game); if (Filename != NULL) { CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->m_Subframes.Add(Sub); + if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->_subframes.Add(Sub); else delete Sub; } - if (Index >= m_Frames.GetSize()) m_Frames.Add(Frame); - else m_Frames.InsertAt(Index, Frame); + if (Index >= _frames.GetSize()) _frames.Add(Frame); + else _frames.InsertAt(Index, Frame); Stack->PushNative(Frame, true); return S_OK; @@ -610,7 +610,7 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Pause") == 0) { Stack->CorrectParams(0); - m_Paused = true; + _paused = true; Stack->PushNULL(); return S_OK; } @@ -620,7 +620,7 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Play") == 0) { Stack->CorrectParams(0); - m_Paused = false; + _paused = false; Stack->PushNULL(); return S_OK; } @@ -631,71 +631,71 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CBSprite::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("sprite"); - return m_ScValue; + _scValue->SetString("sprite"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumFrames") == 0) { - m_ScValue->SetInt(m_Frames.GetSize()); - return m_ScValue; + _scValue->SetInt(_frames.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CurrentFrame") == 0) { - m_ScValue->SetInt(m_CurrentFrame); - return m_ScValue; + _scValue->SetInt(_currentFrame); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PixelPerfect") == 0) { - m_ScValue->SetBool(m_Precise); - return m_ScValue; + _scValue->SetBool(_precise); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Looping ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Looping") == 0) { - m_ScValue->SetBool(m_Looping); - return m_ScValue; + _scValue->SetBool(_looping); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Owner (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Owner") == 0) { - if (m_Owner == NULL) m_ScValue->SetNULL(); - else m_ScValue->SetNative(m_Owner, true); - return m_ScValue; + if (_owner == NULL) _scValue->SetNULL(); + else _scValue->SetNative(_owner, true); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Finished (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Finished") == 0) { - m_ScValue->SetBool(m_Finished); - return m_ScValue; + _scValue->SetBool(_finished); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Paused (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Paused") == 0) { - m_ScValue->SetBool(m_Paused); - return m_ScValue; + _scValue->SetBool(_paused); + return _scValue; } else return CBScriptHolder::ScGetProperty(Name); @@ -708,11 +708,11 @@ HRESULT CBSprite::ScSetProperty(char *Name, CScValue *Value) { // CurrentFrame ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "CurrentFrame") == 0) { - m_CurrentFrame = Value->GetInt(0); - if (m_CurrentFrame >= m_Frames.GetSize() || m_CurrentFrame < 0) { - m_CurrentFrame = -1; + _currentFrame = Value->GetInt(0); + if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { + _currentFrame = -1; } - m_LastFrameTime = 0; + _lastFrameTime = 0; return S_OK; } @@ -720,7 +720,7 @@ HRESULT CBSprite::ScSetProperty(char *Name, CScValue *Value) { // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PixelPerfect") == 0) { - m_Precise = Value->GetBool(); + _precise = Value->GetBool(); return S_OK; } @@ -728,7 +728,7 @@ HRESULT CBSprite::ScSetProperty(char *Name, CScValue *Value) { // Looping ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Looping") == 0) { - m_Looping = Value->GetBool(); + _looping = Value->GetBool(); return S_OK; } @@ -744,8 +744,8 @@ char *CBSprite::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSprite::KillAllSounds() { - for (int i = 0; i < m_Frames.GetSize(); i++) { - if (m_Frames[i]->m_Sound) m_Frames[i]->m_Sound->Stop(); + for (int i = 0; i < _frames.GetSize(); i++) { + if (_frames[i]->_sound) _frames[i]->_sound->Stop(); } return S_OK; } diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index dd09fe0be1..973c263e8f 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -41,41 +41,41 @@ class CBSprite: public CBScriptHolder { public: HRESULT KillAllSounds(); CBSurface *GetSurface(); - char *m_EditorBgFile; - int m_EditorBgOffsetX; - int m_EditorBgOffsetY; - int m_EditorBgAlpha; - bool m_Streamed; - bool m_StreamedKeepLoaded; + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; void Cleanup(); void SetDefaults(); - bool m_Precise; + bool _precise; DECLARE_PERSISTENT(CBSprite, CBScriptHolder) - bool m_EditorAllFrames; + bool _editorAllFrames; bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - int m_MoveY; - int m_MoveX; + int _moveY; + int _moveX; HRESULT Display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); - bool m_CanBreak; - bool m_EditorMuted; - bool m_Continuous; + bool _canBreak; + bool _editorMuted; + bool _continuous; void Reset(); - CBObject *m_Owner; - bool m_Changed; - bool m_Paused; - bool m_Finished; + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - uint32 m_LastFrameTime; + uint32 _lastFrameTime; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); - bool m_Looping; - int m_CurrentFrame; + bool _looping; + int _currentFrame; HRESULT AddFrame(char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); CBSprite(CBGame *inGame, CBObject *Owner = NULL); virtual ~CBSprite(); - CBArray m_Frames; + CBArray _frames; HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp index fda4853115..bebed9a38f 100644 --- a/engines/wintermute/BStringTable.cpp +++ b/engines/wintermute/BStringTable.cpp @@ -44,7 +44,7 @@ CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBStringTable::~CBStringTable() { // delete strings - m_Strings.clear(); + _strings.clear(); } @@ -54,17 +54,17 @@ HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDu if (Key == NULL || Val == NULL) return E_FAIL; if (scumm_stricmp(Key, "@right-to-left") == 0) { - Game->m_TextRTL = true; + Game->_textRTL = true; return S_OK; } Common::String final_key = Key; StringUtil::ToLowerCase(final_key); - m_StringsIter = m_Strings.find(final_key); - if (m_StringsIter != m_Strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + _stringsIter = _strings.find(final_key); + if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); - m_Strings[final_key] = Val; + _strings[final_key] = Val; return S_OK; } @@ -83,10 +83,10 @@ char *CBStringTable::GetKey(const char *Str) { char *new_str; - m_StringsIter = m_Strings.find(key); - if (m_StringsIter != m_Strings.end()) { - new_str = new char[m_StringsIter->_value.size() + 1]; - strcpy(new_str, m_StringsIter->_value.c_str()); + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { delete [] key; char *Ret = GetKey(new_str); @@ -103,7 +103,7 @@ char *CBStringTable::GetKey(const char *Str) { ////////////////////////////////////////////////////////////////////////// void CBStringTable::Expand(char **Str, bool ForceExpand) { - if (Game->m_DoNotExpandStrings && !ForceExpand) return; + if (Game->_doNotExpandStrings && !ForceExpand) return; if (Str == NULL || *Str == NULL || *Str[0] != '/') return; @@ -119,10 +119,10 @@ void CBStringTable::Expand(char **Str, bool ForceExpand) { char *new_str; - m_StringsIter = m_Strings.find(key); - if (m_StringsIter != m_Strings.end()) { - new_str = new char[m_StringsIter->_value.size() + 1]; - strcpy(new_str, m_StringsIter->_value.c_str()); + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); } else { new_str = new char[strlen(value) + 1]; strcpy(new_str, value); @@ -138,7 +138,7 @@ void CBStringTable::Expand(char **Str, bool ForceExpand) { ////////////////////////////////////////////////////////////////////////// const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { - if (Game->m_DoNotExpandStrings && !ForceExpand) return String; + if (Game->_doNotExpandStrings && !ForceExpand) return String; if (String == NULL || String[0] == '\0' || String[0] != '/') return String; @@ -154,9 +154,9 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { const char *new_str; - m_StringsIter = m_Strings.find(key); - if (m_StringsIter != m_Strings.end()) { - new_str = m_StringsIter->_value.c_str(); + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); } else { new_str = value; } @@ -172,10 +172,10 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { HRESULT CBStringTable::LoadFile(char *Filename, bool ClearOld) { Game->LOG(0, "Loading string table..."); - if (ClearOld) m_Strings.clear(); + if (ClearOld) _strings.clear(); uint32 Size; - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); if (Buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -185,12 +185,12 @@ HRESULT CBStringTable::LoadFile(char *Filename, bool ClearOld) { if (Size > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { Pos += 3; - if (Game->m_TextEncoding != TEXT_UTF8) { - Game->m_TextEncoding = TEXT_UTF8; - //Game->m_TextEncoding = TEXT_ANSI; + if (Game->_textEncoding != TEXT_UTF8) { + Game->_textEncoding = TEXT_UTF8; + //Game->_textEncoding = TEXT_ANSI; Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); } - } else Game->m_TextEncoding = TEXT_ANSI; + } else Game->_textEncoding = TEXT_ANSI; int LineLength = 0; while (Pos < Size) { @@ -221,7 +221,7 @@ HRESULT CBStringTable::LoadFile(char *Filename, bool ClearOld) { delete [] Buffer; - Game->LOG(0, " %d strings loaded", m_Strings.size()); + Game->LOG(0, " %d strings loaded", _strings.size()); return S_OK; } diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h index 28617c8593..abb455e3f5 100644 --- a/engines/wintermute/BStringTable.h +++ b/engines/wintermute/BStringTable.h @@ -43,10 +43,10 @@ public: HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); - Common::HashMap m_Strings; + Common::HashMap _strings; char *GetKey(const char *Str); private: - Common::HashMap::iterator m_StringsIter; + Common::HashMap::iterator _stringsIter; }; diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index 85f45156a0..d95fb824bd 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -44,33 +44,33 @@ IMPLEMENT_PERSISTENT(CBSubFrame, false) ////////////////////////////////////////////////////////////////////////// CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { - m_Surface = NULL; - m_HotspotX = m_HotspotY = 0; - m_Alpha = 0xFFFFFFFF; - m_Transparent = 0xFFFF00FF; + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; - CBPlatform::SetRectEmpty(&m_Rect); + CBPlatform::SetRectEmpty(&_rect); - m_EditorSelected = false; + _editorSelected = false; - m_SurfaceFilename = NULL; - m_CKDefault = true; - m_CKRed = m_CKBlue = m_CKGreen = 0; - m_LifeTime = -1; - m_KeepLoaded = false; + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; - m_2DOnly = m_3DOnly = false; - m_Decoration = false; + _2DOnly = _3DOnly = false; + _decoration = false; - m_MirrorX = m_MirrorY = false; + _mirrorX = _mirrorY = false; } ////////////////////////////////////////////////////////////////////////// CBSubFrame::~CBSubFrame() { - if (m_Surface) Game->m_SurfaceStorage->RemoveSurface(m_Surface); - delete[] m_SurfaceFilename; - m_SurfaceFilename = NULL; + if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; } @@ -113,12 +113,12 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { RECT rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custom_trans = false; + bool custo_trans = false; CBPlatform::SetRectEmpty(&rect); char *surface_file = NULL; - delete m_Surface; - m_Surface = NULL; + delete _surface; + _surface = NULL; while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { switch (cmd) { @@ -128,7 +128,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custom_trans = true; + custo_trans = true; break; case TOKEN_RECT: @@ -136,27 +136,27 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &m_HotspotX, &m_HotspotY); + parser.ScanStr(params, "%d,%d", &_hotspotX, &_hotspotY); break; case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &m_2DOnly); + parser.ScanStr(params, "%b", &_2DOnly); break; case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &m_3DOnly); + parser.ScanStr(params, "%b", &_3DOnly); break; case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &m_MirrorX); + parser.ScanStr(params, "%b", &_mirrorX); break; case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &m_MirrorY); + parser.ScanStr(params, "%b", &_mirrorY); break; case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &m_Decoration); + parser.ScanStr(params, "%b", &_decoration); break; case TOKEN_ALPHA_COLOR: @@ -168,7 +168,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &m_EditorSelected); + parser.ScanStr(params, "%b", &_editorSelected); break; case TOKEN_EDITOR_PROPERTY: @@ -182,22 +182,22 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { } if (surface_file != NULL) { - if (custom_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + if (custo_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); else SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); } - m_Alpha = DRGBA(ar, ag, ab, alpha); - if (custom_trans) m_Transparent = DRGBA(r, g, b, 0xFF); + _alpha = DRGBA(ar, ag, ab, alpha); + if (custo_trans) _transparent = DRGBA(r, g, b, 0xFF); /* - if(m_Surface == NULL) + if(_surface == NULL) { Game->LOG(0, "Error parsing sub-frame. Image not set."); return E_FAIL; } */ if (CBPlatform::IsRectEmpty(&rect)) SetDefaultRect(); - else m_Rect = rect; + else _rect = rect; return S_OK; } @@ -205,27 +205,27 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { ////////////////////////////////////////////////////////////////////// HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (!m_Surface) return S_OK; + if (!_surface) return S_OK; - if (Register != NULL && !m_Decoration) { + if (Register != NULL && !_decoration) { if (ZoomX == 100 && ZoomY == 100) { - Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, Register, this, X - m_HotspotX + m_Rect.left, Y - m_HotspotY + m_Rect.top, m_Rect.right - m_Rect.left, m_Rect.bottom - m_Rect.top, ZoomX, ZoomY, Precise)); + Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, X - _hotspotX + _rect.left, Y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, ZoomX, ZoomY, Precise)); } else { - Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (m_HotspotX + m_Rect.left) * (ZoomX / 100)), (int)(Y - (m_HotspotY + m_Rect.top) * (ZoomY / 100)), (int)((m_Rect.right - m_Rect.left) * (ZoomX / 100)), (int)((m_Rect.bottom - m_Rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); + Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (_hotspotX + _rect.left) * (ZoomX / 100)), (int)(Y - (_hotspotY + _rect.top) * (ZoomY / 100)), (int)((_rect.right - _rect.left) * (ZoomX / 100)), (int)((_rect.bottom - _rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); } } - if (Game->m_SuspendedRendering) return S_OK; + if (Game->_suspendedRendering) return S_OK; HRESULT res; - //if(Alpha==0xFFFFFFFF) Alpha = m_Alpha; // TODO: better (combine owner's and self alpha) - if (m_Alpha != 0xFFFFFFFF) Alpha = m_Alpha; + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) Alpha = _alpha; if (Rotate != 0.0f) { - res = m_Surface->DisplayTransform((int)(X - m_HotspotX * (ZoomX / 100)), (int)(Y - m_HotspotY * (ZoomY / 100)), m_HotspotX, m_HotspotY, m_Rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, m_MirrorX, m_MirrorY); + res = _surface->DisplayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); } else { - if (ZoomX == 100 && ZoomY == 100) res = m_Surface->DisplayTrans(X - m_HotspotX, Y - m_HotspotY, m_Rect, Alpha, BlendMode, m_MirrorX, m_MirrorY); - else res = m_Surface->DisplayTransZoom((int)(X - m_HotspotX * (ZoomX / 100)), (int)(Y - m_HotspotY * (ZoomY / 100)), m_Rect, ZoomX, ZoomY, Alpha, BlendMode, m_MirrorX, m_MirrorY); + if (ZoomX == 100 && ZoomY == 100) res = _surface->DisplayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); + else res = _surface->DisplayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); } return res; @@ -240,10 +240,10 @@ bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float float RatioY = ScaleY / 100.0f; CBPlatform::SetRect(Rect, - X - m_HotspotX * RatioX, - Y - m_HotspotY * RatioY, - X - m_HotspotX * RatioX + (m_Rect.right - m_Rect.left)*RatioX, - Y - m_HotspotY * RatioY + (m_Rect.bottom - m_Rect.top)*RatioY); + X - _hotspotX * RatioX, + Y - _hotspotY * RatioY, + X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX, + Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY); return true; } @@ -253,43 +253,43 @@ HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { if (Complete) Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); - if (m_Surface && m_Surface->m_Filename != NULL) - Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", m_Surface->m_Filename); + if (_surface && _surface->_filename != NULL) + Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); - if (m_Transparent != 0xFFFF00FF) - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(m_Transparent), D3DCOLGetG(m_Transparent), D3DCOLGetB(m_Transparent)); + if (_transparent != 0xFFFF00FF) + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); RECT rect; CBPlatform::SetRectEmpty(&rect); - if (m_Surface) CBPlatform::SetRect(&rect, 0, 0, m_Surface->GetWidth(), m_Surface->GetHeight()); - if (!CBPlatform::EqualRect(&rect, &m_Rect)) - Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", m_Rect.left, m_Rect.top, m_Rect.right, m_Rect.bottom); + if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + if (!CBPlatform::EqualRect(&rect, &_rect)) + Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); - if (m_HotspotX != 0 || m_HotspotY != 0) - Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", m_HotspotX, m_HotspotY); + if (_hotspotX != 0 || _hotspotY != 0) + Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - if (m_Alpha != 0xFFFFFFFF) { - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_Alpha), D3DCOLGetG(m_Alpha), D3DCOLGetB(m_Alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_Alpha)); + if (_alpha != 0xFFFFFFFF) { + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); } - if (m_MirrorX) - Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", m_MirrorX ? "TRUE" : "FALSE"); + if (_mirrorX) + Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - if (m_MirrorY) - Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", m_MirrorY ? "TRUE" : "FALSE"); + if (_mirrorY) + Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - if (m_2DOnly) - Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", m_2DOnly ? "TRUE" : "FALSE"); + if (_2DOnly) + Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - if (m_3DOnly) - Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", m_3DOnly ? "TRUE" : "FALSE"); + if (_3DOnly) + Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - if (m_Decoration) - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", m_Decoration ? "TRUE" : "FALSE"); + if (_decoration) + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - if (m_EditorSelected) - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE"); + if (_editorSelected) + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); CBBase::SaveAsText(Buffer, Indent + 2); @@ -303,9 +303,9 @@ HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { ////////////////////////////////////////////////////////////////////////// void CBSubFrame::SetDefaultRect() { - if (m_Surface) { - CBPlatform::SetRect(&m_Rect, 0, 0, m_Surface->GetWidth(), m_Surface->GetHeight()); - } else CBPlatform::SetRectEmpty(&m_Rect); + if (_surface) { + CBPlatform::SetRect(&_rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + } else CBPlatform::SetRectEmpty(&_rect); } @@ -314,26 +314,26 @@ HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_2DOnly)); - PersistMgr->Transfer(TMEMBER(m_3DOnly)); - PersistMgr->Transfer(TMEMBER(m_Alpha)); - PersistMgr->Transfer(TMEMBER(m_Decoration)); - PersistMgr->Transfer(TMEMBER(m_EditorSelected)); - PersistMgr->Transfer(TMEMBER(m_HotspotX)); - PersistMgr->Transfer(TMEMBER(m_HotspotY)); - PersistMgr->Transfer(TMEMBER(m_Rect)); - - PersistMgr->Transfer(TMEMBER(m_SurfaceFilename)); - PersistMgr->Transfer(TMEMBER(m_CKDefault)); - PersistMgr->Transfer(TMEMBER(m_CKRed)); - PersistMgr->Transfer(TMEMBER(m_CKGreen)); - PersistMgr->Transfer(TMEMBER(m_CKBlue)); - PersistMgr->Transfer(TMEMBER(m_LifeTime)); - - PersistMgr->Transfer(TMEMBER(m_KeepLoaded)); - PersistMgr->Transfer(TMEMBER(m_MirrorX)); - PersistMgr->Transfer(TMEMBER(m_MirrorY)); - PersistMgr->Transfer(TMEMBER(m_Transparent)); + PersistMgr->Transfer(TMEMBER(_2DOnly)); + PersistMgr->Transfer(TMEMBER(_3DOnly)); + PersistMgr->Transfer(TMEMBER(_alpha)); + PersistMgr->Transfer(TMEMBER(_decoration)); + PersistMgr->Transfer(TMEMBER(_editorSelected)); + PersistMgr->Transfer(TMEMBER(_hotspotX)); + PersistMgr->Transfer(TMEMBER(_hotspotY)); + PersistMgr->Transfer(TMEMBER(_rect)); + + PersistMgr->Transfer(TMEMBER(_surfaceFilename)); + PersistMgr->Transfer(TMEMBER(_cKDefault)); + PersistMgr->Transfer(TMEMBER(_cKRed)); + PersistMgr->Transfer(TMEMBER(_cKGreen)); + PersistMgr->Transfer(TMEMBER(_cKBlue)); + PersistMgr->Transfer(TMEMBER(_lifeTime)); + + PersistMgr->Transfer(TMEMBER(_keepLoaded)); + PersistMgr->Transfer(TMEMBER(_mirrorX)); + PersistMgr->Transfer(TMEMBER(_mirrorY)); + PersistMgr->Transfer(TMEMBER(_transparent)); return S_OK; } @@ -350,8 +350,8 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T if (strcmp(Name, "GetImage") == 0) { Stack->CorrectParams(0); - if (!m_SurfaceFilename) Stack->PushNULL(); - else Stack->PushString(m_SurfaceFilename); + if (!_surfaceFilename) Stack->PushNULL(); + else Stack->PushString(_surfaceFilename); return S_OK; } @@ -363,9 +363,9 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T CScValue *Val = Stack->Pop(); if (Val->IsNULL()) { - if (m_Surface) Game->m_SurfaceStorage->RemoveSurface(m_Surface); - delete[] m_SurfaceFilename; - m_SurfaceFilename = NULL; + if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; Stack->PushBool(true); } else { char *Filename = Val->GetString(); @@ -384,15 +384,15 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T ////////////////////////////////////////////////////////////////////////// CScValue *CBSubFrame::ScGetProperty(char *Name) { - if (!m_ScValue) m_ScValue = new CScValue(Game); - m_ScValue->SetNULL(); + if (!_scValue) _scValue = new CScValue(Game); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("subframe"); - return m_ScValue; + _scValue->SetString("subframe"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -400,72 +400,72 @@ CScValue *CBSubFrame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaColor") == 0) { - m_ScValue->SetInt((int)m_Alpha); - return m_ScValue; + _scValue->SetInt((int)_alpha); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TransparentColor (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TransparentColor") == 0) { - m_ScValue->SetInt((int)m_Transparent); - return m_ScValue; + _scValue->SetInt((int)_transparent); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Is2DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Is2DOnly") == 0) { - m_ScValue->SetBool(m_2DOnly); - return m_ScValue; + _scValue->SetBool(_2DOnly); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Is3DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Is3DOnly") == 0) { - m_ScValue->SetBool(m_3DOnly); - return m_ScValue; + _scValue->SetBool(_3DOnly); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MirrorX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MirrorX") == 0) { - m_ScValue->SetBool(m_MirrorX); - return m_ScValue; + _scValue->SetBool(_mirrorX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MirrorY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MirrorY") == 0) { - m_ScValue->SetBool(m_MirrorY); - return m_ScValue; + _scValue->SetBool(_mirrorY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Decoration") == 0) { - m_ScValue->SetBool(m_Decoration); - return m_ScValue; + _scValue->SetBool(_decoration); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // HotspotX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HotspotX") == 0) { - m_ScValue->SetInt(m_HotspotX); - return m_ScValue; + _scValue->SetInt(_hotspotX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // HotspotY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HotspotY") == 0) { - m_ScValue->SetInt(m_HotspotY); - return m_ScValue; + _scValue->SetInt(_hotspotY); + return _scValue; } else return CBScriptable::ScGetProperty(Name); @@ -478,7 +478,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "AlphaColor") == 0) { - m_Alpha = (uint32)Value->GetInt(); + _alpha = (uint32)Value->GetInt(); return S_OK; } @@ -486,7 +486,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // Is2DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Is2DOnly") == 0) { - m_2DOnly = Value->GetBool(); + _2DOnly = Value->GetBool(); return S_OK; } @@ -494,7 +494,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // Is3DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Is3DOnly") == 0) { - m_3DOnly = Value->GetBool(); + _3DOnly = Value->GetBool(); return S_OK; } @@ -502,7 +502,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // MirrorX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MirrorX") == 0) { - m_MirrorX = Value->GetBool(); + _mirrorX = Value->GetBool(); return S_OK; } @@ -510,7 +510,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // MirrorY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MirrorY") == 0) { - m_MirrorY = Value->GetBool(); + _mirrorY = Value->GetBool(); return S_OK; } @@ -518,7 +518,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Decoration") == 0) { - m_Decoration = Value->GetBool(); + _decoration = Value->GetBool(); return S_OK; } @@ -526,7 +526,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // HotspotX ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HotspotX") == 0) { - m_HotspotX = Value->GetInt(); + _hotspotX = Value->GetInt(); return S_OK; } @@ -534,7 +534,7 @@ HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { // HotspotY ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HotspotY") == 0) { - m_HotspotY = Value->GetInt(); + _hotspotY = Value->GetInt(); return S_OK; } @@ -550,25 +550,25 @@ char *CBSubFrame::ScToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSubFrame::SetSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - if (m_Surface) { - Game->m_SurfaceStorage->RemoveSurface(m_Surface); - m_Surface = NULL; + if (_surface) { + Game->_surfaceStorage->RemoveSurface(_surface); + _surface = NULL; } - delete[] m_SurfaceFilename; - m_SurfaceFilename = NULL; + delete[] _surfaceFilename; + _surfaceFilename = NULL; - m_Surface = Game->m_SurfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - if (m_Surface) { - m_SurfaceFilename = new char[strlen(Filename) + 1]; - strcpy(m_SurfaceFilename, Filename); + _surface = Game->_surfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(Filename) + 1]; + strcpy(_surfaceFilename, Filename); - m_CKDefault = default_ck; - m_CKRed = ck_red; - m_CKGreen = ck_green; - m_CKBlue = ck_blue; - m_LifeTime = LifeTime; - m_KeepLoaded = KeepLoaded; + _cKDefault = default_ck; + _cKRed = ck_red; + _cKGreen = ck_green; + _cKBlue = ck_blue; + _lifeTime = LifeTime; + _keepLoaded = KeepLoaded; return S_OK; } else return E_FAIL; @@ -577,12 +577,12 @@ HRESULT CBSubFrame::SetSurface(char *Filename, bool default_ck, byte ck_red, byt ////////////////////////////////////////////////////////////////////////// HRESULT CBSubFrame::SetSurfaceSimple() { - if (!m_SurfaceFilename) { - m_Surface = NULL; + if (!_surfaceFilename) { + _surface = NULL; return S_OK; } - m_Surface = Game->m_SurfaceStorage->AddSurface(m_SurfaceFilename, m_CKDefault, m_CKRed, m_CKGreen, m_CKBlue, m_LifeTime, m_KeepLoaded); - if (m_Surface) return S_OK; + _surface = Game->_surfaceStorage->AddSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return S_OK; else return E_FAIL; } diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h index 6147b75811..9a8961df1b 100644 --- a/engines/wintermute/BSubFrame.h +++ b/engines/wintermute/BSubFrame.h @@ -38,39 +38,39 @@ class CBObject; class CBSurface; class CBSubFrame : public CBScriptable { public: - bool m_MirrorX; - bool m_MirrorY; - bool m_Decoration; + bool _mirrorX; + bool _mirrorY; + bool _decoration; HRESULT SetSurface(char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); HRESULT SetSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void SetDefaultRect(); - uint32 m_Transparent; + uint32 _transparent; HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); - bool m_EditorSelected; + bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - int m_HotspotX; - int m_HotspotY; - uint32 m_Alpha; - RECT m_Rect; + int _hotspotX; + int _hotspotY; + uint32 _alpha; + RECT _rect; - bool m_CKDefault; - byte m_CKRed; - byte m_CKGreen; - byte m_CKBlue; - int m_LifeTime; - bool m_KeepLoaded; - char *m_SurfaceFilename; + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; - bool m_2DOnly; - bool m_3DOnly; + bool _2DOnly; + bool _3DOnly; - CBSurface *m_Surface; + CBSurface *_surface; // scripting interface virtual CScValue *ScGetProperty(char *Name); diff --git a/engines/wintermute/BSurface.cpp b/engines/wintermute/BSurface.cpp index 16deda3c59..c51652e503 100644 --- a/engines/wintermute/BSurface.cpp +++ b/engines/wintermute/BSurface.cpp @@ -34,28 +34,28 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { - m_ReferenceCount = 0; + _referenceCount = 0; - m_Width = m_Height = 0; + _width = _height = 0; - m_Filename = NULL; + _filename = NULL; - m_PixelOpReady = false; + _pixelOpReady = false; - m_CKDefault = true; - m_CKRed = m_CKGreen = m_CKBlue = 0; - m_LifeTime = 0; - m_KeepLoaded = false; + _cKDefault = true; + _cKRed = _cKGreen = _cKBlue = 0; + _lifeTime = 0; + _keepLoaded = false; - m_LastUsedTime = 0; - m_Valid = false; + _lastUsedTime = 0; + _valid = false; } ////////////////////////////////////////////////////////////////////// CBSurface::~CBSurface() { - if (m_PixelOpReady) EndPixelOp(); - if (m_Filename) delete [] m_Filename; + if (_pixelOpReady) EndPixelOp(); + if (_filename) delete [] _filename; } @@ -168,29 +168,29 @@ HRESULT CBSurface::Invalidate() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurface::PrepareToDraw() { - m_LastUsedTime = Game->m_LiveTimer; + _lastUsedTime = Game->_liveTimer; - if (!m_Valid) { - //Game->LOG(0, "Reviving: %s", m_Filename); - return Create(m_Filename, m_CKDefault, m_CKRed, m_CKGreen, m_CKBlue, m_LifeTime, m_KeepLoaded); + if (!_valid) { + //Game->LOG(0, "Reviving: %s", _filename); + return Create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); } else return S_OK; } ////////////////////////////////////////////////////////////////////////// void CBSurface::SetFilename(const char *Filename) { - delete[] m_Filename; - m_Filename = NULL; + delete[] _filename; + _filename = NULL; if (!Filename) return; - m_Filename = new char[strlen(Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Filename); + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); } ////////////////////////////////////////////////////////////////////////// void CBSurface::SetSize(int Width, int Height) { - m_Width = Width; - m_Height = Height; + _width = Width; + _height = Height; } } // end of namespace WinterMute diff --git a/engines/wintermute/BSurface.h b/engines/wintermute/BSurface.h index 5fa355fcfa..53b9afa541 100644 --- a/engines/wintermute/BSurface.h +++ b/engines/wintermute/BSurface.h @@ -37,17 +37,17 @@ class CBSurface: public CBBase { public: virtual HRESULT Invalidate(); virtual HRESULT PrepareToDraw(); - bool m_CKDefault; - byte m_CKRed; - byte m_CKGreen; - byte m_CKBlue; + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; - uint32 m_LastUsedTime; - bool m_Valid; - int m_LifeTime; - bool m_KeepLoaded; + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + bool _keepLoaded; - bool m_PixelOpReady; + bool _pixelOpReady; CBSurface(CBGame *inGame); virtual ~CBSurface(); @@ -71,20 +71,20 @@ public: void SetFilename(const char *Filename); void SetSize(int Width, int Height); - int m_ReferenceCount; - char *m_Filename; + int _referenceCount; + char *_filename; int GetWidth() { - return m_Width; + return _width; } int GetHeight() { - return m_Height; + return _height; } - //void SetWidth(int Width){ m_Width = Width; } - //void SetHeight(int Height){ m_Height = Height; } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } protected: - int m_Height; - int m_Width; + int _height; + int _width; }; diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index fccea082a5..e52bfb9561 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -44,28 +44,28 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { - m_Texture = NULL; - m_AlphaMask = NULL; + _texture = NULL; + _alphaMask = NULL; - m_LockPixels = NULL; - m_LockPitch = 0; + _lockPixels = NULL; + _lockPitch = 0; } ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::~CBSurfaceSDL() { //TODO #if 0 - if (m_Texture) SDL_DestroyTexture(m_Texture); - delete[] m_AlphaMask; - m_AlphaMask = NULL; + if (_texture) SDL_DestroyTexture(_texture); + delete[] _alphaMask; + _alphaMask = NULL; - Game->AddMem(-m_Width * m_Height * 4); + Game->AddMem(-_width * _height * 4); #endif } ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - CBRenderSDL *renderer = static_cast(Game->m_Renderer); + CBRenderSDL *renderer = static_cast(Game->_renderer); Common::String strFileName(Filename); Graphics::ImageDecoder *imgDecoder; @@ -78,12 +78,12 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); } - CBFile *file = Game->m_FileManager->OpenFile(Filename); + CBFile *file = Game->_fileManager->OpenFile(Filename); if (!file) return E_FAIL; imgDecoder->loadStream(*file->getMemStream()); const Graphics::Surface *surface = imgDecoder->getSurface(); - Game->m_FileManager->CloseFile(file); + Game->_fileManager->CloseFile(file); if (default_ck) { ck_red = 255; @@ -91,8 +91,8 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte ck_blue = 255; } - m_Width = surface->w; - m_Height = surface->h; + _width = surface->w; + _height = surface->h; bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); if (isSaveGameGrayscale) { @@ -124,18 +124,18 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte uint32 bmask = surface->format.bMax() << surface->format.bShift; uint32 amask = surface->format.aMax(); - SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, m_Width, m_Height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); + SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); // no alpha, set color key if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue)); //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //m_Texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); warning("Surface-textures not fully ported yet"); #if 0 - m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!m_Texture) { + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!_texture) { SDL_FreeSurface(surf); delete imgDecoder; return E_FAIL; @@ -146,25 +146,25 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte SDL_FreeSurface(surf); delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. - m_CKDefault = default_ck; - m_CKRed = ck_red; - m_CKGreen = ck_green; - m_CKBlue = ck_blue; + _cKDefault = default_ck; + _cKRed = ck_red; + _cKGreen = ck_green; + _cKBlue = ck_blue; - if (!m_Filename || scumm_stricmp(m_Filename, Filename) != 0) { + if (!_filename || scumm_stricmp(_filename, Filename) != 0) { SetFilename(Filename); } - if (m_LifeTime == 0 || LifeTime == -1 || LifeTime > m_LifeTime) - m_LifeTime = LifeTime; + if (_lifeTime == 0 || LifeTime == -1 || LifeTime > _lifeTime) + _lifeTime = LifeTime; - m_KeepLoaded = KeepLoaded; - if (m_KeepLoaded) m_LifeTime = -1; + _keepLoaded = KeepLoaded; + if (_keepLoaded) _lifeTime = -1; - m_Valid = true; + _valid = true; - Game->AddMem(m_Width * m_Height * 4); + Game->AddMem(_width * _height * 4); #endif return S_OK; @@ -172,8 +172,8 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte ////////////////////////////////////////////////////////////////////////// void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { - delete[] m_AlphaMask; - m_AlphaMask = NULL; + delete[] _alphaMask; + _alphaMask = NULL; if (!surface) return; SDL_LockSurface(surface); @@ -186,7 +186,7 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); } else hasColorKey = false; */ //TODO - m_AlphaMask = new byte[surface->w * surface->h]; + _alphaMask = new byte[surface->w * surface->h]; bool hasTransparency = false; for (int y = 0; y < surface->h; y++) { @@ -199,7 +199,7 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) a = 0; - m_AlphaMask[y * surface->w + x] = a; + _alphaMask[y * surface->w + x] = a; if (a < 255) hasTransparency = true; } } @@ -207,8 +207,8 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { SDL_UnlockSurface(surface); if (!hasTransparency) { - delete[] m_AlphaMask; - m_AlphaMask = NULL; + delete[] _alphaMask; + _alphaMask = NULL; } } @@ -247,15 +247,15 @@ Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) { HRESULT CBSurfaceSDL::Create(int Width, int Height) { warning("SurfaceSDL::Create not ported yet"); //TODO #if 0 - CBRenderSDL *renderer = static_cast(Game->m_Renderer); - m_Texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); + CBRenderSDL *renderer = static_cast(Game->_renderer); + _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); - m_Width = Width; - m_Height = Height; + _width = Width; + _height = Height; - Game->AddMem(m_Width * m_Height * 4); + Game->AddMem(_width * _height * 4); - m_Valid = true; + _valid = true; #endif return S_OK; } @@ -264,15 +264,15 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) { HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 - CBRenderSDL *renderer = static_cast(Game->m_Renderer); - m_Texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); + CBRenderSDL *renderer = static_cast(Game->_renderer); + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); - m_Width = surface->w; - m_Height = surface->h; + _width = surface->w; + _height = surface->h; - Game->AddMem(m_Width * m_Height * 4); + Game->AddMem(_width * _height * 4); - m_Valid = true; + _valid = true; #endif return S_OK; } @@ -282,7 +282,7 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { int access; int width, height; warning("CBSurfaceSDL::IsTransparentAt not ported yet"); - //SDL_QueryTexture(m_Texture, NULL, &access, &width, &height); //TODO + //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -296,21 +296,21 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { - //if (!m_LockPixels) return false; + //if (!_lockPixels) return false; Uint32 format; int access; int width, height; warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); - //SDL_QueryTexture(m_Texture, &format, &access, &width, &height); + //SDL_QueryTexture(_texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - if (!m_AlphaMask) return false; - else return m_AlphaMask[Y * width + X] <= 128; + if (!_alphaMask) return false; + else return _alphaMask[Y * width + X] <= 128; /* - Uint32* dst = (Uint32*)((Uint8*)m_LockPixels + Y * m_LockPitch); + Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); Uint32 pixel = dst[X]; SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); @@ -324,13 +324,13 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::StartPixelOp() { - //SDL_LockTexture(m_Texture, NULL, &m_LockPixels, &m_LockPitch); + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::EndPixelOp() { - //SDL_UnlockTexture(m_Texture); + //SDL_UnlockTexture(_texture); return S_OK; } @@ -370,9 +370,9 @@ HRESULT CBSurfaceSDL::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Re ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - CBRenderSDL *renderer = static_cast(Game->m_Renderer); + CBRenderSDL *renderer = static_cast(Game->_renderer); - if (renderer->m_ForceAlphaColor != 0) Alpha = renderer->m_ForceAlphaColor; + if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; byte r = D3DCOLGetR(Alpha); byte g = D3DCOLGetG(Alpha); @@ -381,13 +381,13 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo warning("CBSurfaceSDL::DrawSprite not ported yet"); // TODO. #if 0 - SDL_SetTextureColorMod(m_Texture, r, g, b); - SDL_SetTextureAlphaMod(m_Texture, a); + SDL_SetTextureColorMod(_texture, r, g, b); + SDL_SetTextureAlphaMod(_texture, a); if (AlphaDisable) - SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_NONE); + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); else - SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_BLEND); + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); SDL_Rect srcRect; srcRect.x = Rect->left; @@ -406,7 +406,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.x += offsetX; position.y += offsetY; - SDL_RenderCopy(renderer->GetSdlRenderer(), m_Texture, &srcRect, &position); + SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif return S_OK; diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index e32bec90b1..ae5fe154f6 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -63,15 +63,15 @@ public: static long DLL_CALLCONV TellProc(fi_handle handle);*/ private: - SDL_Texture *m_Texture; + SDL_Texture *_texture; HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); void GenAlphaMask(SDL_Surface *surface); uint32 GetPixel(SDL_Surface *surface, int x, int y); - void *m_LockPixels; - int m_LockPitch; - byte *m_AlphaMask; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BSurfaceStorage.cpp b/engines/wintermute/BSurfaceStorage.cpp index 45f70db8f6..a460ac83a6 100644 --- a/engines/wintermute/BSurfaceStorage.cpp +++ b/engines/wintermute/BSurfaceStorage.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { - m_LastCleanupTime = 0; + _lastCleanupTime = 0; } @@ -52,11 +52,11 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceStorage::Cleanup(bool Warn) { - for (int i = 0; i < m_Surfaces.GetSize(); i++) { - if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", m_Surfaces[i]->m_Filename, m_Surfaces[i]->m_ReferenceCount); - delete m_Surfaces[i]; + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); + delete _surfaces[i]; } - m_Surfaces.RemoveAll(); + _surfaces.RemoveAll(); return S_OK; } @@ -64,15 +64,15 @@ HRESULT CBSurfaceStorage::Cleanup(bool Warn) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceStorage::InitLoop() { - if (Game->m_SmartCache && Game->m_LiveTimer - m_LastCleanupTime >= Game->m_SurfaceGCCycleTime) { - m_LastCleanupTime = Game->m_LiveTimer; + if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { + _lastCleanupTime = Game->_liveTimer; SortSurfaces(); - for (int i = 0; i < m_Surfaces.GetSize(); i++) { - if (m_Surfaces[i]->m_LifeTime <= 0) break; + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; - if (m_Surfaces[i]->m_LifeTime > 0 && m_Surfaces[i]->m_Valid && Game->m_LiveTimer - m_Surfaces[i]->m_LastUsedTime >= m_Surfaces[i]->m_LifeTime) { - //Game->QuickMessageForm("Invalidating: %s", m_Surfaces[i]->m_Filename); - m_Surfaces[i]->Invalidate(); + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->Invalidate(); } } } @@ -82,12 +82,12 @@ HRESULT CBSurfaceStorage::InitLoop() { ////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { - for (int i = 0; i < m_Surfaces.GetSize(); i++) { - if (m_Surfaces[i] == surface) { - m_Surfaces[i]->m_ReferenceCount--; - if (m_Surfaces[i]->m_ReferenceCount <= 0) { - delete m_Surfaces[i]; - m_Surfaces.RemoveAt(i); + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.RemoveAt(i); } break; } @@ -98,21 +98,21 @@ HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::AddSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - for (int i = 0; i < m_Surfaces.GetSize(); i++) { - if (scumm_stricmp(m_Surfaces[i]->m_Filename, Filename) == 0) { - m_Surfaces[i]->m_ReferenceCount++; - return m_Surfaces[i]; + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; } } - CBFile *File = Game->m_FileManager->OpenFile(Filename); + CBFile *File = Game->_fileManager->OpenFile(Filename); if (!File) { if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); - if (Game->m_DEBUG_DebugMode) + if (Game->_dEBUG_DebugMode) return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - } else Game->m_FileManager->CloseFile(File); + } else Game->_fileManager->CloseFile(File); CBSurface *surface; @@ -125,8 +125,8 @@ CBSurface *CBSurfaceStorage::AddSurface(char *Filename, bool default_ck, byte ck delete surface; return NULL; } else { - surface->m_ReferenceCount = 1; - m_Surfaces.Add(surface); + surface->_referenceCount = 1; + _surfaces.Add(surface); return surface; } } @@ -135,8 +135,8 @@ CBSurface *CBSurfaceStorage::AddSurface(char *Filename, bool default_ck, byte ck ////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceStorage::RestoreAll() { HRESULT ret; - for (int i = 0; i < m_Surfaces.GetSize(); i++) { - ret = m_Surfaces[i]->Restore(); + for (int i = 0; i < _surfaces.GetSize(); i++) { + ret = _surfaces[i]->Restore(); if (ret != S_OK) { Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); return ret; @@ -151,11 +151,11 @@ HRESULT CBSurfaceStorage::RestoreAll() { HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) { - if(!PersistMgr->m_Saving) Cleanup(false); + if(!PersistMgr->_saving) Cleanup(false); PersistMgr->Transfer(TMEMBER(Game)); - //m_Surfaces.Persist(PersistMgr); + //_surfaces.Persist(PersistMgr); return S_OK; } @@ -164,7 +164,7 @@ HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceStorage::SortSurfaces() { - qsort(m_Surfaces.GetData(), m_Surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); + qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); return S_OK; } @@ -175,17 +175,17 @@ int CBSurfaceStorage::SurfaceSortCB(const void *arg1, const void *arg2) { CBSurface *s2 = *((CBSurface **)arg2); // sort by life time - if (s1->m_LifeTime <= 0 && s2->m_LifeTime > 0) return 1; - else if (s1->m_LifeTime > 0 && s2->m_LifeTime <= 0) return -1; + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; // sort by validity - if (s1->m_Valid && !s2->m_Valid) return -1; - else if (!s1->m_Valid && s2->m_Valid) return 1; + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; // sort by time - else if (s1->m_LastUsedTime > s2->m_LastUsedTime) return 1; - else if (s1->m_LastUsedTime < s2->m_LastUsedTime) return -1; + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; else return 0; } diff --git a/engines/wintermute/BSurfaceStorage.h b/engines/wintermute/BSurfaceStorage.h index 5ebfe3c7d7..275c36b4a9 100644 --- a/engines/wintermute/BSurfaceStorage.h +++ b/engines/wintermute/BSurfaceStorage.h @@ -37,7 +37,7 @@ namespace WinterMute { class CBSurface; class CBSurfaceStorage : public CBBase { public: - uint32 m_LastCleanupTime; + uint32 _lastCleanupTime; HRESULT InitLoop(); HRESULT SortSurfaces(); static int SurfaceSortCB(const void *arg1, const void *arg2); @@ -50,7 +50,7 @@ public: CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); - CBArray m_Surfaces; + CBArray _surfaces; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp index 78fd43c545..1d71fb656d 100644 --- a/engines/wintermute/BTransitionMgr.cpp +++ b/engines/wintermute/BTransitionMgr.cpp @@ -35,12 +35,12 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { - m_State = TRANS_MGR_READY; - m_Type = TRANSITION_NONE; - m_OrigInteractive = false; - m_PreserveInteractive = false; - m_LastTime = 0; - m_Started = false; + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; } @@ -53,28 +53,28 @@ CBTransitionMgr::~CBTransitionMgr() { ////////////////////////////////////////////////////////////////////////// bool CBTransitionMgr::IsReady() { - return (m_State == TRANS_MGR_READY); + return (_state == TRANS_MGR_READY); } ////////////////////////////////////////////////////////////////////////// HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { - if (m_State != TRANS_MGR_READY) return S_OK; + if (_state != TRANS_MGR_READY) return S_OK; if (Type == TRANSITION_NONE || Type >= NUM_TRANSITION_TYPES) { - m_State = TRANS_MGR_READY; + _state = TRANS_MGR_READY; return S_OK; } if (NonInteractive) { - m_PreserveInteractive = true; - m_OrigInteractive = Game->m_Interactive; - Game->m_Interactive = false; - } else m_PreserveInteractive; + _preserveInteractive = true; + _origInteractive = Game->_interactive; + Game->_interactive = false; + } else _preserveInteractive; - m_Type = Type; - m_State = TRANS_MGR_RUNNING; - m_Started = false; + _type = Type; + _state = TRANS_MGR_RUNNING; + _started = false; return S_OK; } @@ -85,40 +85,40 @@ HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { HRESULT CBTransitionMgr::Update() { if (IsReady()) return S_OK; - if (!m_Started) { - m_Started = true; - m_LastTime = CBPlatform::GetTime(); + if (!_started) { + _started = true; + _lastTime = CBPlatform::GetTime(); } - switch (m_Type) { + switch (_type) { case TRANSITION_NONE: - m_State = TRANS_MGR_READY; + _state = TRANS_MGR_READY; break; case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::GetTime() - m_LastTime; + uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; Alpha = MIN(255, MAX(Alpha, 0)); - Game->m_Renderer->Fade((WORD)Alpha); + Game->_renderer->Fade((WORD)Alpha); - if (time > FADE_DURATION) m_State = TRANS_MGR_READY; + if (time > FADE_DURATION) _state = TRANS_MGR_READY; } break; case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::GetTime() - m_LastTime; + uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = (float)time / (float)FADE_DURATION * 255; Alpha = MIN(255, MAX(Alpha, 0)); - Game->m_Renderer->Fade((WORD)Alpha); + Game->_renderer->Fade((WORD)Alpha); - if (time > FADE_DURATION) m_State = TRANS_MGR_READY; + if (time > FADE_DURATION) _state = TRANS_MGR_READY; } break; } if (IsReady()) { - if (m_PreserveInteractive) Game->m_Interactive = m_OrigInteractive; + if (_preserveInteractive) Game->_interactive = _origInteractive; } return S_OK; } diff --git a/engines/wintermute/BTransitionMgr.h b/engines/wintermute/BTransitionMgr.h index 6bcf3ea89b..a0d9afebc8 100644 --- a/engines/wintermute/BTransitionMgr.h +++ b/engines/wintermute/BTransitionMgr.h @@ -35,17 +35,17 @@ namespace WinterMute { class CBTransitionMgr : public CBBase { public: - bool m_Started; - uint32 m_LastTime; - bool m_OrigInteractive; - bool m_PreserveInteractive; + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; HRESULT Update(); HRESULT Start(TTransitionType Type, bool NonInteractive = false); bool IsReady(); - TTransMgrState m_State; + TTransMgrState _state; CBTransitionMgr(CBGame *inGame); virtual ~CBTransitionMgr(); - TTransitionType m_Type; + TTransitionType _type; }; diff --git a/engines/wintermute/BViewport.cpp b/engines/wintermute/BViewport.cpp index 57cb1bc02f..718f98c939 100644 --- a/engines/wintermute/BViewport.cpp +++ b/engines/wintermute/BViewport.cpp @@ -36,9 +36,9 @@ IMPLEMENT_PERSISTENT(CBViewport, false) ////////////////////////////////////////////////////////////////////////// CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&m_Rect); - m_MainObject = NULL; - m_OffsetX = m_OffsetY = 0; + CBPlatform::SetRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; } @@ -53,10 +53,10 @@ HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_MainObject)); - PersistMgr->Transfer(TMEMBER(m_OffsetX)); - PersistMgr->Transfer(TMEMBER(m_OffsetY)); - PersistMgr->Transfer(TMEMBER(m_Rect)); + PersistMgr->Transfer(TMEMBER(_mainObject)); + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_rect)); return S_OK; } @@ -67,32 +67,32 @@ HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoChe if (!NoCheck) { left = MAX(left, 0); top = MAX(top, 0); - right = MIN(right, Game->m_Renderer->m_Width); - bottom = MIN(bottom, Game->m_Renderer->m_Height); + right = MIN(right, Game->_renderer->_width); + bottom = MIN(bottom, Game->_renderer->_height); } - CBPlatform::SetRect(&m_Rect, left, top, right, bottom); - m_OffsetX = left; - m_OffsetY = top; + CBPlatform::SetRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; return S_OK; } ////////////////////////////////////////////////////////////////////////// RECT *CBViewport::GetRect() { - return &m_Rect; + return &_rect; } ////////////////////////////////////////////////////////////////////////// int CBViewport::GetWidth() { - return m_Rect.right - m_Rect.left; + return _rect.right - _rect.left; } ////////////////////////////////////////////////////////////////////////// int CBViewport::GetHeight() { - return m_Rect.bottom - m_Rect.top; + return _rect.bottom - _rect.top; } } // end of namespace WinterMute diff --git a/engines/wintermute/BViewport.h b/engines/wintermute/BViewport.h index 06a5a1952f..7c90b568fb 100644 --- a/engines/wintermute/BViewport.h +++ b/engines/wintermute/BViewport.h @@ -41,13 +41,13 @@ public: RECT *GetRect(); HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) - int m_OffsetY; - int m_OffsetX; - CBObject *m_MainObject; + int _offsetY; + int _offsetX; + CBObject *_mainObject; CBViewport(CBGame *inGame = NULL); virtual ~CBViewport(); private: - RECT m_Rect; + RECT _rect; }; } // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index 04c7095dd1..d161c749cf 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -35,7 +35,7 @@ FontGlyphCache::FontGlyphCache() { FontGlyphCache::~FontGlyphCache() { GlyphInfoMap::iterator it; - for (it = m_Glyphs.begin(); it != m_Glyphs.end(); ++it) { + for (it = _glyphs.begin(); it != _glyphs.end(); ++it) { delete it->_value; it->_value = NULL; } @@ -43,7 +43,7 @@ FontGlyphCache::~FontGlyphCache() { ////////////////////////////////////////////////////////////////////////// bool FontGlyphCache::HasGlyph(wchar_t ch) { - return (m_Glyphs.find(ch) != m_Glyphs.end()); + return (_glyphs.find(ch) != _glyphs.end()); } ////////////////////////////////////////////////////////////////////////// @@ -53,8 +53,8 @@ void FontGlyphCache::Initialize() { ////////////////////////////////////////////////////////////////////////// GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { GlyphInfoMap::const_iterator it; - it = m_Glyphs.find(ch); - if (it == m_Glyphs.end()) return NULL; + it = _glyphs.find(ch); + if (it == _glyphs.end()) return NULL; return it->_value; } @@ -63,34 +63,34 @@ GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) { if (stride == 0) stride = width; - m_Glyphs[ch] = new GlyphInfo(glyphIndex); - m_Glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); - m_Glyphs[ch]->SetGlyphImage(width, height, stride, pixels); + _glyphs[ch] = new GlyphInfo(glyphIndex); + _glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); + _glyphs[ch]->SetGlyphImage(width, height, stride, pixels); } ////////////////////////////////////////////////////////////////////////// void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) { - if (m_Image) SDL_FreeSurface(m_Image); + if (_image) SDL_FreeSurface(_image); - m_Image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - SDL_LockSurface(m_Image); + _image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + SDL_LockSurface(_image); - Uint8 *buf = (Uint8 *)m_Image->pixels; + Uint8 *buf = (Uint8 *)_image->pixels; for (int y = 0; y < height; y++) { Uint32 *buf32 = (Uint32 *)buf; for (int x = 0; x < width; x++) { byte alpha = pixels[y * stride + x]; - Uint32 color = SDL_MapRGBA(m_Image->format, 255, 255, 255, alpha); + Uint32 color = SDL_MapRGBA(_image->format, 255, 255, 255, alpha); buf32[x] = color; } - buf += m_Image->pitch; + buf += _image->pitch; } - SDL_UnlockSurface(m_Image); + SDL_UnlockSurface(_image); } } // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index c30e0f92b8..6800ec996b 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -36,65 +36,65 @@ namespace WinterMute { class GlyphInfo { public: GlyphInfo(int glyphIndex) { - m_GlyphIndex = glyphIndex; - m_AdvanceX = m_AdvanceY = 0; - m_BearingX = m_BearingY = 0; + _glyphIndex = glyphIndex; + _advanceX = _advanceY = 0; + _bearingX = _bearingY = 0; - m_Width = m_Height = 0; + _width = _height = 0; - m_Image = NULL; + _image = NULL; } ~GlyphInfo() { - if (m_Image) SDL_FreeSurface(m_Image); + if (_image) SDL_FreeSurface(_image); } void SetGlyphInfo(float AdvanceX, float AdvanceY, int BearingX, int BearingY) { - m_AdvanceX = AdvanceX; - m_AdvanceY = AdvanceY; - m_BearingX = BearingX; - m_BearingY = BearingY; + _advanceX = AdvanceX; + _advanceY = AdvanceY; + _bearingX = BearingX; + _bearingY = BearingY; } void SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels); int GetGlyphIndex() { - return m_GlyphIndex; + return _glyphIndex; } int GetWidth() { - return m_Width; + return _width; } int GetHeight() { - return m_Height; + return _height; } float GetAdvanceX() { - return m_AdvanceX; + return _advanceX; } float GetAdvanceY() { - return m_AdvanceY; + return _advanceY; } int GetBearingX() { - return m_BearingX; + return _bearingX; } int GetBearingY() { - return m_BearingY; + return _bearingY; } SDL_Surface *GetImage() { - return m_Image; + return _image; } private: - int m_GlyphIndex; + int _glyphIndex; - float m_AdvanceX; - float m_AdvanceY; - int m_BearingX; - int m_BearingY; + float _advanceX; + float _advanceY; + int _bearingX; + int _bearingY; - int m_Width; - int m_Height; + int _width; + int _height; - SDL_Surface *m_Image; + SDL_Surface *_image; }; @@ -113,7 +113,7 @@ public: private: //typedef Common::HashMap GlyphInfoMap; typedef Common::HashMap GlyphInfoMap; // TODO - GlyphInfoMap m_Glyphs; + GlyphInfoMap _glyphs; }; } // end of namespace WinterMute diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index 0e8f7ee1b7..6adfd4bbec 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -42,72 +42,72 @@ IMPLEMENT_PERSISTENT(CPartEmitter, false) ////////////////////////////////////////////////////////////////////////// CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - m_Width = m_Height = 0; + _width = _height = 0; - CBPlatform::SetRectEmpty(&m_Border); - m_BorderThicknessLeft = m_BorderThicknessRight = m_BorderThicknessTop = m_BorderThicknessBottom = 0; + CBPlatform::SetRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - m_Angle1 = m_Angle2 = 0; + _angle1 = _angle2 = 0; - m_Velocity1 = m_Velocity2 = 0.0f; - m_VelocityZBased = false; + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; - m_Scale1 = m_Scale2 = 100.0f; - m_ScaleZBased = false; + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; - m_MaxParticles = 100; + _maxParticles = 100; - m_LifeTime1 = m_LifeTime2 = 1000; - m_LifeTimeZBased = false; + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; - m_LastGenTime = 0; - m_GenInterval = 0; - m_GenAmount = 1; + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; - m_OverheadTime = 0; - m_Running = false; + _overheadTime = 0; + _running = false; - m_MaxBatches = 0; - m_BatchesGenerated = 0; + _maxBatches = 0; + _batchesGenerated = 0; - m_FadeInTime = m_FadeOutTime = 0; + _fadeInTime = _fadeOutTime = 0; - m_Alpha1 = m_Alpha2 = 255; - m_AlphaTimeBased = false; + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; - m_Rotation1 = m_Rotation2 = 0.0f; - m_AngVelocity1 = m_AngVelocity2 = 0.0f; + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; - m_GrowthRate1 = m_GrowthRate2 = 0.0f; - m_ExponentialGrowth = false; + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; - m_UseRegion = false; + _useRegion = false; - m_EmitEvent = NULL; - m_Owner = Owner; + _emitEvent = NULL; + _owner = Owner; } ////////////////////////////////////////////////////////////////////////// CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < m_Particles.GetSize(); i++) { - delete m_Particles[i]; + for (int i = 0; i < _particles.GetSize(); i++) { + delete _particles[i]; } - m_Particles.RemoveAll(); + _particles.RemoveAll(); - for (int i = 0; i < m_Forces.GetSize(); i++) { - delete m_Forces[i]; + for (int i = 0; i < _forces.GetSize(); i++) { + delete _forces[i]; } - m_Forces.RemoveAll(); + _forces.RemoveAll(); - for (int i = 0; i < m_Sprites.GetSize(); i++) { - delete [] m_Sprites[i]; + for (int i = 0; i < _sprites.GetSize(); i++) { + delete [] _sprites[i]; } - m_Sprites.RemoveAll(); + _sprites.RemoveAll(); - delete[] m_EmitEvent; - m_EmitEvent = NULL; + delete[] _emitEvent; + _emitEvent = NULL; } ////////////////////////////////////////////////////////////////////////// @@ -115,30 +115,30 @@ HRESULT CPartEmitter::AddSprite(char *Filename) { if (!Filename) return E_FAIL; // do we already have the file? - for (int i = 0; i < m_Sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, m_Sprites[i]) == 0) return S_OK; + for (int i = 0; i < _sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, _sprites[i]) == 0) return S_OK; } // check if file exists - CBFile *File = Game->m_FileManager->OpenFile(Filename); + CBFile *File = Game->_fileManager->OpenFile(Filename); if (!File) { Game->LOG(0, "Sprite '%s' not found", Filename); return E_FAIL; - } else Game->m_FileManager->CloseFile(File); + } else Game->_fileManager->CloseFile(File); char *Str = new char[strlen(Filename) + 1]; strcpy(Str, Filename); - m_Sprites.Add(Str); + _sprites.Add(Str); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::RemoveSprite(char *Filename) { - for (int i = 0; i < m_Sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, m_Sprites[i]) == 0) { - delete [] m_Sprites[i]; - m_Sprites.RemoveAt(i); + for (int i = 0; i < _sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.RemoveAt(i); return S_OK; } } @@ -148,42 +148,42 @@ HRESULT CPartEmitter::RemoveSprite(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { if (!Particle) return E_FAIL; - if (m_Sprites.GetSize() == 0) return E_FAIL; + if (_sprites.GetSize() == 0) return E_FAIL; - int PosX = CBUtils::RandomInt(m_PosX, m_PosX + m_Width); - int PosY = CBUtils::RandomInt(m_PosY, m_PosY + m_Height); + int PosX = CBUtils::RandomInt(_posX, _posX + _width); + int PosY = CBUtils::RandomInt(_posY, _posY + _height); float PosZ = CBUtils::RandomFloat(0.0f, 100.0f); float Velocity; - if (m_VelocityZBased) Velocity = m_Velocity1 + PosZ * (m_Velocity2 - m_Velocity1) / 100; - else Velocity = CBUtils::RandomFloat(m_Velocity1, m_Velocity2); + if (_velocityZBased) Velocity = _velocity1 + PosZ * (_velocity2 - _velocity1) / 100; + else Velocity = CBUtils::RandomFloat(_velocity1, _velocity2); float Scale; - if (m_ScaleZBased) Scale = m_Scale1 + PosZ * (m_Scale2 - m_Scale1) / 100; - else Scale = CBUtils::RandomFloat(m_Scale1, m_Scale2); + if (_scaleZBased) Scale = _scale1 + PosZ * (_scale2 - _scale1) / 100; + else Scale = CBUtils::RandomFloat(_scale1, _scale2); int LifeTime; - if (m_LifeTimeZBased) LifeTime = m_LifeTime2 - PosZ * (m_LifeTime2 - m_LifeTime1) / 100; - else LifeTime = CBUtils::RandomInt(m_LifeTime1, m_LifeTime2); + if (_lifeTimeZBased) LifeTime = _lifeTime2 - PosZ * (_lifeTime2 - _lifeTime1) / 100; + else LifeTime = CBUtils::RandomInt(_lifeTime1, _lifeTime2); - float Angle = CBUtils::RandomAngle(m_Angle1, m_Angle2); - int SpriteIndex = CBUtils::RandomInt(0, m_Sprites.GetSize() - 1); + float Angle = CBUtils::RandomAngle(_angle1, _angle2); + int SpriteIndex = CBUtils::RandomInt(0, _sprites.GetSize() - 1); - float Rotation = CBUtils::RandomAngle(m_Rotation1, m_Rotation2); - float AngVelocity = CBUtils::RandomFloat(m_AngVelocity1, m_AngVelocity2); - float GrowthRate = CBUtils::RandomFloat(m_GrowthRate1, m_GrowthRate2); + float Rotation = CBUtils::RandomAngle(_rotation1, _rotation2); + float AngVelocity = CBUtils::RandomFloat(_angVelocity1, _angVelocity2); + float GrowthRate = CBUtils::RandomFloat(_growthRate1, _growthRate2); - if (!CBPlatform::IsRectEmpty(&m_Border)) { - int ThicknessLeft = m_BorderThicknessLeft - (float)m_BorderThicknessLeft * PosZ / 100.0f; - int ThicknessRight = m_BorderThicknessRight - (float)m_BorderThicknessRight * PosZ / 100.0f; - int ThicknessTop = m_BorderThicknessTop - (float)m_BorderThicknessTop * PosZ / 100.0f; - int ThicknessBottom = m_BorderThicknessBottom - (float)m_BorderThicknessBottom * PosZ / 100.0f; + if (!CBPlatform::IsRectEmpty(&_border)) { + int ThicknessLeft = _borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f; + int ThicknessRight = _borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f; + int ThicknessTop = _borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f; + int ThicknessBottom = _borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f; - Particle->m_Border = m_Border; - Particle->m_Border.left += ThicknessLeft; - Particle->m_Border.right -= ThicknessRight; - Particle->m_Border.top += ThicknessTop; - Particle->m_Border.bottom -= ThicknessBottom; + Particle->_border = _border; + Particle->_border.left += ThicknessLeft; + Particle->_border.right -= ThicknessRight; + Particle->_border.top += ThicknessTop; + Particle->_border.bottom -= ThicknessBottom; } Vector2 VecPos((float)PosX, (float)PosY); @@ -193,76 +193,76 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); MatRot.TransformVector2(VecVel); - if (m_AlphaTimeBased) { - Particle->m_Alpha1 = m_Alpha1; - Particle->m_Alpha2 = m_Alpha2; + if (_alphaTimeBased) { + Particle->_alpha1 = _alpha1; + Particle->_alpha2 = _alpha2; } else { - int Alpha = CBUtils::RandomInt(m_Alpha1, m_Alpha2); - Particle->m_Alpha1 = Alpha; - Particle->m_Alpha2 = Alpha; - } - - Particle->m_CreationTime = CurrentTime; - Particle->m_Pos = VecPos; - Particle->m_PosZ = PosZ; - Particle->m_Velocity = VecVel; - Particle->m_Scale = Scale; - Particle->m_LifeTime = LifeTime; - Particle->m_Rotation = Rotation; - Particle->m_AngVelocity = AngVelocity; - Particle->m_GrowthRate = GrowthRate; - Particle->m_ExponentialGrowth = m_ExponentialGrowth; - Particle->m_IsDead = FAILED(Particle->SetSprite(m_Sprites[SpriteIndex])); - Particle->FadeIn(CurrentTime, m_FadeInTime); - - - if (Particle->m_IsDead) return E_FAIL; + int Alpha = CBUtils::RandomInt(_alpha1, _alpha2); + Particle->_alpha1 = Alpha; + Particle->_alpha2 = Alpha; + } + + Particle->_creationTime = CurrentTime; + Particle->_pos = VecPos; + Particle->_posZ = PosZ; + Particle->_velocity = VecVel; + Particle->_scale = Scale; + Particle->_lifeTime = LifeTime; + Particle->_rotation = Rotation; + Particle->_angVelocity = AngVelocity; + Particle->_growthRate = GrowthRate; + Particle->_exponentialGrowth = _exponentialGrowth; + Particle->_isDead = FAILED(Particle->SetSprite(_sprites[SpriteIndex])); + Particle->FadeIn(CurrentTime, _fadeInTime); + + + if (Particle->_isDead) return E_FAIL; else return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::Update() { - if (!m_Running) return S_OK; - else return UpdateInternal(Game->m_Timer, Game->m_TimerDelta); + if (!_running) return S_OK; + else return UpdateInternal(Game->_timer, Game->_timerDelta); } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { int NumLive = 0; - for (int i = 0; i < m_Particles.GetSize(); i++) { - m_Particles[i]->Update(this, CurrentTime, TimerDelta); + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->Update(this, CurrentTime, TimerDelta); - if (!m_Particles[i]->m_IsDead) NumLive++; + if (!_particles[i]->_isDead) NumLive++; } // we're understaffed - if (NumLive < m_MaxParticles) { + if (NumLive < _maxParticles) { bool NeedsSort = false; - if (CurrentTime - m_LastGenTime > m_GenInterval) { - m_LastGenTime = CurrentTime; - m_BatchesGenerated++; + if (CurrentTime - _lastGenTime > _genInterval) { + _lastGenTime = CurrentTime; + _batchesGenerated++; - if (m_MaxBatches > 0 && m_BatchesGenerated > m_MaxBatches) { + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { return S_OK; } - int ToGen = std::min(m_GenAmount, m_MaxParticles - NumLive); + int ToGen = std::min(_genAmount, _maxParticles - NumLive); while (ToGen > 0) { int FirstDeadIndex = -1; - for (int i = 0; i < m_Particles.GetSize(); i++) { - if (m_Particles[i]->m_IsDead) { + for (int i = 0; i < _particles.GetSize(); i++) { + if (_particles[i]->_isDead) { FirstDeadIndex = i; break; } } CPartParticle *Particle; - if (FirstDeadIndex >= 0) Particle = m_Particles[FirstDeadIndex]; + if (FirstDeadIndex >= 0) Particle = _particles[FirstDeadIndex]; else { Particle = new CPartParticle(Game); - m_Particles.Add(Particle); + _particles.Add(Particle); } InitParticle(Particle, CurrentTime, TimerDelta); NeedsSort = true; @@ -270,12 +270,12 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { ToGen--; } } - if (NeedsSort && (m_ScaleZBased || m_VelocityZBased || m_LifeTimeZBased)) + if (NeedsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) SortParticlesByZ(); // we actually generated some particles and we're not in fast-forward mode - if (NeedsSort && m_OverheadTime == 0) { - if (m_Owner && m_EmitEvent) m_Owner->ApplyEvent(m_EmitEvent); + if (NeedsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->ApplyEvent(_emitEvent); } } @@ -284,40 +284,40 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::Display(CBRegion *Region) { - if (m_Sprites.GetSize() <= 1) Game->m_Renderer->StartSpriteBatch(); + if (_sprites.GetSize() <= 1) Game->_renderer->StartSpriteBatch(); - for (int i = 0; i < m_Particles.GetSize(); i++) { - if (Region != NULL && m_UseRegion) { - if (!Region->PointInRegion(m_Particles[i]->m_Pos.x, m_Particles[i]->m_Pos.y)) continue; + for (int i = 0; i < _particles.GetSize(); i++) { + if (Region != NULL && _useRegion) { + if (!Region->PointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; } - m_Particles[i]->Display(this); + _particles[i]->Display(this); } - if (m_Sprites.GetSize() <= 1) Game->m_Renderer->EndSpriteBatch(); + if (_sprites.GetSize() <= 1) Game->_renderer->EndSpriteBatch(); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::Start() { - for (int i = 0; i < m_Particles.GetSize(); i++) { - m_Particles[i]->m_IsDead = true; + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->_isDead = true; } - m_Running = true; - m_BatchesGenerated = 0; + _running = true; + _batchesGenerated = 0; - if (m_OverheadTime > 0) { + if (_overheadTime > 0) { uint32 Delta = 500; - int Steps = m_OverheadTime / Delta; - uint32 CurrentTime = Game->m_Timer - m_OverheadTime; + int Steps = _overheadTime / Delta; + uint32 CurrentTime = Game->_timer - _overheadTime; for (int i = 0; i < Steps; i++) { UpdateInternal(CurrentTime, Delta); CurrentTime += Delta; } - m_OverheadTime = 0; + _overheadTime = 0; } @@ -326,8 +326,8 @@ HRESULT CPartEmitter::Start() { ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::SortParticlesByZ() { - // sort particles by m_PosY - qsort(m_Particles.GetData(), m_Particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); + // sort particles by _posY + qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); return S_OK; } @@ -336,24 +336,24 @@ int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { CPartParticle *P1 = *(CPartParticle **)Obj1; CPartParticle *P2 = *(CPartParticle **)Obj2; - if (P1->m_PosZ < P2->m_PosZ) return -1; - else if (P1->m_PosZ > P2->m_PosZ) return 1; + if (P1->_posZ < P2->_posZ) return -1; + else if (P1->_posZ > P2->_posZ) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::SetBorder(int X, int Y, int Width, int Height) { - CBPlatform::SetRect(&m_Border, X, Y, X + Width, Y + Height); + CBPlatform::SetRect(&_border, X, Y, X + Width, Y + Height); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { - m_BorderThicknessLeft = ThicknessLeft; - m_BorderThicknessRight = ThicknessRight; - m_BorderThicknessTop = ThicknessTop; - m_BorderThicknessBottom = ThicknessBottom; + _borderThicknessLeft = ThicknessLeft; + _borderThicknessRight = ThicknessRight; + _borderThicknessTop = ThicknessTop; + _borderThicknessBottom = ThicknessBottom; return S_OK; } @@ -362,9 +362,9 @@ HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, CPartForce *CPartEmitter::AddForceByName(char *Name) { CPartForce *Force = NULL; - for (int i = 0; i < m_Forces.GetSize(); i++) { - if (scumm_stricmp(Name, m_Forces[i]->m_Name) == 0) { - Force = m_Forces[i]; + for (int i = 0; i < _forces.GetSize(); i++) { + if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + Force = _forces[i]; break; } } @@ -372,7 +372,7 @@ CPartForce *CPartEmitter::AddForceByName(char *Name) { Force = new CPartForce(Game); if (Force) { Force->SetName(Name); - m_Forces.Add(Force); + _forces.Add(Force); } } return Force; @@ -384,23 +384,23 @@ HRESULT CPartEmitter::AddForce(char *Name, CPartForce::TForceType Type, int PosX CPartForce *Force = AddForceByName(Name); if (!Force) return E_FAIL; - Force->m_Type = Type; - Force->m_Pos = Vector2(PosX, PosY); + Force->_type = Type; + Force->_pos = Vector2(PosX, PosY); - Force->m_Direction = Vector2(0, Strength); + Force->_direction = Vector2(0, Strength); Matrix4 MatRot; MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); - MatRot.TransformVector2(Force->m_Direction); + MatRot.TransformVector2(Force->_direction); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::RemoveForce(char *Name) { - for (int i = 0; i < m_Forces.GetSize(); i++) { - if (scumm_stricmp(Name, m_Forces[i]->m_Name) == 0) { - delete m_Forces[i]; - m_Forces.RemoveAt(i); + for (int i = 0; i < _forces.GetSize(); i++) { + if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.RemoveAt(i); return S_OK; } } @@ -466,7 +466,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Start") == 0) { Stack->CorrectParams(1); - m_OverheadTime = Stack->Pop()->GetInt(); + _overheadTime = Stack->Pop()->GetInt(); Stack->PushBool(SUCCEEDED(Start())); return S_OK; @@ -478,12 +478,12 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "Stop") == 0) { Stack->CorrectParams(0); - for (int i = 0; i < m_Particles.GetSize(); i++) { - delete m_Particles[i]; + for (int i = 0; i < _particles.GetSize(); i++) { + delete _particles[i]; } - m_Particles.RemoveAll(); + _particles.RemoveAll(); - m_Running = false; + _running = false; Stack->PushBool(true); return S_OK; @@ -494,7 +494,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Pause") == 0) { Stack->CorrectParams(0); - m_Running = false; + _running = false; Stack->PushBool(true); return S_OK; @@ -505,7 +505,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Resume") == 0) { Stack->CorrectParams(0); - m_Running = true; + _running = true; Stack->PushBool(true); return S_OK; @@ -558,270 +558,270 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CPartEmitter::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("particle-emitter"); - return m_ScValue; + _scValue->SetString("particle-emitter"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "X") == 0) { - m_ScValue->SetInt(m_PosX); - return m_ScValue; + _scValue->SetInt(_posX); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Y") == 0) { - m_ScValue->SetInt(m_PosY); - return m_ScValue; + _scValue->SetInt(_posY); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_ScValue->SetInt(m_Width); - return m_ScValue; + _scValue->SetInt(_width); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_ScValue->SetInt(m_Height); - return m_ScValue; + _scValue->SetInt(_height); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale1") == 0) { - m_ScValue->SetFloat(m_Scale1); - return m_ScValue; + _scValue->SetFloat(_scale1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale2") == 0) { - m_ScValue->SetFloat(m_Scale2); - return m_ScValue; + _scValue->SetFloat(_scale2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleZBased") == 0) { - m_ScValue->SetBool(m_ScaleZBased); - return m_ScValue; + _scValue->SetBool(_scaleZBased); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Velocity1") == 0) { - m_ScValue->SetFloat(m_Velocity1); - return m_ScValue; + _scValue->SetFloat(_velocity1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Velocity2") == 0) { - m_ScValue->SetFloat(m_Velocity2); - return m_ScValue; + _scValue->SetFloat(_velocity2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "VelocityZBased") == 0) { - m_ScValue->SetBool(m_VelocityZBased); - return m_ScValue; + _scValue->SetBool(_velocityZBased); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTime1") == 0) { - m_ScValue->SetInt(m_LifeTime1); - return m_ScValue; + _scValue->SetInt(_lifeTime1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTime2") == 0) { - m_ScValue->SetInt(m_LifeTime2); - return m_ScValue; + _scValue->SetInt(_lifeTime2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTimeZBased") == 0) { - m_ScValue->SetBool(m_LifeTimeZBased); - return m_ScValue; + _scValue->SetBool(_lifeTimeZBased); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Angle1") == 0) { - m_ScValue->SetInt(m_Angle1); - return m_ScValue; + _scValue->SetInt(_angle1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Angle2") == 0) { - m_ScValue->SetInt(m_Angle2); - return m_ScValue; + _scValue->SetInt(_angle2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AngVelocity1") == 0) { - m_ScValue->SetFloat(m_AngVelocity1); - return m_ScValue; + _scValue->SetFloat(_angVelocity1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AngVelocity2") == 0) { - m_ScValue->SetFloat(m_AngVelocity2); - return m_ScValue; + _scValue->SetFloat(_angVelocity2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotation1") == 0) { - m_ScValue->SetFloat(m_Rotation1); - return m_ScValue; + _scValue->SetFloat(_rotation1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotation2") == 0) { - m_ScValue->SetFloat(m_Rotation2); - return m_ScValue; + _scValue->SetFloat(_rotation2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Alpha1") == 0) { - m_ScValue->SetInt(m_Alpha1); - return m_ScValue; + _scValue->SetInt(_alpha1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Alpha2") == 0) { - m_ScValue->SetInt(m_Alpha2); - return m_ScValue; + _scValue->SetInt(_alpha2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaTimeBased") == 0) { - m_ScValue->SetBool(m_AlphaTimeBased); - return m_ScValue; + _scValue->SetBool(_alphaTimeBased); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxParticles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxParticles") == 0) { - m_ScValue->SetInt(m_MaxParticles); - return m_ScValue; + _scValue->SetInt(_maxParticles); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumLiveParticles (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumLiveParticles") == 0) { int NumAlive = 0; - for (int i = 0; i < m_Particles.GetSize(); i++) { - if (m_Particles[i] && !m_Particles[i]->m_IsDead) NumAlive++; + for (int i = 0; i < _particles.GetSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) NumAlive++; } - m_ScValue->SetInt(NumAlive); - return m_ScValue; + _scValue->SetInt(NumAlive); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationInterval ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GenerationInterval") == 0) { - m_ScValue->SetInt(m_GenInterval); - return m_ScValue; + _scValue->SetInt(_genInterval); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GenerationAmount") == 0) { - m_ScValue->SetInt(m_GenAmount); - return m_ScValue; + _scValue->SetInt(_genAmount); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxBatches") == 0) { - m_ScValue->SetInt(m_MaxBatches); - return m_ScValue; + _scValue->SetInt(_maxBatches); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeInTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeInTime") == 0) { - m_ScValue->SetInt(m_FadeInTime); - return m_ScValue; + _scValue->SetInt(_fadeInTime); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeOutTime") == 0) { - m_ScValue->SetInt(m_FadeOutTime); - return m_ScValue; + _scValue->SetInt(_fadeOutTime); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GrowthRate1") == 0) { - m_ScValue->SetFloat(m_GrowthRate1); - return m_ScValue; + _scValue->SetFloat(_growthRate1); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GrowthRate2") == 0) { - m_ScValue->SetFloat(m_GrowthRate2); - return m_ScValue; + _scValue->SetFloat(_growthRate2); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ExponentialGrowth") == 0) { - m_ScValue->SetBool(m_ExponentialGrowth); - return m_ScValue; + _scValue->SetBool(_exponentialGrowth); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // UseRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "UseRegion") == 0) { - m_ScValue->SetBool(m_UseRegion); - return m_ScValue; + _scValue->SetBool(_useRegion); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "EmitEvent") == 0) { - if (!m_EmitEvent) m_ScValue->SetNULL(); - else m_ScValue->SetString(m_EmitEvent); - return m_ScValue; + if (!_emitEvent) _scValue->SetNULL(); + else _scValue->SetString(_emitEvent); + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -834,28 +834,28 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // X ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "X") == 0) { - m_PosX = Value->GetInt(); + _posX = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Y") == 0) { - m_PosY = Value->GetInt(); + _posY = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_Width = Value->GetInt(); + _width = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_Height = Value->GetInt(); + _height = Value->GetInt(); return S_OK; } @@ -863,21 +863,21 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // Scale1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale1") == 0) { - m_Scale1 = Value->GetFloat(); + _scale1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Scale2") == 0) { - m_Scale2 = Value->GetFloat(); + _scale2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScaleZBased") == 0) { - m_ScaleZBased = Value->GetBool(); + _scaleZBased = Value->GetBool(); return S_OK; } @@ -885,21 +885,21 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // Velocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Velocity1") == 0) { - m_Velocity1 = Value->GetFloat(); + _velocity1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Velocity2") == 0) { - m_Velocity2 = Value->GetFloat(); + _velocity2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "VelocityZBased") == 0) { - m_VelocityZBased = Value->GetBool(); + _velocityZBased = Value->GetBool(); return S_OK; } @@ -907,21 +907,21 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // LifeTime1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTime1") == 0) { - m_LifeTime1 = Value->GetInt(); + _lifeTime1 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTime2") == 0) { - m_LifeTime2 = Value->GetInt(); + _lifeTime2 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LifeTimeZBased") == 0) { - m_LifeTimeZBased = Value->GetBool(); + _lifeTimeZBased = Value->GetBool(); return S_OK; } @@ -929,14 +929,14 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // Angle1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Angle1") == 0) { - m_Angle1 = Value->GetInt(); + _angle1 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Angle2") == 0) { - m_Angle2 = Value->GetInt(); + _angle2 = Value->GetInt(); return S_OK; } @@ -944,14 +944,14 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // AngVelocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AngVelocity1") == 0) { - m_AngVelocity1 = Value->GetFloat(); + _angVelocity1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AngVelocity2") == 0) { - m_AngVelocity2 = Value->GetFloat(); + _angVelocity2 = Value->GetFloat(); return S_OK; } @@ -959,14 +959,14 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // Rotation1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotation1") == 0) { - m_Rotation1 = Value->GetFloat(); + _rotation1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Rotation2") == 0) { - m_Rotation2 = Value->GetFloat(); + _rotation2 = Value->GetFloat(); return S_OK; } @@ -974,25 +974,25 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // Alpha1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Alpha1") == 0) { - m_Alpha1 = Value->GetInt(); - if (m_Alpha1 < 0) m_Alpha1 = 0; - if (m_Alpha1 > 255) m_Alpha1 = 255; + _alpha1 = Value->GetInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; return S_OK; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Alpha2") == 0) { - m_Alpha2 = Value->GetInt(); - if (m_Alpha2 < 0) m_Alpha2 = 0; - if (m_Alpha2 > 255) m_Alpha2 = 255; + _alpha2 = Value->GetInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; return S_OK; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AlphaTimeBased") == 0) { - m_AlphaTimeBased = Value->GetBool(); + _alphaTimeBased = Value->GetBool(); return S_OK; } @@ -1000,7 +1000,7 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // MaxParticles ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxParticles") == 0) { - m_MaxParticles = Value->GetInt(); + _maxParticles = Value->GetInt(); return S_OK; } @@ -1008,21 +1008,21 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // GenerationInterval ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GenerationInterval") == 0) { - m_GenInterval = Value->GetInt(); + _genInterval = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GenerationAmount") == 0) { - m_GenAmount = Value->GetInt(); + _genAmount = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxBatches") == 0) { - m_MaxBatches = Value->GetInt(); + _maxBatches = Value->GetInt(); return S_OK; } @@ -1030,14 +1030,14 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // FadeInTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeInTime") == 0) { - m_FadeInTime = Value->GetInt(); + _fadeInTime = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeOutTime") == 0) { - m_FadeOutTime = Value->GetInt(); + _fadeOutTime = Value->GetInt(); return S_OK; } @@ -1045,21 +1045,21 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // GrowthRate1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GrowthRate1") == 0) { - m_GrowthRate1 = Value->GetFloat(); + _growthRate1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GrowthRate2") == 0) { - m_GrowthRate2 = Value->GetFloat(); + _growthRate2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ExponentialGrowth") == 0) { - m_ExponentialGrowth = Value->GetBool(); + _exponentialGrowth = Value->GetBool(); return S_OK; } @@ -1067,7 +1067,7 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // UseRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "UseRegion") == 0) { - m_UseRegion = Value->GetBool(); + _useRegion = Value->GetBool(); return S_OK; } @@ -1075,8 +1075,8 @@ HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "EmitEvent") == 0) { - SAFE_DELETE_ARRAY(m_EmitEvent); - if (!Value->IsNULL()) CBUtils::SetString(&m_EmitEvent, Value->GetString()); + SAFE_DELETE_ARRAY(_emitEvent); + if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); return S_OK; } @@ -1096,95 +1096,95 @@ char *CPartEmitter::ScToString() { HRESULT CPartEmitter::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Width)); - PersistMgr->Transfer(TMEMBER(m_Height)); + PersistMgr->Transfer(TMEMBER(_width)); + PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(m_Angle1)); - PersistMgr->Transfer(TMEMBER(m_Angle2)); + PersistMgr->Transfer(TMEMBER(_angle1)); + PersistMgr->Transfer(TMEMBER(_angle2)); - PersistMgr->Transfer(TMEMBER(m_Velocity1)); - PersistMgr->Transfer(TMEMBER(m_Velocity2)); - PersistMgr->Transfer(TMEMBER(m_VelocityZBased)); + PersistMgr->Transfer(TMEMBER(_velocity1)); + PersistMgr->Transfer(TMEMBER(_velocity2)); + PersistMgr->Transfer(TMEMBER(_velocityZBased)); - PersistMgr->Transfer(TMEMBER(m_Scale1)); - PersistMgr->Transfer(TMEMBER(m_Scale2)); - PersistMgr->Transfer(TMEMBER(m_ScaleZBased)); + PersistMgr->Transfer(TMEMBER(_scale1)); + PersistMgr->Transfer(TMEMBER(_scale2)); + PersistMgr->Transfer(TMEMBER(_scaleZBased)); - PersistMgr->Transfer(TMEMBER(m_MaxParticles)); + PersistMgr->Transfer(TMEMBER(_maxParticles)); - PersistMgr->Transfer(TMEMBER(m_LifeTime1)); - PersistMgr->Transfer(TMEMBER(m_LifeTime2)); - PersistMgr->Transfer(TMEMBER(m_LifeTimeZBased)); + PersistMgr->Transfer(TMEMBER(_lifeTime1)); + PersistMgr->Transfer(TMEMBER(_lifeTime2)); + PersistMgr->Transfer(TMEMBER(_lifeTimeZBased)); - PersistMgr->Transfer(TMEMBER(m_GenInterval)); - PersistMgr->Transfer(TMEMBER(m_GenAmount)); + PersistMgr->Transfer(TMEMBER(_genInterval)); + PersistMgr->Transfer(TMEMBER(_genAmount)); - PersistMgr->Transfer(TMEMBER(m_Running)); - PersistMgr->Transfer(TMEMBER(m_OverheadTime)); + PersistMgr->Transfer(TMEMBER(_running)); + PersistMgr->Transfer(TMEMBER(_overheadTime)); - PersistMgr->Transfer(TMEMBER(m_Border)); - PersistMgr->Transfer(TMEMBER(m_BorderThicknessLeft)); - PersistMgr->Transfer(TMEMBER(m_BorderThicknessRight)); - PersistMgr->Transfer(TMEMBER(m_BorderThicknessTop)); - PersistMgr->Transfer(TMEMBER(m_BorderThicknessBottom)); + PersistMgr->Transfer(TMEMBER(_border)); + PersistMgr->Transfer(TMEMBER(_borderThicknessLeft)); + PersistMgr->Transfer(TMEMBER(_borderThicknessRight)); + PersistMgr->Transfer(TMEMBER(_borderThicknessTop)); + PersistMgr->Transfer(TMEMBER(_borderThicknessBottom)); - PersistMgr->Transfer(TMEMBER(m_FadeInTime)); - PersistMgr->Transfer(TMEMBER(m_FadeOutTime)); + PersistMgr->Transfer(TMEMBER(_fadeInTime)); + PersistMgr->Transfer(TMEMBER(_fadeOutTime)); - PersistMgr->Transfer(TMEMBER(m_Alpha1)); - PersistMgr->Transfer(TMEMBER(m_Alpha2)); - PersistMgr->Transfer(TMEMBER(m_AlphaTimeBased)); + PersistMgr->Transfer(TMEMBER(_alpha1)); + PersistMgr->Transfer(TMEMBER(_alpha2)); + PersistMgr->Transfer(TMEMBER(_alphaTimeBased)); - PersistMgr->Transfer(TMEMBER(m_AngVelocity1)); - PersistMgr->Transfer(TMEMBER(m_AngVelocity2)); + PersistMgr->Transfer(TMEMBER(_angVelocity1)); + PersistMgr->Transfer(TMEMBER(_angVelocity2)); - PersistMgr->Transfer(TMEMBER(m_Rotation1)); - PersistMgr->Transfer(TMEMBER(m_Rotation2)); + PersistMgr->Transfer(TMEMBER(_rotation1)); + PersistMgr->Transfer(TMEMBER(_rotation2)); - PersistMgr->Transfer(TMEMBER(m_GrowthRate1)); - PersistMgr->Transfer(TMEMBER(m_GrowthRate2)); - PersistMgr->Transfer(TMEMBER(m_ExponentialGrowth)); + PersistMgr->Transfer(TMEMBER(_growthRate1)); + PersistMgr->Transfer(TMEMBER(_growthRate2)); + PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); - PersistMgr->Transfer(TMEMBER(m_UseRegion)); + PersistMgr->Transfer(TMEMBER(_useRegion)); - PersistMgr->Transfer(TMEMBER_INT(m_MaxBatches)); - PersistMgr->Transfer(TMEMBER_INT(m_BatchesGenerated)); + PersistMgr->Transfer(TMEMBER_INT(_maxBatches)); + PersistMgr->Transfer(TMEMBER_INT(_batchesGenerated)); - PersistMgr->Transfer(TMEMBER(m_EmitEvent)); - PersistMgr->Transfer(TMEMBER(m_Owner)); + PersistMgr->Transfer(TMEMBER(_emitEvent)); + PersistMgr->Transfer(TMEMBER(_owner)); - m_Sprites.Persist(PersistMgr); + _sprites.Persist(PersistMgr); int NumForces; - if (PersistMgr->m_Saving) { - NumForces = m_Forces.GetSize(); + if (PersistMgr->_saving) { + NumForces = _forces.GetSize(); PersistMgr->Transfer(TMEMBER(NumForces)); - for (int i = 0; i < m_Forces.GetSize(); i++) { - m_Forces[i]->Persist(PersistMgr); + for (int i = 0; i < _forces.GetSize(); i++) { + _forces[i]->Persist(PersistMgr); } } else { PersistMgr->Transfer(TMEMBER(NumForces)); for (int i = 0; i < NumForces; i++) { CPartForce *Force = new CPartForce(Game); Force->Persist(PersistMgr); - m_Forces.Add(Force); + _forces.Add(Force); } } int NumParticles; - if (PersistMgr->m_Saving) { - NumParticles = m_Particles.GetSize(); + if (PersistMgr->_saving) { + NumParticles = _particles.GetSize(); PersistMgr->Transfer(TMEMBER(NumParticles)); - for (int i = 0; i < m_Particles.GetSize(); i++) { - m_Particles[i]->Persist(PersistMgr); + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->Persist(PersistMgr); } } else { PersistMgr->Transfer(TMEMBER(NumParticles)); for (int i = 0; i < NumParticles; i++) { CPartParticle *Particle = new CPartParticle(Game); Particle->Persist(PersistMgr); - m_Particles.Add(Particle); + _particles.Add(Particle); } } diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h index d23b4db488..16257153bc 100644 --- a/engines/wintermute/PartEmitter.h +++ b/engines/wintermute/PartEmitter.h @@ -41,62 +41,62 @@ public: CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); virtual ~CPartEmitter(void); - int m_Width; - int m_Height; + int _width; + int _height; - int m_Angle1; - int m_Angle2; + int _angle1; + int _angle2; - float m_Rotation1; - float m_Rotation2; + float _rotation1; + float _rotation2; - float m_AngVelocity1; - float m_AngVelocity2; + float _angVelocity1; + float _angVelocity2; - float m_GrowthRate1; - float m_GrowthRate2; - bool m_ExponentialGrowth; + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; - float m_Velocity1; - float m_Velocity2; - bool m_VelocityZBased; + float _velocity1; + float _velocity2; + bool _velocityZBased; - float m_Scale1; - float m_Scale2; - bool m_ScaleZBased; + float _scale1; + float _scale2; + bool _scaleZBased; - int m_MaxParticles; + int _maxParticles; - int m_LifeTime1; - int m_LifeTime2; - bool m_LifeTimeZBased; + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; - int m_GenInterval; - int m_GenAmount; + int _genInterval; + int _genAmount; - bool m_Running; - int m_OverheadTime; + bool _running; + int _overheadTime; - int m_MaxBatches; - int m_BatchesGenerated; + int _maxBatches; + int _batchesGenerated; - RECT m_Border; - int m_BorderThicknessLeft; - int m_BorderThicknessRight; - int m_BorderThicknessTop; - int m_BorderThicknessBottom; + RECT _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; - int m_FadeInTime; - int m_FadeOutTime; + int _fadeInTime; + int _fadeOutTime; - int m_Alpha1; - int m_Alpha2; - bool m_AlphaTimeBased; + int _alpha1; + int _alpha2; + bool _alphaTimeBased; - bool m_UseRegion; + bool _useRegion; - char *m_EmitEvent; - CBScriptHolder *m_Owner; + char *_emitEvent; + CBScriptHolder *_owner; HRESULT Start(); @@ -112,7 +112,7 @@ public: HRESULT AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); HRESULT RemoveForce(char *Name); - CBArray m_Forces; + CBArray _forces; // scripting interface virtual CScValue *ScGetProperty(char *Name); @@ -126,9 +126,9 @@ private: int static CompareZ(const void *Obj1, const void *Obj2); HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); - uint32 m_LastGenTime; - CBArray m_Particles; - CBArray m_Sprites; + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; }; } // end of namespace WinterMute diff --git a/engines/wintermute/PartForce.cpp b/engines/wintermute/PartForce.cpp index 06f5902ab6..874ffdda1f 100644 --- a/engines/wintermute/PartForce.cpp +++ b/engines/wintermute/PartForce.cpp @@ -32,9 +32,9 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - m_Pos = Vector2(0.0f, 0.0f); - m_Direction = Vector2(0.0f, 0.0f); - m_Type = FORCE_POINT; + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; } @@ -45,10 +45,10 @@ CPartForce::~CPartForce(void) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartForce::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_Name)); - PersistMgr->Transfer(TMEMBER(m_Pos)); - PersistMgr->Transfer(TMEMBER(m_Direction)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_direction)); + PersistMgr->Transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/PartForce.h b/engines/wintermute/PartForce.h index 140174eb4f..6245b438db 100644 --- a/engines/wintermute/PartForce.h +++ b/engines/wintermute/PartForce.h @@ -42,9 +42,9 @@ public: CPartForce(CBGame *inGame); virtual ~CPartForce(void); - Vector2 m_Pos; - Vector2 m_Direction; - TForceType m_Type; + Vector2 _pos; + Vector2 _direction; + TForceType _type; HRESULT Persist(CBPersistMgr *PersistMgr); }; diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp index d1a892645b..cc59e20c17 100644 --- a/engines/wintermute/PartParticle.cpp +++ b/engines/wintermute/PartParticle.cpp @@ -37,56 +37,56 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - m_Pos = Vector2(0.0f, 0.0f); - m_PosZ = 0.0f; - m_Velocity = Vector2(0.0f, 0.0f); - m_Scale = 100.0f; - m_Sprite = NULL; - m_CreationTime = 0; - m_LifeTime = 0; - m_IsDead = true; - CBPlatform::SetRectEmpty(&m_Border); - - m_State = PARTICLE_NORMAL; - m_FadeStart = 0; - m_FadeTime = 0; - m_CurrentAlpha = 255; - - m_Alpha1 = m_Alpha2 = 255; - - m_Rotation = 0.0f; - m_AngVelocity = 0.0f; - - m_GrowthRate = 0.0f; - m_ExponentialGrowth = false; + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::SetRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; } ////////////////////////////////////////////////////////////////////////// CPartParticle::~CPartParticle(void) { - delete m_Sprite; - m_Sprite = NULL; + delete _sprite; + _sprite = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::SetSprite(char *Filename) { - if (m_Sprite && m_Sprite->m_Filename && scumm_stricmp(Filename, m_Sprite->m_Filename) == 0) { - m_Sprite->Reset(); + if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { + _sprite->Reset(); return S_OK; } - delete m_Sprite; - m_Sprite = NULL; + delete _sprite; + _sprite = NULL; - CSysClassRegistry::GetInstance()->m_Disabled = true; - m_Sprite = new CBSprite(Game, Game); - if (m_Sprite && SUCCEEDED(m_Sprite->LoadFile(Filename))) { - CSysClassRegistry::GetInstance()->m_Disabled = false; + CSysClassRegistry::GetInstance()->_disabled = true; + _sprite = new CBSprite(Game, Game); + if (_sprite && SUCCEEDED(_sprite->LoadFile(Filename))) { + CSysClassRegistry::GetInstance()->_disabled = false; return S_OK; } else { - delete m_Sprite; - m_Sprite = NULL; - CSysClassRegistry::GetInstance()->m_Disabled = false; + delete _sprite; + _sprite = NULL; + CSysClassRegistry::GetInstance()->_disabled = false; return E_FAIL; } @@ -94,82 +94,82 @@ HRESULT CPartParticle::SetSprite(char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { - if (m_State == PARTICLE_FADEIN) { - if (CurrentTime - m_FadeStart >= m_FadeTime) { - m_State = PARTICLE_NORMAL; - m_CurrentAlpha = m_Alpha1; - } else m_CurrentAlpha = ((float)CurrentTime - (float)m_FadeStart) / (float)m_FadeTime * m_Alpha1; + if (_state == PARTICLE_FADEIN) { + if (CurrentTime - _fadeStart >= _fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; return S_OK; - } else if (m_State == PARTICLE_FADEOUT) { - if (CurrentTime - m_FadeStart >= m_FadeTime) { - m_IsDead = true; + } else if (_state == PARTICLE_FADEOUT) { + if (CurrentTime - _fadeStart >= _fadeTime) { + _isDead = true; return S_OK; - } else m_CurrentAlpha = m_FadeStartAlpha - ((float)CurrentTime - (float)m_FadeStart) / (float)m_FadeTime * m_FadeStartAlpha; + } else _currentAlpha = _fadeStartAlpha - ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; return S_OK; } else { // time is up - if (m_LifeTime > 0) { - if (CurrentTime - m_CreationTime >= m_LifeTime) { - if (Emitter->m_FadeOutTime > 0) - FadeOut(CurrentTime, Emitter->m_FadeOutTime); + if (_lifeTime > 0) { + if (CurrentTime - _creationTime >= _lifeTime) { + if (Emitter->_fadeOutTime > 0) + FadeOut(CurrentTime, Emitter->_fadeOutTime); else - m_IsDead = true; + _isDead = true; } } // particle hit the border - if (!m_IsDead && !CBPlatform::IsRectEmpty(&m_Border)) { + if (!_isDead && !CBPlatform::IsRectEmpty(&_border)) { POINT p; - p.x = m_Pos.x; - p.y = m_Pos.y; - if (!CBPlatform::PtInRect(&m_Border, p)) FadeOut(CurrentTime, Emitter->m_FadeOutTime); + p.x = _pos.x; + p.y = _pos.y; + if (!CBPlatform::PtInRect(&_border, p)) FadeOut(CurrentTime, Emitter->_fadeOutTime); } - if (m_State != PARTICLE_NORMAL) return S_OK; + if (_state != PARTICLE_NORMAL) return S_OK; // update alpha - if (m_LifeTime > 0) { - int Age = CurrentTime - m_CreationTime; - int AlphaDelta = m_Alpha2 - m_Alpha1; + if (_lifeTime > 0) { + int Age = CurrentTime - _creationTime; + int AlphaDelta = _alpha2 - _alpha1; - m_CurrentAlpha = m_Alpha1 + ((float)AlphaDelta / (float)m_LifeTime * (float)Age); + _currentAlpha = _alpha1 + ((float)AlphaDelta / (float)_lifeTime * (float)Age); } // update position float ElapsedTime = (float)TimerDelta / 1000.f; - for (int i = 0; i < Emitter->m_Forces.GetSize(); i++) { - CPartForce *Force = Emitter->m_Forces[i]; - switch (Force->m_Type) { + for (int i = 0; i < Emitter->_forces.GetSize(); i++) { + CPartForce *Force = Emitter->_forces[i]; + switch (Force->_type) { case CPartForce::FORCE_GLOBAL: - m_Velocity += Force->m_Direction * ElapsedTime; + _velocity += Force->_direction * ElapsedTime; break; case CPartForce::FORCE_POINT: { - Vector2 VecDist = Force->m_Pos - m_Pos; + Vector2 VecDist = Force->_pos - _pos; float Dist = fabs(VecDist.Length()); Dist = 100.0f / Dist; - m_Velocity += Force->m_Direction * Dist * ElapsedTime; + _velocity += Force->_direction * Dist * ElapsedTime; } break; } } - m_Pos += m_Velocity * ElapsedTime; + _pos += _velocity * ElapsedTime; // update rotation - m_Rotation += m_AngVelocity * ElapsedTime; - m_Rotation = CBUtils::NormalizeAngle(m_Rotation); + _rotation += _angVelocity * ElapsedTime; + _rotation = CBUtils::NormalizeAngle(_rotation); // update scale - if (m_ExponentialGrowth) - m_Scale += m_Scale / 100.0f * m_GrowthRate * ElapsedTime; + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * ElapsedTime; else - m_Scale += m_GrowthRate * ElapsedTime; + _scale += _growthRate * ElapsedTime; - if (m_Scale <= 0.0f) m_IsDead = true; + if (_scale <= 0.0f) _isDead = true; return S_OK; @@ -178,70 +178,70 @@ HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::Display(CPartEmitter *Emitter) { - if (!m_Sprite) return E_FAIL; - if (m_IsDead) return S_OK; + if (!_sprite) return E_FAIL; + if (_isDead) return S_OK; - m_Sprite->GetCurrentFrame(); - return m_Sprite->Display(m_Pos.x, m_Pos.y, + _sprite->GetCurrentFrame(); + return _sprite->Display(_pos.x, _pos.y, NULL, - m_Scale, m_Scale, - DRGBA(255, 255, 255, m_CurrentAlpha), - m_Rotation, - Emitter->m_BlendMode); + _scale, _scale, + DRGBA(255, 255, 255, _currentAlpha), + _rotation, + Emitter->_blendMode); } ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { - m_CurrentAlpha = 0; - m_FadeStart = CurrentTime; - m_FadeTime = FadeTime; - m_State = PARTICLE_FADEIN; + _currentAlpha = 0; + _fadeStart = CurrentTime; + _fadeTime = FadeTime; + _state = PARTICLE_FADEIN; return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { - //m_CurrentAlpha = 255; - m_FadeStartAlpha = m_CurrentAlpha; - m_FadeStart = CurrentTime; - m_FadeTime = FadeTime; - m_State = PARTICLE_FADEOUT; + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = CurrentTime; + _fadeTime = FadeTime; + _state = PARTICLE_FADEOUT; return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_Alpha1)); - PersistMgr->Transfer(TMEMBER(m_Alpha2)); - PersistMgr->Transfer(TMEMBER(m_Border)); - PersistMgr->Transfer(TMEMBER(m_Pos)); - PersistMgr->Transfer(TMEMBER(m_PosZ)); - PersistMgr->Transfer(TMEMBER(m_Velocity)); - PersistMgr->Transfer(TMEMBER(m_Scale)); - PersistMgr->Transfer(TMEMBER(m_CreationTime)); - PersistMgr->Transfer(TMEMBER(m_LifeTime)); - PersistMgr->Transfer(TMEMBER(m_IsDead)); - PersistMgr->Transfer(TMEMBER_INT(m_State)); - PersistMgr->Transfer(TMEMBER(m_FadeStart)); - PersistMgr->Transfer(TMEMBER(m_FadeTime)); - PersistMgr->Transfer(TMEMBER(m_CurrentAlpha)); - PersistMgr->Transfer(TMEMBER(m_AngVelocity)); - PersistMgr->Transfer(TMEMBER(m_Rotation)); - PersistMgr->Transfer(TMEMBER(m_GrowthRate)); - PersistMgr->Transfer(TMEMBER(m_ExponentialGrowth)); - PersistMgr->Transfer(TMEMBER(m_FadeStartAlpha)); - - if (PersistMgr->m_Saving) { - PersistMgr->Transfer(TMEMBER(m_Sprite->m_Filename)); + PersistMgr->Transfer(TMEMBER(_alpha1)); + PersistMgr->Transfer(TMEMBER(_alpha2)); + PersistMgr->Transfer(TMEMBER(_border)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_posZ)); + PersistMgr->Transfer(TMEMBER(_velocity)); + PersistMgr->Transfer(TMEMBER(_scale)); + PersistMgr->Transfer(TMEMBER(_creationTime)); + PersistMgr->Transfer(TMEMBER(_lifeTime)); + PersistMgr->Transfer(TMEMBER(_isDead)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_fadeStart)); + PersistMgr->Transfer(TMEMBER(_fadeTime)); + PersistMgr->Transfer(TMEMBER(_currentAlpha)); + PersistMgr->Transfer(TMEMBER(_angVelocity)); + PersistMgr->Transfer(TMEMBER(_rotation)); + PersistMgr->Transfer(TMEMBER(_growthRate)); + PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); + PersistMgr->Transfer(TMEMBER(_fadeStartAlpha)); + + if (PersistMgr->_saving) { + PersistMgr->Transfer(TMEMBER(_sprite->_filename)); } else { char *Filename; PersistMgr->Transfer(TMEMBER(Filename)); - CSysClassRegistry::GetInstance()->m_Disabled = true; + CSysClassRegistry::GetInstance()->_disabled = true; SetSprite(Filename); - CSysClassRegistry::GetInstance()->m_Disabled = false; + CSysClassRegistry::GetInstance()->_disabled = false; delete[] Filename; Filename = NULL; } diff --git a/engines/wintermute/PartParticle.h b/engines/wintermute/PartParticle.h index eec3862b72..9de4248d6d 100644 --- a/engines/wintermute/PartParticle.h +++ b/engines/wintermute/PartParticle.h @@ -45,25 +45,25 @@ public: CPartParticle(CBGame *inGame); virtual ~CPartParticle(void); - float m_GrowthRate; - bool m_ExponentialGrowth; - - float m_Rotation; - float m_AngVelocity; - - int m_Alpha1; - int m_Alpha2; - - RECT m_Border; - Vector2 m_Pos; - float m_PosZ; - Vector2 m_Velocity; - float m_Scale; - CBSprite *m_Sprite; - uint32 m_CreationTime; - int m_LifeTime; - bool m_IsDead; - TParticleState m_State; + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + RECT _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); HRESULT Display(CPartEmitter *Emitter); @@ -75,10 +75,10 @@ public: HRESULT Persist(CBPersistMgr *PersistMgr); private: - uint32 m_FadeStart; - int m_FadeTime; - int m_CurrentAlpha; - int m_FadeStartAlpha; + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; }; } // end of namespace WinterMute diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 1b55c1ca35..f1a295b443 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -78,7 +78,7 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { // set ini name sprintf(param, "./%s", IniName); - Game->m_Registry->SetIniName(param); + Game->_registry->SetIniName(param); delete [] IniDir; delete [] IniName; @@ -87,16 +87,16 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { } - if (Game->m_Registry->ReadBool("Debug", "DebugMode")) Game->DEBUG_DebugEnable("./wme.log"); + if (Game->_registry->ReadBool("Debug", "DebugMode")) Game->DEBUG_DebugEnable("./wme.log"); - Game->m_DEBUG_ShowFPS = Game->m_Registry->ReadBool("Debug", "ShowFPS"); + Game->_dEBUG_ShowFPS = Game->_registry->ReadBool("Debug", "ShowFPS"); - if (Game->m_Registry->ReadBool("Debug", "DisableSmartCache")) { + if (Game->_registry->ReadBool("Debug", "DisableSmartCache")) { Game->LOG(0, "Smart cache is DISABLED"); - Game->m_SmartCache = false; + Game->_smartCache = false; } - bool AllowDirectDraw = Game->m_Registry->ReadBool("Debug", "AllowDirectDraw", false); + bool AllowDirectDraw = Game->_registry->ReadBool("Debug", "AllowDirectDraw", false); // load general game settings Game->Initialize1(); @@ -116,14 +116,14 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { Game->Initialize2(); Game->GetDebugMgr()->OnGameInit(); - Game->m_ScEngine->LoadBreakpoints(); + Game->_scEngine->LoadBreakpoints(); HRESULT ret; // initialize the renderer - ret = Game->m_Renderer->InitRenderer(Game->m_SettingsResWidth, Game->m_SettingsResHeight, windowedMode); + ret = Game->_renderer->InitRenderer(Game->_settingsResWidth, Game->_settingsResHeight, windowedMode); if (FAILED(ret)) { Game->LOG(ret, "Error initializing renderer. Exiting."); @@ -139,7 +139,7 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { #endif // initialize sound manager (non-fatal if we fail) - ret = Game->m_SoundMgr->Initialize(); + ret = Game->_soundMgr->Initialize(); if (FAILED(ret)) { Game->LOG(ret, "Sound is NOT available."); } @@ -148,15 +148,15 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { // load game uint32 DataInitStart = GetTime(); - if (FAILED(Game->LoadFile(Game->m_SettingsGameFile ? Game->m_SettingsGameFile : "default.game"))) { + if (FAILED(Game->LoadFile(Game->_settingsGameFile ? Game->_settingsGameFile : "default.game"))) { Game->LOG(ret, "Error loading game file. Exiting."); delete Game; Game = NULL; return false; } Game->SetWindowTitle(); - Game->m_Renderer->m_Ready = true; - Game->m_MiniUpdateEnabled = true; + Game->_renderer->_ready = true; + Game->_miniUpdateEnabled = true; Game->LOG(0, "Engine initialized in %d ms", GetTime() - DataInitStart); Game->LOG(0, ""); @@ -182,7 +182,7 @@ int CBPlatform::MessageLoop() { HandleEvent(&event); } - if (Game && Game->m_Renderer->m_Active && Game->m_Renderer->m_Ready) { + if (Game && Game->_renderer->_active && Game->_renderer->_ready) { Game->DisplayContent(); Game->DisplayQuickMsg(); @@ -190,27 +190,27 @@ int CBPlatform::MessageLoop() { Game->DisplayDebugInfo(); // ***** flip - if (!Game->m_SuspendedRendering) Game->m_Renderer->Flip(); - if (Game->m_Loading) Game->LoadGame(Game->m_ScheduledLoadSlot); + if (!Game->_suspendedRendering) Game->_renderer->Flip(); + if (Game->_loading) Game->LoadGame(Game->_scheduledLoadSlot); } - if (Game->m_Quitting) break; + if (Game->_quitting) break; } if (Game) { // remember previous window position /* - if(Game->m_Renderer && Game->m_Renderer->m_Windowed) + if(Game->_renderer && Game->_renderer->_windowed) { - if(!::IsIconic(Game->m_Renderer->m_Window)) + if(!::IsIconic(Game->_renderer->_window)) { - int PosX = Game->m_Renderer->m_WindowRect.left; - int PosY = Game->m_Renderer->m_WindowRect.top; - PosX -= Game->m_Renderer->m_MonitorRect.left; - PosY -= Game->m_Renderer->m_MonitorRect.top; + int PosX = Game->_renderer->_windowRect.left; + int PosY = Game->_renderer->_windowRect.top; + PosX -= Game->_renderer->_monitorRect.left; + PosY -= Game->_renderer->_monitorRect.top; - Game->m_Registry->WriteInt("Video", "WindowPosX", PosX); - Game->m_Registry->WriteInt("Video", "WindowPosY", PosY); + Game->_registry->WriteInt("Video", "WindowPosX", PosX); + Game->_registry->WriteInt("Video", "WindowPosY", PosY); } } */ @@ -229,14 +229,14 @@ void CBPlatform::HandleEvent(SDL_Event *event) { #ifdef __IPHONEOS__ { - CBRenderSDL *renderer = static_cast(Game->m_Renderer); + CBRenderSDL *renderer = static_cast(Game->_renderer); POINT p; GetCursorPos(&p); Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - if (Game->m_ActiveObject != NULL && strcmp(Game->m_ActiveObject->GetClassName(), "CUIButton") == 0) { - CUIButton *btn = static_cast(Game->m_ActiveObject); - if (btn->m_Visible && !btn->m_Disable) btn->m_Press = true; + if (Game->_activeObject != NULL && strcmp(Game->_activeObject->GetClassName(), "CUIButton") == 0) { + CUIButton *btn = static_cast(Game->_activeObject); + if (btn->_visible && !btn->_disable) btn->_press = true; } } #endif @@ -307,7 +307,7 @@ void CBPlatform::HandleEvent(SDL_Event *event) { #ifdef __IPHONEOS__ if (Game) { Game->AutoSaveOnExit(); - Game->m_Quitting = true; + Game->_quitting = true; } #else if (Game) Game->OnWindowClose(); @@ -357,7 +357,7 @@ uint32 CBPlatform::GetTime() { ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { - CBRenderSDL *renderer = static_cast(Game->m_Renderer); + CBRenderSDL *renderer = static_cast(Game->_renderer); int x, y; SDL_GetMouseState(&x, &y); @@ -371,7 +371,7 @@ BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::SetCursorPos(int X, int Y) { - CBRenderSDL *renderer = static_cast(Game->m_Renderer); + CBRenderSDL *renderer = static_cast(Game->_renderer); POINT p; p.x = X; diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp index ebde28cdb1..b20c3f934a 100644 --- a/engines/wintermute/SysClass.cpp +++ b/engines/wintermute/SysClass.cpp @@ -39,14 +39,14 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { - m_Name = name; + _name = name; - m_Build = build; - m_Load = load; - m_Next = NULL; - m_SavedID = -1; - m_Persistent = persistent_class; - m_NumInst = 0; + _build = build; + _load = load; + _next = NULL; + _savedID = -1; + _persistent = persistent_class; + _numInst = 0; CSysClassRegistry::GetInstance()->RegisterClass(this); } @@ -61,11 +61,11 @@ CSysClass::~CSysClass() { ////////////////////////////////////////////////////////////////////////// bool CSysClass::RemoveAllInstances() { InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { delete(it->_value); } - //m_Instances.clear(); - m_InstanceMap.clear(); + //_instances.clear(); + _instanceMap.clear(); return true; } @@ -74,9 +74,9 @@ bool CSysClass::RemoveAllInstances() { CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { CSysInstance *inst = new CSysInstance(instance, id, this); inst->SetSavedID(savedId); - //m_Instances.insert(inst); + //_instances.insert(inst); - m_InstanceMap[instance] = inst; + _instanceMap[instance] = inst; CSysClassRegistry::GetInstance()->AddInstanceToTable(inst, instance); @@ -86,25 +86,25 @@ CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { ////////////////////////////////////////////////////////////////////////// bool CSysClass::RemoveInstance(void *instance) { - InstanceMap::iterator mapIt = m_InstanceMap.find(instance); - if (mapIt == m_InstanceMap.end()) return false; + InstanceMap::iterator mapIt = _instanceMap.find(instance); + if (mapIt == _instanceMap.end()) return false; /* - Instances::iterator it = m_Instances.find((*mapIt).second); - if (it != m_Instances.end()) { + Instances::iterator it = _instances.find((*mapIt).second); + if (it != _instances.end()) { delete(*it); - m_Instances.erase(it); + _instances.erase(it); }*/ delete mapIt->_value; - m_InstanceMap.erase(mapIt); + _instanceMap.erase(mapIt); return false; } ////////////////////////////////////////////////////////////////////////// int CSysClass::GetInstanceID(void *pointer) { - InstanceMap::iterator mapIt = m_InstanceMap.find(pointer); - if (mapIt == m_InstanceMap.end()) return -1; + InstanceMap::iterator mapIt = _instanceMap.find(pointer); + if (mapIt == _instanceMap.end()) return -1; else return (*mapIt)._value->GetID(); } @@ -112,11 +112,11 @@ int CSysClass::GetInstanceID(void *pointer) { void *CSysClass::IDToPointer(int savedID) { //slow /*Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + for (it = _instances.begin(); it != _instances.end(); ++it) { if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); }*/ InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); } return NULL; @@ -124,56 +124,56 @@ void *CSysClass::IDToPointer(int savedID) { ////////////////////////////////////////////////////////////////////////// int CSysClass::GetNumInstances() { - //return m_Instances.size(); - return m_InstanceMap.size(); // TODO: This might break, if we have multiple keys per value. + //return _instances.size(); + return _instanceMap.size(); // TODO: This might break, if we have multiple keys per value. } ////////////////////////////////////////////////////////////////////////// void CSysClass::Dump(void *stream) { - fprintf((FILE*)stream, "%03d %c %-20s instances: %d\n", m_ID, m_Persistent ? 'p' : ' ', m_Name.c_str(), GetNumInstances()); + fprintf((FILE*)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); } ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { - PersistMgr->PutString(m_Name.c_str()); - PersistMgr->PutDWORD(m_ID); - PersistMgr->PutDWORD(m_InstanceMap.size()); + PersistMgr->PutString(_name.c_str()); + PersistMgr->PutDWORD(_iD); + PersistMgr->PutDWORD(_instanceMap.size()); InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { PersistMgr->PutDWORD((it->_value)->GetID()); } /* Instances::iterator it; - for (it = m_Instances.begin(); it != m_Instances.end(); ++it) { + for (it = _instances.begin(); it != _instances.end(); ++it) { PersistMgr->PutDWORD((*it)->GetID()); }*/ } ////////////////////////////////////////////////////////////////////////// void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - m_SavedID = PersistMgr->GetDWORD(); + _savedID = PersistMgr->GetDWORD(); int numInstances = PersistMgr->GetDWORD(); for (int i = 0; i < numInstances; i++) { - if (m_Persistent) { + if (_persistent) { int instId = PersistMgr->GetDWORD(); if (i > 0) { - Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", m_Name.c_str(), numInstances); + Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); continue; } - InstanceMap::iterator it = m_InstanceMap.begin(); -/* Instances::iterator it = m_Instances.begin();*/ - if (it != m_InstanceMap.end()) { + InstanceMap::iterator it = _instanceMap.begin(); +/* Instances::iterator it = _instances.begin();*/ + if (it != _instanceMap.end()) { (it->_value)->SetSavedID(instId); CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); - } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, m_Name.c_str()); + } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); } // normal instances, create empty objects else { - void *emptyObject = m_Build(); + void *emptyObject = _build(); AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); } @@ -183,25 +183,25 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { // write instace header - PersistMgr->PutDWORD(m_ID); + PersistMgr->PutDWORD(_iD); PersistMgr->PutDWORD((it->_value)->GetID()); - m_Load((it->_value)->GetInstance(), PersistMgr); + _load((it->_value)->GetInstance(), PersistMgr); } } ////////////////////////////////////////////////////////////////////////// void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { - m_Load(instance, PersistMgr); + _load(instance, PersistMgr); } ////////////////////////////////////////////////////////////////////////// void CSysClass::ResetSavedIDs() { InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { (it->_value)->SetSavedID(-1); } } @@ -209,7 +209,7 @@ void CSysClass::ResetSavedIDs() { ////////////////////////////////////////////////////////////////////////// void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { InstanceMap::iterator it; - for (it = m_InstanceMap.begin(); it != m_InstanceMap.end(); ++it) { + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { lpCallback((it->_value)->GetInstance(), lpData); } } diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index bcd63cc5e4..ca9ffe0082 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -63,22 +63,22 @@ public: void *IDToPointer(int savedID); void SetID(int id) { - m_ID = id; + _iD = id; } int GetID() const { - return m_ID; + return _iD; } int GetSavedID() const { - return m_SavedID; + return _savedID; } bool IsPersistent() const { - return m_Persistent; + return _persistent; } AnsiString GetName() const { - return m_Name; + return _name; } void SaveTable(CBGame *Game, CBPersistMgr *PersistMgr); @@ -94,20 +94,20 @@ public: void Dump(void *stream); private: - int m_NumInst; - bool m_Persistent; - CSysClass *m_Next; - int m_ID; - int m_SavedID; - AnsiString m_Name; - PERSISTBUILD m_Build; - PERSISTLOAD m_Load; + int _numInst; + bool _persistent; + CSysClass *_next; + int _iD; + int _savedID; + AnsiString _name; + PERSISTBUILD _build; + PERSISTLOAD _load; //typedef std::set Instances; - //Instances m_Instances; + //Instances _instances; typedef Common::HashMap InstanceMap; - InstanceMap m_InstanceMap; + InstanceMap _instanceMap; }; } // end of namespace WinterMute diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp index 1170921768..64dfa6a988 100644 --- a/engines/wintermute/SysClassRegistry.cpp +++ b/engines/wintermute/SysClassRegistry.cpp @@ -52,12 +52,12 @@ CSysClassRegistry *CSysClassRegistry::GetInstance() { ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { - classObj->SetID(m_Count++); - //m_Classes.insert(classObj); - m_Classes[classObj] = classObj; + classObj->SetID(_count++); + //_classes.insert(classObj); + _classes[classObj] = classObj; - m_NameMap[classObj->GetName()] = classObj; - m_IdMap[classObj->GetID()] = classObj; + _nameMap[classObj->GetName()] = classObj; + _idMap[classObj->GetID()] = classObj; return true; } @@ -66,21 +66,21 @@ bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { - Classes::iterator it = m_Classes.find(classObj); - if (it == m_Classes.end()) return false; + Classes::iterator it = _classes.find(classObj); + if (it == _classes.end()) return false; if (classObj->GetNumInstances() != 0) { char str[MAX_PATH]; sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->GetName().c_str(), classObj->GetNumInstances()); CBPlatform::OutputDebugString(str); } - m_Classes.erase(it); + _classes.erase(it); - NameMap::iterator mapIt = m_NameMap.find(classObj->GetName()); - if (mapIt != m_NameMap.end()) m_NameMap.erase(mapIt); + NameMap::iterator mapIt = _nameMap.find(classObj->GetName()); + if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); - IdMap::iterator idIt = m_IdMap.find(classObj->GetID()); - if (idIt != m_IdMap.end()) m_IdMap.erase(idIt); + IdMap::iterator idIt = _idMap.find(classObj->GetID()); + if (idIt != _idMap.end()) _idMap.erase(idIt); return true; @@ -89,37 +89,37 @@ bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) { - if (m_Disabled) return true; + if (_disabled) return true; - NameMap::iterator mapIt = m_NameMap.find(className); - if (mapIt == m_NameMap.end()) return false; + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; - CSysInstance *inst = (*mapIt)._value->AddInstance(instance, m_Count++); + CSysInstance *inst = (*mapIt)._value->AddInstance(instance, _count++); return (inst != NULL); } ////////////////////////////////////////////////////////////////////////// void CSysClassRegistry::AddInstanceToTable(CSysInstance *instance, void *pointer) { - m_InstanceMap[pointer] = instance; + _instanceMap[pointer] = instance; if (instance->GetSavedID() >= 0) - m_SavedInstanceMap[instance->GetSavedID()] = instance; + _savedInstanceMap[instance->GetSavedID()] = instance; } ////////////////////////////////////////////////////////////////////////// int CSysClassRegistry::GetNextID() { - return m_Count++; + return _count++; } ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { - NameMap::iterator mapIt = m_NameMap.find(className); - if (mapIt == m_NameMap.end()) return false; + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; (*mapIt)._value->RemoveInstance(instance); - InstanceMap::iterator instIt = m_InstanceMap.find(instance); - if (instIt != m_InstanceMap.end()) { - m_InstanceMap.erase(instIt); + InstanceMap::iterator instIt = _instanceMap.find(instance); + if (instIt != _instanceMap.end()) { + _instanceMap.erase(instIt); return true; } else return false; } @@ -129,8 +129,8 @@ bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceID) { if (pointer == NULL) return true; - InstanceMap::iterator it = m_InstanceMap.find(pointer); - if (it == m_InstanceMap.end()) return false; + InstanceMap::iterator it = _instanceMap.find(pointer); + if (it == _instanceMap.end()) return false; CSysInstance *inst = (*it)._value; @@ -142,26 +142,26 @@ bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceI ////////////////////////////////////////////////////////////////////////// void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { - SavedInstanceMap::iterator it = m_SavedInstanceMap.find(instanceID); - if (it == m_SavedInstanceMap.end()) return NULL; + SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); + if (it == _savedInstanceMap.end()) return NULL; else return (*it)._value->GetInstance(); } ////////////////////////////////////////////////////////////////////////// HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { - PersistMgr->PutDWORD(m_Classes.size()); + PersistMgr->PutDWORD(_classes.size()); int counter = 0; Classes::iterator it; - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { counter++; if (!quickSave) { - Game->m_IndicatorProgress = 50.0f / (float)((float)m_Classes.size() / (float)counter); + Game->_indicatorProgress = 50.0f / (float)((float)_classes.size() / (float)counter); Game->DisplayContent(false); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); } (it->_value)->SaveTable(Game, PersistMgr); @@ -176,28 +176,28 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { Classes::iterator it; // reset SavedID of current instances - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { (it->_value)->ResetSavedIDs(); } - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { if ((it->_value)->IsPersistent()) continue; (it->_value)->RemoveAllInstances(); } - m_InstanceMap.clear(); + _instanceMap.clear(); int numClasses = PersistMgr->GetDWORD(); for (int i = 0; i < numClasses; i++) { - Game->m_IndicatorProgress = 50.0f / (float)((float)numClasses / (float)i); + Game->_indicatorProgress = 50.0f / (float)((float)numClasses / (float)i); Game->DisplayContentSimple(); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); char *className = PersistMgr->GetString(); - NameMap::iterator mapIt = m_NameMap.find(className); - if (mapIt != m_NameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); } return S_OK; @@ -211,21 +211,21 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, // count total instances int numInstances = 0; - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { numInstances += (it->_value)->GetNumInstances(); } PersistMgr->PutDWORD(numInstances); int counter = 0; - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { counter++; if (!quickSave) { if (counter % 20 == 0) { - Game->m_IndicatorProgress = 50 + 50.0f / (float)((float)m_Classes.size() / (float)counter); + Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); Game->DisplayContent(false); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); } } Game->MiniUpdate(); @@ -244,9 +244,9 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { - Game->m_IndicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); + Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); Game->DisplayContentSimple(); - Game->m_Renderer->Flip(); + Game->_renderer->Flip(); } int classID = PersistMgr->GetDWORD(); @@ -255,14 +255,14 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) Classes::iterator it; - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) { + for (it = _classes.begin(); it != _classes.end(); ++it) { if ((it->_value)->GetSavedID() == classID) { (it->_value)->LoadInstance(instance, PersistMgr); } } } - m_SavedInstanceMap.clear(); + _savedInstanceMap.clear(); return S_OK; } @@ -270,8 +270,8 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) ////////////////////////////////////////////////////////////////////////// HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { - NameMap::iterator mapIt = m_NameMap.find(className); - if (mapIt == m_NameMap.end()) return E_FAIL; + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return E_FAIL; (*mapIt)._value->InstanceCallback(lpCallback, lpData); return S_OK; @@ -281,7 +281,7 @@ HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const ////////////////////////////////////////////////////////////////////////// void CSysClassRegistry::DumpClasses(void *stream) { Classes::iterator it; - for (it = m_Classes.begin(); it != m_Classes.end(); ++it) + for (it = _classes.begin(); it != _classes.end(); ++it) (it->_value)->Dump(stream); } diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h index 6d3367fc30..84c4053ee9 100644 --- a/engines/wintermute/SysClassRegistry.h +++ b/engines/wintermute/SysClassRegistry.h @@ -80,23 +80,23 @@ public: CSysClassRegistry(); virtual ~CSysClassRegistry(); - bool m_Disabled; - int m_Count; + bool _disabled; + int _count; typedef Common::HashMap Classes; - Classes m_Classes; + Classes _classes; typedef Common::HashMap NameMap; - NameMap m_NameMap; + NameMap _nameMap; typedef Common::HashMap IdMap; - IdMap m_IdMap; + IdMap _idMap; typedef Common::HashMap InstanceMap; - InstanceMap m_InstanceMap; + InstanceMap _instanceMap; typedef Common::HashMap SavedInstanceMap; - SavedInstanceMap m_SavedInstanceMap; + SavedInstanceMap _savedInstanceMap; }; diff --git a/engines/wintermute/SysInstance.cpp b/engines/wintermute/SysInstance.cpp index 857a857a45..fbbfea87cd 100644 --- a/engines/wintermute/SysInstance.cpp +++ b/engines/wintermute/SysInstance.cpp @@ -34,12 +34,12 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CSysInstance::CSysInstance(void *Instance, int ID, CSysClass *sysClass) { - m_Instance = Instance; - m_ID = ID; - m_SavedID = -1; - m_Class = sysClass; + _instance = Instance; + _iD = ID; + _savedID = -1; + _class = sysClass; - m_Used = false; + _used = false; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/SysInstance.h b/engines/wintermute/SysInstance.h index 0286204c8e..80221d13a9 100644 --- a/engines/wintermute/SysInstance.h +++ b/engines/wintermute/SysInstance.h @@ -39,28 +39,28 @@ public: virtual ~CSysInstance(); int GetID() const { - return m_ID; + return _iD; } int GetSavedID() const { - return m_SavedID; + return _savedID; } void *GetInstance() const { - return m_Instance; + return _instance; } CSysClass *GetClass() const { - return m_Class; + return _class; } void SetSavedID(int id) { - m_SavedID = id; + _savedID = id; } private: - bool m_Used; - int m_ID; - int m_SavedID; - void *m_Instance; - CSysClass *m_Class; + bool _used; + int _iD; + int _savedID; + void *_instance; + CSysClass *_class; }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index 1053cec166..ebb72cbe97 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -49,54 +49,54 @@ IMPLEMENT_PERSISTENT(CUIButton, false) ////////////////////////////////////////////////////////////////////////// CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { - m_BackPress = m_BackHover = m_BackDisable = m_BackFocus = NULL; + _backPress = _backHover = _backDisable = _backFocus = NULL; - m_FontHover = m_FontPress = m_FontDisable = m_FontFocus = NULL; + _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; - m_ImageDisable = m_ImagePress = m_ImageHover = m_ImageFocus = NULL; + _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; - m_Align = TAL_CENTER; + _align = TAL_CENTER; - m_Hover = m_Press = false; + _hover = _press = false; - m_Type = UI_BUTTON; + _type = UI_BUTTON; - m_CanFocus = false; - m_StayPressed = false; + _canFocus = false; + _stayPressed = false; - m_OneTimePress = false; - m_CenterImage = false; + _oneTimePress = false; + _centerImage = false; - m_PixelPerfect = false; + _pixelPerfect = false; } ////////////////////////////////////////////////////////////////////////// CUIButton::~CUIButton() { - if (m_BackPress) delete m_BackPress; - if (m_BackHover) delete m_BackHover; - if (m_BackDisable) delete m_BackDisable; - if (m_BackFocus) delete m_BackFocus; - - if (!m_SharedFonts) { - if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); - if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); - if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); - if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); + if (_backPress) delete _backPress; + if (_backHover) delete _backHover; + if (_backDisable) delete _backDisable; + if (_backFocus) delete _backFocus; + + if (!_sharedFonts) { + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); } - if (!m_SharedImages) { - if (m_ImageHover) delete m_ImageHover; - if (m_ImagePress) delete m_ImagePress; - if (m_ImageDisable) delete m_ImageDisable; - if (m_ImageFocus) delete m_ImageFocus; + if (!_sharedImages) { + if (_imageHover) delete _imageHover; + if (_imagePress) delete _imagePress; + if (_imageDisable) delete _imageDisable; + if (_imageFocus) delete _imageFocus; } } ////////////////////////////////////////////////////////////////////////// HRESULT CUIButton::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -104,8 +104,8 @@ HRESULT CUIButton::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); @@ -222,168 +222,168 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BACK: - delete m_Back; - m_Back = new CUITiledImage(Game); - if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { - delete m_Back; - m_Back = NULL; + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_HOVER: - delete m_BackHover; - m_BackHover = new CUITiledImage(Game); - if (!m_BackHover || FAILED(m_BackHover->LoadFile((char *)params))) { - delete m_BackHover; - m_BackHover = NULL; + delete _backHover; + _backHover = new CUITiledImage(Game); + if (!_backHover || FAILED(_backHover->LoadFile((char *)params))) { + delete _backHover; + _backHover = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_PRESS: - delete m_BackPress; - m_BackPress = new CUITiledImage(Game); - if (!m_BackPress || FAILED(m_BackPress->LoadFile((char *)params))) { - delete m_BackPress; - m_BackPress = NULL; + delete _backPress; + _backPress = new CUITiledImage(Game); + if (!_backPress || FAILED(_backPress->LoadFile((char *)params))) { + delete _backPress; + _backPress = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_DISABLE: - delete m_BackDisable; - m_BackDisable = new CUITiledImage(Game); - if (!m_BackDisable || FAILED(m_BackDisable->LoadFile((char *)params))) { - delete m_BackDisable; - m_BackDisable = NULL; + delete _backDisable; + _backDisable = new CUITiledImage(Game); + if (!_backDisable || FAILED(_backDisable->LoadFile((char *)params))) { + delete _backDisable; + _backDisable = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_FOCUS: - delete m_BackFocus; - m_BackFocus = new CUITiledImage(Game); - if (!m_BackFocus || FAILED(m_BackFocus->LoadFile((char *)params))) { - delete m_BackFocus; - m_BackFocus = NULL; + delete _backFocus; + _backFocus = new CUITiledImage(Game); + if (!_backFocus || FAILED(_backFocus->LoadFile((char *)params))) { + delete _backFocus; + _backFocus = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE: - delete m_Image; - m_Image = new CBSprite(Game); - if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { - delete m_Image; - m_Image = NULL; + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_HOVER: - delete m_ImageHover; - m_ImageHover = new CBSprite(Game); - if (!m_ImageHover || FAILED(m_ImageHover->LoadFile((char *)params))) { - delete m_ImageHover; - m_ImageHover = NULL; + delete _imageHover; + _imageHover = new CBSprite(Game); + if (!_imageHover || FAILED(_imageHover->LoadFile((char *)params))) { + delete _imageHover; + _imageHover = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_PRESS: - delete m_ImagePress; - m_ImagePress = new CBSprite(Game); - if (!m_ImagePress || FAILED(m_ImagePress->LoadFile((char *)params))) { - delete m_ImagePress; - m_ImagePress = NULL; + delete _imagePress; + _imagePress = new CBSprite(Game); + if (!_imagePress || FAILED(_imagePress->LoadFile((char *)params))) { + delete _imagePress; + _imagePress = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_DISABLE: - delete m_ImageDisable; - m_ImageDisable = new CBSprite(Game); - if (!m_ImageDisable || FAILED(m_ImageDisable->LoadFile((char *)params))) { - delete m_ImageDisable; - m_ImageDisable = NULL; + delete _imageDisable; + _imageDisable = new CBSprite(Game); + if (!_imageDisable || FAILED(_imageDisable->LoadFile((char *)params))) { + delete _imageDisable; + _imageDisable = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_FOCUS: - delete m_ImageFocus; - m_ImageFocus = new CBSprite(Game); - if (!m_ImageFocus || FAILED(m_ImageFocus->LoadFile((char *)params))) { - delete m_ImageFocus; - m_ImageFocus = NULL; + delete _imageFocus; + _imageFocus = new CBSprite(Game); + if (!_imageFocus || FAILED(_imageFocus->LoadFile((char *)params))) { + delete _imageFocus; + _imageFocus = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_FONT: - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont((char *)params); - if (!m_Font) cmd = PARSERR_GENERIC; + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); - m_FontHover = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontHover) cmd = PARSERR_GENERIC; + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + _fontHover = Game->_fontStorage->AddFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_PRESS: - if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); - m_FontPress = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontPress) cmd = PARSERR_GENERIC; + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + _fontPress = Game->_fontStorage->AddFont((char *)params); + if (!_fontPress) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_DISABLE: - if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); - m_FontDisable = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontDisable) cmd = PARSERR_GENERIC; + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + _fontDisable = Game->_fontStorage->AddFont((char *)params); + if (!_fontDisable) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_FOCUS: - if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); - m_FontFocus = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontFocus) cmd = PARSERR_GENERIC; + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + _fontFocus = Game->_fontStorage->AddFont((char *)params); + if (!_fontFocus) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: SetText((char *)params); - Game->m_StringTable->Expand(&m_Text); + Game->_stringTable->Expand(&_text); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) m_Align = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) m_Align = TAL_RIGHT; - else m_Align = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_CENTER; break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &m_Width); + parser.ScanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_Height); + parser.ScanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -393,31 +393,31 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &m_ParentNotify); + parser.ScanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &m_Disable); + parser.ScanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &m_Visible); + parser.ScanStr((char *)params, "%b", &_visible); break; case TOKEN_FOCUSABLE: - parser.ScanStr((char *)params, "%b", &m_CanFocus); + parser.ScanStr((char *)params, "%b", &_canFocus); break; case TOKEN_CENTER_IMAGE: - parser.ScanStr((char *)params, "%b", &m_CenterImage); + parser.ScanStr((char *)params, "%b", &_centerImage); break; case TOKEN_PRESSED: - parser.ScanStr((char *)params, "%b", &m_StayPressed); + parser.ScanStr((char *)params, "%b", &_stayPressed); break; case TOKEN_PIXEL_PERFECT: - parser.ScanStr((char *)params, "%b", &m_PixelPerfect); + parser.ScanStr((char *)params, "%b", &_pixelPerfect); break; case TOKEN_EDITOR_PROPERTY: @@ -444,54 +444,54 @@ HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "BUTTON\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Back && m_Back->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); - if (m_BackHover && m_BackHover->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", m_BackHover->m_Filename); - if (m_BackPress && m_BackPress->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", m_BackPress->m_Filename); - if (m_BackDisable && m_BackDisable->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", m_BackDisable->m_Filename); - if (m_BackFocus && m_BackFocus->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", m_BackFocus->m_Filename); - - if (m_Image && m_Image->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); - if (m_ImageHover && m_ImageHover->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", m_ImageHover->m_Filename); - if (m_ImagePress && m_ImagePress->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", m_ImagePress->m_Filename); - if (m_ImageDisable && m_ImageDisable->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", m_ImageDisable->m_Filename); - if (m_ImageFocus && m_ImageFocus->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", m_ImageFocus->m_Filename); - - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); - if (m_FontHover && m_FontHover->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", m_FontHover->m_Filename); - if (m_FontPress && m_FontPress->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", m_FontPress->m_Filename); - if (m_FontDisable && m_FontDisable->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", m_FontDisable->m_Filename); - if (m_FontFocus && m_FontFocus->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", m_FontFocus->m_Filename); - - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backHover && _backHover->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + if (_backPress && _backPress->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + if (_backDisable && _backDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + if (_backFocus && _backFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageHover && _imageHover->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + if (_imagePress && _imagePress->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + if (_imageDisable && _imageDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + if (_imageFocus && _imageFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + if (_fontPress && _fontPress->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + if (_fontDisable && _fontDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + if (_fontFocus && _fontFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - switch (m_Align) { + switch (_align) { case TAL_LEFT: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; @@ -505,25 +505,25 @@ HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", m_CanFocus ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", m_CenterImage ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", m_StayPressed ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", m_PixelPerfect ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "\n"); // scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); @@ -540,111 +540,111 @@ void CUIButton::CorrectSize() { RECT rect; CBSprite *img = NULL; - if (m_Image) img = m_Image; - else if (m_ImageDisable) img = m_ImageDisable; - else if (m_ImageHover) img = m_ImageHover; - else if (m_ImagePress) img = m_ImagePress; - else if (m_ImageFocus) img = m_ImageFocus; + if (_image) img = _image; + else if (_imageDisable) img = _imageDisable; + else if (_imageHover) img = _imageHover; + else if (_imagePress) img = _imagePress; + else if (_imageFocus) img = _imageFocus; - if (m_Width <= 0) { + if (_width <= 0) { if (img) { img->GetBoundingRect(&rect, 0, 0); - m_Width = rect.right - rect.left; - } else m_Width = 100; + _width = rect.right - rect.left; + } else _width = 100; } - if (m_Height <= 0) { + if (_height <= 0) { if (img) { img->GetBoundingRect(&rect, 0, 0); - m_Height = rect.bottom - rect.top; + _height = rect.bottom - rect.top; } } - if (m_Text) { + if (_text) { int text_height; - if (m_Font) text_height = m_Font->GetTextHeight((byte *)m_Text, m_Width); - else text_height = Game->m_SystemFont->GetTextHeight((byte *)m_Text, m_Width); + if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); + else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); - if (text_height > m_Height) m_Height = text_height; + if (text_height > _height) _height = text_height; } - if (m_Height <= 0) m_Height = 100; + if (_height <= 0) _height = 100; - if (m_Back) m_Back->CorrectSize(&m_Width, &m_Height); + if (_back) _back->CorrectSize(&_width, &_height); } ////////////////////////////////////////////////////////////////////////// HRESULT CUIButton::Display(int OffsetX, int OffsetY) { - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; CUITiledImage *back = NULL; CBSprite *image = NULL; CBFont *font = 0; //RECT rect; - //CBPlatform::SetRect(&rect, OffsetX + m_PosX, OffsetY + m_PosY, OffsetX+m_PosX+m_Width, OffsetY+m_PosY+m_Height); - //m_Hover = (!m_Disable && CBPlatform::PtInRect(&rect, Game->m_MousePos)!=FALSE); - m_Hover = (!m_Disable && Game->m_ActiveObject == this && (Game->m_Interactive || Game->m_State == GAME_SEMI_FROZEN)); - - if ((m_Press && m_Hover && !Game->m_MouseLeftDown) || - m_OneTimePress && CBPlatform::GetTime() - m_OneTimePressTime >= 100) Press(); - - - if (m_Disable) { - if (m_BackDisable) back = m_BackDisable; - if (m_ImageDisable) image = m_ImageDisable; - if (m_Text && m_FontDisable) font = m_FontDisable; - } else if (m_Press || m_OneTimePress || m_StayPressed) { - if (m_BackPress) back = m_BackPress; - if (m_ImagePress) image = m_ImagePress; - if (m_Text && m_FontPress) font = m_FontPress; - } else if (m_Hover) { - if (m_BackHover) back = m_BackHover; - if (m_ImageHover) image = m_ImageHover; - if (m_Text && m_FontHover) font = m_FontHover; - } else if (m_CanFocus && IsFocused()) { - if (m_BackFocus) back = m_BackFocus; - if (m_ImageFocus) image = m_ImageFocus; - if (m_Text && m_FontFocus) font = m_FontFocus; + //CBPlatform::SetRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && CBPlatform::PtInRect(&rect, Game->_mousePos)!=FALSE); + _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); + + if ((_press && _hover && !Game->_mouseLeftDown) || + _oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100) Press(); + + + if (_disable) { + if (_backDisable) back = _backDisable; + if (_imageDisable) image = _imageDisable; + if (_text && _fontDisable) font = _fontDisable; + } else if (_press || _oneTimePress || _stayPressed) { + if (_backPress) back = _backPress; + if (_imagePress) image = _imagePress; + if (_text && _fontPress) font = _fontPress; + } else if (_hover) { + if (_backHover) back = _backHover; + if (_imageHover) image = _imageHover; + if (_text && _fontHover) font = _fontHover; + } else if (_canFocus && IsFocused()) { + if (_backFocus) back = _backFocus; + if (_imageFocus) image = _imageFocus; + if (_text && _fontFocus) font = _fontFocus; } - if (!back && m_Back) back = m_Back; - if (!image && m_Image) image = m_Image; - if (m_Text && !font) { - if (m_Font) font = m_Font; - else font = Game->m_SystemFont; + if (!back && _back) back = _back; + if (!image && _image) image = _image; + if (_text && !font) { + if (_font) font = _font; + else font = Game->_systemFont; } - int ImageX = OffsetX + m_PosX; - int ImageY = OffsetY + m_PosY; + int ImageX = OffsetX + _posX; + int ImageY = OffsetY + _posY; - if (image && m_CenterImage) { + if (image && _centerImage) { RECT rc; image->GetBoundingRect(&rc, 0, 0); - ImageX += (m_Width - (rc.right - rc.left)) / 2; - ImageY += (m_Height - (rc.bottom - rc.top)) / 2; + ImageX += (_width - (rc.right - rc.left)) / 2; + ImageY += (_height - (rc.bottom - rc.top)) / 2; } - if (back) back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); - //if(image) image->Draw(ImageX +((m_Press||m_OneTimePress)&&back?1:0), ImageY +((m_Press||m_OneTimePress)&&back?1:0), NULL); - if (image) image->Draw(ImageX + ((m_Press || m_OneTimePress) && back ? 1 : 0), ImageY + ((m_Press || m_OneTimePress) && back ? 1 : 0), m_PixelPerfect ? this : NULL); + if (back) back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); - if (font && m_Text) { - int text_offset = (m_Height - font->GetTextHeight((byte *)m_Text, m_Width)) / 2; - font->DrawText((byte *)m_Text, OffsetX + m_PosX + ((m_Press || m_OneTimePress) ? 1 : 0), OffsetY + m_PosY + text_offset + ((m_Press || m_OneTimePress) ? 1 : 0), m_Width, m_Align); + if (font && _text) { + int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!m_PixelPerfect || !m_Image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites - if (m_Image && m_Image != image) m_Image->Reset(); - if (m_ImageDisable && m_ImageDisable != image) m_ImageDisable->Reset(); - if (m_ImageFocus && m_ImageFocus != image) m_ImageFocus->Reset(); - if (m_ImagePress && m_ImagePress != image) m_ImagePress->Reset(); - if (m_ImageHover && m_ImageHover != image) m_ImageHover->Reset(); + if (_image && _image != image) _image->Reset(); + if (_imageDisable && _imageDisable != image) _imageDisable->Reset(); + if (_imageFocus && _imageFocus != image) _imageFocus->Reset(); + if (_imagePress && _imagePress != image) _imagePress->Reset(); + if (_imageHover && _imageHover != image) _imageHover->Reset(); - m_Press = m_Hover && Game->m_MouseLeftDown && Game->m_CapturedObject == this; + _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; return S_OK; } @@ -653,10 +653,10 @@ HRESULT CUIButton::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// void CUIButton::Press() { ApplyEvent("Press"); - if (m_ListenerObject) m_ListenerObject->Listen(m_ListenerParamObject, m_ListenerParamDWORD); - if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + if (_listenerObject) _listenerObject->Listen(_listenerParamObject, _listenerParamDWORD); + if (_parentNotify && _parent) _parent->ApplyEvent(_name); - m_OneTimePress = false; + _oneTimePress = false; } @@ -671,13 +671,13 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - if (m_FontDisable) Game->m_FontStorage->RemoveFont(m_FontDisable); + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); if (Val->IsNULL()) { - m_FontDisable = NULL; + _fontDisable = NULL; Stack->PushBool(true); } else { - m_FontDisable = Game->m_FontStorage->AddFont(Val->GetString()); - Stack->PushBool(m_FontDisable != NULL); + _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontDisable != NULL); } return S_OK; } @@ -689,13 +689,13 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - if (m_FontHover) Game->m_FontStorage->RemoveFont(m_FontHover); + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); if (Val->IsNULL()) { - m_FontHover = NULL; + _fontHover = NULL; Stack->PushBool(true); } else { - m_FontHover = Game->m_FontStorage->AddFont(Val->GetString()); - Stack->PushBool(m_FontHover != NULL); + _fontHover = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontHover != NULL); } return S_OK; } @@ -707,13 +707,13 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - if (m_FontPress) Game->m_FontStorage->RemoveFont(m_FontPress); + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); if (Val->IsNULL()) { - m_FontPress = NULL; + _fontPress = NULL; Stack->PushBool(true); } else { - m_FontPress = Game->m_FontStorage->AddFont(Val->GetString()); - Stack->PushBool(m_FontPress != NULL); + _fontPress = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontPress != NULL); } return S_OK; } @@ -725,13 +725,13 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - if (m_FontFocus) Game->m_FontStorage->RemoveFont(m_FontFocus); + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); if (Val->IsNULL()) { - m_FontFocus = NULL; + _fontFocus = NULL; Stack->PushBool(true); } else { - m_FontFocus = Game->m_FontStorage->AddFont(Val->GetString()); - Stack->PushBool(m_FontFocus != NULL); + _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontFocus != NULL); } return S_OK; } @@ -742,12 +742,12 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetDisabledImage") == 0) { Stack->CorrectParams(1); - delete m_ImageDisable; - m_ImageDisable = new CBSprite(Game); + delete _imageDisable; + _imageDisable = new CBSprite(Game); char *Filename = Stack->Pop()->GetString(); - if (!m_ImageDisable || FAILED(m_ImageDisable->LoadFile(Filename))) { - delete m_ImageDisable; - m_ImageDisable = NULL; + if (!_imageDisable || FAILED(_imageDisable->LoadFile(Filename))) { + delete _imageDisable; + _imageDisable = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -759,8 +759,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetDisabledImage") == 0) { Stack->CorrectParams(0); - if (!m_ImageDisable || !m_ImageDisable->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ImageDisable->m_Filename); + if (!_imageDisable || !_imageDisable->_filename) Stack->PushNULL(); + else Stack->PushString(_imageDisable->_filename); return S_OK; } @@ -770,8 +770,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetDisabledImageObject") == 0) { Stack->CorrectParams(0); - if (!m_ImageDisable) Stack->PushNULL(); - else Stack->PushNative(m_ImageDisable, true); + if (!_imageDisable) Stack->PushNULL(); + else Stack->PushNative(_imageDisable, true); return S_OK; } @@ -783,12 +783,12 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetHoverImage") == 0) { Stack->CorrectParams(1); - delete m_ImageHover; - m_ImageHover = new CBSprite(Game); + delete _imageHover; + _imageHover = new CBSprite(Game); char *Filename = Stack->Pop()->GetString(); - if (!m_ImageHover || FAILED(m_ImageHover->LoadFile(Filename))) { - delete m_ImageHover; - m_ImageHover = NULL; + if (!_imageHover || FAILED(_imageHover->LoadFile(Filename))) { + delete _imageHover; + _imageHover = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -800,8 +800,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetHoverImage") == 0) { Stack->CorrectParams(0); - if (!m_ImageHover || !m_ImageHover->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ImageHover->m_Filename); + if (!_imageHover || !_imageHover->_filename) Stack->PushNULL(); + else Stack->PushString(_imageHover->_filename); return S_OK; } @@ -811,8 +811,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetHoverImageObject") == 0) { Stack->CorrectParams(0); - if (!m_ImageHover) Stack->PushNULL(); - else Stack->PushNative(m_ImageHover, true); + if (!_imageHover) Stack->PushNULL(); + else Stack->PushNative(_imageHover, true); return S_OK; } @@ -823,12 +823,12 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetPressedImage") == 0) { Stack->CorrectParams(1); - delete m_ImagePress; - m_ImagePress = new CBSprite(Game); + delete _imagePress; + _imagePress = new CBSprite(Game); char *Filename = Stack->Pop()->GetString(); - if (!m_ImagePress || FAILED(m_ImagePress->LoadFile(Filename))) { - delete m_ImagePress; - m_ImagePress = NULL; + if (!_imagePress || FAILED(_imagePress->LoadFile(Filename))) { + delete _imagePress; + _imagePress = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -840,8 +840,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetPressedImage") == 0) { Stack->CorrectParams(0); - if (!m_ImagePress || !m_ImagePress->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ImagePress->m_Filename); + if (!_imagePress || !_imagePress->_filename) Stack->PushNULL(); + else Stack->PushString(_imagePress->_filename); return S_OK; } @@ -851,8 +851,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetPressedImageObject") == 0) { Stack->CorrectParams(0); - if (!m_ImagePress) Stack->PushNULL(); - else Stack->PushNative(m_ImagePress, true); + if (!_imagePress) Stack->PushNULL(); + else Stack->PushNative(_imagePress, true); return S_OK; } @@ -863,12 +863,12 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetFocusedImage") == 0) { Stack->CorrectParams(1); - delete m_ImageFocus; - m_ImageFocus = new CBSprite(Game); + delete _imageFocus; + _imageFocus = new CBSprite(Game); char *Filename = Stack->Pop()->GetString(); - if (!m_ImageFocus || FAILED(m_ImageFocus->LoadFile(Filename))) { - delete m_ImageFocus; - m_ImageFocus = NULL; + if (!_imageFocus || FAILED(_imageFocus->LoadFile(Filename))) { + delete _imageFocus; + _imageFocus = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -880,8 +880,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFocusedImage") == 0) { Stack->CorrectParams(0); - if (!m_ImageFocus || !m_ImageFocus->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ImageFocus->m_Filename); + if (!_imageFocus || !_imageFocus->_filename) Stack->PushNULL(); + else Stack->PushString(_imageFocus->_filename); return S_OK; } @@ -891,8 +891,8 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFocusedImageObject") == 0) { Stack->CorrectParams(0); - if (!m_ImageFocus) Stack->PushNULL(); - else Stack->PushNative(m_ImageFocus, true); + if (!_imageFocus) Stack->PushNULL(); + else Stack->PushNative(_imageFocus, true); return S_OK; } @@ -903,9 +903,9 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "Press") == 0) { Stack->CorrectParams(0); - if (m_Visible && !m_Disable) { - m_OneTimePress = true; - m_OneTimePressTime = CBPlatform::GetTime(); + if (_visible && !_disable) { + _oneTimePress = true; + _oneTimePressTime = CBPlatform::GetTime(); } Stack->PushNULL(); @@ -919,44 +919,44 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CUIButton::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("button"); - return m_ScValue; + _scValue->SetString("button"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextAlign") == 0) { - m_ScValue->SetInt(m_Align); - return m_ScValue; + _scValue->SetInt(_align); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Focusable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Focusable") == 0) { - m_ScValue->SetBool(m_CanFocus); - return m_ScValue; + _scValue->SetBool(_canFocus); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Pressed") == 0) { - m_ScValue->SetBool(m_StayPressed); - return m_ScValue; + _scValue->SetBool(_stayPressed); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PixelPerfect") == 0) { - m_ScValue->SetBool(m_PixelPerfect); - return m_ScValue; + _scValue->SetBool(_pixelPerfect); + return _scValue; } else return CUIObject::ScGetProperty(Name); @@ -971,7 +971,7 @@ HRESULT CUIButton::ScSetProperty(char *Name, CScValue *Value) { if (strcmp(Name, "TextAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - m_Align = (TTextAlign)i; + _align = (TTextAlign)i; return S_OK; } @@ -979,21 +979,21 @@ HRESULT CUIButton::ScSetProperty(char *Name, CScValue *Value) { // Focusable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Focusable") == 0) { - m_CanFocus = Value->GetBool(); + _canFocus = Value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Pressed") == 0) { - m_StayPressed = Value->GetBool(); + _stayPressed = Value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PixelPerfect") == 0) { - m_PixelPerfect = Value->GetBool(); + _pixelPerfect = Value->GetBool(); return S_OK; } @@ -1012,29 +1012,29 @@ HRESULT CUIButton::Persist(CBPersistMgr *PersistMgr) { CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(m_Align)); - PersistMgr->Transfer(TMEMBER(m_BackDisable)); - PersistMgr->Transfer(TMEMBER(m_BackFocus)); - PersistMgr->Transfer(TMEMBER(m_BackHover)); - PersistMgr->Transfer(TMEMBER(m_BackPress)); - PersistMgr->Transfer(TMEMBER(m_CenterImage)); - PersistMgr->Transfer(TMEMBER(m_FontDisable)); - PersistMgr->Transfer(TMEMBER(m_FontFocus)); - PersistMgr->Transfer(TMEMBER(m_FontHover)); - PersistMgr->Transfer(TMEMBER(m_FontPress)); - PersistMgr->Transfer(TMEMBER(m_Hover)); - PersistMgr->Transfer(TMEMBER(m_Image)); - PersistMgr->Transfer(TMEMBER(m_ImageDisable)); - PersistMgr->Transfer(TMEMBER(m_ImageFocus)); - PersistMgr->Transfer(TMEMBER(m_ImageHover)); - PersistMgr->Transfer(TMEMBER(m_ImagePress)); - PersistMgr->Transfer(TMEMBER(m_PixelPerfect)); - PersistMgr->Transfer(TMEMBER(m_Press)); - PersistMgr->Transfer(TMEMBER(m_StayPressed)); - - if (!PersistMgr->m_Saving) { - m_OneTimePress = false; - m_OneTimePressTime = 0; + PersistMgr->Transfer(TMEMBER_INT(_align)); + PersistMgr->Transfer(TMEMBER(_backDisable)); + PersistMgr->Transfer(TMEMBER(_backFocus)); + PersistMgr->Transfer(TMEMBER(_backHover)); + PersistMgr->Transfer(TMEMBER(_backPress)); + PersistMgr->Transfer(TMEMBER(_centerImage)); + PersistMgr->Transfer(TMEMBER(_fontDisable)); + PersistMgr->Transfer(TMEMBER(_fontFocus)); + PersistMgr->Transfer(TMEMBER(_fontHover)); + PersistMgr->Transfer(TMEMBER(_fontPress)); + PersistMgr->Transfer(TMEMBER(_hover)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_imageDisable)); + PersistMgr->Transfer(TMEMBER(_imageFocus)); + PersistMgr->Transfer(TMEMBER(_imageHover)); + PersistMgr->Transfer(TMEMBER(_imagePress)); + PersistMgr->Transfer(TMEMBER(_pixelPerfect)); + PersistMgr->Transfer(TMEMBER(_press)); + PersistMgr->Transfer(TMEMBER(_stayPressed)); + + if (!PersistMgr->_saving) { + _oneTimePress = false; + _oneTimePressTime = 0; } return S_OK; diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index aa4b7f8b78..aa2ac4d66d 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -37,30 +37,30 @@ namespace WinterMute { class CUIButton : public CUIObject { public: - bool m_PixelPerfect; - bool m_StayPressed; - bool m_CenterImage; - bool m_OneTimePress; - uint32 m_OneTimePressTime; + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) void Press(); virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - bool m_Press; - bool m_Hover; + bool _press; + bool _hover; void CorrectSize(); - TTextAlign m_Align; - CBSprite *m_ImageHover; - CBSprite *m_ImagePress; - CBSprite *m_ImageDisable; - CBSprite *m_ImageFocus; - CBFont *m_FontDisable; - CBFont *m_FontPress; - CBFont *m_FontHover; - CBFont *m_FontFocus; - CUITiledImage *m_BackPress; - CUITiledImage *m_BackHover; - CUITiledImage *m_BackDisable; - CUITiledImage *m_BackFocus; + TTextAlign _align; + CBSprite *_imageHover; + CBSprite *_imagePress; + CBSprite *_imageDisable; + CBSprite *_imageFocus; + CBFont *_fontDisable; + CBFont *_fontPress; + CBFont *_fontHover; + CBFont *_fontFocus; + CUITiledImage *_backPress; + CUITiledImage *_backHover; + CUITiledImage *_backDisable; + CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); HRESULT LoadFile(char *Filename); diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 6d1018ec0a..2cb79935df 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -53,48 +53,48 @@ IMPLEMENT_PERSISTENT(CUIEdit, false) ////////////////////////////////////////////////////////////////////////// CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { - m_Type = UI_EDIT; + _type = UI_EDIT; - m_FontSelected = NULL; + _fontSelected = NULL; - m_SelStart = m_SelEnd = 10000; - m_ScrollOffset = 0; + _selStart = _selEnd = 10000; + _scrollOffset = 0; - m_CursorChar = NULL; + _cursorChar = NULL; SetCursorChar("|"); #ifdef __WIN32__ - m_CursorBlinkRate = GetCaretBlinkTime(); + _cursorBlinkRate = GetCaretBlinkTime(); #else - m_CursorBlinkRate = 600; + _cursorBlinkRate = 600; #endif - m_FrameWidth = 0; + _frameWidth = 0; SetText(""); - m_LastBlinkTime = 0; - m_CursorVisible = true; + _lastBlinkTime = 0; + _cursorVisible = true; - m_MaxLength = -1; + _maxLength = -1; - m_CanFocus = true; + _canFocus = true; } ////////////////////////////////////////////////////////////////////////// CUIEdit::~CUIEdit() { - if (!m_SharedFonts) { - if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); + if (!_sharedFonts) { + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); } - delete[] m_CursorChar; - m_CursorChar = NULL; + delete[] _cursorChar; + _cursorChar = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CUIEdit::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -102,8 +102,8 @@ HRESULT CUIEdit::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); @@ -187,60 +187,60 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BACK: - delete m_Back; - m_Back = new CUITiledImage(Game); - if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { - delete m_Back; - m_Back = NULL; + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE: - delete m_Image; - m_Image = new CBSprite(Game); - if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { - delete m_Image; - m_Image = NULL; + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_FONT: - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont((char *)params); - if (!m_Font) cmd = PARSERR_GENERIC; + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_SELECTED: - if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); - m_FontSelected = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontSelected) cmd = PARSERR_GENERIC; + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + _fontSelected = Game->_fontStorage->AddFont((char *)params); + if (!_fontSelected) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: SetText((char *)params); - Game->m_StringTable->Expand(&m_Text); + Game->_stringTable->Expand(&_text); break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &m_Width); + parser.ScanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_Height); + parser.ScanStr((char *)params, "%d", &_height); break; case TOKEN_MAX_LENGTH: - parser.ScanStr((char *)params, "%d", &m_MaxLength); + parser.ScanStr((char *)params, "%d", &_maxLength); break; case TOKEN_CAPTION: @@ -248,21 +248,21 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_CURSOR_BLINK_RATE: - parser.ScanStr((char *)params, "%d", &m_CursorBlinkRate); + parser.ScanStr((char *)params, "%d", &_cursorBlinkRate); break; case TOKEN_FRAME_WIDTH: - parser.ScanStr((char *)params, "%d", &m_FrameWidth); + parser.ScanStr((char *)params, "%d", &_frameWidth); break; case TOKEN_SCRIPT: @@ -270,15 +270,15 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &m_ParentNotify); + parser.ScanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &m_Disable); + parser.ScanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &m_Visible); + parser.ScanStr((char *)params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: @@ -305,47 +305,47 @@ HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "EDIT\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Back && m_Back->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (m_Image && m_Image->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); - if (m_FontSelected && m_FontSelected->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", m_FontSelected->m_Filename); + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontSelected && _fontSelected->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); Buffer->PutTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); - Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", m_MaxLength); - Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", m_CursorBlinkRate); - Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", m_FrameWidth); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); + Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); // scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); @@ -367,9 +367,9 @@ HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "SetSelectedFont") == 0) { Stack->CorrectParams(1); - if (m_FontSelected) Game->m_FontStorage->RemoveFont(m_FontSelected); - m_FontSelected = Game->m_FontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(m_FontSelected != NULL); + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + _fontSelected = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(_fontSelected != NULL); return S_OK; } @@ -380,75 +380,75 @@ HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CUIEdit::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("editor"); - return m_ScValue; + _scValue->SetString("editor"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SelStart") == 0) { - m_ScValue->SetInt(m_SelStart); - return m_ScValue; + _scValue->SetInt(_selStart); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SelEnd ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SelEnd") == 0) { - m_ScValue->SetInt(m_SelEnd); - return m_ScValue; + _scValue->SetInt(_selEnd); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorBlinkRate") == 0) { - m_ScValue->SetInt(m_CursorBlinkRate); - return m_ScValue; + _scValue->SetInt(_cursorBlinkRate); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // CursorChar ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorChar") == 0) { - m_ScValue->SetString(m_CursorChar); - return m_ScValue; + _scValue->SetString(_cursorChar); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // FrameWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FrameWidth") == 0) { - m_ScValue->SetInt(m_FrameWidth); - return m_ScValue; + _scValue->SetInt(_frameWidth); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxLength") == 0) { - m_ScValue->SetInt(m_MaxLength); - return m_ScValue; + _scValue->SetInt(_maxLength); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Text") == 0) { - if (Game->m_TextEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::AnsiToWide(m_Text); - m_ScValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::AnsiToWide(_text); + _scValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); } else { - m_ScValue->SetString(m_Text); + _scValue->SetString(_text); } - return m_ScValue; + return _scValue; } else return CUIObject::ScGetProperty(Name); @@ -461,9 +461,9 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // SelStart ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "SelStart") == 0) { - m_SelStart = Value->GetInt(); - m_SelStart = MAX(m_SelStart, 0); - m_SelStart = MIN((size_t)m_SelStart, strlen(m_Text)); + _selStart = Value->GetInt(); + _selStart = MAX(_selStart, 0); + _selStart = MIN((size_t)_selStart, strlen(_text)); return S_OK; } @@ -471,9 +471,9 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // SelEnd ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SelEnd") == 0) { - m_SelEnd = Value->GetInt(); - m_SelEnd = MAX(m_SelEnd, 0); - m_SelEnd = MIN((size_t)m_SelEnd, strlen(m_Text)); + _selEnd = Value->GetInt(); + _selEnd = MAX(_selEnd, 0); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); return S_OK; } @@ -481,7 +481,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorBlinkRate") == 0) { - m_CursorBlinkRate = Value->GetInt(); + _cursorBlinkRate = Value->GetInt(); return S_OK; } @@ -497,7 +497,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // FrameWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FrameWidth") == 0) { - m_FrameWidth = Value->GetInt(); + _frameWidth = Value->GetInt(); return S_OK; } @@ -505,7 +505,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // MaxLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MaxLength") == 0) { - m_MaxLength = Value->GetInt(); + _maxLength = Value->GetInt(); return S_OK; } @@ -513,7 +513,7 @@ HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Text") == 0) { - if (Game->m_TextEncoding == TEXT_UTF8) { + if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); SetText(StringUtil::WideToAnsi(wstr).c_str()); } else { @@ -535,72 +535,72 @@ char *CUIEdit::ScToString() { ////////////////////////////////////////////////////////////////////////// void CUIEdit::SetCursorChar(char *Char) { if (!Char) return; - delete[] m_CursorChar; - m_CursorChar = new char [strlen(Char) + 1]; - if (m_CursorChar) strcpy(m_CursorChar, Char); + delete[] _cursorChar; + _cursorChar = new char [strlen(Char) + 1]; + if (_cursorChar) strcpy(_cursorChar, Char); } ////////////////////////////////////////////////////////////////////////// HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; // hack! - TTextEncoding OrigEncoding = Game->m_TextEncoding; - Game->m_TextEncoding = TEXT_ANSI; + TTextEncoding OrigEncoding = Game->_textEncoding; + Game->_textEncoding = TEXT_ANSI; - if (m_Back) m_Back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); - if (m_Image) m_Image->Draw(OffsetX + m_PosX, OffsetY + m_PosY, NULL); + if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); // prepare fonts CBFont *font; CBFont *sfont; - if (m_Font) font = m_Font; - else font = Game->m_SystemFont; + if (_font) font = _font; + else font = Game->_systemFont; - if (m_FontSelected) sfont = m_FontSelected; + if (_fontSelected) sfont = _fontSelected; else sfont = font; bool focused = IsFocused(); - m_SelStart = MAX(m_SelStart, 0); - m_SelEnd = MAX(m_SelEnd, 0); + _selStart = MAX(_selStart, 0); + _selEnd = MAX(_selEnd, 0); - m_SelStart = MIN((size_t)m_SelStart, strlen(m_Text)); - m_SelEnd = MIN((size_t)m_SelEnd, strlen(m_Text)); + _selStart = MIN((size_t)_selStart, strlen(_text)); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); - //int CursorWidth = font->GetCharWidth(m_CursorChar[0]); - int CursorWidth = font->GetTextWidth((byte *)m_CursorChar); + //int CursorWidth = font->GetCharWidth(_cursorChar[0]); + int CursorWidth = font->GetTextWidth((byte *)_cursorChar); int s1, s2; bool CurFirst; // modify scroll offset - if (m_SelStart >= m_SelEnd) { - while (font->GetTextWidth((byte *)m_Text + m_ScrollOffset, std::max(0, m_SelEnd - m_ScrollOffset)) > m_Width - CursorWidth - 2 * m_FrameWidth) { - m_ScrollOffset++; - if (m_ScrollOffset >= strlen(m_Text)) break; + if (_selStart >= _selEnd) { + while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= strlen(_text)) break; } - m_ScrollOffset = std::min(m_ScrollOffset, m_SelEnd); + _scrollOffset = std::min(_scrollOffset, _selEnd); - s1 = m_SelEnd; - s2 = m_SelStart; + s1 = _selEnd; + s2 = _selStart; CurFirst = true; } else { - while (font->GetTextWidth((byte *)m_Text + m_ScrollOffset, std::max(0, m_SelStart - m_ScrollOffset)) + - sfont->GetTextWidth((byte *)(m_Text + std::max(m_ScrollOffset, m_SelStart)), m_SelEnd - std::max(m_ScrollOffset, m_SelStart)) + while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selStart - _scrollOffset)) + + sfont->GetTextWidth((byte *)(_text + std::max(_scrollOffset, _selStart)), _selEnd - std::max(_scrollOffset, _selStart)) - > m_Width - CursorWidth - 2 * m_FrameWidth) { - m_ScrollOffset++; - if (m_ScrollOffset >= strlen(m_Text)) break; + > _width - CursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= strlen(_text)) break; } - m_ScrollOffset = std::min(m_ScrollOffset, m_SelEnd); + _scrollOffset = std::min(_scrollOffset, _selEnd); - s1 = m_SelStart; - s2 = m_SelEnd; + s1 = _selStart; + s2 = _selEnd; CurFirst = false; } @@ -611,74 +611,74 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { // draw text int xxx, yyy, width, height; - xxx = m_PosX + m_FrameWidth + OffsetX; - yyy = m_PosY + m_FrameWidth + OffsetY; + xxx = _posX + _frameWidth + OffsetX; + yyy = _posY + _frameWidth + OffsetY; - width = m_PosX + m_Width + OffsetX - m_FrameWidth; + width = _posX + _width + OffsetX - _frameWidth; height = std::max(font->GetLetterHeight(), sfont->GetLetterHeight()); - if (Game->m_TextRTL) xxx += AlignOffset; + if (Game->_textRTL) xxx += AlignOffset; TTextAlign Align = TAL_LEFT; // unselected 1 - if (s1 > m_ScrollOffset) { - if (Count) font->DrawText((byte *)m_Text + m_ScrollOffset, xxx, yyy, width - xxx, Align, height, s1 - m_ScrollOffset); - xxx += font->GetTextWidth((byte *)m_Text + m_ScrollOffset, s1 - m_ScrollOffset); - AlignOffset += font->GetTextWidth((byte *)m_Text + m_ScrollOffset, s1 - m_ScrollOffset); + if (s1 > _scrollOffset) { + if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); } // cursor if (focused && CurFirst) { if (Count) { - if (CBPlatform::GetTime() - m_LastBlinkTime >= m_CursorBlinkRate) { - m_LastBlinkTime = CBPlatform::GetTime(); - m_CursorVisible = !m_CursorVisible; + if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::GetTime(); + _cursorVisible = !_cursorVisible; } - if (m_CursorVisible) - font->DrawText((byte *)m_CursorChar, xxx, yyy, width - xxx, Align, height, 1); + if (_cursorVisible) + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; } // selected - int s3 = std::max(s1, m_ScrollOffset); + int s3 = std::max(s1, _scrollOffset); if (s2 - s3 > 0) { - if (Count) sfont->DrawText((byte *)m_Text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->GetTextWidth((byte *)m_Text + s3, s2 - s3); - AlignOffset += sfont->GetTextWidth((byte *)m_Text + s3, s2 - s3); + if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); } // cursor if (focused && !CurFirst) { if (Count) { - if (CBPlatform::GetTime() - m_LastBlinkTime >= m_CursorBlinkRate) { - m_LastBlinkTime = CBPlatform::GetTime(); - m_CursorVisible = !m_CursorVisible; + if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::GetTime(); + _cursorVisible = !_cursorVisible; } - if (m_CursorVisible) - font->DrawText((byte *)m_CursorChar, xxx, yyy, width - xxx, Align, height, 1); + if (_cursorVisible) + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; } // unselected 2 - if (Count) font->DrawText((byte *)m_Text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->GetTextWidth((byte *)m_Text + s2); + if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->GetTextWidth((byte *)_text + s2); - AlignOffset = (m_Width - 2 * m_FrameWidth) - AlignOffset; + AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; if (AlignOffset < 0) AlignOffset = 0; } - Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - Game->m_TextEncoding = OrigEncoding; + Game->_textEncoding = OrigEncoding; return S_OK; } @@ -698,70 +698,70 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { // ctrl+A case SDLK_a: if (CBKeyboardState::IsControlDown()) { - m_SelStart = 0; - m_SelEnd = strlen(m_Text); + _selStart = 0; + _selEnd = strlen(_text); Handled = true; } break; case SDLK_BACKSPACE: - if (m_SelStart == m_SelEnd) { - if (Game->m_TextRTL) DeleteChars(m_SelStart, m_SelStart + 1); - else DeleteChars(m_SelStart - 1, m_SelStart); - } else DeleteChars(m_SelStart, m_SelEnd); - if (m_SelEnd >= m_SelStart) m_SelEnd -= std::max(1, m_SelEnd - m_SelStart); - m_SelStart = m_SelEnd; + if (_selStart == _selEnd) { + if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); + else DeleteChars(_selStart - 1, _selStart); + } else DeleteChars(_selStart, _selEnd); + if (_selEnd >= _selStart) _selEnd -= std::max(1, _selEnd - _selStart); + _selStart = _selEnd; Handled = true; break; case SDLK_LEFT: case SDLK_UP: - m_SelEnd--; - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + _selEnd--; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; Handled = true; break; case SDLK_RIGHT: case SDLK_DOWN: - m_SelEnd++; - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + _selEnd++; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; Handled = true; break; case SDLK_HOME: - if (Game->m_TextRTL) { - m_SelEnd = strlen(m_Text); - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + if (Game->_textRTL) { + _selEnd = strlen(_text); + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; } else { - m_SelEnd = 0; - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + _selEnd = 0; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; } Handled = true; break; case SDLK_END: - if (Game->m_TextRTL) { - m_SelEnd = 0; - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + if (Game->_textRTL) { + _selEnd = 0; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; } else { - m_SelEnd = strlen(m_Text); - if (!CBKeyboardState::IsShiftDown()) m_SelStart = m_SelEnd; + _selEnd = strlen(_text); + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; } Handled = true; break; case SDLK_DELETE: - if (m_SelStart == m_SelEnd) { - if (Game->m_TextRTL) { - DeleteChars(m_SelStart - 1, m_SelStart); - m_SelEnd--; - if (m_SelEnd < 0) m_SelEnd = 0; - } else DeleteChars(m_SelStart, m_SelStart + 1); - } else DeleteChars(m_SelStart, m_SelEnd); - if (m_SelEnd > m_SelStart) m_SelEnd -= (m_SelEnd - m_SelStart); - - m_SelStart = m_SelEnd; + if (_selStart == _selEnd) { + if (Game->_textRTL) { + DeleteChars(_selStart - 1, _selStart); + _selEnd--; + if (_selEnd < 0) _selEnd = 0; + } else DeleteChars(_selStart, _selStart + 1); + } else DeleteChars(_selStart, _selEnd); + if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); + + _selStart = _selEnd; Handled = true; break; } @@ -769,13 +769,13 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { } #if 0 else if (event->type == SDL_TEXTINPUT) { - if (m_SelStart != m_SelEnd) DeleteChars(m_SelStart, m_SelEnd); + if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); WideString wstr = StringUtil::Utf8ToWide(event->text.text); - m_SelEnd += InsertChars(m_SelEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); - if (Game->m_TextRTL) m_SelEnd = m_SelStart; - else m_SelStart = m_SelEnd; + if (Game->_textRTL) _selEnd = _selStart; + else _selStart = _selEnd; return true; } @@ -790,17 +790,17 @@ int CUIEdit::DeleteChars(int Start, int End) { if (Start > End) CBUtils::Swap(&Start, &End); Start = MAX(Start, (int)0); - End = MIN((size_t)End, strlen(m_Text)); + End = MIN((size_t)End, strlen(_text)); - char *str = new char[strlen(m_Text) - (End - Start) + 1]; + char *str = new char[strlen(_text) - (End - Start) + 1]; if (str) { - if (Start > 0) memcpy(str, m_Text, Start); - memcpy(str + std::max(0, Start), m_Text + End, strlen(m_Text) - End + 1); + if (Start > 0) memcpy(str, _text, Start); + memcpy(str + std::max(0, Start), _text + End, strlen(_text) - End + 1); - delete[] m_Text; - m_Text = str; + delete[] _text; + _text = str; } - if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + if (_parentNotify && _parent) _parent->ApplyEvent(_name); return End - Start; } @@ -808,24 +808,24 @@ int CUIEdit::DeleteChars(int Start, int End) { ////////////////////////////////////////////////////////////////////////// int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { - if (strlen(m_Text) + Num > m_MaxLength) { - Num -= (strlen(m_Text) + Num - m_MaxLength); + if (strlen(_text) + Num > _maxLength) { + Num -= (strlen(_text) + Num - _maxLength); } Pos = MAX(Pos, (int)0); - Pos = MIN((size_t)Pos, strlen(m_Text)); + Pos = MIN((size_t)Pos, strlen(_text)); - char *str = new char[strlen(m_Text) + Num + 1]; + char *str = new char[strlen(_text) + Num + 1]; if (str) { - if (Pos > 0) memcpy(str, m_Text, Pos); - memcpy(str + Pos + Num, m_Text + Pos, strlen(m_Text) - Pos + 1); + if (Pos > 0) memcpy(str, _text, Pos); + memcpy(str + Pos + Num, _text + Pos, strlen(_text) - Pos + 1); memcpy(str + Pos, Chars, Num); - delete[] m_Text; - m_Text = str; + delete[] _text; + _text = str; } - if (m_ParentNotify && m_Parent) m_Parent->ApplyEvent(m_Name); + if (_parentNotify && _parent) _parent->ApplyEvent(_name); return Num; } @@ -837,18 +837,18 @@ HRESULT CUIEdit::Persist(CBPersistMgr *PersistMgr) { CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_CursorBlinkRate)); - PersistMgr->Transfer(TMEMBER(m_CursorChar)); - PersistMgr->Transfer(TMEMBER(m_FontSelected)); - PersistMgr->Transfer(TMEMBER(m_FrameWidth)); - PersistMgr->Transfer(TMEMBER(m_MaxLength)); - PersistMgr->Transfer(TMEMBER(m_ScrollOffset)); - PersistMgr->Transfer(TMEMBER(m_SelEnd)); - PersistMgr->Transfer(TMEMBER(m_SelStart)); - - if (!PersistMgr->m_Saving) { - m_CursorVisible = false; - m_LastBlinkTime = 0; + PersistMgr->Transfer(TMEMBER(_cursorBlinkRate)); + PersistMgr->Transfer(TMEMBER(_cursorChar)); + PersistMgr->Transfer(TMEMBER(_fontSelected)); + PersistMgr->Transfer(TMEMBER(_frameWidth)); + PersistMgr->Transfer(TMEMBER(_maxLength)); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_selEnd)); + PersistMgr->Transfer(TMEMBER(_selStart)); + + if (!PersistMgr->_saving) { + _cursorVisible = false; + _lastBlinkTime = 0; } return S_OK; diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index 134218c877..ccaca4473d 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -37,21 +37,21 @@ class CBFont; class CUIEdit : public CUIObject { public: DECLARE_PERSISTENT(CUIEdit, CUIObject) - int m_MaxLength; + int _maxLength; int InsertChars(int Pos, byte *Chars, int Num); int DeleteChars(int Start, int End); - bool m_CursorVisible; - uint32 m_LastBlinkTime; + bool _cursorVisible; + uint32 _lastBlinkTime; virtual HRESULT Display(int OffsetX, int OffsetY); virtual bool HandleKeypress(SDL_Event *event); - int m_ScrollOffset; - int m_FrameWidth; - uint32 m_CursorBlinkRate; + int _scrollOffset; + int _frameWidth; + uint32 _cursorBlinkRate; void SetCursorChar(char *Char); - char *m_CursorChar; - int m_SelEnd; - int m_SelStart; - CBFont *m_FontSelected; + char *_cursorChar; + int _selEnd; + int _selStart; + CBFont *_fontSelected; CUIEdit(CBGame *inGame); virtual ~CUIEdit(); diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index 2cf7a3096f..b91e226a3e 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -42,21 +42,21 @@ IMPLEMENT_PERSISTENT(CUIEntity, false) ////////////////////////////////////////////////////////////////////////// CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { - m_Type = UI_CUSTOM; - m_Entity = NULL; + _type = UI_CUSTOM; + _entity = NULL; } ////////////////////////////////////////////////////////////////////////// CUIEntity::~CUIEntity() { - if (m_Entity) Game->UnregisterObject(m_Entity); - m_Entity = NULL; + if (_entity) Game->UnregisterObject(_entity); + _entity = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -64,8 +64,8 @@ HRESULT CUIEntity::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); @@ -126,19 +126,19 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &m_Disable); + parser.ScanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &m_Visible); + parser.ScanStr((char *)params, "%b", &_visible); break; case TOKEN_ENTITY: @@ -165,9 +165,9 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { CorrectSize(); - if (Game->m_EditorMode) { - m_Width = 50; - m_Height = 50; + if (Game->_editorMode) { + _width = 50; + _height = 50; } return S_OK; @@ -178,24 +178,24 @@ HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - if (m_Entity && m_Entity->m_Filename) - Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", m_Entity->m_Filename); + if (_entity && _entity->_filename) + Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); Buffer->PutTextIndent(Indent + 2, "\n"); // scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); @@ -209,39 +209,39 @@ HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::SetEntity(char *Filename) { - if (m_Entity) Game->UnregisterObject(m_Entity); - m_Entity = new CAdEntity(Game); - if (!m_Entity || FAILED(m_Entity->LoadFile(Filename))) { - delete m_Entity; - m_Entity = NULL; + if (_entity) Game->UnregisterObject(_entity); + _entity = new CAdEntity(Game); + if (!_entity || FAILED(_entity->LoadFile(Filename))) { + delete _entity; + _entity = NULL; return E_FAIL; } else { - m_Entity->m_NonIntMouseEvents = true; - m_Entity->m_SceneIndependent = true; - m_Entity->MakeFreezable(false); - Game->RegisterObject(m_Entity); + _entity->_nonIntMouseEvents = true; + _entity->_sceneIndependent = true; + _entity->MakeFreezable(false); + Game->RegisterObject(_entity); } return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; - if (m_Entity) { - m_Entity->m_PosX = OffsetX + m_PosX; - m_Entity->m_PosY = OffsetY + m_PosY; - if (m_Entity->m_Scale < 0) m_Entity->m_Zoomable = false; - m_Entity->m_Shadowable = false; + if (_entity) { + _entity->_posX = OffsetX + _posX; + _entity->_posY = OffsetY + _posY; + if (_entity->_scale < 0) _entity->_zoomable = false; + _entity->_shadowable = false; - m_Entity->Update(); + _entity->Update(); - bool OrigReg = m_Entity->m_Registrable; + bool OrigReg = _entity->_registrable; - if (m_Entity->m_Registrable && m_Disable) m_Entity->m_Registrable = false; + if (_entity->_registrable && _disable) _entity->_registrable = false; - m_Entity->Display(); - m_Entity->m_Registrable = OrigReg; + _entity->Display(); + _entity->_registrable = OrigReg; } return S_OK; @@ -258,7 +258,7 @@ HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (strcmp(Name, "GetEntity") == 0) { Stack->CorrectParams(0); - if (m_Entity) Stack->PushNative(m_Entity, true); + if (_entity) Stack->PushNative(_entity, true); else Stack->PushNULL(); return S_OK; @@ -286,23 +286,23 @@ HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CUIEntity::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("entity container"); - return m_ScValue; + _scValue->SetString("entity container"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Freezable") == 0) { - if (m_Entity) m_ScValue->SetBool(m_Entity->m_Freezable); - else m_ScValue->SetBool(false); - return m_ScValue; + if (_entity) _scValue->SetBool(_entity->_freezable); + else _scValue->SetBool(false); + return _scValue; } else return CUIObject::ScGetProperty(Name); @@ -315,7 +315,7 @@ HRESULT CUIEntity::ScSetProperty(char *Name, CScValue *Value) { // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Freezable") == 0) { - if (m_Entity) m_Entity->MakeFreezable(Value->GetBool()); + if (_entity) _entity->MakeFreezable(Value->GetBool()); return S_OK; } else return CUIObject::ScSetProperty(Name, Value); } @@ -332,7 +332,7 @@ HRESULT CUIEntity::Persist(CBPersistMgr *PersistMgr) { CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Entity)); + PersistMgr->Transfer(TMEMBER(_entity)); return S_OK; } diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h index f3c9385b7b..3f4b8c9ee2 100644 --- a/engines/wintermute/UIEntity.h +++ b/engines/wintermute/UIEntity.h @@ -43,7 +43,7 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - CAdEntity *m_Entity; + CAdEntity *_entity; HRESULT SetEntity(char *Filename); // scripting interface diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index 4ff0952bd7..bf0cad25b9 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -42,56 +42,56 @@ IMPLEMENT_PERSISTENT(CUIObject, false) ////////////////////////////////////////////////////////////////////////// CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { - m_Back = NULL; - m_Image = NULL; - m_Font = NULL; - m_Text = NULL; - m_SharedFonts = m_SharedImages = false; + _back = NULL; + _image = NULL; + _font = NULL; + _text = NULL; + _sharedFonts = _sharedImages = false; - m_Width = m_Height = 0; + _width = _height = 0; - m_ListenerObject = NULL; - m_ListenerParamObject = NULL; - m_ListenerParamDWORD = 0; + _listenerObject = NULL; + _listenerParamObject = NULL; + _listenerParamDWORD = 0; - m_Disable = false; - m_Visible = true; + _disable = false; + _visible = true; - m_Type = UI_UNKNOWN; - m_Parent = NULL; + _type = UI_UNKNOWN; + _parent = NULL; - m_ParentNotify = false; + _parentNotify = false; - m_FocusedWidget = NULL; + _focusedWidget = NULL; - m_CanFocus = false; - m_NonIntMouseEvents = true; + _canFocus = false; + _nonIntMouseEvents = true; } ////////////////////////////////////////////////////////////////////////// CUIObject::~CUIObject() { - if (!Game->m_LoadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); + if (!Game->_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); - if (m_Back) delete m_Back; - if (m_Font && !m_SharedFonts) Game->m_FontStorage->RemoveFont(m_Font); + if (_back) delete _back; + if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); - if (m_Image && !m_SharedImages) delete m_Image; + if (_image && !_sharedImages) delete _image; - if (m_Text) delete [] m_Text; + if (_text) delete [] _text; - m_FocusedWidget = NULL; // ref only + _focusedWidget = NULL; // ref only } ////////////////////////////////////////////////////////////////////////// void CUIObject::SetText(const char *Text) { - if (m_Text) delete [] m_Text; - m_Text = new char [strlen(Text) + 1]; - if (m_Text) { - strcpy(m_Text, Text); - for (int i = 0; i < strlen(m_Text); i++) { - if (m_Text[i] == '|') m_Text[i] = '\n'; + if (_text) delete [] _text; + _text = new char [strlen(Text) + 1]; + if (_text) { + strcpy(_text, Text); + for (int i = 0; i < strlen(_text); i++) { + if (_text[i] == '|') _text[i] = '\n'; } } } @@ -105,9 +105,9 @@ HRESULT CUIObject::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { - m_ListenerObject = Object; - m_ListenerParamObject = ListenerObject; - m_ListenerParamDWORD = ListenerParam; + _listenerObject = Object; + _listenerParamObject = ListenerObject; + _listenerParamDWORD = ListenerParam; } @@ -115,21 +115,21 @@ void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObje void CUIObject::CorrectSize() { RECT rect; - if (m_Width <= 0) { - if (m_Image) { - m_Image->GetBoundingRect(&rect, 0, 0); - m_Width = rect.right - rect.left; - } else m_Width = 100; + if (_width <= 0) { + if (_image) { + _image->GetBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; } - if (m_Height <= 0) { - if (m_Image) { - m_Image->GetBoundingRect(&rect, 0, 0); - m_Height = rect.bottom - rect.top; + if (_height <= 0) { + if (_image) { + _image->GetBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; } } - if (m_Back) m_Back->CorrectSize(&m_Width, &m_Height); + if (_back) _back->CorrectSize(&_width, &_height); } @@ -145,13 +145,13 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); + if (_font) Game->_fontStorage->RemoveFont(_font); if (Val->IsNULL()) { - m_Font = NULL; + _font = NULL; Stack->PushBool(true); } else { - m_Font = Game->m_FontStorage->AddFont(Val->GetString()); - Stack->PushBool(m_Font != NULL); + _font = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_font != NULL); } return S_OK; } @@ -165,17 +165,17 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th char *Filename = Val->GetString(); - delete m_Image; - m_Image = NULL; + delete _image; + _image = NULL; if (Val->IsNULL()) { Stack->PushBool(true); return S_OK; } - m_Image = new CBSprite(Game); - if (!m_Image || FAILED(m_Image->LoadFile(Val->GetString()))) { - delete m_Image; - m_Image = NULL; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile(Val->GetString()))) { + delete _image; + _image = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -187,8 +187,8 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetImage") == 0) { Stack->CorrectParams(0); - if (!m_Image || !m_Image->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_Image->m_Filename); + if (!_image || !_image->_filename) Stack->PushNULL(); + else Stack->PushString(_image->_filename); return S_OK; } @@ -198,8 +198,8 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetImageObject") == 0) { Stack->CorrectParams(0); - if (!m_Image) Stack->PushNULL(); - else Stack->PushNative(m_Image, true); + if (!_image) Stack->PushNULL(); + else Stack->PushNative(_image, true); return S_OK; } @@ -220,8 +220,8 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "MoveAfter") == 0 || strcmp(Name, "MoveBefore") == 0) { Stack->CorrectParams(1); - if (m_Parent && m_Parent->m_Type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)m_Parent; + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; int i; bool found = false; @@ -229,8 +229,8 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th // find directly if (val->IsNative()) { CUIObject *widget = (CUIObject *)val->GetNative(); - for (i = 0; i < win->m_Widgets.GetSize(); i++) { - if (win->m_Widgets[i] == widget) { + for (i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == widget) { found = true; break; } @@ -239,8 +239,8 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th // find by name else { char *name = val->GetString(); - for (i = 0; i < win->m_Widgets.GetSize(); i++) { - if (scumm_stricmp(win->m_Widgets[i]->m_Name, name) == 0) { + for (i = 0; i < win->_widgets.GetSize(); i++) { + if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { found = true; break; } @@ -249,13 +249,13 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (found) { bool done = false; - for (int j = 0; j < win->m_Widgets.GetSize(); j++) { - if (win->m_Widgets[j] == this) { + for (int j = 0; j < win->_widgets.GetSize(); j++) { + if (win->_widgets[j] == this) { if (strcmp(Name, "MoveAfter") == 0) i++; if (j >= i) j++; - win->m_Widgets.InsertAt(i, this); - win->m_Widgets.RemoveAt(j); + win->_widgets.InsertAt(i, this); + win->_widgets.RemoveAt(j); done = true; Stack->PushBool(true); @@ -276,12 +276,12 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "MoveToBottom") == 0) { Stack->CorrectParams(0); - if (m_Parent && m_Parent->m_Type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)m_Parent; - for (int i = 0; i < win->m_Widgets.GetSize(); i++) { - if (win->m_Widgets[i] == this) { - win->m_Widgets.RemoveAt(i); - win->m_Widgets.InsertAt(0, this); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.RemoveAt(i); + win->_widgets.InsertAt(0, this); break; } } @@ -297,12 +297,12 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "MoveToTop") == 0) { Stack->CorrectParams(0); - if (m_Parent && m_Parent->m_Type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)m_Parent; - for (int i = 0; i < win->m_Widgets.GetSize(); i++) { - if (win->m_Widgets[i] == this) { - win->m_Widgets.RemoveAt(i); - win->m_Widgets.Add(this); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.RemoveAt(i); + win->_widgets.Add(this); break; } } @@ -318,99 +318,99 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CUIObject::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("ui_object"); - return m_ScValue; + _scValue->SetString("ui_object"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - m_ScValue->SetString(m_Name); - return m_ScValue; + _scValue->SetString(_name); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Parent (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Parent") == 0) { - m_ScValue->SetNative(m_Parent, true); - return m_ScValue; + _scValue->SetNative(_parent, true); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ParentNotify ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ParentNotify") == 0) { - m_ScValue->SetBool(m_ParentNotify); - return m_ScValue; + _scValue->SetBool(_parentNotify); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_ScValue->SetInt(m_Width); - return m_ScValue; + _scValue->SetInt(_width); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_ScValue->SetInt(m_Height); - return m_ScValue; + _scValue->SetInt(_height); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Visible ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Visible") == 0) { - m_ScValue->SetBool(m_Visible); - return m_ScValue; + _scValue->SetBool(_visible); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Disabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Disabled") == 0) { - m_ScValue->SetBool(m_Disable); - return m_ScValue; + _scValue->SetBool(_disable); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Text") == 0) { - m_ScValue->SetString(m_Text); - return m_ScValue; + _scValue->SetString(_text); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NextSibling (RO) / PrevSibling (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NextSibling") == 0 || strcmp(Name, "PrevSibling") == 0) { - m_ScValue->SetNULL(); - if (m_Parent && m_Parent->m_Type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)m_Parent; - for (int i = 0; i < win->m_Widgets.GetSize(); i++) { - if (win->m_Widgets[i] == this) { + _scValue->SetNULL(); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { if (strcmp(Name, "NextSibling") == 0) { - if (i < win->m_Widgets.GetSize() - 1) m_ScValue->SetNative(win->m_Widgets[i + 1], true); + if (i < win->_widgets.GetSize() - 1) _scValue->SetNative(win->_widgets[i + 1], true); } else { - if (i > 0) m_ScValue->SetNative(win->m_Widgets[i - 1], true); + if (i > 0) _scValue->SetNative(win->_widgets[i - 1], true); } break; } } } - return m_ScValue; + return _scValue; } else return CBObject::ScGetProperty(Name); @@ -431,7 +431,7 @@ HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { // ParentNotify ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ParentNotify") == 0) { - m_ParentNotify = Value->GetBool(); + _parentNotify = Value->GetBool(); return S_OK; } @@ -439,7 +439,7 @@ HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Width") == 0) { - m_Width = Value->GetInt(); + _width = Value->GetInt(); return S_OK; } @@ -447,7 +447,7 @@ HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - m_Height = Value->GetInt(); + _height = Value->GetInt(); return S_OK; } @@ -455,7 +455,7 @@ HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { // Visible ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Visible") == 0) { - m_Visible = Value->GetBool(); + _visible = Value->GetBool(); return S_OK; } @@ -463,7 +463,7 @@ HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { // Disabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Disabled") == 0) { - m_Disable = Value->GetBool(); + _disable = Value->GetBool(); return S_OK; } @@ -487,13 +487,13 @@ char *CUIObject::ScToString() { ////////////////////////////////////////////////////////////////////////// bool CUIObject::IsFocused() { - if (!Game->m_FocusedWindow) return false; - if (Game->m_FocusedWindow == this) return true; + if (!Game->_focusedWindow) return false; + if (Game->_focusedWindow == this) return true; - CUIObject *obj = Game->m_FocusedWindow; + CUIObject *obj = Game->_focusedWindow; while (obj) { if (obj == this) return true; - else obj = obj->m_FocusedWidget; + else obj = obj->_focusedWidget; } return false; } @@ -514,22 +514,22 @@ HRESULT CUIObject::Focus() { CUIObject *obj = this; bool disabled = false; while (obj) { - if (obj->m_Disable && obj->m_Type == UI_WINDOW) { + if (obj->_disable && obj->_type == UI_WINDOW) { disabled = true; break; } - obj = obj->m_Parent; + obj = obj->_parent; } if (!disabled) { obj = this; while (obj) { - if (obj->m_Parent) { - if (!obj->m_Disable && obj->m_CanFocus) obj->m_Parent->m_FocusedWidget = obj; + if (obj->_parent) { + if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; } else { - if (obj->m_Type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); + if (obj->_type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); } - obj = obj->m_Parent; + obj = obj->_parent; } } return S_OK; @@ -540,12 +540,12 @@ HRESULT CUIObject::Focus() { HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { int OffX = 0, OffY = 0; - CUIObject *obj = m_Parent; + CUIObject *obj = _parent; while (obj) { - OffX += obj->m_PosX; - OffY += obj->m_PosY; + OffX += obj->_posX; + OffY += obj->_posY; - obj = obj->m_Parent; + obj = obj->_parent; } if (OffsetX) *OffsetX = OffX; if (OffsetY) *OffsetY = OffY; @@ -559,24 +559,24 @@ HRESULT CUIObject::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Back)); - PersistMgr->Transfer(TMEMBER(m_CanFocus)); - PersistMgr->Transfer(TMEMBER(m_Disable)); - PersistMgr->Transfer(TMEMBER(m_FocusedWidget)); - PersistMgr->Transfer(TMEMBER(m_Font)); - PersistMgr->Transfer(TMEMBER(m_Height)); - PersistMgr->Transfer(TMEMBER(m_Image)); - PersistMgr->Transfer(TMEMBER(m_ListenerObject)); - PersistMgr->Transfer(TMEMBER(m_ListenerParamObject)); - PersistMgr->Transfer(TMEMBER(m_ListenerParamDWORD)); - PersistMgr->Transfer(TMEMBER(m_Parent)); - PersistMgr->Transfer(TMEMBER(m_ParentNotify)); - PersistMgr->Transfer(TMEMBER(m_SharedFonts)); - PersistMgr->Transfer(TMEMBER(m_SharedImages)); - PersistMgr->Transfer(TMEMBER(m_Text)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); - PersistMgr->Transfer(TMEMBER(m_Visible)); - PersistMgr->Transfer(TMEMBER(m_Width)); + PersistMgr->Transfer(TMEMBER(_back)); + PersistMgr->Transfer(TMEMBER(_canFocus)); + PersistMgr->Transfer(TMEMBER(_disable)); + PersistMgr->Transfer(TMEMBER(_focusedWidget)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_listenerObject)); + PersistMgr->Transfer(TMEMBER(_listenerParamObject)); + PersistMgr->Transfer(TMEMBER(_listenerParamDWORD)); + PersistMgr->Transfer(TMEMBER(_parent)); + PersistMgr->Transfer(TMEMBER(_parentNotify)); + PersistMgr->Transfer(TMEMBER(_sharedFonts)); + PersistMgr->Transfer(TMEMBER(_sharedImages)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_visible)); + PersistMgr->Transfer(TMEMBER(_width)); return S_OK; } diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h index 9742307504..bf6b1b079a 100644 --- a/engines/wintermute/UIObject.h +++ b/engines/wintermute/UIObject.h @@ -41,34 +41,34 @@ class CUIObject : public CBObject { public: HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); - bool m_CanFocus; + bool _canFocus; HRESULT Focus(); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); bool IsFocused(); - bool m_ParentNotify; + bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) - CUIObject *m_Parent; + CUIObject *_parent; virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); virtual void CorrectSize(); - bool m_SharedFonts; - bool m_SharedImages; + bool _sharedFonts; + bool _sharedImages; void SetText(const char *Text); - char *m_Text; - CBFont *m_Font; - bool m_Visible; - CUITiledImage *m_Back; - bool m_Disable; + char *_text; + CBFont *_font; + bool _visible; + CUITiledImage *_back; + bool _disable; CUIObject(CBGame *inGame = NULL); virtual ~CUIObject(); - int m_Width; - int m_Height; - TUIObjectType m_Type; - CBSprite *m_Image; + int _width; + int _height; + TUIObjectType _type; + CBSprite *_image; void SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); - CBScriptHolder *m_ListenerParamObject; - uint32 m_ListenerParamDWORD; - CBScriptHolder *m_ListenerObject; - CUIObject *m_FocusedWidget; + CBScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + CBScriptHolder *_listenerObject; + CUIObject *_focusedWidget; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 524d1eec91..c0ecc60eac 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -48,10 +48,10 @@ IMPLEMENT_PERSISTENT(CUIText, false) ////////////////////////////////////////////////////////////////////////// CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { - m_TextAlign = TAL_LEFT; - m_VerticalAlign = VAL_CENTER; - m_Type = UI_STATIC; - m_CanFocus = false; + _textAlign = TAL_LEFT; + _verticalAlign = VAL_CENTER; + _type = UI_STATIC; + _canFocus = false; } @@ -63,31 +63,31 @@ CUIText::~CUIText() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::Display(int OffsetX, int OffsetY) { - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; - CBFont *font = m_Font; - if (!font) font = Game->m_SystemFont; + CBFont *font = _font; + if (!font) font = Game->_systemFont; - if (m_Back) m_Back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height); - if (m_Image) m_Image->Draw(OffsetX + m_PosX, OffsetY + m_PosY, NULL); + if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); - if (font && m_Text) { + if (font && _text) { int text_offset; - switch (m_VerticalAlign) { + switch (_verticalAlign) { case VAL_TOP: text_offset = 0; break; case VAL_BOTTOM: - text_offset = m_Height - font->GetTextHeight((byte *)m_Text, m_Width); + text_offset = _height - font->GetTextHeight((byte *)_text, _width); break; default: - text_offset = (m_Height - font->GetTextHeight((byte *)m_Text, m_Width)) / 2; + text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; } - font->DrawText((byte *)m_Text, OffsetX + m_PosX, OffsetY + m_PosY + text_offset, m_Width, m_TextAlign, m_Height); + font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); } - //Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false)); + //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); return S_OK; } @@ -96,7 +96,7 @@ HRESULT CUIText::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -104,8 +104,8 @@ HRESULT CUIText::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); @@ -189,70 +189,70 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BACK: - delete m_Back; - m_Back = new CUITiledImage(Game); - if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { - delete m_Back; - m_Back = NULL; + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE: - delete m_Image; - m_Image = new CBSprite(Game); - if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { - delete m_Image; - m_Image = NULL; + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_FONT: - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont((char *)params); - if (!m_Font) cmd = PARSERR_GENERIC; + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: SetText((char *)params); - Game->m_StringTable->Expand(&m_Text); + Game->_stringTable->Expand(&_text); break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) m_TextAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) m_TextAlign = TAL_RIGHT; - else m_TextAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; + else _textAlign = TAL_CENTER; break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) m_VerticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "bottom") == 0) m_VerticalAlign = VAL_BOTTOM; - else m_VerticalAlign = VAL_CENTER; + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; + else _verticalAlign = VAL_CENTER; break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &m_Width); + parser.ScanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_Height); + parser.ScanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -262,15 +262,15 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &m_ParentNotify); + parser.ScanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &m_Disable); + parser.ScanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &m_Visible); + parser.ScanStr((char *)params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: @@ -297,27 +297,27 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "STATIC\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Back && m_Back->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (m_Image && m_Image->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - if (m_Text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", m_Text); + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - switch (m_TextAlign) { + switch (_textAlign) { case TAL_LEFT: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; @@ -329,7 +329,7 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { break; } - switch (m_VerticalAlign) { + switch (_verticalAlign) { case VAL_TOP: Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; @@ -343,20 +343,20 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "\n"); // scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); @@ -387,7 +387,7 @@ HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HeightToFit") == 0) { Stack->CorrectParams(0); - if (m_Font && m_Text) m_Height = m_Font->GetTextHeight((byte *)m_Text, m_Width); + if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); Stack->PushNULL(); return S_OK; } @@ -398,30 +398,30 @@ HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CUIText::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("static"); - return m_ScValue; + _scValue->SetString("static"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextAlign") == 0) { - m_ScValue->SetInt(m_TextAlign); - return m_ScValue; + _scValue->SetInt(_textAlign); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // VerticalAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "VerticalAlign") == 0) { - m_ScValue->SetInt(m_VerticalAlign); - return m_ScValue; + _scValue->SetInt(_verticalAlign); + return _scValue; } else return CUIObject::ScGetProperty(Name); @@ -436,7 +436,7 @@ HRESULT CUIText::ScSetProperty(char *Name, CScValue *Value) { if (strcmp(Name, "TextAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - m_TextAlign = (TTextAlign)i; + _textAlign = (TTextAlign)i; return S_OK; } @@ -446,7 +446,7 @@ HRESULT CUIText::ScSetProperty(char *Name, CScValue *Value) { else if (strcmp(Name, "VerticalAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; - m_VerticalAlign = (TVerticalAlign)i; + _verticalAlign = (TVerticalAlign)i; return S_OK; } @@ -465,8 +465,8 @@ char *CUIText::ScToString() { HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(m_TextAlign)); - PersistMgr->Transfer(TMEMBER_INT(m_VerticalAlign)); + PersistMgr->Transfer(TMEMBER_INT(_textAlign)); + PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); return S_OK; } @@ -474,9 +474,9 @@ HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::SizeToFit() { - if (m_Font && m_Text) { - m_Width = m_Font->GetTextWidth((byte *)m_Text); - m_Height = m_Font->GetTextHeight((byte *)m_Text, m_Width); + if (_font && _text) { + _width = _font->GetTextWidth((byte *)_text); + _height = _font->GetTextHeight((byte *)_text, _width); } return S_OK; } diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h index 74158cb636..cdd0acbc48 100644 --- a/engines/wintermute/UIText.h +++ b/engines/wintermute/UIText.h @@ -41,8 +41,8 @@ public: DECLARE_PERSISTENT(CUIText, CUIObject) CUIText(CBGame *inGame = NULL); virtual ~CUIText(); - TTextAlign m_TextAlign; - TVerticalAlign m_VerticalAlign; + TTextAlign _textAlign; + TVerticalAlign _verticalAlign; HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp index c85ea38a5e..44d78845a3 100644 --- a/engines/wintermute/UITiledImage.cpp +++ b/engines/wintermute/UITiledImage.cpp @@ -42,77 +42,77 @@ IMPLEMENT_PERSISTENT(CUITiledImage, false) ////////////////////////////////////////////////////////////////////////// CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { - m_Image = NULL; - - CBPlatform::SetRectEmpty(&m_UpLeft); - CBPlatform::SetRectEmpty(&m_UpMiddle); - CBPlatform::SetRectEmpty(&m_UpRight); - CBPlatform::SetRectEmpty(&m_MiddleLeft); - CBPlatform::SetRectEmpty(&m_MiddleMiddle); - CBPlatform::SetRectEmpty(&m_MiddleRight); - CBPlatform::SetRectEmpty(&m_DownLeft); - CBPlatform::SetRectEmpty(&m_DownMiddle); - CBPlatform::SetRectEmpty(&m_DownRight); + _image = NULL; + + CBPlatform::SetRectEmpty(&_upLeft); + CBPlatform::SetRectEmpty(&_upMiddle); + CBPlatform::SetRectEmpty(&_upRight); + CBPlatform::SetRectEmpty(&_middleLeft); + CBPlatform::SetRectEmpty(&_middleMiddle); + CBPlatform::SetRectEmpty(&_middleRight); + CBPlatform::SetRectEmpty(&_downLeft); + CBPlatform::SetRectEmpty(&_downMiddle); + CBPlatform::SetRectEmpty(&_downRight); } ////////////////////////////////////////////////////////////////////////// CUITiledImage::~CUITiledImage() { - delete m_Image; - m_Image = NULL; + delete _image; + _image = NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { - if (!m_Image) return E_FAIL; + if (!_image) return E_FAIL; - int tile_width = m_MiddleMiddle.right - m_MiddleMiddle.left; - int tile_height = m_MiddleMiddle.bottom - m_MiddleMiddle.top; + int tile_width = _middleMiddle.right - _middleMiddle.left; + int tile_height = _middleMiddle.bottom - _middleMiddle.top; - int num_columns = (Width - (m_MiddleLeft.right - m_MiddleLeft.left) - (m_MiddleRight.right - m_MiddleRight.left)) / tile_width; - int num_rows = (Height - (m_UpMiddle.bottom - m_UpMiddle.top) - (m_DownMiddle.bottom - m_DownMiddle.top)) / tile_height; + int nu_columns = (Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; + int nu_rows = (Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; int col, row; - Game->m_Renderer->StartSpriteBatch(); + Game->_renderer->StartSpriteBatch(); // top left/right - m_Image->m_Surface->DisplayTrans(X, Y, m_UpLeft); - m_Image->m_Surface->DisplayTrans(X + (m_UpLeft.right - m_UpLeft.left) + num_columns * tile_width, Y, m_UpRight); + _image->_surface->DisplayTrans(X, Y, _upLeft); + _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); // bottom left/right - m_Image->m_Surface->DisplayTrans(X, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownLeft); - m_Image->m_Surface->DisplayTrans(X + (m_UpLeft.right - m_UpLeft.left) + num_columns * tile_width, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownRight); + _image->_surface->DisplayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); + _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); // left/right - int yyy = Y + (m_UpMiddle.bottom - m_UpMiddle.top); - for (row = 0; row < num_rows; row++) { - m_Image->m_Surface->DisplayTrans(X, yyy, m_MiddleLeft); - m_Image->m_Surface->DisplayTrans(X + (m_MiddleLeft.right - m_MiddleLeft.left) + num_columns * tile_width, yyy, m_MiddleRight); + int yyy = Y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nu_rows; row++) { + _image->_surface->DisplayTrans(X, yyy, _middleLeft); + _image->_surface->DisplayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); yyy += tile_width; } // top/bottom - int xxx = X + (m_UpLeft.right - m_UpLeft.left); - for (col = 0; col < num_columns; col++) { - m_Image->m_Surface->DisplayTrans(xxx, Y, m_UpMiddle); - m_Image->m_Surface->DisplayTrans(xxx, Y + (m_UpMiddle.bottom - m_UpMiddle.top) + num_rows * tile_height, m_DownMiddle); + int xxx = X + (_upLeft.right - _upLeft.left); + for (col = 0; col < nu_columns; col++) { + _image->_surface->DisplayTrans(xxx, Y, _upMiddle); + _image->_surface->DisplayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); xxx += tile_width; } // tiles - yyy = Y + (m_UpMiddle.bottom - m_UpMiddle.top); - for (row = 0; row < num_rows; row++) { - xxx = X + (m_UpLeft.right - m_UpLeft.left); - for (col = 0; col < num_columns; col++) { - m_Image->m_Surface->DisplayTrans(xxx, yyy, m_MiddleMiddle); + yyy = Y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nu_rows; row++) { + xxx = X + (_upLeft.right - _upLeft.left); + for (col = 0; col < nu_columns; col++) { + _image->_surface->DisplayTrans(xxx, yyy, _middleMiddle); xxx += tile_width; } yyy += tile_width; } - Game->m_Renderer->EndSpriteBatch(); + Game->_renderer->EndSpriteBatch(); return S_OK; } @@ -120,7 +120,7 @@ HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// HRESULT CUITiledImage::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -128,8 +128,8 @@ HRESULT CUITiledImage::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); @@ -199,49 +199,49 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_IMAGE: - delete m_Image; - m_Image = new CBSubFrame(Game); - if (!m_Image || FAILED(m_Image->SetSurface((char *)params))) { - delete m_Image; - m_Image = NULL; + delete _image; + _image = new CBSubFrame(Game); + if (!_image || FAILED(_image->SetSurface((char *)params))) { + delete _image; + _image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_UP_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpLeft.left, &m_UpLeft.top, &m_UpLeft.right, &m_UpLeft.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); break; case TOKEN_UP_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpRight.left, &m_UpRight.top, &m_UpRight.right, &m_UpRight.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); break; case TOKEN_UP_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_UpMiddle.left, &m_UpMiddle.top, &m_UpMiddle.right, &m_UpMiddle.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); break; case TOKEN_DOWN_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownLeft.left, &m_DownLeft.top, &m_DownLeft.right, &m_DownLeft.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); break; case TOKEN_DOWN_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownRight.left, &m_DownRight.top, &m_DownRight.right, &m_DownRight.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); break; case TOKEN_DOWN_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DownMiddle.left, &m_DownMiddle.top, &m_DownMiddle.right, &m_DownMiddle.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); break; case TOKEN_MIDDLE_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleLeft.left, &m_MiddleLeft.top, &m_MiddleLeft.right, &m_MiddleLeft.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); break; case TOKEN_MIDDLE_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleRight.left, &m_MiddleRight.top, &m_MiddleRight.right, &m_MiddleRight.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); break; case TOKEN_MIDDLE_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_MiddleMiddle.left, &m_MiddleMiddle.top, &m_MiddleMiddle.right, &m_MiddleMiddle.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); break; case TOKEN_HORIZONTAL_TILES: @@ -270,37 +270,37 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { if (VTiles && HTiles) { // up row - CBPlatform::SetRect(&m_UpLeft, 0, 0, H1, V1); - CBPlatform::SetRect(&m_UpMiddle, H1, 0, H1 + H2, V1); - CBPlatform::SetRect(&m_UpRight, H1 + H2, 0, H1 + H2 + H3, V1); + CBPlatform::SetRect(&_upLeft, 0, 0, H1, V1); + CBPlatform::SetRect(&_upMiddle, H1, 0, H1 + H2, V1); + CBPlatform::SetRect(&_upRight, H1 + H2, 0, H1 + H2 + H3, V1); // middle row - CBPlatform::SetRect(&m_MiddleLeft, 0, V1, H1, V1 + V2); - CBPlatform::SetRect(&m_MiddleMiddle, H1, V1, H1 + H2, V1 + V2); - CBPlatform::SetRect(&m_MiddleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); + CBPlatform::SetRect(&_middleLeft, 0, V1, H1, V1 + V2); + CBPlatform::SetRect(&_middleMiddle, H1, V1, H1 + H2, V1 + V2); + CBPlatform::SetRect(&_middleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); // down row - CBPlatform::SetRect(&m_DownLeft, 0, V1 + V2, H1, V1 + V2 + V3); - CBPlatform::SetRect(&m_DownMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); - CBPlatform::SetRect(&m_DownRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); + CBPlatform::SetRect(&_downLeft, 0, V1 + V2, H1, V1 + V2 + V3); + CBPlatform::SetRect(&_downMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); + CBPlatform::SetRect(&_downRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); } // default - if (m_Image && m_Image->m_Surface) { - int Width = m_Image->m_Surface->GetWidth() / 3; - int Height = m_Image->m_Surface->GetHeight() / 3; + if (_image && _image->_surface) { + int Width = _image->_surface->GetWidth() / 3; + int Height = _image->_surface->GetHeight() / 3; - if (CBPlatform::IsRectEmpty(&m_UpLeft)) CBPlatform::SetRect(&m_UpLeft, 0, 0, Width, Height); - if (CBPlatform::IsRectEmpty(&m_UpMiddle)) CBPlatform::SetRect(&m_UpMiddle, Width, 0, 2 * Width, Height); - if (CBPlatform::IsRectEmpty(&m_UpRight)) CBPlatform::SetRect(&m_UpRight, 2 * Width, 0, 3 * Width, Height); + if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, Width, Height); + if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, Width, 0, 2 * Width, Height); + if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * Width, 0, 3 * Width, Height); - if (CBPlatform::IsRectEmpty(&m_MiddleLeft)) CBPlatform::SetRect(&m_MiddleLeft, 0, Height, Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&m_MiddleMiddle)) CBPlatform::SetRect(&m_MiddleMiddle, Width, Height, 2 * Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&m_MiddleRight)) CBPlatform::SetRect(&m_MiddleRight, 2 * Width, Height, 3 * Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, Height, Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, Width, Height, 2 * Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * Width, Height, 3 * Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&m_DownLeft)) CBPlatform::SetRect(&m_DownLeft, 0, 2 * Height, Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&m_DownMiddle)) CBPlatform::SetRect(&m_DownMiddle, Width, 2 * Height, 2 * Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&m_DownRight)) CBPlatform::SetRect(&m_DownRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * Height, Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, Width, 2 * Height, 2 * Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); } return S_OK; @@ -311,19 +311,19 @@ HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); Buffer->PutTextIndent(Indent, "{\n"); - if (m_Image && m_Image->m_SurfaceFilename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_SurfaceFilename); + if (_image && _image->_surfaceFilename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); int H1, H2, H3; int V1, V2, V3; - H1 = m_UpLeft.right; - H2 = m_UpMiddle.right - m_UpMiddle.left; - H3 = m_UpRight.right - m_UpRight.left; + H1 = _upLeft.right; + H2 = _upMiddle.right - _upMiddle.left; + H3 = _upRight.right - _upRight.left; - V1 = m_UpLeft.bottom; - V2 = m_MiddleLeft.bottom - m_MiddleLeft.top; - V3 = m_DownLeft.bottom - m_DownLeft.top; + V1 = _upLeft.bottom; + V2 = _middleLeft.bottom - _middleLeft.top; + V3 = _downLeft.bottom - _downLeft.top; Buffer->PutTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); @@ -338,14 +338,14 @@ HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// void CUITiledImage::CorrectSize(int *Width, int *Height) { - int tile_width = m_MiddleMiddle.right - m_MiddleMiddle.left; - int tile_height = m_MiddleMiddle.bottom - m_MiddleMiddle.top; + int tile_width = _middleMiddle.right - _middleMiddle.left; + int tile_height = _middleMiddle.bottom - _middleMiddle.top; - int num_columns = (*Width - (m_MiddleLeft.right - m_MiddleLeft.left) - (m_MiddleRight.right - m_MiddleRight.left)) / tile_width; - int num_rows = (*Height - (m_UpMiddle.bottom - m_UpMiddle.top) - (m_DownMiddle.bottom - m_DownMiddle.top)) / tile_height; + int nu_columns = (*Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; + int nu_rows = (*Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; - *Width = (m_MiddleLeft.right - m_MiddleLeft.left) + (m_MiddleRight.right - m_MiddleRight.left) + num_columns * tile_width; - *Height = (m_UpMiddle.bottom - m_UpMiddle.top) + (m_DownMiddle.bottom - m_DownMiddle.top) + num_rows * tile_height; + *Width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nu_columns * tile_width; + *Height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nu_rows * tile_height; } @@ -353,16 +353,16 @@ void CUITiledImage::CorrectSize(int *Width, int *Height) { HRESULT CUITiledImage::Persist(CBPersistMgr *PersistMgr) { CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_DownLeft)); - PersistMgr->Transfer(TMEMBER(m_DownMiddle)); - PersistMgr->Transfer(TMEMBER(m_DownRight)); - PersistMgr->Transfer(TMEMBER(m_Image)); - PersistMgr->Transfer(TMEMBER(m_MiddleLeft)); - PersistMgr->Transfer(TMEMBER(m_MiddleMiddle)); - PersistMgr->Transfer(TMEMBER(m_MiddleRight)); - PersistMgr->Transfer(TMEMBER(m_UpLeft)); - PersistMgr->Transfer(TMEMBER(m_UpMiddle)); - PersistMgr->Transfer(TMEMBER(m_UpRight)); + PersistMgr->Transfer(TMEMBER(_downLeft)); + PersistMgr->Transfer(TMEMBER(_downMiddle)); + PersistMgr->Transfer(TMEMBER(_downRight)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_middleLeft)); + PersistMgr->Transfer(TMEMBER(_middleMiddle)); + PersistMgr->Transfer(TMEMBER(_middleRight)); + PersistMgr->Transfer(TMEMBER(_upLeft)); + PersistMgr->Transfer(TMEMBER(_upMiddle)); + PersistMgr->Transfer(TMEMBER(_upRight)); return S_OK; } diff --git a/engines/wintermute/UITiledImage.h b/engines/wintermute/UITiledImage.h index e97b27f59e..6cee8ae6cc 100644 --- a/engines/wintermute/UITiledImage.h +++ b/engines/wintermute/UITiledImage.h @@ -45,16 +45,16 @@ public: HRESULT Display(int X, int Y, int Width, int Height); CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); - CBSubFrame *m_Image; - RECT m_UpLeft; - RECT m_UpMiddle; - RECT m_UpRight; - RECT m_MiddleLeft; - RECT m_MiddleMiddle; - RECT m_MiddleRight; - RECT m_DownLeft; - RECT m_DownMiddle; - RECT m_DownRight; + CBSubFrame *_image; + RECT _upLeft; + RECT _upMiddle; + RECT _upRight; + RECT _middleLeft; + RECT _middleMiddle; + RECT _middleRight; + RECT _downLeft; + RECT _downMiddle; + RECT _downRight; }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index 86e3eada49..a6ab142238 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -54,36 +54,36 @@ IMPLEMENT_PERSISTENT(CUIWindow, false) ////////////////////////////////////////////////////////////////////////// CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::SetRectEmpty(&m_TitleRect); - CBPlatform::SetRectEmpty(&m_DragRect); - m_TitleAlign = TAL_LEFT; - m_Transparent = false; + CBPlatform::SetRectEmpty(&_titleRect); + CBPlatform::SetRectEmpty(&_dragRect); + _titleAlign = TAL_LEFT; + _transparent = false; - m_BackInactive = NULL; - m_FontInactive = NULL; - m_ImageInactive = NULL; + _backInactive = NULL; + _fontInactive = NULL; + _imageInactive = NULL; - m_Type = UI_WINDOW; - m_CanFocus = true; + _type = UI_WINDOW; + _canFocus = true; - m_Dragging = false; - m_DragFrom.x = m_DragFrom.y = 0; + _dragging = false; + _dragFrom.x = _dragFrom.y = 0; - m_Mode = WINDOW_NORMAL; - m_ShieldWindow = NULL; - m_ShieldButton = NULL; + _mode = WINDOW_NORMAL; + _shieldWindow = NULL; + _shieldButton = NULL; - m_FadeColor = 0x00000000; - m_FadeBackground = false; + _fadeColor = 0x00000000; + _fadeBackground = false; - m_Ready = true; - m_IsMenu = false; - m_InGame = false; + _ready = true; + _isMenu = false; + _inGame = false; - m_ClipContents = false; - m_Viewport = NULL; + _clipContents = false; + _viewport = NULL; - m_PauseMusic = true; + _pauseMusic = true; } @@ -96,102 +96,102 @@ CUIWindow::~CUIWindow() { ////////////////////////////////////////////////////////////////////////// void CUIWindow::Cleanup() { - delete m_ShieldWindow; - delete m_ShieldButton; - delete m_Viewport; - m_ShieldWindow = NULL; - m_ShieldButton = NULL; - m_Viewport = NULL; - - if (m_BackInactive) delete m_BackInactive; - if (!m_SharedFonts && m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); - if (!m_SharedImages && m_ImageInactive) delete m_ImageInactive; - - for (int i = 0; i < m_Widgets.GetSize(); i++) delete m_Widgets[i]; - m_Widgets.RemoveAll(); + delete _shieldWindow; + delete _shieldButton; + delete _viewport; + _shieldWindow = NULL; + _shieldButton = NULL; + _viewport = NULL; + + if (_backInactive) delete _backInactive; + if (!_sharedFonts && _fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + if (!_sharedImages && _imageInactive) delete _imageInactive; + + for (int i = 0; i < _widgets.GetSize(); i++) delete _widgets[i]; + _widgets.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { // go exclusive - if (m_Mode == WINDOW_EXCLUSIVE || m_Mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!m_ShieldWindow) m_ShieldWindow = new CUIWindow(Game); - if (m_ShieldWindow) { - m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; - m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; - m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; - - m_ShieldWindow->Display(); + if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; + + _shieldWindow->Display(); } - } else if (m_IsMenu) { - if (!m_ShieldButton) { - m_ShieldButton = new CUIButton(Game); - m_ShieldButton->SetName("close"); - m_ShieldButton->SetListener(this, m_ShieldButton, 0); - m_ShieldButton->m_Parent = this; + } else if (_isMenu) { + if (!_shieldButton) { + _shieldButton = new CUIButton(Game); + _shieldButton->SetName("close"); + _shieldButton->SetListener(this, _shieldButton, 0); + _shieldButton->_parent = this; } - if (m_ShieldButton) { - m_ShieldButton->m_PosX = m_ShieldButton->m_PosY = 0; - m_ShieldButton->m_Width = Game->m_Renderer->m_Width; - m_ShieldButton->m_Height = Game->m_Renderer->m_Height; + if (_shieldButton) { + _shieldButton->_posX = _shieldButton->_posY = 0; + _shieldButton->_width = Game->_renderer->_width; + _shieldButton->_height = Game->_renderer->_height; - m_ShieldButton->Display(); + _shieldButton->Display(); } } - if (!m_Visible) return S_OK; + if (!_visible) return S_OK; - if (m_FadeBackground) Game->m_Renderer->FadeToColor(m_FadeColor); + if (_fadeBackground) Game->_renderer->FadeToColor(_fadeColor); - if (m_Dragging) { - m_PosX += (Game->m_MousePos.x - m_DragFrom.x); - m_PosY += (Game->m_MousePos.y - m_DragFrom.y); + if (_dragging) { + _posX += (Game->_mousePos.x - _dragFrom.x); + _posY += (Game->_mousePos.y - _dragFrom.y); - m_DragFrom.x = Game->m_MousePos.x; - m_DragFrom.y = Game->m_MousePos.y; + _dragFrom.x = Game->_mousePos.x; + _dragFrom.y = Game->_mousePos.y; } - if (!m_FocusedWidget || (!m_FocusedWidget->m_CanFocus || m_FocusedWidget->m_Disable || !m_FocusedWidget->m_Visible)) { + if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { MoveFocus(); } bool PopViewport = false; - if (m_ClipContents) { - if (!m_Viewport) m_Viewport = new CBViewport(Game); - if (m_Viewport) { - m_Viewport->SetRect(m_PosX + OffsetX, m_PosY + OffsetY, m_PosX + m_Width + OffsetX, m_PosY + m_Height + OffsetY); - Game->PushViewport(m_Viewport); + if (_clipContents) { + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) { + _viewport->SetRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); + Game->PushViewport(_viewport); PopViewport = true; } } - CUITiledImage *back = m_Back; - CBSprite *image = m_Image; - CBFont *font = m_Font; + CUITiledImage *back = _back; + CBSprite *image = _image; + CBFont *font = _font; if (!IsFocused()) { - if (m_BackInactive) back = m_BackInactive; - if (m_ImageInactive) image = m_ImageInactive; - if (m_FontInactive) font = m_FontInactive; + if (_backInactive) back = _backInactive; + if (_imageInactive) image = _imageInactive; + if (_fontInactive) font = _fontInactive; } - if (m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = m_AlphaColor; - if (back) back->Display(m_PosX + OffsetX, m_PosY + OffsetY, m_Width, m_Height); - if (image) image->Draw(m_PosX + OffsetX, m_PosY + OffsetY, m_Transparent ? NULL : this); + if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; + if (back) back->Display(_posX + OffsetX, _posY + OffsetY, _width, _height); + if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); - if (!CBPlatform::IsRectEmpty(&m_TitleRect) && font && m_Text) { - font->DrawText((byte *)m_Text, m_PosX + OffsetX + m_TitleRect.left, m_PosY + OffsetY + m_TitleRect.top, m_TitleRect.right - m_TitleRect.left, m_TitleAlign, m_TitleRect.bottom - m_TitleRect.top); + if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { + font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } - if (!m_Transparent && !image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, m_PosX + OffsetX, m_PosY + OffsetY, m_Width, m_Height, 100, 100, false)); + if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); - for (int i = 0; i < m_Widgets.GetSize(); i++) { - m_Widgets[i]->Display(m_PosX + OffsetX, m_PosY + OffsetY); + for (int i = 0; i < _widgets.GetSize(); i++) { + _widgets[i]->Display(_posX + OffsetX, _posY + OffsetY); } - if (m_AlphaColor != 0) Game->m_Renderer->m_ForceAlphaColor = 0; + if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; if (PopViewport) Game->PopViewport(); @@ -201,7 +201,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::LoadFile(char *Filename) { - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -209,8 +209,8 @@ HRESULT CUIWindow::LoadFile(char *Filename) { HRESULT ret; - m_Filename = new char [strlen(Filename) + 1]; - strcpy(m_Filename, Filename); + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); @@ -329,98 +329,98 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BACK: - delete m_Back; - m_Back = new CUITiledImage(Game); - if (!m_Back || FAILED(m_Back->LoadFile((char *)params))) { - delete m_Back; - m_Back = NULL; + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_BACK_INACTIVE: - delete m_BackInactive; - m_BackInactive = new CUITiledImage(Game); - if (!m_BackInactive || FAILED(m_BackInactive->LoadFile((char *)params))) { - delete m_BackInactive; - m_BackInactive = NULL; + delete _backInactive; + _backInactive = new CUITiledImage(Game); + if (!_backInactive || FAILED(_backInactive->LoadFile((char *)params))) { + delete _backInactive; + _backInactive = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE: - delete m_Image; - m_Image = new CBSprite(Game); - if (!m_Image || FAILED(m_Image->LoadFile((char *)params))) { - delete m_Image; - m_Image = NULL; + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_IMAGE_INACTIVE: - delete m_ImageInactive, - m_ImageInactive = new CBSprite(Game); - if (!m_ImageInactive || FAILED(m_ImageInactive->LoadFile((char *)params))) { - delete m_ImageInactive; - m_ImageInactive = NULL; + delete _imageInactive, + _imageInactive = new CBSprite(Game); + if (!_imageInactive || FAILED(_imageInactive->LoadFile((char *)params))) { + delete _imageInactive; + _imageInactive = NULL; cmd = PARSERR_GENERIC; } break; case TOKEN_FONT: - if (m_Font) Game->m_FontStorage->RemoveFont(m_Font); - m_Font = Game->m_FontStorage->AddFont((char *)params); - if (!m_Font) cmd = PARSERR_GENERIC; + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_INACTIVE: - if (m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); - m_FontInactive = Game->m_FontStorage->AddFont((char *)params); - if (!m_FontInactive) cmd = PARSERR_GENERIC; + if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + _fontInactive = Game->_fontStorage->AddFont((char *)params); + if (!_fontInactive) cmd = PARSERR_GENERIC; break; case TOKEN_TITLE: SetText((char *)params); - Game->m_StringTable->Expand(&m_Text); + Game->_stringTable->Expand(&_text); break; case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) m_TitleAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) m_TitleAlign = TAL_RIGHT; - else m_TitleAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; + else _titleAlign = TAL_CENTER; break; case TOKEN_TITLE_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_TitleRect.left, &m_TitleRect.top, &m_TitleRect.right, &m_TitleRect.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); break; case TOKEN_DRAG_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &m_DragRect.left, &m_DragRect.top, &m_DragRect.right, &m_DragRect.bottom); + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &m_PosX); + parser.ScanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &m_PosY); + parser.ScanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &m_Width); + parser.ScanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &m_Height); + parser.ScanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: - delete m_Cursor; - m_Cursor = new CBSprite(Game); - if (!m_Cursor || FAILED(m_Cursor->LoadFile((char *)params))) { - delete m_Cursor; - m_Cursor = NULL; + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -432,8 +432,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { btn = NULL; cmd = PARSERR_GENERIC; } else { - btn->m_Parent = this; - m_Widgets.Add(btn); + btn->_parent = this; + _widgets.Add(btn); } } break; @@ -445,8 +445,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { text = NULL; cmd = PARSERR_GENERIC; } else { - text->m_Parent = this; - m_Widgets.Add(text); + text->_parent = this; + _widgets.Add(text); } } break; @@ -458,8 +458,8 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { edit = NULL; cmd = PARSERR_GENERIC; } else { - edit->m_Parent = this; - m_Widgets.Add(edit); + edit->_parent = this; + _widgets.Add(edit); } } break; @@ -471,15 +471,15 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { win = NULL; cmd = PARSERR_GENERIC; } else { - win->m_Parent = this; - m_Widgets.Add(win); + win->_parent = this; + _widgets.Add(win); } } break; case TOKEN_TRANSPARENT: - parser.ScanStr((char *)params, "%b", &m_Transparent); + parser.ScanStr((char *)params, "%b", &_transparent); break; case TOKEN_SCRIPT: @@ -487,41 +487,41 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &m_ParentNotify); + parser.ScanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_PAUSE_MUSIC: - parser.ScanStr((char *)params, "%b", &m_PauseMusic); + parser.ScanStr((char *)params, "%b", &_pauseMusic); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &m_Disable); + parser.ScanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &m_Visible); + parser.ScanStr((char *)params, "%b", &_visible); break; case TOKEN_MENU: - parser.ScanStr((char *)params, "%b", &m_IsMenu); + parser.ScanStr((char *)params, "%b", &_isMenu); break; case TOKEN_IN_GAME: - parser.ScanStr((char *)params, "%b", &m_InGame); + parser.ScanStr((char *)params, "%b", &_inGame); break; case TOKEN_CLIP_CONTENTS: - parser.ScanStr((char *)params, "%b", &m_ClipContents); + parser.ScanStr((char *)params, "%b", &_clipContents); break; case TOKEN_FADE_COLOR: parser.ScanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); - m_FadeBackground = true; + _fadeBackground = true; break; case TOKEN_FADE_ALPHA: parser.ScanStr((char *)params, "%d", &FadeA); - m_FadeBackground = true; + _fadeBackground = true; break; case TOKEN_EDITOR_PROPERTY: @@ -557,11 +557,11 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - m_AlphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = DRGBA(ar, ag, ab, alpha); - if (m_FadeBackground) m_FadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); + if (_fadeBackground) _fadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); - m_FocusedWidget = NULL; + _focusedWidget = NULL; return S_OK; } @@ -571,35 +571,35 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "WINDOW\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Back && m_Back->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", m_Back->m_Filename); - if (m_BackInactive && m_BackInactive->m_Filename) - Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", m_BackInactive->m_Filename); + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backInactive && _backInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); - if (m_Image && m_Image->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", m_Image->m_Filename); - if (m_ImageInactive && m_ImageInactive->m_Filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", m_ImageInactive->m_Filename); + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageInactive && _imageInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); - if (m_Font && m_Font->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", m_Font->m_Filename); - if (m_FontInactive && m_FontInactive->m_Filename) - Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", m_FontInactive->m_Filename); + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontInactive && _fontInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); - if (m_Cursor && m_Cursor->m_Filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename); + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_Text) - Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", m_Text); + if (_text) + Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); - switch (m_TitleAlign) { + switch (_titleAlign) { case TAL_LEFT: Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); break; @@ -611,46 +611,46 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { break; } - if (!CBPlatform::IsRectEmpty(&m_TitleRect)) { - Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", m_TitleRect.left, m_TitleRect.top, m_TitleRect.right, m_TitleRect.bottom); + if (!CBPlatform::IsRectEmpty(&_titleRect)) { + Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } - if (!CBPlatform::IsRectEmpty(&m_DragRect)) { - Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", m_DragRect.left, m_DragRect.top, m_DragRect.right, m_DragRect.bottom); + if (!CBPlatform::IsRectEmpty(&_dragRect)) { + Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } Buffer->PutTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", m_PosX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", m_PosY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", m_Width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", m_Height); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", m_Disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", m_Visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", m_ParentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", m_Transparent ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", m_PauseMusic ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", m_IsMenu ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", m_InGame ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", m_ClipContents ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "\n"); - if (m_FadeBackground) { - Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_FadeColor), D3DCOLGetG(m_FadeColor), D3DCOLGetB(m_FadeColor)); - Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(m_FadeColor)); + if (_fadeBackground) { + Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); + Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); } - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_AlphaColor), D3DCOLGetG(m_AlphaColor), D3DCOLGetB(m_AlphaColor)); - Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(m_AlphaColor)); + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); Buffer->PutTextIndent(Indent + 2, "\n"); // scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename); + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } Buffer->PutTextIndent(Indent + 2, "\n"); @@ -659,8 +659,8 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { CBBase::SaveAsText(Buffer, Indent + 2); // controls - for (int i = 0; i < m_Widgets.GetSize(); i++) - m_Widgets[i]->SaveAsText(Buffer, Indent + 2); + for (int i = 0; i < _widgets.GetSize(); i++) + _widgets[i]->SaveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); @@ -669,8 +669,8 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::EnableWidget(char *Name, bool Enable) { - for (int i = 0; i < m_Widgets.GetSize(); i++) { - if (scumm_stricmp(m_Widgets[i]->m_Name, Name) == 0) m_Widgets[i]->m_Disable = !Enable; + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; } return S_OK; } @@ -678,8 +678,8 @@ HRESULT CUIWindow::EnableWidget(char *Name, bool Enable) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::ShowWidget(char *Name, bool Visible) { - for (int i = 0; i < m_Widgets.GetSize(); i++) { - if (scumm_stricmp(m_Widgets[i]->m_Name, Name) == 0) m_Widgets[i]->m_Visible = Visible; + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; } return S_OK; } @@ -697,12 +697,12 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *val = Stack->Pop(); if (val->GetType() == VAL_INT) { int widget = val->GetInt(); - if (widget < 0 || widget >= m_Widgets.GetSize()) Stack->PushNULL(); - else Stack->PushNative(m_Widgets[widget], true); + if (widget < 0 || widget >= _widgets.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_widgets[widget], true); } else { - for (int i = 0; i < m_Widgets.GetSize(); i++) { - if (scumm_stricmp(m_Widgets[i]->m_Name, val->GetString()) == 0) { - Stack->PushNative(m_Widgets[i], true); + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { + Stack->PushNative(_widgets[i], true); return S_OK; } } @@ -718,9 +718,9 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetInactiveFont") == 0) { Stack->CorrectParams(1); - if (m_FontInactive) Game->m_FontStorage->RemoveFont(m_FontInactive); - m_FontInactive = Game->m_FontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(m_FontInactive != NULL); + if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + _fontInactive = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(_fontInactive != NULL); return S_OK; } @@ -731,12 +731,12 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetInactiveImage") == 0) { Stack->CorrectParams(1); - delete m_ImageInactive; - m_ImageInactive = new CBSprite(Game); + delete _imageInactive; + _imageInactive = new CBSprite(Game); char *Filename = Stack->Pop()->GetString(); - if (!m_ImageInactive || FAILED(m_ImageInactive->LoadFile(Filename))) { - delete m_ImageInactive; - m_ImageInactive = NULL; + if (!_imageInactive || FAILED(_imageInactive->LoadFile(Filename))) { + delete _imageInactive; + _imageInactive = NULL; Stack->PushBool(false); } else Stack->PushBool(true); @@ -748,8 +748,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetInactiveImage") == 0) { Stack->CorrectParams(0); - if (!m_ImageInactive || !m_ImageInactive->m_Filename) Stack->PushNULL(); - else Stack->PushString(m_ImageInactive->m_Filename); + if (!_imageInactive || !_imageInactive->_filename) Stack->PushNULL(); + else Stack->PushString(_imageInactive->_filename); return S_OK; } @@ -759,8 +759,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetInactiveImageObject") == 0) { Stack->CorrectParams(0); - if (!m_ImageInactive) Stack->PushNULL(); - else Stack->PushNative(m_ImageInactive, true); + if (!_imageInactive) Stack->PushNULL(); + else Stack->PushNative(_imageInactive, true); return S_OK; } @@ -802,8 +802,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Center") == 0) { Stack->CorrectParams(0); - m_PosX = (Game->m_Renderer->m_Width - m_Width) / 2; - m_PosY = (Game->m_Renderer->m_Height - m_Height) / 2; + _posX = (Game->_renderer->_width - _width) / 2; + _posY = (Game->_renderer->_height - _height) / 2; Stack->PushNULL(); return S_OK; } @@ -834,8 +834,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!Val->IsNULL()) Btn->SetName(Val->GetString()); Stack->PushNative(Btn, true); - Btn->m_Parent = this; - m_Widgets.Add(Btn); + Btn->_parent = this; + _widgets.Add(Btn); return S_OK; } @@ -851,8 +851,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!Val->IsNULL()) Sta->SetName(Val->GetString()); Stack->PushNative(Sta, true); - Sta->m_Parent = this; - m_Widgets.Add(Sta); + Sta->_parent = this; + _widgets.Add(Sta); return S_OK; } @@ -868,8 +868,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!Val->IsNULL()) Edi->SetName(Val->GetString()); Stack->PushNative(Edi, true); - Edi->m_Parent = this; - m_Widgets.Add(Edi); + Edi->_parent = this; + _widgets.Add(Edi); return S_OK; } @@ -885,8 +885,8 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!Val->IsNULL()) Win->SetName(Val->GetString()); Stack->PushNative(Win, true); - Win->m_Parent = this; - m_Widgets.Add(Win); + Win->_parent = this; + _widgets.Add(Win); return S_OK; } @@ -899,10 +899,10 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *val = Stack->Pop(); CUIObject *obj = (CUIObject *)val->GetNative(); - for (int i = 0; i < m_Widgets.GetSize(); i++) { - if (m_Widgets[i] == obj) { - delete m_Widgets[i]; - m_Widgets.RemoveAt(i); + for (int i = 0; i < _widgets.GetSize(); i++) { + if (_widgets[i] == obj) { + delete _widgets[i]; + _widgets.RemoveAt(i); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); } } @@ -916,86 +916,86 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CUIWindow::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("window"); - return m_ScValue; + _scValue->SetString("window"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumWidgets") == 0 || strcmp(Name, "NumControls") == 0) { - m_ScValue->SetInt(m_Widgets.GetSize()); - return m_ScValue; + _scValue->SetInt(_widgets.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Exclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Exclusive") == 0) { - m_ScValue->SetBool(m_Mode == WINDOW_EXCLUSIVE); - return m_ScValue; + _scValue->SetBool(_mode == WINDOW_EXCLUSIVE); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // SystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SystemExclusive") == 0) { - m_ScValue->SetBool(m_Mode == WINDOW_SYSTEM_EXCLUSIVE); - return m_ScValue; + _scValue->SetBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Menu ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Menu") == 0) { - m_ScValue->SetBool(m_IsMenu); - return m_ScValue; + _scValue->SetBool(_isMenu); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // InGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InGame") == 0) { - m_ScValue->SetBool(m_InGame); - return m_ScValue; + _scValue->SetBool(_inGame); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PauseMusic ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PauseMusic") == 0) { - m_ScValue->SetBool(m_PauseMusic); - return m_ScValue; + _scValue->SetBool(_pauseMusic); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // ClipContents ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ClipContents") == 0) { - m_ScValue->SetBool(m_ClipContents); - return m_ScValue; + _scValue->SetBool(_clipContents); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Transparent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Transparent") == 0) { - m_ScValue->SetBool(m_Transparent); - return m_ScValue; + _scValue->SetBool(_transparent); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeColor") == 0) { - m_ScValue->SetInt((int)m_FadeColor); - return m_ScValue; + _scValue->SetInt((int)_fadeColor); + return _scValue; } else return CUIObject::ScGetProperty(Name); @@ -1016,7 +1016,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // Menu ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Menu") == 0) { - m_IsMenu = Value->GetBool(); + _isMenu = Value->GetBool(); return S_OK; } @@ -1024,7 +1024,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // InGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InGame") == 0) { - m_InGame = Value->GetBool(); + _inGame = Value->GetBool(); return S_OK; } @@ -1032,7 +1032,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // PauseMusic ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PauseMusic") == 0) { - m_PauseMusic = Value->GetBool(); + _pauseMusic = Value->GetBool(); return S_OK; } @@ -1040,7 +1040,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // ClipContents ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ClipContents") == 0) { - m_ClipContents = Value->GetBool(); + _clipContents = Value->GetBool(); return S_OK; } @@ -1048,7 +1048,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // Transparent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Transparent") == 0) { - m_Transparent = Value->GetBool(); + _transparent = Value->GetBool(); return S_OK; } @@ -1056,8 +1056,8 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { // FadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FadeColor") == 0) { - m_FadeColor = (uint32)Value->GetInt(); - m_FadeBackground = (m_FadeColor != 0); + _fadeColor = (uint32)Value->GetInt(); + _fadeBackground = (_fadeColor != 0); return S_OK; } @@ -1069,7 +1069,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { GoExclusive(); else { Close(); - m_Visible = true; + _visible = true; } return S_OK; } @@ -1082,7 +1082,7 @@ HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { GoSystemExclusive(); else { Close(); - m_Visible = true; + _visible = true; } return S_OK; } @@ -1104,7 +1104,7 @@ bool CUIWindow::HandleKeypress(SDL_Event *event) { if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { - if (m_FocusedWidget) return m_FocusedWidget->HandleKeypress(event); + if (_focusedWidget) return _focusedWidget->HandleKeypress(event); else return false; } #endif @@ -1114,7 +1114,7 @@ bool CUIWindow::HandleKeypress(SDL_Event *event) { ////////////////////////////////////////////////////////////////////////// bool CUIWindow::HandleMouseWheel(int Delta) { - if (m_FocusedWidget) return m_FocusedWidget->HandleMouseWheel(Delta); + if (_focusedWidget) return _focusedWidget->HandleMouseWheel(Delta); else return false; } @@ -1124,23 +1124,23 @@ HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { HRESULT res = CUIObject::HandleMouse(Event, Button); // handle window dragging - if (!CBPlatform::IsRectEmpty(&m_DragRect)) { + if (!CBPlatform::IsRectEmpty(&_dragRect)) { // start drag if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { - RECT DragRect = m_DragRect; + RECT DragRect = _dragRect; int OffsetX, OffsetY; GetTotalOffset(&OffsetX, &OffsetY); - CBPlatform::OffsetRect(&DragRect, m_PosX + OffsetX, m_PosY + OffsetY); + CBPlatform::OffsetRect(&DragRect, _posX + OffsetX, _posY + OffsetY); - if (CBPlatform::PtInRect(&DragRect, Game->m_MousePos)) { - m_DragFrom.x = Game->m_MousePos.x; - m_DragFrom.y = Game->m_MousePos.y; - m_Dragging = true; + if (CBPlatform::PtInRect(&DragRect, Game->_mousePos)) { + _dragFrom.x = Game->_mousePos.x; + _dragFrom.y = Game->_mousePos.y; + _dragging = true; } } // end drag - else if (m_Dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { - m_Dragging = false; + else if (_dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { + _dragging = false; } } @@ -1154,27 +1154,27 @@ HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_BackInactive)); - PersistMgr->Transfer(TMEMBER(m_ClipContents)); - PersistMgr->Transfer(TMEMBER(m_DragFrom)); - PersistMgr->Transfer(TMEMBER(m_Dragging)); - PersistMgr->Transfer(TMEMBER(m_DragRect)); - PersistMgr->Transfer(TMEMBER(m_FadeBackground)); - PersistMgr->Transfer(TMEMBER(m_FadeColor)); - PersistMgr->Transfer(TMEMBER(m_FontInactive)); - PersistMgr->Transfer(TMEMBER(m_ImageInactive)); - PersistMgr->Transfer(TMEMBER(m_InGame)); - PersistMgr->Transfer(TMEMBER(m_IsMenu)); - PersistMgr->Transfer(TMEMBER_INT(m_Mode)); - PersistMgr->Transfer(TMEMBER(m_ShieldButton)); - PersistMgr->Transfer(TMEMBER(m_ShieldWindow)); - PersistMgr->Transfer(TMEMBER_INT(m_TitleAlign)); - PersistMgr->Transfer(TMEMBER(m_TitleRect)); - PersistMgr->Transfer(TMEMBER(m_Transparent)); - PersistMgr->Transfer(TMEMBER(m_Viewport)); - PersistMgr->Transfer(TMEMBER(m_PauseMusic)); - - m_Widgets.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_backInactive)); + PersistMgr->Transfer(TMEMBER(_clipContents)); + PersistMgr->Transfer(TMEMBER(_dragFrom)); + PersistMgr->Transfer(TMEMBER(_dragging)); + PersistMgr->Transfer(TMEMBER(_dragRect)); + PersistMgr->Transfer(TMEMBER(_fadeBackground)); + PersistMgr->Transfer(TMEMBER(_fadeColor)); + PersistMgr->Transfer(TMEMBER(_fontInactive)); + PersistMgr->Transfer(TMEMBER(_imageInactive)); + PersistMgr->Transfer(TMEMBER(_inGame)); + PersistMgr->Transfer(TMEMBER(_isMenu)); + PersistMgr->Transfer(TMEMBER_INT(_mode)); + PersistMgr->Transfer(TMEMBER(_shieldButton)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER_INT(_titleAlign)); + PersistMgr->Transfer(TMEMBER(_titleRect)); + PersistMgr->Transfer(TMEMBER(_transparent)); + PersistMgr->Transfer(TMEMBER(_viewport)); + PersistMgr->Transfer(TMEMBER(_pauseMusic)); + + _widgets.Persist(PersistMgr); return S_OK; } @@ -1184,35 +1184,35 @@ HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { HRESULT CUIWindow::MoveFocus(bool Forward) { int i; bool found = false; - for (i = 0; i < m_Widgets.GetSize(); i++) { - if (m_Widgets[i] == m_FocusedWidget) { + for (i = 0; i < _widgets.GetSize(); i++) { + if (_widgets[i] == _focusedWidget) { found = true; break; } } - if (!found) m_FocusedWidget = NULL; + if (!found) _focusedWidget = NULL; - if (!m_FocusedWidget) { - if (m_Widgets.GetSize() > 0) i = 0; + if (!_focusedWidget) { + if (_widgets.GetSize() > 0) i = 0; else return S_OK; } int NumTries = 0; bool done = false; - while (NumTries <= m_Widgets.GetSize()) { - if (m_Widgets[i] != m_FocusedWidget && m_Widgets[i]->m_CanFocus && m_Widgets[i]->m_Visible && !m_Widgets[i]->m_Disable) { - m_FocusedWidget = m_Widgets[i]; + while (NumTries <= _widgets.GetSize()) { + if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + _focusedWidget = _widgets[i]; done = true; break; } if (Forward) { i++; - if (i >= m_Widgets.GetSize()) i = 0; + if (i >= _widgets.GetSize()) i = 0; } else { i--; - if (i < 0) i = m_Widgets.GetSize() - 1; + if (i < 0) i = _widgets.GetSize() - 1; } NumTries++; } @@ -1223,13 +1223,13 @@ HRESULT CUIWindow::MoveFocus(bool Forward) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::GoExclusive() { - if (m_Mode == WINDOW_EXCLUSIVE) return S_OK; + if (_mode == WINDOW_EXCLUSIVE) return S_OK; - if (m_Mode == WINDOW_NORMAL) { - m_Ready = false; - m_Mode = WINDOW_EXCLUSIVE; - m_Visible = true; - m_Disable = false; + if (_mode == WINDOW_NORMAL) { + _ready = false; + _mode = WINDOW_EXCLUSIVE; + _visible = true; + _disable = false; Game->FocusWindow(this); return S_OK; } else return E_FAIL; @@ -1238,30 +1238,30 @@ HRESULT CUIWindow::GoExclusive() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::GoSystemExclusive() { - if (m_Mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; MakeFreezable(false); - m_Mode = WINDOW_SYSTEM_EXCLUSIVE; - m_Ready = false; - m_Visible = true; - m_Disable = false; + _mode = WINDOW_SYSTEM_EXCLUSIVE; + _ready = false; + _visible = true; + _disable = false; Game->FocusWindow(this); - Game->Freeze(m_PauseMusic); + Game->Freeze(_pauseMusic); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::Close() { - if (m_Mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { Game->Unfreeze(); } - m_Mode = WINDOW_NORMAL; - m_Visible = false; - m_Ready = true; + _mode = WINDOW_NORMAL; + _visible = false; + _ready = true; return S_OK; } @@ -1271,9 +1271,9 @@ HRESULT CUIWindow::Close() { HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; - switch (obj->m_Type) { + switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->m_Name, "close") == 0) Close(); + if (scumm_stricmp(obj->_name, "close") == 0) Close(); else return CBObject::Listen(param1, param2); break; default: @@ -1286,8 +1286,8 @@ HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// void CUIWindow::MakeFreezable(bool Freezable) { - for (int i = 0; i < m_Widgets.GetSize(); i++) - m_Widgets[i]->MakeFreezable(Freezable); + for (int i = 0; i < _widgets.GetSize(); i++) + _widgets[i]->MakeFreezable(Freezable); CBObject::MakeFreezable(Freezable); } @@ -1295,11 +1295,11 @@ void CUIWindow::MakeFreezable(bool Freezable) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::GetWindowObjects(CBArray& Objects, bool InteractiveOnly) { - for (int i = 0; i < m_Widgets.GetSize(); i++) { - CUIObject *Control = m_Widgets[i]; - if (Control->m_Disable && InteractiveOnly) continue; + for (int i = 0; i < _widgets.GetSize(); i++) { + CUIObject *Control = _widgets[i]; + if (Control->_disable && InteractiveOnly) continue; - switch (Control->m_Type) { + switch (Control->_type) { case UI_WINDOW: ((CUIWindow *)Control)->GetWindowObjects(Objects, InteractiveOnly); break; diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index b8adc2f27f..dc4c83ee1f 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -40,43 +40,43 @@ class CUIWindow : public CUIObject { public: HRESULT GetWindowObjects(CBArray& Objects, bool InteractiveOnly); - bool m_PauseMusic; + bool _pauseMusic; void Cleanup(); virtual void MakeFreezable(bool Freezable); - CBViewport *m_Viewport; - bool m_ClipContents; - bool m_InGame; - bool m_IsMenu; - bool m_FadeBackground; - uint32 m_FadeColor; + CBViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + uint32 _fadeColor; virtual bool HandleMouseWheel(int Delta); - CUIWindow *m_ShieldWindow; - CUIButton *m_ShieldButton; + CUIWindow *_shieldWindow; + CUIButton *_shieldButton; HRESULT Close(); HRESULT GoSystemExclusive(); HRESULT GoExclusive(); - TWindowMode m_Mode; + TWindowMode _mode; HRESULT MoveFocus(bool Forward = true); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - POINT m_DragFrom; - bool m_Dragging; + POINT _dragFrom; + bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) - bool m_Transparent; + bool _transparent; HRESULT ShowWidget(char *Name, bool Visible = true); HRESULT EnableWidget(char *Name, bool Enable = true); - RECT m_TitleRect; - RECT m_DragRect; + RECT _titleRect; + RECT _dragRect; virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); virtual bool HandleKeypress(SDL_Event *event); - CBArray m_Widgets; - TTextAlign m_TitleAlign; + CBArray _widgets; + TTextAlign _titleAlign; HRESULT LoadFile(char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CUITiledImage *m_BackInactive; - CBFont *m_FontInactive; - CBSprite *m_ImageInactive; + CUITiledImage *_backInactive; + CBFont *_fontInactive; + CBSprite *_imageInactive; virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index bcd11126a9..6bbadd6787 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -116,10 +116,10 @@ public: // Implementation protected: - TYPE *m_pData; // the actual array of data - int m_nSize; // # of elements (upperBound - 1) - int m_nMaxSize; // max allocated - int m_nGrowBy; // grow amount + TYPE *_pData; // the actual array of data + int _nSize; // # of elements (upperBound - 1) + int _nMaxSize; // max allocated + int _nGrowBy; // grow amount public: ~CBArray(); @@ -130,11 +130,11 @@ public: ///////////////////////////////////////////////////////////////////////////// template inline int CBArray::GetSize() const { - return m_nSize; + return _nSize; } template inline int CBArray::GetUpperBound() const { - return m_nSize - 1; + return _nSize - 1; } template inline void CBArray::RemoveAll() { @@ -142,27 +142,27 @@ inline void CBArray::RemoveAll() { } template inline TYPE CBArray::GetAt(int nIndex) const { - return m_pData[nIndex]; + return _pData[nIndex]; } template inline void CBArray::SetAt(int nIndex, ARG_TYPE newElement) { - m_pData[nIndex] = newElement; + _pData[nIndex] = newElement; } template inline TYPE &CBArray::ElementAt(int nIndex) { - return m_pData[nIndex]; + return _pData[nIndex]; } template inline const TYPE *CBArray::GetData() const { - return (const TYPE *)m_pData; + return (const TYPE *)_pData; } template inline TYPE *CBArray::GetData() { - return (TYPE *)m_pData; + return (TYPE *)_pData; } template inline int CBArray::Add(ARG_TYPE newElement) { - int nIndex = m_nSize; + int nIndex = _nSize; SetAtGrow(nIndex, newElement); return nIndex; } @@ -180,16 +180,16 @@ inline TYPE &CBArray::operator[](int nIndex) { ///////////////////////////////////////////////////////////////////////////// template CBArray::CBArray() { - m_pData = NULL; - m_nSize = m_nMaxSize = m_nGrowBy = 0; + _pData = NULL; + _nSize = _nMaxSize = _nGrowBy = 0; } ///////////////////////////////////////////////////////////////////////////// template CBArray::~CBArray() { - if (m_pData != NULL) { - DCDestructElements(m_pData, m_nSize); - delete[](byte *)m_pData; + if (_pData != NULL) { + DCDestructElements(_pData, _nSize); + delete[](byte *)_pData; } } @@ -197,140 +197,140 @@ CBArray::~CBArray() { template void CBArray::SetSize(int nNewSize, int nGrowBy) { if (nGrowBy != -1) - m_nGrowBy = nGrowBy; // set new size + _nGrowBy = nGrowBy; // set new size if (nNewSize == 0) { // shrink to nothing - if (m_pData != NULL) { - DCDestructElements(m_pData, m_nSize); - delete[](byte *)m_pData; - m_pData = NULL; + if (_pData != NULL) { + DCDestructElements(_pData, _nSize); + delete[](byte *)_pData; + _pData = NULL; } - m_nSize = m_nMaxSize = 0; - } else if (m_pData == NULL) { + _nSize = _nMaxSize = 0; + } else if (_pData == NULL) { // create one with exact size - m_pData = (TYPE *) new byte[nNewSize * sizeof(TYPE)]; - DCConstructElements(m_pData, nNewSize); - m_nSize = m_nMaxSize = nNewSize; - } else if (nNewSize <= m_nMaxSize) { + _pData = (TYPE *) new byte[nNewSize * sizeof(TYPE)]; + DCConstructElements(_pData, nNewSize); + _nSize = _nMaxSize = nNewSize; + } else if (nNewSize <= _nMaxSize) { // it fits - if (nNewSize > m_nSize) { + if (nNewSize > _nSize) { // initialize the new elements - DCConstructElements(&m_pData[m_nSize], nNewSize - m_nSize); - } else if (m_nSize > nNewSize) { + DCConstructElements(&_pData[_nSize], nNewSize - _nSize); + } else if (_nSize > nNewSize) { // destroy the old elements - DCDestructElements(&m_pData[nNewSize], m_nSize - nNewSize); + DCDestructElements(&_pData[nNewSize], _nSize - nNewSize); } - m_nSize = nNewSize; + _nSize = nNewSize; } else { // otherwise, grow array - int nGrowBy = m_nGrowBy; + int nGrowBy = _nGrowBy; if (nGrowBy == 0) { // heuristically determine growth when nGrowBy == 0 // (this avoids heap fragmentation in many situations) - nGrowBy = m_nSize / 8; + nGrowBy = _nSize / 8; nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy); } int nNewMax; - if (nNewSize < m_nMaxSize + nGrowBy) - nNewMax = m_nMaxSize + nGrowBy; // granularity + if (nNewSize < _nMaxSize + nGrowBy) + nNewMax = _nMaxSize + nGrowBy; // granularity else nNewMax = nNewSize; // no slush TYPE *pNewData = (TYPE *) new byte[nNewMax * sizeof(TYPE)]; // copy new data from old - memcpy(pNewData, m_pData, m_nSize * sizeof(TYPE)); + memcpy(pNewData, _pData, _nSize * sizeof(TYPE)); // construct remaining elements - DCConstructElements(&pNewData[m_nSize], nNewSize - m_nSize); + DCConstructElements(&pNewData[_nSize], nNewSize - _nSize); // get rid of old stuff (note: no destructors called) - delete[](byte *)m_pData; - m_pData = pNewData; - m_nSize = nNewSize; - m_nMaxSize = nNewMax; + delete[](byte *)_pData; + _pData = pNewData; + _nSize = nNewSize; + _nMaxSize = nNewMax; } } ///////////////////////////////////////////////////////////////////////////// template int CBArray::Append(const CBArray &src) { - int nOldSize = m_nSize; - SetSize(m_nSize + src.m_nSize); - DCCopyElements(m_pData + nOldSize, src.m_pData, src.m_nSize); + int nOldSize = _nSize; + SetSize(_nSize + src._nSize); + DCCopyElements(_pData + nOldSize, src._pData, src._nSize); return nOldSize; } ///////////////////////////////////////////////////////////////////////////// template void CBArray::Copy(const CBArray &src) { - SetSize(src.m_nSize); - DCCopyElements(m_pData, src.m_pData, src.m_nSize); + SetSize(src._nSize); + DCCopyElements(_pData, src._pData, src._nSize); } ///////////////////////////////////////////////////////////////////////////// template void CBArray::FreeExtra() { - if (m_nSize != m_nMaxSize) { + if (_nSize != _nMaxSize) { // shrink to desired size TYPE *pNewData = NULL; - if (m_nSize != 0) { - pNewData = (TYPE *) new byte[m_nSize * sizeof(TYPE)]; + if (_nSize != 0) { + pNewData = (TYPE *) new byte[_nSize * sizeof(TYPE)]; // copy new data from old - memcpy(pNewData, m_pData, m_nSize * sizeof(TYPE)); + memcpy(pNewData, _pData, _nSize * sizeof(TYPE)); } // get rid of old stuff (note: no destructors called) - delete[](byte *)m_pData; - m_pData = pNewData; - m_nMaxSize = m_nSize; + delete[](byte *)_pData; + _pData = pNewData; + _nMaxSize = _nSize; } } ///////////////////////////////////////////////////////////////////////////// template void CBArray::SetAtGrow(int nIndex, ARG_TYPE newElement) { - if (nIndex >= m_nSize) + if (nIndex >= _nSize) SetSize(nIndex + 1, -1); - m_pData[nIndex] = newElement; + _pData[nIndex] = newElement; } ///////////////////////////////////////////////////////////////////////////// template void CBArray::InsertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { - if (nIndex >= m_nSize) { + if (nIndex >= _nSize) { // adding after the end of the array SetSize(nIndex + nCount, -1); // grow so nIndex is valid } else { // inserting in the middle of the array - int nOldSize = m_nSize; - SetSize(m_nSize + nCount, -1); // grow it to new size + int nOldSize = _nSize; + SetSize(_nSize + nCount, -1); // grow it to new size // destroy intial data before copying over it - DCDestructElements(&m_pData[nOldSize], nCount); + DCDestructElements(&_pData[nOldSize], nCount); // shift old data up to fill gap - memmove(&m_pData[nIndex + nCount], &m_pData[nIndex], + memmove(&_pData[nIndex + nCount], &_pData[nIndex], (nOldSize - nIndex) * sizeof(TYPE)); // re-init slots we copied from - DCConstructElements(&m_pData[nIndex], nCount); + DCConstructElements(&_pData[nIndex], nCount); } // insert new value in the gap while (nCount--) - m_pData[nIndex++] = newElement; + _pData[nIndex++] = newElement; } ///////////////////////////////////////////////////////////////////////////// template void CBArray::RemoveAt(int nIndex, int nCount) { // just remove a range - int nMoveCount = m_nSize - (nIndex + nCount); - DCDestructElements(&m_pData[nIndex], nCount); + int nMoveCount = _nSize - (nIndex + nCount); + DCDestructElements(&_pData[nIndex], nCount); if (nMoveCount) - memcpy(&m_pData[nIndex], &m_pData[nIndex + nCount], + memcpy(&_pData[nIndex], &_pData[nIndex + nCount], nMoveCount * sizeof(TYPE)); - m_nSize -= nCount; + _nSize -= nCount; } ///////////////////////////////////////////////////////////////////////////// @@ -348,7 +348,7 @@ void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { template HRESULT CBArray::Persist(CBPersistMgr *PersistMgr) { int i, j; - if (PersistMgr->m_Saving) { + if (PersistMgr->_saving) { j = GetSize(); PersistMgr->Transfer("ArraySize", &j); for (i = 0; i < j; i++) { diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 130e080e79..4b528c7947 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -47,7 +47,7 @@ namespace WinterMute { #define DECLARE_PERSISTENT(class_name, parent_class)\ -static const char m_ClassName[];\ +static const char _className[];\ static void* WINAPI PersistBuild(void);\ virtual const char* GetClassName();\ static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ @@ -58,7 +58,7 @@ void operator delete(void* p);\ #define IMPLEMENT_PERSISTENT(class_name, persistent_class)\ -const char class_name::m_ClassName[] = #class_name;\ +const char class_name::_className[] = #class_name;\ void* class_name::PersistBuild(){\ return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ }\ @@ -71,7 +71,7 @@ const char* class_name::GetClassName(){\ return #class_name;\ }\ \ -CSysClass Register##class_name(class_name::m_ClassName, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ +CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ \ void* class_name::operator new (size_t size){\ void* ret = ::operator new(size);\ diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 5203945053..978de4ae52 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -38,33 +38,33 @@ IMPLEMENT_PERSISTENT(CSXArray, false) ////////////////////////////////////////////////////////////////////////// CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - m_Length = 0; - m_Values = new CScValue(Game); + _length = 0; + _values = new CScValue(Game); int NumParams = Stack->Pop()->GetInt(0); - if (NumParams == 1) m_Length = Stack->Pop()->GetInt(0); + if (NumParams == 1) _length = Stack->Pop()->GetInt(0); else if (NumParams > 1) { - m_Length = NumParams; + _length = NumParams; char ParamName[20]; for (int i = 0; i < NumParams; i++) { sprintf(ParamName, "%d", i); - m_Values->SetProp(ParamName, Stack->Pop()); + _values->SetProp(ParamName, Stack->Pop()); } } } ////////////////////////////////////////////////////////////////////////// CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { - m_Length = 0; - m_Values = new CScValue(Game); + _length = 0; + _values = new CScValue(Game); } ////////////////////////////////////////////////////////////////////////// CSXArray::~CSXArray() { - delete m_Values; - m_Values = NULL; + delete _values; + _values = NULL; } @@ -73,16 +73,16 @@ char *CSXArray::ScToString() { static char Dummy[32768]; strcpy(Dummy, ""); char PropName[20]; - for (int i = 0; i < m_Length; i++) { + for (int i = 0; i < _length; i++) { sprintf(PropName, "%d", i); - CScValue *val = m_Values->GetProp(PropName); + CScValue *val = _values->GetProp(PropName); if (val) { if (strlen(Dummy) + strlen(val->GetString()) < 32768) { strcat(Dummy, val->GetString()); } } - if (i < m_Length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); + if (i < _length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); } return Dummy; } @@ -98,11 +98,11 @@ HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi char ParamName[20]; for (int i = 0; i < NumParams; i++) { - m_Length++; - sprintf(ParamName, "%d", m_Length - 1); - m_Values->SetProp(ParamName, Stack->Pop(), true); + _length++; + sprintf(ParamName, "%d", _length - 1); + _values->SetProp(ParamName, Stack->Pop(), true); } - Stack->PushInt(m_Length); + Stack->PushInt(_length); return S_OK; } @@ -114,12 +114,12 @@ HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(0); - if (m_Length > 0) { + if (_length > 0) { char ParamName[20]; - sprintf(ParamName, "%d", m_Length - 1); - Stack->Push(m_Values->GetProp(ParamName)); - m_Values->DeleteProp(ParamName); - m_Length--; + sprintf(ParamName, "%d", _length - 1); + Stack->Push(_values->GetProp(ParamName)); + _values->DeleteProp(ParamName); + _length--; } else Stack->PushNULL(); return S_OK; @@ -131,22 +131,22 @@ HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// CScValue *CSXArray::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("array"); - return m_ScValue; + _scValue->SetString("array"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Length") == 0) { - m_ScValue->SetInt(m_Length); - return m_ScValue; + _scValue->SetInt(_length); + return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -155,8 +155,8 @@ CScValue *CSXArray::ScGetProperty(char *Name) { else { char ParamName[20]; if (ValidNumber(Name, ParamName)) { - return m_Values->GetProp(ParamName); - } else return m_ScValue; + return _values->GetProp(ParamName); + } else return _scValue; } } @@ -167,14 +167,14 @@ HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Length") == 0) { - int OrigLength = m_Length; - m_Length = MAX(Value->GetInt(0), 0); + int OrigLength = _length; + _length = MAX(Value->GetInt(0), 0); char PropName[20]; - if (m_Length < OrigLength) { - for (int i = m_Length; i < OrigLength; i++) { + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { sprintf(PropName, "%d", i); - m_Values->DeleteProp(PropName); + _values->DeleteProp(PropName); } } return S_OK; @@ -187,8 +187,8 @@ HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { char ParamName[20]; if (ValidNumber(Name, ParamName)) { int Index = atoi(ParamName); - if (Index >= m_Length) m_Length = Index + 1; - return m_Values->SetProp(ParamName, Value); + if (Index >= _length) _length = Index + 1; + return _values->SetProp(ParamName, Value); } else return E_FAIL; } } @@ -198,8 +198,8 @@ HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Length)); - PersistMgr->Transfer(TMEMBER(m_Values)); + PersistMgr->Transfer(TMEMBER(_length)); + PersistMgr->Transfer(TMEMBER(_values)); return S_OK; } @@ -225,9 +225,9 @@ bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { ////////////////////////////////////////////////////////////////////////// HRESULT CSXArray::Push(CScValue *Val) { char ParamName[20]; - m_Length++; - sprintf(ParamName, "%d", m_Length - 1); - m_Values->SetProp(ParamName, Val, true); + _length++; + sprintf(ParamName, "%d", _length - 1); + _values->SetProp(ParamName, Val, true); return S_OK; } diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h index 5283db2efb..0605d6c4f8 100644 --- a/engines/wintermute/scriptables/SXArray.h +++ b/engines/wintermute/scriptables/SXArray.h @@ -45,8 +45,8 @@ public: HRESULT ScSetProperty(char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); char *ScToString(); - int m_Length; - CScValue *m_Values; + int _length; + CScValue *_values; }; } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index 232f2beefd..65e6a43782 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -35,23 +35,23 @@ IMPLEMENT_PERSISTENT(CSXDate, false) CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(6); #if 0 - memset(&m_tm, 0, sizeof(m_tm)); + memset(&_tm, 0, sizeof(_tm)); CScValue *valYear = Stack->Pop(); - m_tm.tm_year = valYear->GetInt() - 1900; - m_tm.tm_mon = Stack->Pop()->GetInt() - 1; - m_tm.tm_mday = Stack->Pop()->GetInt(); - m_tm.tm_hour = Stack->Pop()->GetInt(); - m_tm.tm_min = Stack->Pop()->GetInt(); - m_tm.tm_sec = Stack->Pop()->GetInt(); + _tm.t_year = valYear->GetInt() - 1900; + _tm.t_mon = Stack->Pop()->GetInt() - 1; + _tm.t_mday = Stack->Pop()->GetInt(); + _tm.t_hour = Stack->Pop()->GetInt(); + _tm.t_min = Stack->Pop()->GetInt(); + _tm.t_sec = Stack->Pop()->GetInt(); if (valYear->IsNULL()) { time_t TimeNow; time(&TimeNow); - memcpy(&m_tm, localtime(&TimeNow), sizeof(m_tm)); + memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); } - mktime(&m_tm); + mktime(&_tm); #endif } @@ -65,7 +65,7 @@ CSXDate::~CSXDate() { ////////////////////////////////////////////////////////////////////////// char *CSXDate::ScToString() { #if 0 - return asctime(&m_tm); + return asctime(&_tm); #endif return ""; } @@ -79,7 +79,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "GetYear") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_year + 1900); + Stack->PushInt(_tm.t_year + 1900); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -87,7 +87,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetMonth") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_mon + 1); + Stack->PushInt(_tm.t_mon + 1); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -95,7 +95,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetDate") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_mday); + Stack->PushInt(_tm.t_mday); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -103,7 +103,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetHours") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_hour); + Stack->PushInt(_tm.t_hour); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetMinutes") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_min); + Stack->PushInt(_tm.t_min); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetSeconds") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_sec); + Stack->PushInt(_tm.t_sec); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -127,7 +127,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetWeekday") == 0) { Stack->CorrectParams(0); - Stack->PushInt(m_tm.tm_wday); + Stack->PushInt(_tm.t_wday); return S_OK; } @@ -137,8 +137,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetYear") == 0) { Stack->CorrectParams(1); - m_tm.tm_year = Stack->Pop()->GetInt() - 1900; - mktime(&m_tm); + _tm.t_year = Stack->Pop()->GetInt() - 1900; + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -147,8 +147,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetMonth") == 0) { Stack->CorrectParams(1); - m_tm.tm_mon = Stack->Pop()->GetInt() - 1; - mktime(&m_tm); + _tm.t_mon = Stack->Pop()->GetInt() - 1; + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -157,8 +157,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetDate") == 0) { Stack->CorrectParams(1); - m_tm.tm_mday = Stack->Pop()->GetInt(); - mktime(&m_tm); + _tm.t_mday = Stack->Pop()->GetInt(); + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -167,8 +167,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetHours") == 0) { Stack->CorrectParams(1); - m_tm.tm_hour = Stack->Pop()->GetInt(); - mktime(&m_tm); + _tm.t_hour = Stack->Pop()->GetInt(); + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -177,8 +177,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetMinutes") == 0) { Stack->CorrectParams(1); - m_tm.tm_min = Stack->Pop()->GetInt(); - mktime(&m_tm); + _tm.t_min = Stack->Pop()->GetInt(); + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -187,8 +187,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetSeconds") == 0) { Stack->CorrectParams(1); - m_tm.tm_sec = Stack->Pop()->GetInt(); - mktime(&m_tm); + _tm.t_sec = Stack->Pop()->GetInt(); + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -201,8 +201,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(0); time_t TimeNow; time(&TimeNow); - memcpy(&m_tm, localtime(&TimeNow), sizeof(m_tm)); - mktime(&m_tm); + memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); + mktime(&_tm); Stack->PushNULL(); return S_OK; } @@ -215,17 +215,17 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CSXDate::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("date"); - return m_ScValue; + _scValue->SetString("date"); + return _scValue; } - else return m_ScValue; + else return _scValue; } @@ -249,10 +249,10 @@ HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); #if 0 - if (PersistMgr->m_Saving) - PersistMgr->PutBytes((byte *)&m_tm, sizeof(m_tm)); + if (PersistMgr->_saving) + PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); else - PersistMgr->GetBytes((byte *)&m_tm, sizeof(m_tm)); + PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); #endif return S_OK; } @@ -261,8 +261,8 @@ HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// int CSXDate::ScCompare(CBScriptable *Value) { #if 0 - time_t time1 = mktime(&m_tm); - time_t time2 = mktime(&((CSXDate *)Value)->m_tm); + time_t time1 = mktime(&_tm); + time_t time2 = mktime(&((CSXDate *)Value)->_tm); if (time1 < time2) return -1; else if (time1 > time2) return 1; diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h index 638816b6d1..677b7e7dd1 100644 --- a/engines/wintermute/scriptables/SXDate.h +++ b/engines/wintermute/scriptables/SXDate.h @@ -44,8 +44,8 @@ public: HRESULT ScSetProperty(char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); char *ScToString(); - char *m_String; - //struct tm m_tm; // TODO! + char *_string; + //struct tm _tm; // TODO! }; } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index 8e38e2608a..19b60043da 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -44,14 +44,14 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - m_Filename = NULL; - if (!Val->IsNULL()) CBUtils::SetString(&m_Filename, Val->GetString()); + _filename = NULL; + if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); - m_ReadFile = NULL; - m_WriteFile = NULL; + _readFile = NULL; + _writeFile = NULL; - m_Mode = 0; - m_TextMode = false; + _mode = 0; + _textMode = false; } @@ -62,29 +62,29 @@ CSXFile::~CSXFile() { ////////////////////////////////////////////////////////////////////////// void CSXFile::Cleanup() { - delete[] m_Filename; - m_Filename = NULL; + delete[] _filename; + _filename = NULL; Close(); } ////////////////////////////////////////////////////////////////////////// void CSXFile::Close() { - if (m_ReadFile) { - Game->m_FileManager->CloseFile(m_ReadFile); - m_ReadFile = NULL; + if (_readFile) { + Game->_fileManager->CloseFile(_readFile); + _readFile = NULL; } - if (m_WriteFile) { - fclose(m_WriteFile); - m_WriteFile = NULL; + if (_writeFile) { + fclose(_writeFile); + _writeFile = NULL; } - m_Mode = 0; - m_TextMode = false; + _mode = 0; + _textMode = false; } ////////////////////////////////////////////////////////////////////////// char *CSXFile::ScToString() { - if (m_Filename) return m_Filename; + if (_filename) return _filename; else return "[file object]"; } @@ -98,7 +98,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); Cleanup(); - CBUtils::SetString(&m_Filename, Filename); + CBUtils::SetString(&_filename, Filename); Stack->PushNULL(); return S_OK; } @@ -109,33 +109,33 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) { Stack->CorrectParams(1); Close(); - m_Mode = Stack->Pop()->GetInt(1); - if (m_Mode < 1 || m_Mode > 3) { + _mode = Stack->Pop()->GetInt(1); + if (_mode < 1 || _mode > 3) { Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name); - m_Mode = 1; + _mode = 1; } - if (m_Mode == 1) { - m_ReadFile = Game->m_FileManager->OpenFile(m_Filename); - if (!m_ReadFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, m_Filename); + if (_mode == 1) { + _readFile = Game->_fileManager->OpenFile(_filename); + if (!_readFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); Close(); - } else m_TextMode = strcmp(Name, "OpenAsText") == 0; + } else _textMode = strcmp(Name, "OpenAsText") == 0; } else { if (strcmp(Name, "OpenAsText") == 0) { - if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+"); - else m_WriteFile = fopen(m_Filename, "a+"); + if (_mode == 2) _writeFile = fopen(_filename, "w+"); + else _writeFile = fopen(_filename, "a+"); } else { - if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+"); - else m_WriteFile = fopen(m_Filename, "ab+"); + if (_mode == 2) _writeFile = fopen(_filename, "wb+"); + else _writeFile = fopen(_filename, "ab+"); } - if (!m_WriteFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, m_Filename); + if (!_writeFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); Close(); - } else m_TextMode = strcmp(Name, "OpenAsText") == 0; + } else _textMode = strcmp(Name, "OpenAsText") == 0; } - if (m_ReadFile || m_WriteFile) Stack->PushBool(true); + if (_readFile || _writeFile) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -156,7 +156,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetPosition") == 0) { Stack->CorrectParams(1); - if (m_Mode == 0) { + if (_mode == 0) { Script->RuntimeError("File.%s: File is not open", Name); Stack->PushBool(false); } else { @@ -172,7 +172,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "Delete") == 0) { Stack->CorrectParams(0); Close(); - Stack->PushBool(CBPlatform::DeleteFile(m_Filename) != FALSE); + Stack->PushBool(CBPlatform::DeleteFile(_filename) != FALSE); return S_OK; } @@ -185,7 +185,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool Overwrite = Stack->Pop()->GetBool(true); Close(); - Stack->PushBool(CBPlatform::CopyFile(m_Filename, Dest, !Overwrite) != FALSE); + Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != FALSE); return S_OK; } @@ -194,7 +194,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadLine") == 0) { Stack->CorrectParams(0); - if (!m_TextMode || !m_ReadFile) { + if (!_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open in text mode.", Name); Stack->PushNULL(); return S_OK; @@ -206,7 +206,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool FoundNewLine = false; HRESULT Ret = E_FAIL; do { - Ret = m_ReadFile->Read(&b, 1); + Ret = _readFile->Read(&b, 1); if (FAILED(Ret)) break; if (Counter > BufSize) { @@ -245,7 +245,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); int TextLen = Stack->Pop()->GetInt(); - if (!m_TextMode || !m_ReadFile) { + if (!_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open in text mode.", Name); Stack->PushNULL(); return S_OK; @@ -257,7 +257,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This HRESULT Ret = E_FAIL; while (Counter < TextLen) { - Ret = m_ReadFile->Read(&b, 1); + Ret = _readFile->Read(&b, 1); if (FAILED(Ret)) break; if (Counter > BufSize) { @@ -291,15 +291,15 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { Stack->CorrectParams(1); char *Line = Stack->Pop()->GetString(); - if (!m_TextMode || !m_WriteFile) { + if (!_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); Stack->PushBool(false); return S_OK; } if (strcmp(Name, "WriteLine") == 0) - fprintf(m_WriteFile, "%s\n", Line); + fprintf(_writeFile, "%s\n", Line); else - fprintf(m_WriteFile, "%s", Line); + fprintf(_writeFile, "%s", Line); Stack->PushBool(true); @@ -312,13 +312,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadBool") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } bool Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); else Stack->PushNULL(); return S_OK; @@ -329,13 +329,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadByte") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } byte Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val); else Stack->PushNULL(); return S_OK; @@ -346,13 +346,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadShort") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } short Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); else Stack->PushNULL(); return S_OK; @@ -363,13 +363,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } int Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); else Stack->PushNULL(); return S_OK; @@ -380,13 +380,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadFloat") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } float Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); else Stack->PushNULL(); return S_OK; @@ -397,13 +397,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadDouble") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } double Val; - if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); else Stack->PushNULL(); return S_OK; @@ -414,16 +414,16 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ReadString") == 0) { Stack->CorrectParams(0); - if (m_TextMode || !m_ReadFile) { + if (_textMode || !_readFile) { Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); Stack->PushNULL(); return S_OK; } uint32 Size; - if (SUCCEEDED(m_ReadFile->Read(&Size, sizeof(uint32)))) { + if (SUCCEEDED(_readFile->Read(&Size, sizeof(uint32)))) { byte *Str = new byte[Size + 1]; if (Str) { - if (SUCCEEDED(m_ReadFile->Read(Str, Size))) { + if (SUCCEEDED(_readFile->Read(Str, Size))) { Str[Size] = '\0'; Stack->PushString((char *)Str); } @@ -441,12 +441,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); bool Val = Stack->Pop()->GetBool(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -459,12 +459,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); byte Val = Stack->Pop()->GetInt(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -477,12 +477,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); short Val = Stack->Pop()->GetInt(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -495,12 +495,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); int Val = Stack->Pop()->GetInt(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -513,12 +513,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); float Val = Stack->Pop()->GetFloat(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -531,12 +531,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); double Val = Stack->Pop()->GetFloat(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, m_WriteFile); + fwrite(&Val, sizeof(Val), 1, _writeFile); Stack->PushBool(true); return S_OK; @@ -549,15 +549,15 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->CorrectParams(1); char *Val = Stack->Pop()->GetString(); - if (m_TextMode || !m_WriteFile) { + if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); Stack->PushBool(false); return S_OK; } uint32 Size = strlen(Val); - fwrite(&Size, sizeof(Size), 1, m_WriteFile); - fwrite(Val, Size, 1, m_WriteFile); + fwrite(&Size, sizeof(Size), 1, _writeFile); + fwrite(Val, Size, 1, _writeFile); Stack->PushBool(true); @@ -571,54 +571,54 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CSXFile::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("file"); - return m_ScValue; + _scValue->SetString("file"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Filename") == 0) { - m_ScValue->SetString(m_Filename); - return m_ScValue; + _scValue->SetString(_filename); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Position (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Position") == 0) { - m_ScValue->SetInt(GetPos()); - return m_ScValue; + _scValue->SetInt(GetPos()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Length") == 0) { - m_ScValue->SetInt(GetLength()); - return m_ScValue; + _scValue->SetInt(GetLength()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // TextMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TextMode") == 0) { - m_ScValue->SetBool(m_TextMode); - return m_ScValue; + _scValue->SetBool(_textMode); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // AccessMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccessMode") == 0) { - m_ScValue->SetInt(m_Mode); - return m_ScValue; + _scValue->SetInt(_mode); + return _scValue; } else return CBScriptable::ScGetProperty(Name); @@ -632,14 +632,14 @@ HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) { // Length ////////////////////////////////////////////////////////////////////////// if(strcmp(Name, "Length")==0){ - int OrigLength = m_Length; - m_Length = max(Value->GetInt(0), 0); + int OrigLength = _length; + _length = max(Value->GetInt(0), 0); char PropName[20]; - if(m_Length < OrigLength){ - for(int i=m_Length; iDeleteProp(PropName); + _values->DeleteProp(PropName); } } return S_OK; @@ -649,26 +649,26 @@ HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetPos() { - if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetPos(); - else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return ftell(m_WriteFile); + if (_mode == 1 && _readFile) return _readFile->GetPos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); else return 0; } ////////////////////////////////////////////////////////////////////////// bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { - if (m_Mode == 1 && m_ReadFile) return SUCCEEDED(m_ReadFile->Seek(Pos, Origin)); - else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return fseek(m_WriteFile, Pos, (int)Origin) == 0; + if (_mode == 1 && _readFile) return SUCCEEDED(_readFile->Seek(Pos, Origin)); + else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, Pos, (int)Origin) == 0; else return false; } ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetLength() { - if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetSize(); - else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) { - uint32 CurrentPos = ftell(m_WriteFile); - fseek(m_WriteFile, 0, SEEK_END); - int Ret = ftell(m_WriteFile); - fseek(m_WriteFile, CurrentPos, SEEK_SET); + if (_mode == 1 && _readFile) return _readFile->GetSize(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + uint32 CurrentPos = ftell(_writeFile); + fseek(_writeFile, 0, SEEK_END); + int Ret = ftell(_writeFile); + fseek(_writeFile, CurrentPos, SEEK_SET); return Ret; } else return 0; } @@ -678,37 +678,37 @@ HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_Mode)); - PersistMgr->Transfer(TMEMBER(m_TextMode)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_mode)); + PersistMgr->Transfer(TMEMBER(_textMode)); uint32 Pos = 0; - if (PersistMgr->m_Saving) { + if (PersistMgr->_saving) { Pos = GetPos(); PersistMgr->Transfer(TMEMBER(Pos)); } else { PersistMgr->Transfer(TMEMBER(Pos)); // try to re-open file if needed - m_WriteFile = NULL; - m_ReadFile = NULL; + _writeFile = NULL; + _readFile = NULL; - if (m_Mode != 0) { + if (_mode != 0) { // open for reading - if (m_Mode == 1) { - m_ReadFile = Game->m_FileManager->OpenFile(m_Filename); - if (!m_ReadFile) Close(); + if (_mode == 1) { + _readFile = Game->_fileManager->OpenFile(_filename); + if (!_readFile) Close(); } // open for writing / appending else { - if (m_TextMode) { - if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+"); - else m_WriteFile = fopen(m_Filename, "a+"); + if (_textMode) { + if (_mode == 2) _writeFile = fopen(_filename, "w+"); + else _writeFile = fopen(_filename, "a+"); } else { - if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+"); - else m_WriteFile = fopen(m_Filename, "ab+"); + if (_mode == 2) _writeFile = fopen(_filename, "wb+"); + else _writeFile = fopen(_filename, "ab+"); } - if (m_WriteFile) Close(); + if (_writeFile) Close(); } SetPos(Pos); } diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h index 0ab1acb32c..085700d0e1 100644 --- a/engines/wintermute/scriptables/SXFile.h +++ b/engines/wintermute/scriptables/SXFile.h @@ -43,16 +43,16 @@ public: CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); private: - CBFile *m_ReadFile; - FILE *m_WriteFile; - int m_Mode; // 0..none, 1..read, 2..write, 3..append - bool m_TextMode; + CBFile *_readFile; + FILE *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; void Close(); void Cleanup(); uint32 GetPos(); uint32 GetLength(); bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - char *m_Filename; + char *_filename; }; } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXMath.cpp b/engines/wintermute/scriptables/SXMath.cpp index 48e722a02c..fcc85d527c 100644 --- a/engines/wintermute/scriptables/SXMath.cpp +++ b/engines/wintermute/scriptables/SXMath.cpp @@ -246,25 +246,25 @@ HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// CScValue *CSXMath::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("math"); - return m_ScValue; + _scValue->SetString("math"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // PI ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PI") == 0) { - m_ScValue->SetFloat(PI); - return m_ScValue; + _scValue->SetFloat(PI); + return _scValue; } - else return m_ScValue; + else return _scValue; } diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 874aa2c9d1..6215d9c4e3 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -39,8 +39,8 @@ IMPLEMENT_PERSISTENT(CSXMemBuffer, false) ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(1); - m_Buffer = NULL; - m_Size = 0; + _buffer = NULL; + _size = 0; int NewSize = Stack->Pop()->GetInt(); Resize(MAX(0, NewSize)); @@ -48,8 +48,8 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - m_Size = NULL; - m_Buffer = Buffer; + _size = NULL; + _buffer = Buffer; } @@ -60,51 +60,51 @@ CSXMemBuffer::~CSXMemBuffer() { ////////////////////////////////////////////////////////////////////////// void *CSXMemBuffer::ScToMemBuffer() { - return m_Buffer; + return _buffer; } ////////////////////////////////////////////////////////////////////////// void CSXMemBuffer::Cleanup() { - if (m_Size) free(m_Buffer); - m_Buffer = NULL; - m_Size = 0; + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; } ////////////////////////////////////////////////////////////////////////// HRESULT CSXMemBuffer::Resize(int NewSize) { - int OldSize = m_Size; + int OldSize = _size; - if (m_Size == 0) { - m_Buffer = malloc(NewSize); - if (m_Buffer) m_Size = NewSize; + if (_size == 0) { + _buffer = malloc(NewSize); + if (_buffer) _size = NewSize; } else { - void *NewBuf = realloc(m_Buffer, NewSize); + void *NewBuf = realloc(_buffer, NewSize); if (!NewBuf) { if (NewSize == 0) { - m_Buffer = NewBuf; - m_Size = NewSize; + _buffer = NewBuf; + _size = NewSize; } else return E_FAIL; } else { - m_Buffer = NewBuf; - m_Size = NewSize; + _buffer = NewBuf; + _size = NewSize; } } - if (m_Buffer && m_Size > OldSize) { - memset((byte *)m_Buffer + OldSize, 0, m_Size - OldSize); + if (_buffer && _size > OldSize) { + memset((byte *)_buffer + OldSize, 0, _size - OldSize); } return S_OK; } ////////////////////////////////////////////////////////////////////////// bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { - if (m_Buffer == NULL) { + if (_buffer == NULL) { Script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } - if (m_Size == 0) return true; + if (_size == 0) return true; - if (Start < 0 || Length == 0 || Start + Length > m_Size) { + if (Start < 0 || Length == 0 || Start + Length > _size) { Script->RuntimeError("Set/Get method call is out of bounds"); return false; } else return true; @@ -138,7 +138,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); - else Stack->PushBool(*(bool *)((byte *)m_Buffer + Start)); + else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); return S_OK; } @@ -150,7 +150,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushNULL(); - else Stack->PushInt(*(byte *)((byte *)m_Buffer + Start)); + else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); return S_OK; } @@ -162,7 +162,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); - else Stack->PushInt(65536 + * (short *)((byte *)m_Buffer + Start)); + else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -174,7 +174,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); - else Stack->PushInt(*(int *)((byte *)m_Buffer + Start)); + else Stack->PushInt(*(int *)((byte *)_buffer + Start)); return S_OK; } @@ -186,7 +186,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); - else Stack->PushFloat(*(float *)((byte *)m_Buffer + Start)); + else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); return S_OK; } @@ -198,7 +198,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); - else Stack->PushFloat(*(double *)((byte *)m_Buffer + Start)); + else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); return S_OK; } @@ -212,9 +212,9 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack int Length = Stack->Pop()->GetInt(); // find end of string - if (Length == 0 && Start >= 0 && Start < m_Size) { - for (int i = Start; i < m_Size; i++) { - if (((char *)m_Buffer)[i] == '\0') { + if (Length == 0 && Start >= 0 && Start < _size) { + for (int i = Start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { Length = i - Start; break; } @@ -224,7 +224,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, Length)) Stack->PushNULL(); else { char *Str = new char[Length + 1]; - strncpy(Str, (const char *)m_Buffer + Start, Length); + strncpy(Str, (const char *)_buffer + Start, Length); Str[Length] = '\0'; Stack->PushString(Str); delete [] Str; @@ -240,7 +240,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); else { - void *Pointer = *(void **)((byte *)m_Buffer + Start); + void *Pointer = *(void **)((byte *)_buffer + Start); CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); Stack->PushNative(Buf, false); } @@ -257,7 +257,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); else { - *(bool *)((byte *)m_Buffer + Start) = Val; + *(bool *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -273,7 +273,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushBool(false); else { - *(byte *)((byte *)m_Buffer + Start) = Val; + *(byte *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -289,7 +289,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); else { - *(short *)((byte *)m_Buffer + Start) = Val; + *(short *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -305,7 +305,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); else { - *(int *)((byte *)m_Buffer + Start) = Val; + *(int *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -321,7 +321,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); else { - *(float *)((byte *)m_Buffer + Start) = Val; + *(float *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -337,7 +337,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); else { - *(double *)((byte *)m_Buffer + Start) = Val; + *(double *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -353,7 +353,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); else { - memcpy((byte *)m_Buffer + Start, Val, strlen(Val) + 1); + memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); Stack->PushBool(true); } return S_OK; @@ -371,7 +371,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else { /* int Pointer = (int)Val->GetMemBuffer(); - memcpy((byte *)m_Buffer+Start, &Pointer, sizeof(void*)); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); Stack->PushBool(true); */ // TODO fix @@ -386,9 +386,9 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DEBUG_Dump") == 0) { Stack->CorrectParams(0); - if (m_Buffer && m_Size) { + if (_buffer && _size) { FILE *f = fopen("c:\\!!buffer.bin", "wb"); - fwrite(m_Buffer, m_Size, 1, f); + fwrite(_buffer, _size, 1, f); fclose(f); } Stack->PushNULL(); @@ -401,22 +401,22 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CSXMemBuffer::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("membuffer"); - return m_ScValue; + _scValue->SetString("membuffer"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Size (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Size") == 0) { - m_ScValue->SetInt(m_Size); - return m_ScValue; + _scValue->SetInt(_size); + return _scValue; } else return CBScriptable::ScGetProperty(Name); @@ -430,14 +430,14 @@ HRESULT CSXMemBuffer::ScSetProperty(char *Name, CScValue *Value) { // Length ////////////////////////////////////////////////////////////////////////// if(strcmp(Name, "Length")==0){ - int OrigLength = m_Length; - m_Length = max(Value->GetInt(0), 0); + int OrigLength = _length; + _length = max(Value->GetInt(0), 0); char PropName[20]; - if(m_Length < OrigLength){ - for(int i=m_Length; iDeleteProp(PropName); + _values->DeleteProp(PropName); } } return S_OK; @@ -451,15 +451,15 @@ HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_Size)); + PersistMgr->Transfer(TMEMBER(_size)); - if (PersistMgr->m_Saving) { - if (m_Size > 0) PersistMgr->PutBytes((byte *)m_Buffer, m_Size); + if (PersistMgr->_saving) { + if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); } else { - if (m_Size > 0) { - m_Buffer = malloc(m_Size); - PersistMgr->GetBytes((byte *)m_Buffer, m_Size); - } else m_Buffer = NULL; + if (_size > 0) { + _buffer = malloc(_size); + PersistMgr->GetBytes((byte *)_buffer, _size); + } else _buffer = NULL; } return S_OK; @@ -468,7 +468,7 @@ HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// int CSXMemBuffer::ScCompare(CBScriptable *Val) { - if (m_Buffer == Val->ScToMemBuffer()) return 0; + if (_buffer == Val->ScToMemBuffer()) return 0; else return 1; } diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h index e44761b723..715d860302 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.h +++ b/engines/wintermute/scriptables/SXMemBuffer.h @@ -46,10 +46,10 @@ public: CSXMemBuffer(CBGame *inGame, void *Buffer); virtual ~CSXMemBuffer(); virtual void *ScToMemBuffer(); - int m_Size; + int _size; private: HRESULT Resize(int NewSize); - void *m_Buffer; + void *_buffer; void Cleanup(); bool CheckBounds(CScScript *Script, int Start, int Length); }; diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index cdd62599d4..74217b9907 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -45,10 +45,10 @@ CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { StoreKit_SetExternalData((void *)this); #endif - m_EventsEnabled = false; - m_LastProductRequestOwner = NULL; - m_LastPurchaseOwner = NULL; - m_LastRestoreOwner = NULL; + _eventsEnabled = false; + _lastProductRequestOwner = NULL; + _lastPurchaseOwner = NULL; + _lastRestoreOwner = NULL; } @@ -61,19 +61,19 @@ CSXStore::~CSXStore() { void CSXStore::Cleanup() { SetEventsEnabled(NULL, false); - for (int i = 0; i < m_ValidProducts.GetSize(); i++) { - delete m_ValidProducts[i]; + for (int i = 0; i < _validProducts.GetSize(); i++) { + delete _validProducts[i]; } - m_ValidProducts.RemoveAll(); + _validProducts.RemoveAll(); - for (int i = 0; i < m_Transactions.GetSize(); i++) { - delete m_Transactions[i]; + for (int i = 0; i < _transactions.GetSize(); i++) { + delete _transactions[i]; } - m_Transactions.RemoveAll(); + _transactions.RemoveAll(); - m_LastProductRequestOwner = m_LastPurchaseOwner = m_LastRestoreOwner = NULL; + _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL; } ////////////////////////////////////////////////////////////////////////// @@ -102,7 +102,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "ValidateProducts") == 0) { stack->CorrectParams(1); char *prodIdList = stack->Pop()->GetString(); - m_LastProductRequestOwner = script->m_Owner; + _lastProductRequestOwner = script->_owner; ValidateProducts(prodIdList); stack->PushNULL(); return S_OK; @@ -113,13 +113,13 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetValidProduct") == 0) { stack->CorrectParams(1); int index = stack->Pop()->GetInt(); - if (index >= 0 && index < m_ValidProducts.GetSize()) { + if (index >= 0 && index < _validProducts.GetSize()) { CScValue *prod = stack->GetPushValue(); if (prod) { - prod->SetProperty("Id", m_ValidProducts[index]->GetId()); - prod->SetProperty("Name", m_ValidProducts[index]->GetName()); - prod->SetProperty("Description", m_ValidProducts[index]->GetDesc()); - prod->SetProperty("Price", m_ValidProducts[index]->GetPrice()); + prod->SetProperty("Id", _validProducts[index]->GetId()); + prod->SetProperty("Name", _validProducts[index]->GetName()); + prod->SetProperty("Description", _validProducts[index]->GetDesc()); + prod->SetProperty("Price", _validProducts[index]->GetPrice()); } } else stack->PushNULL(); @@ -132,8 +132,8 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetInvalidProduct") == 0) { stack->CorrectParams(1); int index = stack->Pop()->GetInt(); - if (index >= 0 && index < m_InvalidProducts.size()) - stack->PushString(m_InvalidProducts[index].c_str()); + if (index >= 0 && index < _invalidProducts.size()) + stack->PushString(_invalidProducts[index].c_str()); else stack->PushNULL(); @@ -145,12 +145,12 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetTransaction") == 0) { stack->CorrectParams(1); int index = stack->Pop()->GetInt(); - if (index >= 0 && index < m_Transactions.GetSize()) { + if (index >= 0 && index < _transactions.GetSize()) { CScValue *trans = stack->GetPushValue(); if (trans) { - trans->SetProperty("Id", m_Transactions[index]->GetId()); - trans->SetProperty("ProductId", m_Transactions[index]->GetProductId()); - trans->SetProperty("State", m_Transactions[index]->GetState()); + trans->SetProperty("Id", _transactions[index]->GetId()); + trans->SetProperty("ProductId", _transactions[index]->GetProductId()); + trans->SetProperty("State", _transactions[index]->GetState()); } } else stack->PushNULL(); @@ -195,8 +195,8 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->CorrectParams(1); char *prodId = stack->Pop()->GetString(); - Game->m_Registry->WriteBool("Purchases", prodId, true); - Game->m_Registry->SaveValues(); + Game->_registry->WriteBool("Purchases", prodId, true); + Game->_registry->SaveValues(); stack->PushBool(true); @@ -210,7 +210,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->CorrectParams(1); char *prodId = stack->Pop()->GetString(); - stack->PushBool(Game->m_Registry->ReadBool("Purchases", prodId, false)); + stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); return S_OK; } @@ -221,80 +221,80 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CSXStore::ScGetProperty(char *name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - m_ScValue->SetString("store"); - return m_ScValue; + _scValue->SetString("store"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Available (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Available") == 0) { - m_ScValue->SetBool(IsAvailable()); - return m_ScValue; + _scValue->SetBool(IsAvailable()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // EventsEnabled (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EventsEnabled") == 0) { - m_ScValue->SetBool(GetEventsEnabled()); - return m_ScValue; + _scValue->SetBool(GetEventsEnabled()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumValidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumValidProducts") == 0) { - m_ScValue->SetInt(m_ValidProducts.GetSize()); - return m_ScValue; + _scValue->SetInt(_validProducts.GetSize()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumInvalidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumInvalidProducts") == 0) { - m_ScValue->SetInt(m_InvalidProducts.size()); - return m_ScValue; + _scValue->SetInt(_invalidProducts.size()); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumTransactions (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumTransactions") == 0) { - m_ScValue->SetInt(m_Transactions.GetSize()); - return m_ScValue; + _scValue->SetInt(_transactions.GetSize()); + return _scValue; } - else return m_ScValue; + else return _scValue; } ////////////////////////////////////////////////////////////////////////// HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->m_Saving) Cleanup(); + if (!PersistMgr->_saving) Cleanup(); CBObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(m_EventsEnabled)); - PersistMgr->Transfer(TMEMBER(m_LastProductRequestOwner)); - PersistMgr->Transfer(TMEMBER(m_LastPurchaseOwner)); - PersistMgr->Transfer(TMEMBER(m_LastRestoreOwner)); - PersistMgr->Transfer(TMEMBER(m_InvalidProducts)); + PersistMgr->Transfer(TMEMBER(_eventsEnabled)); + PersistMgr->Transfer(TMEMBER(_lastProductRequestOwner)); + PersistMgr->Transfer(TMEMBER(_lastPurchaseOwner)); + PersistMgr->Transfer(TMEMBER(_lastRestoreOwner)); + PersistMgr->Transfer(TMEMBER(_invalidProducts)); // persist valid products int numProducts; - if (PersistMgr->m_Saving) { - numProducts = m_ValidProducts.GetSize(); + if (PersistMgr->_saving) { + numProducts = _validProducts.GetSize(); PersistMgr->Transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) m_ValidProducts[i]->Persist(PersistMgr); + for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(PersistMgr); } else { - numProducts = m_ValidProducts.GetSize(); + numProducts = _validProducts.GetSize(); PersistMgr->Transfer(TMEMBER(numProducts)); for (int i = 0; i < numProducts; i++) { CBStoreProduct *prod = new CBStoreProduct; prod->Persist(PersistMgr); - m_ValidProducts.Add(prod); + _validProducts.Add(prod); } } @@ -304,7 +304,7 @@ HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSXStore::AfterLoad() { - if (m_EventsEnabled) { + if (_eventsEnabled) { SetEventsEnabled(NULL, true); } #ifdef __IPHONEOS__ @@ -314,22 +314,22 @@ void CSXStore::AfterLoad() { ////////////////////////////////////////////////////////////////////////// void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { - if (m_LastProductRequestOwner == obj) m_LastProductRequestOwner = NULL; - if (m_LastPurchaseOwner == obj) m_LastPurchaseOwner = NULL; - if (m_LastRestoreOwner == obj) m_LastRestoreOwner = NULL; + if (_lastProductRequestOwner == obj) _lastProductRequestOwner = NULL; + if (_lastPurchaseOwner == obj) _lastPurchaseOwner = NULL; + if (_lastRestoreOwner == obj) _lastRestoreOwner = NULL; } ////////////////////////////////////////////////////////////////////////// void CSXStore::SetEventsEnabled(CScScript *script, bool val) { - m_EventsEnabled = val; + _eventsEnabled = val; if (val) { - if (script) m_LastPurchaseOwner = script->m_Owner; + if (script) _lastPurchaseOwner = script->_owner; #ifdef __IPHONEOS__ StoreKit_EnableEvents(); #endif } else { - m_LastPurchaseOwner = NULL; + _lastPurchaseOwner = NULL; #ifdef __IPHONEOS__ StoreKit_DisableEvents(); #endif @@ -354,48 +354,48 @@ bool CSXStore::IsAvailable() { ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveProductsStart() { - for (int i = 0; i < m_ValidProducts.GetSize(); i++) { - delete m_ValidProducts[i]; + for (int i = 0; i < _validProducts.GetSize(); i++) { + delete _validProducts[i]; } - m_ValidProducts.RemoveAll(); + _validProducts.RemoveAll(); - m_InvalidProducts.clear(); + _invalidProducts.clear(); } ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveProductsEnd() { - if (m_LastProductRequestOwner) m_LastProductRequestOwner->ApplyEvent("ProductsValidated"); + if (_lastProductRequestOwner) _lastProductRequestOwner->ApplyEvent("ProductsValidated"); } ////////////////////////////////////////////////////////////////////////// void CSXStore::AddValidProduct(const char *id, const char *name, const char *desc, const char *price) { CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); - m_ValidProducts.Add(prod); + _validProducts.Add(prod); } ////////////////////////////////////////////////////////////////////////// void CSXStore::AddInvalidProduct(const char *id) { - m_InvalidProducts.push_back(id); + _invalidProducts.push_back(id); } ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveTransactionsStart() { - for (int i = 0; i < m_Transactions.GetSize(); i++) { - delete m_Transactions[i]; + for (int i = 0; i < _transactions.GetSize(); i++) { + delete _transactions[i]; } - m_Transactions.RemoveAll(); + _transactions.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveTransactionsEnd() { - if (m_LastPurchaseOwner) m_LastPurchaseOwner->ApplyEvent("TransactionsUpdated"); + if (_lastPurchaseOwner) _lastPurchaseOwner->ApplyEvent("TransactionsUpdated"); else Game->ApplyEvent("TransactionsUpdated"); } ////////////////////////////////////////////////////////////////////////// void CSXStore::AddTransaction(const char *id, const char *productId, const char *state) { CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); - m_Transactions.Add(trans); + _transactions.Add(trans); } ////////////////////////////////////////////////////////////////////////// @@ -403,9 +403,9 @@ bool CSXStore::Purchase(CScScript *script, const char *productId) { if (!productId) return false; #ifdef __IPHONEOS__ - for (int i = 0; i < m_ValidProducts.GetSize(); i++) { - if (strcmp(productId, m_ValidProducts[i]->GetId()) == 0) { - m_LastPurchaseOwner = script->m_Owner; + for (int i = 0; i < _validProducts.GetSize(); i++) { + if (strcmp(productId, _validProducts[i]->GetId()) == 0) { + _lastPurchaseOwner = script->_owner; StoreKit_Purchase(productId); return true; @@ -420,11 +420,11 @@ bool CSXStore::Purchase(CScScript *script, const char *productId) { bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { if (!transId) return false; #ifdef __IPHONEOS__ - for (int i = 0; i < m_Transactions.GetSize(); i++) { - if (strcmp(transId, m_Transactions[i]->GetId()) == 0) { + for (int i = 0; i < _transactions.GetSize(); i++) { + if (strcmp(transId, _transactions[i]->GetId()) == 0) { if (StoreKit_FinishTransaction(transId) > 0) { - SAFE_DELETE(m_Transactions[i]); - m_Transactions.RemoveAt(i); + SAFE_DELETE(_transactions[i]); + _transactions.RemoveAt(i); return true; } else return false; } @@ -436,7 +436,7 @@ bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { ////////////////////////////////////////////////////////////////////////// void CSXStore::RestoreTransactions(CScScript *script) { - m_LastRestoreOwner = script->m_Owner; + _lastRestoreOwner = script->_owner; #ifdef __IPHONEOS__ StoreKit_RestoreTransactions(); #endif @@ -444,9 +444,9 @@ void CSXStore::RestoreTransactions(CScScript *script) { ////////////////////////////////////////////////////////////////////////// void CSXStore::OnRestoreFinished(bool error) { - if (m_LastRestoreOwner) { - if (error) m_LastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); - else m_LastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); + if (_lastRestoreOwner) { + if (error) _lastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); + else _lastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); } } diff --git a/engines/wintermute/scriptables/SXStore.h b/engines/wintermute/scriptables/SXStore.h index f6a13e9eeb..dd11416a0f 100644 --- a/engines/wintermute/scriptables/SXStore.h +++ b/engines/wintermute/scriptables/SXStore.h @@ -38,88 +38,88 @@ public: class CBStoreProduct { public: CBStoreProduct() { - m_Id = m_Name = m_Desc = m_Price = NULL; + _id = _name = _desc = _price = NULL; } CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { - m_Id = m_Name = m_Desc = m_Price = NULL; + _id = _name = _desc = _price = NULL; - CBUtils::SetString(&m_Id, id); - CBUtils::SetString(&m_Name, name); - CBUtils::SetString(&m_Desc, desc); - CBUtils::SetString(&m_Price, price); + CBUtils::SetString(&_id, id); + CBUtils::SetString(&_name, name); + CBUtils::SetString(&_desc, desc); + CBUtils::SetString(&_price, price); } ~CBStoreProduct() { - delete [] m_Id; - delete [] m_Name; - delete [] m_Desc; - delete [] m_Price; + delete [] _id; + delete [] _name; + delete [] _desc; + delete [] _price; } HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(m_Id)); - PersistMgr->Transfer(TMEMBER(m_Name)); - PersistMgr->Transfer(TMEMBER(m_Desc)); - PersistMgr->Transfer(TMEMBER(m_Price)); + PersistMgr->Transfer(TMEMBER(_id)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_desc)); + PersistMgr->Transfer(TMEMBER(_price)); return S_OK; } const char *GetId() { - return m_Id; + return _id; } const char *GetName() { - return m_Name; + return _name; } const char *GetDesc() { - return m_Desc; + return _desc; } const char *GetPrice() { - return m_Price; + return _price; } private: - char *m_Id; - char *m_Name; - char *m_Desc; - char *m_Price; + char *_id; + char *_name; + char *_desc; + char *_price; }; ////////////////////////////////////////////////////////////////////////// class CBStoreTransaction { public: CBStoreTransaction() { - m_Id = m_ProductId = m_State = NULL; + _id = _productId = _state = NULL; } CBStoreTransaction(const char *id, const char *productId, const char *state) { - m_Id = m_ProductId = m_State = NULL; + _id = _productId = _state = NULL; - CBUtils::SetString(&m_Id, id); - CBUtils::SetString(&m_ProductId, productId); - CBUtils::SetString(&m_State, state); + CBUtils::SetString(&_id, id); + CBUtils::SetString(&_productId, productId); + CBUtils::SetString(&_state, state); } ~CBStoreTransaction() { - delete [] m_Id; - delete [] m_ProductId; - delete [] m_State; + delete [] _id; + delete [] _productId; + delete [] _state; } const char *GetId() { - return m_Id; + return _id; } const char *GetProductId() { - return m_ProductId; + return _productId; } const char *GetState() { - return m_State; + return _state; } private: - char *m_Id; - char *m_ProductId; - char *m_State; + char *_id; + char *_productId; + char *_state; }; @@ -135,7 +135,7 @@ public: bool IsAvailable(); void SetEventsEnabled(CScScript *script, bool val); bool GetEventsEnabled() const { - return m_EventsEnabled; + return _eventsEnabled; } void ValidateProducts(const char *prodIdList); @@ -156,14 +156,14 @@ private: bool FinishTransaction(CScScript *script, const char *transId); void RestoreTransactions(CScScript *script); - bool m_EventsEnabled; - CBArray m_ValidProducts; - AnsiStringArray m_InvalidProducts; - CBScriptHolder *m_LastProductRequestOwner; - CBScriptHolder *m_LastPurchaseOwner; - CBScriptHolder *m_LastRestoreOwner; + bool _eventsEnabled; + CBArray _validProducts; + AnsiStringArray _invalidProducts; + CBScriptHolder *_lastProductRequestOwner; + CBScriptHolder *_lastPurchaseOwner; + CBScriptHolder *_lastRestoreOwner; - CBArray m_Transactions; + CBArray _transactions; }; diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index 0e4daf02aa..4c9f4db146 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -104,7 +104,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th //try { WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); @@ -112,7 +112,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th //WideString subStr = str.substr(start, end - start + 1); WideString subStr(str.c_str() + start, end - start + 1); - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); @@ -142,7 +142,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th // try { WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); @@ -150,7 +150,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th // WideString subStr = str.substr(start, len); WideString subStr(str.c_str() + start, len); - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); @@ -168,14 +168,14 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(0); WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); StringUtil::ToUpperCase(str); - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(str).c_str()); else Stack->PushString(StringUtil::WideToAnsi(str).c_str()); @@ -190,14 +190,14 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(0); WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); StringUtil::ToLowerCase(str); - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) Stack->PushString(StringUtil::WideToUtf8(str).c_str()); else Stack->PushString(StringUtil::WideToAnsi(str).c_str()); @@ -215,13 +215,13 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th int index = Stack->Pop()->GetInt(); WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); WideString toFind; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) toFind = StringUtil::Utf8ToWide(strToFind); else toFind = StringUtil::AnsiToWide(strToFind); @@ -249,13 +249,13 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th WideString str; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) str = StringUtil::Utf8ToWide(_string); else str = StringUtil::AnsiToWide(_string); WideString delims; - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) delims = StringUtil::Utf8ToWide(Separators); else delims = StringUtil::AnsiToWide(Separators); @@ -285,7 +285,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); - if (Game->m_TextEncoding == TEXT_UTF8) + if (Game->_textEncoding == TEXT_UTF8) Val = new CScValue(Game, StringUtil::WideToUtf8(part).c_str()); else Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); @@ -305,36 +305,36 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// CScValue *CSXString::ScGetProperty(char *Name) { - m_ScValue->SetNULL(); + _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Type") == 0) { - m_ScValue->SetString("string"); - return m_ScValue; + _scValue->SetString("string"); + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Length") == 0) { - if (Game->m_TextEncoding == TEXT_UTF8) { + if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(_string); - m_ScValue->SetInt(wstr.size()); + _scValue->SetInt(wstr.size()); } else - m_ScValue->SetInt(strlen(_string)); + _scValue->SetInt(strlen(_string)); - return m_ScValue; + return _scValue; } ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Capacity") == 0) { - m_ScValue->SetInt(_capacity); - return m_ScValue; + _scValue->SetInt(_capacity); + return _scValue; } - else return m_ScValue; + else return _scValue; } @@ -370,7 +370,7 @@ HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_capacity)); - if (PersistMgr->m_Saving) { + if (PersistMgr->_saving) { if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); } else { if (_capacity > 0) { diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 24272766c2..20716cfd04 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -54,31 +54,31 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { char CompilerPath[MAX_PATH]; strcpy(CompilerPath, COMPILER_DLL); - m_CompilerDLL = ::LoadLibrary(CompilerPath); - if (m_CompilerDLL == NULL) { + _compilerDLL = ::LoadLibrary(CompilerPath); + if (_compilerDLL == NULL) { char ModuleName[MAX_PATH]; ::GetModuleFileName(NULL, ModuleName, MAX_PATH); // switch to exe's dir char *ExeDir = CBUtils::GetPath(ModuleName); sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); - m_CompilerDLL = ::LoadLibrary(CompilerPath); + _compilerDLL = ::LoadLibrary(CompilerPath); delete [] ExeDir; } - if (m_CompilerDLL != NULL) { + if (_compilerDLL != NULL) { // bind compiler's functionality - ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(m_CompilerDLL, "CompileBuffer"); - ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(m_CompilerDLL, "CompileFile"); - ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(m_CompilerDLL, "ReleaseBuffer"); - ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(m_CompilerDLL, "SetCallbacks"); - ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(m_CompilerDLL, "DefineFunction"); - ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(m_CompilerDLL, "DefineVariable"); + ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); + ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); + ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); + ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); + ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); + ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { - m_CompilerAvailable = false; - ::FreeLibrary(m_CompilerDLL); - m_CompilerDLL = NULL; + _compilerAvailable = false; + ::FreeLibrary(_compilerDLL); + _compilerDLL = NULL; } else { /* // publish external methods to the compiler @@ -89,50 +89,50 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ExtSetCallbacks(&c, Game); */ - m_CompilerAvailable = true; + _compilerAvailable = true; } - } else m_CompilerAvailable = false; + } else _compilerAvailable = false; #else - m_CompilerAvailable = false; - m_CompilerDLL = NULL; + _compilerAvailable = false; + _compilerDLL = NULL; #endif - if (m_CompilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); + if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); else Game->LOG(0, " Script compiler is NOT available"); - m_Globals = new CScValue(Game); + _globals = new CScValue(Game); // register 'Game' as global variable - if (!m_Globals->PropExists("Game")) { + if (!_globals->PropExists("Game")) { CScValue val(Game); val.SetNative(Game, true); - m_Globals->SetProp("Game", &val); + _globals->SetProp("Game", &val); } // register 'Math' as global variable - if (!m_Globals->PropExists("Math")) { + if (!_globals->PropExists("Math")) { CScValue val(Game); - val.SetNative(Game->m_MathClass, true); - m_Globals->SetProp("Math", &val); + val.SetNative(Game->_mathClass, true); + _globals->SetProp("Math", &val); } // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) m_CachedScripts[i] = NULL; + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; - m_CurrentScript = NULL; + _currentScript = NULL; - m_FileToCompile = NULL; + _fileToCompile = NULL; - m_CompileErrorCallback = NULL; - m_CompileErrorCallbackData = NULL; + _compileErrorCallback = NULL; + _compileErrorCallbackData = NULL; - m_ParseElementCallback = NULL; - m_ParseElementCallbackData = NULL; + _parseElementCallback = NULL; + _parseElementCallbackData = NULL; - m_IsProfiling = false; - m_ProfilingStartTime = 0; + _isProfiling = false; + _profilingStartTime = 0; //EnableProfiling(); } @@ -145,44 +145,44 @@ CScEngine::~CScEngine() { DisableProfiling(); #ifdef __WIN32__ - if (m_CompilerAvailable && m_CompilerDLL) ::FreeLibrary(m_CompilerDLL); + if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); #endif Cleanup(); - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - delete m_Breakpoints[i]; - m_Breakpoints[i] = NULL; + for (int i = 0; i < _breakpoints.GetSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; } - m_Breakpoints.RemoveAll(); + _breakpoints.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::Cleanup() { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (!m_Scripts[i]->m_Thread && m_Scripts[i]->m_Owner) m_Scripts[i]->m_Owner->RemoveScript(m_Scripts[i]); - delete m_Scripts[i]; - m_Scripts.RemoveAt(i); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + delete _scripts[i]; + _scripts.RemoveAt(i); i--; } - m_Scripts.RemoveAll(); + _scripts.RemoveAll(); - delete m_Globals; - m_Globals = NULL; + delete _globals; + _globals = NULL; EmptyScriptCache(); - m_CurrentScript = NULL; // ref only + _currentScript = NULL; // ref only - delete[] m_FileToCompile; - m_FileToCompile = NULL; + delete[] _fileToCompile; + _fileToCompile = NULL; - m_CompileErrorCallback = NULL; - m_CompileErrorCallbackData = NULL; + _compileErrorCallback = NULL; + _compileErrorCallbackData = NULL; - m_ParseElementCallback = NULL; - m_ParseElementCallbackData = NULL; + _parseElementCallback = NULL; + _parseElementCallbackData = NULL; return S_OK; } @@ -191,7 +191,7 @@ HRESULT CScEngine::Cleanup() { ////////////////////////////////////////////////////////////////////////// byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { CBGame *Game = (CBGame *)Data; - return Game->m_FileManager->ReadWholeFile(Filename, Size); + return Game->_fileManager->ReadWholeFile(Filename, Size); } @@ -205,14 +205,14 @@ void WINAPI CScEngine::AddError(void *Data, int Line, char *Text) { CBGame *Game = (CBGame *)Data; if (Game) { - if (Game->m_ScEngine && Game->m_ScEngine->m_FileToCompile) - Game->LOG(0, "Compiling script '%s'...", Game->m_ScEngine->m_FileToCompile); + if (Game->_scEngine && Game->_scEngine->_fileToCompile) + Game->LOG(0, "Compiling script '%s'...", Game->_scEngine->_fileToCompile); Game->LOG(0, " Error@line %d: %s", Line, Text); // redirect to an engine's own callback - if (Game->m_ScEngine && Game->m_ScEngine->m_CompileErrorCallback) { - Game->m_ScEngine->m_CompileErrorCallback(Line, Text, Game->m_ScEngine->m_CompileErrorCallbackData); + if (Game->_scEngine && Game->_scEngine->_compileErrorCallback) { + Game->_scEngine->_compileErrorCallback(Line, Text, Game->_scEngine->_compileErrorCallbackData); } } } @@ -224,8 +224,8 @@ void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *Elemen if (Game) { // redirect to an engine's own callback - if (Game->m_ScEngine && Game->m_ScEngine->m_ParseElementCallback) { - Game->m_ScEngine->m_ParseElementCallback(Line, Type, ElementData, Game->m_ScEngine->m_CompileErrorCallbackData); + if (Game->_scEngine && Game->_scEngine->_parseElementCallback) { + Game->_scEngine->_parseElementCallback(Line, Type, ElementData, Game->_scEngine->_compileErrorCallbackData); } } } @@ -253,10 +253,10 @@ CScScript *CScEngine::RunScript(char *Filename, CBScriptHolder *Owner) { if (Owner)val.SetNative(Owner, true); else val.SetNULL(); - script->m_Globals->SetProp("self", &val); - script->m_Globals->SetProp("this", &val); + script->_globals->SetProp("self", &val); + script->_globals->SetProp("this", &val); - m_Scripts.Add(script); + _scripts.Add(script); Game->GetDebugMgr()->OnScriptInit(script); return script; @@ -271,10 +271,10 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC // is script in cache? if (!IgnoreCache) { for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (m_CachedScripts[i] && scumm_stricmp(m_CachedScripts[i]->m_Filename, Filename) == 0) { - m_CachedScripts[i]->m_Timestamp = CBPlatform::GetTime(); - *OutSize = m_CachedScripts[i]->m_Size; - return m_CachedScripts[i]->m_Buffer; + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename, Filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); + *OutSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; } } } @@ -286,7 +286,7 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC uint32 Size; - byte *Buffer = Game->m_FileManager->ReadWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); if (!Buffer) { Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); return NULL; @@ -297,7 +297,7 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC CompBuffer = Buffer; CompSize = Size; } else { - if (!m_CompilerAvailable) { + if (!_compilerAvailable) { Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", Filename); delete [] Buffer; return NULL; @@ -333,20 +333,20 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC int index; uint32 MinTime = CBPlatform::GetTime(); for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (m_CachedScripts[i] == NULL) { + if (_cachedScripts[i] == NULL) { index = i; break; - } else if (m_CachedScripts[i]->m_Timestamp <= MinTime) { - MinTime = m_CachedScripts[i]->m_Timestamp; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; index = i; } } - if (m_CachedScripts[index] != NULL) delete m_CachedScripts[index]; - m_CachedScripts[index] = CachedScript; + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = CachedScript; - ret = CachedScript->m_Buffer; - *OutSize = CachedScript->m_Size; + ret = CachedScript->_buffer; + *OutSize = CachedScript->_size; } @@ -363,55 +363,55 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC HRESULT CScEngine::Tick() { int i; - if (m_Scripts.GetSize() == 0) return S_OK; + if (_scripts.GetSize() == 0) return S_OK; // resolve waiting scripts - for (i = 0; i < m_Scripts.GetSize(); i++) { + for (i = 0; i < _scripts.GetSize(); i++) { - switch (m_Scripts[i]->m_State) { + switch (_scripts[i]->_state) { case SCRIPT_WAITING: { /* bool obj_found=false; - for(int j=0; jm_RegObjects.GetSize(); j++) + for(int j=0; j_regObjects.GetSize(); j++) { - if(Game->m_RegObjects[j] == m_Scripts[i]->m_WaitObject) + if(Game->_regObjects[j] == _scripts[i]->_waitObject) { - if(Game->m_RegObjects[j]->IsReady()) m_Scripts[i]->Run(); + if(Game->_regObjects[j]->IsReady()) _scripts[i]->Run(); obj_found = true; break; } } - if(!obj_found) m_Scripts[i]->Finish(); // m_WaitObject no longer exists + if(!obj_found) _scripts[i]->Finish(); // _waitObject no longer exists */ - if (Game->ValidObject(m_Scripts[i]->m_WaitObject)) { - if (m_Scripts[i]->m_WaitObject->IsReady()) m_Scripts[i]->Run(); - } else m_Scripts[i]->Finish(); + if (Game->ValidObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->IsReady()) _scripts[i]->Run(); + } else _scripts[i]->Finish(); break; } case SCRIPT_SLEEPING: { - if (m_Scripts[i]->m_WaitFrozen) { - if (m_Scripts[i]->m_WaitTime <= CBPlatform::GetTime()) m_Scripts[i]->Run(); + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->Run(); } else { - if (m_Scripts[i]->m_WaitTime <= Game->m_Timer) m_Scripts[i]->Run(); + if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->Run(); } break; } case SCRIPT_WAITING_SCRIPT: { - if (!IsValidScript(m_Scripts[i]->m_WaitScript) || m_Scripts[i]->m_WaitScript->m_State == SCRIPT_ERROR) { + if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { // fake return value - m_Scripts[i]->m_Stack->PushNULL(); - m_Scripts[i]->m_WaitScript = NULL; - m_Scripts[i]->Run(); + _scripts[i]->_stack->PushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->Run(); } else { - if (m_Scripts[i]->m_WaitScript->m_State == SCRIPT_THREAD_FINISHED) { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { // copy return value - m_Scripts[i]->m_Stack->Push(m_Scripts[i]->m_WaitScript->m_Stack->Pop()); - m_Scripts[i]->Run(); - m_Scripts[i]->m_WaitScript->Finish(); - m_Scripts[i]->m_WaitScript = NULL; + _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); + _scripts[i]->Run(); + _scripts[i]->_waitScript->Finish(); + _scripts[i]->_waitScript = NULL; } } break; @@ -421,34 +421,34 @@ HRESULT CScEngine::Tick() { // execute scripts - for (i = 0; i < m_Scripts.GetSize(); i++) { + for (i = 0; i < _scripts.GetSize(); i++) { // skip paused scripts - if (m_Scripts[i]->m_State == SCRIPT_PAUSED) continue; + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; // time sliced script - if (m_Scripts[i]->m_TimeSlice > 0) { + if (_scripts[i]->_timeSlice > 0) { uint32 StartTime = CBPlatform::GetTime(); - while (m_Scripts[i]->m_State == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < m_Scripts[i]->m_TimeSlice) { - m_CurrentScript = m_Scripts[i]; - m_Scripts[i]->ExecuteInstruction(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); } - if (m_IsProfiling && m_Scripts[i]->m_Filename) AddScriptTime(m_Scripts[i]->m_Filename, CBPlatform::GetTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } // normal script else { uint32 StartTime; - bool isProfiling = m_IsProfiling; + bool isProfiling = _isProfiling; if (isProfiling) StartTime = CBPlatform::GetTime(); - while (m_Scripts[i]->m_State == SCRIPT_RUNNING) { - m_CurrentScript = m_Scripts[i]; - m_Scripts[i]->ExecuteInstruction(); + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); } - if (isProfiling && m_Scripts[i]->m_Filename) AddScriptTime(m_Scripts[i]->m_Filename, CBPlatform::GetTime() - StartTime); + if (isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } - m_CurrentScript = NULL; + _currentScript = NULL; } RemoveFinishedScripts(); @@ -460,15 +460,15 @@ HRESULT CScEngine::Tick() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::TickUnbreakable() { // execute unbreakable scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (!m_Scripts[i]->m_Unbreakable) continue; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; - while (m_Scripts[i]->m_State == SCRIPT_RUNNING) { - m_CurrentScript = m_Scripts[i]; - m_Scripts[i]->ExecuteInstruction(); + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); } - m_Scripts[i]->Finish(); - m_CurrentScript = NULL; + _scripts[i]->Finish(); + _currentScript = NULL; } RemoveFinishedScripts(); @@ -479,12 +479,12 @@ HRESULT CScEngine::TickUnbreakable() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RemoveFinishedScripts() { // remove finished scripts - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_State == SCRIPT_FINISHED || m_Scripts[i]->m_State == SCRIPT_ERROR) { - if (!m_Scripts[i]->m_Thread && m_Scripts[i]->m_Owner) m_Scripts[i]->m_Owner->RemoveScript(m_Scripts[i]); - Game->GetDebugMgr()->OnScriptShutdown(m_Scripts[i]); - delete m_Scripts[i]; - m_Scripts.RemoveAt(i); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + Game->GetDebugMgr()->OnScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.RemoveAt(i); i--; } } @@ -496,9 +496,9 @@ HRESULT CScEngine::RemoveFinishedScripts() { int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { int running = 0, waiting = 0, persistent = 0, total = 0; - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_State == SCRIPT_FINISHED) continue; - switch (m_Scripts[i]->m_State) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { case SCRIPT_RUNNING: case SCRIPT_SLEEPING: case SCRIPT_PAUSED: @@ -524,9 +524,9 @@ int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::EmptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (m_CachedScripts[i]) { - delete m_CachedScripts[i]; - m_CachedScripts[i] = NULL; + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; } } return S_OK; @@ -536,12 +536,12 @@ HRESULT CScEngine::EmptyScriptCache() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::ResetObject(CBObject *Object) { // terminate all scripts waiting for this object - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_State == SCRIPT_WAITING && m_Scripts[i]->m_WaitObject == Object) { - if (!Game->m_CompatKillMethodThreads) ResetScript(m_Scripts[i]); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!Game->_compatKillMethodThreads) ResetScript(_scripts[i]); - bool IsThread = m_Scripts[i]->m_MethodThread || m_Scripts[i]->m_Thread; - m_Scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well } } return S_OK; @@ -550,9 +550,9 @@ HRESULT CScEngine::ResetObject(CBObject *Object) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::ResetScript(CScScript *Script) { // terminate all scripts waiting for this script - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_State == SCRIPT_WAITING_SCRIPT && m_Scripts[i]->m_WaitScript == Script) { - m_Scripts[i]->Finish(); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == Script) { + _scripts[i]->Finish(); } } return S_OK; @@ -560,13 +560,13 @@ HRESULT CScEngine::ResetScript(CScScript *Script) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->m_Saving) Cleanup(); + if (!PersistMgr->_saving) Cleanup(); PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_CurrentScript)); - PersistMgr->Transfer(TMEMBER(m_FileToCompile)); - PersistMgr->Transfer(TMEMBER(m_Globals)); - m_Scripts.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_currentScript)); + PersistMgr->Transfer(TMEMBER(_fileToCompile)); + PersistMgr->Transfer(TMEMBER(_globals)); + _scripts.Persist(PersistMgr); return S_OK; } @@ -574,10 +574,10 @@ HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CScEngine::EditorCleanup() { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_Owner == NULL && (m_Scripts[i]->m_State == SCRIPT_FINISHED || m_Scripts[i]->m_State == SCRIPT_ERROR)) { - delete m_Scripts[i]; - m_Scripts.RemoveAt(i); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.RemoveAt(i); i--; } } @@ -586,8 +586,8 @@ void CScEngine::EditorCleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::PauseAll() { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i] != m_CurrentScript) m_Scripts[i]->Pause(); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->Pause(); } return S_OK; @@ -596,8 +596,8 @@ HRESULT CScEngine::PauseAll() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::ResumeAll() { - for (int i = 0; i < m_Scripts.GetSize(); i++) - m_Scripts[i]->Resume(); + for (int i = 0; i < _scripts.GetSize(); i++) + _scripts[i]->Resume(); return S_OK; } @@ -605,10 +605,10 @@ HRESULT CScEngine::ResumeAll() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::SetFileToCompile(char *Filename) { - delete[] m_FileToCompile; - m_FileToCompile = new char[strlen(Filename) + 1]; - if (m_FileToCompile) { - strcpy(m_FileToCompile, Filename); + delete[] _fileToCompile; + _fileToCompile = new char[strlen(Filename) + 1]; + if (_fileToCompile) { + strcpy(_fileToCompile, Filename); return S_OK; } else return E_FAIL; } @@ -616,46 +616,46 @@ HRESULT CScEngine::SetFileToCompile(char *Filename) { ////////////////////////////////////////////////////////////////////////// void CScEngine::SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data) { - m_CompileErrorCallback = Callback; - m_CompileErrorCallbackData = Data; + _compileErrorCallback = Callback; + _compileErrorCallbackData = Data; } ////////////////////////////////////////////////////////////////////////// void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data) { - m_ParseElementCallback = Callback; - m_ParseElementCallbackData = Data; + _parseElementCallback = Callback; + _parseElementCallbackData = Data; } ////////////////////////////////////////////////////////////////////////// bool CScEngine::IsValidScript(CScScript *Script) { - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i] == Script) return true; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] == Script) return true; } return false; } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::ClearGlobals(bool IncludingNatives) { - m_Globals->CleanProps(IncludingNatives); + _globals->CleanProps(IncludingNatives); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { // send global variables - m_Globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); + _globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); // process normal scripts first - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_Thread || m_Scripts[i]->m_MethodThread) continue; - m_Scripts[i]->DbgSendScript(Client); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->DbgSendScript(Client); } // and threads later - for (int i = 0; i < m_Scripts.GetSize(); i++) { - if (m_Scripts[i]->m_Thread || m_Scripts[i]->m_MethodThread) - m_Scripts[i]->DbgSendScript(Client); + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->DbgSendScript(Client); } return S_OK; @@ -663,24 +663,24 @@ HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + if (!Game->GetDebugMgr()->_enabled) return S_OK; CScBreakpoint *Bp = NULL; - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - if (scumm_stricmp(m_Breakpoints[i]->m_Filename, ScriptFilename) == 0) { - Bp = m_Breakpoints[i]; + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) { + Bp = _breakpoints[i]; break; } } if (Bp == NULL) { Bp = new CScBreakpoint(ScriptFilename); - m_Breakpoints.Add(Bp); + _breakpoints.Add(Bp); } bool Found = false; - for (int i = 0; i < Bp->m_Lines.GetSize(); i++) { - if (Bp->m_Lines[i] == Line) return S_OK; + for (int i = 0; i < Bp->_lines.GetSize(); i++) { + if (Bp->_lines[i] == Line) return S_OK; } - Bp->m_Lines.Add(Line); + Bp->_lines.Add(Line); // refresh changes RefreshScriptBreakpoints(); @@ -690,16 +690,16 @@ HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; - - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - if (scumm_stricmp(m_Breakpoints[i]->m_Filename, ScriptFilename) == 0) { - for (int j = 0; j < m_Breakpoints[i]->m_Lines.GetSize(); j++) { - if (m_Breakpoints[i]->m_Lines[j] == Line) { - m_Breakpoints[i]->m_Lines.RemoveAt(j); - if (m_Breakpoints[i]->m_Lines.GetSize() == 0) { - delete m_Breakpoints[i]; - m_Breakpoints.RemoveAt(i); + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { + if (_breakpoints[i]->_lines[j] == Line) { + _breakpoints[i]->_lines.RemoveAt(j); + if (_breakpoints[i]->_lines.GetSize() == 0) { + delete _breakpoints[i]; + _breakpoints.RemoveAt(i); } // refresh changes RefreshScriptBreakpoints(); @@ -715,65 +715,65 @@ HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RefreshScriptBreakpoints() { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + if (!Game->GetDebugMgr()->_enabled) return S_OK; - for (int i = 0; i < m_Scripts.GetSize(); i++) { - RefreshScriptBreakpoints(m_Scripts[i]); + for (int i = 0; i < _scripts.GetSize(); i++) { + RefreshScriptBreakpoints(_scripts[i]); } return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + if (!Game->GetDebugMgr()->_enabled) return S_OK; - if (!Script || !Script->m_Filename) return E_FAIL; + if (!Script || !Script->_filename) return E_FAIL; - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - if (scumm_stricmp(m_Breakpoints[i]->m_Filename, Script->m_Filename) == 0) { - Script->m_Breakpoints.Copy(m_Breakpoints[i]->m_Lines); + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename, Script->_filename) == 0) { + Script->_breakpoints.Copy(_breakpoints[i]->_lines); return S_OK; } } - if (Script->m_Breakpoints.GetSize() > 0) Script->m_Breakpoints.RemoveAll(); + if (Script->_breakpoints.GetSize() > 0) Script->_breakpoints.RemoveAll(); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::SaveBreakpoints() { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + if (!Game->GetDebugMgr()->_enabled) return S_OK; char Text[512]; char Key[100]; int Count = 0; - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - for (int j = 0; j < m_Breakpoints[i]->m_Lines.GetSize(); j++) { + for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { Count++; sprintf(Key, "Breakpoint%d", Count); - sprintf(Text, "%s:%d", m_Breakpoints[i]->m_Filename, m_Breakpoints[i]->m_Lines[j]); + sprintf(Text, "%s:%d", _breakpoints[i]->_filename, _breakpoints[i]->_lines[j]); - Game->m_Registry->WriteString("Debug", Key, Text); + Game->_registry->WriteString("Debug", Key, Text); } } - Game->m_Registry->WriteInt("Debug", "NumBreakpoints", Count); + Game->_registry->WriteInt("Debug", "NumBreakpoints", Count); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::LoadBreakpoints() { - if (!Game->GetDebugMgr()->m_Enabled) return S_OK; + if (!Game->GetDebugMgr()->_enabled) return S_OK; char Key[100]; - int Count = Game->m_Registry->ReadInt("Debug", "NumBreakpoints", 0); + int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= Count; i++) { uint32 BufSize = 512; sprintf(Key, "Breakpoint%d", i); - AnsiString breakpoint = Game->m_Registry->ReadString("Debug", Key, ""); + AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); char *Path = CBUtils::StrEntry(0, breakpoint.c_str(), ':'); char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); @@ -791,45 +791,45 @@ HRESULT CScEngine::LoadBreakpoints() { ////////////////////////////////////////////////////////////////////////// void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { - if (!m_IsProfiling) return; + if (!_isProfiling) return; AnsiString fileName = Filename; StringUtil::ToLowerCase(fileName); - m_ScriptTimes[fileName] += Time; + _scriptTimes[fileName] += Time; } ////////////////////////////////////////////////////////////////////////// void CScEngine::EnableProfiling() { - if (m_IsProfiling) return; + if (_isProfiling) return; // destroy old data, if any - m_ScriptTimes.clear(); + _scriptTimes.clear(); - m_ProfilingStartTime = CBPlatform::GetTime(); - m_IsProfiling = true; + _profilingStartTime = CBPlatform::GetTime(); + _isProfiling = true; } ////////////////////////////////////////////////////////////////////////// void CScEngine::DisableProfiling() { - if (!m_IsProfiling) return; + if (!_isProfiling) return; DumpStats(); - m_IsProfiling = false; + _isProfiling = false; } ////////////////////////////////////////////////////////////////////////// void CScEngine::DumpStats() { error("DumpStats not ported to ScummVM yet"); -/* uint32 totalTime = CBPlatform::GetTime() - m_ProfilingStartTime; +/* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; ScriptTimes::iterator it; - for (it = m_ScriptTimes.begin(); it != m_ScriptTimes.end(); it++) { + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { times.push_back(std::pair (it->_value, it->_key)); } std::sort(times.begin(), times.end()); diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 13103f6d3c..7be147b39e 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -58,39 +58,39 @@ public: class CScCachedScript { public: CScCachedScript(char *Filename, byte *Buffer, uint32 Size) { - m_Timestamp = CBPlatform::GetTime(); - m_Buffer = new byte[Size]; - if (m_Buffer) memcpy(m_Buffer, Buffer, Size); - m_Size = Size; - m_Filename = new char[strlen(Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Filename); + _timestamp = CBPlatform::GetTime(); + _buffer = new byte[Size]; + if (_buffer) memcpy(_buffer, Buffer, Size); + _size = Size; + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); }; ~CScCachedScript() { - if (m_Buffer) delete [] m_Buffer; - if (m_Filename) delete [] m_Filename; + if (_buffer) delete [] _buffer; + if (_filename) delete [] _filename; }; - uint32 m_Timestamp; - byte *m_Buffer; - uint32 m_Size; - char *m_Filename; + uint32 _timestamp; + byte *_buffer; + uint32 _size; + char *_filename; }; class CScBreakpoint { public: CScBreakpoint(const char *Filename) { - m_Filename = NULL; - CBUtils::SetString(&m_Filename, Filename); + _filename = NULL; + CBUtils::SetString(&_filename, Filename); } ~CScBreakpoint() { - if (m_Filename) delete [] m_Filename; - m_Lines.RemoveAll(); + if (_filename) delete [] _filename; + _lines.RemoveAll(); } - char *m_Filename; - CBArray m_Lines; + char *_filename; + CBArray _lines; }; @@ -99,7 +99,7 @@ public: public: HRESULT DbgSendScripts(IWmeDebugClient *Client); - CBArray m_Breakpoints; + CBArray _breakpoints; HRESULT AddBreakpoint(char *ScriptFilename, int Line); HRESULT RemoveBreakpoint(char *ScriptFilename, int Line); HRESULT RefreshScriptBreakpoints(); @@ -114,15 +114,15 @@ public: void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); - COMPILE_ERROR_CALLBACK m_CompileErrorCallback; - void *m_CompileErrorCallbackData; + COMPILE_ERROR_CALLBACK _compileErrorCallback; + void *_compileErrorCallbackData; - PARSE_ELEMENT_CALLBACK m_ParseElementCallback; - void *m_ParseElementCallbackData; + PARSE_ELEMENT_CALLBACK _parseElementCallback; + void *_parseElementCallbackData; HRESULT SetFileToCompile(char *Filename); - char *m_FileToCompile; - CScScript *m_CurrentScript; + char *_fileToCompile; + CScScript *_currentScript; HRESULT ResumeAll(); HRESULT PauseAll(); void EditorCleanup(); @@ -134,10 +134,10 @@ public: HRESULT Cleanup(); int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); HRESULT Tick(); - CScValue *m_Globals; + CScValue *_globals; CScScript *RunScript(char *Filename, CBScriptHolder *Owner = NULL); - bool m_CompilerAvailable; - HINSTANCE m_CompilerDLL; + bool _compilerAvailable; + HINSTANCE _compilerDLL; CScEngine(CBGame *inGame); virtual ~CScEngine(); static void WINAPI AddError(void *Data, int Line, char *Text); @@ -151,12 +151,12 @@ public: DLL_DEFINE_FUNCTION ExtDefineFunction; DLL_DEFINE_VARIABLE ExtDefineVariable; - CBArray m_Scripts; + CBArray _scripts; void EnableProfiling(); void DisableProfiling(); bool IsProfiling() { - return m_IsProfiling; + return _isProfiling; } void AddScriptTime(const char *Filename, uint32 Time); @@ -164,12 +164,12 @@ public: private: - CScCachedScript *m_CachedScripts[MAX_CACHED_SCRIPTS]; - bool m_IsProfiling; - uint32 m_ProfilingStartTime; + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; typedef Common::HashMap ScriptTimes; - ScriptTimes m_ScriptTimes; + ScriptTimes _scriptTimes; }; diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp index e954fe9d9f..4d9edf9db4 100644 --- a/engines/wintermute/scriptables/ScScript.cpp +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -39,59 +39,59 @@ IMPLEMENT_PERSISTENT(CScScript, false) ////////////////////////////////////////////////////////////////////////// CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { - m_Buffer = NULL; - m_BufferSize = m_IP = 0; - m_Filename = NULL; - m_CurrentLine = 0; + _buffer = NULL; + _bufferSize = _iP = 0; + _filename = NULL; + _currentLine = 0; - m_Symbols = NULL; - m_NumSymbols = 0; + _symbols = NULL; + _numSymbols = 0; - m_Engine = Engine; + _engine = Engine; - m_Globals = NULL; + _globals = NULL; - m_ScopeStack = NULL; - m_CallStack = NULL; - m_ThisStack = NULL; - m_Stack = NULL; + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; - m_Operand = NULL; - m_Reg1 = NULL; + _operand = NULL; + _reg1 = NULL; - m_Functions = NULL; - m_NumFunctions = 0; + _functions = NULL; + _numFunctions = 0; - m_Methods = NULL; - m_NumMethods = 0; + _methods = NULL; + _numMethods = 0; - m_Events = NULL; - m_NumEvents = 0; + _events = NULL; + _numEvents = 0; - m_Externals = NULL; - m_NumExternals = 0; + _externals = NULL; + _numExternals = 0; - m_State = SCRIPT_FINISHED; - m_OrigState = SCRIPT_FINISHED; + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; - m_WaitObject = NULL; - m_WaitTime = 0; - m_WaitFrozen = false; - m_WaitScript = NULL; + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; - m_TimeSlice = 0; + _timeSlice = 0; - m_Thread = false; - m_MethodThread = false; - m_ThreadEvent = NULL; + _thread = false; + _methodThread = false; + _threadEvent = NULL; - m_Freezable = true; - m_Owner = NULL; + _freezable = true; + _owner = NULL; - m_Unbreakable = false; - m_ParentScript = NULL; + _unbreakable = false; + _parentScript = NULL; - m_TracingMode = false; + _tracingMode = false; } @@ -104,15 +104,15 @@ CScScript::~CScScript() { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::InitScript() { - TScriptHeader *Header = (TScriptHeader *)m_Buffer; + TScriptHeader *Header = (TScriptHeader *)_buffer; if (Header->magic != SCRIPT_MAGIC) { - Game->LOG(0, "File '%s' is not a valid compiled script", m_Filename); + Game->LOG(0, "File '%s' is not a valid compiled script", _filename); Cleanup(); return E_FAIL; } if (Header->version > SCRIPT_VERSION) { - Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", m_Filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); Cleanup(); return E_FAIL; } @@ -120,25 +120,25 @@ HRESULT CScScript::InitScript() { InitTables(); // init stacks - m_ScopeStack = new CScStack(Game); - m_CallStack = new CScStack(Game); - m_ThisStack = new CScStack(Game); - m_Stack = new CScStack(Game); + _scopeStack = new CScStack(Game); + _callStack = new CScStack(Game); + _thisStack = new CScStack(Game); + _stack = new CScStack(Game); - m_Operand = new CScValue(Game); - m_Reg1 = new CScValue(Game); + _operand = new CScValue(Game); + _reg1 = new CScValue(Game); // skip to the beginning - m_IP = Header->code_start; - m_CurrentLine = 0; + _iP = Header->code_start; + _currentLine = 0; // init breakpoints - m_Engine->RefreshScriptBreakpoints(this); + _engine->RefreshScriptBreakpoints(this); // ready to rumble... - m_State = SCRIPT_RUNNING; + _state = SCRIPT_RUNNING; return S_OK; } @@ -146,77 +146,77 @@ HRESULT CScScript::InitScript() { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::InitTables() { - uint32 OrigIP = m_IP; + uint32 OrigIP = _iP; - TScriptHeader *Header = (TScriptHeader *)m_Buffer; + TScriptHeader *Header = (TScriptHeader *)_buffer; uint32 i; // load symbol table - m_IP = Header->symbol_table; + _iP = Header->symbol_table; - m_NumSymbols = GetDWORD(); - m_Symbols = new char*[m_NumSymbols]; - for (i = 0; i < m_NumSymbols; i++) { + _numSymbols = GetDWORD(); + _symbols = new char*[_numSymbols]; + for (i = 0; i < _numSymbols; i++) { uint32 index = GetDWORD(); - m_Symbols[index] = GetString(); + _symbols[index] = GetString(); } // load functions table - m_IP = Header->func_table; + _iP = Header->func_table; - m_NumFunctions = GetDWORD(); - m_Functions = new TFunctionPos[m_NumFunctions]; - for (i = 0; i < m_NumFunctions; i++) { - m_Functions[i].pos = GetDWORD(); - m_Functions[i].name = GetString(); + _numFunctions = GetDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (i = 0; i < _numFunctions; i++) { + _functions[i].pos = GetDWORD(); + _functions[i].name = GetString(); } // load events table - m_IP = Header->event_table; + _iP = Header->event_table; - m_NumEvents = GetDWORD(); - m_Events = new TEventPos[m_NumEvents]; - for (i = 0; i < m_NumEvents; i++) { - m_Events[i].pos = GetDWORD(); - m_Events[i].name = GetString(); + _numEvents = GetDWORD(); + _events = new TEventPos[_numEvents]; + for (i = 0; i < _numEvents; i++) { + _events[i].pos = GetDWORD(); + _events[i].name = GetString(); } // load externals if (Header->version >= 0x0101) { - m_IP = Header->externals_table; - - m_NumExternals = GetDWORD(); - m_Externals = new TExternalFunction[m_NumExternals]; - for (i = 0; i < m_NumExternals; i++) { - m_Externals[i].dll_name = GetString(); - m_Externals[i].name = GetString(); - m_Externals[i].call_type = (TCallType)GetDWORD(); - m_Externals[i].returns = (TExternalType)GetDWORD(); - m_Externals[i].num_params = GetDWORD(); - if (m_Externals[i].num_params > 0) { - m_Externals[i].params = new TExternalType[m_Externals[i].num_params]; - for (int j = 0; j < m_Externals[i].num_params; j++) { - m_Externals[i].params[j] = (TExternalType)GetDWORD(); + _iP = Header->externals_table; + + _numExternals = GetDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (i = 0; i < _numExternals; i++) { + _externals[i].dll_name = GetString(); + _externals[i].name = GetString(); + _externals[i].call_type = (TCallType)GetDWORD(); + _externals[i].returns = (TExternalType)GetDWORD(); + _externals[i].nu_params = GetDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)GetDWORD(); } } } } // load method table - m_IP = Header->method_table; + _iP = Header->method_table; - m_NumMethods = GetDWORD(); - m_Methods = new TMethodPos[m_NumMethods]; - for (i = 0; i < m_NumMethods; i++) { - m_Methods[i].pos = GetDWORD(); - m_Methods[i].name = GetString(); + _numMethods = GetDWORD(); + _methods = new TMethodPos[_numMethods]; + for (i = 0; i < _numMethods; i++) { + _methods[i].pos = GetDWORD(); + _methods[i].name = GetString(); } - m_IP = OrigIP; + _iP = OrigIP; return S_OK; } @@ -226,29 +226,29 @@ HRESULT CScScript::InitTables() { HRESULT CScScript::Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { Cleanup(); - m_Thread = false; - m_MethodThread = false; + _thread = false; + _methodThread = false; - delete[] m_ThreadEvent; - m_ThreadEvent = NULL; + delete[] _threadEvent; + _threadEvent = NULL; - m_Filename = new char[strlen(Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Filename); + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); - m_Buffer = new byte [Size]; - if (!m_Buffer) return E_FAIL; + _buffer = new byte [Size]; + if (!_buffer) return E_FAIL; - memcpy(m_Buffer, Buffer, Size); + memcpy(_buffer, Buffer, Size); - m_BufferSize = Size; + _bufferSize = Size; HRESULT res = InitScript(); if (FAILED(res)) return res; // establish global variables table - m_Globals = new CScValue(Game); + _globals = new CScValue(Game); - m_Owner = Owner; + _owner = Owner; return S_OK; } @@ -258,38 +258,38 @@ HRESULT CScScript::Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHol HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { Cleanup(); - m_Thread = true; - m_MethodThread = false; - m_ThreadEvent = new char[strlen(EventName) + 1]; - if (m_ThreadEvent) strcpy(m_ThreadEvent, EventName); + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(EventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, EventName); // copy filename - m_Filename = new char[strlen(Original->m_Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Original->m_Filename); + _filename = new char[strlen(Original->_filename) + 1]; + if (_filename) strcpy(_filename, Original->_filename); // copy buffer - m_Buffer = new byte [Original->m_BufferSize]; - if (!m_Buffer) return E_FAIL; + _buffer = new byte [Original->_bufferSize]; + if (!_buffer) return E_FAIL; - memcpy(m_Buffer, Original->m_Buffer, Original->m_BufferSize); - m_BufferSize = Original->m_BufferSize; + memcpy(_buffer, Original->_buffer, Original->_bufferSize); + _bufferSize = Original->_bufferSize; // initialize HRESULT res = InitScript(); if (FAILED(res)) return res; // copy globals - m_Globals = Original->m_Globals; + _globals = Original->_globals; // skip to the beginning of the event - m_IP = InitIP; + _iP = InitIP; - m_TimeSlice = Original->m_TimeSlice; - m_Freezable = Original->m_Freezable; - m_Owner = Original->m_Owner; + _timeSlice = Original->_timeSlice; + _freezable = Original->_freezable; + _owner = Original->_owner; - m_Engine = Original->m_Engine; - m_ParentScript = Original; + _engine = Original->_engine; + _parentScript = Original; return S_OK; } @@ -304,38 +304,38 @@ HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodNam Cleanup(); - m_Thread = true; - m_MethodThread = true; - m_ThreadEvent = new char[strlen(MethodName) + 1]; - if (m_ThreadEvent) strcpy(m_ThreadEvent, MethodName); + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(MethodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, MethodName); // copy filename - m_Filename = new char[strlen(Original->m_Filename) + 1]; - if (m_Filename) strcpy(m_Filename, Original->m_Filename); + _filename = new char[strlen(Original->_filename) + 1]; + if (_filename) strcpy(_filename, Original->_filename); // copy buffer - m_Buffer = new byte [Original->m_BufferSize]; - if (!m_Buffer) return E_FAIL; + _buffer = new byte [Original->_bufferSize]; + if (!_buffer) return E_FAIL; - memcpy(m_Buffer, Original->m_Buffer, Original->m_BufferSize); - m_BufferSize = Original->m_BufferSize; + memcpy(_buffer, Original->_buffer, Original->_bufferSize); + _bufferSize = Original->_bufferSize; // initialize HRESULT res = InitScript(); if (FAILED(res)) return res; // copy globals - m_Globals = Original->m_Globals; + _globals = Original->_globals; // skip to the beginning of the event - m_IP = IP; + _iP = IP; - m_TimeSlice = Original->m_TimeSlice; - m_Freezable = Original->m_Freezable; - m_Owner = Original->m_Owner; + _timeSlice = Original->_timeSlice; + _freezable = Original->_freezable; + _owner = Original->_owner; - m_Engine = Original->m_Engine; - m_ParentScript = Original; + _engine = Original->_engine; + _parentScript = Original; return S_OK; } @@ -343,76 +343,76 @@ HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodNam ////////////////////////////////////////////////////////////////////////// void CScScript::Cleanup() { - if (m_Buffer) delete [] m_Buffer; - m_Buffer = NULL; + if (_buffer) delete [] _buffer; + _buffer = NULL; - if (m_Filename) delete [] m_Filename; - m_Filename = NULL; + if (_filename) delete [] _filename; + _filename = NULL; - if (m_Symbols) delete [] m_Symbols; - m_Symbols = NULL; - m_NumSymbols = 0; + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; - if (m_Globals && !m_Thread) delete m_Globals; - m_Globals = NULL; + if (_globals && !_thread) delete _globals; + _globals = NULL; - if (m_ScopeStack) delete m_ScopeStack; - m_ScopeStack = NULL; + if (_scopeStack) delete _scopeStack; + _scopeStack = NULL; - if (m_CallStack) delete m_CallStack; - m_CallStack = NULL; + if (_callStack) delete _callStack; + _callStack = NULL; - if (m_ThisStack) delete m_ThisStack; - m_ThisStack = NULL; + if (_thisStack) delete _thisStack; + _thisStack = NULL; - if (m_Stack) delete m_Stack; - m_Stack = NULL; + if (_stack) delete _stack; + _stack = NULL; - if (m_Functions) delete [] m_Functions; - m_Functions = NULL; - m_NumFunctions = 0; + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; - if (m_Methods) delete [] m_Methods; - m_Methods = NULL; - m_NumMethods = 0; + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; - if (m_Events) delete [] m_Events; - m_Events = NULL; - m_NumEvents = 0; + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; - if (m_Externals) { - for (int i = 0; i < m_NumExternals; i++) { - if (m_Externals[i].num_params > 0) delete [] m_Externals[i].params; + if (_externals) { + for (int i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; } - delete [] m_Externals; + delete [] _externals; } - m_Externals = NULL; - m_NumExternals = 0; + _externals = NULL; + _numExternals = 0; - delete m_Operand; - delete m_Reg1; - m_Operand = NULL; - m_Reg1 = NULL; + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; - delete[] m_ThreadEvent; - m_ThreadEvent = NULL; + delete[] _threadEvent; + _threadEvent = NULL; - m_State = SCRIPT_FINISHED; + _state = SCRIPT_FINISHED; - m_WaitObject = NULL; - m_WaitTime = 0; - m_WaitFrozen = false; - m_WaitScript = NULL; + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; - m_ParentScript = NULL; // ref only + _parentScript = NULL; // ref only } ////////////////////////////////////////////////////////////////////////// uint32 CScScript::GetDWORD() { - uint32 ret = *(uint32 *)(m_Buffer + m_IP); - m_IP += sizeof(uint32); + uint32 ret = *(uint32 *)(_buffer + _iP); + _iP += sizeof(uint32); return ret; } @@ -420,8 +420,8 @@ uint32 CScScript::GetDWORD() { ////////////////////////////////////////////////////////////////////////// double CScScript::GetFloat() { - double ret = *(double *)(m_Buffer + m_IP); - m_IP += sizeof(double); + double ret = *(double *)(_buffer + _iP); + _iP += sizeof(double); return ret; } @@ -429,9 +429,9 @@ double CScScript::GetFloat() { ////////////////////////////////////////////////////////////////////////// char *CScScript::GetString() { - char *ret = (char *)(m_Buffer + m_IP); - while (*(char *)(m_Buffer + m_IP) != '\0') m_IP++; - m_IP++; // string terminator + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator return ret; } @@ -445,7 +445,7 @@ HRESULT CScScript::ExecuteInstruction() { char *str; //CScValue* op = new CScValue(Game); - m_Operand->Cleanup(); + _operand->Cleanup(); CScValue *op1; CScValue *op2; @@ -454,16 +454,16 @@ HRESULT CScScript::ExecuteInstruction() { switch (inst) { case II_DEF_VAR: - m_Operand->SetNULL(); + _operand->SetNULL(); dw = GetDWORD(); - if (m_ScopeStack->m_SP < 0) { - m_Globals->SetProp(m_Symbols[dw], m_Operand); - if (Game->GetDebugMgr()->m_Enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, m_Globals->GetProp(m_Symbols[dw]), m_Symbols[dw]); + if (_scopeStack->_sP < 0) { + _globals->SetProp(_symbols[dw], _operand); + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); } else { - m_ScopeStack->GetTop()->SetProp(m_Symbols[dw], m_Operand); - if (Game->GetDebugMgr()->m_Enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, m_ScopeStack->GetTop(), m_ScopeStack->GetTop()->GetProp(m_Symbols[dw]), m_Symbols[dw]); + _scopeStack->GetTop()->SetProp(_symbols[dw], _operand); + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->GetTop(), _scopeStack->GetTop()->GetProp(_symbols[dw]), _symbols[dw]); } break; @@ -471,89 +471,89 @@ HRESULT CScScript::ExecuteInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { dw = GetDWORD(); - char *Temp = m_Symbols[dw]; // TODO delete + char *Temp = _symbols[dw]; // TODO delete // only create global var if it doesn't exist - if (!m_Engine->m_Globals->PropExists(m_Symbols[dw])) { - m_Operand->SetNULL(); - m_Engine->m_Globals->SetProp(m_Symbols[dw], m_Operand, false, inst == II_DEF_CONST_VAR); + if (!_engine->_globals->PropExists(_symbols[dw])) { + _operand->SetNULL(); + _engine->_globals->SetProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - if (Game->GetDebugMgr()->m_Enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, m_Engine->m_Globals->GetProp(m_Symbols[dw]), m_Symbols[dw]); + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->GetProp(_symbols[dw]), _symbols[dw]); } break; } case II_RET: - if (m_ScopeStack->m_SP >= 0 && m_CallStack->m_SP >= 0) { - Game->GetDebugMgr()->OnScriptShutdownScope(this, m_ScopeStack->GetTop()); + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->GetTop()); - m_ScopeStack->Pop(); - m_IP = (uint32)m_CallStack->Pop()->GetInt(); + _scopeStack->Pop(); + _iP = (uint32)_callStack->Pop()->GetInt(); - if (m_ScopeStack->m_SP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, m_ScopeStack->GetTop()); + if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); } else { - if (m_Thread) { - m_State = SCRIPT_THREAD_FINISHED; + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; } else { - if (m_NumEvents == 0 && m_NumMethods == 0) m_State = SCRIPT_FINISHED; - else m_State = SCRIPT_PERSISTENT; + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; } } break; case II_RET_EVENT: - m_State = SCRIPT_FINISHED; + _state = SCRIPT_FINISHED; break; case II_CALL: dw = GetDWORD(); - m_Operand->SetInt(m_IP); - m_CallStack->Push(m_Operand); + _operand->SetInt(_iP); + _callStack->Push(_operand); - m_IP = dw; + _iP = dw; break; case II_CALL_BY_EXP: { // push var // push string - str = m_Stack->Pop()->GetString(); + str = _stack->Pop()->GetString(); char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); - CScValue *var = m_Stack->Pop(); - if (var->m_Type == VAL_VARIABLE_REF) var = var->m_ValRef; + CScValue *var = _stack->Pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; HRESULT res = E_FAIL; bool TriedNative = false; // we are already calling this method, try native - if (m_Thread && m_MethodThread && strcmp(MethodName, m_ThreadEvent) == 0 && var->m_Type == VAL_NATIVE && m_Owner == var->GetNative()) { + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->GetNative()) { TriedNative = true; - res = var->m_ValNative->ScCallMethod(this, m_Stack, m_ThisStack, MethodName); + res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); } if (FAILED(res)) { if (var->IsNative() && var->GetNative()->CanHandleMethod(MethodName)) { - if (!m_Unbreakable) { - m_WaitScript = var->GetNative()->InvokeMethodThread(MethodName); - if (!m_WaitScript) { - m_Stack->CorrectParams(0); + if (!_unbreakable) { + _waitScript = var->GetNative()->InvokeMethodThread(MethodName); + if (!_waitScript) { + _stack->CorrectParams(0); RuntimeError("Error invoking method '%s'.", MethodName); - m_Stack->PushNULL(); + _stack->PushNULL(); } else { - m_State = SCRIPT_WAITING_SCRIPT; - m_WaitScript->CopyParameters(m_Stack); + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->CopyParameters(_stack); } } else { // can call methods in unbreakable mode - m_Stack->CorrectParams(0); + _stack->CorrectParams(0); RuntimeError("Cannot call method '%s'. Ignored.", MethodName); - m_Stack->PushNULL(); + _stack->PushNULL(); } delete [] MethodName; break; @@ -565,28 +565,28 @@ HRESULT CScScript::ExecuteInstruction() { if(dw==0){ TExternalFunction* f = GetExternal(val->GetString()); if(f){ - ExternalCall(m_Stack, m_ThisStack, f); + ExternalCall(_stack, _thisStack, f); } else{ // not an internal nor external, try for native function - Game->ExternalCall(this, m_Stack, m_ThisStack, val->GetString()); + Game->ExternalCall(this, _stack, _thisStack, val->GetString()); } } else{ - m_Operand->SetInt(m_IP); - m_CallStack->Push(m_Operand); - m_IP = dw; + _operand->SetInt(_iP); + _callStack->Push(_operand); + _iP = dw; } } */ else { res = E_FAIL; - if (var->m_Type == VAL_NATIVE && !TriedNative) res = var->m_ValNative->ScCallMethod(this, m_Stack, m_ThisStack, MethodName); + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); if (FAILED(res)) { - m_Stack->CorrectParams(0); + _stack->CorrectParams(0); RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); - m_Stack->PushNULL(); + _stack->PushNULL(); } } } @@ -597,69 +597,69 @@ HRESULT CScScript::ExecuteInstruction() { case II_EXTERNAL_CALL: { uint32 SymbolIndex = GetDWORD(); - TExternalFunction *f = GetExternal(m_Symbols[SymbolIndex]); + TExternalFunction *f = GetExternal(_symbols[SymbolIndex]); if (f) { - ExternalCall(m_Stack, m_ThisStack, f); - } else Game->ExternalCall(this, m_Stack, m_ThisStack, m_Symbols[SymbolIndex]); + ExternalCall(_stack, _thisStack, f); + } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); break; } case II_SCOPE: - m_Operand->SetNULL(); - m_ScopeStack->Push(m_Operand); + _operand->SetNULL(); + _scopeStack->Push(_operand); - if (m_ScopeStack->m_SP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, m_ScopeStack->GetTop()); + if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); break; case II_CORRECT_STACK: dw = GetDWORD(); // params expected - m_Stack->CorrectParams(dw); + _stack->CorrectParams(dw); break; case II_CREATE_OBJECT: - m_Operand->SetObject(); - m_Stack->Push(m_Operand); + _operand->SetObject(); + _stack->Push(_operand); break; case II_POP_EMPTY: - m_Stack->Pop(); + _stack->Pop(); break; case II_PUSH_VAR: { - CScValue *var = GetVar(m_Symbols[GetDWORD()]); - if (false && /*var->m_Type==VAL_OBJECT ||*/ var->m_Type == VAL_NATIVE) { - m_Operand->SetReference(var); - m_Stack->Push(m_Operand); - } else m_Stack->Push(var); + CScValue *var = GetVar(_symbols[GetDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->SetReference(var); + _stack->Push(_operand); + } else _stack->Push(var); break; } case II_PUSH_VAR_REF: { - CScValue *var = GetVar(m_Symbols[GetDWORD()]); - m_Operand->SetReference(var); - m_Stack->Push(m_Operand); + CScValue *var = GetVar(_symbols[GetDWORD()]); + _operand->SetReference(var); + _stack->Push(_operand); break; } case II_POP_VAR: { - char *VarName = m_Symbols[GetDWORD()]; + char *VarName = _symbols[GetDWORD()]; CScValue *var = GetVar(VarName); if (var) { - CScValue *val = m_Stack->Pop(); + CScValue *val = _stack->Pop(); if (!val) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->SetNULL(); } else { - if (val->GetType() == VAL_VARIABLE_REF) val = val->m_ValRef; - if (val->m_Type == VAL_NATIVE) var->SetValue(val); + if (val->GetType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->SetValue(val); else { var->Copy(val); } } - if (Game->GetDebugMgr()->m_Enabled) + if (Game->GetDebugMgr()->_enabled) Game->GetDebugMgr()->OnVariableChangeValue(var, val); } @@ -667,339 +667,339 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_VAR_THIS: - m_Stack->Push(m_ThisStack->GetTop()); + _stack->Push(_thisStack->GetTop()); break; case II_PUSH_INT: - m_Stack->PushInt((int)GetDWORD()); + _stack->PushInt((int)GetDWORD()); break; case II_PUSH_FLOAT: - m_Stack->PushFloat(GetFloat()); + _stack->PushFloat(GetFloat()); break; case II_PUSH_BOOL: - m_Stack->PushBool(GetDWORD() != 0); + _stack->PushBool(GetDWORD() != 0); break; case II_PUSH_STRING: - m_Stack->PushString(GetString()); + _stack->PushString(GetString()); break; case II_PUSH_NULL: - m_Stack->PushNULL(); + _stack->PushNULL(); break; case II_PUSH_THIS_FROM_STACK: - m_Operand->SetReference(m_Stack->GetTop()); - m_ThisStack->Push(m_Operand); + _operand->SetReference(_stack->GetTop()); + _thisStack->Push(_operand); break; case II_PUSH_THIS: - m_Operand->SetReference(GetVar(m_Symbols[GetDWORD()])); - m_ThisStack->Push(m_Operand); + _operand->SetReference(GetVar(_symbols[GetDWORD()])); + _thisStack->Push(_operand); break; case II_POP_THIS: - m_ThisStack->Pop(); + _thisStack->Pop(); break; case II_PUSH_BY_EXP: { - str = m_Stack->Pop()->GetString(); - CScValue *val = m_Stack->Pop()->GetProp(str); - if (val) m_Stack->Push(val); - else m_Stack->PushNULL(); + str = _stack->Pop()->GetString(); + CScValue *val = _stack->Pop()->GetProp(str); + if (val) _stack->Push(val); + else _stack->PushNULL(); break; } case II_POP_BY_EXP: { - str = m_Stack->Pop()->GetString(); - CScValue *var = m_Stack->Pop(); - CScValue *val = m_Stack->Pop(); + str = _stack->Pop()->GetString(); + CScValue *var = _stack->Pop(); + CScValue *val = _stack->Pop(); if (val == NULL) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->SetNULL(); } else var->SetProp(str, val); - if (Game->GetDebugMgr()->m_Enabled) + if (Game->GetDebugMgr()->_enabled) Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); break; } case II_PUSH_REG1: - m_Stack->Push(m_Reg1); + _stack->Push(_reg1); break; case II_POP_REG1: - m_Reg1->Copy(m_Stack->Pop()); + _reg1->Copy(_stack->Pop()); break; case II_JMP: - m_IP = GetDWORD(); + _iP = GetDWORD(); break; case II_JMP_FALSE: { dw = GetDWORD(); - //if(!m_Stack->Pop()->GetBool()) m_IP = dw; - CScValue *Val = m_Stack->Pop(); + //if(!_stack->Pop()->GetBool()) _iP = dw; + CScValue *Val = _stack->Pop(); if (!Val) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { - if (!Val->GetBool()) m_IP = dw; + if (!Val->GetBool()) _iP = dw; } break; } case II_ADD: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); - if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { str = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; strcpy(str, op1->GetString()); strcat(str, op2->GetString()); - m_Operand->SetString(str); + _operand->SetString(str); delete [] str; } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - m_Operand->SetInt(op1->GetInt() + op2->GetInt()); - else m_Operand->SetFloat(op1->GetFloat() + op2->GetFloat()); + _operand->SetInt(op1->GetInt() + op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_SUB: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); - if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - m_Operand->SetInt(op1->GetInt() - op2->GetInt()); - else m_Operand->SetFloat(op1->GetFloat() - op2->GetFloat()); + _operand->SetInt(op1->GetInt() - op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_MUL: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); - if (op1->IsNULL() || op2->IsNULL()) m_Operand->SetNULL(); + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - m_Operand->SetInt(op1->GetInt() * op2->GetInt()); - else m_Operand->SetFloat(op1->GetFloat() * op2->GetFloat()); + _operand->SetInt(op1->GetInt() * op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_DIV: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); - if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) m_Operand->SetNULL(); - else m_Operand->SetFloat(op1->GetFloat() / op2->GetFloat()); + if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); + else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_MODULO: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); if (op2->GetInt() == 0) RuntimeError("Division by zero."); - if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) m_Operand->SetNULL(); - else m_Operand->SetInt(op1->GetInt() % op2->GetInt()); + if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); + else _operand->SetInt(op1->GetInt() % op2->GetInt()); - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_NOT: - op1 = m_Stack->Pop(); - //if(op1->IsNULL()) m_Operand->SetNULL(); - if (op1->IsNULL()) m_Operand->SetBool(true); - else m_Operand->SetBool(!op1->GetBool()); - m_Stack->Push(m_Operand); + op1 = _stack->Pop(); + //if(op1->IsNULL()) _operand->SetNULL(); + if (op1->IsNULL()) _operand->SetBool(true); + else _operand->SetBool(!op1->GetBool()); + _stack->Push(_operand); break; case II_AND: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - m_Operand->SetBool(false); + _operand->SetBool(false); } else { - m_Operand->SetBool(op1->GetBool() && op2->GetBool()); + _operand->SetBool(op1->GetBool() && op2->GetBool()); } - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_OR: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - m_Operand->SetBool(false); + _operand->SetBool(false); } else { - m_Operand->SetBool(op1->GetBool() || op2->GetBool()); + _operand->SetBool(op1->GetBool() || op2->GetBool()); } - m_Stack->Push(m_Operand); + _stack->Push(_operand); break; case II_CMP_EQ: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) m_Operand->SetBool(false); + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); else if(op1->IsNative() && op2->IsNative()){ - m_Operand->SetBool(op1->GetNative() == op2->GetNative()); + _operand->SetBool(op1->GetNative() == op2->GetNative()); } else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - m_Operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); + _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); } else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() == op2->GetFloat()); + _operand->SetBool(op1->GetFloat() == op2->GetFloat()); } else{ - m_Operand->SetBool(op1->GetInt() == op2->GetInt()); + _operand->SetBool(op1->GetInt() == op2->GetInt()); } */ - m_Operand->SetBool(CScValue::Compare(op1, op2) == 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) == 0); + _stack->Push(_operand); break; case II_CMP_NE: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) m_Operand->SetBool(true); + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); else if(op1->IsNative() && op2->IsNative()){ - m_Operand->SetBool(op1->GetNative() != op2->GetNative()); + _operand->SetBool(op1->GetNative() != op2->GetNative()); } else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - m_Operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); + _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); } else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() != op2->GetFloat()); + _operand->SetBool(op1->GetFloat() != op2->GetFloat()); } else{ - m_Operand->SetBool(op1->GetInt() != op2->GetInt()); + _operand->SetBool(op1->GetInt() != op2->GetInt()); } */ - m_Operand->SetBool(CScValue::Compare(op1, op2) != 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) != 0); + _stack->Push(_operand); break; case II_CMP_L: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() < op2->GetFloat()); + _operand->SetBool(op1->GetFloat() < op2->GetFloat()); } - else m_Operand->SetBool(op1->GetInt() < op2->GetInt()); + else _operand->SetBool(op1->GetInt() < op2->GetInt()); */ - m_Operand->SetBool(CScValue::Compare(op1, op2) < 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) < 0); + _stack->Push(_operand); break; case II_CMP_G: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() > op2->GetFloat()); + _operand->SetBool(op1->GetFloat() > op2->GetFloat()); } - else m_Operand->SetBool(op1->GetInt() > op2->GetInt()); + else _operand->SetBool(op1->GetInt() > op2->GetInt()); */ - m_Operand->SetBool(CScValue::Compare(op1, op2) > 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) > 0); + _stack->Push(_operand); break; case II_CMP_LE: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() <= op2->GetFloat()); + _operand->SetBool(op1->GetFloat() <= op2->GetFloat()); } - else m_Operand->SetBool(op1->GetInt() <= op2->GetInt()); + else _operand->SetBool(op1->GetInt() <= op2->GetInt()); */ - m_Operand->SetBool(CScValue::Compare(op1, op2) <= 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) <= 0); + _stack->Push(_operand); break; case II_CMP_GE: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - m_Operand->SetBool(op1->GetFloat() >= op2->GetFloat()); + _operand->SetBool(op1->GetFloat() >= op2->GetFloat()); } - else m_Operand->SetBool(op1->GetInt() >= op2->GetInt()); + else _operand->SetBool(op1->GetInt() >= op2->GetInt()); */ - m_Operand->SetBool(CScValue::Compare(op1, op2) >= 0); - m_Stack->Push(m_Operand); + _operand->SetBool(CScValue::Compare(op1, op2) >= 0); + _stack->Push(_operand); break; case II_CMP_STRICT_EQ: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); - //m_Operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); - m_Operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); - m_Stack->Push(m_Operand); + //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); + _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); + _stack->Push(_operand); break; case II_CMP_STRICT_NE: - op2 = m_Stack->Pop(); - op1 = m_Stack->Pop(); + op2 = _stack->Pop(); + op1 = _stack->Pop(); - //m_Operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); - m_Operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); - m_Stack->Push(m_Operand); + //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); + _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); + _stack->Push(_operand); break; case II_DBG_LINE: { int NewLine = GetDWORD(); - if (NewLine != m_CurrentLine) { - m_CurrentLine = NewLine; - if (Game->GetDebugMgr()->m_Enabled) { - Game->GetDebugMgr()->OnScriptChangeLine(this, m_CurrentLine); - for (int i = 0; i < m_Breakpoints.GetSize(); i++) { - if (m_Breakpoints[i] == m_CurrentLine) { + if (NewLine != _currentLine) { + _currentLine = NewLine; + if (Game->GetDebugMgr()->_enabled) { + Game->GetDebugMgr()->OnScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (_breakpoints[i] == _currentLine) { Game->GetDebugMgr()->OnScriptHitBreakpoint(this); Sleep(0); break; } } - if (m_TracingMode) { + if (_tracingMode) { Game->GetDebugMgr()->OnScriptHitBreakpoint(this); Sleep(0); break; @@ -1010,8 +1010,8 @@ HRESULT CScScript::ExecuteInstruction() { } default: - Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, m_Filename, m_CurrentLine, m_IP - sizeof(uint32)); - m_State = SCRIPT_FINISHED; + Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; ret = E_FAIL; } // switch(instruction) @@ -1023,8 +1023,8 @@ HRESULT CScScript::ExecuteInstruction() { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::GetFuncPos(const char *Name) { - for (int i = 0; i < m_NumFunctions; i++) { - if (strcmp(Name, m_Functions[i].name) == 0) return m_Functions[i].pos; + for (int i = 0; i < _numFunctions; i++) { + if (strcmp(Name, _functions[i].name) == 0) return _functions[i].pos; } return 0; } @@ -1032,8 +1032,8 @@ uint32 CScScript::GetFuncPos(const char *Name) { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::GetMethodPos(const char *Name) { - for (int i = 0; i < m_NumMethods; i++) { - if (strcmp(Name, m_Methods[i].name) == 0) return m_Methods[i].pos; + for (int i = 0; i < _numMethods; i++) { + if (strcmp(Name, _methods[i].name) == 0) return _methods[i].pos; } return 0; } @@ -1044,31 +1044,31 @@ CScValue *CScScript::GetVar(char *Name) { CScValue *ret = NULL; // scope locals - if (m_ScopeStack->m_SP >= 0) { - if (m_ScopeStack->GetTop()->PropExists(Name)) ret = m_ScopeStack->GetTop()->GetProp(Name); + if (_scopeStack->_sP >= 0) { + if (_scopeStack->GetTop()->PropExists(Name)) ret = _scopeStack->GetTop()->GetProp(Name); } // script globals if (ret == NULL) { - if (m_Globals->PropExists(Name)) ret = m_Globals->GetProp(Name); + if (_globals->PropExists(Name)) ret = _globals->GetProp(Name); } // engine globals if (ret == NULL) { - if (m_Engine->m_Globals->PropExists(Name)) ret = m_Engine->m_Globals->GetProp(Name); + if (_engine->_globals->PropExists(Name)) ret = _engine->_globals->GetProp(Name); } if (ret == NULL) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", Name); - Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, m_Filename, m_CurrentLine); + Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, _filename, _currentLine); CScValue *Val = new CScValue(Game); - CScValue *Scope = m_ScopeStack->GetTop(); + CScValue *Scope = _scopeStack->GetTop(); if (Scope) { Scope->SetProp(Name, Val); - ret = m_ScopeStack->GetTop()->GetProp(Name); + ret = _scopeStack->GetTop()->GetProp(Name); } else { - m_Globals->SetProp(Name, Val); - ret = m_Globals->GetProp(Name); + _globals->SetProp(Name, Val); + ret = _globals->GetProp(Name); } delete Val; } @@ -1079,38 +1079,38 @@ CScValue *CScScript::GetVar(char *Name) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::WaitFor(CBObject *Object) { - if (m_Unbreakable) { + if (_unbreakable) { RuntimeError("Script cannot be interrupted."); return S_OK; } - m_State = SCRIPT_WAITING; - m_WaitObject = Object; + _state = SCRIPT_WAITING; + _waitObject = Object; return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::WaitForExclusive(CBObject *Object) { - m_Engine->ResetObject(Object); + _engine->ResetObject(Object); return WaitFor(Object); } ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Sleep(uint32 Duration) { - if (m_Unbreakable) { + if (_unbreakable) { RuntimeError("Script cannot be interrupted."); return S_OK; } - m_State = SCRIPT_SLEEPING; - if (Game->m_State == GAME_FROZEN) { - m_WaitTime = CBPlatform::GetTime() + Duration; - m_WaitFrozen = true; + _state = SCRIPT_SLEEPING; + if (Game->_state == GAME_FROZEN) { + _waitTime = CBPlatform::GetTime() + Duration; + _waitFrozen = true; } else { - m_WaitTime = Game->m_Timer + Duration; - m_WaitFrozen = false; + _waitTime = Game->_timer + Duration; + _waitFrozen = false; } return S_OK; } @@ -1118,10 +1118,10 @@ HRESULT CScScript::Sleep(uint32 Duration) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Finish(bool IncludingThreads) { - if (m_State != SCRIPT_FINISHED && IncludingThreads) { - m_State = SCRIPT_FINISHED; + if (_state != SCRIPT_FINISHED && IncludingThreads) { + _state = SCRIPT_FINISHED; FinishThreads(); - } else m_State = SCRIPT_FINISHED; + } else _state = SCRIPT_FINISHED; return S_OK; @@ -1130,7 +1130,7 @@ HRESULT CScScript::Finish(bool IncludingThreads) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Run() { - m_State = SCRIPT_RUNNING; + _state = SCRIPT_RUNNING; return S_OK; } @@ -1144,10 +1144,10 @@ void CScScript::RuntimeError(LPCSTR fmt, ...) { vsprintf(buff, fmt, va); va_end(va); - Game->LOG(0, "Runtime error. Script '%s', line %d", m_Filename, m_CurrentLine); + Game->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); Game->LOG(0, " %s", buff); - if (!Game->m_SuppressScriptErrors) + if (!Game->_suppressScriptErrors) Game->QuickMessage("Script runtime error. View log for details."); } @@ -1158,53 +1158,53 @@ HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); // buffer - if (PersistMgr->m_Saving) { - if (m_State != SCRIPT_PERSISTENT && m_State != SCRIPT_FINISHED && m_State != SCRIPT_THREAD_FINISHED) { - PersistMgr->Transfer(TMEMBER(m_BufferSize)); - PersistMgr->PutBytes(m_Buffer, m_BufferSize); + if (PersistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + PersistMgr->Transfer(TMEMBER(_bufferSize)); + PersistMgr->PutBytes(_buffer, _bufferSize); } else { // don't save idle/finished scripts int bufferSize = 0; PersistMgr->Transfer(TMEMBER(bufferSize)); } } else { - PersistMgr->Transfer(TMEMBER(m_BufferSize)); - if (m_BufferSize > 0) { - m_Buffer = new byte[m_BufferSize]; - PersistMgr->GetBytes(m_Buffer, m_BufferSize); + PersistMgr->Transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + PersistMgr->GetBytes(_buffer, _bufferSize); InitTables(); - } else m_Buffer = NULL; + } else _buffer = NULL; } - PersistMgr->Transfer(TMEMBER(m_CallStack)); - PersistMgr->Transfer(TMEMBER(m_CurrentLine)); - PersistMgr->Transfer(TMEMBER(m_Engine)); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_Freezable)); - PersistMgr->Transfer(TMEMBER(m_Globals)); - PersistMgr->Transfer(TMEMBER(m_IP)); - PersistMgr->Transfer(TMEMBER(m_ScopeStack)); - PersistMgr->Transfer(TMEMBER(m_Stack)); - PersistMgr->Transfer(TMEMBER_INT(m_State)); - PersistMgr->Transfer(TMEMBER(m_Operand)); - PersistMgr->Transfer(TMEMBER_INT(m_OrigState)); - PersistMgr->Transfer(TMEMBER(m_Owner)); - PersistMgr->Transfer(TMEMBER(m_Reg1)); - PersistMgr->Transfer(TMEMBER(m_Thread)); - PersistMgr->Transfer(TMEMBER(m_ThreadEvent)); - PersistMgr->Transfer(TMEMBER(m_ThisStack)); - PersistMgr->Transfer(TMEMBER(m_TimeSlice)); - PersistMgr->Transfer(TMEMBER(m_WaitObject)); - PersistMgr->Transfer(TMEMBER(m_WaitScript)); - PersistMgr->Transfer(TMEMBER(m_WaitTime)); - PersistMgr->Transfer(TMEMBER(m_WaitFrozen)); - - PersistMgr->Transfer(TMEMBER(m_MethodThread)); - PersistMgr->Transfer(TMEMBER(m_MethodThread)); - PersistMgr->Transfer(TMEMBER(m_Unbreakable)); - PersistMgr->Transfer(TMEMBER(m_ParentScript)); - - if (!PersistMgr->m_Saving) m_TracingMode = false; + PersistMgr->Transfer(TMEMBER(_callStack)); + PersistMgr->Transfer(TMEMBER(_currentLine)); + PersistMgr->Transfer(TMEMBER(_engine)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_freezable)); + PersistMgr->Transfer(TMEMBER(_globals)); + PersistMgr->Transfer(TMEMBER(_iP)); + PersistMgr->Transfer(TMEMBER(_scopeStack)); + PersistMgr->Transfer(TMEMBER(_stack)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_operand)); + PersistMgr->Transfer(TMEMBER_INT(_origState)); + PersistMgr->Transfer(TMEMBER(_owner)); + PersistMgr->Transfer(TMEMBER(_reg1)); + PersistMgr->Transfer(TMEMBER(_thread)); + PersistMgr->Transfer(TMEMBER(_threadEvent)); + PersistMgr->Transfer(TMEMBER(_thisStack)); + PersistMgr->Transfer(TMEMBER(_timeSlice)); + PersistMgr->Transfer(TMEMBER(_waitObject)); + PersistMgr->Transfer(TMEMBER(_waitScript)); + PersistMgr->Transfer(TMEMBER(_waitTime)); + PersistMgr->Transfer(TMEMBER(_waitFrozen)); + + PersistMgr->Transfer(TMEMBER(_methodThread)); + PersistMgr->Transfer(TMEMBER(_methodThread)); + PersistMgr->Transfer(TMEMBER(_unbreakable)); + PersistMgr->Transfer(TMEMBER(_parentScript)); + + if (!PersistMgr->_saving) _tracingMode = false; return S_OK; } @@ -1212,17 +1212,17 @@ HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable) { - //if(m_State!=SCRIPT_PERSISTENT) return NULL; + //if(_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = GetEventPos(EventName); if (!pos) return NULL; - CScScript *thread = new CScScript(Game, m_Engine); + CScScript *thread = new CScScript(Game, _engine); if (thread) { HRESULT ret = thread->CreateThread(this, pos, EventName); if (SUCCEEDED(ret)) { - thread->m_Unbreakable = Unbreakable; - m_Engine->m_Scripts.Add(thread); + thread->_unbreakable = Unbreakable; + _engine->_scripts.Add(thread); Game->GetDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); return thread; } else { @@ -1236,8 +1236,8 @@ CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable ////////////////////////////////////////////////////////////////////////// uint32 CScScript::GetEventPos(const char *Name) { - for (int i = m_NumEvents - 1; i >= 0; i--) { - if (scumm_stricmp(Name, m_Events[i].name) == 0) return m_Events[i].pos; + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(Name, _events[i].name) == 0) return _events[i].pos; } return 0; } @@ -1257,15 +1257,15 @@ bool CScScript::CanHandleMethod(char *MethodName) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Pause() { - if (m_State == SCRIPT_PAUSED) { - Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", m_Filename, m_CurrentLine); + if (_state == SCRIPT_PAUSED) { + Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return E_FAIL; } - if (!m_Freezable || m_State == SCRIPT_PERSISTENT) return S_OK; + if (!_freezable || _state == SCRIPT_PERSISTENT) return S_OK; - m_OrigState = m_State; - m_State = SCRIPT_PAUSED; + _origState = _state; + _state = SCRIPT_PAUSED; return S_OK; } @@ -1273,17 +1273,17 @@ HRESULT CScScript::Pause() { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Resume() { - if (m_State != SCRIPT_PAUSED) return S_OK; + if (_state != SCRIPT_PAUSED) return S_OK; - m_State = m_OrigState; + _state = _origState; return S_OK; } ////////////////////////////////////////////////////////////////////////// CScScript::TExternalFunction *CScScript::GetExternal(char *Name) { - for (int i = 0; i < m_NumExternals; i++) { - if (strcmp(Name, m_Externals[i].name) == 0) return &m_Externals[i]; + for (int i = 0; i < _numExternals; i++) { + if (strcmp(Name, _externals[i].name) == 0) return &_externals[i]; } return NULL; } @@ -1309,10 +1309,10 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: if (pFunc) { int i; Success = true; - Stack->CorrectParams(Function->num_params); + Stack->CorrectParams(Function->nu_params); CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); - for (i = 0; i < Function->num_params; i++) { + for (i = 0; i < Function->nu_params; i++) { CScValue *Val = Stack->Pop(); switch (Function->params[i]) { case TYPE_BOOL: @@ -1353,10 +1353,10 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: bool StackCorrupted = false; switch (Function->call_type) { case CALL_CDECL: - ret = Call_cdecl(Buffer->m_Buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + ret = Call_cdecl(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); break; default: - ret = Call_stdcall(Buffer->m_Buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + ret = Call_stdcall(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); } delete Buffer; @@ -1493,9 +1493,9 @@ HRESULT CScScript::CopyParameters(CScStack *Stack) { int i; int NumParams = Stack->Pop()->GetInt(); for (i = NumParams - 1; i >= 0; i--) { - m_Stack->Push(Stack->GetAt(i)); + _stack->Push(Stack->GetAt(i)); } - m_Stack->PushInt(NumParams); + _stack->PushInt(NumParams); for (i = 0; i < NumParams; i++) Stack->Pop(); @@ -1505,9 +1505,9 @@ HRESULT CScScript::CopyParameters(CScStack *Stack) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::FinishThreads() { - for (int i = 0; i < m_Engine->m_Scripts.GetSize(); i++) { - CScScript *Scr = m_Engine->m_Scripts[i]; - if (Scr->m_Thread && Scr->m_State != SCRIPT_FINISHED && Scr->m_Owner == m_Owner && scumm_stricmp(Scr->m_Filename, m_Filename) == 0) + for (int i = 0; i < _engine->_scripts.GetSize(); i++) { + CScScript *Scr = _engine->_scripts[i]; + if (Scr->_thread && Scr->_state != SCRIPT_FINISHED && Scr->_owner == _owner && scumm_stricmp(Scr->_filename, _filename) == 0) Scr->Finish(true); } return S_OK; @@ -1517,19 +1517,19 @@ HRESULT CScScript::FinishThreads() { ////////////////////////////////////////////////////////////////////////// // IWmeDebugScript interface implementation int CScScript::DbgGetLine() { - return m_CurrentLine; + return _currentLine; } ////////////////////////////////////////////////////////////////////////// const char *CScScript::DbgGetFilename() { - return m_Filename; + return _filename; } ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { - if (m_MethodThread) Client->OnScriptMethodThreadInit(this, m_ParentScript, m_ThreadEvent); - else if (m_Thread) Client->OnScriptEventThreadInit(this, m_ParentScript, m_ThreadEvent); + if (_methodThread) Client->OnScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) Client->OnScriptEventThreadInit(this, _parentScript, _threadEvent); else Client->OnScriptInit(this); return DbgSendVariables(Client); @@ -1539,12 +1539,12 @@ HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { // send script globals - m_Globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); + _globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); // send scope variables - if (m_ScopeStack->m_SP >= 0) { - for (int i = 0; i <= m_ScopeStack->m_SP; i++) { - CScValue *Scope = m_ScopeStack->GetAt(i); + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + CScValue *Scope = _scopeStack->GetAt(i); //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } @@ -1554,44 +1554,44 @@ HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { ////////////////////////////////////////////////////////////////////////// TScriptState CScScript::DbgGetState() { - return m_State; + return _state; } ////////////////////////////////////////////////////////////////////////// int CScScript::DbgGetNumBreakpoints() { - return m_Breakpoints.GetSize(); + return _breakpoints.GetSize(); } ////////////////////////////////////////////////////////////////////////// int CScScript::DbgGetBreakpoint(int Index) { - if (Index >= 0 && Index < m_Breakpoints.GetSize()) return m_Breakpoints[Index]; + if (Index >= 0 && Index < _breakpoints.GetSize()) return _breakpoints[Index]; else return -1; } ////////////////////////////////////////////////////////////////////////// bool CScScript::DbgSetTracingMode(bool IsTracing) { - m_TracingMode = IsTracing; + _tracingMode = IsTracing; return true; } ////////////////////////////////////////////////////////////////////////// bool CScScript::DbgGetTracingMode() { - return m_TracingMode; + return _tracingMode; } ////////////////////////////////////////////////////////////////////////// void CScScript::AfterLoad() { - if (m_Buffer == NULL) { - byte *buffer = m_Engine->GetCompiledScript(m_Filename, &m_BufferSize); + if (_buffer == NULL) { + byte *buffer = _engine->GetCompiledScript(_filename, &_bufferSize); if (!buffer) { - Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", m_Filename); - m_State = SCRIPT_ERROR; + Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; return; } - m_Buffer = new byte [m_BufferSize]; - memcpy(m_Buffer, buffer, m_BufferSize); + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); InitTables(); } diff --git a/engines/wintermute/scriptables/ScScript.h b/engines/wintermute/scriptables/ScScript.h index 6f467437da..57baf8d92a 100644 --- a/engines/wintermute/scriptables/ScScript.h +++ b/engines/wintermute/scriptables/ScScript.h @@ -46,11 +46,11 @@ public: HRESULT DbgSendScript(IWmeDebugClient *Client); HRESULT DbgSendVariables(IWmeDebugClient *Client); - CBArray m_Breakpoints; - bool m_TracingMode; + CBArray _breakpoints; + bool _tracingMode; - CScScript *m_ParentScript; - bool m_Unbreakable; + CScScript *_parentScript; + bool _unbreakable; HRESULT FinishThreads(); HRESULT CopyParameters(CScStack *Stack); @@ -63,9 +63,9 @@ public: static double GetST0Double(void); #endif - CScValue *m_Operand; - CScValue *m_Reg1; - bool m_Freezable; + CScValue *_operand; + CScValue *_reg1; + bool _freezable; HRESULT Resume(); HRESULT Pause(); bool CanHandleEvent(char *EventName); @@ -73,7 +73,7 @@ public: HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); - uint32 m_TimeSlice; + uint32 _timeSlice; DECLARE_PERSISTENT(CScScript, CBBase) void RuntimeError(LPCSTR fmt, ...); HRESULT Run(); @@ -81,12 +81,12 @@ public: HRESULT Sleep(uint32 Duration); HRESULT WaitForExclusive(CBObject *Object); HRESULT WaitFor(CBObject *Object); - uint32 m_WaitTime; - bool m_WaitFrozen; - CBObject *m_WaitObject; - CScScript *m_WaitScript; - TScriptState m_State; - TScriptState m_OrigState; + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; CScValue *GetVar(char *Name); uint32 GetFuncPos(const char *Name); uint32 GetEventPos(const char *Name); @@ -123,44 +123,44 @@ public: char *dll_name; TCallType call_type; TExternalType returns; - int num_params; + int nu_params; TExternalType *params; } TExternalFunction; - CScStack *m_CallStack; - CScStack *m_ThisStack; - CScStack *m_ScopeStack; - CScStack *m_Stack; - CScValue *m_Globals; - CScEngine *m_Engine; - int m_CurrentLine; + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; HRESULT ExecuteInstruction(); char *GetString(); uint32 GetDWORD(); double GetFloat(); void Cleanup(); HRESULT Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); - uint32 m_IP; - uint32 m_BufferSize; - byte *m_Buffer; + uint32 _iP; + uint32 _bufferSize; + byte *_buffer; CScScript(CBGame *inGame, CScEngine *Engine); virtual ~CScScript(); - char *m_Filename; - char **m_Symbols; - int m_NumSymbols; - TFunctionPos *m_Functions; - TMethodPos *m_Methods; - TEventPos *m_Events; - int m_NumExternals; - TExternalFunction *m_Externals; - int m_NumFunctions; - int m_NumMethods; - int m_NumEvents; - bool m_Thread; - bool m_MethodThread; - char *m_ThreadEvent; - CBScriptHolder *m_Owner; + char *_filename; + char **_symbols; + int _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + int _numExternals; + TExternalFunction *_externals; + int _numFunctions; + int _numMethods; + int _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; CScScript::TExternalFunction *GetExternal(char *Name); HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); private: diff --git a/engines/wintermute/scriptables/ScStack.cpp b/engines/wintermute/scriptables/ScStack.cpp index 7975223516..c7b724e9b2 100644 --- a/engines/wintermute/scriptables/ScStack.cpp +++ b/engines/wintermute/scriptables/ScStack.cpp @@ -36,7 +36,7 @@ IMPLEMENT_PERSISTENT(CScStack, false) ////////////////////////////////////////////////////////////////////////// CScStack::CScStack(CBGame *inGame): CBBase(inGame) { - m_SP = -1; + _sP = -1; } @@ -44,95 +44,95 @@ CScStack::CScStack(CBGame *inGame): CBBase(inGame) { CScStack::~CScStack() { #if _DEBUG - //Game->LOG(0, "STAT: Stack size: %d, SP=%d", m_Values.GetSize(), m_SP); + //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.GetSize(), _sP); #endif - for (int i = 0; i < m_Values.GetSize(); i++) { - delete m_Values[i]; + for (int i = 0; i < _values.GetSize(); i++) { + delete _values[i]; } - m_Values.RemoveAll(); + _values.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::Pop() { - if (m_SP < 0) { + if (_sP < 0) { Game->LOG(0, "Fatal: Stack underflow"); return NULL; } - return m_Values[m_SP--]; + return _values[_sP--]; } ////////////////////////////////////////////////////////////////////////// void CScStack::Push(CScValue *Val) { - m_SP++; + _sP++; - if (m_SP < m_Values.GetSize()) { - m_Values[m_SP]->Cleanup(); - m_Values[m_SP]->Copy(Val); + if (_sP < _values.GetSize()) { + _values[_sP]->Cleanup(); + _values[_sP]->Copy(Val); } else { CScValue *val = new CScValue(Game); val->Copy(Val); - m_Values.Add(val); + _values.Add(val); } } ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::GetPushValue() { - m_SP++; + _sP++; - if (m_SP >= m_Values.GetSize()) { + if (_sP >= _values.GetSize()) { CScValue *val = new CScValue(Game); - m_Values.Add(val); + _values.Add(val); } - m_Values[m_SP]->Cleanup(); - return m_Values[m_SP]; + _values[_sP]->Cleanup(); + return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::GetTop() { - if (m_SP < 0 || m_SP >= m_Values.GetSize()) return NULL; - else return m_Values[m_SP]; + if (_sP < 0 || _sP >= _values.GetSize()) return NULL; + else return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::GetAt(int Index) { - Index = m_SP - Index; - if (Index < 0 || Index >= m_Values.GetSize()) return NULL; - else return m_Values[Index]; + Index = _sP - Index; + if (Index < 0 || Index >= _values.GetSize()) return NULL; + else return _values[Index]; } ////////////////////////////////////////////////////////////////////////// void CScStack::CorrectParams(uint32 expected_params) { - int num_params = Pop()->GetInt(); + int nu_params = Pop()->GetInt(); - if (expected_params < num_params) { // too many params - while (expected_params < num_params) { + if (expected_params < nu_params) { // too many params + while (expected_params < nu_params) { //Pop(); - delete m_Values[m_SP - expected_params]; - m_Values.RemoveAt(m_SP - expected_params); - num_params--; - m_SP--; + delete _values[_sP - expected_params]; + _values.RemoveAt(_sP - expected_params); + nu_params--; + _sP--; } - } else if (expected_params > num_params) { // need more params - while (expected_params > num_params) { + } else if (expected_params > nu_params) { // need more params + while (expected_params > nu_params) { //Push(null_val); CScValue *null_val = new CScValue(Game); null_val->SetNULL(); - m_Values.InsertAt(m_SP - num_params + 1, null_val); - num_params++; - m_SP++; + _values.InsertAt(_sP - nu_params + 1, null_val); + nu_params++; + _sP++; - if (m_Values.GetSize() > m_SP + 1) { - delete m_Values[m_Values.GetSize() - 1]; - m_Values.RemoveAt(m_Values.GetSize() - 1); + if (_values.GetSize() > _sP + 1) { + delete _values[_values.GetSize() - 1]; + _values.RemoveAt(_values.GetSize() - 1); } } } @@ -217,8 +217,8 @@ HRESULT CScStack::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_SP)); - m_Values.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_sP)); + _values.Persist(PersistMgr); return S_OK; } diff --git a/engines/wintermute/scriptables/ScStack.h b/engines/wintermute/scriptables/ScStack.h index 70d54cbbe4..113fb4c19f 100644 --- a/engines/wintermute/scriptables/ScStack.h +++ b/engines/wintermute/scriptables/ScStack.h @@ -56,8 +56,8 @@ public: CScValue *Pop(); CScStack(CBGame *inGame); virtual ~CScStack(); - CBArray m_Values; - int m_SP; + CBArray _values; + int _sP; }; diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index b843e2032c..055f9830ad 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -44,77 +44,77 @@ IMPLEMENT_PERSISTENT(CScValue, false) ////////////////////////////////////////////////////////////////////////// CScValue::CScValue(CBGame *inGame): CBBase(inGame) { - m_Type = VAL_NULL; - - m_ValBool = false; - m_ValInt = 0; - m_ValFloat = 0.0f; - m_ValNative = NULL; - m_ValString = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } ////////////////////////////////////////////////////////////////////////// CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { - m_Type = VAL_BOOL; - m_ValBool = Val; - - m_ValInt = 0; - m_ValFloat = 0.0f; - m_ValNative = NULL; - m_ValString = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _type = VAL_BOOL; + _valBool = Val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } ////////////////////////////////////////////////////////////////////////// CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { - m_Type = VAL_INT; - m_ValInt = Val; - - m_ValFloat = 0.0f; - m_ValBool = false; - m_ValNative = NULL; - m_ValString = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _type = VAL_INT; + _valInt = Val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } ////////////////////////////////////////////////////////////////////////// CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { - m_Type = VAL_FLOAT; - m_ValFloat = Val; - - m_ValInt = 0; - m_ValBool = false; - m_ValNative = NULL; - m_ValString = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _type = VAL_FLOAT; + _valFloat = Val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } ////////////////////////////////////////////////////////////////////////// CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { - m_Type = VAL_STRING; - m_ValString = NULL; + _type = VAL_STRING; + _valString = NULL; SetStringVal(Val); - m_ValBool = false; - m_ValInt = 0; - m_ValFloat = 0.0f; - m_ValNative = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } @@ -122,29 +122,29 @@ CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { void CScValue::Cleanup(bool IgnoreNatives) { DeleteProps(); - if (m_ValString) delete [] m_ValString; + if (_valString) delete [] _valString; if (!IgnoreNatives) { - if (m_ValNative && !m_Persistent) { - m_ValNative->m_RefCount--; - if (m_ValNative->m_RefCount <= 0) { - delete m_ValNative; - m_ValNative = NULL; + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; } } } - m_Type = VAL_NULL; + _type = VAL_NULL; - m_ValBool = false; - m_ValInt = 0; - m_ValFloat = 0.0f; - m_ValNative = NULL; - m_ValString = NULL; - m_ValRef = NULL; - m_Persistent = false; - m_IsConstVar = false; + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; } @@ -157,44 +157,44 @@ CScValue::~CScValue() { ////////////////////////////////////////////////////////////////////////// CScValue *CScValue::GetProp(char *Name) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetProp(Name); + if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(Name); - if (m_Type == VAL_STRING && strcmp(Name, "Length") == 0) { - Game->m_ScValue->m_Type = VAL_INT; + if (_type == VAL_STRING && strcmp(Name, "Length") == 0) { + Game->_scValue->_type = VAL_INT; #if 0 // TODO: Remove FreeType-dependency - if (Game->m_TextEncoding == TEXT_ANSI) { + if (Game->_textEncoding == TEXT_ANSI) { #else if (true) { #endif - Game->m_ScValue->SetInt(strlen(m_ValString)); + Game->_scValue->SetInt(strlen(_valString)); } else { - WideString wstr = StringUtil::Utf8ToWide(m_ValString); - Game->m_ScValue->SetInt(wstr.size()); + WideString wstr = StringUtil::Utf8ToWide(_valString); + Game->_scValue->SetInt(wstr.size()); } - return Game->m_ScValue; + return Game->_scValue; } CScValue *ret = NULL; - if (m_Type == VAL_NATIVE && m_ValNative) ret = m_ValNative->ScGetProperty(Name); + if (_type == VAL_NATIVE && _valNative) ret = _valNative->ScGetProperty(Name); if (ret == NULL) { - m_ValIter = m_ValObject.find(Name); - if (m_ValIter != m_ValObject.end()) ret = m_ValIter->_value; + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) ret = _valIter->_value; } return ret; } ////////////////////////////////////////////////////////////////////////// HRESULT CScValue::DeleteProp(char *Name) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->DeleteProp(Name); + if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(Name); - m_ValIter = m_ValObject.find(Name); - if (m_ValIter != m_ValObject.end()) { - delete m_ValIter->_value; - m_ValIter->_value = NULL; + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; } return S_OK; @@ -204,41 +204,41 @@ HRESULT CScValue::DeleteProp(char *Name) { ////////////////////////////////////////////////////////////////////////// HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->SetProp(Name, Val); + if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(Name, Val); HRESULT ret = E_FAIL; - if (m_Type == VAL_NATIVE && m_ValNative) { - ret = m_ValNative->ScSetProperty(Name, Val); + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->ScSetProperty(Name, Val); } if (FAILED(ret)) { CScValue *val = NULL; - m_ValIter = m_ValObject.find(Name); - if (m_ValIter != m_ValObject.end()) { - val = m_ValIter->_value; + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) { + val = _valIter->_value; } if (!val) val = new CScValue(Game); else val->Cleanup(); val->Copy(Val, CopyWhole); - val->m_IsConstVar = SetAsConst; - m_ValObject[Name] = val; + val->_isConstVar = SetAsConst; + _valObject[Name] = val; - if (m_Type != VAL_NATIVE) m_Type = VAL_OBJECT; + if (_type != VAL_NATIVE) _type = VAL_OBJECT; /* - m_ValIter = m_ValObject.find(Name); - if (m_ValIter != m_ValObject.end()){ - delete m_ValIter->_value; - m_ValIter->_value = NULL; + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; } CScValue* val = new CScValue(Game); val->Copy(Val, CopyWhole); - val->m_IsConstVar = SetAsConst; - m_ValObject[Name] = val; + val->_isConstVar = SetAsConst; + _valObject[Name] = val; - if(m_Type!=VAL_NATIVE) m_Type = VAL_OBJECT; + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; */ } @@ -248,265 +248,265 @@ HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsC ////////////////////////////////////////////////////////////////////////// bool CScValue::PropExists(char *Name) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->PropExists(Name); - m_ValIter = m_ValObject.find(Name); + if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(Name); + _valIter = _valObject.find(Name); - return (m_ValIter != m_ValObject.end()); + return (_valIter != _valObject.end()); } ////////////////////////////////////////////////////////////////////////// void CScValue::DeleteProps() { - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { - delete(CScValue *)m_ValIter->_value; - m_ValIter++; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; } - m_ValObject.clear(); + _valObject.clear(); } ////////////////////////////////////////////////////////////////////////// void CScValue::CleanProps(bool IncludingNatives) { - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { - if (!m_ValIter->_value->m_IsConstVar && (!m_ValIter->_value->IsNative() || IncludingNatives)) m_ValIter->_value->SetNULL(); - m_ValIter++; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->IsNative() || IncludingNatives)) _valIter->_value->SetNULL(); + _valIter++; } } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsNULL() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsNULL(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsNULL(); - return (m_Type == VAL_NULL); + return (_type == VAL_NULL); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsNative() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsNative(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsNative(); - return (m_Type == VAL_NATIVE); + return (_type == VAL_NATIVE); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsString() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsString(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsString(); - return (m_Type == VAL_STRING); + return (_type == VAL_STRING); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsFloat() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsFloat(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsFloat(); - return (m_Type == VAL_FLOAT); + return (_type == VAL_FLOAT); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsInt() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsInt(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsInt(); - return (m_Type == VAL_INT); + return (_type == VAL_INT); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsBool() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsBool(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsBool(); - return (m_Type == VAL_BOOL); + return (_type == VAL_BOOL); } ////////////////////////////////////////////////////////////////////////// bool CScValue::IsObject() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->IsObject(); + if (_type == VAL_VARIABLE_REF) return _valRef->IsObject(); - return (m_Type == VAL_OBJECT); + return (_type == VAL_OBJECT); } ////////////////////////////////////////////////////////////////////////// TValType CScValue::GetTypeTolerant() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetType(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetType(); - return m_Type; + return _type; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetBool(bool Val) { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetBool(Val); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetBool(Val); return; } - if (m_Type == VAL_NATIVE) { - m_ValNative->ScSetBool(Val); + if (_type == VAL_NATIVE) { + _valNative->ScSetBool(Val); return; } - m_ValBool = Val; - m_Type = VAL_BOOL; + _valBool = Val; + _type = VAL_BOOL; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetInt(int Val) { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetInt(Val); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetInt(Val); return; } - if (m_Type == VAL_NATIVE) { - m_ValNative->ScSetInt(Val); + if (_type == VAL_NATIVE) { + _valNative->ScSetInt(Val); return; } - m_ValInt = Val; - m_Type = VAL_INT; + _valInt = Val; + _type = VAL_INT; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetFloat(double Val) { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetFloat(Val); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetFloat(Val); return; } - if (m_Type == VAL_NATIVE) { - m_ValNative->ScSetFloat(Val); + if (_type == VAL_NATIVE) { + _valNative->ScSetFloat(Val); return; } - m_ValFloat = Val; - m_Type = VAL_FLOAT; + _valFloat = Val; + _type = VAL_FLOAT; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetString(const char *Val) { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetString(Val); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetString(Val); return; } - if (m_Type == VAL_NATIVE) { - m_ValNative->ScSetString(Val); + if (_type == VAL_NATIVE) { + _valNative->ScSetString(Val); return; } SetStringVal(Val); - if (m_ValString) m_Type = VAL_STRING; - else m_Type = VAL_NULL; + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetStringVal(const char *Val) { - if (m_ValString) delete [] m_ValString; + if (_valString) delete [] _valString; if (Val == NULL) { - m_ValString = NULL; + _valString = NULL; return; } - m_ValString = new char [strlen(Val) + 1]; - if (m_ValString) { - strcpy(m_ValString, Val); + _valString = new char [strlen(Val) + 1]; + if (_valString) { + strcpy(_valString, Val); } } ////////////////////////////////////////////////////////////////////////// void CScValue::SetNULL() { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetNULL(); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetNULL(); return; } - if (m_ValNative && !m_Persistent) { - m_ValNative->m_RefCount--; - if (m_ValNative->m_RefCount <= 0) delete m_ValNative; + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; } - m_ValNative = NULL; + _valNative = NULL; DeleteProps(); - m_Type = VAL_NULL; + _type = VAL_NULL; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetNative(CBScriptable *Val, bool Persistent) { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetNative(Val, Persistent); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetNative(Val, Persistent); return; } if (Val == NULL) { SetNULL(); } else { - if (m_ValNative && !m_Persistent) { - m_ValNative->m_RefCount--; - if (m_ValNative->m_RefCount <= 0) { - if (m_ValNative != Val) delete m_ValNative; - m_ValNative = NULL; + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != Val) delete _valNative; + _valNative = NULL; } } - m_Type = VAL_NATIVE; - m_Persistent = Persistent; + _type = VAL_NATIVE; + _persistent = Persistent; - m_ValNative = Val; - if (m_ValNative && !m_Persistent) m_ValNative->m_RefCount++; + _valNative = Val; + if (_valNative && !_persistent) _valNative->_refCount++; } } ////////////////////////////////////////////////////////////////////////// void CScValue::SetObject() { - if (m_Type == VAL_VARIABLE_REF) { - m_ValRef->SetObject(); + if (_type == VAL_VARIABLE_REF) { + _valRef->SetObject(); return; } DeleteProps(); - m_Type = VAL_OBJECT; + _type = VAL_OBJECT; } ////////////////////////////////////////////////////////////////////////// void CScValue::SetReference(CScValue *Val) { - m_ValRef = Val; - m_Type = VAL_VARIABLE_REF; + _valRef = Val; + _type = VAL_VARIABLE_REF; } ////////////////////////////////////////////////////////////////////////// bool CScValue::GetBool(bool Default) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetBool(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetBool(); - switch (m_Type) { + switch (_type) { case VAL_BOOL: - return m_ValBool; + return _valBool; case VAL_NATIVE: - return m_ValNative->ScToBool(); + return _valNative->ScToBool(); case VAL_INT: - return (m_ValInt != 0); + return (_valInt != 0); case VAL_FLOAT: - return (m_ValFloat != 0.0f); + return (_valFloat != 0.0f); case VAL_STRING: - return (scumm_stricmp(m_ValString, "1") == 0 || scumm_stricmp(m_ValString, "yes") == 0 || scumm_stricmp(m_ValString, "true") == 0); + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); default: return Default; @@ -516,23 +516,23 @@ bool CScValue::GetBool(bool Default) { ////////////////////////////////////////////////////////////////////////// int CScValue::GetInt(int Default) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetInt(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetInt(); - switch (m_Type) { + switch (_type) { case VAL_BOOL: - return m_ValBool ? 1 : 0; + return _valBool ? 1 : 0; case VAL_NATIVE: - return m_ValNative->ScToInt(); + return _valNative->ScToInt(); case VAL_INT: - return m_ValInt; + return _valInt; case VAL_FLOAT: - return (int)m_ValFloat; + return (int)_valFloat; case VAL_STRING: - return atoi(m_ValString); + return atoi(_valString); default: return Default; @@ -542,23 +542,23 @@ int CScValue::GetInt(int Default) { ////////////////////////////////////////////////////////////////////////// double CScValue::GetFloat(double Default) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetFloat(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetFloat(); - switch (m_Type) { + switch (_type) { case VAL_BOOL: - return m_ValBool ? 1.0f : 0.0f; + return _valBool ? 1.0f : 0.0f; case VAL_NATIVE: - return m_ValNative->ScToFloat(); + return _valNative->ScToFloat(); case VAL_INT: - return (double)m_ValInt; + return (double)_valInt; case VAL_FLOAT: - return m_ValFloat; + return _valFloat; case VAL_STRING: - return atof(m_ValString); + return atof(_valString); default: return Default; @@ -567,18 +567,18 @@ double CScValue::GetFloat(double Default) { ////////////////////////////////////////////////////////////////////////// void *CScValue::GetMemBuffer() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetMemBuffer(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetMemBuffer(); - if (m_Type == VAL_NATIVE) return m_ValNative->ScToMemBuffer(); + if (_type == VAL_NATIVE) return _valNative->ScToMemBuffer(); else return (void *)NULL; } ////////////////////////////////////////////////////////////////////////// char *CScValue::GetString() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetString(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetString(); - switch (m_Type) { + switch (_type) { case VAL_OBJECT: SetStringVal("[object]"); break; @@ -588,26 +588,26 @@ char *CScValue::GetString() { break; case VAL_NATIVE: { - char *StrVal = m_ValNative->ScToString(); + char *StrVal = _valNative->ScToString(); SetStringVal(StrVal); return StrVal; break; } case VAL_BOOL: - SetStringVal(m_ValBool ? "yes" : "no"); + SetStringVal(_valBool ? "yes" : "no"); break; case VAL_INT: { char dummy[50]; - sprintf(dummy, "%d", m_ValInt); + sprintf(dummy, "%d", _valInt); SetStringVal(dummy); break; } case VAL_FLOAT: { char dummy[50]; - sprintf(dummy, "%f", m_ValFloat); + sprintf(dummy, "%f", _valFloat); SetStringVal(dummy); break; } @@ -619,22 +619,22 @@ char *CScValue::GetString() { SetStringVal(""); } - return m_ValString; + return _valString; } ////////////////////////////////////////////////////////////////////////// CBScriptable *CScValue::GetNative() { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->GetNative(); + if (_type == VAL_VARIABLE_REF) return _valRef->GetNative(); - if (m_Type == VAL_NATIVE) return m_ValNative; + if (_type == VAL_NATIVE) return _valNative; else return NULL; } ////////////////////////////////////////////////////////////////////////// TValType CScValue::GetType() { - return m_Type; + return _type; } @@ -642,64 +642,64 @@ TValType CScValue::GetType() { void CScValue::Copy(CScValue *orig, bool CopyWhole) { Game = orig->Game; - if (m_ValNative && !m_Persistent) { - m_ValNative->m_RefCount--; - if (m_ValNative->m_RefCount <= 0) { - if (m_ValNative != orig->m_ValNative) delete m_ValNative; - m_ValNative = NULL; + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; } } - if (orig->m_Type == VAL_VARIABLE_REF && orig->m_ValRef && CopyWhole) orig = orig->m_ValRef; + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && CopyWhole) orig = orig->_valRef; Cleanup(true); - m_Type = orig->m_Type; - m_ValBool = orig->m_ValBool; - m_ValInt = orig->m_ValInt; - m_ValFloat = orig->m_ValFloat; - SetStringVal(orig->m_ValString); + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + SetStringVal(orig->_valString); - m_ValRef = orig->m_ValRef; - m_Persistent = orig->m_Persistent; + _valRef = orig->_valRef; + _persistent = orig->_persistent; - m_ValNative = orig->m_ValNative; - if (m_ValNative && !m_Persistent) m_ValNative->m_RefCount++; + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; //!!!! ref->native++ // copy properties - if (orig->m_Type == VAL_OBJECT && orig->m_ValObject.size() > 0) { - orig->m_ValIter = orig->m_ValObject.begin(); - while (orig->m_ValIter != orig->m_ValObject.end()) { - m_ValObject[orig->m_ValIter->_key] = new CScValue(Game); - m_ValObject[orig->m_ValIter->_key]->Copy(orig->m_ValIter->_value); - orig->m_ValIter++; + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(Game); + _valObject[orig->_valIter->_key]->Copy(orig->_valIter->_value); + orig->_valIter++; } - } else m_ValObject.clear(); + } else _valObject.clear(); } ////////////////////////////////////////////////////////////////////////// void CScValue::SetValue(CScValue *Val) { - if (Val->m_Type == VAL_VARIABLE_REF) { - SetValue(Val->m_ValRef); + if (Val->_type == VAL_VARIABLE_REF) { + SetValue(Val->_valRef); return; } // if being assigned a simple type, preserve native state - if (m_Type == VAL_NATIVE && (Val->m_Type == VAL_INT || Val->m_Type == VAL_STRING || Val->m_Type == VAL_BOOL)) { - switch (Val->m_Type) { + if (_type == VAL_NATIVE && (Val->_type == VAL_INT || Val->_type == VAL_STRING || Val->_type == VAL_BOOL)) { + switch (Val->_type) { case VAL_INT: - m_ValNative->ScSetInt(Val->GetInt()); + _valNative->ScSetInt(Val->GetInt()); break; case VAL_FLOAT: - m_ValNative->ScSetFloat(Val->GetFloat()); + _valNative->ScSetFloat(Val->GetFloat()); break; case VAL_BOOL: - m_ValNative->ScSetBool(Val->GetBool()); + _valNative->ScSetBool(Val->GetBool()); break; case VAL_STRING: - m_ValNative->ScSetString(Val->GetString()); + _valNative->ScSetString(Val->GetString()); break; } } @@ -712,26 +712,26 @@ void CScValue::SetValue(CScValue *Val) { HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_Persistent)); - PersistMgr->Transfer(TMEMBER(m_IsConstVar)); - PersistMgr->Transfer(TMEMBER_INT(m_Type)); - PersistMgr->Transfer(TMEMBER(m_ValBool)); - PersistMgr->Transfer(TMEMBER(m_ValFloat)); - PersistMgr->Transfer(TMEMBER(m_ValInt)); - PersistMgr->Transfer(TMEMBER(m_ValNative)); + PersistMgr->Transfer(TMEMBER(_persistent)); + PersistMgr->Transfer(TMEMBER(_isConstVar)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_valBool)); + PersistMgr->Transfer(TMEMBER(_valFloat)); + PersistMgr->Transfer(TMEMBER(_valInt)); + PersistMgr->Transfer(TMEMBER(_valNative)); int size; char *str; - if (PersistMgr->m_Saving) { - size = m_ValObject.size(); + if (PersistMgr->_saving) { + size = _valObject.size(); PersistMgr->Transfer("", &size); - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { - str = (char *)m_ValIter->_key.c_str(); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = (char *)_valIter->_key.c_str(); PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &m_ValIter->_value); + PersistMgr->Transfer("", &_valIter->_value); - m_ValIter++; + _valIter++; } } else { CScValue *val; @@ -740,28 +740,28 @@ HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer("", &str); PersistMgr->Transfer("", &val); - m_ValObject[str] = val; + _valObject[str] = val; delete [] str; } } - PersistMgr->Transfer(TMEMBER(m_ValRef)); - PersistMgr->Transfer(TMEMBER(m_ValString)); + PersistMgr->Transfer(TMEMBER(_valRef)); + PersistMgr->Transfer(TMEMBER(_valString)); /* FILE* f = fopen("c:\\val.log", "a+"); - switch(m_Type) + switch(_type) { case VAL_STRING: - fprintf(f, "str %s\n", m_ValString); + fprintf(f, "str %s\n", _valString); break; case VAL_INT: - fprintf(f, "int %d\n", m_ValInt); + fprintf(f, "int %d\n", _valInt); break; case VAL_BOOL: - fprintf(f, "bool %d\n", m_ValBool); + fprintf(f, "bool %d\n", _valBool); break; case VAL_NULL: @@ -794,14 +794,14 @@ HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { Buffer->PutTextIndent(Indent, "PROPERTY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)m_ValIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", m_ValIter->_value->GetString()); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_valIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); Buffer->PutTextIndent(Indent, "}\n\n"); - m_ValIter++; + _valIter++; } return S_OK; } @@ -853,10 +853,10 @@ int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { ////////////////////////////////////////////////////////////////////////// HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { - Client->OnVariableInit(Type, Script, ScopeID, m_ValIter->_value, m_ValIter->_key.c_str()); - m_ValIter++; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + Client->OnVariableInit(Type, Script, ScopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; } return S_OK; } @@ -987,23 +987,23 @@ bool CScValue::DbgSetVal() { ////////////////////////////////////////////////////////////////////////// int CScValue::DbgGetNumProperties() { - if (m_ValNative && m_ValNative->m_ScProp) return m_ValNative->m_ScProp->DbgGetNumProperties(); - else return m_ValObject.size(); + if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetNumProperties(); + else return _valObject.size(); } ////////////////////////////////////////////////////////////////////////// bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) { - if (m_ValNative && m_ValNative->m_ScProp) return m_ValNative->m_ScProp->DbgGetProperty(Index, Name, Value); + if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(Index, Name, Value); else { int Count = 0; - m_ValIter = m_ValObject.begin(); - while (m_ValIter != m_ValObject.end()) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { if (Count == Index) { - *Name = m_ValIter->_key.c_str(); - *Value = m_ValIter->_value; + *Name = _valIter->_key.c_str(); + *Value = _valIter->_value; return true; } - m_ValIter++; + _valIter++; Count++; } return false; @@ -1012,10 +1012,10 @@ bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Valu ////////////////////////////////////////////////////////////////////////// bool CScValue::DbgGetDescription(char *Buf, int BufSize) { - if (m_Type == VAL_VARIABLE_REF) return m_ValRef->DbgGetDescription(Buf, BufSize); + if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(Buf, BufSize); - if (m_Type == VAL_NATIVE) { - m_ValNative->ScDebuggerDesc(Buf, BufSize); + if (_type == VAL_NATIVE) { + _valNative->ScDebuggerDesc(Buf, BufSize); } else { strncpy(Buf, GetString(), BufSize); } diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 3d0c69d3f7..992a220622 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -53,10 +53,10 @@ public: void Cleanup(bool IgnoreNatives = false); DECLARE_PERSISTENT(CScValue, CBBase) - bool m_IsConstVar; + bool _isConstVar; HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); void SetValue(CScValue *Val); - bool m_Persistent; + bool _persistent; bool PropExists(char *Name); void Copy(CScValue *orig, bool CopyWhole = false); void SetStringVal(const char *Val); @@ -87,21 +87,21 @@ public: bool IsObject(); HRESULT SetProp(char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); CScValue *GetProp(char *Name); - CBScriptable *m_ValNative; - CScValue *m_ValRef; - bool m_ValBool; - int m_ValInt; - double m_ValFloat; - char *m_ValString; - TValType m_Type; + CBScriptable *_valNative; + CScValue *_valRef; + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; + TValType _type; CScValue(CBGame *inGame); CScValue(CBGame *inGame, bool Val); CScValue(CBGame *inGame, int Val); CScValue(CBGame *inGame, double Val); CScValue(CBGame *inGame, const char *Val); virtual ~CScValue(); - Common::HashMap m_ValObject; - Common::HashMap::iterator m_ValIter; + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; bool SetProperty(const char *PropName, int Value); bool SetProperty(const char *PropName, const char *Value); diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index 6c5ddb5d40..5a7588e765 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -235,7 +235,7 @@ bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { ////////////////////////////////////////////////////////////////////////// char *CBUtils::GetPath(char *Filename) { AnsiString path = PathUtil::GetDirectoryName(Filename); - //path = boost::filesystem::system_complete(path).string(); + //path = boost::filesystem::syste_complete(path).string(); warning("CBUtils::GetPath: (%s), not implemented", Filename); return Filename; char *ret = new char[path.size() + 1]; -- cgit v1.2.3 From 3a3304e324970032638b7a9eca9c264e26dc34c1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 13:48:17 +0200 Subject: WINTERMUTE: Make BPkgFile use zlib-streams and substreams. Note that there is still much that could be simplified here by using substreams more extensively, instead of the specific WinterMute-solutions that are currently in place for dcp-files. --- engines/wintermute/BDiskFile.cpp | 4 +- engines/wintermute/BFileManager.cpp | 21 +++++--- engines/wintermute/BPackage.cpp | 7 +-- engines/wintermute/BPackage.h | 10 ++-- engines/wintermute/BPkgFile.cpp | 98 ++++++------------------------------- engines/wintermute/BPkgFile.h | 5 +- 6 files changed, 42 insertions(+), 103 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index 24c25f3bed..6e66bb721e 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -56,12 +56,13 @@ CBDiskFile::~CBDiskFile() { HRESULT CBDiskFile::Open(Common::String Filename) { Close(); + warning("CBDiskFile::Open(%s)", Filename.c_str()); char FullPath[MAX_PATH]; for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); CorrectSlashes(FullPath); - + warning("CBDiskFile::Open - Attempting: %s", FullPath); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if(tempFile->open(FullPath)) { @@ -79,6 +80,7 @@ HRESULT CBDiskFile::Open(Common::String Filename) { if (!_file) { strcpy(FullPath, Filename.c_str()); CorrectSlashes(FullPath); + warning("CBDiskFile::Open - Attempting2: %s", FullPath); //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index fa491b62df..0967df5518 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -677,8 +677,8 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { ////////////////////////////////////////////////////////////////////////// Common::File *CBFileManager::OpenPackage(char *Name) { - //TODO - warning("Implement OpenPackage %s", Name); + //TODO: Is it really necessary to do this when we have the ScummVM-system? + warning("OpenPackage(%s)", Name); //RestoreCurrentDir(); @@ -687,12 +687,18 @@ Common::File *CBFileManager::OpenPackage(char *Name) { for (int i = 0; i < _packagePaths.GetSize(); i++) { sprintf(Filename, "%s%s.%s", _packagePaths[i], Name, PACKAGE_EXTENSION); - //ret = fopen(Filename, "rb"); ret->open(Filename); if (ret->isOpen()) { return ret; } } + + sprintf(Filename, "%s.%s", Name, PACKAGE_EXTENSION); + ret->open(Filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", Name); delete ret; return NULL; } @@ -815,22 +821,23 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { return NULL; } } - + warning("BFileManager::OpenFileRaw(%s)", Filename); + warning("Trying DiskFile"); CBDiskFile *DiskFile = new CBDiskFile(Game); if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; delete DiskFile; - + warning("Trying PkgFile"); CBPkgFile *PkgFile = new CBPkgFile(Game); if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; delete PkgFile; - + warning("Trying ResourceFile"); CBResourceFile *ResFile = new CBResourceFile(Game); if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; delete ResFile; - + warning("BFileManager::OpenFileRaw - Failed to open %s", Filename); return NULL; } diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp index 64e19491d5..56774c64bd 100644 --- a/engines/wintermute/BPackage.cpp +++ b/engines/wintermute/BPackage.cpp @@ -31,6 +31,7 @@ #include "BGame.h" #include "BFileManager.h" #include "common/file.h" +#include "common/stream.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////// @@ -74,7 +75,7 @@ HRESULT CBPackage::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Read(Common::File *file, uint32 offset, byte *buffer, uint32 size) { +HRESULT CBPackage::Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { HRESULT ret; if (FAILED(ret = Open())) return ret; else { @@ -85,7 +86,7 @@ HRESULT CBPackage::Read(Common::File *file, uint32 offset, byte *buffer, uint32 } ////////////////////////////////////////////////////////////////////////// -Common::File *CBPackage::GetFilePointer() { +Common::SeekableReadStream *CBPackage::GetFilePointer() { Common::File *file = Game->_fileManager->OpenPackage(_name); if (!file) { Game->_fileManager->RequestCD(_cD, _name, ""); @@ -95,7 +96,7 @@ Common::File *CBPackage::GetFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::CloseFilePointer(Common::File*& file) { +void CBPackage::CloseFilePointer(Common::SeekableReadStream*& file) { delete file; file = NULL; } diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h index 347582da4c..586088174f 100644 --- a/engines/wintermute/BPackage.h +++ b/engines/wintermute/BPackage.h @@ -33,24 +33,24 @@ #include "BBase.h" namespace Common { - class File; + class SeekableReadStream; } namespace WinterMute { class CBPackage : public CBBase { public: - Common::File *GetFilePointer(); - void CloseFilePointer(Common::File*& file); + Common::SeekableReadStream *GetFilePointer(); + void CloseFilePointer(Common::SeekableReadStream*& file); bool _boundToExe; byte _priority; - HRESULT Read(Common::File *file, uint32 offset, byte *buffer, uint32 size); + HRESULT Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); HRESULT Close(); HRESULT Open(); char *_name; int _cD; - Common::File *_file; + Common::SeekableReadStream *_file; CBPackage(CBGame *inGame); virtual ~CBPackage(); diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index b8bd760ced..441a990ecb 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -32,17 +32,10 @@ #include "BGame.h" #include "BFileManager.h" #include "common/util.h" - -#if _DEBUG -#pragma comment(lib, "zlib_d.lib") -#else -#pragma comment(lib, "zlib.lib") -#endif - - -extern "C" { -#include "zlib.h" -} +#include "common/file.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" namespace WinterMute { @@ -52,14 +45,8 @@ CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { _file = NULL; _compressed = false; - _stream.zalloc = (alloc_func)0; - _stream.zfree = (free_func)0; - _stream.opaque = (voidpf)0; - - _inflateInit = false; } - ////////////////////////////////////////////////////////////////////////// CBPkgFile::~CBPkgFile() { Close(); @@ -84,10 +71,16 @@ HRESULT CBPkgFile::Open(Common::String Filename) { _file = _fileEntry->_package->GetFilePointer(); if (!_file) return E_FAIL; - + // TODO: Cleanup _compressed = (_fileEntry->_compressedLength != 0); _size = _fileEntry->_length; - + + if (_compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + _file = wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + } + SeekToPos(0); return S_OK; @@ -102,12 +95,10 @@ HRESULT CBPkgFile::Close() { } _file = NULL; + // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? _pos = 0; _size = 0; - if (_inflateInit) inflateEnd(&_stream); - _inflateInit = false; - return S_OK; } @@ -123,32 +114,7 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { if (Size == 0) return E_FAIL; } - if (_compressed) { - uint32 InitOut = _stream.total_out; - - _stream.avail_out = Size; - _stream.next_out = (byte *)Buffer; - - while (_stream.total_out - InitOut < Size && _stream.total_in < _fileEntry->_compressedLength) { - // needs to read more data? - if (_stream.avail_in == 0) { - _stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, _fileEntry->_compressedLength - _stream.total_in); // TODO: long unsigned int???? - _fileEntry->_package->Read(_file, _fileEntry->_offset + _stream.total_in, _compBuffer, _stream.avail_in); - _stream.next_in = _compBuffer; - } - - int res = inflate(&_stream, Z_SYNC_FLUSH); - if (res != Z_OK && res != Z_STREAM_END) { - Game->LOG(0, "zlib error: %d", res); - ret = E_FAIL; - break; - } - } - - - } else { - ret = _fileEntry->_package->Read(_file, _fileEntry->_offset + _pos, (byte *)Buffer, Size); - } + ret = _file->read(Buffer, Size); _pos += Size; @@ -186,42 +152,6 @@ HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { HRESULT ret = S_OK; // seek compressed stream to NewPos - if (_compressed) { - byte StreamBuffer[STREAM_BUFFER_SIZE]; - if (_inflateInit) inflateEnd(&_stream); - _inflateInit = false; - - _stream.avail_in = 0; - _stream.next_in = _compBuffer; - _stream.avail_out = MIN((uint32)STREAM_BUFFER_SIZE, NewPos); //TODO: remove cast. - _stream.next_out = StreamBuffer; - inflateInit(&_stream); - _inflateInit = true; - - while (_stream.total_out < NewPos && _stream.total_in < _fileEntry->_compressedLength) { - // needs to read more data? - if (_stream.avail_in == 0) { - _stream.avail_in = MIN((long unsigned int)COMPRESSED_BUFFER_SIZE, _fileEntry->_compressedLength - _stream.total_in); // TODO: long unsigned int??? - _fileEntry->_package->Read(_file, _fileEntry->_offset + _stream.total_in, _compBuffer, _stream.avail_in); - _stream.next_in = _compBuffer; - } - - // needs more space? - if (_stream.avail_out == 0) { - _stream.next_out = StreamBuffer; - _stream.avail_out = MIN((long unsigned int)STREAM_BUFFER_SIZE, NewPos - _stream.total_out); // TODO: long unsigned int???. - } - - // stream on! - int res = inflate(&_stream, Z_SYNC_FLUSH); - if (res != Z_OK && res != Z_STREAM_END) { - ret = E_FAIL; - break; - } - } - - } - _pos = NewPos; return ret; } diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h index 3d165c4097..9b70d37ed6 100644 --- a/engines/wintermute/BPkgFile.h +++ b/engines/wintermute/BPkgFile.h @@ -37,6 +37,7 @@ #define COMPRESSED_BUFFER_SIZE 4096 namespace Common { + class SeekableReadStream; class File; } @@ -55,9 +56,7 @@ private: HRESULT SeekToPos(uint32 NewPos); bool _compressed; CBFileEntry *_fileEntry; - z_stream _stream; - byte _compBuffer[COMPRESSED_BUFFER_SIZE]; - Common::File *_file; + Common::SeekableReadStream *_file; }; } // end of namespace WinterMute -- cgit v1.2.3 From cb06258124453f8d28f9768433d36ab25c0a92c8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 13:59:30 +0200 Subject: WINTERMUTE: Avoid touching SDL_Quit in-engine --- engines/wintermute/BRenderSDL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index c6684ec348..f287403091 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -54,13 +54,13 @@ CBRenderSDL::~CBRenderSDL() { #if 0 if (_renderer) SDL_DestroyRenderer(_renderer); if (_win) SDL_DestroyWindow(_win); -#endif SDL_Quit(); +#endif } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { - if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; #if 0 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); -- cgit v1.2.3 From 59dffd5e86490d3a513445fa21ff142aa5ff4a02 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 13:59:51 +0200 Subject: WINTERMUTE: Correct the default-resolution to 640x480 --- engines/wintermute/wintermute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index aa32ad8578..1faa4a44f0 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -71,7 +71,7 @@ namespace WinterMute { Common::Error WinterMuteEngine::run() { // Initialize graphics using following: - initGraphics(320, 200, false); + initGraphics(640, 480, false); // You could use backend transactions directly as an alternative, // but it isn't recommended, until you want to handle the error values -- cgit v1.2.3 From 466596eae4e6e241322ad690eed2d3acc4aef084 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 14:11:00 +0200 Subject: WINTERMUTE: Make BSurfaceSDL init its filename again. --- engines/wintermute/BSurfaceSDL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index e52bfb9561..b8d256aad1 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -150,7 +150,7 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte _cKRed = ck_red; _cKGreen = ck_green; _cKBlue = ck_blue; - +#endif if (!_filename || scumm_stricmp(_filename, Filename) != 0) { SetFilename(Filename); @@ -163,7 +163,7 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte if (_keepLoaded) _lifeTime = -1; _valid = true; - +#if 0 Game->AddMem(_width * _height * 4); #endif -- cgit v1.2.3 From 2f7fe9f443464f3b0fc93966753266be5ac8741f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:16:18 +0200 Subject: WINTERMUTE: Make BPkgFiles use SubStreams for non-compressed files too. Since we already do the assumption that we don't need to do the same package-seeks for compressed files, this assumption needs to be carried for uncompressed files too. --- engines/wintermute/BPkgFile.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index 441a990ecb..783011bbb3 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -79,6 +79,8 @@ HRESULT CBPkgFile::Open(Common::String Filename) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. _file = wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + } else { + _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); } SeekToPos(0); -- cgit v1.2.3 From ecc03331dbc0ba5b2ea6ced1dea7ae171f515ab1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:18:35 +0200 Subject: WINTERMUTE: Correct assumptions about PathUtil::GetExtension This puts it in line with Common::lastPathComponent, i.e. not including the '.' --- engines/wintermute/BFileManager.cpp | 2 +- engines/wintermute/BSoundMgr.cpp | 4 ++-- engines/wintermute/BSprite.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 0967df5518..68a4db4910 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -371,7 +371,7 @@ HRESULT CBFileManager::RegisterPackages() { RegisterPackage("data.dcp"); RegisterPackage("english.dcp"); #if 0 - AnsiString extension = AnsiString(".") + AnsiString(PACKAGE_EXTENSION); + AnsiString extension = AnsiString(PACKAGE_EXTENSION); for (int i = 0; i < _packagePaths.GetSize(); i++) { boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index 3f2837b1db..469d601e46 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -135,11 +135,11 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool // try to switch WAV to OGG file (if available) AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::CompareNoCase(ext, ".wav")) { + if (StringUtil::CompareNoCase(ext, "wav")) { AnsiString path = PathUtil::GetDirectoryName(Filename); AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); - AnsiString newFile = PathUtil::Combine(path, name + ".ogg"); + AnsiString newFile = PathUtil::Combine(path, name + "ogg"); CBFile *file = Game->_fileManager->OpenFile(newFile.c_str()); if (file) { Filename = newFile.c_str(); diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index d951f25461..1fc5ba296a 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -135,7 +135,7 @@ HRESULT CBSprite::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheT HRESULT ret; AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, ".bmp") || StringUtil::CompareNoCase(ext, ".tga") || StringUtil::CompareNoCase(ext, ".png") || StringUtil::CompareNoCase(ext, ".jpg")) { + if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, "bmp") || StringUtil::CompareNoCase(ext, "tga") || StringUtil::CompareNoCase(ext, "png") || StringUtil::CompareNoCase(ext, "jpg")) { CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); -- cgit v1.2.3 From 66602bcd9cecdfbb2d7f1088d96f8c744f602f31 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:29:31 +0200 Subject: WINTERMUTE: Silence an error when trying to set window-title Currently we don't set the window-title anyhow, so why trigger an error about the text-encoding? --- engines/wintermute/BGame.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 7e2c0d316c..8da4dce5b5 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -3791,8 +3791,10 @@ void CBGame::SetWindowTitle() { if (_textEncoding == TEXT_UTF8) { title = Utf8String(Title); } else { - WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr); + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + title = Utf8String(Title); +/* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ } CBRenderSDL *renderer = static_cast(_renderer); -- cgit v1.2.3 From 620b45e517a79371c1b1937f9f9a041285c22df0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:37:53 +0200 Subject: WINTERMUTE: Start work on porting BRenderSDL away from SDL2 In particular this stubs away a few troublesome SDL-calls, that stopped us from getting the engine to start right now. --- engines/wintermute/BRenderSDL.cpp | 27 ++++++++++++++++++--------- engines/wintermute/BRenderSDL.h | 15 +++++++++------ engines/wintermute/BSurfaceSDL.h | 1 + engines/wintermute/PlatformSDL.cpp | 2 ++ 4 files changed, 30 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index f287403091..78c68c0cea 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -36,14 +36,17 @@ #include "engines/wintermute/BGame.h" #include "engines/wintermute/BSprite.h" +#include "SDL.h" + namespace WinterMute { // TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { - _renderer = NULL; - _win = NULL; +/* _renderer = NULL; + _win = NULL;*/ + _renderSurface = NULL; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; @@ -140,8 +143,9 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { SDL_WINDOWPOS_UNDEFINED, _realWidth, _realHeight, flags); -#endif + if (!_win) return E_FAIL; +#endif SDL_ShowCursor(SDL_DISABLE); @@ -153,9 +157,12 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { #endif #if 0 _renderer = SDL_CreateRenderer(_win, -1, 0); -#endif - if (!_renderer) return E_FAIL; + if (!_renderer) return E_FAIL; +#endif + _renderSurface = new Graphics::Surface(); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + _renderSurface->create(640,480, format); // TODO: Unhardcode this. _active = true; @@ -228,6 +235,8 @@ HRESULT CBRenderSDL::Fade(WORD Alpha) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { + warning("Implement CBRenderSDL::FadeToColor"); +#if 0 SDL_Rect fillRect; if (rect) { @@ -253,7 +262,7 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); - +#endif return S_OK; } @@ -324,13 +333,13 @@ HRESULT CBRenderSDL::SwitchFullscreen() { ////////////////////////////////////////////////////////////////////////// const char *CBRenderSDL::GetName() { if (_name.empty()) { - if (_renderer) { #if 0 + if (_renderer) { SDL_RendererInfo info; SDL_GetRendererInfo(_renderer, &info); _name = AnsiString(info.name); -#endif } +#endif } return _name.c_str(); } @@ -351,7 +360,7 @@ HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::ModTargetRect(SDL_Rect *rect) { +void CBRenderSDL::ModTargetRect(Common::Rect *rect) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index edcafdff96..3ef5cc1cde 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -30,7 +30,9 @@ #define WINTERMUTE_BRENDERER_SDL_H #include "BRenderer.h" -#include "SDL.h" +/*#include "SDL.h"*/ +#include "common/rect.h" +#include "graphics/surface.h" class SDL_Window; class SDL_Renderer; @@ -58,15 +60,15 @@ public: CBImage *TakeScreenshot(); SDL_Renderer *GetSdlRenderer() const { - return _renderer; +// return _renderer; } SDL_Window *GetSdlWindow() const { - return _win; +// return _win; } HRESULT SetViewport(int left, int top, int right, int bottom); - void ModTargetRect(SDL_Rect *rect); + void ModTargetRect(Common::Rect *rect); void PointFromScreen(POINT *point); void PointToScreen(POINT *point); @@ -80,8 +82,9 @@ public: } private: - SDL_Renderer *_renderer; - SDL_Window *_win; +/* SDL_Renderer *_renderer; + SDL_Window *_win;*/ + Graphics::Surface *_renderSurface; AnsiString _name; int _borderLeft; diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index ae5fe154f6..557eefeedf 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BSURFACESDL_H #include "BSurface.h" +#include "SDL.h" // TODO, remove class SDL_Texture; class SDL_Surface; namespace WinterMute { diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index f1a295b443..b80efb3820 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -34,6 +34,8 @@ THE SOFTWARE. #include "common/str.h" #include "common/textconsole.h" +#include "SDL.h" // TODO remove + #ifdef __WIN32__ # include # include -- cgit v1.2.3 From e31f23d75d9e99bfdaf03a2adc93e6087102e4a1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:38:35 +0200 Subject: WINTERMUTE: Make the mainloop run after initialization. --- engines/wintermute/wintermute.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 1faa4a44f0..6546dcadaf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -104,8 +104,14 @@ namespace WinterMute { debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); CAdGame *game = new CAdGame; - CBPlatform::Initialize(game, NULL, 0); + int ret = 1; + + ret = CBPlatform::Initialize(game, NULL, 0); + + if (ret == 0) { + ret = CBPlatform::MessageLoop(); + } return Common::kNoError; } -- cgit v1.2.3 From 21033f631f5895bb88779c1dd77b6d17466c6840 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 15:50:10 +0200 Subject: WINTERMUTE: Cleanup the debug-warnings a bit. --- engines/wintermute/BDiskFile.cpp | 7 ------- engines/wintermute/BFileManager.cpp | 4 ---- engines/wintermute/BRenderSDL.cpp | 8 +++++++- engines/wintermute/BSurfaceSDL.cpp | 17 ++++++++++++++--- engines/wintermute/StringUtil.cpp | 8 ++++---- 5 files changed, 25 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index 6e66bb721e..591da4b9db 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -56,13 +56,11 @@ CBDiskFile::~CBDiskFile() { HRESULT CBDiskFile::Open(Common::String Filename) { Close(); - warning("CBDiskFile::Open(%s)", Filename.c_str()); char FullPath[MAX_PATH]; for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); CorrectSlashes(FullPath); - warning("CBDiskFile::Open - Attempting: %s", FullPath); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if(tempFile->open(FullPath)) { @@ -80,7 +78,6 @@ HRESULT CBDiskFile::Open(Common::String Filename) { if (!_file) { strcpy(FullPath, Filename.c_str()); CorrectSlashes(FullPath); - warning("CBDiskFile::Open - Attempting2: %s", FullPath); //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); @@ -90,10 +87,6 @@ HRESULT CBDiskFile::Open(Common::String Filename) { delete tempFile; } } - - if (!_file) { - warning("Couldn't load %s", Filename.c_str()); - } if (_file) { uint32 magic1, magic2; diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 68a4db4910..0cc96323cc 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -678,7 +678,6 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { ////////////////////////////////////////////////////////////////////////// Common::File *CBFileManager::OpenPackage(char *Name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? - warning("OpenPackage(%s)", Name); //RestoreCurrentDir(); @@ -822,17 +821,14 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { } } warning("BFileManager::OpenFileRaw(%s)", Filename); - warning("Trying DiskFile"); CBDiskFile *DiskFile = new CBDiskFile(Game); if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; delete DiskFile; - warning("Trying PkgFile"); CBPkgFile *PkgFile = new CBPkgFile(Game); if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; delete PkgFile; - warning("Trying ResourceFile"); CBResourceFile *ResFile = new CBResourceFile(Game); if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 78c68c0cea..9e9d7ef6d5 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -235,7 +235,13 @@ HRESULT CBRenderSDL::Fade(WORD Alpha) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { - warning("Implement CBRenderSDL::FadeToColor"); + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Implement CBRenderSDL::FadeToColor"); // TODO. + hasWarned = true; + } #if 0 SDL_Rect fillRect; diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index b8d256aad1..4f36a13dd5 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -301,7 +301,13 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { Uint32 format; int access; int width, height; - warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); + hasWarned = true; + } //SDL_QueryTexture(_texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -378,8 +384,13 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo byte g = D3DCOLGetG(Alpha); byte b = D3DCOLGetB(Alpha); byte a = D3DCOLGetA(Alpha); - - warning("CBSurfaceSDL::DrawSprite not ported yet"); // TODO. + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::DrawSprite not ported yet"); // TODO. + hasWarned = true; + } #if 0 SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index 3fcc156ffc..746250ceeb 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -80,7 +80,7 @@ bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { ////////////////////////////////////////////////////////////////////////// WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { - error("WideString not supported yet"); + error("StringUtil::Utf8ToWide - WideString not supported yet"); /* size_t WideSize = Utf8Str.size(); if (sizeof(wchar_t) == 2) { @@ -129,7 +129,7 @@ WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { ////////////////////////////////////////////////////////////////////////// Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { - error("Widestring not supported yet"); + error("StringUtil::WideToUtf8 - Widestring not supported yet"); /* size_t WideSize = WideStr.length(); if (sizeof(wchar_t) == 2) { @@ -179,7 +179,7 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { ////////////////////////////////////////////////////////////////////////// WideString StringUtil::AnsiToWide(const AnsiString &str) { // using default os locale! - error("WideString not supported yet"); + error("StringUtil::AnsiToWide - WideString not supported yet"); /* setlocale(LC_CTYPE, ""); size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; wchar_t *wstr = new wchar_t[WideSize]; @@ -193,7 +193,7 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::WideToAnsi(const WideString &wstr) { // using default os locale! - error("WideString not supported yet"); + error("StringUtil::WideToAnsi - WideString not supported yet"); /* setlocale(LC_CTYPE, ""); size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; -- cgit v1.2.3 From 9355850d0728df266b33446e58ab0f330d34321d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 18:04:02 +0200 Subject: WINTERMUTE: Make the engine atleast draw something. --- engines/wintermute/BRenderSDL.cpp | 18 ++++++++---- engines/wintermute/BRenderSDL.h | 3 ++ engines/wintermute/BSurfaceSDL.cpp | 60 +++++++++++++++++++++++++------------- engines/wintermute/BSurfaceSDL.h | 4 ++- engines/wintermute/wintermute.cpp | 3 +- 5 files changed, 60 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 9e9d7ef6d5..1daf2aafc8 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/MathUtil.h" #include "engines/wintermute/BGame.h" #include "engines/wintermute/BSprite.h" - +#include "common/system.h" #include "SDL.h" namespace WinterMute { @@ -161,8 +161,7 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (!_renderer) return E_FAIL; #endif _renderSurface = new Graphics::Surface(); - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - _renderSurface->create(640,480, format); // TODO: Unhardcode this. + _renderSurface->create(640,480, g_system->getScreenFormat()); // TODO: Unhardcode this. _active = true; @@ -211,8 +210,9 @@ HRESULT CBRenderSDL::Flip() { } } #endif - - + // TODO, unhardcode. + g_system->copyRectToScreen((byte*)_renderSurface->pixels, _renderSurface->pitch, 0, 0, 640, 480); + g_system->updateScreen(); //SDL_RenderPresent(_renderer); return S_OK; @@ -272,6 +272,14 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { return S_OK; } +// Replacement for SDL2's SDL_RenderCopy +void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { + for (int i = 0; i < srcRect->height(); i++) { + void *destPtr = _renderSurface->getBasePtr(dstRect->left, dstRect->top + i); + void *srcPtr = surf->getBasePtr(srcRect->left, srcRect->top + i); + memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel * srcRect->width()); + } +} ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { byte r = D3DCOLGetR(Color); diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 3ef5cc1cde..73d3bbac29 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -65,6 +65,9 @@ public: SDL_Window *GetSdlWindow() const { // return _win; } + + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); + HRESULT SetViewport(int left, int top, int right, int bottom); diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 4f36a13dd5..e3853fb252 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -44,7 +44,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { - _texture = NULL; + _surface = new Graphics::Surface(); _alphaMask = NULL; _lockPixels = NULL; @@ -54,6 +54,7 @@ CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::~CBSurfaceSDL() { //TODO + delete _surface; #if 0 if (_texture) SDL_DestroyTexture(_texture); delete[] _alphaMask; @@ -124,12 +125,14 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte uint32 bmask = surface->format.bMax() << surface->format.bShift; uint32 amask = surface->format.aMax(); - SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); +// SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); // no alpha, set color key - if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue)); - +/* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); warning("Surface-textures not fully ported yet"); @@ -281,7 +284,13 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { int access; int width, height; - warning("CBSurfaceSDL::IsTransparentAt not ported yet"); + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::IsTransparentAt not ported yet"); + hasWarned = true; + } //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -388,7 +397,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceSDL::DrawSprite not ported yet"); // TODO. + warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } #if 0 @@ -399,24 +408,33 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); else SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); - - SDL_Rect srcRect; - srcRect.x = Rect->left; - srcRect.y = Rect->top; - srcRect.w = Rect->right - Rect->left; - srcRect.h = Rect->bottom - Rect->top; - - SDL_Rect position; - position.x = X; - position.y = Y; - position.w = (float)srcRect.w * ZoomX / 100.f; - position.h = (float)srcRect.h * ZoomX / 100.f; +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = Rect->left; + srcRect.top = Rect->top; + srcRect.setWidth(Rect->right - Rect->left); + srcRect.setHeight(Rect->bottom - Rect->top); + + Common::Rect position; + position.left = X; + position.top = Y; + // TODO: Scaling... + /* + position.setWidth((float)srcRect.width() * ZoomX / 100.f); + position.setHeight((float)srcRect.height() * ZoomX / 100.f); +*/ + position.setWidth(srcRect.width()); + position.setHeight(srcRect.height()); renderer->ModTargetRect(&position); - position.x += offsetX; - position.y += offsetY; + position.left += offsetX; + position.top += offsetY; + renderer->drawFromSurface(_surface, &srcRect, &position); +#if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index 557eefeedf..9053af3d7d 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -29,6 +29,7 @@ #ifndef WINTERMUTE_BSURFACESDL_H #define WINTERMUTE_BSURFACESDL_H +#include "graphics/surface.h" #include "BSurface.h" #include "SDL.h" // TODO, remove class SDL_Texture; @@ -64,7 +65,8 @@ public: static long DLL_CALLCONV TellProc(fi_handle handle);*/ private: - SDL_Texture *_texture; +// SDL_Texture *_texture; + Graphics::Surface *_surface; HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); void GenAlphaMask(SDL_Surface *surface); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 6546dcadaf..298e4a97c6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -71,7 +71,8 @@ namespace WinterMute { Common::Error WinterMuteEngine::run() { // Initialize graphics using following: - initGraphics(640, 480, false); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + initGraphics(640, 480, false, &format); // You could use backend transactions directly as an alternative, // but it isn't recommended, until you want to handle the error values -- cgit v1.2.3 From 0b8ac2f3b44883875c9366cd965314257fc32ce7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 19:26:47 +0200 Subject: WINTERMUTE: Add a simple alpha-hack for rendering. This is not pretty, but atleast it shows the entire first screen for 'Dirty Split' drawing fine. --- engines/wintermute/BRenderSDL.cpp | 14 ++++++++++---- engines/wintermute/wintermute.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 1daf2aafc8..a8e18c74d2 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -161,7 +161,7 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (!_renderer) return E_FAIL; #endif _renderSurface = new Graphics::Surface(); - _renderSurface->create(640,480, g_system->getScreenFormat()); // TODO: Unhardcode this. + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; @@ -210,8 +210,7 @@ HRESULT CBRenderSDL::Flip() { } } #endif - // TODO, unhardcode. - g_system->copyRectToScreen((byte*)_renderSurface->pixels, _renderSurface->pitch, 0, 0, 640, 480); + g_system->copyRectToScreen((byte*)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); g_system->updateScreen(); //SDL_RenderPresent(_renderer); @@ -277,7 +276,14 @@ void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect for (int i = 0; i < srcRect->height(); i++) { void *destPtr = _renderSurface->getBasePtr(dstRect->left, dstRect->top + i); void *srcPtr = surf->getBasePtr(srcRect->left, srcRect->top + i); - memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel * srcRect->width()); + for (int j = 0; j < srcRect->width(); j++) { + // TODO: Replace this with something less ugly, and more portable. + if (((byte*)srcPtr)[0] == 255) { + memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel); + } + ((byte*)srcPtr)+=_renderSurface->format.bytesPerPixel; + ((byte*)destPtr)+=_renderSurface->format.bytesPerPixel; + } } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 298e4a97c6..e6b273b291 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -72,7 +72,7 @@ namespace WinterMute { Common::Error WinterMuteEngine::run() { // Initialize graphics using following: Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - initGraphics(640, 480, false, &format); + initGraphics(800, 600, false, &format); // You could use backend transactions directly as an alternative, // but it isn't recommended, until you want to handle the error values -- cgit v1.2.3 From 23dd928733340261aabe3a006e3b17010909d537 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 19:49:53 +0200 Subject: WINTERMUTE: Add in basic sound-support. Right now, all that is supported is triggering OGG-files, the choice of codec is hardcoded, and stopping/pausing etc isn't added in. --- engines/wintermute/BSoundBuffer.cpp | 25 ++++++++++++++++++------- engines/wintermute/BSoundBuffer.h | 7 +++++++ engines/wintermute/BSoundMgr.cpp | 29 +++++++++++++---------------- 3 files changed, 38 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index 7de8aec436..a58f39c869 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -33,6 +33,10 @@ #include "BSoundBuffer.h" #include "BFileManager.h" #include "utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "common/system.h" namespace WinterMute { @@ -44,9 +48,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { -#if 0 _stream = NULL; - _sync = NULL; +// _sync = NULL; _streamed = false; _filename = NULL; @@ -59,7 +62,6 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { _type = SOUND_SFX; _freezePaused = false; -#endif } @@ -91,11 +93,15 @@ void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSi ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload); #if 0 if (_stream) { BASS_StreamFree(_stream); _stream = NULL; } +#endif + delete _stream; + _stream = NULL; if (_file) Game->_fileManager->CloseFile(_file); @@ -104,7 +110,12 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } - + + _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES); + CBUtils::SetString(&_filename, Filename); + + return S_OK; +#if 0 BASS_FILEPROCS fileProc; fileProc.close = CBSoundBuffer::FileCloseProc; fileProc.read = CBSoundBuffer::FileReadProc; @@ -166,13 +177,13 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { -#if 0 + warning("Play: %s", _filename); if (_stream) { SetLooping(Looping); - BASS_ChannelPlay(_stream, TRUE); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream); + //BASS_ChannelPlay(_stream, TRUE); } return S_OK; -#endif } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h index 2a1016f7a9..e9ef8264f7 100644 --- a/engines/wintermute/BSoundBuffer.h +++ b/engines/wintermute/BSoundBuffer.h @@ -33,6 +33,11 @@ #include "BBase.h" //#include "bass.h" +namespace Audio { + class SeekableAudioStream; + class SoundHandle; +} + namespace WinterMute { class CBFile; @@ -72,6 +77,8 @@ public: //HSTREAM _stream; //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; bool _freezePaused; uint32 _loopStart; diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index 469d601e46..17fd3c64b0 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -59,10 +59,9 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::Cleanup() { -#if 0 for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; _sounds.RemoveAll(); - +#if 0 BASS_Free(); #endif return S_OK; @@ -107,10 +106,9 @@ HRESULT CBSoundMgr::Initialize() { _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100); _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); -#if 0 _soundAvailable = true; SetMasterVolumePercent(_volumeMaster); -#endif + return S_OK; } @@ -129,7 +127,6 @@ HRESULT CBSoundMgr::InitLoop() { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool Streamed) { if (!_soundAvailable) return NULL; -#if 0 CBSoundBuffer *sound; @@ -178,14 +175,14 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool _sounds.Add(sound); return sound; -#endif + return NULL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { if (!Sound) return E_FAIL; -#if 0 + // set volume appropriately switch (Type) { case SOUND_SFX: @@ -201,13 +198,13 @@ HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { // register sound _sounds.Add(Sound); -#endif + return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { -#if 0 + for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i] == Sound) { delete _sounds[i]; @@ -215,7 +212,7 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { return S_OK; } } -#endif + return E_FAIL; } @@ -223,7 +220,7 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { if (!_soundAvailable) return S_OK; -#if 0 + switch (Type) { case SOUND_SFX: _volumeSFX = Volume; @@ -239,7 +236,7 @@ HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume); } -#endif + return S_OK; } @@ -291,28 +288,28 @@ byte CBSoundMgr::GetMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { -#if 0 + for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { _sounds[i]->Pause(); _sounds[i]->_freezePaused = true; } } -#endif + return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::ResumeAll() { -#if 0 + for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->_freezePaused) { _sounds[i]->Resume(); _sounds[i]->_freezePaused = false; } } -#endif + return S_OK; } -- cgit v1.2.3 From b6f512f392ea6b3819f322949315a0f3f3a616e3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 20:01:01 +0200 Subject: WINTERMUTE: Some refactoring in BSoundMgr. --- engines/wintermute/BGame.cpp | 48 +++++++++++++++++++------------------- engines/wintermute/BObject.cpp | 2 +- engines/wintermute/BSound.cpp | 8 +++---- engines/wintermute/BSoundMgr.cpp | 38 +++++++++++++++--------------- engines/wintermute/BSoundMgr.h | 30 ++++++++++++------------ engines/wintermute/PlatformSDL.cpp | 2 +- 6 files changed, 64 insertions(+), 64 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 8da4dce5b5..98a561530e 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -600,7 +600,7 @@ HRESULT CBGame::InitLoop() { GetDebugMgr()->OnGameTick(); _renderer->InitLoop(); - _soundMgr->InitLoop(); + _soundMgr->initLoop(); UpdateMusicCrossfade(); _surfaceStorage->InitLoop(); @@ -1516,7 +1516,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->SetVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1526,7 +1526,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1536,7 +1536,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1546,7 +1546,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->SetMasterVolumePercent((byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte )Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1556,7 +1556,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_SFX)); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); return S_OK; } @@ -1565,7 +1565,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_SPEECH)); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return S_OK; } @@ -1574,7 +1574,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->GetVolumePercent(SOUND_MUSIC)); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return S_OK; } @@ -1583,7 +1583,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->GetMasterVolumePercent()); + Stack->PushInt(_soundMgr->getMasterVolumePercent()); return S_OK; } @@ -2219,7 +2219,7 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_SFX)); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SFX)); return _scValue; } @@ -2228,7 +2228,7 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_SPEECH)); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return _scValue; } @@ -2237,7 +2237,7 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->GetVolumePercent(SOUND_MUSIC)); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return _scValue; } @@ -2246,7 +2246,7 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->GetMasterVolumePercent()); + _scValue->SetInt(_soundMgr->getMasterVolumePercent()); return _scValue; } @@ -2543,7 +2543,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->SetVolumePercent(SOUND_SFX, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte )Value->GetInt()); return S_OK; } @@ -2552,7 +2552,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->SetVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); return S_OK; } @@ -2561,7 +2561,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->SetVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); return S_OK; } @@ -2570,7 +2570,7 @@ HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->SetMasterVolumePercent((byte )Value->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte )Value->GetInt()); return S_OK; } @@ -3667,7 +3667,7 @@ HRESULT CBGame::FocusWindow(CUIWindow *Window) { HRESULT CBGame::Freeze(bool IncludingMusic) { if (_freezeLevel == 0) { _scEngine->PauseAll(); - _soundMgr->PauseAll(IncludingMusic); + _soundMgr->pauseAll(IncludingMusic); _origState = _state; _origInteractive = _interactive; _interactive = true; @@ -3688,7 +3688,7 @@ HRESULT CBGame::Unfreeze() { _state = _origState; _interactive = _origInteractive; _scEngine->ResumeAll(); - _soundMgr->ResumeAll(); + _soundMgr->resumeAll(); } return S_OK; @@ -4026,7 +4026,7 @@ HRESULT CBGame::DisplayIndicator() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::UpdateMusicCrossfade() { - byte GlobMusicVol = _soundMgr->GetVolumePercent(SOUND_MUSIC); + byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); if (!_musicCrossfadeRunning) return S_OK; if (_state == GAME_FROZEN) return S_OK; @@ -4154,8 +4154,8 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { SetActiveObject(_renderer->GetObjectAt(p.x, p.y)); } - if (Activate) _soundMgr->ResumeAll(); - else _soundMgr->PauseAll(); + if (Activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); return S_OK; } @@ -4390,7 +4390,7 @@ HRESULT CBGame::MiniUpdate() { if (!_miniUpdateEnabled) return S_OK; if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->InitLoop(); + if (_soundMgr) _soundMgr->initLoop(); _lastMiniUpdate = CBPlatform::GetTime(); } return S_OK; @@ -4446,7 +4446,7 @@ bool CBGame::IsDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void CBGame::AutoSaveOnExit() { - _soundMgr->SaveSettings(); + _soundMgr->saveSettings(); _registry->SaveValues(); if (!_autoSaveOnExit) return; diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 3665341550..beadaf1ec2 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -1076,7 +1076,7 @@ HRESULT CBObject::UpdateOneSound(CBSound *Sound) { if (Sound) { if (_autoSoundPanning) - Ret = Sound->SetPan(Game->_soundMgr->PosToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); + Ret = Sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); Ret = Sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp index 46f7c5ce45..e7c047a40f 100644 --- a/engines/wintermute/BSound.cpp +++ b/engines/wintermute/BSound.cpp @@ -56,7 +56,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBSound::~CBSound() { - if (_sound) Game->_soundMgr->RemoveSound(_sound); + if (_sound) Game->_soundMgr->removeSound(_sound); _sound = NULL; delete[] _soundFilename; @@ -67,13 +67,13 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { if (_sound) { - Game->_soundMgr->RemoveSound(_sound); + Game->_soundMgr->removeSound(_sound); _sound = NULL; } delete[] _soundFilename; _soundFilename = NULL; - _sound = Game->_soundMgr->AddSound(Filename, Type, Streamed); + _sound = Game->_soundMgr->addSound(Filename, Type, Streamed); if (_sound) { _soundFilename = new char[strlen(Filename) + 1]; strcpy(_soundFilename, Filename); @@ -88,7 +88,7 @@ HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::SetSoundSimple() { - _sound = Game->_soundMgr->AddSound(_soundFilename, _soundType, _soundStreamed); + _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->SetPosition(_soundPosition); _sound->SetLooping(_soundLooping); diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index 17fd3c64b0..a58878fd95 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -52,13 +52,13 @@ CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBSoundMgr::~CBSoundMgr() { - SaveSettings(); - Cleanup(); + saveSettings(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::Cleanup() { +HRESULT CBSoundMgr::cleanup() { for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; _sounds.RemoveAll(); #if 0 @@ -68,7 +68,7 @@ HRESULT CBSoundMgr::Cleanup() { } ////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::SaveSettings() { +void CBSoundMgr::saveSettings() { if (_soundAvailable) { Game->_registry->WriteInt("Audio", "MasterVolume", _volumeMaster); @@ -79,7 +79,7 @@ void CBSoundMgr::SaveSettings() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::Initialize() { +HRESULT CBSoundMgr::initialize() { _soundAvailable = false; #if 0 @@ -107,14 +107,14 @@ HRESULT CBSoundMgr::Initialize() { _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); _soundAvailable = true; - SetMasterVolumePercent(_volumeMaster); + setMasterVolumePercent(_volumeMaster); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::InitLoop() { +HRESULT CBSoundMgr::initLoop() { if (!_soundAvailable) return S_OK; #if 0 @@ -125,7 +125,7 @@ HRESULT CBSoundMgr::InitLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool Streamed) { +CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool Streamed) { if (!_soundAvailable) return NULL; CBSoundBuffer *sound; @@ -180,7 +180,7 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { +HRESULT CBSoundMgr::addSound(CBSoundBuffer *Sound, TSoundType Type) { if (!Sound) return E_FAIL; // set volume appropriately @@ -203,7 +203,7 @@ HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { +HRESULT CBSoundMgr::removeSound(CBSoundBuffer *Sound) { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i] == Sound) { @@ -218,7 +218,7 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { +HRESULT CBSoundMgr::setVolume(TSoundType Type, int Volume) { if (!_soundAvailable) return S_OK; switch (Type) { @@ -241,13 +241,13 @@ HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::SetVolumePercent(TSoundType Type, byte Percent) { - return SetVolume(Type, Percent); +HRESULT CBSoundMgr::setVolumePercent(TSoundType Type, byte Percent) { + return setVolume(Type, Percent); } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::GetVolumePercent(TSoundType Type) { +byte CBSoundMgr::getVolumePercent(TSoundType Type) { int Volume; switch (Type) { case SOUND_SFX: @@ -266,7 +266,7 @@ byte CBSoundMgr::GetVolumePercent(TSoundType Type) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::SetMasterVolumePercent(byte Percent) { +HRESULT CBSoundMgr::setMasterVolumePercent(byte Percent) { _volumeMaster = Percent; #if 0 BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); @@ -276,7 +276,7 @@ HRESULT CBSoundMgr::SetMasterVolumePercent(byte Percent) { ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::GetMasterVolumePercent() { +byte CBSoundMgr::getMasterVolumePercent() { #if 0 uint32 val = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM); return (float)val / 10000.0f * 100.0f; @@ -287,7 +287,7 @@ byte CBSoundMgr::GetMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { +HRESULT CBSoundMgr::pauseAll(bool IncludingMusic) { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { @@ -301,7 +301,7 @@ HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::ResumeAll() { +HRESULT CBSoundMgr::resumeAll() { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->_freezePaused) { @@ -315,7 +315,7 @@ HRESULT CBSoundMgr::ResumeAll() { ////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::PosToPan(int X, int Y) { +float CBSoundMgr::posToPan(int X, int Y) { float relPos = (float)X / ((float)Game->_renderer->_width); float minPan = -0.7f; diff --git a/engines/wintermute/BSoundMgr.h b/engines/wintermute/BSoundMgr.h index de74f6c4df..aa03edf1de 100644 --- a/engines/wintermute/BSoundMgr.h +++ b/engines/wintermute/BSoundMgr.h @@ -38,31 +38,31 @@ namespace WinterMute { class CBSoundMgr : public CBBase { public: - float PosToPan(int X, int Y); - HRESULT ResumeAll(); - HRESULT PauseAll(bool IncludingMusic = true); - HRESULT Cleanup(); + float posToPan(int X, int Y); + HRESULT resumeAll(); + HRESULT pauseAll(bool IncludingMusic = true); + HRESULT cleanup(); //DECLARE_PERSISTENT(CBSoundMgr, CBBase); - byte GetMasterVolumePercent(); - HRESULT SetMasterVolumePercent(byte Percent); - byte GetVolumePercent(TSoundType Type); - HRESULT SetVolumePercent(TSoundType Type, byte Percent); - HRESULT SetVolume(TSoundType Type, int Volume); + byte getMasterVolumePercent(); + HRESULT setMasterVolumePercent(byte Percent); + byte getVolumePercent(TSoundType Type); + HRESULT setVolumePercent(TSoundType Type, byte Percent); + HRESULT setVolume(TSoundType Type, int Volume); uint32 _volumeOriginal; int _volumeMaster; int _volumeMusic; int _volumeSpeech; int _volumeSFX; - HRESULT RemoveSound(CBSoundBuffer *Sound); - CBSoundBuffer *AddSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); - HRESULT AddSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); - HRESULT InitLoop(); - HRESULT Initialize(); + HRESULT removeSound(CBSoundBuffer *Sound); + CBSoundBuffer *addSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + HRESULT addSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); + HRESULT initLoop(); + HRESULT initialize(); bool _soundAvailable; CBSoundMgr(CBGame *inGame); virtual ~CBSoundMgr(); CBArray _sounds; - void SaveSettings(); + void saveSettings(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index b80efb3820..51e41f01bb 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -141,7 +141,7 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { #endif // initialize sound manager (non-fatal if we fail) - ret = Game->_soundMgr->Initialize(); + ret = Game->_soundMgr->initialize(); if (FAILED(ret)) { Game->LOG(ret, "Sound is NOT available."); } -- cgit v1.2.3 From f07690cb9699b670198dce2445514967ccafb1cb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 9 May 2012 20:04:11 +0200 Subject: WINTERMUTE: Make the messiest warnings warn just once. --- engines/wintermute/BFileManager.cpp | 2 +- engines/wintermute/BSurfaceSDL.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 0cc96323cc..24bc886e9c 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -820,7 +820,7 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { return NULL; } } - warning("BFileManager::OpenFileRaw(%s)", Filename); + CBDiskFile *DiskFile = new CBDiskFile(Game); if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index e3853fb252..b976585b0b 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -135,7 +135,14 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - warning("Surface-textures not fully ported yet"); + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Surface-textures not fully ported yet"); + hasWarned = true; + } #if 0 _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); if (!_texture) { -- cgit v1.2.3 From 2e12f9fe4d74e6f6d6ebe753fa24f863f901e312 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 00:09:22 +0200 Subject: WINTERMUTE: Initial conversion of events from SDL2->OSystem --- engines/wintermute/BGame.cpp | 10 +++-- engines/wintermute/BGame.h | 3 +- engines/wintermute/BKeyboardState.cpp | 28 +++++++------- engines/wintermute/BKeyboardState.h | 6 +-- engines/wintermute/PlatformSDL.cpp | 70 ++++++++++++++++------------------- engines/wintermute/PlatformSDL.h | 3 +- engines/wintermute/UIEdit.cpp | 33 +++++++++-------- engines/wintermute/UIEdit.h | 3 +- 8 files changed, 80 insertions(+), 76 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 98a561530e..08d78e1745 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -69,6 +69,7 @@ #include "engines/wintermute/scriptables/SXString.h" #include "common/textconsole.h" #include "common/util.h" +#include "common/keyboard.h" #ifdef __IPHONEOS__ # include "ios_utils.h" @@ -3696,16 +3697,19 @@ HRESULT CBGame::Unfreeze() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleKeypress(SDL_Event *event) { +bool CBGame::HandleKeypress(Common::Event *event) { #ifdef __WIN32__ + // TODO: Do we really need to handle this in-engine? // handle Alt+F4 on windows - if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_F4 && (event->key.keysym.mod == KMOD_LALT || event->key.keysym.mod == KMOD_RALT)) { + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) { OnWindowClose(); return true; + //TODO } #endif - if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_RETURN && (event->key.keysym.mod == KMOD_LALT || event->key.keysym.mod == KMOD_RALT)) { + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. _renderer->SwitchFullscreen(); return true; } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index f783f2a967..9f8ef5241b 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -37,6 +37,7 @@ #include "engines/wintermute/BObject.h" #include "engines/wintermute/persistent.h" #include "coll_templ.h" +#include "common/events.h" namespace WinterMute { @@ -257,7 +258,7 @@ public: bool _quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); int _freezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 6b68f4a2d3..892c8a837b 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -30,6 +30,8 @@ #include "BKeyboardState.h" #include "engines/wintermute/scriptables/ScValue.h" #include "engines/wintermute/scriptables/ScStack.h" +#include "common/system.h" +#include "common/keyboard.h" namespace WinterMute { @@ -177,7 +179,7 @@ char *CBKeyboardState::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ReadKey(SDL_Event *event) { +HRESULT CBKeyboardState::ReadKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = KeyCodeToVKey(event); //_currentKeyData = KeyData; @@ -207,31 +209,31 @@ HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// bool CBKeyboardState::IsShiftDown() { - int mod = SDL_GetModState(); - return (mod & KMOD_LSHIFT) || (mod & KMOD_RSHIFT); + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); } ////////////////////////////////////////////////////////////////////////// bool CBKeyboardState::IsControlDown() { - int mod = SDL_GetModState(); - return (mod & KMOD_LCTRL) || (mod & KMOD_RCTRL); + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); } ////////////////////////////////////////////////////////////////////////// bool CBKeyboardState::IsAltDown() { - int mod = SDL_GetModState(); - return (mod & KMOD_LALT) || (mod & KMOD_RALT); + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); } ////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::KeyCodeToVKey(SDL_Event *event) { - if (event->type != SDL_KEYDOWN) return 0; +uint32 CBKeyboardState::KeyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; - switch (event->key.keysym.sym) { - case SDLK_KP_ENTER: - return SDLK_RETURN; + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; default: - return event->key.keysym.sym; + return (uint32)event->kbd.keycode; } } diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index 9b43190382..393f93d7da 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -33,7 +33,7 @@ #include "BBase.h" #include "BScriptable.h" #include "common/keyboard.h" -#include +#include "common/events.h" namespace WinterMute { @@ -50,7 +50,7 @@ public: DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) CBKeyboardState(CBGame *inGame); virtual ~CBKeyboardState(); - HRESULT ReadKey(SDL_Event *event); + HRESULT ReadKey(Common::Event *event); static bool IsShiftDown(); static bool IsControlDown(); @@ -63,7 +63,7 @@ public: virtual char *ScToString(); private: - uint32 KeyCodeToVKey(SDL_Event *event); + uint32 KeyCodeToVKey(Common::Event *event); Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 51e41f01bb..3ed76aefa9 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -33,6 +33,7 @@ THE SOFTWARE. #include "engines/wintermute/scriptables/ScEngine.h" #include "common/str.h" #include "common/textconsole.h" +#include "common/system.h" #include "SDL.h" // TODO remove @@ -179,8 +180,8 @@ int CBPlatform::MessageLoop() { bool done = false; while (!done) { - SDL_Event event; - while (SDL_PollEvent(&event)) { + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { HandleEvent(&event); } @@ -224,12 +225,34 @@ int CBPlatform::MessageLoop() { } ////////////////////////////////////////////////////////////////////////// -void CBPlatform::HandleEvent(SDL_Event *event) { +void CBPlatform::HandleEvent(Common::Event *event) { switch (event->type) { - case SDL_MOUSEBUTTONDOWN: - -#ifdef __IPHONEOS__ + case Common::EVENT_LBUTTONDOWN: + if (Game) { + if (Game->IsLeftDoubleClick()) Game->OnMouseLeftDblClick(); + else Game->OnMouseLeftDown(); + } + break; + case Common::EVENT_RBUTTONDOWN: + if (Game) { + if (Game->IsRightDoubleClick()) Game->OnMouseRightDblClick(); + else Game->OnMouseRightDown(); + } + break; + case Common::EVENT_MBUTTONDOWN: + if (Game) Game->OnMouseMiddleDown(); + break; + case Common::EVENT_LBUTTONUP: + if (Game) Game->OnMouseLeftUp(); + break; + case Common::EVENT_RBUTTONUP: + if (Game) Game->OnMouseRightUp(); + break; + case Common::EVENT_MBUTTONUP: + if (Game) Game->OnMouseMiddleUp(); + break; +/*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); POINT p; @@ -241,39 +264,8 @@ void CBPlatform::HandleEvent(SDL_Event *event) { if (btn->_visible && !btn->_disable) btn->_press = true; } } -#endif - switch (event->button.button) { - case SDL_BUTTON_LEFT: - if (Game) { - if (Game->IsLeftDoubleClick()) Game->OnMouseLeftDblClick(); - else Game->OnMouseLeftDown(); - } - break; - case SDL_BUTTON_RIGHT: - if (Game) { - if (Game->IsRightDoubleClick()) Game->OnMouseRightDblClick(); - else Game->OnMouseRightDown(); - } - break; - case SDL_BUTTON_MIDDLE: - if (Game) Game->OnMouseMiddleDown(); - break; - } - break; +#endif*/ - case SDL_MOUSEBUTTONUP: - switch (event->button.button) { - case SDL_BUTTON_LEFT: - if (Game) Game->OnMouseLeftUp(); - break; - case SDL_BUTTON_RIGHT: - if (Game) Game->OnMouseRightUp(); - break; - case SDL_BUTTON_MIDDLE: - if (Game) Game->OnMouseMiddleUp(); - break; - } - break; //TODO /* case SDL_MOUSEWHEEL: if (Game) Game->HandleMouseWheel(event->wheel.y); @@ -305,7 +297,7 @@ void CBPlatform::HandleEvent(SDL_Event *event) { } break; */ - case SDL_QUIT: + case Common::EVENT_QUIT: #ifdef __IPHONEOS__ if (Game) { Game->AutoSaveOnExit(); diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 029902fab9..788a534983 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -32,6 +32,7 @@ #include "dctypes.h" #include "wintypes.h" +#include "common/events.h" union SDL_Event; @@ -45,7 +46,7 @@ class CBPlatform { public: static int Initialize(CBGame *inGame, int argc, char *argv[]); static int MessageLoop(); - static void HandleEvent(SDL_Event *event); + static void HandleEvent(Common::Event *event); static AnsiString GetSystemFontPath(); static AnsiString GetPlatformName(); diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 2cb79935df..65d61d2641 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -46,6 +46,7 @@ #include "engines/wintermute/scriptables/ScScript.h" #include "engines/wintermute/utils.h" #include "common/util.h" +#include "common/keyboard.h" namespace WinterMute { @@ -685,18 +686,18 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::HandleKeypress(SDL_Event *event) { +bool CUIEdit::HandleKeypress(Common::Event *event) { bool Handled = false; - if (event->type == SDL_KEYDOWN) { - switch (event->key.keysym.sym) { - case SDLK_ESCAPE: - case SDLK_TAB: - case SDLK_RETURN: + if (event->type == Common::EVENT_KEYDOWN) { + switch (event->kbd.keycode) { + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_TAB: + case Common::KEYCODE_RETURN: return false; // ctrl+A - case SDLK_a: + case Common::KEYCODE_a: if (CBKeyboardState::IsControlDown()) { _selStart = 0; _selEnd = strlen(_text); @@ -704,7 +705,7 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { } break; - case SDLK_BACKSPACE: + case Common::KEYCODE_BACKSPACE: if (_selStart == _selEnd) { if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); else DeleteChars(_selStart - 1, _selStart); @@ -715,21 +716,21 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { Handled = true; break; - case SDLK_LEFT: - case SDLK_UP: + case Common::KEYCODE_LEFT: + case Common::KEYCODE_UP: _selEnd--; if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; Handled = true; break; - case SDLK_RIGHT: - case SDLK_DOWN: + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_DOWN: _selEnd++; if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; Handled = true; break; - case SDLK_HOME: + case Common::KEYCODE_HOME: if (Game->_textRTL) { _selEnd = strlen(_text); if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; @@ -740,7 +741,7 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { Handled = true; break; - case SDLK_END: + case Common::KEYCODE_END: if (Game->_textRTL) { _selEnd = 0; if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; @@ -751,7 +752,7 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { Handled = true; break; - case SDLK_DELETE: + case Common::KEYCODE_DELETE: if (_selStart == _selEnd) { if (Game->_textRTL) { DeleteChars(_selStart - 1, _selStart); @@ -764,6 +765,8 @@ bool CUIEdit::HandleKeypress(SDL_Event *event) { _selStart = _selEnd; Handled = true; break; + default: + break; } return Handled; } diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index ccaca4473d..ccc332fd63 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -31,6 +31,7 @@ #include "persistent.h" #include "UIObject.h" +#include "common/events.h" namespace WinterMute { class CBFont; @@ -43,7 +44,7 @@ public: bool _cursorVisible; uint32 _lastBlinkTime; virtual HRESULT Display(int OffsetX, int OffsetY); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; -- cgit v1.2.3 From 4cf1d67140fbcf290a8ad1100ede7717a43e0863 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 00:12:28 +0200 Subject: WINTERMUTE: Remove a few SDL-includes. --- engines/wintermute/BFontTT.cpp | 20 ++++++++++++-------- engines/wintermute/BFontTT.h | 7 ++++--- engines/wintermute/BObject.h | 1 - engines/wintermute/BRenderSDL.cpp | 15 ++++++++------- engines/wintermute/BRenderSDL.h | 1 - engines/wintermute/BSurfaceSDL.cpp | 17 ++++++++++++----- engines/wintermute/BSurfaceSDL.h | 11 +++++------ engines/wintermute/FontGlyphCache.cpp | 3 +++ engines/wintermute/FontGlyphCache.h | 9 +++++---- 9 files changed, 49 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 5e4370d69f..8019429329 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -238,7 +238,8 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex TextLineList::iterator it; - + warning("CBFontTT::RenderTextToTexture - Not ported yet"); +#if 0 //TODO int textHeight = lines.size() * (_maxCharHeight + _ascender); SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); @@ -328,21 +329,24 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex delete wmeSurface; return NULL; } +#endif + return NULL; } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect) { +void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { //SDL_BlitSurface(src, NULL, target, targetRect); - + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 for (int y = 0; y < src->h; y++) { if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - Uint8 *srcBuf = (Uint8 *)src->pixels + y * src->pitch; - Uint8 *tgtBuf = (Uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - Uint32 *srcBuf32 = (Uint32 *)srcBuf; - Uint32 *tgtBuf32 = (Uint32 *)tgtBuf; + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; for (int x = 0; x < src->w; x++) { if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; @@ -350,7 +354,7 @@ void CBFontTT::BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targ tgtBuf32[x + targetRect->x] = srcBuf32[x]; } } - +#endif } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 9dc3de1920..812fc61b2e 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -32,10 +32,11 @@ #include "BFontStorage.h" #include "BFont.h" #include "BSurface.h" +#include "common/rect.h" +#include "graphics/surface.h" #define NUM_CACHED_TEXTS 30 -class SDL_Surface; -class SDL_Rect; + namespace WinterMute { class FontGlyphCache; @@ -150,7 +151,7 @@ private: void CacheGlyph(wchar_t ch); CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void BlitSurface(SDL_Surface *src, SDL_Surface *target, SDL_Rect *targetRect); + void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 43fe719ae2..835d5fe34a 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -30,7 +30,6 @@ #define WINTERMUTE_BOBJECT_H -//#include "SDL.h" #include "BScriptHolder.h" #include "persistent.h" diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index a8e18c74d2..613995124f 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -36,7 +36,6 @@ #include "engines/wintermute/BGame.h" #include "engines/wintermute/BSprite.h" #include "common/system.h" -#include "SDL.h" namespace WinterMute { @@ -147,7 +146,8 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (!_win) return E_FAIL; #endif - SDL_ShowCursor(SDL_DISABLE); + warning("TODO: Hide cursor"); + //SDL_ShowCursor(SDL_DISABLE); #ifdef __IPHONEOS__ // SDL defaults to OGL ES2, which doesn't work on old devices @@ -366,11 +366,12 @@ const char *CBRenderSDL::GetName() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { - SDL_Rect rect; - rect.x = left + _borderLeft; - rect.y = top + _borderTop; - rect.w = (right - left) * _ratioX; - rect.h = (bottom - top) * _ratioY; + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = left + _borderLeft; + rect.top = top + _borderTop; + rect.right = (right - left) * _ratioX; + rect.bottom = (bottom - top) * _ratioY; // TODO fix this once viewports work correctly in SDL/landscape #ifndef __IPHONEOS__ diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 73d3bbac29..2d55a3c003 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -30,7 +30,6 @@ #define WINTERMUTE_BRENDERER_SDL_H #include "BRenderer.h" -/*#include "SDL.h"*/ #include "common/rect.h" #include "graphics/surface.h" diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index b976585b0b..0f30101780 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -181,7 +181,10 @@ HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte } ////////////////////////////////////////////////////////////////////////// -void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { +void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { + warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); + return; +#if 0 delete[] _alphaMask; _alphaMask = NULL; if (!surface) return; @@ -220,13 +223,16 @@ void CBSurfaceSDL::GenAlphaMask(SDL_Surface *surface) { delete[] _alphaMask; _alphaMask = NULL; } +#endif } ////////////////////////////////////////////////////////////////////////// -Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) { +uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { + warning("CBSurfaceSDL::GetPixel - Not ported yet"); +#if 0 int bpp = surface->format->BytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ - Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; switch (bpp) { case 1: @@ -251,6 +257,7 @@ Uint32 CBSurfaceSDL::GetPixel(SDL_Surface *surface, int x, int y) { default: return 0; /* shouldn't happen, but avoids warnings */ } +#endif } ////////////////////////////////////////////////////////////////////////// @@ -271,7 +278,7 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::CreateFromSDLSurface(SDL_Surface *surface) { +HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); @@ -314,7 +321,7 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { //if (!_lockPixels) return false; - Uint32 format; + uint32 format; int access; int width, height; // This particular warning is rather messy, as this function is called a ton, diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index 9053af3d7d..792dd01e6d 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -31,9 +31,8 @@ #include "graphics/surface.h" #include "BSurface.h" -#include "SDL.h" // TODO, remove -class SDL_Texture; -class SDL_Surface; +#include "graphics/surface.h" + namespace WinterMute { class CBSurfaceSDL : public CBSurface { @@ -44,7 +43,7 @@ public: HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); HRESULT Create(int Width, int Height); - HRESULT CreateFromSDLSurface(SDL_Surface *surface); + HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function bool IsTransparentAt(int X, int Y); bool IsTransparentAtLite(int X, int Y); @@ -69,8 +68,8 @@ private: Graphics::Surface *_surface; HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); - void GenAlphaMask(SDL_Surface *surface); - uint32 GetPixel(SDL_Surface *surface, int x, int y); + void GenAlphaMask(Graphics::Surface *surface); + uint32 GetPixel(Graphics::Surface *surface, int x, int y); void *_lockPixels; int _lockPitch; diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index d161c749cf..81ecd49c86 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -71,6 +71,8 @@ void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot ////////////////////////////////////////////////////////////////////////// void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) { + warning("GlyphInfo::SetGlyphImage - Not ported yet"); +#if 0 if (_image) SDL_FreeSurface(_image); _image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); @@ -91,6 +93,7 @@ void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte * } SDL_UnlockSurface(_image); +#endif } } // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 6800ec996b..7fac01e40c 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -27,8 +27,8 @@ THE SOFTWARE. #define __WmeFontGlyphCache_H__ -#include "SDL.h" #include "BFontStorage.h" +#include "graphics/surface.h" namespace WinterMute { @@ -46,7 +46,8 @@ public: } ~GlyphInfo() { - if (_image) SDL_FreeSurface(_image); + // TODO + //if (_image) SDL_FreeSurface(_image); } void SetGlyphInfo(float AdvanceX, float AdvanceY, int BearingX, int BearingY) { @@ -79,7 +80,7 @@ public: int GetBearingY() { return _bearingY; } - SDL_Surface *GetImage() { + Graphics::Surface *GetImage() { return _image; } @@ -94,7 +95,7 @@ private: int _width; int _height; - SDL_Surface *_image; + Graphics::Surface *_image; }; -- cgit v1.2.3 From d2d43da4f07e54c446532b85ba01d4d0f96d707a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 00:40:13 +0200 Subject: WINTERMUTE: Cleanup the includes in Platform SDL This should remove the last SDL-include in-engine --- engines/wintermute/PlatformSDL.cpp | 21 +++++---------------- engines/wintermute/PlatformSDL.h | 5 +---- 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 3ed76aefa9..740a0bfa87 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -35,16 +35,6 @@ THE SOFTWARE. #include "common/textconsole.h" #include "common/system.h" -#include "SDL.h" // TODO remove - -#ifdef __WIN32__ -# include -# include -#else -# include -#endif - - namespace WinterMute { CBGame *CBPlatform::Game = NULL; @@ -313,7 +303,7 @@ void CBPlatform::HandleEvent(Common::Event *event) { } ////////////////////////////////////////////////////////////////////////// -int CBPlatform::SDLEventWatcher(void *userdata, SDL_Event *event) { +int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { //TODO /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { if (Game) Game->AutoSaveOnExit(); @@ -346,17 +336,16 @@ void CBPlatform::OutputDebugString(LPCSTR lpOutputString) { ////////////////////////////////////////////////////////////////////////// uint32 CBPlatform::GetTime() { - return SDL_GetTicks(); + return g_system->getMillis(); } ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); - int x, y; - SDL_GetMouseState(&x, &y); - lpPoint->x = x; - lpPoint->y = y; + Common::Point p = g_system->getEventManager()->getMousePos(); + lpPoint->x = p.x; + lpPoint->y = p.y; renderer->PointFromScreen(lpPoint); diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 788a534983..cfb5b6e930 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -34,13 +34,10 @@ #include "wintypes.h" #include "common/events.h" -union SDL_Event; - namespace WinterMute { class CBGame; - ////////////////////////////////////////////////////////////////////////// class CBPlatform { public: @@ -82,7 +79,7 @@ public: static char *strlwr(char *string); // sdl event callback - static int SDLEventWatcher(void *userdata, SDL_Event *event); + static int SDLEventWatcher(void *userdata, Common::Event *event); private: static CBGame *Game; -- cgit v1.2.3 From 858989a6852c74a565554fafb824a1faacaa706d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 00:42:42 +0200 Subject: WINTERMUTE: Comment out Mac OS X specific code. --- engines/wintermute/BFileManager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 24bc886e9c..427c817fb4 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -50,7 +50,6 @@ #include "common/system.h" #include "common/fs.h" #include "common/file.h" -//#include #ifdef __WIN32__ # include @@ -58,9 +57,9 @@ # include #endif -#ifdef __APPLE__ +/*#ifdef __APPLE__ # include -#endif +#endif*/ #if _DEBUG @@ -316,7 +315,7 @@ HRESULT CBFileManager::InitPaths() { // package files paths AddPath(PATH_PACKAGE, "./"); -#ifdef __APPLE__ +/*#ifdef __APPLE__ // search .app path and Resources dir in the bundle CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); @@ -340,7 +339,7 @@ HRESULT CBFileManager::InitPaths() { CFRelease(appUrlRef); CFRelease(macPath); #endif -#endif +#endif*/ pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); -- cgit v1.2.3 From d4fd90e06479f76df274a80e20387e3c79515e3a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 00:49:04 +0200 Subject: WINTERMUTE: Fix font-related crash. --- engines/wintermute/BFontBitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 3bec9d5a20..71bbf95801 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -166,7 +166,7 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig long_line = true; } - if (str[index + 1] == '\0' || (MaxLenght >= 0 && index == MaxLenght - 1)) { + if (str.size() == (index + 1) || (MaxLenght >= 0 && index == MaxLenght - 1)) { done = true; if (!new_line) { end = index; -- cgit v1.2.3 From ab98efe595b09ca44fc6c9283e7aedcdb4f2dd9a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 01:10:40 +0200 Subject: WINTERMUTE: Make ScEngine use Common::String to avoid some double-frees. --- engines/wintermute/scriptables/ScEngine.cpp | 8 ++++---- engines/wintermute/scriptables/ScEngine.h | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 20716cfd04..0b19542beb 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -271,7 +271,7 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC // is script in cache? if (!IgnoreCache) { for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename, Filename) == 0) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), Filename) == 0) { _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); *OutSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; @@ -667,7 +667,7 @@ HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { CScBreakpoint *Bp = NULL; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { Bp = _breakpoints[i]; break; } @@ -693,7 +693,7 @@ HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { if (!Game->GetDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { if (_breakpoints[i]->_lines[j] == Line) { _breakpoints[i]->_lines.RemoveAt(j); @@ -730,7 +730,7 @@ HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { if (!Script || !Script->_filename) return E_FAIL; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename, Script->_filename) == 0) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), Script->_filename) == 0) { Script->_breakpoints.Copy(_breakpoints[i]->_lines); return S_OK; } diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 7be147b39e..7ca9ec0771 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -62,34 +62,30 @@ public: _buffer = new byte[Size]; if (_buffer) memcpy(_buffer, Buffer, Size); _size = Size; - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); + _filename = Filename; }; ~CScCachedScript() { if (_buffer) delete [] _buffer; - if (_filename) delete [] _filename; }; uint32 _timestamp; byte *_buffer; uint32 _size; - char *_filename; + Common::String _filename; }; class CScBreakpoint { public: CScBreakpoint(const char *Filename) { - _filename = NULL; - CBUtils::SetString(&_filename, Filename); + _filename = Filename; } ~CScBreakpoint() { - if (_filename) delete [] _filename; _lines.RemoveAll(); } - char *_filename; + Common::String _filename; CBArray _lines; }; -- cgit v1.2.3 From ffffd68f195963a2d55f12bdecd6e05699669c38 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 01:11:05 +0200 Subject: WINTERMUTE: Make CBSoundBuffer initialize it's SoundHandle. --- engines/wintermute/BSoundBuffer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index a58f39c869..e045d4d769 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -49,6 +49,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { _stream = NULL; + _handle = new Audio::SoundHandle; // _sync = NULL; _streamed = false; -- cgit v1.2.3 From 7339ca988f65cad90a6d0a22e93e1925e4384c35 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 01:32:23 +0200 Subject: WINTERMUTE: Fix StringUtil::EndsWith --- engines/wintermute/StringUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index 746250ceeb..8ef6c55e88 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -252,9 +252,9 @@ bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool if (strLength < patternLength || patternLength == 0) return false; - Common::String endPart(str.c_str(), strLength - patternLength); + Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); - return (likeness == 0); + return (likeness != 0); } } -- cgit v1.2.3 From 6acc470bc6682f4705248b8ace86c3c7ca96f03c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 01:49:37 +0200 Subject: WINTERMUTE: Disable fonts, and remove FreeType2. --- engines/wintermute/BFontStorage.cpp | 8 +++++--- engines/wintermute/BFontStorage.h | 10 +++++----- engines/wintermute/BFontTT.cpp | 28 +++++++++++++++++----------- engines/wintermute/BFontTT.h | 8 ++++---- engines/wintermute/FontGlyphCache.cpp | 4 ++-- engines/wintermute/FontGlyphCache.h | 2 +- 6 files changed, 34 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp index 1ceb77cb1c..61b5e58805 100644 --- a/engines/wintermute/BFontStorage.cpp +++ b/engines/wintermute/BFontStorage.cpp @@ -43,7 +43,7 @@ IMPLEMENT_PERSISTENT(CBFontStorage, true) ////////////////////////////////////////////////////////////////////////// CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { - _fTLibrary = NULL; +// _fTLibrary = NULL; InitFreeType(); } @@ -56,10 +56,12 @@ CBFontStorage::~CBFontStorage() { ////////////////////////////////////////////////////////////////////////// void CBFontStorage::InitFreeType() { +#if 0 FT_Error error = FT_Init_FreeType(&_fTLibrary); if (error) { Game->LOG(0, "Error initializing FreeType library."); } +#endif } ////////////////////////////////////////////////////////////////////////// @@ -72,9 +74,9 @@ HRESULT CBFontStorage::Cleanup(bool Warn) { } _fonts.RemoveAll(); - +#if 0 if (_fTLibrary) FT_Done_FreeType(_fTLibrary); - +#endif return S_OK; } diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h index 010d0a83c2..25e1b345d2 100644 --- a/engines/wintermute/BFontStorage.h +++ b/engines/wintermute/BFontStorage.h @@ -34,8 +34,8 @@ #include "persistent.h" #include "coll_templ.h" -#include -#include FT_FREETYPE_H +/*#include +#include FT_FREETYPE_H*/ namespace WinterMute { @@ -52,13 +52,13 @@ public: CBArray _fonts; HRESULT InitLoop(); - FT_Library GetFTLibrary() const { +/* FT_Library GetFTLibrary() const { return _fTLibrary; - } + }*/ private: void InitFreeType(); - FT_Library _fTLibrary; + //FT_Library _fTLibrary; }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 8019429329..f2971efc52 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#include -#include FT_FREETYPE_H +//#include +//#include FT_FREETYPE_H #include "dcgf.h" #include "BFile.h" #include "BFontTT.h" @@ -56,10 +56,10 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - +#if 0 _fTFace = NULL; _fTStream = NULL; - +#endif _glyphCache = NULL; _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; @@ -81,14 +81,14 @@ CBFontTT::~CBFontTT(void) { delete _glyphCache; _glyphCache = NULL; - +#if 0 if (_fTFace) { FT_Done_Face(_fTFace); _fTFace = NULL; } delete[] _fTStream; _fTStream = NULL; - +#endif } @@ -596,7 +596,8 @@ void CBFontTT::AfterLoad() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; - + warning("BFontTT::InitFont - Not ported yet"); + return E_FAIL; CBFile *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font @@ -608,7 +609,7 @@ HRESULT CBFontTT::InitFont() { return E_FAIL; } } - +#if 0 FT_Error error; float vertDpi = 96.0; @@ -665,7 +666,7 @@ HRESULT CBFontTT::InitFont() { _glyphCache = new FontGlyphCache(); _glyphCache->Initialize(); - +#endif return S_OK; } @@ -673,6 +674,7 @@ HRESULT CBFontTT::InitFont() { ////////////////////////////////////////////////////////////////////////// // I/O bridge between FreeType and WME file system ////////////////////////////////////////////////////////////////////////// +/* unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { CBFile *f = static_cast(stream->descriptor.pointer); if (!f) return 0; @@ -694,7 +696,7 @@ void CBFontTT::FTCloseProc(FT_Stream stream) { Game->_fileManager->CloseFile(f); stream->descriptor.pointer = NULL; -} +}*/ @@ -800,7 +802,7 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); - +#if 0 if (!infoLeft || !infoRight) return 0; FT_Vector delta; @@ -808,6 +810,8 @@ float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { if (error) return 0; return delta.x * (1.0f / 64.0f); +#endif + return 0; } @@ -822,6 +826,7 @@ void CBFontTT::PrepareGlyphs(const WideString &text) { ////////////////////////////////////////////////////////////////////////// void CBFontTT::CacheGlyph(wchar_t ch) { +#if 0 FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); if (!glyphIndex) return; @@ -857,6 +862,7 @@ void CBFontTT::CacheGlyph(wchar_t ch) { _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); if (tempBuffer) delete [] tempBuffer; +#endif } } // end of namespace WinterMute diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 812fc61b2e..5690947465 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -127,8 +127,8 @@ public: HRESULT LoadBuffer(byte *Buffer); HRESULT LoadFile(char *Filename); - static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); - static void FTCloseProc(FT_Stream stream); +/* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); + static void FTCloseProc(FT_Stream stream);*/ FontGlyphCache *GetGlyphCache() { return _glyphCache; @@ -157,8 +157,8 @@ private: CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; HRESULT InitFont(); - FT_Stream _fTStream; - FT_Face _fTFace; + //FT_Stream _fTStream; + //FT_Face _fTFace; FontGlyphCache *_glyphCache; diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index 81ecd49c86..d2ac984b29 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -58,7 +58,7 @@ GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { return it->_value; } - +/* ////////////////////////////////////////////////////////////////////////// void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) { if (stride == 0) stride = width; @@ -67,7 +67,7 @@ void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot _glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); _glyphs[ch]->SetGlyphImage(width, height, stride, pixels); } - +*/ ////////////////////////////////////////////////////////////////////////// void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) { diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 7fac01e40c..0a42748107 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -109,7 +109,7 @@ public: void Initialize(); bool HasGlyph(wchar_t ch); GlyphInfo *GetGlyph(wchar_t ch); - void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0); + //void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0); private: //typedef Common::HashMap GlyphInfoMap; -- cgit v1.2.3 From 26226afc5a546fd45362e402fa035880032963fc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 02:03:07 +0200 Subject: WINTERMUTE: Fix a few warnings in BRenderSDL.h --- engines/wintermute/BRenderSDL.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 2d55a3c003..573c4368c4 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -57,13 +57,6 @@ public: HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); CBImage *TakeScreenshot(); - - SDL_Renderer *GetSdlRenderer() const { -// return _renderer; - } - SDL_Window *GetSdlWindow() const { -// return _win; - } void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); -- cgit v1.2.3 From 6faf92bfda160e037163fe4f6e6dd37d740ba809 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 02:05:13 +0200 Subject: WINTERMUTE: Fix a few swtich-related warnings in PlatformSDL. --- engines/wintermute/PlatformSDL.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 740a0bfa87..2837e16be6 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -298,6 +298,9 @@ void CBPlatform::HandleEvent(Common::Event *event) { #endif break; + default: + // TODO: Do we care about any other events? + break; } } -- cgit v1.2.3 From 076cd93d213f7ecb9a3f42165f6805826c544e96 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 02:20:52 +0200 Subject: WINTERMUTE: Preliminary fontwork. --- engines/wintermute/BFontTT.cpp | 37 ++++++++++++++++++++++++++++--------- engines/wintermute/BFontTT.h | 4 +++- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index f2971efc52..458325e3d1 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -42,6 +42,8 @@ #include "BFileManager.h" #include "utils.h" #include "PlatformSDL.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" namespace WinterMute { @@ -53,6 +55,8 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { _isBold = _isItalic = _isUnderline = _isStriked = false; _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; @@ -79,6 +83,12 @@ CBFontTT::~CBFontTT(void) { delete[] _fontFile; _fontFile = NULL; + delete _font; + _font = NULL; + + delete _fallbackFont; + _fallbackFont = NULL; + delete _glyphCache; _glyphCache = NULL; #if 0 @@ -121,8 +131,8 @@ void CBFontTT::InitLoop() { int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { WideString text; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); +/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -138,8 +148,8 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { int CBFontTT::GetTextHeight(byte *Text, int Width) { WideString text; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); +/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ int textWidth, textHeight; @@ -151,12 +161,14 @@ int CBFontTT::GetTextHeight(byte *Text, int Width) { ////////////////////////////////////////////////////////////////////////// void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { + warning("Draw text: %s", Text); if (Text == NULL || strcmp((char *)Text, "") == 0) return; WideString text; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); + // TODO: Why do we still insist on Widestrings everywhere? +/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -597,18 +609,25 @@ void CBFontTT::AfterLoad() { HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; warning("BFontTT::InitFont - Not ported yet"); - return E_FAIL; + CBFile *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); file = Game->_fileManager->OpenFile((char *)fontFileName.c_str(), false); - if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); - return E_FAIL; + //return E_FAIL; } } + warning("I guess we got a file"); + if (file) { + _font = Graphics::loadTTFFont(*file->getMemStream(), 12); + } else { + _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + return S_OK; #if 0 FT_Error error; diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 5690947465..6994ea3c8f 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -34,6 +34,7 @@ #include "BSurface.h" #include "common/rect.h" #include "graphics/surface.h" +#include "graphics/font.h" #define NUM_CACHED_TEXTS 30 @@ -159,7 +160,8 @@ private: HRESULT InitFont(); //FT_Stream _fTStream; //FT_Face _fTFace; - + Graphics::Font *_font; + const Graphics::Font *_fallbackFont; FontGlyphCache *_glyphCache; float _ascender; -- cgit v1.2.3 From 7bd6151127e072f4f270a62654398db74dc7085c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 07:34:34 +0200 Subject: WINTERMUTE: Add empty virtual destructors to the Debugger-classes, to silence a few warnings. --- engines/wintermute/wme_debugger.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h index 6774ab0768..0f084be75e 100644 --- a/engines/wintermute/wme_debugger.h +++ b/engines/wintermute/wme_debugger.h @@ -64,6 +64,7 @@ EWmeDebuggerVariableType; ////////////////////////////////////////////////////////////////////////// class IWmeDebugScript { public: + virtual ~IWmeDebugScript() {} virtual int DbgGetLine() = 0; virtual const char *DbgGetFilename() = 0; virtual TScriptState DbgGetState() = 0; @@ -80,6 +81,7 @@ class IWmeDebugProp { public: virtual EWmeDebuggerPropType DbgGetType() = 0; + virtual ~IWmeDebugProp() {} // getters virtual int DbgGetValInt() = 0; virtual double DbgGetValFloat() = 0; @@ -104,6 +106,7 @@ public: ////////////////////////////////////////////////////////////////////////// class IWmeDebugObject { public: + virtual ~IWmeDebugObject() {} virtual const char *DbgGetNativeClass() = 0; virtual IWmeDebugProp *DbgGetProperty(const char *Name) = 0; }; @@ -111,6 +114,7 @@ public: ////////////////////////////////////////////////////////////////////////// class IWmeDebugClient { public: + virtual ~IWmeDebugClient() {} virtual bool OnGameInit() = 0; virtual bool OnGameShutdown() = 0; @@ -135,6 +139,7 @@ public: ////////////////////////////////////////////////////////////////////////// class IWmeDebugServer { public: + virtual ~IWmeDebugServer() {} virtual bool AttachClient(IWmeDebugClient *Client) = 0; virtual bool DetachClient(IWmeDebugClient *Client) = 0; -- cgit v1.2.3 From 61945782d6a73967d122f38a4f97f9b7377abdea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 14:16:50 +0200 Subject: WINTERMUTE: Add const to almost all char *Filename instances. Although done semi-automatically, almost all of these accesses don't need write-access to the string, this simplifies debugging a bit, and opens the possibility of adding in Common::String as a replacement down the line. This DOES change quite a bit of code, and has regressions wrt drawing, probably some super-classes don't fully match their sub-classes wrt virtual functions any more. --- engines/wintermute/AdActor.cpp | 12 +++---- engines/wintermute/AdActor.h | 8 ++--- engines/wintermute/AdEntity.cpp | 6 ++-- engines/wintermute/AdEntity.h | 6 ++-- engines/wintermute/AdGame.cpp | 38 ++++++++++----------- engines/wintermute/AdGame.h | 12 +++---- engines/wintermute/AdInventory.cpp | 4 +-- engines/wintermute/AdInventory.h | 4 +-- engines/wintermute/AdInventoryBox.cpp | 2 +- engines/wintermute/AdInventoryBox.h | 2 +- engines/wintermute/AdItem.cpp | 8 ++--- engines/wintermute/AdItem.h | 2 +- engines/wintermute/AdLayer.cpp | 2 +- engines/wintermute/AdLayer.h | 2 +- engines/wintermute/AdNodeState.cpp | 4 +-- engines/wintermute/AdNodeState.h | 4 +-- engines/wintermute/AdObject.cpp | 26 +++++++-------- engines/wintermute/AdObject.h | 6 ++-- engines/wintermute/AdRegion.cpp | 2 +- engines/wintermute/AdRegion.h | 2 +- engines/wintermute/AdResponse.cpp | 10 +++--- engines/wintermute/AdResponse.h | 10 +++--- engines/wintermute/AdResponseBox.cpp | 2 +- engines/wintermute/AdResponseBox.h | 2 +- engines/wintermute/AdRotLevel.cpp | 2 +- engines/wintermute/AdRotLevel.h | 2 +- engines/wintermute/AdScaleLevel.cpp | 2 +- engines/wintermute/AdScaleLevel.h | 2 +- engines/wintermute/AdScene.cpp | 12 +++---- engines/wintermute/AdScene.h | 6 ++-- engines/wintermute/AdSceneState.cpp | 2 +- engines/wintermute/AdSceneState.h | 2 +- engines/wintermute/AdSentence.cpp | 6 ++-- engines/wintermute/AdSentence.h | 6 ++-- engines/wintermute/AdSpriteSet.cpp | 2 +- engines/wintermute/AdSpriteSet.h | 2 +- engines/wintermute/AdTalkHolder.cpp | 8 ++--- engines/wintermute/AdWaypointGroup.cpp | 2 +- engines/wintermute/AdWaypointGroup.h | 2 +- engines/wintermute/BEvent.cpp | 2 +- engines/wintermute/BEvent.h | 2 +- engines/wintermute/BFileManager.cpp | 2 +- engines/wintermute/BFileManager.h | 2 +- engines/wintermute/BFont.cpp | 6 ++-- engines/wintermute/BFont.h | 6 ++-- engines/wintermute/BFontBitmap.cpp | 2 +- engines/wintermute/BFontBitmap.h | 2 +- engines/wintermute/BFontStorage.cpp | 2 +- engines/wintermute/BFontStorage.h | 2 +- engines/wintermute/BFontTT.cpp | 2 +- engines/wintermute/BFontTT.h | 2 +- engines/wintermute/BFrame.cpp | 8 ++--- engines/wintermute/BFrame.h | 2 +- engines/wintermute/BGame.cpp | 46 +++++++++++++------------- engines/wintermute/BGame.h | 10 +++--- engines/wintermute/BImage.cpp | 2 +- engines/wintermute/BImage.h | 2 +- engines/wintermute/BKeyboardState.cpp | 7 ++-- engines/wintermute/BNamedObject.cpp | 2 +- engines/wintermute/BNamedObject.h | 2 +- engines/wintermute/BObject.cpp | 18 +++++----- engines/wintermute/BObject.h | 10 +++--- engines/wintermute/BPersistMgr.cpp | 4 +-- engines/wintermute/BPersistMgr.h | 4 +-- engines/wintermute/BQuickMsg.cpp | 2 +- engines/wintermute/BQuickMsg.h | 2 +- engines/wintermute/BRegion.cpp | 2 +- engines/wintermute/BRegion.h | 2 +- engines/wintermute/BRenderSDL.cpp | 2 +- engines/wintermute/BRenderSDL.h | 2 +- engines/wintermute/BRenderer.h | 2 +- engines/wintermute/BScriptHolder.cpp | 12 +++---- engines/wintermute/BScriptHolder.h | 8 ++--- engines/wintermute/BScriptable.cpp | 4 +-- engines/wintermute/BScriptable.h | 4 +-- engines/wintermute/BSound.cpp | 2 +- engines/wintermute/BSound.h | 2 +- engines/wintermute/BSprite.cpp | 6 ++-- engines/wintermute/BSprite.h | 2 +- engines/wintermute/BStringTable.cpp | 2 +- engines/wintermute/BStringTable.h | 2 +- engines/wintermute/BSubFrame.cpp | 4 +-- engines/wintermute/BSubFrame.h | 2 +- engines/wintermute/BSurface.cpp | 2 +- engines/wintermute/BSurface.h | 2 +- engines/wintermute/BSurfaceSDL.cpp | 2 +- engines/wintermute/BSurfaceSDL.h | 2 +- engines/wintermute/BSurfaceStorage.cpp | 2 +- engines/wintermute/BSurfaceStorage.h | 2 +- engines/wintermute/PartEmitter.cpp | 20 +++++------ engines/wintermute/PartEmitter.h | 10 +++--- engines/wintermute/PartParticle.cpp | 2 +- engines/wintermute/PartParticle.h | 2 +- engines/wintermute/UIButton.cpp | 10 +++--- engines/wintermute/UIButton.h | 2 +- engines/wintermute/UIEdit.cpp | 4 +-- engines/wintermute/UIEdit.h | 4 +-- engines/wintermute/UIEntity.cpp | 6 ++-- engines/wintermute/UIEntity.h | 4 +-- engines/wintermute/UIObject.cpp | 4 +-- engines/wintermute/UIText.cpp | 2 +- engines/wintermute/UIText.h | 2 +- engines/wintermute/UITiledImage.cpp | 2 +- engines/wintermute/UITiledImage.h | 2 +- engines/wintermute/UIWindow.cpp | 4 +-- engines/wintermute/UIWindow.h | 2 +- engines/wintermute/scriptables/SXFile.cpp | 8 ++--- engines/wintermute/scriptables/SXMemBuffer.cpp | 2 +- engines/wintermute/scriptables/SXStore.cpp | 10 +++--- engines/wintermute/scriptables/SXString.cpp | 2 +- engines/wintermute/scriptables/ScEngine.cpp | 13 +++++--- engines/wintermute/scriptables/ScEngine.h | 8 ++--- engines/wintermute/scriptables/ScScript.cpp | 16 ++++----- engines/wintermute/scriptables/ScScript.h | 6 ++-- engines/wintermute/scriptables/ScValue.cpp | 11 +++--- engines/wintermute/scriptables/ScValue.h | 6 ++-- engines/wintermute/utils.cpp | 5 ++- engines/wintermute/utils.h | 4 +-- 118 files changed, 318 insertions(+), 314 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index 2c945573ec..f7203e7d3b 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -145,7 +145,7 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::LoadFile(char *Filename) { +HRESULT CAdActor::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); @@ -957,7 +957,7 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "UnloadAnim") == 0) { Stack->CorrectParams(1); - char *AnimName = Stack->Pop()->GetString(); + const char *AnimName = Stack->Pop()->GetString(); bool Found = false; for (int i = 0; i < _anims.GetSize(); i++) { @@ -983,7 +983,7 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HasAnim") == 0) { Stack->CorrectParams(1); - char *AnimName = Stack->Pop()->GetString(); + const char *AnimName = Stack->Pop()->GetString(); Stack->PushBool(GetAnimByName(AnimName) != NULL); return S_OK; } @@ -1273,7 +1273,7 @@ int CAdActor::GetHeight() { ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::GetAnimByName(char *AnimName) { +CAdSpriteSet *CAdActor::GetAnimByName(const char *AnimName) { if (!AnimName) return NULL; for (int i = 0; i < _anims.GetSize(); i++) { @@ -1283,7 +1283,7 @@ CAdSpriteSet *CAdActor::GetAnimByName(char *AnimName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::MergeAnims(char *AnimsFilename) { +HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END @@ -1319,7 +1319,7 @@ HRESULT CAdActor::MergeAnims(char *AnimsFilename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::PlayAnim(char *Filename) { +HRESULT CAdActor::PlayAnim(const char *Filename) { // if we have an anim with this name, use it CAdSpriteSet *Anim = GetAnimByName(Filename); if (Anim) { diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index 1e6b21884d..85b54060c9 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -67,7 +67,7 @@ public: TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // new anim system @@ -77,8 +77,8 @@ public: char *_turnLeftAnimName; char *_turnRightAnimName; CBArray _anims; - virtual HRESULT PlayAnim(char *Filename); - CAdSpriteSet *GetAnimByName(char *AnimName); + virtual HRESULT PlayAnim(const char *Filename); + CAdSpriteSet *GetAnimByName(const char *AnimName); // scripting interface virtual CScValue *ScGetProperty(char *Name); @@ -89,7 +89,7 @@ public: private: HRESULT SetDefaultAnimNames(); CBSprite *GetTalkStanceOld(char *Stance); - HRESULT MergeAnims(char *AnimsFilename); + HRESULT MergeAnims(const char *AnimsFilename); CBSprite *_animSprite2; void InitLine(CBPoint StartPt, CBPoint EndPt); diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index a67cc2109a..1566ad8bbd 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -78,7 +78,7 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::LoadFile(char *Filename) { +HRESULT CAdEntity::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); @@ -934,12 +934,12 @@ HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdEntity::SetItem(char *ItemName) { +void CAdEntity::SetItem(const char *ItemName) { CBUtils::SetString(&_item, ItemName); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::SetSprite(char *Filename) { +HRESULT CAdEntity::SetSprite(const char *Filename) { bool SetCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h index 1677d3e097..1ee0e75fe4 100644 --- a/engines/wintermute/AdEntity.h +++ b/engines/wintermute/AdEntity.h @@ -35,11 +35,11 @@ namespace WinterMute { class CAdEntity : public CAdTalkHolder { public: - HRESULT SetSprite(char *Filename); + HRESULT SetSprite(const char *Filename); int _walkToX; int _walkToY; TDirection _walkToDir; - void SetItem(char *ItemName); + void SetItem(const char *ItemName); char *_item; DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) void UpdatePosition(); @@ -50,7 +50,7 @@ public: virtual HRESULT Display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); TEntityType _subtype; diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index e736ddc0e0..cce3d5950b 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -240,7 +240,7 @@ HRESULT CAdGame::RemoveObject(CAdObject *Object) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ChangeScene(char *Filename, bool FadeIn) { +HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { if (_scene == NULL) { _scene = new CAdScene(Game); RegisterObject(_scene); @@ -319,7 +319,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "ChangeScene") == 0) { Stack->CorrectParams(3); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); CScValue *valFadeOut = Stack->Pop(); CScValue *valFadeIn = Stack->Pop(); @@ -461,7 +461,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "AddResponse") == 0 || strcmp(Name, "AddResponseOnce") == 0 || strcmp(Name, "AddResponseOnceGame") == 0) { Stack->CorrectParams(6); int id = Stack->Pop()->GetInt(); - char *text = Stack->Pop()->GetString(); + const char *text = Stack->Pop()->GetString(); CScValue *val1 = Stack->Pop(); CScValue *val2 = Stack->Pop(); CScValue *val3 = Stack->Pop(); @@ -571,17 +571,13 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "StartDlgBranch") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - char *BranchName = NULL; - bool DeleteName = false; + Common::String BranchName; if (Val->IsNULL()) { - BranchName = new char[20]; - sprintf(BranchName, "line%d", Script->_currentLine); - DeleteName = true; + BranchName.format("line%d", Script->_currentLine); } else BranchName = Val->GetString(); - StartDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); + StartDlgBranch(BranchName.c_str(), Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); Stack->PushNULL(); - if (DeleteName) delete[] BranchName; return S_OK; } @@ -592,7 +588,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "EndDlgBranch") == 0) { Stack->CorrectParams(1); - char *BranchName = NULL; + const char *BranchName = NULL; CScValue *Val = Stack->Pop(); if (!Val->IsNULL()) BranchName = Val->GetString(); EndDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); @@ -701,7 +697,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadResponseBox") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); Game->UnregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); @@ -720,7 +716,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadInventoryBox") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); Game->UnregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); @@ -740,7 +736,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadItems") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool Merge = Stack->Pop()->GetBool(false); HRESULT Ret = LoadItemsFile(Filename, Merge); @@ -754,7 +750,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddSpeechDir") == 0) { Stack->CorrectParams(1); - char *Dir = Stack->Pop()->GetString(); + const char *Dir = Stack->Pop()->GetString(); Stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); return S_OK; @@ -765,7 +761,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveSpeechDir") == 0) { Stack->CorrectParams(1); - char *Dir = Stack->Pop()->GetString(); + const char *Dir = Stack->Pop()->GetString(); Stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); return S_OK; @@ -1314,7 +1310,7 @@ HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadGame(char *Filename) { +HRESULT CAdGame::LoadGame(const char *Filename) { HRESULT ret = CBGame::LoadGame(Filename); if (SUCCEEDED(ret)) CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CAdRegion", NULL); return ret; @@ -1356,7 +1352,7 @@ void CAdGame::SetPrevSceneFilename(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScheduleChangeScene(char *Filename, bool FadeIn) { +HRESULT CAdGame::ScheduleChangeScene(const char *Filename, bool FadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; @@ -1384,7 +1380,7 @@ HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byt ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadItemsFile(char *Filename, bool Merge) { +HRESULT CAdGame::LoadItemsFile(const char *Filename, bool Merge) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); @@ -1776,7 +1772,7 @@ bool CAdGame::IsItemTaken(char *ItemName) { } ////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::GetItemByName(char *Name) { +CAdItem *CAdGame::GetItemByName(const char *Name) { for (int i = 0; i < _items.GetSize(); i++) { if (scumm_stricmp(_items[i]->_name, Name) == 0) return _items[i]; } @@ -1875,7 +1871,7 @@ HRESULT CAdGame::AddSpeechDir(const char *Dir) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RemoveSpeechDir(char *Dir) { +HRESULT CAdGame::RemoveSpeechDir(const char *Dir) { if (!Dir || Dir[0] == '\0') return E_FAIL; char *Temp = new char[strlen(Dir) + 2]; diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index fd943f6fcf..1558a2ad0e 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -62,7 +62,7 @@ public: CBArray _speechDirs; HRESULT AddSpeechDir(const char *Dir); - HRESULT RemoveSpeechDir(char *Dir); + HRESULT RemoveSpeechDir(const char *Dir); char *FindSpeechFile(char *StringID); HRESULT DeleteItem(CAdItem *Item); @@ -70,7 +70,7 @@ public: bool _tempDisableSaveState; virtual HRESULT ResetContent(); HRESULT AddItem(CAdItem *Item); - CAdItem *GetItemByName(char *Name); + CAdItem *GetItemByName(const char *Name); CBArray _items; CAdObject *_inventoryOwner; bool IsItemTaken(char *ItemName); @@ -105,14 +105,14 @@ public: TTalkSkipButton _talkSkipButton; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - HRESULT ScheduleChangeScene(char *Filename, bool FadeIn); + HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); char *_scheduledScene; bool _scheduledFadeIn; void SetPrevSceneName(char *Name); void SetPrevSceneFilename(char *Name); char *_prevSceneName; char *_prevSceneFilename; - virtual HRESULT LoadGame(char *Filename); + virtual HRESULT LoadGame(const char *Filename); CAdItem *_selectedItem; HRESULT Cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) @@ -124,7 +124,7 @@ public: CAdInventoryBox *_inventoryBox; HRESULT DisplaySentences(bool Frozen); void AddSentence(CAdSentence *Sentence); - HRESULT ChangeScene(char *Filename, bool FadeIn); + HRESULT ChangeScene(const char *Filename, bool FadeIn); HRESULT RemoveObject(CAdObject *Object); HRESULT AddObject(CAdObject *Object); CAdScene *_scene; @@ -143,7 +143,7 @@ public: virtual HRESULT LoadFile(const char *Filename); virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - HRESULT LoadItemsFile(char *Filename, bool Merge = false); + HRESULT LoadItemsFile(const char *Filename, bool Merge = false); HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp index a7024523a8..735b9a542e 100644 --- a/engines/wintermute/AdInventory.cpp +++ b/engines/wintermute/AdInventory.cpp @@ -49,7 +49,7 @@ CAdInventory::~CAdInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::InsertItem(char *Name, char *InsertAfter) { +HRESULT CAdInventory::InsertItem(const char *Name, const char *InsertAfter) { if (Name == NULL) return E_FAIL; CAdItem *item = ((CAdGame *)Game)->GetItemByName(Name); @@ -74,7 +74,7 @@ HRESULT CAdInventory::InsertItem(char *Name, char *InsertAfter) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(char *Name) { +HRESULT CAdInventory::RemoveItem(const char *Name) { if (Name == NULL) return E_FAIL; for (int i = 0; i < _takenItems.GetSize(); i++) { diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h index 159886aa2f..2012054217 100644 --- a/engines/wintermute/AdInventory.h +++ b/engines/wintermute/AdInventory.h @@ -38,9 +38,9 @@ class CAdItem; class CAdInventory : public CBObject { public: DECLARE_PERSISTENT(CAdInventory, CBObject) - HRESULT RemoveItem(char *Name); + HRESULT RemoveItem(const char *Name); HRESULT RemoveItem(CAdItem *Item); - HRESULT InsertItem(char *Name, char *InsertAfter = NULL); + HRESULT InsertItem(const char *Name, const char *InsertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); CBArray _takenItems; diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index 5ab011c5dc..6c093941bf 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -152,7 +152,7 @@ HRESULT CAdInventoryBox::Display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::LoadFile(char *Filename) { +HRESULT CAdInventoryBox::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h index 724a6298f4..3606e96123 100644 --- a/engines/wintermute/AdInventoryBox.h +++ b/engines/wintermute/AdInventoryBox.h @@ -53,7 +53,7 @@ public: CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index d4746015d8..82cdb5e349 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -84,7 +84,7 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::LoadFile(char *Filename) { +HRESULT CAdItem::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); @@ -438,7 +438,7 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool SetCurrent = false; if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); delete _spriteHover; _spriteHover = NULL; @@ -481,7 +481,7 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "SetNormalCursor") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); delete _cursorNormal; _cursorNormal = NULL; @@ -524,7 +524,7 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "SetHoverCursor") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); delete _cursorHover; _cursorHover = NULL; diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index c5144eff12..46993d935f 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -55,7 +55,7 @@ public: CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // scripting interface diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index ea87cd3727..744e278115 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -61,7 +61,7 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::LoadFile(char *Filename) { +HRESULT CAdLayer::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index ad24759fa9..48b9cfdc27 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -42,7 +42,7 @@ public: CAdLayer(CBGame *inGame); virtual ~CAdLayer(); CBArray _nodes; - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp index 5df3aa8b17..f3cdb6cc4d 100644 --- a/engines/wintermute/AdNodeState.cpp +++ b/engines/wintermute/AdNodeState.cpp @@ -76,7 +76,7 @@ void CAdNodeState::SetName(char *Name) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetFilename(char *Filename) { +void CAdNodeState::SetFilename(const char *Filename) { delete[] _filename; _filename = NULL; CBUtils::SetString(&_filename, Filename); @@ -84,7 +84,7 @@ void CAdNodeState::SetFilename(char *Filename) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCursor(char *Filename) { +void CAdNodeState::SetCursor(const char *Filename) { delete[] _cursor; _cursor = NULL; CBUtils::SetString(&_cursor, Filename); diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h index 4c5b87fb89..7c959e3168 100644 --- a/engines/wintermute/AdNodeState.h +++ b/engines/wintermute/AdNodeState.h @@ -37,8 +37,8 @@ class CAdNodeState : public CBBase { public: HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); void SetName(char *Name); - void SetFilename(char *Filename); - void SetCursor(char *Filename); + void SetFilename(const char *Filename); + void SetCursor(const char *Filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) CAdNodeState(CBGame *inGame); virtual ~CAdNodeState(); diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 95b48b8401..38c3336eae 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -145,7 +145,7 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::PlayAnim(char *Filename) { +HRESULT CAdObject::PlayAnim(const char *Filename) { SAFE_DELETE(_animSprite); _animSprite = new CBSprite(Game, this); if (!_animSprite) { @@ -232,7 +232,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ForceTalkAnim") == 0) { Stack->CorrectParams(1); - char *AnimName = Stack->Pop()->GetString(); + const char *AnimName = Stack->Pop()->GetString(); SAFE_DELETE_ARRAY(_forcedTalkAnimName); _forcedTalkAnimName = new char[strlen(AnimName) + 1]; strcpy(_forcedTalkAnimName, AnimName); @@ -248,12 +248,12 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "Talk") == 0 || strcmp(Name, "TalkAsync") == 0) { Stack->CorrectParams(5); - char *Text = Stack->Pop()->GetString(); + const char *Text = Stack->Pop()->GetString(); CScValue *SoundVal = Stack->Pop(); int Duration = Stack->Pop()->GetInt(); CScValue *ValStances = Stack->Pop(); - char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); + const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); int Align; CScValue *val = Stack->Pop(); @@ -262,7 +262,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); - char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); + const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); Talk(Text, Sound, Duration, Stances, (TTextAlign)Align); if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); @@ -286,7 +286,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th _stickRegion = NULL; RegFound = true; } else if (Val->IsString()) { - char *RegionName = Val->GetString(); + const char *RegionName = Val->GetString(); for (i = 0; i < Main->_nodes.GetSize(); i++) { if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { _stickRegion = Main->_nodes[i]->_region; @@ -349,9 +349,9 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *val = Stack->Pop(); if (!val->IsNULL()) { - char *ItemName = val->GetString(); + const char *ItemName = val->GetString(); val = Stack->Pop(); - char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); + const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities @@ -475,7 +475,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddAttachment") == 0) { Stack->CorrectParams(4); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool PreDisplay = Stack->Pop()->GetBool(true); int OffsetX = Stack->Pop()->GetInt(); int OffsetY = Stack->Pop()->GetInt(); @@ -528,7 +528,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } } } else { - char *Name = Val->GetString(); + const char *Name = Val->GetString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { Found = true; @@ -571,7 +571,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CurrIndex++; } } else { - char *Name = Val->GetString(); + const char *Name = Val->GetString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { Ret = _attachmentsPre[i]; @@ -783,7 +783,7 @@ char *CAdObject::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SetFont(char *Filename) { +HRESULT CAdObject::SetFont(const char *Filename) { if (_font) Game->_fontStorage->RemoveFont(_font); if (Filename) { _font = Game->_fontStorage->AddFont(Filename); @@ -815,7 +815,7 @@ int CAdObject::GetHeight() { ////////////////////////////////////////////////////////////////////////// -void CAdObject::Talk(char *Text, char *Sound, uint32 Duration, char *Stances, TTextAlign Align) { +void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { if (!_sentence) _sentence = new CAdSentence(Game); if (!_sentence) return; diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index 7e0e277edb..f229fb7653 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -69,15 +69,15 @@ public: virtual HRESULT UpdateSounds(); HRESULT Reset(); DECLARE_PERSISTENT(CAdObject, CBObject) - virtual void Talk(char *Text, char *Sound = NULL, uint32 Duration = 0, char *Stances = NULL, TTextAlign Align = TAL_CENTER); + virtual void Talk(const char *Text, const char *Sound = NULL, uint32 Duration = 0, const char *Stances = NULL, TTextAlign Align = TAL_CENTER); virtual int GetHeight(); CAdSentence *_sentence; - HRESULT SetFont(char *Filename); + HRESULT SetFont(const char *Filename); virtual HRESULT Update(); virtual HRESULT Display(); bool _drawn; bool _active; - virtual HRESULT PlayAnim(char *Filename); + virtual HRESULT PlayAnim(const char *Filename); CBSprite *_animSprite; CBSprite *_currentSprite; TObjectState _state; diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index cd8ab049f9..81cb8fc72e 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -54,7 +54,7 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::LoadFile(char *Filename) { +HRESULT CAdRegion::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index b1e977155b..896db1f772 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -42,7 +42,7 @@ public: bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/AdResponse.cpp b/engines/wintermute/AdResponse.cpp index c02b2832b5..2e5ddc54b7 100644 --- a/engines/wintermute/AdResponse.cpp +++ b/engines/wintermute/AdResponse.cpp @@ -65,14 +65,14 @@ CAdResponse::~CAdResponse() { ////////////////////////////////////////////////////////////////////////// -void CAdResponse::SetText(char *Text) { +void CAdResponse::SetText(const char *Text) { CBUtils::SetString(&_text, Text); CBUtils::SetString(&_textOrig, Text); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIcon(char *Filename) { +HRESULT CAdResponse::SetIcon(const char *Filename) { delete _icon; _icon = new CBSprite(Game); if (!_icon || FAILED(_icon->LoadFile(Filename))) { @@ -85,7 +85,7 @@ HRESULT CAdResponse::SetIcon(char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetFont(char *Filename) { +HRESULT CAdResponse::SetFont(const char *Filename) { if (_font) Game->_fontStorage->RemoveFont(_font); _font = Game->_fontStorage->AddFont(Filename); if (!_font) { @@ -96,7 +96,7 @@ HRESULT CAdResponse::SetFont(char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconHover(char *Filename) { +HRESULT CAdResponse::SetIconHover(const char *Filename) { delete _iconHover; _iconHover = new CBSprite(Game); if (!_iconHover || FAILED(_iconHover->LoadFile(Filename))) { @@ -110,7 +110,7 @@ HRESULT CAdResponse::SetIconHover(char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconPressed(char *Filename) { +HRESULT CAdResponse::SetIconPressed(const char *Filename) { delete _iconPressed; _iconPressed = new CBSprite(Game); if (!_iconPressed || FAILED(_iconPressed->LoadFile(Filename))) { diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h index 97fe5bccb0..f42926e476 100644 --- a/engines/wintermute/AdResponse.h +++ b/engines/wintermute/AdResponse.h @@ -38,11 +38,11 @@ class CBFont; class CAdResponse : public CBObject { public: DECLARE_PERSISTENT(CAdResponse, CBObject) - HRESULT SetIcon(char *Filename); - HRESULT SetFont(char *Filename); - HRESULT SetIconHover(char *Filename); - HRESULT SetIconPressed(char *Filename); - void SetText(char *Text); + HRESULT SetIcon(const char *Filename); + HRESULT SetFont(const char *Filename); + HRESULT SetIconHover(const char *Filename); + HRESULT SetIconPressed(const char *Filename); + void SetText(const char *Text); int _iD; CBSprite *_icon; CBSprite *_iconHover; diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index 45b73ae148..d64230ceb7 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -183,7 +183,7 @@ HRESULT CAdResponseBox::CreateButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::LoadFile(char *Filename) { +HRESULT CAdResponseBox::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h index be14a6f248..de22874e72 100644 --- a/engines/wintermute/AdResponseBox.h +++ b/engines/wintermute/AdResponseBox.h @@ -75,7 +75,7 @@ public: RECT _responseArea; int _verticalAlign; TTextAlign _align; - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/AdRotLevel.cpp b/engines/wintermute/AdRotLevel.cpp index 1c2ba3ed65..b5256f2050 100644 --- a/engines/wintermute/AdRotLevel.cpp +++ b/engines/wintermute/AdRotLevel.cpp @@ -53,7 +53,7 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::LoadFile(char *Filename) { +HRESULT CAdRotLevel::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h index 6033935349..bd78cedb65 100644 --- a/engines/wintermute/AdRotLevel.h +++ b/engines/wintermute/AdRotLevel.h @@ -40,7 +40,7 @@ public: virtual ~CAdRotLevel(); float _rotation; virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/AdScaleLevel.cpp b/engines/wintermute/AdScaleLevel.cpp index 4edb24eca1..546e0f7f8e 100644 --- a/engines/wintermute/AdScaleLevel.cpp +++ b/engines/wintermute/AdScaleLevel.cpp @@ -51,7 +51,7 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::LoadFile(char *Filename) { +HRESULT CAdScaleLevel::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h index fb0cd38264..efaa5f5e57 100644 --- a/engines/wintermute/AdScaleLevel.h +++ b/engines/wintermute/AdScaleLevel.h @@ -41,7 +41,7 @@ public: CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index a35f2550a1..b8ee74eb71 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -504,7 +504,7 @@ HRESULT CAdScene::InitLoop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadFile(char *Filename) { +HRESULT CAdScene::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); @@ -1353,7 +1353,7 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (layer < 0 || layer >= _layers.GetSize()) Stack->PushNULL(); else Stack->PushNative(_layers[layer], true); } else { - char *LayerName = val->GetString(); + const char *LayerName = val->GetString(); bool LayerFound = false; for (int i = 0; i < _layers.GetSize(); i++) { if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { @@ -1383,7 +1383,7 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetNode") == 0) { Stack->CorrectParams(1); - char *Name = Stack->Pop()->GetString(); + const char *Name = Stack->Pop()->GetString(); CBObject *node = GetNodeByName(Name); if (node) Stack->PushNative((CBScriptable *)node, true); @@ -1404,7 +1404,7 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int Index = Val->GetInt(); if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; } else { - char *Name = Val->GetString(); + const char *Name = Val->GetString(); for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, Name) == 0) { Ret = _objects[i]; @@ -2426,7 +2426,7 @@ void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetNodeByName(char *Name) { +CBObject *CAdScene::GetNodeByName(const char *Name) { int i; CBObject *ret = NULL; @@ -2574,7 +2574,7 @@ float CAdScene::GetRotationAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::HandleItemAssociations(char *ItemName, bool Show) { +HRESULT CAdScene::HandleItemAssociations(const char *ItemName, bool Show) { int i; for (i = 0; i < _layers.GetSize(); i++) { diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index 874e05ac61..cfedc8a911 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -55,14 +55,14 @@ public: HRESULT AfterLoad(); HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - HRESULT HandleItemAssociations(char *ItemName, bool Show); + HRESULT HandleItemAssociations(const char *ItemName, bool Show); CUIWindow *_shieldWindow; float GetRotationAt(int X, int Y); HRESULT LoadState(); HRESULT SaveState(); bool _persistentState; bool _persistentStateSprites; - CBObject *GetNodeByName(char *Name); + CBObject *GetNodeByName(const char *Name); void SetOffset(int OffsetLeft, int OffsetTop); bool PointInViewport(int X, int Y); int GetOffsetTop(); @@ -123,7 +123,7 @@ public: CBArray _layers; CBArray _objects; CBArray _waypointGroups; - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); int _width; int _height; diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp index 2fd2648448..a7acbe78d1 100644 --- a/engines/wintermute/AdSceneState.cpp +++ b/engines/wintermute/AdSceneState.cpp @@ -62,7 +62,7 @@ HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdSceneState::SetFilename(char *Filename) { +void CAdSceneState::SetFilename(const char *Filename) { SAFE_DELETE_ARRAY(_filename); _filename = new char [strlen(Filename) + 1]; if (_filename) strcpy(_filename, Filename); diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h index a49f0ba5f7..81d84529b8 100644 --- a/engines/wintermute/AdSceneState.h +++ b/engines/wintermute/AdSceneState.h @@ -38,7 +38,7 @@ class CAdNodeState; class CAdSceneState : public CBBase { public: CAdNodeState *GetNodeState(char *Name, bool Saving); - void SetFilename(char *Filename); + void SetFilename(const char *Filename); DECLARE_PERSISTENT(CAdSceneState, CBBase) CAdSceneState(CBGame *inGame); virtual ~CAdSceneState(); diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp index 81bcfcf366..b5ba7915cf 100644 --- a/engines/wintermute/AdSentence.cpp +++ b/engines/wintermute/AdSentence.cpp @@ -91,7 +91,7 @@ CAdSentence::~CAdSentence() { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetText(char *Text) { +void CAdSentence::SetText(const char *Text) { if (_text) delete [] _text; _text = new char[strlen(Text) + 1]; if (_text) strcpy(_text, Text); @@ -99,7 +99,7 @@ void CAdSentence::SetText(char *Text) { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetStances(char *Stances) { +void CAdSentence::SetStances(const char *Stances) { if (_stances) delete [] _stances; if (Stances) { _stances = new char[strlen(Stances) + 1]; @@ -238,7 +238,7 @@ HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::SetupTalkFile(char *SoundFilename) { +HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { delete _talkDef; _talkDef = NULL; _currentSprite = NULL; diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h index ded17c83a7..7552a72944 100644 --- a/engines/wintermute/AdSentence.h +++ b/engines/wintermute/AdSentence.h @@ -46,7 +46,7 @@ public: CBSprite *_currentSprite; char *_currentSkelAnim; HRESULT Update(TDirection Dir = DI_DOWN); - HRESULT SetupTalkFile(char *SoundFilename); + HRESULT SetupTalkFile(const char *SoundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) HRESULT Finish(); void SetSound(CBSound *Sound); @@ -59,8 +59,8 @@ public: CBFont *_font; char *GetNextStance(); char *GetCurrentStance(); - void SetStances(char *Stances); - void SetText(char *Text); + void SetStances(const char *Stances); + void SetText(const char *Text); int _currentStance; uint32 _startTime; char *_stances; diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp index e65e701a85..8fe079e780 100644 --- a/engines/wintermute/AdSpriteSet.cpp +++ b/engines/wintermute/AdSpriteSet.cpp @@ -58,7 +58,7 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CAdSpriteSet::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h index 629978bff3..7a68ed9d0a 100644 --- a/engines/wintermute/AdSpriteSet.h +++ b/engines/wintermute/AdSpriteSet.h @@ -44,7 +44,7 @@ public: CBObject *_owner; CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); virtual ~CAdSpriteSet(); - HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); CBSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 44ef2eddb7..5cd8432292 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -137,7 +137,7 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (SetCurrent) _currentSprite = NULL; Stack->PushBool(true); } else { - char *Filename = Val->GetString(); + const char *Filename = Val->GetString(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile(Filename))) { Script->RuntimeError("SetSprite method failed for file '%s'", Filename); @@ -179,7 +179,7 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "AddTalkSprite") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool Ex = Stack->Pop()->GetBool(); CBSprite *spr = new CBSprite(Game, this); @@ -200,7 +200,7 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "RemoveTalkSprite") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool Ex = Stack->Pop()->GetBool(); int i; @@ -243,7 +243,7 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "SetTalkSprite") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool Ex = Stack->Pop()->GetBool(); bool SetCurrent = false; bool SetTemp2 = false; diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index 97a8056713..a4f630c572 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -62,7 +62,7 @@ void CAdWaypointGroup::Cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::LoadFile(char *Filename) { +HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h index e997e89663..de28f3fbf4 100644 --- a/engines/wintermute/AdWaypointGroup.h +++ b/engines/wintermute/AdWaypointGroup.h @@ -44,7 +44,7 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); bool _active; CAdWaypointGroup(CBGame *inGame); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual ~CAdWaypointGroup(); CBArray _points; diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp index 977b965561..68cc581abf 100644 --- a/engines/wintermute/BEvent.cpp +++ b/engines/wintermute/BEvent.cpp @@ -119,7 +119,7 @@ void CBEvent::SetName(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::LoadFile(char *Filename) { +HRESULT CBEvent::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h index 87d3de0e96..a1e071fe94 100644 --- a/engines/wintermute/BEvent.h +++ b/engines/wintermute/BEvent.h @@ -47,7 +47,7 @@ public: CBEvent(CBGame *inGame); CBEvent(CBGame *inGame, TEventType Type, char *Script); virtual ~CBEvent(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 427c817fb4..a3b756eb87 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -182,7 +182,7 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +HRESULT CBFileManager::SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); #if 0 diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index 81b22ffef9..7a9593915a 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -63,7 +63,7 @@ public: } TPathType; HRESULT AddPath(TPathType Type, const char *Path); HRESULT RequestCD(int CD, char *PackageFile, char *Filename); - HRESULT SaveFile(char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); + HRESULT SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); diff --git a/engines/wintermute/BFont.cpp b/engines/wintermute/BFont.cpp index 92ce8595ae..4bae2841ab 100644 --- a/engines/wintermute/BFont.cpp +++ b/engines/wintermute/BFont.cpp @@ -71,7 +71,7 @@ int CBFont::GetTextWidth(byte *text, int MaxLenght) { /* ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::LoadFile(char * Filename) +HRESULT CBFont::LoadFile(const char * Filename) { BYTE* Buffer = Game->_fileManager->ReadWholeFile(Filename); if(Buffer==NULL){ @@ -152,7 +152,7 @@ HRESULT CBFont::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::CreateFromFile(CBGame *Game, char *Filename) { +CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { if (IsTrueType(Game, Filename)) { CBFontTT *Font = new CBFontTT(Game); if (Font) { @@ -180,7 +180,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::IsTrueType(CBGame *Game, char *Filename) { +bool CBFont::IsTrueType(CBGame *Game, const char *Filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) diff --git a/engines/wintermute/BFont.h b/engines/wintermute/BFont.h index 5ffba7ace4..a02b6cd0ca 100644 --- a/engines/wintermute/BFont.h +++ b/engines/wintermute/BFont.h @@ -48,12 +48,12 @@ public: CBFont(CBGame *inGame); virtual ~CBFont(); - static CBFont *CreateFromFile(CBGame *Game, char *Filename); + static CBFont *CreateFromFile(CBGame *Game, const char *Filename); private: //HRESULT LoadBuffer(byte * Buffer); - //HRESULT LoadFile(char* Filename); - static bool IsTrueType(CBGame *Game, char *Filename); + //HRESULT LoadFile(const char* Filename); + static bool IsTrueType(CBGame *Game, const char *Filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 71bbf95801..f2f7fcfc60 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -242,7 +242,7 @@ void CBFontBitmap::DrawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::LoadFile(char *Filename) { +HRESULT CBFontBitmap::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/BFontBitmap.h b/engines/wintermute/BFontBitmap.h index b194674b7c..23ebdaabe2 100644 --- a/engines/wintermute/BFontBitmap.h +++ b/engines/wintermute/BFontBitmap.h @@ -38,7 +38,7 @@ class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); virtual int GetTextWidth(byte *text, int MaxLength = -1); virtual int GetTextHeight(byte *text, int width); virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp index 61b5e58805..f73f018ab7 100644 --- a/engines/wintermute/BFontStorage.cpp +++ b/engines/wintermute/BFontStorage.cpp @@ -90,7 +90,7 @@ HRESULT CBFontStorage::InitLoop() { } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::AddFont(char *Filename) { +CBFont *CBFontStorage::AddFont(const char *Filename) { if (!Filename) return NULL; for (int i = 0; i < _fonts.GetSize(); i++) { diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h index 25e1b345d2..8bf9c556c3 100644 --- a/engines/wintermute/BFontStorage.h +++ b/engines/wintermute/BFontStorage.h @@ -46,7 +46,7 @@ public: DECLARE_PERSISTENT(CBFontStorage, CBBase) HRESULT Cleanup(bool Warn = false); HRESULT RemoveFont(CBFont *Font); - CBFont *AddFont(char *Filename); + CBFont *AddFont(const char *Filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); CBArray _fonts; diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 458325e3d1..24454c7529 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -376,7 +376,7 @@ int CBFontTT::GetLetterHeight() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::LoadFile(char *Filename) { +HRESULT CBFontTT::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index 6994ea3c8f..ec552fc9fa 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -126,7 +126,7 @@ public: virtual int GetLetterHeight(); HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); /* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); static void FTCloseProc(FT_Stream stream);*/ diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index f04b35bfe2..c18d6a55a7 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -479,7 +479,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "AddSubframe") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - char *Filename = NULL; + const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); CBSubFrame *Sub = new CBSubFrame(Game); @@ -502,7 +502,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (Index < 0) Index = 0; CScValue *Val = Stack->Pop(); - char *Filename = NULL; + const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); CBSubFrame *Sub = new CBSubFrame(Game); @@ -535,7 +535,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddEvent") == 0) { Stack->CorrectParams(1); - char *Event = Stack->Pop()->GetString(); + const char *Event = Stack->Pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { Stack->PushNULL(); @@ -552,7 +552,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DeleteEvent") == 0) { Stack->CorrectParams(1); - char *Event = Stack->Pop()->GetString(); + const char *Event = Stack->Pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { delete [] _applyEvent[i]; diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h index 90a7c1b192..279dcd2289 100644 --- a/engines/wintermute/BFrame.h +++ b/engines/wintermute/BFrame.h @@ -58,7 +58,7 @@ public: CBFrame(CBGame *inGame); virtual ~CBFrame(); - CBArray _applyEvent; + CBArray _applyEvent; // scripting interface virtual CScValue *ScGetProperty(char *Name); diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 08d78e1745..eee7d5299a 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -949,7 +949,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { } } - if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("syste_font.fnt"); + if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("system_font.fnt"); if (cmd == PARSERR_TOKENNOTFOUND) { @@ -1017,7 +1017,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadStringTable") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); CScValue *Val = Stack->Pop(); bool ClearOld; @@ -1113,7 +1113,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Channel = Stack->Pop()->GetInt(); } - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); CScValue *ValLooping = Stack->Pop(); bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); @@ -1317,7 +1317,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); int Length = 0; - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); CBSound *Sound = new CBSound(Game); if (Sound && SUCCEEDED(Sound->SetSound(Filename, SOUND_MUSIC, true))) { @@ -1404,7 +1404,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RegWriteNumber") == 0) { Stack->CorrectParams(2); - char *Key = Stack->Pop()->GetString(); + const char *Key = Stack->Pop()->GetString(); int Val = Stack->Pop()->GetInt(); _registry->WriteInt("PrivateSettings", Key, Val); Stack->PushNULL(); @@ -1416,7 +1416,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RegReadNumber") == 0) { Stack->CorrectParams(2); - char *Key = Stack->Pop()->GetString(); + const char *Key = Stack->Pop()->GetString(); int InitVal = Stack->Pop()->GetInt(); Stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); return S_OK; @@ -1427,8 +1427,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RegWriteString") == 0) { Stack->CorrectParams(2); - char *Key = Stack->Pop()->GetString(); - char *Val = Stack->Pop()->GetString(); + const char *Key = Stack->Pop()->GetString(); + const char *Val = Stack->Pop()->GetString(); _registry->WriteString("PrivateSettings", Key, Val); Stack->PushNULL(); return S_OK; @@ -1439,8 +1439,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RegReadString") == 0) { Stack->CorrectParams(2); - char *Key = Stack->Pop()->GetString(); - char *InitVal = Stack->Pop()->GetString(); + const char *Key = Stack->Pop()->GetString(); + const char *InitVal = Stack->Pop()->GetString(); AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); Stack->PushString((char *)val.c_str()); return S_OK; @@ -1452,7 +1452,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "SaveGame") == 0) { Stack->CorrectParams(3); int Slot = Stack->Pop()->GetInt(); - char *xdesc = Stack->Pop()->GetString(); + const char *xdesc = Stack->Pop()->GetString(); bool quick = Stack->Pop()->GetBool(false); char *Desc = new char[strlen(xdesc) + 1]; @@ -1650,7 +1650,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "FileExists") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); CBFile *File = _fileManager->OpenFile(Filename, false); if (!File) Stack->PushBool(false); @@ -1744,7 +1744,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ScreenshotEx") == 0) { Stack->CorrectParams(3); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); int SizeX = Stack->Pop()->GetInt(_renderer->_width); int SizeY = Stack->Pop()->GetInt(_renderer->_height); @@ -1917,7 +1917,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "DisplayLoadingIcon") == 0) { Stack->CorrectParams(4); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); _loadingIconX = Stack->Pop()->GetInt(); _loadingIconY = Stack->Pop()->GetInt(); _loadingIconPersistent = Stack->Pop()->GetBool(); @@ -1953,7 +1953,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DumpTextureStats") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); _renderer->DumpData(Filename); @@ -1966,7 +1966,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccOutputText") == 0) { Stack->CorrectParams(2); - char *Str = Stack->Pop()->GetString(); + const char *Str = Stack->Pop()->GetString(); int Type = Stack->Pop()->GetInt(); // do nothing Stack->PushNULL(); @@ -2007,7 +2007,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFileChecksum") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool AsHex = Stack->Pop()->GetBool(false); CBFile *File = _fileManager->OpenFile(Filename, false); @@ -2715,7 +2715,7 @@ HRESULT CBGame::DisplayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessage(char *Text) { +void CBGame::QuickMessage(const char *Text) { if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.RemoveAt(0); @@ -3091,7 +3091,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ToString") == 0) { Stack->CorrectParams(1); - char *Str = Stack->Pop()->GetString(); + const char *Str = Stack->Pop()->GetString(); char *Str2 = new char[strlen(Str) + 1]; strcpy(Str2, Str); Stack->PushString(Str2); @@ -3215,7 +3215,7 @@ HRESULT CBGame::LoadGame(int Slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(char *Filename) { +HRESULT CBGame::LoadGame(const char *Filename) { LOG(0, "Loading game '%s'...", Filename); GetDebugMgr()->OnGameShutdown(); @@ -3343,7 +3343,7 @@ HRESULT CBGame::DisplayWindows(bool InGame) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PlayMusic(int Channel, char *Filename, bool Looping, uint32 LoopStart) { +HRESULT CBGame::PlayMusic(int Channel, const char *Filename, bool Looping, uint32 LoopStart) { if (Channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3423,7 +3423,7 @@ HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadSettings(char *Filename) { +HRESULT CBGame::LoadSettings(const char *Filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -4121,7 +4121,7 @@ HRESULT CBGame::RestoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetWaitCursor(char *Filename) { +HRESULT CBGame::SetWaitCursor(const char *Filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 9f8ef5241b..cdc937afb9 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -114,7 +114,7 @@ public: virtual HRESULT ResetContent(); void DEBUG_DumpClassRegistry(); - HRESULT SetWaitCursor(char *Filename); + HRESULT SetWaitCursor(const char *Filename); char *_localSaveDir; bool _saveDirChecked; @@ -274,12 +274,12 @@ public: static void AfterLoadScript(void *script, void *data); static void InvalidateValues(void *Value, void *Data); - HRESULT LoadSettings(char *Filename); + HRESULT LoadSettings(const char *Filename); HRESULT ResumeMusic(int Channel); HRESULT SetMusicStartTime(int Channel, uint32 Time); HRESULT PauseMusic(int Channel); HRESULT StopMusic(int Channel); - HRESULT PlayMusic(int Channel, char *Filename, bool Looping = true, uint32 LoopStart = 0); + HRESULT PlayMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); CBSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; @@ -292,7 +292,7 @@ public: bool _useD3D; virtual HRESULT Cleanup(); virtual HRESULT LoadGame(int Slot); - virtual HRESULT LoadGame(char *Filename); + virtual HRESULT LoadGame(const char *Filename); virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); virtual HRESULT ShowCursor(); @@ -316,7 +316,7 @@ public: bool ValidObject(CBObject *Object); HRESULT UnregisterObject(CBObject *Object); HRESULT RegisterObject(CBObject *Object); - void QuickMessage(char *Text); + void QuickMessage(const char *Text); void QuickMessageForm(LPSTR fmt, ...); HRESULT DisplayQuickMsg(); uint32 _fps; diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp index a773bc00c9..f9f481f2d1 100644 --- a/engines/wintermute/BImage.cpp +++ b/engines/wintermute/BImage.cpp @@ -47,7 +47,7 @@ CBImage::~CBImage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::SaveBMPFile(char *Filename) { +HRESULT CBImage::SaveBMPFile(const char *Filename) { #if 0 if (!_bitmap) return E_FAIL; diff --git a/engines/wintermute/BImage.h b/engines/wintermute/BImage.h index 98b6dfaac6..b9e3ca880c 100644 --- a/engines/wintermute/BImage.h +++ b/engines/wintermute/BImage.h @@ -47,7 +47,7 @@ public: byte *CreateBMPBuffer(uint32 *BufferSize = NULL); HRESULT Resize(int NewWidth, int NewHeight); - HRESULT SaveBMPFile(char *Filename); + HRESULT SaveBMPFile(const char *Filename); HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); FIBITMAP *GetBitmap() const { diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 892c8a837b..7499ca70df 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -68,9 +68,10 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta int vKey; if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { - char *str = val->GetString(); - if (str[0] >= 'A' && str[0] <= 'Z') str[0] += ('a' - 'A'); - vKey = (int)str[0]; + const char *str = val->GetString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; } else vKey = val->GetInt(); warning("BKeyboardState doesnt yet have state-support"); //TODO; diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp index fb8526ddad..7f33aaa42d 100644 --- a/engines/wintermute/BNamedObject.cpp +++ b/engines/wintermute/BNamedObject.cpp @@ -55,7 +55,7 @@ CBNamedObject::~CBNamedObject(void) { ////////////////////////////////////////////////////////////////////// -void CBNamedObject::SetName(char *Name) { +void CBNamedObject::SetName(const char *Name) { delete[] _name; _name = new char [strlen(Name) + 1]; diff --git a/engines/wintermute/BNamedObject.h b/engines/wintermute/BNamedObject.h index c3b9abb7bc..aecd45517b 100644 --- a/engines/wintermute/BNamedObject.h +++ b/engines/wintermute/BNamedObject.h @@ -42,7 +42,7 @@ public: CBNamedObject(TDynamicConstructor, TDynamicConstructor); char *_name; - void SetName(char *Name); + void SetName(const char *Name); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index beadaf1ec2..4c63672bc6 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -135,7 +135,7 @@ HRESULT CBObject::Cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::SetCaption(char *Caption, int Case) { +void CBObject::SetCaption(const char *Caption, int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; @@ -268,7 +268,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "LoadSound") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (SUCCEEDED(PlaySFX(Filename, false, false))) Stack->PushBool(true); else @@ -283,7 +283,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "PlaySound") == 0) { Stack->CorrectParams(3); - char *Filename; + const char *Filename; bool Looping; uint32 LoopStart; @@ -313,8 +313,8 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "PlaySoundEvent") == 0) { Stack->CorrectParams(2); - char *Filename; - char *EventName; + const char *Filename; + const char *EventName; CScValue *val1 = Stack->Pop(); CScValue *val2 = Stack->Pop(); @@ -919,7 +919,7 @@ HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetCursor(char *Filename) { +HRESULT CBObject::SetCursor(const char *Filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -936,7 +936,7 @@ HRESULT CBObject::SetCursor(char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetActiveCursor(char *Filename) { +HRESULT CBObject::SetActiveCursor(const char *Filename) { delete _activeCursor; _activeCursor = new CBSprite(Game); if (!_activeCursor || FAILED(_activeCursor->LoadFile(Filename))) { @@ -972,7 +972,7 @@ bool CBObject::HandleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::PlaySFX(char *Filename, bool Looping, bool PlayNow, char *EventName, uint32 LoopStart) { +HRESULT CBObject::PlaySFX(const char *Filename, bool Looping, bool PlayNow, const char *EventName, uint32 LoopStart) { // just play loaded sound if (Filename == NULL && _sFX) { if (Game->_editorMode || _sFXStart) { @@ -1105,7 +1105,7 @@ bool CBObject::IsReady() { ////////////////////////////////////////////////////////////////////////// -void CBObject::SetSoundEvent(char *EventName) { +void CBObject::SetSoundEvent(const char *EventName) { delete[] _soundEvent; _soundEvent = NULL; if (EventName) { diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 835d5fe34a..f896428417 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -51,7 +51,7 @@ public: float _relativeRotate; bool _rotateValid; float _rotate; - void SetSoundEvent(char *EventName); + void SetSoundEvent(const char *EventName); bool _rotatable; uint32 _alphaColor; float _scale; @@ -71,7 +71,7 @@ public: HRESULT ResumeSFX(); HRESULT PauseSFX(); HRESULT StopSFX(bool DeleteSound = true); - HRESULT PlaySFX(char *Filename, bool Looping = false, bool PlayNow = true, char *EventName = NULL, uint32 LoopStart = 0); + HRESULT PlaySFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -84,11 +84,11 @@ public: virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); virtual bool HandleKeypress(SDL_Event *event); virtual int GetHeight(); - HRESULT SetCursor(char *Filename); - HRESULT SetActiveCursor(char *Filename); + HRESULT SetCursor(const char *Filename); + HRESULT SetActiveCursor(const char *Filename); HRESULT Cleanup(); char *GetCaption(int Case = 1); - void SetCaption(char *Caption, int Case = 1); + void SetCaption(const char *Caption, int Case = 1); bool _editorSelected; bool _editorAlwaysRegister; bool _editorOnly; diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp index e8b47441fc..297efeec81 100644 --- a/engines/wintermute/BPersistMgr.cpp +++ b/engines/wintermute/BPersistMgr.cpp @@ -209,7 +209,7 @@ uint16 getHighWord(uint32 dword) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitLoad(char *Filename) { +HRESULT CBPersistMgr::InitLoad(const char *Filename) { Cleanup(); _saving = false; @@ -293,7 +293,7 @@ init_fail: ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::SaveFile(char *Filename) { +HRESULT CBPersistMgr::SaveFile(const char *Filename) { return Game->_fileManager->SaveFile(Filename, _buffer, _offset, Game->_compressedSavegames, _richBuffer, _richBufferSize); } diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h index 381308bcac..3f55146ce8 100644 --- a/engines/wintermute/BPersistMgr.h +++ b/engines/wintermute/BPersistMgr.h @@ -45,13 +45,13 @@ public: byte _savedVerBuild; byte _savedExtMajor; byte _savedExtMinor; - HRESULT SaveFile(char *Filename); + HRESULT SaveFile(const char *Filename); uint32 GetDWORD(); void PutDWORD(uint32 Val); char *GetString(); void PutString(const char *Val); void Cleanup(); - HRESULT InitLoad(char *Filename); + HRESULT InitLoad(const char *Filename); HRESULT InitSave(char *Desc); HRESULT GetBytes(byte *Buffer, uint32 Size); HRESULT PutBytes(byte *Buffer, uint32 Size); diff --git a/engines/wintermute/BQuickMsg.cpp b/engines/wintermute/BQuickMsg.cpp index 1e406af1e8..6fa14ac5c0 100644 --- a/engines/wintermute/BQuickMsg.cpp +++ b/engines/wintermute/BQuickMsg.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, char *Text): CBBase(inGame) { +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *Text): CBBase(inGame) { _text = new char [strlen(Text) + 1]; if (_text) strcpy(_text, Text); _startTime = Game->_currentTime; diff --git a/engines/wintermute/BQuickMsg.h b/engines/wintermute/BQuickMsg.h index 6349a6ae35..a760a9ee21 100644 --- a/engines/wintermute/BQuickMsg.h +++ b/engines/wintermute/BQuickMsg.h @@ -38,7 +38,7 @@ public: char *GetText(); uint32 _startTime; char *_text; - CBQuickMsg(CBGame *inGame, char *Text); + CBQuickMsg(CBGame *inGame, const char *Text); virtual ~CBQuickMsg(); }; diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 44df8dce44..9190955321 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -94,7 +94,7 @@ bool CBRegion::PointInRegion(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::LoadFile(char *Filename) { +HRESULT CBRegion::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index 914f77f7ae..783cb22965 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -50,7 +50,7 @@ public: virtual ~CBRegion(); bool PointInRegion(int X, int Y); bool CreateRegion(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); RECT _rect; CBArray _points; diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 613995124f..a5a3547cb3 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -417,7 +417,7 @@ void CBRenderSDL::PointToScreen(POINT *point) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::DumpData(char *Filename) { +void CBRenderSDL::DumpData(const char *Filename) { FILE *f = fopen(Filename, "wt"); if (!f) return; diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 573c4368c4..5842492743 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -67,7 +67,7 @@ public: void PointFromScreen(POINT *point); void PointToScreen(POINT *point); - void DumpData(char *Filename); + void DumpData(const char *Filename); float GetScaleRatioX() const { return _ratioX; diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h index de7731a3ad..26ea699e6d 100644 --- a/engines/wintermute/BRenderer.h +++ b/engines/wintermute/BRenderer.h @@ -46,7 +46,7 @@ public: int _drawOffsetX; int _drawOffsetY; - virtual void DumpData(char *Filename) {}; + virtual void DumpData(const char *Filename) {}; virtual CBImage *TakeScreenshot(); virtual HRESULT SetViewport(int left, int top, int right, int bottom); virtual HRESULT SetViewport(RECT *Rect); diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index ed7db2507b..a13ef750e8 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -68,7 +68,7 @@ HRESULT CBScriptHolder::Cleanup() { } ////////////////////////////////////////////////////////////////////// -void CBScriptHolder::SetFilename(char *Filename) { +void CBScriptHolder::SetFilename(const char *Filename) { if (_filename != NULL) delete [] _filename; _filename = new char [strlen(Filename) + 1]; @@ -169,7 +169,7 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DetachScript") == 0) { Stack->CorrectParams(2); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool KillThreads = Stack->Pop()->GetBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { @@ -189,7 +189,7 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsScriptRunning") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { @@ -273,7 +273,7 @@ HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::AddScript(char *Filename) { +HRESULT CBScriptHolder::AddScript(const char *Filename) { for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { @@ -319,7 +319,7 @@ HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleEvent(char *EventName) { +bool CBScriptHolder::CanHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->CanHandleEvent(EventName)) return true; } @@ -328,7 +328,7 @@ bool CBScriptHolder::CanHandleEvent(char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleMethod(char *MethodName) { +bool CBScriptHolder::CanHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->CanHandleMethod(MethodName)) return true; } diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index cc54a983c2..2a96817541 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -43,15 +43,15 @@ public: virtual ~CBScriptHolder(); virtual CScScript *InvokeMethodThread(char *MethodName); virtual void MakeFreezable(bool Freezable); - bool CanHandleEvent(char *EventName); - virtual bool CanHandleMethod(char *EventMethod); + bool CanHandleEvent(const char *EventName); + virtual bool CanHandleMethod(const char *EventMethod); HRESULT Cleanup(); HRESULT RemoveScript(CScScript *Script); - HRESULT AddScript(char *Filename); + HRESULT AddScript(const char *Filename); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); - void SetFilename(char *Filename); + void SetFilename(const char *Filename); HRESULT ParseProperty(byte *Buffer, bool Complete = true); char *_filename; bool _freezable; diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index e38ee061d8..2f898078c6 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -74,7 +74,7 @@ HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::ScGetProperty(char *Name) { +CScValue *CBScriptable::ScGetProperty(const char *Name) { if (!_scProp) _scProp = new CScValue(Game); if (_scProp) return _scProp->GetProp(Name); else return NULL; @@ -82,7 +82,7 @@ CScValue *CBScriptable::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBScriptable::ScSetProperty(const char *Name, CScValue *Value) { if (!_scProp) _scProp = new CScValue(Game); if (_scProp) return _scProp->SetProp(Name, Value); else return E_FAIL; diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index 71ce682a4b..b841d1578d 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -50,8 +50,8 @@ public: // high level scripting interface virtual bool CanHandleMethod(char *EventMethod); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual CScValue *ScGetProperty(char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); virtual char *ScToString(); virtual void *ScToMemBuffer(); diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp index e7c047a40f..088235fb75 100644 --- a/engines/wintermute/BSound.cpp +++ b/engines/wintermute/BSound.cpp @@ -65,7 +65,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetSound(char *Filename, TSoundType Type, bool Streamed) { +HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) { if (_sound) { Game->_soundMgr->removeSound(_sound); _sound = NULL; diff --git a/engines/wintermute/BSound.h b/engines/wintermute/BSound.h index 922992de7f..d8da355239 100644 --- a/engines/wintermute/BSound.h +++ b/engines/wintermute/BSound.h @@ -64,7 +64,7 @@ public: TSoundType _soundType; char *_soundFilename; HRESULT SetSoundSimple(); - HRESULT SetSound(char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + HRESULT SetSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); CBSound(CBGame *inGame); virtual ~CBSound(); diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index 1fc5ba296a..f84f2f945a 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -121,7 +121,7 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::LoadFile(char *Filename, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { CBFile *File = Game->_fileManager->OpenFile(Filename); if (!File) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); @@ -562,7 +562,7 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "AddFrame") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - char *Filename = NULL; + const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); CBFrame *Frame = new CBFrame(Game); @@ -588,7 +588,7 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (Index < 0) Index = 0; CScValue *Val = Stack->Pop(); - char *Filename = NULL; + const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); CBFrame *Frame = new CBFrame(Game); diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index 973c263e8f..983b7bb62f 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -67,7 +67,7 @@ public: bool _paused; bool _finished; HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT LoadFile(char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); uint32 _lastFrameTime; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); bool _looping; diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp index bebed9a38f..e53403c6f0 100644 --- a/engines/wintermute/BStringTable.cpp +++ b/engines/wintermute/BStringTable.cpp @@ -169,7 +169,7 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::LoadFile(char *Filename, bool ClearOld) { +HRESULT CBStringTable::LoadFile(const char *Filename, bool ClearOld) { Game->LOG(0, "Loading string table..."); if (ClearOld) _strings.clear(); diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h index abb455e3f5..f4d1bc254e 100644 --- a/engines/wintermute/BStringTable.h +++ b/engines/wintermute/BStringTable.h @@ -38,7 +38,7 @@ namespace WinterMute { class CBStringTable : public CBBase { public: const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT LoadFile(char *Filename, bool DeleteAll = true); + HRESULT LoadFile(const char *Filename, bool DeleteAll = true); void Expand(char **Str, bool ForceExpand = false); HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); CBStringTable(CBGame *inGame); diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index d95fb824bd..e8abd11927 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -368,7 +368,7 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T _surfaceFilename = NULL; Stack->PushBool(true); } else { - char *Filename = Val->GetString(); + const char *Filename = Val->GetString(); if (SUCCEEDED(SetSurface(Filename))) { SetDefaultRect(); Stack->PushBool(true); @@ -549,7 +549,7 @@ char *CBSubFrame::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SetSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::SetSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { if (_surface) { Game->_surfaceStorage->RemoveSurface(_surface); _surface = NULL; diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h index 9a8961df1b..3c0a91344d 100644 --- a/engines/wintermute/BSubFrame.h +++ b/engines/wintermute/BSubFrame.h @@ -41,7 +41,7 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - HRESULT SetSurface(char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT SetSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); HRESULT SetSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void SetDefaultRect(); diff --git a/engines/wintermute/BSurface.cpp b/engines/wintermute/BSurface.cpp index c51652e503..4fe97bcdeb 100644 --- a/engines/wintermute/BSurface.cpp +++ b/engines/wintermute/BSurface.cpp @@ -60,7 +60,7 @@ CBSurface::~CBSurface() { ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSurface::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { return E_FAIL; } diff --git a/engines/wintermute/BSurface.h b/engines/wintermute/BSurface.h index 53b9afa541..88fe58d17b 100644 --- a/engines/wintermute/BSurface.h +++ b/engines/wintermute/BSurface.h @@ -60,7 +60,7 @@ public: virtual HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); virtual HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); virtual HRESULT Restore(); - virtual HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + virtual HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); virtual HRESULT Create(int Width, int Height); virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 0f30101780..9c1e1dc4dc 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -65,7 +65,7 @@ CBSurfaceSDL::~CBSurfaceSDL() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::String strFileName(Filename); diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index 792dd01e6d..71a74beb2d 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -40,7 +40,7 @@ public: CBSurfaceSDL(CBGame *inGame); ~CBSurfaceSDL(); - HRESULT Create(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); HRESULT Create(int Width, int Height); HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function diff --git a/engines/wintermute/BSurfaceStorage.cpp b/engines/wintermute/BSurfaceStorage.cpp index a460ac83a6..0e22ae64fb 100644 --- a/engines/wintermute/BSurfaceStorage.cpp +++ b/engines/wintermute/BSurfaceStorage.cpp @@ -97,7 +97,7 @@ HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::AddSurface(char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { _surfaces[i]->_referenceCount++; diff --git a/engines/wintermute/BSurfaceStorage.h b/engines/wintermute/BSurfaceStorage.h index 275c36b4a9..e91b2a3e84 100644 --- a/engines/wintermute/BSurfaceStorage.h +++ b/engines/wintermute/BSurfaceStorage.h @@ -45,7 +45,7 @@ public: //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); HRESULT RestoreAll(); - CBSurface *AddSurface(char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + CBSurface *AddSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); HRESULT RemoveSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index 6adfd4bbec..49bfe67666 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -111,7 +111,7 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddSprite(char *Filename) { +HRESULT CPartEmitter::AddSprite(const char *Filename) { if (!Filename) return E_FAIL; // do we already have the file? @@ -134,7 +134,7 @@ HRESULT CPartEmitter::AddSprite(char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveSprite(char *Filename) { +HRESULT CPartEmitter::RemoveSprite(const char *Filename) { for (int i = 0; i < _sprites.GetSize(); i++) { if (scumm_stricmp(Filename, _sprites[i]) == 0) { delete [] _sprites[i]; @@ -359,7 +359,7 @@ HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, } ////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::AddForceByName(char *Name) { +CPartForce *CPartEmitter::AddForceByName(const char *Name) { CPartForce *Force = NULL; for (int i = 0; i < _forces.GetSize(); i++) { @@ -380,7 +380,7 @@ CPartForce *CPartEmitter::AddForceByName(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { +HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { CPartForce *Force = AddForceByName(Name); if (!Force) return E_FAIL; @@ -396,7 +396,7 @@ HRESULT CPartEmitter::AddForce(char *Name, CPartForce::TForceType Type, int PosX } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveForce(char *Name) { +HRESULT CPartEmitter::RemoveForce(const char *Name) { for (int i = 0; i < _forces.GetSize(); i++) { if (scumm_stricmp(Name, _forces[i]->_name) == 0) { delete _forces[i]; @@ -445,7 +445,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddSprite") == 0) { Stack->CorrectParams(1); - char *SpriteFile = Stack->Pop()->GetString(); + const char *SpriteFile = Stack->Pop()->GetString(); Stack->PushBool(SUCCEEDED(AddSprite(SpriteFile))); return S_OK; @@ -455,7 +455,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveSprite") == 0) { Stack->CorrectParams(1); - char *SpriteFile = Stack->Pop()->GetString(); + const char *SpriteFile = Stack->Pop()->GetString(); Stack->PushBool(SUCCEEDED(RemoveSprite(SpriteFile))); return S_OK; @@ -516,7 +516,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddGlobalForce") == 0) { Stack->CorrectParams(3); - char *Name = Stack->Pop()->GetString(); + const char *Name = Stack->Pop()->GetString(); float Angle = Stack->Pop()->GetFloat(); float Strength = Stack->Pop()->GetFloat(); @@ -530,7 +530,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddPointForce") == 0) { Stack->CorrectParams(5); - char *Name = Stack->Pop()->GetString(); + const char *Name = Stack->Pop()->GetString(); int PosX = Stack->Pop()->GetInt(); int PosY = Stack->Pop()->GetInt(); float Angle = Stack->Pop()->GetFloat(); @@ -546,7 +546,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveForce") == 0) { Stack->CorrectParams(1); - char *Name = Stack->Pop()->GetString(); + const char *Name = Stack->Pop()->GetString(); Stack->PushBool(SUCCEEDED(RemoveForce(Name))); diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h index 16257153bc..92f6a608bf 100644 --- a/engines/wintermute/PartEmitter.h +++ b/engines/wintermute/PartEmitter.h @@ -104,13 +104,13 @@ public: HRESULT Display(CBRegion *Region = NULL); HRESULT SortParticlesByZ(); - HRESULT AddSprite(char *Filename); - HRESULT RemoveSprite(char *Filename); + HRESULT AddSprite(const char *Filename); + HRESULT RemoveSprite(const char *Filename); HRESULT SetBorder(int X, int Y, int Width, int Height); HRESULT SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); - HRESULT AddForce(char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); - HRESULT RemoveForce(char *Name); + HRESULT AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT RemoveForce(const char *Name); CBArray _forces; @@ -122,7 +122,7 @@ public: private: - CPartForce *AddForceByName(char *Name); + CPartForce *AddForceByName(const char *Name); int static CompareZ(const void *Obj1, const void *Obj2); HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp index cc59e20c17..68f1c62c5a 100644 --- a/engines/wintermute/PartParticle.cpp +++ b/engines/wintermute/PartParticle.cpp @@ -69,7 +69,7 @@ CPartParticle::~CPartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::SetSprite(char *Filename) { +HRESULT CPartParticle::SetSprite(const char *Filename) { if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { _sprite->Reset(); return S_OK; diff --git a/engines/wintermute/PartParticle.h b/engines/wintermute/PartParticle.h index 9de4248d6d..288c462b1d 100644 --- a/engines/wintermute/PartParticle.h +++ b/engines/wintermute/PartParticle.h @@ -68,7 +68,7 @@ public: HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); HRESULT Display(CPartEmitter *Emitter); - HRESULT SetSprite(char *Filename); + HRESULT SetSprite(const char *Filename); HRESULT FadeIn(uint32 CurrentTime, int FadeTime); HRESULT FadeOut(uint32 CurrentTime, int FadeTime); diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index ebb72cbe97..4b5dde50fe 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -95,7 +95,7 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::LoadFile(char *Filename) { +HRESULT CUIButton::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); @@ -744,7 +744,7 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageDisable; _imageDisable = new CBSprite(Game); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (!_imageDisable || FAILED(_imageDisable->LoadFile(Filename))) { delete _imageDisable; _imageDisable = NULL; @@ -785,7 +785,7 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageHover; _imageHover = new CBSprite(Game); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (!_imageHover || FAILED(_imageHover->LoadFile(Filename))) { delete _imageHover; _imageHover = NULL; @@ -825,7 +825,7 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imagePress; _imagePress = new CBSprite(Game); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (!_imagePress || FAILED(_imagePress->LoadFile(Filename))) { delete _imagePress; _imagePress = NULL; @@ -865,7 +865,7 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageFocus; _imageFocus = new CBSprite(Game); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (!_imageFocus || FAILED(_imageFocus->LoadFile(Filename))) { delete _imageFocus; _imageFocus = NULL; diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index aa2ac4d66d..9d1134fdf9 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -63,7 +63,7 @@ public: CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 65d61d2641..3f81b16395 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -94,7 +94,7 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::LoadFile(char *Filename) { +HRESULT CUIEdit::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); @@ -534,7 +534,7 @@ char *CUIEdit::ScToString() { ////////////////////////////////////////////////////////////////////////// -void CUIEdit::SetCursorChar(char *Char) { +void CUIEdit::SetCursorChar(const char *Char) { if (!Char) return; delete[] _cursorChar; _cursorChar = new char [strlen(Char) + 1]; diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index ccc332fd63..4d000d5954 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -48,7 +48,7 @@ public: int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; - void SetCursorChar(char *Char); + void SetCursorChar(const char *Char); char *_cursorChar; int _selEnd; int _selStart; @@ -56,7 +56,7 @@ public: CUIEdit(CBGame *inGame); virtual ~CUIEdit(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index b91e226a3e..15d36c3d3d 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -55,7 +55,7 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::LoadFile(char *Filename) { +HRESULT CUIEntity::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); @@ -208,7 +208,7 @@ HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::SetEntity(char *Filename) { +HRESULT CUIEntity::SetEntity(const char *Filename) { if (_entity) Game->UnregisterObject(_entity); _entity = new CAdEntity(Game); if (!_entity || FAILED(_entity->LoadFile(Filename))) { @@ -270,7 +270,7 @@ HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "SetEntity") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (SUCCEEDED(SetEntity(Filename))) Stack->PushBool(true); diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h index 3f4b8c9ee2..ab3e74f9e6 100644 --- a/engines/wintermute/UIEntity.h +++ b/engines/wintermute/UIEntity.h @@ -38,13 +38,13 @@ public: DECLARE_PERSISTENT(CUIEntity, CUIObject) CUIEntity(CBGame *inGame); virtual ~CUIEntity(); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; - HRESULT SetEntity(char *Filename); + HRESULT SetEntity(const char *Filename); // scripting interface virtual CScValue *ScGetProperty(char *Name); diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index bf0cad25b9..75939c5bf6 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -163,7 +163,7 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - char *Filename = Val->GetString(); + const char *Filename = Val->GetString(); delete _image; _image = NULL; @@ -238,7 +238,7 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } // find by name else { - char *name = val->GetString(); + const char *name = val->GetString(); for (i = 0; i < win->_widgets.GetSize(); i++) { if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { found = true; diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index c0ecc60eac..b00e652b0a 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -95,7 +95,7 @@ HRESULT CUIText::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::LoadFile(char *Filename) { +HRESULT CUIText::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h index cdd0acbc48..7f89fb6b30 100644 --- a/engines/wintermute/UIText.h +++ b/engines/wintermute/UIText.h @@ -43,7 +43,7 @@ public: virtual ~CUIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp index 44d78845a3..4cdf9370fc 100644 --- a/engines/wintermute/UITiledImage.cpp +++ b/engines/wintermute/UITiledImage.cpp @@ -119,7 +119,7 @@ HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::LoadFile(char *Filename) { +HRESULT CUITiledImage::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); diff --git a/engines/wintermute/UITiledImage.h b/engines/wintermute/UITiledImage.h index 6cee8ae6cc..6e4b4d31d3 100644 --- a/engines/wintermute/UITiledImage.h +++ b/engines/wintermute/UITiledImage.h @@ -38,7 +38,7 @@ class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void CorrectSize(int *Width, int *Height); - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index a6ab142238..e450ae7c0d 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -200,7 +200,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::LoadFile(char *Filename) { +HRESULT CUIWindow::LoadFile(const char *Filename) { byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); @@ -733,7 +733,7 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageInactive; _imageInactive = new CBSprite(Game); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); if (!_imageInactive || FAILED(_imageInactive->LoadFile(Filename))) { delete _imageInactive; _imageInactive = NULL; diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index dc4c83ee1f..46649dda18 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -72,7 +72,7 @@ public: virtual bool HandleKeypress(SDL_Event *event); CBArray _widgets; TTextAlign _titleAlign; - HRESULT LoadFile(char *Filename); + HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index 19b60043da..a24615e01d 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -96,7 +96,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "SetFilename") == 0) { Stack->CorrectParams(1); - char *Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); Cleanup(); CBUtils::SetString(&_filename, Filename); Stack->PushNULL(); @@ -181,7 +181,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Copy") == 0) { Stack->CorrectParams(2); - char *Dest = Stack->Pop()->GetString(); + const char *Dest = Stack->Pop()->GetString(); bool Overwrite = Stack->Pop()->GetBool(true); Close(); @@ -290,7 +290,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { Stack->CorrectParams(1); - char *Line = Stack->Pop()->GetString(); + const char *Line = Stack->Pop()->GetString(); if (!_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); Stack->PushBool(false); @@ -547,7 +547,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WriteString") == 0) { Stack->CorrectParams(1); - char *Val = Stack->Pop()->GetString(); + const char *Val = Stack->Pop()->GetString(); if (_textMode || !_writeFile) { Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 6215d9c4e3..d1c4242ae8 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -349,7 +349,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "SetString") == 0) { Stack->CorrectParams(2); int Start = Stack->Pop()->GetInt(); - char *Val = Stack->Pop()->GetString(); + const char *Val = Stack->Pop()->GetString(); if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); else { diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index 74217b9907..f24896f611 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -101,7 +101,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidateProducts") == 0) { stack->CorrectParams(1); - char *prodIdList = stack->Pop()->GetString(); + const char *prodIdList = stack->Pop()->GetString(); _lastProductRequestOwner = script->_owner; ValidateProducts(prodIdList); stack->PushNULL(); @@ -162,7 +162,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Purchase") == 0) { stack->CorrectParams(1); - char *prodId = stack->Pop()->GetString(); + const char *prodId = stack->Pop()->GetString(); stack->PushBool(Purchase(script, prodId)); return S_OK; @@ -172,7 +172,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FinishTransaction") == 0) { stack->CorrectParams(1); - char *transId = stack->Pop()->GetString(); + const char *transId = stack->Pop()->GetString(); stack->PushBool(FinishTransaction(script, transId)); return S_OK; @@ -193,7 +193,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnlockProduct") == 0) { stack->CorrectParams(1); - char *prodId = stack->Pop()->GetString(); + const char *prodId = stack->Pop()->GetString(); Game->_registry->WriteBool("Purchases", prodId, true); Game->_registry->SaveValues(); @@ -208,7 +208,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsProductUnlocked") == 0) { stack->CorrectParams(1); - char *prodId = stack->Pop()->GetString(); + const char *prodId = stack->Pop()->GetString(); stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index 4c9f4db146..b2e5faf1db 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -211,7 +211,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "IndexOf") == 0) { Stack->CorrectParams(2); - char *strToFind = Stack->Pop()->GetString(); + const char *strToFind = Stack->Pop()->GetString(); int index = Stack->Pop()->GetInt(); WideString str; diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 0b19542beb..b5f66bbb14 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -232,7 +232,7 @@ void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *Elemen ////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::RunScript(char *Filename, CBScriptHolder *Owner) { +CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { byte *CompBuffer; uint32 CompSize; @@ -265,7 +265,7 @@ CScScript *CScEngine::RunScript(char *Filename, CBScriptHolder *Owner) { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreCache) { +byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache) { int i; // is script in cache? @@ -316,8 +316,13 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC // publish native interfaces Game->PublishNatives(); + // We have const char* everywhere but in the DLL-interfaces... + char *tempFileName = new char[strlen(Filename) + 1]; + memcpy(tempFileName, Filename, strlen(Filename) + 1); + SetFileToCompile(Filename); - CompBuffer = ExtCompileFile(Filename, &CompSize); + CompBuffer = ExtCompileFile(tempFileName, &CompSize); + delete[] tempFileName; if (!CompBuffer) { Game->QuickMessage("Script compiler error. View log for details."); delete [] Buffer; @@ -604,7 +609,7 @@ HRESULT CScEngine::ResumeAll() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SetFileToCompile(char *Filename) { +HRESULT CScEngine::SetFileToCompile(const char *Filename) { delete[] _fileToCompile; _fileToCompile = new char[strlen(Filename) + 1]; if (_fileToCompile) { diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 7ca9ec0771..6a258688c4 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -57,7 +57,7 @@ class CScEngine : public CBBase { public: class CScCachedScript { public: - CScCachedScript(char *Filename, byte *Buffer, uint32 Size) { + CScCachedScript(const char *Filename, byte *Buffer, uint32 Size) { _timestamp = CBPlatform::GetTime(); _buffer = new byte[Size]; if (_buffer) memcpy(_buffer, Buffer, Size); @@ -116,7 +116,7 @@ public: PARSE_ELEMENT_CALLBACK _parseElementCallback; void *_parseElementCallbackData; - HRESULT SetFileToCompile(char *Filename); + HRESULT SetFileToCompile(const char *Filename); char *_fileToCompile; CScScript *_currentScript; HRESULT ResumeAll(); @@ -125,13 +125,13 @@ public: HRESULT ResetObject(CBObject *Object); HRESULT ResetScript(CScScript *Script); HRESULT EmptyScriptCache(); - byte *GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreCache = false); + byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) HRESULT Cleanup(); int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); HRESULT Tick(); CScValue *_globals; - CScScript *RunScript(char *Filename, CBScriptHolder *Owner = NULL); + CScScript *RunScript(const char *Filename, CBScriptHolder *Owner = NULL); bool _compilerAvailable; HINSTANCE _compilerDLL; CScEngine(CBGame *inGame); diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp index 4d9edf9db4..3678701cf4 100644 --- a/engines/wintermute/scriptables/ScScript.cpp +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -223,7 +223,7 @@ HRESULT CScScript::InitTables() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { +HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { Cleanup(); _thread = false; @@ -442,7 +442,7 @@ HRESULT CScScript::ExecuteInstruction() { HRESULT ret = S_OK; uint32 dw; - char *str; + const char *str; //CScValue* op = new CScValue(Game); _operand->Cleanup(); @@ -761,11 +761,11 @@ HRESULT CScScript::ExecuteInstruction() { if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { - str = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; - strcpy(str, op1->GetString()); - strcat(str, op2->GetString()); + char *tempStr = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; + strcpy(tempStr, op1->GetString()); + strcat(tempStr, op2->GetString()); _operand->SetString(str); - delete [] str; + delete [] tempStr; } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() + op2->GetInt()); else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); @@ -1244,13 +1244,13 @@ uint32 CScScript::GetEventPos(const char *Name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleEvent(char *EventName) { +bool CScScript::CanHandleEvent(const char *EventName) { return GetEventPos(EventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleMethod(char *MethodName) { +bool CScScript::CanHandleMethod(const char *MethodName) { return GetMethodPos(MethodName) != 0; } diff --git a/engines/wintermute/scriptables/ScScript.h b/engines/wintermute/scriptables/ScScript.h index 57baf8d92a..588f57512e 100644 --- a/engines/wintermute/scriptables/ScScript.h +++ b/engines/wintermute/scriptables/ScScript.h @@ -68,8 +68,8 @@ public: bool _freezable; HRESULT Resume(); HRESULT Pause(); - bool CanHandleEvent(char *EventName); - bool CanHandleMethod(char *MethodName); + bool CanHandleEvent(const char *EventName); + bool CanHandleMethod(const char *MethodName); HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); @@ -140,7 +140,7 @@ public: uint32 GetDWORD(); double GetFloat(); void Cleanup(); - HRESULT Create(char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); + HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); uint32 _iP; uint32 _bufferSize; byte *_buffer; diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 055f9830ad..250a61ad67 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -156,7 +156,7 @@ CScValue::~CScValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::GetProp(char *Name) { +CScValue *CScValue::GetProp(const char *Name) { if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(Name); if (_type == VAL_STRING && strcmp(Name, "Length") == 0) { @@ -203,7 +203,7 @@ HRESULT CScValue::DeleteProp(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { +HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(Name, Val); HRESULT ret = E_FAIL; @@ -410,7 +410,10 @@ void CScValue::SetString(const char *Val) { ////////////////////////////////////////////////////////////////////////// void CScValue::SetStringVal(const char *Val) { - if (_valString) delete [] _valString; + if (_valString) { + delete [] _valString; + _valString = NULL; + } if (Val == NULL) { _valString = NULL; @@ -575,7 +578,7 @@ void *CScValue::GetMemBuffer() { ////////////////////////////////////////////////////////////////////////// -char *CScValue::GetString() { +const char *CScValue::GetString() { if (_type == VAL_VARIABLE_REF) return _valRef->GetString(); switch (_type) { diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 992a220622..8696808ad4 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -64,7 +64,7 @@ public: bool GetBool(bool Default = false); int GetInt(int Default = 0); double GetFloat(double Default = 0.0f); - char *GetString(); + const char *GetString(); void *GetMemBuffer(); CBScriptable *GetNative(); HRESULT DeleteProp(char *Name); @@ -85,8 +85,8 @@ public: bool IsFloat(); bool IsInt(); bool IsObject(); - HRESULT SetProp(char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); - CScValue *GetProp(char *Name); + HRESULT SetProp(const char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); + CScValue *GetProp(const char *Name); CBScriptable *_valNative; CScValue *_valRef; bool _valBool; diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index 5a7588e765..de5d00e677 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -233,11 +233,10 @@ bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetPath(char *Filename) { +char *CBUtils::GetPath(const char *Filename) { AnsiString path = PathUtil::GetDirectoryName(Filename); //path = boost::filesystem::syste_complete(path).string(); warning("CBUtils::GetPath: (%s), not implemented", Filename); - return Filename; char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); @@ -245,7 +244,7 @@ char *CBUtils::GetPath(char *Filename) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetFilename(char *Filename) { +char *CBUtils::GetFilename(const char *Filename) { AnsiString path = PathUtil::GetFileName(Filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h index 6fdac018ce..fb61ae6571 100644 --- a/engines/wintermute/utils.h +++ b/engines/wintermute/utils.h @@ -56,8 +56,8 @@ public: static bool MatchesPattern(const char *pattern, const char *string); - static char *GetPath(char *Filename); - static char *GetFilename(char *Filename); + static char *GetPath(const char *Filename); + static char *GetFilename(const char *Filename); static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); static uint32 HSLtoRGB(byte H, byte S, byte L); -- cgit v1.2.3 From ded3c2a4b47a34c93c8129c58feedf2bcecd848b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 15:05:03 +0200 Subject: WINTERMUTE: Add const to even more char-pointers. --- engines/wintermute/AdActor.cpp | 4 ++-- engines/wintermute/AdActor.h | 4 ++-- engines/wintermute/AdGame.cpp | 4 ++-- engines/wintermute/AdGame.h | 4 ++-- engines/wintermute/AdItem.cpp | 2 +- engines/wintermute/AdItem.h | 2 +- engines/wintermute/AdNodeState.cpp | 4 ++-- engines/wintermute/AdNodeState.h | 4 ++-- engines/wintermute/AdObject.cpp | 2 +- engines/wintermute/AdObject.h | 2 +- engines/wintermute/AdResponseBox.cpp | 2 +- engines/wintermute/AdResponseBox.h | 2 +- engines/wintermute/AdResponseContext.cpp | 2 +- engines/wintermute/AdResponseContext.h | 2 +- engines/wintermute/AdTalkHolder.cpp | 2 +- engines/wintermute/AdTalkHolder.h | 2 +- engines/wintermute/BEvent.cpp | 4 ++-- engines/wintermute/BEvent.h | 4 ++-- engines/wintermute/BFileManager.cpp | 8 ++++---- engines/wintermute/BFileManager.h | 8 ++++---- engines/wintermute/BObject.cpp | 2 +- engines/wintermute/BObject.h | 2 +- engines/wintermute/BPersistMgr.cpp | 2 +- engines/wintermute/BPersistMgr.h | 2 +- engines/wintermute/BScriptHolder.cpp | 2 +- engines/wintermute/BScriptHolder.h | 2 +- engines/wintermute/BScriptable.cpp | 2 +- engines/wintermute/BScriptable.h | 2 +- engines/wintermute/BSprite.h | 2 +- engines/wintermute/UIWindow.cpp | 4 ++-- engines/wintermute/UIWindow.h | 4 ++-- engines/wintermute/scriptables/ScEngine.cpp | 4 ++-- engines/wintermute/scriptables/ScEngine.h | 4 ++-- engines/wintermute/scriptables/ScValue.cpp | 4 ++-- engines/wintermute/scriptables/ScValue.h | 4 ++-- 35 files changed, 55 insertions(+), 55 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index f7203e7d3b..a020556dd7 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -1121,7 +1121,7 @@ char *CAdActor::ScToString() { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStance(char *Stance) { +CBSprite *CAdActor::GetTalkStance(const char *Stance) { // forced stance? if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; @@ -1171,7 +1171,7 @@ CBSprite *CAdActor::GetTalkStance(char *Stance) { } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStanceOld(char *Stance) { +CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { CBSprite *ret = NULL; if (Stance != NULL) { diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index 85b54060c9..7b73131c89 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -49,7 +49,7 @@ public: TDirection AngleToDirection(int Angle); DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) virtual int GetHeight(); - CBSprite *GetTalkStance(char *Stance); + CBSprite *GetTalkStance(const char *Stance); virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); CBPoint *_targetPoint; virtual HRESULT Update(); @@ -88,7 +88,7 @@ public: private: HRESULT SetDefaultAnimNames(); - CBSprite *GetTalkStanceOld(char *Stance); + CBSprite *GetTalkStanceOld(const char *Stance); HRESULT MergeAnims(const char *AnimsFilename); CBSprite *_animSprite2; diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index cce3d5950b..454991af10 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -1330,7 +1330,7 @@ void CAdGame::AfterLoadScene(void *Scene, void *Data) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneName(char *Name) { +void CAdGame::SetPrevSceneName(const char *Name) { delete[] _prevSceneName; _prevSceneName = NULL; if (Name) { @@ -1341,7 +1341,7 @@ void CAdGame::SetPrevSceneName(char *Name) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneFilename(char *Name) { +void CAdGame::SetPrevSceneFilename(const char *Name) { delete[] _prevSceneFilename; _prevSceneFilename = NULL; if (Name) { diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index 1558a2ad0e..fbf94d5275 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -108,8 +108,8 @@ public: HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); char *_scheduledScene; bool _scheduledFadeIn; - void SetPrevSceneName(char *Name); - void SetPrevSceneFilename(char *Name); + void SetPrevSceneName(const char *Name); + void SetPrevSceneFilename(const char *Name); char *_prevSceneName; char *_prevSceneFilename; virtual HRESULT LoadGame(const char *Filename); diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index 82cdb5e349..71f13d7c03 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -745,7 +745,7 @@ HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::GetExtendedFlag(char *FlagName) { +bool CAdItem::GetExtendedFlag(const char *FlagName) { if (!FlagName) return false; else if (strcmp(FlagName, "usable") == 0) return true; else return CAdObject::GetExtendedFlag(FlagName); diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index 46993d935f..56dc7ccbf3 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -47,7 +47,7 @@ public: HRESULT Update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) HRESULT Display(int X, int Y); - bool GetExtendedFlag(char *FlagName); + bool GetExtendedFlag(const char *FlagName); bool _inInventory; bool _cursorCombined; CBSprite *_spriteHover; diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp index f3cdb6cc4d..27c796c77b 100644 --- a/engines/wintermute/AdNodeState.cpp +++ b/engines/wintermute/AdNodeState.cpp @@ -68,7 +68,7 @@ CAdNodeState::~CAdNodeState() { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetName(char *Name) { +void CAdNodeState::SetName(const char *Name) { delete[] _name; _name = NULL; CBUtils::SetString(&_name, Name); @@ -107,7 +107,7 @@ HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCaption(char *Caption, int Case) { +void CAdNodeState::SetCaption(const char *Caption, int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h index 7c959e3168..da8dc541b1 100644 --- a/engines/wintermute/AdNodeState.h +++ b/engines/wintermute/AdNodeState.h @@ -36,7 +36,7 @@ class CAdEntity; class CAdNodeState : public CBBase { public: HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); - void SetName(char *Name); + void SetName(const char *Name); void SetFilename(const char *Filename); void SetCursor(const char *Filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) @@ -45,7 +45,7 @@ public: char *_name; bool _active; char *_caption[7]; - void SetCaption(char *Caption, int Case); + void SetCaption(const char *Caption, int Case); char *GetCaption(int Case); uint32 _alphaColor; char *_filename; diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 38c3336eae..471672e784 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -1004,7 +1004,7 @@ HRESULT CAdObject::ResetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::GetExtendedFlag(char *FlagName) { +bool CAdObject::GetExtendedFlag(const char *FlagName) { if (!FlagName) return false; else if (strcmp(FlagName, "usable") == 0) return true; diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index f229fb7653..e47248dd17 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -64,7 +64,7 @@ public: HRESULT UpdateBlockRegion(); bool _forcedTalkAnimUsed; char *_forcedTalkAnimName; - virtual bool GetExtendedFlag(char *FlagName); + virtual bool GetExtendedFlag(const char *FlagName); virtual HRESULT ResetSoundPan(); virtual HRESULT UpdateSounds(); HRESULT Reset(); diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index d64230ceb7..4d9608ea9a 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -552,7 +552,7 @@ HRESULT CAdResponseBox::WeedResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::SetLastResponseText(char *Text, char *TextOrig) { +void CAdResponseBox::SetLastResponseText(const char *Text, const char *TextOrig) { CBUtils::SetString(&_lastResponseText, Text); CBUtils::SetString(&_lastResponseTextOrig, TextOrig); } diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h index de22874e72..b50d91da03 100644 --- a/engines/wintermute/AdResponseBox.h +++ b/engines/wintermute/AdResponseBox.h @@ -45,7 +45,7 @@ public: HRESULT GetObjects(CBArray& Objects, bool InteractiveOnly); HRESULT HandleResponse(CAdResponse *Response); - void SetLastResponseText(char *Text, char *TextOrig); + void SetLastResponseText(const char *Text, const char *TextOrig); char *_lastResponseText; char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) diff --git a/engines/wintermute/AdResponseContext.cpp b/engines/wintermute/AdResponseContext.cpp index c984ad079c..670604fb68 100644 --- a/engines/wintermute/AdResponseContext.cpp +++ b/engines/wintermute/AdResponseContext.cpp @@ -58,7 +58,7 @@ HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::SetContext(char *Context) { +void CAdResponseContext::SetContext(const char *Context) { delete[] _context; _context = NULL; if (Context) { diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h index c4927a79e9..7ae1b14ed2 100644 --- a/engines/wintermute/AdResponseContext.h +++ b/engines/wintermute/AdResponseContext.h @@ -36,7 +36,7 @@ namespace WinterMute { class CAdResponseContext : public CBBase { public: - void SetContext(char *Context); + void SetContext(const char *Context); int _iD; char *_context; DECLARE_PERSISTENT(CAdResponseContext, CBBase) diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 5cd8432292..7caf639c14 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -61,7 +61,7 @@ CAdTalkHolder::~CAdTalkHolder() { } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::GetTalkStance(char *Stance) { +CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { CBSprite *ret = NULL; diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h index 3b30779de8..2520d17996 100644 --- a/engines/wintermute/AdTalkHolder.h +++ b/engines/wintermute/AdTalkHolder.h @@ -36,7 +36,7 @@ namespace WinterMute { class CAdTalkHolder : public CAdObject { public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *GetTalkStance(char *Stance); + virtual CBSprite *GetTalkStance(const char *Stance); virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); CBSprite *_sprite; CBArray _talkSprites; diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp index 68cc581abf..05876784a1 100644 --- a/engines/wintermute/BEvent.cpp +++ b/engines/wintermute/BEvent.cpp @@ -100,7 +100,7 @@ const char *CBEvent::GetEventName(TEventType Type) { ////////////////////////////////////////////////////////////////////////// -void CBEvent::SetScript(char *Script) { +void CBEvent::SetScript(const char *Script) { if (_script) delete [] _script; _script = new char [strlen(Script) + 1]; @@ -109,7 +109,7 @@ void CBEvent::SetScript(char *Script) { ////////////////////////////////////////////////////////////////////////// -void CBEvent::SetName(char *Name) { +void CBEvent::SetName(const char *Name) { if (_name) delete [] _name; _name = new char [strlen(Name) + 1]; diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h index a1e071fe94..e09f0ff3a8 100644 --- a/engines/wintermute/BEvent.h +++ b/engines/wintermute/BEvent.h @@ -38,8 +38,8 @@ namespace WinterMute { class CBEvent : public CBBase { public: DECLARE_PERSISTENT(CBEvent, CBBase) - void SetScript(char *Script); - void SetName(char *Name); + void SetScript(const char *Script); + void SetName(const char *Name); static const char *GetEventName(TEventType Type); char *_script; char *_name; diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index a3b756eb87..4cfe031090 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -675,7 +675,7 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenPackage(char *Name) { +Common::File *CBFileManager::OpenPackage(const char *Name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -703,7 +703,7 @@ Common::File *CBFileManager::OpenPackage(char *Name) { ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenSingleFile(char *Name) { +Common::File *CBFileManager::OpenSingleFile(const char *Name) { RestoreCurrentDir(); Common::File *ret = NULL; @@ -728,7 +728,7 @@ Common::File *CBFileManager::OpenSingleFile(char *Name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::GetFullPath(char *Filename, char *Fullname) { +bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { RestoreCurrentDir(); FILE *f = NULL; @@ -848,7 +848,7 @@ HRESULT CBFileManager::RestoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SetBasePath(char *Path) { +HRESULT CBFileManager::SetBasePath(const char *Path) { Cleanup(); if (Path) { diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index 7a9593915a..f021afa275 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -45,16 +45,16 @@ class CBFileManager: CBBase { public: bool FindPackageSignature(Common::File *f, uint32 *Offset); HRESULT Cleanup(); - HRESULT SetBasePath(char *Path); + HRESULT SetBasePath(const char *Path); HRESULT RestoreCurrentDir(); char *_basePath; - bool GetFullPath(char *Filename, char *Fullname); + bool GetFullPath(const char *Filename, char *Fullname); CBFile *OpenFileRaw(const char *Filename); HRESULT CloseFile(CBFile *File); CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); CBFileEntry *GetPackageEntry(const char *Filename); - Common::File *OpenSingleFile(char *Name); - Common::File *OpenPackage(char *Name); + Common::File *OpenSingleFile(const char *Name); + Common::File *OpenPackage(const char *Name); HRESULT RegisterPackages(); HRESULT InitPaths(); HRESULT ReloadPaths(); diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 4c63672bc6..eb44636ee9 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -1093,7 +1093,7 @@ HRESULT CBObject::ResetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CBObject::GetExtendedFlag(char *FlagName) { +bool CBObject::GetExtendedFlag(const char *FlagName) { return false; } diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index f896428417..f01d88349f 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -59,7 +59,7 @@ public: float _scaleY; float _relativeScale; virtual bool IsReady(); - virtual bool GetExtendedFlag(char *FlagName); + virtual bool GetExtendedFlag(const char *FlagName); virtual HRESULT ResetSoundPan(); virtual HRESULT UpdateSounds(); HRESULT UpdateOneSound(CBSound *Sound); diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp index 297efeec81..e1e84505ca 100644 --- a/engines/wintermute/BPersistMgr.cpp +++ b/engines/wintermute/BPersistMgr.cpp @@ -107,7 +107,7 @@ uint32 makeUint32(byte first, byte second, byte third, byte fourth) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitSave(char *Desc) { +HRESULT CBPersistMgr::InitSave(const char *Desc) { if (!Desc) return E_FAIL; HRESULT res; diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h index 3f55146ce8..01d2fda40a 100644 --- a/engines/wintermute/BPersistMgr.h +++ b/engines/wintermute/BPersistMgr.h @@ -52,7 +52,7 @@ public: void PutString(const char *Val); void Cleanup(); HRESULT InitLoad(const char *Filename); - HRESULT InitSave(char *Desc); + HRESULT InitSave(const char *Desc); HRESULT GetBytes(byte *Buffer, uint32 Size); HRESULT PutBytes(byte *Buffer, uint32 Size); uint32 _offset; diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index a13ef750e8..a976ae89bb 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -424,7 +424,7 @@ void CBScriptHolder::MakeFreezable(bool Freezable) { ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::InvokeMethodThread(char *MethodName) { +CScScript *CBScriptHolder::InvokeMethodThread(const char *MethodName) { for (int i = _scripts.GetSize() - 1; i >= 0; i--) { if (_scripts[i]->CanHandleMethod(MethodName)) { diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index 2a96817541..1c0842815e 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -41,7 +41,7 @@ public: CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); - virtual CScScript *InvokeMethodThread(char *MethodName); + virtual CScScript *InvokeMethodThread(const char *MethodName); virtual void MakeFreezable(bool Freezable); bool CanHandleEvent(const char *EventName); virtual bool CanHandleMethod(const char *EventMethod); diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index 2f898078c6..5de599525f 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -168,7 +168,7 @@ bool CBScriptable::CanHandleMethod(char *EventMethod) { ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::InvokeMethodThread(char *MethodName) { +CScScript *CBScriptable::InvokeMethodThread(const char *MethodName) { return NULL; } diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index b841d1578d..9b0dcee968 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -42,7 +42,7 @@ class CScScript; class CBScriptable : public CBNamedObject, public IWmeDebugObject { public: - virtual CScScript *InvokeMethodThread(char *MethodName); + virtual CScScript *InvokeMethodThread(const char *MethodName); DECLARE_PERSISTENT(CBScriptable, CBNamedObject) CBScriptable(CBGame *inGame, bool NoValue = false, bool Persistable = true); diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index 983b7bb62f..bec49bc3a4 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -72,7 +72,7 @@ public: HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - HRESULT AddFrame(char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); + HRESULT AddFrame(const char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); CBSprite(CBGame *inGame, CBObject *Owner = NULL); virtual ~CBSprite(); CBArray _frames; diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index e450ae7c0d..f70da3cb1e 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -668,7 +668,7 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::EnableWidget(char *Name, bool Enable) { +HRESULT CUIWindow::EnableWidget(const char *Name, bool Enable) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; } @@ -677,7 +677,7 @@ HRESULT CUIWindow::EnableWidget(char *Name, bool Enable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ShowWidget(char *Name, bool Visible) { +HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; } diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index 46649dda18..e0051e9360 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -62,8 +62,8 @@ public: bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - HRESULT ShowWidget(char *Name, bool Visible = true); - HRESULT EnableWidget(char *Name, bool Enable = true); + HRESULT ShowWidget(const char *Name, bool Visible = true); + HRESULT EnableWidget(const char *Name, bool Enable = true); RECT _titleRect; RECT _dragRect; virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index b5f66bbb14..bfdfb53fa0 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -667,7 +667,7 @@ HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { +HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { if (!Game->GetDebugMgr()->_enabled) return S_OK; CScBreakpoint *Bp = NULL; @@ -694,7 +694,7 @@ HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { +HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { if (!Game->GetDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 6a258688c4..d034bf8ed6 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -96,8 +96,8 @@ public: HRESULT DbgSendScripts(IWmeDebugClient *Client); CBArray _breakpoints; - HRESULT AddBreakpoint(char *ScriptFilename, int Line); - HRESULT RemoveBreakpoint(char *ScriptFilename, int Line); + HRESULT AddBreakpoint(const char *ScriptFilename, int Line); + HRESULT RemoveBreakpoint(const char *ScriptFilename, int Line); HRESULT RefreshScriptBreakpoints(); HRESULT RefreshScriptBreakpoints(CScScript *Script); HRESULT SaveBreakpoints(); diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 250a61ad67..3576c0a618 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -188,7 +188,7 @@ CScValue *CScValue::GetProp(const char *Name) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DeleteProp(char *Name) { +HRESULT CScValue::DeleteProp(const char *Name) { if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(Name); _valIter = _valObject.find(Name); @@ -247,7 +247,7 @@ HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool ////////////////////////////////////////////////////////////////////////// -bool CScValue::PropExists(char *Name) { +bool CScValue::PropExists(const char *Name) { if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(Name); _valIter = _valObject.find(Name); diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 8696808ad4..7c87c8e707 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -57,7 +57,7 @@ public: HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); void SetValue(CScValue *Val); bool _persistent; - bool PropExists(char *Name); + bool PropExists(const char *Name); void Copy(CScValue *orig, bool CopyWhole = false); void SetStringVal(const char *Val); TValType GetType(); @@ -67,7 +67,7 @@ public: const char *GetString(); void *GetMemBuffer(); CBScriptable *GetNative(); - HRESULT DeleteProp(char *Name); + HRESULT DeleteProp(const char *Name); void DeleteProps(); void CleanProps(bool IncludingNatives); void SetBool(bool Val); -- cgit v1.2.3 From 2ee58d2dc3f78e03f25edf7103403ee06ba9ab7a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 15:24:49 +0200 Subject: WINTERMUTE: Add const to even more char* (Possibly the last ones) --- engines/wintermute/AdActor.cpp | 6 +++--- engines/wintermute/AdActor.h | 6 +++--- engines/wintermute/AdEntity.cpp | 6 +++--- engines/wintermute/AdEntity.h | 6 +++--- engines/wintermute/AdGame.cpp | 10 +++++----- engines/wintermute/AdGame.h | 10 +++++----- engines/wintermute/AdItem.cpp | 6 +++--- engines/wintermute/AdItem.h | 6 +++--- engines/wintermute/AdLayer.cpp | 6 +++--- engines/wintermute/AdLayer.h | 6 +++--- engines/wintermute/AdObject.cpp | 6 +++--- engines/wintermute/AdObject.h | 6 +++--- engines/wintermute/AdRegion.cpp | 6 +++--- engines/wintermute/AdRegion.h | 6 +++--- engines/wintermute/AdScene.cpp | 6 +++--- engines/wintermute/AdScene.h | 6 +++--- engines/wintermute/AdTalkHolder.cpp | 6 +++--- engines/wintermute/AdTalkHolder.h | 6 +++--- engines/wintermute/AdWaypointGroup.cpp | 4 ++-- engines/wintermute/AdWaypointGroup.h | 4 ++-- engines/wintermute/BFrame.cpp | 6 +++--- engines/wintermute/BFrame.h | 6 +++--- engines/wintermute/BGame.cpp | 8 ++++---- engines/wintermute/BGame.h | 8 ++++---- engines/wintermute/BKeyboardState.cpp | 6 +++--- engines/wintermute/BKeyboardState.h | 6 +++--- engines/wintermute/BObject.cpp | 6 +++--- engines/wintermute/BObject.h | 6 +++--- engines/wintermute/BRegion.cpp | 6 +++--- engines/wintermute/BRegion.h | 6 +++--- engines/wintermute/BScriptHolder.cpp | 6 +++--- engines/wintermute/BScriptHolder.h | 6 +++--- engines/wintermute/BScriptable.cpp | 2 +- engines/wintermute/BScriptable.h | 2 +- engines/wintermute/BSprite.cpp | 6 +++--- engines/wintermute/BSprite.h | 6 +++--- engines/wintermute/BSubFrame.cpp | 6 +++--- engines/wintermute/BSubFrame.h | 6 +++--- engines/wintermute/PartEmitter.cpp | 6 +++--- engines/wintermute/PartEmitter.h | 6 +++--- engines/wintermute/UIButton.cpp | 6 +++--- engines/wintermute/UIButton.h | 6 +++--- engines/wintermute/UIEdit.cpp | 6 +++--- engines/wintermute/UIEdit.h | 6 +++--- engines/wintermute/UIEntity.cpp | 6 +++--- engines/wintermute/UIEntity.h | 6 +++--- engines/wintermute/UIObject.cpp | 6 +++--- engines/wintermute/UIObject.h | 6 +++--- engines/wintermute/UIText.cpp | 6 +++--- engines/wintermute/UIText.h | 6 +++--- engines/wintermute/UIWindow.cpp | 6 +++--- engines/wintermute/UIWindow.h | 6 +++--- engines/wintermute/scriptables/SXArray.cpp | 6 +++--- engines/wintermute/scriptables/SXArray.h | 6 +++--- engines/wintermute/scriptables/SXDate.cpp | 6 +++--- engines/wintermute/scriptables/SXDate.h | 6 +++--- engines/wintermute/scriptables/SXFile.cpp | 6 +++--- engines/wintermute/scriptables/SXFile.h | 6 +++--- engines/wintermute/scriptables/SXMath.cpp | 4 ++-- engines/wintermute/scriptables/SXMath.h | 4 ++-- engines/wintermute/scriptables/SXMemBuffer.cpp | 6 +++--- engines/wintermute/scriptables/SXMemBuffer.h | 6 +++--- engines/wintermute/scriptables/SXStore.cpp | 4 ++-- engines/wintermute/scriptables/SXStore.h | 4 ++-- engines/wintermute/scriptables/SXString.cpp | 6 +++--- engines/wintermute/scriptables/SXString.h | 6 +++--- 66 files changed, 194 insertions(+), 194 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index a020556dd7..d957d08b8c 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -870,7 +870,7 @@ void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// @@ -993,7 +993,7 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::ScGetProperty(char *Name) { +CScValue *CAdActor::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1055,7 +1055,7 @@ CScValue *CAdActor::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index 7b73131c89..d1c44b8948 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -81,9 +81,9 @@ public: CAdSpriteSet *GetAnimByName(const char *AnimName); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); private: diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index 1566ad8bbd..91f7bfeace 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -590,7 +590,7 @@ HRESULT CAdEntity::Update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// @@ -697,7 +697,7 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::ScGetProperty(char *Name) { +CScValue *CAdEntity::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -768,7 +768,7 @@ CScValue *CAdEntity::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Item diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h index 1ee0e75fe4..ac93a05d87 100644 --- a/engines/wintermute/AdEntity.h +++ b/engines/wintermute/AdEntity.h @@ -55,9 +55,9 @@ public: TEntityType _subtype; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index 454991af10..ff190dff98 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -313,7 +313,7 @@ void CAdGame::FinishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// @@ -794,7 +794,7 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::ScGetProperty(char *Name) { +CScValue *CAdGame::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -948,7 +948,7 @@ CScValue *CAdGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem @@ -1450,7 +1450,7 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { ////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::GetSceneState(char *Filename, bool Saving) { +CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { char *FilenameCor = new char[strlen(Filename) + 1]; strcpy(FilenameCor, Filename); for (int i = 0; i < strlen(FilenameCor); i++) { @@ -1514,7 +1514,7 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name) { +HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { if (strcmp(Name, "CreateEntityContainer") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index fbf94d5275..748fda145a 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -93,9 +93,9 @@ public: HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); - CAdSceneState *GetSceneState(char *Filename, bool Saving); + CAdSceneState *GetSceneState(const char *Filename, bool Saving); CBViewport *_sceneViewport; int _texItemLifeTime; int _texWalkLifeTime; @@ -151,9 +151,9 @@ public: virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); bool ValidMouse(); }; diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index 71f13d7c03..cc88b8bb3c 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -428,7 +428,7 @@ HRESULT CAdItem::Display(int X, int Y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// @@ -566,7 +566,7 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::ScGetProperty(char *Name) { +CScValue *CAdItem::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -647,7 +647,7 @@ CScValue *CAdItem::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index 56dc7ccbf3..b5af924092 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -59,9 +59,9 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 744e278115..023379d142 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -227,7 +227,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// @@ -357,7 +357,7 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::ScGetProperty(char *Name) { +CScValue *CAdLayer::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -421,7 +421,7 @@ CScValue *CAdLayer::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index 48b9cfdc27..6de980d0a5 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -47,9 +47,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 471672e784..2908cee79e 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -179,7 +179,7 @@ HRESULT CAdObject::Update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync @@ -599,7 +599,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::ScGetProperty(char *Name) { +CScValue *CAdObject::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -706,7 +706,7 @@ CScValue *CAdObject::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index e47248dd17..e017b979e0 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -99,9 +99,9 @@ public: CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); CBArray _attachmentsPre; diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index 81cb8fc72e..17917066f1 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -221,7 +221,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -240,7 +240,7 @@ HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::ScGetProperty(char *Name) { +CScValue *CAdRegion::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -296,7 +296,7 @@ CScValue *CAdRegion::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index 896db1f772..0af1c743fe 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -47,9 +47,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index b8ee74eb71..4cd4ea1082 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -1246,7 +1246,7 @@ void CAdScene::SkipTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// @@ -1677,7 +1677,7 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::ScGetProperty(char *Name) { +CScValue *CAdScene::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1840,7 +1840,7 @@ CScValue *CAdScene::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index cfedc8a911..5aa2e9ffb0 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -156,9 +156,9 @@ public: int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 7caf639c14..6773626523 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -117,7 +117,7 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// @@ -288,7 +288,7 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::ScGetProperty(char *Name) { +CScValue *CAdTalkHolder::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -304,7 +304,7 @@ CScValue *CAdTalkHolder::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Item diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h index 2520d17996..e6d4c322eb 100644 --- a/engines/wintermute/AdTalkHolder.h +++ b/engines/wintermute/AdTalkHolder.h @@ -45,9 +45,9 @@ public: virtual ~CAdTalkHolder(); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index a4f630c572..865279a57e 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -198,7 +198,7 @@ HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::ScGetProperty(char *Name) { +CScValue *CAdWaypointGroup::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -222,7 +222,7 @@ CScValue *CAdWaypointGroup::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CAdWaypointGroup::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h index de28f3fbf4..66fbcfa0e1 100644 --- a/engines/wintermute/AdWaypointGroup.h +++ b/engines/wintermute/AdWaypointGroup.h @@ -49,8 +49,8 @@ public: virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index c18d6a55a7..08a0e73f72 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -401,7 +401,7 @@ HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -573,7 +573,7 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::ScGetProperty(char *Name) { +CScValue *CBFrame::ScGetProperty(const char *Name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); @@ -650,7 +650,7 @@ CScValue *CBFrame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h index 279dcd2289..b236e60172 100644 --- a/engines/wintermute/BFrame.h +++ b/engines/wintermute/BFrame.h @@ -61,9 +61,9 @@ public: CBArray _applyEvent; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index eee7d5299a..0a7885b7e1 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -968,7 +968,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -2094,7 +2094,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::ScGetProperty(char *Name) { +CScValue *CBGame::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -2485,7 +2485,7 @@ CScValue *CBGame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -3966,7 +3966,7 @@ HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name) { +HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { return E_FAIL; } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index cdc937afb9..145af7c3f2 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -226,9 +226,9 @@ public: virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); // compatibility bits bool _compatKillMethodThreads; @@ -331,7 +331,7 @@ public: int _subtitlesSpeed; void SetInteractive(bool State); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, char *Name); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); HRESULT PopViewport(); diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 7499ca70df..7a4c246899 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -58,7 +58,7 @@ CBKeyboardState::~CBKeyboardState() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// @@ -88,7 +88,7 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta ////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::ScGetProperty(char *Name) { +CScValue *CBKeyboardState::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -158,7 +158,7 @@ CScValue *CBKeyboardState::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index 393f93d7da..956765b4a9 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -57,9 +57,9 @@ public: static bool IsAltDown(); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); private: diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index eb44636ee9..389953ad14 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -165,7 +165,7 @@ HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -473,7 +473,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::ScGetProperty(char *Name) { +CScValue *CBObject::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -666,7 +666,7 @@ CScValue *CBObject::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index f01d88349f..9908d03e3b 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -134,9 +134,9 @@ public: public: // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 9190955321..23071f51a6 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -209,7 +209,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -309,7 +309,7 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::ScGetProperty(char *Name) { +CScValue *CBRegion::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -349,7 +349,7 @@ CScValue *CBRegion::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index 783cb22965..79af62bcae 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -57,9 +57,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride = NULL); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index a976ae89bb..6210ba2f38 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -106,7 +106,7 @@ HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::ScGetProperty(char *Name) { +CScValue *CBScriptHolder::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -237,7 +237,7 @@ CScValue *CBScriptHolder::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBScriptHolder::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index 1c0842815e..2447bf17d6 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -59,9 +59,9 @@ public: CBArray _scripts; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); virtual void ScDebuggerDesc(char *Buf, int BufSize); // IWmeObject diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index 5de599525f..2ced86b1cf 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -61,7 +61,7 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { /* Stack->CorrectParams(0); Stack->PushNULL(); diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index 9b0dcee968..a0142e00ba 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -52,7 +52,7 @@ public: virtual bool CanHandleMethod(char *EventMethod); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); virtual void *ScToMemBuffer(); virtual int ScToInt(); diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index f84f2f945a..e8e9402fe7 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -506,7 +506,7 @@ HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -630,7 +630,7 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::ScGetProperty(char *Name) { +CScValue *CBSprite::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -703,7 +703,7 @@ CScValue *CBSprite::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index bec49bc3a4..18731b682e 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -79,9 +79,9 @@ public: HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index e8abd11927..cea9d93257 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -342,7 +342,7 @@ HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -383,7 +383,7 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T ////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::ScGetProperty(char *Name) { +CScValue *CBSubFrame::ScGetProperty(const char *Name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); @@ -473,7 +473,7 @@ CScValue *CBSubFrame::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h index 3c0a91344d..04be4e86c8 100644 --- a/engines/wintermute/BSubFrame.h +++ b/engines/wintermute/BSubFrame.h @@ -73,9 +73,9 @@ public: CBSurface *_surface; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index 49bfe67666..6500f172c8 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -411,7 +411,7 @@ HRESULT CPartEmitter::RemoveForce(const char *Name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -557,7 +557,7 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack } ////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::ScGetProperty(char *Name) { +CScValue *CPartEmitter::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -829,7 +829,7 @@ CScValue *CPartEmitter::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h index 92f6a608bf..0949c294c3 100644 --- a/engines/wintermute/PartEmitter.h +++ b/engines/wintermute/PartEmitter.h @@ -115,9 +115,9 @@ public: CBArray _forces; // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index 4b5dde50fe..988760f567 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -663,7 +663,7 @@ void CUIButton::Press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// @@ -918,7 +918,7 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::ScGetProperty(char *Name) { +CScValue *CUIButton::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -964,7 +964,7 @@ CScValue *CUIButton::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index 9d1134fdf9..a07b2adce6 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -68,9 +68,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 3f81b16395..3c2abebd33 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -361,7 +361,7 @@ HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// @@ -380,7 +380,7 @@ HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::ScGetProperty(char *Name) { +CScValue *CUIEdit::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -457,7 +457,7 @@ CScValue *CUIEdit::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index 4d000d5954..05c6f14973 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -61,9 +61,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index 15d36c3d3d..ca4528e6cf 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -251,7 +251,7 @@ HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// @@ -285,7 +285,7 @@ HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::ScGetProperty(char *Name) { +CScValue *CUIEntity::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -310,7 +310,7 @@ CScValue *CUIEntity::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIEntity::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h index ab3e74f9e6..3b8107b5d7 100644 --- a/engines/wintermute/UIEntity.h +++ b/engines/wintermute/UIEntity.h @@ -47,9 +47,9 @@ public: HRESULT SetEntity(const char *Filename); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index 75939c5bf6..8a25c56cf5 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -137,7 +137,7 @@ void CUIObject::CorrectSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// @@ -317,7 +317,7 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::ScGetProperty(char *Name) { +CScValue *CUIObject::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -418,7 +418,7 @@ CScValue *CUIObject::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h index bf6b1b079a..6646887a2c 100644 --- a/engines/wintermute/UIObject.h +++ b/engines/wintermute/UIObject.h @@ -72,9 +72,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index b00e652b0a..d0770224c5 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -371,7 +371,7 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// @@ -397,7 +397,7 @@ HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::ScGetProperty(char *Name) { +CScValue *CUIText::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -429,7 +429,7 @@ CScValue *CUIText::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h index 7f89fb6b30..aef5ea1be7 100644 --- a/engines/wintermute/UIText.h +++ b/engines/wintermute/UIText.h @@ -48,9 +48,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index f70da3cb1e..db5e91a23c 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -688,7 +688,7 @@ HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// @@ -915,7 +915,7 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::ScGetProperty(char *Name) { +CScValue *CUIWindow::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1003,7 +1003,7 @@ CScValue *CUIWindow::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index e0051e9360..e2a134282d 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -81,9 +81,9 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScSetProperty(char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); virtual char *ScToString(); }; diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 978de4ae52..77a90b7f12 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -89,7 +89,7 @@ char *CSXArray::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -130,7 +130,7 @@ HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::ScGetProperty(char *Name) { +CScValue *CSXArray::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -162,7 +162,7 @@ CScValue *CSXArray::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h index 0605d6c4f8..8907ec2602 100644 --- a/engines/wintermute/scriptables/SXArray.h +++ b/engines/wintermute/scriptables/SXArray.h @@ -41,9 +41,9 @@ public: CSXArray(CBGame *inGame, CScStack *Stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); - CScValue *ScGetProperty(char *Name); - HRESULT ScSetProperty(char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); char *ScToString(); int _length; CScValue *_values; diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index 65e6a43782..193521d44d 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -72,7 +72,7 @@ char *CSXDate::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { #if 0 ////////////////////////////////////////////////////////////////////////// // GetYear @@ -214,7 +214,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::ScGetProperty(char *Name) { +CScValue *CSXDate::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -230,7 +230,7 @@ CScValue *CSXDate::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h index 677b7e7dd1..ca9744e6ab 100644 --- a/engines/wintermute/scriptables/SXDate.h +++ b/engines/wintermute/scriptables/SXDate.h @@ -40,9 +40,9 @@ public: DECLARE_PERSISTENT(CSXDate, CBScriptable) CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); - CScValue *ScGetProperty(char *Name); - HRESULT ScSetProperty(char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); char *ScToString(); char *_string; //struct tm _tm; // TODO! diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index a24615e01d..fa860e56b6 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -90,7 +90,7 @@ char *CSXFile::ScToString() { #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -570,7 +570,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::ScGetProperty(char *Name) { +CScValue *CSXFile::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -626,7 +626,7 @@ CScValue *CSXFile::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h index 085700d0e1..22bfc5ec70 100644 --- a/engines/wintermute/scriptables/SXFile.h +++ b/engines/wintermute/scriptables/SXFile.h @@ -36,9 +36,9 @@ class CBFile; class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *ScGetProperty(char *Name); - HRESULT ScSetProperty(char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); char *ScToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); diff --git a/engines/wintermute/scriptables/SXMath.cpp b/engines/wintermute/scriptables/SXMath.cpp index fcc85d527c..bcd2e96495 100644 --- a/engines/wintermute/scriptables/SXMath.cpp +++ b/engines/wintermute/scriptables/SXMath.cpp @@ -54,7 +54,7 @@ CSXMath::~CSXMath() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// @@ -245,7 +245,7 @@ HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::ScGetProperty(char *Name) { +CScValue *CSXMath::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/scriptables/SXMath.h b/engines/wintermute/scriptables/SXMath.h index a8c34e954e..3169990159 100644 --- a/engines/wintermute/scriptables/SXMath.h +++ b/engines/wintermute/scriptables/SXMath.h @@ -39,8 +39,8 @@ public: DECLARE_PERSISTENT(CSXMath, CBScriptable) CSXMath(CBGame *inGame); virtual ~CSXMath(); - virtual CScValue *ScGetProperty(char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); private: double DegreeToRadian(double Value); diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index d1c4242ae8..93d8e2e23b 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -117,7 +117,7 @@ char *CSXMemBuffer::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -400,7 +400,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::ScGetProperty(char *Name) { +CScValue *CSXMemBuffer::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -424,7 +424,7 @@ CScValue *CSXMemBuffer::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h index 715d860302..9c6553bd89 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.h +++ b/engines/wintermute/scriptables/SXMemBuffer.h @@ -38,9 +38,9 @@ class CSXMemBuffer : public CBScriptable { public: virtual int ScCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *ScGetProperty(char *Name); - HRESULT ScSetProperty(char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); char *ScToString(); CSXMemBuffer(CBGame *inGame, CScStack *Stack); CSXMemBuffer(CBGame *inGame, void *Buffer); diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index f24896f611..79a4f9bbc0 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -77,7 +77,7 @@ void CSXStore::Cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { +HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // EnableEvents ////////////////////////////////////////////////////////////////////////// @@ -220,7 +220,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// -CScValue *CSXStore::ScGetProperty(char *name) { +CScValue *CSXStore::ScGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/scriptables/SXStore.h b/engines/wintermute/scriptables/SXStore.h index dd11416a0f..8c921958f8 100644 --- a/engines/wintermute/scriptables/SXStore.h +++ b/engines/wintermute/scriptables/SXStore.h @@ -126,8 +126,8 @@ public: DECLARE_PERSISTENT(CSXStore, CBObject) CSXStore(CBGame *inGame); virtual ~CSXStore(); - virtual CScValue *ScGetProperty(char *name); - virtual HRESULT ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); void AfterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index b2e5faf1db..d9e1c246c4 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -91,7 +91,7 @@ void CSXString::ScSetString(const char *Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -304,7 +304,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::ScGetProperty(char *Name) { +CScValue *CSXString::ScGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -339,7 +339,7 @@ CScValue *CSXString::ScGetProperty(char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScSetProperty(char *Name, CScValue *Value) { +HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h index 1cd3a7f52c..8abddf244d 100644 --- a/engines/wintermute/scriptables/SXString.h +++ b/engines/wintermute/scriptables/SXString.h @@ -38,9 +38,9 @@ class CSXString : public CBScriptable { public: virtual int ScCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *ScGetProperty(char *Name); - HRESULT ScSetProperty(char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); void ScSetString(const char *Val); char *ScToString(); void SetStringVal(const char *Val); -- cgit v1.2.3 From ba6a2ac66ea3e679246a28e81013f7c4794ed564 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 16:03:59 +0200 Subject: WINTERMUTE: Run Astyle on code-files to reformat. --- engines/wintermute/AdActor.cpp | 18 +- engines/wintermute/AdActor.h | 4 +- engines/wintermute/AdActorDir.cpp | 4 +- engines/wintermute/AdActorDir.h | 4 +- engines/wintermute/AdEntity.cpp | 18 +- engines/wintermute/AdEntity.h | 4 +- engines/wintermute/AdGame.cpp | 10 +- engines/wintermute/AdGame.h | 4 +- engines/wintermute/AdInventory.cpp | 6 +- engines/wintermute/AdInventory.h | 4 +- engines/wintermute/AdInventoryBox.cpp | 4 +- engines/wintermute/AdInventoryBox.h | 4 +- engines/wintermute/AdItem.cpp | 8 +- engines/wintermute/AdItem.h | 4 +- engines/wintermute/AdLayer.cpp | 6 +- engines/wintermute/AdLayer.h | 4 +- engines/wintermute/AdNodeState.cpp | 4 +- engines/wintermute/AdNodeState.h | 4 +- engines/wintermute/AdObject.cpp | 6 +- engines/wintermute/AdObject.h | 4 +- engines/wintermute/AdPath.cpp | 4 +- engines/wintermute/AdPath.h | 4 +- engines/wintermute/AdPathPoint.cpp | 4 +- engines/wintermute/AdPathPoint.h | 4 +- engines/wintermute/AdRegion.cpp | 4 +- engines/wintermute/AdRegion.h | 4 +- engines/wintermute/AdResponse.cpp | 4 +- engines/wintermute/AdResponse.h | 4 +- engines/wintermute/AdResponseBox.cpp | 6 +- engines/wintermute/AdResponseBox.h | 6 +- engines/wintermute/AdResponseContext.cpp | 4 +- engines/wintermute/AdResponseContext.h | 4 +- engines/wintermute/AdRotLevel.cpp | 4 +- engines/wintermute/AdRotLevel.h | 4 +- engines/wintermute/AdScaleLevel.cpp | 4 +- engines/wintermute/AdScaleLevel.h | 4 +- engines/wintermute/AdScene.cpp | 8 +- engines/wintermute/AdScene.h | 8 +- engines/wintermute/AdSceneNode.cpp | 4 +- engines/wintermute/AdSceneNode.h | 4 +- engines/wintermute/AdSceneState.cpp | 4 +- engines/wintermute/AdSceneState.h | 4 +- engines/wintermute/AdSentence.cpp | 6 +- engines/wintermute/AdSentence.h | 4 +- engines/wintermute/AdSpriteSet.cpp | 4 +- engines/wintermute/AdSpriteSet.h | 4 +- engines/wintermute/AdTalkDef.cpp | 4 +- engines/wintermute/AdTalkDef.h | 4 +- engines/wintermute/AdTalkHolder.cpp | 4 +- engines/wintermute/AdTalkHolder.h | 4 +- engines/wintermute/AdTalkNode.cpp | 4 +- engines/wintermute/AdTalkNode.h | 4 +- engines/wintermute/AdTypes.h | 4 +- engines/wintermute/AdWaypointGroup.cpp | 6 +- engines/wintermute/AdWaypointGroup.h | 4 +- engines/wintermute/BActiveRect.cpp | 4 +- engines/wintermute/BActiveRect.h | 4 +- engines/wintermute/BBase.cpp | 6 +- engines/wintermute/BBase.h | 8 +- engines/wintermute/BDebugger.cpp | 4 +- engines/wintermute/BDebugger.h | 4 +- engines/wintermute/BDiskFile.cpp | 20 +- engines/wintermute/BDiskFile.h | 6 +- engines/wintermute/BDynBuffer.cpp | 16 +- engines/wintermute/BDynBuffer.h | 4 +- engines/wintermute/BEvent.cpp | 4 +- engines/wintermute/BEvent.h | 4 +- engines/wintermute/BFader.cpp | 6 +- engines/wintermute/BFader.h | 4 +- engines/wintermute/BFile.cpp | 4 +- engines/wintermute/BFile.h | 6 +- engines/wintermute/BFileEntry.cpp | 4 +- engines/wintermute/BFileEntry.h | 4 +- engines/wintermute/BFileManager.cpp | 112 +++++----- engines/wintermute/BFileManager.h | 6 +- engines/wintermute/BFont.cpp | 4 +- engines/wintermute/BFont.h | 4 +- engines/wintermute/BFontBitmap.cpp | 16 +- engines/wintermute/BFontBitmap.h | 4 +- engines/wintermute/BFontStorage.cpp | 4 +- engines/wintermute/BFontStorage.h | 10 +- engines/wintermute/BFontTT.cpp | 58 ++--- engines/wintermute/BFontTT.h | 8 +- engines/wintermute/BFrame.cpp | 8 +- engines/wintermute/BFrame.h | 4 +- engines/wintermute/BGame.cpp | 62 +++--- engines/wintermute/BGame.h | 6 +- engines/wintermute/BImage.h | 4 +- engines/wintermute/BKeyboardState.cpp | 4 +- engines/wintermute/BKeyboardState.h | 4 +- engines/wintermute/BNamedObject.cpp | 4 +- engines/wintermute/BNamedObject.h | 4 +- engines/wintermute/BObject.cpp | 6 +- engines/wintermute/BObject.h | 4 +- engines/wintermute/BPackage.cpp | 6 +- engines/wintermute/BPackage.h | 8 +- engines/wintermute/BParser.cpp | 6 +- engines/wintermute/BParser.h | 4 +- engines/wintermute/BPersistMgr.cpp | 62 +++--- engines/wintermute/BPersistMgr.h | 4 +- engines/wintermute/BPkgFile.cpp | 8 +- engines/wintermute/BPkgFile.h | 8 +- engines/wintermute/BPoint.cpp | 4 +- engines/wintermute/BPoint.h | 4 +- engines/wintermute/BQuickMsg.cpp | 4 +- engines/wintermute/BQuickMsg.h | 4 +- engines/wintermute/BRegion.cpp | 4 +- engines/wintermute/BRegion.h | 4 +- engines/wintermute/BRegistry.cpp | 4 +- engines/wintermute/BRegistry.h | 4 +- engines/wintermute/BRenderSDL.cpp | 34 +-- engines/wintermute/BRenderSDL.h | 10 +- engines/wintermute/BRenderer.cpp | 4 +- engines/wintermute/BRenderer.h | 4 +- engines/wintermute/BResourceFile.cpp | 6 +- engines/wintermute/BResourceFile.h | 4 +- engines/wintermute/BResources.cpp | 6 +- engines/wintermute/BResources.h | 6 +- engines/wintermute/BSaveThumbFile.cpp | 6 +- engines/wintermute/BSaveThumbFile.h | 4 +- engines/wintermute/BSaveThumbHelper.cpp | 4 +- engines/wintermute/BSaveThumbHelper.h | 4 +- engines/wintermute/BScriptHolder.h | 4 +- engines/wintermute/BScriptable.cpp | 4 +- engines/wintermute/BScriptable.h | 4 +- engines/wintermute/BSound.cpp | 6 +- engines/wintermute/BSound.h | 4 +- engines/wintermute/BSoundBuffer.cpp | 8 +- engines/wintermute/BSoundBuffer.h | 8 +- engines/wintermute/BSoundMgr.cpp | 6 +- engines/wintermute/BSoundMgr.h | 4 +- engines/wintermute/BSprite.cpp | 4 +- engines/wintermute/BSprite.h | 4 +- engines/wintermute/BStringTable.cpp | 4 +- engines/wintermute/BStringTable.h | 4 +- engines/wintermute/BSubFrame.cpp | 6 +- engines/wintermute/BSubFrame.h | 4 +- engines/wintermute/BSurface.cpp | 4 +- engines/wintermute/BSurface.h | 4 +- engines/wintermute/BSurfaceSDL.cpp | 66 +++--- engines/wintermute/BSurfaceSDL.h | 10 +- engines/wintermute/BSurfaceStorage.cpp | 4 +- engines/wintermute/BSurfaceStorage.h | 4 +- engines/wintermute/BTransitionMgr.cpp | 4 +- engines/wintermute/BTransitionMgr.h | 4 +- engines/wintermute/BViewport.cpp | 4 +- engines/wintermute/BViewport.h | 4 +- engines/wintermute/FontGlyphCache.cpp | 8 +- engines/wintermute/Matrix4.h | 16 +- engines/wintermute/PartParticle.cpp | 10 +- engines/wintermute/PathUtil.cpp | 6 +- engines/wintermute/PathUtil.h | 4 +- engines/wintermute/PlatformSDL.cpp | 98 ++++---- engines/wintermute/PlatformSDL.h | 4 +- engines/wintermute/StringUtil.cpp | 296 ++++++++++++------------- engines/wintermute/StringUtil.h | 4 +- engines/wintermute/SysClass.cpp | 24 +- engines/wintermute/SysClass.h | 10 +- engines/wintermute/SysClassRegistry.cpp | 4 +- engines/wintermute/SysClassRegistry.h | 12 +- engines/wintermute/SysInstance.cpp | 4 +- engines/wintermute/SysInstance.h | 4 +- engines/wintermute/UIButton.cpp | 12 +- engines/wintermute/UIButton.h | 4 +- engines/wintermute/UIEdit.cpp | 34 +-- engines/wintermute/UIEdit.h | 4 +- engines/wintermute/UIEntity.cpp | 4 +- engines/wintermute/UIEntity.h | 4 +- engines/wintermute/UIObject.cpp | 4 +- engines/wintermute/UIObject.h | 4 +- engines/wintermute/UIText.cpp | 16 +- engines/wintermute/UIText.h | 4 +- engines/wintermute/UITiledImage.cpp | 4 +- engines/wintermute/UITiledImage.h | 4 +- engines/wintermute/UIWindow.cpp | 10 +- engines/wintermute/UIWindow.h | 6 +- engines/wintermute/coll_templ.h | 12 +- engines/wintermute/crc.cpp | 2 +- engines/wintermute/dcgf.h | 4 +- engines/wintermute/dcpackage.h | 2 +- engines/wintermute/dcscript.h | 4 +- engines/wintermute/dctypes.h | 8 +- engines/wintermute/detection.cpp | 28 +-- engines/wintermute/persistent.h | 92 ++++---- engines/wintermute/scriptables/SXArray.cpp | 4 +- engines/wintermute/scriptables/SXArray.h | 4 +- engines/wintermute/scriptables/SXDate.cpp | 4 +- engines/wintermute/scriptables/SXDate.h | 4 +- engines/wintermute/scriptables/SXFile.cpp | 14 +- engines/wintermute/scriptables/SXMath.cpp | 4 +- engines/wintermute/scriptables/SXMath.h | 4 +- engines/wintermute/scriptables/SXMemBuffer.cpp | 44 ++-- engines/wintermute/scriptables/SXMemBuffer.h | 4 +- engines/wintermute/scriptables/SXString.cpp | 52 ++--- engines/wintermute/scriptables/SXString.h | 6 +- engines/wintermute/scriptables/ScEngine.cpp | 34 +-- engines/wintermute/scriptables/ScEngine.h | 4 +- engines/wintermute/scriptables/ScScript.cpp | 10 +- engines/wintermute/scriptables/ScScript.h | 4 +- engines/wintermute/scriptables/ScStack.cpp | 4 +- engines/wintermute/scriptables/ScStack.h | 4 +- engines/wintermute/scriptables/ScValue.cpp | 4 +- engines/wintermute/scriptables/ScValue.h | 4 +- engines/wintermute/utils.cpp | 6 +- engines/wintermute/utils.h | 4 +- engines/wintermute/wintermute.cpp | 160 ++++++------- engines/wintermute/wintermute.h | 68 +++--- engines/wintermute/wintypes.h | 4 +- engines/wintermute/wme_debugger.h | 4 +- 209 files changed, 1186 insertions(+), 1182 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index d957d08b8c..dff70dc3e9 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -8,12 +8,12 @@ * 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. @@ -550,13 +550,13 @@ HRESULT CAdActor::Display() { if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; _currentSprite->Display(_posX, - _posY, - Reg ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); + _posY, + Reg ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); } diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index d1c44b8948..c1e41237ee 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdActorDir.cpp b/engines/wintermute/AdActorDir.cpp index bd888ccb03..6966c5fc1b 100644 --- a/engines/wintermute/AdActorDir.cpp +++ b/engines/wintermute/AdActorDir.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdActorDir.h b/engines/wintermute/AdActorDir.h index 6690796e5c..d4889f83fc 100644 --- a/engines/wintermute/AdActorDir.h +++ b/engines/wintermute/AdActorDir.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index 91f7bfeace..0fb9d3b21b 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -8,12 +8,12 @@ * 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. @@ -492,13 +492,13 @@ HRESULT CAdEntity::Display() { DisplaySpriteAttachments(true); if (_currentSprite) { _currentSprite->Display(_posX, - _posY, - (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); + _posY, + (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); } DisplaySpriteAttachments(false); diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h index ac93a05d87..c63da505ce 100644 --- a/engines/wintermute/AdEntity.h +++ b/engines/wintermute/AdEntity.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index ff190dff98..fc1435d1cb 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -8,12 +8,12 @@ * 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. @@ -1492,7 +1492,7 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { switch (cmd) { case TOKEN_ENTITY_CONTAINER: { CUIEntity *ent = new CUIEntity(Game); - if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { + if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { delete ent; ent = NULL; cmd = PARSERR_GENERIC; @@ -2038,10 +2038,10 @@ HRESULT CAdGame::DisplayDebugInfo() { char str[100]; if (Game->_dEBUG_DebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->GetOffsetLeft(), _mousePos.y + _scene->GetOffsetTop()); - _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } return CBGame::DisplayDebugInfo(); } diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index 748fda145a..e74793c8a0 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp index 735b9a542e..7fcd955560 100644 --- a/engines/wintermute/AdInventory.cpp +++ b/engines/wintermute/AdInventory.cpp @@ -8,12 +8,12 @@ * 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. @@ -115,5 +115,5 @@ HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { return S_OK; } - + } // end of namespace WinterMute diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h index 2012054217..f85fc093eb 100644 --- a/engines/wintermute/AdInventory.h +++ b/engines/wintermute/AdInventory.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index 6c093941bf..6429179f50 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h index 3606e96123..edfada69a1 100644 --- a/engines/wintermute/AdInventoryBox.h +++ b/engines/wintermute/AdInventoryBox.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index cc88b8bb3c..448fed3dc7 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -8,12 +8,12 @@ * 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. @@ -412,11 +412,11 @@ HRESULT CAdItem::Display(int X, int Y) { CBFont *Font = _font ? _font : Game->_systemFont; if (Font) { - if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); + if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); else { char Str[256]; sprintf(Str, "%d", _amount); - Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); + Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); } } } diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index b5af924092..51fe0559e2 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 023379d142..9840cf3097 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -8,12 +8,12 @@ * 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. @@ -40,7 +40,7 @@ #include "common/str.h" namespace WinterMute { - + IMPLEMENT_PERSISTENT(CAdLayer, false) ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index 6de980d0a5..afa80bec74 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp index 27c796c77b..80858c4a2d 100644 --- a/engines/wintermute/AdNodeState.cpp +++ b/engines/wintermute/AdNodeState.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h index da8dc541b1..7b515e801c 100644 --- a/engines/wintermute/AdNodeState.h +++ b/engines/wintermute/AdNodeState.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 2908cee79e..58bb742c8a 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -8,12 +8,12 @@ * 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. @@ -884,7 +884,7 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const } else width = Game->_renderer->_width / 2; } - height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); + height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); y = y - height - GetHeight() - 5; if (_subtitlesModRelative) { diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index e017b979e0..706c291eef 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdPath.cpp b/engines/wintermute/AdPath.cpp index f5e3d8ecc7..d9702005c0 100644 --- a/engines/wintermute/AdPath.cpp +++ b/engines/wintermute/AdPath.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdPath.h b/engines/wintermute/AdPath.h index 372b5e1cd4..3f7090815d 100644 --- a/engines/wintermute/AdPath.h +++ b/engines/wintermute/AdPath.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdPathPoint.cpp b/engines/wintermute/AdPathPoint.cpp index 6ebb5b9090..6de03cc5c2 100644 --- a/engines/wintermute/AdPathPoint.cpp +++ b/engines/wintermute/AdPathPoint.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdPathPoint.h b/engines/wintermute/AdPathPoint.h index 56dee7405c..649dab5012 100644 --- a/engines/wintermute/AdPathPoint.h +++ b/engines/wintermute/AdPathPoint.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index 17917066f1..61d1e29f4a 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index 0af1c743fe..7c017be9c7 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdResponse.cpp b/engines/wintermute/AdResponse.cpp index 2e5ddc54b7..9c76c0f4cc 100644 --- a/engines/wintermute/AdResponse.cpp +++ b/engines/wintermute/AdResponse.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h index f42926e476..576092494b 100644 --- a/engines/wintermute/AdResponse.h +++ b/engines/wintermute/AdResponse.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index 4d9608ea9a..a027847d24 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -8,12 +8,12 @@ * 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. @@ -619,7 +619,7 @@ CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::GetObjects(CBArray& Objects, bool InteractiveOnly) { +HRESULT CAdResponseBox::GetObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _respButtons.GetSize(); i++) { Objects.Add(_respButtons[i]); } diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h index b50d91da03..15996d7668 100644 --- a/engines/wintermute/AdResponseBox.h +++ b/engines/wintermute/AdResponseBox.h @@ -8,12 +8,12 @@ * 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. @@ -42,7 +42,7 @@ class CAdResponseBox : public CBObject { public: CBObject *GetNextAccessObject(CBObject *CurrObject); CBObject *GetPrevAccessObject(CBObject *CurrObject); - HRESULT GetObjects(CBArray& Objects, bool InteractiveOnly); + HRESULT GetObjects(CBArray &Objects, bool InteractiveOnly); HRESULT HandleResponse(CAdResponse *Response); void SetLastResponseText(const char *Text, const char *TextOrig); diff --git a/engines/wintermute/AdResponseContext.cpp b/engines/wintermute/AdResponseContext.cpp index 670604fb68..b29f9a42ba 100644 --- a/engines/wintermute/AdResponseContext.cpp +++ b/engines/wintermute/AdResponseContext.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h index 7ae1b14ed2..c801e8a4e2 100644 --- a/engines/wintermute/AdResponseContext.h +++ b/engines/wintermute/AdResponseContext.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdRotLevel.cpp b/engines/wintermute/AdRotLevel.cpp index b5256f2050..7645f19740 100644 --- a/engines/wintermute/AdRotLevel.cpp +++ b/engines/wintermute/AdRotLevel.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h index bd78cedb65..509f9a492a 100644 --- a/engines/wintermute/AdRotLevel.h +++ b/engines/wintermute/AdRotLevel.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdScaleLevel.cpp b/engines/wintermute/AdScaleLevel.cpp index 546e0f7f8e..cd36fb65b8 100644 --- a/engines/wintermute/AdScaleLevel.cpp +++ b/engines/wintermute/AdScaleLevel.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h index efaa5f5e57..b996ff7fb5 100644 --- a/engines/wintermute/AdScaleLevel.h +++ b/engines/wintermute/AdScaleLevel.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index 4cd4ea1082..4fb1096c1e 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -8,12 +8,12 @@ * 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. @@ -2669,7 +2669,7 @@ CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetSceneObjects(CBArray& Objects, bool InteractiveOnly) { +HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _layers.GetSize(); i++) { // close-up layer -> remove everything below it if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); @@ -2725,7 +2725,7 @@ HRESULT CAdScene::GetSceneObjects(CBArray& Objects, bo ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray& Objects, bool InteractiveOnly) { +HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { CAdGame *AdGame = (CAdGame *)Game; CAdObject *Obj; diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index 5aa2e9ffb0..66c27c8c44 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -8,12 +8,12 @@ * 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. @@ -49,8 +49,8 @@ public: CBObject *GetNextAccessObject(CBObject *CurrObject); CBObject *GetPrevAccessObject(CBObject *CurrObject); - HRESULT GetSceneObjects(CBArray& Objects, bool InteractiveOnly); - HRESULT GetRegionObjects(CAdRegion *Region, CBArray& Objects, bool InteractiveOnly); + HRESULT GetSceneObjects(CBArray &Objects, bool InteractiveOnly); + HRESULT GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); HRESULT AfterLoad(); diff --git a/engines/wintermute/AdSceneNode.cpp b/engines/wintermute/AdSceneNode.cpp index 4085eade56..136836ac4a 100644 --- a/engines/wintermute/AdSceneNode.cpp +++ b/engines/wintermute/AdSceneNode.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSceneNode.h b/engines/wintermute/AdSceneNode.h index 366e765cdd..9f71706189 100644 --- a/engines/wintermute/AdSceneNode.h +++ b/engines/wintermute/AdSceneNode.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp index a7acbe78d1..00fd826d6a 100644 --- a/engines/wintermute/AdSceneState.cpp +++ b/engines/wintermute/AdSceneState.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h index 81d84529b8..36f304737e 100644 --- a/engines/wintermute/AdSceneState.h +++ b/engines/wintermute/AdSceneState.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp index b5ba7915cf..cd5fc5d754 100644 --- a/engines/wintermute/AdSentence.cpp +++ b/engines/wintermute/AdSentence.cpp @@ -8,12 +8,12 @@ * 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. @@ -187,7 +187,7 @@ HRESULT CAdSentence::Display() { x = std::min(x, Game->_renderer->_width - _width); y = std::max(y, 0); - _font->DrawText((byte *)_text, x, y, _width, _align); + _font->DrawText((byte *)_text, x, y, _width, _align); } return S_OK; diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h index 7552a72944..c16826f46d 100644 --- a/engines/wintermute/AdSentence.h +++ b/engines/wintermute/AdSentence.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp index 8fe079e780..351d3d2667 100644 --- a/engines/wintermute/AdSpriteSet.cpp +++ b/engines/wintermute/AdSpriteSet.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h index 7a68ed9d0a..689c64af7a 100644 --- a/engines/wintermute/AdSpriteSet.h +++ b/engines/wintermute/AdSpriteSet.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkDef.cpp b/engines/wintermute/AdTalkDef.cpp index 0545887cb3..d8ae610fcb 100644 --- a/engines/wintermute/AdTalkDef.cpp +++ b/engines/wintermute/AdTalkDef.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkDef.h b/engines/wintermute/AdTalkDef.h index 2ead14540b..829c550147 100644 --- a/engines/wintermute/AdTalkDef.h +++ b/engines/wintermute/AdTalkDef.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 6773626523..05d2c46059 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h index e6d4c322eb..647a4b0b98 100644 --- a/engines/wintermute/AdTalkHolder.h +++ b/engines/wintermute/AdTalkHolder.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkNode.cpp b/engines/wintermute/AdTalkNode.cpp index 17e1ca2a2b..4d153e0452 100644 --- a/engines/wintermute/AdTalkNode.cpp +++ b/engines/wintermute/AdTalkNode.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTalkNode.h b/engines/wintermute/AdTalkNode.h index d939847b70..105972c8da 100644 --- a/engines/wintermute/AdTalkNode.h +++ b/engines/wintermute/AdTalkNode.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdTypes.h b/engines/wintermute/AdTypes.h index 8e77f289bc..d11e3b6553 100644 --- a/engines/wintermute/AdTypes.h +++ b/engines/wintermute/AdTypes.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index 865279a57e..c68a7e3101 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -8,12 +8,12 @@ * 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. @@ -34,7 +34,7 @@ #include "BRegion.h" #include "BFileManager.h" namespace WinterMute { - + IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h index 66fbcfa0e1..7a2641a23f 100644 --- a/engines/wintermute/AdWaypointGroup.h +++ b/engines/wintermute/AdWaypointGroup.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BActiveRect.cpp b/engines/wintermute/BActiveRect.cpp index 867b492a85..b94c4d021f 100644 --- a/engines/wintermute/BActiveRect.cpp +++ b/engines/wintermute/BActiveRect.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BActiveRect.h b/engines/wintermute/BActiveRect.h index 9143c1fa6e..6ad5b93448 100644 --- a/engines/wintermute/BActiveRect.h +++ b/engines/wintermute/BActiveRect.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BBase.cpp b/engines/wintermute/BBase.cpp index 32d89cea7f..543259b8d9 100644 --- a/engines/wintermute/BBase.cpp +++ b/engines/wintermute/BBase.cpp @@ -8,12 +8,12 @@ * 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. @@ -59,7 +59,7 @@ const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { _editorPropsIter = _editorProps.find(PropName); if (_editorPropsIter != _editorProps.end()) return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean + //return _editorPropsIter->second.c_str(); // <- TODO Clean else return InitVal; } diff --git a/engines/wintermute/BBase.h b/engines/wintermute/BBase.h index 423c9fef6a..eb1a1e7834 100644 --- a/engines/wintermute/BBase.h +++ b/engines/wintermute/BBase.h @@ -8,12 +8,12 @@ * 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. @@ -57,8 +57,8 @@ public: Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; -/* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ }; } // end of namespace WinterMute diff --git a/engines/wintermute/BDebugger.cpp b/engines/wintermute/BDebugger.cpp index 5c26b6ae23..62efc27bb5 100644 --- a/engines/wintermute/BDebugger.cpp +++ b/engines/wintermute/BDebugger.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BDebugger.h b/engines/wintermute/BDebugger.h index c443863af0..bdae7823a0 100644 --- a/engines/wintermute/BDebugger.h +++ b/engines/wintermute/BDebugger.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index 591da4b9db..b456083058 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -8,12 +8,12 @@ * 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. @@ -63,15 +63,15 @@ HRESULT CBDiskFile::Open(Common::String Filename) { CorrectSlashes(FullPath); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); - if(tempFile->open(FullPath)) { + if (tempFile->open(FullPath)) { _file = tempFile; } else { delete tempFile; } -/* if (_file != NULL) { - error("Tried to open %s, but failed", Filename.c_str()); - break; - }*/ + /* if (_file != NULL) { + error("Tried to open %s, but failed", Filename.c_str()); + break; + }*/ } // if we didn't find it in search paths, try to open directly @@ -87,7 +87,7 @@ HRESULT CBDiskFile::Open(Common::String Filename) { delete tempFile; } } - + if (_file) { uint32 magic1, magic2; magic1 = _file->readUint32LE(); @@ -134,7 +134,7 @@ HRESULT CBDiskFile::Open(Common::String Filename) { _pos = 0; _file->seek(0, SEEK_END); _size = _file->pos() - _prefixSize; - _file->seek(_prefixSize,SEEK_SET); + _file->seek(_prefixSize, SEEK_SET); } return S_OK; @@ -146,7 +146,7 @@ HRESULT CBDiskFile::Open(Common::String Filename) { HRESULT CBDiskFile::Close() { if (_file) { delete _file; - } + } _file = NULL; _pos = 0; _size = 0; diff --git a/engines/wintermute/BDiskFile.h b/engines/wintermute/BDiskFile.h index 6991283437..129dcb0e72 100644 --- a/engines/wintermute/BDiskFile.h +++ b/engines/wintermute/BDiskFile.h @@ -8,12 +8,12 @@ * 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. @@ -33,7 +33,7 @@ #include "BFile.h" namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace WinterMute { diff --git a/engines/wintermute/BDynBuffer.cpp b/engines/wintermute/BDynBuffer.cpp index 68012f29f8..23cd1d2584 100644 --- a/engines/wintermute/BDynBuffer.cpp +++ b/engines/wintermute/BDynBuffer.cpp @@ -8,12 +8,12 @@ * 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. @@ -74,7 +74,7 @@ HRESULT CBDynBuffer::Init(uint32 InitSize) { if (InitSize == 0) InitSize = _initSize; - _buffer = (byte *)malloc(InitSize); + _buffer = (byte *)malloc(InitSize); if (!_buffer) { Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); return E_FAIL; @@ -93,7 +93,7 @@ HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { while (_offset + Size > _realSize) { _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); + _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return E_FAIL; @@ -126,14 +126,14 @@ HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// void CBDynBuffer::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); + PutBytes((byte *)&Val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// uint32 CBDynBuffer::GetDWORD() { uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); + GetBytes((byte *)&ret, sizeof(uint32)); return ret; } @@ -143,7 +143,7 @@ void CBDynBuffer::PutString(const char *Val) { if (!Val) PutString("(null)"); else { PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); } } @@ -186,7 +186,7 @@ void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { char buff[32768]; vsprintf(buff, format, argptr); - PutBytes((byte *)buff, strlen(buff)); + PutBytes((byte *)buff, strlen(buff)); } } // end of namespace WinterMute diff --git a/engines/wintermute/BDynBuffer.h b/engines/wintermute/BDynBuffer.h index 4b05ee88ff..2b4d1d97bf 100644 --- a/engines/wintermute/BDynBuffer.h +++ b/engines/wintermute/BDynBuffer.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp index 05876784a1..2bf77803c4 100644 --- a/engines/wintermute/BEvent.cpp +++ b/engines/wintermute/BEvent.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h index e09f0ff3a8..5afd57ce3a 100644 --- a/engines/wintermute/BEvent.h +++ b/engines/wintermute/BEvent.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFader.cpp b/engines/wintermute/BFader.cpp index b40582318a..ae716f6d3e 100644 --- a/engines/wintermute/BFader.cpp +++ b/engines/wintermute/BFader.cpp @@ -8,12 +8,12 @@ * 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. @@ -74,7 +74,7 @@ HRESULT CBFader::Update() { else { _currentAlpha = _sourceAlpha + (float)time / (float)_duration * AlphaDelta; } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte )0)); // TODO: clean + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean _ready = time >= _duration; if (_ready && _currentAlpha == 0x00) _active = false; diff --git a/engines/wintermute/BFader.h b/engines/wintermute/BFader.h index 38ef8451ab..9007a95de0 100644 --- a/engines/wintermute/BFader.h +++ b/engines/wintermute/BFader.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFile.cpp b/engines/wintermute/BFile.cpp index e66990f571..43b87027e2 100644 --- a/engines/wintermute/BFile.cpp +++ b/engines/wintermute/BFile.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFile.h b/engines/wintermute/BFile.h index 7b077b34b9..78241eaf6a 100644 --- a/engines/wintermute/BFile.h +++ b/engines/wintermute/BFile.h @@ -8,12 +8,12 @@ * 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. @@ -34,7 +34,7 @@ #include "common/str.h" namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace WinterMute { diff --git a/engines/wintermute/BFileEntry.cpp b/engines/wintermute/BFileEntry.cpp index 3b9a9fafa9..447b7e85d7 100644 --- a/engines/wintermute/BFileEntry.cpp +++ b/engines/wintermute/BFileEntry.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFileEntry.h b/engines/wintermute/BFileEntry.h index 00e82f8640..27a4f80eba 100644 --- a/engines/wintermute/BFileEntry.h +++ b/engines/wintermute/BFileEntry.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 4cfe031090..e3e5986b88 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -8,12 +8,12 @@ * 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. @@ -315,31 +315,31 @@ HRESULT CBFileManager::InitPaths() { // package files paths AddPath(PATH_PACKAGE, "./"); -/*#ifdef __APPLE__ - // search .app path and Resources dir in the bundle - CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); - const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); - -#ifdef __IPHONE__ - AddPath(PATH_PACKAGE, pathPtr); - AddPath(PATH_SINGLE, pathPtr); -#else - char bundlePath[MAX_PATH]; + /*#ifdef __APPLE__ + // search .app path and Resources dir in the bundle + CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); - sprintf(bundlePath, "%s/../", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); + #ifdef __IPHONE__ + AddPath(PATH_PACKAGE, pathPtr); + AddPath(PATH_SINGLE, pathPtr); + #else + char bundlePath[MAX_PATH]; - sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); + sprintf(bundlePath, "%s/../", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); + sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); - CFRelease(appUrlRef); - CFRelease(macPath); -#endif -#endif*/ + + CFRelease(appUrlRef); + CFRelease(macPath); + #endif + #endif*/ pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); @@ -365,7 +365,7 @@ HRESULT CBFileManager::RegisterPackages() { Game->LOG(0, "Scanning packages..."); warning("Scanning packages"); - + // TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. RegisterPackage("data.dcp"); RegisterPackage("english.dcp"); @@ -413,10 +413,10 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename.c_str()); return S_OK; } - + uint32 AbsoluteOffset = 0; bool BoundToExe = false; - + if (SearchSignature) { uint32 Offset; if (!FindPackageSignature(package, &Offset)) { @@ -428,7 +428,7 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign BoundToExe = true; } } - + TPackageHeader hdr; hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); @@ -437,11 +437,11 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign delete package; return S_OK; } - + if (hdr.PackageVersion != PACKAGE_VERSION) { Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); } - + // new in v2 if (hdr.PackageVersion == PACKAGE_VERSION) { uint32 DirOffset; @@ -449,55 +449,55 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign DirOffset += AbsoluteOffset; package->seek(DirOffset, SEEK_SET); } - + for (int i = 0; i < hdr.NumDirs; i++) { CBPackage *pkg = new CBPackage(Game); if (!pkg) return E_FAIL; - + pkg->_boundToExe = BoundToExe; - + // read package info byte NameLength = package->readByte(); pkg->_name = new char[NameLength]; package->read(pkg->_name, NameLength); pkg->_cD = package->readByte(); pkg->_priority = hdr.Priority; - + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk _packages.Add(pkg); - - + + // read file entries uint32 NumFiles = package->readUint32LE(); - + for (int j = 0; j < NumFiles; j++) { char *Name; uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - + NameLength = package->readByte(); Name = new char[NameLength]; package->read(Name, NameLength); - + // v2 - xor name if (hdr.PackageVersion == PACKAGE_VERSION) { for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; + ((byte *)Name)[k] ^= 'D'; } } - + // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory Name[NameLength - 1] = '\0'; - - + + CBPlatform::strupr(Name); - + Offset = package->readUint32LE(); Offset += AbsoluteOffset; Length = package->readUint32LE(); CompLength = package->readUint32LE(); Flags = package->readUint32LE(); - + if (hdr.PackageVersion == PACKAGE_VERSION) { TimeDate1 = package->readUint32LE(); TimeDate2 = package->readUint32LE(); @@ -510,7 +510,7 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign file->_length = Length; file->_compressedLength = CompLength; file->_flags = Flags; - + _files[Name] = file; } else { // current package has lower CD number or higher priority, than the registered @@ -525,8 +525,8 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign delete [] Name; } } - - + + delete package; return S_OK; } @@ -587,10 +587,10 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool // read package info byte NameLength; - fread(&NameLength, sizeof(byte ), 1, f); + fread(&NameLength, sizeof(byte), 1, f); pkg->_name = new char[NameLength]; fread(pkg->_name, NameLength, 1, f); - fread(&pkg->_cD, sizeof(byte ), 1, f); + fread(&pkg->_cD, sizeof(byte), 1, f); pkg->_priority = hdr.Priority; if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk @@ -605,14 +605,14 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool char *Name; uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - fread(&NameLength, sizeof(byte ), 1, f); + fread(&NameLength, sizeof(byte), 1, f); Name = new char[NameLength]; fread(Name, NameLength, 1, f); // v2 - xor name if (hdr.PackageVersion == PACKAGE_VERSION) { for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; + ((byte *)Name)[k] ^= 'D'; } } @@ -677,7 +677,7 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { ////////////////////////////////////////////////////////////////////////// Common::File *CBFileManager::OpenPackage(const char *Name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? - + //RestoreCurrentDir(); Common::File *ret = new Common::File(); @@ -705,17 +705,17 @@ Common::File *CBFileManager::OpenPackage(const char *Name) { ////////////////////////////////////////////////////////////////////////// Common::File *CBFileManager::OpenSingleFile(const char *Name) { RestoreCurrentDir(); - + Common::File *ret = NULL; char Filename[MAX_PATH]; - + for (int i = 0; i < _singlePaths.GetSize(); i++) { sprintf(Filename, "%s%s", _singlePaths[i], Name); ret->open(Filename); - if (ret->isOpen()) + if (ret->isOpen()) return ret; } - + // didn't find in search paths, try to open directly ret->open(Name); if (ret->isOpen()) { diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index f021afa275..7b487674f5 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -8,12 +8,12 @@ * 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. @@ -36,7 +36,7 @@ #include "common/archive.h" namespace Common { - class File; +class File; } namespace WinterMute { diff --git a/engines/wintermute/BFont.cpp b/engines/wintermute/BFont.cpp index 4bae2841ab..82dfbb072b 100644 --- a/engines/wintermute/BFont.cpp +++ b/engines/wintermute/BFont.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFont.h b/engines/wintermute/BFont.h index a02b6cd0ca..453f567c96 100644 --- a/engines/wintermute/BFont.h +++ b/engines/wintermute/BFont.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index f2f7fcfc60..caa0fb8bf1 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -8,12 +8,12 @@ * 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. @@ -92,9 +92,9 @@ int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { str = AnsiString((char *)text); } - if (MaxLength >= 0 && str.size() > MaxLength) + if (MaxLength >= 0 && str.size() > MaxLength) str = Common::String(str.c_str(), MaxLength); - //str.substr(0, MaxLength); // TODO: Remove + //str.substr(0, MaxLength); // TODO: Remove int TextWidth = 0; for (size_t i = 0; i < str.size(); i++) { @@ -309,7 +309,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { Game->LOG(0, "'FONT' keyword expected."); return E_FAIL; } - Buffer = (byte *)params; + Buffer = (byte *)params; int widths[300]; int num = 0, default_width = 8; @@ -343,7 +343,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { case TOKEN_WIDTHS: parser.ScanStr(params, "%D", widths, &num); for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { - _widths[last_width] = (byte )widths[i]; + _widths[last_width] = (byte)widths[i]; } break; @@ -388,7 +388,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + ParseEditorProperty((byte *)params, false); break; } @@ -426,7 +426,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { int NewWidth = (int)_widths[i] + ExpandWidth; if (NewWidth < 0) NewWidth = 0; - _widths[i] = (byte )NewWidth; + _widths[i] = (byte)NewWidth; } } diff --git a/engines/wintermute/BFontBitmap.h b/engines/wintermute/BFontBitmap.h index 23ebdaabe2..0079e5a916 100644 --- a/engines/wintermute/BFontBitmap.h +++ b/engines/wintermute/BFontBitmap.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp index f73f018ab7..67c522aabc 100644 --- a/engines/wintermute/BFontStorage.cpp +++ b/engines/wintermute/BFontStorage.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h index 8bf9c556c3..77f17f2382 100644 --- a/engines/wintermute/BFontStorage.h +++ b/engines/wintermute/BFontStorage.h @@ -8,12 +8,12 @@ * 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. @@ -52,9 +52,9 @@ public: CBArray _fonts; HRESULT InitLoop(); -/* FT_Library GetFTLibrary() const { - return _fTLibrary; - }*/ + /* FT_Library GetFTLibrary() const { + return _fTLibrary; + }*/ private: void InitFreeType(); diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 24454c7529..2fdaf7b128 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -8,12 +8,12 @@ * 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. @@ -131,12 +131,12 @@ void CBFontTT::InitLoop() { int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { WideString text; -/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ - if (MaxLength >= 0 && text.size() > MaxLength) + if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); - //text = text.substr(0, MaxLength); // TODO: Remove + //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; MeasureText(text, -1, -1, textWidth, textHeight); @@ -148,8 +148,8 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { int CBFontTT::GetTextHeight(byte *Text, int Width) { WideString text; -/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ int textWidth, textHeight; @@ -167,12 +167,12 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, WideString text; // TODO: Why do we still insist on Widestrings everywhere? -/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ - if (MaxLength >= 0 && text.size() > MaxLength) + if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); - //text = text.substr(0, MaxLength); // TODO: Remove + //text = text.substr(0, MaxLength); // TODO: Remove CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; @@ -437,7 +437,7 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { Game->LOG(0, "'TTFONT' keyword expected."); return E_FAIL; } - Buffer = (byte *)params; + Buffer = (byte *)params; uint32 BaseColor = 0x00000000; @@ -491,7 +491,7 @@ HRESULT CBFontTT::LoadBuffer(byte *Buffer) { case TOKEN_LAYER: { CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); + if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); else { delete Layer; Layer = NULL; @@ -609,7 +609,7 @@ void CBFontTT::AfterLoad() { HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; warning("BFontTT::InitFont - Not ported yet"); - + CBFile *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font @@ -695,26 +695,26 @@ HRESULT CBFontTT::InitFont() { ////////////////////////////////////////////////////////////////////////// /* unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return 0; - - f->Seek(offset, SEEK_TO_BEGIN); - if (count) { - uint32 oldPos = f->GetPos(); - f->Read(buffer, count); - return f->GetPos() - oldPos; - } else return 0; + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return 0; + + f->Seek(offset, SEEK_TO_BEGIN); + if (count) { + uint32 oldPos = f->GetPos(); + f->Read(buffer, count); + return f->GetPos() - oldPos; + } else return 0; } ////////////////////////////////////////////////////////////////////////// void CBFontTT::FTCloseProc(FT_Stream stream) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return; + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return; - CBGame *Game = f->Game; + CBGame *Game = f->Game; - Game->_fileManager->CloseFile(f); - stream->descriptor.pointer = NULL; + Game->_fileManager->CloseFile(f); + stream->descriptor.pointer = NULL; }*/ diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h index ec552fc9fa..c1bd7e7023 100644 --- a/engines/wintermute/BFontTT.h +++ b/engines/wintermute/BFontTT.h @@ -8,12 +8,12 @@ * 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. @@ -128,8 +128,8 @@ public: HRESULT LoadBuffer(byte *Buffer); HRESULT LoadFile(const char *Filename); -/* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); - static void FTCloseProc(FT_Stream stream);*/ + /* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); + static void FTCloseProc(FT_Stream stream);*/ FontGlyphCache *GetGlyphCache() { return _glyphCache; diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index 08a0e73f72..a4e3cb9032 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -8,12 +8,12 @@ * 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. @@ -239,7 +239,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_SUBFRAME: { CBSubFrame *subframe = new CBSubFrame(Game); - if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { + if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; } else _subframes.Add(subframe); @@ -276,7 +276,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + ParseEditorProperty((byte *)params, false); break; } } diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h index b236e60172..9810e50ada 100644 --- a/engines/wintermute/BFrame.h +++ b/engines/wintermute/BFrame.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 0a7885b7e1..e210b3299c 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -8,12 +8,12 @@ * 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. @@ -294,7 +294,7 @@ CBGame::~CBGame() { delete[] _localSaveDir; delete[] _settingsGameFile; delete[] _savedGameExt; - + delete _cachedThumbnail; delete _saveLoadImage; @@ -321,7 +321,7 @@ CBGame::~CBGame() { _saveLoadImage = NULL; _mathClass = NULL; - + _transMgr = NULL; _scEngine = NULL; _fontStorage = NULL; @@ -333,7 +333,7 @@ CBGame::~CBGame() { _fileManager = NULL; _registry = NULL; _stringTable = NULL; - + DEBUG_DebugDisable(); CBPlatform::OutputDebugString("--- shutting down normally ---\n"); } @@ -516,7 +516,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); } - if (_dEBUG_LogFile != NULL) fprintf((FILE*)_dEBUG_LogFile, "\n"); + if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); #endif time_t timeNow; @@ -542,7 +542,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { void CBGame::DEBUG_DebugDisable() { if (_dEBUG_LogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - fclose((FILE*)_dEBUG_LogFile); + fclose((FILE *)_dEBUG_LogFile); _dEBUG_LogFile = NULL; } _dEBUG_DebugMode = false; @@ -578,8 +578,8 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { if (_debugMgr) _debugMgr->OnLog(res, buff); warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fprintf((FILE*)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fflush((FILE*)_dEBUG_LogFile); + fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fflush((FILE *)_dEBUG_LogFile); #endif //QuickMessage(buff); @@ -1517,7 +1517,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1527,7 +1527,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1537,7 +1537,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1547,7 +1547,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { Stack->CorrectParams(1); - Game->_soundMgr->setMasterVolumePercent((byte )Stack->Pop()->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte)Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; } @@ -1831,7 +1831,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::SetString(&_loadImageName, Val->GetString()); + CBUtils::SetString(&_loadImageName, Val->GetString()); } Stack->PushNULL(); return S_OK; @@ -2544,7 +2544,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Value->GetInt()); return S_OK; } @@ -2553,7 +2553,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Value->GetInt()); return S_OK; } @@ -2562,7 +2562,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte )Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Value->GetInt()); return S_OK; } @@ -2571,7 +2571,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->setMasterVolumePercent((byte )Value->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte)Value->GetInt()); return S_OK; } @@ -2706,8 +2706,8 @@ HRESULT CBGame::DisplayQuickMsg() { // display for (i = 0; i < _quickMessages.GetSize(); i++) { - _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); - PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); + _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); + PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); } return S_OK; } @@ -3797,8 +3797,8 @@ void CBGame::SetWindowTitle() { } else { warning("CBGame::SetWindowTitle -Ignoring textencoding"); title = Utf8String(Title); -/* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ } CBRenderSDL *renderer = static_cast(_renderer); @@ -3917,9 +3917,9 @@ HRESULT CBGame::PopViewport() { if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->GetRect()); else _renderer->SetViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); return S_OK; } @@ -4308,7 +4308,7 @@ HRESULT CBGame::DisplayDebugInfo() { if (_dEBUG_ShowFPS) { sprintf(str, "FPS: %d", Game->_fps); - _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); + _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); } if (Game->_dEBUG_DebugMode) { @@ -4320,23 +4320,23 @@ HRESULT CBGame::DisplayDebugInfo() { strcat(str, " ("); strcat(str, _renderer->GetName()); strcat(str, ")"); - _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); _renderer->DisplayDebugInfo(); int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); - _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); sprintf(str, "Timer: %d", _timer); - Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 145af7c3f2..1eb41403b4 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -8,12 +8,12 @@ * 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. @@ -89,7 +89,7 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - + virtual HRESULT MiniUpdate(); void GetMousePos(POINT *Pos); diff --git a/engines/wintermute/BImage.h b/engines/wintermute/BImage.h index b9e3ca880c..80a09fe60f 100644 --- a/engines/wintermute/BImage.h +++ b/engines/wintermute/BImage.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 7a4c246899..1bece9fea6 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index 956765b4a9..2ceaa6eb4d 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp index 7f33aaa42d..13dfee0273 100644 --- a/engines/wintermute/BNamedObject.cpp +++ b/engines/wintermute/BNamedObject.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BNamedObject.h b/engines/wintermute/BNamedObject.h index aecd45517b..c3e7e31aa4 100644 --- a/engines/wintermute/BNamedObject.h +++ b/engines/wintermute/BNamedObject.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 389953ad14..4d3a24cfa4 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -8,12 +8,12 @@ * 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. @@ -211,7 +211,7 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi _cursor = NULL; } else { _cursor = NULL; - + } Stack->PushNULL(); diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 9908d03e3b..11fa3dba19 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp index 56774c64bd..0608fbcde1 100644 --- a/engines/wintermute/BPackage.cpp +++ b/engines/wintermute/BPackage.cpp @@ -8,12 +8,12 @@ * 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. @@ -96,7 +96,7 @@ Common::SeekableReadStream *CBPackage::GetFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::CloseFilePointer(Common::SeekableReadStream*& file) { +void CBPackage::CloseFilePointer(Common::SeekableReadStream *&file) { delete file; file = NULL; } diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h index 586088174f..cd8bb14f40 100644 --- a/engines/wintermute/BPackage.h +++ b/engines/wintermute/BPackage.h @@ -8,12 +8,12 @@ * 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. @@ -33,7 +33,7 @@ #include "BBase.h" namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace WinterMute { @@ -41,7 +41,7 @@ namespace WinterMute { class CBPackage : public CBBase { public: Common::SeekableReadStream *GetFilePointer(); - void CloseFilePointer(Common::SeekableReadStream*& file); + void CloseFilePointer(Common::SeekableReadStream *&file); bool _boundToExe; byte _priority; diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp index 7f40cc8030..97a191eff1 100644 --- a/engines/wintermute/BParser.cpp +++ b/engines/wintermute/BParser.cpp @@ -8,12 +8,12 @@ * 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. @@ -181,7 +181,7 @@ char *CBParser::GetAssignmentText(char **buf) { break; ++*buf; } - **buf = 0; // null terminate it + **buf = 0; // null terminate it if (theChar) // skip the terminator ++*buf; } diff --git a/engines/wintermute/BParser.h b/engines/wintermute/BParser.h index bf5edf7888..eb88467b7e 100644 --- a/engines/wintermute/BParser.h +++ b/engines/wintermute/BParser.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp index e1e84505ca..bc825ac385 100644 --- a/engines/wintermute/BPersistMgr.cpp +++ b/engines/wintermute/BPersistMgr.cpp @@ -8,12 +8,12 @@ * 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. @@ -115,7 +115,7 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { Cleanup(); _saving = true; - _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); + _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); if (_buffer) { _bufferSize = SAVE_BUFFER_INIT_SIZE; res = S_OK; @@ -171,9 +171,9 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { Game->_cachedThumbnail = NULL; uint32 DataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(Desc) + 1 + // description - sizeof(uint32); // timestamp + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(Desc) + 1 + // description + sizeof(uint32); // timestamp PutDWORD(DataOffset); PutString(Desc); @@ -230,7 +230,7 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { _savedExtMinor = getHighByte(getHighWord(Version)); if (Magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte )GetDWORD(); + _savedVerBuild = (byte)GetDWORD(); char *SavedName = GetString(); if (SavedName == NULL || scumm_stricmp(SavedName, Game->_name) != 0) { Game->LOG(0, "ERROR: Saved game name doesn't match current game"); @@ -302,7 +302,7 @@ HRESULT CBPersistMgr::SaveFile(const char *Filename) { HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { while (_offset + Size > _bufferSize) { _bufferSize += SAVE_BUFFER_GROW_BY; - _buffer = (byte *)realloc(_buffer, _bufferSize); + _buffer = (byte *)realloc(_buffer, _bufferSize); if (!_buffer) { Game->LOG(0, "Error reallocating save buffer to %d bytes", _bufferSize); return E_FAIL; @@ -332,14 +332,14 @@ HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// void CBPersistMgr::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); + PutBytes((byte *)&Val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// uint32 CBPersistMgr::GetDWORD() { uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); + GetBytes((byte *)&ret, sizeof(uint32)); return ret; } @@ -349,7 +349,7 @@ void CBPersistMgr::PutString(const char *Val) { if (!Val) PutString("(null)"); else { PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); } } @@ -367,40 +367,40 @@ char *CBPersistMgr::GetString() { ////////////////////////////////////////////////////////////////////////// // bool HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(bool)); - else return GetBytes((byte *)Val, sizeof(bool)); + if (_saving) return PutBytes((byte *)Val, sizeof(bool)); + else return GetBytes((byte *)Val, sizeof(bool)); } ////////////////////////////////////////////////////////////////////////// // int HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(int)); - else return GetBytes((byte *)Val, sizeof(int)); + if (_saving) return PutBytes((byte *)Val, sizeof(int)); + else return GetBytes((byte *)Val, sizeof(int)); } ////////////////////////////////////////////////////////////////////////// // DWORD HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); - else return GetBytes((byte *)Val, sizeof(uint32)); + if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); + else return GetBytes((byte *)Val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// // float HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(float)); - else return GetBytes((byte *)Val, sizeof(float)); + if (_saving) return PutBytes((byte *)Val, sizeof(float)); + else return GetBytes((byte *)Val, sizeof(float)); } ////////////////////////////////////////////////////////////////////////// // double HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(double)); - else return GetBytes((byte *)Val, sizeof(double)); + if (_saving) return PutBytes((byte *)Val, sizeof(double)); + else return GetBytes((byte *)Val, sizeof(double)); } @@ -427,14 +427,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { if (_saving) { size = Val.size(); - PutBytes((byte *)&size, sizeof(size_t)); + PutBytes((byte *)&size, sizeof(size_t)); for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { PutString((*it).c_str()); } } else { Val.clear(); - GetBytes((byte *)&size, sizeof(size_t)); + GetBytes((byte *)&size, sizeof(size_t)); for (size_t i = 0; i < size; i++) { char *str = GetString(); @@ -448,32 +448,32 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { ////////////////////////////////////////////////////////////////////////// // BYTE HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(byte )); - else return GetBytes((byte *)Val, sizeof(byte )); + if (_saving) return PutBytes((byte *)Val, sizeof(byte)); + else return GetBytes((byte *)Val, sizeof(byte)); } ////////////////////////////////////////////////////////////////////////// // RECT HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); - else return GetBytes((byte *)Val, sizeof(RECT)); + if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); + else return GetBytes((byte *)Val, sizeof(RECT)); } ////////////////////////////////////////////////////////////////////////// // POINT HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); - else return GetBytes((byte *)Val, sizeof(POINT)); + if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); + else return GetBytes((byte *)Val, sizeof(POINT)); } ////////////////////////////////////////////////////////////////////////// // Vector2 HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); - else return GetBytes((byte *)Val, sizeof(Vector2)); + if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); + else return GetBytes((byte *)Val, sizeof(Vector2)); } diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h index 01d2fda40a..10e1c9e880 100644 --- a/engines/wintermute/BPersistMgr.h +++ b/engines/wintermute/BPersistMgr.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index 783011bbb3..f336574c0c 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -8,12 +8,12 @@ * 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. @@ -74,7 +74,7 @@ HRESULT CBPkgFile::Open(Common::String Filename) { // TODO: Cleanup _compressed = (_fileEntry->_compressedLength != 0); _size = _fileEntry->_length; - + if (_compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. @@ -82,7 +82,7 @@ HRESULT CBPkgFile::Open(Common::String Filename) { } else { _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); } - + SeekToPos(0); return S_OK; diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h index 9b70d37ed6..e3942718f4 100644 --- a/engines/wintermute/BPkgFile.h +++ b/engines/wintermute/BPkgFile.h @@ -8,12 +8,12 @@ * 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. @@ -37,8 +37,8 @@ #define COMPRESSED_BUFFER_SIZE 4096 namespace Common { - class SeekableReadStream; - class File; +class SeekableReadStream; +class File; } namespace WinterMute { diff --git a/engines/wintermute/BPoint.cpp b/engines/wintermute/BPoint.cpp index 331e9252f4..2cab052b96 100644 --- a/engines/wintermute/BPoint.cpp +++ b/engines/wintermute/BPoint.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BPoint.h b/engines/wintermute/BPoint.h index 6cd17653d9..1517953ef8 100644 --- a/engines/wintermute/BPoint.h +++ b/engines/wintermute/BPoint.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BQuickMsg.cpp b/engines/wintermute/BQuickMsg.cpp index 6fa14ac5c0..49425e7741 100644 --- a/engines/wintermute/BQuickMsg.cpp +++ b/engines/wintermute/BQuickMsg.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BQuickMsg.h b/engines/wintermute/BQuickMsg.h index a760a9ee21..cd7b6b6fdc 100644 --- a/engines/wintermute/BQuickMsg.h +++ b/engines/wintermute/BQuickMsg.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 23071f51a6..f7c4812d3e 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index 79af62bcae..ef7b3f2719 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp index 72f34ef061..0e9592ce56 100644 --- a/engines/wintermute/BRegistry.cpp +++ b/engines/wintermute/BRegistry.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h index 0729374783..99d25e88c3 100644 --- a/engines/wintermute/BRegistry.h +++ b/engines/wintermute/BRegistry.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index a5a3547cb3..b74967b815 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -8,12 +8,12 @@ * 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. @@ -39,12 +39,12 @@ namespace WinterMute { -// TODO: Redo everything here. +// TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { -/* _renderer = NULL; - _win = NULL;*/ + /* _renderer = NULL; + _win = NULL;*/ _renderSurface = NULL; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; @@ -138,10 +138,10 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { #if 0 _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + _realWidth, _realHeight, + flags); if (!_win) return E_FAIL; #endif @@ -210,7 +210,7 @@ HRESULT CBRenderSDL::Flip() { } } #endif - g_system->copyRectToScreen((byte*)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); g_system->updateScreen(); //SDL_RenderPresent(_renderer); @@ -271,18 +271,18 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { return S_OK; } -// Replacement for SDL2's SDL_RenderCopy +// Replacement for SDL2's SDL_RenderCopy void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { for (int i = 0; i < srcRect->height(); i++) { void *destPtr = _renderSurface->getBasePtr(dstRect->left, dstRect->top + i); void *srcPtr = surf->getBasePtr(srcRect->left, srcRect->top + i); for (int j = 0; j < srcRect->width(); j++) { // TODO: Replace this with something less ugly, and more portable. - if (((byte*)srcPtr)[0] == 255) { - memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel); + if (((byte *)srcPtr)[0] == 255) { + memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel); } - ((byte*)srcPtr)+=_renderSurface->format.bytesPerPixel; - ((byte*)destPtr)+=_renderSurface->format.bytesPerPixel; + ((byte *)srcPtr) += _renderSurface->format.bytesPerPixel; + ((byte *)destPtr) += _renderSurface->format.bytesPerPixel; } } } @@ -329,7 +329,7 @@ CBImage *CBRenderSDL::TakeScreenshot() { for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; memcpy(bits, src, bytespp * viewport.w); } @@ -344,7 +344,7 @@ HRESULT CBRenderSDL::SwitchFullscreen() { else SDL_SetWindowFullscreen(_win, SDL_FALSE); _windowed = !_windowed; -*/ + */ Game->_registry->WriteBool("Video", "Windowed", _windowed); return S_OK; diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 5842492743..83199433e8 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -8,12 +8,12 @@ * 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. @@ -57,7 +57,7 @@ public: HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); CBImage *TakeScreenshot(); - + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); @@ -77,8 +77,8 @@ public: } private: -/* SDL_Renderer *_renderer; - SDL_Window *_win;*/ + /* SDL_Renderer *_renderer; + SDL_Window *_win;*/ Graphics::Surface *_renderSurface; AnsiString _name; diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp index a0ebcdd1d3..88ad581e6f 100644 --- a/engines/wintermute/BRenderer.cpp +++ b/engines/wintermute/BRenderer.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h index 26ea699e6d..7a586775dd 100644 --- a/engines/wintermute/BRenderer.h +++ b/engines/wintermute/BRenderer.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp index c03868cde1..c6de083d9c 100644 --- a/engines/wintermute/BResourceFile.cpp +++ b/engines/wintermute/BResourceFile.cpp @@ -8,12 +8,12 @@ * 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. @@ -69,7 +69,7 @@ HRESULT CBResourceFile::Close() { HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { if (!_data || _pos + Size > _size) return E_FAIL; - memcpy(Buffer, (byte *)_data + _pos, Size); + memcpy(Buffer, (byte *)_data + _pos, Size); _pos += Size; return S_OK; diff --git a/engines/wintermute/BResourceFile.h b/engines/wintermute/BResourceFile.h index 110f320d60..654983997b 100644 --- a/engines/wintermute/BResourceFile.h +++ b/engines/wintermute/BResourceFile.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BResources.cpp b/engines/wintermute/BResources.cpp index f387d1848b..e63f1df307 100644 --- a/engines/wintermute/BResources.cpp +++ b/engines/wintermute/BResources.cpp @@ -8,12 +8,12 @@ * 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. @@ -2807,7 +2807,7 @@ unsigned char systemfont[] = { ////////////////////////////////////////////////////////////////////////// -bool CBResources::GetFile(const char *fileName, byte*& buffer, uint32 &size) { +bool CBResources::GetFile(const char *fileName, byte *&buffer, uint32 &size) { // better! if (scumm_stricmp(fileName, "invalid.bmp") == 0) { buffer = invalid; diff --git a/engines/wintermute/BResources.h b/engines/wintermute/BResources.h index ff8c050fa8..26d92af525 100644 --- a/engines/wintermute/BResources.h +++ b/engines/wintermute/BResources.h @@ -8,12 +8,12 @@ * 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. @@ -33,7 +33,7 @@ namespace WinterMute { class CBResources { public: - static bool GetFile(const char *fileName, byte*& buffer, uint32 &size); + static bool GetFile(const char *fileName, byte *&buffer, uint32 &size); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbFile.cpp b/engines/wintermute/BSaveThumbFile.cpp index 4f698563d3..d8d91e8062 100644 --- a/engines/wintermute/BSaveThumbFile.cpp +++ b/engines/wintermute/BSaveThumbFile.cpp @@ -8,12 +8,12 @@ * 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. @@ -112,7 +112,7 @@ HRESULT CBSaveThumbFile::Close() { HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { if (!_data || _pos + Size > _size) return E_FAIL; - memcpy(Buffer, (byte *)_data + _pos, Size); + memcpy(Buffer, (byte *)_data + _pos, Size); _pos += Size; return S_OK; diff --git a/engines/wintermute/BSaveThumbFile.h b/engines/wintermute/BSaveThumbFile.h index 55596b7ecc..69be999f9e 100644 --- a/engines/wintermute/BSaveThumbFile.h +++ b/engines/wintermute/BSaveThumbFile.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSaveThumbHelper.cpp b/engines/wintermute/BSaveThumbHelper.cpp index ac8898c344..6ae2f2013f 100644 --- a/engines/wintermute/BSaveThumbHelper.cpp +++ b/engines/wintermute/BSaveThumbHelper.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSaveThumbHelper.h b/engines/wintermute/BSaveThumbHelper.h index fa42762367..dfb587e194 100644 --- a/engines/wintermute/BSaveThumbHelper.h +++ b/engines/wintermute/BSaveThumbHelper.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index 2447bf17d6..d06778d7af 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index 2ced86b1cf..cfdb0e1771 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index a0142e00ba..be2b961b08 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp index 088235fb75..d419e827b5 100644 --- a/engines/wintermute/BSound.cpp +++ b/engines/wintermute/BSound.cpp @@ -8,12 +8,12 @@ * 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. @@ -58,7 +58,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { CBSound::~CBSound() { if (_sound) Game->_soundMgr->removeSound(_sound); _sound = NULL; - + delete[] _soundFilename; _soundFilename = NULL; } diff --git a/engines/wintermute/BSound.h b/engines/wintermute/BSound.h index d8da355239..2acdaee464 100644 --- a/engines/wintermute/BSound.h +++ b/engines/wintermute/BSound.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index e045d4d769..1905325f8a 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -8,12 +8,12 @@ * 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. @@ -111,10 +111,10 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } - + _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES); CBUtils::SetString(&_filename, Filename); - + return S_OK; #if 0 BASS_FILEPROCS fileProc; diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h index e9ef8264f7..312bb03f31 100644 --- a/engines/wintermute/BSoundBuffer.h +++ b/engines/wintermute/BSoundBuffer.h @@ -8,12 +8,12 @@ * 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. @@ -34,8 +34,8 @@ //#include "bass.h" namespace Audio { - class SeekableAudioStream; - class SoundHandle; +class SeekableAudioStream; +class SoundHandle; } namespace WinterMute { diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index a58878fd95..6b0ae4e6a6 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -8,12 +8,12 @@ * 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. @@ -261,7 +261,7 @@ byte CBSoundMgr::getVolumePercent(TSoundType Type) { break; } - return (byte )Volume; + return (byte)Volume; } diff --git a/engines/wintermute/BSoundMgr.h b/engines/wintermute/BSoundMgr.h index aa03edf1de..5cb130c081 100644 --- a/engines/wintermute/BSoundMgr.h +++ b/engines/wintermute/BSoundMgr.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index e8e9402fe7..f24ee23a78 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index 18731b682e..b2b99bc2db 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp index e53403c6f0..a8d10efd3c 100644 --- a/engines/wintermute/BStringTable.cpp +++ b/engines/wintermute/BStringTable.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h index f4d1bc254e..bbaf819eb7 100644 --- a/engines/wintermute/BStringTable.h +++ b/engines/wintermute/BStringTable.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index cea9d93257..0c57b9b79f 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -8,12 +8,12 @@ * 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. @@ -172,7 +172,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + ParseEditorProperty((byte *)params, false); break; } } diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h index 04be4e86c8..ec4e7204d0 100644 --- a/engines/wintermute/BSubFrame.h +++ b/engines/wintermute/BSubFrame.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSurface.cpp b/engines/wintermute/BSurface.cpp index 4fe97bcdeb..d08ceee6ea 100644 --- a/engines/wintermute/BSurface.cpp +++ b/engines/wintermute/BSurface.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSurface.h b/engines/wintermute/BSurface.h index 88fe58d17b..bd22d48d01 100644 --- a/engines/wintermute/BSurface.h +++ b/engines/wintermute/BSurface.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 9c1e1dc4dc..710c623a43 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -8,12 +8,12 @@ * 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. @@ -68,9 +68,9 @@ CBSurfaceSDL::~CBSurfaceSDL() { HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::String strFileName(Filename); - + Graphics::ImageDecoder *imgDecoder; - + if (strFileName.hasSuffix(".png")) { imgDecoder = new Graphics::PNGDecoder(); } else if (strFileName.hasSuffix(".bmp")) { @@ -78,10 +78,10 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, } else { error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); } - + CBFile *file = Game->_fileManager->OpenFile(Filename); if (!file) return E_FAIL; - + imgDecoder->loadStream(*file->getMemStream()); const Graphics::Surface *surface = imgDecoder->getSurface(); Game->_fileManager->CloseFile(file); @@ -98,41 +98,41 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); -/* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ + /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ } // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) -/* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { - FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - } else { - FreeImage_Unload(img); - return -1; - } - } - - FreeImage_FlipVertical(img);*/ + /* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { + FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + } else { + FreeImage_Unload(img); + return -1; + } + } + + FreeImage_FlipVertical(img);*/ //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: uint32 rmask = surface->format.rMax() << surface->format.rShift; uint32 gmask = surface->format.gMax() << surface->format.gShift; uint32 bmask = surface->format.bMax() << surface->format.bShift; uint32 amask = surface->format.aMax(); - + // SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); // no alpha, set color key -/* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ _surface = new Graphics::Surface(); _surface->copyFrom(*surface); - + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); @@ -194,11 +194,11 @@ void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { bool hasColorKey; Uint32 colorKey; Uint8 ckRed, ckGreen, ckBlue; -/* if (SDL_GetColorKey(surface, &colorKey) == 0) { - hasColorKey = true; - SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); - } else hasColorKey = false; -*/ //TODO + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ //TODO _alphaMask = new byte[surface->w * surface->h]; bool hasTransparency = false; @@ -438,7 +438,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo /* position.setWidth((float)srcRect.width() * ZoomX / 100.f); position.setHeight((float)srcRect.height() * ZoomX / 100.f); -*/ + */ position.setWidth(srcRect.width()); position.setHeight(srcRect.height()); diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index 71a74beb2d..5689e6234c 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -8,12 +8,12 @@ * 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. @@ -59,9 +59,9 @@ public: HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); -/* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); - static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); - static long DLL_CALLCONV TellProc(fi_handle handle);*/ + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ private: // SDL_Texture *_texture; diff --git a/engines/wintermute/BSurfaceStorage.cpp b/engines/wintermute/BSurfaceStorage.cpp index 0e22ae64fb..567df7d1f5 100644 --- a/engines/wintermute/BSurfaceStorage.cpp +++ b/engines/wintermute/BSurfaceStorage.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BSurfaceStorage.h b/engines/wintermute/BSurfaceStorage.h index e91b2a3e84..6ebf2b3992 100644 --- a/engines/wintermute/BSurfaceStorage.h +++ b/engines/wintermute/BSurfaceStorage.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp index 1d71fb656d..87cbb86a3d 100644 --- a/engines/wintermute/BTransitionMgr.cpp +++ b/engines/wintermute/BTransitionMgr.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BTransitionMgr.h b/engines/wintermute/BTransitionMgr.h index a0d9afebc8..2db5d4482e 100644 --- a/engines/wintermute/BTransitionMgr.h +++ b/engines/wintermute/BTransitionMgr.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BViewport.cpp b/engines/wintermute/BViewport.cpp index 718f98c939..397197a935 100644 --- a/engines/wintermute/BViewport.cpp +++ b/engines/wintermute/BViewport.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/BViewport.h b/engines/wintermute/BViewport.h index 7c90b568fb..98cc23ed25 100644 --- a/engines/wintermute/BViewport.h +++ b/engines/wintermute/BViewport.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index d2ac984b29..feb5f33274 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -61,11 +61,11 @@ GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { /* ////////////////////////////////////////////////////////////////////////// void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) { - if (stride == 0) stride = width; + if (stride == 0) stride = width; - _glyphs[ch] = new GlyphInfo(glyphIndex); - _glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); - _glyphs[ch]->SetGlyphImage(width, height, stride, pixels); + _glyphs[ch] = new GlyphInfo(glyphIndex); + _glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); + _glyphs[ch]->SetGlyphImage(width, height, stride, pixels); } */ diff --git a/engines/wintermute/Matrix4.h b/engines/wintermute/Matrix4.h index 866d5cdf34..e372f5747f 100644 --- a/engines/wintermute/Matrix4.h +++ b/engines/wintermute/Matrix4.h @@ -39,14 +39,14 @@ public: void RotationZ(float angle); void TransformVector2(Vector2 &vec); -/* union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - };*/ - float m[4][4]; + /* union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + };*/ + float m[4][4]; //}; }; diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp index 68f1c62c5a..63e0ca56d2 100644 --- a/engines/wintermute/PartParticle.cpp +++ b/engines/wintermute/PartParticle.cpp @@ -183,11 +183,11 @@ HRESULT CPartParticle::Display(CPartEmitter *Emitter) { _sprite->GetCurrentFrame(); return _sprite->Display(_pos.x, _pos.y, - NULL, - _scale, _scale, - DRGBA(255, 255, 255, _currentAlpha), - _rotation, - Emitter->_blendMode); + NULL, + _scale, _scale, + DRGBA(255, 255, 255, _currentAlpha), + _rotation, + Emitter->_blendMode); } diff --git a/engines/wintermute/PathUtil.cpp b/engines/wintermute/PathUtil.cpp index aea35e395f..336667525c 100644 --- a/engines/wintermute/PathUtil.cpp +++ b/engines/wintermute/PathUtil.cpp @@ -8,12 +8,12 @@ * 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. @@ -89,7 +89,7 @@ AnsiString PathUtil::GetFileName(const AnsiString &path) { AnsiString newPath = UnifySeparators(path); //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. - Common::String lastPart = Common::lastPathComponent(path,'/'); + Common::String lastPart = Common::lastPathComponent(path, '/'); if (lastPart[lastPart.size() - 1 ] != '/') return lastPart; else diff --git a/engines/wintermute/PathUtil.h b/engines/wintermute/PathUtil.h index 72dcf806b1..a07e3f6af2 100644 --- a/engines/wintermute/PathUtil.h +++ b/engines/wintermute/PathUtil.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 2837e16be6..8c6cc8d2e3 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -242,51 +242,51 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_MBUTTONUP: if (Game) Game->OnMouseMiddleUp(); break; -/*#ifdef __IPHONEOS__ - { - CBRenderSDL *renderer = static_cast(Game->_renderer); - POINT p; - GetCursorPos(&p); - Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - - if (Game->_activeObject != NULL && strcmp(Game->_activeObject->GetClassName(), "CUIButton") == 0) { - CUIButton *btn = static_cast(Game->_activeObject); - if (btn->_visible && !btn->_disable) btn->_press = true; - } - } -#endif*/ + /*#ifdef __IPHONEOS__ + { + CBRenderSDL *renderer = static_cast(Game->_renderer); + POINT p; + GetCursorPos(&p); + Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); + + if (Game->_activeObject != NULL && strcmp(Game->_activeObject->GetClassName(), "CUIButton") == 0) { + CUIButton *btn = static_cast(Game->_activeObject); + if (btn->_visible && !btn->_disable) btn->_press = true; + } + } + #endif*/ //TODO -/* case SDL_MOUSEWHEEL: - if (Game) Game->HandleMouseWheel(event->wheel.y); - break; - - case SDL_KEYDOWN: - case SDL_TEXTINPUT: - if (Game) Game->HandleKeypress(event); - break; - - case SDL_WINDOWEVENT: - switch (event->window.event) { - case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_RESTORED: - if (Game) Game->OnActivate(true, true); - SDL_ShowCursor(SDL_DISABLE); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - case SDL_WINDOWEVENT_MINIMIZED: -#ifndef __IPHONEOS__ - if (Game) Game->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); -#endif - break; - - case SDL_WINDOWEVENT_CLOSE: - break; - - } - break; -*/ + /* case SDL_MOUSEWHEEL: + if (Game) Game->HandleMouseWheel(event->wheel.y); + break; + + case SDL_KEYDOWN: + case SDL_TEXTINPUT: + if (Game) Game->HandleKeypress(event); + break; + + case SDL_WINDOWEVENT: + switch (event->window.event) { + case SDL_WINDOWEVENT_FOCUS_GAINED: + case SDL_WINDOWEVENT_RESTORED: + if (Game) Game->OnActivate(true, true); + SDL_ShowCursor(SDL_DISABLE); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + case SDL_WINDOWEVENT_MINIMIZED: + #ifndef __IPHONEOS__ + if (Game) Game->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); + #endif + break; + + case SDL_WINDOWEVENT_CLOSE: + break; + + } + break; + */ case Common::EVENT_QUIT: #ifdef __IPHONEOS__ if (Game) { @@ -308,12 +308,12 @@ void CBPlatform::HandleEvent(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { //TODO -/* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { - if (Game) Game->AutoSaveOnExit(); - if (Game) Game->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); - } -*/ + /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + if (Game) Game->AutoSaveOnExit(); + if (Game) Game->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); + } + */ return 1; } diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index cfb5b6e930..27de188030 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index 8ef6c55e88..d98f60d582 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -8,12 +8,12 @@ * 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. @@ -43,7 +43,7 @@ void StringUtil::ToLowerCase(AnsiString &str) { ////////////////////////////////////////////////////////////////////////// /*void StringUtil::ToLowerCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towlower); + std::transform(str.begin(), str.end(), str.begin(), ::towlower); }*/ ////////////////////////////////////////////////////////////////////////// @@ -53,7 +53,7 @@ void StringUtil::ToUpperCase(AnsiString &str) { ////////////////////////////////////////////////////////////////////////// /*void StringUtil::ToUpperCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towupper); + std::transform(str.begin(), str.end(), str.begin(), ::towupper); }*/ ////////////////////////////////////////////////////////////////////////// @@ -69,110 +69,110 @@ bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { ////////////////////////////////////////////////////////////////////////// /*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { - WideString str1lc = str1; - WideString str2lc = str2; + WideString str1lc = str1; + WideString str2lc = str2; - ToLowerCase(str1lc); - ToLowerCase(str2lc); + ToLowerCase(str1lc); + ToLowerCase(str2lc); - return (str1lc == str2lc); + return (str1lc == str2lc); }*/ ////////////////////////////////////////////////////////////////////////// WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { error("StringUtil::Utf8ToWide - WideString not supported yet"); -/* size_t WideSize = Utf8Str.size(); - - if (sizeof(wchar_t) == 2) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF16 *TargetStart = reinterpret_cast(WideStringNative); - UTF16 *TargetEnd = TargetStart + WideSize + 1; - - ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else if (sizeof(wchar_t) == 4) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF32 *TargetStart = reinterpret_cast(WideStringNative); - UTF32 *TargetEnd = TargetStart + WideSize; - - ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else { - return L""; - }*/ + /* size_t WideSize = Utf8Str.size(); + + if (sizeof(wchar_t) == 2) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF16 *TargetStart = reinterpret_cast(WideStringNative); + UTF16 *TargetEnd = TargetStart + WideSize + 1; + + ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else if (sizeof(wchar_t) == 4) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF32 *TargetStart = reinterpret_cast(WideStringNative); + UTF32 *TargetEnd = TargetStart + WideSize; + + ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else { + return L""; + }*/ return ""; } ////////////////////////////////////////////////////////////////////////// Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { error("StringUtil::WideToUtf8 - Widestring not supported yet"); -/* size_t WideSize = WideStr.length(); - - if (sizeof(wchar_t) == 2) { - size_t Utf8Size = 3 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF16 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else if (sizeof(wchar_t) == 4) { - size_t Utf8Size = 4 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF32 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else { - return (Utf8String)""; - }*/ + /* size_t WideSize = WideStr.length(); + + if (sizeof(wchar_t) == 2) { + size_t Utf8Size = 3 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF16 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else if (sizeof(wchar_t) == 4) { + size_t Utf8Size = 4 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF32 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else { + return (Utf8String)""; + }*/ return ""; } @@ -180,13 +180,13 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { WideString StringUtil::AnsiToWide(const AnsiString &str) { // using default os locale! error("StringUtil::AnsiToWide - WideString not supported yet"); -/* setlocale(LC_CTYPE, ""); - size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; - wchar_t *wstr = new wchar_t[WideSize]; - mbstowcs(wstr, str.c_str(), WideSize); - WideString ResultString(wstr); - delete [] wstr; - return ResultString;*/ + /* setlocale(LC_CTYPE, ""); + size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; + wchar_t *wstr = new wchar_t[WideSize]; + mbstowcs(wstr, str.c_str(), WideSize); + WideString ResultString(wstr); + delete [] wstr; + return ResultString;*/ return ""; } @@ -194,37 +194,37 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { AnsiString StringUtil::WideToAnsi(const WideString &wstr) { // using default os locale! error("StringUtil::WideToAnsi - WideString not supported yet"); -/* setlocale(LC_CTYPE, ""); - size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; - char *str = new char[WideSize]; - wcstombs(str, wstr.c_str(), WideSize); - AnsiString ResultString(str); - delete [] str; - return ResultString;*/ + /* setlocale(LC_CTYPE, ""); + size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; + char *str = new char[WideSize]; + wcstombs(str, wstr.c_str(), WideSize); + AnsiString ResultString(str); + delete [] str; + return ResultString;*/ return ""; } ////////////////////////////////////////////////////////////////////////// bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { -/* size_t strLength = str.size(); - size_t patternLength = pattern.size(); + /* size_t strLength = str.size(); + size_t patternLength = pattern.size(); - if (strLength < patternLength || patternLength == 0) - return false; + if (strLength < patternLength || patternLength == 0) + return false; - AnsiString startPart = str.substr(0, patternLength); + AnsiString startPart = str.substr(0, patternLength); - if (ignoreCase) return CompareNoCase(startPart, pattern); - else return (startPart == pattern);*/ + if (ignoreCase) return CompareNoCase(startPart, pattern); + else return (startPart == pattern);*/ if (!ignoreCase) return str.hasPrefix(pattern); else { size_t strLength = str.size(); size_t patternLength = pattern.size(); - + if (strLength < patternLength || patternLength == 0) return false; - + AnsiString startPart(str.c_str(), patternLength); uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); return (likeness == 0); @@ -233,25 +233,25 @@ bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bo ////////////////////////////////////////////////////////////////////////// bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { -/* size_t strLength = str.size(); // TODO: Remove - size_t patternLength = pattern.size(); + /* size_t strLength = str.size(); // TODO: Remove + size_t patternLength = pattern.size(); - if (strLength < patternLength || patternLength == 0) - return false; + if (strLength < patternLength || patternLength == 0) + return false; - AnsiString endPart = str.substr(strLength - patternLength, patternLength); + AnsiString endPart = str.substr(strLength - patternLength, patternLength); - if (ignoreCase) return CompareNoCase(endPart, pattern); - else return (endPart == pattern);*/ + if (ignoreCase) return CompareNoCase(endPart, pattern); + else return (endPart == pattern);*/ if (!ignoreCase) { return str.hasSuffix(pattern); } else { size_t strLength = str.size(); size_t patternLength = pattern.size(); - + if (strLength < patternLength || patternLength == 0) return false; - + Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); return (likeness != 0); @@ -272,19 +272,19 @@ AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, co size_t pos = 0; while (result.contains(from)) { - const char* startPtr = strstr(result.c_str(), from.c_str()); + const char *startPtr = strstr(result.c_str(), from.c_str()); uint32 index = startPtr - result.c_str(); - + Common::String tail(result.c_str() + index + to.size()); result = Common::String(result.c_str(), index); result += to; result += tail; - -/* pos = result.find(from, pos); - if (pos == result.npos) break; - result.replace(pos, from.size(), to); - pos += to.size();*/ + /* pos = result.find(from, pos); + if (pos == result.npos) break; + + result.replace(pos, from.size(), to); + pos += to.size();*/ } return result; @@ -311,7 +311,7 @@ int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t /*size_t pos = str.find(toFind, startFrom); if (pos == str.npos) return -1; else return pos;*/ - const char* index = strstr(str.c_str(), toFind.c_str()); + const char *index = strstr(str.c_str(), toFind.c_str()); if (index == NULL) return -1; else @@ -328,7 +328,7 @@ int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, siz for (int i = startFrom; i < str.size(); i++) { found = false; for (int j = 0; j < toFind.size(); j++) { - if (str[i+j] != toFind[j]) { + if (str[i + j] != toFind[j]) { found = false; break; } else { @@ -343,33 +343,33 @@ int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, siz ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(size_t val) { -/* std::ostringstream str; - str << val; - return str.str();*/ + /* std::ostringstream str; + str << val; + return str.str();*/ return Common::String::format("%u", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(int val) { -/* std::ostringstream str; - str << val; - return str.str();*/ + /* std::ostringstream str; + str << val; + return str.str();*/ return Common::String::format("%d", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(float val) { -/* std::ostringstream str; - str << val; - return str.str();*/ + /* std::ostringstream str; + str << val; + return str.str();*/ return Common::String::format("%f", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::ToString(double val) { -/* std::ostringstream str; - str << val; - return str.str();*/ + /* std::ostringstream str; + str << val; + return str.str();*/ return Common::String::format("%f", val); } diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h index f62f82db9a..1d3da609b6 100644 --- a/engines/wintermute/StringUtil.h +++ b/engines/wintermute/StringUtil.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp index b20c3f934a..90ac06eb80 100644 --- a/engines/wintermute/SysClass.cpp +++ b/engines/wintermute/SysClass.cpp @@ -8,12 +8,12 @@ * 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. @@ -88,12 +88,12 @@ CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { bool CSysClass::RemoveInstance(void *instance) { InstanceMap::iterator mapIt = _instanceMap.find(instance); if (mapIt == _instanceMap.end()) return false; -/* - Instances::iterator it = _instances.find((*mapIt).second); - if (it != _instances.end()) { - delete(*it); - _instances.erase(it); - }*/ + /* + Instances::iterator it = _instances.find((*mapIt).second); + if (it != _instances.end()) { + delete(*it); + _instances.erase(it); + }*/ delete mapIt->_value; _instanceMap.erase(mapIt); @@ -113,7 +113,7 @@ void *CSysClass::IDToPointer(int savedID) { //slow /*Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); + if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); }*/ InstanceMap::iterator it; for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { @@ -130,7 +130,7 @@ int CSysClass::GetNumInstances() { ////////////////////////////////////////////////////////////////////////// void CSysClass::Dump(void *stream) { - fprintf((FILE*)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); + fprintf((FILE *)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); } ////////////////////////////////////////////////////////////////////////// @@ -146,7 +146,7 @@ void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { /* Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - PersistMgr->PutDWORD((*it)->GetID()); + PersistMgr->PutDWORD((*it)->GetID()); }*/ } @@ -165,7 +165,7 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { } InstanceMap::iterator it = _instanceMap.begin(); -/* Instances::iterator it = _instances.begin();*/ + /* Instances::iterator it = _instances.begin();*/ if (it != _instanceMap.end()) { (it->_value)->SetSavedID(instId); CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index ca9ffe0082..df319b5d9b 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -8,12 +8,12 @@ * 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. @@ -39,8 +39,10 @@ namespace Common { template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(void* val) const { return (uint)((size_t)val); } +template<> struct Hash : public UnaryFunction { + uint operator()(void *val) const { + return (uint)((size_t)val); + } }; } diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp index 64dfa6a988..bd86502023 100644 --- a/engines/wintermute/SysClassRegistry.cpp +++ b/engines/wintermute/SysClassRegistry.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h index 84c4053ee9..1f92c94164 100644 --- a/engines/wintermute/SysClassRegistry.h +++ b/engines/wintermute/SysClassRegistry.h @@ -8,12 +8,12 @@ * 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. @@ -45,9 +45,11 @@ class CSysClass; } namespace Common { -template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysClass* val) const { return (uint)((size_t)val); } +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysClass *val) const { + return (uint)((size_t)val); + } }; } diff --git a/engines/wintermute/SysInstance.cpp b/engines/wintermute/SysInstance.cpp index fbbfea87cd..9e6a459bfc 100644 --- a/engines/wintermute/SysInstance.cpp +++ b/engines/wintermute/SysInstance.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/SysInstance.h b/engines/wintermute/SysInstance.h index 80221d13a9..b8e2531c4b 100644 --- a/engines/wintermute/SysInstance.h +++ b/engines/wintermute/SysInstance.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index 988760f567..15a9d6f49b 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -8,12 +8,12 @@ * 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. @@ -562,8 +562,8 @@ void CUIButton::CorrectSize() { if (_text) { int text_height; - if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); - else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); + if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); + else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); if (text_height > _height) _height = text_height; } @@ -631,8 +631,8 @@ HRESULT CUIButton::Display(int OffsetX, int OffsetY) { if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); if (font && _text) { - int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; - font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index a07b2adce6..de50431f2d 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 3c2abebd33..642504e82e 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -8,12 +8,12 @@ * 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. @@ -573,13 +573,13 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { _selEnd = MIN((size_t)_selEnd, strlen(_text)); //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int CursorWidth = font->GetTextWidth((byte *)_cursorChar); + int CursorWidth = font->GetTextWidth((byte *)_cursorChar); int s1, s2; bool CurFirst; // modify scroll offset if (_selStart >= _selEnd) { - while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= strlen(_text)) break; } @@ -590,8 +590,8 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { s2 = _selStart; CurFirst = true; } else { - while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selStart - _scrollOffset)) + - sfont->GetTextWidth((byte *)(_text + std::max(_scrollOffset, _selStart)), _selEnd - std::max(_scrollOffset, _selStart)) + while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selStart - _scrollOffset)) + + sfont->GetTextWidth((byte *)(_text + std::max(_scrollOffset, _selStart)), _selEnd - std::max(_scrollOffset, _selStart)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; @@ -625,9 +625,9 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { // unselected 1 if (s1 > _scrollOffset) { - if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); - xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); } // cursor @@ -638,7 +638,7 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { _cursorVisible = !_cursorVisible; } if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; @@ -648,9 +648,9 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { int s3 = std::max(s1, _scrollOffset); if (s2 - s3 > 0) { - if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); } // cursor @@ -661,15 +661,15 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { _cursorVisible = !_cursorVisible; } if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; } // unselected 2 - if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->GetTextWidth((byte *)_text + s2); + if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->GetTextWidth((byte *)_text + s2); AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; if (AlignOffset < 0) AlignOffset = 0; @@ -775,7 +775,7 @@ bool CUIEdit::HandleKeypress(Common::Event *event) { if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); WideString wstr = StringUtil::Utf8ToWide(event->text.text); - _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); if (Game->_textRTL) _selEnd = _selStart; else _selStart = _selEnd; diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index 05c6f14973..762332e60c 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index ca4528e6cf..f0b7e7a68f 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h index 3b8107b5d7..f55160b4d4 100644 --- a/engines/wintermute/UIEntity.h +++ b/engines/wintermute/UIEntity.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index 8a25c56cf5..468ababfc1 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h index 6646887a2c..1f982ce830 100644 --- a/engines/wintermute/UIObject.h +++ b/engines/wintermute/UIObject.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index d0770224c5..92e917ab36 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -8,12 +8,12 @@ * 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. @@ -79,12 +79,12 @@ HRESULT CUIText::Display(int OffsetX, int OffsetY) { text_offset = 0; break; case VAL_BOTTOM: - text_offset = _height - font->GetTextHeight((byte *)_text, _width); + text_offset = _height - font->GetTextHeight((byte *)_text, _width); break; default: - text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; } - font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); + font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); } //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); @@ -387,7 +387,7 @@ HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HeightToFit") == 0) { Stack->CorrectParams(0); - if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); + if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); Stack->PushNULL(); return S_OK; } @@ -475,8 +475,8 @@ HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::SizeToFit() { if (_font && _text) { - _width = _font->GetTextWidth((byte *)_text); - _height = _font->GetTextHeight((byte *)_text, _width); + _width = _font->GetTextWidth((byte *)_text); + _height = _font->GetTextHeight((byte *)_text, _width); } return S_OK; } diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h index aef5ea1be7..8071461ede 100644 --- a/engines/wintermute/UIText.h +++ b/engines/wintermute/UIText.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp index 4cdf9370fc..1f210fd89d 100644 --- a/engines/wintermute/UITiledImage.cpp +++ b/engines/wintermute/UITiledImage.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UITiledImage.h b/engines/wintermute/UITiledImage.h index 6e4b4d31d3..03d15a0daa 100644 --- a/engines/wintermute/UITiledImage.h +++ b/engines/wintermute/UITiledImage.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index db5e91a23c..eeeb11d836 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -8,12 +8,12 @@ * 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. @@ -182,7 +182,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { - font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); @@ -360,7 +360,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_INACTIVE: delete _imageInactive, - _imageInactive = new CBSprite(Game); + _imageInactive = new CBSprite(Game); if (!_imageInactive || FAILED(_imageInactive->LoadFile((char *)params))) { delete _imageInactive; _imageInactive = NULL; @@ -1294,7 +1294,7 @@ void CUIWindow::MakeFreezable(bool Freezable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GetWindowObjects(CBArray& Objects, bool InteractiveOnly) { +HRESULT CUIWindow::GetWindowObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _widgets.GetSize(); i++) { CUIObject *Control = _widgets[i]; if (Control->_disable && InteractiveOnly) continue; diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index e2a134282d..deb6bd0a1b 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -8,12 +8,12 @@ * 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. @@ -38,7 +38,7 @@ class CUIButton; class CBViewport; class CUIWindow : public CUIObject { public: - HRESULT GetWindowObjects(CBArray& Objects, bool InteractiveOnly); + HRESULT GetWindowObjects(CBArray &Objects, bool InteractiveOnly); bool _pauseMusic; void Cleanup(); diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 6bbadd6787..0e0c3fbe75 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -8,12 +8,12 @@ * 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. @@ -189,7 +189,7 @@ template CBArray::~CBArray() { if (_pData != NULL) { DCDestructElements(_pData, _nSize); - delete[](byte *)_pData; + delete[](byte *)_pData; } } @@ -203,7 +203,7 @@ void CBArray::SetSize(int nNewSize, int nGrowBy) { // shrink to nothing if (_pData != NULL) { DCDestructElements(_pData, _nSize); - delete[](byte *)_pData; + delete[](byte *)_pData; _pData = NULL; } _nSize = _nMaxSize = 0; @@ -246,7 +246,7 @@ void CBArray::SetSize(int nNewSize, int nGrowBy) { DCConstructElements(&pNewData[_nSize], nNewSize - _nSize); // get rid of old stuff (note: no destructors called) - delete[](byte *)_pData; + delete[](byte *)_pData; _pData = pNewData; _nSize = nNewSize; _nMaxSize = nNewMax; @@ -282,7 +282,7 @@ void CBArray::FreeExtra() { } // get rid of old stuff (note: no destructors called) - delete[](byte *)_pData; + delete[](byte *)_pData; _pData = pNewData; _nMaxSize = _nSize; } diff --git a/engines/wintermute/crc.cpp b/engines/wintermute/crc.cpp index 503f8242fa..adfd5da624 100644 --- a/engines/wintermute/crc.cpp +++ b/engines/wintermute/crc.cpp @@ -224,7 +224,7 @@ crc crc_initialize(void) { crc crc_process_byte(unsigned char byte, crc remainder) { unsigned char data; - data = (unsigned char)(REFLECT_DATA(byte ) ^ (remainder >> (WIDTH - 8))); + data = (unsigned char)(REFLECT_DATA(byte) ^ (remainder >> (WIDTH - 8))); remainder = crcTable[data] ^ (remainder << 8); return remainder; } diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 8fba050f34..855da1d542 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h index f3ecb0d645..e5db019e1d 100644 --- a/engines/wintermute/dcpackage.h +++ b/engines/wintermute/dcpackage.h @@ -59,7 +59,7 @@ struct TPackageHeader { PackageVersion = stream->readUint32LE(); GameVersion = stream->readUint32LE(); - + Priority = stream->readByte(); CD = stream->readByte(); MasterIndex = stream->readByte(); diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h index 98e4f74c53..2ebb0fe11a 100644 --- a/engines/wintermute/dcscript.h +++ b/engines/wintermute/dcscript.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index bd5ec3b6e5..f295b01df1 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -8,12 +8,12 @@ * 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. @@ -141,12 +141,12 @@ enum TMouseButton { }; -enum TTransMgrState{ +enum TTransMgrState { TRANS_MGR_RUNNING, TRANS_MGR_READY }; -enum TTransitionType{ +enum TTransitionType { TRANSITION_NONE = 0, TRANSITION_FADE_OUT = 1, TRANSITION_FADE_IN = 2, diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 7c4da190dd..39bb3f1c55 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -8,12 +8,12 @@ * 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. @@ -38,11 +38,11 @@ public: virtual const char *getName() const { return "WinterMute Lite"; } - + virtual const char *getOriginalCopyright() const { return "Copyright (c) 2011 Jan Nedoma"; } - + virtual GameList getSupportedGames() const { GameList games; const PlainGameDescriptor *g = WinterMute_setting; @@ -50,10 +50,10 @@ public: games.push_back(*g); g++; } - + return games; } - + virtual GameDescriptor findGame(const char *gameid) const { const PlainGameDescriptor *g = WinterMute_setting; while (g->gameid) { @@ -63,15 +63,15 @@ public: } return GameDescriptor(g->gameid, g->description); } - + virtual GameList detectGames(const Common::FSList &fslist) const { GameList detectedGames; - + // Iterate over all files in the given directory for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { if (!file->isDirectory()) { const char *gameName = file->getName().c_str(); - + if (0 == scumm_stricmp("data.dcp", gameName)) { // You could check the contents of the file now if you need to. detectedGames.push_back(WinterMute_setting[0]); @@ -81,22 +81,22 @@ public: } return detectedGames; } - + virtual Common::Error createInstance(OSystem *syst, Engine **engine) const { assert(syst); assert(engine); - + // Scan the target directory for files (error out if it does not exist) Common::FSList fslist; Common::FSNode dir(ConfMan.get("path")); if (!dir.getChildren(fslist, Common::FSNode::kListAll)) { return Common::kNoGameDataFoundError; } - + // Invoke the detector Common::String gameid = ConfMan.get("gameid"); GameList detectedGames = detectGames(fslist); - + for (uint i = 0; i < detectedGames.size(); i++) { if (detectedGames[i].gameid() == gameid) { // At this point you may want to perform additional sanity checks. @@ -104,7 +104,7 @@ public: return Common::kNoError; } } - + // Failed to find any game data return Common::kNoGameDataFoundError; } diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 4b528c7947..7a63ff326c 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -8,12 +8,12 @@ * 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. @@ -32,61 +32,61 @@ #include "wintypes.h" namespace WinterMute { - - class CBPersistMgr; - - // persistence support - typedef void *(WINAPI *PERSISTBUILD)(void); - typedef HRESULT(WINAPI *PERSISTLOAD)(void *, CBPersistMgr *); - typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); + +class CBPersistMgr; + +// persistence support +typedef void *(WINAPI *PERSISTBUILD)(void); +typedef HRESULT(WINAPI *PERSISTLOAD)(void *, CBPersistMgr *); +typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute #include "SysClass.h" #include "SysClassRegistry.h" namespace WinterMute { - + #define DECLARE_PERSISTENT(class_name, parent_class)\ -static const char _className[];\ -static void* WINAPI PersistBuild(void);\ -virtual const char* GetClassName();\ -static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ -class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ -virtual HRESULT Persist(CBPersistMgr* PersistMgr);\ -void* operator new (size_t size);\ -void operator delete(void* p);\ + static const char _className[];\ + static void* WINAPI PersistBuild(void);\ + virtual const char* GetClassName();\ + static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ + virtual HRESULT Persist(CBPersistMgr* PersistMgr);\ + void* operator new (size_t size);\ + void operator delete(void* p);\ + - #define IMPLEMENT_PERSISTENT(class_name, persistent_class)\ -const char class_name::_className[] = #class_name;\ -void* class_name::PersistBuild(){\ -return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ -}\ -\ -HRESULT class_name::PersistLoad(void* Instance, CBPersistMgr* PersistMgr){\ -return ((class_name*)Instance)->Persist(PersistMgr);\ -}\ -\ -const char* class_name::GetClassName(){\ -return #class_name;\ -}\ -\ -CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ -\ -void* class_name::operator new (size_t size){\ -void* ret = ::operator new(size);\ -CSysClassRegistry::GetInstance()->RegisterInstance(#class_name, ret);\ -return ret;\ -}\ -\ -void class_name::operator delete (void* p){\ -CSysClassRegistry::GetInstance()->UnregisterInstance(#class_name, p);\ -::operator delete(p);\ -}\ - + const char class_name::_className[] = #class_name;\ + void* class_name::PersistBuild(){\ + return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ + }\ + \ + HRESULT class_name::PersistLoad(void* Instance, CBPersistMgr* PersistMgr){\ + return ((class_name*)Instance)->Persist(PersistMgr);\ + }\ + \ + const char* class_name::GetClassName(){\ + return #class_name;\ + }\ + \ + CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ + \ + void* class_name::operator new (size_t size){\ + void* ret = ::operator new(size);\ + CSysClassRegistry::GetInstance()->RegisterInstance(#class_name, ret);\ + return ret;\ + }\ + \ + void class_name::operator delete (void* p){\ + CSysClassRegistry::GetInstance()->UnregisterInstance(#class_name, p);\ + ::operator delete(p);\ + }\ + #define TMEMBER(member_name) #member_name, &member_name #define TMEMBER_INT(member_name) #member_name, (int*)&member_name - + } // end of namespace WinterMute #endif // WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 77a90b7f12..7ac7dd5460 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h index 8907ec2602..f3ae690ab2 100644 --- a/engines/wintermute/scriptables/SXArray.h +++ b/engines/wintermute/scriptables/SXArray.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index 193521d44d..d04e4c5add 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -250,9 +250,9 @@ HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); #if 0 if (PersistMgr->_saving) - PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); + PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); else - PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); + PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); #endif return S_OK; } diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h index ca9744e6ab..1947925f02 100644 --- a/engines/wintermute/scriptables/SXDate.h +++ b/engines/wintermute/scriptables/SXDate.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index fa860e56b6..a27376750a 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -200,7 +200,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); + byte *Buf = (byte *)malloc(BufSize); uint32 Counter = 0; byte b; bool FoundNewLine = false; @@ -210,7 +210,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (FAILED(Ret)) break; if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); BufSize += FILE_BUFFER_SIZE; } if (b == '\n') { @@ -225,7 +225,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } while (SUCCEEDED(Ret)); if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); BufSize += FILE_BUFFER_SIZE; } Buf[Counter] = '\0'; @@ -251,7 +251,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); + byte *Buf = (byte *)malloc(BufSize); uint32 Counter = 0; byte b; @@ -261,7 +261,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (FAILED(Ret)) break; if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); BufSize += FILE_BUFFER_SIZE; } if (b == 0x0D) continue; @@ -272,7 +272,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); BufSize += FILE_BUFFER_SIZE; } Buf[Counter] = '\0'; @@ -335,7 +335,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } byte Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val); + if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte)))) Stack->PushInt(Val); else Stack->PushNULL(); return S_OK; diff --git a/engines/wintermute/scriptables/SXMath.cpp b/engines/wintermute/scriptables/SXMath.cpp index bcd2e96495..59961fb5f1 100644 --- a/engines/wintermute/scriptables/SXMath.cpp +++ b/engines/wintermute/scriptables/SXMath.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXMath.h b/engines/wintermute/scriptables/SXMath.h index 3169990159..59064c877f 100644 --- a/engines/wintermute/scriptables/SXMath.h +++ b/engines/wintermute/scriptables/SXMath.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 93d8e2e23b..9aea2b0c4c 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -8,12 +8,12 @@ * 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. @@ -91,7 +91,7 @@ HRESULT CSXMemBuffer::Resize(int NewSize) { } if (_buffer && _size > OldSize) { - memset((byte *)_buffer + OldSize, 0, _size - OldSize); + memset((byte *)_buffer + OldSize, 0, _size - OldSize); } return S_OK; } @@ -138,7 +138,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); - else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); + else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); return S_OK; } @@ -149,8 +149,8 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "GetByte") == 0) { Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushNULL(); - else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); + if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushNULL(); + else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); return S_OK; } @@ -162,7 +162,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); - else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); + else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -174,7 +174,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); - else Stack->PushInt(*(int *)((byte *)_buffer + Start)); + else Stack->PushInt(*(int *)((byte *)_buffer + Start)); return S_OK; } @@ -186,7 +186,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); - else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); + else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); return S_OK; } @@ -198,7 +198,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); - else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); + else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); return S_OK; } @@ -240,7 +240,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack int Start = Stack->Pop()->GetInt(); if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); else { - void *Pointer = *(void **)((byte *)_buffer + Start); + void *Pointer = *(void **)((byte *)_buffer + Start); CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); Stack->PushNative(Buf, false); } @@ -257,7 +257,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); else { - *(bool *)((byte *)_buffer + Start) = Val; + *(bool *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -269,11 +269,11 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "SetByte") == 0) { Stack->CorrectParams(2); int Start = Stack->Pop()->GetInt(); - byte Val = (byte )Stack->Pop()->GetInt(); + byte Val = (byte)Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(byte ))) Stack->PushBool(false); + if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushBool(false); else { - *(byte *)((byte *)_buffer + Start) = Val; + *(byte *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -289,7 +289,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); else { - *(short *)((byte *)_buffer + Start) = Val; + *(short *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -305,7 +305,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); else { - *(int *)((byte *)_buffer + Start) = Val; + *(int *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -321,7 +321,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); else { - *(float *)((byte *)_buffer + Start) = Val; + *(float *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -337,7 +337,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); else { - *(double *)((byte *)_buffer + Start) = Val; + *(double *)((byte *)_buffer + Start) = Val; Stack->PushBool(true); } return S_OK; @@ -353,7 +353,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); else { - memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); + memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); Stack->PushBool(true); } return S_OK; @@ -454,11 +454,11 @@ HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_size)); if (PersistMgr->_saving) { - if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); + if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); } else { if (_size > 0) { _buffer = malloc(_size); - PersistMgr->GetBytes((byte *)_buffer, _size); + PersistMgr->GetBytes((byte *)_buffer, _size); } else _buffer = NULL; } diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h index 9c6553bd89..e63601a113 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.h +++ b/engines/wintermute/scriptables/SXMemBuffer.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index d9e1c246c4..acc846dccc 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -103,22 +103,22 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (end < start) CBUtils::Swap(&start, &end); //try { - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); - // } catch (std::exception &) { - // Stack->PushNULL(); - // } + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // Stack->PushNULL(); + // } return S_OK; } @@ -141,19 +141,19 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (val->IsNULL()) len = strlen(_string) - start; // try { - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); // WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); + WideString subStr(str.c_str() + start, len); - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { // Stack->PushNULL(); // } @@ -371,11 +371,11 @@ HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_capacity)); if (PersistMgr->_saving) { - if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); + if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); } else { if (_capacity > 0) { _string = new char[_capacity]; - PersistMgr->GetBytes((byte *)_string, _capacity); + PersistMgr->GetBytes((byte *)_string, _capacity); } else _string = NULL; } diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h index 8abddf244d..a303f2d190 100644 --- a/engines/wintermute/scriptables/SXString.h +++ b/engines/wintermute/scriptables/SXString.h @@ -8,12 +8,12 @@ * 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. @@ -47,7 +47,7 @@ public: CSXString(CBGame *inGame, CScStack *Stack); virtual ~CSXString(); - + private: char *_string; int _capacity; diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index bfdfb53fa0..9c690b1c1f 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -8,12 +8,12 @@ * 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. @@ -319,7 +319,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I // We have const char* everywhere but in the DLL-interfaces... char *tempFileName = new char[strlen(Filename) + 1]; memcpy(tempFileName, Filename, strlen(Filename) + 1); - + SetFileToCompile(Filename); CompBuffer = ExtCompileFile(tempFileName, &CompSize); delete[] tempFileName; @@ -828,26 +828,26 @@ void CScEngine::DisableProfiling() { ////////////////////////////////////////////////////////////////////////// void CScEngine::DumpStats() { error("DumpStats not ported to ScummVM yet"); -/* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; + /* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; - typedef std::vector > TimeVector; - TimeVector times; + typedef std::vector > TimeVector; + TimeVector times; - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); - TimeVector::reverse_iterator tit; + TimeVector::reverse_iterator tit; - Game->LOG(0, "***** Script profiling information: *****"); - Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + Game->LOG(0, "***** Script profiling information: *****"); + Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - for (tit = times.rbegin(); tit != times.rend(); tit++) { - Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ + for (tit = times.rbegin(); tit != times.rend(); tit++) { + Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ } } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index d034bf8ed6..c633a98d6c 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp index 3678701cf4..611ce4124f 100644 --- a/engines/wintermute/scriptables/ScScript.cpp +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -8,12 +8,12 @@ * 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. @@ -1322,7 +1322,7 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: Buffer->PutDWORD(Val->GetInt()); break; case TYPE_BYTE: - Buffer->PutDWORD((byte )Val->GetInt()); + Buffer->PutDWORD((byte)Val->GetInt()); break; case TYPE_STRING: if (Val->IsNULL()) Buffer->PutDWORD(0); @@ -1363,13 +1363,13 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: // return switch (Function->returns) { case TYPE_BOOL: - Stack->PushBool((byte )ret != 0); + Stack->PushBool((byte)ret != 0); break; case TYPE_LONG: Stack->PushInt(ret); break; case TYPE_BYTE: - Stack->PushInt((byte )ret); + Stack->PushInt((byte)ret); break; break; case TYPE_STRING: diff --git a/engines/wintermute/scriptables/ScScript.h b/engines/wintermute/scriptables/ScScript.h index 588f57512e..ce9548fc99 100644 --- a/engines/wintermute/scriptables/ScScript.h +++ b/engines/wintermute/scriptables/ScScript.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/ScStack.cpp b/engines/wintermute/scriptables/ScStack.cpp index c7b724e9b2..0d097c69c7 100644 --- a/engines/wintermute/scriptables/ScStack.cpp +++ b/engines/wintermute/scriptables/ScStack.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/ScStack.h b/engines/wintermute/scriptables/ScStack.h index 113fb4c19f..811492c6ca 100644 --- a/engines/wintermute/scriptables/ScStack.h +++ b/engines/wintermute/scriptables/ScStack.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 3576c0a618..72baddbbc8 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 7c87c8e707..92ee09f0c5 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index de5d00e677..13885dd2e6 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -8,12 +8,12 @@ * 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. @@ -107,7 +107,7 @@ void CBUtils::CreatePath(const char *Path, bool PathOnly) { warning("CBUtils::CreatePath - not implemented: %s", Path); // boost::filesystem::create_directories(path); // } catch (...) { - return; + return; // } } diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h index fb61ae6571..fa83a51ad4 100644 --- a/engines/wintermute/utils.h +++ b/engines/wintermute/utils.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index e6b273b291..e83261225f 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -8,12 +8,12 @@ * 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. @@ -36,84 +36,84 @@ #include "engines/wintermute/PlatformSDL.h" namespace WinterMute { - - WinterMuteEngine::WinterMuteEngine(OSystem *syst) + +WinterMuteEngine::WinterMuteEngine(OSystem *syst) : Engine(syst) { - // Put your engine in a sane state, but do nothing big yet; - // in particular, do not load data from files; rather, if you - // need to do such things, do them from init(). - - // Do not initialize graphics here - - // However this is the place to specify all default directories - const Common::FSNode gameDataDir(ConfMan.get("path")); - //SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); - - // Here is the right place to set up the engine specific debug channels - DebugMan.addDebugChannel(kWinterMuteDebugExample, "example", "this is just an example for a engine specific debug channel"); - DebugMan.addDebugChannel(kWinterMuteDebugExample2, "example2", "also an example"); - - // Don't forget to register your random source - _rnd = new Common::RandomSource("WinterMute"); - - debug("WinterMuteEngine::WinterMuteEngine"); - } - - WinterMuteEngine::~WinterMuteEngine() { - debug("WinterMuteEngine::~WinterMuteEngine"); - - // Dispose your resources here - delete _rnd; - - // Remove all of our debug levels here - DebugMan.clearAllDebugChannels(); - } - - Common::Error WinterMuteEngine::run() { - // Initialize graphics using following: - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - initGraphics(800, 600, false, &format); - - // You could use backend transactions directly as an alternative, - // but it isn't recommended, until you want to handle the error values - // from OSystem::endGFXTransaction yourself. - // This is just an example template: - //_system->beginGFXTransaction(); - // // This setup the graphics mode according to users seetings - // initCommonGFX(false); - // - // // Specify dimensions of game graphics window. - // // In this example: 320x200 - // _system->initSize(320, 200); - //FIXME: You really want to handle - //OSystem::kTransactionSizeChangeFailed here - //_system->endGFXTransaction(); - - // Create debugger console. It requires GFX to be initialized - _console = new Console(this); - - // Additional setup. - debug("WinterMuteEngine::init"); - - // Your main even loop should be (invoked from) here. - debug("WinterMuteEngine::go: Hello, World!"); - - // This test will show up if -d1 and --debugflags=example are specified on the commandline - debugC(1, kWinterMuteDebugExample, "Example debug call"); - - // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline - debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); - - CAdGame *game = new CAdGame; - - int ret = 1; - - ret = CBPlatform::Initialize(game, NULL, 0); - - if (ret == 0) { - ret = CBPlatform::MessageLoop(); - } - return Common::kNoError; + // Put your engine in a sane state, but do nothing big yet; + // in particular, do not load data from files; rather, if you + // need to do such things, do them from init(). + + // Do not initialize graphics here + + // However this is the place to specify all default directories + const Common::FSNode gameDataDir(ConfMan.get("path")); + //SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); + + // Here is the right place to set up the engine specific debug channels + DebugMan.addDebugChannel(kWinterMuteDebugExample, "example", "this is just an example for a engine specific debug channel"); + DebugMan.addDebugChannel(kWinterMuteDebugExample2, "example2", "also an example"); + + // Don't forget to register your random source + _rnd = new Common::RandomSource("WinterMute"); + + debug("WinterMuteEngine::WinterMuteEngine"); +} + +WinterMuteEngine::~WinterMuteEngine() { + debug("WinterMuteEngine::~WinterMuteEngine"); + + // Dispose your resources here + delete _rnd; + + // Remove all of our debug levels here + DebugMan.clearAllDebugChannels(); +} + +Common::Error WinterMuteEngine::run() { + // Initialize graphics using following: + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + initGraphics(800, 600, false, &format); + + // You could use backend transactions directly as an alternative, + // but it isn't recommended, until you want to handle the error values + // from OSystem::endGFXTransaction yourself. + // This is just an example template: + //_system->beginGFXTransaction(); + // // This setup the graphics mode according to users seetings + // initCommonGFX(false); + // + // // Specify dimensions of game graphics window. + // // In this example: 320x200 + // _system->initSize(320, 200); + //FIXME: You really want to handle + //OSystem::kTransactionSizeChangeFailed here + //_system->endGFXTransaction(); + + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); + + // Additional setup. + debug("WinterMuteEngine::init"); + + // Your main even loop should be (invoked from) here. + debug("WinterMuteEngine::go: Hello, World!"); + + // This test will show up if -d1 and --debugflags=example are specified on the commandline + debugC(1, kWinterMuteDebugExample, "Example debug call"); + + // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline + debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); + + CAdGame *game = new CAdGame; + + int ret = 1; + + ret = CBPlatform::Initialize(game, NULL, 0); + + if (ret == 0) { + ret = CBPlatform::MessageLoop(); } - + return Common::kNoError; +} + } // End of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 33ed2892ff..efa07ac669 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -8,12 +8,12 @@ * 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. @@ -28,38 +28,38 @@ #include "gui/debugger.h" namespace WinterMute { - - class Console; - - // our engine debug channels - enum { - kWinterMuteDebugExample = 1 << 0, - kWinterMuteDebugExample2 = 1 << 1 - // next new channel must be 1 << 2 (4) - // the current limitation is 32 debug channels (1 << 31 is the last one) - }; - - class WinterMuteEngine : public Engine { - public: - WinterMuteEngine(OSystem *syst); - ~WinterMuteEngine(); - - virtual Common::Error run(); - - private: - Console *_console; - - // We need random numbers - Common::RandomSource *_rnd; - }; - - // Example console class - class Console : public GUI::Debugger { - public: - Console(WinterMuteEngine *vm) {} - virtual ~Console(void) {} - }; - + +class Console; + +// our engine debug channels +enum { + kWinterMuteDebugExample = 1 << 0, + kWinterMuteDebugExample2 = 1 << 1 + // next new channel must be 1 << 2 (4) + // the current limitation is 32 debug channels (1 << 31 is the last one) +}; + +class WinterMuteEngine : public Engine { +public: + WinterMuteEngine(OSystem *syst); + ~WinterMuteEngine(); + + virtual Common::Error run(); + +private: + Console *_console; + + // We need random numbers + Common::RandomSource *_rnd; +}; + +// Example console class +class Console : public GUI::Debugger { +public: + Console(WinterMuteEngine *vm) {} + virtual ~Console(void) {} +}; + } // End of namespace Wintermute #endif \ No newline at end of file diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index c722b92c51..476676cbaa 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h index 0f084be75e..95e2a894ea 100644 --- a/engines/wintermute/wme_debugger.h +++ b/engines/wintermute/wme_debugger.h @@ -8,12 +8,12 @@ * 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. -- cgit v1.2.3 From ff1b42259a16b927bff5e213a72aeb27e7dfd629 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 16:25:53 +0200 Subject: WINTERMUTE: Unify license-headers, and header-guards. --- engines/wintermute/AdActor.h | 6 ++-- engines/wintermute/AdActorDir.h | 6 ++-- engines/wintermute/AdGame.h | 4 +-- engines/wintermute/AdInventory.h | 4 +-- engines/wintermute/AdInventoryBox.h | 4 +-- engines/wintermute/AdItem.h | 4 +-- engines/wintermute/AdLayer.h | 4 +-- engines/wintermute/AdNodeState.h | 4 +-- engines/wintermute/AdPath.h | 4 +-- engines/wintermute/AdPathPoint.h | 4 +-- engines/wintermute/AdRegion.h | 4 +-- engines/wintermute/AdResponse.h | 4 +-- engines/wintermute/AdResponseBox.h | 4 +-- engines/wintermute/AdResponseContext.h | 4 +-- engines/wintermute/AdRotLevel.h | 4 +-- engines/wintermute/AdScaleLevel.h | 4 +-- engines/wintermute/AdScene.h | 4 +-- engines/wintermute/AdSceneNode.h | 4 +-- engines/wintermute/AdSceneState.h | 4 +-- engines/wintermute/AdSentence.h | 4 +-- engines/wintermute/AdSpriteSet.h | 4 +-- engines/wintermute/AdTalkDef.h | 4 +-- engines/wintermute/AdTalkNode.h | 4 +-- engines/wintermute/AdTypes.h | 2 +- engines/wintermute/AdWaypointGroup.h | 4 +-- engines/wintermute/BImage.cpp | 49 +++++++++++++------------ engines/wintermute/BRenderSDL.h | 2 +- engines/wintermute/BScriptHolder.cpp | 49 +++++++++++++------------ engines/wintermute/BSurfaceSDL.h | 2 +- engines/wintermute/FontGlyphCache.cpp | 49 +++++++++++++------------ engines/wintermute/FontGlyphCache.h | 55 +++++++++++++++-------------- engines/wintermute/MathUtil.cpp | 49 +++++++++++++------------ engines/wintermute/MathUtil.h | 55 +++++++++++++++-------------- engines/wintermute/Matrix4.cpp | 49 +++++++++++++------------ engines/wintermute/Matrix4.h | 55 +++++++++++++++-------------- engines/wintermute/PartEmitter.cpp | 49 +++++++++++++------------ engines/wintermute/PartEmitter.h | 55 +++++++++++++++-------------- engines/wintermute/PartForce.cpp | 49 +++++++++++++------------ engines/wintermute/PartForce.h | 55 +++++++++++++++-------------- engines/wintermute/PartParticle.cpp | 49 +++++++++++++------------ engines/wintermute/PartParticle.h | 55 +++++++++++++++-------------- engines/wintermute/PathUtil.h | 6 ++-- engines/wintermute/PlatformSDL.cpp | 49 +++++++++++++------------ engines/wintermute/StringUtil.h | 2 +- engines/wintermute/Vector2.cpp | 49 +++++++++++++------------ engines/wintermute/Vector2.h | 55 +++++++++++++++-------------- engines/wintermute/dcpackage.h | 49 +++++++++++++------------ engines/wintermute/scriptables/SXDate.cpp | 49 +++++++++++++------------ engines/wintermute/scriptables/SXFile.cpp | 49 +++++++++++++------------ engines/wintermute/scriptables/SXFile.h | 55 +++++++++++++++-------------- engines/wintermute/scriptables/SXStore.cpp | 49 +++++++++++++------------ engines/wintermute/scriptables/SXStore.h | 55 +++++++++++++++-------------- engines/wintermute/scriptables/SXString.cpp | 49 +++++++++++++------------ engines/wintermute/scriptables/SXString.h | 4 +-- engines/wintermute/scriptables/SxObject.cpp | 49 +++++++++++++------------ engines/wintermute/scriptables/SxObject.h | 55 +++++++++++++++-------------- engines/wintermute/wintypes.h | 6 ++-- 57 files changed, 768 insertions(+), 690 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index c1e41237ee..6d91f5f67b 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdActor_H__ -#define __WmeAdActor_H__ +#ifndef WINTERMUTE_ADACTOR_H +#define WINTERMUTE_ADACTOR_H #include "dctypes.h" // Added by ClassView @@ -104,4 +104,4 @@ private: } // end of namespace WinterMute -#endif // __WmeAdActor_H__ +#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/AdActorDir.h b/engines/wintermute/AdActorDir.h index d4889f83fc..ffb9c1ff7c 100644 --- a/engines/wintermute/AdActorDir.h +++ b/engines/wintermute/AdActorDir.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdActorDir_H__ -#define __WmeAdActorDir_H__ +#ifndef WINTERMUTE_ADACTORDIR_H +#define WINTERMUTE_ADACTORDIR_H #include "persistent.h" #include "BBase.h" @@ -43,4 +43,4 @@ public: } // end of namespace WinterMute -#endif // __WmeAdActorDir_H__ \ No newline at end of file +#endif // WINTERMUTE_ADACTORDIR_H \ No newline at end of file diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h index e74793c8a0..f330ef550a 100644 --- a/engines/wintermute/AdGame.h +++ b/engines/wintermute/AdGame.h @@ -25,8 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdGame_H__ -#define __WmeAdGame_H__ +#ifndef WINTERMUTE_ADGAME_H +#define WINTERMUTE_ADGAME_H #include "AdTypes.h" #include "BGame.h" diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h index f85fc093eb..9ea3ade9a2 100644 --- a/engines/wintermute/AdInventory.h +++ b/engines/wintermute/AdInventory.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdInventory_H__ -#define __WmeAdInventory_H__ +#ifndef WINTERMUTE_ADINVENTORY_H +#define WINTERMUTE_ADINVENTORY_H #include "BObject.h" diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h index edfada69a1..9f7dba6a2b 100644 --- a/engines/wintermute/AdInventoryBox.h +++ b/engines/wintermute/AdInventoryBox.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdInventoryBox_H__ -#define __WmeAdInventoryBox_H__ +#ifndef WINTERMUTE_ADINVENTORYBOX_H +#define WINTERMUTE_ADINVENTORYBOX_H #include "BObject.h" diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index 51fe0559e2..50db9cc0b8 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdIte_h__ -#define __WmeAdIte_h__ +#ifndef WINTERMUTE_ADITEM_H +#define WINTERMUTE_ADITEM_H #include "AdTalkHolder.h" diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index afa80bec74..98081d217b 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdLayer_H__ -#define __WmeAdLayer_H__ +#ifndef WINTERMUTE_ADLAYER_H +#define WINTERMUTE_ADLAYER_H namespace WinterMute { class CAdSceneNode; diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h index 7b515e801c..16445376ca 100644 --- a/engines/wintermute/AdNodeState.h +++ b/engines/wintermute/AdNodeState.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdNodeState_H__ -#define __WmeAdNodeState_H__ +#ifndef WINTERMUTE_ADNODESTATE_H +#define WINTERMUTE_ADNODESTATE_H namespace WinterMute { diff --git a/engines/wintermute/AdPath.h b/engines/wintermute/AdPath.h index 3f7090815d..efc7ffa265 100644 --- a/engines/wintermute/AdPath.h +++ b/engines/wintermute/AdPath.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdPath_H__ -#define __WmeAdPath_H__ +#ifndef WINTERMUTE_ADPATH_H +#define WINTERMUTE_ADPATH_H #include "persistent.h" #include "coll_templ.h" diff --git a/engines/wintermute/AdPathPoint.h b/engines/wintermute/AdPathPoint.h index 649dab5012..86edade9d7 100644 --- a/engines/wintermute/AdPathPoint.h +++ b/engines/wintermute/AdPathPoint.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdPathPoint_H__ -#define __WmeAdPathPoint_H__ +#ifndef WINTERMUTE_ADPATHPOINT_H +#define WINTERMUTE_ADPATHPOINT_H #include "persistent.h" #include "BPoint.h" diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index 7c017be9c7..8f386036d1 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdRegion_H__ -#define __WmeAdRegion_H__ +#ifndef WINTERMUTE_ADREGION_H +#define WINTERMUTE_ADREGION_H #include "BRegion.h" diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h index 576092494b..09608c913e 100644 --- a/engines/wintermute/AdResponse.h +++ b/engines/wintermute/AdResponse.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdResponse_H__ -#define __WmeAdResponse_H__ +#ifndef WINTERMUTE_ADRESPONSE_H +#define WINTERMUTE_ADRESPONSE_H #include "BObject.h" diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h index 15996d7668..edc763a19b 100644 --- a/engines/wintermute/AdResponseBox.h +++ b/engines/wintermute/AdResponseBox.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdResponseBox_H__ -#define __WmeAdResponseBox_H__ +#ifndef WINTERMUTE_ADRESPONSEBOX_H +#define WINTERMUTE_ADRESPONSEBOX_H #include "BObject.h" diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h index c801e8a4e2..7bb91943e0 100644 --- a/engines/wintermute/AdResponseContext.h +++ b/engines/wintermute/AdResponseContext.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdResponseContext_H__ -#define __WmeAdResponseContext_H__ +#ifndef WINTERMUTE_ADRESPONSECONTEXT_H +#define WINTERMUTE_ADRESPONSECONTEXT_H #include "persistent.h" #include "BBase.h" diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h index 509f9a492a..a38027b281 100644 --- a/engines/wintermute/AdRotLevel.h +++ b/engines/wintermute/AdRotLevel.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdRotLevel_H__ -#define __WmeAdRotLevel_H__ +#ifndef WINTERMUTE_ADROTLEVEL_H +#define WINTERMUTE_ADROTLEVEL_H #include "BObject.h" diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h index b996ff7fb5..6f1776ea56 100644 --- a/engines/wintermute/AdScaleLevel.h +++ b/engines/wintermute/AdScaleLevel.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdScaleLevel_H__ -#define __WmeAdScaleLevel_H__ +#ifndef WINTERMUTE_ADSCALELEVEL_H +#define WINTERMUTE_ADSCALELEVEL_H #include "BObject.h" diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index 66c27c8c44..6023ec0547 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdScene_H__ -#define __WmeAdScene_H__ +#ifndef WINTERMUTE_ADSCENE_H +#define WINTERMUTE_ADSCENE_H #include "BFader.h" diff --git a/engines/wintermute/AdSceneNode.h b/engines/wintermute/AdSceneNode.h index 9f71706189..5514e5a40a 100644 --- a/engines/wintermute/AdSceneNode.h +++ b/engines/wintermute/AdSceneNode.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdSceneNode_H__ -#define __WmeAdSceneNode_H__ +#ifndef WINTERMUTE_ADSCENENODE_H +#define WINTERMUTE_ADSCENENODE_H #include "AdTypes.h" // Added by ClassView diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h index 36f304737e..4f135d3b9c 100644 --- a/engines/wintermute/AdSceneState.h +++ b/engines/wintermute/AdSceneState.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdSceneState_H__ -#define __WmeAdSceneState_H__ +#ifndef WINTERMUTE_ADSCENESTATE_H +#define WINTERMUTE_ADSCENESTATE_H #include "persistent.h" #include "BBase.h" diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h index c16826f46d..4e36ad118d 100644 --- a/engines/wintermute/AdSentence.h +++ b/engines/wintermute/AdSentence.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdSentence_H__ -#define __WmeAdSentence_H__ +#ifndef WINTERMUTE_ADSENTENCE_H +#define WINTERMUTE_ADSENTENCE_H #include "BBase.h" diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h index 689c64af7a..c4b1f28069 100644 --- a/engines/wintermute/AdSpriteSet.h +++ b/engines/wintermute/AdSpriteSet.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdSpriteSet_H__ -#define __WmeAdSpriteSet_H__ +#ifndef WINTERMUTE_ADSPRITESET_H +#define WINTERMUTE_ADSPRITESET_H #include "BObject.h" diff --git a/engines/wintermute/AdTalkDef.h b/engines/wintermute/AdTalkDef.h index 829c550147..f6ed505cbb 100644 --- a/engines/wintermute/AdTalkDef.h +++ b/engines/wintermute/AdTalkDef.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdTalkDef_H__ -#define __WmeAdTalkDef_H__ +#ifndef WINTERMUTE_ADTALKDEF_H +#define WINTERMUTE_ADTALKDEF_H #include "coll_templ.h" #include "BObject.h" diff --git a/engines/wintermute/AdTalkNode.h b/engines/wintermute/AdTalkNode.h index 105972c8da..89f541f6aa 100644 --- a/engines/wintermute/AdTalkNode.h +++ b/engines/wintermute/AdTalkNode.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdTalkNode_H__ -#define __WmeAdTalkNode_H__ +#ifndef WINTERMUTE_ADTALKNODE_H +#define WINTERMUTE_ADTALKNODE_H #include "persistent.h" #include "BBase.h" diff --git a/engines/wintermute/AdTypes.h b/engines/wintermute/AdTypes.h index d11e3b6553..6531927350 100644 --- a/engines/wintermute/AdTypes.h +++ b/engines/wintermute/AdTypes.h @@ -90,4 +90,4 @@ typedef enum { } // end of namespace WinterMute -#endif // __WmeAdTypes_H__ +#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h index 7a2641a23f..0ce4d8040f 100644 --- a/engines/wintermute/AdWaypointGroup.h +++ b/engines/wintermute/AdWaypointGroup.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeAdWaypointGroup_H__ -#define __WmeAdWaypointGroup_H__ +#ifndef WINTERMUTE_ADWAYPOINTGROUP_H +#define WINTERMUTE_ADWAYPOINTGROUP_H #include "BObject.h" diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp index f9f481f2d1..869d029e27 100644 --- a/engines/wintermute/BImage.cpp +++ b/engines/wintermute/BImage.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "dcgf.h" #include "BImage.h" diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 83199433e8..11b1b74054 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -93,4 +93,4 @@ private: } // end of namespace WinterMute -#endif // __WmeBRenderSDL_H__ +#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index 6210ba2f38..2cd070e925 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "dcgf.h" #include "engines/wintermute/AdGame.h" diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h index 5689e6234c..ca9727331f 100644 --- a/engines/wintermute/BSurfaceSDL.h +++ b/engines/wintermute/BSurfaceSDL.h @@ -78,4 +78,4 @@ private: } // end of namespace WinterMute -#endif // __WmeBSurfaceSDL_H__ +#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index feb5f33274..ea0acd4c19 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "FontGlyphCache.h" diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 0a42748107..3092c60a74 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -1,30 +1,33 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ -#ifndef __WmeFontGlyphCache_H__ -#define __WmeFontGlyphCache_H__ +#ifndef WINTERMUTE_FONTGLYPHCACHE_H +#define WINTERMUTE_FONTGLYPHCACHE_H #include "BFontStorage.h" @@ -119,4 +122,4 @@ private: } // end of namespace WinterMute -#endif // __WmeFontGlyphCache_H__ \ No newline at end of file +#endif // WINTERMUTE_FONTGLYPHCACHE_H \ No newline at end of file diff --git a/engines/wintermute/MathUtil.cpp b/engines/wintermute/MathUtil.cpp index bb85ea66fa..d6b526f5b6 100644 --- a/engines/wintermute/MathUtil.cpp +++ b/engines/wintermute/MathUtil.cpp @@ -1,27 +1,30 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "MathUtil.h" #include diff --git a/engines/wintermute/MathUtil.h b/engines/wintermute/MathUtil.h index ded73a91d4..bacf975d62 100644 --- a/engines/wintermute/MathUtil.h +++ b/engines/wintermute/MathUtil.h @@ -1,30 +1,33 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ -#ifndef __WmeMathUtil_H__ -#define __WmeMathUtil_H__ +#ifndef WINTERMUTE_MATHUTIL_H +#define WINTERMUTE_MATHUTIL_H namespace WinterMute { @@ -36,4 +39,4 @@ public: } // end of namespace WinterMute -#endif // __WmeMathUtil_H__ +#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/Matrix4.cpp b/engines/wintermute/Matrix4.cpp index 90a3f69f2c..eefc8ae303 100644 --- a/engines/wintermute/Matrix4.cpp +++ b/engines/wintermute/Matrix4.cpp @@ -1,27 +1,30 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/Matrix4.h" #include "engines/wintermute/Vector2.h" diff --git a/engines/wintermute/Matrix4.h b/engines/wintermute/Matrix4.h index e372f5747f..019c429789 100644 --- a/engines/wintermute/Matrix4.h +++ b/engines/wintermute/Matrix4.h @@ -1,30 +1,33 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ -#ifndef __WmeMatrix4_H__ -#define __WmeMatrix4_H__ +#ifndef WINTERMUTE_MATRIX4_H +#define WINTERMUTE_MATRIX4_H namespace WinterMute { @@ -53,4 +56,4 @@ public: } // end of namespace WinterMute -#endif // __WmeMatrix4_H__ \ No newline at end of file +#endif // WINTERMUTE_MATRIX4_H \ No newline at end of file diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index 6500f172c8..79bfa8a5b2 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/PartEmitter.h" diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h index 0949c294c3..66814558b1 100644 --- a/engines/wintermute/PartEmitter.h +++ b/engines/wintermute/PartEmitter.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmePartEmitter_H__ -#define __WmePartEmitter_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H #include "BObject.h" diff --git a/engines/wintermute/PartForce.cpp b/engines/wintermute/PartForce.cpp index 874ffdda1f..8431ebbda8 100644 --- a/engines/wintermute/PartForce.cpp +++ b/engines/wintermute/PartForce.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/PartForce.h b/engines/wintermute/PartForce.h index 6245b438db..f4830b3039 100644 --- a/engines/wintermute/PartForce.h +++ b/engines/wintermute/PartForce.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmePartForce_H__ -#define __WmePartForce_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H #include "BBase.h" diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp index 63e0ca56d2..8bbd54d3f9 100644 --- a/engines/wintermute/PartParticle.cpp +++ b/engines/wintermute/PartParticle.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/PartParticle.h" diff --git a/engines/wintermute/PartParticle.h b/engines/wintermute/PartParticle.h index 288c462b1d..e72089ad5f 100644 --- a/engines/wintermute/PartParticle.h +++ b/engines/wintermute/PartParticle.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmePartParticle_H__ -#define __WmePartParticle_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PATRPARTICLE_H +#define WINTERMUTE_PATRPARTICLE_H #include "BBase.h" diff --git a/engines/wintermute/PathUtil.h b/engines/wintermute/PathUtil.h index a07e3f6af2..6bdabdc9d7 100644 --- a/engines/wintermute/PathUtil.h +++ b/engines/wintermute/PathUtil.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPATHUTILS_H -#define WINTERMUTE_BPATHUTILS_H +#ifndef WINTERMUTE_PATHUTILS_H +#define WINTERMUTE_PATHUTILS_H #include "PlatformSDL.h" @@ -53,4 +53,4 @@ public: } // end of namespace WinterMute -#endif // __WmePathUtils_H__ +#endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 8c6cc8d2e3..fab72e29da 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/BGame.h" diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h index 1d3da609b6..5d3f1c668c 100644 --- a/engines/wintermute/StringUtil.h +++ b/engines/wintermute/StringUtil.h @@ -67,4 +67,4 @@ public: } // end of namespace WinterMute -#endif // __WmeStringUtil_H__ +#endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/Vector2.cpp b/engines/wintermute/Vector2.cpp index 6c8d0ae168..b2fa56dff4 100644 --- a/engines/wintermute/Vector2.cpp +++ b/engines/wintermute/Vector2.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "Vector2.h" #include diff --git a/engines/wintermute/Vector2.h b/engines/wintermute/Vector2.h index 032a6f270b..aa3fe5aa86 100644 --- a/engines/wintermute/Vector2.h +++ b/engines/wintermute/Vector2.h @@ -1,30 +1,33 @@ -/* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +/* 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. + * + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ -#ifndef __WmeVector2_H__ -#define __WmeVector2_H__ +#ifndef WINTERMUTE_VECTOR2_H +#define WINTERMUTE_VECTOR2_H namespace WinterMute { @@ -69,4 +72,4 @@ public: } // end of namespace WinterMute -#endif // __WmeVector2_H__ +#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h index e5db019e1d..292248cf5c 100644 --- a/engines/wintermute/dcpackage.h +++ b/engines/wintermute/dcpackage.h @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #ifndef _DCPACKAGE_H_ #define _DCPACKAGE_H_ diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index d04e4c5add..9c16b3595e 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/scriptables/ScStack.h" #include "engines/wintermute/scriptables/ScValue.h" diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index a27376750a..7d6b0ebcc1 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/SysClassRegistry.h" #include "engines/wintermute/SysClass.h" diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h index 22bfc5ec70..daa63c305c 100644 --- a/engines/wintermute/scriptables/SXFile.h +++ b/engines/wintermute/scriptables/SXFile.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmeSXFile_H__ -#define __WmeSXFile_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H #include "engines/wintermute/BScriptable.h" diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index 79a4f9bbc0..9308065499 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/BGame.h" #include "engines/wintermute/BRegistry.h" diff --git a/engines/wintermute/scriptables/SXStore.h b/engines/wintermute/scriptables/SXStore.h index 8c921958f8..4bcb4506d4 100644 --- a/engines/wintermute/scriptables/SXStore.h +++ b/engines/wintermute/scriptables/SXStore.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmeSXStore_H__ -#define __WmeSXStore_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTORE_H +#define WINTERMUTE_SXSTORE_H #include "engines/wintermute/BPersistMgr.h" #include "engines/wintermute/utils.h" #include "engines/wintermute/BObject.h" diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index acc846dccc..183be7dec5 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/BGame.h" #include "engines/wintermute/scriptables/ScStack.h" diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h index a303f2d190..aa3b9ebb35 100644 --- a/engines/wintermute/scriptables/SXString.h +++ b/engines/wintermute/scriptables/SXString.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeSXString_H__ -#define __WmeSXString_H__ +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H #include "engines/wintermute/BScriptable.h" diff --git a/engines/wintermute/scriptables/SxObject.cpp b/engines/wintermute/scriptables/SxObject.cpp index 738db08c53..1af01c1045 100644 --- a/engines/wintermute/scriptables/SxObject.cpp +++ b/engines/wintermute/scriptables/SxObject.cpp @@ -1,27 +1,30 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "SxObject.h" #include "ScValue.h" diff --git a/engines/wintermute/scriptables/SxObject.h b/engines/wintermute/scriptables/SxObject.h index 6a355a7288..40e9046b5a 100644 --- a/engines/wintermute/scriptables/SxObject.h +++ b/engines/wintermute/scriptables/SxObject.h @@ -1,30 +1,33 @@ +/* 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. + * + */ + /* -This file is part of WME Lite. -http://dead-code.org/redir.php?target=wmelite - -Copyright (c) 2011 Jan Nedoma - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef __WmeSxObject_H__ -#define __WmeSxObject_H__ + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H #include "engines/wintermute/BObject.h" diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 476676cbaa..3aed2a0ede 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef __WmeWintypes_H__ -#define __WmeWintypes_H__ +#ifndef WINTERMUTE_WINTYPES_H +#define WINTERMUTE_WINTYPES_H #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/scummsys.h" @@ -117,4 +117,4 @@ typedef long HRESULT; //} // end of namespace WinterMute -#endif // __WmeWintypes_H__ +#endif // WINTERMUTE_WINTYPES_H -- cgit v1.2.3 From 0d9ec2a0a9be9d92cb6c96c401bdfbea24edecf5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 16:46:09 +0200 Subject: WINTERMUTE: Remove a few warnings. --- engines/wintermute/BSurfaceSDL.cpp | 37 ++++++++++++++++++----------- engines/wintermute/StringUtil.cpp | 10 ++++---- engines/wintermute/coll_templ.h | 2 +- engines/wintermute/scriptables/ScScript.cpp | 6 ++--- engines/wintermute/scriptables/ScValue.cpp | 20 ++++++++-------- engines/wintermute/utils.cpp | 22 ++++++++--------- 6 files changed, 53 insertions(+), 44 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 710c623a43..ef97e8d7c2 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -36,7 +36,7 @@ #include "graphics/decoders/bmp.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" -#include "stream.h" +#include "common/stream.h" #include "BFileManager.h" #include "PlatformSDL.h" @@ -66,7 +66,7 @@ CBSurfaceSDL::~CBSurfaceSDL() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - CBRenderSDL *renderer = static_cast(Game->_renderer); +/* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(Filename); Graphics::ImageDecoder *imgDecoder; @@ -120,10 +120,10 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, FreeImage_FlipVertical(img);*/ //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: - uint32 rmask = surface->format.rMax() << surface->format.rShift; +/* uint32 rmask = surface->format.rMax() << surface->format.rShift; uint32 gmask = surface->format.gMax() << surface->format.gShift; uint32 bmask = surface->format.bMax() << surface->format.bShift; - uint32 amask = surface->format.aMax(); + uint32 amask = surface->format.aMax();*/ // SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); @@ -258,6 +258,7 @@ uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { return 0; /* shouldn't happen, but avoids warnings */ } #endif + return 0; } ////////////////////////////////////////////////////////////////////////// @@ -296,8 +297,6 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { ////////////////////////////////////////////////////////////////////////// bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { - int access; - int width, height; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -305,6 +304,9 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { warning("CBSurfaceSDL::IsTransparentAt not ported yet"); hasWarned = true; } +#if 0 + int access; + int width, height; //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; @@ -315,15 +317,14 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { EndPixelOp(); return ret; +#endif + return 0; } ////////////////////////////////////////////////////////////////////////// bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { //if (!_lockPixels) return false; - uint32 format; - int access; - int width, height; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -331,13 +332,19 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); hasWarned = true; } +#if 0 + uint32 format; + int access; + int width, height; + //SDL_QueryTexture(_texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; if (X < 0 || X >= width || Y < 0 || Y >= height) return true; if (!_alphaMask) return false; else return _alphaMask[Y * width + X] <= 128; - +#endif + return false; /* Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); Uint32 pixel = dst[X]; @@ -403,10 +410,6 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; - byte r = D3DCOLGetR(Alpha); - byte g = D3DCOLGetG(Alpha); - byte b = D3DCOLGetB(Alpha); - byte a = D3DCOLGetA(Alpha); // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -414,7 +417,13 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } + return S_OK; #if 0 + byte r = D3DCOLGetR(Alpha); + byte g = D3DCOLGetG(Alpha); + byte b = D3DCOLGetB(Alpha); + byte a = D3DCOLGetA(Alpha); + SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index d98f60d582..35b3bd6fc7 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -269,7 +269,7 @@ AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, co if (from.empty() || from == to) return str; AnsiString result = str; - size_t pos = 0; + /*size_t pos = 0;*/ while (result.contains(from)) { const char *startPtr = strstr(result.c_str(), from.c_str()); @@ -323,11 +323,11 @@ int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, siz /*size_t pos = str.rfind(toFind, startFrom); if (pos == str.npos) return -1; else return pos;*/ - uint32 lastIndex = -1; + int32 lastIndex = -1; bool found = false; - for (int i = startFrom; i < str.size(); i++) { + for (size_t i = startFrom; i < str.size(); i++) { found = false; - for (int j = 0; j < toFind.size(); j++) { + for (size_t j = 0; j < toFind.size(); j++) { if (str[i + j] != toFind[j]) { found = false; break; @@ -346,7 +346,7 @@ AnsiString StringUtil::ToString(size_t val) { /* std::ostringstream str; str << val; return str.str();*/ - return Common::String::format("%u", val); + return Common::String::format("%u", (uint32)val); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 0e0c3fbe75..ec6ef4f202 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -224,7 +224,7 @@ void CBArray::SetSize(int nNewSize, int nGrowBy) { _nSize = nNewSize; } else { // otherwise, grow array - int nGrowBy = _nGrowBy; + nGrowBy = _nGrowBy; if (nGrowBy == 0) { // heuristically determine growth when nGrowBy == 0 // (this avoids heap fragmentation in many situations) diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp index 611ce4124f..b3eca0f346 100644 --- a/engines/wintermute/scriptables/ScScript.cpp +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -150,7 +150,7 @@ HRESULT CScScript::InitTables() { TScriptHeader *Header = (TScriptHeader *)_buffer; - uint32 i; + int32 i; // load symbol table _iP = Header->symbol_table; @@ -471,7 +471,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { dw = GetDWORD(); - char *Temp = _symbols[dw]; // TODO delete +/* char *Temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist if (!_engine->_globals->PropExists(_symbols[dw])) { _operand->SetNULL(); @@ -1544,7 +1544,7 @@ HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { // send scope variables if (_scopeStack->_sP >= 0) { for (int i = 0; i <= _scopeStack->_sP; i++) { - CScValue *Scope = _scopeStack->GetAt(i); + // CScValue *Scope = _scopeStack->GetAt(i); //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 72baddbbc8..7720aa314c 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -724,13 +724,13 @@ HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_valNative)); int size; - char *str; + const char *str; if (PersistMgr->_saving) { size = _valObject.size(); PersistMgr->Transfer("", &size); _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - str = (char *)_valIter->_key.c_str(); + str = _valIter->_key.c_str(); PersistMgr->Transfer("", &str); PersistMgr->Transfer("", &_valIter->_value); @@ -800,7 +800,7 @@ HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { Buffer->PutTextIndent(Indent, "PROPERTY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_valIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); Buffer->PutTextIndent(Indent, "}\n\n"); @@ -868,15 +868,15 @@ HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariable ////////////////////////////////////////////////////////////////////////// bool CScValue::SetProperty(const char *PropName, int Value) { CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// bool CScValue::SetProperty(const char *PropName, const char *Value) { - CScValue *Val = new CScValue(Game, (char *)Value); - bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); delete Val; return Ret; } @@ -884,7 +884,7 @@ bool CScValue::SetProperty(const char *PropName, const char *Value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::SetProperty(const char *PropName, double Value) { CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); delete Val; return Ret; } @@ -893,7 +893,7 @@ bool CScValue::SetProperty(const char *PropName, double Value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::SetProperty(const char *PropName, bool Value) { CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); delete Val; return Ret; } @@ -902,7 +902,7 @@ bool CScValue::SetProperty(const char *PropName, bool Value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::SetProperty(const char *PropName) { CScValue *Val = new CScValue(Game); - bool Ret = SUCCEEDED(SetProp((char *)PropName, Val)); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); delete Val; return Ret; } @@ -977,7 +977,7 @@ bool CScValue::DbgSetVal(bool Value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::DbgSetVal(const char *Value) { - SetString((char *)Value); + SetString(Value); return true; } diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index 13885dd2e6..7f17af9395 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -129,7 +129,7 @@ char *CBUtils::SetString(char **String, const char *Value) { ////////////////////////////////////////////////////////////////////////// int CBUtils::StrNumEntries(const char *Str, const char Delim) { int NumEntries = 1; - for (int i = 0; i < strlen(Str); i++) { + for (uint32 i = 0; i < strlen(Str); i++) { if (Str[i] == Delim) NumEntries++; } return NumEntries; @@ -143,7 +143,7 @@ char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { const char *Start = NULL; int Len = 0; - for (int i = 0; i <= strlen(Str); i++) { + for (uint32 i = 0; i <= strlen(Str); i++) { if (NumEntries == Entry) { if (!Start) Start = Str + i; else Len++; @@ -294,9 +294,9 @@ void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { if (H > 1) H -= 1; } - *OutH = H * 255; - *OutS = S * 255; - *OutL = L * 255; + *OutH = (byte)(H * 255); + *OutS = (byte)(S * 255); + *OutL = (byte)(L * 255); } @@ -310,9 +310,9 @@ uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { if (S == 0) { - R = L * 255; - G = L * 255; - B = L * 255; + R = (byte)(L * 255); + G = (byte)(L * 255); + B = (byte)(L * 255); } else { float var_1, var_2; @@ -321,9 +321,9 @@ uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { var_1 = 2.0f * L - var_2; - R = 255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f)); - G = 255 * Hue2RGB(var_1, var_2, H); - B = 255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f)); + R = (byte)(255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f))); + G = (byte)(255 * Hue2RGB(var_1, var_2, H)); + B = (byte)(255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f))); } return DRGBA(255, R, G, B); } -- cgit v1.2.3 From 987fd67ce0591e35b554b8dc1079e4889e9b0955 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 17:30:43 +0200 Subject: WINTERMUTE: Handle a few more forbidden symbols. --- engines/wintermute/AdActor.cpp | 6 ++--- engines/wintermute/AdInventoryBox.cpp | 4 +-- engines/wintermute/AdResponseBox.cpp | 2 +- engines/wintermute/AdScene.cpp | 34 +++++++++++++------------- engines/wintermute/AdSentence.cpp | 6 ++--- engines/wintermute/AdTalkHolder.cpp | 1 + engines/wintermute/AdWaypointGroup.cpp | 2 ++ engines/wintermute/BFileManager.cpp | 24 +++++++++--------- engines/wintermute/BFileManager.h | 2 +- engines/wintermute/BFontBitmap.cpp | 2 +- engines/wintermute/BFontTT.cpp | 5 ++-- engines/wintermute/BGame.cpp | 18 +++++++------- engines/wintermute/BPersistMgr.cpp | 6 ++--- engines/wintermute/BRegion.cpp | 15 ++++++------ engines/wintermute/BSprite.cpp | 4 +-- engines/wintermute/PartEmitter.cpp | 2 +- engines/wintermute/UIEdit.cpp | 18 +++++++------- engines/wintermute/scriptables/SXArray.cpp | 2 +- engines/wintermute/scriptables/SXMemBuffer.cpp | 4 +++ 19 files changed, 83 insertions(+), 74 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index dff70dc3e9..14a36b1a90 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -805,8 +805,8 @@ void CAdActor::GetNextStep() { MaxStepX = abs(_currentSprite->_moveX); MaxStepY = abs(_currentSprite->_moveY); - MaxStepX = std::max(MaxStepX, MaxStepY); - MaxStepX = std::max(MaxStepX, 1); + MaxStepX = MAX(MaxStepX, MaxStepY); + MaxStepX = MAX(MaxStepX, 1); while (_pFCount > 0 && MaxStepX >= 0) { _pFX += _pFStepX; @@ -851,7 +851,7 @@ void CAdActor::GetNextStep() { ////////////////////////////////////////////////////////////////////////// void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { - _pFCount = std::max((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); + _pFCount = MAX((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); _pFStepX = (double)(EndPt.x - StartPt.x) / _pFCount; _pFStepY = (double)(EndPt.y - StartPt.y) / _pFCount; diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index 6429179f50..c89fd5215f 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -39,7 +39,7 @@ #include "UIWindow.h" #include "PlatformSDL.h" #include "common/str.h" -#include +//#include namespace WinterMute { @@ -83,7 +83,7 @@ HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { _visible = false; } else if (scumm_stricmp(obj->_name, "prev") == 0) { _scrollOffset -= _scrollBy; - _scrollOffset = std::max(_scrollOffset, 0); + _scrollOffset = MAX(_scrollOffset, 0); } else if (scumm_stricmp(obj->_name, "next") == 0) { _scrollOffset += _scrollBy; } else return CBObject::Listen(param1, param2); diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index a027847d24..cd8f950393 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -163,7 +163,7 @@ HRESULT CAdResponseBox::CreateButtons() { // make the responses touchable if (Game->_touchInterface) - btn->_height = std::max(btn->_height, 50); + btn->_height = MAX(btn->_height, 50); //btn->SetListener(this, btn, _responses[i]->_iD); btn->SetListener(this, btn, i); diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index 4fb1096c1e..c3331c223b 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -435,7 +435,7 @@ int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { X += xStep; } } - return std::max(xLength, yLength); + return MAX(xLength, yLength); } @@ -895,10 +895,10 @@ HRESULT CAdScene::TraverseNodes(bool Update) { _lastTimeH = Game->_timer; if (_offsetLeft < _targetOffsetLeft) { _offsetLeft += _scrollPixelsH; - _offsetLeft = std::min(_offsetLeft, _targetOffsetLeft); + _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); } else if (_offsetLeft > _targetOffsetLeft) { _offsetLeft -= _scrollPixelsH; - _offsetLeft = std::max(_offsetLeft, _targetOffsetLeft); + _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); } } @@ -907,10 +907,10 @@ HRESULT CAdScene::TraverseNodes(bool Update) { _lastTimeV = Game->_timer; if (_offsetTop < _targetOffsetTop) { _offsetTop += _scrollPixelsV; - _offsetTop = std::min(_offsetTop, _targetOffsetTop); + _offsetTop = MIN(_offsetTop, _targetOffsetTop); } else if (_offsetTop > _targetOffsetTop) { _offsetTop -= _scrollPixelsV; - _offsetTop = std::max(_offsetTop, _targetOffsetTop); + _offsetTop = MAX(_offsetTop, _targetOffsetTop); } } @@ -1198,11 +1198,11 @@ void CAdScene::ScrollTo(int OffsetX, int OffsetY) { int OrigOffsetLeft = _targetOffsetLeft; int OrigOffsetTop = _targetOffsetTop; - _targetOffsetLeft = std::max(0, OffsetX - ViewportWidth / 2); - _targetOffsetLeft = std::min(_targetOffsetLeft, _width - ViewportWidth); + _targetOffsetLeft = MAX(0, OffsetX - ViewportWidth / 2); + _targetOffsetLeft = MIN(_targetOffsetLeft, _width - ViewportWidth); - _targetOffsetTop = std::max(0, OffsetY - ViewportHeight / 2); - _targetOffsetTop = std::min(_targetOffsetTop, _height - ViewportHeight); + _targetOffsetTop = MAX(0, OffsetY - ViewportHeight / 2); + _targetOffsetTop = MIN(_targetOffsetTop, _height - ViewportHeight); if (Game->_mainObject && Game->_mainObject->_is3D) { @@ -1232,11 +1232,11 @@ void CAdScene::SkipTo(int OffsetX, int OffsetY) { int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - _offsetLeft = std::max(0, OffsetX - ViewportWidth / 2); - _offsetLeft = std::min(_offsetLeft, _width - ViewportWidth); + _offsetLeft = MAX(0, OffsetX - ViewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); - _offsetTop = std::max(0, OffsetY - ViewportHeight / 2); - _offsetTop = std::min(_offsetTop, _height - ViewportHeight); + _offsetTop = MAX(0, OffsetY - ViewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - ViewportHeight); _targetOffsetLeft = _offsetLeft; _targetOffsetTop = _offsetTop; @@ -1914,8 +1914,8 @@ HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - _offsetLeft = std::max(0, _offsetLeft - ViewportWidth / 2); - _offsetLeft = std::min(_offsetLeft, _width - ViewportWidth); + _offsetLeft = MAX(0, _offsetLeft - ViewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); _targetOffsetLeft = _offsetLeft; return S_OK; @@ -1930,8 +1930,8 @@ HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { int ViewportWidth, ViewportHeight; GetViewportSize(&ViewportWidth, &ViewportHeight); - _offsetTop = std::max(0, _offsetTop - ViewportHeight / 2); - _offsetTop = std::min(_offsetTop, _height - ViewportHeight); + _offsetTop = MAX(0, _offsetTop - ViewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - ViewportHeight); _targetOffsetTop = _offsetTop; return S_OK; diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp index cd5fc5d754..9665f36d1e 100644 --- a/engines/wintermute/AdSentence.cpp +++ b/engines/wintermute/AdSentence.cpp @@ -183,9 +183,9 @@ HRESULT CAdSentence::Display() { } - x = std::max(x, 0); - x = std::min(x, Game->_renderer->_width - _width); - y = std::max(y, 0); + x = MAX(x, 0); + x = MIN(x, Game->_renderer->_width - _width); + y = MAX(y, 0); _font->DrawText((byte *)_text, x, y, _width, _align); } diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 05d2c46059..5fc5a40388 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -26,6 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_rand #include "dcgf.h" #include "AdTalkHolder.h" #include "BDynBuffer.h" diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp index c68a7e3101..d85304b6f5 100644 --- a/engines/wintermute/AdWaypointGroup.cpp +++ b/engines/wintermute/AdWaypointGroup.cpp @@ -33,6 +33,8 @@ #include "BGame.h" #include "BRegion.h" #include "BFileManager.h" +#include + namespace WinterMute { IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index e3e5986b88..f3290afdca 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -27,7 +27,7 @@ */ - +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "dcgf.h" #include "BFileManager.h" #include "StringUtil.h" @@ -50,18 +50,18 @@ #include "common/system.h" #include "common/fs.h" #include "common/file.h" - +/* #ifdef __WIN32__ # include #else # include #endif - +*/ /*#ifdef __APPLE__ # include #endif*/ - +/* #if _DEBUG #pragma comment(lib, "zlib_d.lib") #else @@ -73,7 +73,7 @@ extern "C" { #include "zlib.h" } - +*/ namespace WinterMute { ////////////////////////////////////////////////////////////////////// @@ -731,23 +731,23 @@ Common::File *CBFileManager::OpenSingleFile(const char *Name) { bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { RestoreCurrentDir(); - FILE *f = NULL; + Common::File f; bool found = false; for (int i = 0; i < _singlePaths.GetSize(); i++) { sprintf(Fullname, "%s%s", _singlePaths[i], Filename); - f = fopen(Fullname, "rb"); - if (f) { - fclose(f); + f.open(Fullname); + if (f.isOpen()) { + f.close(); found = true; break; } } if (!found) { - f = fopen(Filename, "rb"); - if (f) { - fclose(f); + f.open(Filename); + if (f.isOpen()) { + f.close(); found = true; strcpy(Fullname, Filename); } diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index 7b487674f5..c7363de04e 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BFILEMANAGER_H -#include +//#include #include "coll_templ.h" #include "BFileEntry.h" #include "common/archive.h" diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index caa0fb8bf1..46e66ae84c 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -508,7 +508,7 @@ HRESULT CBFontBitmap::GetWidths() { if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; - min_col = std::max(col, min_col); + min_col = MAX(col, min_col); break; } } diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index 2fdaf7b128..a9495834b3 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -44,6 +44,7 @@ #include "PlatformSDL.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" +#include namespace WinterMute { @@ -281,7 +282,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex GlyphInfo *glyph = _glyphCache->GetGlyph(ch); if (!glyph) continue; - textOffset = std::max(textOffset, glyph->GetBearingY()); + textOffset = MAX(textOffset, glyph->GetBearingY()); } @@ -811,7 +812,7 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, TextLineList::iterator it; for (it = lines.begin(); it != lines.end(); ++it) { TextLine *line = (*it); - textWidth = std::max(textWidth, line->GetWidth()); + textWidth = MAX(textWidth, line->GetWidth()); SAFE_DELETE(line); } } diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index e210b3299c..e3ec86aafc 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -1336,10 +1336,10 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(2); int x = Stack->Pop()->GetInt(); int y = Stack->Pop()->GetInt(); - x = std::max(x, 0); - x = std::min(x, _renderer->_width); - y = std::max(y, 0); - y = std::min(y, _renderer->_height); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); POINT p; p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; @@ -2623,7 +2623,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundBufferSize") == 0) { _soundBufferSizeSec = Value->GetInt(); - _soundBufferSizeSec = std::max(3, _soundBufferSizeSec); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); return S_OK; } @@ -4373,11 +4373,11 @@ void CBGame::GetMousePos(POINT *Pos) { if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { if (!CBPlatform::PtInRect(&_mouseLockRect, *Pos)) { - Pos->x = std::max(_mouseLockRect.left, Pos->x); - Pos->y = std::max(_mouseLockRect.top, Pos->y); + Pos->x = MAX(_mouseLockRect.left, Pos->x); + Pos->y = MAX(_mouseLockRect.top, Pos->y); - Pos->x = std::min(_mouseLockRect.right, Pos->x); - Pos->y = std::min(_mouseLockRect.bottom, Pos->y); + Pos->x = MIN(_mouseLockRect.right, Pos->x); + Pos->y = MIN(_mouseLockRect.bottom, Pos->y); POINT NewPos = *Pos; diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp index bc825ac385..4004375daf 100644 --- a/engines/wintermute/BPersistMgr.cpp +++ b/engines/wintermute/BPersistMgr.cpp @@ -177,10 +177,10 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { PutDWORD(DataOffset); PutString(Desc); - - time_t Timestamp; +// TODO: Add usefull timestamps, we can't use ctime... +/* time_t Timestamp; time(&Timestamp); - PutDWORD((uint32)Timestamp); + PutDWORD((uint32)Timestamp);*/ } return res; } diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index f7c4812d3e..4f71975c39 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/scriptables/ScValue.h" #include "engines/wintermute/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" +#include namespace WinterMute { @@ -443,9 +444,9 @@ bool CBRegion::PtInPolygon(int X, int Y) { p2.x = (double)_points[i % _points.GetSize()]->x; p2.y = (double)_points[i % _points.GetSize()]->y; - if (p.y > std::min(p1.y, p2.y)) { - if (p.y <= std::max(p1.y, p2.y)) { - if (p.x <= std::max(p1.x, p2.x)) { + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { if (p1.y != p2.y) { xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; if (p1.x == p2.x || p.x <= xinters) @@ -471,11 +472,11 @@ HRESULT CBRegion::GetBoundingRect(RECT *Rect) { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; for (int i = 0; i < _points.GetSize(); i++) { - MinX = std::min(MinX, _points[i]->x); - MinY = std::min(MinY, _points[i]->y); + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); - MaxX = std::max(MaxX, _points[i]->x); - MaxY = std::max(MaxY, _points[i]->y); + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); } CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); } diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index f24ee23a78..05ccc9c397 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -278,8 +278,8 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite case TOKEN_EDITOR_BG_ALPHA: parser.ScanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = std::min(_editorBgAlpha, 255); - _editorBgAlpha = std::max(_editorBgAlpha, 0); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); break; case TOKEN_FRAME: { diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index 79bfa8a5b2..a184a46e40 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -251,7 +251,7 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { return S_OK; } - int ToGen = std::min(_genAmount, _maxParticles - NumLive); + int ToGen = MIN(_genAmount, _maxParticles - NumLive); while (ToGen > 0) { int FirstDeadIndex = -1; for (int i = 0; i < _particles.GetSize(); i++) { diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 642504e82e..5b222ac831 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -579,26 +579,26 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { bool CurFirst; // modify scroll offset if (_selStart >= _selEnd) { - while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= strlen(_text)) break; } - _scrollOffset = std::min(_scrollOffset, _selEnd); + _scrollOffset = MIN(_scrollOffset, _selEnd); s1 = _selEnd; s2 = _selStart; CurFirst = true; } else { - while (font->GetTextWidth((byte *)_text + _scrollOffset, std::max(0, _selStart - _scrollOffset)) + - sfont->GetTextWidth((byte *)(_text + std::max(_scrollOffset, _selStart)), _selEnd - std::max(_scrollOffset, _selStart)) + while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + + sfont->GetTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= strlen(_text)) break; } - _scrollOffset = std::min(_scrollOffset, _selEnd); + _scrollOffset = MIN(_scrollOffset, _selEnd); s1 = _selStart; s2 = _selEnd; @@ -616,7 +616,7 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { yyy = _posY + _frameWidth + OffsetY; width = _posX + _width + OffsetX - _frameWidth; - height = std::max(font->GetLetterHeight(), sfont->GetLetterHeight()); + height = MAX(font->GetLetterHeight(), sfont->GetLetterHeight()); if (Game->_textRTL) xxx += AlignOffset; @@ -645,7 +645,7 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { } // selected - int s3 = std::max(s1, _scrollOffset); + int s3 = MAX(s1, _scrollOffset); if (s2 - s3 > 0) { if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); @@ -710,7 +710,7 @@ bool CUIEdit::HandleKeypress(Common::Event *event) { if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); else DeleteChars(_selStart - 1, _selStart); } else DeleteChars(_selStart, _selEnd); - if (_selEnd >= _selStart) _selEnd -= std::max(1, _selEnd - _selStart); + if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); _selStart = _selEnd; Handled = true; @@ -798,7 +798,7 @@ int CUIEdit::DeleteChars(int Start, int End) { char *str = new char[strlen(_text) - (End - Start) + 1]; if (str) { if (Start > 0) memcpy(str, _text, Start); - memcpy(str + std::max(0, Start), _text + End, strlen(_text) - End + 1); + memcpy(str + MAX(0, Start), _text + End, strlen(_text) - End + 1); delete[] _text; _text = str; diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 7ac7dd5460..0dd620c487 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -209,7 +209,7 @@ HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { bool IsNumber = true; for (int i = 0; i < strlen(OrigStr); i++) { - if (!isdigit(OrigStr[i])) { + if (!(OrigStr[i] >= '0' && OrigStr[i] <= '9')) { IsNumber = false; break; } diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 9aea2b0c4c..730108e4a4 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -26,6 +26,10 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_fopen +#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite +#define FORBIDDEN_SYMBOL_EXCEPTION_fclose #include "engines/wintermute/BScriptable.h" #include "engines/wintermute/scriptables/ScStack.h" #include "engines/wintermute/scriptables/ScScript.h" -- cgit v1.2.3 From 7616fabf67f870478d0a6a75f1921f761a82ebfb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 17:40:04 +0200 Subject: WINTERMUTE: Make Sprites draw again. --- engines/wintermute/BSurfaceSDL.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index ef97e8d7c2..349d563503 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -417,7 +417,6 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } - return S_OK; #if 0 byte r = D3DCOLGetR(Alpha); byte g = D3DCOLGetG(Alpha); -- cgit v1.2.3 From c9058b544843553f1f5455c2595b6663e88f246f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 18:01:07 +0200 Subject: WINTERMUTE: Remove a few of the __WIN32__ macros. --- engines/wintermute/BFileManager.cpp | 23 ------------------- engines/wintermute/BGame.cpp | 13 +---------- engines/wintermute/PlatformSDL.cpp | 34 +++-------------------------- engines/wintermute/scriptables/ScEngine.cpp | 7 +++--- engines/wintermute/wintypes.h | 4 ++-- 5 files changed, 10 insertions(+), 71 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index f3290afdca..71b03a5bb9 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -50,30 +50,7 @@ #include "common/system.h" #include "common/fs.h" #include "common/file.h" -/* -#ifdef __WIN32__ -# include -#else -# include -#endif -*/ -/*#ifdef __APPLE__ -# include -#endif*/ - -/* -#if _DEBUG -#pragma comment(lib, "zlib_d.lib") -#else -#pragma comment(lib, "zlib.lib") -#endif - -extern "C" -{ -#include "zlib.h" -} -*/ namespace WinterMute { ////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index e3ec86aafc..fd3d8908cc 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -1796,15 +1796,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // OpenDocument ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "OpenDocument") == 0) { -#ifdef __WIN32__ - Stack->CorrectParams(1); - if (!_renderer->_windowed) CBPlatform::ShowWindow(_renderer->_window, SW_MINIMIZE); - HINSTANCE i = CBPlatform::ShellExecute(_renderer->_window, "open", Stack->Pop()->GetString(), NULL, NULL, SW_MAXIMIZE); - Stack->PushBool((int)i > 32); -#else Stack->CorrectParams(0); Stack->PushNULL(); -#endif return S_OK; } @@ -4421,11 +4414,7 @@ bool CBGame::IsDoubleClick(int buttonIndex) { int maxMoveX = 4; int maxMoveY = 4; -#if __WIN32__ - maxDoubleCLickTime = GetDoubleClickTime(); - maxMoveX = GetSystemMetrics(SM_CXDOUBLECLK); - maxMoveY = GetSystemMetrics(SM_CYDOUBLECLK); -#elif __IPHONEOS__ +#if __IPHONEOS__ maxMoveX = 16; maxMoveY = 16; #endif diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index fab72e29da..0fc8c1628a 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -103,9 +103,7 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { delete Game; Game = NULL; -#ifdef __WIN32__ - ::MessageBox(NULL, "Some of the essential files are missing. Please reinstall.", NULL, MB_OK | MB_ICONERROR); -#endif + warning("Some of the essential files are missing. Please reinstall."); return 2; } @@ -325,18 +323,16 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { // Win32 API bindings ////////////////////////////////////////////////////////////////////////// HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd) { -#ifdef __WIN32__ - return ::ShellExecute(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd); -#else return NULL; -#endif } ////////////////////////////////////////////////////////////////////////// void CBPlatform::OutputDebugString(LPCSTR lpOutputString) { +/* #ifdef __WIN32__ ::OutputDebugString(lpOutputString); #endif +*/ } @@ -373,11 +369,7 @@ BOOL CBPlatform::SetCursorPos(int X, int Y) { ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::ShowWindow(HWND hWnd, int nCmdShow) { -#ifdef __WIN32__ - return ::ShowWindow(hWnd, nCmdShow); -#else return FALSE; -#endif } ////////////////////////////////////////////////////////////////////////// @@ -400,29 +392,17 @@ bool CBPlatform::CopyFile(const char *from, const char *to, bool failIfExists) { ////////////////////////////////////////////////////////////////////////// HWND CBPlatform::SetCapture(HWND hWnd) { -#ifdef __WIN32__ - return ::SetCapture(hWnd); -#else return NULL; -#endif } ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::ReleaseCapture() { -#ifdef __WIN32__ - return ::ReleaseCapture(); -#else return FALSE; -#endif } ////////////////////////////////////////////////////////////////////////// BOOL CBPlatform::SetForegroundWindow(HWND hWnd) { -#ifdef __WIN32__ - return ::SetForegroundWindow(hWnd); -#else return FALSE; -#endif } ////////////////////////////////////////////////////////////////////////// @@ -539,20 +519,12 @@ AnsiString CBPlatform::GetPlatformName() { ////////////////////////////////////////////////////////////////////////// int scumm_stricmp(const char *str1, const char *str2) { -#ifdef __WIN32__ - return ::stricmp(str1, str2); -#else return ::strcasecmp(str1, str2); -#endif } ////////////////////////////////////////////////////////////////////////// int scumm_strnicmp(const char *str1, const char *str2, size_t maxCount) { -#ifdef __WIN32__ - return ::strnicmp(str1, str2, maxCount); -#else return ::strncasecmp(str1, str2, maxCount); -#endif } diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 9c690b1c1f..4edb1c771b 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -49,7 +49,7 @@ IMPLEMENT_PERSISTENT(CScEngine, true) CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { Game->LOG(0, "Initializing scripting engine..."); - +/* #ifdef __WIN32__ char CompilerPath[MAX_PATH]; strcpy(CompilerPath, COMPILER_DLL); @@ -88,14 +88,15 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { c.Dll_LoadFile = LoadFile; ExtSetCallbacks(&c, Game); */ - +/* _compilerAvailable = true; } } else _compilerAvailable = false; #else +*/ _compilerAvailable = false; _compilerDLL = NULL; -#endif +//#endif if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 3aed2a0ede..4f826e9337 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -56,7 +56,7 @@ typedef int BOOL; #define D3DCOLGetG(rgb) ((byte )(((WORD)(rgb)) >> 8)) #define D3DCOLGetR(rgb) ((byte )((rgb)>>16)) #define D3DCOLGetA(rgb) ((byte )((rgb)>>24)) - +/* #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif @@ -64,7 +64,7 @@ typedef int BOOL; #ifndef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif - +*/ #define CONST const #define MAX_PATH 512 -- cgit v1.2.3 From 25f08ba402dfa3b29e996a262b4c6217915de57e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 11 May 2012 18:17:49 +0200 Subject: WINTERMUTE: Remove a few defines from wintypes.h --- engines/wintermute/BRenderSDL.cpp | 2 +- engines/wintermute/BRenderSDL.h | 2 +- engines/wintermute/BRenderer.cpp | 2 +- engines/wintermute/BRenderer.h | 2 +- engines/wintermute/BTransitionMgr.cpp | 4 +-- engines/wintermute/PlatformSDL.cpp | 60 +++++++++++++++---------------- engines/wintermute/PlatformSDL.h | 32 ++++++++--------- engines/wintermute/coll_templ.h | 2 +- engines/wintermute/scriptables/SXFile.cpp | 4 +-- engines/wintermute/wintypes.h | 51 ++++++-------------------- 10 files changed, 65 insertions(+), 96 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index b74967b815..0574b3e7b9 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -226,7 +226,7 @@ HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fade(WORD Alpha) { +HRESULT CBRenderSDL::Fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; return FadeToColor(dwAlpha << 24); } diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h index 11b1b74054..0c5760470e 100644 --- a/engines/wintermute/BRenderSDL.h +++ b/engines/wintermute/BRenderSDL.h @@ -49,7 +49,7 @@ public: HRESULT Flip(); HRESULT Fill(byte r, byte g, byte b, RECT *rect); - HRESULT Fade(WORD Alpha); + HRESULT Fade(uint16 Alpha); HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); HRESULT SwitchFullscreen(); diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp index 88ad581e6f..714981ea49 100644 --- a/engines/wintermute/BRenderer.cpp +++ b/engines/wintermute/BRenderer.cpp @@ -180,7 +180,7 @@ HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int W ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fade(WORD Alpha) { +HRESULT CBRenderer::Fade(uint16 Alpha) { return E_FAIL; } diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h index 7a586775dd..bd2d23071b 100644 --- a/engines/wintermute/BRenderer.h +++ b/engines/wintermute/BRenderer.h @@ -51,7 +51,7 @@ public: virtual HRESULT SetViewport(int left, int top, int right, int bottom); virtual HRESULT SetViewport(RECT *Rect); virtual HRESULT SetScreenViewport(); - virtual HRESULT Fade(WORD Alpha); + virtual HRESULT Fade(uint16 Alpha); virtual HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp index 87cbb86a3d..c5c421250a 100644 --- a/engines/wintermute/BTransitionMgr.cpp +++ b/engines/wintermute/BTransitionMgr.cpp @@ -99,7 +99,7 @@ HRESULT CBTransitionMgr::Update() { uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((WORD)Alpha); + Game->_renderer->Fade((uint16)Alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; } @@ -109,7 +109,7 @@ HRESULT CBTransitionMgr::Update() { uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = (float)time / (float)FADE_DURATION * 255; Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((WORD)Alpha); + Game->_renderer->Fade((uint16)Alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 0fc8c1628a..3335bd3155 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -322,7 +322,7 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // Win32 API bindings ////////////////////////////////////////////////////////////////////////// -HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd) { +HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd) { return NULL; } @@ -342,7 +342,7 @@ uint32 CBPlatform::GetTime() { } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { +bool CBPlatform::GetCursorPos(LPPOINT lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); @@ -351,11 +351,11 @@ BOOL CBPlatform::GetCursorPos(LPPOINT lpPoint) { renderer->PointFromScreen(lpPoint); - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::SetCursorPos(int X, int Y) { +bool CBPlatform::SetCursorPos(int X, int Y) { CBRenderSDL *renderer = static_cast(Game->_renderer); POINT p; @@ -364,12 +364,12 @@ BOOL CBPlatform::SetCursorPos(int X, int Y) { renderer->PointToScreen(&p); // TODO //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::ShowWindow(HWND hWnd, int nCmdShow) { - return FALSE; +bool CBPlatform::ShowWindow(HWND hWnd, int nCmdShow) { + return false; } ////////////////////////////////////////////////////////////////////////// @@ -396,63 +396,63 @@ HWND CBPlatform::SetCapture(HWND hWnd) { } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::ReleaseCapture() { - return FALSE; +bool CBPlatform::ReleaseCapture() { + return false; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::SetForegroundWindow(HWND hWnd) { - return FALSE; +bool CBPlatform::SetForegroundWindow(HWND hWnd) { + return false; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::SetRectEmpty(LPRECT lprc) { +bool CBPlatform::SetRectEmpty(LPRECT lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::IsRectEmpty(const LPRECT lprc) { +bool CBPlatform::IsRectEmpty(const LPRECT lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::PtInRect(LPRECT lprc, POINT p) { +bool CBPlatform::PtInRect(LPRECT lprc, POINT p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::SetRect(LPRECT lprc, int left, int top, int right, int bottom) { +bool CBPlatform::SetRect(LPRECT lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; lprc->bottom = bottom; - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::IntersectRect(LPRECT lprcDst, CONST LPRECT lprcSrc1, CONST LPRECT lprcSrc2) { +bool CBPlatform::IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2) { if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { SetRectEmpty(lprcDst); - return FALSE; + return false; } lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); lprcDst->right = MIN(lprcSrc1->right, lprcSrc2->right); lprcDst->top = MAX(lprcSrc1->top, lprcSrc2->top); lprcDst->bottom = MIN(lprcSrc1->bottom, lprcSrc2->bottom); - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { +bool CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { if (IsRectEmpty(lprcSrc1)) { if (IsRectEmpty(lprcSrc2)) { SetRectEmpty(lprcDst); - return FALSE; + return false; } else { *lprcDst = *lprcSrc2; } @@ -467,31 +467,31 @@ BOOL CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { } } - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::CopyRect(LPRECT lprcDst, RECT *lprcSrc) { - if (lprcDst == NULL || lprcSrc == NULL) return FALSE; +bool CBPlatform::CopyRect(LPRECT lprcDst, RECT *lprcSrc) { + if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::OffsetRect(LPRECT lprc, int dx, int dy) { - if (lprc == NULL) return FALSE; +bool CBPlatform::OffsetRect(LPRECT lprc, int dx, int dy) { + if (lprc == NULL) return false; lprc->left += dx; lprc->top += dy; lprc->right += dx; lprc->bottom += dy; - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////// -BOOL CBPlatform::EqualRect(LPRECT rect1, LPRECT rect2) { +bool CBPlatform::EqualRect(LPRECT rect1, LPRECT rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 27de188030..faf4a7e934 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -49,27 +49,27 @@ public: static AnsiString GetPlatformName(); // Win32 API bindings - static HINSTANCE ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd); + static HINSTANCE ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd); static void OutputDebugString(LPCSTR lpOutputString); static uint32 GetTime(); - static BOOL GetCursorPos(LPPOINT lpPoint); - static BOOL SetCursorPos(int X, int Y); - static BOOL ShowWindow(HWND hWnd, int nCmdShow); + static bool GetCursorPos(LPPOINT lpPoint); + static bool SetCursorPos(int X, int Y); + static bool ShowWindow(HWND hWnd, int nCmdShow); static bool DeleteFile(const char *lpFileName); static bool CopyFile(const char *from, const char *to, bool failIfExists); static HWND SetCapture(HWND hWnd); - static BOOL ReleaseCapture(); - static BOOL SetForegroundWindow(HWND hWnd); - - static BOOL SetRectEmpty(LPRECT lprc); - static BOOL IsRectEmpty(const LPRECT lprc); - static BOOL PtInRect(LPRECT lprc, POINT p); - static BOOL SetRect(LPRECT lprc, int left, int top, int right, int bottom); - static BOOL IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); - static BOOL UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); - static BOOL CopyRect(LPRECT lprcDst, RECT *lprcSrc); - static BOOL OffsetRect(LPRECT lprc, int dx, int dy); - static BOOL EqualRect(LPRECT rect1, LPRECT rect2); + static bool ReleaseCapture(); + static bool SetForegroundWindow(HWND hWnd); + + static bool SetRectEmpty(LPRECT lprc); + static bool IsRectEmpty(const LPRECT lprc); + static bool PtInRect(LPRECT lprc, POINT p); + static bool SetRect(LPRECT lprc, int left, int top, int right, int bottom); + static bool IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); + static bool UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); + static bool CopyRect(LPRECT lprcDst, RECT *lprcSrc); + static bool OffsetRect(LPRECT lprc, int dx, int dy); + static bool EqualRect(LPRECT rect1, LPRECT rect2); // string functions diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index ec6ef4f202..9c3a5ab15d 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -64,7 +64,7 @@ inline void DCCopyElements(TYPE *pDest, const TYPE *pSrc, int nCount) { ///////////////////////////////////////////////////////////////////////////// template -BOOL DCCompareElements(const TYPE *pElement1, const ARG_TYPE *pElement2) { +bool DCCompareElements(const TYPE *pElement1, const ARG_TYPE *pElement2) { return *pElement1 == *pElement2; } diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index 7d6b0ebcc1..e25825bebe 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -175,7 +175,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "Delete") == 0) { Stack->CorrectParams(0); Close(); - Stack->PushBool(CBPlatform::DeleteFile(_filename) != FALSE); + Stack->PushBool(CBPlatform::DeleteFile(_filename) != false); return S_OK; } @@ -188,7 +188,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool Overwrite = Stack->Pop()->GetBool(true); Close(); - Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != FALSE); + Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); return S_OK; } diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 4f826e9337..e3dd615063 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -33,68 +33,38 @@ #include "common/scummsys.h" //namespace WinterMute { -//#include -//#include #ifndef __WIN32__ #define WINAPI #define CALLBACK -#ifndef __OBJC__ -typedef int BOOL; -#endif - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - #define PI ((float) 3.141592653589793f) #define DRGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) #define D3DCOLGetB(rgb) ((byte )(rgb)) -#define D3DCOLGetG(rgb) ((byte )(((WORD)(rgb)) >> 8)) +#define D3DCOLGetG(rgb) ((byte )(((uint16)(rgb)) >> 8)) #define D3DCOLGetR(rgb) ((byte )((rgb)>>16)) #define D3DCOLGetA(rgb) ((byte )((rgb)>>24)) -/* -#ifndef MAX -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif -*/ -#define CONST const #define MAX_PATH 512 -typedef char CHAR; -typedef short SHORT; -typedef int32_t LONG; - -typedef uint16 WORD; -//typedef uint32 QWORD; // HACK for now -typedef int INT; -typedef unsigned int UINT; - -typedef CHAR *NPSTR, *LPSTR, *PSTR; +typedef char *NPSTR, *LPSTR, *PSTR; typedef PSTR *PZPSTR; typedef const PSTR *PCZPSTR; -typedef const CHAR *LPCSTR, *PCSTR; +typedef const char *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; typedef struct tagRECT { - LONG left; - LONG top; - LONG right; - LONG bottom; + uint32 left; + uint32 top; + uint32 right; + uint32 bottom; } RECT, *LPRECT; typedef struct tagPOINT { - LONG x; - LONG y; + uint32 x; + uint32 y; } POINT, *LPPOINT; @@ -102,8 +72,7 @@ typedef uint32 HINSTANCE; typedef uint32 HMODULE; typedef uint32 HWND; -//typedef uint32 HRESULT; -typedef long HRESULT; +typedef int32 HRESULT; #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) #define FAILED(hr) (((HRESULT)(hr)) < 0) -- cgit v1.2.3 From 11aadc56902ae97d6aa2467a94a041623b3c599d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 06:49:10 +0200 Subject: WINTERMUTE: Solve some const-char related warnings. --- engines/wintermute/AdActor.cpp | 2 +- engines/wintermute/AdActor.h | 2 +- engines/wintermute/AdEntity.cpp | 2 +- engines/wintermute/AdEntity.h | 2 +- engines/wintermute/AdItem.cpp | 2 +- engines/wintermute/AdItem.h | 2 +- engines/wintermute/AdLayer.cpp | 2 +- engines/wintermute/AdLayer.h | 2 +- engines/wintermute/AdObject.cpp | 2 +- engines/wintermute/AdObject.h | 2 +- engines/wintermute/AdRegion.cpp | 2 +- engines/wintermute/AdRegion.h | 2 +- engines/wintermute/AdScene.cpp | 2 +- engines/wintermute/AdScene.h | 2 +- engines/wintermute/AdTalkHolder.cpp | 2 +- engines/wintermute/AdTalkHolder.h | 2 +- engines/wintermute/BFileManager.cpp | 4 ++-- engines/wintermute/BFontTT.cpp | 2 +- engines/wintermute/BFrame.cpp | 2 +- engines/wintermute/BFrame.h | 2 +- engines/wintermute/BGame.cpp | 2 +- engines/wintermute/BGame.h | 2 +- engines/wintermute/BKeyboardState.cpp | 2 +- engines/wintermute/BKeyboardState.h | 2 +- engines/wintermute/BObject.cpp | 2 +- engines/wintermute/BObject.h | 2 +- engines/wintermute/BRegion.cpp | 2 +- engines/wintermute/BRegion.h | 2 +- engines/wintermute/BRenderSDL.cpp | 17 +++++++++++------ engines/wintermute/BScriptHolder.cpp | 2 +- engines/wintermute/BScriptHolder.h | 2 +- engines/wintermute/BScriptable.cpp | 2 +- engines/wintermute/BScriptable.h | 2 +- engines/wintermute/BSprite.cpp | 2 +- engines/wintermute/BSprite.h | 2 +- engines/wintermute/BSubFrame.cpp | 2 +- engines/wintermute/BSubFrame.h | 2 +- engines/wintermute/PartEmitter.cpp | 2 +- engines/wintermute/PartEmitter.h | 2 +- engines/wintermute/UIButton.cpp | 2 +- engines/wintermute/UIButton.h | 2 +- engines/wintermute/UIEdit.cpp | 2 +- engines/wintermute/UIEdit.h | 2 +- engines/wintermute/UIEntity.cpp | 2 +- engines/wintermute/UIEntity.h | 2 +- engines/wintermute/UIObject.cpp | 2 +- engines/wintermute/UIObject.h | 2 +- engines/wintermute/UIText.cpp | 2 +- engines/wintermute/UIText.h | 2 +- engines/wintermute/UIWindow.cpp | 2 +- engines/wintermute/UIWindow.h | 2 +- engines/wintermute/scriptables/SXArray.cpp | 2 +- engines/wintermute/scriptables/SXArray.h | 2 +- engines/wintermute/scriptables/SXDate.cpp | 2 +- engines/wintermute/scriptables/SXDate.h | 2 +- engines/wintermute/scriptables/SXFile.cpp | 2 +- engines/wintermute/scriptables/SXFile.h | 2 +- engines/wintermute/scriptables/SXMemBuffer.cpp | 2 +- engines/wintermute/scriptables/SXMemBuffer.h | 2 +- engines/wintermute/scriptables/SXString.cpp | 2 +- engines/wintermute/scriptables/SXString.h | 2 +- engines/wintermute/scriptables/ScValue.cpp | 2 +- 62 files changed, 73 insertions(+), 68 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index 14a36b1a90..328ab31874 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -1115,7 +1115,7 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdActor::ScToString() { +const char *CAdActor::ScToString() { return "[actor object]"; } diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h index 6d91f5f67b..2f3a678f93 100644 --- a/engines/wintermute/AdActor.h +++ b/engines/wintermute/AdActor.h @@ -84,7 +84,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); private: HRESULT SetDefaultAnimNames(); diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index 0fb9d3b21b..0a78cfab98 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -809,7 +809,7 @@ HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdEntity::ScToString() { +const char *CAdEntity::ScToString() { return "[entity object]"; } diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h index c63da505ce..30b9bab3a7 100644 --- a/engines/wintermute/AdEntity.h +++ b/engines/wintermute/AdEntity.h @@ -58,7 +58,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index 448fed3dc7..b360f97e1d 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -718,7 +718,7 @@ HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdItem::ScToString() { +const char *CAdItem::ScToString() { return "[item]"; } diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h index 50db9cc0b8..143f27fc87 100644 --- a/engines/wintermute/AdItem.h +++ b/engines/wintermute/AdItem.h @@ -62,7 +62,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 9840cf3097..156de5b2e7 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -472,7 +472,7 @@ HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdLayer::ScToString() { +const char *CAdLayer::ScToString() { return "[layer]"; } diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h index 98081d217b..1c0e3fa946 100644 --- a/engines/wintermute/AdLayer.h +++ b/engines/wintermute/AdLayer.h @@ -50,7 +50,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 58bb742c8a..4351e0953c 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -777,7 +777,7 @@ HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdObject::ScToString() { +const char *CAdObject::ScToString() { return "[ad object]"; } diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h index 706c291eef..488cf6807f 100644 --- a/engines/wintermute/AdObject.h +++ b/engines/wintermute/AdObject.h @@ -102,7 +102,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); CBArray _attachmentsPre; CBArray _attachmentsPost; diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp index 61d1e29f4a..d928689cda 100644 --- a/engines/wintermute/AdRegion.cpp +++ b/engines/wintermute/AdRegion.cpp @@ -342,7 +342,7 @@ HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdRegion::ScToString() { +const char *CAdRegion::ScToString() { return "[ad region]"; } diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h index 8f386036d1..7c982ca4e1 100644 --- a/engines/wintermute/AdRegion.h +++ b/engines/wintermute/AdRegion.h @@ -50,7 +50,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index c3331c223b..e0fb05d867 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -1942,7 +1942,7 @@ HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdScene::ScToString() { +const char *CAdScene::ScToString() { return "[scene object]"; } diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h index 6023ec0547..4071068d15 100644 --- a/engines/wintermute/AdScene.h +++ b/engines/wintermute/AdScene.h @@ -159,7 +159,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); private: diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp index 5fc5a40388..48bab0b1c1 100644 --- a/engines/wintermute/AdTalkHolder.cpp +++ b/engines/wintermute/AdTalkHolder.cpp @@ -320,7 +320,7 @@ HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CAdTalkHolder::ScToString() { +const char *CAdTalkHolder::ScToString() { return "[talk-holder object]"; } diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h index 647a4b0b98..66fb7c8e10 100644 --- a/engines/wintermute/AdTalkHolder.h +++ b/engines/wintermute/AdTalkHolder.h @@ -48,7 +48,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 71b03a5bb9..21688a5ea9 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -410,13 +410,13 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename.c_str()); delete package; return S_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); + Game->LOG(0, " Warning: package file '%s' is outdated.", Filename.c_str()); } // new in v2 diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index a9495834b3..d27985a62e 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -623,7 +623,7 @@ HRESULT CBFontTT::InitFont() { } warning("I guess we got a file"); if (file) { - _font = Graphics::loadTTFFont(*file->getMemStream(), 12); + //_font = Graphics::loadTTFFont(*file->getMemStream(), 12); } else { _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); warning("BFontTT::InitFont - Couldn't load %s", _fontFile); diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index a4e3cb9032..8f52f90dc3 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -700,7 +700,7 @@ HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBFrame::ScToString() { +const char *CBFrame::ScToString() { return "[frame]"; } diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h index 9810e50ada..086a6106b3 100644 --- a/engines/wintermute/BFrame.h +++ b/engines/wintermute/BFrame.h @@ -64,7 +64,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index fd3d8908cc..fa2e19a3c7 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -2673,7 +2673,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBGame::ScToString() { +const char *CBGame::ScToString() { return "[game object]"; } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 1eb41403b4..de98897a3d 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -229,7 +229,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); // compatibility bits bool _compatKillMethodThreads; diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp index 1bece9fea6..eb1346e645 100644 --- a/engines/wintermute/BKeyboardState.cpp +++ b/engines/wintermute/BKeyboardState.cpp @@ -174,7 +174,7 @@ HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBKeyboardState::ScToString() { +const char *CBKeyboardState::ScToString() { return "[keyboard state]"; } diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h index 2ceaa6eb4d..738f390eea 100644 --- a/engines/wintermute/BKeyboardState.h +++ b/engines/wintermute/BKeyboardState.h @@ -60,7 +60,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); private: uint32 KeyCodeToVKey(Common::Event *event); diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp index 4d3a24cfa4..56c988faea 100644 --- a/engines/wintermute/BObject.cpp +++ b/engines/wintermute/BObject.cpp @@ -845,7 +845,7 @@ HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBObject::ScToString() { +const char *CBObject::ScToString() { return "[object]"; } diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h index 11fa3dba19..53f3aa794d 100644 --- a/engines/wintermute/BObject.h +++ b/engines/wintermute/BObject.h @@ -137,7 +137,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 4f71975c39..15d7b26d94 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -372,7 +372,7 @@ HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBRegion::ScToString() { +const char *CBRegion::ScToString() { return "[region]"; } diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index ef7b3f2719..9869cda5e1 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -60,7 +60,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 0574b3e7b9..fbb683dfb6 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -274,24 +274,29 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { // Replacement for SDL2's SDL_RenderCopy void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { for (int i = 0; i < srcRect->height(); i++) { - void *destPtr = _renderSurface->getBasePtr(dstRect->left, dstRect->top + i); - void *srcPtr = surf->getBasePtr(srcRect->left, srcRect->top + i); + byte *destPtr = (byte*)_renderSurface->getBasePtr(dstRect->left, dstRect->top + i); + byte *srcPtr = (byte*)surf->getBasePtr(srcRect->left, srcRect->top + i); for (int j = 0; j < srcRect->width(); j++) { // TODO: Replace this with something less ugly, and more portable. if (((byte *)srcPtr)[0] == 255) { memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel); } - ((byte *)srcPtr) += _renderSurface->format.bytesPerPixel; - ((byte *)destPtr) += _renderSurface->format.bytesPerPixel; + srcPtr += _renderSurface->format.bytesPerPixel; + destPtr += _renderSurface->format.bytesPerPixel; } } } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { - byte r = D3DCOLGetR(Color); + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderSDL::DrawLine - not fully ported yet"); + hasWarned = true; + } +/* byte r = D3DCOLGetR(Color); byte g = D3DCOLGetG(Color); byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color); + byte a = D3DCOLGetA(Color);*/ //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index 2cd070e925..da6c95c8a8 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -252,7 +252,7 @@ HRESULT CBScriptHolder::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBScriptHolder::ScToString() { +const char *CBScriptHolder::ScToString() { return "[script_holder]"; } diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h index d06778d7af..f094d6591a 100644 --- a/engines/wintermute/BScriptHolder.h +++ b/engines/wintermute/BScriptHolder.h @@ -62,7 +62,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); virtual void ScDebuggerDesc(char *Buf, int BufSize); // IWmeObject public: diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp index cfdb0e1771..78faa0e8ca 100644 --- a/engines/wintermute/BScriptable.cpp +++ b/engines/wintermute/BScriptable.cpp @@ -90,7 +90,7 @@ HRESULT CBScriptable::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBScriptable::ScToString() { +const char *CBScriptable::ScToString() { return "[native object]"; } diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h index be2b961b08..5682cfe8e0 100644 --- a/engines/wintermute/BScriptable.h +++ b/engines/wintermute/BScriptable.h @@ -53,7 +53,7 @@ public: virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); virtual void *ScToMemBuffer(); virtual int ScToInt(); virtual double ScToFloat(); diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index 05ccc9c397..06bf9a4d6a 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -737,7 +737,7 @@ HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBSprite::ScToString() { +const char *CBSprite::ScToString() { return "[sprite]"; } diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h index b2b99bc2db..085dafe8d8 100644 --- a/engines/wintermute/BSprite.h +++ b/engines/wintermute/BSprite.h @@ -82,7 +82,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp index 0c57b9b79f..2e54e1a1ec 100644 --- a/engines/wintermute/BSubFrame.cpp +++ b/engines/wintermute/BSubFrame.cpp @@ -543,7 +543,7 @@ HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CBSubFrame::ScToString() { +const char *CBSubFrame::ScToString() { return "[subframe]"; } diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h index ec4e7204d0..80c0cc6092 100644 --- a/engines/wintermute/BSubFrame.h +++ b/engines/wintermute/BSubFrame.h @@ -76,7 +76,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index a184a46e40..efd167a137 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -1088,7 +1088,7 @@ HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CPartEmitter::ScToString() { +const char *CPartEmitter::ScToString() { return "[particle emitter]"; } diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h index 66814558b1..89a56a21a0 100644 --- a/engines/wintermute/PartEmitter.h +++ b/engines/wintermute/PartEmitter.h @@ -121,7 +121,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); private: diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index 15a9d6f49b..e2c13e80ba 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -1002,7 +1002,7 @@ HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIButton::ScToString() { +const char *CUIButton::ScToString() { return "[button]"; } diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index de50431f2d..0d504fdea0 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -71,7 +71,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 5b222ac831..4e048117ba 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -528,7 +528,7 @@ HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIEdit::ScToString() { +const char *CUIEdit::ScToString() { return "[edit]"; } diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index 762332e60c..9c2f4fddd4 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -64,7 +64,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index f0b7e7a68f..ce94d81519 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -322,7 +322,7 @@ HRESULT CUIEntity::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIEntity::ScToString() { +const char *CUIEntity::ScToString() { return "[entity container]"; } diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h index f55160b4d4..c18fd952dc 100644 --- a/engines/wintermute/UIEntity.h +++ b/engines/wintermute/UIEntity.h @@ -50,7 +50,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index 468ababfc1..153d04ada4 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -480,7 +480,7 @@ HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIObject::ScToString() { +const char *CUIObject::ScToString() { return "[ui_object]"; } diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h index 1f982ce830..6d5f463fca 100644 --- a/engines/wintermute/UIObject.h +++ b/engines/wintermute/UIObject.h @@ -75,7 +75,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 92e917ab36..434ab47027 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -455,7 +455,7 @@ HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIText::ScToString() { +const char *CUIText::ScToString() { return "[static]"; } diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h index 8071461ede..756834fd5c 100644 --- a/engines/wintermute/UIText.h +++ b/engines/wintermute/UIText.h @@ -51,7 +51,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index eeeb11d836..51d3ff0f2b 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -1092,7 +1092,7 @@ HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -char *CUIWindow::ScToString() { +const char *CUIWindow::ScToString() { return "[window]"; } diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h index deb6bd0a1b..510fc076b4 100644 --- a/engines/wintermute/UIWindow.h +++ b/engines/wintermute/UIWindow.h @@ -84,7 +84,7 @@ public: virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual char *ScToString(); + virtual const char *ScToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp index 0dd620c487..d14660de4c 100644 --- a/engines/wintermute/scriptables/SXArray.cpp +++ b/engines/wintermute/scriptables/SXArray.cpp @@ -69,7 +69,7 @@ CSXArray::~CSXArray() { ////////////////////////////////////////////////////////////////////////// -char *CSXArray::ScToString() { +const char *CSXArray::ScToString() { static char Dummy[32768]; strcpy(Dummy, ""); char PropName[20]; diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h index f3ae690ab2..3a174946fd 100644 --- a/engines/wintermute/scriptables/SXArray.h +++ b/engines/wintermute/scriptables/SXArray.h @@ -44,7 +44,7 @@ public: CScValue *ScGetProperty(const char *Name); HRESULT ScSetProperty(const char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - char *ScToString(); + const char *ScToString(); int _length; CScValue *_values; }; diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp index 9c16b3595e..d6b20fc3dc 100644 --- a/engines/wintermute/scriptables/SXDate.cpp +++ b/engines/wintermute/scriptables/SXDate.cpp @@ -66,7 +66,7 @@ CSXDate::~CSXDate() { ////////////////////////////////////////////////////////////////////////// -char *CSXDate::ScToString() { +const char *CSXDate::ScToString() { #if 0 return asctime(&_tm); #endif diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h index 1947925f02..cce3c5300e 100644 --- a/engines/wintermute/scriptables/SXDate.h +++ b/engines/wintermute/scriptables/SXDate.h @@ -43,7 +43,7 @@ public: CScValue *ScGetProperty(const char *Name); HRESULT ScSetProperty(const char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - char *ScToString(); + const char *ScToString(); char *_string; //struct tm _tm; // TODO! }; diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp index e25825bebe..5ffc69d1e7 100644 --- a/engines/wintermute/scriptables/SXFile.cpp +++ b/engines/wintermute/scriptables/SXFile.cpp @@ -86,7 +86,7 @@ void CSXFile::Close() { } ////////////////////////////////////////////////////////////////////////// -char *CSXFile::ScToString() { +const char *CSXFile::ScToString() { if (_filename) return _filename; else return "[file object]"; } diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h index daa63c305c..1900355dea 100644 --- a/engines/wintermute/scriptables/SXFile.h +++ b/engines/wintermute/scriptables/SXFile.h @@ -42,7 +42,7 @@ public: CScValue *ScGetProperty(const char *Name); HRESULT ScSetProperty(const char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - char *ScToString(); + const char *ScToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); private: diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp index 730108e4a4..6f5bfee6bb 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/scriptables/SXMemBuffer.cpp @@ -115,7 +115,7 @@ bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { } ////////////////////////////////////////////////////////////////////////// -char *CSXMemBuffer::ScToString() { +const char *CSXMemBuffer::ScToString() { return "[membuffer object]"; } diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h index e63601a113..824c0aaf77 100644 --- a/engines/wintermute/scriptables/SXMemBuffer.h +++ b/engines/wintermute/scriptables/SXMemBuffer.h @@ -41,7 +41,7 @@ public: CScValue *ScGetProperty(const char *Name); HRESULT ScSetProperty(const char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - char *ScToString(); + const char *ScToString(); CSXMemBuffer(CBGame *inGame, CScStack *Stack); CSXMemBuffer(CBGame *inGame, void *Buffer); virtual ~CSXMemBuffer(); diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp index 183be7dec5..2837530ca0 100644 --- a/engines/wintermute/scriptables/SXString.cpp +++ b/engines/wintermute/scriptables/SXString.cpp @@ -81,7 +81,7 @@ void CSXString::SetStringVal(const char *Val) { ////////////////////////////////////////////////////////////////////////// -char *CSXString::ScToString() { +const char *CSXString::ScToString() { if (_string) return _string; else return "[null string]"; } diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h index aa3b9ebb35..44e2bbe5ef 100644 --- a/engines/wintermute/scriptables/SXString.h +++ b/engines/wintermute/scriptables/SXString.h @@ -42,7 +42,7 @@ public: HRESULT ScSetProperty(const char *Name, CScValue *Value); HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); void ScSetString(const char *Val); - char *ScToString(); + const char *ScToString(); void SetStringVal(const char *Val); CSXString(CBGame *inGame, CScStack *Stack); diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp index 7720aa314c..8075df0e71 100644 --- a/engines/wintermute/scriptables/ScValue.cpp +++ b/engines/wintermute/scriptables/ScValue.cpp @@ -591,7 +591,7 @@ const char *CScValue::GetString() { break; case VAL_NATIVE: { - char *StrVal = _valNative->ScToString(); + const char *StrVal = _valNative->ScToString(); SetStringVal(StrVal); return StrVal; break; -- cgit v1.2.3 From 7c8785d846bc9c813f37f610ed72f210cceba3b1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 06:56:00 +0200 Subject: WINTERMUTE: Require 32bpp for now. --- engines/wintermute/wintermute.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index e83261225f..e756f568c6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -73,7 +73,9 @@ Common::Error WinterMuteEngine::run() { // Initialize graphics using following: Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); initGraphics(800, 600, false, &format); - + if (g_system->getScreenFormat() != format) { + error("Wintermute currently REQUIRES 32bpp"); + } // You could use backend transactions directly as an alternative, // but it isn't recommended, until you want to handle the error values // from OSystem::endGFXTransaction yourself. -- cgit v1.2.3 From e57364959f4684a61480023e58205ee4593f5f9d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 07:01:05 +0200 Subject: WINTERMUTE: Add protected to ScValue --- engines/wintermute/scriptables/ScValue.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h index 92ee09f0c5..5d10e9ff12 100644 --- a/engines/wintermute/scriptables/ScValue.h +++ b/engines/wintermute/scriptables/ScValue.h @@ -89,10 +89,12 @@ public: CScValue *GetProp(const char *Name); CBScriptable *_valNative; CScValue *_valRef; +protected: bool _valBool; int _valInt; double _valFloat; char *_valString; +public: TValType _type; CScValue(CBGame *inGame); CScValue(CBGame *inGame, bool Val); -- cgit v1.2.3 From c97705cedf2a3b7a74219d2e668bd3a80233dbbe Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 07:05:35 +0200 Subject: WINTERMUTE: Fix a few more warnings --- engines/wintermute/BGame.cpp | 6 +++--- engines/wintermute/BGame.h | 2 +- engines/wintermute/BImage.cpp | 1 + engines/wintermute/BSoundBuffer.cpp | 3 ++- engines/wintermute/scriptables/ScEngine.cpp | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index fa2e19a3c7..a447b7a0f8 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -3148,7 +3148,7 @@ HRESULT CBGame::ShowCursor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SaveGame(int slot, char *desc, bool quickSave) { +HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { char Filename[MAX_PATH + 1]; GetSaveSlotFilename(slot, Filename); @@ -3793,10 +3793,10 @@ void CBGame::SetWindowTitle() { /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } - +#if 0 CBRenderSDL *renderer = static_cast(_renderer); // TODO -#if 0 + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); #endif } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index de98897a3d..8b0797825d 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -293,7 +293,7 @@ public: virtual HRESULT Cleanup(); virtual HRESULT LoadGame(int Slot); virtual HRESULT LoadGame(const char *Filename); - virtual HRESULT SaveGame(int slot, char *desc, bool quickSave = false); + virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); virtual HRESULT ShowCursor(); CBSprite *_cursorNoninteractive; diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp index 869d029e27..5f85215f7a 100644 --- a/engines/wintermute/BImage.cpp +++ b/engines/wintermute/BImage.cpp @@ -101,6 +101,7 @@ byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { return Buffer; #endif + return NULL; } diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index 1905325f8a..6b689f59ca 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -204,8 +204,8 @@ HRESULT CBSoundBuffer::Resume() { if (_stream) { BASS_ChannelPlay(_stream, FALSE); } - return S_OK; #endif + return S_OK; } @@ -237,6 +237,7 @@ uint32 CBSoundBuffer::GetLength() { QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); return 1000 * BASS_ChannelBytes2Seconds(_stream, len); #endif + return 0; } diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 4edb1c771b..67e9f9eef0 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -80,7 +80,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ::FreeLibrary(_compilerDLL); _compilerDLL = NULL; } else { - /* + */ /* // publish external methods to the compiler CALLBACKS c; c.Dll_AddError = AddError; @@ -759,7 +759,7 @@ HRESULT CScEngine::SaveBreakpoints() { for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { Count++; sprintf(Key, "Breakpoint%d", Count); - sprintf(Text, "%s:%d", _breakpoints[i]->_filename, _breakpoints[i]->_lines[j]); + sprintf(Text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); Game->_registry->WriteString("Debug", Key, Text); } -- cgit v1.2.3 From e13929b7f13a9f5de4e35fad6ce0029f340ede6d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 07:36:24 +0200 Subject: WINTERMUTE: Fix another bunch of warnings Mostly SAFE_DELETE-macro removal --- engines/wintermute/AdEntity.cpp | 44 +++++++++++++++++++++++------------ engines/wintermute/AdGame.cpp | 6 +++-- engines/wintermute/AdInventoryBox.cpp | 10 ++++---- engines/wintermute/AdItem.cpp | 8 +++++-- engines/wintermute/AdObject.cpp | 42 +++++++++++++++++++++------------ engines/wintermute/AdResponseBox.cpp | 22 +++++++++++------- engines/wintermute/AdSceneState.cpp | 5 ++-- engines/wintermute/BDiskFile.cpp | 2 +- engines/wintermute/BFontBitmap.cpp | 5 +++- engines/wintermute/BFontTT.cpp | 3 ++- engines/wintermute/BFrame.cpp | 3 ++- engines/wintermute/BGame.cpp | 4 ++-- engines/wintermute/BPkgFile.cpp | 2 +- engines/wintermute/BRegistry.cpp | 2 +- engines/wintermute/BRegistry.h | 2 +- engines/wintermute/BResourceFile.cpp | 2 +- engines/wintermute/BSprite.cpp | 5 ++-- engines/wintermute/PartEmitter.cpp | 3 ++- engines/wintermute/PlatformSDL.cpp | 2 +- 19 files changed, 110 insertions(+), 62 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index 0a78cfab98..a472107c90 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -220,7 +220,8 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SPRITE: { - SAFE_DELETE(_sprite); + delete _sprite; + _sprite = NULL; spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; else _sprite = spr; @@ -297,10 +298,11 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - SAFE_DELETE(_cursor); + delete _cursor; _cursor = new CBSprite(Game); if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - SAFE_DELETE(_cursor); + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; @@ -322,13 +324,17 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_BLOCKED_REGION: { - SAFE_DELETE(_blockRegion); - SAFE_DELETE(_currentBlockRegion); + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { - SAFE_DELETE(_blockRegion); - SAFE_DELETE(_currentBlockRegion); + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; cmd = PARSERR_GENERIC; } else { _blockRegion = rgn; @@ -339,13 +345,17 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WAYPOINTS: { - SAFE_DELETE(_wptGroup); - SAFE_DELETE(_currentWptGroup); + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { - SAFE_DELETE(_wptGroup); - SAFE_DELETE(_currentWptGroup); + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; cmd = PARSERR_GENERIC; } else { _wptGroup = wpt; @@ -361,7 +371,8 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SUBTYPE: { if (scumm_stricmp((char *)params, "sound") == 0) { - SAFE_DELETE(_sprite); + delete _sprite; + _sprite = NULL; if (Game->_editorMode) { spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; @@ -514,7 +525,8 @@ HRESULT CAdEntity::Update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { - SAFE_DELETE(_animSprite); + delete _animSprite; + _animSprite = NULL; } // finished playing animation? @@ -946,10 +958,12 @@ HRESULT CAdEntity::SetSprite(const char *Filename) { SetCurrent = true; } - SAFE_DELETE(_sprite); + delete _sprite; + _sprite = NULL; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->LoadFile(Filename))) { - SAFE_DELETE(_sprite); + delete _sprite; + _sprite = NULL; return E_FAIL; } else { _sprite = spr; diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp index fc1435d1cb..e2d790e87e 100644 --- a/engines/wintermute/AdGame.cpp +++ b/engines/wintermute/AdGame.cpp @@ -196,7 +196,8 @@ HRESULT CAdGame::Cleanup() { HRESULT CAdGame::InitLoop() { if (_scheduledScene && _transMgr->IsReady()) { ChangeScene(_scheduledScene, _scheduledFadeIn); - SAFE_DELETE_ARRAY(_scheduledScene); + delete[] _scheduledScene; + _scheduledScene = NULL; Game->_activeObject = NULL; } @@ -705,7 +706,8 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This RegisterObject(_responseBox); Stack->PushBool(true); } else { - SAFE_DELETE(_responseBox); + delete _responseBox; + _responseBox = NULL; Stack->PushBool(false); } return S_OK; diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index c89fd5215f..a5d1b117c6 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -69,7 +69,8 @@ CAdInventoryBox::~CAdInventoryBox() { Game->UnregisterObject(_window); _window = NULL; - SAFE_DELETE(_closeButton); + delete _closeButton; + _closeButton = NULL; } @@ -237,10 +238,11 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WINDOW: - SAFE_DELETE(_window); + delete _window; _window = new CUIWindow(Game); if (!_window || FAILED(_window->LoadBuffer(params, false))) { - SAFE_DELETE(_window); + delete _window; + _window = NULL; cmd = PARSERR_GENERIC; } else Game->RegisterObject(_window); break; @@ -292,7 +294,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { } if (_exclusive) { - SAFE_DELETE(_closeButton); + delete _closeButton; _closeButton = new CUIButton(Game); if (_closeButton) { _closeButton->SetName("close"); diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp index b360f97e1d..3b78fa5507 100644 --- a/engines/wintermute/AdItem.cpp +++ b/engines/wintermute/AdItem.cpp @@ -700,8 +700,12 @@ HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AmountString") == 0) { - if (Value->IsNULL()) SAFE_DELETE_ARRAY(_amountString); - else CBUtils::SetString(&_amountString, Value->GetString()); + if (Value->IsNULL()) { + delete[] _amountString; + _amountString = NULL; + } else { + CBUtils::SetString(&_amountString, Value->GetString()); + } return S_OK; } diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 4351e0953c..122a4bdbb6 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -107,16 +107,22 @@ CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdObject::~CAdObject() { _currentSprite = NULL; // reference only, don't delete - SAFE_DELETE(_animSprite); - SAFE_DELETE(_sentence); - SAFE_DELETE_ARRAY(_forcedTalkAnimName); - - SAFE_DELETE(_blockRegion); - SAFE_DELETE(_wptGroup); + delete _animSprite; + _animSprite = NULL; + delete _sentence; + _sentence = NULL; + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; - SAFE_DELETE(_currentBlockRegion); - SAFE_DELETE(_currentWptGroup); + delete _blockRegion; + _blockRegion = NULL; + delete _wptGroup; + _wptGroup = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; _tempSprite2 = NULL; // reference only _stickRegion = NULL; @@ -146,7 +152,8 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::PlayAnim(const char *Filename) { - SAFE_DELETE(_animSprite); + delete _animSprite; + _animSprite = NULL; _animSprite = new CBSprite(Game, this); if (!_animSprite) { Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); @@ -155,7 +162,8 @@ HRESULT CAdObject::PlayAnim(const char *Filename) { HRESULT res = _animSprite->LoadFile(Filename); if (FAILED(res)) { Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); - SAFE_DELETE(_animSprite); + delete _animSprite; + _animSprite = NULL; return res; } _state = STATE_PLAYING_ANIM; @@ -233,7 +241,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th else if (strcmp(Name, "ForceTalkAnim") == 0) { Stack->CorrectParams(1); const char *AnimName = Stack->Pop()->GetString(); - SAFE_DELETE_ARRAY(_forcedTalkAnimName); + delete[] _forcedTalkAnimName; _forcedTalkAnimName = new char[strlen(AnimName) + 1]; strcpy(_forcedTalkAnimName, AnimName); _forcedTalkAnimUsed = false; @@ -483,7 +491,8 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th HRESULT res; CAdEntity *Ent = new CAdEntity(Game); if (FAILED(res = Ent->LoadFile(Filename))) { - SAFE_DELETE(Ent); + delete Ent; + Ent = NULL; Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); Stack->PushBool(false); } else { @@ -820,11 +829,13 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const if (!_sentence) return; if (_forcedTalkAnimName && _forcedTalkAnimUsed) { - SAFE_DELETE_ARRAY(_forcedTalkAnimName); + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; _forcedTalkAnimUsed = false; } - SAFE_DELETE(_sentence->_sound); + delete (_sentence->_sound); + _sentence->_sound = NULL; _sentence->SetText(Text); Game->_stringTable->Expand(&_sentence->_text); @@ -927,7 +938,8 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::Reset() { if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { - SAFE_DELETE(_animSprite); + delete _animSprite; + _animSprite = NULL; } else if (_state == STATE_TALKING && _sentence) { _sentence->Finish(); } diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index cd8f950393..2ded9d3fa7 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -73,10 +73,14 @@ CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdResponseBox::~CAdResponseBox() { - SAFE_DELETE(_window); - SAFE_DELETE(_shieldWindow); - SAFE_DELETE_ARRAY(_lastResponseText); - SAFE_DELETE_ARRAY(_lastResponseTextOrig); + delete _window; + _window = NULL; + delete _shieldWindow; + _shieldWindow = NULL; + delete[] _lastResponseText; + _lastResponseText = NULL; + delete[] _lastResponseTextOrig; + _lastResponseTextOrig = NULL; if (_font) Game->_fontStorage->RemoveFont(_font); if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); @@ -255,10 +259,11 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_WINDOW: - SAFE_DELETE(_window); + delete _window; _window = new CUIWindow(Game); if (!_window || FAILED(_window->LoadBuffer(params, false))) { - SAFE_DELETE(_window); + delete _window; + _window = NULL; cmd = PARSERR_GENERIC; } else if (_shieldWindow) _shieldWindow->_parent = _window; break; @@ -304,10 +309,11 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CURSOR: - SAFE_DELETE(_cursor); + delete _cursor; _cursor = new CBSprite(Game); if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - SAFE_DELETE(_cursor); + delete _cursor; + _cursor = NULL; cmd = PARSERR_GENERIC; } break; diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp index 00fd826d6a..2404178b09 100644 --- a/engines/wintermute/AdSceneState.cpp +++ b/engines/wintermute/AdSceneState.cpp @@ -45,7 +45,8 @@ CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CAdSceneState::~CAdSceneState() { - SAFE_DELETE_ARRAY(_filename); + delete[] _filename; + _filename = NULL; for (int i = 0; i < _nodeStates.GetSize(); i++) delete _nodeStates[i]; _nodeStates.RemoveAll(); @@ -63,7 +64,7 @@ HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CAdSceneState::SetFilename(const char *Filename) { - SAFE_DELETE_ARRAY(_filename); + delete[] _filename; _filename = new char [strlen(Filename) + 1]; if (_filename) strcpy(_filename, Filename); } diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index b456083058..a2ec38a57e 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -180,7 +180,7 @@ HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { if (_compressed) { - uint32 NewPos = 0; + int32 NewPos = 0; switch (Origin) { case SEEK_TO_BEGIN: diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 46e66ae84c..94edf9292a 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -401,7 +401,10 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { if (sprite_file != NULL) { delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) SAFE_DELETE(_sprite); + if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) { + delete _sprite; + _sprite = NULL; + } } if (surface_file != NULL && !_sprite) { diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp index d27985a62e..94fdd81d0a 100644 --- a/engines/wintermute/BFontTT.cpp +++ b/engines/wintermute/BFontTT.cpp @@ -813,7 +813,8 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, for (it = lines.begin(); it != lines.end(); ++it) { TextLine *line = (*it); textWidth = MAX(textWidth, line->GetWidth()); - SAFE_DELETE(line); + delete line; + line = NULL; } } diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp index 8f52f90dc3..7d0fe61fd4 100644 --- a/engines/wintermute/BFrame.cpp +++ b/engines/wintermute/BFrame.cpp @@ -68,7 +68,8 @@ CBFrame::~CBFrame() { _subframes.RemoveAll(); for (i = 0; i < _applyEvent.GetSize(); i++) { - SAFE_DELETE_ARRAY(_applyEvent[i]); + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; } _applyEvent.RemoveAll(); } diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index a447b7a0f8..6758d2e71e 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -3458,7 +3458,7 @@ HRESULT CBGame::LoadSettings(const char *Filename) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - SAFE_DELETE_ARRAY(_settingsGameFile); + delete[] _settingsGameFile; _settingsGameFile = new char[strlen((char *)params) + 1]; if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); break; @@ -4012,7 +4012,7 @@ HRESULT CBGame::DisplayIndicator() { else _saveLoadImage->DisplayTrans(_saveImageX, _saveImageY, rc); } - if (!_indicatorDisplay && _indicatorWidth <= 0 || _indicatorHeight <= 0) return S_OK; + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; _renderer->SetupLines(); for (int i = 0; i < _indicatorHeight; i++) _renderer->DrawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index f336574c0c..055748b520 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -128,7 +128,7 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { if (!_fileEntry) return E_FAIL; - uint32 NewPos = 0; + int32 NewPos = 0; switch (Origin) { case SEEK_TO_BEGIN: diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp index 0e9592ce56..74d524189a 100644 --- a/engines/wintermute/BRegistry.cpp +++ b/engines/wintermute/BRegistry.cpp @@ -116,7 +116,7 @@ bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetIniName(char *Name) { +void CBRegistry::SetIniName(const char *Name) { delete[] _iniName; _iniName = NULL; diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h index 99d25e88c3..bd4466989e 100644 --- a/engines/wintermute/BRegistry.h +++ b/engines/wintermute/BRegistry.h @@ -35,7 +35,7 @@ namespace WinterMute { class CBRegistry : public CBBase { public: - void SetIniName(char *Name); + void SetIniName(const char *Name); char *GetIniName(); bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp index c6de083d9c..d7eb470ca2 100644 --- a/engines/wintermute/BResourceFile.cpp +++ b/engines/wintermute/BResourceFile.cpp @@ -80,7 +80,7 @@ HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { if (!_data) return E_FAIL; - uint32 NewPos = 0; + int32 NewPos = 0; switch (Origin) { case SEEK_TO_BEGIN: diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp index 06bf9a4d6a..2ecaf1831c 100644 --- a/engines/wintermute/BSprite.cpp +++ b/engines/wintermute/BSprite.cpp @@ -94,7 +94,8 @@ void CBSprite::Cleanup() { delete _frames[i]; _frames.RemoveAll(); - SAFE_DELETE_ARRAY(_editorBgFile); + delete[] _editorBgFile; + _editorBgFile = NULL; SetDefaults(); } @@ -262,7 +263,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite case TOKEN_EDITOR_BG_FILE: if (Game->_editorMode) { - SAFE_DELETE_ARRAY(_editorBgFile); + delete[] _editorBgFile; _editorBgFile = new char[strlen((char *)params) + 1]; if (_editorBgFile) strcpy(_editorBgFile, (char *)params); } diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp index efd167a137..c0e03c25d0 100644 --- a/engines/wintermute/PartEmitter.cpp +++ b/engines/wintermute/PartEmitter.cpp @@ -1078,7 +1078,8 @@ HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "EmitEvent") == 0) { - SAFE_DELETE_ARRAY(_emitEvent); + delete[] _emitEvent; + _emitEvent = NULL; if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); return S_OK; } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 3335bd3155..2446cb210f 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -92,7 +92,7 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { Game->_smartCache = false; } - bool AllowDirectDraw = Game->_registry->ReadBool("Debug", "AllowDirectDraw", false); +/* bool AllowDirectDraw = Game->_registry->ReadBool("Debug", "AllowDirectDraw", false);*/ // load general game settings Game->Initialize1(); -- cgit v1.2.3 From 16f1a45844d89901e2667d800cea33b02f113b8f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 07:47:09 +0200 Subject: WINTERMUTE: Fix more warnings, mostly missing switch-cases. --- engines/wintermute/AdInventoryBox.cpp | 3 +++ engines/wintermute/AdLayer.cpp | 3 +++ engines/wintermute/AdResponseBox.cpp | 6 ++++++ engines/wintermute/AdScene.cpp | 3 +++ engines/wintermute/BFontBitmap.cpp | 3 +++ engines/wintermute/BRegion.cpp | 2 +- engines/wintermute/BRegion.h | 2 +- engines/wintermute/UIText.cpp | 3 +++ 8 files changed, 23 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp index a5d1b117c6..b05072e0b9 100644 --- a/engines/wintermute/AdInventoryBox.cpp +++ b/engines/wintermute/AdInventoryBox.cpp @@ -89,6 +89,9 @@ HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { _scrollOffset += _scrollBy; } else return CBObject::Listen(param1, param2); break; + default: + error("CAdInventoryBox::Listen - Unhandled enum"); + break; } return S_OK; diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp index 156de5b2e7..b25dd57315 100644 --- a/engines/wintermute/AdLayer.cpp +++ b/engines/wintermute/AdLayer.cpp @@ -506,6 +506,9 @@ HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { case OBJECT_REGION: _nodes[i]->_region->SaveAsText(Buffer, Indent + 2); break; + default: + error("CAdLayer::SaveAsText - Unhandled enum"); + break; } } diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index 2ded9d3fa7..603915396b 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -361,6 +361,9 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { case TAL_CENTER: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; + default: + error("CAdResponseBox::SaveAsText - Unhandled enum"); + break; } switch (_verticalAlign) { @@ -551,6 +554,9 @@ HRESULT CAdResponseBox::WeedResponses() { i--; } break; + default: + error("CAdResponseBox::WeedResponses - Unhandled enum"); + break; } } return S_OK; diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index e0fb05d867..904bc87a13 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -1000,6 +1000,9 @@ HRESULT CAdScene::TraverseNodes(bool Update) { if (!Update) DisplayRegionContent(Node->_region); } break; + default: + error("AdScene::TraverseNodes - Unhandled enum"); + break; } // switch } // each node diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp index 94edf9292a..7c659dbfad 100644 --- a/engines/wintermute/BFontBitmap.cpp +++ b/engines/wintermute/BFontBitmap.cpp @@ -188,6 +188,9 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig case TAL_LEFT: StartX = x; break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; } for (i = start; i < end + 1; i++) { if (draw) DrawChar(str[i], StartX, y); diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index 15d7b26d94..f775c61091 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -378,7 +378,7 @@ const char *CBRegion::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride) { +HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h index 9869cda5e1..c265495403 100644 --- a/engines/wintermute/BRegion.h +++ b/engines/wintermute/BRegion.h @@ -54,7 +54,7 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); RECT _rect; CBArray _points; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, char *NameOverride = NULL); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); // scripting interface virtual CScValue *ScGetProperty(const char *Name); diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 434ab47027..3fcda74d1c 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -327,6 +327,9 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { case TAL_CENTER: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; + default: + error("CUIText::SaveAsText - Unhandled enum"); + break; } switch (_verticalAlign) { -- cgit v1.2.3 From 753781f9725507049e8050ccfed6f8ecf291c540 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 12 May 2012 08:06:55 +0200 Subject: WINTERMUTE: Break the binary interface, to fix another truckload of warnings. --- engines/wintermute/scriptables/ScEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index c633a98d6c..5ba93d6d0e 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -42,7 +42,7 @@ typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSi typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); -typedef int (*DLL_DEFINE_FUNCTION)(char *Name); +typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); typedef int (*DLL_DEFINE_VARIABLE)(char *Name); typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); -- cgit v1.2.3 From a53fa953a4869bed8e9aebe86ca6343e79225bf6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 24 May 2012 11:44:19 +0200 Subject: WINTERMUTE: Don't use unsigned datatypes in rects. --- engines/wintermute/wintypes.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index e3dd615063..c96b109d07 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -55,16 +55,16 @@ typedef const char *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; typedef struct tagRECT { - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; + int32 left; + int32 top; + int32 right; + int32 bottom; } RECT, *LPRECT; typedef struct tagPOINT { - uint32 x; - uint32 y; + int32 x; + int32 y; } POINT, *LPPOINT; -- cgit v1.2.3 From ae48c3f7e156d2fd5dfd2dba8931cfee679c0198 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 31 May 2012 22:00:11 +0200 Subject: WINTERMUTE: Add transparentSurface internally for now, to allow alpha-blended blits. --- engines/wintermute/BRenderSDL.cpp | 15 +- engines/wintermute/BSurfaceSDL.cpp | 73 +++-- engines/wintermute/graphics/transparentSurface.cpp | 322 +++++++++++++++++++++ engines/wintermute/graphics/transparentSurface.h | 124 ++++++++ engines/wintermute/module.mk | 1 + 5 files changed, 493 insertions(+), 42 deletions(-) create mode 100644 engines/wintermute/graphics/transparentSurface.cpp create mode 100644 engines/wintermute/graphics/transparentSurface.h (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index fbb683dfb6..34f0a57250 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/BGame.h" #include "engines/wintermute/BSprite.h" #include "common/system.h" +#include "engines/wintermute/graphics/transparentSurface.h" namespace WinterMute { @@ -273,18 +274,8 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { // Replacement for SDL2's SDL_RenderCopy void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { - for (int i = 0; i < srcRect->height(); i++) { - byte *destPtr = (byte*)_renderSurface->getBasePtr(dstRect->left, dstRect->top + i); - byte *srcPtr = (byte*)surf->getBasePtr(srcRect->left, srcRect->top + i); - for (int j = 0; j < srcRect->width(); j++) { - // TODO: Replace this with something less ugly, and more portable. - if (((byte *)srcPtr)[0] == 255) { - memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel); - } - srcPtr += _renderSurface->format.bytesPerPixel; - destPtr += _renderSurface->format.bytesPerPixel; - } - } + TransparentSurface src(*surf, false); + src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(255, 255, 255, 255), dstRect->width(), dstRect->height() ); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index 349d563503..bb99f47a12 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -36,9 +36,11 @@ #include "graphics/decoders/bmp.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" +#include "engines/wintermute/graphics/transparentSurface.h" #include "common/stream.h" #include "BFileManager.h" #include "PlatformSDL.h" +#include "common/system.h" namespace WinterMute { @@ -130,9 +132,12 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, // no alpha, set color key /* if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - + if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { + _surface = surface->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + } //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); @@ -184,16 +189,16 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); return; -#if 0 + delete[] _alphaMask; _alphaMask = NULL; if (!surface) return; - +#if 0 SDL_LockSurface(surface); - +#endif bool hasColorKey; - Uint32 colorKey; - Uint8 ckRed, ckGreen, ckBlue; + uint32 colorKey; + uint8 ckRed, ckGreen, ckBlue; /* if (SDL_GetColorKey(surface, &colorKey) == 0) { hasColorKey = true; SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); @@ -204,10 +209,11 @@ void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { bool hasTransparency = false; for (int y = 0; y < surface->h; y++) { for (int x = 0; x < surface->w; x++) { - Uint32 pixel = GetPixel(surface, x, y); + uint32 pixel = GetPixel(surface, x, y); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) a = 0; @@ -216,23 +222,21 @@ void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { if (a < 255) hasTransparency = true; } } - +#if 0 SDL_UnlockSurface(surface); - +#endif if (!hasTransparency) { delete[] _alphaMask; _alphaMask = NULL; } -#endif } ////////////////////////////////////////////////////////////////////////// uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { warning("CBSurfaceSDL::GetPixel - Not ported yet"); -#if 0 - int bpp = surface->format->BytesPerPixel; + int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ - uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; switch (bpp) { case 1: @@ -240,24 +244,26 @@ uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { break; case 2: - return *(Uint16 *)p; + return *(uint16 *)p; break; case 3: - if (SDL_BYTEORDER == SDL_BIG_ENDIAN) +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) return p[0] << 16 | p[1] << 8 | p[2]; - else +#else + //else return p[0] | p[1] << 8 | p[2] << 16; +#endif break; case 4: - return *(Uint32 *)p; + return *(uint32 *)p; break; default: return 0; /* shouldn't happen, but avoids warnings */ } -#endif return 0; } @@ -267,14 +273,14 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) { #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); - +#endif _width = Width; _height = Height; - +#if 0 Game->AddMem(_width * _height * 4); - - _valid = true; #endif + _valid = true; + return S_OK; } @@ -284,14 +290,21 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); - +#endif + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); _width = surface->w; _height = surface->h; - +#if 0 Game->AddMem(_width * _height * 4); - - _valid = true; #endif + _valid = true; + return S_OK; } diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp new file mode 100644 index 0000000000..c8ac9f1a2c --- /dev/null +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -0,0 +1,322 @@ +/* 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. + */ + +#include "common/algorithm.h" +#include "common/endian.h" +#include "common/util.h" +#include "common/rect.h" +#include "common/textconsole.h" +#include "graphics/primitives.h" +#include "engines/wintermute/graphics/transparentSurface.h" + +namespace WinterMute { + +TransparentSurface::TransparentSurface() : Surface() {} + +TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface() { + if (copyData) { + copyFrom(surf); + } else { + w = surf.w; + h = surf.h; + pitch = surf.pitch; + format = surf.format; + pixels = surf.pixels; + } +} + +Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height) { + int ca = (color >> 24) & 0xff; + + Common::Rect retSize; + retSize.top = 0; + retSize.left = 0; + retSize.setWidth(0); + retSize.setHeight(0); + // Check if we need to draw anything at all + if (ca == 0) + return retSize; + + int cr = (color >> 16) & 0xff; + int cg = (color >> 8) & 0xff; + int cb = (color >> 0) & 0xff; + + // Compensate for transparency. Since we're coming + // down to 255 alpha, we just compensate for the colors here + if (ca != 255) { + cr = cr * ca >> 8; + cg = cg * ca >> 8; + cb = cb * ca >> 8; + } + + // Create an encapsulating surface for the data + TransparentSurface srcImage(*this, false); + // TODO: Is the data really in the screen format? + if (format.bytesPerPixel != 4) { + error("TransparentSurface can only blit 32 bpp images"); + } + + if (pPartRect) { + srcImage.pixels = &((char *)pixels)[pPartRect->top * srcImage.pitch + pPartRect->left * 4]; + srcImage.w = pPartRect->width(); + srcImage.h = pPartRect->height(); + + debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, + pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); + } else { + + debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0, + srcImage.w, srcImage.h, color, width, height); + } + + if (width == -1) + width = srcImage.w; + if (height == -1) + height = srcImage.h; + +#ifdef SCALING_TESTING + // Hardcode scaling to 66% to test scaling + width = width * 2 / 3; + height = height * 2 / 3; +#endif + + Graphics::Surface *img; + Graphics::Surface *imgScaled = NULL; + byte *savedPixels = NULL; + if ((width != srcImage.w) || (height != srcImage.h)) { + // Scale the image + img = imgScaled = srcImage.scale(width, height); + savedPixels = (byte *)img->pixels; + } else { + img = &srcImage; + } + + // Handle off-screen clipping + if (posY < 0) { + img->h = MAX(0, (int)img->h - -posY); + img->pixels = (byte *)img->pixels + img->pitch * -posY; + posY = 0; + } + + if (posX < 0) { + img->w = MAX(0, (int)img->w - -posX); + img->pixels = (byte *)img->pixels + (-posX * 4); + posX = 0; + } + + img->w = CLIP((int)img->w, 0, (int)MAX((int)target.w - posX, 0)); + img->h = CLIP((int)img->h, 0, (int)MAX((int)target.h - posY, 0)); + + if ((img->w > 0) && (img->h > 0)) { + int xp = 0, yp = 0; + + int inStep = 4; + int inoStep = img->pitch; + if (flipping & TransparentSurface::FLIP_V) { + inStep = -inStep; + xp = img->w - 1; + } + + if (flipping & TransparentSurface::FLIP_H) { + inoStep = -inoStep; + yp = img->h - 1; + } + + byte *ino = (byte *)img->getBasePtr(xp, yp); + byte *outo = (byte *)target.getBasePtr(posX, posY); + byte *in, *out; + + int bShift = img->format.bShift; + int gShift = img->format.gShift; + int rShift = img->format.rShift; + int aShift = img->format.aShift; + + int bShiftTarget = target.format.bShift; + int gShiftTarget = target.format.gShift; + int rShiftTarget = target.format.rShift; + int aShiftTarget = target.format.aShift; + + for (int i = 0; i < img->h; i++) { + out = outo; + in = ino; + for (int j = 0; j < img->w; j++) { + uint32 pix = *(uint32 *)in; + uint32 o_pix = *(uint32 *) out; + int b = (pix >> bShift) & 0xff; + int g = (pix >> gShift) & 0xff; + int r = (pix >> rShift) & 0xff; + int a = (pix >> aShift) & 0xff; + int o_b, o_g, o_r, o_a; + in += inStep; + + if (ca != 255) { + a = a * ca >> 8; + } + + switch (a) { + case 0: // Full transparency + out += 4; + break; + case 255: // Full opacity + if (cb != 255) + o_b = (b * cb) >> 8; + else + o_b = b; + + if (cg != 255) + o_g = (g * cg) >> 8; + else + o_g = g; + + if (cr != 255) + o_r = (r * cr) >> 8; + else + o_r = r; + o_a = a; + *(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out += 4; + break; + + default: // alpha blending + o_a = 255; + o_b = (o_pix >> bShiftTarget) & 0xff; + o_g = (o_pix >> gShiftTarget) & 0xff; + o_r = (o_pix >> rShiftTarget) & 0xff; + if (cb == 0) + o_b = 0; + else if (cb != 255) + o_b += ((b - o_b) * a * cb) >> 16; + else + o_b += ((b - o_b) * a) >> 8; + if (cg == 0) + o_g = 0; + else if (cg != 255) + o_g += ((g - o_g) * a * cg) >> 16; + else + o_g += ((g - o_g) * a) >> 8; + if (cr == 0) + o_r = 0; + else if (cr != 255) + o_r += ((r - o_r) * a * cr) >> 16; + else + o_r += ((r - o_r) * a) >> 8; + *(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out += 4; + } + } + outo += target.pitch; + ino += inoStep; + } + } + + if (imgScaled) { + imgScaled->pixels = savedPixels; + imgScaled->free(); + delete imgScaled; + } + + retSize.setWidth(img->w); + retSize.setHeight(img->h); + return retSize; +} + +/** + * Scales a passed surface, creating a new surface with the result + * @param srcImage Source image to scale + * @param scaleFactor Scale amount. Must be between 0 and 1.0 (but not zero) + * @remarks Caller is responsible for freeing the returned surface + */ +TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { + TransparentSurface *s = new TransparentSurface(); + s->create(xSize, ySize, this->format); + + int *horizUsage = scaleLine(xSize, this->w); + int *vertUsage = scaleLine(ySize, this->h); + + // Loop to create scaled version + for (int yp = 0; yp < ySize; ++yp) { + const byte *srcP = (const byte *)this->getBasePtr(0, vertUsage[yp]); + byte *destP = (byte *)s->getBasePtr(0, yp); + + for (int xp = 0; xp < xSize; ++xp) { + const byte *tempSrcP = srcP + (horizUsage[xp] * this->format.bytesPerPixel); + for (int byteCtr = 0; byteCtr < this->format.bytesPerPixel; ++byteCtr) { + *destP++ = *tempSrcP++; + } + } + } + + // Delete arrays and return surface + delete[] horizUsage; + delete[] vertUsage; + return s; +} + +/** + * Writes a color key to the alpha channel of the surface + * @param rKey the red component of the color key + * @param gKey the green component of the color key + * @param bKey the blue component of the color key + * @param overwriteAlpha if true, all other alpha will be set fully opaque + */ +void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + uint32 pix = ((uint32 *)pixels)[i * w + j]; + uint8 r, g, b, a; + format.colorToARGB(pix, a, r, g, b); + if (r == rKey && g == gKey && b == bKey) { + a = 0; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } else if (overwriteAlpha) { + a = 255; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } + } + } +} + +/** + * Returns an array indicating which pixels of a source image horizontally or vertically get + * included in a scaled image + */ +int *TransparentSurface::scaleLine(int size, int srcSize) { + int scale = 100 * size / srcSize; + assert(scale > 0); + int *v = new int[size]; + Common::fill(v, &v[size], 0); + + int distCtr = 0; + int *destP = v; + for (int distIndex = 0; distIndex < srcSize; ++distIndex) { + distCtr += scale; + while (distCtr >= 100) { + assert(destP < &v[size]); + *destP++ = distIndex; + distCtr -= 100; + } + } + + return v; +} + + +} // End of namespace Graphics diff --git a/engines/wintermute/graphics/transparentSurface.h b/engines/wintermute/graphics/transparentSurface.h new file mode 100644 index 0000000000..e271bf2488 --- /dev/null +++ b/engines/wintermute/graphics/transparentSurface.h @@ -0,0 +1,124 @@ +/* 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. + */ + +#ifndef GRAPHICS_TRANSPARENTSURFACE_H +#define GRAPHICS_TRANSPARENTSURFACE_H + +#include "graphics/surface.h" + +/* + * This code is based on Broken Sword 2.5 engine + * + * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer + * + * Licensed under GNU GPL v2 + * + */ + +// TODO: Find a better solution for this. +#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B)) +#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B)) + +namespace WinterMute { + +/** + * A transparent graphics surface, which implements alpha blitting. + */ +struct TransparentSurface : public Graphics::Surface { + TransparentSurface(); + TransparentSurface(const Graphics::Surface &surf, bool copyData = false); + + void setColorKey(char r, char g, char b); + void disableColorKey(); + + // Enums + /** + @brief The possible flipping parameters for the blit methode. + */ + enum FLIP_FLAGS { + /// The image will not be flipped. + FLIP_NONE = 0, + /// The image will be flipped at the horizontal axis. + FLIP_H = 1, + /// The image will be flipped at the vertical axis. + FLIP_V = 2, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_HV = FLIP_H | FLIP_V, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_VH = FLIP_H | FLIP_V + }; + + /** + @brief renders the surface to another surface + @param pDest a pointer to the target image. In most cases this is the framebuffer. + @param PosX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.
+ The default value is 0. + @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.
+ The default value is 0. + @param Flipping how the the image should be flipped.
+ The default value is BS_Image::FLIP_NONE (no flipping) + @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.
+ This referes to the unflipped and unscaled image.
+ The default value is NULL. + @param Color an ARGB color value, which determines the parameters for the color modulation und alpha blending.
+ The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).
+ The color components determines the color for color modulation.
+ The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation). + The macros BS_RGB and BS_ARGB can be used for the creation of the color value. + @param Width the output width of the screen section. + The images will be scaled if the output width of the screen section differs from the image section.
+ The value -1 determines that the image should not be scaled.
+ The default value is -1. + @param Width the output height of the screen section. + The images will be scaled if the output width of the screen section differs from the image section.
+ The value -1 determines that the image should not be scaled.
+ The default value is -1. + @return returns false if the rendering failed. + */ + + Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0, + int flipping = FLIP_NONE, + Common::Rect *pPartRect = NULL, + uint color = BS_ARGB(255, 255, 255, 255), + int width = -1, int height = -1); + void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); + TransparentSurface *scale(int xSize, int ySize) const; +private: + static int *scaleLine(int size, int srcSize); +}; + +/** + * A deleter for Surface objects which can be used with SharedPtr. + * + * This deleter assures Surface::free is called on deletion. + */ +/*struct SharedPtrTransparentSurfaceDeleter { + void operator()(TransparentSurface *ptr) { + ptr->free(); + delete ptr; + } +};*/ + + +} // End of namespace Graphics + + +#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 3dc00b5a33..b5ad3e9921 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -13,6 +13,7 @@ MODULE_OBJS := \ scriptables/SXMemBuffer.o \ scriptables/SXStore.o \ scriptables/SXString.o \ + graphics/transparentSurface.o \ AdActor.o \ AdActorDir.o \ AdEntity.o \ -- cgit v1.2.3 From ebbf92578db8b8b51d3a3b64f5befd30ec8b4547 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 31 May 2012 22:08:09 +0200 Subject: WINTERMUTE: Re-enable scaling. --- engines/wintermute/BSurfaceSDL.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index bb99f47a12..d12a9b7a8f 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -456,12 +456,9 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.left = X; position.top = Y; // TODO: Scaling... - /* + position.setWidth((float)srcRect.width() * ZoomX / 100.f); position.setHeight((float)srcRect.height() * ZoomX / 100.f); - */ - position.setWidth(srcRect.width()); - position.setHeight(srcRect.height()); renderer->ModTargetRect(&position); -- cgit v1.2.3 From c05059ea8a78ef2c6f0f6f9caff3495f7ab28ade Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 31 May 2012 23:35:46 +0200 Subject: WINTERMUTE: Use AdvancedDetector, and add another game. --- engines/wintermute/detection.cpp | 58 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 39bb3f1c55..f0066e4686 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -20,6 +20,7 @@ * */ +#include "engines/advancedDetector.h" #include "engines/wintermute/wintermute.h" #include "common/config-manager.h" @@ -28,24 +29,54 @@ #include "engines/metaengine.h" -static const PlainGameDescriptor WinterMute_setting[] = { - { "wintermute", "WinterMute - Unspecified game" }, +namespace WinterMute { + +static const ADGameDescription gameDescriptions[] = { + { + "wintermute", + "Dirty Split", + AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, + { + "wintermute", + "Five Magical Amulets", + AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, + AD_TABLE_END_MARKER +}; + +} + +static const PlainGameDescriptor wintermuteGames[] = { + { "wintermute", "Wintermute - Unspecified game" }, { 0, 0 } }; -class WinterMuteMetaEngine : public MetaEngine { +class WinterMuteMetaEngine : public AdvancedMetaEngine { public: + WinterMuteMetaEngine() : AdvancedMetaEngine(WinterMute::gameDescriptions, sizeof(ADGameDescription), wintermuteGames) { + } virtual const char *getName() const { - return "WinterMute Lite"; + return "Wintermute"; } virtual const char *getOriginalCopyright() const { return "Copyright (c) 2011 Jan Nedoma"; } - virtual GameList getSupportedGames() const { +/* virtual GameList getSupportedGames() const { GameList games; - const PlainGameDescriptor *g = WinterMute_setting; + const PlainGameDescriptor *g = wintermuteGames; while (g->gameid) { games.push_back(*g); g++; @@ -55,16 +86,16 @@ public: } virtual GameDescriptor findGame(const char *gameid) const { - const PlainGameDescriptor *g = WinterMute_setting; + const PlainGameDescriptor *g = wintermuteGames; while (g->gameid) { if (0 == scumm_stricmp(gameid, g->gameid)) break; g++; } return GameDescriptor(g->gameid, g->description); - } + }*/ - virtual GameList detectGames(const Common::FSList &fslist) const { +/* virtual GameList detectGames(const Common::FSList &fslist) const { GameList detectedGames; // Iterate over all files in the given directory @@ -80,9 +111,8 @@ public: } } return detectedGames; - } - - virtual Common::Error createInstance(OSystem *syst, Engine **engine) const { + }*/ + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { assert(syst); assert(engine); @@ -101,12 +131,12 @@ public: if (detectedGames[i].gameid() == gameid) { // At this point you may want to perform additional sanity checks. *engine = new WinterMute::WinterMuteEngine(syst); - return Common::kNoError; + return true; } } // Failed to find any game data - return Common::kNoGameDataFoundError; + return false; } }; -- cgit v1.2.3 From 03284a3f88d618455c290e5dc4a50ab72ce586e8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 00:43:12 +0200 Subject: WINTERMUTE: Add TGA-support to BSurfaceSDL --- engines/wintermute/BSurfaceSDL.cpp | 4 + engines/wintermute/graphics/tga.cpp | 164 ++++++++++++++++++++++++++++++++++++ engines/wintermute/graphics/tga.h | 57 +++++++++++++ engines/wintermute/module.mk | 1 + 4 files changed, 226 insertions(+) create mode 100644 engines/wintermute/graphics/tga.cpp create mode 100644 engines/wintermute/graphics/tga.h (limited to 'engines') diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp index d12a9b7a8f..732bb45429 100644 --- a/engines/wintermute/BSurfaceSDL.cpp +++ b/engines/wintermute/BSurfaceSDL.cpp @@ -37,6 +37,7 @@ #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/tga.h" #include "common/stream.h" #include "BFileManager.h" #include "PlatformSDL.h" @@ -76,7 +77,10 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, if (strFileName.hasSuffix(".png")) { imgDecoder = new Graphics::PNGDecoder(); } else if (strFileName.hasSuffix(".bmp")) { + warning("Loaded BMP WITH FILENAME!!!! %s", Filename); imgDecoder = new Graphics::BitmapDecoder(); + } else if (strFileName.hasSuffix(".tga")) { + imgDecoder = new WinterMute::TGA(); } else { error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); } diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp new file mode 100644 index 0000000000..6ea6974ce7 --- /dev/null +++ b/engines/wintermute/graphics/tga.cpp @@ -0,0 +1,164 @@ +/* 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. + */ + +/* Based on code from eos https://github.com/DrMcCoy/xoreos/ + * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 + */ + +#include "common/util.h" +#include "common/stream.h" +#include "common/textconsole.h" +#include "common/error.h" + +#include "engines/wintermute/graphics/tga.h" + +namespace WinterMute { + +TGA::TGA() { + +} + +TGA::~TGA() { + destroy(); +} + +void TGA::destroy() { + _surface.free(); +} + +bool TGA::loadStream(Common::SeekableReadStream &tga) { + byte imageType, pixelDepth; + bool success; + success = readHeader(tga, imageType, pixelDepth); + success = readData (tga, imageType, pixelDepth); + + if (tga.err()) { + warning("Failed reading TGA-file"); + return false; + } + return success; +} + +bool TGA::readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth) { + if (!tga.seek(0)) { + warning("Failed reading TGA-file"); + return false; + } + + // TGAs have an optional "id" string in the header + uint32 idLength = tga.readByte(); + + // Number of colors in the color map / palette + if (tga.readByte() != 0) { + warning("Unsupported feature: Color map"); + return false; + } + + // Image type. 2 == unmapped RGB, 3 == Grayscale + imageType = tga.readByte(); + if ((imageType != 2) && (imageType != 3)) { + warning("Unsupported image type: %d", imageType); + return false; + } + + // Color map specifications + X + Y + tga.skip(5 + 2 + 2); + + // Image dimensions + _surface.w = tga.readUint16LE(); + _surface.h = tga.readUint16LE(); + + // Bits per pixel + pixelDepth = tga.readByte(); + _surface.format.bytesPerPixel = pixelDepth / 8; + + if (imageType == 2) { + if (pixelDepth == 24) { + _hasAlpha = false; + _format = Graphics::PixelFormat(pixelDepth/8, 8, 8, 8, 0, 16, 8, 0, 0); + } else if (pixelDepth == 16 || pixelDepth == 32) { + _hasAlpha = true; + _format = Graphics::PixelFormat(pixelDepth/8, 8, 8, 8, 8, 24, 16, 8, 0); + } else { + warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); + return false; + } + } else if (imageType == 3) { + if (pixelDepth != 8) { + warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); + return false; + } + + _hasAlpha = false; + _format = Graphics::PixelFormat(1, 0, 0, 0, 0, 0, 0, 0, 0); + } + + // Image descriptor + tga.skip(1); + + // Skip the id string + tga.skip(idLength); + return true; +} + +bool TGA::readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth) { + if (imageType == 2) { + _surface.create(_surface.w, _surface.h, _format); + + if (pixelDepth == 16) { + // Convert from 16bpp to 32bpp + // 16bpp TGA is ARGB1555 + uint16 count = _surface.w * _surface.h; + byte *dst = (byte*)_surface.pixels; + + while (count--) { + uint16 pixel = tga.readUint16LE(); + + *dst++ = (pixel & 0x1F) << 3; + *dst++ = (pixel & 0x3E0) >> 2; + *dst++ = (pixel & 0x7C00) >> 7; + *dst++ = (pixel & 0x8000) ? 0xFF : 0x00; + } + + } else { + // Read it in raw + tga.read(_surface.pixels, _surface.pitch * _surface.w); + } + } else if (imageType == 3) { + _surface.create(_surface.w, _surface.h, _surface.format); + + byte *data = (byte*)_surface.pixels; + uint32 count = _surface.w * _surface.h; + + while (count-- > 0) { + byte g = tga.readByte(); + + memset(data, g, 3); + data[3] = 0xFF; + + data += 4; + } + + } + return true; +} + +} // End of namespace Graphics diff --git a/engines/wintermute/graphics/tga.h b/engines/wintermute/graphics/tga.h new file mode 100644 index 0000000000..727d10c1a3 --- /dev/null +++ b/engines/wintermute/graphics/tga.h @@ -0,0 +1,57 @@ +/* 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. + */ + +/* Based on code from eos https://github.com/DrMcCoy/xoreos/ + * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 + */ + +#ifndef WINTERMUTE_GRAPHICS_IMAGES_TGA_H +#define WINTERMUTE_GRAPHICS_IMAGES_TGA_H + +#include "graphics/surface.h" +#include "graphics/decoders/image_decoder.h" + +namespace Common { + class SeekableReadStream; +} + +namespace WinterMute { + +/** TarGa image. */ +class TGA : public Graphics::ImageDecoder { +public: + TGA(); + virtual ~TGA(); + virtual void destroy(); + virtual const Graphics::Surface *getSurface() const { return &_surface; }; + virtual bool loadStream(Common::SeekableReadStream &stream); +private: + Graphics::PixelFormat _format; + bool _hasAlpha; + Graphics::Surface _surface; + // Loading helpers + bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth); + bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth); +}; + +} // End of namespace Graphics + +#endif // GRAPHICS_IMAGES_TGA_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index b5ad3e9921..6faab5d506 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ scriptables/SXStore.o \ scriptables/SXString.o \ graphics/transparentSurface.o \ + graphics/tga.o \ AdActor.o \ AdActorDir.o \ AdEntity.o \ -- cgit v1.2.3 From bfcffbea601f03d44344ff4cccb2466ca2f648f2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 00:47:30 +0200 Subject: WINTERMUTE: Fix Linux-build --- engines/wintermute/AdInventory.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 3 ++- engines/wintermute/wintermute.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp index 7fcd955560..2c7c086a73 100644 --- a/engines/wintermute/AdInventory.cpp +++ b/engines/wintermute/AdInventory.cpp @@ -27,7 +27,7 @@ */ #include "AdInventory.h" -#include "ADGame.h" +#include "AdGame.h" #include "AdItem.h" #include "PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 2446cb210f..5ab8ba8932 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -70,7 +70,8 @@ int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { char *IniName = CBUtils::GetFilename(param); // switch to ini's dir - chdir(IniDir); + warning("TODO: Place ini-files somewhere"); +// chdir(IniDir); // set ini name sprintf(param, "./%s", IniName); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index e756f568c6..b7da386054 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,7 +31,7 @@ #include "common/fs.h" #include "engines/util.h" -#include "engines/wintermute/ADGame.h" +#include "engines/wintermute/AdGame.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/PlatformSDL.h" -- cgit v1.2.3 From 0cee40306710b0ddae57e962797fd8d40299558b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 00:51:58 +0200 Subject: WINTERMUTE: Fix a few warnings. --- engines/wintermute/AdActor.cpp | 2 ++ engines/wintermute/AdEntity.cpp | 2 ++ engines/wintermute/AdResponseBox.cpp | 2 ++ engines/wintermute/AdScene.cpp | 4 ++-- engines/wintermute/BTransitionMgr.cpp | 3 ++- engines/wintermute/UIButton.cpp | 2 +- engines/wintermute/UIText.cpp | 2 ++ engines/wintermute/UIWindow.cpp | 2 ++ engines/wintermute/graphics/transparentSurface.cpp | 1 - engines/wintermute/scriptables/ScEngine.cpp | 2 +- engines/wintermute/scriptables/ScEngine.h | 4 ++-- 11 files changed, 18 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp index 328ab31874..3778fbaa5f 100644 --- a/engines/wintermute/AdActor.cpp +++ b/engines/wintermute/AdActor.cpp @@ -742,6 +742,8 @@ HRESULT CAdActor::Update() { } } break; + default: + error("AdActor::Update - Unhandled enum"); } diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp index a472107c90..b00b0bd923 100644 --- a/engines/wintermute/AdEntity.cpp +++ b/engines/wintermute/AdEntity.cpp @@ -577,6 +577,8 @@ HRESULT CAdEntity::Update() { } } break; + default: + error("AdEntity::Update - Unhandled enum"); } diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp index 603915396b..895ecd9bef 100644 --- a/engines/wintermute/AdResponseBox.cpp +++ b/engines/wintermute/AdResponseBox.cpp @@ -502,6 +502,8 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { ClearResponses(); } else return CBObject::Listen(param1, param2); break; + default: + error("AdResponseBox::Listen - Unhandled enum"); } return S_OK; diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp index 904bc87a13..c5e3d63db0 100644 --- a/engines/wintermute/AdScene.cpp +++ b/engines/wintermute/AdScene.cpp @@ -944,8 +944,8 @@ HRESULT CAdScene::TraverseNodes(bool Update) { Game->_renderer->Setup2D(); // for each layer - int MainOffsetX = 0; - int MainOffsetY = 0; + /* int MainOffsetX = 0; */ + /* int MainOffsetY = 0; */ for (j = 0; j < _layers.GetSize(); j++) { if (!_layers[j]->_active) continue; diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp index c5c421250a..177c10a980 100644 --- a/engines/wintermute/BTransitionMgr.cpp +++ b/engines/wintermute/BTransitionMgr.cpp @@ -114,7 +114,8 @@ HRESULT CBTransitionMgr::Update() { if (time > FADE_DURATION) _state = TRANS_MGR_READY; } break; - + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); } if (IsReady()) { diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index e2c13e80ba..70b2825027 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -588,7 +588,7 @@ HRESULT CUIButton::Display(int OffsetX, int OffsetY) { _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !Game->_mouseLeftDown) || - _oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100) Press(); + (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) Press(); if (_disable) { diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 3fcda74d1c..194bff2390 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -342,6 +342,8 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { case VAL_CENTER: Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); break; + default: + error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); } Buffer->PutTextIndent(Indent + 2, "\n"); diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index 51d3ff0f2b..89980d8497 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -609,6 +609,8 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { case TAL_CENTER: Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); break; + default: + error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } if (!CBPlatform::IsRectEmpty(&_titleRect)) { diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index c8ac9f1a2c..1f13e15c55 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -152,7 +152,6 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p int bShiftTarget = target.format.bShift; int gShiftTarget = target.format.gShift; int rShiftTarget = target.format.rShift; - int aShiftTarget = target.format.aShift; for (int i = 0; i < img->h; i++) { out = outo; diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 67e9f9eef0..bb65b438de 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -777,7 +777,7 @@ HRESULT CScEngine::LoadBreakpoints() { int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= Count; i++) { - uint32 BufSize = 512; + /* uint32 BufSize = 512; */ sprintf(Key, "Breakpoint%d", i); AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 5ba93d6d0e..ab1504e899 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -42,8 +42,8 @@ typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSi typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); -typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); -typedef int (*DLL_DEFINE_VARIABLE)(char *Name); +typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); /* Was non-const, changed to silence warnings */ +typedef int (*DLL_DEFINE_VARIABLE)(const char *Name); /* Was non-const, changed to silence warnings */ typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); -- cgit v1.2.3 From 2f02bec21fcbffc18964443c2f59a59ebe50f724 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 02:34:32 +0200 Subject: WINTERMUTE: Add in, and stub the VideoPlayer-files --- engines/wintermute/BGame.cpp | 74 ++- engines/wintermute/BGame.h | 3 +- engines/wintermute/VidPlayer.cpp | 467 ++++++++++++++++ engines/wintermute/VidPlayer.h | 93 ++++ engines/wintermute/VidTheoraPlayer.cpp | 957 +++++++++++++++++++++++++++++++++ engines/wintermute/VidTheoraPlayer.h | 175 ++++++ engines/wintermute/module.mk | 4 + 7 files changed, 1770 insertions(+), 3 deletions(-) create mode 100644 engines/wintermute/VidPlayer.cpp create mode 100644 engines/wintermute/VidPlayer.h create mode 100644 engines/wintermute/VidTheoraPlayer.cpp create mode 100644 engines/wintermute/VidTheoraPlayer.h (limited to 'engines') diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp index 6758d2e71e..59d8f2b4fe 100644 --- a/engines/wintermute/BGame.cpp +++ b/engines/wintermute/BGame.cpp @@ -1373,9 +1373,43 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayVideo ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayVideo") == 0) { - Stack->CorrectParams(0); +/* Stack->CorrectParams(0); Stack->PushBool(false); + return S_OK; + // TODO: ADDVIDEO + */ + + Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + Stack->CorrectParams(6); + const char* Filename = Stack->Pop()->GetString(); + warning("PlayVideo: %s - not implemented yet", Filename); + CScValue* valType = Stack->Pop(); + int Type; + if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->GetInt(); + + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + bool FreezeMusic = Stack->Pop()->GetBool(true); + + CScValue* valSub = Stack->Pop(); + const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); + + if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + + /*if(SUCCEEDED(Game->m_VideoPlayer->Initialize(Filename, SubtitleFile))) + { + if(SUCCEEDED(Game->m_VideoPlayer->Play((TVideoPlayback)Type, X, Y, FreezeMusic))) + { + Stack->PushBool(true); + Script->Sleep(0); + } + else Stack->PushBool(false); + } + else */Stack->PushBool(false); + return S_OK; } @@ -1383,9 +1417,45 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { - Stack->CorrectParams(0); + /* Stack->CorrectParams(0); Stack->PushBool(false); + return S_OK; + // TODO: ADDVIDEO + */ + Stack->CorrectParams(7); + const char* Filename = Stack->Pop()->GetString(); + warning("PlayTheora: %s - not implemented yet", Filename); + CScValue* valType = Stack->Pop(); + int Type; + if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->GetInt(); + + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + bool FreezeMusic = Stack->Pop()->GetBool(true); + bool DropFrames = Stack->Pop()->GetBool(true); + + CScValue* valSub = Stack->Pop(); + const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); + + + if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + + /*SAFE_DELETE(m_TheoraPlayer); + m_TheoraPlayer = new CVidTheoraPlayer(this); + if(m_TheoraPlayer && SUCCEEDED(m_TheoraPlayer->Initialize(Filename, SubtitleFile))) + { + m_TheoraPlayer->m_DontDropFrames = !DropFrames; + if(SUCCEEDED(m_TheoraPlayer->Play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) + { + Stack->PushBool(true); + Script->Sleep(0); + } + else Stack->PushBool(false); + } + else */Stack->PushBool(false); + return S_OK; } diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h index 8b0797825d..3a7e165b2c 100644 --- a/engines/wintermute/BGame.h +++ b/engines/wintermute/BGame.h @@ -263,7 +263,8 @@ public: HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); - +/* CVidPlayer* _videoPlayer; + CVidTheoraPlayer* _theoraPlayer;*/ bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; diff --git a/engines/wintermute/VidPlayer.cpp b/engines/wintermute/VidPlayer.cpp new file mode 100644 index 0000000000..40d953f67b --- /dev/null +++ b/engines/wintermute/VidPlayer.cpp @@ -0,0 +1,467 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + +#include "dcgf.h" +#include "VidPlayer.h" + +//#pragma comment(lib, "vfw32.lib") + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::SetDefaults() { + _playing = false; + +/* _aviFile = NULL; + + _audioStream = NULL; + _audioFormat = NULL; + + _videoStream = NULL; + _videoFormat = NULL; + _videoPGF = NULL;*/ + _videoEndTime = 0; + + //_sound = NULL; + _soundAvailable = false; + + //_vidRenderer = NULL; + + _startTime = 0; + _totalVideoTime = 0; + + //_lastSample = -1; + + //_targetFormat = NULL; + + _playPosX = _playPosY = 0; + _playZoom = 0.0f; + + _filename = NULL; + + _slowRendering = false; + + _currentSubtitle = 0; + _showSubtitle = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::~CVidPlayer() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Cleanup() { +#if 0 + if (_sound) _sound->Stop(); + if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); + _videoPGF = NULL; + + _playing = false; + + + if (_aviFile) AVIFileRelease(m_AviFile); + + if (_audioStream) AVIStreamRelease(m_AudioStream); + if (_videoStream) AVIStreamRelease(m_VideoStream); + + if (_audioFormat) delete [](byte *)m_AudioFormat; + if (_videoFormat) delete [](byte *)m_VideoFormat; + if (_targetFormat) delete [](byte *)m_TargetFormat; + + SAFE_DELETE(_sound); + SAFE_DELETE(_vidRenderer); + + SAFE_DELETE_ARRAY(_filename); + + for (int i = 0; i < _subtitles.GetSize(); i++) delete _subtitles[i]; + _subtitles.RemoveAll(); + + return SetDefaults(); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Initialize(char *inFilename, char *SubtitleFile) { +#if 0 + Cleanup(); + + char Filename[MAX_PATH]; + Game->_fileManager->GetFullPath(inFilename, Filename); + + // open file + if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { + Game->LOG(0, "Error opening AVI file '%s'", Filename); + return E_FAIL; + } + + // get video stream + if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { + Game->LOG(0, "Error finding video stream in AVI file '%s'", Filename); + return E_FAIL; + } + _totalVideoTime = AVIStreamEndTime(_videoStream); + + // get audio stream + if (Game->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + _soundAvailable = true; + else + _soundAvailable = false; + + + LONG Size; + + // get video format + if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { + Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", Filename); + return E_FAIL; + } + _videoFormat = (LPBITMAPINFO)new BYTE[Size]; + AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); + + // initialize optimal target format + m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; + memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); + memcpy(m_TargetFormat, m_VideoFormat, Size); + m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); + + m_TargetFormat->bV4BitCount = 24; + m_TargetFormat->bV4V4Compression = BI_RGB; + + if (Game->m_UseD3D) + m_VidRenderer = new CVidRendererD3D(Game); + else + m_VidRenderer = new CVidRendererDD(Game); + + if (!m_VidRenderer || FAILED(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { + Game->LOG(0, "Error initializing video renderer for AVI file '%s'", Filename); + SAFE_DELETE(m_VidRenderer); + return E_FAIL; + } + + + // create sound buffer + HRESULT res; + + if (_soundAvailable) { + _sound = new CBSoundAVI(Game); + if (FAILED(res = _sound->InitializeBuffer(_audioStream))) { + SAFE_DELETE(_sound); + _soundAvailable = false; + Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", Filename); + } + } + + if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Update() { +#if 0 + if (!m_Playing) return S_OK; + + HRESULT res; + + if (_soundAvailable && m_Sound) { + res = _sound->Update(); + if (FAILED(res)) return res; + } + + + DWORD CurrentTime; // current playing time (in ms) + /* + if(m_SoundAvailable && m_Sound){ + CurrentTime = m_Sound->GetPosition(); // in samples + CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); + + if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; + } + else + CurrentTime = timeGetTime() - m_StartTime; + */ + CurrentTime = timeGetTime() - _startTime; + + if (CurrentTime >= _totalVideoTime) { + Stop(); + return S_OK; + } + + + // get and render frame + DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); + if (sample != _lastSample) { + _lastSample = sample; + + // process subtitles + _showSubtitle = false; + while (_currentSubtitle < _subtitles.GetSize()) { + int End = _subtitles[_currentSubtitle]->m_EndFrame; + + bool NextFrameOK = (_currentSubtitle < _subtitles.GetSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); + + if (sample > End) { + if (NextFrameOK) { + _currentSubtitle++; + } else { + _showSubtitle = (End == 0); + break; + } + } else { + _showSubtitle = true; + break; + } + } + + + // render frame + LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); + if (FrameData) { + if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); + else return _vidRenderer->ProcessFrame(FrameData); + } else return E_FAIL; + } else return S_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Display() { +#if 0 + if (!m_Playing) return S_OK; + + HRESULT res; + if (_vidRenderer) res = _vidRenderer->Display(m_PlayPosX, m_PlayPosY, m_PlayZoom); + else res = E_FAIL; + + // display subtitle + if (m_ShowSubtitle) { + CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); + font->DrawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); + } + + return res; +#endif +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +#if 0 + if (!_videoStream || !_vidRenderer) return E_FAIL; + + switch (Type) { + case VID_PLAY_POS: + _playZoom = 100.0f; + _playPosX = X; + _playPosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float ZoomY = (float)((float)Game->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + _playZoom = min(ZoomX, ZoomY); + _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; + _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; + _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; + break; + } + + _targetFormat->bV4BitCount = 24; + _targetFormat->bV4V4Compression = BI_RGB; + + + _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); + if (!_videoPGF) { + _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); + if (!_videoPGF) { + Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); + Cleanup(); + return E_FAIL; + } else { + Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); + _slowRendering = true; + } + } else _slowRendering = false; + + // HACK!!! + _slowRendering = true; + + + _currentSubtitle = 0; + + Game->Freeze(FreezeMusic); + + _playing = true; + if (_sound) _sound->Play(); + _startTime = timeGetTime(); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Stop() { +#if 0 + if (!_playing) return S_OK; + + Cleanup(); + + Game->Unfreeze(); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::IsPlaying() { + return _playing; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::LoadSubtitles(char *Filename, char *SubtitleFile) { +#if 0 + if (!Filename) return S_OK; + + char NewFile[MAX_PATH]; + char drive[_MAX_DRIVE]; + char dir[_MAX_DIR]; + char fname[_MAX_FNAME]; + + if (SubtitleFile) { + strcpy(NewFile, SubtitleFile); + } else { + _splitpath(Filename, drive, dir, fname, NULL); + _makepath(NewFile, drive, dir, fname, ".SUB"); + } + + DWORD Size; + BYTE *Buffer = Game->m_FileManager->ReadWholeFile(NewFile, &Size, false); + if (Buffer == NULL) return S_OK; // no subtitles + + + LONG Start, End; + bool InToken; + char *TokenStart; + int TokenLength; + int TokenPos; + int TextLength; + + int Pos = 0; + int LineLength = 0; + while (Pos < Size) { + Start = End = -1; + InToken = false; + TokenPos = -1; + TextLength = 0; + + LineLength = 0; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *Text = new char[RealLength + 1]; + char *line = (char *)&Buffer[Pos]; + + for (int i = 0; i < RealLength; i++) { + if (line[i] == '{') { + if (!InToken) { + InToken = true; + TokenStart = line + i + 1; + TokenLength = 0; + TokenPos++; + } else TokenLength++; + } else if (line[i] == '}') { + if (InToken) { + InToken = false; + char *Token = new char[TokenLength + 1]; + strncpy(Token, TokenStart, TokenLength); + Token[TokenLength] = '\0'; + if (TokenPos == 0) Start = atoi(Token); + else if (TokenPos == 1) End = atoi(Token); + + delete [] Token; + } else { + Text[TextLength] = line[i]; + TextLength++; + } + } else { + if (InToken) { + TokenLength++; + } else { + Text[TextLength] = line[i]; + if (Text[TextLength] == '|') Text[TextLength] = '\n'; + TextLength++; + } + } + } + Text[TextLength] = '\0'; + + if (Start != -1 && TextLength > 0) _subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + + delete [] Text; + + Pos += LineLength + 1; + } + + delete [] Buffer; +#endif + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/VidPlayer.h b/engines/wintermute/VidPlayer.h new file mode 100644 index 0000000000..e38baae413 --- /dev/null +++ b/engines/wintermute/VidPlayer.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDPLAYER_H +#define WINTERMUTE_VIDPLAYER_H + +#include "dctypes.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "engines/wintermute/BBase.h" + +#define MAX_AUDIO_STREAMS 5 +#define MAX_VIDEO_STREAMS 5 + + +namespace WinterMute { + +class CVidPlayer : public CBBase { +public: + bool _showSubtitle; + int _currentSubtitle; + HRESULT LoadSubtitles(char *Filename, char *SubtitleFile); + bool _slowRendering; + bool IsPlaying(); + char *_filename; + HRESULT Stop(); + HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + uint32 _totalVideoTime; + uint32 _startTime; + //CVidRenderer *_vidRenderer; + //CBSoundAVI *_sound; + bool _soundAvailable; + HRESULT SetDefaults(); + bool _playing; + HRESULT Display(); + HRESULT Update(); + HRESULT Initialize(char *inFilename, char *SubtitleFile = NULL); + HRESULT Cleanup(); + CVidPlayer(CBGame *inGame); + virtual ~CVidPlayer(); + + /*PAVIFILE _aviFile; + + LONG _lastSample; + + PAVISTREAM _audioStream; + PAVISTREAM _videoStream; + + LPWAVEFORMAT _audioFormat; + + LPBITMAPINFO _videoFormat; + PGETFRAME _videoPGF;*/ + uint32 _videoEndTime; + + int _playPosX; + int _playPosY; + float _playZoom; + +/* LPBITMAPV4HEADER _targetFormat; + + CBArray _subtitles;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/VidTheoraPlayer.cpp b/engines/wintermute/VidTheoraPlayer.cpp new file mode 100644 index 0000000000..f27a27b724 --- /dev/null +++ b/engines/wintermute/VidTheoraPlayer.cpp @@ -0,0 +1,957 @@ +// Copyright 2009, 2010 Jan Nedoma +// +// This file is part of Wintermute Engine. +// +// Wintermute Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Wintermute Engine 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Wintermute Engine. If not, see . +////////////////////////////////////////////////////////////////////////// + + +#include "dcgf.h" +#include "engines/wintermute/vidtheoraplayer.h" + +//#pragma comment(lib, "libtheora.lib") + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::SetDefaults() { +#if 0 + _file = NULL; + _filename = NULL; + _startTime = 0; + _looping = false; + _sound = NULL; + _audiobufGranulepos = 0; + _freezeGame = false; + _currentTime = 0; + + _state = THEORA_STATE_NONE; + + _videoFrameReady = false; + _audioFrameReady = false; + _videobufTime = 0; + + _audioBuf = NULL; + _audioBufFill = 0; + _audioBufSize = 0; + _playbackStarted = false; + _dontDropFrames = false; + + _texture = NULL; + _alphaImage = NULL; + _alphaFilename = NULL; + + _frameRendered = false; + + +/* memset(&m_OggSyncState, 0, sizeof(ogg_sync_state)); + memset(&m_OggPage, 0, sizeof(ogg_page)); + memset(&m_VorbisStreamState, 0 , sizeof(ogg_stream_state)); + memset(&m_TheoraStreamState, 0 , sizeof(ogg_stream_state)); + + memset(&m_TheoraInfo, 0, sizeof(theora_info)); + memset(&m_TheoraComment, 0, sizeof(theora_comment)); + memset(&m_TheoraState, 0, sizeof(theora_state)); + + memset(&m_VorbisInfo, 0, sizeof(vorbis_info)); + memset(&m_VorbisDSPState, 0, sizeof(vorbis_dsp_state)); + memset(&m_VorbisBlock, 0, sizeof(vorbis_block)); + memset(&m_VorbisComment, 0, sizeof(vorbis_comment));*/ + + _vorbisStreams = _theoraStreams = 0; + + GenLookupTables(); + + _seekingKeyframe = false; + _timeOffset = 0.0f; + + _posX = _posY = 0; + _playbackType = VID_PLAY_CENTER; + _playZoom = 0.0f; + + _subtitler = NULL; + + _savedState = THEORA_STATE_NONE; + _savedPos = 0; + _volume = 100; +#endif +} + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::~CVidTheoraPlayer(void) { + Cleanup(); + + SAFE_DELETE_ARRAY(_filename); + SAFE_DELETE_ARRAY(_alphaFilename); + SAFE_DELETE(_texture); + SAFE_DELETE(_alphaImage); +// SAFE_DELETE(_subtitler); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::Cleanup() { +#if 0 + if (_vorbisStreams) { + ogg_stream_clear(&m_VorbisStreamState); + vorbis_block_clear(&m_VorbisBlock); + vorbis_dsp_clear(&m_VorbisDSPState); + vorbis_comment_clear(&m_VorbisComment); + vorbis_info_clear(&m_VorbisInfo); + + _vorbisStreams = 0; + } + if (m_TheoraStreams) { + ogg_stream_clear(&m_TheoraStreamState); + theora_clear(&m_TheoraState); + theora_comment_clear(&m_TheoraComment); + theora_info_clear(&m_TheoraInfo); + + m_TheoraStreams = 0; + } + ogg_sync_clear(&m_OggSyncState); + + + if (m_File) Game->m_FileManager->CloseFile(m_File); + m_File = NULL; + + if (m_Sound) { + Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + } + + + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufFill = 0; + m_AudioBufSize = 0; +#endif +} + +////////////////////////////////////////////////////////////////////////// +/*int CVidTheoraPlayer::BufferData(ogg_sync_state *OggSyncState) { + if (!_file) return 0; + + DWORD Size = 4096; + if (m_File->GetSize() - m_File->GetPos() < Size) Size = m_File->GetSize() - m_File->GetPos(); + + char *Buffer = ogg_sync_buffer(OggSyncState, Size); + m_File->Read(Buffer, Size); + ogg_sync_wrote(OggSyncState, Size); + + return Size; +}*/ + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { +#if 0 + Cleanup(); + + _file = Game->_fileManager->OpenFile(Filename); + if (!_file) return E_FAIL; + + if (Filename != _filename) CBUtils::SetString(&_filename, Filename); + + // start up Ogg stream synchronization layer + ogg_sync_init(&m_OggSyncState); + + // init supporting Vorbis structures needed in header parsing + vorbis_comment_init(&m_VorbisComment); + vorbis_info_init(&m_VorbisInfo); + + // init supporting Theora structures needed in header parsing + theora_comment_init(&m_TheoraComment); + theora_info_init(&m_TheoraInfo); + + + + // Ogg file open; parse the headers + // Only interested in Vorbis/Theora streams + ogg_packet TempOggPacket; + bool IsDone = false; + while (!IsDone) { + int BytesRead = BufferData(&m_OggSyncState); + if (BytesRead == 0) break; + + while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + ogg_stream_state OggStateTest; + + // is this a mandated initial header? If not, stop parsing + if (!ogg_page_bos(&m_OggPage)) { + // don't leak the page; get it into the appropriate stream + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + + IsDone = true; + break; + } + + ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); + ogg_stream_pagein(&OggStateTest, &m_OggPage); + ogg_stream_packetout(&OggStateTest, &TempOggPacket); + + // identify the codec: try theora + if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { + // it is theora + memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); + m_TheoraStreams = 1; + } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { + // it is vorbis + memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); + m_VorbisStreams = 1; + } else { + // whatever it is, we don't care about it + ogg_stream_clear(&OggStateTest); + } + } + } + + // we're expecting more header packets + while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { + int Ret; + + // look for further theora headers + while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { + if (Ret < 0) { + Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return E_FAIL; + } + if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { + Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return E_FAIL; + } + m_TheoraStreams++; + if (m_TheoraStreams == 3) break; + } + + /* look for more vorbis header packets */ + while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { + if (Ret < 0) { + Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return E_FAIL; + } + if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { + Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return E_FAIL; + } + m_VorbisStreams++; + if (m_VorbisStreams == 3) break; + } + + // The header pages/packets will arrive before anything else we + // care about, or the stream is not obeying spec + if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + } else { + int Ret = BufferData(&m_OggSyncState); // someone needs more data + if (Ret == 0) { + Game->LOG(0, "End of file while searching for codec headers"); + return E_FAIL; + } + } + } + + + + // and now we have it all. initialize decoders + if (m_TheoraStreams) { + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + } else { + // tear down the partial theora setup + theora_info_clear(&m_TheoraInfo); + theora_comment_clear(&m_TheoraComment); + } + + if (m_VorbisStreams) { + vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); + vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); + + } else { + // tear down the partial vorbis setup + vorbis_info_clear(&m_VorbisInfo); + vorbis_comment_clear(&m_VorbisComment); + } + + HRESULT Res = S_OK; + + // create sound buffer + if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { + m_Sound = new CBSoundTheora(Game); + Game->m_SoundMgr->AddSound(m_Sound); + if (FAILED(Res = m_Sound->InitializeBuffer(this))) { + Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", Filename); + } else { + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufSize = m_Sound->m_StreamBlockSize; + m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; + } + } + + // create texture + if (m_TheoraStreams && !m_Texture) { + if (Game->m_UseD3D) + m_Texture = new CBSurfaceD3D(Game); + else + m_Texture = new CBSurfaceDD(Game); + + if (!m_Texture || FAILED(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { + SAFE_DELETE(m_Texture); + } + } + + + if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(Filename, SubtitleFile); + + return Res; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::ResetStream() { +#if 0 + if (_sound) _sound->Stop(); + + m_TimeOffset = 0.0f; + Initialize(m_Filename); + Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { +#if 0 + if (ForceZoom < 0.0f) ForceZoom = 100.0f; + if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); + else m_Volume = Volume; + + m_FreezeGame = FreezeGame; + if (!m_PlaybackStarted && m_FreezeGame) Game->Freeze(FreezeMusic); + + m_PlaybackStarted = false; + m_State = THEORA_STATE_PLAYING; + + m_Looping = Looping; + m_PlaybackType = Type; + + float Width, Height; + if (m_TheoraStreams) { + Width = (float)m_TheoraInfo.width; + Height = (float)m_TheoraInfo.height; + } else { + Width = (float)Game->m_Renderer->m_Width; + Height = (float)Game->m_Renderer->m_Height; + } + + switch (Type) { + case VID_PLAY_POS: + m_PlayZoom = ForceZoom; + m_PosX = X; + m_PosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->m_Renderer->m_Width / Width * 100); + float ZoomY = (float)((float)Game->m_Renderer->m_Height / Height * 100); + m_PlayZoom = min(ZoomX, ZoomY); + m_PosX = (Game->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; + m_PosY = (Game->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + m_PlayZoom = 100.0f; + m_PosX = (Game->m_Renderer->m_Width - Width) / 2; + m_PosY = (Game->m_Renderer->m_Height - Height) / 2; + break; + } + + + if (StartTime) SeekToTime(StartTime); + + Update(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Stop() { +#if 0 + if (m_Sound) m_Sound->Stop(); + m_State = THEORA_STATE_FINISHED; + if (m_FreezeGame) Game->Unfreeze(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Update() { +#if 0 + m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; + + if (!IsPlaying()) return S_OK; + + if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return S_OK; + + if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return S_OK; + + int Counter = 0; + while (true) { + if (m_Sound) DecodeVorbis(); + else m_AudioFrameReady = true; + + if (m_Texture) DecodeTheora(); + else m_VideoFrameReady = true; + + if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { + // end playback + if (!m_Looping) { + m_State = THEORA_STATE_FINISHED; + if (m_Sound) m_Sound->Stop(); + if (m_FreezeGame) Game->Unfreeze(); + break; + } else { + ResetStream(); + return S_OK; + } + } + + + if (!m_VideoFrameReady || !m_AudioFrameReady) { + Counter++; + if (StreamInData() == 0) break; + } else break; + } + + + // If playback has begun, top audio buffer off immediately. + //if(m_Sound) WriteAudio(); + + // are we at or past time for this video frame? + if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { + //Game->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); + if (m_Texture) WriteVideo(); + m_VideoFrameReady = false; + + if (m_SavedState == THEORA_STATE_PAUSED) { + Pause(); + m_SavedState = THEORA_STATE_NONE; + } + } + + // if our buffers either don't exist or are ready to go, + // we can begin playback + bool StartNow = false; + if ((!m_TheoraStreams || m_VideoFrameReady) && + (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; + // same if we've run out of input + if (m_File->IsEOF()) StartNow = true; + + + if (m_Sound) WriteAudio(); + + + if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { + //m_StartTime = timeGetTime(); + m_StartTime = m_CurrentTime; + if (m_Sound) { + m_Sound->SetPrivateVolume(m_Volume); + m_Sound->Play(); + } + m_PlaybackStarted = true; + } + + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Update(GetMovieFrame()); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +/*int CVidTheoraPlayer::StreamInData() { +#if 0 + // no data yet for somebody. Grab another page + int BytesRead = BufferData(&m_OggSyncState); + while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + } + return BytesRead; +#endif +}*/ + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::DecodeVorbis() { +#if 0 + if (!m_Sound) return; + + while (m_VorbisStreams && !m_AudioFrameReady) { + int ret; + float **pcm; + + // if there's pending, decoded audio, grab it + if ((ret = vorbis_synthesis_pcmout(&m_VorbisDSPState, &pcm)) > 0 && !m_SeekingKeyframe) { + int count = m_AudioBufFill / 2; + int maxsamples = (m_AudioBufSize - m_AudioBufFill) / 2 / m_VorbisInfo.channels; + + int i; + for (i = 0; i < ret && i < maxsamples; i++) + for (int j = 0; j < m_VorbisInfo.channels; j++) { + int val = (int)(pcm[j][i] * 32767.f); + if (val > 32767) val = 32767; + if (val < -32768) val = -32768; + + m_AudioBuf[count++] = val; + } + vorbis_synthesis_read(&m_VorbisDSPState, i); + m_AudioBufFill += i * m_VorbisInfo.channels * 2; + if (m_AudioBufFill == m_AudioBufSize) m_AudioFrameReady = true; + if (m_VorbisDSPState.granulepos >= 0) + m_AudiobufGranulepos = m_VorbisDSPState.granulepos - ret + i; + else + m_AudiobufGranulepos += i; + } else { + ogg_packet opVorbis; + + //no pending audio; is there a pending packet to decode? + if (ogg_stream_packetout(&m_VorbisStreamState, &opVorbis) > 0) { + //test for success! + if (vorbis_synthesis(&m_VorbisBlock, &opVorbis) == 0) + vorbis_synthesis_blockin(&m_VorbisDSPState, &m_VorbisBlock); + } else { //we need more data; break out to suck in another page + break; + } + } + } // while +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::DecodeTheora() { +#if 0 + ogg_packet opTheora; + + while (m_TheoraStreams && !m_VideoFrameReady) { + // theora is one in, one out... + if (ogg_stream_packetout(&m_TheoraStreamState, &opTheora) > 0) { + theora_decode_packetin(&m_TheoraState, &opTheora); + m_VideobufTime = theora_granule_time(&m_TheoraState, m_TheoraState.granulepos); + + if (m_SeekingKeyframe) { + if (!theora_packet_iskeyframe(&opTheora)) continue; + else { + m_SeekingKeyframe = false; + m_TimeOffset = m_VideobufTime; + } + } + + if (m_VideobufTime >= GetMovieTime() || m_DontDropFrames) m_VideoFrameReady = true; + } else { + break; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +float CVidTheoraPlayer::GetMovieTime() { +#if 0 + if (!m_PlaybackStarted) return 0.0f; + else if (m_Sound) return (float)(m_Sound->GetPosition()) / 1000.0f + m_TimeOffset; + else return (float)(m_CurrentTime - m_StartTime) / 1000.0f + m_TimeOffset; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +int CVidTheoraPlayer::GetMovieFrame() { +#if 0 + if (!m_TheoraStreams) return 0; + float Time = GetMovieTime(); + + return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::WriteAudio() { +#if 0 + if (m_AudioFrameReady) { + if (m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize)) { + m_AudioBufFill = 0; + m_AudioFrameReady = false; + } + } else if (m_File->IsEOF()) { + memset(m_AudioBuf, 0, m_AudioBufSize); + m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::WriteVideo() { +#if 0 + if (!m_Texture) return E_FAIL; + + yuv_buffer yuv; + theora_decode_YUVout(&m_TheoraState, &yuv); + + m_Texture->StartPixelOp(); + RenderFrame(m_Texture, &yuv); + m_Texture->EndPixelOp(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Display(uint32 Alpha) { + + RECT rc; + HRESULT Res; +#if 0 + if (m_Texture) { + SetRect(&rc, 0, 0, m_Texture->GetWidth(), m_Texture->GetHeight()); + if (m_PlayZoom == 100.0f) Res = m_Texture->DisplayTrans(m_PosX, m_PosY, rc, Alpha); + else Res = m_Texture->DisplayTransZoom(m_PosX, m_PosY, rc, m_PlayZoom, m_PlayZoom, Alpha); + } else Res = E_FAIL; + + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); +#endif + return Res; +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::GenLookupTables() { + //used to bring the table into the high side (scale up) so we + //can maintain high precision and not use floats (FIXED POINT) + int scale = 1L << 13; + int temp; + + for (unsigned int i = 0; i < 256; i++) { + temp = i - 128; + + _yTable[i] = (unsigned int)((1.164 * scale + 0.5) * (i - 16)); //Calc Y component + + _rVTable[i] = (unsigned int)((1.596 * scale + 0.5) * temp); //Calc R component + + _gUTable[i] = (unsigned int)((0.391 * scale + 0.5) * temp); //Calc G u & v components + _gVTable[i] = (unsigned int)((0.813 * scale + 0.5) * temp); + + _bUTable[i] = (unsigned int)((2.018 * scale + 0.5) * temp); //Calc B component + } +} + +#define CLIP_RGB_COLOR( rgb_color_test ) max( min(rgb_color_test, 255), 0 ) +////////////////////////////////////////////////////////////////////////// +#if 0 +HRESULT CVidTheoraPlayer::RenderFrame(CBSurface *Texture, yuv_buffer *yuv) { + //Convert 4:2:0 YUV YCrCb to an RGB24 Bitmap + //convenient pointers + int TargetX1 = 0; + int TargetX2 = 1; + int TargetY1 = 0; + int TargetY2 = 1; + + unsigned char *ySrc = (unsigned char *)yuv->y; + unsigned char *uSrc = (unsigned char *)yuv->u; + unsigned char *vSrc = (unsigned char *)yuv->v; + unsigned char *ySrc2 = ySrc + yuv->y_stride; + + //Calculate buffer offset + int yOff = (yuv->y_stride * 2) - yuv->y_width; + + + //Check if upside down, if so, reverse buffers and offsets + if (yuv->y_height < 0) { + yuv->y_height = -yuv->y_height; + ySrc += (yuv->y_height - 1) * yuv->y_stride; + + uSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; + vSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; + + ySrc2 = ySrc - yuv->y_stride; + yOff = -yuv->y_width - (yuv->y_stride * 2); + + yuv->uv_stride = -yuv->uv_stride; + } + + //Cut width and height in half (uv field is only half y field) + yuv->y_height = yuv->y_height >> 1; + yuv->y_width = yuv->y_width >> 1; + + //Convientient temp vars + signed int r, g, b, u, v, bU, gUV, rV, rgbY; + int x; + + //Loop does four blocks per iteration (2 rows, 2 pixels at a time) + for (int y = yuv->y_height; y > 0; --y) { + for (x = 0; x < yuv->y_width; ++x) { + //Get uv pointers for row + u = uSrc[x]; + v = vSrc[x]; + + //get corresponding lookup values + rgbY = m_YTable[*ySrc]; + rV = m_RVTable[v]; + gUV = m_GUTable[u] + m_GVTable[v]; + bU = m_BUTable[u]; + ++ySrc; + + //scale down - brings are values back into the 8 bits of a byte + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX1, TargetY1, r, g, b, GetAlphaAt(TargetX1, TargetY1)); + + //And repeat for other pixels (note, y is unique for each + //pixel, while uv are not) + rgbY = m_YTable[*ySrc]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX2, TargetY1, r, g, b, GetAlphaAt(TargetX2, TargetY1)); + ++ySrc; + + rgbY = m_YTable[*ySrc2]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX1, TargetY2, r, g, b, GetAlphaAt(TargetX1, TargetY2)); + ++ySrc2; + + rgbY = m_YTable[*ySrc2]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX2, TargetY2, r, g, b, GetAlphaAt(TargetX2, TargetY2)); + ++ySrc2; + + /* + Texture->PutPixel(TargetX1, TargetY1, 255, 0, 0, GetAlphaAt(TargetX1, TargetY1)); + Texture->PutPixel(TargetX2, TargetY1, 255, 0, 0, GetAlphaAt(TargetX2, TargetY1)); + Texture->PutPixel(TargetX1, TargetY2, 255, 0, 0, GetAlphaAt(TargetX1, TargetY2)); + Texture->PutPixel(TargetX2, TargetY2, 255, 0, 0, GetAlphaAt(TargetX2, TargetY2)); + */ + + + //Advance inner loop offsets + TargetX1 += 2; + TargetX2 += 2; + } // end for x + + //Advance destination pointers by offsets + TargetX1 = 0; + TargetX2 = 1; + TargetY1 += 2; + TargetY2 += 2; + + ySrc += yOff; + ySrc2 += yOff; + uSrc += yuv->uv_stride; + vSrc += yuv->uv_stride; + } //end for y + + m_FrameRendered = true; + + return S_OK; +} +#endif +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::SetAlphaImage(const char *Filename) { +#if 0 + SAFE_DELETE(m_AlphaImage); + m_AlphaImage = new CBImage(Game); + if (!m_AlphaImage || FAILED(m_AlphaImage->LoadFile(Filename))) { + SAFE_DELETE(m_AlphaImage); + SAFE_DELETE_ARRAY(m_AlphaFilename); + return E_FAIL; + } + if (m_AlphaFilename != Filename) CBUtils::SetString(&m_AlphaFilename, Filename); + m_AlphaImage->Convert(IMG_TRUECOLOR); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +byte CVidTheoraPlayer::GetAlphaAt(int X, int Y) { +#if 0 + if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); + else return 0xFF; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +inline int intlog(int num) { + int r = 0; + while (num > 0) { + num = num / 2; + r = r + 1; + } + + return r; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::SeekToTime(uint32 Time) { +#if 0 + if (!m_TheoraStreams) return E_FAIL; + + + float TargetTime = Time / 1000.0f; + + + ogg_page page; + int read = 1; + ogg_int64_t gran; + float movieLength = 0; + DWORD LastPos = 0; + + int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); + + while (!m_File->IsEOF() && read != 0) { + read = BufferData(&m_OggSyncState); + + while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { + int serno = ogg_page_serialno(&page); + //This is theora stream we were searching for + if (m_TheoraStreamState.serialno == serno) { + //Calculate a rough time estimate + gran = ogg_page_granulepos(&page); + if (gran >= 0) { + ogg_int64_t iframe = gran >> keyframe_granule_shift; + ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); + movieLength = (iframe + pframe) * + ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); + + if (movieLength >= TargetTime) { + m_TimeOffset = movieLength; + //m_TimeOffset = TargetTime; + //m_File->Seek(LastPos); + + goto finish; + } + LastPos = m_File->GetPos(); + } + } + } + } + +finish: + ogg_sync_reset(&m_OggSyncState); + + ogg_stream_reset(&m_TheoraStreamState); + ogg_stream_reset(&m_VorbisStreamState); + + theora_clear(&m_TheoraState); + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + vorbis_synthesis_restart(&m_VorbisDSPState); + + m_SeekingKeyframe = true; + + //theora_packet_iskeyframe + +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Pause() { +#if 0 + if (m_State == THEORA_STATE_PLAYING) { + m_State = THEORA_STATE_PAUSED; + if (m_Sound) m_Sound->Pause(); + return S_OK; + } else return E_FAIL; +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Resume() { +#if 0 + if (_state == THEORA_STATE_PAUSED) { + _state = THEORA_STATE_PLAYING; + if (_sound) _sound->Resume(); + return S_OK; + } else return E_FAIL; +#endif +} + +////////////////////////////////////////////////////////////////////////// +/*HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { + //CBBase::Persist(PersistMgr); +#if 0 + if (PersistMgr->m_Saving) { + m_SavedPos = GetMovieTime() * 1000; + m_SavedState = m_State; + } else { + SetDefaults(); + } + + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(m_SavedPos)); + PersistMgr->Transfer(TMEMBER(m_SavedState)); + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_AlphaFilename)); + PersistMgr->Transfer(TMEMBER(m_PosX)); + PersistMgr->Transfer(TMEMBER(m_PosY)); + PersistMgr->Transfer(TMEMBER(m_PlayZoom)); + PersistMgr->Transfer(TMEMBER_INT(m_PlaybackType)); + PersistMgr->Transfer(TMEMBER(m_Looping)); + + if (PersistMgr->CheckVersion(1, 7, 3)) { + PersistMgr->Transfer(TMEMBER(m_Volume)); + } else { + m_Volume = 100; + } +#endif + return S_OK; +} +*/ +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::InitializeSimple() { +#if 0 + if (SUCCEEDED(Initialize(m_Filename))) { + if (m_AlphaFilename) SetAlphaImage(m_AlphaFilename); + Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, m_SavedPos, m_PlayZoom); + } else m_State = THEORA_STATE_FINISHED; +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CVidTheoraPlayer::GetTexture() { + return _texture; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/VidTheoraPlayer.h b/engines/wintermute/VidTheoraPlayer.h new file mode 100644 index 0000000000..6a32c307ad --- /dev/null +++ b/engines/wintermute/VidTheoraPlayer.h @@ -0,0 +1,175 @@ +// Copyright 2009, 2010 Jan Nedoma +// +// This file is part of Wintermute Engine. +// +// Wintermute Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Wintermute Engine 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Wintermute Engine. If not, see . +////////////////////////////////////////////////////////////////////////// + + +#ifndef WINTERMUTE_VIDTHEORAPLAYER_H +#define WINTERMUTE_VIDTHEORAPLAYER_H + +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/BFile.h" +#include "engines/wintermute/BSurface.h" +#include "engines/wintermute/BImage.h" +//#include + +namespace WinterMute { + +class CVidTheoraPlayer : public CBBase { +private: + enum { THEORA_STATE_NONE = 0, THEORA_STATE_PLAYING = 1, THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; +public: + //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); + + CVidTheoraPlayer(CBGame *inGame); + virtual ~CVidTheoraPlayer(void); + + // Vorbis/Theora structs + /*ogg_sync_state m_OggSyncState; + ogg_page m_OggPage; + ogg_stream_state m_VorbisStreamState; + ogg_stream_state m_TheoraStreamState; + + theora_info m_TheoraInfo; + theora_comment m_TheoraComment; + theora_state m_TheoraState; + + vorbis_info m_VorbisInfo; + vorbis_dsp_state m_VorbisDSPState; + vorbis_block m_VorbisBlock; + vorbis_comment m_VorbisComment;*/ + + int _theoraStreams; + int _vorbisStreams; + + //ogg_int64_t m_AudiobufGranulepos; //time position of last sample + + + // external objects + CBFile *_file; + char *_filename; + + //CBSoundTheora *_sound; + //ogg_int16_t *_audioBuf; + int _audioBufSize; + int _audioBufFill; + + CBSurface *_texture; + //CVidSubtitler *_subtitler; + + // control methods + HRESULT Initialize(char *Filename, char *SubtitleFile = NULL); + HRESULT InitializeSimple(); + HRESULT Update(); + HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); + HRESULT Stop(); + HRESULT Display(uint32 Alpha = 0xFFFFFFFF); + //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + + HRESULT Pause(); + HRESULT Resume(); + + bool IsPlaying() { + return _state == THEORA_STATE_PLAYING; + }; + bool IsFinished() { + return _state == THEORA_STATE_FINISHED; + }; + bool IsPaused() { + return _state == THEORA_STATE_PAUSED; + }; + + float GetMovieTime(); + int GetMovieFrame(); + + CBSurface *GetTexture(); + + int _state; + uint32 _startTime; + + int _savedState; + uint32 _savedPos; + + + // alpha related + CBImage *_alphaImage; + char *_alphaFilename; + HRESULT SetAlphaImage(const char *Filename); + __inline byte GetAlphaAt(int X, int Y); + + HRESULT SeekToTime(uint32 Time); + + + void Cleanup(); + HRESULT ResetStream(); + + // video properties + TVideoPlayback m_PlaybackType; + int _posX; + int _posY; + float _playZoom; + int _volume; + + bool _looping; + bool _dontDropFrames; + bool _freezeGame; + uint32 _currentTime; + + +private: + // data streaming + //int BufferData(ogg_sync_state *OggSyncState); + //int StreamInData(); + + + // lookup tables + unsigned int _yTable[256]; + unsigned int _bUTable[256]; + unsigned int _gUTable[256]; + unsigned int _gVTable[256]; + unsigned int _rVTable[256]; + + void GenLookupTables(); + + + // seeking support + bool _seekingKeyframe; + float _timeOffset; + + bool _frameRendered; + + + // decoding + void DecodeVorbis(); + void DecodeTheora(); + + bool _audioFrameReady; + bool _videoFrameReady; + float _videobufTime; + + HRESULT WriteAudio(); + HRESULT WriteVideo(); + + bool _playbackStarted; + + // helpers + void SetDefaults(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 6faab5d506..70acdb5dec 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -92,6 +92,8 @@ MODULE_OBJS := \ crc.o \ detection.o \ FontGlyphCache.o \ + graphics/transparentSurface.o \ + graphics/tga.o \ MathUtil.o \ Matrix4.o \ PathUtil.o \ @@ -116,6 +118,8 @@ MODULE_OBJS := \ UIWindow.o \ utils.o \ Vector2.o \ + VidPlayer.o \ + VidTheoraPlayer.o \ wintermute.o MODULE_DIRS += \ -- cgit v1.2.3 From 79f86732b8dd17264768b32ceefcb79b1ee422b5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 13:51:06 +0200 Subject: WINTERMUTE: Fix Windows build under MSVC2010 --- engines/wintermute/AdActorDir.h | 2 +- engines/wintermute/AdObject.cpp | 2 +- engines/wintermute/BDiskFile.cpp | 3 ++- engines/wintermute/BFileManager.cpp | 12 +++++++----- engines/wintermute/BParser.cpp | 2 +- engines/wintermute/BPkgFile.cpp | 6 +++--- engines/wintermute/BRegion.cpp | 2 +- engines/wintermute/FontGlyphCache.h | 2 +- engines/wintermute/Matrix4.h | 2 +- engines/wintermute/PlatformSDL.cpp | 11 ----------- engines/wintermute/VidPlayer.cpp | 3 +++ engines/wintermute/VidTheoraPlayer.cpp | 6 ++++++ engines/wintermute/detection.cpp | 2 +- engines/wintermute/scriptables/SXStore.cpp | 2 +- engines/wintermute/scriptables/ScScript.cpp | 2 +- engines/wintermute/wintermute.cpp | 2 +- engines/wintermute/wintermute.h | 2 +- engines/wintermute/wme_debugger.h | 2 +- 18 files changed, 33 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/AdActorDir.h b/engines/wintermute/AdActorDir.h index ffb9c1ff7c..5df19f2aeb 100644 --- a/engines/wintermute/AdActorDir.h +++ b/engines/wintermute/AdActorDir.h @@ -43,4 +43,4 @@ public: } // end of namespace WinterMute -#endif // WINTERMUTE_ADACTORDIR_H \ No newline at end of file +#endif // WINTERMUTE_ADACTORDIR_H diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp index 122a4bdbb6..188eb19fc9 100644 --- a/engines/wintermute/AdObject.cpp +++ b/engines/wintermute/AdObject.cpp @@ -873,7 +873,7 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const // set duration by text length if (_sentence->_duration <= 0) {// TODO: Avoid longs. - _sentence->_duration = MAX((unsigned long)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); + _sentence->_duration = MAX((size_t)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); } diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index a2ec38a57e..e559708b5b 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -179,8 +179,9 @@ HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { + // TODO: Should this really need to use uint32? if (_compressed) { - int32 NewPos = 0; + uint32 NewPos = 0; switch (Origin) { case SEEK_TO_BEGIN: diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 21688a5ea9..7ac64e3236 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -427,7 +427,7 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign package->seek(DirOffset, SEEK_SET); } - for (int i = 0; i < hdr.NumDirs; i++) { + for (uint32 i = 0; i < hdr.NumDirs; i++) { CBPackage *pkg = new CBPackage(Game); if (!pkg) return E_FAIL; @@ -447,7 +447,7 @@ HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSign // read file entries uint32 NumFiles = package->readUint32LE(); - for (int j = 0; j < NumFiles; j++) { + for (uint32 j = 0; j < NumFiles; j++) { char *Name; uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; @@ -818,8 +818,10 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { HRESULT CBFileManager::RestoreCurrentDir() { if (!_basePath) return S_OK; else { - if (!chdir(_basePath)) return S_OK; - else return E_FAIL; + /*if (!chdir(_basePath)) return S_OK; + else return E_FAIL;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return S_OK; } } @@ -852,7 +854,7 @@ bool CBFileManager::FindPackageSignature(Common::File *f, uint32 *Offset) { int StartPos = 1024 * 1024; - int BytesRead = StartPos; + uint32 BytesRead = StartPos; while (BytesRead < FileSize - 16) { int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp index 97a191eff1..f672684f73 100644 --- a/engines/wintermute/BParser.cpp +++ b/engines/wintermute/BParser.cpp @@ -89,7 +89,7 @@ long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data if (tokens->id == 0) { char *p = strchr(*buf, '\n'); if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((long int)255, p - *buf)); // TODO, clean + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean } else strcpy(_lastOffender, ""); return PARSERR_TOKENNOTFOUND; diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index 055748b520..dd04fdec03 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -61,7 +61,7 @@ HRESULT CBPkgFile::Open(Common::String Filename) { strcpy(fileName, Filename.c_str()); // correct slashes - for (int i = 0; i < strlen(fileName); i++) { + for (uint32 i = 0; i < strlen(fileName); i++) { if (fileName[i] == '/') fileName[i] = '\\'; } @@ -78,7 +78,7 @@ HRESULT CBPkgFile::Open(Common::String Filename) { if (_compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. - _file = wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); } else { _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); } @@ -128,7 +128,7 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { if (!_fileEntry) return E_FAIL; - int32 NewPos = 0; + uint32 NewPos = 0; switch (Origin) { case SEEK_TO_BEGIN: diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp index f775c61091..37ab7ff35c 100644 --- a/engines/wintermute/BRegion.cpp +++ b/engines/wintermute/BRegion.cpp @@ -506,4 +506,4 @@ HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { return CreateRegion() ? S_OK : E_FAIL; } -} // end of namespace WinterMute \ No newline at end of file +} // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 3092c60a74..a385125d82 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -122,4 +122,4 @@ private: } // end of namespace WinterMute -#endif // WINTERMUTE_FONTGLYPHCACHE_H \ No newline at end of file +#endif // WINTERMUTE_FONTGLYPHCACHE_H diff --git a/engines/wintermute/Matrix4.h b/engines/wintermute/Matrix4.h index 019c429789..da5fd1393a 100644 --- a/engines/wintermute/Matrix4.h +++ b/engines/wintermute/Matrix4.h @@ -56,4 +56,4 @@ public: } // end of namespace WinterMute -#endif // WINTERMUTE_MATRIX4_H \ No newline at end of file +#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 5ab8ba8932..6cc18f5209 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -518,17 +518,6 @@ AnsiString CBPlatform::GetPlatformName() { return AnsiString("ScummVM"); } -////////////////////////////////////////////////////////////////////////// -int scumm_stricmp(const char *str1, const char *str2) { - return ::strcasecmp(str1, str2); -} - -////////////////////////////////////////////////////////////////////////// -int scumm_strnicmp(const char *str1, const char *str2, size_t maxCount) { - return ::strncasecmp(str1, str2, maxCount); -} - - ////////////////////////////////////////////////////////////////////////// char *CBPlatform::strupr(char *string) { if (string) { diff --git a/engines/wintermute/VidPlayer.cpp b/engines/wintermute/VidPlayer.cpp index 40d953f67b..e6459e26f1 100644 --- a/engines/wintermute/VidPlayer.cpp +++ b/engines/wintermute/VidPlayer.cpp @@ -119,6 +119,7 @@ HRESULT CVidPlayer::Cleanup() { return SetDefaults(); #endif + return 0; } @@ -268,6 +269,7 @@ HRESULT CVidPlayer::Update() { } else return E_FAIL; } else return S_OK; #endif + return 0; } @@ -289,6 +291,7 @@ HRESULT CVidPlayer::Display() { return res; #endif + return 0; } diff --git a/engines/wintermute/VidTheoraPlayer.cpp b/engines/wintermute/VidTheoraPlayer.cpp index f27a27b724..f802620bdd 100644 --- a/engines/wintermute/VidTheoraPlayer.cpp +++ b/engines/wintermute/VidTheoraPlayer.cpp @@ -328,6 +328,7 @@ HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { return Res; #endif + return 0; } @@ -588,6 +589,7 @@ float CVidTheoraPlayer::GetMovieTime() { else if (m_Sound) return (float)(m_Sound->GetPosition()) / 1000.0f + m_TimeOffset; else return (float)(m_CurrentTime - m_StartTime) / 1000.0f + m_TimeOffset; #endif + return 0; } @@ -599,6 +601,7 @@ int CVidTheoraPlayer::GetMovieFrame() { return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); #endif + return 0; } @@ -808,6 +811,7 @@ byte CVidTheoraPlayer::GetAlphaAt(int X, int Y) { if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); else return 0xFF; #endif + return 0; } @@ -894,6 +898,7 @@ HRESULT CVidTheoraPlayer::Pause() { return S_OK; } else return E_FAIL; #endif + return 0; } ////////////////////////////////////////////////////////////////////////// @@ -905,6 +910,7 @@ HRESULT CVidTheoraPlayer::Resume() { return S_OK; } else return E_FAIL; #endif + return 0; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index f0066e4686..15e695441d 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -144,4 +144,4 @@ public: REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); #else REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); -#endif \ No newline at end of file +#endif diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp index 9308065499..ef801feb89 100644 --- a/engines/wintermute/scriptables/SXStore.cpp +++ b/engines/wintermute/scriptables/SXStore.cpp @@ -508,4 +508,4 @@ void StoreKit_RestoreFinishedCallback(void *data, int error) { #endif // __IPHONEOS__ -} // end of namespace WinterMute \ No newline at end of file +} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp index b3eca0f346..0b1f81bd0e 100644 --- a/engines/wintermute/scriptables/ScScript.cpp +++ b/engines/wintermute/scriptables/ScScript.cpp @@ -442,7 +442,7 @@ HRESULT CScScript::ExecuteInstruction() { HRESULT ret = S_OK; uint32 dw; - const char *str; + const char *str = NULL; //CScValue* op = new CScValue(Game); _operand->Cleanup(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index b7da386054..d2473c8dd2 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -118,4 +118,4 @@ Common::Error WinterMuteEngine::run() { return Common::kNoError; } -} // End of namespace WinterMute \ No newline at end of file +} // End of namespace WinterMute diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index efa07ac669..e1f5047239 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -62,4 +62,4 @@ public: } // End of namespace Wintermute -#endif \ No newline at end of file +#endif diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h index 95e2a894ea..e89f9e55a2 100644 --- a/engines/wintermute/wme_debugger.h +++ b/engines/wintermute/wme_debugger.h @@ -169,4 +169,4 @@ typedef bool (*WMEDBG_SHUTDOWN)(IWmeDebugServer *Server); } // end of namespace WinterMute -#endif // WME_DEBUGGER_H \ No newline at end of file +#endif // WME_DEBUGGER_H -- cgit v1.2.3 From 96a8874a9280ff9d428965fedb1360008afea69a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 17:49:29 +0200 Subject: WINTERMUTE: Use the resolution asked for by the engines. --- engines/wintermute/BRenderSDL.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp index 34f0a57250..9702fc140e 100644 --- a/engines/wintermute/BRenderSDL.cpp +++ b/engines/wintermute/BRenderSDL.cpp @@ -137,6 +137,15 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { //_windowed = Game->_registry->ReadBool("Video", "Windowed", true); // if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return E_FAIL; + } #if 0 _win = SDL_CreateWindow("WME Lite", SDL_WINDOWPOS_UNDEFINED, -- cgit v1.2.3 From ed88f83d548a5ad4da483a94d7cd8fbcec8af6bd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 17:49:58 +0200 Subject: WINTERMUTE: Add detection for Rosemary --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 15e695441d..0ae305eb23 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -52,6 +52,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_USEEXTRAASTITLE, GUIO0() }, + { + "wintermute", + "Rosemary", + AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, AD_TABLE_END_MARKER }; -- cgit v1.2.3 From b94c379263fcf3117a54b24c69a53ce89f5074f9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Jun 2012 17:50:51 +0200 Subject: WINTERMUTE: Let blitting of non 32bpp surfaces fail with a warning instead of an error for now. --- engines/wintermute/graphics/transparentSurface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index 1f13e15c55..d7f8719b6e 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -71,7 +71,8 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p TransparentSurface srcImage(*this, false); // TODO: Is the data really in the screen format? if (format.bytesPerPixel != 4) { - error("TransparentSurface can only blit 32 bpp images"); + warning("TransparentSurface can only blit 32 bpp images"); + return retSize; } if (pPartRect) { -- cgit v1.2.3 From b1e4f58fed4afcc4fcd36eb15cadde19036723fb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 00:44:20 +0200 Subject: WINTERMUTE: Use const Common::String& for the file-accessors. --- engines/wintermute/BDiskFile.cpp | 2 +- engines/wintermute/BDiskFile.h | 2 +- engines/wintermute/BFile.h | 2 +- engines/wintermute/BFileManager.cpp | 6 +++--- engines/wintermute/BFileManager.h | 3 ++- engines/wintermute/BPkgFile.cpp | 2 +- engines/wintermute/BPkgFile.h | 2 +- engines/wintermute/BResourceFile.cpp | 2 +- engines/wintermute/BResourceFile.h | 2 +- engines/wintermute/BSaveThumbFile.cpp | 2 +- engines/wintermute/BSaveThumbFile.h | 2 +- 11 files changed, 14 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp index e559708b5b..c8301dde20 100644 --- a/engines/wintermute/BDiskFile.cpp +++ b/engines/wintermute/BDiskFile.cpp @@ -53,7 +53,7 @@ CBDiskFile::~CBDiskFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Open(Common::String Filename) { +HRESULT CBDiskFile::Open(const Common::String &Filename) { Close(); char FullPath[MAX_PATH]; diff --git a/engines/wintermute/BDiskFile.h b/engines/wintermute/BDiskFile.h index 129dcb0e72..3cabe173e6 100644 --- a/engines/wintermute/BDiskFile.h +++ b/engines/wintermute/BDiskFile.h @@ -45,7 +45,7 @@ public: virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); virtual HRESULT Read(void *Buffer, uint32 Size); virtual HRESULT Close(); - virtual HRESULT Open(Common::String Filename); + virtual HRESULT Open(const Common::String &Filename); private: void CorrectSlashes(char *fileName); Common::SeekableReadStream *_file; diff --git a/engines/wintermute/BFile.h b/engines/wintermute/BFile.h index 78241eaf6a..eca8f4a416 100644 --- a/engines/wintermute/BFile.h +++ b/engines/wintermute/BFile.h @@ -52,7 +52,7 @@ public: virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; virtual HRESULT Read(void *Buffer, uint32 Size) = 0; virtual HRESULT Close() = 0; - virtual HRESULT Open(Common::String Filename) = 0; + virtual HRESULT Open(const Common::String &Filename) = 0; virtual bool IsEOF(); CBFile(CBGame *inGame); virtual ~CBFile(); diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp index 7ac64e3236..8c14c1904f 100644 --- a/engines/wintermute/BFileManager.cpp +++ b/engines/wintermute/BFileManager.cpp @@ -785,10 +785,10 @@ HRESULT CBFileManager::CloseFile(CBFile *File) { ////////////////////////////////////////////////////////////////////////// -CBFile *CBFileManager::OpenFileRaw(const char *Filename) { +CBFile *CBFileManager::OpenFileRaw(const Common::String &Filename) { RestoreCurrentDir(); - if (scumm_strnicmp(Filename, "savegame:", 9) == 0) { + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile; else { @@ -809,7 +809,7 @@ CBFile *CBFileManager::OpenFileRaw(const char *Filename) { if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; delete ResFile; - warning("BFileManager::OpenFileRaw - Failed to open %s", Filename); + warning("BFileManager::OpenFileRaw - Failed to open %s", Filename.c_str()); return NULL; } diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h index c7363de04e..0eb7d23a47 100644 --- a/engines/wintermute/BFileManager.h +++ b/engines/wintermute/BFileManager.h @@ -34,6 +34,7 @@ #include "coll_templ.h" #include "BFileEntry.h" #include "common/archive.h" +#include "common/str.h" namespace Common { class File; @@ -49,7 +50,7 @@ public: HRESULT RestoreCurrentDir(); char *_basePath; bool GetFullPath(const char *Filename, char *Fullname); - CBFile *OpenFileRaw(const char *Filename); + CBFile *OpenFileRaw(const Common::String &filename); HRESULT CloseFile(CBFile *File); CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); CBFileEntry *GetPackageEntry(const char *Filename); diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp index dd04fdec03..b60b641daf 100644 --- a/engines/wintermute/BPkgFile.cpp +++ b/engines/wintermute/BPkgFile.cpp @@ -54,7 +54,7 @@ CBPkgFile::~CBPkgFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Open(Common::String Filename) { +HRESULT CBPkgFile::Open(const Common::String &Filename) { Close(); char fileName[MAX_PATH]; diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h index e3942718f4..4efbf21e0d 100644 --- a/engines/wintermute/BPkgFile.h +++ b/engines/wintermute/BPkgFile.h @@ -50,7 +50,7 @@ public: virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); virtual HRESULT Read(void *Buffer, uint32 Size); virtual HRESULT Close(); - virtual HRESULT Open(Common::String Filename); + virtual HRESULT Open(const Common::String &Filename); private: bool _inflateInit; HRESULT SeekToPos(uint32 NewPos); diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp index d7eb470ca2..83c2283db5 100644 --- a/engines/wintermute/BResourceFile.cpp +++ b/engines/wintermute/BResourceFile.cpp @@ -45,7 +45,7 @@ CBResourceFile::~CBResourceFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Open(Common::String Filename) { +HRESULT CBResourceFile::Open(const Common::String &Filename) { Close(); if (CBResources::GetFile(Filename.c_str(), _data, _size)) { diff --git a/engines/wintermute/BResourceFile.h b/engines/wintermute/BResourceFile.h index 654983997b..17d396bd22 100644 --- a/engines/wintermute/BResourceFile.h +++ b/engines/wintermute/BResourceFile.h @@ -40,7 +40,7 @@ public: virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); virtual HRESULT Read(void *Buffer, uint32 Size); virtual HRESULT Close(); - virtual HRESULT Open(Common::String Filename); + virtual HRESULT Open(const Common::String &Filename); private: byte *_data; }; diff --git a/engines/wintermute/BSaveThumbFile.cpp b/engines/wintermute/BSaveThumbFile.cpp index d8d91e8062..67e3803a93 100644 --- a/engines/wintermute/BSaveThumbFile.cpp +++ b/engines/wintermute/BSaveThumbFile.cpp @@ -51,7 +51,7 @@ CBSaveThumbFile::~CBSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Open(Common::String Filename) { +HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { Close(); if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; diff --git a/engines/wintermute/BSaveThumbFile.h b/engines/wintermute/BSaveThumbFile.h index 69be999f9e..d5c6d54ebf 100644 --- a/engines/wintermute/BSaveThumbFile.h +++ b/engines/wintermute/BSaveThumbFile.h @@ -41,7 +41,7 @@ public: virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); virtual HRESULT Read(void *Buffer, uint32 Size); virtual HRESULT Close(); - virtual HRESULT Open(Common::String Filename); + virtual HRESULT Open(const Common::String &Filename); private: byte *_data; }; -- cgit v1.2.3 From 2317b3538fc5148dc9c7b3d26c2d60fdb06c85e4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 01:17:46 +0200 Subject: WINTERMUTE: Move all the Ad files to Ad/ --- engines/wintermute/Ad/AdActor.cpp | 1339 +++++++++++++ engines/wintermute/Ad/AdActor.h | 107 ++ engines/wintermute/Ad/AdActorDir.cpp | 52 + engines/wintermute/Ad/AdActorDir.h | 46 + engines/wintermute/Ad/AdEntity.cpp | 977 ++++++++++ engines/wintermute/Ad/AdEntity.h | 67 + engines/wintermute/Ad/AdGame.cpp | 2060 ++++++++++++++++++++ engines/wintermute/Ad/AdGame.h | 162 ++ engines/wintermute/Ad/AdInventory.cpp | 119 ++ engines/wintermute/Ad/AdInventory.h | 52 + engines/wintermute/Ad/AdInventoryBox.cpp | 373 ++++ engines/wintermute/Ad/AdInventoryBox.h | 63 + engines/wintermute/Ad/AdItem.cpp | 758 ++++++++ engines/wintermute/Ad/AdItem.h | 70 + engines/wintermute/Ad/AdLayer.cpp | 538 ++++++ engines/wintermute/Ad/AdLayer.h | 58 + engines/wintermute/Ad/AdNodeState.cpp | 169 ++ engines/wintermute/Ad/AdNodeState.h | 58 + engines/wintermute/Ad/AdObject.cpp | 1203 ++++++++++++ engines/wintermute/Ad/AdObject.h | 123 ++ engines/wintermute/Ad/AdPath.cpp | 112 ++ engines/wintermute/Ad/AdPath.h | 56 + engines/wintermute/Ad/AdPathPoint.cpp | 75 + engines/wintermute/Ad/AdPathPoint.h | 50 + engines/wintermute/Ad/AdRegion.cpp | 394 ++++ engines/wintermute/Ad/AdRegion.h | 58 + engines/wintermute/Ad/AdResponse.cpp | 143 ++ engines/wintermute/Ad/AdResponse.h | 61 + engines/wintermute/Ad/AdResponseBox.cpp | 645 +++++++ engines/wintermute/Ad/AdResponseBox.h | 85 + engines/wintermute/Ad/AdResponseContext.cpp | 70 + engines/wintermute/Ad/AdResponseContext.h | 50 + engines/wintermute/Ad/AdRotLevel.cpp | 159 ++ engines/wintermute/Ad/AdRotLevel.h | 49 + engines/wintermute/Ad/AdScaleLevel.cpp | 157 ++ engines/wintermute/Ad/AdScaleLevel.h | 50 + engines/wintermute/Ad/AdScene.cpp | 2763 +++++++++++++++++++++++++++ engines/wintermute/Ad/AdScene.h | 181 ++ engines/wintermute/Ad/AdSceneNode.cpp | 83 + engines/wintermute/Ad/AdSceneNode.h | 54 + engines/wintermute/Ad/AdSceneState.cpp | 88 + engines/wintermute/Ad/AdSceneState.h | 51 + engines/wintermute/Ad/AdSentence.cpp | 317 +++ engines/wintermute/Ad/AdSentence.h | 83 + engines/wintermute/Ad/AdSpriteSet.cpp | 313 +++ engines/wintermute/Ad/AdSpriteSet.h | 54 + engines/wintermute/Ad/AdTalkDef.cpp | 260 +++ engines/wintermute/Ad/AdTalkDef.h | 58 + engines/wintermute/Ad/AdTalkHolder.cpp | 356 ++++ engines/wintermute/Ad/AdTalkHolder.h | 57 + engines/wintermute/Ad/AdTalkNode.cpp | 263 +++ engines/wintermute/Ad/AdTalkNode.h | 63 + engines/wintermute/Ad/AdTypes.h | 93 + engines/wintermute/Ad/AdWaypointGroup.cpp | 262 +++ engines/wintermute/Ad/AdWaypointGroup.h | 58 + engines/wintermute/AdActor.cpp | 1339 ------------- engines/wintermute/AdActor.h | 107 -- engines/wintermute/AdActorDir.cpp | 52 - engines/wintermute/AdActorDir.h | 46 - engines/wintermute/AdEntity.cpp | 977 ---------- engines/wintermute/AdEntity.h | 67 - engines/wintermute/AdGame.cpp | 2060 -------------------- engines/wintermute/AdGame.h | 162 -- engines/wintermute/AdInventory.cpp | 119 -- engines/wintermute/AdInventory.h | 52 - engines/wintermute/AdInventoryBox.cpp | 373 ---- engines/wintermute/AdInventoryBox.h | 63 - engines/wintermute/AdItem.cpp | 758 -------- engines/wintermute/AdItem.h | 70 - engines/wintermute/AdLayer.cpp | 538 ------ engines/wintermute/AdLayer.h | 58 - engines/wintermute/AdNodeState.cpp | 169 -- engines/wintermute/AdNodeState.h | 58 - engines/wintermute/AdObject.cpp | 1203 ------------ engines/wintermute/AdObject.h | 123 -- engines/wintermute/AdPath.cpp | 112 -- engines/wintermute/AdPath.h | 56 - engines/wintermute/AdPathPoint.cpp | 75 - engines/wintermute/AdPathPoint.h | 50 - engines/wintermute/AdRegion.cpp | 394 ---- engines/wintermute/AdRegion.h | 58 - engines/wintermute/AdResponse.cpp | 143 -- engines/wintermute/AdResponse.h | 61 - engines/wintermute/AdResponseBox.cpp | 645 ------- engines/wintermute/AdResponseBox.h | 85 - engines/wintermute/AdResponseContext.cpp | 70 - engines/wintermute/AdResponseContext.h | 50 - engines/wintermute/AdRotLevel.cpp | 159 -- engines/wintermute/AdRotLevel.h | 49 - engines/wintermute/AdScaleLevel.cpp | 157 -- engines/wintermute/AdScaleLevel.h | 50 - engines/wintermute/AdScene.cpp | 2763 --------------------------- engines/wintermute/AdScene.h | 181 -- engines/wintermute/AdSceneNode.cpp | 83 - engines/wintermute/AdSceneNode.h | 54 - engines/wintermute/AdSceneState.cpp | 88 - engines/wintermute/AdSceneState.h | 51 - engines/wintermute/AdSentence.cpp | 317 --- engines/wintermute/AdSentence.h | 83 - engines/wintermute/AdSpriteSet.cpp | 313 --- engines/wintermute/AdSpriteSet.h | 54 - engines/wintermute/AdTalkDef.cpp | 260 --- engines/wintermute/AdTalkDef.h | 58 - engines/wintermute/AdTalkHolder.cpp | 356 ---- engines/wintermute/AdTalkHolder.h | 57 - engines/wintermute/AdTalkNode.cpp | 263 --- engines/wintermute/AdTalkNode.h | 63 - engines/wintermute/AdTypes.h | 93 - engines/wintermute/AdWaypointGroup.cpp | 262 --- engines/wintermute/AdWaypointGroup.h | 58 - engines/wintermute/BScriptHolder.cpp | 2 +- engines/wintermute/UIEntity.cpp | 2 +- engines/wintermute/module.mk | 56 +- engines/wintermute/wintermute.cpp | 2 +- 114 files changed, 16095 insertions(+), 16097 deletions(-) create mode 100644 engines/wintermute/Ad/AdActor.cpp create mode 100644 engines/wintermute/Ad/AdActor.h create mode 100644 engines/wintermute/Ad/AdActorDir.cpp create mode 100644 engines/wintermute/Ad/AdActorDir.h create mode 100644 engines/wintermute/Ad/AdEntity.cpp create mode 100644 engines/wintermute/Ad/AdEntity.h create mode 100644 engines/wintermute/Ad/AdGame.cpp create mode 100644 engines/wintermute/Ad/AdGame.h create mode 100644 engines/wintermute/Ad/AdInventory.cpp create mode 100644 engines/wintermute/Ad/AdInventory.h create mode 100644 engines/wintermute/Ad/AdInventoryBox.cpp create mode 100644 engines/wintermute/Ad/AdInventoryBox.h create mode 100644 engines/wintermute/Ad/AdItem.cpp create mode 100644 engines/wintermute/Ad/AdItem.h create mode 100644 engines/wintermute/Ad/AdLayer.cpp create mode 100644 engines/wintermute/Ad/AdLayer.h create mode 100644 engines/wintermute/Ad/AdNodeState.cpp create mode 100644 engines/wintermute/Ad/AdNodeState.h create mode 100644 engines/wintermute/Ad/AdObject.cpp create mode 100644 engines/wintermute/Ad/AdObject.h create mode 100644 engines/wintermute/Ad/AdPath.cpp create mode 100644 engines/wintermute/Ad/AdPath.h create mode 100644 engines/wintermute/Ad/AdPathPoint.cpp create mode 100644 engines/wintermute/Ad/AdPathPoint.h create mode 100644 engines/wintermute/Ad/AdRegion.cpp create mode 100644 engines/wintermute/Ad/AdRegion.h create mode 100644 engines/wintermute/Ad/AdResponse.cpp create mode 100644 engines/wintermute/Ad/AdResponse.h create mode 100644 engines/wintermute/Ad/AdResponseBox.cpp create mode 100644 engines/wintermute/Ad/AdResponseBox.h create mode 100644 engines/wintermute/Ad/AdResponseContext.cpp create mode 100644 engines/wintermute/Ad/AdResponseContext.h create mode 100644 engines/wintermute/Ad/AdRotLevel.cpp create mode 100644 engines/wintermute/Ad/AdRotLevel.h create mode 100644 engines/wintermute/Ad/AdScaleLevel.cpp create mode 100644 engines/wintermute/Ad/AdScaleLevel.h create mode 100644 engines/wintermute/Ad/AdScene.cpp create mode 100644 engines/wintermute/Ad/AdScene.h create mode 100644 engines/wintermute/Ad/AdSceneNode.cpp create mode 100644 engines/wintermute/Ad/AdSceneNode.h create mode 100644 engines/wintermute/Ad/AdSceneState.cpp create mode 100644 engines/wintermute/Ad/AdSceneState.h create mode 100644 engines/wintermute/Ad/AdSentence.cpp create mode 100644 engines/wintermute/Ad/AdSentence.h create mode 100644 engines/wintermute/Ad/AdSpriteSet.cpp create mode 100644 engines/wintermute/Ad/AdSpriteSet.h create mode 100644 engines/wintermute/Ad/AdTalkDef.cpp create mode 100644 engines/wintermute/Ad/AdTalkDef.h create mode 100644 engines/wintermute/Ad/AdTalkHolder.cpp create mode 100644 engines/wintermute/Ad/AdTalkHolder.h create mode 100644 engines/wintermute/Ad/AdTalkNode.cpp create mode 100644 engines/wintermute/Ad/AdTalkNode.h create mode 100644 engines/wintermute/Ad/AdTypes.h create mode 100644 engines/wintermute/Ad/AdWaypointGroup.cpp create mode 100644 engines/wintermute/Ad/AdWaypointGroup.h delete mode 100644 engines/wintermute/AdActor.cpp delete mode 100644 engines/wintermute/AdActor.h delete mode 100644 engines/wintermute/AdActorDir.cpp delete mode 100644 engines/wintermute/AdActorDir.h delete mode 100644 engines/wintermute/AdEntity.cpp delete mode 100644 engines/wintermute/AdEntity.h delete mode 100644 engines/wintermute/AdGame.cpp delete mode 100644 engines/wintermute/AdGame.h delete mode 100644 engines/wintermute/AdInventory.cpp delete mode 100644 engines/wintermute/AdInventory.h delete mode 100644 engines/wintermute/AdInventoryBox.cpp delete mode 100644 engines/wintermute/AdInventoryBox.h delete mode 100644 engines/wintermute/AdItem.cpp delete mode 100644 engines/wintermute/AdItem.h delete mode 100644 engines/wintermute/AdLayer.cpp delete mode 100644 engines/wintermute/AdLayer.h delete mode 100644 engines/wintermute/AdNodeState.cpp delete mode 100644 engines/wintermute/AdNodeState.h delete mode 100644 engines/wintermute/AdObject.cpp delete mode 100644 engines/wintermute/AdObject.h delete mode 100644 engines/wintermute/AdPath.cpp delete mode 100644 engines/wintermute/AdPath.h delete mode 100644 engines/wintermute/AdPathPoint.cpp delete mode 100644 engines/wintermute/AdPathPoint.h delete mode 100644 engines/wintermute/AdRegion.cpp delete mode 100644 engines/wintermute/AdRegion.h delete mode 100644 engines/wintermute/AdResponse.cpp delete mode 100644 engines/wintermute/AdResponse.h delete mode 100644 engines/wintermute/AdResponseBox.cpp delete mode 100644 engines/wintermute/AdResponseBox.h delete mode 100644 engines/wintermute/AdResponseContext.cpp delete mode 100644 engines/wintermute/AdResponseContext.h delete mode 100644 engines/wintermute/AdRotLevel.cpp delete mode 100644 engines/wintermute/AdRotLevel.h delete mode 100644 engines/wintermute/AdScaleLevel.cpp delete mode 100644 engines/wintermute/AdScaleLevel.h delete mode 100644 engines/wintermute/AdScene.cpp delete mode 100644 engines/wintermute/AdScene.h delete mode 100644 engines/wintermute/AdSceneNode.cpp delete mode 100644 engines/wintermute/AdSceneNode.h delete mode 100644 engines/wintermute/AdSceneState.cpp delete mode 100644 engines/wintermute/AdSceneState.h delete mode 100644 engines/wintermute/AdSentence.cpp delete mode 100644 engines/wintermute/AdSentence.h delete mode 100644 engines/wintermute/AdSpriteSet.cpp delete mode 100644 engines/wintermute/AdSpriteSet.h delete mode 100644 engines/wintermute/AdTalkDef.cpp delete mode 100644 engines/wintermute/AdTalkDef.h delete mode 100644 engines/wintermute/AdTalkHolder.cpp delete mode 100644 engines/wintermute/AdTalkHolder.h delete mode 100644 engines/wintermute/AdTalkNode.cpp delete mode 100644 engines/wintermute/AdTalkNode.h delete mode 100644 engines/wintermute/AdTypes.h delete mode 100644 engines/wintermute/AdWaypointGroup.cpp delete mode 100644 engines/wintermute/AdWaypointGroup.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp new file mode 100644 index 0000000000..9b30d16221 --- /dev/null +++ b/engines/wintermute/Ad/AdActor.cpp @@ -0,0 +1,1339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Ad/AdActor.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Ad/AdSpriteSet.h" +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/Ad/AdPath.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActor, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { + _path = new CAdPath(Game); + + _type = OBJECT_ACTOR; + _dir = DI_LEFT; + + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _targetPoint = new CBPoint; + _afterWalkDir = DI_NONE; + + _animSprite2 = NULL; + + SetDefaultAnimNames(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::SetDefaultAnimNames() { + _talkAnimName = NULL; + CBUtils::SetString(&_talkAnimName, "talk"); + + _idleAnimName = NULL; + CBUtils::SetString(&_idleAnimName, "idle"); + + _walkAnimName = NULL; + CBUtils::SetString(&_walkAnimName, "walk"); + + _turnLeftAnimName = NULL; + CBUtils::SetString(&_turnLeftAnimName, "turnleft"); + + _turnRightAnimName = NULL; + CBUtils::SetString(&_turnRightAnimName, "turnright"); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdActor::~CAdActor() { + delete _path; + delete _targetPoint; + _path = NULL; + _targetPoint = NULL; + + delete _walkSprite; + delete _standSprite; + delete _turnLeftSprite; + delete _turnRightSprite; + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _animSprite2 = NULL; // ref only + + for (int i = 0; i < _talkSprites.GetSize(); i++) { + delete _talkSprites[i]; + } + _talkSprites.RemoveAll(); + + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + delete _talkSpritesEx[i]; + } + _talkSpritesEx.RemoveAll(); + + + delete[] _talkAnimName; + delete[] _idleAnimName; + delete[] _walkAnimName; + delete[] _turnLeftAnimName; + delete[] _turnRightAnimName; + _talkAnimName = NULL; + _idleAnimName = NULL; + _walkAnimName = NULL; + _turnLeftAnimName = NULL; + _turnRightAnimName = NULL; + + for (int i = 0; i < _anims.GetSize(); i++) { + delete _anims[i]; + _anims[i] = NULL; + } + _anims.RemoveAll(); + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ACTOR) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(WALK) +TOKEN_DEF(STAND) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(TURN_LEFT) +TOKEN_DEF(TURN_RIGHT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ANIMATION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTOR) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(WALK) + TOKEN_TABLE(STAND) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TURN_LEFT) + TOKEN_TABLE(TURN_RIGHT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + Game->LOG(0, "'ACTOR' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CAdGame *AdGame = (CAdGame *)Game; + CAdSpriteSet *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.ScanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.ScanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.ScanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.ScanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &_active); + break; + + case TOKEN_WALK: + delete _walkSprite; + _walkSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + else _walkSprite = spr; + break; + + case TOKEN_TALK: + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); + break; + + case TOKEN_TALK_SPECIAL: + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); + break; + + case TOKEN_STAND: + delete _standSprite; + _standSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + else _standSprite = spr; + break; + + case TOKEN_TURN_LEFT: + delete _turnLeftSprite; + _turnLeftSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnLeftSprite = spr; + break; + + case TOKEN_TURN_RIGHT: + delete _turnRightSprite; + _turnRightSprite = NULL; + spr = new CAdSpriteSet(Game, this); + if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnRightSprite = spr; + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SOUND_VOLUME: + parser.ScanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_SOUND_PANNING: + parser.ScanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(Game); + CBRegion *crgn = new CBRegion(Game); + if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->Mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->Mimic(_wptGroup); + } + } + break; + + case TOKEN_IGNORE_ITEMS: + parser.ScanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + if (!Anim || FAILED(Anim->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + else _anims.Add(Anim); + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ACTOR definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + if (spr) delete spr; + Game->LOG(0, "Error loading ACTOR definition"); + return E_FAIL; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = DRGBA(ar, ag, ab, alpha); + _state = _nextState = STATE_READY; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::TurnTo(TDirection dir) { + int delta1, delta2, delta3, delta; + + delta1 = dir - _dir; + delta2 = dir + NUM_DIRECTIONS - _dir; + delta3 = dir - NUM_DIRECTIONS - _dir; + + delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; + delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; + + // already there? + if (abs(delta) < 2) { + _dir = dir; + _state = _nextState; + _nextState = STATE_READY; + return; + } + + _targetDir = dir; + _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; + + _tempSprite2 = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { + _afterWalkDir = AfterWalkDir; + if (X == _targetPoint->x && Y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; + + _path->Reset(); + _path->SetReady(false); + + _targetPoint->x = X; + _targetPoint->y = Y; + + ((CAdGame *)Game)->_scene->CorrectTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + + _state = STATE_SEARCHING_PATH; + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Display() { + if (_active) UpdateSounds(); + + uint32 Alpha; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + + float Rotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; + } else Rotate = 0.0f; + + if (_active) DisplaySpriteAttachments(true); + + if (_currentSprite && _active) { + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; + + _currentSprite->Display(_posX, + _posY, + Reg ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); + + } + + if (_active) DisplaySpriteAttachments(false); + if (_active && _partEmitter) _partEmitter->Display(); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Update() { + _currentSprite = NULL; + + if (_state == STATE_READY) { + if (_animSprite) { + delete _animSprite; + _animSprite = NULL; + } + if (_animSprite2) { + _animSprite2 = NULL; + } + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite; + } + + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite2; + } + + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + + // default: stand animation + if (!_currentSprite) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->GetSprite(_dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); + } + } + } + + bool already_moved = false; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM_SET: + _currentSprite = _animSprite2; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_LEFT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_dir > 0) _dir = (TDirection)(_dir - 1); + else _dir = (TDirection)(NUM_DIRECTIONS - 1); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnLeftSprite) { + _tempSprite2 = _turnLeftSprite->GetSprite(_dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(_turnLeftAnimName); + if (Anim) _tempSprite2 = Anim->GetSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->Reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_RIGHT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + _dir = (TDirection)(_dir + 1); + + if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnRightSprite) { + _tempSprite2 = _turnRightSprite->GetSprite(_dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(_turnRightAnimName); + if (Anim) _tempSprite2 = Anim->GetSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->Reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_SEARCHING_PATH: + // keep asking scene for the path + if (((CAdGame *)Game)->_scene->GetPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + _state = STATE_WAITING_PATH; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_WAITING_PATH: + // wait until the scene finished the path + if (_path->_ready) FollowPath(); + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_FOLLOWING_PATH: + GetNextStep(); + already_moved = true; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->Update(_dir); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->Finish(); + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); + } + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); + } + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite && !_animSprite2) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->GetSprite(_dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); + } + } + } + break; + default: + error("AdActor::Update - Unhandled enum"); + } + + + if (_currentSprite && !already_moved) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + AfterMove(); + } + } + + //Game->QuickMessageForm("%s", _currentSprite->_filename); + + UpdateBlockRegion(); + _ready = (_state == STATE_READY); + + UpdatePartEmitter(); + UpdateSpriteAttachments(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::FollowPath() { + // skip current position + _path->GetFirst(); + while (_path->GetCurrent() != NULL) { + if (_path->GetCurrent()->x != _posX || _path->GetCurrent()->y != _posY) break; + _path->GetNext(); + } + + // are there points to follow? + if (_path->GetCurrent() != NULL) { + _state = STATE_FOLLOWING_PATH;; + InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + } else { + if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); + else _state = STATE_READY; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::GetNextStep() { + if (_walkSprite) { + _currentSprite = _walkSprite->GetSprite(_dir); + } else { + CAdSpriteSet *Anim = GetAnimByName(_walkAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); + } + + if (!_currentSprite) return; + + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (!_currentSprite->_changed) return; + + + int MaxStepX, MaxStepY; + MaxStepX = abs(_currentSprite->_moveX); + MaxStepY = abs(_currentSprite->_moveY); + + MaxStepX = MAX(MaxStepX, MaxStepY); + MaxStepX = MAX(MaxStepX, 1); + + while (_pFCount > 0 && MaxStepX >= 0) { + _pFX += _pFStepX; + _pFY += _pFStepY; + + _pFCount--; + MaxStepX--; + } + + if (((CAdGame *)Game)->_scene->IsBlockedAt(_pFX, _pFY, true, this)) { + if (_pFCount == 0) { + _state = _nextState; + _nextState = STATE_READY; + return; + } + GoTo(_targetPoint->x, _targetPoint->y); + return; + } + + + _posX = (int)_pFX; + _posY = (int)_pFY; + + AfterMove(); + + + if (_pFCount == 0) { + if (_path->GetNext() == NULL) { + _posX = _targetPoint->x; + _posY = _targetPoint->y; + + _path->Reset(); + if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); + else { + _state = _nextState; + _nextState = STATE_READY; + } + } else InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { + _pFCount = MAX((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); + + _pFStepX = (double)(EndPt.x - StartPt.x) / _pFCount; + _pFStepY = (double)(EndPt.y - StartPt.y) / _pFCount; + + _pFX = StartPt.x; + _pFY = StartPt.y; + + int angle = (int)(atan2((double)(EndPt.y - StartPt.y), (double)(EndPt.x - StartPt.x)) * (180 / 3.14)); + + _nextState = STATE_FOLLOWING_PATH; + + TurnTo(AngleToDirection(angle)); +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GoTo / GoToAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GoTo") == 0 || strcmp(Name, "GoToAsync") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + GoTo(X, Y); + if (strcmp(Name, "GoToAsync") != 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoToObject / GoToObjectAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoToObject") == 0 || strcmp(Name, "GoToObjectAsync") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (!Val->IsNative()) { + Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Stack->PushNULL(); + return S_OK; + } + CAdObject *Obj = (CAdObject *)Val->GetNative(); + if (!Obj || Obj->_type != OBJECT_ENTITY) { + Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Stack->PushNULL(); + return S_OK; + } + CAdEntity *Ent = (CAdEntity *)Obj; + if (Ent->_walkToX == 0 && Ent->_walkToY == 0) GoTo(Ent->_posX, Ent->_posY); + else GoTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); + if (strcmp(Name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnTo / TurnToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnTo") == 0 || strcmp(Name, "TurnToAsync") == 0) { + Stack->CorrectParams(1); + int dir; + CScValue *val = Stack->Pop(); + + // turn to object? + if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { + CBObject *obj = (CBObject *)val->GetNative(); + int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); + dir = (int)AngleToDirection(angle); + } + // otherwise turn to direction + else dir = val->GetInt(); + + if (dir >= 0 && dir < NUM_DIRECTIONS) { + TurnTo((TDirection)dir); + if (strcmp(Name, "TurnToAsync") != 0) Script->WaitForExclusive(this); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsWalking") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(_state == STATE_FOLLOWING_PATH); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MergeAnims + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MergeAnims") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(SUCCEEDED(MergeAnims(Stack->Pop()->GetString()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadAnim") == 0) { + Stack->CorrectParams(1); + const char *AnimName = Stack->Pop()->GetString(); + + bool Found = false; + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { + // invalidate sprites in use + if (_anims[i]->ContainsSprite(_tempSprite2)) _tempSprite2 = NULL; + if (_anims[i]->ContainsSprite(_currentSprite)) _currentSprite = NULL; + if (_anims[i]->ContainsSprite(_animSprite2)) _animSprite2 = NULL; + + delete _anims[i]; + _anims[i] = NULL; + _anims.RemoveAt(i); + i--; + Found = true; + } + } + Stack->PushBool(Found); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasAnim") == 0) { + Stack->CorrectParams(1); + const char *AnimName = Stack->Pop()->GetString(); + Stack->PushBool(GetAnimByName(AnimName) != NULL); + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdActor::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Direction") == 0) { + _scValue->SetInt(_dir); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Type") == 0) { + _scValue->SetString("actor"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkAnimName") == 0) { + _scValue->SetString(_talkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkAnimName") == 0) { + _scValue->SetString(_walkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IdleAnimName") == 0) { + _scValue->SetString(_idleAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnLeftAnimName") == 0) { + _scValue->SetString(_turnLeftAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnRightAnimName") == 0) { + _scValue->SetString(_turnRightAnimName); + return _scValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Direction") == 0) { + int dir = Value->GetInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&_talkAnimName, "talk"); + else CBUtils::SetString(&_talkAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&_walkAnimName, "walk"); + else CBUtils::SetString(&_walkAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IdleAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&_idleAnimName, "idle"); + else CBUtils::SetString(&_idleAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnLeftAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&_turnLeftAnimName, "turnleft"); + else CBUtils::SetString(&_turnLeftAnimName, Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TurnRightAnimName") == 0) { + if (Value->IsNULL()) CBUtils::SetString(&_turnRightAnimName, "turnright"); + else CBUtils::SetString(&_turnRightAnimName, Value->GetString()); + return S_OK; + } + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdActor::ScToString() { + return "[actor object]"; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::GetTalkStance(const char *Stance) { + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(Game, this); + if (_animSprite) { + HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); + if (FAILED(res)) { + Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + // old way + if (_talkSprites.GetSize() > 0 || _talkSpritesEx.GetSize() > 0) + return GetTalkStanceOld(Stance); + + // new way + CBSprite *Ret = NULL; + + // do we have an animation with this name? + CAdSpriteSet *Anim = GetAnimByName(Stance); + if (Anim) Ret = Anim->GetSprite(_dir); + + // not - get a random talk + if (!Ret) { + CBArray TalkAnims; + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, _talkAnimName) == 0) + TalkAnims.Add(_anims[i]); + } + + if (TalkAnims.GetSize() > 0) { + int rnd = rand() % TalkAnims.GetSize(); + Ret = TalkAnims[rnd]->GetSprite(_dir); + } else { + if (_standSprite) Ret = _standSprite->GetSprite(_dir); + else { + Anim = GetAnimByName(_idleAnimName); + if (Anim) Ret = Anim->GetSprite(_dir); + } + } + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { + CBSprite *ret = NULL; + + if (Stance != NULL) { + // search special stances + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + ret = _talkSpritesEx[i]->GetSprite(_dir); + break; + } + } + if (ret == NULL) { + // search generic stances + for (int i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + ret = _talkSprites[i]->GetSprite(_dir); + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.GetSize() < 1) ret = _standSprite->GetSprite(_dir); + else { + // TODO: remember last + int rnd = rand() % _talkSprites.GetSize(); + ret = _talkSprites[rnd]->GetSprite(_dir); + } + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::Persist(CBPersistMgr *PersistMgr) { + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER_INT(_dir)); + PersistMgr->Transfer(TMEMBER(_path)); + PersistMgr->Transfer(TMEMBER(_pFCount)); + PersistMgr->Transfer(TMEMBER(_pFStepX)); + PersistMgr->Transfer(TMEMBER(_pFStepY)); + PersistMgr->Transfer(TMEMBER(_pFX)); + PersistMgr->Transfer(TMEMBER(_pFY)); + PersistMgr->Transfer(TMEMBER(_standSprite)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(_targetDir)); + PersistMgr->Transfer(TMEMBER_INT(_afterWalkDir)); + PersistMgr->Transfer(TMEMBER(_targetPoint)); + PersistMgr->Transfer(TMEMBER(_turnLeftSprite)); + PersistMgr->Transfer(TMEMBER(_turnRightSprite)); + PersistMgr->Transfer(TMEMBER(_walkSprite)); + + PersistMgr->Transfer(TMEMBER(_animSprite2)); + PersistMgr->Transfer(TMEMBER(_talkAnimName)); + PersistMgr->Transfer(TMEMBER(_idleAnimName)); + PersistMgr->Transfer(TMEMBER(_walkAnimName)); + PersistMgr->Transfer(TMEMBER(_turnLeftAnimName)); + PersistMgr->Transfer(TMEMBER(_turnRightAnimName)); + + _anims.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TDirection CAdActor::AngleToDirection(int Angle) { + TDirection ret = DI_DOWN;; + + if (Angle > -112 && Angle <= -67) ret = DI_UP; + else if (Angle > -67 && Angle <= -22) ret = DI_UPRIGHT; + else if (Angle > -22 && Angle <= 22) ret = DI_RIGHT; + else if (Angle > 22 && Angle <= 67) ret = DI_DOWNRIGHT; + else if (Angle > 67 && Angle <= 112) ret = DI_DOWN; + else if (Angle > 112 && Angle <= 157) ret = DI_DOWNLEFT; + else if ((Angle > 157 && Angle <= 180) || (Angle >= -180 && Angle <= -157)) ret = DI_LEFT; + else if (Angle > -157 && Angle <= -112) ret = DI_UPLEFT; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdActor::GetHeight() { + // if no current sprite is set, set some + if (_currentSprite == NULL) { + if (_standSprite) _currentSprite = _standSprite->GetSprite(_dir); + else { + CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->GetSprite(_dir); + } + } + // and get height + return CAdTalkHolder::GetHeight(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet *CAdActor::GetAnimByName(const char *AnimName) { + if (!AnimName) return NULL; + + for (int i = 0; i < _anims.GetSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) return _anims[i]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + + byte *FileBuffer = Game->_fileManager->ReadWholeFile(AnimsFilename); + if (FileBuffer == NULL) { + Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); + return E_FAIL; + } + + byte *Buffer = FileBuffer; + byte *params; + int cmd; + CBParser parser(Game); + + HRESULT Ret = S_OK; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + if (!Anim || FAILED(Anim->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + Ret = E_FAIL; + } else _anims.Add(Anim); + } + break; + } + } + delete [] FileBuffer; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActor::PlayAnim(const char *Filename) { + // if we have an anim with this name, use it + CAdSpriteSet *Anim = GetAnimByName(Filename); + if (Anim) { + _animSprite2 = Anim->GetSprite(_dir); + if (_animSprite2) { + _animSprite2->Reset(); + _state = STATE_PLAYING_ANIM_SET; + return S_OK; + } + } + // otherwise call the standard handler + return CAdTalkHolder::PlayAnim(Filename); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h new file mode 100644 index 0000000000..cbe5e2161e --- /dev/null +++ b/engines/wintermute/Ad/AdActor.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADACTOR_H +#define WINTERMUTE_ADACTOR_H + + +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/Ad/AdTypes.h" // Added by ClassView +#include "engines/wintermute/Ad/AdTalkHolder.h" +#include "engines/wintermute/BPoint.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "common/str.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +namespace WinterMute { +class CAdSpriteSet; +class CAdPath; +class CAdActor : public CAdTalkHolder { +public: + TDirection AngleToDirection(int Angle); + DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) + virtual int GetHeight(); + CBSprite *GetTalkStance(const char *Stance); + virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); + CBPoint *_targetPoint; + virtual HRESULT Update(); + virtual HRESULT Display(); + TDirection _targetDir; + TDirection _afterWalkDir; + virtual void TurnTo(TDirection dir); + CAdPath *_path; + CAdSpriteSet *_walkSprite; + CAdSpriteSet *_standSprite; + CAdSpriteSet *_turnLeftSprite; + CAdSpriteSet *_turnRightSprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + TDirection _dir; + CAdActor(CBGame *inGame/*=NULL*/); + virtual ~CAdActor(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + // new anim system + char *_talkAnimName; + char *_idleAnimName; + char *_walkAnimName; + char *_turnLeftAnimName; + char *_turnRightAnimName; + CBArray _anims; + virtual HRESULT PlayAnim(const char *Filename); + CAdSpriteSet *GetAnimByName(const char *AnimName); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +private: + HRESULT SetDefaultAnimNames(); + CBSprite *GetTalkStanceOld(const char *Stance); + HRESULT MergeAnims(const char *AnimsFilename); + CBSprite *_animSprite2; + + void InitLine(CBPoint StartPt, CBPoint EndPt); + void GetNextStep(); + void FollowPath(); + double _pFStepX; + double _pFStepY; + double _pFX; + double _pFY; + int _pFCount; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/Ad/AdActorDir.cpp b/engines/wintermute/Ad/AdActorDir.cpp new file mode 100644 index 0000000000..d44cb3dc6d --- /dev/null +++ b/engines/wintermute/Ad/AdActorDir.cpp @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/Ad/AdActorDir.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActorDir, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActorDir::CAdActorDir(CBGame *inGame): CBBase(inGame) { +} + + +////////////////////////////////////////////////////////////////////////// +CAdActorDir::~CAdActorDir(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdActorDir::Persist(CBPersistMgr *PersistMgr) { + //PersistMgr->Transfer(TMEMBER(x)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdActorDir.h b/engines/wintermute/Ad/AdActorDir.h new file mode 100644 index 0000000000..6408c51ad9 --- /dev/null +++ b/engines/wintermute/Ad/AdActorDir.h @@ -0,0 +1,46 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADACTORDIR_H +#define WINTERMUTE_ADACTORDIR_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BBase.h" + +namespace WinterMute { + +class CAdActorDir : public CBBase { +public: + DECLARE_PERSISTENT(CAdActorDir, CBBase) + CAdActorDir(CBGame *inGame); + virtual ~CAdActorDir(void); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADACTORDIR_H diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp new file mode 100644 index 0000000000..1e492bbdca --- /dev/null +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -0,0 +1,977 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BActiveRect.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdEntity, false) + +////////////////////////////////////////////////////////////////////////// +CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { + _type = OBJECT_ENTITY; + _subtype = ENTITY_NORMAL; + _region = NULL; + _item = NULL; + + _walkToX = _walkToY = 0; + _walkToDir = DI_NONE; +} + + +////////////////////////////////////////////////////////////////////////// +CAdEntity::~CAdEntity() { + Game->UnregisterObject(_region); + + delete[] _item; + _item = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(CURSOR) +TOKEN_DEF(REGION) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_START_TIME) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(SOUND) +TOKEN_DEF(SUBTYPE) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ITEM) +TOKEN_DEF(WALK_TO_X) +TOKEN_DEF(WALK_TO_Y) +TOKEN_DEF(WALK_TO_DIR) +TOKEN_DEF(SAVE_STATE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(REGION) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_START_TIME) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(SUBTYPE) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(WALK_TO_X) + TOKEN_TABLE(WALK_TO_Y) + TOKEN_TABLE(WALK_TO_DIR) + TOKEN_TABLE(SAVE_STATE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + Game->LOG(0, "'ENTITY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CAdGame *AdGame = (CAdGame *)Game; + CBSprite *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SPRITE: { + delete _sprite; + _sprite = NULL; + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + break; + + case TOKEN_TALK: { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); + } + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_ITEM: + SetItem((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.ScanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.ScanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.ScanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.ScanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.ScanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &_active); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_REGION: { + if (_region) Game->UnregisterObject(_region); + _region = NULL; + CBRegion *rgn = new CBRegion(Game); + if (!rgn || FAILED(rgn->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + else { + _region = rgn; + Game->RegisterObject(_region); + } + } + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(Game); + CBRegion *crgn = new CBRegion(Game); + if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->Mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->Mimic(_wptGroup); + } + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_SUBTYPE: { + if (scumm_stricmp((char *)params, "sound") == 0) { + delete _sprite; + _sprite = NULL; + if (Game->_editorMode) { + spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + if (Game->_editorMode) _editorOnly = true; + _zoomable = false; + _rotatable = false; + _registrable = Game->_editorMode; + _shadowable = false; + _subtype = ENTITY_SOUND; + } + } + break; + + case TOKEN_SOUND: + PlaySFX((char *)params, false, false); + break; + + case TOKEN_SOUND_START_TIME: + parser.ScanStr((char *)params, "%d", &_sFXStart); + break; + + case TOKEN_SOUND_VOLUME: + parser.ScanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SOUND_PANNING: + parser.ScanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_SAVE_STATE: + parser.ScanStr((char *)params, "%b", &_saveState); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_IGNORE_ITEMS: + parser.ScanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_WALK_TO_X: + parser.ScanStr((char *)params, "%d", &_walkToX); + break; + + case TOKEN_WALK_TO_Y: + parser.ScanStr((char *)params, "%d", &_walkToY); + break; + + case TOKEN_WALK_TO_DIR: { + int i; + parser.ScanStr((char *)params, "%d", &i); + if (i < 0) i = 0; + if (i >= NUM_DIRECTIONS) i = DI_NONE; + _walkToDir = (TDirection)i; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ENTITY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ENTITY definition"); + if (spr) delete spr; + return E_FAIL; + } + + if (_region && _sprite) { + Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); + } + + UpdatePosition(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = DRGBA(ar, ag, ab, alpha); + _state = STATE_READY; + + if (_item && ((CAdGame *)Game)->IsItemTaken(_item)) _active = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Display() { + if (_active) { + UpdateSounds(); + + uint32 Alpha; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + float Rotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; + } else Rotate = 0.0f; + + + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; + + if (_region && (Reg || _editorAlwaysRegister)) { + Game->_renderer->_rectList.Add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); + } + + DisplaySpriteAttachments(true); + if (_currentSprite) { + _currentSprite->Display(_posX, + _posY, + (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); + } + DisplaySpriteAttachments(false); + + if (_partEmitter) _partEmitter->Display(_region); + + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) + _currentSprite = _sprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->Update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->Finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)Game)->AddSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); + } + } + break; + default: + error("AdEntity::Update - Unhandled enum"); + } + + + if (_currentSprite) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + } + } + + UpdateBlockRegion(); + _ready = (_state == STATE_READY); + + + UpdatePartEmitter(); + UpdateSpriteAttachments(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { + Stack->CorrectParams(0); + + if (FAILED(StopSFX(false))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTheoraPlaying") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeTheora") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPaused + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTheoraPaused") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // CreateRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateRegion") == 0) { + Stack->CorrectParams(0); + if (!_region) { + _region = new CBRegion(Game); + Game->RegisterObject(_region); + } + if (_region) Stack->PushNative(_region, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteRegion") == 0) { + Stack->CorrectParams(0); + if (_region) { + Game->UnregisterObject(_region); + _region = NULL; + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdEntity::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("entity"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Item") == 0) { + if (_item) _scValue->SetString(_item); + else _scValue->SetNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtype (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtype") == 0) { + if (_subtype == ENTITY_SOUND) + _scValue->SetString("sound"); + else + _scValue->SetString("normal"); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToX") == 0) { + _scValue->SetInt(_walkToX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToY") == 0) { + _scValue->SetInt(_walkToY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToDirection") == 0) { + _scValue->SetInt((int)_walkToDir); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Region (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Region") == 0) { + if (_region) _scValue->SetNative(_region, true); + else _scValue->SetNULL(); + return _scValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Item") == 0) { + SetItem(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToX") == 0) { + _walkToX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToY") == 0) { + _walkToY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WalkToDirection") == 0) { + int Dir = Value->GetInt(); + if (Dir >= 0 && Dir < NUM_DIRECTIONS) _walkToDir = (TDirection)Dir; + return S_OK; + } + + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdEntity::ScToString() { + return "[entity object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ENTITY {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + if (_subtype == ENTITY_SOUND) + Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_ignoreItems) + Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + if (_rotatable) + Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + + if (!_autoSoundPanning) + Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + + if (!_saveState) + Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + + if (_item && _item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); + + Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); + Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); + if (_walkToDir != DI_NONE) + Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + + int i; + + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) + Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + + if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); + } + + + if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + + if (D3DCOLGetA(_alphaColor) != 0) + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); + + if (_scale >= 0) + Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); + + if (_relativeScale != 0) + Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + CAdTalkHolder::SaveAsText(Buffer, Indent + 2); + + if (_region) _region->SaveAsText(Buffer, Indent + 2); + + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + + CAdObject::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdEntity::GetHeight() { + if (_region && !_sprite) { + return _region->_rect.bottom - _region->_rect.top; + } else { + if (_currentSprite == NULL) _currentSprite = _sprite; + return CAdObject::GetHeight(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::UpdatePosition() { + if (_region && !_sprite) { + _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; + _posY = _region->_rect.bottom; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_item)); + PersistMgr->Transfer(TMEMBER(_region)); + //PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER_INT(_subtype)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_walkToX)); + PersistMgr->Transfer(TMEMBER(_walkToY)); + PersistMgr->Transfer(TMEMBER_INT(_walkToDir)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::SetItem(const char *ItemName) { + CBUtils::SetString(&_item, ItemName); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdEntity::SetSprite(const char *Filename) { + bool SetCurrent = false; + if (_currentSprite == _sprite) { + _currentSprite = NULL; + SetCurrent = true; + } + + delete _sprite; + _sprite = NULL; + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + delete _sprite; + _sprite = NULL; + return E_FAIL; + } else { + _sprite = spr; + _currentSprite = _sprite; + return S_OK; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h new file mode 100644 index 0000000000..071ad5ee5d --- /dev/null +++ b/engines/wintermute/Ad/AdEntity.h @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADENTITY_H +#define WINTERMUTE_ADENTITY_H + +#include "engines/wintermute/Ad/AdTalkHolder.h" + +namespace WinterMute { + +class CAdEntity : public CAdTalkHolder { +public: + HRESULT SetSprite(const char *Filename); + int _walkToX; + int _walkToY; + TDirection _walkToDir; + void SetItem(const char *ItemName); + char *_item; + DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) + void UpdatePosition(); + virtual int GetHeight(); + CBRegion *_region; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Update(); + virtual HRESULT Display(); + CAdEntity(CBGame *inGame); + virtual ~CAdEntity(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + TEntityType _subtype; + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp new file mode 100644 index 0000000000..4de2e70dae --- /dev/null +++ b/engines/wintermute/Ad/AdGame.cpp @@ -0,0 +1,2060 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdResponseBox.h" +#include "engines/wintermute/Ad/AdInventoryBox.h" +#include "engines/wintermute/Ad/AdSceneState.h" +#include "engines/wintermute/PartEmitter.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BTransitionMgr.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/UIEntity.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Ad/AdActor.h" +#include "engines/wintermute/Ad/AdInventory.h" +#include "engines/wintermute/Ad/AdResponseContext.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Ad/AdResponse.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdGame, true) + +////////////////////////////////////////////////////////////////////////// +CAdGame::CAdGame(): CBGame() { + _responseBox = NULL; + _inventoryBox = NULL; + + _scene = new CAdScene(Game); + _scene->SetName(""); + RegisterObject(_scene); + + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _scheduledFadeIn = false; + + + _stateEx = GAME_NORMAL; + + _selectedItem = NULL; + + + _texItemLifeTime = 10000; + _texWalkLifeTime = 10000; + _texStandLifeTime = 10000; + _texTalkLifeTime = 10000; + + _talkSkipButton = TALK_SKIP_LEFT; + + _sceneViewport = NULL; + + _initialScene = true; + _debugStartupScene = NULL; + _startupScene = NULL; + + _invObject = new CAdObject(this); + _inventoryOwner = _invObject; + + _tempDisableSaveState = false; + _itemsFile = NULL; + + _smartItemCursor = false; + + AddSpeechDir("speech"); +} + + +////////////////////////////////////////////////////////////////////////// +CAdGame::~CAdGame() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::Cleanup() { + int i; + + for (i = 0; i < _objects.GetSize(); i++) { + UnregisterObject(_objects[i]); + _objects[i] = NULL; + } + _objects.RemoveAll(); + + + for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.RemoveAll(); + + for (i = 0; i < _speechDirs.GetSize(); i++) { + delete [] _speechDirs[i]; + } + _speechDirs.RemoveAll(); + + + UnregisterObject(_scene); + _scene = NULL; + + // remove items + for (i = 0; i < _items.GetSize(); i++) Game->UnregisterObject(_items[i]); + _items.RemoveAll(); + + + // clear remaining inventories + delete _invObject; + _invObject = NULL; + + for (i = 0; i < _inventories.GetSize(); i++) { + delete _inventories[i]; + } + _inventories.RemoveAll(); + + + if (_responseBox) { + Game->UnregisterObject(_responseBox); + _responseBox = NULL; + } + + if (_inventoryBox) { + Game->UnregisterObject(_inventoryBox); + _inventoryBox = NULL; + } + + delete[] _prevSceneName; + delete[] _prevSceneFilename; + delete[] _scheduledScene; + delete[] _debugStartupScene; + delete[] _itemsFile; + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _debugStartupScene = NULL; + _startupScene = NULL; + _itemsFile = NULL; + + delete _sceneViewport; + _sceneViewport = NULL; + + for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; + _sceneStates.RemoveAll(); + + for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); + + for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; + _responsesGame.RemoveAll(); + + return CBGame::Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::InitLoop() { + if (_scheduledScene && _transMgr->IsReady()) { + ChangeScene(_scheduledScene, _scheduledFadeIn); + delete[] _scheduledScene; + _scheduledScene = NULL; + + Game->_activeObject = NULL; + } + + + HRESULT res; + res = CBGame::InitLoop(); + if (FAILED(res)) return res; + + if (_scene) res = _scene->InitLoop(); + + _sentences.RemoveAll(); + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddObject(CAdObject *Object) { + _objects.Add(Object); + return RegisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RemoveObject(CAdObject *Object) { + // in case the user called Scene.CreateXXX() and Game.DeleteXXX() + if (_scene) { + HRESULT Res = _scene->RemoveObject(Object); + if (SUCCEEDED(Res)) return Res; + } + + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] == Object) { + _objects.RemoveAt(i); + break; + } + } + return UnregisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { + if (_scene == NULL) { + _scene = new CAdScene(Game); + RegisterObject(_scene); + } else { + _scene->ApplyEvent("SceneShutdown", true); + + SetPrevSceneName(_scene->_name); + SetPrevSceneFilename(_scene->_filename); + + if (!_tempDisableSaveState) _scene->SaveState(); + _tempDisableSaveState = false; + } + + if (_scene) { + // reset objects + for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->Reset(); + + // reset scene properties + _scene->_sFXVolume = 100; + if (_scene->_scProp) _scene->_scProp->Cleanup(); + + HRESULT ret; + if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { + _initialScene = false; + ret = _scene->LoadFile(_debugStartupScene); + } else ret = _scene->LoadFile(Filename); + + if (SUCCEEDED(ret)) { + // invalidate references to the original scene + for (int i = 0; i < _objects.GetSize(); i++) { + _objects[i]->InvalidateCurrRegions(); + _objects[i]->_stickRegion = NULL; + } + + _scene->LoadState(); + } + if (FadeIn) Game->_transMgr->Start(TRANSITION_FADE_IN); + return ret; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::AddSentence(CAdSentence *Sentence) { + _sentences.Add(Sentence); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplaySentences(bool Frozen) { + for (int i = 0; i < _sentences.GetSize(); i++) { + if (Frozen && _sentences[i]->_freezable) continue; + else _sentences[i]->Display(); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::FinishSentences() { + for (int i = 0; i < _sentences.GetSize(); i++) { + if (_sentences[i]->CanSkip()) { + _sentences[i]->_duration = 0; + if (_sentences[i]->_sound) _sentences[i]->_sound->Stop(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // ChangeScene + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "ChangeScene") == 0) { + Stack->CorrectParams(3); + const char *Filename = Stack->Pop()->GetString(); + CScValue *valFadeOut = Stack->Pop(); + CScValue *valFadeIn = Stack->Pop(); + + bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); + bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); + + ScheduleChangeScene(Filename, TransIn); + if (TransOut) _transMgr->Start(TRANSITION_FADE_OUT, true); + Stack->PushNULL(); + + + //HRESULT ret = ChangeScene(Stack->Pop()->GetString()); + //if(FAILED(ret)) Stack->PushBool(false); + //else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadActor") == 0) { + Stack->CorrectParams(1); + CAdActor *act = new CAdActor(Game); + if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + AddObject(act); + Stack->PushNative(act, true); + } else { + delete act; + act = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadEntity") == 0) { + Stack->CorrectParams(1); + CAdEntity *ent = new CAdEntity(Game); + if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + AddObject(ent); + Stack->PushNative(ent, true); + } else { + delete ent; + ent = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "DeleteEntity") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CAdObject *obj = (CAdObject *)val->GetNative(); + RemoveObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdEntity *Ent = new CAdEntity(Game); + AddObject(Ent); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = new CAdItem(Game); + AddItem(Item); + if (!Val->IsNULL()) Item->SetName(Val->GetString()); + Stack->PushNative(Item, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = NULL; + if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); + else Item = GetItemByName(Val->GetString()); + + if (Item) { + DeleteItem(Item); + } + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QueryItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "QueryItem") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdItem *Item = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + if (Index >= 0 && Index < _items.GetSize()) Item = _items[Index]; + } else { + Item = GetItemByName(Val->GetString()); + } + + if (Item) Stack->PushNative(Item, true); + else Stack->PushNULL(); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // AddResponse/AddResponseOnce/AddResponseOnceGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddResponse") == 0 || strcmp(Name, "AddResponseOnce") == 0 || strcmp(Name, "AddResponseOnceGame") == 0) { + Stack->CorrectParams(6); + int id = Stack->Pop()->GetInt(); + const char *text = Stack->Pop()->GetString(); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + CScValue *val3 = Stack->Pop(); + CScValue *val4 = Stack->Pop(); + + if (_responseBox) { + CAdResponse *res = new CAdResponse(Game); + if (res) { + res->_iD = id; + res->SetText(text); + _stringTable->Expand(&res->_text); + if (!val1->IsNULL()) res->SetIcon(val1->GetString()); + if (!val2->IsNULL()) res->SetIconHover(val2->GetString()); + if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); + if (!val4->IsNULL()) res->SetFont(val4->GetString()); + + if (strcmp(Name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; + else if (strcmp(Name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; + + _responseBox->_responses.Add(res); + } + } else { + Script->RuntimeError("Game.AddResponse: response box is not defined"); + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResetResponse") == 0) { + Stack->CorrectParams(1); + int ID = Stack->Pop()->GetInt(-1); + ResetResponse(ID); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClearResponses") == 0) { + Stack->CorrectParams(0); + _responseBox->ClearResponses(); + _responseBox->ClearButtons(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetResponse") == 0) { + Stack->CorrectParams(1); + bool AutoSelectLast = Stack->Pop()->GetBool(); + + if (_responseBox) { + _responseBox->WeedResponses(); + + if (_responseBox->_responses.GetSize() == 0) { + Stack->PushNULL(); + return S_OK; + } + + + if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { + Stack->PushInt(_responseBox->_responses[0]->_iD); + _responseBox->HandleResponse(_responseBox->_responses[0]); + _responseBox->ClearResponses(); + return S_OK; + } + + _responseBox->CreateButtons(); + _responseBox->_waitingScript = Script; + Script->WaitForExclusive(_responseBox); + _state = GAME_SEMI_FROZEN; + _stateEx = GAME_WAITING_RESPONSE; + } else { + Script->RuntimeError("Game.GetResponse: response box is not defined"); + Stack->PushNULL(); + } + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // GetNumResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNumResponses") == 0) { + Stack->CorrectParams(0); + if (_responseBox) { + _responseBox->WeedResponses(); + Stack->PushInt(_responseBox->_responses.GetSize()); + } else { + Script->RuntimeError("Game.GetNumResponses: response box is not defined"); + Stack->PushNULL(); + } + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // StartDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartDlgBranch") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + Common::String BranchName; + if (Val->IsNULL()) { + BranchName.format("line%d", Script->_currentLine); + } else BranchName = Val->GetString(); + + StartDlgBranch(BranchName.c_str(), Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EndDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EndDlgBranch") == 0) { + Stack->CorrectParams(1); + + const char *BranchName = NULL; + CScValue *Val = Stack->Pop(); + if (!Val->IsNULL()) BranchName = Val->GetString(); + EndDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); + + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCurrentDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCurrentDlgBranch") == 0) { + Stack->CorrectParams(0); + + if (_dlgPendingBranches.GetSize() > 0) { + Stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TakeItem") == 0) { + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DropItem") == 0) { + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetItem") == 0) { + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasItem") == 0) { + return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + } + + ////////////////////////////////////////////////////////////////////////// + // IsItemTaken + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsItemTaken") == 0) { + Stack->CorrectParams(1); + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + for (int i = 0; i < _inventories.GetSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + if (val->GetNative() == Inv->_takenItems[j]) { + Stack->PushBool(true); + return S_OK; + } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { + Stack->PushBool(true); + return S_OK; + } + } + } + } else Script->RuntimeError("Game.IsItemTaken: item name expected"); + + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInventoryWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInventoryWindow") == 0) { + Stack->CorrectParams(0); + if (_inventoryBox && _inventoryBox->_window) + Stack->PushNative(_inventoryBox->_window, true); + else + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponsesWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetResponsesWindow") == 0 || strcmp(Name, "GetResponseWindow") == 0) { + Stack->CorrectParams(0); + if (_responseBox && _responseBox->_window) + Stack->PushNative(_responseBox->_window, true); + else + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadResponseBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadResponseBox") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + + Game->UnregisterObject(_responseBox); + _responseBox = new CAdResponseBox(Game); + if (_responseBox && !FAILED(_responseBox->LoadFile(Filename))) { + RegisterObject(_responseBox); + Stack->PushBool(true); + } else { + delete _responseBox; + _responseBox = NULL; + Stack->PushBool(false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadInventoryBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadInventoryBox") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + + Game->UnregisterObject(_inventoryBox); + _inventoryBox = new CAdInventoryBox(Game); + if (_inventoryBox && !FAILED(_inventoryBox->LoadFile(Filename))) { + RegisterObject(_inventoryBox); + Stack->PushBool(true); + } else { + delete _inventoryBox; + _inventoryBox = NULL; + Stack->PushBool(false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadItems") == 0) { + Stack->CorrectParams(2); + const char *Filename = Stack->Pop()->GetString(); + bool Merge = Stack->Pop()->GetBool(false); + + HRESULT Ret = LoadItemsFile(Filename, Merge); + Stack->PushBool(SUCCEEDED(Ret)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSpeechDir") == 0) { + Stack->CorrectParams(1); + const char *Dir = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveSpeechDir") == 0) { + Stack->CorrectParams(1); + const char *Dir = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSceneViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSceneViewport") == 0) { + Stack->CorrectParams(4); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + int Width = Stack->Pop()->GetInt(); + int Height = Stack->Pop()->GetInt(); + + if (Width <= 0) Width = _renderer->_width; + if (Height <= 0) Height = _renderer->_height; + + if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (_sceneViewport) _sceneViewport->SetRect(X, Y, X + Width, Y + Height); + + Stack->PushBool(true); + + return S_OK; + } + + + else return CBGame::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdGame::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scene") == 0) { + if (_scene) _scValue->SetNative(_scene, true); + else _scValue->SetNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelectedItem") == 0) { + //if(_selectedItem) _scValue->SetString(_selectedItem->_name); + if (_selectedItem) _scValue->SetNative(_selectedItem, true); + else _scValue->SetNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumItems") == 0) { + return _invObject->ScGetProperty(Name); + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SmartItemCursor") == 0) { + _scValue->SetBool(_smartItemCursor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryVisible") == 0) { + _scValue->SetBool(_inventoryBox && _inventoryBox->_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _scValue->SetInt(_inventoryBox->_scrollOffset); + else _scValue->SetInt(0); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ResponsesVisible (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResponsesVisible") == 0) { + _scValue->SetBool(_stateEx == GAME_WAITING_RESPONSE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevScene / PreviousScene (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PrevScene") == 0 || strcmp(Name, "PreviousScene") == 0) { + if (!_prevSceneName) _scValue->SetString(""); + else _scValue->SetString(_prevSceneName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevSceneFilename / PreviousSceneFilename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PrevSceneFilename") == 0 || strcmp(Name, "PreviousSceneFilename") == 0) { + if (!_prevSceneFilename) _scValue->SetString(""); + else _scValue->SetString(_prevSceneFilename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponse (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LastResponse") == 0) { + if (!_responseBox || !_responseBox->_lastResponseText) _scValue->SetString(""); + else _scValue->SetString(_responseBox->_lastResponseText); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponseOrig (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LastResponseOrig") == 0) { + if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->SetString(""); + else _scValue->SetString(_responseBox->_lastResponseTextOrig); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryObject") == 0) { + if (_inventoryOwner == _invObject) _scValue->SetNative(this, true); + else _scValue->SetNative(_inventoryOwner, true); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TotalNumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TotalNumItems") == 0) { + _scValue->SetInt(_items.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkSkipButton") == 0) { + _scValue->SetInt(_talkSkipButton); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ChangingScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ChangingScene") == 0) { + _scValue->SetBool(_scheduledScene != NULL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartupScene") == 0) { + if (!_startupScene) _scValue->SetNULL(); + else _scValue->SetString(_startupScene); + return _scValue; + } + + else return CBGame::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScSetProperty(const char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SelectedItem") == 0) { + if (Value->IsNULL()) _selectedItem = NULL; + else { + if (Value->IsNative()) { + _selectedItem = NULL; + for (int i = 0; i < _items.GetSize(); i++) { + if (_items[i] == Value->GetNative()) { + _selectedItem = (CAdItem *)Value->GetNative(); + break; + } + } + } else { + // try to get by name + _selectedItem = GetItemByName(Value->GetString()); + } + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SmartItemCursor") == 0) { + _smartItemCursor = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryVisible") == 0) { + if (_inventoryBox) _inventoryBox->_visible = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryObject") == 0) { + if (_inventoryOwner && _inventoryBox) _inventoryOwner->GetInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + + if (Value->IsNULL()) _inventoryOwner = _invObject; + else { + CBObject *Obj = (CBObject *)Value->GetNative(); + if (Obj == this) _inventoryOwner = _invObject; + else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + } + + if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->GetInventory()->_scrollOffset; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _inventoryBox->_scrollOffset = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TalkSkipButton") == 0) { + int Val = Value->GetInt(); + if (Val < 0) Val = 0; + if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; + _talkSkipButton = (TTalkSkipButton)Val; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StartupScene") == 0) { + if (Value == NULL) { + delete[] _startupScene; + _startupScene = NULL; + } else CBUtils::SetString(&_startupScene, Value->GetString()); + + return S_OK; + } + + else return CBGame::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::PublishNatives() { + if (!_scEngine || !_scEngine->_compilerAvailable) return; + + CBGame::PublishNatives(); + + _scEngine->ExtDefineFunction("Actor"); + _scEngine->ExtDefineFunction("Entity"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // Actor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Actor") == 0) { + Stack->CorrectParams(0); + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CAdActor(Game)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Entity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Entity") == 0) { + Stack->CorrectParams(0); + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CAdEntity(Game)); + Stack->PushNULL(); + } + + + ////////////////////////////////////////////////////////////////////////// + // call parent + else return CBGame::ExternalCall(Script, Stack, ThisStack, Name); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ShowCursor() { + if (_cursorHidden) return S_OK; + + if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem->_cursorCombined) { + CBSprite *OrigLastCursor = _lastCursor; + CBGame::ShowCursor(); + _lastCursor = OrigLastCursor; + } + if (_activeObject && _selectedItem->_cursorHover && _activeObject->GetExtendedFlag("usable")) { + if (!_smartItemCursor || _activeObject->CanHandleEvent(_selectedItem->_name)) + return DrawCursor(_selectedItem->_cursorHover); + else + return DrawCursor(_selectedItem->_cursorNormal); + } else return DrawCursor(_selectedItem->_cursorNormal); + } else return CBGame::ShowCursor(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadFile(const char *Filename) { + byte *Buffer = _fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(AD_GAME) +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(ITEMS) +TOKEN_DEF(ITEM) +TOKEN_DEF(TALK_SKIP_BUTTON) +TOKEN_DEF(SCENE_VIEWPORT) +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(STARTUP_SCENE) +TOKEN_DEF(DEBUG_STARTUP_SCENE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(AD_GAME) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(ITEMS) + TOKEN_TABLE(TALK_SKIP_BUTTON) + TOKEN_TABLE(SCENE_VIEWPORT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(STARTUP_SCENE) + TOKEN_TABLE(DEBUG_STARTUP_SCENE) + TOKEN_TABLE_END + + byte *params; + byte *params2; + int cmd = 1; + CBParser parser(Game); + + bool ItemFound = false, ItemsFound = false; + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + if (FAILED(CBGame::LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AD_GAME: + while (cmd > 0 && (cmd = parser.GetCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + switch (cmd) { + case TOKEN_RESPONSE_BOX: + delete _responseBox; + _responseBox = new CAdResponseBox(Game); + if (_responseBox && !FAILED(_responseBox->LoadFile((char *)params2))) + RegisterObject(_responseBox); + else { + delete _responseBox; + _responseBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_INVENTORY_BOX: + delete _inventoryBox; + _inventoryBox = new CAdInventoryBox(Game); + if (_inventoryBox && !FAILED(_inventoryBox->LoadFile((char *)params2))) + RegisterObject(_inventoryBox); + else { + delete _inventoryBox; + _inventoryBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ITEMS: + ItemsFound = true; + CBUtils::SetString(&_itemsFile, (char *)params2); + if (FAILED(LoadItemsFile(_itemsFile))) { + delete[] _itemsFile; + _itemsFile = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_TALK_SKIP_BUTTON: + if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; + else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; + else _talkSkipButton = TALK_SKIP_LEFT; + break; + + case TOKEN_SCENE_VIEWPORT: { + RECT rc; + parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (_sceneViewport) _sceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params2, false); + break; + + case TOKEN_STARTUP_SCENE: + CBUtils::SetString(&_startupScene, (char *)params2); + break; + + case TOKEN_DEBUG_STARTUP_SCENE: + CBUtils::SetString(&_debugStartupScene, (char *)params2); + break; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in GAME definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading GAME definition"); + return E_FAIL; + } + + if (ItemFound && !ItemsFound) { + Game->LOG(0, "**Warning** Please put the items definition to a separate file."); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->_saving) Cleanup(); + CBGame::Persist(PersistMgr); + + _dlgPendingBranches.Persist(PersistMgr); + + _inventories.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_inventoryBox)); + + _objects.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_prevSceneName)); + PersistMgr->Transfer(TMEMBER(_prevSceneFilename)); + + PersistMgr->Transfer(TMEMBER(_responseBox)); + _responsesBranch.Persist(PersistMgr); + _responsesGame.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scene)); + _sceneStates.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scheduledFadeIn)); + PersistMgr->Transfer(TMEMBER(_scheduledScene)); + PersistMgr->Transfer(TMEMBER(_selectedItem)); + PersistMgr->Transfer(TMEMBER_INT(_talkSkipButton)); + + _sentences.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_sceneViewport)); + PersistMgr->Transfer(TMEMBER_INT(_stateEx)); + PersistMgr->Transfer(TMEMBER(_initialScene)); + PersistMgr->Transfer(TMEMBER(_debugStartupScene)); + + PersistMgr->Transfer(TMEMBER(_invObject)); + PersistMgr->Transfer(TMEMBER(_inventoryOwner)); + PersistMgr->Transfer(TMEMBER(_tempDisableSaveState)); + _items.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_itemsFile)); + + _speechDirs.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_smartItemCursor)); + + if (!PersistMgr->_saving) _initialScene = false; + + PersistMgr->Transfer(TMEMBER(_startupScene)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadGame(const char *Filename) { + HRESULT ret = CBGame::LoadGame(Filename); + if (SUCCEEDED(ret)) CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CAdRegion", NULL); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::InitAfterLoad() { + CBGame::InitAfterLoad(); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScene, "CAdScene", NULL); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdGame::AfterLoadScene(void *Scene, void *Data) { + ((CAdScene *)Scene)->AfterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::SetPrevSceneName(const char *Name) { + delete[] _prevSceneName; + _prevSceneName = NULL; + if (Name) { + _prevSceneName = new char[strlen(Name) + 1]; + if (_prevSceneName) strcpy(_prevSceneName, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::SetPrevSceneFilename(const char *Name) { + delete[] _prevSceneFilename; + _prevSceneFilename = NULL; + if (Name) { + _prevSceneFilename = new char[strlen(Name) + 1]; + if (_prevSceneFilename) strcpy(_prevSceneFilename, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ScheduleChangeScene(const char *Filename, bool FadeIn) { + delete[] _scheduledScene; + _scheduledScene = NULL; + + if (_scene && !_scene->_initialized) return ChangeScene(Filename, FadeIn); + else { + _scheduledScene = new char [strlen(Filename) + 1]; + strcpy(_scheduledScene, Filename); + + _scheduledFadeIn = FadeIn; + + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { + CBGame::GetVersion(VerMajor, VerMinor, NULL, NULL); + + if (ExtMajor) *ExtMajor = 0; + if (ExtMinor) *ExtMinor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadItemsFile(const char *Filename, bool Merge) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + //_filename = new char [strlen(Filename)+1]; + //strcpy(_filename, Filename); + + if (FAILED(ret = LoadItemsBuffer(Buffer, Merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (!Merge) { + while (_items.GetSize() > 0) DeleteItem(_items[0]); + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ITEM: { + CAdItem *item = new CAdItem(Game); + if (item && !FAILED(item->LoadBuffer(params, false))) { + // delete item with the same name, if exists + if (Merge) { + CAdItem *PrevItem = GetItemByName(item->_name); + if (PrevItem) DeleteItem(PrevItem); + } + AddItem(item); + } else { + delete item; + item = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ITEMS definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ITEMS definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { + char *FilenameCor = new char[strlen(Filename) + 1]; + strcpy(FilenameCor, Filename); + for (int i = 0; i < strlen(FilenameCor); i++) { + if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; + } + + for (int i = 0; i < _sceneStates.GetSize(); i++) { + if (scumm_stricmp(_sceneStates[i]->_filename, FilenameCor) == 0) { + delete [] FilenameCor; + return _sceneStates[i]; + } + } + + if (Saving) { + CAdSceneState *ret = new CAdSceneState(Game); + ret->SetFilename(FilenameCor); + + _sceneStates.Add(ret); + + delete [] FilenameCor; + return ret; + } else { + delete [] FilenameCor; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE_END + + int cmd = PARSERR_GENERIC; + CBParser parser(Game); + + cmd = parser.GetCommand(Buffer, commands, params); + switch (cmd) { + case TOKEN_ENTITY_CONTAINER: { + CUIEntity *ent = new CUIEntity(Game); + if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { + delete ent; + ent = NULL; + cmd = PARSERR_GENERIC; + } else { + ent->_parent = Win; + Win->_widgets.Add(ent); + } + } + break; + } + + if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { + return E_FAIL; + } + + return S_OK; + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { + if (strcmp(Name, "CreateEntityContainer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIEntity *Ent = new CUIEntity(Game); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + + Ent->_parent = Win; + Win->_widgets.Add(Ent); + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { + char *Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (Name) { + sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); + _dlgPendingBranches.Add(Name); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { + char *Name = NULL; + bool DeleteName = false; + if (BranchName == NULL && _dlgPendingBranches.GetSize() > 0) { + Name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; + } else { + if (BranchName != NULL) { + Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (Name) { + sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); + DeleteName = true; + } + } + } + + if (Name == NULL) return S_OK; + + + int StartIndex = -1; + int i; + for (i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { + if (scumm_stricmp(Name, _dlgPendingBranches[i]) == 0) { + StartIndex = i; + break; + } + } + if (StartIndex >= 0) { + for (i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { + //ClearBranchResponses(_dlgPendingBranches[i]); + delete [] _dlgPendingBranches[i]; + _dlgPendingBranches[i] = NULL; + } + _dlgPendingBranches.RemoveAt(StartIndex, _dlgPendingBranches.GetSize() - StartIndex); + } + + // dialogue is over, forget selected responses + if (_dlgPendingBranches.GetSize() == 0) { + for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); + } + + if (DeleteName) delete [] Name; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ClearBranchResponses(char *Name) { + for (int i = 0; i < _responsesBranch.GetSize(); i++) { + if (scumm_stricmp(Name, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.RemoveAt(i); + i--; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddBranchResponse(int ID) { + if (BranchResponseUsed(ID)) return S_OK; + CAdResponseContext *r = new CAdResponseContext(Game); + r->_iD = ID; + r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + _responsesBranch.Add(r); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::BranchResponseUsed(int ID) { + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < _responsesBranch.GetSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddGameResponse(int ID) { + if (GameResponseUsed(ID)) return S_OK; + CAdResponseContext *r = new CAdResponseContext(Game); + r->_iD = ID; + r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + _responsesGame.Add(r); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::GameResponseUsed(int ID) { + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + for (int i = 0; i < _responsesGame.GetSize(); i++) { + CAdResponseContext *RespContext = _responsesGame[i]; + if (RespContext->_iD == ID) { + if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ResetResponse(int ID) { + char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + + int i; + + for (i = 0; i < _responsesGame.GetSize(); i++) { + if (_responsesGame[i]->_iD == ID) { + if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { + delete _responsesGame[i]; + _responsesGame.RemoveAt(i); + break; + } + } + } + + for (i = 0; i < _responsesBranch.GetSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.RemoveAt(i); + break; + } + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { + // init + if (Update) InitLoop(); + + // fill black + _renderer->Fill(0, 0, 0); + if (!_editorMode) _renderer->SetScreenViewport(); + + // process scripts + if (Update) _scEngine->Tick(); + + POINT p; + GetMousePos(&p); + + _scene->Update(); + _scene->Display(); + + + // display in-game windows + DisplayWindows(true); + if (_inventoryBox) _inventoryBox->Display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); + if (_indicatorDisplay) DisplayIndicator(); + + + if (Update || DisplayAll) { + // display normal windows + DisplayWindows(false); + + SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); + + // textual info + DisplaySentences(_state == GAME_FROZEN); + + ShowCursor(); + + if (_fader) _fader->Display(); + _transMgr->Update(); + } + + + if (_loadingIcon) { + _loadingIcon->Display(_loadingIconX, _loadingIconY); + if (!_loadingIconPersistent) { + delete _loadingIcon; + _loadingIcon = NULL; + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RegisterInventory(CAdInventory *Inv) { + for (int i = 0; i < _inventories.GetSize(); i++) { + if (_inventories[i] == Inv) return S_OK; + } + RegisterObject(Inv); + _inventories.Add(Inv); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { + for (int i = 0; i < _inventories.GetSize(); i++) { + if (_inventories[i] == Inv) { + UnregisterObject(_inventories[i]); + _inventories.RemoveAt(i); + return S_OK; + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::IsItemTaken(char *ItemName) { + int i; + + for (i = 0; i < _inventories.GetSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + if (scumm_stricmp(ItemName, Inv->_takenItems[j]->_name) == 0) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +CAdItem *CAdGame::GetItemByName(const char *Name) { + for (int i = 0; i < _items.GetSize(); i++) { + if (scumm_stricmp(_items[i]->_name, Name) == 0) return _items[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddItem(CAdItem *Item) { + _items.Add(Item); + return Game->RegisterObject(Item); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::ResetContent() { + int i; + + // clear pending dialogs + for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.RemoveAll(); + + + // clear inventories + for (i = 0; i < _inventories.GetSize(); i++) { + _inventories[i]->_takenItems.RemoveAll(); + } + + // clear scene states + for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; + _sceneStates.RemoveAll(); + + // clear once responses + for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + _responsesBranch.RemoveAll(); + + // clear once game responses + for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; + _responsesGame.RemoveAll(); + + // reload inventory items + if (_itemsFile) LoadItemsFile(_itemsFile); + + _tempDisableSaveState = true; + + return CBGame::ResetContent(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DeleteItem(CAdItem *Item) { + if (!Item) return E_FAIL; + + if (_selectedItem == Item) _selectedItem = NULL; + _scene->HandleItemAssociations(Item->_name, false); + + // remove from all inventories + for (int i = 0; i < _inventories.GetSize(); i++) { + _inventories[i]->RemoveItem(Item); + } + + // remove object + for (int i = 0; i < _items.GetSize(); i++) { + if (_items[i] == Item) { + UnregisterObject(_items[i]); + _items.RemoveAt(i); + break; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::AddSpeechDir(const char *Dir) { + if (!Dir || Dir[0] == '\0') return E_FAIL; + + char *Temp = new char[strlen(Dir) + 2]; + strcpy(Temp, Dir); + if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') + strcat(Temp, "\\"); + + for (int i = 0; i < _speechDirs.GetSize(); i++) { + if (scumm_stricmp(_speechDirs[i], Temp) == 0) { + delete [] Temp; + return S_OK; + } + } + _speechDirs.Add(Temp); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::RemoveSpeechDir(const char *Dir) { + if (!Dir || Dir[0] == '\0') return E_FAIL; + + char *Temp = new char[strlen(Dir) + 2]; + strcpy(Temp, Dir); + if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') + strcat(Temp, "\\"); + + bool Found = false; + for (int i = 0; i < _speechDirs.GetSize(); i++) { + if (scumm_stricmp(_speechDirs[i], Temp) == 0) { + delete [] _speechDirs[i]; + _speechDirs.RemoveAt(i); + Found = true; + break; + } + } + delete [] Temp; + + if (Found) return S_OK; + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdGame::FindSpeechFile(char *StringID) { + char *Ret = new char[MAX_PATH]; + + for (int i = 0; i < _speechDirs.GetSize(); i++) { + sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); + CBFile *File = _fileManager->OpenFile(Ret); + if (File) { + _fileManager->CloseFile(File); + return Ret; + } + + sprintf(Ret, "%s%s.wav", _speechDirs[i], StringID); + File = _fileManager->OpenFile(Ret); + if (File) { + _fileManager->CloseFile(File); + return Ret; + } + } + delete [] Ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::ValidMouse() { + POINT Pos; + CBPlatform::GetCursorPos(&Pos); + + return _renderer->PointInViewport(&Pos); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftDown() { + if (!ValidMouse()) return S_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { + FinishSentences(); + } + return S_OK; + } + + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; + _mouseLeftDown = true; + CBPlatform::SetCapture(_renderer->_window); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftUp() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::ReleaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseLeftDblClick() { + if (!ValidMouse()) return S_OK; + + if (_state == GAME_RUNNING && !_interactive) return S_OK; + + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftDoubleClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("LeftDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseRightDown() { + if (!ValidMouse()) return S_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { + FinishSentences(); + } + return S_OK; + } + + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return S_OK; + + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("RightClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnMouseRightUp() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + _scene->ApplyEvent("RightRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::DisplayDebugInfo() { + char str[100]; + if (Game->_dEBUG_DebugMode) { + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->GetOffsetLeft(), _mousePos.y + _scene->GetOffsetTop()); + _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + + sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); + _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + } + return CBGame::DisplayDebugInfo(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdGame::OnScriptShutdown(CScScript *Script) { + if (_responseBox && _responseBox->_waitingScript == Script) + _responseBox->_waitingScript = NULL; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h new file mode 100644 index 0000000000..8c146d1af3 --- /dev/null +++ b/engines/wintermute/Ad/AdGame.h @@ -0,0 +1,162 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_ADGAME_H +#define WINTERMUTE_ADGAME_H + +#include "engines/wintermute/Ad/AdTypes.h" +#include "engines/wintermute/BGame.h" + +namespace WinterMute { +class CAdItem; +class CAdInventory; +class CAdSceneState; +class CAdScene; +class CAdItem; +class CAdObject; +class CAdSentence; +class CAdInventoryBox; +class CAdResponseContext; +class CAdResponseBox; +class CAdGame : public CBGame { +public: + virtual HRESULT OnScriptShutdown(CScScript *Script); + + virtual HRESULT OnMouseLeftDown(); + virtual HRESULT OnMouseLeftUp(); + virtual HRESULT OnMouseLeftDblClick(); + virtual HRESULT OnMouseRightDown(); + virtual HRESULT OnMouseRightUp(); + + virtual HRESULT DisplayDebugInfo(); + + + virtual HRESULT InitAfterLoad(); + static void AfterLoadScene(void *Scene, void *Data); + + bool _smartItemCursor; + + CBArray _speechDirs; + HRESULT AddSpeechDir(const char *Dir); + HRESULT RemoveSpeechDir(const char *Dir); + char *FindSpeechFile(char *StringID); + + HRESULT DeleteItem(CAdItem *Item); + char *_itemsFile; + bool _tempDisableSaveState; + virtual HRESULT ResetContent(); + HRESULT AddItem(CAdItem *Item); + CAdItem *GetItemByName(const char *Name); + CBArray _items; + CAdObject *_inventoryOwner; + bool IsItemTaken(char *ItemName); + HRESULT RegisterInventory(CAdInventory *Inv); + HRESULT UnregisterInventory(CAdInventory *Inv); + + CAdObject *_invObject; + CBArray _inventories; + virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); + char *_debugStartupScene; + char *_startupScene; + bool _initialScene; + bool GameResponseUsed(int ID); + HRESULT AddGameResponse(int ID); + HRESULT ResetResponse(int ID); + + bool BranchResponseUsed(int ID); + HRESULT AddBranchResponse(int ID); + HRESULT ClearBranchResponses(char *Name); + HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); + HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); + virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); + + CAdSceneState *GetSceneState(const char *Filename, bool Saving); + CBViewport *_sceneViewport; + int _texItemLifeTime; + int _texWalkLifeTime; + int _texStandLifeTime; + int _texTalkLifeTime; + + TTalkSkipButton _talkSkipButton; + + virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); + HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); + char *_scheduledScene; + bool _scheduledFadeIn; + void SetPrevSceneName(const char *Name); + void SetPrevSceneFilename(const char *Name); + char *_prevSceneName; + char *_prevSceneFilename; + virtual HRESULT LoadGame(const char *Filename); + CAdItem *_selectedItem; + HRESULT Cleanup(); + DECLARE_PERSISTENT(CAdGame, CBGame) + + void FinishSentences(); + HRESULT ShowCursor(); + TGameStateEx _stateEx; + CAdResponseBox *_responseBox; + CAdInventoryBox *_inventoryBox; + HRESULT DisplaySentences(bool Frozen); + void AddSentence(CAdSentence *Sentence); + HRESULT ChangeScene(const char *Filename, bool FadeIn); + HRESULT RemoveObject(CAdObject *Object); + HRESULT AddObject(CAdObject *Object); + CAdScene *_scene; + HRESULT InitLoop(); + CAdGame(); + virtual ~CAdGame(); + CBArray _objects; + CBArray _sentences; + + CBArray _sceneStates; + CBArray _dlgPendingBranches; + + CBArray _responsesBranch; + CBArray _responsesGame; + + virtual HRESULT LoadFile(const char *Filename); + virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + HRESULT LoadItemsFile(const char *Filename, bool Merge = false); + HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); + + + virtual void PublishNatives(); + virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + bool ValidMouse(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp new file mode 100644 index 0000000000..693f09bcf6 --- /dev/null +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -0,0 +1,119 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdInventory.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventory, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { + _scrollOffset = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventory::~CAdInventory() { + _takenItems.RemoveAll(); // ref only +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::InsertItem(const char *Name, const char *InsertAfter) { + if (Name == NULL) return E_FAIL; + + CAdItem *item = ((CAdGame *)Game)->GetItemByName(Name); + if (item == NULL) return E_FAIL; + + int InsertIndex = -1; + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + _takenItems.RemoveAt(i); + i--; + continue; + } + if (InsertAfter && scumm_stricmp(_takenItems[i]->_name, InsertAfter) == 0) InsertIndex = i + 1; + } + + + if (InsertIndex == -1) _takenItems.Add(item); + else _takenItems.InsertAt(InsertIndex, item); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::RemoveItem(const char *Name) { + if (Name == NULL) return E_FAIL; + + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + _takenItems.RemoveAt(i); + return S_OK; + } + } + + return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::RemoveItem(CAdItem *Item) { + if (Item == NULL) return E_FAIL; + + for (int i = 0; i < _takenItems.GetSize(); i++) { + if (_takenItems[i] == Item) { + if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + _takenItems.RemoveAt(i); + return S_OK; + } + } + + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + _takenItems.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h new file mode 100644 index 0000000000..b6f0c6399a --- /dev/null +++ b/engines/wintermute/Ad/AdInventory.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORY_H +#define WINTERMUTE_ADINVENTORY_H + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CAdItem; + +class CAdInventory : public CBObject { +public: + DECLARE_PERSISTENT(CAdInventory, CBObject) + HRESULT RemoveItem(const char *Name); + HRESULT RemoveItem(CAdItem *Item); + HRESULT InsertItem(const char *Name, const char *InsertAfter = NULL); + CAdInventory(CBGame *inGame); + virtual ~CAdInventory(); + CBArray _takenItems; + int _scrollOffset; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp new file mode 100644 index 0000000000..5de9f54493 --- /dev/null +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -0,0 +1,373 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdInventoryBox.h" +#include "engines/wintermute/Ad/AdInventory.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/UIButton.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +//#include + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventoryBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { + CBPlatform::SetRectEmpty(&_itemsArea); + _scrollOffset = 0; + _spacing = 0; + _itemWidth = _itemHeight = 50; + _scrollBy = 1; + + _window = NULL; + _closeButton = NULL; + + _hideSelected = false; + + _visible = false; + _exclusive = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::~CAdInventoryBox() { + Game->UnregisterObject(_window); + _window = NULL; + + delete _closeButton; + _closeButton = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) { + _visible = false; + } else if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset -= _scrollBy; + _scrollOffset = MAX(_scrollOffset, 0); + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset += _scrollBy; + } else return CBObject::Listen(param1, param2); + break; + default: + error("CAdInventoryBox::Listen - Unhandled enum"); + break; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Display() { + CAdGame *AdGame = (CAdGame *)Game; + + if (!_visible) return S_OK; + + int ItemsX, ItemsY; + ItemsX = floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + ItemsY = floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); + + if (_window) { + _window->EnableWidget("prev", _scrollOffset > 0); + _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()); + } + + + if (_closeButton) { + _closeButton->_posX = _closeButton->_posY = 0; + _closeButton->_width = Game->_renderer->_width; + _closeButton->_height = Game->_renderer->_height; + + _closeButton->Display(); + } + + + // display window + RECT rect = _itemsArea; + if (_window) { + CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + _window->Display(); + } + + // display items + if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor; + int yyy = rect.top; + for (int j = 0; j < ItemsY; j++) { + int xxx = rect.left; + for (int i = 0; i < ItemsX; i++) { + int ItemIndex = _scrollOffset + j * ItemsX + i; + if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()) { + CAdItem *item = AdGame->_inventoryOwner->GetInventory()->_takenItems[ItemIndex]; + if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { + item->Update(); + item->Display(xxx, yyy); + } + } + + xxx += (_itemWidth + _spacing); + } + yyy += (_itemHeight + _spacing); + } + if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(WINDOW) +TOKEN_DEF(EXCLUSIVE) +TOKEN_DEF(ALWAYS_VISIBLE) +TOKEN_DEF(AREA) +TOKEN_DEF(SPACING) +TOKEN_DEF(ITEM_WIDTH) +TOKEN_DEF(ITEM_HEIGHT) +TOKEN_DEF(SCROLL_BY) +TOKEN_DEF(NAME) +TOKEN_DEF(CAPTION) +TOKEN_DEF(HIDE_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(EXCLUSIVE) + TOKEN_TABLE(ALWAYS_VISIBLE) + TOKEN_TABLE(AREA) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(ITEM_WIDTH) + TOKEN_TABLE(ITEM_HEIGHT) + TOKEN_TABLE(SCROLL_BY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(HIDE_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + bool always_visible = false; + + _exclusive = false; + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + Game->LOG(0, "'INVENTORY_BOX' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(Game); + if (!_window || FAILED(_window->LoadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else Game->RegisterObject(_window); + break; + + case TOKEN_AREA: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); + break; + + case TOKEN_EXCLUSIVE: + parser.ScanStr((char *)params, "%b", &_exclusive); + break; + + case TOKEN_HIDE_SELECTED: + parser.ScanStr((char *)params, "%b", &_hideSelected); + break; + + case TOKEN_ALWAYS_VISIBLE: + parser.ScanStr((char *)params, "%b", &always_visible); + break; + + case TOKEN_SPACING: + parser.ScanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_ITEM_WIDTH: + parser.ScanStr((char *)params, "%d", &_itemWidth); + break; + + case TOKEN_ITEM_HEIGHT: + parser.ScanStr((char *)params, "%d", &_itemHeight); + break; + + case TOKEN_SCROLL_BY: + parser.ScanStr((char *)params, "%d", &_scrollBy); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in INVENTORY_BOX definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading INVENTORY_BOX definition"); + return E_FAIL; + } + + if (_exclusive) { + delete _closeButton; + _closeButton = new CUIButton(Game); + if (_closeButton) { + _closeButton->SetName("close"); + _closeButton->SetListener(this, _closeButton, 0); + _closeButton->_parent = _window; + } + } + + _visible = always_visible; + + if (_window) { + for (int i = 0; i < _window->_widgets.GetSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); + + Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // window + if (_window) _window->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdInventoryBox::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_closeButton)); + PersistMgr->Transfer(TMEMBER(_hideSelected)); + PersistMgr->Transfer(TMEMBER(_itemHeight)); + PersistMgr->Transfer(TMEMBER(_itemsArea)); + PersistMgr->Transfer(TMEMBER(_itemWidth)); + PersistMgr->Transfer(TMEMBER(_scrollBy)); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_spacing)); + PersistMgr->Transfer(TMEMBER(_visible)); + PersistMgr->Transfer(TMEMBER(_window)); + PersistMgr->Transfer(TMEMBER(_exclusive)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h new file mode 100644 index 0000000000..b7838607d2 --- /dev/null +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORYBOX_H +#define WINTERMUTE_ADINVENTORYBOX_H + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { +class CUIButton; +class CUIWindow; + +class CAdInventoryBox : public CBObject { +public: + bool _hideSelected; + DECLARE_PERSISTENT(CAdInventoryBox, CBObject) + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; + bool _visible; + virtual HRESULT Display(); + CUIButton *_closeButton; + int _spacing; + int _scrollOffset; + RECT _itemsArea; + HRESULT Listen(CBScriptHolder *param1, uint32 param2); + CUIWindow *_window; + CAdInventoryBox(CBGame *inGame); + virtual ~CAdInventoryBox(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp new file mode 100644 index 0000000000..efd655c500 --- /dev/null +++ b/engines/wintermute/Ad/AdItem.cpp @@ -0,0 +1,758 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdItem, false) + +////////////////////////////////////////////////////////////////////////// +CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { + _spriteHover = NULL; + _cursorNormal = _cursorHover = NULL; + + _cursorCombined = true; + _inInventory = false; + + _displayAmount = false; + _amount = 0; + _amountOffsetX = 0; + _amountOffsetY = 0; + _amountAlign = TAL_RIGHT; + _amountString = NULL; + + _state = STATE_READY; + + _movable = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdItem::~CAdItem() { + delete _spriteHover; + delete _cursorNormal; + delete _cursorHover; + _spriteHover = NULL; + _cursorNormal = NULL; + _cursorHover = NULL; + + delete[] _amountString; + _amountString = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ITEM) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(CURSOR_HOVER) +TOKEN_DEF(CURSOR_COMBINED) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(FONT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(SPRITE_HOVER) +TOKEN_DEF(SPRITE) +TOKEN_DEF(DISPLAY_AMOUNT) +TOKEN_DEF(AMOUNT_OFFSET_X) +TOKEN_DEF(AMOUNT_OFFSET_Y) +TOKEN_DEF(AMOUNT_ALIGN) +TOKEN_DEF(AMOUNT_STRING) +TOKEN_DEF(AMOUNT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(CURSOR_HOVER) + TOKEN_TABLE(CURSOR_COMBINED) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(FONT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(SPRITE_HOVER) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(DISPLAY_AMOUNT) + TOKEN_TABLE(AMOUNT_OFFSET_X) + TOKEN_TABLE(AMOUNT_OFFSET_Y) + TOKEN_TABLE(AMOUNT_ALIGN) + TOKEN_TABLE(AMOUNT_STRING) + TOKEN_TABLE(AMOUNT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + Game->LOG(0, "'ITEM' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int ar = 0, ag = 0, ab = 0, alpha = 255; + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_IMAGE: + case TOKEN_SPRITE: + delete _sprite; + _sprite = new CBSprite(Game, this); + if (!_sprite || FAILED(_sprite->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _sprite; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + case TOKEN_SPRITE_HOVER: + delete _spriteHover; + _spriteHover = new CBSprite(Game, this); + if (!_spriteHover || FAILED(_spriteHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _spriteHover; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_AMOUNT: + parser.ScanStr((char *)params, "%d", &_amount); + break; + + case TOKEN_DISPLAY_AMOUNT: + parser.ScanStr((char *)params, "%b", &_displayAmount); + break; + + case TOKEN_AMOUNT_OFFSET_X: + parser.ScanStr((char *)params, "%d", &_amountOffsetX); + break; + + case TOKEN_AMOUNT_OFFSET_Y: + parser.ScanStr((char *)params, "%d", &_amountOffsetY); + break; + + case TOKEN_AMOUNT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; + else _amountAlign = TAL_CENTER; + break; + + case TOKEN_AMOUNT_STRING: + CBUtils::SetString(&_amountString, (char *)params); + break; + + case TOKEN_TALK: { + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.Add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.Add(spr); + } + break; + + case TOKEN_CURSOR: + delete _cursorNormal; + _cursorNormal = new CBSprite(Game); + if (!_cursorNormal || FAILED(_cursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _cursorNormal; + _cursorNormal = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_HOVER: + delete _cursorHover; + _cursorHover = new CBSprite(Game); + if (!_cursorHover || FAILED(_cursorHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + delete _cursorHover; + _cursorHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_COMBINED: + parser.ScanStr((char *)params, "%b", &_cursorCombined); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ITEM definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ITEM definition"); + return E_FAIL; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = DRGBA(ar, ag, ab, alpha); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) { + if (Game->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; + else _currentSprite = _sprite; + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->Update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->Finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + if (_tempSprite2) { + _tempSprite2->Reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)Game)->AddSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)Game)->AddSentence(_sentence); + } + } + break; + } + _ready = (_state == STATE_READY); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Display(int X, int Y) { + int Width = 0; + if (_currentSprite) { + RECT rc; + _currentSprite->GetBoundingRect(&rc, 0, 0); + Width = rc.right - rc.left; + } + + _posX = X + Width / 2; + _posY = Y; + + HRESULT ret; + if (_currentSprite) ret = _currentSprite->Draw(X, Y, this, 100, 100, _alphaColor); + else ret = S_OK; + + if (_displayAmount) { + int AmountX = X; + int AmountY = Y + _amountOffsetY; + + if (_amountAlign == TAL_RIGHT) { + Width -= _amountOffsetX; + AmountX -= _amountOffsetX; + } + AmountX += _amountOffsetX; + + CBFont *Font = _font ? _font : Game->_systemFont; + if (Font) { + if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); + else { + char Str[256]; + sprintf(Str, "%d", _amount); + Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); + } + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetHoverSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetHoverSprite") == 0) { + Stack->CorrectParams(1); + + bool SetCurrent = false; + if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; + + const char *Filename = Stack->Pop()->GetString(); + + delete _spriteHover; + _spriteHover = NULL; + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); + } else { + _spriteHover = spr; + if (SetCurrent) _currentSprite = _spriteHover; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverSprite") == 0) { + Stack->CorrectParams(0); + + if (!_spriteHover || !_spriteHover->_filename) Stack->PushNULL(); + else Stack->PushString(_spriteHover->_filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverSpriteObject") == 0) { + Stack->CorrectParams(0); + if (!_spriteHover) Stack->PushNULL(); + else Stack->PushNative(_spriteHover, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetNormalCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetNormalCursor") == 0) { + Stack->CorrectParams(1); + + const char *Filename = Stack->Pop()->GetString(); + + delete _cursorNormal; + _cursorNormal = NULL; + CBSprite *spr = new CBSprite(Game); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); + } else { + _cursorNormal = spr; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNormalCursor") == 0) { + Stack->CorrectParams(0); + + if (!_cursorNormal || !_cursorNormal->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorNormal->_filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNormalCursorObject") == 0) { + Stack->CorrectParams(0); + + if (!_cursorNormal) Stack->PushNULL(); + else Stack->PushNative(_cursorNormal, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetHoverCursor") == 0) { + Stack->CorrectParams(1); + + const char *Filename = Stack->Pop()->GetString(); + + delete _cursorHover; + _cursorHover = NULL; + CBSprite *spr = new CBSprite(Game); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); + } else { + _cursorHover = spr; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverCursor") == 0) { + Stack->CorrectParams(0); + + if (!_cursorHover || !_cursorHover->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorHover->_filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverCursorObject") == 0) { + Stack->CorrectParams(0); + + if (!_cursorHover) Stack->PushNULL(); + else Stack->PushNative(_cursorHover, true); + return S_OK; + } + + else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdItem::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("item"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayAmount") == 0) { + _scValue->SetBool(_displayAmount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Amount") == 0) { + _scValue->SetInt(_amount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetX") == 0) { + _scValue->SetInt(_amountOffsetX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetY") == 0) { + _scValue->SetInt(_amountOffsetY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountAlign") == 0) { + _scValue->SetInt(_amountAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountString") == 0) { + if (!_amountString) _scValue->SetNULL(); + else _scValue->SetString(_amountString); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorCombined") == 0) { + _scValue->SetBool(_cursorCombined); + return _scValue; + } + + else return CAdTalkHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayAmount") == 0) { + _displayAmount = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Amount") == 0) { + _amount = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetX") == 0) { + _amountOffsetX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountOffsetY") == 0) { + _amountOffsetY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountAlign") == 0) { + _amountAlign = (TTextAlign)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AmountString") == 0) { + if (Value->IsNULL()) { + delete[] _amountString; + _amountString = NULL; + } else { + CBUtils::SetString(&_amountString, Value->GetString()); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorCombined") == 0) { + _cursorCombined = Value->GetBool(); + return S_OK; + } + + else return CAdTalkHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdItem::ScToString() { + return "[item]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { + + CAdTalkHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_cursorCombined)); + PersistMgr->Transfer(TMEMBER(_cursorHover)); + PersistMgr->Transfer(TMEMBER(_cursorNormal)); + PersistMgr->Transfer(TMEMBER(_spriteHover)); + PersistMgr->Transfer(TMEMBER(_inInventory)); + PersistMgr->Transfer(TMEMBER(_displayAmount)); + PersistMgr->Transfer(TMEMBER(_amount)); + PersistMgr->Transfer(TMEMBER(_amountOffsetX)); + PersistMgr->Transfer(TMEMBER(_amountOffsetY)); + PersistMgr->Transfer(TMEMBER_INT(_amountAlign)); + PersistMgr->Transfer(TMEMBER(_amountString)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::GetExtendedFlag(const char *FlagName) { + if (!FlagName) return false; + else if (strcmp(FlagName, "usable") == 0) return true; + else return CAdObject::GetExtendedFlag(FlagName); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h new file mode 100644 index 0000000000..0168ff7ca8 --- /dev/null +++ b/engines/wintermute/Ad/AdItem.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADITEM_H +#define WINTERMUTE_ADITEM_H + + +#include "engines/wintermute/Ad/AdTalkHolder.h" + +namespace WinterMute { + +class CAdItem : public CAdTalkHolder { +public: + bool _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; + + + HRESULT Update(); + DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) + HRESULT Display(int X, int Y); + bool GetExtendedFlag(const char *FlagName); + bool _inInventory; + bool _cursorCombined; + CBSprite *_spriteHover; + CBSprite *_cursorNormal; + CBSprite *_cursorHover; + CAdItem(CBGame *inGame); + virtual ~CAdItem(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp new file mode 100644 index 0000000000..b6e7a8527e --- /dev/null +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -0,0 +1,538 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Ad/AdLayer.h" +#include "engines/wintermute/Ad/AdSceneNode.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdLayer, false) + +////////////////////////////////////////////////////////////////////////// +CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { + _main = false; + _width = _height = 0; + _active = true; + _closeUp = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdLayer::~CAdLayer() { + for (int i = 0; i < _nodes.GetSize(); i++) + delete _nodes[i]; + _nodes.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(LAYER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(MAIN) +TOKEN_DEF(ENTITY) +TOKEN_DEF(REGION) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(CLOSE_UP) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(MAIN) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(REGION) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(CLOSE_UP) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + Game->LOG(0, "'LAYER' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_MAIN: + parser.ScanStr((char *)params, "%b", &_main); + break; + + case TOKEN_CLOSE_UP: + parser.ScanStr((char *)params, "%b", &_closeUp); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &_height); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &_active); + break; + + case TOKEN_REGION: { + CAdRegion *region = new CAdRegion(Game); + CAdSceneNode *node = new CAdSceneNode(Game); + if (!region || !node || FAILED(region->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete region; + delete node; + region = NULL; + node = NULL; + } else { + node->SetRegion(region); + _nodes.Add(node); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(Game); + CAdSceneNode *node = new CAdSceneNode(Game); + if (entity) entity->_zoomable = false; // scene entites default to NOT zoom + if (!entity || !node || FAILED(entity->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + delete node; + entity = NULL; + node = NULL; + } else { + node->SetEntity(entity); + _nodes.Add(node); + } + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in LAYER definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetNode") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + int node = -1; + + if (val->_type == VAL_INT) node = val->GetInt(); + else { // get by name + for (int i = 0; i < _nodes.GetSize(); i++) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->GetString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->GetString()) == 0)) { + node = i; + break; + } + } + } + + if (node < 0 || node >= _nodes.GetSize()) Stack->PushNULL(); + else { + switch (_nodes[node]->_type) { + case OBJECT_ENTITY: + Stack->PushNative(_nodes[node]->_entity, true); + break; + case OBJECT_REGION: + Stack->PushNative(_nodes[node]->_region, true); + break; + default: + Stack->PushNULL(); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddRegion / AddEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddRegion") == 0 || strcmp(Name, "AddEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *Node = new CAdSceneNode(Game); + if (strcmp(Name, "AddRegion") == 0) { + CAdRegion *Region = new CAdRegion(Game); + if (!Val->IsNULL()) Region->SetName(Val->GetString()); + Node->SetRegion(Region); + Stack->PushNative(Region, true); + } else { + CAdEntity *Entity = new CAdEntity(Game); + if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + Node->SetEntity(Entity); + Stack->PushNative(Entity, true); + } + _nodes.Add(Node); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertRegion / InsertEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertRegion") == 0 || strcmp(Name, "InsertEntity") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *Node = new CAdSceneNode(Game); + if (strcmp(Name, "InsertRegion") == 0) { + CAdRegion *Region = new CAdRegion(Game); + if (!Val->IsNULL()) Region->SetName(Val->GetString()); + Node->SetRegion(Region); + Stack->PushNative(Region, true); + } else { + CAdEntity *Entity = new CAdEntity(Game); + if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + Node->SetEntity(Entity); + Stack->PushNative(Entity, true); + } + if (Index < 0) Index = 0; + if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); + else _nodes.Add(Node); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteNode") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdSceneNode *ToDelete = NULL; + if (Val->IsNative()) { + CBScriptable *Temp = Val->GetNative(); + for (int i = 0; i < _nodes.GetSize(); i++) { + if (_nodes[i]->_region == Temp || _nodes[i]->_entity == Temp) { + ToDelete = _nodes[i]; + break; + } + } + } else { + int Index = Val->GetInt(); + if (Index >= 0 && Index < _nodes.GetSize()) { + ToDelete = _nodes[Index]; + } + } + if (ToDelete == NULL) { + Stack->PushBool(false); + return S_OK; + } + + for (int i = 0; i < _nodes.GetSize(); i++) { + if (_nodes[i] == ToDelete) { + delete _nodes[i]; + _nodes[i] = NULL; + _nodes.RemoveAt(i); + break; + } + } + Stack->PushBool(true); + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdLayer::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("layer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumNodes") == 0) { + _scValue->SetInt(_nodes.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _scValue->SetInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _scValue->SetInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Main (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Main") == 0) { + _scValue->SetBool(_main); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CloseUp") == 0) { + _scValue->SetBool(_closeUp); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + _scValue->SetBool(_active); + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CloseUp") == 0) { + _closeUp = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _width = Value->GetInt(); + if (_width < 0) _width = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _height = Value->GetInt(); + if (_height < 0) _height = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + bool b = Value->GetBool(); + if (b == false && _main) { + Game->LOG(0, "Warning: cannot deactivate scene's main layer"); + } else _active = b; + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdLayer::ScToString() { + return "[layer]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "LAYER {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_closeUp) + Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + + int i; + + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + + for (i = 0; i < _nodes.GetSize(); i++) { + switch (_nodes[i]->_type) { + case OBJECT_ENTITY: + _nodes[i]->_entity->SaveAsText(Buffer, Indent + 2); + break; + case OBJECT_REGION: + _nodes[i]->_region->SaveAsText(Buffer, Indent + 2); + break; + default: + error("CAdLayer::SaveAsText - Unhandled enum"); + break; + } + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdLayer::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_closeUp)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_main)); + _nodes.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_width)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h new file mode 100644 index 0000000000..1c0e3fa946 --- /dev/null +++ b/engines/wintermute/Ad/AdLayer.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADLAYER_H +#define WINTERMUTE_ADLAYER_H + +namespace WinterMute { +class CAdSceneNode; +class CAdLayer : public CBObject { +public: + bool _closeUp; + DECLARE_PERSISTENT(CAdLayer, CBObject) + bool _active; + int _height; + int _width; + bool _main; + CAdLayer(CBGame *inGame); + virtual ~CAdLayer(); + CBArray _nodes; + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp new file mode 100644 index 0000000000..05ff99f7e0 --- /dev/null +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -0,0 +1,169 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Ad/AdNodeState.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdNodeState, false) + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { + _name = NULL; + _active = false; + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _alphaColor = 0; + _filename = NULL; + _cursor = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::~CAdNodeState() { + delete[] _name; + delete[] _filename; + delete[] _cursor; + _name = NULL; + _filename = NULL; + _cursor = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetName(const char *Name) { + delete[] _name; + _name = NULL; + CBUtils::SetString(&_name, Name); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetFilename(const char *Filename) { + delete[] _filename; + _filename = NULL; + CBUtils::SetString(&_filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetCursor(const char *Filename) { + delete[] _cursor; + _cursor = NULL; + CBUtils::SetString(&_cursor, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_cursor)); + PersistMgr->Transfer(TMEMBER(_alphaColor)); + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::SetCaption(const char *Caption, int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7) return; + + delete[] _caption[Case - 1]; + _caption[Case - 1] = new char[strlen(Caption) + 1]; + if (_caption[Case - 1]) { + strcpy(_caption[Case - 1], Caption); + Game->_stringTable->Expand(&_caption[Case - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdNodeState::GetCaption(int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; + else return _caption[Case - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving) { + if (!Entity) return E_FAIL; + + // hack! + if (this->Game != Entity->Game) this->Game = Entity->Game; + + if (Saving) { + for (int i = 0; i < 7; i++) { + if (Entity->_caption[i]) SetCaption(Entity->_caption[i], i); + } + if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { + if (IncludingSprites) SetFilename(Entity->_sprite->_filename); + else SetFilename(""); + } + if (Entity->_cursor && Entity->_cursor->_filename) SetCursor(Entity->_cursor->_filename); + _alphaColor = Entity->_alphaColor; + _active = Entity->_active; + } else { + for (int i = 0; i < 7; i++) { + if (_caption[i]) Entity->SetCaption(_caption[i], i); + } + if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { + if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) + Entity->SetSprite(_filename); + } + if (_cursor) { + if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) + Entity->SetCursor(_cursor); + } + + Entity->_active = _active; + Entity->_alphaColor = _alphaColor; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h new file mode 100644 index 0000000000..16445376ca --- /dev/null +++ b/engines/wintermute/Ad/AdNodeState.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADNODESTATE_H +#define WINTERMUTE_ADNODESTATE_H + +namespace WinterMute { + +class CAdEntity; + +class CAdNodeState : public CBBase { +public: + HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); + void SetName(const char *Name); + void SetFilename(const char *Filename); + void SetCursor(const char *Filename); + DECLARE_PERSISTENT(CAdNodeState, CBBase) + CAdNodeState(CBGame *inGame); + virtual ~CAdNodeState(); + char *_name; + bool _active; + char *_caption[7]; + void SetCaption(const char *Caption, int Case); + char *GetCaption(int Case); + uint32 _alphaColor; + char *_filename; + char *_cursor; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp new file mode 100644 index 0000000000..34903a8ccf --- /dev/null +++ b/engines/wintermute/Ad/AdObject.cpp @@ -0,0 +1,1203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/Ad/AdObject.h" +#include "engines/wintermute/Ad/AdInventory.h" +#include "engines/wintermute/Ad/AdLayer.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/Ad/AdSceneNode.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFrame.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/BSubFrame.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "common/str.h" +#include "common/util.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdObject, false) + +////////////////////////////////////////////////////////////////////////// +CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _state = _nextState = STATE_NONE; + + _active = true; + _drawn = false; + + _currentSprite = NULL; + _animSprite = NULL; + _tempSprite2 = NULL; + + _font = NULL; + + _sentence = NULL; + + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + + _blockRegion = NULL; + _wptGroup = NULL; + + _currentBlockRegion = NULL; + _currentWptGroup = NULL; + + _ignoreItems = false; + _sceneIndependent = false; + + _stickRegion = NULL; + + _subtitlesModRelative = true; + _subtitlesModX = 0; + _subtitlesModY = 0; + _subtitlesWidth = 0; + _subtitlesModXCenter = true; + + _inventory = NULL; + + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + + _partEmitter = NULL; + _partFollowParent = false; + _partOffsetX = _partOffsetY = 0; + + _registerAlias = this; +} + + +////////////////////////////////////////////////////////////////////////// +CAdObject::~CAdObject() { + _currentSprite = NULL; // reference only, don't delete + delete _animSprite; + _animSprite = NULL; + delete _sentence; + _sentence = NULL; + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + + delete _blockRegion; + _blockRegion = NULL; + delete _wptGroup; + _wptGroup = NULL; + + delete _currentBlockRegion; + _currentBlockRegion = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + + _tempSprite2 = NULL; // reference only + _stickRegion = NULL; + + if (_font) Game->_fontStorage->RemoveFont(_font); + + if (_inventory) { + ((CAdGame *)Game)->UnregisterInventory(_inventory); + _inventory = NULL; + } + + if (_partEmitter) + Game->UnregisterObject(_partEmitter); + + + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + Game->UnregisterObject(_attachmentsPre[i]); + } + _attachmentsPre.RemoveAll(); + + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + Game->UnregisterObject(_attachmentsPost[i]); + } + _attachmentsPost.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::PlayAnim(const char *Filename) { + delete _animSprite; + _animSprite = NULL; + _animSprite = new CBSprite(Game, this); + if (!_animSprite) { + Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); + return E_FAIL; + } + HRESULT res = _animSprite->LoadFile(Filename); + if (FAILED(res)) { + Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); + delete _animSprite; + _animSprite = NULL; + return res; + } + _state = STATE_PLAYING_ANIM; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Display() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Update() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // PlayAnim / PlayAnimAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "PlayAnim") == 0 || strcmp(Name, "PlayAnimAsync") == 0) { + Stack->CorrectParams(1); + if (FAILED(PlayAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); + else { + if (strcmp(Name, "PlayAnimAsync") != 0) Script->WaitFor(this); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + Reset(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsTalking") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(_state == STATE_TALKING); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTalk / StopTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { + Stack->CorrectParams(0); + if (_sentence) _sentence->Finish(); + if (_state == STATE_TALKING) { + _state = _nextState; + _nextState = STATE_READY; + Stack->PushBool(true); + } else Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ForceTalkAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ForceTalkAnim") == 0) { + Stack->CorrectParams(1); + const char *AnimName = Stack->Pop()->GetString(); + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = new char[strlen(AnimName) + 1]; + strcpy(_forcedTalkAnimName, AnimName); + _forcedTalkAnimUsed = false; + Stack->PushBool(true); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Talk / TalkAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Talk") == 0 || strcmp(Name, "TalkAsync") == 0) { + Stack->CorrectParams(5); + + const char *Text = Stack->Pop()->GetString(); + CScValue *SoundVal = Stack->Pop(); + int Duration = Stack->Pop()->GetInt(); + CScValue *ValStances = Stack->Pop(); + + const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); + + int Align; + CScValue *val = Stack->Pop(); + if (val->IsNULL()) Align = TAL_CENTER; + else Align = val->GetInt(); + + Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); + + const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); + + Talk(Text, Sound, Duration, Stances, (TTextAlign)Align); + if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StickToRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StickToRegion") == 0) { + Stack->CorrectParams(1); + + CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; + bool RegFound = false; + + int i; + CScValue *Val = Stack->Pop(); + if (Val->IsNULL() || !Main) { + _stickRegion = NULL; + RegFound = true; + } else if (Val->IsString()) { + const char *RegionName = Val->GetString(); + for (i = 0; i < Main->_nodes.GetSize(); i++) { + if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { + _stickRegion = Main->_nodes[i]->_region; + RegFound = true; + break; + } + } + } else if (Val->IsNative()) { + CBScriptable *Obj = Val->GetNative(); + + for (i = 0; i < Main->_nodes.GetSize(); i++) { + if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region == Obj) { + _stickRegion = Main->_nodes[i]->_region; + RegFound = true; + break; + } + } + + } + + if (!RegFound) _stickRegion = NULL; + Stack->PushBool(RegFound); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsNULL()) SetFont(NULL); + else SetFont(Val->GetString()); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFont") == 0) { + Stack->CorrectParams(0); + if (_font && _font->_filename) Stack->PushString(_font->_filename); + else Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TakeItem") == 0) { + Stack->CorrectParams(2); + + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + const char *ItemName = val->GetString(); + val = Stack->Pop(); + const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); + if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + else { + // hide associated entities + ((CAdGame *)Game)->_scene->HandleItemAssociations(ItemName, false); + } + + } else Script->RuntimeError("TakeItem: item name expected"); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DropItem") == 0) { + Stack->CorrectParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + if (FAILED(_inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); + else { + // show associated entities + ((CAdGame *)Game)->_scene->HandleItemAssociations(val->GetString(), true); + } + } else Script->RuntimeError("DropItem: item name expected"); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetItem") == 0) { + Stack->CorrectParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); + } + + CScValue *val = Stack->Pop(); + if (val->_type == VAL_STRING) { + CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); + if (item) Stack->PushNative(item, true); + else Stack->PushNULL(); + } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) + Stack->PushNULL(); + else + Stack->PushNative(_inventory->_takenItems[val->GetInt()], true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasItem") == 0) { + Stack->CorrectParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); + } + + CScValue *val = Stack->Pop(); + if (!val->IsNULL()) { + for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { + if (val->GetNative() == _inventory->_takenItems[i]) { + Stack->PushBool(true); + return S_OK; + } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { + Stack->PushBool(true); + return S_OK; + } + } + } else Script->RuntimeError("HasItem: item name expected"); + + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateParticleEmitter") == 0) { + Stack->CorrectParams(3); + bool FollowParent = Stack->Pop()->GetBool(); + int OffsetX = Stack->Pop()->GetInt(); + int OffsetY = Stack->Pop()->GetInt(); + + CPartEmitter *Emitter = CreateParticleEmitter(FollowParent, OffsetX, OffsetY); + if (Emitter) Stack->PushNative(_partEmitter, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteParticleEmitter") == 0) { + Stack->CorrectParams(0); + if (_partEmitter) { + Game->UnregisterObject(_partEmitter); + _partEmitter = NULL; + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddAttachment") == 0) { + Stack->CorrectParams(4); + const char *Filename = Stack->Pop()->GetString(); + bool PreDisplay = Stack->Pop()->GetBool(true); + int OffsetX = Stack->Pop()->GetInt(); + int OffsetY = Stack->Pop()->GetInt(); + + HRESULT res; + CAdEntity *Ent = new CAdEntity(Game); + if (FAILED(res = Ent->LoadFile(Filename))) { + delete Ent; + Ent = NULL; + Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); + Stack->PushBool(false); + } else { + Game->RegisterObject(Ent); + + Ent->_posX = OffsetX; + Ent->_posY = OffsetY; + Ent->_active = true; + + if (PreDisplay) _attachmentsPre.Add(Ent); + else _attachmentsPost.Add(Ent); + + Stack->PushBool(true); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveAttachment") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + bool Found = false; + if (Val->IsNative()) { + CBScriptable *Obj = Val->GetNative(); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i] == Obj) { + Found = true; + Game->UnregisterObject(_attachmentsPre[i]); + _attachmentsPre.RemoveAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i] == Obj) { + Found = true; + Game->UnregisterObject(_attachmentsPost[i]); + _attachmentsPost.RemoveAt(i); + i--; + } + } + } else { + const char *Name = Val->GetString(); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { + Found = true; + Game->UnregisterObject(_attachmentsPre[i]); + _attachmentsPre.RemoveAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { + Found = true; + Game->UnregisterObject(_attachmentsPost[i]); + _attachmentsPost.RemoveAt(i); + i--; + } + } + } + Stack->PushBool(Found); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetAttachment") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdObject *Ret = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + int CurrIndex = 0; + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (CurrIndex == Index) Ret = _attachmentsPre[i]; + CurrIndex++; + } + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (CurrIndex == Index) Ret = _attachmentsPost[i]; + CurrIndex++; + } + } else { + const char *Name = Val->GetString(); + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { + Ret = _attachmentsPre[i]; + break; + } + } + if (!Ret) { + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { + Ret = _attachmentsPre[i]; + break; + } + } + } + } + + if (Ret != NULL) Stack->PushNative(Ret, true); + else Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdObject::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + _scValue->SetBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IgnoreItems") == 0) { + _scValue->SetBool(_ignoreItems); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SceneIndependent") == 0) { + _scValue->SetBool(_sceneIndependent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesWidth") == 0) { + _scValue->SetInt(_subtitlesWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + _scValue->SetBool(_subtitlesModRelative); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosX") == 0) { + _scValue->SetInt(_subtitlesModX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosY") == 0) { + _scValue->SetInt(_subtitlesModY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + _scValue->SetBool(_subtitlesModXCenter); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumItems (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumItems") == 0) { + _scValue->SetInt(GetInventory()->_takenItems.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParticleEmitter (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParticleEmitter") == 0) { + if (_partEmitter) _scValue->SetNative(_partEmitter, true); + else _scValue->SetNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumAttachments (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumAttachments") == 0) { + _scValue->SetInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); + return _scValue; + } + + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Active") == 0) { + _active = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IgnoreItems") == 0) { + _ignoreItems = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SceneIndependent") == 0) { + _sceneIndependent = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesWidth") == 0) { + _subtitlesWidth = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + _subtitlesModRelative = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosX") == 0) { + _subtitlesModX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosY") == 0) { + _subtitlesModY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + _subtitlesModXCenter = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdObject::ScToString() { + return "[ad object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::SetFont(const char *Filename) { + if (_font) Game->_fontStorage->RemoveFont(_font); + if (Filename) { + _font = Game->_fontStorage->AddFont(Filename); + return _font == NULL ? E_FAIL : S_OK; + } else { + _font = NULL; + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CAdObject::GetHeight() { + if (!_currentSprite) return 0; + else { + CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; + int ret = 0; + for (int i = 0; i < frame->_subframes.GetSize(); i++) { + ret = MAX(ret, frame->_subframes[i]->_hotspotY); + } + + if (_zoomable) { + float zoom = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY); + ret = ret * zoom / 100; + } + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { + if (!_sentence) _sentence = new CAdSentence(Game); + if (!_sentence) return; + + if (_forcedTalkAnimName && _forcedTalkAnimUsed) { + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + } + + delete (_sentence->_sound); + _sentence->_sound = NULL; + + _sentence->SetText(Text); + Game->_stringTable->Expand(&_sentence->_text); + _sentence->SetStances(Stances); + _sentence->_duration = Duration; + _sentence->_align = Align; + _sentence->_startTime = Game->_timer; + _sentence->_currentStance = -1; + _sentence->_font = _font == NULL ? Game->_systemFont : _font; + _sentence->_freezable = _freezable; + + // try to locate speech file automatically + bool DeleteSound = false; + if (!Sound) { + char *Key = Game->_stringTable->GetKey(Text); + if (Key) { + Sound = ((CAdGame *)Game)->FindSpeechFile(Key); + delete [] Key; + + if (Sound) DeleteSound = true; + } + } + + // load sound and set duration appropriately + if (Sound) { + CBSound *snd = new CBSound(Game); + if (snd && SUCCEEDED(snd->SetSound(Sound, SOUND_SPEECH, true))) { + _sentence->SetSound(snd); + if (_sentence->_duration <= 0) { + uint32 Length = snd->GetLength(); + if (Length != 0) _sentence->_duration = Length; + } + } else delete snd; + } + + // set duration by text length + if (_sentence->_duration <= 0) {// TODO: Avoid longs. + _sentence->_duration = MAX((size_t)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); + } + + + int x, y, width, height; + + x = _posX; + y = _posY; + + if (!_sceneIndependent && _subtitlesModRelative) { + x -= ((CAdGame *)Game)->_scene->GetOffsetLeft(); + y -= ((CAdGame *)Game)->_scene->GetOffsetTop(); + } + + + if (_subtitlesWidth > 0) width = _subtitlesWidth; + else { + if ((x < Game->_renderer->_width / 4 || x > Game->_renderer->_width * 0.75) && !Game->_touchInterface) { + width = MAX(Game->_renderer->_width / 4, MIN(x * 2, (Game->_renderer->_width - x) * 2)); + } else width = Game->_renderer->_width / 2; + } + + height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); + + y = y - height - GetHeight() - 5; + if (_subtitlesModRelative) { + x += _subtitlesModX; + y += _subtitlesModY; + } else { + x = _subtitlesModX; + y = _subtitlesModY; + } + if (_subtitlesModXCenter) + x = x - width / 2; + + + x = MIN(MAX(0, x), Game->_renderer->_width - width); + y = MIN(MAX(0, y), Game->_renderer->_height - height); + + _sentence->_width = width; + + + _sentence->_pos.x = x; + _sentence->_pos.y = y; + + + if (_subtitlesModRelative) { + _sentence->_pos.x += ((CAdGame *)Game)->_scene->GetOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)Game)->_scene->GetOffsetTop(); + } + + _sentence->_fixedPos = !_subtitlesModRelative; + + + _sentence->SetupTalkFile(Sound); + + _state = STATE_TALKING; + + if (DeleteSound) delete [] Sound; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Reset() { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + delete _animSprite; + _animSprite = NULL; + } else if (_state == STATE_TALKING && _sentence) { + _sentence->Finish(); + } + + _state = _nextState = STATE_READY; + + Game->_scEngine->ResetObject(this); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_blockRegion)); + PersistMgr->Transfer(TMEMBER(_currentBlockRegion)); + PersistMgr->Transfer(TMEMBER(_currentWptGroup)); + PersistMgr->Transfer(TMEMBER(_currentSprite)); + PersistMgr->Transfer(TMEMBER(_drawn)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_ignoreItems)); + PersistMgr->Transfer(TMEMBER_INT(_nextState)); + PersistMgr->Transfer(TMEMBER(_sentence)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_animSprite)); + PersistMgr->Transfer(TMEMBER(_sceneIndependent)); + PersistMgr->Transfer(TMEMBER(_forcedTalkAnimName)); + PersistMgr->Transfer(TMEMBER(_forcedTalkAnimUsed)); + PersistMgr->Transfer(TMEMBER(_tempSprite2)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_wptGroup)); + PersistMgr->Transfer(TMEMBER(_stickRegion)); + PersistMgr->Transfer(TMEMBER(_subtitlesModRelative)); + PersistMgr->Transfer(TMEMBER(_subtitlesModX)); + PersistMgr->Transfer(TMEMBER(_subtitlesModY)); + PersistMgr->Transfer(TMEMBER(_subtitlesModXCenter)); + PersistMgr->Transfer(TMEMBER(_subtitlesWidth)); + PersistMgr->Transfer(TMEMBER(_inventory)); + PersistMgr->Transfer(TMEMBER(_partEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(_currentRegions[i])); + + _attachmentsPre.Persist(PersistMgr); + _attachmentsPost.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_registerAlias)); + + PersistMgr->Transfer(TMEMBER(_partFollowParent)); + PersistMgr->Transfer(TMEMBER(_partOffsetX)); + PersistMgr->Transfer(TMEMBER(_partOffsetY)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateSounds() { + if (_sentence && _sentence->_sound) + UpdateOneSound(_sentence->_sound); + + return CBObject::UpdateSounds(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::ResetSoundPan() { + if (_sentence && _sentence->_sound) { + _sentence->_sound->SetPan(0.0f); + } + return CBObject::ResetSoundPan(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::GetExtendedFlag(const char *FlagName) { + if (!FlagName) return false; + else if (strcmp(FlagName, "usable") == 0) return true; + + else return CBObject::GetExtendedFlag(FlagName); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + if (_blockRegion) _blockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->SaveAsText(Buffer, Indent + 2); + + CBBase::SaveAsText(Buffer, Indent + 2); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateBlockRegion() { + CAdGame *AdGame = (CAdGame *)Game; + if (AdGame->_scene) { + if (_blockRegion && _currentBlockRegion) + _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); + + if (_wptGroup && _currentWptGroup) + _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdInventory *CAdObject::GetInventory() { + if (!_inventory) { + _inventory = new CAdInventory(Game); + ((CAdGame *)Game)->RegisterInventory(_inventory); + } + return _inventory; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::AfterMove() { + CAdRegion *NewRegions[MAX_NUM_REGIONS]; + + ((CAdGame *)Game)->_scene->GetRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (!NewRegions[i]) break; + bool RegFound = false; + for (int j = 0; j < MAX_NUM_REGIONS; j++) { + if (_currentRegions[j] == NewRegions[i]) { + _currentRegions[j] = NULL; + RegFound = true; + break; + } + } + if (!RegFound) NewRegions[i]->ApplyEvent("ActorEntry"); + } + + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (_currentRegions[i] && Game->ValidObject(_currentRegions[i])) { + _currentRegions[i]->ApplyEvent("ActorLeave"); + } + _currentRegions[i] = NewRegions[i]; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::InvalidateCurrRegions() { + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { + if (_zoomable) { + if (_scaleX >= 0 || _scaleY >= 0) { + *ScaleX = _scaleX < 0 ? 100 : _scaleX; + *ScaleY = _scaleY < 0 ? 100 : _scaleY; + } else if (_scale >= 0) *ScaleX = *ScaleY = _scale; + else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) + _relativeScale; + } else { + *ScaleX = *ScaleY = 100; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdateSpriteAttachments() { + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + _attachmentsPre[i]->Update(); + } + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + _attachmentsPost[i]->Update(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { + if (PreDisplay) { + for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + DisplaySpriteAttachment(_attachmentsPre[i]); + } + } else { + for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + DisplaySpriteAttachment(_attachmentsPost[i]); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { + if (!Attachment->_active) return S_OK; + + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + int OrigX = Attachment->_posX; + int OrigY = Attachment->_posY; + + // inherit position from owner + Attachment->_posX = this->_posX + Attachment->_posX * ScaleX / 100.0f; + Attachment->_posY = this->_posY + Attachment->_posY * ScaleY / 100.0f; + + // inherit other props + Attachment->_alphaColor = this->_alphaColor; + Attachment->_blendMode = this->_blendMode; + + Attachment->_scale = this->_scale; + Attachment->_relativeScale = this->_relativeScale; + Attachment->_scaleX = this->_scaleX; + Attachment->_scaleY = this->_scaleY; + + Attachment->_rotate = this->_rotate; + Attachment->_relativeRotate = this->_relativeRotate; + Attachment->_rotateValid = this->_rotateValid; + + Attachment->_registerAlias = this; + Attachment->_registrable = this->_registrable; + + HRESULT ret = Attachment->Display(); + + Attachment->_posX = OrigX; + Attachment->_posY = OrigY; + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { + _partFollowParent = FollowParent; + _partOffsetX = OffsetX; + _partOffsetY = OffsetY; + + if (!_partEmitter) { + _partEmitter = new CPartEmitter(Game, this); + if (_partEmitter) { + Game->RegisterObject(_partEmitter); + } + } + UpdatePartEmitter(); + return _partEmitter; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdObject::UpdatePartEmitter() { + if (!_partEmitter) return E_FAIL; + + if (_partFollowParent) { + float ScaleX, ScaleY; + GetScale(&ScaleX, &ScaleY); + + _partEmitter->_posX = _posX + (ScaleX / 100.0f) * _partOffsetX; + _partEmitter->_posY = _posY + (ScaleY / 100.0f) * _partOffsetY; + } + return _partEmitter->Update(); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h new file mode 100644 index 0000000000..5f47c0d394 --- /dev/null +++ b/engines/wintermute/Ad/AdObject.h @@ -0,0 +1,123 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADOBJECT_H +#define WINTERMUTE_ADOBJECT_H + +#include "engines/wintermute/Ad/AdTypes.h" +#include "engines/wintermute/PartEmitter.h" + +namespace WinterMute { + +class CAdWaypointGroup; +class CAdRegion; +class CAdSentence; +class CBFont; +class CBRegion; +class CAdInventory; + +#define MAX_NUM_REGIONS 10 + +class CAdObject : public CBObject { +public: + CPartEmitter *_partEmitter; + virtual CPartEmitter *CreateParticleEmitter(bool FollowParent = false, int OffsetX = 0, int OffsetY = 0); + virtual HRESULT UpdatePartEmitter(); + bool _partFollowParent; + int _partOffsetX; + int _partOffsetY; + + HRESULT InvalidateCurrRegions(); + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int _subtitlesModX; + int _subtitlesModY; + int _subtitlesWidth; + CAdRegion *_stickRegion; + bool _sceneIndependent; + bool _ignoreItems; + HRESULT UpdateBlockRegion(); + bool _forcedTalkAnimUsed; + char *_forcedTalkAnimName; + virtual bool GetExtendedFlag(const char *FlagName); + virtual HRESULT ResetSoundPan(); + virtual HRESULT UpdateSounds(); + HRESULT Reset(); + DECLARE_PERSISTENT(CAdObject, CBObject) + virtual void Talk(const char *Text, const char *Sound = NULL, uint32 Duration = 0, const char *Stances = NULL, TTextAlign Align = TAL_CENTER); + virtual int GetHeight(); + CAdSentence *_sentence; + HRESULT SetFont(const char *Filename); + virtual HRESULT Update(); + virtual HRESULT Display(); + bool _drawn; + bool _active; + virtual HRESULT PlayAnim(const char *Filename); + CBSprite *_animSprite; + CBSprite *_currentSprite; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; + CAdObject(CBGame *inGame); + virtual ~CAdObject(); + CBFont *_font; + CBSprite *_tempSprite2; + CBRegion *_blockRegion; + CAdWaypointGroup *_wptGroup; + CBRegion *_currentBlockRegion; + CAdWaypointGroup *_currentWptGroup; + CAdInventory *GetInventory(); + + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + virtual HRESULT AfterMove(); + CAdRegion *_currentRegions[MAX_NUM_REGIONS]; + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + + CBArray _attachmentsPre; + CBArray _attachmentsPost; + + HRESULT UpdateSpriteAttachments(); + HRESULT DisplaySpriteAttachments(bool PreDisplay); + CAdObject *_registerAlias; +private: + HRESULT DisplaySpriteAttachment(CAdObject *Attachment); + CAdInventory *_inventory; + +protected: + HRESULT GetScale(float *ScaleX, float *ScaleY); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp new file mode 100644 index 0000000000..210f13f68b --- /dev/null +++ b/engines/wintermute/Ad/AdPath.cpp @@ -0,0 +1,112 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdPath.h" +#include "engines/wintermute/BPoint.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPath, false) + +////////////////////////////////////////////////////////////////////////// +CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPath::~CAdPath() { + Reset(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::Reset() { + for (int i = 0; i < _points.GetSize(); i++) + delete _points[i]; + + _points.RemoveAll(); + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetFirst() { + if (_points.GetSize() > 0) { + _currIndex = 0; + return _points[_currIndex]; + } else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetNext() { + _currIndex++; + if (_currIndex < _points.GetSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::GetCurrent() { + if (_currIndex >= 0 && _currIndex < _points.GetSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::AddPoint(CBPoint *point) { + _points.Add(point); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::SetReady(bool ready) { + bool orig = _ready; + _ready = ready; + + return orig; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdPath::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_currIndex)); + _points.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_ready)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPath.h b/engines/wintermute/Ad/AdPath.h new file mode 100644 index 0000000000..d921e78c0a --- /dev/null +++ b/engines/wintermute/Ad/AdPath.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATH_H +#define WINTERMUTE_ADPATH_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/BBase.h" + +namespace WinterMute { +class CBPoint; +class CAdPath : public CBBase { +public: + DECLARE_PERSISTENT(CAdPath, CBBase) + CBPoint *GetCurrent(); + bool SetReady(bool ready = true); + void AddPoint(CBPoint *point); + CBPoint *GetNext(); + CBPoint *GetFirst(); + void Reset(); + CAdPath(CBGame *inGame); + virtual ~CAdPath(); + CBArray _points; + int _currIndex; + bool _ready; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp new file mode 100644 index 0000000000..c66a7769f5 --- /dev/null +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdPathPoint.h" +#include "engines/wintermute/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPathPoint, false) + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint() { + x = y = 0; + _distance = 0; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { + x = initX; + y = initY; + _distance = initDistance; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::~CAdPathPoint() { + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdPathPoint::Persist(CBPersistMgr *PersistMgr) { + + CBPoint::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_distance)); + PersistMgr->Transfer(TMEMBER(_marked)); + PersistMgr->Transfer(TMEMBER(_origin)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPathPoint.h b/engines/wintermute/Ad/AdPathPoint.h new file mode 100644 index 0000000000..bb31223dbb --- /dev/null +++ b/engines/wintermute/Ad/AdPathPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATHPOINT_H +#define WINTERMUTE_ADPATHPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BPoint.h" + +namespace WinterMute { + +class CAdPathPoint : public CBPoint { +public: + DECLARE_PERSISTENT(CAdPathPoint, CBPoint) + CAdPathPoint(int initX, int initY, int initDistance); + CAdPathPoint(); + virtual ~CAdPathPoint(); + CAdPathPoint *_origin; + bool _marked; + int _distance; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp new file mode 100644 index 0000000000..41022a85aa --- /dev/null +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -0,0 +1,394 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdRegion.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRegion, false) + +////////////////////////////////////////////////////////////////////////// +CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { + _blocked = false; + _decoration = false; + _zoom = 0; + _alpha = 0xFFFFFFFF; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRegion::~CAdRegion() { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(ZOOM) +TOKEN_DEF(SCALE) +TOKEN_DEF(BLOCKED) +TOKEN_DEF(DECORATION) +TOKEN_DEF(POINT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(ZOOM) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(BLOCKED) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(POINT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + Game->LOG(0, "'REGION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int i; + + for (i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); + + int ar = 255, ag = 255, ab = 255, alpha = 255; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &_active); + break; + + case TOKEN_BLOCKED: + parser.ScanStr((char *)params, "%b", &_blocked); + break; + + case TOKEN_DECORATION: + parser.ScanStr((char *)params, "%b", &_decoration); + break; + + case TOKEN_ZOOM: + case TOKEN_SCALE: { + int i; + parser.ScanStr((char *)params, "%d", &i); + _zoom = (float)i; + } + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + _points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in REGION definition"); + return E_FAIL; + } + + CreateRegion(); + + _alpha = DRGBA(ar, ag, ab, alpha); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + /* + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "SkipTo")==0){ + Stack->CorrectParams(2); + _posX = Stack->Pop()->GetInt(); + _posY = Stack->Pop()->GetInt(); + Stack->PushNULL(); + + return S_OK; + } + + else*/ return CBRegion::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdRegion::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("ad region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Blocked") == 0) { + _scValue->SetBool(_blocked); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + _scValue->SetBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + _scValue->SetFloat(_zoom); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + _scValue->SetInt((int)_alpha); + return _scValue; + } + + else return CBRegion::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Blocked") == 0) { + _blocked = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + _decoration = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + _zoom = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + _alpha = (uint32)Value->GetInt(); + return S_OK; + } + + else return CBRegion::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdRegion::ScToString() { + return "[ad region]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "REGION {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + int i; + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + + for (i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRegion::Persist(CBPersistMgr *PersistMgr) { + CBRegion::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_alpha)); + PersistMgr->Transfer(TMEMBER(_blocked)); + PersistMgr->Transfer(TMEMBER(_decoration)); + PersistMgr->Transfer(TMEMBER(_zoom)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h new file mode 100644 index 0000000000..37be803a9e --- /dev/null +++ b/engines/wintermute/Ad/AdRegion.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADREGION_H +#define WINTERMUTE_ADREGION_H + +#include "engines/wintermute/BRegion.h" + +namespace WinterMute { + +class CAdRegion : public CBRegion { +public: + DECLARE_PERSISTENT(CAdRegion, CBRegion) + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; + CAdRegion(CBGame *inGame); + virtual ~CAdRegion(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp new file mode 100644 index 0000000000..3db37385b6 --- /dev/null +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -0,0 +1,143 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdResponse.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponse, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { + _text = NULL; + _textOrig = NULL; + _icon = _iconHover = _iconPressed = NULL; + _font = NULL; + _iD = 0; + _responseType = RESPONSE_ALWAYS; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponse::~CAdResponse() { + delete[] _text; + delete[] _textOrig; + delete _icon; + delete _iconHover; + delete _iconPressed; + _text = NULL; + _textOrig = NULL; + _icon = NULL; + _iconHover = NULL; + _iconPressed = NULL; + if (_font) Game->_fontStorage->RemoveFont(_font); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponse::SetText(const char *Text) { + CBUtils::SetString(&_text, Text); + CBUtils::SetString(&_textOrig, Text); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIcon(const char *Filename) { + delete _icon; + _icon = new CBSprite(Game); + if (!_icon || FAILED(_icon->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); + delete _icon; + _icon = NULL; + return E_FAIL; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetFont(const char *Filename) { + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont(Filename); + if (!_font) { + Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", Filename); + return E_FAIL; + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIconHover(const char *Filename) { + delete _iconHover; + _iconHover = new CBSprite(Game); + if (!_iconHover || FAILED(_iconHover->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); + delete _iconHover; + _iconHover = NULL; + return E_FAIL; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::SetIconPressed(const char *Filename) { + delete _iconPressed; + _iconPressed = new CBSprite(Game); + if (!_iconPressed || FAILED(_iconPressed->LoadFile(Filename))) { + Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); + delete _iconPressed; + _iconPressed = NULL; + return E_FAIL; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponse::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_icon)); + PersistMgr->Transfer(TMEMBER(_iconHover)); + PersistMgr->Transfer(TMEMBER(_iconPressed)); + PersistMgr->Transfer(TMEMBER(_iD)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER(_textOrig)); + PersistMgr->Transfer(TMEMBER_INT(_responseType)); + PersistMgr->Transfer(TMEMBER(_font)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h new file mode 100644 index 0000000000..88f6fc03a8 --- /dev/null +++ b/engines/wintermute/Ad/AdResponse.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSE_H +#define WINTERMUTE_ADRESPONSE_H + + +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Ad/AdTypes.h" + +namespace WinterMute { +class CBFont; +class CAdResponse : public CBObject { +public: + DECLARE_PERSISTENT(CAdResponse, CBObject) + HRESULT SetIcon(const char *Filename); + HRESULT SetFont(const char *Filename); + HRESULT SetIconHover(const char *Filename); + HRESULT SetIconPressed(const char *Filename); + void SetText(const char *Text); + int _iD; + CBSprite *_icon; + CBSprite *_iconHover; + CBSprite *_iconPressed; + CBFont *_font; + char *_text; + char *_textOrig; + CAdResponse(CBGame *inGame); + virtual ~CAdResponse(); + TResponseType _responseType; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp new file mode 100644 index 0000000000..d50e25e088 --- /dev/null +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -0,0 +1,645 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdResponseBox.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/UIButton.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/Ad/AdResponse.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { + _font = _fontHover = NULL; + + _window = NULL; + _shieldWindow = new CUIWindow(Game); + + _horizontal = false; + CBPlatform::SetRectEmpty(&_responseArea); + _scrollOffset = 0; + _spacing = 0; + + _waitingScript = NULL; + _lastResponseText = NULL; + _lastResponseTextOrig = NULL; + + _verticalAlign = VAL_BOTTOM; + _align = TAL_LEFT; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::~CAdResponseBox() { + + delete _window; + _window = NULL; + delete _shieldWindow; + _shieldWindow = NULL; + delete[] _lastResponseText; + _lastResponseText = NULL; + delete[] _lastResponseTextOrig; + _lastResponseTextOrig = NULL; + + if (_font) Game->_fontStorage->RemoveFont(_font); + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + + ClearResponses(); + ClearButtons(); + + _waitingScript = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::ClearResponses() { + for (int i = 0; i < _responses.GetSize(); i++) { + delete _responses[i]; + } + _responses.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::ClearButtons() { + for (int i = 0; i < _respButtons.GetSize(); i++) { + delete _respButtons[i]; + } + _respButtons.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::InvalidateButtons() { + for (int i = 0; i < _respButtons.GetSize(); i++) { + _respButtons[i]->_image = NULL; + _respButtons[i]->_cursor = NULL; + _respButtons[i]->_font = NULL; + _respButtons[i]->_fontHover = NULL; + _respButtons[i]->_fontPress = NULL; + _respButtons[i]->SetText(""); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::CreateButtons() { + ClearButtons(); + + _scrollOffset = 0; + for (int i = 0; i < _responses.GetSize(); i++) { + CUIButton *btn = new CUIButton(Game); + if (btn) { + btn->_parent = _window; + btn->_sharedFonts = btn->_sharedImages = true; + btn->_sharedCursors = true; + // iconic + if (_responses[i]->_icon) { + btn->_image = _responses[i]->_icon; + if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; + if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; + + btn->SetCaption(_responses[i]->_text); + if (_cursor) btn->_cursor = _cursor; + else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor; + } + // textual + else { + btn->SetText(_responses[i]->_text); + btn->_font = (_font == NULL) ? Game->_systemFont : _font; + btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover; + btn->_fontPress = btn->_fontHover; + btn->_align = _align; + + if (Game->_touchInterface) + btn->_fontHover = btn->_font; + + + if (_responses[i]->_font) btn->_font = _responses[i]->_font; + + btn->_width = _responseArea.right - _responseArea.left; + if (btn->_width <= 0) btn->_width = Game->_renderer->_width; + } + btn->SetName("response"); + btn->CorrectSize(); + + // make the responses touchable + if (Game->_touchInterface) + btn->_height = MAX(btn->_height, 50); + + //btn->SetListener(this, btn, _responses[i]->_iD); + btn->SetListener(this, btn, i); + btn->_visible = false; + _respButtons.Add(btn); + + if (_responseArea.bottom - _responseArea.top < btn->_height) { + Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); + _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); + } + } + } + _ready = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT) +TOKEN_DEF(AREA) +TOKEN_DEF(HORIZONTAL) +TOKEN_DEF(SPACING) +TOKEN_DEF(WINDOW) +TOKEN_DEF(CURSOR) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT) + TOKEN_TABLE(AREA) + TOKEN_TABLE(HORIZONTAL) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + Game->LOG(0, "'RESPONSE_BOX' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(Game); + if (!_window || FAILED(_window->LoadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else if (_shieldWindow) _shieldWindow->_parent = _window; + break; + + case TOKEN_FONT: + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + _fontHover = Game->_fontStorage->AddFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AREA: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); + break; + + case TOKEN_HORIZONTAL: + parser.ScanStr((char *)params, "%b", &_horizontal); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_LEFT; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; + else _verticalAlign = VAL_BOTTOM; + break; + + case TOKEN_SPACING: + parser.ScanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in RESPONSE_BOX definition"); + return E_FAIL; + } + + if (_window) { + for (int i = 0; i < _window->_widgets.GetSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); + + switch (_align) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CAdResponseBox::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + } + + Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // window + if (_window) _window->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Display() { + RECT rect = _responseArea; + if (_window) { + CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + //_window->Display(); + } + + int xxx, yyy, i; + + xxx = rect.left; + yyy = rect.top; + + // shift down if needed + if (!_horizontal) { + int total_height = 0; + for (i = 0; i < _respButtons.GetSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + total_height -= _spacing; + + switch (_verticalAlign) { + case VAL_BOTTOM: + if (yyy + total_height < rect.bottom) + yyy = rect.bottom - total_height; + break; + + case VAL_CENTER: + if (yyy + total_height < rect.bottom) + yyy += ((rect.bottom - rect.top) - total_height) / 2; + break; + + case VAL_TOP: + // do nothing + break; + } + } + + // prepare response buttons + bool scroll_needed = false; + for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) + || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { + + scroll_needed = true; + _respButtons[i]->_visible = false; + break; + } + + _respButtons[i]->_visible = true; + _respButtons[i]->_posX = xxx; + _respButtons[i]->_posY = yyy; + + if (_horizontal) { + xxx += (_respButtons[i]->_width + _spacing); + } else { + yyy += (_respButtons[i]->_height + _spacing); + } + } + + // show appropriate scroll buttons + if (_window) { + _window->ShowWidget("prev", _scrollOffset > 0); + _window->ShowWidget("next", scroll_needed); + } + + // go exclusive + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; + + _shieldWindow->Display(); + } + + // display window + if (_window) _window->Display(); + + + // display response buttons + for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + _respButtons[i]->Display(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset--; + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset++; + } else if (scumm_stricmp(obj->_name, "response") == 0) { + if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD); + HandleResponse(_responses[param2]); + _waitingScript = NULL; + Game->_state = GAME_RUNNING; + ((CAdGame *)Game)->_stateEx = GAME_NORMAL; + _ready = true; + InvalidateButtons(); + ClearResponses(); + } else return CBObject::Listen(param1, param2); + break; + default: + error("AdResponseBox::Listen - Unhandled enum"); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_fontHover)); + PersistMgr->Transfer(TMEMBER(_horizontal)); + PersistMgr->Transfer(TMEMBER(_lastResponseText)); + PersistMgr->Transfer(TMEMBER(_lastResponseTextOrig)); + _respButtons.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_responseArea)); + _responses.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER(_spacing)); + PersistMgr->Transfer(TMEMBER(_waitingScript)); + PersistMgr->Transfer(TMEMBER(_window)); + + PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); + PersistMgr->Transfer(TMEMBER_INT(_align)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::WeedResponses() { + CAdGame *AdGame = (CAdGame *)Game; + + for (int i = 0; i < _responses.GetSize(); i++) { + switch (_responses[i]->_responseType) { + case RESPONSE_ONCE: + if (AdGame->BranchResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.RemoveAt(i); + i--; + } + break; + + case RESPONSE_ONCE_GAME: + if (AdGame->GameResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.RemoveAt(i); + i--; + } + break; + default: + error("CAdResponseBox::WeedResponses - Unhandled enum"); + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::SetLastResponseText(const char *Text, const char *TextOrig) { + CBUtils::SetString(&_lastResponseText, Text); + CBUtils::SetString(&_lastResponseTextOrig, TextOrig); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { + SetLastResponseText(Response->_text, Response->_textOrig); + + CAdGame *AdGame = (CAdGame *)Game; + + switch (Response->_responseType) { + case RESPONSE_ONCE: + AdGame->AddBranchResponse(Response->_iD); + break; + + case RESPONSE_ONCE_GAME: + AdGame->AddGameResponse(Response->_iD); + break; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::GetNextAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = 0; i < Objects.GetSize(); i++) { + if (Objects[i] == CurrObject) { + if (i < Objects.GetSize() - 1) return Objects[i + 1]; + else break; + } + } + } + return Objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = Objects.GetSize() - 1; i >= 0; i--) { + if (Objects[i] == CurrObject) { + if (i > 0) return Objects[i - 1]; + else break; + } + } + } + return Objects[Objects.GetSize() - 1]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseBox::GetObjects(CBArray &Objects, bool InteractiveOnly) { + for (int i = 0; i < _respButtons.GetSize(); i++) { + Objects.Add(_respButtons[i]); + } + if (_window) _window->GetWindowObjects(Objects, InteractiveOnly); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h new file mode 100644 index 0000000000..cf98cfadca --- /dev/null +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSEBOX_H +#define WINTERMUTE_ADRESPONSEBOX_H + + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CUIButton; +class CUIWindow; +class CUIObject; +class CAdResponse; +class CAdResponseBox : public CBObject { +public: + CBObject *GetNextAccessObject(CBObject *CurrObject); + CBObject *GetPrevAccessObject(CBObject *CurrObject); + HRESULT GetObjects(CBArray &Objects, bool InteractiveOnly); + + HRESULT HandleResponse(CAdResponse *Response); + void SetLastResponseText(const char *Text, const char *TextOrig); + char *_lastResponseText; + char *_lastResponseTextOrig; + DECLARE_PERSISTENT(CAdResponseBox, CBObject) + CScScript *_waitingScript; + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + typedef enum { + EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE + } TResponseEvent; + + HRESULT WeedResponses(); + HRESULT Display(); + int _spacing; + int _scrollOffset; + CBFont *_fontHover; + CBFont *_font; + HRESULT CreateButtons(); + HRESULT InvalidateButtons(); + void ClearButtons(); + void ClearResponses(); + CAdResponseBox(CBGame *inGame); + virtual ~CAdResponseBox(); + CBArray _responses; + CBArray _respButtons; + CUIWindow *_window; + CUIWindow *_shieldWindow; + bool _horizontal; + RECT _responseArea; + int _verticalAlign; + TTextAlign _align; + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp new file mode 100644 index 0000000000..482edbcb4d --- /dev/null +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdResponseContext.h" +#include "engines/wintermute/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseContext, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { + _iD = 0; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::~CAdResponseContext() { + delete[] _context; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(_context)); + PersistMgr->Transfer(TMEMBER(_iD)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdResponseContext::SetContext(const char *Context) { + delete[] _context; + _context = NULL; + if (Context) { + _context = new char [strlen(Context) + 1]; + if (_context) strcpy(_context, Context); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseContext.h b/engines/wintermute/Ad/AdResponseContext.h new file mode 100644 index 0000000000..84ca44ef6f --- /dev/null +++ b/engines/wintermute/Ad/AdResponseContext.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSECONTEXT_H +#define WINTERMUTE_ADRESPONSECONTEXT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BBase.h" + +namespace WinterMute { + +class CAdResponseContext : public CBBase { +public: + void SetContext(const char *Context); + int _iD; + char *_context; + DECLARE_PERSISTENT(CAdResponseContext, CBBase) + CAdResponseContext(CBGame *inGame); + virtual ~CAdResponseContext(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp new file mode 100644 index 0000000000..ea1681660a --- /dev/null +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -0,0 +1,159 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdRotLevel.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRotLevel, false) + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { + _posX = 0; + _rotation = 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::~CAdRotLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(X) +TOKEN_DEF(ROTATION) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(X) + TOKEN_TABLE(ROTATION) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_ROTATION: { + int i; + parser.ScanStr((char *)params, "%d", &i); + _rotation = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ROTATION_LEVEL definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); + CBBase::SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdRotLevel::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_rotation)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h new file mode 100644 index 0000000000..dd3b318a34 --- /dev/null +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADROTLEVEL_H +#define WINTERMUTE_ADROTLEVEL_H + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CAdRotLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdRotLevel, CBObject) + CAdRotLevel(CBGame *inGame); + virtual ~CAdRotLevel(); + float _rotation; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp new file mode 100644 index 0000000000..06729c6435 --- /dev/null +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -0,0 +1,157 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdScaleLevel.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScaleLevel, false) + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { + _posY = 0; + _scale = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::~CAdScaleLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(Y) +TOKEN_DEF(SCALE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(Y) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + Game->LOG(0, "'SCALE_LEVEL' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SCALE: { + int i; + parser.ScanStr((char *)params, "%d", &i); + _scale = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SCALE_LEVEL definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); + CBBase::SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScaleLevel::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_scale)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h new file mode 100644 index 0000000000..9cda5cf4d0 --- /dev/null +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCALELEVEL_H +#define WINTERMUTE_ADSCALELEVEL_H + + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { + +class CAdScaleLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdScaleLevel, CBObject) + float _scale; + CAdScaleLevel(CBGame *inGame); + virtual ~CAdScaleLevel(); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp new file mode 100644 index 0000000000..f7cd60c555 --- /dev/null +++ b/engines/wintermute/Ad/AdScene.cpp @@ -0,0 +1,2763 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/Ad/AdActor.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdLayer.h" +#include "engines/wintermute/Ad/AdNodeState.h" +#include "engines/wintermute/Ad/AdObject.h" +#include "engines/wintermute/Ad/AdPath.h" +#include "engines/wintermute/Ad/AdPathPoint.h" +#include "engines/wintermute/Ad/AdRotLevel.h" +#include "engines/wintermute/Ad/AdScaleLevel.h" +#include "engines/wintermute/Ad/AdSceneNode.h" +#include "engines/wintermute/Ad/AdSceneState.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BPoint.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BScriptable.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/utils.h" +#include +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScene, false) + +////////////////////////////////////////////////////////////////////////// +CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { + _pFTarget = new CBPoint; + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdScene::~CAdScene() { + Cleanup(); + Game->UnregisterObject(_fader); + delete _pFTarget; + _pFTarget = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SetDefaults() { + _initialized = false; + _pFReady = true; + _pFTargetPath = NULL; + _pFRequester = NULL; + _mainLayer = NULL; + + _pFPointsNum = 0; + _persistentState = false; + _persistentStateSprites = true; + + _autoScroll = true; + _offsetLeft = _offsetTop = 0; + _targetOffsetLeft = _targetOffsetTop = 0; + + _lastTimeH = _lastTimeV = 0; + _scrollTimeH = _scrollTimeV = 10; + _scrollPixelsH = _scrollPixelsV = 1; + + _pFMaxTime = 15; + + _paralaxScrolling = true; + + // editor settings + _editorMarginH = _editorMarginV = 100; + + _editorColFrame = 0xE0888888; + _editorColEntity = 0xFF008000; + _editorColRegion = 0xFF0000FF; + _editorColBlocked = 0xFF800080; + _editorColWaypoints = 0xFF0000FF; + _editorColEntitySel = 0xFFFF0000; + _editorColRegionSel = 0xFFFF0000; + _editorColBlockedSel = 0xFFFF0000; + _editorColWaypointsSel = 0xFFFF0000; + _editorColScale = 0xFF00FF00; + _editorColDecor = 0xFF00FFFF; + _editorColDecorSel = 0xFFFF0000; + + _editorShowRegions = true; + _editorShowBlocked = true; + _editorShowDecor = true; + _editorShowEntities = true; + _editorShowScale = true; + + _shieldWindow = NULL; + + _fader = new CBFader(Game); + Game->RegisterObject(_fader); + + _viewport = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::Cleanup() { + CBObject::Cleanup(); + + _mainLayer = NULL; // reference only + + int i; + + delete _shieldWindow; + _shieldWindow = NULL; + + Game->UnregisterObject(_fader); + _fader = NULL; + + for (i = 0; i < _layers.GetSize(); i++) + Game->UnregisterObject(_layers[i]); + _layers.RemoveAll(); + + + for (i = 0; i < _waypointGroups.GetSize(); i++) + Game->UnregisterObject(_waypointGroups[i]); + _waypointGroups.RemoveAll(); + + for (i = 0; i < _scaleLevels.GetSize(); i++) + Game->UnregisterObject(_scaleLevels[i]); + _scaleLevels.RemoveAll(); + + for (i = 0; i < _rotLevels.GetSize(); i++) + Game->UnregisterObject(_rotLevels[i]); + _rotLevels.RemoveAll(); + + + for (i = 0; i < _pFPath.GetSize(); i++) + delete _pFPath[i]; + _pFPath.RemoveAll(); + _pFPointsNum = 0; + + for (i = 0; i < _objects.GetSize(); i++) + Game->UnregisterObject(_objects[i]); + _objects.RemoveAll(); + + delete _viewport; + _viewport = NULL; + + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { + if (!_pFReady) return false; + else { + _pFReady = false; + *_pFTarget = target; + _pFTargetPath = path; + _pFRequester = requester; + + _pFTargetPath->Reset(); + _pFTargetPath->SetReady(false); + + // prepare working path + int i; + PFPointsStart(); + + // first point + //_pFPath.Add(new CAdPathPoint(source.x, source.y, 0)); + + // if we're one pixel stuck, get unstuck + int StartX = source.x; + int StartY = source.y; + int BestDistance = 1000; + if (IsBlockedAt(StartX, StartY, true, requester)) { + int Tolerance = 2; + for (int xxx = StartX - Tolerance; xxx <= StartX + Tolerance; xxx++) { + for (int yyy = StartY - Tolerance; yyy <= StartY + Tolerance; yyy++) { + if (IsWalkableAt(xxx, yyy, true, requester)) { + int Distance = abs(xxx - source.x) + abs(yyy - source.y); + if (Distance < BestDistance) { + StartX = xxx; + StartY = yyy; + + BestDistance = Distance; + } + } + } + } + } + + PFPointsAdd(StartX, StartY, 0); + + //CorrectTargetPoint(&target.x, &target.y); + + // last point + //_pFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); + PFPointsAdd(target.x, target.y, INT_MAX); + + // active waypoints + for (i = 0; i < _waypointGroups.GetSize(); i++) { + if (_waypointGroups[i]->_active) { + PFAddWaypointGroup(_waypointGroups[i], requester); + } + } + + + // free waypoints + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { + PFAddWaypointGroup(_objects[i]->_currentWptGroup, requester); + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != requester && AdGame->_objects[i]->_currentWptGroup) { + PFAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); + } + } + + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { + if (!Wpt->_active) return; + + for (int i = 0; i < Wpt->_points.GetSize(); i++) { + if (IsBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; + + //_pFPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + PFPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); + } +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetZoomAt(int X, int Y) { + float ret = 100; + + bool found = false; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_zoom != 0) { + ret = Node->_region->_zoom; + found = true; + break; + } + } + } + } + if (!found) ret = GetScaleAt(Y); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { + if (!Game->_dEBUG_DebugMode) ColorCheck = false; + + uint32 ret; + if (ColorCheck) ret = 0xFFFF0000; + else ret = 0xFFFFFFFF; + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && (ColorCheck || !Node->_region->_blocked) && Node->_region->PointInRegion(X, Y)) { + if (!Node->_region->_blocked) ret = Node->_region->_alpha; + break; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { + bool ret = true; + + + if (CheckFreeObjects) { + int i; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { + if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + /* + if(Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) + { + ret = true; + break; + } + */ + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_blocked) { + ret = true; + break; + } else ret = false; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { + bool ret = false; + + + if (CheckFreeObjects) { + int i; + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; + } + } + CAdGame *AdGame = (CAdGame *)Game; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { + if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_blocked) { + ret = false; + break; + } else ret = true; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { + double xStep, yStep, X, Y; + int xLength, yLength, xCount, yCount; + int X1, Y1, X2, Y2; + + X1 = p1.x; + Y1 = p1.y; + X2 = p2.x; + Y2 = p2.y; + + xLength = abs(X2 - X1); + yLength = abs(Y2 - Y1); + + if (xLength > yLength) { + if (X1 > X2) { + CBUtils::Swap(&X1, &X2); + CBUtils::Swap(&Y1, &Y2); + } + + yStep = (double)(Y2 - Y1) / (double)(X2 - X1); + Y = Y1; + + for (xCount = X1; xCount < X2; xCount++) { + if (IsBlockedAt(xCount, (int)Y, true, requester)) return -1; + Y += yStep; + } + } else { + if (Y1 > Y2) { + CBUtils::Swap(&X1, &X2); + CBUtils::Swap(&Y1, &Y2); + } + + xStep = (double)(X2 - X1) / (double)(Y2 - Y1); + X = X1; + + for (yCount = Y1; yCount < Y2; yCount++) { + if (IsBlockedAt((int)X, yCount, true, requester)) return -1; + X += xStep; + } + } + return MAX(xLength, yLength); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PathFinderStep() { + int i; + // get lowest unmarked + int lowest_dist = INT_MAX; + CAdPathPoint *lowest_pt = NULL; + + for (i = 0; i < _pFPointsNum; i++) + if (!_pFPath[i]->_marked && _pFPath[i]->_distance < lowest_dist) { + lowest_dist = _pFPath[i]->_distance; + lowest_pt = _pFPath[i]; + } + + if (lowest_pt == NULL) { // no path -> terminate PathFinder + _pFReady = true; + _pFTargetPath->SetReady(true); + return; + } + + lowest_pt->_marked = true; + + // target point marked, generate path and terminate + if (lowest_pt->x == _pFTarget->x && lowest_pt->y == _pFTarget->y) { + while (lowest_pt != NULL) { + _pFTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); + lowest_pt = lowest_pt->_origin; + } + + _pFReady = true; + _pFTargetPath->SetReady(true); + return; + } + + // otherwise keep on searching + for (i = 0; i < _pFPointsNum; i++) + if (!_pFPath[i]->_marked) { + int j = GetPointsDist(*lowest_pt, *_pFPath[i], _pFRequester); + if (j != -1 && lowest_pt->_distance + j < _pFPath[i]->_distance) { + _pFPath[i]->_distance = lowest_pt->_distance + j; + _pFPath[i]->_origin = lowest_pt; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::InitLoop() { +#ifdef _DEBUGxxxx + int nu_steps = 0; + uint32 start = Game->_currentTime; + while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) { + PathFinderStep(); + nu_steps++; + } + if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pFMaxTime=%d", nu_steps, _pFReady ? "finished" : "not yet done", _pFMaxTime); +#else + uint32 start = Game->_currentTime; + while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) PathFinderStep(); +#endif + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + delete[] _filename; + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCENE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(LAYER) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(CAMERA) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(EDITOR_MARGIN_H) +TOKEN_DEF(EDITOR_MARGIN_V) +TOKEN_DEF(EDITOR_COLOR_FRAME) +TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION_SEL) +TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) +TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION) +TOKEN_DEF(EDITOR_COLOR_DECORATION) +TOKEN_DEF(EDITOR_COLOR_BLOCKED) +TOKEN_DEF(EDITOR_COLOR_ENTITY) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) +TOKEN_DEF(EDITOR_COLOR_SCALE) +TOKEN_DEF(EDITOR_SHOW_REGIONS) +TOKEN_DEF(EDITOR_SHOW_BLOCKED) +TOKEN_DEF(EDITOR_SHOW_DECORATION) +TOKEN_DEF(EDITOR_SHOW_ENTITIES) +TOKEN_DEF(EDITOR_SHOW_SCALE) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(VIEWPORT) +TOKEN_DEF(PERSISTENT_STATE_SPRITES) +TOKEN_DEF(PERSISTENT_STATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCENE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(CAMERA) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(EDITOR_MARGIN_H) + TOKEN_TABLE(EDITOR_MARGIN_V) + TOKEN_TABLE(EDITOR_COLOR_FRAME) + TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) + TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION) + TOKEN_TABLE(EDITOR_COLOR_DECORATION) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED) + TOKEN_TABLE(EDITOR_COLOR_ENTITY) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) + TOKEN_TABLE(EDITOR_COLOR_SCALE) + TOKEN_TABLE(EDITOR_SHOW_REGIONS) + TOKEN_TABLE(EDITOR_SHOW_DECORATION) + TOKEN_TABLE(EDITOR_SHOW_BLOCKED) + TOKEN_TABLE(EDITOR_SHOW_ENTITIES) + TOKEN_TABLE(EDITOR_SHOW_SCALE) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(VIEWPORT) + TOKEN_TABLE(PERSISTENT_STATE_SPRITES) + TOKEN_TABLE(PERSISTENT_STATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + Cleanup(); + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + Game->LOG(0, "'SCENE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int ar, ag, ab, aa; + char camera[MAX_PATH] = ""; + float WaypointHeight = -1.0f; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_LAYER: { + CAdLayer *layer = new CAdLayer(Game); + if (!layer || FAILED(layer->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete layer; + layer = NULL; + } else { + Game->RegisterObject(layer); + _layers.Add(layer); + if (layer->_main) { + _mainLayer = layer; + _width = layer->_width; + _height = layer->_height; + } + } + } + break; + + case TOKEN_WAYPOINTS: { + CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + if (!wpt || FAILED(wpt->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete wpt; + wpt = NULL; + } else { + Game->RegisterObject(wpt); + _waypointGroups.Add(wpt); + } + } + break; + + case TOKEN_SCALE_LEVEL: { + CAdScaleLevel *sl = new CAdScaleLevel(Game); + if (!sl || FAILED(sl->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete sl; + sl = NULL; + } else { + Game->RegisterObject(sl); + _scaleLevels.Add(sl); + } + } + break; + + case TOKEN_ROTATION_LEVEL: { + CAdRotLevel *rl = new CAdRotLevel(Game); + if (!rl || FAILED(rl->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete rl; + rl = NULL; + } else { + Game->RegisterObject(rl); + _rotLevels.Add(rl); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(Game); + if (!entity || FAILED(entity->LoadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + entity = NULL; + } else { + AddObject(entity); + } + } + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CAMERA: + strcpy(camera, (char *)params); + break; + + case TOKEN_EDITOR_MARGIN_H: + parser.ScanStr((char *)params, "%d", &_editorMarginH); + break; + + case TOKEN_EDITOR_MARGIN_V: + parser.ScanStr((char *)params, "%d", &_editorMarginV); + break; + + case TOKEN_EDITOR_COLOR_FRAME: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColFrame = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntity = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntitySel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegionSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecorSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlockedSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypointsSel = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegion = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecor = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlocked = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypoints = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_SCALE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColScale = DRGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_SHOW_REGIONS: + parser.ScanStr((char *)params, "%b", &_editorShowRegions); + break; + + case TOKEN_EDITOR_SHOW_BLOCKED: + parser.ScanStr((char *)params, "%b", &_editorShowBlocked); + break; + + case TOKEN_EDITOR_SHOW_DECORATION: + parser.ScanStr((char *)params, "%b", &_editorShowDecor); + break; + + case TOKEN_EDITOR_SHOW_ENTITIES: + parser.ScanStr((char *)params, "%b", &_editorShowEntities); + break; + + case TOKEN_EDITOR_SHOW_SCALE: + parser.ScanStr((char *)params, "%b", &_editorShowScale); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_VIEWPORT: { + RECT rc; + parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) _viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); + } + + case TOKEN_PERSISTENT_STATE: + parser.ScanStr((char *)params, "%b", &_persistentState); + break; + + case TOKEN_PERSISTENT_STATE_SPRITES: + parser.ScanStr((char *)params, "%b", &_persistentStateSprites); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SCENE definition"); + return E_FAIL; + } + + if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); + + + SortScaleLevels(); + SortRotLevels(); + + _initialized = true; + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::TraverseNodes(bool Update) { + if (!_initialized) return S_OK; + + int j, k; + CAdGame *AdGame = (CAdGame *)Game; + + + ////////////////////////////////////////////////////////////////////////// + // prepare viewport + bool PopViewport = false; + if (_viewport && !Game->_editorMode) { + Game->PushViewport(_viewport); + PopViewport = true; + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + Game->PushViewport(AdGame->_sceneViewport); + PopViewport = true; + } + + + ////////////////////////////////////////////////////////////////////////// + // *** adjust scroll offset + if (Update) { + /* + if(_autoScroll && Game->_mainObject != NULL) + { + ScrollToObject(Game->_mainObject); + } + */ + + if (_autoScroll) { + // adjust horizontal scroll + if (Game->_timer - _lastTimeH >= _scrollTimeH) { + _lastTimeH = Game->_timer; + if (_offsetLeft < _targetOffsetLeft) { + _offsetLeft += _scrollPixelsH; + _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); + } else if (_offsetLeft > _targetOffsetLeft) { + _offsetLeft -= _scrollPixelsH; + _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); + } + } + + // adjust vertical scroll + if (Game->_timer - _lastTimeV >= _scrollTimeV) { + _lastTimeV = Game->_timer; + if (_offsetTop < _targetOffsetTop) { + _offsetTop += _scrollPixelsV; + _offsetTop = MIN(_offsetTop, _targetOffsetTop); + } else if (_offsetTop > _targetOffsetTop) { + _offsetTop -= _scrollPixelsV; + _offsetTop = MAX(_offsetTop, _targetOffsetTop); + } + } + + if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; + } else _ready = true; // not scrolling, i.e. always ready + } + + + + + ////////////////////////////////////////////////////////////////////////// + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + int ViewportX, ViewportY; + GetViewportOffset(&ViewportX, &ViewportY); + + int ScrollableX = _width - ViewportWidth; + int ScrollableY = _height - ViewportHeight; + + double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)ScrollableX); + double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)ScrollableY); + + int OrigX, OrigY; + Game->GetOffset(&OrigX, &OrigY); + + + + ////////////////////////////////////////////////////////////////////////// + // *** display/update everything + Game->_renderer->Setup2D(); + + // for each layer + /* int MainOffsetX = 0; */ + /* int MainOffsetY = 0; */ + + for (j = 0; j < _layers.GetSize(); j++) { + if (!_layers[j]->_active) continue; + + // make layer exclusive + if (!Update) { + if (_layers[j]->_closeUp && !Game->_editorMode) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; + _shieldWindow->Display(); + } + } + } + + if (_paralaxScrolling) { + int OffsetX = (int)(WidthRatio * (_layers[j]->_width - ViewportWidth) - ViewportX); + int OffsetY = (int)(HeightRatio * (_layers[j]->_height - ViewportHeight) - ViewportY); + Game->SetOffset(OffsetX, OffsetY); + + Game->_offsetPercentX = (float)OffsetX / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; + Game->_offsetPercentY = (float)OffsetY / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; + + //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); + } else { + Game->SetOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); + + Game->_offsetPercentX = (float)(_offsetLeft - ViewportX) / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; + Game->_offsetPercentY = (float)(_offsetTop - ViewportY) / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; + } + + + // for each node + for (k = 0; k < _layers[j]->_nodes.GetSize(); k++) { + CAdSceneNode *Node = _layers[j]->_nodes[k]; + switch (Node->_type) { + case OBJECT_ENTITY: + if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { + Game->_renderer->Setup2D(); + + if (Update) Node->_entity->Update(); + else Node->_entity->Display(); + } + break; + + case OBJECT_REGION: { + if (Node->_region->_blocked) break; + if (Node->_region->_decoration) break; + + if (!Update) DisplayRegionContent(Node->_region); + } + break; + default: + error("AdScene::TraverseNodes - Unhandled enum"); + break; + } // switch + } // each node + + // display/update all objects which are off-regions + if (_layers[j]->_main) { + if (Update) { + UpdateFreeObjects(); + } else { + DisplayRegionContent(NULL); + } + } + } // each layer + + + // restore state + Game->SetOffset(OrigX, OrigY); + Game->_renderer->Setup2D(); + + // display/update fader + if (_fader) { + if (Update) _fader->Update(); + else _fader->Display(); + } + + if (PopViewport) Game->PopViewport(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Display() { + return TraverseNodes(false); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::UpdateFreeObjects() { + CAdGame *AdGame = (CAdGame *)Game; + int i; + + bool Is3DSet; + + // *** update all active objects + Is3DSet = false; + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (!AdGame->_objects[i]->_active) continue; + + AdGame->_objects[i]->Update(); + AdGame->_objects[i]->_drawn = false; + } + + + for (i = 0; i < _objects.GetSize(); i++) { + if (!_objects[i]->_active) continue; + + _objects[i]->Update(); + _objects[i]->_drawn = false; + } + + + if (_autoScroll && Game->_mainObject != NULL) { + ScrollToObject(Game->_mainObject); + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { + CAdGame *AdGame = (CAdGame *)Game; + CBArray Objects; + CAdObject *Obj; + + int i; + + // global objects + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + Obj = AdGame->_objects[i]; + if (Obj->_active && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + Objects.Add(Obj); + } + } + + // scene objects + for (i = 0; i < _objects.GetSize(); i++) { + Obj = _objects[i]; + if (Obj->_active && !Obj->_editorOnly && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + Objects.Add(Obj); + } + } + + // sort by _posY + qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); + + // display them + for (i = 0; i < Objects.GetSize(); i++) { + Obj = Objects[i]; + + if (Display3DOnly && !Obj->_is3D) continue; + + Game->_renderer->Setup2D(); + + if (Game->_editorMode || !Obj->_editorOnly) Obj->Display(); + Obj->_drawn = true; + } + + + // display design only objects + if (!Display3DOnly) { + if (Game->_editorMode && Region == NULL) { + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->Display(); + _objects[i]->_drawn = true; + } + } + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { + CAdObject *Object1 = *(CAdObject **)Obj1; + CAdObject *Object2 = *(CAdObject **)Obj2; + + if (Object1->_posY < Object2->_posY) return -1; + else if (Object1->_posY > Object2->_posY) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { + CAdGame *AdGame = (CAdGame *)Game; + CAdObject *obj; + int i; + + // display all objects in region sorted by _posY + do { + obj = NULL; + int minY = INT_MAX; + + // global objects + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + if (AdGame->_objects[i]->_active && !AdGame->_objects[i]->_drawn && AdGame->_objects[i]->_posY < minY && (AdGame->_objects[i]->_stickRegion == Region || Region == NULL || (AdGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(AdGame->_objects[i]->_posX, AdGame->_objects[i]->_posY)))) { + obj = AdGame->_objects[i]; + minY = AdGame->_objects[i]->_posY; + } + } + + // scene objects + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == Region || Region == NULL || (_objects[i]->_stickRegion == NULL && Region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + obj = _objects[i]; + minY = _objects[i]->_posY; + } + } + + + if (obj != NULL) { + Game->_renderer->Setup2D(); + + if (Game->_editorMode || !obj->_editorOnly) obj->Display(); + obj->_drawn = true; + } + } while (obj != NULL); + + + // design only objects + if (Game->_editorMode && Region == NULL) { + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->Display(); + _objects[i]->_drawn = true; + } + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Update() { + return TraverseNodes(true); +} + +////////////////////////////////////////////////////////////////////////// +void CAdScene::ScrollTo(int OffsetX, int OffsetY) { + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + int OrigOffsetLeft = _targetOffsetLeft; + int OrigOffsetTop = _targetOffsetTop; + + _targetOffsetLeft = MAX(0, OffsetX - ViewportWidth / 2); + _targetOffsetLeft = MIN(_targetOffsetLeft, _width - ViewportWidth); + + _targetOffsetTop = MAX(0, OffsetY - ViewportHeight / 2); + _targetOffsetTop = MIN(_targetOffsetTop, _height - ViewportHeight); + + + if (Game->_mainObject && Game->_mainObject->_is3D) { + if (abs(OrigOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = OrigOffsetLeft; + if (abs(OrigOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = OrigOffsetTop; + //_targetOffsetTop = 0; + } + + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::ScrollToObject(CBObject *Object) { + if (Object) ScrollTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SkipToObject(CBObject *Object) { + if (Object) SkipTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SkipTo(int OffsetX, int OffsetY) { + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + _offsetLeft = MAX(0, OffsetX - ViewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); + + _offsetTop = MAX(0, OffsetY - ViewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - ViewportHeight); + + _targetOffsetLeft = _offsetLeft; + _targetOffsetTop = _offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LoadActor") == 0) { + Stack->CorrectParams(1); + CAdActor *act = new CAdActor(Game); + if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + AddObject(act); + Stack->PushNative(act, true); + } else { + delete act; + act = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadEntity") == 0) { + Stack->CorrectParams(1); + CAdEntity *ent = new CAdEntity(Game); + if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + AddObject(ent); + Stack->PushNative(ent, true); + } else { + delete ent; + ent = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEntity") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdEntity *Ent = new CAdEntity(Game); + AddObject(Ent); + if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + Stack->PushNative(Ent, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "UnloadActor3D") == 0 || strcmp(Name, "DeleteEntity") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CAdObject *obj = (CAdObject *)val->GetNative(); + RemoveObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SkipTo") == 0) { + Stack->CorrectParams(2); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + if (val1->IsNative()) { + SkipToObject((CBObject *)val1->GetNative()); + } else { + SkipTo(val1->GetInt(), val2->GetInt()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollTo / ScrollToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollTo") == 0 || strcmp(Name, "ScrollToAsync") == 0) { + Stack->CorrectParams(2); + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + if (val1->IsNative()) { + ScrollToObject((CBObject *)val1->GetNative()); + } else { + ScrollTo(val1->GetInt(), val2->GetInt()); + } + if (strcmp(Name, "ScrollTo") == 0) Script->WaitForExclusive(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetLayer") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + if (val->IsInt()) { + int layer = val->GetInt(); + if (layer < 0 || layer >= _layers.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_layers[layer], true); + } else { + const char *LayerName = val->GetString(); + bool LayerFound = false; + for (int i = 0; i < _layers.GetSize(); i++) { + if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { + Stack->PushNative(_layers[i], true); + LayerFound = true; + break; + } + } + if (!LayerFound) Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaypointGroup + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaypointGroup") == 0) { + Stack->CorrectParams(1); + int group = Stack->Pop()->GetInt(); + if (group < 0 || group >= _waypointGroups.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_waypointGroups[group], true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetNode") == 0) { + Stack->CorrectParams(1); + const char *Name = Stack->Pop()->GetString(); + + CBObject *node = GetNodeByName(Name); + if (node) Stack->PushNative((CBScriptable *)node, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFreeNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFreeNode") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdObject *Ret = NULL; + if (Val->IsInt()) { + int Index = Val->GetInt(); + if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; + } else { + const char *Name = Val->GetString(); + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, Name) == 0) { + Ret = _objects[i]; + break; + } + } + } + if (Ret) Stack->PushNative(Ret, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRegionAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRegionAt") == 0) { + Stack->CorrectParams(3); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + bool IncludeDecors = false; + if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { + if (Node->_region->_decoration && !IncludeDecors) continue; + + Stack->PushNative(Node->_region, true); + return S_OK; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsBlockedAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsBlockedAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushBool(IsBlockedAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalkableAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsWalkableAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushBool(IsWalkableAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetScaleAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetScaleAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushFloat(GetZoomAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRotationAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRotationAt") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + Stack->PushFloat(GetRotationAt(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScrolling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsScrolling") == 0) { + Stack->CorrectParams(0); + bool Ret = false; + if (_autoScroll) { + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; + } + + Stack->PushBool(Ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(_fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); + if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(_fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFadeColor") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_fader->GetCurrentColor()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsPointInViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsPointInViewport") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + Stack->PushBool(PointInViewport(X, Y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetViewport") == 0) { + Stack->CorrectParams(4); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + int Width = Stack->Pop()->GetInt(); + int Height = Stack->Pop()->GetInt(); + + if (Width <= 0) Width = Game->_renderer->_width; + if (Height <= 0) Height = Game->_renderer->_height; + + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) _viewport->SetRect(X, Y, X + Width, Y + Height); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddLayer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdLayer *Layer = new CAdLayer(Game); + if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (_mainLayer) { + Layer->_width = _mainLayer->_width; + Layer->_height = _mainLayer->_height; + } + _layers.Add(Layer); + Game->RegisterObject(Layer); + + Stack->PushNative(Layer, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertLayer") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + CAdLayer *Layer = new CAdLayer(Game); + if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (_mainLayer) { + Layer->_width = _mainLayer->_width; + Layer->_height = _mainLayer->_height; + } + if (Index < 0) Index = 0; + if (Index <= _layers.GetSize() - 1) _layers.InsertAt(Index, Layer); + else _layers.Add(Layer); + + Game->RegisterObject(Layer); + + Stack->PushNative(Layer, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteLayer") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CAdLayer *ToDelete = NULL; + if (Val->IsNative()) { + CBScriptable *Temp = Val->GetNative(); + for (int i = 0; i < _layers.GetSize(); i++) { + if (_layers[i] == Temp) { + ToDelete = _layers[i]; + break; + } + } + } else { + int Index = Val->GetInt(); + if (Index >= 0 && Index < _layers.GetSize()) { + ToDelete = _layers[Index]; + } + } + if (ToDelete == NULL) { + Stack->PushBool(false); + return S_OK; + } + + if (ToDelete->_main) { + Script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); + Stack->PushBool(false); + return S_OK; + } + + for (int i = 0; i < _layers.GetSize(); i++) { + if (_layers[i] == ToDelete) { + _layers.RemoveAt(i); + Game->UnregisterObject(ToDelete); + break; + } + } + Stack->PushBool(true); + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdScene::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("scene"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumLayers (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumLayers") == 0) { + _scValue->SetInt(_layers.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWaypointGroups (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumWaypointGroups") == 0) { + _scValue->SetInt(_waypointGroups.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainLayer (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainLayer") == 0) { + if (_mainLayer) _scValue->SetNative(_mainLayer, true); + else _scValue->SetNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFreeNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumFreeNodes") == 0) { + _scValue->SetInt(_objects.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + int ViewportX; + GetViewportOffset(&ViewportX); + + _scValue->SetInt(Game->_mousePos.x + _offsetLeft - ViewportX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + int ViewportY; + GetViewportOffset(NULL, &ViewportY); + + _scValue->SetInt(Game->_mousePos.y + _offsetTop - ViewportY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoScroll") == 0) { + _scValue->SetBool(_autoScroll); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentState") == 0) { + _scValue->SetBool(_persistentState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentStateSprites") == 0) { + _scValue->SetBool(_persistentStateSprites); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsX") == 0) { + _scValue->SetInt(_scrollPixelsH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsY") == 0) { + _scValue->SetInt(_scrollPixelsV); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedX") == 0) { + _scValue->SetInt(_scrollTimeH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedY") == 0) { + _scValue->SetInt(_scrollTimeV); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetX") == 0) { + _scValue->SetInt(_offsetLeft); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetY") == 0) { + _scValue->SetInt(_offsetTop); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + if (_mainLayer) _scValue->SetInt(_mainLayer->_width); + else _scValue->SetInt(0); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + if (_mainLayer) _scValue->SetInt(_mainLayer->_height); + else _scValue->SetInt(0); + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoScroll") == 0) { + _autoScroll = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentState") == 0) { + _persistentState = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PersistentStateSprites") == 0) { + _persistentStateSprites = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsX") == 0) { + _scrollPixelsH = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollPixelsY") == 0) { + _scrollPixelsV = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedX") == 0) { + _scrollTimeH = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScrollSpeedY") == 0) { + _scrollTimeV = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetX") == 0) { + _offsetLeft = Value->GetInt(); + + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + _offsetLeft = MAX(0, _offsetLeft - ViewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); + _targetOffsetLeft = _offsetLeft; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OffsetY") == 0) { + _offsetTop = Value->GetInt(); + + int ViewportWidth, ViewportHeight; + GetViewportSize(&ViewportWidth, &ViewportHeight); + + _offsetTop = MAX(0, _offsetTop - ViewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - ViewportHeight); + _targetOffsetTop = _offsetTop; + + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdScene::ScToString() { + return "[scene object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::AddObject(CAdObject *Object) { + _objects.Add(Object); + return Game->RegisterObject(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::RemoveObject(CAdObject *Object) { + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i] == Object) { + _objects.RemoveAt(i); + return Game->UnregisterObject(Object); + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { + int i; + + Buffer->PutTextIndent(Indent, "SCENE {\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + if (_persistentState) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + + if (!_persistentStateSprites) + Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + + + // scripts + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // properties + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + + // viewport + if (_viewport) { + RECT *rc = _viewport->GetRect(); + Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + } + + + + // editor settings + Buffer->PutTextIndent(Indent + 2, "; ----- editor settings\n"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); + Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); + + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + // waypoints + Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); + for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // layers + Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); + for (i = 0; i < _layers.GetSize(); i++) _layers[i]->SaveAsText(Buffer, Indent + 2); + + // scale levels + Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); + for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->SaveAsText(Buffer, Indent + 2); + + // rotation levels + Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); + for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // free entities + Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + _objects[i]->SaveAsText(Buffer, Indent + 2); + + } + } + + + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SortScaleLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _scaleLevels.GetSize() - 1; i++) { + if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { + CAdScaleLevel *sl = _scaleLevels[i]; + _scaleLevels[i] = _scaleLevels[i + 1]; + _scaleLevels[i + 1] = sl; + + changed = true; + } + } + + } while (changed); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SortRotLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _rotLevels.GetSize() - 1; i++) { + if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { + CAdRotLevel *rl = _rotLevels[i]; + _rotLevels[i] = _rotLevels[i + 1]; + _rotLevels[i + 1] = rl; + + changed = true; + } + } + + } while (changed); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetScaleAt(int Y) { + CAdScaleLevel *prev = NULL; + CAdScaleLevel *next = NULL; + + for (int i = 0; i < _scaleLevels.GetSize(); i++) { + CAdScaleLevel *xxx = _scaleLevels[i]; + int j = _scaleLevels.GetSize(); + if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; + else { + next = _scaleLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 100; + + int delta_y = next->_posY - prev->_posY; + float delta_scale = next->_scale - prev->_scale; + Y -= prev->_posY; + + float percent = (float)Y / ((float)delta_y / 100.0f); + return prev->_scale + delta_scale / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_autoScroll)); + PersistMgr->Transfer(TMEMBER(_editorColBlocked)); + PersistMgr->Transfer(TMEMBER(_editorColBlockedSel)); + PersistMgr->Transfer(TMEMBER(_editorColDecor)); + PersistMgr->Transfer(TMEMBER(_editorColDecorSel)); + PersistMgr->Transfer(TMEMBER(_editorColEntity)); + PersistMgr->Transfer(TMEMBER(_editorColEntitySel)); + PersistMgr->Transfer(TMEMBER(_editorColFrame)); + PersistMgr->Transfer(TMEMBER(_editorColRegion)); + PersistMgr->Transfer(TMEMBER(_editorColRegionSel)); + PersistMgr->Transfer(TMEMBER(_editorColScale)); + PersistMgr->Transfer(TMEMBER(_editorColWaypoints)); + PersistMgr->Transfer(TMEMBER(_editorColWaypointsSel)); + PersistMgr->Transfer(TMEMBER(_editorMarginH)); + PersistMgr->Transfer(TMEMBER(_editorMarginV)); + PersistMgr->Transfer(TMEMBER(_editorShowBlocked)); + PersistMgr->Transfer(TMEMBER(_editorShowDecor)); + PersistMgr->Transfer(TMEMBER(_editorShowEntities)); + PersistMgr->Transfer(TMEMBER(_editorShowRegions)); + PersistMgr->Transfer(TMEMBER(_editorShowScale)); + PersistMgr->Transfer(TMEMBER(_fader)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_initialized)); + PersistMgr->Transfer(TMEMBER(_lastTimeH)); + PersistMgr->Transfer(TMEMBER(_lastTimeV)); + _layers.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_mainLayer)); + _objects.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_offsetLeft)); + PersistMgr->Transfer(TMEMBER(_offsetTop)); + PersistMgr->Transfer(TMEMBER(_paralaxScrolling)); + PersistMgr->Transfer(TMEMBER(_persistentState)); + PersistMgr->Transfer(TMEMBER(_persistentStateSprites)); + PersistMgr->Transfer(TMEMBER(_pFMaxTime)); + _pFPath.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_pFPointsNum)); + PersistMgr->Transfer(TMEMBER(_pFReady)); + PersistMgr->Transfer(TMEMBER(_pFRequester)); + PersistMgr->Transfer(TMEMBER(_pFTarget)); + PersistMgr->Transfer(TMEMBER(_pFTargetPath)); + _rotLevels.Persist(PersistMgr); + _scaleLevels.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_scrollPixelsH)); + PersistMgr->Transfer(TMEMBER(_scrollPixelsV)); + PersistMgr->Transfer(TMEMBER(_scrollTimeH)); + PersistMgr->Transfer(TMEMBER(_scrollTimeV)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER(_targetOffsetLeft)); + PersistMgr->Transfer(TMEMBER(_targetOffsetTop)); + _waypointGroups.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_viewport)); + PersistMgr->Transfer(TMEMBER(_width)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::AfterLoad() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { + double xStep, yStep, X, Y; + int xLength, yLength, xCount, yCount; + int X1, Y1, X2, Y2; + + X1 = *TargetX; + Y1 = *TargetY; + X2 = StartX; + Y2 = StartY; + + + xLength = abs(X2 - X1); + yLength = abs(Y2 - Y1); + + if (xLength > yLength) { + /* + if(X1 > X2) + { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + yStep = fabs((double)(Y2 - Y1) / (double)(X2 - X1)); + Y = Y1; + + for (xCount = X1; xCount < X2; xCount++) { + if (IsWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { + *TargetX = xCount; + *TargetY = (int)Y; + return S_OK; + } + Y += yStep; + } + } else { + /* + if(Y1 > Y2) { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + xStep = fabs((double)(X2 - X1) / (double)(Y2 - Y1)); + X = X1; + + for (yCount = Y1; yCount < Y2; yCount++) { + if (IsWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { + *TargetX = (int)X; + *TargetY = yCount; + return S_OK; + } + X += xStep; + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { + int x = *X; + int y = *Y; + + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { + return S_OK; + } + + // right + int length_right = 0; + bool found_right = false; + for (x = *X, y = *Y; x < _mainLayer->_width; x++, length_right++) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { + found_right = true; + break; + } + } + + // left + int length_left = 0; + bool found_left = false; + for (x = *X, y = *Y; x >= 0; x--, length_left--) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { + found_left = true; + break; + } + } + + // up + int length_up = 0; + bool found_up = false; + for (x = *X, y = *Y; y >= 0; y--, length_up--) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { + found_up = true; + break; + } + } + + // down + int length_down = 0; + bool found_down = false; + for (x = *X, y = *Y; y < _mainLayer->_height; y++, length_down++) { + if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { + found_down = true; + break; + } + } + + if (!found_left && !found_right && !found_up && !found_down) { + return S_OK; + } + + int OffsetX = INT_MAX, OffsetY = INT_MAX; + + if (found_left && found_right) { + if (abs(length_left) < abs(length_right)) OffsetX = length_left; + else OffsetX = length_right; + } else if (found_left) OffsetX = length_left; + else if (found_right) OffsetX = length_right; + + if (found_up && found_down) { + if (abs(length_up) < abs(length_down)) OffsetY = length_up; + else OffsetY = length_down; + } else if (found_up) OffsetY = length_up; + else if (found_down) OffsetY = length_down; + + if (abs(OffsetX) < abs(OffsetY)) + *X = *X + OffsetX; + else + *Y = *Y + OffsetY; + + if (!IsWalkableAt(*X, *Y)) return CorrectTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFPointsStart() { + _pFPointsNum = 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::PFPointsAdd(int X, int Y, int Distance) { + if (_pFPointsNum >= _pFPath.GetSize()) { + _pFPath.Add(new CAdPathPoint(X, Y, Distance)); + } else { + _pFPath[_pFPointsNum]->x = X; + _pFPath[_pFPointsNum]->y = Y; + _pFPath[_pFPointsNum]->_distance = Distance; + _pFPath[_pFPointsNum]->_marked = false; + _pFPath[_pFPointsNum]->_origin = NULL; + } + + _pFPointsNum++; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { + CAdGame *AdGame = (CAdGame *)Game; + if (_viewport && !Game->_editorMode) { + if (OffsetX) *OffsetX = _viewport->_offsetX; + if (OffsetY) *OffsetY = _viewport->_offsetY; + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + if (OffsetX) *OffsetX = AdGame->_sceneViewport->_offsetX; + if (OffsetY) *OffsetY = AdGame->_sceneViewport->_offsetY; + } else { + if (OffsetX) *OffsetX = 0; + if (OffsetY) *OffsetY = 0; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { + CAdGame *AdGame = (CAdGame *)Game; + if (_viewport && !Game->_editorMode) { + if (Width) *Width = _viewport->GetWidth(); + if (Height) *Height = _viewport->GetHeight(); + } else if (AdGame->_sceneViewport && !Game->_editorMode) { + if (Width) *Width = AdGame->_sceneViewport->GetWidth(); + if (Height) *Height = AdGame->_sceneViewport->GetHeight(); + } else { + if (Width) *Width = Game->_renderer->_width; + if (Height) *Height = Game->_renderer->_height; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetOffsetLeft() { + int ViewportX; + GetViewportOffset(&ViewportX); + + return _offsetLeft - ViewportX; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::GetOffsetTop() { + int ViewportY; + GetViewportOffset(NULL, &ViewportY); + + return _offsetTop - ViewportY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::PointInViewport(int X, int Y) { + int Left, Top, Width, Height; + + GetViewportOffset(&Left, &Top); + GetViewportSize(&Width, &Height); + + return X >= Left && X <= Left + Width && Y >= Top && Y <= Top + Height; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { + _offsetLeft = OffsetLeft; + _offsetTop = OffsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetNodeByName(const char *Name) { + int i; + CBObject *ret = NULL; + + // dependent objects + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.GetSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(Name, node->_entity->_name)) || + (node->_type == OBJECT_REGION && !scumm_stricmp(Name, node->_region->_name))) { + switch (node->_type) { + case OBJECT_ENTITY: + ret = node->_entity; + break; + case OBJECT_REGION: + ret = node->_region; + break; + default: + ret = NULL; + } + return ret; + } + } + } + + // free entities + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(Name, _objects[i]->_name)) { + return _objects[i]; + } + } + + // waypoint groups + for (i = 0; i < _waypointGroups.GetSize(); i++) { + if (!scumm_stricmp(Name, _waypointGroups[i]->_name)) { + return _waypointGroups[i]; + } + } + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::SaveState() { + return PersistState(true); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::LoadState() { + return PersistState(false); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::PersistState(bool Saving) { + if (!_persistentState) return S_OK; + + CAdGame *AdGame = (CAdGame *)Game; + CAdSceneState *State = AdGame->GetSceneState(_filename, Saving); + if (!State) return S_OK; + + + int i; + CAdNodeState *NodeState; + + // dependent objects + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.GetSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: + if (!node->_entity->_saveState) continue; + NodeState = State->GetNodeState(node->_entity->_name, Saving); + if (NodeState) { + NodeState->TransferEntity(node->_entity, _persistentStateSprites, Saving); + //if(Saving) NodeState->_active = node->_entity->_active; + //else node->_entity->_active = NodeState->_active; + } + break; + case OBJECT_REGION: + if (!node->_region->_saveState) continue; + NodeState = State->GetNodeState(node->_region->_name, Saving); + if (NodeState) { + if (Saving) NodeState->_active = node->_region->_active; + else node->_region->_active = NodeState->_active; + } + break; + } + } + } + + // free entities + for (i = 0; i < _objects.GetSize(); i++) { + if (!_objects[i]->_saveState) continue; + if (_objects[i]->_type == OBJECT_ENTITY) { + NodeState = State->GetNodeState(_objects[i]->_name, Saving); + if (NodeState) { + NodeState->TransferEntity((CAdEntity *)_objects[i], _persistentStateSprites, Saving); + //if(Saving) NodeState->_active = _objects[i]->_active; + //else _objects[i]->_active = NodeState->_active; + } + } + } + + // waypoint groups + for (i = 0; i < _waypointGroups.GetSize(); i++) { + NodeState = State->GetNodeState(_waypointGroups[i]->_name, Saving); + if (NodeState) { + if (Saving) NodeState->_active = _waypointGroups[i]->_active; + else _waypointGroups[i]->_active = NodeState->_active; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::GetRotationAt(int X, int Y) { + CAdRotLevel *prev = NULL; + CAdRotLevel *next = NULL; + + for (int i = 0; i < _rotLevels.GetSize(); i++) { + CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.GetSize(); + if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; + else { + next = _rotLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 0; + + int delta_x = next->_posX - prev->_posX; + float delta_rot = next->_rotation - prev->_rotation; + X -= prev->_posX; + + float percent = (float)X / ((float)delta_x / 100.0f); + return prev->_rotation + delta_rot / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::HandleItemAssociations(const char *ItemName, bool Show) { + int i; + + for (i = 0; i < _layers.GetSize(); i++) { + CAdLayer *Layer = _layers[i]; + for (int j = 0; j < Layer->_nodes.GetSize(); j++) { + if (Layer->_nodes[j]->_type == OBJECT_ENTITY) { + CAdEntity *Ent = Layer->_nodes[j]->_entity; + + if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; + } + } + } + + for (i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + CAdEntity *Ent = (CAdEntity *)_objects[i]; + if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { + int i; + int NumUsed = 0; + if (_mainLayer) { + for (i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *Node = _mainLayer->_nodes[i]; + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { + if (NumUsed < NumRegions - 1) { + RegionList[NumUsed] = Node->_region; + NumUsed++; + } else break; + } + } + } + for (i = NumUsed; i < NumRegions; i++) { + RegionList[i] = NULL; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::RestoreDeviceObjects() { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetNextAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetSceneObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = 0; i < Objects.GetSize(); i++) { + if (Objects[i] == CurrObject) { + if (i < Objects.GetSize() - 1) return Objects[i + 1]; + else break; + } + } + } + return Objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { + CBArray Objects; + GetSceneObjects(Objects, true); + + if (Objects.GetSize() == 0) return NULL; + else { + if (CurrObject != NULL) { + for (int i = Objects.GetSize() - 1; i >= 0; i--) { + if (Objects[i] == CurrObject) { + if (i > 0) return Objects[i - 1]; + else break; + } + } + } + return Objects[Objects.GetSize() - 1]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bool InteractiveOnly) { + for (int i = 0; i < _layers.GetSize(); i++) { + // close-up layer -> remove everything below it + if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); + + + for (int j = 0; j < _layers[i]->_nodes.GetSize(); j++) { + CAdSceneNode *Node = _layers[i]->_nodes[j]; + switch (Node->_type) { + case OBJECT_ENTITY: { + CAdEntity *Ent = Node->_entity; + if (Ent->_active && (Ent->_registrable || !InteractiveOnly)) + Objects.Add(Ent); + } + break; + + case OBJECT_REGION: { + CBArray RegionObj; + GetRegionObjects(Node->_region, RegionObj, InteractiveOnly); + for (int New = 0; New < RegionObj.GetSize(); New++) { + bool Found = false; + for (int Old = 0; Old < Objects.GetSize(); Old++) { + if (Objects[Old] == RegionObj[New]) { + Found = true; + break; + } + } + if (!Found) Objects.Add(RegionObj[New]); + } + //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); + } + break; + } + } + } + + // objects outside any region + CBArray RegionObj; + GetRegionObjects(NULL, RegionObj, InteractiveOnly); + for (int New = 0; New < RegionObj.GetSize(); New++) { + bool Found = false; + for (int Old = 0; Old < Objects.GetSize(); Old++) { + if (Objects[Old] == RegionObj[New]) { + Found = true; + break; + } + } + if (!Found) Objects.Add(RegionObj[New]); + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { + CAdGame *AdGame = (CAdGame *)Game; + CAdObject *Obj; + + int i; + + // global objects + for (i = 0; i < AdGame->_objects.GetSize(); i++) { + Obj = AdGame->_objects[i]; + if (Obj->_active && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + if (InteractiveOnly && !Obj->_registrable) continue; + + Objects.Add(Obj); + } + } + + // scene objects + for (i = 0; i < _objects.GetSize(); i++) { + Obj = _objects[i]; + if (Obj->_active && !Obj->_editorOnly && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { + if (InteractiveOnly && !Obj->_registrable) continue; + + Objects.Add(Obj); + } + } + + // sort by _posY + qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h new file mode 100644 index 0000000000..87bd290970 --- /dev/null +++ b/engines/wintermute/Ad/AdScene.h @@ -0,0 +1,181 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENE_H +#define WINTERMUTE_ADSCENE_H + +#include "engines/wintermute/BFader.h" + +namespace WinterMute { + +class CUIWindow; +class CAdObject; +class CAdRegion; +class CBViewport; +class CAdLayer; +class CBPoint; +class CAdWaypointGroup; +class CAdPath; +class CAdScaleLevel; +class CAdRotLevel; +class CAdPathPoint; +class CAdScene : public CBObject { +public: + + CBObject *GetNextAccessObject(CBObject *CurrObject); + CBObject *GetPrevAccessObject(CBObject *CurrObject); + HRESULT GetSceneObjects(CBArray &Objects, bool InteractiveOnly); + HRESULT GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + + HRESULT AfterLoad(); + + HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + HRESULT HandleItemAssociations(const char *ItemName, bool Show); + CUIWindow *_shieldWindow; + float GetRotationAt(int X, int Y); + HRESULT LoadState(); + HRESULT SaveState(); + bool _persistentState; + bool _persistentStateSprites; + CBObject *GetNodeByName(const char *Name); + void SetOffset(int OffsetLeft, int OffsetTop); + bool PointInViewport(int X, int Y); + int GetOffsetTop(); + int GetOffsetLeft(); + HRESULT GetViewportSize(int *Width = NULL, int *Height = NULL); + HRESULT GetViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + CBViewport *_viewport; + CBFader *_fader; + int _pFPointsNum; + void PFPointsAdd(int X, int Y, int Distance); + void PFPointsStart(); + bool _initialized; + HRESULT CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + HRESULT CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + DECLARE_PERSISTENT(CAdScene, CBObject) + HRESULT DisplayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + HRESULT DisplayRegionContentOld(CAdRegion *Region = NULL); + static int CompareObjs(const void *Obj1, const void *Obj2); + + HRESULT UpdateFreeObjects(); + HRESULT TraverseNodes(bool Update = false); + float GetScaleAt(int Y); + HRESULT SortScaleLevels(); + HRESULT SortRotLevels(); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); + bool _paralaxScrolling; + void SkipTo(int OffsetX, int OffsetY); + void SetDefaults(); + void Cleanup(); + void SkipToObject(CBObject *Object); + void ScrollToObject(CBObject *Object); + void ScrollTo(int OffsetX, int OffsetY); + virtual HRESULT Update(); + bool _autoScroll; + int _targetOffsetTop; + int _targetOffsetLeft; + + int _scrollPixelsV; + uint32 _scrollTimeV; + uint32 _lastTimeV; + + int _scrollPixelsH; + uint32 _scrollTimeH; + uint32 _lastTimeH; + + virtual HRESULT Display(); + uint32 _pFMaxTime; + HRESULT InitLoop(); + void PathFinderStep(); + bool IsBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool IsWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + CAdLayer *_mainLayer; + float GetZoomAt(int X, int Y); + bool GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); + CAdScene(CBGame *inGame); + virtual ~CAdScene(); + CBArray _layers; + CBArray _objects; + CBArray _waypointGroups; + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + int _width; + int _height; + HRESULT AddObject(CAdObject *Object); + HRESULT RemoveObject(CAdObject *Object); + int _editorMarginH; + int _editorMarginV; + uint32 _editorColFrame; + uint32 _editorColEntity; + uint32 _editorColRegion; + uint32 _editorColBlocked; + uint32 _editorColWaypoints; + uint32 _editorColEntitySel; + uint32 _editorColRegionSel; + uint32 _editorColBlockedSel; + uint32 _editorColWaypointsSel; + uint32 _editorColScale; + uint32 _editorColDecor; + uint32 _editorColDecorSel; + + bool _editorShowRegions; + bool _editorShowBlocked; + bool _editorShowDecor; + bool _editorShowEntities; + bool _editorShowScale; + CBArray _scaleLevels; + CBArray _rotLevels; + + virtual HRESULT RestoreDeviceObjects(); + int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + + +private: + HRESULT PersistState(bool Saving = true); + void PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + bool _pFReady; + CBPoint *_pFTarget; + CAdPath *_pFTargetPath; + CBObject *_pFRequester; + CBArray _pFPath; + + int _offsetTop; + int _offsetLeft; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp new file mode 100644 index 0000000000..d7d0ae98cc --- /dev/null +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdSceneNode.h" +#include "engines/wintermute/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _region = NULL; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::~CAdSceneNode() { + Game->UnregisterObject(_region); + _region = NULL; + + Game->UnregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { + _type = OBJECT_ENTITY; + _entity = Entity; + return Game->RegisterObject(Entity); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { + _type = OBJECT_REGION; + _region = Region; + return Game->RegisterObject(Region); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneNode::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_entity)); + PersistMgr->Transfer(TMEMBER(_region)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h new file mode 100644 index 0000000000..f6cc121fbc --- /dev/null +++ b/engines/wintermute/Ad/AdSceneNode.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENENODE_H +#define WINTERMUTE_ADSCENENODE_H + + +#include "engines/wintermute/Ad/AdTypes.h" // Added by ClassView +#include "engines/wintermute/Ad/AdRegion.h" // Added by ClassView +#include "engines/wintermute/Ad/AdEntity.h" + +namespace WinterMute { + +class CAdSceneNode : public CBObject { +public: + DECLARE_PERSISTENT(CAdSceneNode, CBObject) + HRESULT SetRegion(CAdRegion *Region); + HRESULT SetEntity(CAdEntity *Entity); + CAdEntity *_entity; + CAdRegion *_region; + TObjectType _type; + CAdSceneNode(CBGame *inGame); + virtual ~CAdSceneNode(); + +}; + +} + +#endif diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp new file mode 100644 index 0000000000..3a083498fe --- /dev/null +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Ad/AdSceneState.h" +#include "engines/wintermute/Ad/AdNodeState.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneState, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::~CAdSceneState() { + delete[] _filename; + _filename = NULL; + + for (int i = 0; i < _nodeStates.GetSize(); i++) delete _nodeStates[i]; + _nodeStates.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_filename)); + _nodeStates.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSceneState::SetFilename(const char *Filename) { + delete[] _filename; + _filename = new char [strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { + for (int i = 0; i < _nodeStates.GetSize(); i++) { + if (scumm_stricmp(_nodeStates[i]->_name, Name) == 0) return _nodeStates[i]; + } + + if (Saving) { + CAdNodeState *ret = new CAdNodeState(Game); + ret->SetName(Name); + _nodeStates.Add(ret); + + return ret; + } else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSceneState.h b/engines/wintermute/Ad/AdSceneState.h new file mode 100644 index 0000000000..264106b599 --- /dev/null +++ b/engines/wintermute/Ad/AdSceneState.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENESTATE_H +#define WINTERMUTE_ADSCENESTATE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CAdNodeState; +class CAdSceneState : public CBBase { +public: + CAdNodeState *GetNodeState(char *Name, bool Saving); + void SetFilename(const char *Filename); + DECLARE_PERSISTENT(CAdSceneState, CBBase) + CAdSceneState(CBGame *inGame); + virtual ~CAdSceneState(); + char *_filename; + CBArray _nodeStates; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp new file mode 100644 index 0000000000..2395a4996c --- /dev/null +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -0,0 +1,317 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Ad/AdTalkDef.h" +#include "engines/wintermute/Ad/AdTalkNode.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSound.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/BFont.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSentence, false) + +////////////////////////////////////////////////////////////////////////// +CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { + _text = NULL; + _stances = NULL; + _tempStance = NULL; + + _duration = 0; + _startTime = 0; + _currentStance = 0; + + _font = NULL; + + _pos.x = _pos.y = 0; + _width = Game->_renderer->_width; + + _align = (TTextAlign)TAL_CENTER; + + _sound = NULL; + _soundStarted = false; + + _talkDef = NULL; + _currentSprite = NULL; + _currentSkelAnim = NULL; + _fixedPos = false; + _freezable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSentence::~CAdSentence() { + delete _sound; + delete[] _text; + delete[] _stances; + delete[] _tempStance; + delete _talkDef; + _sound = NULL; + _text = NULL; + _stances = NULL; + _tempStance = NULL; + _talkDef = NULL; + + _currentSprite = NULL; // ref only + _currentSkelAnim = NULL; + _font = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetText(const char *Text) { + if (_text) delete [] _text; + _text = new char[strlen(Text) + 1]; + if (_text) strcpy(_text, Text); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetStances(const char *Stances) { + if (_stances) delete [] _stances; + if (Stances) { + _stances = new char[strlen(Stances) + 1]; + if (_stances) strcpy(_stances, Stances); + } else _stances = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetCurrentStance() { + return GetStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetNextStance() { + _currentStance++; + return GetStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::GetStance(int Stance) { + if (_stances == NULL) return NULL; + + if (_tempStance) delete [] _tempStance; + _tempStance = NULL; + + char *start; + char *curr; + int pos; + + if (Stance == 0) start = _stances; + else { + pos = 0; + start = NULL; + curr = _stances; + while (pos < Stance) { + if (*curr == '\0') break; + if (*curr == ',') pos++; + curr++; + } + if (pos == Stance) start = curr; + } + + if (start == NULL) return NULL; + + while (*start == ' ' && *start != ',' && *start != '\0') start++; + + curr = start; + while (*curr != '\0' && *curr != ',') curr++; + + while (curr > start && *(curr - 1) == ' ') curr--; + + _tempStance = new char [curr - start + 1]; + if (_tempStance) { + _tempStance[curr - start] = '\0'; + strncpy(_tempStance, start, curr - start); + } + + return _tempStance; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Display() { + if (!_font || !_text) return E_FAIL; + + if (_sound && !_soundStarted) { + _sound->Play(); + _soundStarted = true; + } + + if (Game->_subtitles) { + int x = _pos.x; + int y = _pos.y; + + if (!_fixedPos) { + x = x - ((CAdGame *)Game)->_scene->GetOffsetLeft(); + y = y - ((CAdGame *)Game)->_scene->GetOffsetTop(); + } + + + x = MAX(x, 0); + x = MIN(x, Game->_renderer->_width - _width); + y = MAX(y, 0); + + _font->DrawText((byte *)_text, x, y, _width, _align); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::SetSound(CBSound *Sound) { + if (!Sound) return; + delete _sound; + _sound = Sound; + _soundStarted = false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Finish() { + if (_sound) _sound->Stop(); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER_INT(_align)); + PersistMgr->Transfer(TMEMBER(_currentStance)); + PersistMgr->Transfer(TMEMBER(_currentSprite)); + PersistMgr->Transfer(TMEMBER(_currentSkelAnim)); + PersistMgr->Transfer(TMEMBER(_duration)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_sound)); + PersistMgr->Transfer(TMEMBER(_soundStarted)); + PersistMgr->Transfer(TMEMBER(_stances)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_talkDef)); + PersistMgr->Transfer(TMEMBER(_tempStance)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER(_width)); + PersistMgr->Transfer(TMEMBER(_fixedPos)); + PersistMgr->Transfer(TMEMBER(_freezable)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { + delete _talkDef; + _talkDef = NULL; + _currentSprite = NULL; + + if (!SoundFilename) return S_OK; + + + AnsiString path = PathUtil::GetDirectoryName(SoundFilename); + AnsiString name = PathUtil::GetFileNameWithoutExtension(SoundFilename); + + AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); + + CBFile *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); + if (file) { + Game->_fileManager->CloseFile(file); + } else return S_OK; // no talk def file found + + + _talkDef = new CAdTalkDef(Game); + if (!_talkDef || FAILED(_talkDef->LoadFile(talkDefFileName.c_str()))) { + delete _talkDef; + _talkDef = NULL; + return E_FAIL; + } + //Game->LOG(0, "Using .talk file: %s", TalkDefFile); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSentence::Update(TDirection Dir) { + if (!_talkDef) return S_OK; + + uint32 CurrentTime; + // if sound is available, synchronize with sound, otherwise use timer + + /* + if(_sound) CurrentTime = _sound->GetPositionTime(); + else CurrentTime = Game->_timer - _startTime; + */ + CurrentTime = Game->_timer - _startTime; + + bool TalkNodeFound = false; + for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { + if (_talkDef->_nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { + TalkNodeFound = true; + + CBSprite *NewSprite = _talkDef->_nodes[i]->GetSprite(Dir); + if (NewSprite != _currentSprite) NewSprite->Reset(); + _currentSprite = NewSprite; + + if (!_talkDef->_nodes[i]->_playToEnd) break; + } + } + + + // no talk node, try to use default sprite instead (if any) + if (!TalkNodeFound) { + CBSprite *NewSprite = _talkDef->GetDefaultSprite(Dir); + if (NewSprite) { + if (NewSprite != _currentSprite) NewSprite->Reset(); + _currentSprite = NewSprite; + } else _currentSprite = NULL; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::CanSkip() { + // prevent accidental sentence skipping (TODO make configurable) + return (Game->_timer - _startTime) > 300; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h new file mode 100644 index 0000000000..495edceee0 --- /dev/null +++ b/engines/wintermute/Ad/AdSentence.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSENTENCE_H +#define WINTERMUTE_ADSENTENCE_H + + +#include "engines/wintermute/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { +class CAdTalkDef; +class CBFont; +class CBSprite; +class CBSound; +class CAdSentence : public CBBase { +public: + bool _freezable; + bool _fixedPos; + CBSprite *_currentSprite; + char *_currentSkelAnim; + HRESULT Update(TDirection Dir = DI_DOWN); + HRESULT SetupTalkFile(const char *SoundFilename); + DECLARE_PERSISTENT(CAdSentence, CBBase) + HRESULT Finish(); + void SetSound(CBSound *Sound); + bool _soundStarted; + CBSound *_sound; + TTextAlign _align; + HRESULT Display(); + int _width; + POINT _pos; + CBFont *_font; + char *GetNextStance(); + char *GetCurrentStance(); + void SetStances(const char *Stances); + void SetText(const char *Text); + int _currentStance; + uint32 _startTime; + char *_stances; + char *_text; + uint32 _duration; + CAdSentence(CBGame *inGame); + virtual ~CAdSentence(); + CAdTalkDef *_talkDef; + + bool CanSkip(); + +private: + char *_tempStance; + char *GetStance(int Stance); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp new file mode 100644 index 0000000000..8ea4849e1c --- /dev/null +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -0,0 +1,313 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdSpriteSet.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSpriteSet, false) + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *Owner): CBObject(inGame) { + _owner = Owner; + + for (int i = 0; i < NUM_DIRECTIONS; i++) + _sprites[i] = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::~CAdSpriteSet() { + for (int i = 0; i < NUM_DIRECTIONS; i++) { + delete _sprites[i]; + _sprites[i] = NULL; + } + + _owner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SPRITESET) +TOKEN_DEF(NAME) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(RIGHT) +TOKEN_DEF(UP) +TOKEN_DEF(DOWN) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(NAME) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(RIGHT) + TOKEN_TABLE(UP) + TOKEN_TABLE(DOWN) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + Game->LOG(0, "'SPRITESET' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + CBSprite *spr = NULL; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_LEFT: + delete _sprites[DI_LEFT]; + _sprites[DI_LEFT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_LEFT] = spr; + break; + + case TOKEN_RIGHT: + delete _sprites[DI_RIGHT]; + _sprites[DI_RIGHT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_RIGHT] = spr; + break; + + case TOKEN_UP: + delete _sprites[DI_UP]; + _sprites[DI_UP] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UP] = spr; + break; + + case TOKEN_DOWN: + delete _sprites[DI_DOWN]; + _sprites[DI_DOWN] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWN] = spr; + break; + + case TOKEN_UP_LEFT: + delete _sprites[DI_UPLEFT]; + _sprites[DI_UPLEFT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPLEFT] = spr; + break; + + case TOKEN_UP_RIGHT: + delete _sprites[DI_UPRIGHT]; + _sprites[DI_UPRIGHT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPRIGHT] = spr; + break; + + case TOKEN_DOWN_LEFT: + delete _sprites[DI_DOWNLEFT]; + _sprites[DI_DOWNLEFT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNLEFT] = spr; + break; + + case TOKEN_DOWN_RIGHT: + delete _sprites[DI_DOWNRIGHT]; + _sprites[DI_DOWNRIGHT] = NULL; + spr = new CBSprite(Game, _owner); + if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNRIGHT] = spr; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SPRITESET definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading SPRITESET definition"); + if (spr) delete spr; + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_owner)); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + PersistMgr->Transfer("", &_sprites[i]); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { + int Dir = (int)Direction; + if (Dir < 0) Dir = 0; + if (Dir >= NUM_DIRECTIONS) Dir = NUM_DIRECTIONS - 1; + + CBSprite *ret = NULL; + + // find nearest set sprite + int i; + int NumSteps = 0; + for (i = Dir, NumSteps = 0; i >= 0; i--) { + if (_sprites[i] != NULL) { + ret = _sprites[i]; + NumSteps = Dir - i; + break; + } + } + + for (i = Dir; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] != NULL) { + if (ret == NULL || NumSteps > i - Dir) return _sprites[i]; + else return ret; + } + } + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SPRITESET {\n"); + if (_name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i]) { + switch (i) { + case DI_UP: + Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPRIGHT: + Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_RIGHT: + Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNRIGHT: + Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWN: + Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNLEFT: + Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_LEFT: + Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPLEFT: + Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + } + } + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { + if (!Sprite) return NULL; + + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] == Sprite) return true; + } + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h new file mode 100644 index 0000000000..4da0fded12 --- /dev/null +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSPRITESET_H +#define WINTERMUTE_ADSPRITESET_H + + +#include "engines/wintermute/BObject.h" +#include "engines/wintermute/BSprite.h" // Added by ClassView + +namespace WinterMute { + +class CAdSpriteSet : public CBObject { +public: + bool ContainsSprite(CBSprite *Sprite); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + CBSprite *GetSprite(TDirection Direction); + DECLARE_PERSISTENT(CAdSpriteSet, CBObject) + CBObject *_owner; + CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); + virtual ~CAdSpriteSet(); + HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + CBSprite *_sprites[NUM_DIRECTIONS]; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp new file mode 100644 index 0000000000..7a5091432f --- /dev/null +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -0,0 +1,260 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdTalkDef.h" +#include "engines/wintermute/Ad/AdTalkNode.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Ad/AdSpriteSet.h" +#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkDef, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::~CAdTalkDef() { + for (int i = 0; i < _nodes.GetSize(); i++) delete _nodes[i]; + _nodes.RemoveAll(); + + delete[] _defaultSpriteFilename; + delete _defaultSprite; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + delete[] _defaultSpriteSetFilename; + delete _defaultSpriteSet; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + CBUtils::SetString(&_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TALK) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(ACTION) +TOKEN_DEF(DEFAULT_SPRITESET_FILE) +TOKEN_DEF(DEFAULT_SPRITESET) +TOKEN_DEF(DEFAULT_SPRITE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(DEFAULT_SPRITESET_FILE) + TOKEN_TABLE(DEFAULT_SPRITESET) + TOKEN_TABLE(DEFAULT_SPRITE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TALK) { + Game->LOG(0, "'TALK' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_ACTION: { + CAdTalkNode *Node = new CAdTalkNode(Game); + if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) _nodes.Add(Node); + else { + delete Node; + Node = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_DEFAULT_SPRITE: + CBUtils::SetString(&_defaultSpriteFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET_FILE: + CBUtils::SetString(&_defaultSpriteSetFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET: { + delete _defaultSpriteSet; + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadBuffer(params, false))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TALK definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading TALK definition"); + return E_FAIL; + } + + delete _defaultSprite; + delete _defaultSpriteSet; + _defaultSprite = NULL; + _defaultSpriteSet = NULL; + + if (_defaultSpriteFilename) { + _defaultSprite = new CBSprite(Game); + if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) return E_FAIL; + } + + if (_defaultSpriteSetFilename) { + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) return E_FAIL; + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_defaultSprite)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteFilename)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteSet)); + PersistMgr->Transfer(TMEMBER(_defaultSpriteSetFilename)); + + _nodes.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "TALK {\n"); + if (_defaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + + if (_defaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + else if (_defaultSpriteSet) _defaultSpriteSet->SaveAsText(Buffer, Indent + 2); + + for (int i = 0; i < _nodes.GetSize(); i++) { + _nodes[i]->SaveAsText(Buffer, Indent + 2); + Buffer->PutTextIndent(Indent, "\n"); + } + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkDef::LoadDefaultSprite() { + if (_defaultSpriteFilename && !_defaultSprite) { + _defaultSprite = new CBSprite(Game); + if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) { + delete _defaultSprite; + _defaultSprite = NULL; + return E_FAIL; + } else return S_OK; + } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { + _defaultSpriteSet = new CAdSpriteSet(Game); + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + return E_FAIL; + } else return S_OK; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkDef::GetDefaultSprite(TDirection Dir) { + LoadDefaultSprite(); + if (_defaultSprite) return _defaultSprite; + else if (_defaultSpriteSet) return _defaultSpriteSet->GetSprite(Dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h new file mode 100644 index 0000000000..7eaafcd6ec --- /dev/null +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKDEF_H +#define WINTERMUTE_ADTALKDEF_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/BObject.h" + +namespace WinterMute { +class CAdTalkNode; +class CAdSpriteSet; +class CAdTalkDef : public CBObject { +public: + char *_defaultSpriteSetFilename; + CAdSpriteSet *_defaultSpriteSet; + CBSprite *GetDefaultSprite(TDirection Dir); + HRESULT LoadDefaultSprite(); + DECLARE_PERSISTENT(CAdTalkDef, CBObject) + + CAdTalkDef(CBGame *inGame); + virtual ~CAdTalkDef(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CBArray _nodes; + char *_defaultSpriteFilename; + CBSprite *_defaultSprite; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp new file mode 100644 index 0000000000..f5ae27967d --- /dev/null +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -0,0 +1,356 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#define FORBIDDEN_SYMBOL_EXCEPTION_rand +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdTalkHolder.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkHolder, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::~CAdTalkHolder() { + delete _sprite; + _sprite = NULL; + + int i; + for (i = 0; i < _talkSprites.GetSize(); i++) delete _talkSprites[i]; + _talkSprites.RemoveAll(); + + for (i = 0; i < _talkSpritesEx.GetSize(); i++) delete _talkSpritesEx[i]; + _talkSpritesEx.RemoveAll(); +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { + CBSprite *ret = NULL; + + + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(Game, this); + if (_animSprite) { + HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); + if (FAILED(res)) { + Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + + if (Stance != NULL) { + // search special talk stances + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + ret = _talkSpritesEx[i]; + break; + } + } + if (ret == NULL) { + // serach generic talk stances + for (int i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + ret = _talkSprites[i]; + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.GetSize() < 1) ret = _sprite; + else { + // TODO: remember last + int rnd = rand() % _talkSprites.GetSize(); + ret = _talkSprites[rnd]; + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSprite") == 0) { + Stack->CorrectParams(1); + + CScValue *Val = Stack->Pop(); + + bool SetCurrent = false; + if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; + + delete _sprite; + _sprite = NULL; + + if (Val->IsNULL()) { + _sprite = NULL; + if (SetCurrent) _currentSprite = NULL; + Stack->PushBool(true); + } else { + const char *Filename = Val->GetString(); + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Script->RuntimeError("SetSprite method failed for file '%s'", Filename); + Stack->PushBool(false); + } else { + _sprite = spr; + if (SetCurrent) _currentSprite = _sprite; + Stack->PushBool(true); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSprite") == 0) { + Stack->CorrectParams(0); + + if (!_sprite || !_sprite->_filename) Stack->PushNULL(); + else Stack->PushString(_sprite->_filename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSpriteObject") == 0) { + Stack->CorrectParams(0); + + if (!_sprite) Stack->PushNULL(); + else Stack->PushNative(_sprite, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddTalkSprite") == 0) { + Stack->CorrectParams(2); + + const char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); + } else { + if (Ex) _talkSpritesEx.Add(spr); + else _talkSprites.Add(spr); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveTalkSprite") == 0) { + Stack->CorrectParams(2); + + const char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + int i; + + bool SetCurrent = false; + bool SetTemp2 = false; + + if (Ex) { + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_filename, Filename) == 0) { + if (_currentSprite == _talkSpritesEx[i]) SetCurrent = true; + if (_tempSprite2 == _talkSpritesEx[i]) SetTemp2 = true; + delete _talkSpritesEx[i]; + _talkSpritesEx.RemoveAt(i); + break; + } + } + } else { + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_filename, Filename) == 0) { + if (_currentSprite == _talkSprites[i]) SetCurrent = true; + if (_tempSprite2 == _talkSprites[i]) SetTemp2 = true; + delete _talkSprites[i]; + _talkSprites.RemoveAt(i); + break; + } + } + + } + + Stack->PushBool(true); + if (SetCurrent) _currentSprite = _sprite; + if (SetTemp2) _tempSprite2 = _sprite; + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetTalkSprite") == 0) { + Stack->CorrectParams(2); + + const char *Filename = Stack->Pop()->GetString(); + bool Ex = Stack->Pop()->GetBool(); + bool SetCurrent = false; + bool SetTemp2 = false; + + CBSprite *spr = new CBSprite(Game, this); + if (!spr || FAILED(spr->LoadFile(Filename))) { + Stack->PushBool(false); + Script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); + } else { + + // delete current + int i; + if (Ex) { + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (_talkSpritesEx[i] == _currentSprite) SetCurrent = true; + if (_talkSpritesEx[i] == _tempSprite2) SetTemp2 = true; + delete _talkSpritesEx[i]; + } + _talkSpritesEx.RemoveAll(); + } else { + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (_talkSprites[i] == _currentSprite) SetCurrent = true; + if (_talkSprites[i] == _tempSprite2) SetTemp2 = true; + delete _talkSprites[i]; + } + _talkSprites.RemoveAll(); + } + + // set new + if (Ex) _talkSpritesEx.Add(spr); + else _talkSprites.Add(spr); + Stack->PushBool(true); + + if (SetCurrent) _currentSprite = spr; + if (SetTemp2) _tempSprite2 = spr; + } + return S_OK; + } + + else return CAdObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdTalkHolder::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("talk-holder"); + return _scValue; + } + + else return CAdObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Item")==0){ + SetItem(Value->GetString()); + return S_OK; + } + + else*/ return CAdObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdTalkHolder::ScToString() { + return "[talk-holder object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { + int i; + for (i = 0; i < _talkSprites.GetSize(); i++) { + if (_talkSprites[i]->_filename) + Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + } + + for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (_talkSpritesEx[i]->_filename) + Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkHolder::Persist(CBPersistMgr *PersistMgr) { + CAdObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_sprite)); + _talkSprites.Persist(PersistMgr); + _talkSpritesEx.Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h new file mode 100644 index 0000000000..7c10783057 --- /dev/null +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKHOLDER_H +#define WINTERMUTE_ADTALKHOLDER_H + +#include "engines/wintermute/Ad/AdObject.h" + +namespace WinterMute { + +class CAdTalkHolder : public CAdObject { +public: + DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) + virtual CBSprite *GetTalkStance(const char *Stance); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + CBSprite *_sprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + CAdTalkHolder(CBGame *inGame); + virtual ~CAdTalkHolder(); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp new file mode 100644 index 0000000000..f2f35539ff --- /dev/null +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -0,0 +1,263 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdTalkNode.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Ad/AdSpriteSet.h" +#include "engines/wintermute/utils.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { + _sprite = NULL; + _spriteFilename = NULL; + _spriteSet = NULL; + _spriteSetFilename = NULL; + _comment = NULL; + + _startTime = _endTime = 0; + _playToEnd = false; + _preCache = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::~CAdTalkNode() { + delete[] _spriteFilename; + delete _sprite; + delete[] _spriteSetFilename; + delete _spriteSet; + delete _comment; + _spriteFilename = NULL; + _sprite = NULL; + _spriteSetFilename = NULL; + _spriteSet = NULL; + _comment = NULL; +} + + + +TOKEN_DEF_START +TOKEN_DEF(ACTION) +TOKEN_DEF(SPRITESET_FILE) +TOKEN_DEF(SPRITESET) +TOKEN_DEF(SPRITE) +TOKEN_DEF(START_TIME) +TOKEN_DEF(END_TIME) +TOKEN_DEF(COMMENT) +TOKEN_DEF(PRECACHE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(SPRITESET_FILE) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(START_TIME) + TOKEN_TABLE(END_TIME) + TOKEN_TABLE(COMMENT) + TOKEN_TABLE(PRECACHE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + Game->LOG(0, "'ACTION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + _endTime = 0; + _playToEnd = false; + _preCache = false; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SPRITE: + CBUtils::SetString(&_spriteFilename, (char *)params); + break; + + case TOKEN_SPRITESET_FILE: + CBUtils::SetString(&_spriteSetFilename, (char *)params); + break; + + case TOKEN_SPRITESET: { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadBuffer(params, false))) { + delete _spriteSet; + _spriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_START_TIME: + parser.ScanStr((char *)params, "%d", &_startTime); + break; + + case TOKEN_END_TIME: + parser.ScanStr((char *)params, "%d", &_endTime); + break; + + case TOKEN_PRECACHE: + parser.ScanStr((char *)params, "%b", &_preCache); + break; + + case TOKEN_COMMENT: + if (Game->_editorMode) CBUtils::SetString(&_comment, (char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ACTION definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ACTION definition"); + return E_FAIL; + } + + if (_endTime == 0) _playToEnd = true; + else _playToEnd = false; + + if (_preCache && _spriteFilename) { + delete _sprite; + _sprite = new CBSprite(Game); + if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) return E_FAIL; + } + + if (_preCache && _spriteSetFilename) { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) return E_FAIL; + } + + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_comment)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_endTime)); + PersistMgr->Transfer(TMEMBER(_playToEnd)); + PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER(_spriteFilename)); + PersistMgr->Transfer(TMEMBER(_spriteSet)); + PersistMgr->Transfer(TMEMBER(_spriteSetFilename)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ACTION {\n"); + if (_comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); + Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + else if (_spriteSet) _spriteSet->SaveAsText(Buffer, Indent + 2); + if (_preCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdTalkNode::LoadSprite() { + if (_spriteFilename && !_sprite) { + _sprite = new CBSprite(Game); + if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) { + delete _sprite; + _sprite = NULL; + return E_FAIL; + } else return S_OK; + } + + else if (_spriteSetFilename && !_spriteSet) { + _spriteSet = new CAdSpriteSet(Game); + if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) { + delete _spriteSet; + _spriteSet = NULL; + return E_FAIL; + } else return S_OK; + } + + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { + if (Time >= _startTime) { + if (_playToEnd) { + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->GetSprite(Dir) && _spriteSet->GetSprite(Dir)->_finished == false)) return true; + else return false; + } else return _endTime >= Time; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkNode::GetSprite(TDirection Dir) { + LoadSprite(); + if (_sprite) return _sprite; + else if (_spriteSet) return _spriteSet->GetSprite(Dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h new file mode 100644 index 0000000000..18781f90da --- /dev/null +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKNODE_H +#define WINTERMUTE_ADTALKNODE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/BBase.h" + +namespace WinterMute { +class CAdSpriteSet; +class CBSprite; +class CAdTalkNode : public CBBase { +public: + char *_spriteSetFilename; + CAdSpriteSet *_spriteSet; + CBSprite *GetSprite(TDirection Dir); + bool IsInTimeInterval(uint32 Time, TDirection Dir); + HRESULT LoadSprite(); + DECLARE_PERSISTENT(CAdTalkNode, CBBase) + + CAdTalkNode(CBGame *inGame); + virtual ~CAdTalkNode(); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + char *_spriteFilename; + CBSprite *_sprite; + uint32 _startTime; + uint32 _endTime; + bool _playToEnd; + bool _preCache; + char *_comment; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Ad/AdTypes.h b/engines/wintermute/Ad/AdTypes.h new file mode 100644 index 0000000000..6531927350 --- /dev/null +++ b/engines/wintermute/Ad/AdTypes.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTYPES_H +#define WINTERMUTE_ADTYPES_H + +namespace WinterMute { + +typedef enum { + GAME_NORMAL, GAME_WAITING_RESPONSE +} TGameStateEx; + + +typedef enum { + OBJECT_ENTITY, OBJECT_REGION, OBJECT_ACTOR, OBJECT_NONE +} TObjectType; + + +typedef enum { + ENTITY_NORMAL, ENTITY_SOUND +} TEntityType; + + +typedef enum { + STATE_NONE, + STATE_IDLE, + STATE_PLAYING_ANIM, + STATE_READY, + STATE_FOLLOWING_PATH, + STATE_SEARCHING_PATH, + STATE_WAITING_PATH, + STATE_TURNING_LEFT, + STATE_TURNING_RIGHT, + STATE_TURNING, + STATE_TALKING, + STATE_DIRECT_CONTROL, + STATE_PLAYING_ANIM_SET +} TObjectState; + +typedef enum { + DIRECT_WALK_NONE, DIRECT_WALK_FW, DIRECT_WALK_BK +} TDirectWalkMode; + +typedef enum { + DIRECT_TURN_NONE, DIRECT_TURN_CW, DIRECT_TURN_CCW +} TDirectTurnMode; + +typedef enum { + RESPONSE_TEXT, RESPONSE_ICON +} TResponseStyle; + +typedef enum { + RESPONSE_ALWAYS, RESPONSE_ONCE, RESPONSE_ONCE_GAME +} TResponseType; + + +typedef enum { + TALK_SKIP_LEFT = 0, TALK_SKIP_RIGHT = 1, TALK_SKIP_BOTH = 2, TALK_SKIP_NONE = 3 +} TTalkSkipButton; + + +typedef enum { + GEOM_WAYPOINT, GEOM_WALKPLANE, GEOM_BLOCKED, GEOM_GENERIC +} TGeomNodeType; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp new file mode 100644 index 0000000000..982079269e --- /dev/null +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -0,0 +1,262 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/BParser.h" +#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/BGame.h" +#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/BFileManager.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; +} + + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::~CAdWaypointGroup() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdWaypointGroup::Cleanup() { + for (int i = 0; i < _points.GetSize(); i++) + delete _points[i]; + _points.RemoveAll(); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(POINT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(POINT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + Game->LOG(0, "'WAYPOINTS' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + _points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in WAYPOINTS definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + CBBase::SaveAsText(Buffer, Indent + 2); + + for (int i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + Buffer->PutTextIndent(Indent, "}\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(_lastMimicScale)); + PersistMgr->Transfer(TMEMBER(_lastMimicX)); + PersistMgr->Transfer(TMEMBER(_lastMimicY)); + _points.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdWaypointGroup::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("waypoint-group"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + _scValue->SetBool(_active); + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Active") == 0) { + _active = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { + if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; + + Cleanup(); + + for (int i = 0; i < Wpt->_points.GetSize(); i++) { + int x, y; + + x = (int)((float)Wpt->_points[i]->x * Scale / 100.0f); + y = (int)((float)Wpt->_points[i]->y * Scale / 100.0f); + + _points.Add(new CBPoint(x + X, y + Y)); + } + + _lastMimicScale = Scale; + _lastMimicX = X; + _lastMimicY = Y; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h new file mode 100644 index 0000000000..ea76bb50fa --- /dev/null +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADWAYPOINTGROUP_H +#define WINTERMUTE_ADWAYPOINTGROUP_H + +#include "engines/wintermute/BObject.h" + +namespace WinterMute { +class CBPoint; +class CAdWaypointGroup : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void Cleanup(); + HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); + DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + bool _active; + CAdWaypointGroup(CBGame *inGame); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual ~CAdWaypointGroup(); + CBArray _points; + int _editorSelectedPoint; + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/AdActor.cpp b/engines/wintermute/AdActor.cpp deleted file mode 100644 index 3778fbaa5f..0000000000 --- a/engines/wintermute/AdActor.cpp +++ /dev/null @@ -1,1339 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/AdActor.h" -#include "engines/wintermute/AdGame.h" -#include "engines/wintermute/AdScene.h" -#include "engines/wintermute/AdEntity.h" -#include "engines/wintermute/AdSpriteSet.h" -#include "engines/wintermute/AdWaypointGroup.h" -#include "engines/wintermute/AdPath.h" -#include "engines/wintermute/AdSentence.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdActor, false) - - -////////////////////////////////////////////////////////////////////////// -CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - _path = new CAdPath(Game); - - _type = OBJECT_ACTOR; - _dir = DI_LEFT; - - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _targetPoint = new CBPoint; - _afterWalkDir = DI_NONE; - - _animSprite2 = NULL; - - SetDefaultAnimNames(); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::SetDefaultAnimNames() { - _talkAnimName = NULL; - CBUtils::SetString(&_talkAnimName, "talk"); - - _idleAnimName = NULL; - CBUtils::SetString(&_idleAnimName, "idle"); - - _walkAnimName = NULL; - CBUtils::SetString(&_walkAnimName, "walk"); - - _turnLeftAnimName = NULL; - CBUtils::SetString(&_turnLeftAnimName, "turnleft"); - - _turnRightAnimName = NULL; - CBUtils::SetString(&_turnRightAnimName, "turnright"); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdActor::~CAdActor() { - delete _path; - delete _targetPoint; - _path = NULL; - _targetPoint = NULL; - - delete _walkSprite; - delete _standSprite; - delete _turnLeftSprite; - delete _turnRightSprite; - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _animSprite2 = NULL; // ref only - - for (int i = 0; i < _talkSprites.GetSize(); i++) { - delete _talkSprites[i]; - } - _talkSprites.RemoveAll(); - - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { - delete _talkSpritesEx[i]; - } - _talkSpritesEx.RemoveAll(); - - - delete[] _talkAnimName; - delete[] _idleAnimName; - delete[] _walkAnimName; - delete[] _turnLeftAnimName; - delete[] _turnRightAnimName; - _talkAnimName = NULL; - _idleAnimName = NULL; - _walkAnimName = NULL; - _turnLeftAnimName = NULL; - _turnRightAnimName = NULL; - - for (int i = 0; i < _anims.GetSize(); i++) { - delete _anims[i]; - _anims[i] = NULL; - } - _anims.RemoveAll(); - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ACTOR) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(WALK) -TOKEN_DEF(STAND) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(TURN_LEFT) -TOKEN_DEF(TURN_RIGHT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ANIMATION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTOR) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(WALK) - TOKEN_TABLE(STAND) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TURN_LEFT) - TOKEN_TABLE(TURN_RIGHT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { - Game->LOG(0, "'ACTOR' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - CAdGame *AdGame = (CAdGame *)Game; - CAdSpriteSet *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); - break; - - case TOKEN_WALK: - delete _walkSprite; - _walkSprite = NULL; - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; - else _walkSprite = spr; - break; - - case TOKEN_TALK: - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); - break; - - case TOKEN_TALK_SPECIAL: - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); - break; - - case TOKEN_STAND: - delete _standSprite; - _standSprite = NULL; - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; - else _standSprite = spr; - break; - - case TOKEN_TURN_LEFT: - delete _turnLeftSprite; - _turnLeftSprite = NULL; - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnLeftSprite = spr; - break; - - case TOKEN_TURN_RIGHT: - delete _turnRightSprite; - _turnRightSprite = NULL; - spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnRightSprite = spr; - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SCALE: { - int s; - parser.ScanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.ScanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(Game); - CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->Mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->Mimic(_wptGroup); - } - } - break; - - case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; - else _anims.Add(Anim); - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ACTOR definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - if (spr) delete spr; - Game->LOG(0, "Error loading ACTOR definition"); - return E_FAIL; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = DRGBA(ar, ag, ab, alpha); - _state = _nextState = STATE_READY; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::TurnTo(TDirection dir) { - int delta1, delta2, delta3, delta; - - delta1 = dir - _dir; - delta2 = dir + NUM_DIRECTIONS - _dir; - delta3 = dir - NUM_DIRECTIONS - _dir; - - delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; - delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; - - // already there? - if (abs(delta) < 2) { - _dir = dir; - _state = _nextState; - _nextState = STATE_READY; - return; - } - - _targetDir = dir; - _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; - - _tempSprite2 = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { - _afterWalkDir = AfterWalkDir; - if (X == _targetPoint->x && Y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; - - _path->Reset(); - _path->SetReady(false); - - _targetPoint->x = X; - _targetPoint->y = Y; - - ((CAdGame *)Game)->_scene->CorrectTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); - - _state = STATE_SEARCHING_PATH; - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Display() { - if (_active) UpdateSounds(); - - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; - - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); - - - float Rotate; - if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; - - if (_active) DisplaySpriteAttachments(true); - - if (_currentSprite && _active) { - bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; - - _currentSprite->Display(_posX, - _posY, - Reg ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); - - } - - if (_active) DisplaySpriteAttachments(false); - if (_active && _partEmitter) _partEmitter->Display(); - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Update() { - _currentSprite = NULL; - - if (_state == STATE_READY) { - if (_animSprite) { - delete _animSprite; - _animSprite = NULL; - } - if (_animSprite2) { - _animSprite2 = NULL; - } - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite; - } - - if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite2; - } - - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); - - // default: stand animation - if (!_currentSprite) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->GetSprite(_dir); - } else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); - } - } - } - - bool already_moved = false; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM_SET: - _currentSprite = _animSprite2; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_LEFT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - if (_dir > 0) _dir = (TDirection)(_dir - 1); - else _dir = (TDirection)(NUM_DIRECTIONS - 1); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnLeftSprite) { - _tempSprite2 = _turnLeftSprite->GetSprite(_dir); - } else { - CAdSpriteSet *Anim = GetAnimByName(_turnLeftAnimName); - if (Anim) _tempSprite2 = Anim->GetSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->Reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_RIGHT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - _dir = (TDirection)(_dir + 1); - - if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnRightSprite) { - _tempSprite2 = _turnRightSprite->GetSprite(_dir); - } else { - CAdSpriteSet *Anim = GetAnimByName(_turnRightAnimName); - if (Anim) _tempSprite2 = Anim->GetSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->Reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_SEARCHING_PATH: - // keep asking scene for the path - if (((CAdGame *)Game)->_scene->GetPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) - _state = STATE_WAITING_PATH; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_WAITING_PATH: - // wait until the scene finished the path - if (_path->_ready) FollowPath(); - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_FOLLOWING_PATH: - GetNextStep(); - already_moved = true; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->Update(_dir); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->Finish(); - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); - if (_tempSprite2) { - _tempSprite2->Reset(); - _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); - } - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); - } - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite && !_animSprite2) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->GetSprite(_dir); - } else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); - } - } - } - break; - default: - error("AdActor::Update - Unhandled enum"); - } - - - if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - AfterMove(); - } - } - - //Game->QuickMessageForm("%s", _currentSprite->_filename); - - UpdateBlockRegion(); - _ready = (_state == STATE_READY); - - UpdatePartEmitter(); - UpdateSpriteAttachments(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::FollowPath() { - // skip current position - _path->GetFirst(); - while (_path->GetCurrent() != NULL) { - if (_path->GetCurrent()->x != _posX || _path->GetCurrent()->y != _posY) break; - _path->GetNext(); - } - - // are there points to follow? - if (_path->GetCurrent() != NULL) { - _state = STATE_FOLLOWING_PATH;; - InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); - } else { - if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); - else _state = STATE_READY; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::GetNextStep() { - if (_walkSprite) { - _currentSprite = _walkSprite->GetSprite(_dir); - } else { - CAdSpriteSet *Anim = GetAnimByName(_walkAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); - } - - if (!_currentSprite) return; - - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); - if (!_currentSprite->_changed) return; - - - int MaxStepX, MaxStepY; - MaxStepX = abs(_currentSprite->_moveX); - MaxStepY = abs(_currentSprite->_moveY); - - MaxStepX = MAX(MaxStepX, MaxStepY); - MaxStepX = MAX(MaxStepX, 1); - - while (_pFCount > 0 && MaxStepX >= 0) { - _pFX += _pFStepX; - _pFY += _pFStepY; - - _pFCount--; - MaxStepX--; - } - - if (((CAdGame *)Game)->_scene->IsBlockedAt(_pFX, _pFY, true, this)) { - if (_pFCount == 0) { - _state = _nextState; - _nextState = STATE_READY; - return; - } - GoTo(_targetPoint->x, _targetPoint->y); - return; - } - - - _posX = (int)_pFX; - _posY = (int)_pFY; - - AfterMove(); - - - if (_pFCount == 0) { - if (_path->GetNext() == NULL) { - _posX = _targetPoint->x; - _posY = _targetPoint->y; - - _path->Reset(); - if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); - else { - _state = _nextState; - _nextState = STATE_READY; - } - } else InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { - _pFCount = MAX((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); - - _pFStepX = (double)(EndPt.x - StartPt.x) / _pFCount; - _pFStepY = (double)(EndPt.y - StartPt.y) / _pFCount; - - _pFX = StartPt.x; - _pFY = StartPt.y; - - int angle = (int)(atan2((double)(EndPt.y - StartPt.y), (double)(EndPt.x - StartPt.x)) * (180 / 3.14)); - - _nextState = STATE_FOLLOWING_PATH; - - TurnTo(AngleToDirection(angle)); -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // GoTo / GoToAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GoTo") == 0 || strcmp(Name, "GoToAsync") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - GoTo(X, Y); - if (strcmp(Name, "GoToAsync") != 0) Script->WaitForExclusive(this); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoToObject / GoToObjectAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoToObject") == 0 || strcmp(Name, "GoToObjectAsync") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - if (!Val->IsNative()) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); - Stack->PushNULL(); - return S_OK; - } - CAdObject *Obj = (CAdObject *)Val->GetNative(); - if (!Obj || Obj->_type != OBJECT_ENTITY) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); - Stack->PushNULL(); - return S_OK; - } - CAdEntity *Ent = (CAdEntity *)Obj; - if (Ent->_walkToX == 0 && Ent->_walkToY == 0) GoTo(Ent->_posX, Ent->_posY); - else GoTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(Name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnTo / TurnToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnTo") == 0 || strcmp(Name, "TurnToAsync") == 0) { - Stack->CorrectParams(1); - int dir; - CScValue *val = Stack->Pop(); - - // turn to object? - if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { - CBObject *obj = (CBObject *)val->GetNative(); - int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); - dir = (int)AngleToDirection(angle); - } - // otherwise turn to direction - else dir = val->GetInt(); - - if (dir >= 0 && dir < NUM_DIRECTIONS) { - TurnTo((TDirection)dir); - if (strcmp(Name, "TurnToAsync") != 0) Script->WaitForExclusive(this); - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsWalking") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(_state == STATE_FOLLOWING_PATH); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MergeAnims - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MergeAnims") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(MergeAnims(Stack->Pop()->GetString()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); - - bool Found = false; - for (int i = 0; i < _anims.GetSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { - // invalidate sprites in use - if (_anims[i]->ContainsSprite(_tempSprite2)) _tempSprite2 = NULL; - if (_anims[i]->ContainsSprite(_currentSprite)) _currentSprite = NULL; - if (_anims[i]->ContainsSprite(_animSprite2)) _animSprite2 = NULL; - - delete _anims[i]; - _anims[i] = NULL; - _anims.RemoveAt(i); - i--; - Found = true; - } - } - Stack->PushBool(Found); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); - Stack->PushBool(GetAnimByName(AnimName) != NULL); - return S_OK; - } - - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Direction") == 0) { - _scValue->SetInt(_dir); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Type") == 0) { - _scValue->SetString("actor"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkAnimName") == 0) { - _scValue->SetString(_talkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkAnimName") == 0) { - _scValue->SetString(_walkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IdleAnimName") == 0) { - _scValue->SetString(_idleAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnLeftAnimName") == 0) { - _scValue->SetString(_turnLeftAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnRightAnimName") == 0) { - _scValue->SetString(_turnRightAnimName); - return _scValue; - } - - else return CAdTalkHolder::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Direction") == 0) { - int dir = Value->GetInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_talkAnimName, "talk"); - else CBUtils::SetString(&_talkAnimName, Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_walkAnimName, "walk"); - else CBUtils::SetString(&_walkAnimName, Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IdleAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_idleAnimName, "idle"); - else CBUtils::SetString(&_idleAnimName, Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnLeftAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_turnLeftAnimName, "turnleft"); - else CBUtils::SetString(&_turnLeftAnimName, Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnRightAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_turnRightAnimName, "turnright"); - else CBUtils::SetString(&_turnRightAnimName, Value->GetString()); - return S_OK; - } - - else return CAdTalkHolder::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdActor::ScToString() { - return "[actor object]"; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStance(const char *Stance) { - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(Game, this); - if (_animSprite) { - HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); - if (FAILED(res)) { - Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - // old way - if (_talkSprites.GetSize() > 0 || _talkSpritesEx.GetSize() > 0) - return GetTalkStanceOld(Stance); - - // new way - CBSprite *Ret = NULL; - - // do we have an animation with this name? - CAdSpriteSet *Anim = GetAnimByName(Stance); - if (Anim) Ret = Anim->GetSprite(_dir); - - // not - get a random talk - if (!Ret) { - CBArray TalkAnims; - for (int i = 0; i < _anims.GetSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, _talkAnimName) == 0) - TalkAnims.Add(_anims[i]); - } - - if (TalkAnims.GetSize() > 0) { - int rnd = rand() % TalkAnims.GetSize(); - Ret = TalkAnims[rnd]->GetSprite(_dir); - } else { - if (_standSprite) Ret = _standSprite->GetSprite(_dir); - else { - Anim = GetAnimByName(_idleAnimName); - if (Anim) Ret = Anim->GetSprite(_dir); - } - } - } - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { - CBSprite *ret = NULL; - - if (Stance != NULL) { - // search special stances - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { - ret = _talkSpritesEx[i]->GetSprite(_dir); - break; - } - } - if (ret == NULL) { - // search generic stances - for (int i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { - ret = _talkSprites[i]->GetSprite(_dir); - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.GetSize() < 1) ret = _standSprite->GetSprite(_dir); - else { - // TODO: remember last - int rnd = rand() % _talkSprites.GetSize(); - ret = _talkSprites[rnd]->GetSprite(_dir); - } - } - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Persist(CBPersistMgr *PersistMgr) { - CAdTalkHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER_INT(_dir)); - PersistMgr->Transfer(TMEMBER(_path)); - PersistMgr->Transfer(TMEMBER(_pFCount)); - PersistMgr->Transfer(TMEMBER(_pFStepX)); - PersistMgr->Transfer(TMEMBER(_pFStepY)); - PersistMgr->Transfer(TMEMBER(_pFX)); - PersistMgr->Transfer(TMEMBER(_pFY)); - PersistMgr->Transfer(TMEMBER(_standSprite)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(_targetDir)); - PersistMgr->Transfer(TMEMBER_INT(_afterWalkDir)); - PersistMgr->Transfer(TMEMBER(_targetPoint)); - PersistMgr->Transfer(TMEMBER(_turnLeftSprite)); - PersistMgr->Transfer(TMEMBER(_turnRightSprite)); - PersistMgr->Transfer(TMEMBER(_walkSprite)); - - PersistMgr->Transfer(TMEMBER(_animSprite2)); - PersistMgr->Transfer(TMEMBER(_talkAnimName)); - PersistMgr->Transfer(TMEMBER(_idleAnimName)); - PersistMgr->Transfer(TMEMBER(_walkAnimName)); - PersistMgr->Transfer(TMEMBER(_turnLeftAnimName)); - PersistMgr->Transfer(TMEMBER(_turnRightAnimName)); - - _anims.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TDirection CAdActor::AngleToDirection(int Angle) { - TDirection ret = DI_DOWN;; - - if (Angle > -112 && Angle <= -67) ret = DI_UP; - else if (Angle > -67 && Angle <= -22) ret = DI_UPRIGHT; - else if (Angle > -22 && Angle <= 22) ret = DI_RIGHT; - else if (Angle > 22 && Angle <= 67) ret = DI_DOWNRIGHT; - else if (Angle > 67 && Angle <= 112) ret = DI_DOWN; - else if (Angle > 112 && Angle <= 157) ret = DI_DOWNLEFT; - else if ((Angle > 157 && Angle <= 180) || (Angle >= -180 && Angle <= -157)) ret = DI_LEFT; - else if (Angle > -157 && Angle <= -112) ret = DI_UPLEFT; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdActor::GetHeight() { - // if no current sprite is set, set some - if (_currentSprite == NULL) { - if (_standSprite) _currentSprite = _standSprite->GetSprite(_dir); - else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); - } - } - // and get height - return CAdTalkHolder::GetHeight(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::GetAnimByName(const char *AnimName) { - if (!AnimName) return NULL; - - for (int i = 0; i < _anims.GetSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) return _anims[i]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - - byte *FileBuffer = Game->_fileManager->ReadWholeFile(AnimsFilename); - if (FileBuffer == NULL) { - Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); - return E_FAIL; - } - - byte *Buffer = FileBuffer; - byte *params; - int cmd; - CBParser parser(Game); - - HRESULT Ret = S_OK; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - Ret = E_FAIL; - } else _anims.Add(Anim); - } - break; - } - } - delete [] FileBuffer; - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::PlayAnim(const char *Filename) { - // if we have an anim with this name, use it - CAdSpriteSet *Anim = GetAnimByName(Filename); - if (Anim) { - _animSprite2 = Anim->GetSprite(_dir); - if (_animSprite2) { - _animSprite2->Reset(); - _state = STATE_PLAYING_ANIM_SET; - return S_OK; - } - } - // otherwise call the standard handler - return CAdTalkHolder::PlayAnim(Filename); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdActor.h b/engines/wintermute/AdActor.h deleted file mode 100644 index 2f3a678f93..0000000000 --- a/engines/wintermute/AdActor.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADACTOR_H -#define WINTERMUTE_ADACTOR_H - - -#include "dctypes.h" // Added by ClassView -#include "AdTypes.h" // Added by ClassView -#include "AdTalkHolder.h" -#include "BPoint.h" // Added by ClassView -#include "persistent.h" -#include "common/str.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -namespace WinterMute { -class CAdSpriteSet; -class CAdPath; -class CAdActor : public CAdTalkHolder { -public: - TDirection AngleToDirection(int Angle); - DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) - virtual int GetHeight(); - CBSprite *GetTalkStance(const char *Stance); - virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); - CBPoint *_targetPoint; - virtual HRESULT Update(); - virtual HRESULT Display(); - TDirection _targetDir; - TDirection _afterWalkDir; - virtual void TurnTo(TDirection dir); - CAdPath *_path; - CAdSpriteSet *_walkSprite; - CAdSpriteSet *_standSprite; - CAdSpriteSet *_turnLeftSprite; - CAdSpriteSet *_turnRightSprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - TDirection _dir; - CAdActor(CBGame *inGame/*=NULL*/); - virtual ~CAdActor(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - - // new anim system - char *_talkAnimName; - char *_idleAnimName; - char *_walkAnimName; - char *_turnLeftAnimName; - char *_turnRightAnimName; - CBArray _anims; - virtual HRESULT PlayAnim(const char *Filename); - CAdSpriteSet *GetAnimByName(const char *AnimName); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -private: - HRESULT SetDefaultAnimNames(); - CBSprite *GetTalkStanceOld(const char *Stance); - HRESULT MergeAnims(const char *AnimsFilename); - CBSprite *_animSprite2; - - void InitLine(CBPoint StartPt, CBPoint EndPt); - void GetNextStep(); - void FollowPath(); - double _pFStepX; - double _pFStepY; - double _pFX; - double _pFY; - int _pFCount; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/AdActorDir.cpp b/engines/wintermute/AdActorDir.cpp deleted file mode 100644 index 6966c5fc1b..0000000000 --- a/engines/wintermute/AdActorDir.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "AdActorDir.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdActorDir, false) - - -////////////////////////////////////////////////////////////////////////// -CAdActorDir::CAdActorDir(CBGame *inGame): CBBase(inGame) { -} - - -////////////////////////////////////////////////////////////////////////// -CAdActorDir::~CAdActorDir(void) { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActorDir::Persist(CBPersistMgr *PersistMgr) { - //PersistMgr->Transfer(TMEMBER(x)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdActorDir.h b/engines/wintermute/AdActorDir.h deleted file mode 100644 index 5df19f2aeb..0000000000 --- a/engines/wintermute/AdActorDir.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADACTORDIR_H -#define WINTERMUTE_ADACTORDIR_H - -#include "persistent.h" -#include "BBase.h" - -namespace WinterMute { - -class CAdActorDir : public CBBase { -public: - DECLARE_PERSISTENT(CAdActorDir, CBBase) - CAdActorDir(CBGame *inGame); - virtual ~CAdActorDir(void); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADACTORDIR_H diff --git a/engines/wintermute/AdEntity.cpp b/engines/wintermute/AdEntity.cpp deleted file mode 100644 index b00b0bd923..0000000000 --- a/engines/wintermute/AdEntity.cpp +++ /dev/null @@ -1,977 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/AdEntity.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/AdGame.h" -#include "engines/wintermute/AdScene.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/AdWaypointGroup.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/AdSentence.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdEntity, false) - -////////////////////////////////////////////////////////////////////////// -CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { - _type = OBJECT_ENTITY; - _subtype = ENTITY_NORMAL; - _region = NULL; - _item = NULL; - - _walkToX = _walkToY = 0; - _walkToDir = DI_NONE; -} - - -////////////////////////////////////////////////////////////////////////// -CAdEntity::~CAdEntity() { - Game->UnregisterObject(_region); - - delete[] _item; - _item = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(CURSOR) -TOKEN_DEF(REGION) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_START_TIME) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(SOUND) -TOKEN_DEF(SUBTYPE) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ITEM) -TOKEN_DEF(WALK_TO_X) -TOKEN_DEF(WALK_TO_Y) -TOKEN_DEF(WALK_TO_DIR) -TOKEN_DEF(SAVE_STATE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(REGION) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_START_TIME) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(SUBTYPE) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(WALK_TO_X) - TOKEN_TABLE(WALK_TO_Y) - TOKEN_TABLE(WALK_TO_DIR) - TOKEN_TABLE(SAVE_STATE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { - Game->LOG(0, "'ENTITY' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - CAdGame *AdGame = (CAdGame *)Game; - CBSprite *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SPRITE: { - delete _sprite; - _sprite = NULL; - spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - break; - - case TOKEN_TALK: { - spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); - } - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_ITEM: - SetItem((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_SCALE: { - int s; - parser.ScanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.ScanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_REGION: { - if (_region) Game->UnregisterObject(_region); - _region = NULL; - CBRegion *rgn = new CBRegion(Game); - if (!rgn || FAILED(rgn->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; - else { - _region = rgn; - Game->RegisterObject(_region); - } - } - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(Game); - CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->Mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->Mimic(_wptGroup); - } - } - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_SUBTYPE: { - if (scumm_stricmp((char *)params, "sound") == 0) { - delete _sprite; - _sprite = NULL; - if (Game->_editorMode) { - spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - if (Game->_editorMode) _editorOnly = true; - _zoomable = false; - _rotatable = false; - _registrable = Game->_editorMode; - _shadowable = false; - _subtype = ENTITY_SOUND; - } - } - break; - - case TOKEN_SOUND: - PlaySFX((char *)params, false, false); - break; - - case TOKEN_SOUND_START_TIME: - parser.ScanStr((char *)params, "%d", &_sFXStart); - break; - - case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_SAVE_STATE: - parser.ScanStr((char *)params, "%b", &_saveState); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - case TOKEN_WALK_TO_X: - parser.ScanStr((char *)params, "%d", &_walkToX); - break; - - case TOKEN_WALK_TO_Y: - parser.ScanStr((char *)params, "%d", &_walkToY); - break; - - case TOKEN_WALK_TO_DIR: { - int i; - parser.ScanStr((char *)params, "%d", &i); - if (i < 0) i = 0; - if (i >= NUM_DIRECTIONS) i = DI_NONE; - _walkToDir = (TDirection)i; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ENTITY definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ENTITY definition"); - if (spr) delete spr; - return E_FAIL; - } - - if (_region && _sprite) { - Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); - } - - UpdatePosition(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = DRGBA(ar, ag, ab, alpha); - _state = STATE_READY; - - if (_item && ((CAdGame *)Game)->IsItemTaken(_item)) _active = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Display() { - if (_active) { - UpdateSounds(); - - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY) : 0xFFFFFFFF; - - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); - - float Rotate; - if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; - - - bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; - - if (_region && (Reg || _editorAlwaysRegister)) { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); - } - - DisplaySpriteAttachments(true); - if (_currentSprite) { - _currentSprite->Display(_posX, - _posY, - (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); - } - DisplaySpriteAttachments(false); - - if (_partEmitter) _partEmitter->Display(_region); - - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) - _currentSprite = _sprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->Update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->Finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); - if (_tempSprite2) { - _tempSprite2->Reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)Game)->AddSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); - } - } - break; - default: - error("AdEntity::Update - Unhandled enum"); - } - - - if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - } - } - - UpdateBlockRegion(); - _ready = (_state == STATE_READY); - - - UpdatePartEmitter(); - UpdateSpriteAttachments(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { - Stack->CorrectParams(0); - - if (FAILED(StopSFX(false))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayTheora") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopTheora") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTheoraPlaying") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseTheora") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeTheora") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPaused - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTheoraPaused") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // CreateRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateRegion") == 0) { - Stack->CorrectParams(0); - if (!_region) { - _region = new CBRegion(Game); - Game->RegisterObject(_region); - } - if (_region) Stack->PushNative(_region, true); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteRegion") == 0) { - Stack->CorrectParams(0); - if (_region) { - Game->UnregisterObject(_region); - _region = NULL; - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("entity"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Item") == 0) { - if (_item) _scValue->SetString(_item); - else _scValue->SetNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtype (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtype") == 0) { - if (_subtype == ENTITY_SOUND) - _scValue->SetString("sound"); - else - _scValue->SetString("normal"); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToX") == 0) { - _scValue->SetInt(_walkToX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToY") == 0) { - _scValue->SetInt(_walkToY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToDirection") == 0) { - _scValue->SetInt((int)_walkToDir); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Region (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Region") == 0) { - if (_region) _scValue->SetNative(_region, true); - else _scValue->SetNULL(); - return _scValue; - } - - else return CAdTalkHolder::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Item") == 0) { - SetItem(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToX") == 0) { - _walkToX = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToY") == 0) { - _walkToY = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToDirection") == 0) { - int Dir = Value->GetInt(); - if (Dir >= 0 && Dir < NUM_DIRECTIONS) _walkToDir = (TDirection)Dir; - return S_OK; - } - - - else return CAdTalkHolder::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdEntity::ScToString() { - return "[entity object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ENTITY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - if (_subtype == ENTITY_SOUND) - Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_ignoreItems) - Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); - if (_rotatable) - Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); - - if (!_autoSoundPanning) - Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); - - if (!_saveState) - Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); - - if (_item && _item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); - - Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); - Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); - if (_walkToDir != DI_NONE) - Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); - - int i; - - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); - - if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); - Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); - Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); - } - - - if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - - if (D3DCOLGetA(_alphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); - - if (_scale >= 0) - Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); - - if (_relativeScale != 0) - Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - CAdTalkHolder::SaveAsText(Buffer, Indent + 2); - - if (_region) _region->SaveAsText(Buffer, Indent + 2); - - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - - CAdObject::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdEntity::GetHeight() { - if (_region && !_sprite) { - return _region->_rect.bottom - _region->_rect.top; - } else { - if (_currentSprite == NULL) _currentSprite = _sprite; - return CAdObject::GetHeight(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::UpdatePosition() { - if (_region && !_sprite) { - _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; - _posY = _region->_rect.bottom; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { - CAdTalkHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_item)); - PersistMgr->Transfer(TMEMBER(_region)); - //PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER_INT(_subtype)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_walkToX)); - PersistMgr->Transfer(TMEMBER(_walkToY)); - PersistMgr->Transfer(TMEMBER_INT(_walkToDir)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::SetItem(const char *ItemName) { - CBUtils::SetString(&_item, ItemName); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::SetSprite(const char *Filename) { - bool SetCurrent = false; - if (_currentSprite == _sprite) { - _currentSprite = NULL; - SetCurrent = true; - } - - delete _sprite; - _sprite = NULL; - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - delete _sprite; - _sprite = NULL; - return E_FAIL; - } else { - _sprite = spr; - _currentSprite = _sprite; - return S_OK; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdEntity.h b/engines/wintermute/AdEntity.h deleted file mode 100644 index 30b9bab3a7..0000000000 --- a/engines/wintermute/AdEntity.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADENTITY_H -#define WINTERMUTE_ADENTITY_H - -#include "AdTalkHolder.h" - -namespace WinterMute { - -class CAdEntity : public CAdTalkHolder { -public: - HRESULT SetSprite(const char *Filename); - int _walkToX; - int _walkToY; - TDirection _walkToDir; - void SetItem(const char *ItemName); - char *_item; - DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) - void UpdatePosition(); - virtual int GetHeight(); - CBRegion *_region; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Update(); - virtual HRESULT Display(); - CAdEntity(CBGame *inGame); - virtual ~CAdEntity(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - TEntityType _subtype; - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdGame.cpp b/engines/wintermute/AdGame.cpp deleted file mode 100644 index e2d790e87e..0000000000 --- a/engines/wintermute/AdGame.cpp +++ /dev/null @@ -1,2060 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/AdGame.h" -#include "engines/wintermute/AdResponseBox.h" -#include "engines/wintermute/AdInventoryBox.h" -#include "engines/wintermute/AdSceneState.h" -#include "engines/wintermute/PartEmitter.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BTransitionMgr.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/UIEntity.h" -#include "engines/wintermute/AdScene.h" -#include "engines/wintermute/AdEntity.h" -#include "engines/wintermute/AdActor.h" -#include "engines/wintermute/AdInventory.h" -#include "engines/wintermute/AdResponseContext.h" -#include "engines/wintermute/AdItem.h" -#include "engines/wintermute/BViewport.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/AdSentence.h" -#include "engines/wintermute/AdResponse.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/utils.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdGame, true) - -////////////////////////////////////////////////////////////////////////// -CAdGame::CAdGame(): CBGame() { - _responseBox = NULL; - _inventoryBox = NULL; - - _scene = new CAdScene(Game); - _scene->SetName(""); - RegisterObject(_scene); - - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _scheduledFadeIn = false; - - - _stateEx = GAME_NORMAL; - - _selectedItem = NULL; - - - _texItemLifeTime = 10000; - _texWalkLifeTime = 10000; - _texStandLifeTime = 10000; - _texTalkLifeTime = 10000; - - _talkSkipButton = TALK_SKIP_LEFT; - - _sceneViewport = NULL; - - _initialScene = true; - _debugStartupScene = NULL; - _startupScene = NULL; - - _invObject = new CAdObject(this); - _inventoryOwner = _invObject; - - _tempDisableSaveState = false; - _itemsFile = NULL; - - _smartItemCursor = false; - - AddSpeechDir("speech"); -} - - -////////////////////////////////////////////////////////////////////////// -CAdGame::~CAdGame() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::Cleanup() { - int i; - - for (i = 0; i < _objects.GetSize(); i++) { - UnregisterObject(_objects[i]); - _objects[i] = NULL; - } - _objects.RemoveAll(); - - - for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.RemoveAll(); - - for (i = 0; i < _speechDirs.GetSize(); i++) { - delete [] _speechDirs[i]; - } - _speechDirs.RemoveAll(); - - - UnregisterObject(_scene); - _scene = NULL; - - // remove items - for (i = 0; i < _items.GetSize(); i++) Game->UnregisterObject(_items[i]); - _items.RemoveAll(); - - - // clear remaining inventories - delete _invObject; - _invObject = NULL; - - for (i = 0; i < _inventories.GetSize(); i++) { - delete _inventories[i]; - } - _inventories.RemoveAll(); - - - if (_responseBox) { - Game->UnregisterObject(_responseBox); - _responseBox = NULL; - } - - if (_inventoryBox) { - Game->UnregisterObject(_inventoryBox); - _inventoryBox = NULL; - } - - delete[] _prevSceneName; - delete[] _prevSceneFilename; - delete[] _scheduledScene; - delete[] _debugStartupScene; - delete[] _itemsFile; - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _debugStartupScene = NULL; - _startupScene = NULL; - _itemsFile = NULL; - - delete _sceneViewport; - _sceneViewport = NULL; - - for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; - _sceneStates.RemoveAll(); - - for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); - - for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; - _responsesGame.RemoveAll(); - - return CBGame::Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::InitLoop() { - if (_scheduledScene && _transMgr->IsReady()) { - ChangeScene(_scheduledScene, _scheduledFadeIn); - delete[] _scheduledScene; - _scheduledScene = NULL; - - Game->_activeObject = NULL; - } - - - HRESULT res; - res = CBGame::InitLoop(); - if (FAILED(res)) return res; - - if (_scene) res = _scene->InitLoop(); - - _sentences.RemoveAll(); - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddObject(CAdObject *Object) { - _objects.Add(Object); - return RegisterObject(Object); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RemoveObject(CAdObject *Object) { - // in case the user called Scene.CreateXXX() and Game.DeleteXXX() - if (_scene) { - HRESULT Res = _scene->RemoveObject(Object); - if (SUCCEEDED(Res)) return Res; - } - - for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] == Object) { - _objects.RemoveAt(i); - break; - } - } - return UnregisterObject(Object); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { - if (_scene == NULL) { - _scene = new CAdScene(Game); - RegisterObject(_scene); - } else { - _scene->ApplyEvent("SceneShutdown", true); - - SetPrevSceneName(_scene->_name); - SetPrevSceneFilename(_scene->_filename); - - if (!_tempDisableSaveState) _scene->SaveState(); - _tempDisableSaveState = false; - } - - if (_scene) { - // reset objects - for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->Reset(); - - // reset scene properties - _scene->_sFXVolume = 100; - if (_scene->_scProp) _scene->_scProp->Cleanup(); - - HRESULT ret; - if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { - _initialScene = false; - ret = _scene->LoadFile(_debugStartupScene); - } else ret = _scene->LoadFile(Filename); - - if (SUCCEEDED(ret)) { - // invalidate references to the original scene - for (int i = 0; i < _objects.GetSize(); i++) { - _objects[i]->InvalidateCurrRegions(); - _objects[i]->_stickRegion = NULL; - } - - _scene->LoadState(); - } - if (FadeIn) Game->_transMgr->Start(TRANSITION_FADE_IN); - return ret; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::AddSentence(CAdSentence *Sentence) { - _sentences.Add(Sentence); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplaySentences(bool Frozen) { - for (int i = 0; i < _sentences.GetSize(); i++) { - if (Frozen && _sentences[i]->_freezable) continue; - else _sentences[i]->Display(); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::FinishSentences() { - for (int i = 0; i < _sentences.GetSize(); i++) { - if (_sentences[i]->CanSkip()) { - _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) _sentences[i]->_sound->Stop(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // ChangeScene - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "ChangeScene") == 0) { - Stack->CorrectParams(3); - const char *Filename = Stack->Pop()->GetString(); - CScValue *valFadeOut = Stack->Pop(); - CScValue *valFadeIn = Stack->Pop(); - - bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); - bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); - - ScheduleChangeScene(Filename, TransIn); - if (TransOut) _transMgr->Start(TRANSITION_FADE_OUT, true); - Stack->PushNULL(); - - - //HRESULT ret = ChangeScene(Stack->Pop()->GetString()); - //if(FAILED(ret)) Stack->PushBool(false); - //else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadActor") == 0) { - Stack->CorrectParams(1); - CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { - AddObject(act); - Stack->PushNative(act, true); - } else { - delete act; - act = NULL; - Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadEntity") == 0) { - Stack->CorrectParams(1); - CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { - AddObject(ent); - Stack->PushNative(ent, true); - } else { - delete ent; - ent = NULL; - Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "DeleteEntity") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - CAdObject *obj = (CAdObject *)val->GetNative(); - RemoveObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdEntity *Ent = new CAdEntity(Game); - AddObject(Ent); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); - Stack->PushNative(Ent, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdItem *Item = new CAdItem(Game); - AddItem(Item); - if (!Val->IsNULL()) Item->SetName(Val->GetString()); - Stack->PushNative(Item, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdItem *Item = NULL; - if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); - else Item = GetItemByName(Val->GetString()); - - if (Item) { - DeleteItem(Item); - } - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QueryItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "QueryItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdItem *Item = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); - if (Index >= 0 && Index < _items.GetSize()) Item = _items[Index]; - } else { - Item = GetItemByName(Val->GetString()); - } - - if (Item) Stack->PushNative(Item, true); - else Stack->PushNULL(); - - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // AddResponse/AddResponseOnce/AddResponseOnceGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddResponse") == 0 || strcmp(Name, "AddResponseOnce") == 0 || strcmp(Name, "AddResponseOnceGame") == 0) { - Stack->CorrectParams(6); - int id = Stack->Pop()->GetInt(); - const char *text = Stack->Pop()->GetString(); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - CScValue *val3 = Stack->Pop(); - CScValue *val4 = Stack->Pop(); - - if (_responseBox) { - CAdResponse *res = new CAdResponse(Game); - if (res) { - res->_iD = id; - res->SetText(text); - _stringTable->Expand(&res->_text); - if (!val1->IsNULL()) res->SetIcon(val1->GetString()); - if (!val2->IsNULL()) res->SetIconHover(val2->GetString()); - if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); - if (!val4->IsNULL()) res->SetFont(val4->GetString()); - - if (strcmp(Name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; - else if (strcmp(Name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; - - _responseBox->_responses.Add(res); - } - } else { - Script->RuntimeError("Game.AddResponse: response box is not defined"); - } - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResetResponse") == 0) { - Stack->CorrectParams(1); - int ID = Stack->Pop()->GetInt(-1); - ResetResponse(ID); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClearResponses") == 0) { - Stack->CorrectParams(0); - _responseBox->ClearResponses(); - _responseBox->ClearButtons(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetResponse") == 0) { - Stack->CorrectParams(1); - bool AutoSelectLast = Stack->Pop()->GetBool(); - - if (_responseBox) { - _responseBox->WeedResponses(); - - if (_responseBox->_responses.GetSize() == 0) { - Stack->PushNULL(); - return S_OK; - } - - - if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { - Stack->PushInt(_responseBox->_responses[0]->_iD); - _responseBox->HandleResponse(_responseBox->_responses[0]); - _responseBox->ClearResponses(); - return S_OK; - } - - _responseBox->CreateButtons(); - _responseBox->_waitingScript = Script; - Script->WaitForExclusive(_responseBox); - _state = GAME_SEMI_FROZEN; - _stateEx = GAME_WAITING_RESPONSE; - } else { - Script->RuntimeError("Game.GetResponse: response box is not defined"); - Stack->PushNULL(); - } - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // GetNumResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNumResponses") == 0) { - Stack->CorrectParams(0); - if (_responseBox) { - _responseBox->WeedResponses(); - Stack->PushInt(_responseBox->_responses.GetSize()); - } else { - Script->RuntimeError("Game.GetNumResponses: response box is not defined"); - Stack->PushNULL(); - } - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // StartDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartDlgBranch") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - Common::String BranchName; - if (Val->IsNULL()) { - BranchName.format("line%d", Script->_currentLine); - } else BranchName = Val->GetString(); - - StartDlgBranch(BranchName.c_str(), Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EndDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EndDlgBranch") == 0) { - Stack->CorrectParams(1); - - const char *BranchName = NULL; - CScValue *Val = Stack->Pop(); - if (!Val->IsNULL()) BranchName = Val->GetString(); - EndDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); - - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCurrentDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCurrentDlgBranch") == 0) { - Stack->CorrectParams(0); - - if (_dlgPendingBranches.GetSize() > 0) { - Stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); - } else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TakeItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DropItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); - } - - ////////////////////////////////////////////////////////////////////////// - // IsItemTaken - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsItemTaken") == 0) { - Stack->CorrectParams(1); - - CScValue *val = Stack->Pop(); - if (!val->IsNULL()) { - for (int i = 0; i < _inventories.GetSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { - if (val->GetNative() == Inv->_takenItems[j]) { - Stack->PushBool(true); - return S_OK; - } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { - Stack->PushBool(true); - return S_OK; - } - } - } - } else Script->RuntimeError("Game.IsItemTaken: item name expected"); - - Stack->PushBool(false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInventoryWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInventoryWindow") == 0) { - Stack->CorrectParams(0); - if (_inventoryBox && _inventoryBox->_window) - Stack->PushNative(_inventoryBox->_window, true); - else - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponsesWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetResponsesWindow") == 0 || strcmp(Name, "GetResponseWindow") == 0) { - Stack->CorrectParams(0); - if (_responseBox && _responseBox->_window) - Stack->PushNative(_responseBox->_window, true); - else - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadResponseBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadResponseBox") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - - Game->UnregisterObject(_responseBox); - _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->LoadFile(Filename))) { - RegisterObject(_responseBox); - Stack->PushBool(true); - } else { - delete _responseBox; - _responseBox = NULL; - Stack->PushBool(false); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadInventoryBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadInventoryBox") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - - Game->UnregisterObject(_inventoryBox); - _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->LoadFile(Filename))) { - RegisterObject(_inventoryBox); - Stack->PushBool(true); - } else { - delete _inventoryBox; - _inventoryBox = NULL; - Stack->PushBool(false); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadItems") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool Merge = Stack->Pop()->GetBool(false); - - HRESULT Ret = LoadItemsFile(Filename, Merge); - Stack->PushBool(SUCCEEDED(Ret)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSpeechDir") == 0) { - Stack->CorrectParams(1); - const char *Dir = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveSpeechDir") == 0) { - Stack->CorrectParams(1); - const char *Dir = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSceneViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSceneViewport") == 0) { - Stack->CorrectParams(4); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - int Width = Stack->Pop()->GetInt(); - int Height = Stack->Pop()->GetInt(); - - if (Width <= 0) Width = _renderer->_width; - if (Height <= 0) Height = _renderer->_height; - - if (!_sceneViewport) _sceneViewport = new CBViewport(Game); - if (_sceneViewport) _sceneViewport->SetRect(X, Y, X + Width, Y + Height); - - Stack->PushBool(true); - - return S_OK; - } - - - else return CBGame::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scene") == 0) { - if (_scene) _scValue->SetNative(_scene, true); - else _scValue->SetNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelectedItem") == 0) { - //if(_selectedItem) _scValue->SetString(_selectedItem->_name); - if (_selectedItem) _scValue->SetNative(_selectedItem, true); - else _scValue->SetNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumItems") == 0) { - return _invObject->ScGetProperty(Name); - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SmartItemCursor") == 0) { - _scValue->SetBool(_smartItemCursor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryVisible") == 0) { - _scValue->SetBool(_inventoryBox && _inventoryBox->_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _scValue->SetInt(_inventoryBox->_scrollOffset); - else _scValue->SetInt(0); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ResponsesVisible (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResponsesVisible") == 0) { - _scValue->SetBool(_stateEx == GAME_WAITING_RESPONSE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevScene / PreviousScene (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PrevScene") == 0 || strcmp(Name, "PreviousScene") == 0) { - if (!_prevSceneName) _scValue->SetString(""); - else _scValue->SetString(_prevSceneName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevSceneFilename / PreviousSceneFilename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PrevSceneFilename") == 0 || strcmp(Name, "PreviousSceneFilename") == 0) { - if (!_prevSceneFilename) _scValue->SetString(""); - else _scValue->SetString(_prevSceneFilename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponse (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LastResponse") == 0) { - if (!_responseBox || !_responseBox->_lastResponseText) _scValue->SetString(""); - else _scValue->SetString(_responseBox->_lastResponseText); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponseOrig (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LastResponseOrig") == 0) { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->SetString(""); - else _scValue->SetString(_responseBox->_lastResponseTextOrig); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryObject") == 0) { - if (_inventoryOwner == _invObject) _scValue->SetNative(this, true); - else _scValue->SetNative(_inventoryOwner, true); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TotalNumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TotalNumItems") == 0) { - _scValue->SetInt(_items.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkSkipButton") == 0) { - _scValue->SetInt(_talkSkipButton); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ChangingScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ChangingScene") == 0) { - _scValue->SetBool(_scheduledScene != NULL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartupScene") == 0) { - if (!_startupScene) _scValue->SetNULL(); - else _scValue->SetString(_startupScene); - return _scValue; - } - - else return CBGame::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScSetProperty(const char *Name, CScValue *Value) { - - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SelectedItem") == 0) { - if (Value->IsNULL()) _selectedItem = NULL; - else { - if (Value->IsNative()) { - _selectedItem = NULL; - for (int i = 0; i < _items.GetSize(); i++) { - if (_items[i] == Value->GetNative()) { - _selectedItem = (CAdItem *)Value->GetNative(); - break; - } - } - } else { - // try to get by name - _selectedItem = GetItemByName(Value->GetString()); - } - } - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SmartItemCursor") == 0) { - _smartItemCursor = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryObject") == 0) { - if (_inventoryOwner && _inventoryBox) _inventoryOwner->GetInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - - if (Value->IsNULL()) _inventoryOwner = _invObject; - else { - CBObject *Obj = (CBObject *)Value->GetNative(); - if (Obj == this) _inventoryOwner = _invObject; - else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; - } - - if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->GetInventory()->_scrollOffset; - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkSkipButton") == 0) { - int Val = Value->GetInt(); - if (Val < 0) Val = 0; - if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; - _talkSkipButton = (TTalkSkipButton)Val; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartupScene") == 0) { - if (Value == NULL) { - delete[] _startupScene; - _startupScene = NULL; - } else CBUtils::SetString(&_startupScene, Value->GetString()); - - return S_OK; - } - - else return CBGame::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::PublishNatives() { - if (!_scEngine || !_scEngine->_compilerAvailable) return; - - CBGame::PublishNatives(); - - _scEngine->ExtDefineFunction("Actor"); - _scEngine->ExtDefineFunction("Entity"); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { - CScValue *this_obj; - - ////////////////////////////////////////////////////////////////////////// - // Actor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Actor") == 0) { - Stack->CorrectParams(0); - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CAdActor(Game)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Entity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Entity") == 0) { - Stack->CorrectParams(0); - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CAdEntity(Game)); - Stack->PushNULL(); - } - - - ////////////////////////////////////////////////////////////////////////// - // call parent - else return CBGame::ExternalCall(Script, Stack, ThisStack, Name); - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ShowCursor() { - if (_cursorHidden) return S_OK; - - if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { - if (_selectedItem->_cursorCombined) { - CBSprite *OrigLastCursor = _lastCursor; - CBGame::ShowCursor(); - _lastCursor = OrigLastCursor; - } - if (_activeObject && _selectedItem->_cursorHover && _activeObject->GetExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->CanHandleEvent(_selectedItem->_name)) - return DrawCursor(_selectedItem->_cursorHover); - else - return DrawCursor(_selectedItem->_cursorNormal); - } else return DrawCursor(_selectedItem->_cursorNormal); - } else return CBGame::ShowCursor(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadFile(const char *Filename) { - byte *Buffer = _fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(AD_GAME) -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(ITEMS) -TOKEN_DEF(ITEM) -TOKEN_DEF(TALK_SKIP_BUTTON) -TOKEN_DEF(SCENE_VIEWPORT) -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(STARTUP_SCENE) -TOKEN_DEF(DEBUG_STARTUP_SCENE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(AD_GAME) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(ITEMS) - TOKEN_TABLE(TALK_SKIP_BUTTON) - TOKEN_TABLE(SCENE_VIEWPORT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(STARTUP_SCENE) - TOKEN_TABLE(DEBUG_STARTUP_SCENE) - TOKEN_TABLE_END - - byte *params; - byte *params2; - int cmd = 1; - CBParser parser(Game); - - bool ItemFound = false, ItemsFound = false; - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - if (FAILED(CBGame::LoadBuffer(params, false))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AD_GAME: - while (cmd > 0 && (cmd = parser.GetCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { - switch (cmd) { - case TOKEN_RESPONSE_BOX: - delete _responseBox; - _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->LoadFile((char *)params2))) - RegisterObject(_responseBox); - else { - delete _responseBox; - _responseBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_INVENTORY_BOX: - delete _inventoryBox; - _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->LoadFile((char *)params2))) - RegisterObject(_inventoryBox); - else { - delete _inventoryBox; - _inventoryBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ITEMS: - ItemsFound = true; - CBUtils::SetString(&_itemsFile, (char *)params2); - if (FAILED(LoadItemsFile(_itemsFile))) { - delete[] _itemsFile; - _itemsFile = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; - else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; - else _talkSkipButton = TALK_SKIP_LEFT; - break; - - case TOKEN_SCENE_VIEWPORT: { - RECT rc; - parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new CBViewport(Game); - if (_sceneViewport) _sceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); - } - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params2, false); - break; - - case TOKEN_STARTUP_SCENE: - CBUtils::SetString(&_startupScene, (char *)params2); - break; - - case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::SetString(&_debugStartupScene, (char *)params2); - break; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in GAME definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading GAME definition"); - return E_FAIL; - } - - if (ItemFound && !ItemsFound) { - Game->LOG(0, "**Warning** Please put the items definition to a separate file."); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - CBGame::Persist(PersistMgr); - - _dlgPendingBranches.Persist(PersistMgr); - - _inventories.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_inventoryBox)); - - _objects.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_prevSceneName)); - PersistMgr->Transfer(TMEMBER(_prevSceneFilename)); - - PersistMgr->Transfer(TMEMBER(_responseBox)); - _responsesBranch.Persist(PersistMgr); - _responsesGame.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scene)); - _sceneStates.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scheduledFadeIn)); - PersistMgr->Transfer(TMEMBER(_scheduledScene)); - PersistMgr->Transfer(TMEMBER(_selectedItem)); - PersistMgr->Transfer(TMEMBER_INT(_talkSkipButton)); - - _sentences.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_sceneViewport)); - PersistMgr->Transfer(TMEMBER_INT(_stateEx)); - PersistMgr->Transfer(TMEMBER(_initialScene)); - PersistMgr->Transfer(TMEMBER(_debugStartupScene)); - - PersistMgr->Transfer(TMEMBER(_invObject)); - PersistMgr->Transfer(TMEMBER(_inventoryOwner)); - PersistMgr->Transfer(TMEMBER(_tempDisableSaveState)); - _items.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_itemsFile)); - - _speechDirs.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_smartItemCursor)); - - if (!PersistMgr->_saving) _initialScene = false; - - PersistMgr->Transfer(TMEMBER(_startupScene)); - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadGame(const char *Filename) { - HRESULT ret = CBGame::LoadGame(Filename); - if (SUCCEEDED(ret)) CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CAdRegion", NULL); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::InitAfterLoad() { - CBGame::InitAfterLoad(); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScene, "CAdScene", NULL); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdGame::AfterLoadScene(void *Scene, void *Data) { - ((CAdScene *)Scene)->AfterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneName(const char *Name) { - delete[] _prevSceneName; - _prevSceneName = NULL; - if (Name) { - _prevSceneName = new char[strlen(Name) + 1]; - if (_prevSceneName) strcpy(_prevSceneName, Name); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneFilename(const char *Name) { - delete[] _prevSceneFilename; - _prevSceneFilename = NULL; - if (Name) { - _prevSceneFilename = new char[strlen(Name) + 1]; - if (_prevSceneFilename) strcpy(_prevSceneFilename, Name); - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScheduleChangeScene(const char *Filename, bool FadeIn) { - delete[] _scheduledScene; - _scheduledScene = NULL; - - if (_scene && !_scene->_initialized) return ChangeScene(Filename, FadeIn); - else { - _scheduledScene = new char [strlen(Filename) + 1]; - strcpy(_scheduledScene, Filename); - - _scheduledFadeIn = FadeIn; - - return S_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { - CBGame::GetVersion(VerMajor, VerMinor, NULL, NULL); - - if (ExtMajor) *ExtMajor = 0; - if (ExtMinor) *ExtMinor = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadItemsFile(const char *Filename, bool Merge) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - //_filename = new char [strlen(Filename)+1]; - //strcpy(_filename, Filename); - - if (FAILED(ret = LoadItemsBuffer(Buffer, Merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (!Merge) { - while (_items.GetSize() > 0) DeleteItem(_items[0]); - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ITEM: { - CAdItem *item = new CAdItem(Game); - if (item && !FAILED(item->LoadBuffer(params, false))) { - // delete item with the same name, if exists - if (Merge) { - CAdItem *PrevItem = GetItemByName(item->_name); - if (PrevItem) DeleteItem(PrevItem); - } - AddItem(item); - } else { - delete item; - item = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ITEMS definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ITEMS definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { - char *FilenameCor = new char[strlen(Filename) + 1]; - strcpy(FilenameCor, Filename); - for (int i = 0; i < strlen(FilenameCor); i++) { - if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; - } - - for (int i = 0; i < _sceneStates.GetSize(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, FilenameCor) == 0) { - delete [] FilenameCor; - return _sceneStates[i]; - } - } - - if (Saving) { - CAdSceneState *ret = new CAdSceneState(Game); - ret->SetFilename(FilenameCor); - - _sceneStates.Add(ret); - - delete [] FilenameCor; - return ret; - } else { - delete [] FilenameCor; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE_END - - int cmd = PARSERR_GENERIC; - CBParser parser(Game); - - cmd = parser.GetCommand(Buffer, commands, params); - switch (cmd) { - case TOKEN_ENTITY_CONTAINER: { - CUIEntity *ent = new CUIEntity(Game); - if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { - delete ent; - ent = NULL; - cmd = PARSERR_GENERIC; - } else { - ent->_parent = Win; - Win->_widgets.Add(ent); - } - } - break; - } - - if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { - return E_FAIL; - } - - return S_OK; - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { - if (strcmp(Name, "CreateEntityContainer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIEntity *Ent = new CUIEntity(Game); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); - Stack->PushNative(Ent, true); - - Ent->_parent = Win; - Win->_widgets.Add(Ent); - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { - char *Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; - if (Name) { - sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); - _dlgPendingBranches.Add(Name); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { - char *Name = NULL; - bool DeleteName = false; - if (BranchName == NULL && _dlgPendingBranches.GetSize() > 0) { - Name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; - } else { - if (BranchName != NULL) { - Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; - if (Name) { - sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); - DeleteName = true; - } - } - } - - if (Name == NULL) return S_OK; - - - int StartIndex = -1; - int i; - for (i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { - if (scumm_stricmp(Name, _dlgPendingBranches[i]) == 0) { - StartIndex = i; - break; - } - } - if (StartIndex >= 0) { - for (i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { - //ClearBranchResponses(_dlgPendingBranches[i]); - delete [] _dlgPendingBranches[i]; - _dlgPendingBranches[i] = NULL; - } - _dlgPendingBranches.RemoveAt(StartIndex, _dlgPendingBranches.GetSize() - StartIndex); - } - - // dialogue is over, forget selected responses - if (_dlgPendingBranches.GetSize() == 0) { - for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); - } - - if (DeleteName) delete [] Name; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ClearBranchResponses(char *Name) { - for (int i = 0; i < _responsesBranch.GetSize(); i++) { - if (scumm_stricmp(Name, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.RemoveAt(i); - i--; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddBranchResponse(int ID) { - if (BranchResponseUsed(ID)) return S_OK; - CAdResponseContext *r = new CAdResponseContext(Game); - r->_iD = ID; - r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); - _responsesBranch.Add(r); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::BranchResponseUsed(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < _responsesBranch.GetSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddGameResponse(int ID) { - if (GameResponseUsed(ID)) return S_OK; - CAdResponseContext *r = new CAdResponseContext(Game); - r->_iD = ID; - r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); - _responsesGame.Add(r); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::GameResponseUsed(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < _responsesGame.GetSize(); i++) { - CAdResponseContext *RespContext = _responsesGame[i]; - if (RespContext->_iD == ID) { - if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ResetResponse(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; - - int i; - - for (i = 0; i < _responsesGame.GetSize(); i++) { - if (_responsesGame[i]->_iD == ID) { - if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { - delete _responsesGame[i]; - _responsesGame.RemoveAt(i); - break; - } - } - } - - for (i = 0; i < _responsesBranch.GetSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.RemoveAt(i); - break; - } - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { - // init - if (Update) InitLoop(); - - // fill black - _renderer->Fill(0, 0, 0); - if (!_editorMode) _renderer->SetScreenViewport(); - - // process scripts - if (Update) _scEngine->Tick(); - - POINT p; - GetMousePos(&p); - - _scene->Update(); - _scene->Display(); - - - // display in-game windows - DisplayWindows(true); - if (_inventoryBox) _inventoryBox->Display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); - if (_indicatorDisplay) DisplayIndicator(); - - - if (Update || DisplayAll) { - // display normal windows - DisplayWindows(false); - - SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); - - // textual info - DisplaySentences(_state == GAME_FROZEN); - - ShowCursor(); - - if (_fader) _fader->Display(); - _transMgr->Update(); - } - - - if (_loadingIcon) { - _loadingIcon->Display(_loadingIconX, _loadingIconY); - if (!_loadingIconPersistent) { - delete _loadingIcon; - _loadingIcon = NULL; - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RegisterInventory(CAdInventory *Inv) { - for (int i = 0; i < _inventories.GetSize(); i++) { - if (_inventories[i] == Inv) return S_OK; - } - RegisterObject(Inv); - _inventories.Add(Inv); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { - for (int i = 0; i < _inventories.GetSize(); i++) { - if (_inventories[i] == Inv) { - UnregisterObject(_inventories[i]); - _inventories.RemoveAt(i); - return S_OK; - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::IsItemTaken(char *ItemName) { - int i; - - for (i = 0; i < _inventories.GetSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { - if (scumm_stricmp(ItemName, Inv->_takenItems[j]->_name) == 0) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::GetItemByName(const char *Name) { - for (int i = 0; i < _items.GetSize(); i++) { - if (scumm_stricmp(_items[i]->_name, Name) == 0) return _items[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddItem(CAdItem *Item) { - _items.Add(Item); - return Game->RegisterObject(Item); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ResetContent() { - int i; - - // clear pending dialogs - for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.RemoveAll(); - - - // clear inventories - for (i = 0; i < _inventories.GetSize(); i++) { - _inventories[i]->_takenItems.RemoveAll(); - } - - // clear scene states - for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; - _sceneStates.RemoveAll(); - - // clear once responses - for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); - - // clear once game responses - for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; - _responsesGame.RemoveAll(); - - // reload inventory items - if (_itemsFile) LoadItemsFile(_itemsFile); - - _tempDisableSaveState = true; - - return CBGame::ResetContent(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DeleteItem(CAdItem *Item) { - if (!Item) return E_FAIL; - - if (_selectedItem == Item) _selectedItem = NULL; - _scene->HandleItemAssociations(Item->_name, false); - - // remove from all inventories - for (int i = 0; i < _inventories.GetSize(); i++) { - _inventories[i]->RemoveItem(Item); - } - - // remove object - for (int i = 0; i < _items.GetSize(); i++) { - if (_items[i] == Item) { - UnregisterObject(_items[i]); - _items.RemoveAt(i); - break; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddSpeechDir(const char *Dir) { - if (!Dir || Dir[0] == '\0') return E_FAIL; - - char *Temp = new char[strlen(Dir) + 2]; - strcpy(Temp, Dir); - if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') - strcat(Temp, "\\"); - - for (int i = 0; i < _speechDirs.GetSize(); i++) { - if (scumm_stricmp(_speechDirs[i], Temp) == 0) { - delete [] Temp; - return S_OK; - } - } - _speechDirs.Add(Temp); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RemoveSpeechDir(const char *Dir) { - if (!Dir || Dir[0] == '\0') return E_FAIL; - - char *Temp = new char[strlen(Dir) + 2]; - strcpy(Temp, Dir); - if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') - strcat(Temp, "\\"); - - bool Found = false; - for (int i = 0; i < _speechDirs.GetSize(); i++) { - if (scumm_stricmp(_speechDirs[i], Temp) == 0) { - delete [] _speechDirs[i]; - _speechDirs.RemoveAt(i); - Found = true; - break; - } - } - delete [] Temp; - - if (Found) return S_OK; - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdGame::FindSpeechFile(char *StringID) { - char *Ret = new char[MAX_PATH]; - - for (int i = 0; i < _speechDirs.GetSize(); i++) { - sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); - CBFile *File = _fileManager->OpenFile(Ret); - if (File) { - _fileManager->CloseFile(File); - return Ret; - } - - sprintf(Ret, "%s%s.wav", _speechDirs[i], StringID); - File = _fileManager->OpenFile(Ret); - if (File) { - _fileManager->CloseFile(File); - return Ret; - } - } - delete [] Ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::ValidMouse() { - POINT Pos; - CBPlatform::GetCursorPos(&Pos); - - return _renderer->PointInViewport(&Pos); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftDown() { - if (!ValidMouse()) return S_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { - FinishSentences(); - } - return S_OK; - } - - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; - _mouseLeftDown = true; - CBPlatform::SetCapture(_renderer->_window); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::ReleaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftRelease"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftDblClick() { - if (!ValidMouse()) return S_OK; - - if (_state == GAME_RUNNING && !_interactive) return S_OK; - - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftDoubleClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftDoubleClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseRightDown() { - if (!ValidMouse()) return S_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { - FinishSentences(); - } - return S_OK; - } - - if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return S_OK; - - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("RightClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseRightUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("RightRelease"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplayDebugInfo() { - char str[100]; - if (Game->_dEBUG_DebugMode) { - sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->GetOffsetLeft(), _mousePos.y + _scene->GetOffsetTop()); - _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - - sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); - } - return CBGame::DisplayDebugInfo(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnScriptShutdown(CScScript *Script) { - if (_responseBox && _responseBox->_waitingScript == Script) - _responseBox->_waitingScript = NULL; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdGame.h b/engines/wintermute/AdGame.h deleted file mode 100644 index f330ef550a..0000000000 --- a/engines/wintermute/AdGame.h +++ /dev/null @@ -1,162 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_ADGAME_H -#define WINTERMUTE_ADGAME_H - -#include "AdTypes.h" -#include "BGame.h" - -namespace WinterMute { -class CAdItem; -class CAdInventory; -class CAdSceneState; -class CAdScene; -class CAdItem; -class CAdObject; -class CAdSentence; -class CAdInventoryBox; -class CAdResponseContext; -class CAdResponseBox; -class CAdGame : public CBGame { -public: - virtual HRESULT OnScriptShutdown(CScScript *Script); - - virtual HRESULT OnMouseLeftDown(); - virtual HRESULT OnMouseLeftUp(); - virtual HRESULT OnMouseLeftDblClick(); - virtual HRESULT OnMouseRightDown(); - virtual HRESULT OnMouseRightUp(); - - virtual HRESULT DisplayDebugInfo(); - - - virtual HRESULT InitAfterLoad(); - static void AfterLoadScene(void *Scene, void *Data); - - bool _smartItemCursor; - - CBArray _speechDirs; - HRESULT AddSpeechDir(const char *Dir); - HRESULT RemoveSpeechDir(const char *Dir); - char *FindSpeechFile(char *StringID); - - HRESULT DeleteItem(CAdItem *Item); - char *_itemsFile; - bool _tempDisableSaveState; - virtual HRESULT ResetContent(); - HRESULT AddItem(CAdItem *Item); - CAdItem *GetItemByName(const char *Name); - CBArray _items; - CAdObject *_inventoryOwner; - bool IsItemTaken(char *ItemName); - HRESULT RegisterInventory(CAdInventory *Inv); - HRESULT UnregisterInventory(CAdInventory *Inv); - - CAdObject *_invObject; - CBArray _inventories; - virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); - char *_debugStartupScene; - char *_startupScene; - bool _initialScene; - bool GameResponseUsed(int ID); - HRESULT AddGameResponse(int ID); - HRESULT ResetResponse(int ID); - - bool BranchResponseUsed(int ID); - HRESULT AddBranchResponse(int ID); - HRESULT ClearBranchResponses(char *Name); - HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); - HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); - virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); - - CAdSceneState *GetSceneState(const char *Filename, bool Saving); - CBViewport *_sceneViewport; - int _texItemLifeTime; - int _texWalkLifeTime; - int _texStandLifeTime; - int _texTalkLifeTime; - - TTalkSkipButton _talkSkipButton; - - virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); - char *_scheduledScene; - bool _scheduledFadeIn; - void SetPrevSceneName(const char *Name); - void SetPrevSceneFilename(const char *Name); - char *_prevSceneName; - char *_prevSceneFilename; - virtual HRESULT LoadGame(const char *Filename); - CAdItem *_selectedItem; - HRESULT Cleanup(); - DECLARE_PERSISTENT(CAdGame, CBGame) - - void FinishSentences(); - HRESULT ShowCursor(); - TGameStateEx _stateEx; - CAdResponseBox *_responseBox; - CAdInventoryBox *_inventoryBox; - HRESULT DisplaySentences(bool Frozen); - void AddSentence(CAdSentence *Sentence); - HRESULT ChangeScene(const char *Filename, bool FadeIn); - HRESULT RemoveObject(CAdObject *Object); - HRESULT AddObject(CAdObject *Object); - CAdScene *_scene; - HRESULT InitLoop(); - CAdGame(); - virtual ~CAdGame(); - CBArray _objects; - CBArray _sentences; - - CBArray _sceneStates; - CBArray _dlgPendingBranches; - - CBArray _responsesBranch; - CBArray _responsesGame; - - virtual HRESULT LoadFile(const char *Filename); - virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - - HRESULT LoadItemsFile(const char *Filename, bool Merge = false); - HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); - - - virtual void PublishNatives(); - virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - bool ValidMouse(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdInventory.cpp b/engines/wintermute/AdInventory.cpp deleted file mode 100644 index 2c7c086a73..0000000000 --- a/engines/wintermute/AdInventory.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "AdInventory.h" -#include "AdGame.h" -#include "AdItem.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventory, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { - _scrollOffset = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventory::~CAdInventory() { - _takenItems.RemoveAll(); // ref only -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::InsertItem(const char *Name, const char *InsertAfter) { - if (Name == NULL) return E_FAIL; - - CAdItem *item = ((CAdGame *)Game)->GetItemByName(Name); - if (item == NULL) return E_FAIL; - - int InsertIndex = -1; - for (int i = 0; i < _takenItems.GetSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { - _takenItems.RemoveAt(i); - i--; - continue; - } - if (InsertAfter && scumm_stricmp(_takenItems[i]->_name, InsertAfter) == 0) InsertIndex = i + 1; - } - - - if (InsertIndex == -1) _takenItems.Add(item); - else _takenItems.InsertAt(InsertIndex, item); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(const char *Name) { - if (Name == NULL) return E_FAIL; - - for (int i = 0; i < _takenItems.GetSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { - if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; - _takenItems.RemoveAt(i); - return S_OK; - } - } - - return E_FAIL; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(CAdItem *Item) { - if (Item == NULL) return E_FAIL; - - for (int i = 0; i < _takenItems.GetSize(); i++) { - if (_takenItems[i] == Item) { - if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; - _takenItems.RemoveAt(i); - return S_OK; - } - } - - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - _takenItems.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdInventory.h b/engines/wintermute/AdInventory.h deleted file mode 100644 index 9ea3ade9a2..0000000000 --- a/engines/wintermute/AdInventory.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORY_H -#define WINTERMUTE_ADINVENTORY_H - -#include "BObject.h" - -namespace WinterMute { - -class CAdItem; - -class CAdInventory : public CBObject { -public: - DECLARE_PERSISTENT(CAdInventory, CBObject) - HRESULT RemoveItem(const char *Name); - HRESULT RemoveItem(CAdItem *Item); - HRESULT InsertItem(const char *Name, const char *InsertAfter = NULL); - CAdInventory(CBGame *inGame); - virtual ~CAdInventory(); - CBArray _takenItems; - int _scrollOffset; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdInventoryBox.cpp b/engines/wintermute/AdInventoryBox.cpp deleted file mode 100644 index b05072e0b9..0000000000 --- a/engines/wintermute/AdInventoryBox.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "dcgf.h" -#include "AdGame.h" -#include "AdInventoryBox.h" -#include "AdInventory.h" -#include "AdItem.h" -#include "BGame.h" -#include "BParser.h" -#include "BFileManager.h" -#include "BViewport.h" -#include "BDynBuffer.h" -#include "UIButton.h" -#include "UIWindow.h" -#include "PlatformSDL.h" -#include "common/str.h" -//#include - - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventoryBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - CBPlatform::SetRectEmpty(&_itemsArea); - _scrollOffset = 0; - _spacing = 0; - _itemWidth = _itemHeight = 50; - _scrollBy = 1; - - _window = NULL; - _closeButton = NULL; - - _hideSelected = false; - - _visible = false; - _exclusive = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::~CAdInventoryBox() { - Game->UnregisterObject(_window); - _window = NULL; - - delete _closeButton; - _closeButton = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) { - _visible = false; - } else if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset -= _scrollBy; - _scrollOffset = MAX(_scrollOffset, 0); - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset += _scrollBy; - } else return CBObject::Listen(param1, param2); - break; - default: - error("CAdInventoryBox::Listen - Unhandled enum"); - break; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Display() { - CAdGame *AdGame = (CAdGame *)Game; - - if (!_visible) return S_OK; - - int ItemsX, ItemsY; - ItemsX = floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); - ItemsY = floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); - - if (_window) { - _window->EnableWidget("prev", _scrollOffset > 0); - _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()); - } - - - if (_closeButton) { - _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = Game->_renderer->_width; - _closeButton->_height = Game->_renderer->_height; - - _closeButton->Display(); - } - - - // display window - RECT rect = _itemsArea; - if (_window) { - CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); - _window->Display(); - } - - // display items - if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor; - int yyy = rect.top; - for (int j = 0; j < ItemsY; j++) { - int xxx = rect.left; - for (int i = 0; i < ItemsX; i++) { - int ItemIndex = _scrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()) { - CAdItem *item = AdGame->_inventoryOwner->GetInventory()->_takenItems[ItemIndex]; - if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { - item->Update(); - item->Display(xxx, yyy); - } - } - - xxx += (_itemWidth + _spacing); - } - yyy += (_itemHeight + _spacing); - } - if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(WINDOW) -TOKEN_DEF(EXCLUSIVE) -TOKEN_DEF(ALWAYS_VISIBLE) -TOKEN_DEF(AREA) -TOKEN_DEF(SPACING) -TOKEN_DEF(ITEM_WIDTH) -TOKEN_DEF(ITEM_HEIGHT) -TOKEN_DEF(SCROLL_BY) -TOKEN_DEF(NAME) -TOKEN_DEF(CAPTION) -TOKEN_DEF(HIDE_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(EXCLUSIVE) - TOKEN_TABLE(ALWAYS_VISIBLE) - TOKEN_TABLE(AREA) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(ITEM_WIDTH) - TOKEN_TABLE(ITEM_HEIGHT) - TOKEN_TABLE(SCROLL_BY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(HIDE_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - bool always_visible = false; - - _exclusive = false; - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { - Game->LOG(0, "'INVENTORY_BOX' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(Game); - if (!_window || FAILED(_window->LoadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else Game->RegisterObject(_window); - break; - - case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); - break; - - case TOKEN_EXCLUSIVE: - parser.ScanStr((char *)params, "%b", &_exclusive); - break; - - case TOKEN_HIDE_SELECTED: - parser.ScanStr((char *)params, "%b", &_hideSelected); - break; - - case TOKEN_ALWAYS_VISIBLE: - parser.ScanStr((char *)params, "%b", &always_visible); - break; - - case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_ITEM_WIDTH: - parser.ScanStr((char *)params, "%d", &_itemWidth); - break; - - case TOKEN_ITEM_HEIGHT: - parser.ScanStr((char *)params, "%d", &_itemHeight); - break; - - case TOKEN_SCROLL_BY: - parser.ScanStr((char *)params, "%d", &_scrollBy); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in INVENTORY_BOX definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading INVENTORY_BOX definition"); - return E_FAIL; - } - - if (_exclusive) { - delete _closeButton; - _closeButton = new CUIButton(Game); - if (_closeButton) { - _closeButton->SetName("close"); - _closeButton->SetListener(this, _closeButton, 0); - _closeButton->_parent = _window; - } - } - - _visible = always_visible; - - if (_window) { - for (int i = 0; i < _window->_widgets.GetSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - - Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); - Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); - Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); - Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // window - if (_window) _window->SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_closeButton)); - PersistMgr->Transfer(TMEMBER(_hideSelected)); - PersistMgr->Transfer(TMEMBER(_itemHeight)); - PersistMgr->Transfer(TMEMBER(_itemsArea)); - PersistMgr->Transfer(TMEMBER(_itemWidth)); - PersistMgr->Transfer(TMEMBER(_scrollBy)); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_spacing)); - PersistMgr->Transfer(TMEMBER(_visible)); - PersistMgr->Transfer(TMEMBER(_window)); - PersistMgr->Transfer(TMEMBER(_exclusive)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdInventoryBox.h b/engines/wintermute/AdInventoryBox.h deleted file mode 100644 index 9f7dba6a2b..0000000000 --- a/engines/wintermute/AdInventoryBox.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORYBOX_H -#define WINTERMUTE_ADINVENTORYBOX_H - -#include "BObject.h" - -namespace WinterMute { -class CUIButton; -class CUIWindow; - -class CAdInventoryBox : public CBObject { -public: - bool _hideSelected; - DECLARE_PERSISTENT(CAdInventoryBox, CBObject) - bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; - bool _visible; - virtual HRESULT Display(); - CUIButton *_closeButton; - int _spacing; - int _scrollOffset; - RECT _itemsArea; - HRESULT Listen(CBScriptHolder *param1, uint32 param2); - CUIWindow *_window; - CAdInventoryBox(CBGame *inGame); - virtual ~CAdInventoryBox(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdItem.cpp b/engines/wintermute/AdItem.cpp deleted file mode 100644 index 3b78fa5507..0000000000 --- a/engines/wintermute/AdItem.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/AdItem.h" -#include "engines/wintermute/AdGame.h" -#include "engines/wintermute/AdSentence.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdItem, false) - -////////////////////////////////////////////////////////////////////////// -CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { - _spriteHover = NULL; - _cursorNormal = _cursorHover = NULL; - - _cursorCombined = true; - _inInventory = false; - - _displayAmount = false; - _amount = 0; - _amountOffsetX = 0; - _amountOffsetY = 0; - _amountAlign = TAL_RIGHT; - _amountString = NULL; - - _state = STATE_READY; - - _movable = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdItem::~CAdItem() { - delete _spriteHover; - delete _cursorNormal; - delete _cursorHover; - _spriteHover = NULL; - _cursorNormal = NULL; - _cursorHover = NULL; - - delete[] _amountString; - _amountString = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ITEM) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(CURSOR_HOVER) -TOKEN_DEF(CURSOR_COMBINED) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(FONT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(SPRITE_HOVER) -TOKEN_DEF(SPRITE) -TOKEN_DEF(DISPLAY_AMOUNT) -TOKEN_DEF(AMOUNT_OFFSET_X) -TOKEN_DEF(AMOUNT_OFFSET_Y) -TOKEN_DEF(AMOUNT_ALIGN) -TOKEN_DEF(AMOUNT_STRING) -TOKEN_DEF(AMOUNT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(CURSOR_HOVER) - TOKEN_TABLE(CURSOR_COMBINED) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(FONT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(SPRITE_HOVER) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(DISPLAY_AMOUNT) - TOKEN_TABLE(AMOUNT_OFFSET_X) - TOKEN_TABLE(AMOUNT_OFFSET_Y) - TOKEN_TABLE(AMOUNT_ALIGN) - TOKEN_TABLE(AMOUNT_STRING) - TOKEN_TABLE(AMOUNT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ITEM) { - Game->LOG(0, "'ITEM' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_IMAGE: - case TOKEN_SPRITE: - delete _sprite; - _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { - delete _sprite; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - case TOKEN_SPRITE_HOVER: - delete _spriteHover; - _spriteHover = new CBSprite(Game, this); - if (!_spriteHover || FAILED(_spriteHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { - delete _spriteHover; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_AMOUNT: - parser.ScanStr((char *)params, "%d", &_amount); - break; - - case TOKEN_DISPLAY_AMOUNT: - parser.ScanStr((char *)params, "%b", &_displayAmount); - break; - - case TOKEN_AMOUNT_OFFSET_X: - parser.ScanStr((char *)params, "%d", &_amountOffsetX); - break; - - case TOKEN_AMOUNT_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &_amountOffsetY); - break; - - case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; - else _amountAlign = TAL_CENTER; - break; - - case TOKEN_AMOUNT_STRING: - CBUtils::SetString(&_amountString, (char *)params); - break; - - case TOKEN_TALK: { - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); - } - break; - - case TOKEN_CURSOR: - delete _cursorNormal; - _cursorNormal = new CBSprite(Game); - if (!_cursorNormal || FAILED(_cursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { - delete _cursorNormal; - _cursorNormal = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_HOVER: - delete _cursorHover; - _cursorHover = new CBSprite(Game); - if (!_cursorHover || FAILED(_cursorHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { - delete _cursorHover; - _cursorHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_COMBINED: - parser.ScanStr((char *)params, "%b", &_cursorCombined); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ITEM definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ITEM definition"); - return E_FAIL; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = DRGBA(ar, ag, ab, alpha); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) { - if (Game->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; - else _currentSprite = _sprite; - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->Update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->Finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); - if (_tempSprite2) { - _tempSprite2->Reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)Game)->AddSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); - } - } - break; - } - _ready = (_state == STATE_READY); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Display(int X, int Y) { - int Width = 0; - if (_currentSprite) { - RECT rc; - _currentSprite->GetBoundingRect(&rc, 0, 0); - Width = rc.right - rc.left; - } - - _posX = X + Width / 2; - _posY = Y; - - HRESULT ret; - if (_currentSprite) ret = _currentSprite->Draw(X, Y, this, 100, 100, _alphaColor); - else ret = S_OK; - - if (_displayAmount) { - int AmountX = X; - int AmountY = Y + _amountOffsetY; - - if (_amountAlign == TAL_RIGHT) { - Width -= _amountOffsetX; - AmountX -= _amountOffsetX; - } - AmountX += _amountOffsetX; - - CBFont *Font = _font ? _font : Game->_systemFont; - if (Font) { - if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); - else { - char Str[256]; - sprintf(Str, "%d", _amount); - Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); - } - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetHoverSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetHoverSprite") == 0) { - Stack->CorrectParams(1); - - bool SetCurrent = false; - if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - - const char *Filename = Stack->Pop()->GetString(); - - delete _spriteHover; - _spriteHover = NULL; - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); - } else { - _spriteHover = spr; - if (SetCurrent) _currentSprite = _spriteHover; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverSprite") == 0) { - Stack->CorrectParams(0); - - if (!_spriteHover || !_spriteHover->_filename) Stack->PushNULL(); - else Stack->PushString(_spriteHover->_filename); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverSpriteObject") == 0) { - Stack->CorrectParams(0); - if (!_spriteHover) Stack->PushNULL(); - else Stack->PushNative(_spriteHover, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetNormalCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetNormalCursor") == 0) { - Stack->CorrectParams(1); - - const char *Filename = Stack->Pop()->GetString(); - - delete _cursorNormal; - _cursorNormal = NULL; - CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); - } else { - _cursorNormal = spr; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNormalCursor") == 0) { - Stack->CorrectParams(0); - - if (!_cursorNormal || !_cursorNormal->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorNormal->_filename); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNormalCursorObject") == 0) { - Stack->CorrectParams(0); - - if (!_cursorNormal) Stack->PushNULL(); - else Stack->PushNative(_cursorNormal, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetHoverCursor") == 0) { - Stack->CorrectParams(1); - - const char *Filename = Stack->Pop()->GetString(); - - delete _cursorHover; - _cursorHover = NULL; - CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); - } else { - _cursorHover = spr; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverCursor") == 0) { - Stack->CorrectParams(0); - - if (!_cursorHover || !_cursorHover->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorHover->_filename); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverCursorObject") == 0) { - Stack->CorrectParams(0); - - if (!_cursorHover) Stack->PushNULL(); - else Stack->PushNative(_cursorHover, true); - return S_OK; - } - - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("item"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayAmount") == 0) { - _scValue->SetBool(_displayAmount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Amount") == 0) { - _scValue->SetInt(_amount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetX") == 0) { - _scValue->SetInt(_amountOffsetX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetY") == 0) { - _scValue->SetInt(_amountOffsetY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountAlign") == 0) { - _scValue->SetInt(_amountAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountString") == 0) { - if (!_amountString) _scValue->SetNULL(); - else _scValue->SetString(_amountString); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorCombined") == 0) { - _scValue->SetBool(_cursorCombined); - return _scValue; - } - - else return CAdTalkHolder::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayAmount") == 0) { - _displayAmount = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Amount") == 0) { - _amount = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetX") == 0) { - _amountOffsetX = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetY") == 0) { - _amountOffsetY = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountAlign") == 0) { - _amountAlign = (TTextAlign)Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountString") == 0) { - if (Value->IsNULL()) { - delete[] _amountString; - _amountString = NULL; - } else { - CBUtils::SetString(&_amountString, Value->GetString()); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorCombined") == 0) { - _cursorCombined = Value->GetBool(); - return S_OK; - } - - else return CAdTalkHolder::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdItem::ScToString() { - return "[item]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { - - CAdTalkHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_cursorCombined)); - PersistMgr->Transfer(TMEMBER(_cursorHover)); - PersistMgr->Transfer(TMEMBER(_cursorNormal)); - PersistMgr->Transfer(TMEMBER(_spriteHover)); - PersistMgr->Transfer(TMEMBER(_inInventory)); - PersistMgr->Transfer(TMEMBER(_displayAmount)); - PersistMgr->Transfer(TMEMBER(_amount)); - PersistMgr->Transfer(TMEMBER(_amountOffsetX)); - PersistMgr->Transfer(TMEMBER(_amountOffsetY)); - PersistMgr->Transfer(TMEMBER_INT(_amountAlign)); - PersistMgr->Transfer(TMEMBER(_amountString)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::GetExtendedFlag(const char *FlagName) { - if (!FlagName) return false; - else if (strcmp(FlagName, "usable") == 0) return true; - else return CAdObject::GetExtendedFlag(FlagName); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdItem.h b/engines/wintermute/AdItem.h deleted file mode 100644 index 143f27fc87..0000000000 --- a/engines/wintermute/AdItem.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADITEM_H -#define WINTERMUTE_ADITEM_H - - -#include "AdTalkHolder.h" - -namespace WinterMute { - -class CAdItem : public CAdTalkHolder { -public: - bool _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; - TTextAlign _amountAlign; - char *_amountString; - - - HRESULT Update(); - DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - HRESULT Display(int X, int Y); - bool GetExtendedFlag(const char *FlagName); - bool _inInventory; - bool _cursorCombined; - CBSprite *_spriteHover; - CBSprite *_cursorNormal; - CBSprite *_cursorHover; - CAdItem(CBGame *inGame); - virtual ~CAdItem(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdLayer.cpp b/engines/wintermute/AdLayer.cpp deleted file mode 100644 index b25dd57315..0000000000 --- a/engines/wintermute/AdLayer.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BGame.h" -#include "AdLayer.h" -#include "AdSceneNode.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "BFileManager.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdLayer, false) - -////////////////////////////////////////////////////////////////////////// -CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { - _main = false; - _width = _height = 0; - _active = true; - _closeUp = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdLayer::~CAdLayer() { - for (int i = 0; i < _nodes.GetSize(); i++) - delete _nodes[i]; - _nodes.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(LAYER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(MAIN) -TOKEN_DEF(ENTITY) -TOKEN_DEF(REGION) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(CLOSE_UP) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(MAIN) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(REGION) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(CLOSE_UP) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_LAYER) { - Game->LOG(0, "'LAYER' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_MAIN: - parser.ScanStr((char *)params, "%b", &_main); - break; - - case TOKEN_CLOSE_UP: - parser.ScanStr((char *)params, "%b", &_closeUp); - break; - - case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); - break; - - case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); - break; - - case TOKEN_REGION: { - CAdRegion *region = new CAdRegion(Game); - CAdSceneNode *node = new CAdSceneNode(Game); - if (!region || !node || FAILED(region->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete region; - delete node; - region = NULL; - node = NULL; - } else { - node->SetRegion(region); - _nodes.Add(node); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(Game); - CAdSceneNode *node = new CAdSceneNode(Game); - if (entity) entity->_zoomable = false; // scene entites default to NOT zoom - if (!entity || !node || FAILED(entity->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - delete node; - entity = NULL; - node = NULL; - } else { - node->SetEntity(entity); - _nodes.Add(node); - } - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in LAYER definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetNode") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - int node = -1; - - if (val->_type == VAL_INT) node = val->GetInt(); - else { // get by name - for (int i = 0; i < _nodes.GetSize(); i++) { - if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->GetString()) == 0) || - (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->GetString()) == 0)) { - node = i; - break; - } - } - } - - if (node < 0 || node >= _nodes.GetSize()) Stack->PushNULL(); - else { - switch (_nodes[node]->_type) { - case OBJECT_ENTITY: - Stack->PushNative(_nodes[node]->_entity, true); - break; - case OBJECT_REGION: - Stack->PushNative(_nodes[node]->_region, true); - break; - default: - Stack->PushNULL(); - } - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddRegion / AddEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddRegion") == 0 || strcmp(Name, "AddEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdSceneNode *Node = new CAdSceneNode(Game); - if (strcmp(Name, "AddRegion") == 0) { - CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->SetName(Val->GetString()); - Node->SetRegion(Region); - Stack->PushNative(Region, true); - } else { - CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->SetName(Val->GetString()); - Node->SetEntity(Entity); - Stack->PushNative(Entity, true); - } - _nodes.Add(Node); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertRegion / InsertEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertRegion") == 0 || strcmp(Name, "InsertEntity") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); - - CAdSceneNode *Node = new CAdSceneNode(Game); - if (strcmp(Name, "InsertRegion") == 0) { - CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->SetName(Val->GetString()); - Node->SetRegion(Region); - Stack->PushNative(Region, true); - } else { - CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->SetName(Val->GetString()); - Node->SetEntity(Entity); - Stack->PushNative(Entity, true); - } - if (Index < 0) Index = 0; - if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); - else _nodes.Add(Node); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteNode") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdSceneNode *ToDelete = NULL; - if (Val->IsNative()) { - CBScriptable *Temp = Val->GetNative(); - for (int i = 0; i < _nodes.GetSize(); i++) { - if (_nodes[i]->_region == Temp || _nodes[i]->_entity == Temp) { - ToDelete = _nodes[i]; - break; - } - } - } else { - int Index = Val->GetInt(); - if (Index >= 0 && Index < _nodes.GetSize()) { - ToDelete = _nodes[Index]; - } - } - if (ToDelete == NULL) { - Stack->PushBool(false); - return S_OK; - } - - for (int i = 0; i < _nodes.GetSize(); i++) { - if (_nodes[i] == ToDelete) { - delete _nodes[i]; - _nodes[i] = NULL; - _nodes.RemoveAt(i); - break; - } - } - Stack->PushBool(true); - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("layer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumNodes") == 0) { - _scValue->SetInt(_nodes.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _scValue->SetInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _scValue->SetInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Main (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Main") == 0) { - _scValue->SetBool(_main); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CloseUp") == 0) { - _scValue->SetBool(_closeUp); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - _scValue->SetBool(_active); - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CloseUp") == 0) { - _closeUp = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _width = Value->GetInt(); - if (_width < 0) _width = 0; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _height = Value->GetInt(); - if (_height < 0) _height = 0; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - bool b = Value->GetBool(); - if (b == false && _main) { - Game->LOG(0, "Warning: cannot deactivate scene's main layer"); - } else _active = b; - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdLayer::ScToString() { - return "[layer]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "LAYER {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_closeUp) - Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); - - int i; - - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - - for (i = 0; i < _nodes.GetSize(); i++) { - switch (_nodes[i]->_type) { - case OBJECT_ENTITY: - _nodes[i]->_entity->SaveAsText(Buffer, Indent + 2); - break; - case OBJECT_REGION: - _nodes[i]->_region->SaveAsText(Buffer, Indent + 2); - break; - default: - error("CAdLayer::SaveAsText - Unhandled enum"); - break; - } - } - - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_closeUp)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_main)); - _nodes.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_width)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdLayer.h b/engines/wintermute/AdLayer.h deleted file mode 100644 index 1c0e3fa946..0000000000 --- a/engines/wintermute/AdLayer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADLAYER_H -#define WINTERMUTE_ADLAYER_H - -namespace WinterMute { -class CAdSceneNode; -class CAdLayer : public CBObject { -public: - bool _closeUp; - DECLARE_PERSISTENT(CAdLayer, CBObject) - bool _active; - int _height; - int _width; - bool _main; - CAdLayer(CBGame *inGame); - virtual ~CAdLayer(); - CBArray _nodes; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdNodeState.cpp b/engines/wintermute/AdNodeState.cpp deleted file mode 100644 index 80858c4a2d..0000000000 --- a/engines/wintermute/AdNodeState.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BGame.h" -#include "AdNodeState.h" -#include "AdEntity.h" -#include "BStringTable.h" -#include "BSprite.h" -#include "utils.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdNodeState, false) - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { - _name = NULL; - _active = false; - for (int i = 0; i < 7; i++) _caption[i] = NULL; - _alphaColor = 0; - _filename = NULL; - _cursor = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::~CAdNodeState() { - delete[] _name; - delete[] _filename; - delete[] _cursor; - _name = NULL; - _filename = NULL; - _cursor = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetName(const char *Name) { - delete[] _name; - _name = NULL; - CBUtils::SetString(&_name, Name); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetFilename(const char *Filename) { - delete[] _filename; - _filename = NULL; - CBUtils::SetString(&_filename, Filename); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCursor(const char *Filename) { - delete[] _cursor; - _cursor = NULL; - CBUtils::SetString(&_cursor, Filename); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_cursor)); - PersistMgr->Transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCaption(const char *Caption, int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) return; - - delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(Caption) + 1]; - if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], Caption); - Game->_stringTable->Expand(&_caption[Case - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::GetCaption(int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; - else return _caption[Case - 1]; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving) { - if (!Entity) return E_FAIL; - - // hack! - if (this->Game != Entity->Game) this->Game = Entity->Game; - - if (Saving) { - for (int i = 0; i < 7; i++) { - if (Entity->_caption[i]) SetCaption(Entity->_caption[i], i); - } - if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { - if (IncludingSprites) SetFilename(Entity->_sprite->_filename); - else SetFilename(""); - } - if (Entity->_cursor && Entity->_cursor->_filename) SetCursor(Entity->_cursor->_filename); - _alphaColor = Entity->_alphaColor; - _active = Entity->_active; - } else { - for (int i = 0; i < 7; i++) { - if (_caption[i]) Entity->SetCaption(_caption[i], i); - } - if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { - if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) - Entity->SetSprite(_filename); - } - if (_cursor) { - if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) - Entity->SetCursor(_cursor); - } - - Entity->_active = _active; - Entity->_alphaColor = _alphaColor; - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdNodeState.h b/engines/wintermute/AdNodeState.h deleted file mode 100644 index 16445376ca..0000000000 --- a/engines/wintermute/AdNodeState.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADNODESTATE_H -#define WINTERMUTE_ADNODESTATE_H - -namespace WinterMute { - -class CAdEntity; - -class CAdNodeState : public CBBase { -public: - HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); - void SetName(const char *Name); - void SetFilename(const char *Filename); - void SetCursor(const char *Filename); - DECLARE_PERSISTENT(CAdNodeState, CBBase) - CAdNodeState(CBGame *inGame); - virtual ~CAdNodeState(); - char *_name; - bool _active; - char *_caption[7]; - void SetCaption(const char *Caption, int Case); - char *GetCaption(int Case); - uint32 _alphaColor; - char *_filename; - char *_cursor; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdObject.cpp b/engines/wintermute/AdObject.cpp deleted file mode 100644 index 188eb19fc9..0000000000 --- a/engines/wintermute/AdObject.cpp +++ /dev/null @@ -1,1203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "engines/wintermute/AdGame.h" -#include "engines/wintermute/AdItem.h" -#include "engines/wintermute/AdObject.h" -#include "engines/wintermute/AdInventory.h" -#include "engines/wintermute/AdLayer.h" -#include "engines/wintermute/AdScene.h" -#include "engines/wintermute/AdSceneNode.h" -#include "engines/wintermute/AdSentence.h" -#include "engines/wintermute/AdWaypointGroup.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFrame.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "common/str.h" -#include "common/util.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdObject, false) - -////////////////////////////////////////////////////////////////////////// -CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _state = _nextState = STATE_NONE; - - _active = true; - _drawn = false; - - _currentSprite = NULL; - _animSprite = NULL; - _tempSprite2 = NULL; - - _font = NULL; - - _sentence = NULL; - - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - - _blockRegion = NULL; - _wptGroup = NULL; - - _currentBlockRegion = NULL; - _currentWptGroup = NULL; - - _ignoreItems = false; - _sceneIndependent = false; - - _stickRegion = NULL; - - _subtitlesModRelative = true; - _subtitlesModX = 0; - _subtitlesModY = 0; - _subtitlesWidth = 0; - _subtitlesModXCenter = true; - - _inventory = NULL; - - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - - _partEmitter = NULL; - _partFollowParent = false; - _partOffsetX = _partOffsetY = 0; - - _registerAlias = this; -} - - -////////////////////////////////////////////////////////////////////////// -CAdObject::~CAdObject() { - _currentSprite = NULL; // reference only, don't delete - delete _animSprite; - _animSprite = NULL; - delete _sentence; - _sentence = NULL; - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - - delete _blockRegion; - _blockRegion = NULL; - delete _wptGroup; - _wptGroup = NULL; - - delete _currentBlockRegion; - _currentBlockRegion = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - - _tempSprite2 = NULL; // reference only - _stickRegion = NULL; - - if (_font) Game->_fontStorage->RemoveFont(_font); - - if (_inventory) { - ((CAdGame *)Game)->UnregisterInventory(_inventory); - _inventory = NULL; - } - - if (_partEmitter) - Game->UnregisterObject(_partEmitter); - - - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - Game->UnregisterObject(_attachmentsPre[i]); - } - _attachmentsPre.RemoveAll(); - - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - Game->UnregisterObject(_attachmentsPost[i]); - } - _attachmentsPost.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::PlayAnim(const char *Filename) { - delete _animSprite; - _animSprite = NULL; - _animSprite = new CBSprite(Game, this); - if (!_animSprite) { - Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); - return E_FAIL; - } - HRESULT res = _animSprite->LoadFile(Filename); - if (FAILED(res)) { - Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); - delete _animSprite; - _animSprite = NULL; - return res; - } - _state = STATE_PLAYING_ANIM; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Display() { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Update() { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - - ////////////////////////////////////////////////////////////////////////// - // PlayAnim / PlayAnimAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "PlayAnim") == 0 || strcmp(Name, "PlayAnimAsync") == 0) { - Stack->CorrectParams(1); - if (FAILED(PlayAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); - else { - if (strcmp(Name, "PlayAnimAsync") != 0) Script->WaitFor(this); - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); - Reset(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTalking") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(_state == STATE_TALKING); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTalk / StopTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { - Stack->CorrectParams(0); - if (_sentence) _sentence->Finish(); - if (_state == STATE_TALKING) { - _state = _nextState; - _nextState = STATE_READY; - Stack->PushBool(true); - } else Stack->PushBool(false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ForceTalkAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ForceTalkAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = new char[strlen(AnimName) + 1]; - strcpy(_forcedTalkAnimName, AnimName); - _forcedTalkAnimUsed = false; - Stack->PushBool(true); - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Talk / TalkAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Talk") == 0 || strcmp(Name, "TalkAsync") == 0) { - Stack->CorrectParams(5); - - const char *Text = Stack->Pop()->GetString(); - CScValue *SoundVal = Stack->Pop(); - int Duration = Stack->Pop()->GetInt(); - CScValue *ValStances = Stack->Pop(); - - const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); - - int Align; - CScValue *val = Stack->Pop(); - if (val->IsNULL()) Align = TAL_CENTER; - else Align = val->GetInt(); - - Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); - - const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); - - Talk(Text, Sound, Duration, Stances, (TTextAlign)Align); - if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StickToRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StickToRegion") == 0) { - Stack->CorrectParams(1); - - CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; - bool RegFound = false; - - int i; - CScValue *Val = Stack->Pop(); - if (Val->IsNULL() || !Main) { - _stickRegion = NULL; - RegFound = true; - } else if (Val->IsString()) { - const char *RegionName = Val->GetString(); - for (i = 0; i < Main->_nodes.GetSize(); i++) { - if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { - _stickRegion = Main->_nodes[i]->_region; - RegFound = true; - break; - } - } - } else if (Val->IsNative()) { - CBScriptable *Obj = Val->GetNative(); - - for (i = 0; i < Main->_nodes.GetSize(); i++) { - if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region == Obj) { - _stickRegion = Main->_nodes[i]->_region; - RegFound = true; - break; - } - } - - } - - if (!RegFound) _stickRegion = NULL; - Stack->PushBool(RegFound); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (Val->IsNULL()) SetFont(NULL); - else SetFont(Val->GetString()); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFont") == 0) { - Stack->CorrectParams(0); - if (_font && _font->_filename) Stack->PushString(_font->_filename); - else Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TakeItem") == 0) { - Stack->CorrectParams(2); - - if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); - } - - CScValue *val = Stack->Pop(); - if (!val->IsNULL()) { - const char *ItemName = val->GetString(); - val = Stack->Pop(); - const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); - if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); - else { - // hide associated entities - ((CAdGame *)Game)->_scene->HandleItemAssociations(ItemName, false); - } - - } else Script->RuntimeError("TakeItem: item name expected"); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DropItem") == 0) { - Stack->CorrectParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); - } - - CScValue *val = Stack->Pop(); - if (!val->IsNULL()) { - if (FAILED(_inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); - else { - // show associated entities - ((CAdGame *)Game)->_scene->HandleItemAssociations(val->GetString(), true); - } - } else Script->RuntimeError("DropItem: item name expected"); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetItem") == 0) { - Stack->CorrectParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); - } - - CScValue *val = Stack->Pop(); - if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); - if (item) Stack->PushNative(item, true); - else Stack->PushNULL(); - } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) - Stack->PushNULL(); - else - Stack->PushNative(_inventory->_takenItems[val->GetInt()], true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasItem") == 0) { - Stack->CorrectParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); - } - - CScValue *val = Stack->Pop(); - if (!val->IsNULL()) { - for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { - if (val->GetNative() == _inventory->_takenItems[i]) { - Stack->PushBool(true); - return S_OK; - } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { - Stack->PushBool(true); - return S_OK; - } - } - } else Script->RuntimeError("HasItem: item name expected"); - - Stack->PushBool(false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateParticleEmitter") == 0) { - Stack->CorrectParams(3); - bool FollowParent = Stack->Pop()->GetBool(); - int OffsetX = Stack->Pop()->GetInt(); - int OffsetY = Stack->Pop()->GetInt(); - - CPartEmitter *Emitter = CreateParticleEmitter(FollowParent, OffsetX, OffsetY); - if (Emitter) Stack->PushNative(_partEmitter, true); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteParticleEmitter") == 0) { - Stack->CorrectParams(0); - if (_partEmitter) { - Game->UnregisterObject(_partEmitter); - _partEmitter = NULL; - } - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddAttachment") == 0) { - Stack->CorrectParams(4); - const char *Filename = Stack->Pop()->GetString(); - bool PreDisplay = Stack->Pop()->GetBool(true); - int OffsetX = Stack->Pop()->GetInt(); - int OffsetY = Stack->Pop()->GetInt(); - - HRESULT res; - CAdEntity *Ent = new CAdEntity(Game); - if (FAILED(res = Ent->LoadFile(Filename))) { - delete Ent; - Ent = NULL; - Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); - Stack->PushBool(false); - } else { - Game->RegisterObject(Ent); - - Ent->_posX = OffsetX; - Ent->_posY = OffsetY; - Ent->_active = true; - - if (PreDisplay) _attachmentsPre.Add(Ent); - else _attachmentsPost.Add(Ent); - - Stack->PushBool(true); - } - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveAttachment") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - bool Found = false; - if (Val->IsNative()) { - CBScriptable *Obj = Val->GetNative(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i] == Obj) { - Found = true; - Game->UnregisterObject(_attachmentsPre[i]); - _attachmentsPre.RemoveAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i] == Obj) { - Found = true; - Game->UnregisterObject(_attachmentsPost[i]); - _attachmentsPost.RemoveAt(i); - i--; - } - } - } else { - const char *Name = Val->GetString(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { - Found = true; - Game->UnregisterObject(_attachmentsPre[i]); - _attachmentsPre.RemoveAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { - Found = true; - Game->UnregisterObject(_attachmentsPost[i]); - _attachmentsPost.RemoveAt(i); - i--; - } - } - } - Stack->PushBool(Found); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetAttachment") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdObject *Ret = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); - int CurrIndex = 0; - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (CurrIndex == Index) Ret = _attachmentsPre[i]; - CurrIndex++; - } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (CurrIndex == Index) Ret = _attachmentsPost[i]; - CurrIndex++; - } - } else { - const char *Name = Val->GetString(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { - Ret = _attachmentsPre[i]; - break; - } - } - if (!Ret) { - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { - Ret = _attachmentsPre[i]; - break; - } - } - } - } - - if (Ret != NULL) Stack->PushNative(Ret, true); - else Stack->PushNULL(); - - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - _scValue->SetBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IgnoreItems") == 0) { - _scValue->SetBool(_ignoreItems); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SceneIndependent") == 0) { - _scValue->SetBool(_sceneIndependent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesWidth") == 0) { - _scValue->SetInt(_subtitlesWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosRelative") == 0) { - _scValue->SetBool(_subtitlesModRelative); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosX") == 0) { - _scValue->SetInt(_subtitlesModX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosY") == 0) { - _scValue->SetInt(_subtitlesModY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { - _scValue->SetBool(_subtitlesModXCenter); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumItems (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumItems") == 0) { - _scValue->SetInt(GetInventory()->_takenItems.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParticleEmitter (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParticleEmitter") == 0) { - if (_partEmitter) _scValue->SetNative(_partEmitter, true); - else _scValue->SetNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumAttachments (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumAttachments") == 0) { - _scValue->SetInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); - return _scValue; - } - - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Active") == 0) { - _active = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IgnoreItems") == 0) { - _ignoreItems = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SceneIndependent") == 0) { - _sceneIndependent = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesWidth") == 0) { - _subtitlesWidth = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosRelative") == 0) { - _subtitlesModRelative = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosX") == 0) { - _subtitlesModX = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosY") == 0) { - _subtitlesModY = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { - _subtitlesModXCenter = Value->GetBool(); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdObject::ScToString() { - return "[ad object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SetFont(const char *Filename) { - if (_font) Game->_fontStorage->RemoveFont(_font); - if (Filename) { - _font = Game->_fontStorage->AddFont(Filename); - return _font == NULL ? E_FAIL : S_OK; - } else { - _font = NULL; - return S_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CAdObject::GetHeight() { - if (!_currentSprite) return 0; - else { - CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; - int ret = 0; - for (int i = 0; i < frame->_subframes.GetSize(); i++) { - ret = MAX(ret, frame->_subframes[i]->_hotspotY); - } - - if (_zoomable) { - float zoom = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY); - ret = ret * zoom / 100; - } - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { - if (!_sentence) _sentence = new CAdSentence(Game); - if (!_sentence) return; - - if (_forcedTalkAnimName && _forcedTalkAnimUsed) { - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - } - - delete (_sentence->_sound); - _sentence->_sound = NULL; - - _sentence->SetText(Text); - Game->_stringTable->Expand(&_sentence->_text); - _sentence->SetStances(Stances); - _sentence->_duration = Duration; - _sentence->_align = Align; - _sentence->_startTime = Game->_timer; - _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? Game->_systemFont : _font; - _sentence->_freezable = _freezable; - - // try to locate speech file automatically - bool DeleteSound = false; - if (!Sound) { - char *Key = Game->_stringTable->GetKey(Text); - if (Key) { - Sound = ((CAdGame *)Game)->FindSpeechFile(Key); - delete [] Key; - - if (Sound) DeleteSound = true; - } - } - - // load sound and set duration appropriately - if (Sound) { - CBSound *snd = new CBSound(Game); - if (snd && SUCCEEDED(snd->SetSound(Sound, SOUND_SPEECH, true))) { - _sentence->SetSound(snd); - if (_sentence->_duration <= 0) { - uint32 Length = snd->GetLength(); - if (Length != 0) _sentence->_duration = Length; - } - } else delete snd; - } - - // set duration by text length - if (_sentence->_duration <= 0) {// TODO: Avoid longs. - _sentence->_duration = MAX((size_t)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); - } - - - int x, y, width, height; - - x = _posX; - y = _posY; - - if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)Game)->_scene->GetOffsetLeft(); - y -= ((CAdGame *)Game)->_scene->GetOffsetTop(); - } - - - if (_subtitlesWidth > 0) width = _subtitlesWidth; - else { - if ((x < Game->_renderer->_width / 4 || x > Game->_renderer->_width * 0.75) && !Game->_touchInterface) { - width = MAX(Game->_renderer->_width / 4, MIN(x * 2, (Game->_renderer->_width - x) * 2)); - } else width = Game->_renderer->_width / 2; - } - - height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); - - y = y - height - GetHeight() - 5; - if (_subtitlesModRelative) { - x += _subtitlesModX; - y += _subtitlesModY; - } else { - x = _subtitlesModX; - y = _subtitlesModY; - } - if (_subtitlesModXCenter) - x = x - width / 2; - - - x = MIN(MAX(0, x), Game->_renderer->_width - width); - y = MIN(MAX(0, y), Game->_renderer->_height - height); - - _sentence->_width = width; - - - _sentence->_pos.x = x; - _sentence->_pos.y = y; - - - if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)Game)->_scene->GetOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)Game)->_scene->GetOffsetTop(); - } - - _sentence->_fixedPos = !_subtitlesModRelative; - - - _sentence->SetupTalkFile(Sound); - - _state = STATE_TALKING; - - if (DeleteSound) delete [] Sound; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Reset() { - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { - delete _animSprite; - _animSprite = NULL; - } else if (_state == STATE_TALKING && _sentence) { - _sentence->Finish(); - } - - _state = _nextState = STATE_READY; - - Game->_scEngine->ResetObject(this); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_blockRegion)); - PersistMgr->Transfer(TMEMBER(_currentBlockRegion)); - PersistMgr->Transfer(TMEMBER(_currentWptGroup)); - PersistMgr->Transfer(TMEMBER(_currentSprite)); - PersistMgr->Transfer(TMEMBER(_drawn)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_ignoreItems)); - PersistMgr->Transfer(TMEMBER_INT(_nextState)); - PersistMgr->Transfer(TMEMBER(_sentence)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_animSprite)); - PersistMgr->Transfer(TMEMBER(_sceneIndependent)); - PersistMgr->Transfer(TMEMBER(_forcedTalkAnimName)); - PersistMgr->Transfer(TMEMBER(_forcedTalkAnimUsed)); - PersistMgr->Transfer(TMEMBER(_tempSprite2)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_wptGroup)); - PersistMgr->Transfer(TMEMBER(_stickRegion)); - PersistMgr->Transfer(TMEMBER(_subtitlesModRelative)); - PersistMgr->Transfer(TMEMBER(_subtitlesModX)); - PersistMgr->Transfer(TMEMBER(_subtitlesModY)); - PersistMgr->Transfer(TMEMBER(_subtitlesModXCenter)); - PersistMgr->Transfer(TMEMBER(_subtitlesWidth)); - PersistMgr->Transfer(TMEMBER(_inventory)); - PersistMgr->Transfer(TMEMBER(_partEmitter)); - - for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(_currentRegions[i])); - - _attachmentsPre.Persist(PersistMgr); - _attachmentsPost.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_registerAlias)); - - PersistMgr->Transfer(TMEMBER(_partFollowParent)); - PersistMgr->Transfer(TMEMBER(_partOffsetX)); - PersistMgr->Transfer(TMEMBER(_partOffsetY)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateSounds() { - if (_sentence && _sentence->_sound) - UpdateOneSound(_sentence->_sound); - - return CBObject::UpdateSounds(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ResetSoundPan() { - if (_sentence && _sentence->_sound) { - _sentence->_sound->SetPan(0.0f); - } - return CBObject::ResetSoundPan(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::GetExtendedFlag(const char *FlagName) { - if (!FlagName) return false; - else if (strcmp(FlagName, "usable") == 0) return true; - - else return CBObject::GetExtendedFlag(FlagName); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { - if (_blockRegion) _blockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->SaveAsText(Buffer, Indent + 2); - - CBBase::SaveAsText(Buffer, Indent + 2); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateBlockRegion() { - CAdGame *AdGame = (CAdGame *)Game; - if (AdGame->_scene) { - if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); - - if (_wptGroup && _currentWptGroup) - _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdInventory *CAdObject::GetInventory() { - if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); - } - return _inventory; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::AfterMove() { - CAdRegion *NewRegions[MAX_NUM_REGIONS]; - - ((CAdGame *)Game)->_scene->GetRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (!NewRegions[i]) break; - bool RegFound = false; - for (int j = 0; j < MAX_NUM_REGIONS; j++) { - if (_currentRegions[j] == NewRegions[i]) { - _currentRegions[j] = NULL; - RegFound = true; - break; - } - } - if (!RegFound) NewRegions[i]->ApplyEvent("ActorEntry"); - } - - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (_currentRegions[i] && Game->ValidObject(_currentRegions[i])) { - _currentRegions[i]->ApplyEvent("ActorLeave"); - } - _currentRegions[i] = NewRegions[i]; - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::InvalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { - if (_zoomable) { - if (_scaleX >= 0 || _scaleY >= 0) { - *ScaleX = _scaleX < 0 ? 100 : _scaleX; - *ScaleY = _scaleY < 0 ? 100 : _scaleY; - } else if (_scale >= 0) *ScaleX = *ScaleY = _scale; - else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) + _relativeScale; - } else { - *ScaleX = *ScaleY = 100; - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateSpriteAttachments() { - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - _attachmentsPre[i]->Update(); - } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - _attachmentsPost[i]->Update(); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { - if (PreDisplay) { - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - DisplaySpriteAttachment(_attachmentsPre[i]); - } - } else { - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - DisplaySpriteAttachment(_attachmentsPost[i]); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { - if (!Attachment->_active) return S_OK; - - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); - - int OrigX = Attachment->_posX; - int OrigY = Attachment->_posY; - - // inherit position from owner - Attachment->_posX = this->_posX + Attachment->_posX * ScaleX / 100.0f; - Attachment->_posY = this->_posY + Attachment->_posY * ScaleY / 100.0f; - - // inherit other props - Attachment->_alphaColor = this->_alphaColor; - Attachment->_blendMode = this->_blendMode; - - Attachment->_scale = this->_scale; - Attachment->_relativeScale = this->_relativeScale; - Attachment->_scaleX = this->_scaleX; - Attachment->_scaleY = this->_scaleY; - - Attachment->_rotate = this->_rotate; - Attachment->_relativeRotate = this->_relativeRotate; - Attachment->_rotateValid = this->_rotateValid; - - Attachment->_registerAlias = this; - Attachment->_registrable = this->_registrable; - - HRESULT ret = Attachment->Display(); - - Attachment->_posX = OrigX; - Attachment->_posY = OrigY; - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { - _partFollowParent = FollowParent; - _partOffsetX = OffsetX; - _partOffsetY = OffsetY; - - if (!_partEmitter) { - _partEmitter = new CPartEmitter(Game, this); - if (_partEmitter) { - Game->RegisterObject(_partEmitter); - } - } - UpdatePartEmitter(); - return _partEmitter; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdatePartEmitter() { - if (!_partEmitter) return E_FAIL; - - if (_partFollowParent) { - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); - - _partEmitter->_posX = _posX + (ScaleX / 100.0f) * _partOffsetX; - _partEmitter->_posY = _posY + (ScaleY / 100.0f) * _partOffsetY; - } - return _partEmitter->Update(); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdObject.h b/engines/wintermute/AdObject.h deleted file mode 100644 index 488cf6807f..0000000000 --- a/engines/wintermute/AdObject.h +++ /dev/null @@ -1,123 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADOBJECT_H -#define WINTERMUTE_ADOBJECT_H - -#include "AdTypes.h" -#include "PartEmitter.h" - -namespace WinterMute { - -class CAdWaypointGroup; -class CAdRegion; -class CAdSentence; -class CBFont; -class CBRegion; -class CAdInventory; - -#define MAX_NUM_REGIONS 10 - -class CAdObject : public CBObject { -public: - CPartEmitter *_partEmitter; - virtual CPartEmitter *CreateParticleEmitter(bool FollowParent = false, int OffsetX = 0, int OffsetY = 0); - virtual HRESULT UpdatePartEmitter(); - bool _partFollowParent; - int _partOffsetX; - int _partOffsetY; - - HRESULT InvalidateCurrRegions(); - bool _subtitlesModRelative; - bool _subtitlesModXCenter; - int _subtitlesModX; - int _subtitlesModY; - int _subtitlesWidth; - CAdRegion *_stickRegion; - bool _sceneIndependent; - bool _ignoreItems; - HRESULT UpdateBlockRegion(); - bool _forcedTalkAnimUsed; - char *_forcedTalkAnimName; - virtual bool GetExtendedFlag(const char *FlagName); - virtual HRESULT ResetSoundPan(); - virtual HRESULT UpdateSounds(); - HRESULT Reset(); - DECLARE_PERSISTENT(CAdObject, CBObject) - virtual void Talk(const char *Text, const char *Sound = NULL, uint32 Duration = 0, const char *Stances = NULL, TTextAlign Align = TAL_CENTER); - virtual int GetHeight(); - CAdSentence *_sentence; - HRESULT SetFont(const char *Filename); - virtual HRESULT Update(); - virtual HRESULT Display(); - bool _drawn; - bool _active; - virtual HRESULT PlayAnim(const char *Filename); - CBSprite *_animSprite; - CBSprite *_currentSprite; - TObjectState _state; - TObjectState _nextState; - TObjectType _type; - CAdObject(CBGame *inGame); - virtual ~CAdObject(); - CBFont *_font; - CBSprite *_tempSprite2; - CBRegion *_blockRegion; - CAdWaypointGroup *_wptGroup; - CBRegion *_currentBlockRegion; - CAdWaypointGroup *_currentWptGroup; - CAdInventory *GetInventory(); - - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - virtual HRESULT AfterMove(); - CAdRegion *_currentRegions[MAX_NUM_REGIONS]; - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - - CBArray _attachmentsPre; - CBArray _attachmentsPost; - - HRESULT UpdateSpriteAttachments(); - HRESULT DisplaySpriteAttachments(bool PreDisplay); - CAdObject *_registerAlias; -private: - HRESULT DisplaySpriteAttachment(CAdObject *Attachment); - CAdInventory *_inventory; - -protected: - HRESULT GetScale(float *ScaleX, float *ScaleY); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdPath.cpp b/engines/wintermute/AdPath.cpp deleted file mode 100644 index d9702005c0..0000000000 --- a/engines/wintermute/AdPath.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdPath.h" -#include "BPoint.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPath, false) - -////////////////////////////////////////////////////////////////////////// -CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPath::~CAdPath() { - Reset(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::Reset() { - for (int i = 0; i < _points.GetSize(); i++) - delete _points[i]; - - _points.RemoveAll(); - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetFirst() { - if (_points.GetSize() > 0) { - _currIndex = 0; - return _points[_currIndex]; - } else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetNext() { - _currIndex++; - if (_currIndex < _points.GetSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetCurrent() { - if (_currIndex >= 0 && _currIndex < _points.GetSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::AddPoint(CBPoint *point) { - _points.Add(point); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPath::SetReady(bool ready) { - bool orig = _ready; - _ready = ready; - - return orig; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdPath::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_currIndex)); - _points.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_ready)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdPath.h b/engines/wintermute/AdPath.h deleted file mode 100644 index efc7ffa265..0000000000 --- a/engines/wintermute/AdPath.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATH_H -#define WINTERMUTE_ADPATH_H - -#include "persistent.h" -#include "coll_templ.h" -#include "BBase.h" - -namespace WinterMute { -class CBPoint; -class CAdPath : public CBBase { -public: - DECLARE_PERSISTENT(CAdPath, CBBase) - CBPoint *GetCurrent(); - bool SetReady(bool ready = true); - void AddPoint(CBPoint *point); - CBPoint *GetNext(); - CBPoint *GetFirst(); - void Reset(); - CAdPath(CBGame *inGame); - virtual ~CAdPath(); - CBArray _points; - int _currIndex; - bool _ready; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdPathPoint.cpp b/engines/wintermute/AdPathPoint.cpp deleted file mode 100644 index 6de03cc5c2..0000000000 --- a/engines/wintermute/AdPathPoint.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "AdPathPoint.h" -#include "BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPathPoint, false) - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint() { - x = y = 0; - _distance = 0; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { - x = initX; - y = initY; - _distance = initDistance; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::~CAdPathPoint() { - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdPathPoint::Persist(CBPersistMgr *PersistMgr) { - - CBPoint::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_distance)); - PersistMgr->Transfer(TMEMBER(_marked)); - PersistMgr->Transfer(TMEMBER(_origin)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdPathPoint.h b/engines/wintermute/AdPathPoint.h deleted file mode 100644 index 86edade9d7..0000000000 --- a/engines/wintermute/AdPathPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATHPOINT_H -#define WINTERMUTE_ADPATHPOINT_H - -#include "persistent.h" -#include "BPoint.h" - -namespace WinterMute { - -class CAdPathPoint : public CBPoint { -public: - DECLARE_PERSISTENT(CAdPathPoint, CBPoint) - CAdPathPoint(int initX, int initY, int initDistance); - CAdPathPoint(); - virtual ~CAdPathPoint(); - CAdPathPoint *_origin; - bool _marked; - int _distance; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdRegion.cpp b/engines/wintermute/AdRegion.cpp deleted file mode 100644 index d928689cda..0000000000 --- a/engines/wintermute/AdRegion.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdRegion.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "BGame.h" -#include "BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRegion, false) - -////////////////////////////////////////////////////////////////////////// -CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { - _blocked = false; - _decoration = false; - _zoom = 0; - _alpha = 0xFFFFFFFF; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRegion::~CAdRegion() { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(ZOOM) -TOKEN_DEF(SCALE) -TOKEN_DEF(BLOCKED) -TOKEN_DEF(DECORATION) -TOKEN_DEF(POINT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(ZOOM) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(BLOCKED) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(POINT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { - Game->LOG(0, "'REGION' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - int i; - - for (i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); - - int ar = 255, ag = 255, ab = 255, alpha = 255; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); - break; - - case TOKEN_BLOCKED: - parser.ScanStr((char *)params, "%b", &_blocked); - break; - - case TOKEN_DECORATION: - parser.ScanStr((char *)params, "%b", &_decoration); - break; - - case TOKEN_ZOOM: - case TOKEN_SCALE: { - int i; - parser.ScanStr((char *)params, "%d", &i); - _zoom = (float)i; - } - break; - - case TOKEN_POINT: { - int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); - } - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in REGION definition"); - return E_FAIL; - } - - CreateRegion(); - - _alpha = DRGBA(ar, ag, ab, alpha); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - /* - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "SkipTo")==0){ - Stack->CorrectParams(2); - _posX = Stack->Pop()->GetInt(); - _posY = Stack->Pop()->GetInt(); - Stack->PushNULL(); - - return S_OK; - } - - else*/ return CBRegion::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("ad region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Blocked") == 0) { - _scValue->SetBool(_blocked); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { - _scValue->SetBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { - _scValue->SetFloat(_zoom); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { - _scValue->SetInt((int)_alpha); - return _scValue; - } - - else return CBRegion::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Blocked") == 0) { - _blocked = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { - _decoration = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { - _zoom = Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { - _alpha = (uint32)Value->GetInt(); - return S_OK; - } - - else return CBRegion::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdRegion::ScToString() { - return "[ad region]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "REGION {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - int i; - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - - for (i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::Persist(CBPersistMgr *PersistMgr) { - CBRegion::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_alpha)); - PersistMgr->Transfer(TMEMBER(_blocked)); - PersistMgr->Transfer(TMEMBER(_decoration)); - PersistMgr->Transfer(TMEMBER(_zoom)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdRegion.h b/engines/wintermute/AdRegion.h deleted file mode 100644 index 7c982ca4e1..0000000000 --- a/engines/wintermute/AdRegion.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADREGION_H -#define WINTERMUTE_ADREGION_H - -#include "BRegion.h" - -namespace WinterMute { - -class CAdRegion : public CBRegion { -public: - DECLARE_PERSISTENT(CAdRegion, CBRegion) - uint32 _alpha; - float _zoom; - bool _blocked; - bool _decoration; - CAdRegion(CBGame *inGame); - virtual ~CAdRegion(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdResponse.cpp b/engines/wintermute/AdResponse.cpp deleted file mode 100644 index 9c76c0f4cc..0000000000 --- a/engines/wintermute/AdResponse.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdResponse.h" -#include "BGame.h" -#include "BFontStorage.h" -#include "BSprite.h" -#include "utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponse, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { - _text = NULL; - _textOrig = NULL; - _icon = _iconHover = _iconPressed = NULL; - _font = NULL; - _iD = 0; - _responseType = RESPONSE_ALWAYS; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponse::~CAdResponse() { - delete[] _text; - delete[] _textOrig; - delete _icon; - delete _iconHover; - delete _iconPressed; - _text = NULL; - _textOrig = NULL; - _icon = NULL; - _iconHover = NULL; - _iconPressed = NULL; - if (_font) Game->_fontStorage->RemoveFont(_font); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponse::SetText(const char *Text) { - CBUtils::SetString(&_text, Text); - CBUtils::SetString(&_textOrig, Text); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIcon(const char *Filename) { - delete _icon; - _icon = new CBSprite(Game); - if (!_icon || FAILED(_icon->LoadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); - delete _icon; - _icon = NULL; - return E_FAIL; - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetFont(const char *Filename) { - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont(Filename); - if (!_font) { - Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", Filename); - return E_FAIL; - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconHover(const char *Filename) { - delete _iconHover; - _iconHover = new CBSprite(Game); - if (!_iconHover || FAILED(_iconHover->LoadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); - delete _iconHover; - _iconHover = NULL; - return E_FAIL; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconPressed(const char *Filename) { - delete _iconPressed; - _iconPressed = new CBSprite(Game); - if (!_iconPressed || FAILED(_iconPressed->LoadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); - delete _iconPressed; - _iconPressed = NULL; - return E_FAIL; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_icon)); - PersistMgr->Transfer(TMEMBER(_iconHover)); - PersistMgr->Transfer(TMEMBER(_iconPressed)); - PersistMgr->Transfer(TMEMBER(_iD)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER(_textOrig)); - PersistMgr->Transfer(TMEMBER_INT(_responseType)); - PersistMgr->Transfer(TMEMBER(_font)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponse.h b/engines/wintermute/AdResponse.h deleted file mode 100644 index 09608c913e..0000000000 --- a/engines/wintermute/AdResponse.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSE_H -#define WINTERMUTE_ADRESPONSE_H - - -#include "BObject.h" -#include "AdTypes.h" - -namespace WinterMute { -class CBFont; -class CAdResponse : public CBObject { -public: - DECLARE_PERSISTENT(CAdResponse, CBObject) - HRESULT SetIcon(const char *Filename); - HRESULT SetFont(const char *Filename); - HRESULT SetIconHover(const char *Filename); - HRESULT SetIconPressed(const char *Filename); - void SetText(const char *Text); - int _iD; - CBSprite *_icon; - CBSprite *_iconHover; - CBSprite *_iconPressed; - CBFont *_font; - char *_text; - char *_textOrig; - CAdResponse(CBGame *inGame); - virtual ~CAdResponse(); - TResponseType _responseType; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdResponseBox.cpp b/engines/wintermute/AdResponseBox.cpp deleted file mode 100644 index 895ecd9bef..0000000000 --- a/engines/wintermute/AdResponseBox.cpp +++ /dev/null @@ -1,645 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdGame.h" -#include "AdResponseBox.h" -#include "BParser.h" -#include "BSurfaceStorage.h" -#include "UIButton.h" -#include "UIWindow.h" -#include "BDynBuffer.h" -#include "BFontStorage.h" -#include "BFont.h" -#include "AdResponse.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "utils.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { - _font = _fontHover = NULL; - - _window = NULL; - _shieldWindow = new CUIWindow(Game); - - _horizontal = false; - CBPlatform::SetRectEmpty(&_responseArea); - _scrollOffset = 0; - _spacing = 0; - - _waitingScript = NULL; - _lastResponseText = NULL; - _lastResponseTextOrig = NULL; - - _verticalAlign = VAL_BOTTOM; - _align = TAL_LEFT; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::~CAdResponseBox() { - - delete _window; - _window = NULL; - delete _shieldWindow; - _shieldWindow = NULL; - delete[] _lastResponseText; - _lastResponseText = NULL; - delete[] _lastResponseTextOrig; - _lastResponseTextOrig = NULL; - - if (_font) Game->_fontStorage->RemoveFont(_font); - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - - ClearResponses(); - ClearButtons(); - - _waitingScript = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::ClearResponses() { - for (int i = 0; i < _responses.GetSize(); i++) { - delete _responses[i]; - } - _responses.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::ClearButtons() { - for (int i = 0; i < _respButtons.GetSize(); i++) { - delete _respButtons[i]; - } - _respButtons.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::InvalidateButtons() { - for (int i = 0; i < _respButtons.GetSize(); i++) { - _respButtons[i]->_image = NULL; - _respButtons[i]->_cursor = NULL; - _respButtons[i]->_font = NULL; - _respButtons[i]->_fontHover = NULL; - _respButtons[i]->_fontPress = NULL; - _respButtons[i]->SetText(""); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::CreateButtons() { - ClearButtons(); - - _scrollOffset = 0; - for (int i = 0; i < _responses.GetSize(); i++) { - CUIButton *btn = new CUIButton(Game); - if (btn) { - btn->_parent = _window; - btn->_sharedFonts = btn->_sharedImages = true; - btn->_sharedCursors = true; - // iconic - if (_responses[i]->_icon) { - btn->_image = _responses[i]->_icon; - if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; - if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; - - btn->SetCaption(_responses[i]->_text); - if (_cursor) btn->_cursor = _cursor; - else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor; - } - // textual - else { - btn->SetText(_responses[i]->_text); - btn->_font = (_font == NULL) ? Game->_systemFont : _font; - btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover; - btn->_fontPress = btn->_fontHover; - btn->_align = _align; - - if (Game->_touchInterface) - btn->_fontHover = btn->_font; - - - if (_responses[i]->_font) btn->_font = _responses[i]->_font; - - btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) btn->_width = Game->_renderer->_width; - } - btn->SetName("response"); - btn->CorrectSize(); - - // make the responses touchable - if (Game->_touchInterface) - btn->_height = MAX(btn->_height, 50); - - //btn->SetListener(this, btn, _responses[i]->_iD); - btn->SetListener(this, btn, i); - btn->_visible = false; - _respButtons.Add(btn); - - if (_responseArea.bottom - _responseArea.top < btn->_height) { - Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); - _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); - } - } - } - _ready = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT) -TOKEN_DEF(AREA) -TOKEN_DEF(HORIZONTAL) -TOKEN_DEF(SPACING) -TOKEN_DEF(WINDOW) -TOKEN_DEF(CURSOR) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT) - TOKEN_TABLE(AREA) - TOKEN_TABLE(HORIZONTAL) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { - Game->LOG(0, "'RESPONSE_BOX' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(Game); - if (!_window || FAILED(_window->LoadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else if (_shieldWindow) _shieldWindow->_parent = _window; - break; - - case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - _fontHover = Game->_fontStorage->AddFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); - break; - - case TOKEN_HORIZONTAL: - parser.ScanStr((char *)params, "%b", &_horizontal); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_LEFT; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; - else _verticalAlign = VAL_BOTTOM; - break; - - case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in RESPONSE_BOX definition"); - return E_FAIL; - } - - if (_window) { - for (int i = 0; i < _window->_widgets.GetSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); - - switch (_align) { - case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CAdResponseBox::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - } - - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // window - if (_window) _window->SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Display() { - RECT rect = _responseArea; - if (_window) { - CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); - //_window->Display(); - } - - int xxx, yyy, i; - - xxx = rect.left; - yyy = rect.top; - - // shift down if needed - if (!_horizontal) { - int total_height = 0; - for (i = 0; i < _respButtons.GetSize(); i++) total_height += (_respButtons[i]->_height + _spacing); - total_height -= _spacing; - - switch (_verticalAlign) { - case VAL_BOTTOM: - if (yyy + total_height < rect.bottom) - yyy = rect.bottom - total_height; - break; - - case VAL_CENTER: - if (yyy + total_height < rect.bottom) - yyy += ((rect.bottom - rect.top) - total_height) / 2; - break; - - case VAL_TOP: - // do nothing - break; - } - } - - // prepare response buttons - bool scroll_needed = false; - for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { - if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) - || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { - - scroll_needed = true; - _respButtons[i]->_visible = false; - break; - } - - _respButtons[i]->_visible = true; - _respButtons[i]->_posX = xxx; - _respButtons[i]->_posY = yyy; - - if (_horizontal) { - xxx += (_respButtons[i]->_width + _spacing); - } else { - yyy += (_respButtons[i]->_height + _spacing); - } - } - - // show appropriate scroll buttons - if (_window) { - _window->ShowWidget("prev", _scrollOffset > 0); - _window->ShowWidget("next", scroll_needed); - } - - // go exclusive - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; - - _shieldWindow->Display(); - } - - // display window - if (_window) _window->Display(); - - - // display response buttons - for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { - _respButtons[i]->Display(); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset--; - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset++; - } else if (scumm_stricmp(obj->_name, "response") == 0) { - if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD); - HandleResponse(_responses[param2]); - _waitingScript = NULL; - Game->_state = GAME_RUNNING; - ((CAdGame *)Game)->_stateEx = GAME_NORMAL; - _ready = true; - InvalidateButtons(); - ClearResponses(); - } else return CBObject::Listen(param1, param2); - break; - default: - error("AdResponseBox::Listen - Unhandled enum"); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_fontHover)); - PersistMgr->Transfer(TMEMBER(_horizontal)); - PersistMgr->Transfer(TMEMBER(_lastResponseText)); - PersistMgr->Transfer(TMEMBER(_lastResponseTextOrig)); - _respButtons.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_responseArea)); - _responses.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER(_spacing)); - PersistMgr->Transfer(TMEMBER(_waitingScript)); - PersistMgr->Transfer(TMEMBER(_window)); - - PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); - PersistMgr->Transfer(TMEMBER_INT(_align)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::WeedResponses() { - CAdGame *AdGame = (CAdGame *)Game; - - for (int i = 0; i < _responses.GetSize(); i++) { - switch (_responses[i]->_responseType) { - case RESPONSE_ONCE: - if (AdGame->BranchResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.RemoveAt(i); - i--; - } - break; - - case RESPONSE_ONCE_GAME: - if (AdGame->GameResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.RemoveAt(i); - i--; - } - break; - default: - error("CAdResponseBox::WeedResponses - Unhandled enum"); - break; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::SetLastResponseText(const char *Text, const char *TextOrig) { - CBUtils::SetString(&_lastResponseText, Text); - CBUtils::SetString(&_lastResponseTextOrig, TextOrig); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { - SetLastResponseText(Response->_text, Response->_textOrig); - - CAdGame *AdGame = (CAdGame *)Game; - - switch (Response->_responseType) { - case RESPONSE_ONCE: - AdGame->AddBranchResponse(Response->_iD); - break; - - case RESPONSE_ONCE_GAME: - AdGame->AddGameResponse(Response->_iD); - break; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::GetNextAccessObject(CBObject *CurrObject) { - CBArray Objects; - GetObjects(Objects, true); - - if (Objects.GetSize() == 0) return NULL; - else { - if (CurrObject != NULL) { - for (int i = 0; i < Objects.GetSize(); i++) { - if (Objects[i] == CurrObject) { - if (i < Objects.GetSize() - 1) return Objects[i + 1]; - else break; - } - } - } - return Objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { - CBArray Objects; - GetObjects(Objects, true); - - if (Objects.GetSize() == 0) return NULL; - else { - if (CurrObject != NULL) { - for (int i = Objects.GetSize() - 1; i >= 0; i--) { - if (Objects[i] == CurrObject) { - if (i > 0) return Objects[i - 1]; - else break; - } - } - } - return Objects[Objects.GetSize() - 1]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::GetObjects(CBArray &Objects, bool InteractiveOnly) { - for (int i = 0; i < _respButtons.GetSize(); i++) { - Objects.Add(_respButtons[i]); - } - if (_window) _window->GetWindowObjects(Objects, InteractiveOnly); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponseBox.h b/engines/wintermute/AdResponseBox.h deleted file mode 100644 index edc763a19b..0000000000 --- a/engines/wintermute/AdResponseBox.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSEBOX_H -#define WINTERMUTE_ADRESPONSEBOX_H - - -#include "BObject.h" - -namespace WinterMute { - -class CUIButton; -class CUIWindow; -class CUIObject; -class CAdResponse; -class CAdResponseBox : public CBObject { -public: - CBObject *GetNextAccessObject(CBObject *CurrObject); - CBObject *GetPrevAccessObject(CBObject *CurrObject); - HRESULT GetObjects(CBArray &Objects, bool InteractiveOnly); - - HRESULT HandleResponse(CAdResponse *Response); - void SetLastResponseText(const char *Text, const char *TextOrig); - char *_lastResponseText; - char *_lastResponseTextOrig; - DECLARE_PERSISTENT(CAdResponseBox, CBObject) - CScScript *_waitingScript; - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - typedef enum { - EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE - } TResponseEvent; - - HRESULT WeedResponses(); - HRESULT Display(); - int _spacing; - int _scrollOffset; - CBFont *_fontHover; - CBFont *_font; - HRESULT CreateButtons(); - HRESULT InvalidateButtons(); - void ClearButtons(); - void ClearResponses(); - CAdResponseBox(CBGame *inGame); - virtual ~CAdResponseBox(); - CBArray _responses; - CBArray _respButtons; - CUIWindow *_window; - CUIWindow *_shieldWindow; - bool _horizontal; - RECT _responseArea; - int _verticalAlign; - TTextAlign _align; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdResponseContext.cpp b/engines/wintermute/AdResponseContext.cpp deleted file mode 100644 index b29f9a42ba..0000000000 --- a/engines/wintermute/AdResponseContext.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdResponseContext.h" -#include "BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseContext, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { - _iD = 0; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::~CAdResponseContext() { - delete[] _context; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_context)); - PersistMgr->Transfer(TMEMBER(_iD)); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::SetContext(const char *Context) { - delete[] _context; - _context = NULL; - if (Context) { - _context = new char [strlen(Context) + 1]; - if (_context) strcpy(_context, Context); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdResponseContext.h b/engines/wintermute/AdResponseContext.h deleted file mode 100644 index 7bb91943e0..0000000000 --- a/engines/wintermute/AdResponseContext.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSECONTEXT_H -#define WINTERMUTE_ADRESPONSECONTEXT_H - -#include "persistent.h" -#include "BBase.h" - -namespace WinterMute { - -class CAdResponseContext : public CBBase { -public: - void SetContext(const char *Context); - int _iD; - char *_context; - DECLARE_PERSISTENT(CAdResponseContext, CBBase) - CAdResponseContext(CBGame *inGame); - virtual ~CAdResponseContext(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdRotLevel.cpp b/engines/wintermute/AdRotLevel.cpp deleted file mode 100644 index 7645f19740..0000000000 --- a/engines/wintermute/AdRotLevel.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdRotLevel.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "BGame.h" -#include "BSprite.h" -#include "BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRotLevel, false) - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { - _posX = 0; - _rotation = 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::~CAdRotLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(X) -TOKEN_DEF(ROTATION) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(X) - TOKEN_TABLE(ROTATION) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { - Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_ROTATION: { - int i; - parser.ScanStr((char *)params, "%d", &i); - _rotation = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ROTATION_LEVEL definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::SaveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_rotation)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdRotLevel.h b/engines/wintermute/AdRotLevel.h deleted file mode 100644 index a38027b281..0000000000 --- a/engines/wintermute/AdRotLevel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADROTLEVEL_H -#define WINTERMUTE_ADROTLEVEL_H - -#include "BObject.h" - -namespace WinterMute { - -class CAdRotLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdRotLevel, CBObject) - CAdRotLevel(CBGame *inGame); - virtual ~CAdRotLevel(); - float _rotation; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdScaleLevel.cpp b/engines/wintermute/AdScaleLevel.cpp deleted file mode 100644 index cd36fb65b8..0000000000 --- a/engines/wintermute/AdScaleLevel.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdScaleLevel.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "BGame.h" -#include "BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScaleLevel, false) - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { - _posY = 0; - _scale = 100; -} - - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::~CAdScaleLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(Y) -TOKEN_DEF(SCALE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(Y) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { - Game->LOG(0, "'SCALE_LEVEL' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SCALE: { - int i; - parser.ScanStr((char *)params, "%d", &i); - _scale = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SCALE_LEVEL definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::SaveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_scale)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdScaleLevel.h b/engines/wintermute/AdScaleLevel.h deleted file mode 100644 index 6f1776ea56..0000000000 --- a/engines/wintermute/AdScaleLevel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCALELEVEL_H -#define WINTERMUTE_ADSCALELEVEL_H - - -#include "BObject.h" - -namespace WinterMute { - -class CAdScaleLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdScaleLevel, CBObject) - float _scale; - CAdScaleLevel(CBGame *inGame); - virtual ~CAdScaleLevel(); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdScene.cpp b/engines/wintermute/AdScene.cpp deleted file mode 100644 index c5e3d63db0..0000000000 --- a/engines/wintermute/AdScene.cpp +++ /dev/null @@ -1,2763 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "AdScene.h" -#include "AdActor.h" -#include "AdEntity.h" -#include "AdGame.h" -#include "AdLayer.h" -#include "AdNodeState.h" -#include "AdObject.h" -#include "AdPath.h" -#include "AdPathPoint.h" -#include "AdRotLevel.h" -#include "AdScaleLevel.h" -#include "AdSceneNode.h" -#include "AdSceneState.h" -#include "AdSentence.h" -#include "AdWaypointGroup.h" -#include "BDynBuffer.h" -#include "BFileManager.h" -#include "BFont.h" -#include "BGame.h" -#include "BObject.h" -#include "BParser.h" -#include "BPoint.h" -#include "BRegion.h" -#include "BScriptable.h" -#include "BSprite.h" -#include "BViewport.h" -#include "PlatformSDL.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "UIWindow.h" -#include "utils.h" -#include -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScene, false) - -////////////////////////////////////////////////////////////////////////// -CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - _pFTarget = new CBPoint; - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdScene::~CAdScene() { - Cleanup(); - Game->UnregisterObject(_fader); - delete _pFTarget; - _pFTarget = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::SetDefaults() { - _initialized = false; - _pFReady = true; - _pFTargetPath = NULL; - _pFRequester = NULL; - _mainLayer = NULL; - - _pFPointsNum = 0; - _persistentState = false; - _persistentStateSprites = true; - - _autoScroll = true; - _offsetLeft = _offsetTop = 0; - _targetOffsetLeft = _targetOffsetTop = 0; - - _lastTimeH = _lastTimeV = 0; - _scrollTimeH = _scrollTimeV = 10; - _scrollPixelsH = _scrollPixelsV = 1; - - _pFMaxTime = 15; - - _paralaxScrolling = true; - - // editor settings - _editorMarginH = _editorMarginV = 100; - - _editorColFrame = 0xE0888888; - _editorColEntity = 0xFF008000; - _editorColRegion = 0xFF0000FF; - _editorColBlocked = 0xFF800080; - _editorColWaypoints = 0xFF0000FF; - _editorColEntitySel = 0xFFFF0000; - _editorColRegionSel = 0xFFFF0000; - _editorColBlockedSel = 0xFFFF0000; - _editorColWaypointsSel = 0xFFFF0000; - _editorColScale = 0xFF00FF00; - _editorColDecor = 0xFF00FFFF; - _editorColDecorSel = 0xFFFF0000; - - _editorShowRegions = true; - _editorShowBlocked = true; - _editorShowDecor = true; - _editorShowEntities = true; - _editorShowScale = true; - - _shieldWindow = NULL; - - _fader = new CBFader(Game); - Game->RegisterObject(_fader); - - _viewport = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::Cleanup() { - CBObject::Cleanup(); - - _mainLayer = NULL; // reference only - - int i; - - delete _shieldWindow; - _shieldWindow = NULL; - - Game->UnregisterObject(_fader); - _fader = NULL; - - for (i = 0; i < _layers.GetSize(); i++) - Game->UnregisterObject(_layers[i]); - _layers.RemoveAll(); - - - for (i = 0; i < _waypointGroups.GetSize(); i++) - Game->UnregisterObject(_waypointGroups[i]); - _waypointGroups.RemoveAll(); - - for (i = 0; i < _scaleLevels.GetSize(); i++) - Game->UnregisterObject(_scaleLevels[i]); - _scaleLevels.RemoveAll(); - - for (i = 0; i < _rotLevels.GetSize(); i++) - Game->UnregisterObject(_rotLevels[i]); - _rotLevels.RemoveAll(); - - - for (i = 0; i < _pFPath.GetSize(); i++) - delete _pFPath[i]; - _pFPath.RemoveAll(); - _pFPointsNum = 0; - - for (i = 0; i < _objects.GetSize(); i++) - Game->UnregisterObject(_objects[i]); - _objects.RemoveAll(); - - delete _viewport; - _viewport = NULL; - - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { - if (!_pFReady) return false; - else { - _pFReady = false; - *_pFTarget = target; - _pFTargetPath = path; - _pFRequester = requester; - - _pFTargetPath->Reset(); - _pFTargetPath->SetReady(false); - - // prepare working path - int i; - PFPointsStart(); - - // first point - //_pFPath.Add(new CAdPathPoint(source.x, source.y, 0)); - - // if we're one pixel stuck, get unstuck - int StartX = source.x; - int StartY = source.y; - int BestDistance = 1000; - if (IsBlockedAt(StartX, StartY, true, requester)) { - int Tolerance = 2; - for (int xxx = StartX - Tolerance; xxx <= StartX + Tolerance; xxx++) { - for (int yyy = StartY - Tolerance; yyy <= StartY + Tolerance; yyy++) { - if (IsWalkableAt(xxx, yyy, true, requester)) { - int Distance = abs(xxx - source.x) + abs(yyy - source.y); - if (Distance < BestDistance) { - StartX = xxx; - StartY = yyy; - - BestDistance = Distance; - } - } - } - } - } - - PFPointsAdd(StartX, StartY, 0); - - //CorrectTargetPoint(&target.x, &target.y); - - // last point - //_pFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); - PFPointsAdd(target.x, target.y, INT_MAX); - - // active waypoints - for (i = 0; i < _waypointGroups.GetSize(); i++) { - if (_waypointGroups[i]->_active) { - PFAddWaypointGroup(_waypointGroups[i], requester); - } - } - - - // free waypoints - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { - PFAddWaypointGroup(_objects[i]->_currentWptGroup, requester); - } - } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != requester && AdGame->_objects[i]->_currentWptGroup) { - PFAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); - } - } - - return true; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { - if (!Wpt->_active) return; - - for (int i = 0; i < Wpt->_points.GetSize(); i++) { - if (IsBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; - - //_pFPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); - PFPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); - } -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::GetZoomAt(int X, int Y) { - float ret = 100; - - bool found = false; - if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_zoom != 0) { - ret = Node->_region->_zoom; - found = true; - break; - } - } - } - } - if (!found) ret = GetScaleAt(Y); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { - if (!Game->_dEBUG_DebugMode) ColorCheck = false; - - uint32 ret; - if (ColorCheck) ret = 0xFFFF0000; - else ret = 0xFFFFFFFF; - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && (ColorCheck || !Node->_region->_blocked) && Node->_region->PointInRegion(X, Y)) { - if (!Node->_region->_blocked) ret = Node->_region->_alpha; - break; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { - bool ret = true; - - - if (CheckFreeObjects) { - int i; - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; - } - } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { - if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - /* - if(Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) - { - ret = true; - break; - } - */ - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_blocked) { - ret = true; - break; - } else ret = false; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { - bool ret = false; - - - if (CheckFreeObjects) { - int i; - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; - } - } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { - if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_blocked) { - ret = false; - break; - } else ret = true; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { - double xStep, yStep, X, Y; - int xLength, yLength, xCount, yCount; - int X1, Y1, X2, Y2; - - X1 = p1.x; - Y1 = p1.y; - X2 = p2.x; - Y2 = p2.y; - - xLength = abs(X2 - X1); - yLength = abs(Y2 - Y1); - - if (xLength > yLength) { - if (X1 > X2) { - CBUtils::Swap(&X1, &X2); - CBUtils::Swap(&Y1, &Y2); - } - - yStep = (double)(Y2 - Y1) / (double)(X2 - X1); - Y = Y1; - - for (xCount = X1; xCount < X2; xCount++) { - if (IsBlockedAt(xCount, (int)Y, true, requester)) return -1; - Y += yStep; - } - } else { - if (Y1 > Y2) { - CBUtils::Swap(&X1, &X2); - CBUtils::Swap(&Y1, &Y2); - } - - xStep = (double)(X2 - X1) / (double)(Y2 - Y1); - X = X1; - - for (yCount = Y1; yCount < Y2; yCount++) { - if (IsBlockedAt((int)X, yCount, true, requester)) return -1; - X += xStep; - } - } - return MAX(xLength, yLength); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::PathFinderStep() { - int i; - // get lowest unmarked - int lowest_dist = INT_MAX; - CAdPathPoint *lowest_pt = NULL; - - for (i = 0; i < _pFPointsNum; i++) - if (!_pFPath[i]->_marked && _pFPath[i]->_distance < lowest_dist) { - lowest_dist = _pFPath[i]->_distance; - lowest_pt = _pFPath[i]; - } - - if (lowest_pt == NULL) { // no path -> terminate PathFinder - _pFReady = true; - _pFTargetPath->SetReady(true); - return; - } - - lowest_pt->_marked = true; - - // target point marked, generate path and terminate - if (lowest_pt->x == _pFTarget->x && lowest_pt->y == _pFTarget->y) { - while (lowest_pt != NULL) { - _pFTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); - lowest_pt = lowest_pt->_origin; - } - - _pFReady = true; - _pFTargetPath->SetReady(true); - return; - } - - // otherwise keep on searching - for (i = 0; i < _pFPointsNum; i++) - if (!_pFPath[i]->_marked) { - int j = GetPointsDist(*lowest_pt, *_pFPath[i], _pFRequester); - if (j != -1 && lowest_pt->_distance + j < _pFPath[i]->_distance) { - _pFPath[i]->_distance = lowest_pt->_distance + j; - _pFPath[i]->_origin = lowest_pt; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::InitLoop() { -#ifdef _DEBUGxxxx - int nu_steps = 0; - uint32 start = Game->_currentTime; - while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) { - PathFinderStep(); - nu_steps++; - } - if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pFMaxTime=%d", nu_steps, _pFReady ? "finished" : "not yet done", _pFMaxTime); -#else - uint32 start = Game->_currentTime; - while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) PathFinderStep(); -#endif - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - delete[] _filename; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCENE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(LAYER) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(CAMERA) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(EDITOR_MARGIN_H) -TOKEN_DEF(EDITOR_MARGIN_V) -TOKEN_DEF(EDITOR_COLOR_FRAME) -TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION_SEL) -TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) -TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION) -TOKEN_DEF(EDITOR_COLOR_DECORATION) -TOKEN_DEF(EDITOR_COLOR_BLOCKED) -TOKEN_DEF(EDITOR_COLOR_ENTITY) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) -TOKEN_DEF(EDITOR_COLOR_SCALE) -TOKEN_DEF(EDITOR_SHOW_REGIONS) -TOKEN_DEF(EDITOR_SHOW_BLOCKED) -TOKEN_DEF(EDITOR_SHOW_DECORATION) -TOKEN_DEF(EDITOR_SHOW_ENTITIES) -TOKEN_DEF(EDITOR_SHOW_SCALE) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(VIEWPORT) -TOKEN_DEF(PERSISTENT_STATE_SPRITES) -TOKEN_DEF(PERSISTENT_STATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCENE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(CAMERA) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(EDITOR_MARGIN_H) - TOKEN_TABLE(EDITOR_MARGIN_V) - TOKEN_TABLE(EDITOR_COLOR_FRAME) - TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) - TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION) - TOKEN_TABLE(EDITOR_COLOR_DECORATION) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED) - TOKEN_TABLE(EDITOR_COLOR_ENTITY) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) - TOKEN_TABLE(EDITOR_COLOR_SCALE) - TOKEN_TABLE(EDITOR_SHOW_REGIONS) - TOKEN_TABLE(EDITOR_SHOW_DECORATION) - TOKEN_TABLE(EDITOR_SHOW_BLOCKED) - TOKEN_TABLE(EDITOR_SHOW_ENTITIES) - TOKEN_TABLE(EDITOR_SHOW_SCALE) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(VIEWPORT) - TOKEN_TABLE(PERSISTENT_STATE_SPRITES) - TOKEN_TABLE(PERSISTENT_STATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - Cleanup(); - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCENE) { - Game->LOG(0, "'SCENE' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - int ar, ag, ab, aa; - char camera[MAX_PATH] = ""; - float WaypointHeight = -1.0f; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_LAYER: { - CAdLayer *layer = new CAdLayer(Game); - if (!layer || FAILED(layer->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete layer; - layer = NULL; - } else { - Game->RegisterObject(layer); - _layers.Add(layer); - if (layer->_main) { - _mainLayer = layer; - _width = layer->_width; - _height = layer->_height; - } - } - } - break; - - case TOKEN_WAYPOINTS: { - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - if (!wpt || FAILED(wpt->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete wpt; - wpt = NULL; - } else { - Game->RegisterObject(wpt); - _waypointGroups.Add(wpt); - } - } - break; - - case TOKEN_SCALE_LEVEL: { - CAdScaleLevel *sl = new CAdScaleLevel(Game); - if (!sl || FAILED(sl->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete sl; - sl = NULL; - } else { - Game->RegisterObject(sl); - _scaleLevels.Add(sl); - } - } - break; - - case TOKEN_ROTATION_LEVEL: { - CAdRotLevel *rl = new CAdRotLevel(Game); - if (!rl || FAILED(rl->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete rl; - rl = NULL; - } else { - Game->RegisterObject(rl); - _rotLevels.Add(rl); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(Game); - if (!entity || FAILED(entity->LoadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - entity = NULL; - } else { - AddObject(entity); - } - } - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CAMERA: - strcpy(camera, (char *)params); - break; - - case TOKEN_EDITOR_MARGIN_H: - parser.ScanStr((char *)params, "%d", &_editorMarginH); - break; - - case TOKEN_EDITOR_MARGIN_V: - parser.ScanStr((char *)params, "%d", &_editorMarginV); - break; - - case TOKEN_EDITOR_COLOR_FRAME: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColFrame = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntity = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntitySel = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegionSel = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecorSel = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlockedSel = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypointsSel = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegion = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecor = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlocked = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypoints = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_SCALE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColScale = DRGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_SHOW_REGIONS: - parser.ScanStr((char *)params, "%b", &_editorShowRegions); - break; - - case TOKEN_EDITOR_SHOW_BLOCKED: - parser.ScanStr((char *)params, "%b", &_editorShowBlocked); - break; - - case TOKEN_EDITOR_SHOW_DECORATION: - parser.ScanStr((char *)params, "%b", &_editorShowDecor); - break; - - case TOKEN_EDITOR_SHOW_ENTITIES: - parser.ScanStr((char *)params, "%b", &_editorShowEntities); - break; - - case TOKEN_EDITOR_SHOW_SCALE: - parser.ScanStr((char *)params, "%b", &_editorShowScale); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_VIEWPORT: { - RECT rc; - parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) _viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); - } - - case TOKEN_PERSISTENT_STATE: - parser.ScanStr((char *)params, "%b", &_persistentState); - break; - - case TOKEN_PERSISTENT_STATE_SPRITES: - parser.ScanStr((char *)params, "%b", &_persistentStateSprites); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SCENE definition"); - return E_FAIL; - } - - if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); - - - SortScaleLevels(); - SortRotLevels(); - - _initialized = true; - - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::TraverseNodes(bool Update) { - if (!_initialized) return S_OK; - - int j, k; - CAdGame *AdGame = (CAdGame *)Game; - - - ////////////////////////////////////////////////////////////////////////// - // prepare viewport - bool PopViewport = false; - if (_viewport && !Game->_editorMode) { - Game->PushViewport(_viewport); - PopViewport = true; - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - Game->PushViewport(AdGame->_sceneViewport); - PopViewport = true; - } - - - ////////////////////////////////////////////////////////////////////////// - // *** adjust scroll offset - if (Update) { - /* - if(_autoScroll && Game->_mainObject != NULL) - { - ScrollToObject(Game->_mainObject); - } - */ - - if (_autoScroll) { - // adjust horizontal scroll - if (Game->_timer - _lastTimeH >= _scrollTimeH) { - _lastTimeH = Game->_timer; - if (_offsetLeft < _targetOffsetLeft) { - _offsetLeft += _scrollPixelsH; - _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); - } else if (_offsetLeft > _targetOffsetLeft) { - _offsetLeft -= _scrollPixelsH; - _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); - } - } - - // adjust vertical scroll - if (Game->_timer - _lastTimeV >= _scrollTimeV) { - _lastTimeV = Game->_timer; - if (_offsetTop < _targetOffsetTop) { - _offsetTop += _scrollPixelsV; - _offsetTop = MIN(_offsetTop, _targetOffsetTop); - } else if (_offsetTop > _targetOffsetTop) { - _offsetTop -= _scrollPixelsV; - _offsetTop = MAX(_offsetTop, _targetOffsetTop); - } - } - - if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; - } else _ready = true; // not scrolling, i.e. always ready - } - - - - - ////////////////////////////////////////////////////////////////////////// - int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); - - int ViewportX, ViewportY; - GetViewportOffset(&ViewportX, &ViewportY); - - int ScrollableX = _width - ViewportWidth; - int ScrollableY = _height - ViewportHeight; - - double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)ScrollableX); - double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)ScrollableY); - - int OrigX, OrigY; - Game->GetOffset(&OrigX, &OrigY); - - - - ////////////////////////////////////////////////////////////////////////// - // *** display/update everything - Game->_renderer->Setup2D(); - - // for each layer - /* int MainOffsetX = 0; */ - /* int MainOffsetY = 0; */ - - for (j = 0; j < _layers.GetSize(); j++) { - if (!_layers[j]->_active) continue; - - // make layer exclusive - if (!Update) { - if (_layers[j]->_closeUp && !Game->_editorMode) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; - _shieldWindow->Display(); - } - } - } - - if (_paralaxScrolling) { - int OffsetX = (int)(WidthRatio * (_layers[j]->_width - ViewportWidth) - ViewportX); - int OffsetY = (int)(HeightRatio * (_layers[j]->_height - ViewportHeight) - ViewportY); - Game->SetOffset(OffsetX, OffsetY); - - Game->_offsetPercentX = (float)OffsetX / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; - Game->_offsetPercentY = (float)OffsetY / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; - - //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); - } else { - Game->SetOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); - - Game->_offsetPercentX = (float)(_offsetLeft - ViewportX) / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; - Game->_offsetPercentY = (float)(_offsetTop - ViewportY) / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; - } - - - // for each node - for (k = 0; k < _layers[j]->_nodes.GetSize(); k++) { - CAdSceneNode *Node = _layers[j]->_nodes[k]; - switch (Node->_type) { - case OBJECT_ENTITY: - if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { - Game->_renderer->Setup2D(); - - if (Update) Node->_entity->Update(); - else Node->_entity->Display(); - } - break; - - case OBJECT_REGION: { - if (Node->_region->_blocked) break; - if (Node->_region->_decoration) break; - - if (!Update) DisplayRegionContent(Node->_region); - } - break; - default: - error("AdScene::TraverseNodes - Unhandled enum"); - break; - } // switch - } // each node - - // display/update all objects which are off-regions - if (_layers[j]->_main) { - if (Update) { - UpdateFreeObjects(); - } else { - DisplayRegionContent(NULL); - } - } - } // each layer - - - // restore state - Game->SetOffset(OrigX, OrigY); - Game->_renderer->Setup2D(); - - // display/update fader - if (_fader) { - if (Update) _fader->Update(); - else _fader->Display(); - } - - if (PopViewport) Game->PopViewport(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Display() { - return TraverseNodes(false); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::UpdateFreeObjects() { - CAdGame *AdGame = (CAdGame *)Game; - int i; - - bool Is3DSet; - - // *** update all active objects - Is3DSet = false; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (!AdGame->_objects[i]->_active) continue; - - AdGame->_objects[i]->Update(); - AdGame->_objects[i]->_drawn = false; - } - - - for (i = 0; i < _objects.GetSize(); i++) { - if (!_objects[i]->_active) continue; - - _objects[i]->Update(); - _objects[i]->_drawn = false; - } - - - if (_autoScroll && Game->_mainObject != NULL) { - ScrollToObject(Game->_mainObject); - } - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { - CAdGame *AdGame = (CAdGame *)Game; - CBArray Objects; - CAdObject *Obj; - - int i; - - // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - Obj = AdGame->_objects[i]; - if (Obj->_active && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - Objects.Add(Obj); - } - } - - // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - Obj = _objects[i]; - if (Obj->_active && !Obj->_editorOnly && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - Objects.Add(Obj); - } - } - - // sort by _posY - qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); - - // display them - for (i = 0; i < Objects.GetSize(); i++) { - Obj = Objects[i]; - - if (Display3DOnly && !Obj->_is3D) continue; - - Game->_renderer->Setup2D(); - - if (Game->_editorMode || !Obj->_editorOnly) Obj->Display(); - Obj->_drawn = true; - } - - - // display design only objects - if (!Display3DOnly) { - if (Game->_editorMode && Region == NULL) { - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->Display(); - _objects[i]->_drawn = true; - } - } - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { - CAdObject *Object1 = *(CAdObject **)Obj1; - CAdObject *Object2 = *(CAdObject **)Obj2; - - if (Object1->_posY < Object2->_posY) return -1; - else if (Object1->_posY > Object2->_posY) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { - CAdGame *AdGame = (CAdGame *)Game; - CAdObject *obj; - int i; - - // display all objects in region sorted by _posY - do { - obj = NULL; - int minY = INT_MAX; - - // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && !AdGame->_objects[i]->_drawn && AdGame->_objects[i]->_posY < minY && (AdGame->_objects[i]->_stickRegion == Region || Region == NULL || (AdGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(AdGame->_objects[i]->_posX, AdGame->_objects[i]->_posY)))) { - obj = AdGame->_objects[i]; - minY = AdGame->_objects[i]->_posY; - } - } - - // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == Region || Region == NULL || (_objects[i]->_stickRegion == NULL && Region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { - obj = _objects[i]; - minY = _objects[i]->_posY; - } - } - - - if (obj != NULL) { - Game->_renderer->Setup2D(); - - if (Game->_editorMode || !obj->_editorOnly) obj->Display(); - obj->_drawn = true; - } - } while (obj != NULL); - - - // design only objects - if (Game->_editorMode && Region == NULL) { - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->Display(); - _objects[i]->_drawn = true; - } - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Update() { - return TraverseNodes(true); -} - -////////////////////////////////////////////////////////////////////////// -void CAdScene::ScrollTo(int OffsetX, int OffsetY) { - int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); - - int OrigOffsetLeft = _targetOffsetLeft; - int OrigOffsetTop = _targetOffsetTop; - - _targetOffsetLeft = MAX(0, OffsetX - ViewportWidth / 2); - _targetOffsetLeft = MIN(_targetOffsetLeft, _width - ViewportWidth); - - _targetOffsetTop = MAX(0, OffsetY - ViewportHeight / 2); - _targetOffsetTop = MIN(_targetOffsetTop, _height - ViewportHeight); - - - if (Game->_mainObject && Game->_mainObject->_is3D) { - if (abs(OrigOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = OrigOffsetLeft; - if (abs(OrigOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = OrigOffsetTop; - //_targetOffsetTop = 0; - } - - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::ScrollToObject(CBObject *Object) { - if (Object) ScrollTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::SkipToObject(CBObject *Object) { - if (Object) SkipTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::SkipTo(int OffsetX, int OffsetY) { - int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); - - _offsetLeft = MAX(0, OffsetX - ViewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); - - _offsetTop = MAX(0, OffsetY - ViewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - ViewportHeight); - - _targetOffsetLeft = _offsetLeft; - _targetOffsetTop = _offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LoadActor") == 0) { - Stack->CorrectParams(1); - CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { - AddObject(act); - Stack->PushNative(act, true); - } else { - delete act; - act = NULL; - Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadEntity") == 0) { - Stack->CorrectParams(1); - CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { - AddObject(ent); - Stack->PushNative(ent, true); - } else { - delete ent; - ent = NULL; - Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdEntity *Ent = new CAdEntity(Game); - AddObject(Ent); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); - Stack->PushNative(Ent, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "UnloadActor3D") == 0 || strcmp(Name, "DeleteEntity") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - CAdObject *obj = (CAdObject *)val->GetNative(); - RemoveObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SkipTo") == 0) { - Stack->CorrectParams(2); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - if (val1->IsNative()) { - SkipToObject((CBObject *)val1->GetNative()); - } else { - SkipTo(val1->GetInt(), val2->GetInt()); - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollTo / ScrollToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollTo") == 0 || strcmp(Name, "ScrollToAsync") == 0) { - Stack->CorrectParams(2); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - if (val1->IsNative()) { - ScrollToObject((CBObject *)val1->GetNative()); - } else { - ScrollTo(val1->GetInt(), val2->GetInt()); - } - if (strcmp(Name, "ScrollTo") == 0) Script->WaitForExclusive(this); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetLayer") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - if (val->IsInt()) { - int layer = val->GetInt(); - if (layer < 0 || layer >= _layers.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_layers[layer], true); - } else { - const char *LayerName = val->GetString(); - bool LayerFound = false; - for (int i = 0; i < _layers.GetSize(); i++) { - if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { - Stack->PushNative(_layers[i], true); - LayerFound = true; - break; - } - } - if (!LayerFound) Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaypointGroup - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaypointGroup") == 0) { - Stack->CorrectParams(1); - int group = Stack->Pop()->GetInt(); - if (group < 0 || group >= _waypointGroups.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_waypointGroups[group], true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNode") == 0) { - Stack->CorrectParams(1); - const char *Name = Stack->Pop()->GetString(); - - CBObject *node = GetNodeByName(Name); - if (node) Stack->PushNative((CBScriptable *)node, true); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFreeNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFreeNode") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdObject *Ret = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); - if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; - } else { - const char *Name = Val->GetString(); - for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, Name) == 0) { - Ret = _objects[i]; - break; - } - } - } - if (Ret) Stack->PushNative(Ret, true); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRegionAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRegionAt") == 0) { - Stack->CorrectParams(3); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); - - bool IncludeDecors = false; - if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_decoration && !IncludeDecors) continue; - - Stack->PushNative(Node->_region, true); - return S_OK; - } - } - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsBlockedAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsBlockedAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - Stack->PushBool(IsBlockedAt(X, Y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalkableAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsWalkableAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - Stack->PushBool(IsWalkableAt(X, Y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetScaleAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetScaleAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - Stack->PushFloat(GetZoomAt(X, Y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRotationAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRotationAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - Stack->PushFloat(GetRotationAt(X, Y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScrolling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsScrolling") == 0) { - Stack->CorrectParams(0); - bool Ret = false; - if (_autoScroll) { - if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; - } - - Stack->PushBool(Ret); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); - - _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(_fader); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); - - _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(_fader); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFadeColor") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_fader->GetCurrentColor()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsPointInViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsPointInViewport") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - Stack->PushBool(PointInViewport(X, Y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetViewport") == 0) { - Stack->CorrectParams(4); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - int Width = Stack->Pop()->GetInt(); - int Height = Stack->Pop()->GetInt(); - - if (Width <= 0) Width = Game->_renderer->_width; - if (Height <= 0) Height = Game->_renderer->_height; - - if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) _viewport->SetRect(X, Y, X + Width, Y + Height); - - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddLayer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->SetName(Val->GetString()); - if (_mainLayer) { - Layer->_width = _mainLayer->_width; - Layer->_height = _mainLayer->_height; - } - _layers.Add(Layer); - Game->RegisterObject(Layer); - - Stack->PushNative(Layer, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertLayer") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); - - CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->SetName(Val->GetString()); - if (_mainLayer) { - Layer->_width = _mainLayer->_width; - Layer->_height = _mainLayer->_height; - } - if (Index < 0) Index = 0; - if (Index <= _layers.GetSize() - 1) _layers.InsertAt(Index, Layer); - else _layers.Add(Layer); - - Game->RegisterObject(Layer); - - Stack->PushNative(Layer, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteLayer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CAdLayer *ToDelete = NULL; - if (Val->IsNative()) { - CBScriptable *Temp = Val->GetNative(); - for (int i = 0; i < _layers.GetSize(); i++) { - if (_layers[i] == Temp) { - ToDelete = _layers[i]; - break; - } - } - } else { - int Index = Val->GetInt(); - if (Index >= 0 && Index < _layers.GetSize()) { - ToDelete = _layers[Index]; - } - } - if (ToDelete == NULL) { - Stack->PushBool(false); - return S_OK; - } - - if (ToDelete->_main) { - Script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); - Stack->PushBool(false); - return S_OK; - } - - for (int i = 0; i < _layers.GetSize(); i++) { - if (_layers[i] == ToDelete) { - _layers.RemoveAt(i); - Game->UnregisterObject(ToDelete); - break; - } - } - Stack->PushBool(true); - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("scene"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumLayers (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumLayers") == 0) { - _scValue->SetInt(_layers.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWaypointGroups (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumWaypointGroups") == 0) { - _scValue->SetInt(_waypointGroups.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainLayer (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainLayer") == 0) { - if (_mainLayer) _scValue->SetNative(_mainLayer, true); - else _scValue->SetNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFreeNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumFreeNodes") == 0) { - _scValue->SetInt(_objects.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { - int ViewportX; - GetViewportOffset(&ViewportX); - - _scValue->SetInt(Game->_mousePos.x + _offsetLeft - ViewportX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { - int ViewportY; - GetViewportOffset(NULL, &ViewportY); - - _scValue->SetInt(Game->_mousePos.y + _offsetTop - ViewportY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoScroll") == 0) { - _scValue->SetBool(_autoScroll); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentState") == 0) { - _scValue->SetBool(_persistentState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentStateSprites") == 0) { - _scValue->SetBool(_persistentStateSprites); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsX") == 0) { - _scValue->SetInt(_scrollPixelsH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsY") == 0) { - _scValue->SetInt(_scrollPixelsV); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedX") == 0) { - _scValue->SetInt(_scrollTimeH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedY") == 0) { - _scValue->SetInt(_scrollTimeV); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetX") == 0) { - _scValue->SetInt(_offsetLeft); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetY") == 0) { - _scValue->SetInt(_offsetTop); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - if (_mainLayer) _scValue->SetInt(_mainLayer->_width); - else _scValue->SetInt(0); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - if (_mainLayer) _scValue->SetInt(_mainLayer->_height); - else _scValue->SetInt(0); - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoScroll") == 0) { - _autoScroll = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentState") == 0) { - _persistentState = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentStateSprites") == 0) { - _persistentStateSprites = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsX") == 0) { - _scrollPixelsH = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsY") == 0) { - _scrollPixelsV = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedX") == 0) { - _scrollTimeH = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedY") == 0) { - _scrollTimeV = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetX") == 0) { - _offsetLeft = Value->GetInt(); - - int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); - - _offsetLeft = MAX(0, _offsetLeft - ViewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); - _targetOffsetLeft = _offsetLeft; - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetY") == 0) { - _offsetTop = Value->GetInt(); - - int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); - - _offsetTop = MAX(0, _offsetTop - ViewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - ViewportHeight); - _targetOffsetTop = _offsetTop; - - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdScene::ScToString() { - return "[scene object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::AddObject(CAdObject *Object) { - _objects.Add(Object); - return Game->RegisterObject(Object); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::RemoveObject(CAdObject *Object) { - for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] == Object) { - _objects.RemoveAt(i); - return Game->UnregisterObject(Object); - } - } - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { - int i; - - Buffer->PutTextIndent(Indent, "SCENE {\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - if (_persistentState) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); - - if (!_persistentStateSprites) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); - - - // scripts - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // properties - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - - // viewport - if (_viewport) { - RECT *rc = _viewport->GetRect(); - Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); - } - - - - // editor settings - Buffer->PutTextIndent(Indent + 2, "; ----- editor settings\n"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); - - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - CBBase::SaveAsText(Buffer, Indent + 2); - - // waypoints - Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // layers - Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.GetSize(); i++) _layers[i]->SaveAsText(Buffer, Indent + 2); - - // scale levels - Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->SaveAsText(Buffer, Indent + 2); - - // rotation levels - Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->SaveAsText(Buffer, Indent + 2); - - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // free entities - Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - _objects[i]->SaveAsText(Buffer, Indent + 2); - - } - } - - - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SortScaleLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _scaleLevels.GetSize() - 1; i++) { - if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { - CAdScaleLevel *sl = _scaleLevels[i]; - _scaleLevels[i] = _scaleLevels[i + 1]; - _scaleLevels[i + 1] = sl; - - changed = true; - } - } - - } while (changed); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SortRotLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _rotLevels.GetSize() - 1; i++) { - if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { - CAdRotLevel *rl = _rotLevels[i]; - _rotLevels[i] = _rotLevels[i + 1]; - _rotLevels[i + 1] = rl; - - changed = true; - } - } - - } while (changed); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::GetScaleAt(int Y) { - CAdScaleLevel *prev = NULL; - CAdScaleLevel *next = NULL; - - for (int i = 0; i < _scaleLevels.GetSize(); i++) { - CAdScaleLevel *xxx = _scaleLevels[i]; - int j = _scaleLevels.GetSize(); - if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; - else { - next = _scaleLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 100; - - int delta_y = next->_posY - prev->_posY; - float delta_scale = next->_scale - prev->_scale; - Y -= prev->_posY; - - float percent = (float)Y / ((float)delta_y / 100.0f); - return prev->_scale + delta_scale / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_autoScroll)); - PersistMgr->Transfer(TMEMBER(_editorColBlocked)); - PersistMgr->Transfer(TMEMBER(_editorColBlockedSel)); - PersistMgr->Transfer(TMEMBER(_editorColDecor)); - PersistMgr->Transfer(TMEMBER(_editorColDecorSel)); - PersistMgr->Transfer(TMEMBER(_editorColEntity)); - PersistMgr->Transfer(TMEMBER(_editorColEntitySel)); - PersistMgr->Transfer(TMEMBER(_editorColFrame)); - PersistMgr->Transfer(TMEMBER(_editorColRegion)); - PersistMgr->Transfer(TMEMBER(_editorColRegionSel)); - PersistMgr->Transfer(TMEMBER(_editorColScale)); - PersistMgr->Transfer(TMEMBER(_editorColWaypoints)); - PersistMgr->Transfer(TMEMBER(_editorColWaypointsSel)); - PersistMgr->Transfer(TMEMBER(_editorMarginH)); - PersistMgr->Transfer(TMEMBER(_editorMarginV)); - PersistMgr->Transfer(TMEMBER(_editorShowBlocked)); - PersistMgr->Transfer(TMEMBER(_editorShowDecor)); - PersistMgr->Transfer(TMEMBER(_editorShowEntities)); - PersistMgr->Transfer(TMEMBER(_editorShowRegions)); - PersistMgr->Transfer(TMEMBER(_editorShowScale)); - PersistMgr->Transfer(TMEMBER(_fader)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_initialized)); - PersistMgr->Transfer(TMEMBER(_lastTimeH)); - PersistMgr->Transfer(TMEMBER(_lastTimeV)); - _layers.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_mainLayer)); - _objects.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_offsetLeft)); - PersistMgr->Transfer(TMEMBER(_offsetTop)); - PersistMgr->Transfer(TMEMBER(_paralaxScrolling)); - PersistMgr->Transfer(TMEMBER(_persistentState)); - PersistMgr->Transfer(TMEMBER(_persistentStateSprites)); - PersistMgr->Transfer(TMEMBER(_pFMaxTime)); - _pFPath.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_pFPointsNum)); - PersistMgr->Transfer(TMEMBER(_pFReady)); - PersistMgr->Transfer(TMEMBER(_pFRequester)); - PersistMgr->Transfer(TMEMBER(_pFTarget)); - PersistMgr->Transfer(TMEMBER(_pFTargetPath)); - _rotLevels.Persist(PersistMgr); - _scaleLevels.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollPixelsH)); - PersistMgr->Transfer(TMEMBER(_scrollPixelsV)); - PersistMgr->Transfer(TMEMBER(_scrollTimeH)); - PersistMgr->Transfer(TMEMBER(_scrollTimeV)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER(_targetOffsetLeft)); - PersistMgr->Transfer(TMEMBER(_targetOffsetTop)); - _waypointGroups.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_viewport)); - PersistMgr->Transfer(TMEMBER(_width)); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::AfterLoad() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { - double xStep, yStep, X, Y; - int xLength, yLength, xCount, yCount; - int X1, Y1, X2, Y2; - - X1 = *TargetX; - Y1 = *TargetY; - X2 = StartX; - Y2 = StartY; - - - xLength = abs(X2 - X1); - yLength = abs(Y2 - Y1); - - if (xLength > yLength) { - /* - if(X1 > X2) - { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - yStep = fabs((double)(Y2 - Y1) / (double)(X2 - X1)); - Y = Y1; - - for (xCount = X1; xCount < X2; xCount++) { - if (IsWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { - *TargetX = xCount; - *TargetY = (int)Y; - return S_OK; - } - Y += yStep; - } - } else { - /* - if(Y1 > Y2) { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - xStep = fabs((double)(X2 - X1) / (double)(Y2 - Y1)); - X = X1; - - for (yCount = Y1; yCount < Y2; yCount++) { - if (IsWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { - *TargetX = (int)X; - *TargetY = yCount; - return S_OK; - } - X += xStep; - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { - int x = *X; - int y = *Y; - - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { - return S_OK; - } - - // right - int length_right = 0; - bool found_right = false; - for (x = *X, y = *Y; x < _mainLayer->_width; x++, length_right++) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { - found_right = true; - break; - } - } - - // left - int length_left = 0; - bool found_left = false; - for (x = *X, y = *Y; x >= 0; x--, length_left--) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { - found_left = true; - break; - } - } - - // up - int length_up = 0; - bool found_up = false; - for (x = *X, y = *Y; y >= 0; y--, length_up--) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { - found_up = true; - break; - } - } - - // down - int length_down = 0; - bool found_down = false; - for (x = *X, y = *Y; y < _mainLayer->_height; y++, length_down++) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { - found_down = true; - break; - } - } - - if (!found_left && !found_right && !found_up && !found_down) { - return S_OK; - } - - int OffsetX = INT_MAX, OffsetY = INT_MAX; - - if (found_left && found_right) { - if (abs(length_left) < abs(length_right)) OffsetX = length_left; - else OffsetX = length_right; - } else if (found_left) OffsetX = length_left; - else if (found_right) OffsetX = length_right; - - if (found_up && found_down) { - if (abs(length_up) < abs(length_down)) OffsetY = length_up; - else OffsetY = length_down; - } else if (found_up) OffsetY = length_up; - else if (found_down) OffsetY = length_down; - - if (abs(OffsetX) < abs(OffsetY)) - *X = *X + OffsetX; - else - *Y = *Y + OffsetY; - - if (!IsWalkableAt(*X, *Y)) return CorrectTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::PFPointsStart() { - _pFPointsNum = 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::PFPointsAdd(int X, int Y, int Distance) { - if (_pFPointsNum >= _pFPath.GetSize()) { - _pFPath.Add(new CAdPathPoint(X, Y, Distance)); - } else { - _pFPath[_pFPointsNum]->x = X; - _pFPath[_pFPointsNum]->y = Y; - _pFPath[_pFPointsNum]->_distance = Distance; - _pFPath[_pFPointsNum]->_marked = false; - _pFPath[_pFPointsNum]->_origin = NULL; - } - - _pFPointsNum++; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { - CAdGame *AdGame = (CAdGame *)Game; - if (_viewport && !Game->_editorMode) { - if (OffsetX) *OffsetX = _viewport->_offsetX; - if (OffsetY) *OffsetY = _viewport->_offsetY; - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - if (OffsetX) *OffsetX = AdGame->_sceneViewport->_offsetX; - if (OffsetY) *OffsetY = AdGame->_sceneViewport->_offsetY; - } else { - if (OffsetX) *OffsetX = 0; - if (OffsetY) *OffsetY = 0; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { - CAdGame *AdGame = (CAdGame *)Game; - if (_viewport && !Game->_editorMode) { - if (Width) *Width = _viewport->GetWidth(); - if (Height) *Height = _viewport->GetHeight(); - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - if (Width) *Width = AdGame->_sceneViewport->GetWidth(); - if (Height) *Height = AdGame->_sceneViewport->GetHeight(); - } else { - if (Width) *Width = Game->_renderer->_width; - if (Height) *Height = Game->_renderer->_height; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::GetOffsetLeft() { - int ViewportX; - GetViewportOffset(&ViewportX); - - return _offsetLeft - ViewportX; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::GetOffsetTop() { - int ViewportY; - GetViewportOffset(NULL, &ViewportY); - - return _offsetTop - ViewportY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::PointInViewport(int X, int Y) { - int Left, Top, Width, Height; - - GetViewportOffset(&Left, &Top); - GetViewportSize(&Width, &Height); - - return X >= Left && X <= Left + Width && Y >= Top && Y <= Top + Height; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { - _offsetLeft = OffsetLeft; - _offsetTop = OffsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetNodeByName(const char *Name) { - int i; - CBObject *ret = NULL; - - // dependent objects - for (i = 0; i < _layers.GetSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.GetSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(Name, node->_entity->_name)) || - (node->_type == OBJECT_REGION && !scumm_stricmp(Name, node->_region->_name))) { - switch (node->_type) { - case OBJECT_ENTITY: - ret = node->_entity; - break; - case OBJECT_REGION: - ret = node->_region; - break; - default: - ret = NULL; - } - return ret; - } - } - } - - // free entities - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(Name, _objects[i]->_name)) { - return _objects[i]; - } - } - - // waypoint groups - for (i = 0; i < _waypointGroups.GetSize(); i++) { - if (!scumm_stricmp(Name, _waypointGroups[i]->_name)) { - return _waypointGroups[i]; - } - } - - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SaveState() { - return PersistState(true); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadState() { - return PersistState(false); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::PersistState(bool Saving) { - if (!_persistentState) return S_OK; - - CAdGame *AdGame = (CAdGame *)Game; - CAdSceneState *State = AdGame->GetSceneState(_filename, Saving); - if (!State) return S_OK; - - - int i; - CAdNodeState *NodeState; - - // dependent objects - for (i = 0; i < _layers.GetSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.GetSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: - if (!node->_entity->_saveState) continue; - NodeState = State->GetNodeState(node->_entity->_name, Saving); - if (NodeState) { - NodeState->TransferEntity(node->_entity, _persistentStateSprites, Saving); - //if(Saving) NodeState->_active = node->_entity->_active; - //else node->_entity->_active = NodeState->_active; - } - break; - case OBJECT_REGION: - if (!node->_region->_saveState) continue; - NodeState = State->GetNodeState(node->_region->_name, Saving); - if (NodeState) { - if (Saving) NodeState->_active = node->_region->_active; - else node->_region->_active = NodeState->_active; - } - break; - } - } - } - - // free entities - for (i = 0; i < _objects.GetSize(); i++) { - if (!_objects[i]->_saveState) continue; - if (_objects[i]->_type == OBJECT_ENTITY) { - NodeState = State->GetNodeState(_objects[i]->_name, Saving); - if (NodeState) { - NodeState->TransferEntity((CAdEntity *)_objects[i], _persistentStateSprites, Saving); - //if(Saving) NodeState->_active = _objects[i]->_active; - //else _objects[i]->_active = NodeState->_active; - } - } - } - - // waypoint groups - for (i = 0; i < _waypointGroups.GetSize(); i++) { - NodeState = State->GetNodeState(_waypointGroups[i]->_name, Saving); - if (NodeState) { - if (Saving) NodeState->_active = _waypointGroups[i]->_active; - else _waypointGroups[i]->_active = NodeState->_active; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::GetRotationAt(int X, int Y) { - CAdRotLevel *prev = NULL; - CAdRotLevel *next = NULL; - - for (int i = 0; i < _rotLevels.GetSize(); i++) { - CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.GetSize(); - if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; - else { - next = _rotLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 0; - - int delta_x = next->_posX - prev->_posX; - float delta_rot = next->_rotation - prev->_rotation; - X -= prev->_posX; - - float percent = (float)X / ((float)delta_x / 100.0f); - return prev->_rotation + delta_rot / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::HandleItemAssociations(const char *ItemName, bool Show) { - int i; - - for (i = 0; i < _layers.GetSize(); i++) { - CAdLayer *Layer = _layers[i]; - for (int j = 0; j < Layer->_nodes.GetSize(); j++) { - if (Layer->_nodes[j]->_type == OBJECT_ENTITY) { - CAdEntity *Ent = Layer->_nodes[j]->_entity; - - if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; - } - } - } - - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - CAdEntity *Ent = (CAdEntity *)_objects[i]; - if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { - int i; - int NumUsed = 0; - if (_mainLayer) { - for (i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { - if (NumUsed < NumRegions - 1) { - RegionList[NumUsed] = Node->_region; - NumUsed++; - } else break; - } - } - } - for (i = NumUsed; i < NumRegions; i++) { - RegionList[i] = NULL; - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::RestoreDeviceObjects() { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetNextAccessObject(CBObject *CurrObject) { - CBArray Objects; - GetSceneObjects(Objects, true); - - if (Objects.GetSize() == 0) return NULL; - else { - if (CurrObject != NULL) { - for (int i = 0; i < Objects.GetSize(); i++) { - if (Objects[i] == CurrObject) { - if (i < Objects.GetSize() - 1) return Objects[i + 1]; - else break; - } - } - } - return Objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { - CBArray Objects; - GetSceneObjects(Objects, true); - - if (Objects.GetSize() == 0) return NULL; - else { - if (CurrObject != NULL) { - for (int i = Objects.GetSize() - 1; i >= 0; i--) { - if (Objects[i] == CurrObject) { - if (i > 0) return Objects[i - 1]; - else break; - } - } - } - return Objects[Objects.GetSize() - 1]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bool InteractiveOnly) { - for (int i = 0; i < _layers.GetSize(); i++) { - // close-up layer -> remove everything below it - if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); - - - for (int j = 0; j < _layers[i]->_nodes.GetSize(); j++) { - CAdSceneNode *Node = _layers[i]->_nodes[j]; - switch (Node->_type) { - case OBJECT_ENTITY: { - CAdEntity *Ent = Node->_entity; - if (Ent->_active && (Ent->_registrable || !InteractiveOnly)) - Objects.Add(Ent); - } - break; - - case OBJECT_REGION: { - CBArray RegionObj; - GetRegionObjects(Node->_region, RegionObj, InteractiveOnly); - for (int New = 0; New < RegionObj.GetSize(); New++) { - bool Found = false; - for (int Old = 0; Old < Objects.GetSize(); Old++) { - if (Objects[Old] == RegionObj[New]) { - Found = true; - break; - } - } - if (!Found) Objects.Add(RegionObj[New]); - } - //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); - } - break; - } - } - } - - // objects outside any region - CBArray RegionObj; - GetRegionObjects(NULL, RegionObj, InteractiveOnly); - for (int New = 0; New < RegionObj.GetSize(); New++) { - bool Found = false; - for (int Old = 0; Old < Objects.GetSize(); Old++) { - if (Objects[Old] == RegionObj[New]) { - Found = true; - break; - } - } - if (!Found) Objects.Add(RegionObj[New]); - } - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { - CAdGame *AdGame = (CAdGame *)Game; - CAdObject *Obj; - - int i; - - // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - Obj = AdGame->_objects[i]; - if (Obj->_active && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - if (InteractiveOnly && !Obj->_registrable) continue; - - Objects.Add(Obj); - } - } - - // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - Obj = _objects[i]; - if (Obj->_active && !Obj->_editorOnly && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - if (InteractiveOnly && !Obj->_registrable) continue; - - Objects.Add(Obj); - } - } - - // sort by _posY - qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdScene.h b/engines/wintermute/AdScene.h deleted file mode 100644 index 4071068d15..0000000000 --- a/engines/wintermute/AdScene.h +++ /dev/null @@ -1,181 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENE_H -#define WINTERMUTE_ADSCENE_H - -#include "BFader.h" - -namespace WinterMute { - -class CUIWindow; -class CAdObject; -class CAdRegion; -class CBViewport; -class CAdLayer; -class CBPoint; -class CAdWaypointGroup; -class CAdPath; -class CAdScaleLevel; -class CAdRotLevel; -class CAdPathPoint; -class CAdScene : public CBObject { -public: - - CBObject *GetNextAccessObject(CBObject *CurrObject); - CBObject *GetPrevAccessObject(CBObject *CurrObject); - HRESULT GetSceneObjects(CBArray &Objects, bool InteractiveOnly); - HRESULT GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - - HRESULT AfterLoad(); - - HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - HRESULT HandleItemAssociations(const char *ItemName, bool Show); - CUIWindow *_shieldWindow; - float GetRotationAt(int X, int Y); - HRESULT LoadState(); - HRESULT SaveState(); - bool _persistentState; - bool _persistentStateSprites; - CBObject *GetNodeByName(const char *Name); - void SetOffset(int OffsetLeft, int OffsetTop); - bool PointInViewport(int X, int Y); - int GetOffsetTop(); - int GetOffsetLeft(); - HRESULT GetViewportSize(int *Width = NULL, int *Height = NULL); - HRESULT GetViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - CBViewport *_viewport; - CBFader *_fader; - int _pFPointsNum; - void PFPointsAdd(int X, int Y, int Distance); - void PFPointsStart(); - bool _initialized; - HRESULT CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - HRESULT CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); - DECLARE_PERSISTENT(CAdScene, CBObject) - HRESULT DisplayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - HRESULT DisplayRegionContentOld(CAdRegion *Region = NULL); - static int CompareObjs(const void *Obj1, const void *Obj2); - - HRESULT UpdateFreeObjects(); - HRESULT TraverseNodes(bool Update = false); - float GetScaleAt(int Y); - HRESULT SortScaleLevels(); - HRESULT SortRotLevels(); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); - bool _paralaxScrolling; - void SkipTo(int OffsetX, int OffsetY); - void SetDefaults(); - void Cleanup(); - void SkipToObject(CBObject *Object); - void ScrollToObject(CBObject *Object); - void ScrollTo(int OffsetX, int OffsetY); - virtual HRESULT Update(); - bool _autoScroll; - int _targetOffsetTop; - int _targetOffsetLeft; - - int _scrollPixelsV; - uint32 _scrollTimeV; - uint32 _lastTimeV; - - int _scrollPixelsH; - uint32 _scrollTimeH; - uint32 _lastTimeH; - - virtual HRESULT Display(); - uint32 _pFMaxTime; - HRESULT InitLoop(); - void PathFinderStep(); - bool IsBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool IsWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - CAdLayer *_mainLayer; - float GetZoomAt(int X, int Y); - bool GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); - CAdScene(CBGame *inGame); - virtual ~CAdScene(); - CBArray _layers; - CBArray _objects; - CBArray _waypointGroups; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - int _width; - int _height; - HRESULT AddObject(CAdObject *Object); - HRESULT RemoveObject(CAdObject *Object); - int _editorMarginH; - int _editorMarginV; - uint32 _editorColFrame; - uint32 _editorColEntity; - uint32 _editorColRegion; - uint32 _editorColBlocked; - uint32 _editorColWaypoints; - uint32 _editorColEntitySel; - uint32 _editorColRegionSel; - uint32 _editorColBlockedSel; - uint32 _editorColWaypointsSel; - uint32 _editorColScale; - uint32 _editorColDecor; - uint32 _editorColDecorSel; - - bool _editorShowRegions; - bool _editorShowBlocked; - bool _editorShowDecor; - bool _editorShowEntities; - bool _editorShowScale; - CBArray _scaleLevels; - CBArray _rotLevels; - - virtual HRESULT RestoreDeviceObjects(); - int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - - -private: - HRESULT PersistState(bool Saving = true); - void PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); - bool _pFReady; - CBPoint *_pFTarget; - CAdPath *_pFTargetPath; - CBObject *_pFRequester; - CBArray _pFPath; - - int _offsetTop; - int _offsetLeft; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdSceneNode.cpp b/engines/wintermute/AdSceneNode.cpp deleted file mode 100644 index 136836ac4a..0000000000 --- a/engines/wintermute/AdSceneNode.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdSceneNode.h" -#include "BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _region = NULL; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::~CAdSceneNode() { - Game->UnregisterObject(_region); - _region = NULL; - - Game->UnregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { - _type = OBJECT_ENTITY; - _entity = Entity; - return Game->RegisterObject(Entity); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { - _type = OBJECT_REGION; - _region = Region; - return Game->RegisterObject(Region); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_entity)); - PersistMgr->Transfer(TMEMBER(_region)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdSceneNode.h b/engines/wintermute/AdSceneNode.h deleted file mode 100644 index 5514e5a40a..0000000000 --- a/engines/wintermute/AdSceneNode.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENENODE_H -#define WINTERMUTE_ADSCENENODE_H - - -#include "AdTypes.h" // Added by ClassView -#include "AdRegion.h" // Added by ClassView -#include "AdEntity.h" - -namespace WinterMute { - -class CAdSceneNode : public CBObject { -public: - DECLARE_PERSISTENT(CAdSceneNode, CBObject) - HRESULT SetRegion(CAdRegion *Region); - HRESULT SetEntity(CAdEntity *Entity); - CAdEntity *_entity; - CAdRegion *_region; - TObjectType _type; - CAdSceneNode(CBGame *inGame); - virtual ~CAdSceneNode(); - -}; - -} - -#endif diff --git a/engines/wintermute/AdSceneState.cpp b/engines/wintermute/AdSceneState.cpp deleted file mode 100644 index 2404178b09..0000000000 --- a/engines/wintermute/AdSceneState.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "persistent.h" -#include "AdSceneState.h" -#include "AdNodeState.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneState, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::~CAdSceneState() { - delete[] _filename; - _filename = NULL; - - for (int i = 0; i < _nodeStates.GetSize(); i++) delete _nodeStates[i]; - _nodeStates.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_filename)); - _nodeStates.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSceneState::SetFilename(const char *Filename) { - delete[] _filename; - _filename = new char [strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { - for (int i = 0; i < _nodeStates.GetSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, Name) == 0) return _nodeStates[i]; - } - - if (Saving) { - CAdNodeState *ret = new CAdNodeState(Game); - ret->SetName(Name); - _nodeStates.Add(ret); - - return ret; - } else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdSceneState.h b/engines/wintermute/AdSceneState.h deleted file mode 100644 index 4f135d3b9c..0000000000 --- a/engines/wintermute/AdSceneState.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENESTATE_H -#define WINTERMUTE_ADSCENESTATE_H - -#include "persistent.h" -#include "BBase.h" -#include "coll_templ.h" - -namespace WinterMute { -class CAdNodeState; -class CAdSceneState : public CBBase { -public: - CAdNodeState *GetNodeState(char *Name, bool Saving); - void SetFilename(const char *Filename); - DECLARE_PERSISTENT(CAdSceneState, CBBase) - CAdSceneState(CBGame *inGame); - virtual ~CAdSceneState(); - char *_filename; - CBArray _nodeStates; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdSentence.cpp b/engines/wintermute/AdSentence.cpp deleted file mode 100644 index 9665f36d1e..0000000000 --- a/engines/wintermute/AdSentence.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdSentence.h" -#include "AdTalkDef.h" -#include "AdTalkNode.h" -#include "AdGame.h" -#include "PathUtil.h" -#include "BGame.h" -#include "BSound.h" -#include "AdScene.h" -#include "BFont.h" -#include "BSprite.h" -#include "BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSentence, false) - -////////////////////////////////////////////////////////////////////////// -CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { - _text = NULL; - _stances = NULL; - _tempStance = NULL; - - _duration = 0; - _startTime = 0; - _currentStance = 0; - - _font = NULL; - - _pos.x = _pos.y = 0; - _width = Game->_renderer->_width; - - _align = (TTextAlign)TAL_CENTER; - - _sound = NULL; - _soundStarted = false; - - _talkDef = NULL; - _currentSprite = NULL; - _currentSkelAnim = NULL; - _fixedPos = false; - _freezable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSentence::~CAdSentence() { - delete _sound; - delete[] _text; - delete[] _stances; - delete[] _tempStance; - delete _talkDef; - _sound = NULL; - _text = NULL; - _stances = NULL; - _tempStance = NULL; - _talkDef = NULL; - - _currentSprite = NULL; // ref only - _currentSkelAnim = NULL; - _font = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetText(const char *Text) { - if (_text) delete [] _text; - _text = new char[strlen(Text) + 1]; - if (_text) strcpy(_text, Text); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetStances(const char *Stances) { - if (_stances) delete [] _stances; - if (Stances) { - _stances = new char[strlen(Stances) + 1]; - if (_stances) strcpy(_stances, Stances); - } else _stances = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetCurrentStance() { - return GetStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetNextStance() { - _currentStance++; - return GetStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetStance(int Stance) { - if (_stances == NULL) return NULL; - - if (_tempStance) delete [] _tempStance; - _tempStance = NULL; - - char *start; - char *curr; - int pos; - - if (Stance == 0) start = _stances; - else { - pos = 0; - start = NULL; - curr = _stances; - while (pos < Stance) { - if (*curr == '\0') break; - if (*curr == ',') pos++; - curr++; - } - if (pos == Stance) start = curr; - } - - if (start == NULL) return NULL; - - while (*start == ' ' && *start != ',' && *start != '\0') start++; - - curr = start; - while (*curr != '\0' && *curr != ',') curr++; - - while (curr > start && *(curr - 1) == ' ') curr--; - - _tempStance = new char [curr - start + 1]; - if (_tempStance) { - _tempStance[curr - start] = '\0'; - strncpy(_tempStance, start, curr - start); - } - - return _tempStance; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Display() { - if (!_font || !_text) return E_FAIL; - - if (_sound && !_soundStarted) { - _sound->Play(); - _soundStarted = true; - } - - if (Game->_subtitles) { - int x = _pos.x; - int y = _pos.y; - - if (!_fixedPos) { - x = x - ((CAdGame *)Game)->_scene->GetOffsetLeft(); - y = y - ((CAdGame *)Game)->_scene->GetOffsetTop(); - } - - - x = MAX(x, 0); - x = MIN(x, Game->_renderer->_width - _width); - y = MAX(y, 0); - - _font->DrawText((byte *)_text, x, y, _width, _align); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetSound(CBSound *Sound) { - if (!Sound) return; - delete _sound; - _sound = Sound; - _soundStarted = false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Finish() { - if (_sound) _sound->Stop(); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER_INT(_align)); - PersistMgr->Transfer(TMEMBER(_currentStance)); - PersistMgr->Transfer(TMEMBER(_currentSprite)); - PersistMgr->Transfer(TMEMBER(_currentSkelAnim)); - PersistMgr->Transfer(TMEMBER(_duration)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_sound)); - PersistMgr->Transfer(TMEMBER(_soundStarted)); - PersistMgr->Transfer(TMEMBER(_stances)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_talkDef)); - PersistMgr->Transfer(TMEMBER(_tempStance)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER(_width)); - PersistMgr->Transfer(TMEMBER(_fixedPos)); - PersistMgr->Transfer(TMEMBER(_freezable)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { - delete _talkDef; - _talkDef = NULL; - _currentSprite = NULL; - - if (!SoundFilename) return S_OK; - - - AnsiString path = PathUtil::GetDirectoryName(SoundFilename); - AnsiString name = PathUtil::GetFileNameWithoutExtension(SoundFilename); - - AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); - - CBFile *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); - if (file) { - Game->_fileManager->CloseFile(file); - } else return S_OK; // no talk def file found - - - _talkDef = new CAdTalkDef(Game); - if (!_talkDef || FAILED(_talkDef->LoadFile(talkDefFileName.c_str()))) { - delete _talkDef; - _talkDef = NULL; - return E_FAIL; - } - //Game->LOG(0, "Using .talk file: %s", TalkDefFile); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Update(TDirection Dir) { - if (!_talkDef) return S_OK; - - uint32 CurrentTime; - // if sound is available, synchronize with sound, otherwise use timer - - /* - if(_sound) CurrentTime = _sound->GetPositionTime(); - else CurrentTime = Game->_timer - _startTime; - */ - CurrentTime = Game->_timer - _startTime; - - bool TalkNodeFound = false; - for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { - if (_talkDef->_nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { - TalkNodeFound = true; - - CBSprite *NewSprite = _talkDef->_nodes[i]->GetSprite(Dir); - if (NewSprite != _currentSprite) NewSprite->Reset(); - _currentSprite = NewSprite; - - if (!_talkDef->_nodes[i]->_playToEnd) break; - } - } - - - // no talk node, try to use default sprite instead (if any) - if (!TalkNodeFound) { - CBSprite *NewSprite = _talkDef->GetDefaultSprite(Dir); - if (NewSprite) { - if (NewSprite != _currentSprite) NewSprite->Reset(); - _currentSprite = NewSprite; - } else _currentSprite = NULL; - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::CanSkip() { - // prevent accidental sentence skipping (TODO make configurable) - return (Game->_timer - _startTime) > 300; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdSentence.h b/engines/wintermute/AdSentence.h deleted file mode 100644 index 4e36ad118d..0000000000 --- a/engines/wintermute/AdSentence.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSENTENCE_H -#define WINTERMUTE_ADSENTENCE_H - - -#include "BBase.h" -#include "persistent.h" -#include "dctypes.h" // Added by ClassView - -namespace WinterMute { -class CAdTalkDef; -class CBFont; -class CBSprite; -class CBSound; -class CAdSentence : public CBBase { -public: - bool _freezable; - bool _fixedPos; - CBSprite *_currentSprite; - char *_currentSkelAnim; - HRESULT Update(TDirection Dir = DI_DOWN); - HRESULT SetupTalkFile(const char *SoundFilename); - DECLARE_PERSISTENT(CAdSentence, CBBase) - HRESULT Finish(); - void SetSound(CBSound *Sound); - bool _soundStarted; - CBSound *_sound; - TTextAlign _align; - HRESULT Display(); - int _width; - POINT _pos; - CBFont *_font; - char *GetNextStance(); - char *GetCurrentStance(); - void SetStances(const char *Stances); - void SetText(const char *Text); - int _currentStance; - uint32 _startTime; - char *_stances; - char *_text; - uint32 _duration; - CAdSentence(CBGame *inGame); - virtual ~CAdSentence(); - CAdTalkDef *_talkDef; - - bool CanSkip(); - -private: - char *_tempStance; - char *GetStance(int Stance); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdSpriteSet.cpp b/engines/wintermute/AdSpriteSet.cpp deleted file mode 100644 index 351d3d2667..0000000000 --- a/engines/wintermute/AdSpriteSet.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdSpriteSet.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "BGame.h" -#include "BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSpriteSet, false) - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *Owner): CBObject(inGame) { - _owner = Owner; - - for (int i = 0; i < NUM_DIRECTIONS; i++) - _sprites[i] = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::~CAdSpriteSet() { - for (int i = 0; i < NUM_DIRECTIONS; i++) { - delete _sprites[i]; - _sprites[i] = NULL; - } - - _owner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SPRITESET) -TOKEN_DEF(NAME) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(RIGHT) -TOKEN_DEF(UP) -TOKEN_DEF(DOWN) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(NAME) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(RIGHT) - TOKEN_TABLE(UP) - TOKEN_TABLE(DOWN) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { - Game->LOG(0, "'SPRITESET' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - CBSprite *spr = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_LEFT: - delete _sprites[DI_LEFT]; - _sprites[DI_LEFT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_LEFT] = spr; - break; - - case TOKEN_RIGHT: - delete _sprites[DI_RIGHT]; - _sprites[DI_RIGHT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_RIGHT] = spr; - break; - - case TOKEN_UP: - delete _sprites[DI_UP]; - _sprites[DI_UP] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UP] = spr; - break; - - case TOKEN_DOWN: - delete _sprites[DI_DOWN]; - _sprites[DI_DOWN] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWN] = spr; - break; - - case TOKEN_UP_LEFT: - delete _sprites[DI_UPLEFT]; - _sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPLEFT] = spr; - break; - - case TOKEN_UP_RIGHT: - delete _sprites[DI_UPRIGHT]; - _sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPRIGHT] = spr; - break; - - case TOKEN_DOWN_LEFT: - delete _sprites[DI_DOWNLEFT]; - _sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNLEFT] = spr; - break; - - case TOKEN_DOWN_RIGHT: - delete _sprites[DI_DOWNRIGHT]; - _sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNRIGHT] = spr; - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SPRITESET definition"); - return E_FAIL; - } - - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading SPRITESET definition"); - if (spr) delete spr; - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_owner)); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - PersistMgr->Transfer("", &_sprites[i]); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { - int Dir = (int)Direction; - if (Dir < 0) Dir = 0; - if (Dir >= NUM_DIRECTIONS) Dir = NUM_DIRECTIONS - 1; - - CBSprite *ret = NULL; - - // find nearest set sprite - int i; - int NumSteps = 0; - for (i = Dir, NumSteps = 0; i >= 0; i--) { - if (_sprites[i] != NULL) { - ret = _sprites[i]; - NumSteps = Dir - i; - break; - } - } - - for (i = Dir; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] != NULL) { - if (ret == NULL || NumSteps > i - Dir) return _sprites[i]; - else return ret; - } - } - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SPRITESET {\n"); - if (_name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i]) { - switch (i) { - case DI_UP: - Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPRIGHT: - Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_RIGHT: - Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNRIGHT: - Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWN: - Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNLEFT: - Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_LEFT: - Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPLEFT: - Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - } - } - } - - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { - if (!Sprite) return NULL; - - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] == Sprite) return true; - } - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdSpriteSet.h b/engines/wintermute/AdSpriteSet.h deleted file mode 100644 index c4b1f28069..0000000000 --- a/engines/wintermute/AdSpriteSet.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSPRITESET_H -#define WINTERMUTE_ADSPRITESET_H - - -#include "BObject.h" -#include "BSprite.h" // Added by ClassView - -namespace WinterMute { - -class CAdSpriteSet : public CBObject { -public: - bool ContainsSprite(CBSprite *Sprite); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); - CBSprite *GetSprite(TDirection Direction); - DECLARE_PERSISTENT(CAdSpriteSet, CBObject) - CBObject *_owner; - CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); - virtual ~CAdSpriteSet(); - HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - CBSprite *_sprites[NUM_DIRECTIONS]; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdTalkDef.cpp b/engines/wintermute/AdTalkDef.cpp deleted file mode 100644 index d8ae610fcb..0000000000 --- a/engines/wintermute/AdTalkDef.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdTalkDef.h" -#include "AdTalkNode.h" -#include "BParser.h" -#include "BGame.h" -#include "BDynBuffer.h" -#include "BSprite.h" -#include "AdSpriteSet.h" -#include "BFileManager.h" -#include "utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkDef, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::~CAdTalkDef() { - for (int i = 0; i < _nodes.GetSize(); i++) delete _nodes[i]; - _nodes.RemoveAll(); - - delete[] _defaultSpriteFilename; - delete _defaultSprite; - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - delete[] _defaultSpriteSetFilename; - delete _defaultSpriteSet; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - CBUtils::SetString(&_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TALK) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(ACTION) -TOKEN_DEF(DEFAULT_SPRITESET_FILE) -TOKEN_DEF(DEFAULT_SPRITESET) -TOKEN_DEF(DEFAULT_SPRITE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(DEFAULT_SPRITESET_FILE) - TOKEN_TABLE(DEFAULT_SPRITESET) - TOKEN_TABLE(DEFAULT_SPRITE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TALK) { - Game->LOG(0, "'TALK' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_ACTION: { - CAdTalkNode *Node = new CAdTalkNode(Game); - if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) _nodes.Add(Node); - else { - delete Node; - Node = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_DEFAULT_SPRITE: - CBUtils::SetString(&_defaultSpriteFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::SetString(&_defaultSpriteSetFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET: { - delete _defaultSpriteSet; - _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadBuffer(params, false))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TALK definition"); - return E_FAIL; - } - - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading TALK definition"); - return E_FAIL; - } - - delete _defaultSprite; - delete _defaultSpriteSet; - _defaultSprite = NULL; - _defaultSpriteSet = NULL; - - if (_defaultSpriteFilename) { - _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) return E_FAIL; - } - - if (_defaultSpriteSetFilename) { - _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) return E_FAIL; - } - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_defaultSprite)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteFilename)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteSet)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteSetFilename)); - - _nodes.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "TALK {\n"); - if (_defaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - - if (_defaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->SaveAsText(Buffer, Indent + 2); - - for (int i = 0; i < _nodes.GetSize(); i++) { - _nodes[i]->SaveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "\n"); - } - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadDefaultSprite() { - if (_defaultSpriteFilename && !_defaultSprite) { - _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) { - delete _defaultSprite; - _defaultSprite = NULL; - return E_FAIL; - } else return S_OK; - } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { - _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - return E_FAIL; - } else return S_OK; - } else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkDef::GetDefaultSprite(TDirection Dir) { - LoadDefaultSprite(); - if (_defaultSprite) return _defaultSprite; - else if (_defaultSpriteSet) return _defaultSpriteSet->GetSprite(Dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkDef.h b/engines/wintermute/AdTalkDef.h deleted file mode 100644 index f6ed505cbb..0000000000 --- a/engines/wintermute/AdTalkDef.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKDEF_H -#define WINTERMUTE_ADTALKDEF_H - -#include "coll_templ.h" -#include "BObject.h" - -namespace WinterMute { -class CAdTalkNode; -class CAdSpriteSet; -class CAdTalkDef : public CBObject { -public: - char *_defaultSpriteSetFilename; - CAdSpriteSet *_defaultSpriteSet; - CBSprite *GetDefaultSprite(TDirection Dir); - HRESULT LoadDefaultSprite(); - DECLARE_PERSISTENT(CAdTalkDef, CBObject) - - CAdTalkDef(CBGame *inGame); - virtual ~CAdTalkDef(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CBArray _nodes; - char *_defaultSpriteFilename; - CBSprite *_defaultSprite; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdTalkHolder.cpp b/engines/wintermute/AdTalkHolder.cpp deleted file mode 100644 index 48bab0b1c1..0000000000 --- a/engines/wintermute/AdTalkHolder.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#define FORBIDDEN_SYMBOL_EXCEPTION_rand -#include "dcgf.h" -#include "AdTalkHolder.h" -#include "BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "BGame.h" -#include "BSprite.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkHolder, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::~CAdTalkHolder() { - delete _sprite; - _sprite = NULL; - - int i; - for (i = 0; i < _talkSprites.GetSize(); i++) delete _talkSprites[i]; - _talkSprites.RemoveAll(); - - for (i = 0; i < _talkSpritesEx.GetSize(); i++) delete _talkSpritesEx[i]; - _talkSpritesEx.RemoveAll(); -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { - CBSprite *ret = NULL; - - - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(Game, this); - if (_animSprite) { - HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); - if (FAILED(res)) { - Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - - if (Stance != NULL) { - // search special talk stances - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { - ret = _talkSpritesEx[i]; - break; - } - } - if (ret == NULL) { - // serach generic talk stances - for (int i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { - ret = _talkSprites[i]; - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.GetSize() < 1) ret = _sprite; - else { - // TODO: remember last - int rnd = rand() % _talkSprites.GetSize(); - ret = _talkSprites[rnd]; - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSprite") == 0) { - Stack->CorrectParams(1); - - CScValue *Val = Stack->Pop(); - - bool SetCurrent = false; - if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; - - delete _sprite; - _sprite = NULL; - - if (Val->IsNULL()) { - _sprite = NULL; - if (SetCurrent) _currentSprite = NULL; - Stack->PushBool(true); - } else { - const char *Filename = Val->GetString(); - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Script->RuntimeError("SetSprite method failed for file '%s'", Filename); - Stack->PushBool(false); - } else { - _sprite = spr; - if (SetCurrent) _currentSprite = _sprite; - Stack->PushBool(true); - } - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSprite") == 0) { - Stack->CorrectParams(0); - - if (!_sprite || !_sprite->_filename) Stack->PushNULL(); - else Stack->PushString(_sprite->_filename); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSpriteObject") == 0) { - Stack->CorrectParams(0); - - if (!_sprite) Stack->PushNULL(); - else Stack->PushNative(_sprite, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddTalkSprite") == 0) { - Stack->CorrectParams(2); - - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); - - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); - } else { - if (Ex) _talkSpritesEx.Add(spr); - else _talkSprites.Add(spr); - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveTalkSprite") == 0) { - Stack->CorrectParams(2); - - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); - int i; - - bool SetCurrent = false; - bool SetTemp2 = false; - - if (Ex) { - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_filename, Filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) SetCurrent = true; - if (_tempSprite2 == _talkSpritesEx[i]) SetTemp2 = true; - delete _talkSpritesEx[i]; - _talkSpritesEx.RemoveAt(i); - break; - } - } - } else { - for (i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_filename, Filename) == 0) { - if (_currentSprite == _talkSprites[i]) SetCurrent = true; - if (_tempSprite2 == _talkSprites[i]) SetTemp2 = true; - delete _talkSprites[i]; - _talkSprites.RemoveAt(i); - break; - } - } - - } - - Stack->PushBool(true); - if (SetCurrent) _currentSprite = _sprite; - if (SetTemp2) _tempSprite2 = _sprite; - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetTalkSprite") == 0) { - Stack->CorrectParams(2); - - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); - bool SetCurrent = false; - bool SetTemp2 = false; - - CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); - } else { - - // delete current - int i; - if (Ex) { - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (_talkSpritesEx[i] == _currentSprite) SetCurrent = true; - if (_talkSpritesEx[i] == _tempSprite2) SetTemp2 = true; - delete _talkSpritesEx[i]; - } - _talkSpritesEx.RemoveAll(); - } else { - for (i = 0; i < _talkSprites.GetSize(); i++) { - if (_talkSprites[i] == _currentSprite) SetCurrent = true; - if (_talkSprites[i] == _tempSprite2) SetTemp2 = true; - delete _talkSprites[i]; - } - _talkSprites.RemoveAll(); - } - - // set new - if (Ex) _talkSpritesEx.Add(spr); - else _talkSprites.Add(spr); - Stack->PushBool(true); - - if (SetCurrent) _currentSprite = spr; - if (SetTemp2) _tempSprite2 = spr; - } - return S_OK; - } - - else return CAdObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("talk-holder"); - return _scValue; - } - - else return CAdObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Item")==0){ - SetItem(Value->GetString()); - return S_OK; - } - - else*/ return CAdObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdTalkHolder::ScToString() { - return "[talk-holder object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { - int i; - for (i = 0; i < _talkSprites.GetSize(); i++) { - if (_talkSprites[i]->_filename) - Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); - } - - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (_talkSpritesEx[i]->_filename) - Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::Persist(CBPersistMgr *PersistMgr) { - CAdObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_sprite)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkHolder.h b/engines/wintermute/AdTalkHolder.h deleted file mode 100644 index 66fb7c8e10..0000000000 --- a/engines/wintermute/AdTalkHolder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKHOLDER_H -#define WINTERMUTE_ADTALKHOLDER_H - -#include "AdObject.h" - -namespace WinterMute { - -class CAdTalkHolder : public CAdObject { -public: - DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *GetTalkStance(const char *Stance); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - CBSprite *_sprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - CAdTalkHolder(CBGame *inGame); - virtual ~CAdTalkHolder(); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdTalkNode.cpp b/engines/wintermute/AdTalkNode.cpp deleted file mode 100644 index 4d153e0452..0000000000 --- a/engines/wintermute/AdTalkNode.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "AdTalkNode.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "BGame.h" -#include "BSprite.h" -#include "AdSpriteSet.h" -#include "utils.h" -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { - _sprite = NULL; - _spriteFilename = NULL; - _spriteSet = NULL; - _spriteSetFilename = NULL; - _comment = NULL; - - _startTime = _endTime = 0; - _playToEnd = false; - _preCache = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::~CAdTalkNode() { - delete[] _spriteFilename; - delete _sprite; - delete[] _spriteSetFilename; - delete _spriteSet; - delete _comment; - _spriteFilename = NULL; - _sprite = NULL; - _spriteSetFilename = NULL; - _spriteSet = NULL; - _comment = NULL; -} - - - -TOKEN_DEF_START -TOKEN_DEF(ACTION) -TOKEN_DEF(SPRITESET_FILE) -TOKEN_DEF(SPRITESET) -TOKEN_DEF(SPRITE) -TOKEN_DEF(START_TIME) -TOKEN_DEF(END_TIME) -TOKEN_DEF(COMMENT) -TOKEN_DEF(PRECACHE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(SPRITESET_FILE) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(START_TIME) - TOKEN_TABLE(END_TIME) - TOKEN_TABLE(COMMENT) - TOKEN_TABLE(PRECACHE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTION) { - Game->LOG(0, "'ACTION' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - _endTime = 0; - _playToEnd = false; - _preCache = false; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SPRITE: - CBUtils::SetString(&_spriteFilename, (char *)params); - break; - - case TOKEN_SPRITESET_FILE: - CBUtils::SetString(&_spriteSetFilename, (char *)params); - break; - - case TOKEN_SPRITESET: { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadBuffer(params, false))) { - delete _spriteSet; - _spriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_START_TIME: - parser.ScanStr((char *)params, "%d", &_startTime); - break; - - case TOKEN_END_TIME: - parser.ScanStr((char *)params, "%d", &_endTime); - break; - - case TOKEN_PRECACHE: - parser.ScanStr((char *)params, "%b", &_preCache); - break; - - case TOKEN_COMMENT: - if (Game->_editorMode) CBUtils::SetString(&_comment, (char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ACTION definition"); - return E_FAIL; - } - - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ACTION definition"); - return E_FAIL; - } - - if (_endTime == 0) _playToEnd = true; - else _playToEnd = false; - - if (_preCache && _spriteFilename) { - delete _sprite; - _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) return E_FAIL; - } - - if (_preCache && _spriteSetFilename) { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) return E_FAIL; - } - - - return S_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_comment)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_endTime)); - PersistMgr->Transfer(TMEMBER(_playToEnd)); - PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER(_spriteFilename)); - PersistMgr->Transfer(TMEMBER(_spriteSet)); - PersistMgr->Transfer(TMEMBER(_spriteSetFilename)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ACTION {\n"); - if (_comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); - Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->SaveAsText(Buffer, Indent + 2); - if (_preCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::LoadSprite() { - if (_spriteFilename && !_sprite) { - _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) { - delete _sprite; - _sprite = NULL; - return E_FAIL; - } else return S_OK; - } - - else if (_spriteSetFilename && !_spriteSet) { - _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) { - delete _spriteSet; - _spriteSet = NULL; - return E_FAIL; - } else return S_OK; - } - - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { - if (Time >= _startTime) { - if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->GetSprite(Dir) && _spriteSet->GetSprite(Dir)->_finished == false)) return true; - else return false; - } else return _endTime >= Time; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::GetSprite(TDirection Dir) { - LoadSprite(); - if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->GetSprite(Dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdTalkNode.h b/engines/wintermute/AdTalkNode.h deleted file mode 100644 index 89f541f6aa..0000000000 --- a/engines/wintermute/AdTalkNode.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKNODE_H -#define WINTERMUTE_ADTALKNODE_H - -#include "persistent.h" -#include "BBase.h" - -namespace WinterMute { -class CAdSpriteSet; -class CBSprite; -class CAdTalkNode : public CBBase { -public: - char *_spriteSetFilename; - CAdSpriteSet *_spriteSet; - CBSprite *GetSprite(TDirection Dir); - bool IsInTimeInterval(uint32 Time, TDirection Dir); - HRESULT LoadSprite(); - DECLARE_PERSISTENT(CAdTalkNode, CBBase) - - CAdTalkNode(CBGame *inGame); - virtual ~CAdTalkNode(); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); - char *_spriteFilename; - CBSprite *_sprite; - uint32 _startTime; - uint32 _endTime; - bool _playToEnd; - bool _preCache; - char *_comment; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/AdTypes.h b/engines/wintermute/AdTypes.h deleted file mode 100644 index 6531927350..0000000000 --- a/engines/wintermute/AdTypes.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTYPES_H -#define WINTERMUTE_ADTYPES_H - -namespace WinterMute { - -typedef enum { - GAME_NORMAL, GAME_WAITING_RESPONSE -} TGameStateEx; - - -typedef enum { - OBJECT_ENTITY, OBJECT_REGION, OBJECT_ACTOR, OBJECT_NONE -} TObjectType; - - -typedef enum { - ENTITY_NORMAL, ENTITY_SOUND -} TEntityType; - - -typedef enum { - STATE_NONE, - STATE_IDLE, - STATE_PLAYING_ANIM, - STATE_READY, - STATE_FOLLOWING_PATH, - STATE_SEARCHING_PATH, - STATE_WAITING_PATH, - STATE_TURNING_LEFT, - STATE_TURNING_RIGHT, - STATE_TURNING, - STATE_TALKING, - STATE_DIRECT_CONTROL, - STATE_PLAYING_ANIM_SET -} TObjectState; - -typedef enum { - DIRECT_WALK_NONE, DIRECT_WALK_FW, DIRECT_WALK_BK -} TDirectWalkMode; - -typedef enum { - DIRECT_TURN_NONE, DIRECT_TURN_CW, DIRECT_TURN_CCW -} TDirectTurnMode; - -typedef enum { - RESPONSE_TEXT, RESPONSE_ICON -} TResponseStyle; - -typedef enum { - RESPONSE_ALWAYS, RESPONSE_ONCE, RESPONSE_ONCE_GAME -} TResponseType; - - -typedef enum { - TALK_SKIP_LEFT = 0, TALK_SKIP_RIGHT = 1, TALK_SKIP_BOTH = 2, TALK_SKIP_NONE = 3 -} TTalkSkipButton; - - -typedef enum { - GEOM_WAYPOINT, GEOM_WALKPLANE, GEOM_BLOCKED, GEOM_GENERIC -} TGeomNodeType; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/AdWaypointGroup.cpp b/engines/wintermute/AdWaypointGroup.cpp deleted file mode 100644 index d85304b6f5..0000000000 --- a/engines/wintermute/AdWaypointGroup.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "AdWaypointGroup.h" -#include "BParser.h" -#include "BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "BGame.h" -#include "BRegion.h" -#include "BFileManager.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; -} - - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::~CAdWaypointGroup() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdWaypointGroup::Cleanup() { - for (int i = 0; i < _points.GetSize(); i++) - delete _points[i]; - _points.RemoveAll(); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(POINT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(POINT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { - Game->LOG(0, "'WAYPOINTS' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_POINT: { - int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in WAYPOINTS definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - CBBase::SaveAsText(Buffer, Indent + 2); - - for (int i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - Buffer->PutTextIndent(Indent, "}\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(_lastMimicScale)); - PersistMgr->Transfer(TMEMBER(_lastMimicX)); - PersistMgr->Transfer(TMEMBER(_lastMimicY)); - _points.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("waypoint-group"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - _scValue->SetBool(_active); - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Active") == 0) { - _active = Value->GetBool(); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { - if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; - - Cleanup(); - - for (int i = 0; i < Wpt->_points.GetSize(); i++) { - int x, y; - - x = (int)((float)Wpt->_points[i]->x * Scale / 100.0f); - y = (int)((float)Wpt->_points[i]->y * Scale / 100.0f); - - _points.Add(new CBPoint(x + X, y + Y)); - } - - _lastMimicScale = Scale; - _lastMimicX = X; - _lastMimicY = Y; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/AdWaypointGroup.h b/engines/wintermute/AdWaypointGroup.h deleted file mode 100644 index 0ce4d8040f..0000000000 --- a/engines/wintermute/AdWaypointGroup.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADWAYPOINTGROUP_H -#define WINTERMUTE_ADWAYPOINTGROUP_H - -#include "BObject.h" - -namespace WinterMute { -class CBPoint; -class CAdWaypointGroup : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void Cleanup(); - HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); - DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - bool _active; - CAdWaypointGroup(CBGame *inGame); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual ~CAdWaypointGroup(); - CBArray _points; - int _editorSelectedPoint; - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp index da6c95c8a8..73e513dca3 100644 --- a/engines/wintermute/BScriptHolder.cpp +++ b/engines/wintermute/BScriptHolder.cpp @@ -27,7 +27,7 @@ */ #include "dcgf.h" -#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/BScriptHolder.h" #include "engines/wintermute/BParser.h" #include "engines/wintermute/scriptables/ScValue.h" diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index ce94d81519..958cb65284 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/AdEntity.h" +#include "engines/wintermute/Ad/AdEntity.h" #include "engines/wintermute/BGame.h" #include "engines/wintermute/BFileManager.h" #include "engines/wintermute/UIEntity.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 70acdb5dec..7e1500da4e 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -13,35 +13,33 @@ MODULE_OBJS := \ scriptables/SXMemBuffer.o \ scriptables/SXStore.o \ scriptables/SXString.o \ - graphics/transparentSurface.o \ - graphics/tga.o \ - AdActor.o \ - AdActorDir.o \ - AdEntity.o \ - AdGame.o \ - AdInventory.o \ - AdInventoryBox.o \ - AdItem.o \ - AdLayer.o \ - AdNodeState.o \ - AdObject.o \ - AdPath.o \ - AdPathPoint.o \ - AdRegion.o \ - AdResponse.o \ - AdResponseBox.o \ - AdResponseContext.o \ - AdRotLevel.o \ - AdScaleLevel.o \ - AdScene.o \ - AdSceneNode.o \ - AdSceneState.o \ - AdSentence.o \ - AdSpriteSet.o \ - AdTalkDef.o \ - AdTalkHolder.o \ - AdTalkNode.o \ - AdWaypointGroup.o \ + Ad/AdActor.o \ + Ad/AdActorDir.o \ + Ad/AdEntity.o \ + Ad/AdGame.o \ + Ad/AdInventory.o \ + Ad/AdInventoryBox.o \ + Ad/AdItem.o \ + Ad/AdLayer.o \ + Ad/AdNodeState.o \ + Ad/AdObject.o \ + Ad/AdPath.o \ + Ad/AdPathPoint.o \ + Ad/AdRegion.o \ + Ad/AdResponse.o \ + Ad/AdResponseBox.o \ + Ad/AdResponseContext.o \ + Ad/AdRotLevel.o \ + Ad/AdScaleLevel.o \ + Ad/AdScene.o \ + Ad/AdSceneNode.o \ + Ad/AdSceneState.o \ + Ad/AdSentence.o \ + Ad/AdSpriteSet.o \ + Ad/AdTalkDef.o \ + Ad/AdTalkHolder.o \ + Ad/AdTalkNode.o \ + Ad/AdWaypointGroup.o \ BActiveRect.o \ BBase.o \ BDebugger.o \ diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index d2473c8dd2..d91619710b 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,7 +31,7 @@ #include "common/fs.h" #include "engines/util.h" -#include "engines/wintermute/AdGame.h" +#include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/PlatformSDL.h" -- cgit v1.2.3 From e6729615ea471891be17d5681b63fe3492f127bd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 02:05:11 +0200 Subject: WINTERMUTE: Move the B and Part files into Base/ --- engines/wintermute/Ad/AdActor.cpp | 18 +- engines/wintermute/Ad/AdActor.h | 2 +- engines/wintermute/Ad/AdActorDir.h | 2 +- engines/wintermute/Ad/AdEntity.cpp | 28 +- engines/wintermute/Ad/AdGame.cpp | 30 +- engines/wintermute/Ad/AdGame.h | 2 +- engines/wintermute/Ad/AdInventory.h | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 10 +- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 20 +- engines/wintermute/Ad/AdLayer.cpp | 14 +- engines/wintermute/Ad/AdNodeState.cpp | 6 +- engines/wintermute/Ad/AdObject.cpp | 26 +- engines/wintermute/Ad/AdObject.h | 2 +- engines/wintermute/Ad/AdPath.cpp | 2 +- engines/wintermute/Ad/AdPath.h | 2 +- engines/wintermute/Ad/AdPathPoint.cpp | 2 +- engines/wintermute/Ad/AdPathPoint.h | 2 +- engines/wintermute/Ad/AdRegion.cpp | 12 +- engines/wintermute/Ad/AdRegion.h | 2 +- engines/wintermute/Ad/AdResponse.cpp | 6 +- engines/wintermute/Ad/AdResponse.h | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 18 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdResponseContext.cpp | 2 +- engines/wintermute/Ad/AdResponseContext.h | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 10 +- engines/wintermute/Ad/AdRotLevel.h | 2 +- engines/wintermute/Ad/AdScaleLevel.cpp | 8 +- engines/wintermute/Ad/AdScaleLevel.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 28 +- engines/wintermute/Ad/AdScene.h | 2 +- engines/wintermute/Ad/AdSceneNode.cpp | 2 +- engines/wintermute/Ad/AdSceneState.h | 2 +- engines/wintermute/Ad/AdSentence.cpp | 10 +- engines/wintermute/Ad/AdSentence.h | 2 +- engines/wintermute/Ad/AdSpriteSet.cpp | 8 +- engines/wintermute/Ad/AdSpriteSet.h | 4 +- engines/wintermute/Ad/AdTalkDef.cpp | 10 +- engines/wintermute/Ad/AdTalkDef.h | 2 +- engines/wintermute/Ad/AdTalkHolder.cpp | 12 +- engines/wintermute/Ad/AdTalkNode.cpp | 8 +- engines/wintermute/Ad/AdTalkNode.h | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 12 +- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- engines/wintermute/BActiveRect.cpp | 107 - engines/wintermute/BActiveRect.h | 59 - engines/wintermute/BBase.cpp | 177 - engines/wintermute/BBase.h | 66 - engines/wintermute/BDebugger.cpp | 203 - engines/wintermute/BDebugger.h | 93 - engines/wintermute/BDiskFile.cpp | 230 - engines/wintermute/BDiskFile.h | 59 - engines/wintermute/BDynBuffer.cpp | 192 - engines/wintermute/BDynBuffer.h | 66 - engines/wintermute/BEvent.cpp | 197 - engines/wintermute/BEvent.h | 56 - engines/wintermute/BFader.cpp | 176 - engines/wintermute/BFader.h | 62 - engines/wintermute/BFile.cpp | 69 - engines/wintermute/BFile.h | 65 - engines/wintermute/BFileEntry.cpp | 50 - engines/wintermute/BFileEntry.h | 57 - engines/wintermute/BFileManager.cpp | 879 ---- engines/wintermute/BFileManager.h | 87 - engines/wintermute/BFont.cpp | 206 - engines/wintermute/BFont.h | 61 - engines/wintermute/BFontBitmap.cpp | 542 --- engines/wintermute/BFontBitmap.h | 72 - engines/wintermute/BFontStorage.cpp | 157 - engines/wintermute/BFontStorage.h | 66 - engines/wintermute/BFontTT.cpp | 889 ---- engines/wintermute/BFontTT.h | 193 - engines/wintermute/BFrame.cpp | 708 --- engines/wintermute/BFrame.h | 73 - engines/wintermute/BGame.cpp | 4537 -------------------- engines/wintermute/BGame.h | 386 -- engines/wintermute/BImage.cpp | 121 - engines/wintermute/BImage.h | 62 - engines/wintermute/BKeyboardState.cpp | 247 -- engines/wintermute/BKeyboardState.h | 72 - engines/wintermute/BNamedObject.cpp | 65 - engines/wintermute/BNamedObject.h | 50 - engines/wintermute/BObject.cpp | 1122 ----- engines/wintermute/BObject.h | 145 - engines/wintermute/BPackage.cpp | 104 - engines/wintermute/BPackage.h | 61 - engines/wintermute/BParser.cpp | 436 -- engines/wintermute/BParser.h | 88 - engines/wintermute/BPersistMgr.cpp | 517 --- engines/wintermute/BPersistMgr.h | 89 - engines/wintermute/BPkgFile.cpp | 161 - engines/wintermute/BPkgFile.h | 64 - engines/wintermute/BPoint.cpp | 64 - engines/wintermute/BPoint.h | 50 - engines/wintermute/BQuickMsg.cpp | 54 - engines/wintermute/BQuickMsg.h | 48 - engines/wintermute/BRegion.cpp | 509 --- engines/wintermute/BRegion.h | 68 - engines/wintermute/BRegistry.cpp | 228 - engines/wintermute/BRegistry.h | 76 - engines/wintermute/BRenderSDL.cpp | 456 -- engines/wintermute/BRenderSDL.h | 96 - engines/wintermute/BRenderer.cpp | 259 -- engines/wintermute/BRenderer.h | 124 - engines/wintermute/BResourceFile.cpp | 103 - engines/wintermute/BResourceFile.h | 50 - engines/wintermute/BResources.cpp | 2830 ------------ engines/wintermute/BResources.h | 41 - engines/wintermute/BSaveThumbFile.cpp | 146 - engines/wintermute/BSaveThumbFile.h | 51 - engines/wintermute/BSaveThumbHelper.cpp | 79 - engines/wintermute/BSaveThumbHelper.h | 50 - engines/wintermute/BScriptHolder.cpp | 473 -- engines/wintermute/BScriptHolder.h | 74 - engines/wintermute/BScriptable.cpp | 188 - engines/wintermute/BScriptable.h | 80 - engines/wintermute/BSound.cpp | 266 -- engines/wintermute/BSound.h | 85 - engines/wintermute/BSoundBuffer.cpp | 397 -- engines/wintermute/BSoundBuffer.h | 102 - engines/wintermute/BSoundMgr.cpp | 327 -- engines/wintermute/BSoundMgr.h | 70 - engines/wintermute/BSprite.cpp | 754 ---- engines/wintermute/BSprite.h | 90 - engines/wintermute/BStringTable.cpp | 229 - engines/wintermute/BStringTable.h | 55 - engines/wintermute/BSubFrame.cpp | 589 --- engines/wintermute/BSubFrame.h | 85 - engines/wintermute/BSurface.cpp | 196 - engines/wintermute/BSurface.h | 93 - engines/wintermute/BSurfaceSDL.cpp | 480 --- engines/wintermute/BSurfaceSDL.h | 81 - engines/wintermute/BSurfaceStorage.cpp | 192 - engines/wintermute/BSurfaceStorage.h | 58 - engines/wintermute/BTransitionMgr.cpp | 127 - engines/wintermute/BTransitionMgr.h | 54 - engines/wintermute/BViewport.cpp | 98 - engines/wintermute/BViewport.h | 55 - engines/wintermute/Base/BActiveRect.cpp | 107 + engines/wintermute/Base/BActiveRect.h | 59 + engines/wintermute/Base/BBase.cpp | 177 + engines/wintermute/Base/BBase.h | 66 + engines/wintermute/Base/BDebugger.cpp | 203 + engines/wintermute/Base/BDebugger.h | 93 + engines/wintermute/Base/BDiskFile.cpp | 230 + engines/wintermute/Base/BDiskFile.h | 59 + engines/wintermute/Base/BDynBuffer.cpp | 192 + engines/wintermute/Base/BDynBuffer.h | 66 + engines/wintermute/Base/BEvent.cpp | 197 + engines/wintermute/Base/BEvent.h | 56 + engines/wintermute/Base/BFader.cpp | 176 + engines/wintermute/Base/BFader.h | 62 + engines/wintermute/Base/BFile.cpp | 69 + engines/wintermute/Base/BFile.h | 65 + engines/wintermute/Base/BFileEntry.cpp | 50 + engines/wintermute/Base/BFileEntry.h | 57 + engines/wintermute/Base/BFileManager.cpp | 879 ++++ engines/wintermute/Base/BFileManager.h | 87 + engines/wintermute/Base/BFont.cpp | 206 + engines/wintermute/Base/BFont.h | 61 + engines/wintermute/Base/BFontBitmap.cpp | 542 +++ engines/wintermute/Base/BFontBitmap.h | 72 + engines/wintermute/Base/BFontStorage.cpp | 157 + engines/wintermute/Base/BFontStorage.h | 66 + engines/wintermute/Base/BFontTT.cpp | 889 ++++ engines/wintermute/Base/BFontTT.h | 193 + engines/wintermute/Base/BFrame.cpp | 708 +++ engines/wintermute/Base/BFrame.h | 73 + engines/wintermute/Base/BGame.cpp | 4537 ++++++++++++++++++++ engines/wintermute/Base/BGame.h | 386 ++ engines/wintermute/Base/BImage.cpp | 121 + engines/wintermute/Base/BImage.h | 62 + engines/wintermute/Base/BKeyboardState.cpp | 247 ++ engines/wintermute/Base/BKeyboardState.h | 72 + engines/wintermute/Base/BNamedObject.cpp | 65 + engines/wintermute/Base/BNamedObject.h | 50 + engines/wintermute/Base/BObject.cpp | 1122 +++++ engines/wintermute/Base/BObject.h | 145 + engines/wintermute/Base/BPackage.cpp | 104 + engines/wintermute/Base/BPackage.h | 61 + engines/wintermute/Base/BParser.cpp | 436 ++ engines/wintermute/Base/BParser.h | 88 + engines/wintermute/Base/BPersistMgr.cpp | 517 +++ engines/wintermute/Base/BPersistMgr.h | 89 + engines/wintermute/Base/BPkgFile.cpp | 161 + engines/wintermute/Base/BPkgFile.h | 64 + engines/wintermute/Base/BPoint.cpp | 64 + engines/wintermute/Base/BPoint.h | 50 + engines/wintermute/Base/BQuickMsg.cpp | 54 + engines/wintermute/Base/BQuickMsg.h | 48 + engines/wintermute/Base/BRegion.cpp | 509 +++ engines/wintermute/Base/BRegion.h | 68 + engines/wintermute/Base/BRegistry.cpp | 228 + engines/wintermute/Base/BRegistry.h | 76 + engines/wintermute/Base/BRenderSDL.cpp | 456 ++ engines/wintermute/Base/BRenderSDL.h | 96 + engines/wintermute/Base/BRenderer.cpp | 259 ++ engines/wintermute/Base/BRenderer.h | 124 + engines/wintermute/Base/BResourceFile.cpp | 103 + engines/wintermute/Base/BResourceFile.h | 50 + engines/wintermute/Base/BResources.cpp | 2830 ++++++++++++ engines/wintermute/Base/BResources.h | 41 + engines/wintermute/Base/BSaveThumbFile.cpp | 146 + engines/wintermute/Base/BSaveThumbFile.h | 51 + engines/wintermute/Base/BSaveThumbHelper.cpp | 79 + engines/wintermute/Base/BSaveThumbHelper.h | 50 + engines/wintermute/Base/BScriptHolder.cpp | 473 ++ engines/wintermute/Base/BScriptHolder.h | 74 + engines/wintermute/Base/BScriptable.cpp | 188 + engines/wintermute/Base/BScriptable.h | 80 + engines/wintermute/Base/BSound.cpp | 266 ++ engines/wintermute/Base/BSound.h | 85 + engines/wintermute/Base/BSoundBuffer.cpp | 397 ++ engines/wintermute/Base/BSoundBuffer.h | 102 + engines/wintermute/Base/BSoundMgr.cpp | 327 ++ engines/wintermute/Base/BSoundMgr.h | 70 + engines/wintermute/Base/BSprite.cpp | 754 ++++ engines/wintermute/Base/BSprite.h | 90 + engines/wintermute/Base/BStringTable.cpp | 229 + engines/wintermute/Base/BStringTable.h | 55 + engines/wintermute/Base/BSubFrame.cpp | 589 +++ engines/wintermute/Base/BSubFrame.h | 85 + engines/wintermute/Base/BSurface.cpp | 196 + engines/wintermute/Base/BSurface.h | 93 + engines/wintermute/Base/BSurfaceSDL.cpp | 480 +++ engines/wintermute/Base/BSurfaceSDL.h | 81 + engines/wintermute/Base/BSurfaceStorage.cpp | 192 + engines/wintermute/Base/BSurfaceStorage.h | 58 + engines/wintermute/Base/BTransitionMgr.cpp | 127 + engines/wintermute/Base/BTransitionMgr.h | 54 + engines/wintermute/Base/BViewport.cpp | 98 + engines/wintermute/Base/BViewport.h | 55 + engines/wintermute/Base/PartEmitter.cpp | 1198 ++++++ engines/wintermute/Base/PartEmitter.h | 139 + engines/wintermute/Base/PartForce.cpp | 59 + engines/wintermute/Base/PartForce.h | 57 + engines/wintermute/Base/PartParticle.cpp | 255 ++ engines/wintermute/Base/PartParticle.h | 89 + engines/wintermute/Base/scriptables/SXArray.cpp | 234 + engines/wintermute/Base/scriptables/SXArray.h | 54 + engines/wintermute/Base/scriptables/SXDate.cpp | 277 ++ engines/wintermute/Base/scriptables/SXDate.h | 53 + engines/wintermute/Base/scriptables/SXFile.cpp | 723 ++++ engines/wintermute/Base/scriptables/SXFile.h | 63 + engines/wintermute/Base/scriptables/SXMath.cpp | 290 ++ engines/wintermute/Base/scriptables/SXMath.h | 53 + .../wintermute/Base/scriptables/SXMemBuffer.cpp | 479 +++ engines/wintermute/Base/scriptables/SXMemBuffer.h | 59 + engines/wintermute/Base/scriptables/SXStore.cpp | 511 +++ engines/wintermute/Base/scriptables/SXStore.h | 175 + engines/wintermute/Base/scriptables/SXString.cpp | 394 ++ engines/wintermute/Base/scriptables/SXString.h | 58 + engines/wintermute/Base/scriptables/ScEngine.cpp | 854 ++++ engines/wintermute/Base/scriptables/ScEngine.h | 174 + engines/wintermute/Base/scriptables/ScScript.cpp | 1600 +++++++ engines/wintermute/Base/scriptables/ScScript.h | 185 + engines/wintermute/Base/scriptables/ScStack.cpp | 226 + engines/wintermute/Base/scriptables/ScStack.h | 66 + engines/wintermute/Base/scriptables/ScValue.cpp | 1028 +++++ engines/wintermute/Base/scriptables/ScValue.h | 142 + engines/wintermute/Base/scriptables/SxObject.cpp | 63 + engines/wintermute/Base/scriptables/SxObject.h | 47 + engines/wintermute/FontGlyphCache.h | 2 +- engines/wintermute/PartEmitter.cpp | 1198 ------ engines/wintermute/PartEmitter.h | 139 - engines/wintermute/PartForce.cpp | 59 - engines/wintermute/PartForce.h | 57 - engines/wintermute/PartParticle.cpp | 255 -- engines/wintermute/PartParticle.h | 89 - engines/wintermute/PathUtil.cpp | 2 +- engines/wintermute/PathUtil.h | 2 +- engines/wintermute/PlatformSDL.cpp | 10 +- engines/wintermute/PlatformSDL.h | 4 +- engines/wintermute/StringUtil.cpp | 2 +- engines/wintermute/StringUtil.h | 2 +- engines/wintermute/SysClass.cpp | 6 +- engines/wintermute/SysClass.h | 4 +- engines/wintermute/SysClassRegistry.cpp | 4 +- engines/wintermute/SysClassRegistry.h | 6 +- engines/wintermute/UIButton.cpp | 24 +- engines/wintermute/UIButton.h | 2 +- engines/wintermute/UIEdit.cpp | 26 +- engines/wintermute/UIEdit.h | 2 +- engines/wintermute/UIEntity.cpp | 14 +- engines/wintermute/UIObject.cpp | 10 +- engines/wintermute/UIObject.h | 4 +- engines/wintermute/UIText.cpp | 22 +- engines/wintermute/UITiledImage.cpp | 12 +- engines/wintermute/UIWindow.cpp | 30 +- engines/wintermute/VidPlayer.cpp | 2 +- engines/wintermute/VidPlayer.h | 4 +- engines/wintermute/VidTheoraPlayer.cpp | 2 +- engines/wintermute/VidTheoraPlayer.h | 8 +- engines/wintermute/coll_templ.h | 2 +- engines/wintermute/module.mk | 122 +- engines/wintermute/persistent.h | 2 +- engines/wintermute/scriptables/SXArray.cpp | 234 - engines/wintermute/scriptables/SXArray.h | 54 - engines/wintermute/scriptables/SXDate.cpp | 277 -- engines/wintermute/scriptables/SXDate.h | 53 - engines/wintermute/scriptables/SXFile.cpp | 723 ---- engines/wintermute/scriptables/SXFile.h | 63 - engines/wintermute/scriptables/SXMath.cpp | 290 -- engines/wintermute/scriptables/SXMath.h | 53 - engines/wintermute/scriptables/SXMemBuffer.cpp | 479 --- engines/wintermute/scriptables/SXMemBuffer.h | 59 - engines/wintermute/scriptables/SXStore.cpp | 511 --- engines/wintermute/scriptables/SXStore.h | 175 - engines/wintermute/scriptables/SXString.cpp | 394 -- engines/wintermute/scriptables/SXString.h | 58 - engines/wintermute/scriptables/ScEngine.cpp | 854 ---- engines/wintermute/scriptables/ScEngine.h | 174 - engines/wintermute/scriptables/ScScript.cpp | 1600 ------- engines/wintermute/scriptables/ScScript.h | 185 - engines/wintermute/scriptables/ScStack.cpp | 226 - engines/wintermute/scriptables/ScStack.h | 66 - engines/wintermute/scriptables/ScValue.cpp | 1028 ----- engines/wintermute/scriptables/ScValue.h | 142 - engines/wintermute/scriptables/SxObject.cpp | 63 - engines/wintermute/scriptables/SxObject.h | 47 - engines/wintermute/utils.cpp | 8 +- engines/wintermute/utils.h | 2 +- 323 files changed, 34873 insertions(+), 34873 deletions(-) delete mode 100644 engines/wintermute/BActiveRect.cpp delete mode 100644 engines/wintermute/BActiveRect.h delete mode 100644 engines/wintermute/BBase.cpp delete mode 100644 engines/wintermute/BBase.h delete mode 100644 engines/wintermute/BDebugger.cpp delete mode 100644 engines/wintermute/BDebugger.h delete mode 100644 engines/wintermute/BDiskFile.cpp delete mode 100644 engines/wintermute/BDiskFile.h delete mode 100644 engines/wintermute/BDynBuffer.cpp delete mode 100644 engines/wintermute/BDynBuffer.h delete mode 100644 engines/wintermute/BEvent.cpp delete mode 100644 engines/wintermute/BEvent.h delete mode 100644 engines/wintermute/BFader.cpp delete mode 100644 engines/wintermute/BFader.h delete mode 100644 engines/wintermute/BFile.cpp delete mode 100644 engines/wintermute/BFile.h delete mode 100644 engines/wintermute/BFileEntry.cpp delete mode 100644 engines/wintermute/BFileEntry.h delete mode 100644 engines/wintermute/BFileManager.cpp delete mode 100644 engines/wintermute/BFileManager.h delete mode 100644 engines/wintermute/BFont.cpp delete mode 100644 engines/wintermute/BFont.h delete mode 100644 engines/wintermute/BFontBitmap.cpp delete mode 100644 engines/wintermute/BFontBitmap.h delete mode 100644 engines/wintermute/BFontStorage.cpp delete mode 100644 engines/wintermute/BFontStorage.h delete mode 100644 engines/wintermute/BFontTT.cpp delete mode 100644 engines/wintermute/BFontTT.h delete mode 100644 engines/wintermute/BFrame.cpp delete mode 100644 engines/wintermute/BFrame.h delete mode 100644 engines/wintermute/BGame.cpp delete mode 100644 engines/wintermute/BGame.h delete mode 100644 engines/wintermute/BImage.cpp delete mode 100644 engines/wintermute/BImage.h delete mode 100644 engines/wintermute/BKeyboardState.cpp delete mode 100644 engines/wintermute/BKeyboardState.h delete mode 100644 engines/wintermute/BNamedObject.cpp delete mode 100644 engines/wintermute/BNamedObject.h delete mode 100644 engines/wintermute/BObject.cpp delete mode 100644 engines/wintermute/BObject.h delete mode 100644 engines/wintermute/BPackage.cpp delete mode 100644 engines/wintermute/BPackage.h delete mode 100644 engines/wintermute/BParser.cpp delete mode 100644 engines/wintermute/BParser.h delete mode 100644 engines/wintermute/BPersistMgr.cpp delete mode 100644 engines/wintermute/BPersistMgr.h delete mode 100644 engines/wintermute/BPkgFile.cpp delete mode 100644 engines/wintermute/BPkgFile.h delete mode 100644 engines/wintermute/BPoint.cpp delete mode 100644 engines/wintermute/BPoint.h delete mode 100644 engines/wintermute/BQuickMsg.cpp delete mode 100644 engines/wintermute/BQuickMsg.h delete mode 100644 engines/wintermute/BRegion.cpp delete mode 100644 engines/wintermute/BRegion.h delete mode 100644 engines/wintermute/BRegistry.cpp delete mode 100644 engines/wintermute/BRegistry.h delete mode 100644 engines/wintermute/BRenderSDL.cpp delete mode 100644 engines/wintermute/BRenderSDL.h delete mode 100644 engines/wintermute/BRenderer.cpp delete mode 100644 engines/wintermute/BRenderer.h delete mode 100644 engines/wintermute/BResourceFile.cpp delete mode 100644 engines/wintermute/BResourceFile.h delete mode 100644 engines/wintermute/BResources.cpp delete mode 100644 engines/wintermute/BResources.h delete mode 100644 engines/wintermute/BSaveThumbFile.cpp delete mode 100644 engines/wintermute/BSaveThumbFile.h delete mode 100644 engines/wintermute/BSaveThumbHelper.cpp delete mode 100644 engines/wintermute/BSaveThumbHelper.h delete mode 100644 engines/wintermute/BScriptHolder.cpp delete mode 100644 engines/wintermute/BScriptHolder.h delete mode 100644 engines/wintermute/BScriptable.cpp delete mode 100644 engines/wintermute/BScriptable.h delete mode 100644 engines/wintermute/BSound.cpp delete mode 100644 engines/wintermute/BSound.h delete mode 100644 engines/wintermute/BSoundBuffer.cpp delete mode 100644 engines/wintermute/BSoundBuffer.h delete mode 100644 engines/wintermute/BSoundMgr.cpp delete mode 100644 engines/wintermute/BSoundMgr.h delete mode 100644 engines/wintermute/BSprite.cpp delete mode 100644 engines/wintermute/BSprite.h delete mode 100644 engines/wintermute/BStringTable.cpp delete mode 100644 engines/wintermute/BStringTable.h delete mode 100644 engines/wintermute/BSubFrame.cpp delete mode 100644 engines/wintermute/BSubFrame.h delete mode 100644 engines/wintermute/BSurface.cpp delete mode 100644 engines/wintermute/BSurface.h delete mode 100644 engines/wintermute/BSurfaceSDL.cpp delete mode 100644 engines/wintermute/BSurfaceSDL.h delete mode 100644 engines/wintermute/BSurfaceStorage.cpp delete mode 100644 engines/wintermute/BSurfaceStorage.h delete mode 100644 engines/wintermute/BTransitionMgr.cpp delete mode 100644 engines/wintermute/BTransitionMgr.h delete mode 100644 engines/wintermute/BViewport.cpp delete mode 100644 engines/wintermute/BViewport.h create mode 100644 engines/wintermute/Base/BActiveRect.cpp create mode 100644 engines/wintermute/Base/BActiveRect.h create mode 100644 engines/wintermute/Base/BBase.cpp create mode 100644 engines/wintermute/Base/BBase.h create mode 100644 engines/wintermute/Base/BDebugger.cpp create mode 100644 engines/wintermute/Base/BDebugger.h create mode 100644 engines/wintermute/Base/BDiskFile.cpp create mode 100644 engines/wintermute/Base/BDiskFile.h create mode 100644 engines/wintermute/Base/BDynBuffer.cpp create mode 100644 engines/wintermute/Base/BDynBuffer.h create mode 100644 engines/wintermute/Base/BEvent.cpp create mode 100644 engines/wintermute/Base/BEvent.h create mode 100644 engines/wintermute/Base/BFader.cpp create mode 100644 engines/wintermute/Base/BFader.h create mode 100644 engines/wintermute/Base/BFile.cpp create mode 100644 engines/wintermute/Base/BFile.h create mode 100644 engines/wintermute/Base/BFileEntry.cpp create mode 100644 engines/wintermute/Base/BFileEntry.h create mode 100644 engines/wintermute/Base/BFileManager.cpp create mode 100644 engines/wintermute/Base/BFileManager.h create mode 100644 engines/wintermute/Base/BFont.cpp create mode 100644 engines/wintermute/Base/BFont.h create mode 100644 engines/wintermute/Base/BFontBitmap.cpp create mode 100644 engines/wintermute/Base/BFontBitmap.h create mode 100644 engines/wintermute/Base/BFontStorage.cpp create mode 100644 engines/wintermute/Base/BFontStorage.h create mode 100644 engines/wintermute/Base/BFontTT.cpp create mode 100644 engines/wintermute/Base/BFontTT.h create mode 100644 engines/wintermute/Base/BFrame.cpp create mode 100644 engines/wintermute/Base/BFrame.h create mode 100644 engines/wintermute/Base/BGame.cpp create mode 100644 engines/wintermute/Base/BGame.h create mode 100644 engines/wintermute/Base/BImage.cpp create mode 100644 engines/wintermute/Base/BImage.h create mode 100644 engines/wintermute/Base/BKeyboardState.cpp create mode 100644 engines/wintermute/Base/BKeyboardState.h create mode 100644 engines/wintermute/Base/BNamedObject.cpp create mode 100644 engines/wintermute/Base/BNamedObject.h create mode 100644 engines/wintermute/Base/BObject.cpp create mode 100644 engines/wintermute/Base/BObject.h create mode 100644 engines/wintermute/Base/BPackage.cpp create mode 100644 engines/wintermute/Base/BPackage.h create mode 100644 engines/wintermute/Base/BParser.cpp create mode 100644 engines/wintermute/Base/BParser.h create mode 100644 engines/wintermute/Base/BPersistMgr.cpp create mode 100644 engines/wintermute/Base/BPersistMgr.h create mode 100644 engines/wintermute/Base/BPkgFile.cpp create mode 100644 engines/wintermute/Base/BPkgFile.h create mode 100644 engines/wintermute/Base/BPoint.cpp create mode 100644 engines/wintermute/Base/BPoint.h create mode 100644 engines/wintermute/Base/BQuickMsg.cpp create mode 100644 engines/wintermute/Base/BQuickMsg.h create mode 100644 engines/wintermute/Base/BRegion.cpp create mode 100644 engines/wintermute/Base/BRegion.h create mode 100644 engines/wintermute/Base/BRegistry.cpp create mode 100644 engines/wintermute/Base/BRegistry.h create mode 100644 engines/wintermute/Base/BRenderSDL.cpp create mode 100644 engines/wintermute/Base/BRenderSDL.h create mode 100644 engines/wintermute/Base/BRenderer.cpp create mode 100644 engines/wintermute/Base/BRenderer.h create mode 100644 engines/wintermute/Base/BResourceFile.cpp create mode 100644 engines/wintermute/Base/BResourceFile.h create mode 100644 engines/wintermute/Base/BResources.cpp create mode 100644 engines/wintermute/Base/BResources.h create mode 100644 engines/wintermute/Base/BSaveThumbFile.cpp create mode 100644 engines/wintermute/Base/BSaveThumbFile.h create mode 100644 engines/wintermute/Base/BSaveThumbHelper.cpp create mode 100644 engines/wintermute/Base/BSaveThumbHelper.h create mode 100644 engines/wintermute/Base/BScriptHolder.cpp create mode 100644 engines/wintermute/Base/BScriptHolder.h create mode 100644 engines/wintermute/Base/BScriptable.cpp create mode 100644 engines/wintermute/Base/BScriptable.h create mode 100644 engines/wintermute/Base/BSound.cpp create mode 100644 engines/wintermute/Base/BSound.h create mode 100644 engines/wintermute/Base/BSoundBuffer.cpp create mode 100644 engines/wintermute/Base/BSoundBuffer.h create mode 100644 engines/wintermute/Base/BSoundMgr.cpp create mode 100644 engines/wintermute/Base/BSoundMgr.h create mode 100644 engines/wintermute/Base/BSprite.cpp create mode 100644 engines/wintermute/Base/BSprite.h create mode 100644 engines/wintermute/Base/BStringTable.cpp create mode 100644 engines/wintermute/Base/BStringTable.h create mode 100644 engines/wintermute/Base/BSubFrame.cpp create mode 100644 engines/wintermute/Base/BSubFrame.h create mode 100644 engines/wintermute/Base/BSurface.cpp create mode 100644 engines/wintermute/Base/BSurface.h create mode 100644 engines/wintermute/Base/BSurfaceSDL.cpp create mode 100644 engines/wintermute/Base/BSurfaceSDL.h create mode 100644 engines/wintermute/Base/BSurfaceStorage.cpp create mode 100644 engines/wintermute/Base/BSurfaceStorage.h create mode 100644 engines/wintermute/Base/BTransitionMgr.cpp create mode 100644 engines/wintermute/Base/BTransitionMgr.h create mode 100644 engines/wintermute/Base/BViewport.cpp create mode 100644 engines/wintermute/Base/BViewport.h create mode 100644 engines/wintermute/Base/PartEmitter.cpp create mode 100644 engines/wintermute/Base/PartEmitter.h create mode 100644 engines/wintermute/Base/PartForce.cpp create mode 100644 engines/wintermute/Base/PartForce.h create mode 100644 engines/wintermute/Base/PartParticle.cpp create mode 100644 engines/wintermute/Base/PartParticle.h create mode 100644 engines/wintermute/Base/scriptables/SXArray.cpp create mode 100644 engines/wintermute/Base/scriptables/SXArray.h create mode 100644 engines/wintermute/Base/scriptables/SXDate.cpp create mode 100644 engines/wintermute/Base/scriptables/SXDate.h create mode 100644 engines/wintermute/Base/scriptables/SXFile.cpp create mode 100644 engines/wintermute/Base/scriptables/SXFile.h create mode 100644 engines/wintermute/Base/scriptables/SXMath.cpp create mode 100644 engines/wintermute/Base/scriptables/SXMath.h create mode 100644 engines/wintermute/Base/scriptables/SXMemBuffer.cpp create mode 100644 engines/wintermute/Base/scriptables/SXMemBuffer.h create mode 100644 engines/wintermute/Base/scriptables/SXStore.cpp create mode 100644 engines/wintermute/Base/scriptables/SXStore.h create mode 100644 engines/wintermute/Base/scriptables/SXString.cpp create mode 100644 engines/wintermute/Base/scriptables/SXString.h create mode 100644 engines/wintermute/Base/scriptables/ScEngine.cpp create mode 100644 engines/wintermute/Base/scriptables/ScEngine.h create mode 100644 engines/wintermute/Base/scriptables/ScScript.cpp create mode 100644 engines/wintermute/Base/scriptables/ScScript.h create mode 100644 engines/wintermute/Base/scriptables/ScStack.cpp create mode 100644 engines/wintermute/Base/scriptables/ScStack.h create mode 100644 engines/wintermute/Base/scriptables/ScValue.cpp create mode 100644 engines/wintermute/Base/scriptables/ScValue.h create mode 100644 engines/wintermute/Base/scriptables/SxObject.cpp create mode 100644 engines/wintermute/Base/scriptables/SxObject.h delete mode 100644 engines/wintermute/PartEmitter.cpp delete mode 100644 engines/wintermute/PartEmitter.h delete mode 100644 engines/wintermute/PartForce.cpp delete mode 100644 engines/wintermute/PartForce.h delete mode 100644 engines/wintermute/PartParticle.cpp delete mode 100644 engines/wintermute/PartParticle.h delete mode 100644 engines/wintermute/scriptables/SXArray.cpp delete mode 100644 engines/wintermute/scriptables/SXArray.h delete mode 100644 engines/wintermute/scriptables/SXDate.cpp delete mode 100644 engines/wintermute/scriptables/SXDate.h delete mode 100644 engines/wintermute/scriptables/SXFile.cpp delete mode 100644 engines/wintermute/scriptables/SXFile.h delete mode 100644 engines/wintermute/scriptables/SXMath.cpp delete mode 100644 engines/wintermute/scriptables/SXMath.h delete mode 100644 engines/wintermute/scriptables/SXMemBuffer.cpp delete mode 100644 engines/wintermute/scriptables/SXMemBuffer.h delete mode 100644 engines/wintermute/scriptables/SXStore.cpp delete mode 100644 engines/wintermute/scriptables/SXStore.h delete mode 100644 engines/wintermute/scriptables/SXString.cpp delete mode 100644 engines/wintermute/scriptables/SXString.h delete mode 100644 engines/wintermute/scriptables/ScEngine.cpp delete mode 100644 engines/wintermute/scriptables/ScEngine.h delete mode 100644 engines/wintermute/scriptables/ScScript.cpp delete mode 100644 engines/wintermute/scriptables/ScScript.h delete mode 100644 engines/wintermute/scriptables/ScStack.cpp delete mode 100644 engines/wintermute/scriptables/ScStack.h delete mode 100644 engines/wintermute/scriptables/ScValue.cpp delete mode 100644 engines/wintermute/scriptables/ScValue.h delete mode 100644 engines/wintermute/scriptables/SxObject.cpp delete mode 100644 engines/wintermute/scriptables/SxObject.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 9b30d16221..17c7b317a1 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/dctypes.h" #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Ad/AdActor.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/Ad/AdScene.h" @@ -38,14 +38,14 @@ #include "engines/wintermute/Ad/AdWaypointGroup.h" #include "engines/wintermute/Ad/AdPath.h" #include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/utils.h" #include "engines/wintermute/PlatformSDL.h" #include diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index cbe5e2161e..0c00b19157 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -33,7 +33,7 @@ #include "engines/wintermute/dctypes.h" // Added by ClassView #include "engines/wintermute/Ad/AdTypes.h" // Added by ClassView #include "engines/wintermute/Ad/AdTalkHolder.h" -#include "engines/wintermute/BPoint.h" // Added by ClassView +#include "engines/wintermute/Base/BPoint.h" // Added by ClassView #include "engines/wintermute/persistent.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdActorDir.h b/engines/wintermute/Ad/AdActorDir.h index 6408c51ad9..f3579ed72c 100644 --- a/engines/wintermute/Ad/AdActorDir.h +++ b/engines/wintermute/Ad/AdActorDir.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADACTORDIR_H #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 1e492bbdca..6f628dfd72 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -30,26 +30,26 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/BSound.h" +#include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" #include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/utils.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 4de2e70dae..bc0ba6a4e8 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -31,14 +31,14 @@ #include "engines/wintermute/Ad/AdResponseBox.h" #include "engines/wintermute/Ad/AdInventoryBox.h" #include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/PartEmitter.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BTransitionMgr.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BSound.h" +#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BTransitionMgr.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/UIEntity.h" #include "engines/wintermute/Ad/AdScene.h" #include "engines/wintermute/Ad/AdEntity.h" @@ -46,16 +46,16 @@ #include "engines/wintermute/Ad/AdInventory.h" #include "engines/wintermute/Ad/AdResponseContext.h" #include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/BViewport.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/BStringTable.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Ad/AdSentence.h" #include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 8c146d1af3..d4c6ae3b6f 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -29,7 +29,7 @@ #define WINTERMUTE_ADGAME_H #include "engines/wintermute/Ad/AdTypes.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BGame.h" namespace WinterMute { class CAdItem; diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h index b6f0c6399a..12aca999f7 100644 --- a/engines/wintermute/Ad/AdInventory.h +++ b/engines/wintermute/Ad/AdInventory.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADINVENTORY_H #define WINTERMUTE_ADINVENTORY_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 5de9f54493..4c6d2523d7 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -30,11 +30,11 @@ #include "engines/wintermute/Ad/AdInventoryBox.h" #include "engines/wintermute/Ad/AdInventory.h" #include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BViewport.h" -#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/UIButton.h" #include "engines/wintermute/UIWindow.h" #include "engines/wintermute/PlatformSDL.h" diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index b7838607d2..c7aeca6eab 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADINVENTORYBOX_H #define WINTERMUTE_ADINVENTORYBOX_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { class CUIButton; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index efd655c500..343bc6c6fc 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -30,18 +30,18 @@ #include "engines/wintermute/Ad/AdItem.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/utils.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index b6e7a8527e..8198bf492b 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -27,15 +27,15 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Ad/AdLayer.h" #include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 05ff99f7e0..bd4dc1906c 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -27,11 +27,11 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Ad/AdNodeState.h" #include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 34903a8ccf..1f892f7eae 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -36,19 +36,19 @@ #include "engines/wintermute/Ad/AdSceneNode.h" #include "engines/wintermute/Ad/AdSentence.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFrame.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" #include "common/str.h" #include "common/util.h" diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index 5f47c0d394..34873c89fc 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADOBJECT_H #include "engines/wintermute/Ad/AdTypes.h" -#include "engines/wintermute/PartEmitter.h" +#include "engines/wintermute/Base/PartEmitter.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 210f13f68b..9d2f1d555b 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdPath.h" -#include "engines/wintermute/BPoint.h" +#include "engines/wintermute/Base/BPoint.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdPath.h b/engines/wintermute/Ad/AdPath.h index d921e78c0a..dbc769117a 100644 --- a/engines/wintermute/Ad/AdPath.h +++ b/engines/wintermute/Ad/AdPath.h @@ -31,7 +31,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" namespace WinterMute { class CBPoint; diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp index c66a7769f5..73d4976a6e 100644 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/Ad/AdPathPoint.h" -#include "engines/wintermute/BPersistMgr.h" +#include "engines/wintermute/Base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdPathPoint.h b/engines/wintermute/Ad/AdPathPoint.h index bb31223dbb..cfa08d319b 100644 --- a/engines/wintermute/Ad/AdPathPoint.h +++ b/engines/wintermute/Ad/AdPathPoint.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADPATHPOINT_H #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BPoint.h" +#include "engines/wintermute/Base/BPoint.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 41022a85aa..5ed3097b30 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -28,12 +28,12 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdRegion.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 37be803a9e..0d119b1ac3 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADREGION_H #define WINTERMUTE_ADREGION_H -#include "engines/wintermute/BRegion.h" +#include "engines/wintermute/Base/BRegion.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 3db37385b6..656d38f247 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -28,9 +28,9 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h index 88f6fc03a8..42f2f90b14 100644 --- a/engines/wintermute/Ad/AdResponse.h +++ b/engines/wintermute/Ad/AdResponse.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADRESPONSE_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Ad/AdTypes.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index d50e25e088..d81d1b5add 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -29,18 +29,18 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/Ad/AdResponseBox.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSurfaceStorage.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/UIButton.h" #include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" #include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index cf98cfadca..8f26940d0a 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADRESPONSEBOX_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 482edbcb4d..03904a1037 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdResponseContext.h" -#include "engines/wintermute/BPersistMgr.h" +#include "engines/wintermute/Base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponseContext.h b/engines/wintermute/Ad/AdResponseContext.h index 84ca44ef6f..f29d943e19 100644 --- a/engines/wintermute/Ad/AdResponseContext.h +++ b/engines/wintermute/Ad/AdResponseContext.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADRESPONSECONTEXT_H #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index ea1681660a..fb1167f426 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -28,11 +28,11 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdRotLevel.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index dd3b318a34..94612c15b5 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADROTLEVEL_H #define WINTERMUTE_ADROTLEVEL_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 06729c6435..d417358c0c 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -28,10 +28,10 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdScaleLevel.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index 9cda5cf4d0..28fdbceb41 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADSCALELEVEL_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f7cd60c555..c71d10207f 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -41,21 +41,21 @@ #include "engines/wintermute/Ad/AdSceneState.h" #include "engines/wintermute/Ad/AdSentence.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BPoint.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BScriptable.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BViewport.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BPoint.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BScriptable.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BViewport.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/UIWindow.h" #include "engines/wintermute/utils.h" #include diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 87bd290970..046db15b21 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADSCENE_H #define WINTERMUTE_ADSCENE_H -#include "engines/wintermute/BFader.h" +#include "engines/wintermute/Base/BFader.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index d7d0ae98cc..aceff64873 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BGame.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdSceneState.h b/engines/wintermute/Ad/AdSceneState.h index 264106b599..6aa03792d2 100644 --- a/engines/wintermute/Ad/AdSceneState.h +++ b/engines/wintermute/Ad/AdSceneState.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADSCENESTATE_H #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/coll_templ.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 2395a4996c..a280916734 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -32,12 +32,12 @@ #include "engines/wintermute/Ad/AdTalkNode.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSound.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 495edceee0..310be3e3e5 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADSENTENCE_H -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dctypes.h" // Added by ClassView diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 8ea4849e1c..4fc5a12c4c 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -28,10 +28,10 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index 4da0fded12..07d2097215 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -30,8 +30,8 @@ #define WINTERMUTE_ADSPRITESET_H -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BSprite.h" // Added by ClassView +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BSprite.h" // Added by ClassView namespace WinterMute { diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 7a5091432f..d3c655bebe 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -29,12 +29,12 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdTalkDef.h" #include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 7eaafcd6ec..08abcaf32b 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADTALKDEF_H #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { class CAdTalkNode; diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index f5ae27967d..61e012b261 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -29,12 +29,12 @@ #define FORBIDDEN_SYMBOL_EXCEPTION_rand #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdTalkHolder.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index f2f35539ff..2c68b188e6 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -28,10 +28,10 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Ad/AdSpriteSet.h" #include "engines/wintermute/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h index 18781f90da..519b57add0 100644 --- a/engines/wintermute/Ad/AdTalkNode.h +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADTALKNODE_H #include "engines/wintermute/persistent.h" -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" namespace WinterMute { class CAdSpriteSet; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 982079269e..7748cdca02 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -27,12 +27,12 @@ */ #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BFileManager.h" #include namespace WinterMute { diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index ea76bb50fa..2c7d981c58 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADWAYPOINTGROUP_H #define WINTERMUTE_ADWAYPOINTGROUP_H -#include "engines/wintermute/BObject.h" +#include "engines/wintermute/Base/BObject.h" namespace WinterMute { class CBPoint; diff --git a/engines/wintermute/BActiveRect.cpp b/engines/wintermute/BActiveRect.cpp deleted file mode 100644 index b94c4d021f..0000000000 --- a/engines/wintermute/BActiveRect.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BActiveRect.h" -#include "BGame.h" -#include "BRegion.h" -#include "PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - ClipRect(); -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise): CBBase(inGame) { - _owner = Owner; - _frame = Frame; - CBPlatform::SetRect(&_rect, X, Y, X + Width, Y + Height); - _zoomX = ZoomX; - _zoomY = ZoomY; - _precise = Precise; - _region = NULL; - _offsetX = _offsetY = 0; - ClipRect(); -} - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY): CBBase(inGame) { - _owner = Owner; - _region = Region; - CBPlatform::CopyRect(&_rect, &Region->_rect); - CBPlatform::OffsetRect(&_rect, -OffsetX, -OffsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - ClipRect(); - _offsetX = OffsetX; - _offsetY = OffsetY; -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBActiveRect::ClipRect() { - RECT rc; - bool CustomViewport; - Game->GetCurrentViewportRect(&rc, &CustomViewport); - CBRenderer *Rend = Game->_renderer; - - if (!CustomViewport) { - rc.left -= Rend->_drawOffsetX; - rc.right -= Rend->_drawOffsetX; - rc.top -= Rend->_drawOffsetY; - rc.bottom -= Rend->_drawOffsetY; - } - - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - - CBPlatform::IntersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BActiveRect.h b/engines/wintermute/BActiveRect.h deleted file mode 100644 index 6ad5b93448..0000000000 --- a/engines/wintermute/BActiveRect.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H - -#include "BBase.h" - -namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { -public: - void ClipRect(); - bool _precise; - float _zoomX; - float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; - int _offsetX; - int _offsetY; - RECT _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX = 100, float ZoomY = 100, bool Precise = true); - CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY); - virtual ~CBActiveRect(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BBase.cpp b/engines/wintermute/BBase.cpp deleted file mode 100644 index 543259b8d9..0000000000 --- a/engines/wintermute/BBase.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BBase.h" -#include "BGame.h" -#include "BParser.h" -#include "BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *GameOwner) { - Game = GameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { - Game = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { - _editorPropsIter = _editorProps.find(PropName); - if (_editorPropsIter != _editorProps.end()) - return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return InitVal; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::SetEditorProp(const char *PropName, const char *PropValue) { - if (PropName == NULL) return E_FAIL; - - if (PropValue == NULL) { - _editorProps.erase(PropName); - } else { - _editorProps[PropName] = PropValue; - } - return S_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - - if (!Game->_editorMode) return S_OK; - - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - char *PropName = NULL; - char *PropValue = NULL; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] PropName; - PropName = new char[strlen((char *)params) + 1]; - if (PropName) strcpy(PropName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] PropValue; - PropValue = new char[strlen((char *)params) + 1]; - if (PropValue) strcpy(PropValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return E_FAIL; - } - - - SetEditorProp(PropName, PropValue); - - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { - _editorPropsIter = _editorProps.begin(); - while (_editorPropsIter != _editorProps.end()) { - Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); - Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - Buffer->PutTextIndent(Indent, "}\n\n"); - - _editorPropsIter++; - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BBase.h b/engines/wintermute/BBase.h deleted file mode 100644 index eb1a1e7834..0000000000 --- a/engines/wintermute/BBase.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H - -#include "wintypes.h" -#include "dctypes.h" -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -//#include -//#include - -namespace WinterMute { - -class CBGame; -class CBDynBuffer; - -class CBBase { -public: - bool _persistable; - HRESULT SetEditorProp(const char *PropName, const char *PropValue); - const char *GetEditorProp(const char *PropName, const char *InitVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; - HRESULT ParseEditorProperty(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); - CBBase(); - CBGame *Game; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); - - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BDebugger.cpp b/engines/wintermute/BDebugger.cpp deleted file mode 100644 index 62efc27bb5..0000000000 --- a/engines/wintermute/BDebugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "BDebugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::Initialize() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::Shutdown() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameInit() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameShutdown() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameTick() { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnLog(unsigned int ErrorCode, const char *Text) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptInit(CScScript *Script) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptShutdown(CScScript *Script) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptChangeLine(CScScript *Script, int Line) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptChangeScope(CScScript *Script, CScValue *Scope) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptShutdownScope(CScScript *Script, CScValue *Scope) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *Value) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *Script) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool CBDebugger::AttachClient(IWmeDebugClient *Client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::DetachClient(IWmeDebugClient *Client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::QueryData(IWmeDebugClient *Client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int CBDebugger::GetPropInt(const char *PropName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double CBDebugger::GetPropFloat(const char *PropName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::GetPropString(const char *PropName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::GetPropBool(const char *PropName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, int PropValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, double PropValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, const char *PropValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, bool PropValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::AddBreakpoint(const char *ScriptFilename, int Line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::RemoveBreakpoint(const char *ScriptFilename, int Line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::ContinueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BDebugger.h b/engines/wintermute/BDebugger.h deleted file mode 100644 index bdae7823a0..0000000000 --- a/engines/wintermute/BDebugger.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "BBase.h" -#include "wme_debugger.h" - -namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { -public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); - - // initialization - bool _enabled; - HRESULT Initialize(); - HRESULT Shutdown(); - - // internal interface - HRESULT OnGameInit(); - HRESULT OnGameShutdown(); - HRESULT OnGameTick(); - HRESULT OnLog(unsigned int ErrorCode, const char *Text); - HRESULT OnScriptInit(CScScript *Script); - HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); - HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); - - HRESULT OnScriptShutdown(CScScript *Script); - HRESULT OnScriptChangeLine(CScScript *Script, int Line); - HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); - HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); - HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName); - HRESULT OnVariableChangeValue(CScValue *Var, CScValue *Value); - - HRESULT OnScriptHitBreakpoint(CScScript *Script); - - // IWmeDebugServer interface - virtual bool AttachClient(IWmeDebugClient *Client); - virtual bool DetachClient(IWmeDebugClient *Client); - virtual bool QueryData(IWmeDebugClient *Client); - - virtual int GetPropInt(const char *PropName); - virtual double GetPropFloat(const char *PropName); - virtual const char *GetPropString(const char *PropName); - virtual bool GetPropBool(const char *PropName); - - virtual bool SetProp(const char *PropName, int PropValue); - virtual bool SetProp(const char *PropName, double PropValue); - virtual bool SetProp(const char *PropName, const char *PropValue); - virtual bool SetProp(const char *PropName, bool PropValue); - - virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize); - - virtual bool AddBreakpoint(const char *ScriptFilename, int Line); - virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line); - - virtual bool ContinueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BDiskFile.cpp b/engines/wintermute/BDiskFile.cpp deleted file mode 100644 index c8301dde20..0000000000 --- a/engines/wintermute/BDiskFile.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BGame.h" -#include "wintypes.h" -#include "BPkgFile.h" -#include "BDiskFile.h" -#include "common/stream.h" -#include "common/file.h" -#include "BFileManager.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { - _file = NULL; - _data = NULL; - _compressed = false; - _prefixSize = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBDiskFile::~CBDiskFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Open(const Common::String &Filename) { - Close(); - - char FullPath[MAX_PATH]; - - for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { - sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); - CorrectSlashes(FullPath); - //_file = Common::createFileStream(FullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { - _file = tempFile; - } else { - delete tempFile; - } - /* if (_file != NULL) { - error("Tried to open %s, but failed", Filename.c_str()); - break; - }*/ - } - - // if we didn't find it in search paths, try to open directly - if (!_file) { - strcpy(FullPath, Filename.c_str()); - CorrectSlashes(FullPath); - //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); - //_file = Common::createFileStream(FullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { - _file = tempFile; - } else { - delete tempFile; - } - } - - if (_file) { - uint32 magic1, magic2; - magic1 = _file->readUint32LE(); - magic2 = _file->readUint32LE(); - - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; - - if (_compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = _file->readUint32LE(); - CompSize = _file->readUint32LE(); - UncompSize = _file->readUint32LE(); - - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); - Close(); - return E_FAIL; - } - - _data = new byte[UncompSize]; - if (!_data) { - Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); - delete [] CompBuffer; - Close(); - return E_FAIL; - } - _file->seek(DataOffset + _prefixSize, SEEK_SET); - _file->read(CompBuffer, CompSize); - - if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { - Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); - delete [] CompBuffer; - Close(); - return E_FAIL; - } - - delete [] CompBuffer; - _size = UncompSize; - _pos = 0; - delete _file; - _file = NULL; - } else { - _pos = 0; - _file->seek(0, SEEK_END); - _size = _file->pos() - _prefixSize; - _file->seek(_prefixSize, SEEK_SET); - } - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Close() { - if (_file) { - delete _file; - } - _file = NULL; - _pos = 0; - _size = 0; - - delete[] _data; - _data = NULL; - - _compressed = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { - if (_compressed) { - memcpy(Buffer, _data + _pos, Size); - _pos += Size; - return S_OK; - } else { - - if (_file) { - size_t count = _file->read(Buffer, Size); - _pos += count; - return S_OK; - } else return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { - // TODO: Should this really need to use uint32? - if (_compressed) { - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - return S_OK; - } else { - if (!_file) return E_FAIL; - int ret = 1; - - switch (Origin) { - case SEEK_TO_BEGIN: - ret = _file->seek(_prefixSize + Pos, SEEK_SET); - break; - case SEEK_TO_END: - ret = _file->seek(Pos, SEEK_END); - break; - case SEEK_TO_CURRENT: - ret = _file->seek(Pos, SEEK_CUR); - break; - } - if (ret == 0) { - _pos = _file->pos() - _prefixSize; - return S_OK; - } else return E_FAIL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBDiskFile::CorrectSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BDiskFile.h b/engines/wintermute/BDiskFile.h deleted file mode 100644 index 3cabe173e6..0000000000 --- a/engines/wintermute/BDiskFile.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H - - -#include "BFile.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBDiskFile : public CBFile { -public: - CBDiskFile(CBGame *inGame); - virtual ~CBDiskFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - void CorrectSlashes(char *fileName); - Common::SeekableReadStream *_file; - byte *_data; - bool _compressed; - uint32 _prefixSize; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BDynBuffer.cpp b/engines/wintermute/BDynBuffer.cpp deleted file mode 100644 index 23cd1d2584..0000000000 --- a/engines/wintermute/BDynBuffer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "BGame.h" -#include "BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase(inGame) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = InitSize; - _growBy = GrowBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::Cleanup() { - if (_buffer) free(_buffer); - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::GetSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::Init(uint32 InitSize) { - Cleanup(); - - if (InitSize == 0) InitSize = _initSize; - - _buffer = (byte *)malloc(InitSize); - if (!_buffer) { - Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); - return E_FAIL; - } - - _realSize = InitSize; - _initialized = true; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { - if (!_initialized) Init(); - - while (_offset + Size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return E_FAIL; - } - } - - memcpy(_buffer + _offset, Buffer, Size); - _offset += Size; - _size += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { - if (!_initialized) Init(); - - if (_offset + Size > _size) { - Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); - return E_FAIL; - } - - memcpy(Buffer, _buffer + _offset, Size); - _offset += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::GetDWORD() { - uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutString(const char *Val) { - if (!Val) PutString("(null)"); - else { - PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::GetString() { - uint32 len = GetDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) return NULL; - else return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutText(LPCSTR fmt, ...) { - va_list va; - - va_start(va, fmt); - PutTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { - va_list va; - - PutText("%*s", Indent, ""); - - va_start(va, fmt); - PutTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - PutBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BDynBuffer.h b/engines/wintermute/BDynBuffer.h deleted file mode 100644 index 2b4d1d97bf..0000000000 --- a/engines/wintermute/BDynBuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H - - -#include "BBase.h" - -namespace WinterMute { - -class CBDynBuffer : public CBBase { -public: - bool _initialized; - void PutText(LPCSTR fmt, ...); - void PutTextIndent(int Indent, LPCSTR fmt, ...); - uint32 GetDWORD(); - void PutDWORD(uint32 Val); - char *GetString(); - void PutString(const char *Val); - HRESULT GetBytes(byte *Buffer, uint32 Size); - HRESULT PutBytes(byte *Buffer, uint32 Size); - uint32 GetSize(); - HRESULT Init(uint32 InitSize = 0); - void Cleanup(); - uint32 _size; - byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); - virtual ~CBDynBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void PutTextForm(const char *format, va_list argptr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BEvent.cpp b/engines/wintermute/BEvent.cpp deleted file mode 100644 index 2bf77803c4..0000000000 --- a/engines/wintermute/BEvent.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "BGame.h" -#include "BFileManager.h" -#include "BEvent.h" -#include "BParser.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBEvent, false) - -////////////////////////////////////////////////////////////////////////// -CBEvent::CBEvent(CBGame *inGame): CBBase(inGame) { - _type = EVENT_NONE; - _script = NULL; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBEvent::CBEvent(CBGame *inGame, TEventType Type, char *Script): CBBase(inGame) { - _type = Type; - _script = new char [strlen(Script) + 1]; - if (_script) strcpy(_script, Script); - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBEvent::~CBEvent() { - delete[] _script; - _script = NULL; - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBEvent::GetEventName(TEventType Type) { - switch (Type) { - case EVENT_INIT: - return "INIT"; - case EVENT_SHUTDOWN: - return "SHUTDOWN"; - case EVENT_LEFT_CLICK: - return "LEFT_CLICK"; - case EVENT_RIGHT_CLICK: - return "RIGHT_CLICK"; - case EVENT_MIDDLE_CLICK: - return "MIDDLE_CLICK"; - case EVENT_LEFT_DBLCLICK: - return "LEFT_DBLCLICK"; - case EVENT_PRESS: - return "PRESS"; - case EVENT_IDLE: - return "IDLE"; - case EVENT_MOUSE_OVER: - return "MOUSE_OVER"; - case EVENT_LEFT_RELEASE: - return "LEFT_RELEASE"; - case EVENT_RIGHT_RELEASE: - return "RIGHT_RELEASE"; - case EVENT_MIDDLE_RELEASE: - return "MIDDLE_RELEASE"; - - default: - return "NONE"; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBEvent::SetScript(const char *Script) { - if (_script) delete [] _script; - - _script = new char [strlen(Script) + 1]; - if (_script) strcpy(_script, Script); -} - - -////////////////////////////////////////////////////////////////////////// -void CBEvent::SetName(const char *Name) { - if (_name) delete [] _name; - - _name = new char [strlen(Name) + 1]; - if (_name) strcpy(_name, Name); -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EVENT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(EVENT) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EVENT) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EVENT) { - Game->LOG(0, "'EVENT' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_SCRIPT: - SetScript((char *)params); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in EVENT definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_script)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BEvent.h b/engines/wintermute/BEvent.h deleted file mode 100644 index 5afd57ce3a..0000000000 --- a/engines/wintermute/BEvent.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BEVENT_H -#define WINTERMUTE_BEVENT_H - - -#include "BBase.h" -#include "dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CBEvent : public CBBase { -public: - DECLARE_PERSISTENT(CBEvent, CBBase) - void SetScript(const char *Script); - void SetName(const char *Name); - static const char *GetEventName(TEventType Type); - char *_script; - char *_name; - TEventType _type; - CBEvent(CBGame *inGame); - CBEvent(CBGame *inGame, TEventType Type, char *Script); - virtual ~CBEvent(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFader.cpp b/engines/wintermute/BFader.cpp deleted file mode 100644 index ae716f6d3e..0000000000 --- a/engines/wintermute/BFader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFader.h" -#include "BGame.h" -#include "PlatformSDL.h" -#include "common/util.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFader, false) - -////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Update() { - if (!_active) return S_OK; - - int AlphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) time = CBPlatform::GetTime() - _startTime; - else time = Game->_timer - _startTime; - - if (time >= _duration) _currentAlpha = _targetAlpha; - else { - _currentAlpha = _sourceAlpha + (float)time / (float)_duration * AlphaDelta; - } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean - - _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Display() { - if (!_active) return S_OK; - - if (_currentAlpha > 0x00) return Game->_renderer->FadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Deactivate() { - _active = false; - _ready = true; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { - _ready = false; - _active = true; - - _red = D3DCOLGetR(SourceColor); - _green = D3DCOLGetG(SourceColor); - _blue = D3DCOLGetB(SourceColor); - - _sourceAlpha = D3DCOLGetA(SourceColor); - _targetAlpha = 0; - - _duration = Duration; - _system = System; - - if (_system) _startTime = CBPlatform::GetTime(); - else _startTime = Game->_timer; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { - _ready = false; - _active = true; - - _red = D3DCOLGetR(TargetColor); - _green = D3DCOLGetG(TargetColor); - _blue = D3DCOLGetB(TargetColor); - - //_sourceAlpha = 0; - _sourceAlpha = _currentAlpha; - _targetAlpha = D3DCOLGetA(TargetColor); - - _duration = Duration; - _system = System; - - if (_system) _startTime = CBPlatform::GetTime(); - else _startTime = Game->_timer; - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBFader::GetCurrentColor() { - return DRGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_blue)); - PersistMgr->Transfer(TMEMBER(_currentAlpha)); - PersistMgr->Transfer(TMEMBER(_duration)); - PersistMgr->Transfer(TMEMBER(_green)); - PersistMgr->Transfer(TMEMBER(_red)); - PersistMgr->Transfer(TMEMBER(_sourceAlpha)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_targetAlpha)); - PersistMgr->Transfer(TMEMBER(_system)); - - if (_system && !PersistMgr->_saving) _startTime = 0; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFader.h b/engines/wintermute/BFader.h deleted file mode 100644 index 9007a95de0..0000000000 --- a/engines/wintermute/BFader.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H - - -#include "BObject.h" - -namespace WinterMute { - -class CBFader : public CBObject { -public: - bool _system; - uint32 GetCurrentColor(); - HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); - HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); - HRESULT Deactivate(); - HRESULT Display(); - HRESULT Update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFile.cpp b/engines/wintermute/BFile.cpp deleted file mode 100644 index 43b87027e2..0000000000 --- a/engines/wintermute/BFile.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFile.h" -#include "common/memstream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFile::IsEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = GetPos(); - Seek(0); - byte *data = new byte[GetSize()]; - Read(data, GetSize()); - Seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFile.h b/engines/wintermute/BFile.h deleted file mode 100644 index eca8f4a416..0000000000 --- a/engines/wintermute/BFile.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H - - -#include "BBase.h" -#include "common/str.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBFile : public CBBase { -public: - uint32 _pos; - uint32 _size; - virtual uint32 GetSize() { - return _size; - }; - virtual uint32 GetPos() { - return _pos; - }; - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; - virtual HRESULT Read(void *Buffer, uint32 Size) = 0; - virtual HRESULT Close() = 0; - virtual HRESULT Open(const Common::String &Filename) = 0; - virtual bool IsEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFileEntry.cpp b/engines/wintermute/BFileEntry.cpp deleted file mode 100644 index 447b7e85d7..0000000000 --- a/engines/wintermute/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "dcgf.h" -#include "BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFileEntry.h b/engines/wintermute/BFileEntry.h deleted file mode 100644 index 27a4f80eba..0000000000 --- a/engines/wintermute/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFileManager.cpp b/engines/wintermute/BFileManager.cpp deleted file mode 100644 index 8c14c1904f..0000000000 --- a/engines/wintermute/BFileManager.cpp +++ /dev/null @@ -1,879 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - -#define FORBIDDEN_SYMBOL_ALLOW_ALL -#include "dcgf.h" -#include "BFileManager.h" -#include "StringUtil.h" -#include "PathUtil.h" -#include "BDiskFile.h" -#include "BResourceFile.h" -#include "BSaveThumbFile.h" -#include "BFileEntry.h" -#include "BPkgFile.h" -#include "BPackage.h" -#include "BRegistry.h" -#include "BGame.h" -#include "dcpackage.h" -#include "utils.h" -#include "PlatformSDL.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/config-manager.h" -#include "common/system.h" -#include "common/fs.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { - _basePath = NULL; - - InitPaths(); - RegisterPackages(); -} - - -////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::Cleanup() { - int i; - - // delete registered paths - for (i = 0; i < _singlePaths.GetSize(); i++) - delete [] _singlePaths[i]; - _singlePaths.RemoveAll(); - - for (i = 0; i < _packagePaths.GetSize(); i++) - delete [] _packagePaths[i]; - _packagePaths.RemoveAll(); - - - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - - // close open files - for (i = 0; i < _openFiles.GetSize(); i++) { - _openFiles[i]->Close(); - delete _openFiles[i]; - } - _openFiles.RemoveAll(); - - - // delete packages - for (i = 0; i < _packages.GetSize(); i++) - delete _packages[i]; - _packages.RemoveAll(); - - delete[] _basePath; - _basePath = NULL; - - return S_OK; -} - - - -#define MAX_FILE_SIZE 10000000 -////////////////////////////////////////////////////////////////////// -byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool MustExist) { - - byte *buffer = NULL; - - CBFile *File = OpenFile(Filename); - if (!File) { - if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename); - return NULL; - } - - /* - if(File->GetSize()>MAX_FILE_SIZE){ - Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - - buffer = new byte[File->GetSize() + 1]; - if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->GetSize() + 1); - CloseFile(File); - return NULL; - } - - if (FAILED(File->Read(buffer, File->GetSize()))) { - Game->LOG(0, "Error reading file '%s'", Filename); - CloseFile(File); - delete [] buffer; - return NULL; - }; - - buffer[File->GetSize()] = '\0'; - if (Size != NULL) *Size = File->GetSize(); - CloseFile(File); - - return buffer; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { - // TODO - warning("Implement SaveFile"); -#if 0 - RestoreCurrentDir(); - - CBUtils::CreatePath(Filename, false); - - FILE *f = fopen(Filename, "wb"); - if (!f) { - Game->LOG(0, "Error opening file '%s' for writing.", Filename); - return E_FAIL; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - Game->LOG(0, "Error allocating compression buffer while saving '%s'", Filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - Game->LOG(0, "Error compressing data while saving '%s'", Filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { - // unmount all non-local packages - for (int i = 0; i < _packages.GetSize(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->Close(); - } - - - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { - if (Path == NULL || strlen(Path) < 1) return E_FAIL; - - bool slashed = (Path[strlen(Path) - 1] == '\\' || Path[strlen(Path) - 1] == '/'); - - char *buffer = new char [strlen(Path) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return E_FAIL; - - strcpy(buffer, Path); - if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); - - switch (Type) { - case PATH_SINGLE: - _singlePaths.Add(buffer); - break; - case PATH_PACKAGE: - _packagePaths.Add(buffer); - break; - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::ReloadPaths() { - // delete registered paths - for (int i = 0; i < _singlePaths.GetSize(); i++) - delete [] _singlePaths[i]; - _singlePaths.RemoveAll(); - - for (int i = 0; i < _packagePaths.GetSize(); i++) - delete [] _packagePaths[i]; - _packagePaths.RemoveAll(); - - return InitPaths(); -} - - -#define TEMP_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::InitPaths() { - RestoreCurrentDir(); - - AnsiString pathList; - int numPaths; - - // single files paths - pathList = Game->_registry->ReadString("Resource", "CustomPaths", ""); - numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - AddPath(PATH_SINGLE, path); - } - delete[] path; - path = NULL; - } - AddPath(PATH_SINGLE, ".\\"); - - - // package files paths - AddPath(PATH_PACKAGE, "./"); - - /*#ifdef __APPLE__ - // search .app path and Resources dir in the bundle - CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); - const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); - - #ifdef __IPHONE__ - AddPath(PATH_PACKAGE, pathPtr); - AddPath(PATH_SINGLE, pathPtr); - #else - char bundlePath[MAX_PATH]; - - sprintf(bundlePath, "%s/../", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); - - sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); - - - CFRelease(appUrlRef); - CFRelease(macPath); - #endif - #endif*/ - - - pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); - numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - AddPath(PATH_PACKAGE, path); - } - delete[] path; - path = NULL; - } - AddPath(PATH_PACKAGE, "data"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackages() { - RestoreCurrentDir(); - - Game->LOG(0, "Scanning packages..."); - warning("Scanning packages"); - -// TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. - RegisterPackage("data.dcp"); - RegisterPackage("english.dcp"); -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.GetSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } - - warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); - Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); -#endif - warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSignature) { -// FILE *f = fopen(Filename, "rb"); - Common::File *package = new Common::File(); - package->open(Filename); - if (!package->isOpen()) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename.c_str()); - return S_OK; - } - - uint32 AbsoluteOffset = 0; - bool BoundToExe = false; - - if (SearchSignature) { - uint32 Offset; - if (!FindPackageSignature(package, &Offset)) { - delete package; - return S_OK; - } else { - package->seek(Offset, SEEK_SET); - AbsoluteOffset = Offset; - BoundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename.c_str()); - delete package; - return S_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", Filename.c_str()); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 DirOffset; - DirOffset = package->readUint32LE(); - DirOffset += AbsoluteOffset; - package->seek(DirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(Game); - if (!pkg) return E_FAIL; - - pkg->_boundToExe = BoundToExe; - - // read package info - byte NameLength = package->readByte(); - pkg->_name = new char[NameLength]; - package->read(pkg->_name, NameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.Add(pkg); - - - // read file entries - uint32 NumFiles = package->readUint32LE(); - - for (uint32 j = 0; j < NumFiles; j++) { - char *Name; - uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - - NameLength = package->readByte(); - Name = new char[NameLength]; - package->read(Name, NameLength); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - Name[NameLength - 1] = '\0'; - - - CBPlatform::strupr(Name); - - Offset = package->readUint32LE(); - Offset += AbsoluteOffset; - Length = package->readUint32LE(); - CompLength = package->readUint32LE(); - Flags = package->readUint32LE(); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - TimeDate1 = package->readUint32LE(); - TimeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(Name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(Game); - file->_package = pkg; - file->_offset = Offset; - file->_length = Length; - file->_compressedLength = CompLength; - file->_flags = Flags; - - _files[Name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = Offset; - _filesIter->_value->_length = Length; - _filesIter->_value->_compressedLength = CompLength; - _filesIter->_value->_flags = Flags; - } - } - delete [] Name; - } - } - - - delete package; - return S_OK; -} -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool SearchSignature) { -// TODO - error("Implement RegisterPackage, this is the old one"); -#if 0 - char Filename[MAX_PATH]; - sprintf(Filename, "%s%s", Path, Name); - - FILE *f = fopen(Filename, "rb"); - if (!f) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename); - return S_OK; - } - - uint32 AbsoluteOffset = 0; - bool BoundToExe = false; - - if (SearchSignature) { - uint32 Offset; - if (!FindPackageSignature(f, &Offset)) { - fclose(f); - return S_OK; - } else { - fseek(f, Offset, SEEK_SET); - AbsoluteOffset = Offset; - BoundToExe = true; - } - } - - TPackageHeader hdr; - fread(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); - fclose(f); - return S_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 DirOffset; - fread(&DirOffset, sizeof(uint32), 1, f); - DirOffset += AbsoluteOffset; - fseek(f, DirOffset, SEEK_SET); - } - - for (int i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(Game); - if (!pkg) return E_FAIL; - - pkg->_boundToExe = BoundToExe; - - // read package info - byte NameLength; - fread(&NameLength, sizeof(byte), 1, f); - pkg->_name = new char[NameLength]; - fread(pkg->_name, NameLength, 1, f); - fread(&pkg->_cD, sizeof(byte), 1, f); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.Add(pkg); - - - // read file entries - uint32 NumFiles; - fread(&NumFiles, sizeof(uint32), 1, f); - - for (int j = 0; j < NumFiles; j++) { - char *Name; - uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - - fread(&NameLength, sizeof(byte), 1, f); - Name = new char[NameLength]; - fread(Name, NameLength, 1, f); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - Name[NameLength - 1] = '\0'; - - - CBPlatform::strupr(Name); - - fread(&Offset, sizeof(uint32), 1, f); - Offset += AbsoluteOffset; - fread(&Length, sizeof(uint32), 1, f); - fread(&CompLength, sizeof(uint32), 1, f); - fread(&Flags, sizeof(uint32), 1, f); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - fread(&TimeDate1, sizeof(uint32), 1, f); - fread(&TimeDate2, sizeof(uint32), 1, f); - } - _filesIter = _files.find(Name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(Game); - file->_package = pkg; - file->_offset = Offset; - file->_length = Length; - file->_compressedLength = CompLength; - file->_flags = Flags; - - _files[Name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = Offset; - _filesIter->_value->_length = Length; - _filesIter->_value->_compressedLength = CompLength; - _filesIter->_value->_flags = Flags; - } - } - delete [] Name; - } - } - - - fclose(f); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::GetFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::StartsWith(plainName, "xdevice_", true)) { - return StringUtil::CompareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenPackage(const char *Name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - - Common::File *ret = new Common::File(); - char Filename[MAX_PATH]; - - for (int i = 0; i < _packagePaths.GetSize(); i++) { - sprintf(Filename, "%s%s.%s", _packagePaths[i], Name, PACKAGE_EXTENSION); - ret->open(Filename); - if (ret->isOpen()) { - return ret; - } - } - - sprintf(Filename, "%s.%s", Name, PACKAGE_EXTENSION); - ret->open(Filename); - if (ret->isOpen()) { - return ret; - } - warning("CBFileManager::OpenPackage - Couldn't load file %s", Name); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenSingleFile(const char *Name) { - RestoreCurrentDir(); - - Common::File *ret = NULL; - char Filename[MAX_PATH]; - - for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Filename, "%s%s", _singlePaths[i], Name); - ret->open(Filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(Name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { - RestoreCurrentDir(); - - Common::File f; - bool found = false; - - for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Fullname, "%s%s", _singlePaths[i], Filename); - f.open(Fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(Filename); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(Fullname, Filename); - } - } - - return found; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { - char *upc_name = new char[strlen(Filename) + 1]; - strcpy(upc_name, Filename); - CBPlatform::strupr(upc_name); - - CBFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - delete [] upc_name; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { - if (strcmp(Filename, "") == 0) return NULL; - //Game->LOG(0, "open file: %s", Filename); -#ifdef __WIN32__ - if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(Filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); - } - } -#endif - - CBFile *File = OpenFileRaw(Filename); - if (File) _openFiles.Add(File); - return File; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::CloseFile(CBFile *File) { - for (int i = 0; i < _openFiles.GetSize(); i++) { - if (_openFiles[i] == File) { - _openFiles[i]->Close(); - delete _openFiles[i]; - _openFiles.RemoveAt(i); - return S_OK; - } - } - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile *CBFileManager::OpenFileRaw(const Common::String &Filename) { - RestoreCurrentDir(); - - if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile; - else { - delete SaveThumbFile; - return NULL; - } - } - - CBDiskFile *DiskFile = new CBDiskFile(Game); - if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; - - delete DiskFile; - CBPkgFile *PkgFile = new CBPkgFile(Game); - if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; - - delete PkgFile; - CBResourceFile *ResFile = new CBResourceFile(Game); - if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; - - delete ResFile; - warning("BFileManager::OpenFileRaw - Failed to open %s", Filename.c_str()); - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RestoreCurrentDir() { - if (!_basePath) return S_OK; - else { - /*if (!chdir(_basePath)) return S_OK; - else return E_FAIL;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); - return S_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SetBasePath(const char *Path) { - Cleanup(); - - if (Path) { - _basePath = new char[strlen(Path) + 1]; - strcpy(_basePath, Path); - } - - InitPaths(); - RegisterPackages(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::FindPackageSignature(Common::File *f, uint32 *Offset) { - byte buf[32768]; - - byte Signature[8]; - ((uint32 *)Signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)Signature)[1] = PACKAGE_MAGIC_2; - - uint32 FileSize = f->size(); - - int StartPos = 1024 * 1024; - - uint32 BytesRead = StartPos; - - while (BytesRead < FileSize - 16) { - int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); - f->seek(StartPos, SEEK_SET); - int ActuallyRead = f->read(buf, ToRead); - if (ActuallyRead != ToRead) return false; - - for (int i = 0; i < ToRead - 8; i++) - if (!memcmp(buf + i, Signature, 8)) { - *Offset = StartPos + i; - return true; - } - - BytesRead = BytesRead + ToRead - 16; - StartPos = StartPos + ToRead - 16; - - } - return false; - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFileManager.h b/engines/wintermute/BFileManager.h deleted file mode 100644 index 0eb7d23a47..0000000000 --- a/engines/wintermute/BFileManager.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H - - -//#include -#include "coll_templ.h" -#include "BFileEntry.h" -#include "common/archive.h" -#include "common/str.h" - -namespace Common { -class File; -} - -namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { -public: - bool FindPackageSignature(Common::File *f, uint32 *Offset); - HRESULT Cleanup(); - HRESULT SetBasePath(const char *Path); - HRESULT RestoreCurrentDir(); - char *_basePath; - bool GetFullPath(const char *Filename, char *Fullname); - CBFile *OpenFileRaw(const Common::String &filename); - HRESULT CloseFile(CBFile *File); - CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); - CBFileEntry *GetPackageEntry(const char *Filename); - Common::File *OpenSingleFile(const char *Name); - Common::File *OpenPackage(const char *Name); - HRESULT RegisterPackages(); - HRESULT InitPaths(); - HRESULT ReloadPaths(); - typedef enum { - PATH_PACKAGE, PATH_SINGLE - } TPathType; - HRESULT AddPath(TPathType Type, const char *Path); - HRESULT RequestCD(int CD, char *PackageFile, char *Filename); - HRESULT SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); - byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); - CBArray _singlePaths; - CBArray _packagePaths; - CBArray _packages; - CBArray _openFiles; - - Common::HashMap _files; -private: - HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); - HRESULT RegisterPackage(Common::String Filename, bool SearchSignature = false); - Common::HashMap::iterator _filesIter; - bool IsValidPackage(const AnsiString &fileName) const; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFont.cpp b/engines/wintermute/BFont.cpp deleted file mode 100644 index 82dfbb072b..0000000000 --- a/engines/wintermute/BFont.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFont.h" -#include "BFontBitmap.h" -#include "BParser.h" -#include "BFileManager.h" -#include "BFontTT.h" -#include "BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFont, false) - -////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { -} - - -////////////////////////////////////////////////////////////////////// -void CBFont::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::GetTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::GetTextWidth(byte *text, int MaxLenght) { - return 0; -} - -/* -////////////////////////////////////////////////////////////////////// -HRESULT CBFont::LoadFile(const char * Filename) -{ - BYTE* Buffer = Game->_fileManager->ReadWholeFile(Filename); - if(Buffer==NULL){ - Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename)+1]; - strcpy(_filename, Filename); - - if(FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBFont::LoadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - CBParser parser(Game); - - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - Game->LOG(0, "'FONT' keyword expected."); - return E_FAIL; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - Game->LOG(0, "Syntax error in FONT definition"); - return E_FAIL; - } - - return S_OK; -} -*/ - -////////////////////////////////////////////////////////////////////////// -int CBFont::GetLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFont::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { - if (IsTrueType(Game, Filename)) { - CBFontTT *Font = new CBFontTT(Game); - if (Font) { - if (FAILED(Font->LoadFile(Filename))) { - delete Font; - return NULL; - } - } - return Font; - } else { - CBFontBitmap *Font = new CBFontBitmap(Game); - if (Font) { - if (FAILED(Font->LoadFile(Filename))) { - delete Font; - return NULL; - } - } - return Font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBFont::IsTrueType(CBGame *Game, const char *Filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) return false; - - byte *WorkBuffer = Buffer; - - char *params; - CBParser parser(Game); - - bool Ret = false; - if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - Ret = true; - - delete [] Buffer; - return Ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFont.h b/engines/wintermute/BFont.h deleted file mode 100644 index 453f567c96..0000000000 --- a/engines/wintermute/BFont.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H - -#include "BObject.h" - -#define NUM_CHARACTERS 256 - -namespace WinterMute { - -class CBFont: public CBObject { -public: - DECLARE_PERSISTENT(CBFont, CBObject) - virtual int GetTextWidth(byte *text, int MaxLenght = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); - virtual int GetLetterHeight(); - - virtual void InitLoop() {}; - - CBFont(CBGame *inGame); - virtual ~CBFont(); - - static CBFont *CreateFromFile(CBGame *Game, const char *Filename); - -private: - //HRESULT LoadBuffer(byte * Buffer); - //HRESULT LoadFile(const char* Filename); - static bool IsTrueType(CBGame *Game, const char *Filename); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFontBitmap.cpp b/engines/wintermute/BFontBitmap.cpp deleted file mode 100644 index 7c659dbfad..0000000000 --- a/engines/wintermute/BFontBitmap.cpp +++ /dev/null @@ -1,542 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFontBitmap.h" -#include "StringUtil.h" -#include "BParser.h" -#include "BFrame.h" -#include "BSurface.h" -#include "BGame.h" -#include "BSubFrame.h" -#include "BFrame.h" -#include "BSprite.h" -#include "BFileManager.h" -#include "PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { - TextHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetTextHeight(byte *text, int width) { - return TextHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { - AnsiString str; - - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); - str = StringUtil::WideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (MaxLength >= 0 && str.size() > MaxLength) - str = Common::String(str.c_str(), MaxLength); - //str.substr(0, MaxLength); // TODO: Remove - - int TextWidth = 0; - for (size_t i = 0; i < str.size(); i++) { - TextWidth += GetCharWidth(str[i]); - } - - return TextWidth; -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { - if (MaxLenght == 0) return 0; - - if (text == NULL || text[0] == '\0') return _tileHeight; - - - - AnsiString str; - - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); - str = StringUtil::WideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - if (str.empty()) return 0; - - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool new_line = false; - bool long_line = false; - - if (draw) Game->_renderer->StartSpriteBatch(); - - while (!done) { - if (max_height > 0 && (NumLines + 1)*_tileHeight > max_height) { - if (draw) Game->_renderer->EndSpriteBatch(); - return NumLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (max_height < 0 || max_height / _tileHeight > 1)) { - end = index - 1; - RealLength = LineLength; - } - - if (str[index] == '\n') { - end = index - 1; - RealLength = LineLength; - new_line = true; - } - - if (LineLength + GetCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; - } - - if (str.size() == (index + 1) || (MaxLenght >= 0 && index == MaxLenght - 1)) { - done = true; - if (!new_line) { - end = index; - LineLength += GetCharWidth(str[index]); - RealLength = LineLength; - } - } else LineLength += GetCharWidth(str[index]); - - if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; - int StartX; - switch (align) { - case TAL_CENTER: - StartX = x + (width - RealLength) / 2; - break; - case TAL_RIGHT: - StartX = x + width - RealLength; - break; - case TAL_LEFT: - StartX = x; - break; - default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) DrawChar(str[i], StartX, y); - StartX += GetCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (long_line) end--; - start = end + 2; - index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; - } - } - - if (draw) Game->_renderer->EndSpriteBatch(); - - return NumLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::DrawChar(byte c, int x, int y) { - if (_fontextFix) c--; - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - RECT rect; - /* l t r b */ - int TileWidth; - if (_wholeCell) TileWidth = _tileWidth; - else TileWidth = _widths[c]; - - CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + TileWidth, (row + 1)*_tileHeight); - bool Handled = false; - if (_sprite) { - _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->DisplayTrans(x, y, rect); - } - Handled = true; - } - } - if (!Handled && _subframe) _subframe->_surface->DisplayTrans(x, y, rect); -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_FONT) { - Game->LOG(0, "'FONT' keyword expected."); - return E_FAIL; - } - Buffer = (byte *)params; - - int widths[300]; - int num = 0, default_width = 8; - int last_width = 0; - int i; - int r = 255, g = 255, b = 255; - bool custo_trans = false; - char *surface_file = NULL; - char *sprite_file = NULL; - - bool AutoWidth = false; - int SpaceWidth = 0; - int ExpandWidth = 0; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surface_file = (char *)params; - break; - - case TOKEN_SPRITE: - sprite_file = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - - case TOKEN_WIDTHS: - parser.ScanStr(params, "%D", widths, &num); - for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { - _widths[last_width] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.ScanStr(params, "%d", &default_width); - break; - - case TOKEN_WIDTHS_FRAME: - parser.ScanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.ScanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.ScanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.ScanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.ScanStr(params, "%b", &AutoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.ScanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.ScanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.ScanStr(params, "%d", &SpaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.ScanStr(params, "%d", &ExpandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in FONT definition"); - return E_FAIL; - } - - if (sprite_file != NULL) { - delete _sprite; - _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surface_file != NULL && !_sprite) { - _subframe = new CBSubFrame(Game); - if (custo_trans) _subframe->SetSurface(surface_file, false, r, g, b); - else _subframe->SetSurface(surface_file); - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - Game->LOG(0, "Incomplete font definition"); - return E_FAIL; - } - - if (AutoWidth) { - // calculate characters width - GetWidths(); - - // do we need to modify widths? - if (ExpandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + ExpandWidth; - if (NewWidth < 0) NewWidth = 0; - - _widths[i] = (byte)NewWidth; - } - } - - // handle space character - char SpaceChar = ' '; - if (_fontextFix) SpaceChar--; - - if (SpaceWidth != 0) _widths[SpaceChar] = SpaceWidth; - else { - if (_widths[SpaceChar] == ExpandWidth || _widths[SpaceChar] == 0) { - _widths[SpaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = last_width; i < NUM_CHARACTERS; i++) _widths[i] = default_width; - } - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { - - CBFont::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_numColumns)); - - PersistMgr->Transfer(TMEMBER(_subframe)); - PersistMgr->Transfer(TMEMBER(_tileHeight)); - PersistMgr->Transfer(TMEMBER(_tileWidth)); - PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER(_widthsFrame)); - - if (PersistMgr->_saving) - PersistMgr->PutBytes(_widths, sizeof(_widths)); - else - PersistMgr->GetBytes(_widths, sizeof(_widths)); - - - PersistMgr->Transfer(TMEMBER(_fontextFix)); - PersistMgr->Transfer(TMEMBER(_wholeCell)); - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetCharWidth(byte Index) { - if (_fontextFix) Index--; - return _widths[Index]; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::GetWidths() { - CBSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.GetSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.GetSize() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || FAILED(surf->StartPixelOp())) return E_FAIL; - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int min_col = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= min_col + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; - if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - min_col = MAX(col, min_col); - break; - } - } - if (min_col == _tileWidth - 1) break; - } - - _widths[i] = min_col + 1; - } - surf->EndPixelOp(); - /* - Game->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetLetterHeight() { - return _tileHeight; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFontBitmap.h b/engines/wintermute/BFontBitmap.h deleted file mode 100644 index 0079e5a916..0000000000 --- a/engines/wintermute/BFontBitmap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H - - -#include "BFont.h" - -namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { -public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) - HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(const char *Filename); - virtual int GetTextWidth(byte *text, int MaxLength = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); - virtual int GetLetterHeight(); - - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); - - - HRESULT GetWidths(); - CBSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; - bool _wholeCell; - -private: - int GetCharWidth(byte Index); - void DrawChar(byte c, int x, int y); - - int TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFontStorage.cpp b/engines/wintermute/BFontStorage.cpp deleted file mode 100644 index 67c522aabc..0000000000 --- a/engines/wintermute/BFontStorage.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFontStorage.h" -#include "BGame.h" -#include "BFont.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -// _fTLibrary = NULL; - InitFreeType(); -} - - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { - Cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontStorage::InitFreeType() { -#if 0 - FT_Error error = FT_Init_FreeType(&_fTLibrary); - if (error) { - Game->LOG(0, "Error initializing FreeType library."); - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::Cleanup(bool Warn) { - int i; - - for (i = 0; i < _fonts.GetSize(); i++) { - if (Warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); - delete _fonts[i]; - } - _fonts.RemoveAll(); - -#if 0 - if (_fTLibrary) FT_Done_FreeType(_fTLibrary); -#endif - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::InitLoop() { - for (int i = 0; i < _fonts.GetSize(); i++) { - _fonts[i]->InitLoop(); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::AddFont(const char *Filename) { - if (!Filename) return NULL; - - for (int i = 0; i < _fonts.GetSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, Filename) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - CBFont* font = new CBFont(Game); - if(!font) return NULL; - - if(FAILED(font->LoadFile(Filename))){ - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.Add(font); - return font; - } - */ - CBFont *font = CBFont::CreateFromFile(Game, Filename); - if (font) { - font->_refCount = 1; - _fonts.Add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::RemoveFont(CBFont *Font) { - if (!Font) return E_FAIL; - - for (int i = 0; i < _fonts.GetSize(); i++) { - if (_fonts[i] == Font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.RemoveAt(i); - } - break; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::Persist(CBPersistMgr *PersistMgr) { - - if (!PersistMgr->_saving) Cleanup(false); - - PersistMgr->Transfer(TMEMBER(Game)); - _fonts.Persist(PersistMgr); - - if (!PersistMgr->_saving) InitFreeType(); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFontStorage.h b/engines/wintermute/BFontStorage.h deleted file mode 100644 index 77f17f2382..0000000000 --- a/engines/wintermute/BFontStorage.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H - - -#include "BBase.h" -#include "persistent.h" -#include "coll_templ.h" - -/*#include -#include FT_FREETYPE_H*/ - -namespace WinterMute { - -class CBFont; - -class CBFontStorage : public CBBase { -public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) - HRESULT Cleanup(bool Warn = false); - HRESULT RemoveFont(CBFont *Font); - CBFont *AddFont(const char *Filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; - HRESULT InitLoop(); - - /* FT_Library GetFTLibrary() const { - return _fTLibrary; - }*/ - -private: - void InitFreeType(); - //FT_Library _fTLibrary; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFontTT.cpp b/engines/wintermute/BFontTT.cpp deleted file mode 100644 index 94fdd81d0a..0000000000 --- a/engines/wintermute/BFontTT.cpp +++ /dev/null @@ -1,889 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -//#include -//#include FT_FREETYPE_H -#include "dcgf.h" -#include "BFile.h" -#include "BFontTT.h" -#include "FontGlyphCache.h" -#include "PathUtil.h" -#include "StringUtil.h" -#include "MathUtil.h" -#include "BRenderSDL.h" -#include "BSurfaceSDL.h" -#include "BParser.h" -#include "BGame.h" -#include "BFileManager.h" -#include "utils.h" -#include "PlatformSDL.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFontTT, false) - -////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - _glyphCache = NULL; - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { - ClearCache(); - - for (int i = 0; i < _layers.GetSize(); i++) { - delete _layers[i]; - } - _layers.RemoveAll(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _font; - _font = NULL; - - delete _fallbackFont; - _fallbackFont = NULL; - - delete _glyphCache; - _glyphCache = NULL; -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::ClearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } - -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::InitLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (Game->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; - } - } -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { - WideString text; - - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (MaxLength >= 0 && text.size() > MaxLength) - text = Common::String(text.c_str(), MaxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - MeasureText(text, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetTextHeight(byte *Text, int Width) { - WideString text; - - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - - int textWidth, textHeight; - MeasureText(text, Width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { - warning("Draw text: %s", Text); - if (Text == NULL || strcmp((char *)Text, "") == 0) return; - - WideString text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (MaxLength >= 0 && text.size() > MaxLength) - text = Common::String(text.c_str(), MaxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; - - // find cached surface, if exists - int MinPriority = INT_MAX; - int MinIndex = -1; - CBSurface *Surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - MinPriority = 0; - MinIndex = i; - } else { - if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == Align && _cachedTexts[i]->_width == Width && _cachedTexts[i]->_maxHeight == MaxHeight && _cachedTexts[i]->_maxLength == MaxLength) { - Surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < MinPriority) { - MinPriority = _cachedTexts[i]->_priority; - MinIndex = i; - } - } - } - } - - // not found, create one - if (!Surface) { - Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); - if (Surface) { - // write surface to cache - if (_cachedTexts[MinIndex] != NULL) delete _cachedTexts[MinIndex]; - _cachedTexts[MinIndex] = new CBCachedTTFontText; - - _cachedTexts[MinIndex]->_surface = Surface; - _cachedTexts[MinIndex]->_align = Align; - _cachedTexts[MinIndex]->_width = Width; - _cachedTexts[MinIndex]->_maxHeight = MaxHeight; - _cachedTexts[MinIndex]->_maxLength = MaxLength; - _cachedTexts[MinIndex]->_priority = 1; - _cachedTexts[MinIndex]->_text = text; - _cachedTexts[MinIndex]->_textOffset = textOffset; - _cachedTexts[MinIndex]->_marked = true; - } - } - - - // and paint it - if (Surface) { - RECT rc; - CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight()); - for (int i = 0; i < _layers.GetSize(); i++) { - uint32 Color = _layers[i]->_color; - uint32 OrigForceAlpha = _renderer->_forceAlphaColor; - if (_renderer->_forceAlphaColor != 0) { - Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(_renderer->_forceAlphaColor)); - _renderer->_forceAlphaColor = 0; - } - Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - _renderer->_forceAlphaColor = OrigForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - TextLineList lines; - WrapText(text, width, maxHeight, lines); - - - TextLineList::iterator it; - warning("CBFontTT::RenderTextToTexture - Not ported yet"); -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); - if (SUCCEEDED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetLetterHeight() { - return GetLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::LoadBuffer(byte *Buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - Game->LOG(0, "'TTFONT' keyword expected."); - return E_FAIL; - } - Buffer = (byte *)params; - - uint32 BaseColor = 0x00000000; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.ScanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - CBUtils::SetString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.ScanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.ScanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.ScanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.ScanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = DRGBA(r, g, b, D3DCOLGetA(BaseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.ScanStr(params, "%d", &a); - BaseColor = DRGBA(D3DCOLGetR(BaseColor), D3DCOLGetG(BaseColor), D3DCOLGetB(BaseColor), a); - } - break; - - case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); - else { - delete Layer; - Layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TTFONT definition"); - return E_FAIL; - } - - // create at least one layer - if (_layers.GetSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->_color = BaseColor; - _layers.Add(Layer); - } - - if (!_fontFile) CBUtils::SetString(&_fontFile, "arial.ttf"); - - return InitFont(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.ScanStr(params, "%d", &Layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.ScanStr(params, "%d", &Layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - Layer->_color = DRGBA(r, g, b, D3DCOLGetA(Layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.ScanStr(params, "%d", &a); - Layer->_color = DRGBA(D3DCOLGetR(Layer->_color), D3DCOLGetG(Layer->_color), D3DCOLGetB(Layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) return E_FAIL; - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { - CBFont::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_isBold)); - PersistMgr->Transfer(TMEMBER(_isItalic)); - PersistMgr->Transfer(TMEMBER(_isUnderline)); - PersistMgr->Transfer(TMEMBER(_isStriked)); - PersistMgr->Transfer(TMEMBER(_fontHeight)); - PersistMgr->Transfer(TMEMBER(_fontFile)); - - - // persist layers - int NumLayers; - if (PersistMgr->_saving) { - NumLayers = _layers.GetSize(); - PersistMgr->Transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(PersistMgr); - } else { - NumLayers = _layers.GetSize(); - PersistMgr->Transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->Persist(PersistMgr); - _layers.Add(Layer); - } - } - - if (!PersistMgr->_saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _glyphCache = NULL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::AfterLoad() { - InitFont(); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::InitFont() { - if (!_fontFile) return E_FAIL; - warning("BFontTT::InitFont - Not ported yet"); - - CBFile *file = Game->_fileManager->OpenFile(_fontFile); - if (!file) { - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); - file = Game->_fileManager->OpenFile((char *)fontFileName.c_str(), false); - if (!file) { - Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return E_FAIL; - } - } - warning("I guess we got a file"); - if (file) { - //_font = Graphics::loadTTFFont(*file->getMemStream(), 12); - } else { - _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); - } - return S_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - Game->_fileManager->CloseFile(file); - return E_FAIL; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return E_FAIL; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// I/O bridge between FreeType and WME file system -////////////////////////////////////////////////////////////////////////// -/* -unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return 0; - - f->Seek(offset, SEEK_TO_BEGIN); - if (count) { - uint32 oldPos = f->GetPos(); - f->Read(buffer, count); - return f->GetPos() - oldPos; - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::FTCloseProc(FT_Stream stream) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return; - - CBGame *Game = f->Game; - - Game->_fileManager->CloseFile(f); - stream->descriptor.pointer = NULL; -}*/ - - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines) { - int currWidth = 0; - wchar_t prevChar = L'\0'; - int prevSpaceIndex = -1; - int prevSpaceWidth = 0; - int lineStartIndex = 0; - - PrepareGlyphs(text); - - for (size_t i = 0; i < text.size(); i++) { - wchar_t ch = text[i]; - - if (ch == L' ') { - prevSpaceIndex = i; - prevSpaceWidth = currWidth; - } - - int charWidth = 0; - - if (ch != L'\n') { - GlyphInfo *glyphInfo = GetGlyphCache()->GetGlyph(ch); - if (!glyphInfo) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - prevChar = ch; - - charWidth = (int)(glyphInfo->GetAdvanceX() + kerning); - } - - bool lineTooLong = maxWidth >= 0 && currWidth + charWidth > maxWidth; - bool breakOnSpace = false; - - // we can't fit even a single character - if (lineTooLong && currWidth == 0) break; - - - if (ch == L'\n' || i == text.size() - 1 || lineTooLong) { - int breakPoint, breakWidth; - - if (prevSpaceIndex >= 0 && lineTooLong) { - breakPoint = prevSpaceIndex; - breakWidth = prevSpaceWidth; - breakOnSpace = true; - } else { - breakPoint = i; - breakWidth = currWidth; - - breakOnSpace = (ch == L'\n'); - - // we're at the end - if (i == text.size() - 1) { - breakPoint++; - breakWidth += charWidth; - } - } - - if (maxHeight >= 0 && (lines.size() + 1) * GetLineHeight() > maxHeight) break; - - //WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); // TODO: Remove - WideString line = Common::String(text.c_str() + lineStartIndex, breakPoint - lineStartIndex); - lines.push_back(new TextLine(line, breakWidth)); - - currWidth = 0; - prevChar = L'\0'; - prevSpaceIndex = -1; - - if (breakOnSpace) breakPoint++; - - lineStartIndex = breakPoint; - i = breakPoint - 1; - - continue; - } - - //if (ch == L' ' && currLine.empty()) continue; - currWidth += charWidth; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - TextLineList lines; - WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * GetLineHeight()); - textWidth = 0; - - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { - GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); - GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); -#if 0 - if (!infoLeft || !infoRight) return 0; - - FT_Vector delta; - FT_Error error = FT_Get_Kerning(_fTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); - if (error) return 0; - - return delta.x * (1.0f / 64.0f); -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::PrepareGlyphs(const WideString &text) { - // make sure we have all the glyphs we need - for (size_t i = 0; i < text.size(); i++) { - wchar_t ch = text[i]; - if (!_glyphCache->HasGlyph(ch)) CacheGlyph(ch); - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::CacheGlyph(wchar_t ch) { -#if 0 - FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); - if (!glyphIndex) return; - - FT_Error error = FT_Load_Glyph(_fTFace, glyphIndex, FT_LOAD_DEFAULT); - if (error) return; - - error = FT_Render_Glyph(_fTFace->glyph, FT_RENDER_MODE_NORMAL); - if (error) return; - - byte *pixels = _fTFace->glyph->bitmap.buffer; - size_t stride = _fTFace->glyph->bitmap.pitch; - - - // convert from monochrome to grayscale if needed - byte *tempBuffer = NULL; - if (pixels != NULL && _fTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - tempBuffer = new byte[_fTFace->glyph->bitmap.width * _fTFace->glyph->bitmap.rows]; - for (int j = 0; j < _fTFace->glyph->bitmap.rows; j++) { - int rowOffset = stride * j; - for (int i = 0; i < _fTFace->glyph->bitmap.width; i++) { - int byteOffset = i / 8; - int bitOffset = 7 - (i % 8); - byte bit = (pixels[rowOffset + byteOffset] & (1 << bitOffset)) >> bitOffset; - tempBuffer[_fTFace->glyph->bitmap.width * j + i] = 255 * bit; - } - } - - pixels = tempBuffer; - stride = _fTFace->glyph->bitmap.width; - } - - // add glyph to cache - _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); - - if (tempBuffer) delete [] tempBuffer; -#endif -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFontTT.h b/engines/wintermute/BFontTT.h deleted file mode 100644 index c1bd7e7023..0000000000 --- a/engines/wintermute/BFontTT.h +++ /dev/null @@ -1,193 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H - -#include "BFontStorage.h" -#include "BFont.h" -#include "BSurface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace WinterMute { - -class FontGlyphCache; - -class CBFontTT : public CBFont { -private: - ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - CBSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - CBCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~CBCachedTTFontText() { - if (_surface) delete _surface; - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { - public: - CBTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_color)); - return S_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString &GetText() const { - return _text; - } - int GetWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - -public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); - - virtual int GetTextWidth(byte *text, int MaxLenght = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); - virtual int GetLetterHeight(); - - HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(const char *Filename); - - /* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); - static void FTCloseProc(FT_Stream stream);*/ - - FontGlyphCache *GetGlyphCache() { - return _glyphCache; - } - - float GetLineHeight() const { - return _lineHeight; - } - - void AfterLoad(); - void InitLoop(); - -private: - HRESULT ParseLayer(CBTTFontLayer *Layer, byte *Buffer); - - void WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - float GetKerning(wchar_t leftChar, wchar_t rightChar); - void PrepareGlyphs(const WideString &text); - void CacheGlyph(wchar_t ch); - - CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - - - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - HRESULT InitFont(); - //FT_Stream _fTStream; - //FT_Face _fTFace; - Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - FontGlyphCache *_glyphCache; - - float _ascender; - float _descender; - float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - CBArray _layers; - void ClearCache(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BFrame.cpp b/engines/wintermute/BFrame.cpp deleted file mode 100644 index 7d0fe61fd4..0000000000 --- a/engines/wintermute/BFrame.cpp +++ /dev/null @@ -1,708 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BFrame.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BSoundMgr.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFrame, false) - -////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { - delete _sound; - _sound = NULL; - - int i; - - for (i = 0; i < _subframes.GetSize(); i++) delete _subframes[i]; - _subframes.RemoveAll(); - - for (i = 0; i < _applyEvent.GetSize(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { - HRESULT res; - - for (int i = 0; i < _subframes.GetSize(); i++) { - res = _subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); - if (FAILED(res)) return res; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { - if (_sound && !Muted) { - if (Owner) Owner->UpdateOneSound(_sound); - _sound->Play(); - /* - if(Game->_state==GAME_FROZEN) - { - _sound->Pause(true); - } - */ - } - if (Owner) { - for (int i = 0; i < _applyEvent.GetSize(); i++) { - Owner->ApplyEvent(_applyEvent[i]); - } - } - return S_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(DELAY) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(MOVE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(SUBFRAME) -TOKEN_DEF(SOUND) -TOKEN_DEF(KEYFRAME) -TOKEN_DEF(DECORATION) -TOKEN_DEF(APPLY_EVENT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_EXPANDED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(KILL_SOUND) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(DELAY) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(MOVE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(SUBFRAME) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(KEYFRAME) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(APPLY_EVENT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_EXPANDED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(KILL_SOUND) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - RECT rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - int HotspotX = 0, HotspotY = 0; - bool custo_trans = false; - bool editor_selected = false; - bool Is2DOnly = false; - bool Is3DOnly = false; - bool Decoration = false; - bool MirrorX = false; - bool MirrorY = false; - CBPlatform::SetRectEmpty(&rect); - char *surface_file = NULL; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_DELAY: - parser.ScanStr(params, "%d", &_delay); - break; - - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - - case TOKEN_RECT: - parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &HotspotX, &HotspotY); - break; - - case TOKEN_MOVE: - parser.ScanStr(params, "%d,%d", &_moveX, &_moveY); - break; - - case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &Is2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &Is3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &MirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &MirrorY); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &editor_selected); - break; - - case TOKEN_EDITOR_EXPANDED: - parser.ScanStr(params, "%b", &_editorExpanded); - break; - - case TOKEN_KILL_SOUND: - parser.ScanStr(params, "%b", &_killSound); - break; - - case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(Game); - if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { - delete subframe; - cmd = PARSERR_GENERIC; - } else _subframes.Add(subframe); - } - break; - - case TOKEN_SOUND: { - if (_sound) { - delete _sound; - _sound = NULL; - } - _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->SetSound(params, SOUND_SFX, false))) { - if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); - delete _sound; - _sound = NULL; - } - } - break; - - case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.Add(Event); - } - break; - - case TOKEN_KEYFRAME: - parser.ScanStr(params, "%b", &_keyframe); - break; - - case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &Decoration); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in FRAME definition"); - return E_FAIL; - } - - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading FRAME definition"); - return E_FAIL; - } - - - CBSubFrame *sub = new CBSubFrame(Game); - if (surface_file != NULL) { - if (custo_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else sub->SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); - - if (!sub->_surface) { - delete sub; - Game->LOG(0, "Error loading SUBFRAME"); - return E_FAIL; - } - - sub->_alpha = DRGBA(ar, ag, ab, alpha); - if (custo_trans) sub->_transparent = DRGBA(r, g, b, 0xFF); - } - - if (CBPlatform::IsRectEmpty(&rect)) sub->SetDefaultRect(); - else sub->_rect = rect; - - sub->_hotspotX = HotspotX; - sub->_hotspotY = HotspotY; - sub->_2DOnly = Is2DOnly; - sub->_3DOnly = Is3DOnly; - sub->_decoration = Decoration; - sub->_mirrorX = MirrorX; - sub->_mirrorY = MirrorY; - - - sub->_editorSelected = editor_selected; - _subframes.InsertAt(0, sub); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; - CBPlatform::SetRectEmpty(Rect); - - RECT SubRect; - - for (int i = 0; i < _subframes.GetSize(); i++) { - _subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); - CBPlatform::UnionRect(Rect, Rect, &SubRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "FRAME {\n"); - Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", _delay); - - if (_moveX != 0 || _moveY != 0) - Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - - if (_sound && _sound->_soundFilename) - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - - Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - - if (_killSound) - Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - - if (_editorExpanded) - Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - - if (_subframes.GetSize() > 0) _subframes[0]->SaveAsText(Buffer, Indent, false); - - int i; - for (i = 1; i < _subframes.GetSize(); i++) { - _subframes[i]->SaveAsText(Buffer, Indent + 2); - } - - for (i = 0; i < _applyEvent.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - CBBase::SaveAsText(Buffer, Indent + 2); - - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); - - _applyEvent.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_delay)); - PersistMgr->Transfer(TMEMBER(_editorExpanded)); - PersistMgr->Transfer(TMEMBER(_keyframe)); - PersistMgr->Transfer(TMEMBER(_killSound)); - PersistMgr->Transfer(TMEMBER(_moveX)); - PersistMgr->Transfer(TMEMBER(_moveY)); - PersistMgr->Transfer(TMEMBER(_sound)); - _subframes.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetSound") == 0) { - Stack->CorrectParams(0); - - if (_sound && _sound->_soundFilename) Stack->PushString(_sound->_soundFilename); - else Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSound") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - delete _sound; - _sound = NULL; - - if (!Val->IsNULL()) { - _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->SetSound(Val->GetString(), SOUND_SFX, false))) { - Stack->PushBool(false); - delete _sound; - _sound = NULL; - } else Stack->PushBool(true); - } else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSubframe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetSubframe") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= _subframes.GetSize()) { - Script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushNative(_subframes[Index], true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteSubframe") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - if (Val->IsInt()) { - int Index = Val->GetInt(-1); - if (Index < 0 || Index >= _subframes.GetSize()) { - Script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); - } - } else { - CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); - for (int i = 0; i < _subframes.GetSize(); i++) { - if (_subframes[i] == Sub) { - delete _subframes[i]; - _subframes.RemoveAt(i); - break; - } - } - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSubframe") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); - - CBSubFrame *Sub = new CBSubFrame(Game); - if (Filename != NULL) { - Sub->SetSurface(Filename); - Sub->SetDefaultRect(); - } - _subframes.Add(Sub); - - Stack->PushNative(Sub, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertSubframe") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - if (Index < 0) Index = 0; - - CScValue *Val = Stack->Pop(); - const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); - - CBSubFrame *Sub = new CBSubFrame(Game); - if (Filename != NULL) { - Sub->SetSurface(Filename); - } - - if (Index >= _subframes.GetSize()) _subframes.Add(Sub); - else _subframes.InsertAt(Index, Sub); - - Stack->PushNative(Sub, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSubframe") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= _applyEvent.GetSize()) { - Script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushString(_applyEvent[Index]); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddEvent") == 0) { - Stack->CorrectParams(1); - const char *Event = Stack->Pop()->GetString(); - for (int i = 0; i < _applyEvent.GetSize(); i++) { - if (scumm_stricmp(_applyEvent[i], Event) == 0) { - Stack->PushNULL(); - return S_OK; - } - } - _applyEvent.Add(Event); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteEvent") == 0) { - Stack->CorrectParams(1); - const char *Event = Stack->Pop()->GetString(); - for (int i = 0; i < _applyEvent.GetSize(); i++) { - if (scumm_stricmp(_applyEvent[i], Event) == 0) { - delete [] _applyEvent[i]; - _applyEvent.RemoveAt(i); - break; - } - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::ScGetProperty(const char *Name) { - if (!_scValue) _scValue = new CScValue(Game); - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("frame"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Delay") == 0) { - _scValue->SetInt(_delay); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyframe") == 0) { - _scValue->SetBool(_keyframe); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KillSounds") == 0) { - _scValue->SetBool(_killSound); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveX") == 0) { - _scValue->SetInt(_moveX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveY") == 0) { - _scValue->SetInt(_moveY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumSubframes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumSubframes") == 0) { - _scValue->SetInt(_subframes.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumEvents") == 0) { - _scValue->SetInt(_applyEvent.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScGetProperty(Name); - else return CBScriptable::ScGetProperty(Name); - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Delay") == 0) { - _delay = MAX(0, Value->GetInt()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyframe") == 0) { - _keyframe = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KillSounds") == 0) { - _killSound = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveX") == 0) { - _moveX = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveY") == 0) { - _moveY = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScSetProperty(Name, Value); - else return CBScriptable::ScSetProperty(Name, Value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBFrame::ScToString() { - return "[frame]"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BFrame.h b/engines/wintermute/BFrame.h deleted file mode 100644 index 086a6106b3..0000000000 --- a/engines/wintermute/BFrame.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H - -#include "BScriptable.h" -#include "coll_templ.h" - -namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { -public: - bool _killSound; - bool _keyframe; - HRESULT OneTimeDisplay(CBObject *Owner, bool Muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; - bool _editorExpanded; - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - int _moveY; - int _moveX; - uint32 _delay; - CBArray _subframes; - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); - - CBFrame(CBGame *inGame); - virtual ~CBFrame(); - - CBArray _applyEvent; - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BGame.cpp b/engines/wintermute/BGame.cpp deleted file mode 100644 index 59d8f2b4fe..0000000000 --- a/engines/wintermute/BGame.cpp +++ /dev/null @@ -1,4537 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFader.h" -#include "engines/wintermute/BFile.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BFontTT.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BImage.h" -#include "engines/wintermute/BKeyboardState.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BQuickMsg.h" -#include "engines/wintermute/BRegistry.h" -#include "engines/wintermute/BRenderSDL.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSoundMgr.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BSurfaceSDL.h" -#include "engines/wintermute/BTransitionMgr.h" -#include "engines/wintermute/BViewport.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BSaveThumbHelper.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/crc.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/SXArray.h" -#include "engines/wintermute/scriptables/SXDate.h" -#include "engines/wintermute/scriptables/SXFile.h" -#include "engines/wintermute/scriptables/SXMemBuffer.h" -#include "engines/wintermute/scriptables/SxObject.h" -#include "engines/wintermute/scriptables/SXMath.h" -#include "engines/wintermute/scriptables/SXStore.h" -#include "engines/wintermute/scriptables/SXString.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/keyboard.h" - -#ifdef __IPHONEOS__ -# include "ios_utils.h" -#endif - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBGame, true) - - -////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _fileManager = NULL; - _transMgr = NULL; - _debugMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _dEBUG_LogFile = NULL; - _dEBUG_DebugMode = false; - _dEBUG_AbsolutePathWarning = true; - _dEBUG_ShowFPS = false; - - _systemFont = NULL; - _videoFont = NULL; - - _mainObject = NULL; - _activeObject = NULL; - - _fader = NULL; - - _offsetX = _offsetY = 0; - _offsetPercentX = _offsetPercentY = 0.0f; - - _subtitles = true; - _videoSubtitles = true; - - _timer = 0; - _timerDelta = 0; - _timerLast = 0; - - _liveTimer = 0; - _liveTimerDelta = 0; - _liveTimerLast = 0; - - _sequence = 0; - - _mousePos.x = _mousePos.y = 0; - _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; - _capturedObject = NULL; - - // FPS counters - _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - - _cursorNoninteractive = NULL; - - _useD3D = false; - - srand((unsigned)time(NULL)); - - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - _settingsResWidth = 800; - _settingsResHeight = 600; - _settingsRequireAcceleration = false; - _settingsRequireSound = false; - _settingsTLMode = 0; - _settingsAllowWindowed = true; - _settingsGameFile = NULL; - _settingsAllowAdvanced = false; - _settingsAllowAccessTab = true; - _settingsAllowAboutTab = true; - _settingsAllowDesktopRes = false; - - _editorForceScripts = false; - _editorAlwaysRegister = false; - - _focusedWindow = NULL; - - _loadInProgress = false; - - _quitting = false; - _loading = false; - _scheduledLoadSlot = -1; - - _personalizedSave = false; - _compressedSavegames = true; - - _editorMode = false; - _doNotExpandStrings = false; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - _smartCache = false; - _surfaceGCCycleTime = 10000; - - _reportTextureFormat = false; - - _viewportSP = -1; - - _subtitlesSpeed = 70; - - _resourceModule = NULL; - - _forceNonStreamedSounds = false; - - _thumbnailWidth = _thumbnailHeight = 0; - - _indicatorDisplay = false; - _indicatorColor = DRGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _richSavedGames = false; - _savedGameExt = NULL; - CBUtils::SetString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _localSaveDir = NULL; - CBUtils::SetString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - CBPlatform::SetRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _autoSaveSlot = 999; - _cursorHidden = false; - -#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else - _touchInterface = false; - _constrainedMemory = false; -#endif - - _store = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - GetDebugMgr()->OnGameShutdown(); - - _registry->WriteBool("System", "LastRun", true); - - Cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _saveLoadImage; - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _soundMgr; - delete _debugMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _fileManager; - delete _registry; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _saveLoadImage = NULL; - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _soundMgr = NULL; - _debugMgr = NULL; - - _renderer = NULL; - _fileManager = NULL; - _registry = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - CBPlatform::OutputDebugString("--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Cleanup() { - int i; - - delete _loadingIcon; - _loadingIcon = NULL; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - for (i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete _music[i]; - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - UnregisterObject(_store); - _store = NULL; - - UnregisterObject(_fader); - _fader = NULL; - - for (i = 0; i < _regObjects.GetSize(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.RemoveAll(); - - _windows.RemoveAll(); // refs only - _focusedWindow = NULL; // ref only - - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (i = 0; i < _scripts.GetSize(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->Finish(); - } - _scripts.RemoveAll(); - - _fontStorage->RemoveFont(_systemFont); - _systemFont = NULL; - - _fontStorage->RemoveFont(_videoFont); - _videoFont = NULL; - - for (i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; - _quickMessages.RemoveAll(); - - _viewportStack.RemoveAll(); - _viewportSP = -1; - - delete[] _name; - delete[] _filename; - _name = NULL; - _filename = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize1() { - _surfaceStorage = new CBSurfaceStorage(this); - if (_surfaceStorage == NULL) goto init_fail; - - _fontStorage = new CBFontStorage(this); - if (_fontStorage == NULL) goto init_fail; - - _fileManager = new CBFileManager(this); - if (_fileManager == NULL) goto init_fail; - - _soundMgr = new CBSoundMgr(this); - if (_soundMgr == NULL) goto init_fail; - - _debugMgr = new CBDebugger(this); - if (_debugMgr == NULL) goto init_fail; - - _mathClass = new CSXMath(this); - if (_mathClass == NULL) goto init_fail; - - _scEngine = new CScEngine(this); - if (_scEngine == NULL) goto init_fail; - - _transMgr = new CBTransitionMgr(this); - if (_transMgr == NULL) goto init_fail; - - _keyboardState = new CBKeyboardState(this); - if (_keyboardState == NULL) goto init_fail; - - _fader = new CBFader(this); - if (_fader == NULL) goto init_fail; - RegisterObject(_fader); - - _store = new CSXStore(this); - if (_store == NULL) goto init_fail; - RegisterObject(_store); - - return S_OK; - -init_fail: - if (_mathClass) delete _mathClass; - if (_store) delete _store; - if (_keyboardState) delete _keyboardState; - if (_transMgr) delete _transMgr; - if (_debugMgr) delete _debugMgr; - if (_surfaceStorage) delete _surfaceStorage; - if (_fontStorage) delete _fontStorage; - if (_soundMgr) delete _soundMgr; - if (_fileManager) delete _fileManager; - if (_scEngine) delete _scEngine; - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize2() { // we know whether we are going to be accelerated - _renderer = new CBRenderSDL(this); - if (_renderer == NULL) goto init_fail; - - return S_OK; - -init_fail: - if (_renderer) delete _renderer; - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *Filename) { - _dEBUG_DebugMode = true; - -#ifndef __IPHONEOS__ - if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); - else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); - - if (!_dEBUG_LogFile) { - AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); - _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); - } - - if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); -#endif - - time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); -#endif - - LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - - AnsiString platform = CBPlatform::GetPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { - if (_dEBUG_LogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - fclose((FILE *)_dEBUG_LogFile); - _dEBUG_LogFile = NULL; - } - _dEBUG_DebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { -#ifndef __IPHONEOS__ - if (!_dEBUG_DebugMode) return; -#endif - time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - char buff[512]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - -#ifdef __IPHONEOS__ - printf("%02d:%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, buff); - fflush(stdout); -#else - if (_dEBUG_LogFile == NULL) return; - - // redirect to an engine's own callback - if (_engineLogCallback) { - _engineLogCallback(buff, res, _engineLogCallbackData); - } - if (_debugMgr) _debugMgr->OnLog(res, buff); - - warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fflush((FILE *)_dEBUG_LogFile); -#endif - - //QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback, void *Data) { - _engineLogCallback = Callback; - _engineLogCallbackData = Data; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitLoop() { - _viewportSP = -1; - - _currentTime = CBPlatform::GetTime(); - - GetDebugMgr()->OnGameTick(); - _renderer->InitLoop(); - _soundMgr->initLoop(); - UpdateMusicCrossfade(); - - _surfaceStorage->InitLoop(); - _fontStorage->InitLoop(); - - - //_activeObject = NULL; - - // count FPS - _deltaTime = _currentTime - _lastTime; - _lastTime = _currentTime; - _fpsTime += _deltaTime; - - _liveTimerDelta = _liveTimer - _liveTimerLast; - _liveTimerLast = _liveTimer; - _liveTimer += MIN((uint32)1000, _deltaTime); - - if (_state != GAME_FROZEN) { - _timerDelta = _timer - _timerLast; - _timerLast = _timer; - _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; - - _framesRendered++; - if (_fpsTime > 1000) { - _fps = _framesRendered; - _framesRendered = 0; - _fpsTime = 0; - } - //Game->LOG(0, "%d", _fps); - - GetMousePos(&_mousePos); - - _focusedWindow = NULL; - for (int i = _windows.GetSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - UpdateSounds(); - - if (_fader) _fader->Update(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitInput(HINSTANCE hInst, HWND hWnd) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBGame::GetSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::SetOffset(int OffsetX, int OffsetY) { - _offsetX = OffsetX; - _offsetY = OffsetY; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::GetOffset(int *OffsetX, int *OffsetY) { - if (OffsetX != NULL) *OffsetX = _offsetX; - if (OffsetY != NULL) *OffsetY = _offsetY; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SYSTEM_FONT) -TOKEN_DEF(VIDEO_FONT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(ACTIVE_CURSOR) -TOKEN_DEF(NONINTERACTIVE_CURSOR) -TOKEN_DEF(STRING_TABLE) -TOKEN_DEF(RESOLUTION) -TOKEN_DEF(SETTINGS) -TOKEN_DEF(REQUIRE_3D_ACCELERATION) -TOKEN_DEF(REQUIRE_SOUND) -TOKEN_DEF(HWTL_MODE) -TOKEN_DEF(ALLOW_WINDOWED_MODE) -TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) -TOKEN_DEF(ALLOW_ABOUT_TAB) -TOKEN_DEF(ALLOW_ADVANCED) -TOKEN_DEF(ALLOW_DESKTOP_RES) -TOKEN_DEF(REGISTRY_PATH) -TOKEN_DEF(PERSONAL_SAVEGAMES) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(SUBTITLES_SPEED) -TOKEN_DEF(SUBTITLES) -TOKEN_DEF(VIDEO_SUBTITLES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(THUMBNAIL_WIDTH) -TOKEN_DEF(THUMBNAIL_HEIGHT) -TOKEN_DEF(INDICATOR_X) -TOKEN_DEF(INDICATOR_Y) -TOKEN_DEF(INDICATOR_WIDTH) -TOKEN_DEF(INDICATOR_HEIGHT) -TOKEN_DEF(INDICATOR_COLOR) -TOKEN_DEF(SAVE_IMAGE_X) -TOKEN_DEF(SAVE_IMAGE_Y) -TOKEN_DEF(SAVE_IMAGE) -TOKEN_DEF(LOAD_IMAGE_X) -TOKEN_DEF(LOAD_IMAGE_Y) -TOKEN_DEF(LOAD_IMAGE) -TOKEN_DEF(LOCAL_SAVE_DIR) -TOKEN_DEF(RICH_SAVED_GAMES) -TOKEN_DEF(SAVED_GAME_EXT) -TOKEN_DEF(GUID) -TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SYSTEM_FONT) - TOKEN_TABLE(VIDEO_FONT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(ACTIVE_CURSOR) - TOKEN_TABLE(NONINTERACTIVE_CURSOR) - TOKEN_TABLE(PERSONAL_SAVEGAMES) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(SUBTITLES_SPEED) - TOKEN_TABLE(SUBTITLES) - TOKEN_TABLE(VIDEO_SUBTITLES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(THUMBNAIL_WIDTH) - TOKEN_TABLE(THUMBNAIL_HEIGHT) - TOKEN_TABLE(INDICATOR_X) - TOKEN_TABLE(INDICATOR_Y) - TOKEN_TABLE(INDICATOR_WIDTH) - TOKEN_TABLE(INDICATOR_HEIGHT) - TOKEN_TABLE(INDICATOR_COLOR) - TOKEN_TABLE(SAVE_IMAGE_X) - TOKEN_TABLE(SAVE_IMAGE_Y) - TOKEN_TABLE(SAVE_IMAGE) - TOKEN_TABLE(LOAD_IMAGE_X) - TOKEN_TABLE(LOAD_IMAGE_Y) - TOKEN_TABLE(LOAD_IMAGE) - TOKEN_TABLE(LOCAL_SAVE_DIR) - TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_GAME) { - Game->LOG(0, "'GAME' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->RemoveFont(_systemFont); - _systemFont = NULL; - - _systemFont = Game->_fontStorage->AddFont((char *)params); - break; - - case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->RemoveFont(_videoFont); - _videoFont = NULL; - - _videoFont = Game->_fontStorage->AddFont((char *)params); - break; - - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ACTIVE_CURSOR: - delete _activeCursor; - _activeCursor = NULL; - _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->LoadFile((char *)params))) { - delete _activeCursor; - _activeCursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NONINTERACTIVE_CURSOR: - delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile((char *)params))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PERSONAL_SAVEGAMES: - parser.ScanStr((char *)params, "%b", &_personalizedSave); - break; - - case TOKEN_SUBTITLES: - parser.ScanStr((char *)params, "%b", &_subtitles); - break; - - case TOKEN_SUBTITLES_SPEED: - parser.ScanStr((char *)params, "%d", &_subtitlesSpeed); - break; - - case TOKEN_VIDEO_SUBTITLES: - parser.ScanStr((char *)params, "%b", &_videoSubtitles); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - case TOKEN_THUMBNAIL_WIDTH: - parser.ScanStr((char *)params, "%d", &_thumbnailWidth); - break; - - case TOKEN_THUMBNAIL_HEIGHT: - parser.ScanStr((char *)params, "%d", &_thumbnailHeight); - break; - - case TOKEN_INDICATOR_X: - parser.ScanStr((char *)params, "%d", &_indicatorX); - break; - - case TOKEN_INDICATOR_Y: - parser.ScanStr((char *)params, "%d", &_indicatorY); - break; - - case TOKEN_INDICATOR_COLOR: { - int r, g, b, a; - parser.ScanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = DRGBA(r, g, b, a); - } - break; - - case TOKEN_INDICATOR_WIDTH: - parser.ScanStr((char *)params, "%d", &_indicatorWidth); - break; - - case TOKEN_INDICATOR_HEIGHT: - parser.ScanStr((char *)params, "%d", &_indicatorHeight); - break; - - case TOKEN_SAVE_IMAGE: - CBUtils::SetString(&_saveImageName, (char *)params); - break; - - case TOKEN_SAVE_IMAGE_X: - parser.ScanStr((char *)params, "%d", &_saveImageX); - break; - - case TOKEN_SAVE_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &_saveImageY); - break; - - case TOKEN_LOAD_IMAGE: - CBUtils::SetString(&_loadImageName, (char *)params); - break; - - case TOKEN_LOAD_IMAGE_X: - parser.ScanStr((char *)params, "%d", &_loadImageX); - break; - - case TOKEN_LOAD_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &_loadImageY); - break; - - case TOKEN_LOCAL_SAVE_DIR: - CBUtils::SetString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.ScanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("system_font.fnt"); - - - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in GAME definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading GAME definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LOG") == 0) { - Stack->CorrectParams(1); - LOG(0, Stack->Pop()->GetString()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { - HRESULT res = CBObject::ScCallMethod(Script, Stack, ThisStack, Name); - SetWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // Msg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Msg") == 0) { - Stack->CorrectParams(1); - QuickMessage(Stack->Pop()->GetString()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RunScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RunScript") == 0) { - Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - Stack->CorrectParams(1); - if (FAILED(AddScript(Stack->Pop()->GetString()))) - Stack->PushBool(false); - else - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadStringTable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadStringTable") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - CScValue *Val = Stack->Pop(); - - bool ClearOld; - if (Val->IsNULL()) ClearOld = true; - else ClearOld = Val->GetBool(); - - if (FAILED(_stringTable->LoadFile(Filename, ClearOld))) - Stack->PushBool(false); - else - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ValidObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ValidObject") == 0) { - Stack->CorrectParams(1); - CBScriptable *obj = Stack->Pop()->GetNative(); - if (ValidObject((CBObject *) obj)) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); - ResetContent(); - Stack->PushNULL(); - - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - CBObject *obj = (CBObject *)val->GetNative(); - UnregisterObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadWindow") == 0) { - Stack->CorrectParams(1); - CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->LoadFile(Stack->Pop()->GetString()))) { - _windows.Add(win); - RegisterObject(win); - Stack->PushNative(win, true); - } else { - delete win; - win = NULL; - Stack->PushNULL(); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ExpandString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExpandString") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - char *str = new char[strlen(val->GetString()) + 1]; - strcpy(str, val->GetString()); - _stringTable->Expand(&str); - Stack->PushString(str); - delete [] str; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayMusic / PlayMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayMusic") == 0 || strcmp(Name, "PlayMusicChannel") == 0) { - int Channel = 0; - if (strcmp(Name, "PlayMusic") == 0) Stack->CorrectParams(3); - else { - Stack->CorrectParams(4); - Channel = Stack->Pop()->GetInt(); - } - - const char *Filename = Stack->Pop()->GetString(); - CScValue *ValLooping = Stack->Pop(); - bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); - - CScValue *ValLoopStart = Stack->Pop(); - uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); - - - if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopMusic / StopMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopMusic") == 0 || strcmp(Name, "StopMusicChannel") == 0) { - int Channel = 0; - - if (strcmp(Name, "StopMusic") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (FAILED(StopMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic / PauseMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0 || strcmp(Name, "PauseMusicChannel") == 0) { - int Channel = 0; - - if (strcmp(Name, "PauseMusic") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (FAILED(PauseMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeMusic / ResumeMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeMusic") == 0 || strcmp(Name, "ResumeMusicChannel") == 0) { - int Channel = 0; - if (strcmp(Name, "ResumeMusic") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (FAILED(ResumeMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusic / GetMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusic") == 0 || strcmp(Name, "GetMusicChannel") == 0) { - int Channel = 0; - if (strcmp(Name, "GetMusic") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) Stack->PushNULL(); - else { - if (!_music[Channel] || !_music[Channel]->_soundFilename) Stack->PushNULL(); - else Stack->PushString(_music[Channel]->_soundFilename); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicPosition / SetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMusicPosition") == 0 || strcmp(Name, "SetMusicChannelPosition") == 0 || strcmp(Name, "SetMusicPositionChannel") == 0) { - int Channel = 0; - if (strcmp(Name, "SetMusicPosition") == 0) Stack->CorrectParams(1); - else { - Stack->CorrectParams(2); - Channel = Stack->Pop()->GetInt(); - } - - uint32 Time = Stack->Pop()->GetInt(); - - if (FAILED(SetMusicStartTime(Channel, Time))) Stack->PushBool(false); - else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicPosition / GetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusicPosition") == 0 || strcmp(Name, "GetMusicChannelPosition") == 0) { - int Channel = 0; - if (strcmp(Name, "GetMusicPosition") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->GetPositionTime()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsMusicPlaying / IsMusicChannelPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsMusicPlaying") == 0 || strcmp(Name, "IsMusicChannelPlaying") == 0) { - int Channel = 0; - if (strcmp(Name, "IsMusicPlaying") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); - else Stack->PushBool(_music[Channel]->IsPlaying()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicVolume / SetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMusicVolume") == 0 || strcmp(Name, "SetMusicChannelVolume") == 0) { - int Channel = 0; - if (strcmp(Name, "SetMusicVolume") == 0) Stack->CorrectParams(1); - else { - Stack->CorrectParams(2); - Channel = Stack->Pop()->GetInt(); - } - - int Volume = Stack->Pop()->GetInt(); - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); - else { - if (FAILED(_music[Channel]->SetVolume(Volume))) Stack->PushBool(false); - else Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicVolume / GetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusicVolume") == 0 || strcmp(Name, "GetMusicChannelVolume") == 0) { - int Channel = 0; - if (strcmp(Name, "GetMusicVolume") == 0) Stack->CorrectParams(0); - else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); - } - - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->GetVolume()); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicCrossfade - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicCrossfade") == 0) { - Stack->CorrectParams(4); - int Channel1 = Stack->Pop()->GetInt(0); - int Channel2 = Stack->Pop()->GetInt(0); - uint32 FadeLength = (uint32)Stack->Pop()->GetInt(0); - bool Swap = Stack->Pop()->GetBool(true); - - if (_musicCrossfadeRunning) { - Script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - Stack->PushBool(false); - return S_OK; - } - - _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = Channel1; - _musicCrossfadeChannel2 = Channel2; - _musicCrossfadeLength = FadeLength; - _musicCrossfadeSwap = Swap; - - _musicCrossfadeRunning = true; - - Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundLength") == 0) { - Stack->CorrectParams(1); - - int Length = 0; - const char *Filename = Stack->Pop()->GetString(); - - CBSound *Sound = new CBSound(Game); - if (Sound && SUCCEEDED(Sound->SetSound(Filename, SOUND_MUSIC, true))) { - Length = Sound->GetLength(); - delete Sound; - Sound = NULL; - } - Stack->PushInt(Length); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMousePos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMousePos") == 0) { - Stack->CorrectParams(2); - int x = Stack->Pop()->GetInt(); - int y = Stack->Pop()->GetInt(); - x = MAX(x, 0); - x = MIN(x, _renderer->_width); - y = MAX(y, 0); - y = MIN(y, _renderer->_height); - POINT p; - p.x = x + _renderer->_drawOffsetX; - p.y = y + _renderer->_drawOffsetY; - - CBPlatform::SetCursorPos(p.x, p.y); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LockMouseRect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LockMouseRect") == 0) { - Stack->CorrectParams(4); - int left = Stack->Pop()->GetInt(); - int top = Stack->Pop()->GetInt(); - int right = Stack->Pop()->GetInt(); - int bottom = Stack->Pop()->GetInt(); - - if (right < left) CBUtils::Swap(&left, &right); - if (bottom < top) CBUtils::Swap(&top, &bottom); - - CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayVideo") == 0) { -/* Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - // TODO: ADDVIDEO - */ - - Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - - Stack->CorrectParams(6); - const char* Filename = Stack->Pop()->GetString(); - warning("PlayVideo: %s - not implemented yet", Filename); - CScValue* valType = Stack->Pop(); - int Type; - if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->GetInt(); - - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - bool FreezeMusic = Stack->Pop()->GetBool(true); - - CScValue* valSub = Stack->Pop(); - const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); - - if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - - /*if(SUCCEEDED(Game->m_VideoPlayer->Initialize(Filename, SubtitleFile))) - { - if(SUCCEEDED(Game->m_VideoPlayer->Play((TVideoPlayback)Type, X, Y, FreezeMusic))) - { - Stack->PushBool(true); - Script->Sleep(0); - } - else Stack->PushBool(false); - } - else */Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayTheora") == 0) { - /* Stack->CorrectParams(0); - Stack->PushBool(false); - - return S_OK; - // TODO: ADDVIDEO - */ - Stack->CorrectParams(7); - const char* Filename = Stack->Pop()->GetString(); - warning("PlayTheora: %s - not implemented yet", Filename); - CScValue* valType = Stack->Pop(); - int Type; - if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->GetInt(); - - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - bool FreezeMusic = Stack->Pop()->GetBool(true); - bool DropFrames = Stack->Pop()->GetBool(true); - - CScValue* valSub = Stack->Pop(); - const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); - - - if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - - /*SAFE_DELETE(m_TheoraPlayer); - m_TheoraPlayer = new CVidTheoraPlayer(this); - if(m_TheoraPlayer && SUCCEEDED(m_TheoraPlayer->Initialize(Filename, SubtitleFile))) - { - m_TheoraPlayer->m_DontDropFrames = !DropFrames; - if(SUCCEEDED(m_TheoraPlayer->Play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) - { - Stack->PushBool(true); - Script->Sleep(0); - } - else Stack->PushBool(false); - } - else */Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QuitGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "QuitGame") == 0) { - Stack->CorrectParams(0); - Stack->PushNULL(); - _quitting = true; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegWriteNumber") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - int Val = Stack->Pop()->GetInt(); - _registry->WriteInt("PrivateSettings", Key, Val); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegReadNumber") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - int InitVal = Stack->Pop()->GetInt(); - Stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegWriteString") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - const char *Val = Stack->Pop()->GetString(); - _registry->WriteString("PrivateSettings", Key, Val); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegReadString") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - const char *InitVal = Stack->Pop()->GetString(); - AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); - Stack->PushString((char *)val.c_str()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveGame") == 0) { - Stack->CorrectParams(3); - int Slot = Stack->Pop()->GetInt(); - const char *xdesc = Stack->Pop()->GetString(); - bool quick = Stack->Pop()->GetBool(false); - - char *Desc = new char[strlen(xdesc) + 1]; - strcpy(Desc, xdesc); - Stack->PushBool(true); - if (FAILED(SaveGame(Slot, Desc, quick))) { - Stack->Pop(); - Stack->PushBool(false); - } - delete [] Desc; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadGame") == 0) { - Stack->CorrectParams(1); - _scheduledLoadSlot = Stack->Pop()->GetInt(); - _loading = true; - Stack->PushBool(false); - Script->Sleep(0); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSaveSlotUsed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsSaveSlotUsed") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); - Stack->PushBool(IsSaveSlotUsed(Slot)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSaveSlotDescription - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSaveSlotDescription") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); - char Desc[512]; - Desc[0] = '\0'; - GetSaveSlotDescription(Slot, Desc); - Stack->PushString(Desc); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmptySaveSlot") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); - EmptySaveSlot(Slot); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setMasterVolumePercent((byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getMasterVolumePercent()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetActiveCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(SetActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetActiveCursor") == 0) { - Stack->CorrectParams(0); - if (!_activeCursor || !_activeCursor->_filename) Stack->PushNULL(); - else Stack->PushString(_activeCursor->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetActiveCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_activeCursor) Stack->PushNULL(); - else Stack->PushNative(_activeCursor, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveActiveCursor") == 0) { - Stack->CorrectParams(0); - delete _activeCursor; - _activeCursor = NULL; - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasActiveCursor") == 0) { - Stack->CorrectParams(0); - - if (_activeCursor) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FileExists - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FileExists") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - - CBFile *File = _fileManager->OpenFile(Filename, false); - if (!File) Stack->PushBool(false); - else { - _fileManager->CloseFile(File); - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0 || strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); - - bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); - - _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(_fader); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0 || strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); - - bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); - - _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(_fader); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFadeColor") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_fader->GetCurrentColor()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Screenshot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Screenshot") == 0) { - Stack->CorrectParams(1); - char Filename[MAX_PATH]; - - CScValue *Val = Stack->Pop(); - - int FileNum = 0; - while (true) { - sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); - FILE *f = fopen(Filename, "rb"); - if (!f) break; - else fclose(f); - FileNum++; - } - - bool ret = false; - CBImage *Image = Game->_renderer->TakeScreenshot(); - if (Image) { - ret = SUCCEEDED(Image->SaveBMPFile(Filename)); - delete Image; - } else ret = false; - - Stack->PushBool(ret); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenshotEx - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenshotEx") == 0) { - Stack->CorrectParams(3); - const char *Filename = Stack->Pop()->GetString(); - int SizeX = Stack->Pop()->GetInt(_renderer->_width); - int SizeY = Stack->Pop()->GetInt(_renderer->_height); - - bool ret = false; - CBImage *Image = Game->_renderer->TakeScreenshot(); - if (Image) { - ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); - if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); - delete Image; - } else ret = false; - - Stack->PushBool(ret); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateWindow") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIWindow *Win = new CUIWindow(Game); - _windows.Add(Win); - RegisterObject(Win); - if (!Val->IsNULL()) Win->SetName(Val->GetString()); - Stack->PushNative(Win, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteWindow") == 0) { - Stack->CorrectParams(1); - CBObject *Obj = (CBObject *)Stack->Pop()->GetNative(); - for (int i = 0; i < _windows.GetSize(); i++) { - if (_windows[i] == Obj) { - UnregisterObject(_windows[i]); - Stack->PushBool(true); - return S_OK; - } - } - Stack->PushBool(false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenDocument - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OpenDocument") == 0) { - Stack->CorrectParams(0); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_DumpClassRegistry - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DEBUG_DumpClassRegistry") == 0) { - Stack->CorrectParams(0); - DEBUG_DumpClassRegistry(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetLoadingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetLoadingScreen") == 0) { - Stack->CorrectParams(3); - CScValue *Val = Stack->Pop(); - _loadImageX = Stack->Pop()->GetInt(); - _loadImageY = Stack->Pop()->GetInt(); - - if (Val->IsNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; - } else { - CBUtils::SetString(&_loadImageName, Val->GetString()); - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSavingScreen") == 0) { - Stack->CorrectParams(3); - CScValue *Val = Stack->Pop(); - _saveImageX = Stack->Pop()->GetInt(); - _saveImageY = Stack->Pop()->GetInt(); - - if (Val->IsNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; - } else { - CBUtils::SetString(&_saveImageName, Val->GetString()); - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetWaitCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(SetWaitCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveWaitCursor") == 0) { - Stack->CorrectParams(0); - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaitCursor") == 0) { - Stack->CorrectParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorNoninteractive->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaitCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_cursorNoninteractive) Stack->PushNULL(); - else Stack->PushNative(_cursorNoninteractive, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearScriptCache - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClearScriptCache") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayLoadingIcon") == 0) { - Stack->CorrectParams(4); - - const char *Filename = Stack->Pop()->GetString(); - _loadingIconX = Stack->Pop()->GetInt(); - _loadingIconY = Stack->Pop()->GetInt(); - _loadingIconPersistent = Stack->Pop()->GetBool(); - - delete _loadingIcon; - _loadingIcon = new CBSprite(this); - if (!_loadingIcon || FAILED(_loadingIcon->LoadFile(Filename))) { - delete _loadingIcon; - _loadingIcon = NULL; - } else { - DisplayContent(false, true); - Game->_renderer->Flip(); - Game->_renderer->InitLoop(); - } - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HideLoadingIcon") == 0) { - Stack->CorrectParams(0); - delete _loadingIcon; - _loadingIcon = NULL; - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DumpTextureStats - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DumpTextureStats") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - - _renderer->DumpData(Filename); - - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccOutputText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccOutputText") == 0) { - Stack->CorrectParams(2); - const char *Str = Stack->Pop()->GetString(); - int Type = Stack->Pop()->GetInt(); - // do nothing - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StoreSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StoreSaveThumbnail") == 0) { - Stack->CorrectParams(0); - delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); - if (FAILED(_cachedThumbnail->StoreThumbnail())) { - delete _cachedThumbnail; - _cachedThumbnail = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteSaveThumbnail") == 0) { - Stack->CorrectParams(0); - delete _cachedThumbnail; - _cachedThumbnail = NULL; - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFileChecksum - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFileChecksum") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool AsHex = Stack->Pop()->GetBool(false); - - CBFile *File = _fileManager->OpenFile(Filename, false); - if (File) { - crc remainder = crc_initialize(); - byte Buf[1024]; - int BytesRead = 0; - - while (BytesRead < File->GetSize()) { - int BufSize = MIN((uint32)1024, File->GetSize() - BytesRead); - BytesRead += BufSize; - - File->Read(Buf, BufSize); - for (int i = 0; i < BufSize; i++) { - remainder = crc_process_byte(Buf[i], remainder); - } - } - crc checksum = crc_finalize(remainder); - - if (AsHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - Stack->PushString(Hex); - } else - Stack->PushInt(checksum); - - _fileManager->CloseFile(File); - File = NULL; - } else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EnableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EnableScriptProfiling") == 0) { - Stack->CorrectParams(0); - _scEngine->EnableProfiling(); - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisableScriptProfiling") == 0) { - Stack->CorrectParams(0); - _scEngine->DisableProfiling(); - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ShowStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ShowStatusLine") == 0) { - Stack->CorrectParams(0); -#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HideStatusLine") == 0) { - Stack->CorrectParams(0); -#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif - Stack->PushNULL(); - - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Hwnd (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Hwnd") == 0) { - _scValue->SetInt((int)_renderer->_window); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CurrentTime") == 0) { - _scValue->SetInt((int)_timer); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowsTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WindowsTime") == 0) { - _scValue->SetInt((int)CBPlatform::GetTime()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowedMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WindowedMode") == 0) { - _scValue->SetBool(_renderer->_windowed); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { - _scValue->SetInt(_mousePos.x); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { - _scValue->SetInt(_mousePos.y); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainObject") == 0) { - _scValue->SetNative(_mainObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ActiveObject (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ActiveObject") == 0) { - _scValue->SetNative(_activeObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenWidth (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenWidth") == 0) { - _scValue->SetInt(_renderer->_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenHeight (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenHeight") == 0) { - _scValue->SetInt(_renderer->_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Interactive") == 0) { - _scValue->SetBool(_interactive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DebugMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DebugMode") == 0) { - _scValue->SetBool(_dEBUG_DebugMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundAvailable (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundAvailable") == 0) { - _scValue->SetBool(_soundMgr->_soundAvailable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SFXVolume") == 0) { - Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SFX)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SpeechVolume") == 0) { - Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicVolume") == 0) { - Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MasterVolume") == 0) { - Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getMasterVolumePercent()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyboard (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyboard") == 0) { - if (_keyboardState) _scValue->SetNative(_keyboardState, true); - else _scValue->SetNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtitles") == 0) { - _scValue->SetBool(_subtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesSpeed") == 0) { - _scValue->SetInt(_subtitlesSpeed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VideoSubtitles") == 0) { - _scValue->SetBool(_videoSubtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FPS (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FPS") == 0) { - _scValue->SetInt(_fps); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AcceleratedMode / Accelerated (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AcceleratedMode") == 0 || strcmp(Name, "Accelerated") == 0) { - _scValue->SetBool(_useD3D); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextEncoding") == 0) { - _scValue->SetInt(_textEncoding); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextRTL") == 0) { - _scValue->SetBool(_textRTL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundBufferSize") == 0) { - _scValue->SetInt(_soundBufferSizeSec); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuspendedRendering") == 0) { - _scValue->SetBool(_suspendedRendering); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuppressScriptErrors") == 0) { - _scValue->SetBool(_suppressScriptErrors); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // Frozen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Frozen") == 0) { - _scValue->SetBool(_state == GAME_FROZEN); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSEnabled") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSTalk - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSTalk") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSCaptions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSCaptions") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSKeypress - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSKeypress") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardEnabled") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardCursorSkip - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardCursorSkip") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardPause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardPause") == 0) { - _scValue->SetBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutorunDisabled") == 0) { - _scValue->SetBool(_autorunDisabled); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveDirectory (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveDirectory") == 0) { - AnsiString dataDir = GetDataDir(); - _scValue->SetString((char *)dataDir.c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveOnExit") == 0) { - _scValue->SetBool(_autoSaveOnExit); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveSlot") == 0) { - _scValue->SetInt(_autoSaveSlot); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorHidden") == 0) { - _scValue->SetBool(_cursorHidden); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Platform (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Platform") == 0) { - _scValue->SetString(CBPlatform::GetPlatformName().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DeviceType (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeviceType") == 0) { - _scValue->SetString(GetDeviceType().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MostRecentSaveSlot (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MostRecentSaveSlot") == 0) { - _scValue->SetInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Store (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Store") == 0) { - if (_store) _scValue->SetNative(_store, true); - else _scValue->SetNULL(); - - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { - _mousePos.x = Value->GetInt(); - ResetMousePos(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { - _mousePos.y = Value->GetInt(); - ResetMousePos(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - HRESULT res = CBObject::ScSetProperty(Name, Value); - SetWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainObject") == 0) { - CBScriptable *obj = Value->GetNative(); - if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Interactive") == 0) { - SetInteractive(Value->GetBool()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SFXVolume") == 0) { - Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Value->GetInt()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SpeechVolume") == 0) { - Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Value->GetInt()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicVolume") == 0) { - Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Value->GetInt()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MasterVolume") == 0) { - Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->setMasterVolumePercent((byte)Value->GetInt()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtitles") == 0) { - _subtitles = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VideoSubtitles") == 0) { - _videoSubtitles = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextEncoding") == 0) { - int Enc = Value->GetInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextRTL") == 0) { - _textRTL = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = Value->GetInt(); - _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuspendedRendering") == 0) { - _suspendedRendering = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutorunDisabled") == 0) { - _autorunDisabled = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveSlot") == 0) { - _autoSaveSlot = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorHidden") == 0) { - _cursorHidden = Value->GetBool(); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBGame::ScToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayQuickMsg() { - if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; - - int i; - - // update - for (i = 0; i < _quickMessages.GetSize(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.RemoveAt(i); - i--; - } - } - - int PosY = 20; - - // display - for (i = 0; i < _quickMessages.GetSize(); i++) { - _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); - PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); - } - return S_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessage(const char *Text) { - if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.RemoveAt(0); - } - _quickMessages.Add(new CBQuickMsg(Game, Text)); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessageForm(LPSTR fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::RegisterObject(CBObject *Object) { - _regObjects.Add(Object); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::UnregisterObject(CBObject *Object) { - if (!Object) return S_OK; - - int i; - - // is it a window? - for (i = 0; i < _windows.GetSize(); i++) { - if ((CBObject *)_windows[i] == Object) { - _windows.RemoveAt(i); - - // get new focused window - if (_focusedWindow == Object) _focusedWindow = NULL; - - break; - } - } - - // is it active object? - if (_activeObject == Object) _activeObject = NULL; - - // is it main object? - if (_mainObject == Object) _mainObject = NULL; - - if (_store) _store->OnObjectDestroyed(Object); - - // destroy object - for (i = 0; i < _regObjects.GetSize(); i++) { - if (_regObjects[i] == Object) { - _regObjects.RemoveAt(i); - if (!_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); - delete Object; - return S_OK; - } - } - - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::InvalidateValues(void *Value, void *Data) { - CScValue *val = (CScValue *)Value; - if (val->IsNative() && val->GetNative() == Data) { - if (!val->_persistent && ((CBScriptable *)Data)->_refCount == 1) { - ((CBScriptable *)Data)->_refCount++; - } - val->SetNative(NULL); - val->SetNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::ValidObject(CBObject *Object) { - if (!Object) return false; - if (Object == this) return true; - - for (int i = 0; i < _regObjects.GetSize(); i++) { - if (_regObjects[i] == Object) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::PublishNatives() { - if (!_scEngine || !_scEngine->_compilerAvailable) return; - - _scEngine->ExtDefineFunction("LOG"); - _scEngine->ExtDefineFunction("String"); - _scEngine->ExtDefineFunction("MemBuffer"); - _scEngine->ExtDefineFunction("File"); - _scEngine->ExtDefineFunction("Date"); - _scEngine->ExtDefineFunction("Array"); - _scEngine->ExtDefineFunction("TcpClient"); - _scEngine->ExtDefineFunction("Object"); - //_scEngine->ExtDefineFunction("Game"); - _scEngine->ExtDefineFunction("Sleep"); - _scEngine->ExtDefineFunction("WaitFor"); - _scEngine->ExtDefineFunction("Random"); - _scEngine->ExtDefineFunction("SetScriptTimeSlice"); - _scEngine->ExtDefineFunction("MakeRGBA"); - _scEngine->ExtDefineFunction("MakeRGB"); - _scEngine->ExtDefineFunction("MakeHSL"); - _scEngine->ExtDefineFunction("RGB"); - _scEngine->ExtDefineFunction("GetRValue"); - _scEngine->ExtDefineFunction("GetGValue"); - _scEngine->ExtDefineFunction("GetBValue"); - _scEngine->ExtDefineFunction("GetAValue"); - _scEngine->ExtDefineFunction("GetHValue"); - _scEngine->ExtDefineFunction("GetSValue"); - _scEngine->ExtDefineFunction("GetLValue"); - _scEngine->ExtDefineFunction("Debug"); - - _scEngine->ExtDefineFunction("ToString"); - _scEngine->ExtDefineFunction("ToInt"); - _scEngine->ExtDefineFunction("ToBool"); - _scEngine->ExtDefineFunction("ToFloat"); - - _scEngine->ExtDefineVariable("Game"); - _scEngine->ExtDefineVariable("Math"); - _scEngine->ExtDefineVariable("Directory"); - _scEngine->ExtDefineVariable("self"); - _scEngine->ExtDefineVariable("this"); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { - CScValue *this_obj; - - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LOG") == 0) { - Stack->CorrectParams(1); - Game->LOG(0, "sc: %s", Stack->Pop()->GetString()); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // String - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "String") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXString(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MemBuffer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MemBuffer") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXMemBuffer(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // File - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "File") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXFile(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Date - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Date") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXDate(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Array - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Array") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXArray(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Object - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Object") == 0) { - this_obj = ThisStack->GetTop(); - - this_obj->SetNative(new CSXObject(Game, Stack)); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Sleep - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sleep") == 0) { - Stack->CorrectParams(1); - - Script->Sleep((uint32)Stack->Pop()->GetInt()); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // WaitFor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WaitFor") == 0) { - Stack->CorrectParams(1); - - CBScriptable *obj = Stack->Pop()->GetNative(); - if (ValidObject((CBObject *)obj)) Script->WaitForExclusive((CBObject *)obj); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Random - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Random") == 0) { - Stack->CorrectParams(2); - - int from = Stack->Pop()->GetInt(); - int to = Stack->Pop()->GetInt(); - - Stack->PushInt(CBUtils::RandomInt(from, to)); - } - - ////////////////////////////////////////////////////////////////////////// - // SetScriptTimeSlice - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetScriptTimeSlice") == 0) { - Stack->CorrectParams(1); - - Script->_timeSlice = (uint32)Stack->Pop()->GetInt(); - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeRGBA / MakeRGB / RGB - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MakeRGBA") == 0 || strcmp(Name, "MakeRGB") == 0 || strcmp(Name, "RGB") == 0) { - Stack->CorrectParams(4); - int r = Stack->Pop()->GetInt(); - int g = Stack->Pop()->GetInt(); - int b = Stack->Pop()->GetInt(); - int a; - CScValue *val = Stack->Pop(); - if (val->IsNULL()) a = 255; - else a = val->GetInt(); - - Stack->PushInt(DRGBA(r, g, b, a)); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeHSL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MakeHSL") == 0) { - Stack->CorrectParams(3); - int h = Stack->Pop()->GetInt(); - int s = Stack->Pop()->GetInt(); - int l = Stack->Pop()->GetInt(); - - Stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetRValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRValue") == 0) { - Stack->CorrectParams(1); - - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetR(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetGValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGValue") == 0) { - Stack->CorrectParams(1); - - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetG(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetBValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetBValue") == 0) { - Stack->CorrectParams(1); - - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetB(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetAValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetAValue") == 0) { - Stack->CorrectParams(1); - - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetA(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetHValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(H); - } - - ////////////////////////////////////////////////////////////////////////// - // GetSValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(S); - } - - ////////////////////////////////////////////////////////////////////////// - // GetLValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetLValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Debug") == 0) { - Stack->CorrectParams(0); - - if (Game->GetDebugMgr()->_enabled) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(Script); - Script->Sleep(0); - } - Stack->PushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // ToString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToString") == 0) { - Stack->CorrectParams(1); - const char *Str = Stack->Pop()->GetString(); - char *Str2 = new char[strlen(Str) + 1]; - strcpy(Str2, Str); - Stack->PushString(Str2); - delete [] Str2; - } - - ////////////////////////////////////////////////////////////////////////// - // ToInt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToInt") == 0) { - Stack->CorrectParams(1); - int Val = Stack->Pop()->GetInt(); - Stack->PushInt(Val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToFloat") == 0) { - Stack->CorrectParams(1); - double Val = Stack->Pop()->GetFloat(); - Stack->PushFloat(Val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToBool") == 0) { - Stack->CorrectParams(1); - bool Val = Stack->Pop()->GetBool(); - Stack->PushBool(Val); - } - - ////////////////////////////////////////////////////////////////////////// - // failure - else { - Script->RuntimeError("Call to undefined function '%s'. Ignored.", Name); - Stack->CorrectParams(0); - Stack->PushNULL(); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ShowCursor() { - if (_cursorHidden) return S_OK; - - if (!_interactive && Game->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return DrawCursor(_cursorNoninteractive); - } else { - if (_activeObject && !FAILED(_activeObject->ShowCursor())) return S_OK; - else { - if (_activeObject && _activeCursor && _activeObject->GetExtendedFlag("usable")) return DrawCursor(_activeCursor); - else if (_cursor) return DrawCursor(_cursor); - } - } - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(slot, Filename); - - LOG(0, "Saving game '%s'...", Filename); - - Game->ApplyEvent("BeforeSave", true); - - HRESULT ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(Game); - if (FAILED(ret = pm->InitSave(desc))) goto save_finish; - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = new CBSurfaceSDL(this); - - if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveTable(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = pm->SaveFile(Filename))) goto save_finish; - - _registry->WriteInt("System", "MostRecentSaveSlot", slot); - -save_finish: - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(int Slot) { - //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); - - return LoadGame(Filename); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(const char *Filename) { - LOG(0, "Loading game '%s'...", Filename); - GetDebugMgr()->OnGameShutdown(); - - HRESULT ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = new CBSurfaceSDL(this); - - if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(Game); - _dEBUG_AbsolutePathWarning = false; - if (FAILED(ret = pm->InitLoad(Filename))) goto load_finish; - - //if(FAILED(ret = Cleanup())) goto load_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadInstances(Game, pm))) goto load_finish; - - // data initialization after load - InitAfterLoad(); - - Game->ApplyEvent("AfterLoad", true); - - DisplayContent(true, false); - //_renderer->Flip(); - - GetDebugMgr()->OnGameInit(); - -load_finish: - _dEBUG_AbsolutePathWarning = true; - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitAfterLoad() { - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSound, "CBSound", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); - - _scEngine->RefreshScriptBreakpoints(); - if (_store) _store->AfterLoad(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadRegion(void *Region, void *Data) { - ((CBRegion *)Region)->CreateRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { - ((CBSubFrame *)Subframe)->SetSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadSound(void *Sound, void *Data) { - ((CBSound *)Sound)->SetSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadFont(void *Font, void *Data) { - ((CBFontTT *)Font)->AfterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadScript(void *script, void *data) { - ((CScScript *)script)->AfterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayWindows(bool InGame) { - HRESULT res; - - int i; - - // did we lose focus? focus topmost window - if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { - _focusedWindow = NULL; - for (i = _windows.GetSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (i = 0; i < _windows.GetSize(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == InGame) { - - res = _windows[i]->Display(); - if (FAILED(res)) return res; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PlayMusic(int Channel, const char *Filename, bool Looping, uint32 LoopStart) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); - return E_FAIL; - } - - delete _music[Channel]; - _music[Channel] = NULL; - - _music[Channel] = new CBSound(Game); - if (_music[Channel] && SUCCEEDED(_music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { - if (_musicStartTime[Channel]) { - _music[Channel]->SetPositionTime(_musicStartTime[Channel]); - _musicStartTime[Channel] = 0; - } - if (LoopStart) _music[Channel]->SetLoopStart(LoopStart); - return _music[Channel]->Play(Looping); - } else { - delete _music[Channel]; - _music[Channel] = NULL; - return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::StopMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); - return E_FAIL; - } - - if (_music[Channel]) { - _music[Channel]->Stop(); - delete _music[Channel]; - _music[Channel] = NULL; - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PauseMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); - return E_FAIL; - } - - if (_music[Channel]) return _music[Channel]->Pause(); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ResumeMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); - return E_FAIL; - } - - if (_music[Channel]) return _music[Channel]->Resume(); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { - - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); - return E_FAIL; - } - - _musicStartTime[Channel] = Time; - if (_music[Channel] && _music[Channel]->IsPlaying()) return _music[Channel]->SetPositionTime(Time); - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadSettings(const char *Filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SETTINGS) - TOKEN_TABLE(GAME) - TOKEN_TABLE(STRING_TABLE) - TOKEN_TABLE(RESOLUTION) - TOKEN_TABLE(REQUIRE_3D_ACCELERATION) - TOKEN_TABLE(REQUIRE_SOUND) - TOKEN_TABLE(HWTL_MODE) - TOKEN_TABLE(ALLOW_WINDOWED_MODE) - TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) - TOKEN_TABLE(ALLOW_ABOUT_TAB) - TOKEN_TABLE(ALLOW_ADVANCED) - TOKEN_TABLE(ALLOW_DESKTOP_RES) - TOKEN_TABLE(REGISTRY_PATH) - TOKEN_TABLE(RICH_SAVED_GAMES) - TOKEN_TABLE(SAVED_GAME_EXT) - TOKEN_TABLE(GUID) - TOKEN_TABLE_END - - - byte *OrigBuffer = Game->_fileManager->ReadWholeFile(Filename); - if (OrigBuffer == NULL) { - Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret = S_OK; - - byte *Buffer = OrigBuffer; - byte *params; - int cmd; - CBParser parser(Game); - - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return E_FAIL; - } - Buffer = params; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - delete[] _settingsGameFile; - _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); - break; - - case TOKEN_STRING_TABLE: - if (FAILED(_stringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_RESOLUTION: - parser.ScanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); - break; - - case TOKEN_REQUIRE_3D_ACCELERATION: - parser.ScanStr((char *)params, "%b", &_settingsRequireAcceleration); - break; - - case TOKEN_REQUIRE_SOUND: - parser.ScanStr((char *)params, "%b", &_settingsRequireSound); - break; - - case TOKEN_HWTL_MODE: - parser.ScanStr((char *)params, "%d", &_settingsTLMode); - break; - - case TOKEN_ALLOW_WINDOWED_MODE: - parser.ScanStr((char *)params, "%b", &_settingsAllowWindowed); - break; - - case TOKEN_ALLOW_DESKTOP_RES: - parser.ScanStr((char *)params, "%b", &_settingsAllowDesktopRes); - break; - - case TOKEN_ALLOW_ADVANCED: - parser.ScanStr((char *)params, "%b", &_settingsAllowAdvanced); - break; - - case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.ScanStr((char *)params, "%b", &_settingsAllowAccessTab); - break; - - case TOKEN_ALLOW_ABOUT_TAB: - parser.ScanStr((char *)params, "%b", &_settingsAllowAboutTab); - break; - - case TOKEN_REGISTRY_PATH: - _registry->SetBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.ScanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - CBUtils::SetString(&_savedGameExt, (char *)params); - break; - - case TOKEN_GUID: - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in game settings '%s'", Filename); - ret = E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading game settings '%s'", Filename); - ret = E_FAIL; - } - - _settingsAllowWindowed = _registry->ReadBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->ReadBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; - - delete [] OrigBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_activeObject)); - PersistMgr->Transfer(TMEMBER(_capturedObject)); - PersistMgr->Transfer(TMEMBER(_cursorNoninteractive)); - PersistMgr->Transfer(TMEMBER(_doNotExpandStrings)); - PersistMgr->Transfer(TMEMBER(_editorMode)); - PersistMgr->Transfer(TMEMBER(_fader)); - PersistMgr->Transfer(TMEMBER(_freezeLevel)); - PersistMgr->Transfer(TMEMBER(_focusedWindow)); - PersistMgr->Transfer(TMEMBER(_fontStorage)); - PersistMgr->Transfer(TMEMBER(_interactive)); - PersistMgr->Transfer(TMEMBER(_keyboardState)); - PersistMgr->Transfer(TMEMBER(_lastTime)); - PersistMgr->Transfer(TMEMBER(_mainObject)); - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - PersistMgr->Transfer(TMEMBER(_music[i])); - PersistMgr->Transfer(TMEMBER(_musicStartTime[i])); - } - - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_offsetPercentX)); - PersistMgr->Transfer(TMEMBER(_offsetPercentY)); - - PersistMgr->Transfer(TMEMBER(_origInteractive)); - PersistMgr->Transfer(TMEMBER_INT(_origState)); - PersistMgr->Transfer(TMEMBER(_personalizedSave)); - PersistMgr->Transfer(TMEMBER(_quitting)); - - _regObjects.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_scEngine)); - //PersistMgr->Transfer(TMEMBER(_soundMgr)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - //PersistMgr->Transfer(TMEMBER(_surfaceStorage)); - PersistMgr->Transfer(TMEMBER(_subtitles)); - PersistMgr->Transfer(TMEMBER(_subtitlesSpeed)); - PersistMgr->Transfer(TMEMBER(_systemFont)); - PersistMgr->Transfer(TMEMBER(_videoFont)); - PersistMgr->Transfer(TMEMBER(_videoSubtitles)); - - PersistMgr->Transfer(TMEMBER(_timer)); - PersistMgr->Transfer(TMEMBER(_timerDelta)); - PersistMgr->Transfer(TMEMBER(_timerLast)); - - PersistMgr->Transfer(TMEMBER(_liveTimer)); - PersistMgr->Transfer(TMEMBER(_liveTimerDelta)); - PersistMgr->Transfer(TMEMBER(_liveTimerLast)); - - PersistMgr->Transfer(TMEMBER(_musicCrossfadeRunning)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeStartTime)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeLength)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel1)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel2)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeSwap)); - - PersistMgr->Transfer(TMEMBER(_loadImageName)); - PersistMgr->Transfer(TMEMBER(_saveImageName)); - PersistMgr->Transfer(TMEMBER(_saveImageX)); - PersistMgr->Transfer(TMEMBER(_saveImageY)); - PersistMgr->Transfer(TMEMBER(_loadImageX)); - PersistMgr->Transfer(TMEMBER(_loadImageY)); - - PersistMgr->Transfer(TMEMBER_INT(_textEncoding)); - PersistMgr->Transfer(TMEMBER(_textRTL)); - - PersistMgr->Transfer(TMEMBER(_soundBufferSizeSec)); - PersistMgr->Transfer(TMEMBER(_suspendedRendering)); - - PersistMgr->Transfer(TMEMBER(_mouseLockRect)); - - _windows.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_suppressScriptErrors)); - PersistMgr->Transfer(TMEMBER(_autorunDisabled)); - - PersistMgr->Transfer(TMEMBER(_autoSaveOnExit)); - PersistMgr->Transfer(TMEMBER(_autoSaveSlot)); - PersistMgr->Transfer(TMEMBER(_cursorHidden)); - - if (PersistMgr->CheckVersion(1, 0, 1)) - PersistMgr->Transfer(TMEMBER(_store)); - else - _store = NULL; - - if (!PersistMgr->_saving) _quitting = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::FocusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; - - int i; - for (i = 0; i < _windows.GetSize(); i++) { - if (_windows[i] == Window) { - if (i < _windows.GetSize() - 1) { - _windows.RemoveAt(i); - _windows.Add(Window); - - Game->_focusedWindow = Window; - } - - if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return FocusWindow(Prev); - else return S_OK; - } - } - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Freeze(bool IncludingMusic) { - if (_freezeLevel == 0) { - _scEngine->PauseAll(); - _soundMgr->pauseAll(IncludingMusic); - _origState = _state; - _origInteractive = _interactive; - _interactive = true; - } - _state = GAME_FROZEN; - _freezeLevel++; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Unfreeze() { - if (_freezeLevel == 0) return S_OK; - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->ResumeAll(); - _soundMgr->resumeAll(); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleKeypress(Common::Event *event) { -#ifdef __WIN32__ - // TODO: Do we really need to handle this in-engine? - // handle Alt+F4 on windows - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) { - OnWindowClose(); - return true; - //TODO - } -#endif - - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->SwitchFullscreen(); - return true; - } - - - - _keyboardState->ReadKey(event); -// TODO -#if 0 - if (_focusedWindow) { - if (!Game->_focusedWindow->HandleKeypress(event)) { - if (event->type != SDL_TEXTINPUT) { - if (Game->_focusedWindow->CanHandleEvent("Keypress")) - Game->_focusedWindow->ApplyEvent("Keypress"); - else - ApplyEvent("Keypress"); - } - } - return true; - } else if (event->type != SDL_TEXTINPUT) { - ApplyEvent("Keypress"); - return true; - } else return true; -#endif - return false; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleMouseWheel(int Delta) { - bool Handled = false; - if (_focusedWindow) { - Handled = Game->_focusedWindow->HandleMouseWheel(Delta); - - if (!Handled) { - if (Delta < 0 && Game->_focusedWindow->CanHandleEvent("MouseWheelDown")) { - Game->_focusedWindow->ApplyEvent("MouseWheelDown"); - Handled = true; - } else if (Game->_focusedWindow->CanHandleEvent("MouseWheelUp")) { - Game->_focusedWindow->ApplyEvent("MouseWheelUp"); - Handled = true; - } - - } - } - - if (!Handled) { - if (Delta < 0) { - ApplyEvent("MouseWheelDown"); - } else { - ApplyEvent("MouseWheelUp"); - } - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { - if (VerMajor) *VerMajor = DCGF_VER_MAJOR; - if (VerMinor) *VerMinor = DCGF_VER_MINOR; - - if (ExtMajor) *ExtMajor = 0; - if (ExtMinor) *ExtMinor = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::SetWindowTitle() { - if (_renderer) { - char Title[512]; - strcpy(Title, _caption[0]); - if (Title[0] != '\0') strcat(Title, " - "); - strcat(Title, "WME Lite"); - - - Utf8String title; - if (_textEncoding == TEXT_UTF8) { - title = Utf8String(Title); - } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); - title = Utf8String(Title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } -#if 0 - CBRenderSDL *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { - AnsiString dataDir = GetDataDir(); - sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::GetDataDir() { - AnsiString userDir = PathUtil::GetUserDirectory(); -#ifdef __IPHONEOS__ - return userDir; -#else - AnsiString baseDir = _registry->GetBasePath(); - return PathUtil::Combine(userDir, baseDir); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { - Buffer[0] = '\0'; - - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); - CBPersistMgr *pm = new CBPersistMgr(Game); - if (!pm) return E_FAIL; - - _dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(Filename))) { - _dEBUG_AbsolutePathWarning = true; - delete pm; - return E_FAIL; - } - - _dEBUG_AbsolutePathWarning = true; - strcpy(Buffer, pm->_savedDescription); - delete pm; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::IsSaveSlotUsed(int Slot) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); - - CBFile *File = _fileManager->OpenFile(Filename, false); - if (!File) return false; - - _fileManager->CloseFile(File); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::EmptySaveSlot(int Slot) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); - - CBPlatform::DeleteFile(Filename); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetActiveObject(CBObject *Obj) { - // not-active when game is frozen - if (Obj && !Game->_interactive && !Obj->_nonIntMouseEvents) { - Obj = NULL; - } - - if (Obj == _activeObject) return S_OK; - - if (_activeObject) _activeObject->ApplyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->ApplyEvent("MouseLeave"); - _activeObject = Obj; - if (_activeObject) { - _activeObject->ApplyEvent("MouseEntry"); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PushViewport(CBViewport *Viewport) { - _viewportSP++; - if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); - else _viewportStack[_viewportSP] = Viewport; - - _renderer->SetViewport(Viewport->GetRect()); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PopViewport() { - _viewportSP--; - if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); - - if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->GetRect()); - else _renderer->SetViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { - if (Rect == NULL) return E_FAIL; - else { - if (_viewportSP >= 0) { - CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->GetRect()); - if (Custom) *Custom = true; - } else { - CBPlatform::SetRect(Rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (Custom) *Custom = false; - } - - return S_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { - if (_viewportSP >= 0) { - if (OffsetX) *OffsetX = _viewportStack[_viewportSP]->_offsetX; - if (OffsetY) *OffsetY = _viewportStack[_viewportSP]->_offsetY; - } else { - if (OffsetX) *OffsetX = 0; - if (OffsetY) *OffsetY = 0; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::SetInteractive(bool State) { - _interactive = State; - if (_transMgr) _transMgr->_origInteractive = State; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::ResetMousePos() { - POINT p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - CBPlatform::SetCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::SetResourceModule(HMODULE ResModule) { - _resourceModule = ResModule; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayContent(bool Update, bool DisplayAll) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayContentSimple() { - // fill black - _renderer->Fill(0, 0, 0); - if (_indicatorDisplay) DisplayIndicator(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayIndicator() { - if (_saveLoadImage) { - RECT rc; - CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->GetWidth(), _saveLoadImage->GetHeight()); - if (_loadInProgress) _saveLoadImage->DisplayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->DisplayTrans(_saveImageX, _saveImageY, rc); - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; - _renderer->SetupLines(); - for (int i = 0; i < _indicatorHeight; i++) - _renderer->DrawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - - _renderer->Setup2D(); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::UpdateMusicCrossfade() { - byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); - - if (!_musicCrossfadeRunning) return S_OK; - if (_state == GAME_FROZEN) return S_OK; - - if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { - _musicCrossfadeRunning = false; - return S_OK; - } - if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { - _musicCrossfadeRunning = false; - return S_OK; - } - - if (!_music[_musicCrossfadeChannel1]->IsPlaying()) _music[_musicCrossfadeChannel1]->Play(); - if (!_music[_musicCrossfadeChannel2]->IsPlaying()) _music[_musicCrossfadeChannel2]->Play(); - - uint32 CurrentTime = Game->_liveTimer - _musicCrossfadeStartTime; - - if (CurrentTime >= _musicCrossfadeLength) { - _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->SetVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->SetVolume(100); - - _music[_musicCrossfadeChannel1]->Stop(); - //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->SetVolume(100); - - - if (_musicCrossfadeSwap) { - // swap channels - CBSound *Dummy = _music[_musicCrossfadeChannel1]; - int DummyInt = _musicStartTime[_musicCrossfadeChannel1]; - - _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; - _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - - _music[_musicCrossfadeChannel2] = Dummy; - _musicStartTime[_musicCrossfadeChannel2] = DummyInt; - } - } else { - //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); - _music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); - - //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ResetContent() { - _scEngine->ClearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { - FILE *f = fopen("./zz_class_reg_dump.log", "wt"); - - CSysClassRegistry::GetInstance()->DumpClasses(f); - - fclose(f); - Game->QuickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InvalidateDeviceObjects() { - for (int i = 0; i < _regObjects.GetSize(); i++) { - _regObjects[i]->InvalidateDeviceObjects(); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::RestoreDeviceObjects() { - for (int i = 0; i < _regObjects.GetSize(); i++) { - _regObjects[i]->RestoreDeviceObjects(); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetWaitCursor(const char *Filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile(Filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return E_FAIL; - } else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DrawCursor(CBSprite *Cursor) { - if (!Cursor) return E_FAIL; - if (Cursor != _lastCursor) { - Cursor->Reset(); - _lastCursor = Cursor; - } - return Cursor->Draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { - if (_shuttingDown || !_renderer) return S_OK; - - _renderer->_active = Activate; - - if (RefreshMouse) { - POINT p; - GetMousePos(&p); - SetActiveObject(_renderer->GetObjectAt(p.x, p.y)); - } - - if (Activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftDown() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _capturedObject = _activeObject; - _mouseLeftDown = true; - CBPlatform::SetCapture(_renderer->_window); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::ReleaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftRelease"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; - - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftDoubleClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; - - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightDoubleClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightDown() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightRelease"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; - - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("MiddleClick"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseMiddleUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); - if (!Handled) { - if (_activeObject != NULL) { - _activeObject->ApplyEvent("MiddleRelease"); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->InitLoop(); - DisplayContent(false, true); - DisplayDebugInfo(); - _renderer->WindowedBlt(); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnWindowClose() { - if (CanHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) Game->ApplyEvent("QuitGame"); - return S_OK; - } else return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayDebugInfo() { - char str[100]; - - if (_dEBUG_ShowFPS) { - sprintf(str, "FPS: %d", Game->_fps); - _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); - } - - if (Game->_dEBUG_DebugMode) { - if (!Game->_renderer->_windowed) - sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else - sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); - - strcat(str, " ("); - strcat(str, _renderer->GetName()); - strcat(str, ")"); - _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - - _renderer->DisplayDebugInfo(); - - int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; - ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); - _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - - - sprintf(str, "Timer: %d", _timer); - Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - - if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); - - sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); - - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::GetDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); - return _debugMgr; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::GetMousePos(POINT *Pos) { - CBPlatform::GetCursorPos(Pos); - - Pos->x -= _renderer->_drawOffsetX; - Pos->y -= _renderer->_drawOffsetY; - - /* - // Windows can squish maximized window if it's larger than desktop - // so we need to modify mouse position appropriately (tnx mRax) - if(_renderer->_windowed && ::IsZoomed(_renderer->_window)) - { - RECT rc; - ::GetClientRect(_renderer->_window, &rc); - Pos->x *= Game->_renderer->_realWidth; - Pos->x /= (rc.right - rc.left); - Pos->y *= Game->_renderer->_realHeight; - Pos->y /= (rc.bottom - rc.top); - } - */ - - if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::PtInRect(&_mouseLockRect, *Pos)) { - Pos->x = MAX(_mouseLockRect.left, Pos->x); - Pos->y = MAX(_mouseLockRect.top, Pos->y); - - Pos->x = MIN(_mouseLockRect.right, Pos->x); - Pos->y = MIN(_mouseLockRect.bottom, Pos->y); - - POINT NewPos = *Pos; - - NewPos.x += _renderer->_drawOffsetX; - NewPos.y += _renderer->_drawOffsetY; - - CBPlatform::SetCursorPos(NewPos.x, NewPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::MiniUpdate() { - if (!_miniUpdateEnabled) return S_OK; - - if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::GetTime(); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnScriptShutdown(CScScript *Script) { - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::IsLeftDoubleClick() { - return IsDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::IsRightDoubleClick() { - return IsDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::IsDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - -#if __IPHONEOS__ - maxMoveX = 16; - maxMoveY = 16; -#endif - - POINT pos; - CBPlatform::GetCursorPos(&pos); - - int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); - int moveY = abs(pos.y - _lastClick[buttonIndex].PosY); - - - if (_lastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].Time = CBPlatform::GetTime(); - _lastClick[buttonIndex].PosX = pos.x; - _lastClick[buttonIndex].PosY = pos.y; - return false; - } else { - _lastClick[buttonIndex].Time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::AutoSaveOnExit() { - _soundMgr->saveSettings(); - _registry->SaveValues(); - - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; - - SaveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::AddMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::GetDeviceType() const { -#ifdef __IPHONEOS__ - char devType[128]; - IOS_GetDeviceType(devType); - return AnsiString(devType); -#else - return "computer"; -#endif -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BGame.h b/engines/wintermute/BGame.h deleted file mode 100644 index 3a7e165b2c..0000000000 --- a/engines/wintermute/BGame.h +++ /dev/null @@ -1,386 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H - -#include "engines/wintermute/BDebugger.h" -//#include "BSaveThumbHelper.h" -//#include "BFader.h" -#include "engines/wintermute/BRenderer.h" -//#include "BSurfaceStorage.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/persistent.h" -#include "coll_templ.h" -#include "common/events.h" - -namespace WinterMute { - -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, HRESULT Result, void *Data); - -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXStore; -class CSXMath; -class CBKeyboardState; - -#define NUM_MUSIC_CHANNELS 5 - -class CBGame: public CBObject { -public: - DECLARE_PERSISTENT(CBGame, CBObject) - - virtual HRESULT OnScriptShutdown(CScScript *Script); - - virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); - virtual HRESULT OnMouseLeftDown(); - virtual HRESULT OnMouseLeftUp(); - virtual HRESULT OnMouseLeftDblClick(); - virtual HRESULT OnMouseRightDblClick(); - virtual HRESULT OnMouseRightDown(); - virtual HRESULT OnMouseRightUp(); - virtual HRESULT OnMouseMiddleDown(); - virtual HRESULT OnMouseMiddleUp(); - virtual HRESULT OnPaint(); - virtual HRESULT OnWindowClose(); - - bool IsLeftDoubleClick(); - bool IsRightDoubleClick(); - - bool _autorunDisabled; - - uint32 _lastMiniUpdate; - bool _miniUpdateEnabled; - - virtual HRESULT MiniUpdate(); - - void GetMousePos(POINT *Pos); - RECT _mouseLockRect; - - bool _shuttingDown; - - virtual HRESULT DisplayDebugInfo(); - bool _dEBUG_ShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - CBSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - virtual HRESULT ResetContent(); - - void DEBUG_DumpClassRegistry(); - HRESULT SetWaitCursor(const char *Filename); - char *_localSaveDir; - bool _saveDirChecked; - - - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorProgress; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - CBSurface *_saveLoadImage; - - HRESULT DisplayIndicator(); - - int _thumbnailWidth; - int _thumbnailHeight; - - bool _reportTextureFormat; - HMODULE _resourceModule; - void SetResourceModule(HMODULE ResModule); - - void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; - bool _editorMode; - - bool _doNotExpandStrings; - void GetOffset(int *OffsetX, int *OffsetY); - void SetOffset(int OffsetX, int OffsetY); - int GetSequence(); - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - CBObject *_mainObject; - - HRESULT InitInput(HINSTANCE hInst, HWND hWnd); - HRESULT InitLoop(); - uint32 _currentTime; - uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; - HRESULT Initialize1(); - HRESULT Initialize2(); - HRESULT Initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *GetDebugMgr(); - - void LOG(HRESULT res, LPCSTR fmt, ...); - - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CSXStore *_store; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); - - virtual ~CBGame(); - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *Filename = NULL); - bool _dEBUG_DebugMode; - bool _dEBUG_AbsolutePathWarning; - - void *_dEBUG_LogFile; - int _sequence; - virtual HRESULT LoadFile(const char *Filename); - virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; - - int _viewportSP; - bool _mouseLeftDown; - bool _mouseRightDown; - bool _mouseMidlleDown; - CBStringTable *_stringTable; - - int _settingsResWidth; - int _settingsResHeight; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - char *_settingsGameFile; - CBFader *_fader; - bool _suppressScriptErrors; - - virtual HRESULT InvalidateDeviceObjects(); - virtual HRESULT RestoreDeviceObjects(); - - virtual void PublishNatives(); - virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - // compatibility bits - bool _compatKillMethodThreads; - -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - -public: - uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; - int _scheduledLoadSlot; - bool _loading; - bool _personalizedSave; - HRESULT EmptySaveSlot(int Slot); - bool IsSaveSlotUsed(int Slot); - HRESULT GetSaveSlotDescription(int Slot, char *Buffer); - HRESULT GetSaveSlotFilename(int Slot, char *Buffer); - void SetWindowTitle(); - virtual bool HandleMouseWheel(int Delta); - bool _quitting; - virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - - virtual bool HandleKeypress(Common::Event *event); - int _freezeLevel; - HRESULT Unfreeze(); - HRESULT Freeze(bool IncludingMusic = true); - HRESULT FocusWindow(CUIWindow *Window); -/* CVidPlayer* _videoPlayer; - CVidTheoraPlayer* _theoraPlayer;*/ - bool _loadInProgress; - CUIWindow *_focusedWindow; - bool _editorForceScripts; - static void AfterLoadRegion(void *Region, void *Data); - static void AfterLoadSubFrame(void *Subframe, void *Data); - static void AfterLoadSound(void *Sound, void *Data); - static void AfterLoadFont(void *Font, void *Data); - static void AfterLoadScript(void *script, void *data); - static void InvalidateValues(void *Value, void *Data); - - HRESULT LoadSettings(const char *Filename); - HRESULT ResumeMusic(int Channel); - HRESULT SetMusicStartTime(int Channel, uint32 Time); - HRESULT PauseMusic(int Channel); - HRESULT StopMusic(int Channel); - HRESULT PlayMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; - HRESULT DisplayWindows(bool InGame = false); - CBRegistry *_registry; - bool _useD3D; - virtual HRESULT Cleanup(); - virtual HRESULT LoadGame(int Slot); - virtual HRESULT LoadGame(const char *Filename); - virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); - virtual HRESULT ShowCursor(); - - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - CBObject *_capturedObject; - POINT _mousePos; - bool ValidObject(CBObject *Object); - HRESULT UnregisterObject(CBObject *Object); - HRESULT RegisterObject(CBObject *Object); - void QuickMessage(const char *Text); - void QuickMessageForm(LPSTR fmt, ...); - HRESULT DisplayQuickMsg(); - uint32 _fps; - HRESULT UpdateMusicCrossfade(); - - CBArray _regObjects; -public: - virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); - virtual HRESULT DisplayContentSimple(); - bool _forceNonStreamedSounds; - void ResetMousePos(); - int _subtitlesSpeed; - void SetInteractive(bool State); - virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); - HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); - HRESULT PopViewport(); - HRESULT PushViewport(CBViewport *Viewport); - HRESULT SetActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - HRESULT DrawCursor(CBSprite *Cursor); - - virtual HRESULT InitAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; - AnsiString GetDataDir(); - void AddMem(int bytes); - - bool _touchInterface; - bool _constrainedMemory; - AnsiString GetDeviceType() const; - -private: - CBDebugger *_debugMgr; - - struct LastClickInfo { - LastClickInfo() { - PosX = PosY = 0; - Time = 0; - } - - int PosX; - int PosY; - uint32 Time; - }; - - LastClickInfo _lastClick[2]; - bool IsDoubleClick(int buttonIndex); - uint32 _usedMem; - - - -protected: - // WME Lite specific - bool _autoSaveOnExit; - int _autoSaveSlot; - bool _cursorHidden; - -public: - void AutoSaveOnExit(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BImage.cpp b/engines/wintermute/BImage.cpp deleted file mode 100644 index 5f85215f7a..0000000000 --- a/engines/wintermute/BImage.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BImage.h" -//#include "FreeImage.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { -#if 0 - _bitmap = bitmap; -#endif - _bitmap = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBImage::~CBImage() { -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::SaveBMPFile(const char *Filename) { -#if 0 - if (!_bitmap) return E_FAIL; - - if (FreeImage_Save(FIF_BMP, _bitmap, Filename)) return S_OK; - else return E_FAIL; -#endif - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::Resize(int NewWidth, int NewHeight) { -#if 0 - if (!_bitmap) return E_FAIL; - - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); - - - FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); - if (newImg) { - FreeImage_Unload(_bitmap); - _bitmap = newImg; - return S_OK; - } else return E_FAIL; -#endif - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { - if (!_bitmap) return NULL; -#if 0 - FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); - uint32 size; - byte *data; - FreeImage_AcquireMemory(fiMem, &data, &size); - - - byte *Buffer = new byte[size]; - memcpy(Buffer, data, size); - - FreeImage_CloseMemory(fiMem); - - if (BufferSize) *BufferSize = size; - - return Buffer; -#endif - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); - - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - - _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); -#endif - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BImage.h b/engines/wintermute/BImage.h deleted file mode 100644 index 80a09fe60f..0000000000 --- a/engines/wintermute/BImage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BIMAGE_H -#define WINTERMUTE_BIMAGE_H - - -//#include "FreeImage.h" -#include "BBase.h" -#include "common/endian.h" - -struct FIBITMAP; - -namespace WinterMute { - -class CBImage: CBBase { - -public: - CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); - ~CBImage(); - - - byte *CreateBMPBuffer(uint32 *BufferSize = NULL); - HRESULT Resize(int NewWidth, int NewHeight); - HRESULT SaveBMPFile(const char *Filename); - HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); - - FIBITMAP *GetBitmap() const { - return _bitmap; - } -private: - FIBITMAP *_bitmap; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BKeyboardState.cpp b/engines/wintermute/BKeyboardState.cpp deleted file mode 100644 index eb1346e645..0000000000 --- a/engines/wintermute/BKeyboardState.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BKeyboardState.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "common/system.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { - _currentPrintable = false; - _currentCharCode = 0; - _currentKeyData = 0; - - _currentShift = false; - _currentAlt = false; - _currentControl = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { - -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "IsKeyDown") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - int vKey; - - if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { - const char *str = val->GetString(); - char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); - vKey = (int)temp; - } else vKey = val->GetInt(); - - warning("BKeyboardState doesnt yet have state-support"); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); -// bool isDown = state[scanCode] > 0; - -// Stack->PushBool(isDown); - return S_OK; - } - - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("keyboard"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Key - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Key") == 0) { - if (_currentPrintable) { - char key[2]; - key[0] = (char)_currentCharCode; - key[1] = '\0'; - _scValue->SetString(key); - } else _scValue->SetString(""); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Printable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Printable") == 0) { - _scValue->SetBool(_currentPrintable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KeyCode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KeyCode") == 0) { - _scValue->SetInt(_currentCharCode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsShift - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsShift") == 0) { - _scValue->SetBool(_currentShift); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsAlt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsAlt") == 0) { - _scValue->SetBool(_currentAlt); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsControl - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsControl") == 0) { - _scValue->SetBool(_currentControl); - return _scValue; - } - - else return CBScriptable::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Name")==0){ - SetName(Value->GetString()); - if(_renderer) SetWindowText(_renderer->_window, _name); - return S_OK; - } - - else*/ return CBScriptable::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::ScToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ReadKey(Common::Event *event) { - //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = KeyCodeToVKey(event); - //_currentKeyData = KeyData; - - _currentControl = IsControlDown(); - _currentAlt = IsAltDown(); - _currentShift = IsShiftDown(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { - //if(!PersistMgr->_saving) Cleanup(); - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_currentAlt)); - PersistMgr->Transfer(TMEMBER(_currentCharCode)); - PersistMgr->Transfer(TMEMBER(_currentControl)); - PersistMgr->Transfer(TMEMBER(_currentKeyData)); - PersistMgr->Transfer(TMEMBER(_currentPrintable)); - PersistMgr->Transfer(TMEMBER(_currentShift)); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::KeyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; - - switch (event->kbd.keycode) { - case Common::KEYCODE_KP_ENTER: - return Common::KEYCODE_RETURN; - default: - return (uint32)event->kbd.keycode; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { - // todo - return (Common::KeyCode)vkey; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BKeyboardState.h b/engines/wintermute/BKeyboardState.h deleted file mode 100644 index 738f390eea..0000000000 --- a/engines/wintermute/BKeyboardState.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H - - -#include "BBase.h" -#include "BScriptable.h" -#include "common/keyboard.h" -#include "common/events.h" - -namespace WinterMute { - -class CBKeyboardState : public CBScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); - HRESULT ReadKey(Common::Event *event); - - static bool IsShiftDown(); - static bool IsControlDown(); - static bool IsAltDown(); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -private: - uint32 KeyCodeToVKey(Common::Event *event); - Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BNamedObject.cpp b/engines/wintermute/BNamedObject.cpp deleted file mode 100644 index 13dfee0273..0000000000 --- a/engines/wintermute/BNamedObject.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BNamedObject.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBNamedObject::SetName(const char *Name) { - delete[] _name; - - _name = new char [strlen(Name) + 1]; - if (_name != NULL) strcpy(_name, Name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BNamedObject.h b/engines/wintermute/BNamedObject.h deleted file mode 100644 index c3e7e31aa4..0000000000 --- a/engines/wintermute/BNamedObject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H - - -#include "BBase.h" - -namespace WinterMute { - -class CBNamedObject : public CBBase { -public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); - - char *_name; - void SetName(const char *Name); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BObject.cpp b/engines/wintermute/BObject.cpp deleted file mode 100644 index 56c988faea..0000000000 --- a/engines/wintermute/BObject.cpp +++ /dev/null @@ -1,1122 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BObject.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSoundMgr.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBObject, false) - -////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { - _posX = _posY = 0; - _movable = true; - _zoomable = true; - _registrable = true; - _shadowable = true; - _rotatable = false; - _is3D = false; - - _alphaColor = 0; - _scale = -1; - _relativeScale = 0; - - _scaleX = -1; - _scaleY = -1; - - _ready = true; - - _soundEvent = NULL; - - _iD = Game->GetSequence(); - - CBPlatform::SetRectEmpty(&_rect); - _rectSet = false; - - _cursor = NULL; - _activeCursor = NULL; - _sharedCursors = false; - - _sFX = NULL; - _sFXStart = 0; - _sFXVolume = 100; - _autoSoundPanning = true; - - _editorAlwaysRegister = false; - _editorSelected = false; - - _editorOnly = false; - - _rotate = 0.0f; - _rotateValid = false; - _relativeRotate = 0.0f; - - for (int i = 0; i < 7; i++) _caption[i] = NULL; - _saveState = true; - - _nonIntMouseEvents = false; - - // sound FX - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - _blendMode = BLEND_NORMAL; -} - - -////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Cleanup() { - if (Game && Game->_activeObject == this) Game->_activeObject = NULL; - - CBScriptHolder::Cleanup(); - delete[] _soundEvent; - _soundEvent = NULL; - - if (!_sharedCursors) { - delete _cursor; - delete _activeCursor; - _cursor = NULL; - _activeCursor = NULL; - } - delete _sFX; - _sFX = NULL; - - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::SetCaption(const char *Caption, int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) return; - - delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(Caption) + 1]; - if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], Caption); - Game->_stringTable->Expand(&_caption[Case - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBObject::GetCaption(int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; - else return _caption[Case - 1]; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SkipTo") == 0) { - Stack->CorrectParams(2); - _posX = Stack->Pop()->GetInt(); - _posY = Stack->Pop()->GetInt(); - AfterMove(); - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { - Stack->CorrectParams(1); - Stack->PushString(GetCaption(Stack->Pop()->GetInt())); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(SetCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveCursor") == 0) { - Stack->CorrectParams(0); - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } else { - _cursor = NULL; - - } - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCursor") == 0) { - Stack->CorrectParams(0); - if (!_cursor || !_cursor->_filename) Stack->PushNULL(); - else Stack->PushString(_cursor->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_cursor) Stack->PushNULL(); - else Stack->PushNative(_cursor, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasCursor") == 0) { - Stack->CorrectParams(0); - - if (_cursor) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCaption") == 0) { - Stack->CorrectParams(2); - SetCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadSound") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - if (SUCCEEDED(PlaySFX(Filename, false, false))) - Stack->PushBool(true); - else - Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlaySound") == 0) { - Stack->CorrectParams(3); - - const char *Filename; - bool Looping; - uint32 LoopStart; - - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - CScValue *val3 = Stack->Pop(); - - if (val1->_type == VAL_BOOL) { - Filename = NULL; - Looping = val1->GetBool(); - LoopStart = val2->GetInt(); - } else { - if (val1->IsNULL()) Filename = NULL; - else Filename = val1->GetString(); - Looping = val2->IsNULL() ? false : val2->GetBool(); - LoopStart = val3->GetInt(); - } - - if (FAILED(PlaySFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySoundEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlaySoundEvent") == 0) { - Stack->CorrectParams(2); - - const char *Filename; - const char *EventName; - - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - - if (val2->IsNULL()) { - Filename = NULL; - EventName = val1->GetString(); - } else { - Filename = val1->GetString(); - EventName = val2->GetString(); - } - - if (FAILED(PlaySFX(Filename, false, true, EventName))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopSound") == 0) { - Stack->CorrectParams(0); - - if (FAILED(StopSFX())) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseSound") == 0) { - Stack->CorrectParams(0); - - if (FAILED(PauseSFX())) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeSound") == 0) { - Stack->CorrectParams(0); - - if (FAILED(ResumeSFX())) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSoundPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsSoundPlaying") == 0) { - Stack->CorrectParams(0); - - if (_sFX && _sFX->IsPlaying()) Stack->PushBool(true); - else Stack->PushBool(false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSoundPosition") == 0) { - Stack->CorrectParams(1); - - uint32 Time = Stack->Pop()->GetInt(); - if (FAILED(SetSFXTime(Time))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundPosition") == 0) { - Stack->CorrectParams(0); - - if (!_sFX) Stack->PushInt(0); - else Stack->PushInt(_sFX->GetPositionTime()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSoundVolume") == 0) { - Stack->CorrectParams(1); - - int Volume = Stack->Pop()->GetInt(); - if (FAILED(SetSFXVolume(Volume))) Stack->PushBool(false); - else Stack->PushBool(true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundVolume") == 0) { - Stack->CorrectParams(0); - - if (!_sFX) Stack->PushInt(_sFXVolume); - else Stack->PushInt(_sFX->GetVolume()); - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SoundFXNone - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXNone") == 0) { - Stack->CorrectParams(0); - _sFXType = SFX_NONE; - _sFXParam1 = 0; - _sFXParam2 = 0; - _sFXParam3 = 0; - _sFXParam4 = 0; - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXEcho - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXEcho") == 0) { - Stack->CorrectParams(4); - _sFXType = SFX_ECHO; - _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXReverb - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXReverb") == 0) { - Stack->CorrectParams(4); - _sFXType = SFX_REVERB; - _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - Stack->PushNULL(); - - return S_OK; - } - - else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { - _scValue->SetString(GetCaption(1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { - _scValue->SetInt(_posX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { - _scValue->SetInt(_posY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _scValue->SetInt(GetHeight()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Ready (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Ready") == 0) { - _scValue->SetBool(_ready); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Movable") == 0) { - _scValue->SetBool(_movable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { - _scValue->SetBool(_registrable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { - _scValue->SetBool(_zoomable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotatable") == 0) { - _scValue->SetBool(_rotatable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { - _scValue->SetInt((int)_alphaColor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "BlendMode") == 0) { - _scValue->SetInt((int)_blendMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { - if (_scale < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scaleX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scaleY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeScale") == 0) { - _scValue->SetFloat((double)_relativeScale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotate") == 0) { - if (!_rotateValid) _scValue->SetNULL(); - else _scValue->SetFloat((double)_rotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeRotate") == 0) { - _scValue->SetFloat((double)_relativeRotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Colorable") == 0) { - _scValue->SetBool(_shadowable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundPanning") == 0) { - _scValue->SetBool(_autoSoundPanning); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveState") == 0) { - _scValue->SetBool(_saveState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NonIntMouseEvents") == 0) { - _scValue->SetBool(_nonIntMouseEvents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccCaption") == 0) { - _scValue->SetNULL(); - return _scValue; - } - - else return CBScriptHolder::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Caption") == 0) { - SetCaption(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { - _posX = Value->GetInt(); - AfterMove(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { - _posY = Value->GetInt(); - AfterMove(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Movable") == 0) { - _movable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { - _registrable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { - _zoomable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotatable") == 0) { - _rotatable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { - _alphaColor = (uint32)Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "BlendMode") == 0) { - int i = Value->GetInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; - _blendMode = (TSpriteBlendMode)i; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { - if (Value->IsNULL()) _scale = -1; - else _scale = (float)Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleX") == 0) { - if (Value->IsNULL()) _scaleX = -1; - else _scaleX = (float)Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleY") == 0) { - if (Value->IsNULL()) _scaleY = -1; - else _scaleY = (float)Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeScale") == 0) { - _relativeScale = (float)Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotate") == 0) { - if (Value->IsNULL()) { - _rotate = 0.0f; - _rotateValid = false; - } else { - _rotate = (float)Value->GetFloat(); - _rotateValid = true; - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeRotate") == 0) { - _relativeRotate = (float)Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Colorable") == 0) { - _shadowable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundPanning") == 0) { - _autoSoundPanning = Value->GetBool(); - if (!_autoSoundPanning) ResetSoundPan(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveState") == 0) { - _saveState = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccCaption") == 0) { - return S_OK; - } - - else return CBScriptHolder::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::ScToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ShowCursor() { - if (_cursor) return Game->DrawCursor(_cursor); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { - CBScriptHolder::Persist(PersistMgr); - - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); - PersistMgr->Transfer(TMEMBER(_activeCursor)); - PersistMgr->Transfer(TMEMBER(_alphaColor)); - PersistMgr->Transfer(TMEMBER(_autoSoundPanning)); - PersistMgr->Transfer(TMEMBER(_cursor)); - PersistMgr->Transfer(TMEMBER(_sharedCursors)); - PersistMgr->Transfer(TMEMBER(_editorAlwaysRegister)); - PersistMgr->Transfer(TMEMBER(_editorOnly)); - PersistMgr->Transfer(TMEMBER(_editorSelected)); - PersistMgr->Transfer(TMEMBER(_iD)); - PersistMgr->Transfer(TMEMBER(_is3D)); - PersistMgr->Transfer(TMEMBER(_movable)); - PersistMgr->Transfer(TMEMBER(_posX)); - PersistMgr->Transfer(TMEMBER(_posY)); - PersistMgr->Transfer(TMEMBER(_relativeScale)); - PersistMgr->Transfer(TMEMBER(_rotatable)); - PersistMgr->Transfer(TMEMBER(_scale)); - PersistMgr->Transfer(TMEMBER(_sFX)); - PersistMgr->Transfer(TMEMBER(_sFXStart)); - PersistMgr->Transfer(TMEMBER(_sFXVolume)); - PersistMgr->Transfer(TMEMBER(_ready)); - PersistMgr->Transfer(TMEMBER(_rect)); - PersistMgr->Transfer(TMEMBER(_rectSet)); - PersistMgr->Transfer(TMEMBER(_registrable)); - PersistMgr->Transfer(TMEMBER(_shadowable)); - PersistMgr->Transfer(TMEMBER(_soundEvent)); - PersistMgr->Transfer(TMEMBER(_zoomable)); - - PersistMgr->Transfer(TMEMBER(_scaleX)); - PersistMgr->Transfer(TMEMBER(_scaleY)); - - PersistMgr->Transfer(TMEMBER(_rotate)); - PersistMgr->Transfer(TMEMBER(_rotateValid)); - PersistMgr->Transfer(TMEMBER(_relativeRotate)); - - PersistMgr->Transfer(TMEMBER(_saveState)); - PersistMgr->Transfer(TMEMBER(_nonIntMouseEvents)); - - PersistMgr->Transfer(TMEMBER_INT(_sFXType)); - PersistMgr->Transfer(TMEMBER(_sFXParam1)); - PersistMgr->Transfer(TMEMBER(_sFXParam2)); - PersistMgr->Transfer(TMEMBER(_sFXParam3)); - PersistMgr->Transfer(TMEMBER(_sFXParam4)); - - - PersistMgr->Transfer(TMEMBER_INT(_blendMode)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetCursor(const char *Filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile(Filename))) { - delete _cursor; - _cursor = NULL; - return E_FAIL; - } else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetActiveCursor(const char *Filename) { - delete _activeCursor; - _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->LoadFile(Filename))) { - delete _activeCursor; - _activeCursor = NULL; - return E_FAIL; - } else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBObject::GetHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleKeypress(SDL_Event *event) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleMouseWheel(int Delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::PlaySFX(const char *Filename, bool Looping, bool PlayNow, const char *EventName, uint32 LoopStart) { - // just play loaded sound - if (Filename == NULL && _sFX) { - if (Game->_editorMode || _sFXStart) { - _sFX->SetVolume(_sFXVolume); - _sFX->SetPositionTime(_sFXStart); - if (!Game->_editorMode) _sFXStart = 0; - } - if (PlayNow) { - SetSoundEvent(EventName); - if (LoopStart) _sFX->SetLoopStart(LoopStart); - return _sFX->Play(Looping); - } else return S_OK; - } - - if (Filename == NULL) return E_FAIL; - - // create new sound - delete _sFX; - - _sFX = new CBSound(Game); - if (_sFX && SUCCEEDED(_sFX->SetSound(Filename, SOUND_SFX, true))) { - _sFX->SetVolume(_sFXVolume); - if (_sFXStart) { - _sFX->SetPositionTime(_sFXStart); - _sFXStart = 0; - } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (PlayNow) { - SetSoundEvent(EventName); - if (LoopStart) _sFX->SetLoopStart(LoopStart); - return _sFX->Play(Looping); - } else return S_OK; - } else { - delete _sFX; - _sFX = NULL; - return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::StopSFX(bool DeleteSound) { - if (_sFX) { - _sFX->Stop(); - if (DeleteSound) { - delete _sFX; - _sFX = NULL; - } - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::PauseSFX() { - if (_sFX) return _sFX->Pause(); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ResumeSFX() { - if (_sFX) return _sFX->Resume(); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetSFXTime(uint32 Time) { - _sFXStart = Time; - if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(Time); - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetSFXVolume(int Volume) { - _sFXVolume = Volume; - if (_sFX) return _sFX->SetVolume(Volume); - else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::UpdateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->IsPlaying()) { - ApplyEvent(_soundEvent); - SetSoundEvent(NULL); - } - } - - if (_sFX) UpdateOneSound(_sFX); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::UpdateOneSound(CBSound *Sound) { - HRESULT Ret = S_OK; - - if (Sound) { - if (_autoSoundPanning) - Ret = Sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); - - Ret = Sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - } - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ResetSoundPan() { - if (!_sFX) return S_OK; - else { - return _sFX->SetPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::GetExtendedFlag(const char *FlagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::IsReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::SetSoundEvent(const char *EventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (EventName) { - _soundEvent = new char[strlen(EventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, EventName); - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::AfterMove() { - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BObject.h b/engines/wintermute/BObject.h deleted file mode 100644 index 53f3aa794d..0000000000 --- a/engines/wintermute/BObject.h +++ /dev/null @@ -1,145 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H - - -#include "BScriptHolder.h" -#include "persistent.h" - -union SDL_Event; - -namespace WinterMute { - -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual HRESULT AfterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void SetSoundEvent(const char *EventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool IsReady(); - virtual bool GetExtendedFlag(const char *FlagName); - virtual HRESULT ResetSoundPan(); - virtual HRESULT UpdateSounds(); - HRESULT UpdateOneSound(CBSound *Sound); - bool _autoSoundPanning; - uint32 _sFXStart; - int _sFXVolume; - HRESULT SetSFXTime(uint32 Time); - HRESULT SetSFXVolume(int Volume); - HRESULT ResumeSFX(); - HRESULT PauseSFX(); - HRESULT StopSFX(bool DeleteSound = true); - HRESULT PlaySFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); - CBSound *_sFX; - - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - - virtual bool HandleMouseWheel(int Delta); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - virtual bool HandleKeypress(SDL_Event *event); - virtual int GetHeight(); - HRESULT SetCursor(const char *Filename); - HRESULT SetActiveCursor(const char *Filename); - HRESULT Cleanup(); - char *GetCaption(int Case = 1); - void SetCaption(const char *Caption, int Case = 1); - bool _editorSelected; - bool _editorAlwaysRegister; - bool _editorOnly; - bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual HRESULT ShowCursor(); - CBSprite *_cursor; - bool _sharedCursors; - CBSprite *_activeCursor; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; - bool _zoomable; - bool _shadowable; - RECT _rect; - bool _rectSet; - int _iD; - bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); - char *_caption[7]; - char *_soundEvent; - int _posY; - int _posX; - bool _saveState; - - // base - virtual HRESULT Update() { - return E_FAIL; - }; - virtual HRESULT Display() { - return E_FAIL; - }; - virtual HRESULT InvalidateDeviceObjects() { - return S_OK; - }; - virtual HRESULT RestoreDeviceObjects() { - return S_OK; - }; - bool _nonIntMouseEvents; - - -public: - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BPackage.cpp b/engines/wintermute/BPackage.cpp deleted file mode 100644 index 0608fbcde1..0000000000 --- a/engines/wintermute/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BPackage.h" -#include "BGame.h" -#include "BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - CloseFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Open() { - if (_file) return S_OK; - else { - _file = GetFilePointer(); - return _file ? S_OK : E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Close() { - delete _file; - _file = NULL; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - HRESULT ret; - if (FAILED(ret = Open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return E_FAIL; - if (file->read(buffer, size) != 1) return E_FAIL; - else return S_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::GetFilePointer() { - Common::File *file = Game->_fileManager->OpenPackage(_name); - if (!file) { - Game->_fileManager->RequestCD(_cD, _name, ""); - file = Game->_fileManager->OpenPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::CloseFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BPackage.h b/engines/wintermute/BPackage.h deleted file mode 100644 index cd8bb14f40..0000000000 --- a/engines/wintermute/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *GetFilePointer(); - void CloseFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - HRESULT Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - HRESULT Close(); - HRESULT Open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BParser.cpp b/engines/wintermute/BParser.cpp deleted file mode 100644 index f672684f73..0000000000 --- a/engines/wintermute/BParser.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BParser.h" -#include "BGame.h" -#include "PlatformSDL.h" -#include "common/str.h" -#include "common/util.h" - -#define WHITESPACE " \t\n\r" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::GetLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { - SkipCharacters(buf, _whiteSpace); - - // skip comment lines. - while (**buf == ';') { - *buf = strchr(*buf, '\n'); - _parserLine++; - SkipCharacters(buf, _whiteSpace); - } - - if (! **buf) // at end of file - return PARSERR_EOF; - - // find the token. - // for now just use brute force. Improve later. - while (tokens->id != 0) { - if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { - // here we could be matching PART of a string - // we could detect this here or the token list - // could just have the longer tokens first in the list - break; - } - ++tokens; - } - if (tokens->id == 0) { - char *p = strchr(*buf, '\n'); - if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); - - return PARSERR_TOKENNOTFOUND; - } - // skip the token - *buf += strlen(tokens->token); - SkipCharacters(buf, _whiteSpace); - - // get optional name - *name = GetSubText(buf, '\'', '\''); // single quotes - SkipCharacters(buf, _whiteSpace); - - // get optional data - if (**buf == '=') // An assignment rather than a command/object. - *data = GetAssignmentText(buf); - else - *data = GetSubText(buf, '{', '}'); - - return tokens->id; -} - - -////////////////////////////////////////////////////////////////////// -long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; - Game->MiniUpdate(); - char *name; - return GetObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::SkipCharacters(char **buf, const char *toSkip) { - char ch; - while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) - return; - ++*buf; // skip this character - } - // we must be at the end of the buffer if we get here -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::GetSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) - return 0; - ++*buf; // skip opening delimiter - char *result = *buf; - - // now find the closing delimiter - char theChar; - long skip = 1; - - if (open == close) // we cant nest identical delimiters - open = 0; - while ((theChar = **buf) != 0) { - if (theChar == open) - ++skip; - if (theChar == close) { - if (--skip == 0) { - **buf = 0; // null terminate the result string - ++*buf; // move past the closing delimiter - break; - } - } - ++*buf; // try next character - } - return result; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::GetAssignmentText(char **buf) { - ++*buf; // skip the '=' - SkipCharacters(buf, _whiteSpace); - char *result = *buf; - - - if (*result == '"') { - result = GetSubText(buf, '"', '"'); - } else { - // now, we need to find the next whitespace to end the data - char theChar; - - while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars - break; - ++*buf; - } - **buf = 0; // null terminate it - if (theChar) // skip the terminator - ++*buf; - } - - return result; -} - - -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -char *CBParser::GetToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; - while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; - if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; - } - - if (*b == '\'') { - b++; - while (*b && *b != '\'') { - *t++ = *b++; - } - *t++ = 0; - if (*b == '\'') b++; - } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || - *b == '%' || *b == ':' || *b == '{' || *b == '}') { - *t++ = *b++; - *t++ = 0; - } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { - *t++ = *b++; - *t++ = 0; - } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { - while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { - *t++ = *b++; - } - *t++ = 0; - } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { - while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { - *t++ = *b++; - } - *t++ = 0; - } else if (*b == 0) { - *buf = b; - return NULL; - } else { - // Error. - return NULL; - } - - *buf = b; - return token; -} - - -////////////////////////////////////////////////////////////////////// -float CBParser::GetTokenFloat(char **buf) { - char *t = GetToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { - // Error situation. We handle this by return 0. - return 0.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::GetTokenInt(char **buf) { - char *t = GetToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-')) { - // Error situation. We handle this by return 0. - return 0; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::SkipToken(char **buf, char *tok, char * /*msg*/) { - char *t = GetToken(buf); - if (strcmp(t, tok)) return; // Error -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::ScanStr(const char *in, const char *format, ...) { - va_list arg; - va_start(arg, format); - - int num = 0; - in += strspn(in, " \t\n\f"); - - while (*format && *in) { - if (*format == '%') { - format++; - switch (*format) { - case 'd': { - int *a = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - *a = atoi(in); - in += strspn(in, "0123456789+- \t\n\f"); - num++; - break; - } - case 'D': { - int i; - int *list = va_arg(arg, int *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { - list[i++] = atoi(in); - in += strspn(in, "0123456789+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 'b': { - bool *a = va_arg(arg, bool *); - in += strspn(in, " \t\n\f"); - const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - int l = (int)(in2 - in); - - *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || - !scumm_strnicmp(in, "1", l)); - - - in = in2 + strspn(in2, " \t\n\f"); - num++; - break; - } - case 'f': { - float *a = va_arg(arg, float *); - in += strspn(in, " \t\n\f"); - *a = (float)atof(in); - in += strspn(in, "0123456789.eE+- \t\n\f"); - num++; - break; - } - case 'F': { - int i; - float *list = va_arg(arg, float *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { - list[i++] = (float)atof(in); - in += strspn(in, "0123456789.eE+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 's': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\'') { - in++; - const char *in2 = strchr(in, '\''); - if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2; - } - in += strspn(in, " \t\n\f"); - num++; - break; - } - case 'S': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\"') { - in++; - while (*in != '\"') { - if (*in == '\\') { - in++; - switch (*in) { - case '\\': - *a++ = '\\'; - break; - case 'n': - *a++ = '\n'; - break; - case 'r': - *a++ = '\r'; - break; - case 't': - *a++ = '\t'; - break; - case '"': - *a++ = '"'; - break; - default: - *a++ = '\\'; - *a++ = *in; - break; - } //switch - in++; - } else { - *a++ = *in++; - } - } //while in string - in++; - num++; - } //if string started - - //terminate string - *a = '\0'; - break; - } - } - if (*format) format++; - } else if (*format == ' ') { - format++; - in += strspn(in, " \t\n\f"); - } else if (*in == *format) { - in++; - format++; - } else { - num = -1; - break; - } - } - - va_end(arg); - - return num; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BParser.h b/engines/wintermute/BParser.h deleted file mode 100644 index eb88467b7e..0000000000 --- a/engines/wintermute/BParser.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H - - -#define TOKEN_DEF_START \ - enum \ - { \ - TOKEN_NONE = 0, -#define TOKEN_DEF(name) \ - TOKEN_ ## name, -#define TOKEN_DEF_END \ - TOKEN_TOTAL_COUNT \ - }; -#define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ - { -#define TOKEN_TABLE(name) \ - { TOKEN_ ## name, #name }, -#define TOKEN_TABLE_END \ - { 0, 0 } \ - }; - -#define PARSERR_GENERIC -3 -#define PARSERR_EOF -2 -#define PARSERR_TOKENNOTFOUND -1 - -#include "BBase.h" -#include "coll_templ.h" - -namespace WinterMute { - -class CBParser : public CBBase { -public: - struct TokenDesc { - long id; - const char *token; - }; - -public: - int ScanStr(const char *in, const char *format, ...); - char *GetLastOffender(); - void SkipToken(char **buf, char *tok, char *msg = NULL); - int GetTokenInt(char **buf); - float GetTokenFloat(char **buf); - char *GetToken(char **buf); - char *GetAssignmentText(char **buf); - char *GetSubText(char **buf, char open, char close); - void SkipCharacters(char **buf, const char *toSkip); - long GetCommand(char **buf, TokenDesc *tokens, char **params); - long GetObject(char **buf, TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); - char *_whiteSpace; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BPersistMgr.cpp b/engines/wintermute/BPersistMgr.cpp deleted file mode 100644 index 4004375daf..0000000000 --- a/engines/wintermute/BPersistMgr.cpp +++ /dev/null @@ -1,517 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFileManager.h" -#include "BGame.h" -#include "BPersistMgr.h" -#include "BSaveThumbHelper.h" -#include "PlatformSDL.h" -#include "Vector2.h" -#include "StringUtil.h" -#include "BImage.h" -#include "BSound.h" -#include "common/str.h" - -namespace WinterMute { - -#define SAVE_BUFFER_INIT_SIZE 100000 -#define SAVE_BUFFER_GROW_BY 50000 - -#define SAVE_MAGIC 0x45564153 -#define SAVE_MAGIC_2 0x32564153 - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { - _saving = false; - _buffer = NULL; - _bufferSize = 0; - _offset = 0; - - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; - _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - _thumbnailData = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::Cleanup() { - if (_buffer) { - if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0; - _offset = 0; - - delete[] _richBuffer; - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; // ref to buffer - _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - if (_thumbnailData) { - delete [] _thumbnailData; - _thumbnailData = NULL; - } -} - -// TODO: This is not at all endian-safe -uint32 makeUint32(byte first, byte second, byte third, byte fourth) { - uint32 retVal = first; - retVal = retVal & second << 8 & third << 16 & fourth << 24; - return retVal; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitSave(const char *Desc) { - if (!Desc) return E_FAIL; - - HRESULT res; - - Cleanup(); - _saving = true; - - _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); - if (_buffer) { - _bufferSize = SAVE_BUFFER_INIT_SIZE; - res = S_OK; - } else res = E_FAIL; - - - if (SUCCEEDED(res)) { - // get thumbnails - if (!Game->_cachedThumbnail) { - Game->_cachedThumbnail = new CBSaveThumbHelper(Game); - if (FAILED(Game->_cachedThumbnail->StoreThumbnail(true))) { - delete Game->_cachedThumbnail; - Game->_cachedThumbnail = NULL; - } - } - - - uint32 magic = DCGF_MAGIC; - PutDWORD(magic); - - magic = SAVE_MAGIC_2; - PutDWORD(magic); - - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - uint32 Version = makeUint32(VerMajor, VerMinor, ExtMajor, ExtMinor); - PutDWORD(Version); - - // new in ver 2 - PutDWORD((uint32)DCGF_VER_BUILD); - PutString(Game->_name); - - // thumbnail data size - bool ThumbnailOK = false; - - if (Game->_cachedThumbnail) { - if (Game->_cachedThumbnail->_thumbnail) { - uint32 Size = 0; - byte *Buffer = Game->_cachedThumbnail->_thumbnail->CreateBMPBuffer(&Size); - - PutDWORD(Size); - if (Size > 0) PutBytes(Buffer, Size); - - delete [] Buffer; - ThumbnailOK = true; - } - } - if (!ThumbnailOK) PutDWORD(0); - - // in any case, destroy the cached thumbnail once used - delete Game->_cachedThumbnail; - Game->_cachedThumbnail = NULL; - - uint32 DataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(Desc) + 1 + // description - sizeof(uint32); // timestamp - - PutDWORD(DataOffset); - PutString(Desc); -// TODO: Add usefull timestamps, we can't use ctime... -/* time_t Timestamp; - time(&Timestamp); - PutDWORD((uint32)Timestamp);*/ - } - return res; -} -// TODO: Do this properly, this is just a quickfix, that probably doesnt even work. -// The main point of which is ditching BASS completely. -byte getLowByte(uint16 word) { - uint16 mask = 0xff; - return word & mask; -} - -byte getHighByte(uint16 word) { - uint16 mask = 0xff << 8; - word = word & mask; - return word >> 8; -} - -uint16 getLowWord(uint32 dword) { - uint32 mask = 0xffff; - return dword & mask; -} - -uint16 getHighWord(uint32 dword) { - uint32 mask = 0xffff << 16; - dword = dword & mask; - return dword >> 16; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitLoad(const char *Filename) { - Cleanup(); - - _saving = false; - - _buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); - if (_buffer) { - uint32 Magic; - Magic = GetDWORD(); - if (Magic != DCGF_MAGIC) goto init_fail; - - Magic = GetDWORD(); - - if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { - uint32 Version = GetDWORD(); - _savedVerMajor = getLowByte(getLowWord(Version)); - _savedVerMinor = getHighByte(getLowWord(Version)); - _savedExtMajor = getLowByte(getHighWord(Version)); - _savedExtMinor = getHighByte(getHighWord(Version)); - - if (Magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)GetDWORD(); - char *SavedName = GetString(); - if (SavedName == NULL || scumm_stricmp(SavedName, Game->_name) != 0) { - Game->LOG(0, "ERROR: Saved game name doesn't match current game"); - goto init_fail; - } - - // load thumbnail - _thumbnailDataSize = GetDWORD(); - if (_thumbnailDataSize > 0) { - _thumbnailData = new byte[_thumbnailDataSize]; - if (_thumbnailData) { - GetBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; - } - } else _savedVerBuild = 35; // last build with ver1 savegames - - - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - Game->LOG(0, "ERROR: Saved game version is newer than current game"); - goto init_fail; - } - - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - goto init_fail; - } - - /* - if( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - Game->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - } else goto init_fail; - - - uint32 DataOffset = GetDWORD(); - - _savedDescription = GetString(); - _savedTimestamp = (time_t)GetDWORD(); - - _offset = DataOffset; - - return S_OK; - } - -init_fail: - Cleanup(); - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::SaveFile(const char *Filename) { - return Game->_fileManager->SaveFile(Filename, _buffer, _offset, Game->_compressedSavegames, _richBuffer, _richBufferSize); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { - while (_offset + Size > _bufferSize) { - _bufferSize += SAVE_BUFFER_GROW_BY; - _buffer = (byte *)realloc(_buffer, _bufferSize); - if (!_buffer) { - Game->LOG(0, "Error reallocating save buffer to %d bytes", _bufferSize); - return E_FAIL; - } - } - - memcpy(_buffer + _offset, Buffer, Size); - _offset += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { - if (_offset + Size > _bufferSize) { - Game->LOG(0, "Fatal: Save buffer underflow"); - return E_FAIL; - } - - memcpy(Buffer, _buffer + _offset, Size); - _offset += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::GetDWORD() { - uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::PutString(const char *Val) { - if (!Val) PutString("(null)"); - else { - PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::GetString() { - uint32 len = GetDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) return NULL; - else return ret; -} - -////////////////////////////////////////////////////////////////////////// -// bool -HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(bool)); - else return GetBytes((byte *)Val, sizeof(bool)); -} - - -////////////////////////////////////////////////////////////////////////// -// int -HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(int)); - else return GetBytes((byte *)Val, sizeof(int)); -} - - -////////////////////////////////////////////////////////////////////////// -// DWORD -HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); - else return GetBytes((byte *)Val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -// float -HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(float)); - else return GetBytes((byte *)Val, sizeof(float)); -} - - -////////////////////////////////////////////////////////////////////////// -// double -HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(double)); - else return GetBytes((byte *)Val, sizeof(double)); -} - - -////////////////////////////////////////////////////////////////////////// -// char* -HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { - if (_saving) { - PutString(*Val); - return S_OK; - } else { - char *str = GetString(); - if (str) { - - *Val = new char[strlen(str) + 1]; - strcpy(*Val, str); - } else *Val = NULL; - return S_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { - size_t size; - - if (_saving) { - size = Val.size(); - PutBytes((byte *)&size, sizeof(size_t)); - - for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { - PutString((*it).c_str()); - } - } else { - Val.clear(); - GetBytes((byte *)&size, sizeof(size_t)); - - for (size_t i = 0; i < size; i++) { - char *str = GetString(); - if (str) Val.push_back(str); - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -// BYTE -HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(byte)); - else return GetBytes((byte *)Val, sizeof(byte)); -} - - -////////////////////////////////////////////////////////////////////////// -// RECT -HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); - else return GetBytes((byte *)Val, sizeof(RECT)); -} - - -////////////////////////////////////////////////////////////////////////// -// POINT -HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); - else return GetBytes((byte *)Val, sizeof(POINT)); -} - - -////////////////////////////////////////////////////////////////////////// -// Vector2 -HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); - else return GetBytes((byte *)Val, sizeof(Vector2)); -} - - -////////////////////////////////////////////////////////////////////////// -// generic pointer -HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { - int ClassID = -1, InstanceID = -1; - - if (_saving) { - CSysClassRegistry::GetInstance()->GetPointerID(*(void **)Val, &ClassID, &InstanceID); - if (*(void **)Val != NULL && (ClassID == -1 || InstanceID == -1)) { - Game->LOG(0, "Warning: invalid instance '%s'", Name); - } - - PutDWORD(ClassID); - PutDWORD(InstanceID); - } else { - ClassID = GetDWORD(); - InstanceID = GetDWORD(); - - *(void **)Val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild) { - if (_saving) return true; - - // it's ok if we are same or newer than the saved game - if (VerMajor > _savedVerMajor || - (VerMajor == _savedVerMajor && VerMinor > _savedVerMinor) || - (VerMajor == _savedVerMajor && VerMinor == _savedVerMinor && VerBuild > _savedVerBuild) - ) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BPersistMgr.h b/engines/wintermute/BPersistMgr.h deleted file mode 100644 index 10e1c9e880..0000000000 --- a/engines/wintermute/BPersistMgr.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H - - -#include "BBase.h" - -namespace WinterMute { - -class Vector2; - -class CBPersistMgr : public CBBase { -public: - char *_savedDescription; - time_t _savedTimestamp; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; - HRESULT SaveFile(const char *Filename); - uint32 GetDWORD(); - void PutDWORD(uint32 Val); - char *GetString(); - void PutString(const char *Val); - void Cleanup(); - HRESULT InitLoad(const char *Filename); - HRESULT InitSave(const char *Desc); - HRESULT GetBytes(byte *Buffer, uint32 Size); - HRESULT PutBytes(byte *Buffer, uint32 Size); - uint32 _offset; - uint32 _bufferSize; - byte *_buffer; - bool _saving; - - uint32 _richBufferSize; - byte *_richBuffer; - - HRESULT Transfer(const char *Name, void *Val); - HRESULT Transfer(const char *Name, int *Val); - HRESULT Transfer(const char *Name, uint32 *Val); - HRESULT Transfer(const char *Name, float *Val); - HRESULT Transfer(const char *Name, double *Val); - HRESULT Transfer(const char *Name, bool *Val); - HRESULT Transfer(const char *Name, byte *Val); - HRESULT Transfer(const char *Name, RECT *Val); - HRESULT Transfer(const char *Name, POINT *Val); - HRESULT Transfer(const char *Name, char **Val); - HRESULT Transfer(const char *Name, Vector2 *Val); - HRESULT Transfer(const char *Name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL); - virtual ~CBPersistMgr(); - bool CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BPkgFile.cpp b/engines/wintermute/BPkgFile.cpp deleted file mode 100644 index b60b641daf..0000000000 --- a/engines/wintermute/BPkgFile.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BPackage.h" -#include "BPkgFile.h" -#include "BGame.h" -#include "BFileManager.h" -#include "common/util.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { - _fileEntry = NULL; - _file = NULL; - _compressed = false; - -} - -////////////////////////////////////////////////////////////////////////// -CBPkgFile::~CBPkgFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Open(const Common::String &Filename) { - Close(); - - char fileName[MAX_PATH]; - strcpy(fileName, Filename.c_str()); - - // correct slashes - for (uint32 i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '/') fileName[i] = '\\'; - } - - _fileEntry = Game->_fileManager->GetPackageEntry(fileName); - if (!_fileEntry) return E_FAIL; - - _file = _fileEntry->_package->GetFilePointer(); - if (!_file) return E_FAIL; - - // TODO: Cleanup - _compressed = (_fileEntry->_compressedLength != 0); - _size = _fileEntry->_length; - - if (_compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. - _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); - } else { - _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); - } - - SeekToPos(0); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Close() { - if (_fileEntry) { - _fileEntry->_package->CloseFilePointer(_file); - _fileEntry = NULL; - } - _file = NULL; - - // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { - if (!_fileEntry) return E_FAIL; - - HRESULT ret = S_OK; - - if (_pos + Size > _size) { - Size = _size - _pos; - if (Size == 0) return E_FAIL; - } - - ret = _file->read(Buffer, Size); - - _pos += Size; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { - if (!_fileEntry) return E_FAIL; - - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - - return SeekToPos(NewPos); -} - - -#define STREAM_BUFFER_SIZE 4096 -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { - HRESULT ret = S_OK; - - // seek compressed stream to NewPos - _pos = NewPos; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BPkgFile.h b/engines/wintermute/BPkgFile.h deleted file mode 100644 index 4efbf21e0d..0000000000 --- a/engines/wintermute/BPkgFile.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPKGFILE_H -#define WINTERMUTE_BPKGFILE_H - - -#include "BFile.h" -#include "BFileEntry.h" -#include // Added by ClassView - -#define COMPRESSED_BUFFER_SIZE 4096 - -namespace Common { -class SeekableReadStream; -class File; -} - -namespace WinterMute { - -class CBPkgFile : public CBFile { -public: - CBPkgFile(CBGame *inGame); - virtual ~CBPkgFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - bool _inflateInit; - HRESULT SeekToPos(uint32 NewPos); - bool _compressed; - CBFileEntry *_fileEntry; - Common::SeekableReadStream *_file; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BPoint.cpp b/engines/wintermute/BPoint.cpp deleted file mode 100644 index 2cab052b96..0000000000 --- a/engines/wintermute/BPoint.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BPoint.h" -#include "BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBPoint, false) - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPoint::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(x)); - PersistMgr->Transfer(TMEMBER(y)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BPoint.h b/engines/wintermute/BPoint.h deleted file mode 100644 index 1517953ef8..0000000000 --- a/engines/wintermute/BPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H - -#include "persistent.h" -#include "BBase.h" - -namespace WinterMute { - -class CBPoint: public CBBase { -public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); - int y; - int x; - virtual ~CBPoint(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BQuickMsg.cpp b/engines/wintermute/BQuickMsg.cpp deleted file mode 100644 index 49425e7741..0000000000 --- a/engines/wintermute/BQuickMsg.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BQuickMsg.h" -#include "BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *Text): CBBase(inGame) { - _text = new char [strlen(Text) + 1]; - if (_text) strcpy(_text, Text); - _startTime = Game->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { - if (_text) delete [] _text; -} - - -////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::GetText() { - return _text; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BQuickMsg.h b/engines/wintermute/BQuickMsg.h deleted file mode 100644 index cd7b6b6fdc..0000000000 --- a/engines/wintermute/BQuickMsg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H - -#include "BBase.h" - -namespace WinterMute { - -class CBQuickMsg : public CBBase { -public: - char *GetText(); - uint32 _startTime; - char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BRegion.cpp b/engines/wintermute/BRegion.cpp deleted file mode 100644 index 37ab7ff35c..0000000000 --- a/engines/wintermute/BRegion.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBRegion, false) - -////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - CBPlatform::SetRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegion::Cleanup() { - for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); - - CBPlatform::SetRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::CreateRegion() { - return SUCCEEDED(GetBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::PointInRegion(int X, int Y) { - if (_points.GetSize() < 3) return false; - - POINT pt; - pt.x = X; - pt.y = Y; - - RECT rect; - rect.left = X - 1; - rect.right = X + 2; - rect.top = Y - 1; - rect.bottom = Y + 2; - - if (CBPlatform::PtInRect(&_rect, pt)) return PtInPolygon(X, Y); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(POINT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(POINT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { - Game->LOG(0, "'REGION' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - int i; - - for (i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); - break; - - case TOKEN_POINT: { - int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); - } - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - ParseProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in REGION definition"); - return E_FAIL; - } - - CreateRegion(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - - ////////////////////////////////////////////////////////////////////////// - // AddPoint - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "AddPoint") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - _points.Add(new CBPoint(X, Y)); - CreateRegion(); - - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertPoint") == 0) { - Stack->CorrectParams(3); - int Index = Stack->Pop()->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - if (Index >= 0 && Index < _points.GetSize()) { - _points.InsertAt(Index, new CBPoint(X, Y)); - CreateRegion(); - - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPoint") == 0) { - Stack->CorrectParams(3); - int Index = Stack->Pop()->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - - if (Index >= 0 && Index < _points.GetSize()) { - _points[Index]->x = X; - _points[Index]->y = Y; - CreateRegion(); - - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemovePoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemovePoint") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(); - - if (Index >= 0 && Index < _points.GetSize()) { - delete _points[Index]; - _points[Index] = NULL; - - _points.RemoveAt(Index); - CreateRegion(); - - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPoint") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(); - - if (Index >= 0 && Index < _points.GetSize()) { - CScValue *Val = Stack->GetPushValue(); - if (Val) { - Val->SetProperty("X", _points[Index]->x); - Val->SetProperty("Y", _points[Index]->y); - } - } else Stack->PushNULL(); - - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - _scValue->SetBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumPoints") == 0) { - _scValue->SetInt(_points.GetSize()); - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { - _active = Value->GetBool(); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBRegion::ScToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { - if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); - else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - int i; - - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(_lastMimicScale)); - PersistMgr->Transfer(TMEMBER(_lastMimicX)); - PersistMgr->Transfer(TMEMBER(_lastMimicY)); - _points.Persist(PersistMgr); - - return S_OK; -} - - -typedef struct { - double x, y; -} dPoint; - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::PtInPolygon(int X, int Y) { - if (_points.GetSize() < 3) return false; - - int counter = 0; - int i; - double xinters; - dPoint p, p1, p2; - - p.x = (double)X; - p.y = (double)Y; - - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; - - for (i = 1; i <= _points.GetSize(); i++) { - p2.x = (double)_points[i % _points.GetSize()]->x; - p2.y = (double)_points[i % _points.GetSize()]->y; - - if (p.y > MIN(p1.y, p2.y)) { - if (p.y <= MAX(p1.y, p2.y)) { - if (p.x <= MAX(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) - counter++; - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) - return false; - else - return true; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::GetBoundingRect(RECT *Rect) { - if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); - else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - - for (int i = 0; i < _points.GetSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); - - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); - } - CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { - if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; - - Cleanup(); - - for (int i = 0; i < Region->_points.GetSize(); i++) { - int x, y; - - x = (int)((float)Region->_points[i]->x * Scale / 100.0f); - y = (int)((float)Region->_points[i]->y * Scale / 100.0f); - - _points.Add(new CBPoint(x + X, y + Y)); - } - - _lastMimicScale = Scale; - _lastMimicX = X; - _lastMimicY = Y; - - return CreateRegion() ? S_OK : E_FAIL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BRegion.h b/engines/wintermute/BRegion.h deleted file mode 100644 index c265495403..0000000000 --- a/engines/wintermute/BRegion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H - -#include "engines/wintermute/BPoint.h" -#include "engines/wintermute/BObject.h" - -namespace WinterMute { - -class CBRegion : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void Cleanup(); - HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); - HRESULT GetBoundingRect(RECT *Rect); - bool PtInPolygon(int X, int Y); - DECLARE_PERSISTENT(CBRegion, CBObject) - bool _active; - int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); - bool PointInRegion(int X, int Y); - bool CreateRegion(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - RECT _rect; - CBArray _points; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BRegistry.cpp b/engines/wintermute/BRegistry.cpp deleted file mode 100644 index 74d524189a..0000000000 --- a/engines/wintermute/BRegistry.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include -#include "BGame.h" -#include "BRegistry.h" -#include "PathUtil.h" -#include "StringUtil.h" -#include "tinyxml.h" -#include "utils.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { - _iniName = NULL; - - SetIniName("./wme.ini"); - LoadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { - SaveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - -#ifdef __WIN32__ - // check ini file first (so what we can use project files on windows) - char buffer[32768]; - GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, _iniName); - ret = AnsiString(buffer); - - if (buffer != init) return ret; -#endif - - bool found = false; - ret = GetValue(_localValues, subKey, key, found); - if (!found) ret = GetValue(_values, subKey, key, found); - if (!found) ret = init; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int init) { -#ifdef __WIN32__ - int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName); - if (ret != init) return ret; -#endif - - AnsiString val = ReadString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteInt(const AnsiString &subKey, const AnsiString &key, int value) { - WriteString(subKey, key, StringUtil::ToString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::ReadBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (ReadInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return WriteInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetIniName(const char *Name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(Name, '\\') == NULL && strchr(Name, '/') == NULL) { - _iniName = new char [strlen(Name) + 3]; - sprintf(_iniName, "./%s", Name); - } else { - _iniName = new char [strlen(Name) + 1]; - strcpy(_iniName, Name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBRegistry::GetIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::LoadValues(bool local) { - if (local) LoadXml("settings.xml", _localValues); - else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::SaveValues() { - SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetBasePath(const char *basePath) { - _basePath = PathUtil::GetFileNameWithoutExtension(basePath); - - LoadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::CreatePath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - std::ofstream stream; - stream.open(fileName.c_str()); - - if (!stream.is_open()) return; - else { - stream << printer.CStr(); - stream.close(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BRegistry.h b/engines/wintermute/BRegistry.h deleted file mode 100644 index bd4466989e..0000000000 --- a/engines/wintermute/BRegistry.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "BBase.h" - -namespace WinterMute { - -class CBRegistry : public CBBase { -public: - void SetIniName(const char *Name); - char *GetIniName(); - bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool WriteInt(const AnsiString &subKey, const AnsiString &key, int value); - int ReadInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); - - void SetBasePath(const char *basePath); - AnsiString GetBasePath() const { - return _basePath; - } - - void LoadValues(bool local); - void SaveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void LoadXml(const AnsiString fileName, PathValueMap &values); - void SaveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BRenderSDL.cpp b/engines/wintermute/BRenderSDL.cpp deleted file mode 100644 index 9702fc140e..0000000000 --- a/engines/wintermute/BRenderSDL.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BRenderSDL.h" -#include "engines/wintermute/BRegistry.h" -#include "engines/wintermute/BSurfaceSDL.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BImage.h" -#include "engines/wintermute/MathUtil.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSprite.h" -#include "common/system.h" -#include "engines/wintermute/graphics/transparentSurface.h" - -namespace WinterMute { - -// TODO: Redo everything here. - -////////////////////////////////////////////////////////////////////////// -CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { - /* _renderer = NULL; - _win = NULL;*/ - _renderSurface = NULL; - - _borderLeft = _borderRight = _borderTop = _borderBottom = 0; - _ratioX = _ratioY = 1.0f; -} - -////////////////////////////////////////////////////////////////////////// -CBRenderSDL::~CBRenderSDL() { -#if 0 - if (_renderer) SDL_DestroyRenderer(_renderer); - if (_win) SDL_DestroyWindow(_win); - SDL_Quit(); -#endif -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; - -#if 0 - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); -#endif - - _width = width; - _height = height; - - _realWidth = width; - _realHeight = height; - - - // find suitable resolution -#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } -#else - _realWidth = Game->_registry->ReadInt("Debug", "ForceResWidth", _width); - _realHeight = Game->_registry->ReadInt("Debug", "ForceResHeight", _height); -#endif - - /* - _realWidth = 480; - _realHeight = 320; - */ - - - float origAspect = (float)_width / (float)_height; - float realAspect = (float)_realWidth / (float)_realHeight; - - float ratio; - if (origAspect < realAspect) { - // normal to wide - ratio = (float)_realHeight / (float)_height; - } else { - // wide to normal - ratio = (float)_realWidth / (float)_width; - } - - _borderLeft = (_realWidth - (_width * ratio)) / 2; - _borderRight = _realWidth - (_width * ratio) - _borderLeft; - - _borderTop = (_realHeight - (_height * ratio)) / 2; - _borderBottom = _realHeight - (_height * ratio) - _borderTop; - - - - _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; - _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - -#if 0 - Uint32 flags = SDL_WINDOW_SHOWN; -#endif -#ifdef __IPHONEOS__ - flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; -#endif - - //_windowed = Game->_registry->ReadBool("Video", "Windowed", true); -// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; - - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - g_system->beginGFXTransaction(); - g_system->initSize(_width, _height, &format); - OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - - if (gfxError != OSystem::kTransactionSuccess) { - warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return E_FAIL; - } -#if 0 - _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); - - if (!_win) return E_FAIL; -#endif - - warning("TODO: Hide cursor"); - //SDL_ShowCursor(SDL_DISABLE); - -#ifdef __IPHONEOS__ - // SDL defaults to OGL ES2, which doesn't work on old devices - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); -#else - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif -#if 0 - _renderer = SDL_CreateRenderer(_win, -1, 0); - - if (!_renderer) return E_FAIL; -#endif - _renderSurface = new Graphics::Surface(); - _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _active = true; - - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Flip() { - -#ifdef __IPHONEOS__ - // hack: until viewports work correctly, we just paint black bars instead - SDL_SetRenderDrawColor(_renderer, 0x00, 0x00, 0x00, 0xFF); - - static bool firstRefresh = true; // prevents a weird color glitch - if (firstRefresh) { - firstRefresh = false; - } else { - SDL_Rect rect; - if (_borderLeft > 0) { - rect.x = 0; - rect.y = 0; - rect.w = _borderLeft; - rect.h = _realHeight; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderRight > 0) { - rect.x = (_realWidth - _borderRight); - rect.y = 0; - rect.w = _borderRight; - rect.h = _realHeight; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderTop > 0) { - rect.x = 0; - rect.y = 0; - rect.w = _realWidth; - rect.h = _borderTop; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderBottom > 0) { - rect.x = 0; - rect.y = _realHeight - _borderBottom; - rect.w = _realWidth; - rect.h = _borderBottom; - SDL_RenderFillRect(_renderer, &rect); - } - } -#endif - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); - g_system->updateScreen(); - //SDL_RenderPresent(_renderer); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { - //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); - //SDL_RenderClear(_renderer); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fade(uint16 Alpha) { - uint32 dwAlpha = 255 - Alpha; - return FadeToColor(dwAlpha << 24); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Implement CBRenderSDL::FadeToColor"); // TODO. - hasWarned = true; - } -#if 0 - SDL_Rect fillRect; - - if (rect) { - fillRect.x = rect->left; - fillRect.y = rect->top; - fillRect.w = rect->right - rect->left; - fillRect.h = rect->bottom - rect->top; - } else { - RECT rc; - Game->GetCurrentViewportRect(&rc); - fillRect.x = rc.left; - fillRect.y = rc.top; - fillRect.w = rc.right - rc.left; - fillRect.h = rc.bottom - rc.top; - } - ModTargetRect(&fillRect); - - byte r = D3DCOLGetR(Color); - byte g = D3DCOLGetG(Color); - byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color); - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - //SDL_RenderFillRect(_renderer, &fillRect); -#endif - return S_OK; -} - -// Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { - TransparentSurface src(*surf, false); - src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(255, 255, 255, 255), dstRect->width(), dstRect->height() ); -} -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { - static bool hasWarned = false; - if (!hasWarned) { - warning("CBRenderSDL::DrawLine - not fully ported yet"); - hasWarned = true; - } -/* byte r = D3DCOLGetR(Color); - byte g = D3DCOLGetG(Color); - byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color);*/ - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - - POINT point1, point2; - point1.x = X1; - point1.y = Y1; - PointToScreen(&point1); - - point2.x = X2; - point2.y = Y2; - PointToScreen(&point2); - - - //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderSDL::TakeScreenshot() { -// TODO: Fix this -#if 0 - SDL_Rect viewport; - - SDL_RenderGetViewport(_renderer, &viewport); - - SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) return NULL; - - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; - - FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - - int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; - memcpy(bits, src, bytespp * viewport.w); - } - - return new CBImage(Game, dib); -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::SwitchFullscreen() { - /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); - else SDL_SetWindowFullscreen(_win, SDL_FALSE); - - _windowed = !_windowed; - */ - Game->_registry->WriteBool("Video", "Windowed", _windowed); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBRenderSDL::GetName() { - if (_name.empty()) { -#if 0 - if (_renderer) { - SDL_RendererInfo info; - SDL_GetRendererInfo(_renderer, &info); - _name = AnsiString(info.name); - } -#endif - } - return _name.c_str(); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { - Common::Rect rect; - // TODO: Hopefully this is the same logic that ScummVM uses. - rect.left = left + _borderLeft; - rect.top = top + _borderTop; - rect.right = (right - left) * _ratioX; - rect.bottom = (bottom - top) * _ratioY; - - // TODO fix this once viewports work correctly in SDL/landscape -#ifndef __IPHONEOS__ - //SDL_RenderSetViewport(GetSdlRenderer(), &rect); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::ModTargetRect(Common::Rect *rect) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * _ratioX); - rect->h = MathUtil::RoundUp(rect->h * _ratioY); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::PointFromScreen(POINT *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; - point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::PointToScreen(POINT *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::DumpData(const char *Filename) { - FILE *f = fopen(Filename, "wt"); - if (!f) return; - - CBSurfaceStorage *Mgr = Game->_surfaceStorage; - - int TotalKB = 0; - int TotalLoss = 0; - fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.GetSize(); i++) { - CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->_surfaces[i]; - if (!Surf->_filename) continue; - if (!Surf->_valid) continue; - - fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->GetWidth(), Surf->GetHeight()); - - int kb = Surf->GetWidth() * Surf->GetHeight() * 4 / 1024; - - TotalKB += kb; - fprintf(f, "%d;", kb); - fprintf(f, "\n"); - } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.GetSize(), TotalKB); - - - fclose(f); - Game->LOG(0, "Texture Stats Dump completed."); - Game->QuickMessage("Texture Stats Dump completed."); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BRenderSDL.h b/engines/wintermute/BRenderSDL.h deleted file mode 100644 index 0c5760470e..0000000000 --- a/engines/wintermute/BRenderSDL.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_SDL_H -#define WINTERMUTE_BRENDERER_SDL_H - -#include "BRenderer.h" -#include "common/rect.h" -#include "graphics/surface.h" - -class SDL_Window; -class SDL_Renderer; - -namespace WinterMute { - -class CBRenderSDL : public CBRenderer { -public: - CBRenderSDL(CBGame *inGame); - ~CBRenderSDL(); - - const char *GetName(); - - HRESULT InitRenderer(int width, int height, bool windowed); - HRESULT Flip(); - HRESULT Fill(byte r, byte g, byte b, RECT *rect); - - HRESULT Fade(uint16 Alpha); - HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); - - HRESULT SwitchFullscreen(); - - HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); - - CBImage *TakeScreenshot(); - - void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); - - - HRESULT SetViewport(int left, int top, int right, int bottom); - - void ModTargetRect(Common::Rect *rect); - void PointFromScreen(POINT *point); - void PointToScreen(POINT *point); - - void DumpData(const char *Filename); - - float GetScaleRatioX() const { - return _ratioX; - } - float GetScaleRatioY() const { - return _ratioY; - } - -private: - /* SDL_Renderer *_renderer; - SDL_Window *_win;*/ - Graphics::Surface *_renderSurface; - AnsiString _name; - - int _borderLeft; - int _borderTop; - int _borderRight; - int _borderBottom; - - float _ratioX; - float _ratioY; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp deleted file mode 100644 index 714981ea49..0000000000 --- a/engines/wintermute/BRenderer.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BActiveRect.h" -#include "BRenderer.h" -#include "BSurface.h" -#include "BSubFrame.h" -#include "BRegion.h" -#include "PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - _instance = NULL; - _window = NULL; - _clipperWindow = NULL; - _active = false; - _ready = false; - _windowed = true; - _forceAlphaColor = 0x00; - - _width = _height = _bPP = 0; - CBPlatform::SetRectEmpty(&_monitorRect); - - _realWidth = _realHeight = 0; - _drawOffsetX = _drawOffsetY = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBRenderer::~CBRenderer() { - DeleteRectList(); - UnclipCursor(); -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::InitLoop() { - DeleteRectList(); -} - - -////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::GetObjectAt(int X, int Y) { - POINT point; - point.x = X; - point.y = Y; - - for (int i = _rectList.GetSize() - 1; i >= 0; i--) { - if (CBPlatform::PtInRect(&_rectList[i]->_rect, point)) { - if (_rectList[i]->_precise) { - // frame - if (_rectList[i]->_frame) { - int XX = (int)((_rectList[i]->_frame->_rect.left + X - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int YY = (int)((_rectList[i]->_frame->_rect.top + Y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); - - if (_rectList[i]->_frame->_mirrorX) { - int Width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; - XX = Width - XX; - } - - if (_rectList[i]->_frame->_mirrorY) { - int Height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; - YY = Height - YY; - } - - if (!_rectList[i]->_frame->_surface->IsTransparentAt(XX, YY)) return _rectList[i]->_owner; - } - // region - else if (_rectList[i]->_region) { - if (_rectList[i]->_region->PointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; - } - } else return _rectList[i]->_owner; - } - } - - return (CBObject *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderer::DeleteRectList() { - for (int i = 0; i < _rectList.GetSize(); i++) { - delete _rectList[i]; - } - _rectList.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SwitchFullscreen() { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Flip() { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::InitRenderer(int width, int height, bool windowed) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::OnWindowChange() { -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fill(byte r, byte g, byte b, RECT *rect) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::WindowedBlt() { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Setup2D(bool Force) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetupLines() { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { - for (int i = 0; i < Width; i++) { - DrawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up - DrawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down - - DrawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left - DrawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fade(uint16 Alpha) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::FadeToColor(uint32 Color, RECT *rect) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetScreenViewport() { - return SetViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetViewport(RECT *Rect) { - return SetViewport(Rect->left + _drawOffsetX, - Rect->top + _drawOffsetY, - Rect->right + _drawOffsetX, - Rect->bottom + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::TakeScreenshot() { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::ClipCursor() { - /* - if(!_windowed) - { - RECT rc; - GetWindowRect(_window, &rc); - - // if "maintain aspect ratio" is in effect, lock mouse to visible area - rc.left = _drawOffsetX; - rc.top = _drawOffsetY; - rc.right = rc.left + _width; - rc.bottom = rc.top + _height; - - ::ClipCursor(&rc); - } - */ - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::UnclipCursor() { - /* - if(!_windowed) ::ClipCursor(NULL); - */ - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::PointInViewport(POINT *P) { - if (P->x < _drawOffsetX) return false; - if (P->y < _drawOffsetY) return false; - if (P->x > _drawOffsetX + _width) return false; - if (P->y > _drawOffsetY + _height) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BRenderer.h b/engines/wintermute/BRenderer.h deleted file mode 100644 index bd2d23071b..0000000000 --- a/engines/wintermute/BRenderer.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_H -#define WINTERMUTE_BRENDERER_H - - -#include "coll_templ.h" -#include "BBase.h" - -namespace WinterMute { - -class CBImage; -class CBActiveRect; -class CBObject; - -class CBRenderer: public CBBase { -public: - int _realWidth; - int _realHeight; - int _drawOffsetX; - int _drawOffsetY; - - virtual void DumpData(const char *Filename) {}; - virtual CBImage *TakeScreenshot(); - virtual HRESULT SetViewport(int left, int top, int right, int bottom); - virtual HRESULT SetViewport(RECT *Rect); - virtual HRESULT SetScreenViewport(); - virtual HRESULT Fade(uint16 Alpha); - virtual HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); - virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); - virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); - CBRenderer(CBGame *inGame = NULL); - virtual ~CBRenderer(); - virtual HRESULT SetProjection() { - return S_OK; - }; - - virtual HRESULT WindowedBlt(); - virtual HRESULT Fill(byte r, byte g, byte b, RECT *rect = NULL); - virtual void OnWindowChange(); - virtual HRESULT InitRenderer(int width, int height, bool windowed); - virtual HRESULT Flip(); - virtual void InitLoop(); - virtual HRESULT SwitchFullscreen(); - virtual HRESULT Setup2D(bool Force = false); - virtual HRESULT SetupLines(); - - virtual const char *GetName() { - return ""; - }; - virtual HRESULT DisplayDebugInfo() { - return E_FAIL; - }; - virtual HRESULT DrawShaderQuad() { - return E_FAIL; - } - - virtual float GetScaleRatioX() const { - return 1.0f; - } - virtual float GetScaleRatioY() const { - return 1.0f; - } - - HRESULT ClipCursor(); - HRESULT UnclipCursor(); - - CBObject *GetObjectAt(int X, int Y); - void DeleteRectList(); - - virtual HRESULT StartSpriteBatch() { - return S_OK; - }; - virtual HRESULT EndSpriteBatch() { - return S_OK; - }; - bool PointInViewport(POINT *P); - uint32 _forceAlphaColor; - HINSTANCE _instance; - HWND _window; - HWND _clipperWindow; - bool _active; - bool _ready; - bool _windowed; - RECT _windowRect; - RECT _viewportRect; - RECT _screenRect; - RECT _monitorRect; - int _bPP; - int _height; - int _width; - - CBArray _rectList; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BResourceFile.cpp b/engines/wintermute/BResourceFile.cpp deleted file mode 100644 index 83c2283db5..0000000000 --- a/engines/wintermute/BResourceFile.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BResourceFile.h" -#include "BResources.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::~CBResourceFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Open(const Common::String &Filename) { - Close(); - - if (CBResources::GetFile(Filename.c_str(), _data, _size)) { - _pos = 0; - return S_OK; - } - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Close() { - _data = NULL; - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; - - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { - if (!_data) return E_FAIL; - - int32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BResourceFile.h b/engines/wintermute/BResourceFile.h deleted file mode 100644 index 17d396bd22..0000000000 --- a/engines/wintermute/BResourceFile.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCEFILE_H -#define WINTERMUTE_BRESOURCEFILE_H - -#include "BFile.h" - -namespace WinterMute { - -class CBResourceFile : public CBFile { -public: - CBResourceFile(CBGame *inGame); - virtual ~CBResourceFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BResources.cpp b/engines/wintermute/BResources.cpp deleted file mode 100644 index e63f1df307..0000000000 --- a/engines/wintermute/BResources.cpp +++ /dev/null @@ -1,2830 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "PlatformSDL.h" -#include "BResources.h" -#include "common/str.h" - -namespace WinterMute { - -unsigned char invalid[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} ; - -unsigned char invaliddebug[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, - 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, - 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, - 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, - 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, - 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, - 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, - 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, - 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, - 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, - 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, - 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, - 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, - 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, - 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, - 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, - 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, - 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, - 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, - 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, - 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, - 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, - 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, - 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, - 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, - 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, - 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, - 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, - 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, - 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, - 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, - 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, - 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, - 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, - 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, - 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, - 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, - 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, - 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, - 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, - 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, - 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, - 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, - 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, - 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, - 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, - 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, - 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, - 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, - 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, - 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, - 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, - 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, - 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, - 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, - 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, - 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, - 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 -} ; - -unsigned char systemfont[] = { - 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -} ; - - -////////////////////////////////////////////////////////////////////////// -bool CBResources::GetFile(const char *fileName, byte *&buffer, uint32 &size) { - // better! - if (scumm_stricmp(fileName, "invalid.bmp") == 0) { - buffer = invalid; - size = sizeof(invalid); - return true; - } else if (scumm_stricmp(fileName, "invalid_debug.bmp") == 0) { - buffer = invaliddebug; - size = sizeof(invaliddebug); - return true; - } else if (scumm_stricmp(fileName, "syste_font.bmp") == 0) { - buffer = systemfont; - size = sizeof(systemfont); - return true; - } - - - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BResources.h b/engines/wintermute/BResources.h deleted file mode 100644 index 26d92af525..0000000000 --- a/engines/wintermute/BResources.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H - -namespace WinterMute { - -class CBResources { -public: - static bool GetFile(const char *fileName, byte *&buffer, uint32 &size); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSaveThumbFile.cpp b/engines/wintermute/BSaveThumbFile.cpp deleted file mode 100644 index 67e3803a93..0000000000 --- a/engines/wintermute/BSaveThumbFile.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BGame.h" -#include "BSaveThumbFile.h" -#include "PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { - Close(); - - if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; - - char *TempFilename = new char[strlen(Filename.c_str()) - 8]; - strcpy(TempFilename, Filename.c_str() + 9); - for (int i = 0; i < strlen(TempFilename); i++) { - if (TempFilename[i] < '0' || TempFilename[i] > '9') { - TempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int Slot = atoi(TempFilename); - delete [] TempFilename; - - char SlotFilename[MAX_PATH + 1]; - Game->GetSaveSlotFilename(Slot, SlotFilename); - CBPersistMgr *pm = new CBPersistMgr(Game); - if (!pm) return E_FAIL; - - Game->_dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(SlotFilename))) { - Game->_dEBUG_AbsolutePathWarning = true; - delete pm; - return E_FAIL; - } - Game->_dEBUG_AbsolutePathWarning = true; - - HRESULT res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = S_OK; - } else res = E_FAIL; - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; - - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { - if (!_data) return E_FAIL; - - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbFile.h b/engines/wintermute/BSaveThumbFile.h deleted file mode 100644 index d5c6d54ebf..0000000000 --- a/engines/wintermute/BSaveThumbFile.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H - - -#include "BFile.h" - -namespace WinterMute { - -class CBSaveThumbFile : public CBFile { -public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSaveThumbHelper.cpp b/engines/wintermute/BSaveThumbHelper.cpp deleted file mode 100644 index 6ae2f2013f..0000000000 --- a/engines/wintermute/BSaveThumbHelper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BSaveThumbHelper.h" -#include "BImage.h" -#include "BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { - delete _thumbnail; - _thumbnail = NULL; - - if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { - if (DoFlip) { - // when using opengl on windows it seems to be necessary to do this twice - // works normally for direct3d - Game->DisplayContent(false); - Game->_renderer->Flip(); - - Game->DisplayContent(false); - Game->_renderer->Flip(); - } - - CBImage *Screenshot = Game->_renderer->TakeScreenshot(); - if (!Screenshot) return E_FAIL; - - // normal thumbnail - if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { - _thumbnail = new CBImage(Game); - _thumbnail->CopyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); - } - - - delete Screenshot; - Screenshot = NULL; - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSaveThumbHelper.h b/engines/wintermute/BSaveThumbHelper.h deleted file mode 100644 index dfb587e194..0000000000 --- a/engines/wintermute/BSaveThumbHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H - - -#include "BBase.h" - -namespace WinterMute { - -class CBImage; - -class CBSaveThumbHelper : public CBBase { -public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); - HRESULT StoreThumbnail(bool DoFlip = false); - - CBImage *_thumbnail; - CBImage *_richThumbnail; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BScriptHolder.cpp b/engines/wintermute/BScriptHolder.cpp deleted file mode 100644 index 73e513dca3..0000000000 --- a/engines/wintermute/BScriptHolder.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/BScriptHolder.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { - SetName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Cleanup() { - delete[] _filename; - _filename = NULL; - - int i; - - for (i = 0; i < _scripts.GetSize(); i++) { - _scripts[i]->Finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.RemoveAll(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////// -void CBScriptHolder::SetFilename(const char *Filename) { - if (_filename != NULL) delete [] _filename; - - _filename = new char [strlen(Filename) + 1]; - if (_filename != NULL) strcpy(_filename, Filename); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { - int NumHandlers = 0; - - HRESULT ret = E_FAIL; - for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->InvokeEventHandler(EventName, Unbreakable); - if (handler) { - //_scripts.Add(handler); - NumHandlers++; - ret = S_OK; - } - } - } - if (NumHandlers > 0 && Unbreakable) Game->_scEngine->TickUnbreakable(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // DEBUG_CrashMe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "DEBUG_CrashMe") == 0) { - Stack->CorrectParams(0); - byte *p = 0; - *p = 10; - Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ApplyEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ApplyEvent") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - HRESULT ret; - ret = ApplyEvent(val->GetString()); - - if (SUCCEEDED(ret)) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CanHandleEvent") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(CanHandleEvent(Stack->Pop()->GetString())); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleMethod - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CanHandleMethod") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(CanHandleMethod(Stack->Pop()->GetString())); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AttachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AttachScript") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(AddScript(Stack->Pop()->GetString()))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DetachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DetachScript") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool KillThreads = Stack->Pop()->GetBool(false); - bool ret = false; - for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { - _scripts[i]->Finish(KillThreads); - ret = true; - break; - } - } - Stack->PushBool(ret); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScriptRunning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsScriptRunning") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - bool ret = false; - for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { - ret = true; - break; - } - } - Stack->PushBool(ret); - - return S_OK; - } else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("script_holder"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Filename") == 0) { - _scValue->SetString(_filename); - return _scValue; - } - - else return CBScriptable::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } else return CBScriptable::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::ScToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { - return CBBase::SaveAsText(Buffer, Indent); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_freezable)); - PersistMgr->Transfer(TMEMBER(_name)); - _scripts.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::AddScript(const char *Filename) { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { - if (_scripts[i]->_state != SCRIPT_FINISHED) { - Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, _name); - return S_OK; - } - } - } - - CScScript *scr = Game->_scEngine->RunScript(Filename, this); - if (!scr) { - if (Game->_editorForceScripts) { - // editor hack - scr = new CScScript(Game, Game->_scEngine); - scr->_filename = new char[strlen(Filename) + 1]; - strcpy(scr->_filename, Filename); - scr->_state = SCRIPT_ERROR; - scr->_owner = this; - _scripts.Add(scr); - Game->_scEngine->_scripts.Add(scr); - Game->GetDebugMgr()->OnScriptInit(scr); - - return S_OK; - } - return E_FAIL; - } else { - scr->_freezable = _freezable; - _scripts.Add(scr); - return S_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] == Script) { - _scripts.RemoveAt(i); - break; - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->CanHandleEvent(EventName)) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->CanHandleMethod(MethodName)) return true; - } - return false; -} - - -TOKEN_DEF_START -TOKEN_DEF(PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - Game->LOG(0, "'PROPERTY' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - char *PropName = NULL; - char *PropValue = NULL; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] PropName; - PropName = new char[strlen((char *)params) + 1]; - if (PropName) strcpy(PropName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] PropValue; - PropValue = new char[strlen((char *)params) + 1]; - if (PropValue) strcpy(PropValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - Game->LOG(0, "Syntax error in PROPERTY definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - Game->LOG(0, "Error loading PROPERTY definition"); - return E_FAIL; - } - - - CScValue *val = new CScValue(Game); - val->SetString(PropValue); - ScSetProperty(PropName, val); - - delete val; - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::MakeFreezable(bool Freezable) { - _freezable = Freezable; - for (int i = 0; i < _scripts.GetSize(); i++) - _scripts[i]->_freezable = Freezable; - -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::InvokeMethodThread(const char *MethodName) { - for (int i = _scripts.GetSize() - 1; i >= 0; i--) { - if (_scripts[i]->CanHandleMethod(MethodName)) { - - CScScript *thread = new CScScript(Game, _scripts[i]->_engine); - if (thread) { - HRESULT ret = thread->CreateMethodThread(_scripts[i], MethodName); - if (SUCCEEDED(ret)) { - _scripts[i]->_engine->_scripts.Add(thread); - Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], MethodName); - - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { - strcpy(Buf, ScToString()); - if (_name && strcmp(_name, "") != 0) { - strcat(Buf, " Name: "); - strcat(Buf, _name); - } - if (_filename) { - strcat(Buf, " File: "); - strcat(Buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::SendEvent(const char *EventName) { - return SUCCEEDED(ApplyEvent((char *)EventName)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BScriptHolder.h b/engines/wintermute/BScriptHolder.h deleted file mode 100644 index f094d6591a..0000000000 --- a/engines/wintermute/BScriptHolder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H - -#include "coll_templ.h" -#include "persistent.h" -#include "BScriptable.h" - -namespace WinterMute { - -class CBScriptHolder : public CBScriptable { -public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) - - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *InvokeMethodThread(const char *MethodName); - virtual void MakeFreezable(bool Freezable); - bool CanHandleEvent(const char *EventName); - virtual bool CanHandleMethod(const char *EventMethod); - HRESULT Cleanup(); - HRESULT RemoveScript(CScScript *Script); - HRESULT AddScript(const char *Filename); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); - void SetFilename(const char *Filename); - HRESULT ParseProperty(byte *Buffer, bool Complete = true); - char *_filename; - bool _freezable; - bool _ready; - - CBArray _scripts; - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - virtual void ScDebuggerDesc(char *Buf, int BufSize); - // IWmeObject -public: - virtual bool SendEvent(const char *EventName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BScriptable.cpp b/engines/wintermute/BScriptable.cpp deleted file mode 100644 index 78faa0e8ca..0000000000 --- a/engines/wintermute/BScriptable.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BScriptable.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptable, false) - -////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool NoValue, bool Persistable): CBNamedObject(inGame) { - _refCount = 0; - - if (NoValue) _scValue = NULL; - else _scValue = new CScValue(Game); - - _persistable = Persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { - //if(_refCount>0) Game->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); - delete _scValue; - delete _scProp; - _scValue = NULL; - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - /* - Stack->CorrectParams(0); - Stack->PushNULL(); - Script->RuntimeError("Call to undefined method '%s'.", Name); - - return S_OK; - */ - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::ScGetProperty(const char *Name) { - if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->GetProp(Name); - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScSetProperty(const char *Name, CScValue *Value) { - if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->SetProp(Name, Value); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::ScToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *CBScriptable::ScToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::ScToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double CBScriptable::ScToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::ScToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetString(const char *Val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetInt(int Val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetFloat(double Val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetBool(bool Val) { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_refCount)); - PersistMgr->Transfer(TMEMBER(_scProp)); - PersistMgr->Transfer(TMEMBER(_scValue)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::ScCompare(CBScriptable *Val) { - if (this < Val) return -1; - else if (this > Val) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScDebuggerDesc(char *Buf, int BufSize) { - strcpy(Buf, ScToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::CanHandleMethod(char *EventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::InvokeMethodThread(const char *MethodName) { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::DbgGetNativeClass() { - return GetClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::DbgGetProperty(const char *Name) { - return ScGetProperty((char *)Name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BScriptable.h b/engines/wintermute/BScriptable.h deleted file mode 100644 index 5682cfe8e0..0000000000 --- a/engines/wintermute/BScriptable.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H - - -#include "engines/wintermute/BNamedObject.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CScStack; -class CScScript; - -class CBScriptable : public CBNamedObject, public IWmeDebugObject { -public: - virtual CScScript *InvokeMethodThread(const char *MethodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) - - CBScriptable(CBGame *inGame, bool NoValue = false, bool Persistable = true); - virtual ~CBScriptable(); - - // high level scripting interface - virtual bool CanHandleMethod(char *EventMethod); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - virtual void *ScToMemBuffer(); - virtual int ScToInt(); - virtual double ScToFloat(); - virtual bool ScToBool(); - virtual void ScSetString(const char *Val); - virtual void ScSetInt(int Val); - virtual void ScSetFloat(double Val); - virtual void ScSetBool(bool Val); - virtual int ScCompare(CBScriptable *Val); - virtual void ScDebuggerDesc(char *Buf, int BufSize); - int _refCount; - CScValue *_scValue; - CScValue *_scProp; - -public: - // IWmeDebugObject - const char *DbgGetNativeClass(); - IWmeDebugProp *DbgGetProperty(const char *Name); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSound.cpp b/engines/wintermute/BSound.cpp deleted file mode 100644 index d419e827b5..0000000000 --- a/engines/wintermute/BSound.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "BSound.h" -#include "BGame.h" -#include "BSoundMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSound, false) - -////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { - _sound = NULL; - _soundFilename = NULL; - - _soundType = SOUND_SFX; - _soundStreamed = false; - _soundLooping = false; - _soundPlaying = false; - _soundPaused = false; - _soundFreezePaused = false; - _soundPosition = 0; - _soundPrivateVolume = 0; - _soundLoopStart = 0; - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { - if (_sound) Game->_soundMgr->removeSound(_sound); - _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) { - if (_sound) { - Game->_soundMgr->removeSound(_sound); - _sound = NULL; - } - delete[] _soundFilename; - _soundFilename = NULL; - - _sound = Game->_soundMgr->addSound(Filename, Type, Streamed); - if (_sound) { - _soundFilename = new char[strlen(Filename) + 1]; - strcpy(_soundFilename, Filename); - - _soundType = Type; - _soundStreamed = Streamed; - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetSoundSimple() { - _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); - if (_sound) { - if (_soundPosition) _sound->SetPosition(_soundPosition); - _sound->SetLooping(_soundLooping); - _sound->SetPrivateVolume(_soundPrivateVolume); - _sound->SetLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->Resume(); - else return S_OK; - } else return E_FAIL; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::GetLength() { - if (_sound) return _sound->GetLength(); - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Play(bool Looping) { - if (_sound) { - _soundPaused = false; - return _sound->Play(Looping, _soundPosition); - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Stop() { - if (_sound) { - _soundPaused = false; - return _sound->Stop(); - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Pause(bool FreezePaused) { - if (_sound) { - _soundPaused = true; - if (FreezePaused) _sound->_freezePaused = true; - return _sound->Pause(); - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->Resume(); - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { - if (PersistMgr->_saving && _sound) { - _soundPlaying = _sound->IsPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) _soundPosition = _sound->GetPosition(); - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (PersistMgr->_saving) { - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - } - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_soundFilename)); - PersistMgr->Transfer(TMEMBER(_soundLooping)); - PersistMgr->Transfer(TMEMBER(_soundPaused)); - PersistMgr->Transfer(TMEMBER(_soundFreezePaused)); - PersistMgr->Transfer(TMEMBER(_soundPlaying)); - PersistMgr->Transfer(TMEMBER(_soundPosition)); - PersistMgr->Transfer(TMEMBER(_soundPrivateVolume)); - PersistMgr->Transfer(TMEMBER(_soundStreamed)); - PersistMgr->Transfer(TMEMBER_INT(_soundType)); - PersistMgr->Transfer(TMEMBER(_soundLoopStart)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::IsPlaying() { - return _sound && _sound->IsPlaying(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::IsPaused() { - return _sound && _soundPaused; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPositionTime(uint32 Time) { - if (!_sound) return E_FAIL; - _soundPosition = Time; - HRESULT ret = _sound->SetPosition(_soundPosition); - if (_sound->IsPlaying()) _soundPosition = 0; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::GetPositionTime() { - if (!_sound) return 0; - - if (!_sound->IsPlaying()) return 0; - else return _sound->GetPosition(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetVolume(int Volume) { - if (!_sound) return E_FAIL; - else return _sound->SetPrivateVolume(Volume); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPrivateVolume(int Volume) { - if (!_sound) return E_FAIL; - else return _sound->_privateVolume = Volume; -} - - -////////////////////////////////////////////////////////////////////////// -int CBSound::GetVolume() { - if (!_sound) return 0; - else return _sound->_privateVolume; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetLoopStart(uint32 Pos) { - if (!_sound) return E_FAIL; - else { - _sound->SetLoopStart(Pos); - return S_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPan(float Pan) { - if (_sound) return _sound->SetPan(Pan); - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { - if (!_sound) return S_OK; - - if (Type != _sFXType || Param1 != _sFXParam1 || Param2 != _sFXParam2 || Param3 != _sFXParam3 || Param4 != _sFXParam4) { - HRESULT Ret = _sound->ApplyFX(Type, Param1, Param2, Param3, Param4); - - _sFXType = Type; - _sFXParam1 = Param1; - _sFXParam2 = Param2; - _sFXParam3 = Param3; - _sFXParam4 = Param4; - - return Ret; - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSound.h b/engines/wintermute/BSound.h deleted file mode 100644 index 2acdaee464..0000000000 --- a/engines/wintermute/BSound.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H - -#include "BBase.h" -#include "dctypes.h" // Added by ClassView -#include "BSoundBuffer.h" -#include "persistent.h" - -namespace WinterMute { - -class CBSound : public CBBase { -public: - HRESULT SetPan(float Pan); - int _soundPrivateVolume; - int GetVolume(); - HRESULT SetVolume(int Volume); - HRESULT SetPrivateVolume(int Volume); - HRESULT SetLoopStart(uint32 Pos); - uint32 GetPositionTime(); - HRESULT SetPositionTime(uint32 Time); - bool _soundPaused; - bool _soundFreezePaused; - bool IsPlaying(); - bool IsPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) - HRESULT Resume(); - HRESULT Pause(bool FreezePaused = false); - HRESULT Stop(); - HRESULT Play(bool Looping = false); - uint32 GetLength(); - bool _soundStreamed; - TSoundType _soundType; - char *_soundFilename; - HRESULT SetSoundSimple(); - HRESULT SetSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); - - HRESULT ApplyFX(TSFXType Type = SFX_NONE, float Param1 = 0, float Param2 = 0, float Param3 = 0, float Param4 = 0); - -private: - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - CBSoundBuffer *_sound; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp deleted file mode 100644 index 6b689f59ca..0000000000 --- a/engines/wintermute/BSoundBuffer.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFile.h" -#include "BGame.h" -#include "BSoundMgr.h" -#include "BSoundBuffer.h" -#include "BFileManager.h" -#include "utils.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/vorbis.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { - _stream = NULL; - _handle = new Audio::SoundHandle; -// _sync = NULL; - - _streamed = false; - _filename = NULL; - _file = NULL; - _privateVolume = 100; - - _looping = false; - _loopStart = 0; - - _type = SOUND_SFX; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { -#if 0 - Stop(); - - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } - - if (_file) { - Game->_fileManager->CloseFile(_file); - _file = NULL; - } - - SAFE_DELETE_ARRAY(_filename); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { - _streamed = Streamed; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif - delete _stream; - _stream = NULL; - - if (_file) Game->_fileManager->CloseFile(_file); - - _file = Game->_fileManager->OpenFile(Filename); - if (!_file) { - Game->LOG(0, "Error opening sound file '%s'", Filename); - return E_FAIL; - } - - _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES); - CBUtils::SetString(&_filename, Filename); - - return S_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), Filename); - return E_FAIL; - } - - CBUtils::SetString(&_filename, Filename); - - /* - HRESULT res; - bool NewlyCreated = false; - - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = Game->_fileManager->OpenFile(Filename); - if(!_file){ - Game->LOG(0, "Error opening sound file '%s'", Filename); - return E_FAIL; - } - // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if(!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if(FAILED(res)){ - Game->LOG(res, "Error creating sound buffer for file '%s'", Filename); - return res; - } - } - - - - // store filename - if(!_filename){ - _filename = new char[strlen(Filename)+1]; - strcpy(_filename, Filename); - } - - // close file (if not streaming) - if(!_streamed && _file){ - Game->_fileManager->CloseFile(_file); - _file = NULL; - } - */ - - return S_OK; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { - warning("Play: %s", _filename); - if (_stream) { - SetLooping(Looping); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream); - //BASS_ChannelPlay(_stream, TRUE); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetLooping(bool looping) { -#if 0 - _looping = looping; - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Resume() { -#if 0 - if (_stream) { - BASS_ChannelPlay(_stream, FALSE); - } -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Stop() { -#if 0 - if (_stream) { - BASS_ChannelStop(_stream); - } -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Pause() { -#if 0 - if (_stream) { - BASS_ChannelPause(_stream); - } -#endif - return S_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::GetLength() { -#if 0 - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(_stream, len); -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetType(TSoundType Type) { - _type = Type; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetVolume(int Volume) { -#if 0 - if (_stream) { - BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); - } -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { -#if 0 - _privateVolume = Volume; - - switch (_type) { - case SOUND_SFX: - Volume = Game->_soundMgr->_volumeSFX; - break; - case SOUND_SPEECH: - Volume = Game->_soundMgr->_volumeSpeech; - break; - case SOUND_MUSIC: - Volume = Game->_soundMgr->_volumeMusic; - break; - } -#endif - return SetVolume(Volume); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::IsPlaying() { -#if 0 - return _freezePaused || BASS_ChannelIsActive(_stream) == BASS_ACTIVE_PLAYING; -#endif - return false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::GetPosition() { -#if 0 - if (_stream) { - QWORD len = BASS_ChannelGetPosition(_stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(_stream, len); - } else return 0; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetLoopStart(uint32 Pos) { - _loopStart = Pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif - return S_OK; -} -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPan(float Pan) { -#if 0 - if (_stream) { - BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_PAN, Pan); - } -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { -#if 0 - switch (Type) { - case SFX_ECHO: - break; - - case SFX_REVERB: - break; - - default: - break; - } -#endif - return S_OK; -} - -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::FileCloseProc(void *user) { - /* - CBFile* file = static_cast(user); - file->Game->_fileManager->CloseFile(file); - */ -} - -////////////////////////////////////////////////////////////////////////// -QWORD CBSoundBuffer::FileLenProc(void *user) { - CBFile *file = static_cast(user); - return file->GetSize(); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::FileReadProc(void *buffer, uint32 length, void *user) { - CBFile *file = static_cast(user); - uint32 oldPos = file->GetPos(); - file->Read(buffer, length); - return file->GetPos() - oldPos; -} - -////////////////////////////////////////////////////////////////////////// -BOOL CBSoundBuffer::FileSeekProc(QWORD offset, void *user) { - CBFile *file = static_cast(user); - return SUCCEEDED(file->Seek(offset)); -} -#endif -} // end of namespace WinterMute diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h deleted file mode 100644 index 312bb03f31..0000000000 --- a/engines/wintermute/BSoundBuffer.h +++ /dev/null @@ -1,102 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H - - -#include "BBase.h" -//#include "bass.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace WinterMute { - -class CBFile; -class CBSoundBuffer : public CBBase { -public: - - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); - - - HRESULT Pause(); - HRESULT Play(bool Looping = false, uint32 StartSample = 0); - HRESULT Resume(); - HRESULT Stop(); - bool IsPlaying(); - - void SetLooping(bool looping); - - uint32 GetPosition(); - HRESULT SetPosition(uint32 Pos); - uint32 GetLength(); - - HRESULT SetLoopStart(uint32 Pos); - uint32 GetLoopStart() const { - return _loopStart; - } - - HRESULT SetPan(float Pan); - HRESULT SetPrivateVolume(int Volume); - HRESULT SetVolume(int Volume); - - void SetType(TSoundType Type); - - HRESULT LoadFromFile(const char *Filename, bool ForceReload = false); - void SetStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); - HRESULT ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - TSoundType _type; - bool _looping; - CBFile *_file; - char *_filename; - bool _streamed; - int _privateVolume; - - /*static void CALLBACK LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user); - - static void CALLBACK FileCloseProc(void *user); - static QWORD CALLBACK FileLenProc(void *user); - static uint32 CALLBACK FileReadProc(void *buffer, uint32 length, void *user); - static BOOL CALLBACK FileSeekProc(QWORD offset, void *user);*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp deleted file mode 100644 index 6b0ae4e6a6..0000000000 --- a/engines/wintermute/BSoundMgr.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BSoundMgr.h" -#include "BRegistry.h" -#include "PathUtil.h" -#include "StringUtil.h" -#include "BGame.h" -#include "BFileManager.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { - _soundAvailable = false; - - _volumeSFX = _volumeSpeech = _volumeMusic = _volumeMaster = 100; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; - _sounds.RemoveAll(); -#if 0 - BASS_Free(); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { - if (_soundAvailable) { - Game->_registry->WriteInt("Audio", "MasterVolume", _volumeMaster); - - Game->_registry->WriteInt("Audio", "SFXVolume", _volumeSFX); - Game->_registry->WriteInt("Audio", "SpeechVolume", _volumeSpeech); - Game->_registry->WriteInt("Audio", "MusicVolume", _volumeMusic); - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::initialize() { - _soundAvailable = false; -#if 0 - -#ifdef __IPHONEOS__ -#define BASS_CONFIG_IOS_MIXAUDIO 34 - BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); -#endif - - - if (HIWORD(BASS_GetVersion()) != BASSVERSION) { - Game->LOG(0, "An incorrect version of BASS was loaded"); - return E_FAIL; - } - - if (!BASS_Init(-1, 44100, 0, 0, NULL)) { - Game->LOG(0, "Can't initialize sound device"); - return E_FAIL; - } -#endif - - _volumeMaster = Game->_registry->ReadInt("Audio", "MasterVolume", 100); - - _volumeSFX = Game->_registry->ReadInt("Audio", "SFXVolume", 100); - _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100); - _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); - - _soundAvailable = true; - setMasterVolumePercent(_volumeMaster); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::initLoop() { - if (!_soundAvailable) return S_OK; -#if 0 - - BASS_Update(500); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool Streamed) { - if (!_soundAvailable) return NULL; - - CBSoundBuffer *sound; - - // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::CompareNoCase(ext, "wav")) { - AnsiString path = PathUtil::GetDirectoryName(Filename); - AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); - - AnsiString newFile = PathUtil::Combine(path, name + "ogg"); - CBFile *file = Game->_fileManager->OpenFile(newFile.c_str()); - if (file) { - Filename = newFile.c_str(); - Game->_fileManager->CloseFile(file); - } - } - - sound = new CBSoundBuffer(Game); - if (!sound) return NULL; - - sound->SetStreaming(Streamed); - sound->SetType(Type); - - - HRESULT res = sound->LoadFromFile(Filename); - if (FAILED(res)) { - Game->LOG(res, "Error loading sound '%s'", Filename); - delete sound; - return NULL; - } - - // set volume appropriately - switch (Type) { - case SOUND_SFX: - sound->SetVolume(_volumeSFX); - break; - case SOUND_SPEECH: - sound->SetVolume(_volumeSpeech); - break; - case SOUND_MUSIC: - sound->SetVolume(_volumeMusic); - break; - } - - // register sound - _sounds.Add(sound); - - return sound; - - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::addSound(CBSoundBuffer *Sound, TSoundType Type) { - if (!Sound) return E_FAIL; - - // set volume appropriately - switch (Type) { - case SOUND_SFX: - Sound->SetVolume(_volumeSFX); - break; - case SOUND_SPEECH: - Sound->SetVolume(_volumeSpeech); - break; - case SOUND_MUSIC: - Sound->SetVolume(_volumeMusic); - break; - } - - // register sound - _sounds.Add(Sound); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::removeSound(CBSoundBuffer *Sound) { - - for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i] == Sound) { - delete _sounds[i]; - _sounds.RemoveAt(i); - return S_OK; - } - } - - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolume(TSoundType Type, int Volume) { - if (!_soundAvailable) return S_OK; - - switch (Type) { - case SOUND_SFX: - _volumeSFX = Volume; - break; - case SOUND_SPEECH: - _volumeSpeech = Volume; - break; - case SOUND_MUSIC: - _volumeMusic = Volume; - break; - } - - for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume); - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolumePercent(TSoundType Type, byte Percent) { - return setVolume(Type, Percent); -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(TSoundType Type) { - int Volume; - switch (Type) { - case SOUND_SFX: - Volume = _volumeSFX; - break; - case SOUND_SPEECH: - Volume = _volumeSpeech; - break; - case SOUND_MUSIC: - Volume = _volumeMusic; - break; - } - - return (byte)Volume; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setMasterVolumePercent(byte Percent) { - _volumeMaster = Percent; -#if 0 - BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { -#if 0 - uint32 val = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM); - return (float)val / 10000.0f * 100.0f; -#endif - return 0; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::pauseAll(bool IncludingMusic) { - - for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { - _sounds[i]->Pause(); - _sounds[i]->_freezePaused = true; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::resumeAll() { - - for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->Resume(); - _sounds[i]->_freezePaused = false; - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int X, int Y) { - float relPos = (float)X / ((float)Game->_renderer->_width); - - float minPan = -0.7f; - float maxPan = 0.7f; - - return minPan + relPos * (maxPan - minPan); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSoundMgr.h b/engines/wintermute/BSoundMgr.h deleted file mode 100644 index 5cb130c081..0000000000 --- a/engines/wintermute/BSoundMgr.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H - -#include "coll_templ.h" -#include "BBase.h" -#include "BSoundBuffer.h" -//#include "bass.h" - -namespace WinterMute { - -class CBSoundMgr : public CBBase { -public: - float posToPan(int X, int Y); - HRESULT resumeAll(); - HRESULT pauseAll(bool IncludingMusic = true); - HRESULT cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); - byte getMasterVolumePercent(); - HRESULT setMasterVolumePercent(byte Percent); - byte getVolumePercent(TSoundType Type); - HRESULT setVolumePercent(TSoundType Type, byte Percent); - HRESULT setVolume(TSoundType Type, int Volume); - uint32 _volumeOriginal; - int _volumeMaster; - int _volumeMusic; - int _volumeSpeech; - int _volumeSFX; - HRESULT removeSound(CBSoundBuffer *Sound); - CBSoundBuffer *addSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); - HRESULT addSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); - HRESULT initLoop(); - HRESULT initialize(); - bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - CBArray _sounds; - void saveSettings(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSprite.cpp b/engines/wintermute/BSprite.cpp deleted file mode 100644 index 2ecaf1831c..0000000000 --- a/engines/wintermute/BSprite.cpp +++ /dev/null @@ -1,754 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BSurface.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFrame.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSprite, false) - -////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::SetDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - _filename = NULL; - _finished = false; - _changed = false; - _paused = false; - _continuous = false; - _moveX = _moveY = 0; - - _editorMuted = false; - _editorBgFile = NULL; - _editorBgOffsetX = _editorBgOffsetY = 0; - _editorBgAlpha = 0xFF; - _streamed = false; - _streamedKeepLoaded = false; - - SetName(""); - - _precise = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::Cleanup() { - CBScriptHolder::Cleanup(); - - for (int i = 0; i < _frames.GetSize(); i++) - delete _frames[i]; - _frames.RemoveAll(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha) { - GetCurrentFrame(ZoomX, ZoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; - - // move owner if allowed to - if (_changed && _owner && _owner->_movable) { - _owner->_posX += _moveX; - _owner->_posY += _moveY; - _owner->AfterMove(); - - X = _owner->_posX; - Y = _owner->_posY; - } - - // draw frame - return Display(X, Y, Register, ZoomX, ZoomY, Alpha); -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - CBFile *File = Game->_fileManager->OpenFile(Filename); - if (!File) { - Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); - if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); - else return LoadFile("invalid.bmp", LifeTime, CacheType); - } else { - Game->_fileManager->CloseFile(File); - File = NULL; - } - - HRESULT ret; - - AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, "bmp") || StringUtil::CompareNoCase(ext, "tga") || StringUtil::CompareNoCase(ext, "png") || StringUtil::CompareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(Game); - CBSubFrame *subframe = new CBSubFrame(Game); - subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); - if (subframe->_surface == NULL) { - Game->LOG(0, "Error loading simple sprite '%s'", Filename); - ret = E_FAIL; - delete frame; - delete subframe; - } else { - CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->GetWidth(), subframe->_surface->GetHeight()); - frame->_subframes.Add(subframe); - _frames.Add(frame); - _currentFrame = 0; - ret = S_OK; - } - } else { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer) { - if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); - delete [] Buffer; - } - } - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - - return ret; -} - - - -TOKEN_DEF_START -TOKEN_DEF(CONTINUOUS) -TOKEN_DEF(SPRITE) -TOKEN_DEF(LOOPING) -TOKEN_DEF(FRAME) -TOKEN_DEF(NAME) -TOKEN_DEF(PRECISE) -TOKEN_DEF(EDITOR_MUTED) -TOKEN_DEF(STREAMED_KEEP_LOADED) -TOKEN_DEF(STREAMED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_BG_FILE) -TOKEN_DEF(EDITOR_BG_OFFSET_X) -TOKEN_DEF(EDITOR_BG_OFFSET_Y) -TOKEN_DEF(EDITOR_BG_ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(CONTINUOUS) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(LOOPING) - TOKEN_TABLE(FRAME) - TOKEN_TABLE(NAME) - TOKEN_TABLE(PRECISE) - TOKEN_TABLE(EDITOR_MUTED) - TOKEN_TABLE(STREAMED_KEEP_LOADED) - TOKEN_TABLE(STREAMED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_BG_FILE) - TOKEN_TABLE(EDITOR_BG_OFFSET_X) - TOKEN_TABLE(EDITOR_BG_OFFSET_Y) - TOKEN_TABLE(EDITOR_BG_ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - Cleanup(); - - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - Game->LOG(0, "'SPRITE' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - int frame_count = 1; - CBFrame *frame; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_CONTINUOUS: - parser.ScanStr((char *)params, "%b", &_continuous); - break; - - case TOKEN_EDITOR_MUTED: - parser.ScanStr((char *)params, "%b", &_editorMuted); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_LOOPING: - parser.ScanStr((char *)params, "%b", &_looping); - break; - - case TOKEN_PRECISE: - parser.ScanStr((char *)params, "%b", &_precise); - break; - - case TOKEN_STREAMED: - parser.ScanStr((char *)params, "%b", &_streamed); - if (_streamed && LifeTime == -1) { - LifeTime = 500; - CacheType = CACHE_ALL; - } - break; - - case TOKEN_STREAMED_KEEP_LOADED: - parser.ScanStr((char *)params, "%b", &_streamedKeepLoaded); - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_EDITOR_BG_FILE: - if (Game->_editorMode) { - delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); - } - break; - - case TOKEN_EDITOR_BG_OFFSET_X: - parser.ScanStr((char *)params, "%d", &_editorBgOffsetX); - break; - - case TOKEN_EDITOR_BG_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &_editorBgOffsetY); - break; - - case TOKEN_EDITOR_BG_ALPHA: - parser.ScanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = MIN(_editorBgAlpha, 255); - _editorBgAlpha = MAX(_editorBgAlpha, 0); - break; - - case TOKEN_FRAME: { - int FrameLifeTime = LifeTime; - if (CacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; - - frame = new CBFrame(Game); - - if (FAILED(frame->LoadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { - delete frame; - Game->LOG(0, "Error parsing frame %d", frame_count); - return E_FAIL; - } - - _frames.Add(frame); - frame_count++; - if (_currentFrame == -1) _currentFrame = 0; - } - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SPRITE definition"); - return E_FAIL; - } - _canBreak = !_continuous; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBSprite::Reset() { - if (_frames.GetSize() > 0) _currentFrame = 0; - else _currentFrame = -1; - - KillAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { - //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true; - - if (_currentFrame == -1) return false; - - uint32 timer; - if (_owner && _owner->_freezable) timer = Game->_timer; - else timer = Game->_liveTimer; - - int LastFrame = _currentFrame; - - // get current frame - if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.GetSize() - 1) { - _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (LastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); - } - - if (_changed) { - _moveX = _frames[_currentFrame]->_moveX; - _moveY = _frames[_currentFrame]->_moveY; - - if (ZoomX != 100 || ZoomY != 100) { - _moveX = (int)((float)_moveX * (float)(ZoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(ZoomY / 100.0f)); - } - } - - return _changed; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; - - // on change... - if (_changed) { - if (_frames[_currentFrame]->_killSound) { - KillAllSounds(); - } - ApplyEvent("FrameChanged"); - _frames[_currentFrame]->OneTimeDisplay(_owner, Game->_editorMode && _editorMuted); - } - - // draw frame - return _frames[_currentFrame]->Draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); -} - - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::GetSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.GetSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; - - CBPlatform::SetRectEmpty(Rect); - for (int i = 0; i < _frames.GetSize(); i++) { - RECT frame; - RECT temp; - CBPlatform::CopyRect(&temp, Rect); - _frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); - CBPlatform::UnionRect(Rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SPRITE {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); - if (_streamed) { - Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - - if (_streamedKeepLoaded) - Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); - } - - if (_editorMuted) - Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - - if (_editorBgFile) { - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); - } - - CBScriptHolder::SaveAsText(Buffer, Indent + 2); - - int i; - - // scripts - for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - - for (i = 0; i < _frames.GetSize(); i++) { - _frames[i]->SaveAsText(Buffer, Indent + 2); - } - - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { - CBScriptHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_canBreak)); - PersistMgr->Transfer(TMEMBER(_changed)); - PersistMgr->Transfer(TMEMBER(_paused)); - PersistMgr->Transfer(TMEMBER(_continuous)); - PersistMgr->Transfer(TMEMBER(_currentFrame)); - PersistMgr->Transfer(TMEMBER(_editorAllFrames)); - PersistMgr->Transfer(TMEMBER(_editorBgAlpha)); - PersistMgr->Transfer(TMEMBER(_editorBgFile)); - PersistMgr->Transfer(TMEMBER(_editorBgOffsetX)); - PersistMgr->Transfer(TMEMBER(_editorBgOffsetY)); - PersistMgr->Transfer(TMEMBER(_editorMuted)); - PersistMgr->Transfer(TMEMBER(_finished)); - - _frames.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_lastFrameTime)); - PersistMgr->Transfer(TMEMBER(_looping)); - PersistMgr->Transfer(TMEMBER(_moveX)); - PersistMgr->Transfer(TMEMBER(_moveY)); - PersistMgr->Transfer(TMEMBER(_owner)); - PersistMgr->Transfer(TMEMBER(_precise)); - PersistMgr->Transfer(TMEMBER(_streamed)); - PersistMgr->Transfer(TMEMBER(_streamedKeepLoaded)); - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetFrame") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); - if (Index < 0 || Index >= _frames.GetSize()) { - Script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushNative(_frames[Index], true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteFrame") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - if (Val->IsInt()) { - int Index = Val->GetInt(-1); - if (Index < 0 || Index >= _frames.GetSize()) { - Script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); - } - } else { - CBFrame *Frame = (CBFrame *)Val->GetNative(); - for (int i = 0; i < _frames.GetSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; - delete _frames[i]; - _frames.RemoveAt(i); - break; - } - } - } - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); - Reset(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddFrame") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); - - CBFrame *Frame = new CBFrame(Game); - if (Filename != NULL) { - CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->SetSurface(Filename))) { - Sub->SetDefaultRect(); - Frame->_subframes.Add(Sub); - } else delete Sub; - } - _frames.Add(Frame); - - Stack->PushNative(Frame, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertFrame") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - if (Index < 0) Index = 0; - - CScValue *Val = Stack->Pop(); - const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); - - CBFrame *Frame = new CBFrame(Game); - if (Filename != NULL) { - CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->_subframes.Add(Sub); - else delete Sub; - } - - if (Index >= _frames.GetSize()) _frames.Add(Frame); - else _frames.InsertAt(Index, Frame); - - Stack->PushNative(Frame, true); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pause") == 0) { - Stack->CorrectParams(0); - _paused = true; - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Play - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Play") == 0) { - Stack->CorrectParams(0); - _paused = false; - Stack->PushNULL(); - return S_OK; - } - - else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("sprite"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFrames (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumFrames") == 0) { - _scValue->SetInt(_frames.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CurrentFrame") == 0) { - _scValue->SetInt(_currentFrame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { - _scValue->SetBool(_precise); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Looping") == 0) { - _scValue->SetBool(_looping); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Owner (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Owner") == 0) { - if (_owner == NULL) _scValue->SetNULL(); - else _scValue->SetNative(_owner, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Finished (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Finished") == 0) { - _scValue->SetBool(_finished); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Paused (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Paused") == 0) { - _scValue->SetBool(_paused); - return _scValue; - } - - else return CBScriptHolder::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "CurrentFrame") == 0) { - _currentFrame = Value->GetInt(0); - if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { - _currentFrame = -1; - } - _lastFrameTime = 0; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { - _precise = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Looping") == 0) { - _looping = Value->GetBool(); - return S_OK; - } - - else return CBScriptHolder::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSprite::ScToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::KillAllSounds() { - for (int i = 0; i < _frames.GetSize(); i++) { - if (_frames[i]->_sound) _frames[i]->_sound->Stop(); - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSprite.h b/engines/wintermute/BSprite.h deleted file mode 100644 index 085dafe8d8..0000000000 --- a/engines/wintermute/BSprite.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/BScriptHolder.h" - -namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { -public: - HRESULT KillAllSounds(); - CBSurface *GetSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void Cleanup(); - void SetDefaults(); - bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) - - bool _editorAllFrames; - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - int _moveY; - int _moveX; - HRESULT Display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; - void Reset(); - CBObject *_owner; - bool _changed; - bool _paused; - bool _finished; - HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - uint32 _lastFrameTime; - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); - bool _looping; - int _currentFrame; - HRESULT AddFrame(const char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); - CBSprite(CBGame *inGame, CBObject *Owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BStringTable.cpp b/engines/wintermute/BStringTable.cpp deleted file mode 100644 index a8d10efd3c..0000000000 --- a/engines/wintermute/BStringTable.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "PlatformSDL.h" -#include "BFileManager.h" -#include "BGame.h" -#include "BStringTable.h" -#include "StringUtil.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDuplicities) { - if (Key == NULL || Val == NULL) return E_FAIL; - - if (scumm_stricmp(Key, "@right-to-left") == 0) { - Game->_textRTL = true; - return S_OK; - } - - Common::String final_key = Key; - StringUtil::ToLowerCase(final_key); - - _stringsIter = _strings.find(final_key); - if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); - - _strings[final_key] = Val; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -char *CBStringTable::GetKey(const char *Str) { - if (Str == NULL || Str[0] != '/') return NULL; - - char *value = strchr((char *)Str + 1, '/'); - if (value == NULL) return NULL; - - char *key = new char[value - Str]; - strncpy(key, Str + 1, value - Str - 1); - key[value - Str - 1] = '\0'; - CBPlatform::strlwr(key); - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = GetKey(new_str); - delete [] new_str; - return Ret; - } else { - delete [] new_str; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBStringTable::Expand(char **Str, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return; - - if (Str == NULL || *Str == NULL || *Str[0] != '/') return; - - char *value = strchr(*Str + 1, '/'); - if (value == NULL) return; - - char *key = new char[value - *Str]; - strncpy(key, *Str + 1, value - *Str - 1); - key[value - *Str - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); - } - - delete [] key; - delete [] *Str; - *Str = new_str; - - if (strlen(*Str) > 0 && *Str[0] == '/') Expand(Str, ForceExpand); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return String; - - if (String == NULL || String[0] == '\0' || String[0] != '/') return String; - - const char *value = strchr(String + 1, '/'); - if (value == NULL) return String; - - char *key = new char[value - String]; - strncpy(key, String + 1, value - String - 1); - key[value - String - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - const char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); - } else { - new_str = value; - } - - delete [] key; - - if (strlen(new_str) > 0 && new_str[0] == '/') return ExpandStatic(new_str, ForceExpand); - else return new_str; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::LoadFile(const char *Filename, bool ClearOld) { - Game->LOG(0, "Loading string table..."); - - if (ClearOld) _strings.clear(); - - uint32 Size; - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); - if (Buffer == NULL) { - Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - int Pos = 0; - - if (Size > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { - Pos += 3; - if (Game->_textEncoding != TEXT_UTF8) { - Game->_textEncoding = TEXT_UTF8; - //Game->_textEncoding = TEXT_ANSI; - Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); - } - } else Game->_textEncoding = TEXT_ANSI; - - int LineLength = 0; - while (Pos < Size) { - LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; - - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *line = new char[RealLength + 1]; - strncpy(line, (char *)&Buffer[Pos], RealLength); - line[RealLength] = '\0'; - char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); - - if (line[0] != ';') { - if (value != NULL) { - value[0] = '\0'; - value++; - for (int i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; - } - AddString(line, value, ClearOld); - } else if (line[0] != '\0') AddString(line, "", ClearOld); - } - - delete [] line; - Pos += LineLength + 1; - } - - delete [] Buffer; - - Game->LOG(0, " %d strings loaded", _strings.size()); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BStringTable.h b/engines/wintermute/BStringTable.h deleted file mode 100644 index bbaf819eb7..0000000000 --- a/engines/wintermute/BStringTable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H - - -#include "common/hashmap.h" -#include "BBase.h" - -namespace WinterMute { - -class CBStringTable : public CBBase { -public: - const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT LoadFile(const char *Filename, bool DeleteAll = true); - void Expand(char **Str, bool ForceExpand = false); - HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); - Common::HashMap _strings; - char *GetKey(const char *Str); -private: - Common::HashMap::iterator _stringsIter; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSubFrame.cpp b/engines/wintermute/BSubFrame.cpp deleted file mode 100644 index 2e54e1a1ec..0000000000 --- a/engines/wintermute/BSubFrame.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BSurface.h" -#include "engines/wintermute/BSurfaceStorage.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - CBPlatform::SetRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { - if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; -} - - -TOKEN_DEF_START -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(DECORATION) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - RECT rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custo_trans = false; - CBPlatform::SetRectEmpty(&rect); - char *surface_file = NULL; - - delete _surface; - _surface = NULL; - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - - case TOKEN_RECT: - parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &_hotspotX, &_hotspotY); - break; - - case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &_2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &_3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &_mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &_mirrorY); - break; - - case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &_decoration); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SUBFRAME definition"); - return E_FAIL; - } - - if (surface_file != NULL) { - if (custo_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); - } - - _alpha = DRGBA(ar, ag, ab, alpha); - if (custo_trans) _transparent = DRGBA(r, g, b, 0xFF); - - /* - if(_surface == NULL) - { - Game->LOG(0, "Error parsing sub-frame. Image not set."); - return E_FAIL; - } - */ - if (CBPlatform::IsRectEmpty(&rect)) SetDefaultRect(); - else _rect = rect; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (!_surface) return S_OK; - - if (Register != NULL && !_decoration) { - if (ZoomX == 100 && ZoomY == 100) { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, X - _hotspotX + _rect.left, Y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, ZoomX, ZoomY, Precise)); - } else { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (_hotspotX + _rect.left) * (ZoomX / 100)), (int)(Y - (_hotspotY + _rect.top) * (ZoomY / 100)), (int)((_rect.right - _rect.left) * (ZoomX / 100)), (int)((_rect.bottom - _rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); - } - } - if (Game->_suspendedRendering) return S_OK; - - HRESULT res; - - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) Alpha = _alpha; - - if (Rotate != 0.0f) { - res = _surface->DisplayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); - } else { - if (ZoomX == 100 && ZoomY == 100) res = _surface->DisplayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); - else res = _surface->DisplayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; - - float RatioX = ScaleX / 100.0f; - float RatioY = ScaleY / 100.0f; - - CBPlatform::SetRect(Rect, - X - _hotspotX * RatioX, - Y - _hotspotY * RatioY, - X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX, - Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { - if (Complete) - Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); - - if (_surface && _surface->_filename != NULL) - Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); - - if (_transparent != 0xFFFF00FF) - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); - - RECT rect; - CBPlatform::SetRectEmpty(&rect); - if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); - if (!CBPlatform::EqualRect(&rect, &_rect)) - Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); - - if (_hotspotX != 0 || _hotspotY != 0) - Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - - if (_alpha != 0xFFFFFFFF) { - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); - } - - if (_mirrorX) - Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - - if (_mirrorY) - Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - - if (_2DOnly) - Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - - if (_3DOnly) - Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - - if (_decoration) - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - - if (_editorSelected) - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - CBBase::SaveAsText(Buffer, Indent + 2); - - - if (Complete) - Buffer->PutTextIndent(Indent, "}\n\n"); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSubFrame::SetDefaultRect() { - if (_surface) { - CBPlatform::SetRect(&_rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); - } else CBPlatform::SetRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_2DOnly)); - PersistMgr->Transfer(TMEMBER(_3DOnly)); - PersistMgr->Transfer(TMEMBER(_alpha)); - PersistMgr->Transfer(TMEMBER(_decoration)); - PersistMgr->Transfer(TMEMBER(_editorSelected)); - PersistMgr->Transfer(TMEMBER(_hotspotX)); - PersistMgr->Transfer(TMEMBER(_hotspotY)); - PersistMgr->Transfer(TMEMBER(_rect)); - - PersistMgr->Transfer(TMEMBER(_surfaceFilename)); - PersistMgr->Transfer(TMEMBER(_cKDefault)); - PersistMgr->Transfer(TMEMBER(_cKRed)); - PersistMgr->Transfer(TMEMBER(_cKGreen)); - PersistMgr->Transfer(TMEMBER(_cKBlue)); - PersistMgr->Transfer(TMEMBER(_lifeTime)); - - PersistMgr->Transfer(TMEMBER(_keepLoaded)); - PersistMgr->Transfer(TMEMBER(_mirrorX)); - PersistMgr->Transfer(TMEMBER(_mirrorY)); - PersistMgr->Transfer(TMEMBER(_transparent)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetImage") == 0) { - Stack->CorrectParams(0); - - if (!_surfaceFilename) Stack->PushNULL(); - else Stack->PushString(_surfaceFilename); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetImage") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (Val->IsNULL()) { - if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; - Stack->PushBool(true); - } else { - const char *Filename = Val->GetString(); - if (SUCCEEDED(SetSurface(Filename))) { - SetDefaultRect(); - Stack->PushBool(true); - } else Stack->PushBool(false); - } - - return S_OK; - } - - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::ScGetProperty(const char *Name) { - if (!_scValue) _scValue = new CScValue(Game); - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("subframe"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { - - _scValue->SetInt((int)_alpha); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TransparentColor (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TransparentColor") == 0) { - _scValue->SetInt((int)_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is2DOnly") == 0) { - _scValue->SetBool(_2DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is3DOnly") == 0) { - _scValue->SetBool(_3DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorX") == 0) { - _scValue->SetBool(_mirrorX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorY") == 0) { - _scValue->SetBool(_mirrorY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { - _scValue->SetBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotX") == 0) { - _scValue->SetInt(_hotspotX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotY") == 0) { - _scValue->SetInt(_hotspotY); - return _scValue; - } - - else return CBScriptable::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "AlphaColor") == 0) { - _alpha = (uint32)Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is2DOnly") == 0) { - _2DOnly = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is3DOnly") == 0) { - _3DOnly = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorX") == 0) { - _mirrorX = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorY") == 0) { - _mirrorY = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { - _decoration = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotX") == 0) { - _hotspotX = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotY") == 0) { - _hotspotY = Value->GetInt(); - return S_OK; - } - - else return CBScriptable::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::ScToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SetSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - if (_surface) { - Game->_surfaceStorage->RemoveSurface(_surface); - _surface = NULL; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = Game->_surfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - if (_surface) { - _surfaceFilename = new char[strlen(Filename) + 1]; - strcpy(_surfaceFilename, Filename); - - _cKDefault = default_ck; - _cKRed = ck_red; - _cKGreen = ck_green; - _cKBlue = ck_blue; - _lifeTime = LifeTime; - _keepLoaded = KeepLoaded; - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SetSurfaceSimple() { - if (!_surfaceFilename) { - _surface = NULL; - return S_OK; - } - _surface = Game->_surfaceStorage->AddSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return S_OK; - else return E_FAIL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSubFrame.h b/engines/wintermute/BSubFrame.h deleted file mode 100644 index 80c0cc6092..0000000000 --- a/engines/wintermute/BSubFrame.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H - - -#include "BBase.h" -#include "BScriptable.h" - -namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - HRESULT SetSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); - HRESULT SetSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) - void SetDefaultRect(); - uint32 _transparent; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); - bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); - HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - - int _hotspotX; - int _hotspotY; - uint32 _alpha; - RECT _rect; - - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - CBSurface *_surface; - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSurface.cpp b/engines/wintermute/BSurface.cpp deleted file mode 100644 index d08ceee6ea..0000000000 --- a/engines/wintermute/BSurface.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "wintypes.h" -#include "BGame.h" -#include "BSurface.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { - _referenceCount = 0; - - _width = _height = 0; - - _filename = NULL; - - _pixelOpReady = false; - - _cKDefault = true; - _cKRed = _cKGreen = _cKBlue = 0; - _lifeTime = 0; - _keepLoaded = false; - - _lastUsedTime = 0; - _valid = false; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface::~CBSurface() { - if (_pixelOpReady) EndPixelOp(); - if (_filename) delete [] _filename; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Restore() { - return E_FAIL; -} - - - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::IsTransparentAt(int X, int Y) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayHalfTrans(int X, int Y, RECT rect) { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DisplayTransZoom(X, Y, Rect, ZoomX, ZoomY, Alpha, BlendMode, MirrorX, MirrorY); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Create(int Width, int Height) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::StartPixelOp() { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::EndPixelOp() { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::PutPixel(int X, int Y, byte R, byte G, byte B, int A) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::ComparePixel(int X, int Y, byte R, byte G, byte B, int A) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::IsTransparentAtLite(int X, int Y) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Invalidate() { - return E_FAIL; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::PrepareToDraw() { - _lastUsedTime = Game->_liveTimer; - - if (!_valid) { - //Game->LOG(0, "Reviving: %s", _filename); - return Create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - } else return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSurface::SetFilename(const char *Filename) { - delete[] _filename; - _filename = NULL; - if (!Filename) return; - - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); -} - -////////////////////////////////////////////////////////////////////////// -void CBSurface::SetSize(int Width, int Height) { - _width = Width; - _height = Height; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSurface.h b/engines/wintermute/BSurface.h deleted file mode 100644 index bd22d48d01..0000000000 --- a/engines/wintermute/BSurface.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACE_H -#define WINTERMUTE_BSURFACE_H - -#include "BBase.h" - -namespace WinterMute { - -class CBSurface: public CBBase { -public: - virtual HRESULT Invalidate(); - virtual HRESULT PrepareToDraw(); - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - - uint32 _lastUsedTime; - bool _valid; - int _lifeTime; - bool _keepLoaded; - - bool _pixelOpReady; - CBSurface(CBGame *inGame); - virtual ~CBSurface(); - - virtual HRESULT DisplayHalfTrans(int X, int Y, RECT rect); - virtual bool IsTransparentAt(int X, int Y); - virtual HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); - virtual HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT Restore(); - virtual HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); - virtual HRESULT Create(int Width, int Height); - virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); - virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); - virtual bool ComparePixel(int X, int Y, byte R, byte G, byte B, int A = -1); - virtual HRESULT StartPixelOp(); - virtual HRESULT EndPixelOp(); - virtual bool IsTransparentAtLite(int X, int Y); - void SetFilename(const char *Filename); - void SetSize(int Width, int Height); - - int _referenceCount; - char *_filename; - - int GetWidth() { - return _width; - } - int GetHeight() { - return _height; - } - //void SetWidth(int Width){ _width = Width; } - //void SetHeight(int Height){ _height = Height; } -protected: - int _height; - int _width; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BSurfaceSDL.cpp b/engines/wintermute/BSurfaceSDL.cpp deleted file mode 100644 index 732bb45429..0000000000 --- a/engines/wintermute/BSurfaceSDL.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BFile.h" -#include "BGame.h" -#include "BSurfaceSDL.h" -#include "BRenderSDL.h" -//#include "SdlUtil.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/bmp.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/graphics/tga.h" -#include "common/stream.h" -#include "BFileManager.h" -#include "PlatformSDL.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { - _surface = new Graphics::Surface(); - _alphaMask = NULL; - - _lockPixels = NULL; - _lockPitch = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBSurfaceSDL::~CBSurfaceSDL() { - //TODO - delete _surface; -#if 0 - if (_texture) SDL_DestroyTexture(_texture); - delete[] _alphaMask; - _alphaMask = NULL; - - Game->AddMem(-_width * _height * 4); -#endif -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { -/* CBRenderSDL *renderer = static_cast(Game->_renderer); */ - Common::String strFileName(Filename); - - Graphics::ImageDecoder *imgDecoder; - - if (strFileName.hasSuffix(".png")) { - imgDecoder = new Graphics::PNGDecoder(); - } else if (strFileName.hasSuffix(".bmp")) { - warning("Loaded BMP WITH FILENAME!!!! %s", Filename); - imgDecoder = new Graphics::BitmapDecoder(); - } else if (strFileName.hasSuffix(".tga")) { - imgDecoder = new WinterMute::TGA(); - } else { - error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); - } - - CBFile *file = Game->_fileManager->OpenFile(Filename); - if (!file) return E_FAIL; - - imgDecoder->loadStream(*file->getMemStream()); - const Graphics::Surface *surface = imgDecoder->getSurface(); - Game->_fileManager->CloseFile(file); - - if (default_ck) { - ck_red = 255; - ck_green = 0; - ck_blue = 255; - } - - _width = surface->w; - _height = surface->h; - - bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); - if (isSaveGameGrayscale) { - warning("grayscaleConversion not yet implemented"); - /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ - } - - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - /* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { - FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - } else { - FreeImage_Unload(img); - return -1; - } - } - - FreeImage_FlipVertical(img);*/ - - //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: -/* uint32 rmask = surface->format.rMax() << surface->format.rShift; - uint32 gmask = surface->format.gMax() << surface->format.gShift; - uint32 bmask = surface->format.bMax() << surface->format.bShift; - uint32 amask = surface->format.aMax();*/ - -// SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); - - // no alpha, set color key - /* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { - _surface = surface->convertTo(g_system->getScreenFormat()); - } else { - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - } - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Surface-textures not fully ported yet"); - hasWarned = true; - } -#if 0 - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!_texture) { - SDL_FreeSurface(surf); - delete imgDecoder; - return E_FAIL; - } - - GenAlphaMask(surf); - - SDL_FreeSurface(surf); - delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. - - _cKDefault = default_ck; - _cKRed = ck_red; - _cKGreen = ck_green; - _cKBlue = ck_blue; -#endif - - if (!_filename || scumm_stricmp(_filename, Filename) != 0) { - SetFilename(Filename); - } - - if (_lifeTime == 0 || LifeTime == -1 || LifeTime > _lifeTime) - _lifeTime = LifeTime; - - _keepLoaded = KeepLoaded; - if (_keepLoaded) _lifeTime = -1; - - _valid = true; -#if 0 - Game->AddMem(_width * _height * 4); -#endif - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { - warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); - return; - - delete[] _alphaMask; - _alphaMask = NULL; - if (!surface) return; -#if 0 - SDL_LockSurface(surface); -#endif - bool hasColorKey; - uint32 colorKey; - uint8 ckRed, ckGreen, ckBlue; - /* if (SDL_GetColorKey(surface, &colorKey) == 0) { - hasColorKey = true; - SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); - } else hasColorKey = false; - */ //TODO - _alphaMask = new byte[surface->w * surface->h]; - - bool hasTransparency = false; - for (int y = 0; y < surface->h; y++) { - for (int x = 0; x < surface->w; x++) { - uint32 pixel = GetPixel(surface, x, y); - - uint8 r, g, b, a; - surface->format.colorToARGB(pixel, a, r, g, b); - //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) - a = 0; - - _alphaMask[y * surface->w + x] = a; - if (a < 255) hasTransparency = true; - } - } -#if 0 - SDL_UnlockSurface(surface); -#endif - if (!hasTransparency) { - delete[] _alphaMask; - _alphaMask = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { - warning("CBSurfaceSDL::GetPixel - Not ported yet"); - int bpp = surface->format.bytesPerPixel; - /* Here p is the address to the pixel we want to retrieve */ - uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; - - switch (bpp) { - case 1: - return *p; - break; - - case 2: - return *(uint16 *)p; - break; - - case 3: -#ifdef SCUMM_BIG_ENDIAN - // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; -#else - //else - return p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - return *(uint32 *)p; - break; - - default: - return 0; /* shouldn't happen, but avoids warnings */ - } - return 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Create(int Width, int Height) { - warning("SurfaceSDL::Create not ported yet"); //TODO -#if 0 - CBRenderSDL *renderer = static_cast(Game->_renderer); - _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); -#endif - _width = Width; - _height = Height; -#if 0 - Game->AddMem(_width * _height * 4); -#endif - _valid = true; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { - warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO -#if 0 - CBRenderSDL *renderer = static_cast(Game->_renderer); - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); -#endif - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - _width = surface->w; - _height = surface->h; -#if 0 - Game->AddMem(_width * _height * 4); -#endif - _valid = true; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::IsTransparentAt not ported yet"); - hasWarned = true; - } -#if 0 - int access; - int width, height; - //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - - StartPixelOp(); - bool ret = IsTransparentAtLite(X, Y); - EndPixelOp(); - - return ret; -#endif - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { - //if (!_lockPixels) return false; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); - hasWarned = true; - } -#if 0 - uint32 format; - int access; - int width, height; - - //SDL_QueryTexture(_texture, &format, &access, &width, &height); - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - if (!_alphaMask) return false; - else return _alphaMask[Y * width + X] <= 128; -#endif - return false; - /* - Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); - Uint32 pixel = dst[X]; - - SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); - SDL_FreeFormat(pixelFormat); - - return a <= 128; - */ -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::StartPixelOp() { - //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::EndPixelOp() { - //SDL_UnlockTexture(_texture); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, 100, 100, 0xFFFFFFFF, true, BlendMode, MirrorX, MirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY, offsetX, offsetY); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, !Transparent, BlendMode, MirrorX, MirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &Rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - CBRenderSDL *renderer = static_cast(Game->_renderer); - - if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. - hasWarned = true; - } -#if 0 - byte r = D3DCOLGetR(Alpha); - byte g = D3DCOLGetG(Alpha); - byte b = D3DCOLGetB(Alpha); - byte a = D3DCOLGetA(Alpha); - - SDL_SetTextureColorMod(_texture, r, g, b); - SDL_SetTextureAlphaMod(_texture, a); - - if (AlphaDisable) - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - else - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); -#endif - // TODO: This _might_ miss the intended behaviour by 1 in each direction - // But I think it fits the model used in Wintermute. - Common::Rect srcRect; - srcRect.left = Rect->left; - srcRect.top = Rect->top; - srcRect.setWidth(Rect->right - Rect->left); - srcRect.setHeight(Rect->bottom - Rect->top); - - Common::Rect position; - position.left = X; - position.top = Y; - // TODO: Scaling... - - position.setWidth((float)srcRect.width() * ZoomX / 100.f); - position.setHeight((float)srcRect.height() * ZoomX / 100.f); - - renderer->ModTargetRect(&position); - - position.left += offsetX; - position.top += offsetY; - - renderer->drawFromSurface(_surface, &srcRect, &position); -#if 0 - SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); -#endif - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSurfaceSDL.h b/engines/wintermute/BSurfaceSDL.h deleted file mode 100644 index ca9727331f..0000000000 --- a/engines/wintermute/BSurfaceSDL.h +++ /dev/null @@ -1,81 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESDL_H -#define WINTERMUTE_BSURFACESDL_H - -#include "graphics/surface.h" -#include "BSurface.h" -#include "graphics/surface.h" - -namespace WinterMute { - -class CBSurfaceSDL : public CBSurface { -public: - CBSurfaceSDL(CBGame *inGame); - ~CBSurfaceSDL(); - - HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); - HRESULT Create(int Width, int Height); - - HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - - bool IsTransparentAt(int X, int Y); - bool IsTransparentAtLite(int X, int Y); - - HRESULT StartPixelOp(); - HRESULT EndPixelOp(); - - - HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); - HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - - /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); - static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); - static long DLL_CALLCONV TellProc(fi_handle handle);*/ - -private: -// SDL_Texture *_texture; - Graphics::Surface *_surface; - - HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); - void GenAlphaMask(Graphics::Surface *surface); - uint32 GetPixel(Graphics::Surface *surface, int x, int y); - - void *_lockPixels; - int _lockPitch; - byte *_alphaMask; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/BSurfaceStorage.cpp b/engines/wintermute/BSurfaceStorage.cpp deleted file mode 100644 index 567df7d1f5..0000000000 --- a/engines/wintermute/BSurfaceStorage.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BSurfaceStorage.h" -#include "BSurfaceSDL.h" -#include "BGame.h" -#include "BFileManager.h" -#include "PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { - Cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::Cleanup(bool Warn) { - for (int i = 0; i < _surfaces.GetSize(); i++) { - if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); - delete _surfaces[i]; - } - _surfaces.RemoveAll(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::InitLoop() { - if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { - _lastCleanupTime = Game->_liveTimer; - SortSurfaces(); - for (int i = 0; i < _surfaces.GetSize(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; - - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { - //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->Invalidate(); - } - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.GetSize(); i++) { - if (_surfaces[i] == surface) { - _surfaces[i]->_referenceCount--; - if (_surfaces[i]->_referenceCount <= 0) { - delete _surfaces[i]; - _surfaces.RemoveAt(i); - } - break; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { - for (int i = 0; i < _surfaces.GetSize(); i++) { - if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - CBFile *File = Game->_fileManager->OpenFile(Filename); - if (!File) { - if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); - if (Game->_dEBUG_DebugMode) - return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - else - return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - } else Game->_fileManager->CloseFile(File); - - - CBSurface *surface; - surface = new CBSurfaceSDL(Game); - - - if (!surface) return NULL; - - if (FAILED(surface->Create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { - delete surface; - return NULL; - } else { - surface->_referenceCount = 1; - _surfaces.Add(surface); - return surface; - } -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::RestoreAll() { - HRESULT ret; - for (int i = 0; i < _surfaces.GetSize(); i++) { - ret = _surfaces[i]->Restore(); - if (ret != S_OK) { - Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return S_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) -{ - - if(!PersistMgr->_saving) Cleanup(false); - - PersistMgr->Transfer(TMEMBER(Game)); - - //_surfaces.Persist(PersistMgr); - - return S_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::SortSurfaces() { - qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::SurfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); - - // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; - - - // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; - - // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BSurfaceStorage.h b/engines/wintermute/BSurfaceStorage.h deleted file mode 100644 index 6ebf2b3992..0000000000 --- a/engines/wintermute/BSurfaceStorage.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H - - -#include "coll_templ.h" -#include "BBase.h" - -namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { -public: - uint32 _lastCleanupTime; - HRESULT InitLoop(); - HRESULT SortSurfaces(); - static int SurfaceSortCB(const void *arg1, const void *arg2); - HRESULT Cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - - HRESULT RestoreAll(); - CBSurface *AddSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); - HRESULT RemoveSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); - - CBArray _surfaces; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BTransitionMgr.cpp b/engines/wintermute/BTransitionMgr.cpp deleted file mode 100644 index 177c10a980..0000000000 --- a/engines/wintermute/BTransitionMgr.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "dcgf.h" -#include "BTransitionMgr.h" -#include "BGame.h" -#include "PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::IsReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { - if (_state != TRANS_MGR_READY) return S_OK; - - if (Type == TRANSITION_NONE || Type >= NUM_TRANSITION_TYPES) { - _state = TRANS_MGR_READY; - return S_OK; - } - - if (NonInteractive) { - _preserveInteractive = true; - _origInteractive = Game->_interactive; - Game->_interactive = false; - } else _preserveInteractive; - - _type = Type; - _state = TRANS_MGR_RUNNING; - _started = false; - - return S_OK; -} - -#define FADE_DURATION 200 - -////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::Update() { - if (IsReady()) return S_OK; - - if (!_started) { - _started = true; - _lastTime = CBPlatform::GetTime(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; - Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((uint16)Alpha); - - if (time > FADE_DURATION) _state = TRANS_MGR_READY; - } - break; - - case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = (float)time / (float)FADE_DURATION * 255; - Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((uint16)Alpha); - - if (time > FADE_DURATION) _state = TRANS_MGR_READY; - } - break; - default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (IsReady()) { - if (_preserveInteractive) Game->_interactive = _origInteractive; - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BTransitionMgr.h b/engines/wintermute/BTransitionMgr.h deleted file mode 100644 index 2db5d4482e..0000000000 --- a/engines/wintermute/BTransitionMgr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H - -#include "BBase.h" - -namespace WinterMute { - -class CBTransitionMgr : public CBBase { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - HRESULT Update(); - HRESULT Start(TTransitionType Type, bool NonInteractive = false); - bool IsReady(); - TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/BViewport.cpp b/engines/wintermute/BViewport.cpp deleted file mode 100644 index 397197a935..0000000000 --- a/engines/wintermute/BViewport.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "BGame.h" -#include "PlatformSDL.h" -#include "BViewport.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBViewport, false) - -////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_mainObject)); - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_rect)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoCheck) { - if (!NoCheck) { - left = MAX(left, 0); - top = MAX(top, 0); - right = MIN(right, Game->_renderer->_width); - bottom = MIN(bottom, Game->_renderer->_height); - } - - CBPlatform::SetRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -RECT *CBViewport::GetRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::GetWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::GetHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/BViewport.h b/engines/wintermute/BViewport.h deleted file mode 100644 index 98cc23ed25..0000000000 --- a/engines/wintermute/BViewport.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H - - -#include "BBase.h" - -namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { -public: - int GetHeight(); - int GetWidth(); - RECT *GetRect(); - HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) - int _offsetY; - int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); -private: - RECT _rect; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp new file mode 100644 index 0000000000..5bb538b72f --- /dev/null +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::SetRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + ClipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise): CBBase(inGame) { + _owner = Owner; + _frame = Frame; + CBPlatform::SetRect(&_rect, X, Y, X + Width, Y + Height); + _zoomX = ZoomX; + _zoomY = ZoomY; + _precise = Precise; + _region = NULL; + _offsetX = _offsetY = 0; + ClipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY): CBBase(inGame) { + _owner = Owner; + _region = Region; + CBPlatform::CopyRect(&_rect, &Region->_rect); + CBPlatform::OffsetRect(&_rect, -OffsetX, -OffsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + ClipRect(); + _offsetX = OffsetX; + _offsetY = OffsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::ClipRect() { + RECT rc; + bool CustomViewport; + Game->GetCurrentViewportRect(&rc, &CustomViewport); + CBRenderer *Rend = Game->_renderer; + + if (!CustomViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + + CBPlatform::IntersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h new file mode 100644 index 0000000000..fe99f76ea1 --- /dev/null +++ b/engines/wintermute/Base/BActiveRect.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void ClipRect(); + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + RECT _rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX = 100, float ZoomY = 100, bool Precise = true); + CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp new file mode 100644 index 0000000000..8f9d306824 --- /dev/null +++ b/engines/wintermute/Base/BBase.cpp @@ -0,0 +1,177 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *GameOwner) { + Game = GameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + Game = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { + _editorPropsIter = _editorProps.find(PropName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean + else return InitVal; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::SetEditorProp(const char *PropName, const char *PropValue) { + if (PropName == NULL) return E_FAIL; + + if (PropValue == NULL) { + _editorProps.erase(PropName); + } else { + _editorProps[PropName] = PropValue; + } + return S_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!Game->_editorMode) return S_OK; + + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + char *PropName = NULL; + char *PropValue = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] PropName; + PropName = new char[strlen((char *)params) + 1]; + if (PropName) strcpy(PropName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] PropValue; + PropValue = new char[strlen((char *)params) + 1]; + if (PropValue) strcpy(PropValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return E_FAIL; + } + + + SetEditorProp(PropName, PropValue); + + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); + Buffer->PutTextIndent(Indent, "{\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + Buffer->PutTextIndent(Indent, "}\n\n"); + + _editorPropsIter++; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h new file mode 100644 index 0000000000..b815281f34 --- /dev/null +++ b/engines/wintermute/Base/BBase.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +//#include +//#include + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool _persistable; + HRESULT SetEditorProp(const char *PropName, const char *PropValue); + const char *GetEditorProp(const char *PropName, const char *InitVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + HRESULT ParseEditorProperty(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + CBBase(); + CBGame *Game; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp new file mode 100644 index 0000000000..d55cb189b7 --- /dev/null +++ b/engines/wintermute/Base/BDebugger.cpp @@ -0,0 +1,203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BDebugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + _enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::Initialize() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::Shutdown() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameInit() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameShutdown() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnGameTick() { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnLog(unsigned int ErrorCode, const char *Text) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptInit(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptShutdown(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptChangeLine(CScScript *Script, int Line) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptChangeScope(CScScript *Script, CScValue *Scope) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptShutdownScope(CScScript *Script, CScValue *Scope) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *Value) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::AttachClient(IWmeDebugClient *Client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::DetachClient(IWmeDebugClient *Client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::QueryData(IWmeDebugClient *Client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::GetPropInt(const char *PropName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::GetPropFloat(const char *PropName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::GetPropString(const char *PropName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::GetPropBool(const char *PropName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, int PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, double PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, const char *PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::SetProp(const char *PropName, bool PropValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::AddBreakpoint(const char *ScriptFilename, int Line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::RemoveBreakpoint(const char *ScriptFilename, int Line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::ContinueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h new file mode 100644 index 0000000000..52bfc51c55 --- /dev/null +++ b/engines/wintermute/Base/BDebugger.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool _enabled; + HRESULT Initialize(); + HRESULT Shutdown(); + + // internal interface + HRESULT OnGameInit(); + HRESULT OnGameShutdown(); + HRESULT OnGameTick(); + HRESULT OnLog(unsigned int ErrorCode, const char *Text); + HRESULT OnScriptInit(CScScript *Script); + HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); + HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); + + HRESULT OnScriptShutdown(CScScript *Script); + HRESULT OnScriptChangeLine(CScScript *Script, int Line); + HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); + HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); + HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName); + HRESULT OnVariableChangeValue(CScValue *Var, CScValue *Value); + + HRESULT OnScriptHitBreakpoint(CScScript *Script); + + // IWmeDebugServer interface + virtual bool AttachClient(IWmeDebugClient *Client); + virtual bool DetachClient(IWmeDebugClient *Client); + virtual bool QueryData(IWmeDebugClient *Client); + + virtual int GetPropInt(const char *PropName); + virtual double GetPropFloat(const char *PropName); + virtual const char *GetPropString(const char *PropName); + virtual bool GetPropBool(const char *PropName); + + virtual bool SetProp(const char *PropName, int PropValue); + virtual bool SetProp(const char *PropName, double PropValue); + virtual bool SetProp(const char *PropName, const char *PropValue); + virtual bool SetProp(const char *PropName, bool PropValue); + + virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize); + + virtual bool AddBreakpoint(const char *ScriptFilename, int Line); + virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line); + + virtual bool ContinueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BDiskFile.cpp b/engines/wintermute/Base/BDiskFile.cpp new file mode 100644 index 0000000000..0d2b41f870 --- /dev/null +++ b/engines/wintermute/Base/BDiskFile.cpp @@ -0,0 +1,230 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Base/BPkgFile.h" +#include "engines/wintermute/Base/BDiskFile.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "common/stream.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { + _file = NULL; + _data = NULL; + _compressed = false; + _prefixSize = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::~CBDiskFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Open(const Common::String &Filename) { + Close(); + + char FullPath[MAX_PATH]; + + for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { + sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); + CorrectSlashes(FullPath); + //_file = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(FullPath)) { + _file = tempFile; + } else { + delete tempFile; + } + /* if (_file != NULL) { + error("Tried to open %s, but failed", Filename.c_str()); + break; + }*/ + } + + // if we didn't find it in search paths, try to open directly + if (!_file) { + strcpy(FullPath, Filename.c_str()); + CorrectSlashes(FullPath); + //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); + //_file = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(FullPath)) { + _file = tempFile; + } else { + delete tempFile; + } + } + + if (_file) { + uint32 magic1, magic2; + magic1 = _file->readUint32LE(); + magic2 = _file->readUint32LE(); + + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; + + if (_compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = _file->readUint32LE(); + CompSize = _file->readUint32LE(); + UncompSize = _file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); + Close(); + return E_FAIL; + } + + _data = new byte[UncompSize]; + if (!_data) { + Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + _file->seek(DataOffset + _prefixSize, SEEK_SET); + _file->read(CompBuffer, CompSize); + + if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { + Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + + delete [] CompBuffer; + _size = UncompSize; + _pos = 0; + delete _file; + _file = NULL; + } else { + _pos = 0; + _file->seek(0, SEEK_END); + _size = _file->pos() - _prefixSize; + _file->seek(_prefixSize, SEEK_SET); + } + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Close() { + if (_file) { + delete _file; + } + _file = NULL; + _pos = 0; + _size = 0; + + delete[] _data; + _data = NULL; + + _compressed = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { + if (_compressed) { + memcpy(Buffer, _data + _pos, Size); + _pos += Size; + return S_OK; + } else { + + if (_file) { + size_t count = _file->read(Buffer, Size); + _pos += count; + return S_OK; + } else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { + // TODO: Should this really need to use uint32? + if (_compressed) { + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + return S_OK; + } else { + if (!_file) return E_FAIL; + int ret = 1; + + switch (Origin) { + case SEEK_TO_BEGIN: + ret = _file->seek(_prefixSize + Pos, SEEK_SET); + break; + case SEEK_TO_END: + ret = _file->seek(Pos, SEEK_END); + break; + case SEEK_TO_CURRENT: + ret = _file->seek(Pos, SEEK_CUR); + break; + } + if (ret == 0) { + _pos = _file->pos() - _prefixSize; + return S_OK; + } else return E_FAIL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBDiskFile::CorrectSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDiskFile.h b/engines/wintermute/Base/BDiskFile.h new file mode 100644 index 0000000000..967e902dff --- /dev/null +++ b/engines/wintermute/Base/BDiskFile.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + + +#include "engines/wintermute/Base/BFile.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBDiskFile : public CBFile { +public: + CBDiskFile(CBGame *inGame); + virtual ~CBDiskFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + void CorrectSlashes(char *fileName); + Common::SeekableReadStream *_file; + byte *_data; + bool _compressed; + uint32 _prefixSize; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp new file mode 100644 index 0000000000..0e1c56d264 --- /dev/null +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase(inGame) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = InitSize; + _growBy = GrowBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::Cleanup() { + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::GetSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::Init(uint32 InitSize) { + Cleanup(); + + if (InitSize == 0) InitSize = _initSize; + + _buffer = (byte *)malloc(InitSize); + if (!_buffer) { + Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); + return E_FAIL; + } + + _realSize = InitSize; + _initialized = true; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { + if (!_initialized) Init(); + + while (_offset + Size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return E_FAIL; + } + } + + memcpy(_buffer + _offset, Buffer, Size); + _offset += Size; + _size += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { + if (!_initialized) Init(); + + if (_offset + Size > _size) { + Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return E_FAIL; + } + + memcpy(Buffer, _buffer + _offset, Size); + _offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutDWORD(uint32 Val) { + PutBytes((byte *)&Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::GetDWORD() { + uint32 ret; + GetBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutString(const char *Val) { + if (!Val) PutString("(null)"); + else { + PutDWORD(strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::GetString() { + uint32 len = GetDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutText(LPCSTR fmt, ...) { + va_list va; + + va_start(va, fmt); + PutTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { + va_list va; + + PutText("%*s", Indent, ""); + + va_start(va, fmt); + PutTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + PutBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h new file mode 100644 index 0000000000..c90c464aad --- /dev/null +++ b/engines/wintermute/Base/BDynBuffer.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool _initialized; + void PutText(LPCSTR fmt, ...); + void PutTextIndent(int Indent, LPCSTR fmt, ...); + uint32 GetDWORD(); + void PutDWORD(uint32 Val); + char *GetString(); + void PutString(const char *Val); + HRESULT GetBytes(byte *Buffer, uint32 Size); + HRESULT PutBytes(byte *Buffer, uint32 Size); + uint32 GetSize(); + HRESULT Init(uint32 InitSize = 0); + void Cleanup(); + uint32 _size; + byte *_buffer; + CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void PutTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BEvent.cpp b/engines/wintermute/Base/BEvent.cpp new file mode 100644 index 0000000000..c0cc5a2e4a --- /dev/null +++ b/engines/wintermute/Base/BEvent.cpp @@ -0,0 +1,197 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BEvent.h" +#include "engines/wintermute/Base/BParser.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBEvent, false) + +////////////////////////////////////////////////////////////////////////// +CBEvent::CBEvent(CBGame *inGame): CBBase(inGame) { + _type = EVENT_NONE; + _script = NULL; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBEvent::CBEvent(CBGame *inGame, TEventType Type, char *Script): CBBase(inGame) { + _type = Type; + _script = new char [strlen(Script) + 1]; + if (_script) strcpy(_script, Script); + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBEvent::~CBEvent() { + delete[] _script; + _script = NULL; + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBEvent::GetEventName(TEventType Type) { + switch (Type) { + case EVENT_INIT: + return "INIT"; + case EVENT_SHUTDOWN: + return "SHUTDOWN"; + case EVENT_LEFT_CLICK: + return "LEFT_CLICK"; + case EVENT_RIGHT_CLICK: + return "RIGHT_CLICK"; + case EVENT_MIDDLE_CLICK: + return "MIDDLE_CLICK"; + case EVENT_LEFT_DBLCLICK: + return "LEFT_DBLCLICK"; + case EVENT_PRESS: + return "PRESS"; + case EVENT_IDLE: + return "IDLE"; + case EVENT_MOUSE_OVER: + return "MOUSE_OVER"; + case EVENT_LEFT_RELEASE: + return "LEFT_RELEASE"; + case EVENT_RIGHT_RELEASE: + return "RIGHT_RELEASE"; + case EVENT_MIDDLE_RELEASE: + return "MIDDLE_RELEASE"; + + default: + return "NONE"; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBEvent::SetScript(const char *Script) { + if (_script) delete [] _script; + + _script = new char [strlen(Script) + 1]; + if (_script) strcpy(_script, Script); +} + + +////////////////////////////////////////////////////////////////////////// +void CBEvent::SetName(const char *Name) { + if (_name) delete [] _name; + + _name = new char [strlen(Name) + 1]; + if (_name) strcpy(_name, Name); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EVENT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(EVENT) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EVENT) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EVENT) { + Game->LOG(0, "'EVENT' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_SCRIPT: + SetScript((char *)params); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in EVENT definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBEvent::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_script)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BEvent.h b/engines/wintermute/Base/BEvent.h new file mode 100644 index 0000000000..a58f7d08d1 --- /dev/null +++ b/engines/wintermute/Base/BEvent.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BEVENT_H +#define WINTERMUTE_BEVENT_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CBEvent : public CBBase { +public: + DECLARE_PERSISTENT(CBEvent, CBBase) + void SetScript(const char *Script); + void SetName(const char *Name); + static const char *GetEventName(TEventType Type); + char *_script; + char *_name; + TEventType _type; + CBEvent(CBGame *inGame); + CBEvent(CBGame *inGame, TEventType Type, char *Script); + virtual ~CBEvent(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp new file mode 100644 index 0000000000..0769e8fd83 --- /dev/null +++ b/engines/wintermute/Base/BFader.cpp @@ -0,0 +1,176 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFader.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Update() { + if (!_active) return S_OK; + + int AlphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) time = CBPlatform::GetTime() - _startTime; + else time = Game->_timer - _startTime; + + if (time >= _duration) _currentAlpha = _targetAlpha; + else { + _currentAlpha = _sourceAlpha + (float)time / (float)_duration * AlphaDelta; + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Display() { + if (!_active) return S_OK; + + if (_currentAlpha > 0x00) return Game->_renderer->FadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Deactivate() { + _active = false; + _ready = true; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { + _ready = false; + _active = true; + + _red = D3DCOLGetR(SourceColor); + _green = D3DCOLGetG(SourceColor); + _blue = D3DCOLGetB(SourceColor); + + _sourceAlpha = D3DCOLGetA(SourceColor); + _targetAlpha = 0; + + _duration = Duration; + _system = System; + + if (_system) _startTime = CBPlatform::GetTime(); + else _startTime = Game->_timer; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { + _ready = false; + _active = true; + + _red = D3DCOLGetR(TargetColor); + _green = D3DCOLGetG(TargetColor); + _blue = D3DCOLGetB(TargetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = D3DCOLGetA(TargetColor); + + _duration = Duration; + _system = System; + + if (_system) _startTime = CBPlatform::GetTime(); + else _startTime = Game->_timer; + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::GetCurrentColor() { + return DRGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFader::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_blue)); + PersistMgr->Transfer(TMEMBER(_currentAlpha)); + PersistMgr->Transfer(TMEMBER(_duration)); + PersistMgr->Transfer(TMEMBER(_green)); + PersistMgr->Transfer(TMEMBER(_red)); + PersistMgr->Transfer(TMEMBER(_sourceAlpha)); + PersistMgr->Transfer(TMEMBER(_startTime)); + PersistMgr->Transfer(TMEMBER(_targetAlpha)); + PersistMgr->Transfer(TMEMBER(_system)); + + if (_system && !PersistMgr->_saving) _startTime = 0; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h new file mode 100644 index 0000000000..141f44f485 --- /dev/null +++ b/engines/wintermute/Base/BFader.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "engines/wintermute/Base/BObject.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool _system; + uint32 GetCurrentColor(); + HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); + HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); + HRESULT Deactivate(); + HRESULT Display(); + HRESULT Update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFile.cpp b/engines/wintermute/Base/BFile.cpp new file mode 100644 index 0000000000..ba75023c7f --- /dev/null +++ b/engines/wintermute/Base/BFile.cpp @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFile.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::IsEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = GetPos(); + Seek(0); + byte *data = new byte[GetSize()]; + Read(data, GetSize()); + Seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFile.h b/engines/wintermute/Base/BFile.h new file mode 100644 index 0000000000..ba20975b46 --- /dev/null +++ b/engines/wintermute/Base/BFile.h @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "common/str.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +public: + uint32 _pos; + uint32 _size; + virtual uint32 GetSize() { + return _size; + }; + virtual uint32 GetPos() { + return _pos; + }; + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; + virtual HRESULT Read(void *Buffer, uint32 Size) = 0; + virtual HRESULT Close() = 0; + virtual HRESULT Open(const Common::String &Filename) = 0; + virtual bool IsEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFileEntry.cpp b/engines/wintermute/Base/BFileEntry.cpp new file mode 100644 index 0000000000..aca145dcf1 --- /dev/null +++ b/engines/wintermute/Base/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFileEntry.h b/engines/wintermute/Base/BFileEntry.h new file mode 100644 index 0000000000..660c9cfd1f --- /dev/null +++ b/engines/wintermute/Base/BFileEntry.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp new file mode 100644 index 0000000000..99f64a4d3b --- /dev/null +++ b/engines/wintermute/Base/BFileManager.cpp @@ -0,0 +1,879 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + +#define FORBIDDEN_SYMBOL_ALLOW_ALL +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/Base/BDiskFile.h" +#include "engines/wintermute/Base/BResourceFile.h" +#include "engines/wintermute/Base/BSaveThumbFile.h" +#include "engines/wintermute/Base/BFileEntry.h" +#include "engines/wintermute/Base/BPkgFile.h" +#include "engines/wintermute/Base/BPackage.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + _basePath = NULL; + + InitPaths(); + RegisterPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::Cleanup() { + int i; + + // delete registered paths + for (i = 0; i < _singlePaths.GetSize(); i++) + delete [] _singlePaths[i]; + _singlePaths.RemoveAll(); + + for (i = 0; i < _packagePaths.GetSize(); i++) + delete [] _packagePaths[i]; + _packagePaths.RemoveAll(); + + + // delete file entries + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; + } + _files.clear(); + + // close open files + for (i = 0; i < _openFiles.GetSize(); i++) { + _openFiles[i]->Close(); + delete _openFiles[i]; + } + _openFiles.RemoveAll(); + + + // delete packages + for (i = 0; i < _packages.GetSize(); i++) + delete _packages[i]; + _packages.RemoveAll(); + + delete[] _basePath; + _basePath = NULL; + + return S_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool MustExist) { + + byte *buffer = NULL; + + CBFile *File = OpenFile(Filename); + if (!File) { + if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename); + return NULL; + } + + /* + if(File->GetSize()>MAX_FILE_SIZE){ + Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[File->GetSize() + 1]; + if (buffer == NULL) { + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->GetSize() + 1); + CloseFile(File); + return NULL; + } + + if (FAILED(File->Read(buffer, File->GetSize()))) { + Game->LOG(0, "Error reading file '%s'", Filename); + CloseFile(File); + delete [] buffer; + return NULL; + }; + + buffer[File->GetSize()] = '\0'; + if (Size != NULL) *Size = File->GetSize(); + CloseFile(File); + + return buffer; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { + // TODO + warning("Implement SaveFile"); +#if 0 + RestoreCurrentDir(); + + CBUtils::CreatePath(Filename, false); + + FILE *f = fopen(Filename, "wb"); + if (!f) { + Game->LOG(0, "Error opening file '%s' for writing.", Filename); + return E_FAIL; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + Game->LOG(0, "Error allocating compression buffer while saving '%s'", Filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + Game->LOG(0, "Error compressing data while saving '%s'", Filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { + // unmount all non-local packages + for (int i = 0; i < _packages.GetSize(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->Close(); + } + + + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { + if (Path == NULL || strlen(Path) < 1) return E_FAIL; + + bool slashed = (Path[strlen(Path) - 1] == '\\' || Path[strlen(Path) - 1] == '/'); + + char *buffer = new char [strlen(Path) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return E_FAIL; + + strcpy(buffer, Path); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (Type) { + case PATH_SINGLE: + _singlePaths.Add(buffer); + break; + case PATH_PACKAGE: + _packagePaths.Add(buffer); + break; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::ReloadPaths() { + // delete registered paths + for (int i = 0; i < _singlePaths.GetSize(); i++) + delete [] _singlePaths[i]; + _singlePaths.RemoveAll(); + + for (int i = 0; i < _packagePaths.GetSize(); i++) + delete [] _packagePaths[i]; + _packagePaths.RemoveAll(); + + return InitPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::InitPaths() { + RestoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = Game->_registry->ReadString("Resource", "CustomPaths", ""); + numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + AddPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + AddPath(PATH_SINGLE, ".\\"); + + + // package files paths + AddPath(PATH_PACKAGE, "./"); + + /*#ifdef __APPLE__ + // search .app path and Resources dir in the bundle + CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); + + #ifdef __IPHONE__ + AddPath(PATH_PACKAGE, pathPtr); + AddPath(PATH_SINGLE, pathPtr); + #else + char bundlePath[MAX_PATH]; + + sprintf(bundlePath, "%s/../", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); + + sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); + AddPath(PATH_PACKAGE, bundlePath); + AddPath(PATH_SINGLE, bundlePath); + + + CFRelease(appUrlRef); + CFRelease(macPath); + #endif + #endif*/ + + + pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); + numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + AddPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + AddPath(PATH_PACKAGE, "data"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackages() { + RestoreCurrentDir(); + + Game->LOG(0, "Scanning packages..."); + warning("Scanning packages"); + +// TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. + RegisterPackage("data.dcp"); + RegisterPackage("english.dcp"); +#if 0 + AnsiString extension = AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < _packagePaths.GetSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); + + //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } + + warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); + Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); +#endif + warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSignature) { +// FILE *f = fopen(Filename, "rb"); + Common::File *package = new Common::File(); + package->open(Filename); + if (!package->isOpen()) { + Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename.c_str()); + return S_OK; + } + + uint32 AbsoluteOffset = 0; + bool BoundToExe = false; + + if (SearchSignature) { + uint32 Offset; + if (!FindPackageSignature(package, &Offset)) { + delete package; + return S_OK; + } else { + package->seek(Offset, SEEK_SET); + AbsoluteOffset = Offset; + BoundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename.c_str()); + delete package; + return S_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + Game->LOG(0, " Warning: package file '%s' is outdated.", Filename.c_str()); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 DirOffset; + DirOffset = package->readUint32LE(); + DirOffset += AbsoluteOffset; + package->seek(DirOffset, SEEK_SET); + } + + for (uint32 i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(Game); + if (!pkg) return E_FAIL; + + pkg->_boundToExe = BoundToExe; + + // read package info + byte NameLength = package->readByte(); + pkg->_name = new char[NameLength]; + package->read(pkg->_name, NameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.Add(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (uint32 j = 0; j < NumFiles; j++) { + char *Name; + uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; + + NameLength = package->readByte(); + Name = new char[NameLength]; + package->read(Name, NameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < NameLength; k++) { + ((byte *)Name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + Name[NameLength - 1] = '\0'; + + + CBPlatform::strupr(Name); + + Offset = package->readUint32LE(); + Offset += AbsoluteOffset; + Length = package->readUint32LE(); + CompLength = package->readUint32LE(); + Flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + TimeDate1 = package->readUint32LE(); + TimeDate2 = package->readUint32LE(); + } + _filesIter = _files.find(Name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(Game); + file->_package = pkg; + file->_offset = Offset; + file->_length = Length; + file->_compressedLength = CompLength; + file->_flags = Flags; + + _files[Name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = Offset; + _filesIter->_value->_length = Length; + _filesIter->_value->_compressedLength = CompLength; + _filesIter->_value->_flags = Flags; + } + } + delete [] Name; + } + } + + + delete package; + return S_OK; +} +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool SearchSignature) { +// TODO + error("Implement RegisterPackage, this is the old one"); +#if 0 + char Filename[MAX_PATH]; + sprintf(Filename, "%s%s", Path, Name); + + FILE *f = fopen(Filename, "rb"); + if (!f) { + Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename); + return S_OK; + } + + uint32 AbsoluteOffset = 0; + bool BoundToExe = false; + + if (SearchSignature) { + uint32 Offset; + if (!FindPackageSignature(f, &Offset)) { + fclose(f); + return S_OK; + } else { + fseek(f, Offset, SEEK_SET); + AbsoluteOffset = Offset; + BoundToExe = true; + } + } + + TPackageHeader hdr; + fread(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); + fclose(f); + return S_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 DirOffset; + fread(&DirOffset, sizeof(uint32), 1, f); + DirOffset += AbsoluteOffset; + fseek(f, DirOffset, SEEK_SET); + } + + for (int i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(Game); + if (!pkg) return E_FAIL; + + pkg->_boundToExe = BoundToExe; + + // read package info + byte NameLength; + fread(&NameLength, sizeof(byte), 1, f); + pkg->_name = new char[NameLength]; + fread(pkg->_name, NameLength, 1, f); + fread(&pkg->_cD, sizeof(byte), 1, f); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.Add(pkg); + + + // read file entries + uint32 NumFiles; + fread(&NumFiles, sizeof(uint32), 1, f); + + for (int j = 0; j < NumFiles; j++) { + char *Name; + uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; + + fread(&NameLength, sizeof(byte), 1, f); + Name = new char[NameLength]; + fread(Name, NameLength, 1, f); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < NameLength; k++) { + ((byte *)Name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + Name[NameLength - 1] = '\0'; + + + CBPlatform::strupr(Name); + + fread(&Offset, sizeof(uint32), 1, f); + Offset += AbsoluteOffset; + fread(&Length, sizeof(uint32), 1, f); + fread(&CompLength, sizeof(uint32), 1, f); + fread(&Flags, sizeof(uint32), 1, f); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + fread(&TimeDate1, sizeof(uint32), 1, f); + fread(&TimeDate2, sizeof(uint32), 1, f); + } + _filesIter = _files.find(Name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(Game); + file->_package = pkg; + file->_offset = Offset; + file->_length = Length; + file->_compressedLength = CompLength; + file->_flags = Flags; + + _files[Name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = Offset; + _filesIter->_value->_length = Length; + _filesIter->_value->_compressedLength = CompLength; + _filesIter->_value->_flags = Flags; + } + } + delete [] Name; + } + } + + + fclose(f); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::GetFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::StartsWith(plainName, "xdevice_", true)) { + return StringUtil::CompareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::OpenPackage(const char *Name) { + //TODO: Is it really necessary to do this when we have the ScummVM-system? + + //RestoreCurrentDir(); + + Common::File *ret = new Common::File(); + char Filename[MAX_PATH]; + + for (int i = 0; i < _packagePaths.GetSize(); i++) { + sprintf(Filename, "%s%s.%s", _packagePaths[i], Name, PACKAGE_EXTENSION); + ret->open(Filename); + if (ret->isOpen()) { + return ret; + } + } + + sprintf(Filename, "%s.%s", Name, PACKAGE_EXTENSION); + ret->open(Filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", Name); + delete ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::OpenSingleFile(const char *Name) { + RestoreCurrentDir(); + + Common::File *ret = NULL; + char Filename[MAX_PATH]; + + for (int i = 0; i < _singlePaths.GetSize(); i++) { + sprintf(Filename, "%s%s", _singlePaths[i], Name); + ret->open(Filename); + if (ret->isOpen()) + return ret; + } + + // didn't find in search paths, try to open directly + ret->open(Name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { + RestoreCurrentDir(); + + Common::File f; + bool found = false; + + for (int i = 0; i < _singlePaths.GetSize(); i++) { + sprintf(Fullname, "%s%s", _singlePaths[i], Filename); + f.open(Fullname); + if (f.isOpen()) { + f.close(); + found = true; + break; + } + } + + if (!found) { + f.open(Filename); + if (f.isOpen()) { + f.close(); + found = true; + strcpy(Fullname, Filename); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { + char *upc_name = new char[strlen(Filename) + 1]; + strcpy(upc_name, Filename); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; + + delete [] upc_name; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { + if (strcmp(Filename, "") == 0) return NULL; + //Game->LOG(0, "open file: %s", Filename); +#ifdef __WIN32__ + if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(Filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); + } + } +#endif + + CBFile *File = OpenFileRaw(Filename); + if (File) _openFiles.Add(File); + return File; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::CloseFile(CBFile *File) { + for (int i = 0; i < _openFiles.GetSize(); i++) { + if (_openFiles[i] == File) { + _openFiles[i]->Close(); + delete _openFiles[i]; + _openFiles.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile *CBFileManager::OpenFileRaw(const Common::String &Filename) { + RestoreCurrentDir(); + + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); + if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile; + else { + delete SaveThumbFile; + return NULL; + } + } + + CBDiskFile *DiskFile = new CBDiskFile(Game); + if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; + + delete DiskFile; + CBPkgFile *PkgFile = new CBPkgFile(Game); + if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; + + delete PkgFile; + CBResourceFile *ResFile = new CBResourceFile(Game); + if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; + + delete ResFile; + warning("BFileManager::OpenFileRaw - Failed to open %s", Filename.c_str()); + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::RestoreCurrentDir() { + if (!_basePath) return S_OK; + else { + /*if (!chdir(_basePath)) return S_OK; + else return E_FAIL;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFileManager::SetBasePath(const char *Path) { + Cleanup(); + + if (Path) { + _basePath = new char[strlen(Path) + 1]; + strcpy(_basePath, Path); + } + + InitPaths(); + RegisterPackages(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::FindPackageSignature(Common::File *f, uint32 *Offset) { + byte buf[32768]; + + byte Signature[8]; + ((uint32 *)Signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)Signature)[1] = PACKAGE_MAGIC_2; + + uint32 FileSize = f->size(); + + int StartPos = 1024 * 1024; + + uint32 BytesRead = StartPos; + + while (BytesRead < FileSize - 16) { + int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); + f->seek(StartPos, SEEK_SET); + int ActuallyRead = f->read(buf, ToRead); + if (ActuallyRead != ToRead) return false; + + for (int i = 0; i < ToRead - 8; i++) + if (!memcmp(buf + i, Signature, 8)) { + *Offset = StartPos + i; + return true; + } + + BytesRead = BytesRead + ToRead - 16; + StartPos = StartPos + ToRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h new file mode 100644 index 0000000000..cf0e284cc1 --- /dev/null +++ b/engines/wintermute/Base/BFileManager.h @@ -0,0 +1,87 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + + +//#include +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BFileEntry.h" +#include "common/archive.h" +#include "common/str.h" + +namespace Common { +class File; +} + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool FindPackageSignature(Common::File *f, uint32 *Offset); + HRESULT Cleanup(); + HRESULT SetBasePath(const char *Path); + HRESULT RestoreCurrentDir(); + char *_basePath; + bool GetFullPath(const char *Filename, char *Fullname); + CBFile *OpenFileRaw(const Common::String &filename); + HRESULT CloseFile(CBFile *File); + CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); + CBFileEntry *GetPackageEntry(const char *Filename); + Common::File *OpenSingleFile(const char *Name); + Common::File *OpenPackage(const char *Name); + HRESULT RegisterPackages(); + HRESULT InitPaths(); + HRESULT ReloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + HRESULT AddPath(TPathType Type, const char *Path); + HRESULT RequestCD(int CD, char *PackageFile, char *Filename); + HRESULT SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); + byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + CBArray _singlePaths; + CBArray _packagePaths; + CBArray _packages; + CBArray _openFiles; + + Common::HashMap _files; +private: + HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); + HRESULT RegisterPackage(Common::String Filename, bool SearchSignature = false); + Common::HashMap::iterator _filesIter; + bool IsValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp new file mode 100644 index 0000000000..0f2b248bee --- /dev/null +++ b/engines/wintermute/Base/BFont.cpp @@ -0,0 +1,206 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontBitmap.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/Base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::GetTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::GetTextWidth(byte *text, int MaxLenght) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +HRESULT CBFont::LoadFile(const char * Filename) +{ + BYTE* Buffer = Game->_fileManager->ReadWholeFile(Filename); + if(Buffer==NULL){ + Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename)+1]; + strcpy(_filename, Filename); + + if(FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFont::LoadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(Game); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + Game->LOG(0, "'FONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + Game->LOG(0, "Syntax error in FONT definition"); + return E_FAIL; + } + + return S_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::GetLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFont::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { + if (IsTrueType(Game, Filename)) { + CBFontTT *Font = new CBFontTT(Game); + if (Font) { + if (FAILED(Font->LoadFile(Filename))) { + delete Font; + return NULL; + } + } + return Font; + } else { + CBFontBitmap *Font = new CBFontBitmap(Game); + if (Font) { + if (FAILED(Font->LoadFile(Filename))) { + delete Font; + return NULL; + } + } + return Font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::IsTrueType(CBGame *Game, const char *Filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) return false; + + byte *WorkBuffer = Buffer; + + char *params; + CBParser parser(Game); + + bool Ret = false; + if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + Ret = true; + + delete [] Buffer; + return Ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h new file mode 100644 index 0000000000..0cfb5ed681 --- /dev/null +++ b/engines/wintermute/Base/BFont.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/Base/BObject.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int GetTextWidth(byte *text, int MaxLenght = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + virtual void InitLoop() {}; + + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *CreateFromFile(CBGame *Game, const char *Filename); + +private: + //HRESULT LoadBuffer(byte * Buffer); + //HRESULT LoadFile(const char* Filename); + static bool IsTrueType(CBGame *Game, const char *Filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp new file mode 100644 index 0000000000..98864f6ebd --- /dev/null +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -0,0 +1,542 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFontBitmap.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { + TextHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetTextHeight(byte *text, int width) { + return TextHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { + AnsiString str; + + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); + str = StringUtil::WideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (MaxLength >= 0 && str.size() > MaxLength) + str = Common::String(str.c_str(), MaxLength); + //str.substr(0, MaxLength); // TODO: Remove + + int TextWidth = 0; + for (size_t i = 0; i < str.size(); i++) { + TextWidth += GetCharWidth(str[i]); + } + + return TextWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { + if (MaxLenght == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + + + AnsiString str; + + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); + str = StringUtil::WideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) Game->_renderer->StartSpriteBatch(); + + while (!done) { + if (max_height > 0 && (NumLines + 1)*_tileHeight > max_height) { + if (draw) Game->_renderer->EndSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (max_height < 0 || max_height / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + GetCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (MaxLenght >= 0 && index == MaxLenght - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += GetCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += GetCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) DrawChar(str[i], StartX, y); + StartX += GetCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) Game->_renderer->EndSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::DrawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + RECT rect; + /* l t r b */ + int TileWidth; + if (_wholeCell) TileWidth = _tileWidth; + else TileWidth = _widths[c]; + + CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + TileWidth, (row + 1)*_tileHeight); + bool Handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->DisplayTrans(x, y, rect); + } + Handled = true; + } + } + if (!Handled && _subframe) _subframe->_surface->DisplayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_FONT) { + Game->LOG(0, "'FONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int last_width = 0; + int i; + int r = 255, g = 255, b = 255; + bool custo_trans = false; + char *surface_file = NULL; + char *sprite_file = NULL; + + bool AutoWidth = false; + int SpaceWidth = 0; + int ExpandWidth = 0; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surface_file = (char *)params; + break; + + case TOKEN_SPRITE: + sprite_file = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + + case TOKEN_WIDTHS: + parser.ScanStr(params, "%D", widths, &num); + for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { + _widths[last_width] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.ScanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.ScanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.ScanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.ScanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.ScanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.ScanStr(params, "%b", &AutoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.ScanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.ScanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.ScanStr(params, "%d", &SpaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.ScanStr(params, "%d", &ExpandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in FONT definition"); + return E_FAIL; + } + + if (sprite_file != NULL) { + delete _sprite; + _sprite = new CBSprite(Game, this); + if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surface_file != NULL && !_sprite) { + _subframe = new CBSubFrame(Game); + if (custo_trans) _subframe->SetSurface(surface_file, false, r, g, b); + else _subframe->SetSurface(surface_file); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + Game->LOG(0, "Incomplete font definition"); + return E_FAIL; + } + + if (AutoWidth) { + // calculate characters width + GetWidths(); + + // do we need to modify widths? + if (ExpandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + ExpandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + char SpaceChar = ' '; + if (_fontextFix) SpaceChar--; + + if (SpaceWidth != 0) _widths[SpaceChar] = SpaceWidth; + else { + if (_widths[SpaceChar] == ExpandWidth || _widths[SpaceChar] == 0) { + _widths[SpaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = last_width; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { + + CBFont::Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_numColumns)); + + PersistMgr->Transfer(TMEMBER(_subframe)); + PersistMgr->Transfer(TMEMBER(_tileHeight)); + PersistMgr->Transfer(TMEMBER(_tileWidth)); + PersistMgr->Transfer(TMEMBER(_sprite)); + PersistMgr->Transfer(TMEMBER(_widthsFrame)); + + if (PersistMgr->_saving) + PersistMgr->PutBytes(_widths, sizeof(_widths)); + else + PersistMgr->GetBytes(_widths, sizeof(_widths)); + + + PersistMgr->Transfer(TMEMBER(_fontextFix)); + PersistMgr->Transfer(TMEMBER(_wholeCell)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetCharWidth(byte Index) { + if (_fontextFix) Index--; + return _widths[Index]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontBitmap::GetWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.GetSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.GetSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || FAILED(surf->StartPixelOp())) return E_FAIL; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int min_col = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= min_col + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; + if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + min_col = MAX(col, min_col); + break; + } + } + if (min_col == _tileWidth - 1) break; + } + + _widths[i] = min_col + 1; + } + surf->EndPixelOp(); + /* + Game->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::GetLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h new file mode 100644 index 0000000000..e22540b3c1 --- /dev/null +++ b/engines/wintermute/Base/BFontBitmap.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/Base/BFont.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + HRESULT LoadBuffer(byte *Buffer); + HRESULT LoadFile(const char *Filename); + virtual int GetTextWidth(byte *text, int MaxLength = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + HRESULT GetWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int GetCharWidth(byte Index); + void DrawChar(byte c, int x, int y); + + int TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp new file mode 100644 index 0000000000..b34e24c286 --- /dev/null +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -0,0 +1,157 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +// _fTLibrary = NULL; + InitFreeType(); +} + + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + Cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontStorage::InitFreeType() { +#if 0 + FT_Error error = FT_Init_FreeType(&_fTLibrary); + if (error) { + Game->LOG(0, "Error initializing FreeType library."); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::Cleanup(bool Warn) { + int i; + + for (i = 0; i < _fonts.GetSize(); i++) { + if (Warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.RemoveAll(); + +#if 0 + if (_fTLibrary) FT_Done_FreeType(_fTLibrary); +#endif + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::InitLoop() { + for (int i = 0; i < _fonts.GetSize(); i++) { + _fonts[i]->InitLoop(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::AddFont(const char *Filename) { + if (!Filename) return NULL; + + for (int i = 0; i < _fonts.GetSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, Filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(Game); + if(!font) return NULL; + + if(FAILED(font->LoadFile(Filename))){ + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.Add(font); + return font; + } + */ + CBFont *font = CBFont::CreateFromFile(Game, Filename); + if (font) { + font->_refCount = 1; + _fonts.Add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::RemoveFont(CBFont *Font) { + if (!Font) return E_FAIL; + + for (int i = 0; i < _fonts.GetSize(); i++) { + if (_fonts[i] == Font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.RemoveAt(i); + } + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontStorage::Persist(CBPersistMgr *PersistMgr) { + + if (!PersistMgr->_saving) Cleanup(false); + + PersistMgr->Transfer(TMEMBER(Game)); + _fonts.Persist(PersistMgr); + + if (!PersistMgr->_saving) InitFreeType(); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h new file mode 100644 index 0000000000..c7d60d7bce --- /dev/null +++ b/engines/wintermute/Base/BFontStorage.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +/*#include +#include FT_FREETYPE_H*/ + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + HRESULT Cleanup(bool Warn = false); + HRESULT RemoveFont(CBFont *Font); + CBFont *AddFont(const char *Filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + HRESULT InitLoop(); + + /* FT_Library GetFTLibrary() const { + return _fTLibrary; + }*/ + +private: + void InitFreeType(); + //FT_Library _fTLibrary; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp new file mode 100644 index 0000000000..deb139859a --- /dev/null +++ b/engines/wintermute/Base/BFontTT.cpp @@ -0,0 +1,889 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +//#include +//#include FT_FREETYPE_H +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/FontGlyphCache.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/MathUtil.h" +#include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + _glyphCache = NULL; + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + ClearCache(); + + for (int i = 0; i < _layers.GetSize(); i++) { + delete _layers[i]; + } + _layers.RemoveAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _font; + _font = NULL; + + delete _fallbackFont; + _fallbackFont = NULL; + + delete _glyphCache; + _glyphCache = NULL; +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::ClearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } + +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::InitLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (Game->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { + WideString text; + + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (MaxLength >= 0 && text.size() > MaxLength) + text = Common::String(text.c_str(), MaxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + MeasureText(text, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetTextHeight(byte *Text, int Width) { + WideString text; + + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + + int textWidth, textHeight; + MeasureText(text, Width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { + warning("Draw text: %s", Text); + if (Text == NULL || strcmp((char *)Text, "") == 0) return; + + WideString text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (MaxLength >= 0 && text.size() > MaxLength) + text = Common::String(text.c_str(), MaxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; + + // find cached surface, if exists + int MinPriority = INT_MAX; + int MinIndex = -1; + CBSurface *Surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + MinPriority = 0; + MinIndex = i; + } else { + if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == Align && _cachedTexts[i]->_width == Width && _cachedTexts[i]->_maxHeight == MaxHeight && _cachedTexts[i]->_maxLength == MaxLength) { + Surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < MinPriority) { + MinPriority = _cachedTexts[i]->_priority; + MinIndex = i; + } + } + } + } + + // not found, create one + if (!Surface) { + Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); + if (Surface) { + // write surface to cache + if (_cachedTexts[MinIndex] != NULL) delete _cachedTexts[MinIndex]; + _cachedTexts[MinIndex] = new CBCachedTTFontText; + + _cachedTexts[MinIndex]->_surface = Surface; + _cachedTexts[MinIndex]->_align = Align; + _cachedTexts[MinIndex]->_width = Width; + _cachedTexts[MinIndex]->_maxHeight = MaxHeight; + _cachedTexts[MinIndex]->_maxLength = MaxLength; + _cachedTexts[MinIndex]->_priority = 1; + _cachedTexts[MinIndex]->_text = text; + _cachedTexts[MinIndex]->_textOffset = textOffset; + _cachedTexts[MinIndex]->_marked = true; + } + } + + + // and paint it + if (Surface) { + RECT rc; + CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight()); + for (int i = 0; i < _layers.GetSize(); i++) { + uint32 Color = _layers[i]->_color; + uint32 OrigForceAlpha = _renderer->_forceAlphaColor; + if (_renderer->_forceAlphaColor != 0) { + Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(_renderer->_forceAlphaColor)); + _renderer->_forceAlphaColor = 0; + } + Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + _renderer->_forceAlphaColor = OrigForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + TextLineList lines; + WrapText(text, width, maxHeight, lines); + + + TextLineList::iterator it; + warning("CBFontTT::RenderTextToTexture - Not ported yet"); +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); + if (SUCCEEDED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::GetLetterHeight() { + return GetLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::LoadBuffer(byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + Game->LOG(0, "'TTFONT' keyword expected."); + return E_FAIL; + } + Buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.ScanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::SetString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.ScanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.ScanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.ScanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.ScanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = DRGBA(r, g, b, D3DCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.ScanStr(params, "%d", &a); + BaseColor = DRGBA(D3DCOLGetR(BaseColor), D3DCOLGetG(BaseColor), D3DCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TTFONT definition"); + return E_FAIL; + } + + // create at least one layer + if (_layers.GetSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.Add(Layer); + } + + if (!_fontFile) CBUtils::SetString(&_fontFile, "arial.ttf"); + + return InitFont(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.ScanStr(params, "%d", &Layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.ScanStr(params, "%d", &Layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + Layer->_color = DRGBA(r, g, b, D3DCOLGetA(Layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.ScanStr(params, "%d", &a); + Layer->_color = DRGBA(D3DCOLGetR(Layer->_color), D3DCOLGetG(Layer->_color), D3DCOLGetB(Layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return E_FAIL; + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { + CBFont::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_isBold)); + PersistMgr->Transfer(TMEMBER(_isItalic)); + PersistMgr->Transfer(TMEMBER(_isUnderline)); + PersistMgr->Transfer(TMEMBER(_isStriked)); + PersistMgr->Transfer(TMEMBER(_fontHeight)); + PersistMgr->Transfer(TMEMBER(_fontFile)); + + + // persist layers + int NumLayers; + if (PersistMgr->_saving) { + NumLayers = _layers.GetSize(); + PersistMgr->Transfer(TMEMBER(NumLayers)); + for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(PersistMgr); + } else { + NumLayers = _layers.GetSize(); + PersistMgr->Transfer(TMEMBER(NumLayers)); + for (int i = 0; i < NumLayers; i++) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->Persist(PersistMgr); + _layers.Add(Layer); + } + } + + if (!PersistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _glyphCache = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::AfterLoad() { + InitFont(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFontTT::InitFont() { + if (!_fontFile) return E_FAIL; + warning("BFontTT::InitFont - Not ported yet"); + + CBFile *file = Game->_fileManager->OpenFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); + file = Game->_fileManager->OpenFile((char *)fontFileName.c_str(), false); + if (!file) { + Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return E_FAIL; + } + } + warning("I guess we got a file"); + if (file) { + //_font = Graphics::loadTTFFont(*file->getMemStream(), 12); + } else { + _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + return S_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + Game->_fileManager->CloseFile(file); + return E_FAIL; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return E_FAIL; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// I/O bridge between FreeType and WME file system +////////////////////////////////////////////////////////////////////////// +/* +unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return 0; + + f->Seek(offset, SEEK_TO_BEGIN); + if (count) { + uint32 oldPos = f->GetPos(); + f->Read(buffer, count); + return f->GetPos() - oldPos; + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::FTCloseProc(FT_Stream stream) { + CBFile *f = static_cast(stream->descriptor.pointer); + if (!f) return; + + CBGame *Game = f->Game; + + Game->_fileManager->CloseFile(f); + stream->descriptor.pointer = NULL; +}*/ + + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines) { + int currWidth = 0; + wchar_t prevChar = L'\0'; + int prevSpaceIndex = -1; + int prevSpaceWidth = 0; + int lineStartIndex = 0; + + PrepareGlyphs(text); + + for (size_t i = 0; i < text.size(); i++) { + wchar_t ch = text[i]; + + if (ch == L' ') { + prevSpaceIndex = i; + prevSpaceWidth = currWidth; + } + + int charWidth = 0; + + if (ch != L'\n') { + GlyphInfo *glyphInfo = GetGlyphCache()->GetGlyph(ch); + if (!glyphInfo) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + prevChar = ch; + + charWidth = (int)(glyphInfo->GetAdvanceX() + kerning); + } + + bool lineTooLong = maxWidth >= 0 && currWidth + charWidth > maxWidth; + bool breakOnSpace = false; + + // we can't fit even a single character + if (lineTooLong && currWidth == 0) break; + + + if (ch == L'\n' || i == text.size() - 1 || lineTooLong) { + int breakPoint, breakWidth; + + if (prevSpaceIndex >= 0 && lineTooLong) { + breakPoint = prevSpaceIndex; + breakWidth = prevSpaceWidth; + breakOnSpace = true; + } else { + breakPoint = i; + breakWidth = currWidth; + + breakOnSpace = (ch == L'\n'); + + // we're at the end + if (i == text.size() - 1) { + breakPoint++; + breakWidth += charWidth; + } + } + + if (maxHeight >= 0 && (lines.size() + 1) * GetLineHeight() > maxHeight) break; + + //WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); // TODO: Remove + WideString line = Common::String(text.c_str() + lineStartIndex, breakPoint - lineStartIndex); + lines.push_back(new TextLine(line, breakWidth)); + + currWidth = 0; + prevChar = L'\0'; + prevSpaceIndex = -1; + + if (breakOnSpace) breakPoint++; + + lineStartIndex = breakPoint; + i = breakPoint - 1; + + continue; + } + + //if (ch == L' ' && currLine.empty()) continue; + currWidth += charWidth; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + TextLineList lines; + WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * GetLineHeight()); + textWidth = 0; + + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { + GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); + GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); +#if 0 + if (!infoLeft || !infoRight) return 0; + + FT_Vector delta; + FT_Error error = FT_Get_Kerning(_fTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); + if (error) return 0; + + return delta.x * (1.0f / 64.0f); +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::PrepareGlyphs(const WideString &text) { + // make sure we have all the glyphs we need + for (size_t i = 0; i < text.size(); i++) { + wchar_t ch = text[i]; + if (!_glyphCache->HasGlyph(ch)) CacheGlyph(ch); + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::CacheGlyph(wchar_t ch) { +#if 0 + FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); + if (!glyphIndex) return; + + FT_Error error = FT_Load_Glyph(_fTFace, glyphIndex, FT_LOAD_DEFAULT); + if (error) return; + + error = FT_Render_Glyph(_fTFace->glyph, FT_RENDER_MODE_NORMAL); + if (error) return; + + byte *pixels = _fTFace->glyph->bitmap.buffer; + size_t stride = _fTFace->glyph->bitmap.pitch; + + + // convert from monochrome to grayscale if needed + byte *tempBuffer = NULL; + if (pixels != NULL && _fTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { + tempBuffer = new byte[_fTFace->glyph->bitmap.width * _fTFace->glyph->bitmap.rows]; + for (int j = 0; j < _fTFace->glyph->bitmap.rows; j++) { + int rowOffset = stride * j; + for (int i = 0; i < _fTFace->glyph->bitmap.width; i++) { + int byteOffset = i / 8; + int bitOffset = 7 - (i % 8); + byte bit = (pixels[rowOffset + byteOffset] & (1 << bitOffset)) >> bitOffset; + tempBuffer[_fTFace->glyph->bitmap.width * j + i] = 255 * bit; + } + } + + pixels = tempBuffer; + stride = _fTFace->glyph->bitmap.width; + } + + // add glyph to cache + _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); + + if (tempBuffer) delete [] tempBuffer; +#endif +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h new file mode 100644 index 0000000000..22630a7444 --- /dev/null +++ b/engines/wintermute/Base/BFontTT.h @@ -0,0 +1,193 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BSurface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class FontGlyphCache; + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + HRESULT Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_color)); + return S_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString &GetText() const { + return _text; + } + int GetWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int GetTextWidth(byte *text, int MaxLenght = -1); + virtual int GetTextHeight(byte *text, int width); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int GetLetterHeight(); + + HRESULT LoadBuffer(byte *Buffer); + HRESULT LoadFile(const char *Filename); + + /* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); + static void FTCloseProc(FT_Stream stream);*/ + + FontGlyphCache *GetGlyphCache() { + return _glyphCache; + } + + float GetLineHeight() const { + return _lineHeight; + } + + void AfterLoad(); + void InitLoop(); + +private: + HRESULT ParseLayer(CBTTFontLayer *Layer, byte *Buffer); + + void WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + float GetKerning(wchar_t leftChar, wchar_t rightChar); + void PrepareGlyphs(const WideString &text); + void CacheGlyph(wchar_t ch); + + CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + HRESULT InitFont(); + //FT_Stream _fTStream; + //FT_Face _fTFace; + Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + FontGlyphCache *_glyphCache; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void ClearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp new file mode 100644 index 0000000000..6fa61b5d51 --- /dev/null +++ b/engines/wintermute/Base/BFrame.cpp @@ -0,0 +1,708 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete _sound; + _sound = NULL; + + int i; + + for (i = 0; i < _subframes.GetSize(); i++) delete _subframes[i]; + _subframes.RemoveAll(); + + for (i = 0; i < _applyEvent.GetSize(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { + HRESULT res; + + for (int i = 0; i < _subframes.GetSize(); i++) { + res = _subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); + if (FAILED(res)) return res; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { + if (_sound && !Muted) { + if (Owner) Owner->UpdateOneSound(_sound); + _sound->Play(); + /* + if(Game->_state==GAME_FROZEN) + { + _sound->Pause(true); + } + */ + } + if (Owner) { + for (int i = 0; i < _applyEvent.GetSize(); i++) { + Owner->ApplyEvent(_applyEvent[i]); + } + } + return S_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + RECT rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int HotspotX = 0, HotspotY = 0; + bool custo_trans = false; + bool editor_selected = false; + bool Is2DOnly = false; + bool Is3DOnly = false; + bool Decoration = false; + bool MirrorX = false; + bool MirrorY = false; + CBPlatform::SetRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.ScanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + + case TOKEN_RECT: + parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.ScanStr(params, "%d,%d", &HotspotX, &HotspotY); + break; + + case TOKEN_MOVE: + parser.ScanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.ScanStr(params, "%b", &Is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.ScanStr(params, "%b", &Is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.ScanStr(params, "%b", &MirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.ScanStr(params, "%b", &MirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr(params, "%b", &editor_selected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.ScanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.ScanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(Game); + if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else _subframes.Add(subframe); + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new CBSound(Game); + if (!_sound || FAILED(_sound->SetSound(params, SOUND_SFX, false))) { + if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + _applyEvent.Add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.ScanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.ScanStr(params, "%b", &Decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in FRAME definition"); + return E_FAIL; + } + + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading FRAME definition"); + return E_FAIL; + } + + + CBSubFrame *sub = new CBSubFrame(Game); + if (surface_file != NULL) { + if (custo_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else sub->SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + + if (!sub->_surface) { + delete sub; + Game->LOG(0, "Error loading SUBFRAME"); + return E_FAIL; + } + + sub->_alpha = DRGBA(ar, ag, ab, alpha); + if (custo_trans) sub->_transparent = DRGBA(r, g, b, 0xFF); + } + + if (CBPlatform::IsRectEmpty(&rect)) sub->SetDefaultRect(); + else sub->_rect = rect; + + sub->_hotspotX = HotspotX; + sub->_hotspotY = HotspotY; + sub->_2DOnly = Is2DOnly; + sub->_3DOnly = Is3DOnly; + sub->_decoration = Decoration; + sub->_mirrorX = MirrorX; + sub->_mirrorY = MirrorY; + + + sub->_editorSelected = editor_selected; + _subframes.InsertAt(0, sub); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + CBPlatform::SetRectEmpty(Rect); + + RECT SubRect; + + for (int i = 0; i < _subframes.GetSize(); i++) { + _subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); + CBPlatform::UnionRect(Rect, Rect, &SubRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "FRAME {\n"); + Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) + Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + + if (_sound && _sound->_soundFilename) + Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + + Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) + Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + + if (_editorExpanded) + Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + + if (_subframes.GetSize() > 0) _subframes[0]->SaveAsText(Buffer, Indent, false); + + int i; + for (i = 1; i < _subframes.GetSize(); i++) { + _subframes[i]->SaveAsText(Buffer, Indent + 2); + } + + for (i = 0; i < _applyEvent.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + CBBase::SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + _applyEvent.Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER(_delay)); + PersistMgr->Transfer(TMEMBER(_editorExpanded)); + PersistMgr->Transfer(TMEMBER(_keyframe)); + PersistMgr->Transfer(TMEMBER(_killSound)); + PersistMgr->Transfer(TMEMBER(_moveX)); + PersistMgr->Transfer(TMEMBER(_moveY)); + PersistMgr->Transfer(TMEMBER(_sound)); + _subframes.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetSound") == 0) { + Stack->CorrectParams(0); + + if (_sound && _sound->_soundFilename) Stack->PushString(_sound->_soundFilename); + else Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSound") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + delete _sound; + _sound = NULL; + + if (!Val->IsNULL()) { + _sound = new CBSound(Game); + if (!_sound || FAILED(_sound->SetSound(Val->GetString(), SOUND_SFX, false))) { + Stack->PushBool(false); + delete _sound; + _sound = NULL; + } else Stack->PushBool(true); + } else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetSubframe") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= _subframes.GetSize()) { + Script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushNative(_subframes[Index], true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteSubframe") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (Val->IsInt()) { + int Index = Val->GetInt(-1); + if (Index < 0 || Index >= _subframes.GetSize()) { + Script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); + } + } else { + CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); + for (int i = 0; i < _subframes.GetSize(); i++) { + if (_subframes[i] == Sub) { + delete _subframes[i]; + _subframes.RemoveAt(i); + break; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSubframe") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + const char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBSubFrame *Sub = new CBSubFrame(Game); + if (Filename != NULL) { + Sub->SetSurface(Filename); + Sub->SetDefaultRect(); + } + _subframes.Add(Sub); + + Stack->PushNative(Sub, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertSubframe") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + if (Index < 0) Index = 0; + + CScValue *Val = Stack->Pop(); + const char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBSubFrame *Sub = new CBSubFrame(Game); + if (Filename != NULL) { + Sub->SetSurface(Filename); + } + + if (Index >= _subframes.GetSize()) _subframes.Add(Sub); + else _subframes.InsertAt(Index, Sub); + + Stack->PushNative(Sub, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSubframe") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= _applyEvent.GetSize()) { + Script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushString(_applyEvent[Index]); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddEvent") == 0) { + Stack->CorrectParams(1); + const char *Event = Stack->Pop()->GetString(); + for (int i = 0; i < _applyEvent.GetSize(); i++) { + if (scumm_stricmp(_applyEvent[i], Event) == 0) { + Stack->PushNULL(); + return S_OK; + } + } + _applyEvent.Add(Event); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteEvent") == 0) { + Stack->CorrectParams(1); + const char *Event = Stack->Pop()->GetString(); + for (int i = 0; i < _applyEvent.GetSize(); i++) { + if (scumm_stricmp(_applyEvent[i], Event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.RemoveAt(i); + break; + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.GetSize() == 1) return _subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::ScGetProperty(const char *Name) { + if (!_scValue) _scValue = new CScValue(Game); + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Delay") == 0) { + _scValue->SetInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyframe") == 0) { + _scValue->SetBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KillSounds") == 0) { + _scValue->SetBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveX") == 0) { + _scValue->SetInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveY") == 0) { + _scValue->SetInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumSubframes") == 0) { + _scValue->SetInt(_subframes.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumEvents") == 0) { + _scValue->SetInt(_applyEvent.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.GetSize() == 1) return _subframes[0]->ScGetProperty(Name); + else return CBScriptable::ScGetProperty(Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Delay") == 0) { + _delay = MAX(0, Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyframe") == 0) { + _keyframe = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KillSounds") == 0) { + _killSound = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveX") == 0) { + _moveX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveY") == 0) { + _moveY = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.GetSize() == 1) return _subframes[0]->ScSetProperty(Name, Value); + else return CBScriptable::ScSetProperty(Name, Value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBFrame::ScToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h new file mode 100644 index 0000000000..ac7c88fbf7 --- /dev/null +++ b/engines/wintermute/Base/BFrame.h @@ -0,0 +1,73 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "engines/wintermute/Base/BScriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool _killSound; + bool _keyframe; + HRESULT OneTimeDisplay(CBObject *Owner, bool Muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *_sound; + bool _editorExpanded; + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray _applyEvent; + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp new file mode 100644 index 0000000000..6b7df8c46b --- /dev/null +++ b/engines/wintermute/Base/BGame.cpp @@ -0,0 +1,4537 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFader.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BQuickMsg.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BTransitionMgr.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BSaveThumbHelper.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/crc.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/SXArray.h" +#include "engines/wintermute/Base/scriptables/SXDate.h" +#include "engines/wintermute/Base/scriptables/SXFile.h" +#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" +#include "engines/wintermute/Base/scriptables/SxObject.h" +#include "engines/wintermute/Base/scriptables/SXMath.h" +#include "engines/wintermute/Base/scriptables/SXStore.h" +#include "engines/wintermute/Base/scriptables/SXString.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" + +#ifdef __IPHONEOS__ +# include "ios_utils.h" +#endif + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _dEBUG_LogFile = NULL; + _dEBUG_DebugMode = false; + _dEBUG_AbsolutePathWarning = true; + _dEBUG_ShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + srand((unsigned)time(NULL)); + + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + _doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _resourceModule = NULL; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _indicatorDisplay = false; + _indicatorColor = DRGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::SetString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _localSaveDir = NULL; + CBUtils::SetString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + CBPlatform::SetRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + +#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices +#else + _touchInterface = false; + _constrainedMemory = false; +#endif + + _store = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + GetDebugMgr()->OnGameShutdown(); + + _registry->WriteBool("System", "LastRun", true); + + Cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _saveLoadImage; + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _saveLoadImage = NULL; + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::OutputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Cleanup() { + int i; + + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + UnregisterObject(_store); + _store = NULL; + + UnregisterObject(_fader); + _fader = NULL; + + for (i = 0; i < _regObjects.GetSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.RemoveAll(); + + _windows.RemoveAll(); // refs only + _focusedWindow = NULL; // ref only + + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (i = 0; i < _scripts.GetSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->Finish(); + } + _scripts.RemoveAll(); + + _fontStorage->RemoveFont(_systemFont); + _systemFont = NULL; + + _fontStorage->RemoveFont(_videoFont); + _videoFont = NULL; + + for (i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; + _quickMessages.RemoveAll(); + + _viewportStack.RemoveAll(); + _viewportSP = -1; + + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize1() { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) goto init_fail; + + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) goto init_fail; + + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) goto init_fail; + + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) goto init_fail; + + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) goto init_fail; + + _mathClass = new CSXMath(this); + if (_mathClass == NULL) goto init_fail; + + _scEngine = new CScEngine(this); + if (_scEngine == NULL) goto init_fail; + + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) goto init_fail; + + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) goto init_fail; + + _fader = new CBFader(this); + if (_fader == NULL) goto init_fail; + RegisterObject(_fader); + + _store = new CSXStore(this); + if (_store == NULL) goto init_fail; + RegisterObject(_store); + + return S_OK; + +init_fail: + if (_mathClass) delete _mathClass; + if (_store) delete _store; + if (_keyboardState) delete _keyboardState; + if (_transMgr) delete _transMgr; + if (_debugMgr) delete _debugMgr; + if (_surfaceStorage) delete _surfaceStorage; + if (_fontStorage) delete _fontStorage; + if (_soundMgr) delete _soundMgr; + if (_fileManager) delete _fileManager; + if (_scEngine) delete _scEngine; + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize2() { // we know whether we are going to be accelerated + _renderer = new CBRenderSDL(this); + if (_renderer == NULL) goto init_fail; + + return S_OK; + +init_fail: + if (_renderer) delete _renderer; + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *Filename) { + _dEBUG_DebugMode = true; + +#ifndef __IPHONEOS__ + if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); + else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); + + if (!_dEBUG_LogFile) { + AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); + _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); + } + + if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); +#endif + + time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::GetPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (_dEBUG_LogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + fclose((FILE *)_dEBUG_LogFile); + _dEBUG_LogFile = NULL; + } + _dEBUG_DebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { +#ifndef __IPHONEOS__ + if (!_dEBUG_DebugMode) return; +#endif + time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + +#ifdef __IPHONEOS__ + printf("%02d:%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, buff); + fflush(stdout); +#else + if (_dEBUG_LogFile == NULL) return; + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + if (_debugMgr) _debugMgr->OnLog(res, buff); + + warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); + fflush((FILE *)_dEBUG_LogFile); +#endif + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback, void *Data) { + _engineLogCallback = Callback; + _engineLogCallbackData = Data; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitLoop() { + _viewportSP = -1; + + _currentTime = CBPlatform::GetTime(); + + GetDebugMgr()->OnGameTick(); + _renderer->InitLoop(); + _soundMgr->initLoop(); + UpdateMusicCrossfade(); + + _surfaceStorage->InitLoop(); + _fontStorage->InitLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //Game->LOG(0, "%d", _fps); + + GetMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.GetSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + UpdateSounds(); + + if (_fader) _fader->Update(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitInput(HINSTANCE hInst, HWND hWnd) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::GetSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetOffset(int OffsetX, int OffsetY) { + _offsetX = OffsetX; + _offsetY = OffsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::GetOffset(int *OffsetX, int *OffsetY) { + if (OffsetX != NULL) *OffsetX = _offsetX; + if (OffsetY != NULL) *OffsetY = _offsetY; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_GAME) { + Game->LOG(0, "'GAME' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) _fontStorage->RemoveFont(_systemFont); + _systemFont = NULL; + + _systemFont = Game->_fontStorage->AddFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) _fontStorage->RemoveFont(_videoFont); + _videoFont = NULL; + + _videoFont = Game->_fontStorage->AddFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(Game); + if (!_activeCursor || FAILED(_activeCursor->LoadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(Game); + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.ScanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.ScanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.ScanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.ScanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.ScanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.ScanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.ScanStr((char *)params, "%d", &_indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.ScanStr((char *)params, "%d", &_indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.ScanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + _indicatorColor = DRGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.ScanStr((char *)params, "%d", &_indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.ScanStr((char *)params, "%d", &_indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::SetString(&_saveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.ScanStr((char *)params, "%d", &_saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.ScanStr((char *)params, "%d", &_saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::SetString(&_loadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.ScanStr((char *)params, "%d", &_loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.ScanStr((char *)params, "%d", &_loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::SetString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.ScanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in GAME definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading GAME definition"); + return E_FAIL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LOG") == 0) { + Stack->CorrectParams(1); + LOG(0, Stack->Pop()->GetString()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + HRESULT res = CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + SetWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Msg") == 0) { + Stack->CorrectParams(1); + QuickMessage(Stack->Pop()->GetString()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RunScript") == 0) { + Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + Stack->CorrectParams(1); + if (FAILED(AddScript(Stack->Pop()->GetString()))) + Stack->PushBool(false); + else + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadStringTable") == 0) { + Stack->CorrectParams(2); + const char *Filename = Stack->Pop()->GetString(); + CScValue *Val = Stack->Pop(); + + bool ClearOld; + if (Val->IsNULL()) ClearOld = true; + else ClearOld = Val->GetBool(); + + if (FAILED(_stringTable->LoadFile(Filename, ClearOld))) + Stack->PushBool(false); + else + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ValidObject") == 0) { + Stack->CorrectParams(1); + CBScriptable *obj = Stack->Pop()->GetNative(); + if (ValidObject((CBObject *) obj)) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + ResetContent(); + Stack->PushNULL(); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UnloadObject") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CBObject *obj = (CBObject *)val->GetNative(); + UnregisterObject(obj); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadWindow") == 0) { + Stack->CorrectParams(1); + CUIWindow *win = new CUIWindow(Game); + if (win && SUCCEEDED(win->LoadFile(Stack->Pop()->GetString()))) { + _windows.Add(win); + RegisterObject(win); + Stack->PushNative(win, true); + } else { + delete win; + win = NULL; + Stack->PushNULL(); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExpandString") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + char *str = new char[strlen(val->GetString()) + 1]; + strcpy(str, val->GetString()); + _stringTable->Expand(&str); + Stack->PushString(str); + delete [] str; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayMusic") == 0 || strcmp(Name, "PlayMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "PlayMusic") == 0) Stack->CorrectParams(3); + else { + Stack->CorrectParams(4); + Channel = Stack->Pop()->GetInt(); + } + + const char *Filename = Stack->Pop()->GetString(); + CScValue *ValLooping = Stack->Pop(); + bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); + + CScValue *ValLoopStart = Stack->Pop(); + uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); + + + if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopMusic") == 0 || strcmp(Name, "StopMusicChannel") == 0) { + int Channel = 0; + + if (strcmp(Name, "StopMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(StopMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0 || strcmp(Name, "PauseMusicChannel") == 0) { + int Channel = 0; + + if (strcmp(Name, "PauseMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(PauseMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeMusic") == 0 || strcmp(Name, "ResumeMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "ResumeMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (FAILED(ResumeMusic(Channel))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusic") == 0 || strcmp(Name, "GetMusicChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusic") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) Stack->PushNULL(); + else { + if (!_music[Channel] || !_music[Channel]->_soundFilename) Stack->PushNULL(); + else Stack->PushString(_music[Channel]->_soundFilename); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMusicPosition") == 0 || strcmp(Name, "SetMusicChannelPosition") == 0 || strcmp(Name, "SetMusicPositionChannel") == 0) { + int Channel = 0; + if (strcmp(Name, "SetMusicPosition") == 0) Stack->CorrectParams(1); + else { + Stack->CorrectParams(2); + Channel = Stack->Pop()->GetInt(); + } + + uint32 Time = Stack->Pop()->GetInt(); + + if (FAILED(SetMusicStartTime(Channel, Time))) Stack->PushBool(false); + else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusicPosition") == 0 || strcmp(Name, "GetMusicChannelPosition") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusicPosition") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); + else Stack->PushInt(_music[Channel]->GetPositionTime()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsMusicPlaying") == 0 || strcmp(Name, "IsMusicChannelPlaying") == 0) { + int Channel = 0; + if (strcmp(Name, "IsMusicPlaying") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); + else Stack->PushBool(_music[Channel]->IsPlaying()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMusicVolume") == 0 || strcmp(Name, "SetMusicChannelVolume") == 0) { + int Channel = 0; + if (strcmp(Name, "SetMusicVolume") == 0) Stack->CorrectParams(1); + else { + Stack->CorrectParams(2); + Channel = Stack->Pop()->GetInt(); + } + + int Volume = Stack->Pop()->GetInt(); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); + else { + if (FAILED(_music[Channel]->SetVolume(Volume))) Stack->PushBool(false); + else Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMusicVolume") == 0 || strcmp(Name, "GetMusicChannelVolume") == 0) { + int Channel = 0; + if (strcmp(Name, "GetMusicVolume") == 0) Stack->CorrectParams(0); + else { + Stack->CorrectParams(1); + Channel = Stack->Pop()->GetInt(); + } + + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); + else Stack->PushInt(_music[Channel]->GetVolume()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicCrossfade") == 0) { + Stack->CorrectParams(4); + int Channel1 = Stack->Pop()->GetInt(0); + int Channel2 = Stack->Pop()->GetInt(0); + uint32 FadeLength = (uint32)Stack->Pop()->GetInt(0); + bool Swap = Stack->Pop()->GetBool(true); + + if (_musicCrossfadeRunning) { + Script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + Stack->PushBool(false); + return S_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = Channel1; + _musicCrossfadeChannel2 = Channel2; + _musicCrossfadeLength = FadeLength; + _musicCrossfadeSwap = Swap; + + _musicCrossfadeRunning = true; + + Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundLength") == 0) { + Stack->CorrectParams(1); + + int Length = 0; + const char *Filename = Stack->Pop()->GetString(); + + CBSound *Sound = new CBSound(Game); + if (Sound && SUCCEEDED(Sound->SetSound(Filename, SOUND_MUSIC, true))) { + Length = Sound->GetLength(); + delete Sound; + Sound = NULL; + } + Stack->PushInt(Length); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMousePos") == 0) { + Stack->CorrectParams(2); + int x = Stack->Pop()->GetInt(); + int y = Stack->Pop()->GetInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + POINT p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + CBPlatform::SetCursorPos(p.x, p.y); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LockMouseRect") == 0) { + Stack->CorrectParams(4); + int left = Stack->Pop()->GetInt(); + int top = Stack->Pop()->GetInt(); + int right = Stack->Pop()->GetInt(); + int bottom = Stack->Pop()->GetInt(); + + if (right < left) CBUtils::Swap(&left, &right); + if (bottom < top) CBUtils::Swap(&top, &bottom); + + CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayVideo") == 0) { +/* Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + // TODO: ADDVIDEO + */ + + Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + Stack->CorrectParams(6); + const char* Filename = Stack->Pop()->GetString(); + warning("PlayVideo: %s - not implemented yet", Filename); + CScValue* valType = Stack->Pop(); + int Type; + if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->GetInt(); + + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + bool FreezeMusic = Stack->Pop()->GetBool(true); + + CScValue* valSub = Stack->Pop(); + const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); + + if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + + /*if(SUCCEEDED(Game->m_VideoPlayer->Initialize(Filename, SubtitleFile))) + { + if(SUCCEEDED(Game->m_VideoPlayer->Play((TVideoPlayback)Type, X, Y, FreezeMusic))) + { + Stack->PushBool(true); + Script->Sleep(0); + } + else Stack->PushBool(false); + } + else */Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlayTheora") == 0) { + /* Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + // TODO: ADDVIDEO + */ + Stack->CorrectParams(7); + const char* Filename = Stack->Pop()->GetString(); + warning("PlayTheora: %s - not implemented yet", Filename); + CScValue* valType = Stack->Pop(); + int Type; + if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->GetInt(); + + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + bool FreezeMusic = Stack->Pop()->GetBool(true); + bool DropFrames = Stack->Pop()->GetBool(true); + + CScValue* valSub = Stack->Pop(); + const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); + + + if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + + /*SAFE_DELETE(m_TheoraPlayer); + m_TheoraPlayer = new CVidTheoraPlayer(this); + if(m_TheoraPlayer && SUCCEEDED(m_TheoraPlayer->Initialize(Filename, SubtitleFile))) + { + m_TheoraPlayer->m_DontDropFrames = !DropFrames; + if(SUCCEEDED(m_TheoraPlayer->Play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) + { + Stack->PushBool(true); + Script->Sleep(0); + } + else Stack->PushBool(false); + } + else */Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "QuitGame") == 0) { + Stack->CorrectParams(0); + Stack->PushNULL(); + _quitting = true; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegWriteNumber") == 0) { + Stack->CorrectParams(2); + const char *Key = Stack->Pop()->GetString(); + int Val = Stack->Pop()->GetInt(); + _registry->WriteInt("PrivateSettings", Key, Val); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegReadNumber") == 0) { + Stack->CorrectParams(2); + const char *Key = Stack->Pop()->GetString(); + int InitVal = Stack->Pop()->GetInt(); + Stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegWriteString") == 0) { + Stack->CorrectParams(2); + const char *Key = Stack->Pop()->GetString(); + const char *Val = Stack->Pop()->GetString(); + _registry->WriteString("PrivateSettings", Key, Val); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RegReadString") == 0) { + Stack->CorrectParams(2); + const char *Key = Stack->Pop()->GetString(); + const char *InitVal = Stack->Pop()->GetString(); + AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); + Stack->PushString((char *)val.c_str()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveGame") == 0) { + Stack->CorrectParams(3); + int Slot = Stack->Pop()->GetInt(); + const char *xdesc = Stack->Pop()->GetString(); + bool quick = Stack->Pop()->GetBool(false); + + char *Desc = new char[strlen(xdesc) + 1]; + strcpy(Desc, xdesc); + Stack->PushBool(true); + if (FAILED(SaveGame(Slot, Desc, quick))) { + Stack->Pop(); + Stack->PushBool(false); + } + delete [] Desc; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadGame") == 0) { + Stack->CorrectParams(1); + _scheduledLoadSlot = Stack->Pop()->GetInt(); + _loading = true; + Stack->PushBool(false); + Script->Sleep(0); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsSaveSlotUsed") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + Stack->PushBool(IsSaveSlotUsed(Slot)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSaveSlotDescription") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + char Desc[512]; + Desc[0] = '\0'; + GetSaveSlotDescription(Slot, Desc); + Stack->PushString(Desc); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmptySaveSlot") == 0) { + Stack->CorrectParams(1); + int Slot = Stack->Pop()->GetInt(); + EmptySaveSlot(Slot); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { + Stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { + Stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { + Stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { + Stack->CorrectParams(1); + Game->_soundMgr->setMasterVolumePercent((byte)Stack->Pop()->GetInt()); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_soundMgr->getMasterVolumePercent()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetActiveCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetActiveCursor") == 0) { + Stack->CorrectParams(0); + if (!_activeCursor || !_activeCursor->_filename) Stack->PushNULL(); + else Stack->PushString(_activeCursor->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetActiveCursorObject") == 0) { + Stack->CorrectParams(0); + if (!_activeCursor) Stack->PushNULL(); + else Stack->PushNative(_activeCursor, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveActiveCursor") == 0) { + Stack->CorrectParams(0); + delete _activeCursor; + _activeCursor = NULL; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasActiveCursor") == 0) { + Stack->CorrectParams(0); + + if (_activeCursor) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FileExists") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + + CBFile *File = _fileManager->OpenFile(Filename, false); + if (!File) Stack->PushBool(false); + else { + _fileManager->CloseFile(File); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0 || strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); + + _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(_fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0 || strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0) { + Stack->CorrectParams(5); + uint32 Duration = Stack->Pop()->GetInt(500); + byte Red = Stack->Pop()->GetInt(0); + byte Green = Stack->Pop()->GetInt(0); + byte Blue = Stack->Pop()->GetInt(0); + byte Alpha = Stack->Pop()->GetInt(0xFF); + + bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); + + _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); + if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(_fader); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFadeColor") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_fader->GetCurrentColor()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Screenshot") == 0) { + Stack->CorrectParams(1); + char Filename[MAX_PATH]; + + CScValue *Val = Stack->Pop(); + + int FileNum = 0; + while (true) { + sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); + FILE *f = fopen(Filename, "rb"); + if (!f) break; + else fclose(f); + FileNum++; + } + + bool ret = false; + CBImage *Image = Game->_renderer->TakeScreenshot(); + if (Image) { + ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + delete Image; + } else ret = false; + + Stack->PushBool(ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenshotEx") == 0) { + Stack->CorrectParams(3); + const char *Filename = Stack->Pop()->GetString(); + int SizeX = Stack->Pop()->GetInt(_renderer->_width); + int SizeY = Stack->Pop()->GetInt(_renderer->_height); + + bool ret = false; + CBImage *Image = Game->_renderer->TakeScreenshot(); + if (Image) { + ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); + if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + delete Image; + } else ret = false; + + Stack->PushBool(ret); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateWindow") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIWindow *Win = new CUIWindow(Game); + _windows.Add(Win); + RegisterObject(Win); + if (!Val->IsNULL()) Win->SetName(Val->GetString()); + Stack->PushNative(Win, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteWindow") == 0) { + Stack->CorrectParams(1); + CBObject *Obj = (CBObject *)Stack->Pop()->GetNative(); + for (int i = 0; i < _windows.GetSize(); i++) { + if (_windows[i] == Obj) { + UnregisterObject(_windows[i]); + Stack->PushBool(true); + return S_OK; + } + } + Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OpenDocument") == 0) { + Stack->CorrectParams(0); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DEBUG_DumpClassRegistry") == 0) { + Stack->CorrectParams(0); + DEBUG_DumpClassRegistry(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetLoadingScreen") == 0) { + Stack->CorrectParams(3); + CScValue *Val = Stack->Pop(); + _loadImageX = Stack->Pop()->GetInt(); + _loadImageY = Stack->Pop()->GetInt(); + + if (Val->IsNULL()) { + delete[] _loadImageName; + _loadImageName = NULL; + } else { + CBUtils::SetString(&_loadImageName, Val->GetString()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSavingScreen") == 0) { + Stack->CorrectParams(3); + CScValue *Val = Stack->Pop(); + _saveImageX = Stack->Pop()->GetInt(); + _saveImageY = Stack->Pop()->GetInt(); + + if (Val->IsNULL()) { + delete[] _saveImageName; + _saveImageName = NULL; + } else { + CBUtils::SetString(&_saveImageName, Val->GetString()); + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetWaitCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetWaitCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveWaitCursor") == 0) { + Stack->CorrectParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaitCursor") == 0) { + Stack->CorrectParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) Stack->PushNULL(); + else Stack->PushString(_cursorNoninteractive->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWaitCursorObject") == 0) { + Stack->CorrectParams(0); + if (!_cursorNoninteractive) Stack->PushNULL(); + else Stack->PushNative(_cursorNoninteractive, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClearScriptCache") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisplayLoadingIcon") == 0) { + Stack->CorrectParams(4); + + const char *Filename = Stack->Pop()->GetString(); + _loadingIconX = Stack->Pop()->GetInt(); + _loadingIconY = Stack->Pop()->GetInt(); + _loadingIconPersistent = Stack->Pop()->GetBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || FAILED(_loadingIcon->LoadFile(Filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + DisplayContent(false, true); + Game->_renderer->Flip(); + Game->_renderer->InitLoop(); + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HideLoadingIcon") == 0) { + Stack->CorrectParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DumpTextureStats") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + + _renderer->DumpData(Filename); + + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccOutputText") == 0) { + Stack->CorrectParams(2); + const char *Str = Stack->Pop()->GetString(); + int Type = Stack->Pop()->GetInt(); + // do nothing + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StoreSaveThumbnail") == 0) { + Stack->CorrectParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (FAILED(_cachedThumbnail->StoreThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteSaveThumbnail") == 0) { + Stack->CorrectParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFileChecksum") == 0) { + Stack->CorrectParams(2); + const char *Filename = Stack->Pop()->GetString(); + bool AsHex = Stack->Pop()->GetBool(false); + + CBFile *File = _fileManager->OpenFile(Filename, false); + if (File) { + crc remainder = crc_initialize(); + byte Buf[1024]; + int BytesRead = 0; + + while (BytesRead < File->GetSize()) { + int BufSize = MIN((uint32)1024, File->GetSize() - BytesRead); + BytesRead += BufSize; + + File->Read(Buf, BufSize); + for (int i = 0; i < BufSize; i++) { + remainder = crc_process_byte(Buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (AsHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + Stack->PushString(Hex); + } else + Stack->PushInt(checksum); + + _fileManager->CloseFile(File); + File = NULL; + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EnableScriptProfiling") == 0) { + Stack->CorrectParams(0); + _scEngine->EnableProfiling(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DisableScriptProfiling") == 0) { + Stack->CorrectParams(0); + _scEngine->DisableProfiling(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ShowStatusLine") == 0) { + Stack->CorrectParams(0); +#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HideStatusLine") == 0) { + Stack->CorrectParams(0); +#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif + Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Hwnd") == 0) { + _scValue->SetInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CurrentTime") == 0) { + _scValue->SetInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WindowsTime") == 0) { + _scValue->SetInt((int)CBPlatform::GetTime()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WindowedMode") == 0) { + _scValue->SetBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + _scValue->SetInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + _scValue->SetInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainObject") == 0) { + _scValue->SetNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ActiveObject") == 0) { + _scValue->SetNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenWidth") == 0) { + _scValue->SetInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScreenHeight") == 0) { + _scValue->SetInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Interactive") == 0) { + _scValue->SetBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DebugMode") == 0) { + _scValue->SetBool(_dEBUG_DebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundAvailable") == 0) { + _scValue->SetBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SFXVolume") == 0) { + Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SFX)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SpeechVolume") == 0) { + Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicVolume") == 0) { + Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MasterVolume") == 0) { + Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->SetInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Keyboard") == 0) { + if (_keyboardState) _scValue->SetNative(_keyboardState, true); + else _scValue->SetNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtitles") == 0) { + _scValue->SetBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesSpeed") == 0) { + _scValue->SetInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VideoSubtitles") == 0) { + _scValue->SetBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FPS") == 0) { + _scValue->SetInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AcceleratedMode") == 0 || strcmp(Name, "Accelerated") == 0) { + _scValue->SetBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextEncoding") == 0) { + _scValue->SetInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextRTL") == 0) { + _scValue->SetBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundBufferSize") == 0) { + _scValue->SetInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuspendedRendering") == 0) { + _scValue->SetBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuppressScriptErrors") == 0) { + _scValue->SetBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Frozen") == 0) { + _scValue->SetBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSEnabled") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSTalk") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSCaptions") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccTTSKeypress") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardEnabled") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardCursorSkip") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccKeyboardPause") == 0) { + _scValue->SetBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutorunDisabled") == 0) { + _scValue->SetBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveDirectory") == 0) { + AnsiString dataDir = GetDataDir(); + _scValue->SetString((char *)dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveOnExit") == 0) { + _scValue->SetBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveSlot") == 0) { + _scValue->SetInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorHidden") == 0) { + _scValue->SetBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Platform") == 0) { + _scValue->SetString(CBPlatform::GetPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeviceType") == 0) { + _scValue->SetString(GetDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MostRecentSaveSlot") == 0) { + _scValue->SetInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Store") == 0) { + if (_store) _scValue->SetNative(_store, true); + else _scValue->SetNULL(); + + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseX") == 0) { + _mousePos.x = Value->GetInt(); + ResetMousePos(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MouseY") == 0) { + _mousePos.y = Value->GetInt(); + ResetMousePos(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + HRESULT res = CBObject::ScSetProperty(Name, Value); + SetWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MainObject") == 0) { + CBScriptable *obj = Value->GetNative(); + if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Interactive") == 0) { + SetInteractive(Value->GetBool()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SFXVolume") == 0) { + Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SpeechVolume") == 0) { + Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MusicVolume") == 0) { + Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MasterVolume") == 0) { + Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + Game->_soundMgr->setMasterVolumePercent((byte)Value->GetInt()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Subtitles") == 0) { + _subtitles = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VideoSubtitles") == 0) { + _videoSubtitles = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextEncoding") == 0) { + int Enc = Value->GetInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + _textEncoding = (TTextEncoding)Enc; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextRTL") == 0) { + _textRTL = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = Value->GetInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuspendedRendering") == 0) { + _suspendedRendering = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutorunDisabled") == 0) { + _autorunDisabled = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AutoSaveSlot") == 0) { + _autoSaveSlot = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorHidden") == 0) { + _cursorHidden = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBGame::ScToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayQuickMsg() { + if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; + + int i; + + // update + for (i = 0; i < _quickMessages.GetSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.RemoveAt(i); + i--; + } + } + + int PosY = 20; + + // display + for (i = 0; i < _quickMessages.GetSize(); i++) { + _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); + PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); + } + return S_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::QuickMessage(const char *Text) { + if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.RemoveAt(0); + } + _quickMessages.Add(new CBQuickMsg(Game, Text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::QuickMessageForm(LPSTR fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::RegisterObject(CBObject *Object) { + _regObjects.Add(Object); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::UnregisterObject(CBObject *Object) { + if (!Object) return S_OK; + + int i; + + // is it a window? + for (i = 0; i < _windows.GetSize(); i++) { + if ((CBObject *)_windows[i] == Object) { + _windows.RemoveAt(i); + + // get new focused window + if (_focusedWindow == Object) _focusedWindow = NULL; + + break; + } + } + + // is it active object? + if (_activeObject == Object) _activeObject = NULL; + + // is it main object? + if (_mainObject == Object) _mainObject = NULL; + + if (_store) _store->OnObjectDestroyed(Object); + + // destroy object + for (i = 0; i < _regObjects.GetSize(); i++) { + if (_regObjects[i] == Object) { + _regObjects.RemoveAt(i); + if (!_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); + delete Object; + return S_OK; + } + } + + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::InvalidateValues(void *Value, void *Data) { + CScValue *val = (CScValue *)Value; + if (val->IsNative() && val->GetNative() == Data) { + if (!val->_persistent && ((CBScriptable *)Data)->_refCount == 1) { + ((CBScriptable *)Data)->_refCount++; + } + val->SetNative(NULL); + val->SetNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ValidObject(CBObject *Object) { + if (!Object) return false; + if (Object == this) return true; + + for (int i = 0; i < _regObjects.GetSize(); i++) { + if (_regObjects[i] == Object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::PublishNatives() { + if (!_scEngine || !_scEngine->_compilerAvailable) return; + + _scEngine->ExtDefineFunction("LOG"); + _scEngine->ExtDefineFunction("String"); + _scEngine->ExtDefineFunction("MemBuffer"); + _scEngine->ExtDefineFunction("File"); + _scEngine->ExtDefineFunction("Date"); + _scEngine->ExtDefineFunction("Array"); + _scEngine->ExtDefineFunction("TcpClient"); + _scEngine->ExtDefineFunction("Object"); + //_scEngine->ExtDefineFunction("Game"); + _scEngine->ExtDefineFunction("Sleep"); + _scEngine->ExtDefineFunction("WaitFor"); + _scEngine->ExtDefineFunction("Random"); + _scEngine->ExtDefineFunction("SetScriptTimeSlice"); + _scEngine->ExtDefineFunction("MakeRGBA"); + _scEngine->ExtDefineFunction("MakeRGB"); + _scEngine->ExtDefineFunction("MakeHSL"); + _scEngine->ExtDefineFunction("RGB"); + _scEngine->ExtDefineFunction("GetRValue"); + _scEngine->ExtDefineFunction("GetGValue"); + _scEngine->ExtDefineFunction("GetBValue"); + _scEngine->ExtDefineFunction("GetAValue"); + _scEngine->ExtDefineFunction("GetHValue"); + _scEngine->ExtDefineFunction("GetSValue"); + _scEngine->ExtDefineFunction("GetLValue"); + _scEngine->ExtDefineFunction("Debug"); + + _scEngine->ExtDefineFunction("ToString"); + _scEngine->ExtDefineFunction("ToInt"); + _scEngine->ExtDefineFunction("ToBool"); + _scEngine->ExtDefineFunction("ToFloat"); + + _scEngine->ExtDefineVariable("Game"); + _scEngine->ExtDefineVariable("Math"); + _scEngine->ExtDefineVariable("Directory"); + _scEngine->ExtDefineVariable("self"); + _scEngine->ExtDefineVariable("this"); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "LOG") == 0) { + Stack->CorrectParams(1); + Game->LOG(0, "sc: %s", Stack->Pop()->GetString()); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "String") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXString(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MemBuffer") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXMemBuffer(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "File") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXFile(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Date") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXDate(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Array") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXArray(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Object") == 0) { + this_obj = ThisStack->GetTop(); + + this_obj->SetNative(new CSXObject(Game, Stack)); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sleep") == 0) { + Stack->CorrectParams(1); + + Script->Sleep((uint32)Stack->Pop()->GetInt()); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WaitFor") == 0) { + Stack->CorrectParams(1); + + CBScriptable *obj = Stack->Pop()->GetNative(); + if (ValidObject((CBObject *)obj)) Script->WaitForExclusive((CBObject *)obj); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Random") == 0) { + Stack->CorrectParams(2); + + int from = Stack->Pop()->GetInt(); + int to = Stack->Pop()->GetInt(); + + Stack->PushInt(CBUtils::RandomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetScriptTimeSlice") == 0) { + Stack->CorrectParams(1); + + Script->_timeSlice = (uint32)Stack->Pop()->GetInt(); + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MakeRGBA") == 0 || strcmp(Name, "MakeRGB") == 0 || strcmp(Name, "RGB") == 0) { + Stack->CorrectParams(4); + int r = Stack->Pop()->GetInt(); + int g = Stack->Pop()->GetInt(); + int b = Stack->Pop()->GetInt(); + int a; + CScValue *val = Stack->Pop(); + if (val->IsNULL()) a = 255; + else a = val->GetInt(); + + Stack->PushInt(DRGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MakeHSL") == 0) { + Stack->CorrectParams(3); + int h = Stack->Pop()->GetInt(); + int s = Stack->Pop()->GetInt(); + int l = Stack->Pop()->GetInt(); + + Stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetRValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetGValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetBValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetAValue") == 0) { + Stack->CorrectParams(1); + + uint32 rgba = (uint32)Stack->Pop()->GetInt(); + Stack->PushInt(D3DCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetLValue") == 0) { + Stack->CorrectParams(1); + uint32 rgb = (uint32)Stack->Pop()->GetInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + Stack->PushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Debug") == 0) { + Stack->CorrectParams(0); + + if (Game->GetDebugMgr()->_enabled) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(Script); + Script->Sleep(0); + } + Stack->PushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToString") == 0) { + Stack->CorrectParams(1); + const char *Str = Stack->Pop()->GetString(); + char *Str2 = new char[strlen(Str) + 1]; + strcpy(Str2, Str); + Stack->PushString(Str2); + delete [] Str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToInt") == 0) { + Stack->CorrectParams(1); + int Val = Stack->Pop()->GetInt(); + Stack->PushInt(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToFloat") == 0) { + Stack->CorrectParams(1); + double Val = Stack->Pop()->GetFloat(); + Stack->PushFloat(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToBool") == 0) { + Stack->CorrectParams(1); + bool Val = Stack->Pop()->GetBool(); + Stack->PushBool(Val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + Script->RuntimeError("Call to undefined function '%s'. Ignored.", Name); + Stack->CorrectParams(0); + Stack->PushNULL(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ShowCursor() { + if (_cursorHidden) return S_OK; + + if (!_interactive && Game->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return DrawCursor(_cursorNoninteractive); + } else { + if (_activeObject && !FAILED(_activeObject->ShowCursor())) return S_OK; + else { + if (_activeObject && _activeCursor && _activeObject->GetExtendedFlag("usable")) return DrawCursor(_activeCursor); + else if (_cursor) return DrawCursor(_cursor); + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(slot, Filename); + + LOG(0, "Saving game '%s'...", Filename); + + Game->ApplyEvent("BeforeSave", true); + + HRESULT ret; + + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(Game); + if (FAILED(ret = pm->InitSave(desc))) goto save_finish; + + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = new CBSurfaceSDL(this); + + if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } + + if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveTable(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = pm->SaveFile(Filename))) goto save_finish; + + _registry->WriteInt("System", "MostRecentSaveSlot", slot); + +save_finish: + delete pm; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadGame(int Slot) { + //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + return LoadGame(Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadGame(const char *Filename) { + LOG(0, "Loading game '%s'...", Filename); + GetDebugMgr()->OnGameShutdown(); + + HRESULT ret; + + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = new CBSurfaceSDL(this); + + if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + + + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(Game); + _dEBUG_AbsolutePathWarning = false; + if (FAILED(ret = pm->InitLoad(Filename))) goto load_finish; + + //if(FAILED(ret = Cleanup())) goto load_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; + if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadInstances(Game, pm))) goto load_finish; + + // data initialization after load + InitAfterLoad(); + + Game->ApplyEvent("AfterLoad", true); + + DisplayContent(true, false); + //_renderer->Flip(); + + GetDebugMgr()->OnGameInit(); + +load_finish: + _dEBUG_AbsolutePathWarning = true; + + _indicatorDisplay = false; + delete pm; + _loadInProgress = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InitAfterLoad() { + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSound, "CBSound", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); + + _scEngine->RefreshScriptBreakpoints(); + if (_store) _store->AfterLoad(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadRegion(void *Region, void *Data) { + ((CBRegion *)Region)->CreateRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { + ((CBSubFrame *)Subframe)->SetSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadSound(void *Sound, void *Data) { + ((CBSound *)Sound)->SetSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadFont(void *Font, void *Data) { + ((CBFontTT *)Font)->AfterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AfterLoadScript(void *script, void *data) { + ((CScScript *)script)->AfterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayWindows(bool InGame) { + HRESULT res; + + int i; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (i = _windows.GetSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (i = 0; i < _windows.GetSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == InGame) { + + res = _windows[i]->Display(); + if (FAILED(res)) return res; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PlayMusic(int Channel, const char *Filename, bool Looping, uint32 LoopStart) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + delete _music[Channel]; + _music[Channel] = NULL; + + _music[Channel] = new CBSound(Game); + if (_music[Channel] && SUCCEEDED(_music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { + if (_musicStartTime[Channel]) { + _music[Channel]->SetPositionTime(_musicStartTime[Channel]); + _musicStartTime[Channel] = 0; + } + if (LoopStart) _music[Channel]->SetLoopStart(LoopStart); + return _music[Channel]->Play(Looping); + } else { + delete _music[Channel]; + _music[Channel] = NULL; + return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::StopMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (_music[Channel]) { + _music[Channel]->Stop(); + delete _music[Channel]; + _music[Channel] = NULL; + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PauseMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (_music[Channel]) return _music[Channel]->Pause(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ResumeMusic(int Channel) { + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + if (_music[Channel]) return _music[Channel]->Resume(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { + + if (Channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + return E_FAIL; + } + + _musicStartTime[Channel] = Time; + if (_music[Channel] && _music[Channel]->IsPlaying()) return _music[Channel]->SetPositionTime(Time); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::LoadSettings(const char *Filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *OrigBuffer = Game->_fileManager->ReadWholeFile(Filename); + if (OrigBuffer == NULL) { + Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret = S_OK; + + byte *Buffer = OrigBuffer; + byte *params; + int cmd; + CBParser parser(Game); + + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return E_FAIL; + } + Buffer = params; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (FAILED(_stringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.ScanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.ScanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.ScanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.ScanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.ScanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.ScanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.ScanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.ScanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.ScanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + _registry->SetBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.ScanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::SetString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in game settings '%s'", Filename); + ret = E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading game settings '%s'", Filename); + ret = E_FAIL; + } + + _settingsAllowWindowed = _registry->ReadBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->ReadBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; + + delete [] OrigBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->_saving) Cleanup(); + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_activeObject)); + PersistMgr->Transfer(TMEMBER(_capturedObject)); + PersistMgr->Transfer(TMEMBER(_cursorNoninteractive)); + PersistMgr->Transfer(TMEMBER(_doNotExpandStrings)); + PersistMgr->Transfer(TMEMBER(_editorMode)); + PersistMgr->Transfer(TMEMBER(_fader)); + PersistMgr->Transfer(TMEMBER(_freezeLevel)); + PersistMgr->Transfer(TMEMBER(_focusedWindow)); + PersistMgr->Transfer(TMEMBER(_fontStorage)); + PersistMgr->Transfer(TMEMBER(_interactive)); + PersistMgr->Transfer(TMEMBER(_keyboardState)); + PersistMgr->Transfer(TMEMBER(_lastTime)); + PersistMgr->Transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + PersistMgr->Transfer(TMEMBER(_music[i])); + PersistMgr->Transfer(TMEMBER(_musicStartTime[i])); + } + + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_offsetPercentX)); + PersistMgr->Transfer(TMEMBER(_offsetPercentY)); + + PersistMgr->Transfer(TMEMBER(_origInteractive)); + PersistMgr->Transfer(TMEMBER_INT(_origState)); + PersistMgr->Transfer(TMEMBER(_personalizedSave)); + PersistMgr->Transfer(TMEMBER(_quitting)); + + _regObjects.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_scEngine)); + //PersistMgr->Transfer(TMEMBER(_soundMgr)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + //PersistMgr->Transfer(TMEMBER(_surfaceStorage)); + PersistMgr->Transfer(TMEMBER(_subtitles)); + PersistMgr->Transfer(TMEMBER(_subtitlesSpeed)); + PersistMgr->Transfer(TMEMBER(_systemFont)); + PersistMgr->Transfer(TMEMBER(_videoFont)); + PersistMgr->Transfer(TMEMBER(_videoSubtitles)); + + PersistMgr->Transfer(TMEMBER(_timer)); + PersistMgr->Transfer(TMEMBER(_timerDelta)); + PersistMgr->Transfer(TMEMBER(_timerLast)); + + PersistMgr->Transfer(TMEMBER(_liveTimer)); + PersistMgr->Transfer(TMEMBER(_liveTimerDelta)); + PersistMgr->Transfer(TMEMBER(_liveTimerLast)); + + PersistMgr->Transfer(TMEMBER(_musicCrossfadeRunning)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeStartTime)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeLength)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel1)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel2)); + PersistMgr->Transfer(TMEMBER(_musicCrossfadeSwap)); + + PersistMgr->Transfer(TMEMBER(_loadImageName)); + PersistMgr->Transfer(TMEMBER(_saveImageName)); + PersistMgr->Transfer(TMEMBER(_saveImageX)); + PersistMgr->Transfer(TMEMBER(_saveImageY)); + PersistMgr->Transfer(TMEMBER(_loadImageX)); + PersistMgr->Transfer(TMEMBER(_loadImageY)); + + PersistMgr->Transfer(TMEMBER_INT(_textEncoding)); + PersistMgr->Transfer(TMEMBER(_textRTL)); + + PersistMgr->Transfer(TMEMBER(_soundBufferSizeSec)); + PersistMgr->Transfer(TMEMBER(_suspendedRendering)); + + PersistMgr->Transfer(TMEMBER(_mouseLockRect)); + + _windows.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_suppressScriptErrors)); + PersistMgr->Transfer(TMEMBER(_autorunDisabled)); + + PersistMgr->Transfer(TMEMBER(_autoSaveOnExit)); + PersistMgr->Transfer(TMEMBER(_autoSaveSlot)); + PersistMgr->Transfer(TMEMBER(_cursorHidden)); + + if (PersistMgr->CheckVersion(1, 0, 1)) + PersistMgr->Transfer(TMEMBER(_store)); + else + _store = NULL; + + if (!PersistMgr->_saving) _quitting = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::FocusWindow(CUIWindow *Window) { + CUIWindow *Prev = _focusedWindow; + + int i; + for (i = 0; i < _windows.GetSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.GetSize() - 1) { + _windows.RemoveAt(i); + _windows.Add(Window); + + Game->_focusedWindow = Window; + } + + if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + return FocusWindow(Prev); + else return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Freeze(bool IncludingMusic) { + if (_freezeLevel == 0) { + _scEngine->PauseAll(); + _soundMgr->pauseAll(IncludingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::Unfreeze() { + if (_freezeLevel == 0) return S_OK; + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->ResumeAll(); + _soundMgr->resumeAll(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::HandleKeypress(Common::Event *event) { +#ifdef __WIN32__ + // TODO: Do we really need to handle this in-engine? + // handle Alt+F4 on windows + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) { + OnWindowClose(); + return true; + //TODO + } +#endif + + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. + _renderer->SwitchFullscreen(); + return true; + } + + + + _keyboardState->ReadKey(event); +// TODO +#if 0 + if (_focusedWindow) { + if (!Game->_focusedWindow->HandleKeypress(event)) { + if (event->type != SDL_TEXTINPUT) { + if (Game->_focusedWindow->CanHandleEvent("Keypress")) + Game->_focusedWindow->ApplyEvent("Keypress"); + else + ApplyEvent("Keypress"); + } + } + return true; + } else if (event->type != SDL_TEXTINPUT) { + ApplyEvent("Keypress"); + return true; + } else return true; +#endif + return false; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::HandleMouseWheel(int Delta) { + bool Handled = false; + if (_focusedWindow) { + Handled = Game->_focusedWindow->HandleMouseWheel(Delta); + + if (!Handled) { + if (Delta < 0 && Game->_focusedWindow->CanHandleEvent("MouseWheelDown")) { + Game->_focusedWindow->ApplyEvent("MouseWheelDown"); + Handled = true; + } else if (Game->_focusedWindow->CanHandleEvent("MouseWheelUp")) { + Game->_focusedWindow->ApplyEvent("MouseWheelUp"); + Handled = true; + } + + } + } + + if (!Handled) { + if (Delta < 0) { + ApplyEvent("MouseWheelDown"); + } else { + ApplyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { + if (VerMajor) *VerMajor = DCGF_VER_MAJOR; + if (VerMinor) *VerMinor = DCGF_VER_MINOR; + + if (ExtMajor) *ExtMajor = 0; + if (ExtMinor) *ExtMinor = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetWindowTitle() { + if (_renderer) { + char Title[512]; + strcpy(Title, _caption[0]); + if (Title[0] != '\0') strcat(Title, " - "); + strcat(Title, "WME Lite"); + + + Utf8String title; + if (_textEncoding == TEXT_UTF8) { + title = Utf8String(Title); + } else { + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + title = Utf8String(Title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } +#if 0 + CBRenderSDL *renderer = static_cast(_renderer); + // TODO + + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { + AnsiString dataDir = GetDataDir(); + sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::GetDataDir() { + AnsiString userDir = PathUtil::GetUserDirectory(); +#ifdef __IPHONEOS__ + return userDir; +#else + AnsiString baseDir = _registry->GetBasePath(); + return PathUtil::Combine(userDir, baseDir); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { + Buffer[0] = '\0'; + + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + CBPersistMgr *pm = new CBPersistMgr(Game); + if (!pm) return E_FAIL; + + _dEBUG_AbsolutePathWarning = false; + if (FAILED(pm->InitLoad(Filename))) { + _dEBUG_AbsolutePathWarning = true; + delete pm; + return E_FAIL; + } + + _dEBUG_AbsolutePathWarning = true; + strcpy(Buffer, pm->_savedDescription); + delete pm; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsSaveSlotUsed(int Slot) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + CBFile *File = _fileManager->OpenFile(Filename, false); + if (!File) return false; + + _fileManager->CloseFile(File); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::EmptySaveSlot(int Slot) { + char Filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, Filename); + + CBPlatform::DeleteFile(Filename); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetActiveObject(CBObject *Obj) { + // not-active when game is frozen + if (Obj && !Game->_interactive && !Obj->_nonIntMouseEvents) { + Obj = NULL; + } + + if (Obj == _activeObject) return S_OK; + + if (_activeObject) _activeObject->ApplyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->ApplyEvent("MouseLeave"); + _activeObject = Obj; + if (_activeObject) { + _activeObject->ApplyEvent("MouseEntry"); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PushViewport(CBViewport *Viewport) { + _viewportSP++; + if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); + else _viewportStack[_viewportSP] = Viewport; + + _renderer->SetViewport(Viewport->GetRect()); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::PopViewport() { + _viewportSP--; + if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); + + if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->GetRect()); + else _renderer->SetViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { + if (Rect == NULL) return E_FAIL; + else { + if (_viewportSP >= 0) { + CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->GetRect()); + if (Custom) *Custom = true; + } else { + CBPlatform::SetRect(Rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (Custom) *Custom = false; + } + + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { + if (_viewportSP >= 0) { + if (OffsetX) *OffsetX = _viewportStack[_viewportSP]->_offsetX; + if (OffsetY) *OffsetY = _viewportStack[_viewportSP]->_offsetY; + } else { + if (OffsetX) *OffsetX = 0; + if (OffsetY) *OffsetY = 0; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetInteractive(bool State) { + _interactive = State; + if (_transMgr) _transMgr->_origInteractive = State; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::ResetMousePos() { + POINT p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + CBPlatform::SetCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::SetResourceModule(HMODULE ResModule) { + _resourceModule = ResModule; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayContent(bool Update, bool DisplayAll) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayContentSimple() { + // fill black + _renderer->Fill(0, 0, 0); + if (_indicatorDisplay) DisplayIndicator(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayIndicator() { + if (_saveLoadImage) { + RECT rc; + CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->GetWidth(), _saveLoadImage->GetHeight()); + if (_loadInProgress) _saveLoadImage->DisplayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->DisplayTrans(_saveImageX, _saveImageY, rc); + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; + _renderer->SetupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->DrawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + + _renderer->Setup2D(); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::UpdateMusicCrossfade() { + byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); + + if (!_musicCrossfadeRunning) return S_OK; + if (_state == GAME_FROZEN) return S_OK; + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return S_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return S_OK; + } + + if (!_music[_musicCrossfadeChannel1]->IsPlaying()) _music[_musicCrossfadeChannel1]->Play(); + if (!_music[_musicCrossfadeChannel2]->IsPlaying()) _music[_musicCrossfadeChannel2]->Play(); + + uint32 CurrentTime = Game->_liveTimer - _musicCrossfadeStartTime; + + if (CurrentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->SetVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->SetVolume(100); + + _music[_musicCrossfadeChannel1]->Stop(); + //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->SetVolume(100); + + + if (_musicCrossfadeSwap) { + // swap channels + CBSound *Dummy = _music[_musicCrossfadeChannel1]; + int DummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = Dummy; + _musicStartTime[_musicCrossfadeChannel2] = DummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); + + //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::ResetContent() { + _scEngine->ClearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + FILE *f = fopen("./zz_class_reg_dump.log", "wt"); + + CSysClassRegistry::GetInstance()->DumpClasses(f); + + fclose(f); + Game->QuickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::InvalidateDeviceObjects() { + for (int i = 0; i < _regObjects.GetSize(); i++) { + _regObjects[i]->InvalidateDeviceObjects(); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::RestoreDeviceObjects() { + for (int i = 0; i < _regObjects.GetSize(); i++) { + _regObjects[i]->RestoreDeviceObjects(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::SetWaitCursor(const char *Filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new CBSprite(Game); + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile(Filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DrawCursor(CBSprite *Cursor) { + if (!Cursor) return E_FAIL; + if (Cursor != _lastCursor) { + Cursor->Reset(); + _lastCursor = Cursor; + } + return Cursor->Draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { + if (_shuttingDown || !_renderer) return S_OK; + + _renderer->_active = Activate; + + if (RefreshMouse) { + POINT p; + GetMousePos(&p); + SetActiveObject(_renderer->GetObjectAt(p.x, p.y)); + } + + if (Activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftDown() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::SetCapture(_renderer->_window); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftUp() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::ReleaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return S_OK; + + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("LeftDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return S_OK; + + if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightDoubleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightDown() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseRightUp() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("RightRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return S_OK; + + if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("MiddleClick"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnMouseMiddleUp() { + if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); + if (!Handled) { + if (_activeObject != NULL) { + _activeObject->ApplyEvent("MiddleRelease"); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->InitLoop(); + DisplayContent(false, true); + DisplayDebugInfo(); + _renderer->WindowedBlt(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnWindowClose() { + if (CanHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) Game->ApplyEvent("QuitGame"); + return S_OK; + } else return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::DisplayDebugInfo() { + char str[100]; + + if (_dEBUG_ShowFPS) { + sprintf(str, "FPS: %d", Game->_fps); + _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (Game->_dEBUG_DebugMode) { + if (!Game->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + else + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + + strcat(str, " ("); + strcat(str, _renderer->GetName()); + strcat(str, ")"); + _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->DisplayDebugInfo(); + + int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; + ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); + _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::GetDebugMgr() { + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::GetMousePos(POINT *Pos) { + CBPlatform::GetCursorPos(Pos); + + Pos->x -= _renderer->_drawOffsetX; + Pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if(_renderer->_windowed && ::IsZoomed(_renderer->_window)) + { + RECT rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= Game->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= Game->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::PtInRect(&_mouseLockRect, *Pos)) { + Pos->x = MAX(_mouseLockRect.left, Pos->x); + Pos->y = MAX(_mouseLockRect.top, Pos->y); + + Pos->x = MIN(_mouseLockRect.right, Pos->x); + Pos->y = MIN(_mouseLockRect.bottom, Pos->y); + + POINT NewPos = *Pos; + + NewPos.x += _renderer->_drawOffsetX; + NewPos.y += _renderer->_drawOffsetY; + + CBPlatform::SetCursorPos(NewPos.x, NewPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::MiniUpdate() { + if (!_miniUpdateEnabled) return S_OK; + + if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->initLoop(); + _lastMiniUpdate = CBPlatform::GetTime(); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::OnScriptShutdown(CScScript *Script) { + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsLeftDoubleClick() { + return IsDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsRightDoubleClick() { + return IsDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + +#if __IPHONEOS__ + maxMoveX = 16; + maxMoveY = 16; +#endif + + POINT pos; + CBPlatform::GetCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); + int moveY = abs(pos.y - _lastClick[buttonIndex].PosY); + + + if (_lastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].Time = CBPlatform::GetTime(); + _lastClick[buttonIndex].PosX = pos.x; + _lastClick[buttonIndex].PosY = pos.y; + return false; + } else { + _lastClick[buttonIndex].Time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AutoSaveOnExit() { + _soundMgr->saveSettings(); + _registry->SaveValues(); + + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; + + SaveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::AddMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::GetDeviceType() const { +#ifdef __IPHONEOS__ + char devType[128]; + IOS_GetDeviceType(devType); + return AnsiString(devType); +#else + return "computer"; +#endif +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h new file mode 100644 index 0000000000..ac8138855f --- /dev/null +++ b/engines/wintermute/Base/BGame.h @@ -0,0 +1,386 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +#include "engines/wintermute/Base/BDebugger.h" +//#include "engines/wintermute/Base/BSaveThumbHelper.h" +//#include "engines/wintermute/Base/BFader.h" +#include "engines/wintermute/Base/BRenderer.h" +//#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "common/events.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, HRESULT Result, void *Data); + +class CBSoundMgr; +class CBFader; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRenderer; +class CBRegistry; +class CBSaveThumbHelper; +class CBSurfaceStorage; +class CSXStore; +class CSXMath; +class CBKeyboardState; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) + + virtual HRESULT OnScriptShutdown(CScScript *Script); + + virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); + virtual HRESULT OnMouseLeftDown(); + virtual HRESULT OnMouseLeftUp(); + virtual HRESULT OnMouseLeftDblClick(); + virtual HRESULT OnMouseRightDblClick(); + virtual HRESULT OnMouseRightDown(); + virtual HRESULT OnMouseRightUp(); + virtual HRESULT OnMouseMiddleDown(); + virtual HRESULT OnMouseMiddleUp(); + virtual HRESULT OnPaint(); + virtual HRESULT OnWindowClose(); + + bool IsLeftDoubleClick(); + bool IsRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual HRESULT MiniUpdate(); + + void GetMousePos(POINT *Pos); + RECT _mouseLockRect; + + bool _shuttingDown; + + virtual HRESULT DisplayDebugInfo(); + bool _dEBUG_ShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + virtual HRESULT ResetContent(); + + void DEBUG_DumpClassRegistry(); + HRESULT SetWaitCursor(const char *Filename); + char *_localSaveDir; + bool _saveDirChecked; + + + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorProgress; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + CBSurface *_saveLoadImage; + + HRESULT DisplayIndicator(); + + int _thumbnailWidth; + int _thumbnailHeight; + + bool _reportTextureFormat; + HMODULE _resourceModule; + void SetResourceModule(HMODULE ResModule); + + void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; + + bool _doNotExpandStrings; + void GetOffset(int *OffsetX, int *OffsetY); + void SetOffset(int OffsetX, int OffsetY); + int GetSequence(); + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; + + HRESULT InitInput(HINSTANCE hInst, HWND hWnd); + HRESULT InitLoop(); + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; + HRESULT Initialize1(); + HRESULT Initialize2(); + HRESULT Initialize3(); + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; + CBDebugger *GetDebugMgr(); + + void LOG(HRESULT res, LPCSTR fmt, ...); + + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CSXStore *_store; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; + CBGame(); + + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *Filename = NULL); + bool _dEBUG_DebugMode; + bool _dEBUG_AbsolutePathWarning; + + void *_dEBUG_LogFile; + int _sequence; + virtual HRESULT LoadFile(const char *Filename); + virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + bool _mouseLeftDown; + bool _mouseRightDown; + bool _mouseMidlleDown; + CBStringTable *_stringTable; + + int _settingsResWidth; + int _settingsResHeight; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + char *_settingsGameFile; + CBFader *_fader; + bool _suppressScriptErrors; + + virtual HRESULT InvalidateDeviceObjects(); + virtual HRESULT RestoreDeviceObjects(); + + virtual void PublishNatives(); + virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + // compatibility bits + bool _compatKillMethodThreads; + +private: + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + +public: + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; + HRESULT EmptySaveSlot(int Slot); + bool IsSaveSlotUsed(int Slot); + HRESULT GetSaveSlotDescription(int Slot, char *Buffer); + HRESULT GetSaveSlotFilename(int Slot, char *Buffer); + void SetWindowTitle(); + virtual bool HandleMouseWheel(int Delta); + bool _quitting; + virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); + + virtual bool HandleKeypress(Common::Event *event); + int _freezeLevel; + HRESULT Unfreeze(); + HRESULT Freeze(bool IncludingMusic = true); + HRESULT FocusWindow(CUIWindow *Window); +/* CVidPlayer* _videoPlayer; + CVidTheoraPlayer* _theoraPlayer;*/ + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; + static void AfterLoadRegion(void *Region, void *Data); + static void AfterLoadSubFrame(void *Subframe, void *Data); + static void AfterLoadSound(void *Sound, void *Data); + static void AfterLoadFont(void *Font, void *Data); + static void AfterLoadScript(void *script, void *data); + static void InvalidateValues(void *Value, void *Data); + + HRESULT LoadSettings(const char *Filename); + HRESULT ResumeMusic(int Channel); + HRESULT SetMusicStartTime(int Channel, uint32 Time); + HRESULT PauseMusic(int Channel); + HRESULT StopMusic(int Channel); + HRESULT PlayMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + HRESULT DisplayWindows(bool InGame = false); + CBRegistry *_registry; + bool _useD3D; + virtual HRESULT Cleanup(); + virtual HRESULT LoadGame(int Slot); + virtual HRESULT LoadGame(const char *Filename); + virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); + virtual HRESULT ShowCursor(); + + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + POINT _mousePos; + bool ValidObject(CBObject *Object); + HRESULT UnregisterObject(CBObject *Object); + HRESULT RegisterObject(CBObject *Object); + void QuickMessage(const char *Text); + void QuickMessageForm(LPSTR fmt, ...); + HRESULT DisplayQuickMsg(); + uint32 _fps; + HRESULT UpdateMusicCrossfade(); + + CBArray _regObjects; +public: + virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); + virtual HRESULT DisplayContentSimple(); + bool _forceNonStreamedSounds; + void ResetMousePos(); + int _subtitlesSpeed; + void SetInteractive(bool State); + virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); + HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); + HRESULT PopViewport(); + HRESULT PushViewport(CBViewport *Viewport); + HRESULT SetActiveObject(CBObject *Obj); + CBSprite *_lastCursor; + HRESULT DrawCursor(CBSprite *Cursor); + + virtual HRESULT InitAfterLoad(); + CBSaveThumbHelper *_cachedThumbnail; + AnsiString GetDataDir(); + void AddMem(int bytes); + + bool _touchInterface; + bool _constrainedMemory; + AnsiString GetDeviceType() const; + +private: + CBDebugger *_debugMgr; + + struct LastClickInfo { + LastClickInfo() { + PosX = PosY = 0; + Time = 0; + } + + int PosX; + int PosY; + uint32 Time; + }; + + LastClickInfo _lastClick[2]; + bool IsDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void AutoSaveOnExit(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp new file mode 100644 index 0000000000..7561e65adc --- /dev/null +++ b/engines/wintermute/Base/BImage.cpp @@ -0,0 +1,121 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BImage.h" +//#include "FreeImage.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +#if 0 + _bitmap = bitmap; +#endif + _bitmap = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBImage::~CBImage() { +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::SaveBMPFile(const char *Filename) { +#if 0 + if (!_bitmap) return E_FAIL; + + if (FreeImage_Save(FIF_BMP, _bitmap, Filename)) return S_OK; + else return E_FAIL; +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::Resize(int NewWidth, int NewHeight) { +#if 0 + if (!_bitmap) return E_FAIL; + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + + + FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + if (newImg) { + FreeImage_Unload(_bitmap); + _bitmap = newImg; + return S_OK; + } else return E_FAIL; +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { + if (!_bitmap) return NULL; +#if 0 + FIMEMORY *fiMem = FreeImage_OpenMemory(); + FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); + uint32 size; + byte *data; + FreeImage_AcquireMemory(fiMem, &data, &size); + + + byte *Buffer = new byte[size]; + memcpy(Buffer, data, size); + + FreeImage_CloseMemory(fiMem); + + if (BufferSize) *BufferSize = size; + + return Buffer; +#endif + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + + _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); +#endif + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h new file mode 100644 index 0000000000..cabc155723 --- /dev/null +++ b/engines/wintermute/Base/BImage.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BIMAGE_H +#define WINTERMUTE_BIMAGE_H + + +//#include "FreeImage.h" +#include "engines/wintermute/Base/BBase.h" +#include "common/endian.h" + +struct FIBITMAP; + +namespace WinterMute { + +class CBImage: CBBase { + +public: + CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); + ~CBImage(); + + + byte *CreateBMPBuffer(uint32 *BufferSize = NULL); + HRESULT Resize(int NewWidth, int NewHeight); + HRESULT SaveBMPFile(const char *Filename); + HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); + + FIBITMAP *GetBitmap() const { + return _bitmap; + } +private: + FIBITMAP *_bitmap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp new file mode 100644 index 0000000000..b81803e0ce --- /dev/null +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -0,0 +1,247 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "IsKeyDown") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { + const char *str = val->GetString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; + } else vKey = val->GetInt(); + + warning("BKeyboardState doesnt yet have state-support"); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); +// bool isDown = state[scanCode] > 0; + +// Stack->PushBool(isDown); + return S_OK; + } + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->SetString(key); + } else _scValue->SetString(""); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Printable") == 0) { + _scValue->SetBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "KeyCode") == 0) { + _scValue->SetInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsShift") == 0) { + _scValue->SetBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsAlt") == 0) { + _scValue->SetBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsControl") == 0) { + _scValue->SetBool(_currentControl); + return _scValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Name")==0){ + SetName(Value->GetString()); + if(_renderer) SetWindowText(_renderer->_window, _name); + return S_OK; + } + + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBKeyboardState::ScToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::ReadKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = KeyCodeToVKey(event); + //_currentKeyData = KeyData; + + _currentControl = IsControlDown(); + _currentAlt = IsAltDown(); + _currentShift = IsShiftDown(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { + //if(!PersistMgr->_saving) Cleanup(); + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_currentAlt)); + PersistMgr->Transfer(TMEMBER(_currentCharCode)); + PersistMgr->Transfer(TMEMBER(_currentControl)); + PersistMgr->Transfer(TMEMBER(_currentKeyData)); + PersistMgr->Transfer(TMEMBER(_currentPrintable)); + PersistMgr->Transfer(TMEMBER(_currentShift)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::IsAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::KeyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { + // todo + return (Common::KeyCode)vkey; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h new file mode 100644 index 0000000000..feed86df5e --- /dev/null +++ b/engines/wintermute/Base/BKeyboardState.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BScriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + HRESULT ReadKey(Common::Event *event); + + static bool IsShiftDown(); + static bool IsControlDown(); + static bool IsAltDown(); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +private: + uint32 KeyCodeToVKey(Common::Event *event); + Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BNamedObject.cpp b/engines/wintermute/Base/BNamedObject.cpp new file mode 100644 index 0000000000..3c4652b731 --- /dev/null +++ b/engines/wintermute/Base/BNamedObject.cpp @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BNamedObject.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::SetName(const char *Name) { + delete[] _name; + + _name = new char [strlen(Name) + 1]; + if (_name != NULL) strcpy(_name, Name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BNamedObject.h b/engines/wintermute/Base/BNamedObject.h new file mode 100644 index 0000000000..ef1a3a444c --- /dev/null +++ b/engines/wintermute/Base/BNamedObject.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *_name; + void SetName(const char *Name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp new file mode 100644 index 0000000000..046f31e4ac --- /dev/null +++ b/engines/wintermute/Base/BObject.cpp @@ -0,0 +1,1122 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = Game->GetSequence(); + + CBPlatform::SetRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Cleanup() { + if (Game && Game->_activeObject == this) Game->_activeObject = NULL; + + CBScriptHolder::Cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::SetCaption(const char *Caption, int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7) return; + + delete[] _caption[Case - 1]; + _caption[Case - 1] = new char[strlen(Caption) + 1]; + if (_caption[Case - 1]) { + strcpy(_caption[Case - 1], Caption); + Game->_stringTable->Expand(&_caption[Case - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBObject::GetCaption(int Case) { + if (Case == 0) Case = 1; + if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; + else return _caption[Case - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SkipTo") == 0) { + Stack->CorrectParams(2); + _posX = Stack->Pop()->GetInt(); + _posY = Stack->Pop()->GetInt(); + AfterMove(); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + Stack->CorrectParams(1); + Stack->PushString(GetCaption(Stack->Pop()->GetInt())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCursor") == 0) { + Stack->CorrectParams(1); + if (SUCCEEDED(SetCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveCursor") == 0) { + Stack->CorrectParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCursor") == 0) { + Stack->CorrectParams(0); + if (!_cursor || !_cursor->_filename) Stack->PushNULL(); + else Stack->PushString(_cursor->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetCursorObject") == 0) { + Stack->CorrectParams(0); + if (!_cursor) Stack->PushNULL(); + else Stack->PushNative(_cursor, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HasCursor") == 0) { + Stack->CorrectParams(0); + + if (_cursor) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCaption") == 0) { + Stack->CorrectParams(2); + SetCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadSound") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + if (SUCCEEDED(PlaySFX(Filename, false, false))) + Stack->PushBool(true); + else + Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlaySound") == 0) { + Stack->CorrectParams(3); + + const char *Filename; + bool Looping; + uint32 LoopStart; + + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + CScValue *val3 = Stack->Pop(); + + if (val1->_type == VAL_BOOL) { + Filename = NULL; + Looping = val1->GetBool(); + LoopStart = val2->GetInt(); + } else { + if (val1->IsNULL()) Filename = NULL; + else Filename = val1->GetString(); + Looping = val2->IsNULL() ? false : val2->GetBool(); + LoopStart = val3->GetInt(); + } + + if (FAILED(PlaySFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PlaySoundEvent") == 0) { + Stack->CorrectParams(2); + + const char *Filename; + const char *EventName; + + CScValue *val1 = Stack->Pop(); + CScValue *val2 = Stack->Pop(); + + if (val2->IsNULL()) { + Filename = NULL; + EventName = val1->GetString(); + } else { + Filename = val1->GetString(); + EventName = val2->GetString(); + } + + if (FAILED(PlaySFX(Filename, false, true, EventName))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "StopSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(StopSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(PauseSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ResumeSound") == 0) { + Stack->CorrectParams(0); + + if (FAILED(ResumeSFX())) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsSoundPlaying") == 0) { + Stack->CorrectParams(0); + + if (_sFX && _sFX->IsPlaying()) Stack->PushBool(true); + else Stack->PushBool(false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSoundPosition") == 0) { + Stack->CorrectParams(1); + + uint32 Time = Stack->Pop()->GetInt(); + if (FAILED(SetSFXTime(Time))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundPosition") == 0) { + Stack->CorrectParams(0); + + if (!_sFX) Stack->PushInt(0); + else Stack->PushInt(_sFX->GetPositionTime()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSoundVolume") == 0) { + Stack->CorrectParams(1); + + int Volume = Stack->Pop()->GetInt(); + if (FAILED(SetSFXVolume(Volume))) Stack->PushBool(false); + else Stack->PushBool(true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSoundVolume") == 0) { + Stack->CorrectParams(0); + + if (!_sFX) Stack->PushInt(_sFXVolume); + else Stack->PushInt(_sFX->GetVolume()); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXNone") == 0) { + Stack->CorrectParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXEcho") == 0) { + Stack->CorrectParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundFXReverb") == 0) { + Stack->CorrectParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + Stack->PushNULL(); + + return S_OK; + } + + else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Caption") == 0) { + _scValue->SetString(GetCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + _scValue->SetInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + _scValue->SetInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _scValue->SetInt(GetHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Ready") == 0) { + _scValue->SetBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Movable") == 0) { + _scValue->SetBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + _scValue->SetBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + _scValue->SetBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotatable") == 0) { + _scValue->SetBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + _scValue->SetInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "BlendMode") == 0) { + _scValue->SetInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + if (_scale < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleX") == 0) { + if (_scaleX < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scaleX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleY") == 0) { + if (_scaleY < 0) _scValue->SetNULL(); + else _scValue->SetFloat((double)_scaleY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeScale") == 0) { + _scValue->SetFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotate") == 0) { + if (!_rotateValid) _scValue->SetNULL(); + else _scValue->SetFloat((double)_rotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeRotate") == 0) { + _scValue->SetFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Colorable") == 0) { + _scValue->SetBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundPanning") == 0) { + _scValue->SetBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveState") == 0) { + _scValue->SetBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NonIntMouseEvents") == 0) { + _scValue->SetBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccCaption") == 0) { + _scValue->SetNULL(); + return _scValue; + } + + else return CBScriptHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Caption") == 0) { + SetCaption(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + _posX = Value->GetInt(); + AfterMove(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + _posY = Value->GetInt(); + AfterMove(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Movable") == 0) { + _movable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + _registrable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + _zoomable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotatable") == 0) { + _rotatable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + _alphaColor = (uint32)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "BlendMode") == 0) { + int i = Value->GetInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + _blendMode = (TSpriteBlendMode)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale") == 0) { + if (Value->IsNULL()) _scale = -1; + else _scale = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleX") == 0) { + if (Value->IsNULL()) _scaleX = -1; + else _scaleX = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleY") == 0) { + if (Value->IsNULL()) _scaleY = -1; + else _scaleY = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeScale") == 0) { + _relativeScale = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotate") == 0) { + if (Value->IsNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)Value->GetFloat(); + _rotateValid = true; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RelativeRotate") == 0) { + _relativeRotate = (float)Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Colorable") == 0) { + _shadowable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SoundPanning") == 0) { + _autoSoundPanning = Value->GetBool(); + if (!_autoSoundPanning) ResetSoundPan(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SaveState") == 0) { + _saveState = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccCaption") == 0) { + return S_OK; + } + + else return CBScriptHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::ScToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ShowCursor() { + if (_cursor) return Game->DrawCursor(_cursor); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { + CBScriptHolder::Persist(PersistMgr); + + for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); + PersistMgr->Transfer(TMEMBER(_activeCursor)); + PersistMgr->Transfer(TMEMBER(_alphaColor)); + PersistMgr->Transfer(TMEMBER(_autoSoundPanning)); + PersistMgr->Transfer(TMEMBER(_cursor)); + PersistMgr->Transfer(TMEMBER(_sharedCursors)); + PersistMgr->Transfer(TMEMBER(_editorAlwaysRegister)); + PersistMgr->Transfer(TMEMBER(_editorOnly)); + PersistMgr->Transfer(TMEMBER(_editorSelected)); + PersistMgr->Transfer(TMEMBER(_iD)); + PersistMgr->Transfer(TMEMBER(_is3D)); + PersistMgr->Transfer(TMEMBER(_movable)); + PersistMgr->Transfer(TMEMBER(_posX)); + PersistMgr->Transfer(TMEMBER(_posY)); + PersistMgr->Transfer(TMEMBER(_relativeScale)); + PersistMgr->Transfer(TMEMBER(_rotatable)); + PersistMgr->Transfer(TMEMBER(_scale)); + PersistMgr->Transfer(TMEMBER(_sFX)); + PersistMgr->Transfer(TMEMBER(_sFXStart)); + PersistMgr->Transfer(TMEMBER(_sFXVolume)); + PersistMgr->Transfer(TMEMBER(_ready)); + PersistMgr->Transfer(TMEMBER(_rect)); + PersistMgr->Transfer(TMEMBER(_rectSet)); + PersistMgr->Transfer(TMEMBER(_registrable)); + PersistMgr->Transfer(TMEMBER(_shadowable)); + PersistMgr->Transfer(TMEMBER(_soundEvent)); + PersistMgr->Transfer(TMEMBER(_zoomable)); + + PersistMgr->Transfer(TMEMBER(_scaleX)); + PersistMgr->Transfer(TMEMBER(_scaleY)); + + PersistMgr->Transfer(TMEMBER(_rotate)); + PersistMgr->Transfer(TMEMBER(_rotateValid)); + PersistMgr->Transfer(TMEMBER(_relativeRotate)); + + PersistMgr->Transfer(TMEMBER(_saveState)); + PersistMgr->Transfer(TMEMBER(_nonIntMouseEvents)); + + PersistMgr->Transfer(TMEMBER_INT(_sFXType)); + PersistMgr->Transfer(TMEMBER(_sFXParam1)); + PersistMgr->Transfer(TMEMBER(_sFXParam2)); + PersistMgr->Transfer(TMEMBER(_sFXParam3)); + PersistMgr->Transfer(TMEMBER(_sFXParam4)); + + + PersistMgr->Transfer(TMEMBER_INT(_blendMode)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetCursor(const char *Filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile(Filename))) { + delete _cursor; + _cursor = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetActiveCursor(const char *Filename) { + delete _activeCursor; + _activeCursor = new CBSprite(Game); + if (!_activeCursor || FAILED(_activeCursor->LoadFile(Filename))) { + delete _activeCursor; + _activeCursor = NULL; + return E_FAIL; + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::GetHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::HandleKeypress(SDL_Event *event) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::HandleMouseWheel(int Delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::PlaySFX(const char *Filename, bool Looping, bool PlayNow, const char *EventName, uint32 LoopStart) { + // just play loaded sound + if (Filename == NULL && _sFX) { + if (Game->_editorMode || _sFXStart) { + _sFX->SetVolume(_sFXVolume); + _sFX->SetPositionTime(_sFXStart); + if (!Game->_editorMode) _sFXStart = 0; + } + if (PlayNow) { + SetSoundEvent(EventName); + if (LoopStart) _sFX->SetLoopStart(LoopStart); + return _sFX->Play(Looping); + } else return S_OK; + } + + if (Filename == NULL) return E_FAIL; + + // create new sound + delete _sFX; + + _sFX = new CBSound(Game); + if (_sFX && SUCCEEDED(_sFX->SetSound(Filename, SOUND_SFX, true))) { + _sFX->SetVolume(_sFXVolume); + if (_sFXStart) { + _sFX->SetPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (PlayNow) { + SetSoundEvent(EventName); + if (LoopStart) _sFX->SetLoopStart(LoopStart); + return _sFX->Play(Looping); + } else return S_OK; + } else { + delete _sFX; + _sFX = NULL; + return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::StopSFX(bool DeleteSound) { + if (_sFX) { + _sFX->Stop(); + if (DeleteSound) { + delete _sFX; + _sFX = NULL; + } + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::PauseSFX() { + if (_sFX) return _sFX->Pause(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ResumeSFX() { + if (_sFX) return _sFX->Resume(); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetSFXTime(uint32 Time) { + _sFXStart = Time; + if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(Time); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::SetSFXVolume(int Volume) { + _sFXVolume = Volume; + if (_sFX) return _sFX->SetVolume(Volume); + else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::UpdateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->IsPlaying()) { + ApplyEvent(_soundEvent); + SetSoundEvent(NULL); + } + } + + if (_sFX) UpdateOneSound(_sFX); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::UpdateOneSound(CBSound *Sound) { + HRESULT Ret = S_OK; + + if (Sound) { + if (_autoSoundPanning) + Ret = Sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); + + Ret = Sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::ResetSoundPan() { + if (!_sFX) return S_OK; + else { + return _sFX->SetPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::GetExtendedFlag(const char *FlagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::IsReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::SetSoundEvent(const char *EventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (EventName) { + _soundEvent = new char[strlen(EventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, EventName); + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBObject::AfterMove() { + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h new file mode 100644 index 0000000000..e2c3b25fd8 --- /dev/null +++ b/engines/wintermute/Base/BObject.h @@ -0,0 +1,145 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "engines/wintermute/Base/BScriptHolder.h" +#include "engines/wintermute/persistent.h" + +union SDL_Event; + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode _blendMode; + virtual HRESULT AfterMove(); + float _relativeRotate; + bool _rotateValid; + float _rotate; + void SetSoundEvent(const char *EventName); + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; + virtual bool IsReady(); + virtual bool GetExtendedFlag(const char *FlagName); + virtual HRESULT ResetSoundPan(); + virtual HRESULT UpdateSounds(); + HRESULT UpdateOneSound(CBSound *Sound); + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; + HRESULT SetSFXTime(uint32 Time); + HRESULT SetSFXVolume(int Volume); + HRESULT ResumeSFX(); + HRESULT PauseSFX(); + HRESULT StopSFX(bool DeleteSound = true); + HRESULT PlaySFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); + CBSound *_sFX; + + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + + virtual bool HandleMouseWheel(int Delta); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + virtual bool HandleKeypress(SDL_Event *event); + virtual int GetHeight(); + HRESULT SetCursor(const char *Filename); + HRESULT SetActiveCursor(const char *Filename); + HRESULT Cleanup(); + char *GetCaption(int Case = 1); + void SetCaption(const char *Caption, int Case = 1); + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual HRESULT ShowCursor(); + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + RECT _rect; + bool _rectSet; + int _iD; + bool _movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; + + // base + virtual HRESULT Update() { + return E_FAIL; + }; + virtual HRESULT Display() { + return E_FAIL; + }; + virtual HRESULT InvalidateDeviceObjects() { + return S_OK; + }; + virtual HRESULT RestoreDeviceObjects() { + return S_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp new file mode 100644 index 0000000000..976e9b3344 --- /dev/null +++ b/engines/wintermute/Base/BPackage.cpp @@ -0,0 +1,104 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BPackage.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + CloseFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Open() { + if (_file) return S_OK; + else { + _file = GetFilePointer(); + return _file ? S_OK : E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Close() { + delete _file; + _file = NULL; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPackage::Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + HRESULT ret; + if (FAILED(ret = Open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return E_FAIL; + if (file->read(buffer, size) != 1) return E_FAIL; + else return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::GetFilePointer() { + Common::File *file = Game->_fileManager->OpenPackage(_name); + if (!file) { + Game->_fileManager->RequestCD(_cD, _name, ""); + file = Game->_fileManager->OpenPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::CloseFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h new file mode 100644 index 0000000000..80d8e481f2 --- /dev/null +++ b/engines/wintermute/Base/BPackage.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *GetFilePointer(); + void CloseFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + HRESULT Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + HRESULT Close(); + HRESULT Open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp new file mode 100644 index 0000000000..e3887f1acb --- /dev/null +++ b/engines/wintermute/Base/BParser.cpp @@ -0,0 +1,436 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (_whiteSpace != NULL) delete [] _whiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { + SkipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + SkipCharacters(buf, _whiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else strcpy(_lastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + SkipCharacters(buf, _whiteSpace); + + // get optional name + *name = GetSubText(buf, '\'', '\''); // single quotes + SkipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = GetAssignmentText(buf); + else + *data = GetSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + Game->MiniUpdate(); + char *name; + return GetObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::SkipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') _parserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::GetAssignmentText(char **buf) { + ++*buf; // skip the '=' + SkipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = GetSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::GetToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::GetTokenFloat(char **buf) { + char *t = GetToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::GetTokenInt(char **buf) { + char *t = GetToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::SkipToken(char **buf, char *tok, char * /*msg*/) { + char *t = GetToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::ScanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BParser.h b/engines/wintermute/Base/BParser.h new file mode 100644 index 0000000000..07764a97da --- /dev/null +++ b/engines/wintermute/Base/BParser.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + long id; + const char *token; + }; + +public: + int ScanStr(const char *in, const char *format, ...); + char *GetLastOffender(); + void SkipToken(char **buf, char *tok, char *msg = NULL); + int GetTokenInt(char **buf); + float GetTokenFloat(char **buf); + char *GetToken(char **buf); + char *GetAssignmentText(char **buf); + char *GetSubText(char **buf, char open, char close); + void SkipCharacters(char **buf, const char *toSkip); + long GetCommand(char **buf, TokenDesc *tokens, char **params); + long GetObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); + char *_whiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp new file mode 100644 index 0000000000..e005c09591 --- /dev/null +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -0,0 +1,517 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BPersistMgr.h" +#include "engines/wintermute/Base/BSaveThumbHelper.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/BSound.h" +#include "common/str.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { + _saving = false; + _buffer = NULL; + _bufferSize = 0; + _offset = 0; + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; + _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::Cleanup() { + if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0; + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; // ref to buffer + _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; + } +} + +// TODO: This is not at all endian-safe +uint32 makeUint32(byte first, byte second, byte third, byte fourth) { + uint32 retVal = first; + retVal = retVal & second << 8 & third << 16 & fourth << 24; + return retVal; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::InitSave(const char *Desc) { + if (!Desc) return E_FAIL; + + HRESULT res; + + Cleanup(); + _saving = true; + + _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); + if (_buffer) { + _bufferSize = SAVE_BUFFER_INIT_SIZE; + res = S_OK; + } else res = E_FAIL; + + + if (SUCCEEDED(res)) { + // get thumbnails + if (!Game->_cachedThumbnail) { + Game->_cachedThumbnail = new CBSaveThumbHelper(Game); + if (FAILED(Game->_cachedThumbnail->StoreThumbnail(true))) { + delete Game->_cachedThumbnail; + Game->_cachedThumbnail = NULL; + } + } + + + uint32 magic = DCGF_MAGIC; + PutDWORD(magic); + + magic = SAVE_MAGIC_2; + PutDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + uint32 Version = makeUint32(VerMajor, VerMinor, ExtMajor, ExtMinor); + PutDWORD(Version); + + // new in ver 2 + PutDWORD((uint32)DCGF_VER_BUILD); + PutString(Game->_name); + + // thumbnail data size + bool ThumbnailOK = false; + + if (Game->_cachedThumbnail) { + if (Game->_cachedThumbnail->_thumbnail) { + uint32 Size = 0; + byte *Buffer = Game->_cachedThumbnail->_thumbnail->CreateBMPBuffer(&Size); + + PutDWORD(Size); + if (Size > 0) PutBytes(Buffer, Size); + + delete [] Buffer; + ThumbnailOK = true; + } + } + if (!ThumbnailOK) PutDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete Game->_cachedThumbnail; + Game->_cachedThumbnail = NULL; + + uint32 DataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(Desc) + 1 + // description + sizeof(uint32); // timestamp + + PutDWORD(DataOffset); + PutString(Desc); +// TODO: Add usefull timestamps, we can't use ctime... +/* time_t Timestamp; + time(&Timestamp); + PutDWORD((uint32)Timestamp);*/ + } + return res; +} +// TODO: Do this properly, this is just a quickfix, that probably doesnt even work. +// The main point of which is ditching BASS completely. +byte getLowByte(uint16 word) { + uint16 mask = 0xff; + return word & mask; +} + +byte getHighByte(uint16 word) { + uint16 mask = 0xff << 8; + word = word & mask; + return word >> 8; +} + +uint16 getLowWord(uint32 dword) { + uint32 mask = 0xffff; + return dword & mask; +} + +uint16 getHighWord(uint32 dword) { + uint32 mask = 0xffff << 16; + dword = dword & mask; + return dword >> 16; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::InitLoad(const char *Filename) { + Cleanup(); + + _saving = false; + + _buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); + if (_buffer) { + uint32 Magic; + Magic = GetDWORD(); + if (Magic != DCGF_MAGIC) goto init_fail; + + Magic = GetDWORD(); + + if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { + uint32 Version = GetDWORD(); + _savedVerMajor = getLowByte(getLowWord(Version)); + _savedVerMinor = getHighByte(getLowWord(Version)); + _savedExtMajor = getLowByte(getHighWord(Version)); + _savedExtMinor = getHighByte(getHighWord(Version)); + + if (Magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)GetDWORD(); + char *SavedName = GetString(); + if (SavedName == NULL || scumm_stricmp(SavedName, Game->_name) != 0) { + Game->LOG(0, "ERROR: Saved game name doesn't match current game"); + goto init_fail; + } + + // load thumbnail + _thumbnailDataSize = GetDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + GetBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; + } + } else _savedVerBuild = 35; // last build with ver1 savegames + + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game version is newer than current game"); + goto init_fail; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + goto init_fail; + } + + /* + if( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + Game->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + } else goto init_fail; + + + uint32 DataOffset = GetDWORD(); + + _savedDescription = GetString(); + _savedTimestamp = (time_t)GetDWORD(); + + _offset = DataOffset; + + return S_OK; + } + +init_fail: + Cleanup(); + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::SaveFile(const char *Filename) { + return Game->_fileManager->SaveFile(Filename, _buffer, _offset, Game->_compressedSavegames, _richBuffer, _richBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { + while (_offset + Size > _bufferSize) { + _bufferSize += SAVE_BUFFER_GROW_BY; + _buffer = (byte *)realloc(_buffer, _bufferSize); + if (!_buffer) { + Game->LOG(0, "Error reallocating save buffer to %d bytes", _bufferSize); + return E_FAIL; + } + } + + memcpy(_buffer + _offset, Buffer, Size); + _offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { + if (_offset + Size > _bufferSize) { + Game->LOG(0, "Fatal: Save buffer underflow"); + return E_FAIL; + } + + memcpy(Buffer, _buffer + _offset, Size); + _offset += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::PutDWORD(uint32 Val) { + PutBytes((byte *)&Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::GetDWORD() { + uint32 ret; + GetBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::PutString(const char *Val) { + if (!Val) PutString("(null)"); + else { + PutDWORD(strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::GetString() { + uint32 len = GetDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + +////////////////////////////////////////////////////////////////////////// +// bool +HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(bool)); + else return GetBytes((byte *)Val, sizeof(bool)); +} + + +////////////////////////////////////////////////////////////////////////// +// int +HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(int)); + else return GetBytes((byte *)Val, sizeof(int)); +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); + else return GetBytes((byte *)Val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +// float +HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(float)); + else return GetBytes((byte *)Val, sizeof(float)); +} + + +////////////////////////////////////////////////////////////////////////// +// double +HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(double)); + else return GetBytes((byte *)Val, sizeof(double)); +} + + +////////////////////////////////////////////////////////////////////////// +// char* +HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { + if (_saving) { + PutString(*Val); + return S_OK; + } else { + char *str = GetString(); + if (str) { + + *Val = new char[strlen(str) + 1]; + strcpy(*Val, str); + } else *Val = NULL; + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { + size_t size; + + if (_saving) { + size = Val.size(); + PutBytes((byte *)&size, sizeof(size_t)); + + for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { + PutString((*it).c_str()); + } + } else { + Val.clear(); + GetBytes((byte *)&size, sizeof(size_t)); + + for (size_t i = 0; i < size; i++) { + char *str = GetString(); + if (str) Val.push_back(str); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(byte)); + else return GetBytes((byte *)Val, sizeof(byte)); +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); + else return GetBytes((byte *)Val, sizeof(RECT)); +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); + else return GetBytes((byte *)Val, sizeof(POINT)); +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { + if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); + else return GetBytes((byte *)Val, sizeof(Vector2)); +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { + int ClassID = -1, InstanceID = -1; + + if (_saving) { + CSysClassRegistry::GetInstance()->GetPointerID(*(void **)Val, &ClassID, &InstanceID); + if (*(void **)Val != NULL && (ClassID == -1 || InstanceID == -1)) { + Game->LOG(0, "Warning: invalid instance '%s'", Name); + } + + PutDWORD(ClassID); + PutDWORD(InstanceID); + } else { + ClassID = GetDWORD(); + InstanceID = GetDWORD(); + + *(void **)Val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild) { + if (_saving) return true; + + // it's ok if we are same or newer than the saved game + if (VerMajor > _savedVerMajor || + (VerMajor == _savedVerMajor && VerMinor > _savedVerMinor) || + (VerMajor == _savedVerMajor && VerMinor == _savedVerMinor && VerBuild > _savedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h new file mode 100644 index 0000000000..9049b72b3c --- /dev/null +++ b/engines/wintermute/Base/BPersistMgr.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *_savedDescription; + time_t _savedTimestamp; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + HRESULT SaveFile(const char *Filename); + uint32 GetDWORD(); + void PutDWORD(uint32 Val); + char *GetString(); + void PutString(const char *Val); + void Cleanup(); + HRESULT InitLoad(const char *Filename); + HRESULT InitSave(const char *Desc); + HRESULT GetBytes(byte *Buffer, uint32 Size); + HRESULT PutBytes(byte *Buffer, uint32 Size); + uint32 _offset; + uint32 _bufferSize; + byte *_buffer; + bool _saving; + + uint32 _richBufferSize; + byte *_richBuffer; + + HRESULT Transfer(const char *Name, void *Val); + HRESULT Transfer(const char *Name, int *Val); + HRESULT Transfer(const char *Name, uint32 *Val); + HRESULT Transfer(const char *Name, float *Val); + HRESULT Transfer(const char *Name, double *Val); + HRESULT Transfer(const char *Name, bool *Val); + HRESULT Transfer(const char *Name, byte *Val); + HRESULT Transfer(const char *Name, RECT *Val); + HRESULT Transfer(const char *Name, POINT *Val); + HRESULT Transfer(const char *Name, char **Val); + HRESULT Transfer(const char *Name, Vector2 *Val); + HRESULT Transfer(const char *Name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL); + virtual ~CBPersistMgr(); + bool CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BPkgFile.cpp b/engines/wintermute/Base/BPkgFile.cpp new file mode 100644 index 0000000000..a48ccf7555 --- /dev/null +++ b/engines/wintermute/Base/BPkgFile.cpp @@ -0,0 +1,161 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BPackage.h" +#include "engines/wintermute/Base/BPkgFile.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "common/util.h" +#include "common/file.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { + _fileEntry = NULL; + _file = NULL; + _compressed = false; + +} + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::~CBPkgFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Open(const Common::String &Filename) { + Close(); + + char fileName[MAX_PATH]; + strcpy(fileName, Filename.c_str()); + + // correct slashes + for (uint32 i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '/') fileName[i] = '\\'; + } + + _fileEntry = Game->_fileManager->GetPackageEntry(fileName); + if (!_fileEntry) return E_FAIL; + + _file = _fileEntry->_package->GetFilePointer(); + if (!_file) return E_FAIL; + + // TODO: Cleanup + _compressed = (_fileEntry->_compressedLength != 0); + _size = _fileEntry->_length; + + if (_compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + } else { + _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); + } + + SeekToPos(0); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Close() { + if (_fileEntry) { + _fileEntry->_package->CloseFilePointer(_file); + _fileEntry = NULL; + } + _file = NULL; + + // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { + if (!_fileEntry) return E_FAIL; + + HRESULT ret = S_OK; + + if (_pos + Size > _size) { + Size = _size - _pos; + if (Size == 0) return E_FAIL; + } + + ret = _file->read(Buffer, Size); + + _pos += Size; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { + if (!_fileEntry) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + + return SeekToPos(NewPos); +} + + +#define STREAM_BUFFER_SIZE 4096 +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { + HRESULT ret = S_OK; + + // seek compressed stream to NewPos + _pos = NewPos; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPkgFile.h b/engines/wintermute/Base/BPkgFile.h new file mode 100644 index 0000000000..e2817f8a00 --- /dev/null +++ b/engines/wintermute/Base/BPkgFile.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPKGFILE_H +#define WINTERMUTE_BPKGFILE_H + + +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BFileEntry.h" +#include // Added by ClassView + +#define COMPRESSED_BUFFER_SIZE 4096 + +namespace Common { +class SeekableReadStream; +class File; +} + +namespace WinterMute { + +class CBPkgFile : public CBFile { +public: + CBPkgFile(CBGame *inGame); + virtual ~CBPkgFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + bool _inflateInit; + HRESULT SeekToPos(uint32 NewPos); + bool _compressed; + CBFileEntry *_fileEntry; + Common::SeekableReadStream *_file; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp new file mode 100644 index 0000000000..943e6d7843 --- /dev/null +++ b/engines/wintermute/Base/BPoint.cpp @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BPoint.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPoint::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(x)); + PersistMgr->Transfer(TMEMBER(y)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPoint.h b/engines/wintermute/Base/BPoint.h new file mode 100644 index 0000000000..7b9c561fac --- /dev/null +++ b/engines/wintermute/Base/BPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BQuickMsg.cpp b/engines/wintermute/Base/BQuickMsg.cpp new file mode 100644 index 0000000000..e425368929 --- /dev/null +++ b/engines/wintermute/Base/BQuickMsg.cpp @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BQuickMsg.h" +#include "engines/wintermute/Base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *Text): CBBase(inGame) { + _text = new char [strlen(Text) + 1]; + if (_text) strcpy(_text, Text); + _startTime = Game->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (_text) delete [] _text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::GetText() { + return _text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BQuickMsg.h b/engines/wintermute/Base/BQuickMsg.h new file mode 100644 index 0000000000..3f03ef21fc --- /dev/null +++ b/engines/wintermute/Base/BQuickMsg.h @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *GetText(); + uint32 _startTime; + char *_text; + CBQuickMsg(CBGame *inGame, const char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp new file mode 100644 index 0000000000..dd3c8db881 --- /dev/null +++ b/engines/wintermute/Base/BRegion.cpp @@ -0,0 +1,509 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + CBPlatform::SetRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::Cleanup() { + for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); + + CBPlatform::SetRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::CreateRegion() { + return SUCCEEDED(GetBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::PointInRegion(int X, int Y) { + if (_points.GetSize() < 3) return false; + + POINT pt; + pt.x = X; + pt.y = Y; + + RECT rect; + rect.left = X - 1; + rect.right = X + 2; + rect.top = Y - 1; + rect.bottom = Y + 2; + + if (CBPlatform::PtInRect(&_rect, pt)) return PtInPolygon(X, Y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + Game->LOG(0, "'REGION' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int i; + + for (i = 0; i < _points.GetSize(); i++) delete _points[i]; + _points.RemoveAll(); + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.ScanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.ScanStr((char *)params, "%d,%d", &x, &y); + _points.Add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + ParseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in REGION definition"); + return E_FAIL; + } + + CreateRegion(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "AddPoint") == 0) { + Stack->CorrectParams(2); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + _points.Add(new CBPoint(X, Y)); + CreateRegion(); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertPoint") == 0) { + Stack->CorrectParams(3); + int Index = Stack->Pop()->GetInt(); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < _points.GetSize()) { + _points.InsertAt(Index, new CBPoint(X, Y)); + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPoint") == 0) { + Stack->CorrectParams(3); + int Index = Stack->Pop()->GetInt(); + int X = Stack->Pop()->GetInt(); + int Y = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < _points.GetSize()) { + _points[Index]->x = X; + _points[Index]->y = Y; + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemovePoint") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < _points.GetSize()) { + delete _points[Index]; + _points[Index] = NULL; + + _points.RemoveAt(Index); + CreateRegion(); + + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPoint") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(); + + if (Index >= 0 && Index < _points.GetSize()) { + CScValue *Val = Stack->GetPushValue(); + if (Val) { + Val->SetProperty("X", _points[Index]->x); + Val->SetProperty("Y", _points[Index]->y); + } + } else Stack->PushNULL(); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + _scValue->SetBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumPoints") == 0) { + _scValue->SetInt(_points.GetSize()); + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Active") == 0) { + _active = Value->GetBool(); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBRegion::ScToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { + if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); + else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + int i; + + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (i = 0; i < _points.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_active)); + PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); + PersistMgr->Transfer(TMEMBER(_lastMimicScale)); + PersistMgr->Transfer(TMEMBER(_lastMimicX)); + PersistMgr->Transfer(TMEMBER(_lastMimicY)); + _points.Persist(PersistMgr); + + return S_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::PtInPolygon(int X, int Y) { + if (_points.GetSize() < 3) return false; + + int counter = 0; + int i; + double xinters; + dPoint p, p1, p2; + + p.x = (double)X; + p.y = (double)Y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (i = 1; i <= _points.GetSize(); i++) { + p2.x = (double)_points[i % _points.GetSize()]->x; + p2.y = (double)_points[i % _points.GetSize()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::GetBoundingRect(RECT *Rect) { + if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < _points.GetSize(); i++) { + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); + + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); + } + CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { + if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; + + Cleanup(); + + for (int i = 0; i < Region->_points.GetSize(); i++) { + int x, y; + + x = (int)((float)Region->_points[i]->x * Scale / 100.0f); + y = (int)((float)Region->_points[i]->y * Scale / 100.0f); + + _points.Add(new CBPoint(x + X, y + Y)); + } + + _lastMimicScale = Scale; + _lastMimicX = X; + _lastMimicY = Y; + + return CreateRegion() ? S_OK : E_FAIL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h new file mode 100644 index 0000000000..c2fe086655 --- /dev/null +++ b/engines/wintermute/Base/BRegion.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "engines/wintermute/Base/BPoint.h" +#include "engines/wintermute/Base/BObject.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void Cleanup(); + HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); + HRESULT GetBoundingRect(RECT *Rect); + bool PtInPolygon(int X, int Y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool _active; + int _editorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool PointInRegion(int X, int Y); + bool CreateRegion(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + RECT _rect; + CBArray _points; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp new file mode 100644 index 0000000000..d918202ff1 --- /dev/null +++ b/engines/wintermute/Base/BRegistry.cpp @@ -0,0 +1,228 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/tinyxml.h" +#include "engines/wintermute/utils.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + _iniName = NULL; + + SetIniName("./wme.ini"); + LoadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + SaveValues(); + delete[] _iniName; + _iniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + +#ifdef __WIN32__ + // check ini file first (so what we can use project files on windows) + char buffer[32768]; + GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, _iniName); + ret = AnsiString(buffer); + + if (buffer != init) return ret; +#endif + + bool found = false; + ret = GetValue(_localValues, subKey, key, found); + if (!found) ret = GetValue(_values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + _values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int init) { +#ifdef __WIN32__ + int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName); + if (ret != init) return ret; +#endif + + AnsiString val = ReadString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteInt(const AnsiString &subKey, const AnsiString &key, int value) { + WriteString(subKey, key, StringUtil::ToString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::ReadBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (ReadInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return WriteInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SetIniName(const char *Name) { + delete[] _iniName; + _iniName = NULL; + + if (strchr(Name, '\\') == NULL && strchr(Name, '/') == NULL) { + _iniName = new char [strlen(Name) + 3]; + sprintf(_iniName, "./%s", Name); + } else { + _iniName = new char [strlen(Name) + 1]; + strcpy(_iniName, Name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::GetIniName() { + return _iniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::LoadValues(bool local) { + if (local) LoadXml("settings.xml", _localValues); + else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SaveValues() { + SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SetBasePath(const char *basePath) { + _basePath = PathUtil::GetFileNameWithoutExtension(basePath); + + LoadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it)._value; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt)._value; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName.c_str()); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::CreatePath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt)._value; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + std::ofstream stream; + stream.open(fileName.c_str()); + + if (!stream.is_open()) return; + else { + stream << printer.CStr(); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegistry.h b/engines/wintermute/Base/BRegistry.h new file mode 100644 index 0000000000..1b2b5846b1 --- /dev/null +++ b/engines/wintermute/Base/BRegistry.h @@ -0,0 +1,76 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void SetIniName(const char *Name); + char *GetIniName(); + bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool WriteInt(const AnsiString &subKey, const AnsiString &key, int value); + int ReadInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void SetBasePath(const char *basePath); + AnsiString GetBasePath() const { + return _basePath; + } + + void LoadValues(bool local); + void SaveValues(); + +private: + char *_iniName; + + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; + + PathValueMap _localValues; + PathValueMap _values; + + AnsiString _basePath; + + void LoadXml(const AnsiString fileName, PathValueMap &values); + void SaveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp new file mode 100644 index 0000000000..43b6134845 --- /dev/null +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -0,0 +1,456 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/MathUtil.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "common/system.h" +#include "engines/wintermute/graphics/transparentSurface.h" + +namespace WinterMute { + +// TODO: Redo everything here. + +////////////////////////////////////////////////////////////////////////// +CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { + /* _renderer = NULL; + _win = NULL;*/ + _renderSurface = NULL; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; +} + +////////////////////////////////////////////////////////////////////////// +CBRenderSDL::~CBRenderSDL() { +#if 0 + if (_renderer) SDL_DestroyRenderer(_renderer); + if (_win) SDL_DestroyWindow(_win); + SDL_Quit(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; + +#if 0 + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); +#endif + + _width = width; + _height = height; + + _realWidth = width; + _realHeight = height; + + + // find suitable resolution +#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } +#else + _realWidth = Game->_registry->ReadInt("Debug", "ForceResWidth", _width); + _realHeight = Game->_registry->ReadInt("Debug", "ForceResHeight", _height); +#endif + + /* + _realWidth = 480; + _realHeight = 320; + */ + + + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)_realHeight / (float)_height; + } else { + // wide to normal + ratio = (float)_realWidth / (float)_width; + } + + _borderLeft = (_realWidth - (_width * ratio)) / 2; + _borderRight = _realWidth - (_width * ratio) - _borderLeft; + + _borderTop = (_realHeight - (_height * ratio)) / 2; + _borderBottom = _realHeight - (_height * ratio) - _borderTop; + + + + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; + +#if 0 + Uint32 flags = SDL_WINDOW_SHOWN; +#endif +#ifdef __IPHONEOS__ + flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; +#endif + + //_windowed = Game->_registry->ReadBool("Video", "Windowed", true); +// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return E_FAIL; + } +#if 0 + _win = SDL_CreateWindow("WME Lite", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + _realWidth, _realHeight, + flags); + + if (!_win) return E_FAIL; +#endif + + warning("TODO: Hide cursor"); + //SDL_ShowCursor(SDL_DISABLE); + +#ifdef __IPHONEOS__ + // SDL defaults to OGL ES2, which doesn't work on old devices + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); +#else + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif +#if 0 + _renderer = SDL_CreateRenderer(_win, -1, 0); + + if (!_renderer) return E_FAIL; +#endif + _renderSurface = new Graphics::Surface(); + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _active = true; + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Flip() { + +#ifdef __IPHONEOS__ + // hack: until viewports work correctly, we just paint black bars instead + SDL_SetRenderDrawColor(_renderer, 0x00, 0x00, 0x00, 0xFF); + + static bool firstRefresh = true; // prevents a weird color glitch + if (firstRefresh) { + firstRefresh = false; + } else { + SDL_Rect rect; + if (_borderLeft > 0) { + rect.x = 0; + rect.y = 0; + rect.w = _borderLeft; + rect.h = _realHeight; + SDL_RenderFillRect(_renderer, &rect); + } + if (_borderRight > 0) { + rect.x = (_realWidth - _borderRight); + rect.y = 0; + rect.w = _borderRight; + rect.h = _realHeight; + SDL_RenderFillRect(_renderer, &rect); + } + if (_borderTop > 0) { + rect.x = 0; + rect.y = 0; + rect.w = _realWidth; + rect.h = _borderTop; + SDL_RenderFillRect(_renderer, &rect); + } + if (_borderBottom > 0) { + rect.x = 0; + rect.y = _realHeight - _borderBottom; + rect.w = _realWidth; + rect.h = _borderBottom; + SDL_RenderFillRect(_renderer, &rect); + } + } +#endif + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + g_system->updateScreen(); + //SDL_RenderPresent(_renderer); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { + //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); + //SDL_RenderClear(_renderer); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::Fade(uint16 Alpha) { + uint32 dwAlpha = 255 - Alpha; + return FadeToColor(dwAlpha << 24); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Implement CBRenderSDL::FadeToColor"); // TODO. + hasWarned = true; + } +#if 0 + SDL_Rect fillRect; + + if (rect) { + fillRect.x = rect->left; + fillRect.y = rect->top; + fillRect.w = rect->right - rect->left; + fillRect.h = rect->bottom - rect->top; + } else { + RECT rc; + Game->GetCurrentViewportRect(&rc); + fillRect.x = rc.left; + fillRect.y = rc.top; + fillRect.w = rc.right - rc.left; + fillRect.h = rc.bottom - rc.top; + } + ModTargetRect(&fillRect); + + byte r = D3DCOLGetR(Color); + byte g = D3DCOLGetG(Color); + byte b = D3DCOLGetB(Color); + byte a = D3DCOLGetA(Color); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); +#endif + return S_OK; +} + +// Replacement for SDL2's SDL_RenderCopy +void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { + TransparentSurface src(*surf, false); + src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(255, 255, 255, 255), dstRect->width(), dstRect->height() ); +} +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderSDL::DrawLine - not fully ported yet"); + hasWarned = true; + } +/* byte r = D3DCOLGetR(Color); + byte g = D3DCOLGetG(Color); + byte b = D3DCOLGetB(Color); + byte a = D3DCOLGetA(Color);*/ + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + + POINT point1, point2; + point1.x = X1; + point1.y = Y1; + PointToScreen(&point1); + + point2.x = X2; + point2.y = Y2; + PointToScreen(&point2); + + + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderSDL::TakeScreenshot() { +// TODO: Fix this +#if 0 + SDL_Rect viewport; + + SDL_RenderGetViewport(_renderer, &viewport); + + SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); + if (!surface) return NULL; + + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + + FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + + int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); + + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + byte *bits = FreeImage_GetScanLine(dib, y); + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + memcpy(bits, src, bytespp * viewport.w); + } + + return new CBImage(Game, dib); +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::SwitchFullscreen() { + /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); + else SDL_SetWindowFullscreen(_win, SDL_FALSE); + + _windowed = !_windowed; + */ + Game->_registry->WriteBool("Video", "Windowed", _windowed); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBRenderSDL::GetName() { + if (_name.empty()) { +#if 0 + if (_renderer) { + SDL_RendererInfo info; + SDL_GetRendererInfo(_renderer, &info); + _name = AnsiString(info.name); + } +#endif + } + return _name.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = left + _borderLeft; + rect.top = top + _borderTop; + rect.right = (right - left) * _ratioX; + rect.bottom = (bottom - top) * _ratioY; + + // TODO fix this once viewports work correctly in SDL/landscape +#ifndef __IPHONEOS__ + //SDL_RenderSetViewport(GetSdlRenderer(), &rect); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::ModTargetRect(Common::Rect *rect) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * _ratioX); + rect->h = MathUtil::RoundUp(rect->h * _ratioY); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::PointFromScreen(POINT *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; + point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::PointToScreen(POINT *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderSDL::DumpData(const char *Filename) { + FILE *f = fopen(Filename, "wt"); + if (!f) return; + + CBSurfaceStorage *Mgr = Game->_surfaceStorage; + + int TotalKB = 0; + int TotalLoss = 0; + fprintf(f, "Filename;Usage;Size;KBytes\n"); + for (int i = 0; i < Mgr->_surfaces.GetSize(); i++) { + CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->_surfaces[i]; + if (!Surf->_filename) continue; + if (!Surf->_valid) continue; + + fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); + fprintf(f, "%dx%d;", Surf->GetWidth(), Surf->GetHeight()); + + int kb = Surf->GetWidth() * Surf->GetHeight() * 4 / 1024; + + TotalKB += kb; + fprintf(f, "%d;", kb); + fprintf(f, "\n"); + } + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.GetSize(), TotalKB); + + + fclose(f); + Game->LOG(0, "Texture Stats Dump completed."); + Game->QuickMessage("Texture Stats Dump completed."); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h new file mode 100644 index 0000000000..73dc88d4be --- /dev/null +++ b/engines/wintermute/Base/BRenderSDL.h @@ -0,0 +1,96 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_SDL_H +#define WINTERMUTE_BRENDERER_SDL_H + +#include "engines/wintermute/Base/BRenderer.h" +#include "common/rect.h" +#include "graphics/surface.h" + +class SDL_Window; +class SDL_Renderer; + +namespace WinterMute { + +class CBRenderSDL : public CBRenderer { +public: + CBRenderSDL(CBGame *inGame); + ~CBRenderSDL(); + + const char *GetName(); + + HRESULT InitRenderer(int width, int height, bool windowed); + HRESULT Flip(); + HRESULT Fill(byte r, byte g, byte b, RECT *rect); + + HRESULT Fade(uint16 Alpha); + HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + + HRESULT SwitchFullscreen(); + + HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + + CBImage *TakeScreenshot(); + + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); + + + HRESULT SetViewport(int left, int top, int right, int bottom); + + void ModTargetRect(Common::Rect *rect); + void PointFromScreen(POINT *point); + void PointToScreen(POINT *point); + + void DumpData(const char *Filename); + + float GetScaleRatioX() const { + return _ratioX; + } + float GetScaleRatioY() const { + return _ratioY; + } + +private: + /* SDL_Renderer *_renderer; + SDL_Window *_win;*/ + Graphics::Surface *_renderSurface; + AnsiString _name; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + float _ratioX; + float _ratioY; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp new file mode 100644 index 0000000000..ba7b0bb405 --- /dev/null +++ b/engines/wintermute/Base/BRenderer.cpp @@ -0,0 +1,259 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BRenderer.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { + _instance = NULL; + _window = NULL; + _clipperWindow = NULL; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _width = _height = _bPP = 0; + CBPlatform::SetRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBRenderer::~CBRenderer() { + DeleteRectList(); + UnclipCursor(); +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::InitLoop() { + DeleteRectList(); +} + + +////////////////////////////////////////////////////////////////////// +CBObject *CBRenderer::GetObjectAt(int X, int Y) { + POINT point; + point.x = X; + point.y = Y; + + for (int i = _rectList.GetSize() - 1; i >= 0; i--) { + if (CBPlatform::PtInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + int XX = (int)((_rectList[i]->_frame->_rect.left + X - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int YY = (int)((_rectList[i]->_frame->_rect.top + Y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + + if (_rectList[i]->_frame->_mirrorX) { + int Width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + XX = Width - XX; + } + + if (_rectList[i]->_frame->_mirrorY) { + int Height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + YY = Height - YY; + } + + if (!_rectList[i]->_frame->_surface->IsTransparentAt(XX, YY)) return _rectList[i]->_owner; + } + // region + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->PointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + } + } else return _rectList[i]->_owner; + } + } + + return (CBObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderer::DeleteRectList() { + for (int i = 0; i < _rectList.GetSize(); i++) { + delete _rectList[i]; + } + _rectList.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SwitchFullscreen() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Flip() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::InitRenderer(int width, int height, bool windowed) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::OnWindowChange() { +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Fill(byte r, byte g, byte b, RECT *rect) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::WindowedBlt() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Setup2D(bool Force) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetupLines() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { + for (int i = 0; i < Width; i++) { + DrawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up + DrawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down + + DrawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left + DrawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::Fade(uint16 Alpha) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::FadeToColor(uint32 Color, RECT *rect) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetScreenViewport() { + return SetViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::SetViewport(RECT *Rect) { + return SetViewport(Rect->left + _drawOffsetX, + Rect->top + _drawOffsetY, + Rect->right + _drawOffsetX, + Rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderer::TakeScreenshot() { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::ClipCursor() { + /* + if(!_windowed) + { + RECT rc; + GetWindowRect(_window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; + + ::ClipCursor(&rc); + } + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBRenderer::UnclipCursor() { + /* + if(!_windowed) ::ClipCursor(NULL); + */ + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::PointInViewport(POINT *P) { + if (P->x < _drawOffsetX) return false; + if (P->y < _drawOffsetY) return false; + if (P->x > _drawOffsetX + _width) return false; + if (P->y > _drawOffsetY + _height) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h new file mode 100644 index 0000000000..91d0f211c6 --- /dev/null +++ b/engines/wintermute/Base/BRenderer.h @@ -0,0 +1,124 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_H +#define WINTERMUTE_BRENDERER_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBImage; +class CBActiveRect; +class CBObject; + +class CBRenderer: public CBBase { +public: + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void DumpData(const char *Filename) {}; + virtual CBImage *TakeScreenshot(); + virtual HRESULT SetViewport(int left, int top, int right, int bottom); + virtual HRESULT SetViewport(RECT *Rect); + virtual HRESULT SetScreenViewport(); + virtual HRESULT Fade(uint16 Alpha); + virtual HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); + CBRenderer(CBGame *inGame = NULL); + virtual ~CBRenderer(); + virtual HRESULT SetProjection() { + return S_OK; + }; + + virtual HRESULT WindowedBlt(); + virtual HRESULT Fill(byte r, byte g, byte b, RECT *rect = NULL); + virtual void OnWindowChange(); + virtual HRESULT InitRenderer(int width, int height, bool windowed); + virtual HRESULT Flip(); + virtual void InitLoop(); + virtual HRESULT SwitchFullscreen(); + virtual HRESULT Setup2D(bool Force = false); + virtual HRESULT SetupLines(); + + virtual const char *GetName() { + return ""; + }; + virtual HRESULT DisplayDebugInfo() { + return E_FAIL; + }; + virtual HRESULT DrawShaderQuad() { + return E_FAIL; + } + + virtual float GetScaleRatioX() const { + return 1.0f; + } + virtual float GetScaleRatioY() const { + return 1.0f; + } + + HRESULT ClipCursor(); + HRESULT UnclipCursor(); + + CBObject *GetObjectAt(int X, int Y); + void DeleteRectList(); + + virtual HRESULT StartSpriteBatch() { + return S_OK; + }; + virtual HRESULT EndSpriteBatch() { + return S_OK; + }; + bool PointInViewport(POINT *P); + uint32 _forceAlphaColor; + HINSTANCE _instance; + HWND _window; + HWND _clipperWindow; + bool _active; + bool _ready; + bool _windowed; + RECT _windowRect; + RECT _viewportRect; + RECT _screenRect; + RECT _monitorRect; + int _bPP; + int _height; + int _width; + + CBArray _rectList; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BResourceFile.cpp b/engines/wintermute/Base/BResourceFile.cpp new file mode 100644 index 0000000000..805868e5c8 --- /dev/null +++ b/engines/wintermute/Base/BResourceFile.cpp @@ -0,0 +1,103 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BResourceFile.h" +#include "engines/wintermute/Base/BResources.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::~CBResourceFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Open(const Common::String &Filename) { + Close(); + + if (CBResources::GetFile(Filename.c_str(), _data, _size)) { + _pos = 0; + return S_OK; + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Close() { + _data = NULL; + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { + if (!_data || _pos + Size > _size) return E_FAIL; + + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { + if (!_data) return E_FAIL; + + int32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BResourceFile.h b/engines/wintermute/Base/BResourceFile.h new file mode 100644 index 0000000000..721134dd84 --- /dev/null +++ b/engines/wintermute/Base/BResourceFile.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCEFILE_H +#define WINTERMUTE_BRESOURCEFILE_H + +#include "engines/wintermute/Base/BFile.h" + +namespace WinterMute { + +class CBResourceFile : public CBFile { +public: + CBResourceFile(CBGame *inGame); + virtual ~CBResourceFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BResources.cpp b/engines/wintermute/Base/BResources.cpp new file mode 100644 index 0000000000..d0714abaf2 --- /dev/null +++ b/engines/wintermute/Base/BResources.cpp @@ -0,0 +1,2830 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/BResources.h" +#include "common/str.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + + +////////////////////////////////////////////////////////////////////////// +bool CBResources::GetFile(const char *fileName, byte *&buffer, uint32 &size) { + // better! + if (scumm_stricmp(fileName, "invalid.bmp") == 0) { + buffer = invalid; + size = sizeof(invalid); + return true; + } else if (scumm_stricmp(fileName, "invalid_debug.bmp") == 0) { + buffer = invaliddebug; + size = sizeof(invaliddebug); + return true; + } else if (scumm_stricmp(fileName, "syste_font.bmp") == 0) { + buffer = systemfont; + size = sizeof(systemfont); + return true; + } + + + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BResources.h b/engines/wintermute/Base/BResources.h new file mode 100644 index 0000000000..26d92af525 --- /dev/null +++ b/engines/wintermute/Base/BResources.h @@ -0,0 +1,41 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +namespace WinterMute { + +class CBResources { +public: + static bool GetFile(const char *fileName, byte *&buffer, uint32 &size); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSaveThumbFile.cpp b/engines/wintermute/Base/BSaveThumbFile.cpp new file mode 100644 index 0000000000..66f1e8a95f --- /dev/null +++ b/engines/wintermute/Base/BSaveThumbFile.cpp @@ -0,0 +1,146 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSaveThumbFile.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { + Close(); + + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; + + char *TempFilename = new char[strlen(Filename.c_str()) - 8]; + strcpy(TempFilename, Filename.c_str() + 9); + for (int i = 0; i < strlen(TempFilename); i++) { + if (TempFilename[i] < '0' || TempFilename[i] > '9') { + TempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int Slot = atoi(TempFilename); + delete [] TempFilename; + + char SlotFilename[MAX_PATH + 1]; + Game->GetSaveSlotFilename(Slot, SlotFilename); + CBPersistMgr *pm = new CBPersistMgr(Game); + if (!pm) return E_FAIL; + + Game->_dEBUG_AbsolutePathWarning = false; + if (FAILED(pm->InitLoad(SlotFilename))) { + Game->_dEBUG_AbsolutePathWarning = true; + delete pm; + return E_FAIL; + } + Game->_dEBUG_AbsolutePathWarning = true; + + HRESULT res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = S_OK; + } else res = E_FAIL; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { + if (!_data || _pos + Size > _size) return E_FAIL; + + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { + if (!_data) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbFile.h b/engines/wintermute/Base/BSaveThumbFile.h new file mode 100644 index 0000000000..71bdb46431 --- /dev/null +++ b/engines/wintermute/Base/BSaveThumbFile.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/Base/BFile.h" + +namespace WinterMute { + +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp new file mode 100644 index 0000000000..58ddbe5eca --- /dev/null +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BSaveThumbHelper.h" +#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { + if (DoFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + Game->DisplayContent(false); + Game->_renderer->Flip(); + + Game->DisplayContent(false); + Game->_renderer->Flip(); + } + + CBImage *Screenshot = Game->_renderer->TakeScreenshot(); + if (!Screenshot) return E_FAIL; + + // normal thumbnail + if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { + _thumbnail = new CBImage(Game); + _thumbnail->CopyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); + } + + + delete Screenshot; + Screenshot = NULL; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbHelper.h b/engines/wintermute/Base/BSaveThumbHelper.h new file mode 100644 index 0000000000..36c21363c4 --- /dev/null +++ b/engines/wintermute/Base/BSaveThumbHelper.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + HRESULT StoreThumbnail(bool DoFlip = false); + + CBImage *_thumbnail; + CBImage *_richThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp new file mode 100644 index 0000000000..2b575befa5 --- /dev/null +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -0,0 +1,473 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Base/BScriptHolder.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + SetName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Cleanup() { + delete[] _filename; + _filename = NULL; + + int i; + + for (i = 0; i < _scripts.GetSize(); i++) { + _scripts[i]->Finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.RemoveAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::SetFilename(const char *Filename) { + if (_filename != NULL) delete [] _filename; + + _filename = new char [strlen(Filename) + 1]; + if (_filename != NULL) strcpy(_filename, Filename); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { + int NumHandlers = 0; + + HRESULT ret = E_FAIL; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->InvokeEventHandler(EventName, Unbreakable); + if (handler) { + //_scripts.Add(handler); + NumHandlers++; + ret = S_OK; + } + } + } + if (NumHandlers > 0 && Unbreakable) Game->_scEngine->TickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "DEBUG_CrashMe") == 0) { + Stack->CorrectParams(0); + byte *p = 0; + *p = 10; + Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ApplyEvent") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + HRESULT ret; + ret = ApplyEvent(val->GetString()); + + if (SUCCEEDED(ret)) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CanHandleEvent") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(CanHandleEvent(Stack->Pop()->GetString())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CanHandleMethod") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(CanHandleMethod(Stack->Pop()->GetString())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AttachScript") == 0) { + Stack->CorrectParams(1); + Stack->PushBool(SUCCEEDED(AddScript(Stack->Pop()->GetString()))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DetachScript") == 0) { + Stack->CorrectParams(2); + const char *Filename = Stack->Pop()->GetString(); + bool KillThreads = Stack->Pop()->GetBool(false); + bool ret = false; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + _scripts[i]->Finish(KillThreads); + ret = true; + break; + } + } + Stack->PushBool(ret); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IsScriptRunning") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + bool ret = false; + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + Stack->PushBool(ret); + + return S_OK; + } else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Filename") == 0) { + _scValue->SetString(_filename); + return _scValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } else return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptHolder::ScToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return CBBase::SaveAsText(Buffer, Indent); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_freezable)); + PersistMgr->Transfer(TMEMBER(_name)); + _scripts.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::AddScript(const char *Filename) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, _name); + return S_OK; + } + } + } + + CScScript *scr = Game->_scEngine->RunScript(Filename, this); + if (!scr) { + if (Game->_editorForceScripts) { + // editor hack + scr = new CScScript(Game, Game->_scEngine); + scr->_filename = new char[strlen(Filename) + 1]; + strcpy(scr->_filename, Filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.Add(scr); + Game->_scEngine->_scripts.Add(scr); + Game->GetDebugMgr()->OnScriptInit(scr); + + return S_OK; + } + return E_FAIL; + } else { + scr->_freezable = _freezable; + _scripts.Add(scr); + return S_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] == Script) { + _scripts.RemoveAt(i); + break; + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::CanHandleEvent(const char *EventName) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->CanHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::CanHandleMethod(const char *MethodName) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->CanHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + Game->LOG(0, "'PROPERTY' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + char *PropName = NULL; + char *PropValue = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] PropName; + PropName = new char[strlen((char *)params) + 1]; + if (PropName) strcpy(PropName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] PropValue; + PropValue = new char[strlen((char *)params) + 1]; + if (PropValue) strcpy(PropValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Syntax error in PROPERTY definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + Game->LOG(0, "Error loading PROPERTY definition"); + return E_FAIL; + } + + + CScValue *val = new CScValue(Game); + val->SetString(PropValue); + ScSetProperty(PropName, val); + + delete val; + delete[] PropName; + delete[] PropValue; + PropName = NULL; + PropValue = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::MakeFreezable(bool Freezable) { + _freezable = Freezable; + for (int i = 0; i < _scripts.GetSize(); i++) + _scripts[i]->_freezable = Freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::InvokeMethodThread(const char *MethodName) { + for (int i = _scripts.GetSize() - 1; i >= 0; i--) { + if (_scripts[i]->CanHandleMethod(MethodName)) { + + CScScript *thread = new CScScript(Game, _scripts[i]->_engine); + if (thread) { + HRESULT ret = thread->CreateMethodThread(_scripts[i], MethodName); + if (SUCCEEDED(ret)) { + _scripts[i]->_engine->_scripts.Add(thread); + Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], MethodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { + strcpy(Buf, ScToString()); + if (_name && strcmp(_name, "") != 0) { + strcat(Buf, " Name: "); + strcat(Buf, _name); + } + if (_filename) { + strcat(Buf, " File: "); + strcat(Buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::SendEvent(const char *EventName) { + return SUCCEEDED(ApplyEvent((char *)EventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h new file mode 100644 index 0000000000..83df7dc3e0 --- /dev/null +++ b/engines/wintermute/Base/BScriptHolder.h @@ -0,0 +1,74 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CBScriptHolder : public CBScriptable { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + virtual CScScript *InvokeMethodThread(const char *MethodName); + virtual void MakeFreezable(bool Freezable); + bool CanHandleEvent(const char *EventName); + virtual bool CanHandleMethod(const char *EventMethod); + HRESULT Cleanup(); + HRESULT RemoveScript(CScScript *Script); + HRESULT AddScript(const char *Filename); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); + void SetFilename(const char *Filename); + HRESULT ParseProperty(byte *Buffer, bool Complete = true); + char *_filename; + bool _freezable; + bool _ready; + + CBArray _scripts; + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + virtual void ScDebuggerDesc(char *Buf, int BufSize); + // IWmeObject +public: + virtual bool SendEvent(const char *EventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp new file mode 100644 index 0000000000..b7dd2d5be1 --- /dev/null +++ b/engines/wintermute/Base/BScriptable.cpp @@ -0,0 +1,188 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BScriptable.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool NoValue, bool Persistable): CBNamedObject(inGame) { + _refCount = 0; + + if (NoValue) _scValue = NULL; + else _scValue = new CScValue(Game); + + _persistable = Persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(_refCount>0) Game->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + /* + Stack->CorrectParams(0); + Stack->PushNULL(); + Script->RuntimeError("Call to undefined method '%s'.", Name); + + return S_OK; + */ + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::ScGetProperty(const char *Name) { + if (!_scProp) _scProp = new CScValue(Game); + if (_scProp) return _scProp->GetProp(Name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::ScSetProperty(const char *Name, CScValue *Value) { + if (!_scProp) _scProp = new CScValue(Game); + if (_scProp) return _scProp->SetProp(Name, Value); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::ScToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::ScToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::ScToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::ScToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::ScToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetString(const char *Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetInt(int Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetFloat(double Val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScSetBool(bool Val) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBScriptable::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(_refCount)); + PersistMgr->Transfer(TMEMBER(_scProp)); + PersistMgr->Transfer(TMEMBER(_scValue)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::ScCompare(CBScriptable *Val) { + if (this < Val) return -1; + else if (this > Val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::ScDebuggerDesc(char *Buf, int BufSize) { + strcpy(Buf, ScToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::CanHandleMethod(char *EventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::InvokeMethodThread(const char *MethodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::DbgGetNativeClass() { + return GetClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::DbgGetProperty(const char *Name) { + return ScGetProperty((char *)Name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h new file mode 100644 index 0000000000..5a24bde8e8 --- /dev/null +++ b/engines/wintermute/Base/BScriptable.h @@ -0,0 +1,80 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/Base/BNamedObject.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *InvokeMethodThread(const char *MethodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool NoValue = false, bool Persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool CanHandleMethod(char *EventMethod); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + virtual void *ScToMemBuffer(); + virtual int ScToInt(); + virtual double ScToFloat(); + virtual bool ScToBool(); + virtual void ScSetString(const char *Val); + virtual void ScSetInt(int Val); + virtual void ScSetFloat(double Val); + virtual void ScSetBool(bool Val); + virtual int ScCompare(CBScriptable *Val); + virtual void ScDebuggerDesc(char *Buf, int BufSize); + int _refCount; + CScValue *_scValue; + CScValue *_scProp; + +public: + // IWmeDebugObject + const char *DbgGetNativeClass(); + IWmeDebugProp *DbgGetProperty(const char *Name); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp new file mode 100644 index 0000000000..5df469934f --- /dev/null +++ b/engines/wintermute/Base/BSound.cpp @@ -0,0 +1,266 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSoundMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + _sound = NULL; + _soundFilename = NULL; + + _soundType = SOUND_SFX; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (_sound) Game->_soundMgr->removeSound(_sound); + _sound = NULL; + + delete[] _soundFilename; + _soundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) { + if (_sound) { + Game->_soundMgr->removeSound(_sound); + _sound = NULL; + } + delete[] _soundFilename; + _soundFilename = NULL; + + _sound = Game->_soundMgr->addSound(Filename, Type, Streamed); + if (_sound) { + _soundFilename = new char[strlen(Filename) + 1]; + strcpy(_soundFilename, Filename); + + _soundType = Type; + _soundStreamed = Streamed; + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetSoundSimple() { + _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->SetPosition(_soundPosition); + _sound->SetLooping(_soundLooping); + _sound->SetPrivateVolume(_soundPrivateVolume); + _sound->SetLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->Resume(); + else return S_OK; + } else return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::GetLength() { + if (_sound) return _sound->GetLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Play(bool Looping) { + if (_sound) { + _soundPaused = false; + return _sound->Play(Looping, _soundPosition); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Stop() { + if (_sound) { + _soundPaused = false; + return _sound->Stop(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Pause(bool FreezePaused) { + if (_sound) { + _soundPaused = true; + if (FreezePaused) _sound->_freezePaused = true; + return _sound->Pause(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->Resume(); + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { + if (PersistMgr->_saving && _sound) { + _soundPlaying = _sound->IsPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) _soundPosition = _sound->GetPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (PersistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_soundFilename)); + PersistMgr->Transfer(TMEMBER(_soundLooping)); + PersistMgr->Transfer(TMEMBER(_soundPaused)); + PersistMgr->Transfer(TMEMBER(_soundFreezePaused)); + PersistMgr->Transfer(TMEMBER(_soundPlaying)); + PersistMgr->Transfer(TMEMBER(_soundPosition)); + PersistMgr->Transfer(TMEMBER(_soundPrivateVolume)); + PersistMgr->Transfer(TMEMBER(_soundStreamed)); + PersistMgr->Transfer(TMEMBER_INT(_soundType)); + PersistMgr->Transfer(TMEMBER(_soundLoopStart)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::IsPlaying() { + return _sound && _sound->IsPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::IsPaused() { + return _sound && _soundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPositionTime(uint32 Time) { + if (!_sound) return E_FAIL; + _soundPosition = Time; + HRESULT ret = _sound->SetPosition(_soundPosition); + if (_sound->IsPlaying()) _soundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::GetPositionTime() { + if (!_sound) return 0; + + if (!_sound->IsPlaying()) return 0; + else return _sound->GetPosition(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetVolume(int Volume) { + if (!_sound) return E_FAIL; + else return _sound->SetPrivateVolume(Volume); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPrivateVolume(int Volume) { + if (!_sound) return E_FAIL; + else return _sound->_privateVolume = Volume; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSound::GetVolume() { + if (!_sound) return 0; + else return _sound->_privateVolume; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetLoopStart(uint32 Pos) { + if (!_sound) return E_FAIL; + else { + _sound->SetLoopStart(Pos); + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::SetPan(float Pan) { + if (_sound) return _sound->SetPan(Pan); + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSound::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { + if (!_sound) return S_OK; + + if (Type != _sFXType || Param1 != _sFXParam1 || Param2 != _sFXParam2 || Param3 != _sFXParam3 || Param4 != _sFXParam4) { + HRESULT Ret = _sound->ApplyFX(Type, Param1, Param2, Param3, Param4); + + _sFXType = Type; + _sFXParam1 = Param1; + _sFXParam2 = Param2; + _sFXParam3 = Param3; + _sFXParam4 = Param4; + + return Ret; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h new file mode 100644 index 0000000000..a9d1a0b5af --- /dev/null +++ b/engines/wintermute/Base/BSound.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/Base/BSoundBuffer.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CBSound : public CBBase { +public: + HRESULT SetPan(float Pan); + int _soundPrivateVolume; + int GetVolume(); + HRESULT SetVolume(int Volume); + HRESULT SetPrivateVolume(int Volume); + HRESULT SetLoopStart(uint32 Pos); + uint32 GetPositionTime(); + HRESULT SetPositionTime(uint32 Time); + bool _soundPaused; + bool _soundFreezePaused; + bool IsPlaying(); + bool IsPaused(); + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + HRESULT Resume(); + HRESULT Pause(bool FreezePaused = false); + HRESULT Stop(); + HRESULT Play(bool Looping = false); + uint32 GetLength(); + bool _soundStreamed; + TSoundType _soundType; + char *_soundFilename; + HRESULT SetSoundSimple(); + HRESULT SetSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + HRESULT ApplyFX(TSFXType Type = SFX_NONE, float Param1 = 0, float Param2 = 0, float Param3 = 0, float Param4 = 0); + +private: + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp new file mode 100644 index 0000000000..9dcbbadf7e --- /dev/null +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -0,0 +1,397 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BSoundBuffer.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { + _stream = NULL; + _handle = new Audio::SoundHandle; +// _sync = NULL; + + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 100; + + _looping = false; + _loopStart = 0; + + _type = SOUND_SFX; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { +#if 0 + Stop(); + + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } + + if (_file) { + Game->_fileManager->CloseFile(_file); + _file = NULL; + } + + SAFE_DELETE_ARRAY(_filename); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + _streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload); +#if 0 + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } +#endif + delete _stream; + _stream = NULL; + + if (_file) Game->_fileManager->CloseFile(_file); + + _file = Game->_fileManager->OpenFile(Filename); + if (!_file) { + Game->LOG(0, "Error opening sound file '%s'", Filename); + return E_FAIL; + } + + _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES); + CBUtils::SetString(&_filename, Filename); + + return S_OK; +#if 0 + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { + Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), Filename); + return E_FAIL; + } + + CBUtils::SetString(&_filename, Filename); + + /* + HRESULT res; + bool NewlyCreated = false; + + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = Game->_fileManager->OpenFile(Filename); + if(!_file){ + Game->LOG(0, "Error opening sound file '%s'", Filename); + return E_FAIL; + } + // switch to streamed for big files + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!_soundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(_file); + if(FAILED(res)){ + Game->LOG(res, "Error creating sound buffer for file '%s'", Filename); + return res; + } + } + + + + // store filename + if(!_filename){ + _filename = new char[strlen(Filename)+1]; + strcpy(_filename, Filename); + } + + // close file (if not streaming) + if(!_streamed && _file){ + Game->_fileManager->CloseFile(_file); + _file = NULL; + } + */ + + return S_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { + warning("Play: %s", _filename); + if (_stream) { + SetLooping(Looping); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream); + //BASS_ChannelPlay(_stream, TRUE); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetLooping(bool looping) { +#if 0 + _looping = looping; + + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Resume() { +#if 0 + if (_stream) { + BASS_ChannelPlay(_stream, FALSE); + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Stop() { +#if 0 + if (_stream) { + BASS_ChannelStop(_stream); + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::Pause() { +#if 0 + if (_stream) { + BASS_ChannelPause(_stream); + } +#endif + return S_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::GetLength() { +#if 0 + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(_stream, len); +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::SetType(TSoundType Type) { + _type = Type; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetVolume(int Volume) { +#if 0 + if (_stream) { + BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); + } +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { +#if 0 + _privateVolume = Volume; + + switch (_type) { + case SOUND_SFX: + Volume = Game->_soundMgr->_volumeSFX; + break; + case SOUND_SPEECH: + Volume = Game->_soundMgr->_volumeSpeech; + break; + case SOUND_MUSIC: + Volume = Game->_soundMgr->_volumeMusic; + break; + } +#endif + return SetVolume(Volume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::IsPlaying() { +#if 0 + return _freezePaused || BASS_ChannelIsActive(_stream) == BASS_ACTIVE_PLAYING; +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::GetPosition() { +#if 0 + if (_stream) { + QWORD len = BASS_ChannelGetPosition(_stream, BASS_POS_BYTE); + return 1000 * BASS_ChannelBytes2Seconds(_stream, len); + } else return 0; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { +#if 0 + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetLoopStart(uint32 Pos) { + _loopStart = Pos; +#if 0 + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; + } + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return S_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::SetPan(float Pan) { +#if 0 + if (_stream) { + BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_PAN, Pan); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { +#if 0 + switch (Type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } +#endif + return S_OK; +} + +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::FileCloseProc(void *user) { + /* + CBFile* file = static_cast(user); + file->Game->_fileManager->CloseFile(file); + */ +} + +////////////////////////////////////////////////////////////////////////// +QWORD CBSoundBuffer::FileLenProc(void *user) { + CBFile *file = static_cast(user); + return file->GetSize(); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::FileReadProc(void *buffer, uint32 length, void *user) { + CBFile *file = static_cast(user); + uint32 oldPos = file->GetPos(); + file->Read(buffer, length); + return file->GetPos() - oldPos; +} + +////////////////////////////////////////////////////////////////////////// +BOOL CBSoundBuffer::FileSeekProc(QWORD offset, void *user) { + CBFile *file = static_cast(user); + return SUCCEEDED(file->Seek(offset)); +} +#endif +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h new file mode 100644 index 0000000000..5445376555 --- /dev/null +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -0,0 +1,102 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "engines/wintermute/Base/BBase.h" +//#include "bass.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + HRESULT Pause(); + HRESULT Play(bool Looping = false, uint32 StartSample = 0); + HRESULT Resume(); + HRESULT Stop(); + bool IsPlaying(); + + void SetLooping(bool looping); + + uint32 GetPosition(); + HRESULT SetPosition(uint32 Pos); + uint32 GetLength(); + + HRESULT SetLoopStart(uint32 Pos); + uint32 GetLoopStart() const { + return _loopStart; + } + + HRESULT SetPan(float Pan); + HRESULT SetPrivateVolume(int Volume); + HRESULT SetVolume(int Volume); + + void SetType(TSoundType Type); + + HRESULT LoadFromFile(const char *Filename, bool ForceReload = false); + void SetStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); + HRESULT ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + TSoundType _type; + bool _looping; + CBFile *_file; + char *_filename; + bool _streamed; + int _privateVolume; + + /*static void CALLBACK LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user); + + static void CALLBACK FileCloseProc(void *user); + static QWORD CALLBACK FileLenProc(void *user); + static uint32 CALLBACK FileReadProc(void *buffer, uint32 length, void *user); + static BOOL CALLBACK FileSeekProc(QWORD offset, void *user);*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp new file mode 100644 index 0000000000..d0d757777f --- /dev/null +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -0,0 +1,327 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + _soundAvailable = false; + + _volumeSFX = _volumeSpeech = _volumeMusic = _volumeMaster = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::cleanup() { + for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; + _sounds.RemoveAll(); +#if 0 + BASS_Free(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::saveSettings() { + if (_soundAvailable) { + Game->_registry->WriteInt("Audio", "MasterVolume", _volumeMaster); + + Game->_registry->WriteInt("Audio", "SFXVolume", _volumeSFX); + Game->_registry->WriteInt("Audio", "SpeechVolume", _volumeSpeech); + Game->_registry->WriteInt("Audio", "MusicVolume", _volumeMusic); + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::initialize() { + _soundAvailable = false; +#if 0 + +#ifdef __IPHONEOS__ +#define BASS_CONFIG_IOS_MIXAUDIO 34 + BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); +#endif + + + if (HIWORD(BASS_GetVersion()) != BASSVERSION) { + Game->LOG(0, "An incorrect version of BASS was loaded"); + return E_FAIL; + } + + if (!BASS_Init(-1, 44100, 0, 0, NULL)) { + Game->LOG(0, "Can't initialize sound device"); + return E_FAIL; + } +#endif + + _volumeMaster = Game->_registry->ReadInt("Audio", "MasterVolume", 100); + + _volumeSFX = Game->_registry->ReadInt("Audio", "SFXVolume", 100); + _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100); + _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); + + _soundAvailable = true; + setMasterVolumePercent(_volumeMaster); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::initLoop() { + if (!_soundAvailable) return S_OK; +#if 0 + + BASS_Update(500); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool Streamed) { + if (!_soundAvailable) return NULL; + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::GetExtension(Filename); + if (StringUtil::CompareNoCase(ext, "wav")) { + AnsiString path = PathUtil::GetDirectoryName(Filename); + AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); + + AnsiString newFile = PathUtil::Combine(path, name + "ogg"); + CBFile *file = Game->_fileManager->OpenFile(newFile.c_str()); + if (file) { + Filename = newFile.c_str(); + Game->_fileManager->CloseFile(file); + } + } + + sound = new CBSoundBuffer(Game); + if (!sound) return NULL; + + sound->SetStreaming(Streamed); + sound->SetType(Type); + + + HRESULT res = sound->LoadFromFile(Filename); + if (FAILED(res)) { + Game->LOG(res, "Error loading sound '%s'", Filename); + delete sound; + return NULL; + } + + // set volume appropriately + switch (Type) { + case SOUND_SFX: + sound->SetVolume(_volumeSFX); + break; + case SOUND_SPEECH: + sound->SetVolume(_volumeSpeech); + break; + case SOUND_MUSIC: + sound->SetVolume(_volumeMusic); + break; + } + + // register sound + _sounds.Add(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::addSound(CBSoundBuffer *Sound, TSoundType Type) { + if (!Sound) return E_FAIL; + + // set volume appropriately + switch (Type) { + case SOUND_SFX: + Sound->SetVolume(_volumeSFX); + break; + case SOUND_SPEECH: + Sound->SetVolume(_volumeSpeech); + break; + case SOUND_MUSIC: + Sound->SetVolume(_volumeMusic); + break; + } + + // register sound + _sounds.Add(Sound); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::removeSound(CBSoundBuffer *Sound) { + + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i] == Sound) { + delete _sounds[i]; + _sounds.RemoveAt(i); + return S_OK; + } + } + + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::setVolume(TSoundType Type, int Volume) { + if (!_soundAvailable) return S_OK; + + switch (Type) { + case SOUND_SFX: + _volumeSFX = Volume; + break; + case SOUND_SPEECH: + _volumeSpeech = Volume; + break; + case SOUND_MUSIC: + _volumeMusic = Volume; + break; + } + + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume); + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::setVolumePercent(TSoundType Type, byte Percent) { + return setVolume(Type, Percent); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getVolumePercent(TSoundType Type) { + int Volume; + switch (Type) { + case SOUND_SFX: + Volume = _volumeSFX; + break; + case SOUND_SPEECH: + Volume = _volumeSpeech; + break; + case SOUND_MUSIC: + Volume = _volumeMusic; + break; + } + + return (byte)Volume; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::setMasterVolumePercent(byte Percent) { + _volumeMaster = Percent; +#if 0 + BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolumePercent() { +#if 0 + uint32 val = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM); + return (float)val / 10000.0f * 100.0f; +#endif + return 0; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::pauseAll(bool IncludingMusic) { + + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { + _sounds[i]->Pause(); + _sounds[i]->_freezePaused = true; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSoundMgr::resumeAll() { + + for (int i = 0; i < _sounds.GetSize(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->Resume(); + _sounds[i]->_freezePaused = false; + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::posToPan(int X, int Y) { + float relPos = (float)X / ((float)Game->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h new file mode 100644 index 0000000000..f790693e71 --- /dev/null +++ b/engines/wintermute/Base/BSoundMgr.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BSoundBuffer.h" +//#include "bass.h" + +namespace WinterMute { + +class CBSoundMgr : public CBBase { +public: + float posToPan(int X, int Y); + HRESULT resumeAll(); + HRESULT pauseAll(bool IncludingMusic = true); + HRESULT cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte getMasterVolumePercent(); + HRESULT setMasterVolumePercent(byte Percent); + byte getVolumePercent(TSoundType Type); + HRESULT setVolumePercent(TSoundType Type, byte Percent); + HRESULT setVolume(TSoundType Type, int Volume); + uint32 _volumeOriginal; + int _volumeMaster; + int _volumeMusic; + int _volumeSpeech; + int _volumeSFX; + HRESULT removeSound(CBSoundBuffer *Sound); + CBSoundBuffer *addSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + HRESULT addSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); + HRESULT initLoop(); + HRESULT initialize(); + bool _soundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + CBArray _sounds; + void saveSettings(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp new file mode 100644 index 0000000000..5720cd1f42 --- /dev/null +++ b/engines/wintermute/Base/BSprite.cpp @@ -0,0 +1,754 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::SetDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + SetName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::Cleanup() { + CBScriptHolder::Cleanup(); + + for (int i = 0; i < _frames.GetSize(); i++) + delete _frames[i]; + _frames.RemoveAll(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha) { + GetCurrentFrame(ZoomX, ZoomY); + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->AfterMove(); + + X = _owner->_posX; + Y = _owner->_posY; + } + + // draw frame + return Display(X, Y, Register, ZoomX, ZoomY, Alpha); +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { + CBFile *File = Game->_fileManager->OpenFile(Filename); + if (!File) { + Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); + if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); + else return LoadFile("invalid.bmp", LifeTime, CacheType); + } else { + Game->_fileManager->CloseFile(File); + File = NULL; + } + + HRESULT ret; + + AnsiString ext = PathUtil::GetExtension(Filename); + if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, "bmp") || StringUtil::CompareNoCase(ext, "tga") || StringUtil::CompareNoCase(ext, "png") || StringUtil::CompareNoCase(ext, "jpg")) { + CBFrame *frame = new CBFrame(Game); + CBSubFrame *subframe = new CBSubFrame(Game); + subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); + if (subframe->_surface == NULL) { + Game->LOG(0, "Error loading simple sprite '%s'", Filename); + ret = E_FAIL; + delete frame; + delete subframe; + } else { + CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->GetWidth(), subframe->_surface->GetHeight()); + frame->_subframes.Add(subframe); + _frames.Add(frame); + _currentFrame = 0; + ret = S_OK; + } + } else { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer) { + if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); + delete [] Buffer; + } + } + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + + Cleanup(); + + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + Game->LOG(0, "'SPRITE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + int frame_count = 1; + CBFrame *frame; + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.ScanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.ScanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.ScanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.ScanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.ScanStr((char *)params, "%b", &_streamed); + if (_streamed && LifeTime == -1) { + LifeTime = 500; + CacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.ScanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (Game->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.ScanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.ScanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.ScanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = LifeTime; + if (CacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(Game); + + if (FAILED(frame->LoadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + delete frame; + Game->LOG(0, "Error parsing frame %d", frame_count); + return E_FAIL; + } + + _frames.Add(frame); + frame_count++; + if (_currentFrame == -1) _currentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SPRITE definition"); + return E_FAIL; + } + _canBreak = !_continuous; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::Reset() { + if (_frames.GetSize() > 0) _currentFrame = 0; + else _currentFrame = -1; + + KillAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { + //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) return false; + + uint32 timer; + if (_owner && _owner->_freezable) timer = Game->_timer; + else timer = Game->_liveTimer; + + int LastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.GetSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (LastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (ZoomX != 100 || ZoomY != 100) { + _moveX = (int)((float)_moveX * (float)(ZoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(ZoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + KillAllSounds(); + } + ApplyEvent("FrameChanged"); + _frames[_currentFrame]->OneTimeDisplay(_owner, Game->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->Draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::GetSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.GetSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + + CBPlatform::SetRectEmpty(Rect); + for (int i = 0; i < _frames.GetSize(); i++) { + RECT frame; + RECT temp; + CBPlatform::CopyRect(&temp, Rect); + _frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); + CBPlatform::UnionRect(Rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "SPRITE {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) + Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (_editorMuted) + Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + + if (_editorBgFile) { + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + CBScriptHolder::SaveAsText(Buffer, Indent + 2); + + int i; + + // scripts + for (i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + + for (i = 0; i < _frames.GetSize(); i++) { + _frames[i]->SaveAsText(Buffer, Indent + 2); + } + + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { + CBScriptHolder::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_canBreak)); + PersistMgr->Transfer(TMEMBER(_changed)); + PersistMgr->Transfer(TMEMBER(_paused)); + PersistMgr->Transfer(TMEMBER(_continuous)); + PersistMgr->Transfer(TMEMBER(_currentFrame)); + PersistMgr->Transfer(TMEMBER(_editorAllFrames)); + PersistMgr->Transfer(TMEMBER(_editorBgAlpha)); + PersistMgr->Transfer(TMEMBER(_editorBgFile)); + PersistMgr->Transfer(TMEMBER(_editorBgOffsetX)); + PersistMgr->Transfer(TMEMBER(_editorBgOffsetY)); + PersistMgr->Transfer(TMEMBER(_editorMuted)); + PersistMgr->Transfer(TMEMBER(_finished)); + + _frames.Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_lastFrameTime)); + PersistMgr->Transfer(TMEMBER(_looping)); + PersistMgr->Transfer(TMEMBER(_moveX)); + PersistMgr->Transfer(TMEMBER(_moveY)); + PersistMgr->Transfer(TMEMBER(_owner)); + PersistMgr->Transfer(TMEMBER(_precise)); + PersistMgr->Transfer(TMEMBER(_streamed)); + PersistMgr->Transfer(TMEMBER(_streamedKeepLoaded)); + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetFrame") == 0) { + Stack->CorrectParams(1); + int Index = Stack->Pop()->GetInt(-1); + if (Index < 0 || Index >= _frames.GetSize()) { + Script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + Stack->PushNULL(); + } else Stack->PushNative(_frames[Index], true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteFrame") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + if (Val->IsInt()) { + int Index = Val->GetInt(-1); + if (Index < 0 || Index >= _frames.GetSize()) { + Script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->GetNative(); + for (int i = 0; i < _frames.GetSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.RemoveAt(i); + break; + } + } + } + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Reset") == 0) { + Stack->CorrectParams(0); + Reset(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddFrame") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + const char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBFrame *Frame = new CBFrame(Game); + if (Filename != NULL) { + CBSubFrame *Sub = new CBSubFrame(Game); + if (SUCCEEDED(Sub->SetSurface(Filename))) { + Sub->SetDefaultRect(); + Frame->_subframes.Add(Sub); + } else delete Sub; + } + _frames.Add(Frame); + + Stack->PushNative(Frame, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InsertFrame") == 0) { + Stack->CorrectParams(2); + int Index = Stack->Pop()->GetInt(); + if (Index < 0) Index = 0; + + CScValue *Val = Stack->Pop(); + const char *Filename = NULL; + if (!Val->IsNULL()) Filename = Val->GetString(); + + CBFrame *Frame = new CBFrame(Game); + if (Filename != NULL) { + CBSubFrame *Sub = new CBSubFrame(Game); + if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->_subframes.Add(Sub); + else delete Sub; + } + + if (Index >= _frames.GetSize()) _frames.Add(Frame); + else _frames.InsertAt(Index, Frame); + + Stack->PushNative(Frame, true); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pause") == 0) { + Stack->CorrectParams(0); + _paused = true; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Play") == 0) { + Stack->CorrectParams(0); + _paused = false; + Stack->PushNULL(); + return S_OK; + } + + else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumFrames") == 0) { + _scValue->SetInt(_frames.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CurrentFrame") == 0) { + _scValue->SetInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + _scValue->SetBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Looping") == 0) { + _scValue->SetBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Owner") == 0) { + if (_owner == NULL) _scValue->SetNULL(); + else _scValue->SetNative(_owner, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Finished") == 0) { + _scValue->SetBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Paused") == 0) { + _scValue->SetBool(_paused); + return _scValue; + } + + else return CBScriptHolder::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "CurrentFrame") == 0) { + _currentFrame = Value->GetInt(0); + if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + _precise = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Looping") == 0) { + _looping = Value->GetBool(); + return S_OK; + } + + else return CBScriptHolder::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSprite::ScToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSprite::KillAllSounds() { + for (int i = 0; i < _frames.GetSize(); i++) { + if (_frames[i]->_sound) _frames[i]->_sound->Stop(); + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h new file mode 100644 index 0000000000..8fa1656b37 --- /dev/null +++ b/engines/wintermute/Base/BSprite.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BScriptHolder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + HRESULT KillAllSounds(); + CBSurface *GetSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void Cleanup(); + void SetDefaults(); + bool _precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool _editorAllFrames; + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + int _moveY; + int _moveX; + HRESULT Display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void Reset(); + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; + HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + uint32 _lastFrameTime; + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + HRESULT AddFrame(const char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); + CBSprite(CBGame *inGame, CBObject *Owner = NULL); + virtual ~CBSprite(); + CBArray _frames; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp new file mode 100644 index 0000000000..f8196c5677 --- /dev/null +++ b/engines/wintermute/Base/BStringTable.cpp @@ -0,0 +1,229 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/StringUtil.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDuplicities) { + if (Key == NULL || Val == NULL) return E_FAIL; + + if (scumm_stricmp(Key, "@right-to-left") == 0) { + Game->_textRTL = true; + return S_OK; + } + + Common::String final_key = Key; + StringUtil::ToLowerCase(final_key); + + _stringsIter = _strings.find(final_key); + if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + + _strings[final_key] = Val; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::GetKey(const char *Str) { + if (Str == NULL || Str[0] != '/') return NULL; + + char *value = strchr((char *)Str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - Str]; + strncpy(key, Str + 1, value - Str - 1); + key[value - Str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = GetKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::Expand(char **Str, bool ForceExpand) { + if (Game->_doNotExpandStrings && !ForceExpand) return; + + if (Str == NULL || *Str == NULL || *Str[0] != '/') return; + + char *value = strchr(*Str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *Str]; + strncpy(key, *Str + 1, value - *Str - 1); + key[value - *Str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *Str; + *Str = new_str; + + if (strlen(*Str) > 0 && *Str[0] == '/') Expand(Str, ForceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { + if (Game->_doNotExpandStrings && !ForceExpand) return String; + + if (String == NULL || String[0] == '\0' || String[0] != '/') return String; + + const char *value = strchr(String + 1, '/'); + if (value == NULL) return String; + + char *key = new char[value - String]; + strncpy(key, String + 1, value - String - 1); + key[value - String - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return ExpandStatic(new_str, ForceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBStringTable::LoadFile(const char *Filename, bool ClearOld) { + Game->LOG(0, "Loading string table..."); + + if (ClearOld) _strings.clear(); + + uint32 Size; + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); + if (Buffer == NULL) { + Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + int Pos = 0; + + if (Size > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { + Pos += 3; + if (Game->_textEncoding != TEXT_UTF8) { + Game->_textEncoding = TEXT_UTF8; + //Game->_textEncoding = TEXT_ANSI; + Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else Game->_textEncoding = TEXT_ANSI; + + int LineLength = 0; + while (Pos < Size) { + LineLength = 0; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *line = new char[RealLength + 1]; + strncpy(line, (char *)&Buffer[Pos], RealLength); + line[RealLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (int i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + AddString(line, value, ClearOld); + } else if (line[0] != '\0') AddString(line, "", ClearOld); + } + + delete [] line; + Pos += LineLength + 1; + } + + delete [] Buffer; + + Game->LOG(0, " %d strings loaded", _strings.size()); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h new file mode 100644 index 0000000000..57c75ef1e9 --- /dev/null +++ b/engines/wintermute/Base/BStringTable.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *ExpandStatic(const char *String, bool ForceExpand = false); + HRESULT LoadFile(const char *Filename, bool DeleteAll = true); + void Expand(char **Str, bool ForceExpand = false); + HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + Common::HashMap _strings; + char *GetKey(const char *Str); +private: + Common::HashMap::iterator _stringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp new file mode 100644 index 0000000000..6b5d4e9f2e --- /dev/null +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + CBPlatform::SetRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + RECT rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custo_trans = false; + CBPlatform::SetRectEmpty(&rect); + char *surface_file = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + + case TOKEN_RECT: + parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.ScanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.ScanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.ScanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.ScanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.ScanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.ScanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.ScanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in SUBFRAME definition"); + return E_FAIL; + } + + if (surface_file != NULL) { + if (custo_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + } + + _alpha = DRGBA(ar, ag, ab, alpha); + if (custo_trans) _transparent = DRGBA(r, g, b, 0xFF); + + /* + if(_surface == NULL) + { + Game->LOG(0, "Error parsing sub-frame. Image not set."); + return E_FAIL; + } + */ + if (CBPlatform::IsRectEmpty(&rect)) SetDefaultRect(); + else _rect = rect; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (!_surface) return S_OK; + + if (Register != NULL && !_decoration) { + if (ZoomX == 100 && ZoomY == 100) { + Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, X - _hotspotX + _rect.left, Y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, ZoomX, ZoomY, Precise)); + } else { + Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (_hotspotX + _rect.left) * (ZoomX / 100)), (int)(Y - (_hotspotY + _rect.top) * (ZoomY / 100)), (int)((_rect.right - _rect.left) * (ZoomX / 100)), (int)((_rect.bottom - _rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); + } + } + if (Game->_suspendedRendering) return S_OK; + + HRESULT res; + + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) Alpha = _alpha; + + if (Rotate != 0.0f) { + res = _surface->DisplayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); + } else { + if (ZoomX == 100 && ZoomY == 100) res = _surface->DisplayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); + else res = _surface->DisplayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { + if (!Rect) return false; + + float RatioX = ScaleX / 100.0f; + float RatioY = ScaleY / 100.0f; + + CBPlatform::SetRect(Rect, + X - _hotspotX * RatioX, + Y - _hotspotY * RatioY, + X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX, + Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { + if (Complete) + Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); + + if (_surface && _surface->_filename != NULL) + Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); + + if (_transparent != 0xFFFF00FF) + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); + + RECT rect; + CBPlatform::SetRectEmpty(&rect); + if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + if (!CBPlatform::EqualRect(&rect, &_rect)) + Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + + if (_hotspotX != 0 || _hotspotY != 0) + Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + + if (_alpha != 0xFFFFFFFF) { + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + } + + if (_mirrorX) + Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + + if (_mirrorY) + Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + + if (_2DOnly) + Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + + if (_3DOnly) + Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + + if (_decoration) + Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + + if (_editorSelected) + Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + CBBase::SaveAsText(Buffer, Indent + 2); + + + if (Complete) + Buffer->PutTextIndent(Indent, "}\n\n"); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::SetDefaultRect() { + if (_surface) { + CBPlatform::SetRect(&_rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + } else CBPlatform::SetRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_2DOnly)); + PersistMgr->Transfer(TMEMBER(_3DOnly)); + PersistMgr->Transfer(TMEMBER(_alpha)); + PersistMgr->Transfer(TMEMBER(_decoration)); + PersistMgr->Transfer(TMEMBER(_editorSelected)); + PersistMgr->Transfer(TMEMBER(_hotspotX)); + PersistMgr->Transfer(TMEMBER(_hotspotY)); + PersistMgr->Transfer(TMEMBER(_rect)); + + PersistMgr->Transfer(TMEMBER(_surfaceFilename)); + PersistMgr->Transfer(TMEMBER(_cKDefault)); + PersistMgr->Transfer(TMEMBER(_cKRed)); + PersistMgr->Transfer(TMEMBER(_cKGreen)); + PersistMgr->Transfer(TMEMBER(_cKBlue)); + PersistMgr->Transfer(TMEMBER(_lifeTime)); + + PersistMgr->Transfer(TMEMBER(_keepLoaded)); + PersistMgr->Transfer(TMEMBER(_mirrorX)); + PersistMgr->Transfer(TMEMBER(_mirrorY)); + PersistMgr->Transfer(TMEMBER(_transparent)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetImage") == 0) { + Stack->CorrectParams(0); + + if (!_surfaceFilename) Stack->PushNULL(); + else Stack->PushString(_surfaceFilename); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetImage") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsNULL()) { + if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; + Stack->PushBool(true); + } else { + const char *Filename = Val->GetString(); + if (SUCCEEDED(SetSurface(Filename))) { + SetDefaultRect(); + Stack->PushBool(true); + } else Stack->PushBool(false); + } + + return S_OK; + } + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::ScGetProperty(const char *Name) { + if (!_scValue) _scValue = new CScValue(Game); + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaColor") == 0) { + + _scValue->SetInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TransparentColor") == 0) { + _scValue->SetInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is2DOnly") == 0) { + _scValue->SetBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is3DOnly") == 0) { + _scValue->SetBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorX") == 0) { + _scValue->SetBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorY") == 0) { + _scValue->SetBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + _scValue->SetBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotX") == 0) { + _scValue->SetInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotY") == 0) { + _scValue->SetInt(_hotspotY); + return _scValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "AlphaColor") == 0) { + _alpha = (uint32)Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is2DOnly") == 0) { + _2DOnly = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Is3DOnly") == 0) { + _3DOnly = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorX") == 0) { + _mirrorX = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MirrorY") == 0) { + _mirrorY = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Decoration") == 0) { + _decoration = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotX") == 0) { + _hotspotX = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HotspotY") == 0) { + _hotspotY = Value->GetInt(); + return S_OK; + } + + else return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSubFrame::ScToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SetSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + if (_surface) { + Game->_surfaceStorage->RemoveSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = Game->_surfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(Filename) + 1]; + strcpy(_surfaceFilename, Filename); + + _cKDefault = default_ck; + _cKRed = ck_red; + _cKGreen = ck_green; + _cKBlue = ck_blue; + _lifeTime = LifeTime; + _keepLoaded = KeepLoaded; + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSubFrame::SetSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return S_OK; + } + _surface = Game->_surfaceStorage->AddSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return S_OK; + else return E_FAIL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h new file mode 100644 index 0000000000..00462b1298 --- /dev/null +++ b/engines/wintermute/Base/BSubFrame.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + HRESULT SetSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT SetSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void SetDefaultRect(); + uint32 _transparent; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); + bool _editorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + RECT _rect; + + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + CBSurface *_surface; + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp new file mode 100644 index 0000000000..69b137813b --- /dev/null +++ b/engines/wintermute/Base/BSurface.cpp @@ -0,0 +1,196 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSurface.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = NULL; + + _pixelOpReady = false; + + _cKDefault = true; + _cKRed = _cKGreen = _cKBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface::~CBSurface() { + if (_pixelOpReady) EndPixelOp(); + if (_filename) delete [] _filename; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Restore() { + return E_FAIL; +} + + + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::IsTransparentAt(int X, int Y) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayHalfTrans(int X, int Y, RECT rect) { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DisplayTransZoom(X, Y, Rect, ZoomX, ZoomY, Alpha, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Create(int Width, int Height) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::StartPixelOp() { + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::EndPixelOp() { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::PutPixel(int X, int Y, byte R, byte G, byte B, int A) { + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::ComparePixel(int X, int Y, byte R, byte G, byte B, int A) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::IsTransparentAtLite(int X, int Y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::Invalidate() { + return E_FAIL; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurface::PrepareToDraw() { + _lastUsedTime = Game->_liveTimer; + + if (!_valid) { + //Game->LOG(0, "Reviving: %s", _filename); + return Create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + } else return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSurface::SetFilename(const char *Filename) { + delete[] _filename; + _filename = NULL; + if (!Filename) return; + + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); +} + +////////////////////////////////////////////////////////////////////////// +void CBSurface::SetSize(int Width, int Height) { + _width = Width; + _height = Height; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h new file mode 100644 index 0000000000..a7279a9217 --- /dev/null +++ b/engines/wintermute/Base/BSurface.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACE_H +#define WINTERMUTE_BSURFACE_H + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBSurface: public CBBase { +public: + virtual HRESULT Invalidate(); + virtual HRESULT PrepareToDraw(); + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + bool _keepLoaded; + + bool _pixelOpReady; + CBSurface(CBGame *inGame); + virtual ~CBSurface(); + + virtual HRESULT DisplayHalfTrans(int X, int Y, RECT rect); + virtual bool IsTransparentAt(int X, int Y); + virtual HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); + virtual HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + virtual HRESULT Restore(); + virtual HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + virtual HRESULT Create(int Width, int Height); + virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); + virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); + virtual bool ComparePixel(int X, int Y, byte R, byte G, byte B, int A = -1); + virtual HRESULT StartPixelOp(); + virtual HRESULT EndPixelOp(); + virtual bool IsTransparentAtLite(int X, int Y); + void SetFilename(const char *Filename); + void SetSize(int Width, int Height); + + int _referenceCount; + char *_filename; + + int GetWidth() { + return _width; + } + int GetHeight() { + return _height; + } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } +protected: + int _height; + int _width; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp new file mode 100644 index 0000000000..e4fc48d1e3 --- /dev/null +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -0,0 +1,480 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BRenderSDL.h" +//#include "SdlUtil.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/tga.h" +#include "common/stream.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + + _lockPixels = NULL; + _lockPitch = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBSurfaceSDL::~CBSurfaceSDL() { + //TODO + delete _surface; +#if 0 + if (_texture) SDL_DestroyTexture(_texture); + delete[] _alphaMask; + _alphaMask = NULL; + + Game->AddMem(-_width * _height * 4); +#endif +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +/* CBRenderSDL *renderer = static_cast(Game->_renderer); */ + Common::String strFileName(Filename); + + Graphics::ImageDecoder *imgDecoder; + + if (strFileName.hasSuffix(".png")) { + imgDecoder = new Graphics::PNGDecoder(); + } else if (strFileName.hasSuffix(".bmp")) { + warning("Loaded BMP WITH FILENAME!!!! %s", Filename); + imgDecoder = new Graphics::BitmapDecoder(); + } else if (strFileName.hasSuffix(".tga")) { + imgDecoder = new WinterMute::TGA(); + } else { + error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); + } + + CBFile *file = Game->_fileManager->OpenFile(Filename); + if (!file) return E_FAIL; + + imgDecoder->loadStream(*file->getMemStream()); + const Graphics::Surface *surface = imgDecoder->getSurface(); + Game->_fileManager->CloseFile(file); + + if (default_ck) { + ck_red = 255; + ck_green = 0; + ck_blue = 255; + } + + _width = surface->w; + _height = surface->h; + + bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); + /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ + } + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + /* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { + FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + } else { + FreeImage_Unload(img); + return -1; + } + } + + FreeImage_FlipVertical(img);*/ + + //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: +/* uint32 rmask = surface->format.rMax() << surface->format.rShift; + uint32 gmask = surface->format.gMax() << surface->format.gShift; + uint32 bmask = surface->format.bMax() << surface->format.bShift; + uint32 amask = surface->format.aMax();*/ + +// SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); + + // no alpha, set color key + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { + _surface = surface->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + } + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO + //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Surface-textures not fully ported yet"); + hasWarned = true; + } +#if 0 + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!_texture) { + SDL_FreeSurface(surf); + delete imgDecoder; + return E_FAIL; + } + + GenAlphaMask(surf); + + SDL_FreeSurface(surf); + delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. + + _cKDefault = default_ck; + _cKRed = ck_red; + _cKGreen = ck_green; + _cKBlue = ck_blue; +#endif + + if (!_filename || scumm_stricmp(_filename, Filename) != 0) { + SetFilename(Filename); + } + + if (_lifeTime == 0 || LifeTime == -1 || LifeTime > _lifeTime) + _lifeTime = LifeTime; + + _keepLoaded = KeepLoaded; + if (_keepLoaded) _lifeTime = -1; + + _valid = true; +#if 0 + Game->AddMem(_width * _height * 4); +#endif + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { + warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); + return; + + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) return; +#if 0 + SDL_LockSurface(surface); +#endif + bool hasColorKey; + uint32 colorKey; + uint8 ckRed, ckGreen, ckBlue; + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ //TODO + _alphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + uint32 pixel = GetPixel(surface, x, y); + + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + a = 0; + + _alphaMask[y * surface->w + x] = a; + if (a < 255) hasTransparency = true; + } + } +#if 0 + SDL_UnlockSurface(surface); +#endif + if (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { + warning("CBSurfaceSDL::GetPixel - Not ported yet"); + int bpp = surface->format.bytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(uint16 *)p; + break; + + case 3: +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + //else + return p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + return *(uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Create(int Width, int Height) { + warning("SurfaceSDL::Create not ported yet"); //TODO +#if 0 + CBRenderSDL *renderer = static_cast(Game->_renderer); + _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); +#endif + _width = Width; + _height = Height; +#if 0 + Game->AddMem(_width * _height * 4); +#endif + _valid = true; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { + warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO +#if 0 + CBRenderSDL *renderer = static_cast(Game->_renderer); + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); +#endif + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + _width = surface->w; + _height = surface->h; +#if 0 + Game->AddMem(_width * _height * 4); +#endif + _valid = true; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::IsTransparentAt not ported yet"); + hasWarned = true; + } +#if 0 + int access; + int width, height; + //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + + StartPixelOp(); + bool ret = IsTransparentAtLite(X, Y); + EndPixelOp(); + + return ret; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { + //if (!_lockPixels) return false; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); + hasWarned = true; + } +#if 0 + uint32 format; + int access; + int width, height; + + //SDL_QueryTexture(_texture, &format, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + if (!_alphaMask) return false; + else return _alphaMask[Y * width + X] <= 128; +#endif + return false; + /* + Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); + Uint32 pixel = dst[X]; + + SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); + SDL_FreeFormat(pixelFormat); + + return a <= 128; + */ +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::StartPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::EndPixelOp() { + //SDL_UnlockTexture(_texture); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, 100, 100, 0xFFFFFFFF, true, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, !Transparent, BlendMode, MirrorX, MirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { + return DrawSprite(X, Y, &Rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { + CBRenderSDL *renderer = static_cast(Game->_renderer); + + if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. + hasWarned = true; + } +#if 0 + byte r = D3DCOLGetR(Alpha); + byte g = D3DCOLGetG(Alpha); + byte b = D3DCOLGetB(Alpha); + byte a = D3DCOLGetA(Alpha); + + SDL_SetTextureColorMod(_texture, r, g, b); + SDL_SetTextureAlphaMod(_texture, a); + + if (AlphaDisable) + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); + else + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = Rect->left; + srcRect.top = Rect->top; + srcRect.setWidth(Rect->right - Rect->left); + srcRect.setHeight(Rect->bottom - Rect->top); + + Common::Rect position; + position.left = X; + position.top = Y; + // TODO: Scaling... + + position.setWidth((float)srcRect.width() * ZoomX / 100.f); + position.setHeight((float)srcRect.height() * ZoomX / 100.f); + + renderer->ModTargetRect(&position); + + position.left += offsetX; + position.top += offsetY; + + renderer->drawFromSurface(_surface, &srcRect, &position); +#if 0 + SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); +#endif + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h new file mode 100644 index 0000000000..07c9b7cc6b --- /dev/null +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -0,0 +1,81 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESDL_H +#define WINTERMUTE_BSURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/Base/BSurface.h" +#include "graphics/surface.h" + +namespace WinterMute { + +class CBSurfaceSDL : public CBSurface { +public: + CBSurfaceSDL(CBGame *inGame); + ~CBSurfaceSDL(); + + HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); + HRESULT Create(int Width, int Height); + + HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + + bool IsTransparentAt(int X, int Y); + bool IsTransparentAtLite(int X, int Y); + + HRESULT StartPixelOp(); + HRESULT EndPixelOp(); + + + HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); + HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); + + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + +private: +// SDL_Texture *_texture; + Graphics::Surface *_surface; + + HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); + void GenAlphaMask(Graphics::Surface *surface); + uint32 GetPixel(Graphics::Surface *surface, int x, int y); + + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp new file mode 100644 index 0000000000..538b9a2649 --- /dev/null +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + Cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::Cleanup(bool Warn) { + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); + delete _surfaces[i]; + } + _surfaces.RemoveAll(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::InitLoop() { + if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { + _lastCleanupTime = Game->_liveTimer; + SortSurfaces(); + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->Invalidate(); + } + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.RemoveAt(i); + } + break; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { + for (int i = 0; i < _surfaces.GetSize(); i++) { + if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + CBFile *File = Game->_fileManager->OpenFile(Filename); + if (!File) { + if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); + if (Game->_dEBUG_DebugMode) + return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + else + return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + } else Game->_fileManager->CloseFile(File); + + + CBSurface *surface; + surface = new CBSurfaceSDL(Game); + + + if (!surface) return NULL; + + if (FAILED(surface->Create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.Add(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::RestoreAll() { + HRESULT ret; + for (int i = 0; i < _surfaces.GetSize(); i++) { + ret = _surfaces[i]->Restore(); + if (ret != S_OK) { + Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return S_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) +{ + + if(!PersistMgr->_saving) Cleanup(false); + + PersistMgr->Transfer(TMEMBER(Game)); + + //_surfaces.Persist(PersistMgr); + + return S_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSurfaceStorage::SortSurfaces() { + qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::SurfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + + + // sort by validity + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h new file mode 100644 index 0000000000..5491252557 --- /dev/null +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 _lastCleanupTime; + HRESULT InitLoop(); + HRESULT SortSurfaces(); + static int SurfaceSortCB(const void *arg1, const void *arg2); + HRESULT Cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + HRESULT RestoreAll(); + CBSurface *AddSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT RemoveSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + CBArray _surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp new file mode 100644 index 0000000000..74553f3031 --- /dev/null +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -0,0 +1,127 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BTransitionMgr.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::IsReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { + if (_state != TRANS_MGR_READY) return S_OK; + + if (Type == TRANSITION_NONE || Type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return S_OK; + } + + if (NonInteractive) { + _preserveInteractive = true; + _origInteractive = Game->_interactive; + Game->_interactive = false; + } else _preserveInteractive; + + _type = Type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return S_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +HRESULT CBTransitionMgr::Update() { + if (IsReady()) return S_OK; + + if (!_started) { + _started = true; + _lastTime = CBPlatform::GetTime(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::GetTime() - _lastTime; + int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; + Alpha = MIN(255, MAX(Alpha, 0)); + Game->_renderer->Fade((uint16)Alpha); + + if (time > FADE_DURATION) _state = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::GetTime() - _lastTime; + int Alpha = (float)time / (float)FADE_DURATION * 255; + Alpha = MIN(255, MAX(Alpha, 0)); + Game->_renderer->Fade((uint16)Alpha); + + if (time > FADE_DURATION) _state = TRANS_MGR_READY; + } + break; + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (IsReady()) { + if (_preserveInteractive) Game->_interactive = _origInteractive; + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h new file mode 100644 index 0000000000..01cdee8262 --- /dev/null +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + HRESULT Update(); + HRESULT Start(TTransitionType Type, bool NonInteractive = false); + bool IsReady(); + TTransMgrState _state; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp new file mode 100644 index 0000000000..c8cff8f376 --- /dev/null +++ b/engines/wintermute/Base/BViewport.cpp @@ -0,0 +1,98 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/BViewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::SetRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_mainObject)); + PersistMgr->Transfer(TMEMBER(_offsetX)); + PersistMgr->Transfer(TMEMBER(_offsetY)); + PersistMgr->Transfer(TMEMBER(_rect)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoCheck) { + if (!NoCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, Game->_renderer->_width); + bottom = MIN(bottom, Game->_renderer->_height); + } + + CBPlatform::SetRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +RECT *CBViewport::GetRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::GetWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::GetHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h new file mode 100644 index 0000000000..640f54f438 --- /dev/null +++ b/engines/wintermute/Base/BViewport.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "engines/wintermute/Base/BBase.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int GetHeight(); + int GetWidth(); + RECT *GetRect(); + HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int _offsetY; + int _offsetX; + CBObject *_mainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + RECT _rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp new file mode 100644 index 0000000000..ba3f688a34 --- /dev/null +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -0,0 +1,1198 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/Matrix4.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::SetRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.GetSize(); i++) { + delete _particles[i]; + } + _particles.RemoveAll(); + + for (int i = 0; i < _forces.GetSize(); i++) { + delete _forces[i]; + } + _forces.RemoveAll(); + + + for (int i = 0; i < _sprites.GetSize(); i++) { + delete [] _sprites[i]; + } + _sprites.RemoveAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::AddSprite(const char *Filename) { + if (!Filename) return E_FAIL; + + // do we already have the file? + for (int i = 0; i < _sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, _sprites[i]) == 0) return S_OK; + } + + // check if file exists + CBFile *File = Game->_fileManager->OpenFile(Filename); + if (!File) { + Game->LOG(0, "Sprite '%s' not found", Filename); + return E_FAIL; + } else Game->_fileManager->CloseFile(File); + + char *Str = new char[strlen(Filename) + 1]; + strcpy(Str, Filename); + _sprites.Add(Str); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::RemoveSprite(const char *Filename) { + for (int i = 0; i < _sprites.GetSize(); i++) { + if (scumm_stricmp(Filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { + if (!Particle) return E_FAIL; + if (_sprites.GetSize() == 0) return E_FAIL; + + int PosX = CBUtils::RandomInt(_posX, _posX + _width); + int PosY = CBUtils::RandomInt(_posY, _posY + _height); + float PosZ = CBUtils::RandomFloat(0.0f, 100.0f); + + float Velocity; + if (_velocityZBased) Velocity = _velocity1 + PosZ * (_velocity2 - _velocity1) / 100; + else Velocity = CBUtils::RandomFloat(_velocity1, _velocity2); + + float Scale; + if (_scaleZBased) Scale = _scale1 + PosZ * (_scale2 - _scale1) / 100; + else Scale = CBUtils::RandomFloat(_scale1, _scale2); + + int LifeTime; + if (_lifeTimeZBased) LifeTime = _lifeTime2 - PosZ * (_lifeTime2 - _lifeTime1) / 100; + else LifeTime = CBUtils::RandomInt(_lifeTime1, _lifeTime2); + + float Angle = CBUtils::RandomAngle(_angle1, _angle2); + int SpriteIndex = CBUtils::RandomInt(0, _sprites.GetSize() - 1); + + float Rotation = CBUtils::RandomAngle(_rotation1, _rotation2); + float AngVelocity = CBUtils::RandomFloat(_angVelocity1, _angVelocity2); + float GrowthRate = CBUtils::RandomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::IsRectEmpty(&_border)) { + int ThicknessLeft = _borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f; + int ThicknessRight = _borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f; + int ThicknessTop = _borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f; + int ThicknessBottom = _borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f; + + Particle->_border = _border; + Particle->_border.left += ThicknessLeft; + Particle->_border.right -= ThicknessRight; + Particle->_border.top += ThicknessTop; + Particle->_border.bottom -= ThicknessBottom; + } + + Vector2 VecPos((float)PosX, (float)PosY); + Vector2 VecVel(0, Velocity); + + Matrix4 MatRot; + MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.TransformVector2(VecVel); + + if (_alphaTimeBased) { + Particle->_alpha1 = _alpha1; + Particle->_alpha2 = _alpha2; + } else { + int Alpha = CBUtils::RandomInt(_alpha1, _alpha2); + Particle->_alpha1 = Alpha; + Particle->_alpha2 = Alpha; + } + + Particle->_creationTime = CurrentTime; + Particle->_pos = VecPos; + Particle->_posZ = PosZ; + Particle->_velocity = VecVel; + Particle->_scale = Scale; + Particle->_lifeTime = LifeTime; + Particle->_rotation = Rotation; + Particle->_angVelocity = AngVelocity; + Particle->_growthRate = GrowthRate; + Particle->_exponentialGrowth = _exponentialGrowth; + Particle->_isDead = FAILED(Particle->SetSprite(_sprites[SpriteIndex])); + Particle->FadeIn(CurrentTime, _fadeInTime); + + + if (Particle->_isDead) return E_FAIL; + else return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Update() { + if (!_running) return S_OK; + else return UpdateInternal(Game->_timer, Game->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { + int NumLive = 0; + + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->Update(this, CurrentTime, TimerDelta); + + if (!_particles[i]->_isDead) NumLive++; + } + + + // we're understaffed + if (NumLive < _maxParticles) { + bool NeedsSort = false; + if (CurrentTime - _lastGenTime > _genInterval) { + _lastGenTime = CurrentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return S_OK; + } + + int ToGen = MIN(_genAmount, _maxParticles - NumLive); + while (ToGen > 0) { + int FirstDeadIndex = -1; + for (int i = 0; i < _particles.GetSize(); i++) { + if (_particles[i]->_isDead) { + FirstDeadIndex = i; + break; + } + } + + CPartParticle *Particle; + if (FirstDeadIndex >= 0) Particle = _particles[FirstDeadIndex]; + else { + Particle = new CPartParticle(Game); + _particles.Add(Particle); + } + InitParticle(Particle, CurrentTime, TimerDelta); + NeedsSort = true; + + ToGen--; + } + } + if (NeedsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + SortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (NeedsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->ApplyEvent(_emitEvent); + } + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Display(CBRegion *Region) { + if (_sprites.GetSize() <= 1) Game->_renderer->StartSpriteBatch(); + + for (int i = 0; i < _particles.GetSize(); i++) { + if (Region != NULL && _useRegion) { + if (!Region->PointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; + } + + _particles[i]->Display(this); + } + + if (_sprites.GetSize() <= 1) Game->_renderer->EndSpriteBatch(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Start() { + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 Delta = 500; + int Steps = _overheadTime / Delta; + uint32 CurrentTime = Game->_timer - _overheadTime; + + for (int i = 0; i < Steps; i++) { + UpdateInternal(CurrentTime, Delta); + CurrentTime += Delta; + } + _overheadTime = 0; + } + + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SortParticlesByZ() { + // sort particles by _posY + qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { + CPartParticle *P1 = *(CPartParticle **)Obj1; + CPartParticle *P2 = *(CPartParticle **)Obj2; + + if (P1->_posZ < P2->_posZ) return -1; + else if (P1->_posZ > P2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SetBorder(int X, int Y, int Width, int Height) { + CBPlatform::SetRect(&_border, X, Y, X + Width, Y + Height); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { + _borderThicknessLeft = ThicknessLeft; + _borderThicknessRight = ThicknessRight; + _borderThicknessTop = ThicknessTop; + _borderThicknessBottom = ThicknessBottom; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::AddForceByName(const char *Name) { + CPartForce *Force = NULL; + + for (int i = 0; i < _forces.GetSize(); i++) { + if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + Force = _forces[i]; + break; + } + } + if (!Force) { + Force = new CPartForce(Game); + if (Force) { + Force->SetName(Name); + _forces.Add(Force); + } + } + return Force; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { + CPartForce *Force = AddForceByName(Name); + if (!Force) return E_FAIL; + + Force->_type = Type; + Force->_pos = Vector2(PosX, PosY); + + Force->_direction = Vector2(0, Strength); + Matrix4 MatRot; + MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.TransformVector2(Force->_direction); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::RemoveForce(const char *Name) { + for (int i = 0; i < _forces.GetSize(); i++) { + if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.RemoveAt(i); + return S_OK; + } + } + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetBorder") == 0) { + Stack->CorrectParams(4); + int BorderX = Stack->Pop()->GetInt(); + int BorderY = Stack->Pop()->GetInt(); + int BorderWidth = Stack->Pop()->GetInt(); + int BorderHeight = Stack->Pop()->GetInt(); + + Stack->PushBool(SUCCEEDED(SetBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetBorderThickness") == 0) { + Stack->CorrectParams(4); + int Left = Stack->Pop()->GetInt(); + int Right = Stack->Pop()->GetInt(); + int Top = Stack->Pop()->GetInt(); + int Bottom = Stack->Pop()->GetInt(); + + Stack->PushBool(SUCCEEDED(SetBorderThickness(Left, Right, Top, Bottom))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddSprite") == 0) { + Stack->CorrectParams(1); + const char *SpriteFile = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(AddSprite(SpriteFile))); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveSprite") == 0) { + Stack->CorrectParams(1); + const char *SpriteFile = Stack->Pop()->GetString(); + Stack->PushBool(SUCCEEDED(RemoveSprite(SpriteFile))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Start") == 0) { + Stack->CorrectParams(1); + _overheadTime = Stack->Pop()->GetInt(); + Stack->PushBool(SUCCEEDED(Start())); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Stop") == 0) { + Stack->CorrectParams(0); + + for (int i = 0; i < _particles.GetSize(); i++) { + delete _particles[i]; + } + _particles.RemoveAll(); + + _running = false; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pause") == 0) { + Stack->CorrectParams(0); + _running = false; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Resume") == 0) { + Stack->CorrectParams(0); + _running = true; + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddGlobalForce") == 0) { + Stack->CorrectParams(3); + const char *Name = Stack->Pop()->GetString(); + float Angle = Stack->Pop()->GetFloat(); + float Strength = Stack->Pop()->GetFloat(); + + Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AddPointForce") == 0) { + Stack->CorrectParams(5); + const char *Name = Stack->Pop()->GetString(); + int PosX = Stack->Pop()->GetInt(); + int PosY = Stack->Pop()->GetInt(); + float Angle = Stack->Pop()->GetFloat(); + float Strength = Stack->Pop()->GetFloat(); + + Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RemoveForce") == 0) { + Stack->CorrectParams(1); + const char *Name = Stack->Pop()->GetString(); + + Stack->PushBool(SUCCEEDED(RemoveForce(Name))); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "X") == 0) { + _scValue->SetInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + _scValue->SetInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _scValue->SetInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _scValue->SetInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale1") == 0) { + _scValue->SetFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale2") == 0) { + _scValue->SetFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleZBased") == 0) { + _scValue->SetBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity1") == 0) { + _scValue->SetFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity2") == 0) { + _scValue->SetFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VelocityZBased") == 0) { + _scValue->SetBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime1") == 0) { + _scValue->SetInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime2") == 0) { + _scValue->SetInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTimeZBased") == 0) { + _scValue->SetBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle1") == 0) { + _scValue->SetInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle2") == 0) { + _scValue->SetInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity1") == 0) { + _scValue->SetFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity2") == 0) { + _scValue->SetFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation1") == 0) { + _scValue->SetFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation2") == 0) { + _scValue->SetFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha1") == 0) { + _scValue->SetInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha2") == 0) { + _scValue->SetInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaTimeBased") == 0) { + _scValue->SetBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxParticles") == 0) { + _scValue->SetInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumLiveParticles") == 0) { + int NumAlive = 0; + for (int i = 0; i < _particles.GetSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) NumAlive++; + } + _scValue->SetInt(NumAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationInterval") == 0) { + _scValue->SetInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationAmount") == 0) { + _scValue->SetInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxBatches") == 0) { + _scValue->SetInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeInTime") == 0) { + _scValue->SetInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOutTime") == 0) { + _scValue->SetInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate1") == 0) { + _scValue->SetFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate2") == 0) { + _scValue->SetFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExponentialGrowth") == 0) { + _scValue->SetBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UseRegion") == 0) { + _scValue->SetBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->SetNULL(); + else _scValue->SetString(_emitEvent); + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "X") == 0) { + _posX = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Y") == 0) { + _posY = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _width = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _height = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale1") == 0) { + _scale1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Scale2") == 0) { + _scale2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ScaleZBased") == 0) { + _scaleZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity1") == 0) { + _velocity1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Velocity2") == 0) { + _velocity2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VelocityZBased") == 0) { + _velocityZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime1") == 0) { + _lifeTime1 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTime2") == 0) { + _lifeTime2 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle1") == 0) { + _angle1 = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Angle2") == 0) { + _angle2 = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity1") == 0) { + _angVelocity1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AngVelocity2") == 0) { + _angVelocity2 = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation1") == 0) { + _rotation1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Rotation2") == 0) { + _rotation2 = Value->GetFloat(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha1") == 0) { + _alpha1 = Value->GetInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Alpha2") == 0) { + _alpha2 = Value->GetInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AlphaTimeBased") == 0) { + _alphaTimeBased = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxParticles") == 0) { + _maxParticles = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationInterval") == 0) { + _genInterval = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GenerationAmount") == 0) { + _genAmount = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxBatches") == 0) { + _maxBatches = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeInTime") == 0) { + _fadeInTime = Value->GetInt(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeOutTime") == 0) { + _fadeOutTime = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate1") == 0) { + _growthRate1 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GrowthRate2") == 0) { + _growthRate2 = Value->GetFloat(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ExponentialGrowth") == 0) { + _exponentialGrowth = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "UseRegion") == 0) { + _useRegion = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::ScToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartEmitter::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_width)); + PersistMgr->Transfer(TMEMBER(_height)); + + PersistMgr->Transfer(TMEMBER(_angle1)); + PersistMgr->Transfer(TMEMBER(_angle2)); + + PersistMgr->Transfer(TMEMBER(_velocity1)); + PersistMgr->Transfer(TMEMBER(_velocity2)); + PersistMgr->Transfer(TMEMBER(_velocityZBased)); + + PersistMgr->Transfer(TMEMBER(_scale1)); + PersistMgr->Transfer(TMEMBER(_scale2)); + PersistMgr->Transfer(TMEMBER(_scaleZBased)); + + PersistMgr->Transfer(TMEMBER(_maxParticles)); + + PersistMgr->Transfer(TMEMBER(_lifeTime1)); + PersistMgr->Transfer(TMEMBER(_lifeTime2)); + PersistMgr->Transfer(TMEMBER(_lifeTimeZBased)); + + PersistMgr->Transfer(TMEMBER(_genInterval)); + PersistMgr->Transfer(TMEMBER(_genAmount)); + + PersistMgr->Transfer(TMEMBER(_running)); + PersistMgr->Transfer(TMEMBER(_overheadTime)); + + PersistMgr->Transfer(TMEMBER(_border)); + PersistMgr->Transfer(TMEMBER(_borderThicknessLeft)); + PersistMgr->Transfer(TMEMBER(_borderThicknessRight)); + PersistMgr->Transfer(TMEMBER(_borderThicknessTop)); + PersistMgr->Transfer(TMEMBER(_borderThicknessBottom)); + + PersistMgr->Transfer(TMEMBER(_fadeInTime)); + PersistMgr->Transfer(TMEMBER(_fadeOutTime)); + + PersistMgr->Transfer(TMEMBER(_alpha1)); + PersistMgr->Transfer(TMEMBER(_alpha2)); + PersistMgr->Transfer(TMEMBER(_alphaTimeBased)); + + PersistMgr->Transfer(TMEMBER(_angVelocity1)); + PersistMgr->Transfer(TMEMBER(_angVelocity2)); + + PersistMgr->Transfer(TMEMBER(_rotation1)); + PersistMgr->Transfer(TMEMBER(_rotation2)); + + PersistMgr->Transfer(TMEMBER(_growthRate1)); + PersistMgr->Transfer(TMEMBER(_growthRate2)); + PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); + + PersistMgr->Transfer(TMEMBER(_useRegion)); + + PersistMgr->Transfer(TMEMBER_INT(_maxBatches)); + PersistMgr->Transfer(TMEMBER_INT(_batchesGenerated)); + + PersistMgr->Transfer(TMEMBER(_emitEvent)); + PersistMgr->Transfer(TMEMBER(_owner)); + + + _sprites.Persist(PersistMgr); + + int NumForces; + if (PersistMgr->_saving) { + NumForces = _forces.GetSize(); + PersistMgr->Transfer(TMEMBER(NumForces)); + for (int i = 0; i < _forces.GetSize(); i++) { + _forces[i]->Persist(PersistMgr); + } + } else { + PersistMgr->Transfer(TMEMBER(NumForces)); + for (int i = 0; i < NumForces; i++) { + CPartForce *Force = new CPartForce(Game); + Force->Persist(PersistMgr); + _forces.Add(Force); + } + } + + int NumParticles; + if (PersistMgr->_saving) { + NumParticles = _particles.GetSize(); + PersistMgr->Transfer(TMEMBER(NumParticles)); + for (int i = 0; i < _particles.GetSize(); i++) { + _particles[i]->Persist(PersistMgr); + } + } else { + PersistMgr->Transfer(TMEMBER(NumParticles)); + for (int i = 0; i < NumParticles; i++) { + CPartParticle *Particle = new CPartParticle(Game); + Particle->Persist(PersistMgr); + _particles.Add(Particle); + } + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h new file mode 100644 index 0000000000..69ab35053d --- /dev/null +++ b/engines/wintermute/Base/PartEmitter.h @@ -0,0 +1,139 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/PartParticle.h" +#include "engines/wintermute/Base/PartForce.h" + +namespace WinterMute { +class CBRegion; + +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + RECT _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + HRESULT Start(); + + HRESULT Update(); + HRESULT Display(CBRegion *Region = NULL); + + HRESULT SortParticlesByZ(); + HRESULT AddSprite(const char *Filename); + HRESULT RemoveSprite(const char *Filename); + HRESULT SetBorder(int X, int Y, int Width, int Height); + HRESULT SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); + + HRESULT AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT RemoveForce(const char *Name); + + CBArray _forces; + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); + + +private: + CPartForce *AddForceByName(const char *Name); + int static CompareZ(const void *Obj1, const void *Obj2); + HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); + HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp new file mode 100644 index 0000000000..6389e38662 --- /dev/null +++ b/engines/wintermute/Base/PartForce.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Base/PartForce.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartForce::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_direction)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h new file mode 100644 index 0000000000..b8f85bba2a --- /dev/null +++ b/engines/wintermute/Base/PartForce.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BNamedObject.h" +#include "engines/wintermute/Vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + HRESULT Persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp new file mode 100644 index 0000000000..5a17706ca6 --- /dev/null +++ b/engines/wintermute/Base/PartParticle.cpp @@ -0,0 +1,255 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/PartParticle.h" +#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::SetRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::SetSprite(const char *Filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { + _sprite->Reset(); + return S_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::GetInstance()->_disabled = true; + _sprite = new CBSprite(Game, Game); + if (_sprite && SUCCEEDED(_sprite->LoadFile(Filename))) { + CSysClassRegistry::GetInstance()->_disabled = false; + return S_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::GetInstance()->_disabled = false; + return E_FAIL; + } + +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { + if (_state == PARTICLE_FADEIN) { + if (CurrentTime - _fadeStart >= _fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; + + return S_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (CurrentTime - _fadeStart >= _fadeTime) { + _isDead = true; + return S_OK; + } else _currentAlpha = _fadeStartAlpha - ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; + + return S_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (CurrentTime - _creationTime >= _lifeTime) { + if (Emitter->_fadeOutTime > 0) + FadeOut(CurrentTime, Emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::IsRectEmpty(&_border)) { + POINT p; + p.x = _pos.x; + p.y = _pos.y; + if (!CBPlatform::PtInRect(&_border, p)) FadeOut(CurrentTime, Emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return S_OK; + + // update alpha + if (_lifeTime > 0) { + int Age = CurrentTime - _creationTime; + int AlphaDelta = _alpha2 - _alpha1; + + _currentAlpha = _alpha1 + ((float)AlphaDelta / (float)_lifeTime * (float)Age); + } + + // update position + float ElapsedTime = (float)TimerDelta / 1000.f; + + for (int i = 0; i < Emitter->_forces.GetSize(); i++) { + CPartForce *Force = Emitter->_forces[i]; + switch (Force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += Force->_direction * ElapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 VecDist = Force->_pos - _pos; + float Dist = fabs(VecDist.Length()); + + Dist = 100.0f / Dist; + + _velocity += Force->_direction * Dist * ElapsedTime; + } + break; + } + } + _pos += _velocity * ElapsedTime; + + // update rotation + _rotation += _angVelocity * ElapsedTime; + _rotation = CBUtils::NormalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * ElapsedTime; + else + _scale += _growthRate * ElapsedTime; + + if (_scale <= 0.0f) _isDead = true; + + + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Display(CPartEmitter *Emitter) { + if (!_sprite) return E_FAIL; + if (_isDead) return S_OK; + + _sprite->GetCurrentFrame(); + return _sprite->Display(_pos.x, _pos.y, + NULL, + _scale, _scale, + DRGBA(255, 255, 255, _currentAlpha), + _rotation, + Emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { + _currentAlpha = 0; + _fadeStart = CurrentTime; + _fadeTime = FadeTime; + _state = PARTICLE_FADEIN; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = CurrentTime; + _fadeTime = FadeTime; + _state = PARTICLE_FADEOUT; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CPartParticle::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_alpha1)); + PersistMgr->Transfer(TMEMBER(_alpha2)); + PersistMgr->Transfer(TMEMBER(_border)); + PersistMgr->Transfer(TMEMBER(_pos)); + PersistMgr->Transfer(TMEMBER(_posZ)); + PersistMgr->Transfer(TMEMBER(_velocity)); + PersistMgr->Transfer(TMEMBER(_scale)); + PersistMgr->Transfer(TMEMBER(_creationTime)); + PersistMgr->Transfer(TMEMBER(_lifeTime)); + PersistMgr->Transfer(TMEMBER(_isDead)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_fadeStart)); + PersistMgr->Transfer(TMEMBER(_fadeTime)); + PersistMgr->Transfer(TMEMBER(_currentAlpha)); + PersistMgr->Transfer(TMEMBER(_angVelocity)); + PersistMgr->Transfer(TMEMBER(_rotation)); + PersistMgr->Transfer(TMEMBER(_growthRate)); + PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); + PersistMgr->Transfer(TMEMBER(_fadeStartAlpha)); + + if (PersistMgr->_saving) { + PersistMgr->Transfer(TMEMBER(_sprite->_filename)); + } else { + char *Filename; + PersistMgr->Transfer(TMEMBER(Filename)); + CSysClassRegistry::GetInstance()->_disabled = true; + SetSprite(Filename); + CSysClassRegistry::GetInstance()->_disabled = false; + delete[] Filename; + Filename = NULL; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h new file mode 100644 index 0000000000..09eb7e8443 --- /dev/null +++ b/engines/wintermute/Base/PartParticle.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PATRPARTICLE_H +#define WINTERMUTE_PATRPARTICLE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + RECT _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); + HRESULT Display(CPartEmitter *Emitter); + + HRESULT SetSprite(const char *Filename); + + HRESULT FadeIn(uint32 CurrentTime, int FadeTime); + HRESULT FadeOut(uint32 CurrentTime, int FadeTime); + + HRESULT Persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp new file mode 100644 index 0000000000..bd8962cc0c --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -0,0 +1,234 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/SysInstance.h" +#include "engines/wintermute/Base/scriptables/SXArray.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(Game); + + int NumParams = Stack->Pop()->GetInt(0); + + if (NumParams == 1) _length = Stack->Pop()->GetInt(0); + else if (NumParams > 1) { + _length = NumParams; + char ParamName[20]; + for (int i = 0; i < NumParams; i++) { + sprintf(ParamName, "%d", i); + _values->SetProp(ParamName, Stack->Pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(Game); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXArray::ScToString() { + static char Dummy[32768]; + strcpy(Dummy, ""); + char PropName[20]; + for (int i = 0; i < _length; i++) { + sprintf(PropName, "%d", i); + CScValue *val = _values->GetProp(PropName); + if (val) { + if (strlen(Dummy) + strlen(val->GetString()) < 32768) { + strcat(Dummy, val->GetString()); + } + } + + if (i < _length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); + } + return Dummy; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Push") == 0) { + int NumParams = Stack->Pop()->GetInt(0); + char ParamName[20]; + + for (int i = 0; i < NumParams; i++) { + _length++; + sprintf(ParamName, "%d", _length - 1); + _values->SetProp(ParamName, Stack->Pop(), true); + } + Stack->PushInt(_length); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Pop") == 0) { + + Stack->CorrectParams(0); + + if (_length > 0) { + char ParamName[20]; + sprintf(ParamName, "%d", _length - 1); + Stack->Push(_values->GetProp(ParamName)); + _values->DeleteProp(ParamName); + _length--; + } else Stack->PushNULL(); + + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + _scValue->SetInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (ValidNumber(Name, ParamName)) { + return _values->GetProp(ParamName); + } else return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Length") == 0) { + int OrigLength = _length; + _length = MAX(Value->GetInt(0), 0); + + char PropName[20]; + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + _values->DeleteProp(PropName); + } + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (ValidNumber(Name, ParamName)) { + int Index = atoi(ParamName); + if (Index >= _length) _length = Index + 1; + return _values->SetProp(ParamName, Value); + } else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_length)); + PersistMgr->Transfer(TMEMBER(_values)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { + bool IsNumber = true; + for (int i = 0; i < strlen(OrigStr); i++) { + if (!(OrigStr[i] >= '0' && OrigStr[i] <= '9')) { + IsNumber = false; + break; + } + } + + if (IsNumber) { + int Index = atoi(OrigStr); + sprintf(OutStr, "%d", Index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXArray::Push(CScValue *Val) { + char ParamName[20]; + _length++; + sprintf(ParamName, "%d", _length - 1); + _values->SetProp(ParamName, Val, true); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h new file mode 100644 index 0000000000..d1cc4ce4db --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + HRESULT Push(CScValue *Val); + bool ValidNumber(const char *OrigStr, char *OutStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *Stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *ScToString(); + int _length; + CScValue *_values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp new file mode 100644 index 0000000000..e9cfc4b406 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -0,0 +1,277 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/SXDate.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(6); +#if 0 + memset(&_tm, 0, sizeof(_tm)); + + CScValue *valYear = Stack->Pop(); + _tm.t_year = valYear->GetInt() - 1900; + _tm.t_mon = Stack->Pop()->GetInt() - 1; + _tm.t_mday = Stack->Pop()->GetInt(); + _tm.t_hour = Stack->Pop()->GetInt(); + _tm.t_min = Stack->Pop()->GetInt(); + _tm.t_sec = Stack->Pop()->GetInt(); + + if (valYear->IsNULL()) { + time_t TimeNow; + time(&TimeNow); + memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); + } + + mktime(&_tm); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXDate::ScToString() { +#if 0 + return asctime(&_tm); +#endif + return ""; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +#if 0 + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetYear") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_year + 1900); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMonth") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_mon + 1); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDate") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_mday); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHours") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_hour); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetMinutes") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_min); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetSeconds") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_sec); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetWeekday") == 0) { + Stack->CorrectParams(0); + Stack->PushInt(_tm.t_wday); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetYear") == 0) { + Stack->CorrectParams(1); + _tm.t_year = Stack->Pop()->GetInt() - 1900; + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMonth") == 0) { + Stack->CorrectParams(1); + _tm.t_mon = Stack->Pop()->GetInt() - 1; + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDate") == 0) { + Stack->CorrectParams(1); + _tm.t_mday = Stack->Pop()->GetInt(); + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHours") == 0) { + Stack->CorrectParams(1); + _tm.t_hour = Stack->Pop()->GetInt(); + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetMinutes") == 0) { + Stack->CorrectParams(1); + _tm.t_min = Stack->Pop()->GetInt(); + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetSeconds") == 0) { + Stack->CorrectParams(1); + _tm.t_sec = Stack->Pop()->GetInt(); + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetCurrentTime") == 0) { + Stack->CorrectParams(0); + time_t TimeNow; + time(&TimeNow); + memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); + mktime(&_tm); + Stack->PushNULL(); + return S_OK; + } + + else +#endif + return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("date"); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Name")==0){ + SetName(Value->GetString()); + return S_OK; + } + + else*/ return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); +#if 0 + if (PersistMgr->_saving) + PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); + else + PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXDate::ScCompare(CBScriptable *Value) { +#if 0 + time_t time1 = mktime(&_tm); + time_t time2 = mktime(&((CSXDate *)Value)->_tm); + + if (time1 < time2) return -1; + else if (time1 > time2) return 1; + else +#endif + return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h new file mode 100644 index 0000000000..7d4d29af93 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int ScCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *ScToString(); + char *_string; + //struct tm _tm; // TODO! +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp new file mode 100644 index 0000000000..ffff0e736d --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -0,0 +1,723 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/SysClassRegistry.h" +#include "engines/wintermute/SysClass.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/SXFile.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + _filename = NULL; + if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::Cleanup() { + delete[] _filename; + _filename = NULL; + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::Close() { + if (_readFile) { + Game->_fileManager->CloseFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + fclose(_writeFile); + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXFile::ScToString() { + if (_filename) return _filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetFilename") == 0) { + Stack->CorrectParams(1); + const char *Filename = Stack->Pop()->GetString(); + Cleanup(); + CBUtils::SetString(&_filename, Filename); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) { + Stack->CorrectParams(1); + Close(); + _mode = Stack->Pop()->GetInt(1); + if (_mode < 1 || _mode > 3) { + Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name); + _mode = 1; + } + if (_mode == 1) { + _readFile = Game->_fileManager->OpenFile(_filename); + if (!_readFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + Close(); + } else _textMode = strcmp(Name, "OpenAsText") == 0; + } else { + if (strcmp(Name, "OpenAsText") == 0) { + if (_mode == 2) _writeFile = fopen(_filename, "w+"); + else _writeFile = fopen(_filename, "a+"); + } else { + if (_mode == 2) _writeFile = fopen(_filename, "wb+"); + else _writeFile = fopen(_filename, "ab+"); + } + + if (!_writeFile) { + //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + Close(); + } else _textMode = strcmp(Name, "OpenAsText") == 0; + } + + if (_readFile || _writeFile) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Close") == 0) { + Stack->CorrectParams(0); + Close(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPosition") == 0) { + Stack->CorrectParams(1); + if (_mode == 0) { + Script->RuntimeError("File.%s: File is not open", Name); + Stack->PushBool(false); + } else { + int Pos = Stack->Pop()->GetInt(); + Stack->PushBool(SetPos(Pos)); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Delete") == 0) { + Stack->CorrectParams(0); + Close(); + Stack->PushBool(CBPlatform::DeleteFile(_filename) != false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Copy") == 0) { + Stack->CorrectParams(2); + const char *Dest = Stack->Pop()->GetString(); + bool Overwrite = Stack->Pop()->GetBool(true); + + Close(); + Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadLine") == 0) { + Stack->CorrectParams(0); + if (!_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open in text mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 BufSize = FILE_BUFFER_SIZE; + byte *Buf = (byte *)malloc(BufSize); + uint32 Counter = 0; + byte b; + bool FoundNewLine = false; + HRESULT Ret = E_FAIL; + do { + Ret = _readFile->Read(&b, 1); + if (FAILED(Ret)) break; + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + Buf[Counter] = '\0'; + FoundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + Buf[Counter] = b; + Counter++; + } + } while (SUCCEEDED(Ret)); + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + Buf[Counter] = '\0'; + + if (!FoundNewLine && Counter == 0) Stack->PushNULL(); + else Stack->PushString((char *)Buf); + + free(Buf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadText") == 0) { + Stack->CorrectParams(1); + int TextLen = Stack->Pop()->GetInt(); + + if (!_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open in text mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 BufSize = FILE_BUFFER_SIZE; + byte *Buf = (byte *)malloc(BufSize); + uint32 Counter = 0; + byte b; + + HRESULT Ret = E_FAIL; + while (Counter < TextLen) { + Ret = _readFile->Read(&b, 1); + if (FAILED(Ret)) break; + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + Buf[Counter] = b; + Counter++; + } + } + + if (Counter > BufSize) { + Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); + BufSize += FILE_BUFFER_SIZE; + } + Buf[Counter] = '\0'; + + if (TextLen > 0 && Counter == 0) Stack->PushNULL(); + else Stack->PushString((char *)Buf); + + free(Buf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { + Stack->CorrectParams(1); + const char *Line = Stack->Pop()->GetString(); + if (!_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); + Stack->PushBool(false); + return S_OK; + } + if (strcmp(Name, "WriteLine") == 0) + fprintf(_writeFile, "%s\n", Line); + else + fprintf(_writeFile, "%s", Line); + + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadBool") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + bool Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadByte") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + byte Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte)))) Stack->PushInt(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadShort") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + short Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + int Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadFloat") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + float Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadDouble") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + double Val; + if (SUCCEEDED(_readFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ReadString") == 0) { + Stack->CorrectParams(0); + if (_textMode || !_readFile) { + Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); + Stack->PushNULL(); + return S_OK; + } + uint32 Size; + if (SUCCEEDED(_readFile->Read(&Size, sizeof(uint32)))) { + byte *Str = new byte[Size + 1]; + if (Str) { + if (SUCCEEDED(_readFile->Read(Str, Size))) { + Str[Size] = '\0'; + Stack->PushString((char *)Str); + } + delete [] Str; + } else Stack->PushNULL(); + } else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteBool") == 0) { + Stack->CorrectParams(1); + bool Val = Stack->Pop()->GetBool(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteByte") == 0) { + Stack->CorrectParams(1); + byte Val = Stack->Pop()->GetInt(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteShort") == 0) { + Stack->CorrectParams(1); + short Val = Stack->Pop()->GetInt(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteInt") == 0 || strcmp(Name, "WriteLong") == 0) { + Stack->CorrectParams(1); + int Val = Stack->Pop()->GetInt(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteFloat") == 0) { + Stack->CorrectParams(1); + float Val = Stack->Pop()->GetFloat(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteDouble") == 0) { + Stack->CorrectParams(1); + double Val = Stack->Pop()->GetFloat(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + fwrite(&Val, sizeof(Val), 1, _writeFile); + Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "WriteString") == 0) { + Stack->CorrectParams(1); + const char *Val = Stack->Pop()->GetString(); + + if (_textMode || !_writeFile) { + Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); + Stack->PushBool(false); + return S_OK; + } + + uint32 Size = strlen(Val); + fwrite(&Size, sizeof(Size), 1, _writeFile); + fwrite(Val, Size, 1, _writeFile); + + Stack->PushBool(true); + + return S_OK; + } + + + else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Filename") == 0) { + _scValue->SetString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Position") == 0) { + _scValue->SetInt(GetPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + _scValue->SetInt(GetLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextMode") == 0) { + _scValue->SetBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "AccessMode") == 0) { + _scValue->SetInt(_mode); + return _scValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Length")==0){ + int OrigLength = _length; + _length = max(Value->GetInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return S_OK; + } + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::GetPos() { + if (_mode == 1 && _readFile) return _readFile->GetPos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { + if (_mode == 1 && _readFile) return SUCCEEDED(_readFile->Seek(Pos, Origin)); + else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, Pos, (int)Origin) == 0; + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::GetLength() { + if (_mode == 1 && _readFile) return _readFile->GetSize(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + uint32 CurrentPos = ftell(_writeFile); + fseek(_writeFile, 0, SEEK_END); + int Ret = ftell(_writeFile); + fseek(_writeFile, CurrentPos, SEEK_SET); + return Ret; + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_mode)); + PersistMgr->Transfer(TMEMBER(_textMode)); + + uint32 Pos = 0; + if (PersistMgr->_saving) { + Pos = GetPos(); + PersistMgr->Transfer(TMEMBER(Pos)); + } else { + PersistMgr->Transfer(TMEMBER(Pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = Game->_fileManager->OpenFile(_filename); + if (!_readFile) Close(); + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) _writeFile = fopen(_filename, "w+"); + else _writeFile = fopen(_filename, "a+"); + } else { + if (_mode == 2) _writeFile = fopen(_filename, "wb+"); + else _writeFile = fopen(_filename, "ab+"); + } + if (_writeFile) Close(); + } + SetPos(Pos); + } + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h new file mode 100644 index 0000000000..f05a0e11ec --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *ScToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + CBFile *_readFile; + FILE *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void Close(); + void Cleanup(); + uint32 GetPos(); + uint32 GetLength(); + bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + char *_filename; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp new file mode 100644 index 0000000000..8ac70581b9 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -0,0 +1,290 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/scriptables/SXMath.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/persistent.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Abs") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(fabs(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Acos") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(acos(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Asin") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(asin(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Atan") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(atan(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Atan2") == 0) { + Stack->CorrectParams(2); + double y = Stack->Pop()->GetFloat(); + double x = Stack->Pop()->GetFloat(); + Stack->PushFloat(atan2(y, x)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Ceil") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(ceil(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Cos") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(cos(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Cosh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(cosh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exp") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(exp(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Floor") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(floor(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Log") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(log(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Log10") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(log10(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pow") == 0) { + Stack->CorrectParams(2); + double x = Stack->Pop()->GetFloat(); + double y = Stack->Pop()->GetFloat(); + + Stack->PushFloat(pow(x, y)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sin") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sin(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sinh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sinh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Tan") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(tan(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Tanh") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(tanh(DegreeToRadian(Stack->Pop()->GetFloat()))); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Sqrt") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(sqrt(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DegToRad") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(DegreeToRadian(Stack->Pop()->GetFloat())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "RadToDeg") == 0) { + Stack->CorrectParams(1); + Stack->PushFloat(RadianToDegree(Stack->Pop()->GetFloat())); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PI") == 0) { + _scValue->SetFloat(PI); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::DegreeToRadian(double Value) { + return Value * (PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::RadianToDegree(double Value) { + return Value * (180.0f / PI); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMath::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h new file mode 100644 index 0000000000..0e61738161 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + +private: + double DegreeToRadian(double Value); + double RadianToDegree(double Value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp new file mode 100644 index 0000000000..dd869477a1 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -0,0 +1,479 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_fopen +#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite +#define FORBIDDEN_SYMBOL_EXCEPTION_fclose +#include "engines/wintermute/Base/BScriptable.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + Stack->CorrectParams(1); + _buffer = NULL; + _size = 0; + + int NewSize = Stack->Pop()->GetInt(); + Resize(MAX(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + _size = NULL; + _buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::ScToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::Cleanup() { + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::Resize(int NewSize) { + int OldSize = _size; + + if (_size == 0) { + _buffer = malloc(NewSize); + if (_buffer) _size = NewSize; + } else { + void *NewBuf = realloc(_buffer, NewSize); + if (!NewBuf) { + if (NewSize == 0) { + _buffer = NewBuf; + _size = NewSize; + } else return E_FAIL; + } else { + _buffer = NewBuf; + _size = NewSize; + } + } + + if (_buffer && _size > OldSize) { + memset((byte *)_buffer + OldSize, 0, _size - OldSize); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { + if (_buffer == NULL) { + Script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) return true; + + if (Start < 0 || Length == 0 || Start + Length > _size) { + Script->RuntimeError("Set/Get method call is out of bounds"); + return false; + } else return true; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXMemBuffer::ScToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSize") == 0) { + Stack->CorrectParams(1); + int NewSize = Stack->Pop()->GetInt(); + NewSize = MAX(0, NewSize); + if (SUCCEEDED(Resize(NewSize))) Stack->PushBool(true); + else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetBool") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); + else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetByte") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushNULL(); + else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetShort") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); + else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInt") == 0 || strcmp(Name, "GetLong") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); + else Stack->PushInt(*(int *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFloat") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); + else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDouble") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); + else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetString") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + int Length = Stack->Pop()->GetInt(); + + // find end of string + if (Length == 0 && Start >= 0 && Start < _size) { + for (int i = Start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + Length = i - Start; + break; + } + } + } + + if (!CheckBounds(Script, Start, Length)) Stack->PushNULL(); + else { + char *Str = new char[Length + 1]; + strncpy(Str, (const char *)_buffer + Start, Length); + Str[Length] = '\0'; + Stack->PushString(Str); + delete [] Str; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPointer") == 0) { + Stack->CorrectParams(1); + int Start = Stack->Pop()->GetInt(); + if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); + else { + void *Pointer = *(void **)((byte *)_buffer + Start); + CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); + Stack->PushNative(Buf, false); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetBool") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + bool Val = Stack->Pop()->GetBool(); + + if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); + else { + *(bool *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetByte") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + byte Val = (byte)Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushBool(false); + else { + *(byte *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetShort") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + short Val = (short)Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); + else { + *(short *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInt") == 0 || strcmp(Name, "SetLong") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + int Val = Stack->Pop()->GetInt(); + + if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); + else { + *(int *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFloat") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + float Val = (float)Stack->Pop()->GetFloat(); + + if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); + else { + *(float *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDouble") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + double Val = Stack->Pop()->GetFloat(); + + if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); + else { + *(double *)((byte *)_buffer + Start) = Val; + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetString") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + const char *Val = Stack->Pop()->GetString(); + + if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); + else { + memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); + Stack->PushBool(true); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPointer") == 0) { + Stack->CorrectParams(2); + int Start = Stack->Pop()->GetInt(); + CScValue *Val = Stack->Pop(); + + if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushBool(false); + else { + /* + int Pointer = (int)Val->GetMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + Stack->PushBool(true); + */ + // TODO fix + Stack->PushBool(false); + + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DEBUG_Dump") == 0) { + Stack->CorrectParams(0); + if (_buffer && _size) { + FILE *f = fopen("c:\\!!buffer.bin", "wb"); + fwrite(_buffer, _size, 1, f); + fclose(f); + } + Stack->PushNULL(); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Size") == 0) { + _scValue->SetInt(_size); + return _scValue; + } + + else return CBScriptable::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(Name, "Length")==0){ + int OrigLength = _length; + _length = max(Value->GetInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return S_OK; + } + else*/ return CBScriptable::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_size)); + + if (PersistMgr->_saving) { + if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); + } else { + if (_size > 0) { + _buffer = malloc(_size); + PersistMgr->GetBytes((byte *)_buffer, _size); + } else _buffer = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::ScCompare(CBScriptable *Val) { + if (_buffer == Val->ScToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h new file mode 100644 index 0000000000..54074b183d --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int ScCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *ScToString(); + CSXMemBuffer(CBGame *inGame, CScStack *Stack); + CSXMemBuffer(CBGame *inGame, void *Buffer); + virtual ~CSXMemBuffer(); + virtual void *ScToMemBuffer(); + int _size; +private: + HRESULT Resize(int NewSize); + void *_buffer; + void Cleanup(); + bool CheckBounds(CScScript *Script, int Start, int Length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp new file mode 100644 index 0000000000..3562392b13 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -0,0 +1,511 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/scriptables/SXStore.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/StringUtil.h" + +#ifdef __IPHONEOS__ +# include "IOS_StoreKit_interface.h" +#endif + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXStore, false) + +////////////////////////////////////////////////////////////////////////// +CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { +#ifdef __IPHONEOS__ + StoreKit_SetExternalData((void *)this); +#endif + + _eventsEnabled = false; + _lastProductRequestOwner = NULL; + _lastPurchaseOwner = NULL; + _lastRestoreOwner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CSXStore::~CSXStore() { + Cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::Cleanup() { + SetEventsEnabled(NULL, false); + + for (int i = 0; i < _validProducts.GetSize(); i++) { + delete _validProducts[i]; + } + _validProducts.RemoveAll(); + + + for (int i = 0; i < _transactions.GetSize(); i++) { + delete _transactions[i]; + } + _transactions.RemoveAll(); + + + _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // EnableEvents + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "EnableEvents") == 0) { + stack->CorrectParams(0); + SetEventsEnabled(script, true); + stack->PushBool(GetEventsEnabled() == true); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // DisableEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableEvents") == 0) { + stack->CorrectParams(0); + SetEventsEnabled(script, false); + stack->PushBool(GetEventsEnabled() == false); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ValidateProducts + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidateProducts") == 0) { + stack->CorrectParams(1); + const char *prodIdList = stack->Pop()->GetString(); + _lastProductRequestOwner = script->_owner; + ValidateProducts(prodIdList); + stack->PushNULL(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetValidProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetValidProduct") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < _validProducts.GetSize()) { + CScValue *prod = stack->GetPushValue(); + if (prod) { + prod->SetProperty("Id", _validProducts[index]->GetId()); + prod->SetProperty("Name", _validProducts[index]->GetName()); + prod->SetProperty("Description", _validProducts[index]->GetDesc()); + prod->SetProperty("Price", _validProducts[index]->GetPrice()); + } + } else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetInvalidProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInvalidProduct") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < _invalidProducts.size()) + stack->PushString(_invalidProducts[index].c_str()); + else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetTransaction + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetTransaction") == 0) { + stack->CorrectParams(1); + int index = stack->Pop()->GetInt(); + if (index >= 0 && index < _transactions.GetSize()) { + CScValue *trans = stack->GetPushValue(); + if (trans) { + trans->SetProperty("Id", _transactions[index]->GetId()); + trans->SetProperty("ProductId", _transactions[index]->GetProductId()); + trans->SetProperty("State", _transactions[index]->GetState()); + } + } else + stack->PushNULL(); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Purchase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Purchase") == 0) { + stack->CorrectParams(1); + const char *prodId = stack->Pop()->GetString(); + stack->PushBool(Purchase(script, prodId)); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FinishTransaction + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FinishTransaction") == 0) { + stack->CorrectParams(1); + const char *transId = stack->Pop()->GetString(); + stack->PushBool(FinishTransaction(script, transId)); + + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RestoreTransactions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RestoreTransactions") == 0) { + stack->CorrectParams(0); + RestoreTransactions(script); + stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnlockProduct + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnlockProduct") == 0) { + stack->CorrectParams(1); + const char *prodId = stack->Pop()->GetString(); + + Game->_registry->WriteBool("Purchases", prodId, true); + Game->_registry->SaveValues(); + + stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsProductUnlocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsProductUnlocked") == 0) { + stack->CorrectParams(1); + const char *prodId = stack->Pop()->GetString(); + + stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); + + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXStore::ScGetProperty(const char *name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->SetString("store"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Available (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Available") == 0) { + _scValue->SetBool(IsAvailable()); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // EventsEnabled (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EventsEnabled") == 0) { + _scValue->SetBool(GetEventsEnabled()); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumValidProducts (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumValidProducts") == 0) { + _scValue->SetInt(_validProducts.GetSize()); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumInvalidProducts (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumInvalidProducts") == 0) { + _scValue->SetInt(_invalidProducts.size()); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumTransactions (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumTransactions") == 0) { + _scValue->SetInt(_transactions.GetSize()); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->_saving) Cleanup(); + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_eventsEnabled)); + PersistMgr->Transfer(TMEMBER(_lastProductRequestOwner)); + PersistMgr->Transfer(TMEMBER(_lastPurchaseOwner)); + PersistMgr->Transfer(TMEMBER(_lastRestoreOwner)); + PersistMgr->Transfer(TMEMBER(_invalidProducts)); + + // persist valid products + int numProducts; + if (PersistMgr->_saving) { + numProducts = _validProducts.GetSize(); + PersistMgr->Transfer(TMEMBER(numProducts)); + for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(PersistMgr); + } else { + numProducts = _validProducts.GetSize(); + PersistMgr->Transfer(TMEMBER(numProducts)); + for (int i = 0; i < numProducts; i++) { + CBStoreProduct *prod = new CBStoreProduct; + prod->Persist(PersistMgr); + _validProducts.Add(prod); + } + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AfterLoad() { + if (_eventsEnabled) { + SetEventsEnabled(NULL, true); + } +#ifdef __IPHONEOS__ + StoreKit_SetExternalData((void *)this); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { + if (_lastProductRequestOwner == obj) _lastProductRequestOwner = NULL; + if (_lastPurchaseOwner == obj) _lastPurchaseOwner = NULL; + if (_lastRestoreOwner == obj) _lastRestoreOwner = NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::SetEventsEnabled(CScScript *script, bool val) { + _eventsEnabled = val; + + if (val) { + if (script) _lastPurchaseOwner = script->_owner; +#ifdef __IPHONEOS__ + StoreKit_EnableEvents(); +#endif + } else { + _lastPurchaseOwner = NULL; +#ifdef __IPHONEOS__ + StoreKit_DisableEvents(); +#endif + } +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ValidateProducts(const char *prodIdList) { +#ifdef __IPHONEOS__ + StoreKit_ValidateProducts(prodIdList); +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::IsAvailable() { +#ifdef __IPHONEOS__ + return StoreKit_IsStoreAvailable() > 0; +#else + return false; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveProductsStart() { + for (int i = 0; i < _validProducts.GetSize(); i++) { + delete _validProducts[i]; + } + _validProducts.RemoveAll(); + + _invalidProducts.clear(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveProductsEnd() { + if (_lastProductRequestOwner) _lastProductRequestOwner->ApplyEvent("ProductsValidated"); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddValidProduct(const char *id, const char *name, const char *desc, const char *price) { + CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); + _validProducts.Add(prod); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddInvalidProduct(const char *id) { + _invalidProducts.push_back(id); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveTransactionsStart() { + for (int i = 0; i < _transactions.GetSize(); i++) { + delete _transactions[i]; + } + _transactions.RemoveAll(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::ReceiveTransactionsEnd() { + if (_lastPurchaseOwner) _lastPurchaseOwner->ApplyEvent("TransactionsUpdated"); + else Game->ApplyEvent("TransactionsUpdated"); +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::AddTransaction(const char *id, const char *productId, const char *state) { + CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); + _transactions.Add(trans); +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::Purchase(CScScript *script, const char *productId) { + if (!productId) return false; + +#ifdef __IPHONEOS__ + for (int i = 0; i < _validProducts.GetSize(); i++) { + if (strcmp(productId, _validProducts[i]->GetId()) == 0) { + _lastPurchaseOwner = script->_owner; + + StoreKit_Purchase(productId); + return true; + } + } +#endif + script->RuntimeError("Store.Purchase() - '%s' is not a valid product id", productId); + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { + if (!transId) return false; +#ifdef __IPHONEOS__ + for (int i = 0; i < _transactions.GetSize(); i++) { + if (strcmp(transId, _transactions[i]->GetId()) == 0) { + if (StoreKit_FinishTransaction(transId) > 0) { + SAFE_DELETE(_transactions[i]); + _transactions.RemoveAt(i); + return true; + } else return false; + } + } +#endif + script->RuntimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); + return false; +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::RestoreTransactions(CScScript *script) { + _lastRestoreOwner = script->_owner; +#ifdef __IPHONEOS__ + StoreKit_RestoreTransactions(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CSXStore::OnRestoreFinished(bool error) { + if (_lastRestoreOwner) { + if (error) _lastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); + else _lastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); + } +} + + + +#ifdef __IPHONEOS__ + +////////////////////////////////////////////////////////////////////////// +// StoreKit callbacks (called from ObjC) +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddValidProductCallback(const char *id, const char *name, const char *desc, const char *price, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddValidProduct(id, name, desc, price); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddInvalidProductCallback(const char *id, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddInvalidProduct(id); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveProductsStartCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveProductsStart(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveProductsEndCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveProductsEnd(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_AddTransactionCallback(const char *id, const char *productId, const char *state, void *data) { + CSXStore *store = static_cast(data); + if (store) store->AddTransaction(id, productId, state); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveTransactionsStartCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveTransactionsStart(); +} + +////////////////////////////////////////////////////////////////////////// +void StoreKit_ReceiveTransactionsEndCallback(void *data) { + CSXStore *store = static_cast(data); + if (store) store->ReceiveTransactionsEnd(); +} +////////////////////////////////////////////////////////////////////////// +void StoreKit_RestoreFinishedCallback(void *data, int error) { + CSXStore *store = static_cast(data); + if (store) store->OnRestoreFinished(error > 0); +} + +#endif // __IPHONEOS__ + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h new file mode 100644 index 0000000000..42fe6983e4 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -0,0 +1,175 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTORE_H +#define WINTERMUTE_SXSTORE_H +#include "engines/wintermute/Base/BPersistMgr.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/Base/BObject.h" + +namespace WinterMute { + +class CSXStore : public CBObject { +public: + + ////////////////////////////////////////////////////////////////////////// + class CBStoreProduct { + public: + CBStoreProduct() { + _id = _name = _desc = _price = NULL; + } + + CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { + _id = _name = _desc = _price = NULL; + + CBUtils::SetString(&_id, id); + CBUtils::SetString(&_name, name); + CBUtils::SetString(&_desc, desc); + CBUtils::SetString(&_price, price); + } + + ~CBStoreProduct() { + delete [] _id; + delete [] _name; + delete [] _desc; + delete [] _price; + } + + HRESULT Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(_id)); + PersistMgr->Transfer(TMEMBER(_name)); + PersistMgr->Transfer(TMEMBER(_desc)); + PersistMgr->Transfer(TMEMBER(_price)); + return S_OK; + } + + const char *GetId() { + return _id; + } + const char *GetName() { + return _name; + } + const char *GetDesc() { + return _desc; + } + const char *GetPrice() { + return _price; + } + + private: + char *_id; + char *_name; + char *_desc; + char *_price; + }; + + ////////////////////////////////////////////////////////////////////////// + class CBStoreTransaction { + public: + CBStoreTransaction() { + _id = _productId = _state = NULL; + } + + CBStoreTransaction(const char *id, const char *productId, const char *state) { + _id = _productId = _state = NULL; + + CBUtils::SetString(&_id, id); + CBUtils::SetString(&_productId, productId); + CBUtils::SetString(&_state, state); + } + + ~CBStoreTransaction() { + delete [] _id; + delete [] _productId; + delete [] _state; + } + + const char *GetId() { + return _id; + } + const char *GetProductId() { + return _productId; + } + const char *GetState() { + return _state; + } + + private: + char *_id; + char *_productId; + char *_state; + }; + + + DECLARE_PERSISTENT(CSXStore, CBObject) + CSXStore(CBGame *inGame); + virtual ~CSXStore(); + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + + void AfterLoad(); + void OnObjectDestroyed(CBScriptHolder *obj); + + bool IsAvailable(); + void SetEventsEnabled(CScScript *script, bool val); + bool GetEventsEnabled() const { + return _eventsEnabled; + } + void ValidateProducts(const char *prodIdList); + + void ReceiveTransactionsStart(); + void ReceiveTransactionsEnd(); + void AddTransaction(const char *id, const char *productId, const char *state); + + void ReceiveProductsStart(); + void ReceiveProductsEnd(); + void AddValidProduct(const char *id, const char *name, const char *desc, const char *price); + void AddInvalidProduct(const char *id); + + void OnRestoreFinished(bool error); + +private: + void Cleanup(); + bool Purchase(CScScript *script, const char *productId); + bool FinishTransaction(CScScript *script, const char *transId); + void RestoreTransactions(CScScript *script); + + bool _eventsEnabled; + CBArray _validProducts; + AnsiStringArray _invalidProducts; + CBScriptHolder *_lastProductRequestOwner; + CBScriptHolder *_lastPurchaseOwner; + CBScriptHolder *_lastRestoreOwner; + + CBArray _transactions; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp new file mode 100644 index 0000000000..408b892c05 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -0,0 +1,394 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/Base/scriptables/SXString.h" +#include "engines/wintermute/Base/scriptables/SXArray.h" +#include "engines/wintermute/StringUtil.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (Val->IsInt()) { + _capacity = MAX(0, Val->GetInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + SetStringVal(Val->GetString()); + } + + if (_capacity == 0) SetStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::SetStringVal(const char *Val) { + int Len = strlen(Val); + if (Len >= _capacity) { + _capacity = Len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, Val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXString::ScToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::ScSetString(const char *Val) { + SetStringVal(Val); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Substring") == 0) { + Stack->CorrectParams(2); + int start = Stack->Pop()->GetInt(); + int end = Stack->Pop()->GetInt(); + + if (end < start) CBUtils::Swap(&start, &end); + + //try { + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // Stack->PushNULL(); + // } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Substr") == 0) { + Stack->CorrectParams(2); + int start = Stack->Pop()->GetInt(); + + CScValue *val = Stack->Pop(); + int len = val->GetInt(); + + if (!val->IsNULL() && len <= 0) { + Stack->PushString(""); + return S_OK; + } + + if (val->IsNULL()) len = strlen(_string) - start; + +// try { + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); +// } catch (std::exception &) { +// Stack->PushNULL(); +// } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToUpperCase") == 0) { + Stack->CorrectParams(0); + + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + StringUtil::ToUpperCase(str); + + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ToLowerCase") == 0) { + Stack->CorrectParams(0); + + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + StringUtil::ToLowerCase(str); + + if (Game->_textEncoding == TEXT_UTF8) + Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + else + Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "IndexOf") == 0) { + Stack->CorrectParams(2); + + const char *strToFind = Stack->Pop()->GetString(); + int index = Stack->Pop()->GetInt(); + + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString toFind; + if (Game->_textEncoding == TEXT_UTF8) + toFind = StringUtil::Utf8ToWide(strToFind); + else + toFind = StringUtil::AnsiToWide(strToFind); + + int indexOf = StringUtil::IndexOf(str, toFind, index); + Stack->PushInt(indexOf); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Split") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + char Separators[MAX_PATH] = ","; + if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); + + CSXArray *Array = new CSXArray(Game); + if (!Array) { + Stack->PushNULL(); + return S_OK; + } + + + WideString str; + if (Game->_textEncoding == TEXT_UTF8) + str = StringUtil::Utf8ToWide(_string); + else + str = StringUtil::AnsiToWide(_string); + + WideString delims; + if (Game->_textEncoding == TEXT_UTF8) + delims = StringUtil::Utf8ToWide(Separators); + else + delims = StringUtil::AnsiToWide(Separators); + + Common::Array parts; + + + size_t start, pos; + start = 0; + do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size()); + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (Game->_textEncoding == TEXT_UTF8) + Val = new CScValue(Game, StringUtil::WideToUtf8(part).c_str()); + else + Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); + + Array->Push(Val); + delete[] Val; + Val = NULL; + } + + Stack->PushNative(Array, false); + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Length") == 0) { + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(_string); + _scValue->SetInt(wstr.size()); + } else + _scValue->SetInt(strlen(_string)); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Capacity") == 0) { + _scValue->SetInt(_capacity); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Capacity") == 0) { + int NewCap = Value->GetInt(); + if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); + else if (NewCap != _capacity) { + char *NewStr = new char[NewCap]; + if (NewStr) { + memset(NewStr, 0, NewCap); + strcpy(NewStr, _string); + delete[] _string; + _string = NewStr; + _capacity = NewCap; + } + } + return S_OK; + } + + else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { + + CBScriptable::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_capacity)); + + if (PersistMgr->_saving) { + if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + PersistMgr->GetBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::ScCompare(CBScriptable *Val) { + return strcmp(_string, ((CSXString *)Val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h new file mode 100644 index 0000000000..649a6c6f24 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int ScCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *ScGetProperty(const char *Name); + HRESULT ScSetProperty(const char *Name, CScValue *Value); + HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + void ScSetString(const char *Val); + const char *ScToString(); + void SetStringVal(const char *Val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp new file mode 100644 index 0000000000..9929fd7ce2 --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -0,0 +1,854 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/SXMath.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BFileManager.h" +#include +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + Game->LOG(0, "Initializing scripting engine..."); + +/* +#ifdef __WIN32__ + char CompilerPath[MAX_PATH]; + strcpy(CompilerPath, COMPILER_DLL); + + _compilerDLL = ::LoadLibrary(CompilerPath); + if (_compilerDLL == NULL) { + char ModuleName[MAX_PATH]; + ::GetModuleFileName(NULL, ModuleName, MAX_PATH); + + // switch to exe's dir + char *ExeDir = CBUtils::GetPath(ModuleName); + sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); + _compilerDLL = ::LoadLibrary(CompilerPath); + + delete [] ExeDir; + } + if (_compilerDLL != NULL) { + // bind compiler's functionality + ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); + ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); + ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); + ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); + ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); + ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); + + if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { + _compilerAvailable = false; + ::FreeLibrary(_compilerDLL); + _compilerDLL = NULL; + } else { + */ /* + // publish external methods to the compiler + CALLBACKS c; + c.Dll_AddError = AddError; + c.Dll_CloseFile = CloseFile; + c.Dll_LoadFile = LoadFile; + ExtSetCallbacks(&c, Game); + */ +/* + _compilerAvailable = true; + } + } else _compilerAvailable = false; +#else +*/ + _compilerAvailable = false; + _compilerDLL = NULL; +//#endif + + + if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); + else Game->LOG(0, " Script compiler is NOT available"); + + _globals = new CScValue(Game); + + + // register 'Game' as global variable + if (!_globals->PropExists("Game")) { + CScValue val(Game); + val.SetNative(Game, true); + _globals->SetProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->PropExists("Math")) { + CScValue val(Game); + val.SetNative(Game->_mathClass, true); + _globals->SetProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + + _currentScript = NULL; + + _fileToCompile = NULL; + + _compileErrorCallback = NULL; + _compileErrorCallbackData = NULL; + + _parseElementCallback = NULL; + _parseElementCallbackData = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + Game->LOG(0, "Shutting down scripting engine"); + SaveBreakpoints(); + + DisableProfiling(); +#ifdef __WIN32__ + if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); +#endif + Cleanup(); + + for (int i = 0; i < _breakpoints.GetSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; + } + _breakpoints.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Cleanup() { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + delete _scripts[i]; + _scripts.RemoveAt(i); + i--; + } + + _scripts.RemoveAll(); + + delete _globals; + _globals = NULL; + + EmptyScriptCache(); + + _currentScript = NULL; // ref only + + delete[] _fileToCompile; + _fileToCompile = NULL; + + _compileErrorCallback = NULL; + _compileErrorCallbackData = NULL; + + _parseElementCallback = NULL; + _parseElementCallbackData = NULL; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { + CBGame *Game = (CBGame *)Data; + return Game->_fileManager->ReadWholeFile(Filename, Size); +} + + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::CloseFile(void *Data, byte *Buffer) { + delete [] Buffer; +} + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::AddError(void *Data, int Line, char *Text) { + CBGame *Game = (CBGame *)Data; + + if (Game) { + if (Game->_scEngine && Game->_scEngine->_fileToCompile) + Game->LOG(0, "Compiling script '%s'...", Game->_scEngine->_fileToCompile); + Game->LOG(0, " Error@line %d: %s", Line, Text); + + + // redirect to an engine's own callback + if (Game->_scEngine && Game->_scEngine->_compileErrorCallback) { + Game->_scEngine->_compileErrorCallback(Line, Text, Game->_scEngine->_compileErrorCallbackData); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *ElementData) { + CBGame *Game = (CBGame *)Data; + + if (Game) { + // redirect to an engine's own callback + if (Game->_scEngine && Game->_scEngine->_parseElementCallback) { + Game->_scEngine->_parseElementCallback(Line, Type, ElementData, Game->_scEngine->_compileErrorCallbackData); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { + byte *CompBuffer; + uint32 CompSize; + + // get script from cache + CompBuffer = GetCompiledScript(Filename, &CompSize); + if (!CompBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(Game, this); + HRESULT ret = script->Create(Filename, CompBuffer, CompSize, Owner); + if (FAILED(ret)) { + Game->LOG(ret, "Error running script '%s'...", Filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(Game); + if (Owner)val.SetNative(Owner, true); + else val.SetNULL(); + + script->_globals->SetProp("self", &val); + script->_globals->SetProp("this", &val); + + _scripts.Add(script); + Game->GetDebugMgr()->OnScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache) { + int i; + + // is script in cache? + if (!IgnoreCache) { + for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), Filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); + *OutSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *CompBuffer; + uint32 CompSize; + bool CompiledNow = false; + + uint32 Size; + + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); + if (!Buffer) { + Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); + return NULL; + } + + // needs to be compiled? + if (*(uint32 *)Buffer == SCRIPT_MAGIC) { + CompBuffer = Buffer; + CompSize = Size; + } else { + if (!_compilerAvailable) { + Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", Filename); + delete [] Buffer; + return NULL; + } + + CompiledNow = true; + + // publish external methods to the compiler + CALLBACKS c; + c.Dll_AddError = AddError; + c.Dll_CloseFile = CloseFile; + c.Dll_LoadFile = LoadFile; + c.Dll_ParseElement = ParseElement; + ExtSetCallbacks(&c, Game); + + // publish native interfaces + Game->PublishNatives(); + + // We have const char* everywhere but in the DLL-interfaces... + char *tempFileName = new char[strlen(Filename) + 1]; + memcpy(tempFileName, Filename, strlen(Filename) + 1); + + SetFileToCompile(Filename); + CompBuffer = ExtCompileFile(tempFileName, &CompSize); + delete[] tempFileName; + if (!CompBuffer) { + Game->QuickMessage("Script compiler error. View log for details."); + delete [] Buffer; + return NULL; + } + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *CachedScript = new CScCachedScript(Filename, CompBuffer, CompSize); + if (CachedScript) { + int index; + uint32 MinTime = CBPlatform::GetTime(); + for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = CachedScript; + + ret = CachedScript->_buffer; + *OutSize = CachedScript->_size; + } + + + // cleanup + delete [] Buffer; + if (CompiledNow) ExtReleaseBuffer(CompBuffer); + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Tick() { + int i; + + if (_scripts.GetSize() == 0) return S_OK; + + + // resolve waiting scripts + for (i = 0; i < _scripts.GetSize(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j_regObjects.GetSize(); j++) + { + if(Game->_regObjects[j] == _scripts[i]->_waitObject) + { + if(Game->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) _scripts[i]->Finish(); // _waitObject no longer exists + */ + if (Game->ValidObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->IsReady()) _scripts[i]->Run(); + } else _scripts[i]->Finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->Run(); + } else { + if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->Run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->PushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->Run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); + _scripts[i]->Run(); + _scripts[i]->_waitScript->Finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + } // switch + } // for each script + + + // execute scripts + for (i = 0; i < _scripts.GetSize(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 StartTime = CBPlatform::GetTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + } + + // normal script + else { + uint32 StartTime; + bool isProfiling = _isProfiling; + if (isProfiling) StartTime = CBPlatform::GetTime(); + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); + } + if (isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + } + _currentScript = NULL; + } + + RemoveFinishedScripts(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::TickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->ExecuteInstruction(); + } + _scripts[i]->Finish(); + _currentScript = NULL; + } + RemoveFinishedScripts(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RemoveFinishedScripts() { + // remove finished scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + Game->GetDebugMgr()->OnScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.RemoveAt(i); + i--; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { + int running = 0, waiting = 0, persistent = 0, total = 0; + + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + running++; + break; + case SCRIPT_WAITING: + waiting++; + break; + case SCRIPT_PERSISTENT: + persistent++; + break; + } + total++; + } + if (Running) *Running = running; + if (Waiting) *Waiting = waiting; + if (Persistent) *Persistent = persistent; + + return total; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::EmptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!Game->_compatKillMethodThreads) ResetScript(_scripts[i]); + + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResetScript(CScScript *Script) { + // terminate all scripts waiting for this script + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == Script) { + _scripts[i]->Finish(); + } + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { + if (!PersistMgr->_saving) Cleanup(); + + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(_currentScript)); + PersistMgr->Transfer(TMEMBER(_fileToCompile)); + PersistMgr->Transfer(TMEMBER(_globals)); + _scripts.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::EditorCleanup() { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.RemoveAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::PauseAll() { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->Pause(); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ResumeAll() { + for (int i = 0; i < _scripts.GetSize(); i++) + _scripts[i]->Resume(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::SetFileToCompile(const char *Filename) { + delete[] _fileToCompile; + _fileToCompile = new char[strlen(Filename) + 1]; + if (_fileToCompile) { + strcpy(_fileToCompile, Filename); + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data) { + _compileErrorCallback = Callback; + _compileErrorCallbackData = Data; +} + +////////////////////////////////////////////////////////////////////////// +void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data) { + _parseElementCallback = Callback; + _parseElementCallbackData = Data; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::IsValidScript(CScScript *Script) { + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i] == Script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::ClearGlobals(bool IncludingNatives) { + _globals->CleanProps(IncludingNatives); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { + // send global variables + _globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->DbgSendScript(Client); + } + + // and threads later + for (int i = 0; i < _scripts.GetSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->DbgSendScript(Client); + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + CScBreakpoint *Bp = NULL; + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { + Bp = _breakpoints[i]; + break; + } + } + if (Bp == NULL) { + Bp = new CScBreakpoint(ScriptFilename); + _breakpoints.Add(Bp); + } + bool Found = false; + for (int i = 0; i < Bp->_lines.GetSize(); i++) { + if (Bp->_lines[i] == Line) return S_OK; + } + Bp->_lines.Add(Line); + + // refresh changes + RefreshScriptBreakpoints(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { + if (_breakpoints[i]->_lines[j] == Line) { + _breakpoints[i]->_lines.RemoveAt(j); + if (_breakpoints[i]->_lines.GetSize() == 0) { + delete _breakpoints[i]; + _breakpoints.RemoveAt(i); + } + // refresh changes + RefreshScriptBreakpoints(); + + return S_OK; + } + } + break; + } + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RefreshScriptBreakpoints() { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + for (int i = 0; i < _scripts.GetSize(); i++) { + RefreshScriptBreakpoints(_scripts[i]); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + if (!Script || !Script->_filename) return E_FAIL; + + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), Script->_filename) == 0) { + Script->_breakpoints.Copy(_breakpoints[i]->_lines); + return S_OK; + } + } + if (Script->_breakpoints.GetSize() > 0) Script->_breakpoints.RemoveAll(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::SaveBreakpoints() { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + + char Text[512]; + char Key[100]; + + int Count = 0; + for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { + Count++; + sprintf(Key, "Breakpoint%d", Count); + sprintf(Text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + + Game->_registry->WriteString("Debug", Key, Text); + } + } + Game->_registry->WriteInt("Debug", "NumBreakpoints", Count); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScEngine::LoadBreakpoints() { + if (!Game->GetDebugMgr()->_enabled) return S_OK; + + char Key[100]; + + int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= Count; i++) { + /* uint32 BufSize = 512; */ + sprintf(Key, "Breakpoint%d", i); + AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); + + char *Path = CBUtils::StrEntry(0, breakpoint.c_str(), ':'); + char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); + + if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); + delete[] Path; + delete[] Line; + Path = NULL; + Line = NULL; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { + if (!_isProfiling) return; + + AnsiString fileName = Filename; + StringUtil::ToLowerCase(fileName); + _scriptTimes[fileName] += Time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::EnableProfiling() { + if (_isProfiling) return; + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = CBPlatform::GetTime(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::DisableProfiling() { + if (!_isProfiling) return; + + DumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::DumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + Game->LOG(0, "***** Script profiling information: *****"); + Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h new file mode 100644 index 0000000000..5e2e5861e7 --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -0,0 +1,174 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); +typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); +typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); +typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); +typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); /* Was non-const, changed to silence warnings */ +typedef int (*DLL_DEFINE_VARIABLE)(const char *Name); /* Was non-const, changed to silence warnings */ + +typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); +typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(const char *Filename, byte *Buffer, uint32 Size) { + _timestamp = CBPlatform::GetTime(); + _buffer = new byte[Size]; + if (_buffer) memcpy(_buffer, Buffer, Size); + _size = Size; + _filename = Filename; + }; + + ~CScCachedScript() { + if (_buffer) delete [] _buffer; + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *Filename) { + _filename = Filename; + } + + ~CScBreakpoint() { + _lines.RemoveAll(); + } + + Common::String _filename; + CBArray _lines; + }; + + + + +public: + HRESULT DbgSendScripts(IWmeDebugClient *Client); + + CBArray _breakpoints; + HRESULT AddBreakpoint(const char *ScriptFilename, int Line); + HRESULT RemoveBreakpoint(const char *ScriptFilename, int Line); + HRESULT RefreshScriptBreakpoints(); + HRESULT RefreshScriptBreakpoints(CScScript *Script); + HRESULT SaveBreakpoints(); + HRESULT LoadBreakpoints(); + + HRESULT ClearGlobals(bool IncludingNatives = false); + HRESULT TickUnbreakable(); + HRESULT RemoveFinishedScripts(); + bool IsValidScript(CScScript *Script); + void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); + void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); + + COMPILE_ERROR_CALLBACK _compileErrorCallback; + void *_compileErrorCallbackData; + + PARSE_ELEMENT_CALLBACK _parseElementCallback; + void *_parseElementCallbackData; + + HRESULT SetFileToCompile(const char *Filename); + char *_fileToCompile; + CScScript *_currentScript; + HRESULT ResumeAll(); + HRESULT PauseAll(); + void EditorCleanup(); + HRESULT ResetObject(CBObject *Object); + HRESULT ResetScript(CScScript *Script); + HRESULT EmptyScriptCache(); + byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + HRESULT Cleanup(); + int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); + HRESULT Tick(); + CScValue *_globals; + CScScript *RunScript(const char *Filename, CBScriptHolder *Owner = NULL); + bool _compilerAvailable; + HINSTANCE _compilerDLL; + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static void WINAPI AddError(void *Data, int Line, char *Text); + static byte *WINAPI LoadFile(void *Data, char *Filename, uint32 *Size); + static void WINAPI CloseFile(void *Data, byte *Buffer); + static void WINAPI ParseElement(void *Data, int Line, int Type, void *ElementData); + DLL_COMPILE_BUFFER ExtCompileBuffer; + DLL_COMPILE_FILE ExtCompileFile; + DLL_RELEASE_BUFFER ExtReleaseBuffer; + DLL_SET_CALLBACKS ExtSetCallbacks; + DLL_DEFINE_FUNCTION ExtDefineFunction; + DLL_DEFINE_VARIABLE ExtDefineVariable; + + CBArray _scripts; + + void EnableProfiling(); + void DisableProfiling(); + bool IsProfiling() { + return _isProfiling; + } + + void AddScriptTime(const char *Filename, uint32 Time); + void DumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp new file mode 100644 index 0000000000..7a2f0db62a --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -0,0 +1,1600 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = Engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + Cleanup(); +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::InitScript() { + TScriptHeader *Header = (TScriptHeader *)_buffer; + if (Header->magic != SCRIPT_MAGIC) { + Game->LOG(0, "File '%s' is not a valid compiled script", _filename); + Cleanup(); + return E_FAIL; + } + + if (Header->version > SCRIPT_VERSION) { + Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + Cleanup(); + return E_FAIL; + } + + InitTables(); + + // init stacks + _scopeStack = new CScStack(Game); + _callStack = new CScStack(Game); + _thisStack = new CScStack(Game); + _stack = new CScStack(Game); + + _operand = new CScValue(Game); + _reg1 = new CScValue(Game); + + + // skip to the beginning + _iP = Header->code_start; + _currentLine = 0; + + // init breakpoints + _engine->RefreshScriptBreakpoints(this); + + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::InitTables() { + uint32 OrigIP = _iP; + + TScriptHeader *Header = (TScriptHeader *)_buffer; + + int32 i; + + // load symbol table + _iP = Header->symbol_table; + + _numSymbols = GetDWORD(); + _symbols = new char*[_numSymbols]; + for (i = 0; i < _numSymbols; i++) { + uint32 index = GetDWORD(); + _symbols[index] = GetString(); + } + + // load functions table + _iP = Header->func_table; + + _numFunctions = GetDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (i = 0; i < _numFunctions; i++) { + _functions[i].pos = GetDWORD(); + _functions[i].name = GetString(); + } + + + // load events table + _iP = Header->event_table; + + _numEvents = GetDWORD(); + _events = new TEventPos[_numEvents]; + for (i = 0; i < _numEvents; i++) { + _events[i].pos = GetDWORD(); + _events[i].name = GetString(); + } + + + // load externals + if (Header->version >= 0x0101) { + _iP = Header->externals_table; + + _numExternals = GetDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (i = 0; i < _numExternals; i++) { + _externals[i].dll_name = GetString(); + _externals[i].name = GetString(); + _externals[i].call_type = (TCallType)GetDWORD(); + _externals[i].returns = (TExternalType)GetDWORD(); + _externals[i].nu_params = GetDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)GetDWORD(); + } + } + } + } + + // load method table + _iP = Header->method_table; + + _numMethods = GetDWORD(); + _methods = new TMethodPos[_numMethods]; + for (i = 0; i < _numMethods; i++) { + _methods[i].pos = GetDWORD(); + _methods[i].name = GetString(); + } + + + _iP = OrigIP; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { + Cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); + + _buffer = new byte [Size]; + if (!_buffer) return E_FAIL; + + memcpy(_buffer, Buffer, Size); + + _bufferSize = Size; + + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // establish global variables table + _globals = new CScValue(Game); + + _owner = Owner; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { + Cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(EventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, EventName); + + // copy filename + _filename = new char[strlen(Original->_filename) + 1]; + if (_filename) strcpy(_filename, Original->_filename); + + // copy buffer + _buffer = new byte [Original->_bufferSize]; + if (!_buffer) return E_FAIL; + + memcpy(_buffer, Original->_buffer, Original->_bufferSize); + _bufferSize = Original->_bufferSize; + + // initialize + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // copy globals + _globals = Original->_globals; + + // skip to the beginning of the event + _iP = InitIP; + + _timeSlice = Original->_timeSlice; + _freezable = Original->_freezable; + _owner = Original->_owner; + + _engine = Original->_engine; + _parentScript = Original; + + return S_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodName) { + uint32 IP = Original->GetMethodPos(MethodName); + if (IP == 0) return E_FAIL; + + Cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(MethodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, MethodName); + + // copy filename + _filename = new char[strlen(Original->_filename) + 1]; + if (_filename) strcpy(_filename, Original->_filename); + + // copy buffer + _buffer = new byte [Original->_bufferSize]; + if (!_buffer) return E_FAIL; + + memcpy(_buffer, Original->_buffer, Original->_bufferSize); + _bufferSize = Original->_bufferSize; + + // initialize + HRESULT res = InitScript(); + if (FAILED(res)) return res; + + // copy globals + _globals = Original->_globals; + + // skip to the beginning of the event + _iP = IP; + + _timeSlice = Original->_timeSlice; + _freezable = Original->_freezable; + _owner = Original->_owner; + + _engine = Original->_engine; + _parentScript = Original; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::Cleanup() { + if (_buffer) delete [] _buffer; + _buffer = NULL; + + if (_filename) delete [] _filename; + _filename = NULL; + + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) delete _globals; + _globals = NULL; + + if (_scopeStack) delete _scopeStack; + _scopeStack = NULL; + + if (_callStack) delete _callStack; + _callStack = NULL; + + if (_thisStack) delete _thisStack; + _thisStack = NULL; + + if (_stack) delete _stack; + _stack = NULL; + + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; + + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; + + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (int i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; + } + delete [] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetDWORD() { + uint32 ret = *(uint32 *)(_buffer + _iP); + _iP += sizeof(uint32); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +double CScScript::GetFloat() { + double ret = *(double *)(_buffer + _iP); + _iP += sizeof(double); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::GetString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::ExecuteInstruction() { + HRESULT ret = S_OK; + + uint32 dw; + const char *str = NULL; + + //CScValue* op = new CScValue(Game); + _operand->Cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = GetDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->SetNULL(); + dw = GetDWORD(); + if (_scopeStack->_sP < 0) { + _globals->SetProp(_symbols[dw], _operand); + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); + } else { + _scopeStack->GetTop()->SetProp(_symbols[dw], _operand); + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->GetTop(), _scopeStack->GetTop()->GetProp(_symbols[dw]), _symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = GetDWORD(); +/* char *Temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->PropExists(_symbols[dw])) { + _operand->SetNULL(); + _engine->_globals->SetProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->GetProp(_symbols[dw]), _symbols[dw]); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->GetTop()); + + _scopeStack->Pop(); + _iP = (uint32)_callStack->Pop()->GetInt(); + + if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = GetDWORD(); + + _operand->SetInt(_iP); + _callStack->Push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->Pop()->GetString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = _stack->Pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + + HRESULT res = E_FAIL; + bool TriedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->GetNative()) { + TriedNative = true; + res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); + } + + if (FAILED(res)) { + if (var->IsNative() && var->GetNative()->CanHandleMethod(MethodName)) { + if (!_unbreakable) { + _waitScript = var->GetNative()->InvokeMethodThread(MethodName); + if (!_waitScript) { + _stack->CorrectParams(0); + RuntimeError("Error invoking method '%s'.", MethodName); + _stack->PushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->CopyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->CorrectParams(0); + RuntimeError("Cannot call method '%s'. Ignored.", MethodName); + _stack->PushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->GetProp(MethodName); + if(val){ + dw = GetFuncPos(val->GetString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->GetString()); + if(f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + Game->ExternalCall(this, _stack, _thisStack, val->GetString()); + } + } + else{ + _operand->SetInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = E_FAIL; + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); + + if (FAILED(res)) { + _stack->CorrectParams(0); + RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); + _stack->PushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = GetDWORD(); + + TExternalFunction *f = GetExternal(_symbols[SymbolIndex]); + if (f) { + ExternalCall(_stack, _thisStack, f); + } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + _operand->SetNULL(); + _scopeStack->Push(_operand); + + if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + + break; + + case II_CORRECT_STACK: + dw = GetDWORD(); // params expected + _stack->CorrectParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->SetObject(); + _stack->Push(_operand); + break; + + case II_POP_EMPTY: + _stack->Pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = GetVar(_symbols[GetDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->SetReference(var); + _stack->Push(_operand); + } else _stack->Push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = GetVar(_symbols[GetDWORD()]); + _operand->SetReference(var); + _stack->Push(_operand); + break; + } + + case II_POP_VAR: { + char *VarName = _symbols[GetDWORD()]; + CScValue *var = GetVar(VarName); + if (var) { + CScValue *val = _stack->Pop(); + if (!val) { + RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->SetNULL(); + } else { + if (val->GetType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->SetValue(val); + else { + var->Copy(val); + } + } + + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->Push(_thisStack->GetTop()); + break; + + case II_PUSH_INT: + _stack->PushInt((int)GetDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->PushFloat(GetFloat()); + break; + + + case II_PUSH_BOOL: + _stack->PushBool(GetDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->PushString(GetString()); + break; + + case II_PUSH_NULL: + _stack->PushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->SetReference(_stack->GetTop()); + _thisStack->Push(_operand); + break; + + case II_PUSH_THIS: + _operand->SetReference(GetVar(_symbols[GetDWORD()])); + _thisStack->Push(_operand); + break; + + case II_POP_THIS: + _thisStack->Pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->Pop()->GetString(); + CScValue *val = _stack->Pop()->GetProp(str); + if (val) _stack->Push(val); + else _stack->PushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = _stack->Pop()->GetString(); + CScValue *var = _stack->Pop(); + CScValue *val = _stack->Pop(); + + if (val == NULL) { + RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->SetNULL(); + } else var->SetProp(str, val); + + if (Game->GetDebugMgr()->_enabled) + Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + _stack->Push(_reg1); + break; + + case II_POP_REG1: + _reg1->Copy(_stack->Pop()); + break; + + case II_JMP: + _iP = GetDWORD(); + break; + + case II_JMP_FALSE: { + dw = GetDWORD(); + //if(!_stack->Pop()->GetBool()) _iP = dw; + CScValue *Val = _stack->Pop(); + if (!Val) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!Val->GetBool()) _iP = dw; + } + break; + } + + case II_ADD: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); + else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; + strcpy(tempStr, op1->GetString()); + strcat(tempStr, op2->GetString()); + _operand->SetString(str); + delete [] tempStr; + } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + _operand->SetInt(op1->GetInt() + op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); + + _stack->Push(_operand); + + break; + + case II_SUB: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); + else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + _operand->SetInt(op1->GetInt() - op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); + + _stack->Push(_operand); + + break; + + case II_MUL: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); + else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) + _operand->SetInt(op1->GetInt() * op2->GetInt()); + else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); + + _stack->Push(_operand); + + break; + + case II_DIV: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); + + if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); + else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); + + _stack->Push(_operand); + + break; + + case II_MODULO: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + if (op2->GetInt() == 0) RuntimeError("Division by zero."); + + if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); + else _operand->SetInt(op1->GetInt() % op2->GetInt()); + + _stack->Push(_operand); + + break; + + case II_NOT: + op1 = _stack->Pop(); + //if(op1->IsNULL()) _operand->SetNULL(); + if (op1->IsNULL()) _operand->SetBool(true); + else _operand->SetBool(!op1->GetBool()); + _stack->Push(_operand); + + break; + + case II_AND: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + if (op1 == NULL || op2 == NULL) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->SetBool(false); + } else { + _operand->SetBool(op1->GetBool() && op2->GetBool()); + } + _stack->Push(_operand); + break; + + case II_OR: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + if (op1 == NULL || op2 == NULL) { + RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->SetBool(false); + } else { + _operand->SetBool(op1->GetBool() || op2->GetBool()); + } + _stack->Push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); + else if(op1->IsNative() && op2->IsNative()){ + _operand->SetBool(op1->GetNative() == op2->GetNative()); + } + else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ + _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); + } + else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() == op2->GetFloat()); + } + else{ + _operand->SetBool(op1->GetInt() == op2->GetInt()); + } + */ + + _operand->SetBool(CScValue::Compare(op1, op2) == 0); + _stack->Push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); + else if(op1->IsNative() && op2->IsNative()){ + _operand->SetBool(op1->GetNative() != op2->GetNative()); + } + else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ + _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); + } + else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() != op2->GetFloat()); + } + else{ + _operand->SetBool(op1->GetInt() != op2->GetInt()); + } + */ + + _operand->SetBool(CScValue::Compare(op1, op2) != 0); + _stack->Push(_operand); + break; + + case II_CMP_L: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() < op2->GetFloat()); + } + else _operand->SetBool(op1->GetInt() < op2->GetInt()); + */ + + _operand->SetBool(CScValue::Compare(op1, op2) < 0); + _stack->Push(_operand); + break; + + case II_CMP_G: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() > op2->GetFloat()); + } + else _operand->SetBool(op1->GetInt() > op2->GetInt()); + */ + + _operand->SetBool(CScValue::Compare(op1, op2) > 0); + _stack->Push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() <= op2->GetFloat()); + } + else _operand->SetBool(op1->GetInt() <= op2->GetInt()); + */ + + _operand->SetBool(CScValue::Compare(op1, op2) <= 0); + _stack->Push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + /* + if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ + _operand->SetBool(op1->GetFloat() >= op2->GetFloat()); + } + else _operand->SetBool(op1->GetInt() >= op2->GetInt()); + */ + + _operand->SetBool(CScValue::Compare(op1, op2) >= 0); + _stack->Push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); + _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); + _stack->Push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->Pop(); + op1 = _stack->Pop(); + + //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); + _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); + _stack->Push(_operand); + break; + + case II_DBG_LINE: { + int NewLine = GetDWORD(); + if (NewLine != _currentLine) { + _currentLine = NewLine; + if (Game->GetDebugMgr()->_enabled) { + Game->GetDebugMgr()->OnScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.GetSize(); i++) { + if (_breakpoints[i] == _currentLine) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Sleep(0); + break; + } + } + if (_tracingMode) { + Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Sleep(0); + break; + } + } + } + break; + + } + default: + Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = E_FAIL; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetFuncPos(const char *Name) { + for (int i = 0; i < _numFunctions; i++) { + if (strcmp(Name, _functions[i].name) == 0) return _functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetMethodPos(const char *Name) { + for (int i = 0; i < _numMethods; i++) { + if (strcmp(Name, _methods[i].name) == 0) return _methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::GetVar(char *Name) { + CScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->GetTop()->PropExists(Name)) ret = _scopeStack->GetTop()->GetProp(Name); + } + + // script globals + if (ret == NULL) { + if (_globals->PropExists(Name)) ret = _globals->GetProp(Name); + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->PropExists(Name)) ret = _engine->_globals->GetProp(Name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", Name); + Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, _filename, _currentLine); + CScValue *Val = new CScValue(Game); + CScValue *Scope = _scopeStack->GetTop(); + if (Scope) { + Scope->SetProp(Name, Val); + ret = _scopeStack->GetTop()->GetProp(Name); + } else { + _globals->SetProp(Name, Val); + ret = _globals->GetProp(Name); + } + delete Val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::WaitFor(CBObject *Object) { + if (_unbreakable) { + RuntimeError("Script cannot be interrupted."); + return S_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = Object; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::WaitForExclusive(CBObject *Object) { + _engine->ResetObject(Object); + return WaitFor(Object); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Sleep(uint32 Duration) { + if (_unbreakable) { + RuntimeError("Script cannot be interrupted."); + return S_OK; + } + + _state = SCRIPT_SLEEPING; + if (Game->_state == GAME_FROZEN) { + _waitTime = CBPlatform::GetTime() + Duration; + _waitFrozen = true; + } else { + _waitTime = Game->_timer + Duration; + _waitFrozen = false; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Finish(bool IncludingThreads) { + if (_state != SCRIPT_FINISHED && IncludingThreads) { + _state = SCRIPT_FINISHED; + FinishThreads(); + } else _state = SCRIPT_FINISHED; + + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Run() { + _state = SCRIPT_RUNNING; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::RuntimeError(LPCSTR fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + Game->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + Game->LOG(0, " %s", buff); + + if (!Game->_suppressScriptErrors) + Game->QuickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + // buffer + if (PersistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + PersistMgr->Transfer(TMEMBER(_bufferSize)); + PersistMgr->PutBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + PersistMgr->Transfer(TMEMBER(bufferSize)); + } + } else { + PersistMgr->Transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + PersistMgr->GetBytes(_buffer, _bufferSize); + InitTables(); + } else _buffer = NULL; + } + + PersistMgr->Transfer(TMEMBER(_callStack)); + PersistMgr->Transfer(TMEMBER(_currentLine)); + PersistMgr->Transfer(TMEMBER(_engine)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_freezable)); + PersistMgr->Transfer(TMEMBER(_globals)); + PersistMgr->Transfer(TMEMBER(_iP)); + PersistMgr->Transfer(TMEMBER(_scopeStack)); + PersistMgr->Transfer(TMEMBER(_stack)); + PersistMgr->Transfer(TMEMBER_INT(_state)); + PersistMgr->Transfer(TMEMBER(_operand)); + PersistMgr->Transfer(TMEMBER_INT(_origState)); + PersistMgr->Transfer(TMEMBER(_owner)); + PersistMgr->Transfer(TMEMBER(_reg1)); + PersistMgr->Transfer(TMEMBER(_thread)); + PersistMgr->Transfer(TMEMBER(_threadEvent)); + PersistMgr->Transfer(TMEMBER(_thisStack)); + PersistMgr->Transfer(TMEMBER(_timeSlice)); + PersistMgr->Transfer(TMEMBER(_waitObject)); + PersistMgr->Transfer(TMEMBER(_waitScript)); + PersistMgr->Transfer(TMEMBER(_waitTime)); + PersistMgr->Transfer(TMEMBER(_waitFrozen)); + + PersistMgr->Transfer(TMEMBER(_methodThread)); + PersistMgr->Transfer(TMEMBER(_methodThread)); + PersistMgr->Transfer(TMEMBER(_unbreakable)); + PersistMgr->Transfer(TMEMBER(_parentScript)); + + if (!PersistMgr->_saving) _tracingMode = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable) { + //if(_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = GetEventPos(EventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(Game, _engine); + if (thread) { + HRESULT ret = thread->CreateThread(this, pos, EventName); + if (SUCCEEDED(ret)) { + thread->_unbreakable = Unbreakable; + _engine->_scripts.Add(thread); + Game->GetDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::GetEventPos(const char *Name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(Name, _events[i].name) == 0) return _events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::CanHandleEvent(const char *EventName) { + return GetEventPos(EventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::CanHandleMethod(const char *MethodName) { + return GetMethodPos(MethodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Pause() { + if (_state == SCRIPT_PAUSED) { + Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return E_FAIL; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) return S_OK; + + _origState = _state; + _state = SCRIPT_PAUSED; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::Resume() { + if (_state != SCRIPT_PAUSED) return S_OK; + + _state = _origState; + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::GetExternal(char *Name) { + for (int i = 0; i < _numExternals; i++) { + if (strcmp(Name, _externals[i].name) == 0) return &_externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function) { + +#ifndef __WIN32__ + + Game->LOG(0, "External functions are not supported on this platform."); + Stack->CorrectParams(0); + Stack->PushNULL(); + return E_FAIL; + +#else + + bool Success = false; + HMODULE hDll = LoadLibrary(Function->dll_name); + + if (hDll) { + FARPROC pFunc = GetProcAddress(hDll, Function->name); + if (pFunc) { + int i; + Success = true; + Stack->CorrectParams(Function->nu_params); + CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); + + for (i = 0; i < Function->nu_params; i++) { + CScValue *Val = Stack->Pop(); + switch (Function->params[i]) { + case TYPE_BOOL: + Buffer->PutDWORD((uint32)Val->GetBool()); + break; + case TYPE_LONG: + Buffer->PutDWORD(Val->GetInt()); + break; + case TYPE_BYTE: + Buffer->PutDWORD((byte)Val->GetInt()); + break; + case TYPE_STRING: + if (Val->IsNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->GetString()); + break; + case TYPE_MEMBUFFER: + if (Val->IsNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->GetMemBuffer()); + break; + case TYPE_FLOAT: { + float f = Val->GetFloat(); + Buffer->PutDWORD(*((uint32 *)&f)); + break; + } + case TYPE_DOUBLE: { + double d = Val->GetFloat(); + uint32 *pd = (uint32 *)&d; + + Buffer->PutDWORD(pd[0]); + Buffer->PutDWORD(pd[1]); + break; + } + } + } + + // call + uint32 ret; + bool StackCorrupted = false; + switch (Function->call_type) { + case CALL_CDECL: + ret = Call_cdecl(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + break; + default: + ret = Call_stdcall(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + } + delete Buffer; + + // return + switch (Function->returns) { + case TYPE_BOOL: + Stack->PushBool((byte)ret != 0); + break; + case TYPE_LONG: + Stack->PushInt(ret); + break; + case TYPE_BYTE: + Stack->PushInt((byte)ret); + break; + break; + case TYPE_STRING: + Stack->PushString((char *)ret); + break; + case TYPE_MEMBUFFER: { + CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); + Stack->PushNative(Buf, false); + } + break; + case TYPE_FLOAT: { + uint32 dw = GetST0(); + Stack->PushFloat(*((float *)&dw)); + break; + } + case TYPE_DOUBLE: + Stack->PushFloat(GetST0Double()); + break; + + default: + Stack->PushNULL(); + } + + if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); + } else RuntimeError("Exported function '%s' not found in '%s'", Function->name, Function->dll_name); + } else RuntimeError("Error loading DLL '%s'", Function->dll_name); + + if (!Success) { + Stack->CorrectParams(0); + Stack->PushNULL(); + } + + if (hDll) FreeLibrary(hDll); + + return Success ? S_OK : E_FAIL; +#endif +} + +#ifdef __WIN32__ +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { + uint32 rc; // here's our return value... + uint32 OrigESP; + bool StkCorrupt = false; + __asm { + mov OrigESP, esp + mov ecx, sz // get size of buffer + mov esi, args // get buffer + sub esp, ecx // allocate stack space + mov edi, esp // start of destination stack frame + shr ecx, 2 // make it dwords + rep movsd // copy params to real stack + call [func] // call the function + mov rc, eax // save the return value + add esp, sz // restore the stack pointer + cmp esp, OrigESP + jz finish + mov esp, OrigESP + mov StkCorrupt, 1 + finish: + } + + if (StackCorrupt) *StackCorrupt = StkCorrupt; + return rc; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { + uint32 rc; // here's our return value... + uint32 OrigESP; + bool StkCorrupt = false; + + __asm { + mov OrigESP, esp + mov ecx, sz // get size of buffer + mov esi, args // get buffer + sub esp, ecx // allocate stack space + mov edi, esp // start of destination stack frame + shr ecx, 2 // make it dwords + rep movsd // copy it + call [func] // call the function + mov rc, eax // save the return value + cmp esp, OrigESP + jz finish + mov esp, OrigESP + mov StkCorrupt, 1 + finish: + } + + if (StackCorrupt) *StackCorrupt = StkCorrupt; + return rc; +} + + +////////////////////////////////////////////////////////////////////////// +__declspec(naked) uint32 CScScript::GetST0(void) { + uint32 f; // temp var + __asm { + fstp uint32 ptr [f] // pop ST0 into f + mov eax, uint32 ptr [f] // copy into eax + ret // done + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScScript::GetST0Double(void) { + double d; // temp var + __asm { + fstp qword ptr [d] // get ST0 into d + } + return d; +} +#endif + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::CopyParameters(CScStack *Stack) { + int i; + int NumParams = Stack->Pop()->GetInt(); + for (i = NumParams - 1; i >= 0; i--) { + _stack->Push(Stack->GetAt(i)); + } + _stack->PushInt(NumParams); + + for (i = 0; i < NumParams; i++) Stack->Pop(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::FinishThreads() { + for (int i = 0; i < _engine->_scripts.GetSize(); i++) { + CScScript *Scr = _engine->_scripts[i]; + if (Scr->_thread && Scr->_state != SCRIPT_FINISHED && Scr->_owner == _owner && scumm_stricmp(Scr->_filename, _filename) == 0) + Scr->Finish(true); + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::DbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::DbgGetFilename() { + return _filename; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { + if (_methodThread) Client->OnScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) Client->OnScriptEventThreadInit(this, _parentScript, _threadEvent); + else Client->OnScriptInit(this); + + return DbgSendVariables(Client); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { + // send script globals + _globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + // CScValue *Scope = _scopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::DbgGetState() { + return _state; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::DbgGetNumBreakpoints() { + return _breakpoints.GetSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::DbgGetBreakpoint(int Index) { + if (Index >= 0 && Index < _breakpoints.GetSize()) return _breakpoints[Index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::DbgSetTracingMode(bool IsTracing) { + _tracingMode = IsTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::DbgGetTracingMode() { + return _tracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::AfterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->GetCompiledScript(_filename, &_bufferSize); + if (!buffer) { + Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + InitTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h new file mode 100644 index 0000000000..226e6d8031 --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -0,0 +1,185 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + HRESULT DbgSendScript(IWmeDebugClient *Client); + HRESULT DbgSendVariables(IWmeDebugClient *Client); + + CBArray _breakpoints; + bool _tracingMode; + + CScScript *_parentScript; + bool _unbreakable; + HRESULT FinishThreads(); + HRESULT CopyParameters(CScStack *Stack); + + void AfterLoad(); + +#ifdef __WIN32__ + static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt); + static uint32 Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt); + static uint32 GetST0(void); + static double GetST0Double(void); +#endif + + CScValue *_operand; + CScValue *_reg1; + bool _freezable; + HRESULT Resume(); + HRESULT Pause(); + bool CanHandleEvent(const char *EventName); + bool CanHandleMethod(const char *MethodName); + HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); + HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); + CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void RuntimeError(LPCSTR fmt, ...); + HRESULT Run(); + HRESULT Finish(bool IncludingThreads = false); + HRESULT Sleep(uint32 Duration); + HRESULT WaitForExclusive(CBObject *Object); + HRESULT WaitFor(CBObject *Object); + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + CScValue *GetVar(char *Name); + uint32 GetFuncPos(const char *Name); + uint32 GetEventPos(const char *Name); + uint32 GetMethodPos(const char *Name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; + HRESULT ExecuteInstruction(); + char *GetString(); + uint32 GetDWORD(); + double GetFloat(); + void Cleanup(); + HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); + uint32 _iP; + uint32 _bufferSize; + byte *_buffer; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *_filename; + char **_symbols; + int _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + int _numExternals; + TExternalFunction *_externals; + int _numFunctions; + int _numMethods; + int _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; + CScScript::TExternalFunction *GetExternal(char *Name); + HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); +private: + HRESULT InitScript(); + HRESULT InitTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int DbgGetLine(); + virtual const char *DbgGetFilename(); + virtual TScriptState DbgGetState(); + virtual int DbgGetNumBreakpoints(); + virtual int DbgGetBreakpoint(int Index); + + virtual bool DbgSetTracingMode(bool IsTracing); + virtual bool DbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp new file mode 100644 index 0000000000..26e8aa118b --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -0,0 +1,226 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.GetSize(), _sP); +#endif + + for (int i = 0; i < _values.GetSize(); i++) { + delete _values[i]; + } + _values.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::Pop() { + if (_sP < 0) { + Game->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::Push(CScValue *Val) { + _sP++; + + if (_sP < _values.GetSize()) { + _values[_sP]->Cleanup(); + _values[_sP]->Copy(Val); + } else { + CScValue *val = new CScValue(Game); + val->Copy(Val); + _values.Add(val); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetPushValue() { + _sP++; + + if (_sP >= _values.GetSize()) { + CScValue *val = new CScValue(Game); + _values.Add(val); + } + _values[_sP]->Cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetTop() { + if (_sP < 0 || _sP >= _values.GetSize()) return NULL; + else return _values[_sP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::GetAt(int Index) { + Index = _sP - Index; + if (Index < 0 || Index >= _values.GetSize()) return NULL; + else return _values[Index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::CorrectParams(uint32 expected_params) { + int nu_params = Pop()->GetInt(); + + if (expected_params < nu_params) { // too many params + while (expected_params < nu_params) { + //Pop(); + delete _values[_sP - expected_params]; + _values.RemoveAt(_sP - expected_params); + nu_params--; + _sP--; + } + } else if (expected_params > nu_params) { // need more params + while (expected_params > nu_params) { + //Push(null_val); + CScValue *null_val = new CScValue(Game); + null_val->SetNULL(); + _values.InsertAt(_sP - nu_params + 1, null_val); + nu_params++; + _sP++; + + if (_values.GetSize() > _sP + 1) { + delete _values[_values.GetSize() - 1]; + _values.RemoveAt(_values.GetSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushNULL() { + /* + CScValue* val = new CScValue(Game); + val->SetNULL(); + Push(val); + delete val; + */ + GetPushValue()->SetNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushInt(int Val) { + /* + CScValue* val = new CScValue(Game); + val->SetInt(Val); + Push(val); + delete val; + */ + GetPushValue()->SetInt(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushFloat(double Val) { + /* + CScValue* val = new CScValue(Game); + val->SetFloat(Val); + Push(val); + delete val; + */ + GetPushValue()->SetFloat(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushBool(bool Val) { + /* + CScValue* val = new CScValue(Game); + val->SetBool(Val); + Push(val); + delete val; + */ + GetPushValue()->SetBool(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushString(const char *Val) { + /* + CScValue* val = new CScValue(Game); + val->SetString(Val); + Push(val); + delete val; + */ + GetPushValue()->SetString(Val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::PushNative(CBScriptable *Val, bool Persistent) { + /* + CScValue* val = new CScValue(Game); + val->SetNative(Val, Persistent); + Push(val); + delete val; + */ + + GetPushValue()->SetNative(Val, Persistent); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScStack::Persist(CBPersistMgr *PersistMgr) { + + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_sP)); + _values.Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScStack.h b/engines/wintermute/Base/scriptables/ScStack.h new file mode 100644 index 0000000000..3e7f557cdd --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScStack.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *GetAt(int Index); + CScValue *GetPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void PushNative(CBScriptable *Val, bool Persistent); + void PushString(const char *Val); + void PushBool(bool Val); + void PushInt(int Val); + void PushFloat(double Val); + void PushNULL(); + void CorrectParams(uint32 expected_params); + CScValue *GetTop(); + void Push(CScValue *Val); + CScValue *Pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray _values; + int _sP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp new file mode 100644 index 0000000000..ed3778b635 --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -0,0 +1,1028 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/BScriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { + _type = VAL_BOOL; + _valBool = Val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { + _type = VAL_INT; + _valInt = Val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { + _type = VAL_FLOAT; + _valFloat = Val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { + _type = VAL_STRING; + _valString = NULL; + SetStringVal(Val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::Cleanup(bool IgnoreNatives) { + DeleteProps(); + + if (_valString) delete [] _valString; + + if (!IgnoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::GetProp(const char *Name) { + if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(Name); + + if (_type == VAL_STRING && strcmp(Name, "Length") == 0) { + Game->_scValue->_type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (Game->_textEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + Game->_scValue->SetInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::Utf8ToWide(_valString); + Game->_scValue->SetInt(wstr.size()); + } + + return Game->_scValue; + } + + CScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) ret = _valNative->ScGetProperty(Name); + + if (ret == NULL) { + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) ret = _valIter->_value; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::DeleteProp(const char *Name) { + if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(Name); + + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { + if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(Name, Val); + + HRESULT ret = E_FAIL; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->ScSetProperty(Name, Val); + } + + if (FAILED(ret)) { + CScValue *val = NULL; + + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()) { + val = _valIter->_value; + } + if (!val) val = new CScValue(Game); + else val->Cleanup(); + + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if (_type != VAL_NATIVE) _type = VAL_OBJECT; + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + CScValue* val = new CScValue(Game); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::PropExists(const char *Name) { + if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(Name); + _valIter = _valObject.find(Name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::DeleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool IncludingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->IsNative() || IncludingNatives)) _valIter->_value->SetNULL(); + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsNULL() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsNULL(); + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsNative() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsNative(); + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsString() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsString(); + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsFloat() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsFloat(); + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsInt() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsInt(); + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsBool() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsBool(); + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::IsObject() { + if (_type == VAL_VARIABLE_REF) return _valRef->IsObject(); + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::GetTypeTolerant() { + if (_type == VAL_VARIABLE_REF) return _valRef->GetType(); + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetBool(bool Val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetBool(Val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->ScSetBool(Val); + return; + } + + _valBool = Val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetInt(int Val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetInt(Val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->ScSetInt(Val); + return; + } + + _valInt = Val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetFloat(double Val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetFloat(Val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->ScSetFloat(Val); + return; + } + + _valFloat = Val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetString(const char *Val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetString(Val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->ScSetString(Val); + return; + } + + SetStringVal(Val); + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetStringVal(const char *Val) { + if (_valString) { + delete [] _valString; + _valString = NULL; + } + + if (Val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(Val) + 1]; + if (_valString) { + strcpy(_valString, Val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; + } + _valNative = NULL; + DeleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetNative(CBScriptable *Val, bool Persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetNative(Val, Persistent); + return; + } + + if (Val == NULL) { + SetNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != Val) delete _valNative; + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = Persistent; + + _valNative = Val; + if (_valNative && !_persistent) _valNative->_refCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->SetObject(); + return; + } + + DeleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetReference(CScValue *Val) { + _valRef = Val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::GetBool(bool Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->GetBool(); + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->ScToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return Default; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::GetInt(int Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->GetInt(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->ScToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return Default; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::GetFloat(double Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->GetFloat(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->ScToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return Default; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::GetMemBuffer() { + if (_type == VAL_VARIABLE_REF) return _valRef->GetMemBuffer(); + + if (_type == VAL_NATIVE) return _valNative->ScToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::GetString() { + if (_type == VAL_VARIABLE_REF) return _valRef->GetString(); + + switch (_type) { + case VAL_OBJECT: + SetStringVal("[object]"); + break; + + case VAL_NULL: + SetStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *StrVal = _valNative->ScToString(); + SetStringVal(StrVal); + return StrVal; + break; + } + + case VAL_BOOL: + SetStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + SetStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + SetStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + SetStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::GetNative() { + if (_type == VAL_VARIABLE_REF) return _valRef->GetNative(); + + if (_type == VAL_NATIVE) return _valNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::GetType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::Copy(CScValue *orig, bool CopyWhole) { + Game = orig->Game; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && CopyWhole) orig = orig->_valRef; + + Cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + SetStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(Game); + _valObject[orig->_valIter->_key]->Copy(orig->_valIter->_value); + orig->_valIter++; + } + } else _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::SetValue(CScValue *Val) { + if (Val->_type == VAL_VARIABLE_REF) { + SetValue(Val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (Val->_type == VAL_INT || Val->_type == VAL_STRING || Val->_type == VAL_BOOL)) { + switch (Val->_type) { + case VAL_INT: + _valNative->ScSetInt(Val->GetInt()); + break; + case VAL_FLOAT: + _valNative->ScSetFloat(Val->GetFloat()); + break; + case VAL_BOOL: + _valNative->ScSetBool(Val->GetBool()); + break; + case VAL_STRING: + _valNative->ScSetString(Val->GetString()); + break; + } + } + // otherwise just copy everything + else Copy(Val); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { + PersistMgr->Transfer(TMEMBER(Game)); + + PersistMgr->Transfer(TMEMBER(_persistent)); + PersistMgr->Transfer(TMEMBER(_isConstVar)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_valBool)); + PersistMgr->Transfer(TMEMBER(_valFloat)); + PersistMgr->Transfer(TMEMBER(_valInt)); + PersistMgr->Transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (PersistMgr->_saving) { + size = _valObject.size(); + PersistMgr->Transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + PersistMgr->Transfer("", &str); + PersistMgr->Transfer("", &_valIter->_value); + + _valIter++; + } + } else { + CScValue *val; + PersistMgr->Transfer("", &size); + for (int i = 0; i < size; i++) { + PersistMgr->Transfer("", &str); + PersistMgr->Transfer("", &val); + + _valObject[str] = val; + delete [] str; + } + } + + PersistMgr->Transfer(TMEMBER(_valRef)); + PersistMgr->Transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + Buffer->PutTextIndent(Indent, "PROPERTY {\n"); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); + Buffer->PutTextIndent(Indent, "}\n\n"); + + _valIter++; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::Compare(CScValue *Val1, CScValue *Val2) { + // both natives? + if (Val1->IsNative() && Val2->IsNative()) { + // same class? + if (strcmp(Val1->GetNative()->GetClassName(), Val2->GetNative()->GetClassName()) == 0) { + return Val1->GetNative()->ScCompare(Val2->GetNative()); + } else return strcmp(Val1->GetString(), Val2->GetString()); + } + + // both objects? + if (Val1->IsObject() && Val2->IsObject()) return -1; + + + // null states + if (Val1->IsNULL() && !Val2->IsNULL()) return -1; + else if (!Val1->IsNULL() && Val2->IsNULL()) return 1; + else if (Val1->IsNULL() && Val2->IsNULL()) return 0; + + // one of them is string? convert both to string + if (Val1->IsString() || Val2->IsString()) return strcmp(Val1->GetString(), Val2->GetString()); + + // one of them is float? + if (Val1->IsFloat() || Val2->IsFloat()) { + if (Val1->GetFloat() < Val2->GetFloat()) return -1; + else if (Val1->GetFloat() > Val2->GetFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (Val1->GetInt() < Val2->GetInt()) return -1; + else if (Val1->GetInt() > Val2->GetInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { + if (Val1->GetTypeTolerant() != Val2->GetTypeTolerant()) return -1; + else return CScValue::Compare(Val1, Val2); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + Client->OnVariableInit(Type, Script, ScopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, int Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); + delete Val; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, const char *Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); + delete Val; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, double Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName, bool Value) { + CScValue *Val = new CScValue(Game, Value); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::SetProperty(const char *PropName) { + CScValue *Val = new CScValue(Game); + bool Ret = SUCCEEDED(SetProp(PropName, Val)); + delete Val; + return Ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::DbgGetType() { + switch (GetType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::DbgGetValInt() { + return GetInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::DbgGetValFloat() { + return GetFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetValBool() { + return GetBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::DbgGetValString() { + return GetString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::DbgGetValNative() { + return GetNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(int Value) { + SetInt(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(double Value) { + SetFloat(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(bool Value) { + SetBool(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal(const char *Value) { + SetString(Value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgSetVal() { + SetNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::DbgGetNumProperties() { + if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetNumProperties(); + else return _valObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) { + if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(Index, Name, Value); + else { + int Count = 0; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (Count == Index) { + *Name = _valIter->_key.c_str(); + *Value = _valIter->_value; + return true; + } + _valIter++; + Count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::DbgGetDescription(char *Buf, int BufSize) { + if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(Buf, BufSize); + + if (_type == VAL_NATIVE) { + _valNative->ScDebuggerDesc(Buf, BufSize); + } else { + strncpy(Buf, GetString(), BufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h new file mode 100644 index 0000000000..fedf3572f3 --- /dev/null +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -0,0 +1,142 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +//#include +//#include +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID); + + static int Compare(CScValue *Val1, CScValue *Val2); + static int CompareStrict(CScValue *Val1, CScValue *Val2); + TValType GetTypeTolerant(); + void Cleanup(bool IgnoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool _isConstVar; + HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + void SetValue(CScValue *Val); + bool _persistent; + bool PropExists(const char *Name); + void Copy(CScValue *orig, bool CopyWhole = false); + void SetStringVal(const char *Val); + TValType GetType(); + bool GetBool(bool Default = false); + int GetInt(int Default = 0); + double GetFloat(double Default = 0.0f); + const char *GetString(); + void *GetMemBuffer(); + CBScriptable *GetNative(); + HRESULT DeleteProp(const char *Name); + void DeleteProps(); + void CleanProps(bool IncludingNatives); + void SetBool(bool Val); + void SetInt(int Val); + void SetFloat(double Val); + void SetString(const char *Val); + void SetNULL(); + void SetNative(CBScriptable *Val, bool Persistent = false); + void SetObject(); + void SetReference(CScValue *Val); + bool IsNULL(); + bool IsNative(); + bool IsString(); + bool IsBool(); + bool IsFloat(); + bool IsInt(); + bool IsObject(); + HRESULT SetProp(const char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); + CScValue *GetProp(const char *Name); + CBScriptable *_valNative; + CScValue *_valRef; +protected: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool SetProperty(const char *PropName, int Value); + bool SetProperty(const char *PropName, const char *Value); + bool SetProperty(const char *PropName, double Value); + bool SetProperty(const char *PropName, bool Value); + bool SetProperty(const char *PropName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType DbgGetType(); + + // getters + virtual int DbgGetValInt(); + virtual double DbgGetValFloat(); + virtual bool DbgGetValBool(); + virtual const char *DbgGetValString(); + virtual IWmeDebugObject *DbgGetValNative(); + + // setters + virtual bool DbgSetVal(int Value); + virtual bool DbgSetVal(double Value); + virtual bool DbgSetVal(bool Value); + virtual bool DbgSetVal(const char *Value); + virtual bool DbgSetVal(); + + // properties + virtual int DbgGetNumProperties(); + virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); + + virtual bool DbgGetDescription(char *Buf, int BufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp new file mode 100644 index 0000000000..1af01c1045 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SxObject.h" +#include "ScValue.h" +#include "ScStack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { + int NumParams = Stack->Pop()->GetInt(0); + for (int i = 0; i < NumParams; i++) { + AddScript(Stack->Pop()->GetString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSXObject::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SxObject.h b/engines/wintermute/Base/scriptables/SxObject.h new file mode 100644 index 0000000000..2a6ad36a58 --- /dev/null +++ b/engines/wintermute/Base/scriptables/SxObject.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/Base/BObject.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index a385125d82..9b1cafe4cb 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -30,7 +30,7 @@ #define WINTERMUTE_FONTGLYPHCACHE_H -#include "BFontStorage.h" +#include "engines/wintermute/Base/BFontStorage.h" #include "graphics/surface.h" namespace WinterMute { diff --git a/engines/wintermute/PartEmitter.cpp b/engines/wintermute/PartEmitter.cpp deleted file mode 100644 index c0e03c25d0..0000000000 --- a/engines/wintermute/PartEmitter.cpp +++ /dev/null @@ -1,1198 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/PartEmitter.h" -#include "engines/wintermute/Vector2.h" -#include "engines/wintermute/Matrix4.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BRegion.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CPartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - _width = _height = 0; - - CBPlatform::SetRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = Owner; -} - - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.GetSize(); i++) { - delete _particles[i]; - } - _particles.RemoveAll(); - - for (int i = 0; i < _forces.GetSize(); i++) { - delete _forces[i]; - } - _forces.RemoveAll(); - - - for (int i = 0; i < _sprites.GetSize(); i++) { - delete [] _sprites[i]; - } - _sprites.RemoveAll(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddSprite(const char *Filename) { - if (!Filename) return E_FAIL; - - // do we already have the file? - for (int i = 0; i < _sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, _sprites[i]) == 0) return S_OK; - } - - // check if file exists - CBFile *File = Game->_fileManager->OpenFile(Filename); - if (!File) { - Game->LOG(0, "Sprite '%s' not found", Filename); - return E_FAIL; - } else Game->_fileManager->CloseFile(File); - - char *Str = new char[strlen(Filename) + 1]; - strcpy(Str, Filename); - _sprites.Add(Str); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveSprite(const char *Filename) { - for (int i = 0; i < _sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, _sprites[i]) == 0) { - delete [] _sprites[i]; - _sprites.RemoveAt(i); - return S_OK; - } - } - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { - if (!Particle) return E_FAIL; - if (_sprites.GetSize() == 0) return E_FAIL; - - int PosX = CBUtils::RandomInt(_posX, _posX + _width); - int PosY = CBUtils::RandomInt(_posY, _posY + _height); - float PosZ = CBUtils::RandomFloat(0.0f, 100.0f); - - float Velocity; - if (_velocityZBased) Velocity = _velocity1 + PosZ * (_velocity2 - _velocity1) / 100; - else Velocity = CBUtils::RandomFloat(_velocity1, _velocity2); - - float Scale; - if (_scaleZBased) Scale = _scale1 + PosZ * (_scale2 - _scale1) / 100; - else Scale = CBUtils::RandomFloat(_scale1, _scale2); - - int LifeTime; - if (_lifeTimeZBased) LifeTime = _lifeTime2 - PosZ * (_lifeTime2 - _lifeTime1) / 100; - else LifeTime = CBUtils::RandomInt(_lifeTime1, _lifeTime2); - - float Angle = CBUtils::RandomAngle(_angle1, _angle2); - int SpriteIndex = CBUtils::RandomInt(0, _sprites.GetSize() - 1); - - float Rotation = CBUtils::RandomAngle(_rotation1, _rotation2); - float AngVelocity = CBUtils::RandomFloat(_angVelocity1, _angVelocity2); - float GrowthRate = CBUtils::RandomFloat(_growthRate1, _growthRate2); - - if (!CBPlatform::IsRectEmpty(&_border)) { - int ThicknessLeft = _borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f; - int ThicknessRight = _borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f; - int ThicknessTop = _borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f; - int ThicknessBottom = _borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f; - - Particle->_border = _border; - Particle->_border.left += ThicknessLeft; - Particle->_border.right -= ThicknessRight; - Particle->_border.top += ThicknessTop; - Particle->_border.bottom -= ThicknessBottom; - } - - Vector2 VecPos((float)PosX, (float)PosY); - Vector2 VecVel(0, Velocity); - - Matrix4 MatRot; - MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); - MatRot.TransformVector2(VecVel); - - if (_alphaTimeBased) { - Particle->_alpha1 = _alpha1; - Particle->_alpha2 = _alpha2; - } else { - int Alpha = CBUtils::RandomInt(_alpha1, _alpha2); - Particle->_alpha1 = Alpha; - Particle->_alpha2 = Alpha; - } - - Particle->_creationTime = CurrentTime; - Particle->_pos = VecPos; - Particle->_posZ = PosZ; - Particle->_velocity = VecVel; - Particle->_scale = Scale; - Particle->_lifeTime = LifeTime; - Particle->_rotation = Rotation; - Particle->_angVelocity = AngVelocity; - Particle->_growthRate = GrowthRate; - Particle->_exponentialGrowth = _exponentialGrowth; - Particle->_isDead = FAILED(Particle->SetSprite(_sprites[SpriteIndex])); - Particle->FadeIn(CurrentTime, _fadeInTime); - - - if (Particle->_isDead) return E_FAIL; - else return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Update() { - if (!_running) return S_OK; - else return UpdateInternal(Game->_timer, Game->_timerDelta); -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { - int NumLive = 0; - - for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->Update(this, CurrentTime, TimerDelta); - - if (!_particles[i]->_isDead) NumLive++; - } - - - // we're understaffed - if (NumLive < _maxParticles) { - bool NeedsSort = false; - if (CurrentTime - _lastGenTime > _genInterval) { - _lastGenTime = CurrentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return S_OK; - } - - int ToGen = MIN(_genAmount, _maxParticles - NumLive); - while (ToGen > 0) { - int FirstDeadIndex = -1; - for (int i = 0; i < _particles.GetSize(); i++) { - if (_particles[i]->_isDead) { - FirstDeadIndex = i; - break; - } - } - - CPartParticle *Particle; - if (FirstDeadIndex >= 0) Particle = _particles[FirstDeadIndex]; - else { - Particle = new CPartParticle(Game); - _particles.Add(Particle); - } - InitParticle(Particle, CurrentTime, TimerDelta); - NeedsSort = true; - - ToGen--; - } - } - if (NeedsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - SortParticlesByZ(); - - // we actually generated some particles and we're not in fast-forward mode - if (NeedsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->ApplyEvent(_emitEvent); - } - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Display(CBRegion *Region) { - if (_sprites.GetSize() <= 1) Game->_renderer->StartSpriteBatch(); - - for (int i = 0; i < _particles.GetSize(); i++) { - if (Region != NULL && _useRegion) { - if (!Region->PointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; - } - - _particles[i]->Display(this); - } - - if (_sprites.GetSize() <= 1) Game->_renderer->EndSpriteBatch(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Start() { - for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 Delta = 500; - int Steps = _overheadTime / Delta; - uint32 CurrentTime = Game->_timer - _overheadTime; - - for (int i = 0; i < Steps; i++) { - UpdateInternal(CurrentTime, Delta); - CurrentTime += Delta; - } - _overheadTime = 0; - } - - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SortParticlesByZ() { - // sort particles by _posY - qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { - CPartParticle *P1 = *(CPartParticle **)Obj1; - CPartParticle *P2 = *(CPartParticle **)Obj2; - - if (P1->_posZ < P2->_posZ) return -1; - else if (P1->_posZ > P2->_posZ) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SetBorder(int X, int Y, int Width, int Height) { - CBPlatform::SetRect(&_border, X, Y, X + Width, Y + Height); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { - _borderThicknessLeft = ThicknessLeft; - _borderThicknessRight = ThicknessRight; - _borderThicknessTop = ThicknessTop; - _borderThicknessBottom = ThicknessBottom; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::AddForceByName(const char *Name) { - CPartForce *Force = NULL; - - for (int i = 0; i < _forces.GetSize(); i++) { - if (scumm_stricmp(Name, _forces[i]->_name) == 0) { - Force = _forces[i]; - break; - } - } - if (!Force) { - Force = new CPartForce(Game); - if (Force) { - Force->SetName(Name); - _forces.Add(Force); - } - } - return Force; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { - CPartForce *Force = AddForceByName(Name); - if (!Force) return E_FAIL; - - Force->_type = Type; - Force->_pos = Vector2(PosX, PosY); - - Force->_direction = Vector2(0, Strength); - Matrix4 MatRot; - MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); - MatRot.TransformVector2(Force->_direction); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveForce(const char *Name) { - for (int i = 0; i < _forces.GetSize(); i++) { - if (scumm_stricmp(Name, _forces[i]->_name) == 0) { - delete _forces[i]; - _forces.RemoveAt(i); - return S_OK; - } - } - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetBorder") == 0) { - Stack->CorrectParams(4); - int BorderX = Stack->Pop()->GetInt(); - int BorderY = Stack->Pop()->GetInt(); - int BorderWidth = Stack->Pop()->GetInt(); - int BorderHeight = Stack->Pop()->GetInt(); - - Stack->PushBool(SUCCEEDED(SetBorder(BorderX, BorderY, BorderWidth, BorderHeight))); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetBorderThickness") == 0) { - Stack->CorrectParams(4); - int Left = Stack->Pop()->GetInt(); - int Right = Stack->Pop()->GetInt(); - int Top = Stack->Pop()->GetInt(); - int Bottom = Stack->Pop()->GetInt(); - - Stack->PushBool(SUCCEEDED(SetBorderThickness(Left, Right, Top, Bottom))); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSprite") == 0) { - Stack->CorrectParams(1); - const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(AddSprite(SpriteFile))); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveSprite") == 0) { - Stack->CorrectParams(1); - const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveSprite(SpriteFile))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Start") == 0) { - Stack->CorrectParams(1); - _overheadTime = Stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(Start())); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Stop") == 0) { - Stack->CorrectParams(0); - - for (int i = 0; i < _particles.GetSize(); i++) { - delete _particles[i]; - } - _particles.RemoveAll(); - - _running = false; - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pause") == 0) { - Stack->CorrectParams(0); - _running = false; - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Resume") == 0) { - Stack->CorrectParams(0); - _running = true; - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddGlobalForce") == 0) { - Stack->CorrectParams(3); - const char *Name = Stack->Pop()->GetString(); - float Angle = Stack->Pop()->GetFloat(); - float Strength = Stack->Pop()->GetFloat(); - - Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddPointForce") == 0) { - Stack->CorrectParams(5); - const char *Name = Stack->Pop()->GetString(); - int PosX = Stack->Pop()->GetInt(); - int PosY = Stack->Pop()->GetInt(); - float Angle = Stack->Pop()->GetFloat(); - float Strength = Stack->Pop()->GetFloat(); - - Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveForce") == 0) { - Stack->CorrectParams(1); - const char *Name = Stack->Pop()->GetString(); - - Stack->PushBool(SUCCEEDED(RemoveForce(Name))); - - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - -////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { - _scValue->SetInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { - _scValue->SetInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _scValue->SetInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _scValue->SetInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale1") == 0) { - _scValue->SetFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale2") == 0) { - _scValue->SetFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleZBased") == 0) { - _scValue->SetBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity1") == 0) { - _scValue->SetFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity2") == 0) { - _scValue->SetFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VelocityZBased") == 0) { - _scValue->SetBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime1") == 0) { - _scValue->SetInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime2") == 0) { - _scValue->SetInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTimeZBased") == 0) { - _scValue->SetBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle1") == 0) { - _scValue->SetInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle2") == 0) { - _scValue->SetInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity1") == 0) { - _scValue->SetFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity2") == 0) { - _scValue->SetFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation1") == 0) { - _scValue->SetFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation2") == 0) { - _scValue->SetFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha1") == 0) { - _scValue->SetInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha2") == 0) { - _scValue->SetInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaTimeBased") == 0) { - _scValue->SetBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxParticles") == 0) { - _scValue->SetInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumLiveParticles") == 0) { - int NumAlive = 0; - for (int i = 0; i < _particles.GetSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) NumAlive++; - } - _scValue->SetInt(NumAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationInterval") == 0) { - _scValue->SetInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationAmount") == 0) { - _scValue->SetInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxBatches") == 0) { - _scValue->SetInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeInTime") == 0) { - _scValue->SetInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOutTime") == 0) { - _scValue->SetInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate1") == 0) { - _scValue->SetFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate2") == 0) { - _scValue->SetFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExponentialGrowth") == 0) { - _scValue->SetBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UseRegion") == 0) { - _scValue->SetBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->SetNULL(); - else _scValue->SetString(_emitEvent); - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "X") == 0) { - _posX = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { - _posY = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _width = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _height = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale1") == 0) { - _scale1 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale2") == 0) { - _scale2 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleZBased") == 0) { - _scaleZBased = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity1") == 0) { - _velocity1 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity2") == 0) { - _velocity2 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VelocityZBased") == 0) { - _velocityZBased = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime1") == 0) { - _lifeTime1 = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime2") == 0) { - _lifeTime2 = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle1") == 0) { - _angle1 = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle2") == 0) { - _angle2 = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity1") == 0) { - _angVelocity1 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity2") == 0) { - _angVelocity2 = Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation1") == 0) { - _rotation1 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation2") == 0) { - _rotation2 = Value->GetFloat(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha1") == 0) { - _alpha1 = Value->GetInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha2") == 0) { - _alpha2 = Value->GetInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaTimeBased") == 0) { - _alphaTimeBased = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxParticles") == 0) { - _maxParticles = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationInterval") == 0) { - _genInterval = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationAmount") == 0) { - _genAmount = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxBatches") == 0) { - _maxBatches = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeInTime") == 0) { - _fadeInTime = Value->GetInt(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOutTime") == 0) { - _fadeOutTime = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate1") == 0) { - _growthRate1 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate2") == 0) { - _growthRate2 = Value->GetFloat(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExponentialGrowth") == 0) { - _exponentialGrowth = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UseRegion") == 0) { - _useRegion = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::ScToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_width)); - PersistMgr->Transfer(TMEMBER(_height)); - - PersistMgr->Transfer(TMEMBER(_angle1)); - PersistMgr->Transfer(TMEMBER(_angle2)); - - PersistMgr->Transfer(TMEMBER(_velocity1)); - PersistMgr->Transfer(TMEMBER(_velocity2)); - PersistMgr->Transfer(TMEMBER(_velocityZBased)); - - PersistMgr->Transfer(TMEMBER(_scale1)); - PersistMgr->Transfer(TMEMBER(_scale2)); - PersistMgr->Transfer(TMEMBER(_scaleZBased)); - - PersistMgr->Transfer(TMEMBER(_maxParticles)); - - PersistMgr->Transfer(TMEMBER(_lifeTime1)); - PersistMgr->Transfer(TMEMBER(_lifeTime2)); - PersistMgr->Transfer(TMEMBER(_lifeTimeZBased)); - - PersistMgr->Transfer(TMEMBER(_genInterval)); - PersistMgr->Transfer(TMEMBER(_genAmount)); - - PersistMgr->Transfer(TMEMBER(_running)); - PersistMgr->Transfer(TMEMBER(_overheadTime)); - - PersistMgr->Transfer(TMEMBER(_border)); - PersistMgr->Transfer(TMEMBER(_borderThicknessLeft)); - PersistMgr->Transfer(TMEMBER(_borderThicknessRight)); - PersistMgr->Transfer(TMEMBER(_borderThicknessTop)); - PersistMgr->Transfer(TMEMBER(_borderThicknessBottom)); - - PersistMgr->Transfer(TMEMBER(_fadeInTime)); - PersistMgr->Transfer(TMEMBER(_fadeOutTime)); - - PersistMgr->Transfer(TMEMBER(_alpha1)); - PersistMgr->Transfer(TMEMBER(_alpha2)); - PersistMgr->Transfer(TMEMBER(_alphaTimeBased)); - - PersistMgr->Transfer(TMEMBER(_angVelocity1)); - PersistMgr->Transfer(TMEMBER(_angVelocity2)); - - PersistMgr->Transfer(TMEMBER(_rotation1)); - PersistMgr->Transfer(TMEMBER(_rotation2)); - - PersistMgr->Transfer(TMEMBER(_growthRate1)); - PersistMgr->Transfer(TMEMBER(_growthRate2)); - PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); - - PersistMgr->Transfer(TMEMBER(_useRegion)); - - PersistMgr->Transfer(TMEMBER_INT(_maxBatches)); - PersistMgr->Transfer(TMEMBER_INT(_batchesGenerated)); - - PersistMgr->Transfer(TMEMBER(_emitEvent)); - PersistMgr->Transfer(TMEMBER(_owner)); - - - _sprites.Persist(PersistMgr); - - int NumForces; - if (PersistMgr->_saving) { - NumForces = _forces.GetSize(); - PersistMgr->Transfer(TMEMBER(NumForces)); - for (int i = 0; i < _forces.GetSize(); i++) { - _forces[i]->Persist(PersistMgr); - } - } else { - PersistMgr->Transfer(TMEMBER(NumForces)); - for (int i = 0; i < NumForces; i++) { - CPartForce *Force = new CPartForce(Game); - Force->Persist(PersistMgr); - _forces.Add(Force); - } - } - - int NumParticles; - if (PersistMgr->_saving) { - NumParticles = _particles.GetSize(); - PersistMgr->Transfer(TMEMBER(NumParticles)); - for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->Persist(PersistMgr); - } - } else { - PersistMgr->Transfer(TMEMBER(NumParticles)); - for (int i = 0; i < NumParticles; i++) { - CPartParticle *Particle = new CPartParticle(Game); - Particle->Persist(PersistMgr); - _particles.Add(Particle); - } - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/PartEmitter.h b/engines/wintermute/PartEmitter.h deleted file mode 100644 index 89a56a21a0..0000000000 --- a/engines/wintermute/PartEmitter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "BObject.h" -#include "PartParticle.h" -#include "PartForce.h" - -namespace WinterMute { -class CBRegion; - -class CPartEmitter : public CBObject { -public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) - - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); - - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - RECT _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - int _fadeOutTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - CBScriptHolder *_owner; - - HRESULT Start(); - - HRESULT Update(); - HRESULT Display(CBRegion *Region = NULL); - - HRESULT SortParticlesByZ(); - HRESULT AddSprite(const char *Filename); - HRESULT RemoveSprite(const char *Filename); - HRESULT SetBorder(int X, int Y, int Width, int Height); - HRESULT SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); - - HRESULT AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); - HRESULT RemoveForce(const char *Name); - - CBArray _forces; - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - - -private: - CPartForce *AddForceByName(const char *Name); - int static CompareZ(const void *Obj1, const void *Obj2); - HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); - HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); - uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/PartForce.cpp b/engines/wintermute/PartForce.cpp deleted file mode 100644 index 8431ebbda8..0000000000 --- a/engines/wintermute/PartForce.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/PartForce.h" -#include "engines/wintermute/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartForce::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_direction)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/PartForce.h b/engines/wintermute/PartForce.h deleted file mode 100644 index f4830b3039..0000000000 --- a/engines/wintermute/PartForce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "BBase.h" -#include "BNamedObject.h" -#include "Vector2.h" - -namespace WinterMute { - -class CPartForce : public CBNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - HRESULT Persist(CBPersistMgr *PersistMgr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/PartParticle.cpp b/engines/wintermute/PartParticle.cpp deleted file mode 100644 index 8bbd54d3f9..0000000000 --- a/engines/wintermute/PartParticle.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/PartParticle.h" -#include "engines/wintermute/PartEmitter.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - CBPlatform::SetRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::SetSprite(const char *Filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { - _sprite->Reset(); - return S_OK; - } - - delete _sprite; - _sprite = NULL; - - CSysClassRegistry::GetInstance()->_disabled = true; - _sprite = new CBSprite(Game, Game); - if (_sprite && SUCCEEDED(_sprite->LoadFile(Filename))) { - CSysClassRegistry::GetInstance()->_disabled = false; - return S_OK; - } else { - delete _sprite; - _sprite = NULL; - CSysClassRegistry::GetInstance()->_disabled = false; - return E_FAIL; - } - -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { - if (_state == PARTICLE_FADEIN) { - if (CurrentTime - _fadeStart >= _fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else _currentAlpha = ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; - - return S_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (CurrentTime - _fadeStart >= _fadeTime) { - _isDead = true; - return S_OK; - } else _currentAlpha = _fadeStartAlpha - ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; - - return S_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (CurrentTime - _creationTime >= _lifeTime) { - if (Emitter->_fadeOutTime > 0) - FadeOut(CurrentTime, Emitter->_fadeOutTime); - else - _isDead = true; - } - } - - // particle hit the border - if (!_isDead && !CBPlatform::IsRectEmpty(&_border)) { - POINT p; - p.x = _pos.x; - p.y = _pos.y; - if (!CBPlatform::PtInRect(&_border, p)) FadeOut(CurrentTime, Emitter->_fadeOutTime); - } - if (_state != PARTICLE_NORMAL) return S_OK; - - // update alpha - if (_lifeTime > 0) { - int Age = CurrentTime - _creationTime; - int AlphaDelta = _alpha2 - _alpha1; - - _currentAlpha = _alpha1 + ((float)AlphaDelta / (float)_lifeTime * (float)Age); - } - - // update position - float ElapsedTime = (float)TimerDelta / 1000.f; - - for (int i = 0; i < Emitter->_forces.GetSize(); i++) { - CPartForce *Force = Emitter->_forces[i]; - switch (Force->_type) { - case CPartForce::FORCE_GLOBAL: - _velocity += Force->_direction * ElapsedTime; - break; - - case CPartForce::FORCE_POINT: { - Vector2 VecDist = Force->_pos - _pos; - float Dist = fabs(VecDist.Length()); - - Dist = 100.0f / Dist; - - _velocity += Force->_direction * Dist * ElapsedTime; - } - break; - } - } - _pos += _velocity * ElapsedTime; - - // update rotation - _rotation += _angVelocity * ElapsedTime; - _rotation = CBUtils::NormalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * ElapsedTime; - else - _scale += _growthRate * ElapsedTime; - - if (_scale <= 0.0f) _isDead = true; - - - return S_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Display(CPartEmitter *Emitter) { - if (!_sprite) return E_FAIL; - if (_isDead) return S_OK; - - _sprite->GetCurrentFrame(); - return _sprite->Display(_pos.x, _pos.y, - NULL, - _scale, _scale, - DRGBA(255, 255, 255, _currentAlpha), - _rotation, - Emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { - _currentAlpha = 0; - _fadeStart = CurrentTime; - _fadeTime = FadeTime; - _state = PARTICLE_FADEIN; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = CurrentTime; - _fadeTime = FadeTime; - _state = PARTICLE_FADEOUT; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_alpha1)); - PersistMgr->Transfer(TMEMBER(_alpha2)); - PersistMgr->Transfer(TMEMBER(_border)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_posZ)); - PersistMgr->Transfer(TMEMBER(_velocity)); - PersistMgr->Transfer(TMEMBER(_scale)); - PersistMgr->Transfer(TMEMBER(_creationTime)); - PersistMgr->Transfer(TMEMBER(_lifeTime)); - PersistMgr->Transfer(TMEMBER(_isDead)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_fadeStart)); - PersistMgr->Transfer(TMEMBER(_fadeTime)); - PersistMgr->Transfer(TMEMBER(_currentAlpha)); - PersistMgr->Transfer(TMEMBER(_angVelocity)); - PersistMgr->Transfer(TMEMBER(_rotation)); - PersistMgr->Transfer(TMEMBER(_growthRate)); - PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); - PersistMgr->Transfer(TMEMBER(_fadeStartAlpha)); - - if (PersistMgr->_saving) { - PersistMgr->Transfer(TMEMBER(_sprite->_filename)); - } else { - char *Filename; - PersistMgr->Transfer(TMEMBER(Filename)); - CSysClassRegistry::GetInstance()->_disabled = true; - SetSprite(Filename); - CSysClassRegistry::GetInstance()->_disabled = false; - delete[] Filename; - Filename = NULL; - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/PartParticle.h b/engines/wintermute/PartParticle.h deleted file mode 100644 index e72089ad5f..0000000000 --- a/engines/wintermute/PartParticle.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PATRPARTICLE_H -#define WINTERMUTE_PATRPARTICLE_H - - -#include "BBase.h" -#include "Vector2.h" - -namespace WinterMute { - -class CPartEmitter; -class CBSprite; -class CBPersistMgr; - -class CPartParticle : public CBBase { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - RECT _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - CBSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); - HRESULT Display(CPartEmitter *Emitter); - - HRESULT SetSprite(const char *Filename); - - HRESULT FadeIn(uint32 CurrentTime, int FadeTime); - HRESULT FadeOut(uint32 CurrentTime, int FadeTime); - - HRESULT Persist(CBPersistMgr *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/PathUtil.cpp b/engines/wintermute/PathUtil.cpp index 336667525c..dc722e2389 100644 --- a/engines/wintermute/PathUtil.cpp +++ b/engines/wintermute/PathUtil.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include #include #include "PathUtil.h" diff --git a/engines/wintermute/PathUtil.h b/engines/wintermute/PathUtil.h index 6bdabdc9d7..0bc883a1fa 100644 --- a/engines/wintermute/PathUtil.h +++ b/engines/wintermute/PathUtil.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_PATHUTILS_H #define WINTERMUTE_PATHUTILS_H -#include "PlatformSDL.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 6cc18f5209..765c6ecd93 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -27,13 +27,13 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BRenderSDL.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRenderSDL.h" #include "engines/wintermute/PathUtil.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/BRegistry.h" -#include "engines/wintermute/BSoundMgr.h" -#include "engines/wintermute/scriptables/ScEngine.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" #include "common/str.h" #include "common/textconsole.h" #include "common/system.h" diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index faf4a7e934..347d306378 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -29,9 +29,9 @@ #ifndef WINTERMUTE_PLATFORMSDL_H #define WINTERMUTE_PLATFORMSDL_H -#include "dctypes.h" +#include "engines/wintermute/dctypes.h" -#include "wintypes.h" +#include "engines/wintermute/wintypes.h" #include "common/events.h" namespace WinterMute { diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp index 35b3bd6fc7..cd4f99e034 100644 --- a/engines/wintermute/StringUtil.cpp +++ b/engines/wintermute/StringUtil.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include #include #include diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h index 5d3f1c668c..a4727fabbe 100644 --- a/engines/wintermute/StringUtil.h +++ b/engines/wintermute/StringUtil.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_STRINGUTIL_H #define WINTERMUTE_STRINGUTIL_H -#include "PlatformSDL.h" +#include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp index 90ac06eb80..cd5bff0c8c 100644 --- a/engines/wintermute/SysClass.cpp +++ b/engines/wintermute/SysClass.cpp @@ -26,12 +26,12 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "persistent.h" +#include "engines/wintermute/persistent.h" #include "SysInstance.h" #include "SysClass.h" #include "SysClassRegistry.h" -#include "BGame.h" -#include "BPersistMgr.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h index df319b5d9b..3d6200997b 100644 --- a/engines/wintermute/SysClass.h +++ b/engines/wintermute/SysClass.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_SYSCLASS_H #define WINTERMUTE_SYSCLASS_H -#include "persistent.h" -#include "dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dctypes.h" //#include //#include diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp index bd86502023..25f271fab9 100644 --- a/engines/wintermute/SysClassRegistry.cpp +++ b/engines/wintermute/SysClassRegistry.cpp @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "BGame.h" -#include "PlatformSDL.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" #include "SysInstance.h" #include "SysClassRegistry.h" diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h index 1f92c94164..5d437af324 100644 --- a/engines/wintermute/SysClassRegistry.h +++ b/engines/wintermute/SysClassRegistry.h @@ -29,9 +29,9 @@ #ifndef WINTERMUTE_SYSCLASSREGISTRY_H #define WINTERMUTE_SYSCLASSREGISTRY_H -#include "wintypes.h" -#include "dctypes.h" -#include "persistent.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" //#include //#include #include "common/hashmap.h" diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp index 70b2825027..a81320217e 100644 --- a/engines/wintermute/UIButton.cpp +++ b/engines/wintermute/UIButton.cpp @@ -27,21 +27,21 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/UIButton.h" #include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h index 0d504fdea0..75133e2c0a 100644 --- a/engines/wintermute/UIButton.h +++ b/engines/wintermute/UIButton.h @@ -31,7 +31,7 @@ #include "UIObject.h" -#include "dctypes.h" // Added by ClassView +#include "engines/wintermute/dctypes.h" // Added by ClassView namespace WinterMute { diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp index 4e048117ba..00c91ba2e7 100644 --- a/engines/wintermute/UIEdit.cpp +++ b/engines/wintermute/UIEdit.cpp @@ -30,20 +30,20 @@ #include "engines/wintermute/UIObject.h" #include "engines/wintermute/UITiledImage.h" #include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BKeyboardState.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/BGame.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/utils.h" #include "common/util.h" #include "common/keyboard.h" diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h index 9c2f4fddd4..3b8698d55d 100644 --- a/engines/wintermute/UIEdit.h +++ b/engines/wintermute/UIEdit.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_UIEDIT_H #define WINTERMUTE_UIEDIT_H -#include "persistent.h" +#include "engines/wintermute/persistent.h" #include "UIObject.h" #include "common/events.h" diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp index 958cb65284..a864f7cbea 100644 --- a/engines/wintermute/UIEntity.cpp +++ b/engines/wintermute/UIEntity.cpp @@ -27,14 +27,14 @@ */ #include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/UIEntity.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" namespace WinterMute { diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp index 153d04ada4..2bb860da3e 100644 --- a/engines/wintermute/UIObject.cpp +++ b/engines/wintermute/UIObject.cpp @@ -26,15 +26,15 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSprite.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/UIObject.h" #include "engines/wintermute/UITiledImage.h" #include "engines/wintermute/UIWindow.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BFontStorage.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BFontStorage.h" namespace WinterMute { diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h index 6d5f463fca..7d6dfb41f5 100644 --- a/engines/wintermute/UIObject.h +++ b/engines/wintermute/UIObject.h @@ -30,8 +30,8 @@ #define WINTERMUTE_UIOBJECT_H -#include "BObject.h" -#include "dctypes.h" // Added by ClassView +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView namespace WinterMute { diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp index 194bff2390..64bb730fd4 100644 --- a/engines/wintermute/UIText.cpp +++ b/engines/wintermute/UIText.cpp @@ -27,19 +27,19 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/BDynBuffer.h" +#include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/UIText.h" #include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp index 1f210fd89d..80618890f2 100644 --- a/engines/wintermute/UITiledImage.cpp +++ b/engines/wintermute/UITiledImage.cpp @@ -28,12 +28,12 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/BSurface.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSubFrame.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp index 89980d8497..ac13170aaf 100644 --- a/engines/wintermute/UIWindow.cpp +++ b/engines/wintermute/UIWindow.cpp @@ -26,26 +26,26 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BParser.h" -#include "engines/wintermute/BActiveRect.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BKeyboardState.h" -#include "engines/wintermute/scriptables/ScValue.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/UIButton.h" #include "engines/wintermute/UIEdit.h" #include "engines/wintermute/UIText.h" #include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/BViewport.h" -#include "engines/wintermute/BFontStorage.h" -#include "engines/wintermute/BFont.h" -#include "engines/wintermute/BStringTable.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/BSprite.h" -#include "engines/wintermute/BFileManager.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/VidPlayer.cpp b/engines/wintermute/VidPlayer.cpp index e6459e26f1..ab20135595 100644 --- a/engines/wintermute/VidPlayer.cpp +++ b/engines/wintermute/VidPlayer.cpp @@ -27,7 +27,7 @@ */ -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include "VidPlayer.h" //#pragma comment(lib, "vfw32.lib") diff --git a/engines/wintermute/VidPlayer.h b/engines/wintermute/VidPlayer.h index e38baae413..a1abf2ea46 100644 --- a/engines/wintermute/VidPlayer.h +++ b/engines/wintermute/VidPlayer.h @@ -29,12 +29,12 @@ #ifndef WINTERMUTE_VIDPLAYER_H #define WINTERMUTE_VIDPLAYER_H -#include "dctypes.h" // Added by ClassView +#include "engines/wintermute/dctypes.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 -#include "engines/wintermute/BBase.h" +#include "engines/wintermute/Base/BBase.h" #define MAX_AUDIO_STREAMS 5 #define MAX_VIDEO_STREAMS 5 diff --git a/engines/wintermute/VidTheoraPlayer.cpp b/engines/wintermute/VidTheoraPlayer.cpp index f802620bdd..509a7006e5 100644 --- a/engines/wintermute/VidTheoraPlayer.cpp +++ b/engines/wintermute/VidTheoraPlayer.cpp @@ -17,7 +17,7 @@ ////////////////////////////////////////////////////////////////////////// -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include "engines/wintermute/vidtheoraplayer.h" //#pragma comment(lib, "libtheora.lib") diff --git a/engines/wintermute/VidTheoraPlayer.h b/engines/wintermute/VidTheoraPlayer.h index 6a32c307ad..38f3fe85ae 100644 --- a/engines/wintermute/VidTheoraPlayer.h +++ b/engines/wintermute/VidTheoraPlayer.h @@ -20,10 +20,10 @@ #ifndef WINTERMUTE_VIDTHEORAPLAYER_H #define WINTERMUTE_VIDTHEORAPLAYER_H -#include "engines/wintermute/BBase.h" -#include "engines/wintermute/BFile.h" -#include "engines/wintermute/BSurface.h" -#include "engines/wintermute/BImage.h" +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BImage.h" //#include namespace WinterMute { diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 9c3a5ab15d..a5c02b313d 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -31,7 +31,7 @@ #include -#include "BPersistMgr.h" +#include "engines/wintermute/Base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 7e1500da4e..5596cc5e46 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,18 +1,18 @@ MODULE := engines/wintermute MODULE_OBJS := \ - scriptables/ScEngine.o \ - scriptables/ScScript.o \ - scriptables/ScStack.o \ - scriptables/ScValue.o \ - scriptables/SXArray.o \ - scriptables/SXDate.o \ - scriptables/SXFile.o \ - scriptables/SXMath.o \ - scriptables/SxObject.o \ - scriptables/SXMemBuffer.o \ - scriptables/SXStore.o \ - scriptables/SXString.o \ + Base/scriptables/ScEngine.o \ + Base/scriptables/ScScript.o \ + Base/scriptables/ScStack.o \ + Base/scriptables/ScValue.o \ + Base/scriptables/SXArray.o \ + Base/scriptables/SXDate.o \ + Base/scriptables/SXFile.o \ + Base/scriptables/SXMath.o \ + Base/scriptables/SxObject.o \ + Base/scriptables/SXMemBuffer.o \ + Base/scriptables/SXStore.o \ + Base/scriptables/SXString.o \ Ad/AdActor.o \ Ad/AdActorDir.o \ Ad/AdEntity.o \ @@ -40,52 +40,52 @@ MODULE_OBJS := \ Ad/AdTalkHolder.o \ Ad/AdTalkNode.o \ Ad/AdWaypointGroup.o \ - BActiveRect.o \ - BBase.o \ - BDebugger.o \ - BDiskFile.o \ - BDynBuffer.o \ - BFader.o \ - BFile.o \ - BFileEntry.o \ - BFileManager.o \ - BGame.o \ - BFont.o \ - BFontBitmap.o \ - BFontStorage.o \ - BFontTT.o \ - BFrame.o \ - BImage.o \ - BKeyboardState.o \ - BNamedObject.o \ - BObject.o \ - BPackage.o \ - BParser.o \ - BPersistMgr.o \ - BPkgFile.o \ - BPoint.o \ - BQuickMsg.o \ - BRegion.o \ - BRegistry.o \ - BRenderer.o \ - BRenderSDL.o \ - BResources.o \ - BResourceFile.o \ - BSaveThumbFile.o \ - BSaveThumbHelper.o \ - BScriptable.o \ - BScriptHolder.o \ - BSound.o \ - BSoundBuffer.o \ - BSoundMgr.o \ - BSprite.o \ - BStringTable.o \ - BSubFrame.o \ - BSurface.o \ - BSurfaceSDL.o \ - BSurfaceStorage.o \ - BTransitionMgr.o \ - BViewport.o \ + Base/BActiveRect.o \ + Base/BBase.o \ + Base/BDebugger.o \ + Base/BDiskFile.o \ + Base/BDynBuffer.o \ + Base/BFader.o \ + Base/BFile.o \ + Base/BFileEntry.o \ + Base/BFileManager.o \ + Base/BGame.o \ + Base/BFont.o \ + Base/BFontBitmap.o \ + Base/BFontStorage.o \ + Base/BFontTT.o \ + Base/BFrame.o \ + Base/BImage.o \ + Base/BKeyboardState.o \ + Base/BNamedObject.o \ + Base/BObject.o \ + Base/BPackage.o \ + Base/BParser.o \ + Base/BPersistMgr.o \ + Base/BPkgFile.o \ + Base/BPoint.o \ + Base/BQuickMsg.o \ + Base/BRegion.o \ + Base/BRegistry.o \ + Base/BRenderer.o \ + Base/BRenderSDL.o \ + Base/BResources.o \ + Base/BResourceFile.o \ + Base/BSaveThumbFile.o \ + Base/BSaveThumbHelper.o \ + Base/BScriptable.o \ + Base/BScriptHolder.o \ + Base/BSound.o \ + Base/BSoundBuffer.o \ + Base/BSoundMgr.o \ + Base/BSprite.o \ + Base/BStringTable.o \ + Base/BSubFrame.o \ + Base/BSurface.o \ + Base/BSurfaceSDL.o \ + Base/BSurfaceStorage.o \ + Base/BTransitionMgr.o \ + Base/BViewport.o \ ConvertUTF.o \ crc.o \ detection.o \ @@ -95,9 +95,9 @@ MODULE_OBJS := \ MathUtil.o \ Matrix4.o \ PathUtil.o \ - PartParticle.o \ - PartEmitter.o \ - PartForce.o \ + Base/PartParticle.o \ + Base/PartEmitter.o \ + Base/PartForce.o \ PlatformSDL.o \ StringUtil.o \ SysClass.o \ diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 7a63ff326c..d62ca006a8 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_PERSISTENT_H #define WINTERMUTE_PERSISTENT_H -#include "wintypes.h" +#include "engines/wintermute/wintypes.h" namespace WinterMute { diff --git a/engines/wintermute/scriptables/SXArray.cpp b/engines/wintermute/scriptables/SXArray.cpp deleted file mode 100644 index d14660de4c..0000000000 --- a/engines/wintermute/scriptables/SXArray.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/SysInstance.h" -#include "engines/wintermute/scriptables/SXArray.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXArray, false) - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(Game); - - int NumParams = Stack->Pop()->GetInt(0); - - if (NumParams == 1) _length = Stack->Pop()->GetInt(0); - else if (NumParams > 1) { - _length = NumParams; - char ParamName[20]; - for (int i = 0; i < NumParams; i++) { - sprintf(ParamName, "%d", i); - _values->SetProp(ParamName, Stack->Pop()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(Game); -} - - -////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXArray::ScToString() { - static char Dummy[32768]; - strcpy(Dummy, ""); - char PropName[20]; - for (int i = 0; i < _length; i++) { - sprintf(PropName, "%d", i); - CScValue *val = _values->GetProp(PropName); - if (val) { - if (strlen(Dummy) + strlen(val->GetString()) < 32768) { - strcat(Dummy, val->GetString()); - } - } - - if (i < _length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); - } - return Dummy; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // Push - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Push") == 0) { - int NumParams = Stack->Pop()->GetInt(0); - char ParamName[20]; - - for (int i = 0; i < NumParams; i++) { - _length++; - sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, Stack->Pop(), true); - } - Stack->PushInt(_length); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pop - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Pop") == 0) { - - Stack->CorrectParams(0); - - if (_length > 0) { - char ParamName[20]; - sprintf(ParamName, "%d", _length - 1); - Stack->Push(_values->GetProp(ParamName)); - _values->DeleteProp(ParamName); - _length--; - } else Stack->PushNULL(); - - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("array"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { - _scValue->SetInt(_length); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char ParamName[20]; - if (ValidNumber(Name, ParamName)) { - return _values->GetProp(ParamName); - } else return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Length") == 0) { - int OrigLength = _length; - _length = MAX(Value->GetInt(0), 0); - - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->DeleteProp(PropName); - } - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char ParamName[20]; - if (ValidNumber(Name, ParamName)) { - int Index = atoi(ParamName); - if (Index >= _length) _length = Index + 1; - return _values->SetProp(ParamName, Value); - } else return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_length)); - PersistMgr->Transfer(TMEMBER(_values)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { - bool IsNumber = true; - for (int i = 0; i < strlen(OrigStr); i++) { - if (!(OrigStr[i] >= '0' && OrigStr[i] <= '9')) { - IsNumber = false; - break; - } - } - - if (IsNumber) { - int Index = atoi(OrigStr); - sprintf(OutStr, "%d", Index); - return true; - } else return false; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::Push(CScValue *Val) { - char ParamName[20]; - _length++; - sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, Val, true); - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXArray.h b/engines/wintermute/scriptables/SXArray.h deleted file mode 100644 index 3a174946fd..0000000000 --- a/engines/wintermute/scriptables/SXArray.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CSXArray : public CBScriptable { -public: - HRESULT Push(CScValue *Val); - bool ValidNumber(const char *OrigStr, char *OutStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *Stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); - int _length; - CScValue *_values; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXDate.cpp b/engines/wintermute/scriptables/SXDate.cpp deleted file mode 100644 index d6b20fc3dc..0000000000 --- a/engines/wintermute/scriptables/SXDate.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/SXDate.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXDate, false) - -////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(6); -#if 0 - memset(&_tm, 0, sizeof(_tm)); - - CScValue *valYear = Stack->Pop(); - _tm.t_year = valYear->GetInt() - 1900; - _tm.t_mon = Stack->Pop()->GetInt() - 1; - _tm.t_mday = Stack->Pop()->GetInt(); - _tm.t_hour = Stack->Pop()->GetInt(); - _tm.t_min = Stack->Pop()->GetInt(); - _tm.t_sec = Stack->Pop()->GetInt(); - - if (valYear->IsNULL()) { - time_t TimeNow; - time(&TimeNow); - memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); - } - - mktime(&_tm); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { - -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXDate::ScToString() { -#if 0 - return asctime(&_tm); -#endif - return ""; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { -#if 0 - ////////////////////////////////////////////////////////////////////////// - // GetYear - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetYear") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_year + 1900); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMonth") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_mon + 1); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDate") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_mday); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHours") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_hour); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMinutes") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_min); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSeconds") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_sec); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetWeekday - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWeekday") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.t_wday); - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetYear - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetYear") == 0) { - Stack->CorrectParams(1); - _tm.t_year = Stack->Pop()->GetInt() - 1900; - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMonth") == 0) { - Stack->CorrectParams(1); - _tm.t_mon = Stack->Pop()->GetInt() - 1; - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDate") == 0) { - Stack->CorrectParams(1); - _tm.t_mday = Stack->Pop()->GetInt(); - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHours") == 0) { - Stack->CorrectParams(1); - _tm.t_hour = Stack->Pop()->GetInt(); - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMinutes") == 0) { - Stack->CorrectParams(1); - _tm.t_min = Stack->Pop()->GetInt(); - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSeconds") == 0) { - Stack->CorrectParams(1); - _tm.t_sec = Stack->Pop()->GetInt(); - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetCurrentTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCurrentTime") == 0) { - Stack->CorrectParams(0); - time_t TimeNow; - time(&TimeNow); - memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); - mktime(&_tm); - Stack->PushNULL(); - return S_OK; - } - - else -#endif - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("date"); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Name")==0){ - SetName(Value->GetString()); - return S_OK; - } - - else*/ return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); -#if 0 - if (PersistMgr->_saving) - PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); - else - PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXDate::ScCompare(CBScriptable *Value) { -#if 0 - time_t time1 = mktime(&_tm); - time_t time2 = mktime(&((CSXDate *)Value)->_tm); - - if (time1 < time2) return -1; - else if (time1 > time2) return 1; - else -#endif - return 0; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXDate.h b/engines/wintermute/scriptables/SXDate.h deleted file mode 100644 index cce3c5300e..0000000000 --- a/engines/wintermute/scriptables/SXDate.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXDATE_H -#define WINTERMUTE_SXDATE_H - - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CSXDate : public CBScriptable { -public: - int ScCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); - char *_string; - //struct tm _tm; // TODO! -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp deleted file mode 100644 index 5ffc69d1e7..0000000000 --- a/engines/wintermute/scriptables/SXFile.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/SysClassRegistry.h" -#include "engines/wintermute/SysClass.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BFile.h" -#include "engines/wintermute/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/scriptables/SXFile.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXFile, false) - -////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - _filename = NULL; - if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { - Cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXFile::Cleanup() { - delete[] _filename; - _filename = NULL; - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -void CSXFile::Close() { - if (_readFile) { - Game->_fileManager->CloseFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - fclose(_writeFile); - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXFile::ScToString() { - if (_filename) return _filename; - else return "[file object]"; -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetFilename") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); - Cleanup(); - CBUtils::SetString(&_filename, Filename); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenAsText / OpenAsBinary - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) { - Stack->CorrectParams(1); - Close(); - _mode = Stack->Pop()->GetInt(1); - if (_mode < 1 || _mode > 3) { - Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name); - _mode = 1; - } - if (_mode == 1) { - _readFile = Game->_fileManager->OpenFile(_filename); - if (!_readFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - Close(); - } else _textMode = strcmp(Name, "OpenAsText") == 0; - } else { - if (strcmp(Name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = fopen(_filename, "w+"); - else _writeFile = fopen(_filename, "a+"); - } else { - if (_mode == 2) _writeFile = fopen(_filename, "wb+"); - else _writeFile = fopen(_filename, "ab+"); - } - - if (!_writeFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - Close(); - } else _textMode = strcmp(Name, "OpenAsText") == 0; - } - - if (_readFile || _writeFile) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Close") == 0) { - Stack->CorrectParams(0); - Close(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPosition") == 0) { - Stack->CorrectParams(1); - if (_mode == 0) { - Script->RuntimeError("File.%s: File is not open", Name); - Stack->PushBool(false); - } else { - int Pos = Stack->Pop()->GetInt(); - Stack->PushBool(SetPos(Pos)); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Delete - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Delete") == 0) { - Stack->CorrectParams(0); - Close(); - Stack->PushBool(CBPlatform::DeleteFile(_filename) != false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Copy - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Copy") == 0) { - Stack->CorrectParams(2); - const char *Dest = Stack->Pop()->GetString(); - bool Overwrite = Stack->Pop()->GetBool(true); - - Close(); - Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadLine") == 0) { - Stack->CorrectParams(0); - if (!_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open in text mode.", Name); - Stack->PushNULL(); - return S_OK; - } - uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); - uint32 Counter = 0; - byte b; - bool FoundNewLine = false; - HRESULT Ret = E_FAIL; - do { - Ret = _readFile->Read(&b, 1); - if (FAILED(Ret)) break; - - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; - } - if (b == '\n') { - Buf[Counter] = '\0'; - FoundNewLine = true; - break; - } else if (b == 0x0D) continue; - else { - Buf[Counter] = b; - Counter++; - } - } while (SUCCEEDED(Ret)); - - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; - } - Buf[Counter] = '\0'; - - if (!FoundNewLine && Counter == 0) Stack->PushNULL(); - else Stack->PushString((char *)Buf); - - free(Buf); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadText") == 0) { - Stack->CorrectParams(1); - int TextLen = Stack->Pop()->GetInt(); - - if (!_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open in text mode.", Name); - Stack->PushNULL(); - return S_OK; - } - uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); - uint32 Counter = 0; - byte b; - - HRESULT Ret = E_FAIL; - while (Counter < TextLen) { - Ret = _readFile->Read(&b, 1); - if (FAILED(Ret)) break; - - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; - } - if (b == 0x0D) continue; - else { - Buf[Counter] = b; - Counter++; - } - } - - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; - } - Buf[Counter] = '\0'; - - if (TextLen > 0 && Counter == 0) Stack->PushNULL(); - else Stack->PushString((char *)Buf); - - free(Buf); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteLine / WriteText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { - Stack->CorrectParams(1); - const char *Line = Stack->Pop()->GetString(); - if (!_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); - Stack->PushBool(false); - return S_OK; - } - if (strcmp(Name, "WriteLine") == 0) - fprintf(_writeFile, "%s\n", Line); - else - fprintf(_writeFile, "%s", Line); - - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ReadBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadBool") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - bool Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadByte") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - byte Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte)))) Stack->PushInt(Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadShort") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - short Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadInt / ReadLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - int Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadFloat") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - float Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadDouble") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - double Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadString") == 0) { - Stack->CorrectParams(0); - if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); - return S_OK; - } - uint32 Size; - if (SUCCEEDED(_readFile->Read(&Size, sizeof(uint32)))) { - byte *Str = new byte[Size + 1]; - if (Str) { - if (SUCCEEDED(_readFile->Read(Str, Size))) { - Str[Size] = '\0'; - Stack->PushString((char *)Str); - } - delete [] Str; - } else Stack->PushNULL(); - } else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteBool") == 0) { - Stack->CorrectParams(1); - bool Val = Stack->Pop()->GetBool(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteByte") == 0) { - Stack->CorrectParams(1); - byte Val = Stack->Pop()->GetInt(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteShort") == 0) { - Stack->CorrectParams(1); - short Val = Stack->Pop()->GetInt(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteInt / WriteLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteInt") == 0 || strcmp(Name, "WriteLong") == 0) { - Stack->CorrectParams(1); - int Val = Stack->Pop()->GetInt(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteFloat") == 0) { - Stack->CorrectParams(1); - float Val = Stack->Pop()->GetFloat(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteDouble") == 0) { - Stack->CorrectParams(1); - double Val = Stack->Pop()->GetFloat(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - fwrite(&Val, sizeof(Val), 1, _writeFile); - Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteString") == 0) { - Stack->CorrectParams(1); - const char *Val = Stack->Pop()->GetString(); - - if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); - return S_OK; - } - - uint32 Size = strlen(Val); - fwrite(&Size, sizeof(Size), 1, _writeFile); - fwrite(Val, Size, 1, _writeFile); - - Stack->PushBool(true); - - return S_OK; - } - - - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("file"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Filename") == 0) { - _scValue->SetString(_filename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Position (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Position") == 0) { - _scValue->SetInt(GetPos()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { - _scValue->SetInt(GetLength()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextMode") == 0) { - _scValue->SetBool(_textMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccessMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccessMode") == 0) { - _scValue->SetInt(_mode); - return _scValue; - } - - else return CBScriptable::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Length")==0){ - int OrigLength = _length; - _length = max(Value->GetInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return S_OK; - } - else*/ return CBScriptable::ScSetProperty(Name, Value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::GetPos() { - if (_mode == 1 && _readFile) return _readFile->GetPos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { - if (_mode == 1 && _readFile) return SUCCEEDED(_readFile->Seek(Pos, Origin)); - else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, Pos, (int)Origin) == 0; - else return false; -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::GetLength() { - if (_mode == 1 && _readFile) return _readFile->GetSize(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - uint32 CurrentPos = ftell(_writeFile); - fseek(_writeFile, 0, SEEK_END); - int Ret = ftell(_writeFile); - fseek(_writeFile, CurrentPos, SEEK_SET); - return Ret; - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_mode)); - PersistMgr->Transfer(TMEMBER(_textMode)); - - uint32 Pos = 0; - if (PersistMgr->_saving) { - Pos = GetPos(); - PersistMgr->Transfer(TMEMBER(Pos)); - } else { - PersistMgr->Transfer(TMEMBER(Pos)); - - // try to re-open file if needed - _writeFile = NULL; - _readFile = NULL; - - if (_mode != 0) { - // open for reading - if (_mode == 1) { - _readFile = Game->_fileManager->OpenFile(_filename); - if (!_readFile) Close(); - } - // open for writing / appending - else { - if (_textMode) { - if (_mode == 2) _writeFile = fopen(_filename, "w+"); - else _writeFile = fopen(_filename, "a+"); - } else { - if (_mode == 2) _writeFile = fopen(_filename, "wb+"); - else _writeFile = fopen(_filename, "ab+"); - } - if (_writeFile) Close(); - } - SetPos(Pos); - } - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXFile.h b/engines/wintermute/scriptables/SXFile.h deleted file mode 100644 index 1900355dea..0000000000 --- a/engines/wintermute/scriptables/SXFile.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTES_SXFILE_H -#define WINTERMUTES_SXFILE_H - - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CBFile; - -class CSXFile : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); -private: - CBFile *_readFile; - FILE *_writeFile; - int _mode; // 0..none, 1..read, 2..write, 3..append - bool _textMode; - void Close(); - void Cleanup(); - uint32 GetPos(); - uint32 GetLength(); - bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - char *_filename; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXMath.cpp b/engines/wintermute/scriptables/SXMath.cpp deleted file mode 100644 index 59961fb5f1..0000000000 --- a/engines/wintermute/scriptables/SXMath.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/scriptables/SXMath.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/persistent.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -IMPLEMENT_PERSISTENT(CSXMath, true) - -////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // Abs - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Abs") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(fabs(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Acos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Acos") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(acos(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Asin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Asin") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(asin(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Atan") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(atan(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Atan2") == 0) { - Stack->CorrectParams(2); - double y = Stack->Pop()->GetFloat(); - double x = Stack->Pop()->GetFloat(); - Stack->PushFloat(atan2(y, x)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Ceil - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Ceil") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(ceil(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Cos") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(cos(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cosh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Cosh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(cosh(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exp") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(exp(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Floor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Floor") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(floor(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Log") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(log(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log10 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Log10") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(log10(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pow") == 0) { - Stack->CorrectParams(2); - double x = Stack->Pop()->GetFloat(); - double y = Stack->Pop()->GetFloat(); - - Stack->PushFloat(pow(x, y)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sin") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sin(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sinh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sinh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sinh(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Tan") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(tan(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tanh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Tanh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(tanh(DegreeToRadian(Stack->Pop()->GetFloat()))); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sqrt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sqrt") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sqrt(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DegToRad - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DegToRad") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(DegreeToRadian(Stack->Pop()->GetFloat())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RadToDeg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RadToDeg") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(RadianToDegree(Stack->Pop()->GetFloat())); - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("math"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PI - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PI") == 0) { - _scValue->SetFloat(PI); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::DegreeToRadian(double Value) { - return Value * (PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::RadianToDegree(double Value) { - return Value * (180.0f / PI); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXMath.h b/engines/wintermute/scriptables/SXMath.h deleted file mode 100644 index 59064c877f..0000000000 --- a/engines/wintermute/scriptables/SXMath.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMATH_H -#define WINTERMUTE_SXMATH_H - - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CSXMath : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - -private: - double DegreeToRadian(double Value); - double RadianToDegree(double Value); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXMemBuffer.cpp b/engines/wintermute/scriptables/SXMemBuffer.cpp deleted file mode 100644 index 6f5bfee6bb..0000000000 --- a/engines/wintermute/scriptables/SXMemBuffer.cpp +++ /dev/null @@ -1,479 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE -#define FORBIDDEN_SYMBOL_EXCEPTION_fopen -#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite -#define FORBIDDEN_SYMBOL_EXCEPTION_fclose -#include "engines/wintermute/BScriptable.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/SXMemBuffer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(1); - _buffer = NULL; - _size = 0; - - int NewSize = Stack->Pop()->GetInt(); - Resize(MAX(0, NewSize)); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - _size = NULL; - _buffer = Buffer; -} - - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { - Cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::ScToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::Cleanup() { - if (_size) free(_buffer); - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::Resize(int NewSize) { - int OldSize = _size; - - if (_size == 0) { - _buffer = malloc(NewSize); - if (_buffer) _size = NewSize; - } else { - void *NewBuf = realloc(_buffer, NewSize); - if (!NewBuf) { - if (NewSize == 0) { - _buffer = NewBuf; - _size = NewSize; - } else return E_FAIL; - } else { - _buffer = NewBuf; - _size = NewSize; - } - } - - if (_buffer && _size > OldSize) { - memset((byte *)_buffer + OldSize, 0, _size - OldSize); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { - if (_buffer == NULL) { - Script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); - return false; - } - if (_size == 0) return true; - - if (Start < 0 || Length == 0 || Start + Length > _size) { - Script->RuntimeError("Set/Get method call is out of bounds"); - return false; - } else return true; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::ScToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetSize - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSize") == 0) { - Stack->CorrectParams(1); - int NewSize = Stack->Pop()->GetInt(); - NewSize = MAX(0, NewSize); - if (SUCCEEDED(Resize(NewSize))) Stack->PushBool(true); - else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetBool") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); - else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetByte") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushNULL(); - else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetShort") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); - else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInt / GetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInt") == 0 || strcmp(Name, "GetLong") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); - else Stack->PushInt(*(int *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFloat") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); - else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDouble") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); - else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetString") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - int Length = Stack->Pop()->GetInt(); - - // find end of string - if (Length == 0 && Start >= 0 && Start < _size) { - for (int i = Start; i < _size; i++) { - if (((char *)_buffer)[i] == '\0') { - Length = i - Start; - break; - } - } - } - - if (!CheckBounds(Script, Start, Length)) Stack->PushNULL(); - else { - char *Str = new char[Length + 1]; - strncpy(Str, (const char *)_buffer + Start, Length); - Str[Length] = '\0'; - Stack->PushString(Str); - delete [] Str; - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPointer") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); - else { - void *Pointer = *(void **)((byte *)_buffer + Start); - CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); - Stack->PushNative(Buf, false); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetBool") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - bool Val = Stack->Pop()->GetBool(); - - if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); - else { - *(bool *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetByte") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - byte Val = (byte)Stack->Pop()->GetInt(); - - if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushBool(false); - else { - *(byte *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetShort") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - short Val = (short)Stack->Pop()->GetInt(); - - if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); - else { - *(short *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInt / SetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInt") == 0 || strcmp(Name, "SetLong") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - int Val = Stack->Pop()->GetInt(); - - if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); - else { - *(int *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFloat") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - float Val = (float)Stack->Pop()->GetFloat(); - - if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); - else { - *(float *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDouble") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - double Val = Stack->Pop()->GetFloat(); - - if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); - else { - *(double *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetString") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - const char *Val = Stack->Pop()->GetString(); - - if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); - else { - memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); - Stack->PushBool(true); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPointer") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); - - if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushBool(false); - else { - /* - int Pointer = (int)Val->GetMemBuffer(); - memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - Stack->PushBool(true); - */ - // TODO fix - Stack->PushBool(false); - - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_Dump - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DEBUG_Dump") == 0) { - Stack->CorrectParams(0); - if (_buffer && _size) { - FILE *f = fopen("c:\\!!buffer.bin", "wb"); - fwrite(_buffer, _size, 1, f); - fclose(f); - } - Stack->PushNULL(); - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("membuffer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Size (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Size") == 0) { - _scValue->SetInt(_size); - return _scValue; - } - - else return CBScriptable::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Length")==0){ - int OrigLength = _length; - _length = max(Value->GetInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return S_OK; - } - else*/ return CBScriptable::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_size)); - - if (PersistMgr->_saving) { - if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); - } else { - if (_size > 0) { - _buffer = malloc(_size); - PersistMgr->GetBytes((byte *)_buffer, _size); - } else _buffer = NULL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::ScCompare(CBScriptable *Val) { - if (_buffer == Val->ScToMemBuffer()) return 0; - else return 1; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXMemBuffer.h b/engines/wintermute/scriptables/SXMemBuffer.h deleted file mode 100644 index 824c0aaf77..0000000000 --- a/engines/wintermute/scriptables/SXMemBuffer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CSXMemBuffer : public CBScriptable { -public: - virtual int ScCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); - CSXMemBuffer(CBGame *inGame, CScStack *Stack); - CSXMemBuffer(CBGame *inGame, void *Buffer); - virtual ~CSXMemBuffer(); - virtual void *ScToMemBuffer(); - int _size; -private: - HRESULT Resize(int NewSize); - void *_buffer; - void Cleanup(); - bool CheckBounds(CScScript *Script, int Start, int Length); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXStore.cpp b/engines/wintermute/scriptables/SXStore.cpp deleted file mode 100644 index ef801feb89..0000000000 --- a/engines/wintermute/scriptables/SXStore.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BRegistry.h" -#include "engines/wintermute/scriptables/SXStore.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/StringUtil.h" - -#ifdef __IPHONEOS__ -# include "IOS_StoreKit_interface.h" -#endif - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXStore, false) - -////////////////////////////////////////////////////////////////////////// -CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { -#ifdef __IPHONEOS__ - StoreKit_SetExternalData((void *)this); -#endif - - _eventsEnabled = false; - _lastProductRequestOwner = NULL; - _lastPurchaseOwner = NULL; - _lastRestoreOwner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CSXStore::~CSXStore() { - Cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::Cleanup() { - SetEventsEnabled(NULL, false); - - for (int i = 0; i < _validProducts.GetSize(); i++) { - delete _validProducts[i]; - } - _validProducts.RemoveAll(); - - - for (int i = 0; i < _transactions.GetSize(); i++) { - delete _transactions[i]; - } - _transactions.RemoveAll(); - - - _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // EnableEvents - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "EnableEvents") == 0) { - stack->CorrectParams(0); - SetEventsEnabled(script, true); - stack->PushBool(GetEventsEnabled() == true); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // DisableEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableEvents") == 0) { - stack->CorrectParams(0); - SetEventsEnabled(script, false); - stack->PushBool(GetEventsEnabled() == false); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ValidateProducts - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidateProducts") == 0) { - stack->CorrectParams(1); - const char *prodIdList = stack->Pop()->GetString(); - _lastProductRequestOwner = script->_owner; - ValidateProducts(prodIdList); - stack->PushNULL(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetValidProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetValidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); - if (index >= 0 && index < _validProducts.GetSize()) { - CScValue *prod = stack->GetPushValue(); - if (prod) { - prod->SetProperty("Id", _validProducts[index]->GetId()); - prod->SetProperty("Name", _validProducts[index]->GetName()); - prod->SetProperty("Description", _validProducts[index]->GetDesc()); - prod->SetProperty("Price", _validProducts[index]->GetPrice()); - } - } else - stack->PushNULL(); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetInvalidProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInvalidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); - if (index >= 0 && index < _invalidProducts.size()) - stack->PushString(_invalidProducts[index].c_str()); - else - stack->PushNULL(); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetTransaction - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetTransaction") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); - if (index >= 0 && index < _transactions.GetSize()) { - CScValue *trans = stack->GetPushValue(); - if (trans) { - trans->SetProperty("Id", _transactions[index]->GetId()); - trans->SetProperty("ProductId", _transactions[index]->GetProductId()); - trans->SetProperty("State", _transactions[index]->GetState()); - } - } else - stack->PushNULL(); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Purchase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Purchase") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); - stack->PushBool(Purchase(script, prodId)); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FinishTransaction - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FinishTransaction") == 0) { - stack->CorrectParams(1); - const char *transId = stack->Pop()->GetString(); - stack->PushBool(FinishTransaction(script, transId)); - - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RestoreTransactions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RestoreTransactions") == 0) { - stack->CorrectParams(0); - RestoreTransactions(script); - stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnlockProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnlockProduct") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); - - Game->_registry->WriteBool("Purchases", prodId, true); - Game->_registry->SaveValues(); - - stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsProductUnlocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsProductUnlocked") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); - - stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); - - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXStore::ScGetProperty(const char *name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->SetString("store"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Available (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Available") == 0) { - _scValue->SetBool(IsAvailable()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // EventsEnabled (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EventsEnabled") == 0) { - _scValue->SetBool(GetEventsEnabled()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumValidProducts (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumValidProducts") == 0) { - _scValue->SetInt(_validProducts.GetSize()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumInvalidProducts (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumInvalidProducts") == 0) { - _scValue->SetInt(_invalidProducts.size()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumTransactions (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumTransactions") == 0) { - _scValue->SetInt(_transactions.GetSize()); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_eventsEnabled)); - PersistMgr->Transfer(TMEMBER(_lastProductRequestOwner)); - PersistMgr->Transfer(TMEMBER(_lastPurchaseOwner)); - PersistMgr->Transfer(TMEMBER(_lastRestoreOwner)); - PersistMgr->Transfer(TMEMBER(_invalidProducts)); - - // persist valid products - int numProducts; - if (PersistMgr->_saving) { - numProducts = _validProducts.GetSize(); - PersistMgr->Transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(PersistMgr); - } else { - numProducts = _validProducts.GetSize(); - PersistMgr->Transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) { - CBStoreProduct *prod = new CBStoreProduct; - prod->Persist(PersistMgr); - _validProducts.Add(prod); - } - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXStore::AfterLoad() { - if (_eventsEnabled) { - SetEventsEnabled(NULL, true); - } -#ifdef __IPHONEOS__ - StoreKit_SetExternalData((void *)this); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { - if (_lastProductRequestOwner == obj) _lastProductRequestOwner = NULL; - if (_lastPurchaseOwner == obj) _lastPurchaseOwner = NULL; - if (_lastRestoreOwner == obj) _lastRestoreOwner = NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::SetEventsEnabled(CScScript *script, bool val) { - _eventsEnabled = val; - - if (val) { - if (script) _lastPurchaseOwner = script->_owner; -#ifdef __IPHONEOS__ - StoreKit_EnableEvents(); -#endif - } else { - _lastPurchaseOwner = NULL; -#ifdef __IPHONEOS__ - StoreKit_DisableEvents(); -#endif - } -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::ValidateProducts(const char *prodIdList) { -#ifdef __IPHONEOS__ - StoreKit_ValidateProducts(prodIdList); -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::IsAvailable() { -#ifdef __IPHONEOS__ - return StoreKit_IsStoreAvailable() > 0; -#else - return false; -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveProductsStart() { - for (int i = 0; i < _validProducts.GetSize(); i++) { - delete _validProducts[i]; - } - _validProducts.RemoveAll(); - - _invalidProducts.clear(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveProductsEnd() { - if (_lastProductRequestOwner) _lastProductRequestOwner->ApplyEvent("ProductsValidated"); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::AddValidProduct(const char *id, const char *name, const char *desc, const char *price) { - CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); - _validProducts.Add(prod); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::AddInvalidProduct(const char *id) { - _invalidProducts.push_back(id); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveTransactionsStart() { - for (int i = 0; i < _transactions.GetSize(); i++) { - delete _transactions[i]; - } - _transactions.RemoveAll(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveTransactionsEnd() { - if (_lastPurchaseOwner) _lastPurchaseOwner->ApplyEvent("TransactionsUpdated"); - else Game->ApplyEvent("TransactionsUpdated"); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::AddTransaction(const char *id, const char *productId, const char *state) { - CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); - _transactions.Add(trans); -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::Purchase(CScScript *script, const char *productId) { - if (!productId) return false; - -#ifdef __IPHONEOS__ - for (int i = 0; i < _validProducts.GetSize(); i++) { - if (strcmp(productId, _validProducts[i]->GetId()) == 0) { - _lastPurchaseOwner = script->_owner; - - StoreKit_Purchase(productId); - return true; - } - } -#endif - script->RuntimeError("Store.Purchase() - '%s' is not a valid product id", productId); - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { - if (!transId) return false; -#ifdef __IPHONEOS__ - for (int i = 0; i < _transactions.GetSize(); i++) { - if (strcmp(transId, _transactions[i]->GetId()) == 0) { - if (StoreKit_FinishTransaction(transId) > 0) { - SAFE_DELETE(_transactions[i]); - _transactions.RemoveAt(i); - return true; - } else return false; - } - } -#endif - script->RuntimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); - return false; -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::RestoreTransactions(CScScript *script) { - _lastRestoreOwner = script->_owner; -#ifdef __IPHONEOS__ - StoreKit_RestoreTransactions(); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::OnRestoreFinished(bool error) { - if (_lastRestoreOwner) { - if (error) _lastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); - else _lastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); - } -} - - - -#ifdef __IPHONEOS__ - -////////////////////////////////////////////////////////////////////////// -// StoreKit callbacks (called from ObjC) -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddValidProductCallback(const char *id, const char *name, const char *desc, const char *price, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddValidProduct(id, name, desc, price); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddInvalidProductCallback(const char *id, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddInvalidProduct(id); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveProductsStartCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveProductsStart(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveProductsEndCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveProductsEnd(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddTransactionCallback(const char *id, const char *productId, const char *state, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddTransaction(id, productId, state); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveTransactionsStartCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveTransactionsStart(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveTransactionsEndCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveTransactionsEnd(); -} -////////////////////////////////////////////////////////////////////////// -void StoreKit_RestoreFinishedCallback(void *data, int error) { - CSXStore *store = static_cast(data); - if (store) store->OnRestoreFinished(error > 0); -} - -#endif // __IPHONEOS__ - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXStore.h b/engines/wintermute/scriptables/SXStore.h deleted file mode 100644 index 4bcb4506d4..0000000000 --- a/engines/wintermute/scriptables/SXStore.h +++ /dev/null @@ -1,175 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTORE_H -#define WINTERMUTE_SXSTORE_H -#include "engines/wintermute/BPersistMgr.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/BObject.h" - -namespace WinterMute { - -class CSXStore : public CBObject { -public: - - ////////////////////////////////////////////////////////////////////////// - class CBStoreProduct { - public: - CBStoreProduct() { - _id = _name = _desc = _price = NULL; - } - - CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { - _id = _name = _desc = _price = NULL; - - CBUtils::SetString(&_id, id); - CBUtils::SetString(&_name, name); - CBUtils::SetString(&_desc, desc); - CBUtils::SetString(&_price, price); - } - - ~CBStoreProduct() { - delete [] _id; - delete [] _name; - delete [] _desc; - delete [] _price; - } - - HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_id)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_desc)); - PersistMgr->Transfer(TMEMBER(_price)); - return S_OK; - } - - const char *GetId() { - return _id; - } - const char *GetName() { - return _name; - } - const char *GetDesc() { - return _desc; - } - const char *GetPrice() { - return _price; - } - - private: - char *_id; - char *_name; - char *_desc; - char *_price; - }; - - ////////////////////////////////////////////////////////////////////////// - class CBStoreTransaction { - public: - CBStoreTransaction() { - _id = _productId = _state = NULL; - } - - CBStoreTransaction(const char *id, const char *productId, const char *state) { - _id = _productId = _state = NULL; - - CBUtils::SetString(&_id, id); - CBUtils::SetString(&_productId, productId); - CBUtils::SetString(&_state, state); - } - - ~CBStoreTransaction() { - delete [] _id; - delete [] _productId; - delete [] _state; - } - - const char *GetId() { - return _id; - } - const char *GetProductId() { - return _productId; - } - const char *GetState() { - return _state; - } - - private: - char *_id; - char *_productId; - char *_state; - }; - - - DECLARE_PERSISTENT(CSXStore, CBObject) - CSXStore(CBGame *inGame); - virtual ~CSXStore(); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - - void AfterLoad(); - void OnObjectDestroyed(CBScriptHolder *obj); - - bool IsAvailable(); - void SetEventsEnabled(CScScript *script, bool val); - bool GetEventsEnabled() const { - return _eventsEnabled; - } - void ValidateProducts(const char *prodIdList); - - void ReceiveTransactionsStart(); - void ReceiveTransactionsEnd(); - void AddTransaction(const char *id, const char *productId, const char *state); - - void ReceiveProductsStart(); - void ReceiveProductsEnd(); - void AddValidProduct(const char *id, const char *name, const char *desc, const char *price); - void AddInvalidProduct(const char *id); - - void OnRestoreFinished(bool error); - -private: - void Cleanup(); - bool Purchase(CScScript *script, const char *productId); - bool FinishTransaction(CScScript *script, const char *transId); - void RestoreTransactions(CScScript *script); - - bool _eventsEnabled; - CBArray _validProducts; - AnsiStringArray _invalidProducts; - CBScriptHolder *_lastProductRequestOwner; - CBScriptHolder *_lastPurchaseOwner; - CBScriptHolder *_lastRestoreOwner; - - CBArray _transactions; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SXString.cpp b/engines/wintermute/scriptables/SXString.cpp deleted file mode 100644 index 2837530ca0..0000000000 --- a/engines/wintermute/scriptables/SXString.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/scriptables/SXString.h" -#include "engines/wintermute/scriptables/SXArray.h" -#include "engines/wintermute/StringUtil.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXString, false) - -////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - _string = NULL; - _capacity = 0; - - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (Val->IsInt()) { - _capacity = MAX(0, Val->GetInt()); - if (_capacity > 0) { - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - } else { - SetStringVal(Val->GetString()); - } - - if (_capacity == 0) SetStringVal(""); -} - - -////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { - if (_string) delete [] _string; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::SetStringVal(const char *Val) { - int Len = strlen(Val); - if (Len >= _capacity) { - _capacity = Len + 1; - delete[] _string; - _string = NULL; - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - strcpy(_string, Val); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXString::ScToString() { - if (_string) return _string; - else return "[null string]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::ScSetString(const char *Val) { - SetStringVal(Val); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // Substring - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Substring") == 0) { - Stack->CorrectParams(2); - int start = Stack->Pop()->GetInt(); - int end = Stack->Pop()->GetInt(); - - if (end < start) CBUtils::Swap(&start, &end); - - //try { - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); - - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); - // } catch (std::exception &) { - // Stack->PushNULL(); - // } - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Substr - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Substr") == 0) { - Stack->CorrectParams(2); - int start = Stack->Pop()->GetInt(); - - CScValue *val = Stack->Pop(); - int len = val->GetInt(); - - if (!val->IsNULL() && len <= 0) { - Stack->PushString(""); - return S_OK; - } - - if (val->IsNULL()) len = strlen(_string) - start; - -// try { - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - -// WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); - - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); -// } catch (std::exception &) { -// Stack->PushNULL(); -// } - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToUpperCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToUpperCase") == 0) { - Stack->CorrectParams(0); - - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - - StringUtil::ToUpperCase(str); - - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(str).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(str).c_str()); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToLowerCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToLowerCase") == 0) { - Stack->CorrectParams(0); - - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - - StringUtil::ToLowerCase(str); - - if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(str).c_str()); - else - Stack->PushString(StringUtil::WideToAnsi(str).c_str()); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IndexOf - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IndexOf") == 0) { - Stack->CorrectParams(2); - - const char *strToFind = Stack->Pop()->GetString(); - int index = Stack->Pop()->GetInt(); - - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - - WideString toFind; - if (Game->_textEncoding == TEXT_UTF8) - toFind = StringUtil::Utf8ToWide(strToFind); - else - toFind = StringUtil::AnsiToWide(strToFind); - - int indexOf = StringUtil::IndexOf(str, toFind, index); - Stack->PushInt(indexOf); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Split - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Split") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - char Separators[MAX_PATH] = ","; - if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); - - CSXArray *Array = new CSXArray(Game); - if (!Array) { - Stack->PushNULL(); - return S_OK; - } - - - WideString str; - if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); - else - str = StringUtil::AnsiToWide(_string); - - WideString delims; - if (Game->_textEncoding == TEXT_UTF8) - delims = StringUtil::Utf8ToWide(Separators); - else - delims = StringUtil::AnsiToWide(Separators); - - Common::Array parts; - - - size_t start, pos; - start = 0; - do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - - } while (pos != str.size()); - - for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { - WideString &part = (*it); - - if (Game->_textEncoding == TEXT_UTF8) - Val = new CScValue(Game, StringUtil::WideToUtf8(part).c_str()); - else - Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); - - Array->Push(Val); - delete[] Val; - Val = NULL; - } - - Stack->PushNative(Array, false); - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("string"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(_string); - _scValue->SetInt(wstr.size()); - } else - _scValue->SetInt(strlen(_string)); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Capacity") == 0) { - _scValue->SetInt(_capacity); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Capacity") == 0) { - int NewCap = Value->GetInt(); - if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); - else if (NewCap != _capacity) { - char *NewStr = new char[NewCap]; - if (NewStr) { - memset(NewStr, 0, NewCap); - strcpy(NewStr, _string); - delete[] _string; - _string = NewStr; - _capacity = NewCap; - } - } - return S_OK; - } - - else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_capacity)); - - if (PersistMgr->_saving) { - if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); - } else { - if (_capacity > 0) { - _string = new char[_capacity]; - PersistMgr->GetBytes((byte *)_string, _capacity); - } else _string = NULL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXString::ScCompare(CBScriptable *Val) { - return strcmp(_string, ((CSXString *)Val)->_string); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SXString.h b/engines/wintermute/scriptables/SXString.h deleted file mode 100644 index 44e2bbe5ef..0000000000 --- a/engines/wintermute/scriptables/SXString.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTRING_H -#define WINTERMUTE_SXSTRING_H - - -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -class CSXString : public CBScriptable { -public: - virtual int ScCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - void ScSetString(const char *Val); - const char *ScToString(); - void SetStringVal(const char *Val); - - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp deleted file mode 100644 index bb65b438de..0000000000 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ /dev/null @@ -1,854 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/SXMath.h" -#include "engines/wintermute/BRegistry.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/BSound.h" -#include "engines/wintermute/BFileManager.h" -#include -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { - Game->LOG(0, "Initializing scripting engine..."); - -/* -#ifdef __WIN32__ - char CompilerPath[MAX_PATH]; - strcpy(CompilerPath, COMPILER_DLL); - - _compilerDLL = ::LoadLibrary(CompilerPath); - if (_compilerDLL == NULL) { - char ModuleName[MAX_PATH]; - ::GetModuleFileName(NULL, ModuleName, MAX_PATH); - - // switch to exe's dir - char *ExeDir = CBUtils::GetPath(ModuleName); - sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); - _compilerDLL = ::LoadLibrary(CompilerPath); - - delete [] ExeDir; - } - if (_compilerDLL != NULL) { - // bind compiler's functionality - ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); - ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); - ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); - ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); - ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); - ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); - - if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { - _compilerAvailable = false; - ::FreeLibrary(_compilerDLL); - _compilerDLL = NULL; - } else { - */ /* - // publish external methods to the compiler - CALLBACKS c; - c.Dll_AddError = AddError; - c.Dll_CloseFile = CloseFile; - c.Dll_LoadFile = LoadFile; - ExtSetCallbacks(&c, Game); - */ -/* - _compilerAvailable = true; - } - } else _compilerAvailable = false; -#else -*/ - _compilerAvailable = false; - _compilerDLL = NULL; -//#endif - - - if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); - else Game->LOG(0, " Script compiler is NOT available"); - - _globals = new CScValue(Game); - - - // register 'Game' as global variable - if (!_globals->PropExists("Game")) { - CScValue val(Game); - val.SetNative(Game, true); - _globals->SetProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->PropExists("Math")) { - CScValue val(Game); - val.SetNative(Game->_mathClass, true); - _globals->SetProp("Math", &val); - } - - // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; - - _currentScript = NULL; - - _fileToCompile = NULL; - - _compileErrorCallback = NULL; - _compileErrorCallbackData = NULL; - - _parseElementCallback = NULL; - _parseElementCallbackData = NULL; - - _isProfiling = false; - _profilingStartTime = 0; - - //EnableProfiling(); -} - - -////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { - Game->LOG(0, "Shutting down scripting engine"); - SaveBreakpoints(); - - DisableProfiling(); -#ifdef __WIN32__ - if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); -#endif - Cleanup(); - - for (int i = 0; i < _breakpoints.GetSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Cleanup() { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); - delete _scripts[i]; - _scripts.RemoveAt(i); - i--; - } - - _scripts.RemoveAll(); - - delete _globals; - _globals = NULL; - - EmptyScriptCache(); - - _currentScript = NULL; // ref only - - delete[] _fileToCompile; - _fileToCompile = NULL; - - _compileErrorCallback = NULL; - _compileErrorCallbackData = NULL; - - _parseElementCallback = NULL; - _parseElementCallbackData = NULL; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { - CBGame *Game = (CBGame *)Data; - return Game->_fileManager->ReadWholeFile(Filename, Size); -} - - -////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::CloseFile(void *Data, byte *Buffer) { - delete [] Buffer; -} - -////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::AddError(void *Data, int Line, char *Text) { - CBGame *Game = (CBGame *)Data; - - if (Game) { - if (Game->_scEngine && Game->_scEngine->_fileToCompile) - Game->LOG(0, "Compiling script '%s'...", Game->_scEngine->_fileToCompile); - Game->LOG(0, " Error@line %d: %s", Line, Text); - - - // redirect to an engine's own callback - if (Game->_scEngine && Game->_scEngine->_compileErrorCallback) { - Game->_scEngine->_compileErrorCallback(Line, Text, Game->_scEngine->_compileErrorCallbackData); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *ElementData) { - CBGame *Game = (CBGame *)Data; - - if (Game) { - // redirect to an engine's own callback - if (Game->_scEngine && Game->_scEngine->_parseElementCallback) { - Game->_scEngine->_parseElementCallback(Line, Type, ElementData, Game->_scEngine->_compileErrorCallbackData); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { - byte *CompBuffer; - uint32 CompSize; - - // get script from cache - CompBuffer = GetCompiledScript(Filename, &CompSize); - if (!CompBuffer) return NULL; - - // add new script - CScScript *script = new CScScript(Game, this); - HRESULT ret = script->Create(Filename, CompBuffer, CompSize, Owner); - if (FAILED(ret)) { - Game->LOG(ret, "Error running script '%s'...", Filename); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - CScValue val(Game); - if (Owner)val.SetNative(Owner, true); - else val.SetNULL(); - - script->_globals->SetProp("self", &val); - script->_globals->SetProp("this", &val); - - _scripts.Add(script); - Game->GetDebugMgr()->OnScriptInit(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache) { - int i; - - // is script in cache? - if (!IgnoreCache) { - for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), Filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); - *OutSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *CompBuffer; - uint32 CompSize; - bool CompiledNow = false; - - uint32 Size; - - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); - if (!Buffer) { - Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); - return NULL; - } - - // needs to be compiled? - if (*(uint32 *)Buffer == SCRIPT_MAGIC) { - CompBuffer = Buffer; - CompSize = Size; - } else { - if (!_compilerAvailable) { - Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", Filename); - delete [] Buffer; - return NULL; - } - - CompiledNow = true; - - // publish external methods to the compiler - CALLBACKS c; - c.Dll_AddError = AddError; - c.Dll_CloseFile = CloseFile; - c.Dll_LoadFile = LoadFile; - c.Dll_ParseElement = ParseElement; - ExtSetCallbacks(&c, Game); - - // publish native interfaces - Game->PublishNatives(); - - // We have const char* everywhere but in the DLL-interfaces... - char *tempFileName = new char[strlen(Filename) + 1]; - memcpy(tempFileName, Filename, strlen(Filename) + 1); - - SetFileToCompile(Filename); - CompBuffer = ExtCompileFile(tempFileName, &CompSize); - delete[] tempFileName; - if (!CompBuffer) { - Game->QuickMessage("Script compiler error. View log for details."); - delete [] Buffer; - return NULL; - } - } - - byte *ret = NULL; - - // add script to cache - CScCachedScript *CachedScript = new CScCachedScript(Filename, CompBuffer, CompSize); - if (CachedScript) { - int index; - uint32 MinTime = CBPlatform::GetTime(); - for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] == NULL) { - index = i; - break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; - index = i; - } - } - - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; - _cachedScripts[index] = CachedScript; - - ret = CachedScript->_buffer; - *OutSize = CachedScript->_size; - } - - - // cleanup - delete [] Buffer; - if (CompiledNow) ExtReleaseBuffer(CompBuffer); - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Tick() { - int i; - - if (_scripts.GetSize() == 0) return S_OK; - - - // resolve waiting scripts - for (i = 0; i < _scripts.GetSize(); i++) { - - switch (_scripts[i]->_state) { - case SCRIPT_WAITING: { - /* - bool obj_found=false; - for(int j=0; j_regObjects.GetSize(); j++) - { - if(Game->_regObjects[j] == _scripts[i]->_waitObject) - { - if(Game->_regObjects[j]->IsReady()) _scripts[i]->Run(); - obj_found = true; - break; - } - } - if(!obj_found) _scripts[i]->Finish(); // _waitObject no longer exists - */ - if (Game->ValidObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->IsReady()) _scripts[i]->Run(); - } else _scripts[i]->Finish(); - break; - } - - case SCRIPT_SLEEPING: { - if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->Run(); - } else { - if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->Run(); - } - break; - } - - case SCRIPT_WAITING_SCRIPT: { - if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { - // fake return value - _scripts[i]->_stack->PushNULL(); - _scripts[i]->_waitScript = NULL; - _scripts[i]->Run(); - } else { - if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { - // copy return value - _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); - _scripts[i]->Run(); - _scripts[i]->_waitScript->Finish(); - _scripts[i]->_waitScript = NULL; - } - } - break; - } - } // switch - } // for each script - - - // execute scripts - for (i = 0; i < _scripts.GetSize(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; - - // time sliced script - if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::GetTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < _scripts[i]->_timeSlice) { - _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); - } - if (_isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); - } - - // normal script - else { - uint32 StartTime; - bool isProfiling = _isProfiling; - if (isProfiling) StartTime = CBPlatform::GetTime(); - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); - } - if (isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); - } - _currentScript = NULL; - } - - RemoveFinishedScripts(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::TickUnbreakable() { - // execute unbreakable scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); - } - _scripts[i]->Finish(); - _currentScript = NULL; - } - RemoveFinishedScripts(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RemoveFinishedScripts() { - // remove finished scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); - Game->GetDebugMgr()->OnScriptShutdown(_scripts[i]); - delete _scripts[i]; - _scripts.RemoveAt(i); - i--; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { - int running = 0, waiting = 0, persistent = 0, total = 0; - - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; - switch (_scripts[i]->_state) { - case SCRIPT_RUNNING: - case SCRIPT_SLEEPING: - case SCRIPT_PAUSED: - running++; - break; - case SCRIPT_WAITING: - waiting++; - break; - case SCRIPT_PERSISTENT: - persistent++; - break; - } - total++; - } - if (Running) *Running = running; - if (Waiting) *Waiting = waiting; - if (Persistent) *Persistent = persistent; - - return total; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::EmptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResetObject(CBObject *Object) { - // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!Game->_compatKillMethodThreads) ResetScript(_scripts[i]); - - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResetScript(CScScript *Script) { - // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == Script) { - _scripts[i]->Finish(); - } - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_currentScript)); - PersistMgr->Transfer(TMEMBER(_fileToCompile)); - PersistMgr->Transfer(TMEMBER(_globals)); - _scripts.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::EditorCleanup() { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { - delete _scripts[i]; - _scripts.RemoveAt(i); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::PauseAll() { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->Pause(); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResumeAll() { - for (int i = 0; i < _scripts.GetSize(); i++) - _scripts[i]->Resume(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SetFileToCompile(const char *Filename) { - delete[] _fileToCompile; - _fileToCompile = new char[strlen(Filename) + 1]; - if (_fileToCompile) { - strcpy(_fileToCompile, Filename); - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data) { - _compileErrorCallback = Callback; - _compileErrorCallbackData = Data; -} - -////////////////////////////////////////////////////////////////////////// -void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data) { - _parseElementCallback = Callback; - _parseElementCallbackData = Data; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::IsValidScript(CScScript *Script) { - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] == Script) return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ClearGlobals(bool IncludingNatives) { - _globals->CleanProps(IncludingNatives); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { - // send global variables - _globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->DbgSendScript(Client); - } - - // and threads later - for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->DbgSendScript(Client); - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - CScBreakpoint *Bp = NULL; - for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { - Bp = _breakpoints[i]; - break; - } - } - if (Bp == NULL) { - Bp = new CScBreakpoint(ScriptFilename); - _breakpoints.Add(Bp); - } - bool Found = false; - for (int i = 0; i < Bp->_lines.GetSize(); i++) { - if (Bp->_lines[i] == Line) return S_OK; - } - Bp->_lines.Add(Line); - - // refresh changes - RefreshScriptBreakpoints(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { - if (_breakpoints[i]->_lines[j] == Line) { - _breakpoints[i]->_lines.RemoveAt(j); - if (_breakpoints[i]->_lines.GetSize() == 0) { - delete _breakpoints[i]; - _breakpoints.RemoveAt(i); - } - // refresh changes - RefreshScriptBreakpoints(); - - return S_OK; - } - } - break; - } - } - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RefreshScriptBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - for (int i = 0; i < _scripts.GetSize(); i++) { - RefreshScriptBreakpoints(_scripts[i]); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - if (!Script || !Script->_filename) return E_FAIL; - - for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), Script->_filename) == 0) { - Script->_breakpoints.Copy(_breakpoints[i]->_lines); - return S_OK; - } - } - if (Script->_breakpoints.GetSize() > 0) Script->_breakpoints.RemoveAll(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SaveBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - - char Text[512]; - char Key[100]; - - int Count = 0; - for (int i = 0; i < _breakpoints.GetSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { - Count++; - sprintf(Key, "Breakpoint%d", Count); - sprintf(Text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - Game->_registry->WriteString("Debug", Key, Text); - } - } - Game->_registry->WriteInt("Debug", "NumBreakpoints", Count); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::LoadBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; - - char Key[100]; - - int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= Count; i++) { - /* uint32 BufSize = 512; */ - sprintf(Key, "Breakpoint%d", i); - AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); - - char *Path = CBUtils::StrEntry(0, breakpoint.c_str(), ':'); - char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); - - if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); - delete[] Path; - delete[] Line; - Path = NULL; - Line = NULL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { - if (!_isProfiling) return; - - AnsiString fileName = Filename; - StringUtil::ToLowerCase(fileName); - _scriptTimes[fileName] += Time; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::EnableProfiling() { - if (_isProfiling) return; - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = CBPlatform::GetTime(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::DisableProfiling() { - if (!_isProfiling) return; - - DumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::DumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; - - typedef std::vector > TimeVector; - TimeVector times; - - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); - - - TimeVector::reverse_iterator tit; - - Game->LOG(0, "***** Script profiling information: *****"); - Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - - for (tit = times.rbegin(); tit != times.rend(); tit++) { - Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h deleted file mode 100644 index ab1504e899..0000000000 --- a/engines/wintermute/scriptables/ScEngine.h +++ /dev/null @@ -1,174 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCENGINE_H -#define WINTERMUTE_SCENGINE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/BBase.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); -typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); -typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); -typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); -typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); /* Was non-const, changed to silence warnings */ -typedef int (*DLL_DEFINE_VARIABLE)(const char *Name); /* Was non-const, changed to silence warnings */ - -typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); -typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); - -#define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { -public: - class CScCachedScript { - public: - CScCachedScript(const char *Filename, byte *Buffer, uint32 Size) { - _timestamp = CBPlatform::GetTime(); - _buffer = new byte[Size]; - if (_buffer) memcpy(_buffer, Buffer, Size); - _size = Size; - _filename = Filename; - }; - - ~CScCachedScript() { - if (_buffer) delete [] _buffer; - }; - - uint32 _timestamp; - byte *_buffer; - uint32 _size; - Common::String _filename; - }; - - class CScBreakpoint { - public: - CScBreakpoint(const char *Filename) { - _filename = Filename; - } - - ~CScBreakpoint() { - _lines.RemoveAll(); - } - - Common::String _filename; - CBArray _lines; - }; - - - - -public: - HRESULT DbgSendScripts(IWmeDebugClient *Client); - - CBArray _breakpoints; - HRESULT AddBreakpoint(const char *ScriptFilename, int Line); - HRESULT RemoveBreakpoint(const char *ScriptFilename, int Line); - HRESULT RefreshScriptBreakpoints(); - HRESULT RefreshScriptBreakpoints(CScScript *Script); - HRESULT SaveBreakpoints(); - HRESULT LoadBreakpoints(); - - HRESULT ClearGlobals(bool IncludingNatives = false); - HRESULT TickUnbreakable(); - HRESULT RemoveFinishedScripts(); - bool IsValidScript(CScScript *Script); - void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); - void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); - - COMPILE_ERROR_CALLBACK _compileErrorCallback; - void *_compileErrorCallbackData; - - PARSE_ELEMENT_CALLBACK _parseElementCallback; - void *_parseElementCallbackData; - - HRESULT SetFileToCompile(const char *Filename); - char *_fileToCompile; - CScScript *_currentScript; - HRESULT ResumeAll(); - HRESULT PauseAll(); - void EditorCleanup(); - HRESULT ResetObject(CBObject *Object); - HRESULT ResetScript(CScScript *Script); - HRESULT EmptyScriptCache(); - byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) - HRESULT Cleanup(); - int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); - HRESULT Tick(); - CScValue *_globals; - CScScript *RunScript(const char *Filename, CBScriptHolder *Owner = NULL); - bool _compilerAvailable; - HINSTANCE _compilerDLL; - CScEngine(CBGame *inGame); - virtual ~CScEngine(); - static void WINAPI AddError(void *Data, int Line, char *Text); - static byte *WINAPI LoadFile(void *Data, char *Filename, uint32 *Size); - static void WINAPI CloseFile(void *Data, byte *Buffer); - static void WINAPI ParseElement(void *Data, int Line, int Type, void *ElementData); - DLL_COMPILE_BUFFER ExtCompileBuffer; - DLL_COMPILE_FILE ExtCompileFile; - DLL_RELEASE_BUFFER ExtReleaseBuffer; - DLL_SET_CALLBACKS ExtSetCallbacks; - DLL_DEFINE_FUNCTION ExtDefineFunction; - DLL_DEFINE_VARIABLE ExtDefineVariable; - - CBArray _scripts; - - void EnableProfiling(); - void DisableProfiling(); - bool IsProfiling() { - return _isProfiling; - } - - void AddScriptTime(const char *Filename, uint32 Time); - void DumpStats(); - -private: - - CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; - bool _isProfiling; - uint32 _profilingStartTime; - - typedef Common::HashMap ScriptTimes; - ScriptTimes _scriptTimes; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/ScScript.cpp b/engines/wintermute/scriptables/ScScript.cpp deleted file mode 100644 index 0b1f81bd0e..0000000000 --- a/engines/wintermute/scriptables/ScScript.cpp +++ /dev/null @@ -1,1600 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/scriptables/ScEngine.h" -#include "engines/wintermute/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScScript, false) - -////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { - _buffer = NULL; - _bufferSize = _iP = 0; - _filename = NULL; - _currentLine = 0; - - _symbols = NULL; - _numSymbols = 0; - - _engine = Engine; - - _globals = NULL; - - _scopeStack = NULL; - _callStack = NULL; - _thisStack = NULL; - _stack = NULL; - - _operand = NULL; - _reg1 = NULL; - - _functions = NULL; - _numFunctions = 0; - - _methods = NULL; - _numMethods = 0; - - _events = NULL; - _numEvents = 0; - - _externals = NULL; - _numExternals = 0; - - _state = SCRIPT_FINISHED; - _origState = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _timeSlice = 0; - - _thread = false; - _methodThread = false; - _threadEvent = NULL; - - _freezable = true; - _owner = NULL; - - _unbreakable = false; - _parentScript = NULL; - - _tracingMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { - Cleanup(); -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::InitScript() { - TScriptHeader *Header = (TScriptHeader *)_buffer; - if (Header->magic != SCRIPT_MAGIC) { - Game->LOG(0, "File '%s' is not a valid compiled script", _filename); - Cleanup(); - return E_FAIL; - } - - if (Header->version > SCRIPT_VERSION) { - Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - Cleanup(); - return E_FAIL; - } - - InitTables(); - - // init stacks - _scopeStack = new CScStack(Game); - _callStack = new CScStack(Game); - _thisStack = new CScStack(Game); - _stack = new CScStack(Game); - - _operand = new CScValue(Game); - _reg1 = new CScValue(Game); - - - // skip to the beginning - _iP = Header->code_start; - _currentLine = 0; - - // init breakpoints - _engine->RefreshScriptBreakpoints(this); - - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::InitTables() { - uint32 OrigIP = _iP; - - TScriptHeader *Header = (TScriptHeader *)_buffer; - - int32 i; - - // load symbol table - _iP = Header->symbol_table; - - _numSymbols = GetDWORD(); - _symbols = new char*[_numSymbols]; - for (i = 0; i < _numSymbols; i++) { - uint32 index = GetDWORD(); - _symbols[index] = GetString(); - } - - // load functions table - _iP = Header->func_table; - - _numFunctions = GetDWORD(); - _functions = new TFunctionPos[_numFunctions]; - for (i = 0; i < _numFunctions; i++) { - _functions[i].pos = GetDWORD(); - _functions[i].name = GetString(); - } - - - // load events table - _iP = Header->event_table; - - _numEvents = GetDWORD(); - _events = new TEventPos[_numEvents]; - for (i = 0; i < _numEvents; i++) { - _events[i].pos = GetDWORD(); - _events[i].name = GetString(); - } - - - // load externals - if (Header->version >= 0x0101) { - _iP = Header->externals_table; - - _numExternals = GetDWORD(); - _externals = new TExternalFunction[_numExternals]; - for (i = 0; i < _numExternals; i++) { - _externals[i].dll_name = GetString(); - _externals[i].name = GetString(); - _externals[i].call_type = (TCallType)GetDWORD(); - _externals[i].returns = (TExternalType)GetDWORD(); - _externals[i].nu_params = GetDWORD(); - if (_externals[i].nu_params > 0) { - _externals[i].params = new TExternalType[_externals[i].nu_params]; - for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)GetDWORD(); - } - } - } - } - - // load method table - _iP = Header->method_table; - - _numMethods = GetDWORD(); - _methods = new TMethodPos[_numMethods]; - for (i = 0; i < _numMethods; i++) { - _methods[i].pos = GetDWORD(); - _methods[i].name = GetString(); - } - - - _iP = OrigIP; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { - Cleanup(); - - _thread = false; - _methodThread = false; - - delete[] _threadEvent; - _threadEvent = NULL; - - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); - - _buffer = new byte [Size]; - if (!_buffer) return E_FAIL; - - memcpy(_buffer, Buffer, Size); - - _bufferSize = Size; - - HRESULT res = InitScript(); - if (FAILED(res)) return res; - - // establish global variables table - _globals = new CScValue(Game); - - _owner = Owner; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { - Cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[strlen(EventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, EventName); - - // copy filename - _filename = new char[strlen(Original->_filename) + 1]; - if (_filename) strcpy(_filename, Original->_filename); - - // copy buffer - _buffer = new byte [Original->_bufferSize]; - if (!_buffer) return E_FAIL; - - memcpy(_buffer, Original->_buffer, Original->_bufferSize); - _bufferSize = Original->_bufferSize; - - // initialize - HRESULT res = InitScript(); - if (FAILED(res)) return res; - - // copy globals - _globals = Original->_globals; - - // skip to the beginning of the event - _iP = InitIP; - - _timeSlice = Original->_timeSlice; - _freezable = Original->_freezable; - _owner = Original->_owner; - - _engine = Original->_engine; - _parentScript = Original; - - return S_OK; -} - - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodName) { - uint32 IP = Original->GetMethodPos(MethodName); - if (IP == 0) return E_FAIL; - - Cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[strlen(MethodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, MethodName); - - // copy filename - _filename = new char[strlen(Original->_filename) + 1]; - if (_filename) strcpy(_filename, Original->_filename); - - // copy buffer - _buffer = new byte [Original->_bufferSize]; - if (!_buffer) return E_FAIL; - - memcpy(_buffer, Original->_buffer, Original->_bufferSize); - _bufferSize = Original->_bufferSize; - - // initialize - HRESULT res = InitScript(); - if (FAILED(res)) return res; - - // copy globals - _globals = Original->_globals; - - // skip to the beginning of the event - _iP = IP; - - _timeSlice = Original->_timeSlice; - _freezable = Original->_freezable; - _owner = Original->_owner; - - _engine = Original->_engine; - _parentScript = Original; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::Cleanup() { - if (_buffer) delete [] _buffer; - _buffer = NULL; - - if (_filename) delete [] _filename; - _filename = NULL; - - if (_symbols) delete [] _symbols; - _symbols = NULL; - _numSymbols = 0; - - if (_globals && !_thread) delete _globals; - _globals = NULL; - - if (_scopeStack) delete _scopeStack; - _scopeStack = NULL; - - if (_callStack) delete _callStack; - _callStack = NULL; - - if (_thisStack) delete _thisStack; - _thisStack = NULL; - - if (_stack) delete _stack; - _stack = NULL; - - if (_functions) delete [] _functions; - _functions = NULL; - _numFunctions = 0; - - if (_methods) delete [] _methods; - _methods = NULL; - _numMethods = 0; - - if (_events) delete [] _events; - _events = NULL; - _numEvents = 0; - - - if (_externals) { - for (int i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; - } - delete [] _externals; - } - _externals = NULL; - _numExternals = 0; - - delete _operand; - delete _reg1; - _operand = NULL; - _reg1 = NULL; - - delete[] _threadEvent; - _threadEvent = NULL; - - _state = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _parentScript = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetDWORD() { - uint32 ret = *(uint32 *)(_buffer + _iP); - _iP += sizeof(uint32); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -double CScScript::GetFloat() { - double ret = *(double *)(_buffer + _iP); - _iP += sizeof(double); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -char *CScScript::GetString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; - _iP++; // string terminator - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::ExecuteInstruction() { - HRESULT ret = S_OK; - - uint32 dw; - const char *str = NULL; - - //CScValue* op = new CScValue(Game); - _operand->Cleanup(); - - CScValue *op1; - CScValue *op2; - - uint32 inst = GetDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->SetNULL(); - dw = GetDWORD(); - if (_scopeStack->_sP < 0) { - _globals->SetProp(_symbols[dw], _operand); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); - } else { - _scopeStack->GetTop()->SetProp(_symbols[dw], _operand); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->GetTop(), _scopeStack->GetTop()->GetProp(_symbols[dw]), _symbols[dw]); - } - - break; - - case II_DEF_GLOB_VAR: - case II_DEF_CONST_VAR: { - dw = GetDWORD(); -/* char *Temp = _symbols[dw]; // TODO delete */ - // only create global var if it doesn't exist - if (!_engine->_globals->PropExists(_symbols[dw])) { - _operand->SetNULL(); - _engine->_globals->SetProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->GetProp(_symbols[dw]), _symbols[dw]); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->GetTop()); - - _scopeStack->Pop(); - _iP = (uint32)_callStack->Pop()->GetInt(); - - if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); - } else { - if (_thread) { - _state = SCRIPT_THREAD_FINISHED; - } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; - } - } - - break; - - case II_RET_EVENT: - _state = SCRIPT_FINISHED; - break; - - - case II_CALL: - dw = GetDWORD(); - - _operand->SetInt(_iP); - _callStack->Push(_operand); - - _iP = dw; - - break; - - case II_CALL_BY_EXP: { - // push var - // push string - str = _stack->Pop()->GetString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); - - CScValue *var = _stack->Pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - - HRESULT res = E_FAIL; - bool TriedNative = false; - - // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->GetNative()) { - TriedNative = true; - res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); - } - - if (FAILED(res)) { - if (var->IsNative() && var->GetNative()->CanHandleMethod(MethodName)) { - if (!_unbreakable) { - _waitScript = var->GetNative()->InvokeMethodThread(MethodName); - if (!_waitScript) { - _stack->CorrectParams(0); - RuntimeError("Error invoking method '%s'.", MethodName); - _stack->PushNULL(); - } else { - _state = SCRIPT_WAITING_SCRIPT; - _waitScript->CopyParameters(_stack); - } - } else { - // can call methods in unbreakable mode - _stack->CorrectParams(0); - RuntimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->PushNULL(); - } - delete [] MethodName; - break; - } - /* - CScValue* val = var->GetProp(MethodName); - if(val){ - dw = GetFuncPos(val->GetString()); - if(dw==0){ - TExternalFunction* f = GetExternal(val->GetString()); - if(f){ - ExternalCall(_stack, _thisStack, f); - } - else{ - // not an internal nor external, try for native function - Game->ExternalCall(this, _stack, _thisStack, val->GetString()); - } - } - else{ - _operand->SetInt(_iP); - _callStack->Push(_operand); - _iP = dw; - } - } - */ - else { - res = E_FAIL; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); - - if (FAILED(res)) { - _stack->CorrectParams(0); - RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->PushNULL(); - } - } - } - delete [] MethodName; - } - break; - - case II_EXTERNAL_CALL: { - uint32 SymbolIndex = GetDWORD(); - - TExternalFunction *f = GetExternal(_symbols[SymbolIndex]); - if (f) { - ExternalCall(_stack, _thisStack, f); - } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); - - break; - } - case II_SCOPE: - _operand->SetNULL(); - _scopeStack->Push(_operand); - - if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); - - break; - - case II_CORRECT_STACK: - dw = GetDWORD(); // params expected - _stack->CorrectParams(dw); - break; - - case II_CREATE_OBJECT: - _operand->SetObject(); - _stack->Push(_operand); - break; - - case II_POP_EMPTY: - _stack->Pop(); - break; - - case II_PUSH_VAR: { - CScValue *var = GetVar(_symbols[GetDWORD()]); - if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->SetReference(var); - _stack->Push(_operand); - } else _stack->Push(var); - break; - } - - case II_PUSH_VAR_REF: { - CScValue *var = GetVar(_symbols[GetDWORD()]); - _operand->SetReference(var); - _stack->Push(_operand); - break; - } - - case II_POP_VAR: { - char *VarName = _symbols[GetDWORD()]; - CScValue *var = GetVar(VarName); - if (var) { - CScValue *val = _stack->Pop(); - if (!val) { - RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->SetNULL(); - } else { - if (val->GetType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->SetValue(val); - else { - var->Copy(val); - } - } - - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableChangeValue(var, val); - } - - break; - } - - case II_PUSH_VAR_THIS: - _stack->Push(_thisStack->GetTop()); - break; - - case II_PUSH_INT: - _stack->PushInt((int)GetDWORD()); - break; - - case II_PUSH_FLOAT: - _stack->PushFloat(GetFloat()); - break; - - - case II_PUSH_BOOL: - _stack->PushBool(GetDWORD() != 0); - - break; - - case II_PUSH_STRING: - _stack->PushString(GetString()); - break; - - case II_PUSH_NULL: - _stack->PushNULL(); - break; - - case II_PUSH_THIS_FROM_STACK: - _operand->SetReference(_stack->GetTop()); - _thisStack->Push(_operand); - break; - - case II_PUSH_THIS: - _operand->SetReference(GetVar(_symbols[GetDWORD()])); - _thisStack->Push(_operand); - break; - - case II_POP_THIS: - _thisStack->Pop(); - break; - - case II_PUSH_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *val = _stack->Pop()->GetProp(str); - if (val) _stack->Push(val); - else _stack->PushNULL(); - - break; - } - - case II_POP_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *var = _stack->Pop(); - CScValue *val = _stack->Pop(); - - if (val == NULL) { - RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->SetNULL(); - } else var->SetProp(str, val); - - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); - - break; - } - - case II_PUSH_REG1: - _stack->Push(_reg1); - break; - - case II_POP_REG1: - _reg1->Copy(_stack->Pop()); - break; - - case II_JMP: - _iP = GetDWORD(); - break; - - case II_JMP_FALSE: { - dw = GetDWORD(); - //if(!_stack->Pop()->GetBool()) _iP = dw; - CScValue *Val = _stack->Pop(); - if (!Val) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - } else { - if (!Val->GetBool()) _iP = dw; - } - break; - } - - case II_ADD: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; - strcpy(tempStr, op1->GetString()); - strcat(tempStr, op2->GetString()); - _operand->SetString(str); - delete [] tempStr; - } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() + op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); - - _stack->Push(_operand); - - break; - - case II_SUB: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() - op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); - - _stack->Push(_operand); - - break; - - case II_MUL: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() * op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); - - _stack->Push(_operand); - - break; - - case II_DIV: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); - - if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); - else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); - - _stack->Push(_operand); - - break; - - case II_MODULO: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - if (op2->GetInt() == 0) RuntimeError("Division by zero."); - - if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); - else _operand->SetInt(op1->GetInt() % op2->GetInt()); - - _stack->Push(_operand); - - break; - - case II_NOT: - op1 = _stack->Pop(); - //if(op1->IsNULL()) _operand->SetNULL(); - if (op1->IsNULL()) _operand->SetBool(true); - else _operand->SetBool(!op1->GetBool()); - _stack->Push(_operand); - - break; - - case II_AND: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - if (op1 == NULL || op2 == NULL) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->SetBool(false); - } else { - _operand->SetBool(op1->GetBool() && op2->GetBool()); - } - _stack->Push(_operand); - break; - - case II_OR: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - if (op1 == NULL || op2 == NULL) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->SetBool(false); - } else { - _operand->SetBool(op1->GetBool() || op2->GetBool()); - } - _stack->Push(_operand); - break; - - case II_CMP_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); - else if(op1->IsNative() && op2->IsNative()){ - _operand->SetBool(op1->GetNative() == op2->GetNative()); - } - else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); - } - else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() == op2->GetFloat()); - } - else{ - _operand->SetBool(op1->GetInt() == op2->GetInt()); - } - */ - - _operand->SetBool(CScValue::Compare(op1, op2) == 0); - _stack->Push(_operand); - break; - - case II_CMP_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); - else if(op1->IsNative() && op2->IsNative()){ - _operand->SetBool(op1->GetNative() != op2->GetNative()); - } - else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); - } - else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() != op2->GetFloat()); - } - else{ - _operand->SetBool(op1->GetInt() != op2->GetInt()); - } - */ - - _operand->SetBool(CScValue::Compare(op1, op2) != 0); - _stack->Push(_operand); - break; - - case II_CMP_L: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() < op2->GetFloat()); - } - else _operand->SetBool(op1->GetInt() < op2->GetInt()); - */ - - _operand->SetBool(CScValue::Compare(op1, op2) < 0); - _stack->Push(_operand); - break; - - case II_CMP_G: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() > op2->GetFloat()); - } - else _operand->SetBool(op1->GetInt() > op2->GetInt()); - */ - - _operand->SetBool(CScValue::Compare(op1, op2) > 0); - _stack->Push(_operand); - break; - - case II_CMP_LE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() <= op2->GetFloat()); - } - else _operand->SetBool(op1->GetInt() <= op2->GetInt()); - */ - - _operand->SetBool(CScValue::Compare(op1, op2) <= 0); - _stack->Push(_operand); - break; - - case II_CMP_GE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() >= op2->GetFloat()); - } - else _operand->SetBool(op1->GetInt() >= op2->GetInt()); - */ - - _operand->SetBool(CScValue::Compare(op1, op2) >= 0); - _stack->Push(_operand); - break; - - case II_CMP_STRICT_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); - _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); - _stack->Push(_operand); - - break; - - case II_CMP_STRICT_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); - - //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); - _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); - _stack->Push(_operand); - break; - - case II_DBG_LINE: { - int NewLine = GetDWORD(); - if (NewLine != _currentLine) { - _currentLine = NewLine; - if (Game->GetDebugMgr()->_enabled) { - Game->GetDebugMgr()->OnScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (_breakpoints[i] == _currentLine) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(this); - Sleep(0); - break; - } - } - if (_tracingMode) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(this); - Sleep(0); - break; - } - } - } - break; - - } - default: - Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); - _state = SCRIPT_FINISHED; - ret = E_FAIL; - } // switch(instruction) - - //delete op; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetFuncPos(const char *Name) { - for (int i = 0; i < _numFunctions; i++) { - if (strcmp(Name, _functions[i].name) == 0) return _functions[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetMethodPos(const char *Name) { - for (int i = 0; i < _numMethods; i++) { - if (strcmp(Name, _methods[i].name) == 0) return _methods[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::GetVar(char *Name) { - CScValue *ret = NULL; - - // scope locals - if (_scopeStack->_sP >= 0) { - if (_scopeStack->GetTop()->PropExists(Name)) ret = _scopeStack->GetTop()->GetProp(Name); - } - - // script globals - if (ret == NULL) { - if (_globals->PropExists(Name)) ret = _globals->GetProp(Name); - } - - // engine globals - if (ret == NULL) { - if (_engine->_globals->PropExists(Name)) ret = _engine->_globals->GetProp(Name); - } - - if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", Name); - Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, _filename, _currentLine); - CScValue *Val = new CScValue(Game); - CScValue *Scope = _scopeStack->GetTop(); - if (Scope) { - Scope->SetProp(Name, Val); - ret = _scopeStack->GetTop()->GetProp(Name); - } else { - _globals->SetProp(Name, Val); - ret = _globals->GetProp(Name); - } - delete Val; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::WaitFor(CBObject *Object) { - if (_unbreakable) { - RuntimeError("Script cannot be interrupted."); - return S_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = Object; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::WaitForExclusive(CBObject *Object) { - _engine->ResetObject(Object); - return WaitFor(Object); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Sleep(uint32 Duration) { - if (_unbreakable) { - RuntimeError("Script cannot be interrupted."); - return S_OK; - } - - _state = SCRIPT_SLEEPING; - if (Game->_state == GAME_FROZEN) { - _waitTime = CBPlatform::GetTime() + Duration; - _waitFrozen = true; - } else { - _waitTime = Game->_timer + Duration; - _waitFrozen = false; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Finish(bool IncludingThreads) { - if (_state != SCRIPT_FINISHED && IncludingThreads) { - _state = SCRIPT_FINISHED; - FinishThreads(); - } else _state = SCRIPT_FINISHED; - - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Run() { - _state = SCRIPT_RUNNING; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CScScript::RuntimeError(LPCSTR fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - Game->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - Game->LOG(0, " %s", buff); - - if (!Game->_suppressScriptErrors) - Game->QuickMessage("Script runtime error. View log for details."); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - // buffer - if (PersistMgr->_saving) { - if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - PersistMgr->Transfer(TMEMBER(_bufferSize)); - PersistMgr->PutBytes(_buffer, _bufferSize); - } else { - // don't save idle/finished scripts - int bufferSize = 0; - PersistMgr->Transfer(TMEMBER(bufferSize)); - } - } else { - PersistMgr->Transfer(TMEMBER(_bufferSize)); - if (_bufferSize > 0) { - _buffer = new byte[_bufferSize]; - PersistMgr->GetBytes(_buffer, _bufferSize); - InitTables(); - } else _buffer = NULL; - } - - PersistMgr->Transfer(TMEMBER(_callStack)); - PersistMgr->Transfer(TMEMBER(_currentLine)); - PersistMgr->Transfer(TMEMBER(_engine)); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_freezable)); - PersistMgr->Transfer(TMEMBER(_globals)); - PersistMgr->Transfer(TMEMBER(_iP)); - PersistMgr->Transfer(TMEMBER(_scopeStack)); - PersistMgr->Transfer(TMEMBER(_stack)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_operand)); - PersistMgr->Transfer(TMEMBER_INT(_origState)); - PersistMgr->Transfer(TMEMBER(_owner)); - PersistMgr->Transfer(TMEMBER(_reg1)); - PersistMgr->Transfer(TMEMBER(_thread)); - PersistMgr->Transfer(TMEMBER(_threadEvent)); - PersistMgr->Transfer(TMEMBER(_thisStack)); - PersistMgr->Transfer(TMEMBER(_timeSlice)); - PersistMgr->Transfer(TMEMBER(_waitObject)); - PersistMgr->Transfer(TMEMBER(_waitScript)); - PersistMgr->Transfer(TMEMBER(_waitTime)); - PersistMgr->Transfer(TMEMBER(_waitFrozen)); - - PersistMgr->Transfer(TMEMBER(_methodThread)); - PersistMgr->Transfer(TMEMBER(_methodThread)); - PersistMgr->Transfer(TMEMBER(_unbreakable)); - PersistMgr->Transfer(TMEMBER(_parentScript)); - - if (!PersistMgr->_saving) _tracingMode = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = GetEventPos(EventName); - if (!pos) return NULL; - - CScScript *thread = new CScScript(Game, _engine); - if (thread) { - HRESULT ret = thread->CreateThread(this, pos, EventName); - if (SUCCEEDED(ret)) { - thread->_unbreakable = Unbreakable; - _engine->_scripts.Add(thread); - Game->GetDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); - return thread; - } else { - delete thread; - return NULL; - } - } else return NULL; - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetEventPos(const char *Name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(Name, _events[i].name) == 0) return _events[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleEvent(const char *EventName) { - return GetEventPos(EventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleMethod(const char *MethodName) { - return GetMethodPos(MethodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Pause() { - if (_state == SCRIPT_PAUSED) { - Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return E_FAIL; - } - - if (!_freezable || _state == SCRIPT_PERSISTENT) return S_OK; - - _origState = _state; - _state = SCRIPT_PAUSED; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Resume() { - if (_state != SCRIPT_PAUSED) return S_OK; - - _state = _origState; - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::GetExternal(char *Name) { - for (int i = 0; i < _numExternals; i++) { - if (strcmp(Name, _externals[i].name) == 0) return &_externals[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function) { - -#ifndef __WIN32__ - - Game->LOG(0, "External functions are not supported on this platform."); - Stack->CorrectParams(0); - Stack->PushNULL(); - return E_FAIL; - -#else - - bool Success = false; - HMODULE hDll = LoadLibrary(Function->dll_name); - - if (hDll) { - FARPROC pFunc = GetProcAddress(hDll, Function->name); - if (pFunc) { - int i; - Success = true; - Stack->CorrectParams(Function->nu_params); - CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); - - for (i = 0; i < Function->nu_params; i++) { - CScValue *Val = Stack->Pop(); - switch (Function->params[i]) { - case TYPE_BOOL: - Buffer->PutDWORD((uint32)Val->GetBool()); - break; - case TYPE_LONG: - Buffer->PutDWORD(Val->GetInt()); - break; - case TYPE_BYTE: - Buffer->PutDWORD((byte)Val->GetInt()); - break; - case TYPE_STRING: - if (Val->IsNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->GetString()); - break; - case TYPE_MEMBUFFER: - if (Val->IsNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->GetMemBuffer()); - break; - case TYPE_FLOAT: { - float f = Val->GetFloat(); - Buffer->PutDWORD(*((uint32 *)&f)); - break; - } - case TYPE_DOUBLE: { - double d = Val->GetFloat(); - uint32 *pd = (uint32 *)&d; - - Buffer->PutDWORD(pd[0]); - Buffer->PutDWORD(pd[1]); - break; - } - } - } - - // call - uint32 ret; - bool StackCorrupted = false; - switch (Function->call_type) { - case CALL_CDECL: - ret = Call_cdecl(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); - break; - default: - ret = Call_stdcall(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); - } - delete Buffer; - - // return - switch (Function->returns) { - case TYPE_BOOL: - Stack->PushBool((byte)ret != 0); - break; - case TYPE_LONG: - Stack->PushInt(ret); - break; - case TYPE_BYTE: - Stack->PushInt((byte)ret); - break; - break; - case TYPE_STRING: - Stack->PushString((char *)ret); - break; - case TYPE_MEMBUFFER: { - CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); - Stack->PushNative(Buf, false); - } - break; - case TYPE_FLOAT: { - uint32 dw = GetST0(); - Stack->PushFloat(*((float *)&dw)); - break; - } - case TYPE_DOUBLE: - Stack->PushFloat(GetST0Double()); - break; - - default: - Stack->PushNULL(); - } - - if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); - } else RuntimeError("Exported function '%s' not found in '%s'", Function->name, Function->dll_name); - } else RuntimeError("Error loading DLL '%s'", Function->dll_name); - - if (!Success) { - Stack->CorrectParams(0); - Stack->PushNULL(); - } - - if (hDll) FreeLibrary(hDll); - - return Success ? S_OK : E_FAIL; -#endif -} - -#ifdef __WIN32__ -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { - uint32 rc; // here's our return value... - uint32 OrigESP; - bool StkCorrupt = false; - __asm { - mov OrigESP, esp - mov ecx, sz // get size of buffer - mov esi, args // get buffer - sub esp, ecx // allocate stack space - mov edi, esp // start of destination stack frame - shr ecx, 2 // make it dwords - rep movsd // copy params to real stack - call [func] // call the function - mov rc, eax // save the return value - add esp, sz // restore the stack pointer - cmp esp, OrigESP - jz finish - mov esp, OrigESP - mov StkCorrupt, 1 - finish: - } - - if (StackCorrupt) *StackCorrupt = StkCorrupt; - return rc; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { - uint32 rc; // here's our return value... - uint32 OrigESP; - bool StkCorrupt = false; - - __asm { - mov OrigESP, esp - mov ecx, sz // get size of buffer - mov esi, args // get buffer - sub esp, ecx // allocate stack space - mov edi, esp // start of destination stack frame - shr ecx, 2 // make it dwords - rep movsd // copy it - call [func] // call the function - mov rc, eax // save the return value - cmp esp, OrigESP - jz finish - mov esp, OrigESP - mov StkCorrupt, 1 - finish: - } - - if (StackCorrupt) *StackCorrupt = StkCorrupt; - return rc; -} - - -////////////////////////////////////////////////////////////////////////// -__declspec(naked) uint32 CScScript::GetST0(void) { - uint32 f; // temp var - __asm { - fstp uint32 ptr [f] // pop ST0 into f - mov eax, uint32 ptr [f] // copy into eax - ret // done - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScScript::GetST0Double(void) { - double d; // temp var - __asm { - fstp qword ptr [d] // get ST0 into d - } - return d; -} -#endif - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CopyParameters(CScStack *Stack) { - int i; - int NumParams = Stack->Pop()->GetInt(); - for (i = NumParams - 1; i >= 0; i--) { - _stack->Push(Stack->GetAt(i)); - } - _stack->PushInt(NumParams); - - for (i = 0; i < NumParams; i++) Stack->Pop(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::FinishThreads() { - for (int i = 0; i < _engine->_scripts.GetSize(); i++) { - CScScript *Scr = _engine->_scripts[i]; - if (Scr->_thread && Scr->_state != SCRIPT_FINISHED && Scr->_owner == _owner && scumm_stricmp(Scr->_filename, _filename) == 0) - Scr->Finish(true); - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int CScScript::DbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *CScScript::DbgGetFilename() { - return _filename; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { - if (_methodThread) Client->OnScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) Client->OnScriptEventThreadInit(this, _parentScript, _threadEvent); - else Client->OnScriptInit(this); - - return DbgSendVariables(Client); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { - // send script globals - _globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::DbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::DbgGetNumBreakpoints() { - return _breakpoints.GetSize(); -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::DbgGetBreakpoint(int Index) { - if (Index >= 0 && Index < _breakpoints.GetSize()) return _breakpoints[Index]; - else return -1; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::DbgSetTracingMode(bool IsTracing) { - _tracingMode = IsTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::DbgGetTracingMode() { - return _tracingMode; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::AfterLoad() { - if (_buffer == NULL) { - byte *buffer = _engine->GetCompiledScript(_filename, &_bufferSize); - if (!buffer) { - Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); - _state = SCRIPT_ERROR; - return; - } - - _buffer = new byte [_bufferSize]; - memcpy(_buffer, buffer, _bufferSize); - - InitTables(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScScript.h b/engines/wintermute/scriptables/ScScript.h deleted file mode 100644 index ce9548fc99..0000000000 --- a/engines/wintermute/scriptables/ScScript.h +++ /dev/null @@ -1,185 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/BBase.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -#include "engines/wintermute/wme_debugger.h" - -namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { -public: - HRESULT DbgSendScript(IWmeDebugClient *Client); - HRESULT DbgSendVariables(IWmeDebugClient *Client); - - CBArray _breakpoints; - bool _tracingMode; - - CScScript *_parentScript; - bool _unbreakable; - HRESULT FinishThreads(); - HRESULT CopyParameters(CScStack *Stack); - - void AfterLoad(); - -#ifdef __WIN32__ - static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt); - static uint32 Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt); - static uint32 GetST0(void); - static double GetST0Double(void); -#endif - - CScValue *_operand; - CScValue *_reg1; - bool _freezable; - HRESULT Resume(); - HRESULT Pause(); - bool CanHandleEvent(const char *EventName); - bool CanHandleMethod(const char *MethodName); - HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); - HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); - CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); - uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) - void RuntimeError(LPCSTR fmt, ...); - HRESULT Run(); - HRESULT Finish(bool IncludingThreads = false); - HRESULT Sleep(uint32 Duration); - HRESULT WaitForExclusive(CBObject *Object); - HRESULT WaitFor(CBObject *Object); - uint32 _waitTime; - bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - CScValue *GetVar(char *Name); - uint32 GetFuncPos(const char *Name); - uint32 GetEventPos(const char *Name); - uint32 GetMethodPos(const char *Name); - typedef struct { - uint32 magic; - uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; - } TScriptHeader; - - - typedef struct { - char *name; - uint32 pos; - } TFunctionPos; - - typedef struct { - char *name; - uint32 pos; - } TMethodPos; - - typedef struct { - char *name; - uint32 pos; - } TEventPos; - - typedef struct { - char *name; - char *dll_name; - TCallType call_type; - TExternalType returns; - int nu_params; - TExternalType *params; - } TExternalFunction; - - - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; - int _currentLine; - HRESULT ExecuteInstruction(); - char *GetString(); - uint32 GetDWORD(); - double GetFloat(); - void Cleanup(); - HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); - uint32 _iP; - uint32 _bufferSize; - byte *_buffer; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); - char *_filename; - char **_symbols; - int _numSymbols; - TFunctionPos *_functions; - TMethodPos *_methods; - TEventPos *_events; - int _numExternals; - TExternalFunction *_externals; - int _numFunctions; - int _numMethods; - int _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *GetExternal(char *Name); - HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); -private: - HRESULT InitScript(); - HRESULT InitTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int DbgGetLine(); - virtual const char *DbgGetFilename(); - virtual TScriptState DbgGetState(); - virtual int DbgGetNumBreakpoints(); - virtual int DbgGetBreakpoint(int Index); - - virtual bool DbgSetTracingMode(bool IsTracing); - virtual bool DbgGetTracingMode(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/ScStack.cpp b/engines/wintermute/scriptables/ScStack.cpp deleted file mode 100644 index 0d097c69c7..0000000000 --- a/engines/wintermute/scriptables/ScStack.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/scriptables/ScStack.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScStack, false) - -////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { - -#if _DEBUG - //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.GetSize(), _sP); -#endif - - for (int i = 0; i < _values.GetSize(); i++) { - delete _values[i]; - } - _values.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::Pop() { - if (_sP < 0) { - Game->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::Push(CScValue *Val) { - _sP++; - - if (_sP < _values.GetSize()) { - _values[_sP]->Cleanup(); - _values[_sP]->Copy(Val); - } else { - CScValue *val = new CScValue(Game); - val->Copy(Val); - _values.Add(val); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetPushValue() { - _sP++; - - if (_sP >= _values.GetSize()) { - CScValue *val = new CScValue(Game); - _values.Add(val); - } - _values[_sP]->Cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetTop() { - if (_sP < 0 || _sP >= _values.GetSize()) return NULL; - else return _values[_sP]; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetAt(int Index) { - Index = _sP - Index; - if (Index < 0 || Index >= _values.GetSize()) return NULL; - else return _values[Index]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::CorrectParams(uint32 expected_params) { - int nu_params = Pop()->GetInt(); - - if (expected_params < nu_params) { // too many params - while (expected_params < nu_params) { - //Pop(); - delete _values[_sP - expected_params]; - _values.RemoveAt(_sP - expected_params); - nu_params--; - _sP--; - } - } else if (expected_params > nu_params) { // need more params - while (expected_params > nu_params) { - //Push(null_val); - CScValue *null_val = new CScValue(Game); - null_val->SetNULL(); - _values.InsertAt(_sP - nu_params + 1, null_val); - nu_params++; - _sP++; - - if (_values.GetSize() > _sP + 1) { - delete _values[_values.GetSize() - 1]; - _values.RemoveAt(_values.GetSize() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushNULL() { - /* - CScValue* val = new CScValue(Game); - val->SetNULL(); - Push(val); - delete val; - */ - GetPushValue()->SetNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushInt(int Val) { - /* - CScValue* val = new CScValue(Game); - val->SetInt(Val); - Push(val); - delete val; - */ - GetPushValue()->SetInt(Val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushFloat(double Val) { - /* - CScValue* val = new CScValue(Game); - val->SetFloat(Val); - Push(val); - delete val; - */ - GetPushValue()->SetFloat(Val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushBool(bool Val) { - /* - CScValue* val = new CScValue(Game); - val->SetBool(Val); - Push(val); - delete val; - */ - GetPushValue()->SetBool(Val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushString(const char *Val) { - /* - CScValue* val = new CScValue(Game); - val->SetString(Val); - Push(val); - delete val; - */ - GetPushValue()->SetString(Val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::PushNative(CBScriptable *Val, bool Persistent) { - /* - CScValue* val = new CScValue(Game); - val->SetNative(Val, Persistent); - Push(val); - delete val; - */ - - GetPushValue()->SetNative(Val, Persistent); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScStack::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_sP)); - _values.Persist(PersistMgr); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScStack.h b/engines/wintermute/scriptables/ScStack.h deleted file mode 100644 index 811492c6ca..0000000000 --- a/engines/wintermute/scriptables/ScStack.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSTACK_H -#define WINTERMUTE_SCSTACK_H - - -#include "engines/wintermute/BBase.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CBScriptable; - -class CScStack : public CBBase { -public: - CScValue *GetAt(int Index); - CScValue *GetPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void PushNative(CBScriptable *Val, bool Persistent); - void PushString(const char *Val); - void PushBool(bool Val); - void PushInt(int Val); - void PushFloat(double Val); - void PushNULL(); - void CorrectParams(uint32 expected_params); - CScValue *GetTop(); - void Push(CScValue *Val); - CScValue *Pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; - int _sP; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/ScValue.cpp b/engines/wintermute/scriptables/ScValue.cpp deleted file mode 100644 index 8075df0e71..0000000000 --- a/engines/wintermute/scriptables/ScValue.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/BDynBuffer.h" -#include "engines/wintermute/BGame.h" -#include "engines/wintermute/scriptables/ScValue.h" -#include "engines/wintermute/scriptables/ScScript.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/BScriptable.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CScValue, false) - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { - _type = VAL_BOOL; - _valBool = Val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { - _type = VAL_INT; - _valInt = Val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { - _type = VAL_FLOAT; - _valFloat = Val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { - _type = VAL_STRING; - _valString = NULL; - SetStringVal(Val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::Cleanup(bool IgnoreNatives) { - DeleteProps(); - - if (_valString) delete [] _valString; - - if (!IgnoreNatives) { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - _valNative = NULL; - } - } - } - - - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::GetProp(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(Name); - - if (_type == VAL_STRING && strcmp(Name, "Length") == 0) { - Game->_scValue->_type = VAL_INT; - -#if 0 // TODO: Remove FreeType-dependency - if (Game->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif - Game->_scValue->SetInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::Utf8ToWide(_valString); - Game->_scValue->SetInt(wstr.size()); - } - - return Game->_scValue; - } - - CScValue *ret = NULL; - - if (_type == VAL_NATIVE && _valNative) ret = _valNative->ScGetProperty(Name); - - if (ret == NULL) { - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()) ret = _valIter->_value; - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DeleteProp(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(Name); - - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()) { - delete _valIter->_value; - _valIter->_value = NULL; - } - - return S_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { - if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(Name, Val); - - HRESULT ret = E_FAIL; - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->ScSetProperty(Name, Val); - } - - if (FAILED(ret)) { - CScValue *val = NULL; - - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()) { - val = _valIter->_value; - } - if (!val) val = new CScValue(Game); - else val->Cleanup(); - - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if (_type != VAL_NATIVE) _type = VAL_OBJECT; - - /* - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()){ - delete _valIter->_value; - _valIter->_value = NULL; - } - CScValue* val = new CScValue(Game); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::PropExists(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(Name); - _valIter = _valObject.find(Name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::DeleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool IncludingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->IsNative() || IncludingNatives)) _valIter->_value->SetNULL(); - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsNULL() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsNULL(); - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsNative(); - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsString() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsString(); - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsFloat() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsFloat(); - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsInt() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsInt(); - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsBool() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsBool(); - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::IsObject() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsObject(); - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::GetTypeTolerant() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetType(); - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetBool(bool Val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetBool(Val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->ScSetBool(Val); - return; - } - - _valBool = Val; - _type = VAL_BOOL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetInt(int Val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetInt(Val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->ScSetInt(Val); - return; - } - - _valInt = Val; - _type = VAL_INT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetFloat(double Val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetFloat(Val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->ScSetFloat(Val); - return; - } - - _valFloat = Val; - _type = VAL_FLOAT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetString(const char *Val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetString(Val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->ScSetString(Val); - return; - } - - SetStringVal(Val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetStringVal(const char *Val) { - if (_valString) { - delete [] _valString; - _valString = NULL; - } - - if (Val == NULL) { - _valString = NULL; - return; - } - - _valString = new char [strlen(Val) + 1]; - if (_valString) { - strcpy(_valString, Val); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetNULL() { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetNULL(); - return; - } - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; - } - _valNative = NULL; - DeleteProps(); - - _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetNative(CBScriptable *Val, bool Persistent) { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetNative(Val, Persistent); - return; - } - - if (Val == NULL) { - SetNULL(); - } else { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != Val) delete _valNative; - _valNative = NULL; - } - } - - _type = VAL_NATIVE; - _persistent = Persistent; - - _valNative = Val; - if (_valNative && !_persistent) _valNative->_refCount++; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->SetObject(); - return; - } - - DeleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetReference(CScValue *Val) { - _valRef = Val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::GetBool(bool Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetBool(); - - switch (_type) { - case VAL_BOOL: - return _valBool; - - case VAL_NATIVE: - return _valNative->ScToBool(); - - case VAL_INT: - return (_valInt != 0); - - case VAL_FLOAT: - return (_valFloat != 0.0f); - - case VAL_STRING: - return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); - - default: - return Default; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::GetInt(int Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetInt(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1 : 0; - - case VAL_NATIVE: - return _valNative->ScToInt(); - - case VAL_INT: - return _valInt; - - case VAL_FLOAT: - return (int)_valFloat; - - case VAL_STRING: - return atoi(_valString); - - default: - return Default; - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScValue::GetFloat(double Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetFloat(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1.0f : 0.0f; - - case VAL_NATIVE: - return _valNative->ScToFloat(); - - case VAL_INT: - return (double)_valInt; - - case VAL_FLOAT: - return _valFloat; - - case VAL_STRING: - return atof(_valString); - - default: - return Default; - } -} - -////////////////////////////////////////////////////////////////////////// -void *CScValue::GetMemBuffer() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetMemBuffer(); - - if (_type == VAL_NATIVE) return _valNative->ScToMemBuffer(); - else return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::GetString() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetString(); - - switch (_type) { - case VAL_OBJECT: - SetStringVal("[object]"); - break; - - case VAL_NULL: - SetStringVal("[null]"); - break; - - case VAL_NATIVE: { - const char *StrVal = _valNative->ScToString(); - SetStringVal(StrVal); - return StrVal; - break; - } - - case VAL_BOOL: - SetStringVal(_valBool ? "yes" : "no"); - break; - - case VAL_INT: { - char dummy[50]; - sprintf(dummy, "%d", _valInt); - SetStringVal(dummy); - break; - } - - case VAL_FLOAT: { - char dummy[50]; - sprintf(dummy, "%f", _valFloat); - SetStringVal(dummy); - break; - } - - case VAL_STRING: - break; - - default: - SetStringVal(""); - } - - return _valString; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::GetNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetNative(); - - if (_type == VAL_NATIVE) return _valNative; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::GetType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::Copy(CScValue *orig, bool CopyWhole) { - Game = orig->Game; - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; - _valNative = NULL; - } - } - - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && CopyWhole) orig = orig->_valRef; - - Cleanup(true); - - _type = orig->_type; - _valBool = orig->_valBool; - _valInt = orig->_valInt; - _valFloat = orig->_valFloat; - SetStringVal(orig->_valString); - - _valRef = orig->_valRef; - _persistent = orig->_persistent; - - _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; -//!!!! ref->native++ - - // copy properties - if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { - orig->_valIter = orig->_valObject.begin(); - while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(Game); - _valObject[orig->_valIter->_key]->Copy(orig->_valIter->_value); - orig->_valIter++; - } - } else _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::SetValue(CScValue *Val) { - if (Val->_type == VAL_VARIABLE_REF) { - SetValue(Val->_valRef); - return; - } - - // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (Val->_type == VAL_INT || Val->_type == VAL_STRING || Val->_type == VAL_BOOL)) { - switch (Val->_type) { - case VAL_INT: - _valNative->ScSetInt(Val->GetInt()); - break; - case VAL_FLOAT: - _valNative->ScSetFloat(Val->GetFloat()); - break; - case VAL_BOOL: - _valNative->ScSetBool(Val->GetBool()); - break; - case VAL_STRING: - _valNative->ScSetString(Val->GetString()); - break; - } - } - // otherwise just copy everything - else Copy(Val); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_persistent)); - PersistMgr->Transfer(TMEMBER(_isConstVar)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_valBool)); - PersistMgr->Transfer(TMEMBER(_valFloat)); - PersistMgr->Transfer(TMEMBER(_valInt)); - PersistMgr->Transfer(TMEMBER(_valNative)); - - int size; - const char *str; - if (PersistMgr->_saving) { - size = _valObject.size(); - PersistMgr->Transfer("", &size); - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - str = _valIter->_key.c_str(); - PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &_valIter->_value); - - _valIter++; - } - } else { - CScValue *val; - PersistMgr->Transfer("", &size); - for (int i = 0; i < size; i++) { - PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &val); - - _valObject[str] = val; - delete [] str; - } - } - - PersistMgr->Transfer(TMEMBER(_valRef)); - PersistMgr->Transfer(TMEMBER(_valString)); - - /* - FILE* f = fopen("c:\\val.log", "a+"); - switch(_type) - { - case VAL_STRING: - fprintf(f, "str %s\n", _valString); - break; - - case VAL_INT: - fprintf(f, "int %d\n", _valInt); - break; - - case VAL_BOOL: - fprintf(f, "bool %d\n", _valBool); - break; - - case VAL_NULL: - fprintf(f, "null\n"); - break; - - case VAL_NATIVE: - fprintf(f, "native\n"); - break; - - case VAL_VARIABLE_REF: - fprintf(f, "ref\n"); - break; - - case VAL_OBJECT: - fprintf(f, "obj\n"); - break; - - case VAL_FLOAT: - fprintf(f, "float\n"); - break; - - } - fclose(f); - */ - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - Buffer->PutTextIndent(Indent, "PROPERTY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); - Buffer->PutTextIndent(Indent, "}\n\n"); - - _valIter++; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::Compare(CScValue *Val1, CScValue *Val2) { - // both natives? - if (Val1->IsNative() && Val2->IsNative()) { - // same class? - if (strcmp(Val1->GetNative()->GetClassName(), Val2->GetNative()->GetClassName()) == 0) { - return Val1->GetNative()->ScCompare(Val2->GetNative()); - } else return strcmp(Val1->GetString(), Val2->GetString()); - } - - // both objects? - if (Val1->IsObject() && Val2->IsObject()) return -1; - - - // null states - if (Val1->IsNULL() && !Val2->IsNULL()) return -1; - else if (!Val1->IsNULL() && Val2->IsNULL()) return 1; - else if (Val1->IsNULL() && Val2->IsNULL()) return 0; - - // one of them is string? convert both to string - if (Val1->IsString() || Val2->IsString()) return strcmp(Val1->GetString(), Val2->GetString()); - - // one of them is float? - if (Val1->IsFloat() || Val2->IsFloat()) { - if (Val1->GetFloat() < Val2->GetFloat()) return -1; - else if (Val1->GetFloat() > Val2->GetFloat()) return 1; - else return 0; - } - - // otherwise compare as int's - if (Val1->GetInt() < Val2->GetInt()) return -1; - else if (Val1->GetInt() > Val2->GetInt()) return 1; - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { - if (Val1->GetTypeTolerant() != Val2->GetTypeTolerant()) return -1; - else return CScValue::Compare(Val1, Val2); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - Client->OnVariableInit(Type, Script, ScopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, int Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); - delete Val; - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, const char *Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); - delete Val; - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, double Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); - delete Val; - return Ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, bool Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); - delete Val; - return Ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName) { - CScValue *Val = new CScValue(Game); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); - delete Val; - return Ret; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::DbgGetType() { - switch (GetType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int CScValue::DbgGetValInt() { - return GetInt(); -} - -////////////////////////////////////////////////////////////////////////// -double CScValue::DbgGetValFloat() { - return GetFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetValBool() { - return GetBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::DbgGetValString() { - return GetString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::DbgGetValNative() { - return GetNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(int Value) { - SetInt(Value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(double Value) { - SetFloat(Value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(bool Value) { - SetBool(Value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(const char *Value) { - SetString(Value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal() { - SetNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::DbgGetNumProperties() { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetNumProperties(); - else return _valObject.size(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(Index, Name, Value); - else { - int Count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (Count == Index) { - *Name = _valIter->_key.c_str(); - *Value = _valIter->_value; - return true; - } - _valIter++; - Count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetDescription(char *Buf, int BufSize) { - if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(Buf, BufSize); - - if (_type == VAL_NATIVE) { - _valNative->ScDebuggerDesc(Buf, BufSize); - } else { - strncpy(Buf, GetString(), BufSize); - } - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/ScValue.h b/engines/wintermute/scriptables/ScValue.h deleted file mode 100644 index 5d10e9ff12..0000000000 --- a/engines/wintermute/scriptables/ScValue.h +++ /dev/null @@ -1,142 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCVALUE_H -#define WINTERMUTE_SCVALUE_H - - -#include "engines/wintermute/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -//#include -//#include -#include "engines/wintermute/wme_debugger.h" -#include "common/str.h" - -namespace WinterMute { - -class CScScript; -class CBScriptable; - -class CScValue : public CBBase, public IWmeDebugProp { -public: - HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID); - - static int Compare(CScValue *Val1, CScValue *Val2); - static int CompareStrict(CScValue *Val1, CScValue *Val2); - TValType GetTypeTolerant(); - void Cleanup(bool IgnoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) - - bool _isConstVar; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - void SetValue(CScValue *Val); - bool _persistent; - bool PropExists(const char *Name); - void Copy(CScValue *orig, bool CopyWhole = false); - void SetStringVal(const char *Val); - TValType GetType(); - bool GetBool(bool Default = false); - int GetInt(int Default = 0); - double GetFloat(double Default = 0.0f); - const char *GetString(); - void *GetMemBuffer(); - CBScriptable *GetNative(); - HRESULT DeleteProp(const char *Name); - void DeleteProps(); - void CleanProps(bool IncludingNatives); - void SetBool(bool Val); - void SetInt(int Val); - void SetFloat(double Val); - void SetString(const char *Val); - void SetNULL(); - void SetNative(CBScriptable *Val, bool Persistent = false); - void SetObject(); - void SetReference(CScValue *Val); - bool IsNULL(); - bool IsNative(); - bool IsString(); - bool IsBool(); - bool IsFloat(); - bool IsInt(); - bool IsObject(); - HRESULT SetProp(const char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); - CScValue *GetProp(const char *Name); - CBScriptable *_valNative; - CScValue *_valRef; -protected: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; - - bool SetProperty(const char *PropName, int Value); - bool SetProperty(const char *PropName, const char *Value); - bool SetProperty(const char *PropName, double Value); - bool SetProperty(const char *PropName, bool Value); - bool SetProperty(const char *PropName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType DbgGetType(); - - // getters - virtual int DbgGetValInt(); - virtual double DbgGetValFloat(); - virtual bool DbgGetValBool(); - virtual const char *DbgGetValString(); - virtual IWmeDebugObject *DbgGetValNative(); - - // setters - virtual bool DbgSetVal(int Value); - virtual bool DbgSetVal(double Value); - virtual bool DbgSetVal(bool Value); - virtual bool DbgSetVal(const char *Value); - virtual bool DbgSetVal(); - - // properties - virtual int DbgGetNumProperties(); - virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); - - virtual bool DbgGetDescription(char *Buf, int BufSize); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/scriptables/SxObject.cpp b/engines/wintermute/scriptables/SxObject.cpp deleted file mode 100644 index 1af01c1045..0000000000 --- a/engines/wintermute/scriptables/SxObject.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SxObject.h" -#include "ScValue.h" -#include "ScStack.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CSXObject, false) - -////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { - int NumParams = Stack->Pop()->GetInt(0); - for (int i = 0; i < NumParams; i++) { - AddScript(Stack->Pop()->GetString()); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSXObject::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/scriptables/SxObject.h b/engines/wintermute/scriptables/SxObject.h deleted file mode 100644 index 40e9046b5a..0000000000 --- a/engines/wintermute/scriptables/SxObject.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/BObject.h" - -namespace WinterMute { - -class CSXObject : public CBObject { -public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp index 7f17af9395..d1ce280639 100644 --- a/engines/wintermute/utils.cpp +++ b/engines/wintermute/utils.cpp @@ -26,12 +26,12 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "dcgf.h" +#include "engines/wintermute/dcgf.h" #include "utils.h" -#include "PlatformSDL.h" -#include "wintypes.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintypes.h" #include "PathUtil.h" -#include "BGame.h" +#include "engines/wintermute/Base/BGame.h" #include "common/str.h" #include "common/textconsole.h" diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h index fa83a51ad4..46e895ff4d 100644 --- a/engines/wintermute/utils.h +++ b/engines/wintermute/utils.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_UTILS_H #define WINTERMUTE_UTILS_H -#include "wintypes.h" +#include "engines/wintermute/wintypes.h" namespace WinterMute { -- cgit v1.2.3 From 221490a93df13fb6b17589c48c536c73ef6576b5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 02:21:01 +0200 Subject: WINTERMUTE: Add subfolders for math, UI, tinyxml and Sys --- engines/wintermute/Ad/AdGame.cpp | 4 +- engines/wintermute/Ad/AdInventoryBox.cpp | 4 +- engines/wintermute/Ad/AdResponseBox.cpp | 4 +- engines/wintermute/Ad/AdScene.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Base/BRegistry.cpp | 2 +- engines/wintermute/Base/BRenderSDL.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 4 +- engines/wintermute/Base/PartForce.h | 2 +- engines/wintermute/Base/PartParticle.h | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 4 +- engines/wintermute/MathUtil.cpp | 48 - engines/wintermute/MathUtil.h | 42 - engines/wintermute/Matrix4.cpp | 86 -- engines/wintermute/Matrix4.h | 59 - engines/wintermute/Sys/SysClass.cpp | 217 +++ engines/wintermute/Sys/SysClass.h | 117 ++ engines/wintermute/Sys/SysClassRegistry.cpp | 288 ++++ engines/wintermute/Sys/SysClassRegistry.h | 107 ++ engines/wintermute/Sys/SysInstance.cpp | 49 + engines/wintermute/Sys/SysInstance.h | 68 + engines/wintermute/SysClass.cpp | 217 --- engines/wintermute/SysClass.h | 117 -- engines/wintermute/SysClassRegistry.cpp | 288 ---- engines/wintermute/SysClassRegistry.h | 107 -- engines/wintermute/SysInstance.cpp | 49 - engines/wintermute/SysInstance.h | 68 - engines/wintermute/UI/UIButton.cpp | 1043 +++++++++++++ engines/wintermute/UI/UIButton.h | 79 + engines/wintermute/UI/UIEdit.cpp | 860 +++++++++++ engines/wintermute/UI/UIEdit.h | 72 + engines/wintermute/UI/UIEntity.cpp | 339 ++++ engines/wintermute/UI/UIEntity.h | 58 + engines/wintermute/UI/UIObject.cpp | 589 +++++++ engines/wintermute/UI/UIObject.h | 83 + engines/wintermute/UI/UIText.cpp | 489 ++++++ engines/wintermute/UI/UIText.h | 59 + engines/wintermute/UI/UITiledImage.cpp | 370 +++++ engines/wintermute/UI/UITiledImage.h | 62 + engines/wintermute/UI/UIWindow.cpp | 1321 ++++++++++++++++ engines/wintermute/UI/UIWindow.h | 92 ++ engines/wintermute/UIButton.cpp | 1043 ------------- engines/wintermute/UIButton.h | 79 - engines/wintermute/UIEdit.cpp | 860 ----------- engines/wintermute/UIEdit.h | 72 - engines/wintermute/UIEntity.cpp | 339 ---- engines/wintermute/UIEntity.h | 58 - engines/wintermute/UIObject.cpp | 589 ------- engines/wintermute/UIObject.h | 83 - engines/wintermute/UIText.cpp | 489 ------ engines/wintermute/UIText.h | 59 - engines/wintermute/UITiledImage.cpp | 370 ----- engines/wintermute/UITiledImage.h | 62 - engines/wintermute/UIWindow.cpp | 1321 ---------------- engines/wintermute/UIWindow.h | 92 -- engines/wintermute/Vector2.cpp | 55 - engines/wintermute/Vector2.h | 75 - engines/wintermute/math/MathUtil.cpp | 48 + engines/wintermute/math/MathUtil.h | 42 + engines/wintermute/math/Matrix4.cpp | 86 ++ engines/wintermute/math/Matrix4.h | 59 + engines/wintermute/math/Vector2.cpp | 55 + engines/wintermute/math/Vector2.h | 75 + engines/wintermute/module.mk | 34 +- engines/wintermute/persistent.h | 4 +- engines/wintermute/tinystr.cpp | 111 -- engines/wintermute/tinystr.h | 305 ---- engines/wintermute/tinyxml.cpp | 1888 ----------------------- engines/wintermute/tinyxml.h | 1803 ---------------------- engines/wintermute/tinyxml/tinystr.cpp | 111 ++ engines/wintermute/tinyxml/tinystr.h | 305 ++++ engines/wintermute/tinyxml/tinyxml.cpp | 1888 +++++++++++++++++++++++ engines/wintermute/tinyxml/tinyxml.h | 1803 ++++++++++++++++++++++ engines/wintermute/tinyxml/tinyxmlerror.cpp | 53 + engines/wintermute/tinyxml/tinyxmlparser.cpp | 1638 ++++++++++++++++++++ engines/wintermute/tinyxmlerror.cpp | 53 - engines/wintermute/tinyxmlparser.cpp | 1638 -------------------- 80 files changed, 12563 insertions(+), 12563 deletions(-) delete mode 100644 engines/wintermute/MathUtil.cpp delete mode 100644 engines/wintermute/MathUtil.h delete mode 100644 engines/wintermute/Matrix4.cpp delete mode 100644 engines/wintermute/Matrix4.h create mode 100644 engines/wintermute/Sys/SysClass.cpp create mode 100644 engines/wintermute/Sys/SysClass.h create mode 100644 engines/wintermute/Sys/SysClassRegistry.cpp create mode 100644 engines/wintermute/Sys/SysClassRegistry.h create mode 100644 engines/wintermute/Sys/SysInstance.cpp create mode 100644 engines/wintermute/Sys/SysInstance.h delete mode 100644 engines/wintermute/SysClass.cpp delete mode 100644 engines/wintermute/SysClass.h delete mode 100644 engines/wintermute/SysClassRegistry.cpp delete mode 100644 engines/wintermute/SysClassRegistry.h delete mode 100644 engines/wintermute/SysInstance.cpp delete mode 100644 engines/wintermute/SysInstance.h create mode 100644 engines/wintermute/UI/UIButton.cpp create mode 100644 engines/wintermute/UI/UIButton.h create mode 100644 engines/wintermute/UI/UIEdit.cpp create mode 100644 engines/wintermute/UI/UIEdit.h create mode 100644 engines/wintermute/UI/UIEntity.cpp create mode 100644 engines/wintermute/UI/UIEntity.h create mode 100644 engines/wintermute/UI/UIObject.cpp create mode 100644 engines/wintermute/UI/UIObject.h create mode 100644 engines/wintermute/UI/UIText.cpp create mode 100644 engines/wintermute/UI/UIText.h create mode 100644 engines/wintermute/UI/UITiledImage.cpp create mode 100644 engines/wintermute/UI/UITiledImage.h create mode 100644 engines/wintermute/UI/UIWindow.cpp create mode 100644 engines/wintermute/UI/UIWindow.h delete mode 100644 engines/wintermute/UIButton.cpp delete mode 100644 engines/wintermute/UIButton.h delete mode 100644 engines/wintermute/UIEdit.cpp delete mode 100644 engines/wintermute/UIEdit.h delete mode 100644 engines/wintermute/UIEntity.cpp delete mode 100644 engines/wintermute/UIEntity.h delete mode 100644 engines/wintermute/UIObject.cpp delete mode 100644 engines/wintermute/UIObject.h delete mode 100644 engines/wintermute/UIText.cpp delete mode 100644 engines/wintermute/UIText.h delete mode 100644 engines/wintermute/UITiledImage.cpp delete mode 100644 engines/wintermute/UITiledImage.h delete mode 100644 engines/wintermute/UIWindow.cpp delete mode 100644 engines/wintermute/UIWindow.h delete mode 100644 engines/wintermute/Vector2.cpp delete mode 100644 engines/wintermute/Vector2.h create mode 100644 engines/wintermute/math/MathUtil.cpp create mode 100644 engines/wintermute/math/MathUtil.h create mode 100644 engines/wintermute/math/Matrix4.cpp create mode 100644 engines/wintermute/math/Matrix4.h create mode 100644 engines/wintermute/math/Vector2.cpp create mode 100644 engines/wintermute/math/Vector2.h delete mode 100644 engines/wintermute/tinystr.cpp delete mode 100644 engines/wintermute/tinystr.h delete mode 100644 engines/wintermute/tinyxml.cpp delete mode 100644 engines/wintermute/tinyxml.h create mode 100644 engines/wintermute/tinyxml/tinystr.cpp create mode 100644 engines/wintermute/tinyxml/tinystr.h create mode 100644 engines/wintermute/tinyxml/tinyxml.cpp create mode 100644 engines/wintermute/tinyxml/tinyxml.h create mode 100644 engines/wintermute/tinyxml/tinyxmlerror.cpp create mode 100644 engines/wintermute/tinyxml/tinyxmlparser.cpp delete mode 100644 engines/wintermute/tinyxmlerror.cpp delete mode 100644 engines/wintermute/tinyxmlparser.cpp (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index bc0ba6a4e8..319709734c 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -37,9 +37,9 @@ #include "engines/wintermute/Base/BTransitionMgr.h" #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/UIEntity.h" +#include "engines/wintermute/UI/UIEntity.h" #include "engines/wintermute/Ad/AdScene.h" #include "engines/wintermute/Ad/AdEntity.h" #include "engines/wintermute/Ad/AdActor.h" diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 4c6d2523d7..1b80763cb4 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -35,8 +35,8 @@ #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BViewport.h" #include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/UIButton.h" -#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/UI/UIButton.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" //#include diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index d81d1b5add..5d946b4895 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -31,8 +31,8 @@ #include "engines/wintermute/Ad/AdResponseBox.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/UIButton.h" -#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/UI/UIButton.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/Base/BFontStorage.h" #include "engines/wintermute/Base/BFont.h" diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index c71d10207f..f3760dcb98 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -56,7 +56,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/utils.h" #include #include diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index deb139859a..a52baeb70b 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/FontGlyphCache.h" #include "engines/wintermute/PathUtil.h" #include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/MathUtil.h" +#include "engines/wintermute/math/MathUtil.h" #include "engines/wintermute/Base/BRenderSDL.h" #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BParser.h" diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6b7df8c46b..dbeb010317 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -54,7 +54,7 @@ #include "engines/wintermute/crc.h" #include "engines/wintermute/PathUtil.h" #include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/UIWindow.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index e005c09591..76156edc61 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/BPersistMgr.h" #include "engines/wintermute/Base/BSaveThumbHelper.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/math/Vector2.h" #include "engines/wintermute/StringUtil.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BSound.h" diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index d918202ff1..87d7c492c4 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/PathUtil.h" #include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/tinyxml.h" +#include "engines/wintermute/tinyxml/tinyxml.h" #include "engines/wintermute/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 43b6134845..d8a27f67d7 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/Base/BImage.h" -#include "engines/wintermute/MathUtil.h" +#include "engines/wintermute/math/MathUtil.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSprite.h" #include "common/system.h" diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index ba3f688a34..2667643882 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -28,8 +28,8 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/PartEmitter.h" -#include "engines/wintermute/Vector2.h" -#include "engines/wintermute/Matrix4.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/math/Matrix4.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/BGame.h" diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h index b8f85bba2a..0754eebfdf 100644 --- a/engines/wintermute/Base/PartForce.h +++ b/engines/wintermute/Base/PartForce.h @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/Base/BNamedObject.h" -#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/math/Vector2.h" namespace WinterMute { diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 09eb7e8443..04f33c2cce 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Vector2.h" +#include "engines/wintermute/math/Vector2.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index bd8962cc0c..18118727da 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/SysInstance.h" +#include "engines/wintermute/Sys/SysInstance.h" #include "engines/wintermute/Base/scriptables/SXArray.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index ffff0e736d..9e954cd1ef 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/SysClassRegistry.h" -#include "engines/wintermute/SysClass.h" +#include "engines/wintermute/Sys/SysClassRegistry.h" +#include "engines/wintermute/Sys/SysClass.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" diff --git a/engines/wintermute/MathUtil.cpp b/engines/wintermute/MathUtil.cpp deleted file mode 100644 index d6b526f5b6..0000000000 --- a/engines/wintermute/MathUtil.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "MathUtil.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -float MathUtil::Round(float val) { - float result = floor(val); - if (val - result >= 0.5) result += 1.0; - return result; -} - -////////////////////////////////////////////////////////////////////////// -float MathUtil::RoundUp(float val) { - float result = floor(val); - if (val - result > 0) result += 1.0; - return result; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/MathUtil.h b/engines/wintermute/MathUtil.h deleted file mode 100644 index bacf975d62..0000000000 --- a/engines/wintermute/MathUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATHUTIL_H -#define WINTERMUTE_MATHUTIL_H - -namespace WinterMute { - -class MathUtil { -public: - static float Round(float val); - static float RoundUp(float val); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/Matrix4.cpp b/engines/wintermute/Matrix4.cpp deleted file mode 100644 index eefc8ae303..0000000000 --- a/engines/wintermute/Matrix4.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Matrix4.h" -#include "engines/wintermute/Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Matrix4::Matrix4() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } -} - -////////////////////////////////////////////////////////////////////////// -Matrix4::~Matrix4() { -} - - -////////////////////////////////////////////////////////////////////////// -void Matrix4::Identity() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } - m[0][0] = 1.0f; - m[1][1] = 1.0f; - m[2][2] = 1.0f; - m[3][3] = 1.0f; - -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::RotationZ(float angle) { - Identity(); - - m[0][0] = cos(angle); - m[1][1] = cos(angle); - m[0][1] = sin(angle); - m[1][0] = -sin(angle); -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::TransformVector2(Vector2 &vec) { - float norm; - - norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; - - float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; - float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; - - vec.x = x; - vec.y = y; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Matrix4.h b/engines/wintermute/Matrix4.h deleted file mode 100644 index da5fd1393a..0000000000 --- a/engines/wintermute/Matrix4.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATRIX4_H -#define WINTERMUTE_MATRIX4_H - -namespace WinterMute { - -class Vector2; - -class Matrix4 { -public: - Matrix4(); - ~Matrix4(); - - void Identity(); - void RotationZ(float angle); - void TransformVector2(Vector2 &vec); - - /* union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - };*/ - float m[4][4]; - //}; - -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp new file mode 100644 index 0000000000..cd5bff0c8c --- /dev/null +++ b/engines/wintermute/Sys/SysClass.cpp @@ -0,0 +1,217 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "SysInstance.h" +#include "SysClass.h" +#include "SysClassRegistry.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +// TODO: Note that the set was removed, this might have bizarre side-effects. + +////////////////////////////////////////////////////////////////////////// +CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { + _name = name; + + _build = build; + _load = load; + _next = NULL; + _savedID = -1; + _persistent = persistent_class; + _numInst = 0; + + CSysClassRegistry::GetInstance()->RegisterClass(this); +} + + +////////////////////////////////////////////////////////////////////////// +CSysClass::~CSysClass() { + CSysClassRegistry::GetInstance()->UnregisterClass(this); + RemoveAllInstances(); +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::RemoveAllInstances() { + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + delete(it->_value); + } + //_instances.clear(); + _instanceMap.clear(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { + CSysInstance *inst = new CSysInstance(instance, id, this); + inst->SetSavedID(savedId); + //_instances.insert(inst); + + _instanceMap[instance] = inst; + + CSysClassRegistry::GetInstance()->AddInstanceToTable(inst, instance); + + return inst; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::RemoveInstance(void *instance) { + InstanceMap::iterator mapIt = _instanceMap.find(instance); + if (mapIt == _instanceMap.end()) return false; + /* + Instances::iterator it = _instances.find((*mapIt).second); + if (it != _instances.end()) { + delete(*it); + _instances.erase(it); + }*/ + + delete mapIt->_value; + _instanceMap.erase(mapIt); + + return false; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::GetInstanceID(void *pointer) { + InstanceMap::iterator mapIt = _instanceMap.find(pointer); + if (mapIt == _instanceMap.end()) return -1; + else return (*mapIt)._value->GetID(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClass::IDToPointer(int savedID) { + //slow + /*Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); + }*/ + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::GetNumInstances() { + //return _instances.size(); + return _instanceMap.size(); // TODO: This might break, if we have multiple keys per value. +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::Dump(void *stream) { + fprintf((FILE *)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { + PersistMgr->PutString(_name.c_str()); + PersistMgr->PutDWORD(_iD); + PersistMgr->PutDWORD(_instanceMap.size()); + + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + PersistMgr->PutDWORD((it->_value)->GetID()); + } + /* + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + PersistMgr->PutDWORD((*it)->GetID()); + }*/ +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { + _savedID = PersistMgr->GetDWORD(); + int numInstances = PersistMgr->GetDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (_persistent) { + int instId = PersistMgr->GetDWORD(); + + if (i > 0) { + Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); + continue; + } + + InstanceMap::iterator it = _instanceMap.begin(); + /* Instances::iterator it = _instances.begin();*/ + if (it != _instanceMap.end()) { + (it->_value)->SetSavedID(instId); + CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); + } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } + // normal instances, create empty objects + else { + void *emptyObject = _build(); + AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); + } + + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + // write instace header + PersistMgr->PutDWORD(_iD); + PersistMgr->PutDWORD((it->_value)->GetID()); + + _load((it->_value)->GetInstance(), PersistMgr); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { + _load(instance, PersistMgr); +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClass::ResetSavedIDs() { + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + (it->_value)->SetSavedID(-1); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { + InstanceMap::iterator it; + for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + lpCallback((it->_value)->GetInstance(), lpData); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h new file mode 100644 index 0000000000..3d6200997b --- /dev/null +++ b/engines/wintermute/Sys/SysClass.h @@ -0,0 +1,117 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASS_H +#define WINTERMUTE_SYSCLASS_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dctypes.h" + +//#include +//#include +#include "common/hashmap.h" +#include "common/func.h" +namespace Common { +template struct Hash; + +template<> struct Hash : public UnaryFunction { + uint operator()(void *val) const { + return (uint)((size_t)val); + } +}; + +} + +namespace WinterMute { +class CSysInstance; +class CBGame; +class CBPersistMgr; +class CSysClass { +public: + CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); + ~CSysClass(); + + int GetNumInstances(); + bool RemoveInstance(void *instance); + CSysInstance *AddInstance(void *instance, int id, int savedId = -1); + bool RemoveAllInstances(); + + int GetInstanceID(void *pointer); + void *IDToPointer(int savedID); + + void SetID(int id) { + _iD = id; + } + int GetID() const { + return _iD; + } + + int GetSavedID() const { + return _savedID; + } + + bool IsPersistent() const { + return _persistent; + } + + AnsiString GetName() const { + return _name; + } + + void SaveTable(CBGame *Game, CBPersistMgr *PersistMgr); + void LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); + + void SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr); + void LoadInstance(void *instance, CBPersistMgr *PersistMgr); + + void InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + + void ResetSavedIDs(); + + void Dump(void *stream); + +private: + int _numInst; + bool _persistent; + CSysClass *_next; + int _iD; + int _savedID; + AnsiString _name; + PERSISTBUILD _build; + PERSISTLOAD _load; + + //typedef std::set Instances; + //Instances _instances; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp new file mode 100644 index 0000000000..25f271fab9 --- /dev/null +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -0,0 +1,288 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "SysInstance.h" +#include "SysClassRegistry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::CSysClassRegistry() { +} + + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::~CSysClassRegistry() { + +} + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry *CSysClassRegistry::GetInstance() { + static CSysClassRegistry classReg; + return &classReg; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { + classObj->SetID(_count++); + //_classes.insert(classObj); + _classes[classObj] = classObj; + + _nameMap[classObj->GetName()] = classObj; + _idMap[classObj->GetID()] = classObj; + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { + + Classes::iterator it = _classes.find(classObj); + if (it == _classes.end()) return false; + + if (classObj->GetNumInstances() != 0) { + char str[MAX_PATH]; + sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->GetName().c_str(), classObj->GetNumInstances()); + CBPlatform::OutputDebugString(str); + } + _classes.erase(it); + + NameMap::iterator mapIt = _nameMap.find(classObj->GetName()); + if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); + + IdMap::iterator idIt = _idMap.find(classObj->GetID()); + if (idIt != _idMap.end()) _idMap.erase(idIt); + + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) { + if (_disabled) return true; + + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + + CSysInstance *inst = (*mapIt)._value->AddInstance(instance, _count++); + return (inst != NULL); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::AddInstanceToTable(CSysInstance *instance, void *pointer) { + _instanceMap[pointer] = instance; + + if (instance->GetSavedID() >= 0) + _savedInstanceMap[instance->GetSavedID()] = instance; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClassRegistry::GetNextID() { + return _count++; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + (*mapIt)._value->RemoveInstance(instance); + + InstanceMap::iterator instIt = _instanceMap.find(instance); + if (instIt != _instanceMap.end()) { + _instanceMap.erase(instIt); + return true; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceID) { + if (pointer == NULL) return true; + + InstanceMap::iterator it = _instanceMap.find(pointer); + if (it == _instanceMap.end()) return false; + + + CSysInstance *inst = (*it)._value; + *instanceID = inst->GetID(); + *classID = inst->GetClass()->GetID(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { + SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); + if (it == _savedInstanceMap.end()) return NULL; + else return (*it)._value->GetInstance(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { + PersistMgr->PutDWORD(_classes.size()); + + int counter = 0; + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + Game->_indicatorProgress = 50.0f / (float)((float)_classes.size() / (float)counter); + Game->DisplayContent(false); + Game->_renderer->Flip(); + } + + (it->_value)->SaveTable(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { + Classes::iterator it; + + // reset SavedID of current instances + for (it = _classes.begin(); it != _classes.end(); ++it) { + (it->_value)->ResetSavedIDs(); + } + + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->IsPersistent()) continue; + (it->_value)->RemoveAllInstances(); + } + + _instanceMap.clear(); + + + int numClasses = PersistMgr->GetDWORD(); + + for (int i = 0; i < numClasses; i++) { + Game->_indicatorProgress = 50.0f / (float)((float)numClasses / (float)i); + Game->DisplayContentSimple(); + Game->_renderer->Flip(); + + char *className = PersistMgr->GetString(); + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { + + Classes::iterator it; + + // count total instances + int numInstances = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + numInstances += (it->_value)->GetNumInstances(); + } + + PersistMgr->PutDWORD(numInstances); + + int counter = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + if (counter % 20 == 0) { + Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); + Game->DisplayContent(false); + Game->_renderer->Flip(); + } + } + Game->MiniUpdate(); + + (it->_value)->SaveInstances(Game, PersistMgr); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) { + // get total instances + int numInstances = PersistMgr->GetDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (i % 20 == 0) { + Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); + Game->DisplayContentSimple(); + Game->_renderer->Flip(); + } + + int classID = PersistMgr->GetDWORD(); + int instanceID = PersistMgr->GetDWORD(); + void *instance = IDToPointer(classID, instanceID); + + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->GetSavedID() == classID) { + (it->_value)->LoadInstance(instance, PersistMgr); + } + } + } + + _savedInstanceMap.clear(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return E_FAIL; + + (*mapIt)._value->InstanceCallback(lpCallback, lpData); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::DumpClasses(void *stream) { + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) + (it->_value)->Dump(stream); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h new file mode 100644 index 0000000000..5d437af324 --- /dev/null +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASSREGISTRY_H +#define WINTERMUTE_SYSCLASSREGISTRY_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +//#include +//#include +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/func.h" + +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + +namespace WinterMute { +class CSysClass; +} + +namespace Common { +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysClass *val) const { + return (uint)((size_t)val); + } +}; + +} + +namespace WinterMute { + +class CBGame; +class CBPersistMgr; +class CSysInstance; + +class CSysClassRegistry { +public: + static CSysClassRegistry *GetInstance(); + + HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + HRESULT LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + void *IDToPointer(int classID, int instanceID); + bool GetPointerID(void *pointer, int *classID, int *instanceID); + bool RegisterClass(CSysClass *classObj); + bool UnregisterClass(CSysClass *classObj); + bool RegisterInstance(const char *className, void *instance); + bool UnregisterInstance(const char *className, void *instance); + void DumpClasses(void *stream); + int GetNextID(); + void AddInstanceToTable(CSysInstance *instance, void *pointer); + + CSysClassRegistry(); + virtual ~CSysClassRegistry(); + + bool _disabled; + int _count; + + typedef Common::HashMap Classes; + Classes _classes; + + typedef Common::HashMap NameMap; + NameMap _nameMap; + + typedef Common::HashMap IdMap; + IdMap _idMap; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; + + typedef Common::HashMap SavedInstanceMap; + SavedInstanceMap _savedInstanceMap; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Sys/SysInstance.cpp b/engines/wintermute/Sys/SysInstance.cpp new file mode 100644 index 0000000000..9e6a459bfc --- /dev/null +++ b/engines/wintermute/Sys/SysInstance.cpp @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SysInstance.h" +#include "SysClassRegistry.h" +#include "SysClass.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysInstance::CSysInstance(void *Instance, int ID, CSysClass *sysClass) { + _instance = Instance; + _iD = ID; + _savedID = -1; + _class = sysClass; + + _used = false; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance::~CSysInstance() { +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysInstance.h b/engines/wintermute/Sys/SysInstance.h new file mode 100644 index 0000000000..b8e2531c4b --- /dev/null +++ b/engines/wintermute/Sys/SysInstance.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSINSTANCE_H +#define WINTERMUTE_SYSINSTANCE_H + +namespace WinterMute { + +class CSysClass; + +class CSysInstance { +public: + CSysInstance(void *Instance, int ID, CSysClass *sysClass); + virtual ~CSysInstance(); + + int GetID() const { + return _iD; + } + int GetSavedID() const { + return _savedID; + } + void *GetInstance() const { + return _instance; + } + CSysClass *GetClass() const { + return _class; + } + + void SetSavedID(int id) { + _savedID = id; + } + +private: + bool _used; + int _iD; + int _savedID; + void *_instance; + CSysClass *_class; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/SysClass.cpp b/engines/wintermute/SysClass.cpp deleted file mode 100644 index cd5bff0c8c..0000000000 --- a/engines/wintermute/SysClass.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "SysInstance.h" -#include "SysClass.h" -#include "SysClassRegistry.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -// TODO: Note that the set was removed, this might have bizarre side-effects. - -////////////////////////////////////////////////////////////////////////// -CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { - _name = name; - - _build = build; - _load = load; - _next = NULL; - _savedID = -1; - _persistent = persistent_class; - _numInst = 0; - - CSysClassRegistry::GetInstance()->RegisterClass(this); -} - - -////////////////////////////////////////////////////////////////////////// -CSysClass::~CSysClass() { - CSysClassRegistry::GetInstance()->UnregisterClass(this); - RemoveAllInstances(); -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::RemoveAllInstances() { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - delete(it->_value); - } - //_instances.clear(); - _instanceMap.clear(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { - CSysInstance *inst = new CSysInstance(instance, id, this); - inst->SetSavedID(savedId); - //_instances.insert(inst); - - _instanceMap[instance] = inst; - - CSysClassRegistry::GetInstance()->AddInstanceToTable(inst, instance); - - return inst; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::RemoveInstance(void *instance) { - InstanceMap::iterator mapIt = _instanceMap.find(instance); - if (mapIt == _instanceMap.end()) return false; - /* - Instances::iterator it = _instances.find((*mapIt).second); - if (it != _instances.end()) { - delete(*it); - _instances.erase(it); - }*/ - - delete mapIt->_value; - _instanceMap.erase(mapIt); - - return false; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::GetInstanceID(void *pointer) { - InstanceMap::iterator mapIt = _instanceMap.find(pointer); - if (mapIt == _instanceMap.end()) return -1; - else return (*mapIt)._value->GetID(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClass::IDToPointer(int savedID) { - //slow - /*Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); - }*/ - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::GetNumInstances() { - //return _instances.size(); - return _instanceMap.size(); // TODO: This might break, if we have multiple keys per value. -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::Dump(void *stream) { - fprintf((FILE *)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { - PersistMgr->PutString(_name.c_str()); - PersistMgr->PutDWORD(_iD); - PersistMgr->PutDWORD(_instanceMap.size()); - - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - PersistMgr->PutDWORD((it->_value)->GetID()); - } - /* - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - PersistMgr->PutDWORD((*it)->GetID()); - }*/ -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - _savedID = PersistMgr->GetDWORD(); - int numInstances = PersistMgr->GetDWORD(); - - for (int i = 0; i < numInstances; i++) { - if (_persistent) { - int instId = PersistMgr->GetDWORD(); - - if (i > 0) { - Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); - continue; - } - - InstanceMap::iterator it = _instanceMap.begin(); - /* Instances::iterator it = _instances.begin();*/ - if (it != _instanceMap.end()) { - (it->_value)->SetSavedID(instId); - CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); - } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); - } - // normal instances, create empty objects - else { - void *emptyObject = _build(); - AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); - } - - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - // write instace header - PersistMgr->PutDWORD(_iD); - PersistMgr->PutDWORD((it->_value)->GetID()); - - _load((it->_value)->GetInstance(), PersistMgr); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { - _load(instance, PersistMgr); -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClass::ResetSavedIDs() { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - (it->_value)->SetSavedID(-1); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - lpCallback((it->_value)->GetInstance(), lpData); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/SysClass.h b/engines/wintermute/SysClass.h deleted file mode 100644 index 3d6200997b..0000000000 --- a/engines/wintermute/SysClass.h +++ /dev/null @@ -1,117 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASS_H -#define WINTERMUTE_SYSCLASS_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dctypes.h" - -//#include -//#include -#include "common/hashmap.h" -#include "common/func.h" -namespace Common { -template struct Hash; - -template<> struct Hash : public UnaryFunction { - uint operator()(void *val) const { - return (uint)((size_t)val); - } -}; - -} - -namespace WinterMute { -class CSysInstance; -class CBGame; -class CBPersistMgr; -class CSysClass { -public: - CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); - ~CSysClass(); - - int GetNumInstances(); - bool RemoveInstance(void *instance); - CSysInstance *AddInstance(void *instance, int id, int savedId = -1); - bool RemoveAllInstances(); - - int GetInstanceID(void *pointer); - void *IDToPointer(int savedID); - - void SetID(int id) { - _iD = id; - } - int GetID() const { - return _iD; - } - - int GetSavedID() const { - return _savedID; - } - - bool IsPersistent() const { - return _persistent; - } - - AnsiString GetName() const { - return _name; - } - - void SaveTable(CBGame *Game, CBPersistMgr *PersistMgr); - void LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); - - void SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr); - void LoadInstance(void *instance, CBPersistMgr *PersistMgr); - - void InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); - - void ResetSavedIDs(); - - void Dump(void *stream); - -private: - int _numInst; - bool _persistent; - CSysClass *_next; - int _iD; - int _savedID; - AnsiString _name; - PERSISTBUILD _build; - PERSISTLOAD _load; - - //typedef std::set Instances; - //Instances _instances; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/SysClassRegistry.cpp b/engines/wintermute/SysClassRegistry.cpp deleted file mode 100644 index 25f271fab9..0000000000 --- a/engines/wintermute/SysClassRegistry.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "SysInstance.h" -#include "SysClassRegistry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::CSysClassRegistry() { -} - - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::~CSysClassRegistry() { - -} - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry *CSysClassRegistry::GetInstance() { - static CSysClassRegistry classReg; - return &classReg; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { - classObj->SetID(_count++); - //_classes.insert(classObj); - _classes[classObj] = classObj; - - _nameMap[classObj->GetName()] = classObj; - _idMap[classObj->GetID()] = classObj; - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { - - Classes::iterator it = _classes.find(classObj); - if (it == _classes.end()) return false; - - if (classObj->GetNumInstances() != 0) { - char str[MAX_PATH]; - sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->GetName().c_str(), classObj->GetNumInstances()); - CBPlatform::OutputDebugString(str); - } - _classes.erase(it); - - NameMap::iterator mapIt = _nameMap.find(classObj->GetName()); - if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); - - IdMap::iterator idIt = _idMap.find(classObj->GetID()); - if (idIt != _idMap.end()) _idMap.erase(idIt); - - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) { - if (_disabled) return true; - - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - - CSysInstance *inst = (*mapIt)._value->AddInstance(instance, _count++); - return (inst != NULL); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::AddInstanceToTable(CSysInstance *instance, void *pointer) { - _instanceMap[pointer] = instance; - - if (instance->GetSavedID() >= 0) - _savedInstanceMap[instance->GetSavedID()] = instance; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClassRegistry::GetNextID() { - return _count++; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - (*mapIt)._value->RemoveInstance(instance); - - InstanceMap::iterator instIt = _instanceMap.find(instance); - if (instIt != _instanceMap.end()) { - _instanceMap.erase(instIt); - return true; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceID) { - if (pointer == NULL) return true; - - InstanceMap::iterator it = _instanceMap.find(pointer); - if (it == _instanceMap.end()) return false; - - - CSysInstance *inst = (*it)._value; - *instanceID = inst->GetID(); - *classID = inst->GetClass()->GetID(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { - SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); - if (it == _savedInstanceMap.end()) return NULL; - else return (*it)._value->GetInstance(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { - PersistMgr->PutDWORD(_classes.size()); - - int counter = 0; - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - Game->_indicatorProgress = 50.0f / (float)((float)_classes.size() / (float)counter); - Game->DisplayContent(false); - Game->_renderer->Flip(); - } - - (it->_value)->SaveTable(Game, PersistMgr); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - Classes::iterator it; - - // reset SavedID of current instances - for (it = _classes.begin(); it != _classes.end(); ++it) { - (it->_value)->ResetSavedIDs(); - } - - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->IsPersistent()) continue; - (it->_value)->RemoveAllInstances(); - } - - _instanceMap.clear(); - - - int numClasses = PersistMgr->GetDWORD(); - - for (int i = 0; i < numClasses; i++) { - Game->_indicatorProgress = 50.0f / (float)((float)numClasses / (float)i); - Game->DisplayContentSimple(); - Game->_renderer->Flip(); - - char *className = PersistMgr->GetString(); - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { - - Classes::iterator it; - - // count total instances - int numInstances = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - numInstances += (it->_value)->GetNumInstances(); - } - - PersistMgr->PutDWORD(numInstances); - - int counter = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - if (counter % 20 == 0) { - Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); - Game->DisplayContent(false); - Game->_renderer->Flip(); - } - } - Game->MiniUpdate(); - - (it->_value)->SaveInstances(Game, PersistMgr); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) { - // get total instances - int numInstances = PersistMgr->GetDWORD(); - - for (int i = 0; i < numInstances; i++) { - if (i % 20 == 0) { - Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); - Game->DisplayContentSimple(); - Game->_renderer->Flip(); - } - - int classID = PersistMgr->GetDWORD(); - int instanceID = PersistMgr->GetDWORD(); - void *instance = IDToPointer(classID, instanceID); - - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->GetSavedID() == classID) { - (it->_value)->LoadInstance(instance, PersistMgr); - } - } - } - - _savedInstanceMap.clear(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return E_FAIL; - - (*mapIt)._value->InstanceCallback(lpCallback, lpData); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::DumpClasses(void *stream) { - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) - (it->_value)->Dump(stream); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/SysClassRegistry.h b/engines/wintermute/SysClassRegistry.h deleted file mode 100644 index 5d437af324..0000000000 --- a/engines/wintermute/SysClassRegistry.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASSREGISTRY_H -#define WINTERMUTE_SYSCLASSREGISTRY_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -//#include -//#include -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/func.h" - -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE - -namespace WinterMute { -class CSysClass; -} - -namespace Common { -template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysClass *val) const { - return (uint)((size_t)val); - } -}; - -} - -namespace WinterMute { - -class CBGame; -class CBPersistMgr; -class CSysInstance; - -class CSysClassRegistry { -public: - static CSysClassRegistry *GetInstance(); - - HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - HRESULT LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - void *IDToPointer(int classID, int instanceID); - bool GetPointerID(void *pointer, int *classID, int *instanceID); - bool RegisterClass(CSysClass *classObj); - bool UnregisterClass(CSysClass *classObj); - bool RegisterInstance(const char *className, void *instance); - bool UnregisterInstance(const char *className, void *instance); - void DumpClasses(void *stream); - int GetNextID(); - void AddInstanceToTable(CSysInstance *instance, void *pointer); - - CSysClassRegistry(); - virtual ~CSysClassRegistry(); - - bool _disabled; - int _count; - - typedef Common::HashMap Classes; - Classes _classes; - - typedef Common::HashMap NameMap; - NameMap _nameMap; - - typedef Common::HashMap IdMap; - IdMap _idMap; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; - - typedef Common::HashMap SavedInstanceMap; - SavedInstanceMap _savedInstanceMap; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/SysInstance.cpp b/engines/wintermute/SysInstance.cpp deleted file mode 100644 index 9e6a459bfc..0000000000 --- a/engines/wintermute/SysInstance.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SysInstance.h" -#include "SysClassRegistry.h" -#include "SysClass.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysInstance::CSysInstance(void *Instance, int ID, CSysClass *sysClass) { - _instance = Instance; - _iD = ID; - _savedID = -1; - _class = sysClass; - - _used = false; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance::~CSysInstance() { -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/SysInstance.h b/engines/wintermute/SysInstance.h deleted file mode 100644 index b8e2531c4b..0000000000 --- a/engines/wintermute/SysInstance.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSINSTANCE_H -#define WINTERMUTE_SYSINSTANCE_H - -namespace WinterMute { - -class CSysClass; - -class CSysInstance { -public: - CSysInstance(void *Instance, int ID, CSysClass *sysClass); - virtual ~CSysInstance(); - - int GetID() const { - return _iD; - } - int GetSavedID() const { - return _savedID; - } - void *GetInstance() const { - return _instance; - } - CSysClass *GetClass() const { - return _class; - } - - void SetSavedID(int id) { - _savedID = id; - } - -private: - bool _used; - int _iD; - int _savedID; - void *_instance; - CSysClass *_class; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp new file mode 100644 index 0000000000..75cc3d5689 --- /dev/null +++ b/engines/wintermute/UI/UIButton.cpp @@ -0,0 +1,1043 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/UI/UIButton.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIButton, false) + +////////////////////////////////////////////////////////////////////////// +CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { + _backPress = _backHover = _backDisable = _backFocus = NULL; + + _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; + + _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; + + _align = TAL_CENTER; + + _hover = _press = false; + + _type = UI_BUTTON; + + _canFocus = false; + _stayPressed = false; + + _oneTimePress = false; + _centerImage = false; + + _pixelPerfect = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIButton::~CUIButton() { + if (_backPress) delete _backPress; + if (_backHover) delete _backHover; + if (_backDisable) delete _backDisable; + if (_backFocus) delete _backFocus; + + if (!_sharedFonts) { + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + } + + if (!_sharedImages) { + if (_imageHover) delete _imageHover; + if (_imagePress) delete _imagePress; + if (_imageDisable) delete _imageDisable; + if (_imageFocus) delete _imageFocus; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(BUTTON) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(FOCUSABLE) +TOKEN_DEF(BACK_HOVER) +TOKEN_DEF(BACK_PRESS) +TOKEN_DEF(BACK_DISABLE) +TOKEN_DEF(BACK_FOCUS) +TOKEN_DEF(BACK) +TOKEN_DEF(CENTER_IMAGE) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE_PRESS) +TOKEN_DEF(IMAGE_DISABLE) +TOKEN_DEF(IMAGE_FOCUS) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT_PRESS) +TOKEN_DEF(FONT_DISABLE) +TOKEN_DEF(FONT_FOCUS) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(PRESSED) +TOKEN_DEF(PIXEL_PERFECT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(FOCUSABLE) + TOKEN_TABLE(BACK_HOVER) + TOKEN_TABLE(BACK_PRESS) + TOKEN_TABLE(BACK_DISABLE) + TOKEN_TABLE(BACK_FOCUS) + TOKEN_TABLE(BACK) + TOKEN_TABLE(CENTER_IMAGE) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE_PRESS) + TOKEN_TABLE(IMAGE_DISABLE) + TOKEN_TABLE(IMAGE_FOCUS) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT_PRESS) + TOKEN_TABLE(FONT_DISABLE) + TOKEN_TABLE(FONT_FOCUS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(PRESSED) + TOKEN_TABLE(PIXEL_PERFECT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + Game->LOG(0, "'BUTTON' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_HOVER: + delete _backHover; + _backHover = new CUITiledImage(Game); + if (!_backHover || FAILED(_backHover->LoadFile((char *)params))) { + delete _backHover; + _backHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_PRESS: + delete _backPress; + _backPress = new CUITiledImage(Game); + if (!_backPress || FAILED(_backPress->LoadFile((char *)params))) { + delete _backPress; + _backPress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_DISABLE: + delete _backDisable; + _backDisable = new CUITiledImage(Game); + if (!_backDisable || FAILED(_backDisable->LoadFile((char *)params))) { + delete _backDisable; + _backDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_FOCUS: + delete _backFocus; + _backFocus = new CUITiledImage(Game); + if (!_backFocus || FAILED(_backFocus->LoadFile((char *)params))) { + delete _backFocus; + _backFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + delete _imageHover; + _imageHover = new CBSprite(Game); + if (!_imageHover || FAILED(_imageHover->LoadFile((char *)params))) { + delete _imageHover; + _imageHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_PRESS: + delete _imagePress; + _imagePress = new CBSprite(Game); + if (!_imagePress || FAILED(_imagePress->LoadFile((char *)params))) { + delete _imagePress; + _imagePress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_DISABLE: + delete _imageDisable; + _imageDisable = new CBSprite(Game); + if (!_imageDisable || FAILED(_imageDisable->LoadFile((char *)params))) { + delete _imageDisable; + _imageDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_FOCUS: + delete _imageFocus; + _imageFocus = new CBSprite(Game); + if (!_imageFocus || FAILED(_imageFocus->LoadFile((char *)params))) { + delete _imageFocus; + _imageFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + _fontHover = Game->_fontStorage->AddFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_PRESS: + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + _fontPress = Game->_fontStorage->AddFont((char *)params); + if (!_fontPress) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_DISABLE: + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + _fontDisable = Game->_fontStorage->AddFont((char *)params); + if (!_fontDisable) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_FOCUS: + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + _fontFocus = Game->_fontStorage->AddFont((char *)params); + if (!_fontFocus) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->_stringTable->Expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_CENTER; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_FOCUSABLE: + parser.ScanStr((char *)params, "%b", &_canFocus); + break; + + case TOKEN_CENTER_IMAGE: + parser.ScanStr((char *)params, "%b", &_centerImage); + break; + + case TOKEN_PRESSED: + parser.ScanStr((char *)params, "%b", &_stayPressed); + break; + + case TOKEN_PIXEL_PERFECT: + parser.ScanStr((char *)params, "%b", &_pixelPerfect); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in BUTTON definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading BUTTON definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "BUTTON\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backHover && _backHover->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + if (_backPress && _backPress->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + if (_backDisable && _backDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + if (_backFocus && _backFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageHover && _imageHover->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + if (_imagePress && _imagePress->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + if (_imageDisable && _imageDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + if (_imageFocus && _imageFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + if (_fontPress && _fontPress->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + if (_fontDisable && _fontDisable->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + if (_fontFocus && _fontFocus->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_align) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUIButton::CorrectSize() { + RECT rect; + + CBSprite *img = NULL; + if (_image) img = _image; + else if (_imageDisable) img = _imageDisable; + else if (_imageHover) img = _imageHover; + else if (_imagePress) img = _imagePress; + else if (_imageFocus) img = _imageFocus; + + if (_width <= 0) { + if (img) { + img->GetBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (img) { + img->GetBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_text) { + int text_height; + if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); + else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); + + if (text_height > _height) _height = text_height; + } + + if (_height <= 0) _height = 100; + + if (_back) _back->CorrectSize(&_width, &_height); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::Display(int OffsetX, int OffsetY) { + if (!_visible) return S_OK; + + CUITiledImage *back = NULL; + CBSprite *image = NULL; + CBFont *font = 0; + + //RECT rect; + //CBPlatform::SetRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && CBPlatform::PtInRect(&rect, Game->_mousePos)!=FALSE); + _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); + + if ((_press && _hover && !Game->_mouseLeftDown) || + (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) Press(); + + + if (_disable) { + if (_backDisable) back = _backDisable; + if (_imageDisable) image = _imageDisable; + if (_text && _fontDisable) font = _fontDisable; + } else if (_press || _oneTimePress || _stayPressed) { + if (_backPress) back = _backPress; + if (_imagePress) image = _imagePress; + if (_text && _fontPress) font = _fontPress; + } else if (_hover) { + if (_backHover) back = _backHover; + if (_imageHover) image = _imageHover; + if (_text && _fontHover) font = _fontHover; + } else if (_canFocus && IsFocused()) { + if (_backFocus) back = _backFocus; + if (_imageFocus) image = _imageFocus; + if (_text && _fontFocus) font = _fontFocus; + } + + if (!back && _back) back = _back; + if (!image && _image) image = _image; + if (_text && !font) { + if (_font) font = _font; + else font = Game->_systemFont; + } + + int ImageX = OffsetX + _posX; + int ImageY = OffsetY + _posY; + + if (image && _centerImage) { + RECT rc; + image->GetBoundingRect(&rc, 0, 0); + ImageX += (_width - (rc.right - rc.left)) / 2; + ImageY += (_height - (rc.bottom - rc.top)) / 2; + } + + if (back) back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + + if (font && _text) { + int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + } + + if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + // reset unused sprites + if (_image && _image != image) _image->Reset(); + if (_imageDisable && _imageDisable != image) _imageDisable->Reset(); + if (_imageFocus && _imageFocus != image) _imageFocus->Reset(); + if (_imagePress && _imagePress != image) _imagePress->Reset(); + if (_imageHover && _imageHover != image) _imageHover->Reset(); + + _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIButton::Press() { + ApplyEvent("Press"); + if (_listenerObject) _listenerObject->Listen(_listenerParamObject, _listenerParamDWORD); + if (_parentNotify && _parent) _parent->ApplyEvent(_name); + + _oneTimePress = false; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetDisabledFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetDisabledFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + if (Val->IsNULL()) { + _fontDisable = NULL; + Stack->PushBool(true); + } else { + _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontDisable != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHoverFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + if (Val->IsNULL()) { + _fontHover = NULL; + Stack->PushBool(true); + } else { + _fontHover = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontHover != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPressedFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + if (Val->IsNULL()) { + _fontPress = NULL; + Stack->PushBool(true); + } else { + _fontPress = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontPress != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFocusedFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + if (Val->IsNULL()) { + _fontFocus = NULL; + Stack->PushBool(true); + } else { + _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_fontFocus != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetDisabledImage") == 0) { + Stack->CorrectParams(1); + + delete _imageDisable; + _imageDisable = new CBSprite(Game); + const char *Filename = Stack->Pop()->GetString(); + if (!_imageDisable || FAILED(_imageDisable->LoadFile(Filename))) { + delete _imageDisable; + _imageDisable = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDisabledImage") == 0) { + Stack->CorrectParams(0); + if (!_imageDisable || !_imageDisable->_filename) Stack->PushNULL(); + else Stack->PushString(_imageDisable->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetDisabledImageObject") == 0) { + Stack->CorrectParams(0); + if (!_imageDisable) Stack->PushNULL(); + else Stack->PushNative(_imageDisable, true); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetHoverImage") == 0) { + Stack->CorrectParams(1); + + delete _imageHover; + _imageHover = new CBSprite(Game); + const char *Filename = Stack->Pop()->GetString(); + if (!_imageHover || FAILED(_imageHover->LoadFile(Filename))) { + delete _imageHover; + _imageHover = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverImage") == 0) { + Stack->CorrectParams(0); + if (!_imageHover || !_imageHover->_filename) Stack->PushNULL(); + else Stack->PushString(_imageHover->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetHoverImageObject") == 0) { + Stack->CorrectParams(0); + if (!_imageHover) Stack->PushNULL(); + else Stack->PushNative(_imageHover, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetPressedImage") == 0) { + Stack->CorrectParams(1); + + delete _imagePress; + _imagePress = new CBSprite(Game); + const char *Filename = Stack->Pop()->GetString(); + if (!_imagePress || FAILED(_imagePress->LoadFile(Filename))) { + delete _imagePress; + _imagePress = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPressedImage") == 0) { + Stack->CorrectParams(0); + if (!_imagePress || !_imagePress->_filename) Stack->PushNULL(); + else Stack->PushString(_imagePress->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetPressedImageObject") == 0) { + Stack->CorrectParams(0); + if (!_imagePress) Stack->PushNULL(); + else Stack->PushNative(_imagePress, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetFocusedImage") == 0) { + Stack->CorrectParams(1); + + delete _imageFocus; + _imageFocus = new CBSprite(Game); + const char *Filename = Stack->Pop()->GetString(); + if (!_imageFocus || FAILED(_imageFocus->LoadFile(Filename))) { + delete _imageFocus; + _imageFocus = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFocusedImage") == 0) { + Stack->CorrectParams(0); + if (!_imageFocus || !_imageFocus->_filename) Stack->PushNULL(); + else Stack->PushString(_imageFocus->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetFocusedImageObject") == 0) { + Stack->CorrectParams(0); + if (!_imageFocus) Stack->PushNULL(); + else Stack->PushNative(_imageFocus, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Press + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Press") == 0) { + Stack->CorrectParams(0); + + if (_visible && !_disable) { + _oneTimePress = true; + _oneTimePressTime = CBPlatform::GetTime(); + } + Stack->PushNULL(); + + return S_OK; + } + + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIButton::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("button"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextAlign") == 0) { + _scValue->SetInt(_align); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focusable") == 0) { + _scValue->SetBool(_canFocus); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pressed") == 0) { + _scValue->SetBool(_stayPressed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + _scValue->SetBool(_pixelPerfect); + return _scValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "TextAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _align = (TTextAlign)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focusable") == 0) { + _canFocus = Value->GetBool(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Pressed") == 0) { + _stayPressed = Value->GetBool(); + return S_OK; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PixelPerfect") == 0) { + _pixelPerfect = Value->GetBool(); + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIButton::ScToString() { + return "[button]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIButton::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER_INT(_align)); + PersistMgr->Transfer(TMEMBER(_backDisable)); + PersistMgr->Transfer(TMEMBER(_backFocus)); + PersistMgr->Transfer(TMEMBER(_backHover)); + PersistMgr->Transfer(TMEMBER(_backPress)); + PersistMgr->Transfer(TMEMBER(_centerImage)); + PersistMgr->Transfer(TMEMBER(_fontDisable)); + PersistMgr->Transfer(TMEMBER(_fontFocus)); + PersistMgr->Transfer(TMEMBER(_fontHover)); + PersistMgr->Transfer(TMEMBER(_fontPress)); + PersistMgr->Transfer(TMEMBER(_hover)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_imageDisable)); + PersistMgr->Transfer(TMEMBER(_imageFocus)); + PersistMgr->Transfer(TMEMBER(_imageHover)); + PersistMgr->Transfer(TMEMBER(_imagePress)); + PersistMgr->Transfer(TMEMBER(_pixelPerfect)); + PersistMgr->Transfer(TMEMBER(_press)); + PersistMgr->Transfer(TMEMBER(_stayPressed)); + + if (!PersistMgr->_saving) { + _oneTimePress = false; + _oneTimePressTime = 0; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h new file mode 100644 index 0000000000..75133e2c0a --- /dev/null +++ b/engines/wintermute/UI/UIButton.h @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIBUTTON_H +#define WINTERMUTE_UIBUTTON_H + + +#include "UIObject.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUIButton : public CUIObject { +public: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + uint32 _oneTimePressTime; + DECLARE_PERSISTENT(CUIButton, CUIObject) + void Press(); + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + bool _press; + bool _hover; + void CorrectSize(); + TTextAlign _align; + CBSprite *_imageHover; + CBSprite *_imagePress; + CBSprite *_imageDisable; + CBSprite *_imageFocus; + CBFont *_fontDisable; + CBFont *_fontPress; + CBFont *_fontHover; + CBFont *_fontFocus; + CUITiledImage *_backPress; + CUITiledImage *_backHover; + CUITiledImage *_backDisable; + CUITiledImage *_backFocus; + CUIButton(CBGame *inGame = NULL); + virtual ~CUIButton(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp new file mode 100644 index 0000000000..3f2bc71996 --- /dev/null +++ b/engines/wintermute/UI/UIEdit.cpp @@ -0,0 +1,860 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/UI/UIEdit.h" +#include "engines/wintermute/UI/UIObject.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/utils.h" +#include "common/util.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEdit, false) + +////////////////////////////////////////////////////////////////////////// +CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { + _type = UI_EDIT; + + _fontSelected = NULL; + + _selStart = _selEnd = 10000; + _scrollOffset = 0; + + _cursorChar = NULL; + SetCursorChar("|"); + +#ifdef __WIN32__ + _cursorBlinkRate = GetCaretBlinkTime(); +#else + _cursorBlinkRate = 600; +#endif + _frameWidth = 0; + + SetText(""); + + _lastBlinkTime = 0; + _cursorVisible = true; + + _maxLength = -1; + + _canFocus = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEdit::~CUIEdit() { + if (!_sharedFonts) { + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + } + + delete[] _cursorChar; + _cursorChar = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_SELECTED) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR_BLINK_RATE) +TOKEN_DEF(CURSOR) +TOKEN_DEF(FRAME_WIDTH) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MAX_LENGTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF(CAPTION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_SELECTED) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR_BLINK_RATE) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(FRAME_WIDTH) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MAX_LENGTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + Game->LOG(0, "'EDIT' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_SELECTED: + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + _fontSelected = Game->_fontStorage->AddFont((char *)params); + if (!_fontSelected) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->_stringTable->Expand(&_text); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &_height); + break; + + case TOKEN_MAX_LENGTH: + parser.ScanStr((char *)params, "%d", &_maxLength); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_BLINK_RATE: + parser.ScanStr((char *)params, "%d", &_cursorBlinkRate); + break; + + case TOKEN_FRAME_WIDTH: + parser.ScanStr((char *)params, "%d", &_frameWidth); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in EDIT definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading EDIT definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "EDIT\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontSelected && _fontSelected->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); + Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + // scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetSelectedFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetSelectedFont") == 0) { + Stack->CorrectParams(1); + + if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + _fontSelected = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(_fontSelected != NULL); + + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEdit::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("editor"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelStart") == 0) { + _scValue->SetInt(_selStart); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelEnd") == 0) { + _scValue->SetInt(_selEnd); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorBlinkRate") == 0) { + _scValue->SetInt(_cursorBlinkRate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorChar") == 0) { + _scValue->SetString(_cursorChar); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FrameWidth") == 0) { + _scValue->SetInt(_frameWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxLength") == 0) { + _scValue->SetInt(_maxLength); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::AnsiToWide(_text); + _scValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); + } else { + _scValue->SetString(_text); + } + return _scValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SelStart") == 0) { + _selStart = Value->GetInt(); + _selStart = MAX(_selStart, 0); + _selStart = MIN((size_t)_selStart, strlen(_text)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SelEnd") == 0) { + _selEnd = Value->GetInt(); + _selEnd = MAX(_selEnd, 0); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorBlinkRate") == 0) { + _cursorBlinkRate = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CursorChar") == 0) { + SetCursorChar(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FrameWidth") == 0) { + _frameWidth = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MaxLength") == 0) { + _maxLength = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); + SetText(StringUtil::WideToAnsi(wstr).c_str()); + } else { + SetText(Value->GetString()); + } + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEdit::ScToString() { + return "[edit]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIEdit::SetCursorChar(const char *Char) { + if (!Char) return; + delete[] _cursorChar; + _cursorChar = new char [strlen(Char) + 1]; + if (_cursorChar) strcpy(_cursorChar, Char); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { + if (!_visible) return S_OK; + + + // hack! + TTextEncoding OrigEncoding = Game->_textEncoding; + Game->_textEncoding = TEXT_ANSI; + + if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); + + // prepare fonts + CBFont *font; + CBFont *sfont; + + if (_font) font = _font; + else font = Game->_systemFont; + + if (_fontSelected) sfont = _fontSelected; + else sfont = font; + + bool focused = IsFocused(); + + _selStart = MAX(_selStart, 0); + _selEnd = MAX(_selEnd, 0); + + _selStart = MIN((size_t)_selStart, strlen(_text)); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + + //int CursorWidth = font->GetCharWidth(_cursorChar[0]); + int CursorWidth = font->GetTextWidth((byte *)_cursorChar); + + int s1, s2; + bool CurFirst; + // modify scroll offset + if (_selStart >= _selEnd) { + while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selEnd; + s2 = _selStart; + CurFirst = true; + } else { + while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + + sfont->GetTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + + > _width - CursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selStart; + s2 = _selEnd; + CurFirst = false; + } + + + int AlignOffset = 0; + + for (int Count = 0; Count < 2; Count++) { + // draw text + int xxx, yyy, width, height; + + xxx = _posX + _frameWidth + OffsetX; + yyy = _posY + _frameWidth + OffsetY; + + width = _posX + _width + OffsetX - _frameWidth; + height = MAX(font->GetLetterHeight(), sfont->GetLetterHeight()); + + if (Game->_textRTL) xxx += AlignOffset; + + TTextAlign Align = TAL_LEFT; + + + // unselected 1 + if (s1 > _scrollOffset) { + if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + } + + // cursor + if (focused && CurFirst) { + if (Count) { + if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::GetTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += CursorWidth; + AlignOffset += CursorWidth; + } + + // selected + int s3 = MAX(s1, _scrollOffset); + + if (s2 - s3 > 0) { + if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + } + + // cursor + if (focused && !CurFirst) { + if (Count) { + if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::GetTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += CursorWidth; + AlignOffset += CursorWidth; + } + + // unselected 2 + if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->GetTextWidth((byte *)_text + s2); + + AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; + if (AlignOffset < 0) AlignOffset = 0; + } + + + Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + + Game->_textEncoding = OrigEncoding; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::HandleKeypress(Common::Event *event) { + bool Handled = false; + + if (event->type == Common::EVENT_KEYDOWN) { + switch (event->kbd.keycode) { + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_TAB: + case Common::KEYCODE_RETURN: + return false; + + // ctrl+A + case Common::KEYCODE_a: + if (CBKeyboardState::IsControlDown()) { + _selStart = 0; + _selEnd = strlen(_text); + Handled = true; + } + break; + + case Common::KEYCODE_BACKSPACE: + if (_selStart == _selEnd) { + if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); + else DeleteChars(_selStart - 1, _selStart); + } else DeleteChars(_selStart, _selEnd); + if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); + _selStart = _selEnd; + + Handled = true; + break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_UP: + _selEnd--; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + Handled = true; + break; + + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_DOWN: + _selEnd++; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + Handled = true; + break; + + case Common::KEYCODE_HOME: + if (Game->_textRTL) { + _selEnd = strlen(_text); + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + } else { + _selEnd = 0; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + } + Handled = true; + break; + + case Common::KEYCODE_END: + if (Game->_textRTL) { + _selEnd = 0; + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + } else { + _selEnd = strlen(_text); + if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + } + Handled = true; + break; + + case Common::KEYCODE_DELETE: + if (_selStart == _selEnd) { + if (Game->_textRTL) { + DeleteChars(_selStart - 1, _selStart); + _selEnd--; + if (_selEnd < 0) _selEnd = 0; + } else DeleteChars(_selStart, _selStart + 1); + } else DeleteChars(_selStart, _selEnd); + if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); + + _selStart = _selEnd; + Handled = true; + break; + default: + break; + } + return Handled; + } +#if 0 + else if (event->type == SDL_TEXTINPUT) { + if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); + + WideString wstr = StringUtil::Utf8ToWide(event->text.text); + _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + + if (Game->_textRTL) _selEnd = _selStart; + else _selStart = _selEnd; + + return true; + } +#endif + return false; +} + + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::DeleteChars(int Start, int End) { + if (Start > End) CBUtils::Swap(&Start, &End); + + Start = MAX(Start, (int)0); + End = MIN((size_t)End, strlen(_text)); + + char *str = new char[strlen(_text) - (End - Start) + 1]; + if (str) { + if (Start > 0) memcpy(str, _text, Start); + memcpy(str + MAX(0, Start), _text + End, strlen(_text) - End + 1); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->ApplyEvent(_name); + + return End - Start; +} + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { + if (strlen(_text) + Num > _maxLength) { + Num -= (strlen(_text) + Num - _maxLength); + } + + Pos = MAX(Pos, (int)0); + Pos = MIN((size_t)Pos, strlen(_text)); + + char *str = new char[strlen(_text) + Num + 1]; + if (str) { + if (Pos > 0) memcpy(str, _text, Pos); + memcpy(str + Pos + Num, _text + Pos, strlen(_text) - Pos + 1); + + memcpy(str + Pos, Chars, Num); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->ApplyEvent(_name); + + return Num; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEdit::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_cursorBlinkRate)); + PersistMgr->Transfer(TMEMBER(_cursorChar)); + PersistMgr->Transfer(TMEMBER(_fontSelected)); + PersistMgr->Transfer(TMEMBER(_frameWidth)); + PersistMgr->Transfer(TMEMBER(_maxLength)); + PersistMgr->Transfer(TMEMBER(_scrollOffset)); + PersistMgr->Transfer(TMEMBER(_selEnd)); + PersistMgr->Transfer(TMEMBER(_selStart)); + + if (!PersistMgr->_saving) { + _cursorVisible = false; + _lastBlinkTime = 0; + } + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h new file mode 100644 index 0000000000..3b8698d55d --- /dev/null +++ b/engines/wintermute/UI/UIEdit.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIEDIT_H +#define WINTERMUTE_UIEDIT_H + +#include "engines/wintermute/persistent.h" +#include "UIObject.h" +#include "common/events.h" + +namespace WinterMute { +class CBFont; +class CUIEdit : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEdit, CUIObject) + int _maxLength; + int InsertChars(int Pos, byte *Chars, int Num); + int DeleteChars(int Start, int End); + bool _cursorVisible; + uint32 _lastBlinkTime; + virtual HRESULT Display(int OffsetX, int OffsetY); + virtual bool HandleKeypress(Common::Event *event); + int _scrollOffset; + int _frameWidth; + uint32 _cursorBlinkRate; + void SetCursorChar(const char *Char); + char *_cursorChar; + int _selEnd; + int _selStart; + CBFont *_fontSelected; + CUIEdit(CBGame *inGame); + virtual ~CUIEdit(); + + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp new file mode 100644 index 0000000000..97565603f3 --- /dev/null +++ b/engines/wintermute/UI/UIEntity.cpp @@ -0,0 +1,339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/UI/UIEntity.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEntity, false) + +////////////////////////////////////////////////////////////////////////// +CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { + _type = UI_CUSTOM; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEntity::~CUIEntity() { + if (_entity) Game->UnregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(NAME) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_ENTITY: + if (FAILED(SetEntity((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); + return E_FAIL; + } + + CorrectSize(); + + if (Game->_editorMode) { + _width = 50; + _height = 50; + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + + if (_entity && _entity->_filename) + Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::SetEntity(const char *Filename) { + if (_entity) Game->UnregisterObject(_entity); + _entity = new CAdEntity(Game); + if (!_entity || FAILED(_entity->LoadFile(Filename))) { + delete _entity; + _entity = NULL; + return E_FAIL; + } else { + _entity->_nonIntMouseEvents = true; + _entity->_sceneIndependent = true; + _entity->MakeFreezable(false); + Game->RegisterObject(_entity); + } + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { + if (!_visible) return S_OK; + + if (_entity) { + _entity->_posX = OffsetX + _posX; + _entity->_posY = OffsetY + _posY; + if (_entity->_scale < 0) _entity->_zoomable = false; + _entity->_shadowable = false; + + _entity->Update(); + + bool OrigReg = _entity->_registrable; + + if (_entity->_registrable && _disable) _entity->_registrable = false; + + _entity->Display(); + _entity->_registrable = OrigReg; + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetEntity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetEntity") == 0) { + Stack->CorrectParams(0); + + if (_entity) Stack->PushNative(_entity, true); + else Stack->PushNULL(); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetEntity") == 0) { + Stack->CorrectParams(1); + + const char *Filename = Stack->Pop()->GetString(); + + if (SUCCEEDED(SetEntity(Filename))) + Stack->PushBool(true); + else + Stack->PushBool(false); + + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEntity::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("entity container"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Freezable") == 0) { + if (_entity) _scValue->SetBool(_entity->_freezable); + else _scValue->SetBool(false); + return _scValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Freezable") == 0) { + if (_entity) _entity->MakeFreezable(Value->GetBool()); + return S_OK; + } else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEntity::ScToString() { + return "[entity container]"; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIEntity::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_entity)); + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h new file mode 100644 index 0000000000..c18fd952dc --- /dev/null +++ b/engines/wintermute/UI/UIEntity.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIENTITY_H +#define WINTERMUTE_UIENTITY_H + +#include "UIObject.h" + +namespace WinterMute { +class CAdEntity; +class CUIEntity : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEntity, CUIObject) + CUIEntity(CBGame *inGame); + virtual ~CUIEntity(); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + CAdEntity *_entity; + HRESULT SetEntity(const char *Filename); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp new file mode 100644 index 0000000000..20a89c5897 --- /dev/null +++ b/engines/wintermute/UI/UIObject.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/UI/UIObject.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/UI/UIWindow.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BFontStorage.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIObject, false) + +////////////////////////////////////////////////////////////////////////// +CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { + _back = NULL; + _image = NULL; + _font = NULL; + _text = NULL; + _sharedFonts = _sharedImages = false; + + _width = _height = 0; + + _listenerObject = NULL; + _listenerParamObject = NULL; + _listenerParamDWORD = 0; + + _disable = false; + _visible = true; + + _type = UI_UNKNOWN; + _parent = NULL; + + _parentNotify = false; + + _focusedWidget = NULL; + + _canFocus = false; + _nonIntMouseEvents = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIObject::~CUIObject() { + if (!Game->_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); + + if (_back) delete _back; + if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); + + if (_image && !_sharedImages) delete _image; + + if (_text) delete [] _text; + + _focusedWidget = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::SetText(const char *Text) { + if (_text) delete [] _text; + _text = new char [strlen(Text) + 1]; + if (_text) { + strcpy(_text, Text); + for (int i = 0; i < strlen(_text); i++) { + if (_text[i] == '|') _text[i] = '\n'; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Display(int OffsetX, int OffsetY) { + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { + _listenerObject = Object; + _listenerParamObject = ListenerObject; + _listenerParamDWORD = ListenerParam; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::CorrectSize() { + RECT rect; + + if (_width <= 0) { + if (_image) { + _image->GetBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (_image) { + _image->GetBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_back) _back->CorrectSize(&_width, &_height); +} + + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SetFont") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + if (_font) Game->_fontStorage->RemoveFont(_font); + if (Val->IsNULL()) { + _font = NULL; + Stack->PushBool(true); + } else { + _font = Game->_fontStorage->AddFont(Val->GetString()); + Stack->PushBool(_font != NULL); + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetImage") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + const char *Filename = Val->GetString(); + + delete _image; + _image = NULL; + if (Val->IsNULL()) { + Stack->PushBool(true); + return S_OK; + } + + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile(Val->GetString()))) { + delete _image; + _image = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetImage") == 0) { + Stack->CorrectParams(0); + if (!_image || !_image->_filename) Stack->PushNULL(); + else Stack->PushString(_image->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetImageObject") == 0) { + Stack->CorrectParams(0); + if (!_image) Stack->PushNULL(); + else Stack->PushNative(_image, true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focus + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Focus") == 0) { + Stack->CorrectParams(0); + Focus(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveAfter / MoveBefore + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveAfter") == 0 || strcmp(Name, "MoveBefore") == 0) { + Stack->CorrectParams(1); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + + int i; + bool found = false; + CScValue *val = Stack->Pop(); + // find directly + if (val->IsNative()) { + CUIObject *widget = (CUIObject *)val->GetNative(); + for (i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == widget) { + found = true; + break; + } + } + } + // find by name + else { + const char *name = val->GetString(); + for (i = 0; i < win->_widgets.GetSize(); i++) { + if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { + found = true; + break; + } + } + } + + if (found) { + bool done = false; + for (int j = 0; j < win->_widgets.GetSize(); j++) { + if (win->_widgets[j] == this) { + if (strcmp(Name, "MoveAfter") == 0) i++; + if (j >= i) j++; + + win->_widgets.InsertAt(i, this); + win->_widgets.RemoveAt(j); + + done = true; + Stack->PushBool(true); + break; + } + } + if (!done) Stack->PushBool(false); + } else Stack->PushBool(false); + + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToBottom + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveToBottom") == 0) { + Stack->CorrectParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.RemoveAt(i); + win->_widgets.InsertAt(0, this); + break; + } + } + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToTop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "MoveToTop") == 0) { + Stack->CorrectParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.RemoveAt(i); + win->_widgets.Add(this); + break; + } + } + Stack->PushBool(true); + } else Stack->PushBool(false); + + return S_OK; + } + + else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIObject::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("ui_object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Name") == 0) { + _scValue->SetString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Parent (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Parent") == 0) { + _scValue->SetNative(_parent, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParentNotify") == 0) { + _scValue->SetBool(_parentNotify); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _scValue->SetInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _scValue->SetInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Visible") == 0) { + _scValue->SetBool(_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Disabled") == 0) { + _scValue->SetBool(_disable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + _scValue->SetString(_text); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NextSibling (RO) / PrevSibling (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NextSibling") == 0 || strcmp(Name, "PrevSibling") == 0) { + _scValue->SetNULL(); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.GetSize(); i++) { + if (win->_widgets[i] == this) { + if (strcmp(Name, "NextSibling") == 0) { + if (i < win->_widgets.GetSize() - 1) _scValue->SetNative(win->_widgets[i + 1], true); + } else { + if (i > 0) _scValue->SetNative(win->_widgets[i - 1], true); + } + break; + } + } + } + return _scValue; + } + + else return CBObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ParentNotify") == 0) { + _parentNotify = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Width") == 0) { + _width = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Height") == 0) { + _height = Value->GetInt(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Visible") == 0) { + _visible = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Disabled") == 0) { + _disable = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Text") == 0) { + SetText(Value->GetString()); + return S_OK; + } + + else return CBObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIObject::ScToString() { + return "[ui_object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::IsFocused() { + if (!Game->_focusedWindow) return false; + if (Game->_focusedWindow == this) return true; + + CUIObject *obj = Game->_focusedWindow; + while (obj) { + if (obj == this) return true; + else obj = obj->_focusedWidget; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { + // handle focus change + if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { + Focus(); + } + return CBObject::HandleMouse(Event, Button); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Focus() { + CUIObject *obj = this; + bool disabled = false; + while (obj) { + if (obj->_disable && obj->_type == UI_WINDOW) { + disabled = true; + break; + } + obj = obj->_parent; + } + if (!disabled) { + obj = this; + while (obj) { + if (obj->_parent) { + if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; + } else { + if (obj->_type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); + } + + obj = obj->_parent; + } + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { + int OffX = 0, OffY = 0; + + CUIObject *obj = _parent; + while (obj) { + OffX += obj->_posX; + OffY += obj->_posY; + + obj = obj->_parent; + } + if (OffsetX) *OffsetX = OffX; + if (OffsetY) *OffsetY = OffY; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::Persist(CBPersistMgr *PersistMgr) { + + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_back)); + PersistMgr->Transfer(TMEMBER(_canFocus)); + PersistMgr->Transfer(TMEMBER(_disable)); + PersistMgr->Transfer(TMEMBER(_focusedWidget)); + PersistMgr->Transfer(TMEMBER(_font)); + PersistMgr->Transfer(TMEMBER(_height)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_listenerObject)); + PersistMgr->Transfer(TMEMBER(_listenerParamObject)); + PersistMgr->Transfer(TMEMBER(_listenerParamDWORD)); + PersistMgr->Transfer(TMEMBER(_parent)); + PersistMgr->Transfer(TMEMBER(_parentNotify)); + PersistMgr->Transfer(TMEMBER(_sharedFonts)); + PersistMgr->Transfer(TMEMBER(_sharedImages)); + PersistMgr->Transfer(TMEMBER(_text)); + PersistMgr->Transfer(TMEMBER_INT(_type)); + PersistMgr->Transfer(TMEMBER(_visible)); + PersistMgr->Transfer(TMEMBER(_width)); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { + return E_FAIL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h new file mode 100644 index 0000000000..7d6dfb41f5 --- /dev/null +++ b/engines/wintermute/UI/UIObject.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIOBJECT_H +#define WINTERMUTE_UIOBJECT_H + + +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUITiledImage; +class CBFont; +class CUIObject : public CBObject { +public: + + HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); + bool _canFocus; + HRESULT Focus(); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + bool IsFocused(); + bool _parentNotify; + DECLARE_PERSISTENT(CUIObject, CBObject) + CUIObject *_parent; + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual void CorrectSize(); + bool _sharedFonts; + bool _sharedImages; + void SetText(const char *Text); + char *_text; + CBFont *_font; + bool _visible; + CUITiledImage *_back; + bool _disable; + CUIObject(CBGame *inGame = NULL); + virtual ~CUIObject(); + int _width; + int _height; + TUIObjectType _type; + CBSprite *_image; + void SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); + CBScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + CBScriptHolder *_listenerObject; + CUIObject *_focusedWidget; + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp new file mode 100644 index 0000000000..c2888e7393 --- /dev/null +++ b/engines/wintermute/UI/UIText.cpp @@ -0,0 +1,489 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/UI/UIText.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIText, false) + +////////////////////////////////////////////////////////////////////////// +CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { + _textAlign = TAL_LEFT; + _verticalAlign = VAL_CENTER; + _type = UI_STATIC; + _canFocus = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIText::~CUIText() { + +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::Display(int OffsetX, int OffsetY) { + if (!_visible) return S_OK; + + + CBFont *font = _font; + if (!font) font = Game->_systemFont; + + if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); + + if (font && _text) { + int text_offset; + switch (_verticalAlign) { + case VAL_TOP: + text_offset = 0; + break; + case VAL_BOTTOM: + text_offset = _height - font->GetTextHeight((byte *)_text, _width); + break; + default: + text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + } + font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); + } + + //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + return S_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(STATIC) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + Game->LOG(0, "'STATIC' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + SetText((char *)params); + Game->_stringTable->Expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; + else _textAlign = TAL_CENTER; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; + else _verticalAlign = VAL_CENTER; + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in STATIC definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading STATIC definition"); + return E_FAIL; + } + + CorrectSize(); + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "STATIC\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + if (_text) + Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_textAlign) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CUIText::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // SizeToFit + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "SizeToFit") == 0) { + Stack->CorrectParams(0); + SizeToFit(); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HeightToFit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "HeightToFit") == 0) { + Stack->CorrectParams(0); + if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); + Stack->PushNULL(); + return S_OK; + } + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIText::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("static"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "TextAlign") == 0) { + _scValue->SetInt(_textAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VerticalAlign") == 0) { + _scValue->SetInt(_verticalAlign); + return _scValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "TextAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _textAlign = (TTextAlign)i; + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "VerticalAlign") == 0) { + int i = Value->GetInt(); + if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; + _verticalAlign = (TVerticalAlign)i; + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIText::ScToString() { + return "[static]"; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + PersistMgr->Transfer(TMEMBER_INT(_textAlign)); + PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIText::SizeToFit() { + if (_font && _text) { + _width = _font->GetTextWidth((byte *)_text); + _height = _font->GetTextHeight((byte *)_text, _width); + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h new file mode 100644 index 0000000000..756834fd5c --- /dev/null +++ b/engines/wintermute/UI/UIText.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITEXT_H +#define WINTERMUTE_UITEXT_H + + +#include "UIObject.h" + +namespace WinterMute { + +class CUIText : public CUIObject { +public: + HRESULT SizeToFit(); + virtual HRESULT Display(int OffsetX, int OffsetY); + DECLARE_PERSISTENT(CUIText, CUIObject) + CUIText(CBGame *inGame = NULL); + virtual ~CUIText(); + TTextAlign _textAlign; + TVerticalAlign _verticalAlign; + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp new file mode 100644 index 0000000000..9965ed5128 --- /dev/null +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -0,0 +1,370 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUITiledImage, false) + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { + _image = NULL; + + CBPlatform::SetRectEmpty(&_upLeft); + CBPlatform::SetRectEmpty(&_upMiddle); + CBPlatform::SetRectEmpty(&_upRight); + CBPlatform::SetRectEmpty(&_middleLeft); + CBPlatform::SetRectEmpty(&_middleMiddle); + CBPlatform::SetRectEmpty(&_middleRight); + CBPlatform::SetRectEmpty(&_downLeft); + CBPlatform::SetRectEmpty(&_downMiddle); + CBPlatform::SetRectEmpty(&_downRight); +} + + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::~CUITiledImage() { + delete _image; + _image = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { + if (!_image) return E_FAIL; + + int tile_width = _middleMiddle.right - _middleMiddle.left; + int tile_height = _middleMiddle.bottom - _middleMiddle.top; + + int nu_columns = (Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; + int nu_rows = (Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; + + int col, row; + + Game->_renderer->StartSpriteBatch(); + + // top left/right + _image->_surface->DisplayTrans(X, Y, _upLeft); + _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); + + // bottom left/right + _image->_surface->DisplayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); + _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); + + // left/right + int yyy = Y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nu_rows; row++) { + _image->_surface->DisplayTrans(X, yyy, _middleLeft); + _image->_surface->DisplayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); + yyy += tile_width; + } + + // top/bottom + int xxx = X + (_upLeft.right - _upLeft.left); + for (col = 0; col < nu_columns; col++) { + _image->_surface->DisplayTrans(xxx, Y, _upMiddle); + _image->_surface->DisplayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); + xxx += tile_width; + } + + // tiles + yyy = Y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nu_rows; row++) { + xxx = X + (_upLeft.right - _upLeft.left); + for (col = 0; col < nu_columns; col++) { + _image->_surface->DisplayTrans(xxx, yyy, _middleMiddle); + xxx += tile_width; + } + yyy += tile_width; + } + + Game->_renderer->EndSpriteBatch(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); + + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TILED_IMAGE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(UP_MIDDLE) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(DOWN_MIDDLE) +TOKEN_DEF(MIDDLE_LEFT) +TOKEN_DEF(MIDDLE_RIGHT) +TOKEN_DEF(MIDDLE_MIDDLE) +TOKEN_DEF(VERTICAL_TILES) +TOKEN_DEF(HORIZONTAL_TILES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TILED_IMAGE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(UP_MIDDLE) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(DOWN_MIDDLE) + TOKEN_TABLE(MIDDLE_LEFT) + TOKEN_TABLE(MIDDLE_RIGHT) + TOKEN_TABLE(MIDDLE_MIDDLE) + TOKEN_TABLE(VERTICAL_TILES) + TOKEN_TABLE(HORIZONTAL_TILES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(Game); + bool HTiles = false, VTiles = false; + int H1 = 0, H2 = 0, H3 = 0; + int V1 = 0, V2 = 0, V3 = 0; + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + Game->LOG(0, "'TILED_IMAGE' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSubFrame(Game); + if (!_image || FAILED(_image->SetSurface((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_UP_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); + break; + + case TOKEN_UP_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); + break; + + case TOKEN_UP_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); + break; + + case TOKEN_DOWN_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); + break; + + case TOKEN_DOWN_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); + break; + + case TOKEN_DOWN_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); + break; + + case TOKEN_MIDDLE_LEFT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); + break; + + case TOKEN_MIDDLE_RIGHT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); + break; + + case TOKEN_MIDDLE_MIDDLE: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); + break; + + case TOKEN_HORIZONTAL_TILES: + parser.ScanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); + HTiles = true; + break; + + case TOKEN_VERTICAL_TILES: + parser.ScanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); + VTiles = true; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TILED_IMAGE definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading TILED_IMAGE definition"); + return E_FAIL; + } + + if (VTiles && HTiles) { + // up row + CBPlatform::SetRect(&_upLeft, 0, 0, H1, V1); + CBPlatform::SetRect(&_upMiddle, H1, 0, H1 + H2, V1); + CBPlatform::SetRect(&_upRight, H1 + H2, 0, H1 + H2 + H3, V1); + + // middle row + CBPlatform::SetRect(&_middleLeft, 0, V1, H1, V1 + V2); + CBPlatform::SetRect(&_middleMiddle, H1, V1, H1 + H2, V1 + V2); + CBPlatform::SetRect(&_middleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); + + // down row + CBPlatform::SetRect(&_downLeft, 0, V1 + V2, H1, V1 + V2 + V3); + CBPlatform::SetRect(&_downMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); + CBPlatform::SetRect(&_downRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); + } + + // default + if (_image && _image->_surface) { + int Width = _image->_surface->GetWidth() / 3; + int Height = _image->_surface->GetHeight() / 3; + + if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, Width, Height); + if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, Width, 0, 2 * Width, Height); + if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * Width, 0, 3 * Width, Height); + + if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, Height, Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, Width, Height, 2 * Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * Width, Height, 3 * Width, 2 * Height); + + if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * Height, Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, Width, 2 * Height, 2 * Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); + } + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + if (_image && _image->_surfaceFilename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + + int H1, H2, H3; + int V1, V2, V3; + + H1 = _upLeft.right; + H2 = _upMiddle.right - _upMiddle.left; + H3 = _upRight.right - _upRight.left; + + V1 = _upLeft.bottom; + V2 = _middleLeft.bottom - _middleLeft.top; + V3 = _downLeft.bottom - _downLeft.top; + + + Buffer->PutTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); + Buffer->PutTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUITiledImage::CorrectSize(int *Width, int *Height) { + int tile_width = _middleMiddle.right - _middleMiddle.left; + int tile_height = _middleMiddle.bottom - _middleMiddle.top; + + int nu_columns = (*Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; + int nu_rows = (*Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; + + *Width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nu_columns * tile_width; + *Height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nu_rows * tile_height; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUITiledImage::Persist(CBPersistMgr *PersistMgr) { + CBObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_downLeft)); + PersistMgr->Transfer(TMEMBER(_downMiddle)); + PersistMgr->Transfer(TMEMBER(_downRight)); + PersistMgr->Transfer(TMEMBER(_image)); + PersistMgr->Transfer(TMEMBER(_middleLeft)); + PersistMgr->Transfer(TMEMBER(_middleMiddle)); + PersistMgr->Transfer(TMEMBER(_middleRight)); + PersistMgr->Transfer(TMEMBER(_upLeft)); + PersistMgr->Transfer(TMEMBER(_upMiddle)); + PersistMgr->Transfer(TMEMBER(_upRight)); + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h new file mode 100644 index 0000000000..03d15a0daa --- /dev/null +++ b/engines/wintermute/UI/UITiledImage.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITILEDIMAGE_H +#define WINTERMUTE_UITILEDIMAGE_H + + +#include "UIObject.h" + +namespace WinterMute { +class CBSubFrame; +class CUITiledImage : public CBObject { +public: + DECLARE_PERSISTENT(CUITiledImage, CBObject) + void CorrectSize(int *Width, int *Height); + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + HRESULT Display(int X, int Y, int Width, int Height); + CUITiledImage(CBGame *inGame = NULL); + virtual ~CUITiledImage(); + CBSubFrame *_image; + RECT _upLeft; + RECT _upMiddle; + RECT _upRight; + RECT _middleLeft; + RECT _middleMiddle; + RECT _middleRight; + RECT _downLeft; + RECT _downMiddle; + RECT _downRight; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp new file mode 100644 index 0000000000..d364b27740 --- /dev/null +++ b/engines/wintermute/UI/UIWindow.cpp @@ -0,0 +1,1321 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/UI/UIWindow.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/BDynBuffer.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/UI/UIButton.h" +#include "engines/wintermute/UI/UIEdit.h" +#include "engines/wintermute/UI/UIText.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BStringTable.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIWindow, false) + +////////////////////////////////////////////////////////////////////////// +CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { + CBPlatform::SetRectEmpty(&_titleRect); + CBPlatform::SetRectEmpty(&_dragRect); + _titleAlign = TAL_LEFT; + _transparent = false; + + _backInactive = NULL; + _fontInactive = NULL; + _imageInactive = NULL; + + _type = UI_WINDOW; + _canFocus = true; + + _dragging = false; + _dragFrom.x = _dragFrom.y = 0; + + _mode = WINDOW_NORMAL; + _shieldWindow = NULL; + _shieldButton = NULL; + + _fadeColor = 0x00000000; + _fadeBackground = false; + + _ready = true; + _isMenu = false; + _inGame = false; + + _clipContents = false; + _viewport = NULL; + + _pauseMusic = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIWindow::~CUIWindow() { + Close(); + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::Cleanup() { + delete _shieldWindow; + delete _shieldButton; + delete _viewport; + _shieldWindow = NULL; + _shieldButton = NULL; + _viewport = NULL; + + if (_backInactive) delete _backInactive; + if (!_sharedFonts && _fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + if (!_sharedImages && _imageInactive) delete _imageInactive; + + for (int i = 0; i < _widgets.GetSize(); i++) delete _widgets[i]; + _widgets.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { + // go exclusive + if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = Game->_renderer->_width; + _shieldWindow->_height = Game->_renderer->_height; + + _shieldWindow->Display(); + } + } else if (_isMenu) { + if (!_shieldButton) { + _shieldButton = new CUIButton(Game); + _shieldButton->SetName("close"); + _shieldButton->SetListener(this, _shieldButton, 0); + _shieldButton->_parent = this; + } + if (_shieldButton) { + _shieldButton->_posX = _shieldButton->_posY = 0; + _shieldButton->_width = Game->_renderer->_width; + _shieldButton->_height = Game->_renderer->_height; + + _shieldButton->Display(); + } + } + + if (!_visible) return S_OK; + + if (_fadeBackground) Game->_renderer->FadeToColor(_fadeColor); + + if (_dragging) { + _posX += (Game->_mousePos.x - _dragFrom.x); + _posY += (Game->_mousePos.y - _dragFrom.y); + + _dragFrom.x = Game->_mousePos.x; + _dragFrom.y = Game->_mousePos.y; + } + + if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { + MoveFocus(); + } + + bool PopViewport = false; + if (_clipContents) { + if (!_viewport) _viewport = new CBViewport(Game); + if (_viewport) { + _viewport->SetRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); + Game->PushViewport(_viewport); + PopViewport = true; + } + } + + + CUITiledImage *back = _back; + CBSprite *image = _image; + CBFont *font = _font; + + if (!IsFocused()) { + if (_backInactive) back = _backInactive; + if (_imageInactive) image = _imageInactive; + if (_fontInactive) font = _fontInactive; + } + + if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; + if (back) back->Display(_posX + OffsetX, _posY + OffsetY, _width, _height); + if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); + + if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { + font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + } + + if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); + + for (int i = 0; i < _widgets.GetSize(); i++) { + _widgets[i]->Display(_posX + OffsetX, _posY + OffsetY); + } + + if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; + + if (PopViewport) Game->PopViewport(); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::LoadFile(const char *Filename) { + byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + if (Buffer == NULL) { + Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); + return E_FAIL; + } + + HRESULT ret; + + _filename = new char [strlen(Filename) + 1]; + strcpy(_filename, Filename); + + if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WINDOW) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK_INACTIVE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE_INACTIVE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_INACTIVE) +TOKEN_DEF(FONT) +TOKEN_DEF(TITLE_ALIGN) +TOKEN_DEF(TITLE_RECT) +TOKEN_DEF(TITLE) +TOKEN_DEF(DRAG_RECT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(FADE_ALPHA) +TOKEN_DEF(FADE_COLOR) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(BUTTON) +TOKEN_DEF(STATIC) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MENU) +TOKEN_DEF(IN_GAME) +TOKEN_DEF(CLIP_CONTENTS) +TOKEN_DEF(PAUSE_MUSIC) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK_INACTIVE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE_INACTIVE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_INACTIVE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TITLE_ALIGN) + TOKEN_TABLE(TITLE_RECT) + TOKEN_TABLE(TITLE) + TOKEN_TABLE(DRAG_RECT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(FADE_ALPHA) + TOKEN_TABLE(FADE_COLOR) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MENU) + TOKEN_TABLE(IN_GAME) + TOKEN_TABLE(CLIP_CONTENTS) + TOKEN_TABLE(PAUSE_MUSIC) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(Game); + + int FadeR = 0, FadeG = 0, FadeB = 0, FadeA = 0; + int ar = 0, ag = 0, ab = 0, alpha = 0; + + if (Complete) { + if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + Game->LOG(0, "'WINDOW' keyword expected."); + return E_FAIL; + } + Buffer = params; + } + + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + SetName((char *)params); + break; + + case TOKEN_CAPTION: + SetCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(Game); + if (!_back || FAILED(_back->LoadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_INACTIVE: + delete _backInactive; + _backInactive = new CUITiledImage(Game); + if (!_backInactive || FAILED(_backInactive->LoadFile((char *)params))) { + delete _backInactive; + _backInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(Game); + if (!_image || FAILED(_image->LoadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_INACTIVE: + delete _imageInactive, + _imageInactive = new CBSprite(Game); + if (!_imageInactive || FAILED(_imageInactive->LoadFile((char *)params))) { + delete _imageInactive; + _imageInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) Game->_fontStorage->RemoveFont(_font); + _font = Game->_fontStorage->AddFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_INACTIVE: + if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + _fontInactive = Game->_fontStorage->AddFont((char *)params); + if (!_fontInactive) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TITLE: + SetText((char *)params); + Game->_stringTable->Expand(&_text); + break; + + case TOKEN_TITLE_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; + else _titleAlign = TAL_CENTER; + break; + + case TOKEN_TITLE_RECT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); + break; + + case TOKEN_DRAG_RECT: + parser.ScanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); + break; + + case TOKEN_X: + parser.ScanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.ScanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.ScanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.ScanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(Game); + if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BUTTON: { + CUIButton *btn = new CUIButton(Game); + if (!btn || FAILED(btn->LoadBuffer(params, false))) { + delete btn; + btn = NULL; + cmd = PARSERR_GENERIC; + } else { + btn->_parent = this; + _widgets.Add(btn); + } + } + break; + + case TOKEN_STATIC: { + CUIText *text = new CUIText(Game); + if (!text || FAILED(text->LoadBuffer(params, false))) { + delete text; + text = NULL; + cmd = PARSERR_GENERIC; + } else { + text->_parent = this; + _widgets.Add(text); + } + } + break; + + case TOKEN_EDIT: { + CUIEdit *edit = new CUIEdit(Game); + if (!edit || FAILED(edit->LoadBuffer(params, false))) { + delete edit; + edit = NULL; + cmd = PARSERR_GENERIC; + } else { + edit->_parent = this; + _widgets.Add(edit); + } + } + break; + + case TOKEN_WINDOW: { + CUIWindow *win = new CUIWindow(Game); + if (!win || FAILED(win->LoadBuffer(params, false))) { + delete win; + win = NULL; + cmd = PARSERR_GENERIC; + } else { + win->_parent = this; + _widgets.Add(win); + } + } + break; + + + case TOKEN_TRANSPARENT: + parser.ScanStr((char *)params, "%b", &_transparent); + break; + + case TOKEN_SCRIPT: + AddScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.ScanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_PAUSE_MUSIC: + parser.ScanStr((char *)params, "%b", &_pauseMusic); + break; + + case TOKEN_DISABLED: + parser.ScanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.ScanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_MENU: + parser.ScanStr((char *)params, "%b", &_isMenu); + break; + + case TOKEN_IN_GAME: + parser.ScanStr((char *)params, "%b", &_inGame); + break; + + case TOKEN_CLIP_CONTENTS: + parser.ScanStr((char *)params, "%b", &_clipContents); + break; + + case TOKEN_FADE_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); + _fadeBackground = true; + break; + + case TOKEN_FADE_ALPHA: + parser.ScanStr((char *)params, "%d", &FadeA); + _fadeBackground = true; + break; + + case TOKEN_EDITOR_PROPERTY: + ParseEditorProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.ScanStr((char *)params, "%d", &alpha); + break; + + + default: + if (FAILED(Game->WindowLoadHook(this, (char **)&Buffer, (char **)params))) { + cmd = PARSERR_GENERIC; + } + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in WINDOW definition"); + return E_FAIL; + } + if (cmd == PARSERR_GENERIC) { + Game->LOG(0, "Error loading WINDOW definition"); + return E_FAIL; + } + + CorrectSize(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = DRGBA(ar, ag, ab, alpha); + + if (_fadeBackground) _fadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); + + _focusedWidget = NULL; + + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { + Buffer->PutTextIndent(Indent, "WINDOW\n"); + Buffer->PutTextIndent(Indent, "{\n"); + + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_back && _back->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backInactive && _backInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + + if (_image && _image->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageInactive && _imageInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + + if (_font && _font->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontInactive && _fontInactive->_filename) + Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + + if (_cursor && _cursor->_filename) + Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_text) + Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); + + switch (_titleAlign) { + case TAL_LEFT: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); + } + + if (!CBPlatform::IsRectEmpty(&_titleRect)) { + Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + } + + if (!CBPlatform::IsRectEmpty(&_dragRect)) { + Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + + Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + if (_fadeBackground) { + Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); + Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); + } + + Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.GetSize(); i++) { + Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + Buffer->PutTextIndent(Indent + 2, "\n"); + + // editor properties + CBBase::SaveAsText(Buffer, Indent + 2); + + // controls + for (int i = 0; i < _widgets.GetSize(); i++) + _widgets[i]->SaveAsText(Buffer, Indent + 2); + + + Buffer->PutTextIndent(Indent, "}\n"); + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::EnableWidget(const char *Name, bool Enable) { + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; + } + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { + ////////////////////////////////////////////////////////////////////////// + // GetWidget / GetControl + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "GetWidget") == 0 || strcmp(Name, "GetControl") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + if (val->GetType() == VAL_INT) { + int widget = val->GetInt(); + if (widget < 0 || widget >= _widgets.GetSize()) Stack->PushNULL(); + else Stack->PushNative(_widgets[widget], true); + } else { + for (int i = 0; i < _widgets.GetSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { + Stack->PushNative(_widgets[i], true); + return S_OK; + } + } + Stack->PushNULL(); + } + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInactiveFont") == 0) { + Stack->CorrectParams(1); + + if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + _fontInactive = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); + Stack->PushBool(_fontInactive != NULL); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SetInactiveImage") == 0) { + Stack->CorrectParams(1); + + delete _imageInactive; + _imageInactive = new CBSprite(Game); + const char *Filename = Stack->Pop()->GetString(); + if (!_imageInactive || FAILED(_imageInactive->LoadFile(Filename))) { + delete _imageInactive; + _imageInactive = NULL; + Stack->PushBool(false); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInactiveImage") == 0) { + Stack->CorrectParams(0); + if (!_imageInactive || !_imageInactive->_filename) Stack->PushNULL(); + else Stack->PushString(_imageInactive->_filename); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GetInactiveImageObject") == 0) { + Stack->CorrectParams(0); + if (!_imageInactive) Stack->PushNULL(); + else Stack->PushNative(_imageInactive, true); + + return S_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Close") == 0) { + Stack->CorrectParams(0); + Stack->PushBool(SUCCEEDED(Close())); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoExclusive") == 0) { + Stack->CorrectParams(0); + GoExclusive(); + Script->WaitFor(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoSystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "GoSystemExclusive") == 0) { + Stack->CorrectParams(0); + GoSystemExclusive(); + Script->WaitFor(this); + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Center + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Center") == 0) { + Stack->CorrectParams(0); + _posX = (Game->_renderer->_width - _width) / 2; + _posY = (Game->_renderer->_height - _height) / 2; + Stack->PushNULL(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadFromFile + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "LoadFromFile") == 0) { + Stack->CorrectParams(1); + + CScValue *Val = Stack->Pop(); + Cleanup(); + if (!Val->IsNULL()) { + Stack->PushBool(SUCCEEDED(LoadFile(Val->GetString()))); + } else Stack->PushBool(true); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateButton") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIButton *Btn = new CUIButton(Game); + if (!Val->IsNULL()) Btn->SetName(Val->GetString()); + Stack->PushNative(Btn, true); + + Btn->_parent = this; + _widgets.Add(Btn); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateStatic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateStatic") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIText *Sta = new CUIText(Game); + if (!Val->IsNULL()) Sta->SetName(Val->GetString()); + Stack->PushNative(Sta, true); + + Sta->_parent = this; + _widgets.Add(Sta); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEditor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateEditor") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIEdit *Edi = new CUIEdit(Game); + if (!Val->IsNULL()) Edi->SetName(Val->GetString()); + Stack->PushNative(Edi, true); + + Edi->_parent = this; + _widgets.Add(Edi); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "CreateWindow") == 0) { + Stack->CorrectParams(1); + CScValue *Val = Stack->Pop(); + + CUIWindow *Win = new CUIWindow(Game); + if (!Val->IsNULL()) Win->SetName(Val->GetString()); + Stack->PushNative(Win, true); + + Win->_parent = this; + _widgets.Add(Win); + + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "DeleteControl") == 0 || strcmp(Name, "DeleteButton") == 0 || strcmp(Name, "DeleteStatic") == 0 || strcmp(Name, "DeleteEditor") == 0 || strcmp(Name, "DeleteWindow") == 0) { + Stack->CorrectParams(1); + CScValue *val = Stack->Pop(); + CUIObject *obj = (CUIObject *)val->GetNative(); + + for (int i = 0; i < _widgets.GetSize(); i++) { + if (_widgets[i] == obj) { + delete _widgets[i]; + _widgets.RemoveAt(i); + if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + } + } + Stack->PushNULL(); + return S_OK; + } else if SUCCEEDED(Game->WindowScriptMethodHook(this, Script, Stack, Name)) return S_OK; + + else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIWindow::ScGetProperty(const char *Name) { + _scValue->SetNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Type") == 0) { + _scValue->SetString("window"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWidgets / NumControls (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "NumWidgets") == 0 || strcmp(Name, "NumControls") == 0) { + _scValue->SetInt(_widgets.GetSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exclusive") == 0) { + _scValue->SetBool(_mode == WINDOW_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SystemExclusive") == 0) { + _scValue->SetBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Menu") == 0) { + _scValue->SetBool(_isMenu); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InGame") == 0) { + _scValue->SetBool(_inGame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0) { + _scValue->SetBool(_pauseMusic); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClipContents") == 0) { + _scValue->SetBool(_clipContents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Transparent") == 0) { + _scValue->SetBool(_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeColor") == 0) { + _scValue->SetInt((int)_fadeColor); + return _scValue; + } + + else return CUIObject::ScGetProperty(Name); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(Name, "Name") == 0) { + SetName(Value->GetString()); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Menu") == 0) { + _isMenu = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "InGame") == 0) { + _inGame = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "PauseMusic") == 0) { + _pauseMusic = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "ClipContents") == 0) { + _clipContents = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Transparent") == 0) { + _transparent = Value->GetBool(); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "FadeColor") == 0) { + _fadeColor = (uint32)Value->GetInt(); + _fadeBackground = (_fadeColor != 0); + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "Exclusive") == 0) { + if (Value->GetBool()) + GoExclusive(); + else { + Close(); + _visible = true; + } + return S_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(Name, "SystemExclusive") == 0) { + if (Value->GetBool()) + GoSystemExclusive(); + else { + Close(); + _visible = true; + } + return S_OK; + } + + else return CUIObject::ScSetProperty(Name, Value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIWindow::ScToString() { + return "[window]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::HandleKeypress(SDL_Event *event) { +//TODO +#if 0 + if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { + return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); + } else { + if (_focusedWidget) return _focusedWidget->HandleKeypress(event); + else return false; + } +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::HandleMouseWheel(int Delta) { + if (_focusedWidget) return _focusedWidget->HandleMouseWheel(Delta); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { + HRESULT res = CUIObject::HandleMouse(Event, Button); + + // handle window dragging + if (!CBPlatform::IsRectEmpty(&_dragRect)) { + // start drag + if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { + RECT DragRect = _dragRect; + int OffsetX, OffsetY; + GetTotalOffset(&OffsetX, &OffsetY); + CBPlatform::OffsetRect(&DragRect, _posX + OffsetX, _posY + OffsetY); + + if (CBPlatform::PtInRect(&DragRect, Game->_mousePos)) { + _dragFrom.x = Game->_mousePos.x; + _dragFrom.y = Game->_mousePos.y; + _dragging = true; + } + } + // end drag + else if (_dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { + _dragging = false; + } + } + + return res; +} + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { + + CUIObject::Persist(PersistMgr); + + PersistMgr->Transfer(TMEMBER(_backInactive)); + PersistMgr->Transfer(TMEMBER(_clipContents)); + PersistMgr->Transfer(TMEMBER(_dragFrom)); + PersistMgr->Transfer(TMEMBER(_dragging)); + PersistMgr->Transfer(TMEMBER(_dragRect)); + PersistMgr->Transfer(TMEMBER(_fadeBackground)); + PersistMgr->Transfer(TMEMBER(_fadeColor)); + PersistMgr->Transfer(TMEMBER(_fontInactive)); + PersistMgr->Transfer(TMEMBER(_imageInactive)); + PersistMgr->Transfer(TMEMBER(_inGame)); + PersistMgr->Transfer(TMEMBER(_isMenu)); + PersistMgr->Transfer(TMEMBER_INT(_mode)); + PersistMgr->Transfer(TMEMBER(_shieldButton)); + PersistMgr->Transfer(TMEMBER(_shieldWindow)); + PersistMgr->Transfer(TMEMBER_INT(_titleAlign)); + PersistMgr->Transfer(TMEMBER(_titleRect)); + PersistMgr->Transfer(TMEMBER(_transparent)); + PersistMgr->Transfer(TMEMBER(_viewport)); + PersistMgr->Transfer(TMEMBER(_pauseMusic)); + + _widgets.Persist(PersistMgr); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::MoveFocus(bool Forward) { + int i; + bool found = false; + for (i = 0; i < _widgets.GetSize(); i++) { + if (_widgets[i] == _focusedWidget) { + found = true; + break; + } + } + if (!found) _focusedWidget = NULL; + + if (!_focusedWidget) { + if (_widgets.GetSize() > 0) i = 0; + else return S_OK; + } + + int NumTries = 0; + bool done = false; + + while (NumTries <= _widgets.GetSize()) { + if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + _focusedWidget = _widgets[i]; + done = true; + break; + } + + if (Forward) { + i++; + if (i >= _widgets.GetSize()) i = 0; + } else { + i--; + if (i < 0) i = _widgets.GetSize() - 1; + } + NumTries++; + } + + return done ? S_OK : E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GoExclusive() { + if (_mode == WINDOW_EXCLUSIVE) return S_OK; + + if (_mode == WINDOW_NORMAL) { + _ready = false; + _mode = WINDOW_EXCLUSIVE; + _visible = true; + _disable = false; + Game->FocusWindow(this); + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GoSystemExclusive() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; + + MakeFreezable(false); + + _mode = WINDOW_SYSTEM_EXCLUSIVE; + _ready = false; + _visible = true; + _disable = false; + Game->FocusWindow(this); + + Game->Freeze(_pauseMusic); + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Close() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { + Game->Unfreeze(); + } + + _mode = WINDOW_NORMAL; + _visible = false; + _ready = true; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) Close(); + else return CBObject::Listen(param1, param2); + break; + default: + return CBObject::Listen(param1, param2); + } + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::MakeFreezable(bool Freezable) { + for (int i = 0; i < _widgets.GetSize(); i++) + _widgets[i]->MakeFreezable(Freezable); + + CBObject::MakeFreezable(Freezable); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CUIWindow::GetWindowObjects(CBArray &Objects, bool InteractiveOnly) { + for (int i = 0; i < _widgets.GetSize(); i++) { + CUIObject *Control = _widgets[i]; + if (Control->_disable && InteractiveOnly) continue; + + switch (Control->_type) { + case UI_WINDOW: + ((CUIWindow *)Control)->GetWindowObjects(Objects, InteractiveOnly); + break; + + case UI_BUTTON: + case UI_EDIT: + Objects.Add(Control); + break; + + default: + if (!InteractiveOnly) Objects.Add(Control); + } + } + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h new file mode 100644 index 0000000000..510fc076b4 --- /dev/null +++ b/engines/wintermute/UI/UIWindow.h @@ -0,0 +1,92 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIWINDOW_H +#define WINTERMUTE_UIWINDOW_H + + +#include "UIObject.h" + +namespace WinterMute { + +class CUIButton; +class CBViewport; +class CUIWindow : public CUIObject { +public: + HRESULT GetWindowObjects(CBArray &Objects, bool InteractiveOnly); + + bool _pauseMusic; + void Cleanup(); + virtual void MakeFreezable(bool Freezable); + CBViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + uint32 _fadeColor; + virtual bool HandleMouseWheel(int Delta); + CUIWindow *_shieldWindow; + CUIButton *_shieldButton; + HRESULT Close(); + HRESULT GoSystemExclusive(); + HRESULT GoExclusive(); + TWindowMode _mode; + HRESULT MoveFocus(bool Forward = true); + virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + POINT _dragFrom; + bool _dragging; + DECLARE_PERSISTENT(CUIWindow, CUIObject) + bool _transparent; + HRESULT ShowWidget(const char *Name, bool Visible = true); + HRESULT EnableWidget(const char *Name, bool Enable = true); + RECT _titleRect; + RECT _dragRect; + virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + CUIWindow(CBGame *inGame); + virtual ~CUIWindow(); + virtual bool HandleKeypress(SDL_Event *event); + CBArray _widgets; + TTextAlign _titleAlign; + HRESULT LoadFile(const char *Filename); + HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + CUITiledImage *_backInactive; + CBFont *_fontInactive; + CBSprite *_imageInactive; + virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + + // scripting interface + virtual CScValue *ScGetProperty(const char *Name); + virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *ScToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UIButton.cpp b/engines/wintermute/UIButton.cpp deleted file mode 100644 index a81320217e..0000000000 --- a/engines/wintermute/UIButton.cpp +++ /dev/null @@ -1,1043 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/UIButton.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIButton, false) - -////////////////////////////////////////////////////////////////////////// -CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { - _backPress = _backHover = _backDisable = _backFocus = NULL; - - _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; - - _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; - - _align = TAL_CENTER; - - _hover = _press = false; - - _type = UI_BUTTON; - - _canFocus = false; - _stayPressed = false; - - _oneTimePress = false; - _centerImage = false; - - _pixelPerfect = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIButton::~CUIButton() { - if (_backPress) delete _backPress; - if (_backHover) delete _backHover; - if (_backDisable) delete _backDisable; - if (_backFocus) delete _backFocus; - - if (!_sharedFonts) { - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); - } - - if (!_sharedImages) { - if (_imageHover) delete _imageHover; - if (_imagePress) delete _imagePress; - if (_imageDisable) delete _imageDisable; - if (_imageFocus) delete _imageFocus; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(BUTTON) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(FOCUSABLE) -TOKEN_DEF(BACK_HOVER) -TOKEN_DEF(BACK_PRESS) -TOKEN_DEF(BACK_DISABLE) -TOKEN_DEF(BACK_FOCUS) -TOKEN_DEF(BACK) -TOKEN_DEF(CENTER_IMAGE) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE_PRESS) -TOKEN_DEF(IMAGE_DISABLE) -TOKEN_DEF(IMAGE_FOCUS) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT_PRESS) -TOKEN_DEF(FONT_DISABLE) -TOKEN_DEF(FONT_FOCUS) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(PRESSED) -TOKEN_DEF(PIXEL_PERFECT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(FOCUSABLE) - TOKEN_TABLE(BACK_HOVER) - TOKEN_TABLE(BACK_PRESS) - TOKEN_TABLE(BACK_DISABLE) - TOKEN_TABLE(BACK_FOCUS) - TOKEN_TABLE(BACK) - TOKEN_TABLE(CENTER_IMAGE) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE_PRESS) - TOKEN_TABLE(IMAGE_DISABLE) - TOKEN_TABLE(IMAGE_FOCUS) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT_PRESS) - TOKEN_TABLE(FONT_DISABLE) - TOKEN_TABLE(FONT_FOCUS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(PRESSED) - TOKEN_TABLE(PIXEL_PERFECT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { - Game->LOG(0, "'BUTTON' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_HOVER: - delete _backHover; - _backHover = new CUITiledImage(Game); - if (!_backHover || FAILED(_backHover->LoadFile((char *)params))) { - delete _backHover; - _backHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_PRESS: - delete _backPress; - _backPress = new CUITiledImage(Game); - if (!_backPress || FAILED(_backPress->LoadFile((char *)params))) { - delete _backPress; - _backPress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_DISABLE: - delete _backDisable; - _backDisable = new CUITiledImage(Game); - if (!_backDisable || FAILED(_backDisable->LoadFile((char *)params))) { - delete _backDisable; - _backDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_FOCUS: - delete _backFocus; - _backFocus = new CUITiledImage(Game); - if (!_backFocus || FAILED(_backFocus->LoadFile((char *)params))) { - delete _backFocus; - _backFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - delete _imageHover; - _imageHover = new CBSprite(Game); - if (!_imageHover || FAILED(_imageHover->LoadFile((char *)params))) { - delete _imageHover; - _imageHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_PRESS: - delete _imagePress; - _imagePress = new CBSprite(Game); - if (!_imagePress || FAILED(_imagePress->LoadFile((char *)params))) { - delete _imagePress; - _imagePress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_DISABLE: - delete _imageDisable; - _imageDisable = new CBSprite(Game); - if (!_imageDisable || FAILED(_imageDisable->LoadFile((char *)params))) { - delete _imageDisable; - _imageDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_FOCUS: - delete _imageFocus; - _imageFocus = new CBSprite(Game); - if (!_imageFocus || FAILED(_imageFocus->LoadFile((char *)params))) { - delete _imageFocus; - _imageFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - _fontHover = Game->_fontStorage->AddFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_PRESS: - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - _fontPress = Game->_fontStorage->AddFont((char *)params); - if (!_fontPress) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_DISABLE: - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - _fontDisable = Game->_fontStorage->AddFont((char *)params); - if (!_fontDisable) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_FOCUS: - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); - _fontFocus = Game->_fontStorage->AddFont((char *)params); - if (!_fontFocus) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - SetText((char *)params); - Game->_stringTable->Expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_CENTER; - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_FOCUSABLE: - parser.ScanStr((char *)params, "%b", &_canFocus); - break; - - case TOKEN_CENTER_IMAGE: - parser.ScanStr((char *)params, "%b", &_centerImage); - break; - - case TOKEN_PRESSED: - parser.ScanStr((char *)params, "%b", &_stayPressed); - break; - - case TOKEN_PIXEL_PERFECT: - parser.ScanStr((char *)params, "%b", &_pixelPerfect); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in BUTTON definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading BUTTON definition"); - return E_FAIL; - } - - CorrectSize(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "BUTTON\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backHover && _backHover->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); - if (_backPress && _backPress->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); - if (_backDisable && _backDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); - if (_backFocus && _backFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); - - if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageHover && _imageHover->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); - if (_imagePress && _imagePress->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); - if (_imageDisable && _imageDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); - if (_imageFocus && _imageFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - if (_fontPress && _fontPress->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); - if (_fontDisable && _fontDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); - if (_fontFocus && _fontFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_align) { - case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - - - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUIButton::CorrectSize() { - RECT rect; - - CBSprite *img = NULL; - if (_image) img = _image; - else if (_imageDisable) img = _imageDisable; - else if (_imageHover) img = _imageHover; - else if (_imagePress) img = _imagePress; - else if (_imageFocus) img = _imageFocus; - - if (_width <= 0) { - if (img) { - img->GetBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (img) { - img->GetBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_text) { - int text_height; - if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); - else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); - - if (text_height > _height) _height = text_height; - } - - if (_height <= 0) _height = 100; - - if (_back) _back->CorrectSize(&_width, &_height); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::Display(int OffsetX, int OffsetY) { - if (!_visible) return S_OK; - - CUITiledImage *back = NULL; - CBSprite *image = NULL; - CBFont *font = 0; - - //RECT rect; - //CBPlatform::SetRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::PtInRect(&rect, Game->_mousePos)!=FALSE); - _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); - - if ((_press && _hover && !Game->_mouseLeftDown) || - (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) Press(); - - - if (_disable) { - if (_backDisable) back = _backDisable; - if (_imageDisable) image = _imageDisable; - if (_text && _fontDisable) font = _fontDisable; - } else if (_press || _oneTimePress || _stayPressed) { - if (_backPress) back = _backPress; - if (_imagePress) image = _imagePress; - if (_text && _fontPress) font = _fontPress; - } else if (_hover) { - if (_backHover) back = _backHover; - if (_imageHover) image = _imageHover; - if (_text && _fontHover) font = _fontHover; - } else if (_canFocus && IsFocused()) { - if (_backFocus) back = _backFocus; - if (_imageFocus) image = _imageFocus; - if (_text && _fontFocus) font = _fontFocus; - } - - if (!back && _back) back = _back; - if (!image && _image) image = _image; - if (_text && !font) { - if (_font) font = _font; - else font = Game->_systemFont; - } - - int ImageX = OffsetX + _posX; - int ImageY = OffsetY + _posY; - - if (image && _centerImage) { - RECT rc; - image->GetBoundingRect(&rc, 0, 0); - ImageX += (_width - (rc.right - rc.left)) / 2; - ImageY += (_height - (rc.bottom - rc.top)) / 2; - } - - if (back) back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); - //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); - - if (font && _text) { - int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; - font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); - } - - if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - // reset unused sprites - if (_image && _image != image) _image->Reset(); - if (_imageDisable && _imageDisable != image) _imageDisable->Reset(); - if (_imageFocus && _imageFocus != image) _imageFocus->Reset(); - if (_imagePress && _imagePress != image) _imagePress->Reset(); - if (_imageHover && _imageHover != image) _imageHover->Reset(); - - _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIButton::Press() { - ApplyEvent("Press"); - if (_listenerObject) _listenerObject->Listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->ApplyEvent(_name); - - _oneTimePress = false; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetDisabledFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetDisabledFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - if (Val->IsNULL()) { - _fontDisable = NULL; - Stack->PushBool(true); - } else { - _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontDisable != NULL); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHoverFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - if (Val->IsNULL()) { - _fontHover = NULL; - Stack->PushBool(true); - } else { - _fontHover = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontHover != NULL); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPressedFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - if (Val->IsNULL()) { - _fontPress = NULL; - Stack->PushBool(true); - } else { - _fontPress = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontPress != NULL); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFocusedFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); - if (Val->IsNULL()) { - _fontFocus = NULL; - Stack->PushBool(true); - } else { - _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontFocus != NULL); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDisabledImage") == 0) { - Stack->CorrectParams(1); - - delete _imageDisable; - _imageDisable = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); - if (!_imageDisable || FAILED(_imageDisable->LoadFile(Filename))) { - delete _imageDisable; - _imageDisable = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDisabledImage") == 0) { - Stack->CorrectParams(0); - if (!_imageDisable || !_imageDisable->_filename) Stack->PushNULL(); - else Stack->PushString(_imageDisable->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDisabledImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageDisable) Stack->PushNULL(); - else Stack->PushNative(_imageDisable, true); - - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHoverImage") == 0) { - Stack->CorrectParams(1); - - delete _imageHover; - _imageHover = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); - if (!_imageHover || FAILED(_imageHover->LoadFile(Filename))) { - delete _imageHover; - _imageHover = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverImage") == 0) { - Stack->CorrectParams(0); - if (!_imageHover || !_imageHover->_filename) Stack->PushNULL(); - else Stack->PushString(_imageHover->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageHover) Stack->PushNULL(); - else Stack->PushNative(_imageHover, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPressedImage") == 0) { - Stack->CorrectParams(1); - - delete _imagePress; - _imagePress = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); - if (!_imagePress || FAILED(_imagePress->LoadFile(Filename))) { - delete _imagePress; - _imagePress = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPressedImage") == 0) { - Stack->CorrectParams(0); - if (!_imagePress || !_imagePress->_filename) Stack->PushNULL(); - else Stack->PushString(_imagePress->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPressedImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imagePress) Stack->PushNULL(); - else Stack->PushNative(_imagePress, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFocusedImage") == 0) { - Stack->CorrectParams(1); - - delete _imageFocus; - _imageFocus = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); - if (!_imageFocus || FAILED(_imageFocus->LoadFile(Filename))) { - delete _imageFocus; - _imageFocus = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFocusedImage") == 0) { - Stack->CorrectParams(0); - if (!_imageFocus || !_imageFocus->_filename) Stack->PushNULL(); - else Stack->PushString(_imageFocus->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFocusedImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageFocus) Stack->PushNULL(); - else Stack->PushNative(_imageFocus, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Press - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Press") == 0) { - Stack->CorrectParams(0); - - if (_visible && !_disable) { - _oneTimePress = true; - _oneTimePressTime = CBPlatform::GetTime(); - } - Stack->PushNULL(); - - return S_OK; - } - - - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("button"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextAlign") == 0) { - _scValue->SetInt(_align); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focusable") == 0) { - _scValue->SetBool(_canFocus); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pressed") == 0) { - _scValue->SetBool(_stayPressed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { - _scValue->SetBool(_pixelPerfect); - return _scValue; - } - - else return CUIObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "TextAlign") == 0) { - int i = Value->GetInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _align = (TTextAlign)i; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focusable") == 0) { - _canFocus = Value->GetBool(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pressed") == 0) { - _stayPressed = Value->GetBool(); - return S_OK; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { - _pixelPerfect = Value->GetBool(); - return S_OK; - } - - else return CUIObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIButton::ScToString() { - return "[button]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER_INT(_align)); - PersistMgr->Transfer(TMEMBER(_backDisable)); - PersistMgr->Transfer(TMEMBER(_backFocus)); - PersistMgr->Transfer(TMEMBER(_backHover)); - PersistMgr->Transfer(TMEMBER(_backPress)); - PersistMgr->Transfer(TMEMBER(_centerImage)); - PersistMgr->Transfer(TMEMBER(_fontDisable)); - PersistMgr->Transfer(TMEMBER(_fontFocus)); - PersistMgr->Transfer(TMEMBER(_fontHover)); - PersistMgr->Transfer(TMEMBER(_fontPress)); - PersistMgr->Transfer(TMEMBER(_hover)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_imageDisable)); - PersistMgr->Transfer(TMEMBER(_imageFocus)); - PersistMgr->Transfer(TMEMBER(_imageHover)); - PersistMgr->Transfer(TMEMBER(_imagePress)); - PersistMgr->Transfer(TMEMBER(_pixelPerfect)); - PersistMgr->Transfer(TMEMBER(_press)); - PersistMgr->Transfer(TMEMBER(_stayPressed)); - - if (!PersistMgr->_saving) { - _oneTimePress = false; - _oneTimePressTime = 0; - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIButton.h b/engines/wintermute/UIButton.h deleted file mode 100644 index 75133e2c0a..0000000000 --- a/engines/wintermute/UIButton.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIBUTTON_H -#define WINTERMUTE_UIBUTTON_H - - -#include "UIObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUIButton : public CUIObject { -public: - bool _pixelPerfect; - bool _stayPressed; - bool _centerImage; - bool _oneTimePress; - uint32 _oneTimePressTime; - DECLARE_PERSISTENT(CUIButton, CUIObject) - void Press(); - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - bool _press; - bool _hover; - void CorrectSize(); - TTextAlign _align; - CBSprite *_imageHover; - CBSprite *_imagePress; - CBSprite *_imageDisable; - CBSprite *_imageFocus; - CBFont *_fontDisable; - CBFont *_fontPress; - CBFont *_fontHover; - CBFont *_fontFocus; - CUITiledImage *_backPress; - CUITiledImage *_backHover; - CUITiledImage *_backDisable; - CUITiledImage *_backFocus; - CUIButton(CBGame *inGame = NULL); - virtual ~CUIButton(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UIEdit.cpp b/engines/wintermute/UIEdit.cpp deleted file mode 100644 index 00c91ba2e7..0000000000 --- a/engines/wintermute/UIEdit.cpp +++ /dev/null @@ -1,860 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/UIEdit.h" -#include "engines/wintermute/UIObject.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils.h" -#include "common/util.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEdit, false) - -////////////////////////////////////////////////////////////////////////// -CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { - _type = UI_EDIT; - - _fontSelected = NULL; - - _selStart = _selEnd = 10000; - _scrollOffset = 0; - - _cursorChar = NULL; - SetCursorChar("|"); - -#ifdef __WIN32__ - _cursorBlinkRate = GetCaretBlinkTime(); -#else - _cursorBlinkRate = 600; -#endif - _frameWidth = 0; - - SetText(""); - - _lastBlinkTime = 0; - _cursorVisible = true; - - _maxLength = -1; - - _canFocus = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEdit::~CUIEdit() { - if (!_sharedFonts) { - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - } - - delete[] _cursorChar; - _cursorChar = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_SELECTED) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR_BLINK_RATE) -TOKEN_DEF(CURSOR) -TOKEN_DEF(FRAME_WIDTH) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MAX_LENGTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF(CAPTION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_SELECTED) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR_BLINK_RATE) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(FRAME_WIDTH) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MAX_LENGTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDIT) { - Game->LOG(0, "'EDIT' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_SELECTED: - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont((char *)params); - if (!_fontSelected) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - SetText((char *)params); - Game->_stringTable->Expand(&_text); - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); - break; - - case TOKEN_MAX_LENGTH: - parser.ScanStr((char *)params, "%d", &_maxLength); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_BLINK_RATE: - parser.ScanStr((char *)params, "%d", &_cursorBlinkRate); - break; - - case TOKEN_FRAME_WIDTH: - parser.ScanStr((char *)params, "%d", &_frameWidth); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in EDIT definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading EDIT definition"); - return E_FAIL; - } - - CorrectSize(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "EDIT\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontSelected && _fontSelected->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); - Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); - Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetSelectedFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSelectedFont") == 0) { - Stack->CorrectParams(1); - - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(_fontSelected != NULL); - - return S_OK; - } - - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("editor"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelStart") == 0) { - _scValue->SetInt(_selStart); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelEnd") == 0) { - _scValue->SetInt(_selEnd); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorBlinkRate") == 0) { - _scValue->SetInt(_cursorBlinkRate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorChar") == 0) { - _scValue->SetString(_cursorChar); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FrameWidth") == 0) { - _scValue->SetInt(_frameWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxLength") == 0) { - _scValue->SetInt(_maxLength); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::AnsiToWide(_text); - _scValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); - } else { - _scValue->SetString(_text); - } - return _scValue; - } - - else return CUIObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SelStart") == 0) { - _selStart = Value->GetInt(); - _selStart = MAX(_selStart, 0); - _selStart = MIN((size_t)_selStart, strlen(_text)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelEnd") == 0) { - _selEnd = Value->GetInt(); - _selEnd = MAX(_selEnd, 0); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorChar") == 0) { - SetCursorChar(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FrameWidth") == 0) { - _frameWidth = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxLength") == 0) { - _maxLength = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); - SetText(StringUtil::WideToAnsi(wstr).c_str()); - } else { - SetText(Value->GetString()); - } - return S_OK; - } - - else return CUIObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEdit::ScToString() { - return "[edit]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIEdit::SetCursorChar(const char *Char) { - if (!Char) return; - delete[] _cursorChar; - _cursorChar = new char [strlen(Char) + 1]; - if (_cursorChar) strcpy(_cursorChar, Char); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { - if (!_visible) return S_OK; - - - // hack! - TTextEncoding OrigEncoding = Game->_textEncoding; - Game->_textEncoding = TEXT_ANSI; - - if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); - - // prepare fonts - CBFont *font; - CBFont *sfont; - - if (_font) font = _font; - else font = Game->_systemFont; - - if (_fontSelected) sfont = _fontSelected; - else sfont = font; - - bool focused = IsFocused(); - - _selStart = MAX(_selStart, 0); - _selEnd = MAX(_selEnd, 0); - - _selStart = MIN((size_t)_selStart, strlen(_text)); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - - //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int CursorWidth = font->GetTextWidth((byte *)_cursorChar); - - int s1, s2; - bool CurFirst; - // modify scroll offset - if (_selStart >= _selEnd) { - while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selEnd; - s2 = _selStart; - CurFirst = true; - } else { - while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + - sfont->GetTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - - > _width - CursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selStart; - s2 = _selEnd; - CurFirst = false; - } - - - int AlignOffset = 0; - - for (int Count = 0; Count < 2; Count++) { - // draw text - int xxx, yyy, width, height; - - xxx = _posX + _frameWidth + OffsetX; - yyy = _posY + _frameWidth + OffsetY; - - width = _posX + _width + OffsetX - _frameWidth; - height = MAX(font->GetLetterHeight(), sfont->GetLetterHeight()); - - if (Game->_textRTL) xxx += AlignOffset; - - TTextAlign Align = TAL_LEFT; - - - // unselected 1 - if (s1 > _scrollOffset) { - if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); - xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - } - - // cursor - if (focused && CurFirst) { - if (Count) { - if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::GetTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += CursorWidth; - AlignOffset += CursorWidth; - } - - // selected - int s3 = MAX(s1, _scrollOffset); - - if (s2 - s3 > 0) { - if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); - } - - // cursor - if (focused && !CurFirst) { - if (Count) { - if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::GetTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += CursorWidth; - AlignOffset += CursorWidth; - } - - // unselected 2 - if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->GetTextWidth((byte *)_text + s2); - - AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; - if (AlignOffset < 0) AlignOffset = 0; - } - - - Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - - Game->_textEncoding = OrigEncoding; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::HandleKeypress(Common::Event *event) { - bool Handled = false; - - if (event->type == Common::EVENT_KEYDOWN) { - switch (event->kbd.keycode) { - case Common::KEYCODE_ESCAPE: - case Common::KEYCODE_TAB: - case Common::KEYCODE_RETURN: - return false; - - // ctrl+A - case Common::KEYCODE_a: - if (CBKeyboardState::IsControlDown()) { - _selStart = 0; - _selEnd = strlen(_text); - Handled = true; - } - break; - - case Common::KEYCODE_BACKSPACE: - if (_selStart == _selEnd) { - if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); - else DeleteChars(_selStart - 1, _selStart); - } else DeleteChars(_selStart, _selEnd); - if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); - _selStart = _selEnd; - - Handled = true; - break; - - case Common::KEYCODE_LEFT: - case Common::KEYCODE_UP: - _selEnd--; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - Handled = true; - break; - - case Common::KEYCODE_RIGHT: - case Common::KEYCODE_DOWN: - _selEnd++; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - Handled = true; - break; - - case Common::KEYCODE_HOME: - if (Game->_textRTL) { - _selEnd = strlen(_text); - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - } else { - _selEnd = 0; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - } - Handled = true; - break; - - case Common::KEYCODE_END: - if (Game->_textRTL) { - _selEnd = 0; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - } else { - _selEnd = strlen(_text); - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; - } - Handled = true; - break; - - case Common::KEYCODE_DELETE: - if (_selStart == _selEnd) { - if (Game->_textRTL) { - DeleteChars(_selStart - 1, _selStart); - _selEnd--; - if (_selEnd < 0) _selEnd = 0; - } else DeleteChars(_selStart, _selStart + 1); - } else DeleteChars(_selStart, _selEnd); - if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); - - _selStart = _selEnd; - Handled = true; - break; - default: - break; - } - return Handled; - } -#if 0 - else if (event->type == SDL_TEXTINPUT) { - if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); - - WideString wstr = StringUtil::Utf8ToWide(event->text.text); - _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); - - if (Game->_textRTL) _selEnd = _selStart; - else _selStart = _selEnd; - - return true; - } -#endif - return false; -} - - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::DeleteChars(int Start, int End) { - if (Start > End) CBUtils::Swap(&Start, &End); - - Start = MAX(Start, (int)0); - End = MIN((size_t)End, strlen(_text)); - - char *str = new char[strlen(_text) - (End - Start) + 1]; - if (str) { - if (Start > 0) memcpy(str, _text, Start); - memcpy(str + MAX(0, Start), _text + End, strlen(_text) - End + 1); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->ApplyEvent(_name); - - return End - Start; -} - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { - if (strlen(_text) + Num > _maxLength) { - Num -= (strlen(_text) + Num - _maxLength); - } - - Pos = MAX(Pos, (int)0); - Pos = MIN((size_t)Pos, strlen(_text)); - - char *str = new char[strlen(_text) + Num + 1]; - if (str) { - if (Pos > 0) memcpy(str, _text, Pos); - memcpy(str + Pos + Num, _text + Pos, strlen(_text) - Pos + 1); - - memcpy(str + Pos, Chars, Num); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->ApplyEvent(_name); - - return Num; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_cursorBlinkRate)); - PersistMgr->Transfer(TMEMBER(_cursorChar)); - PersistMgr->Transfer(TMEMBER(_fontSelected)); - PersistMgr->Transfer(TMEMBER(_frameWidth)); - PersistMgr->Transfer(TMEMBER(_maxLength)); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_selEnd)); - PersistMgr->Transfer(TMEMBER(_selStart)); - - if (!PersistMgr->_saving) { - _cursorVisible = false; - _lastBlinkTime = 0; - } - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIEdit.h b/engines/wintermute/UIEdit.h deleted file mode 100644 index 3b8698d55d..0000000000 --- a/engines/wintermute/UIEdit.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIEDIT_H -#define WINTERMUTE_UIEDIT_H - -#include "engines/wintermute/persistent.h" -#include "UIObject.h" -#include "common/events.h" - -namespace WinterMute { -class CBFont; -class CUIEdit : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEdit, CUIObject) - int _maxLength; - int InsertChars(int Pos, byte *Chars, int Num); - int DeleteChars(int Start, int End); - bool _cursorVisible; - uint32 _lastBlinkTime; - virtual HRESULT Display(int OffsetX, int OffsetY); - virtual bool HandleKeypress(Common::Event *event); - int _scrollOffset; - int _frameWidth; - uint32 _cursorBlinkRate; - void SetCursorChar(const char *Char); - char *_cursorChar; - int _selEnd; - int _selStart; - CBFont *_fontSelected; - CUIEdit(CBGame *inGame); - virtual ~CUIEdit(); - - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UIEntity.cpp b/engines/wintermute/UIEntity.cpp deleted file mode 100644 index a864f7cbea..0000000000 --- a/engines/wintermute/UIEntity.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/UIEntity.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEntity, false) - -////////////////////////////////////////////////////////////////////////// -CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { - _type = UI_CUSTOM; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEntity::~CUIEntity() { - if (_entity) Game->UnregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(NAME) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { - Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_ENTITY: - if (FAILED(SetEntity((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); - return E_FAIL; - } - - CorrectSize(); - - if (Game->_editorMode) { - _width = 50; - _height = 50; - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - - if (_entity && _entity->_filename) - Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::SetEntity(const char *Filename) { - if (_entity) Game->UnregisterObject(_entity); - _entity = new CAdEntity(Game); - if (!_entity || FAILED(_entity->LoadFile(Filename))) { - delete _entity; - _entity = NULL; - return E_FAIL; - } else { - _entity->_nonIntMouseEvents = true; - _entity->_sceneIndependent = true; - _entity->MakeFreezable(false); - Game->RegisterObject(_entity); - } - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { - if (!_visible) return S_OK; - - if (_entity) { - _entity->_posX = OffsetX + _posX; - _entity->_posY = OffsetY + _posY; - if (_entity->_scale < 0) _entity->_zoomable = false; - _entity->_shadowable = false; - - _entity->Update(); - - bool OrigReg = _entity->_registrable; - - if (_entity->_registrable && _disable) _entity->_registrable = false; - - _entity->Display(); - _entity->_registrable = OrigReg; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // GetEntity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetEntity") == 0) { - Stack->CorrectParams(0); - - if (_entity) Stack->PushNative(_entity, true); - else Stack->PushNULL(); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetEntity") == 0) { - Stack->CorrectParams(1); - - const char *Filename = Stack->Pop()->GetString(); - - if (SUCCEEDED(SetEntity(Filename))) - Stack->PushBool(true); - else - Stack->PushBool(false); - - return S_OK; - } - - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("entity container"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Freezable") == 0) { - if (_entity) _scValue->SetBool(_entity->_freezable); - else _scValue->SetBool(false); - return _scValue; - } - - else return CUIObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Freezable") == 0) { - if (_entity) _entity->MakeFreezable(Value->GetBool()); - return S_OK; - } else return CUIObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEntity::ScToString() { - return "[entity container]"; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_entity)); - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIEntity.h b/engines/wintermute/UIEntity.h deleted file mode 100644 index c18fd952dc..0000000000 --- a/engines/wintermute/UIEntity.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIENTITY_H -#define WINTERMUTE_UIENTITY_H - -#include "UIObject.h" - -namespace WinterMute { -class CAdEntity; -class CUIEntity : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEntity, CUIObject) - CUIEntity(CBGame *inGame); - virtual ~CUIEntity(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - CAdEntity *_entity; - HRESULT SetEntity(const char *Filename); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UIObject.cpp b/engines/wintermute/UIObject.cpp deleted file mode 100644 index 2bb860da3e..0000000000 --- a/engines/wintermute/UIObject.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/UIObject.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BFontStorage.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIObject, false) - -////////////////////////////////////////////////////////////////////////// -CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { - _back = NULL; - _image = NULL; - _font = NULL; - _text = NULL; - _sharedFonts = _sharedImages = false; - - _width = _height = 0; - - _listenerObject = NULL; - _listenerParamObject = NULL; - _listenerParamDWORD = 0; - - _disable = false; - _visible = true; - - _type = UI_UNKNOWN; - _parent = NULL; - - _parentNotify = false; - - _focusedWidget = NULL; - - _canFocus = false; - _nonIntMouseEvents = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIObject::~CUIObject() { - if (!Game->_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); - - if (_back) delete _back; - if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); - - if (_image && !_sharedImages) delete _image; - - if (_text) delete [] _text; - - _focusedWidget = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::SetText(const char *Text) { - if (_text) delete [] _text; - _text = new char [strlen(Text) + 1]; - if (_text) { - strcpy(_text, Text); - for (int i = 0; i < strlen(_text); i++) { - if (_text[i] == '|') _text[i] = '\n'; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Display(int OffsetX, int OffsetY) { - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { - _listenerObject = Object; - _listenerParamObject = ListenerObject; - _listenerParamDWORD = ListenerParam; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::CorrectSize() { - RECT rect; - - if (_width <= 0) { - if (_image) { - _image->GetBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (_image) { - _image->GetBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_back) _back->CorrectSize(&_width, &_height); -} - - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - if (_font) Game->_fontStorage->RemoveFont(_font); - if (Val->IsNULL()) { - _font = NULL; - Stack->PushBool(true); - } else { - _font = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_font != NULL); - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetImage") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - const char *Filename = Val->GetString(); - - delete _image; - _image = NULL; - if (Val->IsNULL()) { - Stack->PushBool(true); - return S_OK; - } - - _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile(Val->GetString()))) { - delete _image; - _image = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetImage") == 0) { - Stack->CorrectParams(0); - if (!_image || !_image->_filename) Stack->PushNULL(); - else Stack->PushString(_image->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetImageObject") == 0) { - Stack->CorrectParams(0); - if (!_image) Stack->PushNULL(); - else Stack->PushNative(_image, true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focus - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focus") == 0) { - Stack->CorrectParams(0); - Focus(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveAfter / MoveBefore - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveAfter") == 0 || strcmp(Name, "MoveBefore") == 0) { - Stack->CorrectParams(1); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - - int i; - bool found = false; - CScValue *val = Stack->Pop(); - // find directly - if (val->IsNative()) { - CUIObject *widget = (CUIObject *)val->GetNative(); - for (i = 0; i < win->_widgets.GetSize(); i++) { - if (win->_widgets[i] == widget) { - found = true; - break; - } - } - } - // find by name - else { - const char *name = val->GetString(); - for (i = 0; i < win->_widgets.GetSize(); i++) { - if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { - found = true; - break; - } - } - } - - if (found) { - bool done = false; - for (int j = 0; j < win->_widgets.GetSize(); j++) { - if (win->_widgets[j] == this) { - if (strcmp(Name, "MoveAfter") == 0) i++; - if (j >= i) j++; - - win->_widgets.InsertAt(i, this); - win->_widgets.RemoveAt(j); - - done = true; - Stack->PushBool(true); - break; - } - } - if (!done) Stack->PushBool(false); - } else Stack->PushBool(false); - - } else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToBottom - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveToBottom") == 0) { - Stack->CorrectParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.RemoveAt(i); - win->_widgets.InsertAt(0, this); - break; - } - } - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToTop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveToTop") == 0) { - Stack->CorrectParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.RemoveAt(i); - win->_widgets.Add(this); - break; - } - } - Stack->PushBool(true); - } else Stack->PushBool(false); - - return S_OK; - } - - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("ui_object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - _scValue->SetString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Parent (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Parent") == 0) { - _scValue->SetNative(_parent, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParentNotify") == 0) { - _scValue->SetBool(_parentNotify); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _scValue->SetInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _scValue->SetInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Visible") == 0) { - _scValue->SetBool(_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Disabled") == 0) { - _scValue->SetBool(_disable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { - _scValue->SetString(_text); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NextSibling (RO) / PrevSibling (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NextSibling") == 0 || strcmp(Name, "PrevSibling") == 0) { - _scValue->SetNULL(); - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { - if (win->_widgets[i] == this) { - if (strcmp(Name, "NextSibling") == 0) { - if (i < win->_widgets.GetSize() - 1) _scValue->SetNative(win->_widgets[i + 1], true); - } else { - if (i > 0) _scValue->SetNative(win->_widgets[i - 1], true); - } - break; - } - } - } - return _scValue; - } - - else return CBObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParentNotify") == 0) { - _parentNotify = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { - _width = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { - _height = Value->GetInt(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Visible") == 0) { - _visible = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Disabled") == 0) { - _disable = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { - SetText(Value->GetString()); - return S_OK; - } - - else return CBObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIObject::ScToString() { - return "[ui_object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::IsFocused() { - if (!Game->_focusedWindow) return false; - if (Game->_focusedWindow == this) return true; - - CUIObject *obj = Game->_focusedWindow; - while (obj) { - if (obj == this) return true; - else obj = obj->_focusedWidget; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { - // handle focus change - if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { - Focus(); - } - return CBObject::HandleMouse(Event, Button); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Focus() { - CUIObject *obj = this; - bool disabled = false; - while (obj) { - if (obj->_disable && obj->_type == UI_WINDOW) { - disabled = true; - break; - } - obj = obj->_parent; - } - if (!disabled) { - obj = this; - while (obj) { - if (obj->_parent) { - if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; - } else { - if (obj->_type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); - } - - obj = obj->_parent; - } - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { - int OffX = 0, OffY = 0; - - CUIObject *obj = _parent; - while (obj) { - OffX += obj->_posX; - OffY += obj->_posY; - - obj = obj->_parent; - } - if (OffsetX) *OffsetX = OffX; - if (OffsetY) *OffsetY = OffY; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_back)); - PersistMgr->Transfer(TMEMBER(_canFocus)); - PersistMgr->Transfer(TMEMBER(_disable)); - PersistMgr->Transfer(TMEMBER(_focusedWidget)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_listenerObject)); - PersistMgr->Transfer(TMEMBER(_listenerParamObject)); - PersistMgr->Transfer(TMEMBER(_listenerParamDWORD)); - PersistMgr->Transfer(TMEMBER(_parent)); - PersistMgr->Transfer(TMEMBER(_parentNotify)); - PersistMgr->Transfer(TMEMBER(_sharedFonts)); - PersistMgr->Transfer(TMEMBER(_sharedImages)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_visible)); - PersistMgr->Transfer(TMEMBER(_width)); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { - return E_FAIL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIObject.h b/engines/wintermute/UIObject.h deleted file mode 100644 index 7d6dfb41f5..0000000000 --- a/engines/wintermute/UIObject.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIOBJECT_H -#define WINTERMUTE_UIOBJECT_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUITiledImage; -class CBFont; -class CUIObject : public CBObject { -public: - - HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); - bool _canFocus; - HRESULT Focus(); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - bool IsFocused(); - bool _parentNotify; - DECLARE_PERSISTENT(CUIObject, CBObject) - CUIObject *_parent; - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - virtual void CorrectSize(); - bool _sharedFonts; - bool _sharedImages; - void SetText(const char *Text); - char *_text; - CBFont *_font; - bool _visible; - CUITiledImage *_back; - bool _disable; - CUIObject(CBGame *inGame = NULL); - virtual ~CUIObject(); - int _width; - int _height; - TUIObjectType _type; - CBSprite *_image; - void SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); - CBScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - CBScriptHolder *_listenerObject; - CUIObject *_focusedWidget; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UIText.cpp b/engines/wintermute/UIText.cpp deleted file mode 100644 index 64bb730fd4..0000000000 --- a/engines/wintermute/UIText.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/UIText.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIText, false) - -////////////////////////////////////////////////////////////////////////// -CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { - _textAlign = TAL_LEFT; - _verticalAlign = VAL_CENTER; - _type = UI_STATIC; - _canFocus = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIText::~CUIText() { - -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::Display(int OffsetX, int OffsetY) { - if (!_visible) return S_OK; - - - CBFont *font = _font; - if (!font) font = Game->_systemFont; - - if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); - - if (font && _text) { - int text_offset; - switch (_verticalAlign) { - case VAL_TOP: - text_offset = 0; - break; - case VAL_BOTTOM: - text_offset = _height - font->GetTextHeight((byte *)_text, _width); - break; - default: - text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; - } - font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); - } - - //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - return S_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(STATIC) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_STATIC) { - Game->LOG(0, "'STATIC' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - SetText((char *)params); - Game->_stringTable->Expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; - else _textAlign = TAL_CENTER; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; - else _verticalAlign = VAL_CENTER; - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in STATIC definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading STATIC definition"); - return E_FAIL; - } - - CorrectSize(); - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "STATIC\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_textAlign) { - case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CUIText::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // SizeToFit - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SizeToFit") == 0) { - Stack->CorrectParams(0); - SizeToFit(); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HeightToFit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HeightToFit") == 0) { - Stack->CorrectParams(0); - if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); - Stack->PushNULL(); - return S_OK; - } - - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("static"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextAlign") == 0) { - _scValue->SetInt(_textAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VerticalAlign") == 0) { - _scValue->SetInt(_verticalAlign); - return _scValue; - } - - else return CUIObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "TextAlign") == 0) { - int i = Value->GetInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _textAlign = (TTextAlign)i; - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VerticalAlign") == 0) { - int i = Value->GetInt(); - if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; - _verticalAlign = (TVerticalAlign)i; - return S_OK; - } - - else return CUIObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIText::ScToString() { - return "[static]"; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(_textAlign)); - PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::SizeToFit() { - if (_font && _text) { - _width = _font->GetTextWidth((byte *)_text); - _height = _font->GetTextHeight((byte *)_text, _width); - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIText.h b/engines/wintermute/UIText.h deleted file mode 100644 index 756834fd5c..0000000000 --- a/engines/wintermute/UIText.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITEXT_H -#define WINTERMUTE_UITEXT_H - - -#include "UIObject.h" - -namespace WinterMute { - -class CUIText : public CUIObject { -public: - HRESULT SizeToFit(); - virtual HRESULT Display(int OffsetX, int OffsetY); - DECLARE_PERSISTENT(CUIText, CUIObject) - CUIText(CBGame *inGame = NULL); - virtual ~CUIText(); - TTextAlign _textAlign; - TVerticalAlign _verticalAlign; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UITiledImage.cpp b/engines/wintermute/UITiledImage.cpp deleted file mode 100644 index 80618890f2..0000000000 --- a/engines/wintermute/UITiledImage.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUITiledImage, false) - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { - _image = NULL; - - CBPlatform::SetRectEmpty(&_upLeft); - CBPlatform::SetRectEmpty(&_upMiddle); - CBPlatform::SetRectEmpty(&_upRight); - CBPlatform::SetRectEmpty(&_middleLeft); - CBPlatform::SetRectEmpty(&_middleMiddle); - CBPlatform::SetRectEmpty(&_middleRight); - CBPlatform::SetRectEmpty(&_downLeft); - CBPlatform::SetRectEmpty(&_downMiddle); - CBPlatform::SetRectEmpty(&_downRight); -} - - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::~CUITiledImage() { - delete _image; - _image = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { - if (!_image) return E_FAIL; - - int tile_width = _middleMiddle.right - _middleMiddle.left; - int tile_height = _middleMiddle.bottom - _middleMiddle.top; - - int nu_columns = (Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; - int nu_rows = (Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; - - int col, row; - - Game->_renderer->StartSpriteBatch(); - - // top left/right - _image->_surface->DisplayTrans(X, Y, _upLeft); - _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); - - // bottom left/right - _image->_surface->DisplayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); - _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); - - // left/right - int yyy = Y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nu_rows; row++) { - _image->_surface->DisplayTrans(X, yyy, _middleLeft); - _image->_surface->DisplayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); - yyy += tile_width; - } - - // top/bottom - int xxx = X + (_upLeft.right - _upLeft.left); - for (col = 0; col < nu_columns; col++) { - _image->_surface->DisplayTrans(xxx, Y, _upMiddle); - _image->_surface->DisplayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); - xxx += tile_width; - } - - // tiles - yyy = Y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nu_rows; row++) { - xxx = X + (_upLeft.right - _upLeft.left); - for (col = 0; col < nu_columns; col++) { - _image->_surface->DisplayTrans(xxx, yyy, _middleMiddle); - xxx += tile_width; - } - yyy += tile_width; - } - - Game->_renderer->EndSpriteBatch(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); - - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TILED_IMAGE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(UP_MIDDLE) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(DOWN_MIDDLE) -TOKEN_DEF(MIDDLE_LEFT) -TOKEN_DEF(MIDDLE_RIGHT) -TOKEN_DEF(MIDDLE_MIDDLE) -TOKEN_DEF(VERTICAL_TILES) -TOKEN_DEF(HORIZONTAL_TILES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TILED_IMAGE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(UP_MIDDLE) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(DOWN_MIDDLE) - TOKEN_TABLE(MIDDLE_LEFT) - TOKEN_TABLE(MIDDLE_RIGHT) - TOKEN_TABLE(MIDDLE_MIDDLE) - TOKEN_TABLE(VERTICAL_TILES) - TOKEN_TABLE(HORIZONTAL_TILES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - bool HTiles = false, VTiles = false; - int H1 = 0, H2 = 0, H3 = 0; - int V1 = 0, V2 = 0, V3 = 0; - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { - Game->LOG(0, "'TILED_IMAGE' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSubFrame(Game); - if (!_image || FAILED(_image->SetSurface((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_UP_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); - break; - - case TOKEN_UP_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); - break; - - case TOKEN_UP_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); - break; - - case TOKEN_DOWN_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); - break; - - case TOKEN_DOWN_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); - break; - - case TOKEN_DOWN_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); - break; - - case TOKEN_MIDDLE_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); - break; - - case TOKEN_MIDDLE_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); - break; - - case TOKEN_MIDDLE_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); - break; - - case TOKEN_HORIZONTAL_TILES: - parser.ScanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); - HTiles = true; - break; - - case TOKEN_VERTICAL_TILES: - parser.ScanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); - VTiles = true; - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TILED_IMAGE definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading TILED_IMAGE definition"); - return E_FAIL; - } - - if (VTiles && HTiles) { - // up row - CBPlatform::SetRect(&_upLeft, 0, 0, H1, V1); - CBPlatform::SetRect(&_upMiddle, H1, 0, H1 + H2, V1); - CBPlatform::SetRect(&_upRight, H1 + H2, 0, H1 + H2 + H3, V1); - - // middle row - CBPlatform::SetRect(&_middleLeft, 0, V1, H1, V1 + V2); - CBPlatform::SetRect(&_middleMiddle, H1, V1, H1 + H2, V1 + V2); - CBPlatform::SetRect(&_middleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); - - // down row - CBPlatform::SetRect(&_downLeft, 0, V1 + V2, H1, V1 + V2 + V3); - CBPlatform::SetRect(&_downMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); - CBPlatform::SetRect(&_downRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); - } - - // default - if (_image && _image->_surface) { - int Width = _image->_surface->GetWidth() / 3; - int Height = _image->_surface->GetHeight() / 3; - - if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, Width, Height); - if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, Width, 0, 2 * Width, Height); - if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * Width, 0, 3 * Width, Height); - - if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, Height, Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, Width, Height, 2 * Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * Width, Height, 3 * Width, 2 * Height); - - if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * Height, Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, Width, 2 * Height, 2 * Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); - } - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - if (_image && _image->_surfaceFilename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); - - int H1, H2, H3; - int V1, V2, V3; - - H1 = _upLeft.right; - H2 = _upMiddle.right - _upMiddle.left; - H3 = _upRight.right - _upRight.left; - - V1 = _upLeft.bottom; - V2 = _middleLeft.bottom - _middleLeft.top; - V3 = _downLeft.bottom - _downLeft.top; - - - Buffer->PutTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); - Buffer->PutTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUITiledImage::CorrectSize(int *Width, int *Height) { - int tile_width = _middleMiddle.right - _middleMiddle.left; - int tile_height = _middleMiddle.bottom - _middleMiddle.top; - - int nu_columns = (*Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; - int nu_rows = (*Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; - - *Width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nu_columns * tile_width; - *Height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nu_rows * tile_height; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_downLeft)); - PersistMgr->Transfer(TMEMBER(_downMiddle)); - PersistMgr->Transfer(TMEMBER(_downRight)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_middleLeft)); - PersistMgr->Transfer(TMEMBER(_middleMiddle)); - PersistMgr->Transfer(TMEMBER(_middleRight)); - PersistMgr->Transfer(TMEMBER(_upLeft)); - PersistMgr->Transfer(TMEMBER(_upMiddle)); - PersistMgr->Transfer(TMEMBER(_upRight)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UITiledImage.h b/engines/wintermute/UITiledImage.h deleted file mode 100644 index 03d15a0daa..0000000000 --- a/engines/wintermute/UITiledImage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITILEDIMAGE_H -#define WINTERMUTE_UITILEDIMAGE_H - - -#include "UIObject.h" - -namespace WinterMute { -class CBSubFrame; -class CUITiledImage : public CBObject { -public: - DECLARE_PERSISTENT(CUITiledImage, CBObject) - void CorrectSize(int *Width, int *Height); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - HRESULT Display(int X, int Y, int Width, int Height); - CUITiledImage(CBGame *inGame = NULL); - virtual ~CUITiledImage(); - CBSubFrame *_image; - RECT _upLeft; - RECT _upMiddle; - RECT _upRight; - RECT _middleLeft; - RECT _middleMiddle; - RECT _middleRight; - RECT _downLeft; - RECT _downMiddle; - RECT _downRight; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UIWindow.cpp b/engines/wintermute/UIWindow.cpp deleted file mode 100644 index ac13170aaf..0000000000 --- a/engines/wintermute/UIWindow.cpp +++ /dev/null @@ -1,1321 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/UIWindow.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/UIButton.h" -#include "engines/wintermute/UIEdit.h" -#include "engines/wintermute/UIText.h" -#include "engines/wintermute/UITiledImage.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIWindow, false) - -////////////////////////////////////////////////////////////////////////// -CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::SetRectEmpty(&_titleRect); - CBPlatform::SetRectEmpty(&_dragRect); - _titleAlign = TAL_LEFT; - _transparent = false; - - _backInactive = NULL; - _fontInactive = NULL; - _imageInactive = NULL; - - _type = UI_WINDOW; - _canFocus = true; - - _dragging = false; - _dragFrom.x = _dragFrom.y = 0; - - _mode = WINDOW_NORMAL; - _shieldWindow = NULL; - _shieldButton = NULL; - - _fadeColor = 0x00000000; - _fadeBackground = false; - - _ready = true; - _isMenu = false; - _inGame = false; - - _clipContents = false; - _viewport = NULL; - - _pauseMusic = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIWindow::~CUIWindow() { - Close(); - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::Cleanup() { - delete _shieldWindow; - delete _shieldButton; - delete _viewport; - _shieldWindow = NULL; - _shieldButton = NULL; - _viewport = NULL; - - if (_backInactive) delete _backInactive; - if (!_sharedFonts && _fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - if (!_sharedImages && _imageInactive) delete _imageInactive; - - for (int i = 0; i < _widgets.GetSize(); i++) delete _widgets[i]; - _widgets.RemoveAll(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { - // go exclusive - if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; - - _shieldWindow->Display(); - } - } else if (_isMenu) { - if (!_shieldButton) { - _shieldButton = new CUIButton(Game); - _shieldButton->SetName("close"); - _shieldButton->SetListener(this, _shieldButton, 0); - _shieldButton->_parent = this; - } - if (_shieldButton) { - _shieldButton->_posX = _shieldButton->_posY = 0; - _shieldButton->_width = Game->_renderer->_width; - _shieldButton->_height = Game->_renderer->_height; - - _shieldButton->Display(); - } - } - - if (!_visible) return S_OK; - - if (_fadeBackground) Game->_renderer->FadeToColor(_fadeColor); - - if (_dragging) { - _posX += (Game->_mousePos.x - _dragFrom.x); - _posY += (Game->_mousePos.y - _dragFrom.y); - - _dragFrom.x = Game->_mousePos.x; - _dragFrom.y = Game->_mousePos.y; - } - - if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { - MoveFocus(); - } - - bool PopViewport = false; - if (_clipContents) { - if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) { - _viewport->SetRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); - Game->PushViewport(_viewport); - PopViewport = true; - } - } - - - CUITiledImage *back = _back; - CBSprite *image = _image; - CBFont *font = _font; - - if (!IsFocused()) { - if (_backInactive) back = _backInactive; - if (_imageInactive) image = _imageInactive; - if (_fontInactive) font = _fontInactive; - } - - if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; - if (back) back->Display(_posX + OffsetX, _posY + OffsetY, _width, _height); - if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); - - if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { - font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); - } - - if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); - - for (int i = 0; i < _widgets.GetSize(); i++) { - _widgets[i]->Display(_posX + OffsetX, _posY + OffsetY); - } - - if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; - - if (PopViewport) Game->PopViewport(); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WINDOW) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK_INACTIVE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE_INACTIVE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_INACTIVE) -TOKEN_DEF(FONT) -TOKEN_DEF(TITLE_ALIGN) -TOKEN_DEF(TITLE_RECT) -TOKEN_DEF(TITLE) -TOKEN_DEF(DRAG_RECT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(FADE_ALPHA) -TOKEN_DEF(FADE_COLOR) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(BUTTON) -TOKEN_DEF(STATIC) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MENU) -TOKEN_DEF(IN_GAME) -TOKEN_DEF(CLIP_CONTENTS) -TOKEN_DEF(PAUSE_MUSIC) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK_INACTIVE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE_INACTIVE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_INACTIVE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TITLE_ALIGN) - TOKEN_TABLE(TITLE_RECT) - TOKEN_TABLE(TITLE) - TOKEN_TABLE(DRAG_RECT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(FADE_ALPHA) - TOKEN_TABLE(FADE_COLOR) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MENU) - TOKEN_TABLE(IN_GAME) - TOKEN_TABLE(CLIP_CONTENTS) - TOKEN_TABLE(PAUSE_MUSIC) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(Game); - - int FadeR = 0, FadeG = 0, FadeB = 0, FadeA = 0; - int ar = 0, ag = 0, ab = 0, alpha = 0; - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { - Game->LOG(0, "'WINDOW' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_CAPTION: - SetCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_INACTIVE: - delete _backInactive; - _backInactive = new CUITiledImage(Game); - if (!_backInactive || FAILED(_backInactive->LoadFile((char *)params))) { - delete _backInactive; - _backInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_INACTIVE: - delete _imageInactive, - _imageInactive = new CBSprite(Game); - if (!_imageInactive || FAILED(_imageInactive->LoadFile((char *)params))) { - delete _imageInactive; - _imageInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_INACTIVE: - if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont((char *)params); - if (!_fontInactive) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TITLE: - SetText((char *)params); - Game->_stringTable->Expand(&_text); - break; - - case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; - else _titleAlign = TAL_CENTER; - break; - - case TOKEN_TITLE_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); - break; - - case TOKEN_DRAG_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); - break; - - case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BUTTON: { - CUIButton *btn = new CUIButton(Game); - if (!btn || FAILED(btn->LoadBuffer(params, false))) { - delete btn; - btn = NULL; - cmd = PARSERR_GENERIC; - } else { - btn->_parent = this; - _widgets.Add(btn); - } - } - break; - - case TOKEN_STATIC: { - CUIText *text = new CUIText(Game); - if (!text || FAILED(text->LoadBuffer(params, false))) { - delete text; - text = NULL; - cmd = PARSERR_GENERIC; - } else { - text->_parent = this; - _widgets.Add(text); - } - } - break; - - case TOKEN_EDIT: { - CUIEdit *edit = new CUIEdit(Game); - if (!edit || FAILED(edit->LoadBuffer(params, false))) { - delete edit; - edit = NULL; - cmd = PARSERR_GENERIC; - } else { - edit->_parent = this; - _widgets.Add(edit); - } - } - break; - - case TOKEN_WINDOW: { - CUIWindow *win = new CUIWindow(Game); - if (!win || FAILED(win->LoadBuffer(params, false))) { - delete win; - win = NULL; - cmd = PARSERR_GENERIC; - } else { - win->_parent = this; - _widgets.Add(win); - } - } - break; - - - case TOKEN_TRANSPARENT: - parser.ScanStr((char *)params, "%b", &_transparent); - break; - - case TOKEN_SCRIPT: - AddScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_PAUSE_MUSIC: - parser.ScanStr((char *)params, "%b", &_pauseMusic); - break; - - case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_MENU: - parser.ScanStr((char *)params, "%b", &_isMenu); - break; - - case TOKEN_IN_GAME: - parser.ScanStr((char *)params, "%b", &_inGame); - break; - - case TOKEN_CLIP_CONTENTS: - parser.ScanStr((char *)params, "%b", &_clipContents); - break; - - case TOKEN_FADE_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); - _fadeBackground = true; - break; - - case TOKEN_FADE_ALPHA: - parser.ScanStr((char *)params, "%d", &FadeA); - _fadeBackground = true; - break; - - case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); - break; - - - default: - if (FAILED(Game->WindowLoadHook(this, (char **)&Buffer, (char **)params))) { - cmd = PARSERR_GENERIC; - } - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in WINDOW definition"); - return E_FAIL; - } - if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading WINDOW definition"); - return E_FAIL; - } - - CorrectSize(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = DRGBA(ar, ag, ab, alpha); - - if (_fadeBackground) _fadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); - - _focusedWidget = NULL; - - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "WINDOW\n"); - Buffer->PutTextIndent(Indent, "{\n"); - - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backInactive && _backInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); - - if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageInactive && _imageInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); - - if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontInactive && _fontInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); - - if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_text) - Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); - - switch (_titleAlign) { - case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); - } - - if (!CBPlatform::IsRectEmpty(&_titleRect)) { - Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); - } - - if (!CBPlatform::IsRectEmpty(&_dragRect)) { - Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - if (_fadeBackground) { - Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); - Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); - } - - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - Buffer->PutTextIndent(Indent + 2, "\n"); - - // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); - - // controls - for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->SaveAsText(Buffer, Indent + 2); - - - Buffer->PutTextIndent(Indent, "}\n"); - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::EnableWidget(const char *Name, bool Enable) { - for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { - for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; - } - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { - ////////////////////////////////////////////////////////////////////////// - // GetWidget / GetControl - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetWidget") == 0 || strcmp(Name, "GetControl") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - if (val->GetType() == VAL_INT) { - int widget = val->GetInt(); - if (widget < 0 || widget >= _widgets.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_widgets[widget], true); - } else { - for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { - Stack->PushNative(_widgets[i], true); - return S_OK; - } - } - Stack->PushNULL(); - } - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInactiveFont") == 0) { - Stack->CorrectParams(1); - - if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(_fontInactive != NULL); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInactiveImage") == 0) { - Stack->CorrectParams(1); - - delete _imageInactive; - _imageInactive = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); - if (!_imageInactive || FAILED(_imageInactive->LoadFile(Filename))) { - delete _imageInactive; - _imageInactive = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInactiveImage") == 0) { - Stack->CorrectParams(0); - if (!_imageInactive || !_imageInactive->_filename) Stack->PushNULL(); - else Stack->PushString(_imageInactive->_filename); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInactiveImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageInactive) Stack->PushNULL(); - else Stack->PushNative(_imageInactive, true); - - return S_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Close") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(Close())); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoExclusive") == 0) { - Stack->CorrectParams(0); - GoExclusive(); - Script->WaitFor(this); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoSystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoSystemExclusive") == 0) { - Stack->CorrectParams(0); - GoSystemExclusive(); - Script->WaitFor(this); - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Center - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Center") == 0) { - Stack->CorrectParams(0); - _posX = (Game->_renderer->_width - _width) / 2; - _posY = (Game->_renderer->_height - _height) / 2; - Stack->PushNULL(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadFromFile - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadFromFile") == 0) { - Stack->CorrectParams(1); - - CScValue *Val = Stack->Pop(); - Cleanup(); - if (!Val->IsNULL()) { - Stack->PushBool(SUCCEEDED(LoadFile(Val->GetString()))); - } else Stack->PushBool(true); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateButton") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIButton *Btn = new CUIButton(Game); - if (!Val->IsNULL()) Btn->SetName(Val->GetString()); - Stack->PushNative(Btn, true); - - Btn->_parent = this; - _widgets.Add(Btn); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateStatic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateStatic") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIText *Sta = new CUIText(Game); - if (!Val->IsNULL()) Sta->SetName(Val->GetString()); - Stack->PushNative(Sta, true); - - Sta->_parent = this; - _widgets.Add(Sta); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEditor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEditor") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIEdit *Edi = new CUIEdit(Game); - if (!Val->IsNULL()) Edi->SetName(Val->GetString()); - Stack->PushNative(Edi, true); - - Edi->_parent = this; - _widgets.Add(Edi); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateWindow") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); - - CUIWindow *Win = new CUIWindow(Game); - if (!Val->IsNULL()) Win->SetName(Val->GetString()); - Stack->PushNative(Win, true); - - Win->_parent = this; - _widgets.Add(Win); - - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteControl") == 0 || strcmp(Name, "DeleteButton") == 0 || strcmp(Name, "DeleteStatic") == 0 || strcmp(Name, "DeleteEditor") == 0 || strcmp(Name, "DeleteWindow") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); - CUIObject *obj = (CUIObject *)val->GetNative(); - - for (int i = 0; i < _widgets.GetSize(); i++) { - if (_widgets[i] == obj) { - delete _widgets[i]; - _widgets.RemoveAt(i); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - } - } - Stack->PushNULL(); - return S_OK; - } else if SUCCEEDED(Game->WindowScriptMethodHook(this, Script, Stack, Name)) return S_OK; - - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::ScGetProperty(const char *Name) { - _scValue->SetNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { - _scValue->SetString("window"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWidgets / NumControls (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumWidgets") == 0 || strcmp(Name, "NumControls") == 0) { - _scValue->SetInt(_widgets.GetSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exclusive") == 0) { - _scValue->SetBool(_mode == WINDOW_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SystemExclusive") == 0) { - _scValue->SetBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Menu") == 0) { - _scValue->SetBool(_isMenu); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InGame") == 0) { - _scValue->SetBool(_inGame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0) { - _scValue->SetBool(_pauseMusic); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClipContents") == 0) { - _scValue->SetBool(_clipContents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Transparent") == 0) { - _scValue->SetBool(_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeColor") == 0) { - _scValue->SetInt((int)_fadeColor); - return _scValue; - } - - else return CUIObject::ScGetProperty(Name); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Menu") == 0) { - _isMenu = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InGame") == 0) { - _inGame = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0) { - _pauseMusic = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClipContents") == 0) { - _clipContents = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Transparent") == 0) { - _transparent = Value->GetBool(); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeColor") == 0) { - _fadeColor = (uint32)Value->GetInt(); - _fadeBackground = (_fadeColor != 0); - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exclusive") == 0) { - if (Value->GetBool()) - GoExclusive(); - else { - Close(); - _visible = true; - } - return S_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SystemExclusive") == 0) { - if (Value->GetBool()) - GoSystemExclusive(); - else { - Close(); - _visible = true; - } - return S_OK; - } - - else return CUIObject::ScSetProperty(Name, Value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIWindow::ScToString() { - return "[window]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleKeypress(SDL_Event *event) { -//TODO -#if 0 - if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { - return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); - } else { - if (_focusedWidget) return _focusedWidget->HandleKeypress(event); - else return false; - } -#endif - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleMouseWheel(int Delta) { - if (_focusedWidget) return _focusedWidget->HandleMouseWheel(Delta); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { - HRESULT res = CUIObject::HandleMouse(Event, Button); - - // handle window dragging - if (!CBPlatform::IsRectEmpty(&_dragRect)) { - // start drag - if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { - RECT DragRect = _dragRect; - int OffsetX, OffsetY; - GetTotalOffset(&OffsetX, &OffsetY); - CBPlatform::OffsetRect(&DragRect, _posX + OffsetX, _posY + OffsetY); - - if (CBPlatform::PtInRect(&DragRect, Game->_mousePos)) { - _dragFrom.x = Game->_mousePos.x; - _dragFrom.y = Game->_mousePos.y; - _dragging = true; - } - } - // end drag - else if (_dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { - _dragging = false; - } - } - - return res; -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_backInactive)); - PersistMgr->Transfer(TMEMBER(_clipContents)); - PersistMgr->Transfer(TMEMBER(_dragFrom)); - PersistMgr->Transfer(TMEMBER(_dragging)); - PersistMgr->Transfer(TMEMBER(_dragRect)); - PersistMgr->Transfer(TMEMBER(_fadeBackground)); - PersistMgr->Transfer(TMEMBER(_fadeColor)); - PersistMgr->Transfer(TMEMBER(_fontInactive)); - PersistMgr->Transfer(TMEMBER(_imageInactive)); - PersistMgr->Transfer(TMEMBER(_inGame)); - PersistMgr->Transfer(TMEMBER(_isMenu)); - PersistMgr->Transfer(TMEMBER_INT(_mode)); - PersistMgr->Transfer(TMEMBER(_shieldButton)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER_INT(_titleAlign)); - PersistMgr->Transfer(TMEMBER(_titleRect)); - PersistMgr->Transfer(TMEMBER(_transparent)); - PersistMgr->Transfer(TMEMBER(_viewport)); - PersistMgr->Transfer(TMEMBER(_pauseMusic)); - - _widgets.Persist(PersistMgr); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::MoveFocus(bool Forward) { - int i; - bool found = false; - for (i = 0; i < _widgets.GetSize(); i++) { - if (_widgets[i] == _focusedWidget) { - found = true; - break; - } - } - if (!found) _focusedWidget = NULL; - - if (!_focusedWidget) { - if (_widgets.GetSize() > 0) i = 0; - else return S_OK; - } - - int NumTries = 0; - bool done = false; - - while (NumTries <= _widgets.GetSize()) { - if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { - _focusedWidget = _widgets[i]; - done = true; - break; - } - - if (Forward) { - i++; - if (i >= _widgets.GetSize()) i = 0; - } else { - i--; - if (i < 0) i = _widgets.GetSize() - 1; - } - NumTries++; - } - - return done ? S_OK : E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GoExclusive() { - if (_mode == WINDOW_EXCLUSIVE) return S_OK; - - if (_mode == WINDOW_NORMAL) { - _ready = false; - _mode = WINDOW_EXCLUSIVE; - _visible = true; - _disable = false; - Game->FocusWindow(this); - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GoSystemExclusive() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; - - MakeFreezable(false); - - _mode = WINDOW_SYSTEM_EXCLUSIVE; - _ready = false; - _visible = true; - _disable = false; - Game->FocusWindow(this); - - Game->Freeze(_pauseMusic); - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Close() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - Game->Unfreeze(); - } - - _mode = WINDOW_NORMAL; - _visible = false; - _ready = true; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) Close(); - else return CBObject::Listen(param1, param2); - break; - default: - return CBObject::Listen(param1, param2); - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::MakeFreezable(bool Freezable) { - for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->MakeFreezable(Freezable); - - CBObject::MakeFreezable(Freezable); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GetWindowObjects(CBArray &Objects, bool InteractiveOnly) { - for (int i = 0; i < _widgets.GetSize(); i++) { - CUIObject *Control = _widgets[i]; - if (Control->_disable && InteractiveOnly) continue; - - switch (Control->_type) { - case UI_WINDOW: - ((CUIWindow *)Control)->GetWindowObjects(Objects, InteractiveOnly); - break; - - case UI_BUTTON: - case UI_EDIT: - Objects.Add(Control); - break; - - default: - if (!InteractiveOnly) Objects.Add(Control); - } - } - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UIWindow.h b/engines/wintermute/UIWindow.h deleted file mode 100644 index 510fc076b4..0000000000 --- a/engines/wintermute/UIWindow.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIWINDOW_H -#define WINTERMUTE_UIWINDOW_H - - -#include "UIObject.h" - -namespace WinterMute { - -class CUIButton; -class CBViewport; -class CUIWindow : public CUIObject { -public: - HRESULT GetWindowObjects(CBArray &Objects, bool InteractiveOnly); - - bool _pauseMusic; - void Cleanup(); - virtual void MakeFreezable(bool Freezable); - CBViewport *_viewport; - bool _clipContents; - bool _inGame; - bool _isMenu; - bool _fadeBackground; - uint32 _fadeColor; - virtual bool HandleMouseWheel(int Delta); - CUIWindow *_shieldWindow; - CUIButton *_shieldButton; - HRESULT Close(); - HRESULT GoSystemExclusive(); - HRESULT GoExclusive(); - TWindowMode _mode; - HRESULT MoveFocus(bool Forward = true); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - POINT _dragFrom; - bool _dragging; - DECLARE_PERSISTENT(CUIWindow, CUIObject) - bool _transparent; - HRESULT ShowWidget(const char *Name, bool Visible = true); - HRESULT EnableWidget(const char *Name, bool Enable = true); - RECT _titleRect; - RECT _dragRect; - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); - CUIWindow(CBGame *inGame); - virtual ~CUIWindow(); - virtual bool HandleKeypress(SDL_Event *event); - CBArray _widgets; - TTextAlign _titleAlign; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - CUITiledImage *_backInactive; - CBFont *_fontInactive; - CBSprite *_imageInactive; - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); - - // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Vector2.cpp b/engines/wintermute/Vector2.cpp deleted file mode 100644 index b2fa56dff4..0000000000 --- a/engines/wintermute/Vector2.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2() { - x = y = 0.0f; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2(float x, float y) { - this->x = x; - this->y = y; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::~Vector2() { -} - - -////////////////////////////////////////////////////////////////////////// -float Vector2::Length() const { - return sqrt(x * x + y * y); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Vector2.h b/engines/wintermute/Vector2.h deleted file mode 100644 index aa3fe5aa86..0000000000 --- a/engines/wintermute/Vector2.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VECTOR2_H -#define WINTERMUTE_VECTOR2_H - -namespace WinterMute { - -class Vector2 { -public: - Vector2(); - Vector2(float x, float y); - ~Vector2(); - - float Length() const; - - inline Vector2 &operator= (const Vector2 &other) { - x = other.x; - y = other.y; - - return *this; - } - - inline Vector2 operator+ (const Vector2 &other) const { - return Vector2(x + other.x, y + other.y); - } - - inline Vector2 operator- (const Vector2 &other) const { - return Vector2(x - other.x, y - other.y); - } - - inline Vector2 operator* (const float scalar) const { - return Vector2(x * scalar, y * scalar); - } - - inline Vector2 &operator+= (const Vector2 &other) { - x += other.x; - y += other.y; - - return *this; - } - - - float x; - float y; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/math/MathUtil.cpp b/engines/wintermute/math/MathUtil.cpp new file mode 100644 index 0000000000..d6b526f5b6 --- /dev/null +++ b/engines/wintermute/math/MathUtil.cpp @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "MathUtil.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +float MathUtil::Round(float val) { + float result = floor(val); + if (val - result >= 0.5) result += 1.0; + return result; +} + +////////////////////////////////////////////////////////////////////////// +float MathUtil::RoundUp(float val) { + float result = floor(val); + if (val - result > 0) result += 1.0; + return result; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/MathUtil.h b/engines/wintermute/math/MathUtil.h new file mode 100644 index 0000000000..bacf975d62 --- /dev/null +++ b/engines/wintermute/math/MathUtil.h @@ -0,0 +1,42 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATHUTIL_H +#define WINTERMUTE_MATHUTIL_H + +namespace WinterMute { + +class MathUtil { +public: + static float Round(float val); + static float RoundUp(float val); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/Matrix4.cpp b/engines/wintermute/math/Matrix4.cpp new file mode 100644 index 0000000000..d9d17b613b --- /dev/null +++ b/engines/wintermute/math/Matrix4.cpp @@ -0,0 +1,86 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/math/Vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Matrix4::Matrix4() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } +} + +////////////////////////////////////////////////////////////////////////// +Matrix4::~Matrix4() { +} + + +////////////////////////////////////////////////////////////////////////// +void Matrix4::Identity() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } + m[0][0] = 1.0f; + m[1][1] = 1.0f; + m[2][2] = 1.0f; + m[3][3] = 1.0f; + +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::RotationZ(float angle) { + Identity(); + + m[0][0] = cos(angle); + m[1][1] = cos(angle); + m[0][1] = sin(angle); + m[1][0] = -sin(angle); +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::TransformVector2(Vector2 &vec) { + float norm; + + norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; + + float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; + float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; + + vec.x = x; + vec.y = y; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/Matrix4.h b/engines/wintermute/math/Matrix4.h new file mode 100644 index 0000000000..da5fd1393a --- /dev/null +++ b/engines/wintermute/math/Matrix4.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATRIX4_H +#define WINTERMUTE_MATRIX4_H + +namespace WinterMute { + +class Vector2; + +class Matrix4 { +public: + Matrix4(); + ~Matrix4(); + + void Identity(); + void RotationZ(float angle); + void TransformVector2(Vector2 &vec); + + /* union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + };*/ + float m[4][4]; + //}; + +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/Vector2.cpp b/engines/wintermute/math/Vector2.cpp new file mode 100644 index 0000000000..b2fa56dff4 --- /dev/null +++ b/engines/wintermute/math/Vector2.cpp @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "Vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2() { + x = y = 0.0f; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2(float x, float y) { + this->x = x; + this->y = y; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::~Vector2() { +} + + +////////////////////////////////////////////////////////////////////////// +float Vector2::Length() const { + return sqrt(x * x + y * y); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/Vector2.h b/engines/wintermute/math/Vector2.h new file mode 100644 index 0000000000..aa3fe5aa86 --- /dev/null +++ b/engines/wintermute/math/Vector2.h @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VECTOR2_H +#define WINTERMUTE_VECTOR2_H + +namespace WinterMute { + +class Vector2 { +public: + Vector2(); + Vector2(float x, float y); + ~Vector2(); + + float Length() const; + + inline Vector2 &operator= (const Vector2 &other) { + x = other.x; + y = other.y; + + return *this; + } + + inline Vector2 operator+ (const Vector2 &other) const { + return Vector2(x + other.x, y + other.y); + } + + inline Vector2 operator- (const Vector2 &other) const { + return Vector2(x - other.x, y - other.y); + } + + inline Vector2 operator* (const float scalar) const { + return Vector2(x * scalar, y * scalar); + } + + inline Vector2 &operator+= (const Vector2 &other) { + x += other.x; + y += other.y; + + return *this; + } + + + float x; + float y; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 5596cc5e46..8e929b0dcd 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -92,30 +92,30 @@ MODULE_OBJS := \ FontGlyphCache.o \ graphics/transparentSurface.o \ graphics/tga.o \ - MathUtil.o \ - Matrix4.o \ + math/MathUtil.o \ + math/Matrix4.o \ + math/Vector2.o \ PathUtil.o \ Base/PartParticle.o \ Base/PartEmitter.o \ Base/PartForce.o \ PlatformSDL.o \ StringUtil.o \ - SysClass.o \ - SysClassRegistry.o \ - SysInstance.o \ - tinyxml.o \ - tinystr.o \ - tinyxmlparser.o \ - tinyxmlerror.o \ - UIButton.o \ - UIEdit.o \ - UIEntity.o \ - UIObject.o \ - UIText.o \ - UITiledImage.o \ - UIWindow.o \ + Sys/SysClass.o \ + Sys/SysClassRegistry.o \ + Sys/SysInstance.o \ + tinyxml/tinyxml.o \ + tinyxml/tinystr.o \ + tinyxml/tinyxmlparser.o \ + tinyxml/tinyxmlerror.o \ + UI/UIButton.o \ + UI/UIEdit.o \ + UI/UIEntity.o \ + UI/UIObject.o \ + UI/UIText.o \ + UI/UITiledImage.o \ + UI/UIWindow.o \ utils.o \ - Vector2.o \ VidPlayer.o \ VidTheoraPlayer.o \ wintermute.o diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index d62ca006a8..fc9c4d674c 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -41,8 +41,8 @@ typedef HRESULT(WINAPI *PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute -#include "SysClass.h" -#include "SysClassRegistry.h" +#include "engines/wintermute/Sys/SysClass.h" +#include "engines/wintermute/Sys/SysClassRegistry.h" namespace WinterMute { diff --git a/engines/wintermute/tinystr.cpp b/engines/wintermute/tinystr.cpp deleted file mode 100644 index 0665768205..0000000000 --- a/engines/wintermute/tinystr.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - - -#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinystr.h b/engines/wintermute/tinystr.h deleted file mode 100644 index 89cca33415..0000000000 --- a/engines/wintermute/tinystr.h +++ /dev/null @@ -1,305 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TIXML_USE_STL - -#ifndef TIXML_STRING_INCLUDED -#define TIXML_STRING_INCLUDED - -#include -#include - -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: -*/ -#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit -#elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit -#else - #define TIXML_EXPLICIT -#endif - - -/* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. -*/ -class TiXmlString -{ - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; - -} ; - - -inline bool operator == (const TiXmlString & a, const TiXmlString & b) -{ - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare -} -inline bool operator < (const TiXmlString & a, const TiXmlString & b) -{ - return strcmp(a.c_str(), b.c_str()) < 0; -} - -inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } -inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } -inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } -inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } - -inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } -inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } -inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } -inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); -TiXmlString operator + (const TiXmlString & a, const char* b); -TiXmlString operator + (const char* a, const TiXmlString & b); - - -/* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. -*/ -class TiXmlOutStream : public TiXmlString -{ -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } - -} ; - -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml.cpp b/engines/wintermute/tinyxml.cpp deleted file mode 100644 index 4ff47d1432..0000000000 --- a/engines/wintermute/tinyxml.cpp +++ /dev/null @@ -1,1888 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include - -#ifdef TIXML_USE_STL -#include -#include -#endif - -#include "engines/wintermute/tinyxml.h" - - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( replaceThis->parent != this ) - return 0; - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return &node->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const char* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s ); - } - else { - *i = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const std::string* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s->c_str() ); - } - else { - *i = 0; - } - } - return s; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const char* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s ); - } - else { - *d = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const std::string* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s->c_str() ); - } - else { - *d = 0; - } - } - return s; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); - #else - sprintf( buf, "%d", val ); - #endif - SetAttribute( name, buf ); -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - std::ostringstream oss; - oss << val; - SetAttribute( name, oss.str() ); -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); - #else - sprintf( buf, "%f", val ); - #endif - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING _name( cname ); - TIXML_STRING _value( cvalue ); - #else - const char* _name = cname; - const char* _value = cvalue; - #endif - - TiXmlAttribute* node = attributeSet.Find( _name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - // See STL_STRING_BUG below. - //StringToBuffer buf( value ); - - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - // See STL_STRING_BUG below. -// StringToBuffer buf( value ); -// -// if ( buf.buffer && SaveFile( buf.buffer ) ) -// return true; -// -// return false; - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // Add an extra string to avoid the crash. - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // - // - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - if ( *p == 0xa ) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append( lastPos, (p-lastPos+1) ); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert( p <= (buf+length) ); - } - else if ( *p == 0xd ) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ( (p-lastPos) > 0 ) { - data.append( lastPos, p-lastPos ); // do not add the CR - } - data += (char)0xa; // a proper newline - - if ( *(p+1) == 0xa ) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert( p <= (buf+length) ); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert( p <= (buf+length) ); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if ( p-lastPos ) { - data.append( lastPos, p-lastPos ); - } - delete [] buf; - buf = 0; - - Parse( data.c_str(), 0, encoding ); - - if ( Error() ) - return false; - else - return true; -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); - #else - sprintf (buf, "%lf", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} -*/ -#endif - - -const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} -*/ - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && iNextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && iNextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && iNextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && iNextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += ""; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += ""; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += ""; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - diff --git a/engines/wintermute/tinyxml.h b/engines/wintermute/tinyxml.h deleted file mode 100644 index afb07cfbed..0000000000 --- a/engines/wintermute/tinyxml.h +++ /dev/null @@ -1,1803 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#undef TIXML_USE_STL - -#ifndef TINYXML_INCLUDED -#define TINYXML_INCLUDED - -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4530 ) -#pragma warning( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include - -// Help out windows: -#if defined( _DEBUG ) && !defined( DEBUG ) -#define DEBUG -#endif - -#ifdef TIXML_USE_STL - #include - #include - #include - #define TIXML_STRING std::string -#else - #include "tinystr.h" - #define TIXML_STRING TiXmlString -#endif - -// Deprecated library function hell. Compilers want to use the -// new safe versions. This probably doesn't fully address the problem, -// but it gets closer. There are too many compilers for me to fully -// test. If you get compilation troubles, undefine TIXML_SAFE -#define TIXML_SAFE - -#ifdef TIXML_SAFE - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s - #define TIXML_SNSCANF _snscanf_s - #define TIXML_SSCANF sscanf_s - #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - //#pragma message( "Using _sn* functions." ) - #define TIXML_SNPRINTF _snprintf - #define TIXML_SNSCANF _snscanf - #define TIXML_SSCANF sscanf - #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_SNSCANF snscanf - #define TIXML_SSCANF sscanf - #else - #define TIXML_SSCANF sscanf - #endif -#endif - -class TiXmlDocument; -class TiXmlElement; -class TiXmlComment; -class TiXmlUnknown; -class TiXmlAttribute; -class TiXmlText; -class TiXmlDeclaration; -class TiXmlParsingData; - -const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 5; -const int TIXML_PATCH_VERSION = 3; - -/* Internal structure for tracking location of items - in the XML file. -*/ -struct TiXmlCursor -{ - TiXmlCursor() { Clear(); } - void Clear() { row = col = -1; } - - int row; // 0 based. - int col; // 0 based. -}; - - -/** - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simple called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its sibilings will be Visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - - You should never change the document from a callback. - - @sa TiXmlNode::Accept() -*/ -class TiXmlVisitor -{ -public: - virtual ~TiXmlVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } - /// Visit a document. - virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } - - /// Visit an element. - virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } - /// Visit an element. - virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } - - /// Visit a declaration - virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } - /// Visit a text node - virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } - /// Visit a comment node - virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknow node - virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } -}; - -// Only used by Attribute::Query functions -enum -{ - TIXML_SUCCESS, - TIXML_NO_ATTRIBUTE, - TIXML_WRONG_TYPE -}; - - -// Used by the parsing routines. -enum TiXmlEncoding -{ - TIXML_ENCODING_UNKNOWN, - TIXML_ENCODING_UTF8, - TIXML_ENCODING_LEGACY -}; - -const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; - -/** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - @endverbatim -*/ -class TiXmlBase -{ - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; - -public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} - - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert - tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } - - /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. - - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. - - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. - - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - - @sa TiXmlDocument::SetTabSize() - */ - int Row() const { return location.row + 1; } - int Column() const { return location.col + 1; } ///< See Row() - - void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. - void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. - const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. - - // Table that returs, for a given lead byte, the total number of bytes - // in the UTF-8 sequence. - static const int utf8ByteTable[256]; - - virtual const char* Parse( const char* p, - TiXmlParsingData* data, - TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, - or they will be transformed into entities! - */ - static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_OUT_OF_MEMORY, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - TIXML_ERROR_PARSING_CDATA, - TIXML_ERROR_DOCUMENT_TOP_ONLY, - - TIXML_ERROR_STRING_COUNT - }; - -protected: - - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); - } - inline static bool IsWhiteSpace( int c ) - { - if ( c < 256 ) - return IsWhiteSpace( (char) c ); - return false; // Again, only truly correct for English/Latin...but usually works. - } - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); - static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding ); // the current encoding - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); - - // Get a character, while interpreting entities. - // The length can be from 0 to 4 bytes. - inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) - { - assert( p ); - if ( encoding == TIXML_ENCODING_UTF8 ) - { - *length = utf8ByteTable[ *((const unsigned char*)p) ]; - assert( *length >= 0 && *length < 5 ); - } - else - { - *length = 1; - } - - if ( *length == 1 ) - { - if ( *p == '&' ) - return GetEntity( p, _value, length, encoding ); - *_value = *p; - return p+1; - } - else if ( *length ) - { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), - // and the null terminator isn't needed - for( int i=0; p[i] && i<*length; ++i ) { - _value[i] = p[i]; - } - return p + (*length); - } - else - { - // Not valid text. - return 0; - } - } - - // Return true if the next characters in the stream are any of the endTag sequences. - // Ignore case only works for english, and should only be relied on when comparing - // to English words: StringEqual( p, "version", true ) is fine. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase, - TiXmlEncoding encoding ); - - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; - - TiXmlCursor location; - - /// Field containing a generic user pointer - void* userData; - - // None of these methods are reliable for any language except English. - // Good for approximation, not great for accuracy. - static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); - static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); - inline static int ToLower( int v, TiXmlEncoding encoding ) - { - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( v < 128 ) return tolower( v ); - return v; - } - else - { - return tolower( v ); - } - } - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - -private: - TiXmlBase( const TiXmlBase& ); // not implemented. - void operator=( const TiXmlBase& base ); // not allowed. - - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; -}; - - -/** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. -*/ -class TiXmlNode : public TiXmlBase -{ - friend class TiXmlDocument; - friend class TiXmlElement; - -public: - #ifdef TIXML_USE_STL - - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); - - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - DOCUMENT, - ELEMENT, - COMMENT, - UNKNOWN, - TEXT, - DECLARATION, - TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ - const char *Value() const { return value.c_str (); } - - #ifdef TIXML_USE_STL - /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ - const std::string& ValueStr() const { return value; } - #endif - - const TIXML_STRING& ValueTStr() const { return value; } - - /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - void SetValue(const char * _value) { value = _value;} - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); - - /// One step up the DOM. - TiXmlNode* Parent() { return parent; } - const TiXmlNode* Parent() const { return parent; } - - const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - /// The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* FirstChild( const char * _value ) { - // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) - // call the method, cast the return back to non-const. - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); - } - const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild() { return lastChild; } - - const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. - TiXmlNode* LastChild( const char * _value ) { - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); - } - - /// This flavor of IterateChildren searches for children with a particular 'value' - const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - #endif - - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - - /** Add a new node related to this. Adds a child past the LastChild. - - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. - - @sa InsertEndChild - */ - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling() const { return prev; } - TiXmlNode* PreviousSibling() { return prev; } - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling( const char * ) const; - TiXmlNode* PreviousSibling( const char *_prev ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - const TiXmlNode* NextSibling() const { return next; } - TiXmlNode* NextSibling() { return next; } - - /// Navigate to a sibling node with the given 'value'. - const TiXmlNode* NextSibling( const char * ) const; - TiXmlNode* NextSibling( const char* _next ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement() const; - TiXmlElement* NextSiblingElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement( const char * ) const; - TiXmlElement* NextSiblingElement( const char *_next ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement() const; - TiXmlElement* FirstChildElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); - } - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement( const char * _value ) const; - TiXmlElement* FirstChildElement( const char * _value ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. - */ - int Type() const { return type; } - - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - const TiXmlDocument* GetDocument() const; - TiXmlDocument* GetDocument() { - return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); - } - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ - virtual TiXmlNode* Clone() const = 0; - - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. - - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( TiXmlVisitor* visitor ) const = 0; - -protected: - TiXmlNode( NodeType _type ); - - // Copy to the allocated object. Shared functionality between Clone, Copy constructor, - // and the assignment operator. - void CopyTo( TiXmlNode* target ) const; - - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; - #endif - - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - - TiXmlNode* parent; - NodeType type; - - TiXmlNode* firstChild; - TiXmlNode* lastChild; - - TIXML_STRING value; - - TiXmlNode* prev; - TiXmlNode* next; - -private: - TiXmlNode( const TiXmlNode& ); // not implemented. - void operator=( const TiXmlNode& base ); // not allowed. -}; - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. -*/ -class TiXmlAttribute : public TiXmlBase -{ - friend class TiXmlAttributeSet; - -public: - /// Construct an empty attribute. - TiXmlAttribute() : TiXmlBase() - { - document = 0; - prev = next = 0; - } - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - - const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. - #ifdef TIXML_USE_STL - const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. - #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - - // Get the tinyxml string representation - const TIXML_STRING& NameTStr() const { return name; } - - /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ - int QueryIntValue( int* _value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* _value ) const; - - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. - - void SetIntValue( int _value ); ///< Set the value from an integer. - void SetDoubleValue( double _value ); ///< Set the value from a double. - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - const TiXmlAttribute* Next() const; - TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); - } - - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - const TiXmlAttribute* Previous() const; - TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); - } - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } - -private: - TiXmlAttribute( const TiXmlAttribute& ); // not implemented. - void operator=( const TiXmlAttribute& base ); // not allowed. - - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; -}; - - -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. -*/ -class TiXmlAttributeSet -{ -public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); - - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); - - const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - - const TiXmlAttribute* Find( const char* _name ) const; - TiXmlAttribute* Find( const char* _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - #ifdef TIXML_USE_STL - const TiXmlAttribute* Find( const std::string& _name ) const; - TiXmlAttribute* Find( const std::string& _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - - #endif - -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed - void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) - - TiXmlAttribute sentinel; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TiXmlElement : public TiXmlNode -{ -public: - /// Construct an element. - TiXmlElement (const char * in_value); - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ); - #endif - - TiXmlElement( const TiXmlElement& ); - - void operator=( const TiXmlElement& base ); - - virtual ~TiXmlElement(); - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ - const char* Attribute( const char* name, double* d ) const; - - /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ - int QueryIntAttribute( const char* name, int* _value ) const; - /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* _value ) const; - /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { - double d; - int result = QueryDoubleAttribute( name, &d ); - if ( result == TIXML_SUCCESS ) { - *_value = (float)d; - } - return result; - } - - #ifdef TIXML_USE_STL - /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. - - NOTE: This method doesn't work correctly for 'string' types. - - @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ - template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - std::stringstream sstream( node->ValueStr() ); - sstream >> *outValue; - if ( !sstream.fail() ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; - } - /* - This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" - but template specialization is hard to get working cross-compiler. Leaving the bug for now. - - // The above will fail for std::string because the space character is used as a seperator. - // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string - template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - *outValue = node->ValueStr(); - return TIXML_SUCCESS; - } - */ - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * _value ); - - #ifdef TIXML_USE_STL - const std::string* Attribute( const std::string& name ) const; - const std::string* Attribute( const std::string& name, int* i ) const; - const std::string* Attribute( const std::string& name, double* d ) const; - int QueryIntAttribute( const std::string& name, int* _value ) const; - int QueryDoubleAttribute( const std::string& name, double* _value ) const; - - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ); - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ); - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetDoubleAttribute( const char * name, double value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); - #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif - - const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } - const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ - const char* GetText() const; - - /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; - // Print the Element to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - - void CopyTo( TiXmlElement* target ) const; - void ClearThis(); // like clear, but initializes 'this' object as well - - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - -private: - - TiXmlAttributeSet attributeSet; -}; - - -/** An XML comment. -*/ -class TiXmlComment : public TiXmlNode -{ -public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} - /// Construct a comment from text. - TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { - SetValue( _value ); - } - TiXmlComment( const TiXmlComment& ); - void operator=( const TiXmlComment& base ); - - virtual ~TiXmlComment() {} - - /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; - // Write this Comment to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlComment* target ) const; - - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; - -private: - -}; - - -/** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). -*/ -class TiXmlText : public TiXmlNode -{ - friend class TiXmlElement; -public: - /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - #endif - - TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } - void operator=( const TiXmlText& base ) { base.CopyTo( this ); } - - // Write this text object to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /// Queries whether this represents text using a CDATA section. - bool CDATA() const { return cdata; } - /// Turns on or off a CDATA representation of text. - void SetCDATA( bool _cdata ) { cdata = _cdata; } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - void CopyTo( TiXmlText* target ) const; - - bool Blank() const; // returns true if all white space and new lines - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - bool cdata; // true if this should be input and output as a CDATA style text element -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. -*/ -class TiXmlDeclaration : public TiXmlNode -{ -public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} - -#ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ); -#endif - - /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); - - TiXmlDeclaration( const TiXmlDeclaration& copy ); - void operator=( const TiXmlDeclaration& copy ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return an empty string if none was found. - const char *Version() const { return version.c_str (); } - /// Encoding. Will return an empty string if none was found. - const char *Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char *Standalone() const { return standalone.c_str (); } - - /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; - // Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlDeclaration* target ) const; - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; -}; - - -/** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into TiXmlUnknowns. -*/ -class TiXmlUnknown : public TiXmlNode -{ -public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} - virtual ~TiXmlUnknown() {} - - TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } - void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } - - /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; - // Print this Unknown to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected: - void CopyTo( TiXmlUnknown* target ) const; - - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - -}; - - -/** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. -*/ -class TiXmlDocument : public TiXmlNode -{ -public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ); - #endif - - TiXmlDocument( const TiXmlDocument& copy ); - void operator=( const TiXmlDocument& copy ); - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ - bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given FILE*. Returns true if successful. - bool SaveFile( FILE* ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && LoadFile( f.buffer, encoding )); - return LoadFile( filename.c_str(), encoding ); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && SaveFile( f.buffer )); - return SaveFile( filename.c_str() ); - } - #endif - - /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - const TiXmlElement* RootElement() const { return FirstChildElement(); } - TiXmlElement* RootElement() { return FirstChildElement(); } - - /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - int ErrorId() const { return errorId; } - - /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) - - @sa SetTabSize, Row, Column - */ - int ErrorRow() const { return errorLocation.row+1; } - int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - - /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. - - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. - - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. - - Note that row and column tracking is not supported when using operator>>. - - The tab size needs to be enabled before the parse or load. Correct usage: - @verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - @endverbatim - - @sa Row, Column - */ - void SetTabSize( int _tabsize ) { tabsize = _tabsize; } - - int TabSize() const { return tabsize; } - - /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; - } - - /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { Print( stdout, 0 ); } - - /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ - //char* PrintToMemory() const; - - /// Print this Document to a FILE stream. - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - - virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - void CopyTo( TiXmlDocument* target ) const; - - bool error; - int errorId; - TIXML_STRING errorDesc; - int tabsize; - TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. -}; - - -/** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - TiXmlHandle handleCopy = handle; - @endverbatim - - What they should not be used for is iteration: - - @verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - @endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - @endverbatim -*/ -class TiXmlHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } - /// Copy constructor - TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } - - /// Return a handle to the first child node. - TiXmlHandle FirstChild() const; - /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; - /// Return a handle to the first child element. - TiXmlHandle FirstChildElement() const; - /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; - - /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( int index ) const; - - #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } - - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } - #endif - - /** Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* ToNode() const { return node; } - /** Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /** Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /** Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - - /** @deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* Node() const { return ToNode(); } - /** @deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* Element() const { return ToElement(); } - /** @deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* Text() const { return ToText(); } - /** @deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* Unknown() const { return ToUnknown(); } - -private: - TiXmlNode* node; -}; - - -/** Print to memory functionality. The TiXmlPrinter is useful when you need to: - - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) - - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. - - TiXmlPrinter uses the Visitor API. - @verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); - - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - @endverbatim -*/ -class TiXmlPrinter : public TiXmlVisitor -{ -public: - TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), - buffer(), indent( " " ), lineBreak( "\n" ) {} - - virtual bool VisitEnter( const TiXmlDocument& doc ); - virtual bool VisitExit( const TiXmlDocument& doc ); - - virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); - virtual bool VisitExit( const TiXmlElement& element ); - - virtual bool Visit( const TiXmlDeclaration& declaration ); - virtual bool Visit( const TiXmlText& text ); - virtual bool Visit( const TiXmlComment& comment ); - virtual bool Visit( const TiXmlUnknown& unknown ); - - /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ - void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } - /// Query the indention string. - const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ - void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } - /// Query the current line breaking string. - const char* LineBreak() { return lineBreak.c_str(); } - - /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ - void SetStreamPrinting() { indent = ""; - lineBreak = ""; - } - /// Return the result. - const char* CStr() { return buffer.c_str(); } - /// Return the length of the result string. - size_t Size() { return buffer.size(); } - - #ifdef TIXML_USE_STL - /// Return the result. - const std::string& Str() { return buffer; } - #endif - -private: - void DoIndent() { - for( int i=0; i(-1); + + +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; + + +void TiXmlString::reserve (size_type cap) +{ + if (cap > capacity()) + { + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); + } +} + + +TiXmlString& TiXmlString::assign(const char* str, size_type len) +{ + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; +} + + +TiXmlString& TiXmlString::append(const char* str, size_type len) +{ + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; +} + + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) +{ + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; +} + +TiXmlString operator + (const TiXmlString & a, const char* b) +{ + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; +} + +TiXmlString operator + (const char* a, const TiXmlString & b) +{ + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; +} + + +#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinystr.h b/engines/wintermute/tinyxml/tinystr.h new file mode 100644 index 0000000000..89cca33415 --- /dev/null +++ b/engines/wintermute/tinyxml/tinystr.h @@ -0,0 +1,305 @@ +/* +www.sourceforge.net/projects/tinyxml + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include +#include + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinyxml.cpp b/engines/wintermute/tinyxml/tinyxml.cpp new file mode 100644 index 0000000000..e4a0c2780f --- /dev/null +++ b/engines/wintermute/tinyxml/tinyxml.cpp @@ -0,0 +1,1888 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include + +#ifdef TIXML_USE_STL +#include +#include +#endif + +#include "engines/wintermute/tinyxml/tinyxml.h" + + +bool TiXmlBase::condenseWhiteSpace = true; + +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) +{ + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; + #else + return fopen( filename, mode ); + #endif +} + +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) +{ + int i=0; + + while( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); + #else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + #endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } +} + + +TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() +{ + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; +} + + +TiXmlNode::~TiXmlNode() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } +} + + +void TiXmlNode::CopyTo( TiXmlNode* target ) const +{ + target->SetValue (value.c_str() ); + target->userData = userData; +} + + +void TiXmlNode::Clear() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } + + firstChild = 0; + lastChild = 0; +} + + +TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) +{ + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + node->parent = this; + + node->prev = lastChild; + node->next = 0; + + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. + + lastChild = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) +{ + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + + return LinkEndChild( node ); +} + + +TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) +{ + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) +{ + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; +} + + +TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) +{ + if ( replaceThis->parent != this ) + return 0; + + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; +} + + +bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) +{ + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; + + delete removeThis; + return true; +} + +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } +} + + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +void TiXmlElement::RemoveAttribute( const char * name ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); + #else + TiXmlAttribute* node = attributeSet.Find( name ); + #endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } +} + +const TiXmlElement* TiXmlNode::FirstChildElement() const +{ + const TiXmlNode* node; + + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement() const +{ + const TiXmlNode* node; + + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlDocument* TiXmlNode::GetDocument() const +{ + const TiXmlNode* node; + + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; +} + + +TiXmlElement::TiXmlElement (const char * _value) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} + + +#ifdef TIXML_USE_STL +TiXmlElement::TiXmlElement( const std::string& _value ) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} +#endif + + +TiXmlElement::TiXmlElement( const TiXmlElement& copy) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + copy.CopyTo( this ); +} + + +void TiXmlElement::operator=( const TiXmlElement& base ) +{ + ClearThis(); + base.CopyTo( this ); +} + + +TiXmlElement::~TiXmlElement() +{ + ClearThis(); +} + + +void TiXmlElement::ClearThis() +{ + Clear(); + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } +} + + +const char* TiXmlElement::Attribute( const char* name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return &node->ValueStr(); + return 0; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, int* i ) const +{ + const char* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s ); + } + else { + *i = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const +{ + const std::string* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s->c_str() ); + } + else { + *i = 0; + } + } + return s; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const char* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s ); + } + else { + *d = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const std::string* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s->c_str() ); + } + else { + *d = 0; + } + } + return s; +} +#endif + + +int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} +#endif + + +int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} +#endif + + +void TiXmlElement::SetAttribute( const char * name, int val ) +{ + char buf[64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); + #else + sprintf( buf, "%d", val ); + #endif + SetAttribute( name, buf ); +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + std::ostringstream oss; + oss << val; + SetAttribute( name, oss.str() ); +} +#endif + + +void TiXmlElement::SetDoubleAttribute( const char * name, double val ) +{ + char buf[256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); + #else + sprintf( buf, "%f", val ); + #endif + SetAttribute( name, buf ); +} + + +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING _name( cname ); + TIXML_STRING _value( cvalue ); + #else + const char* _name = cname; + const char* _value = cvalue; + #endif + + TiXmlAttribute* node = attributeSet.Find( _name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) +{ + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} +#endif + + +void TiXmlElement::Print( FILE* cfile, int depth ) const +{ + int i; + assert( cfile ); + for ( i=0; iNext() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a node + // 2) An element with only a text child is printed as text + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i", value.c_str() ); + } +} + + +void TiXmlElement::CopyTo( TiXmlElement* target ) const +{ + // superclass: + TiXmlNode::CopyTo( target ); + + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +TiXmlNode* TiXmlElement::Clone() const +{ + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; +} + + +TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); +} + +TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} + + +#ifdef TIXML_USE_STL +TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} +#endif + + +TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDocument::operator=( const TiXmlDocument& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) +{ + // See STL_STRING_BUG below. + //StringToBuffer buf( value ); + + return LoadFile( Value(), encoding ); +} + + +bool TiXmlDocument::SaveFile() const +{ + // See STL_STRING_BUG below. +// StringToBuffer buf( value ); +// +// if ( buf.buffer && SaveFile( buf.buffer ) ) +// return true; +// +// return false; + return SaveFile( Value() ); +} + +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) +{ + // There was a really terrifying little bug here. The code: + // value = filename + // in the STL case, cause the assignment method of the std::string to + // be called. What is strange, is that the std::string had the same + // address as it's c_str() method, and so bad things happen. Looks + // like a bug in the Microsoft STL implementation. + // Add an extra string to avoid the crash. + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} + +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // + // + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + const char* lastPos = buf; + const char* p = buf; + + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + if ( *p == 0xa ) { + // Newline character. No special rules for this. Append all the characters + // since the last string, and include the newline. + data.append( lastPos, (p-lastPos+1) ); // append, include the newline + ++p; // move past the newline + lastPos = p; // and point to the new buffer (may be 0) + assert( p <= (buf+length) ); + } + else if ( *p == 0xd ) { + // Carriage return. Append what we have so far, then + // handle moving forward in the buffer. + if ( (p-lastPos) > 0 ) { + data.append( lastPos, p-lastPos ); // do not add the CR + } + data += (char)0xa; // a proper newline + + if ( *(p+1) == 0xa ) { + // Carriage return - new line sequence + p += 2; + lastPos = p; + assert( p <= (buf+length) ); + } + else { + // it was followed by something else...that is presumably characters again. + ++p; + lastPos = p; + assert( p <= (buf+length) ); + } + } + else { + ++p; + } + } + // Handle any left over characters. + if ( p-lastPos ) { + data.append( lastPos, p-lastPos ); + } + delete [] buf; + buf = 0; + + Parse( data.c_str(), 0, encoding ); + + if ( Error() ) + return false; + else + return true; +} + + +bool TiXmlDocument::SaveFile( const char * filename ) const +{ + // The old c stuff lives on... + FILE* fp = TiXmlFOpen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; +} + + +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + +void TiXmlDocument::CopyTo( TiXmlDocument* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->error = error; + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + + +TiXmlNode* TiXmlDocument::Clone() const +{ + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlDocument::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } +} + + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +const TiXmlAttribute* TiXmlAttribute::Next() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} + +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ + +const TiXmlAttribute* TiXmlAttribute::Previous() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} + +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ + +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + TIXML_STRING n, v; + + EncodeString( name, &n ); + EncodeString( value, &v ); + + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } + } + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } + } +} + + +int TiXmlAttribute::QueryIntValue( int* ival ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +int TiXmlAttribute::QueryDoubleValue( double* dval ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +void TiXmlAttribute::SetIntValue( int _value ) +{ + char buf [64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); + #else + sprintf (buf, "%d", _value); + #endif + SetValue (buf); +} + +void TiXmlAttribute::SetDoubleValue( double _value ) +{ + char buf [256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); + #else + sprintf (buf, "%lf", _value); + #endif + SetValue (buf); +} + +int TiXmlAttribute::IntValue() const +{ + return atoi (value.c_str ()); +} + +double TiXmlAttribute::DoubleValue() const +{ + return atof (value.c_str ()); +} + + +TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlComment::operator=( const TiXmlComment& base ) +{ + Clear(); + base.CopyTo( this ); +} + + +void TiXmlComment::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlComment::CopyTo( TiXmlComment* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlComment::Clone() const +{ + TiXmlComment* clone = new TiXmlComment(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlText::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } +} + + +void TiXmlText::CopyTo( TiXmlText* target ) const +{ + TiXmlNode::CopyTo( target ); + target->cdata = cdata; +} + + +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlText::Clone() const +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlDeclaration::TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} + + +#ifdef TIXML_USE_STL +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} +#endif + + +TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + if ( cfile ) fprintf( cfile, "" ); + if ( str ) (*str) += "?>"; +} + + +void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->version = version; + target->encoding = encoding; + target->standalone = standalone; +} + + +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlDeclaration::Clone() const +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlUnknown::Print( FILE* cfile, int depth ) const +{ + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlUnknown::Clone() const +{ + TiXmlUnknown* clone = new TiXmlUnknown(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlAttributeSet::TiXmlAttributeSet() +{ + sentinel.next = &sentinel; + sentinel.prev = &sentinel; +} + + +TiXmlAttributeSet::~TiXmlAttributeSet() +{ + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); +} + + +void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) +{ + #ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. + #else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + #endif + + addMe->next = &sentinel; + addMe->prev = sentinel.prev; + + sentinel.prev->next = addMe; + sentinel.prev = addMe; +} + +void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) +{ + TiXmlAttribute* node; + + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. +} + + +#ifdef TIXML_USE_STL +const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const +{ + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} +*/ +#endif + + +const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} +*/ + +#ifdef TIXML_USE_STL +std::istream& operator>> (std::istream & in, TiXmlNode & base) +{ + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); + + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; +} +#endif + + +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + + return out; +} + + +std::string& operator<< (std::string& out, const TiXmlNode& base ) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; +} +#endif + + +TiXmlHandle TiXmlHandle::FirstChild() const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement() const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && iNextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && iNextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && iNextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && iNextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += ""; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += ""; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += ""; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff --git a/engines/wintermute/tinyxml/tinyxml.h b/engines/wintermute/tinyxml/tinyxml.h new file mode 100644 index 0000000000..afb07cfbed --- /dev/null +++ b/engines/wintermute/tinyxml/tinyxml.h @@ -0,0 +1,1803 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#undef TIXML_USE_STL + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include +#include +#include +#include +#include + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include + #include + #include + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SNSCANF _snscanf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SNSCANF _snscanf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SNSCANF snscanf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 5; +const int TIXML_PATCH_VERSION = 3; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + DOCUMENT, + ELEMENT, + COMMENT, + UNKNOWN, + TEXT, + DECLARATION, + TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + const TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* Find( const char* _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + #ifdef TIXML_USE_STL + const TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* Find( const std::string& _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + + #endif + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + void operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + /* + This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" + but template specialization is hard to get working cross-compiler. Leaving the bug for now. + + // The above will fail for std::string because the space character is used as a seperator. + // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string + template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + */ + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetDoubleAttribute( const char * name, double value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); + #ifdef TIXML_USE_STL + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif + + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; + + /// Creates a new Element and returns it - the returned element is a copy. + virtual TiXmlNode* Clone() const; + // Print the Element to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + + void CopyTo( TiXmlElement* target ) const; + void ClearThis(); // like clear, but initializes 'this' object as well + + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + +private: + + TiXmlAttributeSet attributeSet; +}; + + +/** An XML comment. +*/ +class TiXmlComment : public TiXmlNode +{ +public: + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { + SetValue( _value ); + } + TiXmlComment( const TiXmlComment& ); + void operator=( const TiXmlComment& base ); + + virtual ~TiXmlComment() {} + + /// Returns a copy of this Comment. + virtual TiXmlNode* Clone() const; + // Write this Comment to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlComment* target ) const; + + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif +// virtual void StreamOut( TIXML_OSTREAM * out ) const; + +private: + +}; + + +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class TiXmlText : public TiXmlNode +{ + friend class TiXmlElement; +public: + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + #endif + + TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } + void operator=( const TiXmlText& base ) { base.CopyTo( this ); } + + // Write this text object to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + /// [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + void CopyTo( TiXmlText* target ) const; + + bool Blank() const; // returns true if all white space and new lines + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + bool cdata; // true if this should be input and output as a CDATA style text element +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ +class TiXmlDeclaration : public TiXmlNode +{ +public: + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} + +#ifdef TIXML_USE_STL + /// Constructor. + TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ); +#endif + + /// Construct. + TiXmlDeclaration( const char* _version, + const char* _encoding, + const char* _standalone ); + + TiXmlDeclaration( const TiXmlDeclaration& copy ); + void operator=( const TiXmlDeclaration& copy ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return an empty string if none was found. + const char *Version() const { return version.c_str (); } + /// Encoding. Will return an empty string if none was found. + const char *Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char *Standalone() const { return standalone.c_str (); } + + /// Creates a copy of this Declaration and returns it. + virtual TiXmlNode* Clone() const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlDeclaration* target ) const; + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class TiXmlUnknown : public TiXmlNode +{ +public: + TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} + virtual ~TiXmlUnknown() {} + + TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } + void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } + + /// Creates a copy of this Unknown and returns it. + virtual TiXmlNode* Clone() const; + // Print this Unknown to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected: + void CopyTo( TiXmlUnknown* target ) const; + + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + +}; + + +/** Always the top level node. A document binds together all the + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ +class TiXmlDocument : public TiXmlNode +{ +public: + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ); + #endif + + TiXmlDocument( const TiXmlDocument& copy ); + void operator=( const TiXmlDocument& copy ); + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && LoadFile( f.buffer, encoding )); + return LoadFile( filename.c_str(), encoding ); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && SaveFile( f.buffer )); + return SaveFile( filename.c_str() ); + } + #endif + + /** Parse the given null terminated block of xml data. Passing in an encoding to this + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } + + /** If an error occurs, Error will be set to true. Also, + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + int ErrorId() const { return errorId; } + + /** Returns the location (if known) of the error. The first column is column 1, + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) + + @sa SetTabSize, Row, Column + */ + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. + + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. + + Note that row and column tracking is not supported when using operator>>. + + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim + + @sa Row, Column + */ + void SetTabSize( int _tabsize ) { tabsize = _tabsize; } + + int TabSize() const { return tabsize; } + + /** If you have handled the error, it can be reset with this call. The error + state is automatically cleared if you Parse a new XML block. + */ + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; + } + + /** Write the document to standard out using formatted printing ("pretty print"). */ + void Print() const { Print( stdout, 0 ); } + + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + + /// Print this Document to a FILE stream. + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + void CopyTo( TiXmlDocument* target ) const; + + bool error; + int errorId; + TIXML_STRING errorDesc; + int tabsize; + TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. +}; + + +/** + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ +class TiXmlHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } + /// Copy constructor + TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } + + /// Return a handle to the first child node. + TiXmlHandle FirstChild() const; + /// Return a handle to the first child node with the given name. + TiXmlHandle FirstChild( const char * value ) const; + /// Return a handle to the first child element. + TiXmlHandle FirstChildElement() const; + /// Return a handle to the first child element with the given name. + TiXmlHandle FirstChildElement( const char * value ) const; + + /** Return a handle to the "index" child with the given name. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( const char* value, int index ) const; + /** Return a handle to the "index" child. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( int index ) const; + /** Return a handle to the "index" child element with the given name. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( const char* value, int index ) const; + /** Return a handle to the "index" child element. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( int index ) const; + + #ifdef TIXML_USE_STL + TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + + TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + #endif + + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } + +private: + TiXmlNode* node; +}; + + +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; i +#include + +#include "tinyxml.h" + +//#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif + +// Note tha "PutString" hardcodes the same list. This +// is less flexible than it appears. Changing the entries +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = +{ + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } +}; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// Including the basic of this table, which determines the #bytes in the +// sequence from the lead byte. 1 placed for invalid sequences -- +// although the result will be junk, pass it through as much as possible. +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf + +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +const int TiXmlBase::utf8ByteTable[256] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid +}; + + +void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { *length = 0; return; } // This code won't covert this correctly anyway. + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } +} + + +/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalpha( anyByte ); +// } +} + + +/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalnum( anyByte ); +// } +} + + +class TiXmlParsingData +{ + friend class TiXmlDocument; + public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() { return cursor; } + + private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; +}; + + +void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) +{ + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { p +=3; ++col; } // A normal character. + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); +} + + +const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) +{ + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) + ++p; + } + + return p; +} + +#ifdef TIXML_USE_STL +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) +{ + for( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; + + *tag += (char) in->get(); + } +} + +/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) +{ + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; +} +#endif + +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// +const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) +{ + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } + return p; + } + return 0; +} + +const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) +{ + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for( i=0; iappend( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p ) + p += strlen( endTag ); + return p; +} + +#ifdef TIXML_USE_STL + +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); +} + +#endif + +const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) +{ + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; +} + +void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } +} + + +TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) +{ + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if( !p || !*p || *p != '<' ) + { + return 0; + } + + TiXmlDocument* doc = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: "; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p ) + p += strlen( endTag ); + + return p; +} + + +const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + +// int tabsize = 4; +// if ( document ) +// tabsize = document->TabSize(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } + } +} +#endif + +const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = ""; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } +} + +#ifdef TIXML_USE_STL +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + +const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) +{ + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; +} + +bool TiXmlText::Blank() const +{ + for ( unsigned i=0; i -#include - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; iappend( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p ) - p += strlen( endTag ); - return p; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); -} - -#endif - -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) -{ - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; -} - -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } -} - - -TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) -{ - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - TiXmlDocument* doc = GetDocument(); - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // [ 1475201 ] TinyXML parses entities in comments - // Oops - ReadText doesn't work, because we don't want to parse the entities. - // p = ReadText( p, &value, false, endTag, false, encoding ); - // - // from the XML spec: - /* - [Definition: Comments may appear anywhere in a document outside other markup; in addition, - they may appear within the document type declaration at places allowed by the grammar. - They are not part of the document's character data; an XML processor MAY, but need not, - make it possible for an application to retrieve the text of comments. For compatibility, - the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity - references MUST NOT be recognized within comments. - - An example of a comment: - - - */ - - value = ""; - // Keep all the white space. - while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) - { - value.append( p, 1 ); - ++p; - } - if ( p ) - p += strlen( endTag ); - - return p; -} - - -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - -// int tabsize = 4; -// if ( document ) -// tabsize = document->TabSize(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; -} - -#ifdef TIXML_USE_STL -void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } -} -#endif - -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = ""; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; - } -} - -#ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } -} -#endif - -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) -{ - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; -} - -bool TiXmlText::Blank() const -{ - for ( unsigned i=0; i diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 6f628dfd72..c8a40f857d 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -46,7 +46,7 @@ #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 319709734c..175cc98b38 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -56,7 +56,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 343bc6c6fc..09a9ef08f4 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index bd4dc1906c..00703c3b1a 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/Ad/AdEntity.h" #include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 656d38f247..952ecce4b7 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFontStorage.h" #include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 5d946b4895..4ce6172015 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -41,7 +41,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f3760dcb98..8ebc674c63 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -57,7 +57,7 @@ #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include #include diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index a280916734..28e5b2cf26 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Ad/AdTalkDef.h" #include "engines/wintermute/Ad/AdTalkNode.h" #include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Ad/AdScene.h" diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index d3c655bebe..67c7c74e42 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Ad/AdSpriteSet.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 2c68b188e6..c8f2c2c971 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" namespace WinterMute { IMPLEMENT_PERSISTENT(CAdTalkNode, false) diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 99f64a4d3b..8a8de885c0 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -30,8 +30,8 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/Base/BDiskFile.h" #include "engines/wintermute/Base/BResourceFile.h" #include "engines/wintermute/Base/BSaveThumbFile.h" @@ -41,7 +41,7 @@ #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/dcpackage.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" #include "common/textconsole.h" diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 98864f6ebd..759db24994 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BFontBitmap.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BFrame.h" #include "engines/wintermute/Base/BSurface.h" diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index a52baeb70b..003cada4c7 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -32,15 +32,15 @@ #include "engines/wintermute/Base/BFile.h" #include "engines/wintermute/Base/BFontTT.h" #include "engines/wintermute/FontGlyphCache.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/math/MathUtil.h" #include "engines/wintermute/Base/BRenderSDL.h" #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index dbeb010317..7febffbab5 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -51,9 +51,9 @@ #include "engines/wintermute/Base/BRegion.h" #include "engines/wintermute/Base/BSaveThumbHelper.h" #include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/crc.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 76156edc61..7c5505bd4a 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/Base/BSaveThumbHelper.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BSound.h" #include "common/str.h" diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 87d7c492c4..06a8a63f4f 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -29,10 +29,10 @@ #include #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 9dcbbadf7e..2a3daf144a 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/Base/BSoundBuffer.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "audio/audiostream.h" #include "audio/mixer.h" #include "audio/decoders/vorbis.h" diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index d0d757777f..8c98f83dc2 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -29,8 +29,8 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/PathUtil.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 5720cd1f42..87da65e9d0 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -28,8 +28,8 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/StringUtil.h" -#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/Base/BSurface.h" diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index f8196c5677..8b71e2ac60 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 2667643882..e37d0f1373 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BRegion.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 5a17706ca6..cb276242c0 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/PartEmitter.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" #include diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 9e954cd1ef..7761246ed6 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFile.h" #include "engines/wintermute/Base/BFileManager.h" diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 3562392b13..26d19376a1 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #ifdef __IPHONEOS__ # include "IOS_StoreKit_interface.h" diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 42fe6983e4..0d73bb9c11 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_SXSTORE_H #define WINTERMUTE_SXSTORE_H #include "engines/wintermute/Base/BPersistMgr.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/Base/BObject.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 408b892c05..4a1936da58 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -29,10 +29,10 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/Base/scriptables/SXString.h" #include "engines/wintermute/Base/scriptables/SXArray.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 9929fd7ce2..a2c7e077a0 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 5e2e5861e7..4d545bea66 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index ed3778b635..b2df4cae16 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BScriptable.h" namespace WinterMute { diff --git a/engines/wintermute/ConvertUTF.c b/engines/wintermute/ConvertUTF.c deleted file mode 100644 index 8f7d6d2124..0000000000 --- a/engines/wintermute/ConvertUTF.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Source code file. - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Sept 2001: fixed const & error conditions per - mods suggested by S. Parent & A. Lillich. - June 2002: Tim Dodd added detection and handling of incomplete - source sequences, enhanced error detection, added casts - to eliminate compiler warnings. - July 2003: slight mods to back out aggressive FFFE detection. - Jan 2004: updated switches in from-UTF8 conversions. - Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. - - See the header file "ConvertUTF.h" for complete documentation. - ------------------------------------------------------------------------- */ - - -#include "ConvertUTF.h" -#ifdef CVTUTF_DEBUG -#include -#endif - -static const int halfShift = 10; /* used for shifting by 10 bits */ - -static const UTF32 halfBase = 0x0010000UL; -static const UTF32 halfMask = 0x3FFUL; - -#define UNI_SUR_HIGH_START (UTF32)0xD800 -#define UNI_SUR_HIGH_END (UTF32)0xDBFF -#define UNI_SUR_LOW_START (UTF32)0xDC00 -#define UNI_SUR_LOW_END (UTF32)0xDFFF -#define false 0 -#define true 1 - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - if (target >= targetEnd) { - result = targetExhausted; - break; - } - ch = *source++; - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_LEGAL_UTF32) { - if (flags == strictConversion) { - result = sourceIllegal; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - --source; /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF32 *target = *targetStart; - UTF32 ch, ch2; - while (source < sourceEnd) { - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - if (target >= targetEnd) { - source = oldSource; /* Back up source pointer! */ - result = targetExhausted; - break; - } - *target++ = ch; - } - *sourceStart = source; - *targetStart = target; -#ifdef CVTUTF_DEBUG - if (result == sourceIllegal) { - fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); - fflush(stderr); - } -#endif - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Index into the table below with the first byte of a UTF-8 sequence to - * get the number of trailing bytes that are supposed to follow it. - * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is - * left as-is for anyone who may want to do such conversion, which was - * allowed in earlier algorithms. - */ -static const char trailingBytesForUTF8[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 -}; - -/* - * Magic values subtracted from a buffer value during UTF8 conversion. - * This table contains as many values as there might be trailing bytes - * in a UTF-8 sequence. - */ -static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL - }; - -/* - * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed - * into the first byte, depending on how many bytes follow. There are - * as many entries in this table as there are UTF-8 sequence types. - * (I.e., one byte sequence, two byte... etc.). Remember that sequencs - * for *legal* UTF-8 will be 4 or fewer bytes total. - */ -static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -/* --------------------------------------------------------------------- */ - -/* The interface converts a whole buffer to avoid function-call overhead. - * Constants have been gathered. Loops & conditionals have been removed as - * much as possible for efficiency, in favor of drop-through switches. - * (See "Note A" at the bottom of the file for equivalent code.) - * If your compiler supports it, the "isLegalUTF8" call can be turned - * into an inline function. - */ - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - UTF32 ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* Figure out how many bytes the result will require */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch < (UTF32)0x110000) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - } - - target += bytesToWrite; - if (target > targetEnd) { - source = oldSource; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Utility routine to tell whether a sequence of bytes is legal UTF-8. - * This must be called with the length pre-determined by the first byte. - * If not calling this from ConvertUTF8to*, then the length can be set by: - * length = trailingBytesForUTF8[*source]+1; - * and the sequence is illegal right away if there aren't that many bytes - * available. - * If presented with a length > 4, this returns false. The Unicode - * definition of UTF-8 goes up to 4-byte sequences. - */ - -static Boolean isLegalUTF8(const UTF8 *source, int length) { - UTF8 a; - const UTF8 *srcptr = source + length; - switch (length) { - default: - return false; - /* Everything else falls through when "true"... */ - case 4: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: - if ((a = (*--srcptr)) > 0xBF) return false; - - switch (*source) { - /* no fall-through in this inner switch */ - case 0xE0: - if (a < 0xA0) return false; - break; - case 0xED: - if (a > 0x9F) return false; - break; - case 0xF0: - if (a < 0x90) return false; - break; - case 0xF4: - if (a > 0x8F) return false; - break; - default: - if (a < 0x80) return false; - } - - case 1: - if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; -} - -/* --------------------------------------------------------------------- */ - -/* - * Exported function to return whether a UTF-8 sequence is legal or not. - * This is not used here; it's just exported. - */ -Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { - int length = trailingBytesForUTF8[*source] + 1; - if (source + length > sourceEnd) { - return false; - } - return isLegalUTF8(source, length); -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 4: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_UTF16) { - if (flags == strictConversion) { - result = sourceIllegal; - source -= (extraBytesToRead + 1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - ch = *source++; - if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* - * Figure out how many bytes the result will require. Turn any - * illegally large UTF32 things (> Plane 17) into replacement chars. - */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch <= UNI_MAX_LEGAL_UTF32) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - result = sourceIllegal; - } - - target += bytesToWrite; - if (target > targetEnd) { - --source; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF32 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; - case 4: - ch += *source++; - ch <<= 6; - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up the source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_LEGAL_UTF32) { - /* - * UTF-16 surrogate values are illegal in UTF-32, and anything - * over Plane 17 (> 0x10FFFF) is illegal. - */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = ch; - } - } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ - result = sourceIllegal; - *target++ = UNI_REPLACEMENT_CHAR; - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- - - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - In UTF-8 writing code, the switches on "bytesToWrite" are - similarly unrolled loops. - - --------------------------------------------------------------------- */ diff --git a/engines/wintermute/ConvertUTF.h b/engines/wintermute/ConvertUTF.h deleted file mode 100644 index 03a8bb2bae..0000000000 --- a/engines/wintermute/ConvertUTF.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Header file. - - Several funtions are included here, forming a complete set of - conversions between the three formats. UTF-7 is not included - here, but is handled in a separate source file. - - Each of these routines takes pointers to input buffers and output - buffers. The input buffers are const. - - Each routine converts the text between *sourceStart and sourceEnd, - putting the result into the buffer between *targetStart and - targetEnd. Note: the end pointers are *after* the last item: e.g. - *(sourceEnd - 1) is the last item. - - The return result indicates whether the conversion was successful, - and if not, whether the problem was in the source or target buffers. - (Only the first encountered problem is indicated.) - - After the conversion, *sourceStart and *targetStart are both - updated to point to the end of last text successfully converted in - the respective buffers. - - Input parameters: - sourceStart - pointer to a pointer to the source buffer. - The contents of this are modified on return so that - it points at the next thing to be converted. - targetStart - similarly, pointer to pointer to the target buffer. - sourceEnd, targetEnd - respectively pointers to the ends of the - two buffers, for overflow checking only. - - These conversion functions take a ConversionFlags argument. When this - flag is set to strict, both irregular sequences and isolated surrogates - will cause an error. When the flag is set to lenient, both irregular - sequences and isolated surrogates are converted. - - Whether the flag is strict or lenient, all illegal sequences will cause - an error return. This includes sequences such as: , , - or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code - must check for illegal sequences. - - When the flag is set to lenient, characters over 0x10FFFF are converted - to the replacement character; otherwise (when the flag is set to strict) - they constitute an error. - - Output parameters: - The value "sourceIllegal" is returned from some routines if the input - sequence is malformed. When "sourceIllegal" is returned, the source - value will point to the illegal value that caused the problem. E.g., - in UTF-8 when a sequence is malformed, it points to the start of the - malformed sequence. - - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Fixes & updates, Sept 2001. - ------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------- - The following 4 definitions are compiler-specific. - The C standard does not guarantee that wchar_t has at least - 16 bits, so wchar_t is no less portable than unsigned short! - All should be unsigned values to avoid sign extension during - bit mask & shift operations. ------------------------------------------------------------------------- */ - -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ - -/* Some fundamental constants */ -#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD -#define UNI_MAX_BMP (UTF32)0x0000FFFF -#define UNI_MAX_UTF16 (UTF32)0x0010FFFF -#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF -#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF - -typedef enum { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ -} ConversionResult; - -typedef enum { - strictConversion = 0, - lenientConversion -} ConversionFlags; - -/* This is for C++ and does no harm in C */ -#ifdef __cplusplus -extern "C" { -#endif - - ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - - Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); - -#ifdef __cplusplus -} -#endif - -/* --------------------------------------------------------------------- */ diff --git a/engines/wintermute/PathUtil.cpp b/engines/wintermute/PathUtil.cpp deleted file mode 100644 index dc722e2389..0000000000 --- a/engines/wintermute/PathUtil.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include -#include -#include "PathUtil.h" -#include "StringUtil.h" - - -#ifdef __WIN32__ -# include -#endif - -#ifdef __MACOSX__ -# include -#endif - -#ifdef __IPHONEOS__ -# include "ios_utils.h" -#endif - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::UnifySeparators(const AnsiString &path) { - AnsiString newPath = path; - - std::replace(newPath.begin(), newPath.end(), L'\\', L'/'); - return newPath; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::NormalizeFileName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); - StringUtil::ToLowerCase(newPath); - return newPath; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::Combine(const AnsiString &path1, const AnsiString &path2) { - AnsiString newPath1 = UnifySeparators(path1); - AnsiString newPath2 = UnifySeparators(path2); - - if (!StringUtil::EndsWith(newPath1, "/", true) && !StringUtil::StartsWith(newPath2, "/", true)) - newPath1 += "/"; - - return newPath1 + newPath2; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetDirectoryName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); - Common::String filename = GetFileName(path); - return Common::String(path.c_str(), path.size() - filename.size()); - //if (pos == AnsiString::npos) return ""; - //else return newPath.substr(0, pos + 1); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetFileName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. - Common::String lastPart = Common::lastPathComponent(path, '/'); - if (lastPart[lastPart.size() - 1 ] != '/') - return lastPart; - else - return path; - //if (pos == AnsiString::npos) return path; - //else return newPath.substr(pos + 1); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { - AnsiString fileName = GetFileName(path); - - //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! - // TODO: Prettify this. - Common::String extension = Common::lastPathComponent(path, '.'); - Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); - return filename; - //if (pos == AnsiString::npos) return fileName; - //else return fileName.substr(0, pos); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetExtension(const AnsiString &path) { - AnsiString fileName = GetFileName(path); - - //size_t pos = fileName.find_last_of('.'); - return Common::lastPathComponent(path, '.'); - //if (pos == AnsiString::npos) return ""; - //else return fileName.substr(pos); -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetSafeLogFileName() { - AnsiString logFileName = GetUserDirectory(); - -#ifdef __WIN32__ - char moduleName[MAX_PATH]; - ::GetModuleFileName(NULL, moduleName, MAX_PATH); - - AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; - fileName = Combine("/Wintermute Engine/Logs/", fileName); - logFileName = Combine(logFileName, fileName); - -#else - // !PORTME - logFileName = Combine(logFileName, "/Wintermute Engine/wme.log"); -#endif - - CreateDirectory(GetDirectoryName(logFileName)); - return logFileName; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::CreateDirectory(const AnsiString &path) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::FileExists(const AnsiString &fileName) { - std::ifstream stream; - - stream.open(fileName.c_str()); - bool ret = stream.is_open(); - stream.close(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetUserDirectory() { - AnsiString userDir = "./"; - -#ifdef __WIN32__ - char buffer[MAX_PATH]; - buffer[0] = '\0'; - LPITEMIDLIST pidl = NULL; - LPMALLOC pMalloc; - if (SUCCEEDED(SHGetMalloc(&pMalloc))) { - SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - if (pidl) { - SHGetPathFromIDList(pidl, buffer); - } - pMalloc->Free(pidl); - userDir = AnsiString(buffer); - } -#elif __MACOSX__ - FSRef fileRef; - OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); - if (error == noErr) { - char buffer[MAX_PATH]; - error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); - if (error == noErr) - userDir = buffer; - - } -#elif __IPHONEOS__ - char path[MAX_PATH]; - IOS_GetDataDir(path); - userDir = AnsiString(path); -#endif - - return userDir; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/PathUtil.h b/engines/wintermute/PathUtil.h deleted file mode 100644 index 0bc883a1fa..0000000000 --- a/engines/wintermute/PathUtil.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PATHUTILS_H -#define WINTERMUTE_PATHUTILS_H - -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -class PathUtil { -public: - static AnsiString UnifySeparators(const AnsiString &path); - static AnsiString NormalizeFileName(const AnsiString &path); - static AnsiString Combine(const AnsiString &path1, const AnsiString &path2); - static AnsiString GetDirectoryName(const AnsiString &path); - static AnsiString GetFileName(const AnsiString &path); - static AnsiString GetFileNameWithoutExtension(const AnsiString &path); - static AnsiString GetExtension(const AnsiString &path); - static bool CreateDirectory(const AnsiString &path); - static bool MatchesMask(const AnsiString &fileName, const AnsiString &mask); - - static bool FileExists(const AnsiString &fileName); - - static AnsiString GetSafeLogFileName(); - static AnsiString GetUserDirectory(); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 765c6ecd93..909ecb525e 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BRenderSDL.h" -#include "engines/wintermute/PathUtil.h" +#include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/Base/BSoundMgr.h" diff --git a/engines/wintermute/StringUtil.cpp b/engines/wintermute/StringUtil.cpp deleted file mode 100644 index cd4f99e034..0000000000 --- a/engines/wintermute/StringUtil.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include -#include -#include -#include "common/tokenizer.h" -#include "StringUtil.h" -#include "ConvertUTF.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -void StringUtil::ToLowerCase(AnsiString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); -} - -////////////////////////////////////////////////////////////////////////// -/*void StringUtil::ToLowerCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towlower); -}*/ - -////////////////////////////////////////////////////////////////////////// -void StringUtil::ToUpperCase(AnsiString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::toupper); -} - -////////////////////////////////////////////////////////////////////////// -/*void StringUtil::ToUpperCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towupper); -}*/ - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { - AnsiString str1lc = str1; - AnsiString str2lc = str2; - - ToLowerCase(str1lc); - ToLowerCase(str2lc); - - return (str1lc == str2lc); -} - -////////////////////////////////////////////////////////////////////////// -/*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { - WideString str1lc = str1; - WideString str2lc = str2; - - ToLowerCase(str1lc); - ToLowerCase(str2lc); - - return (str1lc == str2lc); -}*/ - -////////////////////////////////////////////////////////////////////////// -WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { - error("StringUtil::Utf8ToWide - WideString not supported yet"); - /* size_t WideSize = Utf8Str.size(); - - if (sizeof(wchar_t) == 2) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF16 *TargetStart = reinterpret_cast(WideStringNative); - UTF16 *TargetEnd = TargetStart + WideSize + 1; - - ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else if (sizeof(wchar_t) == 4) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF32 *TargetStart = reinterpret_cast(WideStringNative); - UTF32 *TargetEnd = TargetStart + WideSize; - - ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else { - return L""; - }*/ - return ""; -} - -////////////////////////////////////////////////////////////////////////// -Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { - error("StringUtil::WideToUtf8 - Widestring not supported yet"); - /* size_t WideSize = WideStr.length(); - - if (sizeof(wchar_t) == 2) { - size_t Utf8Size = 3 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF16 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else if (sizeof(wchar_t) == 4) { - size_t Utf8Size = 4 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF32 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else { - return (Utf8String)""; - }*/ - return ""; -} - -////////////////////////////////////////////////////////////////////////// -WideString StringUtil::AnsiToWide(const AnsiString &str) { - // using default os locale! - error("StringUtil::AnsiToWide - WideString not supported yet"); - /* setlocale(LC_CTYPE, ""); - size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; - wchar_t *wstr = new wchar_t[WideSize]; - mbstowcs(wstr, str.c_str(), WideSize); - WideString ResultString(wstr); - delete [] wstr; - return ResultString;*/ - return ""; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::WideToAnsi(const WideString &wstr) { - // using default os locale! - error("StringUtil::WideToAnsi - WideString not supported yet"); - /* setlocale(LC_CTYPE, ""); - size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; - char *str = new char[WideSize]; - wcstombs(str, wstr.c_str(), WideSize); - AnsiString ResultString(str); - delete [] str; - return ResultString;*/ - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString startPart = str.substr(0, patternLength); - - if (ignoreCase) return CompareNoCase(startPart, pattern); - else return (startPart == pattern);*/ - if (!ignoreCase) - return str.hasPrefix(pattern); - else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString startPart(str.c_str(), patternLength); - uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); - return (likeness == 0); - } -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); // TODO: Remove - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString endPart = str.substr(strLength - patternLength, patternLength); - - if (ignoreCase) return CompareNoCase(endPart, pattern); - else return (endPart == pattern);*/ - if (!ignoreCase) { - return str.hasSuffix(pattern); - } else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); - uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); - return (likeness != 0); - } -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::IsUtf8BOM(const byte *Buffer, uint32 BufferSize) { - if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; - else return false; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { - if (from.empty() || from == to) return str; - - AnsiString result = str; - /*size_t pos = 0;*/ - - while (result.contains(from)) { - const char *startPtr = strstr(result.c_str(), from.c_str()); - uint32 index = startPtr - result.c_str(); - - Common::String tail(result.c_str() + index + to.size()); - result = Common::String(result.c_str(), index); - result += to; - result += tail; - - /* pos = result.find(from, pos); - if (pos == result.npos) break; - - result.replace(pos, from.size(), to); - pos += to.size();*/ - } - - return result; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { - AnsiString trimmedStr = str; - - if (fromRight) { - //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO - warning("fromRight-trim not implemented yet, %s", chars.c_str()); - } - if (fromLeft) { - uint32 lastOf = LastIndexOf(str, chars, 0); - trimmedStr = Common::String(trimmedStr.c_str() + lastOf); - //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); - } - return trimmedStr; -} - -////////////////////////////////////////////////////////////////////////// -int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.find(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ - const char *index = strstr(str.c_str(), toFind.c_str()); - if (index == NULL) - return -1; - else - return index - str.c_str(); -} - -////////////////////////////////////////////////////////////////////////// -int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.rfind(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ - int32 lastIndex = -1; - bool found = false; - for (size_t i = startFrom; i < str.size(); i++) { - found = false; - for (size_t j = 0; j < toFind.size(); j++) { - if (str[i + j] != toFind[j]) { - found = false; - break; - } else { - found = true; - } - } - if (found) - lastIndex = i; - } - return lastIndex; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(size_t val) { - /* std::ostringstream str; - str << val; - return str.str();*/ - return Common::String::format("%u", (uint32)val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(int val) { - /* std::ostringstream str; - str << val; - return str.str();*/ - return Common::String::format("%d", val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(float val) { - /* std::ostringstream str; - str << val; - return str.str();*/ - return Common::String::format("%f", val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(double val) { - /* std::ostringstream str; - str << val; - return str.str();*/ - return Common::String::format("%f", val); -} - - -////////////////////////////////////////////////////////////////////////// -void StringUtil::Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { - result.clear(); -//TODO: Verify this, wrt keepEmptyItems. - Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); - //typedef boost::char_separator separator_t; - //typedef boost::tokenizer tokenizer_t; - - //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); - //tokenizer_t tokens(list, del); - while (!tokenizer.empty()) { - Common::String copy(tokenizer.nextToken().c_str()); - result.push_back(copy); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/StringUtil.h b/engines/wintermute/StringUtil.h deleted file mode 100644 index a4727fabbe..0000000000 --- a/engines/wintermute/StringUtil.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_STRINGUTIL_H -#define WINTERMUTE_STRINGUTIL_H - -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -class StringUtil { -public: - static void ToLowerCase(AnsiString &str); - //static void ToLowerCase(WideString &str); - static void ToUpperCase(AnsiString &str); - //static void ToUpperCase(WideString &str); - static bool CompareNoCase(const AnsiString &str1, const AnsiString &str2); - //static bool CompareNoCase(const WideString &str1, const WideString &str2); - static WideString Utf8ToWide(const Utf8String &Utf8Str); - static Utf8String WideToUtf8(const WideString &WideStr); - static WideString AnsiToWide(const AnsiString &str); - static AnsiString WideToAnsi(const WideString &str); - - static bool StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - - static bool IsUtf8BOM(const byte *buffer, uint32 bufferSize); - - static AnsiString Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); - static AnsiString Trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); - - static int IndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static int LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - - static AnsiString ToString(size_t val); - static AnsiString ToString(int val); - static AnsiString ToString(float val); - static AnsiString ToString(double val); - - static void Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 3f2bc71996..b85159240f 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/UI/UIEdit.h" #include "engines/wintermute/UI/UIObject.h" #include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/StringUtil.h" +#include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BActiveRect.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BFont.h" @@ -44,7 +44,7 @@ #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils.h" +#include "engines/wintermute/utils/utils.h" #include "common/util.h" #include "common/keyboard.h" diff --git a/engines/wintermute/VidPlayer.cpp b/engines/wintermute/VidPlayer.cpp deleted file mode 100644 index ab20135595..0000000000 --- a/engines/wintermute/VidPlayer.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - -#include "engines/wintermute/dcgf.h" -#include "VidPlayer.h" - -//#pragma comment(lib, "vfw32.lib") - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::SetDefaults() { - _playing = false; - -/* _aviFile = NULL; - - _audioStream = NULL; - _audioFormat = NULL; - - _videoStream = NULL; - _videoFormat = NULL; - _videoPGF = NULL;*/ - _videoEndTime = 0; - - //_sound = NULL; - _soundAvailable = false; - - //_vidRenderer = NULL; - - _startTime = 0; - _totalVideoTime = 0; - - //_lastSample = -1; - - //_targetFormat = NULL; - - _playPosX = _playPosY = 0; - _playZoom = 0.0f; - - _filename = NULL; - - _slowRendering = false; - - _currentSubtitle = 0; - _showSubtitle = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CVidPlayer::~CVidPlayer() { - Cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Cleanup() { -#if 0 - if (_sound) _sound->Stop(); - if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); - _videoPGF = NULL; - - _playing = false; - - - if (_aviFile) AVIFileRelease(m_AviFile); - - if (_audioStream) AVIStreamRelease(m_AudioStream); - if (_videoStream) AVIStreamRelease(m_VideoStream); - - if (_audioFormat) delete [](byte *)m_AudioFormat; - if (_videoFormat) delete [](byte *)m_VideoFormat; - if (_targetFormat) delete [](byte *)m_TargetFormat; - - SAFE_DELETE(_sound); - SAFE_DELETE(_vidRenderer); - - SAFE_DELETE_ARRAY(_filename); - - for (int i = 0; i < _subtitles.GetSize(); i++) delete _subtitles[i]; - _subtitles.RemoveAll(); - - return SetDefaults(); -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Initialize(char *inFilename, char *SubtitleFile) { -#if 0 - Cleanup(); - - char Filename[MAX_PATH]; - Game->_fileManager->GetFullPath(inFilename, Filename); - - // open file - if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - Game->LOG(0, "Error opening AVI file '%s'", Filename); - return E_FAIL; - } - - // get video stream - if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - Game->LOG(0, "Error finding video stream in AVI file '%s'", Filename); - return E_FAIL; - } - _totalVideoTime = AVIStreamEndTime(_videoStream); - - // get audio stream - if (Game->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) - _soundAvailable = true; - else - _soundAvailable = false; - - - LONG Size; - - // get video format - if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", Filename); - return E_FAIL; - } - _videoFormat = (LPBITMAPINFO)new BYTE[Size]; - AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); - - // initialize optimal target format - m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; - memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); - memcpy(m_TargetFormat, m_VideoFormat, Size); - m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); - - m_TargetFormat->bV4BitCount = 24; - m_TargetFormat->bV4V4Compression = BI_RGB; - - if (Game->m_UseD3D) - m_VidRenderer = new CVidRendererD3D(Game); - else - m_VidRenderer = new CVidRendererDD(Game); - - if (!m_VidRenderer || FAILED(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - Game->LOG(0, "Error initializing video renderer for AVI file '%s'", Filename); - SAFE_DELETE(m_VidRenderer); - return E_FAIL; - } - - - // create sound buffer - HRESULT res; - - if (_soundAvailable) { - _sound = new CBSoundAVI(Game); - if (FAILED(res = _sound->InitializeBuffer(_audioStream))) { - SAFE_DELETE(_sound); - _soundAvailable = false; - Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", Filename); - } - } - - if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); - - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Update() { -#if 0 - if (!m_Playing) return S_OK; - - HRESULT res; - - if (_soundAvailable && m_Sound) { - res = _sound->Update(); - if (FAILED(res)) return res; - } - - - DWORD CurrentTime; // current playing time (in ms) - /* - if(m_SoundAvailable && m_Sound){ - CurrentTime = m_Sound->GetPosition(); // in samples - CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); - - if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; - } - else - CurrentTime = timeGetTime() - m_StartTime; - */ - CurrentTime = timeGetTime() - _startTime; - - if (CurrentTime >= _totalVideoTime) { - Stop(); - return S_OK; - } - - - // get and render frame - DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); - if (sample != _lastSample) { - _lastSample = sample; - - // process subtitles - _showSubtitle = false; - while (_currentSubtitle < _subtitles.GetSize()) { - int End = _subtitles[_currentSubtitle]->m_EndFrame; - - bool NextFrameOK = (_currentSubtitle < _subtitles.GetSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); - - if (sample > End) { - if (NextFrameOK) { - _currentSubtitle++; - } else { - _showSubtitle = (End == 0); - break; - } - } else { - _showSubtitle = true; - break; - } - } - - - // render frame - LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); - if (FrameData) { - if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); - else return _vidRenderer->ProcessFrame(FrameData); - } else return E_FAIL; - } else return S_OK; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Display() { -#if 0 - if (!m_Playing) return S_OK; - - HRESULT res; - if (_vidRenderer) res = _vidRenderer->Display(m_PlayPosX, m_PlayPosY, m_PlayZoom); - else res = E_FAIL; - - // display subtitle - if (m_ShowSubtitle) { - CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); - font->DrawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); - } - - return res; -#endif - return 0; -} - - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { -#if 0 - if (!_videoStream || !_vidRenderer) return E_FAIL; - - switch (Type) { - case VID_PLAY_POS: - _playZoom = 100.0f; - _playPosX = X; - _playPosY = Y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float ZoomY = (float)((float)Game->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); - _playZoom = min(ZoomX, ZoomY); - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - _playZoom = 100.0f; - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; - break; - } - - _targetFormat->bV4BitCount = 24; - _targetFormat->bV4V4Compression = BI_RGB; - - - _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); - if (!_videoPGF) { - _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); - if (!_videoPGF) { - Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); - Cleanup(); - return E_FAIL; - } else { - Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); - _slowRendering = true; - } - } else _slowRendering = false; - - // HACK!!! - _slowRendering = true; - - - _currentSubtitle = 0; - - Game->Freeze(FreezeMusic); - - _playing = true; - if (_sound) _sound->Play(); - _startTime = timeGetTime(); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Stop() { -#if 0 - if (!_playing) return S_OK; - - Cleanup(); - - Game->Unfreeze(); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::IsPlaying() { - return _playing; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::LoadSubtitles(char *Filename, char *SubtitleFile) { -#if 0 - if (!Filename) return S_OK; - - char NewFile[MAX_PATH]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - - if (SubtitleFile) { - strcpy(NewFile, SubtitleFile); - } else { - _splitpath(Filename, drive, dir, fname, NULL); - _makepath(NewFile, drive, dir, fname, ".SUB"); - } - - DWORD Size; - BYTE *Buffer = Game->m_FileManager->ReadWholeFile(NewFile, &Size, false); - if (Buffer == NULL) return S_OK; // no subtitles - - - LONG Start, End; - bool InToken; - char *TokenStart; - int TokenLength; - int TokenPos; - int TextLength; - - int Pos = 0; - int LineLength = 0; - while (Pos < Size) { - Start = End = -1; - InToken = false; - TokenPos = -1; - TextLength = 0; - - LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; - - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *Text = new char[RealLength + 1]; - char *line = (char *)&Buffer[Pos]; - - for (int i = 0; i < RealLength; i++) { - if (line[i] == '{') { - if (!InToken) { - InToken = true; - TokenStart = line + i + 1; - TokenLength = 0; - TokenPos++; - } else TokenLength++; - } else if (line[i] == '}') { - if (InToken) { - InToken = false; - char *Token = new char[TokenLength + 1]; - strncpy(Token, TokenStart, TokenLength); - Token[TokenLength] = '\0'; - if (TokenPos == 0) Start = atoi(Token); - else if (TokenPos == 1) End = atoi(Token); - - delete [] Token; - } else { - Text[TextLength] = line[i]; - TextLength++; - } - } else { - if (InToken) { - TokenLength++; - } else { - Text[TextLength] = line[i]; - if (Text[TextLength] == '|') Text[TextLength] = '\n'; - TextLength++; - } - } - } - Text[TextLength] = '\0'; - - if (Start != -1 && TextLength > 0) _subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); - - delete [] Text; - - Pos += LineLength + 1; - } - - delete [] Buffer; -#endif - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/VidPlayer.h b/engines/wintermute/VidPlayer.h deleted file mode 100644 index a1abf2ea46..0000000000 --- a/engines/wintermute/VidPlayer.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VIDPLAYER_H -#define WINTERMUTE_VIDPLAYER_H - -#include "engines/wintermute/dctypes.h" // Added by ClassView -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "engines/wintermute/Base/BBase.h" - -#define MAX_AUDIO_STREAMS 5 -#define MAX_VIDEO_STREAMS 5 - - -namespace WinterMute { - -class CVidPlayer : public CBBase { -public: - bool _showSubtitle; - int _currentSubtitle; - HRESULT LoadSubtitles(char *Filename, char *SubtitleFile); - bool _slowRendering; - bool IsPlaying(); - char *_filename; - HRESULT Stop(); - HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); - uint32 _totalVideoTime; - uint32 _startTime; - //CVidRenderer *_vidRenderer; - //CBSoundAVI *_sound; - bool _soundAvailable; - HRESULT SetDefaults(); - bool _playing; - HRESULT Display(); - HRESULT Update(); - HRESULT Initialize(char *inFilename, char *SubtitleFile = NULL); - HRESULT Cleanup(); - CVidPlayer(CBGame *inGame); - virtual ~CVidPlayer(); - - /*PAVIFILE _aviFile; - - LONG _lastSample; - - PAVISTREAM _audioStream; - PAVISTREAM _videoStream; - - LPWAVEFORMAT _audioFormat; - - LPBITMAPINFO _videoFormat; - PGETFRAME _videoPGF;*/ - uint32 _videoEndTime; - - int _playPosX; - int _playPosY; - float _playZoom; - -/* LPBITMAPV4HEADER _targetFormat; - - CBArray _subtitles;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/VidTheoraPlayer.cpp b/engines/wintermute/VidTheoraPlayer.cpp deleted file mode 100644 index 509a7006e5..0000000000 --- a/engines/wintermute/VidTheoraPlayer.cpp +++ /dev/null @@ -1,963 +0,0 @@ -// Copyright 2009, 2010 Jan Nedoma -// -// This file is part of Wintermute Engine. -// -// Wintermute Engine is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Wintermute Engine 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 Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Wintermute Engine. If not, see . -////////////////////////////////////////////////////////////////////////// - - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/vidtheoraplayer.h" - -//#pragma comment(lib, "libtheora.lib") - -namespace WinterMute { - -//IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); - -////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { - SetDefaults(); -} - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::SetDefaults() { -#if 0 - _file = NULL; - _filename = NULL; - _startTime = 0; - _looping = false; - _sound = NULL; - _audiobufGranulepos = 0; - _freezeGame = false; - _currentTime = 0; - - _state = THEORA_STATE_NONE; - - _videoFrameReady = false; - _audioFrameReady = false; - _videobufTime = 0; - - _audioBuf = NULL; - _audioBufFill = 0; - _audioBufSize = 0; - _playbackStarted = false; - _dontDropFrames = false; - - _texture = NULL; - _alphaImage = NULL; - _alphaFilename = NULL; - - _frameRendered = false; - - -/* memset(&m_OggSyncState, 0, sizeof(ogg_sync_state)); - memset(&m_OggPage, 0, sizeof(ogg_page)); - memset(&m_VorbisStreamState, 0 , sizeof(ogg_stream_state)); - memset(&m_TheoraStreamState, 0 , sizeof(ogg_stream_state)); - - memset(&m_TheoraInfo, 0, sizeof(theora_info)); - memset(&m_TheoraComment, 0, sizeof(theora_comment)); - memset(&m_TheoraState, 0, sizeof(theora_state)); - - memset(&m_VorbisInfo, 0, sizeof(vorbis_info)); - memset(&m_VorbisDSPState, 0, sizeof(vorbis_dsp_state)); - memset(&m_VorbisBlock, 0, sizeof(vorbis_block)); - memset(&m_VorbisComment, 0, sizeof(vorbis_comment));*/ - - _vorbisStreams = _theoraStreams = 0; - - GenLookupTables(); - - _seekingKeyframe = false; - _timeOffset = 0.0f; - - _posX = _posY = 0; - _playbackType = VID_PLAY_CENTER; - _playZoom = 0.0f; - - _subtitler = NULL; - - _savedState = THEORA_STATE_NONE; - _savedPos = 0; - _volume = 100; -#endif -} - -////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::~CVidTheoraPlayer(void) { - Cleanup(); - - SAFE_DELETE_ARRAY(_filename); - SAFE_DELETE_ARRAY(_alphaFilename); - SAFE_DELETE(_texture); - SAFE_DELETE(_alphaImage); -// SAFE_DELETE(_subtitler); -} - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::Cleanup() { -#if 0 - if (_vorbisStreams) { - ogg_stream_clear(&m_VorbisStreamState); - vorbis_block_clear(&m_VorbisBlock); - vorbis_dsp_clear(&m_VorbisDSPState); - vorbis_comment_clear(&m_VorbisComment); - vorbis_info_clear(&m_VorbisInfo); - - _vorbisStreams = 0; - } - if (m_TheoraStreams) { - ogg_stream_clear(&m_TheoraStreamState); - theora_clear(&m_TheoraState); - theora_comment_clear(&m_TheoraComment); - theora_info_clear(&m_TheoraInfo); - - m_TheoraStreams = 0; - } - ogg_sync_clear(&m_OggSyncState); - - - if (m_File) Game->m_FileManager->CloseFile(m_File); - m_File = NULL; - - if (m_Sound) { - Game->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - } - - - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufFill = 0; - m_AudioBufSize = 0; -#endif -} - -////////////////////////////////////////////////////////////////////////// -/*int CVidTheoraPlayer::BufferData(ogg_sync_state *OggSyncState) { - if (!_file) return 0; - - DWORD Size = 4096; - if (m_File->GetSize() - m_File->GetPos() < Size) Size = m_File->GetSize() - m_File->GetPos(); - - char *Buffer = ogg_sync_buffer(OggSyncState, Size); - m_File->Read(Buffer, Size); - ogg_sync_wrote(OggSyncState, Size); - - return Size; -}*/ - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { -#if 0 - Cleanup(); - - _file = Game->_fileManager->OpenFile(Filename); - if (!_file) return E_FAIL; - - if (Filename != _filename) CBUtils::SetString(&_filename, Filename); - - // start up Ogg stream synchronization layer - ogg_sync_init(&m_OggSyncState); - - // init supporting Vorbis structures needed in header parsing - vorbis_comment_init(&m_VorbisComment); - vorbis_info_init(&m_VorbisInfo); - - // init supporting Theora structures needed in header parsing - theora_comment_init(&m_TheoraComment); - theora_info_init(&m_TheoraInfo); - - - - // Ogg file open; parse the headers - // Only interested in Vorbis/Theora streams - ogg_packet TempOggPacket; - bool IsDone = false; - while (!IsDone) { - int BytesRead = BufferData(&m_OggSyncState); - if (BytesRead == 0) break; - - while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - ogg_stream_state OggStateTest; - - // is this a mandated initial header? If not, stop parsing - if (!ogg_page_bos(&m_OggPage)) { - // don't leak the page; get it into the appropriate stream - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - - IsDone = true; - break; - } - - ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); - ogg_stream_pagein(&OggStateTest, &m_OggPage); - ogg_stream_packetout(&OggStateTest, &TempOggPacket); - - // identify the codec: try theora - if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { - // it is theora - memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); - m_TheoraStreams = 1; - } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { - // it is vorbis - memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); - m_VorbisStreams = 1; - } else { - // whatever it is, we don't care about it - ogg_stream_clear(&OggStateTest); - } - } - } - - // we're expecting more header packets - while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { - int Ret; - - // look for further theora headers - while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { - if (Ret < 0) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return E_FAIL; - } - if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return E_FAIL; - } - m_TheoraStreams++; - if (m_TheoraStreams == 3) break; - } - - /* look for more vorbis header packets */ - while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { - if (Ret < 0) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return E_FAIL; - } - if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return E_FAIL; - } - m_VorbisStreams++; - if (m_VorbisStreams == 3) break; - } - - // The header pages/packets will arrive before anything else we - // care about, or the stream is not obeying spec - if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - } else { - int Ret = BufferData(&m_OggSyncState); // someone needs more data - if (Ret == 0) { - Game->LOG(0, "End of file while searching for codec headers"); - return E_FAIL; - } - } - } - - - - // and now we have it all. initialize decoders - if (m_TheoraStreams) { - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - } else { - // tear down the partial theora setup - theora_info_clear(&m_TheoraInfo); - theora_comment_clear(&m_TheoraComment); - } - - if (m_VorbisStreams) { - vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); - vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); - - } else { - // tear down the partial vorbis setup - vorbis_info_clear(&m_VorbisInfo); - vorbis_comment_clear(&m_VorbisComment); - } - - HRESULT Res = S_OK; - - // create sound buffer - if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { - m_Sound = new CBSoundTheora(Game); - Game->m_SoundMgr->AddSound(m_Sound); - if (FAILED(Res = m_Sound->InitializeBuffer(this))) { - Game->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", Filename); - } else { - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufSize = m_Sound->m_StreamBlockSize; - m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; - } - } - - // create texture - if (m_TheoraStreams && !m_Texture) { - if (Game->m_UseD3D) - m_Texture = new CBSurfaceD3D(Game); - else - m_Texture = new CBSurfaceDD(Game); - - if (!m_Texture || FAILED(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { - SAFE_DELETE(m_Texture); - } - } - - - if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(Filename, SubtitleFile); - - return Res; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::ResetStream() { -#if 0 - if (_sound) _sound->Stop(); - - m_TimeOffset = 0.0f; - Initialize(m_Filename); - Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { -#if 0 - if (ForceZoom < 0.0f) ForceZoom = 100.0f; - if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); - else m_Volume = Volume; - - m_FreezeGame = FreezeGame; - if (!m_PlaybackStarted && m_FreezeGame) Game->Freeze(FreezeMusic); - - m_PlaybackStarted = false; - m_State = THEORA_STATE_PLAYING; - - m_Looping = Looping; - m_PlaybackType = Type; - - float Width, Height; - if (m_TheoraStreams) { - Width = (float)m_TheoraInfo.width; - Height = (float)m_TheoraInfo.height; - } else { - Width = (float)Game->m_Renderer->m_Width; - Height = (float)Game->m_Renderer->m_Height; - } - - switch (Type) { - case VID_PLAY_POS: - m_PlayZoom = ForceZoom; - m_PosX = X; - m_PosY = Y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->m_Renderer->m_Width / Width * 100); - float ZoomY = (float)((float)Game->m_Renderer->m_Height / Height * 100); - m_PlayZoom = min(ZoomX, ZoomY); - m_PosX = (Game->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - m_PlayZoom = 100.0f; - m_PosX = (Game->m_Renderer->m_Width - Width) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height) / 2; - break; - } - - - if (StartTime) SeekToTime(StartTime); - - Update(); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Stop() { -#if 0 - if (m_Sound) m_Sound->Stop(); - m_State = THEORA_STATE_FINISHED; - if (m_FreezeGame) Game->Unfreeze(); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Update() { -#if 0 - m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; - - if (!IsPlaying()) return S_OK; - - if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return S_OK; - - if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return S_OK; - - int Counter = 0; - while (true) { - if (m_Sound) DecodeVorbis(); - else m_AudioFrameReady = true; - - if (m_Texture) DecodeTheora(); - else m_VideoFrameReady = true; - - if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { - // end playback - if (!m_Looping) { - m_State = THEORA_STATE_FINISHED; - if (m_Sound) m_Sound->Stop(); - if (m_FreezeGame) Game->Unfreeze(); - break; - } else { - ResetStream(); - return S_OK; - } - } - - - if (!m_VideoFrameReady || !m_AudioFrameReady) { - Counter++; - if (StreamInData() == 0) break; - } else break; - } - - - // If playback has begun, top audio buffer off immediately. - //if(m_Sound) WriteAudio(); - - // are we at or past time for this video frame? - if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { - //Game->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); - if (m_Texture) WriteVideo(); - m_VideoFrameReady = false; - - if (m_SavedState == THEORA_STATE_PAUSED) { - Pause(); - m_SavedState = THEORA_STATE_NONE; - } - } - - // if our buffers either don't exist or are ready to go, - // we can begin playback - bool StartNow = false; - if ((!m_TheoraStreams || m_VideoFrameReady) && - (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; - // same if we've run out of input - if (m_File->IsEOF()) StartNow = true; - - - if (m_Sound) WriteAudio(); - - - if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { - //m_StartTime = timeGetTime(); - m_StartTime = m_CurrentTime; - if (m_Sound) { - m_Sound->SetPrivateVolume(m_Volume); - m_Sound->Play(); - } - m_PlaybackStarted = true; - } - - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Update(GetMovieFrame()); -#endif - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -/*int CVidTheoraPlayer::StreamInData() { -#if 0 - // no data yet for somebody. Grab another page - int BytesRead = BufferData(&m_OggSyncState); - while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - } - return BytesRead; -#endif -}*/ - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::DecodeVorbis() { -#if 0 - if (!m_Sound) return; - - while (m_VorbisStreams && !m_AudioFrameReady) { - int ret; - float **pcm; - - // if there's pending, decoded audio, grab it - if ((ret = vorbis_synthesis_pcmout(&m_VorbisDSPState, &pcm)) > 0 && !m_SeekingKeyframe) { - int count = m_AudioBufFill / 2; - int maxsamples = (m_AudioBufSize - m_AudioBufFill) / 2 / m_VorbisInfo.channels; - - int i; - for (i = 0; i < ret && i < maxsamples; i++) - for (int j = 0; j < m_VorbisInfo.channels; j++) { - int val = (int)(pcm[j][i] * 32767.f); - if (val > 32767) val = 32767; - if (val < -32768) val = -32768; - - m_AudioBuf[count++] = val; - } - vorbis_synthesis_read(&m_VorbisDSPState, i); - m_AudioBufFill += i * m_VorbisInfo.channels * 2; - if (m_AudioBufFill == m_AudioBufSize) m_AudioFrameReady = true; - if (m_VorbisDSPState.granulepos >= 0) - m_AudiobufGranulepos = m_VorbisDSPState.granulepos - ret + i; - else - m_AudiobufGranulepos += i; - } else { - ogg_packet opVorbis; - - //no pending audio; is there a pending packet to decode? - if (ogg_stream_packetout(&m_VorbisStreamState, &opVorbis) > 0) { - //test for success! - if (vorbis_synthesis(&m_VorbisBlock, &opVorbis) == 0) - vorbis_synthesis_blockin(&m_VorbisDSPState, &m_VorbisBlock); - } else { //we need more data; break out to suck in another page - break; - } - } - } // while -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::DecodeTheora() { -#if 0 - ogg_packet opTheora; - - while (m_TheoraStreams && !m_VideoFrameReady) { - // theora is one in, one out... - if (ogg_stream_packetout(&m_TheoraStreamState, &opTheora) > 0) { - theora_decode_packetin(&m_TheoraState, &opTheora); - m_VideobufTime = theora_granule_time(&m_TheoraState, m_TheoraState.granulepos); - - if (m_SeekingKeyframe) { - if (!theora_packet_iskeyframe(&opTheora)) continue; - else { - m_SeekingKeyframe = false; - m_TimeOffset = m_VideobufTime; - } - } - - if (m_VideobufTime >= GetMovieTime() || m_DontDropFrames) m_VideoFrameReady = true; - } else { - break; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -float CVidTheoraPlayer::GetMovieTime() { -#if 0 - if (!m_PlaybackStarted) return 0.0f; - else if (m_Sound) return (float)(m_Sound->GetPosition()) / 1000.0f + m_TimeOffset; - else return (float)(m_CurrentTime - m_StartTime) / 1000.0f + m_TimeOffset; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CVidTheoraPlayer::GetMovieFrame() { -#if 0 - if (!m_TheoraStreams) return 0; - float Time = GetMovieTime(); - - return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::WriteAudio() { -#if 0 - if (m_AudioFrameReady) { - if (m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize)) { - m_AudioBufFill = 0; - m_AudioFrameReady = false; - } - } else if (m_File->IsEOF()) { - memset(m_AudioBuf, 0, m_AudioBufSize); - m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize); - } -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::WriteVideo() { -#if 0 - if (!m_Texture) return E_FAIL; - - yuv_buffer yuv; - theora_decode_YUVout(&m_TheoraState, &yuv); - - m_Texture->StartPixelOp(); - RenderFrame(m_Texture, &yuv); - m_Texture->EndPixelOp(); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Display(uint32 Alpha) { - - RECT rc; - HRESULT Res; -#if 0 - if (m_Texture) { - SetRect(&rc, 0, 0, m_Texture->GetWidth(), m_Texture->GetHeight()); - if (m_PlayZoom == 100.0f) Res = m_Texture->DisplayTrans(m_PosX, m_PosY, rc, Alpha); - else Res = m_Texture->DisplayTransZoom(m_PosX, m_PosY, rc, m_PlayZoom, m_PlayZoom, Alpha); - } else Res = E_FAIL; - - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); -#endif - return Res; -} - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::GenLookupTables() { - //used to bring the table into the high side (scale up) so we - //can maintain high precision and not use floats (FIXED POINT) - int scale = 1L << 13; - int temp; - - for (unsigned int i = 0; i < 256; i++) { - temp = i - 128; - - _yTable[i] = (unsigned int)((1.164 * scale + 0.5) * (i - 16)); //Calc Y component - - _rVTable[i] = (unsigned int)((1.596 * scale + 0.5) * temp); //Calc R component - - _gUTable[i] = (unsigned int)((0.391 * scale + 0.5) * temp); //Calc G u & v components - _gVTable[i] = (unsigned int)((0.813 * scale + 0.5) * temp); - - _bUTable[i] = (unsigned int)((2.018 * scale + 0.5) * temp); //Calc B component - } -} - -#define CLIP_RGB_COLOR( rgb_color_test ) max( min(rgb_color_test, 255), 0 ) -////////////////////////////////////////////////////////////////////////// -#if 0 -HRESULT CVidTheoraPlayer::RenderFrame(CBSurface *Texture, yuv_buffer *yuv) { - //Convert 4:2:0 YUV YCrCb to an RGB24 Bitmap - //convenient pointers - int TargetX1 = 0; - int TargetX2 = 1; - int TargetY1 = 0; - int TargetY2 = 1; - - unsigned char *ySrc = (unsigned char *)yuv->y; - unsigned char *uSrc = (unsigned char *)yuv->u; - unsigned char *vSrc = (unsigned char *)yuv->v; - unsigned char *ySrc2 = ySrc + yuv->y_stride; - - //Calculate buffer offset - int yOff = (yuv->y_stride * 2) - yuv->y_width; - - - //Check if upside down, if so, reverse buffers and offsets - if (yuv->y_height < 0) { - yuv->y_height = -yuv->y_height; - ySrc += (yuv->y_height - 1) * yuv->y_stride; - - uSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; - vSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; - - ySrc2 = ySrc - yuv->y_stride; - yOff = -yuv->y_width - (yuv->y_stride * 2); - - yuv->uv_stride = -yuv->uv_stride; - } - - //Cut width and height in half (uv field is only half y field) - yuv->y_height = yuv->y_height >> 1; - yuv->y_width = yuv->y_width >> 1; - - //Convientient temp vars - signed int r, g, b, u, v, bU, gUV, rV, rgbY; - int x; - - //Loop does four blocks per iteration (2 rows, 2 pixels at a time) - for (int y = yuv->y_height; y > 0; --y) { - for (x = 0; x < yuv->y_width; ++x) { - //Get uv pointers for row - u = uSrc[x]; - v = vSrc[x]; - - //get corresponding lookup values - rgbY = m_YTable[*ySrc]; - rV = m_RVTable[v]; - gUV = m_GUTable[u] + m_GVTable[v]; - bU = m_BUTable[u]; - ++ySrc; - - //scale down - brings are values back into the 8 bits of a byte - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX1, TargetY1, r, g, b, GetAlphaAt(TargetX1, TargetY1)); - - //And repeat for other pixels (note, y is unique for each - //pixel, while uv are not) - rgbY = m_YTable[*ySrc]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX2, TargetY1, r, g, b, GetAlphaAt(TargetX2, TargetY1)); - ++ySrc; - - rgbY = m_YTable[*ySrc2]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX1, TargetY2, r, g, b, GetAlphaAt(TargetX1, TargetY2)); - ++ySrc2; - - rgbY = m_YTable[*ySrc2]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX2, TargetY2, r, g, b, GetAlphaAt(TargetX2, TargetY2)); - ++ySrc2; - - /* - Texture->PutPixel(TargetX1, TargetY1, 255, 0, 0, GetAlphaAt(TargetX1, TargetY1)); - Texture->PutPixel(TargetX2, TargetY1, 255, 0, 0, GetAlphaAt(TargetX2, TargetY1)); - Texture->PutPixel(TargetX1, TargetY2, 255, 0, 0, GetAlphaAt(TargetX1, TargetY2)); - Texture->PutPixel(TargetX2, TargetY2, 255, 0, 0, GetAlphaAt(TargetX2, TargetY2)); - */ - - - //Advance inner loop offsets - TargetX1 += 2; - TargetX2 += 2; - } // end for x - - //Advance destination pointers by offsets - TargetX1 = 0; - TargetX2 = 1; - TargetY1 += 2; - TargetY2 += 2; - - ySrc += yOff; - ySrc2 += yOff; - uSrc += yuv->uv_stride; - vSrc += yuv->uv_stride; - } //end for y - - m_FrameRendered = true; - - return S_OK; -} -#endif -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::SetAlphaImage(const char *Filename) { -#if 0 - SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new CBImage(Game); - if (!m_AlphaImage || FAILED(m_AlphaImage->LoadFile(Filename))) { - SAFE_DELETE(m_AlphaImage); - SAFE_DELETE_ARRAY(m_AlphaFilename); - return E_FAIL; - } - if (m_AlphaFilename != Filename) CBUtils::SetString(&m_AlphaFilename, Filename); - m_AlphaImage->Convert(IMG_TRUECOLOR); -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -byte CVidTheoraPlayer::GetAlphaAt(int X, int Y) { -#if 0 - if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); - else return 0xFF; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -inline int intlog(int num) { - int r = 0; - while (num > 0) { - num = num / 2; - r = r + 1; - } - - return r; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::SeekToTime(uint32 Time) { -#if 0 - if (!m_TheoraStreams) return E_FAIL; - - - float TargetTime = Time / 1000.0f; - - - ogg_page page; - int read = 1; - ogg_int64_t gran; - float movieLength = 0; - DWORD LastPos = 0; - - int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); - - while (!m_File->IsEOF() && read != 0) { - read = BufferData(&m_OggSyncState); - - while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { - int serno = ogg_page_serialno(&page); - //This is theora stream we were searching for - if (m_TheoraStreamState.serialno == serno) { - //Calculate a rough time estimate - gran = ogg_page_granulepos(&page); - if (gran >= 0) { - ogg_int64_t iframe = gran >> keyframe_granule_shift; - ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); - movieLength = (iframe + pframe) * - ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); - - if (movieLength >= TargetTime) { - m_TimeOffset = movieLength; - //m_TimeOffset = TargetTime; - //m_File->Seek(LastPos); - - goto finish; - } - LastPos = m_File->GetPos(); - } - } - } - } - -finish: - ogg_sync_reset(&m_OggSyncState); - - ogg_stream_reset(&m_TheoraStreamState); - ogg_stream_reset(&m_VorbisStreamState); - - theora_clear(&m_TheoraState); - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - vorbis_synthesis_restart(&m_VorbisDSPState); - - m_SeekingKeyframe = true; - - //theora_packet_iskeyframe - -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Pause() { -#if 0 - if (m_State == THEORA_STATE_PLAYING) { - m_State = THEORA_STATE_PAUSED; - if (m_Sound) m_Sound->Pause(); - return S_OK; - } else return E_FAIL; -#endif - return 0; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Resume() { -#if 0 - if (_state == THEORA_STATE_PAUSED) { - _state = THEORA_STATE_PLAYING; - if (_sound) _sound->Resume(); - return S_OK; - } else return E_FAIL; -#endif - return 0; -} - -////////////////////////////////////////////////////////////////////////// -/*HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { - //CBBase::Persist(PersistMgr); -#if 0 - if (PersistMgr->m_Saving) { - m_SavedPos = GetMovieTime() * 1000; - m_SavedState = m_State; - } else { - SetDefaults(); - } - - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_SavedPos)); - PersistMgr->Transfer(TMEMBER(m_SavedState)); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_AlphaFilename)); - PersistMgr->Transfer(TMEMBER(m_PosX)); - PersistMgr->Transfer(TMEMBER(m_PosY)); - PersistMgr->Transfer(TMEMBER(m_PlayZoom)); - PersistMgr->Transfer(TMEMBER_INT(m_PlaybackType)); - PersistMgr->Transfer(TMEMBER(m_Looping)); - - if (PersistMgr->CheckVersion(1, 7, 3)) { - PersistMgr->Transfer(TMEMBER(m_Volume)); - } else { - m_Volume = 100; - } -#endif - return S_OK; -} -*/ -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::InitializeSimple() { -#if 0 - if (SUCCEEDED(Initialize(m_Filename))) { - if (m_AlphaFilename) SetAlphaImage(m_AlphaFilename); - Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, m_SavedPos, m_PlayZoom); - } else m_State = THEORA_STATE_FINISHED; -#endif - return S_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CVidTheoraPlayer::GetTexture() { - return _texture; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/VidTheoraPlayer.h b/engines/wintermute/VidTheoraPlayer.h deleted file mode 100644 index 38f3fe85ae..0000000000 --- a/engines/wintermute/VidTheoraPlayer.h +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2009, 2010 Jan Nedoma -// -// This file is part of Wintermute Engine. -// -// Wintermute Engine is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Wintermute Engine 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 Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Wintermute Engine. If not, see . -////////////////////////////////////////////////////////////////////////// - - -#ifndef WINTERMUTE_VIDTHEORAPLAYER_H -#define WINTERMUTE_VIDTHEORAPLAYER_H - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BFile.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BImage.h" -//#include - -namespace WinterMute { - -class CVidTheoraPlayer : public CBBase { -private: - enum { THEORA_STATE_NONE = 0, THEORA_STATE_PLAYING = 1, THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; -public: - //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); - - CVidTheoraPlayer(CBGame *inGame); - virtual ~CVidTheoraPlayer(void); - - // Vorbis/Theora structs - /*ogg_sync_state m_OggSyncState; - ogg_page m_OggPage; - ogg_stream_state m_VorbisStreamState; - ogg_stream_state m_TheoraStreamState; - - theora_info m_TheoraInfo; - theora_comment m_TheoraComment; - theora_state m_TheoraState; - - vorbis_info m_VorbisInfo; - vorbis_dsp_state m_VorbisDSPState; - vorbis_block m_VorbisBlock; - vorbis_comment m_VorbisComment;*/ - - int _theoraStreams; - int _vorbisStreams; - - //ogg_int64_t m_AudiobufGranulepos; //time position of last sample - - - // external objects - CBFile *_file; - char *_filename; - - //CBSoundTheora *_sound; - //ogg_int16_t *_audioBuf; - int _audioBufSize; - int _audioBufFill; - - CBSurface *_texture; - //CVidSubtitler *_subtitler; - - // control methods - HRESULT Initialize(char *Filename, char *SubtitleFile = NULL); - HRESULT InitializeSimple(); - HRESULT Update(); - HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); - HRESULT Stop(); - HRESULT Display(uint32 Alpha = 0xFFFFFFFF); - //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); - - HRESULT Pause(); - HRESULT Resume(); - - bool IsPlaying() { - return _state == THEORA_STATE_PLAYING; - }; - bool IsFinished() { - return _state == THEORA_STATE_FINISHED; - }; - bool IsPaused() { - return _state == THEORA_STATE_PAUSED; - }; - - float GetMovieTime(); - int GetMovieFrame(); - - CBSurface *GetTexture(); - - int _state; - uint32 _startTime; - - int _savedState; - uint32 _savedPos; - - - // alpha related - CBImage *_alphaImage; - char *_alphaFilename; - HRESULT SetAlphaImage(const char *Filename); - __inline byte GetAlphaAt(int X, int Y); - - HRESULT SeekToTime(uint32 Time); - - - void Cleanup(); - HRESULT ResetStream(); - - // video properties - TVideoPlayback m_PlaybackType; - int _posX; - int _posY; - float _playZoom; - int _volume; - - bool _looping; - bool _dontDropFrames; - bool _freezeGame; - uint32 _currentTime; - - -private: - // data streaming - //int BufferData(ogg_sync_state *OggSyncState); - //int StreamInData(); - - - // lookup tables - unsigned int _yTable[256]; - unsigned int _bUTable[256]; - unsigned int _gUTable[256]; - unsigned int _gVTable[256]; - unsigned int _rVTable[256]; - - void GenLookupTables(); - - - // seeking support - bool _seekingKeyframe; - float _timeOffset; - - bool _frameRendered; - - - // decoding - void DecodeVorbis(); - void DecodeTheora(); - - bool _audioFrameReady; - bool _videoFrameReady; - float _videobufTime; - - HRESULT WriteAudio(); - HRESULT WriteVideo(); - - bool _playbackStarted; - - // helpers - void SetDefaults(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/crc.cpp b/engines/wintermute/crc.cpp deleted file mode 100644 index adfd5da624..0000000000 --- a/engines/wintermute/crc.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/********************************************************************** - * - * Filename: crc.c - * - * Description: Slow and fast implementations of the CRC standards. - * - * Notes: The parameters for each supported CRC standard are - * defined in the header file crc.h. The implementations - * here should stand up to further additions to that list. - * - * - * Copyright (c) 2000 by Michael Barr. This software is placed into - * the public domain and may be used for any purpose. However, this - * notice must not be changed or removed and no warranty is either - * expressed or implied by its publication or distribution. - **********************************************************************/ - -#include "crc.h" - - -/* - * Derive parameters from the standard-specific parameters in crc.h. - */ -#define WIDTH (8 * sizeof(crc)) -#define TOPBIT (1 << (WIDTH - 1)) - -#if (REFLECT_DATA == TRUE) -#undef REFLECT_DATA -#define REFLECT_DATA(X) ((unsigned char) reflect((X), 8)) -#else -#undef REFLECT_DATA -#define REFLECT_DATA(X) (X) -#endif - -#if (REFLECT_REMAINDER == TRUE) -#undef REFLECT_REMAINDER -#define REFLECT_REMAINDER(X) ((crc) reflect((X), WIDTH)) -#else -#undef REFLECT_REMAINDER -#define REFLECT_REMAINDER(X) (X) -#endif - - -/********************************************************************* - * - * Function: reflect() - * - * Description: Reorder the bits of a binary sequence, by reflecting - * them about the middle position. - * - * Notes: No checking is done that nBits <= 32. - * - * Returns: The reflection of the original data. - * - *********************************************************************/ -static unsigned long -reflect(unsigned long data, unsigned char nBits) { - unsigned long reflection = 0x00000000; - unsigned char bit; - - /* - * Reflect the data about the center bit. - */ - for (bit = 0; bit < nBits; ++bit) { - /* - * If the LSB bit is set, set the reflection of it. - */ - if (data & 0x01) { - reflection |= (1 << ((nBits - 1) - bit)); - } - - data = (data >> 1); - } - - return (reflection); - -} /* reflect() */ - - -/********************************************************************* - * - * Function: crcSlow() - * - * Description: Compute the CRC of a given message. - * - * Notes: - * - * Returns: The CRC of the message. - * - *********************************************************************/ -crc -crcSlow(unsigned char const message[], int nBytes) { - crc remainder = INITIAL_REMAINDER; - int byte; - unsigned char bit; - - - /* - * Perform modulo-2 division, a byte at a time. - */ - for (byte = 0; byte < nBytes; ++byte) { - /* - * Bring the next byte into the remainder. - */ - remainder ^= (REFLECT_DATA(message[byte]) << (WIDTH - 8)); - - /* - * Perform modulo-2 division, a bit at a time. - */ - for (bit = 8; bit > 0; --bit) { - /* - * Try to divide the current data bit. - */ - if (remainder & TOPBIT) { - remainder = (remainder << 1) ^ POLYNOMIAL; - } else { - remainder = (remainder << 1); - } - } - } - - /* - * The final remainder is the CRC result. - */ - return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); - -} /* crcSlow() */ - - -crc crcTable[256]; - - -/********************************************************************* - * - * Function: crcInit() - * - * Description: Populate the partial CRC lookup table. - * - * Notes: This function must be rerun any time the CRC standard - * is changed. If desired, it can be run "offline" and - * the table results stored in an embedded system's ROM. - * - * Returns: None defined. - * - *********************************************************************/ -void -crcInit(void) { - crc remainder; - int dividend; - unsigned char bit; - - - /* - * Compute the remainder of each possible dividend. - */ - for (dividend = 0; dividend < 256; ++dividend) { - /* - * Start with the dividend followed by zeros. - */ - remainder = dividend << (WIDTH - 8); - - /* - * Perform modulo-2 division, a bit at a time. - */ - for (bit = 8; bit > 0; --bit) { - /* - * Try to divide the current data bit. - */ - if (remainder & TOPBIT) { - remainder = (remainder << 1) ^ POLYNOMIAL; - } else { - remainder = (remainder << 1); - } - } - - /* - * Store the result into the table. - */ - crcTable[dividend] = remainder; - } - -} /* crcInit() */ - - -/********************************************************************* - * - * Function: crcFast() - * - * Description: Compute the CRC of a given message. - * - * Notes: crcInit() must be called first. - * - * Returns: The CRC of the message. - * - *********************************************************************/ -crc -crcFast(unsigned char const message[], int nBytes) { - crc remainder = INITIAL_REMAINDER; - unsigned char data; - int byte; - - - /* - * Divide the message by the polynomial, a byte at a time. - */ - for (byte = 0; byte < nBytes; ++byte) { - data = (unsigned char)(REFLECT_DATA(message[byte]) ^ (remainder >> (WIDTH - 8))); - remainder = crcTable[data] ^ (remainder << 8); - } - - /* - * The final remainder is the CRC. - */ - return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); - -} /* crcFast() */ - - - -crc crc_initialize(void) { - crcInit(); - return INITIAL_REMAINDER; -} - -crc crc_process_byte(unsigned char byte, crc remainder) { - unsigned char data; - data = (unsigned char)(REFLECT_DATA(byte) ^ (remainder >> (WIDTH - 8))); - remainder = crcTable[data] ^ (remainder << 8); - return remainder; -} - -crc crc_finalize(crc remainder) { - return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); -} diff --git a/engines/wintermute/crc.h b/engines/wintermute/crc.h deleted file mode 100644 index 578b423de8..0000000000 --- a/engines/wintermute/crc.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************** - * - * Filename: crc.h - * - * Description: A header file describing the various CRC standards. - * - * Notes: - * - * - * Copyright (c) 2000 by Michael Barr. This software is placed into - * the public domain and may be used for any purpose. However, this - * notice must not be changed or removed and no warranty is either - * expressed or implied by its publication or distribution. - **********************************************************************/ - -#ifndef _crc_h -#define _crc_h - -#ifndef TRUE -#define FALSE 0 -#define TRUE !FALSE -#endif - -/* - * Select the CRC standard from the list that follows. - */ -#define CRC32 - - -#if defined(CRC_CCITT) - -typedef unsigned short crc; - -#define CRC_NAME "CRC-CCITT" -#define POLYNOMIAL 0x1021 -#define INITIAL_REMAINDER 0xFFFF -#define FINAL_XOR_VALUE 0x0000 -#define REFLECT_DATA FALSE -#define REFLECT_REMAINDER FALSE -#define CHECK_VALUE 0x29B1 - -#elif defined(CRC16) - -typedef unsigned short crc; - -#define CRC_NAME "CRC-16" -#define POLYNOMIAL 0x8005 -#define INITIAL_REMAINDER 0x0000 -#define FINAL_XOR_VALUE 0x0000 -#define REFLECT_DATA TRUE -#define REFLECT_REMAINDER TRUE -#define CHECK_VALUE 0xBB3D - -#elif defined(CRC32) - -typedef unsigned long crc; - -#define CRC_NAME "CRC-32" -#define POLYNOMIAL 0x04C11DB7 -#define INITIAL_REMAINDER 0xFFFFFFFF -#define FINAL_XOR_VALUE 0xFFFFFFFF -#define REFLECT_DATA TRUE -#define REFLECT_REMAINDER TRUE -#define CHECK_VALUE 0xCBF43926 - -#else - -#error "One of CRC_CCITT, CRC16, or CRC32 must be #define'd." - -#endif - -void crcInit(void); -crc crcSlow(unsigned char const message[], int nBytes); -crc crcFast(unsigned char const message[], int nBytes); - -extern "C" crc crc_initialize(void); -extern "C" crc crc_process_byte(unsigned char byte, crc remainder); -extern "C" crc crc_finalize(crc remainder); - - -#endif /* _crc_h */ diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 8e929b0dcd..59caef82b1 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,18 +1,6 @@ MODULE := engines/wintermute MODULE_OBJS := \ - Base/scriptables/ScEngine.o \ - Base/scriptables/ScScript.o \ - Base/scriptables/ScStack.o \ - Base/scriptables/ScValue.o \ - Base/scriptables/SXArray.o \ - Base/scriptables/SXDate.o \ - Base/scriptables/SXFile.o \ - Base/scriptables/SXMath.o \ - Base/scriptables/SxObject.o \ - Base/scriptables/SXMemBuffer.o \ - Base/scriptables/SXStore.o \ - Base/scriptables/SXString.o \ Ad/AdActor.o \ Ad/AdActorDir.o \ Ad/AdEntity.o \ @@ -40,6 +28,18 @@ MODULE_OBJS := \ Ad/AdTalkHolder.o \ Ad/AdTalkNode.o \ Ad/AdWaypointGroup.o \ + Base/scriptables/ScEngine.o \ + Base/scriptables/ScScript.o \ + Base/scriptables/ScStack.o \ + Base/scriptables/ScValue.o \ + Base/scriptables/SXArray.o \ + Base/scriptables/SXDate.o \ + Base/scriptables/SXFile.o \ + Base/scriptables/SXMath.o \ + Base/scriptables/SxObject.o \ + Base/scriptables/SXMemBuffer.o \ + Base/scriptables/SXStore.o \ + Base/scriptables/SXString.o \ Base/BActiveRect.o \ Base/BBase.o \ Base/BDebugger.o \ @@ -86,8 +86,9 @@ MODULE_OBJS := \ Base/BSurfaceStorage.o \ Base/BTransitionMgr.o \ Base/BViewport.o \ - ConvertUTF.o \ - crc.o \ + Base/PartParticle.o \ + Base/PartEmitter.o \ + Base/PartForce.o \ detection.o \ FontGlyphCache.o \ graphics/transparentSurface.o \ @@ -95,12 +96,7 @@ MODULE_OBJS := \ math/MathUtil.o \ math/Matrix4.o \ math/Vector2.o \ - PathUtil.o \ - Base/PartParticle.o \ - Base/PartEmitter.o \ - Base/PartForce.o \ PlatformSDL.o \ - StringUtil.o \ Sys/SysClass.o \ Sys/SysClassRegistry.o \ Sys/SysInstance.o \ @@ -115,9 +111,13 @@ MODULE_OBJS := \ UI/UIText.o \ UI/UITiledImage.o \ UI/UIWindow.o \ - utils.o \ - VidPlayer.o \ - VidTheoraPlayer.o \ + utils/ConvertUTF.o \ + utils/crc.o \ + utils/PathUtil.o \ + utils/StringUtil.o \ + utils/utils.o \ + video/VidPlayer.o \ + video/VidTheoraPlayer.o \ wintermute.o MODULE_DIRS += \ diff --git a/engines/wintermute/utils.cpp b/engines/wintermute/utils.cpp deleted file mode 100644 index d1ce280639..0000000000 --- a/engines/wintermute/utils.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintypes.h" -#include "PathUtil.h" -#include "engines/wintermute/Base/BGame.h" -#include "common/str.h" -#include "common/textconsole.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -static inline unsigned Sqr(int x) { - return (x * x); -} - - -////////////////////////////////////////////////////////////////////////////////// -void CBUtils::Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect) { - // If it's partly off the right side of the screen - if (*DestX + (SrcRect->right - SrcRect->left) > DestRect->right) - SrcRect->right -= *DestX + (SrcRect->right - SrcRect->left) - DestRect->right; - - if (SrcRect->right < 0) SrcRect->right = 0; - - // Partly off the left side of the screen - if (*DestX < DestRect->left) { - SrcRect->left += DestRect->left - *DestX; - *DestX = DestRect->left; - } - - // Partly off the top of the screen - if (*DestY < DestRect->top) { - SrcRect->top += DestRect->top - *DestY; - *DestY = DestRect->top; - } - - // If it's partly off the bottom side of the screen - if (*DestY + (SrcRect->bottom - SrcRect->top) > DestRect->bottom) - SrcRect->bottom -= ((SrcRect->bottom - SrcRect->top) + *DestY) - DestRect->bottom; - - if (SrcRect->bottom < 0) SrcRect->bottom = 0; - - return; -} - -////////////////////////////////////////////////////////////////////////////////// -// Swap - swaps two integers -////////////////////////////////////////////////////////////////////////////////// -void CBUtils::Swap(int *a, int *b) { - int Temp = *a; - *a = *b; - *b = Temp; -} - -////////////////////////////////////////////////////////////////////////// -bool CBUtils::StrBeginsI(const char *String, const char *Fragment) { - return (scumm_strnicmp(String, Fragment, strlen(Fragment)) == 0); -} - - -////////////////////////////////////////////////////////////////////////// -float CBUtils::NormalizeAngle(float Angle) { - while (Angle > 360) Angle -= 360; - while (Angle < 0) Angle += 360; - - return Angle; -} - - -//////////////////////////////////////////////////////////////////////////////// -void CBUtils::CreatePath(const char *Path, bool PathOnly) { - AnsiString path; - - if (!PathOnly) path = PathUtil::GetDirectoryName(Path); - else path = Path; - -// try { - warning("CBUtils::CreatePath - not implemented: %s", Path); -// boost::filesystem::create_directories(path); -// } catch (...) { - return; -// } -} - - -////////////////////////////////////////////////////////////////////////// -void CBUtils::DebugMessage(HWND hWnd, const char *Text) { - //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); -} - - -////////////////////////////////////////////////////////////////////////// -char *CBUtils::SetString(char **String, const char *Value) { - delete[] *String; - *String = new char[strlen(Value) + 1]; - if (*String) strcpy(*String, Value); - return *String; -} - -////////////////////////////////////////////////////////////////////////// -int CBUtils::StrNumEntries(const char *Str, const char Delim) { - int NumEntries = 1; - for (uint32 i = 0; i < strlen(Str); i++) { - if (Str[i] == Delim) NumEntries++; - } - return NumEntries; -} - - -////////////////////////////////////////////////////////////////////////// -char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { - int NumEntries = 0; - - const char *Start = NULL; - int Len = 0; - - for (uint32 i = 0; i <= strlen(Str); i++) { - if (NumEntries == Entry) { - if (!Start) Start = Str + i; - else Len++; - } - if (Str[i] == Delim || Str[i] == '\0') { - NumEntries++; - if (Start) { - char *Ret = new char[Len + 1]; - memset(Ret, 0, Len + 1); - strncpy(Ret, Start, Len); - return Ret; - } - } - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int CBUtils::RandomInt(int From, int To) { - if (To < From) { - int i = To; - To = From; - From = i; - } - return (rand() % (To - From + 1)) + From; -} - -////////////////////////////////////////////////////////////////////////// -float CBUtils::RandomFloat(float From, float To) { - float RandNum = (float)rand() / (float)RAND_MAX; - return From + (To - From) * RandNum; -} - -////////////////////////////////////////////////////////////////////////// -float CBUtils::RandomAngle(float From, float To) { - while (To < From) { - To += 360; - } - return NormalizeAngle(RandomFloat(From, To)); -} - -////////////////////////////////////////////////////////////////////////// -bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { - char stringc, patternc; - - for (;; ++String) { - stringc = toupper(*String); - patternc = toupper(*Pattern++); - - switch (patternc) { - case 0: - return (stringc == 0); - - case '?': - if (stringc == 0) return false; - break; - - case '*': - if (!*Pattern) return true; - - if (*Pattern == '.') { - char *dot; - if (Pattern[1] == '*' && Pattern[2] == 0) return true; - dot = (char *)strchr(String, '.'); - if (Pattern[1] == 0) return (dot == NULL || dot[1] == 0); - if (dot != NULL) { - String = dot; - if (strpbrk(Pattern, "*?[") == NULL && strchr(String + 1, '.') == NULL) - return(scumm_stricmp(Pattern + 1, String + 1) == 0); - } - } - - while (*String) - if (CBUtils::MatchesPattern(Pattern, String++)) - return true; - return false; - - default: - if (patternc != stringc) - if (patternc == '.' && stringc == 0) - return(CBUtils::MatchesPattern(Pattern, String)); - else - return false; - break; - } - } -} - -////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetPath(const char *Filename) { - AnsiString path = PathUtil::GetDirectoryName(Filename); - //path = boost::filesystem::syste_complete(path).string(); - warning("CBUtils::GetPath: (%s), not implemented", Filename); - char *ret = new char[path.size() + 1]; - strcpy(ret, path.c_str()); - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetFilename(const char *Filename) { - AnsiString path = PathUtil::GetFileName(Filename); - char *ret = new char[path.size() + 1]; - strcpy(ret, path.c_str()); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { - float var_R = (D3DCOLGetR(RGBColor) / 255.0f); - float var_G = (D3DCOLGetG(RGBColor) / 255.0f); - float var_B = (D3DCOLGetB(RGBColor) / 255.0f); - - //Min. value of RGB - float var_Min = MIN(var_R, var_G); - var_Min = MIN(var_Min, var_B); - - //Max. value of RGB - float var_Max = MAX(var_R, var_G); - var_Max = MAX(var_Max, var_B); - - //Delta RGB value - float del_Max = var_Max - var_Min; - - float H, S, L; - - L = (var_Max + var_Min) / 2.0f; - - //This is a gray, no chroma... - if (del_Max == 0) { - H = 0; - S = 0; - } - //Chromatic data... - else { - if (L < 0.5f) S = del_Max / (var_Max + var_Min); - else S = del_Max / (2.0f - var_Max - var_Min); - - float del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; - float del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; - float del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; - - if (var_R == var_Max) H = del_B - del_G; - else if (var_G == var_Max) H = (1.0f / 3.0f) + del_R - del_B; - else if (var_B == var_Max) H = (2.0f / 3.0f) + del_G - del_R; - - if (H < 0) H += 1; - if (H > 1) H -= 1; - } - - *OutH = (byte)(H * 255); - *OutS = (byte)(S * 255); - *OutL = (byte)(L * 255); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { - float H = InH / 255.0f; - float S = InS / 255.0f; - float L = InL / 255.0f; - - byte R, G, B; - - - if (S == 0) { - R = (byte)(L * 255); - G = (byte)(L * 255); - B = (byte)(L * 255); - } else { - float var_1, var_2; - - if (L < 0.5) var_2 = L * (1.0 + S); - else var_2 = (L + S) - (S * L); - - var_1 = 2.0f * L - var_2; - - R = (byte)(255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f))); - G = (byte)(255 * Hue2RGB(var_1, var_2, H)); - B = (byte)(255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f))); - } - return DRGBA(255, R, G, B); -} - - -////////////////////////////////////////////////////////////////////////// -float CBUtils::Hue2RGB(float v1, float v2, float vH) { - if (vH < 0.0f) vH += 1.0f; - if (vH > 1.0f) vH -= 1.0f; - if ((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH); - if ((2.0f * vH) < 1.0f) return (v2); - if ((3.0f * vH) < 2.0f) return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f); - return (v1); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/utils.h b/engines/wintermute/utils.h deleted file mode 100644 index 46e895ff4d..0000000000 --- a/engines/wintermute/utils.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UTILS_H -#define WINTERMUTE_UTILS_H - -#include "engines/wintermute/wintypes.h" - -namespace WinterMute { - -class CBGame; - -class CBUtils { -public: - static void Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); - static void Swap(int *a, int *b); - static bool StrBeginsI(const char *String, const char *Fragment); - static float NormalizeAngle(float Angle); - - static void CreatePath(const char *Path, bool PathOnly = false); - - static void DebugMessage(HWND hWnd, const char *Text); - static char *SetString(char **String, const char *Value); - - static int StrNumEntries(const char *Str, const char Delim = ','); - static char *StrEntry(int Entry, const char *Str, const char Delim = ','); - - static int RandomInt(int From, int To); - static float RandomFloat(float From, float To); - static float RandomAngle(float From, float To); - - static bool MatchesPattern(const char *pattern, const char *string); - - static char *GetPath(const char *Filename); - static char *GetFilename(const char *Filename); - - static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); - static uint32 HSLtoRGB(byte H, byte S, byte L); - -private: - static float Hue2RGB(float v1, float v2, float vH); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/utils/ConvertUTF.c b/engines/wintermute/utils/ConvertUTF.c new file mode 100644 index 0000000000..8f7d6d2124 --- /dev/null +++ b/engines/wintermute/utils/ConvertUTF.c @@ -0,0 +1,612 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "ConvertUTF.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; + break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF32 *target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; + break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG + if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); + } +#endif + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source + length; + switch (length) { + default: + return false; + /* Everything else falls through when "true"... */ + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) return false; + break; + case 0xED: + if (a > 0x9F) return false; + break; + case 0xF0: + if (a < 0x90) return false; + break; + case 0xF4: + if (a > 0x8F) return false; + break; + default: + if (a < 0x80) return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source] + 1; + if (source + length > sourceEnd) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 4: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF32 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; + case 4: + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up the source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_LEGAL_UTF32) { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = ch; + } + } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/ConvertUTF.h b/engines/wintermute/utils/ConvertUTF.h new file mode 100644 index 0000000000..03a8bb2bae --- /dev/null +++ b/engines/wintermute/utils/ConvertUTF.h @@ -0,0 +1,149 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that wchar_t has at least + 16 bits, so wchar_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + + ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp new file mode 100644 index 0000000000..dc722e2389 --- /dev/null +++ b/engines/wintermute/utils/PathUtil.cpp @@ -0,0 +1,204 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include +#include +#include "PathUtil.h" +#include "StringUtil.h" + + +#ifdef __WIN32__ +# include +#endif + +#ifdef __MACOSX__ +# include +#endif + +#ifdef __IPHONEOS__ +# include "ios_utils.h" +#endif + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::UnifySeparators(const AnsiString &path) { + AnsiString newPath = path; + + std::replace(newPath.begin(), newPath.end(), L'\\', L'/'); + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::NormalizeFileName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + StringUtil::ToLowerCase(newPath); + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::Combine(const AnsiString &path1, const AnsiString &path2) { + AnsiString newPath1 = UnifySeparators(path1); + AnsiString newPath2 = UnifySeparators(path2); + + if (!StringUtil::EndsWith(newPath1, "/", true) && !StringUtil::StartsWith(newPath2, "/", true)) + newPath1 += "/"; + + return newPath1 + newPath2; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetDirectoryName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + + //size_t pos = newPath.find_last_of(L'/'); + Common::String filename = GetFileName(path); + return Common::String(path.c_str(), path.size() - filename.size()); + //if (pos == AnsiString::npos) return ""; + //else return newPath.substr(0, pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetFileName(const AnsiString &path) { + AnsiString newPath = UnifySeparators(path); + + //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. + Common::String lastPart = Common::lastPathComponent(path, '/'); + if (lastPart[lastPart.size() - 1 ] != '/') + return lastPart; + else + return path; + //if (pos == AnsiString::npos) return path; + //else return newPath.substr(pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { + AnsiString fileName = GetFileName(path); + + //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! + // TODO: Prettify this. + Common::String extension = Common::lastPathComponent(path, '.'); + Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); + return filename; + //if (pos == AnsiString::npos) return fileName; + //else return fileName.substr(0, pos); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetExtension(const AnsiString &path) { + AnsiString fileName = GetFileName(path); + + //size_t pos = fileName.find_last_of('.'); + return Common::lastPathComponent(path, '.'); + //if (pos == AnsiString::npos) return ""; + //else return fileName.substr(pos); +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetSafeLogFileName() { + AnsiString logFileName = GetUserDirectory(); + +#ifdef __WIN32__ + char moduleName[MAX_PATH]; + ::GetModuleFileName(NULL, moduleName, MAX_PATH); + + AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; + fileName = Combine("/Wintermute Engine/Logs/", fileName); + logFileName = Combine(logFileName, fileName); + +#else + // !PORTME + logFileName = Combine(logFileName, "/Wintermute Engine/wme.log"); +#endif + + CreateDirectory(GetDirectoryName(logFileName)); + return logFileName; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::CreateDirectory(const AnsiString &path) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::FileExists(const AnsiString &fileName) { + std::ifstream stream; + + stream.open(fileName.c_str()); + bool ret = stream.is_open(); + stream.close(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::GetUserDirectory() { + AnsiString userDir = "./"; + +#ifdef __WIN32__ + char buffer[MAX_PATH]; + buffer[0] = '\0'; + LPITEMIDLIST pidl = NULL; + LPMALLOC pMalloc; + if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); + if (pidl) { + SHGetPathFromIDList(pidl, buffer); + } + pMalloc->Free(pidl); + userDir = AnsiString(buffer); + } +#elif __MACOSX__ + FSRef fileRef; + OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); + if (error == noErr) { + char buffer[MAX_PATH]; + error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); + if (error == noErr) + userDir = buffer; + + } +#elif __IPHONEOS__ + char path[MAX_PATH]; + IOS_GetDataDir(path); + userDir = AnsiString(path); +#endif + + return userDir; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/PathUtil.h b/engines/wintermute/utils/PathUtil.h new file mode 100644 index 0000000000..0bc883a1fa --- /dev/null +++ b/engines/wintermute/utils/PathUtil.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PATHUTILS_H +#define WINTERMUTE_PATHUTILS_H + +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +class PathUtil { +public: + static AnsiString UnifySeparators(const AnsiString &path); + static AnsiString NormalizeFileName(const AnsiString &path); + static AnsiString Combine(const AnsiString &path1, const AnsiString &path2); + static AnsiString GetDirectoryName(const AnsiString &path); + static AnsiString GetFileName(const AnsiString &path); + static AnsiString GetFileNameWithoutExtension(const AnsiString &path); + static AnsiString GetExtension(const AnsiString &path); + static bool CreateDirectory(const AnsiString &path); + static bool MatchesMask(const AnsiString &fileName, const AnsiString &mask); + + static bool FileExists(const AnsiString &fileName); + + static AnsiString GetSafeLogFileName(); + static AnsiString GetUserDirectory(); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp new file mode 100644 index 0000000000..cd4f99e034 --- /dev/null +++ b/engines/wintermute/utils/StringUtil.cpp @@ -0,0 +1,393 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include +#include +#include +#include "common/tokenizer.h" +#include "StringUtil.h" +#include "ConvertUTF.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToLowerCase(AnsiString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::tolower); +} + +////////////////////////////////////////////////////////////////////////// +/*void StringUtil::ToLowerCase(WideString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::towlower); +}*/ + +////////////////////////////////////////////////////////////////////////// +void StringUtil::ToUpperCase(AnsiString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); +} + +////////////////////////////////////////////////////////////////////////// +/*void StringUtil::ToUpperCase(WideString &str) { + std::transform(str.begin(), str.end(), str.begin(), ::towupper); +}*/ + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { + AnsiString str1lc = str1; + AnsiString str2lc = str2; + + ToLowerCase(str1lc); + ToLowerCase(str2lc); + + return (str1lc == str2lc); +} + +////////////////////////////////////////////////////////////////////////// +/*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { + WideString str1lc = str1; + WideString str2lc = str2; + + ToLowerCase(str1lc); + ToLowerCase(str2lc); + + return (str1lc == str2lc); +}*/ + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { + error("StringUtil::Utf8ToWide - WideString not supported yet"); + /* size_t WideSize = Utf8Str.size(); + + if (sizeof(wchar_t) == 2) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF16 *TargetStart = reinterpret_cast(WideStringNative); + UTF16 *TargetEnd = TargetStart + WideSize + 1; + + ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else if (sizeof(wchar_t) == 4) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF32 *TargetStart = reinterpret_cast(WideStringNative); + UTF32 *TargetEnd = TargetStart + WideSize; + + ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else { + return L""; + }*/ + return ""; +} + +////////////////////////////////////////////////////////////////////////// +Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { + error("StringUtil::WideToUtf8 - Widestring not supported yet"); + /* size_t WideSize = WideStr.length(); + + if (sizeof(wchar_t) == 2) { + size_t Utf8Size = 3 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF16 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else if (sizeof(wchar_t) == 4) { + size_t Utf8Size = 4 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF32 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else { + return (Utf8String)""; + }*/ + return ""; +} + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::AnsiToWide(const AnsiString &str) { + // using default os locale! + error("StringUtil::AnsiToWide - WideString not supported yet"); + /* setlocale(LC_CTYPE, ""); + size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; + wchar_t *wstr = new wchar_t[WideSize]; + mbstowcs(wstr, str.c_str(), WideSize); + WideString ResultString(wstr); + delete [] wstr; + return ResultString;*/ + return ""; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::WideToAnsi(const WideString &wstr) { + // using default os locale! + error("StringUtil::WideToAnsi - WideString not supported yet"); + /* setlocale(LC_CTYPE, ""); + size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; + char *str = new char[WideSize]; + wcstombs(str, wstr.c_str(), WideSize); + AnsiString ResultString(str); + delete [] str; + return ResultString;*/ + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + /* size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart = str.substr(0, patternLength); + + if (ignoreCase) return CompareNoCase(startPart, pattern); + else return (startPart == pattern);*/ + if (!ignoreCase) + return str.hasPrefix(pattern); + else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart(str.c_str(), patternLength); + uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + return (likeness == 0); + } +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + /* size_t strLength = str.size(); // TODO: Remove + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString endPart = str.substr(strLength - patternLength, patternLength); + + if (ignoreCase) return CompareNoCase(endPart, pattern); + else return (endPart == pattern);*/ + if (!ignoreCase) { + return str.hasSuffix(pattern); + } else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); + uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + return (likeness != 0); + } +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::IsUtf8BOM(const byte *Buffer, uint32 BufferSize) { + if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; + else return false; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { + if (from.empty() || from == to) return str; + + AnsiString result = str; + /*size_t pos = 0;*/ + + while (result.contains(from)) { + const char *startPtr = strstr(result.c_str(), from.c_str()); + uint32 index = startPtr - result.c_str(); + + Common::String tail(result.c_str() + index + to.size()); + result = Common::String(result.c_str(), index); + result += to; + result += tail; + + /* pos = result.find(from, pos); + if (pos == result.npos) break; + + result.replace(pos, from.size(), to); + pos += to.size();*/ + } + + return result; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { + AnsiString trimmedStr = str; + + if (fromRight) { + //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO + warning("fromRight-trim not implemented yet, %s", chars.c_str()); + } + if (fromLeft) { + uint32 lastOf = LastIndexOf(str, chars, 0); + trimmedStr = Common::String(trimmedStr.c_str() + lastOf); + //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); + } + return trimmedStr; +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + /*size_t pos = str.find(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos;*/ + const char *index = strstr(str.c_str(), toFind.c_str()); + if (index == NULL) + return -1; + else + return index - str.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + /*size_t pos = str.rfind(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos;*/ + int32 lastIndex = -1; + bool found = false; + for (size_t i = startFrom; i < str.size(); i++) { + found = false; + for (size_t j = 0; j < toFind.size(); j++) { + if (str[i + j] != toFind[j]) { + found = false; + break; + } else { + found = true; + } + } + if (found) + lastIndex = i; + } + return lastIndex; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(size_t val) { + /* std::ostringstream str; + str << val; + return str.str();*/ + return Common::String::format("%u", (uint32)val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(int val) { + /* std::ostringstream str; + str << val; + return str.str();*/ + return Common::String::format("%d", val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(float val) { + /* std::ostringstream str; + str << val; + return str.str();*/ + return Common::String::format("%f", val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::ToString(double val) { + /* std::ostringstream str; + str << val; + return str.str();*/ + return Common::String::format("%f", val); +} + + +////////////////////////////////////////////////////////////////////////// +void StringUtil::Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { + result.clear(); +//TODO: Verify this, wrt keepEmptyItems. + Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); + //typedef boost::char_separator separator_t; + //typedef boost::tokenizer tokenizer_t; + + //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); + //tokenizer_t tokens(list, del); + while (!tokenizer.empty()) { + Common::String copy(tokenizer.nextToken().c_str()); + result.push_back(copy); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h new file mode 100644 index 0000000000..a4727fabbe --- /dev/null +++ b/engines/wintermute/utils/StringUtil.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_STRINGUTIL_H +#define WINTERMUTE_STRINGUTIL_H + +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +class StringUtil { +public: + static void ToLowerCase(AnsiString &str); + //static void ToLowerCase(WideString &str); + static void ToUpperCase(AnsiString &str); + //static void ToUpperCase(WideString &str); + static bool CompareNoCase(const AnsiString &str1, const AnsiString &str2); + //static bool CompareNoCase(const WideString &str1, const WideString &str2); + static WideString Utf8ToWide(const Utf8String &Utf8Str); + static Utf8String WideToUtf8(const WideString &WideStr); + static WideString AnsiToWide(const AnsiString &str); + static AnsiString WideToAnsi(const WideString &str); + + static bool StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + static bool EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + + static bool IsUtf8BOM(const byte *buffer, uint32 bufferSize); + + static AnsiString Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); + static AnsiString Trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); + + static int IndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + static int LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + + static AnsiString ToString(size_t val); + static AnsiString ToString(int val); + static AnsiString ToString(float val); + static AnsiString ToString(double val); + + static void Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp new file mode 100644 index 0000000000..adfd5da624 --- /dev/null +++ b/engines/wintermute/utils/crc.cpp @@ -0,0 +1,234 @@ +/********************************************************************** + * + * Filename: crc.c + * + * Description: Slow and fast implementations of the CRC standards. + * + * Notes: The parameters for each supported CRC standard are + * defined in the header file crc.h. The implementations + * here should stand up to further additions to that list. + * + * + * Copyright (c) 2000 by Michael Barr. This software is placed into + * the public domain and may be used for any purpose. However, this + * notice must not be changed or removed and no warranty is either + * expressed or implied by its publication or distribution. + **********************************************************************/ + +#include "crc.h" + + +/* + * Derive parameters from the standard-specific parameters in crc.h. + */ +#define WIDTH (8 * sizeof(crc)) +#define TOPBIT (1 << (WIDTH - 1)) + +#if (REFLECT_DATA == TRUE) +#undef REFLECT_DATA +#define REFLECT_DATA(X) ((unsigned char) reflect((X), 8)) +#else +#undef REFLECT_DATA +#define REFLECT_DATA(X) (X) +#endif + +#if (REFLECT_REMAINDER == TRUE) +#undef REFLECT_REMAINDER +#define REFLECT_REMAINDER(X) ((crc) reflect((X), WIDTH)) +#else +#undef REFLECT_REMAINDER +#define REFLECT_REMAINDER(X) (X) +#endif + + +/********************************************************************* + * + * Function: reflect() + * + * Description: Reorder the bits of a binary sequence, by reflecting + * them about the middle position. + * + * Notes: No checking is done that nBits <= 32. + * + * Returns: The reflection of the original data. + * + *********************************************************************/ +static unsigned long +reflect(unsigned long data, unsigned char nBits) { + unsigned long reflection = 0x00000000; + unsigned char bit; + + /* + * Reflect the data about the center bit. + */ + for (bit = 0; bit < nBits; ++bit) { + /* + * If the LSB bit is set, set the reflection of it. + */ + if (data & 0x01) { + reflection |= (1 << ((nBits - 1) - bit)); + } + + data = (data >> 1); + } + + return (reflection); + +} /* reflect() */ + + +/********************************************************************* + * + * Function: crcSlow() + * + * Description: Compute the CRC of a given message. + * + * Notes: + * + * Returns: The CRC of the message. + * + *********************************************************************/ +crc +crcSlow(unsigned char const message[], int nBytes) { + crc remainder = INITIAL_REMAINDER; + int byte; + unsigned char bit; + + + /* + * Perform modulo-2 division, a byte at a time. + */ + for (byte = 0; byte < nBytes; ++byte) { + /* + * Bring the next byte into the remainder. + */ + remainder ^= (REFLECT_DATA(message[byte]) << (WIDTH - 8)); + + /* + * Perform modulo-2 division, a bit at a time. + */ + for (bit = 8; bit > 0; --bit) { + /* + * Try to divide the current data bit. + */ + if (remainder & TOPBIT) { + remainder = (remainder << 1) ^ POLYNOMIAL; + } else { + remainder = (remainder << 1); + } + } + } + + /* + * The final remainder is the CRC result. + */ + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); + +} /* crcSlow() */ + + +crc crcTable[256]; + + +/********************************************************************* + * + * Function: crcInit() + * + * Description: Populate the partial CRC lookup table. + * + * Notes: This function must be rerun any time the CRC standard + * is changed. If desired, it can be run "offline" and + * the table results stored in an embedded system's ROM. + * + * Returns: None defined. + * + *********************************************************************/ +void +crcInit(void) { + crc remainder; + int dividend; + unsigned char bit; + + + /* + * Compute the remainder of each possible dividend. + */ + for (dividend = 0; dividend < 256; ++dividend) { + /* + * Start with the dividend followed by zeros. + */ + remainder = dividend << (WIDTH - 8); + + /* + * Perform modulo-2 division, a bit at a time. + */ + for (bit = 8; bit > 0; --bit) { + /* + * Try to divide the current data bit. + */ + if (remainder & TOPBIT) { + remainder = (remainder << 1) ^ POLYNOMIAL; + } else { + remainder = (remainder << 1); + } + } + + /* + * Store the result into the table. + */ + crcTable[dividend] = remainder; + } + +} /* crcInit() */ + + +/********************************************************************* + * + * Function: crcFast() + * + * Description: Compute the CRC of a given message. + * + * Notes: crcInit() must be called first. + * + * Returns: The CRC of the message. + * + *********************************************************************/ +crc +crcFast(unsigned char const message[], int nBytes) { + crc remainder = INITIAL_REMAINDER; + unsigned char data; + int byte; + + + /* + * Divide the message by the polynomial, a byte at a time. + */ + for (byte = 0; byte < nBytes; ++byte) { + data = (unsigned char)(REFLECT_DATA(message[byte]) ^ (remainder >> (WIDTH - 8))); + remainder = crcTable[data] ^ (remainder << 8); + } + + /* + * The final remainder is the CRC. + */ + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); + +} /* crcFast() */ + + + +crc crc_initialize(void) { + crcInit(); + return INITIAL_REMAINDER; +} + +crc crc_process_byte(unsigned char byte, crc remainder) { + unsigned char data; + data = (unsigned char)(REFLECT_DATA(byte) ^ (remainder >> (WIDTH - 8))); + remainder = crcTable[data] ^ (remainder << 8); + return remainder; +} + +crc crc_finalize(crc remainder) { + return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); +} diff --git a/engines/wintermute/utils/crc.h b/engines/wintermute/utils/crc.h new file mode 100644 index 0000000000..578b423de8 --- /dev/null +++ b/engines/wintermute/utils/crc.h @@ -0,0 +1,81 @@ +/********************************************************************** + * + * Filename: crc.h + * + * Description: A header file describing the various CRC standards. + * + * Notes: + * + * + * Copyright (c) 2000 by Michael Barr. This software is placed into + * the public domain and may be used for any purpose. However, this + * notice must not be changed or removed and no warranty is either + * expressed or implied by its publication or distribution. + **********************************************************************/ + +#ifndef _crc_h +#define _crc_h + +#ifndef TRUE +#define FALSE 0 +#define TRUE !FALSE +#endif + +/* + * Select the CRC standard from the list that follows. + */ +#define CRC32 + + +#if defined(CRC_CCITT) + +typedef unsigned short crc; + +#define CRC_NAME "CRC-CCITT" +#define POLYNOMIAL 0x1021 +#define INITIAL_REMAINDER 0xFFFF +#define FINAL_XOR_VALUE 0x0000 +#define REFLECT_DATA FALSE +#define REFLECT_REMAINDER FALSE +#define CHECK_VALUE 0x29B1 + +#elif defined(CRC16) + +typedef unsigned short crc; + +#define CRC_NAME "CRC-16" +#define POLYNOMIAL 0x8005 +#define INITIAL_REMAINDER 0x0000 +#define FINAL_XOR_VALUE 0x0000 +#define REFLECT_DATA TRUE +#define REFLECT_REMAINDER TRUE +#define CHECK_VALUE 0xBB3D + +#elif defined(CRC32) + +typedef unsigned long crc; + +#define CRC_NAME "CRC-32" +#define POLYNOMIAL 0x04C11DB7 +#define INITIAL_REMAINDER 0xFFFFFFFF +#define FINAL_XOR_VALUE 0xFFFFFFFF +#define REFLECT_DATA TRUE +#define REFLECT_REMAINDER TRUE +#define CHECK_VALUE 0xCBF43926 + +#else + +#error "One of CRC_CCITT, CRC16, or CRC32 must be #define'd." + +#endif + +void crcInit(void); +crc crcSlow(unsigned char const message[], int nBytes); +crc crcFast(unsigned char const message[], int nBytes); + +extern "C" crc crc_initialize(void); +extern "C" crc crc_process_byte(unsigned char byte, crc remainder); +extern "C" crc crc_finalize(crc remainder); + + +#endif /* _crc_h */ diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp new file mode 100644 index 0000000000..d1ce280639 --- /dev/null +++ b/engines/wintermute/utils/utils.cpp @@ -0,0 +1,342 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintypes.h" +#include "PathUtil.h" +#include "engines/wintermute/Base/BGame.h" +#include "common/str.h" +#include "common/textconsole.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +static inline unsigned Sqr(int x) { + return (x * x); +} + + +////////////////////////////////////////////////////////////////////////////////// +void CBUtils::Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect) { + // If it's partly off the right side of the screen + if (*DestX + (SrcRect->right - SrcRect->left) > DestRect->right) + SrcRect->right -= *DestX + (SrcRect->right - SrcRect->left) - DestRect->right; + + if (SrcRect->right < 0) SrcRect->right = 0; + + // Partly off the left side of the screen + if (*DestX < DestRect->left) { + SrcRect->left += DestRect->left - *DestX; + *DestX = DestRect->left; + } + + // Partly off the top of the screen + if (*DestY < DestRect->top) { + SrcRect->top += DestRect->top - *DestY; + *DestY = DestRect->top; + } + + // If it's partly off the bottom side of the screen + if (*DestY + (SrcRect->bottom - SrcRect->top) > DestRect->bottom) + SrcRect->bottom -= ((SrcRect->bottom - SrcRect->top) + *DestY) - DestRect->bottom; + + if (SrcRect->bottom < 0) SrcRect->bottom = 0; + + return; +} + +////////////////////////////////////////////////////////////////////////////////// +// Swap - swaps two integers +////////////////////////////////////////////////////////////////////////////////// +void CBUtils::Swap(int *a, int *b) { + int Temp = *a; + *a = *b; + *b = Temp; +} + +////////////////////////////////////////////////////////////////////////// +bool CBUtils::StrBeginsI(const char *String, const char *Fragment) { + return (scumm_strnicmp(String, Fragment, strlen(Fragment)) == 0); +} + + +////////////////////////////////////////////////////////////////////////// +float CBUtils::NormalizeAngle(float Angle) { + while (Angle > 360) Angle -= 360; + while (Angle < 0) Angle += 360; + + return Angle; +} + + +//////////////////////////////////////////////////////////////////////////////// +void CBUtils::CreatePath(const char *Path, bool PathOnly) { + AnsiString path; + + if (!PathOnly) path = PathUtil::GetDirectoryName(Path); + else path = Path; + +// try { + warning("CBUtils::CreatePath - not implemented: %s", Path); +// boost::filesystem::create_directories(path); +// } catch (...) { + return; +// } +} + + +////////////////////////////////////////////////////////////////////////// +void CBUtils::DebugMessage(HWND hWnd, const char *Text) { + //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); +} + + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::SetString(char **String, const char *Value) { + delete[] *String; + *String = new char[strlen(Value) + 1]; + if (*String) strcpy(*String, Value); + return *String; +} + +////////////////////////////////////////////////////////////////////////// +int CBUtils::StrNumEntries(const char *Str, const char Delim) { + int NumEntries = 1; + for (uint32 i = 0; i < strlen(Str); i++) { + if (Str[i] == Delim) NumEntries++; + } + return NumEntries; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { + int NumEntries = 0; + + const char *Start = NULL; + int Len = 0; + + for (uint32 i = 0; i <= strlen(Str); i++) { + if (NumEntries == Entry) { + if (!Start) Start = Str + i; + else Len++; + } + if (Str[i] == Delim || Str[i] == '\0') { + NumEntries++; + if (Start) { + char *Ret = new char[Len + 1]; + memset(Ret, 0, Len + 1); + strncpy(Ret, Start, Len); + return Ret; + } + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CBUtils::RandomInt(int From, int To) { + if (To < From) { + int i = To; + To = From; + From = i; + } + return (rand() % (To - From + 1)) + From; +} + +////////////////////////////////////////////////////////////////////////// +float CBUtils::RandomFloat(float From, float To) { + float RandNum = (float)rand() / (float)RAND_MAX; + return From + (To - From) * RandNum; +} + +////////////////////////////////////////////////////////////////////////// +float CBUtils::RandomAngle(float From, float To) { + while (To < From) { + To += 360; + } + return NormalizeAngle(RandomFloat(From, To)); +} + +////////////////////////////////////////////////////////////////////////// +bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { + char stringc, patternc; + + for (;; ++String) { + stringc = toupper(*String); + patternc = toupper(*Pattern++); + + switch (patternc) { + case 0: + return (stringc == 0); + + case '?': + if (stringc == 0) return false; + break; + + case '*': + if (!*Pattern) return true; + + if (*Pattern == '.') { + char *dot; + if (Pattern[1] == '*' && Pattern[2] == 0) return true; + dot = (char *)strchr(String, '.'); + if (Pattern[1] == 0) return (dot == NULL || dot[1] == 0); + if (dot != NULL) { + String = dot; + if (strpbrk(Pattern, "*?[") == NULL && strchr(String + 1, '.') == NULL) + return(scumm_stricmp(Pattern + 1, String + 1) == 0); + } + } + + while (*String) + if (CBUtils::MatchesPattern(Pattern, String++)) + return true; + return false; + + default: + if (patternc != stringc) + if (patternc == '.' && stringc == 0) + return(CBUtils::MatchesPattern(Pattern, String)); + else + return false; + break; + } + } +} + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::GetPath(const char *Filename) { + AnsiString path = PathUtil::GetDirectoryName(Filename); + //path = boost::filesystem::syste_complete(path).string(); + warning("CBUtils::GetPath: (%s), not implemented", Filename); + char *ret = new char[path.size() + 1]; + strcpy(ret, path.c_str()); + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +char *CBUtils::GetFilename(const char *Filename) { + AnsiString path = PathUtil::GetFileName(Filename); + char *ret = new char[path.size() + 1]; + strcpy(ret, path.c_str()); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { + float var_R = (D3DCOLGetR(RGBColor) / 255.0f); + float var_G = (D3DCOLGetG(RGBColor) / 255.0f); + float var_B = (D3DCOLGetB(RGBColor) / 255.0f); + + //Min. value of RGB + float var_Min = MIN(var_R, var_G); + var_Min = MIN(var_Min, var_B); + + //Max. value of RGB + float var_Max = MAX(var_R, var_G); + var_Max = MAX(var_Max, var_B); + + //Delta RGB value + float del_Max = var_Max - var_Min; + + float H, S, L; + + L = (var_Max + var_Min) / 2.0f; + + //This is a gray, no chroma... + if (del_Max == 0) { + H = 0; + S = 0; + } + //Chromatic data... + else { + if (L < 0.5f) S = del_Max / (var_Max + var_Min); + else S = del_Max / (2.0f - var_Max - var_Min); + + float del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; + float del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; + float del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; + + if (var_R == var_Max) H = del_B - del_G; + else if (var_G == var_Max) H = (1.0f / 3.0f) + del_R - del_B; + else if (var_B == var_Max) H = (2.0f / 3.0f) + del_G - del_R; + + if (H < 0) H += 1; + if (H > 1) H -= 1; + } + + *OutH = (byte)(H * 255); + *OutS = (byte)(S * 255); + *OutL = (byte)(L * 255); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { + float H = InH / 255.0f; + float S = InS / 255.0f; + float L = InL / 255.0f; + + byte R, G, B; + + + if (S == 0) { + R = (byte)(L * 255); + G = (byte)(L * 255); + B = (byte)(L * 255); + } else { + float var_1, var_2; + + if (L < 0.5) var_2 = L * (1.0 + S); + else var_2 = (L + S) - (S * L); + + var_1 = 2.0f * L - var_2; + + R = (byte)(255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f))); + G = (byte)(255 * Hue2RGB(var_1, var_2, H)); + B = (byte)(255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f))); + } + return DRGBA(255, R, G, B); +} + + +////////////////////////////////////////////////////////////////////////// +float CBUtils::Hue2RGB(float v1, float v2, float vH) { + if (vH < 0.0f) vH += 1.0f; + if (vH > 1.0f) vH -= 1.0f; + if ((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH); + if ((2.0f * vH) < 1.0f) return (v2); + if ((3.0f * vH) < 2.0f) return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f); + return (v1); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h new file mode 100644 index 0000000000..46e895ff4d --- /dev/null +++ b/engines/wintermute/utils/utils.h @@ -0,0 +1,71 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UTILS_H +#define WINTERMUTE_UTILS_H + +#include "engines/wintermute/wintypes.h" + +namespace WinterMute { + +class CBGame; + +class CBUtils { +public: + static void Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); + static void Swap(int *a, int *b); + static bool StrBeginsI(const char *String, const char *Fragment); + static float NormalizeAngle(float Angle); + + static void CreatePath(const char *Path, bool PathOnly = false); + + static void DebugMessage(HWND hWnd, const char *Text); + static char *SetString(char **String, const char *Value); + + static int StrNumEntries(const char *Str, const char Delim = ','); + static char *StrEntry(int Entry, const char *Str, const char Delim = ','); + + static int RandomInt(int From, int To); + static float RandomFloat(float From, float To); + static float RandomAngle(float From, float To); + + static bool MatchesPattern(const char *pattern, const char *string); + + static char *GetPath(const char *Filename); + static char *GetFilename(const char *Filename); + + static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); + static uint32 HSLtoRGB(byte H, byte S, byte L); + +private: + static float Hue2RGB(float v1, float v2, float vH); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp new file mode 100644 index 0000000000..ab20135595 --- /dev/null +++ b/engines/wintermute/video/VidPlayer.cpp @@ -0,0 +1,470 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + +#include "engines/wintermute/dcgf.h" +#include "VidPlayer.h" + +//#pragma comment(lib, "vfw32.lib") + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::SetDefaults() { + _playing = false; + +/* _aviFile = NULL; + + _audioStream = NULL; + _audioFormat = NULL; + + _videoStream = NULL; + _videoFormat = NULL; + _videoPGF = NULL;*/ + _videoEndTime = 0; + + //_sound = NULL; + _soundAvailable = false; + + //_vidRenderer = NULL; + + _startTime = 0; + _totalVideoTime = 0; + + //_lastSample = -1; + + //_targetFormat = NULL; + + _playPosX = _playPosY = 0; + _playZoom = 0.0f; + + _filename = NULL; + + _slowRendering = false; + + _currentSubtitle = 0; + _showSubtitle = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::~CVidPlayer() { + Cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Cleanup() { +#if 0 + if (_sound) _sound->Stop(); + if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); + _videoPGF = NULL; + + _playing = false; + + + if (_aviFile) AVIFileRelease(m_AviFile); + + if (_audioStream) AVIStreamRelease(m_AudioStream); + if (_videoStream) AVIStreamRelease(m_VideoStream); + + if (_audioFormat) delete [](byte *)m_AudioFormat; + if (_videoFormat) delete [](byte *)m_VideoFormat; + if (_targetFormat) delete [](byte *)m_TargetFormat; + + SAFE_DELETE(_sound); + SAFE_DELETE(_vidRenderer); + + SAFE_DELETE_ARRAY(_filename); + + for (int i = 0; i < _subtitles.GetSize(); i++) delete _subtitles[i]; + _subtitles.RemoveAll(); + + return SetDefaults(); +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Initialize(char *inFilename, char *SubtitleFile) { +#if 0 + Cleanup(); + + char Filename[MAX_PATH]; + Game->_fileManager->GetFullPath(inFilename, Filename); + + // open file + if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { + Game->LOG(0, "Error opening AVI file '%s'", Filename); + return E_FAIL; + } + + // get video stream + if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { + Game->LOG(0, "Error finding video stream in AVI file '%s'", Filename); + return E_FAIL; + } + _totalVideoTime = AVIStreamEndTime(_videoStream); + + // get audio stream + if (Game->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + _soundAvailable = true; + else + _soundAvailable = false; + + + LONG Size; + + // get video format + if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { + Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", Filename); + return E_FAIL; + } + _videoFormat = (LPBITMAPINFO)new BYTE[Size]; + AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); + + // initialize optimal target format + m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; + memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); + memcpy(m_TargetFormat, m_VideoFormat, Size); + m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); + + m_TargetFormat->bV4BitCount = 24; + m_TargetFormat->bV4V4Compression = BI_RGB; + + if (Game->m_UseD3D) + m_VidRenderer = new CVidRendererD3D(Game); + else + m_VidRenderer = new CVidRendererDD(Game); + + if (!m_VidRenderer || FAILED(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { + Game->LOG(0, "Error initializing video renderer for AVI file '%s'", Filename); + SAFE_DELETE(m_VidRenderer); + return E_FAIL; + } + + + // create sound buffer + HRESULT res; + + if (_soundAvailable) { + _sound = new CBSoundAVI(Game); + if (FAILED(res = _sound->InitializeBuffer(_audioStream))) { + SAFE_DELETE(_sound); + _soundAvailable = false; + Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", Filename); + } + } + + if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + + _filename = new char[strlen(Filename) + 1]; + if (_filename) strcpy(_filename, Filename); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Update() { +#if 0 + if (!m_Playing) return S_OK; + + HRESULT res; + + if (_soundAvailable && m_Sound) { + res = _sound->Update(); + if (FAILED(res)) return res; + } + + + DWORD CurrentTime; // current playing time (in ms) + /* + if(m_SoundAvailable && m_Sound){ + CurrentTime = m_Sound->GetPosition(); // in samples + CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); + + if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; + } + else + CurrentTime = timeGetTime() - m_StartTime; + */ + CurrentTime = timeGetTime() - _startTime; + + if (CurrentTime >= _totalVideoTime) { + Stop(); + return S_OK; + } + + + // get and render frame + DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); + if (sample != _lastSample) { + _lastSample = sample; + + // process subtitles + _showSubtitle = false; + while (_currentSubtitle < _subtitles.GetSize()) { + int End = _subtitles[_currentSubtitle]->m_EndFrame; + + bool NextFrameOK = (_currentSubtitle < _subtitles.GetSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); + + if (sample > End) { + if (NextFrameOK) { + _currentSubtitle++; + } else { + _showSubtitle = (End == 0); + break; + } + } else { + _showSubtitle = true; + break; + } + } + + + // render frame + LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); + if (FrameData) { + if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); + else return _vidRenderer->ProcessFrame(FrameData); + } else return E_FAIL; + } else return S_OK; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Display() { +#if 0 + if (!m_Playing) return S_OK; + + HRESULT res; + if (_vidRenderer) res = _vidRenderer->Display(m_PlayPosX, m_PlayPosY, m_PlayZoom); + else res = E_FAIL; + + // display subtitle + if (m_ShowSubtitle) { + CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); + font->DrawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); + } + + return res; +#endif + return 0; +} + + + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +#if 0 + if (!_videoStream || !_vidRenderer) return E_FAIL; + + switch (Type) { + case VID_PLAY_POS: + _playZoom = 100.0f; + _playPosX = X; + _playPosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float ZoomY = (float)((float)Game->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + _playZoom = min(ZoomX, ZoomY); + _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; + _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; + _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; + break; + } + + _targetFormat->bV4BitCount = 24; + _targetFormat->bV4V4Compression = BI_RGB; + + + _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); + if (!_videoPGF) { + _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); + if (!_videoPGF) { + Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); + Cleanup(); + return E_FAIL; + } else { + Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); + _slowRendering = true; + } + } else _slowRendering = false; + + // HACK!!! + _slowRendering = true; + + + _currentSubtitle = 0; + + Game->Freeze(FreezeMusic); + + _playing = true; + if (_sound) _sound->Play(); + _startTime = timeGetTime(); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::Stop() { +#if 0 + if (!_playing) return S_OK; + + Cleanup(); + + Game->Unfreeze(); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::IsPlaying() { + return _playing; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidPlayer::LoadSubtitles(char *Filename, char *SubtitleFile) { +#if 0 + if (!Filename) return S_OK; + + char NewFile[MAX_PATH]; + char drive[_MAX_DRIVE]; + char dir[_MAX_DIR]; + char fname[_MAX_FNAME]; + + if (SubtitleFile) { + strcpy(NewFile, SubtitleFile); + } else { + _splitpath(Filename, drive, dir, fname, NULL); + _makepath(NewFile, drive, dir, fname, ".SUB"); + } + + DWORD Size; + BYTE *Buffer = Game->m_FileManager->ReadWholeFile(NewFile, &Size, false); + if (Buffer == NULL) return S_OK; // no subtitles + + + LONG Start, End; + bool InToken; + char *TokenStart; + int TokenLength; + int TokenPos; + int TextLength; + + int Pos = 0; + int LineLength = 0; + while (Pos < Size) { + Start = End = -1; + InToken = false; + TokenPos = -1; + TextLength = 0; + + LineLength = 0; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *Text = new char[RealLength + 1]; + char *line = (char *)&Buffer[Pos]; + + for (int i = 0; i < RealLength; i++) { + if (line[i] == '{') { + if (!InToken) { + InToken = true; + TokenStart = line + i + 1; + TokenLength = 0; + TokenPos++; + } else TokenLength++; + } else if (line[i] == '}') { + if (InToken) { + InToken = false; + char *Token = new char[TokenLength + 1]; + strncpy(Token, TokenStart, TokenLength); + Token[TokenLength] = '\0'; + if (TokenPos == 0) Start = atoi(Token); + else if (TokenPos == 1) End = atoi(Token); + + delete [] Token; + } else { + Text[TextLength] = line[i]; + TextLength++; + } + } else { + if (InToken) { + TokenLength++; + } else { + Text[TextLength] = line[i]; + if (Text[TextLength] == '|') Text[TextLength] = '\n'; + TextLength++; + } + } + } + Text[TextLength] = '\0'; + + if (Start != -1 && TextLength > 0) _subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + + delete [] Text; + + Pos += LineLength + 1; + } + + delete [] Buffer; +#endif + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h new file mode 100644 index 0000000000..a1abf2ea46 --- /dev/null +++ b/engines/wintermute/video/VidPlayer.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDPLAYER_H +#define WINTERMUTE_VIDPLAYER_H + +#include "engines/wintermute/dctypes.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "engines/wintermute/Base/BBase.h" + +#define MAX_AUDIO_STREAMS 5 +#define MAX_VIDEO_STREAMS 5 + + +namespace WinterMute { + +class CVidPlayer : public CBBase { +public: + bool _showSubtitle; + int _currentSubtitle; + HRESULT LoadSubtitles(char *Filename, char *SubtitleFile); + bool _slowRendering; + bool IsPlaying(); + char *_filename; + HRESULT Stop(); + HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + uint32 _totalVideoTime; + uint32 _startTime; + //CVidRenderer *_vidRenderer; + //CBSoundAVI *_sound; + bool _soundAvailable; + HRESULT SetDefaults(); + bool _playing; + HRESULT Display(); + HRESULT Update(); + HRESULT Initialize(char *inFilename, char *SubtitleFile = NULL); + HRESULT Cleanup(); + CVidPlayer(CBGame *inGame); + virtual ~CVidPlayer(); + + /*PAVIFILE _aviFile; + + LONG _lastSample; + + PAVISTREAM _audioStream; + PAVISTREAM _videoStream; + + LPWAVEFORMAT _audioFormat; + + LPBITMAPINFO _videoFormat; + PGETFRAME _videoPGF;*/ + uint32 _videoEndTime; + + int _playPosX; + int _playPosY; + float _playZoom; + +/* LPBITMAPV4HEADER _targetFormat; + + CBArray _subtitles;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp new file mode 100644 index 0000000000..01e1728732 --- /dev/null +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -0,0 +1,963 @@ +// Copyright 2009, 2010 Jan Nedoma +// +// This file is part of Wintermute Engine. +// +// Wintermute Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Wintermute Engine 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Wintermute Engine. If not, see . +////////////////////////////////////////////////////////////////////////// + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/video/vidtheoraplayer.h" + +//#pragma comment(lib, "libtheora.lib") + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::SetDefaults() { +#if 0 + _file = NULL; + _filename = NULL; + _startTime = 0; + _looping = false; + _sound = NULL; + _audiobufGranulepos = 0; + _freezeGame = false; + _currentTime = 0; + + _state = THEORA_STATE_NONE; + + _videoFrameReady = false; + _audioFrameReady = false; + _videobufTime = 0; + + _audioBuf = NULL; + _audioBufFill = 0; + _audioBufSize = 0; + _playbackStarted = false; + _dontDropFrames = false; + + _texture = NULL; + _alphaImage = NULL; + _alphaFilename = NULL; + + _frameRendered = false; + + +/* memset(&m_OggSyncState, 0, sizeof(ogg_sync_state)); + memset(&m_OggPage, 0, sizeof(ogg_page)); + memset(&m_VorbisStreamState, 0 , sizeof(ogg_stream_state)); + memset(&m_TheoraStreamState, 0 , sizeof(ogg_stream_state)); + + memset(&m_TheoraInfo, 0, sizeof(theora_info)); + memset(&m_TheoraComment, 0, sizeof(theora_comment)); + memset(&m_TheoraState, 0, sizeof(theora_state)); + + memset(&m_VorbisInfo, 0, sizeof(vorbis_info)); + memset(&m_VorbisDSPState, 0, sizeof(vorbis_dsp_state)); + memset(&m_VorbisBlock, 0, sizeof(vorbis_block)); + memset(&m_VorbisComment, 0, sizeof(vorbis_comment));*/ + + _vorbisStreams = _theoraStreams = 0; + + GenLookupTables(); + + _seekingKeyframe = false; + _timeOffset = 0.0f; + + _posX = _posY = 0; + _playbackType = VID_PLAY_CENTER; + _playZoom = 0.0f; + + _subtitler = NULL; + + _savedState = THEORA_STATE_NONE; + _savedPos = 0; + _volume = 100; +#endif +} + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::~CVidTheoraPlayer(void) { + Cleanup(); + + SAFE_DELETE_ARRAY(_filename); + SAFE_DELETE_ARRAY(_alphaFilename); + SAFE_DELETE(_texture); + SAFE_DELETE(_alphaImage); +// SAFE_DELETE(_subtitler); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::Cleanup() { +#if 0 + if (_vorbisStreams) { + ogg_stream_clear(&m_VorbisStreamState); + vorbis_block_clear(&m_VorbisBlock); + vorbis_dsp_clear(&m_VorbisDSPState); + vorbis_comment_clear(&m_VorbisComment); + vorbis_info_clear(&m_VorbisInfo); + + _vorbisStreams = 0; + } + if (m_TheoraStreams) { + ogg_stream_clear(&m_TheoraStreamState); + theora_clear(&m_TheoraState); + theora_comment_clear(&m_TheoraComment); + theora_info_clear(&m_TheoraInfo); + + m_TheoraStreams = 0; + } + ogg_sync_clear(&m_OggSyncState); + + + if (m_File) Game->m_FileManager->CloseFile(m_File); + m_File = NULL; + + if (m_Sound) { + Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + } + + + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufFill = 0; + m_AudioBufSize = 0; +#endif +} + +////////////////////////////////////////////////////////////////////////// +/*int CVidTheoraPlayer::BufferData(ogg_sync_state *OggSyncState) { + if (!_file) return 0; + + DWORD Size = 4096; + if (m_File->GetSize() - m_File->GetPos() < Size) Size = m_File->GetSize() - m_File->GetPos(); + + char *Buffer = ogg_sync_buffer(OggSyncState, Size); + m_File->Read(Buffer, Size); + ogg_sync_wrote(OggSyncState, Size); + + return Size; +}*/ + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { +#if 0 + Cleanup(); + + _file = Game->_fileManager->OpenFile(Filename); + if (!_file) return E_FAIL; + + if (Filename != _filename) CBUtils::SetString(&_filename, Filename); + + // start up Ogg stream synchronization layer + ogg_sync_init(&m_OggSyncState); + + // init supporting Vorbis structures needed in header parsing + vorbis_comment_init(&m_VorbisComment); + vorbis_info_init(&m_VorbisInfo); + + // init supporting Theora structures needed in header parsing + theora_comment_init(&m_TheoraComment); + theora_info_init(&m_TheoraInfo); + + + + // Ogg file open; parse the headers + // Only interested in Vorbis/Theora streams + ogg_packet TempOggPacket; + bool IsDone = false; + while (!IsDone) { + int BytesRead = BufferData(&m_OggSyncState); + if (BytesRead == 0) break; + + while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + ogg_stream_state OggStateTest; + + // is this a mandated initial header? If not, stop parsing + if (!ogg_page_bos(&m_OggPage)) { + // don't leak the page; get it into the appropriate stream + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + + IsDone = true; + break; + } + + ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); + ogg_stream_pagein(&OggStateTest, &m_OggPage); + ogg_stream_packetout(&OggStateTest, &TempOggPacket); + + // identify the codec: try theora + if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { + // it is theora + memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); + m_TheoraStreams = 1; + } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { + // it is vorbis + memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); + m_VorbisStreams = 1; + } else { + // whatever it is, we don't care about it + ogg_stream_clear(&OggStateTest); + } + } + } + + // we're expecting more header packets + while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { + int Ret; + + // look for further theora headers + while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { + if (Ret < 0) { + Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return E_FAIL; + } + if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { + Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return E_FAIL; + } + m_TheoraStreams++; + if (m_TheoraStreams == 3) break; + } + + /* look for more vorbis header packets */ + while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { + if (Ret < 0) { + Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return E_FAIL; + } + if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { + Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return E_FAIL; + } + m_VorbisStreams++; + if (m_VorbisStreams == 3) break; + } + + // The header pages/packets will arrive before anything else we + // care about, or the stream is not obeying spec + if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + } else { + int Ret = BufferData(&m_OggSyncState); // someone needs more data + if (Ret == 0) { + Game->LOG(0, "End of file while searching for codec headers"); + return E_FAIL; + } + } + } + + + + // and now we have it all. initialize decoders + if (m_TheoraStreams) { + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + } else { + // tear down the partial theora setup + theora_info_clear(&m_TheoraInfo); + theora_comment_clear(&m_TheoraComment); + } + + if (m_VorbisStreams) { + vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); + vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); + + } else { + // tear down the partial vorbis setup + vorbis_info_clear(&m_VorbisInfo); + vorbis_comment_clear(&m_VorbisComment); + } + + HRESULT Res = S_OK; + + // create sound buffer + if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { + m_Sound = new CBSoundTheora(Game); + Game->m_SoundMgr->AddSound(m_Sound); + if (FAILED(Res = m_Sound->InitializeBuffer(this))) { + Game->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", Filename); + } else { + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufSize = m_Sound->m_StreamBlockSize; + m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; + } + } + + // create texture + if (m_TheoraStreams && !m_Texture) { + if (Game->m_UseD3D) + m_Texture = new CBSurfaceD3D(Game); + else + m_Texture = new CBSurfaceDD(Game); + + if (!m_Texture || FAILED(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { + SAFE_DELETE(m_Texture); + } + } + + + if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(Filename, SubtitleFile); + + return Res; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::ResetStream() { +#if 0 + if (_sound) _sound->Stop(); + + m_TimeOffset = 0.0f; + Initialize(m_Filename); + Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { +#if 0 + if (ForceZoom < 0.0f) ForceZoom = 100.0f; + if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); + else m_Volume = Volume; + + m_FreezeGame = FreezeGame; + if (!m_PlaybackStarted && m_FreezeGame) Game->Freeze(FreezeMusic); + + m_PlaybackStarted = false; + m_State = THEORA_STATE_PLAYING; + + m_Looping = Looping; + m_PlaybackType = Type; + + float Width, Height; + if (m_TheoraStreams) { + Width = (float)m_TheoraInfo.width; + Height = (float)m_TheoraInfo.height; + } else { + Width = (float)Game->m_Renderer->m_Width; + Height = (float)Game->m_Renderer->m_Height; + } + + switch (Type) { + case VID_PLAY_POS: + m_PlayZoom = ForceZoom; + m_PosX = X; + m_PosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->m_Renderer->m_Width / Width * 100); + float ZoomY = (float)((float)Game->m_Renderer->m_Height / Height * 100); + m_PlayZoom = min(ZoomX, ZoomY); + m_PosX = (Game->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; + m_PosY = (Game->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + m_PlayZoom = 100.0f; + m_PosX = (Game->m_Renderer->m_Width - Width) / 2; + m_PosY = (Game->m_Renderer->m_Height - Height) / 2; + break; + } + + + if (StartTime) SeekToTime(StartTime); + + Update(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Stop() { +#if 0 + if (m_Sound) m_Sound->Stop(); + m_State = THEORA_STATE_FINISHED; + if (m_FreezeGame) Game->Unfreeze(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Update() { +#if 0 + m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; + + if (!IsPlaying()) return S_OK; + + if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return S_OK; + + if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return S_OK; + + int Counter = 0; + while (true) { + if (m_Sound) DecodeVorbis(); + else m_AudioFrameReady = true; + + if (m_Texture) DecodeTheora(); + else m_VideoFrameReady = true; + + if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { + // end playback + if (!m_Looping) { + m_State = THEORA_STATE_FINISHED; + if (m_Sound) m_Sound->Stop(); + if (m_FreezeGame) Game->Unfreeze(); + break; + } else { + ResetStream(); + return S_OK; + } + } + + + if (!m_VideoFrameReady || !m_AudioFrameReady) { + Counter++; + if (StreamInData() == 0) break; + } else break; + } + + + // If playback has begun, top audio buffer off immediately. + //if(m_Sound) WriteAudio(); + + // are we at or past time for this video frame? + if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { + //Game->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); + if (m_Texture) WriteVideo(); + m_VideoFrameReady = false; + + if (m_SavedState == THEORA_STATE_PAUSED) { + Pause(); + m_SavedState = THEORA_STATE_NONE; + } + } + + // if our buffers either don't exist or are ready to go, + // we can begin playback + bool StartNow = false; + if ((!m_TheoraStreams || m_VideoFrameReady) && + (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; + // same if we've run out of input + if (m_File->IsEOF()) StartNow = true; + + + if (m_Sound) WriteAudio(); + + + if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { + //m_StartTime = timeGetTime(); + m_StartTime = m_CurrentTime; + if (m_Sound) { + m_Sound->SetPrivateVolume(m_Volume); + m_Sound->Play(); + } + m_PlaybackStarted = true; + } + + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Update(GetMovieFrame()); +#endif + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +/*int CVidTheoraPlayer::StreamInData() { +#if 0 + // no data yet for somebody. Grab another page + int BytesRead = BufferData(&m_OggSyncState); + while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + } + return BytesRead; +#endif +}*/ + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::DecodeVorbis() { +#if 0 + if (!m_Sound) return; + + while (m_VorbisStreams && !m_AudioFrameReady) { + int ret; + float **pcm; + + // if there's pending, decoded audio, grab it + if ((ret = vorbis_synthesis_pcmout(&m_VorbisDSPState, &pcm)) > 0 && !m_SeekingKeyframe) { + int count = m_AudioBufFill / 2; + int maxsamples = (m_AudioBufSize - m_AudioBufFill) / 2 / m_VorbisInfo.channels; + + int i; + for (i = 0; i < ret && i < maxsamples; i++) + for (int j = 0; j < m_VorbisInfo.channels; j++) { + int val = (int)(pcm[j][i] * 32767.f); + if (val > 32767) val = 32767; + if (val < -32768) val = -32768; + + m_AudioBuf[count++] = val; + } + vorbis_synthesis_read(&m_VorbisDSPState, i); + m_AudioBufFill += i * m_VorbisInfo.channels * 2; + if (m_AudioBufFill == m_AudioBufSize) m_AudioFrameReady = true; + if (m_VorbisDSPState.granulepos >= 0) + m_AudiobufGranulepos = m_VorbisDSPState.granulepos - ret + i; + else + m_AudiobufGranulepos += i; + } else { + ogg_packet opVorbis; + + //no pending audio; is there a pending packet to decode? + if (ogg_stream_packetout(&m_VorbisStreamState, &opVorbis) > 0) { + //test for success! + if (vorbis_synthesis(&m_VorbisBlock, &opVorbis) == 0) + vorbis_synthesis_blockin(&m_VorbisDSPState, &m_VorbisBlock); + } else { //we need more data; break out to suck in another page + break; + } + } + } // while +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::DecodeTheora() { +#if 0 + ogg_packet opTheora; + + while (m_TheoraStreams && !m_VideoFrameReady) { + // theora is one in, one out... + if (ogg_stream_packetout(&m_TheoraStreamState, &opTheora) > 0) { + theora_decode_packetin(&m_TheoraState, &opTheora); + m_VideobufTime = theora_granule_time(&m_TheoraState, m_TheoraState.granulepos); + + if (m_SeekingKeyframe) { + if (!theora_packet_iskeyframe(&opTheora)) continue; + else { + m_SeekingKeyframe = false; + m_TimeOffset = m_VideobufTime; + } + } + + if (m_VideobufTime >= GetMovieTime() || m_DontDropFrames) m_VideoFrameReady = true; + } else { + break; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +float CVidTheoraPlayer::GetMovieTime() { +#if 0 + if (!m_PlaybackStarted) return 0.0f; + else if (m_Sound) return (float)(m_Sound->GetPosition()) / 1000.0f + m_TimeOffset; + else return (float)(m_CurrentTime - m_StartTime) / 1000.0f + m_TimeOffset; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CVidTheoraPlayer::GetMovieFrame() { +#if 0 + if (!m_TheoraStreams) return 0; + float Time = GetMovieTime(); + + return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::WriteAudio() { +#if 0 + if (m_AudioFrameReady) { + if (m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize)) { + m_AudioBufFill = 0; + m_AudioFrameReady = false; + } + } else if (m_File->IsEOF()) { + memset(m_AudioBuf, 0, m_AudioBufSize); + m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::WriteVideo() { +#if 0 + if (!m_Texture) return E_FAIL; + + yuv_buffer yuv; + theora_decode_YUVout(&m_TheoraState, &yuv); + + m_Texture->StartPixelOp(); + RenderFrame(m_Texture, &yuv); + m_Texture->EndPixelOp(); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Display(uint32 Alpha) { + + RECT rc; + HRESULT Res; +#if 0 + if (m_Texture) { + SetRect(&rc, 0, 0, m_Texture->GetWidth(), m_Texture->GetHeight()); + if (m_PlayZoom == 100.0f) Res = m_Texture->DisplayTrans(m_PosX, m_PosY, rc, Alpha); + else Res = m_Texture->DisplayTransZoom(m_PosX, m_PosY, rc, m_PlayZoom, m_PlayZoom, Alpha); + } else Res = E_FAIL; + + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); +#endif + return Res; +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::GenLookupTables() { + //used to bring the table into the high side (scale up) so we + //can maintain high precision and not use floats (FIXED POINT) + int scale = 1L << 13; + int temp; + + for (unsigned int i = 0; i < 256; i++) { + temp = i - 128; + + _yTable[i] = (unsigned int)((1.164 * scale + 0.5) * (i - 16)); //Calc Y component + + _rVTable[i] = (unsigned int)((1.596 * scale + 0.5) * temp); //Calc R component + + _gUTable[i] = (unsigned int)((0.391 * scale + 0.5) * temp); //Calc G u & v components + _gVTable[i] = (unsigned int)((0.813 * scale + 0.5) * temp); + + _bUTable[i] = (unsigned int)((2.018 * scale + 0.5) * temp); //Calc B component + } +} + +#define CLIP_RGB_COLOR( rgb_color_test ) max( min(rgb_color_test, 255), 0 ) +////////////////////////////////////////////////////////////////////////// +#if 0 +HRESULT CVidTheoraPlayer::RenderFrame(CBSurface *Texture, yuv_buffer *yuv) { + //Convert 4:2:0 YUV YCrCb to an RGB24 Bitmap + //convenient pointers + int TargetX1 = 0; + int TargetX2 = 1; + int TargetY1 = 0; + int TargetY2 = 1; + + unsigned char *ySrc = (unsigned char *)yuv->y; + unsigned char *uSrc = (unsigned char *)yuv->u; + unsigned char *vSrc = (unsigned char *)yuv->v; + unsigned char *ySrc2 = ySrc + yuv->y_stride; + + //Calculate buffer offset + int yOff = (yuv->y_stride * 2) - yuv->y_width; + + + //Check if upside down, if so, reverse buffers and offsets + if (yuv->y_height < 0) { + yuv->y_height = -yuv->y_height; + ySrc += (yuv->y_height - 1) * yuv->y_stride; + + uSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; + vSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; + + ySrc2 = ySrc - yuv->y_stride; + yOff = -yuv->y_width - (yuv->y_stride * 2); + + yuv->uv_stride = -yuv->uv_stride; + } + + //Cut width and height in half (uv field is only half y field) + yuv->y_height = yuv->y_height >> 1; + yuv->y_width = yuv->y_width >> 1; + + //Convientient temp vars + signed int r, g, b, u, v, bU, gUV, rV, rgbY; + int x; + + //Loop does four blocks per iteration (2 rows, 2 pixels at a time) + for (int y = yuv->y_height; y > 0; --y) { + for (x = 0; x < yuv->y_width; ++x) { + //Get uv pointers for row + u = uSrc[x]; + v = vSrc[x]; + + //get corresponding lookup values + rgbY = m_YTable[*ySrc]; + rV = m_RVTable[v]; + gUV = m_GUTable[u] + m_GVTable[v]; + bU = m_BUTable[u]; + ++ySrc; + + //scale down - brings are values back into the 8 bits of a byte + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX1, TargetY1, r, g, b, GetAlphaAt(TargetX1, TargetY1)); + + //And repeat for other pixels (note, y is unique for each + //pixel, while uv are not) + rgbY = m_YTable[*ySrc]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX2, TargetY1, r, g, b, GetAlphaAt(TargetX2, TargetY1)); + ++ySrc; + + rgbY = m_YTable[*ySrc2]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX1, TargetY2, r, g, b, GetAlphaAt(TargetX1, TargetY2)); + ++ySrc2; + + rgbY = m_YTable[*ySrc2]; + r = CLIP_RGB_COLOR((rgbY + rV) >> 13); + g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); + b = CLIP_RGB_COLOR((rgbY + bU) >> 13); + Texture->PutPixel(TargetX2, TargetY2, r, g, b, GetAlphaAt(TargetX2, TargetY2)); + ++ySrc2; + + /* + Texture->PutPixel(TargetX1, TargetY1, 255, 0, 0, GetAlphaAt(TargetX1, TargetY1)); + Texture->PutPixel(TargetX2, TargetY1, 255, 0, 0, GetAlphaAt(TargetX2, TargetY1)); + Texture->PutPixel(TargetX1, TargetY2, 255, 0, 0, GetAlphaAt(TargetX1, TargetY2)); + Texture->PutPixel(TargetX2, TargetY2, 255, 0, 0, GetAlphaAt(TargetX2, TargetY2)); + */ + + + //Advance inner loop offsets + TargetX1 += 2; + TargetX2 += 2; + } // end for x + + //Advance destination pointers by offsets + TargetX1 = 0; + TargetX2 = 1; + TargetY1 += 2; + TargetY2 += 2; + + ySrc += yOff; + ySrc2 += yOff; + uSrc += yuv->uv_stride; + vSrc += yuv->uv_stride; + } //end for y + + m_FrameRendered = true; + + return S_OK; +} +#endif +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::SetAlphaImage(const char *Filename) { +#if 0 + SAFE_DELETE(m_AlphaImage); + m_AlphaImage = new CBImage(Game); + if (!m_AlphaImage || FAILED(m_AlphaImage->LoadFile(Filename))) { + SAFE_DELETE(m_AlphaImage); + SAFE_DELETE_ARRAY(m_AlphaFilename); + return E_FAIL; + } + if (m_AlphaFilename != Filename) CBUtils::SetString(&m_AlphaFilename, Filename); + m_AlphaImage->Convert(IMG_TRUECOLOR); +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +byte CVidTheoraPlayer::GetAlphaAt(int X, int Y) { +#if 0 + if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); + else return 0xFF; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +inline int intlog(int num) { + int r = 0; + while (num > 0) { + num = num / 2; + r = r + 1; + } + + return r; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::SeekToTime(uint32 Time) { +#if 0 + if (!m_TheoraStreams) return E_FAIL; + + + float TargetTime = Time / 1000.0f; + + + ogg_page page; + int read = 1; + ogg_int64_t gran; + float movieLength = 0; + DWORD LastPos = 0; + + int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); + + while (!m_File->IsEOF() && read != 0) { + read = BufferData(&m_OggSyncState); + + while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { + int serno = ogg_page_serialno(&page); + //This is theora stream we were searching for + if (m_TheoraStreamState.serialno == serno) { + //Calculate a rough time estimate + gran = ogg_page_granulepos(&page); + if (gran >= 0) { + ogg_int64_t iframe = gran >> keyframe_granule_shift; + ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); + movieLength = (iframe + pframe) * + ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); + + if (movieLength >= TargetTime) { + m_TimeOffset = movieLength; + //m_TimeOffset = TargetTime; + //m_File->Seek(LastPos); + + goto finish; + } + LastPos = m_File->GetPos(); + } + } + } + } + +finish: + ogg_sync_reset(&m_OggSyncState); + + ogg_stream_reset(&m_TheoraStreamState); + ogg_stream_reset(&m_VorbisStreamState); + + theora_clear(&m_TheoraState); + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + vorbis_synthesis_restart(&m_VorbisDSPState); + + m_SeekingKeyframe = true; + + //theora_packet_iskeyframe + +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Pause() { +#if 0 + if (m_State == THEORA_STATE_PLAYING) { + m_State = THEORA_STATE_PAUSED; + if (m_Sound) m_Sound->Pause(); + return S_OK; + } else return E_FAIL; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::Resume() { +#if 0 + if (_state == THEORA_STATE_PAUSED) { + _state = THEORA_STATE_PLAYING; + if (_sound) _sound->Resume(); + return S_OK; + } else return E_FAIL; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +/*HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { + //CBBase::Persist(PersistMgr); +#if 0 + if (PersistMgr->m_Saving) { + m_SavedPos = GetMovieTime() * 1000; + m_SavedState = m_State; + } else { + SetDefaults(); + } + + PersistMgr->Transfer(TMEMBER(Game)); + PersistMgr->Transfer(TMEMBER(m_SavedPos)); + PersistMgr->Transfer(TMEMBER(m_SavedState)); + PersistMgr->Transfer(TMEMBER(m_Filename)); + PersistMgr->Transfer(TMEMBER(m_AlphaFilename)); + PersistMgr->Transfer(TMEMBER(m_PosX)); + PersistMgr->Transfer(TMEMBER(m_PosY)); + PersistMgr->Transfer(TMEMBER(m_PlayZoom)); + PersistMgr->Transfer(TMEMBER_INT(m_PlaybackType)); + PersistMgr->Transfer(TMEMBER(m_Looping)); + + if (PersistMgr->CheckVersion(1, 7, 3)) { + PersistMgr->Transfer(TMEMBER(m_Volume)); + } else { + m_Volume = 100; + } +#endif + return S_OK; +} +*/ +////////////////////////////////////////////////////////////////////////// +HRESULT CVidTheoraPlayer::InitializeSimple() { +#if 0 + if (SUCCEEDED(Initialize(m_Filename))) { + if (m_AlphaFilename) SetAlphaImage(m_AlphaFilename); + Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, m_SavedPos, m_PlayZoom); + } else m_State = THEORA_STATE_FINISHED; +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CVidTheoraPlayer::GetTexture() { + return _texture; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h new file mode 100644 index 0000000000..38f3fe85ae --- /dev/null +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -0,0 +1,175 @@ +// Copyright 2009, 2010 Jan Nedoma +// +// This file is part of Wintermute Engine. +// +// Wintermute Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Wintermute Engine 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Wintermute Engine. If not, see . +////////////////////////////////////////////////////////////////////////// + + +#ifndef WINTERMUTE_VIDTHEORAPLAYER_H +#define WINTERMUTE_VIDTHEORAPLAYER_H + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BImage.h" +//#include + +namespace WinterMute { + +class CVidTheoraPlayer : public CBBase { +private: + enum { THEORA_STATE_NONE = 0, THEORA_STATE_PLAYING = 1, THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; +public: + //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); + + CVidTheoraPlayer(CBGame *inGame); + virtual ~CVidTheoraPlayer(void); + + // Vorbis/Theora structs + /*ogg_sync_state m_OggSyncState; + ogg_page m_OggPage; + ogg_stream_state m_VorbisStreamState; + ogg_stream_state m_TheoraStreamState; + + theora_info m_TheoraInfo; + theora_comment m_TheoraComment; + theora_state m_TheoraState; + + vorbis_info m_VorbisInfo; + vorbis_dsp_state m_VorbisDSPState; + vorbis_block m_VorbisBlock; + vorbis_comment m_VorbisComment;*/ + + int _theoraStreams; + int _vorbisStreams; + + //ogg_int64_t m_AudiobufGranulepos; //time position of last sample + + + // external objects + CBFile *_file; + char *_filename; + + //CBSoundTheora *_sound; + //ogg_int16_t *_audioBuf; + int _audioBufSize; + int _audioBufFill; + + CBSurface *_texture; + //CVidSubtitler *_subtitler; + + // control methods + HRESULT Initialize(char *Filename, char *SubtitleFile = NULL); + HRESULT InitializeSimple(); + HRESULT Update(); + HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); + HRESULT Stop(); + HRESULT Display(uint32 Alpha = 0xFFFFFFFF); + //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + + HRESULT Pause(); + HRESULT Resume(); + + bool IsPlaying() { + return _state == THEORA_STATE_PLAYING; + }; + bool IsFinished() { + return _state == THEORA_STATE_FINISHED; + }; + bool IsPaused() { + return _state == THEORA_STATE_PAUSED; + }; + + float GetMovieTime(); + int GetMovieFrame(); + + CBSurface *GetTexture(); + + int _state; + uint32 _startTime; + + int _savedState; + uint32 _savedPos; + + + // alpha related + CBImage *_alphaImage; + char *_alphaFilename; + HRESULT SetAlphaImage(const char *Filename); + __inline byte GetAlphaAt(int X, int Y); + + HRESULT SeekToTime(uint32 Time); + + + void Cleanup(); + HRESULT ResetStream(); + + // video properties + TVideoPlayback m_PlaybackType; + int _posX; + int _posY; + float _playZoom; + int _volume; + + bool _looping; + bool _dontDropFrames; + bool _freezeGame; + uint32 _currentTime; + + +private: + // data streaming + //int BufferData(ogg_sync_state *OggSyncState); + //int StreamInData(); + + + // lookup tables + unsigned int _yTable[256]; + unsigned int _bUTable[256]; + unsigned int _gUTable[256]; + unsigned int _gVTable[256]; + unsigned int _rVTable[256]; + + void GenLookupTables(); + + + // seeking support + bool _seekingKeyframe; + float _timeOffset; + + bool _frameRendered; + + + // decoding + void DecodeVorbis(); + void DecodeTheora(); + + bool _audioFrameReady; + bool _videoFrameReady; + float _videobufTime; + + HRESULT WriteAudio(); + HRESULT WriteVideo(); + + bool _playbackStarted; + + // helpers + void SetDefaults(); + +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 84601ca89ef05807a86b10f6c0412a60c6b079e6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 02:41:18 +0200 Subject: WINTERMUTE: Move the file-related classes into Base/file --- engines/wintermute/Base/BDiskFile.cpp | 230 ------------------------ engines/wintermute/Base/BDiskFile.h | 59 ------ engines/wintermute/Base/BFile.cpp | 69 ------- engines/wintermute/Base/BFile.h | 65 ------- engines/wintermute/Base/BFileManager.cpp | 8 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BPkgFile.cpp | 161 ----------------- engines/wintermute/Base/BPkgFile.h | 64 ------- engines/wintermute/Base/BResourceFile.cpp | 103 ----------- engines/wintermute/Base/BResourceFile.h | 50 ------ engines/wintermute/Base/BSaveThumbFile.cpp | 146 --------------- engines/wintermute/Base/BSaveThumbFile.h | 51 ------ engines/wintermute/Base/BSoundBuffer.cpp | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 2 +- engines/wintermute/Base/file/BDiskFile.cpp | 230 ++++++++++++++++++++++++ engines/wintermute/Base/file/BDiskFile.h | 59 ++++++ engines/wintermute/Base/file/BFile.cpp | 69 +++++++ engines/wintermute/Base/file/BFile.h | 65 +++++++ engines/wintermute/Base/file/BPkgFile.cpp | 161 +++++++++++++++++ engines/wintermute/Base/file/BPkgFile.h | 64 +++++++ engines/wintermute/Base/file/BResourceFile.cpp | 103 +++++++++++ engines/wintermute/Base/file/BResourceFile.h | 50 ++++++ engines/wintermute/Base/file/BSaveThumbFile.cpp | 146 +++++++++++++++ engines/wintermute/Base/file/BSaveThumbFile.h | 51 ++++++ engines/wintermute/Base/scriptables/SXFile.cpp | 2 +- engines/wintermute/module.mk | 10 +- engines/wintermute/video/VidTheoraPlayer.h | 2 +- 28 files changed, 1013 insertions(+), 1013 deletions(-) delete mode 100644 engines/wintermute/Base/BDiskFile.cpp delete mode 100644 engines/wintermute/Base/BDiskFile.h delete mode 100644 engines/wintermute/Base/BFile.cpp delete mode 100644 engines/wintermute/Base/BFile.h delete mode 100644 engines/wintermute/Base/BPkgFile.cpp delete mode 100644 engines/wintermute/Base/BPkgFile.h delete mode 100644 engines/wintermute/Base/BResourceFile.cpp delete mode 100644 engines/wintermute/Base/BResourceFile.h delete mode 100644 engines/wintermute/Base/BSaveThumbFile.cpp delete mode 100644 engines/wintermute/Base/BSaveThumbFile.h create mode 100644 engines/wintermute/Base/file/BDiskFile.cpp create mode 100644 engines/wintermute/Base/file/BDiskFile.h create mode 100644 engines/wintermute/Base/file/BFile.cpp create mode 100644 engines/wintermute/Base/file/BFile.h create mode 100644 engines/wintermute/Base/file/BPkgFile.cpp create mode 100644 engines/wintermute/Base/file/BPkgFile.h create mode 100644 engines/wintermute/Base/file/BResourceFile.cpp create mode 100644 engines/wintermute/Base/file/BResourceFile.h create mode 100644 engines/wintermute/Base/file/BSaveThumbFile.cpp create mode 100644 engines/wintermute/Base/file/BSaveThumbFile.h (limited to 'engines') diff --git a/engines/wintermute/Base/BDiskFile.cpp b/engines/wintermute/Base/BDiskFile.cpp deleted file mode 100644 index 0d2b41f870..0000000000 --- a/engines/wintermute/Base/BDiskFile.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/Base/BPkgFile.h" -#include "engines/wintermute/Base/BDiskFile.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "common/stream.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { - _file = NULL; - _data = NULL; - _compressed = false; - _prefixSize = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBDiskFile::~CBDiskFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Open(const Common::String &Filename) { - Close(); - - char FullPath[MAX_PATH]; - - for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { - sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); - CorrectSlashes(FullPath); - //_file = Common::createFileStream(FullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { - _file = tempFile; - } else { - delete tempFile; - } - /* if (_file != NULL) { - error("Tried to open %s, but failed", Filename.c_str()); - break; - }*/ - } - - // if we didn't find it in search paths, try to open directly - if (!_file) { - strcpy(FullPath, Filename.c_str()); - CorrectSlashes(FullPath); - //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); - //_file = Common::createFileStream(FullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { - _file = tempFile; - } else { - delete tempFile; - } - } - - if (_file) { - uint32 magic1, magic2; - magic1 = _file->readUint32LE(); - magic2 = _file->readUint32LE(); - - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; - - if (_compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = _file->readUint32LE(); - CompSize = _file->readUint32LE(); - UncompSize = _file->readUint32LE(); - - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); - Close(); - return E_FAIL; - } - - _data = new byte[UncompSize]; - if (!_data) { - Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); - delete [] CompBuffer; - Close(); - return E_FAIL; - } - _file->seek(DataOffset + _prefixSize, SEEK_SET); - _file->read(CompBuffer, CompSize); - - if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { - Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); - delete [] CompBuffer; - Close(); - return E_FAIL; - } - - delete [] CompBuffer; - _size = UncompSize; - _pos = 0; - delete _file; - _file = NULL; - } else { - _pos = 0; - _file->seek(0, SEEK_END); - _size = _file->pos() - _prefixSize; - _file->seek(_prefixSize, SEEK_SET); - } - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Close() { - if (_file) { - delete _file; - } - _file = NULL; - _pos = 0; - _size = 0; - - delete[] _data; - _data = NULL; - - _compressed = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { - if (_compressed) { - memcpy(Buffer, _data + _pos, Size); - _pos += Size; - return S_OK; - } else { - - if (_file) { - size_t count = _file->read(Buffer, Size); - _pos += count; - return S_OK; - } else return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { - // TODO: Should this really need to use uint32? - if (_compressed) { - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - return S_OK; - } else { - if (!_file) return E_FAIL; - int ret = 1; - - switch (Origin) { - case SEEK_TO_BEGIN: - ret = _file->seek(_prefixSize + Pos, SEEK_SET); - break; - case SEEK_TO_END: - ret = _file->seek(Pos, SEEK_END); - break; - case SEEK_TO_CURRENT: - ret = _file->seek(Pos, SEEK_CUR); - break; - } - if (ret == 0) { - _pos = _file->pos() - _prefixSize; - return S_OK; - } else return E_FAIL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBDiskFile::CorrectSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDiskFile.h b/engines/wintermute/Base/BDiskFile.h deleted file mode 100644 index 967e902dff..0000000000 --- a/engines/wintermute/Base/BDiskFile.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H - - -#include "engines/wintermute/Base/BFile.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBDiskFile : public CBFile { -public: - CBDiskFile(CBGame *inGame); - virtual ~CBDiskFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - void CorrectSlashes(char *fileName); - Common::SeekableReadStream *_file; - byte *_data; - bool _compressed; - uint32 _prefixSize; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFile.cpp b/engines/wintermute/Base/BFile.cpp deleted file mode 100644 index ba75023c7f..0000000000 --- a/engines/wintermute/Base/BFile.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFile.h" -#include "common/memstream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFile::IsEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = GetPos(); - Seek(0); - byte *data = new byte[GetSize()]; - Read(data, GetSize()); - Seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFile.h b/engines/wintermute/Base/BFile.h deleted file mode 100644 index ba20975b46..0000000000 --- a/engines/wintermute/Base/BFile.h +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "common/str.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBFile : public CBBase { -public: - uint32 _pos; - uint32 _size; - virtual uint32 GetSize() { - return _size; - }; - virtual uint32 GetPos() { - return _pos; - }; - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; - virtual HRESULT Read(void *Buffer, uint32 Size) = 0; - virtual HRESULT Close() = 0; - virtual HRESULT Open(const Common::String &Filename) = 0; - virtual bool IsEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 8a8de885c0..06130092ac 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -32,11 +32,11 @@ #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/Base/BDiskFile.h" -#include "engines/wintermute/Base/BResourceFile.h" -#include "engines/wintermute/Base/BSaveThumbFile.h" +#include "engines/wintermute/Base/file/BDiskFile.h" +#include "engines/wintermute/Base/file/BResourceFile.h" +#include "engines/wintermute/Base/file/BSaveThumbFile.h" #include "engines/wintermute/Base/BFileEntry.h" -#include "engines/wintermute/Base/BPkgFile.h" +#include "engines/wintermute/Base/file/BPkgFile.h" #include "engines/wintermute/Base/BPackage.h" #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/Base/BGame.h" diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 003cada4c7..6ec9382a63 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -29,7 +29,7 @@ //#include //#include FT_FREETYPE_H #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFontTT.h" #include "engines/wintermute/FontGlyphCache.h" #include "engines/wintermute/utils/PathUtil.h" diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7febffbab5..287092e02d 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BFontTT.h" #include "engines/wintermute/Base/BFontStorage.h" diff --git a/engines/wintermute/Base/BPkgFile.cpp b/engines/wintermute/Base/BPkgFile.cpp deleted file mode 100644 index a48ccf7555..0000000000 --- a/engines/wintermute/Base/BPkgFile.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BPackage.h" -#include "engines/wintermute/Base/BPkgFile.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "common/util.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { - _fileEntry = NULL; - _file = NULL; - _compressed = false; - -} - -////////////////////////////////////////////////////////////////////////// -CBPkgFile::~CBPkgFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Open(const Common::String &Filename) { - Close(); - - char fileName[MAX_PATH]; - strcpy(fileName, Filename.c_str()); - - // correct slashes - for (uint32 i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '/') fileName[i] = '\\'; - } - - _fileEntry = Game->_fileManager->GetPackageEntry(fileName); - if (!_fileEntry) return E_FAIL; - - _file = _fileEntry->_package->GetFilePointer(); - if (!_file) return E_FAIL; - - // TODO: Cleanup - _compressed = (_fileEntry->_compressedLength != 0); - _size = _fileEntry->_length; - - if (_compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. - _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); - } else { - _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); - } - - SeekToPos(0); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Close() { - if (_fileEntry) { - _fileEntry->_package->CloseFilePointer(_file); - _fileEntry = NULL; - } - _file = NULL; - - // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { - if (!_fileEntry) return E_FAIL; - - HRESULT ret = S_OK; - - if (_pos + Size > _size) { - Size = _size - _pos; - if (Size == 0) return E_FAIL; - } - - ret = _file->read(Buffer, Size); - - _pos += Size; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { - if (!_fileEntry) return E_FAIL; - - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - - return SeekToPos(NewPos); -} - - -#define STREAM_BUFFER_SIZE 4096 -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { - HRESULT ret = S_OK; - - // seek compressed stream to NewPos - _pos = NewPos; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPkgFile.h b/engines/wintermute/Base/BPkgFile.h deleted file mode 100644 index e2817f8a00..0000000000 --- a/engines/wintermute/Base/BPkgFile.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPKGFILE_H -#define WINTERMUTE_BPKGFILE_H - - -#include "engines/wintermute/Base/BFile.h" -#include "engines/wintermute/Base/BFileEntry.h" -#include // Added by ClassView - -#define COMPRESSED_BUFFER_SIZE 4096 - -namespace Common { -class SeekableReadStream; -class File; -} - -namespace WinterMute { - -class CBPkgFile : public CBFile { -public: - CBPkgFile(CBGame *inGame); - virtual ~CBPkgFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - bool _inflateInit; - HRESULT SeekToPos(uint32 NewPos); - bool _compressed; - CBFileEntry *_fileEntry; - Common::SeekableReadStream *_file; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BResourceFile.cpp b/engines/wintermute/Base/BResourceFile.cpp deleted file mode 100644 index 805868e5c8..0000000000 --- a/engines/wintermute/Base/BResourceFile.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BResourceFile.h" -#include "engines/wintermute/Base/BResources.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::~CBResourceFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Open(const Common::String &Filename) { - Close(); - - if (CBResources::GetFile(Filename.c_str(), _data, _size)) { - _pos = 0; - return S_OK; - } - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Close() { - _data = NULL; - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; - - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { - if (!_data) return E_FAIL; - - int32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BResourceFile.h b/engines/wintermute/Base/BResourceFile.h deleted file mode 100644 index 721134dd84..0000000000 --- a/engines/wintermute/Base/BResourceFile.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCEFILE_H -#define WINTERMUTE_BRESOURCEFILE_H - -#include "engines/wintermute/Base/BFile.h" - -namespace WinterMute { - -class CBResourceFile : public CBFile { -public: - CBResourceFile(CBGame *inGame); - virtual ~CBResourceFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSaveThumbFile.cpp b/engines/wintermute/Base/BSaveThumbFile.cpp deleted file mode 100644 index 66f1e8a95f..0000000000 --- a/engines/wintermute/Base/BSaveThumbFile.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSaveThumbFile.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { - Close(); - - if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; - - char *TempFilename = new char[strlen(Filename.c_str()) - 8]; - strcpy(TempFilename, Filename.c_str() + 9); - for (int i = 0; i < strlen(TempFilename); i++) { - if (TempFilename[i] < '0' || TempFilename[i] > '9') { - TempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int Slot = atoi(TempFilename); - delete [] TempFilename; - - char SlotFilename[MAX_PATH + 1]; - Game->GetSaveSlotFilename(Slot, SlotFilename); - CBPersistMgr *pm = new CBPersistMgr(Game); - if (!pm) return E_FAIL; - - Game->_dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(SlotFilename))) { - Game->_dEBUG_AbsolutePathWarning = true; - delete pm; - return E_FAIL; - } - Game->_dEBUG_AbsolutePathWarning = true; - - HRESULT res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = S_OK; - } else res = E_FAIL; - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; - - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { - if (!_data) return E_FAIL; - - uint32 NewPos = 0; - - switch (Origin) { - case SEEK_TO_BEGIN: - NewPos = Pos; - break; - case SEEK_TO_END: - NewPos = _size + Pos; - break; - case SEEK_TO_CURRENT: - NewPos = _pos + Pos; - break; - } - - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbFile.h b/engines/wintermute/Base/BSaveThumbFile.h deleted file mode 100644 index 71bdb46431..0000000000 --- a/engines/wintermute/Base/BSaveThumbFile.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H - - -#include "engines/wintermute/Base/BFile.h" - -namespace WinterMute { - -class CBSaveThumbFile : public CBFile { -public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 2a3daf144a..dd269d5b4e 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/Base/BSoundBuffer.h" diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index e4fc48d1e3..166fbc171b 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BRenderSDL.h" diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp new file mode 100644 index 0000000000..b807925772 --- /dev/null +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -0,0 +1,230 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Base/file/BPkgFile.h" +#include "engines/wintermute/Base/file/BDiskFile.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "common/stream.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { + _file = NULL; + _data = NULL; + _compressed = false; + _prefixSize = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBDiskFile::~CBDiskFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Open(const Common::String &Filename) { + Close(); + + char FullPath[MAX_PATH]; + + for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { + sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); + CorrectSlashes(FullPath); + //_file = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(FullPath)) { + _file = tempFile; + } else { + delete tempFile; + } + /* if (_file != NULL) { + error("Tried to open %s, but failed", Filename.c_str()); + break; + }*/ + } + + // if we didn't find it in search paths, try to open directly + if (!_file) { + strcpy(FullPath, Filename.c_str()); + CorrectSlashes(FullPath); + //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); + //_file = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(FullPath)) { + _file = tempFile; + } else { + delete tempFile; + } + } + + if (_file) { + uint32 magic1, magic2; + magic1 = _file->readUint32LE(); + magic2 = _file->readUint32LE(); + + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; + + if (_compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = _file->readUint32LE(); + CompSize = _file->readUint32LE(); + UncompSize = _file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); + Close(); + return E_FAIL; + } + + _data = new byte[UncompSize]; + if (!_data) { + Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + _file->seek(DataOffset + _prefixSize, SEEK_SET); + _file->read(CompBuffer, CompSize); + + if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { + Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); + delete [] CompBuffer; + Close(); + return E_FAIL; + } + + delete [] CompBuffer; + _size = UncompSize; + _pos = 0; + delete _file; + _file = NULL; + } else { + _pos = 0; + _file->seek(0, SEEK_END); + _size = _file->pos() - _prefixSize; + _file->seek(_prefixSize, SEEK_SET); + } + + return S_OK; + } else return E_FAIL; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Close() { + if (_file) { + delete _file; + } + _file = NULL; + _pos = 0; + _size = 0; + + delete[] _data; + _data = NULL; + + _compressed = false; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { + if (_compressed) { + memcpy(Buffer, _data + _pos, Size); + _pos += Size; + return S_OK; + } else { + + if (_file) { + size_t count = _file->read(Buffer, Size); + _pos += count; + return S_OK; + } else return E_FAIL; + } +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { + // TODO: Should this really need to use uint32? + if (_compressed) { + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + return S_OK; + } else { + if (!_file) return E_FAIL; + int ret = 1; + + switch (Origin) { + case SEEK_TO_BEGIN: + ret = _file->seek(_prefixSize + Pos, SEEK_SET); + break; + case SEEK_TO_END: + ret = _file->seek(Pos, SEEK_END); + break; + case SEEK_TO_CURRENT: + ret = _file->seek(Pos, SEEK_CUR); + break; + } + if (ret == 0) { + _pos = _file->pos() - _prefixSize; + return S_OK; + } else return E_FAIL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBDiskFile::CorrectSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BDiskFile.h b/engines/wintermute/Base/file/BDiskFile.h new file mode 100644 index 0000000000..89fd81b858 --- /dev/null +++ b/engines/wintermute/Base/file/BDiskFile.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + + +#include "engines/wintermute/Base/file/BFile.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBDiskFile : public CBFile { +public: + CBDiskFile(CBGame *inGame); + virtual ~CBDiskFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + void CorrectSlashes(char *fileName); + Common::SeekableReadStream *_file; + byte *_data; + bool _compressed; + uint32 _prefixSize; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/file/BFile.cpp b/engines/wintermute/Base/file/BFile.cpp new file mode 100644 index 0000000000..f3a37614a3 --- /dev/null +++ b/engines/wintermute/Base/file/BFile.cpp @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/file/BFile.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::IsEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = GetPos(); + Seek(0); + byte *data = new byte[GetSize()]; + Read(data, GetSize()); + Seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h new file mode 100644 index 0000000000..ba20975b46 --- /dev/null +++ b/engines/wintermute/Base/file/BFile.h @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "common/str.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +public: + uint32 _pos; + uint32 _size; + virtual uint32 GetSize() { + return _size; + }; + virtual uint32 GetPos() { + return _pos; + }; + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; + virtual HRESULT Read(void *Buffer, uint32 Size) = 0; + virtual HRESULT Close() = 0; + virtual HRESULT Open(const Common::String &Filename) = 0; + virtual bool IsEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp new file mode 100644 index 0000000000..d1802f36a9 --- /dev/null +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -0,0 +1,161 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BPackage.h" +#include "engines/wintermute/Base/file/BPkgFile.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "common/util.h" +#include "common/file.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { + _fileEntry = NULL; + _file = NULL; + _compressed = false; + +} + +////////////////////////////////////////////////////////////////////////// +CBPkgFile::~CBPkgFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Open(const Common::String &Filename) { + Close(); + + char fileName[MAX_PATH]; + strcpy(fileName, Filename.c_str()); + + // correct slashes + for (uint32 i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '/') fileName[i] = '\\'; + } + + _fileEntry = Game->_fileManager->GetPackageEntry(fileName); + if (!_fileEntry) return E_FAIL; + + _file = _fileEntry->_package->GetFilePointer(); + if (!_file) return E_FAIL; + + // TODO: Cleanup + _compressed = (_fileEntry->_compressedLength != 0); + _size = _fileEntry->_length; + + if (_compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + } else { + _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); + } + + SeekToPos(0); + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Close() { + if (_fileEntry) { + _fileEntry->_package->CloseFilePointer(_file); + _fileEntry = NULL; + } + _file = NULL; + + // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { + if (!_fileEntry) return E_FAIL; + + HRESULT ret = S_OK; + + if (_pos + Size > _size) { + Size = _size - _pos; + if (Size == 0) return E_FAIL; + } + + ret = _file->read(Buffer, Size); + + _pos += Size; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { + if (!_fileEntry) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + + return SeekToPos(NewPos); +} + + +#define STREAM_BUFFER_SIZE 4096 +////////////////////////////////////////////////////////////////////////// +HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { + HRESULT ret = S_OK; + + // seek compressed stream to NewPos + _pos = NewPos; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BPkgFile.h b/engines/wintermute/Base/file/BPkgFile.h new file mode 100644 index 0000000000..e4acdf1eb9 --- /dev/null +++ b/engines/wintermute/Base/file/BPkgFile.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPKGFILE_H +#define WINTERMUTE_BPKGFILE_H + + +#include "engines/wintermute/Base/file/BFile.h" +#include "engines/wintermute/Base/BFileEntry.h" +#include // Added by ClassView + +#define COMPRESSED_BUFFER_SIZE 4096 + +namespace Common { +class SeekableReadStream; +class File; +} + +namespace WinterMute { + +class CBPkgFile : public CBFile { +public: + CBPkgFile(CBGame *inGame); + virtual ~CBPkgFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + bool _inflateInit; + HRESULT SeekToPos(uint32 NewPos); + bool _compressed; + CBFileEntry *_fileEntry; + Common::SeekableReadStream *_file; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/file/BResourceFile.cpp b/engines/wintermute/Base/file/BResourceFile.cpp new file mode 100644 index 0000000000..8ec47f72c3 --- /dev/null +++ b/engines/wintermute/Base/file/BResourceFile.cpp @@ -0,0 +1,103 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/file/BResourceFile.h" +#include "engines/wintermute/Base/BResources.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBResourceFile::~CBResourceFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Open(const Common::String &Filename) { + Close(); + + if (CBResources::GetFile(Filename.c_str(), _data, _size)) { + _pos = 0; + return S_OK; + } + return E_FAIL; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Close() { + _data = NULL; + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { + if (!_data || _pos + Size > _size) return E_FAIL; + + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { + if (!_data) return E_FAIL; + + int32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BResourceFile.h b/engines/wintermute/Base/file/BResourceFile.h new file mode 100644 index 0000000000..77d8b629b1 --- /dev/null +++ b/engines/wintermute/Base/file/BResourceFile.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCEFILE_H +#define WINTERMUTE_BRESOURCEFILE_H + +#include "engines/wintermute/Base/file/BFile.h" + +namespace WinterMute { + +class CBResourceFile : public CBFile { +public: + CBResourceFile(CBGame *inGame); + virtual ~CBResourceFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp new file mode 100644 index 0000000000..357a9606c7 --- /dev/null +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -0,0 +1,146 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/file/BSaveThumbFile.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + Close(); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { + Close(); + + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; + + char *TempFilename = new char[strlen(Filename.c_str()) - 8]; + strcpy(TempFilename, Filename.c_str() + 9); + for (int i = 0; i < strlen(TempFilename); i++) { + if (TempFilename[i] < '0' || TempFilename[i] > '9') { + TempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int Slot = atoi(TempFilename); + delete [] TempFilename; + + char SlotFilename[MAX_PATH + 1]; + Game->GetSaveSlotFilename(Slot, SlotFilename); + CBPersistMgr *pm = new CBPersistMgr(Game); + if (!pm) return E_FAIL; + + Game->_dEBUG_AbsolutePathWarning = false; + if (FAILED(pm->InitLoad(SlotFilename))) { + Game->_dEBUG_AbsolutePathWarning = true; + delete pm; + return E_FAIL; + } + Game->_dEBUG_AbsolutePathWarning = true; + + HRESULT res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = S_OK; + } else res = E_FAIL; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { + if (!_data || _pos + Size > _size) return E_FAIL; + + memcpy(Buffer, (byte *)_data + _pos, Size); + _pos += Size; + + return S_OK; +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { + if (!_data) return E_FAIL; + + uint32 NewPos = 0; + + switch (Origin) { + case SEEK_TO_BEGIN: + NewPos = Pos; + break; + case SEEK_TO_END: + NewPos = _size + Pos; + break; + case SEEK_TO_CURRENT: + NewPos = _pos + Pos; + break; + } + + if (NewPos < 0 || NewPos > _size) return E_FAIL; + else _pos = NewPos; + + return S_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h new file mode 100644 index 0000000000..0531d6a873 --- /dev/null +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/Base/file/BFile.h" + +namespace WinterMute { + +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Close(); + virtual HRESULT Open(const Common::String &Filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 7761246ed6..ebdb436235 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/scriptables/SXFile.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 59caef82b1..47c41be5cc 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -40,13 +40,16 @@ MODULE_OBJS := \ Base/scriptables/SXMemBuffer.o \ Base/scriptables/SXStore.o \ Base/scriptables/SXString.o \ + Base/file/BDiskFile.o \ + Base/file/BFile.o \ + Base/file/BResourceFile.o \ + Base/file/BSaveThumbFile.o \ + Base/file/BPkgFile.o \ Base/BActiveRect.o \ Base/BBase.o \ Base/BDebugger.o \ - Base/BDiskFile.o \ Base/BDynBuffer.o \ Base/BFader.o \ - Base/BFile.o \ Base/BFileEntry.o \ Base/BFileManager.o \ Base/BGame.o \ @@ -62,7 +65,6 @@ MODULE_OBJS := \ Base/BPackage.o \ Base/BParser.o \ Base/BPersistMgr.o \ - Base/BPkgFile.o \ Base/BPoint.o \ Base/BQuickMsg.o \ Base/BRegion.o \ @@ -70,8 +72,6 @@ MODULE_OBJS := \ Base/BRenderer.o \ Base/BRenderSDL.o \ Base/BResources.o \ - Base/BResourceFile.o \ - Base/BSaveThumbFile.o \ Base/BSaveThumbHelper.o \ Base/BScriptable.o \ Base/BScriptHolder.o \ diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 38f3fe85ae..9766988656 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -21,7 +21,7 @@ #define WINTERMUTE_VIDTHEORAPLAYER_H #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BFile.h" +#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BSurface.h" #include "engines/wintermute/Base/BImage.h" //#include -- cgit v1.2.3 From 5fde51cd2375c4155ca5117a557bba4188628c16 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 02:44:01 +0200 Subject: WINTERMUTE: Protect CBFile's private members. --- engines/wintermute/Base/file/BFile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index ba20975b46..bfabb9dfb9 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -40,9 +40,10 @@ class SeekableReadStream; namespace WinterMute { class CBFile : public CBBase { -public: +protected: uint32 _pos; uint32 _size; +public: virtual uint32 GetSize() { return _size; }; -- cgit v1.2.3 From afe556742110ac477115083bcd4aeec2f9482b9f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 02:58:38 +0200 Subject: WINTERMUTE: Start refactoring the file-files in Base. --- engines/wintermute/Base/BFileManager.cpp | 10 +++--- engines/wintermute/Base/BGame.cpp | 4 +-- engines/wintermute/Base/file/BDiskFile.cpp | 38 ++++++++++---------- engines/wintermute/Base/file/BDiskFile.h | 8 ++--- engines/wintermute/Base/file/BFile.cpp | 8 ++--- engines/wintermute/Base/file/BFile.h | 10 +++--- engines/wintermute/Base/file/BPkgFile.cpp | 20 +++++------ engines/wintermute/Base/file/BPkgFile.h | 8 ++--- engines/wintermute/Base/file/BResourceFile.cpp | 28 +++++++-------- engines/wintermute/Base/file/BSaveThumbFile.cpp | 48 ++++++++++++------------- engines/wintermute/Base/scriptables/SXFile.cpp | 4 +-- 11 files changed, 93 insertions(+), 93 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 06130092ac..8ba77b90b4 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -136,22 +136,22 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must */ - buffer = new byte[File->GetSize() + 1]; + buffer = new byte[File->getSize() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->GetSize() + 1); + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->getSize() + 1); CloseFile(File); return NULL; } - if (FAILED(File->Read(buffer, File->GetSize()))) { + if (FAILED(File->Read(buffer, File->getSize()))) { Game->LOG(0, "Error reading file '%s'", Filename); CloseFile(File); delete [] buffer; return NULL; }; - buffer[File->GetSize()] = '\0'; - if (Size != NULL) *Size = File->GetSize(); + buffer[File->getSize()] = '\0'; + if (Size != NULL) *Size = File->getSize(); CloseFile(File); return buffer; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 287092e02d..9b840cd273 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -2079,8 +2079,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS byte Buf[1024]; int BytesRead = 0; - while (BytesRead < File->GetSize()) { - int BufSize = MIN((uint32)1024, File->GetSize() - BytesRead); + while (BytesRead < File->getSize()) { + int BufSize = MIN((uint32)1024, File->getSize() - BytesRead); BytesRead += BufSize; File->Read(Buf, BufSize); diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index b807925772..8540829f09 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -60,7 +60,7 @@ HRESULT CBDiskFile::Open(const Common::String &Filename) { for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); - CorrectSlashes(FullPath); + correctSlashes(FullPath); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if (tempFile->open(FullPath)) { @@ -77,7 +77,7 @@ HRESULT CBDiskFile::Open(const Common::String &Filename) { // if we didn't find it in search paths, try to open directly if (!_file) { strcpy(FullPath, Filename.c_str()); - CorrectSlashes(FullPath); + correctSlashes(FullPath); //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); @@ -161,15 +161,15 @@ HRESULT CBDiskFile::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { +HRESULT CBDiskFile::Read(void *buffer, uint32 size) { if (_compressed) { - memcpy(Buffer, _data + _pos, Size); - _pos += Size; + memcpy(buffer, _data + _pos, size); + _pos += size; return S_OK; } else { if (_file) { - size_t count = _file->read(Buffer, Size); + size_t count = _file->read(buffer, size); _pos += count; return S_OK; } else return E_FAIL; @@ -178,39 +178,39 @@ HRESULT CBDiskFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { +HRESULT CBDiskFile::Seek(uint32 pos, TSeek origin) { // TODO: Should this really need to use uint32? if (_compressed) { - uint32 NewPos = 0; + uint32 newPos = 0; - switch (Origin) { + switch (origin) { case SEEK_TO_BEGIN: - NewPos = Pos; + newPos = pos; break; case SEEK_TO_END: - NewPos = _size + Pos; + newPos = _size + pos; break; case SEEK_TO_CURRENT: - NewPos = _pos + Pos; + newPos = _pos + pos; break; } - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; + if (newPos < 0 || newPos > _size) return E_FAIL; + else _pos = newPos; return S_OK; } else { if (!_file) return E_FAIL; int ret = 1; - switch (Origin) { + switch (origin) { case SEEK_TO_BEGIN: - ret = _file->seek(_prefixSize + Pos, SEEK_SET); + ret = _file->seek(_prefixSize + pos, SEEK_SET); break; case SEEK_TO_END: - ret = _file->seek(Pos, SEEK_END); + ret = _file->seek(pos, SEEK_END); break; case SEEK_TO_CURRENT: - ret = _file->seek(Pos, SEEK_CUR); + ret = _file->seek(pos, SEEK_CUR); break; } if (ret == 0) { @@ -221,7 +221,7 @@ HRESULT CBDiskFile::Seek(uint32 Pos, TSeek Origin) { } ////////////////////////////////////////////////////////////////////////// -void CBDiskFile::CorrectSlashes(char *fileName) { +void CBDiskFile::correctSlashes(char *fileName) { for (size_t i = 0; i < strlen(fileName); i++) { if (fileName[i] == '\\') fileName[i] = '/'; } diff --git a/engines/wintermute/Base/file/BDiskFile.h b/engines/wintermute/Base/file/BDiskFile.h index 89fd81b858..d9e7af548f 100644 --- a/engines/wintermute/Base/file/BDiskFile.h +++ b/engines/wintermute/Base/file/BDiskFile.h @@ -42,12 +42,12 @@ class CBDiskFile : public CBFile { public: CBDiskFile(CBGame *inGame); virtual ~CBDiskFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *buffer, uint32 size); virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); + virtual HRESULT Open(const Common::String &filename); private: - void CorrectSlashes(char *fileName); + void correctSlashes(char *fileName); Common::SeekableReadStream *_file; byte *_data; bool _compressed; diff --git a/engines/wintermute/Base/file/BFile.cpp b/engines/wintermute/Base/file/BFile.cpp index f3a37614a3..6fa7cb84d6 100644 --- a/engines/wintermute/Base/file/BFile.cpp +++ b/engines/wintermute/Base/file/BFile.cpp @@ -56,12 +56,12 @@ bool CBFile::IsEOF() { } Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = GetPos(); + uint32 oldPos = getPos(); Seek(0); - byte *data = new byte[GetSize()]; - Read(data, GetSize()); + byte *data = new byte[getSize()]; + Read(data, getSize()); Seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, GetSize(), DisposeAfterUse::YES); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); return memStream; } diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index bfabb9dfb9..fa6fafcb25 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -44,16 +44,16 @@ protected: uint32 _pos; uint32 _size; public: - virtual uint32 GetSize() { + virtual uint32 getSize() { return _size; }; - virtual uint32 GetPos() { + virtual uint32 getPos() { return _pos; }; - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN) = 0; - virtual HRESULT Read(void *Buffer, uint32 Size) = 0; + virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; + virtual HRESULT Read(void *buffer, uint32 size) = 0; virtual HRESULT Close() = 0; - virtual HRESULT Open(const Common::String &Filename) = 0; + virtual HRESULT Open(const Common::String &filename) = 0; virtual bool IsEOF(); CBFile(CBGame *inGame); virtual ~CBFile(); diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index d1802f36a9..fe04b816d2 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -125,36 +125,36 @@ HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Seek(uint32 Pos, TSeek Origin) { +HRESULT CBPkgFile::Seek(uint32 pos, TSeek origin) { if (!_fileEntry) return E_FAIL; - uint32 NewPos = 0; + uint32 newPos = 0; - switch (Origin) { + switch (origin) { case SEEK_TO_BEGIN: - NewPos = Pos; + newPos = pos; break; case SEEK_TO_END: - NewPos = _size + Pos; + newPos = _size + pos; break; case SEEK_TO_CURRENT: - NewPos = _pos + Pos; + newPos = _pos + pos; break; } - if (NewPos < 0 || NewPos > _size) return E_FAIL; + if (newPos < 0 || newPos > _size) return E_FAIL; - return SeekToPos(NewPos); + return SeekToPos(newPos); } #define STREAM_BUFFER_SIZE 4096 ////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::SeekToPos(uint32 NewPos) { +HRESULT CBPkgFile::SeekToPos(uint32 newPos) { HRESULT ret = S_OK; // seek compressed stream to NewPos - _pos = NewPos; + _pos = newPos; return ret; } diff --git a/engines/wintermute/Base/file/BPkgFile.h b/engines/wintermute/Base/file/BPkgFile.h index e4acdf1eb9..912b351ac8 100644 --- a/engines/wintermute/Base/file/BPkgFile.h +++ b/engines/wintermute/Base/file/BPkgFile.h @@ -47,13 +47,13 @@ class CBPkgFile : public CBFile { public: CBPkgFile(CBGame *inGame); virtual ~CBPkgFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); + virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); + virtual HRESULT Read(void *buffer, uint32 size); virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); + virtual HRESULT Open(const Common::String &filename); private: bool _inflateInit; - HRESULT SeekToPos(uint32 NewPos); + HRESULT SeekToPos(uint32 newPos); bool _compressed; CBFileEntry *_fileEntry; Common::SeekableReadStream *_file; diff --git a/engines/wintermute/Base/file/BResourceFile.cpp b/engines/wintermute/Base/file/BResourceFile.cpp index 8ec47f72c3..9ac93c4f9b 100644 --- a/engines/wintermute/Base/file/BResourceFile.cpp +++ b/engines/wintermute/Base/file/BResourceFile.cpp @@ -45,10 +45,10 @@ CBResourceFile::~CBResourceFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Open(const Common::String &Filename) { +HRESULT CBResourceFile::Open(const Common::String &filename) { Close(); - if (CBResources::GetFile(Filename.c_str(), _data, _size)) { + if (CBResources::GetFile(filename.c_str(), _data, _size)) { _pos = 0; return S_OK; } @@ -66,36 +66,36 @@ HRESULT CBResourceFile::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; +HRESULT CBResourceFile::Read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return E_FAIL; - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Seek(uint32 Pos, TSeek Origin) { +HRESULT CBResourceFile::Seek(uint32 pos, TSeek origin) { if (!_data) return E_FAIL; - int32 NewPos = 0; + int32 newPos = 0; - switch (Origin) { + switch (origin) { case SEEK_TO_BEGIN: - NewPos = Pos; + newPos = pos; break; case SEEK_TO_END: - NewPos = _size + Pos; + newPos = _size + pos; break; case SEEK_TO_CURRENT: - NewPos = _pos + Pos; + newPos = _pos + pos; break; } - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; + if (newPos < 0 || newPos > _size) return E_FAIL; + else _pos = newPos; return S_OK; } diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 357a9606c7..f976b4a00c 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -51,31 +51,31 @@ CBSaveThumbFile::~CBSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Open(const Common::String &Filename) { +HRESULT CBSaveThumbFile::Open(const Common::String &filename) { Close(); - if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) != 0) return E_FAIL; + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return E_FAIL; - char *TempFilename = new char[strlen(Filename.c_str()) - 8]; - strcpy(TempFilename, Filename.c_str() + 9); - for (int i = 0; i < strlen(TempFilename); i++) { - if (TempFilename[i] < '0' || TempFilename[i] > '9') { - TempFilename[i] = '\0'; + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (int i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; break; } } // get slot number from name - int Slot = atoi(TempFilename); - delete [] TempFilename; + int slot = atoi(tempFilename); + delete [] tempFilename; - char SlotFilename[MAX_PATH + 1]; - Game->GetSaveSlotFilename(Slot, SlotFilename); + char slotFilename[MAX_PATH + 1]; + Game->GetSaveSlotFilename(slot, slotFilename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; Game->_dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(SlotFilename))) { + if (FAILED(pm->InitLoad(slotFilename))) { Game->_dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; @@ -109,36 +109,36 @@ HRESULT CBSaveThumbFile::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Read(void *Buffer, uint32 Size) { - if (!_data || _pos + Size > _size) return E_FAIL; +HRESULT CBSaveThumbFile::Read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return E_FAIL; - memcpy(Buffer, (byte *)_data + _pos, Size); - _pos += Size; + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Seek(uint32 Pos, TSeek Origin) { +HRESULT CBSaveThumbFile::Seek(uint32 pos, TSeek origin) { if (!_data) return E_FAIL; - uint32 NewPos = 0; + uint32 newPos = 0; - switch (Origin) { + switch (origin) { case SEEK_TO_BEGIN: - NewPos = Pos; + newPos = pos; break; case SEEK_TO_END: - NewPos = _size + Pos; + newPos = _size + pos; break; case SEEK_TO_CURRENT: - NewPos = _pos + Pos; + newPos = _pos + pos; break; } - if (NewPos < 0 || NewPos > _size) return E_FAIL; - else _pos = NewPos; + if (newPos < 0 || newPos > _size) return E_FAIL; + else _pos = newPos; return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index ebdb436235..e73f244f00 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -652,7 +652,7 @@ HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetPos() { - if (_mode == 1 && _readFile) return _readFile->GetPos(); + if (_mode == 1 && _readFile) return _readFile->getPos(); else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); else return 0; } @@ -666,7 +666,7 @@ bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetLength() { - if (_mode == 1 && _readFile) return _readFile->GetSize(); + if (_mode == 1 && _readFile) return _readFile->getSize(); else if ((_mode == 2 || _mode == 3) && _writeFile) { uint32 CurrentPos = ftell(_writeFile); fseek(_writeFile, 0, SEEK_END); -- cgit v1.2.3 From 4a10bc8b141f575ceb9c4d87563290d2791e3380 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 11:09:22 +0200 Subject: WINTERMUTE: Revamp the file-system to deliver Common::-streams directly --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Base/BFileManager.cpp | 49 +++--- engines/wintermute/Base/BFileManager.h | 8 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 13 +- engines/wintermute/Base/BResources.cpp | 28 ++-- engines/wintermute/Base/BResources.h | 5 +- engines/wintermute/Base/BSoundBuffer.cpp | 2 +- engines/wintermute/Base/BSoundBuffer.h | 4 +- engines/wintermute/Base/BSoundMgr.cpp | 2 +- engines/wintermute/Base/BSprite.cpp | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 4 +- engines/wintermute/Base/BSurfaceStorage.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 2 +- engines/wintermute/Base/file/BDiskFile.cpp | 208 +++++++------------------ engines/wintermute/Base/file/BDiskFile.h | 19 +-- engines/wintermute/Base/file/BFile.h | 1 + engines/wintermute/Base/file/BPkgFile.cpp | 136 ++++------------ engines/wintermute/Base/file/BPkgFile.h | 22 +-- engines/wintermute/Base/file/BResourceFile.cpp | 103 ------------ engines/wintermute/Base/file/BResourceFile.h | 50 ------ engines/wintermute/Base/scriptables/SXFile.cpp | 34 ++-- engines/wintermute/Base/scriptables/SXFile.h | 3 +- engines/wintermute/module.mk | 1 - 25 files changed, 169 insertions(+), 535 deletions(-) delete mode 100644 engines/wintermute/Base/file/BResourceFile.cpp delete mode 100644 engines/wintermute/Base/file/BResourceFile.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 175cc98b38..584504b7c6 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1903,7 +1903,7 @@ char *CAdGame::FindSpeechFile(char *StringID) { for (int i = 0; i < _speechDirs.GetSize(); i++) { sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); - CBFile *File = _fileManager->OpenFile(Ret); + Common::SeekableReadStream *File = _fileManager->OpenFile(Ret); if (File) { _fileManager->CloseFile(File); return Ret; diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 28e5b2cf26..e513d1f3ed 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -251,7 +251,7 @@ HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); - CBFile *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); if (file) { Game->_fileManager->CloseFile(file); } else return S_OK; // no talk def file found diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 8ba77b90b4..ce33e1a13c 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -33,10 +33,10 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/Base/file/BDiskFile.h" -#include "engines/wintermute/Base/file/BResourceFile.h" #include "engines/wintermute/Base/file/BSaveThumbFile.h" #include "engines/wintermute/Base/BFileEntry.h" #include "engines/wintermute/Base/file/BPkgFile.h" +#include "engines/wintermute/Base/BResources.h" #include "engines/wintermute/Base/BPackage.h" #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/Base/BGame.h" @@ -96,7 +96,6 @@ HRESULT CBFileManager::Cleanup() { // close open files for (i = 0; i < _openFiles.GetSize(); i++) { - _openFiles[i]->Close(); delete _openFiles[i]; } _openFiles.RemoveAll(); @@ -121,7 +120,7 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must byte *buffer = NULL; - CBFile *File = OpenFile(Filename); + Common::SeekableReadStream *File = OpenFile(Filename); if (!File) { if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename); return NULL; @@ -136,22 +135,22 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must */ - buffer = new byte[File->getSize() + 1]; + buffer = new byte[File->size() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->getSize() + 1); + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->size() + 1); CloseFile(File); return NULL; } - if (FAILED(File->Read(buffer, File->getSize()))) { + if (File->read(buffer, File->size()) != File->size()) { Game->LOG(0, "Error reading file '%s'", Filename); CloseFile(File); delete [] buffer; return NULL; }; - buffer[File->getSize()] = '\0'; - if (Size != NULL) *Size = File->getSize(); + buffer[File->size()] = '\0'; + if (Size != NULL) *Size = File->size(); CloseFile(File); return buffer; @@ -751,10 +750,10 @@ CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { +Common::SeekableReadStream *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { if (strcmp(Filename, "") == 0) return NULL; //Game->LOG(0, "open file: %s", Filename); -#ifdef __WIN32__ +/*#ifdef __WIN32__ if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { char Drive[_MAX_DRIVE]; _splitpath(Filename, Drive, NULL, NULL, NULL); @@ -762,19 +761,18 @@ CBFile *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); } } -#endif +#endif*/ - CBFile *File = OpenFileRaw(Filename); + Common::SeekableReadStream *File = OpenFileRaw(Filename); if (File) _openFiles.Add(File); return File; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::CloseFile(CBFile *File) { +HRESULT CBFileManager::CloseFile(Common::SeekableReadStream *File) { for (int i = 0; i < _openFiles.GetSize(); i++) { if (_openFiles[i] == File) { - _openFiles[i]->Close(); delete _openFiles[i]; _openFiles.RemoveAt(i); return S_OK; @@ -785,30 +783,29 @@ HRESULT CBFileManager::CloseFile(CBFile *File) { ////////////////////////////////////////////////////////////////////////// -CBFile *CBFileManager::OpenFileRaw(const Common::String &Filename) { +Common::SeekableReadStream *CBFileManager::OpenFileRaw(const Common::String &Filename) { RestoreCurrentDir(); if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile; + if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile->getMemStream(); else { delete SaveThumbFile; return NULL; } } - CBDiskFile *DiskFile = new CBDiskFile(Game); - if (SUCCEEDED(DiskFile->Open(Filename))) return DiskFile; - - delete DiskFile; - CBPkgFile *PkgFile = new CBPkgFile(Game); - if (SUCCEEDED(PkgFile->Open(Filename))) return PkgFile; + Common::SeekableReadStream *ret = NULL; + + ret = openDiskFile(Filename, this); + if (ret) return ret; - delete PkgFile; - CBResourceFile *ResFile = new CBResourceFile(Game); - if (SUCCEEDED(ResFile->Open(Filename))) return ResFile; + ret = openPkgFile(Filename, this); + if (ret) return ret; + + ret = CBResources::getFile(Filename); + if (ret) return ret; - delete ResFile; warning("BFileManager::OpenFileRaw - Failed to open %s", Filename.c_str()); return NULL; } diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index cf0e284cc1..77f99c8570 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -50,9 +50,9 @@ public: HRESULT RestoreCurrentDir(); char *_basePath; bool GetFullPath(const char *Filename, char *Fullname); - CBFile *OpenFileRaw(const Common::String &filename); - HRESULT CloseFile(CBFile *File); - CBFile *OpenFile(const char *Filename, bool AbsPathWarning = true); + Common::SeekableReadStream *OpenFileRaw(const Common::String &filename); + HRESULT CloseFile(Common::SeekableReadStream *File); + Common::SeekableReadStream *OpenFile(const char *Filename, bool AbsPathWarning = true); CBFileEntry *GetPackageEntry(const char *Filename); Common::File *OpenSingleFile(const char *Name); Common::File *OpenPackage(const char *Name); @@ -71,7 +71,7 @@ public: CBArray _singlePaths; CBArray _packagePaths; CBArray _packages; - CBArray _openFiles; + CBArray _openFiles; Common::HashMap _files; private: diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 6ec9382a63..e18279a73d 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -611,7 +611,7 @@ HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; warning("BFontTT::InitFont - Not ported yet"); - CBFile *file = Game->_fileManager->OpenFile(_fontFile); + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 9b840cd273..c9b122759d 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1722,7 +1722,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); const char *Filename = Stack->Pop()->GetString(); - CBFile *File = _fileManager->OpenFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); if (!File) Stack->PushBool(false); else { _fileManager->CloseFile(File); @@ -2073,17 +2073,16 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS const char *Filename = Stack->Pop()->GetString(); bool AsHex = Stack->Pop()->GetBool(false); - CBFile *File = _fileManager->OpenFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); if (File) { crc remainder = crc_initialize(); byte Buf[1024]; int BytesRead = 0; - while (BytesRead < File->getSize()) { - int BufSize = MIN((uint32)1024, File->getSize() - BytesRead); - BytesRead += BufSize; + while (BytesRead < File->size()) { + int BufSize = MIN((uint32)1024, (uint32)(File->size() - BytesRead)); + BytesRead += File->read(Buf, BufSize); - File->Read(Buf, BufSize); for (int i = 0; i < BufSize; i++) { remainder = crc_process_byte(Buf[i], remainder); } @@ -3922,7 +3921,7 @@ bool CBGame::IsSaveSlotUsed(int Slot) { char Filename[MAX_PATH + 1]; GetSaveSlotFilename(Slot, Filename); - CBFile *File = _fileManager->OpenFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); if (!File) return false; _fileManager->CloseFile(File); diff --git a/engines/wintermute/Base/BResources.cpp b/engines/wintermute/Base/BResources.cpp index d0714abaf2..3b6d0a264c 100644 --- a/engines/wintermute/Base/BResources.cpp +++ b/engines/wintermute/Base/BResources.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/BResources.h" #include "common/str.h" +#include "common/memstream.h" namespace WinterMute { @@ -2805,26 +2806,15 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; - -////////////////////////////////////////////////////////////////////////// -bool CBResources::GetFile(const char *fileName, byte *&buffer, uint32 &size) { - // better! - if (scumm_stricmp(fileName, "invalid.bmp") == 0) { - buffer = invalid; - size = sizeof(invalid); - return true; - } else if (scumm_stricmp(fileName, "invalid_debug.bmp") == 0) { - buffer = invaliddebug; - size = sizeof(invaliddebug); - return true; - } else if (scumm_stricmp(fileName, "syste_font.bmp") == 0) { - buffer = systemfont; - size = sizeof(systemfont); - return true; +Common::SeekableReadStream *CBResources::getFile(const Common::String& fileName) { + if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); } - - - return false; + return NULL; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BResources.h b/engines/wintermute/Base/BResources.h index 26d92af525..f9a28865b4 100644 --- a/engines/wintermute/Base/BResources.h +++ b/engines/wintermute/Base/BResources.h @@ -29,11 +29,14 @@ #ifndef WINTERMUTE_BRESOURCES_H #define WINTERMUTE_BRESOURCES_H +#include "common/stream.h" +#include "common/str.h" + namespace WinterMute { class CBResources { public: - static bool GetFile(const char *fileName, byte *&buffer, uint32 &size); + static Common::SeekableReadStream *getFile(const Common::String& fileName); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index dd269d5b4e..62a9bd78b6 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -112,7 +112,7 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { return E_FAIL; } - _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES); + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::NO); CBUtils::SetString(&_filename, Filename); return S_OK; diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 5445376555..9fa9dec1cf 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BBase.h" -//#include "bass.h" +#include "common/stream.h" namespace Audio { class SeekableAudioStream; @@ -84,7 +84,7 @@ public: uint32 _loopStart; TSoundType _type; bool _looping; - CBFile *_file; + Common::SeekableReadStream *_file; char *_filename; bool _streamed; int _privateVolume; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 8c98f83dc2..bac53f6b22 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -137,7 +137,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); AnsiString newFile = PathUtil::Combine(path, name + "ogg"); - CBFile *file = Game->_fileManager->OpenFile(newFile.c_str()); + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(newFile.c_str()); if (file) { Filename = newFile.c_str(); Game->_fileManager->CloseFile(file); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 87da65e9d0..f3f35a8364 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -123,7 +123,7 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - CBFile *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); if (!File) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 166fbc171b..f41839a244 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -85,10 +85,10 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); } - CBFile *file = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(Filename); if (!file) return E_FAIL; - imgDecoder->loadStream(*file->getMemStream()); + imgDecoder->loadStream(*file); const Graphics::Surface *surface = imgDecoder->getSurface(); Game->_fileManager->CloseFile(file); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 538b9a2649..1ff31e1338 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -105,7 +105,7 @@ CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, b } } - CBFile *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); if (!File) { if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); if (Game->_dEBUG_DebugMode) diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index e37d0f1373..29d51c063d 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -123,7 +123,7 @@ HRESULT CPartEmitter::AddSprite(const char *Filename) { } // check if file exists - CBFile *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); if (!File) { Game->LOG(0, "Sprite '%s' not found", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index 8540829f09..57e9a0a0f0 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -33,198 +33,98 @@ #include "engines/wintermute/Base/file/BDiskFile.h" #include "engines/wintermute/Base/BFileManager.h" #include "common/stream.h" +#include "common/memstream.h" #include "common/file.h" +#include "common/zlib.h" namespace WinterMute { -////////////////////////////////////////////////////////////////////////// -CBDiskFile::CBDiskFile(CBGame *inGame): CBFile(inGame) { - _file = NULL; - _data = NULL; - _compressed = false; - _prefixSize = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBDiskFile::~CBDiskFile() { - Close(); +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } } - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Open(const Common::String &Filename) { - Close(); - +Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager) { char FullPath[MAX_PATH]; + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; - for (int i = 0; i < Game->_fileManager->_singlePaths.GetSize(); i++) { - sprintf(FullPath, "%s%s", Game->_fileManager->_singlePaths[i], Filename.c_str()); + for (int i = 0; i < fileManager->_singlePaths.GetSize(); i++) { + sprintf(FullPath, "%s%s", fileManager->_singlePaths[i], Filename.c_str()); correctSlashes(FullPath); - //_file = Common::createFileStream(FullPath); Common::File *tempFile = new Common::File(); if (tempFile->open(FullPath)) { - _file = tempFile; + file = tempFile; } else { delete tempFile; } - /* if (_file != NULL) { - error("Tried to open %s, but failed", Filename.c_str()); - break; - }*/ } - + // if we didn't find it in search paths, try to open directly - if (!_file) { + if (!file) { strcpy(FullPath, Filename.c_str()); correctSlashes(FullPath); - //error("Tried to open %s, TODO: add SearchMan-support", Filename.c_str()); - //_file = Common::createFileStream(FullPath); + Common::File *tempFile = new Common::File(); if (tempFile->open(FullPath)) { - _file = tempFile; + file = tempFile; } else { delete tempFile; } } - - if (_file) { + + if (file) { uint32 magic1, magic2; - magic1 = _file->readUint32LE(); - magic2 = _file->readUint32LE(); - - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) _compressed = true; - - if (_compressed) { + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + + if (compressed) { uint32 DataOffset, CompSize, UncompSize; - DataOffset = _file->readUint32LE(); - CompSize = _file->readUint32LE(); - UncompSize = _file->readUint32LE(); - + DataOffset = file->readUint32LE(); + CompSize = file->readUint32LE(); + UncompSize = file->readUint32LE(); + byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { - Game->LOG(0, "Error allocating memory for compressed file '%s'", Filename.c_str()); - Close(); - return E_FAIL; + error("Error allocating memory for compressed file '%s'", Filename.c_str()); + delete file; + return NULL; } - - _data = new byte[UncompSize]; - if (!_data) { - Game->LOG(0, "Error allocating buffer for file '%s'", Filename.c_str()); + + byte *data = new byte[UncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", Filename.c_str()); delete [] CompBuffer; - Close(); - return E_FAIL; + delete file; + return NULL; } - _file->seek(DataOffset + _prefixSize, SEEK_SET); - _file->read(CompBuffer, CompSize); - - if (uncompress(_data, (uLongf *)&UncompSize, CompBuffer, CompSize) != Z_OK) { - Game->LOG(0, "Error uncompressing file '%s'", Filename.c_str()); + file->seek(DataOffset + prefixSize, SEEK_SET); + file->read(CompBuffer, CompSize); + + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + error("Error uncompressing file '%s'", Filename.c_str()); delete [] CompBuffer; - Close(); - return E_FAIL; + delete file; + return NULL; } - + delete [] CompBuffer; - _size = UncompSize; - _pos = 0; - delete _file; - _file = NULL; + + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; } else { - _pos = 0; - _file->seek(0, SEEK_END); - _size = _file->pos() - _prefixSize; - _file->seek(_prefixSize, SEEK_SET); - } - - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Close() { - if (_file) { - delete _file; - } - _file = NULL; - _pos = 0; - _size = 0; - - delete[] _data; - _data = NULL; - - _compressed = false; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Read(void *buffer, uint32 size) { - if (_compressed) { - memcpy(buffer, _data + _pos, size); - _pos += size; - return S_OK; - } else { - - if (_file) { - size_t count = _file->read(buffer, size); - _pos += count; - return S_OK; - } else return E_FAIL; - } -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBDiskFile::Seek(uint32 pos, TSeek origin) { - // TODO: Should this really need to use uint32? - if (_compressed) { - uint32 newPos = 0; - - switch (origin) { - case SEEK_TO_BEGIN: - newPos = pos; - break; - case SEEK_TO_END: - newPos = _size + pos; - break; - case SEEK_TO_CURRENT: - newPos = _pos + pos; - break; - } - - if (newPos < 0 || newPos > _size) return E_FAIL; - else _pos = newPos; - return S_OK; - } else { - if (!_file) return E_FAIL; - int ret = 1; - - switch (origin) { - case SEEK_TO_BEGIN: - ret = _file->seek(_prefixSize + pos, SEEK_SET); - break; - case SEEK_TO_END: - ret = _file->seek(pos, SEEK_END); - break; - case SEEK_TO_CURRENT: - ret = _file->seek(pos, SEEK_CUR); - break; + return file; } - if (ret == 0) { - _pos = _file->pos() - _prefixSize; - return S_OK; - } else return E_FAIL; - } -} + + return file; -////////////////////////////////////////////////////////////////////////// -void CBDiskFile::correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; } + return NULL; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BDiskFile.h b/engines/wintermute/Base/file/BDiskFile.h index d9e7af548f..ebe1400128 100644 --- a/engines/wintermute/Base/file/BDiskFile.h +++ b/engines/wintermute/Base/file/BDiskFile.h @@ -29,30 +29,13 @@ #ifndef WINTERMUTE_BDISKFILE_H #define WINTERMUTE_BDISKFILE_H - -#include "engines/wintermute/Base/file/BFile.h" - namespace Common { class SeekableReadStream; } namespace WinterMute { -class CBDiskFile : public CBFile { -public: - CBDiskFile(CBGame *inGame); - virtual ~CBDiskFile(); - virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *buffer, uint32 size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &filename); -private: - void correctSlashes(char *fileName); - Common::SeekableReadStream *_file; - byte *_data; - bool _compressed; - uint32 _prefixSize; -}; +Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index fa6fafcb25..caeac3e14b 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -32,6 +32,7 @@ #include "engines/wintermute/Base/BBase.h" #include "common/str.h" +#include "common/stream.h" namespace Common { class SeekableReadStream; diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index fe04b816d2..ed3a24f313 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -39,24 +39,23 @@ namespace WinterMute { -////////////////////////////////////////////////////////////////////////// -CBPkgFile::CBPkgFile(CBGame *inGame): CBFile(inGame) { - _fileEntry = NULL; - _file = NULL; - _compressed = false; - -} - -////////////////////////////////////////////////////////////////////////// -CBPkgFile::~CBPkgFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Open(const Common::String &Filename) { - Close(); - +// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. +class CBPkgFile : public Common::SeekableReadStream { + uint32 _size; + Common::SeekableReadStream *_stream; +public: + CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} + virtual ~CBPkgFile() { delete _stream; } + virtual uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } + virtual bool eos() const { return _stream->eos(); } + virtual int32 pos() const { return _stream->pos(); } + virtual int32 size() const { return _size; } + virtual bool seek(int32 offset, int whence = SEEK_SET) { return _stream->seek(offset, whence); } +}; + +Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileManager *fileManager) { + CBFileEntry *fileEntry; + Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH]; strcpy(fileName, Filename.c_str()); @@ -65,97 +64,30 @@ HRESULT CBPkgFile::Open(const Common::String &Filename) { if (fileName[i] == '/') fileName[i] = '\\'; } - _fileEntry = Game->_fileManager->GetPackageEntry(fileName); - if (!_fileEntry) return E_FAIL; - - _file = _fileEntry->_package->GetFilePointer(); - if (!_file) return E_FAIL; - + fileEntry = fileManager->GetPackageEntry(fileName); + if (!fileEntry) return NULL; + + file = fileEntry->_package->GetFilePointer(); + if (!file) return NULL; + // TODO: Cleanup - _compressed = (_fileEntry->_compressedLength != 0); - _size = _fileEntry->_length; - - if (_compressed) { + bool compressed = (fileEntry->_compressedLength != 0); + /* _size = fileEntry->_length; */ + + if (compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. - _file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES)); + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); } else { - _file = new Common::SeekableSubReadStream(_file, _fileEntry->_offset, _fileEntry->_offset + _fileEntry->_length, DisposeAfterUse::YES); + file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); } - - SeekToPos(0); - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Close() { - if (_fileEntry) { - _fileEntry->_package->CloseFilePointer(_file); - _fileEntry = NULL; + if (file->size() == 0) { + file = new CBPkgFile(file, fileEntry->_length); } - _file = NULL; - - // TODO: Do we really need to take care of our position and size at all (or could (Safe)SubStreams fix that for us? - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Read(void *Buffer, uint32 Size) { - if (!_fileEntry) return E_FAIL; - - HRESULT ret = S_OK; - - if (_pos + Size > _size) { - Size = _size - _pos; - if (Size == 0) return E_FAIL; - } - - ret = _file->read(Buffer, Size); - - _pos += Size; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::Seek(uint32 pos, TSeek origin) { - if (!_fileEntry) return E_FAIL; - - uint32 newPos = 0; - - switch (origin) { - case SEEK_TO_BEGIN: - newPos = pos; - break; - case SEEK_TO_END: - newPos = _size + pos; - break; - case SEEK_TO_CURRENT: - newPos = _pos + pos; - break; - } - - if (newPos < 0 || newPos > _size) return E_FAIL; - - return SeekToPos(newPos); -} - - -#define STREAM_BUFFER_SIZE 4096 -////////////////////////////////////////////////////////////////////////// -HRESULT CBPkgFile::SeekToPos(uint32 newPos) { - HRESULT ret = S_OK; - // seek compressed stream to NewPos - _pos = newPos; - return ret; + file->seek(0); + + return file; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BPkgFile.h b/engines/wintermute/Base/file/BPkgFile.h index 912b351ac8..e2d90e2b50 100644 --- a/engines/wintermute/Base/file/BPkgFile.h +++ b/engines/wintermute/Base/file/BPkgFile.h @@ -29,12 +29,7 @@ #ifndef WINTERMUTE_BPKGFILE_H #define WINTERMUTE_BPKGFILE_H - -#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFileEntry.h" -#include // Added by ClassView - -#define COMPRESSED_BUFFER_SIZE 4096 namespace Common { class SeekableReadStream; @@ -43,21 +38,8 @@ class File; namespace WinterMute { -class CBPkgFile : public CBFile { -public: - CBPkgFile(CBGame *inGame); - virtual ~CBPkgFile(); - virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *buffer, uint32 size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &filename); -private: - bool _inflateInit; - HRESULT SeekToPos(uint32 newPos); - bool _compressed; - CBFileEntry *_fileEntry; - Common::SeekableReadStream *_file; -}; +class CBFileManager; +Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BResourceFile.cpp b/engines/wintermute/Base/file/BResourceFile.cpp deleted file mode 100644 index 9ac93c4f9b..0000000000 --- a/engines/wintermute/Base/file/BResourceFile.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/file/BResourceFile.h" -#include "engines/wintermute/Base/BResources.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::CBResourceFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBResourceFile::~CBResourceFile() { - Close(); -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Open(const Common::String &filename) { - Close(); - - if (CBResources::GetFile(filename.c_str(), _data, _size)) { - _pos = 0; - return S_OK; - } - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Close() { - _data = NULL; - _pos = 0; - _size = 0; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return E_FAIL; - - memcpy(buffer, (byte *)_data + _pos, size); - _pos += size; - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBResourceFile::Seek(uint32 pos, TSeek origin) { - if (!_data) return E_FAIL; - - int32 newPos = 0; - - switch (origin) { - case SEEK_TO_BEGIN: - newPos = pos; - break; - case SEEK_TO_END: - newPos = _size + pos; - break; - case SEEK_TO_CURRENT: - newPos = _pos + pos; - break; - } - - if (newPos < 0 || newPos > _size) return E_FAIL; - else _pos = newPos; - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BResourceFile.h b/engines/wintermute/Base/file/BResourceFile.h deleted file mode 100644 index 77d8b629b1..0000000000 --- a/engines/wintermute/Base/file/BResourceFile.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCEFILE_H -#define WINTERMUTE_BRESOURCEFILE_H - -#include "engines/wintermute/Base/file/BFile.h" - -namespace WinterMute { - -class CBResourceFile : public CBFile { -public: - CBResourceFile(CBGame *inGame); - virtual ~CBResourceFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index e73f244f00..c869b6985d 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -209,8 +209,8 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool FoundNewLine = false; HRESULT Ret = E_FAIL; do { - Ret = _readFile->Read(&b, 1); - if (FAILED(Ret)) break; + Ret = _readFile->read(&b, 1); + if (Ret != 1) break; if (Counter > BufSize) { Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); @@ -260,8 +260,8 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This HRESULT Ret = E_FAIL; while (Counter < TextLen) { - Ret = _readFile->Read(&b, 1); - if (FAILED(Ret)) break; + Ret = _readFile->read(&b, 1); + if (Ret != 1) break; if (Counter > BufSize) { Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); @@ -321,7 +321,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } bool Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val); + if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) Stack->PushBool(Val); else Stack->PushNULL(); return S_OK; @@ -338,7 +338,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } byte Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte)))) Stack->PushInt(Val); + if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) Stack->PushInt(Val); else Stack->PushNULL(); return S_OK; @@ -355,7 +355,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } short Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val); + if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) Stack->PushInt(65536 + Val); else Stack->PushNULL(); return S_OK; @@ -372,7 +372,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } int Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val); + if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) Stack->PushInt(Val); else Stack->PushNULL(); return S_OK; @@ -389,7 +389,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } float Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val); + if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) Stack->PushFloat(Val); else Stack->PushNULL(); return S_OK; @@ -406,7 +406,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } double Val; - if (SUCCEEDED(_readFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val); + if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) Stack->PushFloat(Val); else Stack->PushNULL(); return S_OK; @@ -423,10 +423,10 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } uint32 Size; - if (SUCCEEDED(_readFile->Read(&Size, sizeof(uint32)))) { + if (_readFile->read(&Size, sizeof(uint32)) == sizeof(uint32)) { byte *Str = new byte[Size + 1]; if (Str) { - if (SUCCEEDED(_readFile->Read(Str, Size))) { + if (_readFile->read(Str, Size) == Size) { Str[Size] = '\0'; Stack->PushString((char *)Str); } @@ -652,21 +652,21 @@ HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetPos() { - if (_mode == 1 && _readFile) return _readFile->getPos(); + if (_mode == 1 && _readFile) return _readFile->pos(); else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); else return 0; } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::SetPos(uint32 Pos, TSeek Origin) { - if (_mode == 1 && _readFile) return SUCCEEDED(_readFile->Seek(Pos, Origin)); - else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, Pos, (int)Origin) == 0; +bool CSXFile::SetPos(uint32 pos, TSeek origin) { + if (_mode == 1 && _readFile) return _readFile->seek(pos, origin); + else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, pos, (int)origin) == 0; else return false; } ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetLength() { - if (_mode == 1 && _readFile) return _readFile->getSize(); + if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { uint32 CurrentPos = ftell(_writeFile); fseek(_writeFile, 0, SEEK_END); diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index f05a0e11ec..f1c6552a71 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BScriptable.h" +#include "common/stream.h" namespace WinterMute { @@ -46,7 +47,7 @@ public: CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); private: - CBFile *_readFile; + Common::SeekableReadStream *_readFile; FILE *_writeFile; int _mode; // 0..none, 1..read, 2..write, 3..append bool _textMode; diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 47c41be5cc..217317ece6 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -42,7 +42,6 @@ MODULE_OBJS := \ Base/scriptables/SXString.o \ Base/file/BDiskFile.o \ Base/file/BFile.o \ - Base/file/BResourceFile.o \ Base/file/BSaveThumbFile.o \ Base/file/BPkgFile.o \ Base/BActiveRect.o \ -- cgit v1.2.3 From 5fd8d1360f8d9da234c92ae2782f26b082211cfb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 11:10:36 +0200 Subject: WINTERMUTE: Mark BSaveThumbFile for future refactoring. --- engines/wintermute/Base/file/BSaveThumbFile.h | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 0531d6a873..78626eeff4 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -34,6 +34,7 @@ namespace WinterMute { +//TODO: Get rid of this class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); -- cgit v1.2.3 From 2db256605539b82ed4ace20d41c6046f50792706 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 12:10:48 +0200 Subject: WINTERMUTE: Convert 8bpp images to 32 bpp --- engines/wintermute/Base/BSurfaceSDL.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index f41839a244..c0157696d6 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -90,6 +90,7 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, imgDecoder->loadStream(*file); const Graphics::Surface *surface = imgDecoder->getSurface(); + const byte* palette = imgDecoder->getPalette(); Game->_fileManager->CloseFile(file); if (default_ck) { @@ -136,7 +137,10 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, // no alpha, set color key /* if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { + if (surface->format.bytesPerPixel == 1 && palette) { + _surface = surface->convertTo(g_system->getScreenFormat(), palette); + } + else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { _surface = surface->convertTo(g_system->getScreenFormat()); } else { _surface = new Graphics::Surface(); -- cgit v1.2.3 From e7a802700c3872215049d304fb6898549eef56f5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 13:48:26 +0200 Subject: WINTERMUTE: Add color-keying for BSurfaceSDL BMPs --- engines/wintermute/Base/BSurfaceSDL.cpp | 14 +++++++++++--- engines/wintermute/graphics/transparentSurface.cpp | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index c0157696d6..0b16f3d39b 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -137,10 +137,18 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, // no alpha, set color key /* if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - if (surface->format.bytesPerPixel == 1 && palette) { + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + if (strFileName.hasSuffix(".bmp") && surface->format.bytesPerPixel == 4) { _surface = surface->convertTo(g_system->getScreenFormat(), palette); - } - else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { + TransparentSurface trans(*_surface); + trans.applyColorKey(ck_red, ck_green, ck_blue); + } else if (surface->format.bytesPerPixel == 1 && palette) { + _surface = surface->convertTo(g_system->getScreenFormat(), palette); + TransparentSurface trans(*_surface); + trans.applyColorKey(ck_red, ck_green, ck_blue, true); + } else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { _surface = surface->convertTo(g_system->getScreenFormat()); } else { _surface = new Graphics::Surface(); diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index d7f8719b6e..33f2043839 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -278,6 +278,7 @@ TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { * @param overwriteAlpha if true, all other alpha will be set fully opaque */ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { + assert(format.bytesPerPixel == 4); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { uint32 pix = ((uint32 *)pixels)[i * w + j]; -- cgit v1.2.3 From 74ff79e90bb2862e8c84867ff50f56675c1b4c7e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 14:28:58 +0200 Subject: WINTERMUTE: Implement IsTransparentAtLite, to fix the BitmapFont-drawing. --- engines/wintermute/Base/BSurfaceSDL.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 0b16f3d39b..af41231968 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -361,6 +361,16 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); hasWarned = true; } + if (_surface->format.bytesPerPixel == 4) { + uint32 pixel = *(uint32*)_surface->getBasePtr(X, Y); + uint8 r,g,b,a; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } #if 0 uint32 format; int access; -- cgit v1.2.3 From cafdcd1c8a68fb23dd6e2841b427fb69f29dd62c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 18:38:20 +0200 Subject: WINTERMUTE: Add in more of the missing Video-pieces, also, copy over the TheoraPlayer from SWORD25 --- engines/wintermute/Ad/AdGame.cpp | 64 ++- engines/wintermute/Base/BGame.cpp | 54 +- engines/wintermute/Base/BGame.h | 9 +- engines/wintermute/video/VidPlayer.cpp | 18 +- engines/wintermute/video/VidPlayer.h | 16 +- engines/wintermute/video/VidTheoraPlayer.cpp | 20 +- engines/wintermute/video/VidTheoraPlayer.h | 19 +- .../wintermute/video/decoders/theora_decoder.cpp | 566 +++++++++++++++++++++ engines/wintermute/video/decoders/theora_decoder.h | 144 ++++++ 9 files changed, 840 insertions(+), 70 deletions(-) create mode 100644 engines/wintermute/video/decoders/theora_decoder.cpp create mode 100644 engines/wintermute/video/decoders/theora_decoder.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 584504b7c6..9c6c9f4174 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -57,6 +57,8 @@ #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" #include "common/str.h" namespace WinterMute { @@ -1689,40 +1691,58 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // fill black _renderer->Fill(0, 0, 0); if (!_editorMode) _renderer->SetScreenViewport(); + + // playing exclusive video? + if(_videoPlayer->isPlaying()) + { + if(Update) _videoPlayer->update(); + _videoPlayer->display(); + } + else if(_theoraPlayer) + { + if(_theoraPlayer->isPlaying()) { + if(Update) _theoraPlayer->update(); + _theoraPlayer->display(); + } + if(_theoraPlayer->IsFinished()) { + delete _theoraPlayer; + _theoraPlayer = NULL; + } + } else { - // process scripts - if (Update) _scEngine->Tick(); + // process scripts + if (Update) _scEngine->Tick(); - POINT p; - GetMousePos(&p); + POINT p; + GetMousePos(&p); - _scene->Update(); - _scene->Display(); + _scene->Update(); + _scene->Display(); - // display in-game windows - DisplayWindows(true); - if (_inventoryBox) _inventoryBox->Display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); - if (_indicatorDisplay) DisplayIndicator(); + // display in-game windows + DisplayWindows(true); + if (_inventoryBox) _inventoryBox->Display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); + if (_indicatorDisplay) DisplayIndicator(); - if (Update || DisplayAll) { - // display normal windows - DisplayWindows(false); + if (Update || DisplayAll) { + // display normal windows + DisplayWindows(false); - SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); + SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); - // textual info - DisplaySentences(_state == GAME_FROZEN); + // textual info + DisplaySentences(_state == GAME_FROZEN); - ShowCursor(); - - if (_fader) _fader->Display(); - _transMgr->Update(); - } + ShowCursor(); + if (_fader) _fader->Display(); + _transMgr->Update(); + } + } if (_loadingIcon) { _loadingIcon->Display(_loadingIconX, _loadingIconY); if (!_loadingIconPersistent) { diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index c9b122759d..3a4e88a612 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -67,6 +67,8 @@ #include "engines/wintermute/Base/scriptables/SXMath.h" #include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/Base/scriptables/SXString.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" #include "common/textconsole.h" #include "common/util.h" #include "common/keyboard.h" @@ -115,6 +117,9 @@ CBGame::CBGame(): CBObject(this) { _systemFont = NULL; _videoFont = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _mainObject = NULL; _activeObject = NULL; @@ -304,6 +309,8 @@ CBGame::~CBGame() { delete _scEngine; delete _fontStorage; delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; delete _soundMgr; delete _debugMgr; //SAFE_DELETE(_keyboardState); @@ -326,6 +333,8 @@ CBGame::~CBGame() { _scEngine = NULL; _fontStorage = NULL; _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; _soundMgr = NULL; _debugMgr = NULL; @@ -445,6 +454,9 @@ HRESULT CBGame::Initialize1() { _scEngine = new CScEngine(this); if (_scEngine == NULL) goto init_fail; + + _videoPlayer = new CVidPlayer(this); + if(_videoPlayer==NULL) goto init_fail; _transMgr = new CBTransitionMgr(this); if (_transMgr == NULL) goto init_fail; @@ -473,6 +485,7 @@ init_fail: if (_soundMgr) delete _soundMgr; if (_fileManager) delete _fileManager; if (_scEngine) delete _scEngine; + if (_videoPlayer) delete _videoPlayer; return E_FAIL; } @@ -1399,16 +1412,16 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - /*if(SUCCEEDED(Game->m_VideoPlayer->Initialize(Filename, SubtitleFile))) + if(SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { - if(SUCCEEDED(Game->m_VideoPlayer->Play((TVideoPlayback)Type, X, Y, FreezeMusic))) + if(SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } else Stack->PushBool(false); } - else */Stack->PushBool(false); + else Stack->PushBool(false); return S_OK; } @@ -1441,20 +1454,20 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - - /*SAFE_DELETE(m_TheoraPlayer); - m_TheoraPlayer = new CVidTheoraPlayer(this); - if(m_TheoraPlayer && SUCCEEDED(m_TheoraPlayer->Initialize(Filename, SubtitleFile))) + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if(_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) { - m_TheoraPlayer->m_DontDropFrames = !DropFrames; - if(SUCCEEDED(m_TheoraPlayer->Play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) + _theoraPlayer->_dontDropFrames = !DropFrames; + if(SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } else Stack->PushBool(false); } - else */Stack->PushBool(false); + else Stack->PushBool(false); return S_OK; } @@ -4195,6 +4208,27 @@ HRESULT CBGame::SetWaitCursor(const char *Filename) { } else return S_OK; } +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsVideoPlaying() +{ + if(_videoPlayer->isPlaying()) return true; + if(_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::StopVideo() +{ + if(_videoPlayer->isPlaying()) _videoPlayer->stop(); + if(_theoraPlayer && _theoraPlayer->isPlaying()) + { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return S_OK; +} + ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DrawCursor(CBSprite *Cursor) { diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index ac8138855f..2f9b6147ec 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -61,6 +61,8 @@ class CBSurfaceStorage; class CSXStore; class CSXMath; class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; #define NUM_MUSIC_CHANNELS 5 @@ -263,8 +265,8 @@ public: HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); -/* CVidPlayer* _videoPlayer; - CVidTheoraPlayer* _theoraPlayer;*/ + CVidPlayer* _videoPlayer; + CVidTheoraPlayer* _theoraPlayer; bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; @@ -323,6 +325,9 @@ public: uint32 _fps; HRESULT UpdateMusicCrossfade(); + bool IsVideoPlaying(); + HRESULT StopVideo(); + CBArray _regObjects; public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index ab20135595..cd693f0b3f 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -86,12 +86,12 @@ HRESULT CVidPlayer::SetDefaults() { ////////////////////////////////////////////////////////////////////////// CVidPlayer::~CVidPlayer() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Cleanup() { +HRESULT CVidPlayer::cleanup() { #if 0 if (_sound) _sound->Stop(); if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); @@ -124,7 +124,7 @@ HRESULT CVidPlayer::Cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Initialize(char *inFilename, char *SubtitleFile) { +HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 Cleanup(); @@ -204,7 +204,7 @@ HRESULT CVidPlayer::Initialize(char *inFilename, char *SubtitleFile) { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Update() { +HRESULT CVidPlayer::update() { #if 0 if (!m_Playing) return S_OK; @@ -274,7 +274,7 @@ HRESULT CVidPlayer::Update() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Display() { +HRESULT CVidPlayer::display() { #if 0 if (!m_Playing) return S_OK; @@ -298,7 +298,7 @@ HRESULT CVidPlayer::Display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +HRESULT CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { #if 0 if (!_videoStream || !_vidRenderer) return E_FAIL; @@ -359,7 +359,7 @@ HRESULT CVidPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::Stop() { +HRESULT CVidPlayer::stop() { #if 0 if (!_playing) return S_OK; @@ -372,13 +372,13 @@ HRESULT CVidPlayer::Stop() { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::IsPlaying() { +bool CVidPlayer::isPlaying() { return _playing; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::LoadSubtitles(char *Filename, char *SubtitleFile) { +HRESULT CVidPlayer::loadSubtitles(const char *Filename, const char *SubtitleFile) { #if 0 if (!Filename) return S_OK; diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index a1abf2ea46..eca9a96782 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -46,12 +46,12 @@ class CVidPlayer : public CBBase { public: bool _showSubtitle; int _currentSubtitle; - HRESULT LoadSubtitles(char *Filename, char *SubtitleFile); + HRESULT loadSubtitles(const char *Filename, const char *SubtitleFile); bool _slowRendering; - bool IsPlaying(); + bool isPlaying(); char *_filename; - HRESULT Stop(); - HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + HRESULT stop(); + HRESULT play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); uint32 _totalVideoTime; uint32 _startTime; //CVidRenderer *_vidRenderer; @@ -59,10 +59,10 @@ public: bool _soundAvailable; HRESULT SetDefaults(); bool _playing; - HRESULT Display(); - HRESULT Update(); - HRESULT Initialize(char *inFilename, char *SubtitleFile = NULL); - HRESULT Cleanup(); + HRESULT display(); + HRESULT update(); + HRESULT initialize(const char *inFilename, const char *SubtitleFile = NULL); + HRESULT cleanup(); CVidPlayer(CBGame *inGame); virtual ~CVidPlayer(); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 01e1728732..56bdcc8a8a 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -159,7 +159,7 @@ void CVidTheoraPlayer::Cleanup() { }*/ ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { +HRESULT CVidTheoraPlayer::initialize(const char *Filename, const char *SubtitleFile) { #if 0 Cleanup(); @@ -328,7 +328,7 @@ HRESULT CVidTheoraPlayer::Initialize(char *Filename, char *SubtitleFile) { return Res; #endif - return 0; + return E_FAIL; } @@ -345,7 +345,7 @@ HRESULT CVidTheoraPlayer::ResetStream() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { +HRESULT CVidTheoraPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { #if 0 if (ForceZoom < 0.0f) ForceZoom = 100.0f; if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); @@ -397,11 +397,11 @@ HRESULT CVidTheoraPlayer::Play(TVideoPlayback Type, int X, int Y, bool FreezeGam Update(); #endif - return S_OK; + return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Stop() { +HRESULT CVidTheoraPlayer::stop() { #if 0 if (m_Sound) m_Sound->Stop(); m_State = THEORA_STATE_FINISHED; @@ -411,7 +411,7 @@ HRESULT CVidTheoraPlayer::Stop() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Update() { +HRESULT CVidTheoraPlayer::update() { #if 0 m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; @@ -637,7 +637,7 @@ HRESULT CVidTheoraPlayer::WriteVideo() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Display(uint32 Alpha) { +HRESULT CVidTheoraPlayer::display(uint32 Alpha) { RECT rc; HRESULT Res; @@ -890,7 +890,7 @@ finish: } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Pause() { +HRESULT CVidTheoraPlayer::pause() { #if 0 if (m_State == THEORA_STATE_PLAYING) { m_State = THEORA_STATE_PAUSED; @@ -902,7 +902,7 @@ HRESULT CVidTheoraPlayer::Pause() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Resume() { +HRESULT CVidTheoraPlayer::resume() { #if 0 if (_state == THEORA_STATE_PAUSED) { _state = THEORA_STATE_PLAYING; @@ -945,7 +945,7 @@ HRESULT CVidTheoraPlayer::Resume() { } */ ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::InitializeSimple() { +HRESULT CVidTheoraPlayer::initializeSimple() { #if 0 if (SUCCEEDED(Initialize(m_Filename))) { if (m_AlphaFilename) SetAlphaImage(m_AlphaFilename); diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 9766988656..74a094bf5c 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -71,21 +71,22 @@ public: //CVidSubtitler *_subtitler; // control methods - HRESULT Initialize(char *Filename, char *SubtitleFile = NULL); - HRESULT InitializeSimple(); - HRESULT Update(); - HRESULT Play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); - HRESULT Stop(); - HRESULT Display(uint32 Alpha = 0xFFFFFFFF); + HRESULT initialize(const char *Filename, const char *SubtitleFile = NULL); + HRESULT initializeSimple(); + HRESULT update(); + HRESULT play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); + HRESULT stop(); + HRESULT display(uint32 Alpha = 0xFFFFFFFF); //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); - HRESULT Pause(); - HRESULT Resume(); + HRESULT pause(); + HRESULT resume(); - bool IsPlaying() { + bool isPlaying() { return _state == THEORA_STATE_PLAYING; }; bool IsFinished() { + return true; // HACK return _state == THEORA_STATE_FINISHED; }; bool IsPaused() { diff --git a/engines/wintermute/video/decoders/theora_decoder.cpp b/engines/wintermute/video/decoders/theora_decoder.cpp new file mode 100644 index 0000000000..7c766fe3c6 --- /dev/null +++ b/engines/wintermute/video/decoders/theora_decoder.cpp @@ -0,0 +1,566 @@ +/* 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. + * + */ + +/* + * Source is based on the player example from libvorbis package, + * available at: http://svn.xiph.org/trunk/theora/examples/player_example.c + * + * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. + * + * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 + * by the Xiph.Org Foundation and contributors http://www.xiph.org/ + * + */ + +#include "engines/wintermute/video/decoders/theora_decoder.h" + +#ifdef USE_THEORADEC +#include "common/system.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "graphics/yuv_to_rgb.h" +#include "audio/decoders/raw.h" +#include "common/stream.h" +#include "common/debug.h" + +namespace WinterMute { + +#define AUDIOFD_FRAGSIZE 10240 + +static double rint(double v) { + return floor(v + 0.5); +} + +TheoraDecoder::TheoraDecoder(Audio::Mixer::SoundType soundType) { + _fileStream = 0; + + _theoraPacket = 0; + _vorbisPacket = 0; + _theoraDecode = 0; + _theoraSetup = 0; + _nextFrameStartTime = 0.0; + + _soundType = soundType; + _audStream = 0; + _audHandle = new Audio::SoundHandle(); + + ogg_sync_init(&_oggSync); + + _curFrame = -1; + _audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t)); + + reset(); +} + +TheoraDecoder::~TheoraDecoder() { + close(); + delete _fileStream; + delete _audHandle; + free(_audiobuf); +} + +void TheoraDecoder::queuePage(ogg_page *page) { + if (_theoraPacket) + ogg_stream_pagein(&_theoraOut, page); + + if (_vorbisPacket) + ogg_stream_pagein(&_vorbisOut, page); +} + +int TheoraDecoder::bufferData() { + char *buffer = ogg_sync_buffer(&_oggSync, 4096); + int bytes = _fileStream->read(buffer, 4096); + + ogg_sync_wrote(&_oggSync, bytes); + + return bytes; +} + +bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) { + close(); + + _endOfAudio = false; + _endOfVideo = false; + _fileStream = stream; + + // start up Ogg stream synchronization layer + ogg_sync_init(&_oggSync); + + // init supporting Vorbis structures needed in header parsing + vorbis_info_init(&_vorbisInfo); + vorbis_comment_init(&_vorbisComment); + + // init supporting Theora structures needed in header parsing + th_comment_init(&_theoraComment); + th_info_init(&_theoraInfo); + + // Ogg file open; parse the headers + // Only interested in Vorbis/Theora streams + bool foundHeader = false; + while (!foundHeader) { + int ret = bufferData(); + + if (ret == 0) + break; + + while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) { + ogg_stream_state test; + + // is this a mandated initial header? If not, stop parsing + if (!ogg_page_bos(&_oggPage)) { + // don't leak the page; get it into the appropriate stream + queuePage(&_oggPage); + foundHeader = true; + break; + } + + ogg_stream_init(&test, ogg_page_serialno(&_oggPage)); + ogg_stream_pagein(&test, &_oggPage); + ogg_stream_packetout(&test, &_oggPacket); + + // identify the codec: try theora + if (!_theoraPacket && th_decode_headerin(&_theoraInfo, &_theoraComment, &_theoraSetup, &_oggPacket) >= 0) { + // it is theora + memcpy(&_theoraOut, &test, sizeof(test)); + _theoraPacket = 1; + } else if (!_vorbisPacket && vorbis_synthesis_headerin(&_vorbisInfo, &_vorbisComment, &_oggPacket) >= 0) { + // it is vorbis + memcpy(&_vorbisOut, &test, sizeof(test)); + _vorbisPacket = 1; + } else { + // whatever it is, we don't care about it + ogg_stream_clear(&test); + } + } + // fall through to non-bos page parsing + } + + // we're expecting more header packets. + while ((_theoraPacket && _theoraPacket < 3) || (_vorbisPacket && _vorbisPacket < 3)) { + int ret; + + // look for further theora headers + while (_theoraPacket && (_theoraPacket < 3) && (ret = ogg_stream_packetout(&_theoraOut, &_oggPacket))) { + if (ret < 0) + error("Error parsing Theora stream headers; corrupt stream?"); + + if (!th_decode_headerin(&_theoraInfo, &_theoraComment, &_theoraSetup, &_oggPacket)) + error("Error parsing Theora stream headers; corrupt stream?"); + + _theoraPacket++; + } + + // look for more vorbis header packets + while (_vorbisPacket && (_vorbisPacket < 3) && (ret = ogg_stream_packetout(&_vorbisOut, &_oggPacket))) { + if (ret < 0) + error("Error parsing Vorbis stream headers; corrupt stream?"); + + if (vorbis_synthesis_headerin(&_vorbisInfo, &_vorbisComment, &_oggPacket)) + error("Error parsing Vorbis stream headers; corrupt stream?"); + + _vorbisPacket++; + + if (_vorbisPacket == 3) + break; + } + + // The header pages/packets will arrive before anything else we + // care about, or the stream is not obeying spec + + if (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) { + queuePage(&_oggPage); // demux into the appropriate stream + } else { + ret = bufferData(); // someone needs more data + + if (ret == 0) + error("End of file while searching for codec headers."); + } + } + + // and now we have it all. initialize decoders + if (_theoraPacket) { + _theoraDecode = th_decode_alloc(&_theoraInfo, _theoraSetup); + debugN(1, "Ogg logical stream %lx is Theora %dx%d %.02f fps", + _theoraOut.serialno, _theoraInfo.pic_width, _theoraInfo.pic_height, + (double)_theoraInfo.fps_numerator / _theoraInfo.fps_denominator); + + switch (_theoraInfo.pixel_fmt) { + case TH_PF_420: + debug(1, " 4:2:0 video"); + break; + case TH_PF_422: + debug(1, " 4:2:2 video"); + break; + case TH_PF_444: + debug(1, " 4:4:4 video"); + break; + case TH_PF_RSVD: + default: + debug(1, " video\n (UNKNOWN Chroma sampling!)"); + break; + } + + if (_theoraInfo.pic_width != _theoraInfo.frame_width || _theoraInfo.pic_height != _theoraInfo.frame_height) + debug(1, " Frame content is %dx%d with offset (%d,%d).", + _theoraInfo.frame_width, _theoraInfo.frame_height, _theoraInfo.pic_x, _theoraInfo.pic_y); + + switch (_theoraInfo.colorspace){ + case TH_CS_UNSPECIFIED: + /* nothing to report */ + break; + case TH_CS_ITU_REC_470M: + debug(1, " encoder specified ITU Rec 470M (NTSC) color."); + break; + case TH_CS_ITU_REC_470BG: + debug(1, " encoder specified ITU Rec 470BG (PAL) color."); + break; + default: + debug(1, "warning: encoder specified unknown colorspace (%d).", _theoraInfo.colorspace); + break; + } + + debug(1, "Encoded by %s", _theoraComment.vendor); + if (_theoraComment.comments) { + debug(1, "theora comment header:"); + for (int i = 0; i < _theoraComment.comments; i++) { + if (_theoraComment.user_comments[i]) { + int len = _theoraComment.comment_lengths[i]; + char *value = (char *)malloc(len + 1); + if (value) { + memcpy(value, _theoraComment.user_comments[i], len); + value[len] = '\0'; + debug(1, "\t%s", value); + free(value); + } + } + } + } + + th_decode_ctl(_theoraDecode, TH_DECCTL_GET_PPLEVEL_MAX, &_ppLevelMax, sizeof(_ppLevelMax)); + _ppLevel = _ppLevelMax; + th_decode_ctl(_theoraDecode, TH_DECCTL_SET_PPLEVEL, &_ppLevel, sizeof(_ppLevel)); + _ppInc = 0; + } else { + // tear down the partial theora setup + th_info_clear(&_theoraInfo); + th_comment_clear(&_theoraComment); + } + + th_setup_free(_theoraSetup); + _theoraSetup = 0; + + if (_vorbisPacket) { + vorbis_synthesis_init(&_vorbisDSP, &_vorbisInfo); + vorbis_block_init(&_vorbisDSP, &_vorbisBlock); + debug(3, "Ogg logical stream %lx is Vorbis %d channel %ld Hz audio.", + _vorbisOut.serialno, _vorbisInfo.channels, _vorbisInfo.rate); + + _audStream = Audio::makeQueuingAudioStream(_vorbisInfo.rate, _vorbisInfo.channels); + + // Get enough audio data to start us off + while (_audStream->numQueuedStreams() == 0) { + // Queue more data + bufferData(); + while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) + queuePage(&_oggPage); + + queueAudio(); + } + + if (_audStream) + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _audHandle, _audStream, -1, getVolume(), getBalance()); + } else { + // tear down the partial vorbis setup + vorbis_info_clear(&_vorbisInfo); + vorbis_comment_clear(&_vorbisComment); + _endOfAudio = true; + } + + _surface.create(_theoraInfo.frame_width, _theoraInfo.frame_height, g_system->getScreenFormat()); + + // Set up a display surface + _displaySurface.pixels = _surface.getBasePtr(_theoraInfo.pic_x, _theoraInfo.pic_y); + _displaySurface.w = _theoraInfo.pic_width; + _displaySurface.h = _theoraInfo.pic_height; + _displaySurface.format = _surface.format; + _displaySurface.pitch = _surface.pitch; + + // Set the frame rate + _frameRate = Common::Rational(_theoraInfo.fps_numerator, _theoraInfo.fps_denominator); + + return true; +} + +void TheoraDecoder::close() { + if (_vorbisPacket) { + ogg_stream_clear(&_vorbisOut); + vorbis_block_clear(&_vorbisBlock); + vorbis_dsp_clear(&_vorbisDSP); + vorbis_comment_clear(&_vorbisComment); + vorbis_info_clear(&_vorbisInfo); + + g_system->getMixer()->stopHandle(*_audHandle); + + _audStream = 0; + _vorbisPacket = false; + } + if (_theoraPacket) { + ogg_stream_clear(&_theoraOut); + th_decode_free(_theoraDecode); + th_comment_clear(&_theoraComment); + th_info_clear(&_theoraInfo); + _theoraDecode = 0; + _theoraPacket = false; + } + + if (!_fileStream) + return; + + ogg_sync_clear(&_oggSync); + + delete _fileStream; + _fileStream = 0; + + _surface.free(); + _displaySurface.pixels = 0; + _displaySurface.free(); + + reset(); +} + +const Graphics::Surface *TheoraDecoder::decodeNextFrame() { + // First, let's get our frame + while (_theoraPacket) { + // theora is one in, one out... + if (ogg_stream_packetout(&_theoraOut, &_oggPacket) > 0) { + + if (_ppInc) { + _ppLevel += _ppInc; + th_decode_ctl(_theoraDecode, TH_DECCTL_SET_PPLEVEL, &_ppLevel, sizeof(_ppLevel)); + _ppInc = 0; + } + + if (th_decode_packetin(_theoraDecode, &_oggPacket, NULL) == 0) { + _curFrame++; + + // Convert YUV data to RGB data + th_ycbcr_buffer yuv; + th_decode_ycbcr_out(_theoraDecode, yuv); + translateYUVtoRGBA(yuv); + + if (_curFrame == 0) + _startTime = g_system->getMillis(); + + double time = th_granule_time(_theoraDecode, _oggPacket.granulepos); + + // We need to calculate when the next frame should be shown + // This is all in floating point because that's what the Ogg code gives us + // Ogg is a lossy container format, so it doesn't always list the time to the + // next frame. In such cases, we need to calculate it ourselves. + if (time == -1.0) + _nextFrameStartTime += _frameRate.getInverse().toDouble(); + else + _nextFrameStartTime = time; + + // break out + break; + } + } else { + // If we can't get any more frames, we're done. + if (_theoraOut.e_o_s || _fileStream->eos()) { + _endOfVideo = true; + break; + } + + // Queue more data + bufferData(); + while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) + queuePage(&_oggPage); + } + + // Update audio if we can + queueAudio(); + } + + // Force at least some audio to be buffered + // TODO: 5 is very arbitrary. We probably should do something like QuickTime does. + while (!_endOfAudio && _audStream->numQueuedStreams() < 5) { + bufferData(); + while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) + queuePage(&_oggPage); + + bool queuedAudio = queueAudio(); + if ((_vorbisOut.e_o_s || _fileStream->eos()) && !queuedAudio) { + _endOfAudio = true; + break; + } + } + + return &_displaySurface; +} + +bool TheoraDecoder::queueAudio() { + if (!_audStream) + return false; + + // An audio buffer should have been allocated (either in the constructor or after queuing the current buffer) + if (!_audiobuf) { + warning("[TheoraDecoder::queueAudio] Invalid audio buffer"); + return false; + } + + bool queuedAudio = false; + + for (;;) { + float **pcm; + + // if there's pending, decoded audio, grab it + int ret = vorbis_synthesis_pcmout(&_vorbisDSP, &pcm); + if (ret > 0) { + int count = _audiobufFill / 2; + int maxsamples = ((AUDIOFD_FRAGSIZE - _audiobufFill) / _vorbisInfo.channels) >> 1; + int i; + for (i = 0; i < ret && i < maxsamples; i++) + for (int j = 0; j < _vorbisInfo.channels; j++) { + int val = CLIP((int)rint(pcm[j][i] * 32767.f), -32768, 32767); + _audiobuf[count++] = val; + } + + vorbis_synthesis_read(&_vorbisDSP, i); + _audiobufFill += (i * _vorbisInfo.channels) << 1; + + if (_audiobufFill == AUDIOFD_FRAGSIZE) { + byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; +#ifdef SCUMM_LITTLE_ENDIAN + flags |= Audio::FLAG_LITTLE_ENDIAN; +#endif + _audStream->queueBuffer((byte *)_audiobuf, AUDIOFD_FRAGSIZE, DisposeAfterUse::NO, flags); + + // The audio mixer is now responsible for the old audio buffer. + // We need to create a new one. + _audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t)); + if (!_audiobuf) { + warning("[TheoraDecoder::queueAudio] Cannot allocate memory for audio buffer"); + return false; + } + + _audiobufFill = 0; + queuedAudio = true; + } + } else { + // no pending audio; is there a pending packet to decode? + if (ogg_stream_packetout(&_vorbisOut, &_oggPacket) > 0) { + if (vorbis_synthesis(&_vorbisBlock, &_oggPacket) == 0) // test for success! + vorbis_synthesis_blockin(&_vorbisDSP, &_vorbisBlock); + } else // we've buffered all we have, break out for now + return queuedAudio; + } + } + + // Unreachable + return false; +} + +void TheoraDecoder::reset() { + VideoDecoder::reset(); + + // FIXME: This does a rewind() instead of a reset()! + + if (_fileStream) + _fileStream->seek(0); + + _audiobufFill = 0; + _audiobufReady = false; + + _curFrame = -1; + + _theoraPacket = 0; + _vorbisPacket = 0; +} + +bool TheoraDecoder::endOfVideo() const { + return !isVideoLoaded() || (_endOfVideo && (!_audStream || (_audStream->endOfData() && _endOfAudio))); +} + +uint32 TheoraDecoder::getTimeToNextFrame() const { + if (endOfVideo() || _curFrame < 0) + return 0; + + uint32 elapsedTime = getTime(); + uint32 nextFrameStartTime = (uint32)(_nextFrameStartTime * 1000); + + if (nextFrameStartTime <= elapsedTime) + return 0; + + return nextFrameStartTime - elapsedTime; +} + +uint32 TheoraDecoder::getTime() const { + if (_audStream) + return g_system->getMixer()->getSoundElapsedTime(*_audHandle); + + return VideoDecoder::getTime(); +} + +void TheoraDecoder::pauseVideoIntern(bool pause) { + if (_audStream) + g_system->getMixer()->pauseHandle(*_audHandle, pause); +} + +enum TheoraYUVBuffers { + kBufferY = 0, + kBufferU = 1, + kBufferV = 2 +}; + +void TheoraDecoder::translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer) { + // Width and height of all buffers have to be divisible by 2. + assert((YUVBuffer[kBufferY].width & 1) == 0); + assert((YUVBuffer[kBufferY].height & 1) == 0); + assert((YUVBuffer[kBufferU].width & 1) == 0); + assert((YUVBuffer[kBufferV].width & 1) == 0); + + // UV images have to have a quarter of the Y image resolution + assert(YUVBuffer[kBufferU].width == YUVBuffer[kBufferY].width >> 1); + assert(YUVBuffer[kBufferV].width == YUVBuffer[kBufferY].width >> 1); + assert(YUVBuffer[kBufferU].height == YUVBuffer[kBufferY].height >> 1); + assert(YUVBuffer[kBufferV].height == YUVBuffer[kBufferY].height >> 1); + + Graphics::convertYUV420ToRGB(&_surface, YUVBuffer[kBufferY].data, YUVBuffer[kBufferU].data, YUVBuffer[kBufferV].data, YUVBuffer[kBufferY].width, YUVBuffer[kBufferY].height, YUVBuffer[kBufferY].stride, YUVBuffer[kBufferU].stride); +} + +void TheoraDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelVolume(*_audHandle, getVolume()); +} + +void TheoraDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelBalance(*_audHandle, getBalance()); +} + +} // End of namespace Sword25 + +#endif diff --git a/engines/wintermute/video/decoders/theora_decoder.h b/engines/wintermute/video/decoders/theora_decoder.h new file mode 100644 index 0000000000..34a7aa32a4 --- /dev/null +++ b/engines/wintermute/video/decoders/theora_decoder.h @@ -0,0 +1,144 @@ +/* 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. + * + */ + +#ifndef WINTERMUTE_THEORADECODER_H +#define WINTERMUTE_THEORADECODER_H + +#include "common/scummsys.h" // for USE_THEORADEC + +#ifdef USE_THEORADEC + +#include "common/rational.h" +#include "video/video_decoder.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" + +#include +#include + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +/** + * + * Decoder for Theora videos. + * Video decoder used in engines: + * - sword25 + */ +class TheoraDecoder : public Video::VideoDecoder { +public: + TheoraDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); + virtual ~TheoraDecoder(); + + /** + * Load a video file + * @param stream the stream to load + */ + bool loadStream(Common::SeekableReadStream *stream); + void close(); + void reset(); + + /** + * Decode the next frame and return the frame's surface + * @note the return surface should *not* be freed + * @note this may return 0, in which case the last frame should be kept on screen + */ + const Graphics::Surface *decodeNextFrame(); + + bool isVideoLoaded() const { return _fileStream != 0; } + uint16 getWidth() const { return _displaySurface.w; } + uint16 getHeight() const { return _displaySurface.h; } + + uint32 getFrameCount() const { + // It is not possible to get frame count easily + // I.e. seeking is required + assert(0); + return 0; + } + + Graphics::PixelFormat getPixelFormat() const { return _displaySurface.format; } + uint32 getTime() const; + uint32 getTimeToNextFrame() const; + + bool endOfVideo() const; + +protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + void pauseVideoIntern(bool pause); + +private: + void queuePage(ogg_page *page); + bool queueAudio(); + int bufferData(); + void translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer); + + Common::SeekableReadStream *_fileStream; + Graphics::Surface _surface; + Graphics::Surface _displaySurface; + Common::Rational _frameRate; + double _nextFrameStartTime; + bool _endOfVideo; + bool _endOfAudio; + + Audio::Mixer::SoundType _soundType; + Audio::SoundHandle *_audHandle; + Audio::QueuingAudioStream *_audStream; + + ogg_sync_state _oggSync; + ogg_page _oggPage; + ogg_packet _oggPacket; + ogg_stream_state _vorbisOut; + ogg_stream_state _theoraOut; + th_info _theoraInfo; + th_comment _theoraComment; + th_dec_ctx *_theoraDecode; + th_setup_info *_theoraSetup; + vorbis_info _vorbisInfo; + vorbis_dsp_state _vorbisDSP; + vorbis_block _vorbisBlock; + vorbis_comment _vorbisComment; + + int _theoraPacket; + int _vorbisPacket; + + int _ppLevelMax; + int _ppLevel; + int _ppInc; + + // single audio fragment audio buffering + int _audiobufFill; + bool _audiobufReady; + ogg_int16_t *_audiobuf; +}; + +} // End of namespace Sword25 + +#endif + +#endif -- cgit v1.2.3 From a647ef3afb8535a3245014739abc643be6ebfba2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 19:41:18 +0200 Subject: WINTERMUTE: Add hacky, but working video playback --- engines/wintermute/Base/BSurface.h | 2 + engines/wintermute/Base/BSurfaceSDL.cpp | 9 ++- engines/wintermute/Base/BSurfaceSDL.h | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 79 ++++++++++++++++++---- engines/wintermute/video/VidTheoraPlayer.h | 7 +- engines/wintermute/video/decoders/theora_decoder.h | 1 + 6 files changed, 80 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index a7279a9217..046041ac6a 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BSURFACE_H #include "engines/wintermute/Base/BBase.h" +#include "graphics/surface.h" namespace WinterMute { @@ -62,6 +63,7 @@ public: virtual HRESULT Restore(); virtual HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); virtual HRESULT Create(int Width, int Height); + virtual HRESULT PutSurface(const Graphics::Surface &surface) { return E_FAIL; } virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); virtual bool ComparePixel(int X, int Y, byte R, byte G, byte B, int A = -1); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index af41231968..391b83c7bb 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -456,12 +456,12 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } -#if 0 + byte r = D3DCOLGetR(Alpha); byte g = D3DCOLGetG(Alpha); byte b = D3DCOLGetB(Alpha); byte a = D3DCOLGetA(Alpha); - +#if 0 SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); @@ -499,4 +499,9 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo return S_OK; } +HRESULT CBSurfaceSDL::PutSurface(const Graphics::Surface &surface) { + _surface->copyFrom(surface); + return S_OK; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 07c9b7cc6b..767db0fa74 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -58,7 +58,7 @@ public: HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - + virtual HRESULT PutSurface(const Graphics::Surface &surface); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 56bdcc8a8a..219dc03d69 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -19,7 +19,13 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/video/vidtheoraplayer.h" - +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/video/decoders/theora_decoder.h" +#include "common/system.h" //#pragma comment(lib, "libtheora.lib") namespace WinterMute { @@ -99,10 +105,10 @@ void CVidTheoraPlayer::SetDefaults() { CVidTheoraPlayer::~CVidTheoraPlayer(void) { Cleanup(); - SAFE_DELETE_ARRAY(_filename); +/* SAFE_DELETE_ARRAY(_filename); SAFE_DELETE_ARRAY(_alphaFilename); SAFE_DELETE(_texture); - SAFE_DELETE(_alphaImage); + SAFE_DELETE(_alphaImage);*/ // SAFE_DELETE(_subtitler); } @@ -160,6 +166,28 @@ void CVidTheoraPlayer::Cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initialize(const char *Filename, const char *SubtitleFile) { + Cleanup(); + + _file = Game->_fileManager->OpenFile(Filename); + if (!_file) return E_FAIL; + + //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); + _theoraDecoder = new TheoraDecoder(); + _theoraDecoder->loadStream(_file); + + if (!_theoraDecoder->isVideoLoaded()) + return E_FAIL; + + _state = THEORA_STATE_PAUSED; + + // Additional setup. + _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); + _texture = new CBSurfaceSDL(Game); + _texture->Create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); + _state = THEORA_STATE_PLAYING; + _playZoom = 100; + + return S_OK; #if 0 Cleanup(); @@ -346,6 +374,11 @@ HRESULT CVidTheoraPlayer::ResetStream() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { + if (_theoraDecoder) { + _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); + _state = THEORA_STATE_PLAYING; + return S_OK; + } #if 0 if (ForceZoom < 0.0f) ForceZoom = 100.0f; if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); @@ -412,6 +445,21 @@ HRESULT CVidTheoraPlayer::stop() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::update() { + if (_theoraDecoder) { + if (_theoraDecoder->endOfVideo()) { + warning("Finished movie"); + _state = THEORA_STATE_FINISHED; + } + if (_state == THEORA_STATE_PLAYING) { + if (_theoraDecoder->getTimeToNextFrame() > 0) { + _surface.copyFrom(*_theoraDecoder->decodeNextFrame()->convertTo(g_system->getScreenFormat())); + } + if (_texture) WriteVideo(); + _videoFrameReady = true; + return S_OK; + } + } + #if 0 m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; @@ -623,16 +671,17 @@ HRESULT CVidTheoraPlayer::WriteAudio() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::WriteVideo() { -#if 0 - if (!m_Texture) return E_FAIL; + if (!_texture) return E_FAIL; +#if 0 yuv_buffer yuv; theora_decode_YUVout(&m_TheoraState, &yuv); - - m_Texture->StartPixelOp(); - RenderFrame(m_Texture, &yuv); - m_Texture->EndPixelOp(); #endif + _texture->StartPixelOp(); + //RenderFrame(_texture, &yuv); + _texture->PutSurface(_surface); + _texture->EndPixelOp(); + return S_OK; } @@ -641,13 +690,13 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { RECT rc; HRESULT Res; -#if 0 - if (m_Texture) { - SetRect(&rc, 0, 0, m_Texture->GetWidth(), m_Texture->GetHeight()); - if (m_PlayZoom == 100.0f) Res = m_Texture->DisplayTrans(m_PosX, m_PosY, rc, Alpha); - else Res = m_Texture->DisplayTransZoom(m_PosX, m_PosY, rc, m_PlayZoom, m_PlayZoom, Alpha); - } else Res = E_FAIL; + if (_texture) { + CBPlatform::SetRect(&rc, 0, 0, _texture->GetWidth(), _texture->GetHeight()); + if (_playZoom == 100.0f) Res = _texture->DisplayTrans(_posX, _posY, rc, Alpha); + else Res = _texture->DisplayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, Alpha); + } else Res = E_FAIL; +#if 0 if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); #endif return Res; diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 74a094bf5c..72bb073c0f 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -24,6 +24,8 @@ #include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BSurface.h" #include "engines/wintermute/Base/BImage.h" +#include "video/video_decoder.h" +#include "common/stream.h" //#include namespace WinterMute { @@ -31,6 +33,8 @@ namespace WinterMute { class CVidTheoraPlayer : public CBBase { private: enum { THEORA_STATE_NONE = 0, THEORA_STATE_PLAYING = 1, THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; + Video::VideoDecoder *_theoraDecoder; + Graphics::Surface _surface; public: //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); @@ -59,7 +63,7 @@ public: // external objects - CBFile *_file; + Common::SeekableReadStream *_file; char *_filename; //CBSoundTheora *_sound; @@ -86,7 +90,6 @@ public: return _state == THEORA_STATE_PLAYING; }; bool IsFinished() { - return true; // HACK return _state == THEORA_STATE_FINISHED; }; bool IsPaused() { diff --git a/engines/wintermute/video/decoders/theora_decoder.h b/engines/wintermute/video/decoders/theora_decoder.h index 34a7aa32a4..79e669c068 100644 --- a/engines/wintermute/video/decoders/theora_decoder.h +++ b/engines/wintermute/video/decoders/theora_decoder.h @@ -48,6 +48,7 @@ namespace WinterMute { * Decoder for Theora videos. * Video decoder used in engines: * - sword25 + * - wintermute */ class TheoraDecoder : public Video::VideoDecoder { public: -- cgit v1.2.3 From af518b7433d1c13e476444cbaf4482313d5c9caf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 21:36:42 +0200 Subject: WINTERMUTE: Clean up Theora support quite a bit. --- engines/wintermute/Ad/AdGame.cpp | 9 +- engines/wintermute/Base/BFileManager.cpp | 64 ++--- engines/wintermute/Base/BFileManager.h | 20 +- engines/wintermute/video/VidTheoraPlayer.cpp | 406 ++++----------------------- engines/wintermute/video/VidTheoraPlayer.h | 57 ++-- 5 files changed, 116 insertions(+), 440 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 9c6c9f4174..5c87278217 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1693,18 +1693,15 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { if (!_editorMode) _renderer->SetScreenViewport(); // playing exclusive video? - if(_videoPlayer->isPlaying()) - { + if(_videoPlayer->isPlaying()) { if(Update) _videoPlayer->update(); _videoPlayer->display(); - } - else if(_theoraPlayer) - { + } else if(_theoraPlayer) { if(_theoraPlayer->isPlaying()) { if(Update) _theoraPlayer->update(); _theoraPlayer->display(); } - if(_theoraPlayer->IsFinished()) { + if(_theoraPlayer->isFinished()) { delete _theoraPlayer; _theoraPlayer = NULL; } diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index ce33e1a13c..8a13b3155a 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -116,13 +116,13 @@ HRESULT CBFileManager::Cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool MustExist) { +byte *CBFileManager::ReadWholeFile(const Common::String &Filename, uint32 *Size, bool MustExist) { byte *buffer = NULL; Common::SeekableReadStream *File = OpenFile(Filename); if (!File) { - if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename); + if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename.c_str()); return NULL; } @@ -137,13 +137,13 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must buffer = new byte[File->size() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename, File->size() + 1); + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename.c_str(), File->size() + 1); CloseFile(File); return NULL; } if (File->read(buffer, File->size()) != File->size()) { - Game->LOG(0, "Error reading file '%s'", Filename); + Game->LOG(0, "Error reading file '%s'", Filename.c_str()); CloseFile(File); delete [] buffer; return NULL; @@ -158,7 +158,7 @@ byte *CBFileManager::ReadWholeFile(const char *Filename, uint32 *Size, bool Must ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); #if 0 @@ -226,15 +226,15 @@ HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::AddPath(TPathType Type, const char *Path) { - if (Path == NULL || strlen(Path) < 1) return E_FAIL; +HRESULT CBFileManager::AddPath(TPathType Type, const Common::String &Path) { + if (Path.c_str() == NULL || strlen(Path.c_str()) < 1) return E_FAIL; - bool slashed = (Path[strlen(Path) - 1] == '\\' || Path[strlen(Path) - 1] == '/'); + bool slashed = (Path[Path.size() - 1] == '\\' || Path[Path.size() - 1] == '/'); - char *buffer = new char [strlen(Path) + 1 + (slashed ? 0 : 1)]; + char *buffer = new char [strlen(Path.c_str()) + 1 + (slashed ? 0 : 1)]; if (buffer == NULL) return E_FAIL; - strcpy(buffer, Path); + strcpy(buffer, Path.c_str()); if (!slashed) strcat(buffer, "\\"); //CBPlatform::strlwr(buffer); @@ -381,7 +381,7 @@ HRESULT CBFileManager::RegisterPackages() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackage(Common::String Filename , bool SearchSignature) { +HRESULT CBFileManager::RegisterPackage(const Common::String &Filename , bool SearchSignature) { // FILE *f = fopen(Filename, "rb"); Common::File *package = new Common::File(); package->open(Filename); @@ -651,7 +651,7 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenPackage(const char *Name) { +Common::File *CBFileManager::OpenPackage(const Common::String &Name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -660,33 +660,33 @@ Common::File *CBFileManager::OpenPackage(const char *Name) { char Filename[MAX_PATH]; for (int i = 0; i < _packagePaths.GetSize(); i++) { - sprintf(Filename, "%s%s.%s", _packagePaths[i], Name, PACKAGE_EXTENSION); + sprintf(Filename, "%s%s.%s", _packagePaths[i], Name.c_str(), PACKAGE_EXTENSION); ret->open(Filename); if (ret->isOpen()) { return ret; } } - sprintf(Filename, "%s.%s", Name, PACKAGE_EXTENSION); + sprintf(Filename, "%s.%s", Name.c_str(), PACKAGE_EXTENSION); ret->open(Filename); if (ret->isOpen()) { return ret; } - warning("CBFileManager::OpenPackage - Couldn't load file %s", Name); + warning("CBFileManager::OpenPackage - Couldn't load file %s", Name.c_str()); delete ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenSingleFile(const char *Name) { +Common::File *CBFileManager::OpenSingleFile(const Common::String &Name) { RestoreCurrentDir(); Common::File *ret = NULL; char Filename[MAX_PATH]; for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Filename, "%s%s", _singlePaths[i], Name); + sprintf(Filename, "%s%s", _singlePaths[i], Name.c_str()); ret->open(Filename); if (ret->isOpen()) return ret; @@ -704,14 +704,14 @@ Common::File *CBFileManager::OpenSingleFile(const char *Name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { +bool CBFileManager::GetFullPath(const Common::String &filename, char *Fullname) { RestoreCurrentDir(); Common::File f; bool found = false; for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Fullname, "%s%s", _singlePaths[i], Filename); + sprintf(Fullname, "%s%s", _singlePaths[i], filename.c_str()); f.open(Fullname); if (f.isOpen()) { f.close(); @@ -721,11 +721,11 @@ bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { } if (!found) { - f.open(Filename); + f.open(filename.c_str()); if (f.isOpen()) { f.close(); found = true; - strcpy(Fullname, Filename); + strcpy(Fullname, filename.c_str()); } } @@ -734,9 +734,9 @@ bool CBFileManager::GetFullPath(const char *Filename, char *Fullname) { ////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { - char *upc_name = new char[strlen(Filename) + 1]; - strcpy(upc_name, Filename); +CBFileEntry *CBFileManager::GetPackageEntry(const Common::String &Filename) { + char *upc_name = new char[strlen(Filename.c_str()) + 1]; + strcpy(upc_name, Filename.c_str()); CBPlatform::strupr(upc_name); CBFileEntry *ret = NULL; @@ -750,8 +750,8 @@ CBFileEntry *CBFileManager::GetPackageEntry(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::OpenFile(const char *Filename, bool AbsPathWarning) { - if (strcmp(Filename, "") == 0) return NULL; +Common::SeekableReadStream *CBFileManager::OpenFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) return NULL; //Game->LOG(0, "open file: %s", Filename); /*#ifdef __WIN32__ if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { @@ -763,8 +763,8 @@ Common::SeekableReadStream *CBFileManager::OpenFile(const char *Filename, bool A } #endif*/ - Common::SeekableReadStream *File = OpenFileRaw(Filename); - if (File) _openFiles.Add(File); + Common::SeekableReadStream *File = OpenFileRaw(filename); + if (File && keepTrackOf) _openFiles.Add(File); return File; } @@ -824,12 +824,12 @@ HRESULT CBFileManager::RestoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SetBasePath(const char *Path) { +HRESULT CBFileManager::SetBasePath(const Common::String &Path) { Cleanup(); - if (Path) { - _basePath = new char[strlen(Path) + 1]; - strcpy(_basePath, Path); + if (Path.c_str()) { + _basePath = new char[Path.size() + 1]; + strcpy(_basePath, Path.c_str()); } InitPaths(); diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 77f99c8570..533575c1ba 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -46,26 +46,26 @@ class CBFileManager: CBBase { public: bool FindPackageSignature(Common::File *f, uint32 *Offset); HRESULT Cleanup(); - HRESULT SetBasePath(const char *Path); + HRESULT SetBasePath(const Common::String &path); HRESULT RestoreCurrentDir(); char *_basePath; - bool GetFullPath(const char *Filename, char *Fullname); + bool GetFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *OpenFileRaw(const Common::String &filename); HRESULT CloseFile(Common::SeekableReadStream *File); - Common::SeekableReadStream *OpenFile(const char *Filename, bool AbsPathWarning = true); - CBFileEntry *GetPackageEntry(const char *Filename); - Common::File *OpenSingleFile(const char *Name); - Common::File *OpenPackage(const char *Name); + Common::SeekableReadStream *OpenFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *GetPackageEntry(const Common::String &filename); + Common::File *OpenSingleFile(const Common::String &name); + Common::File *OpenPackage(const Common::String &name); HRESULT RegisterPackages(); HRESULT InitPaths(); HRESULT ReloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - HRESULT AddPath(TPathType Type, const char *Path); + HRESULT AddPath(TPathType Type, const Common::String &path); HRESULT RequestCD(int CD, char *PackageFile, char *Filename); - HRESULT SaveFile(const char *Filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); - byte *ReadWholeFile(const char *Filename, uint32 *Size = NULL, bool MustExist = true); + HRESULT SaveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); + byte *ReadWholeFile(const Common::String &filename, uint32 *Size = NULL, bool MustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); CBArray _singlePaths; @@ -76,7 +76,7 @@ public: Common::HashMap _files; private: HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); - HRESULT RegisterPackage(Common::String Filename, bool SearchSignature = false); + HRESULT RegisterPackage(const Common::String &filename, bool SearchSignature = false); Common::HashMap::iterator _filesIter; bool IsValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 219dc03d69..555f0b7f32 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -39,13 +39,12 @@ CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// void CVidTheoraPlayer::SetDefaults() { -#if 0 + _file = NULL; - _filename = NULL; + _filename = ""; _startTime = 0; _looping = false; - _sound = NULL; - _audiobufGranulepos = 0; + _freezeGame = false; _currentTime = 0; @@ -55,9 +54,6 @@ void CVidTheoraPlayer::SetDefaults() { _audioFrameReady = false; _videobufTime = 0; - _audioBuf = NULL; - _audioBufFill = 0; - _audioBufSize = 0; _playbackStarted = false; _dontDropFrames = false; @@ -67,43 +63,28 @@ void CVidTheoraPlayer::SetDefaults() { _frameRendered = false; - -/* memset(&m_OggSyncState, 0, sizeof(ogg_sync_state)); - memset(&m_OggPage, 0, sizeof(ogg_page)); - memset(&m_VorbisStreamState, 0 , sizeof(ogg_stream_state)); - memset(&m_TheoraStreamState, 0 , sizeof(ogg_stream_state)); - - memset(&m_TheoraInfo, 0, sizeof(theora_info)); - memset(&m_TheoraComment, 0, sizeof(theora_comment)); - memset(&m_TheoraState, 0, sizeof(theora_state)); - - memset(&m_VorbisInfo, 0, sizeof(vorbis_info)); - memset(&m_VorbisDSPState, 0, sizeof(vorbis_dsp_state)); - memset(&m_VorbisBlock, 0, sizeof(vorbis_block)); - memset(&m_VorbisComment, 0, sizeof(vorbis_comment));*/ - - _vorbisStreams = _theoraStreams = 0; - - GenLookupTables(); - _seekingKeyframe = false; _timeOffset = 0.0f; - + _posX = _posY = 0; _playbackType = VID_PLAY_CENTER; _playZoom = 0.0f; - - _subtitler = NULL; - + _savedState = THEORA_STATE_NONE; _savedPos = 0; _volume = 100; +#if 0 + _vorbisStreams = _theoraStreams = 0; + + GenLookupTables(); + + _subtitler = NULL; #endif } ////////////////////////////////////////////////////////////////////////// CVidTheoraPlayer::~CVidTheoraPlayer(void) { - Cleanup(); + cleanup(); /* SAFE_DELETE_ARRAY(_filename); SAFE_DELETE_ARRAY(_alphaFilename); @@ -113,37 +94,13 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { } ////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::Cleanup() { +void CVidTheoraPlayer::cleanup() { #if 0 - if (_vorbisStreams) { - ogg_stream_clear(&m_VorbisStreamState); - vorbis_block_clear(&m_VorbisBlock); - vorbis_dsp_clear(&m_VorbisDSPState); - vorbis_comment_clear(&m_VorbisComment); - vorbis_info_clear(&m_VorbisInfo); - - _vorbisStreams = 0; - } - if (m_TheoraStreams) { - ogg_stream_clear(&m_TheoraStreamState); - theora_clear(&m_TheoraState); - theora_comment_clear(&m_TheoraComment); - theora_info_clear(&m_TheoraInfo); - - m_TheoraStreams = 0; - } - ogg_sync_clear(&m_OggSyncState); - - - if (m_File) Game->m_FileManager->CloseFile(m_File); - m_File = NULL; - if (m_Sound) { Game->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; } - SAFE_DELETE_ARRAY(m_AudioBuf); m_AudioBufFill = 0; m_AudioBufSize = 0; @@ -151,24 +108,10 @@ void CVidTheoraPlayer::Cleanup() { } ////////////////////////////////////////////////////////////////////////// -/*int CVidTheoraPlayer::BufferData(ogg_sync_state *OggSyncState) { - if (!_file) return 0; - - DWORD Size = 4096; - if (m_File->GetSize() - m_File->GetPos() < Size) Size = m_File->GetSize() - m_File->GetPos(); - - char *Buffer = ogg_sync_buffer(OggSyncState, Size); - m_File->Read(Buffer, Size); - ogg_sync_wrote(OggSyncState, Size); - - return Size; -}*/ - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::initialize(const char *Filename, const char *SubtitleFile) { - Cleanup(); +HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { + cleanup(); - _file = Game->_fileManager->OpenFile(Filename); + _file = Game->_fileManager->OpenFile(filename, true, false); if (!_file) return E_FAIL; //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); @@ -361,7 +304,7 @@ HRESULT CVidTheoraPlayer::initialize(const char *Filename, const char *SubtitleF ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::ResetStream() { +HRESULT CVidTheoraPlayer::resetStream() { #if 0 if (_sound) _sound->Stop(); @@ -451,11 +394,13 @@ HRESULT CVidTheoraPlayer::update() { _state = THEORA_STATE_FINISHED; } if (_state == THEORA_STATE_PLAYING) { - if (_theoraDecoder->getTimeToNextFrame() > 0) { - _surface.copyFrom(*_theoraDecoder->decodeNextFrame()->convertTo(g_system->getScreenFormat())); + if (_theoraDecoder->getTimeToNextFrame() == 0) { + _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); + _videoFrameReady = true; + } + if (_texture && _videoFrameReady) { + WriteVideo(); } - if (_texture) WriteVideo(); - _videoFrameReady = true; return S_OK; } } @@ -540,109 +485,18 @@ HRESULT CVidTheoraPlayer::update() { return S_OK; } - -////////////////////////////////////////////////////////////////////////// -/*int CVidTheoraPlayer::StreamInData() { -#if 0 - // no data yet for somebody. Grab another page - int BytesRead = BufferData(&m_OggSyncState); - while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - } - return BytesRead; -#endif -}*/ - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::DecodeVorbis() { -#if 0 - if (!m_Sound) return; - - while (m_VorbisStreams && !m_AudioFrameReady) { - int ret; - float **pcm; - - // if there's pending, decoded audio, grab it - if ((ret = vorbis_synthesis_pcmout(&m_VorbisDSPState, &pcm)) > 0 && !m_SeekingKeyframe) { - int count = m_AudioBufFill / 2; - int maxsamples = (m_AudioBufSize - m_AudioBufFill) / 2 / m_VorbisInfo.channels; - - int i; - for (i = 0; i < ret && i < maxsamples; i++) - for (int j = 0; j < m_VorbisInfo.channels; j++) { - int val = (int)(pcm[j][i] * 32767.f); - if (val > 32767) val = 32767; - if (val < -32768) val = -32768; - - m_AudioBuf[count++] = val; - } - vorbis_synthesis_read(&m_VorbisDSPState, i); - m_AudioBufFill += i * m_VorbisInfo.channels * 2; - if (m_AudioBufFill == m_AudioBufSize) m_AudioFrameReady = true; - if (m_VorbisDSPState.granulepos >= 0) - m_AudiobufGranulepos = m_VorbisDSPState.granulepos - ret + i; - else - m_AudiobufGranulepos += i; - } else { - ogg_packet opVorbis; - - //no pending audio; is there a pending packet to decode? - if (ogg_stream_packetout(&m_VorbisStreamState, &opVorbis) > 0) { - //test for success! - if (vorbis_synthesis(&m_VorbisBlock, &opVorbis) == 0) - vorbis_synthesis_blockin(&m_VorbisDSPState, &m_VorbisBlock); - } else { //we need more data; break out to suck in another page - break; - } - } - } // while -#endif -} - - ////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::DecodeTheora() { -#if 0 - ogg_packet opTheora; - - while (m_TheoraStreams && !m_VideoFrameReady) { - // theora is one in, one out... - if (ogg_stream_packetout(&m_TheoraStreamState, &opTheora) > 0) { - theora_decode_packetin(&m_TheoraState, &opTheora); - m_VideobufTime = theora_granule_time(&m_TheoraState, m_TheoraState.granulepos); - - if (m_SeekingKeyframe) { - if (!theora_packet_iskeyframe(&opTheora)) continue; - else { - m_SeekingKeyframe = false; - m_TimeOffset = m_VideobufTime; - } - } - - if (m_VideobufTime >= GetMovieTime() || m_DontDropFrames) m_VideoFrameReady = true; - } else { - break; - } +float CVidTheoraPlayer::getMovieTime() { + if (!_playbackStarted) { + return 0.0f; + } else { + return _theoraDecoder->getTime(); } -#endif -} - -////////////////////////////////////////////////////////////////////////// -float CVidTheoraPlayer::GetMovieTime() { -#if 0 - if (!m_PlaybackStarted) return 0.0f; - else if (m_Sound) return (float)(m_Sound->GetPosition()) / 1000.0f + m_TimeOffset; - else return (float)(m_CurrentTime - m_StartTime) / 1000.0f + m_TimeOffset; -#endif - return 0; } ////////////////////////////////////////////////////////////////////////// -int CVidTheoraPlayer::GetMovieFrame() { +int CVidTheoraPlayer::getMovieFrame() { #if 0 if (!m_TheoraStreams) return 0; float Time = GetMovieTime(); @@ -652,31 +506,10 @@ int CVidTheoraPlayer::GetMovieFrame() { return 0; } - -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::WriteAudio() { -#if 0 - if (m_AudioFrameReady) { - if (m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize)) { - m_AudioBufFill = 0; - m_AudioFrameReady = false; - } - } else if (m_File->IsEOF()) { - memset(m_AudioBuf, 0, m_AudioBufSize); - m_Sound->WriteBlock((BYTE *)m_AudioBuf, m_AudioBufSize); - } -#endif - return S_OK; -} - ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::WriteVideo() { - if (!_texture) return E_FAIL; -#if 0 - yuv_buffer yuv; - theora_decode_YUVout(&m_TheoraState, &yuv); -#endif + _texture->StartPixelOp(); //RenderFrame(_texture, &yuv); _texture->PutSurface(_surface); @@ -703,143 +536,8 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { } ////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::GenLookupTables() { - //used to bring the table into the high side (scale up) so we - //can maintain high precision and not use floats (FIXED POINT) - int scale = 1L << 13; - int temp; - - for (unsigned int i = 0; i < 256; i++) { - temp = i - 128; - - _yTable[i] = (unsigned int)((1.164 * scale + 0.5) * (i - 16)); //Calc Y component - - _rVTable[i] = (unsigned int)((1.596 * scale + 0.5) * temp); //Calc R component - - _gUTable[i] = (unsigned int)((0.391 * scale + 0.5) * temp); //Calc G u & v components - _gVTable[i] = (unsigned int)((0.813 * scale + 0.5) * temp); - - _bUTable[i] = (unsigned int)((2.018 * scale + 0.5) * temp); //Calc B component - } -} - -#define CLIP_RGB_COLOR( rgb_color_test ) max( min(rgb_color_test, 255), 0 ) -////////////////////////////////////////////////////////////////////////// -#if 0 -HRESULT CVidTheoraPlayer::RenderFrame(CBSurface *Texture, yuv_buffer *yuv) { - //Convert 4:2:0 YUV YCrCb to an RGB24 Bitmap - //convenient pointers - int TargetX1 = 0; - int TargetX2 = 1; - int TargetY1 = 0; - int TargetY2 = 1; - - unsigned char *ySrc = (unsigned char *)yuv->y; - unsigned char *uSrc = (unsigned char *)yuv->u; - unsigned char *vSrc = (unsigned char *)yuv->v; - unsigned char *ySrc2 = ySrc + yuv->y_stride; - - //Calculate buffer offset - int yOff = (yuv->y_stride * 2) - yuv->y_width; - - - //Check if upside down, if so, reverse buffers and offsets - if (yuv->y_height < 0) { - yuv->y_height = -yuv->y_height; - ySrc += (yuv->y_height - 1) * yuv->y_stride; - - uSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; - vSrc += ((yuv->y_height / 2) - 1) * yuv->uv_stride; - - ySrc2 = ySrc - yuv->y_stride; - yOff = -yuv->y_width - (yuv->y_stride * 2); - - yuv->uv_stride = -yuv->uv_stride; - } - - //Cut width and height in half (uv field is only half y field) - yuv->y_height = yuv->y_height >> 1; - yuv->y_width = yuv->y_width >> 1; - - //Convientient temp vars - signed int r, g, b, u, v, bU, gUV, rV, rgbY; - int x; - - //Loop does four blocks per iteration (2 rows, 2 pixels at a time) - for (int y = yuv->y_height; y > 0; --y) { - for (x = 0; x < yuv->y_width; ++x) { - //Get uv pointers for row - u = uSrc[x]; - v = vSrc[x]; - - //get corresponding lookup values - rgbY = m_YTable[*ySrc]; - rV = m_RVTable[v]; - gUV = m_GUTable[u] + m_GVTable[v]; - bU = m_BUTable[u]; - ++ySrc; - - //scale down - brings are values back into the 8 bits of a byte - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX1, TargetY1, r, g, b, GetAlphaAt(TargetX1, TargetY1)); - - //And repeat for other pixels (note, y is unique for each - //pixel, while uv are not) - rgbY = m_YTable[*ySrc]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX2, TargetY1, r, g, b, GetAlphaAt(TargetX2, TargetY1)); - ++ySrc; - - rgbY = m_YTable[*ySrc2]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX1, TargetY2, r, g, b, GetAlphaAt(TargetX1, TargetY2)); - ++ySrc2; - - rgbY = m_YTable[*ySrc2]; - r = CLIP_RGB_COLOR((rgbY + rV) >> 13); - g = CLIP_RGB_COLOR((rgbY - gUV) >> 13); - b = CLIP_RGB_COLOR((rgbY + bU) >> 13); - Texture->PutPixel(TargetX2, TargetY2, r, g, b, GetAlphaAt(TargetX2, TargetY2)); - ++ySrc2; - - /* - Texture->PutPixel(TargetX1, TargetY1, 255, 0, 0, GetAlphaAt(TargetX1, TargetY1)); - Texture->PutPixel(TargetX2, TargetY1, 255, 0, 0, GetAlphaAt(TargetX2, TargetY1)); - Texture->PutPixel(TargetX1, TargetY2, 255, 0, 0, GetAlphaAt(TargetX1, TargetY2)); - Texture->PutPixel(TargetX2, TargetY2, 255, 0, 0, GetAlphaAt(TargetX2, TargetY2)); - */ - - - //Advance inner loop offsets - TargetX1 += 2; - TargetX2 += 2; - } // end for x - - //Advance destination pointers by offsets - TargetX1 = 0; - TargetX2 = 1; - TargetY1 += 2; - TargetY2 += 2; - - ySrc += yOff; - ySrc2 += yOff; - uSrc += yuv->uv_stride; - vSrc += yuv->uv_stride; - } //end for y - - m_FrameRendered = true; - - return S_OK; -} -#endif -////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::SetAlphaImage(const char *Filename) { +HRESULT CVidTheoraPlayer::setAlphaImage(const char *filename) { + warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename); #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); @@ -855,7 +553,7 @@ HRESULT CVidTheoraPlayer::SetAlphaImage(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -byte CVidTheoraPlayer::GetAlphaAt(int X, int Y) { +byte CVidTheoraPlayer::getAlphaAt(int X, int Y) { #if 0 if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); else return 0xFF; @@ -876,7 +574,8 @@ inline int intlog(int num) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::SeekToTime(uint32 Time) { +HRESULT CVidTheoraPlayer::SeekToTime(uint32 time) { + warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); #if 0 if (!m_TheoraStreams) return E_FAIL; @@ -940,26 +639,24 @@ finish: ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::pause() { -#if 0 - if (m_State == THEORA_STATE_PLAYING) { - m_State = THEORA_STATE_PAUSED; - if (m_Sound) m_Sound->Pause(); + if (_state == THEORA_STATE_PLAYING) { + _state = THEORA_STATE_PAUSED; + _theoraDecoder->pauseVideo(true); return S_OK; - } else return E_FAIL; -#endif - return 0; + } else { + return E_FAIL; + } } ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::resume() { -#if 0 if (_state == THEORA_STATE_PAUSED) { _state = THEORA_STATE_PLAYING; - if (_sound) _sound->Resume(); + _theoraDecoder->pauseVideo(false); return S_OK; - } else return E_FAIL; -#endif - return 0; + } else { + return E_FAIL; + } } ////////////////////////////////////////////////////////////////////////// @@ -995,17 +692,16 @@ HRESULT CVidTheoraPlayer::resume() { */ ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initializeSimple() { -#if 0 - if (SUCCEEDED(Initialize(m_Filename))) { - if (m_AlphaFilename) SetAlphaImage(m_AlphaFilename); - Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, m_SavedPos, m_PlayZoom); - } else m_State = THEORA_STATE_FINISHED; -#endif + if (SUCCEEDED(initialize(_filename))) { + if (_alphaFilename) setAlphaImage(_alphaFilename); + play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); + } else _state = THEORA_STATE_FINISHED; + return S_OK; } ////////////////////////////////////////////////////////////////////////// -CBSurface *CVidTheoraPlayer::GetTexture() { +CBSurface *CVidTheoraPlayer::getTexture() { return _texture; } diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 72bb073c0f..a27ce04042 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -54,28 +54,28 @@ public: vorbis_info m_VorbisInfo; vorbis_dsp_state m_VorbisDSPState; vorbis_block m_VorbisBlock; - vorbis_comment m_VorbisComment;*/ + vorbis_comment m_VorbisComment; int _theoraStreams; - int _vorbisStreams; + int _vorbisStreams;*/ //ogg_int64_t m_AudiobufGranulepos; //time position of last sample // external objects Common::SeekableReadStream *_file; - char *_filename; + Common::String _filename; //CBSoundTheora *_sound; //ogg_int16_t *_audioBuf; - int _audioBufSize; - int _audioBufFill; + /*int _audioBufSize; + int _audioBufFill;*/ CBSurface *_texture; //CVidSubtitler *_subtitler; // control methods - HRESULT initialize(const char *Filename, const char *SubtitleFile = NULL); + HRESULT initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); HRESULT initializeSimple(); HRESULT update(); HRESULT play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); @@ -89,17 +89,17 @@ public: bool isPlaying() { return _state == THEORA_STATE_PLAYING; }; - bool IsFinished() { + bool isFinished() { return _state == THEORA_STATE_FINISHED; }; - bool IsPaused() { + bool isPaused() { return _state == THEORA_STATE_PAUSED; }; - float GetMovieTime(); - int GetMovieFrame(); + float getMovieTime(); + int getMovieFrame(); - CBSurface *GetTexture(); + CBSurface *getTexture(); int _state; uint32 _startTime; @@ -111,17 +111,17 @@ public: // alpha related CBImage *_alphaImage; char *_alphaFilename; - HRESULT SetAlphaImage(const char *Filename); - __inline byte GetAlphaAt(int X, int Y); + HRESULT setAlphaImage(const char *Filename); + __inline byte getAlphaAt(int X, int Y); HRESULT SeekToTime(uint32 Time); - void Cleanup(); - HRESULT ResetStream(); + void cleanup(); + HRESULT resetStream(); // video properties - TVideoPlayback m_PlaybackType; + TVideoPlayback _playbackType; int _posX; int _posY; float _playZoom; @@ -134,37 +134,20 @@ public: private: - // data streaming - //int BufferData(ogg_sync_state *OggSyncState); - //int StreamInData(); - - - // lookup tables - unsigned int _yTable[256]; - unsigned int _bUTable[256]; - unsigned int _gUTable[256]; - unsigned int _gVTable[256]; - unsigned int _rVTable[256]; - - void GenLookupTables(); - - // seeking support bool _seekingKeyframe; float _timeOffset; bool _frameRendered; - - // decoding - void DecodeVorbis(); - void DecodeTheora(); - + void getIsFrameReady() { + return _videoFrameReady; + } +private: bool _audioFrameReady; bool _videoFrameReady; float _videobufTime; - HRESULT WriteAudio(); HRESULT WriteVideo(); bool _playbackStarted; -- cgit v1.2.3 From 071c5a1d83e4da25e0d91f2d957a0bafed1cb341 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 01:15:49 +0200 Subject: WINTERMUTE: Add detection for the J.U.L.I.A.-demo --- engines/wintermute/detection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 0ae305eb23..d7eb48e4be 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -62,6 +62,17 @@ static const ADGameDescription gameDescriptions[] = { ADGF_USEEXTRAASTITLE, GUIO0() }, + { + "wintermute", + "J.U.L.I.A. Demo", + AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE | + ADGF_DEMO, + GUIO0() + }, AD_TABLE_END_MARKER }; -- cgit v1.2.3 From 9f66bed4b5517ffdf3caaa13a9f08f049ad2e08e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 01:16:20 +0200 Subject: WINTERMUTE: Don't delete the fonts gotten from FontMan, they are const. --- engines/wintermute/Base/BFontTT.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index e18279a73d..d1fad44c64 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -87,9 +87,6 @@ CBFontTT::~CBFontTT(void) { delete _font; _font = NULL; - delete _fallbackFont; - _fallbackFont = NULL; - delete _glyphCache; _glyphCache = NULL; #if 0 -- cgit v1.2.3 From f0a0f5c35c2571bcd6e1e26392d381d64092a1df Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 02:32:13 +0200 Subject: WINTERMUTE: Actually register all DCPs. --- engines/wintermute/Base/BFileManager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 8a13b3155a..9b0789fd1b 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -343,8 +343,14 @@ HRESULT CBFileManager::RegisterPackages() { warning("Scanning packages"); // TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. - RegisterPackage("data.dcp"); - RegisterPackage("english.dcp"); + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.dcp"); + int size = files.size(); + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + RegisterPackage((*it)->getName().c_str()); + } +/* RegisterPackage("data.dcp"); + RegisterPackage("english.dcp");*/ #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); -- cgit v1.2.3 From 15796f0eed66eb0e9e923ff2c59ce551ec518103 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 02:32:36 +0200 Subject: WINTERMUTE: Add JPEG-support to BSurfaceSDL --- engines/wintermute/Base/BSurfaceSDL.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 391b83c7bb..8406985be8 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -34,6 +34,7 @@ //#include "SdlUtil.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" +#include "graphics/decoders/jpeg.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "engines/wintermute/graphics/transparentSurface.h" @@ -81,6 +82,8 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, imgDecoder = new Graphics::BitmapDecoder(); } else if (strFileName.hasSuffix(".tga")) { imgDecoder = new WinterMute::TGA(); + } else if (strFileName.hasSuffix(".jpg")) { + imgDecoder = new Graphics::JPEGDecoder(); } else { error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); } -- cgit v1.2.3 From 9a3fdd4cc431ab4787979cec0ecc696a338bafb6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 02:33:10 +0200 Subject: WINTERMUTE: Make Theora-playback behave a bit more as expected. --- engines/wintermute/video/VidTheoraPlayer.cpp | 83 +++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 555f0b7f32..05691d8fdb 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -22,6 +22,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/video/decoders/theora_decoder.h" @@ -317,20 +318,63 @@ HRESULT CVidTheoraPlayer::resetStream() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { + if (ForceZoom < 0.0f) + ForceZoom = 100.0f; + if (Volume < 0) + _volume = Game->_soundMgr->getVolumePercent(SOUND_SFX); + else _volume = Volume; + + _freezeGame = FreezeGame; + + if (!_playbackStarted && _freezeGame) + Game->Freeze(FreezeMusic); + + _playbackStarted = false; + float Width, Height; if (_theoraDecoder) { _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); _state = THEORA_STATE_PLAYING; - return S_OK; + _looping = Looping; + _playbackType = Type; + + _startTime = StartTime; + _volume = Volume; + _posX = X; + _posY = Y; + _playZoom = ForceZoom; + + Width = (float)_theoraDecoder->getWidth(); + Height = (float)_theoraDecoder->getHeight(); + } else { + Width = (float)Game->_renderer->_width; + Height = (float)Game->_renderer->_height; } -#if 0 - if (ForceZoom < 0.0f) ForceZoom = 100.0f; - if (Volume < 0) m_Volume = Game->m_SoundMgr->GetVolumePercent(SOUND_SFX); - else m_Volume = Volume; - m_FreezeGame = FreezeGame; - if (!m_PlaybackStarted && m_FreezeGame) Game->Freeze(FreezeMusic); + switch (Type) { + case VID_PLAY_POS: + _playZoom = ForceZoom; + _posX = X; + _posY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->_renderer->_width / Width * 100); + float ZoomY = (float)((float)Game->_renderer->_height / Height * 100); + _playZoom = MIN(ZoomX, ZoomY); + _posX = (Game->_renderer->_width - Width * (_playZoom / 100)) / 2; + _posY = (Game->_renderer->_height - Height * (_playZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _posX = (Game->_renderer->_width - Width) / 2; + _posY = (Game->_renderer->_height - Height) / 2; + break; + } + return S_OK; +#if 0 - m_PlaybackStarted = false; m_State = THEORA_STATE_PLAYING; m_Looping = Looping; @@ -388,10 +432,21 @@ HRESULT CVidTheoraPlayer::stop() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::update() { + _currentTime = _freezeGame ? Game->_liveTimer : Game->_timer; + + if (!isPlaying()) return S_OK; + + if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return S_OK; + + if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return S_OK; + + int Counter = 0; if (_theoraDecoder) { if (_theoraDecoder->endOfVideo()) { warning("Finished movie"); _state = THEORA_STATE_FINISHED; + _playbackStarted = false; + if (_freezeGame) Game->Unfreeze(); } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { @@ -404,6 +459,18 @@ HRESULT CVidTheoraPlayer::update() { return S_OK; } } + // Skip the busy-loop? + if ((!_texture || !_videoFrameReady) && !_theoraDecoder->endOfVideo()) { + // end playback + if (!_looping) { + _state = THEORA_STATE_FINISHED; + if (_freezeGame) Game->Unfreeze(); + return S_OK; + } else { + resetStream(); + return S_OK; + } + } #if 0 m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; -- cgit v1.2.3 From ca1e62035d690ee3a3d16e02d2e75512ef3870b7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 02:52:33 +0200 Subject: WINTERMUTE: Add back Theora support to AdEntity. --- engines/wintermute/Ad/AdEntity.cpp | 55 ++++++++++++++++++++++++++++++++------ engines/wintermute/Ad/AdEntity.h | 3 ++- 2 files changed, 49 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index c8a40f857d..827209b120 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -50,6 +50,7 @@ #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" #include "common/str.h" namespace WinterMute { @@ -65,6 +66,8 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { _walkToX = _walkToY = 0; _walkToDir = DI_NONE; + + _theora = NULL; } @@ -72,6 +75,9 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { CAdEntity::~CAdEntity() { Game->UnregisterObject(_region); + delete _theora; + _theora = NULL; + delete[] _item; _item = NULL; } @@ -578,7 +584,7 @@ HRESULT CAdEntity::Update() { } break; default: - error("AdEntity::Update - Unhandled enum"); + warning("AdEntity::Update - Unhandled enum"); } @@ -620,8 +626,23 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(false); + Stack->CorrectParams(4); + const char* Filename = Stack->Pop()->GetString(); + bool Looping = Stack->Pop()->GetBool(false); + CScValue* ValAlpha = Stack->Pop(); + int StartTime = Stack->Pop()->GetInt(); + + delete _theora; + _theora = new CVidTheoraPlayer(Game); + if(_theora && SUCCEEDED(_theora->initialize(Filename))) { + if(!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); + _theora->play(VID_PLAY_POS, 0, 0, false, false, Looping, StartTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); + //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; + Stack->PushBool(true); + } else { + Script->RuntimeError("Entity.PlayTheora - error playing video '%s'", Filename); + Stack->PushBool(false); + } return S_OK; } @@ -631,7 +652,13 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StopTheora") == 0) { Stack->CorrectParams(0); - Stack->PushBool(false); + if(_theora) { + _theora->stop(); + delete _theora; + _theora = NULL; + Stack->PushBool(true); + } + else Stack->PushBool(false); return S_OK; } @@ -641,7 +668,8 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsTheoraPlaying") == 0) { Stack->CorrectParams(0); - Stack->PushBool(false); + if(_theora && _theora->isPlaying()) Stack->PushBool(true); + else Stack->PushBool(false); return S_OK; } @@ -651,7 +679,11 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PauseTheora") == 0) { Stack->CorrectParams(0); - Stack->PushBool(false); + if(_theora && _theora->isPlaying()) { + _theora->pause(); + Stack->PushBool(true); + } + else Stack->PushBool(false); return S_OK; } @@ -661,7 +693,11 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ResumeTheora") == 0) { Stack->CorrectParams(0); - Stack->PushBool(false); + if(_theora && _theora->isPaused()) { + _theora->resume(); + Stack->PushBool(true); + } + else Stack->PushBool(false); return S_OK; } @@ -671,7 +707,8 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsTheoraPaused") == 0) { Stack->CorrectParams(0); - Stack->PushBool(false); + if(_theora && _theora->isPaused()) Stack->PushBool(true); + else Stack->PushBool(false); return S_OK; } @@ -943,6 +980,8 @@ HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_walkToY)); PersistMgr->Transfer(TMEMBER_INT(_walkToDir)); + PersistMgr->Transfer(TMEMBER(_theora)); + return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 071ad5ee5d..e8a55a16aa 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -32,9 +32,10 @@ #include "engines/wintermute/Ad/AdTalkHolder.h" namespace WinterMute { - +class CVidTheoraPlayer; class CAdEntity : public CAdTalkHolder { public: + CVidTheoraPlayer* _theora; HRESULT SetSprite(const char *Filename); int _walkToX; int _walkToY; -- cgit v1.2.3 From d79549964c23336dd609702defb9ac740ab971ff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 03:16:57 +0200 Subject: WINTERMUTE: Make the engine atleast register keypresses. --- engines/wintermute/Base/BGame.cpp | 12 ++++++------ engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BObject.h | 5 ++--- engines/wintermute/PlatformSDL.cpp | 2 ++ engines/wintermute/UI/UIWindow.cpp | 6 ++---- engines/wintermute/UI/UIWindow.h | 3 ++- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3a4e88a612..33bfc8956a 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3793,22 +3793,22 @@ bool CBGame::HandleKeypress(Common::Event *event) { _keyboardState->ReadKey(event); // TODO -#if 0 + if (_focusedWindow) { if (!Game->_focusedWindow->HandleKeypress(event)) { - if (event->type != SDL_TEXTINPUT) { + /*if (event->type != SDL_TEXTINPUT) {*/ if (Game->_focusedWindow->CanHandleEvent("Keypress")) Game->_focusedWindow->ApplyEvent("Keypress"); else ApplyEvent("Keypress"); - } + /*}*/ } return true; - } else if (event->type != SDL_TEXTINPUT) { + } else /*if (event->type != SDL_TEXTINPUT)*/ { ApplyEvent("Keypress"); return true; - } else return true; -#endif + } //else return true; + return false; } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 046f31e4ac..9f34541087 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -960,7 +960,7 @@ HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleKeypress(SDL_Event *event) { +bool CBObject::HandleKeypress(Common::Event *event) { return false; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index e2c3b25fd8..475325e8e2 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -32,8 +32,7 @@ #include "engines/wintermute/Base/BScriptHolder.h" #include "engines/wintermute/persistent.h" - -union SDL_Event; +#include "common/events.h" namespace WinterMute { @@ -82,7 +81,7 @@ public: virtual bool HandleMouseWheel(int Delta); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); virtual int GetHeight(); HRESULT SetCursor(const char *Filename); HRESULT SetActiveCursor(const char *Filename); diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 909ecb525e..934670a628 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -244,6 +244,8 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_MBUTTONUP: if (Game) Game->OnMouseMiddleUp(); break; + case Common::EVENT_KEYDOWN: + if (Game) Game->HandleKeypress(event); /*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d364b27740..53ce72fe4a 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1100,16 +1100,14 @@ const char *CUIWindow::ScToString() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleKeypress(SDL_Event *event) { +bool CUIWindow::HandleKeypress(Common::Event *event) { //TODO -#if 0 - if (event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_TAB) { + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { if (_focusedWidget) return _focusedWidget->HandleKeypress(event); else return false; } -#endif return false; } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 510fc076b4..4bdef647a3 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -31,6 +31,7 @@ #include "UIObject.h" +#include "common/events.h" namespace WinterMute { @@ -69,7 +70,7 @@ public: virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); - virtual bool HandleKeypress(SDL_Event *event); + virtual bool HandleKeypress(Common::Event *event); CBArray _widgets; TTextAlign _titleAlign; HRESULT LoadFile(const char *Filename); -- cgit v1.2.3 From c69f3bf8b678e0c928f7c1f712ddadc7d8a09f42 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 03:49:56 +0200 Subject: WINTERMUTE: Add detection for the white chamber v1.7 --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index d7eb48e4be..8d38eeb1ef 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -73,6 +73,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_DEMO, GUIO0() }, + { + "wintermute", + "the white chamber", + AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, AD_TABLE_END_MARKER }; -- cgit v1.2.3 From dbebaaf50d2b07d7657d7c1210587e009f6d7f06 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 16:55:38 +0200 Subject: WINTERMUTE: Get a fallback font to at least draw something for BFontTT --- engines/wintermute/Base/BFontTT.cpp | 17 +++++++++++++---- engines/wintermute/Base/BRenderSDL.cpp | 4 ++-- engines/wintermute/Base/BRenderSDL.h | 2 +- engines/wintermute/Base/BSurface.h | 4 ++-- engines/wintermute/Base/BSurfaceSDL.h | 12 ++++++++++++ 5 files changed, 30 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index d1fad44c64..a183254f52 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -162,10 +162,10 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, warning("Draw text: %s", Text); if (Text == NULL || strcmp((char *)Text, "") == 0) return; - WideString text; + WideString text = (char*)Text; // TODO: Why do we still insist on Widestrings everywhere? - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); +/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ if (MaxLength >= 0 && text.size() > MaxLength) @@ -244,11 +244,20 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, ////////////////////////////////////////////////////////////////////////// CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { TextLineList lines; - WrapText(text, width, maxHeight, lines); + // TODO + //WrapText(text, width, maxHeight, lines); TextLineList::iterator it; warning("CBFontTT::RenderTextToTexture - Not ported yet"); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 5, 1, 0)); + _fallbackFont->drawString(surface, text, 0, 0, width, 255); + CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); + retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); + delete surface; + return retSurface; #if 0 //TODO int textHeight = lines.size() * (_maxCharHeight + _ascender); SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); @@ -620,7 +629,7 @@ HRESULT CBFontTT::InitFont() { } warning("I guess we got a file"); if (file) { - //_font = Graphics::loadTTFFont(*file->getMemStream(), 12); + //_font = Graphics::loadTTFFont(*file->getMemStream(), _fontHeight); } else { _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); warning("BFontTT::InitFont - Couldn't load %s", _fontFile); diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index d8a27f67d7..066e89e83c 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -282,9 +282,9 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { } // Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect) { +void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a) { TransparentSurface src(*surf, false); - src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(255, 255, 255, 255), dstRect->width(), dstRect->height() ); + src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(r, g, b, a), dstRect->width(), dstRect->height() ); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 73dc88d4be..299eec3f0b 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -58,7 +58,7 @@ public: CBImage *TakeScreenshot(); - void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest); + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255); HRESULT SetViewport(int left, int top, int right, int bottom); diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 046041ac6a..9da7db6a61 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -76,10 +76,10 @@ public: int _referenceCount; char *_filename; - int GetWidth() { + virtual int GetWidth() { return _width; } - int GetHeight() { + virtual int GetHeight() { return _height; } //void SetWidth(int Width){ _width = Width; } diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 767db0fa74..4b43bd3467 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -62,6 +62,18 @@ public: /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ + virtual int GetWidth() { + if (_surface) { + return _surface->w; + } + return _width; + } + virtual int GetHeight() { + if (_surface) { + return _surface->h; + } + return _height; + } private: // SDL_Texture *_texture; -- cgit v1.2.3 From b881ff7eef5b014fda3aaa3cbc9bd544134a944a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 17:36:19 +0200 Subject: WINTERMUTE: Implement most of BSoundBuffer, to get sentences to play properly. --- engines/wintermute/Base/BSoundBuffer.cpp | 106 ++++++++++--------------------- 1 file changed, 34 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 62a9bd78b6..9751ad44c0 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -68,12 +68,11 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::~CBSoundBuffer() { -#if 0 Stop(); - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; + if (_handle) { + delete _handle; + _handle = NULL; } if (_file) { @@ -81,8 +80,8 @@ CBSoundBuffer::~CBSoundBuffer() { _file = NULL; } - SAFE_DELETE_ARRAY(_filename); -#endif + delete[] _filename; + _filename = NULL; } @@ -178,17 +177,17 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { - warning("Play: %s", _filename); + // TODO: looping if (_stream) { SetLooping(Looping); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream); - //BASS_ChannelPlay(_stream, TRUE); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); } return S_OK; } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetLooping(bool looping) { + warning("BSoundBuffer::SetLooping - not implemented yet"); #if 0 _looping = looping; @@ -200,43 +199,37 @@ void CBSoundBuffer::SetLooping(bool looping) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Resume() { -#if 0 - if (_stream) { - BASS_ChannelPlay(_stream, FALSE); + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); } -#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Stop() { -#if 0 - if (_stream) { - BASS_ChannelStop(_stream); + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); } -#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::Pause() { -#if 0 - if (_stream) { - BASS_ChannelPause(_stream); + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); } -#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// uint32 CBSoundBuffer::GetLength() { -#if 0 - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(_stream, len); -#endif + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } return 0; } @@ -249,11 +242,10 @@ void CBSoundBuffer::SetType(TSoundType Type) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetVolume(int Volume) { -#if 0 - if (_stream) { - BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_VOL, (float)Volume / 100.0f); + if (_stream && _handle) { + byte vol = Volume/100.f * Audio::Mixer::kMaxChannelVolume; + g_system->getMixer()->setChannelVolume(*_handle, vol); } -#endif return S_OK; } @@ -281,27 +273,27 @@ HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// bool CBSoundBuffer::IsPlaying() { -#if 0 - return _freezePaused || BASS_ChannelIsActive(_stream) == BASS_ACTIVE_PLAYING; -#endif - return false; + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// uint32 CBSoundBuffer::GetPosition() { -#if 0 - if (_stream) { - QWORD len = BASS_ChannelGetPosition(_stream, BASS_POS_BYTE); - return 1000 * BASS_ChannelBytes2Seconds(_stream, len); - } else return 0; -#endif + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } return 0; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { + warning("CBSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); @@ -339,17 +331,16 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPan(float Pan) { -#if 0 +HRESULT CBSoundBuffer::SetPan(float pan) { if (_stream) { - BASS_ChannelSetAttribute(_stream, BASS_ATTRIB_PAN, Pan); + g_system->getMixer()->setChannelBalance(*_handle, pan * 127); } -#endif return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { + warning("CBSoundBuffer::ApplyFX - not implemented yet"); #if 0 switch (Type) { case SFX_ECHO: @@ -365,33 +356,4 @@ HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float return S_OK; } -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::FileCloseProc(void *user) { - /* - CBFile* file = static_cast(user); - file->Game->_fileManager->CloseFile(file); - */ -} - -////////////////////////////////////////////////////////////////////////// -QWORD CBSoundBuffer::FileLenProc(void *user) { - CBFile *file = static_cast(user); - return file->GetSize(); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::FileReadProc(void *buffer, uint32 length, void *user) { - CBFile *file = static_cast(user); - uint32 oldPos = file->GetPos(); - file->Read(buffer, length); - return file->GetPos() - oldPos; -} - -////////////////////////////////////////////////////////////////////////// -BOOL CBSoundBuffer::FileSeekProc(QWORD offset, void *user) { - CBFile *file = static_cast(user); - return SUCCEEDED(file->Seek(offset)); -} -#endif } // end of namespace WinterMute -- cgit v1.2.3 From db2c12fb08277a55e8bd215e140931b963b08e95 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 21:45:59 +0200 Subject: WINTERMUTE: Make BFontTT draw almost the right color. --- engines/wintermute/Base/BFontTT.cpp | 21 +++++++++++++-------- engines/wintermute/Base/BSurfaceSDL.cpp | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index a183254f52..2c062e6d91 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -249,11 +249,14 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex TextLineList::iterator it; - warning("CBFontTT::RenderTextToTexture - Not ported yet"); + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 5, 1, 0)); - _fallbackFont->drawString(surface, text, 0, 0, width, 255); + surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + + uint16 useColor = 0xffff; + _fallbackFont->drawString(surface, text, 0, 0, width, useColor); CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); delete surface; @@ -615,7 +618,6 @@ void CBFontTT::AfterLoad() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; - warning("BFontTT::InitFont - Not ported yet"); Common::SeekableReadStream *file = Game->_fileManager->OpenFile(_fontFile); if (!file) { @@ -627,11 +629,14 @@ HRESULT CBFontTT::InitFont() { //return E_FAIL; } } - warning("I guess we got a file"); + if (file) { - //_font = Graphics::loadTTFFont(*file->getMemStream(), _fontHeight); - } else { - _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); +#ifdef USE_FREETYPE2 + _font = Graphics::loadTTFFont(*file, _fontHeight); +#endif + } + if (!_font) { + _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); warning("BFontTT::InitFont - Couldn't load %s", _fontFile); } return S_OK; diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 8406985be8..ba211ac86d 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -494,7 +494,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.left += offsetX; position.top += offsetY; - renderer->drawFromSurface(_surface, &srcRect, &position); + renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a); #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif -- cgit v1.2.3 From 9ea09aee2443949e5c7cee5b51adc6ff4772b43f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 21:47:20 +0200 Subject: WINTERMUTE: Don't error out on missing WeedResponses. --- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 4ce6172015..c4ba940c89 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -557,7 +557,7 @@ HRESULT CAdResponseBox::WeedResponses() { } break; default: - error("CAdResponseBox::WeedResponses - Unhandled enum"); + warning("CAdResponseBox::WeedResponses - Unhandled enum"); break; } } -- cgit v1.2.3 From 311341bff02670d7b0a94e7499229a038a816edd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 22:12:08 +0200 Subject: WINTERMUTE: Correct RGBA->ARGB in BSurfaceSDL --- engines/wintermute/Base/BRenderSDL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 066e89e83c..93fed39a59 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -284,7 +284,7 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { // Replacement for SDL2's SDL_RenderCopy void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a) { TransparentSurface src(*surf, false); - src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(r, g, b, a), dstRect->width(), dstRect->height() ); + src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(a, r, g, b), dstRect->width(), dstRect->height() ); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { -- cgit v1.2.3 From b830ae44eaedefc7cf3b4c18b06cb88cfcea184e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 22:53:17 +0200 Subject: WINTERMUTE: Fix a missing const that made Rosemary bug out in scripts. --- engines/wintermute/Base/BScriptable.cpp | 2 +- engines/wintermute/Base/BScriptable.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index b7dd2d5be1..ef378500e2 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -162,7 +162,7 @@ void CBScriptable::ScDebuggerDesc(char *Buf, int BufSize) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::CanHandleMethod(char *EventMethod) { +bool CBScriptable::CanHandleMethod(const char *EventMethod) { return false; } diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index 5a24bde8e8..dfe36abf52 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -49,7 +49,7 @@ public: virtual ~CBScriptable(); // high level scripting interface - virtual bool CanHandleMethod(char *EventMethod); + virtual bool CanHandleMethod(const char *EventMethod); virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); virtual CScValue *ScGetProperty(const char *Name); virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); -- cgit v1.2.3 From a3901c76fdea01f40b0941d46bd2eb538d89341d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 23:12:32 +0200 Subject: WINTERMUTE: Make sprite-mirroring work correctly. --- engines/wintermute/Base/BRenderSDL.cpp | 9 +++++++-- engines/wintermute/Base/BRenderSDL.h | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 93fed39a59..01e48f3e04 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -282,9 +282,14 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { } // Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a) { +void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a, bool mirrorX, bool mirrorY) { TransparentSurface src(*surf, false); - src.blit(*_renderSurface, dstRect->left, dstRect->top, TransparentSurface::FLIP_NONE, srcRect,BS_ARGB(a, r, g, b), dstRect->width(), dstRect->height() ); + int mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + mirror |= TransparentSurface::FLIP_H; + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect,BS_ARGB(a, r, g, b), dstRect->width(), dstRect->height() ); } ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 299eec3f0b..6718e33f86 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -58,7 +58,7 @@ public: CBImage *TakeScreenshot(); - void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255); + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool mirrorX = false, bool mirrorY = false); HRESULT SetViewport(int left, int top, int right, int bottom); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index ba211ac86d..00b59792d4 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -494,7 +494,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.left += offsetX; position.top += offsetY; - renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a); + renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a, MirrorX, MirrorY); #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif -- cgit v1.2.3 From 70427e6d7e0e06e0559aed167e86784a9c176f34 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 3 Jun 2012 23:57:31 +0200 Subject: WINTERMUTE: Make text-measuring work without FreeType2. --- engines/wintermute/Base/BFontTT.cpp | 39 +++++++++++++++++++++++---------- engines/wintermute/Base/BFontTT.h | 3 ++- engines/wintermute/utils/StringUtil.cpp | 8 +++---- 3 files changed, 33 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 2c062e6d91..7b28c9fd93 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -58,6 +58,7 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { _fontFile = NULL; _font = NULL; _fallbackFont = NULL; + _deletableFont = NULL; for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; @@ -84,7 +85,7 @@ CBFontTT::~CBFontTT(void) { delete[] _fontFile; _fontFile = NULL; - delete _font; + delete _deletableFont; _font = NULL; delete _glyphCache; @@ -129,8 +130,8 @@ void CBFontTT::InitLoop() { int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { WideString text; - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -146,8 +147,8 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { int CBFontTT::GetTextHeight(byte *Text, int Width) { WideString text; - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); int textWidth, textHeight; @@ -636,9 +637,10 @@ HRESULT CBFontTT::InitFont() { #endif } if (!_font) { - _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); warning("BFontTT::InitFont - Couldn't load %s", _fontFile); } + _lineHeight = _font->getFontHeight(); return S_OK; #if 0 FT_Error error; @@ -814,19 +816,32 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex ////////////////////////////////////////////////////////////////////////// void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - TextLineList lines; - WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * GetLineHeight()); - textWidth = 0; + //TextLineList lines; + warning("Todo: Test Mesuretext"); + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + textHeight = (int)(lines.size() * GetLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } +/* TextLineList::iterator it; for (it = lines.begin(); it != lines.end(); ++it) { TextLine *line = (*it); textWidth = MAX(textWidth, line->GetWidth()); delete line; line = NULL; - } + }*/ } diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 22630a7444..d21729369b 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -160,7 +160,8 @@ private: HRESULT InitFont(); //FT_Stream _fTStream; //FT_Face _fTFace; - Graphics::Font *_font; + Graphics::Font *_deletableFont; + const Graphics::Font *_font; const Graphics::Font *_fallbackFont; FontGlyphCache *_glyphCache; diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index cd4f99e034..8ca2ed8c07 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -179,7 +179,7 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { ////////////////////////////////////////////////////////////////////////// WideString StringUtil::AnsiToWide(const AnsiString &str) { // using default os locale! - error("StringUtil::AnsiToWide - WideString not supported yet"); + warning("StringUtil::AnsiToWide - WideString not supported yet"); /* setlocale(LC_CTYPE, ""); size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; wchar_t *wstr = new wchar_t[WideSize]; @@ -187,13 +187,13 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { WideString ResultString(wstr); delete [] wstr; return ResultString;*/ - return ""; + return WideString(str); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::WideToAnsi(const WideString &wstr) { // using default os locale! - error("StringUtil::WideToAnsi - WideString not supported yet"); + warning("StringUtil::WideToAnsi - WideString not supported yet"); /* setlocale(LC_CTYPE, ""); size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; @@ -201,7 +201,7 @@ AnsiString StringUtil::WideToAnsi(const WideString &wstr) { AnsiString ResultString(str); delete [] str; return ResultString;*/ - return ""; + return AnsiString(wstr); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 31d0b89e82952c3956289c95a3a748255038e09a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 4 Jun 2012 01:55:23 +0200 Subject: WINTERMUTE: Reenable CBRenderSDL::Fill to let the screen be blanked for every frame This makes J.U.L.I.A. look a lot better. --- engines/wintermute/Base/BRenderSDL.cpp | 13 +++++++++++-- engines/wintermute/Base/BRenderSDL.h | 4 ++-- engines/wintermute/Base/BRenderer.cpp | 4 ++-- engines/wintermute/Base/BRenderer.h | 5 +++-- 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 01e48f3e04..5513dd5e69 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -228,9 +228,18 @@ HRESULT CBRenderSDL::Flip() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, RECT *rect) { +HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); + uint32 color = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!rect) { + rect = new Common::Rect(); + rect->setWidth(_renderSurface->w); + rect->setHeight(_renderSurface->h); + _renderSurface->fillRect(*rect, color); + delete rect; + } + _renderSurface->fillRect(*rect, color); return S_OK; } @@ -243,7 +252,7 @@ HRESULT CBRenderSDL::Fade(uint16 Alpha) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::FadeToColor(uint32 Color, RECT *rect) { +HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 6718e33f86..ab343578f4 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -47,10 +47,10 @@ public: HRESULT InitRenderer(int width, int height, bool windowed); HRESULT Flip(); - HRESULT Fill(byte r, byte g, byte b, RECT *rect); + HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect); HRESULT Fade(uint16 Alpha); - HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + HRESULT FadeToColor(uint32 Color, Common::Rect *rect = NULL); HRESULT SwitchFullscreen(); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index ba7b0bb405..9c48c93070 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -138,7 +138,7 @@ void CBRenderer::OnWindowChange() { ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fill(byte r, byte g, byte b, RECT *rect) { +HRESULT CBRenderer::Fill(byte r, byte g, byte b, Common::Rect *rect) { return E_FAIL; } @@ -186,7 +186,7 @@ HRESULT CBRenderer::Fade(uint16 Alpha) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::FadeToColor(uint32 Color, RECT *rect) { +HRESULT CBRenderer::FadeToColor(uint32 Color, Common::Rect *rect) { return E_FAIL; } diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 91d0f211c6..a13082b1b2 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -32,6 +32,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" +#include "common/rect.h" namespace WinterMute { @@ -52,7 +53,7 @@ public: virtual HRESULT SetViewport(RECT *Rect); virtual HRESULT SetScreenViewport(); virtual HRESULT Fade(uint16 Alpha); - virtual HRESULT FadeToColor(uint32 Color, RECT *rect = NULL); + virtual HRESULT FadeToColor(uint32 Color, Common::Rect *rect = NULL); virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); CBRenderer(CBGame *inGame = NULL); @@ -62,7 +63,7 @@ public: }; virtual HRESULT WindowedBlt(); - virtual HRESULT Fill(byte r, byte g, byte b, RECT *rect = NULL); + virtual HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect = NULL); virtual void OnWindowChange(); virtual HRESULT InitRenderer(int width, int height, bool windowed); virtual HRESULT Flip(); -- cgit v1.2.3 From 8add2f10e8c6575eed630dbc1163ed41554e2590 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 4 Jun 2012 02:57:04 +0200 Subject: WINTERMUTE: Add missing break in event-handler switch-case. --- engines/wintermute/PlatformSDL.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 934670a628..b80d742da3 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -246,6 +246,7 @@ void CBPlatform::HandleEvent(Common::Event *event) { break; case Common::EVENT_KEYDOWN: if (Game) Game->HandleKeypress(event); + break; /*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); -- cgit v1.2.3 From 81e57690b2778e8f73134d0975cadda0f3fb9a79 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 4 Jun 2012 03:36:50 +0200 Subject: WINTERMUTE: Make BDiskFile reset it's files after testing for compression. --- engines/wintermute/Base/file/BDiskFile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index 57e9a0a0f0..ce6a6a100c 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -118,6 +118,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM delete file; file = NULL; } else { + file->seek(0, SEEK_SET); return file; } -- cgit v1.2.3 From 22602f0561cd768ad52cfc711420775848cc4a53 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 4 Jun 2012 03:38:50 +0200 Subject: WINTERMUTE: Add word-wrapping for TTF-fonts, as well as proper loading of fonts in game-folder. --- engines/wintermute/Base/BFontTT.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 7b28c9fd93..37f14ea0db 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -244,20 +244,26 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, ////////////////////////////////////////////////////////////////////////// CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - TextLineList lines; + //TextLineList lines; // TODO //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); - - TextLineList::iterator it; warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + surface->create(width, _fontHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); uint16 useColor = 0xffff; - _fallbackFont->drawString(surface, text, 0, 0, width, useColor); + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor); + heightOffset += _lineHeight; + } + CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); delete surface; @@ -633,7 +639,8 @@ HRESULT CBFontTT::InitFont() { if (file) { #ifdef USE_FREETYPE2 - _font = Graphics::loadTTFFont(*file, _fontHeight); + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight); + _font = _deletableFont; #endif } if (!_font) { -- cgit v1.2.3 From ff28c0215b32d1dbfb301bc29bbded619a92e40f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 4 Jun 2012 03:39:30 +0200 Subject: WINTERMUTE: Let SystemFontPath be empty for now. --- engines/wintermute/PlatformSDL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index b80d742da3..bf13dced4e 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -510,7 +510,8 @@ AnsiString CBPlatform::GetSystemFontPath() { return PathUtil::Combine(AnsiString(winDir), "fonts"); #else // !PORTME - return "/Library/Fonts/"; + //return "/Library/Fonts/"; + return ""; #endif } -- cgit v1.2.3 From 6e04d78a3652d9eea9ba7220967afe3d6c1cd89f Mon Sep 17 00:00:00 2001 From: Einar Johan T. Sømåen Date: Thu, 7 Jun 2012 12:53:13 +0200 Subject: WINTERMUTE: Fix compile on linux again. --- engines/wintermute/module.mk | 1 + engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.h | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 217317ece6..ed94ebf2fc 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -117,6 +117,7 @@ MODULE_OBJS := \ utils/utils.o \ video/VidPlayer.o \ video/VidTheoraPlayer.o \ + video/decoders/theora_decoder.o \ wintermute.o MODULE_DIRS += \ diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 05691d8fdb..f6733c3fde 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -18,7 +18,7 @@ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/video/vidtheoraplayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BSurfaceSDL.h" diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index a27ce04042..0ce6e42b5a 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -32,7 +32,12 @@ namespace WinterMute { class CVidTheoraPlayer : public CBBase { private: - enum { THEORA_STATE_NONE = 0, THEORA_STATE_PLAYING = 1, THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; + enum { + THEORA_STATE_NONE = 0, + THEORA_STATE_PLAYING = 1, + THEORA_STATE_PAUSED = 2, + THEORA_STATE_FINISHED = 3 + }; Video::VideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: @@ -140,7 +145,7 @@ private: bool _frameRendered; - void getIsFrameReady() { + bool getIsFrameReady() { return _videoFrameReady; } private: -- cgit v1.2.3 From 9aa2d43facd0a3fbafb1e7e432fca80f89aa6c66 Mon Sep 17 00:00:00 2001 From: Einar Johan T. Sømåen Date: Thu, 7 Jun 2012 13:40:57 +0200 Subject: WINTERMUTE: Fix BRenderSDL::Fill --- engines/wintermute/Base/BRenderSDL.cpp | 3 ++- engines/wintermute/Base/BRenderSDL.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 5513dd5e69..3dca9e1f39 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -238,8 +238,9 @@ HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { rect->setHeight(_renderSurface->h); _renderSurface->fillRect(*rect, color); delete rect; + } else { + _renderSurface->fillRect(*rect, color); } - _renderSurface->fillRect(*rect, color); return S_OK; } diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index ab343578f4..ccdca89be5 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -47,7 +47,7 @@ public: HRESULT InitRenderer(int width, int height, bool windowed); HRESULT Flip(); - HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect); + HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect = NULL); HRESULT Fade(uint16 Alpha); HRESULT FadeToColor(uint32 Color, Common::Rect *rect = NULL); -- cgit v1.2.3 From 1c18f0efdc2e0f7062dfcf38925131a0050526a0 Mon Sep 17 00:00:00 2001 From: Einar Johan T. Sømåen Date: Thu, 7 Jun 2012 13:50:49 +0200 Subject: WINTERMUTE: Add detection for german Dirty Split --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 8d38eeb1ef..4756c96542 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -42,6 +42,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_USEEXTRAASTITLE, GUIO0() }, + { + "wintermute", + "Dirty Split", + AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, { "wintermute", "Five Magical Amulets", -- cgit v1.2.3 From 088a6b7b45b08f3257329e3da99fda699ba3aedc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 00:21:04 +0200 Subject: WINTERMUTE: Avoid compilation errors if Theora isn't included. --- engines/wintermute/video/VidTheoraPlayer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index f6733c3fde..3380e8c4a4 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -116,7 +116,11 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo if (!_file) return E_FAIL; //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); +#if defined (USE_THEORA) _theoraDecoder = new TheoraDecoder(); +#else + return E_FAIL; +#endif _theoraDecoder->loadStream(_file); if (!_theoraDecoder->isVideoLoaded()) -- cgit v1.2.3 From ed7b31f84142c7a1b6c47b1f84b4d4518f3a521c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 00:35:19 +0200 Subject: WINTERMUTE: Remember to free the image decoders after use. --- engines/wintermute/Base/BSurfaceSDL.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 00b59792d4..5db00e5eef 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -167,6 +167,7 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, warning("Surface-textures not fully ported yet"); hasWarned = true; } + delete imgDecoder; #if 0 _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); if (!_texture) { -- cgit v1.2.3 From 2e0b523d418a4494e0d50de5f350055c25916e1f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 01:18:03 +0200 Subject: WINTERMUTE: VarName -> varName in BSurface/BSurfaceSDL --- engines/wintermute/Base/BFontBitmap.cpp | 12 ++--- engines/wintermute/Base/BFontTT.cpp | 6 +-- engines/wintermute/Base/BGame.cpp | 10 ++-- engines/wintermute/Base/BRenderSDL.cpp | 4 +- engines/wintermute/Base/BRenderer.cpp | 2 +- engines/wintermute/Base/BSprite.cpp | 2 +- engines/wintermute/Base/BSubFrame.cpp | 10 ++-- engines/wintermute/Base/BSurface.cpp | 77 ++++++++------------------ engines/wintermute/Base/BSurface.h | 48 ++++++++--------- engines/wintermute/Base/BSurfaceSDL.cpp | 80 ++++++++++++++-------------- engines/wintermute/Base/BSurfaceSDL.h | 38 ++++++------- engines/wintermute/Base/BSurfaceStorage.cpp | 6 +-- engines/wintermute/UI/UITiledImage.cpp | 22 ++++---- engines/wintermute/video/VidTheoraPlayer.cpp | 14 ++--- 14 files changed, 149 insertions(+), 182 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 759db24994..10df7fdf3a 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -235,12 +235,12 @@ void CBFontBitmap::DrawChar(byte c, int x, int y) { _sprite->GetCurrentFrame(); if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->DisplayTrans(x, y, rect); + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); } Handled = true; } } - if (!Handled && _subframe) _subframe->_surface->DisplayTrans(x, y, rect); + if (!Handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); } @@ -500,7 +500,7 @@ HRESULT CBFontBitmap::GetWidths() { } } if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || FAILED(surf->StartPixelOp())) return E_FAIL; + if (!surf || FAILED(surf->startPixelOp())) return E_FAIL; for (int i = 0; i < NUM_CHARACTERS; i++) { @@ -511,8 +511,8 @@ HRESULT CBFontBitmap::GetWidths() { int min_col = -1; for (int row = 0; row < _tileHeight; row++) { for (int col = _tileWidth - 1; col >= min_col + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->GetWidth() || yyy + row < 0 || yyy + row >= surf->GetHeight()) continue; - if (!surf->IsTransparentAtLite(xxx + col, yyy + row)) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; min_col = MAX(col, min_col); break; @@ -523,7 +523,7 @@ HRESULT CBFontBitmap::GetWidths() { _widths[i] = min_col + 1; } - surf->EndPixelOp(); + surf->endPixelOp(); /* Game->LOG(0, "----- %s ------", _filename); for(int j=0; j<16; j++) diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 37f14ea0db..68645e88bb 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -225,7 +225,7 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, // and paint it if (Surface) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight()); + CBPlatform::SetRect(&rc, 0, 0, Surface->getWidth(), Surface->getHeight()); for (int i = 0; i < _layers.GetSize(); i++) { uint32 Color = _layers[i]->_color; uint32 OrigForceAlpha = _renderer->_forceAlphaColor; @@ -233,7 +233,7 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(_renderer->_forceAlphaColor)); _renderer->_forceAlphaColor = 0; } - Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + Surface->displayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); _renderer->_forceAlphaColor = OrigForceAlpha; } @@ -265,7 +265,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex } CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); - retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); + retSurface->putSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); delete surface; return retSurface; #if 0 //TODO diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 33bfc8956a..631fdfd43d 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3251,7 +3251,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { if (_saveImageName) { _saveLoadImage = new CBSurfaceSDL(this); - if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_saveImageName, true, 0, 0, 0))) { + if (!_saveLoadImage || FAILED(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; } @@ -3301,7 +3301,7 @@ HRESULT CBGame::LoadGame(const char *Filename) { if (_loadImageName) { _saveLoadImage = new CBSurfaceSDL(this); - if (!_saveLoadImage || FAILED(_saveLoadImage->Create(_loadImageName, true, 0, 0, 0))) { + if (!_saveLoadImage || FAILED(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; } @@ -4089,9 +4089,9 @@ HRESULT CBGame::DisplayContentSimple() { HRESULT CBGame::DisplayIndicator() { if (_saveLoadImage) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->GetWidth(), _saveLoadImage->GetHeight()); - if (_loadInProgress) _saveLoadImage->DisplayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->DisplayTrans(_saveImageX, _saveImageY, rc); + CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 3dca9e1f39..616aa4b944 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -452,9 +452,9 @@ void CBRenderSDL::DumpData(const char *Filename) { if (!Surf->_valid) continue; fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->GetWidth(), Surf->GetHeight()); + fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); - int kb = Surf->GetWidth() * Surf->GetHeight() * 4 / 1024; + int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; TotalKB += kb; fprintf(f, "%d;", kb); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 9c48c93070..c8de494097 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -91,7 +91,7 @@ CBObject *CBRenderer::GetObjectAt(int X, int Y) { YY = Height - YY; } - if (!_rectList[i]->_frame->_surface->IsTransparentAt(XX, YY)) return _rectList[i]->_owner; + if (!_rectList[i]->_frame->_surface->isTransparentAt(XX, YY)) return _rectList[i]->_owner; } // region else if (_rectList[i]->_region) { diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index f3f35a8364..bd3e2711d9 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -146,7 +146,7 @@ HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType delete frame; delete subframe; } else { - CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->GetWidth(), subframe->_surface->GetHeight()); + CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); frame->_subframes.Add(subframe); _frames.Add(frame); _currentFrame = 0; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 6b5d4e9f2e..392d65dc0d 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -222,10 +222,10 @@ HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zo if (_alpha != 0xFFFFFFFF) Alpha = _alpha; if (Rotate != 0.0f) { - res = _surface->DisplayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); + res = _surface->displayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); } else { - if (ZoomX == 100 && ZoomY == 100) res = _surface->DisplayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); - else res = _surface->DisplayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); + if (ZoomX == 100 && ZoomY == 100) res = _surface->displayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); } return res; @@ -261,7 +261,7 @@ HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { RECT rect; CBPlatform::SetRectEmpty(&rect); - if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::EqualRect(&rect, &_rect)) Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); @@ -304,7 +304,7 @@ HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { ////////////////////////////////////////////////////////////////////////// void CBSubFrame::SetDefaultRect() { if (_surface) { - CBPlatform::SetRect(&_rect, 0, 0, _surface->GetWidth(), _surface->GetHeight()); + CBPlatform::SetRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); } else CBPlatform::SetRectEmpty(&_rect); } diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 69b137813b..299218fd4b 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -54,141 +54,108 @@ CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBSurface::~CBSurface() { - if (_pixelOpReady) EndPixelOp(); + if (_pixelOpReady) endPixelOp(); if (_filename) delete [] _filename; } ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSurface::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { return E_FAIL; } ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Restore() { +HRESULT CBSurface::restore() { return E_FAIL; } - - - ////////////////////////////////////////////////////////////////////// -bool CBSurface::IsTransparentAt(int X, int Y) { +bool CBSurface::isTransparentAt(int x, int y) { return false; } - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return E_FAIL; -} - - ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayHalfTrans(int X, int Y, RECT rect) { +HRESULT CBSurface::displayHalfTrans(int x, int y, RECT rect) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DisplayTransZoom(X, Y, Rect, ZoomX, ZoomY, Alpha, BlendMode, MirrorX, MirrorY); +HRESULT CBSurface::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Create(int Width, int Height) { +HRESULT CBSurface::create(int Width, int Height) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::StartPixelOp() { +HRESULT CBSurface::startPixelOp() { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::EndPixelOp() { +HRESULT CBSurface::endPixelOp() { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A) { +HRESULT CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::PutPixel(int X, int Y, byte R, byte G, byte B, int A) { +HRESULT CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::ComparePixel(int X, int Y, byte R, byte G, byte B, int A) { +bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { return false; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::IsTransparentAtLite(int X, int Y) { +bool CBSurface::isTransparentAtLite(int x, int y) { return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::Invalidate() { +HRESULT CBSurface::invalidate() { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::PrepareToDraw() { +HRESULT CBSurface::prepareToDraw() { _lastUsedTime = Game->_liveTimer; if (!_valid) { //Game->LOG(0, "Reviving: %s", _filename); - return Create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + return create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); } else return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CBSurface::SetFilename(const char *Filename) { +void CBSurface::setFilename(const char *filename) { delete[] _filename; _filename = NULL; - if (!Filename) return; + if (!filename) return; - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); } ////////////////////////////////////////////////////////////////////////// -void CBSurface::SetSize(int Width, int Height) { +void CBSurface::setSize(int Width, int Height) { _width = Width; _height = Height; } diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 9da7db6a61..469923bcdd 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -36,8 +36,8 @@ namespace WinterMute { class CBSurface: public CBBase { public: - virtual HRESULT Invalidate(); - virtual HRESULT PrepareToDraw(); + virtual HRESULT invalidate(); + virtual HRESULT prepareToDraw(); bool _cKDefault; byte _cKRed; byte _cKGreen; @@ -52,34 +52,34 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual HRESULT DisplayHalfTrans(int X, int Y, RECT rect); - virtual bool IsTransparentAt(int X, int Y); - virtual HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); - virtual HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT Restore(); - virtual HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); - virtual HRESULT Create(int Width, int Height); - virtual HRESULT PutSurface(const Graphics::Surface &surface) { return E_FAIL; } - virtual HRESULT PutPixel(int X, int Y, byte R, byte G, byte B, int A = -1); - virtual HRESULT GetPixel(int X, int Y, byte *R, byte *G, byte *B, byte *A = NULL); - virtual bool ComparePixel(int X, int Y, byte R, byte G, byte B, int A = -1); - virtual HRESULT StartPixelOp(); - virtual HRESULT EndPixelOp(); - virtual bool IsTransparentAtLite(int X, int Y); - void SetFilename(const char *Filename); - void SetSize(int Width, int Height); + virtual HRESULT displayHalfTrans(int x, int y, RECT rect); + virtual bool isTransparentAt(int x, int y); + virtual HRESULT displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual HRESULT displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual HRESULT displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual HRESULT displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual HRESULT restore(); + virtual HRESULT create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; + virtual HRESULT create(int Width, int Height); + virtual HRESULT putSurface(const Graphics::Surface &surface) { return E_FAIL; } + virtual HRESULT putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual HRESULT getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual HRESULT startPixelOp(); + virtual HRESULT endPixelOp(); + virtual bool isTransparentAtLite(int x, int y); + void setFilename(const char *Filename); + void setSize(int width, int height); int _referenceCount; char *_filename; - virtual int GetWidth() { + virtual int getWidth() { return _width; } - virtual int GetHeight() { + virtual int getHeight() { return _height; } //void SetWidth(int Width){ _width = Width; } diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 5db00e5eef..2486f9915b 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -69,26 +69,26 @@ CBSurfaceSDL::~CBSurfaceSDL() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ - Common::String strFileName(Filename); + Common::String strFileName(filename); Graphics::ImageDecoder *imgDecoder; if (strFileName.hasSuffix(".png")) { imgDecoder = new Graphics::PNGDecoder(); } else if (strFileName.hasSuffix(".bmp")) { - warning("Loaded BMP WITH FILENAME!!!! %s", Filename); + warning("Loaded BMP WITH FILENAME!!!! %s", filename); imgDecoder = new Graphics::BitmapDecoder(); } else if (strFileName.hasSuffix(".tga")) { imgDecoder = new WinterMute::TGA(); } else if (strFileName.hasSuffix(".jpg")) { imgDecoder = new Graphics::JPEGDecoder(); } else { - error("CBSurfaceSDL::Create : Unsupported fileformat %s", Filename); + error("CBSurfaceSDL::Create : Unsupported fileformat %s", filename); } - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename); if (!file) return E_FAIL; imgDecoder->loadStream(*file); @@ -105,7 +105,7 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, _width = surface->w; _height = surface->h; - bool isSaveGameGrayscale = scumm_strnicmp(Filename, "savegame:", 9) == 0 && (Filename[strFileName.size() - 1] == 'g' || Filename[strFileName.size() - 1] == 'G'); + bool isSaveGameGrayscale = scumm_strnicmp(filename, "savegame:", 9) == 0 && (filename[strFileName.size() - 1] == 'g' || filename[strFileName.size() - 1] == 'G'); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); @@ -187,14 +187,14 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, _cKBlue = ck_blue; #endif - if (!_filename || scumm_stricmp(_filename, Filename) != 0) { - SetFilename(Filename); + if (!_filename || scumm_stricmp(_filename, filename) != 0) { + setFilename(filename); } - if (_lifeTime == 0 || LifeTime == -1 || LifeTime > _lifeTime) - _lifeTime = LifeTime; + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + _lifeTime = lifeTime; - _keepLoaded = KeepLoaded; + _keepLoaded = keepLoaded; if (_keepLoaded) _lifeTime = -1; _valid = true; @@ -206,7 +206,7 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red, } ////////////////////////////////////////////////////////////////////////// -void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { +void CBSurfaceSDL::genAlphaMask(Graphics::Surface *surface) { warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); return; @@ -229,7 +229,7 @@ void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { bool hasTransparency = false; for (int y = 0; y < surface->h; y++) { for (int x = 0; x < surface->w; x++) { - uint32 pixel = GetPixel(surface, x, y); + uint32 pixel = getPixel(surface, x, y); uint8 r, g, b, a; surface->format.colorToARGB(pixel, a, r, g, b); @@ -252,7 +252,7 @@ void CBSurfaceSDL::GenAlphaMask(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { +uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { warning("CBSurfaceSDL::GetPixel - Not ported yet"); int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ @@ -288,14 +288,14 @@ uint32 CBSurfaceSDL::GetPixel(Graphics::Surface *surface, int x, int y) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Create(int Width, int Height) { +HRESULT CBSurfaceSDL::create(int width, int height) { warning("SurfaceSDL::Create not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); #endif - _width = Width; - _height = Height; + _width = width; + _height = height; #if 0 Game->AddMem(_width * _height * 4); #endif @@ -305,7 +305,7 @@ HRESULT CBSurfaceSDL::Create(int Width, int Height) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { +HRESULT CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); @@ -329,7 +329,7 @@ HRESULT CBSurfaceSDL::CreateFromSDLSurface(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { +bool CBSurfaceSDL::isTransparentAt(int x, int y) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -355,7 +355,7 @@ bool CBSurfaceSDL::IsTransparentAt(int X, int Y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { +bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { //if (!_lockPixels) return false; // This particular warning is rather messy, as this function is called a ton, @@ -366,7 +366,7 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { hasWarned = true; } if (_surface->format.bytesPerPixel == 4) { - uint32 pixel = *(uint32*)_surface->getBasePtr(X, Y); + uint32 pixel = *(uint32*)_surface->getBasePtr(x, y); uint8 r,g,b,a; _surface->format.colorToARGB(pixel, a, r, g, b); if (a <= 128) { @@ -402,53 +402,53 @@ bool CBSurfaceSDL::IsTransparentAtLite(int X, int Y) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::StartPixelOp() { +HRESULT CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::EndPixelOp() { +HRESULT CBSurfaceSDL::endPixelOp() { //SDL_UnlockTexture(_texture); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, 100, 100, 0xFFFFFFFF, true, BlendMode, MirrorX, MirrorY); +HRESULT CBSurfaceSDL::display(int x, int y, RECT rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTrans(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY); +HRESULT CBSurfaceSDL::displayTrans(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { - return DrawSprite(X, Y, &rect, 100, 100, Alpha, false, BlendMode, MirrorX, MirrorY, offsetX, offsetY); +HRESULT CBSurfaceSDL::displayTransOffset(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +HRESULT CBSurfaceSDL::displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha, bool Transparent, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &rect, ZoomX, ZoomY, Alpha, !Transparent, BlendMode, MirrorX, MirrorY); +HRESULT CBSurfaceSDL::displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY) { - return DrawSprite(X, Y, &Rect, ZoomX, ZoomY, Alpha, false, BlendMode, MirrorX, MirrorY); +HRESULT CBSurfaceSDL::displayTransform(int x, int y, int HotX, int HotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &Rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) { +HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; @@ -483,8 +483,8 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo srcRect.setHeight(Rect->bottom - Rect->top); Common::Rect position; - position.left = X; - position.top = Y; + position.left = x; + position.top = y; // TODO: Scaling... position.setWidth((float)srcRect.width() * ZoomX / 100.f); @@ -495,7 +495,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo position.left += offsetX; position.top += offsetY; - renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a, MirrorX, MirrorY); + renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif @@ -503,7 +503,7 @@ HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float Zo return S_OK; } -HRESULT CBSurfaceSDL::PutSurface(const Graphics::Surface &surface) { +HRESULT CBSurfaceSDL::putSurface(const Graphics::Surface &surface) { _surface->copyFrom(surface); return S_OK; } diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 4b43bd3467..961d7e0cdd 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -40,35 +40,35 @@ public: CBSurfaceSDL(CBGame *inGame); ~CBSurfaceSDL(); - HRESULT Create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false); - HRESULT Create(int Width, int Height); + HRESULT create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime = -1, bool keepLoaded = false); + HRESULT create(int Width, int Height); - HRESULT CreateFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + HRESULT createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - bool IsTransparentAt(int X, int Y); - bool IsTransparentAtLite(int X, int Y); + bool isTransparentAt(int x, int y); + bool isTransparentAtLite(int x, int y); - HRESULT StartPixelOp(); - HRESULT EndPixelOp(); + HRESULT startPixelOp(); + HRESULT endPixelOp(); - HRESULT DisplayTransZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTrans(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTransOffset(int X, int Y, RECT rect, uint32 Alpha = 0xFFFFFFFF, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false, int offsetX = 0, int offsetY = 0); - HRESULT Display(int X, int Y, RECT rect, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayZoom(int X, int Y, RECT rect, float ZoomX, float ZoomY, uint32 Alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - HRESULT DisplayTransform(int X, int Y, int HotX, int HotY, RECT Rect, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode = BLEND_NORMAL, bool MirrorX = false, bool MirrorY = false); - virtual HRESULT PutSurface(const Graphics::Surface &surface); + HRESULT displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + HRESULT displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + HRESULT displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + HRESULT displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + HRESULT displayTransform(int x, int y, int HotX, int HotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float Rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual HRESULT putSurface(const Graphics::Surface &surface); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ - virtual int GetWidth() { + virtual int getWidth() { if (_surface) { return _surface->w; } return _width; } - virtual int GetHeight() { + virtual int getHeight() { if (_surface) { return _surface->h; } @@ -79,9 +79,9 @@ private: // SDL_Texture *_texture; Graphics::Surface *_surface; - HRESULT DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX = 0, int offsetY = 0); - void GenAlphaMask(Graphics::Surface *surface); - uint32 GetPixel(Graphics::Surface *surface, int x, int y); + HRESULT drawSprite(int x, int y, RECT *Rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + void genAlphaMask(Graphics::Surface *surface); + uint32 getPixel(Graphics::Surface *surface, int x, int y); void *_lockPixels; int _lockPitch; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 1ff31e1338..5facd1682c 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -72,7 +72,7 @@ HRESULT CBSurfaceStorage::InitLoop() { if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->Invalidate(); + _surfaces[i]->invalidate(); } } } @@ -121,7 +121,7 @@ CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, b if (!surface) return NULL; - if (FAILED(surface->Create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { + if (FAILED(surface->create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { delete surface; return NULL; } else { @@ -136,7 +136,7 @@ CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, b HRESULT CBSurfaceStorage::RestoreAll() { HRESULT ret; for (int i = 0; i < _surfaces.GetSize(); i++) { - ret = _surfaces[i]->Restore(); + ret = _surfaces[i]->restore(); if (ret != S_OK) { Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); return ret; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 9965ed5128..a38b6df54e 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -78,26 +78,26 @@ HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { Game->_renderer->StartSpriteBatch(); // top left/right - _image->_surface->DisplayTrans(X, Y, _upLeft); - _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); + _image->_surface->displayTrans(X, Y, _upLeft); + _image->_surface->displayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); // bottom left/right - _image->_surface->DisplayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); - _image->_surface->DisplayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); + _image->_surface->displayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); + _image->_surface->displayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); // left/right int yyy = Y + (_upMiddle.bottom - _upMiddle.top); for (row = 0; row < nu_rows; row++) { - _image->_surface->DisplayTrans(X, yyy, _middleLeft); - _image->_surface->DisplayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); + _image->_surface->displayTrans(X, yyy, _middleLeft); + _image->_surface->displayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); yyy += tile_width; } // top/bottom int xxx = X + (_upLeft.right - _upLeft.left); for (col = 0; col < nu_columns; col++) { - _image->_surface->DisplayTrans(xxx, Y, _upMiddle); - _image->_surface->DisplayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); + _image->_surface->displayTrans(xxx, Y, _upMiddle); + _image->_surface->displayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); xxx += tile_width; } @@ -106,7 +106,7 @@ HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { for (row = 0; row < nu_rows; row++) { xxx = X + (_upLeft.right - _upLeft.left); for (col = 0; col < nu_columns; col++) { - _image->_surface->DisplayTrans(xxx, yyy, _middleMiddle); + _image->_surface->displayTrans(xxx, yyy, _middleMiddle); xxx += tile_width; } yyy += tile_width; @@ -287,8 +287,8 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { // default if (_image && _image->_surface) { - int Width = _image->_surface->GetWidth() / 3; - int Height = _image->_surface->GetHeight() / 3; + int Width = _image->_surface->getWidth() / 3; + int Height = _image->_surface->getHeight() / 3; if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, Width, Height); if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, Width, 0, 2 * Width, Height); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 3380e8c4a4..6820dbe809 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -131,7 +131,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo // Additional setup. _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); _texture = new CBSurfaceSDL(Game); - _texture->Create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); + _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; @@ -581,10 +581,10 @@ int CVidTheoraPlayer::getMovieFrame() { HRESULT CVidTheoraPlayer::WriteVideo() { if (!_texture) return E_FAIL; - _texture->StartPixelOp(); + _texture->startPixelOp(); //RenderFrame(_texture, &yuv); - _texture->PutSurface(_surface); - _texture->EndPixelOp(); + _texture->putSurface(_surface); + _texture->endPixelOp(); return S_OK; } @@ -596,9 +596,9 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { HRESULT Res; if (_texture) { - CBPlatform::SetRect(&rc, 0, 0, _texture->GetWidth(), _texture->GetHeight()); - if (_playZoom == 100.0f) Res = _texture->DisplayTrans(_posX, _posY, rc, Alpha); - else Res = _texture->DisplayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, Alpha); + CBPlatform::SetRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); + if (_playZoom == 100.0f) Res = _texture->displayTrans(_posX, _posY, rc, Alpha); + else Res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, Alpha); } else Res = E_FAIL; #if 0 if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); -- cgit v1.2.3 From 8adae39ca4e239889469e1017da4d697c892e7f3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 01:21:19 +0200 Subject: WINTERMUTE: Minor cleanup in includes in BSurfaceSDL --- engines/wintermute/Base/BSurfaceSDL.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 2486f9915b..4e4253b1a2 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -26,22 +26,20 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/file/BFile.h" +#include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BRenderSDL.h" -//#include "SdlUtil.h" +#include "engines/wintermute/PlatformSDL.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" #include "engines/wintermute/graphics/transparentSurface.h" #include "engines/wintermute/graphics/tga.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" #include "common/stream.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" #include "common/system.h" namespace WinterMute { -- cgit v1.2.3 From 1d5e59766fc1e6083921741a1ad270dd8d9363d1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 18:24:41 +0200 Subject: WINTERMUTE: Move FORBIDDEN_SYMBOL_EXCEPTION out of the headers and into the CPP-files that still need it. --- engines/wintermute/Base/BGame.cpp | 11 +++++- engines/wintermute/Base/BRegistry.cpp | 3 ++ engines/wintermute/Base/BRenderSDL.cpp | 5 +++ engines/wintermute/Base/scriptables/SXFile.cpp | 44 ++++++++++++++---------- engines/wintermute/Base/scriptables/SXFile.h | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 8 +++-- engines/wintermute/Sys/SysClass.cpp | 2 ++ engines/wintermute/utils/utils.cpp | 2 ++ engines/wintermute/wintypes.h | 5 ++- 9 files changed, 56 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 631fdfd43d..074aad18ff 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -25,8 +25,17 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include +#undef FORBIDDEN_SYMBOL_ALLOW_ALL +#define FORBIDDEN_SYMBOL_EXCEPTION_srand +#define FORBIDDEN_SYMBOL_EXCEPTION_time +#define FORBIDDEN_SYMBOL_EXCEPTION_time +#define FORBIDDEN_SYMBOL_EXCEPTION_localtime +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fopen +#define FORBIDDEN_SYMBOL_EXCEPTION_fclose +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 06a8a63f4f..fcb20ad54f 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -26,7 +26,10 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include +#include "engines/wintermute/tinyxml/tinyxml.h" +#undef FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/utils/PathUtil.h" diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 616aa4b944..de4fdddcbc 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -26,6 +26,11 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fopen +#define FORBIDDEN_SYMBOL_EXCEPTION_fclose +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BRenderSDL.h" #include "engines/wintermute/Base/BRegistry.h" diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index c869b6985d..1c6438e217 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -26,6 +26,14 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_fclose +#define FORBIDDEN_SYMBOL_EXCEPTION_fopen +#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite +#define FORBIDDEN_SYMBOL_EXCEPTION_ftell +#define FORBIDDEN_SYMBOL_EXCEPTION_fseek +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + #include "engines/wintermute/Sys/SysClassRegistry.h" #include "engines/wintermute/Sys/SysClass.h" #include "engines/wintermute/Base/scriptables/ScStack.h" @@ -77,8 +85,8 @@ void CSXFile::Close() { Game->_fileManager->CloseFile(_readFile); _readFile = NULL; } - if (_writeFile) { - fclose(_writeFile); + if ((FILE*)_writeFile) { + fclose((FILE*)_writeFile); _writeFile = NULL; } _mode = 0; @@ -300,9 +308,9 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } if (strcmp(Name, "WriteLine") == 0) - fprintf(_writeFile, "%s\n", Line); + fprintf((FILE*)_writeFile, "%s\n", Line); else - fprintf(_writeFile, "%s", Line); + fprintf((FILE*)_writeFile, "%s", Line); Stack->PushBool(true); @@ -449,7 +457,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -467,7 +475,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -485,7 +493,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -503,7 +511,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -521,7 +529,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -539,7 +547,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, _writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); Stack->PushBool(true); return S_OK; @@ -559,8 +567,8 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } uint32 Size = strlen(Val); - fwrite(&Size, sizeof(Size), 1, _writeFile); - fwrite(Val, Size, 1, _writeFile); + fwrite(&Size, sizeof(Size), 1, (FILE*)_writeFile); + fwrite(Val, Size, 1, (FILE*)_writeFile); Stack->PushBool(true); @@ -653,14 +661,14 @@ HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetPos() { if (_mode == 1 && _readFile) return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile); + else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE*)_writeFile); else return 0; } ////////////////////////////////////////////////////////////////////////// bool CSXFile::SetPos(uint32 pos, TSeek origin) { if (_mode == 1 && _readFile) return _readFile->seek(pos, origin); - else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, pos, (int)origin) == 0; + else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE*)_writeFile, pos, (int)origin) == 0; else return false; } @@ -668,10 +676,10 @@ bool CSXFile::SetPos(uint32 pos, TSeek origin) { uint32 CSXFile::GetLength() { if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { - uint32 CurrentPos = ftell(_writeFile); - fseek(_writeFile, 0, SEEK_END); - int Ret = ftell(_writeFile); - fseek(_writeFile, CurrentPos, SEEK_SET); + uint32 CurrentPos = ftell((FILE*)_writeFile); + fseek((FILE*)_writeFile, 0, SEEK_END); + int Ret = ftell((FILE*)_writeFile); + fseek((FILE*)_writeFile, CurrentPos, SEEK_SET); return Ret; } else return 0; } diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index f1c6552a71..91cef4c1c5 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -48,7 +48,7 @@ public: virtual ~CSXFile(); private: Common::SeekableReadStream *_readFile; - FILE *_writeFile; + void *_writeFile; int _mode; // 0..none, 1..read, 2..write, 3..append bool _textMode; void Close(); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a2c7e077a0..85451bb150 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -25,7 +25,10 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - +#define FORBIDDEN_SYMBOL_ALLOW_ALL +#include +#include +#undef FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/utils/StringUtil.h" @@ -37,8 +40,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BFileManager.h" -#include -#include + namespace WinterMute { diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index cd5bff0c8c..308287c436 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -25,6 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #include "engines/wintermute/persistent.h" #include "SysInstance.h" diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index d1ce280639..c9131608be 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -26,6 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ +#define FORBIDDEN_SYMBOL_EXCEPTION_rand + #include "engines/wintermute/dcgf.h" #include "utils.h" #include "engines/wintermute/PlatformSDL.h" diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index c96b109d07..026dfeab27 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -29,10 +29,10 @@ #ifndef WINTERMUTE_WINTYPES_H #define WINTERMUTE_WINTYPES_H -#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/scummsys.h" //namespace WinterMute { + #ifndef __WIN32__ #define WINAPI @@ -81,8 +81,7 @@ typedef int32 HRESULT; //#define S_FALSE ((HRESULT)1) #define E_FAIL ((HRESULT)-1) - -#endif // !__WIN32__ +#endif __WIN32__ //} // end of namespace WinterMute -- cgit v1.2.3 From f7679dca8c3e0fc07d29376be49188e318273200 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 8 Jun 2012 18:44:57 +0200 Subject: WINTERMUTE: Align TTF's properly. --- engines/wintermute/Base/BFontTT.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 68645e88bb..9b05790876 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -250,6 +250,15 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex Common::Array lines; _font->wordWrapText(text, width, lines); + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; @@ -260,7 +269,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex Common::Array::iterator it; int heightOffset = 0; for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor); + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); heightOffset += _lineHeight; } -- cgit v1.2.3 From ef2eb685ddc94401d3981af863988f4e084fe02b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 15:31:48 +0200 Subject: WINTERMUTE: Formatting in BRenderSDL --- engines/wintermute/Base/BRenderSDL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index de4fdddcbc..365dd0b62d 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -233,7 +233,7 @@ HRESULT CBRenderSDL::Flip() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { +HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); uint32 color = _renderSurface->format.ARGBToColor(0xFF, r, g, b); -- cgit v1.2.3 From 63efd7619221f4c4591c65c2ca3419006586ccbc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 15:35:32 +0200 Subject: WINTERMUTE: Make Theora-playback fail properly when THEORA isn't compiled in. --- engines/wintermute/Base/BGame.cpp | 6 +++++- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 074aad18ff..60a2ee1f28 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1476,7 +1476,11 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } else Stack->PushBool(false); } - else Stack->PushBool(false); + else { + Stack->PushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } return S_OK; } diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 6820dbe809..048027be2c 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -116,7 +116,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo if (!_file) return E_FAIL; //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); -#if defined (USE_THEORA) +#if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else return E_FAIL; -- cgit v1.2.3 From a522aa5f6c6ec0e87f038cda9e6e50f13df41f8e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 16:11:16 +0200 Subject: WINTERMUTE: Make AdEntity-Theora videos work properly. --- engines/wintermute/Ad/AdEntity.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 827209b120..ccd520a543 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -507,7 +507,10 @@ HRESULT CAdEntity::Display() { } DisplaySpriteAttachments(true); - if (_currentSprite) { + if(_theora && (_theora->isPlaying() || _theora->isPaused())) + { + _theora->display(Alpha); + } else if (_currentSprite) { _currentSprite->Display(_posX, _posY, (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, @@ -599,6 +602,20 @@ HRESULT CAdEntity::Update() { UpdateBlockRegion(); _ready = (_state == STATE_READY); + if(_theora) + { + int OffsetX, OffsetY; + Game->GetOffset(&OffsetX, &OffsetY); + _theora->_posX = _posX - OffsetX; + _theora->_posY = _posY - OffsetY; + + _theora->update(); + if(_theora->isFinished()) + { + _theora->stop(); + delete _theora; + } + } UpdatePartEmitter(); UpdateSpriteAttachments(); -- cgit v1.2.3 From 0b02dae394a6fa4828c22526a518accaacc8bd51 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 16:41:59 +0200 Subject: WINTERMUTE: Let looping movies atleast stall at the end for now. --- engines/wintermute/video/VidTheoraPlayer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 048027be2c..3171e6881f 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -446,7 +446,9 @@ HRESULT CVidTheoraPlayer::update() { int Counter = 0; if (_theoraDecoder) { - if (_theoraDecoder->endOfVideo()) { + if (_theoraDecoder->endOfVideo() && _looping) { + warning("Should loop movie"); + } else if (_theoraDecoder->endOfVideo() && !_looping) { warning("Finished movie"); _state = THEORA_STATE_FINISHED; _playbackStarted = false; -- cgit v1.2.3 From 58b054ca970a8cb74d0e5549de522f98d7700801 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 18:47:21 +0200 Subject: WINTERMUTE: Stub out BRenderSDL::DumpData, to get rid of the FORBIDDEN_SYMBOL_EXCEPTIONs there --- engines/wintermute/Base/BRenderSDL.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 365dd0b62d..2457de8f51 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -26,11 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_fopen -#define FORBIDDEN_SYMBOL_EXCEPTION_fclose -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE - #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BRenderSDL.h" #include "engines/wintermute/Base/BRegistry.h" @@ -443,6 +438,8 @@ void CBRenderSDL::PointToScreen(POINT *point) { ////////////////////////////////////////////////////////////////////////// void CBRenderSDL::DumpData(const char *Filename) { + warning("CBRenderSDL::DumpData(%s) - not reimplemented yet", Filename); // TODO +#if 0 FILE *f = fopen(Filename, "wt"); if (!f) return; @@ -471,6 +468,7 @@ void CBRenderSDL::DumpData(const char *Filename) { fclose(f); Game->LOG(0, "Texture Stats Dump completed."); Game->QuickMessage("Texture Stats Dump completed."); +#endif } } // end of namespace WinterMute -- cgit v1.2.3 From 819d16ea9b44476451c32933977278d80ce52def Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 19:14:25 +0200 Subject: WINTERMUTE: Get rid of all but one FORBIDDEN SYMBOL in BGame. --- engines/wintermute/Base/BGame.cpp | 75 +++++++++++++++++------------ engines/wintermute/Sys/SysClass.cpp | 7 ++- engines/wintermute/Sys/SysClass.h | 4 +- engines/wintermute/Sys/SysClassRegistry.cpp | 3 +- engines/wintermute/Sys/SysClassRegistry.h | 3 +- 5 files changed, 55 insertions(+), 37 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 60a2ee1f28..0bd1adddd4 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -25,17 +25,9 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_ALLOW_ALL -#include -#undef FORBIDDEN_SYMBOL_ALLOW_ALL + #define FORBIDDEN_SYMBOL_EXCEPTION_srand -#define FORBIDDEN_SYMBOL_EXCEPTION_time -#define FORBIDDEN_SYMBOL_EXCEPTION_time -#define FORBIDDEN_SYMBOL_EXCEPTION_localtime -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_fopen -#define FORBIDDEN_SYMBOL_EXCEPTION_fclose -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE + #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" @@ -81,6 +73,8 @@ #include "common/textconsole.h" #include "common/util.h" #include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" #ifdef __IPHONEOS__ # include "ios_utils.h" @@ -161,7 +155,7 @@ CBGame::CBGame(): CBObject(this) { _useD3D = false; - srand((unsigned)time(NULL)); + srand(g_system->getMillis()); _registry = new CBRegistry(this); _stringTable = new CBStringTable(this); @@ -530,18 +524,19 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { _dEBUG_DebugMode = true; #ifndef __IPHONEOS__ - if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); - else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); + //if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); + //else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); if (!_dEBUG_LogFile) { AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); - _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); + //_dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); } - if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); + //if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); + warning("BGame::DEBUG_DebugEnable - No logfile is currently created"); //TODO: Use a dumpfile? #endif - time_t timeNow; +/* time_t timeNow; time(&timeNow); struct tm *tm = localtime(&timeNow); @@ -549,6 +544,17 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); #else LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); +#endif*/ + int secs = g_system->getMillis() / 1000; + int hours = secs % 3600; + secs -= hours * 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); #endif LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); @@ -564,7 +570,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { void CBGame::DEBUG_DebugDisable() { if (_dEBUG_LogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - fclose((FILE *)_dEBUG_LogFile); + //fclose((FILE *)_dEBUG_LogFile); _dEBUG_LogFile = NULL; } _dEBUG_DebugMode = false; @@ -576,9 +582,14 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { #ifndef __IPHONEOS__ if (!_dEBUG_DebugMode) return; #endif - time_t timeNow; +/* time_t timeNow; time(&timeNow); - struct tm *tm = localtime(&timeNow); + struct tm *tm = localtime(&timeNow);*/ + int secs = g_system->getMillis() / 1000; + int hours = secs % 3600; + secs -= hours * 3600; + int mins = secs / 60; + secs = secs % 60; char buff[512]; va_list va; @@ -599,9 +610,9 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { } if (_debugMgr) _debugMgr->OnLog(res, buff); - warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff); - fflush((FILE *)_dEBUG_LogFile); + warning("%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_dEBUG_LogFile); #endif //QuickMessage(buff); @@ -1439,12 +1450,12 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { - /* Stack->CorrectParams(0); + Stack->CorrectParams(0); Stack->PushBool(false); return S_OK; // TODO: ADDVIDEO - */ + Stack->CorrectParams(7); const char* Filename = Stack->Pop()->GetString(); warning("PlayTheora: %s - not implemented yet", Filename); @@ -1815,12 +1826,13 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CScValue *Val = Stack->Pop(); + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int FileNum = 0; + while (true) { sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); - FILE *f = fopen(Filename, "rb"); - if (!f) break; - else fclose(f); + if (!Common::File::exists(Filename)) + break; FileNum++; } @@ -4182,11 +4194,14 @@ HRESULT CBGame::ResetContent() { ////////////////////////////////////////////////////////////////////////// void CBGame::DEBUG_DumpClassRegistry() { - FILE *f = fopen("./zz_class_reg_dump.log", "wt"); + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); CSysClassRegistry::GetInstance()->DumpClasses(f); - - fclose(f); + + f->close(); + delete f; Game->QuickMessage("Classes dump completed."); } diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index 308287c436..30ccf3aa08 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -25,8 +25,6 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf #include "engines/wintermute/persistent.h" #include "SysInstance.h" @@ -131,8 +129,9 @@ int CSysClass::GetNumInstances() { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::Dump(void *stream) { - fprintf((FILE *)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); +void CSysClass::Dump(Common::WriteStream *stream) { + Common::String str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); + stream->writeString(str); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h index 3d6200997b..82b612927e 100644 --- a/engines/wintermute/Sys/SysClass.h +++ b/engines/wintermute/Sys/SysClass.h @@ -36,6 +36,8 @@ //#include #include "common/hashmap.h" #include "common/func.h" +#include "common/stream.h" + namespace Common { template struct Hash; @@ -93,7 +95,7 @@ public: void ResetSavedIDs(); - void Dump(void *stream); + void Dump(Common::WriteStream *stream); private: int _numInst; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 25f271fab9..1a644c3a61 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/PlatformSDL.h" #include "SysInstance.h" #include "SysClassRegistry.h" +#include "common/stream.h" namespace WinterMute { @@ -279,7 +280,7 @@ HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::DumpClasses(void *stream) { +void CSysClassRegistry::DumpClasses(Common::WriteStream *stream) { Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) (it->_value)->Dump(stream); diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 5d437af324..870f07df20 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -37,6 +37,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" #include "common/func.h" +#include "common/stream.h" #define FORBIDDEN_SYMBOL_EXCEPTION_FILE @@ -75,7 +76,7 @@ public: bool UnregisterClass(CSysClass *classObj); bool RegisterInstance(const char *className, void *instance); bool UnregisterInstance(const char *className, void *instance); - void DumpClasses(void *stream); + void DumpClasses(Common::WriteStream *stream); int GetNextID(); void AddInstanceToTable(CSysInstance *instance, void *pointer); -- cgit v1.2.3 From 43da09f95b2d5e1138b582da9d52c1a23416eae8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 11 Jun 2012 19:22:03 +0200 Subject: WINTERMUTE: Get rid of even more FORBIDDEN SYMBOLs --- engines/wintermute/Base/scriptables/SXMemBuffer.cpp | 13 ++++++------- engines/wintermute/Sys/SysClassRegistry.h | 4 ---- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index dd869477a1..ab00178b21 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -26,15 +26,12 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE -#define FORBIDDEN_SYMBOL_EXCEPTION_fopen -#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite -#define FORBIDDEN_SYMBOL_EXCEPTION_fclose #include "engines/wintermute/Base/BScriptable.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/SXMemBuffer.h" +#include "common/file.h" namespace WinterMute { @@ -391,9 +388,11 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "DEBUG_Dump") == 0) { Stack->CorrectParams(0); if (_buffer && _size) { - FILE *f = fopen("c:\\!!buffer.bin", "wb"); - fwrite(_buffer, _size, 1, f); - fclose(f); + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); } Stack->PushNULL(); return S_OK; diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 870f07df20..30516d4636 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -32,15 +32,11 @@ #include "engines/wintermute/wintypes.h" #include "engines/wintermute/dctypes.h" #include "engines/wintermute/persistent.h" -//#include -//#include #include "common/hashmap.h" #include "common/hash-str.h" #include "common/func.h" #include "common/stream.h" -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE - namespace WinterMute { class CSysClass; } -- cgit v1.2.3 From 3508829882502b5a4dd5ba21ee47ff347efbf7b8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 14:22:54 +0200 Subject: WINTERMUTE: Correct some math-errors in the debug-logging. --- engines/wintermute/Base/BGame.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 0bd1adddd4..24dc8d357a 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -546,8 +546,8 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); #endif*/ int secs = g_system->getMillis() / 1000; - int hours = secs % 3600; - secs -= hours * 3600; + int hours = secs / 3600; + secs = secs % 3600; int mins = secs / 60; secs = secs % 60; @@ -586,8 +586,8 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { time(&timeNow); struct tm *tm = localtime(&timeNow);*/ int secs = g_system->getMillis() / 1000; - int hours = secs % 3600; - secs -= hours * 3600; + int hours = secs / 3600; + secs = secs % 3600; int mins = secs / 60; secs = secs % 60; -- cgit v1.2.3 From c6c2cfab4e444211654df2906f6e6eecccb9a22c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 14:41:29 +0200 Subject: WINTERMUTE: Fix formatting. --- engines/wintermute/Ad/AdEntity.cpp | 33 ++++++++++--------------- engines/wintermute/Ad/AdGame.cpp | 12 ++++----- engines/wintermute/Ad/AdRegion.cpp | 2 +- engines/wintermute/Ad/AdScene.cpp | 8 +++--- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Base/BFileManager.cpp | 2 +- engines/wintermute/Base/BFontStorage.cpp | 4 +-- engines/wintermute/Base/BFrame.cpp | 3 +-- engines/wintermute/Base/BGame.cpp | 39 +++++++++++++----------------- engines/wintermute/Base/BKeyboardState.cpp | 4 +-- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Base/BRenderer.cpp | 5 ++-- 12 files changed, 51 insertions(+), 65 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index ccd520a543..b7d93d6bd3 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -507,8 +507,7 @@ HRESULT CAdEntity::Display() { } DisplaySpriteAttachments(true); - if(_theora && (_theora->isPlaying() || _theora->isPaused())) - { + if (_theora && (_theora->isPlaying() || _theora->isPaused())) { _theora->display(Alpha); } else if (_currentSprite) { _currentSprite->Display(_posX, @@ -602,16 +601,14 @@ HRESULT CAdEntity::Update() { UpdateBlockRegion(); _ready = (_state == STATE_READY); - if(_theora) - { + if (_theora) { int OffsetX, OffsetY; Game->GetOffset(&OffsetX, &OffsetY); _theora->_posX = _posX - OffsetX; _theora->_posY = _posY - OffsetY; _theora->update(); - if(_theora->isFinished()) - { + if (_theora->isFinished()) { _theora->stop(); delete _theora; } @@ -651,8 +648,8 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _theora; _theora = new CVidTheoraPlayer(Game); - if(_theora && SUCCEEDED(_theora->initialize(Filename))) { - if(!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); + if (_theora && SUCCEEDED(_theora->initialize(Filename))) { + if (!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, Looping, StartTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; Stack->PushBool(true); @@ -669,13 +666,12 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StopTheora") == 0) { Stack->CorrectParams(0); - if(_theora) { + if (_theora) { _theora->stop(); delete _theora; _theora = NULL; Stack->PushBool(true); - } - else Stack->PushBool(false); + } else Stack->PushBool(false); return S_OK; } @@ -685,7 +681,7 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsTheoraPlaying") == 0) { Stack->CorrectParams(0); - if(_theora && _theora->isPlaying()) Stack->PushBool(true); + if (_theora && _theora->isPlaying()) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -696,11 +692,10 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PauseTheora") == 0) { Stack->CorrectParams(0); - if(_theora && _theora->isPlaying()) { + if (_theora && _theora->isPlaying()) { _theora->pause(); Stack->PushBool(true); - } - else Stack->PushBool(false); + } else Stack->PushBool(false); return S_OK; } @@ -710,11 +705,10 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ResumeTheora") == 0) { Stack->CorrectParams(0); - if(_theora && _theora->isPaused()) { + if (_theora && _theora->isPaused()) { _theora->resume(); Stack->PushBool(true); - } - else Stack->PushBool(false); + } else Stack->PushBool(false); return S_OK; } @@ -724,7 +718,7 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IsTheoraPaused") == 0) { Stack->CorrectParams(0); - if(_theora && _theora->isPaused()) Stack->PushBool(true); + if (_theora && _theora->isPaused()) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -871,7 +865,6 @@ HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CAdTalkHolder::ScSetProperty(Name, Value); } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 5c87278217..26cbc299bf 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1693,15 +1693,15 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { if (!_editorMode) _renderer->SetScreenViewport(); // playing exclusive video? - if(_videoPlayer->isPlaying()) { - if(Update) _videoPlayer->update(); + if (_videoPlayer->isPlaying()) { + if (Update) _videoPlayer->update(); _videoPlayer->display(); - } else if(_theoraPlayer) { - if(_theoraPlayer->isPlaying()) { - if(Update) _theoraPlayer->update(); + } else if (_theoraPlayer) { + if (_theoraPlayer->isPlaying()) { + if (Update) _theoraPlayer->update(); _theoraPlayer->display(); } - if(_theoraPlayer->isFinished()) { + if (_theoraPlayer->isFinished()) { delete _theoraPlayer; _theoraPlayer = NULL; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 5ed3097b30..b6735f72ff 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -226,7 +226,7 @@ HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SkipTo ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "SkipTo")==0){ + if (strcmp(Name, "SkipTo")==0) { Stack->CorrectParams(2); _posX = Stack->Pop()->GetInt(); _posY = Stack->Pop()->GetInt(); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 8ebc674c63..3400fba145 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -340,7 +340,7 @@ bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { CAdSceneNode *Node = _mainLayer->_nodes[i]; /* - if(Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { ret = true; break; @@ -883,7 +883,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // *** adjust scroll offset if (Update) { /* - if(_autoScroll && Game->_mainObject != NULL) + if (_autoScroll && Game->_mainObject != NULL) { ScrollToObject(Game->_mainObject); } @@ -2217,7 +2217,7 @@ HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int if (xLength > yLength) { /* - if(X1 > X2) + if (X1 > X2) { Swap(&X1, &X2); Swap(&Y1, &Y2); @@ -2237,7 +2237,7 @@ HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int } } else { /* - if(Y1 > Y2) { + if (Y1 > Y2) { Swap(&X1, &X2); Swap(&Y1, &Y2); } diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index e513d1f3ed..468f8a49c1 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -277,7 +277,7 @@ HRESULT CAdSentence::Update(TDirection Dir) { // if sound is available, synchronize with sound, otherwise use timer /* - if(_sound) CurrentTime = _sound->GetPositionTime(); + if (_sound) CurrentTime = _sound->GetPositionTime(); else CurrentTime = Game->_timer - _startTime; */ CurrentTime = Game->_timer - _startTime; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 9b0789fd1b..ecccb04493 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -127,7 +127,7 @@ byte *CBFileManager::ReadWholeFile(const Common::String &Filename, uint32 *Size, } /* - if(File->GetSize()>MAX_FILE_SIZE){ + if (File->GetSize() > MAX_FILE_SIZE) { Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); CloseFile(File); return NULL; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index b34e24c286..0d00f89e60 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -102,9 +102,9 @@ CBFont *CBFontStorage::AddFont(const char *Filename) { /* CBFont* font = new CBFont(Game); - if(!font) return NULL; + if (!font) return NULL; - if(FAILED(font->LoadFile(Filename))){ + if (FAILED(font->LoadFile(Filename))) { delete font; return NULL; } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 6fa61b5d51..fa1ed5484e 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -93,8 +93,7 @@ HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { if (Owner) Owner->UpdateOneSound(_sound); _sound->Play(); /* - if(Game->_state==GAME_FROZEN) - { + if (Game->_state == GAME_FROZEN) { _sound->Pause(true); } */ diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 24dc8d357a..f5ac836624 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -459,7 +459,7 @@ HRESULT CBGame::Initialize1() { if (_scEngine == NULL) goto init_fail; _videoPlayer = new CVidPlayer(this); - if(_videoPlayer==NULL) goto init_fail; + if (_videoPlayer==NULL) goto init_fail; _transMgr = new CBTransitionMgr(this); if (_transMgr == NULL) goto init_fail; @@ -1420,7 +1420,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS warning("PlayVideo: %s - not implemented yet", Filename); CScValue* valType = Stack->Pop(); int Type; - if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); int X = Stack->Pop()->GetInt(); @@ -1430,12 +1430,11 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CScValue* valSub = Stack->Pop(); const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); - if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + Type = (int)VID_PLAY_STRETCH; - if(SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) - { - if(SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) - { + if (SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { + if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } @@ -1461,7 +1460,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS warning("PlayTheora: %s - not implemented yet", Filename); CScValue* valType = Stack->Pop(); int Type; - if(valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; + if (valType->IsNULL()) + Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); int X = Stack->Pop()->GetInt(); @@ -1471,17 +1471,14 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CScValue* valSub = Stack->Pop(); const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); - - - if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; delete _theoraPlayer; _theoraPlayer = new CVidTheoraPlayer(this); - if(_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) - { + if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !DropFrames; - if(SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) - { + if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } @@ -4239,17 +4236,16 @@ HRESULT CBGame::SetWaitCursor(const char *Filename) { ////////////////////////////////////////////////////////////////////////// bool CBGame::IsVideoPlaying() { - if(_videoPlayer->isPlaying()) return true; - if(_theoraPlayer && _theoraPlayer->isPlaying()) return true; + if (_videoPlayer->isPlaying()) return true; + if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; return false; } ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::StopVideo() { - if(_videoPlayer->isPlaying()) _videoPlayer->stop(); - if(_theoraPlayer && _theoraPlayer->isPlaying()) - { + if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); delete _theoraPlayer; _theoraPlayer = NULL; @@ -4484,8 +4480,7 @@ void CBGame::GetMousePos(POINT *Pos) { /* // Windows can squish maximized window if it's larger than desktop // so we need to modify mouse position appropriately (tnx mRax) - if(_renderer->_windowed && ::IsZoomed(_renderer->_window)) - { + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { RECT rc; ::GetClientRect(_renderer->_window, &rc); Pos->x *= Game->_renderer->_realWidth; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index b81803e0ce..17d27712ad 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -163,9 +163,9 @@ HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Name")==0){ + if (strcmp(Name, "Name") == 0) { SetName(Value->GetString()); - if(_renderer) SetWindowText(_renderer->_window, _name); + if (_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 7c5505bd4a..3372e05ba1 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -267,7 +267,7 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { } /* - if( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) { Game->LOG(0, "ERROR: Saved game is created by other WME version"); goto init_fail; diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index c8de494097..fa9bec5f4f 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -221,8 +221,7 @@ CBImage *CBRenderer::TakeScreenshot() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::ClipCursor() { /* - if(!_windowed) - { + if (!_windowed) { RECT rc; GetWindowRect(_window, &rc); @@ -241,7 +240,7 @@ HRESULT CBRenderer::ClipCursor() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderer::UnclipCursor() { /* - if(!_windowed) ::ClipCursor(NULL); + if (!_windowed) ::ClipCursor(NULL); */ return S_OK; } -- cgit v1.2.3 From eb6895ed6be52a772b4f2bd3e0c4b408202170ea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 15:58:00 +0200 Subject: WINTERMUTE: Add rewindability to Theora-Decoder This currently just abuses the fact that reset() does a rewind instead of a proper reset(). --- engines/wintermute/video/VidTheoraPlayer.cpp | 8 ++++++-- engines/wintermute/video/VidTheoraPlayer.h | 2 +- engines/wintermute/video/decoders/theora_decoder.cpp | 4 ++++ engines/wintermute/video/decoders/theora_decoder.h | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 3171e6881f..fd1b7cea2b 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -448,6 +448,7 @@ HRESULT CVidTheoraPlayer::update() { if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie"); + _theoraDecoder->rewind(); } else if (_theoraDecoder->endOfVideo() && !_looping) { warning("Finished movie"); _state = THEORA_STATE_FINISHED; @@ -576,7 +577,11 @@ int CVidTheoraPlayer::getMovieFrame() { return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); #endif - return 0; + if (_theoraDecoder) { + return _theoraDecoder->getTime(); + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -593,7 +598,6 @@ HRESULT CVidTheoraPlayer::WriteVideo() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::display(uint32 Alpha) { - RECT rc; HRESULT Res; diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 0ce6e42b5a..50a94667fd 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -38,7 +38,7 @@ private: THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; - Video::VideoDecoder *_theoraDecoder; + Video::RewindableVideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); diff --git a/engines/wintermute/video/decoders/theora_decoder.cpp b/engines/wintermute/video/decoders/theora_decoder.cpp index 7c766fe3c6..647d9aff08 100644 --- a/engines/wintermute/video/decoders/theora_decoder.cpp +++ b/engines/wintermute/video/decoders/theora_decoder.cpp @@ -561,6 +561,10 @@ void TheoraDecoder::updateBalance() { g_system->getMixer()->setChannelBalance(*_audHandle, getBalance()); } +void TheoraDecoder::rewind() { + reset(); +} + } // End of namespace Sword25 #endif diff --git a/engines/wintermute/video/decoders/theora_decoder.h b/engines/wintermute/video/decoders/theora_decoder.h index 79e669c068..3844434036 100644 --- a/engines/wintermute/video/decoders/theora_decoder.h +++ b/engines/wintermute/video/decoders/theora_decoder.h @@ -50,7 +50,7 @@ namespace WinterMute { * - sword25 * - wintermute */ -class TheoraDecoder : public Video::VideoDecoder { +class TheoraDecoder : public Video::RewindableVideoDecoder { public: TheoraDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); virtual ~TheoraDecoder(); @@ -87,6 +87,8 @@ public: bool endOfVideo() const; + void rewind(); + protected: // VideoDecoder API void updateVolume(); -- cgit v1.2.3 From c2a2a816f1f3ca39867a150fb224376b784b5ce0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 15:58:32 +0200 Subject: WINTERMUTE: Make sure to NULL-out _theora in AdEntity. --- engines/wintermute/Ad/AdEntity.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index b7d93d6bd3..91b9123697 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -611,6 +611,7 @@ HRESULT CAdEntity::Update() { if (_theora->isFinished()) { _theora->stop(); delete _theora; + _theora = NULL; } } -- cgit v1.2.3 From fcb36b6b9083a52f68989da12b1adb377a782469 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 16:15:53 +0200 Subject: WINTERMUTE: Clear out the debug-printing, so that it's actually readable. --- engines/wintermute/Ad/AdEntity.cpp | 4 ++-- engines/wintermute/Base/BFontTT.cpp | 17 +++++++++++++---- engines/wintermute/Base/BSurfaceSDL.cpp | 1 - engines/wintermute/utils/StringUtil.cpp | 15 +++++++++++++-- 4 files changed, 28 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 91b9123697..71f466fde1 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -585,8 +585,8 @@ HRESULT CAdEntity::Update() { } } break; - default: - warning("AdEntity::Update - Unhandled enum"); + default: // Silence unhandled enum-warning + break; } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 9b05790876..6c61d6bc0d 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -160,7 +160,6 @@ int CBFontTT::GetTextHeight(byte *Text, int Width) { ////////////////////////////////////////////////////////////////////////// void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { - warning("Draw text: %s", Text); if (Text == NULL || strcmp((char *)Text, "") == 0) return; WideString text = (char*)Text; @@ -203,6 +202,7 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, // not found, create one if (!Surface) { + warning("Draw text: %s", Text); Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); if (Surface) { // write surface to cache @@ -258,8 +258,12 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex } else if (align == TAL_RIGHT) { alignment = Graphics::kTextAlignRight; } - - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); @@ -833,7 +837,12 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex ////////////////////////////////////////////////////////////////////////// void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; - warning("Todo: Test Mesuretext"); + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } if (maxWidth >= 0) { Common::Array lines; _font->wordWrapText(text, maxWidth, lines); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 4e4253b1a2..200a34166a 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -76,7 +76,6 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, if (strFileName.hasSuffix(".png")) { imgDecoder = new Graphics::PNGDecoder(); } else if (strFileName.hasSuffix(".bmp")) { - warning("Loaded BMP WITH FILENAME!!!! %s", filename); imgDecoder = new Graphics::BitmapDecoder(); } else if (strFileName.hasSuffix(".tga")) { imgDecoder = new WinterMute::TGA(); diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 8ca2ed8c07..050f76b3b6 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -178,8 +178,14 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { ////////////////////////////////////////////////////////////////////////// WideString StringUtil::AnsiToWide(const AnsiString &str) { + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("StringUtil::AnsiToWide - WideString not supported yet"); + } // using default os locale! - warning("StringUtil::AnsiToWide - WideString not supported yet"); + /* setlocale(LC_CTYPE, ""); size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; wchar_t *wstr = new wchar_t[WideSize]; @@ -193,7 +199,12 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::WideToAnsi(const WideString &wstr) { // using default os locale! - warning("StringUtil::WideToAnsi - WideString not supported yet"); + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("StringUtil::WideToAnsi - WideString not supported yet"); + } /* setlocale(LC_CTYPE, ""); size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; -- cgit v1.2.3 From 92b7703265c83b9dfec702ada156d78fe4eb93ea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 17:32:22 +0200 Subject: WINTERMUTE: Add some loop-support to BSoundBuffer. --- engines/wintermute/Base/BSoundBuffer.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 9751ad44c0..bbec1342c3 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -176,18 +176,24 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { - // TODO: looping +HRESULT CBSoundBuffer::Play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } if (_stream) { - SetLooping(Looping); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + if (looping) { + Audio::AudioStream *loopStream = Audio::makeLoopingAudioStream(_stream, 0); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, loopStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + } } return S_OK; } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetLooping(bool looping) { - warning("BSoundBuffer::SetLooping - not implemented yet"); + warning("BSoundBuffer::SetLooping(%d) - not implemented yet", looping); #if 0 _looping = looping; -- cgit v1.2.3 From 2e3aec48adc591d6496823f234631332e2f4af59 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 19:49:58 +0200 Subject: WINTERMUTE: Optimize the blitting in BSurfaceSDL by adding scale-caching, and alpha-less blits for completely opaque surfaces. --- engines/wintermute/Base/BRenderSDL.cpp | 45 ++++++++++++++++++++ engines/wintermute/Base/BRenderSDL.h | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 73 ++++++++++++++++++++++++++++++--- engines/wintermute/Base/BSurfaceSDL.h | 4 +- 4 files changed, 116 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 2457de8f51..14c2d2a6e4 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -301,6 +301,51 @@ void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect mirror |= TransparentSurface::FLIP_H; src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect,BS_ARGB(a, r, g, b), dstRect->width(), dstRect->height() ); } + +void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a, bool mirrorX, bool mirrorY) { + TransparentSurface src(*surf, false); + TransparentSurface *img = NULL; + TransparentSurface *imgScaled = NULL; + byte *savedPixels = NULL; + if ((dstRect->width() != surf->w) || (dstRect->height() != surf->h)) { + img = imgScaled = src.scale(dstRect->width(), dstRect->height()); + savedPixels = (byte *)img->pixels; + } else { + img = &src; + } + + int posX = dstRect->left; + int posY = dstRect->top; + + // Handle off-screen clipping + if (posY < 0) { + img->h = MAX(0, (int)img->h - -posY); + img->pixels = (byte *)img->pixels + img->pitch * -posY; + posY = 0; + } + + if (posX < 0) { + img->w = MAX(0, (int)img->w - -posX); + img->pixels = (byte *)img->pixels + (-posX * 4); + posX = 0; + } + + img->w = CLIP((int)img->w, 0, (int)MAX((int)_renderSurface->w - posX, 0)); + img->h = CLIP((int)img->h, 0, (int)MAX((int)_renderSurface->h - posY, 0)); + + for (int i = 0; i < img->h; i++) { + void *destPtr = _renderSurface->getBasePtr(posX, posY + i); + void *srcPtr = img->getBasePtr(0, i); + memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel * img->w); + } + + if (imgScaled) { + imgScaled->pixels = savedPixels; + imgScaled->free(); + delete imgScaled; + imgScaled = NULL; + } +} ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { static bool hasWarned = false; diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index ccdca89be5..efcdc5cc4a 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -59,7 +59,7 @@ public: CBImage *TakeScreenshot(); void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool mirrorX = false, bool mirrorY = false); - + void drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool mirrorX = false, bool mirrorY = false); HRESULT SetViewport(int left, int top, int right, int bottom); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 200a34166a..025019ae8c 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -47,6 +47,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { _surface = new Graphics::Surface(); + _scaledSurface = NULL; _alphaMask = NULL; _lockPixels = NULL; @@ -56,14 +57,41 @@ CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::~CBSurfaceSDL() { //TODO - delete _surface; + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + if (_scaledSurface) { + _scaledSurface->free(); + delete _scaledSurface; + _scaledSurface = NULL; + } #if 0 if (_texture) SDL_DestroyTexture(_texture); delete[] _alphaMask; _alphaMask = NULL; - - Game->AddMem(-_width * _height * 4); #endif + Game->AddMem(-_width * _height * 4); +} + +bool hasTransparency(Graphics::Surface *surf) { + if (surf->format.bytesPerPixel != 4) { + warning("hasTransparency:: non 32 bpp surface passed as argument"); + return false; + } + uint8 r,g,b,a; + for (int i = 0; i < surf->h; i++) { + for (int j = 0; j < surf->w; j++) { + uint32 pix = *(uint32*)surf->getBasePtr(j, i); + surf->format.colorToARGB(pix, a, r, g, b); + if (a != 255) { + return true; + } + } + } + return false; } ////////////////////////////////////////////////////////////////////////// @@ -154,6 +182,8 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, _surface = new Graphics::Surface(); _surface->copyFrom(*surface); } + + _hasAlpha = hasTransparency(_surface); //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); @@ -293,9 +323,9 @@ HRESULT CBSurfaceSDL::create(int width, int height) { #endif _width = width; _height = height; -#if 0 + Game->AddMem(_width * _height * 4); -#endif + _valid = true; return S_OK; @@ -492,7 +522,38 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo position.left += offsetX; position.top += offsetY; - renderer->drawFromSurface(_surface, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); + // TODO: This actually requires us to have the SAME source-offsets every time, + // But no checking is in place for that yet. + Graphics::Surface drawSrc; + drawSrc.w = position.width(); + drawSrc.h = position.height(); + drawSrc.format = _surface->format; + + if (position.width() != srcRect.width() || position.height() != srcRect.height()) { + if (_scaledSurface && position.width() == _scaledSurface->w && position.height() == _scaledSurface->h) { + drawSrc.pixels = _scaledSurface->pixels; + drawSrc.pitch = _scaledSurface->pitch; + } else { + delete _scaledSurface; + TransparentSurface src(*_surface, false); + _scaledSurface = src.scale(position.width(), position.height()); + drawSrc.pixels = _scaledSurface->pixels; + drawSrc.pitch = _scaledSurface->pitch; + } + } else { // No scaling + drawSrc.pitch = _surface->pitch; + drawSrc.pixels = &((char *)_surface->pixels)[srcRect.top * _surface->pitch + srcRect.left * 4]; + } + srcRect.left = 0; + srcRect.top = 0; + srcRect.setWidth(drawSrc.w); + srcRect.setHeight(drawSrc.h); + + if (_hasAlpha && !AlphaDisable) { + renderer->drawFromSurface(&drawSrc, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); + } else { + renderer->drawOpaqueFromSurface(&drawSrc, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); + } #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 961d7e0cdd..34d25b43b5 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -34,7 +34,7 @@ #include "graphics/surface.h" namespace WinterMute { - +class TransparentSurface; class CBSurfaceSDL : public CBSurface { public: CBSurfaceSDL(CBGame *inGame); @@ -78,11 +78,13 @@ public: private: // SDL_Texture *_texture; Graphics::Surface *_surface; + TransparentSurface *_scaledSurface; HRESULT drawSprite(int x, int y, RECT *Rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); + bool _hasAlpha; void *_lockPixels; int _lockPitch; byte *_alphaMask; -- cgit v1.2.3 From 0793c961a4066cc0396e781516d63e88a8f92c97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 19:50:36 +0200 Subject: WINTERMUTE: Fix some memory-leaks in BSoundBuffer. --- engines/wintermute/Base/BSoundBuffer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index bbec1342c3..052dbf98d5 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -112,6 +112,9 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { } _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::NO); + if (!_stream) { + return E_FAIL; + } CBUtils::SetString(&_filename, Filename); return S_OK; @@ -182,10 +185,10 @@ HRESULT CBSoundBuffer::Play(bool looping, uint32 startSample) { } if (_stream) { if (looping) { - Audio::AudioStream *loopStream = Audio::makeLoopingAudioStream(_stream, 0); + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, loopStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); } else { - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); } } return S_OK; -- cgit v1.2.3 From 879d6902f4f55db949ea2fe096611f8cbaabc652 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 15:33:45 +0200 Subject: WINTERMUTE: Use the correct height for TTF-fonts. --- engines/wintermute/Base/BFontTT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 6c61d6bc0d..3c72d974ab 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -267,7 +267,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create(width, _fontHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + surface->create(width, _lineHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); uint16 useColor = 0xffff; Common::Array::iterator it; -- cgit v1.2.3 From b8a6dce3988e3599463f56fe401feadc451d5bf0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 15:35:29 +0200 Subject: WINTERMUTE: Implement various functions in BRenderSDL. --- engines/wintermute/Base/BRenderSDL.cpp | 43 +++++++++++++++++++-------------- engines/wintermute/Base/BSurfaceSDL.cpp | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 14c2d2a6e4..da35408142 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -46,7 +46,7 @@ namespace WinterMute { CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { /* _renderer = NULL; _win = NULL;*/ - _renderSurface = NULL; + _renderSurface = new Graphics::Surface(); _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; @@ -54,6 +54,8 @@ CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { ////////////////////////////////////////////////////////////////////////// CBRenderSDL::~CBRenderSDL() { + _renderSurface->free(); + delete _renderSurface; #if 0 if (_renderer) SDL_DestroyRenderer(_renderer); if (_win) SDL_DestroyWindow(_win); @@ -156,8 +158,7 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (!_win) return E_FAIL; #endif - warning("TODO: Hide cursor"); - //SDL_ShowCursor(SDL_DISABLE); + g_system->showMouse(false); #ifdef __IPHONEOS__ // SDL defaults to OGL ES2, which doesn't work on old devices @@ -170,7 +171,6 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { if (!_renderer) return E_FAIL; #endif - _renderSurface = new Graphics::Surface(); _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; @@ -261,21 +261,21 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { warning("Implement CBRenderSDL::FadeToColor"); // TODO. hasWarned = true; } -#if 0 - SDL_Rect fillRect; + + Common::Rect fillRect; if (rect) { - fillRect.x = rect->left; - fillRect.y = rect->top; - fillRect.w = rect->right - rect->left; - fillRect.h = rect->bottom - rect->top; + fillRect.left = rect->left; + fillRect.top = rect->top; + fillRect.setWidth(rect->width()); + fillRect.setHeight(rect->height()); } else { RECT rc; Game->GetCurrentViewportRect(&rc); - fillRect.x = rc.left; - fillRect.y = rc.top; - fillRect.w = rc.right - rc.left; - fillRect.h = rc.bottom - rc.top; + fillRect.left = rc.left; + fillRect.top = rc.top; + fillRect.setWidth(rc.right - rc.left); + fillRect.setHeight(rc.bottom - rc.top); } ModTargetRect(&fillRect); @@ -284,10 +284,14 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { byte b = D3DCOLGetB(Color); byte a = D3DCOLGetA(Color); + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->fillRect(fillRect, col); + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); -#endif + return S_OK; } @@ -353,10 +357,10 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { warning("CBRenderSDL::DrawLine - not fully ported yet"); hasWarned = true; } -/* byte r = D3DCOLGetR(Color); + byte r = D3DCOLGetR(Color); byte g = D3DCOLGetG(Color); byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color);*/ + byte a = D3DCOLGetA(Color); //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); @@ -370,7 +374,9 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { point2.y = Y2; PointToScreen(&point2); - + // TODO: This thing is mostly here until I'm sure about the final color-format. + uint32 color = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, color); //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); return S_OK; } @@ -378,6 +384,7 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { ////////////////////////////////////////////////////////////////////////// CBImage *CBRenderSDL::TakeScreenshot() { // TODO: Fix this + warning("CBRenderSDL::TakeScreenshot() - not ported yet"); #if 0 SDL_Rect viewport; diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 025019ae8c..715c057783 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -49,6 +49,7 @@ CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { _surface = new Graphics::Surface(); _scaledSurface = NULL; _alphaMask = NULL; + _hasAlpha = true; _lockPixels = NULL; _lockPitch = 0; -- cgit v1.2.3 From c081d40c961ef61549b4485d79fcb62fc2e2ad73 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 20:17:36 +0200 Subject: WINTERMUTE: Move image-loading to BImage, and cleanup some relevant code. --- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BImage.cpp | 51 +++++++++++++++++++++++++++ engines/wintermute/Base/BImage.h | 18 +++++++--- engines/wintermute/Base/BRenderSDL.cpp | 20 +++++++++-- engines/wintermute/Base/BRenderSDL.h | 7 ++-- engines/wintermute/Base/BSurface.h | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 62 +++++++++++++-------------------- engines/wintermute/Base/BSurfaceSDL.h | 2 +- 8 files changed, 114 insertions(+), 50 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 3c72d974ab..449767e359 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -278,7 +278,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex } CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); - retSurface->putSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0))); + retSurface->putSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)), true); delete surface; return retSurface; #if 0 //TODO diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 7561e65adc..bacfd9ece5 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -28,6 +28,18 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/bmp.h" +#include "graphics/surface.h" +#include "engines/wintermute/graphics/tga.h" +#include "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" //#include "FreeImage.h" namespace WinterMute { @@ -38,16 +50,55 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { _bitmap = bitmap; #endif _bitmap = NULL; + _palette = NULL; + _surface = NULL; + _decoder = NULL; } ////////////////////////////////////////////////////////////////////// CBImage::~CBImage() { + delete _bitmap; + delete _decoder; #if 0 if (_bitmap) FreeImage_Unload(_bitmap); #endif } +HRESULT CBImage::loadFile(const Common::String &filename) { + _filename = filename; + Graphics::ImageDecoder *imgDecoder; + + if (filename.hasSuffix(".png")) { + imgDecoder = new Graphics::PNGDecoder(); + } else if (filename.hasSuffix(".bmp")) { + imgDecoder = new Graphics::BitmapDecoder(); + } else if (filename.hasSuffix(".tga")) { + imgDecoder = new WinterMute::TGA(); + } else if (filename.hasSuffix(".jpg")) { + imgDecoder = new Graphics::JPEGDecoder(); + } else { + error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename.c_str()); + if (!file) return E_FAIL; + + imgDecoder->loadStream(*file); + _surface = imgDecoder->getSurface(); + _palette = imgDecoder->getPalette(); + Game->_fileManager->CloseFile(file); + + return S_OK; +} + +byte CBImage::getAlphaAt(int x, int y) { + if (!_surface) return 0xFF; + uint32 color = *(uint32*)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} ////////////////////////////////////////////////////////////////////////// HRESULT CBImage::SaveBMPFile(const char *Filename) { diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index cabc155723..2cc1a448f8 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -32,29 +32,37 @@ //#include "FreeImage.h" #include "engines/wintermute/Base/BBase.h" +#include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/decoders/image_decoder.h" #include "common/endian.h" +#include "common/str.h" struct FIBITMAP; namespace WinterMute { - +class CBSurface; class CBImage: CBBase { public: CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); ~CBImage(); - + HRESULT loadFile(const Common::String &filename); + const Graphics::Surface *getSurface() const { return _surface; }; + const byte *getPalette() const { return _palette; } + byte getAlphaAt(int x, int y); byte *CreateBMPBuffer(uint32 *BufferSize = NULL); HRESULT Resize(int NewWidth, int NewHeight); HRESULT SaveBMPFile(const char *Filename); HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); - FIBITMAP *GetBitmap() const { - return _bitmap; - } private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; FIBITMAP *_bitmap; + const Graphics::Surface *_surface; + const byte *_palette; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index da35408142..86aa518de2 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -50,6 +50,8 @@ CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); } ////////////////////////////////////////////////////////////////////////// @@ -178,6 +180,18 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { return S_OK; } +void CBRenderSDL::setAlphaMod(byte alpha) { + byte r = D3DCOLGetR(_colorMod); + byte g = D3DCOLGetB(_colorMod); + byte b = D3DCOLGetB(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +void CBRenderSDL::setColorMod(byte r, byte g, byte b) { + byte alpha = D3DCOLGetA(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::Flip() { @@ -296,17 +310,17 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { } // Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a, bool mirrorX, bool mirrorY) { +void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { TransparentSurface src(*surf, false); int mirror = TransparentSurface::FLIP_NONE; if (mirrorX) mirror |= TransparentSurface::FLIP_V; if (mirrorY) mirror |= TransparentSurface::FLIP_H; - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect,BS_ARGB(a, r, g, b), dstRect->width(), dstRect->height() ); + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect, _colorMod, dstRect->width(), dstRect->height() ); } -void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, byte r, byte g, byte b, byte a, bool mirrorX, bool mirrorY) { +void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { TransparentSurface src(*surf, false); TransparentSurface *img = NULL; TransparentSurface *imgScaled = NULL; diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index efcdc5cc4a..2a1910790a 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -58,8 +58,10 @@ public: CBImage *TakeScreenshot(); - void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool mirrorX = false, bool mirrorY = false); - void drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, byte r = 255, byte g = 255, byte b = 255, byte a = 255, bool mirrorX = false, bool mirrorY = false); + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + void drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); HRESULT SetViewport(int left, int top, int right, int bottom); @@ -89,6 +91,7 @@ private: float _ratioX; float _ratioY; + uint32 _colorMod; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 469923bcdd..e91f03ca02 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -63,7 +63,7 @@ public: virtual HRESULT restore(); virtual HRESULT create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; virtual HRESULT create(int Width, int Height); - virtual HRESULT putSurface(const Graphics::Surface &surface) { return E_FAIL; } + virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return E_FAIL; } virtual HRESULT putPixel(int x, int y, byte r, byte g, byte b, int a = -1); virtual HRESULT getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 715c057783..5c4e6952d7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/PlatformSDL.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" @@ -99,28 +100,10 @@ bool hasTransparency(Graphics::Surface *surf) { HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(filename); - - Graphics::ImageDecoder *imgDecoder; - - if (strFileName.hasSuffix(".png")) { - imgDecoder = new Graphics::PNGDecoder(); - } else if (strFileName.hasSuffix(".bmp")) { - imgDecoder = new Graphics::BitmapDecoder(); - } else if (strFileName.hasSuffix(".tga")) { - imgDecoder = new WinterMute::TGA(); - } else if (strFileName.hasSuffix(".jpg")) { - imgDecoder = new Graphics::JPEGDecoder(); - } else { - error("CBSurfaceSDL::Create : Unsupported fileformat %s", filename); - } - - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename); - if (!file) return E_FAIL; - - imgDecoder->loadStream(*file); - const Graphics::Surface *surface = imgDecoder->getSurface(); - const byte* palette = imgDecoder->getPalette(); - Game->_fileManager->CloseFile(file); + warning("CBSurfaceSDL::create(%s, %d, %d, %d, %d, %d, %d", filename, default_ck, ck_red, ck_green, ck_blue, lifeTime, keepLoaded); + CBImage *image = new CBImage(Game); + image->loadFile(strFileName); +// const Graphics::Surface *surface = image->getSurface(); if (default_ck) { ck_red = 255; @@ -128,8 +111,8 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, ck_blue = 255; } - _width = surface->w; - _height = surface->h; + _width = image->getSurface()->w; + _height = image->getSurface()->h; bool isSaveGameGrayscale = scumm_strnicmp(filename, "savegame:", 9) == 0 && (filename[strFileName.size() - 1] == 'g' || filename[strFileName.size() - 1] == 'G'); if (isSaveGameGrayscale) { @@ -169,19 +152,19 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. - if (strFileName.hasSuffix(".bmp") && surface->format.bytesPerPixel == 4) { - _surface = surface->convertTo(g_system->getScreenFormat(), palette); + if (strFileName.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); trans.applyColorKey(ck_red, ck_green, ck_blue); - } else if (surface->format.bytesPerPixel == 1 && palette) { - _surface = surface->convertTo(g_system->getScreenFormat(), palette); + } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); trans.applyColorKey(ck_red, ck_green, ck_blue, true); - } else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) { - _surface = surface->convertTo(g_system->getScreenFormat()); + } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); } else { _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); + _surface->copyFrom(*image->getSurface()); } _hasAlpha = hasTransparency(_surface); @@ -195,7 +178,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, warning("Surface-textures not fully ported yet"); hasWarned = true; } - delete imgDecoder; + //delete imgDecoder; #if 0 _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); if (!_texture) { @@ -226,9 +209,10 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, if (_keepLoaded) _lifeTime = -1; _valid = true; -#if 0 + Game->AddMem(_width * _height * 4); -#endif + + delete image; return S_OK; } @@ -493,6 +477,9 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo byte g = D3DCOLGetG(Alpha); byte b = D3DCOLGetB(Alpha); byte a = D3DCOLGetA(Alpha); + + renderer->setAlphaMod(a); + renderer->setColorMod(r, g, b); #if 0 SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); @@ -551,9 +538,9 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo srcRect.setHeight(drawSrc.h); if (_hasAlpha && !AlphaDisable) { - renderer->drawFromSurface(&drawSrc, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); + renderer->drawFromSurface(&drawSrc, &srcRect, &position, mirrorX, mirrorY); } else { - renderer->drawOpaqueFromSurface(&drawSrc, &srcRect, &position, r, g, b, a, mirrorX, mirrorY); + renderer->drawOpaqueFromSurface(&drawSrc, &srcRect, &position, mirrorX, mirrorY); } #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); @@ -562,8 +549,9 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo return S_OK; } -HRESULT CBSurfaceSDL::putSurface(const Graphics::Surface &surface) { +HRESULT CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _surface->copyFrom(surface); + _hasAlpha = hasAlpha; return S_OK; } diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 34d25b43b5..6301310f01 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -58,7 +58,7 @@ public: HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); HRESULT displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); HRESULT displayTransform(int x, int y, int HotX, int HotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float Rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual HRESULT putSurface(const Graphics::Surface &surface); + virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ -- cgit v1.2.3 From d4ac01148f54f0320657d7e29092be8893c6c9fc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 20:17:59 +0200 Subject: WINTERMUTE: Add support for alpha-images in Theora-player. --- engines/wintermute/video/VidTheoraPlayer.cpp | 54 +++++++++++++++++++++++----- engines/wintermute/video/VidTheoraPlayer.h | 5 +-- 2 files changed, 48 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index fd1b7cea2b..9877a67bdc 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -60,7 +60,7 @@ void CVidTheoraPlayer::SetDefaults() { _texture = NULL; _alphaImage = NULL; - _alphaFilename = NULL; + _alphaFilename = ""; _frameRendered = false; @@ -589,13 +589,38 @@ HRESULT CVidTheoraPlayer::WriteVideo() { if (!_texture) return E_FAIL; _texture->startPixelOp(); + + writeAlpha(); + if (_alphaImage) { + _texture->putSurface(_surface, true); + } else { + _texture->putSurface(_surface, false); + } + //RenderFrame(_texture, &yuv); - _texture->putSurface(_surface); + _texture->endPixelOp(); return S_OK; } +void CVidTheoraPlayer::writeAlpha() { + if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { + assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); + assert(_surface.format.bytesPerPixel == 4); + const byte *alphaData = (byte*)_alphaImage->getSurface()->getBasePtr(0, 0); + int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); + alphaData += alphaPlace; + byte *imgData = (byte*)_surface.getBasePtr(0,0); + imgData += (_surface.format.aShift / 8); + for (int i = 0; i < _surface.w * _surface.h; i++) { + *imgData = *alphaData; + alphaData += 4; + imgData += 4; + } + } +} + ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::display(uint32 Alpha) { RECT rc; @@ -613,8 +638,22 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::setAlphaImage(const char *filename) { - warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename); +HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { + warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); + + delete _alphaImage; + _alphaImage = new CBImage(Game); + if (!_alphaImage || FAILED(_alphaImage->loadFile(filename))) { + delete _alphaImage; + _alphaImage = NULL; + _alphaFilename = ""; + return E_FAIL; + } + + if (_alphaFilename != filename) { + _alphaFilename = filename; + } + //TODO: Conversion. #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); @@ -631,11 +670,8 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const char *filename) { ////////////////////////////////////////////////////////////////////////// byte CVidTheoraPlayer::getAlphaAt(int X, int Y) { -#if 0 - if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); + if (_alphaImage) return _alphaImage->getAlphaAt(X, Y); else return 0xFF; -#endif - return 0; } @@ -770,7 +806,7 @@ HRESULT CVidTheoraPlayer::resume() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initializeSimple() { if (SUCCEEDED(initialize(_filename))) { - if (_alphaFilename) setAlphaImage(_alphaFilename); + if (_alphaFilename != "") setAlphaImage(_alphaFilename); play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); } else _state = THEORA_STATE_FINISHED; diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 50a94667fd..fc89b07c53 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -115,9 +115,10 @@ public: // alpha related CBImage *_alphaImage; - char *_alphaFilename; - HRESULT setAlphaImage(const char *Filename); + Common::String _alphaFilename; + HRESULT setAlphaImage(const Common::String &filename); __inline byte getAlphaAt(int X, int Y); + void writeAlpha(); HRESULT SeekToTime(uint32 Time); -- cgit v1.2.3 From fb7423f47ceca492aa84ce2a8baa2725fe6056ea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 21:09:42 +0200 Subject: WINTERMUTE: Fix a critical typo in II_ADD in ScScript --- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 7a2f0db62a..49e3417946 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -764,7 +764,7 @@ HRESULT CScScript::ExecuteInstruction() { char *tempStr = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; strcpy(tempStr, op1->GetString()); strcat(tempStr, op2->GetString()); - _operand->SetString(str); + _operand->SetString(tempStr); delete [] tempStr; } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() + op2->GetInt()); -- cgit v1.2.3 From 84837f4bae998d8067f809531533e4f5afeb28be Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 13 Jun 2012 22:37:13 +0200 Subject: WINTERMUTE: Implement SXDate --- engines/wintermute/Base/scriptables/SXDate.cpp | 118 ++++++++++++++----------- engines/wintermute/Base/scriptables/SXDate.h | 6 +- 2 files changed, 70 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index e9cfc4b406..28b152149c 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -37,25 +37,20 @@ IMPLEMENT_PERSISTENT(CSXDate, false) ////////////////////////////////////////////////////////////////////////// CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(6); -#if 0 + memset(&_tm, 0, sizeof(_tm)); CScValue *valYear = Stack->Pop(); - _tm.t_year = valYear->GetInt() - 1900; - _tm.t_mon = Stack->Pop()->GetInt() - 1; - _tm.t_mday = Stack->Pop()->GetInt(); - _tm.t_hour = Stack->Pop()->GetInt(); - _tm.t_min = Stack->Pop()->GetInt(); - _tm.t_sec = Stack->Pop()->GetInt(); + _tm.tm_year = valYear->GetInt() - 1900; + _tm.tm_mon = Stack->Pop()->GetInt() - 1; + _tm.tm_mday = Stack->Pop()->GetInt(); + _tm.tm_hour = Stack->Pop()->GetInt(); + _tm.tm_min = Stack->Pop()->GetInt(); + _tm.tm_sec = Stack->Pop()->GetInt(); if (valYear->IsNULL()) { - time_t TimeNow; - time(&TimeNow); - memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); + g_system->getTimeAndDate(_tm); } - - mktime(&_tm); -#endif } @@ -64,25 +59,25 @@ CSXDate::~CSXDate() { } - ////////////////////////////////////////////////////////////////////////// const char *CSXDate::ScToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); #if 0 return asctime(&_tm); #endif - return ""; } ////////////////////////////////////////////////////////////////////////// HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { -#if 0 ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "GetYear") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_year + 1900); + Stack->PushInt(_tm.tm_year + 1900); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -90,7 +85,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetMonth") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_mon + 1); + Stack->PushInt(_tm.tm_mon + 1); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -98,7 +93,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetDate") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_mday); + Stack->PushInt(_tm.tm_mday); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -106,7 +101,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetHours") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_hour); + Stack->PushInt(_tm.tm_hour); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -114,7 +109,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetMinutes") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_min); + Stack->PushInt(_tm.tm_min); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -122,7 +117,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetSeconds") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_sec); + Stack->PushInt(_tm.tm_sec); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -130,7 +125,8 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetWeekday") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_tm.t_wday); + warning("GetWeekday returns a wrong value on purpose"); + Stack->PushInt(_tm.tm_mday % 7); return S_OK; } @@ -140,8 +136,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetYear") == 0) { Stack->CorrectParams(1); - _tm.t_year = Stack->Pop()->GetInt() - 1900; - mktime(&_tm); + _tm.tm_year = Stack->Pop()->GetInt() - 1900; Stack->PushNULL(); return S_OK; } @@ -150,8 +145,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetMonth") == 0) { Stack->CorrectParams(1); - _tm.t_mon = Stack->Pop()->GetInt() - 1; - mktime(&_tm); + _tm.tm_mon = Stack->Pop()->GetInt() - 1; Stack->PushNULL(); return S_OK; } @@ -160,8 +154,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetDate") == 0) { Stack->CorrectParams(1); - _tm.t_mday = Stack->Pop()->GetInt(); - mktime(&_tm); + _tm.tm_mday = Stack->Pop()->GetInt(); Stack->PushNULL(); return S_OK; } @@ -170,8 +163,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetHours") == 0) { Stack->CorrectParams(1); - _tm.t_hour = Stack->Pop()->GetInt(); - mktime(&_tm); + _tm.tm_hour = Stack->Pop()->GetInt(); Stack->PushNULL(); return S_OK; } @@ -180,8 +172,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetMinutes") == 0) { Stack->CorrectParams(1); - _tm.t_min = Stack->Pop()->GetInt(); - mktime(&_tm); + _tm.tm_min = Stack->Pop()->GetInt(); Stack->PushNULL(); return S_OK; } @@ -190,8 +181,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetSeconds") == 0) { Stack->CorrectParams(1); - _tm.t_sec = Stack->Pop()->GetInt(); - mktime(&_tm); + _tm.tm_sec = Stack->Pop()->GetInt(); Stack->PushNULL(); return S_OK; } @@ -202,16 +192,12 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetCurrentTime") == 0) { Stack->CorrectParams(0); - time_t TimeNow; - time(&TimeNow); - memcpy(&_tm, localtime(&TimeNow), sizeof(_tm)); - mktime(&_tm); + g_system->getTimeAndDate(_tm); Stack->PushNULL(); return S_OK; } else -#endif return E_FAIL; } @@ -251,27 +237,55 @@ HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); -#if 0 if (PersistMgr->_saving) PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); else PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); -#endif return S_OK; } - ////////////////////////////////////////////////////////////////////////// int CSXDate::ScCompare(CBScriptable *Value) { -#if 0 - time_t time1 = mktime(&_tm); - time_t time2 = mktime(&((CSXDate *)Value)->_tm); - - if (time1 < time2) return -1; - else if (time1 > time2) return 1; - else -#endif - return 0; + TimeDate time1 = _tm; + TimeDate time2 = ((CSXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 7d4d29af93..95334d0196 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_SXDATE_H #define WINTERMUTE_SXDATE_H - +#include "common/system.h" #include "engines/wintermute/Base/BScriptable.h" namespace WinterMute { @@ -45,7 +45,9 @@ public: HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); const char *ScToString(); char *_string; - //struct tm _tm; // TODO! + TimeDate _tm; +private: + Common::String _strRep; }; } // end of namespace WinterMute -- cgit v1.2.3 From 076ed07e9277ea0fd8b49c9dd8734de8d13145b1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 00:12:15 +0200 Subject: WINTERMUTE: Fix theora-playback with the new Rendering-changes. --- engines/wintermute/Base/BGame.cpp | 5 ++--- engines/wintermute/Base/BSurfaceSDL.cpp | 6 ++++++ engines/wintermute/video/VidTheoraPlayer.cpp | 11 +++++------ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index f5ac836624..15510ec6d5 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1449,15 +1449,14 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { - Stack->CorrectParams(0); +/* Stack->CorrectParams(0); Stack->PushBool(false); - return S_OK; + return S_OK;*/ // TODO: ADDVIDEO Stack->CorrectParams(7); const char* Filename = Stack->Pop()->GetString(); - warning("PlayTheora: %s - not implemented yet", Filename); CScValue* valType = Stack->Pop(); int Type; if (valType->IsNULL()) diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 5c4e6952d7..8c8c6d4fb9 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -416,6 +416,12 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + if (_scaledSurface) { + _scaledSurface->free(); + delete _scaledSurface; + _scaledSurface = NULL; + } return S_OK; } diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 9877a67bdc..ca01b51d6f 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -458,10 +458,9 @@ HRESULT CVidTheoraPlayer::update() { if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); - _videoFrameReady = true; - } - if (_texture && _videoFrameReady) { - WriteVideo(); + if (_texture) { + WriteVideo(); + } } return S_OK; } @@ -600,7 +599,7 @@ HRESULT CVidTheoraPlayer::WriteVideo() { //RenderFrame(_texture, &yuv); _texture->endPixelOp(); - + _videoFrameReady = true; return S_OK; } @@ -626,7 +625,7 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { RECT rc; HRESULT Res; - if (_texture) { + if (_texture && _videoFrameReady) { CBPlatform::SetRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); if (_playZoom == 100.0f) Res = _texture->displayTrans(_posX, _posY, rc, Alpha); else Res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, Alpha); -- cgit v1.2.3 From c1046889411d4f38babd21b1b38c0cbd457caf10 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 00:56:24 +0200 Subject: WINTERMUTE: Fix quite a lot of memory leaks. --- engines/wintermute/Base/BFontTT.cpp | 6 +++++- engines/wintermute/Base/BImage.cpp | 15 +++++++-------- engines/wintermute/Base/BSurfaceSDL.cpp | 6 +++++- engines/wintermute/video/VidTheoraPlayer.cpp | 8 ++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 449767e359..c2991f1277 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -278,8 +278,12 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex } CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); - retSurface->putSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)), true); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); delete surface; + delete convertedSurface; return retSurface; #if 0 //TODO int textHeight = lines.size() * (_maxCharHeight + _ascender); diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index bacfd9ece5..69859b4c05 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -67,16 +67,15 @@ CBImage::~CBImage() { HRESULT CBImage::loadFile(const Common::String &filename) { _filename = filename; - Graphics::ImageDecoder *imgDecoder; if (filename.hasSuffix(".png")) { - imgDecoder = new Graphics::PNGDecoder(); + _decoder = new Graphics::PNGDecoder(); } else if (filename.hasSuffix(".bmp")) { - imgDecoder = new Graphics::BitmapDecoder(); + _decoder = new Graphics::BitmapDecoder(); } else if (filename.hasSuffix(".tga")) { - imgDecoder = new WinterMute::TGA(); + _decoder = new WinterMute::TGA(); } else if (filename.hasSuffix(".jpg")) { - imgDecoder = new Graphics::JPEGDecoder(); + _decoder = new Graphics::JPEGDecoder(); } else { error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); } @@ -84,9 +83,9 @@ HRESULT CBImage::loadFile(const Common::String &filename) { Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename.c_str()); if (!file) return E_FAIL; - imgDecoder->loadStream(*file); - _surface = imgDecoder->getSurface(); - _palette = imgDecoder->getPalette(); + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); Game->_fileManager->CloseFile(file); return S_OK; diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 8c8c6d4fb9..ae7bad54b7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -528,7 +528,11 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo drawSrc.pixels = _scaledSurface->pixels; drawSrc.pitch = _scaledSurface->pitch; } else { - delete _scaledSurface; + if (_scaledSurface) { + _scaledSurface->free(); + delete _scaledSurface; + _scaledSurface = NULL; + } TransparentSurface src(*_surface, false); _scaledSurface = src.scale(position.width(), position.height()); drawSrc.pixels = _scaledSurface->pixels; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index ca01b51d6f..33ef835933 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -74,6 +74,7 @@ void CVidTheoraPlayer::SetDefaults() { _savedState = THEORA_STATE_NONE; _savedPos = 0; _volume = 100; + _theoraDecoder = NULL; #if 0 _vorbisStreams = _theoraStreams = 0; @@ -96,6 +97,13 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { ////////////////////////////////////////////////////////////////////////// void CVidTheoraPlayer::cleanup() { + _surface.free(); + delete _theoraDecoder; + _theoraDecoder = NULL; + delete _alphaImage; + _alphaImage = NULL; + delete _texture; + _texture = NULL; #if 0 if (m_Sound) { Game->m_SoundMgr->RemoveSound(m_Sound); -- cgit v1.2.3 From 7f19595d911cd017439cc6a3e87f04698c8bbacc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 02:18:47 +0200 Subject: WINTERMUTE: Fix SXString's - "Split" --- engines/wintermute/Base/scriptables/SXString.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 4a1936da58..50799d6d4a 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/Base/scriptables/SXString.h" #include "engines/wintermute/Base/scriptables/SXArray.h" #include "engines/wintermute/utils/StringUtil.h" +#include "common/tokenizer.h" namespace WinterMute { @@ -268,7 +269,14 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th size_t start, pos; start = 0; - do { + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); //pos = str.find_first_of(delims, start); if (pos == start) { @@ -283,7 +291,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th //start = str.find_first_not_of(delims, start); start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - } while (pos != str.size()); + } while (pos != str.size());*/ for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); @@ -294,7 +302,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); Array->Push(Val); - delete[] Val; + delete Val; Val = NULL; } -- cgit v1.2.3 From d14fd7b1a352df6e94247e325f679cc25fef671c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 12:59:06 +0200 Subject: WINTERMUTE: Implement a bit more of the key-handling. --- engines/wintermute/Base/BGame.cpp | 11 +++++++++-- engines/wintermute/Base/BGame.h | 1 + engines/wintermute/Base/BKeyboardState.cpp | 27 +++++++++++++++++++++++---- engines/wintermute/Base/BKeyboardState.h | 3 +++ engines/wintermute/PlatformSDL.cpp | 3 +++ 5 files changed, 39 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 15510ec6d5..4aea2816e4 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3794,6 +3794,11 @@ HRESULT CBGame::Unfreeze() { ////////////////////////////////////////////////////////////////////////// bool CBGame::HandleKeypress(Common::Event *event) { + if(IsVideoPlaying()) { + if(event->kbd.keycode == Common::KEYCODE_ESCAPE) + StopVideo(); + return true; + } #ifdef __WIN32__ // TODO: Do we really need to handle this in-engine? // handle Alt+F4 on windows @@ -3811,7 +3816,7 @@ bool CBGame::HandleKeypress(Common::Event *event) { } - + _keyboardState->handleKeyPress(event); _keyboardState->ReadKey(event); // TODO @@ -3833,7 +3838,9 @@ bool CBGame::HandleKeypress(Common::Event *event) { return false; } - +bool CBGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 2f9b6147ec..897ae7c40a 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -261,6 +261,7 @@ public: virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); virtual bool HandleKeypress(Common::Event *event); + virtual bool handleKeyRelease(Common::Event *event); int _freezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 17d27712ad..4b1ba919bb 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -46,14 +46,29 @@ CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { _currentShift = false; _currentAlt = false; _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } } - ////////////////////////////////////////////////////////////////////////// CBKeyboardState::~CBKeyboardState() { + delete[] _keyStates; +} +void CBKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } } +void CBKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} ////////////////////////////////////////////////////////////////////////// // high level scripting interface @@ -74,12 +89,12 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta vKey = (int)temp; } else vKey = val->GetInt(); - warning("BKeyboardState doesnt yet have state-support"); //TODO; + warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; // Uint8 *state = SDL_GetKeyboardState(NULL); // SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); -// bool isDown = state[scanCode] > 0; + bool isDown = _keyStates[VKeyToKeyCode(vKey)]; -// Stack->PushBool(isDown); + Stack->PushBool(isDown); return S_OK; } @@ -183,6 +198,10 @@ const char *CBKeyboardState::ScToString() { HRESULT CBKeyboardState::ReadKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = KeyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + _currentPrintable = true; + } //_currentKeyData = KeyData; _currentControl = IsControlDown(); diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index feed86df5e..0db409f64b 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -52,6 +52,8 @@ public: virtual ~CBKeyboardState(); HRESULT ReadKey(Common::Event *event); + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); static bool IsShiftDown(); static bool IsControlDown(); static bool IsAltDown(); @@ -63,6 +65,7 @@ public: virtual const char *ScToString(); private: + uint8 *_keyStates; uint32 KeyCodeToVKey(Common::Event *event); Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index bf13dced4e..10d18c7fc1 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -247,6 +247,9 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_KEYDOWN: if (Game) Game->HandleKeypress(event); break; + case Common::EVENT_KEYUP: + if (Game) Game->handleKeyRelease(event); + break; /*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); -- cgit v1.2.3 From fbc71915493f8162a674e0c83d470bfe6eb80a42 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 16:13:26 +0200 Subject: WINTERMUTE: Add a quick-fix to replace SDL_TEXTINPUT. --- engines/wintermute/Base/BGame.cpp | 4 ++-- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BKeyboardState.cpp | 2 ++ engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/UI/UIEdit.cpp | 13 ++++++------- engines/wintermute/UI/UIEdit.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 4 ++-- engines/wintermute/UI/UIWindow.h | 2 +- 9 files changed, 17 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 4aea2816e4..46abfe16cf 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3793,7 +3793,7 @@ HRESULT CBGame::Unfreeze() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleKeypress(Common::Event *event) { +bool CBGame::HandleKeypress(Common::Event *event, bool printable) { if(IsVideoPlaying()) { if(event->kbd.keycode == Common::KEYCODE_ESCAPE) StopVideo(); @@ -3821,7 +3821,7 @@ bool CBGame::HandleKeypress(Common::Event *event) { // TODO if (_focusedWindow) { - if (!Game->_focusedWindow->HandleKeypress(event)) { + if (!Game->_focusedWindow->HandleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ if (Game->_focusedWindow->CanHandleEvent("Keypress")) Game->_focusedWindow->ApplyEvent("Keypress"); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 897ae7c40a..a727978dd3 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -260,7 +260,7 @@ public: bool _quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - virtual bool HandleKeypress(Common::Event *event); + virtual bool HandleKeypress(Common::Event *event, bool printable = false); virtual bool handleKeyRelease(Common::Event *event); int _freezeLevel; HRESULT Unfreeze(); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 4b1ba919bb..32a5d529eb 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -201,6 +201,8 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) { if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { _currentPrintable = true; + } else { + _currentPrintable = false; } //_currentKeyData = KeyData; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 9f34541087..f947fdb1f5 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -960,7 +960,7 @@ HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleKeypress(Common::Event *event) { +bool CBObject::HandleKeypress(Common::Event *event, bool printable) { return false; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 475325e8e2..20bc17baac 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -81,7 +81,7 @@ public: virtual bool HandleMouseWheel(int Delta); virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - virtual bool HandleKeypress(Common::Event *event); + virtual bool HandleKeypress(Common::Event *event, bool printable = false); virtual int GetHeight(); HRESULT SetCursor(const char *Filename); HRESULT SetActiveCursor(const char *Filename); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index b85159240f..54c85021c9 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -686,10 +686,10 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::HandleKeypress(Common::Event *event) { +bool CUIEdit::HandleKeypress(Common::Event *event, bool printable) { bool Handled = false; - if (event->type == Common::EVENT_KEYDOWN) { + if (event->type == Common::EVENT_KEYDOWN && !printable) { switch (event->kbd.keycode) { case Common::KEYCODE_ESCAPE: case Common::KEYCODE_TAB: @@ -769,12 +769,11 @@ bool CUIEdit::HandleKeypress(Common::Event *event) { break; } return Handled; - } -#if 0 - else if (event->type == SDL_TEXTINPUT) { + } else if (event->type == Common::EVENT_KEYDOWN && printable) { if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); - WideString wstr = StringUtil::Utf8ToWide(event->text.text); + //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); + WideString wstr; wstr += (char)event->kbd.ascii; _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); if (Game->_textRTL) _selEnd = _selStart; @@ -782,7 +781,7 @@ bool CUIEdit::HandleKeypress(Common::Event *event) { return true; } -#endif + return false; } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 3b8698d55d..4771a0f772 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -44,7 +44,7 @@ public: bool _cursorVisible; uint32 _lastBlinkTime; virtual HRESULT Display(int OffsetX, int OffsetY); - virtual bool HandleKeypress(Common::Event *event); + virtual bool HandleKeypress(Common::Event *event, bool printable = false); int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 53ce72fe4a..94c76a60ea 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1100,12 +1100,12 @@ const char *CUIWindow::ScToString() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleKeypress(Common::Event *event) { +bool CUIWindow::HandleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { - if (_focusedWidget) return _focusedWidget->HandleKeypress(event); + if (_focusedWidget) return _focusedWidget->HandleKeypress(event, printable); else return false; } return false; diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 4bdef647a3..43d5961e7e 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -70,7 +70,7 @@ public: virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); - virtual bool HandleKeypress(Common::Event *event); + virtual bool HandleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; HRESULT LoadFile(const char *Filename); -- cgit v1.2.3 From 24726c143aa0d51b9d07ebdc5f8ee8d40e985399 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 16:14:07 +0200 Subject: WINTERMUTE: Make VidTheoraPlayer::Stop actually do something. --- engines/wintermute/video/VidTheoraPlayer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 33ef835933..65afeb2f34 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -434,6 +434,11 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeGam ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::stop() { + _theoraDecoder->close(); + _state = THEORA_STATE_FINISHED; + if (_freezeGame) { + Game->Unfreeze(); + } #if 0 if (m_Sound) m_Sound->Stop(); m_State = THEORA_STATE_FINISHED; -- cgit v1.2.3 From d8c33544b24b015c907b9bce5cc9990ed724bde4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 18:05:51 +0200 Subject: WINTERMUTE: Use fonts 1/3 larger than the engine asks for, to compensate for the difference in dpi between ScummVM and WME (with thanks to LordHoto for pointing this out). --- engines/wintermute/Base/BFontTT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index c2991f1277..85c2bee334 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -656,7 +656,7 @@ HRESULT CBFontTT::InitFont() { if (file) { #ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight); + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4/3); // Compensate for the difference in dpi (96 vs 72). _font = _deletableFont; #endif } -- cgit v1.2.3 From bcc93b735c0a6b48bfbc4ee8e10f9dccc7bcaa9f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 18:07:23 +0200 Subject: WINTERMUTE: Use offsets correctly in BSurfaceSDL. --- engines/wintermute/Base/BSurfaceSDL.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index ae7bad54b7..02788e0ffc 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -504,8 +504,8 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo srcRect.setHeight(Rect->bottom - Rect->top); Common::Rect position; - position.left = x; - position.top = y; + position.left = x + offsetX; + position.top = y + offsetY; // TODO: Scaling... position.setWidth((float)srcRect.width() * ZoomX / 100.f); @@ -513,8 +513,8 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo renderer->ModTargetRect(&position); - position.left += offsetX; - position.top += offsetY; +/* position.left += offsetX; + position.top += offsetY;*/ // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. -- cgit v1.2.3 From f7888fea6ee8d55778e792fbb4d04f0b3acf6885 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 18:08:12 +0200 Subject: WINTERMUTE: Add Ansi->ISO conversion for \' (quick hack to make J.U.L.I.A.-demo look right) --- engines/wintermute/utils/StringUtil.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 050f76b3b6..a1525f21b5 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -176,6 +176,19 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { return ""; } +// Currently this only does Ansi->ISO 8859, and only for carets. +char simpleAnsiToWide(const AnsiString &str, int &offset) { + char c = str[offset]; + + if (c == 92) { + offset++; + return '\''; + } else { + offset++; + return c; + } +} + ////////////////////////////////////////////////////////////////////////// WideString StringUtil::AnsiToWide(const AnsiString &str) { // TODO: This function gets called a lot, so warnings like these drown out the usefull information @@ -184,6 +197,11 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { hasWarned = true; warning("StringUtil::AnsiToWide - WideString not supported yet"); } + Common::String converted = ""; + int index = 0; + while (index != str.size()) { + converted += simpleAnsiToWide(str, index); + } // using default os locale! /* setlocale(LC_CTYPE, ""); @@ -193,7 +211,7 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { WideString ResultString(wstr); delete [] wstr; return ResultString;*/ - return WideString(str); + return WideString(converted); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 181414d749080b0c10c441ace945c3965f43fa39 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 14 Jun 2012 22:51:53 +0200 Subject: WINTERMUTE: Warn about WAVE-files for now. --- engines/wintermute/Base/BSoundBuffer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 052dbf98d5..c658cf5b31 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -36,6 +36,7 @@ #include "audio/audiostream.h" #include "audio/mixer.h" #include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" #include "common/system.h" namespace WinterMute { @@ -110,8 +111,15 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } - - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::NO); + Common::String strFilename(Filename); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::NO); + } else if (strFilename.hasSuffix(".wav")) { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s", Filename); + //_stream = Audio::makeWAVStream(_file, DisposeAfterUse::NO); + } else { + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", Filename); + } if (!_stream) { return E_FAIL; } -- cgit v1.2.3 From a488db8f93f37f79123226fdd561ba78578822f5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 00:28:59 +0200 Subject: WINTERMUTE: Clear out a bunch of warning (mostly shadowed variables) --- engines/wintermute/Ad/AdGame.cpp | 5 ++--- engines/wintermute/Ad/AdObject.cpp | 12 ++++++------ engines/wintermute/Ad/AdRegion.cpp | 10 ++++------ engines/wintermute/Ad/AdScene.cpp | 18 +++++++++--------- engines/wintermute/Base/BFileManager.cpp | 9 +++------ engines/wintermute/Base/BFontTT.cpp | 3 ++- engines/wintermute/Base/BGame.cpp | 20 +++++++++----------- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BImage.cpp | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 12 ++++++------ engines/wintermute/Base/scriptables/SXMemBuffer.cpp | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 2 -- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 9 ++++----- 16 files changed, 51 insertions(+), 61 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 26cbc299bf..32c037cba8 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1566,15 +1566,14 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co int StartIndex = -1; - int i; - for (i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { + for (int i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { if (scumm_stricmp(Name, _dlgPendingBranches[i]) == 0) { StartIndex = i; break; } } if (StartIndex >= 0) { - for (i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { + for (int i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); delete [] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 1f892f7eae..27ff2599a8 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -537,9 +537,9 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } } } else { - const char *Name = Val->GetString(); + const char *attachmentName = Val->GetString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { Found = true; Game->UnregisterObject(_attachmentsPre[i]); _attachmentsPre.RemoveAt(i); @@ -547,7 +547,7 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { Found = true; Game->UnregisterObject(_attachmentsPost[i]); _attachmentsPost.RemoveAt(i); @@ -580,16 +580,16 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CurrIndex++; } } else { - const char *Name = Val->GetString(); + const char *attachmentName = Val->GetString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, Name) == 0) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { Ret = _attachmentsPre[i]; break; } } if (!Ret) { for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, Name) == 0) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { Ret = _attachmentsPre[i]; break; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index b6735f72ff..c335269885 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -128,9 +128,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { Buffer = params; } - int i; - - for (i = 0; i < _points.GetSize(); i++) delete _points[i]; + for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -163,9 +161,9 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ZOOM: case TOKEN_SCALE: { - int i; - parser.ScanStr((char *)params, "%d", &i); - _zoom = (float)i; + int j; + parser.ScanStr((char *)params, "%d", &j); + _zoom = (float)j; } break; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 3400fba145..53d1d78907 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -626,7 +626,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { int ar, ag, ab, aa; char camera[MAX_PATH] = ""; - float WaypointHeight = -1.0f; + /* float WaypointHeight = -1.0f; */ while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -1386,9 +1386,9 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetNode") == 0) { Stack->CorrectParams(1); - const char *Name = Stack->Pop()->GetString(); + const char *nodeName = Stack->Pop()->GetString(); - CBObject *node = GetNodeByName(Name); + CBObject *node = GetNodeByName(nodeName); if (node) Stack->PushNative((CBScriptable *)node, true); else Stack->PushNULL(); @@ -1407,9 +1407,9 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int Index = Val->GetInt(); if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; } else { - const char *Name = Val->GetString(); + const char *nodeName = Val->GetString(); for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, Name) == 0) { + if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { Ret = _objects[i]; break; } @@ -2115,8 +2115,8 @@ float CAdScene::GetScaleAt(int Y) { CAdScaleLevel *next = NULL; for (int i = 0; i < _scaleLevels.GetSize(); i++) { - CAdScaleLevel *xxx = _scaleLevels[i]; - int j = _scaleLevels.GetSize(); + /* CAdScaleLevel *xxx = _scaleLevels[i];*/ + /* int j = _scaleLevels.GetSize(); */ if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; else { next = _scaleLevels[i]; @@ -2556,8 +2556,8 @@ float CAdScene::GetRotationAt(int X, int Y) { CAdRotLevel *next = NULL; for (int i = 0; i < _rotLevels.GetSize(); i++) { - CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.GetSize(); + /* CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.GetSize();*/ if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; else { next = _rotLevels[i]; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index ecccb04493..1848595c19 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -342,15 +342,12 @@ HRESULT CBFileManager::RegisterPackages() { Game->LOG(0, "Scanning packages..."); warning("Scanning packages"); -// TODO: Actually scan the folder, for now we just hardcode the files for Dirty Split. Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.dcp"); - int size = files.size(); + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { RegisterPackage((*it)->getName().c_str()); } -/* RegisterPackage("data.dcp"); - RegisterPackage("english.dcp");*/ #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); @@ -378,10 +375,10 @@ HRESULT CBFileManager::RegisterPackages() { } } } - +#endif warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); -#endif + warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); return S_OK; } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 85c2bee334..2ec1f5031b 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -876,9 +876,10 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, ////////////////////////////////////////////////////////////////////////// float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { +#if 0 GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); -#if 0 + if (!infoLeft || !infoRight) return 0; FT_Vector delta; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 46abfe16cf..00e5cc8ea7 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -353,15 +353,13 @@ CBGame::~CBGame() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::Cleanup() { - int i; - delete _loadingIcon; _loadingIcon = NULL; _engineLogCallback = NULL; _engineLogCallbackData = NULL; - for (i = 0; i < NUM_MUSIC_CHANNELS; i++) { + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { delete _music[i]; _music[i] = NULL; _musicStartTime[i] = 0; @@ -373,7 +371,7 @@ HRESULT CBGame::Cleanup() { UnregisterObject(_fader); _fader = NULL; - for (i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.GetSize(); i++) { delete _regObjects[i]; _regObjects[i] = NULL; } @@ -399,7 +397,7 @@ HRESULT CBGame::Cleanup() { _scValue = NULL; _sFX = NULL; - for (i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.GetSize(); i++) { _scripts[i]->_owner = NULL; _scripts[i]->Finish(); } @@ -411,7 +409,7 @@ HRESULT CBGame::Cleanup() { _fontStorage->RemoveFont(_videoFont); _videoFont = NULL; - for (i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; + for (int i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; _quickMessages.RemoveAll(); _viewportStack.RemoveAll(); @@ -2063,8 +2061,8 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccOutputText") == 0) { Stack->CorrectParams(2); - const char *Str = Stack->Pop()->GetString(); - int Type = Stack->Pop()->GetInt(); + /* const char *Str = */ Stack->Pop()->GetString(); + /* int Type = */ Stack->Pop()->GetInt(); // do nothing Stack->PushNULL(); @@ -3838,7 +3836,7 @@ bool CBGame::HandleKeypress(Common::Event *event, bool printable) { return false; } -bool CBGame::handleKeyRelease(Common::Event *event) { +void CBGame::handleKeyRelease(Common::Event *event) { _keyboardState->handleKeyRelease(event); } @@ -4098,7 +4096,7 @@ void CBGame::SetResourceModule(HMODULE ResModule) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayContent(bool Update, bool DisplayAll) { +HRESULT CBGame::DisplayContent(bool update, bool displayAll) { return S_OK; } @@ -4133,7 +4131,7 @@ HRESULT CBGame::DisplayIndicator() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::UpdateMusicCrossfade() { - byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); + /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) return S_OK; if (_state == GAME_FROZEN) return S_OK; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index a727978dd3..e3363ccf4c 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -261,7 +261,7 @@ public: virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); virtual bool HandleKeypress(Common::Event *event, bool printable = false); - virtual bool handleKeyRelease(Common::Event *event); + virtual void handleKeyRelease(Common::Event *event); int _freezeLevel; HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 69859b4c05..e0c39ad9e9 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -58,7 +58,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBImage::~CBImage() { - delete _bitmap; +/* delete _bitmap; */ delete _decoder; #if 0 if (_bitmap) FreeImage_Unload(_bitmap); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 02788e0ffc..9e77b9c1b7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -229,7 +229,7 @@ void CBSurfaceSDL::genAlphaMask(Graphics::Surface *surface) { SDL_LockSurface(surface); #endif bool hasColorKey; - uint32 colorKey; + /* uint32 colorKey; */ uint8 ckRed, ckGreen, ckBlue; /* if (SDL_GetColorKey(surface, &colorKey) == 0) { hasColorKey = true; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 29d51c063d..09afdcc6b4 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -519,11 +519,11 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddGlobalForce") == 0) { Stack->CorrectParams(3); - const char *Name = Stack->Pop()->GetString(); + const char *forceName = Stack->Pop()->GetString(); float Angle = Stack->Pop()->GetFloat(); float Strength = Stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + Stack->PushBool(SUCCEEDED(AddForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); return S_OK; } @@ -533,13 +533,13 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AddPointForce") == 0) { Stack->CorrectParams(5); - const char *Name = Stack->Pop()->GetString(); + const char *forceName = Stack->Pop()->GetString(); int PosX = Stack->Pop()->GetInt(); int PosY = Stack->Pop()->GetInt(); float Angle = Stack->Pop()->GetFloat(); float Strength = Stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(AddForce(Name, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + Stack->PushBool(SUCCEEDED(AddForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); return S_OK; } @@ -549,9 +549,9 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "RemoveForce") == 0) { Stack->CorrectParams(1); - const char *Name = Stack->Pop()->GetString(); + const char *forceName = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveForce(Name))); + Stack->PushBool(SUCCEEDED(RemoveForce(forceName))); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index ab00178b21..5737fe4d72 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -366,7 +366,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "SetPointer") == 0) { Stack->CorrectParams(2); int Start = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); + /* CScValue *Val = */ Stack->Pop(); if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushBool(false); else { diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 50799d6d4a..f8de678547 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -267,8 +267,6 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Common::Array parts; - size_t start, pos; - start = 0; Common::StringTokenizer tokenizer(str, delims); while (!tokenizer.empty()) { diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 85451bb150..30bda66558 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -684,7 +684,7 @@ HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { Bp = new CScBreakpoint(ScriptFilename); _breakpoints.Add(Bp); } - bool Found = false; + for (int i = 0; i < Bp->_lines.GetSize(); i++) { if (Bp->_lines[i] == Line) return S_OK; } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 20a89c5897..3ef052da3e 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -163,7 +163,7 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - const char *Filename = Val->GetString(); + /* const char *Filename = */ Val->GetString(); delete _image; _image = NULL; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 65afeb2f34..991286c56c 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -450,14 +450,13 @@ HRESULT CVidTheoraPlayer::stop() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::update() { _currentTime = _freezeGame ? Game->_liveTimer : Game->_timer; - + if (!isPlaying()) return S_OK; - + if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return S_OK; - + if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return S_OK; - - int Counter = 0; + if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie"); -- cgit v1.2.3 From cac5db7dfe58cf8f353d13d02fdd4be1452490d9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 00:43:09 +0200 Subject: WINTERMUTE: Clean up and refactor VidTheoraPlayer a bit. --- engines/wintermute/video/VidTheoraPlayer.cpp | 121 +++++++++++++++------------ engines/wintermute/video/VidTheoraPlayer.h | 78 +++++++---------- 2 files changed, 96 insertions(+), 103 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 991286c56c..ca9287afb8 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -1,20 +1,30 @@ -// Copyright 2009, 2010 Jan Nedoma -// -// This file is part of Wintermute Engine. -// -// Wintermute Engine is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Wintermute Engine 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 Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Wintermute Engine. If not, see . -////////////////////////////////////////////////////////////////////////// +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #include "engines/wintermute/dcgf.h" @@ -318,6 +328,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::resetStream() { + warning("VidTheoraPlayer::resetStream - stubbed"); #if 0 if (_sound) _sound->Stop(); @@ -329,59 +340,59 @@ HRESULT CVidTheoraPlayer::resetStream() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeGame, bool FreezeMusic, bool Looping, uint32 StartTime, float ForceZoom, int Volume) { - if (ForceZoom < 0.0f) - ForceZoom = 100.0f; - if (Volume < 0) +HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { + if (forceZoom < 0.0f) + forceZoom = 100.0f; + if (volume < 0) _volume = Game->_soundMgr->getVolumePercent(SOUND_SFX); - else _volume = Volume; + else _volume = volume; - _freezeGame = FreezeGame; + _freezeGame = freezeGame; if (!_playbackStarted && _freezeGame) - Game->Freeze(FreezeMusic); + Game->Freeze(freezeMusic); _playbackStarted = false; - float Width, Height; + float width, height; if (_theoraDecoder) { _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); _state = THEORA_STATE_PLAYING; - _looping = Looping; - _playbackType = Type; - - _startTime = StartTime; - _volume = Volume; - _posX = X; - _posY = Y; - _playZoom = ForceZoom; + _looping = looping; + _playbackType = type; + + _startTime = startTime; + _volume = volume; + _posX = x; + _posY = y; + _playZoom = forceZoom; - Width = (float)_theoraDecoder->getWidth(); - Height = (float)_theoraDecoder->getHeight(); + width = (float)_theoraDecoder->getWidth(); + height = (float)_theoraDecoder->getHeight(); } else { - Width = (float)Game->_renderer->_width; - Height = (float)Game->_renderer->_height; + width = (float)Game->_renderer->_width; + height = (float)Game->_renderer->_height; } - switch (Type) { + switch (type) { case VID_PLAY_POS: - _playZoom = ForceZoom; - _posX = X; - _posY = Y; + _playZoom = forceZoom; + _posX = x; + _posY = y; break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->_width / Width * 100); - float ZoomY = (float)((float)Game->_renderer->_height / Height * 100); + float ZoomX = (float)((float)Game->_renderer->_width / width * 100); + float ZoomY = (float)((float)Game->_renderer->_height / height * 100); _playZoom = MIN(ZoomX, ZoomY); - _posX = (Game->_renderer->_width - Width * (_playZoom / 100)) / 2; - _posY = (Game->_renderer->_height - Height * (_playZoom / 100)) / 2; + _posX = (Game->_renderer->_width - width * (_playZoom / 100)) / 2; + _posY = (Game->_renderer->_height - height * (_playZoom / 100)) / 2; } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _posX = (Game->_renderer->_width - Width) / 2; - _posY = (Game->_renderer->_height - Height) / 2; + _posX = (Game->_renderer->_width - width) / 2; + _posY = (Game->_renderer->_height - height) / 2; break; } return S_OK; @@ -633,19 +644,19 @@ void CVidTheoraPlayer::writeAlpha() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::display(uint32 Alpha) { +HRESULT CVidTheoraPlayer::display(uint32 alpha) { RECT rc; - HRESULT Res; + HRESULT res; if (_texture && _videoFrameReady) { CBPlatform::SetRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); - if (_playZoom == 100.0f) Res = _texture->displayTrans(_posX, _posY, rc, Alpha); - else Res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, Alpha); - } else Res = E_FAIL; + if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); + else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); + } else res = E_FAIL; #if 0 if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); #endif - return Res; + return res; } ////////////////////////////////////////////////////////////////////////// @@ -680,8 +691,8 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -byte CVidTheoraPlayer::getAlphaAt(int X, int Y) { - if (_alphaImage) return _alphaImage->getAlphaAt(X, Y); +byte CVidTheoraPlayer::getAlphaAt(int x, int y) { + if (_alphaImage) return _alphaImage->getAlphaAt(x, y); else return 0xFF; } diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index fc89b07c53..b679cbe428 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -1,21 +1,30 @@ -// Copyright 2009, 2010 Jan Nedoma -// -// This file is part of Wintermute Engine. -// -// Wintermute Engine is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Wintermute Engine 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 Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Wintermute Engine. If not, see . -////////////////////////////////////////////////////////////////////////// - +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ #ifndef WINTERMUTE_VIDTHEORAPLAYER_H #define WINTERMUTE_VIDTHEORAPLAYER_H @@ -26,7 +35,6 @@ #include "engines/wintermute/Base/BImage.h" #include "video/video_decoder.h" #include "common/stream.h" -//#include namespace WinterMute { @@ -46,36 +54,10 @@ public: CVidTheoraPlayer(CBGame *inGame); virtual ~CVidTheoraPlayer(void); - // Vorbis/Theora structs - /*ogg_sync_state m_OggSyncState; - ogg_page m_OggPage; - ogg_stream_state m_VorbisStreamState; - ogg_stream_state m_TheoraStreamState; - - theora_info m_TheoraInfo; - theora_comment m_TheoraComment; - theora_state m_TheoraState; - - vorbis_info m_VorbisInfo; - vorbis_dsp_state m_VorbisDSPState; - vorbis_block m_VorbisBlock; - vorbis_comment m_VorbisComment; - - int _theoraStreams; - int _vorbisStreams;*/ - - //ogg_int64_t m_AudiobufGranulepos; //time position of last sample - - // external objects Common::SeekableReadStream *_file; Common::String _filename; - //CBSoundTheora *_sound; - //ogg_int16_t *_audioBuf; - /*int _audioBufSize; - int _audioBufFill;*/ - CBSurface *_texture; //CVidSubtitler *_subtitler; @@ -83,9 +65,9 @@ public: HRESULT initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); HRESULT initializeSimple(); HRESULT update(); - HRESULT play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeGame = false, bool FreezeMusic = true, bool Looping = false, uint32 StartTime = 0, float ForceZoom = -1.0f, int Volume = -1); + HRESULT play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); HRESULT stop(); - HRESULT display(uint32 Alpha = 0xFFFFFFFF); + HRESULT display(uint32 alpha = 0xFFFFFFFF); //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); HRESULT pause(); @@ -117,7 +99,7 @@ public: CBImage *_alphaImage; Common::String _alphaFilename; HRESULT setAlphaImage(const Common::String &filename); - __inline byte getAlphaAt(int X, int Y); + __inline byte getAlphaAt(int x, int y); void writeAlpha(); HRESULT SeekToTime(uint32 Time); -- cgit v1.2.3 From 407a8818002b91f512faacb2ce9fa1f48b4c649e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 00:48:42 +0200 Subject: WINTERMUTE: Clean up BFonTT a little. --- engines/wintermute/Base/BFontTT.cpp | 23 ++++++++++++----------- engines/wintermute/Base/BFontTT.h | 19 ++++++------------- engines/wintermute/FontGlyphCache.cpp | 4 ++-- engines/wintermute/FontGlyphCache.h | 4 ++-- 4 files changed, 22 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 2ec1f5031b..fd0993a5bb 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -756,7 +756,7 @@ void CBFontTT::FTCloseProc(FT_Stream stream) { }*/ - +#if 0 ////////////////////////////////////////////////////////////////////////// void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines) { int currWidth = 0; @@ -837,7 +837,7 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex currWidth += charWidth; } } - +#endif ////////////////////////////////////////////////////////////////////////// void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; @@ -873,10 +873,10 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, }*/ } - +#if 0 ////////////////////////////////////////////////////////////////////////// float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { -#if 0 + GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); @@ -887,23 +887,25 @@ float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { if (error) return 0; return delta.x * (1.0f / 64.0f); -#endif + return 0; } - - +#endif +#if 0 ////////////////////////////////////////////////////////////////////////// void CBFontTT::PrepareGlyphs(const WideString &text) { + // make sure we have all the glyphs we need for (size_t i = 0; i < text.size(); i++) { wchar_t ch = text[i]; if (!_glyphCache->HasGlyph(ch)) CacheGlyph(ch); } -} +} +#endif +#if 0 ////////////////////////////////////////////////////////////////////////// void CBFontTT::CacheGlyph(wchar_t ch) { -#if 0 FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); if (!glyphIndex) return; @@ -939,7 +941,6 @@ void CBFontTT::CacheGlyph(wchar_t ch) { _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); if (tempBuffer) delete [] tempBuffer; -#endif } - +#endif } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index d21729369b..5658997d2e 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -120,16 +120,13 @@ public: CBFontTT(CBGame *inGame); virtual ~CBFontTT(void); - virtual int GetTextWidth(byte *text, int MaxLenght = -1); + virtual int GetTextWidth(byte *text, int maxLenght = -1); virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLenght = -1); virtual int GetLetterHeight(); - HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(const char *Filename); - - /* static unsigned long FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count); - static void FTCloseProc(FT_Stream stream);*/ + HRESULT LoadBuffer(byte *buffer); + HRESULT LoadFile(const char *filename); FontGlyphCache *GetGlyphCache() { return _glyphCache; @@ -143,13 +140,10 @@ public: void InitLoop(); private: - HRESULT ParseLayer(CBTTFontLayer *Layer, byte *Buffer); + HRESULT ParseLayer(CBTTFontLayer *layer, byte *buffer); void WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - float GetKerning(wchar_t leftChar, wchar_t rightChar); - void PrepareGlyphs(const WideString &text); - void CacheGlyph(wchar_t ch); CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); @@ -158,8 +152,7 @@ private: CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; HRESULT InitFont(); - //FT_Stream _fTStream; - //FT_Face _fTFace; + Graphics::Font *_deletableFont; const Graphics::Font *_font; const Graphics::Font *_fallbackFont; diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp index ea0acd4c19..73dc3d2ff1 100644 --- a/engines/wintermute/FontGlyphCache.cpp +++ b/engines/wintermute/FontGlyphCache.cpp @@ -29,7 +29,7 @@ #include "FontGlyphCache.h" namespace WinterMute { - +#if 0 ////////////////////////////////////////////////////////////////////////// FontGlyphCache::FontGlyphCache() { } @@ -98,5 +98,5 @@ void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte * SDL_UnlockSurface(_image); #endif } - +#endif } // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h index 9b1cafe4cb..bb36c0d864 100644 --- a/engines/wintermute/FontGlyphCache.h +++ b/engines/wintermute/FontGlyphCache.h @@ -34,7 +34,7 @@ #include "graphics/surface.h" namespace WinterMute { - +#if 0 ////////////////////////////////////////////////////////////////////////// class GlyphInfo { public: @@ -119,7 +119,7 @@ private: typedef Common::HashMap GlyphInfoMap; // TODO GlyphInfoMap _glyphs; }; - +#endif } // end of namespace WinterMute #endif // WINTERMUTE_FONTGLYPHCACHE_H -- cgit v1.2.3 From 41c3b57aadbaa3030ea56f0fb9a3c57d671d151d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 00:57:58 +0200 Subject: WINTERMUTE: Clean up the formatting in dctypes a bit --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/dctypes.h | 103 +++++++++++++++++++++++++--------- engines/wintermute/utils/PathUtil.cpp | 2 +- 3 files changed, 78 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 07eac85a93..55e73ea482 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - +#define FORBIDDEN_SYMBOL_EXCEPTION_rand #include "engines/wintermute/dcgf.h" #include "engines/wintermute/dctypes.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index f295b01df1..988f865f21 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -29,14 +29,10 @@ #ifndef WINTERMUTE_DCTYPES_H #define WINTERMUTE_DCTYPES_H -#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/str.h" #include "common/list.h" #include "common/array.h" -//#include -//#include -//#include namespace WinterMute { @@ -55,25 +51,45 @@ typedef Common::Array AnsiStringArray; enum TGameState { - GAME_RUNNING, GAME_FROZEN, GAME_SEMI_FROZEN + GAME_RUNNING, + GAME_FROZEN, + GAME_SEMI_FROZEN }; -enum TImageType { IMG_PALETTED8, IMG_TRUECOLOR } ; +enum TImageType { + IMG_PALETTED8, + IMG_TRUECOLOR +}; enum TTextAlign { - TAL_LEFT = 0, TAL_RIGHT, TAL_CENTER, NUM_TEXT_ALIGN + TAL_LEFT = 0, + TAL_RIGHT, + TAL_CENTER, + NUM_TEXT_ALIGN }; enum TVerticalAlign { - VAL_TOP = 0, VAL_CENTER, VAL_BOTTOM, NUM_VERTICAL_ALIGN + VAL_TOP = 0, + VAL_CENTER, + VAL_BOTTOM, + NUM_VERTICAL_ALIGN }; enum TDirection { - DI_UP = 0, DI_UPRIGHT = 1, DI_RIGHT = 2, DI_DOWNRIGHT = 3, DI_DOWN = 4, DI_DOWNLEFT = 5, DI_LEFT = 6, DI_UPLEFT = 7, NUM_DIRECTIONS = 8, DI_NONE = 9 + DI_UP = 0, + DI_UPRIGHT = 1, + DI_RIGHT = 2, + DI_DOWNRIGHT = 3, + DI_DOWN = 4, + DI_DOWNLEFT = 5, + DI_LEFT = 6, + DI_UPLEFT = 7, + NUM_DIRECTIONS = 8, + DI_NONE = 9 }; @@ -96,12 +112,21 @@ enum TEventType { enum TUIObjectType { - UI_UNKNOWN, UI_BUTTON, UI_WINDOW, UI_STATIC, UI_EDIT, UI_HTML, UI_CUSTOM + UI_UNKNOWN, + UI_BUTTON, + UI_WINDOW, + UI_STATIC, + UI_EDIT, + UI_HTML, + UI_CUSTOM }; enum TRendererState { - RSTATE_3D, RSTATE_2D, RSTATE_LINES, RSTATE_NONE + RSTATE_3D, + RSTATE_2D, + RSTATE_LINES, + RSTATE_NONE }; @@ -116,28 +141,36 @@ enum TSeek { }; enum TSoundType { - SOUND_SFX, SOUND_MUSIC, SOUND_SPEECH + SOUND_SFX, + SOUND_MUSIC, + SOUND_SPEECH }; enum TVideoMode { - VIDEO_WINDOW, VIDEO_FULLSCREEN, VIDEO_ANY + VIDEO_WINDOW, + VIDEO_FULLSCREEN, + VIDEO_ANY }; enum TVideoPlayback { - VID_PLAY_POS = 0, - VID_PLAY_STRETCH = 1, - VID_PLAY_CENTER = 2 + VID_PLAY_POS = 0, + VID_PLAY_STRETCH = 1, + VID_PLAY_CENTER = 2 }; enum TMouseEvent { - MOUSE_CLICK, MOUSE_RELEASE, MOUSE_DBLCLICK + MOUSE_CLICK, + MOUSE_RELEASE, + MOUSE_DBLCLICK }; enum TMouseButton { - MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE + MOUSE_BUTTON_LEFT, + MOUSE_BUTTON_RIGHT, + MOUSE_BUTTON_MIDDLE }; @@ -147,40 +180,56 @@ enum TTransMgrState { enum TTransitionType { - TRANSITION_NONE = 0, + TRANSITION_NONE = 0, TRANSITION_FADE_OUT = 1, - TRANSITION_FADE_IN = 2, + TRANSITION_FADE_IN = 2, NUM_TRANSITION_TYPES }; enum TWindowMode { - WINDOW_NORMAL, WINDOW_EXCLUSIVE, WINDOW_SYSTEM_EXCLUSIVE + WINDOW_NORMAL, + WINDOW_EXCLUSIVE, + WINDOW_SYSTEM_EXCLUSIVE }; enum TSFXType { - SFX_NONE, SFX_ECHO, SFX_REVERB + SFX_NONE, + SFX_ECHO, + SFX_REVERB }; enum TSpriteCacheType { - CACHE_ALL, CACHE_HALF + CACHE_ALL, + CACHE_HALF }; enum TTextEncoding { - TEXT_ANSI = 0, TEXT_UTF8 = 1, NUM_TEXT_ENCODINGS + TEXT_ANSI = 0, + TEXT_UTF8 = 1, + NUM_TEXT_ENCODINGS }; enum TSpriteBlendMode { - BLEND_UNKNOWN = -1, BLEND_NORMAL = 0, BLEND_ADDITIVE = 1, BLEND_SUBTRACTIVE = 2, NUM_BLEND_MODES + BLEND_UNKNOWN = -1, + BLEND_NORMAL = 0, + BLEND_ADDITIVE = 1, + BLEND_SUBTRACTIVE = 2, + NUM_BLEND_MODES }; enum TTTSType { - TTS_CAPTION = 0, TTS_TALK, TTS_KEYPRESS + TTS_CAPTION = 0, + TTS_TALK, + TTS_KEYPRESS }; enum TShadowType { - SHADOW_NONE = 0, SHADOW_SIMPLE = 1, SHADOW_FLAT = 2, SHADOW_STENCIL = 3 + SHADOW_NONE = 0, + SHADOW_SIMPLE = 1, + SHADOW_FLAT = 2, + SHADOW_STENCIL = 3 }; } // end of namespace WinterMute diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index dc722e2389..e2e6c56b9f 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/dcgf.h" #include #include -- cgit v1.2.3 From bed4f81fc616d6ca920e5ab534d4accea9c1a9ef Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 01:21:28 +0200 Subject: WINTERMUTE: Clean out some un-needed headers, and some FORBIDDEN_SYMBOL_EXCEPTIONs --- engines/wintermute/Base/BFont.h | 2 +- engines/wintermute/Base/BGame.cpp | 4 ++-- engines/wintermute/Base/scriptables/ScEngine.cpp | 5 +---- engines/wintermute/Sys/SysClass.h | 3 --- engines/wintermute/dcgf.h | 2 -- engines/wintermute/dcscript.h | 10 +++++++++- engines/wintermute/utils/PathUtil.cpp | 23 ++++++----------------- 7 files changed, 19 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index 0cfb5ed681..148cbe7ed8 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -44,7 +44,7 @@ public: virtual int GetLetterHeight(); virtual void InitLoop() {}; - + virtual void AfterLoad() {}; CBFont(CBGame *inGame); virtual ~CBFont(); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 00e5cc8ea7..f643d3e302 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/Base/BFader.h" #include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/Base/BFont.h" #include "engines/wintermute/Base/BFontStorage.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BKeyboardState.h" @@ -3397,7 +3397,7 @@ void CBGame::AfterLoadSound(void *Sound, void *Data) { ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadFont(void *Font, void *Data) { - ((CBFontTT *)Font)->AfterLoad(); + ((CBFont*)Font)->AfterLoad(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 30bda66558..e8560bca6f 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -25,10 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_ALLOW_ALL -#include -#include -#undef FORBIDDEN_SYMBOL_ALLOW_ALL + #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/utils/StringUtil.h" diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h index 82b612927e..c81e38ee43 100644 --- a/engines/wintermute/Sys/SysClass.h +++ b/engines/wintermute/Sys/SysClass.h @@ -31,9 +31,6 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/dctypes.h" - -//#include -//#include #include "common/hashmap.h" #include "common/func.h" #include "common/stream.h" diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 855da1d542..74eb7f782a 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -54,8 +54,6 @@ // macros #define RELEASE(obj) if(obj) { obj->Release(); obj = NULL; } else 0 -#define SAFE_DELETE(obj) if(obj) { delete obj; obj = NULL; } else 0 -#define SAFE_DELETE_ARRAY(obj) if(obj) { delete [] obj; obj = NULL; } else 0 #define DegToRad(_val) (_val*PI*(1.0f/180.0f)) #define RadToDeg(_val) (_val*(180/PI)) diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h index 2ebb0fe11a..a4a608da46 100644 --- a/engines/wintermute/dcscript.h +++ b/engines/wintermute/dcscript.h @@ -49,7 +49,15 @@ typedef enum { // script states typedef enum { - SCRIPT_RUNNING, SCRIPT_WAITING, SCRIPT_SLEEPING, SCRIPT_FINISHED, SCRIPT_PERSISTENT, SCRIPT_ERROR, SCRIPT_PAUSED, SCRIPT_WAITING_SCRIPT, SCRIPT_THREAD_FINISHED + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED } TScriptState; // opcodes diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index e2e6c56b9f..284db8acfc 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -25,26 +25,12 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_ALLOW_ALL +#define FORBIDDEN_SYMBOL_EXCEPTION_ifstream #include "engines/wintermute/dcgf.h" -#include #include #include "PathUtil.h" #include "StringUtil.h" - -#ifdef __WIN32__ -# include -#endif - -#ifdef __MACOSX__ -# include -#endif - -#ifdef __IPHONEOS__ -# include "ios_utils.h" -#endif - namespace WinterMute { ////////////////////////////////////////////////////////////////////////// @@ -155,6 +141,8 @@ bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { ////////////////////////////////////////////////////////////////////////// bool PathUtil::FileExists(const AnsiString &fileName) { + warning("PathUtil::FileExists(%s)", fileName.c_str()); + std::ifstream stream; stream.open(fileName.c_str()); @@ -167,8 +155,9 @@ bool PathUtil::FileExists(const AnsiString &fileName) { ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::GetUserDirectory() { + warning("PathUtil::GetUserDirectory - stubbed"); AnsiString userDir = "./"; - +#if 0 #ifdef __WIN32__ char buffer[MAX_PATH]; buffer[0] = '\0'; @@ -197,7 +186,7 @@ AnsiString PathUtil::GetUserDirectory() { IOS_GetDataDir(path); userDir = AnsiString(path); #endif - +#endif // 0 return userDir; } -- cgit v1.2.3 From dae2209e4c144ffbcf586b5cdcea9a6746274443 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 01:54:26 +0200 Subject: WINTERMUTE: Make factory-functions for the SX-classes, to avoid having to include all of them in BGame.cpp --- engines/wintermute/Base/BGame.cpp | 18 ++++++------------ engines/wintermute/Base/BScriptable.h | 10 ++++++++++ engines/wintermute/Base/scriptables/SXArray.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXDate.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXFile.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXMath.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXMemBuffer.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXStore.cpp | 4 ++++ engines/wintermute/Base/scriptables/SXString.cpp | 4 ++++ engines/wintermute/Base/scriptables/SxObject.cpp | 4 ++++ 10 files changed, 48 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index f643d3e302..bf7eaa561f 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -60,14 +60,8 @@ #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/SXArray.h" -#include "engines/wintermute/Base/scriptables/SXDate.h" -#include "engines/wintermute/Base/scriptables/SXFile.h" -#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" -#include "engines/wintermute/Base/scriptables/SxObject.h" #include "engines/wintermute/Base/scriptables/SXMath.h" #include "engines/wintermute/Base/scriptables/SXStore.h" -#include "engines/wintermute/Base/scriptables/SXString.h" #include "engines/wintermute/video/VidPlayer.h" #include "engines/wintermute/video/VidTheoraPlayer.h" #include "common/textconsole.h" @@ -2966,7 +2960,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "String") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXString(Game, Stack)); + this_obj->SetNative(makeSXString(Game, Stack)); Stack->PushNULL(); } @@ -2976,7 +2970,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "MemBuffer") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXMemBuffer(Game, Stack)); + this_obj->SetNative(makeSXMemBuffer(Game, Stack)); Stack->PushNULL(); } @@ -2986,7 +2980,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "File") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXFile(Game, Stack)); + this_obj->SetNative(makeSXFile(Game, Stack)); Stack->PushNULL(); } @@ -2996,7 +2990,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "Date") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXDate(Game, Stack)); + this_obj->SetNative(makeSXDate(Game, Stack)); Stack->PushNULL(); } @@ -3006,7 +3000,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "Array") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXArray(Game, Stack)); + this_obj->SetNative(makeSXArray(Game, Stack)); Stack->PushNULL(); } @@ -3016,7 +3010,7 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "Object") == 0) { this_obj = ThisStack->GetTop(); - this_obj->SetNative(new CSXObject(Game, Stack)); + this_obj->SetNative(makeSXObject(Game, Stack)); Stack->PushNULL(); } diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index dfe36abf52..0ee7808445 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -75,6 +75,16 @@ public: }; +// Implemented in their respective .cpp-files +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXMath(CBGame *inGame); +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXStore(CBGame *inGame); +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); + } // end of namespace WinterMute #endif diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 18118727da..d9b3dfe455 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -36,6 +36,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXArray, false) +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { + return new CSXArray(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { _length = 0; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 28b152149c..2947428dad 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -34,6 +34,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXDate, false) +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { + return new CSXDate(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(6); diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 1c6438e217..e7ac75c58b 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -50,6 +50,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXFile, false) +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { + return new CSXFile(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(1); diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 8ac70581b9..5005b885b8 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -41,6 +41,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXMath, true) +CBScriptable *makeSXMath(CBGame *inGame) { + return new CSXMath(inGame); +} + ////////////////////////////////////////////////////////////////////////// CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 5737fe4d72..3a661b502c 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -37,6 +37,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXMemBuffer, false) +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { + return new CSXMemBuffer(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { Stack->CorrectParams(1); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 26d19376a1..54280e8b29 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -42,6 +42,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXStore, false) +CBScriptable *makeSXStore(CBGame *inGame, CScStack *stack) { + return new CSXStore(inGame); +} + ////////////////////////////////////////////////////////////////////////// CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { #ifdef __IPHONEOS__ diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index f8de678547..16cb198671 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -39,6 +39,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXString, false) +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { + return new CSXString(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { _string = NULL; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 1af01c1045..2785606338 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -38,6 +38,10 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXObject, false) +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { + return new CSXObject(inGame, stack); +} + ////////////////////////////////////////////////////////////////////////// CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { int NumParams = Stack->Pop()->GetInt(0); -- cgit v1.2.3 From dba91234287bc9e07c0704f008c9077fdbb8fd3d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 01:57:15 +0200 Subject: WINTERMUTE: Remove a bunch of commented-out includes. --- engines/wintermute/Ad/AdInventoryBox.cpp | 2 -- engines/wintermute/Base/BBase.h | 2 -- engines/wintermute/Base/BFileManager.h | 2 -- engines/wintermute/Base/BFontTT.cpp | 2 -- engines/wintermute/Base/BGame.h | 3 --- engines/wintermute/Base/BImage.cpp | 1 - engines/wintermute/Base/BImage.h | 2 -- engines/wintermute/Base/BSoundMgr.h | 1 - engines/wintermute/Base/scriptables/ScValue.h | 2 -- 9 files changed, 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 1b80763cb4..8d4720c984 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -39,8 +39,6 @@ #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" -//#include - namespace WinterMute { diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index b815281f34..ea4efa00d1 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -34,8 +34,6 @@ #include "common/str.h" #include "common/hashmap.h" #include "common/hash-str.h" -//#include -//#include namespace WinterMute { diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 533575c1ba..dd49637cd6 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -29,8 +29,6 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H - -//#include #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BFileEntry.h" #include "common/archive.h" diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index fd0993a5bb..dff2c252e4 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -26,8 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -//#include -//#include FT_FREETYPE_H #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFontTT.h" diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index e3363ccf4c..4a660a91fb 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -30,10 +30,7 @@ #define WINTERMUTE_BGAME_H #include "engines/wintermute/Base/BDebugger.h" -//#include "engines/wintermute/Base/BSaveThumbHelper.h" -//#include "engines/wintermute/Base/BFader.h" #include "engines/wintermute/Base/BRenderer.h" -//#include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index e0c39ad9e9..31c05226f5 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -40,7 +40,6 @@ #include "common/textconsole.h" #include "common/stream.h" #include "common/system.h" -//#include "FreeImage.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 2cc1a448f8..90d684d01a 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -29,8 +29,6 @@ #ifndef WINTERMUTE_BIMAGE_H #define WINTERMUTE_BIMAGE_H - -//#include "FreeImage.h" #include "engines/wintermute/Base/BBase.h" #include "graphics/surface.h" #include "graphics/pixelformat.h" diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index f790693e71..83d24d87ca 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -32,7 +32,6 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/Base/BSoundBuffer.h" -//#include "bass.h" namespace WinterMute { diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index fedf3572f3..430385615b 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -33,8 +33,6 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dcscript.h" // Added by ClassView -//#include -//#include #include "engines/wintermute/wme_debugger.h" #include "common/str.h" -- cgit v1.2.3 From 0fedd08714ac7ec36567db9dc4896a7513c0700f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 02:00:44 +0200 Subject: WINTERMUTE: Remove unused include in BGame.cpp --- engines/wintermute/Base/BGame.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index bf7eaa561f..953bd24686 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -31,7 +31,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BFont.h" #include "engines/wintermute/Base/BFontStorage.h" -- cgit v1.2.3 From 4b7201c7e1f92a620ed6bbc936d0b0f3648f1470 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 02:04:24 +0200 Subject: WINTERMUTE: Alphabetize the includes in AdGame --- engines/wintermute/Ad/AdGame.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 32c037cba8..22400accfa 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -27,35 +27,35 @@ */ #include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Ad/AdActor.h" #include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdResponseBox.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Ad/AdInventory.h" #include "engines/wintermute/Ad/AdInventoryBox.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/Ad/AdResponse.h" +#include "engines/wintermute/Ad/AdResponseBox.h" +#include "engines/wintermute/Ad/AdResponseContext.h" +#include "engines/wintermute/Ad/AdScene.h" #include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/Base/BTransitionMgr.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/UI/UIEntity.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Ad/AdActor.h" -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdResponseContext.h" -#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/PartEmitter.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Ad/AdResponse.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/UI/UIEntity.h" +#include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/video/VidPlayer.h" #include "engines/wintermute/video/VidTheoraPlayer.h" -- cgit v1.2.3 From e546237a2311d2e4d323d0754dd313730b58200e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 02:17:36 +0200 Subject: WINTERMUTE: Clear up another few includes. --- engines/wintermute/Base/BSoundMgr.cpp | 1 + engines/wintermute/Base/BSoundMgr.h | 3 +-- engines/wintermute/Base/BSurfaceSDL.h | 1 - engines/wintermute/Base/PartEmitter.cpp | 1 + engines/wintermute/Base/PartEmitter.h | 3 +-- engines/wintermute/Base/PartParticle.h | 4 ++-- 6 files changed, 6 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index bac53f6b22..dc9f3e9011 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BSoundBuffer.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index 83d24d87ca..313823449d 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -31,10 +31,9 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BSoundBuffer.h" namespace WinterMute { - +class CBSoundBuffer; class CBSoundMgr : public CBBase { public: float posToPan(int X, int Y); diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 6301310f01..1c5c3c3e15 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -31,7 +31,6 @@ #include "graphics/surface.h" #include "engines/wintermute/Base/BSurface.h" -#include "graphics/surface.h" namespace WinterMute { class TransparentSurface; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 09afdcc6b4..4bf6b8ece0 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Base/PartParticle.h" #include "engines/wintermute/math/Vector2.h" #include "engines/wintermute/math/Matrix4.h" #include "engines/wintermute/Base/scriptables/ScValue.h" diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 69ab35053d..98eed9e678 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -31,12 +31,11 @@ #include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/PartParticle.h" #include "engines/wintermute/Base/PartForce.h" namespace WinterMute { class CBRegion; - +class CPartParticle; class CPartEmitter : public CBObject { public: DECLARE_PERSISTENT(CPartEmitter, CBObject) diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 04f33c2cce..e86c1004ae 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_PATRPARTICLE_H -#define WINTERMUTE_PATRPARTICLE_H +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H #include "engines/wintermute/Base/BBase.h" -- cgit v1.2.3 From bd31b5f20144169c830211db29eac8d4789f1428 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 18:45:28 +0200 Subject: WINTERMUTE: Move some of the initialization code over from PlatformSDL --- engines/wintermute/PlatformSDL.cpp | 169 ---------------------------------- engines/wintermute/PlatformSDL.h | 1 - engines/wintermute/wintermute.cpp | 182 ++++++++++++++++++++++++++++++++++++- engines/wintermute/wintermute.h | 6 +- 4 files changed, 181 insertions(+), 177 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 10d18c7fc1..e27cbb291f 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -42,178 +42,9 @@ namespace WinterMute { CBGame *CBPlatform::Game = NULL; - #define CLASS_NAME "GF_FRAME" -////////////////////////////////////////////////////////////////////////// int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { - //setlocale(LC_CTYPE, ""); - Game = inGame; - if (!Game) return 1; - - - bool windowedMode = true; - - - // parse command line - char *SaveGame = NULL; - char param[MAX_PATH]; - for (int i = 0; i < argc; i++) { - strcpy(param, argv[i]); - - if (scumm_stricmp(param, "-project") == 0) { - if (argc > i) strcpy(param, argv[i + 1]); - else param[0] = '\0'; - - if (strcmp(param, "") != 0) { - char *IniDir = CBUtils::GetPath(param); - char *IniName = CBUtils::GetFilename(param); - - // switch to ini's dir - warning("TODO: Place ini-files somewhere"); -// chdir(IniDir); - - // set ini name - sprintf(param, "./%s", IniName); - Game->_registry->SetIniName(param); - - delete [] IniDir; - delete [] IniName; - } - } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; - } - - - if (Game->_registry->ReadBool("Debug", "DebugMode")) Game->DEBUG_DebugEnable("./wme.log"); - - Game->_dEBUG_ShowFPS = Game->_registry->ReadBool("Debug", "ShowFPS"); - - if (Game->_registry->ReadBool("Debug", "DisableSmartCache")) { - Game->LOG(0, "Smart cache is DISABLED"); - Game->_smartCache = false; - } - -/* bool AllowDirectDraw = Game->_registry->ReadBool("Debug", "AllowDirectDraw", false);*/ - - // load general game settings - Game->Initialize1(); - - - if (FAILED(Game->LoadSettings("startup.settings"))) { - Game->LOG(0, "Error loading game settings."); - delete Game; - Game = NULL; - - warning("Some of the essential files are missing. Please reinstall."); - return 2; - } - - Game->Initialize2(); - - Game->GetDebugMgr()->OnGameInit(); - Game->_scEngine->LoadBreakpoints(); - - - - HRESULT ret; - - // initialize the renderer - ret = Game->_renderer->InitRenderer(Game->_settingsResWidth, Game->_settingsResHeight, windowedMode); - if (FAILED(ret)) { - Game->LOG(ret, "Error initializing renderer. Exiting."); - - delete Game; - Game = NULL; - return 3; - } - - Game->Initialize3(); - -#ifdef __IPHONEOS__ - SDL_AddEventWatch(CBPlatform::SDLEventWatcher, NULL); -#endif - - // initialize sound manager (non-fatal if we fail) - ret = Game->_soundMgr->initialize(); - if (FAILED(ret)) { - Game->LOG(ret, "Sound is NOT available."); - } - - - // load game - uint32 DataInitStart = GetTime(); - - if (FAILED(Game->LoadFile(Game->_settingsGameFile ? Game->_settingsGameFile : "default.game"))) { - Game->LOG(ret, "Error loading game file. Exiting."); - delete Game; - Game = NULL; - return false; - } - Game->SetWindowTitle(); - Game->_renderer->_ready = true; - Game->_miniUpdateEnabled = true; - - Game->LOG(0, "Engine initialized in %d ms", GetTime() - DataInitStart); - Game->LOG(0, ""); - - - if (SaveGame) { - Game->LoadGame(SaveGame); - delete [] SaveGame; - } - - // all set, ready to go - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CBPlatform::MessageLoop() { - bool done = false; - - while (!done) { - Common::Event event; - while (g_system->getEventManager()->pollEvent(event)) { - HandleEvent(&event); - } - - if (Game && Game->_renderer->_active && Game->_renderer->_ready) { - - Game->DisplayContent(); - Game->DisplayQuickMsg(); - - Game->DisplayDebugInfo(); - - // ***** flip - if (!Game->_suspendedRendering) Game->_renderer->Flip(); - if (Game->_loading) Game->LoadGame(Game->_scheduledLoadSlot); - } - if (Game->_quitting) break; - - } - - if (Game) { - // remember previous window position - /* - if(Game->_renderer && Game->_renderer->_windowed) - { - if(!::IsIconic(Game->_renderer->_window)) - { - int PosX = Game->_renderer->_windowRect.left; - int PosY = Game->_renderer->_windowRect.top; - PosX -= Game->_renderer->_monitorRect.left; - PosY -= Game->_renderer->_monitorRect.top; - - Game->_registry->WriteInt("Video", "WindowPosX", PosX); - Game->_registry->WriteInt("Video", "WindowPosY", PosY); - } - } - */ - - delete Game; - Game = NULL; - } - return 0; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 347d306378..6adba29ae8 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -42,7 +42,6 @@ class CBGame; class CBPlatform { public: static int Initialize(CBGame *inGame, int argc, char *argv[]); - static int MessageLoop(); static void HandleEvent(Common::Event *event); static AnsiString GetSystemFontPath(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index d91619710b..ed8054885d 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -34,6 +34,10 @@ #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/Base/BRegistry.h" + +#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" namespace WinterMute { @@ -57,6 +61,7 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst) _rnd = new Common::RandomSource("WinterMute"); debug("WinterMuteEngine::WinterMuteEngine"); + _game = NULL; } WinterMuteEngine::~WinterMuteEngine() { @@ -106,16 +111,183 @@ Common::Error WinterMuteEngine::run() { // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); - CAdGame *game = new CAdGame; - int ret = 1; - - ret = CBPlatform::Initialize(game, NULL, 0); + + ret = init(); if (ret == 0) { - ret = CBPlatform::MessageLoop(); + ret = messageLoop(); } return Common::kNoError; } +int WinterMuteEngine::init() { + char argv[1] = { ' ' }; + int argc = 0; + _game = new CAdGame; + if (!_game) return 1; + + bool windowedMode = true; + + // parse command line + char *SaveGame = NULL; + char param[MAX_PATH]; +/* for (int i = 0; i < argc; i++) { + strcpy(param, argv[i]); + + if (scumm_stricmp(param, "-project") == 0) { + if (argc > i) strcpy(param, argv[i + 1]); + else param[0] = '\0'; + + if (strcmp(param, "") != 0) { + char *IniDir = CBUtils::GetPath(param); + char *IniName = CBUtils::GetFilename(param); + + // switch to ini's dir + warning("TODO: Place ini-files somewhere"); + // chdir(IniDir); + + // set ini name + sprintf(param, "./%s", IniName); + _game->_registry->SetIniName(param); + + delete [] IniDir; + delete [] IniName; + } + } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; + }*/ + + + if (_game->_registry->ReadBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); + + _game->_dEBUG_ShowFPS = _game->_registry->ReadBool("Debug", "ShowFPS"); + + if (_game->_registry->ReadBool("Debug", "DisableSmartCache")) { + _game->LOG(0, "Smart cache is DISABLED"); + _game->_smartCache = false; + } + + /* bool AllowDirectDraw = _game->_registry->ReadBool("Debug", "AllowDirectDraw", false);*/ + + // load general game settings + _game->Initialize1(); + + + if (FAILED(_game->LoadSettings("startup.settings"))) { + _game->LOG(0, "Error loading game settings."); + delete _game; + _game = NULL; + + warning("Some of the essential files are missing. Please reinstall."); + return 2; + } + + _game->Initialize2(); + + _game->GetDebugMgr()->OnGameInit(); + _game->_scEngine->LoadBreakpoints(); + + + + HRESULT ret; + + // initialize the renderer + ret = _game->_renderer->InitRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); + if (FAILED(ret)) { + _game->LOG(ret, "Error initializing renderer. Exiting."); + + delete _game; + _game = NULL; + return 3; + } + + _game->Initialize3(); + +#ifdef __IPHONEOS__ + SDL_AddEventWatch(CBPlatform::SDLEventWatcher, NULL); +#endif + + // initialize sound manager (non-fatal if we fail) + ret = _game->_soundMgr->initialize(); + if (FAILED(ret)) { + _game->LOG(ret, "Sound is NOT available."); + } + + + // load game + uint32 DataInitStart = CBPlatform::GetTime(); + + if (FAILED(_game->LoadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { + _game->LOG(ret, "Error loading game file. Exiting."); + delete _game; + _game = NULL; + return false; + } + _game->SetWindowTitle(); + _game->_renderer->_ready = true; + _game->_miniUpdateEnabled = true; + + _game->LOG(0, "Engine initialized in %d ms", CBPlatform::GetTime() - DataInitStart); + _game->LOG(0, ""); + + + if (SaveGame) { + _game->LoadGame(SaveGame); + delete [] SaveGame; + } + + CBPlatform::Initialize(_game, 0, NULL); + + // all set, ready to go + return 0; +} + +int WinterMuteEngine::messageLoop() { + bool done = false; + + while (!done) { + Common::Event event; + while (_system->getEventManager()->pollEvent(event)) { + CBPlatform::HandleEvent(&event); + } + + if (_game && _game->_renderer->_active && _game->_renderer->_ready) { + + _game->DisplayContent(); + _game->DisplayQuickMsg(); + + _game->DisplayDebugInfo(); + + // ***** flip + if (!_game->_suspendedRendering) _game->_renderer->Flip(); + if (_game->_loading) _game->LoadGame(_game->_scheduledLoadSlot); + } + if (_game->_quitting) break; + + } + + if (_game) { + // remember previous window position + /* + if(_game->_renderer && _game->_renderer->_windowed) + { + if(!::IsIconic(_game->_renderer->_window)) + { + int PosX = _game->_renderer->_windowRect.left; + int PosY = _game->_renderer->_windowRect.top; + PosX -= _game->_renderer->_monitorRect.left; + PosY -= _game->_renderer->_monitorRect.top; + + _game->_registry->WriteInt("Video", "WindowPosX", PosX); + _game->_registry->WriteInt("Video", "WindowPosY", PosY); + } + } + */ + + delete _game; + _game = NULL; + } + return 0; +} + } // End of namespace WinterMute diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index e1f5047239..1a03de5553 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -30,7 +30,7 @@ namespace WinterMute { class Console; - +class CBGame; // our engine debug channels enum { kWinterMuteDebugExample = 1 << 0, @@ -47,8 +47,10 @@ public: virtual Common::Error run(); private: + int init(); + int messageLoop(); Console *_console; - + CBGame *_game; // We need random numbers Common::RandomSource *_rnd; }; -- cgit v1.2.3 From 4c1909db9a2b7e17a338eba6d144d530a59190f1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 18:55:46 +0200 Subject: WINTERMUTE: Add untested mouse-wheel-handling. --- engines/wintermute/PlatformSDL.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index e27cbb291f..a0ba4f4a05 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -81,6 +81,10 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_KEYUP: if (Game) Game->handleKeyRelease(event); break; + case Common::EVENT_WHEELUP: + case Common::EVENT_WHEELDOWN: + if (Game) Game->HandleMouseWheel(event->mouse.y); + break; /*#ifdef __IPHONEOS__ { CBRenderSDL *renderer = static_cast(Game->_renderer); -- cgit v1.2.3 From 3d49eb16058c4e5a5fb3889b8bc89546c43891b2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 18:56:16 +0200 Subject: WINTERMUTE: Add a global g_wintermute. --- engines/wintermute/wintermute.cpp | 4 ++++ engines/wintermute/wintermute.h | 2 ++ 2 files changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index ed8054885d..7fa59930d5 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -41,6 +41,8 @@ namespace WinterMute { +WinterMuteEngine *g_wintermute; + WinterMuteEngine::WinterMuteEngine(OSystem *syst) : Engine(syst) { // Put your engine in a sane state, but do nothing big yet; @@ -62,6 +64,8 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst) debug("WinterMuteEngine::WinterMuteEngine"); _game = NULL; + + g_wintermute = this; } WinterMuteEngine::~WinterMuteEngine() { diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 1a03de5553..015f31c2bb 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -62,6 +62,8 @@ public: virtual ~Console(void) {} }; +extern WinterMuteEngine *g_wintermute; + } // End of namespace Wintermute #endif -- cgit v1.2.3 From 850e237d318a3299648a07fd142667b966e316c3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 19:19:09 +0200 Subject: WINTERMUTE: Get rid of rand/srand. --- engines/wintermute/Ad/AdActor.cpp | 8 ++++---- engines/wintermute/Ad/AdTalkHolder.cpp | 4 ++-- engines/wintermute/Base/BGame.cpp | 4 ---- engines/wintermute/utils/utils.cpp | 23 ++++++++++++----------- engines/wintermute/wintermute.cpp | 4 ++++ engines/wintermute/wintermute.h | 1 + 6 files changed, 23 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 55e73ea482..27adf1a6f2 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_rand + #include "engines/wintermute/dcgf.h" #include "engines/wintermute/dctypes.h" #include "engines/wintermute/persistent.h" @@ -48,7 +48,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" -#include +#include "engines/wintermute/wintermute.h" namespace WinterMute { @@ -1159,7 +1159,7 @@ CBSprite *CAdActor::GetTalkStance(const char *Stance) { } if (TalkAnims.GetSize() > 0) { - int rnd = rand() % TalkAnims.GetSize(); + int rnd = g_wintermute->randInt(0, TalkAnims.GetSize() - 1); Ret = TalkAnims[rnd]->GetSprite(_dir); } else { if (_standSprite) Ret = _standSprite->GetSprite(_dir); @@ -1200,7 +1200,7 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { if (_talkSprites.GetSize() < 1) ret = _standSprite->GetSprite(_dir); else { // TODO: remember last - int rnd = rand() % _talkSprites.GetSize(); + int rnd = g_wintermute->randInt(0, _talkSprites.GetSize() - 1); ret = _talkSprites[rnd]->GetSprite(_dir); } } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 61e012b261..a2af4223a3 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_rand #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdTalkHolder.h" #include "engines/wintermute/Base/BDynBuffer.h" @@ -36,6 +35,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" #include "common/str.h" namespace WinterMute { @@ -106,7 +106,7 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { if (_talkSprites.GetSize() < 1) ret = _sprite; else { // TODO: remember last - int rnd = rand() % _talkSprites.GetSize(); + int rnd = g_wintermute->randInt(0, _talkSprites.GetSize() - 1); ret = _talkSprites[rnd]; } } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 953bd24686..b30deadc41 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -26,8 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_srand - #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" @@ -148,8 +146,6 @@ CBGame::CBGame(): CBObject(this) { _useD3D = false; - srand(g_system->getMillis()); - _registry = new CBRegistry(this); _stringTable = new CBStringTable(this); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index c9131608be..4e4678ffae 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -26,8 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_rand - #include "engines/wintermute/dcgf.h" #include "utils.h" #include "engines/wintermute/PlatformSDL.h" @@ -36,6 +34,7 @@ #include "engines/wintermute/Base/BGame.h" #include "common/str.h" #include "common/textconsole.h" +#include "wintermute.h" namespace WinterMute { @@ -164,19 +163,21 @@ char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { } ////////////////////////////////////////////////////////////////////////// -int CBUtils::RandomInt(int From, int To) { - if (To < From) { - int i = To; - To = From; - From = i; +int CBUtils::RandomInt(int from, int to) { + if (to < from) { + int i = to; + to = from; + from = i; } - return (rand() % (To - From + 1)) + From; + return g_wintermute->randInt(from, to); +// return (rand() % (to - from + 1)) + from; } ////////////////////////////////////////////////////////////////////////// -float CBUtils::RandomFloat(float From, float To) { - float RandNum = (float)rand() / (float)RAND_MAX; - return From + (To - From) * RandNum; +float CBUtils::RandomFloat(float from, float to) { + const uint32 randMax = RAND_MAX; + float randNum = (float)g_wintermute->randInt(0, randMax) / (float)randMax; + return from + (to - from) * randNum; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 7fa59930d5..8b12a422cf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -294,4 +294,8 @@ int WinterMuteEngine::messageLoop() { return 0; } +uint32 WinterMuteEngine::randInt(int from, int to) { + return _rnd->getRandomNumberRng(from, to); +} + } // End of namespace WinterMute diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 015f31c2bb..d6c3b1faf9 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -46,6 +46,7 @@ public: virtual Common::Error run(); + uint32 randInt(int from, int to); private: int init(); int messageLoop(); -- cgit v1.2.3 From 0c8497229484270019722d883cee2f6c9492443d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 19:33:30 +0200 Subject: WINTERMUTE: Change a few char* to Common::String in AdActor --- engines/wintermute/Ad/AdActor.cpp | 61 ++++++++----------------- engines/wintermute/Ad/AdActor.h | 12 ++--- engines/wintermute/Base/scriptables/ScValue.cpp | 3 ++ engines/wintermute/Base/scriptables/ScValue.h | 1 + 4 files changed, 29 insertions(+), 48 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 27adf1a6f2..3124585bc5 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -77,21 +77,11 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::SetDefaultAnimNames() { - _talkAnimName = NULL; - CBUtils::SetString(&_talkAnimName, "talk"); - - _idleAnimName = NULL; - CBUtils::SetString(&_idleAnimName, "idle"); - - _walkAnimName = NULL; - CBUtils::SetString(&_walkAnimName, "walk"); - - _turnLeftAnimName = NULL; - CBUtils::SetString(&_turnLeftAnimName, "turnleft"); - - _turnRightAnimName = NULL; - CBUtils::SetString(&_turnRightAnimName, "turnright"); - + _talkAnimName = "talk"; + _idleAnimName = "idle"; + _walkAnimName = "walk"; + _turnLeftAnimName = "turnleft"; + _turnRightAnimName = "turnright"; return S_OK; } @@ -123,18 +113,6 @@ CAdActor::~CAdActor() { } _talkSpritesEx.RemoveAll(); - - delete[] _talkAnimName; - delete[] _idleAnimName; - delete[] _walkAnimName; - delete[] _turnLeftAnimName; - delete[] _turnRightAnimName; - _talkAnimName = NULL; - _idleAnimName = NULL; - _walkAnimName = NULL; - _turnLeftAnimName = NULL; - _turnRightAnimName = NULL; - for (int i = 0; i < _anims.GetSize(); i++) { delete _anims[i]; _anims[i] = NULL; @@ -1071,8 +1049,8 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_talkAnimName, "talk"); - else CBUtils::SetString(&_talkAnimName, Value->GetString()); + if (Value->IsNULL()) _talkAnimName = "talk"; + else _talkAnimName = Value->GetString(); return S_OK; } @@ -1080,8 +1058,8 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "WalkAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_walkAnimName, "walk"); - else CBUtils::SetString(&_walkAnimName, Value->GetString()); + if (Value->IsNULL()) _walkAnimName = "walk"; + else _walkAnimName = Value->GetString(); return S_OK; } @@ -1089,8 +1067,8 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "IdleAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_idleAnimName, "idle"); - else CBUtils::SetString(&_idleAnimName, Value->GetString()); + if (Value->IsNULL()) _idleAnimName = "idle"; + else _idleAnimName = Value->GetString(); return S_OK; } @@ -1098,8 +1076,8 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnLeftAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_turnLeftAnimName, "turnleft"); - else CBUtils::SetString(&_turnLeftAnimName, Value->GetString()); + if (Value->IsNULL()) _turnLeftAnimName = "turnleft"; + else _turnLeftAnimName = Value->GetString(); return S_OK; } @@ -1107,8 +1085,8 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TurnRightAnimName") == 0) { - if (Value->IsNULL()) CBUtils::SetString(&_turnRightAnimName, "turnright"); - else CBUtils::SetString(&_turnRightAnimName, Value->GetString()); + if (Value->IsNULL()) _turnRightAnimName = "turnright"; + else _turnRightAnimName = Value->GetString(); return S_OK; } @@ -1154,7 +1132,7 @@ CBSprite *CAdActor::GetTalkStance(const char *Stance) { if (!Ret) { CBArray TalkAnims; for (int i = 0; i < _anims.GetSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, _talkAnimName) == 0) + if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) TalkAnims.Add(_anims[i]); } @@ -1275,11 +1253,10 @@ int CAdActor::GetHeight() { ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::GetAnimByName(const char *AnimName) { - if (!AnimName) return NULL; - +CAdSpriteSet *CAdActor::GetAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.GetSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) return _anims[i]; + if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) + return _anims[i]; } return NULL; } diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index 0c00b19157..1a689bafd4 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -71,14 +71,14 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // new anim system - char *_talkAnimName; - char *_idleAnimName; - char *_walkAnimName; - char *_turnLeftAnimName; - char *_turnRightAnimName; + Common::String _talkAnimName; + Common::String _idleAnimName; + Common::String _walkAnimName; + Common::String _turnLeftAnimName; + Common::String _turnRightAnimName; CBArray _anims; virtual HRESULT PlayAnim(const char *Filename); - CAdSpriteSet *GetAnimByName(const char *AnimName); + CAdSpriteSet *GetAnimByName(const Common::String &animName); // scripting interface virtual CScValue *ScGetProperty(const char *Name); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index b2df4cae16..517c1516ba 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -407,6 +407,9 @@ void CScValue::SetString(const char *Val) { else _type = VAL_NULL; } +void CScValue::SetString(const Common::String &Val) { + SetString(Val.c_str()); +} ////////////////////////////////////////////////////////////////////////// void CScValue::SetStringVal(const char *Val) { diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 430385615b..79a6634fb3 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -72,6 +72,7 @@ public: void SetInt(int Val); void SetFloat(double Val); void SetString(const char *Val); + void SetString(const Common::String &Val); void SetNULL(); void SetNative(CBScriptable *Val, bool Persistent = false); void SetObject(); -- cgit v1.2.3 From b8a7266c4ea5a49cff7576fb21c13d1cf40b9e1e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 15 Jun 2012 19:49:13 +0200 Subject: WINTERMUTE: Get rid of all system-headers BUT limits.h --- engines/wintermute/Ad/AdScene.cpp | 1 - engines/wintermute/Base/BFontStorage.h | 3 --- engines/wintermute/dcpackage.h | 7 +------ 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 53d1d78907..b3551d0811 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -58,7 +58,6 @@ #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/utils/utils.h" -#include #include namespace WinterMute { diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index c7d60d7bce..17d0501093 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -34,9 +34,6 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" -/*#include -#include FT_FREETYPE_H*/ - namespace WinterMute { class CBFont; diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h index 292248cf5c..0b7bdf9b44 100644 --- a/engines/wintermute/dcpackage.h +++ b/engines/wintermute/dcpackage.h @@ -35,7 +35,6 @@ #define PACKAGE_VERSION 0x00000200 #define PACKAGE_EXTENSION "dcp" -#include #include "common/stream.h" namespace WinterMute { @@ -48,11 +47,7 @@ struct TPackageHeader { byte Priority; byte CD; bool MasterIndex; -#ifdef __WIN32__ - __time32_t CreationTime; -#else - time_t CreationTime; -#endif + uint32 CreationTime; char Desc[100]; uint32 NumDirs; // TODO: Move this out of the header. -- cgit v1.2.3 From 3d4495d1ceb7e4e6fbb4dafa2df388804f2bf783 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 16 Jun 2012 02:14:35 +0200 Subject: WINTERMUTE: A first attempt at getting savegames to work. --- engines/wintermute/Base/BFileManager.cpp | 14 + engines/wintermute/Base/BFileManager.h | 1 + engines/wintermute/Base/BGame.cpp | 5 +- engines/wintermute/Base/BPersistMgr.cpp | 359 ++++++++++++++++++++----- engines/wintermute/Base/BPersistMgr.h | 17 +- engines/wintermute/Base/scriptables/SXDate.cpp | 10 +- engines/wintermute/wintermute.h | 1 + 7 files changed, 328 insertions(+), 79 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 1848595c19..990375ef73 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -43,6 +43,7 @@ #include "engines/wintermute/dcpackage.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/textconsole.h" #include "common/util.h" @@ -50,6 +51,7 @@ #include "common/system.h" #include "common/fs.h" #include "common/file.h" +#include "common/savefile.h" namespace WinterMute { @@ -156,11 +158,23 @@ byte *CBFileManager::ReadWholeFile(const Common::String &Filename, uint32 *Size, return buffer; } +Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::InSaveFile *file = saveMan->openForLoading(filename); + return file; +} ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(Filename); + file->write(PrefixBuffer, PrefixSize); + file->write(Buffer, BufferSize); + file->finalize(); + delete file; #if 0 RestoreCurrentDir(); diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index dd49637cd6..11a90fc823 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -62,6 +62,7 @@ public: } TPathType; HRESULT AddPath(TPathType Type, const Common::String &path); HRESULT RequestCD(int CD, char *PackageFile, char *Filename); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); HRESULT SaveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); byte *ReadWholeFile(const Common::String &filename, uint32 *Size = NULL, bool MustExist = true); CBFileManager(CBGame *inGame = NULL); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index b30deadc41..b966f3822b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3903,8 +3903,9 @@ void CBGame::SetWindowTitle() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { AnsiString dataDir = GetDataDir(); - sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - + //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + sprintf(Buffer, "save%03d.%s", Slot, _savedGameExt); + warning("Saving %s - we really should prefix these things to avoid collisions.", Buffer); return S_OK; } diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 3372e05ba1..d94a88b102 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BSound.h" +#include "commoN/memstream.h" #include "common/str.h" namespace WinterMute { @@ -49,9 +50,11 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { _saving = false; - _buffer = NULL; - _bufferSize = 0; +// _buffer = NULL; +// _bufferSize = 0; _offset = 0; + _saveStream = NULL; + _loadStream = NULL; _richBuffer = NULL; _richBufferSize = 0; @@ -74,13 +77,13 @@ CBPersistMgr::~CBPersistMgr() { ////////////////////////////////////////////////////////////////////////// void CBPersistMgr::Cleanup() { - if (_buffer) { +/* if (_buffer) { if (_saving) free(_buffer); else delete [] _buffer; // allocated by file manager } _buffer = NULL; - _bufferSize = 0; + _bufferSize = 0;*/ _offset = 0; delete[] _richBuffer; @@ -97,6 +100,11 @@ void CBPersistMgr::Cleanup() { delete [] _thumbnailData; _thumbnailData = NULL; } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; } // TODO: This is not at all endian-safe @@ -115,14 +123,14 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { Cleanup(); _saving = true; - _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); +/* _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); if (_buffer) { _bufferSize = SAVE_BUFFER_INIT_SIZE; res = S_OK; - } else res = E_FAIL; + } else res = E_FAIL;*/ + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - - if (SUCCEEDED(res)) { + if (_saveStream) { // get thumbnails if (!Game->_cachedThumbnail) { Game->_cachedThumbnail = new CBSaveThumbHelper(Game); @@ -142,8 +150,10 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { byte VerMajor, VerMinor, ExtMajor, ExtMinor; Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - uint32 Version = makeUint32(VerMajor, VerMinor, ExtMajor, ExtMinor); - PutDWORD(Version); + _saveStream->writeByte(VerMajor); + _saveStream->writeByte(VerMinor); + _saveStream->writeByte(ExtMajor); + _saveStream->writeByte(ExtMinor); // new in ver 2 PutDWORD((uint32)DCGF_VER_BUILD); @@ -158,8 +168,7 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { byte *Buffer = Game->_cachedThumbnail->_thumbnail->CreateBMPBuffer(&Size); PutDWORD(Size); - if (Size > 0) PutBytes(Buffer, Size); - + if (Size > 0) _saveStream->write(Buffer, Size); delete [] Buffer; ThumbnailOK = true; } @@ -181,8 +190,9 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { /* time_t Timestamp; time(&Timestamp); PutDWORD((uint32)Timestamp);*/ + PutDWORD(0); } - return res; + return S_OK; } // TODO: Do this properly, this is just a quickfix, that probably doesnt even work. // The main point of which is ditching BASS completely. @@ -214,8 +224,9 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { _saving = false; - _buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); - if (_buffer) { + _loadStream = Game->_fileManager->loadSaveGame(Filename); + //_buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); + if (_loadStream) { uint32 Magic; Magic = GetDWORD(); if (Magic != DCGF_MAGIC) goto init_fail; @@ -223,11 +234,10 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { Magic = GetDWORD(); if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { - uint32 Version = GetDWORD(); - _savedVerMajor = getLowByte(getLowWord(Version)); - _savedVerMinor = getHighByte(getLowWord(Version)); - _savedExtMajor = getLowByte(getHighWord(Version)); - _savedExtMinor = getHighByte(getHighWord(Version)); + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); if (Magic == SAVE_MAGIC_2) { _savedVerBuild = (byte)GetDWORD(); @@ -294,13 +304,17 @@ init_fail: ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::SaveFile(const char *Filename) { - return Game->_fileManager->SaveFile(Filename, _buffer, _offset, Game->_compressedSavegames, _richBuffer, _richBufferSize); + return Game->_fileManager->SaveFile(Filename, ((Common::MemoryWriteStreamDynamic*)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic*)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { - while (_offset + Size > _bufferSize) { +HRESULT CBPersistMgr::PutBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) + return E_FAIL; + return S_OK; +/* while (_offset + Size > _bufferSize) { _bufferSize += SAVE_BUFFER_GROW_BY; _buffer = (byte *)realloc(_buffer, _bufferSize); if (!_buffer) { @@ -312,13 +326,16 @@ HRESULT CBPersistMgr::PutBytes(byte *Buffer, uint32 Size) { memcpy(_buffer + _offset, Buffer, Size); _offset += Size; - return S_OK; + return S_OK;*/ } - ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { - if (_offset + Size > _bufferSize) { +HRESULT CBPersistMgr::GetBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) + return E_FAIL; + return S_OK; +/* if (_offset + Size > _bufferSize) { Game->LOG(0, "Fatal: Save buffer underflow"); return E_FAIL; } @@ -326,81 +343,178 @@ HRESULT CBPersistMgr::GetBytes(byte *Buffer, uint32 Size) { memcpy(Buffer, _buffer + _offset, Size); _offset += Size; - return S_OK; + return S_OK;*/ } - ////////////////////////////////////////////////////////////////////////// void CBPersistMgr::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); + //PutBytes((byte *)&Val, sizeof(uint32)); + _saveStream->writeUint32LE(Val); } ////////////////////////////////////////////////////////////////////////// uint32 CBPersistMgr::GetDWORD() { - uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); + uint32 ret = _loadStream->readUint32LE(); +// GetBytes((byte *)&ret, sizeof(uint32)); return ret; } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::PutString(const char *Val) { - if (!Val) PutString("(null)"); +void CBPersistMgr::PutString(const Common::String &Val) { + if (!Val.size()) PutString("(null)"); else { - PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); + /* PutDWORD(strlen(Val) + 1); + PutBytes((byte *)Val, strlen(Val) + 1);*/ + _saveStream->writeUint32LE(Val.size()); + _saveStream->writeString(Val); } } ////////////////////////////////////////////////////////////////////////// char *CBPersistMgr::GetString() { - uint32 len = GetDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; +/* char *ret = (char *)(_buffer + _offset); + _offset += len;*/ + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else return ret; +} + +void CBPersistMgr::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float CBPersistMgr::getFloat() { + char *str = GetString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} - if (!strcmp(ret, "(null)")) return NULL; - else return ret; +void CBPersistMgr::putDouble(double val) { + Common::String str = Common::String::format("F%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double CBPersistMgr::getDouble() { + char *str = GetString(); + double value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; } ////////////////////////////////////////////////////////////////////////// // bool HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(bool)); - else return GetBytes((byte *)Val, sizeof(bool)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(bool)); + _saveStream->writeByte(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + //return GetBytes((byte *)Val, sizeof(bool)); + *Val = _loadStream->readByte(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // int HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(int)); - else return GetBytes((byte *)Val, sizeof(int)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(int)); + _saveStream->writeSint32LE(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + // return GetBytes((byte *)Val, sizeof(int)); + *Val = _loadStream->readSint32LE(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // DWORD HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(uint32)); - else return GetBytes((byte *)Val, sizeof(uint32)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(uint32)); + _saveStream->writeUint32LE(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + // return GetBytes((byte *)Val, sizeof(uint32)); + *Val = _loadStream->readUint32LE(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // float HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(float)); - else return GetBytes((byte *)Val, sizeof(float)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(float)); + putFloat(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + //return GetBytes((byte *)Val, sizeof(float)); + *Val = getFloat(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // double HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(double)); - else return GetBytes((byte *)Val, sizeof(double)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(double)); + putDouble(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + // return GetBytes((byte *)Val, sizeof(double)); + *Val = getDouble(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } @@ -412,11 +526,64 @@ HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { return S_OK; } else { char *str = GetString(); - if (str) { + if (_loadStream->err()) { + delete[] str; + return E_FAIL; + } + *Val = str; + /* if (str) { + + char *ret = new char[strlen(str) + 1]; + strcpy(ret, str); + delete[] str; + } else *Val = NULL;*/ + return S_OK; + } +} - *Val = new char[strlen(str) + 1]; - strcpy(*Val, str); - } else *Val = NULL; +////////////////////////////////////////////////////////////////////////// +// const char* +HRESULT CBPersistMgr::Transfer(const char *Name, const char **Val) { + if (_saving) { + PutString(*Val); + return S_OK; + } else { + char *str = GetString(); + if (_loadStream->err()) { + delete[] str; + return E_FAIL; + } + *Val = str; +/* if (str) { + + char *ret = new char[strlen(str) + 1]; + strcpy(ret, str); + delete[] str; + } else *Val = NULL;*/ + return S_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +HRESULT CBPersistMgr::Transfer(const char *Name, Common::String *val) { + if (_saving) { + PutString(*val); + return S_OK; + } else { + char *str = GetString(); + if (_loadStream->err()) { + delete[] str; + return E_FAIL; + } + *val = str; + delete[] str; + /* if (str) { + + char *ret = new char[strlen(str) + 1]; + strcpy(ret, str); + delete[] str; + } else *Val = NULL;*/ return S_OK; } } @@ -427,18 +594,25 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { if (_saving) { size = Val.size(); - PutBytes((byte *)&size, sizeof(size_t)); + _saveStream->writeUint32LE(size); + //PutBytes((byte *)&size, sizeof(size_t)); for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { PutString((*it).c_str()); } } else { Val.clear(); - GetBytes((byte *)&size, sizeof(size_t)); + size = _loadStream->readUint32LE(); + //GetBytes((byte *)&size, sizeof(size_t)); for (size_t i = 0; i < size; i++) { char *str = GetString(); + if (_loadStream->err()) { + delete[] str; + return E_FAIL; + } if (str) Val.push_back(str); + delete[] str; } } @@ -448,32 +622,75 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { ////////////////////////////////////////////////////////////////////////// // BYTE HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(byte)); - else return GetBytes((byte *)Val, sizeof(byte)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(byte)); + _saveStream->writeByte(*Val); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } else { + //return GetBytes((byte *)Val, sizeof(byte)); + *Val = _loadStream->readByte(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // RECT HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(RECT)); - else return GetBytes((byte *)Val, sizeof(RECT)); + if (_saving) { + // return PutBytes((byte *)Val, sizeof(RECT)); + _saveStream->writeSint32LE(Val->left); + _saveStream->writeSint32LE(Val->top); + _saveStream->writeSint32LE(Val->right); + _saveStream->writeSint32LE(Val->bottom); + if (_saveStream->err()) + return E_FAIL; + return S_OK; + } + else { + // return GetBytes((byte *)Val, sizeof(RECT)); + Val->left = _loadStream->readSint32LE(); + Val->top = _loadStream->readSint32LE(); + Val->right = _loadStream->readSint32LE(); + Val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; + } } ////////////////////////////////////////////////////////////////////////// // POINT HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(POINT)); - else return GetBytes((byte *)Val, sizeof(POINT)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(POINT)); + _saveStream->writeSint32LE(Val->x); + _saveStream->writeSint32LE(Val->y); + } else { + // return GetBytes((byte *)Val, sizeof(POINT)); + Val->x = _loadStream->readSint32LE(); + Val->y = _loadStream->readSint32LE(); + } } ////////////////////////////////////////////////////////////////////////// // Vector2 HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { - if (_saving) return PutBytes((byte *)Val, sizeof(Vector2)); - else return GetBytes((byte *)Val, sizeof(Vector2)); + if (_saving) { + //return PutBytes((byte *)Val, sizeof(Vector2)); + putFloat(Val->x); + putFloat(Val->y); + } else { + // return GetBytes((byte *)Val, sizeof(Vector2)); + Val->x = getFloat(); + Val->y = getFloat(); + } } @@ -488,11 +705,15 @@ HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { Game->LOG(0, "Warning: invalid instance '%s'", Name); } - PutDWORD(ClassID); - PutDWORD(InstanceID); + _saveStream->writeUint32LE(ClassID); + _saveStream->writeUint32LE(InstanceID); + // PutDWORD(ClassID); + // PutDWORD(InstanceID); } else { - ClassID = GetDWORD(); - InstanceID = GetDWORD(); + ClassID = _loadStream->readUint32LE(); + InstanceID = _loadStream->readUint32LE(); +/* ClassID = GetDWORD(); + InstanceID = GetDWORD();*/ *(void **)Val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); } diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 9049b72b3c..0fe1d75550 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "common/stream.h" namespace WinterMute { @@ -49,15 +50,19 @@ public: uint32 GetDWORD(); void PutDWORD(uint32 Val); char *GetString(); - void PutString(const char *Val); + void PutString(const Common::String &Val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); void Cleanup(); HRESULT InitLoad(const char *Filename); HRESULT InitSave(const char *Desc); HRESULT GetBytes(byte *Buffer, uint32 Size); HRESULT PutBytes(byte *Buffer, uint32 Size); uint32 _offset; - uint32 _bufferSize; - byte *_buffer; + //uint32 _bufferSize; + //byte *_buffer; bool _saving; uint32 _richBufferSize; @@ -72,7 +77,9 @@ public: HRESULT Transfer(const char *Name, byte *Val); HRESULT Transfer(const char *Name, RECT *Val); HRESULT Transfer(const char *Name, POINT *Val); + HRESULT Transfer(const char *Name, const char **Val); HRESULT Transfer(const char *Name, char **Val); + HRESULT Transfer(const char *Name, Common::String *val); HRESULT Transfer(const char *Name, Vector2 *Val); HRESULT Transfer(const char *Name, AnsiStringArray &Val); CBPersistMgr(CBGame *inGame = NULL); @@ -81,7 +88,9 @@ public: uint32 _thumbnailDataSize; byte *_thumbnailData; - +private: + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 2947428dad..069e31b06b 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -241,10 +241,12 @@ HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { CBScriptable::Persist(PersistMgr); - if (PersistMgr->_saving) - PersistMgr->PutBytes((byte *)&_tm, sizeof(_tm)); - else - PersistMgr->GetBytes((byte *)&_tm, sizeof(_tm)); + PersistMgr->Transfer(TMEMBER(_tm.tm_year)); + PersistMgr->Transfer(TMEMBER(_tm.tm_mon)); + PersistMgr->Transfer(TMEMBER(_tm.tm_mday)); + PersistMgr->Transfer(TMEMBER(_tm.tm_hour)); + PersistMgr->Transfer(TMEMBER(_tm.tm_min)); + PersistMgr->Transfer(TMEMBER(_tm.tm_sec)); return S_OK; } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index d6c3b1faf9..5c5aa1bf18 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -46,6 +46,7 @@ public: virtual Common::Error run(); + Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } uint32 randInt(int from, int to); private: int init(); -- cgit v1.2.3 From 0f6a87ae95dfa6ef122ba75a0a65a114616189ba Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 16 Jun 2012 16:39:02 +0200 Subject: WINTERMUTE: Make saves get listed properly --- engines/wintermute/Base/BGame.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index b966f3822b..13bfd9fc75 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -61,6 +61,8 @@ #include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/video/VidPlayer.h" #include "engines/wintermute/video/VidTheoraPlayer.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" #include "common/textconsole.h" #include "common/util.h" #include "common/keyboard.h" @@ -3950,10 +3952,10 @@ bool CBGame::IsSaveSlotUsed(int Slot) { char Filename[MAX_PATH + 1]; GetSaveSlotFilename(Slot, Filename); - Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", Slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(Filename); if (!File) return false; - - _fileManager->CloseFile(File); + delete File; return true; } -- cgit v1.2.3 From c12060ce936493a571b92236a3869a83a34f8ac3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 16 Jun 2012 16:39:51 +0200 Subject: WINTERMUTE: Save the VidTheoraPlayer-data too. --- engines/wintermute/video/VidTheoraPlayer.cpp | 38 ++++++++++++++-------------- engines/wintermute/video/VidTheoraPlayer.h | 3 ++- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index ca9287afb8..d64a6f2bb1 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/video/VidTheoraPlayer.h" +#include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BSurfaceSDL.h" @@ -41,7 +42,7 @@ namespace WinterMute { -//IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); +IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); ////////////////////////////////////////////////////////////////////////// CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { @@ -795,36 +796,35 @@ HRESULT CVidTheoraPlayer::resume() { } ////////////////////////////////////////////////////////////////////////// -/*HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { +HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { //CBBase::Persist(PersistMgr); -#if 0 - if (PersistMgr->m_Saving) { - m_SavedPos = GetMovieTime() * 1000; - m_SavedState = m_State; + + if (PersistMgr->_saving) { + _savedPos = getMovieTime() * 1000; + _savedState = _state; } else { SetDefaults(); } PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(m_SavedPos)); - PersistMgr->Transfer(TMEMBER(m_SavedState)); - PersistMgr->Transfer(TMEMBER(m_Filename)); - PersistMgr->Transfer(TMEMBER(m_AlphaFilename)); - PersistMgr->Transfer(TMEMBER(m_PosX)); - PersistMgr->Transfer(TMEMBER(m_PosY)); - PersistMgr->Transfer(TMEMBER(m_PlayZoom)); - PersistMgr->Transfer(TMEMBER_INT(m_PlaybackType)); - PersistMgr->Transfer(TMEMBER(m_Looping)); + PersistMgr->Transfer(TMEMBER(_savedPos)); + PersistMgr->Transfer(TMEMBER(_savedState)); + PersistMgr->Transfer(TMEMBER(_filename)); + PersistMgr->Transfer(TMEMBER(_alphaFilename)); + PersistMgr->Transfer(TMEMBER(_posX)); + PersistMgr->Transfer(TMEMBER(_posY)); + PersistMgr->Transfer(TMEMBER(_playZoom)); + PersistMgr->Transfer(TMEMBER_INT(_playbackType)); + PersistMgr->Transfer(TMEMBER(_looping)); if (PersistMgr->CheckVersion(1, 7, 3)) { - PersistMgr->Transfer(TMEMBER(m_Volume)); + PersistMgr->Transfer(TMEMBER(_volume)); } else { - m_Volume = 100; + _volume = 100; } -#endif return S_OK; } -*/ + ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initializeSimple() { if (SUCCEEDED(initialize(_filename))) { diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index b679cbe428..039588d6a1 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -33,6 +33,7 @@ #include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BSurface.h" #include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/persistent.h" #include "video/video_decoder.h" #include "common/stream.h" @@ -49,7 +50,7 @@ private: Video::RewindableVideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: - //DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); + DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); CVidTheoraPlayer(CBGame *inGame); virtual ~CVidTheoraPlayer(void); -- cgit v1.2.3 From 03aadc3ce16572f6bdc245f29d86ce8e4d938b2a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 16 Jun 2012 16:53:33 +0200 Subject: WINTERMUTE: Handle empty strings properly in saves. --- engines/wintermute/Base/BPersistMgr.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index d94a88b102..92307093ee 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -576,8 +576,12 @@ HRESULT CBPersistMgr::Transfer(const char *Name, Common::String *val) { delete[] str; return E_FAIL; } - *val = str; - delete[] str; + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } /* if (str) { char *ret = new char[strlen(str) + 1]; -- cgit v1.2.3 From ece5997fc3cd4e9fcab6062d6959720129a7aeab Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 18 Jun 2012 18:39:28 +0200 Subject: WINTERMUTE: Fix StringUtil::StartsWith --- engines/wintermute/utils/StringUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index a1525f21b5..21d777eb32 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -255,7 +255,7 @@ bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bo return false; AnsiString startPart(str.c_str(), patternLength); - uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + uint32 likeness = startPart.compareToIgnoreCase(pattern.c_str()); return (likeness == 0); } } -- cgit v1.2.3 From 06e8306aab6458e01b4356b6afa95544c64eae9d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 18 Jun 2012 19:11:15 +0200 Subject: WINTERMUTE: Add savegame-thumbnail-support. --- engines/wintermute/Base/BImage.cpp | 98 +++++++++++++++++++++++++++++++-- engines/wintermute/Base/BImage.h | 6 +- engines/wintermute/Base/BPersistMgr.cpp | 12 +++- engines/wintermute/Base/BRenderSDL.cpp | 3 + 4 files changed, 110 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 31c05226f5..6076b09963 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/utils/StringUtil.h" #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" @@ -52,6 +53,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { _palette = NULL; _surface = NULL; _decoder = NULL; + _deletableSurface = NULL; } @@ -59,6 +61,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { CBImage::~CBImage() { /* delete _bitmap; */ delete _decoder; + delete _deletableSurface; #if 0 if (_bitmap) FreeImage_Unload(_bitmap); #endif @@ -66,8 +69,10 @@ CBImage::~CBImage() { HRESULT CBImage::loadFile(const Common::String &filename) { _filename = filename; - - if (filename.hasSuffix(".png")) { + + if (StringUtil::StartsWith(filename, "savegame:", true)) { + _decoder = new Graphics::BitmapDecoder(); + } else if (filename.hasSuffix(".png")) { _decoder = new Graphics::PNGDecoder(); } else if (filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); @@ -98,6 +103,11 @@ byte CBImage::getAlphaAt(int x, int y) { return a; } +void CBImage::copyFrom(Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + ////////////////////////////////////////////////////////////////////////// HRESULT CBImage::SaveBMPFile(const char *Filename) { #if 0 @@ -131,8 +141,81 @@ HRESULT CBImage::Resize(int NewWidth, int NewHeight) { ////////////////////////////////////////////////////////////////////////// -byte *CBImage::CreateBMPBuffer(uint32 *BufferSize) { - if (!_bitmap) return NULL; +bool CBImage::writeBMPToStream(Common::WriteStream *stream) { + if (!_surface) return NULL; + + /* The following is just copied over and inverted to write-ops from the BMP-decoder */ + stream->writeByte('B'); + stream->writeByte('M'); + + /* Since we don't care during reads, we don't care during writes: */ + /* uint32 fileSize = */ stream->writeUint32LE(0); + /* uint16 res1 = */ stream->writeUint16LE(0); + /* uint16 res2 = */ stream->writeUint16LE(0); + const uint32 imageOffset = 54; + stream->writeUint32LE(imageOffset); + + const uint32 infoSize = 40; /* Windows v3 BMP */ + stream->writeUint32LE(infoSize); + + uint32 width = _surface->w; + int32 height = _surface->h; + stream->writeUint32LE(width); + stream->writeUint32LE(height); + + if (width == 0 || height == 0) + return false; + + if (height < 0) { + warning("Right-side up bitmaps not supported"); + return false; + } + + /* uint16 planes = */ stream->writeUint16LE(0); + const uint16 bitsPerPixel = 24; + stream->writeUint16LE(bitsPerPixel); + + const uint32 compression = 0; + stream->writeUint32LE(compression); + + /* uint32 imageSize = */ stream->writeUint32LE(0); + /* uint32 pixelsPerMeterX = */ stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ stream->writeUint32LE(0); + const uint32 paletteColorCount = 0; + stream->writeUint32LE(paletteColorCount); + /* uint32 colorsImportant = */ stream->writeUint32LE(0); + + // Start us at the beginning of the image (54 bytes in) + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + + // BGRA for 24bpp + if (bitsPerPixel == 24) + format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + + Graphics::Surface *surface = _surface->convertTo(format); + + int srcPitch = width * (bitsPerPixel >> 3); + const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + + for (int32 i = height - 1; i >= 0; i--) { + for (uint32 j = 0; j < width; j++) { + byte b,g,r; + uint32 color = *(uint32*)surface->getBasePtr(j, i); + surface->format.colorToRGB(color, r, g, b); + stream->writeByte(b); + stream->writeByte(g); + stream->writeByte(r); + } + + for (int k = 0; k < extraDataLength; k++) { + stream->writeByte(0); + } + } + surface->free(); + delete surface; + return true; + + //*BufferSize = 0; #if 0 FIMEMORY *fiMem = FreeImage_OpenMemory(); FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); @@ -164,6 +247,13 @@ HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); #endif + TransparentSurface temp(*OrigImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale(NewWidth, NewHeight); return S_OK; } diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 90d684d01a..1161c97fa5 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -35,6 +35,7 @@ #include "graphics/decoders/image_decoder.h" #include "common/endian.h" #include "common/str.h" +#include "common/stream.h" struct FIBITMAP; @@ -50,16 +51,17 @@ public: const Graphics::Surface *getSurface() const { return _surface; }; const byte *getPalette() const { return _palette; } byte getAlphaAt(int x, int y); - byte *CreateBMPBuffer(uint32 *BufferSize = NULL); + bool writeBMPToStream(Common::WriteStream *stream); HRESULT Resize(int NewWidth, int NewHeight); HRESULT SaveBMPFile(const char *Filename); HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); - + void copyFrom(Graphics::Surface *surface); private: Common::String _filename; Graphics::ImageDecoder *_decoder; FIBITMAP *_bitmap; const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; const byte *_palette; }; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 92307093ee..346a8bfa59 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -165,11 +165,17 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { if (Game->_cachedThumbnail) { if (Game->_cachedThumbnail->_thumbnail) { uint32 Size = 0; - byte *Buffer = Game->_cachedThumbnail->_thumbnail->CreateBMPBuffer(&Size); + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (Game->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } - PutDWORD(Size); +/* PutDWORD(Size); if (Size > 0) _saveStream->write(Buffer, Size); - delete [] Buffer; + delete [] Buffer;*/ ThumbnailOK = true; } } diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 86aa518de2..83adca59f3 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -399,6 +399,9 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { CBImage *CBRenderSDL::TakeScreenshot() { // TODO: Fix this warning("CBRenderSDL::TakeScreenshot() - not ported yet"); + CBImage *screenshot = new CBImage(Game); + screenshot->copyFrom(_renderSurface); + return screenshot; #if 0 SDL_Rect viewport; -- cgit v1.2.3 From 721fd394def5d9930e12f2e7223831e6c2d3bb82 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 19 Jun 2012 02:02:20 +0200 Subject: WINTERMUTE: Add a first attempt at load-from-launcher support --- engines/wintermute/Base/BPersistMgr.cpp | 213 ++++++++++++++++++++++++-------- engines/wintermute/Base/BPersistMgr.h | 15 ++- engines/wintermute/detection.cpp | 51 ++++++++ engines/wintermute/wintermute.cpp | 8 +- 4 files changed, 231 insertions(+), 56 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 346a8bfa59..a70b915fc2 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -36,8 +36,11 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BSound.h" -#include "commoN/memstream.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" #include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" namespace WinterMute { @@ -60,7 +63,7 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { _richBufferSize = 0; _savedDescription = NULL; - _savedTimestamp = 0; +// _savedTimestamp = 0; _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; _savedExtMajor = _savedExtMinor = 0; @@ -91,7 +94,7 @@ void CBPersistMgr::Cleanup() { _richBufferSize = 0; _savedDescription = NULL; // ref to buffer - _savedTimestamp = 0; +// _savedTimestamp = 0; _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; _savedExtMajor = _savedExtMinor = 0; @@ -114,6 +117,64 @@ uint32 makeUint32(byte first, byte second, byte third, byte fourth) { return retVal; } +Common::String CBPersistMgr::getFilenameForSlot(int slot) { + // TODO: Temporary solution until I have the namespacing sorted out + return Common::String::format("save%03d.DirtySplitSav", slot); +} + +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor& desc) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (FAILED(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void CBPersistMgr::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 CBPersistMgr::getMaxUsedSlot() { + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles("save???.DirtySplitSav"); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); it++) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool CBPersistMgr::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (FAILED(readHeader(filename))) { + return false; + } + return true; +} + ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::InitSave(const char *Desc) { if (!Desc) return E_FAIL; @@ -192,11 +253,11 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { PutDWORD(DataOffset); PutString(Desc); -// TODO: Add usefull timestamps, we can't use ctime... -/* time_t Timestamp; - time(&Timestamp); - PutDWORD((uint32)Timestamp);*/ - PutDWORD(0); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); } return S_OK; } @@ -224,18 +285,21 @@ uint16 getHighWord(uint32 dword) { return dword >> 16; } -////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitLoad(const char *Filename) { +HRESULT CBPersistMgr::readHeader(const Common::String &filename) { Cleanup(); - + _saving = false; - - _loadStream = Game->_fileManager->loadSaveGame(Filename); + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); //_buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); if (_loadStream) { uint32 Magic; Magic = GetDWORD(); - if (Magic != DCGF_MAGIC) goto init_fail; + + if (Magic != DCGF_MAGIC) { + Cleanup(); + return E_FAIL; + } Magic = GetDWORD(); @@ -244,14 +308,10 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { _savedVerMinor = _loadStream->readByte(); _savedExtMajor = _loadStream->readByte(); _savedExtMinor = _loadStream->readByte(); - + if (Magic == SAVE_MAGIC_2) { _savedVerBuild = (byte)GetDWORD(); - char *SavedName = GetString(); - if (SavedName == NULL || scumm_stricmp(SavedName, Game->_name) != 0) { - Game->LOG(0, "ERROR: Saved game name doesn't match current game"); - goto init_fail; - } + _savedName = GetString(); // load thumbnail _thumbnailDataSize = GetDWORD(); @@ -263,48 +323,68 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { } } else _savedVerBuild = 35; // last build with ver1 savegames + uint32 DataOffset = GetDWORD(); - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - Game->LOG(0, "ERROR: Saved game version is newer than current game"); - goto init_fail; - } + _savedDescription = GetString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - goto init_fail; - } + _offset = DataOffset; + + return S_OK; + } + } - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - Game->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - } else goto init_fail; + Cleanup(); + return E_FAIL; +} +////////////////////////////////////////////////////////////////////////// +HRESULT CBPersistMgr::InitLoad(const char *Filename) { - uint32 DataOffset = GetDWORD(); - _savedDescription = GetString(); - _savedTimestamp = (time_t)GetDWORD(); + if (FAILED(readHeader(Filename))) { + Cleanup(); + return E_FAIL; + } + _saving = false; - _offset = DataOffset; + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), Game->_name) != 0) { + Game->LOG(0, "ERROR: Saved game name doesn't match current game"); + Cleanup(); + return E_FAIL; + } - return S_OK; + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game version is newer than current game"); + Cleanup(); + return E_FAIL; } -init_fail: - Cleanup(); - return E_FAIL; + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + Cleanup(); + return E_FAIL; + + } + + /* + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + Game->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + + return S_OK; } @@ -387,13 +467,40 @@ char *CBPersistMgr::GetString() { ret[len] = '\0'; /* char *ret = (char *)(_buffer + _offset); _offset += len;*/ - + warning("Read string %s with len %d", ret, len); if (!strcmp(ret, "(null)")) { delete[] ret; return NULL; } else return ret; } +HRESULT CBPersistMgr::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return E_FAIL; + } + return S_OK; +} + +TimeDate CBPersistMgr::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + void CBPersistMgr::putFloat(float val) { Common::String str = Common::String::format("F%f", val); _saveStream->writeUint32LE(str.size()); diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 0fe1d75550..12760bf6ca 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -31,7 +31,10 @@ #include "engines/wintermute/Base/BBase.h" +#include "engines/savestate.h" #include "common/stream.h" +#include "common/str.h" +#include "common/system.h" namespace WinterMute { @@ -40,12 +43,14 @@ class Vector2; class CBPersistMgr : public CBBase { public: char *_savedDescription; - time_t _savedTimestamp; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; byte _savedVerMajor; byte _savedVerMinor; byte _savedVerBuild; byte _savedExtMajor; byte _savedExtMinor; + Common::String _savedName; HRESULT SaveFile(const char *Filename); uint32 GetDWORD(); void PutDWORD(uint32 Val); @@ -56,6 +61,10 @@ public: double getDouble(); void putDouble(double val); void Cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor& desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); HRESULT InitLoad(const char *Filename); HRESULT InitSave(const char *Desc); HRESULT GetBytes(byte *Buffer, uint32 Size); @@ -89,6 +98,10 @@ public: uint32 _thumbnailDataSize; byte *_thumbnailData; private: + Common::String getFilenameForSlot(int slot); + HRESULT readHeader(const Common::String &filename); + TimeDate getTimeDate(); + HRESULT putTimeDate(const TimeDate &t); Common::WriteStream *_saveStream; Common::SeekableReadStream *_loadStream; }; diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 4756c96542..610f34c643 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -22,6 +22,7 @@ #include "engines/advancedDetector.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/Base/BPersistMgr.h" #include "common/config-manager.h" #include "common/error.h" @@ -179,6 +180,56 @@ public: // Failed to find any game data return false; } + + bool hasFeature(MetaEngineFeature f) const { + switch (f) { + case MetaEngine::kSupportsListSaves: + return true; + case MetaEngine::kSupportsLoadingDuringStartup: + return true; + case MetaEngine::kSupportsDeleteSave: + return true; + case MetaEngine::kSavesSupportCreationDate: + return true; + case MetaEngine::kSavesSupportMetaInfo: + return true; + case MetaEngine::kSavesSupportThumbnail: + return true; + default: + return false; + } + } + + SaveStateList listSaves(const char *target) const { + SaveStateList saves; + WinterMute::CBPersistMgr pm; + for (int i = 0; i < getMaximumSaveSlot(); i++) { + if (pm.getSaveExists(i)) { + SaveStateDescriptor desc; + pm.getSaveStateDesc(i, desc); + saves.push_back(desc); + } + } + return saves; + } + + int getMaximumSaveSlot() const { + WinterMute::CBPersistMgr pm; + return pm.getMaxUsedSlot() + 1; // TODO: Since we use slot 0, this misses a bit. + } + + void removeSaveState(const char *target, int slot) const { + WinterMute::CBPersistMgr pm; + pm.deleteSaveSlot(slot); + } + + virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { + WinterMute::CBPersistMgr pm; + SaveStateDescriptor retVal; + retVal.setDescription("Invalid savegame"); + pm.getSaveStateDesc(slot, retVal); + return retVal; + } }; #if PLUGIN_ENABLED_DYNAMIC(WINTERMUTE) diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 8b12a422cf..4e24d740b9 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -130,6 +130,7 @@ int WinterMuteEngine::init() { int argc = 0; _game = new CAdGame; if (!_game) return 1; + CBPlatform::Initialize(_game, 0, NULL); bool windowedMode = true; @@ -234,14 +235,17 @@ int WinterMuteEngine::init() { _game->LOG(0, "Engine initialized in %d ms", CBPlatform::GetTime() - DataInitStart); _game->LOG(0, ""); + if (ConfMan.hasKey("save_slot")) { + int slot = ConfMan.getInt("save_slot"); + Common::String str = Common::String::format("save00%d.DirtySplitSav", slot); + _game->LoadGame(str.c_str()); + } if (SaveGame) { _game->LoadGame(SaveGame); delete [] SaveGame; } - CBPlatform::Initialize(_game, 0, NULL); - // all set, ready to go return 0; } -- cgit v1.2.3 From c59507a6e9f422d9e1147c64344c2963f6373a41 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 19 Jun 2012 02:30:40 +0200 Subject: WINTERMUTE: Add RTL-support. --- engines/wintermute/PlatformSDL.cpp | 1 + engines/wintermute/wintermute.cpp | 10 ++++++++++ engines/wintermute/wintermute.h | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index a0ba4f4a05..fde05eafe3 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -131,6 +131,7 @@ void CBPlatform::HandleEvent(Common::Event *event) { break; */ case Common::EVENT_QUIT: + case Common::EVENT_RTL: #ifdef __IPHONEOS__ if (Game) { Game->AutoSaveOnExit(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 4e24d740b9..44faec5c3a 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -78,6 +78,16 @@ WinterMuteEngine::~WinterMuteEngine() { DebugMan.clearAllDebugChannels(); } +bool WinterMuteEngine::hasFeature(EngineFeature f) const { + switch (f) { + case kSupportsRTL: + return true; + default: + return false; + } + return false; +} + Common::Error WinterMuteEngine::run() { // Initialize graphics using following: Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 5c5aa1bf18..92dbedc6b5 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -45,7 +45,7 @@ public: ~WinterMuteEngine(); virtual Common::Error run(); - + virtual bool hasFeature(EngineFeature f) const; Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } uint32 randInt(int from, int to); private: -- cgit v1.2.3 From e3a7921dff85fe70c11b9428afa21b12d9894486 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 19 Jun 2012 03:11:57 +0200 Subject: WINTERMUTE: Make sure the TGA-decoder returns false on error --- engines/wintermute/graphics/tga.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp index 6ea6974ce7..45d67756a0 100644 --- a/engines/wintermute/graphics/tga.cpp +++ b/engines/wintermute/graphics/tga.cpp @@ -50,7 +50,7 @@ bool TGA::loadStream(Common::SeekableReadStream &tga) { success = readHeader(tga, imageType, pixelDepth); success = readData (tga, imageType, pixelDepth); - if (tga.err()) { + if (tga.err() || !success) { warning("Failed reading TGA-file"); return false; } -- cgit v1.2.3 From 8c463aa58c6b61c4336a0ff45a02578fad804c05 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 21 Jun 2012 18:49:10 +0200 Subject: WINTERMUTE: Fix loading of fonts from savegames. --- engines/wintermute/Base/BFontTT.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index dff2c252e4..91ef15cebf 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -626,6 +626,7 @@ HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { if (!PersistMgr->_saving) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; _glyphCache = NULL; + _fallbackFont = _font = _deletableFont = NULL; } return S_OK; -- cgit v1.2.3 From 7d702c95954e94d0ae29c6f973765ccda03d4d51 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 21 Jun 2012 18:49:30 +0200 Subject: WINTERMUTE: Use the fullscreen-setting from the launcher. --- engines/wintermute/wintermute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 44faec5c3a..d2edf6d1f3 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -142,7 +142,7 @@ int WinterMuteEngine::init() { if (!_game) return 1; CBPlatform::Initialize(_game, 0, NULL); - bool windowedMode = true; + bool windowedMode = !ConfMan.getBool("fullscreen"); // parse command line char *SaveGame = NULL; -- cgit v1.2.3 From 93f7bcdf287765107a6d4f5d57fc79ca0c3b8cbb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 10:12:11 +0200 Subject: WINTERMUTE: Fix a mistake in saving CVidTheora-objects (and strengthen the saving by putting in some more headers) --- engines/wintermute/Base/BKeyboardState.cpp | 7 +++ engines/wintermute/Sys/SysClass.cpp | 88 +++++++++++++--------------- engines/wintermute/Sys/SysClass.h | 22 +++++-- engines/wintermute/Sys/SysClassRegistry.cpp | 25 ++++++-- engines/wintermute/video/VidTheoraPlayer.cpp | 6 +- 5 files changed, 89 insertions(+), 59 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 32a5d529eb..c91438dba9 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -225,6 +225,13 @@ HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_currentKeyData)); PersistMgr->Transfer(TMEMBER(_currentPrintable)); PersistMgr->Transfer(TMEMBER(_currentShift)); + + if (!PersistMgr->_saving) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } return S_OK; } diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index 30ccf3aa08..dede71b756 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -35,8 +35,6 @@ namespace WinterMute { -// TODO: Note that the set was removed, this might have bizarre side-effects. - ////////////////////////////////////////////////////////////////////////// CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { _name = name; @@ -60,11 +58,11 @@ CSysClass::~CSysClass() { ////////////////////////////////////////////////////////////////////////// bool CSysClass::RemoveAllInstances() { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { delete(it->_value); } - //_instances.clear(); + _instances.clear(); _instanceMap.clear(); return true; @@ -74,7 +72,7 @@ bool CSysClass::RemoveAllInstances() { CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { CSysInstance *inst = new CSysInstance(instance, id, this); inst->SetSavedID(savedId); - //_instances.insert(inst); + _instances[inst] = (inst); _instanceMap[instance] = inst; @@ -88,14 +86,13 @@ CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { bool CSysClass::RemoveInstance(void *instance) { InstanceMap::iterator mapIt = _instanceMap.find(instance); if (mapIt == _instanceMap.end()) return false; - /* - Instances::iterator it = _instances.find((*mapIt).second); - if (it != _instances.end()) { - delete(*it); - _instances.erase(it); - }*/ - - delete mapIt->_value; + + Instances::iterator it = _instances.find((mapIt->_value)); + if (it != _instances.end()) { + delete(it->_value); + _instances.erase(it); + } + _instanceMap.erase(mapIt); return false; @@ -105,18 +102,14 @@ bool CSysClass::RemoveInstance(void *instance) { int CSysClass::GetInstanceID(void *pointer) { InstanceMap::iterator mapIt = _instanceMap.find(pointer); if (mapIt == _instanceMap.end()) return -1; - else return (*mapIt)._value->GetID(); + else return (mapIt->_value)->GetID(); } ////////////////////////////////////////////////////////////////////////// void *CSysClass::IDToPointer(int savedID) { //slow - /*Instances::iterator it; + Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((*it)->GetSavedID() == savedID) return (*it)->GetInstance(); - }*/ - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); } return NULL; @@ -124,58 +117,59 @@ void *CSysClass::IDToPointer(int savedID) { ////////////////////////////////////////////////////////////////////////// int CSysClass::GetNumInstances() { - //return _instances.size(); - return _instanceMap.size(); // TODO: This might break, if we have multiple keys per value. + return _instances.size(); } ////////////////////////////////////////////////////////////////////////// void CSysClass::Dump(Common::WriteStream *stream) { - Common::String str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); - stream->writeString(str); + //fprintf(stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); + Common::String str; + str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); + stream->write(str.c_str(), str.size()); } ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { + warning("Saving %d:%s with %d instancces", _iD, _name.c_str(), _instances.size()); PersistMgr->PutString(_name.c_str()); PersistMgr->PutDWORD(_iD); - PersistMgr->PutDWORD(_instanceMap.size()); + PersistMgr->PutDWORD(_instances.size()); - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { - PersistMgr->PutDWORD((it->_value)->GetID()); - } - /* Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - PersistMgr->PutDWORD((*it)->GetID()); - }*/ + PersistMgr->PutDWORD((it->_value)->GetID()); + } } ////////////////////////////////////////////////////////////////////////// void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { _savedID = PersistMgr->GetDWORD(); int numInstances = PersistMgr->GetDWORD(); - + warning("Loading table for %d:%s with %d instances", _savedID, _name.c_str(), numInstances); for (int i = 0; i < numInstances; i++) { + int instID = PersistMgr->GetDWORD(); + warning("Loaded instanceID: %d", instID); if (_persistent) { - int instId = PersistMgr->GetDWORD(); if (i > 0) { Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); continue; } - InstanceMap::iterator it = _instanceMap.begin(); - /* Instances::iterator it = _instances.begin();*/ - if (it != _instanceMap.end()) { - (it->_value)->SetSavedID(instId); + Instances::iterator it = _instances.begin(); + if (it != _instances.end()) { + (it->_value)->SetSavedID(instID); CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); } // normal instances, create empty objects else { void *emptyObject = _build(); - AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); + if (!emptyObject) { + warning("HALT"); + } + + AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), instID); } } @@ -183,13 +177,15 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { // write instace header + PersistMgr->PutString(""); PersistMgr->PutDWORD(_iD); PersistMgr->PutDWORD((it->_value)->GetID()); - + PersistMgr->PutString(""); _load((it->_value)->GetInstance(), PersistMgr); + PersistMgr->PutString(""); } } @@ -201,16 +197,16 @@ void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { ////////////////////////////////////////////////////////////////////////// void CSysClass::ResetSavedIDs() { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { (it->_value)->SetSavedID(-1); } } ////////////////////////////////////////////////////////////////////////// void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { - InstanceMap::iterator it; - for (it = _instanceMap.begin(); it != _instanceMap.end(); ++it) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { lpCallback((it->_value)->GetInstance(), lpData); } } diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h index c81e38ee43..a2575c262c 100644 --- a/engines/wintermute/Sys/SysClass.h +++ b/engines/wintermute/Sys/SysClass.h @@ -35,6 +35,14 @@ #include "common/func.h" #include "common/stream.h" +namespace WinterMute { +class CSysInstance; +class CBGame; +class CBPersistMgr; +class CSysClass; + +} + namespace Common { template struct Hash; @@ -44,12 +52,17 @@ template<> struct Hash : public UnaryFunction { } }; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysInstance* val) const { + return (uint)((size_t)val); + } +}; + + } namespace WinterMute { -class CSysInstance; -class CBGame; -class CBPersistMgr; + class CSysClass { public: CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); @@ -105,7 +118,8 @@ private: PERSISTLOAD _load; //typedef std::set Instances; - //Instances _instances; + typedef Common::HashMap Instances; + Instances _instances; typedef Common::HashMap InstanceMap; InstanceMap _instanceMap; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 1a644c3a61..a7d401c5bb 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -148,9 +148,20 @@ void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { else return (*it)._value->GetInstance(); } +bool checkHeader(const char* tag, CBPersistMgr *pm) { + char *test = pm->GetString(); + Common::String verify = test; + delete[] test; + bool retVal = (verify == tag); + if (!retVal) { + error("Expected %s in Save-file not found", tag); + } + return retVal; +} ////////////////////////////////////////////////////////////////////////// HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { + PersistMgr->PutString(""); PersistMgr->PutDWORD(_classes.size()); int counter = 0; @@ -167,16 +178,17 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, boo (it->_value)->SaveTable(Game, PersistMgr); } - + PersistMgr->PutString(""); return S_OK; } ////////////////////////////////////////////////////////////////////////// HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - Classes::iterator it; + checkHeader("", PersistMgr); // reset SavedID of current instances + Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) { (it->_value)->ResetSavedIDs(); } @@ -188,7 +200,6 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { _instanceMap.clear(); - int numClasses = PersistMgr->GetDWORD(); for (int i = 0; i < numClasses; i++) { @@ -201,6 +212,8 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); } + checkHeader("", PersistMgr); + return S_OK; } @@ -237,7 +250,6 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, return S_OK; } - ////////////////////////////////////////////////////////////////////////// HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) { // get total instances @@ -250,17 +262,22 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) Game->_renderer->Flip(); } + checkHeader("", PersistMgr); + int classID = PersistMgr->GetDWORD(); int instanceID = PersistMgr->GetDWORD(); void *instance = IDToPointer(classID, instanceID); + checkHeader("", PersistMgr); Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) { if ((it->_value)->GetSavedID() == classID) { (it->_value)->LoadInstance(instance, PersistMgr); + break; } } + checkHeader("", PersistMgr); } _savedInstanceMap.clear(); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d64a6f2bb1..d0553a4ffd 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -816,12 +816,8 @@ HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_playZoom)); PersistMgr->Transfer(TMEMBER_INT(_playbackType)); PersistMgr->Transfer(TMEMBER(_looping)); + PersistMgr->Transfer(TMEMBER(_volume)); - if (PersistMgr->CheckVersion(1, 7, 3)) { - PersistMgr->Transfer(TMEMBER(_volume)); - } else { - _volume = 100; - } return S_OK; } -- cgit v1.2.3 From 9ce1685bf51a1f4f02e3a9760fc84c53ebc328c9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 10:34:50 +0200 Subject: WINTERMUTE: Remove AdActorDir and fix build --- engines/wintermute/Ad/AdActorDir.cpp | 52 ---------------------------- engines/wintermute/Ad/AdActorDir.h | 46 ------------------------ engines/wintermute/module.mk | 1 - engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.h | 2 +- 6 files changed, 3 insertions(+), 102 deletions(-) delete mode 100644 engines/wintermute/Ad/AdActorDir.cpp delete mode 100644 engines/wintermute/Ad/AdActorDir.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActorDir.cpp b/engines/wintermute/Ad/AdActorDir.cpp deleted file mode 100644 index d44cb3dc6d..0000000000 --- a/engines/wintermute/Ad/AdActorDir.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/Ad/AdActorDir.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdActorDir, false) - - -////////////////////////////////////////////////////////////////////////// -CAdActorDir::CAdActorDir(CBGame *inGame): CBBase(inGame) { -} - - -////////////////////////////////////////////////////////////////////////// -CAdActorDir::~CAdActorDir(void) { -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CAdActorDir::Persist(CBPersistMgr *PersistMgr) { - //PersistMgr->Transfer(TMEMBER(x)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdActorDir.h b/engines/wintermute/Ad/AdActorDir.h deleted file mode 100644 index f3579ed72c..0000000000 --- a/engines/wintermute/Ad/AdActorDir.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADACTORDIR_H -#define WINTERMUTE_ADACTORDIR_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CAdActorDir : public CBBase { -public: - DECLARE_PERSISTENT(CAdActorDir, CBBase) - CAdActorDir(CBGame *inGame); - virtual ~CAdActorDir(void); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADACTORDIR_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index ed94ebf2fc..64c334d0eb 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -2,7 +2,6 @@ MODULE := engines/wintermute MODULE_OBJS := \ Ad/AdActor.o \ - Ad/AdActorDir.o \ Ad/AdEntity.o \ Ad/AdGame.o \ Ad/AdInventory.o \ diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 4e4678ffae..29c992f1ac 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/Base/BGame.h" #include "common/str.h" #include "common/textconsole.h" -#include "wintermute.h" +#include "engines/wintermute/wintermute.h" namespace WinterMute { diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d0553a4ffd..aeba5608b3 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -42,7 +42,7 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false); +IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false) ////////////////////////////////////////////////////////////////////////// CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 039588d6a1..2c103095a1 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -50,7 +50,7 @@ private: Video::RewindableVideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: - DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase); + DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase) CVidTheoraPlayer(CBGame *inGame); virtual ~CVidTheoraPlayer(void); -- cgit v1.2.3 From 590cf7b5b133d5afd36daec7fd15c3d9f64df538 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 11:04:55 +0200 Subject: WINTERMUTE: Reinitialize Theora-videos after load. --- engines/wintermute/video/VidTheoraPlayer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index aeba5608b3..8398578c2b 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -130,7 +130,8 @@ void CVidTheoraPlayer::cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { cleanup(); - + + _filename = filename; _file = Game->_fileManager->OpenFile(filename, true, false); if (!_file) return E_FAIL; @@ -818,6 +819,10 @@ HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { PersistMgr->Transfer(TMEMBER(_looping)); PersistMgr->Transfer(TMEMBER(_volume)); + if (!PersistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { + initializeSimple(); + } + return S_OK; } -- cgit v1.2.3 From 9b26ea4f7f363c187a2f4be21133d9c77fb46bd6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 11:18:57 +0200 Subject: WINTERMUTE: Clean out a few debug-prints. --- engines/wintermute/Base/BPersistMgr.cpp | 1 - engines/wintermute/Base/BSurfaceSDL.cpp | 1 - engines/wintermute/Sys/SysClass.cpp | 5 +---- 3 files changed, 1 insertion(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index a70b915fc2..938498dae8 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -467,7 +467,6 @@ char *CBPersistMgr::GetString() { ret[len] = '\0'; /* char *ret = (char *)(_buffer + _offset); _offset += len;*/ - warning("Read string %s with len %d", ret, len); if (!strcmp(ret, "(null)")) { delete[] ret; return NULL; diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 9e77b9c1b7..e118bac384 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -100,7 +100,6 @@ bool hasTransparency(Graphics::Surface *surf) { HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(filename); - warning("CBSurfaceSDL::create(%s, %d, %d, %d, %d, %d, %d", filename, default_ck, ck_red, ck_green, ck_blue, lifeTime, keepLoaded); CBImage *image = new CBImage(Game); image->loadFile(strFileName); // const Graphics::Surface *surface = image->getSurface(); diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index dede71b756..730753cf18 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -122,7 +122,6 @@ int CSysClass::GetNumInstances() { ////////////////////////////////////////////////////////////////////////// void CSysClass::Dump(Common::WriteStream *stream) { - //fprintf(stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); Common::String str; str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); stream->write(str.c_str(), str.size()); @@ -130,7 +129,6 @@ void CSysClass::Dump(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { - warning("Saving %d:%s with %d instancces", _iD, _name.c_str(), _instances.size()); PersistMgr->PutString(_name.c_str()); PersistMgr->PutDWORD(_iD); PersistMgr->PutDWORD(_instances.size()); @@ -145,10 +143,9 @@ void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { _savedID = PersistMgr->GetDWORD(); int numInstances = PersistMgr->GetDWORD(); - warning("Loading table for %d:%s with %d instances", _savedID, _name.c_str(), numInstances); + for (int i = 0; i < numInstances; i++) { int instID = PersistMgr->GetDWORD(); - warning("Loaded instanceID: %d", instID); if (_persistent) { if (i > 0) { -- cgit v1.2.3 From 5a5fd609f13ef8754fb256d7ed3d774f51100ebb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 13:56:51 +0200 Subject: WINTERMUTE: Rename the functions and arguments in BPersistMgr --- engines/wintermute/Ad/AdActor.cpp | 56 +-- engines/wintermute/Ad/AdEntity.cpp | 24 +- engines/wintermute/Ad/AdGame.cpp | 64 ++-- engines/wintermute/Ad/AdInventory.cpp | 8 +- engines/wintermute/Ad/AdInventoryBox.cpp | 28 +- engines/wintermute/Ad/AdItem.cpp | 30 +- engines/wintermute/Ad/AdLayer.cpp | 16 +- engines/wintermute/Ad/AdNodeState.cpp | 18 +- engines/wintermute/Ad/AdObject.cpp | 78 ++--- engines/wintermute/Ad/AdPath.cpp | 10 +- engines/wintermute/Ad/AdPathPoint.cpp | 10 +- engines/wintermute/Ad/AdRegion.cpp | 12 +- engines/wintermute/Ad/AdResponse.cpp | 24 +- engines/wintermute/Ad/AdResponseBox.cpp | 38 +- engines/wintermute/Ad/AdResponseContext.cpp | 8 +- engines/wintermute/Ad/AdRotLevel.cpp | 6 +- engines/wintermute/Ad/AdScaleLevel.cpp | 6 +- engines/wintermute/Ad/AdScene.cpp | 110 +++--- engines/wintermute/Ad/AdSceneNode.cpp | 10 +- engines/wintermute/Ad/AdSceneState.cpp | 6 +- engines/wintermute/Ad/AdSentence.cpp | 42 +-- engines/wintermute/Ad/AdSpriteSet.cpp | 8 +- engines/wintermute/Ad/AdTalkDef.cpp | 14 +- engines/wintermute/Ad/AdTalkHolder.cpp | 10 +- engines/wintermute/Ad/AdTalkNode.cpp | 18 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 16 +- engines/wintermute/Base/BEvent.cpp | 10 +- engines/wintermute/Base/BFader.cpp | 30 +- engines/wintermute/Base/BFont.cpp | 4 +- engines/wintermute/Base/BFontBitmap.cpp | 26 +- engines/wintermute/Base/BFontStorage.cpp | 10 +- engines/wintermute/Base/BFontTT.cpp | 28 +- engines/wintermute/Base/BFontTT.h | 8 +- engines/wintermute/Base/BFrame.cpp | 24 +- engines/wintermute/Base/BGame.cpp | 148 ++++---- engines/wintermute/Base/BKeyboardState.cpp | 22 +- engines/wintermute/Base/BObject.cpp | 98 +++--- engines/wintermute/Base/BPersistMgr.cpp | 382 ++++++++------------- engines/wintermute/Base/BPersistMgr.h | 55 ++- engines/wintermute/Base/BPoint.cpp | 6 +- engines/wintermute/Base/BRegion.cpp | 16 +- engines/wintermute/Base/BScriptHolder.cpp | 12 +- engines/wintermute/Base/BScriptable.cpp | 10 +- engines/wintermute/Base/BSound.cpp | 30 +- engines/wintermute/Base/BSprite.cpp | 52 +-- engines/wintermute/Base/BSubFrame.cpp | 48 +-- engines/wintermute/Base/BSurfaceStorage.cpp | 8 +- engines/wintermute/Base/BViewport.cpp | 12 +- engines/wintermute/Base/PartEmitter.cpp | 106 +++--- engines/wintermute/Base/PartForce.cpp | 10 +- engines/wintermute/Base/PartParticle.cpp | 48 +-- engines/wintermute/Base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 8 +- engines/wintermute/Base/scriptables/SXDate.cpp | 18 +- engines/wintermute/Base/scriptables/SXFile.cpp | 16 +- engines/wintermute/Base/scriptables/SXMath.cpp | 4 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 12 +- engines/wintermute/Base/scriptables/SXStore.cpp | 26 +- engines/wintermute/Base/scriptables/SXStore.h | 10 +- engines/wintermute/Base/scriptables/SXString.cpp | 12 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 16 +- engines/wintermute/Base/scriptables/ScScript.cpp | 74 ++-- engines/wintermute/Base/scriptables/ScStack.cpp | 8 +- engines/wintermute/Base/scriptables/ScValue.cpp | 36 +- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- engines/wintermute/Sys/SysClass.cpp | 36 +- engines/wintermute/Sys/SysClass.h | 4 +- engines/wintermute/Sys/SysClassRegistry.cpp | 48 +-- engines/wintermute/UI/UIButton.cpp | 50 +-- engines/wintermute/UI/UIEdit.cpp | 22 +- engines/wintermute/UI/UIEntity.cpp | 6 +- engines/wintermute/UI/UIObject.cpp | 44 +-- engines/wintermute/UI/UIText.cpp | 8 +- engines/wintermute/UI/UITiledImage.cpp | 26 +- engines/wintermute/UI/UIWindow.cpp | 50 +-- engines/wintermute/coll_templ.h | 14 +- engines/wintermute/video/VidTheoraPlayer.cpp | 32 +- 77 files changed, 1173 insertions(+), 1286 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 3124585bc5..3d4e77565a 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -1187,34 +1187,34 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Persist(CBPersistMgr *PersistMgr) { - CAdTalkHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER_INT(_dir)); - PersistMgr->Transfer(TMEMBER(_path)); - PersistMgr->Transfer(TMEMBER(_pFCount)); - PersistMgr->Transfer(TMEMBER(_pFStepX)); - PersistMgr->Transfer(TMEMBER(_pFStepY)); - PersistMgr->Transfer(TMEMBER(_pFX)); - PersistMgr->Transfer(TMEMBER(_pFY)); - PersistMgr->Transfer(TMEMBER(_standSprite)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(_targetDir)); - PersistMgr->Transfer(TMEMBER_INT(_afterWalkDir)); - PersistMgr->Transfer(TMEMBER(_targetPoint)); - PersistMgr->Transfer(TMEMBER(_turnLeftSprite)); - PersistMgr->Transfer(TMEMBER(_turnRightSprite)); - PersistMgr->Transfer(TMEMBER(_walkSprite)); - - PersistMgr->Transfer(TMEMBER(_animSprite2)); - PersistMgr->Transfer(TMEMBER(_talkAnimName)); - PersistMgr->Transfer(TMEMBER(_idleAnimName)); - PersistMgr->Transfer(TMEMBER(_walkAnimName)); - PersistMgr->Transfer(TMEMBER(_turnLeftAnimName)); - PersistMgr->Transfer(TMEMBER(_turnRightAnimName)); - - _anims.Persist(PersistMgr); +HRESULT CAdActor::Persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::Persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_dir)); + persistMgr->transfer(TMEMBER(_path)); + persistMgr->transfer(TMEMBER(_pFCount)); + persistMgr->transfer(TMEMBER(_pFStepX)); + persistMgr->transfer(TMEMBER(_pFStepY)); + persistMgr->transfer(TMEMBER(_pFX)); + persistMgr->transfer(TMEMBER(_pFY)); + persistMgr->transfer(TMEMBER(_standSprite)); + _talkSprites.Persist(persistMgr); + _talkSpritesEx.Persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_targetDir)); + persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); + persistMgr->transfer(TMEMBER(_targetPoint)); + persistMgr->transfer(TMEMBER(_turnLeftSprite)); + persistMgr->transfer(TMEMBER(_turnRightSprite)); + persistMgr->transfer(TMEMBER(_walkSprite)); + + persistMgr->transfer(TMEMBER(_animSprite2)); + persistMgr->transfer(TMEMBER(_talkAnimName)); + persistMgr->transfer(TMEMBER(_idleAnimName)); + persistMgr->transfer(TMEMBER(_walkAnimName)); + persistMgr->transfer(TMEMBER(_turnLeftAnimName)); + persistMgr->transfer(TMEMBER(_turnRightAnimName)); + + _anims.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 71f466fde1..f54f26d466 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -977,21 +977,21 @@ void CAdEntity::UpdatePosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Persist(CBPersistMgr *PersistMgr) { - CAdTalkHolder::Persist(PersistMgr); +HRESULT CAdEntity::Persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_item)); - PersistMgr->Transfer(TMEMBER(_region)); - //PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER_INT(_subtype)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_item)); + persistMgr->transfer(TMEMBER(_region)); + //persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER_INT(_subtype)); + _talkSprites.Persist(persistMgr); + _talkSpritesEx.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_walkToX)); - PersistMgr->Transfer(TMEMBER(_walkToY)); - PersistMgr->Transfer(TMEMBER_INT(_walkToDir)); + persistMgr->transfer(TMEMBER(_walkToX)); + persistMgr->transfer(TMEMBER(_walkToY)); + persistMgr->transfer(TMEMBER_INT(_walkToDir)); - PersistMgr->Transfer(TMEMBER(_theora)); + persistMgr->transfer(TMEMBER(_theora)); return S_OK; } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 22400accfa..938ad66b12 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1263,50 +1263,50 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - CBGame::Persist(PersistMgr); +HRESULT CAdGame::Persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) Cleanup(); + CBGame::Persist(persistMgr); - _dlgPendingBranches.Persist(PersistMgr); + _dlgPendingBranches.Persist(persistMgr); - _inventories.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_inventoryBox)); + _inventories.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_inventoryBox)); - _objects.Persist(PersistMgr); + _objects.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_prevSceneName)); - PersistMgr->Transfer(TMEMBER(_prevSceneFilename)); + persistMgr->transfer(TMEMBER(_prevSceneName)); + persistMgr->transfer(TMEMBER(_prevSceneFilename)); - PersistMgr->Transfer(TMEMBER(_responseBox)); - _responsesBranch.Persist(PersistMgr); - _responsesGame.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scene)); - _sceneStates.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scheduledFadeIn)); - PersistMgr->Transfer(TMEMBER(_scheduledScene)); - PersistMgr->Transfer(TMEMBER(_selectedItem)); - PersistMgr->Transfer(TMEMBER_INT(_talkSkipButton)); + persistMgr->transfer(TMEMBER(_responseBox)); + _responsesBranch.Persist(persistMgr); + _responsesGame.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_scene)); + _sceneStates.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_scheduledFadeIn)); + persistMgr->transfer(TMEMBER(_scheduledScene)); + persistMgr->transfer(TMEMBER(_selectedItem)); + persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); - _sentences.Persist(PersistMgr); + _sentences.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_sceneViewport)); - PersistMgr->Transfer(TMEMBER_INT(_stateEx)); - PersistMgr->Transfer(TMEMBER(_initialScene)); - PersistMgr->Transfer(TMEMBER(_debugStartupScene)); + persistMgr->transfer(TMEMBER(_sceneViewport)); + persistMgr->transfer(TMEMBER_INT(_stateEx)); + persistMgr->transfer(TMEMBER(_initialScene)); + persistMgr->transfer(TMEMBER(_debugStartupScene)); - PersistMgr->Transfer(TMEMBER(_invObject)); - PersistMgr->Transfer(TMEMBER(_inventoryOwner)); - PersistMgr->Transfer(TMEMBER(_tempDisableSaveState)); - _items.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_invObject)); + persistMgr->transfer(TMEMBER(_inventoryOwner)); + persistMgr->transfer(TMEMBER(_tempDisableSaveState)); + _items.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_itemsFile)); + persistMgr->transfer(TMEMBER(_itemsFile)); - _speechDirs.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_smartItemCursor)); + _speechDirs.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_smartItemCursor)); - if (!PersistMgr->_saving) _initialScene = false; + if (!persistMgr->_saving) _initialScene = false; - PersistMgr->Transfer(TMEMBER(_startupScene)); + persistMgr->transfer(TMEMBER(_startupScene)); return S_OK; diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 693f09bcf6..c81e1f4be7 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -106,12 +106,12 @@ HRESULT CAdInventory::RemoveItem(CAdItem *Item) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdInventory::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - _takenItems.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); + _takenItems.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); return S_OK; } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 8d4720c984..debe74db01 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -350,20 +350,20 @@ HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_closeButton)); - PersistMgr->Transfer(TMEMBER(_hideSelected)); - PersistMgr->Transfer(TMEMBER(_itemHeight)); - PersistMgr->Transfer(TMEMBER(_itemsArea)); - PersistMgr->Transfer(TMEMBER(_itemWidth)); - PersistMgr->Transfer(TMEMBER(_scrollBy)); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_spacing)); - PersistMgr->Transfer(TMEMBER(_visible)); - PersistMgr->Transfer(TMEMBER(_window)); - PersistMgr->Transfer(TMEMBER(_exclusive)); +HRESULT CAdInventoryBox::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_closeButton)); + persistMgr->transfer(TMEMBER(_hideSelected)); + persistMgr->transfer(TMEMBER(_itemHeight)); + persistMgr->transfer(TMEMBER(_itemsArea)); + persistMgr->transfer(TMEMBER(_itemWidth)); + persistMgr->transfer(TMEMBER(_scrollBy)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_window)); + persistMgr->transfer(TMEMBER(_exclusive)); return S_OK; } diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 09a9ef08f4..fd792b3f5b 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -728,21 +728,21 @@ const char *CAdItem::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Persist(CBPersistMgr *PersistMgr) { - - CAdTalkHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_cursorCombined)); - PersistMgr->Transfer(TMEMBER(_cursorHover)); - PersistMgr->Transfer(TMEMBER(_cursorNormal)); - PersistMgr->Transfer(TMEMBER(_spriteHover)); - PersistMgr->Transfer(TMEMBER(_inInventory)); - PersistMgr->Transfer(TMEMBER(_displayAmount)); - PersistMgr->Transfer(TMEMBER(_amount)); - PersistMgr->Transfer(TMEMBER(_amountOffsetX)); - PersistMgr->Transfer(TMEMBER(_amountOffsetY)); - PersistMgr->Transfer(TMEMBER_INT(_amountAlign)); - PersistMgr->Transfer(TMEMBER(_amountString)); +HRESULT CAdItem::Persist(CBPersistMgr *persistMgr) { + + CAdTalkHolder::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_cursorCombined)); + persistMgr->transfer(TMEMBER(_cursorHover)); + persistMgr->transfer(TMEMBER(_cursorNormal)); + persistMgr->transfer(TMEMBER(_spriteHover)); + persistMgr->transfer(TMEMBER(_inInventory)); + persistMgr->transfer(TMEMBER(_displayAmount)); + persistMgr->transfer(TMEMBER(_amount)); + persistMgr->transfer(TMEMBER(_amountOffsetX)); + persistMgr->transfer(TMEMBER(_amountOffsetY)); + persistMgr->transfer(TMEMBER_INT(_amountAlign)); + persistMgr->transfer(TMEMBER(_amountString)); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 8198bf492b..ae8baabcd6 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -521,16 +521,16 @@ HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdLayer::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_closeUp)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_main)); - _nodes.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_closeUp)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_main)); + _nodes.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_width)); return S_OK; } diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 00703c3b1a..7089e63a31 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -92,15 +92,15 @@ void CAdNodeState::SetCursor(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_cursor)); - PersistMgr->Transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); +HRESULT CAdNodeState::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(Game)); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); return S_OK; } diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 27ff2599a8..5cafa399e7 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -953,45 +953,45 @@ HRESULT CAdObject::Reset() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_blockRegion)); - PersistMgr->Transfer(TMEMBER(_currentBlockRegion)); - PersistMgr->Transfer(TMEMBER(_currentWptGroup)); - PersistMgr->Transfer(TMEMBER(_currentSprite)); - PersistMgr->Transfer(TMEMBER(_drawn)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_ignoreItems)); - PersistMgr->Transfer(TMEMBER_INT(_nextState)); - PersistMgr->Transfer(TMEMBER(_sentence)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_animSprite)); - PersistMgr->Transfer(TMEMBER(_sceneIndependent)); - PersistMgr->Transfer(TMEMBER(_forcedTalkAnimName)); - PersistMgr->Transfer(TMEMBER(_forcedTalkAnimUsed)); - PersistMgr->Transfer(TMEMBER(_tempSprite2)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_wptGroup)); - PersistMgr->Transfer(TMEMBER(_stickRegion)); - PersistMgr->Transfer(TMEMBER(_subtitlesModRelative)); - PersistMgr->Transfer(TMEMBER(_subtitlesModX)); - PersistMgr->Transfer(TMEMBER(_subtitlesModY)); - PersistMgr->Transfer(TMEMBER(_subtitlesModXCenter)); - PersistMgr->Transfer(TMEMBER(_subtitlesWidth)); - PersistMgr->Transfer(TMEMBER(_inventory)); - PersistMgr->Transfer(TMEMBER(_partEmitter)); - - for (int i = 0; i < MAX_NUM_REGIONS; i++) PersistMgr->Transfer(TMEMBER(_currentRegions[i])); - - _attachmentsPre.Persist(PersistMgr); - _attachmentsPost.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_registerAlias)); - - PersistMgr->Transfer(TMEMBER(_partFollowParent)); - PersistMgr->Transfer(TMEMBER(_partOffsetX)); - PersistMgr->Transfer(TMEMBER(_partOffsetY)); +HRESULT CAdObject::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blockRegion)); + persistMgr->transfer(TMEMBER(_currentBlockRegion)); + persistMgr->transfer(TMEMBER(_currentWptGroup)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_drawn)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_ignoreItems)); + persistMgr->transfer(TMEMBER_INT(_nextState)); + persistMgr->transfer(TMEMBER(_sentence)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_animSprite)); + persistMgr->transfer(TMEMBER(_sceneIndependent)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); + persistMgr->transfer(TMEMBER(_tempSprite2)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_wptGroup)); + persistMgr->transfer(TMEMBER(_stickRegion)); + persistMgr->transfer(TMEMBER(_subtitlesModRelative)); + persistMgr->transfer(TMEMBER(_subtitlesModX)); + persistMgr->transfer(TMEMBER(_subtitlesModY)); + persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); + persistMgr->transfer(TMEMBER(_subtitlesWidth)); + persistMgr->transfer(TMEMBER(_inventory)); + persistMgr->transfer(TMEMBER(_partEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); + + _attachmentsPre.Persist(persistMgr); + _attachmentsPost.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_registerAlias)); + + persistMgr->transfer(TMEMBER(_partFollowParent)); + persistMgr->transfer(TMEMBER(_partOffsetX)); + persistMgr->transfer(TMEMBER(_partOffsetY)); return S_OK; } diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 9d2f1d555b..6fcaa47866 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -98,13 +98,13 @@ bool CAdPath::SetReady(bool ready) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPath::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdPath::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_currIndex)); - _points.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_currIndex)); + _points.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_ready)); return S_OK; } diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp index 73d4976a6e..d74284fa22 100644 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -61,13 +61,13 @@ CAdPathPoint::~CAdPathPoint() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPathPoint::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdPathPoint::Persist(CBPersistMgr *persistMgr) { - CBPoint::Persist(PersistMgr); + CBPoint::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_distance)); - PersistMgr->Transfer(TMEMBER(_marked)); - PersistMgr->Transfer(TMEMBER(_origin)); + persistMgr->transfer(TMEMBER(_distance)); + persistMgr->transfer(TMEMBER(_marked)); + persistMgr->transfer(TMEMBER(_origin)); return S_OK; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index c335269885..16598e409b 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -378,13 +378,13 @@ HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::Persist(CBPersistMgr *PersistMgr) { - CBRegion::Persist(PersistMgr); +HRESULT CAdRegion::Persist(CBPersistMgr *persistMgr) { + CBRegion::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_alpha)); - PersistMgr->Transfer(TMEMBER(_blocked)); - PersistMgr->Transfer(TMEMBER(_decoration)); - PersistMgr->Transfer(TMEMBER(_zoom)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_blocked)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_zoom)); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 952ecce4b7..4567e90109 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -124,18 +124,18 @@ HRESULT CAdResponse::SetIconPressed(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_icon)); - PersistMgr->Transfer(TMEMBER(_iconHover)); - PersistMgr->Transfer(TMEMBER(_iconPressed)); - PersistMgr->Transfer(TMEMBER(_iD)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER(_textOrig)); - PersistMgr->Transfer(TMEMBER_INT(_responseType)); - PersistMgr->Transfer(TMEMBER(_font)); +HRESULT CAdResponse::Persist(CBPersistMgr *persistMgr) { + + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_icon)); + persistMgr->transfer(TMEMBER(_iconHover)); + persistMgr->transfer(TMEMBER(_iconPressed)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_textOrig)); + persistMgr->transfer(TMEMBER_INT(_responseType)); + persistMgr->transfer(TMEMBER(_font)); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index c4ba940c89..afceaf8a31 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -511,25 +511,25 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_fontHover)); - PersistMgr->Transfer(TMEMBER(_horizontal)); - PersistMgr->Transfer(TMEMBER(_lastResponseText)); - PersistMgr->Transfer(TMEMBER(_lastResponseTextOrig)); - _respButtons.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_responseArea)); - _responses.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER(_spacing)); - PersistMgr->Transfer(TMEMBER(_waitingScript)); - PersistMgr->Transfer(TMEMBER(_window)); - - PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); - PersistMgr->Transfer(TMEMBER_INT(_align)); +HRESULT CAdResponseBox::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_horizontal)); + persistMgr->transfer(TMEMBER(_lastResponseText)); + persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); + _respButtons.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_responseArea)); + _responses.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_waitingScript)); + persistMgr->transfer(TMEMBER(_window)); + + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + persistMgr->transfer(TMEMBER_INT(_align)); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 03904a1037..054681f656 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -49,10 +49,10 @@ CAdResponseContext::~CAdResponseContext() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseContext::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_context)); - PersistMgr->Transfer(TMEMBER(_iD)); +HRESULT CAdResponseContext::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_context)); + persistMgr->transfer(TMEMBER(_iD)); return S_OK; } diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index fb1167f426..c35784d4d6 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -147,11 +147,11 @@ HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdRotLevel::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_rotation)); return S_OK; } diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index d417358c0c..5ab835a149 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -145,11 +145,11 @@ HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdScaleLevel::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_scale)); return S_OK; } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index b3551d0811..31d30356bd 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -2135,61 +2135,61 @@ float CAdScene::GetScaleAt(int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_autoScroll)); - PersistMgr->Transfer(TMEMBER(_editorColBlocked)); - PersistMgr->Transfer(TMEMBER(_editorColBlockedSel)); - PersistMgr->Transfer(TMEMBER(_editorColDecor)); - PersistMgr->Transfer(TMEMBER(_editorColDecorSel)); - PersistMgr->Transfer(TMEMBER(_editorColEntity)); - PersistMgr->Transfer(TMEMBER(_editorColEntitySel)); - PersistMgr->Transfer(TMEMBER(_editorColFrame)); - PersistMgr->Transfer(TMEMBER(_editorColRegion)); - PersistMgr->Transfer(TMEMBER(_editorColRegionSel)); - PersistMgr->Transfer(TMEMBER(_editorColScale)); - PersistMgr->Transfer(TMEMBER(_editorColWaypoints)); - PersistMgr->Transfer(TMEMBER(_editorColWaypointsSel)); - PersistMgr->Transfer(TMEMBER(_editorMarginH)); - PersistMgr->Transfer(TMEMBER(_editorMarginV)); - PersistMgr->Transfer(TMEMBER(_editorShowBlocked)); - PersistMgr->Transfer(TMEMBER(_editorShowDecor)); - PersistMgr->Transfer(TMEMBER(_editorShowEntities)); - PersistMgr->Transfer(TMEMBER(_editorShowRegions)); - PersistMgr->Transfer(TMEMBER(_editorShowScale)); - PersistMgr->Transfer(TMEMBER(_fader)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_initialized)); - PersistMgr->Transfer(TMEMBER(_lastTimeH)); - PersistMgr->Transfer(TMEMBER(_lastTimeV)); - _layers.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_mainLayer)); - _objects.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_offsetLeft)); - PersistMgr->Transfer(TMEMBER(_offsetTop)); - PersistMgr->Transfer(TMEMBER(_paralaxScrolling)); - PersistMgr->Transfer(TMEMBER(_persistentState)); - PersistMgr->Transfer(TMEMBER(_persistentStateSprites)); - PersistMgr->Transfer(TMEMBER(_pFMaxTime)); - _pFPath.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_pFPointsNum)); - PersistMgr->Transfer(TMEMBER(_pFReady)); - PersistMgr->Transfer(TMEMBER(_pFRequester)); - PersistMgr->Transfer(TMEMBER(_pFTarget)); - PersistMgr->Transfer(TMEMBER(_pFTargetPath)); - _rotLevels.Persist(PersistMgr); - _scaleLevels.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_scrollPixelsH)); - PersistMgr->Transfer(TMEMBER(_scrollPixelsV)); - PersistMgr->Transfer(TMEMBER(_scrollTimeH)); - PersistMgr->Transfer(TMEMBER(_scrollTimeV)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER(_targetOffsetLeft)); - PersistMgr->Transfer(TMEMBER(_targetOffsetTop)); - _waypointGroups.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_viewport)); - PersistMgr->Transfer(TMEMBER(_width)); +HRESULT CAdScene::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_autoScroll)); + persistMgr->transfer(TMEMBER(_editorColBlocked)); + persistMgr->transfer(TMEMBER(_editorColBlockedSel)); + persistMgr->transfer(TMEMBER(_editorColDecor)); + persistMgr->transfer(TMEMBER(_editorColDecorSel)); + persistMgr->transfer(TMEMBER(_editorColEntity)); + persistMgr->transfer(TMEMBER(_editorColEntitySel)); + persistMgr->transfer(TMEMBER(_editorColFrame)); + persistMgr->transfer(TMEMBER(_editorColRegion)); + persistMgr->transfer(TMEMBER(_editorColRegionSel)); + persistMgr->transfer(TMEMBER(_editorColScale)); + persistMgr->transfer(TMEMBER(_editorColWaypoints)); + persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); + persistMgr->transfer(TMEMBER(_editorMarginH)); + persistMgr->transfer(TMEMBER(_editorMarginV)); + persistMgr->transfer(TMEMBER(_editorShowBlocked)); + persistMgr->transfer(TMEMBER(_editorShowDecor)); + persistMgr->transfer(TMEMBER(_editorShowEntities)); + persistMgr->transfer(TMEMBER(_editorShowRegions)); + persistMgr->transfer(TMEMBER(_editorShowScale)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_initialized)); + persistMgr->transfer(TMEMBER(_lastTimeH)); + persistMgr->transfer(TMEMBER(_lastTimeV)); + _layers.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_mainLayer)); + _objects.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_offsetLeft)); + persistMgr->transfer(TMEMBER(_offsetTop)); + persistMgr->transfer(TMEMBER(_paralaxScrolling)); + persistMgr->transfer(TMEMBER(_persistentState)); + persistMgr->transfer(TMEMBER(_persistentStateSprites)); + persistMgr->transfer(TMEMBER(_pFMaxTime)); + _pFPath.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_pFPointsNum)); + persistMgr->transfer(TMEMBER(_pFReady)); + persistMgr->transfer(TMEMBER(_pFRequester)); + persistMgr->transfer(TMEMBER(_pFTarget)); + persistMgr->transfer(TMEMBER(_pFTargetPath)); + _rotLevels.Persist(persistMgr); + _scaleLevels.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollPixelsH)); + persistMgr->transfer(TMEMBER(_scrollPixelsV)); + persistMgr->transfer(TMEMBER(_scrollTimeH)); + persistMgr->transfer(TMEMBER(_scrollTimeV)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_targetOffsetLeft)); + persistMgr->transfer(TMEMBER(_targetOffsetTop)); + _waypointGroups.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_width)); return S_OK; } diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index aceff64873..071469c996 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -69,13 +69,13 @@ HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdSceneNode::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_entity)); - PersistMgr->Transfer(TMEMBER(_region)); - PersistMgr->Transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_entity)); + persistMgr->transfer(TMEMBER(_region)); + persistMgr->transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 3a083498fe..a3dfc3c27d 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -54,9 +54,9 @@ CAdSceneState::~CAdSceneState() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneState::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_filename)); - _nodeStates.Persist(PersistMgr); +HRESULT CAdSceneState::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_filename)); + _nodeStates.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 468f8a49c1..dd6a8c9269 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -211,27 +211,27 @@ HRESULT CAdSentence::Finish() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Persist(CBPersistMgr *PersistMgr) { - - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER_INT(_align)); - PersistMgr->Transfer(TMEMBER(_currentStance)); - PersistMgr->Transfer(TMEMBER(_currentSprite)); - PersistMgr->Transfer(TMEMBER(_currentSkelAnim)); - PersistMgr->Transfer(TMEMBER(_duration)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_sound)); - PersistMgr->Transfer(TMEMBER(_soundStarted)); - PersistMgr->Transfer(TMEMBER(_stances)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_talkDef)); - PersistMgr->Transfer(TMEMBER(_tempStance)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER(_width)); - PersistMgr->Transfer(TMEMBER(_fixedPos)); - PersistMgr->Transfer(TMEMBER(_freezable)); +HRESULT CAdSentence::Persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(Game)); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_currentStance)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_currentSkelAnim)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_sound)); + persistMgr->transfer(TMEMBER(_soundStarted)); + persistMgr->transfer(TMEMBER(_stances)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_talkDef)); + persistMgr->transfer(TMEMBER(_tempStance)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_fixedPos)); + persistMgr->transfer(TMEMBER(_freezable)); return S_OK; } diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 4fc5a12c4c..86937dde8e 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -214,13 +214,13 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdSpriteSet::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_owner)); for (int i = 0; i < NUM_DIRECTIONS; i++) { - PersistMgr->Transfer("", &_sprites[i]); + persistMgr->transfer("", &_sprites[i]); } return S_OK; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 67c7c74e42..283df609cb 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -194,16 +194,16 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdTalkDef::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_defaultSprite)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteFilename)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteSet)); - PersistMgr->Transfer(TMEMBER(_defaultSpriteSetFilename)); + persistMgr->transfer(TMEMBER(_defaultSprite)); + persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); + persistMgr->transfer(TMEMBER(_defaultSpriteSet)); + persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); - _nodes.Persist(PersistMgr); + _nodes.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index a2af4223a3..e8b691b9fd 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -343,12 +343,12 @@ HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::Persist(CBPersistMgr *PersistMgr) { - CAdObject::Persist(PersistMgr); +HRESULT CAdTalkHolder::Persist(CBPersistMgr *persistMgr) { + CAdObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_sprite)); - _talkSprites.Persist(PersistMgr); - _talkSpritesEx.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_sprite)); + _talkSprites.Persist(persistMgr); + _talkSpritesEx.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index c8f2c2c971..0a3adc1632 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -183,15 +183,15 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_comment)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_endTime)); - PersistMgr->Transfer(TMEMBER(_playToEnd)); - PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER(_spriteFilename)); - PersistMgr->Transfer(TMEMBER(_spriteSet)); - PersistMgr->Transfer(TMEMBER(_spriteSetFilename)); +HRESULT CAdTalkNode::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_comment)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_endTime)); + persistMgr->transfer(TMEMBER(_playToEnd)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_spriteFilename)); + persistMgr->transfer(TMEMBER(_spriteSet)); + persistMgr->transfer(TMEMBER(_spriteSetFilename)); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 7748cdca02..77cec106dd 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -184,16 +184,16 @@ HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::Persist(CBPersistMgr *PersistMgr) { +HRESULT CAdWaypointGroup::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(_lastMimicScale)); - PersistMgr->Transfer(TMEMBER(_lastMimicX)); - PersistMgr->Transfer(TMEMBER(_lastMimicY)); - _points.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BEvent.cpp b/engines/wintermute/Base/BEvent.cpp index c0cc5a2e4a..1272f85322 100644 --- a/engines/wintermute/Base/BEvent.cpp +++ b/engines/wintermute/Base/BEvent.cpp @@ -183,13 +183,13 @@ HRESULT CBEvent::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBEvent::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_script)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_script)); + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index 0769e8fd83..a00215158c 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -154,21 +154,21 @@ uint32 CBFader::GetCurrentColor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_blue)); - PersistMgr->Transfer(TMEMBER(_currentAlpha)); - PersistMgr->Transfer(TMEMBER(_duration)); - PersistMgr->Transfer(TMEMBER(_green)); - PersistMgr->Transfer(TMEMBER(_red)); - PersistMgr->Transfer(TMEMBER(_sourceAlpha)); - PersistMgr->Transfer(TMEMBER(_startTime)); - PersistMgr->Transfer(TMEMBER(_targetAlpha)); - PersistMgr->Transfer(TMEMBER(_system)); - - if (_system && !PersistMgr->_saving) _startTime = 0; +HRESULT CBFader::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->_saving) _startTime = 0; return S_OK; } diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 0f2b248bee..302d4728d0 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -144,9 +144,9 @@ int CBFont::GetLetterHeight() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFont::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBFont::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 10df7fdf3a..94f723cef3 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -456,25 +456,25 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBFontBitmap::Persist(CBPersistMgr *persistMgr) { - CBFont::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_numColumns)); + CBFont::Persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); - PersistMgr->Transfer(TMEMBER(_subframe)); - PersistMgr->Transfer(TMEMBER(_tileHeight)); - PersistMgr->Transfer(TMEMBER(_tileWidth)); - PersistMgr->Transfer(TMEMBER(_sprite)); - PersistMgr->Transfer(TMEMBER(_widthsFrame)); + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); - if (PersistMgr->_saving) - PersistMgr->PutBytes(_widths, sizeof(_widths)); + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); else - PersistMgr->GetBytes(_widths, sizeof(_widths)); + persistMgr->getBytes(_widths, sizeof(_widths)); - PersistMgr->Transfer(TMEMBER(_fontextFix)); - PersistMgr->Transfer(TMEMBER(_wholeCell)); + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); return S_OK; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 0d00f89e60..a96809d194 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -142,14 +142,14 @@ HRESULT CBFontStorage::RemoveFont(CBFont *Font) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBFontStorage::Persist(CBPersistMgr *persistMgr) { - if (!PersistMgr->_saving) Cleanup(false); + if (!persistMgr->_saving) Cleanup(false); - PersistMgr->Transfer(TMEMBER(Game)); - _fonts.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(Game)); + _fonts.Persist(persistMgr); - if (!PersistMgr->_saving) InitFreeType(); + if (!persistMgr->_saving) InitFreeType(); return S_OK; } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 91ef15cebf..7592eff3bf 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -596,34 +596,34 @@ HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::Persist(CBPersistMgr *PersistMgr) { - CBFont::Persist(PersistMgr); +HRESULT CBFontTT::Persist(CBPersistMgr *persistMgr) { + CBFont::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_isBold)); - PersistMgr->Transfer(TMEMBER(_isItalic)); - PersistMgr->Transfer(TMEMBER(_isUnderline)); - PersistMgr->Transfer(TMEMBER(_isStriked)); - PersistMgr->Transfer(TMEMBER(_fontHeight)); - PersistMgr->Transfer(TMEMBER(_fontFile)); + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); // persist layers int NumLayers; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { NumLayers = _layers.GetSize(); - PersistMgr->Transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(PersistMgr); + persistMgr->transfer(TMEMBER(NumLayers)); + for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(persistMgr); } else { NumLayers = _layers.GetSize(); - PersistMgr->Transfer(TMEMBER(NumLayers)); + persistMgr->transfer(TMEMBER(NumLayers)); for (int i = 0; i < NumLayers; i++) { CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->Persist(PersistMgr); + Layer->Persist(persistMgr); _layers.Add(Layer); } } - if (!PersistMgr->_saving) { + if (!persistMgr->_saving) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; _glyphCache = NULL; _fallbackFont = _font = _deletableFont = NULL; diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 5658997d2e..127c727922 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -82,10 +82,10 @@ public: _color = 0x00000000; } - HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_color)); + HRESULT Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); return S_OK; } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index fa1ed5484e..9e07407f26 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -381,18 +381,18 @@ HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); - - _applyEvent.Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_delay)); - PersistMgr->Transfer(TMEMBER(_editorExpanded)); - PersistMgr->Transfer(TMEMBER(_keyframe)); - PersistMgr->Transfer(TMEMBER(_killSound)); - PersistMgr->Transfer(TMEMBER(_moveX)); - PersistMgr->Transfer(TMEMBER(_moveY)); - PersistMgr->Transfer(TMEMBER(_sound)); - _subframes.Persist(PersistMgr); +HRESULT CBFrame::Persist(CBPersistMgr *persistMgr) { + CBScriptable::Persist(persistMgr); + + _applyEvent.Persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 13bfd9fc75..4c545b7a1c 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3253,7 +3253,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); - if (FAILED(ret = pm->InitSave(desc))) goto save_finish; + if (FAILED(ret = pm->initSave(desc))) goto save_finish; if (!quickSave) { delete _saveLoadImage; @@ -3270,7 +3270,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveTable(Game, pm, quickSave))) goto save_finish; if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = pm->SaveFile(Filename))) goto save_finish; + if (FAILED(ret = pm->saveFile(Filename))) goto save_finish; _registry->WriteInt("System", "MostRecentSaveSlot", slot); @@ -3323,7 +3323,7 @@ HRESULT CBGame::LoadGame(const char *Filename) { _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); _dEBUG_AbsolutePathWarning = false; - if (FAILED(ret = pm->InitLoad(Filename))) goto load_finish; + if (FAILED(ret = pm->initLoad(Filename))) goto load_finish; //if(FAILED(ret = Cleanup())) goto load_finish; if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; @@ -3631,96 +3631,96 @@ HRESULT CBGame::LoadSettings(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_activeObject)); - PersistMgr->Transfer(TMEMBER(_capturedObject)); - PersistMgr->Transfer(TMEMBER(_cursorNoninteractive)); - PersistMgr->Transfer(TMEMBER(_doNotExpandStrings)); - PersistMgr->Transfer(TMEMBER(_editorMode)); - PersistMgr->Transfer(TMEMBER(_fader)); - PersistMgr->Transfer(TMEMBER(_freezeLevel)); - PersistMgr->Transfer(TMEMBER(_focusedWindow)); - PersistMgr->Transfer(TMEMBER(_fontStorage)); - PersistMgr->Transfer(TMEMBER(_interactive)); - PersistMgr->Transfer(TMEMBER(_keyboardState)); - PersistMgr->Transfer(TMEMBER(_lastTime)); - PersistMgr->Transfer(TMEMBER(_mainObject)); +HRESULT CBGame::Persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) Cleanup(); + + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_doNotExpandStrings)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - PersistMgr->Transfer(TMEMBER(_music[i])); - PersistMgr->Transfer(TMEMBER(_musicStartTime[i])); + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); } - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_offsetPercentX)); - PersistMgr->Transfer(TMEMBER(_offsetPercentY)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); - PersistMgr->Transfer(TMEMBER(_origInteractive)); - PersistMgr->Transfer(TMEMBER_INT(_origState)); - PersistMgr->Transfer(TMEMBER(_personalizedSave)); - PersistMgr->Transfer(TMEMBER(_quitting)); + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); - _regObjects.Persist(PersistMgr); + _regObjects.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_scEngine)); - //PersistMgr->Transfer(TMEMBER(_soundMgr)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - //PersistMgr->Transfer(TMEMBER(_surfaceStorage)); - PersistMgr->Transfer(TMEMBER(_subtitles)); - PersistMgr->Transfer(TMEMBER(_subtitlesSpeed)); - PersistMgr->Transfer(TMEMBER(_systemFont)); - PersistMgr->Transfer(TMEMBER(_videoFont)); - PersistMgr->Transfer(TMEMBER(_videoSubtitles)); + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); - PersistMgr->Transfer(TMEMBER(_timer)); - PersistMgr->Transfer(TMEMBER(_timerDelta)); - PersistMgr->Transfer(TMEMBER(_timerLast)); + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); - PersistMgr->Transfer(TMEMBER(_liveTimer)); - PersistMgr->Transfer(TMEMBER(_liveTimerDelta)); - PersistMgr->Transfer(TMEMBER(_liveTimerLast)); + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeRunning)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeStartTime)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeLength)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel1)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeChannel2)); - PersistMgr->Transfer(TMEMBER(_musicCrossfadeSwap)); + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - PersistMgr->Transfer(TMEMBER(_loadImageName)); - PersistMgr->Transfer(TMEMBER(_saveImageName)); - PersistMgr->Transfer(TMEMBER(_saveImageX)); - PersistMgr->Transfer(TMEMBER(_saveImageY)); - PersistMgr->Transfer(TMEMBER(_loadImageX)); - PersistMgr->Transfer(TMEMBER(_loadImageY)); + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); - PersistMgr->Transfer(TMEMBER_INT(_textEncoding)); - PersistMgr->Transfer(TMEMBER(_textRTL)); + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); - PersistMgr->Transfer(TMEMBER(_soundBufferSizeSec)); - PersistMgr->Transfer(TMEMBER(_suspendedRendering)); + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); - PersistMgr->Transfer(TMEMBER(_mouseLockRect)); + persistMgr->transfer(TMEMBER(_mouseLockRect)); - _windows.Persist(PersistMgr); + _windows.Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_suppressScriptErrors)); - PersistMgr->Transfer(TMEMBER(_autorunDisabled)); + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); - PersistMgr->Transfer(TMEMBER(_autoSaveOnExit)); - PersistMgr->Transfer(TMEMBER(_autoSaveSlot)); - PersistMgr->Transfer(TMEMBER(_cursorHidden)); + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); - if (PersistMgr->CheckVersion(1, 0, 1)) - PersistMgr->Transfer(TMEMBER(_store)); + if (persistMgr->checkVersion(1, 0, 1)) + persistMgr->transfer(TMEMBER(_store)); else _store = NULL; - if (!PersistMgr->_saving) _quitting = false; + if (!persistMgr->_saving) _quitting = false; return S_OK; } @@ -3933,7 +3933,7 @@ HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { if (!pm) return E_FAIL; _dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(Filename))) { + if (FAILED(pm->initLoad(Filename))) { _dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index c91438dba9..cc25dd39a9 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -215,18 +215,18 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::Persist(CBPersistMgr *PersistMgr) { - //if(!PersistMgr->_saving) Cleanup(); - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_currentAlt)); - PersistMgr->Transfer(TMEMBER(_currentCharCode)); - PersistMgr->Transfer(TMEMBER(_currentControl)); - PersistMgr->Transfer(TMEMBER(_currentKeyData)); - PersistMgr->Transfer(TMEMBER(_currentPrintable)); - PersistMgr->Transfer(TMEMBER(_currentShift)); +HRESULT CBKeyboardState::Persist(CBPersistMgr *persistMgr) { + //if(!persistMgr->_saving) Cleanup(); + CBScriptable::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); - if (!PersistMgr->_saving) { + if (!persistMgr->_saving) { _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum for (int i = 0; i < 323; i++) { _keyStates[i] = false; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index f947fdb1f5..f59978eb77 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -864,55 +864,55 @@ HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Persist(CBPersistMgr *PersistMgr) { - CBScriptHolder::Persist(PersistMgr); - - for (int i = 0; i < 7; i++) PersistMgr->Transfer(TMEMBER(_caption[i])); - PersistMgr->Transfer(TMEMBER(_activeCursor)); - PersistMgr->Transfer(TMEMBER(_alphaColor)); - PersistMgr->Transfer(TMEMBER(_autoSoundPanning)); - PersistMgr->Transfer(TMEMBER(_cursor)); - PersistMgr->Transfer(TMEMBER(_sharedCursors)); - PersistMgr->Transfer(TMEMBER(_editorAlwaysRegister)); - PersistMgr->Transfer(TMEMBER(_editorOnly)); - PersistMgr->Transfer(TMEMBER(_editorSelected)); - PersistMgr->Transfer(TMEMBER(_iD)); - PersistMgr->Transfer(TMEMBER(_is3D)); - PersistMgr->Transfer(TMEMBER(_movable)); - PersistMgr->Transfer(TMEMBER(_posX)); - PersistMgr->Transfer(TMEMBER(_posY)); - PersistMgr->Transfer(TMEMBER(_relativeScale)); - PersistMgr->Transfer(TMEMBER(_rotatable)); - PersistMgr->Transfer(TMEMBER(_scale)); - PersistMgr->Transfer(TMEMBER(_sFX)); - PersistMgr->Transfer(TMEMBER(_sFXStart)); - PersistMgr->Transfer(TMEMBER(_sFXVolume)); - PersistMgr->Transfer(TMEMBER(_ready)); - PersistMgr->Transfer(TMEMBER(_rect)); - PersistMgr->Transfer(TMEMBER(_rectSet)); - PersistMgr->Transfer(TMEMBER(_registrable)); - PersistMgr->Transfer(TMEMBER(_shadowable)); - PersistMgr->Transfer(TMEMBER(_soundEvent)); - PersistMgr->Transfer(TMEMBER(_zoomable)); - - PersistMgr->Transfer(TMEMBER(_scaleX)); - PersistMgr->Transfer(TMEMBER(_scaleY)); - - PersistMgr->Transfer(TMEMBER(_rotate)); - PersistMgr->Transfer(TMEMBER(_rotateValid)); - PersistMgr->Transfer(TMEMBER(_relativeRotate)); - - PersistMgr->Transfer(TMEMBER(_saveState)); - PersistMgr->Transfer(TMEMBER(_nonIntMouseEvents)); - - PersistMgr->Transfer(TMEMBER_INT(_sFXType)); - PersistMgr->Transfer(TMEMBER(_sFXParam1)); - PersistMgr->Transfer(TMEMBER(_sFXParam2)); - PersistMgr->Transfer(TMEMBER(_sFXParam3)); - PersistMgr->Transfer(TMEMBER(_sFXParam4)); - - - PersistMgr->Transfer(TMEMBER_INT(_blendMode)); +HRESULT CBObject::Persist(CBPersistMgr *persistMgr) { + CBScriptHolder::Persist(persistMgr); + + for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); return S_OK; } diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 938498dae8..c0cab7f865 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -74,19 +74,19 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBPersistMgr::~CBPersistMgr() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::Cleanup() { -/* if (_buffer) { - if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0;*/ +void CBPersistMgr::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ _offset = 0; delete[] _richBuffer; @@ -103,26 +103,19 @@ void CBPersistMgr::Cleanup() { delete [] _thumbnailData; _thumbnailData = NULL; } - + delete _loadStream; delete _saveStream; _loadStream = NULL; _saveStream = NULL; } -// TODO: This is not at all endian-safe -uint32 makeUint32(byte first, byte second, byte third, byte fourth) { - uint32 retVal = first; - retVal = retVal & second << 8 & third << 16 & fourth << 24; - return retVal; -} - Common::String CBPersistMgr::getFilenameForSlot(int slot) { // TODO: Temporary solution until I have the namespacing sorted out return Common::String::format("save%03d.DirtySplitSav", slot); } -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor& desc) { +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (FAILED(readHeader(filename))) { @@ -133,7 +126,7 @@ void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor& desc) { desc.setDescription(_savedDescription); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); - + if (_thumbnailDataSize > 0) { Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); Graphics::BitmapDecoder bmpDecoder; @@ -176,19 +169,12 @@ bool CBPersistMgr::getSaveExists(int slot) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitSave(const char *Desc) { - if (!Desc) return E_FAIL; - - HRESULT res; +HRESULT CBPersistMgr::initSave(const char *desc) { + if (!desc) return E_FAIL; - Cleanup(); + cleanup(); _saving = true; -/* _buffer = (byte *)malloc(SAVE_BUFFER_INIT_SIZE); - if (_buffer) { - _bufferSize = SAVE_BUFFER_INIT_SIZE; - res = S_OK; - } else res = E_FAIL;*/ _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); if (_saveStream) { @@ -201,12 +187,11 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { } } - uint32 magic = DCGF_MAGIC; - PutDWORD(magic); + putDWORD(magic); magic = SAVE_MAGIC_2; - PutDWORD(magic); + putDWORD(magic); byte VerMajor, VerMinor, ExtMajor, ExtMinor; Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); @@ -217,15 +202,14 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { _saveStream->writeByte(ExtMinor); // new in ver 2 - PutDWORD((uint32)DCGF_VER_BUILD); - PutString(Game->_name); + putDWORD((uint32)DCGF_VER_BUILD); + putString(Game->_name); // thumbnail data size bool ThumbnailOK = false; if (Game->_cachedThumbnail) { if (Game->_cachedThumbnail->_thumbnail) { - uint32 Size = 0; Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); if (Game->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { _saveStream->writeUint32LE(thumbStream.size()); @@ -234,25 +218,22 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { _saveStream->writeUint32LE(0); } -/* PutDWORD(Size); - if (Size > 0) _saveStream->write(Buffer, Size); - delete [] Buffer;*/ ThumbnailOK = true; } } - if (!ThumbnailOK) PutDWORD(0); + if (!ThumbnailOK) putDWORD(0); // in any case, destroy the cached thumbnail once used delete Game->_cachedThumbnail; Game->_cachedThumbnail = NULL; - uint32 DataOffset = _offset + + uint32 dataOffset = _offset + sizeof(uint32) + // data offset - sizeof(uint32) + strlen(Desc) + 1 + // description + sizeof(uint32) + strlen(desc) + 1 + // description sizeof(uint32); // timestamp - PutDWORD(DataOffset); - PutString(Desc); + putDWORD(dataOffset); + putString(desc); g_system->getTimeAndDate(_savedTimestamp); putTimeDate(_savedTimestamp); @@ -261,117 +242,94 @@ HRESULT CBPersistMgr::InitSave(const char *Desc) { } return S_OK; } -// TODO: Do this properly, this is just a quickfix, that probably doesnt even work. -// The main point of which is ditching BASS completely. -byte getLowByte(uint16 word) { - uint16 mask = 0xff; - return word & mask; -} - -byte getHighByte(uint16 word) { - uint16 mask = 0xff << 8; - word = word & mask; - return word >> 8; -} - -uint16 getLowWord(uint32 dword) { - uint32 mask = 0xffff; - return dword & mask; -} - -uint16 getHighWord(uint32 dword) { - uint32 mask = 0xffff << 16; - dword = dword & mask; - return dword >> 16; -} HRESULT CBPersistMgr::readHeader(const Common::String &filename) { - Cleanup(); - + cleanup(); + _saving = false; - + _loadStream = g_system->getSavefileManager()->openForLoading(filename); //_buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); if (_loadStream) { uint32 Magic; - Magic = GetDWORD(); + Magic = getDWORD(); if (Magic != DCGF_MAGIC) { - Cleanup(); + cleanup(); return E_FAIL; } - Magic = GetDWORD(); + Magic = getDWORD(); if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { _savedVerMajor = _loadStream->readByte(); _savedVerMinor = _loadStream->readByte(); _savedExtMajor = _loadStream->readByte(); _savedExtMinor = _loadStream->readByte(); - + if (Magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)GetDWORD(); - _savedName = GetString(); + _savedVerBuild = (byte)getDWORD(); + _savedName = getString(); // load thumbnail - _thumbnailDataSize = GetDWORD(); + _thumbnailDataSize = getDWORD(); if (_thumbnailDataSize > 0) { _thumbnailData = new byte[_thumbnailDataSize]; if (_thumbnailData) { - GetBytes(_thumbnailData, _thumbnailDataSize); + getBytes(_thumbnailData, _thumbnailDataSize); } else _thumbnailDataSize = 0; } } else _savedVerBuild = 35; // last build with ver1 savegames - uint32 DataOffset = GetDWORD(); + uint32 DataOffset = getDWORD(); - _savedDescription = GetString(); + _savedDescription = getString(); _savedTimestamp = getTimeDate(); _savedPlayTime = _loadStream->readUint32LE(); _offset = DataOffset; - + return S_OK; } } - Cleanup(); + cleanup(); return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::InitLoad(const char *Filename) { +HRESULT CBPersistMgr::initLoad(const char *filename) { - if (FAILED(readHeader(Filename))) { - Cleanup(); + if (FAILED(readHeader(filename))) { + cleanup(); return E_FAIL; } _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), Game->_name) != 0) { Game->LOG(0, "ERROR: Saved game name doesn't match current game"); - Cleanup(); + cleanup(); return E_FAIL; } // if save is newer version than we are, fail if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { Game->LOG(0, "ERROR: Saved game version is newer than current game"); - Cleanup(); + cleanup(); return E_FAIL; } // if save is older than the minimal version we support if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - Cleanup(); + cleanup(); return E_FAIL; } @@ -389,85 +347,58 @@ HRESULT CBPersistMgr::InitLoad(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::SaveFile(const char *Filename) { - return Game->_fileManager->SaveFile(Filename, ((Common::MemoryWriteStreamDynamic*)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic*)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); +HRESULT CBPersistMgr::saveFile(const char *filename) { + return Game->_fileManager->SaveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::PutBytes(byte *buffer, uint32 size) { +HRESULT CBPersistMgr::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); if (_saveStream->err()) return E_FAIL; return S_OK; -/* while (_offset + Size > _bufferSize) { - _bufferSize += SAVE_BUFFER_GROW_BY; - _buffer = (byte *)realloc(_buffer, _bufferSize); - if (!_buffer) { - Game->LOG(0, "Error reallocating save buffer to %d bytes", _bufferSize); - return E_FAIL; - } - } - - memcpy(_buffer + _offset, Buffer, Size); - _offset += Size; - - return S_OK;*/ } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::GetBytes(byte *buffer, uint32 size) { +HRESULT CBPersistMgr::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); if (_loadStream->err()) return E_FAIL; return S_OK; -/* if (_offset + Size > _bufferSize) { - Game->LOG(0, "Fatal: Save buffer underflow"); - return E_FAIL; - } - - memcpy(Buffer, _buffer + _offset, Size); - _offset += Size; - - return S_OK;*/ } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::PutDWORD(uint32 Val) { - //PutBytes((byte *)&Val, sizeof(uint32)); - _saveStream->writeUint32LE(Val); +void CBPersistMgr::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); } ////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::GetDWORD() { +uint32 CBPersistMgr::getDWORD() { uint32 ret = _loadStream->readUint32LE(); -// GetBytes((byte *)&ret, sizeof(uint32)); return ret; } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::PutString(const Common::String &Val) { - if (!Val.size()) PutString("(null)"); +void CBPersistMgr::putString(const Common::String &val) { + if (!val.size()) putString("(null)"); else { - /* PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1);*/ - _saveStream->writeUint32LE(Val.size()); - _saveStream->writeString(Val); + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); } } ////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::GetString() { +char *CBPersistMgr::getString() { uint32 len = _loadStream->readUint32LE(); char *ret = new char[len + 1]; _loadStream->read(ret, len); ret[len] = '\0'; -/* char *ret = (char *)(_buffer + _offset); - _offset += len;*/ - if (!strcmp(ret, "(null)")) { + + if (!strcmp(ret, "(null)")) { delete[] ret; return NULL; } else return ret; @@ -481,7 +412,7 @@ HRESULT CBPersistMgr::putTimeDate(const TimeDate &t) { _saveStream->writeSint32LE(t.tm_mon); _saveStream->writeSint32LE(t.tm_year); // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next - + if (_saveStream->err()) { return E_FAIL; } @@ -507,7 +438,7 @@ void CBPersistMgr::putFloat(float val) { } float CBPersistMgr::getFloat() { - char *str = GetString(); + char *str = getString(); float value = 0.0f; int ret = sscanf(str, "F%f", &value); if (ret != 1) { @@ -525,7 +456,7 @@ void CBPersistMgr::putDouble(double val) { } double CBPersistMgr::getDouble() { - char *str = GetString(); + char *str = getString(); double value = 0.0f; int ret = sscanf(str, "F%f", &value); if (ret != 1) { @@ -537,16 +468,14 @@ double CBPersistMgr::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { - if (_saving) { - //return PutBytes((byte *)Val, sizeof(bool)); - _saveStream->writeByte(*Val); +HRESULT CBPersistMgr::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); if (_saveStream->err()) return E_FAIL; return S_OK; } else { - //return GetBytes((byte *)Val, sizeof(bool)); - *Val = _loadStream->readByte(); + *val = _loadStream->readByte(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -556,16 +485,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, bool *Val) { ////////////////////////////////////////////////////////////////////////// // int -HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { +HRESULT CBPersistMgr::transfer(const char *name, int *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(int)); - _saveStream->writeSint32LE(*Val); + _saveStream->writeSint32LE(*val); if (_saveStream->err()) return E_FAIL; return S_OK; } else { - // return GetBytes((byte *)Val, sizeof(int)); - *Val = _loadStream->readSint32LE(); + *val = _loadStream->readSint32LE(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -575,16 +502,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, int *Val) { ////////////////////////////////////////////////////////////////////////// // DWORD -HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { +HRESULT CBPersistMgr::transfer(const char *name, uint32 *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(uint32)); - _saveStream->writeUint32LE(*Val); + _saveStream->writeUint32LE(*val); if (_saveStream->err()) return E_FAIL; return S_OK; } else { - // return GetBytes((byte *)Val, sizeof(uint32)); - *Val = _loadStream->readUint32LE(); + *val = _loadStream->readUint32LE(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -594,16 +519,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, uint32 *Val) { ////////////////////////////////////////////////////////////////////////// // float -HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { +HRESULT CBPersistMgr::transfer(const char *name, float *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(float)); - putFloat(*Val); + putFloat(*val); if (_saveStream->err()) return E_FAIL; return S_OK; } else { - //return GetBytes((byte *)Val, sizeof(float)); - *Val = getFloat(); + *val = getFloat(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -613,16 +536,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, float *Val) { ////////////////////////////////////////////////////////////////////////// // double -HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { +HRESULT CBPersistMgr::transfer(const char *name, double *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(double)); - putDouble(*Val); + putDouble(*val); if (_saveStream->err()) return E_FAIL; return S_OK; } else { - // return GetBytes((byte *)Val, sizeof(double)); - *Val = getDouble(); + *val = getDouble(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -632,58 +553,46 @@ HRESULT CBPersistMgr::Transfer(const char *Name, double *Val) { ////////////////////////////////////////////////////////////////////////// // char* -HRESULT CBPersistMgr::Transfer(const char *Name, char **Val) { +HRESULT CBPersistMgr::transfer(const char *name, char **val) { if (_saving) { - PutString(*Val); + putString(*val); return S_OK; } else { - char *str = GetString(); + char *str = getString(); if (_loadStream->err()) { delete[] str; return E_FAIL; } - *Val = str; - /* if (str) { - - char *ret = new char[strlen(str) + 1]; - strcpy(ret, str); - delete[] str; - } else *Val = NULL;*/ + *val = str; return S_OK; } } ////////////////////////////////////////////////////////////////////////// // const char* -HRESULT CBPersistMgr::Transfer(const char *Name, const char **Val) { +HRESULT CBPersistMgr::transfer(const char *name, const char **val) { if (_saving) { - PutString(*Val); + putString(*val); return S_OK; } else { - char *str = GetString(); + char *str = getString(); if (_loadStream->err()) { delete[] str; return E_FAIL; } - *Val = str; -/* if (str) { - - char *ret = new char[strlen(str) + 1]; - strcpy(ret, str); - delete[] str; - } else *Val = NULL;*/ + *val = str; return S_OK; } } ////////////////////////////////////////////////////////////////////////// // Common::String -HRESULT CBPersistMgr::Transfer(const char *Name, Common::String *val) { +HRESULT CBPersistMgr::transfer(const char *name, Common::String *val) { if (_saving) { - PutString(*val); + putString(*val); return S_OK; } else { - char *str = GetString(); + char *str = getString(); if (_loadStream->err()) { delete[] str; return E_FAIL; @@ -694,40 +603,32 @@ HRESULT CBPersistMgr::Transfer(const char *Name, Common::String *val) { } else { *val = ""; } - /* if (str) { - - char *ret = new char[strlen(str) + 1]; - strcpy(ret, str); - delete[] str; - } else *Val = NULL;*/ return S_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { +HRESULT CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { size_t size; if (_saving) { - size = Val.size(); + size = val.size(); _saveStream->writeUint32LE(size); - //PutBytes((byte *)&size, sizeof(size_t)); - for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it) { - PutString((*it).c_str()); + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); } } else { - Val.clear(); + val.clear(); size = _loadStream->readUint32LE(); - //GetBytes((byte *)&size, sizeof(size_t)); for (size_t i = 0; i < size; i++) { - char *str = GetString(); + char *str = getString(); if (_loadStream->err()) { delete[] str; return E_FAIL; } - if (str) Val.push_back(str); + if (str) val.push_back(str); delete[] str; } } @@ -737,16 +638,14 @@ HRESULT CBPersistMgr::Transfer(const char *Name, AnsiStringArray &Val) { ////////////////////////////////////////////////////////////////////////// // BYTE -HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { +HRESULT CBPersistMgr::transfer(const char *name, byte *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(byte)); - _saveStream->writeByte(*Val); + _saveStream->writeByte(*val); if (_saveStream->err()) return E_FAIL; return S_OK; - } else { - //return GetBytes((byte *)Val, sizeof(byte)); - *Val = _loadStream->readByte(); + } else { + *val = _loadStream->readByte(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -756,23 +655,20 @@ HRESULT CBPersistMgr::Transfer(const char *Name, byte *Val) { ////////////////////////////////////////////////////////////////////////// // RECT -HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { +HRESULT CBPersistMgr::transfer(const char *name, RECT *val) { if (_saving) { - // return PutBytes((byte *)Val, sizeof(RECT)); - _saveStream->writeSint32LE(Val->left); - _saveStream->writeSint32LE(Val->top); - _saveStream->writeSint32LE(Val->right); - _saveStream->writeSint32LE(Val->bottom); + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); if (_saveStream->err()) return E_FAIL; return S_OK; - } - else { - // return GetBytes((byte *)Val, sizeof(RECT)); - Val->left = _loadStream->readSint32LE(); - Val->top = _loadStream->readSint32LE(); - Val->right = _loadStream->readSint32LE(); - Val->bottom = _loadStream->readSint32LE(); + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); if (_loadStream->err()) return E_FAIL; return S_OK; @@ -782,56 +678,48 @@ HRESULT CBPersistMgr::Transfer(const char *Name, RECT *Val) { ////////////////////////////////////////////////////////////////////////// // POINT -HRESULT CBPersistMgr::Transfer(const char *Name, POINT *Val) { +HRESULT CBPersistMgr::transfer(const char *name, POINT *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(POINT)); - _saveStream->writeSint32LE(Val->x); - _saveStream->writeSint32LE(Val->y); + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); } else { - // return GetBytes((byte *)Val, sizeof(POINT)); - Val->x = _loadStream->readSint32LE(); - Val->y = _loadStream->readSint32LE(); + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); } } ////////////////////////////////////////////////////////////////////////// // Vector2 -HRESULT CBPersistMgr::Transfer(const char *Name, Vector2 *Val) { +HRESULT CBPersistMgr::transfer(const char *name, Vector2 *val) { if (_saving) { - //return PutBytes((byte *)Val, sizeof(Vector2)); - putFloat(Val->x); - putFloat(Val->y); + putFloat(val->x); + putFloat(val->y); } else { - // return GetBytes((byte *)Val, sizeof(Vector2)); - Val->x = getFloat(); - Val->y = getFloat(); + val->x = getFloat(); + val->y = getFloat(); } } ////////////////////////////////////////////////////////////////////////// // generic pointer -HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { +HRESULT CBPersistMgr::transfer(const char *name, void *val) { int ClassID = -1, InstanceID = -1; if (_saving) { - CSysClassRegistry::GetInstance()->GetPointerID(*(void **)Val, &ClassID, &InstanceID); - if (*(void **)Val != NULL && (ClassID == -1 || InstanceID == -1)) { - Game->LOG(0, "Warning: invalid instance '%s'", Name); + CSysClassRegistry::GetInstance()->GetPointerID(*(void **)val, &ClassID, &InstanceID); + if (*(void **)val != NULL && (ClassID == -1 || InstanceID == -1)) { + Game->LOG(0, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(ClassID); _saveStream->writeUint32LE(InstanceID); - // PutDWORD(ClassID); - // PutDWORD(InstanceID); } else { ClassID = _loadStream->readUint32LE(); InstanceID = _loadStream->readUint32LE(); -/* ClassID = GetDWORD(); - InstanceID = GetDWORD();*/ - *(void **)Val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); + *(void **)val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); } return S_OK; @@ -839,13 +727,13 @@ HRESULT CBPersistMgr::Transfer(const char *Name, void *Val) { ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild) { +bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { if (_saving) return true; // it's ok if we are same or newer than the saved game - if (VerMajor > _savedVerMajor || - (VerMajor == _savedVerMajor && VerMinor > _savedVerMinor) || - (VerMajor == _savedVerMajor && VerMinor == _savedVerMinor && VerBuild > _savedVerBuild) + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) ) return false; return true; diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 12760bf6ca..79ec12214a 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -51,49 +51,48 @@ public: byte _savedExtMajor; byte _savedExtMinor; Common::String _savedName; - HRESULT SaveFile(const char *Filename); - uint32 GetDWORD(); - void PutDWORD(uint32 Val); - char *GetString(); - void PutString(const Common::String &Val); + HRESULT saveFile(const char *filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const Common::String &val); float getFloat(); void putFloat(float val); double getDouble(); void putDouble(double val); - void Cleanup(); - void getSaveStateDesc(int slot, SaveStateDescriptor& desc); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); void deleteSaveSlot(int slot); uint32 getMaxUsedSlot(); bool getSaveExists(int slot); - HRESULT InitLoad(const char *Filename); - HRESULT InitSave(const char *Desc); - HRESULT GetBytes(byte *Buffer, uint32 Size); - HRESULT PutBytes(byte *Buffer, uint32 Size); + HRESULT initLoad(const char *filename); + HRESULT initSave(const char *desc); + HRESULT getBytes(byte *buffer, uint32 size); + HRESULT putBytes(byte *buffer, uint32 size); uint32 _offset; - //uint32 _bufferSize; - //byte *_buffer; + bool _saving; uint32 _richBufferSize; byte *_richBuffer; - HRESULT Transfer(const char *Name, void *Val); - HRESULT Transfer(const char *Name, int *Val); - HRESULT Transfer(const char *Name, uint32 *Val); - HRESULT Transfer(const char *Name, float *Val); - HRESULT Transfer(const char *Name, double *Val); - HRESULT Transfer(const char *Name, bool *Val); - HRESULT Transfer(const char *Name, byte *Val); - HRESULT Transfer(const char *Name, RECT *Val); - HRESULT Transfer(const char *Name, POINT *Val); - HRESULT Transfer(const char *Name, const char **Val); - HRESULT Transfer(const char *Name, char **Val); - HRESULT Transfer(const char *Name, Common::String *val); - HRESULT Transfer(const char *Name, Vector2 *Val); - HRESULT Transfer(const char *Name, AnsiStringArray &Val); + HRESULT transfer(const char *name, void *val); + HRESULT transfer(const char *name, int *val); + HRESULT transfer(const char *name, uint32 *val); + HRESULT transfer(const char *name, float *val); + HRESULT transfer(const char *name, double *val); + HRESULT transfer(const char *name, bool *val); + HRESULT transfer(const char *name, byte *val); + HRESULT transfer(const char *name, RECT *val); + HRESULT transfer(const char *name, POINT *val); + HRESULT transfer(const char *name, const char **val); + HRESULT transfer(const char *name, char **val); + HRESULT transfer(const char *name, Common::String *val); + HRESULT transfer(const char *name, Vector2 *val); + HRESULT transfer(const char *name, AnsiStringArray &Val); CBPersistMgr(CBGame *inGame = NULL); virtual ~CBPersistMgr(); - bool CheckVersion(byte VerMajor, byte VerMinor, byte VerBuild); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); uint32 _thumbnailDataSize; byte *_thumbnailData; diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp index 943e6d7843..105159cb6c 100644 --- a/engines/wintermute/Base/BPoint.cpp +++ b/engines/wintermute/Base/BPoint.cpp @@ -53,10 +53,10 @@ CBPoint::CBPoint(int initX, int initY) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPoint::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBPoint::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(x)); - PersistMgr->Transfer(TMEMBER(y)); + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); return S_OK; } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index dd3c8db881..f7d3f5b2ef 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -406,16 +406,16 @@ HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOv ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBRegion::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_active)); - PersistMgr->Transfer(TMEMBER(_editorSelectedPoint)); - PersistMgr->Transfer(TMEMBER(_lastMimicScale)); - PersistMgr->Transfer(TMEMBER(_lastMimicX)); - PersistMgr->Transfer(TMEMBER(_lastMimicY)); - _points.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 2b575befa5..50a704421c 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -263,13 +263,13 @@ HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); +HRESULT CBScriptHolder::Persist(CBPersistMgr *persistMgr) { + CBScriptable::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_freezable)); - PersistMgr->Transfer(TMEMBER(_name)); - _scripts.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_name)); + _scripts.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index ef378500e2..715a1fef8c 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -139,11 +139,11 @@ void CBScriptable::ScSetBool(bool Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_refCount)); - PersistMgr->Transfer(TMEMBER(_scProp)); - PersistMgr->Transfer(TMEMBER(_scValue)); +HRESULT CBScriptable::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); return S_OK; } diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index 5df469934f..9a48484bfe 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -147,8 +147,8 @@ HRESULT CBSound::Resume() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { - if (PersistMgr->_saving && _sound) { +HRESULT CBSound::Persist(CBPersistMgr *persistMgr) { + if (persistMgr->_saving && _sound) { _soundPlaying = _sound->IsPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; @@ -157,23 +157,23 @@ HRESULT CBSound::Persist(CBPersistMgr *PersistMgr) { _soundFreezePaused = _sound->_freezePaused; } - if (PersistMgr->_saving) { + if (persistMgr->_saving) { _sFXType = SFX_NONE; _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } - PersistMgr->Transfer(TMEMBER(Game)); - - PersistMgr->Transfer(TMEMBER(_soundFilename)); - PersistMgr->Transfer(TMEMBER(_soundLooping)); - PersistMgr->Transfer(TMEMBER(_soundPaused)); - PersistMgr->Transfer(TMEMBER(_soundFreezePaused)); - PersistMgr->Transfer(TMEMBER(_soundPlaying)); - PersistMgr->Transfer(TMEMBER(_soundPosition)); - PersistMgr->Transfer(TMEMBER(_soundPrivateVolume)); - PersistMgr->Transfer(TMEMBER(_soundStreamed)); - PersistMgr->Transfer(TMEMBER_INT(_soundType)); - PersistMgr->Transfer(TMEMBER(_soundLoopStart)); + persistMgr->transfer(TMEMBER(Game)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); return S_OK; } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index bd3e2711d9..6ebaa0fa7b 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -472,32 +472,32 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Persist(CBPersistMgr *PersistMgr) { - CBScriptHolder::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_canBreak)); - PersistMgr->Transfer(TMEMBER(_changed)); - PersistMgr->Transfer(TMEMBER(_paused)); - PersistMgr->Transfer(TMEMBER(_continuous)); - PersistMgr->Transfer(TMEMBER(_currentFrame)); - PersistMgr->Transfer(TMEMBER(_editorAllFrames)); - PersistMgr->Transfer(TMEMBER(_editorBgAlpha)); - PersistMgr->Transfer(TMEMBER(_editorBgFile)); - PersistMgr->Transfer(TMEMBER(_editorBgOffsetX)); - PersistMgr->Transfer(TMEMBER(_editorBgOffsetY)); - PersistMgr->Transfer(TMEMBER(_editorMuted)); - PersistMgr->Transfer(TMEMBER(_finished)); - - _frames.Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_lastFrameTime)); - PersistMgr->Transfer(TMEMBER(_looping)); - PersistMgr->Transfer(TMEMBER(_moveX)); - PersistMgr->Transfer(TMEMBER(_moveY)); - PersistMgr->Transfer(TMEMBER(_owner)); - PersistMgr->Transfer(TMEMBER(_precise)); - PersistMgr->Transfer(TMEMBER(_streamed)); - PersistMgr->Transfer(TMEMBER(_streamedKeepLoaded)); +HRESULT CBSprite::Persist(CBPersistMgr *persistMgr) { + CBScriptHolder::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); return S_OK; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 392d65dc0d..ce7ffa3e9a 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -310,30 +310,30 @@ void CBSubFrame::SetDefaultRect() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_2DOnly)); - PersistMgr->Transfer(TMEMBER(_3DOnly)); - PersistMgr->Transfer(TMEMBER(_alpha)); - PersistMgr->Transfer(TMEMBER(_decoration)); - PersistMgr->Transfer(TMEMBER(_editorSelected)); - PersistMgr->Transfer(TMEMBER(_hotspotX)); - PersistMgr->Transfer(TMEMBER(_hotspotY)); - PersistMgr->Transfer(TMEMBER(_rect)); - - PersistMgr->Transfer(TMEMBER(_surfaceFilename)); - PersistMgr->Transfer(TMEMBER(_cKDefault)); - PersistMgr->Transfer(TMEMBER(_cKRed)); - PersistMgr->Transfer(TMEMBER(_cKGreen)); - PersistMgr->Transfer(TMEMBER(_cKBlue)); - PersistMgr->Transfer(TMEMBER(_lifeTime)); - - PersistMgr->Transfer(TMEMBER(_keepLoaded)); - PersistMgr->Transfer(TMEMBER(_mirrorX)); - PersistMgr->Transfer(TMEMBER(_mirrorY)); - PersistMgr->Transfer(TMEMBER(_transparent)); +HRESULT CBSubFrame::Persist(CBPersistMgr *persistMgr) { + + CBScriptable::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); return S_OK; } diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 5facd1682c..c5980719d7 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -148,14 +148,14 @@ HRESULT CBSurfaceStorage::RestoreAll() { /* ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::Persist(CBPersistMgr *PersistMgr) +HRESULT CBSurfaceStorage::Persist(CBPersistMgr *persistMgr) { - if(!PersistMgr->_saving) Cleanup(false); + if(!persistMgr->_saving) Cleanup(false); - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); - //_surfaces.Persist(PersistMgr); + //_surfaces.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index c8cff8f376..eef044bb50 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -49,14 +49,14 @@ CBViewport::~CBViewport() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBViewport::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_mainObject)); - PersistMgr->Transfer(TMEMBER(_offsetX)); - PersistMgr->Transfer(TMEMBER(_offsetY)); - PersistMgr->Transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); return S_OK; } diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 4bf6b8ece0..c7a9259a51 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -1098,97 +1098,97 @@ const char *CPartEmitter::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); +HRESULT CPartEmitter::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_width)); - PersistMgr->Transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_angle1)); - PersistMgr->Transfer(TMEMBER(_angle2)); + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); - PersistMgr->Transfer(TMEMBER(_velocity1)); - PersistMgr->Transfer(TMEMBER(_velocity2)); - PersistMgr->Transfer(TMEMBER(_velocityZBased)); + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); - PersistMgr->Transfer(TMEMBER(_scale1)); - PersistMgr->Transfer(TMEMBER(_scale2)); - PersistMgr->Transfer(TMEMBER(_scaleZBased)); + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); - PersistMgr->Transfer(TMEMBER(_maxParticles)); + persistMgr->transfer(TMEMBER(_maxParticles)); - PersistMgr->Transfer(TMEMBER(_lifeTime1)); - PersistMgr->Transfer(TMEMBER(_lifeTime2)); - PersistMgr->Transfer(TMEMBER(_lifeTimeZBased)); + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - PersistMgr->Transfer(TMEMBER(_genInterval)); - PersistMgr->Transfer(TMEMBER(_genAmount)); + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); - PersistMgr->Transfer(TMEMBER(_running)); - PersistMgr->Transfer(TMEMBER(_overheadTime)); + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); - PersistMgr->Transfer(TMEMBER(_border)); - PersistMgr->Transfer(TMEMBER(_borderThicknessLeft)); - PersistMgr->Transfer(TMEMBER(_borderThicknessRight)); - PersistMgr->Transfer(TMEMBER(_borderThicknessTop)); - PersistMgr->Transfer(TMEMBER(_borderThicknessBottom)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - PersistMgr->Transfer(TMEMBER(_fadeInTime)); - PersistMgr->Transfer(TMEMBER(_fadeOutTime)); + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); - PersistMgr->Transfer(TMEMBER(_alpha1)); - PersistMgr->Transfer(TMEMBER(_alpha2)); - PersistMgr->Transfer(TMEMBER(_alphaTimeBased)); + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); - PersistMgr->Transfer(TMEMBER(_angVelocity1)); - PersistMgr->Transfer(TMEMBER(_angVelocity2)); + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); - PersistMgr->Transfer(TMEMBER(_rotation1)); - PersistMgr->Transfer(TMEMBER(_rotation2)); + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); - PersistMgr->Transfer(TMEMBER(_growthRate1)); - PersistMgr->Transfer(TMEMBER(_growthRate2)); - PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); - PersistMgr->Transfer(TMEMBER(_useRegion)); + persistMgr->transfer(TMEMBER(_useRegion)); - PersistMgr->Transfer(TMEMBER_INT(_maxBatches)); - PersistMgr->Transfer(TMEMBER_INT(_batchesGenerated)); + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - PersistMgr->Transfer(TMEMBER(_emitEvent)); - PersistMgr->Transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); - _sprites.Persist(PersistMgr); + _sprites.Persist(persistMgr); int NumForces; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { NumForces = _forces.GetSize(); - PersistMgr->Transfer(TMEMBER(NumForces)); + persistMgr->transfer(TMEMBER(NumForces)); for (int i = 0; i < _forces.GetSize(); i++) { - _forces[i]->Persist(PersistMgr); + _forces[i]->Persist(persistMgr); } } else { - PersistMgr->Transfer(TMEMBER(NumForces)); + persistMgr->transfer(TMEMBER(NumForces)); for (int i = 0; i < NumForces; i++) { CPartForce *Force = new CPartForce(Game); - Force->Persist(PersistMgr); + Force->Persist(persistMgr); _forces.Add(Force); } } int NumParticles; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { NumParticles = _particles.GetSize(); - PersistMgr->Transfer(TMEMBER(NumParticles)); + persistMgr->transfer(TMEMBER(NumParticles)); for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->Persist(PersistMgr); + _particles[i]->Persist(persistMgr); } } else { - PersistMgr->Transfer(TMEMBER(NumParticles)); + persistMgr->transfer(TMEMBER(NumParticles)); for (int i = 0; i < NumParticles; i++) { CPartParticle *Particle = new CPartParticle(Game); - Particle->Persist(PersistMgr); + Particle->Persist(persistMgr); _particles.Add(Particle); } } diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp index 6389e38662..eb76a25469 100644 --- a/engines/wintermute/Base/PartForce.cpp +++ b/engines/wintermute/Base/PartForce.cpp @@ -47,11 +47,11 @@ CPartForce::~CPartForce(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartForce::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_direction)); - PersistMgr->Transfer(TMEMBER_INT(_type)); +HRESULT CPartForce::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); return S_OK; } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index cb276242c0..d6682e309b 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -216,32 +216,32 @@ HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_alpha1)); - PersistMgr->Transfer(TMEMBER(_alpha2)); - PersistMgr->Transfer(TMEMBER(_border)); - PersistMgr->Transfer(TMEMBER(_pos)); - PersistMgr->Transfer(TMEMBER(_posZ)); - PersistMgr->Transfer(TMEMBER(_velocity)); - PersistMgr->Transfer(TMEMBER(_scale)); - PersistMgr->Transfer(TMEMBER(_creationTime)); - PersistMgr->Transfer(TMEMBER(_lifeTime)); - PersistMgr->Transfer(TMEMBER(_isDead)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_fadeStart)); - PersistMgr->Transfer(TMEMBER(_fadeTime)); - PersistMgr->Transfer(TMEMBER(_currentAlpha)); - PersistMgr->Transfer(TMEMBER(_angVelocity)); - PersistMgr->Transfer(TMEMBER(_rotation)); - PersistMgr->Transfer(TMEMBER(_growthRate)); - PersistMgr->Transfer(TMEMBER(_exponentialGrowth)); - PersistMgr->Transfer(TMEMBER(_fadeStartAlpha)); - - if (PersistMgr->_saving) { - PersistMgr->Transfer(TMEMBER(_sprite->_filename)); +HRESULT CPartParticle::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); } else { char *Filename; - PersistMgr->Transfer(TMEMBER(Filename)); + persistMgr->transfer(TMEMBER(Filename)); CSysClassRegistry::GetInstance()->_disabled = true; SetSprite(Filename); CSysClassRegistry::GetInstance()->_disabled = false; diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index f976b4a00c..062cda4b83 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -75,7 +75,7 @@ HRESULT CBSaveThumbFile::Open(const Common::String &filename) { if (!pm) return E_FAIL; Game->_dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->InitLoad(slotFilename))) { + if (FAILED(pm->initLoad(slotFilename))) { Game->_dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index d9b3dfe455..f427a351af 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -199,11 +199,11 @@ HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::Persist(CBPersistMgr *PersistMgr) { - CBScriptable::Persist(PersistMgr); +HRESULT CSXArray::Persist(CBPersistMgr *persistMgr) { + CBScriptable::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_length)); - PersistMgr->Transfer(TMEMBER(_values)); + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 069e31b06b..d046d88294 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -238,15 +238,15 @@ HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::Persist(CBPersistMgr *PersistMgr) { - - CBScriptable::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER(_tm.tm_year)); - PersistMgr->Transfer(TMEMBER(_tm.tm_mon)); - PersistMgr->Transfer(TMEMBER(_tm.tm_mday)); - PersistMgr->Transfer(TMEMBER(_tm.tm_hour)); - PersistMgr->Transfer(TMEMBER(_tm.tm_min)); - PersistMgr->Transfer(TMEMBER(_tm.tm_sec)); +HRESULT CSXDate::Persist(CBPersistMgr *persistMgr) { + + CBScriptable::Persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index e7ac75c58b..7ebbf9fc50 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -689,20 +689,20 @@ uint32 CSXFile::GetLength() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) { +HRESULT CSXFile::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(PersistMgr); + CBScriptable::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_mode)); - PersistMgr->Transfer(TMEMBER(_textMode)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); uint32 Pos = 0; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { Pos = GetPos(); - PersistMgr->Transfer(TMEMBER(Pos)); + persistMgr->transfer(TMEMBER(Pos)); } else { - PersistMgr->Transfer(TMEMBER(Pos)); + persistMgr->transfer(TMEMBER(Pos)); // try to re-open file if needed _writeFile = NULL; diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 5005b885b8..68bad8c7d9 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -285,9 +285,9 @@ double CSXMath::RadianToDegree(double Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::Persist(CBPersistMgr *PersistMgr) { +HRESULT CSXMath::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(PersistMgr); + CBScriptable::Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 3a661b502c..4fd543663b 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -454,18 +454,18 @@ HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::Persist(CBPersistMgr *PersistMgr) { +HRESULT CSXMemBuffer::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(PersistMgr); + CBScriptable::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_size)); + persistMgr->transfer(TMEMBER(_size)); - if (PersistMgr->_saving) { - if (_size > 0) PersistMgr->PutBytes((byte *)_buffer, _size); + if (persistMgr->_saving) { + if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); } else { if (_size > 0) { _buffer = malloc(_size); - PersistMgr->GetBytes((byte *)_buffer, _size); + persistMgr->getBytes((byte *)_buffer, _size); } else _buffer = NULL; } diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 54280e8b29..4192e2f8d4 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -278,29 +278,29 @@ CScValue *CSXStore::ScGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); +HRESULT CSXStore::Persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) Cleanup(); - CBObject::Persist(PersistMgr); + CBObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_eventsEnabled)); - PersistMgr->Transfer(TMEMBER(_lastProductRequestOwner)); - PersistMgr->Transfer(TMEMBER(_lastPurchaseOwner)); - PersistMgr->Transfer(TMEMBER(_lastRestoreOwner)); - PersistMgr->Transfer(TMEMBER(_invalidProducts)); + persistMgr->transfer(TMEMBER(_eventsEnabled)); + persistMgr->transfer(TMEMBER(_lastProductRequestOwner)); + persistMgr->transfer(TMEMBER(_lastPurchaseOwner)); + persistMgr->transfer(TMEMBER(_lastRestoreOwner)); + persistMgr->transfer(TMEMBER(_invalidProducts)); // persist valid products int numProducts; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { numProducts = _validProducts.GetSize(); - PersistMgr->Transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(PersistMgr); + persistMgr->transfer(TMEMBER(numProducts)); + for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(persistMgr); } else { numProducts = _validProducts.GetSize(); - PersistMgr->Transfer(TMEMBER(numProducts)); + persistMgr->transfer(TMEMBER(numProducts)); for (int i = 0; i < numProducts; i++) { CBStoreProduct *prod = new CBStoreProduct; - prod->Persist(PersistMgr); + prod->Persist(persistMgr); _validProducts.Add(prod); } } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 0d73bb9c11..f4ccaa3bb7 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -60,11 +60,11 @@ public: delete [] _price; } - HRESULT Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(_id)); - PersistMgr->Transfer(TMEMBER(_name)); - PersistMgr->Transfer(TMEMBER(_desc)); - PersistMgr->Transfer(TMEMBER(_price)); + HRESULT Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_id)); + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_desc)); + persistMgr->transfer(TMEMBER(_price)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 16cb198671..7c0f11813a 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -377,18 +377,18 @@ HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::Persist(CBPersistMgr *PersistMgr) { +HRESULT CSXString::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(PersistMgr); + CBScriptable::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_capacity)); + persistMgr->transfer(TMEMBER(_capacity)); - if (PersistMgr->_saving) { - if (_capacity > 0) PersistMgr->PutBytes((byte *)_string, _capacity); + if (persistMgr->_saving) { + if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); } else { if (_capacity > 0) { _string = new char[_capacity]; - PersistMgr->GetBytes((byte *)_string, _capacity); + persistMgr->getBytes((byte *)_string, _capacity); } else _string = NULL; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index e8560bca6f..a4bb951dc2 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -564,14 +564,14 @@ HRESULT CScEngine::ResetScript(CScScript *Script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Persist(CBPersistMgr *PersistMgr) { - if (!PersistMgr->_saving) Cleanup(); - - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_currentScript)); - PersistMgr->Transfer(TMEMBER(_fileToCompile)); - PersistMgr->Transfer(TMEMBER(_globals)); - _scripts.Persist(PersistMgr); +HRESULT CScEngine::Persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) Cleanup(); + + persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_fileToCompile)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 49e3417946..20dd8fb156 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1153,58 +1153,58 @@ void CScScript::RuntimeError(LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Persist(CBPersistMgr *PersistMgr) { +HRESULT CScScript::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); // buffer - if (PersistMgr->_saving) { + if (persistMgr->_saving) { if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - PersistMgr->Transfer(TMEMBER(_bufferSize)); - PersistMgr->PutBytes(_buffer, _bufferSize); + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); } else { // don't save idle/finished scripts int bufferSize = 0; - PersistMgr->Transfer(TMEMBER(bufferSize)); + persistMgr->transfer(TMEMBER(bufferSize)); } } else { - PersistMgr->Transfer(TMEMBER(_bufferSize)); + persistMgr->transfer(TMEMBER(_bufferSize)); if (_bufferSize > 0) { _buffer = new byte[_bufferSize]; - PersistMgr->GetBytes(_buffer, _bufferSize); + persistMgr->getBytes(_buffer, _bufferSize); InitTables(); } else _buffer = NULL; } - PersistMgr->Transfer(TMEMBER(_callStack)); - PersistMgr->Transfer(TMEMBER(_currentLine)); - PersistMgr->Transfer(TMEMBER(_engine)); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_freezable)); - PersistMgr->Transfer(TMEMBER(_globals)); - PersistMgr->Transfer(TMEMBER(_iP)); - PersistMgr->Transfer(TMEMBER(_scopeStack)); - PersistMgr->Transfer(TMEMBER(_stack)); - PersistMgr->Transfer(TMEMBER_INT(_state)); - PersistMgr->Transfer(TMEMBER(_operand)); - PersistMgr->Transfer(TMEMBER_INT(_origState)); - PersistMgr->Transfer(TMEMBER(_owner)); - PersistMgr->Transfer(TMEMBER(_reg1)); - PersistMgr->Transfer(TMEMBER(_thread)); - PersistMgr->Transfer(TMEMBER(_threadEvent)); - PersistMgr->Transfer(TMEMBER(_thisStack)); - PersistMgr->Transfer(TMEMBER(_timeSlice)); - PersistMgr->Transfer(TMEMBER(_waitObject)); - PersistMgr->Transfer(TMEMBER(_waitScript)); - PersistMgr->Transfer(TMEMBER(_waitTime)); - PersistMgr->Transfer(TMEMBER(_waitFrozen)); - - PersistMgr->Transfer(TMEMBER(_methodThread)); - PersistMgr->Transfer(TMEMBER(_methodThread)); - PersistMgr->Transfer(TMEMBER(_unbreakable)); - PersistMgr->Transfer(TMEMBER(_parentScript)); - - if (!PersistMgr->_saving) _tracingMode = false; + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->_saving) _tracingMode = false; return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 26e8aa118b..100424bc2d 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -213,12 +213,12 @@ void CScStack::PushNative(CBScriptable *Val, bool Persistent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScStack::Persist(CBPersistMgr *PersistMgr) { +HRESULT CScStack::Persist(CBPersistMgr *persistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_sP)); - _values.Persist(PersistMgr); + persistMgr->transfer(TMEMBER(_sP)); + _values.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 517c1516ba..81828e3580 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -715,44 +715,44 @@ void CScValue::SetValue(CScValue *Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::Persist(CBPersistMgr *PersistMgr) { - PersistMgr->Transfer(TMEMBER(Game)); +HRESULT CScValue::Persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_persistent)); - PersistMgr->Transfer(TMEMBER(_isConstVar)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_valBool)); - PersistMgr->Transfer(TMEMBER(_valFloat)); - PersistMgr->Transfer(TMEMBER(_valInt)); - PersistMgr->Transfer(TMEMBER(_valNative)); + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); int size; const char *str; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { size = _valObject.size(); - PersistMgr->Transfer("", &size); + persistMgr->transfer("", &size); _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { str = _valIter->_key.c_str(); - PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &_valIter->_value); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); _valIter++; } } else { CScValue *val; - PersistMgr->Transfer("", &size); + persistMgr->transfer("", &size); for (int i = 0; i < size; i++) { - PersistMgr->Transfer("", &str); - PersistMgr->Transfer("", &val); + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); _valObject[str] = val; delete [] str; } } - PersistMgr->Transfer(TMEMBER(_valRef)); - PersistMgr->Transfer(TMEMBER(_valString)); + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); /* FILE* f = fopen("c:\\val.log", "a+"); diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 2785606338..a1760eeaa5 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -58,8 +58,8 @@ CSXObject::~CSXObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXObject::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); +HRESULT CSXObject::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index 730753cf18..f7be3d2449 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -128,24 +128,24 @@ void CSysClass::Dump(Common::WriteStream *stream) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr) { - PersistMgr->PutString(_name.c_str()); - PersistMgr->PutDWORD(_iD); - PersistMgr->PutDWORD(_instances.size()); +void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *persistMgr) { + persistMgr->putString(_name.c_str()); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD(_instances.size()); Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - PersistMgr->PutDWORD((it->_value)->GetID()); + persistMgr->putDWORD((it->_value)->GetID()); } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - _savedID = PersistMgr->GetDWORD(); - int numInstances = PersistMgr->GetDWORD(); +void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { + _savedID = persistMgr->getDWORD(); + int numInstances = persistMgr->getDWORD(); for (int i = 0; i < numInstances; i++) { - int instID = PersistMgr->GetDWORD(); + int instID = persistMgr->getDWORD(); if (_persistent) { if (i > 0) { @@ -173,22 +173,22 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr) { +void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr) { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { // write instace header - PersistMgr->PutString(""); - PersistMgr->PutDWORD(_iD); - PersistMgr->PutDWORD((it->_value)->GetID()); - PersistMgr->PutString(""); - _load((it->_value)->GetInstance(), PersistMgr); - PersistMgr->PutString(""); + persistMgr->putString(""); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD((it->_value)->GetID()); + persistMgr->putString(""); + _load((it->_value)->GetInstance(), persistMgr); + persistMgr->putString(""); } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadInstance(void *instance, CBPersistMgr *PersistMgr) { - _load(instance, PersistMgr); +void CSysClass::LoadInstance(void *instance, CBPersistMgr *persistMgr) { + _load(instance, persistMgr); } diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h index a2575c262c..2fdf3a31da 100644 --- a/engines/wintermute/Sys/SysClass.h +++ b/engines/wintermute/Sys/SysClass.h @@ -52,8 +52,8 @@ template<> struct Hash : public UnaryFunction { } }; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysInstance* val) const { +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysInstance *val) const { return (uint)((size_t)val); } }; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index a7d401c5bb..05412ae0e9 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -148,8 +148,8 @@ void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { else return (*it)._value->GetInstance(); } -bool checkHeader(const char* tag, CBPersistMgr *pm) { - char *test = pm->GetString(); +bool checkHeader(const char *tag, CBPersistMgr *pm) { + char *test = pm->getString(); Common::String verify = test; delete[] test; bool retVal = (verify == tag); @@ -160,9 +160,9 @@ bool checkHeader(const char* tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { - PersistMgr->PutString(""); - PersistMgr->PutDWORD(_classes.size()); +HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { + persistMgr->putString(""); + persistMgr->putDWORD(_classes.size()); int counter = 0; @@ -176,16 +176,16 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, boo Game->_renderer->Flip(); } - (it->_value)->SaveTable(Game, PersistMgr); + (it->_value)->SaveTable(Game, persistMgr); } - PersistMgr->PutString(""); + persistMgr->putString(""); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { - checkHeader("", PersistMgr); +HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { + checkHeader("", persistMgr); // reset SavedID of current instances Classes::iterator it; @@ -200,26 +200,26 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *PersistMgr) { _instanceMap.clear(); - int numClasses = PersistMgr->GetDWORD(); + int numClasses = persistMgr->getDWORD(); for (int i = 0; i < numClasses; i++) { Game->_indicatorProgress = 50.0f / (float)((float)numClasses / (float)i); Game->DisplayContentSimple(); Game->_renderer->Flip(); - char *className = PersistMgr->GetString(); + char *className = persistMgr->getString(); NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, PersistMgr); + if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, persistMgr); } - checkHeader("", PersistMgr); + checkHeader("", persistMgr); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave) { +HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { Classes::iterator it; @@ -229,7 +229,7 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, numInstances += (it->_value)->GetNumInstances(); } - PersistMgr->PutDWORD(numInstances); + persistMgr->putDWORD(numInstances); int counter = 0; for (it = _classes.begin(); it != _classes.end(); ++it) { @@ -244,16 +244,16 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, } Game->MiniUpdate(); - (it->_value)->SaveInstances(Game, PersistMgr); + (it->_value)->SaveInstances(Game, persistMgr); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) { +HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *persistMgr) { // get total instances - int numInstances = PersistMgr->GetDWORD(); + int numInstances = persistMgr->getDWORD(); for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { @@ -262,22 +262,22 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr) Game->_renderer->Flip(); } - checkHeader("", PersistMgr); + checkHeader("", persistMgr); - int classID = PersistMgr->GetDWORD(); - int instanceID = PersistMgr->GetDWORD(); + int classID = persistMgr->getDWORD(); + int instanceID = persistMgr->getDWORD(); void *instance = IDToPointer(classID, instanceID); - checkHeader("", PersistMgr); + checkHeader("", persistMgr); Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) { if ((it->_value)->GetSavedID() == classID) { - (it->_value)->LoadInstance(instance, PersistMgr); + (it->_value)->LoadInstance(instance, persistMgr); break; } } - checkHeader("", PersistMgr); + checkHeader("", persistMgr); } _savedInstanceMap.clear(); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 75cc3d5689..9decb4ea2a 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -1008,31 +1008,31 @@ const char *CUIButton::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER_INT(_align)); - PersistMgr->Transfer(TMEMBER(_backDisable)); - PersistMgr->Transfer(TMEMBER(_backFocus)); - PersistMgr->Transfer(TMEMBER(_backHover)); - PersistMgr->Transfer(TMEMBER(_backPress)); - PersistMgr->Transfer(TMEMBER(_centerImage)); - PersistMgr->Transfer(TMEMBER(_fontDisable)); - PersistMgr->Transfer(TMEMBER(_fontFocus)); - PersistMgr->Transfer(TMEMBER(_fontHover)); - PersistMgr->Transfer(TMEMBER(_fontPress)); - PersistMgr->Transfer(TMEMBER(_hover)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_imageDisable)); - PersistMgr->Transfer(TMEMBER(_imageFocus)); - PersistMgr->Transfer(TMEMBER(_imageHover)); - PersistMgr->Transfer(TMEMBER(_imagePress)); - PersistMgr->Transfer(TMEMBER(_pixelPerfect)); - PersistMgr->Transfer(TMEMBER(_press)); - PersistMgr->Transfer(TMEMBER(_stayPressed)); - - if (!PersistMgr->_saving) { +HRESULT CUIButton::Persist(CBPersistMgr *persistMgr) { + + CUIObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_backDisable)); + persistMgr->transfer(TMEMBER(_backFocus)); + persistMgr->transfer(TMEMBER(_backHover)); + persistMgr->transfer(TMEMBER(_backPress)); + persistMgr->transfer(TMEMBER(_centerImage)); + persistMgr->transfer(TMEMBER(_fontDisable)); + persistMgr->transfer(TMEMBER(_fontFocus)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_fontPress)); + persistMgr->transfer(TMEMBER(_hover)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_imageDisable)); + persistMgr->transfer(TMEMBER(_imageFocus)); + persistMgr->transfer(TMEMBER(_imageHover)); + persistMgr->transfer(TMEMBER(_imagePress)); + persistMgr->transfer(TMEMBER(_pixelPerfect)); + persistMgr->transfer(TMEMBER(_press)); + persistMgr->transfer(TMEMBER(_stayPressed)); + + if (!persistMgr->_saving) { _oneTimePress = false; _oneTimePressTime = 0; } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 54c85021c9..28f9671a6a 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -835,20 +835,20 @@ int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::Persist(CBPersistMgr *PersistMgr) { +HRESULT CUIEdit::Persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(PersistMgr); + CUIObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_cursorBlinkRate)); - PersistMgr->Transfer(TMEMBER(_cursorChar)); - PersistMgr->Transfer(TMEMBER(_fontSelected)); - PersistMgr->Transfer(TMEMBER(_frameWidth)); - PersistMgr->Transfer(TMEMBER(_maxLength)); - PersistMgr->Transfer(TMEMBER(_scrollOffset)); - PersistMgr->Transfer(TMEMBER(_selEnd)); - PersistMgr->Transfer(TMEMBER(_selStart)); + persistMgr->transfer(TMEMBER(_cursorBlinkRate)); + persistMgr->transfer(TMEMBER(_cursorChar)); + persistMgr->transfer(TMEMBER(_fontSelected)); + persistMgr->transfer(TMEMBER(_frameWidth)); + persistMgr->transfer(TMEMBER(_maxLength)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_selEnd)); + persistMgr->transfer(TMEMBER(_selStart)); - if (!PersistMgr->_saving) { + if (!persistMgr->_saving) { _cursorVisible = false; _lastBlinkTime = 0; } diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 97565603f3..ed0c9e1230 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -328,11 +328,11 @@ const char *CUIEntity::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::Persist(CBPersistMgr *PersistMgr) { +HRESULT CUIEntity::Persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(PersistMgr); + CUIObject::Persist(persistMgr); - PersistMgr->Transfer(TMEMBER(_entity)); + persistMgr->transfer(TMEMBER(_entity)); return S_OK; } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 3ef052da3e..4160bf1115 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -555,28 +555,28 @@ HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Persist(CBPersistMgr *PersistMgr) { - - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_back)); - PersistMgr->Transfer(TMEMBER(_canFocus)); - PersistMgr->Transfer(TMEMBER(_disable)); - PersistMgr->Transfer(TMEMBER(_focusedWidget)); - PersistMgr->Transfer(TMEMBER(_font)); - PersistMgr->Transfer(TMEMBER(_height)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_listenerObject)); - PersistMgr->Transfer(TMEMBER(_listenerParamObject)); - PersistMgr->Transfer(TMEMBER(_listenerParamDWORD)); - PersistMgr->Transfer(TMEMBER(_parent)); - PersistMgr->Transfer(TMEMBER(_parentNotify)); - PersistMgr->Transfer(TMEMBER(_sharedFonts)); - PersistMgr->Transfer(TMEMBER(_sharedImages)); - PersistMgr->Transfer(TMEMBER(_text)); - PersistMgr->Transfer(TMEMBER_INT(_type)); - PersistMgr->Transfer(TMEMBER(_visible)); - PersistMgr->Transfer(TMEMBER(_width)); +HRESULT CUIObject::Persist(CBPersistMgr *persistMgr) { + + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_back)); + persistMgr->transfer(TMEMBER(_canFocus)); + persistMgr->transfer(TMEMBER(_disable)); + persistMgr->transfer(TMEMBER(_focusedWidget)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_listenerObject)); + persistMgr->transfer(TMEMBER(_listenerParamObject)); + persistMgr->transfer(TMEMBER(_listenerParamDWORD)); + persistMgr->transfer(TMEMBER(_parent)); + persistMgr->transfer(TMEMBER(_parentNotify)); + persistMgr->transfer(TMEMBER(_sharedFonts)); + persistMgr->transfer(TMEMBER(_sharedImages)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_width)); return S_OK; } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index c2888e7393..f9ac91d422 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -467,11 +467,11 @@ const char *CUIText::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::Persist(CBPersistMgr *PersistMgr) { +HRESULT CUIText::Persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(PersistMgr); - PersistMgr->Transfer(TMEMBER_INT(_textAlign)); - PersistMgr->Transfer(TMEMBER_INT(_verticalAlign)); + CUIObject::Persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_textAlign)); + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); return S_OK; } diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index a38b6df54e..79c2278d0b 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -350,19 +350,19 @@ void CUITiledImage::CorrectSize(int *Width, int *Height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::Persist(CBPersistMgr *PersistMgr) { - CBObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_downLeft)); - PersistMgr->Transfer(TMEMBER(_downMiddle)); - PersistMgr->Transfer(TMEMBER(_downRight)); - PersistMgr->Transfer(TMEMBER(_image)); - PersistMgr->Transfer(TMEMBER(_middleLeft)); - PersistMgr->Transfer(TMEMBER(_middleMiddle)); - PersistMgr->Transfer(TMEMBER(_middleRight)); - PersistMgr->Transfer(TMEMBER(_upLeft)); - PersistMgr->Transfer(TMEMBER(_upMiddle)); - PersistMgr->Transfer(TMEMBER(_upRight)); +HRESULT CUITiledImage::Persist(CBPersistMgr *persistMgr) { + CBObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_downLeft)); + persistMgr->transfer(TMEMBER(_downMiddle)); + persistMgr->transfer(TMEMBER(_downRight)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_middleLeft)); + persistMgr->transfer(TMEMBER(_middleMiddle)); + persistMgr->transfer(TMEMBER(_middleRight)); + persistMgr->transfer(TMEMBER(_upLeft)); + persistMgr->transfer(TMEMBER(_upMiddle)); + persistMgr->transfer(TMEMBER(_upRight)); return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 94c76a60ea..b8f00fdb1e 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1150,31 +1150,31 @@ HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Persist(CBPersistMgr *PersistMgr) { - - CUIObject::Persist(PersistMgr); - - PersistMgr->Transfer(TMEMBER(_backInactive)); - PersistMgr->Transfer(TMEMBER(_clipContents)); - PersistMgr->Transfer(TMEMBER(_dragFrom)); - PersistMgr->Transfer(TMEMBER(_dragging)); - PersistMgr->Transfer(TMEMBER(_dragRect)); - PersistMgr->Transfer(TMEMBER(_fadeBackground)); - PersistMgr->Transfer(TMEMBER(_fadeColor)); - PersistMgr->Transfer(TMEMBER(_fontInactive)); - PersistMgr->Transfer(TMEMBER(_imageInactive)); - PersistMgr->Transfer(TMEMBER(_inGame)); - PersistMgr->Transfer(TMEMBER(_isMenu)); - PersistMgr->Transfer(TMEMBER_INT(_mode)); - PersistMgr->Transfer(TMEMBER(_shieldButton)); - PersistMgr->Transfer(TMEMBER(_shieldWindow)); - PersistMgr->Transfer(TMEMBER_INT(_titleAlign)); - PersistMgr->Transfer(TMEMBER(_titleRect)); - PersistMgr->Transfer(TMEMBER(_transparent)); - PersistMgr->Transfer(TMEMBER(_viewport)); - PersistMgr->Transfer(TMEMBER(_pauseMusic)); - - _widgets.Persist(PersistMgr); +HRESULT CUIWindow::Persist(CBPersistMgr *persistMgr) { + + CUIObject::Persist(persistMgr); + + persistMgr->transfer(TMEMBER(_backInactive)); + persistMgr->transfer(TMEMBER(_clipContents)); + persistMgr->transfer(TMEMBER(_dragFrom)); + persistMgr->transfer(TMEMBER(_dragging)); + persistMgr->transfer(TMEMBER(_dragRect)); + persistMgr->transfer(TMEMBER(_fadeBackground)); + persistMgr->transfer(TMEMBER(_fadeColor)); + persistMgr->transfer(TMEMBER(_fontInactive)); + persistMgr->transfer(TMEMBER(_imageInactive)); + persistMgr->transfer(TMEMBER(_inGame)); + persistMgr->transfer(TMEMBER(_isMenu)); + persistMgr->transfer(TMEMBER_INT(_mode)); + persistMgr->transfer(TMEMBER(_shieldButton)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER_INT(_titleAlign)); + persistMgr->transfer(TMEMBER(_titleRect)); + persistMgr->transfer(TMEMBER(_transparent)); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_pauseMusic)); + + _widgets.Persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index a5c02b313d..131a261bf1 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -88,7 +88,7 @@ public: // Clean up void FreeExtra(); void RemoveAll(); - HRESULT Persist(CBPersistMgr *PersistMgr); + HRESULT Persist(CBPersistMgr *persistMgr); // Accessing elements TYPE GetAt(int nIndex) const; @@ -346,21 +346,21 @@ void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { ///////////////////////////////////////////////////////////////////////////// template -HRESULT CBArray::Persist(CBPersistMgr *PersistMgr) { +HRESULT CBArray::Persist(CBPersistMgr *persistMgr) { int i, j; - if (PersistMgr->_saving) { + if (persistMgr->_saving) { j = GetSize(); - PersistMgr->Transfer("ArraySize", &j); + persistMgr->transfer("ArraySize", &j); for (i = 0; i < j; i++) { ARG_TYPE obj = GetAt(i); - PersistMgr->Transfer("", &obj); + persistMgr->transfer("", &obj); } } else { SetSize(0, -1); - PersistMgr->Transfer("ArraySize", &j); + persistMgr->transfer("ArraySize", &j); for (i = 0; i < j; i++) { ARG_TYPE obj; - PersistMgr->Transfer("", &obj); + persistMgr->transfer("", &obj); Add(obj); } } diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 8398578c2b..d52248ad4a 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -797,29 +797,29 @@ HRESULT CVidTheoraPlayer::resume() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *PersistMgr) { - //CBBase::Persist(PersistMgr); +HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *persistMgr) { + //CBBase::Persist(persistMgr); - if (PersistMgr->_saving) { + if (persistMgr->_saving) { _savedPos = getMovieTime() * 1000; _savedState = _state; } else { SetDefaults(); } - PersistMgr->Transfer(TMEMBER(Game)); - PersistMgr->Transfer(TMEMBER(_savedPos)); - PersistMgr->Transfer(TMEMBER(_savedState)); - PersistMgr->Transfer(TMEMBER(_filename)); - PersistMgr->Transfer(TMEMBER(_alphaFilename)); - PersistMgr->Transfer(TMEMBER(_posX)); - PersistMgr->Transfer(TMEMBER(_posY)); - PersistMgr->Transfer(TMEMBER(_playZoom)); - PersistMgr->Transfer(TMEMBER_INT(_playbackType)); - PersistMgr->Transfer(TMEMBER(_looping)); - PersistMgr->Transfer(TMEMBER(_volume)); - - if (!PersistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { + persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_savedPos)); + persistMgr->transfer(TMEMBER(_savedState)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_alphaFilename)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_playZoom)); + persistMgr->transfer(TMEMBER_INT(_playbackType)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_volume)); + + if (!persistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { initializeSimple(); } -- cgit v1.2.3 From b06f4ac72c2ea3d4b05ece81a60f699b0bf70086 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 13:59:28 +0200 Subject: WINTERMUTE: Fix a few warnings in BPersistMgr --- engines/wintermute/Base/BPersistMgr.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index c0cab7f865..795d7e3d03 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -682,9 +682,15 @@ HRESULT CBPersistMgr::transfer(const char *name, POINT *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) + return E_FAIL; + return S_OK; } else { val->x = _loadStream->readSint32LE(); val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; } } @@ -695,9 +701,15 @@ HRESULT CBPersistMgr::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); + if (_saveStream->err()) + return E_FAIL; + return S_OK; } else { val->x = getFloat(); val->y = getFloat(); + if (_loadStream->err()) + return E_FAIL; + return S_OK; } } -- cgit v1.2.3 From 4e33b8ea75719cbeaf9b62c527fd49e94abd6e3e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 14:10:08 +0200 Subject: WINTERMUTE: Run astyle on the source-files. --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdEntity.cpp | 12 +-- engines/wintermute/Ad/AdEntity.h | 2 +- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdScene.cpp | 4 +- engines/wintermute/Base/BFileManager.cpp | 24 ++--- engines/wintermute/Base/BFontTT.cpp | 38 +++---- engines/wintermute/Base/BGame.cpp | 128 +++++++++++------------ engines/wintermute/Base/BGame.h | 4 +- engines/wintermute/Base/BImage.cpp | 45 ++++---- engines/wintermute/Base/BImage.h | 8 +- engines/wintermute/Base/BKeyboardState.cpp | 10 +- engines/wintermute/Base/BParser.cpp | 2 +- engines/wintermute/Base/BRenderSDL.cpp | 18 ++-- engines/wintermute/Base/BResources.cpp | 2 +- engines/wintermute/Base/BResources.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 4 +- engines/wintermute/Base/BSoundBuffer.cpp | 2 +- engines/wintermute/Base/BSurface.h | 4 +- engines/wintermute/Base/BSurfaceSDL.cpp | 38 +++---- engines/wintermute/Base/BTransitionMgr.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 4 +- engines/wintermute/Base/PartEmitter.h | 4 +- engines/wintermute/Base/PartForce.cpp | 4 +- engines/wintermute/Base/PartForce.h | 4 +- engines/wintermute/Base/PartParticle.cpp | 4 +- engines/wintermute/Base/PartParticle.h | 4 +- engines/wintermute/Base/file/BDiskFile.cpp | 22 ++-- engines/wintermute/Base/file/BPkgFile.cpp | 32 ++++-- engines/wintermute/Base/scriptables/SXDate.cpp | 6 +- engines/wintermute/Base/scriptables/SXFile.cpp | 40 +++---- engines/wintermute/Base/scriptables/SXFile.h | 4 +- engines/wintermute/Base/scriptables/SXMath.cpp | 2 +- engines/wintermute/Base/scriptables/SXStore.cpp | 4 +- engines/wintermute/Base/scriptables/SXStore.h | 4 +- engines/wintermute/Base/scriptables/SXString.cpp | 32 +++--- engines/wintermute/Base/scriptables/ScEngine.cpp | 92 ++++++++-------- engines/wintermute/Base/scriptables/ScScript.cpp | 4 +- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- engines/wintermute/Base/scriptables/SxObject.h | 4 +- engines/wintermute/UI/UIEdit.cpp | 3 +- engines/wintermute/graphics/tga.cpp | 20 ++-- engines/wintermute/graphics/tga.h | 8 +- engines/wintermute/video/VidPlayer.cpp | 12 +-- engines/wintermute/video/VidPlayer.h | 4 +- engines/wintermute/video/VidTheoraPlayer.cpp | 88 ++++++++-------- engines/wintermute/video/VidTheoraPlayer.h | 12 +-- 49 files changed, 401 insertions(+), 377 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 3d4e77565a..68d173102e 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -1255,7 +1255,7 @@ int CAdActor::GetHeight() { ////////////////////////////////////////////////////////////////////////// CAdSpriteSet *CAdActor::GetAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.GetSize(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) + if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) return _anims[i]; } return NULL; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index f54f26d466..62b3156842 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -66,7 +66,7 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { _walkToX = _walkToY = 0; _walkToDir = DI_NONE; - + _theora = NULL; } @@ -606,7 +606,7 @@ HRESULT CAdEntity::Update() { Game->GetOffset(&OffsetX, &OffsetY); _theora->_posX = _posX - OffsetX; _theora->_posY = _posY - OffsetY; - + _theora->update(); if (_theora->isFinished()) { _theora->stop(); @@ -642,15 +642,15 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { Stack->CorrectParams(4); - const char* Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); bool Looping = Stack->Pop()->GetBool(false); - CScValue* ValAlpha = Stack->Pop(); + CScValue *ValAlpha = Stack->Pop(); int StartTime = Stack->Pop()->GetInt(); - + delete _theora; _theora = new CVidTheoraPlayer(Game); if (_theora && SUCCEEDED(_theora->initialize(Filename))) { - if (!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); + if (!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, Looping, StartTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; Stack->PushBool(true); diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index e8a55a16aa..6590007021 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -35,7 +35,7 @@ namespace WinterMute { class CVidTheoraPlayer; class CAdEntity : public CAdTalkHolder { public: - CVidTheoraPlayer* _theora; + CVidTheoraPlayer *_theora; HRESULT SetSprite(const char *Filename); int _walkToX; int _walkToY; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 938ad66b12..c20bf721de 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1690,7 +1690,7 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // fill black _renderer->Fill(0, 0, 0); if (!_editorMode) _renderer->SetScreenViewport(); - + // playing exclusive video? if (_videoPlayer->isPlaying()) { if (Update) _videoPlayer->update(); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 5cafa399e7..4f93a30a8e 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -834,7 +834,7 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const _forcedTalkAnimUsed = false; } - delete (_sentence->_sound); + delete(_sentence->_sound); _sentence->_sound = NULL; _sentence->SetText(Text); diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index afceaf8a31..26590af65f 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -502,7 +502,7 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { ClearResponses(); } else return CBObject::Listen(param1, param2); break; - default: + default: error("AdResponseBox::Listen - Unhandled enum"); } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 31d30356bd..cc51ddef22 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -2555,8 +2555,8 @@ float CAdScene::GetRotationAt(int X, int Y) { CAdRotLevel *next = NULL; for (int i = 0; i < _rotLevels.GetSize(); i++) { - /* CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.GetSize();*/ + /* CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.GetSize();*/ if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; else { next = _rotLevels[i]; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 990375ef73..90c0fffc39 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -168,7 +168,7 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); - + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(Filename); file->write(PrefixBuffer, PrefixSize); @@ -770,15 +770,15 @@ CBFileEntry *CBFileManager::GetPackageEntry(const Common::String &Filename) { Common::SeekableReadStream *CBFileManager::OpenFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; //Game->LOG(0, "open file: %s", Filename); -/*#ifdef __WIN32__ - if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(Filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); - } - } -#endif*/ + /*#ifdef __WIN32__ + if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(Filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); + } + } + #endif*/ Common::SeekableReadStream *File = OpenFileRaw(filename); if (File && keepTrackOf) _openFiles.Add(File); @@ -813,13 +813,13 @@ Common::SeekableReadStream *CBFileManager::OpenFileRaw(const Common::String &Fil } Common::SeekableReadStream *ret = NULL; - + ret = openDiskFile(Filename, this); if (ret) return ret; ret = openPkgFile(Filename, this); if (ret) return ret; - + ret = CBResources::getFile(Filename); if (ret) return ret; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 7592eff3bf..9f0e9e3b36 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -129,7 +129,7 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -146,7 +146,7 @@ int CBFontTT::GetTextHeight(byte *Text, int Width) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text); int textWidth, textHeight; @@ -160,11 +160,11 @@ int CBFontTT::GetTextHeight(byte *Text, int Width) { void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { if (Text == NULL || strcmp((char *)Text, "") == 0) return; - WideString text = (char*)Text; + WideString text = (char *)Text; // TODO: Why do we still insist on Widestrings everywhere? -/* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -262,7 +262,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex hasWarned = true; warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); } - warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color)); + warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color), D3DCOLGetB(_layers[0]->_color), D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); surface->create(width, _lineHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); @@ -271,12 +271,12 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex Common::Array::iterator it; int heightOffset = 0; for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); heightOffset += _lineHeight; } CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); surface->free(); @@ -655,10 +655,10 @@ HRESULT CBFontTT::InitFont() { if (file) { #ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4/3); // Compensate for the difference in dpi (96 vs 72). + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). _font = _deletableFont; #endif - } + } if (!_font) { _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); warning("BFontTT::InitFont - Couldn't load %s", _fontFile); @@ -854,7 +854,7 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, for (it = lines.begin(); it != lines.end(); it++) { textWidth = MAX(textWidth, _font->getStringWidth(*it)); } - + //WrapText(text, maxWidth, maxHeight, lines); textHeight = (int)(lines.size() * GetLineHeight()); @@ -862,14 +862,14 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, textWidth = _font->getStringWidth(text); textHeight = _fontHeight; } -/* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ } #if 0 diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 4c545b7a1c..def8c5137e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -446,9 +446,9 @@ HRESULT CBGame::Initialize1() { _scEngine = new CScEngine(this); if (_scEngine == NULL) goto init_fail; - + _videoPlayer = new CVidPlayer(this); - if (_videoPlayer==NULL) goto init_fail; + if (_videoPlayer == NULL) goto init_fail; _transMgr = new CBTransitionMgr(this); if (_transMgr == NULL) goto init_fail; @@ -525,21 +525,21 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) { warning("BGame::DEBUG_DebugEnable - No logfile is currently created"); //TODO: Use a dumpfile? #endif -/* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); -#endif*/ + #ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #endif*/ int secs = g_system->getMillis() / 1000; int hours = secs / 3600; secs = secs % 3600; int mins = secs / 60; secs = secs % 60; - + #ifdef _DEBUG LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); #else @@ -571,9 +571,9 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { #ifndef __IPHONEOS__ if (!_dEBUG_DebugMode) return; #endif -/* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow);*/ + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow);*/ int secs = g_system->getMillis() / 1000; int hours = secs / 3600; secs = secs % 3600; @@ -1395,42 +1395,40 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayVideo ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayVideo") == 0) { -/* Stack->CorrectParams(0); - Stack->PushBool(false); + /* Stack->CorrectParams(0); + Stack->PushBool(false); + + return S_OK; + // TODO: ADDVIDEO + */ - return S_OK; - // TODO: ADDVIDEO - */ - Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - + Stack->CorrectParams(6); - const char* Filename = Stack->Pop()->GetString(); + const char *Filename = Stack->Pop()->GetString(); warning("PlayVideo: %s - not implemented yet", Filename); - CScValue* valType = Stack->Pop(); + CScValue *valType = Stack->Pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - + int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); bool FreezeMusic = Stack->Pop()->GetBool(true); - - CScValue* valSub = Stack->Pop(); - const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); - - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + + CScValue *valSub = Stack->Pop(); + const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - + if (SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); - } - else Stack->PushBool(false); - } - else Stack->PushBool(false); - + } else Stack->PushBool(false); + } else Stack->PushBool(false); + return S_OK; } @@ -1438,27 +1436,27 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "PlayTheora") == 0) { -/* Stack->CorrectParams(0); - Stack->PushBool(false); + /* Stack->CorrectParams(0); + Stack->PushBool(false); - return S_OK;*/ + return S_OK;*/ // TODO: ADDVIDEO Stack->CorrectParams(7); - const char* Filename = Stack->Pop()->GetString(); - CScValue* valType = Stack->Pop(); + const char *Filename = Stack->Pop()->GetString(); + CScValue *valType = Stack->Pop(); int Type; - if (valType->IsNULL()) + if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - + int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); bool FreezeMusic = Stack->Pop()->GetBool(true); bool DropFrames = Stack->Pop()->GetBool(true); - - CScValue* valSub = Stack->Pop(); - const char* SubtitleFile = valSub->IsNULL()?NULL:valSub->GetString(); + + CScValue *valSub = Stack->Pop(); + const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; @@ -1469,15 +1467,13 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); - } - else Stack->PushBool(false); - } - else { + } else Stack->PushBool(false); + } else { Stack->PushBool(false); delete _theoraPlayer; _theoraPlayer = NULL; } - + return S_OK; } @@ -1813,7 +1809,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int FileNum = 0; - + while (true) { sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); if (!Common::File::exists(Filename)) @@ -2052,8 +2048,10 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AccOutputText") == 0) { Stack->CorrectParams(2); - /* const char *Str = */ Stack->Pop()->GetString(); - /* int Type = */ Stack->Pop()->GetInt(); + /* const char *Str = */ + Stack->Pop()->GetString(); + /* int Type = */ + Stack->Pop()->GetInt(); // do nothing Stack->PushNULL(); @@ -3388,7 +3386,7 @@ void CBGame::AfterLoadSound(void *Sound, void *Data) { ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadFont(void *Font, void *Data) { - ((CBFont*)Font)->AfterLoad(); + ((CBFont *)Font)->AfterLoad(); } ////////////////////////////////////////////////////////////////////////// @@ -3783,8 +3781,8 @@ HRESULT CBGame::Unfreeze() { ////////////////////////////////////////////////////////////////////////// bool CBGame::HandleKeypress(Common::Event *event, bool printable) { - if(IsVideoPlaying()) { - if(event->kbd.keycode == Common::KEYCODE_ESCAPE) + if (IsVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) StopVideo(); return true; } @@ -3812,14 +3810,14 @@ bool CBGame::HandleKeypress(Common::Event *event, bool printable) { if (_focusedWindow) { if (!Game->_focusedWindow->HandleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ - if (Game->_focusedWindow->CanHandleEvent("Keypress")) - Game->_focusedWindow->ApplyEvent("Keypress"); - else - ApplyEvent("Keypress"); + if (Game->_focusedWindow->CanHandleEvent("Keypress")) + Game->_focusedWindow->ApplyEvent("Keypress"); + else + ApplyEvent("Keypress"); /*}*/ } return true; - } else /*if (event->type != SDL_TEXTINPUT)*/ { + } else { /*if (event->type != SDL_TEXTINPUT)*/ ApplyEvent("Keypress"); return true; } //else return true; @@ -4192,7 +4190,7 @@ void CBGame::DEBUG_DumpClassRegistry() { f->open("zz_class_reg_dump.log"); CSysClassRegistry::GetInstance()->DumpClasses(f); - + f->close(); delete f; Game->QuickMessage("Classes dump completed."); @@ -4230,16 +4228,14 @@ HRESULT CBGame::SetWaitCursor(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsVideoPlaying() -{ +bool CBGame::IsVideoPlaying() { if (_videoPlayer->isPlaying()) return true; if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::StopVideo() -{ +HRESULT CBGame::StopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 4a660a91fb..e920fab2b9 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -263,8 +263,8 @@ public: HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); - CVidPlayer* _videoPlayer; - CVidTheoraPlayer* _theoraPlayer; + CVidPlayer *_videoPlayer; + CVidTheoraPlayer *_theoraPlayer; bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 6076b09963..2504850887 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -8,12 +8,12 @@ * 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. @@ -59,7 +59,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBImage::~CBImage() { -/* delete _bitmap; */ + /* delete _bitmap; */ delete _decoder; delete _deletableSurface; #if 0 @@ -83,21 +83,21 @@ HRESULT CBImage::loadFile(const Common::String &filename) { } else { error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); } - + Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename.c_str()); if (!file) return E_FAIL; - + _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); Game->_fileManager->CloseFile(file); - + return S_OK; } byte CBImage::getAlphaAt(int x, int y) { if (!_surface) return 0xFF; - uint32 color = *(uint32*)_surface->getBasePtr(x, y); + uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; _surface->format.colorToARGB(color, a, r, g, b); return a; @@ -149,9 +149,12 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { stream->writeByte('M'); /* Since we don't care during reads, we don't care during writes: */ - /* uint32 fileSize = */ stream->writeUint32LE(0); - /* uint16 res1 = */ stream->writeUint16LE(0); - /* uint16 res2 = */ stream->writeUint16LE(0); + /* uint32 fileSize = */ + stream->writeUint32LE(0); + /* uint16 res1 = */ + stream->writeUint16LE(0); + /* uint16 res2 = */ + stream->writeUint16LE(0); const uint32 imageOffset = 54; stream->writeUint32LE(imageOffset); @@ -165,12 +168,12 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { if (width == 0 || height == 0) return false; - + if (height < 0) { warning("Right-side up bitmaps not supported"); return false; } - + /* uint16 planes = */ stream->writeUint16LE(0); const uint16 bitsPerPixel = 24; stream->writeUint16LE(bitsPerPixel); @@ -178,12 +181,16 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { const uint32 compression = 0; stream->writeUint32LE(compression); - /* uint32 imageSize = */ stream->writeUint32LE(0); - /* uint32 pixelsPerMeterX = */ stream->writeUint32LE(0); - /* uint32 pixelsPerMeterY = */ stream->writeUint32LE(0); + /* uint32 imageSize = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterX = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ + stream->writeUint32LE(0); const uint32 paletteColorCount = 0; stream->writeUint32LE(paletteColorCount); - /* uint32 colorsImportant = */ stream->writeUint32LE(0); + /* uint32 colorsImportant = */ + stream->writeUint32LE(0); // Start us at the beginning of the image (54 bytes in) Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); @@ -199,14 +206,14 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { for (int32 i = height - 1; i >= 0; i--) { for (uint32 j = 0; j < width; j++) { - byte b,g,r; - uint32 color = *(uint32*)surface->getBasePtr(j, i); + byte b, g, r; + uint32 color = *(uint32 *)surface->getBasePtr(j, i); surface->format.colorToRGB(color, r, g, b); stream->writeByte(b); stream->writeByte(g); stream->writeByte(r); } - + for (int k = 0; k < extraDataLength; k++) { stream->writeByte(0); } diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 1161c97fa5..8b2cf70cc1 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -48,8 +48,12 @@ public: ~CBImage(); HRESULT loadFile(const Common::String &filename); - const Graphics::Surface *getSurface() const { return _surface; }; - const byte *getPalette() const { return _palette; } + const Graphics::Surface *getSurface() const { + return _surface; + }; + const byte *getPalette() const { + return _palette; + } byte getAlphaAt(int x, int y); bool writeBMPToStream(Common::WriteStream *stream); HRESULT Resize(int NewWidth, int NewHeight); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index cc25dd39a9..3f5d9b1225 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -46,7 +46,7 @@ CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { _currentShift = false; _currentAlt = false; _currentControl = false; - + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum for (int i = 0; i < 323; i++) { _keyStates[i] = false; @@ -66,7 +66,7 @@ void CBKeyboardState::handleKeyPress(Common::Event *event) { void CBKeyboardState::handleKeyRelease(Common::Event *event) { if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; + _keyStates[event->kbd.keycode] = false; } } @@ -198,8 +198,8 @@ const char *CBKeyboardState::ScToString() { HRESULT CBKeyboardState::ReadKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = KeyCodeToVKey(event); - if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { _currentPrintable = true; } else { _currentPrintable = false; @@ -225,7 +225,7 @@ HRESULT CBKeyboardState::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_currentKeyData)); persistMgr->transfer(TMEMBER(_currentPrintable)); persistMgr->transfer(TMEMBER(_currentShift)); - + if (!persistMgr->_saving) { _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum for (int i = 0; i < 323; i++) { diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp index e3887f1acb..d7d58241cc 100644 --- a/engines/wintermute/Base/BParser.cpp +++ b/engines/wintermute/Base/BParser.cpp @@ -181,7 +181,7 @@ char *CBParser::GetAssignmentText(char **buf) { break; ++*buf; } - **buf = 0; // null terminate it + **buf = 0; // null terminate it if (theChar) // skip the terminator ++*buf; } diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 83adca59f3..54119d3a7a 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -145,7 +145,7 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { g_system->beginGFXTransaction(); g_system->initSize(_width, _height, &format); OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - + if (gfxError != OSystem::kTransactionSuccess) { warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); return E_FAIL; @@ -275,7 +275,7 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { warning("Implement CBRenderSDL::FadeToColor"); // TODO. hasWarned = true; } - + Common::Rect fillRect; if (rect) { @@ -317,7 +317,7 @@ void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect mirror |= TransparentSurface::FLIP_V; if (mirrorY) mirror |= TransparentSurface::FLIP_H; - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect, _colorMod, dstRect->width(), dstRect->height() ); + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect, _colorMod, dstRect->width(), dstRect->height()); } void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { @@ -332,31 +332,31 @@ void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *s img = &src; } - int posX = dstRect->left; + int posX = dstRect->left; int posY = dstRect->top; - + // Handle off-screen clipping if (posY < 0) { img->h = MAX(0, (int)img->h - -posY); img->pixels = (byte *)img->pixels + img->pitch * -posY; posY = 0; } - + if (posX < 0) { img->w = MAX(0, (int)img->w - -posX); img->pixels = (byte *)img->pixels + (-posX * 4); posX = 0; } - + img->w = CLIP((int)img->w, 0, (int)MAX((int)_renderSurface->w - posX, 0)); img->h = CLIP((int)img->h, 0, (int)MAX((int)_renderSurface->h - posY, 0)); - + for (int i = 0; i < img->h; i++) { void *destPtr = _renderSurface->getBasePtr(posX, posY + i); void *srcPtr = img->getBasePtr(0, i); memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel * img->w); } - + if (imgScaled) { imgScaled->pixels = savedPixels; imgScaled->free(); diff --git a/engines/wintermute/Base/BResources.cpp b/engines/wintermute/Base/BResources.cpp index 3b6d0a264c..75b4a5d1ea 100644 --- a/engines/wintermute/Base/BResources.cpp +++ b/engines/wintermute/Base/BResources.cpp @@ -2806,7 +2806,7 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; -Common::SeekableReadStream *CBResources::getFile(const Common::String& fileName) { +Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { diff --git a/engines/wintermute/Base/BResources.h b/engines/wintermute/Base/BResources.h index f9a28865b4..6ec0541b5c 100644 --- a/engines/wintermute/Base/BResources.h +++ b/engines/wintermute/Base/BResources.h @@ -36,7 +36,7 @@ namespace WinterMute { class CBResources { public: - static Common::SeekableReadStream *getFile(const Common::String& fileName); + static Common::SeekableReadStream *getFile(const Common::String &fileName); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 50a704421c..efe8e5f195 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index c658cf5b31..a8c41cd022 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -260,7 +260,7 @@ void CBSoundBuffer::SetType(TSoundType Type) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetVolume(int Volume) { if (_stream && _handle) { - byte vol = Volume/100.f * Audio::Mixer::kMaxChannelVolume; + byte vol = Volume / 100.f * Audio::Mixer::kMaxChannelVolume; g_system->getMixer()->setChannelVolume(*_handle, vol); } return S_OK; diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index e91f03ca02..2e745b8ed4 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -63,7 +63,9 @@ public: virtual HRESULT restore(); virtual HRESULT create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; virtual HRESULT create(int Width, int Height); - virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return E_FAIL; } + virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return E_FAIL; + } virtual HRESULT putPixel(int x, int y, byte r, byte g, byte b, int a = -1); virtual HRESULT getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index e118bac384..618c155b36 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -83,14 +83,14 @@ bool hasTransparency(Graphics::Surface *surf) { warning("hasTransparency:: non 32 bpp surface passed as argument"); return false; } - uint8 r,g,b,a; + uint8 r, g, b, a; for (int i = 0; i < surf->h; i++) { for (int j = 0; j < surf->w; j++) { - uint32 pix = *(uint32*)surf->getBasePtr(j, i); + uint32 pix = *(uint32 *)surf->getBasePtr(j, i); surf->format.colorToARGB(pix, a, r, g, b); if (a != 255) { return true; - } + } } } return false; @@ -98,7 +98,7 @@ bool hasTransparency(Graphics::Surface *surf) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { -/* CBRenderSDL *renderer = static_cast(Game->_renderer); */ + /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(filename); CBImage *image = new CBImage(Game); image->loadFile(strFileName); @@ -138,10 +138,10 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, FreeImage_FlipVertical(img);*/ //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: -/* uint32 rmask = surface->format.rMax() << surface->format.rShift; - uint32 gmask = surface->format.gMax() << surface->format.gShift; - uint32 bmask = surface->format.bMax() << surface->format.bShift; - uint32 amask = surface->format.aMax();*/ + /* uint32 rmask = surface->format.rMax() << surface->format.rShift; + uint32 gmask = surface->format.gMax() << surface->format.gShift; + uint32 bmask = surface->format.bMax() << surface->format.bShift; + uint32 amask = surface->format.aMax();*/ // SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); @@ -165,7 +165,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, _surface = new Graphics::Surface(); _surface->copyFrom(*image->getSurface()); } - + _hasAlpha = hasTransparency(_surface); //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); @@ -210,7 +210,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, _valid = true; Game->AddMem(_width * _height * 4); - + delete image; return S_OK; @@ -280,11 +280,11 @@ uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { case 3: #ifdef SCUMM_BIG_ENDIAN - // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; #else //else - return p[0] | p[1] << 8 | p[2] << 16; + return p[0] | p[1] << 8 | p[2] << 16; #endif break; @@ -377,8 +377,8 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { hasWarned = true; } if (_surface->format.bytesPerPixel == 4) { - uint32 pixel = *(uint32*)_surface->getBasePtr(x, y); - uint8 r,g,b,a; + uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); + uint8 r, g, b, a; _surface->format.colorToARGB(pixel, a, r, g, b); if (a <= 128) { return true; @@ -482,7 +482,7 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo byte g = D3DCOLGetG(Alpha); byte b = D3DCOLGetB(Alpha); byte a = D3DCOLGetA(Alpha); - + renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); #if 0 @@ -506,14 +506,14 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo position.left = x + offsetX; position.top = y + offsetY; // TODO: Scaling... - + position.setWidth((float)srcRect.width() * ZoomX / 100.f); position.setHeight((float)srcRect.height() * ZoomX / 100.f); renderer->ModTargetRect(&position); -/* position.left += offsetX; - position.top += offsetY;*/ + /* position.left += offsetX; + position.top += offsetY;*/ // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 74553f3031..500f2a961d 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -115,7 +115,7 @@ HRESULT CBTransitionMgr::Update() { } break; default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); } if (IsReady()) { diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index c7a9259a51..39416377c8 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 98eed9e678..76d4bcdbd2 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp index eb76a25469..441831dc8c 100644 --- a/engines/wintermute/Base/PartForce.cpp +++ b/engines/wintermute/Base/PartForce.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h index 0754eebfdf..8bfc7ebf68 100644 --- a/engines/wintermute/Base/PartForce.h +++ b/engines/wintermute/Base/PartForce.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index d6682e309b..da97a702f8 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index e86c1004ae..a7f7c37a65 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index ce6a6a100c..c26b3f02c6 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -45,7 +45,7 @@ void correctSlashes(char *fileName) { } } -Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager) { +Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager) { char FullPath[MAX_PATH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; @@ -60,7 +60,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM delete tempFile; } } - + // if we didn't find it in search paths, try to open directly if (!file) { strcpy(FullPath, Filename.c_str()); @@ -73,28 +73,28 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM delete tempFile; } } - + if (file) { uint32 magic1, magic2; magic1 = file->readUint32LE(); magic2 = file->readUint32LE(); - + bool compressed = false; if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; - + if (compressed) { uint32 DataOffset, CompSize, UncompSize; DataOffset = file->readUint32LE(); CompSize = file->readUint32LE(); UncompSize = file->readUint32LE(); - + byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { error("Error allocating memory for compressed file '%s'", Filename.c_str()); delete file; return NULL; } - + byte *data = new byte[UncompSize]; if (!data) { error("Error allocating buffer for file '%s'", Filename.c_str()); @@ -104,16 +104,16 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM } file->seek(DataOffset + prefixSize, SEEK_SET); file->read(CompBuffer, CompSize); - + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { error("Error uncompressing file '%s'", Filename.c_str()); delete [] CompBuffer; delete file; return NULL; } - + delete [] CompBuffer; - + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); delete file; file = NULL; @@ -121,7 +121,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM file->seek(0, SEEK_SET); return file; } - + return file; } diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index ed3a24f313..02aec3419f 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -45,12 +45,24 @@ class CBPkgFile : public Common::SeekableReadStream { Common::SeekableReadStream *_stream; public: CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { delete _stream; } - virtual uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } - virtual bool eos() const { return _stream->eos(); } - virtual int32 pos() const { return _stream->pos(); } - virtual int32 size() const { return _size; } - virtual bool seek(int32 offset, int whence = SEEK_SET) { return _stream->seek(offset, whence); } + virtual ~CBPkgFile() { + delete _stream; + } + virtual uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } + virtual bool eos() const { + return _stream->eos(); + } + virtual int32 pos() const { + return _stream->pos(); + } + virtual int32 size() const { + return _size; + } + virtual bool seek(int32 offset, int whence = SEEK_SET) { + return _stream->seek(offset, whence); + } }; Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileManager *fileManager) { @@ -66,14 +78,14 @@ Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileMa fileEntry = fileManager->GetPackageEntry(fileName); if (!fileEntry) return NULL; - + file = fileEntry->_package->GetFilePointer(); if (!file) return NULL; - + // TODO: Cleanup bool compressed = (fileEntry->_compressedLength != 0); /* _size = fileEntry->_length; */ - + if (compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. @@ -86,7 +98,7 @@ Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileMa } file->seek(0); - + return file; } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index d046d88294..80905bba37 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -8,12 +8,12 @@ * 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. @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXDate, false) CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); + return new CSXDate(inGame, stack); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 7ebbf9fc50..cb883a9a7b 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -8,12 +8,12 @@ * 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. @@ -89,8 +89,8 @@ void CSXFile::Close() { Game->_fileManager->CloseFile(_readFile); _readFile = NULL; } - if ((FILE*)_writeFile) { - fclose((FILE*)_writeFile); + if ((FILE *)_writeFile) { + fclose((FILE *)_writeFile); _writeFile = NULL; } _mode = 0; @@ -312,9 +312,9 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } if (strcmp(Name, "WriteLine") == 0) - fprintf((FILE*)_writeFile, "%s\n", Line); + fprintf((FILE *)_writeFile, "%s\n", Line); else - fprintf((FILE*)_writeFile, "%s", Line); + fprintf((FILE *)_writeFile, "%s", Line); Stack->PushBool(true); @@ -461,7 +461,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -479,7 +479,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -497,7 +497,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -515,7 +515,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -533,7 +533,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -551,7 +551,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Stack->PushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE*)_writeFile); + fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); Stack->PushBool(true); return S_OK; @@ -571,8 +571,8 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } uint32 Size = strlen(Val); - fwrite(&Size, sizeof(Size), 1, (FILE*)_writeFile); - fwrite(Val, Size, 1, (FILE*)_writeFile); + fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile); + fwrite(Val, Size, 1, (FILE *)_writeFile); Stack->PushBool(true); @@ -665,14 +665,14 @@ HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// uint32 CSXFile::GetPos() { if (_mode == 1 && _readFile) return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE*)_writeFile); + else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE *)_writeFile); else return 0; } ////////////////////////////////////////////////////////////////////////// bool CSXFile::SetPos(uint32 pos, TSeek origin) { if (_mode == 1 && _readFile) return _readFile->seek(pos, origin); - else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE*)_writeFile, pos, (int)origin) == 0; + else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE *)_writeFile, pos, (int)origin) == 0; else return false; } @@ -680,10 +680,10 @@ bool CSXFile::SetPos(uint32 pos, TSeek origin) { uint32 CSXFile::GetLength() { if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { - uint32 CurrentPos = ftell((FILE*)_writeFile); - fseek((FILE*)_writeFile, 0, SEEK_END); - int Ret = ftell((FILE*)_writeFile); - fseek((FILE*)_writeFile, CurrentPos, SEEK_SET); + uint32 CurrentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int Ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); return Ret; } else return 0; } diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index 91cef4c1c5..8c37127f7b 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 68bad8c7d9..351fed9fe3 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CSXMath, true) CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); + return new CSXMath(inGame); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 4192e2f8d4..0e13f5d738 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index f4ccaa3bb7..2eff4b065f 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 7c0f11813a..65bf933d0a 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -8,12 +8,12 @@ * 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. @@ -271,7 +271,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Common::Array parts; - + Common::StringTokenizer tokenizer(str, delims); while (!tokenizer.empty()) { Common::String str2 = tokenizer.nextToken(); @@ -279,19 +279,19 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } // TODO: Clean this up /*do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; } while (pos != str.size());*/ diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a4bb951dc2..0083c55ee9 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -48,51 +48,51 @@ IMPLEMENT_PERSISTENT(CScEngine, true) CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { Game->LOG(0, "Initializing scripting engine..."); -/* -#ifdef __WIN32__ - char CompilerPath[MAX_PATH]; - strcpy(CompilerPath, COMPILER_DLL); - - _compilerDLL = ::LoadLibrary(CompilerPath); - if (_compilerDLL == NULL) { - char ModuleName[MAX_PATH]; - ::GetModuleFileName(NULL, ModuleName, MAX_PATH); - - // switch to exe's dir - char *ExeDir = CBUtils::GetPath(ModuleName); - sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); - _compilerDLL = ::LoadLibrary(CompilerPath); - - delete [] ExeDir; - } - if (_compilerDLL != NULL) { - // bind compiler's functionality - ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); - ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); - ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); - ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); - ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); - ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); - - if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { - _compilerAvailable = false; - ::FreeLibrary(_compilerDLL); - _compilerDLL = NULL; - } else { - */ /* - // publish external methods to the compiler - CALLBACKS c; - c.Dll_AddError = AddError; - c.Dll_CloseFile = CloseFile; - c.Dll_LoadFile = LoadFile; - ExtSetCallbacks(&c, Game); - */ -/* - _compilerAvailable = true; - } - } else _compilerAvailable = false; -#else -*/ + /* + #ifdef __WIN32__ + char CompilerPath[MAX_PATH]; + strcpy(CompilerPath, COMPILER_DLL); + + _compilerDLL = ::LoadLibrary(CompilerPath); + if (_compilerDLL == NULL) { + char ModuleName[MAX_PATH]; + ::GetModuleFileName(NULL, ModuleName, MAX_PATH); + + // switch to exe's dir + char *ExeDir = CBUtils::GetPath(ModuleName); + sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); + _compilerDLL = ::LoadLibrary(CompilerPath); + + delete [] ExeDir; + } + if (_compilerDLL != NULL) { + // bind compiler's functionality + ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); + ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); + ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); + ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); + ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); + ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); + + if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { + _compilerAvailable = false; + ::FreeLibrary(_compilerDLL); + _compilerDLL = NULL; + } else { + */ /* + // publish external methods to the compiler + CALLBACKS c; + c.Dll_AddError = AddError; + c.Dll_CloseFile = CloseFile; + c.Dll_LoadFile = LoadFile; + ExtSetCallbacks(&c, Game); + */ + /* + _compilerAvailable = true; + } + } else _compilerAvailable = false; + #else + */ _compilerAvailable = false; _compilerDLL = NULL; //#endif @@ -776,7 +776,7 @@ HRESULT CScEngine::LoadBreakpoints() { int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= Count; i++) { - /* uint32 BufSize = 512; */ + /* uint32 BufSize = 512; */ sprintf(Key, "Breakpoint%d", i); AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 20dd8fb156..638f4ab816 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -471,7 +471,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { dw = GetDWORD(); -/* char *Temp = _symbols[dw]; // TODO delete */ + /* char *Temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist if (!_engine->_globals->PropExists(_symbols[dw])) { _operand->SetNULL(); @@ -1544,7 +1544,7 @@ HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { // send scope variables if (_scopeStack->_sP >= 0) { for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); + // CScValue *Scope = _scopeStack->GetAt(i); //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index a1760eeaa5..9e33abdb2e 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/Base/scriptables/SxObject.h b/engines/wintermute/Base/scriptables/SxObject.h index 2a6ad36a58..35dab041d1 100644 --- a/engines/wintermute/Base/scriptables/SxObject.h +++ b/engines/wintermute/Base/scriptables/SxObject.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 28f9671a6a..f6224c5e90 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -773,7 +773,8 @@ bool CUIEdit::HandleKeypress(Common::Event *event, bool printable) { if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); - WideString wstr; wstr += (char)event->kbd.ascii; + WideString wstr; + wstr += (char)event->kbd.ascii; _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); if (Game->_textRTL) _selEnd = _selStart; diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp index 45d67756a0..1c0d73c6cd 100644 --- a/engines/wintermute/graphics/tga.cpp +++ b/engines/wintermute/graphics/tga.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Based on code from eos https://github.com/DrMcCoy/xoreos/ +/* Based on code from eos https://github.com/DrMcCoy/xoreos/ * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 */ @@ -33,7 +33,7 @@ namespace WinterMute { TGA::TGA() { - + } TGA::~TGA() { @@ -45,10 +45,10 @@ void TGA::destroy() { } bool TGA::loadStream(Common::SeekableReadStream &tga) { - byte imageType, pixelDepth; - bool success; - success = readHeader(tga, imageType, pixelDepth); - success = readData (tga, imageType, pixelDepth); + byte imageType, pixelDepth; + bool success; + success = readHeader(tga, imageType, pixelDepth); + success = readData(tga, imageType, pixelDepth); if (tga.err() || !success) { warning("Failed reading TGA-file"); @@ -93,10 +93,10 @@ bool TGA::readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pix if (imageType == 2) { if (pixelDepth == 24) { _hasAlpha = false; - _format = Graphics::PixelFormat(pixelDepth/8, 8, 8, 8, 0, 16, 8, 0, 0); + _format = Graphics::PixelFormat(pixelDepth / 8, 8, 8, 8, 0, 16, 8, 0, 0); } else if (pixelDepth == 16 || pixelDepth == 32) { _hasAlpha = true; - _format = Graphics::PixelFormat(pixelDepth/8, 8, 8, 8, 8, 24, 16, 8, 0); + _format = Graphics::PixelFormat(pixelDepth / 8, 8, 8, 8, 8, 24, 16, 8, 0); } else { warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); return false; @@ -127,7 +127,7 @@ bool TGA::readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDe // Convert from 16bpp to 32bpp // 16bpp TGA is ARGB1555 uint16 count = _surface.w * _surface.h; - byte *dst = (byte*)_surface.pixels; + byte *dst = (byte *)_surface.pixels; while (count--) { uint16 pixel = tga.readUint16LE(); @@ -145,7 +145,7 @@ bool TGA::readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDe } else if (imageType == 3) { _surface.create(_surface.w, _surface.h, _surface.format); - byte *data = (byte*)_surface.pixels; + byte *data = (byte *)_surface.pixels; uint32 count = _surface.w * _surface.h; while (count-- > 0) { diff --git a/engines/wintermute/graphics/tga.h b/engines/wintermute/graphics/tga.h index 727d10c1a3..b3b46fb529 100644 --- a/engines/wintermute/graphics/tga.h +++ b/engines/wintermute/graphics/tga.h @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Based on code from eos https://github.com/DrMcCoy/xoreos/ +/* Based on code from eos https://github.com/DrMcCoy/xoreos/ * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 */ @@ -30,7 +30,7 @@ #include "graphics/decoders/image_decoder.h" namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace WinterMute { @@ -41,7 +41,9 @@ public: TGA(); virtual ~TGA(); virtual void destroy(); - virtual const Graphics::Surface *getSurface() const { return &_surface; }; + virtual const Graphics::Surface *getSurface() const { + return &_surface; + }; virtual bool loadStream(Common::SeekableReadStream &stream); private: Graphics::PixelFormat _format; diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index cd693f0b3f..73d6fffb6b 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -48,14 +48,14 @@ CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { HRESULT CVidPlayer::SetDefaults() { _playing = false; -/* _aviFile = NULL; + /* _aviFile = NULL; - _audioStream = NULL; - _audioFormat = NULL; + _audioStream = NULL; + _audioFormat = NULL; - _videoStream = NULL; - _videoFormat = NULL; - _videoPGF = NULL;*/ + _videoStream = NULL; + _videoFormat = NULL; + _videoPGF = NULL;*/ _videoEndTime = 0; //_sound = NULL; diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index eca9a96782..f3dfa97e33 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -83,9 +83,9 @@ public: int _playPosY; float _playZoom; -/* LPBITMAPV4HEADER _targetFormat; + /* LPBITMAPV4HEADER _targetFormat; - CBArray _subtitles;*/ + CBArray _subtitles;*/ }; } // end of namespace WinterMute diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d52248ad4a..d44231d0d0 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -8,12 +8,12 @@ * 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. @@ -77,11 +77,11 @@ void CVidTheoraPlayer::SetDefaults() { _seekingKeyframe = false; _timeOffset = 0.0f; - + _posX = _posY = 0; _playbackType = VID_PLAY_CENTER; _playZoom = 0.0f; - + _savedState = THEORA_STATE_NONE; _savedPos = 0; _volume = 100; @@ -99,10 +99,10 @@ void CVidTheoraPlayer::SetDefaults() { CVidTheoraPlayer::~CVidTheoraPlayer(void) { cleanup(); -/* SAFE_DELETE_ARRAY(_filename); - SAFE_DELETE_ARRAY(_alphaFilename); - SAFE_DELETE(_texture); - SAFE_DELETE(_alphaImage);*/ + /* SAFE_DELETE_ARRAY(_filename); + SAFE_DELETE_ARRAY(_alphaFilename); + SAFE_DELETE(_texture); + SAFE_DELETE(_alphaImage);*/ // SAFE_DELETE(_subtitler); } @@ -134,7 +134,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _filename = filename; _file = Game->_fileManager->OpenFile(filename, true, false); if (!_file) return E_FAIL; - + //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); @@ -142,10 +142,10 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo return E_FAIL; #endif _theoraDecoder->loadStream(_file); - + if (!_theoraDecoder->isVideoLoaded()) return E_FAIL; - + _state = THEORA_STATE_PAUSED; // Additional setup. @@ -154,7 +154,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; - + return S_OK; #if 0 Cleanup(); @@ -343,17 +343,17 @@ HRESULT CVidTheoraPlayer::resetStream() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { - if (forceZoom < 0.0f) + if (forceZoom < 0.0f) forceZoom = 100.0f; - if (volume < 0) + if (volume < 0) _volume = Game->_soundMgr->getVolumePercent(SOUND_SFX); else _volume = volume; - + _freezeGame = freezeGame; - - if (!_playbackStarted && _freezeGame) + + if (!_playbackStarted && _freezeGame) Game->Freeze(freezeMusic); - + _playbackStarted = false; float width, height; if (_theoraDecoder) { @@ -367,7 +367,7 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam _posX = x; _posY = y; _playZoom = forceZoom; - + width = (float)_theoraDecoder->getWidth(); height = (float)_theoraDecoder->getHeight(); } else { @@ -376,26 +376,26 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam } switch (type) { - case VID_PLAY_POS: - _playZoom = forceZoom; - _posX = x; - _posY = y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->_width / width * 100); - float ZoomY = (float)((float)Game->_renderer->_height / height * 100); - _playZoom = MIN(ZoomX, ZoomY); - _posX = (Game->_renderer->_width - width * (_playZoom / 100)) / 2; - _posY = (Game->_renderer->_height - height * (_playZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - _playZoom = 100.0f; - _posX = (Game->_renderer->_width - width) / 2; - _posY = (Game->_renderer->_height - height) / 2; - break; + case VID_PLAY_POS: + _playZoom = forceZoom; + _posX = x; + _posY = y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)Game->_renderer->_width / width * 100); + float ZoomY = (float)((float)Game->_renderer->_height / height * 100); + _playZoom = MIN(ZoomX, ZoomY); + _posX = (Game->_renderer->_width - width * (_playZoom / 100)) / 2; + _posY = (Game->_renderer->_height - height * (_playZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _posX = (Game->_renderer->_width - width) / 2; + _posY = (Game->_renderer->_height - height) / 2; + break; } return S_OK; #if 0 @@ -613,7 +613,7 @@ HRESULT CVidTheoraPlayer::WriteVideo() { if (!_texture) return E_FAIL; _texture->startPixelOp(); - + writeAlpha(); if (_alphaImage) { _texture->putSurface(_surface, true); @@ -632,10 +632,10 @@ void CVidTheoraPlayer::writeAlpha() { if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); - const byte *alphaData = (byte*)_alphaImage->getSurface()->getBasePtr(0, 0); + const byte *alphaData = (byte *)_alphaImage->getSurface()->getBasePtr(0, 0); int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); alphaData += alphaPlace; - byte *imgData = (byte*)_surface.getBasePtr(0,0); + byte *imgData = (byte *)_surface.getBasePtr(0, 0); imgData += (_surface.format.aShift / 8); for (int i = 0; i < _surface.w * _surface.h; i++) { *imgData = *alphaData; @@ -664,7 +664,7 @@ HRESULT CVidTheoraPlayer::display(uint32 alpha) { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); - + delete _alphaImage; _alphaImage = new CBImage(Game); if (!_alphaImage || FAILED(_alphaImage->loadFile(filename))) { @@ -673,7 +673,7 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { _alphaFilename = ""; return E_FAIL; } - + if (_alphaFilename != filename) { _alphaFilename = filename; } diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 2c103095a1..43be1801a0 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -8,12 +8,12 @@ * 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. @@ -42,10 +42,10 @@ namespace WinterMute { class CVidTheoraPlayer : public CBBase { private: enum { - THEORA_STATE_NONE = 0, - THEORA_STATE_PLAYING = 1, - THEORA_STATE_PAUSED = 2, - THEORA_STATE_FINISHED = 3 + THEORA_STATE_NONE = 0, + THEORA_STATE_PLAYING = 1, + THEORA_STATE_PAUSED = 2, + THEORA_STATE_FINISHED = 3 }; Video::RewindableVideoDecoder *_theoraDecoder; Graphics::Surface _surface; -- cgit v1.2.3 From 759024d51ad11002ef1c9a2f98b7982602cb39f0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 14:13:18 +0200 Subject: WINTERMUTE: Remove FontGlyphCache. --- engines/wintermute/Base/BFontTT.cpp | 5 -- engines/wintermute/Base/BFontTT.h | 7 -- engines/wintermute/FontGlyphCache.cpp | 102 --------------------------- engines/wintermute/FontGlyphCache.h | 125 ---------------------------------- engines/wintermute/module.mk | 1 - 5 files changed, 240 deletions(-) delete mode 100644 engines/wintermute/FontGlyphCache.cpp delete mode 100644 engines/wintermute/FontGlyphCache.h (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 9f0e9e3b36..0d2f39f730 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/file/BFile.h" #include "engines/wintermute/Base/BFontTT.h" -#include "engines/wintermute/FontGlyphCache.h" #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/math/MathUtil.h" @@ -64,7 +63,6 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { _fTFace = NULL; _fTStream = NULL; #endif - _glyphCache = NULL; _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; _horDpi = _vertDpi = 0; @@ -86,8 +84,6 @@ CBFontTT::~CBFontTT(void) { delete _deletableFont; _font = NULL; - delete _glyphCache; - _glyphCache = NULL; #if 0 if (_fTFace) { FT_Done_Face(_fTFace); @@ -625,7 +621,6 @@ HRESULT CBFontTT::Persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _glyphCache = NULL; _fallbackFont = _font = _deletableFont = NULL; } diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 127c727922..418efb3e9b 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -40,8 +40,6 @@ namespace WinterMute { -class FontGlyphCache; - class CBFontTT : public CBFont { private: ////////////////////////////////////////////////////////////////////////// @@ -128,10 +126,6 @@ public: HRESULT LoadBuffer(byte *buffer); HRESULT LoadFile(const char *filename); - FontGlyphCache *GetGlyphCache() { - return _glyphCache; - } - float GetLineHeight() const { return _lineHeight; } @@ -156,7 +150,6 @@ private: Graphics::Font *_deletableFont; const Graphics::Font *_font; const Graphics::Font *_fallbackFont; - FontGlyphCache *_glyphCache; float _ascender; float _descender; diff --git a/engines/wintermute/FontGlyphCache.cpp b/engines/wintermute/FontGlyphCache.cpp deleted file mode 100644 index 73dc3d2ff1..0000000000 --- a/engines/wintermute/FontGlyphCache.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "FontGlyphCache.h" - -namespace WinterMute { -#if 0 -////////////////////////////////////////////////////////////////////////// -FontGlyphCache::FontGlyphCache() { -} - -////////////////////////////////////////////////////////////////////////// -FontGlyphCache::~FontGlyphCache() { - GlyphInfoMap::iterator it; - - for (it = _glyphs.begin(); it != _glyphs.end(); ++it) { - delete it->_value; - it->_value = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -bool FontGlyphCache::HasGlyph(wchar_t ch) { - return (_glyphs.find(ch) != _glyphs.end()); -} - -////////////////////////////////////////////////////////////////////////// -void FontGlyphCache::Initialize() { -} - -////////////////////////////////////////////////////////////////////////// -GlyphInfo *FontGlyphCache::GetGlyph(wchar_t ch) { - GlyphInfoMap::const_iterator it; - it = _glyphs.find(ch); - if (it == _glyphs.end()) return NULL; - - return it->_value; -} -/* -////////////////////////////////////////////////////////////////////////// -void FontGlyphCache::AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride) { - if (stride == 0) stride = width; - - _glyphs[ch] = new GlyphInfo(glyphIndex); - _glyphs[ch]->SetGlyphInfo(glyphSlot->advance.x / 64.f, glyphSlot->advance.y / 64.f, glyphSlot->bitmap_left, glyphSlot->bitmap_top); - _glyphs[ch]->SetGlyphImage(width, height, stride, pixels); -} -*/ - -////////////////////////////////////////////////////////////////////////// -void GlyphInfo::SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels) { - warning("GlyphInfo::SetGlyphImage - Not ported yet"); -#if 0 - if (_image) SDL_FreeSurface(_image); - - _image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - SDL_LockSurface(_image); - - Uint8 *buf = (Uint8 *)_image->pixels; - - for (int y = 0; y < height; y++) { - Uint32 *buf32 = (Uint32 *)buf; - - for (int x = 0; x < width; x++) { - byte alpha = pixels[y * stride + x]; - Uint32 color = SDL_MapRGBA(_image->format, 255, 255, 255, alpha); - buf32[x] = color; - } - - buf += _image->pitch; - } - - SDL_UnlockSurface(_image); -#endif -} -#endif -} // end of namespace WinterMute diff --git a/engines/wintermute/FontGlyphCache.h b/engines/wintermute/FontGlyphCache.h deleted file mode 100644 index bb36c0d864..0000000000 --- a/engines/wintermute/FontGlyphCache.h +++ /dev/null @@ -1,125 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_FONTGLYPHCACHE_H -#define WINTERMUTE_FONTGLYPHCACHE_H - - -#include "engines/wintermute/Base/BFontStorage.h" -#include "graphics/surface.h" - -namespace WinterMute { -#if 0 -////////////////////////////////////////////////////////////////////////// -class GlyphInfo { -public: - GlyphInfo(int glyphIndex) { - _glyphIndex = glyphIndex; - _advanceX = _advanceY = 0; - _bearingX = _bearingY = 0; - - _width = _height = 0; - - _image = NULL; - } - - ~GlyphInfo() { - // TODO - //if (_image) SDL_FreeSurface(_image); - } - - void SetGlyphInfo(float AdvanceX, float AdvanceY, int BearingX, int BearingY) { - _advanceX = AdvanceX; - _advanceY = AdvanceY; - _bearingX = BearingX; - _bearingY = BearingY; - } - - void SetGlyphImage(size_t width, size_t height, size_t stride, byte *pixels); - - int GetGlyphIndex() { - return _glyphIndex; - } - int GetWidth() { - return _width; - } - int GetHeight() { - return _height; - } - float GetAdvanceX() { - return _advanceX; - } - float GetAdvanceY() { - return _advanceY; - } - int GetBearingX() { - return _bearingX; - } - int GetBearingY() { - return _bearingY; - } - Graphics::Surface *GetImage() { - return _image; - } - -private: - int _glyphIndex; - - float _advanceX; - float _advanceY; - int _bearingX; - int _bearingY; - - int _width; - int _height; - - Graphics::Surface *_image; -}; - - - -////////////////////////////////////////////////////////////////////////// -class FontGlyphCache { -public: - FontGlyphCache(); - virtual ~FontGlyphCache(); - - void Initialize(); - bool HasGlyph(wchar_t ch); - GlyphInfo *GetGlyph(wchar_t ch); - //void AddGlyph(wchar_t ch, int glyphIndex, FT_GlyphSlot glyphSlot, size_t width, size_t height, byte *pixels, size_t stride = 0); - -private: - //typedef Common::HashMap GlyphInfoMap; - typedef Common::HashMap GlyphInfoMap; // TODO - GlyphInfoMap _glyphs; -}; -#endif -} // end of namespace WinterMute - -#endif // WINTERMUTE_FONTGLYPHCACHE_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 64c334d0eb..6c263ede22 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -88,7 +88,6 @@ MODULE_OBJS := \ Base/PartEmitter.o \ Base/PartForce.o \ detection.o \ - FontGlyphCache.o \ graphics/transparentSurface.o \ graphics/tga.o \ math/MathUtil.o \ -- cgit v1.2.3 From 853e7c8900c1cee8e6f44119f0440ce743c9bb08 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 14:30:58 +0200 Subject: WINTERMUTE: Fix another enum-warning. --- engines/wintermute/Ad/AdItem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index fd792b3f5b..366efefdc1 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -376,6 +376,7 @@ HRESULT CAdItem::Update() { ((CAdGame *)Game)->AddSentence(_sentence); } } + default: break; } _ready = (_state == STATE_READY); -- cgit v1.2.3 From 2e34a25040c4f95e62ce899be5521d7e5e76d095 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 18:56:10 +0200 Subject: WINTERMUTE: Get rid of the global constructions. --- engines/wintermute/module.mk | 4 +- engines/wintermute/persistent.cpp | 169 ++++++++++++++++++++++++++++++++++++++ engines/wintermute/persistent.h | 4 +- engines/wintermute/wintermute.cpp | 1 + 4 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 engines/wintermute/persistent.cpp (limited to 'engines') diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 6c263ede22..4fe22fc795 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -47,6 +47,7 @@ MODULE_OBJS := \ Base/BBase.o \ Base/BDebugger.o \ Base/BDynBuffer.o \ + Base/BEvent.o \ Base/BFader.o \ Base/BFileEntry.o \ Base/BFileManager.o \ @@ -116,7 +117,8 @@ MODULE_OBJS := \ video/VidPlayer.o \ video/VidTheoraPlayer.o \ video/decoders/theora_decoder.o \ - wintermute.o + wintermute.o \ + persistent.o MODULE_DIRS += \ engines/wintermute diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp new file mode 100644 index 0000000000..347d0e822d --- /dev/null +++ b/engines/wintermute/persistent.cpp @@ -0,0 +1,169 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Ad/AdActor.h" +#include "engines/wintermute/Ad/AdEntity.h" +#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/Ad/AdInventory.h" +#include "engines/wintermute/Ad/AdInventoryBox.h" +#include "engines/wintermute/Ad/AdItem.h" +#include "engines/wintermute/Ad/AdLayer.h" +#include "engines/wintermute/Ad/AdNodeState.h" +#include "engines/wintermute/Ad/AdObject.h" +#include "engines/wintermute/Ad/AdPath.h" +#include "engines/wintermute/Ad/AdPathPoint.h" +#include "engines/wintermute/Ad/AdRegion.h" +#include "engines/wintermute/Ad/AdResponse.h" +#include "engines/wintermute/Ad/AdResponseBox.h" +#include "engines/wintermute/Ad/AdResponseContext.h" +#include "engines/wintermute/Ad/AdRotLevel.h" +#include "engines/wintermute/Ad/AdScaleLevel.h" +#include "engines/wintermute/Ad/AdScene.h" +#include "engines/wintermute/Ad/AdSceneNode.h" +#include "engines/wintermute/Ad/AdSceneState.h" +#include "engines/wintermute/Ad/AdSentence.h" +#include "engines/wintermute/Ad/AdSpriteSet.h" +#include "engines/wintermute/Ad/AdTalkDef.h" +#include "engines/wintermute/Ad/AdTalkHolder.h" +#include "engines/wintermute/Ad/AdTalkNode.h" +#include "engines/wintermute/Ad/AdWaypointGroup.h" +#include "engines/wintermute/Base/BEvent.h" +#include "engines/wintermute/Base/BFader.h" +#include "engines/wintermute/Base/BFontBitmap.h" +#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BKeyboardState.h" +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/BPoint.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BScriptable.h" +#include "engines/wintermute/Base/BScriptHolder.h" +#include "engines/wintermute/Base/BSound.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BViewport.h" +#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/Base/scriptables/ScScript.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/SXArray.h" +#include "engines/wintermute/Base/scriptables/SXDate.h" +#include "engines/wintermute/Base/scriptables/SXFile.h" +#include "engines/wintermute/Base/scriptables/SXMath.h" +#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" +#include "engines/wintermute/Base/scriptables/SxObject.h" +#include "engines/wintermute/Base/scriptables/SXStore.h" +#include "engines/wintermute/Base/scriptables/SXString.h" +#include "engines/wintermute/UI/UIButton.h" +#include "engines/wintermute/UI/UIEdit.h" +#include "engines/wintermute/UI/UIEntity.h" +#include "engines/wintermute/UI/UIText.h" +#include "engines/wintermute/UI/UITiledImage.h" +#include "engines/wintermute/UI/UIWindow.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" + +#define REGISTER_CLASS(class_name, persistent_class)\ + new WinterMute::CSysClass(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class); + +namespace WinterMute { + +void registerClasses() { + REGISTER_CLASS(CAdActor, false) + REGISTER_CLASS(CAdEntity, false) + REGISTER_CLASS(CAdGame, true) + REGISTER_CLASS(CAdInventory, false) + REGISTER_CLASS(CAdInventoryBox, false) + REGISTER_CLASS(CAdItem, false) + REGISTER_CLASS(CAdLayer, false) + REGISTER_CLASS(CAdNodeState, false) + REGISTER_CLASS(CAdObject, false) + REGISTER_CLASS(CAdPath, false) + REGISTER_CLASS(CAdPathPoint, false) + REGISTER_CLASS(CAdRegion, false) + REGISTER_CLASS(CAdResponse, false) + REGISTER_CLASS(CAdResponseBox, false) + REGISTER_CLASS(CAdResponseContext, false) + REGISTER_CLASS(CAdRotLevel, false) + REGISTER_CLASS(CAdScaleLevel, false) + REGISTER_CLASS(CAdScene, false) + REGISTER_CLASS(CAdSceneNode, false) + REGISTER_CLASS(CAdSceneState, false) + REGISTER_CLASS(CAdSentence, false) + REGISTER_CLASS(CAdSpriteSet, false) + REGISTER_CLASS(CAdTalkDef, false) + REGISTER_CLASS(CAdTalkHolder, false) + REGISTER_CLASS(CAdTalkNode, false) + REGISTER_CLASS(CAdWaypointGroup, false) + + REGISTER_CLASS(CBEvent, false) + REGISTER_CLASS(CBFader, false) + REGISTER_CLASS(CBFont, false) + REGISTER_CLASS(CBFontBitmap, false) + REGISTER_CLASS(CBFontStorage, true) + REGISTER_CLASS(CBFontTT, false) + REGISTER_CLASS(CBFrame, false) + REGISTER_CLASS(CBGame, true) + REGISTER_CLASS(CBKeyboardState, false) + REGISTER_CLASS(CBObject, false) + REGISTER_CLASS(CBPoint, false) + REGISTER_CLASS(CBRegion, false) + REGISTER_CLASS(CBScriptable, false) + REGISTER_CLASS(CBScriptHolder, false) + REGISTER_CLASS(CBSound, false) + REGISTER_CLASS(CBSprite, false) + REGISTER_CLASS(CBSubFrame, false) + + REGISTER_CLASS(CBViewport, false) + REGISTER_CLASS(CPartEmitter, false) + REGISTER_CLASS(CScEngine, true) + REGISTER_CLASS(CScScript, false) + REGISTER_CLASS(CScStack, false) + REGISTER_CLASS(CScValue, false) + REGISTER_CLASS(CSXArray, false) + REGISTER_CLASS(CSXDate, false) + REGISTER_CLASS(CSXFile, false) + REGISTER_CLASS(CSXMath, true) + REGISTER_CLASS(CSXMemBuffer, false) + REGISTER_CLASS(CSXObject, false) + REGISTER_CLASS(CSXStore, false) + REGISTER_CLASS(CSXString, false) + + REGISTER_CLASS(CUIButton, false) + REGISTER_CLASS(CUIEdit, false) + REGISTER_CLASS(CUIEntity, false) + REGISTER_CLASS(CUIObject, false) + REGISTER_CLASS(CUIText, false) + REGISTER_CLASS(CUITiledImage, false) + REGISTER_CLASS(CUIWindow, false) + REGISTER_CLASS(CVidTheoraPlayer, false) + warning("TODO: Clean this up at some proper time"); +} + +} diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index fc9c4d674c..f6da9cf293 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -71,7 +71,7 @@ namespace WinterMute { return #class_name;\ }\ \ - CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);\ + /*CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);*/\ \ void* class_name::operator new (size_t size){\ void* ret = ::operator new(size);\ @@ -87,6 +87,8 @@ namespace WinterMute { #define TMEMBER(member_name) #member_name, &member_name #define TMEMBER_INT(member_name) #member_name, (int*)&member_name +void registerClasses(); + } // end of namespace WinterMute #endif // WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index d2edf6d1f3..0cd3da2c6a 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -138,6 +138,7 @@ Common::Error WinterMuteEngine::run() { int WinterMuteEngine::init() { char argv[1] = { ' ' }; int argc = 0; + registerClasses(); // Needs to be done before the first WME class is instantiated _game = new CAdGame; if (!_game) return 1; CBPlatform::Initialize(_game, 0, NULL); -- cgit v1.2.3 From 77c42af859c12ea7279c28373a200a916e77204f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 18:59:19 +0200 Subject: WINTERMUTE: Remove BEvent. --- engines/wintermute/Base/BEvent.cpp | 197 ------------------------------------- engines/wintermute/Base/BEvent.h | 56 ----------- engines/wintermute/module.mk | 1 - engines/wintermute/persistent.cpp | 2 - 4 files changed, 256 deletions(-) delete mode 100644 engines/wintermute/Base/BEvent.cpp delete mode 100644 engines/wintermute/Base/BEvent.h (limited to 'engines') diff --git a/engines/wintermute/Base/BEvent.cpp b/engines/wintermute/Base/BEvent.cpp deleted file mode 100644 index 1272f85322..0000000000 --- a/engines/wintermute/Base/BEvent.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BEvent.h" -#include "engines/wintermute/Base/BParser.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBEvent, false) - -////////////////////////////////////////////////////////////////////////// -CBEvent::CBEvent(CBGame *inGame): CBBase(inGame) { - _type = EVENT_NONE; - _script = NULL; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBEvent::CBEvent(CBGame *inGame, TEventType Type, char *Script): CBBase(inGame) { - _type = Type; - _script = new char [strlen(Script) + 1]; - if (_script) strcpy(_script, Script); - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBEvent::~CBEvent() { - delete[] _script; - _script = NULL; - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBEvent::GetEventName(TEventType Type) { - switch (Type) { - case EVENT_INIT: - return "INIT"; - case EVENT_SHUTDOWN: - return "SHUTDOWN"; - case EVENT_LEFT_CLICK: - return "LEFT_CLICK"; - case EVENT_RIGHT_CLICK: - return "RIGHT_CLICK"; - case EVENT_MIDDLE_CLICK: - return "MIDDLE_CLICK"; - case EVENT_LEFT_DBLCLICK: - return "LEFT_DBLCLICK"; - case EVENT_PRESS: - return "PRESS"; - case EVENT_IDLE: - return "IDLE"; - case EVENT_MOUSE_OVER: - return "MOUSE_OVER"; - case EVENT_LEFT_RELEASE: - return "LEFT_RELEASE"; - case EVENT_RIGHT_RELEASE: - return "RIGHT_RELEASE"; - case EVENT_MIDDLE_RELEASE: - return "MIDDLE_RELEASE"; - - default: - return "NONE"; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBEvent::SetScript(const char *Script) { - if (_script) delete [] _script; - - _script = new char [strlen(Script) + 1]; - if (_script) strcpy(_script, Script); -} - - -////////////////////////////////////////////////////////////////////////// -void CBEvent::SetName(const char *Name) { - if (_name) delete [] _name; - - _name = new char [strlen(Name) + 1]; - if (_name) strcpy(_name, Name); -} - - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBEvent::LoadFile failed for file '%s'", Filename); - return E_FAIL; - } - - HRESULT ret; - - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EVENT file '%s'", Filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(EVENT) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::LoadBuffer(byte *Buffer, bool Complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EVENT) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(Game); - - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EVENT) { - Game->LOG(0, "'EVENT' keyword expected."); - return E_FAIL; - } - Buffer = params; - } - - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - SetName((char *)params); - break; - - case TOKEN_SCRIPT: - SetScript((char *)params); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in EVENT definition"); - return E_FAIL; - } - - return S_OK; -} - - -////////////////////////////////////////////////////////////////////////// -HRESULT CBEvent::Persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(Game)); - - persistMgr->transfer(TMEMBER(_script)); - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return S_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BEvent.h b/engines/wintermute/Base/BEvent.h deleted file mode 100644 index a58f7d08d1..0000000000 --- a/engines/wintermute/Base/BEvent.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BEVENT_H -#define WINTERMUTE_BEVENT_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CBEvent : public CBBase { -public: - DECLARE_PERSISTENT(CBEvent, CBBase) - void SetScript(const char *Script); - void SetName(const char *Name); - static const char *GetEventName(TEventType Type); - char *_script; - char *_name; - TEventType _type; - CBEvent(CBGame *inGame); - CBEvent(CBGame *inGame, TEventType Type, char *Script); - virtual ~CBEvent(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 4fe22fc795..8dbdd94b0a 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -47,7 +47,6 @@ MODULE_OBJS := \ Base/BBase.o \ Base/BDebugger.o \ Base/BDynBuffer.o \ - Base/BEvent.o \ Base/BFader.o \ Base/BFileEntry.o \ Base/BFileManager.o \ diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 347d0e822d..3b8f70bf0c 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -52,7 +52,6 @@ #include "engines/wintermute/Ad/AdTalkHolder.h" #include "engines/wintermute/Ad/AdTalkNode.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BEvent.h" #include "engines/wintermute/Base/BFader.h" #include "engines/wintermute/Base/BFontBitmap.h" #include "engines/wintermute/Base/BFontStorage.h" @@ -122,7 +121,6 @@ void registerClasses() { REGISTER_CLASS(CAdTalkNode, false) REGISTER_CLASS(CAdWaypointGroup, false) - REGISTER_CLASS(CBEvent, false) REGISTER_CLASS(CBFader, false) REGISTER_CLASS(CBFont, false) REGISTER_CLASS(CBFontBitmap, false) -- cgit v1.2.3 From 9f2c5385ba232c0cc086f3c914b5f98463df330d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 20:06:12 +0200 Subject: WINTERMUTE: Rename Persist->persist --- engines/wintermute/Ad/AdActor.cpp | 10 +++++----- engines/wintermute/Ad/AdEntity.cpp | 8 ++++---- engines/wintermute/Ad/AdGame.cpp | 22 +++++++++++----------- engines/wintermute/Ad/AdInventory.cpp | 6 +++--- engines/wintermute/Ad/AdInventoryBox.cpp | 4 ++-- engines/wintermute/Ad/AdItem.cpp | 4 ++-- engines/wintermute/Ad/AdLayer.cpp | 6 +++--- engines/wintermute/Ad/AdNodeState.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 8 ++++---- engines/wintermute/Ad/AdPath.cpp | 4 ++-- engines/wintermute/Ad/AdPathPoint.cpp | 4 ++-- engines/wintermute/Ad/AdRegion.cpp | 4 ++-- engines/wintermute/Ad/AdResponse.cpp | 4 ++-- engines/wintermute/Ad/AdResponseBox.cpp | 8 ++++---- engines/wintermute/Ad/AdResponseContext.cpp | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 4 ++-- engines/wintermute/Ad/AdScaleLevel.cpp | 4 ++-- engines/wintermute/Ad/AdScene.cpp | 16 ++++++++-------- engines/wintermute/Ad/AdSceneNode.cpp | 4 ++-- engines/wintermute/Ad/AdSceneState.cpp | 4 ++-- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Ad/AdSpriteSet.cpp | 4 ++-- engines/wintermute/Ad/AdTalkDef.cpp | 6 +++--- engines/wintermute/Ad/AdTalkHolder.cpp | 8 ++++---- engines/wintermute/Ad/AdTalkNode.cpp | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 6 +++--- engines/wintermute/Base/BFader.cpp | 4 ++-- engines/wintermute/Base/BFont.cpp | 4 ++-- engines/wintermute/Base/BFontBitmap.cpp | 4 ++-- engines/wintermute/Base/BFontStorage.cpp | 4 ++-- engines/wintermute/Base/BFontTT.cpp | 8 ++++---- engines/wintermute/Base/BFontTT.h | 2 +- engines/wintermute/Base/BFrame.cpp | 8 ++++---- engines/wintermute/Base/BGame.cpp | 8 ++++---- engines/wintermute/Base/BKeyboardState.cpp | 4 ++-- engines/wintermute/Base/BObject.cpp | 4 ++-- engines/wintermute/Base/BPersistMgr.cpp | 10 +++++----- engines/wintermute/Base/BPoint.cpp | 2 +- engines/wintermute/Base/BRegion.cpp | 6 +++--- engines/wintermute/Base/BScriptHolder.cpp | 6 +++--- engines/wintermute/Base/BScriptable.cpp | 2 +- engines/wintermute/Base/BSound.cpp | 2 +- engines/wintermute/Base/BSprite.cpp | 6 +++--- engines/wintermute/Base/BSubFrame.cpp | 4 ++-- engines/wintermute/Base/BSurfaceStorage.cpp | 4 ++-- engines/wintermute/Base/BViewport.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 14 +++++++------- engines/wintermute/Base/PartForce.cpp | 2 +- engines/wintermute/Base/PartForce.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/PartParticle.h | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 4 ++-- engines/wintermute/Base/scriptables/SXDate.cpp | 4 ++-- engines/wintermute/Base/scriptables/SXFile.cpp | 4 ++-- engines/wintermute/Base/scriptables/SXMath.cpp | 4 ++-- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 4 ++-- engines/wintermute/Base/scriptables/SXStore.cpp | 8 ++++---- engines/wintermute/Base/scriptables/SXStore.h | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 4 ++-- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 ++-- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- engines/wintermute/Base/scriptables/ScStack.cpp | 4 ++-- engines/wintermute/Base/scriptables/ScValue.cpp | 2 +- engines/wintermute/Base/scriptables/SxObject.cpp | 4 ++-- engines/wintermute/UI/UIButton.cpp | 4 ++-- engines/wintermute/UI/UIEdit.cpp | 4 ++-- engines/wintermute/UI/UIEntity.cpp | 4 ++-- engines/wintermute/UI/UIObject.cpp | 4 ++-- engines/wintermute/UI/UIText.cpp | 4 ++-- engines/wintermute/UI/UITiledImage.cpp | 4 ++-- engines/wintermute/UI/UIWindow.cpp | 6 +++--- engines/wintermute/coll_templ.h | 4 ++-- engines/wintermute/persistent.h | 4 ++-- engines/wintermute/video/VidTheoraPlayer.cpp | 4 ++-- 74 files changed, 182 insertions(+), 182 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 68d173102e..da73b5161c 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -1187,8 +1187,8 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::Persist(persistMgr); +HRESULT CAdActor::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_dir)); persistMgr->transfer(TMEMBER(_path)); @@ -1198,8 +1198,8 @@ HRESULT CAdActor::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_pFX)); persistMgr->transfer(TMEMBER(_pFY)); persistMgr->transfer(TMEMBER(_standSprite)); - _talkSprites.Persist(persistMgr); - _talkSpritesEx.Persist(persistMgr); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_targetDir)); persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); persistMgr->transfer(TMEMBER(_targetPoint)); @@ -1214,7 +1214,7 @@ HRESULT CAdActor::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_turnLeftAnimName)); persistMgr->transfer(TMEMBER(_turnRightAnimName)); - _anims.Persist(persistMgr); + _anims.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 62b3156842..1f98d15f36 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -977,15 +977,15 @@ void CAdEntity::UpdatePosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::Persist(persistMgr); +HRESULT CAdEntity::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_item)); persistMgr->transfer(TMEMBER(_region)); //persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER_INT(_subtype)); - _talkSprites.Persist(persistMgr); - _talkSpritesEx.Persist(persistMgr); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); persistMgr->transfer(TMEMBER(_walkToX)); persistMgr->transfer(TMEMBER(_walkToY)); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index c20bf721de..23d144a426 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1263,31 +1263,31 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) Cleanup(); - CBGame::Persist(persistMgr); + CBGame::persist(persistMgr); - _dlgPendingBranches.Persist(persistMgr); + _dlgPendingBranches.persist(persistMgr); - _inventories.Persist(persistMgr); + _inventories.persist(persistMgr); persistMgr->transfer(TMEMBER(_inventoryBox)); - _objects.Persist(persistMgr); + _objects.persist(persistMgr); persistMgr->transfer(TMEMBER(_prevSceneName)); persistMgr->transfer(TMEMBER(_prevSceneFilename)); persistMgr->transfer(TMEMBER(_responseBox)); - _responsesBranch.Persist(persistMgr); - _responsesGame.Persist(persistMgr); + _responsesBranch.persist(persistMgr); + _responsesGame.persist(persistMgr); persistMgr->transfer(TMEMBER(_scene)); - _sceneStates.Persist(persistMgr); + _sceneStates.persist(persistMgr); persistMgr->transfer(TMEMBER(_scheduledFadeIn)); persistMgr->transfer(TMEMBER(_scheduledScene)); persistMgr->transfer(TMEMBER(_selectedItem)); persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); - _sentences.Persist(persistMgr); + _sentences.persist(persistMgr); persistMgr->transfer(TMEMBER(_sceneViewport)); persistMgr->transfer(TMEMBER_INT(_stateEx)); @@ -1297,11 +1297,11 @@ HRESULT CAdGame::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_invObject)); persistMgr->transfer(TMEMBER(_inventoryOwner)); persistMgr->transfer(TMEMBER(_tempDisableSaveState)); - _items.Persist(persistMgr); + _items.persist(persistMgr); persistMgr->transfer(TMEMBER(_itemsFile)); - _speechDirs.Persist(persistMgr); + _speechDirs.persist(persistMgr); persistMgr->transfer(TMEMBER(_smartItemCursor)); if (!persistMgr->_saving) _initialScene = false; diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index c81e1f4be7..fd94d906e6 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -106,11 +106,11 @@ HRESULT CAdInventory::RemoveItem(CAdItem *Item) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdInventory::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); - _takenItems.Persist(persistMgr); + _takenItems.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollOffset)); return S_OK; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index debe74db01..e4da8e975c 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -350,8 +350,8 @@ HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CAdInventoryBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_closeButton)); persistMgr->transfer(TMEMBER(_hideSelected)); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 366efefdc1..8d891f7d19 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -729,9 +729,9 @@ const char *CAdItem::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdItem::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::Persist(persistMgr); + CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_cursorCombined)); persistMgr->transfer(TMEMBER(_cursorHover)); diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index ae8baabcd6..28f437e703 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -521,15 +521,15 @@ HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdLayer::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_closeUp)); persistMgr->transfer(TMEMBER(_height)); persistMgr->transfer(TMEMBER(_main)); - _nodes.Persist(persistMgr); + _nodes.persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); return S_OK; diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 7089e63a31..0a7389045f 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -92,7 +92,7 @@ void CAdNodeState::SetCursor(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdNodeState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_active)); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 4f93a30a8e..85a6ad49b3 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -953,8 +953,8 @@ HRESULT CAdObject::Reset() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CAdObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_blockRegion)); @@ -985,8 +985,8 @@ HRESULT CAdObject::Persist(CBPersistMgr *persistMgr) { for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); - _attachmentsPre.Persist(persistMgr); - _attachmentsPost.Persist(persistMgr); + _attachmentsPre.persist(persistMgr); + _attachmentsPost.persist(persistMgr); persistMgr->transfer(TMEMBER(_registerAlias)); persistMgr->transfer(TMEMBER(_partFollowParent)); diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 6fcaa47866..620ea5c38c 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -98,12 +98,12 @@ bool CAdPath::SetReady(bool ready) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPath::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdPath::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_currIndex)); - _points.Persist(persistMgr); + _points.persist(persistMgr); persistMgr->transfer(TMEMBER(_ready)); return S_OK; diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp index d74284fa22..4f82f8e7f4 100644 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -61,9 +61,9 @@ CAdPathPoint::~CAdPathPoint() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPathPoint::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdPathPoint::persist(CBPersistMgr *persistMgr) { - CBPoint::Persist(persistMgr); + CBPoint::persist(persistMgr); persistMgr->transfer(TMEMBER(_distance)); persistMgr->transfer(TMEMBER(_marked)); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 16598e409b..19e817dd04 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -378,8 +378,8 @@ HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::Persist(CBPersistMgr *persistMgr) { - CBRegion::Persist(persistMgr); +HRESULT CAdRegion::persist(CBPersistMgr *persistMgr) { + CBRegion::persist(persistMgr); persistMgr->transfer(TMEMBER(_alpha)); persistMgr->transfer(TMEMBER(_blocked)); diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 4567e90109..cd67a7c0f7 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -124,9 +124,9 @@ HRESULT CAdResponse::SetIconPressed(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdResponse::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_icon)); persistMgr->transfer(TMEMBER(_iconHover)); diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 26590af65f..7a38451925 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -511,17 +511,17 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CAdResponseBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_font)); persistMgr->transfer(TMEMBER(_fontHover)); persistMgr->transfer(TMEMBER(_horizontal)); persistMgr->transfer(TMEMBER(_lastResponseText)); persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); - _respButtons.Persist(persistMgr); + _respButtons.persist(persistMgr); persistMgr->transfer(TMEMBER(_responseArea)); - _responses.Persist(persistMgr); + _responses.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollOffset)); persistMgr->transfer(TMEMBER(_shieldWindow)); persistMgr->transfer(TMEMBER(_spacing)); diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 054681f656..6947838ff0 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -49,7 +49,7 @@ CAdResponseContext::~CAdResponseContext() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseContext::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdResponseContext::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_iD)); diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index c35784d4d6..371c2f6ab0 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -147,9 +147,9 @@ HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdRotLevel::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_rotation)); diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 5ab835a149..be459bbcaf 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -145,9 +145,9 @@ HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdScaleLevel::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_scale)); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index cc51ddef22..e8229a3351 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -2135,8 +2135,8 @@ float CAdScene::GetScaleAt(int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CAdScene::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_autoScroll)); persistMgr->transfer(TMEMBER(_editorColBlocked)); @@ -2163,23 +2163,23 @@ HRESULT CAdScene::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_initialized)); persistMgr->transfer(TMEMBER(_lastTimeH)); persistMgr->transfer(TMEMBER(_lastTimeV)); - _layers.Persist(persistMgr); + _layers.persist(persistMgr); persistMgr->transfer(TMEMBER(_mainLayer)); - _objects.Persist(persistMgr); + _objects.persist(persistMgr); persistMgr->transfer(TMEMBER(_offsetLeft)); persistMgr->transfer(TMEMBER(_offsetTop)); persistMgr->transfer(TMEMBER(_paralaxScrolling)); persistMgr->transfer(TMEMBER(_persistentState)); persistMgr->transfer(TMEMBER(_persistentStateSprites)); persistMgr->transfer(TMEMBER(_pFMaxTime)); - _pFPath.Persist(persistMgr); + _pFPath.persist(persistMgr); persistMgr->transfer(TMEMBER(_pFPointsNum)); persistMgr->transfer(TMEMBER(_pFReady)); persistMgr->transfer(TMEMBER(_pFRequester)); persistMgr->transfer(TMEMBER(_pFTarget)); persistMgr->transfer(TMEMBER(_pFTargetPath)); - _rotLevels.Persist(persistMgr); - _scaleLevels.Persist(persistMgr); + _rotLevels.persist(persistMgr); + _scaleLevels.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollPixelsH)); persistMgr->transfer(TMEMBER(_scrollPixelsV)); persistMgr->transfer(TMEMBER(_scrollTimeH)); @@ -2187,7 +2187,7 @@ HRESULT CAdScene::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_shieldWindow)); persistMgr->transfer(TMEMBER(_targetOffsetLeft)); persistMgr->transfer(TMEMBER(_targetOffsetTop)); - _waypointGroups.Persist(persistMgr); + _waypointGroups.persist(persistMgr); persistMgr->transfer(TMEMBER(_viewport)); persistMgr->transfer(TMEMBER(_width)); diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 071469c996..d1584f192e 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -69,9 +69,9 @@ HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdSceneNode::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_entity)); persistMgr->transfer(TMEMBER(_region)); diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index a3dfc3c27d..9e7260d5a7 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -54,9 +54,9 @@ CAdSceneState::~CAdSceneState() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneState::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdSceneState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); - _nodeStates.Persist(persistMgr); + _nodeStates.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index dd6a8c9269..a893a00489 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -211,7 +211,7 @@ HRESULT CAdSentence::Finish() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdSentence::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 86937dde8e..4f6d17b7dd 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -214,9 +214,9 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdSpriteSet::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_owner)); for (int i = 0; i < NUM_DIRECTIONS; i++) { diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 283df609cb..2f3e9de799 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -194,16 +194,16 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_defaultSprite)); persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); persistMgr->transfer(TMEMBER(_defaultSpriteSet)); persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); - _nodes.Persist(persistMgr); + _nodes.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index e8b691b9fd..162fcf0f2b 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -343,12 +343,12 @@ HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::Persist(CBPersistMgr *persistMgr) { - CAdObject::Persist(persistMgr); +HRESULT CAdTalkHolder::persist(CBPersistMgr *persistMgr) { + CAdObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_sprite)); - _talkSprites.Persist(persistMgr); - _talkSpritesEx.Persist(persistMgr); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 0a3adc1632..bb6ff83efb 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -183,7 +183,7 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_comment)); persistMgr->transfer(TMEMBER(_startTime)); persistMgr->transfer(TMEMBER(_endTime)); diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 77cec106dd..a9d29692c5 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -184,16 +184,16 @@ HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::Persist(CBPersistMgr *persistMgr) { +HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_editorSelectedPoint)); persistMgr->transfer(TMEMBER(_lastMimicScale)); persistMgr->transfer(TMEMBER(_lastMimicX)); persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.Persist(persistMgr); + _points.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index a00215158c..cd78ece27a 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -154,8 +154,8 @@ uint32 CBFader::GetCurrentColor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CBFader::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_blue)); diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 302d4728d0..28317b00ce 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -144,9 +144,9 @@ int CBFont::GetLetterHeight() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFont::Persist(CBPersistMgr *persistMgr) { +HRESULT CBFont::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 94f723cef3..5db8e34a08 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -456,9 +456,9 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::Persist(CBPersistMgr *persistMgr) { +HRESULT CBFontBitmap::persist(CBPersistMgr *persistMgr) { - CBFont::Persist(persistMgr); + CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_numColumns)); persistMgr->transfer(TMEMBER(_subframe)); diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index a96809d194..a6ad5fb6a6 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -142,12 +142,12 @@ HRESULT CBFontStorage::RemoveFont(CBFont *Font) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::Persist(CBPersistMgr *persistMgr) { +HRESULT CBFontStorage::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) Cleanup(false); persistMgr->transfer(TMEMBER(Game)); - _fonts.Persist(persistMgr); + _fonts.persist(persistMgr); if (!persistMgr->_saving) InitFreeType(); diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 0d2f39f730..d7ab99a026 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -592,8 +592,8 @@ HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::Persist(CBPersistMgr *persistMgr) { - CBFont::Persist(persistMgr); +HRESULT CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_isBold)); persistMgr->transfer(TMEMBER(_isItalic)); @@ -608,13 +608,13 @@ HRESULT CBFontTT::Persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving) { NumLayers = _layers.GetSize(); persistMgr->transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) _layers[i]->Persist(persistMgr); + for (int i = 0; i < NumLayers; i++) _layers[i]->persist(persistMgr); } else { NumLayers = _layers.GetSize(); persistMgr->transfer(TMEMBER(NumLayers)); for (int i = 0; i < NumLayers; i++) { CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->Persist(persistMgr); + Layer->persist(persistMgr); _layers.Add(Layer); } } diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 418efb3e9b..db5b029c93 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -80,7 +80,7 @@ public: _color = 0x00000000; } - HRESULT Persist(CBPersistMgr *persistMgr) { + HRESULT persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_offsetX)); persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_color)); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 9e07407f26..1f14c4ea8f 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -381,10 +381,10 @@ HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); +HRESULT CBFrame::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); - _applyEvent.Persist(persistMgr); + _applyEvent.persist(persistMgr); persistMgr->transfer(TMEMBER(_delay)); persistMgr->transfer(TMEMBER(_editorExpanded)); persistMgr->transfer(TMEMBER(_keyframe)); @@ -392,7 +392,7 @@ HRESULT CBFrame::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_moveX)); persistMgr->transfer(TMEMBER(_moveY)); persistMgr->transfer(TMEMBER(_sound)); - _subframes.Persist(persistMgr); + _subframes.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index def8c5137e..9544f1552e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3629,10 +3629,10 @@ HRESULT CBGame::LoadSettings(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Persist(CBPersistMgr *persistMgr) { +HRESULT CBGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) Cleanup(); - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_activeObject)); persistMgr->transfer(TMEMBER(_capturedObject)); @@ -3662,7 +3662,7 @@ HRESULT CBGame::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_personalizedSave)); persistMgr->transfer(TMEMBER(_quitting)); - _regObjects.Persist(persistMgr); + _regObjects.persist(persistMgr); persistMgr->transfer(TMEMBER(_scEngine)); //persistMgr->transfer(TMEMBER(_soundMgr)); @@ -3704,7 +3704,7 @@ HRESULT CBGame::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_mouseLockRect)); - _windows.Persist(persistMgr); + _windows.persist(persistMgr); persistMgr->transfer(TMEMBER(_suppressScriptErrors)); persistMgr->transfer(TMEMBER(_autorunDisabled)); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 3f5d9b1225..2d95c34d4f 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -215,9 +215,9 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::Persist(CBPersistMgr *persistMgr) { +HRESULT CBKeyboardState::persist(CBPersistMgr *persistMgr) { //if(!persistMgr->_saving) Cleanup(); - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); persistMgr->transfer(TMEMBER(_currentCharCode)); diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index f59978eb77..66de667645 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -864,8 +864,8 @@ HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Persist(CBPersistMgr *persistMgr) { - CBScriptHolder::Persist(persistMgr); +HRESULT CBObject::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); persistMgr->transfer(TMEMBER(_activeCursor)); diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 795d7e3d03..64cbb76277 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -206,7 +206,7 @@ HRESULT CBPersistMgr::initSave(const char *desc) { putString(Game->_name); // thumbnail data size - bool ThumbnailOK = false; + bool thumbnailOK = false; if (Game->_cachedThumbnail) { if (Game->_cachedThumbnail->_thumbnail) { @@ -218,10 +218,10 @@ HRESULT CBPersistMgr::initSave(const char *desc) { _saveStream->writeUint32LE(0); } - ThumbnailOK = true; + thumbnailOK = true; } } - if (!ThumbnailOK) putDWORD(0); + if (!thumbnailOK) putDWORD(0); // in any case, destroy the cached thumbnail once used delete Game->_cachedThumbnail; @@ -281,13 +281,13 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { } } else _savedVerBuild = 35; // last build with ver1 savegames - uint32 DataOffset = getDWORD(); + uint32 dataOffset = getDWORD(); _savedDescription = getString(); _savedTimestamp = getTimeDate(); _savedPlayTime = _loadStream->readUint32LE(); - _offset = DataOffset; + _offset = dataOffset; return S_OK; } diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp index 105159cb6c..92cfccd87a 100644 --- a/engines/wintermute/Base/BPoint.cpp +++ b/engines/wintermute/Base/BPoint.cpp @@ -53,7 +53,7 @@ CBPoint::CBPoint(int initX, int initY) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPoint::Persist(CBPersistMgr *persistMgr) { +HRESULT CBPoint::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(x)); persistMgr->transfer(TMEMBER(y)); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index f7d3f5b2ef..355070ba26 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -406,16 +406,16 @@ HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOv ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::Persist(CBPersistMgr *persistMgr) { +HRESULT CBRegion::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_editorSelectedPoint)); persistMgr->transfer(TMEMBER(_lastMimicScale)); persistMgr->transfer(TMEMBER(_lastMimicX)); persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.Persist(persistMgr); + _points.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index efe8e5f195..0dfeab4b07 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -263,13 +263,13 @@ HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); +HRESULT CBScriptHolder::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); persistMgr->transfer(TMEMBER(_name)); - _scripts.Persist(persistMgr); + _scripts.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 715a1fef8c..09a8f2c0aa 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -139,7 +139,7 @@ void CBScriptable::ScSetBool(bool Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::Persist(CBPersistMgr *persistMgr) { +HRESULT CBScriptable::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index 9a48484bfe..477c44dba3 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -147,7 +147,7 @@ HRESULT CBSound::Resume() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Persist(CBPersistMgr *persistMgr) { +HRESULT CBSound::persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving && _sound) { _soundPlaying = _sound->IsPlaying(); _soundLooping = _sound->_looping; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6ebaa0fa7b..f4f6e8b232 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -472,8 +472,8 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Persist(CBPersistMgr *persistMgr) { - CBScriptHolder::Persist(persistMgr); +HRESULT CBSprite::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_canBreak)); persistMgr->transfer(TMEMBER(_changed)); @@ -488,7 +488,7 @@ HRESULT CBSprite::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_editorMuted)); persistMgr->transfer(TMEMBER(_finished)); - _frames.Persist(persistMgr); + _frames.persist(persistMgr); persistMgr->transfer(TMEMBER(_lastFrameTime)); persistMgr->transfer(TMEMBER(_looping)); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index ce7ffa3e9a..5ab1a10a9b 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -310,9 +310,9 @@ void CBSubFrame::SetDefaultRect() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::Persist(CBPersistMgr *persistMgr) { +HRESULT CBSubFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index c5980719d7..797c5f3d49 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -148,14 +148,14 @@ HRESULT CBSurfaceStorage::RestoreAll() { /* ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::Persist(CBPersistMgr *persistMgr) +HRESULT CBSurfaceStorage::persist(CBPersistMgr *persistMgr) { if(!persistMgr->_saving) Cleanup(false); persistMgr->transfer(TMEMBER(Game)); - //_surfaces.Persist(persistMgr); + //_surfaces.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index eef044bb50..5010b2c030 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -49,7 +49,7 @@ CBViewport::~CBViewport() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::Persist(CBPersistMgr *persistMgr) { +HRESULT CBViewport::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 39416377c8..1c845f88be 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -1098,8 +1098,8 @@ const char *CPartEmitter::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); persistMgr->transfer(TMEMBER(_height)); @@ -1159,20 +1159,20 @@ HRESULT CPartEmitter::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_owner)); - _sprites.Persist(persistMgr); + _sprites.persist(persistMgr); int NumForces; if (persistMgr->_saving) { NumForces = _forces.GetSize(); persistMgr->transfer(TMEMBER(NumForces)); for (int i = 0; i < _forces.GetSize(); i++) { - _forces[i]->Persist(persistMgr); + _forces[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(NumForces)); for (int i = 0; i < NumForces; i++) { CPartForce *Force = new CPartForce(Game); - Force->Persist(persistMgr); + Force->persist(persistMgr); _forces.Add(Force); } } @@ -1182,13 +1182,13 @@ HRESULT CPartEmitter::Persist(CBPersistMgr *persistMgr) { NumParticles = _particles.GetSize(); persistMgr->transfer(TMEMBER(NumParticles)); for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->Persist(persistMgr); + _particles[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(NumParticles)); for (int i = 0; i < NumParticles; i++) { CPartParticle *Particle = new CPartParticle(Game); - Particle->Persist(persistMgr); + Particle->persist(persistMgr); _particles.Add(Particle); } } diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp index 441831dc8c..f6be20be93 100644 --- a/engines/wintermute/Base/PartForce.cpp +++ b/engines/wintermute/Base/PartForce.cpp @@ -47,7 +47,7 @@ CPartForce::~CPartForce(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartForce::Persist(CBPersistMgr *persistMgr) { +HRESULT CPartForce::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h index 8bfc7ebf68..548803a4a8 100644 --- a/engines/wintermute/Base/PartForce.h +++ b/engines/wintermute/Base/PartForce.h @@ -49,7 +49,7 @@ public: Vector2 _direction; TForceType _type; - HRESULT Persist(CBPersistMgr *PersistMgr); + HRESULT persist(CBPersistMgr *PersistMgr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index da97a702f8..f772e6fe77 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -216,7 +216,7 @@ HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Persist(CBPersistMgr *persistMgr) { +HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_alpha1)); persistMgr->transfer(TMEMBER(_alpha2)); persistMgr->transfer(TMEMBER(_border)); diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index a7f7c37a65..2c5c57034c 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -76,7 +76,7 @@ public: HRESULT FadeIn(uint32 CurrentTime, int FadeTime); HRESULT FadeOut(uint32 CurrentTime, int FadeTime); - HRESULT Persist(CBPersistMgr *PersistMgr); + HRESULT persist(CBPersistMgr *PersistMgr); private: uint32 _fadeStart; int _fadeTime; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index f427a351af..41b3514f92 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -199,8 +199,8 @@ HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::Persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); +HRESULT CSXArray::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_length)); persistMgr->transfer(TMEMBER(_values)); diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 80905bba37..465999241f 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -238,9 +238,9 @@ HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXDate::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_tm.tm_year)); persistMgr->transfer(TMEMBER(_tm.tm_mon)); persistMgr->transfer(TMEMBER(_tm.tm_mday)); diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index cb883a9a7b..9e61181ad0 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -689,9 +689,9 @@ uint32 CSXFile::GetLength() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_mode)); diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 351fed9fe3..da05de0e95 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -285,9 +285,9 @@ double CSXMath::RadianToDegree(double Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXMath::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 4fd543663b..88f293367a 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -454,9 +454,9 @@ HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXMemBuffer::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_size)); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 0e13f5d738..52e7d2d53f 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -278,10 +278,10 @@ CScValue *CSXStore::ScGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) Cleanup(); - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_eventsEnabled)); persistMgr->transfer(TMEMBER(_lastProductRequestOwner)); @@ -294,13 +294,13 @@ HRESULT CSXStore::Persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving) { numProducts = _validProducts.GetSize(); persistMgr->transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) _validProducts[i]->Persist(persistMgr); + for (int i = 0; i < numProducts; i++) _validProducts[i]->persist(persistMgr); } else { numProducts = _validProducts.GetSize(); persistMgr->transfer(TMEMBER(numProducts)); for (int i = 0; i < numProducts; i++) { CBStoreProduct *prod = new CBStoreProduct; - prod->Persist(persistMgr); + prod->persist(persistMgr); _validProducts.Add(prod); } } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 2eff4b065f..200349addf 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -60,7 +60,7 @@ public: delete [] _price; } - HRESULT Persist(CBPersistMgr *persistMgr) { + HRESULT persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_id)); persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_desc)); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 65bf933d0a..fdbcea5ef2 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -377,9 +377,9 @@ HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::Persist(CBPersistMgr *persistMgr) { +HRESULT CSXString::persist(CBPersistMgr *persistMgr) { - CBScriptable::Persist(persistMgr); + CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_capacity)); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 0083c55ee9..d81db93e34 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -564,14 +564,14 @@ HRESULT CScEngine::ResetScript(CScScript *Script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Persist(CBPersistMgr *persistMgr) { +HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) Cleanup(); persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_currentScript)); persistMgr->transfer(TMEMBER(_fileToCompile)); persistMgr->transfer(TMEMBER(_globals)); - _scripts.Persist(persistMgr); + _scripts.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 638f4ab816..c293009da1 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1153,7 +1153,7 @@ void CScScript::RuntimeError(LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Persist(CBPersistMgr *persistMgr) { +HRESULT CScScript::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 100424bc2d..6e792ceb53 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -213,12 +213,12 @@ void CScStack::PushNative(CBScriptable *Val, bool Persistent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScStack::Persist(CBPersistMgr *persistMgr) { +HRESULT CScStack::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_sP)); - _values.Persist(persistMgr); + _values.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 81828e3580..2182e58e71 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -715,7 +715,7 @@ void CScValue::SetValue(CScValue *Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::Persist(CBPersistMgr *persistMgr) { +HRESULT CScValue::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_persistent)); diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 9e33abdb2e..7ebbb45132 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -58,8 +58,8 @@ CSXObject::~CSXObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXObject::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CSXObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 9decb4ea2a..93bef195ea 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -1008,9 +1008,9 @@ const char *CUIButton::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIButton::persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(persistMgr); + CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_align)); persistMgr->transfer(TMEMBER(_backDisable)); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index f6224c5e90..3b4b274bd0 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -836,9 +836,9 @@ int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIEdit::persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(persistMgr); + CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_cursorBlinkRate)); persistMgr->transfer(TMEMBER(_cursorChar)); diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index ed0c9e1230..d8d53270ef 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -328,9 +328,9 @@ const char *CUIEntity::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIEntity::persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(persistMgr); + CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_entity)); return S_OK; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 4160bf1115..64a2b28084 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -555,9 +555,9 @@ HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIObject::persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_back)); persistMgr->transfer(TMEMBER(_canFocus)); diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index f9ac91d422..7213c34534 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -467,9 +467,9 @@ const char *CUIText::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIText::persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(persistMgr); + CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_textAlign)); persistMgr->transfer(TMEMBER_INT(_verticalAlign)); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 79c2278d0b..ba2558aa84 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -350,8 +350,8 @@ void CUITiledImage::CorrectSize(int *Width, int *Height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::Persist(CBPersistMgr *persistMgr) { - CBObject::Persist(persistMgr); +HRESULT CUITiledImage::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_downLeft)); persistMgr->transfer(TMEMBER(_downMiddle)); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index b8f00fdb1e..d0d91084d9 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1150,9 +1150,9 @@ HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Persist(CBPersistMgr *persistMgr) { +HRESULT CUIWindow::persist(CBPersistMgr *persistMgr) { - CUIObject::Persist(persistMgr); + CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_backInactive)); persistMgr->transfer(TMEMBER(_clipContents)); @@ -1174,7 +1174,7 @@ HRESULT CUIWindow::Persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_viewport)); persistMgr->transfer(TMEMBER(_pauseMusic)); - _widgets.Persist(persistMgr); + _widgets.persist(persistMgr); return S_OK; } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 131a261bf1..c9e85253e5 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -88,7 +88,7 @@ public: // Clean up void FreeExtra(); void RemoveAll(); - HRESULT Persist(CBPersistMgr *persistMgr); + HRESULT persist(CBPersistMgr *persistMgr); // Accessing elements TYPE GetAt(int nIndex) const; @@ -346,7 +346,7 @@ void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { ///////////////////////////////////////////////////////////////////////////// template -HRESULT CBArray::Persist(CBPersistMgr *persistMgr) { +HRESULT CBArray::persist(CBPersistMgr *persistMgr) { int i, j; if (persistMgr->_saving) { j = GetSize(); diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index f6da9cf293..7184d48829 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -52,7 +52,7 @@ namespace WinterMute { virtual const char* GetClassName();\ static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ - virtual HRESULT Persist(CBPersistMgr* PersistMgr);\ + virtual HRESULT persist(CBPersistMgr* PersistMgr);\ void* operator new (size_t size);\ void operator delete(void* p);\ @@ -64,7 +64,7 @@ namespace WinterMute { }\ \ HRESULT class_name::PersistLoad(void* Instance, CBPersistMgr* PersistMgr){\ - return ((class_name*)Instance)->Persist(PersistMgr);\ + return ((class_name*)Instance)->persist(PersistMgr);\ }\ \ const char* class_name::GetClassName(){\ diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d44231d0d0..1afd114bd4 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -797,8 +797,8 @@ HRESULT CVidTheoraPlayer::resume() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::Persist(CBPersistMgr *persistMgr) { - //CBBase::Persist(persistMgr); +HRESULT CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { + //CBBase::persist(persistMgr); if (persistMgr->_saving) { _savedPos = getMovieTime() * 1000; -- cgit v1.2.3 From d495c588977fc63e42c986e8404ac23ba40a4923 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 22 Jun 2012 20:39:38 +0200 Subject: WINTERMUTE: Get rid of a few warnings --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 4 ++-- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Base/BImage.cpp | 6 +++--- engines/wintermute/Base/BRenderSDL.cpp | 8 ++++---- engines/wintermute/PlatformSDL.cpp | 1 + engines/wintermute/utils/StringUtil.cpp | 4 ++-- engines/wintermute/video/VidTheoraPlayer.cpp | 10 +++++----- engines/wintermute/video/VidTheoraPlayer.h | 2 +- engines/wintermute/wintermute.cpp | 3 --- 10 files changed, 20 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 23d144a426..adcae6a4bd 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1457,7 +1457,7 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { char *FilenameCor = new char[strlen(Filename) + 1]; strcpy(FilenameCor, Filename); - for (int i = 0; i < strlen(FilenameCor); i++) { + for (uint32 i = 0; i < strlen(FilenameCor); i++) { if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index e4da8e975c..100d4f8d8e 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -103,8 +103,8 @@ HRESULT CAdInventoryBox::Display() { if (!_visible) return S_OK; int ItemsX, ItemsY; - ItemsX = floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); - ItemsY = floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); + ItemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + ItemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); if (_window) { _window->EnableWidget("prev", _scrollOffset > 0); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 85a6ad49b3..816821568e 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -816,7 +816,7 @@ int CAdObject::GetHeight() { if (_zoomable) { float zoom = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY); - ret = ret * zoom / 100; + ret = (int)(ret * zoom / 100); } return ret; } diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 2504850887..eadf845109 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -142,7 +142,7 @@ HRESULT CBImage::Resize(int NewWidth, int NewHeight) { ////////////////////////////////////////////////////////////////////////// bool CBImage::writeBMPToStream(Common::WriteStream *stream) { - if (!_surface) return NULL; + if (!_surface) return false; /* The following is just copied over and inverted to write-ops from the BMP-decoder */ stream->writeByte('B'); @@ -164,7 +164,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { uint32 width = _surface->w; int32 height = _surface->h; stream->writeUint32LE(width); - stream->writeUint32LE(height); + stream->writeUint32LE((uint32)height); if (width == 0 || height == 0) return false; @@ -240,7 +240,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { return Buffer; #endif - return NULL; + return false; } diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 54119d3a7a..80c3372c62 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -120,11 +120,11 @@ HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { ratio = (float)_realWidth / (float)_width; } - _borderLeft = (_realWidth - (_width * ratio)) / 2; - _borderRight = _realWidth - (_width * ratio) - _borderLeft; + _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); + _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); - _borderTop = (_realHeight - (_height * ratio)) / 2; - _borderBottom = _realHeight - (_height * ratio) - _borderTop; + _borderTop = (int)((_realHeight - (_height * ratio)) / 2); + _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index fde05eafe3..9eb1970f11 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -45,6 +45,7 @@ CBGame *CBPlatform::Game = NULL; #define CLASS_NAME "GF_FRAME" int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { Game = inGame; + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 21d777eb32..0e273ea84f 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -177,7 +177,7 @@ Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { } // Currently this only does Ansi->ISO 8859, and only for carets. -char simpleAnsiToWide(const AnsiString &str, int &offset) { +char simpleAnsiToWide(const AnsiString &str, uint32 &offset) { char c = str[offset]; if (c == 92) { @@ -198,7 +198,7 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { warning("StringUtil::AnsiToWide - WideString not supported yet"); } Common::String converted = ""; - int index = 0; + uint32 index = 0; while (index != str.size()) { converted += simpleAnsiToWide(str, index); } diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 1afd114bd4..bcf4569737 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -386,15 +386,15 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam float ZoomX = (float)((float)Game->_renderer->_width / width * 100); float ZoomY = (float)((float)Game->_renderer->_height / height * 100); _playZoom = MIN(ZoomX, ZoomY); - _posX = (Game->_renderer->_width - width * (_playZoom / 100)) / 2; - _posY = (Game->_renderer->_height - height * (_playZoom / 100)) / 2; + _posX = (int)((Game->_renderer->_width - width * (_playZoom / 100)) / 2); + _posY = (int)((Game->_renderer->_height - height * (_playZoom / 100)) / 2); } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _posX = (Game->_renderer->_width - width) / 2; - _posY = (Game->_renderer->_height - height) / 2; + _posX = (int)((Game->_renderer->_width - width) / 2); + _posY = (int)((Game->_renderer->_height - height) / 2); break; } return S_OK; @@ -594,7 +594,7 @@ float CVidTheoraPlayer::getMovieTime() { ////////////////////////////////////////////////////////////////////////// -int CVidTheoraPlayer::getMovieFrame() { +uint32 CVidTheoraPlayer::getMovieFrame() { #if 0 if (!m_TheoraStreams) return 0; float Time = GetMovieTime(); diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 43be1801a0..a112377f91 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -85,7 +85,7 @@ public: }; float getMovieTime(); - int getMovieFrame(); + uint32 getMovieFrame(); CBSurface *getTexture(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 0cd3da2c6a..06ab932f21 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -136,8 +136,6 @@ Common::Error WinterMuteEngine::run() { } int WinterMuteEngine::init() { - char argv[1] = { ' ' }; - int argc = 0; registerClasses(); // Needs to be done before the first WME class is instantiated _game = new CAdGame; if (!_game) return 1; @@ -147,7 +145,6 @@ int WinterMuteEngine::init() { // parse command line char *SaveGame = NULL; - char param[MAX_PATH]; /* for (int i = 0; i < argc; i++) { strcpy(param, argv[i]); -- cgit v1.2.3 From e68ab9b5721caaafd99d9936dd372fa266069957 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 15:13:34 +0200 Subject: WINTERMUTE: Make the ClassRegistry clean up after itself when returning to launcher --- engines/wintermute/Sys/SysClassRegistry.cpp | 12 +++++++++--- engines/wintermute/Sys/SysClassRegistry.h | 8 +++++--- engines/wintermute/persistent.cpp | 4 +++- engines/wintermute/persistent.h | 2 -- engines/wintermute/wintermute.cpp | 10 +++++++++- engines/wintermute/wintermute.h | 4 ++++ 6 files changed, 30 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 05412ae0e9..0a41b59d35 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" #include "SysInstance.h" #include "SysClassRegistry.h" #include "common/stream.h" @@ -41,15 +42,20 @@ CSysClassRegistry::CSysClassRegistry() { ////////////////////////////////////////////////////////////////////////// CSysClassRegistry::~CSysClassRegistry() { - + unregisterClasses(); } ////////////////////////////////////////////////////////////////////////// CSysClassRegistry *CSysClassRegistry::GetInstance() { - static CSysClassRegistry classReg; - return &classReg; + return g_wintermute->getClassRegistry(); } +void CSysClassRegistry::unregisterClasses() { + // CSysClass calls UnregisterClass upon destruction. + while (_classes.size() > 0) { + delete _classes.begin()->_value; + } +} ////////////////////////////////////////////////////////////////////////// bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 30516d4636..6bc2c11fcf 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -58,9 +58,14 @@ class CBPersistMgr; class CSysInstance; class CSysClassRegistry { + void unregisterClasses(); public: + void registerClasses(); // persistent.cpp static CSysClassRegistry *GetInstance(); + CSysClassRegistry(); + virtual ~CSysClassRegistry(); + HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); @@ -76,9 +81,6 @@ public: int GetNextID(); void AddInstanceToTable(CSysInstance *instance, void *pointer); - CSysClassRegistry(); - virtual ~CSysClassRegistry(); - bool _disabled; int _count; diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 3b8f70bf0c..2e80f20049 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -88,12 +88,14 @@ #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/video/VidTheoraPlayer.h" +// CSysClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ new WinterMute::CSysClass(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class); namespace WinterMute { -void registerClasses() { +// This is done in a separate file, to avoid including the kitchensink in CSysClassRegistry. +void CSysClassRegistry::registerClasses() { REGISTER_CLASS(CAdActor, false) REGISTER_CLASS(CAdEntity, false) REGISTER_CLASS(CAdGame, true) diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 7184d48829..30f9cd8780 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -87,8 +87,6 @@ namespace WinterMute { #define TMEMBER(member_name) #member_name, &member_name #define TMEMBER_INT(member_name) #member_name, (int*)&member_name -void registerClasses(); - } // end of namespace WinterMute #endif // WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 06ab932f21..f34aa0d9f6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -66,6 +66,7 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst) _game = NULL; g_wintermute = this; + _classReg = NULL; } WinterMuteEngine::~WinterMuteEngine() { @@ -132,11 +133,14 @@ Common::Error WinterMuteEngine::run() { if (ret == 0) { ret = messageLoop(); } + deinit(); return Common::kNoError; } int WinterMuteEngine::init() { - registerClasses(); // Needs to be done before the first WME class is instantiated + _classReg = new CSysClassRegistry(); + _classReg->registerClasses(); + _game = new CAdGame; if (!_game) return 1; CBPlatform::Initialize(_game, 0, NULL); @@ -306,6 +310,10 @@ int WinterMuteEngine::messageLoop() { return 0; } +void WinterMuteEngine::deinit() { + delete _classReg; +} + uint32 WinterMuteEngine::randInt(int from, int to) { return _rnd->getRandomNumberRng(from, to); } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 92dbedc6b5..c3ade92fe4 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -31,6 +31,7 @@ namespace WinterMute { class Console; class CBGame; +class CSysClassRegistry; // our engine debug channels enum { kWinterMuteDebugExample = 1 << 0, @@ -47,12 +48,15 @@ public: virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } + CSysClassRegistry *getClassRegistry(){ return _classReg; } uint32 randInt(int from, int to); private: int init(); + void deinit(); int messageLoop(); Console *_console; CBGame *_game; + CSysClassRegistry *_classReg; // We need random numbers Common::RandomSource *_rnd; }; -- cgit v1.2.3 From 0fc175857ad83127541ce3a85cd701f85f7e844d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 15:26:33 +0200 Subject: WINTERMUTE: Move the engine-log over to a debug-channel. --- engines/wintermute/Base/BGame.cpp | 16 ++-------------- engines/wintermute/wintermute.cpp | 11 +++++------ engines/wintermute/wintermute.h | 4 ++-- 3 files changed, 9 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 9544f1552e..69a0a31288 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -568,12 +568,6 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { -#ifndef __IPHONEOS__ - if (!_dEBUG_DebugMode) return; -#endif - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow);*/ int secs = g_system->getMillis() / 1000; int hours = secs / 3600; secs = secs % 3600; @@ -587,22 +581,16 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { vsprintf(buff, fmt, va); va_end(va); -#ifdef __IPHONEOS__ - printf("%02d:%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, buff); - fflush(stdout); -#else - if (_dEBUG_LogFile == NULL) return; - // redirect to an engine's own callback if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } if (_debugMgr) _debugMgr->OnLog(res, buff); - warning("%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); //fflush((FILE *)_dEBUG_LogFile); -#endif //QuickMessage(buff); } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index f34aa0d9f6..91a086af63 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -56,8 +56,8 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst) //SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); // Here is the right place to set up the engine specific debug channels - DebugMan.addDebugChannel(kWinterMuteDebugExample, "example", "this is just an example for a engine specific debug channel"); - DebugMan.addDebugChannel(kWinterMuteDebugExample2, "example2", "also an example"); + DebugMan.addDebugChannel(kWinterMuteDebugLog, "enginelog", "Covers the same output as the log-file in WME"); + DebugMan.addDebugChannel(kWinterMuteDebugSaveGame, "savegame", "Savegames"); // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); @@ -120,11 +120,10 @@ Common::Error WinterMuteEngine::run() { // Your main even loop should be (invoked from) here. debug("WinterMuteEngine::go: Hello, World!"); + DebugMan.enableDebugChannel("enginelog"); // This test will show up if -d1 and --debugflags=example are specified on the commandline - debugC(1, kWinterMuteDebugExample, "Example debug call"); - - // This test will show up if --debugflags=example or --debugflags=example2 or both of them and -d3 are specified on the commandline - debugC(3, kWinterMuteDebugExample | kWinterMuteDebugExample2, "Example debug call two"); + debugC(1, kWinterMuteDebugLog, "Engine Debug-LOG enabled"); + debugC(2, kWinterMuteDebugSaveGame , "Savegame debugging-enabled"); int ret = 1; diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index c3ade92fe4..0b607301d1 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -34,8 +34,8 @@ class CBGame; class CSysClassRegistry; // our engine debug channels enum { - kWinterMuteDebugExample = 1 << 0, - kWinterMuteDebugExample2 = 1 << 1 + kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine + kWinterMuteDebugSaveGame = 1 << 1 // next new channel must be 1 << 2 (4) // the current limitation is 32 debug channels (1 << 31 is the last one) }; -- cgit v1.2.3 From 4c61cf042b09a64593a8beb6e1e9d72a883a7cda Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 15:48:00 +0200 Subject: WINTERMUTE: Fix a bunch of warnings --- engines/wintermute/Ad/AdResponseBox.cpp | 2 ++ engines/wintermute/Ad/AdScene.cpp | 6 ++++++ engines/wintermute/Ad/AdSpriteSet.cpp | 2 +- engines/wintermute/Base/BScriptable.cpp | 2 +- engines/wintermute/Base/BSoundBuffer.cpp | 2 +- engines/wintermute/Base/scriptables/SXMemBuffer.cpp | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 6 ++++++ engines/wintermute/Base/scriptables/ScValue.cpp | 3 +++ engines/wintermute/math/Vector2.cpp | 8 ++++---- engines/wintermute/video/VidTheoraPlayer.cpp | 4 ++-- engines/wintermute/video/VidTheoraPlayer.h | 2 +- 11 files changed, 28 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 7a38451925..0359da03dd 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -586,6 +586,8 @@ HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { case RESPONSE_ONCE_GAME: AdGame->AddGameResponse(Response->_iD); break; + default: + warning("CAdResponseBox::HandleResponse - Unhandled enum"); } return S_OK; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index e8229a3351..c21d694468 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -2519,6 +2519,9 @@ HRESULT CAdScene::PersistState(bool Saving) { else node->_region->_active = NodeState->_active; } break; + default: + warning("CAdScene::PersistState - unhandled enum"); + break; } } } @@ -2703,6 +2706,9 @@ HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bo //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); } break; + default: + warning("CAdScene::GetSceneObjects - Unhandled enum"); + break; } } } diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 4f6d17b7dd..70b5f15dbe 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -302,7 +302,7 @@ HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { - if (!Sprite) return NULL; + if (!Sprite) return false; for (int i = 0; i < NUM_DIRECTIONS; i++) { if (_sprites[i] == Sprite) return true; diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 09a8f2c0aa..38a3325f91 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -182,7 +182,7 @@ const char *CBScriptable::DbgGetNativeClass() { ////////////////////////////////////////////////////////////////////////// IWmeDebugProp *CBScriptable::DbgGetProperty(const char *Name) { - return ScGetProperty((char *)Name); + return ScGetProperty(Name); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index a8c41cd022..35471bd4d9 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -260,7 +260,7 @@ void CBSoundBuffer::SetType(TSoundType Type) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::SetVolume(int Volume) { if (_stream && _handle) { - byte vol = Volume / 100.f * Audio::Mixer::kMaxChannelVolume; + byte vol = (byte)(Volume / 100.f * Audio::Mixer::kMaxChannelVolume); g_system->getMixer()->setChannelVolume(*_handle, vol); } return S_OK; diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 88f293367a..6769d3fda9 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -53,7 +53,7 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - _size = NULL; + _size = 0; _buffer = Buffer; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index d81db93e34..a8bfc10800 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -421,6 +421,9 @@ HRESULT CScEngine::Tick() { } break; } + default: + warning("CScEngine::Tick - Unhandled enum"); + break; } // switch } // for each script @@ -515,6 +518,9 @@ int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { case SCRIPT_PERSISTENT: persistent++; break; + default: + warning("CScEngine::GetNumScripts - unhandled enum"); + break; } total++; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 2182e58e71..4dce85c1a0 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -707,6 +707,9 @@ void CScValue::SetValue(CScValue *Val) { case VAL_STRING: _valNative->ScSetString(Val->GetString()); break; + default: + warning("CScValue::SetValue - unhandled enum"); + break; } } // otherwise just copy everything diff --git a/engines/wintermute/math/Vector2.cpp b/engines/wintermute/math/Vector2.cpp index b2fa56dff4..a72fb51e79 100644 --- a/engines/wintermute/math/Vector2.cpp +++ b/engines/wintermute/math/Vector2.cpp @@ -37,9 +37,9 @@ Vector2::Vector2() { } ////////////////////////////////////////////////////////////////////////// -Vector2::Vector2(float x, float y) { - this->x = x; - this->y = y; +Vector2::Vector2(float xVal, float yVal) { + this->x = xVal; + this->y = yVal; } ////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ Vector2::~Vector2() { ////////////////////////////////////////////////////////////////////////// float Vector2::Length() const { - return sqrt(x * x + y * y); + return (float)sqrt(x * x + y * y); } } // end of namespace WinterMute diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index bcf4569737..c6447c7431 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -584,9 +584,9 @@ HRESULT CVidTheoraPlayer::update() { } ////////////////////////////////////////////////////////////////////////// -float CVidTheoraPlayer::getMovieTime() { +uint32 CVidTheoraPlayer::getMovieTime() { if (!_playbackStarted) { - return 0.0f; + return 0; } else { return _theoraDecoder->getTime(); } diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index a112377f91..437a72db67 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -84,7 +84,7 @@ public: return _state == THEORA_STATE_PAUSED; }; - float getMovieTime(); + uint32 getMovieTime(); uint32 getMovieFrame(); CBSurface *getTexture(); -- cgit v1.2.3 From 58b8b371fe579292b41e272145c0c20ff13ab70b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 16:14:28 +0200 Subject: WINTERMUTE: Fix even more warnings --- engines/wintermute/Ad/AdObject.cpp | 8 ++++---- engines/wintermute/Base/BBase.cpp | 2 +- engines/wintermute/Base/BFader.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 8 ++++---- engines/wintermute/Base/BGame.cpp | 8 ++++---- engines/wintermute/Base/BRenderSDL.cpp | 24 ++++++++++++------------ engines/wintermute/Base/BScriptHolder.cpp | 2 +- engines/wintermute/Base/BSurfaceSDL.cpp | 4 ++-- engines/wintermute/Base/BTransitionMgr.cpp | 4 ++-- engines/wintermute/Base/PartEmitter.cpp | 8 ++++---- engines/wintermute/Base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 4 ++-- engines/wintermute/Sys/SysClassRegistry.cpp | 8 ++++---- engines/wintermute/UI/UIButton.cpp | 3 +++ 15 files changed, 46 insertions(+), 43 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 816821568e..896bdfdaf5 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -1143,8 +1143,8 @@ HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { int OrigY = Attachment->_posY; // inherit position from owner - Attachment->_posX = this->_posX + Attachment->_posX * ScaleX / 100.0f; - Attachment->_posY = this->_posY + Attachment->_posY * ScaleY / 100.0f; + Attachment->_posX = (int)(this->_posX + Attachment->_posX * ScaleX / 100.0f); + Attachment->_posY = (int)(this->_posY + Attachment->_posY * ScaleY / 100.0f); // inherit other props Attachment->_alphaColor = this->_alphaColor; @@ -1194,8 +1194,8 @@ HRESULT CAdObject::UpdatePartEmitter() { float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); - _partEmitter->_posX = _posX + (ScaleX / 100.0f) * _partOffsetX; - _partEmitter->_posY = _posY + (ScaleY / 100.0f) * _partOffsetY; + _partEmitter->_posX = (int)(_posX + (ScaleX / 100.0f) * _partOffsetX); + _partEmitter->_posY = (int)(_posY + (ScaleY / 100.0f) * _partOffsetY); } return _partEmitter->Update(); } diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index 8f9d306824..97e7864dea 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -163,7 +163,7 @@ HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { while (_editorPropsIter != _editorProps.end()) { Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->_key.c_str()); + Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index cd78ece27a..b20d377e93 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -72,7 +72,7 @@ HRESULT CBFader::Update() { if (time >= _duration) _currentAlpha = _targetAlpha; else { - _currentAlpha = _sourceAlpha + (float)time / (float)_duration * AlphaDelta; + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * AlphaDelta); } _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index d7ab99a026..81dca9d293 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -261,14 +261,14 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color), D3DCOLGetB(_layers[0]->_color), D3DCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create(width, _lineHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); uint16 useColor = 0xffff; Common::Array::iterator it; int heightOffset = 0; for (it = lines.begin(); it != lines.end(); it++) { _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += _lineHeight; + heightOffset += (int)_lineHeight; } CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); @@ -399,7 +399,7 @@ void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Co ////////////////////////////////////////////////////////////////////////// int CBFontTT::GetLetterHeight() { - return GetLineHeight(); + return (int)GetLineHeight(); } @@ -641,7 +641,7 @@ HRESULT CBFontTT::InitFont() { if (!file) { // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); - file = Game->_fileManager->OpenFile((char *)fontFileName.c_str(), false); + file = Game->_fileManager->OpenFile(fontFileName.c_str(), false); if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return E_FAIL; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 69a0a31288..3ccd6d6a12 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -197,7 +197,7 @@ CBGame::CBGame(): CBObject(this) { _subtitlesSpeed = 70; - _resourceModule = NULL; + _resourceModule = 0; _forceNonStreamedSounds = false; @@ -568,10 +568,10 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { - int secs = g_system->getMillis() / 1000; - int hours = secs / 3600; + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; secs = secs % 3600; - int mins = secs / 60; + uint32 mins = secs / 60; secs = secs % 60; char buff[512]; diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 80c3372c62..f372335cf1 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -286,10 +286,10 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { } else { RECT rc; Game->GetCurrentViewportRect(&rc); - fillRect.left = rc.left; - fillRect.top = rc.top; - fillRect.setWidth(rc.right - rc.left); - fillRect.setHeight(rc.bottom - rc.top); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); } ModTargetRect(&fillRect); @@ -337,19 +337,19 @@ void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *s // Handle off-screen clipping if (posY < 0) { - img->h = MAX(0, (int)img->h - -posY); + img->h = (uint16)(MAX(0, (int)img->h - -posY)); img->pixels = (byte *)img->pixels + img->pitch * -posY; posY = 0; } if (posX < 0) { - img->w = MAX(0, (int)img->w - -posX); + img->w = (uint16)(MAX(0, (int)img->w - -posX)); img->pixels = (byte *)img->pixels + (-posX * 4); posX = 0; } - img->w = CLIP((int)img->w, 0, (int)MAX((int)_renderSurface->w - posX, 0)); - img->h = CLIP((int)img->h, 0, (int)MAX((int)_renderSurface->h - posY, 0)); + img->w = (uint16)(CLIP((int)img->w, 0, (int)MAX((int)_renderSurface->w - posX, 0))); + img->h = (uint16)(CLIP((int)img->h, 0, (int)MAX((int)_renderSurface->h - posY, 0))); for (int i = 0; i < img->h; i++) { void *destPtr = _renderSurface->getBasePtr(posX, posY + i); @@ -457,10 +457,10 @@ const char *CBRenderSDL::GetName() { HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. - rect.left = left + _borderLeft; - rect.top = top + _borderTop; - rect.right = (right - left) * _ratioX; - rect.bottom = (bottom - top) * _ratioY; + rect.left = (int16)(left + _borderLeft); + rect.top = (int16)(top + _borderTop); + rect.right = (int16)((right - left) * _ratioX); + rect.bottom = (int16)((bottom - top) * _ratioY); // TODO fix this once viewports work correctly in SDL/landscape #ifndef __IPHONEOS__ diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 0dfeab4b07..a721619538 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -467,7 +467,7 @@ void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { // IWmeObject ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::SendEvent(const char *EventName) { - return SUCCEEDED(ApplyEvent((char *)EventName)); + return SUCCEEDED(ApplyEvent(EventName)); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 618c155b36..3bac8ecc78 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -518,8 +518,8 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. Graphics::Surface drawSrc; - drawSrc.w = position.width(); - drawSrc.h = position.height(); + drawSrc.w = (uint16)position.width(); + drawSrc.h = (uint16)position.height(); drawSrc.format = _surface->format; if (position.width() != srcRect.width() || position.height() != srcRect.height()) { diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 500f2a961d..1a9d9008c6 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -97,7 +97,7 @@ HRESULT CBTransitionMgr::Update() { case TRANSITION_FADE_OUT: { uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = 255 - (float)time / (float)FADE_DURATION * 255; + int Alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); Alpha = MIN(255, MAX(Alpha, 0)); Game->_renderer->Fade((uint16)Alpha); @@ -107,7 +107,7 @@ HRESULT CBTransitionMgr::Update() { case TRANSITION_FADE_IN: { uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = (float)time / (float)FADE_DURATION * 255; + int Alpha = (int)((float)time / (float)FADE_DURATION * 255); Alpha = MIN(255, MAX(Alpha, 0)); Game->_renderer->Fade((uint16)Alpha); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 1c845f88be..a3c1843b82 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -178,10 +178,10 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, float GrowthRate = CBUtils::RandomFloat(_growthRate1, _growthRate2); if (!CBPlatform::IsRectEmpty(&_border)) { - int ThicknessLeft = _borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f; - int ThicknessRight = _borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f; - int ThicknessTop = _borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f; - int ThicknessBottom = _borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f; + int ThicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f); + int ThicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f); + int ThicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f); + int ThicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f); Particle->_border = _border; Particle->_border.left += ThicknessLeft; diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 062cda4b83..5f5278199b 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -137,7 +137,7 @@ HRESULT CBSaveThumbFile::Seek(uint32 pos, TSeek origin) { break; } - if (newPos < 0 || newPos > _size) return E_FAIL; + if (newPos > _size) return E_FAIL; else _pos = newPos; return S_OK; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a8bfc10800..c3c376790f 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -94,7 +94,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { #else */ _compilerAvailable = false; - _compilerDLL = NULL; + _compilerDLL = 0; //#endif diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 9eb1970f11..37270d8834 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -167,7 +167,7 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { // Win32 API bindings ////////////////////////////////////////////////////////////////////////// HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd) { - return NULL; + return 0; } ////////////////////////////////////////////////////////////////////////// @@ -236,7 +236,7 @@ bool CBPlatform::CopyFile(const char *from, const char *to, bool failIfExists) { ////////////////////////////////////////////////////////////////////////// HWND CBPlatform::SetCapture(HWND hWnd) { - return NULL; + return 0; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 0a41b59d35..7025e4c79a 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -177,7 +177,7 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, boo counter++; if (!quickSave) { - Game->_indicatorProgress = 50.0f / (float)((float)_classes.size() / (float)counter); + Game->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); Game->DisplayContent(false); Game->_renderer->Flip(); } @@ -206,10 +206,10 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { _instanceMap.clear(); - int numClasses = persistMgr->getDWORD(); + uint32 numClasses = persistMgr->getDWORD(); - for (int i = 0; i < numClasses; i++) { - Game->_indicatorProgress = 50.0f / (float)((float)numClasses / (float)i); + for (uint32 i = 0; i < numClasses; i++) { + Game->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); Game->DisplayContentSimple(); Game->_renderer->Flip(); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 93bef195ea..9ce8230104 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -501,6 +501,9 @@ HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { case TAL_CENTER: Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; + default: + warning("CUIButton::SaveAsText - unhandled enum"); + break; } Buffer->PutTextIndent(Indent + 2, "\n"); -- cgit v1.2.3 From 1c26b37ef2f4571e28a95d83d923b8eed9225231 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 16:19:36 +0200 Subject: WINTERMUTE: Remove the DEGTORAD/RADTODEG-macros --- engines/wintermute/Base/PartEmitter.cpp | 5 +++-- engines/wintermute/dcgf.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index a3c1843b82..89de02a074 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -39,6 +39,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" +#include "common/math.h" namespace WinterMute { @@ -194,7 +195,7 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, Vector2 VecVel(0, Velocity); Matrix4 MatRot; - MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.RotationZ(Common::deg2rad(CBUtils::NormalizeAngle(Angle - 180))); MatRot.TransformVector2(VecVel); if (_alphaTimeBased) { @@ -393,7 +394,7 @@ HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, in Force->_direction = Vector2(0, Strength); Matrix4 MatRot; - MatRot.RotationZ(DegToRad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.RotationZ(Common::deg2rad(CBUtils::NormalizeAngle(Angle - 180))); MatRot.TransformVector2(Force->_direction); return S_OK; diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 74eb7f782a..831a881a69 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -54,7 +54,5 @@ // macros #define RELEASE(obj) if(obj) { obj->Release(); obj = NULL; } else 0 -#define DegToRad(_val) (_val*PI*(1.0f/180.0f)) -#define RadToDeg(_val) (_val*(180/PI)) #endif // _DCGF_H_ -- cgit v1.2.3 From c2a8af7ae567e8869aac9a18d479af943cbf4a95 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 16:44:44 +0200 Subject: WINTERMUTE: Rename functions and arguments in BScriptable. --- engines/wintermute/Ad/AdActor.cpp | 14 +++---- engines/wintermute/Ad/AdActor.h | 8 ++-- engines/wintermute/Ad/AdEntity.cpp | 14 +++---- engines/wintermute/Ad/AdEntity.h | 8 ++-- engines/wintermute/Ad/AdGame.cpp | 22 +++++----- engines/wintermute/Ad/AdGame.h | 6 +-- engines/wintermute/Ad/AdItem.cpp | 14 +++---- engines/wintermute/Ad/AdItem.h | 8 ++-- engines/wintermute/Ad/AdLayer.cpp | 14 +++---- engines/wintermute/Ad/AdLayer.h | 8 ++-- engines/wintermute/Ad/AdObject.cpp | 14 +++---- engines/wintermute/Ad/AdObject.h | 8 ++-- engines/wintermute/Ad/AdRegion.cpp | 14 +++---- engines/wintermute/Ad/AdRegion.h | 8 ++-- engines/wintermute/Ad/AdScene.cpp | 14 +++---- engines/wintermute/Ad/AdScene.h | 8 ++-- engines/wintermute/Ad/AdTalkHolder.cpp | 14 +++---- engines/wintermute/Ad/AdTalkHolder.h | 8 ++-- engines/wintermute/Ad/AdWaypointGroup.cpp | 8 ++-- engines/wintermute/Ad/AdWaypointGroup.h | 4 +- engines/wintermute/Base/BFrame.cpp | 20 ++++----- engines/wintermute/Base/BFrame.h | 8 ++-- engines/wintermute/Base/BGame.cpp | 18 ++++---- engines/wintermute/Base/BGame.h | 8 ++-- engines/wintermute/Base/BKeyboardState.cpp | 14 +++---- engines/wintermute/Base/BKeyboardState.h | 8 ++-- engines/wintermute/Base/BObject.cpp | 14 +++---- engines/wintermute/Base/BObject.h | 8 ++-- engines/wintermute/Base/BRegion.cpp | 14 +++---- engines/wintermute/Base/BRegion.h | 8 ++-- engines/wintermute/Base/BScriptHolder.cpp | 34 +++++++-------- engines/wintermute/Base/BScriptHolder.h | 14 +++---- engines/wintermute/Base/BScriptable.cpp | 48 +++++++++++----------- engines/wintermute/Base/BScriptable.h | 34 +++++++-------- engines/wintermute/Base/BSprite.cpp | 14 +++---- engines/wintermute/Base/BSprite.h | 8 ++-- engines/wintermute/Base/BSubFrame.cpp | 14 +++---- engines/wintermute/Base/BSubFrame.h | 8 ++-- engines/wintermute/Base/PartEmitter.cpp | 14 +++---- engines/wintermute/Base/PartEmitter.h | 8 ++-- engines/wintermute/Base/scriptables/SXArray.cpp | 8 ++-- engines/wintermute/Base/scriptables/SXArray.h | 8 ++-- engines/wintermute/Base/scriptables/SXDate.cpp | 10 ++--- engines/wintermute/Base/scriptables/SXDate.h | 10 ++--- engines/wintermute/Base/scriptables/SXFile.cpp | 14 +++---- engines/wintermute/Base/scriptables/SXFile.h | 8 ++-- engines/wintermute/Base/scriptables/SXMath.cpp | 4 +- engines/wintermute/Base/scriptables/SXMath.h | 4 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 18 ++++---- engines/wintermute/Base/scriptables/SXMemBuffer.h | 12 +++--- engines/wintermute/Base/scriptables/SXStore.cpp | 4 +- engines/wintermute/Base/scriptables/SXStore.h | 4 +- engines/wintermute/Base/scriptables/SXString.cpp | 12 +++--- engines/wintermute/Base/scriptables/SXString.h | 12 +++--- engines/wintermute/Base/scriptables/ScScript.cpp | 10 ++--- engines/wintermute/Base/scriptables/ScScript.h | 2 +- engines/wintermute/Base/scriptables/ScValue.cpp | 34 +++++++-------- engines/wintermute/UI/UIButton.cpp | 14 +++---- engines/wintermute/UI/UIButton.h | 8 ++-- engines/wintermute/UI/UIEdit.cpp | 14 +++---- engines/wintermute/UI/UIEdit.h | 8 ++-- engines/wintermute/UI/UIEntity.cpp | 14 +++---- engines/wintermute/UI/UIEntity.h | 8 ++-- engines/wintermute/UI/UIObject.cpp | 14 +++---- engines/wintermute/UI/UIObject.h | 8 ++-- engines/wintermute/UI/UIText.cpp | 14 +++---- engines/wintermute/UI/UIText.h | 8 ++-- engines/wintermute/UI/UIWindow.cpp | 14 +++---- engines/wintermute/UI/UIWindow.h | 8 ++-- 69 files changed, 419 insertions(+), 419 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index da73b5161c..a5a3895dc3 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -850,7 +850,7 @@ void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// @@ -968,12 +968,12 @@ HRESULT CAdActor::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::ScGetProperty(const char *Name) { +CScValue *CAdActor::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1030,12 +1030,12 @@ CScValue *CAdActor::ScGetProperty(const char *Name) { return _scValue; } - else return CAdTalkHolder::ScGetProperty(Name); + else return CAdTalkHolder::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// @@ -1090,12 +1090,12 @@ HRESULT CAdActor::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CAdTalkHolder::ScSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdActor::ScToString() { +const char *CAdActor::scToString() { return "[actor object]"; } diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index 1a689bafd4..32df33d39a 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -81,10 +81,10 @@ public: CAdSpriteSet *GetAnimByName(const Common::String &animName); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); private: HRESULT SetDefaultAnimNames(); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 1f98d15f36..dae511982d 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -625,7 +625,7 @@ HRESULT CAdEntity::Update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// @@ -755,12 +755,12 @@ HRESULT CAdEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::ScGetProperty(const char *Name) { +CScValue *CAdEntity::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -826,12 +826,12 @@ CScValue *CAdEntity::ScGetProperty(const char *Name) { return _scValue; } - else return CAdTalkHolder::ScGetProperty(Name); + else return CAdTalkHolder::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdEntity::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Item @@ -866,12 +866,12 @@ HRESULT CAdEntity::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CAdTalkHolder::ScSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdEntity::ScToString() { +const char *CAdEntity::scToString() { return "[entity object]"; } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 6590007021..7dff8c072b 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -56,10 +56,10 @@ public: TEntityType _subtype; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index adcae6a4bd..b852ec4469 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -316,7 +316,7 @@ void CAdGame::FinishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// @@ -618,28 +618,28 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This // TakeItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "TakeItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // DropItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "DropItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // GetItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// // HasItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HasItem") == 0) { - return _invObject->ScCallMethod(Script, Stack, ThisStack, Name); + return _invObject->scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// @@ -793,12 +793,12 @@ HRESULT CAdGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } - else return CBGame::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBGame::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::ScGetProperty(const char *Name) { +CScValue *CAdGame::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -831,7 +831,7 @@ CScValue *CAdGame::ScGetProperty(const char *Name) { // NumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumItems") == 0) { - return _invObject->ScGetProperty(Name); + return _invObject->scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// @@ -947,12 +947,12 @@ CScValue *CAdGame::ScGetProperty(const char *Name) { return _scValue; } - else return CBGame::ScGetProperty(Name); + else return CBGame::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem @@ -1042,7 +1042,7 @@ HRESULT CAdGame::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBGame::ScSetProperty(Name, Value); + else return CBGame::scSetProperty(Name, Value); } diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index d4c6ae3b6f..8139102a22 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -151,9 +151,9 @@ public: virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); bool ValidMouse(); }; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 8d891f7d19..bb7d9a1607 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -429,7 +429,7 @@ HRESULT CAdItem::Display(int X, int Y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// @@ -562,12 +562,12 @@ HRESULT CAdItem::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } - else return CAdTalkHolder::ScCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::ScGetProperty(const char *Name) { +CScValue *CAdItem::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -643,12 +643,12 @@ CScValue *CAdItem::ScGetProperty(const char *Name) { return _scValue; } - else return CAdTalkHolder::ScGetProperty(Name); + else return CAdTalkHolder::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -718,12 +718,12 @@ HRESULT CAdItem::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CAdTalkHolder::ScSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdItem::ScToString() { +const char *CAdItem::scToString() { return "[item]"; } diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index 0168ff7ca8..9e970c1b58 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -59,10 +59,10 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 28f437e703..eec0754793 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -227,7 +227,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// @@ -352,12 +352,12 @@ HRESULT CAdLayer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::ScGetProperty(const char *Name) { +CScValue *CAdLayer::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -416,12 +416,12 @@ CScValue *CAdLayer::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -467,12 +467,12 @@ HRESULT CAdLayer::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdLayer::ScToString() { +const char *CAdLayer::scToString() { return "[layer]"; } diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 1c0e3fa946..c06c1e7c92 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -47,10 +47,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 896bdfdaf5..bbd51907fe 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -187,7 +187,7 @@ HRESULT CAdObject::Update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync @@ -603,12 +603,12 @@ HRESULT CAdObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::ScGetProperty(const char *Name) { +CScValue *CAdObject::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -710,12 +710,12 @@ CScValue *CAdObject::ScGetProperty(const char *Name) { } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active @@ -781,12 +781,12 @@ HRESULT CAdObject::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdObject::ScToString() { +const char *CAdObject::scToString() { return "[ad object]"; } diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index 34873c89fc..a7527bd8f6 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -99,10 +99,10 @@ public: CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); CBArray _attachmentsPre; CBArray _attachmentsPost; diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 19e817dd04..8ec34d3fe8 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -219,7 +219,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -233,12 +233,12 @@ HRESULT CAdRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } - else*/ return CBRegion::ScCallMethod(Script, Stack, ThisStack, Name); + else*/ return CBRegion::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::ScGetProperty(const char *Name) { +CScValue *CAdRegion::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -289,12 +289,12 @@ CScValue *CAdRegion::ScGetProperty(const char *Name) { return _scValue; } - else return CBRegion::ScGetProperty(Name); + else return CBRegion::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -335,12 +335,12 @@ HRESULT CAdRegion::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBRegion::ScSetProperty(Name, Value); + else return CBRegion::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdRegion::ScToString() { +const char *CAdRegion::scToString() { return "[ad region]"; } diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 0d119b1ac3..a7db643104 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -47,10 +47,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index c21d694468..9637d09516 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1248,7 +1248,7 @@ void CAdScene::SkipTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// @@ -1674,12 +1674,12 @@ HRESULT CAdScene::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::ScGetProperty(const char *Name) { +CScValue *CAdScene::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1837,12 +1837,12 @@ CScValue *CAdScene::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1939,12 +1939,12 @@ HRESULT CAdScene::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdScene::ScToString() { +const char *CAdScene::scToString() { return "[scene object]"; } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 046db15b21..f772183cb4 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -156,10 +156,10 @@ public: int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); private: diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 162fcf0f2b..a5022e32c5 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -118,7 +118,7 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// @@ -284,12 +284,12 @@ HRESULT CAdTalkHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack return S_OK; } - else return CAdObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CAdObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::ScGetProperty(const char *Name) { +CScValue *CAdTalkHolder::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -300,12 +300,12 @@ CScValue *CAdTalkHolder::ScGetProperty(const char *Name) { return _scValue; } - else return CAdObject::ScGetProperty(Name); + else return CAdObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdTalkHolder::scSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Item @@ -315,12 +315,12 @@ HRESULT CAdTalkHolder::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else*/ return CAdObject::ScSetProperty(Name, Value); + else*/ return CAdObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdTalkHolder::ScToString() { +const char *CAdTalkHolder::scToString() { return "[talk-holder object]"; } diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h index 7c10783057..ec30decece 100644 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -45,10 +45,10 @@ public: virtual ~CAdTalkHolder(); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index a9d29692c5..5f03fa7898 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -200,7 +200,7 @@ HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::ScGetProperty(const char *Name) { +CScValue *CAdWaypointGroup::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -219,12 +219,12 @@ CScValue *CAdWaypointGroup::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdWaypointGroup::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// @@ -233,7 +233,7 @@ HRESULT CAdWaypointGroup::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 2c7d981c58..00852fce41 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -49,8 +49,8 @@ public: virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 1f14c4ea8f..cdf3eab96b 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -401,7 +401,7 @@ HRESULT CBFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -566,14 +566,14 @@ HRESULT CBFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScCallMethod(Script, Stack, ThisStack, Name); - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + if (_subframes.GetSize() == 1) return _subframes[0]->scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); } } ////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::ScGetProperty(const char *Name) { +CScValue *CBFrame::scGetProperty(const char *Name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); @@ -643,14 +643,14 @@ CScValue *CBFrame::ScGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScGetProperty(Name); - else return CBScriptable::ScGetProperty(Name); + if (_subframes.GetSize() == 1) return _subframes[0]->scGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// @@ -693,14 +693,14 @@ HRESULT CBFrame::ScSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->ScSetProperty(Name, Value); - else return CBScriptable::ScSetProperty(Name, Value); + if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(Name, Value); + else return CBScriptable::scSetProperty(Name, Value); } } ////////////////////////////////////////////////////////////////////////// -const char *CBFrame::ScToString() { +const char *CBFrame::scToString() { return "[frame]"; } diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index ac7c88fbf7..64887bd802 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -61,10 +61,10 @@ public: CBArray _applyEvent; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3ccd6d6a12..c54f73fd49 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -978,7 +978,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -993,7 +993,7 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Caption") == 0) { - HRESULT res = CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + HRESULT res = CBObject::scCallMethod(Script, Stack, ThisStack, Name); SetWindowTitle(); return res; } @@ -2160,12 +2160,12 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::ScGetProperty(const char *Name) { +CScValue *CBGame::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -2551,12 +2551,12 @@ CScValue *CBGame::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -2588,7 +2588,7 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Name") == 0) { - HRESULT res = CBObject::ScSetProperty(Name, Value); + HRESULT res = CBObject::scSetProperty(Name, Value); SetWindowTitle(); return res; } @@ -2746,12 +2746,12 @@ HRESULT CBGame::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBGame::ScToString() { +const char *CBGame::scToString() { return "[game object]"; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index e920fab2b9..ecbad813c6 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -225,10 +225,10 @@ public: virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 2d95c34d4f..953270c03b 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -73,7 +73,7 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBKeyboardState::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// @@ -98,12 +98,12 @@ HRESULT CBKeyboardState::ScCallMethod(CScScript *Script, CScStack *Stack, CScSta return S_OK; } - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::ScGetProperty(const char *Name) { +CScValue *CBKeyboardState::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -168,12 +168,12 @@ CScValue *CBKeyboardState::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptable::ScGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBKeyboardState::scSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -184,12 +184,12 @@ HRESULT CBKeyboardState::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else*/ return CBScriptable::ScSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::ScToString() { +const char *CBKeyboardState::scToString() { return "[keyboard state]"; } diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index 0db409f64b..d5b61cfb9a 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -59,10 +59,10 @@ public: static bool IsAltDown(); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); private: uint8 *_keyStates; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 66de667645..92ac56f5de 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -165,7 +165,7 @@ HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -468,12 +468,12 @@ HRESULT CBObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptHolder::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::ScGetProperty(const char *Name) { +CScValue *CBObject::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -661,12 +661,12 @@ CScValue *CBObject::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptHolder::ScGetProperty(Name); + else return CBScriptHolder::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// @@ -840,12 +840,12 @@ HRESULT CBObject::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBScriptHolder::ScSetProperty(Name, Value); + else return CBScriptHolder::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBObject::ScToString() { +const char *CBObject::scToString() { return "[object]"; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 20bc17baac..8bd980a710 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -133,10 +133,10 @@ public: public: // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 355070ba26..867cc33cfe 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -210,7 +210,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -305,12 +305,12 @@ HRESULT CBRegion::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::ScGetProperty(const char *Name) { +CScValue *CBRegion::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -345,12 +345,12 @@ CScValue *CBRegion::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -367,12 +367,12 @@ HRESULT CBRegion::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBRegion::ScToString() { +const char *CBRegion::scToString() { return "[region]"; } diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index c2fe086655..0a4549d003 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -57,10 +57,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index a721619538..0b4d09641e 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -109,7 +109,7 @@ HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -152,7 +152,7 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CanHandleMethod") == 0) { Stack->CorrectParams(1); - Stack->PushBool(CanHandleMethod(Stack->Pop()->GetString())); + Stack->PushBool(canHandleMethod(Stack->Pop()->GetString())); return S_OK; } @@ -203,12 +203,12 @@ HRESULT CBScriptHolder::ScCallMethod(CScScript *Script, CScStack *Stack, CScStac Stack->PushBool(ret); return S_OK; - } else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + } else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::ScGetProperty(const char *Name) { +CScValue *CBScriptHolder::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -235,24 +235,24 @@ CScValue *CBScriptHolder::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptable::ScGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBScriptHolder::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { SetName(Value->GetString()); return S_OK; - } else return CBScriptable::ScSetProperty(Name, Value); + } else return CBScriptable::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::ScToString() { +const char *CBScriptHolder::scToString() { return "[script_holder]"; } @@ -331,9 +331,9 @@ bool CBScriptHolder::CanHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleMethod(const char *MethodName) { +bool CBScriptHolder::canHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->CanHandleMethod(MethodName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; } return false; } @@ -405,7 +405,7 @@ HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { CScValue *val = new CScValue(Game); val->SetString(PropValue); - ScSetProperty(PropName, val); + scSetProperty(PropName, val); delete val; delete[] PropName; @@ -427,16 +427,16 @@ void CBScriptHolder::MakeFreezable(bool Freezable) { ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::InvokeMethodThread(const char *MethodName) { +CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { for (int i = _scripts.GetSize() - 1; i >= 0; i--) { - if (_scripts[i]->CanHandleMethod(MethodName)) { + if (_scripts[i]->canHandleMethod(methodName)) { CScScript *thread = new CScScript(Game, _scripts[i]->_engine); if (thread) { - HRESULT ret = thread->CreateMethodThread(_scripts[i], MethodName); + HRESULT ret = thread->CreateMethodThread(_scripts[i], methodName); if (SUCCEEDED(ret)) { _scripts[i]->_engine->_scripts.Add(thread); - Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], MethodName); + Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], methodName); return thread; } else { @@ -450,8 +450,8 @@ CScScript *CBScriptHolder::InvokeMethodThread(const char *MethodName) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::ScDebuggerDesc(char *Buf, int BufSize) { - strcpy(Buf, ScToString()); +void CBScriptHolder::scDebuggerDesc(char *Buf, int BufSize) { + strcpy(Buf, scToString()); if (_name && strcmp(_name, "") != 0) { strcat(Buf, " Name: "); strcat(Buf, _name); diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index 83df7dc3e0..efedb093a0 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -41,10 +41,10 @@ public: CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); - virtual CScScript *InvokeMethodThread(const char *MethodName); + virtual CScScript *invokeMethodThread(const char *MethodName); virtual void MakeFreezable(bool Freezable); bool CanHandleEvent(const char *EventName); - virtual bool CanHandleMethod(const char *EventMethod); + virtual bool canHandleMethod(const char *EventMethod); HRESULT Cleanup(); HRESULT RemoveScript(CScScript *Script); HRESULT AddScript(const char *Filename); @@ -59,11 +59,11 @@ public: CBArray _scripts; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - virtual void ScDebuggerDesc(char *Buf, int BufSize); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *Buf, int BufSize); // IWmeObject public: virtual bool SendEvent(const char *EventName); diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 38a3325f91..d75f6c1994 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -36,13 +36,13 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CBScriptable, false) ////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool NoValue, bool Persistable): CBNamedObject(inGame) { +CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { _refCount = 0; - if (NoValue) _scValue = NULL; + if (noValue) _scValue = NULL; else _scValue = new CScValue(Game); - _persistable = Persistable; + _persistable = persistable; _scProp = NULL; } @@ -61,7 +61,7 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* Stack->CorrectParams(0); Stack->PushNULL(); @@ -74,67 +74,67 @@ HRESULT CBScriptable::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::ScGetProperty(const char *Name) { +CScValue *CBScriptable::scGetProperty(const char *name) { if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->GetProp(Name); + if (_scProp) return _scProp->GetProp(name); else return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBScriptable::scSetProperty(const char *name, CScValue *value) { if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->SetProp(Name, Value); + if (_scProp) return _scProp->SetProp(name, value); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::ScToString() { +const char *CBScriptable::scToString() { return "[native object]"; } ////////////////////////////////////////////////////////////////////////// -void *CBScriptable::ScToMemBuffer() { +void *CBScriptable::scToMemBuffer() { return (void *)NULL; } ////////////////////////////////////////////////////////////////////////// -int CBScriptable::ScToInt() { +int CBScriptable::scToInt() { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBScriptable::ScToFloat() { +double CBScriptable::scToFloat() { return 0.0f; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::ScToBool() { +bool CBScriptable::scToBool() { return false; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetString(const char *Val) { +void CBScriptable::scSetString(const char *val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetInt(int Val) { +void CBScriptable::scSetInt(int val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetFloat(double Val) { +void CBScriptable::scSetFloat(double val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScSetBool(bool Val) { +void CBScriptable::scSetBool(bool val) { } @@ -150,25 +150,25 @@ HRESULT CBScriptable::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBScriptable::ScCompare(CBScriptable *Val) { +int CBScriptable::scCompare(CBScriptable *Val) { if (this < Val) return -1; else if (this > Val) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::ScDebuggerDesc(char *Buf, int BufSize) { - strcpy(Buf, ScToString()); +void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::CanHandleMethod(const char *EventMethod) { +bool CBScriptable::canHandleMethod(const char *eventMethod) { return false; } ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::InvokeMethodThread(const char *MethodName) { +CScScript *CBScriptable::invokeMethodThread(const char *methodName) { return NULL; } @@ -181,8 +181,8 @@ const char *CBScriptable::DbgGetNativeClass() { } ////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::DbgGetProperty(const char *Name) { - return ScGetProperty(Name); +IWmeDebugProp *CBScriptable::DbgGetProperty(const char *name) { + return scGetProperty(name); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index 0ee7808445..40e7460b92 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -42,28 +42,28 @@ class CScScript; class CBScriptable : public CBNamedObject, public IWmeDebugObject { public: - virtual CScScript *InvokeMethodThread(const char *MethodName); + virtual CScScript *invokeMethodThread(const char *methodName); DECLARE_PERSISTENT(CBScriptable, CBNamedObject) - CBScriptable(CBGame *inGame, bool NoValue = false, bool Persistable = true); + CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); virtual ~CBScriptable(); // high level scripting interface - virtual bool CanHandleMethod(const char *EventMethod); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); - virtual void *ScToMemBuffer(); - virtual int ScToInt(); - virtual double ScToFloat(); - virtual bool ScToBool(); - virtual void ScSetString(const char *Val); - virtual void ScSetInt(int Val); - virtual void ScSetFloat(double Val); - virtual void ScSetBool(bool Val); - virtual int ScCompare(CBScriptable *Val); - virtual void ScDebuggerDesc(char *Buf, int BufSize); + virtual bool canHandleMethod(const char *eventMethod); + virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(CBScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); int _refCount; CScValue *_scValue; CScValue *_scProp; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index f4f6e8b232..ae88a17d44 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -507,7 +507,7 @@ HRESULT CBSprite::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -626,12 +626,12 @@ HRESULT CBSprite::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi return S_OK; } - else return CBScriptHolder::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptHolder::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::ScGetProperty(const char *Name) { +CScValue *CBSprite::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -699,12 +699,12 @@ CScValue *CBSprite::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptHolder::ScGetProperty(Name); + else return CBScriptHolder::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBSprite::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// @@ -733,12 +733,12 @@ HRESULT CBSprite::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBScriptHolder::ScSetProperty(Name, Value); + else return CBScriptHolder::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSprite::ScToString() { +const char *CBSprite::scToString() { return "[sprite]"; } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 8fa1656b37..faa74b4ba3 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -79,10 +79,10 @@ public: HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 5ab1a10a9b..b63ccc0d3c 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -342,7 +342,7 @@ HRESULT CBSubFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBSubFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -378,12 +378,12 @@ HRESULT CBSubFrame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *T return S_OK; } - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::ScGetProperty(const char *Name) { +CScValue *CBSubFrame::scGetProperty(const char *Name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); @@ -468,12 +468,12 @@ CScValue *CBSubFrame::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptable::ScGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// @@ -538,12 +538,12 @@ HRESULT CBSubFrame::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBScriptable::ScSetProperty(Name, Value); + else return CBScriptable::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::ScToString() { +const char *CBSubFrame::scToString() { return "[subframe]"; } diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 00462b1298..fb91e66a21 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -73,10 +73,10 @@ public: CBSurface *_surface; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 89de02a074..2ff9a56679 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -416,7 +416,7 @@ HRESULT CPartEmitter::RemoveForce(const char *Name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -558,11 +558,11 @@ HRESULT CPartEmitter::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::ScGetProperty(const char *Name) { +CScValue *CPartEmitter::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -829,12 +829,12 @@ CScValue *CPartEmitter::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// @@ -1086,12 +1086,12 @@ HRESULT CPartEmitter::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::ScToString() { +const char *CPartEmitter::scToString() { return "[particle emitter]"; } diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 76d4bcdbd2..45997b280e 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -117,10 +117,10 @@ public: CBArray _forces; // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); private: diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 41b3514f92..b7d69bd2f2 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -73,7 +73,7 @@ CSXArray::~CSXArray() { ////////////////////////////////////////////////////////////////////////// -const char *CSXArray::ScToString() { +const char *CSXArray::scToString() { static char Dummy[32768]; strcpy(Dummy, ""); char PropName[20]; @@ -93,7 +93,7 @@ const char *CSXArray::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXArray::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ HRESULT CSXArray::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::ScGetProperty(const char *Name) { +CScValue *CSXArray::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ CScValue *CSXArray::ScGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXArray::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index d1cc4ce4db..938e020d93 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -41,10 +41,10 @@ public: CSXArray(CBGame *inGame, CScStack *Stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); + CScValue *scGetProperty(const char *Name); + HRESULT scSetProperty(const char *Name, CScValue *Value); + HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *scToString(); int _length; CScValue *_values; }; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 465999241f..669b072d2f 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -64,7 +64,7 @@ CSXDate::~CSXDate() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXDate::ScToString() { +const char *CSXDate::scToString() { // TODO: Make this more stringy, and less ISO 8601-like _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); return _strRep.c_str(); @@ -75,7 +75,7 @@ const char *CSXDate::ScToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXDate::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ HRESULT CSXDate::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::ScGetProperty(const char *Name) { +CScValue *CSXDate::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ CScValue *CSXDate::ScGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXDate::scSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -251,7 +251,7 @@ HRESULT CSXDate::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -int CSXDate::ScCompare(CBScriptable *Value) { +int CSXDate::scCompare(CBScriptable *Value) { TimeDate time1 = _tm; TimeDate time2 = ((CSXDate *)Value)->_tm; diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 95334d0196..28d2590c31 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -36,14 +36,14 @@ namespace WinterMute { class CSXDate : public CBScriptable { public: - int ScCompare(CBScriptable *Value); + int scCompare(CBScriptable *Value); DECLARE_PERSISTENT(CSXDate, CBScriptable) CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); + CScValue *scGetProperty(const char *Name); + HRESULT scSetProperty(const char *Name, CScValue *Value); + HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *scToString(); char *_string; TimeDate _tm; private: diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 9e61181ad0..2be008edaf 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -98,14 +98,14 @@ void CSXFile::Close() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXFile::ScToString() { +const char *CSXFile::scToString() { if (_filename) return _filename; else return "[file object]"; } #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -580,12 +580,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } - else return CBScriptable::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::ScGetProperty(const char *Name) { +CScValue *CSXFile::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -636,12 +636,12 @@ CScValue *CSXFile::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptable::ScGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXFile::scSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -659,7 +659,7 @@ HRESULT CSXFile::ScSetProperty(const char *Name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::ScSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index 8c37127f7b..d36f8ec3ae 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -40,10 +40,10 @@ class CBFile; class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); + CScValue *scGetProperty(const char *Name); + HRESULT scSetProperty(const char *Name, CScValue *Value); + HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *scToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); private: diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index da05de0e95..f6ee46e33b 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -58,7 +58,7 @@ CSXMath::~CSXMath() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXMath::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// @@ -249,7 +249,7 @@ HRESULT CSXMath::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::ScGetProperty(const char *Name) { +CScValue *CSXMath::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index 0e61738161..355bb78890 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -39,8 +39,8 @@ public: DECLARE_PERSISTENT(CSXMath, CBScriptable) CSXMath(CBGame *inGame); virtual ~CSXMath(); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); private: double DegreeToRadian(double Value); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 6769d3fda9..de635e1c72 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -64,7 +64,7 @@ CSXMemBuffer::~CSXMemBuffer() { } ////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::ScToMemBuffer() { +void *CSXMemBuffer::scToMemBuffer() { return _buffer; } @@ -116,13 +116,13 @@ bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { } ////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::ScToString() { +const char *CSXMemBuffer::scToString() { return "[membuffer object]"; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -407,7 +407,7 @@ HRESULT CSXMemBuffer::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::ScGetProperty(const char *Name) { +CScValue *CSXMemBuffer::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -426,12 +426,12 @@ CScValue *CSXMemBuffer::ScGetProperty(const char *Name) { return _scValue; } - else return CBScriptable::ScGetProperty(Name); + else return CBScriptable::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXMemBuffer::scSetProperty(const char *Name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -449,7 +449,7 @@ HRESULT CSXMemBuffer::ScSetProperty(const char *Name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::ScSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(Name, Value); } @@ -474,8 +474,8 @@ HRESULT CSXMemBuffer::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::ScCompare(CBScriptable *Val) { - if (_buffer == Val->ScToMemBuffer()) return 0; +int CSXMemBuffer::scCompare(CBScriptable *Val) { + if (_buffer == Val->scToMemBuffer()) return 0; else return 1; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index 54074b183d..d080b1f136 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -36,16 +36,16 @@ namespace WinterMute { class CSXMemBuffer : public CBScriptable { public: - virtual int ScCompare(CBScriptable *Val); + virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - const char *ScToString(); + CScValue *scGetProperty(const char *Name); + HRESULT scSetProperty(const char *Name, CScValue *Value); + HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + const char *scToString(); CSXMemBuffer(CBGame *inGame, CScStack *Stack); CSXMemBuffer(CBGame *inGame, void *Buffer); virtual ~CSXMemBuffer(); - virtual void *ScToMemBuffer(); + virtual void *scToMemBuffer(); int _size; private: HRESULT Resize(int NewSize); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 52e7d2d53f..322ef8930d 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -84,7 +84,7 @@ void CSXStore::Cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // EnableEvents ////////////////////////////////////////////////////////////////////////// @@ -227,7 +227,7 @@ HRESULT CSXStore::ScCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// -CScValue *CSXStore::ScGetProperty(const char *name) { +CScValue *CSXStore::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 200349addf..fd5f36a882 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -129,8 +129,8 @@ public: DECLARE_PERSISTENT(CSXStore, CBObject) CSXStore(CBGame *inGame); virtual ~CSXStore(); - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); void AfterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index fdbcea5ef2..35343d095a 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -86,20 +86,20 @@ void CSXString::SetStringVal(const char *Val) { ////////////////////////////////////////////////////////////////////////// -const char *CSXString::ScToString() { +const char *CSXString::scToString() { if (_string) return _string; else return "[null string]"; } ////////////////////////////////////////////////////////////////////////// -void CSXString::ScSetString(const char *Val) { +void CSXString::scSetString(const char *Val) { SetStringVal(Val); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -317,7 +317,7 @@ HRESULT CSXString::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::ScGetProperty(const char *Name) { +CScValue *CSXString::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,7 @@ CScValue *CSXString::ScGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXString::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// @@ -397,7 +397,7 @@ HRESULT CSXString::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXString::ScCompare(CBScriptable *Val) { +int CSXString::scCompare(CBScriptable *Val) { return strcmp(_string, ((CSXString *)Val)->_string); } diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index 649a6c6f24..1adc0cad1e 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -36,13 +36,13 @@ namespace WinterMute { class CSXString : public CBScriptable { public: - virtual int ScCompare(CBScriptable *Val); + virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *ScGetProperty(const char *Name); - HRESULT ScSetProperty(const char *Name, CScValue *Value); - HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - void ScSetString(const char *Val); - const char *ScToString(); + CScValue *scGetProperty(const char *Name); + HRESULT scSetProperty(const char *Name, CScValue *Value); + HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + void scSetString(const char *Val); + const char *scToString(); void SetStringVal(const char *Val); CSXString(CBGame *inGame, CScStack *Stack); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index c293009da1..33e697ffd7 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -534,13 +534,13 @@ HRESULT CScScript::ExecuteInstruction() { // we are already calling this method, try native if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->GetNative()) { TriedNative = true; - res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); } if (FAILED(res)) { - if (var->IsNative() && var->GetNative()->CanHandleMethod(MethodName)) { + if (var->IsNative() && var->GetNative()->canHandleMethod(MethodName)) { if (!_unbreakable) { - _waitScript = var->GetNative()->InvokeMethodThread(MethodName); + _waitScript = var->GetNative()->invokeMethodThread(MethodName); if (!_waitScript) { _stack->CorrectParams(0); RuntimeError("Error invoking method '%s'.", MethodName); @@ -581,7 +581,7 @@ HRESULT CScScript::ExecuteInstruction() { */ else { res = E_FAIL; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->ScCallMethod(this, _stack, _thisStack, MethodName); + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); if (FAILED(res)) { _stack->CorrectParams(0); @@ -1250,7 +1250,7 @@ bool CScScript::CanHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleMethod(const char *MethodName) { +bool CScScript::canHandleMethod(const char *MethodName) { return GetMethodPos(MethodName) != 0; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 226e6d8031..dd6fcb1f4a 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -69,7 +69,7 @@ public: HRESULT Resume(); HRESULT Pause(); bool CanHandleEvent(const char *EventName); - bool CanHandleMethod(const char *MethodName); + bool canHandleMethod(const char *MethodName); HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 4dce85c1a0..c75487a268 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -178,7 +178,7 @@ CScValue *CScValue::GetProp(const char *Name) { CScValue *ret = NULL; - if (_type == VAL_NATIVE && _valNative) ret = _valNative->ScGetProperty(Name); + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(Name); if (ret == NULL) { _valIter = _valObject.find(Name); @@ -208,7 +208,7 @@ HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool HRESULT ret = E_FAIL; if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->ScSetProperty(Name, Val); + ret = _valNative->scSetProperty(Name, Val); } if (FAILED(ret)) { @@ -347,7 +347,7 @@ void CScValue::SetBool(bool Val) { } if (_type == VAL_NATIVE) { - _valNative->ScSetBool(Val); + _valNative->scSetBool(Val); return; } @@ -364,7 +364,7 @@ void CScValue::SetInt(int Val) { } if (_type == VAL_NATIVE) { - _valNative->ScSetInt(Val); + _valNative->scSetInt(Val); return; } @@ -381,7 +381,7 @@ void CScValue::SetFloat(double Val) { } if (_type == VAL_NATIVE) { - _valNative->ScSetFloat(Val); + _valNative->scSetFloat(Val); return; } @@ -398,7 +398,7 @@ void CScValue::SetString(const char *Val) { } if (_type == VAL_NATIVE) { - _valNative->ScSetString(Val); + _valNative->scSetString(Val); return; } @@ -503,7 +503,7 @@ bool CScValue::GetBool(bool Default) { return _valBool; case VAL_NATIVE: - return _valNative->ScToBool(); + return _valNative->scToBool(); case VAL_INT: return (_valInt != 0); @@ -529,7 +529,7 @@ int CScValue::GetInt(int Default) { return _valBool ? 1 : 0; case VAL_NATIVE: - return _valNative->ScToInt(); + return _valNative->scToInt(); case VAL_INT: return _valInt; @@ -555,7 +555,7 @@ double CScValue::GetFloat(double Default) { return _valBool ? 1.0f : 0.0f; case VAL_NATIVE: - return _valNative->ScToFloat(); + return _valNative->scToFloat(); case VAL_INT: return (double)_valInt; @@ -575,7 +575,7 @@ double CScValue::GetFloat(double Default) { void *CScValue::GetMemBuffer() { if (_type == VAL_VARIABLE_REF) return _valRef->GetMemBuffer(); - if (_type == VAL_NATIVE) return _valNative->ScToMemBuffer(); + if (_type == VAL_NATIVE) return _valNative->scToMemBuffer(); else return (void *)NULL; } @@ -594,7 +594,7 @@ const char *CScValue::GetString() { break; case VAL_NATIVE: { - const char *StrVal = _valNative->ScToString(); + const char *StrVal = _valNative->scToString(); SetStringVal(StrVal); return StrVal; break; @@ -696,16 +696,16 @@ void CScValue::SetValue(CScValue *Val) { if (_type == VAL_NATIVE && (Val->_type == VAL_INT || Val->_type == VAL_STRING || Val->_type == VAL_BOOL)) { switch (Val->_type) { case VAL_INT: - _valNative->ScSetInt(Val->GetInt()); + _valNative->scSetInt(Val->GetInt()); break; case VAL_FLOAT: - _valNative->ScSetFloat(Val->GetFloat()); + _valNative->scSetFloat(Val->GetFloat()); break; case VAL_BOOL: - _valNative->ScSetBool(Val->GetBool()); + _valNative->scSetBool(Val->GetBool()); break; case VAL_STRING: - _valNative->ScSetString(Val->GetString()); + _valNative->scSetString(Val->GetString()); break; default: warning("CScValue::SetValue - unhandled enum"); @@ -823,7 +823,7 @@ int CScValue::Compare(CScValue *Val1, CScValue *Val2) { if (Val1->IsNative() && Val2->IsNative()) { // same class? if (strcmp(Val1->GetNative()->GetClassName(), Val2->GetNative()->GetClassName()) == 0) { - return Val1->GetNative()->ScCompare(Val2->GetNative()); + return Val1->GetNative()->scCompare(Val2->GetNative()); } else return strcmp(Val1->GetString(), Val2->GetString()); } @@ -1024,7 +1024,7 @@ bool CScValue::DbgGetDescription(char *Buf, int BufSize) { if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(Buf, BufSize); if (_type == VAL_NATIVE) { - _valNative->ScDebuggerDesc(Buf, BufSize); + _valNative->scDebuggerDesc(Buf, BufSize); } else { strncpy(Buf, GetString(), BufSize); } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 9ce8230104..493c41649c 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -666,7 +666,7 @@ void CUIButton::Press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// @@ -916,12 +916,12 @@ HRESULT CUIButton::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::ScGetProperty(const char *Name) { +CScValue *CUIButton::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -962,12 +962,12 @@ CScValue *CUIButton::ScGetProperty(const char *Name) { return _scValue; } - else return CUIObject::ScGetProperty(Name); + else return CUIObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIButton::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -1000,12 +1000,12 @@ HRESULT CUIButton::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::ScSetProperty(Name, Value); + else return CUIObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIButton::ScToString() { +const char *CUIButton::scToString() { return "[button]"; } diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 75133e2c0a..29496bdf79 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -68,10 +68,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 3b4b274bd0..8e9708526f 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -361,7 +361,7 @@ HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIEdit::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// @@ -375,12 +375,12 @@ HRESULT CUIEdit::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::ScGetProperty(const char *Name) { +CScValue *CUIEdit::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -452,12 +452,12 @@ CScValue *CUIEdit::ScGetProperty(const char *Name) { return _scValue; } - else return CUIObject::ScGetProperty(Name); + else return CUIObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// @@ -523,12 +523,12 @@ HRESULT CUIEdit::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::ScSetProperty(Name, Value); + else return CUIObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIEdit::ScToString() { +const char *CUIEdit::scToString() { return "[edit]"; } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 4771a0f772..44bd6198a6 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -61,10 +61,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index d8d53270ef..d473f18a1a 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -251,7 +251,7 @@ HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// @@ -280,12 +280,12 @@ HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::ScGetProperty(const char *Name) { +CScValue *CUIEntity::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -305,24 +305,24 @@ CScValue *CUIEntity::ScGetProperty(const char *Name) { return _scValue; } - else return CUIObject::ScGetProperty(Name); + else return CUIObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIEntity::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Freezable") == 0) { if (_entity) _entity->MakeFreezable(Value->GetBool()); return S_OK; - } else return CUIObject::ScSetProperty(Name, Value); + } else return CUIObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIEntity::ScToString() { +const char *CUIEntity::scToString() { return "[entity container]"; } diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index c18fd952dc..1db2eb5ccc 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -47,10 +47,10 @@ public: HRESULT SetEntity(const char *Filename); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 64a2b28084..9ed7e36182 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -137,7 +137,7 @@ void CUIObject::CorrectSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// @@ -312,12 +312,12 @@ HRESULT CUIObject::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } - else return CBObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::ScGetProperty(const char *Name) { +CScValue *CUIObject::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -413,12 +413,12 @@ CScValue *CUIObject::ScGetProperty(const char *Name) { return _scValue; } - else return CBObject::ScGetProperty(Name); + else return CBObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -475,12 +475,12 @@ HRESULT CUIObject::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::ScSetProperty(Name, Value); + else return CBObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIObject::ScToString() { +const char *CUIObject::scToString() { return "[ui_object]"; } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 7d6dfb41f5..b91be5ac92 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -72,10 +72,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 7213c34534..adfb4801e4 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -376,7 +376,7 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIText::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// @@ -397,12 +397,12 @@ HRESULT CUIText::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This return S_OK; } - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::ScGetProperty(const char *Name) { +CScValue *CUIText::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -429,12 +429,12 @@ CScValue *CUIText::ScGetProperty(const char *Name) { return _scValue; } - else return CUIObject::ScGetProperty(Name); + else return CUIObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIText::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -455,12 +455,12 @@ HRESULT CUIText::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::ScSetProperty(Name, Value); + else return CUIObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIText::ScToString() { +const char *CUIText::scToString() { return "[static]"; } diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 756834fd5c..74e70acdd7 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -48,10 +48,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d0d91084d9..cc1b0bc806 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -690,7 +690,7 @@ HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// @@ -912,12 +912,12 @@ HRESULT CUIWindow::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th return S_OK; } else if SUCCEEDED(Game->WindowScriptMethodHook(this, Script, Stack, Name)) return S_OK; - else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::ScGetProperty(const char *Name) { +CScValue *CUIWindow::scGetProperty(const char *Name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1000,12 +1000,12 @@ CScValue *CUIWindow::ScGetProperty(const char *Name) { return _scValue; } - else return CUIObject::ScGetProperty(Name); + else return CUIObject::scGetProperty(Name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1089,12 +1089,12 @@ HRESULT CUIWindow::ScSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::ScSetProperty(Name, Value); + else return CUIObject::scSetProperty(Name, Value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIWindow::ScToString() { +const char *CUIWindow::scToString() { return "[window]"; } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 43d5961e7e..4b376b1929 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -82,10 +82,10 @@ public: virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *ScGetProperty(const char *Name); - virtual HRESULT ScSetProperty(const char *Name, CScValue *Value); - virtual HRESULT ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - virtual const char *ScToString(); + virtual CScValue *scGetProperty(const char *Name); + virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual const char *scToString(); }; } // end of namespace WinterMute -- cgit v1.2.3 From c4c3f724a6bcd7cdb80c333fae661f2b10c6aaf5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 17:09:58 +0200 Subject: WINTERMUTE: Silence a warning in wintypes.h --- engines/wintermute/wintypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 026dfeab27..82134f7725 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -81,7 +81,7 @@ typedef int32 HRESULT; //#define S_FALSE ((HRESULT)1) #define E_FAIL ((HRESULT)-1) -#endif __WIN32__ +#endif // __WIN32__ //} // end of namespace WinterMute -- cgit v1.2.3 From 580ed9026f0f9e0cff5f6e9818c9e2248a0ae4e5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 25 Jun 2012 17:24:00 +0200 Subject: WINTERMUTE: Remove std::replace from PathUtil --- engines/wintermute/utils/PathUtil.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index 284db8acfc..ba432019eb 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -37,7 +37,10 @@ namespace WinterMute { AnsiString PathUtil::UnifySeparators(const AnsiString &path) { AnsiString newPath = path; - std::replace(newPath.begin(), newPath.end(), L'\\', L'/'); + AnsiString::iterator it; + for (it = newPath.begin(); it != newPath.end(); it++) { + if (*it == '\\') *it = '/'; + } return newPath; } -- cgit v1.2.3 From 4f1989e6b82ed493b59a06df7744c62b668b5929 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 00:13:57 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BBase --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdEntity.cpp | 12 ++++++------ engines/wintermute/Ad/AdEntity.h | 2 +- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 8 ++++---- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 2 +- engines/wintermute/Ad/AdLayer.cpp | 12 ++++++------ engines/wintermute/Ad/AdLayer.h | 2 +- engines/wintermute/Ad/AdObject.cpp | 8 ++++---- engines/wintermute/Ad/AdObject.h | 2 +- engines/wintermute/Ad/AdRegion.cpp | 8 ++++---- engines/wintermute/Ad/AdRegion.h | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 8 ++++---- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 6 +++--- engines/wintermute/Ad/AdRotLevel.h | 2 +- engines/wintermute/Ad/AdScaleLevel.cpp | 6 +++--- engines/wintermute/Ad/AdScaleLevel.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 18 +++++++++--------- engines/wintermute/Ad/AdScene.h | 2 +- engines/wintermute/Ad/AdSpriteSet.cpp | 6 +++--- engines/wintermute/Ad/AdSpriteSet.h | 2 +- engines/wintermute/Ad/AdTalkDef.cpp | 10 +++++----- engines/wintermute/Ad/AdTalkDef.h | 2 +- engines/wintermute/Ad/AdTalkHolder.cpp | 2 +- engines/wintermute/Ad/AdTalkHolder.h | 2 +- engines/wintermute/Ad/AdTalkNode.cpp | 8 ++++---- engines/wintermute/Ad/AdTalkNode.h | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 8 ++++---- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- engines/wintermute/Base/BBase.cpp | 10 +++++----- engines/wintermute/Base/BBase.h | 8 ++++---- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFrame.cpp | 10 +++++----- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BRegion.cpp | 4 ++-- engines/wintermute/Base/BRegion.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 4 ++-- engines/wintermute/Base/BScriptHolder.h | 2 +- engines/wintermute/Base/BSprite.cpp | 8 ++++---- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BSubFrame.cpp | 6 +++--- engines/wintermute/Base/BSubFrame.h | 2 +- engines/wintermute/Base/scriptables/ScValue.cpp | 2 +- engines/wintermute/Base/scriptables/ScValue.h | 2 +- engines/wintermute/UI/UIButton.cpp | 6 +++--- engines/wintermute/UI/UIButton.h | 2 +- engines/wintermute/UI/UIEdit.cpp | 6 +++--- engines/wintermute/UI/UIEdit.h | 2 +- engines/wintermute/UI/UIEntity.cpp | 6 +++--- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIObject.h | 2 +- engines/wintermute/UI/UIText.cpp | 6 +++--- engines/wintermute/UI/UIText.h | 2 +- engines/wintermute/UI/UITiledImage.cpp | 6 +++--- engines/wintermute/UI/UITiledImage.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 8 ++++---- engines/wintermute/UI/UIWindow.h | 2 +- 63 files changed, 140 insertions(+), 140 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index a5a3895dc3..09f19da65c 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -428,7 +428,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; case TOKEN_ANIMATION: { diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index dae511982d..0cd1276885 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -431,7 +431,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; case TOKEN_WALK_TO_X: @@ -877,7 +877,7 @@ const char *CAdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ENTITY {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) @@ -942,13 +942,13 @@ HRESULT CAdEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { if (_cursor && _cursor->_filename) Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - CAdTalkHolder::SaveAsText(Buffer, Indent + 2); + CAdTalkHolder::saveAsText(Buffer, Indent + 2); - if (_region) _region->SaveAsText(Buffer, Indent + 2); + if (_region) _region->saveAsText(Buffer, Indent + 2); - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); - CAdObject::SaveAsText(Buffer, Indent + 2); + CAdObject::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 7dff8c072b..9418147cb7 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -46,7 +46,7 @@ public: void UpdatePosition(); virtual int GetHeight(); CBRegion *_region; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Update(); virtual HRESULT Display(); CAdEntity(CBGame *inGame); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index b852ec4469..049247db0a 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1229,7 +1229,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params2, false); + parseEditorProperty(params2, false); break; case TOKEN_STARTUP_SCENE: diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 100d4f8d8e..7a1b7d6f00 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -281,7 +281,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -317,7 +317,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -337,12 +337,12 @@ HRESULT CAdInventoryBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // window - if (_window) _window->SaveAsText(Buffer, Indent + 2); + if (_window) _window->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index c7aeca6eab..463c6c224a 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -55,7 +55,7 @@ public: virtual ~CAdInventoryBox(); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index bb7d9a1607..7f4a8d6525 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -296,7 +296,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index eec0754793..1183e0efa1 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -211,7 +211,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -478,7 +478,7 @@ const char *CAdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "LAYER {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); @@ -496,15 +496,15 @@ HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); for (i = 0; i < _nodes.GetSize(); i++) { switch (_nodes[i]->_type) { case OBJECT_ENTITY: - _nodes[i]->_entity->SaveAsText(Buffer, Indent + 2); + _nodes[i]->_entity->saveAsText(Buffer, Indent + 2); break; case OBJECT_REGION: - _nodes[i]->_region->SaveAsText(Buffer, Indent + 2); + _nodes[i]->_region->saveAsText(Buffer, Indent + 2); break; default: error("CAdLayer::SaveAsText - Unhandled enum"); @@ -512,7 +512,7 @@ HRESULT CAdLayer::SaveAsText(CBDynBuffer *Buffer, int Indent) { } } - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index c06c1e7c92..69208298a7 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -44,7 +44,7 @@ public: CBArray _nodes; HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index bbd51907fe..15c07aa22b 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -1025,11 +1025,11 @@ bool CAdObject::GetExtendedFlag(const char *FlagName) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { - if (_blockRegion) _blockRegion->SaveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->SaveAsText(Buffer, Indent + 2); +HRESULT CAdObject::saveAsText(CBDynBuffer *Buffer, int Indent) { + if (_blockRegion) _blockRegion->saveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->saveAsText(Buffer, Indent + 2); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); return S_OK; } diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index a7527bd8f6..6c20e5d84e 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -93,7 +93,7 @@ public: CAdWaypointGroup *_currentWptGroup; CAdInventory *GetInventory(); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT AfterMove(); CAdRegion *_currentRegions[MAX_NUM_REGIONS]; diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 8ec34d3fe8..fb8493b1d4 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -199,7 +199,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -346,7 +346,7 @@ const char *CAdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdRegion::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "REGION {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); @@ -363,13 +363,13 @@ HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); for (i = 0; i < _points.GetSize(); i++) { Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index a7db643104..2608aae77c 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -44,7 +44,7 @@ public: virtual ~CAdRegion(); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 0359da03dd..1da0389037 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -305,7 +305,7 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; case TOKEN_CURSOR: @@ -335,7 +335,7 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -383,12 +383,12 @@ HRESULT CAdResponseBox::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // window - if (_window) _window->SaveAsText(Buffer, Indent + 2); + if (_window) _window->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 8f26940d0a..52e5e20d76 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -77,7 +77,7 @@ public: TTextAlign _align; HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 371c2f6ab0..b1256c9f27 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -121,7 +121,7 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -135,11 +135,11 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdRotLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index 94612c15b5..5701055a97 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -39,7 +39,7 @@ public: CAdRotLevel(CBGame *inGame); virtual ~CAdRotLevel(); float _rotation; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index be459bbcaf..8e03781382 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -119,7 +119,7 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -133,11 +133,11 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdScaleLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index 28fdbceb41..2026a1ff58 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -40,7 +40,7 @@ public: float _scale; CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 9637d09516..e14a6ce5ba 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -836,7 +836,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } @@ -1969,7 +1969,7 @@ HRESULT CAdScene::RemoveObject(CAdObject *Object) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { int i; Buffer->PutTextIndent(Indent, "SCENE {\n"); @@ -1992,7 +1992,7 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // properties - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); // viewport if (_viewport) { @@ -2027,25 +2027,25 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); // waypoints Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); // layers Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.GetSize(); i++) _layers[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _layers.GetSize(); i++) _layers[i]->saveAsText(Buffer, Indent + 2); // scale levels Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->saveAsText(Buffer, Indent + 2); // rotation levels Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->SaveAsText(Buffer, Indent + 2); + for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -2054,7 +2054,7 @@ HRESULT CAdScene::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { - _objects[i]->SaveAsText(Buffer, Indent + 2); + _objects[i]->saveAsText(Buffer, Indent + 2); } } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index f772183cb4..4d3720ecfa 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -87,7 +87,7 @@ public: float GetScaleAt(int Y); HRESULT SortScaleLevels(); HRESULT SortRotLevels(); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; void SkipTo(int OffsetX, int OffsetY); diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 70b5f15dbe..64de71f39d 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -194,7 +194,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -259,7 +259,7 @@ CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SPRITESET {\n"); if (_name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { @@ -293,7 +293,7 @@ HRESULT CAdSpriteSet::SaveAsText(CBDynBuffer *Buffer, int Indent) { } } - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index 07d2097215..fab0d7143a 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -38,7 +38,7 @@ namespace WinterMute { class CAdSpriteSet : public CBObject { public: bool ContainsSprite(CBSprite *Sprite); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); CBSprite *GetSprite(TDirection Direction); DECLARE_PERSISTENT(CAdSpriteSet, CBObject) CBObject *_owner; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 2f3e9de799..41ea23ff38 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -159,7 +159,7 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -210,18 +210,18 @@ HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdTalkDef::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "TALK {\n"); if (_defaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); if (_defaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->SaveAsText(Buffer, Indent + 2); + else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(Buffer, Indent + 2); for (int i = 0; i < _nodes.GetSize(); i++) { - _nodes[i]->SaveAsText(Buffer, Indent + 2); + _nodes[i]->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "\n"); } - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 08abcaf32b..870408f820 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -50,7 +50,7 @@ public: CBArray _nodes; char *_defaultSpriteFilename; CBSprite *_defaultSprite; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index a5022e32c5..222376dd8d 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -326,7 +326,7 @@ const char *CAdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *Buffer, int Indent) { int i; for (i = 0; i < _talkSprites.GetSize(); i++) { if (_talkSprites[i]->_filename) diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h index ec30decece..193dadfe00 100644 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -37,7 +37,7 @@ class CAdTalkHolder : public CAdObject { public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) virtual CBSprite *GetTalkStance(const char *Stance); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); CBSprite *_sprite; CBArray _talkSprites; CBArray _talkSpritesEx; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index bb6ff83efb..d9aeb2e85f 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -147,7 +147,7 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -198,17 +198,17 @@ HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdTalkNode::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ACTION {\n"); if (_comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); if (!_playToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); if (_spriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); if (_spriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->SaveAsText(Buffer, Indent + 2); + else if (_spriteSet) _spriteSet->saveAsText(Buffer, Indent + 2); if (_preCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h index 519b57add0..8d356181e8 100644 --- a/engines/wintermute/Ad/AdTalkNode.h +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -47,7 +47,7 @@ public: CAdTalkNode(CBGame *inGame); virtual ~CAdTalkNode(); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); char *_spriteFilename; CBSprite *_sprite; uint32 _startTime; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 5f03fa7898..481f495880 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -150,7 +150,7 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -164,14 +164,14 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); - CBBase::SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); for (int i = 0; i < _points.GetSize(); i++) { Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 00852fce41..1cf44716a5 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -41,7 +41,7 @@ public: void Cleanup(); HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); bool _active; CAdWaypointGroup(CBGame *inGame); HRESULT LoadFile(const char *Filename); diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index 97e7864dea..afae06af68 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -55,7 +55,7 @@ CBBase::~CBBase() { ////////////////////////////////////////////////////////////////////////// -const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { +const char *CBBase::getEditorProp(const char *PropName, const char *InitVal) { _editorPropsIter = _editorProps.find(PropName); if (_editorPropsIter != _editorProps.end()) return _editorPropsIter->_value.c_str(); @@ -65,7 +65,7 @@ const char *CBBase::GetEditorProp(const char *PropName, const char *InitVal) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::SetEditorProp(const char *PropName, const char *PropValue) { +HRESULT CBBase::setEditorProp(const char *PropName, const char *PropValue) { if (PropName == NULL) return E_FAIL; if (PropValue == NULL) { @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { +HRESULT CBBase::parseEditorProperty(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -146,7 +146,7 @@ HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { } - SetEditorProp(PropName, PropValue); + setEditorProp(PropName, PropValue); delete[] PropName; delete[] PropValue; @@ -158,7 +158,7 @@ HRESULT CBBase::ParseEditorProperty(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBBase::saveAsText(CBDynBuffer *Buffer, int Indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index ea4efa00d1..15bc768bfd 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -43,11 +43,11 @@ class CBDynBuffer; class CBBase { public: bool _persistable; - HRESULT SetEditorProp(const char *PropName, const char *PropValue); - const char *GetEditorProp(const char *PropName, const char *InitVal = NULL); + HRESULT setEditorProp(const char *PropName, const char *PropValue); + const char *getEditorProp(const char *PropName, const char *InitVal = NULL); CBBase(TDynamicConstructor, TDynamicConstructor) {}; - HRESULT ParseEditorProperty(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent = 0); + HRESULT parseEditorProperty(byte *Buffer, bool Complete = true); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); CBBase(); CBGame *Game; CBBase(CBGame *GameOwner); diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 5db8e34a08..8e7a8c20b3 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -391,7 +391,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + parseEditorProperty((byte *)params, false); break; } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index cdf3eab96b..2838c57d89 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -276,7 +276,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + parseEditorProperty((byte *)params, false); break; } } @@ -342,7 +342,7 @@ bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBFrame::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "FRAME {\n"); Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", _delay); @@ -360,18 +360,18 @@ HRESULT CBFrame::SaveAsText(CBDynBuffer *Buffer, int Indent) { if (_editorExpanded) Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - if (_subframes.GetSize() > 0) _subframes[0]->SaveAsText(Buffer, Indent, false); + if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(Buffer, Indent, false); int i; for (i = 1; i < _subframes.GetSize(); i++) { - _subframes[i]->SaveAsText(Buffer, Indent + 2); + _subframes[i]->saveAsText(Buffer, Indent + 2); } for (i = 0; i < _applyEvent.GetSize(); i++) { Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 64887bd802..752e0c6925 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -47,7 +47,7 @@ public: CBSound *_sound; bool _editorExpanded; bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); int _moveY; int _moveX; uint32 _delay; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index c54f73fd49..cfa3002d32 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -891,7 +891,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; case TOKEN_THUMBNAIL_WIDTH: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 92ac56f5de..7eee851e65 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -858,7 +858,7 @@ HRESULT CBObject::ShowCursor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBObject::saveAsText(CBDynBuffer *Buffer, int Indent) { return S_OK; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 8bd980a710..4658770aad 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -97,7 +97,7 @@ public: CBSprite *_cursor; bool _sharedCursors; CBSprite *_activeCursor; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 867cc33cfe..5a9ddcbbf0 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -378,7 +378,7 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { +HRESULT CBRegion::saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); @@ -397,7 +397,7 @@ HRESULT CBRegion::SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOv Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - if (_scProp) _scProp->SaveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 0a4549d003..aa49503967 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -54,7 +54,7 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); RECT _rect; CBArray _points; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 0b4d09641e..d47f2915c6 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -257,8 +257,8 @@ const char *CBScriptHolder::scToString() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::SaveAsText(CBDynBuffer *Buffer, int Indent) { - return CBBase::SaveAsText(Buffer, Indent); +HRESULT CBScriptHolder::saveAsText(CBDynBuffer *Buffer, int Indent) { + return CBBase::saveAsText(Buffer, Indent); } diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index efedb093a0..6e406699d5 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -48,7 +48,7 @@ public: HRESULT Cleanup(); HRESULT RemoveScript(CScScript *Script); HRESULT AddScript(const char *Filename); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); void SetFilename(const char *Filename); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index ae88a17d44..670bf77560 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -302,7 +302,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -428,7 +428,7 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBSprite::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SPRITE {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); @@ -451,7 +451,7 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } - CBScriptHolder::SaveAsText(Buffer, Indent + 2); + CBScriptHolder::saveAsText(Buffer, Indent + 2); int i; @@ -462,7 +462,7 @@ HRESULT CBSprite::SaveAsText(CBDynBuffer *Buffer, int Indent) { for (i = 0; i < _frames.GetSize(); i++) { - _frames[i]->SaveAsText(Buffer, Indent + 2); + _frames[i]->saveAsText(Buffer, Indent + 2); } Buffer->PutTextIndent(Indent, "}\n\n"); diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index faa74b4ba3..6969253285 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -76,7 +76,7 @@ public: CBSprite(CBGame *inGame, CBObject *Owner = NULL); virtual ~CBSprite(); CBArray _frames; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index b63ccc0d3c..2ff51f289a 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -172,7 +172,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty((byte *)params, false); + parseEditorProperty((byte *)params, false); break; } } @@ -249,7 +249,7 @@ bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { +HRESULT CBSubFrame::saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { if (Complete) Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); @@ -291,7 +291,7 @@ HRESULT CBSubFrame::SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { if (_editorSelected) Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); if (Complete) diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index fb91e66a21..4226fc7a2d 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -46,7 +46,7 @@ public: DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void SetDefaultRect(); uint32 _transparent; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); + HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index c75487a268..cb007f91b1 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -802,7 +802,7 @@ HRESULT CScValue::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CScValue::saveAsText(CBDynBuffer *Buffer, int Indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { Buffer->PutTextIndent(Indent, "PROPERTY {\n"); diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 79a6634fb3..6f6388a9da 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -52,7 +52,7 @@ public: DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; - HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); void SetValue(CScValue *Val); bool _persistent; bool PropExists(const char *Name); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 493c41649c..d9d39791f5 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -421,7 +421,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -440,7 +440,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIButton::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "BUTTON\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -532,7 +532,7 @@ HRESULT CUIButton::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 29496bdf79..0f2a01b425 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -65,7 +65,7 @@ public: virtual ~CUIButton(); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 8e9708526f..9fd2c7664e 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -283,7 +283,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -302,7 +302,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIEdit::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "EDIT\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -352,7 +352,7 @@ HRESULT CUIEdit::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 44bd6198a6..aea0f6088e 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -58,7 +58,7 @@ public: HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index d473f18a1a..eca15ec513 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -150,7 +150,7 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -174,7 +174,7 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -201,7 +201,7 @@ HRESULT CUIEntity::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 1db2eb5ccc..5c3f29bd7d 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -40,7 +40,7 @@ public: virtual ~CUIEntity(); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 9ed7e36182..da7fd37502 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -582,7 +582,7 @@ HRESULT CUIObject::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIObject::saveAsText(CBDynBuffer *Buffer, int Indent) { return E_FAIL; } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index b91be5ac92..910a2045cc 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -69,7 +69,7 @@ public: uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; CUIObject *_focusedWidget; - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index adfb4801e4..6034131763 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -274,7 +274,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -293,7 +293,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "STATIC\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -367,7 +367,7 @@ HRESULT CUIText::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 74e70acdd7..e59c7b3cb3 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -45,7 +45,7 @@ public: TVerticalAlign _verticalAlign; HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index ba2558aa84..38cbdfdba7 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -255,7 +255,7 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; } } @@ -307,7 +307,7 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -330,7 +330,7 @@ HRESULT CUITiledImage::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); return S_OK; diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 03d15a0daa..f73c995310 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -40,7 +40,7 @@ public: void CorrectSize(int *Width, int *Height); HRESULT LoadFile(const char *Filename); HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); HRESULT Display(int X, int Y, int Width, int Height); CUITiledImage(CBGame *inGame = NULL); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index cc1b0bc806..319a81ecf5 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -525,7 +525,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_EDITOR_PROPERTY: - ParseEditorProperty(params, false); + parseEditorProperty(params, false); break; case TOKEN_ALPHA_COLOR: @@ -567,7 +567,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "WINDOW\n"); Buffer->PutTextIndent(Indent, "{\n"); @@ -658,11 +658,11 @@ HRESULT CUIWindow::SaveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "\n"); // editor properties - CBBase::SaveAsText(Buffer, Indent + 2); + CBBase::saveAsText(Buffer, Indent + 2); // controls for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->SaveAsText(Buffer, Indent + 2); + _widgets[i]->saveAsText(Buffer, Indent + 2); Buffer->PutTextIndent(Indent, "}\n"); diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 4b376b1929..b8b8613d21 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -79,7 +79,7 @@ public: CBFont *_fontInactive; CBSprite *_imageInactive; virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - virtual HRESULT SaveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface virtual CScValue *scGetProperty(const char *Name); -- cgit v1.2.3 From 37079a633591c386731c6287800a09cb093ae78b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 00:41:05 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BNamedObject and BScriptHolder --- engines/wintermute/Ad/AdActor.cpp | 6 +- engines/wintermute/Ad/AdEntity.cpp | 6 +- engines/wintermute/Ad/AdGame.cpp | 54 +++++++------- engines/wintermute/Ad/AdGame.h | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 8 +- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 8 +- engines/wintermute/Ad/AdLayer.cpp | 16 ++-- engines/wintermute/Ad/AdNodeState.cpp | 8 +- engines/wintermute/Ad/AdNodeState.h | 4 +- engines/wintermute/Ad/AdObject.cpp | 4 +- engines/wintermute/Ad/AdRegion.cpp | 8 +- engines/wintermute/Ad/AdResponseBox.cpp | 6 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 22 +++--- engines/wintermute/Ad/AdScene.h | 2 +- engines/wintermute/Ad/AdSceneState.cpp | 4 +- engines/wintermute/Ad/AdSceneState.h | 2 +- engines/wintermute/Ad/AdSpriteSet.cpp | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 10 +-- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- engines/wintermute/Base/BDynBuffer.cpp | 6 +- engines/wintermute/Base/BDynBuffer.h | 2 +- engines/wintermute/Base/BFileManager.cpp | 6 +- engines/wintermute/Base/BFileManager.h | 2 +- engines/wintermute/Base/BFontStorage.cpp | 6 +- engines/wintermute/Base/BFontStorage.h | 2 +- engines/wintermute/Base/BFrame.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 86 +++++++++++----------- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BKeyboardState.cpp | 4 +- engines/wintermute/Base/BNamedObject.cpp | 6 +- engines/wintermute/Base/BNamedObject.h | 2 +- engines/wintermute/Base/BObject.cpp | 10 +-- engines/wintermute/Base/BObject.h | 4 +- engines/wintermute/Base/BRegion.cpp | 14 ++-- engines/wintermute/Base/BRegion.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 36 ++++----- engines/wintermute/Base/BScriptHolder.h | 34 ++++----- engines/wintermute/Base/BSprite.cpp | 16 ++-- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BSurfaceStorage.cpp | 6 +- engines/wintermute/Base/BSurfaceStorage.h | 2 +- engines/wintermute/Base/PartEmitter.cpp | 4 +- engines/wintermute/Base/scriptables/SXDate.cpp | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 6 +- engines/wintermute/Base/scriptables/SXFile.h | 2 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 4 +- engines/wintermute/Base/scriptables/SXMemBuffer.h | 2 +- engines/wintermute/Base/scriptables/SXStore.cpp | 16 ++-- engines/wintermute/Base/scriptables/SXStore.h | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 12 +-- engines/wintermute/Base/scriptables/ScEngine.h | 4 +- engines/wintermute/Base/scriptables/ScScript.cpp | 18 ++--- engines/wintermute/Base/scriptables/ScScript.h | 4 +- engines/wintermute/Base/scriptables/ScStack.cpp | 4 +- engines/wintermute/Base/scriptables/ScValue.cpp | 8 +- engines/wintermute/Base/scriptables/ScValue.h | 2 +- engines/wintermute/Base/scriptables/SxObject.cpp | 2 +- engines/wintermute/UI/UIButton.cpp | 10 +-- engines/wintermute/UI/UIEdit.cpp | 8 +- engines/wintermute/UI/UIEntity.cpp | 8 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 4 +- engines/wintermute/UI/UIWindow.cpp | 36 ++++----- engines/wintermute/UI/UIWindow.h | 6 +- engines/wintermute/video/VidPlayer.cpp | 6 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- 68 files changed, 302 insertions(+), 302 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 09f19da65c..dd201ac6c1 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -253,7 +253,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -332,7 +332,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_CURSOR: @@ -370,7 +370,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_BLOCKED_REGION: { diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 0cd1276885..60a94b5e5a 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -249,7 +249,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_ITEM: @@ -372,7 +372,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_SUBTYPE: { @@ -415,7 +415,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_IGNORE_ITEMS: diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 049247db0a..cb547e02b8 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -71,7 +71,7 @@ CAdGame::CAdGame(): CBGame() { _inventoryBox = NULL; _scene = new CAdScene(Game); - _scene->SetName(""); + _scene->setName(""); RegisterObject(_scene); _prevSceneName = NULL; @@ -112,12 +112,12 @@ CAdGame::CAdGame(): CBGame() { ////////////////////////////////////////////////////////////////////////// CAdGame::~CAdGame() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::Cleanup() { +HRESULT CAdGame::cleanup() { int i; for (i = 0; i < _objects.GetSize(); i++) { @@ -190,7 +190,7 @@ HRESULT CAdGame::Cleanup() { for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; _responsesGame.RemoveAll(); - return CBGame::Cleanup(); + return CBGame::cleanup(); } @@ -248,7 +248,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { _scene = new CAdScene(Game); RegisterObject(_scene); } else { - _scene->ApplyEvent("SceneShutdown", true); + _scene->applyEvent("SceneShutdown", true); SetPrevSceneName(_scene->_name); SetPrevSceneFilename(_scene->_filename); @@ -263,7 +263,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { // reset scene properties _scene->_sFXVolume = 100; - if (_scene->_scProp) _scene->_scProp->Cleanup(); + if (_scene->_scProp) _scene->_scProp->cleanup(); HRESULT ret; if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { @@ -398,7 +398,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CAdEntity *Ent = new CAdEntity(Game); AddObject(Ent); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + if (!Val->IsNULL()) Ent->setName(Val->GetString()); Stack->PushNative(Ent, true); return S_OK; } @@ -412,7 +412,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CAdItem *Item = new CAdItem(Game); AddItem(Item); - if (!Val->IsNULL()) Item->SetName(Val->GetString()); + if (!Val->IsNULL()) Item->setName(Val->GetString()); Stack->PushNative(Item, true); return S_OK; } @@ -1104,7 +1104,7 @@ HRESULT CAdGame::ShowCursor() { _lastCursor = OrigLastCursor; } if (_activeObject && _selectedItem->_cursorHover && _activeObject->GetExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->CanHandleEvent(_selectedItem->_name)) + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) return DrawCursor(_selectedItem->_cursorHover); else return DrawCursor(_selectedItem->_cursorNormal); @@ -1264,7 +1264,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) Cleanup(); + if (!persistMgr->_saving) cleanup(); CBGame::persist(persistMgr); _dlgPendingBranches.persist(persistMgr); @@ -1470,7 +1470,7 @@ CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { if (Saving) { CAdSceneState *ret = new CAdSceneState(Game); - ret->SetFilename(FilenameCor); + ret->setFilename(FilenameCor); _sceneStates.Add(ret); @@ -1524,7 +1524,7 @@ HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScSt CScValue *Val = Stack->Pop(); CUIEntity *Ent = new CUIEntity(Game); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + if (!Val->IsNULL()) Ent->setName(Val->GetString()); Stack->PushNative(Ent, true); Ent->_parent = Win; @@ -1957,12 +1957,12 @@ HRESULT CAdGame::OnMouseLeftDown() { if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftClick"); + _activeObject->applyEvent("LeftClick"); } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftClick"); + _scene->applyEvent("LeftClick"); } } @@ -1981,12 +1981,12 @@ HRESULT CAdGame::OnMouseLeftUp() { _capturedObject = NULL; _mouseLeftDown = false; - bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(ApplyEvent("LeftRelease")); + bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(applyEvent("LeftRelease")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftRelease"); + _activeObject->applyEvent("LeftRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftRelease"); + _scene->applyEvent("LeftRelease"); } } return S_OK; @@ -2000,12 +2000,12 @@ HRESULT CAdGame::OnMouseLeftDblClick() { if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftDoubleClick"); + _activeObject->applyEvent("LeftDoubleClick"); } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("LeftDoubleClick"); + _scene->applyEvent("LeftDoubleClick"); } } return S_OK; @@ -2025,12 +2025,12 @@ HRESULT CAdGame::OnMouseRightDown() { if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightClick"); + _activeObject->applyEvent("RightClick"); } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("RightClick"); + _scene->applyEvent("RightClick"); } } return S_OK; @@ -2040,12 +2040,12 @@ HRESULT CAdGame::OnMouseRightDown() { HRESULT CAdGame::OnMouseRightUp() { if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightRelease"); + _activeObject->applyEvent("RightRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { - _scene->ApplyEvent("RightRelease"); + _scene->applyEvent("RightRelease"); } } return S_OK; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 8139102a22..b722249620 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -114,7 +114,7 @@ public: char *_prevSceneFilename; virtual HRESULT LoadGame(const char *Filename); CAdItem *_selectedItem; - HRESULT Cleanup(); + HRESULT cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) void FinishSentences(); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 7a1b7d6f00..0eb612757b 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -73,7 +73,7 @@ CAdInventoryBox::~CAdInventoryBox() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { +HRESULT CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -85,7 +85,7 @@ HRESULT CAdInventoryBox::Listen(CBScriptHolder *param1, uint32 param2) { _scrollOffset = MAX(_scrollOffset, 0); } else if (scumm_stricmp(obj->_name, "next") == 0) { _scrollOffset += _scrollBy; - } else return CBObject::Listen(param1, param2); + } else return CBObject::listen(param1, param2); break; default: error("CAdInventoryBox::Listen - Unhandled enum"); @@ -231,7 +231,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -298,7 +298,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { delete _closeButton; _closeButton = new CUIButton(Game); if (_closeButton) { - _closeButton->SetName("close"); + _closeButton->setName("close"); _closeButton->SetListener(this, _closeButton, 0); _closeButton->_parent = _window; } diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index 463c6c224a..bf3a3acbd6 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -49,7 +49,7 @@ public: int _spacing; int _scrollOffset; RECT _itemsArea; - HRESULT Listen(CBScriptHolder *param1, uint32 param2); + HRESULT listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 7f4a8d6525..001ecec3fa 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -184,7 +184,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_FONT: @@ -280,11 +280,11 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_ALPHA_COLOR: @@ -653,7 +653,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 1183e0efa1..454644e591 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -138,7 +138,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -203,11 +203,11 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_EDITOR_PROPERTY: @@ -273,12 +273,12 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(Name, "AddRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->SetName(Val->GetString()); + if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->SetRegion(Region); Stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->SetEntity(Entity); Stack->PushNative(Entity, true); } @@ -297,12 +297,12 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(Name, "InsertRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->SetName(Val->GetString()); + if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->SetRegion(Region); Stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->SetName(Val->GetString()); + if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->SetEntity(Entity); Stack->PushNative(Entity, true); } @@ -426,7 +426,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 0a7389045f..59165d834c 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -68,7 +68,7 @@ CAdNodeState::~CAdNodeState() { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetName(const char *Name) { +void CAdNodeState::setName(const char *Name) { delete[] _name; _name = NULL; CBUtils::SetString(&_name, Name); @@ -76,7 +76,7 @@ void CAdNodeState::SetName(const char *Name) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetFilename(const char *Filename) { +void CAdNodeState::setFilename(const char *Filename) { delete[] _filename; _filename = NULL; CBUtils::SetString(&_filename, Filename); @@ -140,8 +140,8 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b if (Entity->_caption[i]) SetCaption(Entity->_caption[i], i); } if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { - if (IncludingSprites) SetFilename(Entity->_sprite->_filename); - else SetFilename(""); + if (IncludingSprites) setFilename(Entity->_sprite->_filename); + else setFilename(""); } if (Entity->_cursor && Entity->_cursor->_filename) SetCursor(Entity->_cursor->_filename); _alphaColor = Entity->_alphaColor; diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index 16445376ca..99238226c3 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -36,8 +36,8 @@ class CAdEntity; class CAdNodeState : public CBBase { public: HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); - void SetName(const char *Name); - void SetFilename(const char *Filename); + void setName(const char *Name); + void setFilename(const char *Filename); void SetCursor(const char *Filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) CAdNodeState(CBGame *inGame); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 15c07aa22b..13e6391d69 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -1073,12 +1073,12 @@ HRESULT CAdObject::AfterMove() { break; } } - if (!RegFound) NewRegions[i]->ApplyEvent("ActorEntry"); + if (!RegFound) NewRegions[i]->applyEvent("ActorEntry"); } for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (_currentRegions[i] && Game->ValidObject(_currentRegions[i])) { - _currentRegions[i]->ApplyEvent("ActorLeave"); + _currentRegions[i]->applyEvent("ActorLeave"); } _currentRegions[i] = NewRegions[i]; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index fb8493b1d4..43ed13eef3 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -140,7 +140,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -191,11 +191,11 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_EDITOR_PROPERTY: @@ -299,7 +299,7 @@ HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 1da0389037..fe0784feff 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -162,7 +162,7 @@ HRESULT CAdResponseBox::CreateButtons() { btn->_width = _responseArea.right - _responseArea.left; if (btn->_width <= 0) btn->_width = Game->_renderer->_width; } - btn->SetName("response"); + btn->setName("response"); btn->CorrectSize(); // make the responses touchable @@ -482,7 +482,7 @@ HRESULT CAdResponseBox::Display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { +HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -500,7 +500,7 @@ HRESULT CAdResponseBox::Listen(CBScriptHolder *param1, uint32 param2) { _ready = true; InvalidateButtons(); ClearResponses(); - } else return CBObject::Listen(param1, param2); + } else return CBObject::listen(param1, param2); break; default: error("AdResponseBox::Listen - Unhandled enum"); diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 52e5e20d76..044a78bb4f 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -50,7 +50,7 @@ public: char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) CScScript *_waitingScript; - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); typedef enum { EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE } TResponseEvent; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index e14a6ce5ba..6bd5be4bea 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -73,7 +73,7 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdScene::~CAdScene() { - Cleanup(); + cleanup(); Game->UnregisterObject(_fader); delete _pFTarget; _pFTarget = NULL; @@ -136,8 +136,8 @@ void CAdScene::SetDefaults() { ////////////////////////////////////////////////////////////////////////// -void CAdScene::Cleanup() { - CBObject::Cleanup(); +void CAdScene::cleanup() { + CBObject::cleanup(); _mainLayer = NULL; // reference only @@ -609,7 +609,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END - Cleanup(); + cleanup(); byte *params; int cmd; @@ -634,7 +634,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -813,11 +813,11 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_VIEWPORT: { @@ -1292,7 +1292,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CAdEntity *Ent = new CAdEntity(Game); AddObject(Ent); - if (!Val->IsNULL()) Ent->SetName(Val->GetString()); + if (!Val->IsNULL()) Ent->setName(Val->GetString()); Stack->PushNative(Ent, true); return S_OK; } @@ -1594,7 +1594,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *Val = Stack->Pop(); CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (!Val->IsNULL()) Layer->setName(Val->GetString()); if (_mainLayer) { Layer->_width = _mainLayer->_width; Layer->_height = _mainLayer->_height; @@ -1615,7 +1615,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *Val = Stack->Pop(); CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->SetName(Val->GetString()); + if (!Val->IsNULL()) Layer->setName(Val->GetString()); if (_mainLayer) { Layer->_width = _mainLayer->_width; Layer->_height = _mainLayer->_height; @@ -1847,7 +1847,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 4d3720ecfa..8aa5657bc2 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -92,7 +92,7 @@ public: bool _paralaxScrolling; void SkipTo(int OffsetX, int OffsetY); void SetDefaults(); - void Cleanup(); + void cleanup(); void SkipToObject(CBObject *Object); void ScrollToObject(CBObject *Object); void ScrollTo(int OffsetX, int OffsetY); diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 9e7260d5a7..7c1a5d9378 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -63,7 +63,7 @@ HRESULT CAdSceneState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdSceneState::SetFilename(const char *Filename) { +void CAdSceneState::setFilename(const char *Filename) { delete[] _filename; _filename = new char [strlen(Filename) + 1]; if (_filename) strcpy(_filename, Filename); @@ -78,7 +78,7 @@ CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { if (Saving) { CAdNodeState *ret = new CAdNodeState(Game); - ret->SetName(Name); + ret->setName(Name); _nodeStates.Add(ret); return ret; diff --git a/engines/wintermute/Ad/AdSceneState.h b/engines/wintermute/Ad/AdSceneState.h index 6aa03792d2..2b91a53a4f 100644 --- a/engines/wintermute/Ad/AdSceneState.h +++ b/engines/wintermute/Ad/AdSceneState.h @@ -38,7 +38,7 @@ class CAdNodeState; class CAdSceneState : public CBBase { public: CAdNodeState *GetNodeState(char *Name, bool Saving); - void SetFilename(const char *Filename); + void setFilename(const char *Filename); DECLARE_PERSISTENT(CAdSceneState, CBBase) CAdSceneState(CBGame *inGame); virtual ~CAdSceneState(); diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 64de71f39d..3cd0b7aff0 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -126,7 +126,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_LEFT: diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 481f495880..b8ee1be55c 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -50,12 +50,12 @@ CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdWaypointGroup::~CAdWaypointGroup() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CAdWaypointGroup::Cleanup() { +void CAdWaypointGroup::cleanup() { for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); @@ -127,7 +127,7 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_POINT: { @@ -146,7 +146,7 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_EDITOR_PROPERTY: @@ -241,7 +241,7 @@ HRESULT CAdWaypointGroup::scSetProperty(const char *Name, CScValue *Value) { HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; - Cleanup(); + cleanup(); for (int i = 0; i < Wpt->_points.GetSize(); i++) { int x, y; diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 1cf44716a5..653d4eae7b 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -38,7 +38,7 @@ public: float _lastMimicScale; int _lastMimicX; int _lastMimicY; - void Cleanup(); + void cleanup(); HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index 0e1c56d264..4a498fb3dd 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -47,12 +47,12 @@ CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase ////////////////////////////////////////////////////////////////////////// CBDynBuffer::~CBDynBuffer() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::Cleanup() { +void CBDynBuffer::cleanup() { if (_buffer) free(_buffer); _buffer = NULL; _size = 0; @@ -70,7 +70,7 @@ uint32 CBDynBuffer::GetSize() { ////////////////////////////////////////////////////////////////////////// HRESULT CBDynBuffer::Init(uint32 InitSize) { - Cleanup(); + cleanup(); if (InitSize == 0) InitSize = _initSize; diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index c90c464aad..626ce04314 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -47,7 +47,7 @@ public: HRESULT PutBytes(byte *Buffer, uint32 Size); uint32 GetSize(); HRESULT Init(uint32 InitSize = 0); - void Cleanup(); + void cleanup(); uint32 _size; byte *_buffer; CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 90c0fffc39..397d314c3a 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -70,12 +70,12 @@ CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBFileManager::~CBFileManager() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::Cleanup() { +HRESULT CBFileManager::cleanup() { int i; // delete registered paths @@ -842,7 +842,7 @@ HRESULT CBFileManager::RestoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::SetBasePath(const Common::String &Path) { - Cleanup(); + cleanup(); if (Path.c_str()) { _basePath = new char[Path.size() + 1]; diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 11a90fc823..173bf4c570 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -43,7 +43,7 @@ class CBFile; class CBFileManager: CBBase { public: bool FindPackageSignature(Common::File *f, uint32 *Offset); - HRESULT Cleanup(); + HRESULT cleanup(); HRESULT SetBasePath(const Common::String &path); HRESULT RestoreCurrentDir(); char *_basePath; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index a6ad5fb6a6..3244dfa332 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -50,7 +50,7 @@ CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBFontStorage::~CBFontStorage() { - Cleanup(true); + cleanup(true); } @@ -65,7 +65,7 @@ void CBFontStorage::InitFreeType() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::Cleanup(bool Warn) { +HRESULT CBFontStorage::cleanup(bool Warn) { int i; for (i = 0; i < _fonts.GetSize(); i++) { @@ -144,7 +144,7 @@ HRESULT CBFontStorage::RemoveFont(CBFont *Font) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontStorage::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) Cleanup(false); + if (!persistMgr->_saving) cleanup(false); persistMgr->transfer(TMEMBER(Game)); _fonts.persist(persistMgr); diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index 17d0501093..110f4634c8 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -41,7 +41,7 @@ class CBFont; class CBFontStorage : public CBBase { public: DECLARE_PERSISTENT(CBFontStorage, CBBase) - HRESULT Cleanup(bool Warn = false); + HRESULT cleanup(bool Warn = false); HRESULT RemoveFont(CBFont *Font); CBFont *AddFont(const char *Filename); CBFontStorage(CBGame *inGame); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 2838c57d89..b774a4bf92 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -100,7 +100,7 @@ HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { } if (Owner) { for (int i = 0; i < _applyEvent.GetSize(); i++) { - Owner->ApplyEvent(_applyEvent[i]); + Owner->applyEvent(_applyEvent[i]); } } return S_OK; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index cfa3002d32..73cdea0971 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -288,7 +288,7 @@ CBGame::~CBGame() { _registry->WriteBool("System", "LastRun", true); - Cleanup(); + cleanup(); delete[] _localSaveDir; delete[] _settingsGameFile; @@ -343,7 +343,7 @@ CBGame::~CBGame() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Cleanup() { +HRESULT CBGame::cleanup() { delete _loadingIcon; _loadingIcon = NULL; @@ -813,7 +813,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -867,7 +867,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PERSONAL_SAVEGAMES: @@ -887,7 +887,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; case TOKEN_EDITOR_PROPERTY: @@ -1014,7 +1014,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "RunScript") == 0) { Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); Stack->CorrectParams(1); - if (FAILED(AddScript(Stack->Pop()->GetString()))) + if (FAILED(addScript(Stack->Pop()->GetString()))) Stack->PushBool(false); else Stack->PushBool(true); @@ -1847,7 +1847,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CUIWindow *Win = new CUIWindow(Game); _windows.Add(Win); RegisterObject(Win); - if (!Val->IsNULL()) Win->SetName(Val->GetString()); + if (!Val->IsNULL()) Win->setName(Val->GetString()); Stack->PushNative(Win, true); return S_OK; } @@ -2561,7 +2561,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } @@ -3232,7 +3232,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { LOG(0, "Saving game '%s'...", Filename); - Game->ApplyEvent("BeforeSave", true); + Game->applyEvent("BeforeSave", true); HRESULT ret; @@ -3311,14 +3311,14 @@ HRESULT CBGame::LoadGame(const char *Filename) { _dEBUG_AbsolutePathWarning = false; if (FAILED(ret = pm->initLoad(Filename))) goto load_finish; - //if(FAILED(ret = Cleanup())) goto load_finish; + //if(FAILED(ret = cleanup())) goto load_finish; if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadInstances(Game, pm))) goto load_finish; // data initialization after load InitAfterLoad(); - Game->ApplyEvent("AfterLoad", true); + Game->applyEvent("AfterLoad", true); DisplayContent(true, false); //_renderer->Flip(); @@ -3618,7 +3618,7 @@ HRESULT CBGame::LoadSettings(const char *Filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) Cleanup(); + if (!persistMgr->_saving) cleanup(); CBObject::persist(persistMgr); @@ -3798,15 +3798,15 @@ bool CBGame::HandleKeypress(Common::Event *event, bool printable) { if (_focusedWindow) { if (!Game->_focusedWindow->HandleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ - if (Game->_focusedWindow->CanHandleEvent("Keypress")) - Game->_focusedWindow->ApplyEvent("Keypress"); + if (Game->_focusedWindow->canHandleEvent("Keypress")) + Game->_focusedWindow->applyEvent("Keypress"); else - ApplyEvent("Keypress"); + applyEvent("Keypress"); /*}*/ } return true; } else { /*if (event->type != SDL_TEXTINPUT)*/ - ApplyEvent("Keypress"); + applyEvent("Keypress"); return true; } //else return true; @@ -3825,11 +3825,11 @@ bool CBGame::HandleMouseWheel(int Delta) { Handled = Game->_focusedWindow->HandleMouseWheel(Delta); if (!Handled) { - if (Delta < 0 && Game->_focusedWindow->CanHandleEvent("MouseWheelDown")) { - Game->_focusedWindow->ApplyEvent("MouseWheelDown"); + if (Delta < 0 && Game->_focusedWindow->canHandleEvent("MouseWheelDown")) { + Game->_focusedWindow->applyEvent("MouseWheelDown"); Handled = true; - } else if (Game->_focusedWindow->CanHandleEvent("MouseWheelUp")) { - Game->_focusedWindow->ApplyEvent("MouseWheelUp"); + } else if (Game->_focusedWindow->canHandleEvent("MouseWheelUp")) { + Game->_focusedWindow->applyEvent("MouseWheelUp"); Handled = true; } @@ -3838,9 +3838,9 @@ bool CBGame::HandleMouseWheel(int Delta) { if (!Handled) { if (Delta < 0) { - ApplyEvent("MouseWheelDown"); + applyEvent("MouseWheelDown"); } else { - ApplyEvent("MouseWheelUp"); + applyEvent("MouseWheelUp"); } } @@ -3966,11 +3966,11 @@ HRESULT CBGame::SetActiveObject(CBObject *Obj) { if (Obj == _activeObject) return S_OK; - if (_activeObject) _activeObject->ApplyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->ApplyEvent("MouseLeave"); + if (_activeObject) _activeObject->applyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); _activeObject = Obj; if (_activeObject) { - _activeObject->ApplyEvent("MouseEntry"); + _activeObject->applyEvent("MouseEntry"); } return S_OK; @@ -4268,10 +4268,10 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { HRESULT CBGame::OnMouseLeftDown() { if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftClick"); + _activeObject->applyEvent("LeftClick"); } } @@ -4290,10 +4290,10 @@ HRESULT CBGame::OnMouseLeftUp() { _capturedObject = NULL; _mouseLeftDown = false; - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftRelease")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftRelease"); + _activeObject->applyEvent("LeftRelease"); } } return S_OK; @@ -4305,10 +4305,10 @@ HRESULT CBGame::OnMouseLeftDblClick() { if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("LeftDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("LeftDoubleClick"); + _activeObject->applyEvent("LeftDoubleClick"); } } return S_OK; @@ -4320,10 +4320,10 @@ HRESULT CBGame::OnMouseRightDblClick() { if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightDoubleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightDoubleClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightDoubleClick"); + _activeObject->applyEvent("RightDoubleClick"); } } return S_OK; @@ -4333,10 +4333,10 @@ HRESULT CBGame::OnMouseRightDblClick() { HRESULT CBGame::OnMouseRightDown() { if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightClick"); + _activeObject->applyEvent("RightClick"); } } return S_OK; @@ -4346,10 +4346,10 @@ HRESULT CBGame::OnMouseRightDown() { HRESULT CBGame::OnMouseRightUp() { if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("RightRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("RightRelease"); + _activeObject->applyEvent("RightRelease"); } } return S_OK; @@ -4361,10 +4361,10 @@ HRESULT CBGame::OnMouseMiddleDown() { if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleClick")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleClick")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("MiddleClick"); + _activeObject->applyEvent("MiddleClick"); } } return S_OK; @@ -4374,10 +4374,10 @@ HRESULT CBGame::OnMouseMiddleDown() { HRESULT CBGame::OnMouseMiddleUp() { if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(ApplyEvent("MiddleRelease")); + bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); if (!Handled) { if (_activeObject != NULL) { - _activeObject->ApplyEvent("MiddleRelease"); + _activeObject->applyEvent("MiddleRelease"); } } return S_OK; @@ -4396,8 +4396,8 @@ HRESULT CBGame::OnPaint() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnWindowClose() { - if (CanHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) Game->ApplyEvent("QuitGame"); + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) Game->applyEvent("QuitGame"); return S_OK; } else return E_FAIL; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index ecbad813c6..8aa1cce127 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -291,7 +291,7 @@ public: HRESULT DisplayWindows(bool InGame = false); CBRegistry *_registry; bool _useD3D; - virtual HRESULT Cleanup(); + virtual HRESULT cleanup(); virtual HRESULT LoadGame(int Slot); virtual HRESULT LoadGame(const char *Filename); virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 953270c03b..09d24453fa 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -179,7 +179,7 @@ HRESULT CBKeyboardState::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); if (_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } @@ -216,7 +216,7 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// HRESULT CBKeyboardState::persist(CBPersistMgr *persistMgr) { - //if(!persistMgr->_saving) Cleanup(); + //if(!persistMgr->_saving) cleanup(); CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); diff --git a/engines/wintermute/Base/BNamedObject.cpp b/engines/wintermute/Base/BNamedObject.cpp index 3c4652b731..855bdb2738 100644 --- a/engines/wintermute/Base/BNamedObject.cpp +++ b/engines/wintermute/Base/BNamedObject.cpp @@ -55,11 +55,11 @@ CBNamedObject::~CBNamedObject(void) { ////////////////////////////////////////////////////////////////////// -void CBNamedObject::SetName(const char *Name) { +void CBNamedObject::setName(const char *name) { delete[] _name; - _name = new char [strlen(Name) + 1]; - if (_name != NULL) strcpy(_name, Name); + _name = new char [strlen(name) + 1]; + if (_name != NULL) strcpy(_name, name); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BNamedObject.h b/engines/wintermute/Base/BNamedObject.h index ef1a3a444c..e2649acbf5 100644 --- a/engines/wintermute/Base/BNamedObject.h +++ b/engines/wintermute/Base/BNamedObject.h @@ -42,7 +42,7 @@ public: CBNamedObject(TDynamicConstructor, TDynamicConstructor); char *_name; - void SetName(const char *Name); + void setName(const char *name); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 7eee851e65..107ab2537c 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -101,15 +101,15 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// CBObject::~CBObject() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Cleanup() { +HRESULT CBObject::cleanup() { if (Game && Game->_activeObject == this) Game->_activeObject = NULL; - CBScriptHolder::Cleanup(); + CBScriptHolder::cleanup(); delete[] _soundEvent; _soundEvent = NULL; @@ -157,7 +157,7 @@ char *CBObject::GetCaption(int Case) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::Listen(CBScriptHolder *param1, uint32 param2) { +HRESULT CBObject::listen(CBScriptHolder *param1, uint32 param2) { return E_FAIL; } @@ -1060,7 +1060,7 @@ HRESULT CBObject::SetSFXVolume(int Volume) { HRESULT CBObject::UpdateSounds() { if (_soundEvent) { if (_sFX && !_sFX->IsPlaying()) { - ApplyEvent(_soundEvent); + applyEvent(_soundEvent); SetSoundEvent(NULL); } } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 4658770aad..294b345dec 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -85,7 +85,7 @@ public: virtual int GetHeight(); HRESULT SetCursor(const char *Filename); HRESULT SetActiveCursor(const char *Filename); - HRESULT Cleanup(); + HRESULT cleanup(); char *GetCaption(int Case = 1); void SetCaption(const char *Caption, int Case = 1); bool _editorSelected; @@ -98,7 +98,7 @@ public: bool _sharedCursors; CBSprite *_activeCursor; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; bool _zoomable; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 5a9ddcbbf0..9307af62bb 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -55,12 +55,12 @@ CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CBRegion::~CBRegion() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBRegion::Cleanup() { +void CBRegion::cleanup() { for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); @@ -165,7 +165,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -184,7 +184,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_EDITOR_SELECTED_POINT: @@ -192,7 +192,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_PROPERTY: - ParseProperty(params, false); + parseProperty(params, false); break; } } @@ -355,7 +355,7 @@ HRESULT CBRegion::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } @@ -488,7 +488,7 @@ HRESULT CBRegion::GetBoundingRect(RECT *Rect) { HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; - Cleanup(); + cleanup(); for (int i = 0; i < Region->_points.GetSize(); i++) { int x, y; diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index aa49503967..f52f646f2c 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -39,7 +39,7 @@ public: float _lastMimicScale; int _lastMimicX; int _lastMimicY; - void Cleanup(); + void cleanup(); HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); HRESULT GetBoundingRect(RECT *Rect); bool PtInPolygon(int X, int Y); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index d47f2915c6..aaf73b2bc2 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -41,7 +41,7 @@ IMPLEMENT_PERSISTENT(CBScriptHolder, false) ////////////////////////////////////////////////////////////////////// CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { - SetName(""); + setName(""); _freezable = true; _filename = NULL; @@ -50,12 +50,12 @@ CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////// CBScriptHolder::~CBScriptHolder() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Cleanup() { +HRESULT CBScriptHolder::cleanup() { delete[] _filename; _filename = NULL; @@ -71,7 +71,7 @@ HRESULT CBScriptHolder::Cleanup() { } ////////////////////////////////////////////////////////////////////// -void CBScriptHolder::SetFilename(const char *Filename) { +void CBScriptHolder::setFilename(const char *Filename) { if (_filename != NULL) delete [] _filename; _filename = new char [strlen(Filename) + 1]; @@ -80,7 +80,7 @@ void CBScriptHolder::SetFilename(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { +HRESULT CBScriptHolder::applyEvent(const char *EventName, bool Unbreakable) { int NumHandlers = 0; HRESULT ret = E_FAIL; @@ -101,7 +101,7 @@ HRESULT CBScriptHolder::ApplyEvent(const char *EventName, bool Unbreakable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::Listen(CBScriptHolder *param1, uint32 param2) { +HRESULT CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { return E_FAIL; } @@ -129,7 +129,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac Stack->CorrectParams(1); CScValue *val = Stack->Pop(); HRESULT ret; - ret = ApplyEvent(val->GetString()); + ret = applyEvent(val->GetString()); if (SUCCEEDED(ret)) Stack->PushBool(true); else Stack->PushBool(false); @@ -142,7 +142,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CanHandleEvent") == 0) { Stack->CorrectParams(1); - Stack->PushBool(CanHandleEvent(Stack->Pop()->GetString())); + Stack->PushBool(canHandleEvent(Stack->Pop()->GetString())); return S_OK; } @@ -162,7 +162,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "AttachScript") == 0) { Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(AddScript(Stack->Pop()->GetString()))); + Stack->PushBool(SUCCEEDED(addScript(Stack->Pop()->GetString()))); return S_OK; } @@ -245,7 +245,7 @@ HRESULT CBScriptHolder::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } else return CBScriptable::scSetProperty(Name, Value); } @@ -276,7 +276,7 @@ HRESULT CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::AddScript(const char *Filename) { +HRESULT CBScriptHolder::addScript(const char *Filename) { for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { @@ -311,7 +311,7 @@ HRESULT CBScriptHolder::AddScript(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { +HRESULT CBScriptHolder::removeScript(CScScript *Script) { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i] == Script) { _scripts.RemoveAt(i); @@ -322,9 +322,9 @@ HRESULT CBScriptHolder::RemoveScript(CScScript *Script) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::CanHandleEvent(const char *EventName) { +bool CBScriptHolder::canHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->CanHandleEvent(EventName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; } return false; } @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { +HRESULT CBScriptHolder::parseProperty(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -418,7 +418,7 @@ HRESULT CBScriptHolder::ParseProperty(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::MakeFreezable(bool Freezable) { +void CBScriptHolder::makeFreezable(bool Freezable) { _freezable = Freezable; for (int i = 0; i < _scripts.GetSize(); i++) _scripts[i]->_freezable = Freezable; @@ -466,8 +466,8 @@ void CBScriptHolder::scDebuggerDesc(char *Buf, int BufSize) { ////////////////////////////////////////////////////////////////////////// // IWmeObject ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::SendEvent(const char *EventName) { - return SUCCEEDED(ApplyEvent(EventName)); +bool CBScriptHolder::sendEvent(const char *EventName) { + return SUCCEEDED(applyEvent(EventName)); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index 6e406699d5..688e13c7e3 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -41,32 +41,32 @@ public: CBScriptHolder(CBGame *inGame); virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *MethodName); - virtual void MakeFreezable(bool Freezable); - bool CanHandleEvent(const char *EventName); - virtual bool canHandleMethod(const char *EventMethod); - HRESULT Cleanup(); - HRESULT RemoveScript(CScScript *Script); - HRESULT AddScript(const char *Filename); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); - HRESULT ApplyEvent(const char *EventName, bool Unbreakable = false); - void SetFilename(const char *Filename); - HRESULT ParseProperty(byte *Buffer, bool Complete = true); + virtual CScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + HRESULT cleanup(); + HRESULT removeScript(CScScript *script); + HRESULT addScript(const char *filename); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); + HRESULT applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + HRESULT parseProperty(byte *buffer, bool complete = true); char *_filename; bool _freezable; bool _ready; CBArray _scripts; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); - virtual void scDebuggerDesc(char *Buf, int BufSize); + virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject public: - virtual bool SendEvent(const char *EventName); + virtual bool sendEvent(const char *eventName); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 670bf77560..8e851d5605 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -57,7 +57,7 @@ CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// CBSprite::~CBSprite() { - Cleanup(); + cleanup(); } @@ -80,15 +80,15 @@ void CBSprite::SetDefaults() { _streamed = false; _streamedKeepLoaded = false; - SetName(""); + setName(""); _precise = true; } ////////////////////////////////////////////////////////////////////////// -void CBSprite::Cleanup() { - CBScriptHolder::Cleanup(); +void CBSprite::cleanup() { + CBScriptHolder::cleanup(); for (int i = 0; i < _frames.GetSize(); i++) delete _frames[i]; @@ -210,7 +210,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite int cmd; CBParser parser(Game); - Cleanup(); + cleanup(); if (Complete) { @@ -234,7 +234,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_LOOPING: @@ -258,7 +258,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_EDITOR_BG_FILE: @@ -391,7 +391,7 @@ HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float Z if (_frames[_currentFrame]->_killSound) { KillAllSounds(); } - ApplyEvent("FrameChanged"); + applyEvent("FrameChanged"); _frames[_currentFrame]->OneTimeDisplay(_owner, Game->_editorMode && _editorMuted); } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 6969253285..a5dde324e5 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -47,7 +47,7 @@ public: int _editorBgAlpha; bool _streamed; bool _streamedKeepLoaded; - void Cleanup(); + void cleanup(); void SetDefaults(); bool _precise; DECLARE_PERSISTENT(CBSprite, CBScriptHolder) diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 797c5f3d49..337ad50bba 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -46,12 +46,12 @@ CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBSurfaceStorage::~CBSurfaceStorage() { - Cleanup(true); + cleanup(true); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::Cleanup(bool Warn) { +HRESULT CBSurfaceStorage::cleanup(bool Warn) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); delete _surfaces[i]; @@ -151,7 +151,7 @@ HRESULT CBSurfaceStorage::RestoreAll() { HRESULT CBSurfaceStorage::persist(CBPersistMgr *persistMgr) { - if(!persistMgr->_saving) Cleanup(false); + if(!persistMgr->_saving) cleanup(false); persistMgr->transfer(TMEMBER(Game)); diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index 5491252557..62c9796bfc 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -41,7 +41,7 @@ public: HRESULT InitLoop(); HRESULT SortSurfaces(); static int SurfaceSortCB(const void *arg1, const void *arg2); - HRESULT Cleanup(bool Warn = false); + HRESULT cleanup(bool Warn = false); //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); HRESULT RestoreAll(); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 2ff9a56679..bfce64041e 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -280,7 +280,7 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { // we actually generated some particles and we're not in fast-forward mode if (NeedsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->ApplyEvent(_emitEvent); + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); } } @@ -376,7 +376,7 @@ CPartForce *CPartEmitter::AddForceByName(const char *Name) { if (!Force) { Force = new CPartForce(Game); if (Force) { - Force->SetName(Name); + Force->setName(Name); _forces.Add(Force); } } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 669b072d2f..4bb2a3b32a 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -229,7 +229,7 @@ HRESULT CSXDate::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if(strcmp(Name, "Name")==0){ - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 2be008edaf..bffd1d462a 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -72,11 +72,11 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// CSXFile::~CSXFile() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CSXFile::Cleanup() { +void CSXFile::cleanup() { delete[] _filename; _filename = NULL; Close(); @@ -112,7 +112,7 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (strcmp(Name, "SetFilename") == 0) { Stack->CorrectParams(1); const char *Filename = Stack->Pop()->GetString(); - Cleanup(); + cleanup(); CBUtils::SetString(&_filename, Filename); Stack->PushNULL(); return S_OK; diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index d36f8ec3ae..d3076620c2 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -52,7 +52,7 @@ private: int _mode; // 0..none, 1..read, 2..write, 3..append bool _textMode; void Close(); - void Cleanup(); + void cleanup(); uint32 GetPos(); uint32 GetLength(); bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index de635e1c72..7a128d5899 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -60,7 +60,7 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::~CSXMemBuffer() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// @@ -69,7 +69,7 @@ void *CSXMemBuffer::scToMemBuffer() { } ////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::Cleanup() { +void CSXMemBuffer::cleanup() { if (_size) free(_buffer); _buffer = NULL; _size = 0; diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index d080b1f136..a14f09bfd6 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -50,7 +50,7 @@ public: private: HRESULT Resize(int NewSize); void *_buffer; - void Cleanup(); + void cleanup(); bool CheckBounds(CScScript *Script, int Start, int Length); }; diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 322ef8930d..b910f27f62 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -61,11 +61,11 @@ CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CSXStore::~CSXStore() { - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CSXStore::Cleanup() { +void CSXStore::cleanup() { SetEventsEnabled(NULL, false); for (int i = 0; i < _validProducts.GetSize(); i++) { @@ -279,7 +279,7 @@ CScValue *CSXStore::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) Cleanup(); + if (!persistMgr->_saving) cleanup(); CBObject::persist(persistMgr); @@ -371,7 +371,7 @@ void CSXStore::ReceiveProductsStart() { ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveProductsEnd() { - if (_lastProductRequestOwner) _lastProductRequestOwner->ApplyEvent("ProductsValidated"); + if (_lastProductRequestOwner) _lastProductRequestOwner->applyEvent("ProductsValidated"); } ////////////////////////////////////////////////////////////////////////// @@ -395,8 +395,8 @@ void CSXStore::ReceiveTransactionsStart() { ////////////////////////////////////////////////////////////////////////// void CSXStore::ReceiveTransactionsEnd() { - if (_lastPurchaseOwner) _lastPurchaseOwner->ApplyEvent("TransactionsUpdated"); - else Game->ApplyEvent("TransactionsUpdated"); + if (_lastPurchaseOwner) _lastPurchaseOwner->applyEvent("TransactionsUpdated"); + else Game->applyEvent("TransactionsUpdated"); } ////////////////////////////////////////////////////////////////////////// @@ -452,8 +452,8 @@ void CSXStore::RestoreTransactions(CScScript *script) { ////////////////////////////////////////////////////////////////////////// void CSXStore::OnRestoreFinished(bool error) { if (_lastRestoreOwner) { - if (error) _lastRestoreOwner->ApplyEvent("TransactionsRestoreFailed"); - else _lastRestoreOwner->ApplyEvent("TransactionsRestoreFinished"); + if (error) _lastRestoreOwner->applyEvent("TransactionsRestoreFailed"); + else _lastRestoreOwner->applyEvent("TransactionsRestoreFinished"); } } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index fd5f36a882..5889678122 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -154,7 +154,7 @@ public: void OnRestoreFinished(bool error); private: - void Cleanup(); + void cleanup(); bool Purchase(CScScript *script, const char *productId); bool FinishTransaction(CScScript *script, const char *transId); void RestoreTransactions(CScScript *script); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index c3c376790f..0066a2574f 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -147,7 +147,7 @@ CScEngine::~CScEngine() { #ifdef __WIN32__ if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); #endif - Cleanup(); + cleanup(); for (int i = 0; i < _breakpoints.GetSize(); i++) { delete _breakpoints[i]; @@ -158,9 +158,9 @@ CScEngine::~CScEngine() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Cleanup() { +HRESULT CScEngine::cleanup() { for (int i = 0; i < _scripts.GetSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; _scripts.RemoveAt(i); i--; @@ -489,7 +489,7 @@ HRESULT CScEngine::RemoveFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->RemoveScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); Game->GetDebugMgr()->OnScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.RemoveAt(i); @@ -571,7 +571,7 @@ HRESULT CScEngine::ResetScript(CScScript *Script) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) Cleanup(); + if (!persistMgr->_saving) cleanup(); persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_currentScript)); @@ -584,7 +584,7 @@ HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::EditorCleanup() { +void CScEngine::editorCleanup() { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 4d545bea66..06417793ed 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -121,13 +121,13 @@ public: CScScript *_currentScript; HRESULT ResumeAll(); HRESULT PauseAll(); - void EditorCleanup(); + void editorCleanup(); HRESULT ResetObject(CBObject *Object); HRESULT ResetScript(CScScript *Script); HRESULT EmptyScriptCache(); byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) - HRESULT Cleanup(); + HRESULT cleanup(); int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); HRESULT Tick(); CScValue *_globals; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 33e697ffd7..aa3485030e 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -97,7 +97,7 @@ CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CScScript::~CScScript() { - Cleanup(); + cleanup(); } @@ -107,13 +107,13 @@ HRESULT CScScript::InitScript() { TScriptHeader *Header = (TScriptHeader *)_buffer; if (Header->magic != SCRIPT_MAGIC) { Game->LOG(0, "File '%s' is not a valid compiled script", _filename); - Cleanup(); + cleanup(); return E_FAIL; } if (Header->version > SCRIPT_VERSION) { Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - Cleanup(); + cleanup(); return E_FAIL; } @@ -224,7 +224,7 @@ HRESULT CScScript::InitTables() { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { - Cleanup(); + cleanup(); _thread = false; _methodThread = false; @@ -256,7 +256,7 @@ HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScr ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { - Cleanup(); + cleanup(); _thread = true; _methodThread = false; @@ -302,7 +302,7 @@ HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodNam uint32 IP = Original->GetMethodPos(MethodName); if (IP == 0) return E_FAIL; - Cleanup(); + cleanup(); _thread = true; _methodThread = true; @@ -342,7 +342,7 @@ HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodNam ////////////////////////////////////////////////////////////////////////// -void CScScript::Cleanup() { +void CScScript::cleanup() { if (_buffer) delete [] _buffer; _buffer = NULL; @@ -445,7 +445,7 @@ HRESULT CScScript::ExecuteInstruction() { const char *str = NULL; //CScValue* op = new CScValue(Game); - _operand->Cleanup(); + _operand->cleanup(); CScValue *op1; CScValue *op2; @@ -1244,7 +1244,7 @@ uint32 CScScript::GetEventPos(const char *Name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::CanHandleEvent(const char *EventName) { +bool CScScript::canHandleEvent(const char *EventName) { return GetEventPos(EventName) != 0; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index dd6fcb1f4a..24cc4debdf 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -68,7 +68,7 @@ public: bool _freezable; HRESULT Resume(); HRESULT Pause(); - bool CanHandleEvent(const char *EventName); + bool canHandleEvent(const char *EventName); bool canHandleMethod(const char *MethodName); HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); @@ -139,7 +139,7 @@ public: char *GetString(); uint32 GetDWORD(); double GetFloat(); - void Cleanup(); + void cleanup(); HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); uint32 _iP; uint32 _bufferSize; diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 6e792ceb53..8dac129788 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -70,7 +70,7 @@ void CScStack::Push(CScValue *Val) { _sP++; if (_sP < _values.GetSize()) { - _values[_sP]->Cleanup(); + _values[_sP]->cleanup(); _values[_sP]->Copy(Val); } else { CScValue *val = new CScValue(Game); @@ -88,7 +88,7 @@ CScValue *CScStack::GetPushValue() { CScValue *val = new CScValue(Game); _values.Add(val); } - _values[_sP]->Cleanup(); + _values[_sP]->cleanup(); return _values[_sP]; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index cb007f91b1..7e575879c1 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -119,7 +119,7 @@ CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -void CScValue::Cleanup(bool IgnoreNatives) { +void CScValue::cleanup(bool IgnoreNatives) { DeleteProps(); if (_valString) delete [] _valString; @@ -151,7 +151,7 @@ void CScValue::Cleanup(bool IgnoreNatives) { ////////////////////////////////////////////////////////////////////////// CScValue::~CScValue() { - Cleanup(); + cleanup(); } @@ -219,7 +219,7 @@ HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool val = _valIter->_value; } if (!val) val = new CScValue(Game); - else val->Cleanup(); + else val->cleanup(); val->Copy(Val, CopyWhole); val->_isConstVar = SetAsConst; @@ -658,7 +658,7 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && CopyWhole) orig = orig->_valRef; - Cleanup(true); + cleanup(true); _type = orig->_type; _valBool = orig->_valBool; diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 6f6388a9da..6ee0981020 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -48,7 +48,7 @@ public: static int Compare(CScValue *Val1, CScValue *Val2); static int CompareStrict(CScValue *Val1, CScValue *Val2); TValType GetTypeTolerant(); - void Cleanup(bool IgnoreNatives = false); + void cleanup(bool IgnoreNatives = false); DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 7ebbb45132..d991085792 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -46,7 +46,7 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { int NumParams = Stack->Pop()->GetInt(0); for (int i = 0; i < NumParams; i++) { - AddScript(Stack->Pop()->GetString()); + addScript(Stack->Pop()->GetString()); } } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index d9d39791f5..4751ead13b 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -214,7 +214,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -389,7 +389,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PARENT_NOTIFY: @@ -655,9 +655,9 @@ HRESULT CUIButton::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// void CUIButton::Press() { - ApplyEvent("Press"); - if (_listenerObject) _listenerObject->Listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->ApplyEvent(_name); + applyEvent("Press"); + if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); + if (_parentNotify && _parent) _parent->applyEvent(_name); _oneTimePress = false; } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 9fd2c7664e..9c874b8ba3 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -184,7 +184,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_BACK: @@ -267,7 +267,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PARENT_NOTIFY: @@ -803,7 +803,7 @@ int CUIEdit::DeleteChars(int Start, int End) { delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->ApplyEvent(_name); + if (_parentNotify && _parent) _parent->applyEvent(_name); return End - Start; } @@ -828,7 +828,7 @@ int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->ApplyEvent(_name); + if (_parentNotify && _parent) _parent->applyEvent(_name); return Num; } diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index eca15ec513..8143afdf44 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -122,7 +122,7 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_X: @@ -146,7 +146,7 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_EDITOR_PROPERTY: @@ -218,7 +218,7 @@ HRESULT CUIEntity::SetEntity(const char *Filename) { } else { _entity->_nonIntMouseEvents = true; _entity->_sceneIndependent = true; - _entity->MakeFreezable(false); + _entity->makeFreezable(false); Game->RegisterObject(_entity); } return S_OK; @@ -315,7 +315,7 @@ HRESULT CUIEntity::scSetProperty(const char *Name, CScValue *Value) { // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Freezable") == 0) { - if (_entity) _entity->MakeFreezable(Value->GetBool()); + if (_entity) _entity->makeFreezable(Value->GetBool()); return S_OK; } else return CUIObject::scSetProperty(Name, Value); } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index da7fd37502..8560747297 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -423,7 +423,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 6034131763..1c2033a8d3 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -181,7 +181,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -258,7 +258,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PARENT_NOTIFY: diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 319a81ecf5..d89a5e4b42 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -90,12 +90,12 @@ CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIWindow::~CUIWindow() { Close(); - Cleanup(); + cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CUIWindow::Cleanup() { +void CUIWindow::cleanup() { delete _shieldWindow; delete _shieldButton; delete _viewport; @@ -127,7 +127,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { } else if (_isMenu) { if (!_shieldButton) { _shieldButton = new CUIButton(Game); - _shieldButton->SetName("close"); + _shieldButton->setName("close"); _shieldButton->SetListener(this, _shieldButton, 0); _shieldButton->_parent = this; } @@ -321,7 +321,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_NAME: - SetName((char *)params); + setName((char *)params); break; case TOKEN_CAPTION: @@ -483,7 +483,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SCRIPT: - AddScript((char *)params); + addScript((char *)params); break; case TOKEN_PARENT_NOTIFY: @@ -817,7 +817,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); - Cleanup(); + cleanup(); if (!Val->IsNULL()) { Stack->PushBool(SUCCEEDED(LoadFile(Val->GetString()))); } else Stack->PushBool(true); @@ -833,7 +833,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *Val = Stack->Pop(); CUIButton *Btn = new CUIButton(Game); - if (!Val->IsNULL()) Btn->SetName(Val->GetString()); + if (!Val->IsNULL()) Btn->setName(Val->GetString()); Stack->PushNative(Btn, true); Btn->_parent = this; @@ -850,7 +850,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *Val = Stack->Pop(); CUIText *Sta = new CUIText(Game); - if (!Val->IsNULL()) Sta->SetName(Val->GetString()); + if (!Val->IsNULL()) Sta->setName(Val->GetString()); Stack->PushNative(Sta, true); Sta->_parent = this; @@ -867,7 +867,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *Val = Stack->Pop(); CUIEdit *Edi = new CUIEdit(Game); - if (!Val->IsNULL()) Edi->SetName(Val->GetString()); + if (!Val->IsNULL()) Edi->setName(Val->GetString()); Stack->PushNative(Edi, true); Edi->_parent = this; @@ -884,7 +884,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *Val = Stack->Pop(); CUIWindow *Win = new CUIWindow(Game); - if (!Val->IsNULL()) Win->SetName(Val->GetString()); + if (!Val->IsNULL()) Win->setName(Val->GetString()); Stack->PushNative(Win, true); Win->_parent = this; @@ -1010,7 +1010,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Name") == 0) { - SetName(Value->GetString()); + setName(Value->GetString()); return S_OK; } @@ -1240,7 +1240,7 @@ HRESULT CUIWindow::GoExclusive() { HRESULT CUIWindow::GoSystemExclusive() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; - MakeFreezable(false); + makeFreezable(false); _mode = WINDOW_SYSTEM_EXCLUSIVE; _ready = false; @@ -1268,16 +1268,16 @@ HRESULT CUIWindow::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { +HRESULT CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { case UI_BUTTON: if (scumm_stricmp(obj->_name, "close") == 0) Close(); - else return CBObject::Listen(param1, param2); + else return CBObject::listen(param1, param2); break; default: - return CBObject::Listen(param1, param2); + return CBObject::listen(param1, param2); } return S_OK; @@ -1285,11 +1285,11 @@ HRESULT CUIWindow::Listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -void CUIWindow::MakeFreezable(bool Freezable) { +void CUIWindow::makeFreezable(bool Freezable) { for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->MakeFreezable(Freezable); + _widgets[i]->makeFreezable(Freezable); - CBObject::MakeFreezable(Freezable); + CBObject::makeFreezable(Freezable); } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index b8b8613d21..53d52d55fc 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -42,8 +42,8 @@ public: HRESULT GetWindowObjects(CBArray &Objects, bool InteractiveOnly); bool _pauseMusic; - void Cleanup(); - virtual void MakeFreezable(bool Freezable); + void cleanup(); + virtual void makeFreezable(bool Freezable); CBViewport *_viewport; bool _clipContents; bool _inGame; @@ -78,7 +78,7 @@ public: CUITiledImage *_backInactive; CBFont *_fontInactive; CBSprite *_imageInactive; - virtual HRESULT Listen(CBScriptHolder *param1, uint32 param2); + virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 73d6fffb6b..365e10bdd7 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -126,7 +126,7 @@ HRESULT CVidPlayer::cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 - Cleanup(); + cleanup(); char Filename[MAX_PATH]; Game->_fileManager->GetFullPath(inFilename, Filename); @@ -334,7 +334,7 @@ HRESULT CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); if (!_videoPGF) { Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); - Cleanup(); + cleanup(); return E_FAIL; } else { Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); @@ -363,7 +363,7 @@ HRESULT CVidPlayer::stop() { #if 0 if (!_playing) return S_OK; - Cleanup(); + cleanup(); Game->Unfreeze(); #endif diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index c6447c7431..6b85f0b20f 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -157,7 +157,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo return S_OK; #if 0 - Cleanup(); + cleanup(); _file = Game->_fileManager->OpenFile(Filename); if (!_file) return E_FAIL; -- cgit v1.2.3 From c2239512909eae01f6fa4ad3ed2c34de9cc9343f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 01:11:52 +0200 Subject: WINTERMUTE: Rename FuncName -> funcName in BObject --- engines/wintermute/Ad/AdActor.cpp | 18 ++-- engines/wintermute/Ad/AdActor.h | 6 +- engines/wintermute/Ad/AdEntity.cpp | 24 ++--- engines/wintermute/Ad/AdEntity.h | 6 +- engines/wintermute/Ad/AdGame.cpp | 38 +++---- engines/wintermute/Ad/AdGame.h | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 14 +-- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 12 +-- engines/wintermute/Ad/AdItem.h | 6 +- engines/wintermute/Ad/AdLayer.cpp | 4 +- engines/wintermute/Ad/AdNodeState.cpp | 10 +- engines/wintermute/Ad/AdNodeState.h | 4 +- engines/wintermute/Ad/AdObject.cpp | 30 +++--- engines/wintermute/Ad/AdObject.h | 12 +-- engines/wintermute/Ad/AdRegion.cpp | 4 +- engines/wintermute/Ad/AdResponseBox.cpp | 12 +-- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 40 +++---- engines/wintermute/Ad/AdScene.h | 6 +- engines/wintermute/Ad/AdSentence.cpp | 4 +- engines/wintermute/Ad/AdSentence.h | 4 +- engines/wintermute/Base/BFader.cpp | 4 +- engines/wintermute/Base/BFader.h | 4 +- engines/wintermute/Base/BFrame.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 48 ++++----- engines/wintermute/Base/BGame.h | 10 +- engines/wintermute/Base/BObject.cpp | 126 +++++++++++------------ engines/wintermute/Base/BObject.h | 50 ++++----- engines/wintermute/Base/BRegion.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 4 +- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BTransitionMgr.cpp | 8 +- engines/wintermute/Base/BTransitionMgr.h | 4 +- engines/wintermute/Base/BViewport.cpp | 2 +- engines/wintermute/Base/BViewport.h | 2 +- engines/wintermute/Base/PartEmitter.cpp | 8 +- engines/wintermute/Base/PartEmitter.h | 4 +- engines/wintermute/Base/PartParticle.cpp | 6 +- engines/wintermute/Base/PartParticle.h | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 8 +- engines/wintermute/UI/UIButton.cpp | 8 +- engines/wintermute/UI/UIButton.h | 2 +- engines/wintermute/UI/UIEdit.cpp | 10 +- engines/wintermute/UI/UIEdit.h | 4 +- engines/wintermute/UI/UIEntity.cpp | 6 +- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/UI/UIObject.cpp | 6 +- engines/wintermute/UI/UIObject.h | 4 +- engines/wintermute/UI/UIText.cpp | 8 +- engines/wintermute/UI/UIText.h | 2 +- engines/wintermute/UI/UITiledImage.cpp | 2 +- engines/wintermute/UI/UITiledImage.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 26 ++--- engines/wintermute/UI/UIWindow.h | 8 +- engines/wintermute/video/VidPlayer.cpp | 4 +- engines/wintermute/video/VidTheoraPlayer.cpp | 4 +- 58 files changed, 330 insertions(+), 330 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index dd201ac6c1..bfd344531c 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -257,7 +257,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_FONT: @@ -504,8 +504,8 @@ void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Display() { - if (_active) UpdateSounds(); +HRESULT CAdActor::display() { + if (_active) updateSounds(); uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; @@ -527,7 +527,7 @@ HRESULT CAdActor::Display() { bool Reg = _registrable; if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; - _currentSprite->Display(_posX, + _currentSprite->display(_posX, _posY, Reg ? _registerAlias : NULL, ScaleX, @@ -539,7 +539,7 @@ HRESULT CAdActor::Display() { } if (_active) DisplaySpriteAttachments(false); - if (_active && _partEmitter) _partEmitter->Display(); + if (_active && _partEmitter) _partEmitter->display(); return S_OK; @@ -547,7 +547,7 @@ HRESULT CAdActor::Display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::Update() { +HRESULT CAdActor::update() { _currentSprite = NULL; if (_state == STATE_READY) { @@ -681,7 +681,7 @@ HRESULT CAdActor::Update() { ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - _sentence->Update(_dir); + _sentence->update(_dir); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); @@ -1238,7 +1238,7 @@ TDirection CAdActor::AngleToDirection(int Angle) { ////////////////////////////////////////////////////////////////////////// -int CAdActor::GetHeight() { +int CAdActor::getHeight() { // if no current sprite is set, set some if (_currentSprite == NULL) { if (_standSprite) _currentSprite = _standSprite->GetSprite(_dir); @@ -1248,7 +1248,7 @@ int CAdActor::GetHeight() { } } // and get height - return CAdTalkHolder::GetHeight(); + return CAdTalkHolder::getHeight(); } diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index 32df33d39a..ab1b8a775e 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -48,12 +48,12 @@ class CAdActor : public CAdTalkHolder { public: TDirection AngleToDirection(int Angle); DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) - virtual int GetHeight(); + virtual int getHeight(); CBSprite *GetTalkStance(const char *Stance); virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); CBPoint *_targetPoint; - virtual HRESULT Update(); - virtual HRESULT Display(); + virtual HRESULT update(); + virtual HRESULT display(); TDirection _targetDir; TDirection _afterWalkDir; virtual void TurnTo(TDirection dir); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 60a94b5e5a..9e7fb28f2a 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -257,7 +257,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_FONT: @@ -395,7 +395,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_SOUND: - PlaySFX((char *)params, false, false); + playSFX((char *)params, false, false); break; case TOKEN_SOUND_START_TIME: @@ -481,9 +481,9 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Display() { +HRESULT CAdEntity::display() { if (_active) { - UpdateSounds(); + updateSounds(); uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; @@ -510,7 +510,7 @@ HRESULT CAdEntity::Display() { if (_theora && (_theora->isPlaying() || _theora->isPaused())) { _theora->display(Alpha); } else if (_currentSprite) { - _currentSprite->Display(_posX, + _currentSprite->display(_posX, _posY, (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, ScaleX, @@ -521,7 +521,7 @@ HRESULT CAdEntity::Display() { } DisplaySpriteAttachments(false); - if (_partEmitter) _partEmitter->Display(_region); + if (_partEmitter) _partEmitter->display(_region); } return S_OK; @@ -529,7 +529,7 @@ HRESULT CAdEntity::Display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::Update() { +HRESULT CAdEntity::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -562,7 +562,7 @@ HRESULT CAdEntity::Update() { ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - _sentence->Update(); + _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); @@ -632,7 +632,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (strcmp(Name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { Stack->CorrectParams(0); - if (FAILED(StopSFX(false))) Stack->PushBool(false); + if (FAILED(stopSFX(false))) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -882,7 +882,7 @@ HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); @@ -957,12 +957,12 @@ HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -int CAdEntity::GetHeight() { +int CAdEntity::getHeight() { if (_region && !_sprite) { return _region->_rect.bottom - _region->_rect.top; } else { if (_currentSprite == NULL) _currentSprite = _sprite; - return CAdObject::GetHeight(); + return CAdObject::getHeight(); } } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 9418147cb7..28e491cd4e 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -44,11 +44,11 @@ public: char *_item; DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) void UpdatePosition(); - virtual int GetHeight(); + virtual int getHeight(); CBRegion *_region; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Update(); - virtual HRESULT Display(); + virtual HRESULT update(); + virtual HRESULT display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); HRESULT LoadFile(const char *Filename); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index cb547e02b8..c16c1dac28 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -196,7 +196,7 @@ HRESULT CAdGame::cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::InitLoop() { - if (_scheduledScene && _transMgr->IsReady()) { + if (_scheduledScene && _transMgr->isReady()) { ChangeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; _scheduledScene = NULL; @@ -296,7 +296,7 @@ void CAdGame::AddSentence(CAdSentence *Sentence) { HRESULT CAdGame::DisplaySentences(bool Frozen) { for (int i = 0; i < _sentences.GetSize(); i++) { if (Frozen && _sentences[i]->_freezable) continue; - else _sentences[i]->Display(); + else _sentences[i]->display(); } return S_OK; } @@ -1094,22 +1094,22 @@ HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ShowCursor() { +HRESULT CAdGame::showCursor() { if (_cursorHidden) return S_OK; if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { CBSprite *OrigLastCursor = _lastCursor; - CBGame::ShowCursor(); + CBGame::showCursor(); _lastCursor = OrigLastCursor; } - if (_activeObject && _selectedItem->_cursorHover && _activeObject->GetExtendedFlag("usable")) { + if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) return DrawCursor(_selectedItem->_cursorHover); else return DrawCursor(_selectedItem->_cursorNormal); } else return DrawCursor(_selectedItem->_cursorNormal); - } else return CBGame::ShowCursor(); + } else return CBGame::showCursor(); } @@ -1712,14 +1712,14 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { POINT p; GetMousePos(&p); - _scene->Update(); - _scene->Display(); + _scene->update(); + _scene->display(); // display in-game windows DisplayWindows(true); - if (_inventoryBox) _inventoryBox->Display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->Display(); + if (_inventoryBox) _inventoryBox->display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); if (_indicatorDisplay) DisplayIndicator(); @@ -1732,15 +1732,15 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // textual info DisplaySentences(_state == GAME_FROZEN); - ShowCursor(); + showCursor(); - if (_fader) _fader->Display(); - _transMgr->Update(); + if (_fader) _fader->display(); + _transMgr->update(); } } if (_loadingIcon) { - _loadingIcon->Display(_loadingIconX, _loadingIconY); + _loadingIcon->display(_loadingIconX, _loadingIconY); if (!_loadingIconPersistent) { delete _loadingIcon; _loadingIcon = NULL; @@ -1955,7 +1955,7 @@ HRESULT CAdGame::OnMouseLeftDown() { return S_OK; } - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); if (!Handled) { @@ -1975,7 +1975,7 @@ HRESULT CAdGame::OnMouseLeftDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseLeftUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); _capturedObject = NULL; @@ -1998,7 +1998,7 @@ HRESULT CAdGame::OnMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); if (!Handled) { @@ -2023,7 +2023,7 @@ HRESULT CAdGame::OnMouseRightDown() { if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return S_OK; - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); if (!Handled) { @@ -2038,7 +2038,7 @@ HRESULT CAdGame::OnMouseRightDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::OnMouseRightUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); if (!Handled) { diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index b722249620..287421c2a4 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -118,7 +118,7 @@ public: DECLARE_PERSISTENT(CAdGame, CBGame) void FinishSentences(); - HRESULT ShowCursor(); + HRESULT showCursor(); TGameStateEx _stateEx; CAdResponseBox *_responseBox; CAdInventoryBox *_inventoryBox; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 0eb612757b..ee3e9dedfe 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -97,7 +97,7 @@ HRESULT CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::Display() { +HRESULT CAdInventoryBox::display() { CAdGame *AdGame = (CAdGame *)Game; if (!_visible) return S_OK; @@ -117,7 +117,7 @@ HRESULT CAdInventoryBox::Display() { _closeButton->_width = Game->_renderer->_width; _closeButton->_height = Game->_renderer->_height; - _closeButton->Display(); + _closeButton->display(); } @@ -125,7 +125,7 @@ HRESULT CAdInventoryBox::Display() { RECT rect = _itemsArea; if (_window) { CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); - _window->Display(); + _window->display(); } // display items @@ -138,8 +138,8 @@ HRESULT CAdInventoryBox::Display() { if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()) { CAdItem *item = AdGame->_inventoryOwner->GetInventory()->_takenItems[ItemIndex]; if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { - item->Update(); - item->Display(xxx, yyy); + item->update(); + item->display(xxx, yyy); } } @@ -235,7 +235,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_WINDOW: @@ -322,7 +322,7 @@ HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "{\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index bf3a3acbd6..f0900406ad 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -44,7 +44,7 @@ public: int _itemHeight; int _itemWidth; bool _visible; - virtual HRESULT Display(); + virtual HRESULT display(); CUIButton *_closeButton; int _spacing; int _scrollOffset; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 001ecec3fa..ca001b3eb7 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -192,7 +192,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_IMAGE: @@ -319,7 +319,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Update() { +HRESULT CAdItem::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -354,7 +354,7 @@ HRESULT CAdItem::Update() { ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { - _sentence->Update(); + _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); @@ -386,7 +386,7 @@ HRESULT CAdItem::Update() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::Display(int X, int Y) { +HRESULT CAdItem::display(int X, int Y) { int Width = 0; if (_currentSprite) { RECT rc; @@ -750,10 +750,10 @@ HRESULT CAdItem::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::GetExtendedFlag(const char *FlagName) { +bool CAdItem::getExtendedFlag(const char *FlagName) { if (!FlagName) return false; else if (strcmp(FlagName, "usable") == 0) return true; - else return CAdObject::GetExtendedFlag(FlagName); + else return CAdObject::getExtendedFlag(FlagName); } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index 9e970c1b58..d394310172 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -44,10 +44,10 @@ public: char *_amountString; - HRESULT Update(); + HRESULT update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - HRESULT Display(int X, int Y); - bool GetExtendedFlag(const char *FlagName); + HRESULT display(int X, int Y); + bool getExtendedFlag(const char *FlagName); bool _inInventory; bool _cursorCombined; CBSprite *_spriteHover; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 454644e591..45c6678188 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -142,7 +142,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_MAIN: @@ -481,7 +481,7 @@ const char *CAdLayer::scToString() { HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "LAYER {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 59165d834c..0e6c718ae0 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -107,7 +107,7 @@ HRESULT CAdNodeState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCaption(const char *Caption, int Case) { +void CAdNodeState::setCaption(const char *Caption, int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; @@ -121,7 +121,7 @@ void CAdNodeState::SetCaption(const char *Caption, int Case) { ////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::GetCaption(int Case) { +char *CAdNodeState::getCaption(int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; else return _caption[Case - 1]; @@ -137,7 +137,7 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b if (Saving) { for (int i = 0; i < 7; i++) { - if (Entity->_caption[i]) SetCaption(Entity->_caption[i], i); + if (Entity->_caption[i]) setCaption(Entity->_caption[i], i); } if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { if (IncludingSprites) setFilename(Entity->_sprite->_filename); @@ -148,7 +148,7 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b _active = Entity->_active; } else { for (int i = 0; i < 7; i++) { - if (_caption[i]) Entity->SetCaption(_caption[i], i); + if (_caption[i]) Entity->setCaption(_caption[i], i); } if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) @@ -156,7 +156,7 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b } if (_cursor) { if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) - Entity->SetCursor(_cursor); + Entity->setCursor(_cursor); } Entity->_active = _active; diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index 99238226c3..d180a3543e 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -45,8 +45,8 @@ public: char *_name; bool _active; char *_caption[7]; - void SetCaption(const char *Caption, int Case); - char *GetCaption(int Case); + void setCaption(const char *Caption, int Case); + char *getCaption(int Case); uint32 _alphaColor; char *_filename; char *_cursor; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 13e6391d69..ca6880557e 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -173,13 +173,13 @@ HRESULT CAdObject::PlayAnim(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Display() { +HRESULT CAdObject::display() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Update() { +HRESULT CAdObject::update() { return S_OK; } @@ -805,7 +805,7 @@ HRESULT CAdObject::SetFont(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -int CAdObject::GetHeight() { +int CAdObject::getHeight() { if (!_currentSprite) return 0; else { CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; @@ -897,7 +897,7 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); - y = y - height - GetHeight() - 5; + y = y - height - getHeight() - 5; if (_subtitlesModRelative) { x += _subtitlesModX; y += _subtitlesModY; @@ -998,29 +998,29 @@ HRESULT CAdObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateSounds() { +HRESULT CAdObject::updateSounds() { if (_sentence && _sentence->_sound) - UpdateOneSound(_sentence->_sound); + updateOneSound(_sentence->_sound); - return CBObject::UpdateSounds(); + return CBObject::updateSounds(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::ResetSoundPan() { +HRESULT CAdObject::resetSoundPan() { if (_sentence && _sentence->_sound) { _sentence->_sound->SetPan(0.0f); } - return CBObject::ResetSoundPan(); + return CBObject::resetSoundPan(); } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::GetExtendedFlag(const char *FlagName) { +bool CAdObject::getExtendedFlag(const char *FlagName) { if (!FlagName) return false; else if (strcmp(FlagName, "usable") == 0) return true; - else return CBObject::GetExtendedFlag(FlagName); + else return CBObject::getExtendedFlag(FlagName); } @@ -1110,10 +1110,10 @@ HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::UpdateSpriteAttachments() { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - _attachmentsPre[i]->Update(); + _attachmentsPre[i]->update(); } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - _attachmentsPost[i]->Update(); + _attachmentsPost[i]->update(); } return S_OK; } @@ -1162,7 +1162,7 @@ HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { Attachment->_registerAlias = this; Attachment->_registrable = this->_registrable; - HRESULT ret = Attachment->Display(); + HRESULT ret = Attachment->display(); Attachment->_posX = OrigX; Attachment->_posY = OrigY; @@ -1197,7 +1197,7 @@ HRESULT CAdObject::UpdatePartEmitter() { _partEmitter->_posX = (int)(_posX + (ScaleX / 100.0f) * _partOffsetX); _partEmitter->_posY = (int)(_posY + (ScaleY / 100.0f) * _partOffsetY); } - return _partEmitter->Update(); + return _partEmitter->update(); } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index 6c20e5d84e..ca85da42b0 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -64,17 +64,17 @@ public: HRESULT UpdateBlockRegion(); bool _forcedTalkAnimUsed; char *_forcedTalkAnimName; - virtual bool GetExtendedFlag(const char *FlagName); - virtual HRESULT ResetSoundPan(); - virtual HRESULT UpdateSounds(); + virtual bool getExtendedFlag(const char *FlagName); + virtual HRESULT resetSoundPan(); + virtual HRESULT updateSounds(); HRESULT Reset(); DECLARE_PERSISTENT(CAdObject, CBObject) virtual void Talk(const char *Text, const char *Sound = NULL, uint32 Duration = 0, const char *Stances = NULL, TTextAlign Align = TAL_CENTER); - virtual int GetHeight(); + virtual int getHeight(); CAdSentence *_sentence; HRESULT SetFont(const char *Filename); - virtual HRESULT Update(); - virtual HRESULT Display(); + virtual HRESULT update(); + virtual HRESULT display(); bool _drawn; bool _active; virtual HRESULT PlayAnim(const char *Filename); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 43ed13eef3..c8b65a6691 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -144,7 +144,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_ACTIVE: @@ -349,7 +349,7 @@ const char *CAdRegion::scToString() { HRESULT CAdRegion::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "REGION {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index fe0784feff..42f1038ffc 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -141,7 +141,7 @@ HRESULT CAdResponseBox::CreateButtons() { if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; - btn->SetCaption(_responses[i]->_text); + btn->setCaption(_responses[i]->_text); if (_cursor) btn->_cursor = _cursor; else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor; } @@ -396,11 +396,11 @@ HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::Display() { +HRESULT CAdResponseBox::display() { RECT rect = _responseArea; if (_window) { CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); - //_window->Display(); + //_window->display(); } int xxx, yyy, i; @@ -465,16 +465,16 @@ HRESULT CAdResponseBox::Display() { _shieldWindow->_width = Game->_renderer->_width; _shieldWindow->_height = Game->_renderer->_height; - _shieldWindow->Display(); + _shieldWindow->display(); } // display window - if (_window) _window->Display(); + if (_window) _window->display(); // display response buttons for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { - _respButtons[i]->Display(); + _respButtons[i]->display(); } return S_OK; diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 044a78bb4f..0f719ab6c1 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -56,7 +56,7 @@ public: } TResponseEvent; HRESULT WeedResponses(); - HRESULT Display(); + HRESULT display(); int _spacing; int _scrollOffset; CBFont *_fontHover; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 6bd5be4bea..2feb042df6 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -638,7 +638,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_LAYER: { @@ -957,7 +957,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { _shieldWindow->_posX = _shieldWindow->_posY = 0; _shieldWindow->_width = Game->_renderer->_width; _shieldWindow->_height = Game->_renderer->_height; - _shieldWindow->Display(); + _shieldWindow->display(); } } } @@ -987,8 +987,8 @@ HRESULT CAdScene::TraverseNodes(bool Update) { if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { Game->_renderer->Setup2D(); - if (Update) Node->_entity->Update(); - else Node->_entity->Display(); + if (Update) Node->_entity->update(); + else Node->_entity->display(); } break; @@ -1022,8 +1022,8 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // display/update fader if (_fader) { - if (Update) _fader->Update(); - else _fader->Display(); + if (Update) _fader->update(); + else _fader->display(); } if (PopViewport) Game->PopViewport(); @@ -1033,7 +1033,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Display() { +HRESULT CAdScene::display() { return TraverseNodes(false); } @@ -1049,7 +1049,7 @@ HRESULT CAdScene::UpdateFreeObjects() { for (i = 0; i < AdGame->_objects.GetSize(); i++) { if (!AdGame->_objects[i]->_active) continue; - AdGame->_objects[i]->Update(); + AdGame->_objects[i]->update(); AdGame->_objects[i]->_drawn = false; } @@ -1057,7 +1057,7 @@ HRESULT CAdScene::UpdateFreeObjects() { for (i = 0; i < _objects.GetSize(); i++) { if (!_objects[i]->_active) continue; - _objects[i]->Update(); + _objects[i]->update(); _objects[i]->_drawn = false; } @@ -1106,7 +1106,7 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { Game->_renderer->Setup2D(); - if (Game->_editorMode || !Obj->_editorOnly) Obj->Display(); + if (Game->_editorMode || !Obj->_editorOnly) Obj->display(); Obj->_drawn = true; } @@ -1116,7 +1116,7 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { if (Game->_editorMode && Region == NULL) { for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->Display(); + _objects[i]->display(); _objects[i]->_drawn = true; } } @@ -1167,7 +1167,7 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { if (obj != NULL) { Game->_renderer->Setup2D(); - if (Game->_editorMode || !obj->_editorOnly) obj->Display(); + if (Game->_editorMode || !obj->_editorOnly) obj->display(); obj->_drawn = true; } } while (obj != NULL); @@ -1177,7 +1177,7 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { if (Game->_editorMode && Region == NULL) { for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->Display(); + _objects[i]->display(); _objects[i]->_drawn = true; } } @@ -1188,7 +1188,7 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::Update() { +HRESULT CAdScene::update() { return TraverseNodes(true); } @@ -1219,13 +1219,13 @@ void CAdScene::ScrollTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// void CAdScene::ScrollToObject(CBObject *Object) { - if (Object) ScrollTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); + if (Object) ScrollTo(Object->_posX, Object->_posY - Object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// void CAdScene::SkipToObject(CBObject *Object) { - if (Object) SkipTo(Object->_posX, Object->_posY - Object->GetHeight() / 2); + if (Object) SkipTo(Object->_posX, Object->_posY - Object->getHeight() / 2); } @@ -1975,7 +1975,7 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "SCENE {\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); if (_persistentState) Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); @@ -2379,10 +2379,10 @@ HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { CAdGame *AdGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (Width) *Width = _viewport->GetWidth(); - if (Height) *Height = _viewport->GetHeight(); + if (Height) *Height = _viewport->getHeight(); } else if (AdGame->_sceneViewport && !Game->_editorMode) { if (Width) *Width = AdGame->_sceneViewport->GetWidth(); - if (Height) *Height = AdGame->_sceneViewport->GetHeight(); + if (Height) *Height = AdGame->_sceneViewport->getHeight(); } else { if (Width) *Width = Game->_renderer->_width; if (Height) *Height = Game->_renderer->_height; @@ -2627,7 +2627,7 @@ HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegi } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::RestoreDeviceObjects() { +HRESULT CAdScene::restoreDeviceObjects() { return S_OK; } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 8aa5657bc2..6587418dd9 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -96,7 +96,7 @@ public: void SkipToObject(CBObject *Object); void ScrollToObject(CBObject *Object); void ScrollTo(int OffsetX, int OffsetY); - virtual HRESULT Update(); + virtual HRESULT update(); bool _autoScroll; int _targetOffsetTop; int _targetOffsetLeft; @@ -109,7 +109,7 @@ public: uint32 _scrollTimeH; uint32 _lastTimeH; - virtual HRESULT Display(); + virtual HRESULT display(); uint32 _pFMaxTime; HRESULT InitLoop(); void PathFinderStep(); @@ -152,7 +152,7 @@ public: CBArray _scaleLevels; CBArray _rotLevels; - virtual HRESULT RestoreDeviceObjects(); + virtual HRESULT restoreDeviceObjects(); int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index a893a00489..a753f13a67 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -165,7 +165,7 @@ char *CAdSentence::GetStance(int Stance) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Display() { +HRESULT CAdSentence::display() { if (!_font || !_text) return E_FAIL; if (_sound && !_soundStarted) { @@ -270,7 +270,7 @@ HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Update(TDirection Dir) { +HRESULT CAdSentence::update(TDirection Dir) { if (!_talkDef) return S_OK; uint32 CurrentTime; diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 310be3e3e5..675cb9d744 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -45,7 +45,7 @@ public: bool _fixedPos; CBSprite *_currentSprite; char *_currentSkelAnim; - HRESULT Update(TDirection Dir = DI_DOWN); + HRESULT update(TDirection Dir = DI_DOWN); HRESULT SetupTalkFile(const char *SoundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) HRESULT Finish(); @@ -53,7 +53,7 @@ public: bool _soundStarted; CBSound *_sound; TTextAlign _align; - HRESULT Display(); + HRESULT display(); int _width; POINT _pos; CBFont *_font; diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index b20d377e93..741b586d56 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -60,7 +60,7 @@ CBFader::~CBFader() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Update() { +HRESULT CBFader::update() { if (!_active) return S_OK; int AlphaDelta = _targetAlpha - _sourceAlpha; @@ -84,7 +84,7 @@ HRESULT CBFader::Update() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Display() { +HRESULT CBFader::display() { if (!_active) return S_OK; if (_currentAlpha > 0x00) return Game->_renderer->FadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h index 141f44f485..663766127b 100644 --- a/engines/wintermute/Base/BFader.h +++ b/engines/wintermute/Base/BFader.h @@ -41,8 +41,8 @@ public: HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); HRESULT Deactivate(); - HRESULT Display(); - HRESULT Update(); + HRESULT display(); + HRESULT update(); DECLARE_PERSISTENT(CBFader, CBObject) CBFader(CBGame *inGame); virtual ~CBFader(); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index b774a4bf92..7acc45e3ba 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -90,7 +90,7 @@ HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY ////////////////////////////////////////////////////////////////////////// HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { if (_sound && !Muted) { - if (Owner) Owner->UpdateOneSound(_sound); + if (Owner) Owner->updateOneSound(_sound); _sound->Play(); /* if (Game->_state == GAME_FROZEN) { diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 73cdea0971..62197ec430 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -653,9 +653,9 @@ HRESULT CBGame::InitLoop() { } } - UpdateSounds(); + updateSounds(); - if (_fader) _fader->Update(); + if (_fader) _fader->update(); return S_OK; } @@ -817,7 +817,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_SYSTEM_FONT: @@ -1669,7 +1669,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetActiveCursor") == 0) { Stack->CorrectParams(1); - if (SUCCEEDED(SetActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + if (SUCCEEDED(setActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -3209,15 +3209,15 @@ HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ShowCursor() { +HRESULT CBGame::showCursor() { if (_cursorHidden) return S_OK; if (!_interactive && Game->_state == GAME_RUNNING) { if (_cursorNoninteractive) return DrawCursor(_cursorNoninteractive); } else { - if (_activeObject && !FAILED(_activeObject->ShowCursor())) return S_OK; + if (_activeObject && !FAILED(_activeObject->showCursor())) return S_OK; else { - if (_activeObject && _activeCursor && _activeObject->GetExtendedFlag("usable")) return DrawCursor(_activeCursor); + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return DrawCursor(_activeCursor); else if (_cursor) return DrawCursor(_cursor); } } @@ -3404,7 +3404,7 @@ HRESULT CBGame::DisplayWindows(bool InGame) { for (i = 0; i < _windows.GetSize(); i++) { if (_windows[i]->_visible && _windows[i]->_inGame == InGame) { - res = _windows[i]->Display(); + res = _windows[i]->display(); if (FAILED(res)) return res; } } @@ -3768,7 +3768,7 @@ HRESULT CBGame::Unfreeze() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleKeypress(Common::Event *event, bool printable) { +bool CBGame::handleKeypress(Common::Event *event, bool printable) { if (IsVideoPlaying()) { if (event->kbd.keycode == Common::KEYCODE_ESCAPE) StopVideo(); @@ -3796,7 +3796,7 @@ bool CBGame::HandleKeypress(Common::Event *event, bool printable) { // TODO if (_focusedWindow) { - if (!Game->_focusedWindow->HandleKeypress(event, _keyboardState->_currentPrintable)) { + if (!Game->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ if (Game->_focusedWindow->canHandleEvent("Keypress")) Game->_focusedWindow->applyEvent("Keypress"); @@ -3819,10 +3819,10 @@ void CBGame::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::HandleMouseWheel(int Delta) { +bool CBGame::handleMouseWheel(int Delta) { bool Handled = false; if (_focusedWindow) { - Handled = Game->_focusedWindow->HandleMouseWheel(Delta); + Handled = Game->_focusedWindow->handleMouseWheel(Delta); if (!Handled) { if (Delta < 0 && Game->_focusedWindow->canHandleEvent("MouseWheelDown")) { @@ -4186,18 +4186,18 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InvalidateDeviceObjects() { +HRESULT CBGame::invalidateDeviceObjects() { for (int i = 0; i < _regObjects.GetSize(); i++) { - _regObjects[i]->InvalidateDeviceObjects(); + _regObjects[i]->invalidateDeviceObjects(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::RestoreDeviceObjects() { +HRESULT CBGame::restoreDeviceObjects() { for (int i = 0; i < _regObjects.GetSize(); i++) { - _regObjects[i]->RestoreDeviceObjects(); + _regObjects[i]->restoreDeviceObjects(); } return S_OK; } @@ -4266,7 +4266,7 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseLeftDown() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); if (!Handled) { @@ -4284,7 +4284,7 @@ HRESULT CBGame::OnMouseLeftDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseLeftUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); _capturedObject = NULL; @@ -4303,7 +4303,7 @@ HRESULT CBGame::OnMouseLeftUp() { HRESULT CBGame::OnMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); if (!Handled) { @@ -4318,7 +4318,7 @@ HRESULT CBGame::OnMouseLeftDblClick() { HRESULT CBGame::OnMouseRightDblClick() { if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (_activeObject) _activeObject->HandleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightDoubleClick")); if (!Handled) { @@ -4331,7 +4331,7 @@ HRESULT CBGame::OnMouseRightDblClick() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseRightDown() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); if (!Handled) { @@ -4344,7 +4344,7 @@ HRESULT CBGame::OnMouseRightDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseRightUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); if (!Handled) { @@ -4359,7 +4359,7 @@ HRESULT CBGame::OnMouseRightUp() { HRESULT CBGame::OnMouseMiddleDown() { if (_state == GAME_RUNNING && !_interactive) return S_OK; - if (_activeObject) _activeObject->HandleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleClick")); if (!Handled) { @@ -4372,7 +4372,7 @@ HRESULT CBGame::OnMouseMiddleDown() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnMouseMiddleUp() { - if (_activeObject) _activeObject->HandleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); if (!Handled) { diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 8aa1cce127..51f792dc75 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -219,8 +219,8 @@ public: CBFader *_fader; bool _suppressScriptErrors; - virtual HRESULT InvalidateDeviceObjects(); - virtual HRESULT RestoreDeviceObjects(); + virtual HRESULT invalidateDeviceObjects(); + virtual HRESULT restoreDeviceObjects(); virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); @@ -253,11 +253,11 @@ public: HRESULT GetSaveSlotDescription(int Slot, char *Buffer); HRESULT GetSaveSlotFilename(int Slot, char *Buffer); void SetWindowTitle(); - virtual bool HandleMouseWheel(int Delta); + virtual bool handleMouseWheel(int Delta); bool _quitting; virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - virtual bool HandleKeypress(Common::Event *event, bool printable = false); + virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); int _freezeLevel; HRESULT Unfreeze(); @@ -295,7 +295,7 @@ public: virtual HRESULT LoadGame(int Slot); virtual HRESULT LoadGame(const char *Filename); virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); - virtual HRESULT ShowCursor(); + virtual HRESULT showCursor(); CBSprite *_cursorNoninteractive; CBObject *_activeObject; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 107ab2537c..156575b2b5 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -135,21 +135,21 @@ HRESULT CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::SetCaption(const char *Caption, int Case) { +void CBObject::setCaption(const char *caption, int Case) { // TODO: rename Case to something usefull if (Case == 0) Case = 1; if (Case < 1 || Case > 7) return; delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(Caption) + 1]; + _caption[Case - 1] = new char[strlen(caption) + 1]; if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], Caption); + strcpy(_caption[Case - 1], caption); Game->_stringTable->Expand(&_caption[Case - 1]); } } ////////////////////////////////////////////////////////////////////////// -char *CBObject::GetCaption(int Case) { +char *CBObject::getCaption(int Case) { if (Case == 0) Case = 1; if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; else return _caption[Case - 1]; @@ -185,7 +185,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Caption") == 0) { Stack->CorrectParams(1); - Stack->PushString(GetCaption(Stack->Pop()->GetInt())); + Stack->PushString(getCaption(Stack->Pop()->GetInt())); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetCursor") == 0) { Stack->CorrectParams(1); - if (SUCCEEDED(SetCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); + if (SUCCEEDED(setCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; @@ -257,7 +257,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetCaption") == 0) { Stack->CorrectParams(2); - SetCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); + setCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); Stack->PushNULL(); return S_OK; @@ -269,7 +269,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "LoadSound") == 0) { Stack->CorrectParams(1); const char *Filename = Stack->Pop()->GetString(); - if (SUCCEEDED(PlaySFX(Filename, false, false))) + if (SUCCEEDED(playSFX(Filename, false, false))) Stack->PushBool(true); else Stack->PushBool(false); @@ -302,7 +302,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi LoopStart = val3->GetInt(); } - if (FAILED(PlaySFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); + if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -327,7 +327,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi EventName = val2->GetString(); } - if (FAILED(PlaySFX(Filename, false, true, EventName))) Stack->PushBool(false); + if (FAILED(playSFX(Filename, false, true, EventName))) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -338,7 +338,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "StopSound") == 0) { Stack->CorrectParams(0); - if (FAILED(StopSFX())) Stack->PushBool(false); + if (FAILED(stopSFX())) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -349,7 +349,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "PauseSound") == 0) { Stack->CorrectParams(0); - if (FAILED(PauseSFX())) Stack->PushBool(false); + if (FAILED(pauseSFX())) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -360,7 +360,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "ResumeSound") == 0) { Stack->CorrectParams(0); - if (FAILED(ResumeSFX())) Stack->PushBool(false); + if (FAILED(resumeSFX())) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -383,7 +383,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); uint32 Time = Stack->Pop()->GetInt(); - if (FAILED(SetSFXTime(Time))) Stack->PushBool(false); + if (FAILED(setSFXTime(Time))) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -406,7 +406,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); int Volume = Stack->Pop()->GetInt(); - if (FAILED(SetSFXVolume(Volume))) Stack->PushBool(false); + if (FAILED(setSFXVolume(Volume))) Stack->PushBool(false); else Stack->PushBool(true); return S_OK; } @@ -488,7 +488,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Caption") == 0) { - _scValue->SetString(GetCaption(1)); + _scValue->SetString(getCaption(1)); return _scValue; } @@ -512,7 +512,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Height") == 0) { - _scValue->SetInt(GetHeight()); + _scValue->SetInt(getHeight()); return _scValue; } @@ -671,7 +671,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { // Caption ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "Caption") == 0) { - SetCaption(Value->GetString()); + setCaption(Value->GetString()); return S_OK; } @@ -813,7 +813,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SoundPanning") == 0) { _autoSoundPanning = Value->GetBool(); - if (!_autoSoundPanning) ResetSoundPan(); + if (!_autoSoundPanning) resetSoundPan(); return S_OK; } @@ -851,14 +851,14 @@ const char *CBObject::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ShowCursor() { +HRESULT CBObject::showCursor() { if (_cursor) return Game->DrawCursor(_cursor); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::saveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBObject::saveAsText(CBDynBuffer *buffer, int indent) { return S_OK; } @@ -919,7 +919,7 @@ HRESULT CBObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetCursor(const char *Filename) { +HRESULT CBObject::setCursor(const char *filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -927,7 +927,7 @@ HRESULT CBObject::SetCursor(const char *Filename) { _sharedCursors = false; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile(Filename))) { + if (!_cursor || FAILED(_cursor->LoadFile(filename))) { delete _cursor; _cursor = NULL; return E_FAIL; @@ -936,10 +936,10 @@ HRESULT CBObject::SetCursor(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetActiveCursor(const char *Filename) { +HRESULT CBObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->LoadFile(Filename))) { + if (!_activeCursor || FAILED(_activeCursor->LoadFile(filename))) { delete _activeCursor; _activeCursor = NULL; return E_FAIL; @@ -948,62 +948,62 @@ HRESULT CBObject::SetActiveCursor(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -int CBObject::GetHeight() { +int CBObject::getHeight() { return 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { +HRESULT CBObject::handleMouse(TMouseEvent event, TMouseButton button) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleKeypress(Common::Event *event, bool printable) { +bool CBObject::handleKeypress(Common::Event *event, bool printable) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::HandleMouseWheel(int Delta) { +bool CBObject::handleMouseWheel(int delta) { return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::PlaySFX(const char *Filename, bool Looping, bool PlayNow, const char *EventName, uint32 LoopStart) { +HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound - if (Filename == NULL && _sFX) { + if (filename == NULL && _sFX) { if (Game->_editorMode || _sFXStart) { _sFX->SetVolume(_sFXVolume); _sFX->SetPositionTime(_sFXStart); if (!Game->_editorMode) _sFXStart = 0; } - if (PlayNow) { - SetSoundEvent(EventName); - if (LoopStart) _sFX->SetLoopStart(LoopStart); - return _sFX->Play(Looping); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->SetLoopStart(loopStart); + return _sFX->Play(looping); } else return S_OK; } - if (Filename == NULL) return E_FAIL; + if (filename == NULL) return E_FAIL; // create new sound delete _sFX; _sFX = new CBSound(Game); - if (_sFX && SUCCEEDED(_sFX->SetSound(Filename, SOUND_SFX, true))) { + if (_sFX && SUCCEEDED(_sFX->SetSound(filename, SOUND_SFX, true))) { _sFX->SetVolume(_sFXVolume); if (_sFXStart) { _sFX->SetPositionTime(_sFXStart); _sFXStart = 0; } _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (PlayNow) { - SetSoundEvent(EventName); - if (LoopStart) _sFX->SetLoopStart(LoopStart); - return _sFX->Play(Looping); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->SetLoopStart(loopStart); + return _sFX->Play(looping); } else return S_OK; } else { delete _sFX; @@ -1014,10 +1014,10 @@ HRESULT CBObject::PlaySFX(const char *Filename, bool Looping, bool PlayNow, cons ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::StopSFX(bool DeleteSound) { +HRESULT CBObject::stopSFX(bool deleteSound) { if (_sFX) { _sFX->Stop(); - if (DeleteSound) { + if (deleteSound) { delete _sFX; _sFX = NULL; } @@ -1027,29 +1027,29 @@ HRESULT CBObject::StopSFX(bool DeleteSound) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::PauseSFX() { +HRESULT CBObject::pauseSFX() { if (_sFX) return _sFX->Pause(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ResumeSFX() { +HRESULT CBObject::resumeSFX() { if (_sFX) return _sFX->Resume(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetSFXTime(uint32 Time) { - _sFXStart = Time; - if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(Time); +HRESULT CBObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(time); else return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::SetSFXVolume(int Volume) { +HRESULT CBObject::setSFXVolume(int Volume) { _sFXVolume = Volume; if (_sFX) return _sFX->SetVolume(Volume); else return S_OK; @@ -1057,34 +1057,34 @@ HRESULT CBObject::SetSFXVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::UpdateSounds() { +HRESULT CBObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->IsPlaying()) { applyEvent(_soundEvent); - SetSoundEvent(NULL); + setSoundEvent(NULL); } } - if (_sFX) UpdateOneSound(_sFX); + if (_sFX) updateOneSound(_sFX); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::UpdateOneSound(CBSound *Sound) { +HRESULT CBObject::updateOneSound(CBSound *sound) { HRESULT Ret = S_OK; - if (Sound) { + if (sound) { if (_autoSoundPanning) - Ret = Sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); + Ret = sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); - Ret = Sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } return Ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::ResetSoundPan() { +HRESULT CBObject::resetSoundPan() { if (!_sFX) return S_OK; else { return _sFX->SetPan(0.0f); @@ -1093,24 +1093,24 @@ HRESULT CBObject::ResetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CBObject::GetExtendedFlag(const char *FlagName) { +bool CBObject::getExtendedFlag(const char *flagName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::IsReady() { +bool CBObject::isReady() { return _ready; } ////////////////////////////////////////////////////////////////////////// -void CBObject::SetSoundEvent(const char *EventName) { +void CBObject::setSoundEvent(const char *eventName) { delete[] _soundEvent; _soundEvent = NULL; - if (EventName) { - _soundEvent = new char[strlen(EventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, EventName); + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, eventName); } } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 294b345dec..20b6cfdb2a 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -50,27 +50,27 @@ public: float _relativeRotate; bool _rotateValid; float _rotate; - void SetSoundEvent(const char *EventName); + void setSoundEvent(const char *EventName); bool _rotatable; uint32 _alphaColor; float _scale; float _scaleX; float _scaleY; float _relativeScale; - virtual bool IsReady(); - virtual bool GetExtendedFlag(const char *FlagName); - virtual HRESULT ResetSoundPan(); - virtual HRESULT UpdateSounds(); - HRESULT UpdateOneSound(CBSound *Sound); + virtual bool isReady(); + virtual bool getExtendedFlag(const char *FlagName); + virtual HRESULT resetSoundPan(); + virtual HRESULT updateSounds(); + HRESULT updateOneSound(CBSound *Sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; - HRESULT SetSFXTime(uint32 Time); - HRESULT SetSFXVolume(int Volume); - HRESULT ResumeSFX(); - HRESULT PauseSFX(); - HRESULT StopSFX(bool DeleteSound = true); - HRESULT PlaySFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); + HRESULT setSFXTime(uint32 Time); + HRESULT setSFXVolume(int Volume); + HRESULT resumeSFX(); + HRESULT pauseSFX(); + HRESULT stopSFX(bool DeleteSound = true); + HRESULT playSFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -79,21 +79,21 @@ public: float _sFXParam3; float _sFXParam4; - virtual bool HandleMouseWheel(int Delta); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); - virtual bool HandleKeypress(Common::Event *event, bool printable = false); - virtual int GetHeight(); - HRESULT SetCursor(const char *Filename); - HRESULT SetActiveCursor(const char *Filename); + virtual bool handleMouseWheel(int Delta); + virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + HRESULT setCursor(const char *Filename); + HRESULT setActiveCursor(const char *Filename); HRESULT cleanup(); - char *GetCaption(int Case = 1); - void SetCaption(const char *Caption, int Case = 1); + char *getCaption(int Case = 1); + void setCaption(const char *Caption, int Case = 1); bool _editorSelected; bool _editorAlwaysRegister; bool _editorOnly; bool _is3D; DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual HRESULT ShowCursor(); + virtual HRESULT showCursor(); CBSprite *_cursor; bool _sharedCursors; CBSprite *_activeCursor; @@ -116,16 +116,16 @@ public: bool _saveState; // base - virtual HRESULT Update() { + virtual HRESULT update() { return E_FAIL; }; - virtual HRESULT Display() { + virtual HRESULT display() { return E_FAIL; }; - virtual HRESULT InvalidateDeviceObjects() { + virtual HRESULT invalidateDeviceObjects() { return S_OK; }; - virtual HRESULT RestoreDeviceObjects() { + virtual HRESULT restoreDeviceObjects() { return S_OK; }; bool _nonIntMouseEvents; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 9307af62bb..9de95bb858 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -169,7 +169,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_ACTIVE: @@ -383,7 +383,7 @@ HRESULT CBRegion::saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOv else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 8e851d5605..e7f9df194d 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -117,7 +117,7 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom } // draw frame - return Display(X, Y, Register, ZoomX, ZoomY, Alpha); + return display(X, Y, Register, ZoomX, ZoomY, Alpha); } @@ -383,7 +383,7 @@ bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +HRESULT CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; // on change... diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index a5dde324e5..67f703d744 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -56,7 +56,7 @@ public: bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); int _moveY; int _moveX; - HRESULT Display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + HRESULT display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); bool _canBreak; bool _editorMuted; diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 1a9d9008c6..c44a5960a1 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -52,7 +52,7 @@ CBTransitionMgr::~CBTransitionMgr() { ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::IsReady() { +bool CBTransitionMgr::isReady() { return (_state == TRANS_MGR_READY); } @@ -82,8 +82,8 @@ HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { #define FADE_DURATION 200 ////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::Update() { - if (IsReady()) return S_OK; +HRESULT CBTransitionMgr::update() { + if (isReady()) return S_OK; if (!_started) { _started = true; @@ -118,7 +118,7 @@ HRESULT CBTransitionMgr::Update() { error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); } - if (IsReady()) { + if (isReady()) { if (_preserveInteractive) Game->_interactive = _origInteractive; } return S_OK; diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h index 01cdee8262..41ec077822 100644 --- a/engines/wintermute/Base/BTransitionMgr.h +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -39,9 +39,9 @@ public: uint32 _lastTime; bool _origInteractive; bool _preserveInteractive; - HRESULT Update(); + HRESULT update(); HRESULT Start(TTransitionType Type, bool NonInteractive = false); - bool IsReady(); + bool isReady(); TTransMgrState _state; CBTransitionMgr(CBGame *inGame); virtual ~CBTransitionMgr(); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index 5010b2c030..e6c372b4e6 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -91,7 +91,7 @@ int CBViewport::GetWidth() { ////////////////////////////////////////////////////////////////////////// -int CBViewport::GetHeight() { +int CBViewport::getHeight() { return _rect.bottom - _rect.top; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 640f54f438..65d82de45b 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -36,7 +36,7 @@ namespace WinterMute { class CBObject; class CBViewport : public CBBase { public: - int GetHeight(); + int getHeight(); int GetWidth(); RECT *GetRect(); HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index bfce64041e..5f7f8f5906 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -226,7 +226,7 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Update() { +HRESULT CPartEmitter::update() { if (!_running) return S_OK; else return UpdateInternal(Game->_timer, Game->_timerDelta); } @@ -236,7 +236,7 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { int NumLive = 0; for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->Update(this, CurrentTime, TimerDelta); + _particles[i]->update(this, CurrentTime, TimerDelta); if (!_particles[i]->_isDead) NumLive++; } @@ -288,7 +288,7 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Display(CBRegion *Region) { +HRESULT CPartEmitter::display(CBRegion *Region) { if (_sprites.GetSize() <= 1) Game->_renderer->StartSpriteBatch(); for (int i = 0; i < _particles.GetSize(); i++) { @@ -296,7 +296,7 @@ HRESULT CPartEmitter::Display(CBRegion *Region) { if (!Region->PointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; } - _particles[i]->Display(this); + _particles[i]->display(this); } if (_sprites.GetSize() <= 1) Game->_renderer->EndSpriteBatch(); diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 45997b280e..f4ef67fe69 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -102,8 +102,8 @@ public: HRESULT Start(); - HRESULT Update(); - HRESULT Display(CBRegion *Region = NULL); + HRESULT update(); + HRESULT display(CBRegion *Region = NULL); HRESULT SortParticlesByZ(); HRESULT AddSprite(const char *Filename); diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index f772e6fe77..69b933b518 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -96,7 +96,7 @@ HRESULT CPartParticle::SetSprite(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { +HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { if (_state == PARTICLE_FADEIN) { if (CurrentTime - _fadeStart >= _fadeTime) { _state = PARTICLE_NORMAL; @@ -180,12 +180,12 @@ HRESULT CPartParticle::Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::Display(CPartEmitter *Emitter) { +HRESULT CPartParticle::display(CPartEmitter *Emitter) { if (!_sprite) return E_FAIL; if (_isDead) return S_OK; _sprite->GetCurrentFrame(); - return _sprite->Display(_pos.x, _pos.y, + return _sprite->display(_pos.x, _pos.y, NULL, _scale, _scale, DRGBA(255, 255, 255, _currentAlpha), diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 2c5c57034c..9618954475 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -68,8 +68,8 @@ public: bool _isDead; TParticleState _state; - HRESULT Update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); - HRESULT Display(CPartEmitter *Emitter); + HRESULT update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); + HRESULT display(CPartEmitter *Emitter); HRESULT SetSprite(const char *Filename); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 0066a2574f..4e2dd203cc 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -390,7 +390,7 @@ HRESULT CScEngine::Tick() { if(!obj_found) _scripts[i]->Finish(); // _waitObject no longer exists */ if (Game->ValidObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->IsReady()) _scripts[i]->Run(); + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->Run(); } else _scripts[i]->Finish(); break; } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 37270d8834..6817ef047b 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -77,14 +77,14 @@ void CBPlatform::HandleEvent(Common::Event *event) { if (Game) Game->OnMouseMiddleUp(); break; case Common::EVENT_KEYDOWN: - if (Game) Game->HandleKeypress(event); + if (Game) Game->handleKeypress(event); break; case Common::EVENT_KEYUP: if (Game) Game->handleKeyRelease(event); break; case Common::EVENT_WHEELUP: case Common::EVENT_WHEELDOWN: - if (Game) Game->HandleMouseWheel(event->mouse.y); + if (Game) Game->handleMouseWheel(event->mouse.y); break; /*#ifdef __IPHONEOS__ { @@ -102,12 +102,12 @@ void CBPlatform::HandleEvent(Common::Event *event) { //TODO /* case SDL_MOUSEWHEEL: - if (Game) Game->HandleMouseWheel(event->wheel.y); + if (Game) Game->handleMouseWheel(event->wheel.y); break; case SDL_KEYDOWN: case SDL_TEXTINPUT: - if (Game) Game->HandleKeypress(event); + if (Game) Game->handleKeypress(event); break; case SDL_WINDOWEVENT: diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 4751ead13b..f545a0a745 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -218,7 +218,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_BACK: @@ -445,7 +445,7 @@ HRESULT CUIButton::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "{\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -578,7 +578,7 @@ void CUIButton::CorrectSize() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::Display(int OffsetX, int OffsetY) { +HRESULT CUIButton::display(int OffsetX, int OffsetY) { if (!_visible) return S_OK; CUITiledImage *back = NULL; @@ -629,7 +629,7 @@ HRESULT CUIButton::Display(int OffsetX, int OffsetY) { ImageY += (_height - (rc.bottom - rc.top)) / 2; } - if (back) back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (back) back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 0f2a01b425..5a86087d76 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -44,7 +44,7 @@ public: uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) void Press(); - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); bool _press; bool _hover; void CorrectSize(); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 9c874b8ba3..fdb5b00a80 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -245,7 +245,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_CURSOR: @@ -307,7 +307,7 @@ HRESULT CUIEdit::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "{\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -543,7 +543,7 @@ void CUIEdit::SetCursorChar(const char *Char) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { +HRESULT CUIEdit::display(int OffsetX, int OffsetY) { if (!_visible) return S_OK; @@ -551,7 +551,7 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { TTextEncoding OrigEncoding = Game->_textEncoding; Game->_textEncoding = TEXT_ANSI; - if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); // prepare fonts @@ -686,7 +686,7 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::HandleKeypress(Common::Event *event, bool printable) { +bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { bool Handled = false; if (event->type == Common::EVENT_KEYDOWN && !printable) { diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index aea0f6088e..192257e996 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -43,8 +43,8 @@ public: int DeleteChars(int Start, int End); bool _cursorVisible; uint32 _lastBlinkTime; - virtual HRESULT Display(int OffsetX, int OffsetY); - virtual bool HandleKeypress(Common::Event *event, bool printable = false); + virtual HRESULT display(int OffsetX, int OffsetY); + virtual bool handleKeypress(Common::Event *event, bool printable = false); int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 8143afdf44..962a6b87d7 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -225,7 +225,7 @@ HRESULT CUIEntity::SetEntity(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { +HRESULT CUIEntity::display(int OffsetX, int OffsetY) { if (!_visible) return S_OK; if (_entity) { @@ -234,13 +234,13 @@ HRESULT CUIEntity::Display(int OffsetX, int OffsetY) { if (_entity->_scale < 0) _entity->_zoomable = false; _entity->_shadowable = false; - _entity->Update(); + _entity->update(); bool OrigReg = _entity->_registrable; if (_entity->_registrable && _disable) _entity->_registrable = false; - _entity->Display(); + _entity->display(); _entity->_registrable = OrigReg; } diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 5c3f29bd7d..29262d77c1 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -42,7 +42,7 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; HRESULT SetEntity(const char *Filename); diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 8560747297..31a7c044c7 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -98,7 +98,7 @@ void CUIObject::SetText(const char *Text) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Display(int OffsetX, int OffsetY) { +HRESULT CUIObject::display(int OffsetX, int OffsetY) { return S_OK; } @@ -500,12 +500,12 @@ bool CUIObject::IsFocused() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::HandleMouse(TMouseEvent Event, TMouseButton Button) { +HRESULT CUIObject::handleMouse(TMouseEvent Event, TMouseButton Button) { // handle focus change if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { Focus(); } - return CBObject::HandleMouse(Event, Button); + return CBObject::handleMouse(Event, Button); } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 910a2045cc..272b094131 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -43,12 +43,12 @@ public: HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); bool _canFocus; HRESULT Focus(); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); bool IsFocused(); bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) CUIObject *_parent; - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); virtual void CorrectSize(); bool _sharedFonts; bool _sharedImages; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 1c2033a8d3..e221314218 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -62,14 +62,14 @@ CUIText::~CUIText() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::Display(int OffsetX, int OffsetY) { +HRESULT CUIText::display(int OffsetX, int OffsetY) { if (!_visible) return S_OK; CBFont *font = _font; if (!font) font = Game->_systemFont; - if (_back) _back->Display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); if (font && _text) { @@ -185,7 +185,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_BACK: @@ -298,7 +298,7 @@ HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "{\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index e59c7b3cb3..5092623d8c 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -37,7 +37,7 @@ namespace WinterMute { class CUIText : public CUIObject { public: HRESULT SizeToFit(); - virtual HRESULT Display(int OffsetX, int OffsetY); + virtual HRESULT display(int OffsetX, int OffsetY); DECLARE_PERSISTENT(CUIText, CUIObject) CUIText(CBGame *inGame = NULL); virtual ~CUIText(); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 38cbdfdba7..54a85a0578 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -64,7 +64,7 @@ CUITiledImage::~CUITiledImage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::Display(int X, int Y, int Width, int Height) { +HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { if (!_image) return E_FAIL; int tile_width = _middleMiddle.right - _middleMiddle.left; diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index f73c995310..fa0338586e 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -42,7 +42,7 @@ public: HRESULT LoadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT Display(int X, int Y, int Width, int Height); + HRESULT display(int X, int Y, int Width, int Height); CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d89a5e4b42..8b6ed746af 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -113,7 +113,7 @@ void CUIWindow::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { +HRESULT CUIWindow::display(int OffsetX, int OffsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); @@ -122,7 +122,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { _shieldWindow->_width = Game->_renderer->_width; _shieldWindow->_height = Game->_renderer->_height; - _shieldWindow->Display(); + _shieldWindow->display(); } } else if (_isMenu) { if (!_shieldButton) { @@ -136,7 +136,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { _shieldButton->_width = Game->_renderer->_width; _shieldButton->_height = Game->_renderer->_height; - _shieldButton->Display(); + _shieldButton->display(); } } @@ -178,7 +178,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { } if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; - if (back) back->Display(_posX + OffsetX, _posY + OffsetY, _width, _height); + if (back) back->display(_posX + OffsetX, _posY + OffsetY, _width, _height); if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { @@ -188,7 +188,7 @@ HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); for (int i = 0; i < _widgets.GetSize(); i++) { - _widgets[i]->Display(_posX + OffsetX, _posY + OffsetY); + _widgets[i]->display(_posX + OffsetX, _posY + OffsetY); } if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; @@ -325,7 +325,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_CAPTION: - SetCaption((char *)params); + setCaption((char *)params); break; case TOKEN_BACK: @@ -572,7 +572,7 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { Buffer->PutTextIndent(Indent, "{\n"); Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption()); + Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); Buffer->PutTextIndent(Indent + 2, "\n"); @@ -1100,12 +1100,12 @@ const char *CUIWindow::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleKeypress(Common::Event *event, bool printable) { +bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); } else { - if (_focusedWidget) return _focusedWidget->HandleKeypress(event, printable); + if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); else return false; } return false; @@ -1113,15 +1113,15 @@ bool CUIWindow::HandleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::HandleMouseWheel(int Delta) { - if (_focusedWidget) return _focusedWidget->HandleMouseWheel(Delta); +bool CUIWindow::handleMouseWheel(int Delta) { + if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); else return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::HandleMouse(TMouseEvent Event, TMouseButton Button) { - HRESULT res = CUIObject::HandleMouse(Event, Button); +HRESULT CUIWindow::handleMouse(TMouseEvent Event, TMouseButton Button) { + HRESULT res = CUIObject::handleMouse(Event, Button); // handle window dragging if (!CBPlatform::IsRectEmpty(&_dragRect)) { diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 53d52d55fc..ed81ef9d06 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -50,7 +50,7 @@ public: bool _isMenu; bool _fadeBackground; uint32 _fadeColor; - virtual bool HandleMouseWheel(int Delta); + virtual bool handleMouseWheel(int Delta); CUIWindow *_shieldWindow; CUIButton *_shieldButton; HRESULT Close(); @@ -58,7 +58,7 @@ public: HRESULT GoExclusive(); TWindowMode _mode; HRESULT MoveFocus(bool Forward = true); - virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button); + virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); POINT _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) @@ -67,10 +67,10 @@ public: HRESULT EnableWidget(const char *Name, bool Enable = true); RECT _titleRect; RECT _dragRect; - virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); - virtual bool HandleKeypress(Common::Event *event, bool printable = false); + virtual bool handleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; HRESULT LoadFile(const char *Filename); diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 365e10bdd7..c0dbfea56f 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -211,7 +211,7 @@ HRESULT CVidPlayer::update() { HRESULT res; if (_soundAvailable && m_Sound) { - res = _sound->Update(); + res = _sound->update(); if (FAILED(res)) return res; } @@ -279,7 +279,7 @@ HRESULT CVidPlayer::display() { if (!m_Playing) return S_OK; HRESULT res; - if (_vidRenderer) res = _vidRenderer->Display(m_PlayPosX, m_PlayPosY, m_PlayZoom); + if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); else res = E_FAIL; // display subtitle diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 6b85f0b20f..779827212a 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -578,7 +578,7 @@ HRESULT CVidTheoraPlayer::update() { m_PlaybackStarted = true; } - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Update(GetMovieFrame()); + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); #endif return S_OK; } @@ -656,7 +656,7 @@ HRESULT CVidTheoraPlayer::display(uint32 alpha) { else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); } else res = E_FAIL; #if 0 - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->Display(); + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->display(); #endif return res; } -- cgit v1.2.3 From 293e12f7d082806f1fb60f22bf348cbe47381430 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 01:19:42 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the file-classes --- engines/wintermute/Base/BFileManager.cpp | 4 ++-- engines/wintermute/Base/BPackage.cpp | 8 ++++---- engines/wintermute/Base/BPackage.h | 6 +++--- engines/wintermute/Base/file/BFile.cpp | 8 ++++---- engines/wintermute/Base/file/BFile.h | 10 +++++----- engines/wintermute/Base/file/BSaveThumbFile.cpp | 12 ++++++------ engines/wintermute/Base/file/BSaveThumbFile.h | 8 ++++---- engines/wintermute/UI/UIWindow.cpp | 12 ++++++------ engines/wintermute/UI/UIWindow.h | 2 +- 9 files changed, 35 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 397d314c3a..448c1d684f 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -231,7 +231,7 @@ HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, ui HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { // unmount all non-local packages for (int i = 0; i < _packages.GetSize(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->Close(); + if (_packages[i]->_cD > 0) _packages[i]->close(); } @@ -805,7 +805,7 @@ Common::SeekableReadStream *CBFileManager::OpenFileRaw(const Common::String &Fil if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->Open(Filename))) return SaveThumbFile->getMemStream(); + if (SUCCEEDED(SaveThumbFile->open(Filename))) return SaveThumbFile->getMemStream(); else { delete SaveThumbFile; return NULL; diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index 976e9b3344..9f68bfa2d0 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -57,7 +57,7 @@ CBPackage::~CBPackage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Open() { +HRESULT CBPackage::open() { if (_file) return S_OK; else { _file = GetFilePointer(); @@ -67,7 +67,7 @@ HRESULT CBPackage::Open() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Close() { +HRESULT CBPackage::close() { delete _file; _file = NULL; return S_OK; @@ -75,9 +75,9 @@ HRESULT CBPackage::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { +HRESULT CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { HRESULT ret; - if (FAILED(ret = Open())) return ret; + if (FAILED(ret = open())) return ret; else { if (file->seek(offset, SEEK_SET)) return E_FAIL; if (file->read(buffer, size) != 1) return E_FAIL; diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h index 80d8e481f2..7b4e8a4d6c 100644 --- a/engines/wintermute/Base/BPackage.h +++ b/engines/wintermute/Base/BPackage.h @@ -45,9 +45,9 @@ public: bool _boundToExe; byte _priority; - HRESULT Read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - HRESULT Close(); - HRESULT Open(); + HRESULT read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + HRESULT close(); + HRESULT open(); char *_name; int _cD; Common::SeekableReadStream *_file; diff --git a/engines/wintermute/Base/file/BFile.cpp b/engines/wintermute/Base/file/BFile.cpp index 6fa7cb84d6..9da60a11ec 100644 --- a/engines/wintermute/Base/file/BFile.cpp +++ b/engines/wintermute/Base/file/BFile.cpp @@ -51,16 +51,16 @@ CBFile::~CBFile() { ////////////////////////////////////////////////////////////////////////// -bool CBFile::IsEOF() { +bool CBFile::isEOF() { return _pos == _size; } Common::SeekableReadStream *CBFile::getMemStream() { uint32 oldPos = getPos(); - Seek(0); + seek(0); byte *data = new byte[getSize()]; - Read(data, getSize()); - Seek(oldPos); + read(data, getSize()); + seek(oldPos); Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); return memStream; } diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index caeac3e14b..16b51a50fc 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -51,11 +51,11 @@ public: virtual uint32 getPos() { return _pos; }; - virtual HRESULT Seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; - virtual HRESULT Read(void *buffer, uint32 size) = 0; - virtual HRESULT Close() = 0; - virtual HRESULT Open(const Common::String &filename) = 0; - virtual bool IsEOF(); + virtual HRESULT seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; + virtual HRESULT read(void *buffer, uint32 size) = 0; + virtual HRESULT close() = 0; + virtual HRESULT open(const Common::String &filename) = 0; + virtual bool isEOF(); CBFile(CBGame *inGame); virtual ~CBFile(); // Temporary solution to allow usage in ScummVM-code: diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 5f5278199b..5f70f7636f 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -46,13 +46,13 @@ CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { ////////////////////////////////////////////////////////////////////////// CBSaveThumbFile::~CBSaveThumbFile() { - Close(); + close(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Open(const Common::String &filename) { - Close(); +HRESULT CBSaveThumbFile::open(const Common::String &filename) { + close(); if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return E_FAIL; @@ -97,7 +97,7 @@ HRESULT CBSaveThumbFile::Open(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Close() { +HRESULT CBSaveThumbFile::close() { delete[] _data; _data = NULL; @@ -109,7 +109,7 @@ HRESULT CBSaveThumbFile::Close() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Read(void *buffer, uint32 size) { +HRESULT CBSaveThumbFile::read(void *buffer, uint32 size) { if (!_data || _pos + size > _size) return E_FAIL; memcpy(buffer, (byte *)_data + _pos, size); @@ -120,7 +120,7 @@ HRESULT CBSaveThumbFile::Read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::Seek(uint32 pos, TSeek origin) { +HRESULT CBSaveThumbFile::seek(uint32 pos, TSeek origin) { if (!_data) return E_FAIL; uint32 newPos = 0; diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 78626eeff4..280a5a1447 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -39,10 +39,10 @@ class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); virtual ~CBSaveThumbFile(); - virtual HRESULT Seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT Read(void *Buffer, uint32 Size); - virtual HRESULT Close(); - virtual HRESULT Open(const Common::String &Filename); + virtual HRESULT seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + virtual HRESULT read(void *Buffer, uint32 Size); + virtual HRESULT close(); + virtual HRESULT open(const Common::String &Filename); private: byte *_data; }; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 8b6ed746af..1998b380cd 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -89,7 +89,7 @@ CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIWindow::~CUIWindow() { - Close(); + close(); cleanup(); } @@ -773,7 +773,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Close") == 0) { Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(Close())); + Stack->PushBool(SUCCEEDED(close())); return S_OK; } @@ -1070,7 +1070,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { if (Value->GetBool()) GoExclusive(); else { - Close(); + close(); _visible = true; } return S_OK; @@ -1083,7 +1083,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { if (Value->GetBool()) GoSystemExclusive(); else { - Close(); + close(); _visible = true; } return S_OK; @@ -1254,7 +1254,7 @@ HRESULT CUIWindow::GoSystemExclusive() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::Close() { +HRESULT CUIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { Game->Unfreeze(); } @@ -1273,7 +1273,7 @@ HRESULT CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) Close(); + if (scumm_stricmp(obj->_name, "close") == 0) close(); else return CBObject::listen(param1, param2); break; default: diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index ed81ef9d06..adc2a89d21 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -53,7 +53,7 @@ public: virtual bool handleMouseWheel(int Delta); CUIWindow *_shieldWindow; CUIButton *_shieldButton; - HRESULT Close(); + HRESULT close(); HRESULT GoSystemExclusive(); HRESULT GoExclusive(); TWindowMode _mode; -- cgit v1.2.3 From cb16242d5dfe7d8ccbb1828c0898ab1f5a92e41a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 01:30:01 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the Particle Engine --- engines/wintermute/Base/PartEmitter.cpp | 56 ++++++++++++++++---------------- engines/wintermute/Base/PartEmitter.h | 27 +++++++-------- engines/wintermute/Base/PartParticle.cpp | 12 +++---- engines/wintermute/Base/PartParticle.h | 6 ++-- 4 files changed, 51 insertions(+), 50 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 5f7f8f5906..1ff3bf1122 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -116,7 +116,7 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddSprite(const char *Filename) { +HRESULT CPartEmitter::addSprite(const char *Filename) { if (!Filename) return E_FAIL; // do we already have the file? @@ -139,7 +139,7 @@ HRESULT CPartEmitter::AddSprite(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveSprite(const char *Filename) { +HRESULT CPartEmitter::removeSprite(const char *Filename) { for (int i = 0; i < _sprites.GetSize(); i++) { if (scumm_stricmp(Filename, _sprites[i]) == 0) { delete [] _sprites[i]; @@ -151,7 +151,7 @@ HRESULT CPartEmitter::RemoveSprite(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { +HRESULT CPartEmitter::initParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { if (!Particle) return E_FAIL; if (_sprites.GetSize() == 0) return E_FAIL; @@ -217,8 +217,8 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, Particle->_angVelocity = AngVelocity; Particle->_growthRate = GrowthRate; Particle->_exponentialGrowth = _exponentialGrowth; - Particle->_isDead = FAILED(Particle->SetSprite(_sprites[SpriteIndex])); - Particle->FadeIn(CurrentTime, _fadeInTime); + Particle->_isDead = FAILED(Particle->setSprite(_sprites[SpriteIndex])); + Particle->fadeIn(CurrentTime, _fadeInTime); if (Particle->_isDead) return E_FAIL; @@ -228,11 +228,11 @@ HRESULT CPartEmitter::InitParticle(CPartParticle *Particle, uint32 CurrentTime, ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::update() { if (!_running) return S_OK; - else return UpdateInternal(Game->_timer, Game->_timerDelta); + else return updateInternal(Game->_timer, Game->_timerDelta); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { +HRESULT CPartEmitter::updateInternal(uint32 CurrentTime, uint32 TimerDelta) { int NumLive = 0; for (int i = 0; i < _particles.GetSize(); i++) { @@ -269,14 +269,14 @@ HRESULT CPartEmitter::UpdateInternal(uint32 CurrentTime, uint32 TimerDelta) { Particle = new CPartParticle(Game); _particles.Add(Particle); } - InitParticle(Particle, CurrentTime, TimerDelta); + initParticle(Particle, CurrentTime, TimerDelta); NeedsSort = true; ToGen--; } } if (NeedsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - SortParticlesByZ(); + sortParticlesByZ(); // we actually generated some particles and we're not in fast-forward mode if (NeedsSort && _overheadTime == 0) { @@ -305,7 +305,7 @@ HRESULT CPartEmitter::display(CBRegion *Region) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::Start() { +HRESULT CPartEmitter::start() { for (int i = 0; i < _particles.GetSize(); i++) { _particles[i]->_isDead = true; } @@ -319,7 +319,7 @@ HRESULT CPartEmitter::Start() { uint32 CurrentTime = Game->_timer - _overheadTime; for (int i = 0; i < Steps; i++) { - UpdateInternal(CurrentTime, Delta); + updateInternal(CurrentTime, Delta); CurrentTime += Delta; } _overheadTime = 0; @@ -330,14 +330,14 @@ HRESULT CPartEmitter::Start() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SortParticlesByZ() { +HRESULT CPartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::CompareZ); + qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); return S_OK; } ////////////////////////////////////////////////////////////////////////// -int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { +int CPartEmitter::compareZ(const void *Obj1, const void *Obj2) { CPartParticle *P1 = *(CPartParticle **)Obj1; CPartParticle *P2 = *(CPartParticle **)Obj2; @@ -347,14 +347,14 @@ int CPartEmitter::CompareZ(const void *Obj1, const void *Obj2) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SetBorder(int X, int Y, int Width, int Height) { +HRESULT CPartEmitter::setBorder(int X, int Y, int Width, int Height) { CBPlatform::SetRect(&_border, X, Y, X + Width, Y + Height); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { +HRESULT CPartEmitter::setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { _borderThicknessLeft = ThicknessLeft; _borderThicknessRight = ThicknessRight; _borderThicknessTop = ThicknessTop; @@ -364,7 +364,7 @@ HRESULT CPartEmitter::SetBorderThickness(int ThicknessLeft, int ThicknessRight, } ////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::AddForceByName(const char *Name) { +CPartForce *CPartEmitter::addForceByName(const char *Name) { CPartForce *Force = NULL; for (int i = 0; i < _forces.GetSize(); i++) { @@ -385,8 +385,8 @@ CPartForce *CPartEmitter::AddForceByName(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { - CPartForce *Force = AddForceByName(Name); +HRESULT CPartEmitter::addForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { + CPartForce *Force = addForceByName(Name); if (!Force) return E_FAIL; Force->_type = Type; @@ -401,7 +401,7 @@ HRESULT CPartEmitter::AddForce(const char *Name, CPartForce::TForceType Type, in } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::RemoveForce(const char *Name) { +HRESULT CPartEmitter::removeForce(const char *Name) { for (int i = 0; i < _forces.GetSize(); i++) { if (scumm_stricmp(Name, _forces[i]->_name) == 0) { delete _forces[i]; @@ -427,7 +427,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack int BorderWidth = Stack->Pop()->GetInt(); int BorderHeight = Stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(SetBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + Stack->PushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); return S_OK; } @@ -441,7 +441,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack int Top = Stack->Pop()->GetInt(); int Bottom = Stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(SetBorderThickness(Left, Right, Top, Bottom))); + Stack->PushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); return S_OK; } @@ -451,7 +451,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "AddSprite") == 0) { Stack->CorrectParams(1); const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(AddSprite(SpriteFile))); + Stack->PushBool(SUCCEEDED(addSprite(SpriteFile))); return S_OK; } @@ -461,7 +461,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "RemoveSprite") == 0) { Stack->CorrectParams(1); const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveSprite(SpriteFile))); + Stack->PushBool(SUCCEEDED(removeSprite(SpriteFile))); return S_OK; } @@ -472,7 +472,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack else if (strcmp(Name, "Start") == 0) { Stack->CorrectParams(1); _overheadTime = Stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(Start())); + Stack->PushBool(SUCCEEDED(start())); return S_OK; } @@ -525,7 +525,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack float Angle = Stack->Pop()->GetFloat(); float Strength = Stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(AddForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + Stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); return S_OK; } @@ -541,7 +541,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack float Angle = Stack->Pop()->GetFloat(); float Strength = Stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(AddForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + Stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); return S_OK; } @@ -553,7 +553,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack Stack->CorrectParams(1); const char *forceName = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveForce(forceName))); + Stack->PushBool(SUCCEEDED(removeForce(forceName))); return S_OK; } diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index f4ef67fe69..1fd061f95b 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -100,19 +100,20 @@ public: char *_emitEvent; CBScriptHolder *_owner; - HRESULT Start(); + HRESULT start(); HRESULT update(); - HRESULT display(CBRegion *Region = NULL); + HRESULT display() { return display(NULL); } // To avoid shadowing the inherited display-function. + HRESULT display(CBRegion *Region); - HRESULT SortParticlesByZ(); - HRESULT AddSprite(const char *Filename); - HRESULT RemoveSprite(const char *Filename); - HRESULT SetBorder(int X, int Y, int Width, int Height); - HRESULT SetBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); + HRESULT sortParticlesByZ(); + HRESULT addSprite(const char *Filename); + HRESULT removeSprite(const char *Filename); + HRESULT setBorder(int X, int Y, int Width, int Height); + HRESULT setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); - HRESULT AddForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); - HRESULT RemoveForce(const char *Name); + HRESULT addForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT removeForce(const char *Name); CBArray _forces; @@ -124,10 +125,10 @@ public: private: - CPartForce *AddForceByName(const char *Name); - int static CompareZ(const void *Obj1, const void *Obj2); - HRESULT InitParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); - HRESULT UpdateInternal(uint32 CurrentTime, uint32 TimerDelta); + CPartForce *addForceByName(const char *Name); + int static compareZ(const void *Obj1, const void *Obj2); + HRESULT initParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); + HRESULT updateInternal(uint32 CurrentTime, uint32 TimerDelta); uint32 _lastGenTime; CBArray _particles; CBArray _sprites; diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 69b933b518..4b1475f780 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -72,7 +72,7 @@ CPartParticle::~CPartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::SetSprite(const char *Filename) { +HRESULT CPartParticle::setSprite(const char *Filename) { if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { _sprite->Reset(); return S_OK; @@ -116,7 +116,7 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 if (_lifeTime > 0) { if (CurrentTime - _creationTime >= _lifeTime) { if (Emitter->_fadeOutTime > 0) - FadeOut(CurrentTime, Emitter->_fadeOutTime); + fadeOut(CurrentTime, Emitter->_fadeOutTime); else _isDead = true; } @@ -127,7 +127,7 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 POINT p; p.x = _pos.x; p.y = _pos.y; - if (!CBPlatform::PtInRect(&_border, p)) FadeOut(CurrentTime, Emitter->_fadeOutTime); + if (!CBPlatform::PtInRect(&_border, p)) fadeOut(CurrentTime, Emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return S_OK; @@ -195,7 +195,7 @@ HRESULT CPartParticle::display(CPartEmitter *Emitter) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { +HRESULT CPartParticle::fadeIn(uint32 CurrentTime, int FadeTime) { _currentAlpha = 0; _fadeStart = CurrentTime; _fadeTime = FadeTime; @@ -205,7 +205,7 @@ HRESULT CPartParticle::FadeIn(uint32 CurrentTime, int FadeTime) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::FadeOut(uint32 CurrentTime, int FadeTime) { +HRESULT CPartParticle::fadeOut(uint32 CurrentTime, int FadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; _fadeStart = CurrentTime; @@ -243,7 +243,7 @@ HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { char *Filename; persistMgr->transfer(TMEMBER(Filename)); CSysClassRegistry::GetInstance()->_disabled = true; - SetSprite(Filename); + setSprite(Filename); CSysClassRegistry::GetInstance()->_disabled = false; delete[] Filename; Filename = NULL; diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 9618954475..9edc999426 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -71,10 +71,10 @@ public: HRESULT update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); HRESULT display(CPartEmitter *Emitter); - HRESULT SetSprite(const char *Filename); + HRESULT setSprite(const char *Filename); - HRESULT FadeIn(uint32 CurrentTime, int FadeTime); - HRESULT FadeOut(uint32 CurrentTime, int FadeTime); + HRESULT fadeIn(uint32 CurrentTime, int FadeTime); + HRESULT fadeOut(uint32 CurrentTime, int FadeTime); HRESULT persist(CBPersistMgr *PersistMgr); private: -- cgit v1.2.3 From 1d2653e2b0dae173203dba0012e7b342df93cbb2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 01:47:10 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the sound-classes. --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdItem.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 6 +- engines/wintermute/Ad/AdSentence.cpp | 4 +- engines/wintermute/Base/BFrame.cpp | 6 +- engines/wintermute/Base/BGame.cpp | 52 ++++++++-------- engines/wintermute/Base/BObject.cpp | 40 ++++++------ engines/wintermute/Base/BSound.cpp | 104 +++++++++++++++---------------- engines/wintermute/Base/BSound.h | 34 +++++----- engines/wintermute/Base/BSoundBuffer.cpp | 38 +++++------ engines/wintermute/Base/BSoundBuffer.h | 36 +++++------ engines/wintermute/Base/BSoundMgr.cpp | 26 ++++---- engines/wintermute/Base/BSprite.cpp | 2 +- 15 files changed, 178 insertions(+), 178 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index bfd344531c..b2686245a6 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -684,7 +684,7 @@ HRESULT CAdActor::update() { _sentence->update(_dir); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->Finish(); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 9e7fb28f2a..64a9531678 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -565,7 +565,7 @@ HRESULT CAdEntity::update() { _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->Finish(); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index c16c1dac28..2d1a24c600 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -307,7 +307,7 @@ void CAdGame::FinishSentences() { for (int i = 0; i < _sentences.GetSize(); i++) { if (_sentences[i]->CanSkip()) { _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) _sentences[i]->_sound->Stop(); + if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); } } } diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index ca001b3eb7..2885623454 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -357,7 +357,7 @@ HRESULT CAdItem::update() { _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->IsPlaying() && !_sentence->_sound->IsPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->Finish(); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index ca6880557e..6cd37ee040 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -862,10 +862,10 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const // load sound and set duration appropriately if (Sound) { CBSound *snd = new CBSound(Game); - if (snd && SUCCEEDED(snd->SetSound(Sound, SOUND_SPEECH, true))) { + if (snd && SUCCEEDED(snd->setSound(Sound, SOUND_SPEECH, true))) { _sentence->SetSound(snd); if (_sentence->_duration <= 0) { - uint32 Length = snd->GetLength(); + uint32 Length = snd->getLength(); if (Length != 0) _sentence->_duration = Length; } } else delete snd; @@ -1009,7 +1009,7 @@ HRESULT CAdObject::updateSounds() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::resetSoundPan() { if (_sentence && _sentence->_sound) { - _sentence->_sound->SetPan(0.0f); + _sentence->_sound->setPan(0.0f); } return CBObject::resetSoundPan(); } diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index a753f13a67..feaeec714d 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -169,7 +169,7 @@ HRESULT CAdSentence::display() { if (!_font || !_text) return E_FAIL; if (_sound && !_soundStarted) { - _sound->Play(); + _sound->play(); _soundStarted = true; } @@ -205,7 +205,7 @@ void CAdSentence::SetSound(CBSound *Sound) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSentence::Finish() { - if (_sound) _sound->Stop(); + if (_sound) _sound->stop(); return S_OK; } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 7acc45e3ba..95b81feb51 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -91,7 +91,7 @@ HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { if (_sound && !Muted) { if (Owner) Owner->updateOneSound(_sound); - _sound->Play(); + _sound->play(); /* if (Game->_state == GAME_FROZEN) { _sound->Pause(true); @@ -252,7 +252,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { _sound = NULL; } _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->SetSound(params, SOUND_SFX, false))) { + if (!_sound || FAILED(_sound->setSound(params, SOUND_SFX, false))) { if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); delete _sound; _sound = NULL; @@ -425,7 +425,7 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (!Val->IsNULL()) { _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->SetSound(Val->GetString(), SOUND_SFX, false))) { + if (!_sound || FAILED(_sound->setSound(Val->GetString(), SOUND_SFX, false))) { Stack->PushBool(false); delete _sound; _sound = NULL; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 62197ec430..08f0ddecfa 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1235,7 +1235,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->GetPositionTime()); + else Stack->PushInt(_music[Channel]->getPositionTime()); return S_OK; } @@ -1251,7 +1251,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); - else Stack->PushBool(_music[Channel]->IsPlaying()); + else Stack->PushBool(_music[Channel]->isPlaying()); return S_OK; } @@ -1269,7 +1269,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS int Volume = Stack->Pop()->GetInt(); if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); else { - if (FAILED(_music[Channel]->SetVolume(Volume))) Stack->PushBool(false); + if (FAILED(_music[Channel]->setVolume(Volume))) Stack->PushBool(false); else Stack->PushBool(true); } return S_OK; @@ -1287,7 +1287,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->GetVolume()); + else Stack->PushInt(_music[Channel]->getVolume()); return S_OK; } @@ -1330,8 +1330,8 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS const char *Filename = Stack->Pop()->GetString(); CBSound *Sound = new CBSound(Game); - if (Sound && SUCCEEDED(Sound->SetSound(Filename, SOUND_MUSIC, true))) { - Length = Sound->GetLength(); + if (Sound && SUCCEEDED(Sound->setSound(Filename, SOUND_MUSIC, true))) { + Length = Sound->getLength(); delete Sound; Sound = NULL; } @@ -3369,7 +3369,7 @@ void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadSound(void *Sound, void *Data) { - ((CBSound *)Sound)->SetSoundSimple(); + ((CBSound *)Sound)->setSoundSimple(); } ////////////////////////////////////////////////////////////////////////// @@ -3424,13 +3424,13 @@ HRESULT CBGame::PlayMusic(int Channel, const char *Filename, bool Looping, uint3 _music[Channel] = NULL; _music[Channel] = new CBSound(Game); - if (_music[Channel] && SUCCEEDED(_music[Channel]->SetSound(Filename, SOUND_MUSIC, true))) { + if (_music[Channel] && SUCCEEDED(_music[Channel]->setSound(Filename, SOUND_MUSIC, true))) { if (_musicStartTime[Channel]) { - _music[Channel]->SetPositionTime(_musicStartTime[Channel]); + _music[Channel]->setPositionTime(_musicStartTime[Channel]); _musicStartTime[Channel] = 0; } - if (LoopStart) _music[Channel]->SetLoopStart(LoopStart); - return _music[Channel]->Play(Looping); + if (LoopStart) _music[Channel]->setLoopStart(LoopStart); + return _music[Channel]->play(Looping); } else { delete _music[Channel]; _music[Channel] = NULL; @@ -3447,7 +3447,7 @@ HRESULT CBGame::StopMusic(int Channel) { } if (_music[Channel]) { - _music[Channel]->Stop(); + _music[Channel]->stop(); delete _music[Channel]; _music[Channel] = NULL; return S_OK; @@ -3462,7 +3462,7 @@ HRESULT CBGame::PauseMusic(int Channel) { return E_FAIL; } - if (_music[Channel]) return _music[Channel]->Pause(); + if (_music[Channel]) return _music[Channel]->pause(); else return E_FAIL; } @@ -3474,7 +3474,7 @@ HRESULT CBGame::ResumeMusic(int Channel) { return E_FAIL; } - if (_music[Channel]) return _music[Channel]->Resume(); + if (_music[Channel]) return _music[Channel]->resume(); else return E_FAIL; } @@ -3488,7 +3488,7 @@ HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { } _musicStartTime[Channel] = Time; - if (_music[Channel] && _music[Channel]->IsPlaying()) return _music[Channel]->SetPositionTime(Time); + if (_music[Channel] && _music[Channel]->isPlaying()) return _music[Channel]->setPositionTime(Time); else return S_OK; } @@ -4123,19 +4123,19 @@ HRESULT CBGame::UpdateMusicCrossfade() { return S_OK; } - if (!_music[_musicCrossfadeChannel1]->IsPlaying()) _music[_musicCrossfadeChannel1]->Play(); - if (!_music[_musicCrossfadeChannel2]->IsPlaying()) _music[_musicCrossfadeChannel2]->Play(); + if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); + if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); uint32 CurrentTime = Game->_liveTimer - _musicCrossfadeStartTime; if (CurrentTime >= _musicCrossfadeLength) { _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->SetVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->SetVolume(100); + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolume(100); - _music[_musicCrossfadeChannel1]->Stop(); - //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->SetVolume(100); + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolume(100); if (_musicCrossfadeSwap) { @@ -4150,10 +4150,10 @@ HRESULT CBGame::UpdateMusicCrossfade() { _musicStartTime[_musicCrossfadeChannel2] = DummyInt; } } else { - //_music[_musicCrossfadeChannel1]->SetVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->SetVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); - _music[_musicCrossfadeChannel2]->SetVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 156575b2b5..d117fe3455 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -371,7 +371,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "IsSoundPlaying") == 0) { Stack->CorrectParams(0); - if (_sFX && _sFX->IsPlaying()) Stack->PushBool(true); + if (_sFX && _sFX->isPlaying()) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; } @@ -395,7 +395,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(0); if (!_sFX) Stack->PushInt(0); - else Stack->PushInt(_sFX->GetPositionTime()); + else Stack->PushInt(_sFX->getPositionTime()); return S_OK; } @@ -418,7 +418,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(0); if (!_sFX) Stack->PushInt(_sFXVolume); - else Stack->PushInt(_sFX->GetVolume()); + else Stack->PushInt(_sFX->getVolume()); return S_OK; } @@ -976,14 +976,14 @@ HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, cons // just play loaded sound if (filename == NULL && _sFX) { if (Game->_editorMode || _sFXStart) { - _sFX->SetVolume(_sFXVolume); - _sFX->SetPositionTime(_sFXStart); + _sFX->setVolume(_sFXVolume); + _sFX->setPositionTime(_sFXStart); if (!Game->_editorMode) _sFXStart = 0; } if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->SetLoopStart(loopStart); - return _sFX->Play(looping); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); } else return S_OK; } @@ -993,17 +993,17 @@ HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, cons delete _sFX; _sFX = new CBSound(Game); - if (_sFX && SUCCEEDED(_sFX->SetSound(filename, SOUND_SFX, true))) { - _sFX->SetVolume(_sFXVolume); + if (_sFX && SUCCEEDED(_sFX->setSound(filename, SOUND_SFX, true))) { + _sFX->setVolume(_sFXVolume); if (_sFXStart) { - _sFX->SetPositionTime(_sFXStart); + _sFX->setPositionTime(_sFXStart); _sFXStart = 0; } _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->SetLoopStart(loopStart); - return _sFX->Play(looping); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); } else return S_OK; } else { delete _sFX; @@ -1016,7 +1016,7 @@ HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, cons ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::stopSFX(bool deleteSound) { if (_sFX) { - _sFX->Stop(); + _sFX->stop(); if (deleteSound) { delete _sFX; _sFX = NULL; @@ -1028,14 +1028,14 @@ HRESULT CBObject::stopSFX(bool deleteSound) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::pauseSFX() { - if (_sFX) return _sFX->Pause(); + if (_sFX) return _sFX->pause(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::resumeSFX() { - if (_sFX) return _sFX->Resume(); + if (_sFX) return _sFX->resume(); else return E_FAIL; } @@ -1043,7 +1043,7 @@ HRESULT CBObject::resumeSFX() { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::setSFXTime(uint32 time) { _sFXStart = time; - if (_sFX && _sFX->IsPlaying()) return _sFX->SetPositionTime(time); + if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); else return S_OK; } @@ -1051,7 +1051,7 @@ HRESULT CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::setSFXVolume(int Volume) { _sFXVolume = Volume; - if (_sFX) return _sFX->SetVolume(Volume); + if (_sFX) return _sFX->setVolume(Volume); else return S_OK; } @@ -1059,7 +1059,7 @@ HRESULT CBObject::setSFXVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::updateSounds() { if (_soundEvent) { - if (_sFX && !_sFX->IsPlaying()) { + if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); setSoundEvent(NULL); } @@ -1076,7 +1076,7 @@ HRESULT CBObject::updateOneSound(CBSound *sound) { if (sound) { if (_autoSoundPanning) - Ret = sound->SetPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); + Ret = sound->setPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } @@ -1087,7 +1087,7 @@ HRESULT CBObject::updateOneSound(CBSound *sound) { HRESULT CBObject::resetSoundPan() { if (!_sFX) return S_OK; else { - return _sFX->SetPan(0.0f); + return _sFX->setPan(0.0f); } } diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index 477c44dba3..e6ba15ee3a 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -65,7 +65,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) { +HRESULT CBSound::setSound(const char *filename, TSoundType type, bool streamed) { if (_sound) { Game->_soundMgr->removeSound(_sound); _sound = NULL; @@ -73,13 +73,13 @@ HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) delete[] _soundFilename; _soundFilename = NULL; - _sound = Game->_soundMgr->addSound(Filename, Type, Streamed); + _sound = Game->_soundMgr->addSound(filename, type, streamed); if (_sound) { - _soundFilename = new char[strlen(Filename) + 1]; - strcpy(_soundFilename, Filename); + _soundFilename = new char[strlen(filename) + 1]; + strcpy(_soundFilename, filename); - _soundType = Type; - _soundStreamed = Streamed; + _soundType = type; + _soundStreamed = streamed; return S_OK; } else return E_FAIL; @@ -87,15 +87,15 @@ HRESULT CBSound::SetSound(const char *Filename, TSoundType Type, bool Streamed) ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetSoundSimple() { +HRESULT CBSound::setSoundSimple() { _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { - if (_soundPosition) _sound->SetPosition(_soundPosition); - _sound->SetLooping(_soundLooping); - _sound->SetPrivateVolume(_soundPrivateVolume); - _sound->SetLoopStart(_soundLoopStart); + if (_soundPosition) _sound->setPosition(_soundPosition); + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->Resume(); + if (_soundPlaying) return _sound->resume(); else return S_OK; } else return E_FAIL; } @@ -103,45 +103,45 @@ HRESULT CBSound::SetSoundSimple() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::GetLength() { - if (_sound) return _sound->GetLength(); +uint32 CBSound::getLength() { + if (_sound) return _sound->getLength(); else return 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Play(bool Looping) { +HRESULT CBSound::play(bool looping) { if (_sound) { _soundPaused = false; - return _sound->Play(Looping, _soundPosition); + return _sound->play(looping, _soundPosition); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Stop() { +HRESULT CBSound::stop() { if (_sound) { _soundPaused = false; - return _sound->Stop(); + return _sound->stop(); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Pause(bool FreezePaused) { +HRESULT CBSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; - if (FreezePaused) _sound->_freezePaused = true; - return _sound->Pause(); + if (freezePaused) _sound->_freezePaused = true; + return _sound->pause(); } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::Resume() { +HRESULT CBSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; - return _sound->Resume(); + return _sound->resume(); } else return E_FAIL; } @@ -149,10 +149,10 @@ HRESULT CBSound::Resume() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving && _sound) { - _soundPlaying = _sound->IsPlaying(); + _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) _soundPosition = _sound->GetPosition(); + if (_soundPlaying) _soundPosition = _sound->getPosition(); _soundLoopStart = _sound->_loopStart; _soundFreezePaused = _sound->_freezePaused; } @@ -180,83 +180,83 @@ HRESULT CBSound::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::IsPlaying() { - return _sound && _sound->IsPlaying(); +bool CBSound::isPlaying() { + return _sound && _sound->isPlaying(); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::IsPaused() { +bool CBSound::isPaused() { return _sound && _soundPaused; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPositionTime(uint32 Time) { +HRESULT CBSound::setPositionTime(uint32 time) { if (!_sound) return E_FAIL; - _soundPosition = Time; - HRESULT ret = _sound->SetPosition(_soundPosition); - if (_sound->IsPlaying()) _soundPosition = 0; + _soundPosition = time; + HRESULT ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) _soundPosition = 0; return ret; } ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::GetPositionTime() { +uint32 CBSound::getPositionTime() { if (!_sound) return 0; - if (!_sound->IsPlaying()) return 0; - else return _sound->GetPosition(); + if (!_sound->isPlaying()) return 0; + else return _sound->getPosition(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetVolume(int Volume) { +HRESULT CBSound::setVolume(int volume) { if (!_sound) return E_FAIL; - else return _sound->SetPrivateVolume(Volume); + else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPrivateVolume(int Volume) { +HRESULT CBSound::setPrivateVolume(int volume) { if (!_sound) return E_FAIL; - else return _sound->_privateVolume = Volume; + else return _sound->_privateVolume = volume; } ////////////////////////////////////////////////////////////////////////// -int CBSound::GetVolume() { +int CBSound::getVolume() { if (!_sound) return 0; else return _sound->_privateVolume; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetLoopStart(uint32 Pos) { +HRESULT CBSound::setLoopStart(uint32 pos) { if (!_sound) return E_FAIL; else { - _sound->SetLoopStart(Pos); + _sound->setLoopStart(pos); return S_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::SetPan(float Pan) { - if (_sound) return _sound->SetPan(Pan); +HRESULT CBSound::setPan(float pan) { + if (_sound) return _sound->setPan(pan); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { +HRESULT CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) return S_OK; - if (Type != _sFXType || Param1 != _sFXParam1 || Param2 != _sFXParam2 || Param3 != _sFXParam3 || Param4 != _sFXParam4) { - HRESULT Ret = _sound->ApplyFX(Type, Param1, Param2, Param3, Param4); + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + HRESULT Ret = _sound->applyFX(type, param1, param2, param3, param4); - _sFXType = Type; - _sFXParam1 = Param1; - _sFXParam2 = Param2; - _sFXParam3 = Param3; - _sFXParam4 = Param4; + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; return Ret; } diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h index a9d1a0b5af..4bc3f25c19 100644 --- a/engines/wintermute/Base/BSound.h +++ b/engines/wintermute/Base/BSound.h @@ -38,37 +38,37 @@ namespace WinterMute { class CBSound : public CBBase { public: - HRESULT SetPan(float Pan); + HRESULT setPan(float pan); int _soundPrivateVolume; - int GetVolume(); - HRESULT SetVolume(int Volume); - HRESULT SetPrivateVolume(int Volume); - HRESULT SetLoopStart(uint32 Pos); - uint32 GetPositionTime(); - HRESULT SetPositionTime(uint32 Time); + int getVolume(); + HRESULT setVolume(int volume); + HRESULT setPrivateVolume(int volume); + HRESULT setLoopStart(uint32 pos); + uint32 getPositionTime(); + HRESULT setPositionTime(uint32 time); bool _soundPaused; bool _soundFreezePaused; - bool IsPlaying(); - bool IsPaused(); + bool isPlaying(); + bool isPaused(); bool _soundPlaying; bool _soundLooping; uint32 _soundLoopStart; uint32 _soundPosition; DECLARE_PERSISTENT(CBSound, CBBase) - HRESULT Resume(); - HRESULT Pause(bool FreezePaused = false); - HRESULT Stop(); - HRESULT Play(bool Looping = false); - uint32 GetLength(); + HRESULT resume(); + HRESULT pause(bool freezePaused = false); + HRESULT stop(); + HRESULT play(bool looping = false); + uint32 getLength(); bool _soundStreamed; TSoundType _soundType; char *_soundFilename; - HRESULT SetSoundSimple(); - HRESULT SetSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + HRESULT setSoundSimple(); + HRESULT setSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); CBSound(CBGame *inGame); virtual ~CBSound(); - HRESULT ApplyFX(TSFXType Type = SFX_NONE, float Param1 = 0, float Param2 = 0, float Param3 = 0, float Param4 = 0); + HRESULT ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); private: TSFXType _sFXType; diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 35471bd4d9..b24bdcfb19 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -69,7 +69,7 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::~CBSoundBuffer() { - Stop(); + stop(); if (_handle) { delete _handle; @@ -87,13 +87,13 @@ CBSoundBuffer::~CBSoundBuffer() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { +void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { _streamed = Streamed; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { +HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload); #if 0 if (_stream) { @@ -187,7 +187,7 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Play(bool looping, uint32 startSample) { +HRESULT CBSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } @@ -203,7 +203,7 @@ HRESULT CBSoundBuffer::Play(bool looping, uint32 startSample) { } ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetLooping(bool looping) { +void CBSoundBuffer::setLooping(bool looping) { warning("BSoundBuffer::SetLooping(%d) - not implemented yet", looping); #if 0 _looping = looping; @@ -215,7 +215,7 @@ void CBSoundBuffer::SetLooping(bool looping) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Resume() { +HRESULT CBSoundBuffer::resume() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); } @@ -224,7 +224,7 @@ HRESULT CBSoundBuffer::Resume() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Stop() { +HRESULT CBSoundBuffer::stop() { if (_stream && _handle) { g_system->getMixer()->stopHandle(*_handle); } @@ -233,7 +233,7 @@ HRESULT CBSoundBuffer::Stop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Pause() { +HRESULT CBSoundBuffer::pause() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, true); } @@ -242,7 +242,7 @@ HRESULT CBSoundBuffer::Pause() { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::GetLength() { +uint32 CBSoundBuffer::getLength() { if (_stream) { uint32 len = _stream->getLength().msecs(); return len * 1000; @@ -252,13 +252,13 @@ uint32 CBSoundBuffer::GetLength() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::SetType(TSoundType Type) { +void CBSoundBuffer::setType(TSoundType Type) { _type = Type; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetVolume(int Volume) { +HRESULT CBSoundBuffer::setVolume(int Volume) { if (_stream && _handle) { byte vol = (byte)(Volume / 100.f * Audio::Mixer::kMaxChannelVolume); g_system->getMixer()->setChannelVolume(*_handle, vol); @@ -268,7 +268,7 @@ HRESULT CBSoundBuffer::SetVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { +HRESULT CBSoundBuffer::setPrivateVolume(int Volume) { #if 0 _privateVolume = Volume; @@ -284,12 +284,12 @@ HRESULT CBSoundBuffer::SetPrivateVolume(int Volume) { break; } #endif - return SetVolume(Volume); + return setVolume(Volume); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::IsPlaying() { +bool CBSoundBuffer::isPlaying() { if (_stream && _handle) { return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); } else { @@ -299,7 +299,7 @@ bool CBSoundBuffer::IsPlaying() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::GetPosition() { +uint32 CBSoundBuffer::getPosition() { if (_stream && _handle) { uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); return pos; @@ -309,7 +309,7 @@ uint32 CBSoundBuffer::GetPosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { +HRESULT CBSoundBuffer::setPosition(uint32 Pos) { warning("CBSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { @@ -321,7 +321,7 @@ HRESULT CBSoundBuffer::SetPosition(uint32 Pos) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetLoopStart(uint32 Pos) { +HRESULT CBSoundBuffer::setLoopStart(uint32 Pos) { _loopStart = Pos; #if 0 if (_stream) { @@ -348,7 +348,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::SetPan(float pan) { +HRESULT CBSoundBuffer::setPan(float pan) { if (_stream) { g_system->getMixer()->setChannelBalance(*_handle, pan * 127); } @@ -356,7 +356,7 @@ HRESULT CBSoundBuffer::SetPan(float pan) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { +HRESULT CBSoundBuffer::applyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { warning("CBSoundBuffer::ApplyFX - not implemented yet"); #if 0 switch (Type) { diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 9fa9dec1cf..1e59ef0971 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -48,32 +48,32 @@ public: virtual ~CBSoundBuffer(); - HRESULT Pause(); - HRESULT Play(bool Looping = false, uint32 StartSample = 0); - HRESULT Resume(); - HRESULT Stop(); - bool IsPlaying(); + HRESULT pause(); + HRESULT play(bool Looping = false, uint32 StartSample = 0); + HRESULT resume(); + HRESULT stop(); + bool isPlaying(); - void SetLooping(bool looping); + void setLooping(bool looping); - uint32 GetPosition(); - HRESULT SetPosition(uint32 Pos); - uint32 GetLength(); + uint32 getPosition(); + HRESULT setPosition(uint32 Pos); + uint32 getLength(); - HRESULT SetLoopStart(uint32 Pos); - uint32 GetLoopStart() const { + HRESULT setLoopStart(uint32 Pos); + uint32 getLoopStart() const { return _loopStart; } - HRESULT SetPan(float Pan); - HRESULT SetPrivateVolume(int Volume); - HRESULT SetVolume(int Volume); + HRESULT setPan(float Pan); + HRESULT setPrivateVolume(int Volume); + HRESULT setVolume(int Volume); - void SetType(TSoundType Type); + void setType(TSoundType Type); - HRESULT LoadFromFile(const char *Filename, bool ForceReload = false); - void SetStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); - HRESULT ApplyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); + HRESULT loadFromFile(const char *Filename, bool ForceReload = false); + void setStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); + HRESULT applyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); //HSTREAM _stream; //HSYNC _sync; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index dc9f3e9011..e931d95f2d 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -148,11 +148,11 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool sound = new CBSoundBuffer(Game); if (!sound) return NULL; - sound->SetStreaming(Streamed); - sound->SetType(Type); + sound->setStreaming(Streamed); + sound->setType(Type); - HRESULT res = sound->LoadFromFile(Filename); + HRESULT res = sound->loadFromFile(Filename); if (FAILED(res)) { Game->LOG(res, "Error loading sound '%s'", Filename); delete sound; @@ -162,13 +162,13 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool // set volume appropriately switch (Type) { case SOUND_SFX: - sound->SetVolume(_volumeSFX); + sound->setVolume(_volumeSFX); break; case SOUND_SPEECH: - sound->SetVolume(_volumeSpeech); + sound->setVolume(_volumeSpeech); break; case SOUND_MUSIC: - sound->SetVolume(_volumeMusic); + sound->setVolume(_volumeMusic); break; } @@ -187,13 +187,13 @@ HRESULT CBSoundMgr::addSound(CBSoundBuffer *Sound, TSoundType Type) { // set volume appropriately switch (Type) { case SOUND_SFX: - Sound->SetVolume(_volumeSFX); + Sound->setVolume(_volumeSFX); break; case SOUND_SPEECH: - Sound->SetVolume(_volumeSpeech); + Sound->setVolume(_volumeSpeech); break; case SOUND_MUSIC: - Sound->SetVolume(_volumeMusic); + Sound->setVolume(_volumeMusic); break; } @@ -235,7 +235,7 @@ HRESULT CBSoundMgr::setVolume(TSoundType Type, int Volume) { } for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume); + if (_sounds[i]->_type == Type) _sounds[i]->setVolume(Volume); } return S_OK; @@ -291,8 +291,8 @@ byte CBSoundMgr::getMasterVolumePercent() { HRESULT CBSoundMgr::pauseAll(bool IncludingMusic) { for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { - _sounds[i]->Pause(); + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { + _sounds[i]->pause(); _sounds[i]->_freezePaused = true; } } @@ -306,7 +306,7 @@ HRESULT CBSoundMgr::resumeAll() { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->_freezePaused) { - _sounds[i]->Resume(); + _sounds[i]->resume(); _sounds[i]->_freezePaused = false; } } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index e7f9df194d..5b22c36db2 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -746,7 +746,7 @@ const char *CBSprite::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSprite::KillAllSounds() { for (int i = 0; i < _frames.GetSize(); i++) { - if (_frames[i]->_sound) _frames[i]->_sound->Stop(); + if (_frames[i]->_sound) _frames[i]->_sound->stop(); } return S_OK; } -- cgit v1.2.3 From 95983fa2eabd2c5f507f095d89efb6bbda0d3701 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:00:10 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BSubFrame, BSurfaceStorage and BTransitionMgr --- engines/wintermute/Ad/AdGame.cpp | 8 ++++---- engines/wintermute/Ad/AdScene.cpp | 10 ++++----- engines/wintermute/Base/BFontBitmap.cpp | 4 ++-- engines/wintermute/Base/BFrame.cpp | 18 ++++++++-------- engines/wintermute/Base/BGame.cpp | 10 ++++----- engines/wintermute/Base/BSprite.cpp | 8 ++++---- engines/wintermute/Base/BSubFrame.cpp | 32 ++++++++++++++--------------- engines/wintermute/Base/BSubFrame.h | 15 +++++++------- engines/wintermute/Base/BSurfaceStorage.cpp | 20 +++++++++--------- engines/wintermute/Base/BSurfaceStorage.h | 12 +++++------ engines/wintermute/Base/BTransitionMgr.cpp | 8 ++++---- engines/wintermute/Base/BTransitionMgr.h | 2 +- engines/wintermute/Base/BViewport.cpp | 6 +++--- engines/wintermute/Base/BViewport.h | 6 +++--- engines/wintermute/UI/UITiledImage.cpp | 2 +- engines/wintermute/UI/UIWindow.cpp | 2 +- 16 files changed, 82 insertions(+), 81 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 2d1a24c600..5e1af7fc77 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -280,7 +280,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { _scene->LoadState(); } - if (FadeIn) Game->_transMgr->Start(TRANSITION_FADE_IN); + if (FadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); return ret; } else return E_FAIL; } @@ -330,7 +330,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); ScheduleChangeScene(Filename, TransIn); - if (TransOut) _transMgr->Start(TRANSITION_FADE_OUT, true); + if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true); Stack->PushNULL(); @@ -785,7 +785,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (Height <= 0) Height = _renderer->_height; if (!_sceneViewport) _sceneViewport = new CBViewport(Game); - if (_sceneViewport) _sceneViewport->SetRect(X, Y, X + Width, Y + Height); + if (_sceneViewport) _sceneViewport->setRect(X, Y, X + Width, Y + Height); Stack->PushBool(true); @@ -1224,7 +1224,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { RECT rc; parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) _sceneViewport = new CBViewport(Game); - if (_sceneViewport) _sceneViewport->SetRect(rc.left, rc.top, rc.right, rc.bottom); + if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); } break; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 2feb042df6..206bf67aa3 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -824,7 +824,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { RECT rc; parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) _viewport->SetRect(rc.left, rc.top, rc.right, rc.bottom, true); + if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); } case TOKEN_PERSISTENT_STATE: @@ -1579,7 +1579,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (Height <= 0) Height = Game->_renderer->_height; if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) _viewport->SetRect(X, Y, X + Width, Y + Height); + if (_viewport) _viewport->setRect(X, Y, X + Width, Y + Height); Stack->PushBool(true); @@ -1996,7 +1996,7 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { // viewport if (_viewport) { - RECT *rc = _viewport->GetRect(); + RECT *rc = _viewport->getRect(); Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } @@ -2378,10 +2378,10 @@ HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { CAdGame *AdGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { - if (Width) *Width = _viewport->GetWidth(); + if (Width) *Width = _viewport->getWidth(); if (Height) *Height = _viewport->getHeight(); } else if (AdGame->_sceneViewport && !Game->_editorMode) { - if (Width) *Width = AdGame->_sceneViewport->GetWidth(); + if (Width) *Width = AdGame->_sceneViewport->getWidth(); if (Height) *Height = AdGame->_sceneViewport->getHeight(); } else { if (Width) *Width = Game->_renderer->_width; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 8e7a8c20b3..8650a077bd 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -412,8 +412,8 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { if (surface_file != NULL && !_sprite) { _subframe = new CBSubFrame(Game); - if (custo_trans) _subframe->SetSurface(surface_file, false, r, g, b); - else _subframe->SetSurface(surface_file); + if (custo_trans) _subframe->setSurface(surface_file, false, r, g, b); + else _subframe->setSurface(surface_file); } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 95b81feb51..8e05d865fd 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -80,7 +80,7 @@ HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY HRESULT res; for (int i = 0; i < _subframes.GetSize(); i++) { - res = _subframes[i]->Draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); + res = _subframes[i]->draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); if (FAILED(res)) return res; } return S_OK; @@ -239,7 +239,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_SUBFRAME: { CBSubFrame *subframe = new CBSubFrame(Game); - if (!subframe || FAILED(subframe->LoadBuffer((byte *)params, LifeTime, KeepLoaded))) { + if (!subframe || FAILED(subframe->loadBuffer((byte *)params, LifeTime, KeepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; } else _subframes.Add(subframe); @@ -293,8 +293,8 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { CBSubFrame *sub = new CBSubFrame(Game); if (surface_file != NULL) { - if (custo_trans) sub->SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else sub->SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + if (custo_trans) sub->setSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); if (!sub->_surface) { delete sub; @@ -306,7 +306,7 @@ HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { if (custo_trans) sub->_transparent = DRGBA(r, g, b, 0xFF); } - if (CBPlatform::IsRectEmpty(&rect)) sub->SetDefaultRect(); + if (CBPlatform::IsRectEmpty(&rect)) sub->setDefaultRect(); else sub->_rect = rect; sub->_hotspotX = HotspotX; @@ -333,7 +333,7 @@ bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca RECT SubRect; for (int i = 0; i < _subframes.GetSize(); i++) { - _subframes[i]->GetBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); + _subframes[i]->getBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); CBPlatform::UnionRect(Rect, Rect, &SubRect); } return true; @@ -484,8 +484,8 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CBSubFrame *Sub = new CBSubFrame(Game); if (Filename != NULL) { - Sub->SetSurface(Filename); - Sub->SetDefaultRect(); + Sub->setSurface(Filename); + Sub->setDefaultRect(); } _subframes.Add(Sub); @@ -507,7 +507,7 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This CBSubFrame *Sub = new CBSubFrame(Game); if (Filename != NULL) { - Sub->SetSurface(Filename); + Sub->setSurface(Filename); } if (Index >= _subframes.GetSize()) _subframes.Add(Sub); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 08f0ddecfa..1fdf555731 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -614,7 +614,7 @@ HRESULT CBGame::InitLoop() { _soundMgr->initLoop(); UpdateMusicCrossfade(); - _surfaceStorage->InitLoop(); + _surfaceStorage->initLoop(); _fontStorage->InitLoop(); @@ -3363,7 +3363,7 @@ void CBGame::AfterLoadRegion(void *Region, void *Data) { ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { - ((CBSubFrame *)Subframe)->SetSurfaceSimple(); + ((CBSubFrame *)Subframe)->setSurfaceSimple(); } @@ -3983,7 +3983,7 @@ HRESULT CBGame::PushViewport(CBViewport *Viewport) { if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); else _viewportStack[_viewportSP] = Viewport; - _renderer->SetViewport(Viewport->GetRect()); + _renderer->SetViewport(Viewport->getRect()); return S_OK; } @@ -3994,7 +3994,7 @@ HRESULT CBGame::PopViewport() { _viewportSP--; if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); - if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->GetRect()); + if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->getRect()); else _renderer->SetViewport(_renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, @@ -4009,7 +4009,7 @@ HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { if (Rect == NULL) return E_FAIL; else { if (_viewportSP >= 0) { - CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->GetRect()); + CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->getRect()); if (Custom) *Custom = true; } else { CBPlatform::SetRect(Rect, _renderer->_drawOffsetX, diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 5b22c36db2..f848ae456f 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -139,7 +139,7 @@ HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, "bmp") || StringUtil::CompareNoCase(ext, "tga") || StringUtil::CompareNoCase(ext, "png") || StringUtil::CompareNoCase(ext, "jpg")) { CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); - subframe->SetSurface(Filename, true, 0, 0, 0, LifeTime, true); + subframe->setSurface(Filename, true, 0, 0, 0, LifeTime, true); if (subframe->_surface == NULL) { Game->LOG(0, "Error loading simple sprite '%s'", Filename); ret = E_FAIL; @@ -569,8 +569,8 @@ HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CBFrame *Frame = new CBFrame(Game); if (Filename != NULL) { CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->SetSurface(Filename))) { - Sub->SetDefaultRect(); + if (SUCCEEDED(Sub->setSurface(Filename))) { + Sub->setDefaultRect(); Frame->_subframes.Add(Sub); } else delete Sub; } @@ -595,7 +595,7 @@ HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CBFrame *Frame = new CBFrame(Game); if (Filename != NULL) { CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->SetSurface(Filename))) Frame->_subframes.Add(Sub); + if (SUCCEEDED(Sub->setSurface(Filename))) Frame->_subframes.Add(Sub); else delete Sub; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 2ff51f289a..127c4a7bba 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -68,7 +68,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// CBSubFrame::~CBSubFrame() { - if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + if (_surface) Game->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; } @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -182,8 +182,8 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { } if (surface_file != NULL) { - if (custo_trans) SetSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else SetSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + if (custo_trans) setSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); + else setSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); } _alpha = DRGBA(ar, ag, ab, alpha); @@ -196,7 +196,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { return E_FAIL; } */ - if (CBPlatform::IsRectEmpty(&rect)) SetDefaultRect(); + if (CBPlatform::IsRectEmpty(&rect)) setDefaultRect(); else _rect = rect; return S_OK; @@ -204,7 +204,7 @@ HRESULT CBSubFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +HRESULT CBSubFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { if (!_surface) return S_OK; if (Register != NULL && !_decoration) { @@ -233,7 +233,7 @@ HRESULT CBSubFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zo ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { +bool CBSubFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { if (!Rect) return false; float RatioX = ScaleX / 100.0f; @@ -302,7 +302,7 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { ////////////////////////////////////////////////////////////////////////// -void CBSubFrame::SetDefaultRect() { +void CBSubFrame::setDefaultRect() { if (_surface) { CBPlatform::SetRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); } else CBPlatform::SetRectEmpty(&_rect); @@ -363,14 +363,14 @@ HRESULT CBSubFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *T CScValue *Val = Stack->Pop(); if (Val->IsNULL()) { - if (_surface) Game->_surfaceStorage->RemoveSurface(_surface); + if (_surface) Game->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; Stack->PushBool(true); } else { const char *Filename = Val->GetString(); - if (SUCCEEDED(SetSurface(Filename))) { - SetDefaultRect(); + if (SUCCEEDED(setSurface(Filename))) { + setDefaultRect(); Stack->PushBool(true); } else Stack->PushBool(false); } @@ -549,16 +549,16 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SetSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::setSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { if (_surface) { - Game->_surfaceStorage->RemoveSurface(_surface); + Game->_surfaceStorage->removeSurface(_surface); _surface = NULL; } delete[] _surfaceFilename; _surfaceFilename = NULL; - _surface = Game->_surfaceStorage->AddSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + _surface = Game->_surfaceStorage->addSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); if (_surface) { _surfaceFilename = new char[strlen(Filename) + 1]; strcpy(_surfaceFilename, Filename); @@ -576,12 +576,12 @@ HRESULT CBSubFrame::SetSurface(const char *Filename, bool default_ck, byte ck_re ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::SetSurfaceSimple() { +HRESULT CBSubFrame::setSurfaceSimple() { if (!_surfaceFilename) { _surface = NULL; return S_OK; } - _surface = Game->_surfaceStorage->AddSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + _surface = Game->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); if (_surface) return S_OK; else return E_FAIL; } diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 4226fc7a2d..67f3201fa1 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -41,18 +41,19 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - HRESULT SetSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); - HRESULT SetSurfaceSimple(); + HRESULT setSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT setSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) - void SetDefaultRect(); + void setDefaultRect(); uint32 _transparent; - HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete = true); + HRESULT saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + HRESULT saveAsText(CBDynBuffer *buffer, int indent, bool complete); bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); - HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); int _hotspotX; int _hotspotY; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 337ad50bba..237c9d760d 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -63,10 +63,10 @@ HRESULT CBSurfaceStorage::cleanup(bool Warn) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::InitLoop() { +HRESULT CBSurfaceStorage::initLoop() { if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { _lastCleanupTime = Game->_liveTimer; - SortSurfaces(); + sortSurfaces(); for (int i = 0; i < _surfaces.GetSize(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; @@ -81,7 +81,7 @@ HRESULT CBSurfaceStorage::InitLoop() { ////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { +HRESULT CBSurfaceStorage::removeSurface(CBSurface *surface) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; @@ -97,7 +97,7 @@ HRESULT CBSurfaceStorage::RemoveSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +CBSurface *CBSurfaceStorage::addSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { _surfaces[i]->_referenceCount++; @@ -109,9 +109,9 @@ CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, b if (!File) { if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); if (Game->_dEBUG_DebugMode) - return AddSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + return addSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else - return AddSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + return addSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); } else Game->_fileManager->CloseFile(File); @@ -133,7 +133,7 @@ CBSurface *CBSurfaceStorage::AddSurface(const char *Filename, bool default_ck, b ////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::RestoreAll() { +HRESULT CBSurfaceStorage::restoreAll() { HRESULT ret; for (int i = 0; i < _surfaces.GetSize(); i++) { ret = _surfaces[i]->restore(); @@ -163,14 +163,14 @@ HRESULT CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::SortSurfaces() { - qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), SurfaceSortCB); +HRESULT CBSurfaceStorage::sortSurfaces() { + qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), surfaceSortCB); return S_OK; } ////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::SurfaceSortCB(const void *arg1, const void *arg2) { +int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { CBSurface *s1 = *((CBSurface **)arg1); CBSurface *s2 = *((CBSurface **)arg2); diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index 62c9796bfc..ac624e70d1 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -38,15 +38,15 @@ class CBSurface; class CBSurfaceStorage : public CBBase { public: uint32 _lastCleanupTime; - HRESULT InitLoop(); - HRESULT SortSurfaces(); - static int SurfaceSortCB(const void *arg1, const void *arg2); + HRESULT initLoop(); + HRESULT sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); HRESULT cleanup(bool Warn = false); //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - HRESULT RestoreAll(); - CBSurface *AddSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); - HRESULT RemoveSurface(CBSurface *surface); + HRESULT restoreAll(); + CBSurface *addSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool keepLoaded = false); + HRESULT removeSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index c44a5960a1..f61cd9d518 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -58,21 +58,21 @@ bool CBTransitionMgr::isReady() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::Start(TTransitionType Type, bool NonInteractive) { +HRESULT CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { if (_state != TRANS_MGR_READY) return S_OK; - if (Type == TRANSITION_NONE || Type >= NUM_TRANSITION_TYPES) { + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { _state = TRANS_MGR_READY; return S_OK; } - if (NonInteractive) { + if (nonInteractive) { _preserveInteractive = true; _origInteractive = Game->_interactive; Game->_interactive = false; } else _preserveInteractive; - _type = Type; + _type = type; _state = TRANS_MGR_RUNNING; _started = false; diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h index 41ec077822..402ee32310 100644 --- a/engines/wintermute/Base/BTransitionMgr.h +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -40,7 +40,7 @@ public: bool _origInteractive; bool _preserveInteractive; HRESULT update(); - HRESULT Start(TTransitionType Type, bool NonInteractive = false); + HRESULT start(TTransitionType Type, bool NonInteractive = false); bool isReady(); TTransMgrState _state; CBTransitionMgr(CBGame *inGame); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index e6c372b4e6..5ac5e375d9 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -63,7 +63,7 @@ HRESULT CBViewport::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoCheck) { +HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool NoCheck) { if (!NoCheck) { left = MAX(left, 0); top = MAX(top, 0); @@ -79,13 +79,13 @@ HRESULT CBViewport::SetRect(int left, int top, int right, int bottom, bool NoChe ////////////////////////////////////////////////////////////////////////// -RECT *CBViewport::GetRect() { +RECT *CBViewport::getRect() { return &_rect; } ////////////////////////////////////////////////////////////////////////// -int CBViewport::GetWidth() { +int CBViewport::getWidth() { return _rect.right - _rect.left; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 65d82de45b..6be57b712d 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -37,9 +37,9 @@ class CBObject; class CBViewport : public CBBase { public: int getHeight(); - int GetWidth(); - RECT *GetRect(); - HRESULT SetRect(int left, int top, int right, int bottom, bool NoCheck = false); + int getWidth(); + RECT *getRect(); + HRESULT setRect(int left, int top, int right, int bottom, bool NoCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; int _offsetX; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 54a85a0578..61ad44e8d8 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -201,7 +201,7 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: delete _image; _image = new CBSubFrame(Game); - if (!_image || FAILED(_image->SetSurface((char *)params))) { + if (!_image || FAILED(_image->setSurface((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 1998b380cd..38c950c337 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -160,7 +160,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (_clipContents) { if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) { - _viewport->SetRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); + _viewport->setRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); Game->PushViewport(_viewport); PopViewport = true; } -- cgit v1.2.3 From caa5ee1d89de77f535f285904eb7c576d0397572 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:07:12 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BFileManager --- engines/wintermute/Ad/AdActor.cpp | 4 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 12 ++-- engines/wintermute/Ad/AdInventoryBox.cpp | 2 +- engines/wintermute/Ad/AdItem.cpp | 2 +- engines/wintermute/Ad/AdLayer.cpp | 2 +- engines/wintermute/Ad/AdRegion.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 2 +- engines/wintermute/Ad/AdScaleLevel.cpp | 2 +- engines/wintermute/Ad/AdScene.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 4 +- engines/wintermute/Ad/AdSpriteSet.cpp | 2 +- engines/wintermute/Ad/AdTalkDef.cpp | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 2 +- engines/wintermute/Base/BFileManager.cpp | 84 ++++++++++++------------ engines/wintermute/Base/BFileManager.h | 40 +++++------ engines/wintermute/Base/BFont.cpp | 4 +- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 10 +-- engines/wintermute/Base/BGame.cpp | 12 ++-- engines/wintermute/Base/BImage.cpp | 4 +- engines/wintermute/Base/BPackage.cpp | 6 +- engines/wintermute/Base/BPersistMgr.cpp | 4 +- engines/wintermute/Base/BRegion.cpp | 2 +- engines/wintermute/Base/BSoundBuffer.cpp | 10 +-- engines/wintermute/Base/BSoundMgr.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 6 +- engines/wintermute/Base/BStringTable.cpp | 2 +- engines/wintermute/Base/BSurfaceStorage.cpp | 4 +- engines/wintermute/Base/PartEmitter.cpp | 4 +- engines/wintermute/Base/file/BPkgFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 6 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 +- engines/wintermute/UI/UIButton.cpp | 2 +- engines/wintermute/UI/UIEdit.cpp | 2 +- engines/wintermute/UI/UIEntity.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 2 +- engines/wintermute/UI/UITiledImage.cpp | 2 +- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/video/VidPlayer.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 4 +- 42 files changed, 136 insertions(+), 136 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index b2686245a6..f560bf9049 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -124,7 +124,7 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -1268,7 +1268,7 @@ HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { TOKEN_TABLE_END - byte *FileBuffer = Game->_fileManager->ReadWholeFile(AnimsFilename); + byte *FileBuffer = Game->_fileManager->readWholeFile(AnimsFilename); if (FileBuffer == NULL) { Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 64a9531678..8b1cd0853d 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -85,7 +85,7 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 5e1af7fc77..2467a47e9f 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1115,7 +1115,7 @@ HRESULT CAdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadFile(const char *Filename) { - byte *Buffer = _fileManager->ReadWholeFile(Filename); + byte *Buffer = _fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -1385,7 +1385,7 @@ HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byt ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadItemsFile(const char *Filename, bool Merge) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); return E_FAIL; @@ -1919,16 +1919,16 @@ char *CAdGame::FindSpeechFile(char *StringID) { for (int i = 0; i < _speechDirs.GetSize(); i++) { sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); - Common::SeekableReadStream *File = _fileManager->OpenFile(Ret); + Common::SeekableReadStream *File = _fileManager->openFile(Ret); if (File) { - _fileManager->CloseFile(File); + _fileManager->closeFile(File); return Ret; } sprintf(Ret, "%s%s.wav", _speechDirs[i], StringID); - File = _fileManager->OpenFile(Ret); + File = _fileManager->openFile(Ret); if (File) { - _fileManager->CloseFile(File); + _fileManager->closeFile(File); return Ret; } } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index ee3e9dedfe..55214f51ce 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -155,7 +155,7 @@ HRESULT CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdInventoryBox::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 2885623454..31bc3c7644 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -85,7 +85,7 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdItem::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 45c6678188..c5d24898cd 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -62,7 +62,7 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdLayer::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index c8b65a6691..df124e7692 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -55,7 +55,7 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRegion::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 42f1038ffc..d62324e4b1 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -188,7 +188,7 @@ HRESULT CAdResponseBox::CreateButtons() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index b1256c9f27..4f20973958 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -54,7 +54,7 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRotLevel::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 8e03781382..68cccac35a 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -52,7 +52,7 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScaleLevel::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 206bf67aa3..098ea3829d 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -504,7 +504,7 @@ HRESULT CAdScene::InitLoop() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index feaeec714d..d7bf67d7af 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -251,9 +251,9 @@ HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(talkDefFileName.c_str()); + Common::SeekableReadStream *file = Game->_fileManager->openFile(talkDefFileName.c_str()); if (file) { - Game->_fileManager->CloseFile(file); + Game->_fileManager->closeFile(file); } else return S_OK; // no talk def file found diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 3cd0b7aff0..62787b6c68 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -59,7 +59,7 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSpriteSet::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 41ea23ff38..8aa3d3523f 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -70,7 +70,7 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index b8ee1be55c..dc0059cf40 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -65,7 +65,7 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 448c1d684f..5ad65e8fe1 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -63,8 +63,8 @@ namespace WinterMute { CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { _basePath = NULL; - InitPaths(); - RegisterPackages(); + initPaths(); + registerPackages(); } @@ -118,11 +118,11 @@ HRESULT CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::ReadWholeFile(const Common::String &Filename, uint32 *Size, bool MustExist) { +byte *CBFileManager::readWholeFile(const Common::String &Filename, uint32 *Size, bool MustExist) { byte *buffer = NULL; - Common::SeekableReadStream *File = OpenFile(Filename); + Common::SeekableReadStream *File = openFile(Filename); if (!File) { if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename.c_str()); return NULL; @@ -140,20 +140,20 @@ byte *CBFileManager::ReadWholeFile(const Common::String &Filename, uint32 *Size, buffer = new byte[File->size() + 1]; if (buffer == NULL) { Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename.c_str(), File->size() + 1); - CloseFile(File); + closeFile(File); return NULL; } if (File->read(buffer, File->size()) != File->size()) { Game->LOG(0, "Error reading file '%s'", Filename.c_str()); - CloseFile(File); + closeFile(File); delete [] buffer; return NULL; }; buffer[File->size()] = '\0'; if (Size != NULL) *Size = File->size(); - CloseFile(File); + closeFile(File); return buffer; } @@ -165,7 +165,7 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +HRESULT CBFileManager::saveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); @@ -228,7 +228,7 @@ HRESULT CBFileManager::SaveFile(const Common::String &Filename, byte *Buffer, ui ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { +HRESULT CBFileManager::requestCD(int CD, char *PackageFile, char *Filename) { // unmount all non-local packages for (int i = 0; i < _packages.GetSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); @@ -240,7 +240,7 @@ HRESULT CBFileManager::RequestCD(int CD, char *PackageFile, char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::AddPath(TPathType Type, const Common::String &Path) { +HRESULT CBFileManager::addPath(TPathType Type, const Common::String &Path) { if (Path.c_str() == NULL || strlen(Path.c_str()) < 1) return E_FAIL; bool slashed = (Path[Path.size() - 1] == '\\' || Path[Path.size() - 1] == '/'); @@ -265,7 +265,7 @@ HRESULT CBFileManager::AddPath(TPathType Type, const Common::String &Path) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::ReloadPaths() { +HRESULT CBFileManager::reloadPaths() { // delete registered paths for (int i = 0; i < _singlePaths.GetSize(); i++) delete [] _singlePaths[i]; @@ -275,14 +275,14 @@ HRESULT CBFileManager::ReloadPaths() { delete [] _packagePaths[i]; _packagePaths.RemoveAll(); - return InitPaths(); + return initPaths(); } #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::InitPaths() { - RestoreCurrentDir(); +HRESULT CBFileManager::initPaths() { + restoreCurrentDir(); AnsiString pathList; int numPaths; @@ -294,16 +294,16 @@ HRESULT CBFileManager::InitPaths() { for (int i = 0; i < numPaths; i++) { char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - AddPath(PATH_SINGLE, path); + addPath(PATH_SINGLE, path); } delete[] path; path = NULL; } - AddPath(PATH_SINGLE, ".\\"); + addPath(PATH_SINGLE, ".\\"); // package files paths - AddPath(PATH_PACKAGE, "./"); + addPath(PATH_PACKAGE, "./"); /*#ifdef __APPLE__ // search .app path and Resources dir in the bundle @@ -338,20 +338,20 @@ HRESULT CBFileManager::InitPaths() { for (int i = 0; i < numPaths; i++) { char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - AddPath(PATH_PACKAGE, path); + addPath(PATH_PACKAGE, path); } delete[] path; path = NULL; } - AddPath(PATH_PACKAGE, "data"); + addPath(PATH_PACKAGE, "data"); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackages() { - RestoreCurrentDir(); +HRESULT CBFileManager::registerPackages() { + restoreCurrentDir(); Game->LOG(0, "Scanning packages..."); warning("Scanning packages"); @@ -360,7 +360,7 @@ HRESULT CBFileManager::RegisterPackages() { SearchMan.listMatchingMembers(files, "*.dcp"); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - RegisterPackage((*it)->getName().c_str()); + registerPackage((*it)->getName().c_str()); } #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); @@ -398,7 +398,7 @@ HRESULT CBFileManager::RegisterPackages() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackage(const Common::String &Filename , bool SearchSignature) { +HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool SearchSignature) { // FILE *f = fopen(Filename, "rb"); Common::File *package = new Common::File(); package->open(Filename); @@ -412,7 +412,7 @@ HRESULT CBFileManager::RegisterPackage(const Common::String &Filename , bool Sea if (SearchSignature) { uint32 Offset; - if (!FindPackageSignature(package, &Offset)) { + if (!findPackageSignature(package, &Offset)) { delete package; return S_OK; } else { @@ -524,7 +524,7 @@ HRESULT CBFileManager::RegisterPackage(const Common::String &Filename , bool Sea return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool SearchSignature) { +HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool SearchSignature) { // TODO error("Implement RegisterPackage, this is the old one"); #if 0 @@ -657,7 +657,7 @@ HRESULT CBFileManager::RegisterPackage(const char *Path, const char *Name, bool } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { +bool CBFileManager::isValidPackage(const AnsiString &fileName) const { AnsiString plainName = PathUtil::GetFileNameWithoutExtension(fileName); // check for device-type specific packages @@ -668,7 +668,7 @@ bool CBFileManager::IsValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenPackage(const Common::String &Name) { +Common::File *CBFileManager::openPackage(const Common::String &Name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -696,8 +696,8 @@ Common::File *CBFileManager::OpenPackage(const Common::String &Name) { ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::OpenSingleFile(const Common::String &Name) { - RestoreCurrentDir(); +Common::File *CBFileManager::openSingleFile(const Common::String &Name) { + restoreCurrentDir(); Common::File *ret = NULL; char Filename[MAX_PATH]; @@ -721,8 +721,8 @@ Common::File *CBFileManager::OpenSingleFile(const Common::String &Name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::GetFullPath(const Common::String &filename, char *Fullname) { - RestoreCurrentDir(); +bool CBFileManager::getFullPath(const Common::String &filename, char *Fullname) { + restoreCurrentDir(); Common::File f; bool found = false; @@ -751,7 +751,7 @@ bool CBFileManager::GetFullPath(const Common::String &filename, char *Fullname) ////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::GetPackageEntry(const Common::String &Filename) { +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &Filename) { char *upc_name = new char[strlen(Filename.c_str()) + 1]; strcpy(upc_name, Filename.c_str()); CBPlatform::strupr(upc_name); @@ -767,7 +767,7 @@ CBFileEntry *CBFileManager::GetPackageEntry(const Common::String &Filename) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::OpenFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; //Game->LOG(0, "open file: %s", Filename); /*#ifdef __WIN32__ @@ -780,14 +780,14 @@ Common::SeekableReadStream *CBFileManager::OpenFile(const Common::String &filena } #endif*/ - Common::SeekableReadStream *File = OpenFileRaw(filename); + Common::SeekableReadStream *File = openFileRaw(filename); if (File && keepTrackOf) _openFiles.Add(File); return File; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::CloseFile(Common::SeekableReadStream *File) { +HRESULT CBFileManager::closeFile(Common::SeekableReadStream *File) { for (int i = 0; i < _openFiles.GetSize(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; @@ -800,8 +800,8 @@ HRESULT CBFileManager::CloseFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::OpenFileRaw(const Common::String &Filename) { - RestoreCurrentDir(); +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &Filename) { + restoreCurrentDir(); if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); @@ -829,7 +829,7 @@ Common::SeekableReadStream *CBFileManager::OpenFileRaw(const Common::String &Fil ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::RestoreCurrentDir() { +HRESULT CBFileManager::restoreCurrentDir() { if (!_basePath) return S_OK; else { /*if (!chdir(_basePath)) return S_OK; @@ -841,7 +841,7 @@ HRESULT CBFileManager::RestoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::SetBasePath(const Common::String &Path) { +HRESULT CBFileManager::setBasePath(const Common::String &Path) { cleanup(); if (Path.c_str()) { @@ -849,15 +849,15 @@ HRESULT CBFileManager::SetBasePath(const Common::String &Path) { strcpy(_basePath, Path.c_str()); } - InitPaths(); - RegisterPackages(); + initPaths(); + registerPackages(); return S_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::FindPackageSignature(Common::File *f, uint32 *Offset) { +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *Offset) { byte buf[32768]; byte Signature[8]; diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 173bf4c570..fdeb9b732d 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -42,29 +42,29 @@ namespace WinterMute { class CBFile; class CBFileManager: CBBase { public: - bool FindPackageSignature(Common::File *f, uint32 *Offset); + bool findPackageSignature(Common::File *f, uint32 *Offset); HRESULT cleanup(); - HRESULT SetBasePath(const Common::String &path); - HRESULT RestoreCurrentDir(); + HRESULT setBasePath(const Common::String &path); + HRESULT restoreCurrentDir(); char *_basePath; - bool GetFullPath(const Common::String &filename, char *fullname); - Common::SeekableReadStream *OpenFileRaw(const Common::String &filename); - HRESULT CloseFile(Common::SeekableReadStream *File); - Common::SeekableReadStream *OpenFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *GetPackageEntry(const Common::String &filename); - Common::File *OpenSingleFile(const Common::String &name); - Common::File *OpenPackage(const Common::String &name); - HRESULT RegisterPackages(); - HRESULT InitPaths(); - HRESULT ReloadPaths(); + bool getFullPath(const Common::String &filename, char *fullname); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + HRESULT closeFile(Common::SeekableReadStream *File); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *getPackageEntry(const Common::String &filename); + Common::File *openSingleFile(const Common::String &name); + Common::File *openPackage(const Common::String &name); + HRESULT registerPackages(); + HRESULT initPaths(); + HRESULT reloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - HRESULT AddPath(TPathType Type, const Common::String &path); - HRESULT RequestCD(int CD, char *PackageFile, char *Filename); + HRESULT addPath(TPathType Type, const Common::String &path); + HRESULT requestCD(int CD, char *PackageFile, char *Filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - HRESULT SaveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); - byte *ReadWholeFile(const Common::String &filename, uint32 *Size = NULL, bool MustExist = true); + HRESULT saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *Size = NULL, bool MustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); CBArray _singlePaths; @@ -74,10 +74,10 @@ public: Common::HashMap _files; private: - HRESULT RegisterPackage(const char *Path, const char *Name, bool SearchSignature = false); - HRESULT RegisterPackage(const Common::String &filename, bool SearchSignature = false); + HRESULT registerPackage(const char *Path, const char *Name, bool SearchSignature = false); + HRESULT registerPackage(const Common::String &filename, bool SearchSignature = false); Common::HashMap::iterator _filesIter; - bool IsValidPackage(const AnsiString &fileName) const; + bool isValidPackage(const AnsiString &fileName) const; }; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 28317b00ce..5a6513d7d3 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -73,7 +73,7 @@ int CBFont::GetTextWidth(byte *text, int MaxLenght) { ////////////////////////////////////////////////////////////////////// HRESULT CBFont::LoadFile(const char * Filename) { - BYTE* Buffer = Game->_fileManager->ReadWholeFile(Filename); + BYTE* Buffer = Game->_fileManager->readWholeFile(Filename); if(Buffer==NULL){ Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -187,7 +187,7 @@ bool CBFont::IsTrueType(CBGame *Game, const char *Filename) { TOKEN_TABLE_END - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) return false; byte *WorkBuffer = Buffer; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 8650a077bd..e88a6f0589 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -246,7 +246,7 @@ void CBFontBitmap::DrawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// HRESULT CBFontBitmap::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 81dca9d293..fb3b6e3fb1 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -405,7 +405,7 @@ int CBFontTT::GetLetterHeight() { ////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -637,11 +637,11 @@ void CBFontTT::AfterLoad() { HRESULT CBFontTT::InitFont() { if (!_fontFile) return E_FAIL; - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(_fontFile); + Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); - file = Game->_fileManager->OpenFile(fontFileName.c_str(), false); + file = Game->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return E_FAIL; @@ -682,7 +682,7 @@ HRESULT CBFontTT::InitFont() { error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); if (error) { SAFE_DELETE_ARRAY(_fTStream); - Game->_fileManager->CloseFile(file); + Game->_fileManager->closeFile(file); return E_FAIL; } @@ -745,7 +745,7 @@ void CBFontTT::FTCloseProc(FT_Stream stream) { CBGame *Game = f->Game; - Game->_fileManager->CloseFile(f); + Game->_fileManager->closeFile(f); stream->descriptor.pointer = NULL; }*/ diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 1fdf555731..12398c109c 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -688,7 +688,7 @@ void CBGame::GetOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); return E_FAIL; @@ -1728,10 +1728,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); const char *Filename = Stack->Pop()->GetString(); - Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); if (!File) Stack->PushBool(false); else { - _fileManager->CloseFile(File); + _fileManager->closeFile(File); Stack->PushBool(true); } return S_OK; @@ -2082,7 +2082,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS const char *Filename = Stack->Pop()->GetString(); bool AsHex = Stack->Pop()->GetBool(false); - Common::SeekableReadStream *File = _fileManager->OpenFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); if (File) { crc remainder = crc_initialize(); byte Buf[1024]; @@ -2105,7 +2105,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } else Stack->PushInt(checksum); - _fileManager->CloseFile(File); + _fileManager->closeFile(File); File = NULL; } else Stack->PushNULL(); @@ -3515,7 +3515,7 @@ HRESULT CBGame::LoadSettings(const char *Filename) { TOKEN_TABLE_END - byte *OrigBuffer = Game->_fileManager->ReadWholeFile(Filename); + byte *OrigBuffer = Game->_fileManager->readWholeFile(Filename); if (OrigBuffer == NULL) { Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index eadf845109..cbe134c7c6 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -84,13 +84,13 @@ HRESULT CBImage::loadFile(const Common::String &filename) { error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); } - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(filename.c_str()); + Common::SeekableReadStream *file = Game->_fileManager->openFile(filename.c_str()); if (!file) return E_FAIL; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); - Game->_fileManager->CloseFile(file); + Game->_fileManager->closeFile(file); return S_OK; } diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index 9f68bfa2d0..69ae1c6eff 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -87,10 +87,10 @@ HRESULT CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *b ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *CBPackage::GetFilePointer() { - Common::File *file = Game->_fileManager->OpenPackage(_name); + Common::File *file = Game->_fileManager->openPackage(_name); if (!file) { - Game->_fileManager->RequestCD(_cD, _name, ""); - file = Game->_fileManager->OpenPackage(_name); + Game->_fileManager->requestCD(_cD, _name, ""); + file = Game->_fileManager->openPackage(_name); } return file; } diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 64cbb76277..6db1fb5cd5 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -249,7 +249,7 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { _saving = false; _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = Game->_fileManager->ReadWholeFile(Filename, &_bufferSize); + //_buffer = Game->_fileManager->readWholeFile(Filename, &_bufferSize); if (_loadStream) { uint32 Magic; Magic = getDWORD(); @@ -348,7 +348,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::saveFile(const char *filename) { - return Game->_fileManager->SaveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); + return Game->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 9de95bb858..8a0600792d 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -96,7 +96,7 @@ bool CBRegion::PointInRegion(int X, int Y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index b24bdcfb19..a60b78ee33 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -77,7 +77,7 @@ CBSoundBuffer::~CBSoundBuffer() { } if (_file) { - Game->_fileManager->CloseFile(_file); + Game->_fileManager->closeFile(_file); _file = NULL; } @@ -104,9 +104,9 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { delete _stream; _stream = NULL; - if (_file) Game->_fileManager->CloseFile(_file); + if (_file) Game->_fileManager->closeFile(_file); - _file = Game->_fileManager->OpenFile(Filename); + _file = Game->_fileManager->openFile(Filename); if (!_file) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; @@ -146,7 +146,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { bool NewlyCreated = false; if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = Game->_fileManager->OpenFile(Filename); + if(!_file) _file = Game->_fileManager->openFile(Filename); if(!_file){ Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; @@ -176,7 +176,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { // close file (if not streaming) if(!_streamed && _file){ - Game->_fileManager->CloseFile(_file); + Game->_fileManager->closeFile(_file); _file = NULL; } */ diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index e931d95f2d..d9ef81b315 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -138,10 +138,10 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); AnsiString newFile = PathUtil::Combine(path, name + "ogg"); - Common::SeekableReadStream *file = Game->_fileManager->OpenFile(newFile.c_str()); + Common::SeekableReadStream *file = Game->_fileManager->openFile(newFile.c_str()); if (file) { Filename = newFile.c_str(); - Game->_fileManager->CloseFile(file); + Game->_fileManager->closeFile(file); } } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index f848ae456f..efe07505eb 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -123,13 +123,13 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); if (!File) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); else return LoadFile("invalid.bmp", LifeTime, CacheType); } else { - Game->_fileManager->CloseFile(File); + Game->_fileManager->closeFile(File); File = NULL; } @@ -153,7 +153,7 @@ HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType ret = S_OK; } } else { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer) { if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); delete [] Buffer; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 8b71e2ac60..f494658906 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -175,7 +175,7 @@ HRESULT CBStringTable::LoadFile(const char *Filename, bool ClearOld) { if (ClearOld) _strings.clear(); uint32 Size; - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->readWholeFile(Filename, &Size); if (Buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 237c9d760d..8d30b01d19 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -105,14 +105,14 @@ CBSurface *CBSurfaceStorage::addSurface(const char *Filename, bool default_ck, b } } - Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); if (!File) { if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); if (Game->_dEBUG_DebugMode) return addSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else return addSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - } else Game->_fileManager->CloseFile(File); + } else Game->_fileManager->closeFile(File); CBSurface *surface; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 1ff3bf1122..0c7606b4f0 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -125,11 +125,11 @@ HRESULT CPartEmitter::addSprite(const char *Filename) { } // check if file exists - Common::SeekableReadStream *File = Game->_fileManager->OpenFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); if (!File) { Game->LOG(0, "Sprite '%s' not found", Filename); return E_FAIL; - } else Game->_fileManager->CloseFile(File); + } else Game->_fileManager->closeFile(File); char *Str = new char[strlen(Filename) + 1]; strcpy(Str, Filename); diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index 02aec3419f..a7f634be25 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -76,7 +76,7 @@ Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileMa if (fileName[i] == '/') fileName[i] = '\\'; } - fileEntry = fileManager->GetPackageEntry(fileName); + fileEntry = fileManager->getPackageEntry(fileName); if (!fileEntry) return NULL; file = fileEntry->_package->GetFilePointer(); diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index bffd1d462a..ec115ca50b 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -86,7 +86,7 @@ void CSXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// void CSXFile::Close() { if (_readFile) { - Game->_fileManager->CloseFile(_readFile); + Game->_fileManager->closeFile(_readFile); _readFile = NULL; } if ((FILE *)_writeFile) { @@ -130,7 +130,7 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This _mode = 1; } if (_mode == 1) { - _readFile = Game->_fileManager->OpenFile(_filename); + _readFile = Game->_fileManager->openFile(_filename); if (!_readFile) { //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); Close(); @@ -711,7 +711,7 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { if (_mode != 0) { // open for reading if (_mode == 1) { - _readFile = Game->_fileManager->OpenFile(_filename); + _readFile = Game->_fileManager->openFile(_filename); if (!_readFile) Close(); } // open for writing / appending diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 4e2dd203cc..a28a35948f 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -191,7 +191,7 @@ HRESULT CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { CBGame *Game = (CBGame *)Data; - return Game->_fileManager->ReadWholeFile(Filename, Size); + return Game->_fileManager->readWholeFile(Filename, Size); } @@ -286,7 +286,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I uint32 Size; - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->readWholeFile(Filename, &Size); if (!Buffer) { Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); return NULL; diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index f545a0a745..a4653c2007 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -96,7 +96,7 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIButton::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index fdb5b00a80..091de2c2c9 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -95,7 +95,7 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEdit::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 962a6b87d7..ef9e0df393 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -56,7 +56,7 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index e221314218..9b495efafd 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -96,7 +96,7 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 61ad44e8d8..c47f3f09de 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -120,7 +120,7 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// HRESULT CUITiledImage::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 38c950c337..e0750a84f2 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -201,7 +201,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::LoadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->ReadWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); return E_FAIL; diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index c0dbfea56f..7f35e022cf 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -395,7 +395,7 @@ HRESULT CVidPlayer::loadSubtitles(const char *Filename, const char *SubtitleFile } DWORD Size; - BYTE *Buffer = Game->m_FileManager->ReadWholeFile(NewFile, &Size, false); + BYTE *Buffer = Game->m_FileManager->readWholeFile(NewFile, &Size, false); if (Buffer == NULL) return S_OK; // no subtitles diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 779827212a..b6793fbbbd 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -132,7 +132,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo cleanup(); _filename = filename; - _file = Game->_fileManager->OpenFile(filename, true, false); + _file = Game->_fileManager->openFile(filename, true, false); if (!_file) return E_FAIL; //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); @@ -159,7 +159,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo #if 0 cleanup(); - _file = Game->_fileManager->OpenFile(Filename); + _file = Game->_fileManager->openFile(Filename); if (!_file) return E_FAIL; if (Filename != _filename) CBUtils::SetString(&_filename, Filename); -- cgit v1.2.3 From 191ca9cdeca2fe677299d89c9208e394d3f180f9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:09:41 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BFader. --- engines/wintermute/Ad/AdScene.cpp | 6 +++--- engines/wintermute/Base/BFader.cpp | 8 ++++---- engines/wintermute/Base/BFader.h | 8 ++++---- engines/wintermute/Base/BGame.cpp | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 098ea3829d..0acc081c27 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1520,7 +1520,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi byte Blue = Stack->Pop()->GetInt(0); byte Alpha = Stack->Pop()->GetInt(0xFF); - _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); + _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); @@ -1538,7 +1538,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi byte Blue = Stack->Pop()->GetInt(0); byte Alpha = Stack->Pop()->GetInt(0xFF); - _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); + _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); @@ -1550,7 +1550,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFadeColor") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_fader->GetCurrentColor()); + Stack->PushInt(_fader->getCurrentColor()); return S_OK; } diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index 741b586d56..a1e551df3f 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -93,7 +93,7 @@ HRESULT CBFader::display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::Deactivate() { +HRESULT CBFader::deactivate() { _active = false; _ready = true; return S_OK; @@ -101,7 +101,7 @@ HRESULT CBFader::Deactivate() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { +HRESULT CBFader::fadeIn(uint32 SourceColor, uint32 Duration, bool System) { _ready = false; _active = true; @@ -123,7 +123,7 @@ HRESULT CBFader::FadeIn(uint32 SourceColor, uint32 Duration, bool System) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { +HRESULT CBFader::fadeOut(uint32 TargetColor, uint32 Duration, bool System) { _ready = false; _active = true; @@ -147,7 +147,7 @@ HRESULT CBFader::FadeOut(uint32 TargetColor, uint32 Duration, bool System) { ////////////////////////////////////////////////////////////////////////// -uint32 CBFader::GetCurrentColor() { +uint32 CBFader::getCurrentColor() { return DRGBA(_red, _green, _blue, _currentAlpha); } diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h index 663766127b..8a98bea8fe 100644 --- a/engines/wintermute/Base/BFader.h +++ b/engines/wintermute/Base/BFader.h @@ -37,10 +37,10 @@ namespace WinterMute { class CBFader : public CBObject { public: bool _system; - uint32 GetCurrentColor(); - HRESULT FadeOut(uint32 TargetColor, uint32 Duration, bool System = false); - HRESULT FadeIn(uint32 SourceColor, uint32 Duration, bool System = false); - HRESULT Deactivate(); + uint32 getCurrentColor(); + HRESULT fadeOut(uint32 TargetColor, uint32 Duration, bool System = false); + HRESULT fadeIn(uint32 SourceColor, uint32 Duration, bool System = false); + HRESULT deactivate(); HRESULT display(); HRESULT update(); DECLARE_PERSISTENT(CBFader, CBObject) diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 12398c109c..05dfcf6abb 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1750,7 +1750,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); - _fader->FadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); + _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); @@ -1770,7 +1770,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); - _fader->FadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); + _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(_fader); Stack->PushNULL(); @@ -1782,7 +1782,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GetFadeColor") == 0) { Stack->CorrectParams(0); - Stack->PushInt(_fader->GetCurrentColor()); + Stack->PushInt(_fader->getCurrentColor()); return S_OK; } -- cgit v1.2.3 From 382e3b097eacf79722d12c0e402c3300488436dd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:15:56 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BDynBuffer. --- engines/wintermute/Ad/AdEntity.cpp | 62 +++++++++--------- engines/wintermute/Ad/AdInventoryBox.cpp | 30 ++++----- engines/wintermute/Ad/AdLayer.cpp | 22 +++---- engines/wintermute/Ad/AdRegion.cpp | 26 ++++---- engines/wintermute/Ad/AdResponseBox.cpp | 34 +++++----- engines/wintermute/Ad/AdRotLevel.cpp | 8 +-- engines/wintermute/Ad/AdScaleLevel.cpp | 8 +-- engines/wintermute/Ad/AdScene.cpp | 78 +++++++++++------------ engines/wintermute/Ad/AdSpriteSet.cpp | 22 +++---- engines/wintermute/Ad/AdTalkDef.cpp | 10 +-- engines/wintermute/Ad/AdTalkHolder.cpp | 4 +- engines/wintermute/Ad/AdTalkNode.cpp | 16 ++--- engines/wintermute/Ad/AdWaypointGroup.cpp | 12 ++-- engines/wintermute/Base/BBase.cpp | 14 ++--- engines/wintermute/Base/BDynBuffer.cpp | 68 ++++++++++---------- engines/wintermute/Base/BDynBuffer.h | 22 +++---- engines/wintermute/Base/BFrame.cpp | 18 +++--- engines/wintermute/Base/BRegion.cpp | 18 +++--- engines/wintermute/Base/BSprite.cpp | 28 ++++----- engines/wintermute/Base/BSubFrame.cpp | 28 ++++----- engines/wintermute/Base/scriptables/ScValue.cpp | 8 +-- engines/wintermute/UI/UIButton.cpp | 84 ++++++++++++------------- engines/wintermute/UI/UIEdit.cpp | 52 +++++++-------- engines/wintermute/UI/UIEntity.cpp | 26 ++++---- engines/wintermute/UI/UIText.cpp | 56 ++++++++--------- engines/wintermute/UI/UITiledImage.cpp | 12 ++-- engines/wintermute/UI/UIWindow.cpp | 82 ++++++++++++------------ 27 files changed, 424 insertions(+), 424 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 8b1cd0853d..d5e2fe954f 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -878,69 +878,69 @@ const char *CAdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ENTITY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent, "ENTITY {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) - Buffer->PutTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); if (_ignoreItems) - Buffer->PutTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); if (_rotatable) - Buffer->PutTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); if (!_autoSoundPanning) - Buffer->PutTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); if (!_saveState) - Buffer->PutTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); - if (_item && _item[0] != '\0') Buffer->PutTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); + if (_item && _item[0] != '\0') Buffer->putTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); - Buffer->PutTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); - Buffer->PutTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); + Buffer->putTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); + Buffer->putTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); if (_walkToDir != DI_NONE) - Buffer->PutTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + Buffer->putTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + Buffer->putTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); - Buffer->PutTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); - Buffer->PutTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); + Buffer->putTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + Buffer->putTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + Buffer->putTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); } if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); if (D3DCOLGetA(_alphaColor) != 0) - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); + Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); if (_scale >= 0) - Buffer->PutTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); + Buffer->putTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); if (_relativeScale != 0) - Buffer->PutTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + Buffer->putTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); CAdTalkHolder::saveAsText(Buffer, Indent + 2); @@ -950,7 +950,7 @@ HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { CAdObject::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 55214f51ce..9c2d5bbcfc 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -318,33 +318,33 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "INVENTORY_BOX\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "INVENTORY_BOX\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); + Buffer->putTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - Buffer->PutTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); - Buffer->PutTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); - Buffer->PutTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); - Buffer->PutTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); + Buffer->putTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + Buffer->putTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + Buffer->putTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + Buffer->putTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // window if (_window) _window->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index c5d24898cd..0967fd74c9 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -479,21 +479,21 @@ const char *CAdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "LAYER {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent, "LAYER {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); if (_closeUp) - Buffer->PutTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); @@ -514,7 +514,7 @@ HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index df124e7692..d7346665e5 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -347,31 +347,31 @@ const char *CAdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRegion::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "REGION {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent, "REGION {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); + Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); for (i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index d62324e4b1..39caffe00f 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -336,30 +336,30 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "RESPONSE_BOX\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "RESPONSE_BOX\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); + Buffer->putTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontHover && _fontHover->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->PutTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); switch (_align) { case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: error("CAdResponseBox::SaveAsText - Unhandled enum"); @@ -368,29 +368,29 @@ HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { switch (_verticalAlign) { case VAL_TOP: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; case VAL_BOTTOM: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); break; case VAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); break; } - Buffer->PutTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + Buffer->putTextIndent(Indent + 2, "SPACING=%d\n", _spacing); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // window if (_window) _window->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 4f20973958..e2d82ed952 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -136,11 +136,11 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRotLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ROTATION_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); + Buffer->putTextIndent(Indent, "ROTATION_LEVEL {\n"); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 68cccac35a..3ed0d93f46 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -134,11 +134,11 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScaleLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SCALE_LEVEL {\n"); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); + Buffer->putTextIndent(Indent, "SCALE_LEVEL {\n"); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 0acc081c27..fe3820d574 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1972,24 +1972,24 @@ HRESULT CAdScene::RemoveObject(CAdObject *Object) { HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { int i; - Buffer->PutTextIndent(Indent, "SCENE {\n"); + Buffer->putTextIndent(Indent, "SCENE {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); if (_persistentState) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); if (!_persistentStateSprites) - Buffer->PutTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); // scripts for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // properties if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); @@ -1997,61 +1997,61 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { // viewport if (_viewport) { RECT *rc = _viewport->getRect(); - Buffer->PutTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + Buffer->putTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } // editor settings - Buffer->PutTextIndent(Indent + 2, "; ----- editor settings\n"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); - Buffer->PutTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); - Buffer->PutTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); - - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); - - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "; ----- editor settings\n"); + Buffer->putTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + Buffer->putTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); + Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); + + Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); + + Buffer->putTextIndent(Indent + 2, "\n"); CBBase::saveAsText(Buffer, Indent + 2); // waypoints - Buffer->PutTextIndent(Indent + 2, "; ----- waypoints\n"); + Buffer->putTextIndent(Indent + 2, "; ----- waypoints\n"); for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // layers - Buffer->PutTextIndent(Indent + 2, "; ----- layers\n"); + Buffer->putTextIndent(Indent + 2, "; ----- layers\n"); for (i = 0; i < _layers.GetSize(); i++) _layers[i]->saveAsText(Buffer, Indent + 2); // scale levels - Buffer->PutTextIndent(Indent + 2, "; ----- scale levels\n"); + Buffer->putTextIndent(Indent + 2, "; ----- scale levels\n"); for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->saveAsText(Buffer, Indent + 2); // rotation levels - Buffer->PutTextIndent(Indent + 2, "; ----- rotation levels\n"); + Buffer->putTextIndent(Indent + 2, "; ----- rotation levels\n"); for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // free entities - Buffer->PutTextIndent(Indent + 2, "; ----- free entities\n"); + Buffer->putTextIndent(Indent + 2, "; ----- free entities\n"); for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { _objects[i]->saveAsText(Buffer, Indent + 2); @@ -2061,7 +2061,7 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 62787b6c68..3eb30e2496 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -260,34 +260,34 @@ CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SPRITESET {\n"); - if (_name) Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent, "SPRITESET {\n"); + if (_name) Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { if (_sprites[i]) { switch (i) { case DI_UP: - Buffer->PutTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPRIGHT: - Buffer->PutTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_RIGHT: - Buffer->PutTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNRIGHT: - Buffer->PutTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWN: - Buffer->PutTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNLEFT: - Buffer->PutTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_LEFT: - Buffer->PutTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPLEFT: - Buffer->PutTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); break; } } @@ -295,7 +295,7 @@ HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *Buffer, int Indent) { CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 8aa3d3523f..8b485f2092 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -211,19 +211,19 @@ HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "TALK {\n"); - if (_defaultSpriteFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + Buffer->putTextIndent(Indent, "TALK {\n"); + if (_defaultSpriteFilename) Buffer->putTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - if (_defaultSpriteSetFilename) Buffer->PutTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + if (_defaultSpriteSetFilename) Buffer->putTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(Buffer, Indent + 2); for (int i = 0; i < _nodes.GetSize(); i++) { _nodes[i]->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "\n"); + Buffer->putTextIndent(Indent, "\n"); } CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 222376dd8d..204de117b6 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -330,12 +330,12 @@ HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *Buffer, int Indent) { int i; for (i = 0; i < _talkSprites.GetSize(); i++) { if (_talkSprites[i]->_filename) - Buffer->PutTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + Buffer->putTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); } for (i = 0; i < _talkSpritesEx.GetSize(); i++) { if (_talkSpritesEx[i]->_filename) - Buffer->PutTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + Buffer->putTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); } return S_OK; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index d9aeb2e85f..9f9264113b 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -199,18 +199,18 @@ HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkNode::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ACTION {\n"); - if (_comment) Buffer->PutTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); - Buffer->PutTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) Buffer->PutTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) Buffer->PutTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) Buffer->PutTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + Buffer->putTextIndent(Indent, "ACTION {\n"); + if (_comment) Buffer->putTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); + Buffer->putTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) Buffer->putTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) Buffer->putTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) Buffer->putTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); else if (_spriteSet) _spriteSet->saveAsText(Buffer, Indent + 2); - if (_preCache) Buffer->PutTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + if (_preCache) Buffer->putTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index dc0059cf40..c2613d4cd7 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -165,19 +165,19 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "WAYPOINTS {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + Buffer->putTextIndent(Indent, "WAYPOINTS {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); CBBase::saveAsText(Buffer, Indent + 2); for (int i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index afae06af68..bcd6a43e23 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -161,13 +161,13 @@ HRESULT CBBase::parseEditorProperty(byte *Buffer, bool Complete) { HRESULT CBBase::saveAsText(CBDynBuffer *Buffer, int Indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { - Buffer->PutTextIndent(Indent, "EDITOR_PROPERTY\n"); - Buffer->PutTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "EDITOR_PROPERTY\n"); + Buffer->putTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + Buffer->putTextIndent(Indent, "}\n\n"); _editorPropsIter++; } diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index 4a498fb3dd..7a4a5afeec 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -32,14 +32,14 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 InitSize, uint32 GrowBy): CBBase(inGame) { +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { _buffer = NULL; _size = 0; _realSize = 0; _offset = 0; - _initSize = InitSize; - _growBy = GrowBy; + _initSize = initSize; + _growBy = growBy; _initialized = false; } @@ -63,24 +63,24 @@ void CBDynBuffer::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::GetSize() { +uint32 CBDynBuffer::getSize() { return _size; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::Init(uint32 InitSize) { +HRESULT CBDynBuffer::init(uint32 initSize) { cleanup(); - if (InitSize == 0) InitSize = _initSize; + if (initSize == 0) initSize = _initSize; - _buffer = (byte *)malloc(InitSize); + _buffer = (byte *)malloc(initSize); if (!_buffer) { - Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", InitSize); + Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); return E_FAIL; } - _realSize = InitSize; + _realSize = initSize; _initialized = true; return S_OK; @@ -88,10 +88,10 @@ HRESULT CBDynBuffer::Init(uint32 InitSize) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { - if (!_initialized) Init(); +HRESULT CBDynBuffer::putBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); - while (_offset + Size > _realSize) { + while (_offset + size > _realSize) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { @@ -100,57 +100,57 @@ HRESULT CBDynBuffer::PutBytes(byte *Buffer, uint32 Size) { } } - memcpy(_buffer + _offset, Buffer, Size); - _offset += Size; - _size += Size; + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::GetBytes(byte *Buffer, uint32 Size) { - if (!_initialized) Init(); +HRESULT CBDynBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); - if (_offset + Size > _size) { + if (_offset + size > _size) { Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); return E_FAIL; } - memcpy(Buffer, _buffer + _offset, Size); - _offset += Size; + memcpy(buffer, _buffer + _offset, size); + _offset += size; return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutDWORD(uint32 Val) { - PutBytes((byte *)&Val, sizeof(uint32)); +void CBDynBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::GetDWORD() { +uint32 CBDynBuffer::getDWORD() { uint32 ret; - GetBytes((byte *)&ret, sizeof(uint32)); + getBytes((byte *)&ret, sizeof(uint32)); return ret; } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutString(const char *Val) { - if (!Val) PutString("(null)"); +void CBDynBuffer::putString(const char *val) { + if (!val) putString("(null)"); else { - PutDWORD(strlen(Val) + 1); - PutBytes((byte *)Val, strlen(Val) + 1); + putDWORD(strlen(val) + 1); + putBytes((byte *)val, strlen(val) + 1); } } ////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::GetString() { - uint32 len = GetDWORD(); +char *CBDynBuffer::getString() { + uint32 len = getDWORD(); char *ret = (char *)(_buffer + _offset); _offset += len; @@ -160,7 +160,7 @@ char *CBDynBuffer::GetString() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutText(LPCSTR fmt, ...) { +void CBDynBuffer::putText(LPCSTR fmt, ...) { va_list va; va_start(va, fmt); @@ -171,10 +171,10 @@ void CBDynBuffer::PutText(LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { +void CBDynBuffer::putTextIndent(int indent, LPCSTR fmt, ...) { va_list va; - PutText("%*s", Indent, ""); + putText("%*s", indent, ""); va_start(va, fmt); PutTextForm(fmt, va); @@ -186,7 +186,7 @@ void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...) { void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { char buff[32768]; vsprintf(buff, format, argptr); - PutBytes((byte *)buff, strlen(buff)); + putBytes((byte *)buff, strlen(buff)); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index 626ce04314..4d11b2fe6a 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -37,20 +37,20 @@ namespace WinterMute { class CBDynBuffer : public CBBase { public: bool _initialized; - void PutText(LPCSTR fmt, ...); - void PutTextIndent(int Indent, LPCSTR fmt, ...); - uint32 GetDWORD(); - void PutDWORD(uint32 Val); - char *GetString(); - void PutString(const char *Val); - HRESULT GetBytes(byte *Buffer, uint32 Size); - HRESULT PutBytes(byte *Buffer, uint32 Size); - uint32 GetSize(); - HRESULT Init(uint32 InitSize = 0); + void putText(LPCSTR fmt, ...); + void putTextIndent(int indent, LPCSTR fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + HRESULT getBytes(byte *buffer, uint32 size); + HRESULT putBytes(byte *buffer, uint32 size); + uint32 getSize(); + HRESULT init(uint32 initSize = 0); void cleanup(); uint32 _size; byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 InitSize = 1000, uint32 GrowBy = 1000); + CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); virtual ~CBDynBuffer(); private: diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 8e05d865fd..35e6ca814b 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -343,22 +343,22 @@ bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca ////////////////////////////////////////////////////////////////////////// HRESULT CBFrame::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "FRAME {\n"); - Buffer->PutTextIndent(Indent + 2, "DELAY = %d\n", _delay); + Buffer->putTextIndent(Indent, "FRAME {\n"); + Buffer->putTextIndent(Indent + 2, "DELAY = %d\n", _delay); if (_moveX != 0 || _moveY != 0) - Buffer->PutTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + Buffer->putTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); if (_sound && _sound->_soundFilename) - Buffer->PutTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + Buffer->putTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - Buffer->PutTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); if (_killSound) - Buffer->PutTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); if (_editorExpanded) - Buffer->PutTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(Buffer, Indent, false); @@ -368,13 +368,13 @@ HRESULT CBFrame::saveAsText(CBDynBuffer *Buffer, int Indent) { } for (i = 0; i < _applyEvent.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + Buffer->putTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 8a0600792d..c66ee67e17 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -379,27 +379,27 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { - if (!NameOverride) Buffer->PutTextIndent(Indent, "REGION {\n"); - else Buffer->PutTextIndent(Indent, "%s {\n", NameOverride); + if (!NameOverride) Buffer->putTextIndent(Indent, "REGION {\n"); + else Buffer->putTextIndent(Indent, "%s {\n", NameOverride); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } for (i = 0; i < _points.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index efe07505eb..6ec19c6ba3 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -429,26 +429,26 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc ////////////////////////////////////////////////////////////////////////// HRESULT CBSprite::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "SPRITE {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent, "SPRITE {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); if (_streamed) { - Buffer->PutTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); if (_streamedKeepLoaded) - Buffer->PutTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); } if (_editorMuted) - Buffer->PutTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); if (_editorBgFile) { - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - Buffer->PutTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + Buffer->putTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + Buffer->putTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + Buffer->putTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + Buffer->putTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } CBScriptHolder::saveAsText(Buffer, Indent + 2); @@ -457,7 +457,7 @@ HRESULT CBSprite::saveAsText(CBDynBuffer *Buffer, int Indent) { // scripts for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -465,7 +465,7 @@ HRESULT CBSprite::saveAsText(CBDynBuffer *Buffer, int Indent) { _frames[i]->saveAsText(Buffer, Indent + 2); } - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 127c4a7bba..f86d654980 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -251,51 +251,51 @@ bool CBSubFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ////////////////////////////////////////////////////////////////////////// HRESULT CBSubFrame::saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { if (Complete) - Buffer->PutTextIndent(Indent, "SUBFRAME {\n"); + Buffer->putTextIndent(Indent, "SUBFRAME {\n"); if (_surface && _surface->_filename != NULL) - Buffer->PutTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); if (_transparent != 0xFFFF00FF) - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); + Buffer->putTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); RECT rect; CBPlatform::SetRectEmpty(&rect); if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::EqualRect(&rect, &_rect)) - Buffer->PutTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + Buffer->putTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) - Buffer->PutTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + Buffer->putTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); if (_alpha != 0xFFFFFFFF) { - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); } if (_mirrorX) - Buffer->PutTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); if (_mirrorY) - Buffer->PutTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); if (_2DOnly) - Buffer->PutTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); if (_3DOnly) - Buffer->PutTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); if (_decoration) - Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); if (_editorSelected) - Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); CBBase::saveAsText(Buffer, Indent + 2); if (Complete) - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 7e575879c1..707fda0984 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -805,10 +805,10 @@ HRESULT CScValue::persist(CBPersistMgr *persistMgr) { HRESULT CScValue::saveAsText(CBDynBuffer *Buffer, int Indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - Buffer->PutTextIndent(Indent, "PROPERTY {\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - Buffer->PutTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); - Buffer->PutTextIndent(Indent, "}\n\n"); + Buffer->putTextIndent(Indent, "PROPERTY {\n"); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); + Buffer->putTextIndent(Indent, "}\n\n"); _valIter++; } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index a4653c2007..79218a62e5 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -441,100 +441,100 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIButton::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "BUTTON\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "BUTTON\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_backHover && _backHover->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + Buffer->putTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); if (_backPress && _backPress->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + Buffer->putTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); if (_backDisable && _backDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + Buffer->putTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); if (_backFocus && _backFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + Buffer->putTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_imageHover && _imageHover->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); if (_imagePress && _imagePress->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); if (_imageDisable && _imageDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); if (_imageFocus && _imageFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontHover && _fontHover->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); if (_fontPress && _fontPress->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); if (_fontDisable && _fontDisable->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); if (_fontFocus && _fontFocus->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); switch (_align) { case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: warning("CUIButton::SaveAsText - unhandled enum"); break; } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 091de2c2c9..928d04016a 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -303,58 +303,58 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEdit::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "EDIT\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "EDIT\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontSelected && _fontSelected->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); - Buffer->PutTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); - Buffer->PutTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->putTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); + Buffer->putTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + Buffer->putTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index ef9e0df393..5a30c32e5d 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -175,35 +175,35 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "ENTITY_CONTAINER\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "ENTITY_CONTAINER\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); if (_entity && _entity->_filename) - Buffer->PutTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + Buffer->putTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 9b495efafd..260ade166c 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -294,38 +294,38 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "STATIC\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "STATIC\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); if (_text) - Buffer->PutTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); switch (_textAlign) { case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: error("CUIText::SaveAsText - Unhandled enum"); @@ -334,42 +334,42 @@ HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { switch (_verticalAlign) { case VAL_TOP: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; case VAL_BOTTOM: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); break; case VAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); break; default: error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index c47f3f09de..aea658e254 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -308,11 +308,11 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "TILED_IMAGE\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "TILED_IMAGE\n"); + Buffer->putTextIndent(Indent, "{\n"); if (_image && _image->_surfaceFilename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); int H1, H2, H3; int V1, V2, V3; @@ -326,13 +326,13 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { V3 = _downLeft.bottom - _downLeft.top; - Buffer->PutTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); - Buffer->PutTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); + Buffer->putTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); + Buffer->putTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); // editor properties CBBase::saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index e0750a84f2..5d7bade46e 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -568,94 +568,94 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->PutTextIndent(Indent, "WINDOW\n"); - Buffer->PutTextIndent(Indent, "{\n"); + Buffer->putTextIndent(Indent, "WINDOW\n"); + Buffer->putTextIndent(Indent, "{\n"); - Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_back && _back->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_backInactive && _backInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + Buffer->putTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); if (_image && _image->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_imageInactive && _imageInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + Buffer->putTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); if (_font && _font->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontInactive && _fontInactive->_filename) - Buffer->PutTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + Buffer->putTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); if (_cursor && _cursor->_filename) - Buffer->PutTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_text) - Buffer->PutTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); + Buffer->putTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); switch (_titleAlign) { case TAL_LEFT: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->PutTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); break; default: error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } if (!CBPlatform::IsRectEmpty(&_titleRect)) { - Buffer->PutTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + Buffer->putTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } if (!CBPlatform::IsRectEmpty(&_dragRect)) { - Buffer->PutTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); + Buffer->putTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); - Buffer->PutTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->PutTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->PutTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->PutTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); + Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); + Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->PutTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + Buffer->putTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); if (_fadeBackground) { - Buffer->PutTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); - Buffer->PutTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); + Buffer->putTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); + Buffer->putTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); } - Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - Buffer->PutTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); + Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + Buffer->putTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->PutTextIndent(Indent + 2, "\n"); + Buffer->putTextIndent(Indent + 2, "\n"); // editor properties CBBase::saveAsText(Buffer, Indent + 2); @@ -665,7 +665,7 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { _widgets[i]->saveAsText(Buffer, Indent + 2); - Buffer->PutTextIndent(Indent, "}\n"); + Buffer->putTextIndent(Indent, "}\n"); return S_OK; } -- cgit v1.2.3 From cc56ba01e470f9af9f16724acbda58f67852d284 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:27:33 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in Brenderer/BrendererSDL --- engines/wintermute/Ad/AdGame.cpp | 8 ++-- engines/wintermute/Ad/AdScene.cpp | 10 ++--- engines/wintermute/Base/BFader.cpp | 2 +- engines/wintermute/Base/BFontBitmap.cpp | 6 +-- engines/wintermute/Base/BGame.cpp | 40 ++++++++--------- engines/wintermute/Base/BRenderSDL.cpp | 36 ++++++++-------- engines/wintermute/Base/BRenderSDL.h | 32 +++++++------- engines/wintermute/Base/BRenderer.cpp | 62 +++++++++++++-------------- engines/wintermute/Base/BRenderer.h | 64 ++++++++++++++-------------- engines/wintermute/Base/BSaveThumbHelper.cpp | 6 +-- engines/wintermute/Base/BSurfaceSDL.cpp | 2 +- engines/wintermute/Base/BTransitionMgr.cpp | 4 +- engines/wintermute/Base/PartEmitter.cpp | 4 +- engines/wintermute/PlatformSDL.cpp | 4 +- engines/wintermute/Sys/SysClassRegistry.cpp | 8 ++-- engines/wintermute/UI/UITiledImage.cpp | 4 +- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/wintermute.cpp | 4 +- 18 files changed, 149 insertions(+), 149 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 2467a47e9f..6d1744b3d3 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1688,8 +1688,8 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { if (Update) InitLoop(); // fill black - _renderer->Fill(0, 0, 0); - if (!_editorMode) _renderer->SetScreenViewport(); + _renderer->fill(0, 0, 0); + if (!_editorMode) _renderer->setScreenViewport(); // playing exclusive video? if (_videoPlayer->isPlaying()) { @@ -1727,7 +1727,7 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // display normal windows DisplayWindows(false); - SetActiveObject(Game->_renderer->GetObjectAt(p.x, p.y)); + SetActiveObject(Game->_renderer->getObjectAt(p.x, p.y)); // textual info DisplaySentences(_state == GAME_FROZEN); @@ -1942,7 +1942,7 @@ bool CAdGame::ValidMouse() { POINT Pos; CBPlatform::GetCursorPos(&Pos); - return _renderer->PointInViewport(&Pos); + return _renderer->pointInViewport(&Pos); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index fe3820d574..670fb7283d 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -940,7 +940,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// // *** display/update everything - Game->_renderer->Setup2D(); + Game->_renderer->setup2D(); // for each layer /* int MainOffsetX = 0; */ @@ -985,7 +985,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { switch (Node->_type) { case OBJECT_ENTITY: if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { - Game->_renderer->Setup2D(); + Game->_renderer->setup2D(); if (Update) Node->_entity->update(); else Node->_entity->display(); @@ -1018,7 +1018,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // restore state Game->SetOffset(OrigX, OrigY); - Game->_renderer->Setup2D(); + Game->_renderer->setup2D(); // display/update fader if (_fader) { @@ -1104,7 +1104,7 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { if (Display3DOnly && !Obj->_is3D) continue; - Game->_renderer->Setup2D(); + Game->_renderer->setup2D(); if (Game->_editorMode || !Obj->_editorOnly) Obj->display(); Obj->_drawn = true; @@ -1165,7 +1165,7 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { if (obj != NULL) { - Game->_renderer->Setup2D(); + Game->_renderer->setup2D(); if (Game->_editorMode || !obj->_editorOnly) obj->display(); obj->_drawn = true; diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index a1e551df3f..55937dbcfa 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -87,7 +87,7 @@ HRESULT CBFader::update() { HRESULT CBFader::display() { if (!_active) return S_OK; - if (_currentAlpha > 0x00) return Game->_renderer->FadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); + if (_currentAlpha > 0x00) return Game->_renderer->fadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); else return S_OK; } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index e88a6f0589..31a667bcbe 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -138,11 +138,11 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig bool new_line = false; bool long_line = false; - if (draw) Game->_renderer->StartSpriteBatch(); + if (draw) Game->_renderer->startSpriteBatch(); while (!done) { if (max_height > 0 && (NumLines + 1)*_tileHeight > max_height) { - if (draw) Game->_renderer->EndSpriteBatch(); + if (draw) Game->_renderer->endSpriteBatch(); return NumLines * _tileHeight; } @@ -208,7 +208,7 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig } } - if (draw) Game->_renderer->EndSpriteBatch(); + if (draw) Game->_renderer->endSpriteBatch(); return NumLines * _tileHeight; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 05dfcf6abb..994dd48b2c 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -610,7 +610,7 @@ HRESULT CBGame::InitLoop() { _currentTime = CBPlatform::GetTime(); GetDebugMgr()->OnGameTick(); - _renderer->InitLoop(); + _renderer->initLoop(); _soundMgr->initLoop(); UpdateMusicCrossfade(); @@ -1806,7 +1806,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } bool ret = false; - CBImage *Image = Game->_renderer->TakeScreenshot(); + CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { ret = SUCCEEDED(Image->SaveBMPFile(Filename)); delete Image; @@ -1826,7 +1826,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS int SizeY = Stack->Pop()->GetInt(_renderer->_height); bool ret = false; - CBImage *Image = Game->_renderer->TakeScreenshot(); + CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); @@ -1999,8 +1999,8 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS _loadingIcon = NULL; } else { DisplayContent(false, true); - Game->_renderer->Flip(); - Game->_renderer->InitLoop(); + Game->_renderer->flip(); + Game->_renderer->initLoop(); } Stack->PushNULL(); @@ -2025,7 +2025,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Stack->CorrectParams(1); const char *Filename = Stack->Pop()->GetString(); - _renderer->DumpData(Filename); + _renderer->dumpData(Filename); Stack->PushNULL(); return S_OK; @@ -3321,7 +3321,7 @@ HRESULT CBGame::LoadGame(const char *Filename) { Game->applyEvent("AfterLoad", true); DisplayContent(true, false); - //_renderer->Flip(); + //_renderer->flip(); GetDebugMgr()->OnGameInit(); @@ -3786,7 +3786,7 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { // TODO: Handle alt-enter as well as alt-return. - _renderer->SwitchFullscreen(); + _renderer->switchFullscreen(); return true; } @@ -3983,7 +3983,7 @@ HRESULT CBGame::PushViewport(CBViewport *Viewport) { if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); else _viewportStack[_viewportSP] = Viewport; - _renderer->SetViewport(Viewport->getRect()); + _renderer->setViewport(Viewport->getRect()); return S_OK; } @@ -3994,8 +3994,8 @@ HRESULT CBGame::PopViewport() { _viewportSP--; if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); - if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->SetViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->SetViewport(_renderer->_drawOffsetX, + if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + else _renderer->setViewport(_renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); @@ -4082,7 +4082,7 @@ HRESULT CBGame::DisplayContent(bool update, bool displayAll) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DisplayContentSimple() { // fill black - _renderer->Fill(0, 0, 0); + _renderer->fill(0, 0, 0); if (_indicatorDisplay) DisplayIndicator(); return S_OK; @@ -4099,11 +4099,11 @@ HRESULT CBGame::DisplayIndicator() { } if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; - _renderer->SetupLines(); + _renderer->setupLines(); for (int i = 0; i < _indicatorHeight; i++) - _renderer->DrawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - _renderer->Setup2D(); + _renderer->setup2D(); return S_OK; } @@ -4255,7 +4255,7 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { if (RefreshMouse) { POINT p; GetMousePos(&p); - SetActiveObject(_renderer->GetObjectAt(p.x, p.y)); + SetActiveObject(_renderer->getObjectAt(p.x, p.y)); } if (Activate) _soundMgr->resumeAll(); @@ -4386,10 +4386,10 @@ HRESULT CBGame::OnMouseMiddleUp() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::OnPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->InitLoop(); + _renderer->initLoop(); DisplayContent(false, true); DisplayDebugInfo(); - _renderer->WindowedBlt(); + _renderer->windowedBlt(); } return S_OK; } @@ -4418,11 +4418,11 @@ HRESULT CBGame::DisplayDebugInfo() { sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); strcat(str, " ("); - strcat(str, _renderer->GetName()); + strcat(str, _renderer->getName()); strcat(str, ")"); _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - _renderer->DisplayDebugInfo(); + _renderer->displayDebugInfo(); int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index f372335cf1..6ddf200b9e 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -66,7 +66,7 @@ CBRenderSDL::~CBRenderSDL() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::InitRenderer(int width, int height, bool windowed) { +HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { //if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; #if 0 @@ -193,7 +193,7 @@ void CBRenderSDL::setColorMod(byte r, byte g, byte b) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Flip() { +HRESULT CBRenderSDL::flip() { #ifdef __IPHONEOS__ // hack: until viewports work correctly, we just paint black bars instead @@ -242,7 +242,7 @@ HRESULT CBRenderSDL::Flip() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { +HRESULT CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); uint32 color = _renderSurface->format.ARGBToColor(0xFF, r, g, b); @@ -260,14 +260,14 @@ HRESULT CBRenderSDL::Fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::Fade(uint16 Alpha) { +HRESULT CBRenderSDL::fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; - return FadeToColor(dwAlpha << 24); + return fadeToColor(dwAlpha << 24); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { +HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -291,7 +291,7 @@ HRESULT CBRenderSDL::FadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setWidth((int16)(rc.right - rc.left)); fillRect.setHeight((int16)(rc.bottom - rc.top)); } - ModTargetRect(&fillRect); + modTargetRect(&fillRect); byte r = D3DCOLGetR(Color); byte g = D3DCOLGetG(Color); @@ -365,7 +365,7 @@ void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *s } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { +HRESULT CBRenderSDL::drawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { static bool hasWarned = false; if (!hasWarned) { warning("CBRenderSDL::DrawLine - not fully ported yet"); @@ -382,11 +382,11 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { POINT point1, point2; point1.x = X1; point1.y = Y1; - PointToScreen(&point1); + pointToScreen(&point1); point2.x = X2; point2.y = Y2; - PointToScreen(&point2); + pointToScreen(&point2); // TODO: This thing is mostly here until I'm sure about the final color-format. uint32 color = _renderSurface->format.ARGBToColor(a, r, g, b); @@ -396,7 +396,7 @@ HRESULT CBRenderSDL::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { } ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderSDL::TakeScreenshot() { +CBImage *CBRenderSDL::takeScreenshot() { // TODO: Fix this warning("CBRenderSDL::TakeScreenshot() - not ported yet"); CBImage *screenshot = new CBImage(Game); @@ -428,7 +428,7 @@ CBImage *CBRenderSDL::TakeScreenshot() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::SwitchFullscreen() { +HRESULT CBRenderSDL::switchFullscreen() { /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); else SDL_SetWindowFullscreen(_win, SDL_FALSE); @@ -440,7 +440,7 @@ HRESULT CBRenderSDL::SwitchFullscreen() { } ////////////////////////////////////////////////////////////////////////// -const char *CBRenderSDL::GetName() { +const char *CBRenderSDL::getName() { if (_name.empty()) { #if 0 if (_renderer) { @@ -454,7 +454,7 @@ const char *CBRenderSDL::GetName() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { +HRESULT CBRenderSDL::setViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. rect.left = (int16)(left + _borderLeft); @@ -470,7 +470,7 @@ HRESULT CBRenderSDL::SetViewport(int left, int top, int right, int bottom) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::ModTargetRect(Common::Rect *rect) { +void CBRenderSDL::modTargetRect(Common::Rect *rect) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -483,7 +483,7 @@ void CBRenderSDL::ModTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::PointFromScreen(POINT *point) { +void CBRenderSDL::pointFromScreen(POINT *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -495,7 +495,7 @@ void CBRenderSDL::PointFromScreen(POINT *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::PointToScreen(POINT *point) { +void CBRenderSDL::pointToScreen(POINT *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -506,7 +506,7 @@ void CBRenderSDL::PointToScreen(POINT *point) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::DumpData(const char *Filename) { +void CBRenderSDL::dumpData(const char *Filename) { warning("CBRenderSDL::DumpData(%s) - not reimplemented yet", Filename); // TODO #if 0 FILE *f = fopen(Filename, "wt"); diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 2a1910790a..e9ca53610a 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -43,38 +43,38 @@ public: CBRenderSDL(CBGame *inGame); ~CBRenderSDL(); - const char *GetName(); + const char *getName(); - HRESULT InitRenderer(int width, int height, bool windowed); - HRESULT Flip(); - HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + HRESULT initRenderer(int width, int height, bool windowed); + HRESULT flip(); + HRESULT fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - HRESULT Fade(uint16 Alpha); - HRESULT FadeToColor(uint32 Color, Common::Rect *rect = NULL); + HRESULT fade(uint16 Alpha); + HRESULT fadeToColor(uint32 Color, Common::Rect *rect = NULL); - HRESULT SwitchFullscreen(); + HRESULT switchFullscreen(); - HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + HRESULT drawLine(int X1, int Y1, int X2, int Y2, uint32 Color); - CBImage *TakeScreenshot(); + CBImage *takeScreenshot(); void setAlphaMod(byte alpha); void setColorMod(byte r, byte g, byte b); void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); void drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); - HRESULT SetViewport(int left, int top, int right, int bottom); + HRESULT setViewport(int left, int top, int right, int bottom); - void ModTargetRect(Common::Rect *rect); - void PointFromScreen(POINT *point); - void PointToScreen(POINT *point); + void modTargetRect(Common::Rect *rect); + void pointFromScreen(POINT *point); + void pointToScreen(POINT *point); - void DumpData(const char *Filename); + void dumpData(const char *Filename); - float GetScaleRatioX() const { + float getScaleRatioX() const { return _ratioX; } - float GetScaleRatioY() const { + float getScaleRatioY() const { return _ratioY; } diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index fa9bec5f4f..3a58cdefb4 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -56,19 +56,19 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBRenderer::~CBRenderer() { - DeleteRectList(); - UnclipCursor(); + deleteRectList(); + unclipCursor(); } ////////////////////////////////////////////////////////////////////// -void CBRenderer::InitLoop() { - DeleteRectList(); +void CBRenderer::initLoop() { + deleteRectList(); } ////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::GetObjectAt(int X, int Y) { +CBObject *CBRenderer::getObjectAt(int X, int Y) { POINT point; point.x = X; point.y = Y; @@ -106,7 +106,7 @@ CBObject *CBRenderer::GetObjectAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -void CBRenderer::DeleteRectList() { +void CBRenderer::deleteRectList() { for (int i = 0; i < _rectList.GetSize(); i++) { delete _rectList[i]; } @@ -116,96 +116,96 @@ void CBRenderer::DeleteRectList() { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SwitchFullscreen() { +HRESULT CBRenderer::switchFullscreen() { return E_FAIL; } ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Flip() { +HRESULT CBRenderer::flip() { return E_FAIL; } ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::InitRenderer(int width, int height, bool windowed) { +HRESULT CBRenderer::initRenderer(int width, int height, bool windowed) { return E_FAIL; } ////////////////////////////////////////////////////////////////////// -void CBRenderer::OnWindowChange() { +void CBRenderer::onWindowChange() { } ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fill(byte r, byte g, byte b, Common::Rect *rect) { +HRESULT CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::WindowedBlt() { +HRESULT CBRenderer::windowedBlt() { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Setup2D(bool Force) { +HRESULT CBRenderer::setup2D(bool Force) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetupLines() { +HRESULT CBRenderer::setupLines() { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { +HRESULT CBRenderer::drawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { +HRESULT CBRenderer::drawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { for (int i = 0; i < Width; i++) { - DrawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up - DrawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down + drawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up + drawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down - DrawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left - DrawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right + drawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left + drawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::Fade(uint16 Alpha) { +HRESULT CBRenderer::fade(uint16 Alpha) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::FadeToColor(uint32 Color, Common::Rect *rect) { +HRESULT CBRenderer::fadeToColor(uint32 Color, Common::Rect *rect) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) { +HRESULT CBRenderer::setViewport(int left, int top, int right, int bottom) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetScreenViewport() { - return SetViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +HRESULT CBRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::SetViewport(RECT *Rect) { - return SetViewport(Rect->left + _drawOffsetX, +HRESULT CBRenderer::setViewport(RECT *Rect) { + return setViewport(Rect->left + _drawOffsetX, Rect->top + _drawOffsetY, Rect->right + _drawOffsetX, Rect->bottom + _drawOffsetY); @@ -213,13 +213,13 @@ HRESULT CBRenderer::SetViewport(RECT *Rect) { ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::TakeScreenshot() { +CBImage *CBRenderer::takeScreenshot() { return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::ClipCursor() { +HRESULT CBRenderer::clipCursor() { /* if (!_windowed) { RECT rc; @@ -238,7 +238,7 @@ HRESULT CBRenderer::ClipCursor() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::UnclipCursor() { +HRESULT CBRenderer::unclipCursor() { /* if (!_windowed) ::ClipCursor(NULL); */ @@ -246,7 +246,7 @@ HRESULT CBRenderer::UnclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::PointInViewport(POINT *P) { +bool CBRenderer::pointInViewport(POINT *P) { if (P->x < _drawOffsetX) return false; if (P->y < _drawOffsetY) return false; if (P->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index a13082b1b2..38925fc57a 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -47,61 +47,61 @@ public: int _drawOffsetX; int _drawOffsetY; - virtual void DumpData(const char *Filename) {}; - virtual CBImage *TakeScreenshot(); - virtual HRESULT SetViewport(int left, int top, int right, int bottom); - virtual HRESULT SetViewport(RECT *Rect); - virtual HRESULT SetScreenViewport(); - virtual HRESULT Fade(uint16 Alpha); - virtual HRESULT FadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual HRESULT DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color); - virtual HRESULT DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); + virtual void dumpData(const char *Filename) {}; + virtual CBImage *takeScreenshot(); + virtual HRESULT setViewport(int left, int top, int right, int bottom); + virtual HRESULT setViewport(RECT *Rect); + virtual HRESULT setScreenViewport(); + virtual HRESULT fade(uint16 Alpha); + virtual HRESULT fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual HRESULT drawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + virtual HRESULT drawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); CBRenderer(CBGame *inGame = NULL); virtual ~CBRenderer(); - virtual HRESULT SetProjection() { + virtual HRESULT setProjection() { return S_OK; }; - virtual HRESULT WindowedBlt(); - virtual HRESULT Fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - virtual void OnWindowChange(); - virtual HRESULT InitRenderer(int width, int height, bool windowed); - virtual HRESULT Flip(); - virtual void InitLoop(); - virtual HRESULT SwitchFullscreen(); - virtual HRESULT Setup2D(bool Force = false); - virtual HRESULT SetupLines(); - - virtual const char *GetName() { + virtual HRESULT windowedBlt(); + virtual HRESULT fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual void onWindowChange(); + virtual HRESULT initRenderer(int width, int height, bool windowed); + virtual HRESULT flip(); + virtual void initLoop(); + virtual HRESULT switchFullscreen(); + virtual HRESULT setup2D(bool Force = false); + virtual HRESULT setupLines(); + + virtual const char *getName() { return ""; }; - virtual HRESULT DisplayDebugInfo() { + virtual HRESULT displayDebugInfo() { return E_FAIL; }; - virtual HRESULT DrawShaderQuad() { + virtual HRESULT drawShaderQuad() { return E_FAIL; } - virtual float GetScaleRatioX() const { + virtual float getScaleRatioX() const { return 1.0f; } - virtual float GetScaleRatioY() const { + virtual float getScaleRatioY() const { return 1.0f; } - HRESULT ClipCursor(); - HRESULT UnclipCursor(); + HRESULT clipCursor(); + HRESULT unclipCursor(); - CBObject *GetObjectAt(int X, int Y); - void DeleteRectList(); + CBObject *getObjectAt(int X, int Y); + void deleteRectList(); - virtual HRESULT StartSpriteBatch() { + virtual HRESULT startSpriteBatch() { return S_OK; }; - virtual HRESULT EndSpriteBatch() { + virtual HRESULT endSpriteBatch() { return S_OK; }; - bool PointInViewport(POINT *P); + bool pointInViewport(POINT *P); uint32 _forceAlphaColor; HINSTANCE _instance; HWND _window; diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 58ddbe5eca..1e54470924 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -54,13 +54,13 @@ HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { // when using opengl on windows it seems to be necessary to do this twice // works normally for direct3d Game->DisplayContent(false); - Game->_renderer->Flip(); + Game->_renderer->flip(); Game->DisplayContent(false); - Game->_renderer->Flip(); + Game->_renderer->flip(); } - CBImage *Screenshot = Game->_renderer->TakeScreenshot(); + CBImage *Screenshot = Game->_renderer->takeScreenshot(); if (!Screenshot) return E_FAIL; // normal thumbnail diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 3bac8ecc78..1a86bf8a90 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -510,7 +510,7 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo position.setWidth((float)srcRect.width() * ZoomX / 100.f); position.setHeight((float)srcRect.height() * ZoomX / 100.f); - renderer->ModTargetRect(&position); + renderer->modTargetRect(&position); /* position.left += offsetX; position.top += offsetY;*/ diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index f61cd9d518..7ddbf21ec9 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -99,7 +99,7 @@ HRESULT CBTransitionMgr::update() { uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((uint16)Alpha); + Game->_renderer->fade((uint16)Alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; } @@ -109,7 +109,7 @@ HRESULT CBTransitionMgr::update() { uint32 time = CBPlatform::GetTime() - _lastTime; int Alpha = (int)((float)time / (float)FADE_DURATION * 255); Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->Fade((uint16)Alpha); + Game->_renderer->fade((uint16)Alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; } diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 0c7606b4f0..9809e50695 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -289,7 +289,7 @@ HRESULT CPartEmitter::updateInternal(uint32 CurrentTime, uint32 TimerDelta) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::display(CBRegion *Region) { - if (_sprites.GetSize() <= 1) Game->_renderer->StartSpriteBatch(); + if (_sprites.GetSize() <= 1) Game->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.GetSize(); i++) { if (Region != NULL && _useRegion) { @@ -299,7 +299,7 @@ HRESULT CPartEmitter::display(CBRegion *Region) { _particles[i]->display(this); } - if (_sprites.GetSize() <= 1) Game->_renderer->EndSpriteBatch(); + if (_sprites.GetSize() <= 1) Game->_renderer->endSpriteBatch(); return S_OK; } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 6817ef047b..9b4c8e7e04 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -193,7 +193,7 @@ bool CBPlatform::GetCursorPos(LPPOINT lpPoint) { lpPoint->x = p.x; lpPoint->y = p.y; - renderer->PointFromScreen(lpPoint); + renderer->pointFromScreen(lpPoint); return true; } @@ -205,7 +205,7 @@ bool CBPlatform::SetCursorPos(int X, int Y) { POINT p; p.x = X; p.y = Y; - renderer->PointToScreen(&p); + renderer->pointToScreen(&p); // TODO //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); return true; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 7025e4c79a..8125678ee4 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -179,7 +179,7 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, boo if (!quickSave) { Game->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); Game->DisplayContent(false); - Game->_renderer->Flip(); + Game->_renderer->flip(); } (it->_value)->SaveTable(Game, persistMgr); @@ -211,7 +211,7 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { for (uint32 i = 0; i < numClasses; i++) { Game->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); Game->DisplayContentSimple(); - Game->_renderer->Flip(); + Game->_renderer->flip(); char *className = persistMgr->getString(); NameMap::iterator mapIt = _nameMap.find(className); @@ -245,7 +245,7 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr, if (counter % 20 == 0) { Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); Game->DisplayContent(false); - Game->_renderer->Flip(); + Game->_renderer->flip(); } } Game->MiniUpdate(); @@ -265,7 +265,7 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *persistMgr) if (i % 20 == 0) { Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); Game->DisplayContentSimple(); - Game->_renderer->Flip(); + Game->_renderer->flip(); } checkHeader("", persistMgr); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index aea658e254..5d1cc53aa3 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -75,7 +75,7 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { int col, row; - Game->_renderer->StartSpriteBatch(); + Game->_renderer->startSpriteBatch(); // top left/right _image->_surface->displayTrans(X, Y, _upLeft); @@ -112,7 +112,7 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { yyy += tile_width; } - Game->_renderer->EndSpriteBatch(); + Game->_renderer->endSpriteBatch(); return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 5d7bade46e..ce1fb05042 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -142,7 +142,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (!_visible) return S_OK; - if (_fadeBackground) Game->_renderer->FadeToColor(_fadeColor); + if (_fadeBackground) Game->_renderer->fadeToColor(_fadeColor); if (_dragging) { _posX += (Game->_mousePos.x - _dragFrom.x); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 91a086af63..cbcd652946 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -208,7 +208,7 @@ int WinterMuteEngine::init() { HRESULT ret; // initialize the renderer - ret = _game->_renderer->InitRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); + ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); if (FAILED(ret)) { _game->LOG(ret, "Error initializing renderer. Exiting."); @@ -278,7 +278,7 @@ int WinterMuteEngine::messageLoop() { _game->DisplayDebugInfo(); // ***** flip - if (!_game->_suspendedRendering) _game->_renderer->Flip(); + if (!_game->_suspendedRendering) _game->_renderer->flip(); if (_game->_loading) _game->LoadGame(_game->_scheduledLoadSlot); } if (_game->_quitting) break; -- cgit v1.2.3 From 7207f20f6a18da76786bc537bd2f931de9024c57 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 02:37:28 +0200 Subject: WINTERMUTE: Fix a few warnings --- engines/wintermute/Base/BGame.cpp | 4 ++-- engines/wintermute/Base/BRenderer.cpp | 6 +++--- engines/wintermute/Base/BStringTable.cpp | 2 +- engines/wintermute/UI/UIEdit.cpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 994dd48b2c..625c154d7d 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1518,7 +1518,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS const char *Key = Stack->Pop()->GetString(); const char *InitVal = Stack->Pop()->GetString(); AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); - Stack->PushString((char *)val.c_str()); + Stack->PushString(val.c_str()); return S_OK; } @@ -2489,7 +2489,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SaveDirectory") == 0) { AnsiString dataDir = GetDataDir(); - _scValue->SetString((char *)dataDir.c_str()); + _scValue->SetString(dataDir.c_str()); return _scValue; } diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 3a58cdefb4..690f16016c 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -38,9 +38,9 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - _instance = NULL; - _window = NULL; - _clipperWindow = NULL; + _instance = 0; + _window = 0; + _clipperWindow = 0; _active = false; _ready = false; _windowed = true; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index f494658906..2136bc4d94 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -73,7 +73,7 @@ HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDu char *CBStringTable::GetKey(const char *Str) { if (Str == NULL || Str[0] != '/') return NULL; - char *value = strchr((char *)Str + 1, '/'); + const char *value = strchr(Str + 1, '/'); if (value == NULL) return NULL; char *key = new char[value - Str]; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 928d04016a..e2d5c1f01e 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -581,7 +581,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { if (_selStart >= _selEnd) { while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; - if (_scrollOffset >= strlen(_text)) break; + if (_scrollOffset >= (int)strlen(_text)) break; } _scrollOffset = MIN(_scrollOffset, _selEnd); @@ -595,7 +595,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; - if (_scrollOffset >= strlen(_text)) break; + if (_scrollOffset >= (int)strlen(_text)) break; } _scrollOffset = MIN(_scrollOffset, _selEnd); @@ -811,7 +811,7 @@ int CUIEdit::DeleteChars(int Start, int End) { ////////////////////////////////////////////////////////////////////////// int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { - if (strlen(_text) + Num > _maxLength) { + if ((int)strlen(_text) + Num > _maxLength) { Num -= (strlen(_text) + Num - _maxLength); } -- cgit v1.2.3 From 831560d03b5d19e64feccdac9ff909ffe9100a39 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 12:33:37 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in AdObject --- engines/wintermute/Ad/AdActor.cpp | 16 ++++++------- engines/wintermute/Ad/AdEntity.cpp | 10 ++++---- engines/wintermute/Ad/AdGame.cpp | 8 +++---- engines/wintermute/Ad/AdInventoryBox.cpp | 6 ++--- engines/wintermute/Ad/AdObject.cpp | 40 ++++++++++++++++---------------- engines/wintermute/Ad/AdObject.h | 36 ++++++++++++++-------------- engines/wintermute/Base/BObject.cpp | 8 +++---- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BSprite.cpp | 2 +- 9 files changed, 64 insertions(+), 64 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index f560bf9049..40c18bbb34 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -521,7 +521,7 @@ HRESULT CAdActor::display() { else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; - if (_active) DisplaySpriteAttachments(true); + if (_active) displaySpriteAttachments(true); if (_currentSprite && _active) { bool Reg = _registrable; @@ -538,7 +538,7 @@ HRESULT CAdActor::display() { } - if (_active) DisplaySpriteAttachments(false); + if (_active) displaySpriteAttachments(false); if (_active && _partEmitter) _partEmitter->display(); @@ -730,17 +730,17 @@ HRESULT CAdActor::update() { if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; - AfterMove(); + afterMove(); } } //Game->QuickMessageForm("%s", _currentSprite->_filename); - UpdateBlockRegion(); + updateBlockRegion(); _ready = (_state == STATE_READY); - UpdatePartEmitter(); - UpdateSpriteAttachments(); + updatePartEmitter(); + updateSpriteAttachments(); return S_OK; } @@ -810,7 +810,7 @@ void CAdActor::GetNextStep() { _posX = (int)_pFX; _posY = (int)_pFY; - AfterMove(); + afterMove(); if (_pFCount == 0) { @@ -1310,7 +1310,7 @@ HRESULT CAdActor::PlayAnim(const char *Filename) { } } // otherwise call the standard handler - return CAdTalkHolder::PlayAnim(Filename); + return CAdTalkHolder::playAnim(Filename); } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index d5e2fe954f..35e9ea7caa 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -506,7 +506,7 @@ HRESULT CAdEntity::display() { Game->_renderer->_rectList.Add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); } - DisplaySpriteAttachments(true); + displaySpriteAttachments(true); if (_theora && (_theora->isPlaying() || _theora->isPaused())) { _theora->display(Alpha); } else if (_currentSprite) { @@ -519,7 +519,7 @@ HRESULT CAdEntity::display() { Rotate, _blendMode); } - DisplaySpriteAttachments(false); + displaySpriteAttachments(false); if (_partEmitter) _partEmitter->display(_region); @@ -598,7 +598,7 @@ HRESULT CAdEntity::update() { } } - UpdateBlockRegion(); + updateBlockRegion(); _ready = (_state == STATE_READY); if (_theora) { @@ -615,8 +615,8 @@ HRESULT CAdEntity::update() { } } - UpdatePartEmitter(); - UpdateSpriteAttachments(); + updatePartEmitter(); + updateSpriteAttachments(); return S_OK; } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 6d1744b3d3..96948c7042 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -259,7 +259,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { if (_scene) { // reset objects - for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->Reset(); + for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->reset(); // reset scene properties _scene->_sFXVolume = 100; @@ -274,7 +274,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { if (SUCCEEDED(ret)) { // invalidate references to the original scene for (int i = 0; i < _objects.GetSize(); i++) { - _objects[i]->InvalidateCurrRegions(); + _objects[i]->invalidateCurrRegions(); _objects[i]->_stickRegion = NULL; } @@ -997,7 +997,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "InventoryObject") == 0) { - if (_inventoryOwner && _inventoryBox) _inventoryOwner->GetInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; if (Value->IsNULL()) _inventoryOwner = _invObject; else { @@ -1006,7 +1006,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } - if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->GetInventory()->_scrollOffset; + if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; return S_OK; } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 9c2d5bbcfc..f7aa67b280 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -108,7 +108,7 @@ HRESULT CAdInventoryBox::display() { if (_window) { _window->EnableWidget("prev", _scrollOffset > 0); - _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()); + _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); } @@ -135,8 +135,8 @@ HRESULT CAdInventoryBox::display() { int xxx = rect.left; for (int i = 0; i < ItemsX; i++) { int ItemIndex = _scrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->GetInventory()->_takenItems.GetSize()) { - CAdItem *item = AdGame->_inventoryOwner->GetInventory()->_takenItems[ItemIndex]; + if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()) { + CAdItem *item = AdGame->_inventoryOwner->getInventory()->_takenItems[ItemIndex]; if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { item->update(); item->display(xxx, yyy); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 6cd37ee040..4a2ec065e9 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -151,7 +151,7 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::PlayAnim(const char *Filename) { +HRESULT CAdObject::playAnim(const char *Filename) { delete _animSprite; _animSprite = NULL; _animSprite = new CBSprite(Game, this); @@ -194,7 +194,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "PlayAnim") == 0 || strcmp(Name, "PlayAnimAsync") == 0) { Stack->CorrectParams(1); - if (FAILED(PlayAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); + if (FAILED(playAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); else { if (strcmp(Name, "PlayAnimAsync") != 0) Script->WaitFor(this); Stack->PushBool(true); @@ -207,7 +207,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Reset") == 0) { Stack->CorrectParams(0); - Reset(); + reset(); Stack->PushNULL(); return S_OK; } @@ -272,7 +272,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); - Talk(Text, Sound, Duration, Stances, (TTextAlign)Align); + talk(Text, Sound, Duration, Stances, (TTextAlign)Align); if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); Stack->PushNULL(); @@ -457,7 +457,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th int OffsetX = Stack->Pop()->GetInt(); int OffsetY = Stack->Pop()->GetInt(); - CPartEmitter *Emitter = CreateParticleEmitter(FollowParent, OffsetX, OffsetY); + CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY); if (Emitter) Stack->PushNative(_partEmitter, true); else Stack->PushNULL(); @@ -687,7 +687,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { // NumItems (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "NumItems") == 0) { - _scValue->SetInt(GetInventory()->_takenItems.GetSize()); + _scValue->SetInt(getInventory()->_takenItems.GetSize()); return _scValue; } @@ -824,7 +824,7 @@ int CAdObject::getHeight() { ////////////////////////////////////////////////////////////////////////// -void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { +void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { if (!_sentence) _sentence = new CAdSentence(Game); if (!_sentence) return; @@ -936,7 +936,7 @@ void CAdObject::Talk(const char *Text, const char *Sound, uint32 Duration, const ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::Reset() { +HRESULT CAdObject::reset() { if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { delete _animSprite; _animSprite = NULL; @@ -1036,7 +1036,7 @@ HRESULT CAdObject::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateBlockRegion() { +HRESULT CAdObject::updateBlockRegion() { CAdGame *AdGame = (CAdGame *)Game; if (AdGame->_scene) { if (_blockRegion && _currentBlockRegion) @@ -1049,7 +1049,7 @@ HRESULT CAdObject::UpdateBlockRegion() { } ////////////////////////////////////////////////////////////////////////// -CAdInventory *CAdObject::GetInventory() { +CAdInventory *CAdObject::getInventory() { if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); @@ -1059,7 +1059,7 @@ CAdInventory *CAdObject::GetInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::AfterMove() { +HRESULT CAdObject::afterMove() { CAdRegion *NewRegions[MAX_NUM_REGIONS]; ((CAdGame *)Game)->_scene->GetRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); @@ -1087,7 +1087,7 @@ HRESULT CAdObject::AfterMove() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::InvalidateCurrRegions() { +HRESULT CAdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; return S_OK; } @@ -1108,7 +1108,7 @@ HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdateSpriteAttachments() { +HRESULT CAdObject::updateSpriteAttachments() { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { _attachmentsPre[i]->update(); } @@ -1119,21 +1119,21 @@ HRESULT CAdObject::UpdateSpriteAttachments() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::DisplaySpriteAttachments(bool PreDisplay) { +HRESULT CAdObject::displaySpriteAttachments(bool PreDisplay) { if (PreDisplay) { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - DisplaySpriteAttachment(_attachmentsPre[i]); + displaySpriteAttachment(_attachmentsPre[i]); } } else { for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - DisplaySpriteAttachment(_attachmentsPost[i]); + displaySpriteAttachment(_attachmentsPost[i]); } } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { +HRESULT CAdObject::displaySpriteAttachment(CAdObject *Attachment) { if (!Attachment->_active) return S_OK; float ScaleX, ScaleY; @@ -1171,7 +1171,7 @@ HRESULT CAdObject::DisplaySpriteAttachment(CAdObject *Attachment) { } ////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { +CPartEmitter *CAdObject::createParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { _partFollowParent = FollowParent; _partOffsetX = OffsetX; _partOffsetY = OffsetY; @@ -1182,12 +1182,12 @@ CPartEmitter *CAdObject::CreateParticleEmitter(bool FollowParent, int OffsetX, i Game->RegisterObject(_partEmitter); } } - UpdatePartEmitter(); + updatePartEmitter(); return _partEmitter; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::UpdatePartEmitter() { +HRESULT CAdObject::updatePartEmitter() { if (!_partEmitter) return E_FAIL; if (_partFollowParent) { diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index ca85da42b0..05548c6dbd 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -46,13 +46,13 @@ class CAdInventory; class CAdObject : public CBObject { public: CPartEmitter *_partEmitter; - virtual CPartEmitter *CreateParticleEmitter(bool FollowParent = false, int OffsetX = 0, int OffsetY = 0); - virtual HRESULT UpdatePartEmitter(); + virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); + virtual HRESULT updatePartEmitter(); bool _partFollowParent; int _partOffsetX; int _partOffsetY; - HRESULT InvalidateCurrRegions(); + HRESULT invalidateCurrRegions(); bool _subtitlesModRelative; bool _subtitlesModXCenter; int _subtitlesModX; @@ -61,23 +61,23 @@ public: CAdRegion *_stickRegion; bool _sceneIndependent; bool _ignoreItems; - HRESULT UpdateBlockRegion(); + HRESULT updateBlockRegion(); bool _forcedTalkAnimUsed; char *_forcedTalkAnimName; - virtual bool getExtendedFlag(const char *FlagName); + virtual bool getExtendedFlag(const char *flagName); virtual HRESULT resetSoundPan(); virtual HRESULT updateSounds(); - HRESULT Reset(); + HRESULT reset(); DECLARE_PERSISTENT(CAdObject, CBObject) - virtual void Talk(const char *Text, const char *Sound = NULL, uint32 Duration = 0, const char *Stances = NULL, TTextAlign Align = TAL_CENTER); + virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); virtual int getHeight(); CAdSentence *_sentence; - HRESULT SetFont(const char *Filename); + HRESULT SetFont(const char *filename); virtual HRESULT update(); virtual HRESULT display(); bool _drawn; bool _active; - virtual HRESULT PlayAnim(const char *Filename); + virtual HRESULT playAnim(const char *filename); CBSprite *_animSprite; CBSprite *_currentSprite; TObjectState _state; @@ -91,27 +91,27 @@ public: CAdWaypointGroup *_wptGroup; CBRegion *_currentBlockRegion; CAdWaypointGroup *_currentWptGroup; - CAdInventory *GetInventory(); + CAdInventory *getInventory(); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT AfterMove(); + virtual HRESULT afterMove(); CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); CBArray _attachmentsPre; CBArray _attachmentsPost; - HRESULT UpdateSpriteAttachments(); - HRESULT DisplaySpriteAttachments(bool PreDisplay); + HRESULT updateSpriteAttachments(); + HRESULT displaySpriteAttachments(bool preDisplay); CAdObject *_registerAlias; private: - HRESULT DisplaySpriteAttachment(CAdObject *Attachment); + HRESULT displaySpriteAttachment(CAdObject *Attachment); CAdInventory *_inventory; protected: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index d117fe3455..7c3acd83a7 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -174,7 +174,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(2); _posX = Stack->Pop()->GetInt(); _posY = Stack->Pop()->GetInt(); - AfterMove(); + afterMove(); Stack->PushNULL(); return S_OK; @@ -680,7 +680,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "X") == 0) { _posX = Value->GetInt(); - AfterMove(); + afterMove(); return S_OK; } @@ -689,7 +689,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Y") == 0) { _posY = Value->GetInt(); - AfterMove(); + afterMove(); return S_OK; } @@ -1115,7 +1115,7 @@ void CBObject::setSoundEvent(const char *eventName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::AfterMove() { +HRESULT CBObject::afterMove() { return S_OK; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 20b6cfdb2a..c289bd1313 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -46,7 +46,7 @@ class CScScript; class CBObject : public CBScriptHolder { public: TSpriteBlendMode _blendMode; - virtual HRESULT AfterMove(); + virtual HRESULT afterMove(); float _relativeRotate; bool _rotateValid; float _rotate; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6ec19c6ba3..6f23649737 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -110,7 +110,7 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom if (_changed && _owner && _owner->_movable) { _owner->_posX += _moveX; _owner->_posY += _moveY; - _owner->AfterMove(); + _owner->afterMove(); X = _owner->_posX; Y = _owner->_posY; -- cgit v1.2.3 From 86513195d1d3378b96a82c17cba4cd8ecd5bb6ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 13:04:17 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in AdTalkNode, AdTalkHolder, AdTalkDef, AdSpriteSet, AdSentence and AdSceneState --- engines/wintermute/Ad/AdActor.cpp | 88 +++++++++--------- engines/wintermute/Ad/AdActor.h | 6 +- engines/wintermute/Ad/AdEntity.cpp | 32 +++---- engines/wintermute/Ad/AdEntity.h | 4 +- engines/wintermute/Ad/AdGame.cpp | 28 +++--- engines/wintermute/Ad/AdGame.h | 4 +- engines/wintermute/Ad/AdInventoryBox.cpp | 10 +- engines/wintermute/Ad/AdInventoryBox.h | 4 +- engines/wintermute/Ad/AdItem.cpp | 32 +++---- engines/wintermute/Ad/AdItem.h | 4 +- engines/wintermute/Ad/AdLayer.cpp | 12 +-- engines/wintermute/Ad/AdLayer.h | 4 +- engines/wintermute/Ad/AdObject.cpp | 16 ++-- engines/wintermute/Ad/AdRegion.cpp | 8 +- engines/wintermute/Ad/AdRegion.h | 4 +- engines/wintermute/Ad/AdResponse.cpp | 6 +- engines/wintermute/Ad/AdResponseBox.cpp | 12 +-- engines/wintermute/Ad/AdResponseBox.h | 4 +- engines/wintermute/Ad/AdRotLevel.cpp | 8 +- engines/wintermute/Ad/AdRotLevel.h | 4 +- engines/wintermute/Ad/AdScaleLevel.cpp | 8 +- engines/wintermute/Ad/AdScaleLevel.h | 4 +- engines/wintermute/Ad/AdScene.cpp | 32 +++---- engines/wintermute/Ad/AdScene.h | 4 +- engines/wintermute/Ad/AdSceneState.cpp | 14 +-- engines/wintermute/Ad/AdSceneState.h | 4 +- engines/wintermute/Ad/AdSentence.cpp | 50 +++++----- engines/wintermute/Ad/AdSentence.h | 18 ++-- engines/wintermute/Ad/AdSpriteSet.cpp | 68 +++++++------- engines/wintermute/Ad/AdSpriteSet.h | 12 +-- engines/wintermute/Ad/AdTalkDef.cpp | 46 +++++----- engines/wintermute/Ad/AdTalkDef.h | 10 +- engines/wintermute/Ad/AdTalkHolder.cpp | 111 +++++++++++------------ engines/wintermute/Ad/AdTalkHolder.h | 10 +- engines/wintermute/Ad/AdTalkNode.cpp | 24 ++--- engines/wintermute/Ad/AdTalkNode.h | 10 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 8 +- engines/wintermute/Ad/AdWaypointGroup.h | 4 +- engines/wintermute/Base/BFont.cpp | 10 +- engines/wintermute/Base/BFont.h | 4 +- engines/wintermute/Base/BFontBitmap.cpp | 8 +- engines/wintermute/Base/BFontBitmap.h | 4 +- engines/wintermute/Base/BFontStorage.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 6 +- engines/wintermute/Base/BFontTT.h | 4 +- engines/wintermute/Base/BFrame.cpp | 2 +- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 26 +++--- engines/wintermute/Base/BGame.h | 4 +- engines/wintermute/Base/BObject.cpp | 4 +- engines/wintermute/Base/BRegion.cpp | 8 +- engines/wintermute/Base/BRegion.h | 4 +- engines/wintermute/Base/BScriptHolder.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 12 +-- engines/wintermute/Base/BSprite.h | 4 +- engines/wintermute/Base/BStringTable.cpp | 2 +- engines/wintermute/Base/BStringTable.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 16 ++-- engines/wintermute/Base/scriptables/ScEngine.h | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 4 +- engines/wintermute/Base/scriptables/ScScript.h | 2 +- engines/wintermute/UI/UIButton.cpp | 38 ++++---- engines/wintermute/UI/UIButton.h | 4 +- engines/wintermute/UI/UIEdit.cpp | 14 +-- engines/wintermute/UI/UIEdit.h | 4 +- engines/wintermute/UI/UIEntity.cpp | 10 +- engines/wintermute/UI/UIEntity.h | 4 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 14 +-- engines/wintermute/UI/UIText.h | 4 +- engines/wintermute/UI/UITiledImage.cpp | 8 +- engines/wintermute/UI/UITiledImage.h | 4 +- engines/wintermute/UI/UIWindow.cpp | 30 +++--- engines/wintermute/UI/UIWindow.h | 4 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/wintermute.cpp | 2 +- 77 files changed, 504 insertions(+), 505 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 40c18bbb34..67b5b42336 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -123,7 +123,7 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::LoadFile(const char *Filename) { +HRESULT CAdActor::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); @@ -135,7 +135,7 @@ HRESULT CAdActor::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); delete [] Buffer; @@ -183,7 +183,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdActor::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -241,7 +241,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: @@ -291,19 +291,19 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { delete _walkSprite; _walkSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; else _walkSprite = spr; break; case TOKEN_TALK: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); break; case TOKEN_TALK_SPECIAL: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); break; @@ -311,7 +311,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { delete _standSprite; _standSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; else _standSprite = spr; break; @@ -319,7 +319,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { delete _turnLeftSprite; _turnLeftSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnLeftSprite = spr; break; @@ -327,7 +327,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { delete _turnRightSprite; _turnRightSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->LoadBuffer(params, true))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnRightSprite = spr; break; @@ -338,7 +338,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -380,7 +380,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + if (!rgn || !crgn || FAILED(rgn->loadBuffer(params, false))) { delete _blockRegion; delete _currentBlockRegion; _blockRegion = NULL; @@ -401,7 +401,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + if (!wpt || !cwpt || FAILED(wpt->loadBuffer(params, false))) { delete _wptGroup; delete _currentWptGroup; _wptGroup = NULL; @@ -433,7 +433,7 @@ HRESULT CAdActor::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (!Anim || FAILED(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else _anims.Add(Anim); } break; @@ -573,17 +573,17 @@ HRESULT CAdActor::update() { _currentSprite = _animSprite2; } - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->finish(); // default: stand animation if (!_currentSprite) { if (_sprite) _currentSprite = _sprite; else { if (_standSprite) { - _currentSprite = _standSprite->GetSprite(_dir); + _currentSprite = _standSprite->getSprite(_dir); } else { CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); + if (Anim) _currentSprite = Anim->getSprite(_dir); } } } @@ -613,10 +613,10 @@ HRESULT CAdActor::update() { _nextState = STATE_READY; } else { if (_turnLeftSprite) { - _tempSprite2 = _turnLeftSprite->GetSprite(_dir); + _tempSprite2 = _turnLeftSprite->getSprite(_dir); } else { CAdSpriteSet *Anim = GetAnimByName(_turnLeftAnimName); - if (Anim) _tempSprite2 = Anim->GetSprite(_dir); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); } if (_tempSprite2) { @@ -642,10 +642,10 @@ HRESULT CAdActor::update() { _nextState = STATE_READY; } else { if (_turnRightSprite) { - _tempSprite2 = _turnRightSprite->GetSprite(_dir); + _tempSprite2 = _turnRightSprite->getSprite(_dir); } else { CAdSpriteSet *Anim = GetAnimByName(_turnRightAnimName); - if (Anim) _tempSprite2 = Anim->GetSprite(_dir); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); } if (_tempSprite2) { @@ -687,12 +687,12 @@ HRESULT CAdActor::update() { bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - _sentence->Finish(); + _sentence->finish(); _tempSprite2 = NULL; _state = _nextState; _nextState = STATE_READY; } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { _tempSprite2->Reset(); _currentSprite = _tempSprite2; @@ -712,10 +712,10 @@ HRESULT CAdActor::update() { if (_sprite) _currentSprite = _sprite; else { if (_standSprite) { - _currentSprite = _standSprite->GetSprite(_dir); + _currentSprite = _standSprite->getSprite(_dir); } else { CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); + if (Anim) _currentSprite = Anim->getSprite(_dir); } } } @@ -769,10 +769,10 @@ void CAdActor::FollowPath() { ////////////////////////////////////////////////////////////////////////// void CAdActor::GetNextStep() { if (_walkSprite) { - _currentSprite = _walkSprite->GetSprite(_dir); + _currentSprite = _walkSprite->getSprite(_dir); } else { CAdSpriteSet *Anim = GetAnimByName(_walkAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); + if (Anim) _currentSprite = Anim->getSprite(_dir); } if (!_currentSprite) return; @@ -943,9 +943,9 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi for (int i = 0; i < _anims.GetSize(); i++) { if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { // invalidate sprites in use - if (_anims[i]->ContainsSprite(_tempSprite2)) _tempSprite2 = NULL; - if (_anims[i]->ContainsSprite(_currentSprite)) _currentSprite = NULL; - if (_anims[i]->ContainsSprite(_animSprite2)) _animSprite2 = NULL; + if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; + if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; + if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; delete _anims[i]; _anims[i] = NULL; @@ -1101,14 +1101,14 @@ const char *CAdActor::scToString() { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStance(const char *Stance) { +CBSprite *CAdActor::getTalkStance(const char *Stance) { // forced stance? if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; delete _animSprite; _animSprite = new CBSprite(Game, this); if (_animSprite) { - HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); + HRESULT res = _animSprite->loadFile(_forcedTalkAnimName); if (FAILED(res)) { Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; @@ -1126,7 +1126,7 @@ CBSprite *CAdActor::GetTalkStance(const char *Stance) { // do we have an animation with this name? CAdSpriteSet *Anim = GetAnimByName(Stance); - if (Anim) Ret = Anim->GetSprite(_dir); + if (Anim) Ret = Anim->getSprite(_dir); // not - get a random talk if (!Ret) { @@ -1138,12 +1138,12 @@ CBSprite *CAdActor::GetTalkStance(const char *Stance) { if (TalkAnims.GetSize() > 0) { int rnd = g_wintermute->randInt(0, TalkAnims.GetSize() - 1); - Ret = TalkAnims[rnd]->GetSprite(_dir); + Ret = TalkAnims[rnd]->getSprite(_dir); } else { - if (_standSprite) Ret = _standSprite->GetSprite(_dir); + if (_standSprite) Ret = _standSprite->getSprite(_dir); else { Anim = GetAnimByName(_idleAnimName); - if (Anim) Ret = Anim->GetSprite(_dir); + if (Anim) Ret = Anim->getSprite(_dir); } } } @@ -1158,7 +1158,7 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { // search special stances for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { - ret = _talkSpritesEx[i]->GetSprite(_dir); + ret = _talkSpritesEx[i]->getSprite(_dir); break; } } @@ -1166,7 +1166,7 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { // search generic stances for (int i = 0; i < _talkSprites.GetSize(); i++) { if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { - ret = _talkSprites[i]->GetSprite(_dir); + ret = _talkSprites[i]->getSprite(_dir); break; } } @@ -1175,11 +1175,11 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.GetSize() < 1) ret = _standSprite->GetSprite(_dir); + if (_talkSprites.GetSize() < 1) ret = _standSprite->getSprite(_dir); else { // TODO: remember last int rnd = g_wintermute->randInt(0, _talkSprites.GetSize() - 1); - ret = _talkSprites[rnd]->GetSprite(_dir); + ret = _talkSprites[rnd]->getSprite(_dir); } } @@ -1241,10 +1241,10 @@ TDirection CAdActor::AngleToDirection(int Angle) { int CAdActor::getHeight() { // if no current sprite is set, set some if (_currentSprite == NULL) { - if (_standSprite) _currentSprite = _standSprite->GetSprite(_dir); + if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); else { CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->GetSprite(_dir); + if (Anim) _currentSprite = Anim->getSprite(_dir); } } // and get height @@ -1285,7 +1285,7 @@ HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { switch (cmd) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->LoadBuffer(params, false))) { + if (!Anim || FAILED(Anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = E_FAIL; } else _anims.Add(Anim); @@ -1302,7 +1302,7 @@ HRESULT CAdActor::PlayAnim(const char *Filename) { // if we have an anim with this name, use it CAdSpriteSet *Anim = GetAnimByName(Filename); if (Anim) { - _animSprite2 = Anim->GetSprite(_dir); + _animSprite2 = Anim->getSprite(_dir); if (_animSprite2) { _animSprite2->Reset(); _state = STATE_PLAYING_ANIM_SET; diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index ab1b8a775e..50444d844a 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -49,7 +49,7 @@ public: TDirection AngleToDirection(int Angle); DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) virtual int getHeight(); - CBSprite *GetTalkStance(const char *Stance); + CBSprite *getTalkStance(const char *Stance); virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); CBPoint *_targetPoint; virtual HRESULT update(); @@ -67,8 +67,8 @@ public: TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); // new anim system Common::String _talkAnimName; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 35e9ea7caa..b872251b85 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -84,7 +84,7 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::LoadFile(const char *Filename) { +HRESULT CAdEntity::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); @@ -96,7 +96,7 @@ HRESULT CAdEntity::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); delete [] Buffer; @@ -150,7 +150,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -214,7 +214,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: @@ -229,21 +229,21 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { delete _sprite; _sprite = NULL; spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; else _sprite = spr; } break; case TOKEN_TALK: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); } break; @@ -306,7 +306,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -321,7 +321,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { if (_region) Game->UnregisterObject(_region); _region = NULL; CBRegion *rgn = new CBRegion(Game); - if (!rgn || FAILED(rgn->LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (!rgn || FAILED(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else { _region = rgn; Game->RegisterObject(_region); @@ -336,7 +336,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->LoadBuffer(params, false))) { + if (!rgn || !crgn || FAILED(rgn->loadBuffer(params, false))) { delete _blockRegion; _blockRegion = NULL; delete _currentBlockRegion; @@ -357,7 +357,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->LoadBuffer(params, false))) { + if (!wpt || !cwpt || FAILED(wpt->loadBuffer(params, false))) { delete _wptGroup; _wptGroup = NULL; delete _currentWptGroup; @@ -381,7 +381,7 @@ HRESULT CAdEntity::LoadBuffer(byte *Buffer, bool Complete) { _sprite = NULL; if (Game->_editorMode) { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; else _sprite = spr; } if (Game->_editorMode) _editorOnly = true; @@ -543,7 +543,7 @@ HRESULT CAdEntity::update() { _currentSprite = _animSprite; } - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->finish(); // default: stand animation if (!_currentSprite) _currentSprite = _sprite; @@ -568,11 +568,11 @@ HRESULT CAdEntity::update() { bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - _sentence->Finish(); + _sentence->finish(); _tempSprite2 = NULL; _state = STATE_READY; } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { _tempSprite2->Reset(); _currentSprite = _tempSprite2; @@ -1013,7 +1013,7 @@ HRESULT CAdEntity::SetSprite(const char *Filename) { delete _sprite; _sprite = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(Filename))) { delete _sprite; _sprite = NULL; return E_FAIL; diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 28e491cd4e..0d6864d8eb 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -51,8 +51,8 @@ public: virtual HRESULT display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); TEntityType _subtype; // scripting interface diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 96948c7042..72e17e9d02 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -268,8 +268,8 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { HRESULT ret; if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { _initialScene = false; - ret = _scene->LoadFile(_debugStartupScene); - } else ret = _scene->LoadFile(Filename); + ret = _scene->loadFile(_debugStartupScene); + } else ret = _scene->loadFile(Filename); if (SUCCEEDED(ret)) { // invalidate references to the original scene @@ -347,7 +347,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "LoadActor") == 0) { Stack->CorrectParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(Stack->Pop()->GetString()))) { AddObject(act); Stack->PushNative(act, true); } else { @@ -364,7 +364,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "LoadEntity") == 0) { Stack->CorrectParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(Stack->Pop()->GetString()))) { AddObject(ent); Stack->PushNative(ent, true); } else { @@ -704,7 +704,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Game->UnregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->LoadFile(Filename))) { + if (_responseBox && !FAILED(_responseBox->loadFile(Filename))) { RegisterObject(_responseBox); Stack->PushBool(true); } else { @@ -724,7 +724,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Game->UnregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->LoadFile(Filename))) { + if (_inventoryBox && !FAILED(_inventoryBox->loadFile(Filename))) { RegisterObject(_inventoryBox); Stack->PushBool(true); } else { @@ -1114,7 +1114,7 @@ HRESULT CAdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadFile(const char *Filename) { +HRESULT CAdGame::loadFile(const char *Filename) { byte *Buffer = _fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); @@ -1126,7 +1126,7 @@ HRESULT CAdGame::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); delete [] Buffer; @@ -1150,7 +1150,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1174,7 +1174,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - if (FAILED(CBGame::LoadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (FAILED(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; break; case TOKEN_AD_GAME: @@ -1183,7 +1183,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_RESPONSE_BOX: delete _responseBox; _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->LoadFile((char *)params2))) + if (_responseBox && !FAILED(_responseBox->loadFile((char *)params2))) RegisterObject(_responseBox); else { delete _responseBox; @@ -1195,7 +1195,7 @@ HRESULT CAdGame::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->LoadFile((char *)params2))) + if (_inventoryBox && !FAILED(_inventoryBox->loadFile((char *)params2))) RegisterObject(_inventoryBox); else { delete _inventoryBox; @@ -1423,7 +1423,7 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { switch (cmd) { case TOKEN_ITEM: { CAdItem *item = new CAdItem(Game); - if (item && !FAILED(item->LoadBuffer(params, false))) { + if (item && !FAILED(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (Merge) { CAdItem *PrevItem = GetItemByName(item->_name); @@ -1496,7 +1496,7 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { switch (cmd) { case TOKEN_ENTITY_CONTAINER: { CUIEntity *ent = new CUIEntity(Game); - if (!ent || FAILED(ent->LoadBuffer((byte *)*params, false))) { + if (!ent || FAILED(ent->loadBuffer((byte *)*params, false))) { delete ent; ent = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 287421c2a4..10f99b345a 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -140,8 +140,8 @@ public: CBArray _responsesBranch; CBArray _responsesGame; - virtual HRESULT LoadFile(const char *Filename); - virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT loadFile(const char *Filename); + virtual HRESULT loadBuffer(byte *Buffer, bool Complete = true); HRESULT LoadItemsFile(const char *Filename, bool Merge = false); HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index f7aa67b280..76d00e8a4d 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -154,7 +154,7 @@ HRESULT CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::LoadFile(const char *Filename) { +HRESULT CAdInventoryBox::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); @@ -166,7 +166,7 @@ HRESULT CAdInventoryBox::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); delete [] Buffer; @@ -192,7 +192,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -227,7 +227,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -241,7 +241,7 @@ HRESULT CAdInventoryBox::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_WINDOW: delete _window; _window = new CUIWindow(Game); - if (!_window || FAILED(_window->LoadBuffer(params, false))) { + if (!_window || FAILED(_window->loadBuffer(params, false))) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index f0900406ad..3e8714ae8f 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -53,8 +53,8 @@ public: CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 31bc3c7644..8d8de1a48c 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -84,7 +84,7 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::LoadFile(const char *Filename) { +HRESULT CAdItem::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); @@ -96,7 +96,7 @@ HRESULT CAdItem::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); delete [] Buffer; @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdItem::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -180,7 +180,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -199,7 +199,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SPRITE: delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_sprite || FAILED(_sprite->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _sprite; cmd = PARSERR_GENERIC; } @@ -209,7 +209,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SPRITE_HOVER: delete _spriteHover; _spriteHover = new CBSprite(Game, this); - if (!_spriteHover || FAILED(_spriteHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_spriteHover || FAILED(_spriteHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _spriteHover; cmd = PARSERR_GENERIC; } @@ -243,14 +243,14 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_TALK: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); } break; @@ -258,7 +258,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursorNormal; _cursorNormal = new CBSprite(Game); - if (!_cursorNormal || FAILED(_cursorNormal->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_cursorNormal || FAILED(_cursorNormal->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _cursorNormal; _cursorNormal = NULL; cmd = PARSERR_GENERIC; @@ -268,7 +268,7 @@ HRESULT CAdItem::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR_HOVER: delete _cursorHover; _cursorHover = new CBSprite(Game); - if (!_cursorHover || FAILED(_cursorHover->LoadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_cursorHover || FAILED(_cursorHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _cursorHover; _cursorHover = NULL; cmd = PARSERR_GENERIC; @@ -333,7 +333,7 @@ HRESULT CAdItem::update() { _currentSprite = _animSprite; } - if (_sentence && _state != STATE_TALKING) _sentence->Finish(); + if (_sentence && _state != STATE_TALKING) _sentence->finish(); // default: stand animation if (!_currentSprite) _currentSprite = _sprite; @@ -360,11 +360,11 @@ HRESULT CAdItem::update() { bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { - _sentence->Finish(); + _sentence->finish(); _tempSprite2 = NULL; _state = STATE_READY; } else { - _tempSprite2 = GetTalkStance(_sentence->GetNextStance()); + _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { _tempSprite2->Reset(); _currentSprite = _tempSprite2; @@ -444,7 +444,7 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This delete _spriteHover; _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); } else { @@ -487,7 +487,7 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This delete _cursorNormal; _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->LoadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); } else { @@ -530,7 +530,7 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This delete _cursorHover; _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->LoadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(Filename))) { Stack->PushBool(false); Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); } else { diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index d394310172..201e2450fb 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -55,8 +55,8 @@ public: CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 0967fd74c9..37ff0a43b2 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -61,7 +61,7 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::LoadFile(const char *Filename) { +HRESULT CAdLayer::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); @@ -73,7 +73,7 @@ HRESULT CAdLayer::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); delete [] Buffer; @@ -100,7 +100,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -134,7 +134,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -168,7 +168,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_REGION: { CAdRegion *region = new CAdRegion(Game); CAdSceneNode *node = new CAdSceneNode(Game); - if (!region || !node || FAILED(region->LoadBuffer(params, false))) { + if (!region || !node || FAILED(region->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete region; delete node; @@ -185,7 +185,7 @@ HRESULT CAdLayer::LoadBuffer(byte *Buffer, bool Complete) { CAdEntity *entity = new CAdEntity(Game); CAdSceneNode *node = new CAdSceneNode(Game); if (entity) entity->_zoomable = false; // scene entites default to NOT zoom - if (!entity || !node || FAILED(entity->LoadBuffer(params, false))) { + if (!entity || !node || FAILED(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; delete node; diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 69208298a7..824e843828 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -42,8 +42,8 @@ public: CAdLayer(CBGame *inGame); virtual ~CAdLayer(); CBArray _nodes; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 4a2ec065e9..6602093a0d 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -159,7 +159,7 @@ HRESULT CAdObject::playAnim(const char *Filename) { Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); return E_FAIL; } - HRESULT res = _animSprite->LoadFile(Filename); + HRESULT res = _animSprite->loadFile(Filename); if (FAILED(res)) { Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); delete _animSprite; @@ -226,7 +226,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { Stack->CorrectParams(0); - if (_sentence) _sentence->Finish(); + if (_sentence) _sentence->finish(); if (_state == STATE_TALKING) { _state = _nextState; _nextState = STATE_READY; @@ -490,7 +490,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th HRESULT res; CAdEntity *Ent = new CAdEntity(Game); - if (FAILED(res = Ent->LoadFile(Filename))) { + if (FAILED(res = Ent->loadFile(Filename))) { delete Ent; Ent = NULL; Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); @@ -837,9 +837,9 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const delete(_sentence->_sound); _sentence->_sound = NULL; - _sentence->SetText(Text); + _sentence->setText(Text); Game->_stringTable->Expand(&_sentence->_text); - _sentence->SetStances(Stances); + _sentence->setStances(Stances); _sentence->_duration = Duration; _sentence->_align = Align; _sentence->_startTime = Game->_timer; @@ -863,7 +863,7 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const if (Sound) { CBSound *snd = new CBSound(Game); if (snd && SUCCEEDED(snd->setSound(Sound, SOUND_SPEECH, true))) { - _sentence->SetSound(snd); + _sentence->setSound(snd); if (_sentence->_duration <= 0) { uint32 Length = snd->getLength(); if (Length != 0) _sentence->_duration = Length; @@ -927,7 +927,7 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const _sentence->_fixedPos = !_subtitlesModRelative; - _sentence->SetupTalkFile(Sound); + _sentence->setupTalkFile(Sound); _state = STATE_TALKING; @@ -941,7 +941,7 @@ HRESULT CAdObject::reset() { delete _animSprite; _animSprite = NULL; } else if (_state == STATE_TALKING && _sentence) { - _sentence->Finish(); + _sentence->finish(); } _state = _nextState = STATE_READY; diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index d7346665e5..3e4fe2ea6d 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -54,7 +54,7 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::LoadFile(const char *Filename) { +HRESULT CAdRegion::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); @@ -66,7 +66,7 @@ HRESULT CAdRegion::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); delete [] Buffer; @@ -95,7 +95,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdRegion::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -136,7 +136,7 @@ HRESULT CAdRegion::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 2608aae77c..86bd577d3f 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -42,8 +42,8 @@ public: bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index cd67a7c0f7..2b1b9efded 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -75,7 +75,7 @@ void CAdResponse::SetText(const char *Text) { HRESULT CAdResponse::SetIcon(const char *Filename) { delete _icon; _icon = new CBSprite(Game); - if (!_icon || FAILED(_icon->LoadFile(Filename))) { + if (!_icon || FAILED(_icon->loadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); delete _icon; _icon = NULL; @@ -99,7 +99,7 @@ HRESULT CAdResponse::SetFont(const char *Filename) { HRESULT CAdResponse::SetIconHover(const char *Filename) { delete _iconHover; _iconHover = new CBSprite(Game); - if (!_iconHover || FAILED(_iconHover->LoadFile(Filename))) { + if (!_iconHover || FAILED(_iconHover->loadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); delete _iconHover; _iconHover = NULL; @@ -113,7 +113,7 @@ HRESULT CAdResponse::SetIconHover(const char *Filename) { HRESULT CAdResponse::SetIconPressed(const char *Filename) { delete _iconPressed; _iconPressed = new CBSprite(Game); - if (!_iconPressed || FAILED(_iconPressed->LoadFile(Filename))) { + if (!_iconPressed || FAILED(_iconPressed->loadFile(Filename))) { Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); delete _iconPressed; _iconPressed = NULL; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 39caffe00f..bf449214e1 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -187,7 +187,7 @@ HRESULT CAdResponseBox::CreateButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::LoadFile(const char *Filename) { +HRESULT CAdResponseBox::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); @@ -199,7 +199,7 @@ HRESULT CAdResponseBox::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); delete [] Buffer; @@ -223,7 +223,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdResponseBox::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -255,13 +255,13 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_WINDOW: delete _window; _window = new CUIWindow(Game); - if (!_window || FAILED(_window->LoadBuffer(params, false))) { + if (!_window || FAILED(_window->loadBuffer(params, false))) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; @@ -311,7 +311,7 @@ HRESULT CAdResponseBox::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 0f719ab6c1..82a5b4fae5 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -75,8 +75,8 @@ public: RECT _responseArea; int _verticalAlign; TTextAlign _align; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index e2d82ed952..f1c866c91e 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -53,7 +53,7 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::LoadFile(const char *Filename) { +HRESULT CAdRotLevel::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); @@ -65,7 +65,7 @@ HRESULT CAdRotLevel::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); delete [] Buffer; @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdRotLevel::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -106,7 +106,7 @@ HRESULT CAdRotLevel::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index 5701055a97..cfa6f88f1c 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -40,8 +40,8 @@ public: virtual ~CAdRotLevel(); float _rotation; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 3ed0d93f46..e7a54eb927 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -51,7 +51,7 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::LoadFile(const char *Filename) { +HRESULT CAdScaleLevel::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); @@ -63,7 +63,7 @@ HRESULT CAdScaleLevel::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); delete [] Buffer; @@ -80,7 +80,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdScaleLevel::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -104,7 +104,7 @@ HRESULT CAdScaleLevel::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_Y: diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index 2026a1ff58..a00197620c 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -41,8 +41,8 @@ public: CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 670fb7283d..1b9df6211c 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -503,7 +503,7 @@ HRESULT CAdScene::InitLoop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadFile(const char *Filename) { +HRESULT CAdScene::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); @@ -516,7 +516,7 @@ HRESULT CAdScene::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); @@ -568,7 +568,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -630,7 +630,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -643,7 +643,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_LAYER: { CAdLayer *layer = new CAdLayer(Game); - if (!layer || FAILED(layer->LoadBuffer(params, false))) { + if (!layer || FAILED(layer->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete layer; layer = NULL; @@ -661,7 +661,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_WAYPOINTS: { CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - if (!wpt || FAILED(wpt->LoadBuffer(params, false))) { + if (!wpt || FAILED(wpt->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete wpt; wpt = NULL; @@ -674,7 +674,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SCALE_LEVEL: { CAdScaleLevel *sl = new CAdScaleLevel(Game); - if (!sl || FAILED(sl->LoadBuffer(params, false))) { + if (!sl || FAILED(sl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete sl; sl = NULL; @@ -687,7 +687,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ROTATION_LEVEL: { CAdRotLevel *rl = new CAdRotLevel(Game); - if (!rl || FAILED(rl->LoadBuffer(params, false))) { + if (!rl || FAILED(rl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete rl; rl = NULL; @@ -700,7 +700,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_ENTITY: { CAdEntity *entity = new CAdEntity(Game); - if (!entity || FAILED(entity->LoadBuffer(params, false))) { + if (!entity || FAILED(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; entity = NULL; @@ -713,7 +713,7 @@ HRESULT CAdScene::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -1255,7 +1255,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (strcmp(Name, "LoadActor") == 0) { Stack->CorrectParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->LoadFile(Stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(Stack->Pop()->GetString()))) { AddObject(act); Stack->PushNative(act, true); } else { @@ -1272,7 +1272,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi else if (strcmp(Name, "LoadEntity") == 0) { Stack->CorrectParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->LoadFile(Stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(Stack->Pop()->GetString()))) { AddObject(ent); Stack->PushNative(ent, true); } else { @@ -2504,7 +2504,7 @@ HRESULT CAdScene::PersistState(bool Saving) { switch (node->_type) { case OBJECT_ENTITY: if (!node->_entity->_saveState) continue; - NodeState = State->GetNodeState(node->_entity->_name, Saving); + NodeState = State->getNodeState(node->_entity->_name, Saving); if (NodeState) { NodeState->TransferEntity(node->_entity, _persistentStateSprites, Saving); //if(Saving) NodeState->_active = node->_entity->_active; @@ -2513,7 +2513,7 @@ HRESULT CAdScene::PersistState(bool Saving) { break; case OBJECT_REGION: if (!node->_region->_saveState) continue; - NodeState = State->GetNodeState(node->_region->_name, Saving); + NodeState = State->getNodeState(node->_region->_name, Saving); if (NodeState) { if (Saving) NodeState->_active = node->_region->_active; else node->_region->_active = NodeState->_active; @@ -2530,7 +2530,7 @@ HRESULT CAdScene::PersistState(bool Saving) { for (i = 0; i < _objects.GetSize(); i++) { if (!_objects[i]->_saveState) continue; if (_objects[i]->_type == OBJECT_ENTITY) { - NodeState = State->GetNodeState(_objects[i]->_name, Saving); + NodeState = State->getNodeState(_objects[i]->_name, Saving); if (NodeState) { NodeState->TransferEntity((CAdEntity *)_objects[i], _persistentStateSprites, Saving); //if(Saving) NodeState->_active = _objects[i]->_active; @@ -2541,7 +2541,7 @@ HRESULT CAdScene::PersistState(bool Saving) { // waypoint groups for (i = 0; i < _waypointGroups.GetSize(); i++) { - NodeState = State->GetNodeState(_waypointGroups[i]->_name, Saving); + NodeState = State->getNodeState(_waypointGroups[i]->_name, Saving); if (NodeState) { if (Saving) NodeState->_active = _waypointGroups[i]->_active; else _waypointGroups[i]->_active = NodeState->_active; diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 6587418dd9..8061136dcc 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -123,8 +123,8 @@ public: CBArray _layers; CBArray _objects; CBArray _waypointGroups; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); int _width; int _height; HRESULT AddObject(CAdObject *Object); diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 7c1a5d9378..ffa1dfe84f 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -63,22 +63,22 @@ HRESULT CAdSceneState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdSceneState::setFilename(const char *Filename) { +void CAdSceneState::setFilename(const char *filename) { delete[] _filename; - _filename = new char [strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); } ////////////////////////////////////////////////////////////////////////// -CAdNodeState *CAdSceneState::GetNodeState(char *Name, bool Saving) { +CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { for (int i = 0; i < _nodeStates.GetSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, Name) == 0) return _nodeStates[i]; + if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; } - if (Saving) { + if (saving) { CAdNodeState *ret = new CAdNodeState(Game); - ret->setName(Name); + ret->setName(name); _nodeStates.Add(ret); return ret; diff --git a/engines/wintermute/Ad/AdSceneState.h b/engines/wintermute/Ad/AdSceneState.h index 2b91a53a4f..d81c7b31cb 100644 --- a/engines/wintermute/Ad/AdSceneState.h +++ b/engines/wintermute/Ad/AdSceneState.h @@ -37,8 +37,8 @@ namespace WinterMute { class CAdNodeState; class CAdSceneState : public CBBase { public: - CAdNodeState *GetNodeState(char *Name, bool Saving); - void setFilename(const char *Filename); + CAdNodeState *getNodeState(char *name, bool saving); + void setFilename(const char *filename); DECLARE_PERSISTENT(CAdSceneState, CBBase) CAdSceneState(CBGame *inGame); virtual ~CAdSceneState(); diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index d7bf67d7af..a153c86854 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -91,38 +91,38 @@ CAdSentence::~CAdSentence() { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetText(const char *Text) { +void CAdSentence::setText(const char *text) { if (_text) delete [] _text; - _text = new char[strlen(Text) + 1]; - if (_text) strcpy(_text, Text); + _text = new char[strlen(text) + 1]; + if (_text) strcpy(_text, text); } ////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetStances(const char *Stances) { +void CAdSentence::setStances(const char *stances) { if (_stances) delete [] _stances; - if (Stances) { - _stances = new char[strlen(Stances) + 1]; - if (_stances) strcpy(_stances, Stances); + if (stances) { + _stances = new char[strlen(stances) + 1]; + if (_stances) strcpy(_stances, stances); } else _stances = NULL; } ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetCurrentStance() { - return GetStance(_currentStance); +char *CAdSentence::getCurrentStance() { + return getStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetNextStance() { +char *CAdSentence::getNextStance() { _currentStance++; - return GetStance(_currentStance); + return getStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::GetStance(int Stance) { +char *CAdSentence::getStance(int Stance) { if (_stances == NULL) return NULL; if (_tempStance) delete [] _tempStance; @@ -195,16 +195,16 @@ HRESULT CAdSentence::display() { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::SetSound(CBSound *Sound) { - if (!Sound) return; +void CAdSentence::setSound(CBSound *sound) { + if (!sound) return; delete _sound; - _sound = Sound; + _sound = sound; _soundStarted = false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::Finish() { +HRESULT CAdSentence::finish() { if (_sound) _sound->stop(); return S_OK; } @@ -238,16 +238,16 @@ HRESULT CAdSentence::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { +HRESULT CAdSentence::setupTalkFile(const char *soundFilename) { delete _talkDef; _talkDef = NULL; _currentSprite = NULL; - if (!SoundFilename) return S_OK; + if (!soundFilename) return S_OK; - AnsiString path = PathUtil::GetDirectoryName(SoundFilename); - AnsiString name = PathUtil::GetFileNameWithoutExtension(SoundFilename); + AnsiString path = PathUtil::GetDirectoryName(soundFilename); + AnsiString name = PathUtil::GetFileNameWithoutExtension(soundFilename); AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); @@ -258,7 +258,7 @@ HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { _talkDef = new CAdTalkDef(Game); - if (!_talkDef || FAILED(_talkDef->LoadFile(talkDefFileName.c_str()))) { + if (!_talkDef || FAILED(_talkDef->loadFile(talkDefFileName.c_str()))) { delete _talkDef; _talkDef = NULL; return E_FAIL; @@ -270,7 +270,7 @@ HRESULT CAdSentence::SetupTalkFile(const char *SoundFilename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::update(TDirection Dir) { +HRESULT CAdSentence::update(TDirection dir) { if (!_talkDef) return S_OK; uint32 CurrentTime; @@ -284,10 +284,10 @@ HRESULT CAdSentence::update(TDirection Dir) { bool TalkNodeFound = false; for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { - if (_talkDef->_nodes[i]->IsInTimeInterval(CurrentTime, Dir)) { + if (_talkDef->_nodes[i]->isInTimeInterval(CurrentTime, dir)) { TalkNodeFound = true; - CBSprite *NewSprite = _talkDef->_nodes[i]->GetSprite(Dir); + CBSprite *NewSprite = _talkDef->_nodes[i]->getSprite(dir); if (NewSprite != _currentSprite) NewSprite->Reset(); _currentSprite = NewSprite; @@ -298,7 +298,7 @@ HRESULT CAdSentence::update(TDirection Dir) { // no talk node, try to use default sprite instead (if any) if (!TalkNodeFound) { - CBSprite *NewSprite = _talkDef->GetDefaultSprite(Dir); + CBSprite *NewSprite = _talkDef->getDefaultSprite(dir); if (NewSprite) { if (NewSprite != _currentSprite) NewSprite->Reset(); _currentSprite = NewSprite; diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 675cb9d744..7a5fe6e891 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -45,11 +45,11 @@ public: bool _fixedPos; CBSprite *_currentSprite; char *_currentSkelAnim; - HRESULT update(TDirection Dir = DI_DOWN); - HRESULT SetupTalkFile(const char *SoundFilename); + HRESULT update(TDirection dir = DI_DOWN); + HRESULT setupTalkFile(const char *soundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) - HRESULT Finish(); - void SetSound(CBSound *Sound); + HRESULT finish(); + void setSound(CBSound *Sound); bool _soundStarted; CBSound *_sound; TTextAlign _align; @@ -57,10 +57,10 @@ public: int _width; POINT _pos; CBFont *_font; - char *GetNextStance(); - char *GetCurrentStance(); - void SetStances(const char *Stances); - void SetText(const char *Text); + char *getNextStance(); + char *getCurrentStance(); + void setStances(const char *stances); + void setText(const char *text); int _currentStance; uint32 _startTime; char *_stances; @@ -74,7 +74,7 @@ public: private: char *_tempStance; - char *GetStance(int Stance); + char *getStance(int Stance); }; diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 3eb30e2496..d51bdc3d02 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -58,16 +58,16 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); delete [] Buffer; @@ -90,7 +90,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -110,19 +110,19 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { Game->LOG(0, "'SPRITESET' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } CBSprite *spr = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -133,7 +133,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_LEFT] = spr; break; @@ -141,7 +141,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_RIGHT] = spr; break; @@ -149,7 +149,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UP] = spr; break; @@ -157,7 +157,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWN] = spr; break; @@ -165,7 +165,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPLEFT] = spr; break; @@ -173,7 +173,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPRIGHT] = spr; break; @@ -181,7 +181,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNLEFT] = spr; break; @@ -189,7 +189,7 @@ HRESULT CAdSpriteSet::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSp delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->LoadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNRIGHT] = spr; break; @@ -228,8 +228,8 @@ HRESULT CAdSpriteSet::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { - int Dir = (int)Direction; +CBSprite *CAdSpriteSet::getSprite(TDirection direction) { + int Dir = (int)direction; if (Dir < 0) Dir = 0; if (Dir >= NUM_DIRECTIONS) Dir = NUM_DIRECTIONS - 1; @@ -259,49 +259,49 @@ CBSprite *CAdSpriteSet::GetSprite(TDirection Direction) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "SPRITESET {\n"); - if (_name) Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); +HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITESET {\n"); + if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { if (_sprites[i]) { switch (i) { case DI_UP: - Buffer->putTextIndent(Indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPRIGHT: - Buffer->putTextIndent(Indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_RIGHT: - Buffer->putTextIndent(Indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNRIGHT: - Buffer->putTextIndent(Indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWN: - Buffer->putTextIndent(Indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); break; case DI_DOWNLEFT: - Buffer->putTextIndent(Indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_LEFT: - Buffer->putTextIndent(Indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); break; case DI_UPLEFT: - Buffer->putTextIndent(Indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); break; } } } - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::ContainsSprite(CBSprite *Sprite) { +bool CAdSpriteSet::containsSprite(CBSprite *Sprite) { if (!Sprite) return false; for (int i = 0; i < NUM_DIRECTIONS; i++) { diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index fab0d7143a..e1e527c267 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -37,15 +37,15 @@ namespace WinterMute { class CAdSpriteSet : public CBObject { public: - bool ContainsSprite(CBSprite *Sprite); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); - CBSprite *GetSprite(TDirection Direction); + bool containsSprite(CBSprite *sprite); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); + CBSprite *getSprite(TDirection direction); DECLARE_PERSISTENT(CAdSpriteSet, CBObject) CBObject *_owner; - CAdSpriteSet(CBGame *inGame, CBObject *Owner = NULL); + CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); virtual ~CAdSpriteSet(); - HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + HRESULT loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); CBSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 8b485f2092..679da816c0 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -69,7 +69,7 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadFile(const char *Filename) { +HRESULT CAdTalkDef::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); @@ -80,7 +80,7 @@ HRESULT CAdTalkDef::LoadFile(const char *Filename) { CBUtils::SetString(&_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); delete [] Buffer; @@ -98,7 +98,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdTalkDef::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -124,12 +124,12 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_ACTION: { CAdTalkNode *Node = new CAdTalkNode(Game); - if (Node && SUCCEEDED(Node->LoadBuffer(params, false))) _nodes.Add(Node); + if (Node && SUCCEEDED(Node->loadBuffer(params, false))) _nodes.Add(Node); else { delete Node; Node = NULL; @@ -149,7 +149,7 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_DEFAULT_SPRITESET: { delete _defaultSpriteSet; _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadBuffer(params, false))) { + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadBuffer(params, false))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; cmd = PARSERR_GENERIC; @@ -180,12 +180,12 @@ HRESULT CAdTalkDef::LoadBuffer(byte *Buffer, bool Complete) { if (_defaultSpriteFilename) { _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) return E_FAIL; + if (!_defaultSprite || FAILED(_defaultSprite->loadFile(_defaultSpriteFilename))) return E_FAIL; } if (_defaultSpriteSetFilename) { _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) return E_FAIL; + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return E_FAIL; } @@ -210,37 +210,37 @@ HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "TALK {\n"); - if (_defaultSpriteFilename) Buffer->putTextIndent(Indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); +HRESULT CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TALK {\n"); + if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - if (_defaultSpriteSetFilename) Buffer->putTextIndent(Indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(Buffer, Indent + 2); + if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); for (int i = 0; i < _nodes.GetSize(); i++) { - _nodes[i]->saveAsText(Buffer, Indent + 2); - Buffer->putTextIndent(Indent, "\n"); + _nodes[i]->saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "\n"); } - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::LoadDefaultSprite() { +HRESULT CAdTalkDef::loadDefaultSprite() { if (_defaultSpriteFilename && !_defaultSprite) { _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->LoadFile(_defaultSpriteFilename))) { + if (!_defaultSprite || FAILED(_defaultSprite->loadFile(_defaultSpriteFilename))) { delete _defaultSprite; _defaultSprite = NULL; return E_FAIL; } else return S_OK; } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->LoadFile(_defaultSpriteSetFilename))) { + if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; return E_FAIL; @@ -250,10 +250,10 @@ HRESULT CAdTalkDef::LoadDefaultSprite() { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkDef::GetDefaultSprite(TDirection Dir) { - LoadDefaultSprite(); +CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { + loadDefaultSprite(); if (_defaultSprite) return _defaultSprite; - else if (_defaultSpriteSet) return _defaultSpriteSet->GetSprite(Dir); + else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); else return NULL; } diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 870408f820..46bcd0da9c 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -39,18 +39,18 @@ class CAdTalkDef : public CBObject { public: char *_defaultSpriteSetFilename; CAdSpriteSet *_defaultSpriteSet; - CBSprite *GetDefaultSprite(TDirection Dir); - HRESULT LoadDefaultSprite(); + CBSprite *getDefaultSprite(TDirection Dir); + HRESULT loadDefaultSprite(); DECLARE_PERSISTENT(CAdTalkDef, CBObject) CAdTalkDef(CBGame *inGame); virtual ~CAdTalkDef(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *filename); + HRESULT loadBuffer(byte *buffer, bool complete = true); CBArray _nodes; char *_defaultSpriteFilename; CBSprite *_defaultSprite; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 204de117b6..8c7ffdd49d 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -62,7 +62,7 @@ CAdTalkHolder::~CAdTalkHolder() { } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { +CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { CBSprite *ret = NULL; @@ -72,7 +72,7 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { delete _animSprite; _animSprite = new CBSprite(Game, this); if (_animSprite) { - HRESULT res = _animSprite->LoadFile(_forcedTalkAnimName); + HRESULT res = _animSprite->loadFile(_forcedTalkAnimName); if (FAILED(res)) { Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; @@ -82,10 +82,10 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { } - if (Stance != NULL) { + if (stance != NULL) { // search special talk stances for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { ret = _talkSpritesEx[i]; break; } @@ -93,7 +93,7 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { if (ret == NULL) { // serach generic talk stances for (int i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { ret = _talkSprites[i]; break; } @@ -118,14 +118,14 @@ CBSprite *CAdTalkHolder::GetTalkStance(const char *Stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSprite") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "SetSprite") == 0) { + stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); bool SetCurrent = false; if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; @@ -136,17 +136,17 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack if (Val->IsNULL()) { _sprite = NULL; if (SetCurrent) _currentSprite = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { const char *Filename = Val->GetString(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Script->RuntimeError("SetSprite method failed for file '%s'", Filename); - Stack->PushBool(false); + if (!spr || FAILED(spr->loadFile(Filename))) { + script->RuntimeError("SetSprite method failed for file '%s'", Filename); + stack->PushBool(false); } else { _sprite = spr; if (SetCurrent) _currentSprite = _sprite; - Stack->PushBool(true); + stack->PushBool(true); } } return S_OK; @@ -155,42 +155,42 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSprite") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetSprite") == 0) { + stack->CorrectParams(0); - if (!_sprite || !_sprite->_filename) Stack->PushNULL(); - else Stack->PushString(_sprite->_filename); + if (!_sprite || !_sprite->_filename) stack->PushNULL(); + else stack->PushString(_sprite->_filename); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSpriteObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSpriteObject") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetSpriteObject") == 0) { + stack->CorrectParams(0); - if (!_sprite) Stack->PushNULL(); - else Stack->PushNative(_sprite, true); + if (!_sprite) stack->PushNULL(); + else stack->PushNative(_sprite, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AddTalkSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddTalkSprite") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "AddTalkSprite") == 0) { + stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); + const char *Filename = stack->Pop()->GetString(); + bool Ex = stack->Pop()->GetBool(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); + if (!spr || FAILED(spr->loadFile(Filename))) { + stack->PushBool(false); + script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); } else { if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -198,11 +198,11 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // RemoveTalkSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveTalkSprite") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "RemoveTalkSprite") == 0) { + stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); + const char *Filename = stack->Pop()->GetString(); + bool Ex = stack->Pop()->GetBool(); int i; bool SetCurrent = false; @@ -231,7 +231,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack } - Stack->PushBool(true); + stack->PushBool(true); if (SetCurrent) _currentSprite = _sprite; if (SetTemp2) _tempSprite2 = _sprite; @@ -241,18 +241,18 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetTalkSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetTalkSprite") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "SetTalkSprite") == 0) { + stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool Ex = Stack->Pop()->GetBool(); + const char *Filename = stack->Pop()->GetString(); + bool Ex = stack->Pop()->GetBool(); bool SetCurrent = false; bool SetTemp2 = false; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->LoadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); + if (!spr || FAILED(spr->loadFile(Filename))) { + stack->PushBool(false); + script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); } else { // delete current @@ -276,7 +276,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack // set new if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); - Stack->PushBool(true); + stack->PushBool(true); if (SetCurrent) _currentSprite = spr; if (SetTemp2) _tempSprite2 = spr; @@ -284,38 +284,38 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack return S_OK; } - else return CAdObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CAdObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::scGetProperty(const char *Name) { +CScValue *CAdTalkHolder::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("talk-holder"); return _scValue; } - else return CAdObject::scGetProperty(Name); + else return CAdObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Item")==0){ + if(strcmp(name, "Item")==0){ SetItem(Value->GetString()); return S_OK; } - else*/ return CAdObject::scSetProperty(Name, Value); + else*/ return CAdObject::scSetProperty(name, value); } @@ -326,16 +326,15 @@ const char *CAdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *Buffer, int Indent) { - int i; - for (i = 0; i < _talkSprites.GetSize(); i++) { +HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { + for (int i = 0; i < _talkSprites.GetSize(); i++) { if (_talkSprites[i]->_filename) - Buffer->putTextIndent(Indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); } - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { if (_talkSpritesEx[i]->_filename) - Buffer->putTextIndent(Indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); } return S_OK; diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h index 193dadfe00..d2d51a7213 100644 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -36,8 +36,8 @@ namespace WinterMute { class CAdTalkHolder : public CAdObject { public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *GetTalkStance(const char *Stance); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual CBSprite *getTalkStance(const char *stance); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); CBSprite *_sprite; CBArray _talkSprites; CBArray _talkSpritesEx; @@ -45,9 +45,9 @@ public: virtual ~CAdTalkHolder(); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 9f9264113b..291721662a 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -80,7 +80,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdTalkNode::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -122,7 +122,7 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_SPRITESET: { delete _spriteSet; _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadBuffer(params, false))) { + if (!_spriteSet || FAILED(_spriteSet->loadBuffer(params, false))) { delete _spriteSet; _spriteSet = NULL; cmd = PARSERR_GENERIC; @@ -167,13 +167,13 @@ HRESULT CAdTalkNode::LoadBuffer(byte *Buffer, bool Complete) { if (_preCache && _spriteFilename) { delete _sprite; _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) return E_FAIL; + if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) return E_FAIL; } if (_preCache && _spriteSetFilename) { delete _spriteSet; _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) return E_FAIL; + if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) return E_FAIL; } @@ -217,10 +217,10 @@ HRESULT CAdTalkNode::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::LoadSprite() { +HRESULT CAdTalkNode::loadSprite() { if (_spriteFilename && !_sprite) { _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->LoadFile(_spriteFilename))) { + if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) { delete _sprite; _sprite = NULL; return E_FAIL; @@ -229,7 +229,7 @@ HRESULT CAdTalkNode::LoadSprite() { else if (_spriteSetFilename && !_spriteSet) { _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->LoadFile(_spriteSetFilename))) { + if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; _spriteSet = NULL; return E_FAIL; @@ -241,11 +241,11 @@ HRESULT CAdTalkNode::LoadSprite() { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { +bool CAdTalkNode::isInTimeInterval(uint32 Time, TDirection Dir) { if (Time >= _startTime) { if (_playToEnd) { if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->GetSprite(Dir) && _spriteSet->GetSprite(Dir)->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(Dir) && _spriteSet->getSprite(Dir)->_finished == false)) return true; else return false; } else return _endTime >= Time; } else return false; @@ -253,10 +253,10 @@ bool CAdTalkNode::IsInTimeInterval(uint32 Time, TDirection Dir) { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::GetSprite(TDirection Dir) { - LoadSprite(); +CBSprite *CAdTalkNode::getSprite(TDirection Dir) { + loadSprite(); if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->GetSprite(Dir); + else if (_spriteSet) return _spriteSet->getSprite(Dir); else return NULL; } diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h index 8d356181e8..57cce1deb4 100644 --- a/engines/wintermute/Ad/AdTalkNode.h +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -39,15 +39,15 @@ class CAdTalkNode : public CBBase { public: char *_spriteSetFilename; CAdSpriteSet *_spriteSet; - CBSprite *GetSprite(TDirection Dir); - bool IsInTimeInterval(uint32 Time, TDirection Dir); - HRESULT LoadSprite(); + CBSprite *getSprite(TDirection dir); + bool isInTimeInterval(uint32 time, TDirection dir); + HRESULT loadSprite(); DECLARE_PERSISTENT(CAdTalkNode, CBBase) CAdTalkNode(CBGame *inGame); virtual ~CAdTalkNode(); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); char *_spriteFilename; CBSprite *_sprite; uint32 _startTime; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index c2613d4cd7..8f7137b9e8 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -64,7 +64,7 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { +HRESULT CAdWaypointGroup::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); @@ -76,7 +76,7 @@ HRESULT CAdWaypointGroup::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); delete [] Buffer; @@ -96,7 +96,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdWaypointGroup::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -123,7 +123,7 @@ HRESULT CAdWaypointGroup::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 653d4eae7b..e5203cc61d 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -44,8 +44,8 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); bool _active; CAdWaypointGroup(CBGame *inGame); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 5a6513d7d3..22b0c0f1a0 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -71,7 +71,7 @@ int CBFont::GetTextWidth(byte *text, int MaxLenght) { /* ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::LoadFile(const char * Filename) +HRESULT CBFont::loadFile(const char * Filename) { BYTE* Buffer = Game->_fileManager->readWholeFile(Filename); if(Buffer==NULL){ @@ -84,7 +84,7 @@ HRESULT CBFont::LoadFile(const char * Filename) _filename = new char [strlen(Filename)+1]; strcpy(_filename, Filename); - if(FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + if(FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); delete [] Buffer; @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::LoadBuffer(byte * Buffer) +HRESULT CBFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -156,7 +156,7 @@ CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { if (IsTrueType(Game, Filename)) { CBFontTT *Font = new CBFontTT(Game); if (Font) { - if (FAILED(Font->LoadFile(Filename))) { + if (FAILED(Font->loadFile(Filename))) { delete Font; return NULL; } @@ -165,7 +165,7 @@ CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { } else { CBFontBitmap *Font = new CBFontBitmap(Game); if (Font) { - if (FAILED(Font->LoadFile(Filename))) { + if (FAILED(Font->loadFile(Filename))) { delete Font; return NULL; } diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index 148cbe7ed8..7a115517da 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -51,8 +51,8 @@ public: static CBFont *CreateFromFile(CBGame *Game, const char *Filename); private: - //HRESULT LoadBuffer(byte * Buffer); - //HRESULT LoadFile(const char* Filename); + //HRESULT loadBuffer(byte * Buffer); + //HRESULT loadFile(const char* Filename); static bool IsTrueType(CBGame *Game, const char *Filename); }; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 31a667bcbe..eb30bfa6f5 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -245,7 +245,7 @@ void CBFontBitmap::DrawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::LoadFile(const char *Filename) { +HRESULT CBFontBitmap::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); @@ -257,7 +257,7 @@ HRESULT CBFontBitmap::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); delete [] Buffer; @@ -284,7 +284,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { +HRESULT CBFontBitmap::loadBuffer(byte *Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -404,7 +404,7 @@ HRESULT CBFontBitmap::LoadBuffer(byte *Buffer) { if (sprite_file != NULL) { delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->LoadFile(sprite_file))) { + if (!_sprite || FAILED(_sprite->loadFile(sprite_file))) { delete _sprite; _sprite = NULL; } diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h index e22540b3c1..64fffb7a12 100644 --- a/engines/wintermute/Base/BFontBitmap.h +++ b/engines/wintermute/Base/BFontBitmap.h @@ -37,8 +37,8 @@ class CBSubFrame; class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) - HRESULT LoadBuffer(byte *Buffer); - HRESULT LoadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer); + HRESULT loadFile(const char *Filename); virtual int GetTextWidth(byte *text, int MaxLength = -1); virtual int GetTextHeight(byte *text, int width); virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 3244dfa332..9996f9b3e2 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -104,7 +104,7 @@ CBFont *CBFontStorage::AddFont(const char *Filename) { CBFont* font = new CBFont(Game); if (!font) return NULL; - if (FAILED(font->LoadFile(Filename))) { + if (FAILED(font->loadFile(Filename))) { delete font; return NULL; } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index fb3b6e3fb1..5a44a0fc13 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -404,7 +404,7 @@ int CBFontTT::GetLetterHeight() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::LoadFile(const char *Filename) { +HRESULT CBFontTT::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); @@ -416,7 +416,7 @@ HRESULT CBFontTT::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); delete [] Buffer; @@ -441,7 +441,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::LoadBuffer(byte *Buffer) { +HRESULT CBFontTT::loadBuffer(byte *Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index db5b029c93..4d1f52279c 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -123,8 +123,8 @@ public: virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLenght = -1); virtual int GetLetterHeight(); - HRESULT LoadBuffer(byte *buffer); - HRESULT LoadFile(const char *filename); + HRESULT loadBuffer(byte *buffer); + HRESULT loadFile(const char *filename); float GetLineHeight() const { return _lineHeight; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 35e6ca814b..b7526d4da9 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -132,7 +132,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 752e0c6925..a9030b8848 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -53,7 +53,7 @@ public: uint32 _delay; CBArray _subframes; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - HRESULT LoadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 625c154d7d..6db323b333 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -390,7 +390,7 @@ HRESULT CBGame::cleanup() { for (int i = 0; i < _scripts.GetSize(); i++) { _scripts[i]->_owner = NULL; - _scripts[i]->Finish(); + _scripts[i]->finish(); } _scripts.RemoveAll(); @@ -687,7 +687,7 @@ void CBGame::GetOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadFile(const char *Filename) { +HRESULT CBGame::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); @@ -699,7 +699,7 @@ HRESULT CBGame::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); delete [] Buffer; @@ -758,7 +758,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CBGame::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -809,7 +809,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -838,7 +838,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -849,7 +849,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { delete _activeCursor; _activeCursor = NULL; _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->LoadFile((char *)params))) { + if (!_activeCursor || FAILED(_activeCursor->loadFile((char *)params))) { delete _activeCursor; _activeCursor = NULL; cmd = PARSERR_GENERIC; @@ -859,7 +859,7 @@ HRESULT CBGame::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile((char *)params))) { + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile((char *)params))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; cmd = PARSERR_GENERIC; @@ -1034,7 +1034,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (Val->IsNULL()) ClearOld = true; else ClearOld = Val->GetBool(); - if (FAILED(_stringTable->LoadFile(Filename, ClearOld))) + if (FAILED(_stringTable->loadFile(Filename, ClearOld))) Stack->PushBool(false); else Stack->PushBool(true); @@ -1086,7 +1086,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS else if (strcmp(Name, "LoadWindow") == 0) { Stack->CorrectParams(1); CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->LoadFile(Stack->Pop()->GetString()))) { + if (win && SUCCEEDED(win->loadFile(Stack->Pop()->GetString()))) { _windows.Add(win); RegisterObject(win); Stack->PushNative(win, true); @@ -1994,7 +1994,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS delete _loadingIcon; _loadingIcon = new CBSprite(this); - if (!_loadingIcon || FAILED(_loadingIcon->LoadFile(Filename))) { + if (!_loadingIcon || FAILED(_loadingIcon->loadFile(Filename))) { delete _loadingIcon; _loadingIcon = NULL; } else { @@ -3542,7 +3542,7 @@ HRESULT CBGame::LoadSettings(const char *Filename) { break; case TOKEN_STRING_TABLE: - if (FAILED(_stringTable->LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_RESOLUTION: @@ -4208,7 +4208,7 @@ HRESULT CBGame::SetWaitCursor(const char *Filename) { _cursorNoninteractive = NULL; _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->LoadFile(Filename))) { + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile(Filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; return E_FAIL; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 51f792dc75..6c5776ef2e 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -193,8 +193,8 @@ public: void *_dEBUG_LogFile; int _sequence; - virtual HRESULT LoadFile(const char *Filename); - virtual HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT loadFile(const char *Filename); + virtual HRESULT loadBuffer(byte *Buffer, bool Complete = true); CBArray _quickMessages; CBArray _windows; CBArray _viewportStack; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 7c3acd83a7..6512a1f163 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -927,7 +927,7 @@ HRESULT CBObject::setCursor(const char *filename) { _sharedCursors = false; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile(filename))) { + if (!_cursor || FAILED(_cursor->loadFile(filename))) { delete _cursor; _cursor = NULL; return E_FAIL; @@ -939,7 +939,7 @@ HRESULT CBObject::setCursor(const char *filename) { HRESULT CBObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->LoadFile(filename))) { + if (!_activeCursor || FAILED(_activeCursor->loadFile(filename))) { delete _activeCursor; _activeCursor = NULL; return E_FAIL; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index c66ee67e17..6fc11cb8a8 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -95,7 +95,7 @@ bool CBRegion::PointInRegion(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::LoadFile(const char *Filename) { +HRESULT CBRegion::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); @@ -107,7 +107,7 @@ HRESULT CBRegion::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); delete [] Buffer; @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CBRegion::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -161,7 +161,7 @@ HRESULT CBRegion::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index f52f646f2c..6e8f8bbbb2 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -50,8 +50,8 @@ public: virtual ~CBRegion(); bool PointInRegion(int X, int Y); bool CreateRegion(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); RECT _rect; CBArray _points; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index aaf73b2bc2..0b9bc27958 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -62,7 +62,7 @@ HRESULT CBScriptHolder::cleanup() { int i; for (i = 0; i < _scripts.GetSize(); i++) { - _scripts[i]->Finish(true); + _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } _scripts.RemoveAll(); @@ -177,7 +177,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { - _scripts[i]->Finish(KillThreads); + _scripts[i]->finish(KillThreads); ret = true; break; } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6f23649737..e31cb80d7c 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -122,12 +122,12 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CBSprite::loadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); if (!File) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); - if (Game->_dEBUG_DebugMode) return LoadFile("invalid_debug.bmp", LifeTime, CacheType); - else return LoadFile("invalid.bmp", LifeTime, CacheType); + if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", LifeTime, CacheType); + else return loadFile("invalid.bmp", LifeTime, CacheType); } else { Game->_fileManager->closeFile(File); File = NULL; @@ -155,7 +155,7 @@ HRESULT CBSprite::LoadFile(const char *Filename, int LifeTime, TSpriteCacheType } else { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer) { - if (FAILED(ret = LoadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); delete [] Buffer; } } @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CBSprite::loadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -289,7 +289,7 @@ HRESULT CBSprite::LoadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite frame = new CBFrame(Game); - if (FAILED(frame->LoadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + if (FAILED(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; Game->LOG(0, "Error parsing frame %d", frame_count); return E_FAIL; diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 67f703d744..1e35a1555f 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -66,8 +66,8 @@ public: bool _changed; bool _paused; bool _finished; - HRESULT LoadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT LoadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); uint32 _lastFrameTime; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); bool _looping; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 2136bc4d94..794af32ab7 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -169,7 +169,7 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::LoadFile(const char *Filename, bool ClearOld) { +HRESULT CBStringTable::loadFile(const char *Filename, bool ClearOld) { Game->LOG(0, "Loading string table..."); if (ClearOld) _strings.clear(); diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index 57c75ef1e9..7a6177098c 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -38,7 +38,7 @@ namespace WinterMute { class CBStringTable : public CBBase { public: const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT LoadFile(const char *Filename, bool DeleteAll = true); + HRESULT loadFile(const char *Filename, bool DeleteAll = true); void Expand(char **Str, bool ForceExpand = false); HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); CBStringTable(CBGame *inGame); diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 4b1475f780..3443bcbb71 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -83,7 +83,7 @@ HRESULT CPartParticle::setSprite(const char *Filename) { CSysClassRegistry::GetInstance()->_disabled = true; _sprite = new CBSprite(Game, Game); - if (_sprite && SUCCEEDED(_sprite->LoadFile(Filename))) { + if (_sprite && SUCCEEDED(_sprite->loadFile(Filename))) { CSysClassRegistry::GetInstance()->_disabled = false; return S_OK; } else { diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a28a35948f..0835566d2c 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -189,7 +189,7 @@ HRESULT CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// -byte *WINAPI CScEngine::LoadFile(void *Data, char *Filename, uint32 *Size) { +byte *WINAPI CScEngine::loadFile(void *Data, char *Filename, uint32 *Size) { CBGame *Game = (CBGame *)Data; return Game->_fileManager->readWholeFile(Filename, Size); } @@ -309,7 +309,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I CALLBACKS c; c.Dll_AddError = AddError; c.Dll_CloseFile = CloseFile; - c.Dll_LoadFile = LoadFile; + c.Dll_LoadFile = loadFile; c.Dll_ParseElement = ParseElement; ExtSetCallbacks(&c, Game); @@ -387,11 +387,11 @@ HRESULT CScEngine::Tick() { break; } } - if(!obj_found) _scripts[i]->Finish(); // _waitObject no longer exists + if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (Game->ValidObject(_scripts[i]->_waitObject)) { if (_scripts[i]->_waitObject->isReady()) _scripts[i]->Run(); - } else _scripts[i]->Finish(); + } else _scripts[i]->finish(); break; } @@ -415,7 +415,7 @@ HRESULT CScEngine::Tick() { // copy return value _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); _scripts[i]->Run(); - _scripts[i]->_waitScript->Finish(); + _scripts[i]->_waitScript->finish(); _scripts[i]->_waitScript = NULL; } } @@ -475,7 +475,7 @@ HRESULT CScEngine::TickUnbreakable() { _currentScript = _scripts[i]; _scripts[i]->ExecuteInstruction(); } - _scripts[i]->Finish(); + _scripts[i]->finish(); _currentScript = NULL; } RemoveFinishedScripts(); @@ -552,7 +552,7 @@ HRESULT CScEngine::ResetObject(CBObject *Object) { if (!Game->_compatKillMethodThreads) ResetScript(_scripts[i]); bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->Finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well } } return S_OK; @@ -563,7 +563,7 @@ HRESULT CScEngine::ResetScript(CScScript *Script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == Script) { - _scripts[i]->Finish(); + _scripts[i]->finish(); } } return S_OK; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 06417793ed..c7fb8eb3a8 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -137,7 +137,7 @@ public: CScEngine(CBGame *inGame); virtual ~CScEngine(); static void WINAPI AddError(void *Data, int Line, char *Text); - static byte *WINAPI LoadFile(void *Data, char *Filename, uint32 *Size); + static byte *WINAPI loadFile(void *Data, char *Filename, uint32 *Size); static void WINAPI CloseFile(void *Data, byte *Buffer); static void WINAPI ParseElement(void *Data, int Line, int Type, void *ElementData); DLL_COMPILE_BUFFER ExtCompileBuffer; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index aa3485030e..77c3784ef4 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1117,7 +1117,7 @@ HRESULT CScScript::Sleep(uint32 Duration) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Finish(bool IncludingThreads) { +HRESULT CScScript::finish(bool IncludingThreads) { if (_state != SCRIPT_FINISHED && IncludingThreads) { _state = SCRIPT_FINISHED; FinishThreads(); @@ -1508,7 +1508,7 @@ HRESULT CScScript::FinishThreads() { for (int i = 0; i < _engine->_scripts.GetSize(); i++) { CScScript *Scr = _engine->_scripts[i]; if (Scr->_thread && Scr->_state != SCRIPT_FINISHED && Scr->_owner == _owner && scumm_stricmp(Scr->_filename, _filename) == 0) - Scr->Finish(true); + Scr->finish(true); } return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 24cc4debdf..1ed08375d1 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -77,7 +77,7 @@ public: DECLARE_PERSISTENT(CScScript, CBBase) void RuntimeError(LPCSTR fmt, ...); HRESULT Run(); - HRESULT Finish(bool IncludingThreads = false); + HRESULT finish(bool IncludingThreads = false); HRESULT Sleep(uint32 Duration); HRESULT WaitForExclusive(CBObject *Object); HRESULT WaitFor(CBObject *Object); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 79218a62e5..759a37b4b3 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -95,7 +95,7 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::LoadFile(const char *Filename) { +HRESULT CUIButton::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); @@ -107,7 +107,7 @@ HRESULT CUIButton::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); delete [] Buffer; @@ -155,7 +155,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -210,7 +210,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -224,7 +224,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { + if (!_back || FAILED(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -234,7 +234,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK_HOVER: delete _backHover; _backHover = new CUITiledImage(Game); - if (!_backHover || FAILED(_backHover->LoadFile((char *)params))) { + if (!_backHover || FAILED(_backHover->loadFile((char *)params))) { delete _backHover; _backHover = NULL; cmd = PARSERR_GENERIC; @@ -244,7 +244,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK_PRESS: delete _backPress; _backPress = new CUITiledImage(Game); - if (!_backPress || FAILED(_backPress->LoadFile((char *)params))) { + if (!_backPress || FAILED(_backPress->loadFile((char *)params))) { delete _backPress; _backPress = NULL; cmd = PARSERR_GENERIC; @@ -254,7 +254,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK_DISABLE: delete _backDisable; _backDisable = new CUITiledImage(Game); - if (!_backDisable || FAILED(_backDisable->LoadFile((char *)params))) { + if (!_backDisable || FAILED(_backDisable->loadFile((char *)params))) { delete _backDisable; _backDisable = NULL; cmd = PARSERR_GENERIC; @@ -264,7 +264,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK_FOCUS: delete _backFocus; _backFocus = new CUITiledImage(Game); - if (!_backFocus || FAILED(_backFocus->LoadFile((char *)params))) { + if (!_backFocus || FAILED(_backFocus->loadFile((char *)params))) { delete _backFocus; _backFocus = NULL; cmd = PARSERR_GENERIC; @@ -274,7 +274,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { + if (!_image || FAILED(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -284,7 +284,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_HOVER: delete _imageHover; _imageHover = new CBSprite(Game); - if (!_imageHover || FAILED(_imageHover->LoadFile((char *)params))) { + if (!_imageHover || FAILED(_imageHover->loadFile((char *)params))) { delete _imageHover; _imageHover = NULL; cmd = PARSERR_GENERIC; @@ -294,7 +294,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_PRESS: delete _imagePress; _imagePress = new CBSprite(Game); - if (!_imagePress || FAILED(_imagePress->LoadFile((char *)params))) { + if (!_imagePress || FAILED(_imagePress->loadFile((char *)params))) { delete _imagePress; _imagePress = NULL; cmd = PARSERR_GENERIC; @@ -304,7 +304,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_DISABLE: delete _imageDisable; _imageDisable = new CBSprite(Game); - if (!_imageDisable || FAILED(_imageDisable->LoadFile((char *)params))) { + if (!_imageDisable || FAILED(_imageDisable->loadFile((char *)params))) { delete _imageDisable; _imageDisable = NULL; cmd = PARSERR_GENERIC; @@ -314,7 +314,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_FOCUS: delete _imageFocus; _imageFocus = new CBSprite(Game); - if (!_imageFocus || FAILED(_imageFocus->LoadFile((char *)params))) { + if (!_imageFocus || FAILED(_imageFocus->loadFile((char *)params))) { delete _imageFocus; _imageFocus = NULL; cmd = PARSERR_GENERIC; @@ -381,7 +381,7 @@ HRESULT CUIButton::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -748,7 +748,7 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageDisable; _imageDisable = new CBSprite(Game); const char *Filename = Stack->Pop()->GetString(); - if (!_imageDisable || FAILED(_imageDisable->LoadFile(Filename))) { + if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) { delete _imageDisable; _imageDisable = NULL; Stack->PushBool(false); @@ -789,7 +789,7 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageHover; _imageHover = new CBSprite(Game); const char *Filename = Stack->Pop()->GetString(); - if (!_imageHover || FAILED(_imageHover->LoadFile(Filename))) { + if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) { delete _imageHover; _imageHover = NULL; Stack->PushBool(false); @@ -829,7 +829,7 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imagePress; _imagePress = new CBSprite(Game); const char *Filename = Stack->Pop()->GetString(); - if (!_imagePress || FAILED(_imagePress->LoadFile(Filename))) { + if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) { delete _imagePress; _imagePress = NULL; Stack->PushBool(false); @@ -869,7 +869,7 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageFocus; _imageFocus = new CBSprite(Game); const char *Filename = Stack->Pop()->GetString(); - if (!_imageFocus || FAILED(_imageFocus->LoadFile(Filename))) { + if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) { delete _imageFocus; _imageFocus = NULL; Stack->PushBool(false); diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 5a86087d76..b404a781d1 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -63,8 +63,8 @@ public: CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index e2d5c1f01e..9a193b5c23 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -94,7 +94,7 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::LoadFile(const char *Filename) { +HRESULT CUIEdit::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); @@ -106,7 +106,7 @@ HRESULT CUIEdit::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); delete [] Buffer; @@ -139,7 +139,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -180,7 +180,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -190,7 +190,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { + if (!_back || FAILED(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -200,7 +200,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { + if (!_image || FAILED(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -251,7 +251,7 @@ HRESULT CUIEdit::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 192257e996..6ad5f50758 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -56,8 +56,8 @@ public: CUIEdit(CBGame *inGame); virtual ~CUIEdit(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 5a30c32e5d..41b197dcd7 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -55,7 +55,7 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::LoadFile(const char *Filename) { +HRESULT CUIEntity::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); @@ -67,7 +67,7 @@ HRESULT CUIEntity::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); delete [] Buffer; @@ -89,7 +89,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -118,7 +118,7 @@ HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -211,7 +211,7 @@ HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { HRESULT CUIEntity::SetEntity(const char *Filename) { if (_entity) Game->UnregisterObject(_entity); _entity = new CAdEntity(Game); - if (!_entity || FAILED(_entity->LoadFile(Filename))) { + if (!_entity || FAILED(_entity->loadFile(Filename))) { delete _entity; _entity = NULL; return E_FAIL; diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 29262d77c1..813831af67 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -38,8 +38,8 @@ public: DECLARE_PERSISTENT(CUIEntity, CUIObject) CUIEntity(CBGame *inGame); virtual ~CUIEntity(); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 31a7c044c7..94033389f8 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -173,7 +173,7 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile(Val->GetString()))) { + if (!_image || FAILED(_image->loadFile(Val->GetString()))) { delete _image; _image = NULL; Stack->PushBool(false); diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 260ade166c..5f11ebc964 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -95,7 +95,7 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::LoadFile(const char *Filename) { +HRESULT CUIText::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); @@ -107,7 +107,7 @@ HRESULT CUIText::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); delete [] Buffer; @@ -138,7 +138,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -177,7 +177,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -191,7 +191,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { + if (!_back || FAILED(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -201,7 +201,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { + if (!_image || FAILED(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -250,7 +250,7 @@ HRESULT CUIText::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 5092623d8c..aac9caf896 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -43,8 +43,8 @@ public: virtual ~CUIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 5d1cc53aa3..a259050872 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -119,7 +119,7 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::LoadFile(const char *Filename) { +HRESULT CUITiledImage::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); @@ -131,7 +131,7 @@ HRESULT CUITiledImage::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); delete [] Buffer; @@ -158,7 +158,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUITiledImage::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -195,7 +195,7 @@ HRESULT CUITiledImage::LoadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_IMAGE: diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index fa0338586e..62ae6a0cce 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -38,8 +38,8 @@ class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void CorrectSize(int *Width, int *Height); - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); HRESULT display(int X, int Y, int Width, int Height); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index ce1fb05042..887d869076 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -200,7 +200,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::LoadFile(const char *Filename) { +HRESULT CUIWindow::loadFile(const char *Filename) { byte *Buffer = Game->_fileManager->readWholeFile(Filename); if (Buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); @@ -212,7 +212,7 @@ HRESULT CUIWindow::LoadFile(const char *Filename) { _filename = new char [strlen(Filename) + 1]; strcpy(_filename, Filename); - if (FAILED(ret = LoadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); delete [] Buffer; @@ -259,7 +259,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -317,7 +317,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -331,7 +331,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->LoadFile((char *)params))) { + if (!_back || FAILED(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -341,7 +341,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BACK_INACTIVE: delete _backInactive; _backInactive = new CUITiledImage(Game); - if (!_backInactive || FAILED(_backInactive->LoadFile((char *)params))) { + if (!_backInactive || FAILED(_backInactive->loadFile((char *)params))) { delete _backInactive; _backInactive = NULL; cmd = PARSERR_GENERIC; @@ -351,7 +351,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->LoadFile((char *)params))) { + if (!_image || FAILED(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -361,7 +361,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_IMAGE_INACTIVE: delete _imageInactive, _imageInactive = new CBSprite(Game); - if (!_imageInactive || FAILED(_imageInactive->LoadFile((char *)params))) { + if (!_imageInactive || FAILED(_imageInactive->loadFile((char *)params))) { delete _imageInactive; _imageInactive = NULL; cmd = PARSERR_GENERIC; @@ -418,7 +418,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->LoadFile((char *)params))) { + if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -427,7 +427,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_BUTTON: { CUIButton *btn = new CUIButton(Game); - if (!btn || FAILED(btn->LoadBuffer(params, false))) { + if (!btn || FAILED(btn->loadBuffer(params, false))) { delete btn; btn = NULL; cmd = PARSERR_GENERIC; @@ -440,7 +440,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_STATIC: { CUIText *text = new CUIText(Game); - if (!text || FAILED(text->LoadBuffer(params, false))) { + if (!text || FAILED(text->loadBuffer(params, false))) { delete text; text = NULL; cmd = PARSERR_GENERIC; @@ -453,7 +453,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_EDIT: { CUIEdit *edit = new CUIEdit(Game); - if (!edit || FAILED(edit->LoadBuffer(params, false))) { + if (!edit || FAILED(edit->loadBuffer(params, false))) { delete edit; edit = NULL; cmd = PARSERR_GENERIC; @@ -466,7 +466,7 @@ HRESULT CUIWindow::LoadBuffer(byte *Buffer, bool Complete) { case TOKEN_WINDOW: { CUIWindow *win = new CUIWindow(Game); - if (!win || FAILED(win->LoadBuffer(params, false))) { + if (!win || FAILED(win->loadBuffer(params, false))) { delete win; win = NULL; cmd = PARSERR_GENERIC; @@ -736,7 +736,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th delete _imageInactive; _imageInactive = new CBSprite(Game); const char *Filename = Stack->Pop()->GetString(); - if (!_imageInactive || FAILED(_imageInactive->LoadFile(Filename))) { + if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) { delete _imageInactive; _imageInactive = NULL; Stack->PushBool(false); @@ -819,7 +819,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th CScValue *Val = Stack->Pop(); cleanup(); if (!Val->IsNULL()) { - Stack->PushBool(SUCCEEDED(LoadFile(Val->GetString()))); + Stack->PushBool(SUCCEEDED(loadFile(Val->GetString()))); } else Stack->PushBool(true); return S_OK; diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index adc2a89d21..bf40df1cb7 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -73,8 +73,8 @@ public: virtual bool handleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; - HRESULT LoadFile(const char *Filename); - HRESULT LoadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *Filename); + HRESULT loadBuffer(byte *Buffer, bool Complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; CBSprite *_imageInactive; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index b6793fbbbd..aa0ace09c8 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -681,7 +681,7 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); - if (!m_AlphaImage || FAILED(m_AlphaImage->LoadFile(Filename))) { + if (!m_AlphaImage || FAILED(m_AlphaImage->loadFile(Filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); return E_FAIL; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index cbcd652946..7b987867c3 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -233,7 +233,7 @@ int WinterMuteEngine::init() { // load game uint32 DataInitStart = CBPlatform::GetTime(); - if (FAILED(_game->LoadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { + if (FAILED(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); delete _game; _game = NULL; -- cgit v1.2.3 From b1f42e95e9861dc9df1353d6b1303f676a59af2b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 13:23:32 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in AdSceneNode and AdScene --- engines/wintermute/Ad/AdActor.cpp | 14 +- engines/wintermute/Ad/AdEntity.cpp | 6 +- engines/wintermute/Ad/AdGame.cpp | 24 +-- engines/wintermute/Ad/AdLayer.cpp | 12 +- engines/wintermute/Ad/AdObject.cpp | 22 +-- engines/wintermute/Ad/AdScene.cpp | 342 +++++++++++++++++----------------- engines/wintermute/Ad/AdScene.h | 108 +++++------ engines/wintermute/Ad/AdSceneNode.cpp | 4 +- engines/wintermute/Ad/AdSceneNode.h | 4 +- engines/wintermute/Ad/AdSentence.cpp | 4 +- 10 files changed, 270 insertions(+), 270 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 67b5b42336..84a727209d 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -496,7 +496,7 @@ void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { _targetPoint->x = X; _targetPoint->y = Y; - ((CAdGame *)Game)->_scene->CorrectTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + ((CAdGame *)Game)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); _state = STATE_SEARCHING_PATH; @@ -509,7 +509,7 @@ HRESULT CAdActor::display() { uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); @@ -518,7 +518,7 @@ HRESULT CAdActor::display() { float Rotate; if (_rotatable) { if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; + else Rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; if (_active) displaySpriteAttachments(true); @@ -661,7 +661,7 @@ HRESULT CAdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_SEARCHING_PATH: // keep asking scene for the path - if (((CAdGame *)Game)->_scene->GetPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + if (((CAdGame *)Game)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) _state = STATE_WAITING_PATH; break; @@ -726,7 +726,7 @@ HRESULT CAdActor::update() { if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -777,7 +777,7 @@ void CAdActor::GetNextStep() { if (!_currentSprite) return; - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); if (!_currentSprite->_changed) return; @@ -796,7 +796,7 @@ void CAdActor::GetNextStep() { MaxStepX--; } - if (((CAdGame *)Game)->_scene->IsBlockedAt(_pFX, _pFY, true, this)) { + if (((CAdGame *)Game)->_scene->isBlockedAt(_pFX, _pFY, true, this)) { if (_pFCount == 0) { _state = _nextState; _nextState = STATE_READY; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index b872251b85..22f85d58cf 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -487,7 +487,7 @@ HRESULT CAdEntity::display() { uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->GetAlphaAt(_posX, _posY) : 0xFFFFFFFF; + else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; float ScaleX, ScaleY; GetScale(&ScaleX, &ScaleY); @@ -495,7 +495,7 @@ HRESULT CAdEntity::display() { float Rotate; if (_rotatable) { if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->GetRotationAt(_posX, _posY) + _relativeRotate; + else Rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; @@ -591,7 +591,7 @@ HRESULT CAdEntity::update() { if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 72e17e9d02..85eb897c6d 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -209,7 +209,7 @@ HRESULT CAdGame::InitLoop() { res = CBGame::InitLoop(); if (FAILED(res)) return res; - if (_scene) res = _scene->InitLoop(); + if (_scene) res = _scene->initLoop(); _sentences.RemoveAll(); @@ -228,7 +228,7 @@ HRESULT CAdGame::AddObject(CAdObject *Object) { HRESULT CAdGame::RemoveObject(CAdObject *Object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { - HRESULT Res = _scene->RemoveObject(Object); + HRESULT Res = _scene->removeObject(Object); if (SUCCEEDED(Res)) return Res; } @@ -253,7 +253,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { SetPrevSceneName(_scene->_name); SetPrevSceneFilename(_scene->_filename); - if (!_tempDisableSaveState) _scene->SaveState(); + if (!_tempDisableSaveState) _scene->saveState(); _tempDisableSaveState = false; } @@ -278,7 +278,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { _objects[i]->_stickRegion = NULL; } - _scene->LoadState(); + _scene->loadState(); } if (FadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); return ret; @@ -1329,7 +1329,7 @@ HRESULT CAdGame::InitAfterLoad() { ////////////////////////////////////////////////////////////////////////// void CAdGame::AfterLoadScene(void *Scene, void *Data) { - ((CAdScene *)Scene)->AfterLoad(); + ((CAdScene *)Scene)->afterLoad(); } @@ -1847,7 +1847,7 @@ HRESULT CAdGame::DeleteItem(CAdItem *Item) { if (!Item) return E_FAIL; if (_selectedItem == Item) _selectedItem = NULL; - _scene->HandleItemAssociations(Item->_name, false); + _scene->handleItemAssociations(Item->_name, false); // remove from all inventories for (int i = 0; i < _inventories.GetSize(); i++) { @@ -1961,7 +1961,7 @@ HRESULT CAdGame::OnMouseLeftDown() { if (!Handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftClick"); } } @@ -1985,7 +1985,7 @@ HRESULT CAdGame::OnMouseLeftUp() { if (!Handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftRelease"); } } @@ -2004,7 +2004,7 @@ HRESULT CAdGame::OnMouseLeftDblClick() { if (!Handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftDoubleClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftDoubleClick"); } } @@ -2029,7 +2029,7 @@ HRESULT CAdGame::OnMouseRightDown() { if (!Handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("RightClick"); } } @@ -2044,7 +2044,7 @@ HRESULT CAdGame::OnMouseRightUp() { if (!Handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->PointInViewport(_mousePos.x, _mousePos.y)) { + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("RightRelease"); } } @@ -2055,7 +2055,7 @@ HRESULT CAdGame::OnMouseRightUp() { HRESULT CAdGame::DisplayDebugInfo() { char str[100]; if (Game->_dEBUG_DebugMode) { - sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->GetOffsetLeft(), _mousePos.y + _scene->GetOffsetTop()); + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 37ff0a43b2..5f5ae728dd 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -175,7 +175,7 @@ HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { region = NULL; node = NULL; } else { - node->SetRegion(region); + node->setRegion(region); _nodes.Add(node); } } @@ -192,7 +192,7 @@ HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { entity = NULL; node = NULL; } else { - node->SetEntity(entity); + node->setEntity(entity); _nodes.Add(node); } } @@ -274,12 +274,12 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (strcmp(Name, "AddRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); - Node->SetRegion(Region); + Node->setRegion(Region); Stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); - Node->SetEntity(Entity); + Node->setEntity(Entity); Stack->PushNative(Entity, true); } _nodes.Add(Node); @@ -298,12 +298,12 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (strcmp(Name, "InsertRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); - Node->SetRegion(Region); + Node->setRegion(Region); Stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); - Node->SetEntity(Entity); + Node->setEntity(Entity); Stack->PushNative(Entity, true); } if (Index < 0) Index = 0; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 6602093a0d..52c7e57be5 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -363,7 +363,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities - ((CAdGame *)Game)->_scene->HandleItemAssociations(ItemName, false); + ((CAdGame *)Game)->_scene->handleItemAssociations(ItemName, false); } } else Script->RuntimeError("TakeItem: item name expected"); @@ -388,7 +388,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (FAILED(_inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); else { // show associated entities - ((CAdGame *)Game)->_scene->HandleItemAssociations(val->GetString(), true); + ((CAdGame *)Game)->_scene->handleItemAssociations(val->GetString(), true); } } else Script->RuntimeError("DropItem: item name expected"); @@ -815,7 +815,7 @@ int CAdObject::getHeight() { } if (_zoomable) { - float zoom = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY); + float zoom = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY); ret = (int)(ret * zoom / 100); } return ret; @@ -883,8 +883,8 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const y = _posY; if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)Game)->_scene->GetOffsetLeft(); - y -= ((CAdGame *)Game)->_scene->GetOffsetTop(); + x -= ((CAdGame *)Game)->_scene->getOffsetLeft(); + y -= ((CAdGame *)Game)->_scene->getOffsetTop(); } @@ -920,8 +920,8 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)Game)->_scene->GetOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)Game)->_scene->GetOffsetTop(); + _sentence->_pos.x += ((CAdGame *)Game)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)Game)->_scene->getOffsetTop(); } _sentence->_fixedPos = !_subtitlesModRelative; @@ -1040,10 +1040,10 @@ HRESULT CAdObject::updateBlockRegion() { CAdGame *AdGame = (CAdGame *)Game; if (AdGame->_scene) { if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); + _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); if (_wptGroup && _currentWptGroup) - _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->GetScaleAt(_posY) : 100.0f, _posX, _posY); + _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); } return S_OK; } @@ -1062,7 +1062,7 @@ CAdInventory *CAdObject::getInventory() { HRESULT CAdObject::afterMove() { CAdRegion *NewRegions[MAX_NUM_REGIONS]; - ((CAdGame *)Game)->_scene->GetRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); + ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (!NewRegions[i]) break; bool RegFound = false; @@ -1100,7 +1100,7 @@ HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { *ScaleX = _scaleX < 0 ? 100 : _scaleX; *ScaleY = _scaleY < 0 ? 100 : _scaleY; } else if (_scale >= 0) *ScaleX = *ScaleY = _scale; - else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->GetZoomAt(_posX, _posY) + _relativeScale; + else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) + _relativeScale; } else { *ScaleX = *ScaleY = 100; } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 1b9df6211c..022924da84 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -66,8 +66,8 @@ IMPLEMENT_PERSISTENT(CAdScene, false) ////////////////////////////////////////////////////////////////////////// CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - _pFTarget = new CBPoint; - SetDefaults(); + _pfTarget = new CBPoint; + setDefaults(); } @@ -75,20 +75,20 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { CAdScene::~CAdScene() { cleanup(); Game->UnregisterObject(_fader); - delete _pFTarget; - _pFTarget = NULL; + delete _pfTarget; + _pfTarget = NULL; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::SetDefaults() { +void CAdScene::setDefaults() { _initialized = false; - _pFReady = true; - _pFTargetPath = NULL; - _pFRequester = NULL; + _pfReady = true; + _pfTargetPath = NULL; + _pfRequester = NULL; _mainLayer = NULL; - _pFPointsNum = 0; + _pfPointsNum = 0; _persistentState = false; _persistentStateSprites = true; @@ -100,7 +100,7 @@ void CAdScene::SetDefaults() { _scrollTimeH = _scrollTimeV = 10; _scrollPixelsH = _scrollPixelsV = 1; - _pFMaxTime = 15; + _pfMaxTime = 15; _paralaxScrolling = true; @@ -167,10 +167,10 @@ void CAdScene::cleanup() { _rotLevels.RemoveAll(); - for (i = 0; i < _pFPath.GetSize(); i++) - delete _pFPath[i]; - _pFPath.RemoveAll(); - _pFPointsNum = 0; + for (i = 0; i < _pfPath.GetSize(); i++) + delete _pfPath[i]; + _pfPath.RemoveAll(); + _pfPointsNum = 0; for (i = 0; i < _objects.GetSize(); i++) Game->UnregisterObject(_objects[i]); @@ -179,38 +179,38 @@ void CAdScene::cleanup() { delete _viewport; _viewport = NULL; - SetDefaults(); + setDefaults(); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { - if (!_pFReady) return false; +bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { + if (!_pfReady) return false; else { - _pFReady = false; - *_pFTarget = target; - _pFTargetPath = path; - _pFRequester = requester; + _pfReady = false; + *_pfTarget = target; + _pfTargetPath = path; + _pfRequester = requester; - _pFTargetPath->Reset(); - _pFTargetPath->SetReady(false); + _pfTargetPath->Reset(); + _pfTargetPath->SetReady(false); // prepare working path int i; - PFPointsStart(); + pfPointsStart(); // first point - //_pFPath.Add(new CAdPathPoint(source.x, source.y, 0)); + //_pfPath.Add(new CAdPathPoint(source.x, source.y, 0)); // if we're one pixel stuck, get unstuck int StartX = source.x; int StartY = source.y; int BestDistance = 1000; - if (IsBlockedAt(StartX, StartY, true, requester)) { + if (isBlockedAt(StartX, StartY, true, requester)) { int Tolerance = 2; for (int xxx = StartX - Tolerance; xxx <= StartX + Tolerance; xxx++) { for (int yyy = StartY - Tolerance; yyy <= StartY + Tolerance; yyy++) { - if (IsWalkableAt(xxx, yyy, true, requester)) { + if (isWalkableAt(xxx, yyy, true, requester)) { int Distance = abs(xxx - source.x) + abs(yyy - source.y); if (Distance < BestDistance) { StartX = xxx; @@ -223,18 +223,18 @@ bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * } } - PFPointsAdd(StartX, StartY, 0); + pfPointsAdd(StartX, StartY, 0); //CorrectTargetPoint(&target.x, &target.y); // last point - //_pFPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); - PFPointsAdd(target.x, target.y, INT_MAX); + //_pfPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); + pfPointsAdd(target.x, target.y, INT_MAX); // active waypoints for (i = 0; i < _waypointGroups.GetSize(); i++) { if (_waypointGroups[i]->_active) { - PFAddWaypointGroup(_waypointGroups[i], requester); + pfAddWaypointGroup(_waypointGroups[i], requester); } } @@ -242,13 +242,13 @@ bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * // free waypoints for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { - PFAddWaypointGroup(_objects[i]->_currentWptGroup, requester); + pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } CAdGame *AdGame = (CAdGame *)Game; for (i = 0; i < AdGame->_objects.GetSize(); i++) { if (AdGame->_objects[i]->_active && AdGame->_objects[i] != requester && AdGame->_objects[i]->_currentWptGroup) { - PFAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); + pfAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); } } @@ -258,20 +258,20 @@ bool CAdScene::GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * ////////////////////////////////////////////////////////////////////////// -void CAdScene::PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { +void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { if (!Wpt->_active) return; for (int i = 0; i < Wpt->_points.GetSize(); i++) { - if (IsBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; + if (isBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; - //_pFPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); - PFPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); + //_pfPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + pfPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); } } ////////////////////////////////////////////////////////////////////////// -float CAdScene::GetZoomAt(int X, int Y) { +float CAdScene::getZoomAt(int X, int Y) { float ret = 100; bool found = false; @@ -287,14 +287,14 @@ float CAdScene::GetZoomAt(int X, int Y) { } } } - if (!found) ret = GetScaleAt(Y); + if (!found) ret = getScaleAt(Y); return ret; } ////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { +uint32 CAdScene::getAlphaAt(int X, int Y, bool ColorCheck) { if (!Game->_dEBUG_DebugMode) ColorCheck = false; uint32 ret; @@ -315,7 +315,7 @@ uint32 CAdScene::GetAlphaAt(int X, int Y, bool ColorCheck) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { +bool CAdScene::isBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { bool ret = true; @@ -358,7 +358,7 @@ bool CAdScene::IsBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques ////////////////////////////////////////////////////////////////////////// -bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { +bool CAdScene::isWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { bool ret = false; @@ -394,7 +394,7 @@ bool CAdScene::IsWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Reque ////////////////////////////////////////////////////////////////////////// -int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { +int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { double xStep, yStep, X, Y; int xLength, yLength, xCount, yCount; int X1, Y1, X2, Y2; @@ -417,7 +417,7 @@ int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { Y = Y1; for (xCount = X1; xCount < X2; xCount++) { - if (IsBlockedAt(xCount, (int)Y, true, requester)) return -1; + if (isBlockedAt(xCount, (int)Y, true, requester)) return -1; Y += yStep; } } else { @@ -430,7 +430,7 @@ int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { X = X1; for (yCount = Y1; yCount < Y2; yCount++) { - if (IsBlockedAt((int)X, yCount, true, requester)) return -1; + if (isBlockedAt((int)X, yCount, true, requester)) return -1; X += xStep; } } @@ -439,63 +439,63 @@ int CAdScene::GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::PathFinderStep() { +void CAdScene::pathFinderStep() { int i; // get lowest unmarked int lowest_dist = INT_MAX; CAdPathPoint *lowest_pt = NULL; - for (i = 0; i < _pFPointsNum; i++) - if (!_pFPath[i]->_marked && _pFPath[i]->_distance < lowest_dist) { - lowest_dist = _pFPath[i]->_distance; - lowest_pt = _pFPath[i]; + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowest_dist) { + lowest_dist = _pfPath[i]->_distance; + lowest_pt = _pfPath[i]; } if (lowest_pt == NULL) { // no path -> terminate PathFinder - _pFReady = true; - _pFTargetPath->SetReady(true); + _pfReady = true; + _pfTargetPath->SetReady(true); return; } lowest_pt->_marked = true; // target point marked, generate path and terminate - if (lowest_pt->x == _pFTarget->x && lowest_pt->y == _pFTarget->y) { + if (lowest_pt->x == _pfTarget->x && lowest_pt->y == _pfTarget->y) { while (lowest_pt != NULL) { - _pFTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); + _pfTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); lowest_pt = lowest_pt->_origin; } - _pFReady = true; - _pFTargetPath->SetReady(true); + _pfReady = true; + _pfTargetPath->SetReady(true); return; } // otherwise keep on searching - for (i = 0; i < _pFPointsNum; i++) - if (!_pFPath[i]->_marked) { - int j = GetPointsDist(*lowest_pt, *_pFPath[i], _pFRequester); - if (j != -1 && lowest_pt->_distance + j < _pFPath[i]->_distance) { - _pFPath[i]->_distance = lowest_pt->_distance + j; - _pFPath[i]->_origin = lowest_pt; + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked) { + int j = getPointsDist(*lowest_pt, *_pfPath[i], _pfRequester); + if (j != -1 && lowest_pt->_distance + j < _pfPath[i]->_distance) { + _pfPath[i]->_distance = lowest_pt->_distance + j; + _pfPath[i]->_origin = lowest_pt; } } } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::InitLoop() { +HRESULT CAdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = Game->_currentTime; - while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) { + while (!_pfReady && CBPlatform::GetTime() - start <= _pfMaxTime) { PathFinderStep(); nu_steps++; } - if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pFMaxTime=%d", nu_steps, _pFReady ? "finished" : "not yet done", _pFMaxTime); + if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); #else uint32 start = Game->_currentTime; - while (!_pFReady && CBPlatform::GetTime() - start <= _pFMaxTime) PathFinderStep(); + while (!_pfReady && CBPlatform::GetTime() - start <= _pfMaxTime) pathFinderStep(); #endif return S_OK; @@ -705,7 +705,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { delete entity; entity = NULL; } else { - AddObject(entity); + addObject(entity); } } break; @@ -849,8 +849,8 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); - SortScaleLevels(); - SortRotLevels(); + sortScaleLevels(); + sortRotLevels(); _initialized = true; @@ -859,7 +859,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::TraverseNodes(bool Update) { +HRESULT CAdScene::traverseNodes(bool Update) { if (!_initialized) return S_OK; int j, k; @@ -922,10 +922,10 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); + getViewportSize(&ViewportWidth, &ViewportHeight); int ViewportX, ViewportY; - GetViewportOffset(&ViewportX, &ViewportY); + getViewportOffset(&ViewportX, &ViewportY); int ScrollableX = _width - ViewportWidth; int ScrollableY = _height - ViewportHeight; @@ -996,7 +996,7 @@ HRESULT CAdScene::TraverseNodes(bool Update) { if (Node->_region->_blocked) break; if (Node->_region->_decoration) break; - if (!Update) DisplayRegionContent(Node->_region); + if (!Update) displayRegionContent(Node->_region); } break; default: @@ -1008,9 +1008,9 @@ HRESULT CAdScene::TraverseNodes(bool Update) { // display/update all objects which are off-regions if (_layers[j]->_main) { if (Update) { - UpdateFreeObjects(); + updateFreeObjects(); } else { - DisplayRegionContent(NULL); + displayRegionContent(NULL); } } } // each layer @@ -1034,11 +1034,11 @@ HRESULT CAdScene::TraverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::display() { - return TraverseNodes(false); + return traverseNodes(false); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::UpdateFreeObjects() { +HRESULT CAdScene::updateFreeObjects() { CAdGame *AdGame = (CAdGame *)Game; int i; @@ -1063,7 +1063,7 @@ HRESULT CAdScene::UpdateFreeObjects() { if (_autoScroll && Game->_mainObject != NULL) { - ScrollToObject(Game->_mainObject); + scrollToObject(Game->_mainObject); } @@ -1072,7 +1072,7 @@ HRESULT CAdScene::UpdateFreeObjects() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { +HRESULT CAdScene::displayRegionContent(CAdRegion *Region, bool Display3DOnly) { CAdGame *AdGame = (CAdGame *)Game; CBArray Objects; CAdObject *Obj; @@ -1096,7 +1096,7 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { } // sort by _posY - qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::CompareObjs); + qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); // display them for (i = 0; i < Objects.GetSize(); i++) { @@ -1127,7 +1127,7 @@ HRESULT CAdScene::DisplayRegionContent(CAdRegion *Region, bool Display3DOnly) { } ////////////////////////////////////////////////////////////////////////// -int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { +int CAdScene::compareObjs(const void *Obj1, const void *Obj2) { CAdObject *Object1 = *(CAdObject **)Obj1; CAdObject *Object2 = *(CAdObject **)Obj2; @@ -1137,7 +1137,7 @@ int CAdScene::CompareObjs(const void *Obj1, const void *Obj2) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { +HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { CAdGame *AdGame = (CAdGame *)Game; CAdObject *obj; int i; @@ -1189,13 +1189,13 @@ HRESULT CAdScene::DisplayRegionContentOld(CAdRegion *Region) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::update() { - return TraverseNodes(true); + return traverseNodes(true); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::ScrollTo(int OffsetX, int OffsetY) { +void CAdScene::scrollTo(int OffsetX, int OffsetY) { int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); + getViewportSize(&ViewportWidth, &ViewportHeight); int OrigOffsetLeft = _targetOffsetLeft; int OrigOffsetTop = _targetOffsetTop; @@ -1218,21 +1218,21 @@ void CAdScene::ScrollTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::ScrollToObject(CBObject *Object) { - if (Object) ScrollTo(Object->_posX, Object->_posY - Object->getHeight() / 2); +void CAdScene::scrollToObject(CBObject *Object) { + if (Object) scrollTo(Object->_posX, Object->_posY - Object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::SkipToObject(CBObject *Object) { - if (Object) SkipTo(Object->_posX, Object->_posY - Object->getHeight() / 2); +void CAdScene::skipToObject(CBObject *Object) { + if (Object) skipTo(Object->_posX, Object->_posY - Object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::SkipTo(int OffsetX, int OffsetY) { +void CAdScene::skipTo(int OffsetX, int OffsetY) { int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); + getViewportSize(&ViewportWidth, &ViewportHeight); _offsetLeft = MAX(0, OffsetX - ViewportWidth / 2); _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); @@ -1256,7 +1256,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); CAdActor *act = new CAdActor(Game); if (act && SUCCEEDED(act->loadFile(Stack->Pop()->GetString()))) { - AddObject(act); + addObject(act); Stack->PushNative(act, true); } else { delete act; @@ -1273,7 +1273,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); CAdEntity *ent = new CAdEntity(Game); if (ent && SUCCEEDED(ent->loadFile(Stack->Pop()->GetString()))) { - AddObject(ent); + addObject(ent); Stack->PushNative(ent, true); } else { delete ent; @@ -1291,7 +1291,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *Val = Stack->Pop(); CAdEntity *Ent = new CAdEntity(Game); - AddObject(Ent); + addObject(Ent); if (!Val->IsNULL()) Ent->setName(Val->GetString()); Stack->PushNative(Ent, true); return S_OK; @@ -1304,7 +1304,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); CScValue *val = Stack->Pop(); CAdObject *obj = (CAdObject *)val->GetNative(); - RemoveObject(obj); + removeObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); Stack->PushNULL(); @@ -1319,9 +1319,9 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *val1 = Stack->Pop(); CScValue *val2 = Stack->Pop(); if (val1->IsNative()) { - SkipToObject((CBObject *)val1->GetNative()); + skipToObject((CBObject *)val1->GetNative()); } else { - SkipTo(val1->GetInt(), val2->GetInt()); + skipTo(val1->GetInt(), val2->GetInt()); } Stack->PushNULL(); return S_OK; @@ -1335,9 +1335,9 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi CScValue *val1 = Stack->Pop(); CScValue *val2 = Stack->Pop(); if (val1->IsNative()) { - ScrollToObject((CBObject *)val1->GetNative()); + scrollToObject((CBObject *)val1->GetNative()); } else { - ScrollTo(val1->GetInt(), val2->GetInt()); + scrollTo(val1->GetInt(), val2->GetInt()); } if (strcmp(Name, "ScrollTo") == 0) Script->WaitForExclusive(this); Stack->PushNULL(); @@ -1387,7 +1387,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(1); const char *nodeName = Stack->Pop()->GetString(); - CBObject *node = GetNodeByName(nodeName); + CBObject *node = getNodeByName(nodeName); if (node) Stack->PushNative((CBScriptable *)node, true); else Stack->PushNULL(); @@ -1455,7 +1455,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - Stack->PushBool(IsBlockedAt(X, Y)); + Stack->PushBool(isBlockedAt(X, Y)); return S_OK; } @@ -1467,7 +1467,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - Stack->PushBool(IsWalkableAt(X, Y)); + Stack->PushBool(isWalkableAt(X, Y)); return S_OK; } @@ -1479,7 +1479,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - Stack->PushFloat(GetZoomAt(X, Y)); + Stack->PushFloat(getZoomAt(X, Y)); return S_OK; } @@ -1491,7 +1491,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - Stack->PushFloat(GetRotationAt(X, Y)); + Stack->PushFloat(getRotationAt(X, Y)); return S_OK; } @@ -1561,7 +1561,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Stack->CorrectParams(2); int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - Stack->PushBool(PointInViewport(X, Y)); + Stack->PushBool(pointInViewport(X, Y)); return S_OK; } @@ -1729,7 +1729,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseX") == 0) { int ViewportX; - GetViewportOffset(&ViewportX); + getViewportOffset(&ViewportX); _scValue->SetInt(Game->_mousePos.x + _offsetLeft - ViewportX); return _scValue; @@ -1740,7 +1740,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "MouseY") == 0) { int ViewportY; - GetViewportOffset(NULL, &ViewportY); + getViewportOffset(NULL, &ViewportY); _scValue->SetInt(Game->_mousePos.y + _offsetTop - ViewportY); return _scValue; @@ -1914,7 +1914,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { _offsetLeft = Value->GetInt(); int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); + getViewportSize(&ViewportWidth, &ViewportHeight); _offsetLeft = MAX(0, _offsetLeft - ViewportWidth / 2); _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); @@ -1930,7 +1930,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { _offsetTop = Value->GetInt(); int ViewportWidth, ViewportHeight; - GetViewportSize(&ViewportWidth, &ViewportHeight); + getViewportSize(&ViewportWidth, &ViewportHeight); _offsetTop = MAX(0, _offsetTop - ViewportHeight / 2); _offsetTop = MIN(_offsetTop, _height - ViewportHeight); @@ -1950,14 +1950,14 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::AddObject(CAdObject *Object) { +HRESULT CAdScene::addObject(CAdObject *Object) { _objects.Add(Object); return Game->RegisterObject(Object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::RemoveObject(CAdObject *Object) { +HRESULT CAdScene::removeObject(CAdObject *Object) { for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] == Object) { _objects.RemoveAt(i); @@ -2067,7 +2067,7 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SortScaleLevels() { +HRESULT CAdScene::sortScaleLevels() { bool changed; do { changed = false; @@ -2088,7 +2088,7 @@ HRESULT CAdScene::SortScaleLevels() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SortRotLevels() { +HRESULT CAdScene::sortRotLevels() { bool changed; do { changed = false; @@ -2109,7 +2109,7 @@ HRESULT CAdScene::SortRotLevels() { ////////////////////////////////////////////////////////////////////////// -float CAdScene::GetScaleAt(int Y) { +float CAdScene::getScaleAt(int Y) { CAdScaleLevel *prev = NULL; CAdScaleLevel *next = NULL; @@ -2171,13 +2171,13 @@ HRESULT CAdScene::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_paralaxScrolling)); persistMgr->transfer(TMEMBER(_persistentState)); persistMgr->transfer(TMEMBER(_persistentStateSprites)); - persistMgr->transfer(TMEMBER(_pFMaxTime)); - _pFPath.persist(persistMgr); - persistMgr->transfer(TMEMBER(_pFPointsNum)); - persistMgr->transfer(TMEMBER(_pFReady)); - persistMgr->transfer(TMEMBER(_pFRequester)); - persistMgr->transfer(TMEMBER(_pFTarget)); - persistMgr->transfer(TMEMBER(_pFTargetPath)); + persistMgr->transfer(TMEMBER(_pfMaxTime)); + _pfPath.persist(persistMgr); + persistMgr->transfer(TMEMBER(_pfPointsNum)); + persistMgr->transfer(TMEMBER(_pfReady)); + persistMgr->transfer(TMEMBER(_pfRequester)); + persistMgr->transfer(TMEMBER(_pfTarget)); + persistMgr->transfer(TMEMBER(_pfTargetPath)); _rotLevels.persist(persistMgr); _scaleLevels.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollPixelsH)); @@ -2195,12 +2195,12 @@ HRESULT CAdScene::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::AfterLoad() { +HRESULT CAdScene::afterLoad() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { +HRESULT CAdScene::correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { double xStep, yStep, X, Y; int xLength, yLength, xCount, yCount; int X1, Y1, X2, Y2; @@ -2227,7 +2227,7 @@ HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int Y = Y1; for (xCount = X1; xCount < X2; xCount++) { - if (IsWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { + if (isWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { *TargetX = xCount; *TargetY = (int)Y; return S_OK; @@ -2246,7 +2246,7 @@ HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int X = X1; for (yCount = Y1; yCount < Y2; yCount++) { - if (IsWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { + if (isWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { *TargetX = (int)X; *TargetY = yCount; return S_OK; @@ -2259,11 +2259,11 @@ HRESULT CAdScene::CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { +HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { int x = *X; int y = *Y; - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { + if (isWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { return S_OK; } @@ -2271,7 +2271,7 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo int length_right = 0; bool found_right = false; for (x = *X, y = *Y; x < _mainLayer->_width; x++, length_right++) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { + if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { found_right = true; break; } @@ -2281,7 +2281,7 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo int length_left = 0; bool found_left = false; for (x = *X, y = *Y; x >= 0; x--, length_left--) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { + if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { found_left = true; break; } @@ -2291,7 +2291,7 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo int length_up = 0; bool found_up = false; for (x = *X, y = *Y; y >= 0; y--, length_up--) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { + if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { found_up = true; break; } @@ -2301,7 +2301,7 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo int length_down = 0; bool found_down = false; for (x = *X, y = *Y; y < _mainLayer->_height; y++, length_down++) { - if (IsWalkableAt(x, y, CheckFreeObjects, Requester) && IsWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { + if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { found_down = true; break; } @@ -2330,35 +2330,35 @@ HRESULT CAdScene::CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, boo else *Y = *Y + OffsetY; - if (!IsWalkableAt(*X, *Y)) return CorrectTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); + if (!isWalkableAt(*X, *Y)) return correctTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); else return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::PFPointsStart() { - _pFPointsNum = 0; +void CAdScene::pfPointsStart() { + _pfPointsNum = 0; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::PFPointsAdd(int X, int Y, int Distance) { - if (_pFPointsNum >= _pFPath.GetSize()) { - _pFPath.Add(new CAdPathPoint(X, Y, Distance)); +void CAdScene::pfPointsAdd(int X, int Y, int Distance) { + if (_pfPointsNum >= _pfPath.GetSize()) { + _pfPath.Add(new CAdPathPoint(X, Y, Distance)); } else { - _pFPath[_pFPointsNum]->x = X; - _pFPath[_pFPointsNum]->y = Y; - _pFPath[_pFPointsNum]->_distance = Distance; - _pFPath[_pFPointsNum]->_marked = false; - _pFPath[_pFPointsNum]->_origin = NULL; + _pfPath[_pfPointsNum]->x = X; + _pfPath[_pfPointsNum]->y = Y; + _pfPath[_pfPointsNum]->_distance = Distance; + _pfPath[_pfPointsNum]->_marked = false; + _pfPath[_pfPointsNum]->_origin = NULL; } - _pFPointsNum++; + _pfPointsNum++; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { +HRESULT CAdScene::getViewportOffset(int *OffsetX, int *OffsetY) { CAdGame *AdGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (OffsetX) *OffsetX = _viewport->_offsetX; @@ -2375,7 +2375,7 @@ HRESULT CAdScene::GetViewportOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { +HRESULT CAdScene::getViewportSize(int *Width, int *Height) { CAdGame *AdGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (Width) *Width = _viewport->getWidth(); @@ -2392,43 +2392,43 @@ HRESULT CAdScene::GetViewportSize(int *Width, int *Height) { ////////////////////////////////////////////////////////////////////////// -int CAdScene::GetOffsetLeft() { +int CAdScene::getOffsetLeft() { int ViewportX; - GetViewportOffset(&ViewportX); + getViewportOffset(&ViewportX); return _offsetLeft - ViewportX; } ////////////////////////////////////////////////////////////////////////// -int CAdScene::GetOffsetTop() { +int CAdScene::getOffsetTop() { int ViewportY; - GetViewportOffset(NULL, &ViewportY); + getViewportOffset(NULL, &ViewportY); return _offsetTop - ViewportY; } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::PointInViewport(int X, int Y) { +bool CAdScene::pointInViewport(int X, int Y) { int Left, Top, Width, Height; - GetViewportOffset(&Left, &Top); - GetViewportSize(&Width, &Height); + getViewportOffset(&Left, &Top); + getViewportSize(&Width, &Height); return X >= Left && X <= Left + Width && Y >= Top && Y <= Top + Height; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::SetOffset(int OffsetLeft, int OffsetTop) { +void CAdScene::setOffset(int OffsetLeft, int OffsetTop) { _offsetLeft = OffsetLeft; _offsetTop = OffsetTop; } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetNodeByName(const char *Name) { +CBObject *CAdScene::getNodeByName(const char *Name) { int i; CBObject *ret = NULL; @@ -2473,19 +2473,19 @@ CBObject *CAdScene::GetNodeByName(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::SaveState() { - return PersistState(true); +HRESULT CAdScene::saveState() { + return persistState(true); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::LoadState() { - return PersistState(false); +HRESULT CAdScene::loadState() { + return persistState(false); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::PersistState(bool Saving) { +HRESULT CAdScene::persistState(bool Saving) { if (!_persistentState) return S_OK; CAdGame *AdGame = (CAdGame *)Game; @@ -2553,7 +2553,7 @@ HRESULT CAdScene::PersistState(bool Saving) { ////////////////////////////////////////////////////////////////////////// -float CAdScene::GetRotationAt(int X, int Y) { +float CAdScene::getRotationAt(int X, int Y) { CAdRotLevel *prev = NULL; CAdRotLevel *next = NULL; @@ -2579,7 +2579,7 @@ float CAdScene::GetRotationAt(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::HandleItemAssociations(const char *ItemName, bool Show) { +HRESULT CAdScene::handleItemAssociations(const char *ItemName, bool Show) { int i; for (i = 0; i < _layers.GetSize(); i++) { @@ -2605,7 +2605,7 @@ HRESULT CAdScene::HandleItemAssociations(const char *ItemName, bool Show) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { +HRESULT CAdScene::getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { int i; int NumUsed = 0; if (_mainLayer) { @@ -2633,9 +2633,9 @@ HRESULT CAdScene::restoreDeviceObjects() { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetNextAccessObject(CBObject *CurrObject) { +CBObject *CAdScene::getNextAccessObject(CBObject *CurrObject) { CBArray Objects; - GetSceneObjects(Objects, true); + getSceneObjects(Objects, true); if (Objects.GetSize() == 0) return NULL; else { @@ -2653,9 +2653,9 @@ CBObject *CAdScene::GetNextAccessObject(CBObject *CurrObject) { } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { +CBObject *CAdScene::getPrevAccessObject(CBObject *CurrObject) { CBArray Objects; - GetSceneObjects(Objects, true); + getSceneObjects(Objects, true); if (Objects.GetSize() == 0) return NULL; else { @@ -2674,7 +2674,7 @@ CBObject *CAdScene::GetPrevAccessObject(CBObject *CurrObject) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdScene::getSceneObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _layers.GetSize(); i++) { // close-up layer -> remove everything below it if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); @@ -2692,7 +2692,7 @@ HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bo case OBJECT_REGION: { CBArray RegionObj; - GetRegionObjects(Node->_region, RegionObj, InteractiveOnly); + getRegionObjects(Node->_region, RegionObj, InteractiveOnly); for (int New = 0; New < RegionObj.GetSize(); New++) { bool Found = false; for (int Old = 0; Old < Objects.GetSize(); Old++) { @@ -2715,7 +2715,7 @@ HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bo // objects outside any region CBArray RegionObj; - GetRegionObjects(NULL, RegionObj, InteractiveOnly); + getRegionObjects(NULL, RegionObj, InteractiveOnly); for (int New = 0; New < RegionObj.GetSize(); New++) { bool Found = false; for (int Old = 0; Old < Objects.GetSize(); Old++) { @@ -2733,7 +2733,7 @@ HRESULT CAdScene::GetSceneObjects(CBArray &Objects, bo ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdScene::getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { CAdGame *AdGame = (CAdGame *)Game; CAdObject *Obj; @@ -2760,7 +2760,7 @@ HRESULT CAdScene::GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - HRESULT GetRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + HRESULT getSceneObjects(CBArray &Objects, bool InteractiveOnly); + HRESULT getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - HRESULT AfterLoad(); + HRESULT afterLoad(); - HRESULT GetRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - HRESULT HandleItemAssociations(const char *ItemName, bool Show); + HRESULT getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + HRESULT handleItemAssociations(const char *ItemName, bool Show); CUIWindow *_shieldWindow; - float GetRotationAt(int X, int Y); - HRESULT LoadState(); - HRESULT SaveState(); + float getRotationAt(int X, int Y); + HRESULT loadState(); + HRESULT saveState(); bool _persistentState; bool _persistentStateSprites; - CBObject *GetNodeByName(const char *Name); - void SetOffset(int OffsetLeft, int OffsetTop); - bool PointInViewport(int X, int Y); - int GetOffsetTop(); - int GetOffsetLeft(); - HRESULT GetViewportSize(int *Width = NULL, int *Height = NULL); - HRESULT GetViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + CBObject *getNodeByName(const char *Name); + void setOffset(int OffsetLeft, int OffsetTop); + bool pointInViewport(int X, int Y); + int getOffsetTop(); + int getOffsetLeft(); + HRESULT getViewportSize(int *Width = NULL, int *Height = NULL); + HRESULT getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); CBViewport *_viewport; CBFader *_fader; - int _pFPointsNum; - void PFPointsAdd(int X, int Y, int Distance); - void PFPointsStart(); + int _pfPointsNum; + void pfPointsAdd(int X, int Y, int Distance); + void pfPointsStart(); bool _initialized; - HRESULT CorrectTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - HRESULT CorrectTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + HRESULT correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + HRESULT correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); DECLARE_PERSISTENT(CAdScene, CBObject) - HRESULT DisplayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - HRESULT DisplayRegionContentOld(CAdRegion *Region = NULL); - static int CompareObjs(const void *Obj1, const void *Obj2); - - HRESULT UpdateFreeObjects(); - HRESULT TraverseNodes(bool Update = false); - float GetScaleAt(int Y); - HRESULT SortScaleLevels(); - HRESULT SortRotLevels(); + HRESULT displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + HRESULT displayRegionContentOld(CAdRegion *Region = NULL); + static int compareObjs(const void *Obj1, const void *Obj2); + + HRESULT updateFreeObjects(); + HRESULT traverseNodes(bool Update = false); + float getScaleAt(int Y); + HRESULT sortScaleLevels(); + HRESULT sortRotLevels(); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - uint32 GetAlphaAt(int X, int Y, bool ColorCheck = false); + uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; - void SkipTo(int OffsetX, int OffsetY); - void SetDefaults(); + void skipTo(int OffsetX, int OffsetY); + void setDefaults(); void cleanup(); - void SkipToObject(CBObject *Object); - void ScrollToObject(CBObject *Object); - void ScrollTo(int OffsetX, int OffsetY); + void skipToObject(CBObject *Object); + void scrollToObject(CBObject *Object); + void scrollTo(int OffsetX, int OffsetY); virtual HRESULT update(); bool _autoScroll; int _targetOffsetTop; @@ -110,14 +110,14 @@ public: uint32 _lastTimeH; virtual HRESULT display(); - uint32 _pFMaxTime; - HRESULT InitLoop(); - void PathFinderStep(); - bool IsBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool IsWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + uint32 _pfMaxTime; + HRESULT initLoop(); + void pathFinderStep(); + bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); CAdLayer *_mainLayer; - float GetZoomAt(int X, int Y); - bool GetPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); + float getZoomAt(int X, int Y); + bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); CAdScene(CBGame *inGame); virtual ~CAdScene(); CBArray _layers; @@ -127,8 +127,8 @@ public: HRESULT loadBuffer(byte *Buffer, bool Complete = true); int _width; int _height; - HRESULT AddObject(CAdObject *Object); - HRESULT RemoveObject(CAdObject *Object); + HRESULT addObject(CAdObject *Object); + HRESULT removeObject(CAdObject *Object); int _editorMarginH; int _editorMarginV; uint32 _editorColFrame; @@ -153,7 +153,7 @@ public: CBArray _rotLevels; virtual HRESULT restoreDeviceObjects(); - int GetPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface virtual CScValue *scGetProperty(const char *Name); @@ -163,13 +163,13 @@ public: private: - HRESULT PersistState(bool Saving = true); - void PFAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); - bool _pFReady; - CBPoint *_pFTarget; - CAdPath *_pFTargetPath; - CBObject *_pFRequester; - CBArray _pFPath; + HRESULT persistState(bool Saving = true); + void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + bool _pfReady; + CBPoint *_pfTarget; + CAdPath *_pfTargetPath; + CBObject *_pfRequester; + CBArray _pfPath; int _offsetTop; int _offsetLeft; diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index d1584f192e..dbb4a0054f 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -53,7 +53,7 @@ CAdSceneNode::~CAdSceneNode() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { +HRESULT CAdSceneNode::setEntity(CAdEntity *Entity) { _type = OBJECT_ENTITY; _entity = Entity; return Game->RegisterObject(Entity); @@ -61,7 +61,7 @@ HRESULT CAdSceneNode::SetEntity(CAdEntity *Entity) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::SetRegion(CAdRegion *Region) { +HRESULT CAdSceneNode::setRegion(CAdRegion *Region) { _type = OBJECT_REGION; _region = Region; return Game->RegisterObject(Region); diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h index f6cc121fbc..198a83beb8 100644 --- a/engines/wintermute/Ad/AdSceneNode.h +++ b/engines/wintermute/Ad/AdSceneNode.h @@ -39,8 +39,8 @@ namespace WinterMute { class CAdSceneNode : public CBObject { public: DECLARE_PERSISTENT(CAdSceneNode, CBObject) - HRESULT SetRegion(CAdRegion *Region); - HRESULT SetEntity(CAdEntity *Entity); + HRESULT setRegion(CAdRegion *Region); + HRESULT setEntity(CAdEntity *Entity); CAdEntity *_entity; CAdRegion *_region; TObjectType _type; diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index a153c86854..0a526e4afa 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -178,8 +178,8 @@ HRESULT CAdSentence::display() { int y = _pos.y; if (!_fixedPos) { - x = x - ((CAdGame *)Game)->_scene->GetOffsetLeft(); - y = y - ((CAdGame *)Game)->_scene->GetOffsetTop(); + x = x - ((CAdGame *)Game)->_scene->getOffsetLeft(); + y = y - ((CAdGame *)Game)->_scene->getOffsetTop(); } -- cgit v1.2.3 From fc2a2ff8d3ee6e083b1b10da4b96bd573f6a6660 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 13:28:20 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in AdResponseBox and AdResponseContext --- engines/wintermute/Ad/AdGame.cpp | 18 +++++++------- engines/wintermute/Ad/AdResponseBox.cpp | 38 ++++++++++++++--------------- engines/wintermute/Ad/AdResponseBox.h | 20 +++++++-------- engines/wintermute/Ad/AdResponseContext.cpp | 2 +- engines/wintermute/Ad/AdResponseContext.h | 2 +- 5 files changed, 40 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 85eb897c6d..56e0961743 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -510,8 +510,8 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "ClearResponses") == 0) { Stack->CorrectParams(0); - _responseBox->ClearResponses(); - _responseBox->ClearButtons(); + _responseBox->clearResponses(); + _responseBox->clearButtons(); Stack->PushNULL(); return S_OK; } @@ -524,7 +524,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This bool AutoSelectLast = Stack->Pop()->GetBool(); if (_responseBox) { - _responseBox->WeedResponses(); + _responseBox->weedResponses(); if (_responseBox->_responses.GetSize() == 0) { Stack->PushNULL(); @@ -534,12 +534,12 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { Stack->PushInt(_responseBox->_responses[0]->_iD); - _responseBox->HandleResponse(_responseBox->_responses[0]); - _responseBox->ClearResponses(); + _responseBox->handleResponse(_responseBox->_responses[0]); + _responseBox->clearResponses(); return S_OK; } - _responseBox->CreateButtons(); + _responseBox->createButtons(); _responseBox->_waitingScript = Script; Script->WaitForExclusive(_responseBox); _state = GAME_SEMI_FROZEN; @@ -558,7 +558,7 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This else if (strcmp(Name, "GetNumResponses") == 0) { Stack->CorrectParams(0); if (_responseBox) { - _responseBox->WeedResponses(); + _responseBox->weedResponses(); Stack->PushInt(_responseBox->_responses.GetSize()); } else { Script->RuntimeError("Game.GetNumResponses: response box is not defined"); @@ -1611,7 +1611,7 @@ HRESULT CAdGame::AddBranchResponse(int ID) { if (BranchResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; - r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); _responsesBranch.Add(r); return S_OK; } @@ -1634,7 +1634,7 @@ HRESULT CAdGame::AddGameResponse(int ID) { if (GameResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; - r->SetContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); + r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); _responsesGame.Add(r); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index bf449214e1..c14497a4c4 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -85,15 +85,15 @@ CAdResponseBox::~CAdResponseBox() { if (_font) Game->_fontStorage->RemoveFont(_font); if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - ClearResponses(); - ClearButtons(); + clearResponses(); + clearButtons(); _waitingScript = NULL; } ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::ClearResponses() { +void CAdResponseBox::clearResponses() { for (int i = 0; i < _responses.GetSize(); i++) { delete _responses[i]; } @@ -102,7 +102,7 @@ void CAdResponseBox::ClearResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::ClearButtons() { +void CAdResponseBox::clearButtons() { for (int i = 0; i < _respButtons.GetSize(); i++) { delete _respButtons[i]; } @@ -111,7 +111,7 @@ void CAdResponseBox::ClearButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::InvalidateButtons() { +HRESULT CAdResponseBox::invalidateButtons() { for (int i = 0; i < _respButtons.GetSize(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; @@ -125,8 +125,8 @@ HRESULT CAdResponseBox::InvalidateButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::CreateButtons() { - ClearButtons(); +HRESULT CAdResponseBox::createButtons() { + clearButtons(); _scrollOffset = 0; for (int i = 0; i < _responses.GetSize(); i++) { @@ -493,13 +493,13 @@ HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { _scrollOffset++; } else if (scumm_stricmp(obj->_name, "response") == 0) { if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD); - HandleResponse(_responses[param2]); + handleResponse(_responses[param2]); _waitingScript = NULL; Game->_state = GAME_RUNNING; ((CAdGame *)Game)->_stateEx = GAME_NORMAL; _ready = true; - InvalidateButtons(); - ClearResponses(); + invalidateButtons(); + clearResponses(); } else return CBObject::listen(param1, param2); break; default: @@ -536,7 +536,7 @@ HRESULT CAdResponseBox::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::WeedResponses() { +HRESULT CAdResponseBox::weedResponses() { CAdGame *AdGame = (CAdGame *)Game; for (int i = 0; i < _responses.GetSize(); i++) { @@ -566,15 +566,15 @@ HRESULT CAdResponseBox::WeedResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::SetLastResponseText(const char *Text, const char *TextOrig) { +void CAdResponseBox::setLastResponseText(const char *Text, const char *TextOrig) { CBUtils::SetString(&_lastResponseText, Text); CBUtils::SetString(&_lastResponseTextOrig, TextOrig); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { - SetLastResponseText(Response->_text, Response->_textOrig); +HRESULT CAdResponseBox::handleResponse(CAdResponse *Response) { + setLastResponseText(Response->_text, Response->_textOrig); CAdGame *AdGame = (CAdGame *)Game; @@ -595,9 +595,9 @@ HRESULT CAdResponseBox::HandleResponse(CAdResponse *Response) { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::GetNextAccessObject(CBObject *CurrObject) { +CBObject *CAdResponseBox::getNextAccessObject(CBObject *CurrObject) { CBArray Objects; - GetObjects(Objects, true); + getObjects(Objects, true); if (Objects.GetSize() == 0) return NULL; else { @@ -615,9 +615,9 @@ CBObject *CAdResponseBox::GetNextAccessObject(CBObject *CurrObject) { } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { +CBObject *CAdResponseBox::getPrevAccessObject(CBObject *CurrObject) { CBArray Objects; - GetObjects(Objects, true); + getObjects(Objects, true); if (Objects.GetSize() == 0) return NULL; else { @@ -635,7 +635,7 @@ CBObject *CAdResponseBox::GetPrevAccessObject(CBObject *CurrObject) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::GetObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdResponseBox::getObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _respButtons.GetSize(); i++) { Objects.Add(_respButtons[i]); } diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 82a5b4fae5..17778beaba 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -40,12 +40,12 @@ class CUIObject; class CAdResponse; class CAdResponseBox : public CBObject { public: - CBObject *GetNextAccessObject(CBObject *CurrObject); - CBObject *GetPrevAccessObject(CBObject *CurrObject); - HRESULT GetObjects(CBArray &Objects, bool InteractiveOnly); + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + HRESULT getObjects(CBArray &Objects, bool InteractiveOnly); - HRESULT HandleResponse(CAdResponse *Response); - void SetLastResponseText(const char *Text, const char *TextOrig); + HRESULT handleResponse(CAdResponse *Response); + void setLastResponseText(const char *Text, const char *TextOrig); char *_lastResponseText; char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) @@ -55,16 +55,16 @@ public: EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE } TResponseEvent; - HRESULT WeedResponses(); + HRESULT weedResponses(); HRESULT display(); int _spacing; int _scrollOffset; CBFont *_fontHover; CBFont *_font; - HRESULT CreateButtons(); - HRESULT InvalidateButtons(); - void ClearButtons(); - void ClearResponses(); + HRESULT createButtons(); + HRESULT invalidateButtons(); + void clearButtons(); + void clearResponses(); CAdResponseBox(CBGame *inGame); virtual ~CAdResponseBox(); CBArray _responses; diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 6947838ff0..d757010023 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -58,7 +58,7 @@ HRESULT CAdResponseContext::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::SetContext(const char *Context) { +void CAdResponseContext::setContext(const char *Context) { delete[] _context; _context = NULL; if (Context) { diff --git a/engines/wintermute/Ad/AdResponseContext.h b/engines/wintermute/Ad/AdResponseContext.h index f29d943e19..d6ad9a9d17 100644 --- a/engines/wintermute/Ad/AdResponseContext.h +++ b/engines/wintermute/Ad/AdResponseContext.h @@ -36,7 +36,7 @@ namespace WinterMute { class CAdResponseContext : public CBBase { public: - void SetContext(const char *Context); + void setContext(const char *Context); int _iD; char *_context; DECLARE_PERSISTENT(CAdResponseContext, CBBase) -- cgit v1.2.3 From e1597f38ff1eec5aa3cbbbe78bda069decdd14c6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 13:31:29 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BFrame and BActiveRect --- engines/wintermute/Base/BActiveRect.cpp | 8 ++++---- engines/wintermute/Base/BActiveRect.h | 2 +- engines/wintermute/Base/BFrame.cpp | 6 +++--- engines/wintermute/Base/BFrame.h | 6 +++--- engines/wintermute/Base/BSprite.cpp | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 5bb538b72f..46dd6ed51f 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -43,7 +43,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { _zoomX = 100; _zoomY = 100; _offsetX = _offsetY = 0; - ClipRect(); + clipRect(); } @@ -57,7 +57,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, i _precise = Precise; _region = NULL; _offsetX = _offsetY = 0; - ClipRect(); + clipRect(); } ////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, in _zoomY = 100; _precise = true; _frame = NULL; - ClipRect(); + clipRect(); _offsetX = OffsetX; _offsetY = OffsetY; } @@ -85,7 +85,7 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// -void CBActiveRect::ClipRect() { +void CBActiveRect::clipRect() { RECT rc; bool CustomViewport; Game->GetCurrentViewportRect(&rc, &CustomViewport); diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index fe99f76ea1..1577c2d9b2 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -37,7 +37,7 @@ class CBSubFrame; class CBObject; class CBActiveRect: CBBase { public: - void ClipRect(); + void clipRect(); bool _precise; float _zoomX; float _zoomY; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index b7526d4da9..5dd5627e58 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -76,7 +76,7 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { +HRESULT CBFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { HRESULT res; for (int i = 0; i < _subframes.GetSize(); i++) { @@ -88,7 +88,7 @@ HRESULT CBFrame::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::OneTimeDisplay(CBObject *Owner, bool Muted) { +HRESULT CBFrame::oneTimeDisplay(CBObject *Owner, bool Muted) { if (_sound && !Muted) { if (Owner) Owner->updateOneSound(_sound); _sound->play(); @@ -326,7 +326,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { +bool CBFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { if (!Rect) return false; CBPlatform::SetRectEmpty(Rect); diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index a9030b8848..df33303d6d 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -42,17 +42,17 @@ class CBFrame: public CBScriptable { public: bool _killSound; bool _keyframe; - HRESULT OneTimeDisplay(CBObject *Owner, bool Muted = false); + HRESULT oneTimeDisplay(CBObject *Owner, bool Muted = false); DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); int _moveY; int _moveX; uint32 _delay; CBArray _subframes; - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); + HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); CBFrame(CBGame *inGame); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index e31cb80d7c..8683fbb496 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -392,11 +392,11 @@ HRESULT CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float Z KillAllSounds(); } applyEvent("FrameChanged"); - _frames[_currentFrame]->OneTimeDisplay(_owner, Game->_editorMode && _editorMuted); + _frames[_currentFrame]->oneTimeDisplay(_owner, Game->_editorMode && _editorMuted); } // draw frame - return _frames[_currentFrame]->Draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); + return _frames[_currentFrame]->draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); } @@ -421,7 +421,7 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc RECT frame; RECT temp; CBPlatform::CopyRect(&temp, Rect); - _frames[i]->GetBoundingRect(&frame, X, Y, ScaleX, ScaleY); + _frames[i]->getBoundingRect(&frame, X, Y, ScaleX, ScaleY); CBPlatform::UnionRect(Rect, &temp, &frame); } return true; -- cgit v1.2.3 From b46750869c72df19d29b5cad4aac483b0046afc2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 13:43:16 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the Font-classes. --- engines/wintermute/Ad/AdGame.cpp | 4 +-- engines/wintermute/Ad/AdItem.cpp | 4 +-- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Base/BFont.cpp | 14 ++++---- engines/wintermute/Base/BFont.h | 16 ++++----- engines/wintermute/Base/BFontBitmap.cpp | 34 +++++++++---------- engines/wintermute/Base/BFontBitmap.h | 16 ++++----- engines/wintermute/Base/BFontStorage.cpp | 4 +-- engines/wintermute/Base/BFontTT.cpp | 42 ++++++++++++------------ engines/wintermute/Base/BFontTT.h | 28 ++++++++-------- engines/wintermute/Base/BGame.cpp | 22 ++++++------- engines/wintermute/Base/scriptables/SXStore.cpp | 2 +- engines/wintermute/Base/scriptables/SXStore.h | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.h | 2 +- engines/wintermute/UI/UIButton.cpp | 8 ++--- engines/wintermute/UI/UIEdit.cpp | 30 ++++++++--------- engines/wintermute/UI/UIText.cpp | 12 +++---- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/video/VidPlayer.cpp | 2 +- 21 files changed, 125 insertions(+), 125 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 56e0961743..dd16e2c0f0 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -2056,10 +2056,10 @@ HRESULT CAdGame::DisplayDebugInfo() { char str[100]; if (Game->_dEBUG_DebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); - _systemFont->DrawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->DrawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } return CBGame::DisplayDebugInfo(); } diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 8d8de1a48c..11bfe39747 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -413,11 +413,11 @@ HRESULT CAdItem::display(int X, int Y) { CBFont *Font = _font ? _font : Game->_systemFont; if (Font) { - if (_amountString) Font->DrawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); + if (_amountString) Font->drawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); else { char Str[256]; sprintf(Str, "%d", _amount); - Font->DrawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); + Font->drawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); } } } diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 52c7e57be5..e89e83905f 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -895,7 +895,7 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const } else width = Game->_renderer->_width / 2; } - height = _sentence->_font->GetTextHeight((byte *)_sentence->_text, width); + height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); y = y - height - getHeight() - 5; if (_subtitlesModRelative) { diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 0a526e4afa..41d4c3745d 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -187,7 +187,7 @@ HRESULT CAdSentence::display() { x = MIN(x, Game->_renderer->_width - _width); y = MAX(y, 0); - _font->DrawText((byte *)_text, x, y, _width, _align); + _font->drawText((byte *)_text, x, y, _width, _align); } return S_OK; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 22b0c0f1a0..7c832becf2 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -54,18 +54,18 @@ CBFont::~CBFont() { ////////////////////////////////////////////////////////////////////// -void CBFont::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { } ////////////////////////////////////////////////////////////////////// -int CBFont::GetTextHeight(byte *text, int width) { +int CBFont::getTextHeight(byte *text, int width) { return 0; } ////////////////////////////////////////////////////////////////////// -int CBFont::GetTextWidth(byte *text, int MaxLenght) { +int CBFont::getTextWidth(byte *text, int MaxLenght) { return 0; } @@ -138,7 +138,7 @@ HRESULT CBFont::loadBuffer(byte * Buffer) */ ////////////////////////////////////////////////////////////////////////// -int CBFont::GetLetterHeight() { +int CBFont::getLetterHeight() { return 0; } @@ -152,8 +152,8 @@ HRESULT CBFont::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::CreateFromFile(CBGame *Game, const char *Filename) { - if (IsTrueType(Game, Filename)) { +CBFont *CBFont::createFromFile(CBGame *Game, const char *Filename) { + if (isTrueType(Game, Filename)) { CBFontTT *Font = new CBFontTT(Game); if (Font) { if (FAILED(Font->loadFile(Filename))) { @@ -180,7 +180,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::IsTrueType(CBGame *Game, const char *Filename) { +bool CBFont::isTrueType(CBGame *Game, const char *Filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index 7a115517da..a8d613b92e 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -38,22 +38,22 @@ namespace WinterMute { class CBFont: public CBObject { public: DECLARE_PERSISTENT(CBFont, CBObject) - virtual int GetTextWidth(byte *text, int MaxLenght = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); - virtual int GetLetterHeight(); + virtual int getTextWidth(byte *text, int MaxLenght = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int getLetterHeight(); - virtual void InitLoop() {}; - virtual void AfterLoad() {}; + virtual void initLoop() {}; + virtual void afterLoad() {}; CBFont(CBGame *inGame); virtual ~CBFont(); - static CBFont *CreateFromFile(CBGame *Game, const char *Filename); + static CBFont *createFromFile(CBGame *Game, const char *Filename); private: //HRESULT loadBuffer(byte * Buffer); //HRESULT loadFile(const char* Filename); - static bool IsTrueType(CBGame *Game, const char *Filename); + static bool isTrueType(CBGame *Game, const char *Filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index eb30bfa6f5..b12116446f 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -70,19 +70,19 @@ CBFontBitmap::~CBFontBitmap() { ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::DrawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { - TextHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { + textHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetTextHeight(byte *text, int width) { - return TextHeightDraw(text, 0, 0, width, TAL_LEFT, false); +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { +int CBFontBitmap::getTextWidth(byte *text, int MaxLength) { AnsiString str; if (Game->_textEncoding == TEXT_UTF8) { @@ -98,7 +98,7 @@ int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { int TextWidth = 0; for (size_t i = 0; i < str.size(); i++) { - TextWidth += GetCharWidth(str[i]); + TextWidth += getCharWidth(str[i]); } return TextWidth; @@ -106,7 +106,7 @@ int CBFontBitmap::GetTextWidth(byte *text, int MaxLength) { ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { if (MaxLenght == 0) return 0; if (text == NULL || text[0] == '\0') return _tileHeight; @@ -159,7 +159,7 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig new_line = true; } - if (LineLength + GetCharWidth(str[index]) > width && last_end == end) { + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { end = index - 1; RealLength = LineLength; new_line = true; @@ -170,10 +170,10 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig done = true; if (!new_line) { end = index; - LineLength += GetCharWidth(str[index]); + LineLength += getCharWidth(str[index]); RealLength = LineLength; } - } else LineLength += GetCharWidth(str[index]); + } else LineLength += getCharWidth(str[index]); if ((LineLength > width) || done || new_line) { if (end < 0) done = true; @@ -193,8 +193,8 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig break; } for (i = start; i < end + 1; i++) { - if (draw) DrawChar(str[i], StartX, y); - StartX += GetCharWidth(str[i]); + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); } y += _tileHeight; last_end = end; @@ -215,7 +215,7 @@ int CBFontBitmap::TextHeightDraw(byte *text, int x, int y, int width, TTextAlig ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::DrawChar(byte c, int x, int y) { +void CBFontBitmap::drawChar(byte c, int x, int y) { if (_fontextFix) c--; int row, col; @@ -424,7 +424,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *Buffer) { if (AutoWidth) { // calculate characters width - GetWidths(); + getWidths(); // do we need to modify widths? if (ExpandWidth != 0) { @@ -482,14 +482,14 @@ HRESULT CBFontBitmap::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetCharWidth(byte Index) { +int CBFontBitmap::getCharWidth(byte Index) { if (_fontextFix) Index--; return _widths[Index]; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::GetWidths() { +HRESULT CBFontBitmap::getWidths() { CBSurface *surf = NULL; if (_sprite) { @@ -535,7 +535,7 @@ HRESULT CBFontBitmap::GetWidths() { } ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::GetLetterHeight() { +int CBFontBitmap::getLetterHeight() { return _tileHeight; } diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h index 64fffb7a12..f64ef05a64 100644 --- a/engines/wintermute/Base/BFontBitmap.h +++ b/engines/wintermute/Base/BFontBitmap.h @@ -39,16 +39,16 @@ public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) HRESULT loadBuffer(byte *Buffer); HRESULT loadFile(const char *Filename); - virtual int GetTextWidth(byte *text, int MaxLength = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); - virtual int GetLetterHeight(); + virtual int getTextWidth(byte *text, int MaxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int getLetterHeight(); CBFontBitmap(CBGame *inGame); virtual ~CBFontBitmap(); - HRESULT GetWidths(); + HRESULT getWidths(); CBSprite *_sprite; int _widthsFrame; bool _fontextFix; @@ -60,10 +60,10 @@ public: bool _wholeCell; private: - int GetCharWidth(byte Index); - void DrawChar(byte c, int x, int y); + int getCharWidth(byte Index); + void drawChar(byte c, int x, int y); - int TextHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); }; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 9996f9b3e2..fa08bb44fc 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -84,7 +84,7 @@ HRESULT CBFontStorage::cleanup(bool Warn) { ////////////////////////////////////////////////////////////////////////// HRESULT CBFontStorage::InitLoop() { for (int i = 0; i < _fonts.GetSize(); i++) { - _fonts[i]->InitLoop(); + _fonts[i]->initLoop(); } return S_OK; } @@ -114,7 +114,7 @@ CBFont *CBFontStorage::AddFont(const char *Filename) { return font; } */ - CBFont *font = CBFont::CreateFromFile(Game, Filename); + CBFont *font = CBFont::createFromFile(Game, Filename); if (font) { font->_refCount = 1; _fonts.Add(font); diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 5a44a0fc13..c0f7f4a75b 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -71,7 +71,7 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { ////////////////////////////////////////////////////////////////////////// CBFontTT::~CBFontTT(void) { - ClearCache(); + clearCache(); for (int i = 0; i < _layers.GetSize(); i++) { delete _layers[i]; @@ -96,7 +96,7 @@ CBFontTT::~CBFontTT(void) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::ClearCache() { +void CBFontTT::clearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i]) delete _cachedTexts[i]; _cachedTexts[i] = NULL; @@ -105,7 +105,7 @@ void CBFontTT::ClearCache() { } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::InitLoop() { +void CBFontTT::initLoop() { // we need more aggressive cache management on iOS not to waste too much memory on fonts if (Game->_constrainedMemory) { // purge all cached images not used in the last frame @@ -121,7 +121,7 @@ void CBFontTT::InitLoop() { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { +int CBFontTT::getTextWidth(byte *Text, int MaxLength) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); @@ -132,13 +132,13 @@ int CBFontTT::GetTextWidth(byte *Text, int MaxLength) { //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; - MeasureText(text, -1, -1, textWidth, textHeight); + measureText(text, -1, -1, textWidth, textHeight); return textWidth; } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetTextHeight(byte *Text, int Width) { +int CBFontTT::getTextHeight(byte *Text, int Width) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); @@ -146,14 +146,14 @@ int CBFontTT::GetTextHeight(byte *Text, int Width) { int textWidth, textHeight; - MeasureText(text, Width, -1, textWidth, textHeight); + measureText(text, Width, -1, textWidth, textHeight); return textHeight; } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { +void CBFontTT::drawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { if (Text == NULL || strcmp((char *)Text, "") == 0) return; WideString text = (char *)Text; @@ -197,7 +197,7 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, // not found, create one if (!Surface) { warning("Draw text: %s", Text); - Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset); + Surface = renderTextToTexture(text, Width, Align, MaxHeight, textOffset); if (Surface) { // write surface to cache if (_cachedTexts[MinIndex] != NULL) delete _cachedTexts[MinIndex]; @@ -237,7 +237,7 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align, } ////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { //TextLineList lines; // TODO //WrapText(text, width, maxHeight, lines); @@ -374,7 +374,7 @@ CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTex } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { //SDL_BlitSurface(src, NULL, target, targetRect); warning("CBFontTT::BlitSurface - not ported yet"); #if 0 @@ -398,8 +398,8 @@ void CBFontTT::BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Co } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::GetLetterHeight() { - return (int)GetLineHeight(); +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); } @@ -519,7 +519,7 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { case TOKEN_LAYER: { CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && SUCCEEDED(ParseLayer(Layer, (byte *)params))) _layers.Add(Layer); + if (Layer && SUCCEEDED(parseLayer(Layer, (byte *)params))) _layers.Add(Layer); else { delete Layer; Layer = NULL; @@ -544,12 +544,12 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { if (!_fontFile) CBUtils::SetString(&_fontFile, "arial.ttf"); - return InitFont(); + return initFont(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::ParseLayer(CBTTFontLayer *Layer, byte *Buffer) { +HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -629,12 +629,12 @@ HRESULT CBFontTT::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::AfterLoad() { - InitFont(); +void CBFontTT::afterLoad() { + initFont(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::InitFont() { +HRESULT CBFontTT::initFont() { if (!_fontFile) return E_FAIL; Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); @@ -833,7 +833,7 @@ void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, Tex } #endif ////////////////////////////////////////////////////////////////////////// -void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; // TODO: This function gets called a lot, so warnings like these drown out the usefull information static bool hasWarned = false; @@ -852,7 +852,7 @@ void CBFontTT::MeasureText(const WideString &text, int maxWidth, int maxHeight, //WrapText(text, maxWidth, maxHeight, lines); - textHeight = (int)(lines.size() * GetLineHeight()); + textHeight = (int)(lines.size() * getLineHeight()); } else { textWidth = _font->getStringWidth(text); textHeight = _fontHeight; diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 4d1f52279c..9ae713f6f4 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -118,34 +118,34 @@ public: CBFontTT(CBGame *inGame); virtual ~CBFontTT(void); - virtual int GetTextWidth(byte *text, int maxLenght = -1); - virtual int GetTextHeight(byte *text, int width); - virtual void DrawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLenght = -1); - virtual int GetLetterHeight(); + virtual int getTextWidth(byte *text, int maxLenght = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLenght = -1); + virtual int getLetterHeight(); HRESULT loadBuffer(byte *buffer); HRESULT loadFile(const char *filename); - float GetLineHeight() const { + float getLineHeight() const { return _lineHeight; } - void AfterLoad(); - void InitLoop(); + void afterLoad(); + void initLoop(); private: - HRESULT ParseLayer(CBTTFontLayer *layer, byte *buffer); + HRESULT parseLayer(CBTTFontLayer *layer, byte *buffer); - void WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void MeasureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - CBSurface *RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void BlitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - HRESULT InitFont(); + HRESULT initFont(); Graphics::Font *_deletableFont; const Graphics::Font *_font; @@ -171,7 +171,7 @@ public: char *_fontFile; CBArray _layers; - void ClearCache(); + void clearCache(); }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6db323b333..8a31e8019b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -2777,8 +2777,8 @@ HRESULT CBGame::DisplayQuickMsg() { // display for (i = 0; i < _quickMessages.GetSize(); i++) { - _systemFont->DrawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); - PosY += _systemFont->GetTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); + _systemFont->drawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); + PosY += _systemFont->getTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); } return S_OK; } @@ -3350,7 +3350,7 @@ HRESULT CBGame::InitAfterLoad() { CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); _scEngine->RefreshScriptBreakpoints(); - if (_store) _store->AfterLoad(); + if (_store) _store->afterLoad(); return S_OK; } @@ -3374,12 +3374,12 @@ void CBGame::AfterLoadSound(void *Sound, void *Data) { ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadFont(void *Font, void *Data) { - ((CBFont *)Font)->AfterLoad(); + ((CBFont *)Font)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// void CBGame::AfterLoadScript(void *script, void *data) { - ((CScScript *)script)->AfterLoad(); + ((CScScript *)script)->afterLoad(); } @@ -4408,7 +4408,7 @@ HRESULT CBGame::DisplayDebugInfo() { if (_dEBUG_ShowFPS) { sprintf(str, "FPS: %d", Game->_fps); - _systemFont->DrawText((byte *)str, 0, 0, 100, TAL_LEFT); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); } if (Game->_dEBUG_DebugMode) { @@ -4420,23 +4420,23 @@ HRESULT CBGame::DisplayDebugInfo() { strcat(str, " ("); strcat(str, _renderer->getName()); strcat(str, ")"); - _systemFont->DrawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); _renderer->displayDebugInfo(); int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); - _systemFont->DrawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); sprintf(str, "Timer: %d", _timer); - Game->_systemFont->DrawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + Game->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->DrawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->DrawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); } diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index b910f27f62..bfdbd212c7 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -310,7 +310,7 @@ HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CSXStore::AfterLoad() { +void CSXStore::afterLoad() { if (_eventsEnabled) { SetEventsEnabled(NULL, true); } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 5889678122..bb7f0eeb42 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -132,7 +132,7 @@ public: virtual CScValue *scGetProperty(const char *Name); virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); - void AfterLoad(); + void afterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); bool IsAvailable(); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 77c3784ef4..a386c13229 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1581,7 +1581,7 @@ bool CScScript::DbgGetTracingMode() { ////////////////////////////////////////////////////////////////////////// -void CScScript::AfterLoad() { +void CScScript::afterLoad() { if (_buffer == NULL) { byte *buffer = _engine->GetCompiledScript(_filename, &_bufferSize); if (!buffer) { diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 1ed08375d1..fdf00bae82 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -54,7 +54,7 @@ public: HRESULT FinishThreads(); HRESULT CopyParameters(CScStack *Stack); - void AfterLoad(); + void afterLoad(); #ifdef __WIN32__ static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 759a37b4b3..7898b6f5c9 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -565,8 +565,8 @@ void CUIButton::CorrectSize() { if (_text) { int text_height; - if (_font) text_height = _font->GetTextHeight((byte *)_text, _width); - else text_height = Game->_systemFont->GetTextHeight((byte *)_text, _width); + if (_font) text_height = _font->getTextHeight((byte *)_text, _width); + else text_height = Game->_systemFont->getTextHeight((byte *)_text, _width); if (text_height > _height) _height = text_height; } @@ -634,8 +634,8 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); if (font && _text) { - int text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; - font->DrawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + font->drawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 9a193b5c23..cab0be5ba8 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -573,13 +573,13 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { _selEnd = MIN((size_t)_selEnd, strlen(_text)); //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int CursorWidth = font->GetTextWidth((byte *)_cursorChar); + int CursorWidth = font->getTextWidth((byte *)_cursorChar); int s1, s2; bool CurFirst; // modify scroll offset if (_selStart >= _selEnd) { - while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= (int)strlen(_text)) break; } @@ -590,8 +590,8 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { s2 = _selStart; CurFirst = true; } else { - while (font->GetTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + - sfont->GetTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + + sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) > _width - CursorWidth - 2 * _frameWidth) { _scrollOffset++; @@ -616,7 +616,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { yyy = _posY + _frameWidth + OffsetY; width = _posX + _width + OffsetX - _frameWidth; - height = MAX(font->GetLetterHeight(), sfont->GetLetterHeight()); + height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); if (Game->_textRTL) xxx += AlignOffset; @@ -625,9 +625,9 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { // unselected 1 if (s1 > _scrollOffset) { - if (Count) font->DrawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); - xxx += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->GetTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); } // cursor @@ -638,7 +638,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { _cursorVisible = !_cursorVisible; } if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; @@ -648,9 +648,9 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { int s3 = MAX(s1, _scrollOffset); if (s2 - s3 > 0) { - if (Count) sfont->DrawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->GetTextWidth((byte *)_text + s3, s2 - s3); + if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); } // cursor @@ -661,15 +661,15 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { _cursorVisible = !_cursorVisible; } if (_cursorVisible) - font->DrawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } xxx += CursorWidth; AlignOffset += CursorWidth; } // unselected 2 - if (Count) font->DrawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->GetTextWidth((byte *)_text + s2); + if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->getTextWidth((byte *)_text + s2); AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; if (AlignOffset < 0) AlignOffset = 0; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 5f11ebc964..afff0d204d 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -79,12 +79,12 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { text_offset = 0; break; case VAL_BOTTOM: - text_offset = _height - font->GetTextHeight((byte *)_text, _width); + text_offset = _height - font->getTextHeight((byte *)_text, _width); break; default: - text_offset = (_height - font->GetTextHeight((byte *)_text, _width)) / 2; + text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; } - font->DrawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); + font->drawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); } //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); @@ -392,7 +392,7 @@ HRESULT CUIText::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "HeightToFit") == 0) { Stack->CorrectParams(0); - if (_font && _text) _height = _font->GetTextHeight((byte *)_text, _width); + if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); Stack->PushNULL(); return S_OK; } @@ -480,8 +480,8 @@ HRESULT CUIText::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::SizeToFit() { if (_font && _text) { - _width = _font->GetTextWidth((byte *)_text); - _height = _font->GetTextHeight((byte *)_text, _width); + _width = _font->getTextWidth((byte *)_text); + _height = _font->getTextHeight((byte *)_text, _width); } return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 887d869076..d80f63a464 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -182,7 +182,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { - font->DrawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + font->drawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 7f35e022cf..e511f52284 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -286,7 +286,7 @@ HRESULT CVidPlayer::display() { if (m_ShowSubtitle) { CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); - font->DrawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); + font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); } return res; -- cgit v1.2.3 From 9d08670191a61b7794a0341d68633649e616ab1a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 14:12:55 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the UI-classes. --- engines/wintermute/Ad/AdInventoryBox.cpp | 8 +++---- engines/wintermute/Ad/AdResponseBox.cpp | 16 +++++++------- engines/wintermute/UI/UIButton.cpp | 14 ++++++------ engines/wintermute/UI/UIButton.h | 4 ++-- engines/wintermute/UI/UIEdit.cpp | 38 ++++++++++++++++---------------- engines/wintermute/UI/UIEdit.h | 6 ++--- engines/wintermute/UI/UIEntity.cpp | 10 ++++----- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/UI/UIObject.cpp | 20 ++++++++--------- engines/wintermute/UI/UIObject.h | 14 ++++++------ engines/wintermute/UI/UIText.cpp | 4 ++-- engines/wintermute/UI/UITiledImage.cpp | 2 +- engines/wintermute/UI/UITiledImage.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 36 +++++++++++++++--------------- engines/wintermute/UI/UIWindow.h | 12 +++++----- 15 files changed, 94 insertions(+), 94 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 76d00e8a4d..60b0a77692 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -107,8 +107,8 @@ HRESULT CAdInventoryBox::display() { ItemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); if (_window) { - _window->EnableWidget("prev", _scrollOffset > 0); - _window->EnableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); + _window->enableWidget("prev", _scrollOffset > 0); + _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); } @@ -299,7 +299,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { _closeButton = new CUIButton(Game); if (_closeButton) { _closeButton->setName("close"); - _closeButton->SetListener(this, _closeButton, 0); + _closeButton->setListener(this, _closeButton, 0); _closeButton->_parent = _window; } } @@ -309,7 +309,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { if (_window) { for (int i = 0; i < _window->_widgets.GetSize(); i++) { if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index c14497a4c4..1f226c0d5d 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -118,7 +118,7 @@ HRESULT CAdResponseBox::invalidateButtons() { _respButtons[i]->_font = NULL; _respButtons[i]->_fontHover = NULL; _respButtons[i]->_fontPress = NULL; - _respButtons[i]->SetText(""); + _respButtons[i]->setText(""); } return S_OK; } @@ -147,7 +147,7 @@ HRESULT CAdResponseBox::createButtons() { } // textual else { - btn->SetText(_responses[i]->_text); + btn->setText(_responses[i]->_text); btn->_font = (_font == NULL) ? Game->_systemFont : _font; btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover; btn->_fontPress = btn->_fontHover; @@ -163,14 +163,14 @@ HRESULT CAdResponseBox::createButtons() { if (btn->_width <= 0) btn->_width = Game->_renderer->_width; } btn->setName("response"); - btn->CorrectSize(); + btn->correctSize(); // make the responses touchable if (Game->_touchInterface) btn->_height = MAX(btn->_height, 50); //btn->SetListener(this, btn, _responses[i]->_iD); - btn->SetListener(this, btn, i); + btn->setListener(this, btn, i); btn->_visible = false; _respButtons.Add(btn); @@ -327,7 +327,7 @@ HRESULT CAdResponseBox::loadBuffer(byte *Buffer, bool Complete) { if (_window) { for (int i = 0; i < _window->_widgets.GetSize(); i++) { if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->SetListener(this, _window->_widgets[i], 0); + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } } @@ -455,8 +455,8 @@ HRESULT CAdResponseBox::display() { // show appropriate scroll buttons if (_window) { - _window->ShowWidget("prev", _scrollOffset > 0); - _window->ShowWidget("next", scroll_needed); + _window->showWidget("prev", _scrollOffset > 0); + _window->showWidget("next", scroll_needed); } // go exclusive @@ -639,7 +639,7 @@ HRESULT CAdResponseBox::getObjects(CBArray &Objects, b for (int i = 0; i < _respButtons.GetSize(); i++) { Objects.Add(_respButtons[i]); } - if (_window) _window->GetWindowObjects(Objects, InteractiveOnly); + if (_window) _window->getWindowObjects(Objects, InteractiveOnly); return S_OK; } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 7898b6f5c9..58440d0095 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -352,7 +352,7 @@ HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_TEXT: - SetText((char *)params); + setText((char *)params); Game->_stringTable->Expand(&_text); break; @@ -434,7 +434,7 @@ HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - CorrectSize(); + correctSize(); return S_OK; } @@ -539,7 +539,7 @@ HRESULT CUIButton::saveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -void CUIButton::CorrectSize() { +void CUIButton::correctSize() { RECT rect; CBSprite *img = NULL; @@ -573,7 +573,7 @@ void CUIButton::CorrectSize() { if (_height <= 0) _height = 100; - if (_back) _back->CorrectSize(&_width, &_height); + if (_back) _back->correctSize(&_width, &_height); } @@ -591,7 +591,7 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !Game->_mouseLeftDown) || - (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) Press(); + (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) press(); if (_disable) { @@ -606,7 +606,7 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { if (_backHover) back = _backHover; if (_imageHover) image = _imageHover; if (_text && _fontHover) font = _fontHover; - } else if (_canFocus && IsFocused()) { + } else if (_canFocus && isFocused()) { if (_backFocus) back = _backFocus; if (_imageFocus) image = _imageFocus; if (_text && _fontFocus) font = _fontFocus; @@ -654,7 +654,7 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -void CUIButton::Press() { +void CUIButton::press() { applyEvent("Press"); if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); if (_parentNotify && _parent) _parent->applyEvent(_name); diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index b404a781d1..bc3ba87257 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -43,11 +43,11 @@ public: bool _oneTimePress; uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) - void Press(); + void press(); virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); bool _press; bool _hover; - void CorrectSize(); + void correctSize(); TTextAlign _align; CBSprite *_imageHover; CBSprite *_imagePress; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index cab0be5ba8..cc98830898 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -62,7 +62,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { _scrollOffset = 0; _cursorChar = NULL; - SetCursorChar("|"); + setCursorChar("|"); #ifdef __WIN32__ _cursorBlinkRate = GetCaretBlinkTime(); @@ -71,7 +71,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { #endif _frameWidth = 0; - SetText(""); + setText(""); _lastBlinkTime = 0; _cursorVisible = true; @@ -220,7 +220,7 @@ HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_TEXT: - SetText((char *)params); + setText((char *)params); Game->_stringTable->Expand(&_text); break; @@ -296,7 +296,7 @@ HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - CorrectSize(); + correctSize(); return S_OK; } @@ -490,7 +490,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { // CursorChar ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "CursorChar") == 0) { - SetCursorChar(Value->GetString()); + setCursorChar(Value->GetString()); return S_OK; } @@ -516,9 +516,9 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { else if (strcmp(Name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); - SetText(StringUtil::WideToAnsi(wstr).c_str()); + setText(StringUtil::WideToAnsi(wstr).c_str()); } else { - SetText(Value->GetString()); + setText(Value->GetString()); } return S_OK; } @@ -534,7 +534,7 @@ const char *CUIEdit::scToString() { ////////////////////////////////////////////////////////////////////////// -void CUIEdit::SetCursorChar(const char *Char) { +void CUIEdit::setCursorChar(const char *Char) { if (!Char) return; delete[] _cursorChar; _cursorChar = new char [strlen(Char) + 1]; @@ -564,7 +564,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { if (_fontSelected) sfont = _fontSelected; else sfont = font; - bool focused = IsFocused(); + bool focused = isFocused(); _selStart = MAX(_selStart, 0); _selEnd = MAX(_selEnd, 0); @@ -707,9 +707,9 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_BACKSPACE: if (_selStart == _selEnd) { - if (Game->_textRTL) DeleteChars(_selStart, _selStart + 1); - else DeleteChars(_selStart - 1, _selStart); - } else DeleteChars(_selStart, _selEnd); + if (Game->_textRTL) deleteChars(_selStart, _selStart + 1); + else deleteChars(_selStart - 1, _selStart); + } else deleteChars(_selStart, _selEnd); if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); _selStart = _selEnd; @@ -755,11 +755,11 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_DELETE: if (_selStart == _selEnd) { if (Game->_textRTL) { - DeleteChars(_selStart - 1, _selStart); + deleteChars(_selStart - 1, _selStart); _selEnd--; if (_selEnd < 0) _selEnd = 0; - } else DeleteChars(_selStart, _selStart + 1); - } else DeleteChars(_selStart, _selEnd); + } else deleteChars(_selStart, _selStart + 1); + } else deleteChars(_selStart, _selEnd); if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); _selStart = _selEnd; @@ -770,12 +770,12 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { } return Handled; } else if (event->type == Common::EVENT_KEYDOWN && printable) { - if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd); + if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); WideString wstr; wstr += (char)event->kbd.ascii; - _selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + _selEnd += insertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); if (Game->_textRTL) _selEnd = _selStart; else _selStart = _selEnd; @@ -789,7 +789,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// -int CUIEdit::DeleteChars(int Start, int End) { +int CUIEdit::deleteChars(int Start, int End) { if (Start > End) CBUtils::Swap(&Start, &End); Start = MAX(Start, (int)0); @@ -810,7 +810,7 @@ int CUIEdit::DeleteChars(int Start, int End) { ////////////////////////////////////////////////////////////////////////// -int CUIEdit::InsertChars(int Pos, byte *Chars, int Num) { +int CUIEdit::insertChars(int Pos, byte *Chars, int Num) { if ((int)strlen(_text) + Num > _maxLength) { Num -= (strlen(_text) + Num - _maxLength); } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 6ad5f50758..34f849f9fa 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -39,8 +39,8 @@ class CUIEdit : public CUIObject { public: DECLARE_PERSISTENT(CUIEdit, CUIObject) int _maxLength; - int InsertChars(int Pos, byte *Chars, int Num); - int DeleteChars(int Start, int End); + int insertChars(int Pos, byte *Chars, int Num); + int deleteChars(int Start, int End); bool _cursorVisible; uint32 _lastBlinkTime; virtual HRESULT display(int OffsetX, int OffsetY); @@ -48,7 +48,7 @@ public: int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; - void SetCursorChar(const char *Char); + void setCursorChar(const char *Char); char *_cursorChar; int _selEnd; int _selStart; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 41b197dcd7..deefe965e3 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -142,7 +142,7 @@ HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_ENTITY: - if (FAILED(SetEntity((char *)params))) cmd = PARSERR_GENERIC; + if (FAILED(setEntity((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_SCRIPT: @@ -163,7 +163,7 @@ HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - CorrectSize(); + correctSize(); if (Game->_editorMode) { _width = 50; @@ -208,10 +208,10 @@ HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::SetEntity(const char *Filename) { +HRESULT CUIEntity::setEntity(const char *filename) { if (_entity) Game->UnregisterObject(_entity); _entity = new CAdEntity(Game); - if (!_entity || FAILED(_entity->loadFile(Filename))) { + if (!_entity || FAILED(_entity->loadFile(filename))) { delete _entity; _entity = NULL; return E_FAIL; @@ -272,7 +272,7 @@ HRESULT CUIEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th const char *Filename = Stack->Pop()->GetString(); - if (SUCCEEDED(SetEntity(Filename))) + if (SUCCEEDED(setEntity(Filename))) Stack->PushBool(true); else Stack->PushBool(false); diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 813831af67..bd588f7d37 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -44,7 +44,7 @@ public: virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; - HRESULT SetEntity(const char *Filename); + HRESULT setEntity(const char *Filename); // scripting interface virtual CScValue *scGetProperty(const char *Name); diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 94033389f8..aaeeb6e5dd 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -85,7 +85,7 @@ CUIObject::~CUIObject() { ////////////////////////////////////////////////////////////////////////// -void CUIObject::SetText(const char *Text) { +void CUIObject::setText(const char *Text) { if (_text) delete [] _text; _text = new char [strlen(Text) + 1]; if (_text) { @@ -104,7 +104,7 @@ HRESULT CUIObject::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { +void CUIObject::setListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { _listenerObject = Object; _listenerParamObject = ListenerObject; _listenerParamDWORD = ListenerParam; @@ -112,7 +112,7 @@ void CUIObject::SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObje ////////////////////////////////////////////////////////////////////////// -void CUIObject::CorrectSize() { +void CUIObject::correctSize() { RECT rect; if (_width <= 0) { @@ -129,7 +129,7 @@ void CUIObject::CorrectSize() { } } - if (_back) _back->CorrectSize(&_width, &_height); + if (_back) _back->correctSize(&_width, &_height); } @@ -209,7 +209,7 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Focus") == 0) { Stack->CorrectParams(0); - Focus(); + focus(); Stack->PushNULL(); return S_OK; } @@ -471,7 +471,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Text") == 0) { - SetText(Value->GetString()); + setText(Value->GetString()); return S_OK; } @@ -486,7 +486,7 @@ const char *CUIObject::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CUIObject::IsFocused() { +bool CUIObject::isFocused() { if (!Game->_focusedWindow) return false; if (Game->_focusedWindow == this) return true; @@ -503,14 +503,14 @@ bool CUIObject::IsFocused() { HRESULT CUIObject::handleMouse(TMouseEvent Event, TMouseButton Button) { // handle focus change if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { - Focus(); + focus(); } return CBObject::handleMouse(Event, Button); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::Focus() { +HRESULT CUIObject::focus() { CUIObject *obj = this; bool disabled = false; while (obj) { @@ -537,7 +537,7 @@ HRESULT CUIObject::Focus() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::GetTotalOffset(int *OffsetX, int *OffsetY) { +HRESULT CUIObject::getTotalOffset(int *OffsetX, int *OffsetY) { int OffX = 0, OffY = 0; CUIObject *obj = _parent; diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 272b094131..7e16041bbe 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -40,19 +40,19 @@ class CBFont; class CUIObject : public CBObject { public: - HRESULT GetTotalOffset(int *OffsetX, int *OffsetY); + HRESULT getTotalOffset(int *offsetX, int *offsetY); bool _canFocus; - HRESULT Focus(); + HRESULT focus(); virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); - bool IsFocused(); + bool isFocused(); bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) CUIObject *_parent; - virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); - virtual void CorrectSize(); + virtual HRESULT display(int offsetX = 0, int offsetY = 0); + virtual void correctSize(); bool _sharedFonts; bool _sharedImages; - void SetText(const char *Text); + void setText(const char *text); char *_text; CBFont *_font; bool _visible; @@ -64,7 +64,7 @@ public: int _height; TUIObjectType _type; CBSprite *_image; - void SetListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); + void setListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); CBScriptHolder *_listenerParamObject; uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index afff0d204d..4eaa114a83 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -215,7 +215,7 @@ HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_TEXT: - SetText((char *)params); + setText((char *)params); Game->_stringTable->Expand(&_text); break; @@ -287,7 +287,7 @@ HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - CorrectSize(); + correctSize(); return S_OK; } diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index a259050872..e7734acdc5 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -337,7 +337,7 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -void CUITiledImage::CorrectSize(int *Width, int *Height) { +void CUITiledImage::correctSize(int *Width, int *Height) { int tile_width = _middleMiddle.right - _middleMiddle.left; int tile_height = _middleMiddle.bottom - _middleMiddle.top; diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 62ae6a0cce..d571f1354f 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -37,7 +37,7 @@ class CBSubFrame; class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) - void CorrectSize(int *Width, int *Height); + void correctSize(int *Width, int *Height); HRESULT loadFile(const char *Filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d80f63a464..38fefc4cc7 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -128,7 +128,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (!_shieldButton) { _shieldButton = new CUIButton(Game); _shieldButton->setName("close"); - _shieldButton->SetListener(this, _shieldButton, 0); + _shieldButton->setListener(this, _shieldButton, 0); _shieldButton->_parent = this; } if (_shieldButton) { @@ -153,7 +153,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { } if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { - MoveFocus(); + moveFocus(); } bool PopViewport = false; @@ -171,7 +171,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { CBSprite *image = _image; CBFont *font = _font; - if (!IsFocused()) { + if (!isFocused()) { if (_backInactive) back = _backInactive; if (_imageInactive) image = _imageInactive; if (_fontInactive) font = _fontInactive; @@ -381,7 +381,7 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_TITLE: - SetText((char *)params); + setText((char *)params); Game->_stringTable->Expand(&_text); break; @@ -552,7 +552,7 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - CorrectSize(); + correctSize(); if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; @@ -670,7 +670,7 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::EnableWidget(const char *Name, bool Enable) { +HRESULT CUIWindow::enableWidget(const char *Name, bool Enable) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; } @@ -679,7 +679,7 @@ HRESULT CUIWindow::EnableWidget(const char *Name, bool Enable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::ShowWidget(const char *Name, bool Visible) { +HRESULT CUIWindow::showWidget(const char *Name, bool Visible) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; } @@ -782,7 +782,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GoExclusive") == 0) { Stack->CorrectParams(0); - GoExclusive(); + goExclusive(); Script->WaitFor(this); Stack->PushNULL(); return S_OK; @@ -793,7 +793,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "GoSystemExclusive") == 0) { Stack->CorrectParams(0); - GoSystemExclusive(); + goSystemExclusive(); Script->WaitFor(this); Stack->PushNULL(); return S_OK; @@ -1068,7 +1068,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "Exclusive") == 0) { if (Value->GetBool()) - GoExclusive(); + goExclusive(); else { close(); _visible = true; @@ -1081,7 +1081,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SystemExclusive") == 0) { if (Value->GetBool()) - GoSystemExclusive(); + goSystemExclusive(); else { close(); _visible = true; @@ -1103,7 +1103,7 @@ const char *CUIWindow::scToString() { bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown())); + return SUCCEEDED(moveFocus(!CBKeyboardState::IsShiftDown())); } else { if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); else return false; @@ -1129,7 +1129,7 @@ HRESULT CUIWindow::handleMouse(TMouseEvent Event, TMouseButton Button) { if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { RECT DragRect = _dragRect; int OffsetX, OffsetY; - GetTotalOffset(&OffsetX, &OffsetY); + getTotalOffset(&OffsetX, &OffsetY); CBPlatform::OffsetRect(&DragRect, _posX + OffsetX, _posY + OffsetY); if (CBPlatform::PtInRect(&DragRect, Game->_mousePos)) { @@ -1181,7 +1181,7 @@ HRESULT CUIWindow::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::MoveFocus(bool Forward) { +HRESULT CUIWindow::moveFocus(bool Forward) { int i; bool found = false; for (i = 0; i < _widgets.GetSize(); i++) { @@ -1222,7 +1222,7 @@ HRESULT CUIWindow::MoveFocus(bool Forward) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GoExclusive() { +HRESULT CUIWindow::goExclusive() { if (_mode == WINDOW_EXCLUSIVE) return S_OK; if (_mode == WINDOW_NORMAL) { @@ -1237,7 +1237,7 @@ HRESULT CUIWindow::GoExclusive() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GoSystemExclusive() { +HRESULT CUIWindow::goSystemExclusive() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; makeFreezable(false); @@ -1294,14 +1294,14 @@ void CUIWindow::makeFreezable(bool Freezable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::GetWindowObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CUIWindow::getWindowObjects(CBArray &Objects, bool InteractiveOnly) { for (int i = 0; i < _widgets.GetSize(); i++) { CUIObject *Control = _widgets[i]; if (Control->_disable && InteractiveOnly) continue; switch (Control->_type) { case UI_WINDOW: - ((CUIWindow *)Control)->GetWindowObjects(Objects, InteractiveOnly); + ((CUIWindow *)Control)->getWindowObjects(Objects, InteractiveOnly); break; case UI_BUTTON: diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index bf40df1cb7..e86409e43c 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -39,7 +39,7 @@ class CUIButton; class CBViewport; class CUIWindow : public CUIObject { public: - HRESULT GetWindowObjects(CBArray &Objects, bool InteractiveOnly); + HRESULT getWindowObjects(CBArray &Objects, bool InteractiveOnly); bool _pauseMusic; void cleanup(); @@ -54,17 +54,17 @@ public: CUIWindow *_shieldWindow; CUIButton *_shieldButton; HRESULT close(); - HRESULT GoSystemExclusive(); - HRESULT GoExclusive(); + HRESULT goSystemExclusive(); + HRESULT goExclusive(); TWindowMode _mode; - HRESULT MoveFocus(bool Forward = true); + HRESULT moveFocus(bool Forward = true); virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); POINT _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - HRESULT ShowWidget(const char *Name, bool Visible = true); - HRESULT EnableWidget(const char *Name, bool Enable = true); + HRESULT showWidget(const char *Name, bool Visible = true); + HRESULT enableWidget(const char *Name, bool Enable = true); RECT _titleRect; RECT _dragRect; virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); -- cgit v1.2.3 From 3f9ff1791a5034bf74d460e38282c9bcfe54b6db Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 14:28:53 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in the Sys-classes. --- engines/wintermute/Ad/AdGame.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 22 +++---- engines/wintermute/Base/BPersistMgr.cpp | 4 +- engines/wintermute/Base/BScriptable.cpp | 2 +- engines/wintermute/Base/PartParticle.cpp | 10 +-- engines/wintermute/Base/scriptables/ScValue.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 2 +- engines/wintermute/Sys/SysClass.cpp | 58 ++++++++--------- engines/wintermute/Sys/SysClass.h | 36 +++++------ engines/wintermute/Sys/SysClassRegistry.cpp | 82 ++++++++++++------------- engines/wintermute/Sys/SysClassRegistry.h | 30 ++++----- engines/wintermute/Sys/SysInstance.cpp | 6 +- engines/wintermute/Sys/SysInstance.h | 14 ++--- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/persistent.cpp | 2 +- engines/wintermute/persistent.h | 16 ++--- 16 files changed, 146 insertions(+), 146 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index dd16e2c0f0..7758737359 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1316,14 +1316,14 @@ HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadGame(const char *Filename) { HRESULT ret = CBGame::LoadGame(Filename); - if (SUCCEEDED(ret)) CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CAdRegion", NULL); + if (SUCCEEDED(ret)) CSysClassRegistry::getInstance()->enumInstances(AfterLoadRegion, "CAdRegion", NULL); return ret; } ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::InitAfterLoad() { CBGame::InitAfterLoad(); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScene, "CAdScene", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadScene, "CAdScene", NULL); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 8a31e8019b..1321d31c67 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -2845,7 +2845,7 @@ HRESULT CBGame::UnregisterObject(CBObject *Object) { for (i = 0; i < _regObjects.GetSize(); i++) { if (_regObjects[i] == Object) { _regObjects.RemoveAt(i); - if (!_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(InvalidateValues, "CScValue", (void *)Object); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(InvalidateValues, "CScValue", (void *)Object); delete Object; return S_OK; } @@ -3254,8 +3254,8 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { } } - if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveTable(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->SaveInstances(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish; + if (FAILED(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; if (FAILED(ret = pm->saveFile(Filename))) goto save_finish; _registry->WriteInt("System", "MostRecentSaveSlot", slot); @@ -3312,8 +3312,8 @@ HRESULT CBGame::LoadGame(const char *Filename) { if (FAILED(ret = pm->initLoad(Filename))) goto load_finish; //if(FAILED(ret = cleanup())) goto load_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadTable(Game, pm))) goto load_finish; - if (FAILED(ret = CSysClassRegistry::GetInstance()->LoadInstances(Game, pm))) goto load_finish; + if (FAILED(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish; + if (FAILED(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish; // data initialization after load InitAfterLoad(); @@ -3343,11 +3343,11 @@ load_finish: ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::InitAfterLoad() { - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadSound, "CBSound", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::GetInstance()->EnumInstances(AfterLoadScript, "CScScript", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(AfterLoadScript, "CScScript", NULL); _scEngine->RefreshScriptBreakpoints(); if (_store) _store->afterLoad(); @@ -4177,7 +4177,7 @@ void CBGame::DEBUG_DumpClassRegistry() { Common::DumpFile *f = new Common::DumpFile; f->open("zz_class_reg_dump.log"); - CSysClassRegistry::GetInstance()->DumpClasses(f); + CSysClassRegistry::getInstance()->dumpClasses(f); f->close(); delete f; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 6db1fb5cd5..e5479ea8f6 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -720,7 +720,7 @@ HRESULT CBPersistMgr::transfer(const char *name, void *val) { int ClassID = -1, InstanceID = -1; if (_saving) { - CSysClassRegistry::GetInstance()->GetPointerID(*(void **)val, &ClassID, &InstanceID); + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &ClassID, &InstanceID); if (*(void **)val != NULL && (ClassID == -1 || InstanceID == -1)) { Game->LOG(0, "Warning: invalid instance '%s'", name); } @@ -731,7 +731,7 @@ HRESULT CBPersistMgr::transfer(const char *name, void *val) { ClassID = _loadStream->readUint32LE(); InstanceID = _loadStream->readUint32LE(); - *(void **)val = CSysClassRegistry::GetInstance()->IDToPointer(ClassID, InstanceID); + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(ClassID, InstanceID); } return S_OK; diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index d75f6c1994..aa2bb7059c 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -177,7 +177,7 @@ CScScript *CBScriptable::invokeMethodThread(const char *methodName) { // IWmeDebugObject ////////////////////////////////////////////////////////////////////////// const char *CBScriptable::DbgGetNativeClass() { - return GetClassName(); + return getClassName(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 3443bcbb71..85966eb510 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -81,15 +81,15 @@ HRESULT CPartParticle::setSprite(const char *Filename) { delete _sprite; _sprite = NULL; - CSysClassRegistry::GetInstance()->_disabled = true; + CSysClassRegistry::getInstance()->_disabled = true; _sprite = new CBSprite(Game, Game); if (_sprite && SUCCEEDED(_sprite->loadFile(Filename))) { - CSysClassRegistry::GetInstance()->_disabled = false; + CSysClassRegistry::getInstance()->_disabled = false; return S_OK; } else { delete _sprite; _sprite = NULL; - CSysClassRegistry::GetInstance()->_disabled = false; + CSysClassRegistry::getInstance()->_disabled = false; return E_FAIL; } @@ -242,9 +242,9 @@ HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { } else { char *Filename; persistMgr->transfer(TMEMBER(Filename)); - CSysClassRegistry::GetInstance()->_disabled = true; + CSysClassRegistry::getInstance()->_disabled = true; setSprite(Filename); - CSysClassRegistry::GetInstance()->_disabled = false; + CSysClassRegistry::getInstance()->_disabled = false; delete[] Filename; Filename = NULL; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 707fda0984..eab345f393 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -822,7 +822,7 @@ int CScValue::Compare(CScValue *Val1, CScValue *Val2) { // both natives? if (Val1->IsNative() && Val2->IsNative()) { // same class? - if (strcmp(Val1->GetNative()->GetClassName(), Val2->GetNative()->GetClassName()) == 0) { + if (strcmp(Val1->GetNative()->getClassName(), Val2->GetNative()->getClassName()) == 0) { return Val1->GetNative()->scCompare(Val2->GetNative()); } else return strcmp(Val1->GetString(), Val2->GetString()); } diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 9b4c8e7e04..6f330e35e8 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -93,7 +93,7 @@ void CBPlatform::HandleEvent(Common::Event *event) { GetCursorPos(&p); Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - if (Game->_activeObject != NULL && strcmp(Game->_activeObject->GetClassName(), "CUIButton") == 0) { + if (Game->_activeObject != NULL && strcmp(Game->_activeObject->getClassName(), "CUIButton") == 0) { CUIButton *btn = static_cast(Game->_activeObject); if (btn->_visible && !btn->_disable) btn->_press = true; } diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index f7be3d2449..91639bc0ba 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -46,18 +46,18 @@ CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD loa _persistent = persistent_class; _numInst = 0; - CSysClassRegistry::GetInstance()->RegisterClass(this); + CSysClassRegistry::getInstance()->registerClass(this); } ////////////////////////////////////////////////////////////////////////// CSysClass::~CSysClass() { - CSysClassRegistry::GetInstance()->UnregisterClass(this); - RemoveAllInstances(); + CSysClassRegistry::getInstance()->unregisterClass(this); + removeAllInstances(); } ////////////////////////////////////////////////////////////////////////// -bool CSysClass::RemoveAllInstances() { +bool CSysClass::removeAllInstances() { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { delete(it->_value); @@ -69,21 +69,21 @@ bool CSysClass::RemoveAllInstances() { } ////////////////////////////////////////////////////////////////////////// -CSysInstance *CSysClass::AddInstance(void *instance, int id, int savedId) { +CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { CSysInstance *inst = new CSysInstance(instance, id, this); - inst->SetSavedID(savedId); + inst->setSavedID(savedId); _instances[inst] = (inst); _instanceMap[instance] = inst; - CSysClassRegistry::GetInstance()->AddInstanceToTable(inst, instance); + CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); return inst; } ////////////////////////////////////////////////////////////////////////// -bool CSysClass::RemoveInstance(void *instance) { +bool CSysClass::removeInstance(void *instance) { InstanceMap::iterator mapIt = _instanceMap.find(instance); if (mapIt == _instanceMap.end()) return false; @@ -99,48 +99,48 @@ bool CSysClass::RemoveInstance(void *instance) { } ////////////////////////////////////////////////////////////////////////// -int CSysClass::GetInstanceID(void *pointer) { +int CSysClass::getInstanceID(void *pointer) { InstanceMap::iterator mapIt = _instanceMap.find(pointer); if (mapIt == _instanceMap.end()) return -1; - else return (mapIt->_value)->GetID(); + else return (mapIt->_value)->getID(); } ////////////////////////////////////////////////////////////////////////// -void *CSysClass::IDToPointer(int savedID) { +void *CSysClass::idToPointer(int savedID) { //slow Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((it->_value)->GetSavedID() == savedID) return (it->_value)->GetInstance(); + if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); } return NULL; } ////////////////////////////////////////////////////////////////////////// -int CSysClass::GetNumInstances() { +int CSysClass::getNumInstances() { return _instances.size(); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::Dump(Common::WriteStream *stream) { +void CSysClass::dump(Common::WriteStream *stream) { Common::String str; - str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances()); + str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); stream->write(str.c_str(), str.size()); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveTable(CBGame *Game, CBPersistMgr *persistMgr) { +void CSysClass::saveTable(CBGame *Game, CBPersistMgr *persistMgr) { persistMgr->putString(_name.c_str()); persistMgr->putDWORD(_iD); persistMgr->putDWORD(_instances.size()); Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - persistMgr->putDWORD((it->_value)->GetID()); + persistMgr->putDWORD((it->_value)->getID()); } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { +void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { _savedID = persistMgr->getDWORD(); int numInstances = persistMgr->getDWORD(); @@ -155,8 +155,8 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { Instances::iterator it = _instances.begin(); if (it != _instances.end()) { - (it->_value)->SetSavedID(instID); - CSysClassRegistry::GetInstance()->AddInstanceToTable((it->_value), (it->_value)->GetInstance()); + (it->_value)->setSavedID(instID); + CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); } // normal instances, create empty objects @@ -166,45 +166,45 @@ void CSysClass::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { warning("HALT"); } - AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), instID); + addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); } } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr) { +void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { // write instace header persistMgr->putString(""); persistMgr->putDWORD(_iD); - persistMgr->putDWORD((it->_value)->GetID()); + persistMgr->putDWORD((it->_value)->getID()); persistMgr->putString(""); - _load((it->_value)->GetInstance(), persistMgr); + _load((it->_value)->getInstance(), persistMgr); persistMgr->putString(""); } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::LoadInstance(void *instance, CBPersistMgr *persistMgr) { +void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { _load(instance, persistMgr); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::ResetSavedIDs() { +void CSysClass::resetSavedIDs() { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - (it->_value)->SetSavedID(-1); + (it->_value)->setSavedID(-1); } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { +void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - lpCallback((it->_value)->GetInstance(), lpData); + lpCallback((it->_value)->getInstance(), lpData); } } diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h index 2fdf3a31da..f807ea677c 100644 --- a/engines/wintermute/Sys/SysClass.h +++ b/engines/wintermute/Sys/SysClass.h @@ -68,44 +68,44 @@ public: CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); ~CSysClass(); - int GetNumInstances(); - bool RemoveInstance(void *instance); - CSysInstance *AddInstance(void *instance, int id, int savedId = -1); - bool RemoveAllInstances(); + int getNumInstances(); + bool removeInstance(void *instance); + CSysInstance *addInstance(void *instance, int id, int savedId = -1); + bool removeAllInstances(); - int GetInstanceID(void *pointer); - void *IDToPointer(int savedID); + int getInstanceID(void *pointer); + void *idToPointer(int savedID); - void SetID(int id) { + void setID(int id) { _iD = id; } - int GetID() const { + int getID() const { return _iD; } - int GetSavedID() const { + int getSavedID() const { return _savedID; } - bool IsPersistent() const { + bool isPersistent() const { return _persistent; } - AnsiString GetName() const { + AnsiString getName() const { return _name; } - void SaveTable(CBGame *Game, CBPersistMgr *PersistMgr); - void LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); + void saveTable(CBGame *Game, CBPersistMgr *PersistMgr); + void loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - void SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr); - void LoadInstance(void *instance, CBPersistMgr *PersistMgr); + void saveInstances(CBGame *Game, CBPersistMgr *PersistMgr); + void loadInstance(void *instance, CBPersistMgr *PersistMgr); - void InstanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); - void ResetSavedIDs(); + void resetSavedIDs(); - void Dump(Common::WriteStream *stream); + void dump(Common::WriteStream *stream); private: int _numInst; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 8125678ee4..88b45c3c3a 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -46,7 +46,7 @@ CSysClassRegistry::~CSysClassRegistry() { } ////////////////////////////////////////////////////////////////////////// -CSysClassRegistry *CSysClassRegistry::GetInstance() { +CSysClassRegistry *CSysClassRegistry::getInstance() { return g_wintermute->getClassRegistry(); } @@ -58,35 +58,35 @@ void CSysClassRegistry::unregisterClasses() { } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::RegisterClass(CSysClass *classObj) { - classObj->SetID(_count++); +bool CSysClassRegistry::registerClass(CSysClass *classObj) { + classObj->setID(_count++); //_classes.insert(classObj); _classes[classObj] = classObj; - _nameMap[classObj->GetName()] = classObj; - _idMap[classObj->GetID()] = classObj; + _nameMap[classObj->getName()] = classObj; + _idMap[classObj->getID()] = classObj; return true; } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { +bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { Classes::iterator it = _classes.find(classObj); if (it == _classes.end()) return false; - if (classObj->GetNumInstances() != 0) { + if (classObj->getNumInstances() != 0) { char str[MAX_PATH]; - sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->GetName().c_str(), classObj->GetNumInstances()); + sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); CBPlatform::OutputDebugString(str); } _classes.erase(it); - NameMap::iterator mapIt = _nameMap.find(classObj->GetName()); + NameMap::iterator mapIt = _nameMap.find(classObj->getName()); if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); - IdMap::iterator idIt = _idMap.find(classObj->GetID()); + IdMap::iterator idIt = _idMap.find(classObj->getID()); if (idIt != _idMap.end()) _idMap.erase(idIt); @@ -95,34 +95,34 @@ bool CSysClassRegistry::UnregisterClass(CSysClass *classObj) { ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::RegisterInstance(const char *className, void *instance) { +bool CSysClassRegistry::registerInstance(const char *className, void *instance) { if (_disabled) return true; NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return false; - CSysInstance *inst = (*mapIt)._value->AddInstance(instance, _count++); + CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); return (inst != NULL); } ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::AddInstanceToTable(CSysInstance *instance, void *pointer) { +void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { _instanceMap[pointer] = instance; - if (instance->GetSavedID() >= 0) - _savedInstanceMap[instance->GetSavedID()] = instance; + if (instance->getSavedID() >= 0) + _savedInstanceMap[instance->getSavedID()] = instance; } ////////////////////////////////////////////////////////////////////////// -int CSysClassRegistry::GetNextID() { +int CSysClassRegistry::getNextID() { return _count++; } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance) { +bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return false; - (*mapIt)._value->RemoveInstance(instance); + (*mapIt)._value->removeInstance(instance); InstanceMap::iterator instIt = _instanceMap.find(instance); if (instIt != _instanceMap.end()) { @@ -133,7 +133,7 @@ bool CSysClassRegistry::UnregisterInstance(const char *className, void *instance ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceID) { +bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { if (pointer == NULL) return true; InstanceMap::iterator it = _instanceMap.find(pointer); @@ -141,17 +141,17 @@ bool CSysClassRegistry::GetPointerID(void *pointer, int *classID, int *instanceI CSysInstance *inst = (*it)._value; - *instanceID = inst->GetID(); - *classID = inst->GetClass()->GetID(); + *instanceID = inst->getID(); + *classID = inst->getClass()->getID(); return true; } ////////////////////////////////////////////////////////////////////////// -void *CSysClassRegistry::IDToPointer(int classID, int instanceID) { +void *CSysClassRegistry::idToPointer(int classID, int instanceID) { SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); if (it == _savedInstanceMap.end()) return NULL; - else return (*it)._value->GetInstance(); + else return (*it)._value->getInstance(); } bool checkHeader(const char *tag, CBPersistMgr *pm) { @@ -166,7 +166,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +HRESULT CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { persistMgr->putString(""); persistMgr->putDWORD(_classes.size()); @@ -182,7 +182,7 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, boo Game->_renderer->flip(); } - (it->_value)->SaveTable(Game, persistMgr); + (it->_value)->saveTable(Game, persistMgr); } persistMgr->putString(""); return S_OK; @@ -190,18 +190,18 @@ HRESULT CSysClassRegistry::SaveTable(CBGame *Game, CBPersistMgr *persistMgr, boo ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { +HRESULT CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { checkHeader("", persistMgr); // reset SavedID of current instances Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) { - (it->_value)->ResetSavedIDs(); + (it->_value)->resetSavedIDs(); } for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->IsPersistent()) continue; - (it->_value)->RemoveAllInstances(); + if ((it->_value)->isPersistent()) continue; + (it->_value)->removeAllInstances(); } _instanceMap.clear(); @@ -215,7 +215,7 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { char *className = persistMgr->getString(); NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->LoadTable(Game, persistMgr); + if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(Game, persistMgr); } checkHeader("", persistMgr); @@ -225,14 +225,14 @@ HRESULT CSysClassRegistry::LoadTable(CBGame *Game, CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { Classes::iterator it; // count total instances int numInstances = 0; for (it = _classes.begin(); it != _classes.end(); ++it) { - numInstances += (it->_value)->GetNumInstances(); + numInstances += (it->_value)->getNumInstances(); } persistMgr->putDWORD(numInstances); @@ -250,14 +250,14 @@ HRESULT CSysClassRegistry::SaveInstances(CBGame *Game, CBPersistMgr *persistMgr, } Game->MiniUpdate(); - (it->_value)->SaveInstances(Game, persistMgr); + (it->_value)->saveInstances(Game, persistMgr); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *persistMgr) { +HRESULT CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) { // get total instances int numInstances = persistMgr->getDWORD(); @@ -272,14 +272,14 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *persistMgr) int classID = persistMgr->getDWORD(); int instanceID = persistMgr->getDWORD(); - void *instance = IDToPointer(classID, instanceID); + void *instance = idToPointer(classID, instanceID); checkHeader("", persistMgr); Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->GetSavedID() == classID) { - (it->_value)->LoadInstance(instance, persistMgr); + if ((it->_value)->getSavedID() == classID) { + (it->_value)->loadInstance(instance, persistMgr); break; } } @@ -293,20 +293,20 @@ HRESULT CSysClassRegistry::LoadInstances(CBGame *Game, CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { +HRESULT CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return E_FAIL; - (*mapIt)._value->InstanceCallback(lpCallback, lpData); + (*mapIt)._value->instanceCallback(lpCallback, lpData); return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::DumpClasses(Common::WriteStream *stream) { +void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) - (it->_value)->Dump(stream); + (it->_value)->dump(stream); } } // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 6bc2c11fcf..92dfa5214b 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -61,25 +61,25 @@ class CSysClassRegistry { void unregisterClasses(); public: void registerClasses(); // persistent.cpp - static CSysClassRegistry *GetInstance(); + static CSysClassRegistry *getInstance(); CSysClassRegistry(); virtual ~CSysClassRegistry(); - HRESULT EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - HRESULT LoadTable(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT SaveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - HRESULT LoadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT SaveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - void *IDToPointer(int classID, int instanceID); - bool GetPointerID(void *pointer, int *classID, int *instanceID); - bool RegisterClass(CSysClass *classObj); - bool UnregisterClass(CSysClass *classObj); - bool RegisterInstance(const char *className, void *instance); - bool UnregisterInstance(const char *className, void *instance); - void DumpClasses(Common::WriteStream *stream); - int GetNextID(); - void AddInstanceToTable(CSysInstance *instance, void *pointer); + HRESULT enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + HRESULT loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + HRESULT loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + HRESULT saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + void *idToPointer(int classID, int instanceID); + bool getPointerID(void *pointer, int *classID, int *instanceID); + bool registerClass(CSysClass *classObj); + bool unregisterClass(CSysClass *classObj); + bool registerInstance(const char *className, void *instance); + bool unregisterInstance(const char *className, void *instance); + void dumpClasses(Common::WriteStream *stream); + int getNextID(); + void addInstanceToTable(CSysInstance *instance, void *pointer); bool _disabled; int _count; diff --git a/engines/wintermute/Sys/SysInstance.cpp b/engines/wintermute/Sys/SysInstance.cpp index 9e6a459bfc..b7f6079912 100644 --- a/engines/wintermute/Sys/SysInstance.cpp +++ b/engines/wintermute/Sys/SysInstance.cpp @@ -33,9 +33,9 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CSysInstance::CSysInstance(void *Instance, int ID, CSysClass *sysClass) { - _instance = Instance; - _iD = ID; +CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { + _instance = instance; + _id = id; _savedID = -1; _class = sysClass; diff --git a/engines/wintermute/Sys/SysInstance.h b/engines/wintermute/Sys/SysInstance.h index b8e2531c4b..6becd491af 100644 --- a/engines/wintermute/Sys/SysInstance.h +++ b/engines/wintermute/Sys/SysInstance.h @@ -38,26 +38,26 @@ public: CSysInstance(void *Instance, int ID, CSysClass *sysClass); virtual ~CSysInstance(); - int GetID() const { - return _iD; + int getID() const { + return _id; } - int GetSavedID() const { + int getSavedID() const { return _savedID; } - void *GetInstance() const { + void *getInstance() const { return _instance; } - CSysClass *GetClass() const { + CSysClass *getClass() const { return _class; } - void SetSavedID(int id) { + void setSavedID(int id) { _savedID = id; } private: bool _used; - int _iD; + int _id; int _savedID; void *_instance; CSysClass *_class; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index aaeeb6e5dd..46bfe399f2 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -71,7 +71,7 @@ CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIObject::~CUIObject() { - if (!Game->_loadInProgress) CSysClassRegistry::GetInstance()->EnumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); + if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); if (_back) delete _back; if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 2e80f20049..8d451aad7b 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -90,7 +90,7 @@ // CSysClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ - new WinterMute::CSysClass(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class); + new WinterMute::CSysClass(class_name::_className, class_name::persistBuild, class_name::persistLoad, persistent_class); namespace WinterMute { diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 30f9cd8780..5d81ff51e9 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -48,9 +48,9 @@ namespace WinterMute { #define DECLARE_PERSISTENT(class_name, parent_class)\ static const char _className[];\ - static void* WINAPI PersistBuild(void);\ - virtual const char* GetClassName();\ - static HRESULT WINAPI PersistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + static void* WINAPI persistBuild(void);\ + virtual const char* getClassName();\ + static HRESULT WINAPI persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ virtual HRESULT persist(CBPersistMgr* PersistMgr);\ void* operator new (size_t size);\ @@ -59,15 +59,15 @@ namespace WinterMute { #define IMPLEMENT_PERSISTENT(class_name, persistent_class)\ const char class_name::_className[] = #class_name;\ - void* class_name::PersistBuild(){\ + void* class_name::persistBuild(){\ return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ }\ \ - HRESULT class_name::PersistLoad(void* Instance, CBPersistMgr* PersistMgr){\ + HRESULT class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ return ((class_name*)Instance)->persist(PersistMgr);\ }\ \ - const char* class_name::GetClassName(){\ + const char* class_name::getClassName(){\ return #class_name;\ }\ \ @@ -75,12 +75,12 @@ namespace WinterMute { \ void* class_name::operator new (size_t size){\ void* ret = ::operator new(size);\ - CSysClassRegistry::GetInstance()->RegisterInstance(#class_name, ret);\ + CSysClassRegistry::getInstance()->registerInstance(#class_name, ret);\ return ret;\ }\ \ void class_name::operator delete (void* p){\ - CSysClassRegistry::GetInstance()->UnregisterInstance(#class_name, p);\ + CSysClassRegistry::getInstance()->unregisterInstance(#class_name, p);\ ::operator delete(p);\ }\ -- cgit v1.2.3 From 79cb18ff38b3c79db10ee09fc21cc678fc75b74a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 14:47:15 +0200 Subject: WINTERMUTE: Silence another few warnings. --- engines/wintermute/Base/BSubFrame.cpp | 8 ++++---- engines/wintermute/Base/PartParticle.cpp | 8 ++++---- engines/wintermute/dcgf.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index f86d654980..2e1ddf2a12 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -240,10 +240,10 @@ bool CBSubFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float float RatioY = ScaleY / 100.0f; CBPlatform::SetRect(Rect, - X - _hotspotX * RatioX, - Y - _hotspotY * RatioY, - X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX, - Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY); + (int)(X - _hotspotX * RatioX), + (int)(Y - _hotspotY * RatioY), + (int)(X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX), + (int)(Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY)); return true; } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 85966eb510..b348521808 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -125,16 +125,16 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 // particle hit the border if (!_isDead && !CBPlatform::IsRectEmpty(&_border)) { POINT p; - p.x = _pos.x; - p.y = _pos.y; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; if (!CBPlatform::PtInRect(&_border, p)) fadeOut(CurrentTime, Emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return S_OK; // update alpha if (_lifeTime > 0) { - int Age = CurrentTime - _creationTime; - int AlphaDelta = _alpha2 - _alpha1; + int Age = (int)(CurrentTime - _creationTime); + int AlphaDelta = (int)(_alpha2 - _alpha1); _currentAlpha = _alpha1 + ((float)AlphaDelta / (float)_lifeTime * (float)Age); } diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 831a881a69..305ff0b5b7 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -42,8 +42,8 @@ // minimal saved game version we support #define SAVEGAME_VER_MAJOR 1 -#define SAVEGAME_VER_MINOR 0 -#define SAVEGAME_VER_BUILD 0 +#define SAVEGAME_VER_MINOR 1 +#define SAVEGAME_VER_BUILD 1 ////////////////////////////////////////////////////////////////////////// #define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP -- cgit v1.2.3 From eb02d6db23bb340f08a24b6c11a300511eec8d7d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 14:51:00 +0200 Subject: WINTERMUTE: Remove some old code from BFontTT --- engines/wintermute/Base/BFontTT.cpp | 181 ------------------------------------ 1 file changed, 181 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index c0f7f4a75b..2eee39e9c9 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -721,117 +721,6 @@ HRESULT CBFontTT::initFont() { return S_OK; } - -////////////////////////////////////////////////////////////////////////// -// I/O bridge between FreeType and WME file system -////////////////////////////////////////////////////////////////////////// -/* -unsigned long CBFontTT::FTReadSeekProc(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return 0; - - f->Seek(offset, SEEK_TO_BEGIN); - if (count) { - uint32 oldPos = f->GetPos(); - f->Read(buffer, count); - return f->GetPos() - oldPos; - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::FTCloseProc(FT_Stream stream) { - CBFile *f = static_cast(stream->descriptor.pointer); - if (!f) return; - - CBGame *Game = f->Game; - - Game->_fileManager->closeFile(f); - stream->descriptor.pointer = NULL; -}*/ - - -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBFontTT::WrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines) { - int currWidth = 0; - wchar_t prevChar = L'\0'; - int prevSpaceIndex = -1; - int prevSpaceWidth = 0; - int lineStartIndex = 0; - - PrepareGlyphs(text); - - for (size_t i = 0; i < text.size(); i++) { - wchar_t ch = text[i]; - - if (ch == L' ') { - prevSpaceIndex = i; - prevSpaceWidth = currWidth; - } - - int charWidth = 0; - - if (ch != L'\n') { - GlyphInfo *glyphInfo = GetGlyphCache()->GetGlyph(ch); - if (!glyphInfo) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - prevChar = ch; - - charWidth = (int)(glyphInfo->GetAdvanceX() + kerning); - } - - bool lineTooLong = maxWidth >= 0 && currWidth + charWidth > maxWidth; - bool breakOnSpace = false; - - // we can't fit even a single character - if (lineTooLong && currWidth == 0) break; - - - if (ch == L'\n' || i == text.size() - 1 || lineTooLong) { - int breakPoint, breakWidth; - - if (prevSpaceIndex >= 0 && lineTooLong) { - breakPoint = prevSpaceIndex; - breakWidth = prevSpaceWidth; - breakOnSpace = true; - } else { - breakPoint = i; - breakWidth = currWidth; - - breakOnSpace = (ch == L'\n'); - - // we're at the end - if (i == text.size() - 1) { - breakPoint++; - breakWidth += charWidth; - } - } - - if (maxHeight >= 0 && (lines.size() + 1) * GetLineHeight() > maxHeight) break; - - //WideString line = text.substr(lineStartIndex, breakPoint - lineStartIndex); // TODO: Remove - WideString line = Common::String(text.c_str() + lineStartIndex, breakPoint - lineStartIndex); - lines.push_back(new TextLine(line, breakWidth)); - - currWidth = 0; - prevChar = L'\0'; - prevSpaceIndex = -1; - - if (breakOnSpace) breakPoint++; - - lineStartIndex = breakPoint; - i = breakPoint - 1; - - continue; - } - - //if (ch == L' ' && currLine.empty()) continue; - currWidth += charWidth; - } -} -#endif ////////////////////////////////////////////////////////////////////////// void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; @@ -867,74 +756,4 @@ void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, }*/ } -#if 0 -////////////////////////////////////////////////////////////////////////// -float CBFontTT::GetKerning(wchar_t leftChar, wchar_t rightChar) { - - GlyphInfo *infoLeft = _glyphCache->GetGlyph(leftChar); - GlyphInfo *infoRight = _glyphCache->GetGlyph(rightChar); - - if (!infoLeft || !infoRight) return 0; - - FT_Vector delta; - FT_Error error = FT_Get_Kerning(_fTFace, infoLeft->GetGlyphIndex(), infoRight->GetGlyphIndex(), ft_kerning_unfitted, &delta); - if (error) return 0; - - return delta.x * (1.0f / 64.0f); - - return 0; -} -#endif -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBFontTT::PrepareGlyphs(const WideString &text) { - - // make sure we have all the glyphs we need - for (size_t i = 0; i < text.size(); i++) { - wchar_t ch = text[i]; - if (!_glyphCache->HasGlyph(ch)) CacheGlyph(ch); - } - -} -#endif -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBFontTT::CacheGlyph(wchar_t ch) { - FT_UInt glyphIndex = FT_Get_Char_Index(_fTFace, ch); - if (!glyphIndex) return; - - FT_Error error = FT_Load_Glyph(_fTFace, glyphIndex, FT_LOAD_DEFAULT); - if (error) return; - - error = FT_Render_Glyph(_fTFace->glyph, FT_RENDER_MODE_NORMAL); - if (error) return; - - byte *pixels = _fTFace->glyph->bitmap.buffer; - size_t stride = _fTFace->glyph->bitmap.pitch; - - - // convert from monochrome to grayscale if needed - byte *tempBuffer = NULL; - if (pixels != NULL && _fTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - tempBuffer = new byte[_fTFace->glyph->bitmap.width * _fTFace->glyph->bitmap.rows]; - for (int j = 0; j < _fTFace->glyph->bitmap.rows; j++) { - int rowOffset = stride * j; - for (int i = 0; i < _fTFace->glyph->bitmap.width; i++) { - int byteOffset = i / 8; - int bitOffset = 7 - (i % 8); - byte bit = (pixels[rowOffset + byteOffset] & (1 << bitOffset)) >> bitOffset; - tempBuffer[_fTFace->glyph->bitmap.width * j + i] = 255 * bit; - } - } - - pixels = tempBuffer; - stride = _fTFace->glyph->bitmap.width; - } - - // add glyph to cache - _glyphCache->AddGlyph(ch, glyphIndex, _fTFace->glyph, _fTFace->glyph->bitmap.width, _fTFace->glyph->bitmap.rows, pixels, stride); - - if (tempBuffer) delete [] tempBuffer; -} -#endif } // end of namespace WinterMute -- cgit v1.2.3 From 88a3d91cbd60a4e31194750cf367f8b50620604b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 20:46:39 +0200 Subject: WINTERMUTE: Fix a few warnings pointed out by [md5] --- engines/wintermute/Base/BSoundMgr.cpp | 5 ++++- engines/wintermute/Base/BSurfaceSDL.h | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 ++-- engines/wintermute/utils/PathUtil.cpp | 8 ++++---- engines/wintermute/utils/StringUtil.cpp | 7 ++----- engines/wintermute/utils/crc.cpp | 4 ++-- engines/wintermute/utils/crc.h | 2 +- engines/wintermute/utils/utils.cpp | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index d9ef81b315..1702bfb8d1 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -249,7 +249,7 @@ HRESULT CBSoundMgr::setVolumePercent(TSoundType Type, byte Percent) { ////////////////////////////////////////////////////////////////////////// byte CBSoundMgr::getVolumePercent(TSoundType Type) { - int Volume; + int Volume = 0; switch (Type) { case SOUND_SFX: Volume = _volumeSFX; @@ -260,6 +260,9 @@ byte CBSoundMgr::getVolumePercent(TSoundType Type) { case SOUND_MUSIC: Volume = _volumeMusic; break; + default: + error("Sound-type not set"); + break; } return (byte)Volume; diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 1c5c3c3e15..eba8b96af8 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -33,7 +33,7 @@ #include "engines/wintermute/Base/BSurface.h" namespace WinterMute { -class TransparentSurface; +struct TransparentSurface; class CBSurfaceSDL : public CBSurface { public: CBSurfaceSDL(CBGame *inGame); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 0835566d2c..473fb487cc 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -335,7 +335,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I // add script to cache CScCachedScript *CachedScript = new CScCachedScript(Filename, CompBuffer, CompSize); if (CachedScript) { - int index; + int index = 0; uint32 MinTime = CBPlatform::GetTime(); for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { @@ -446,7 +446,7 @@ HRESULT CScEngine::Tick() { // normal script else { - uint32 StartTime; + uint32 StartTime = 0; bool isProfiling = _isProfiling; if (isProfiling) StartTime = CBPlatform::GetTime(); diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index ba432019eb..f975ea6199 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -25,9 +25,9 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_ifstream + #include "engines/wintermute/dcgf.h" -#include +#include "common/file.h" #include "PathUtil.h" #include "StringUtil.h" @@ -146,10 +146,10 @@ bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { bool PathUtil::FileExists(const AnsiString &fileName) { warning("PathUtil::FileExists(%s)", fileName.c_str()); - std::ifstream stream; + Common::File stream; stream.open(fileName.c_str()); - bool ret = stream.is_open(); + bool ret = stream.isOpen(); stream.close(); return ret; diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 0e273ea84f..d7cc2fde21 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -27,9 +27,6 @@ */ #include "engines/wintermute/dcgf.h" -#include -#include -#include #include "common/tokenizer.h" #include "StringUtil.h" #include "ConvertUTF.h" @@ -38,7 +35,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// void StringUtil::ToLowerCase(AnsiString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); + return str.toUppercase(); } ////////////////////////////////////////////////////////////////////////// @@ -48,7 +45,7 @@ void StringUtil::ToLowerCase(AnsiString &str) { ////////////////////////////////////////////////////////////////////////// void StringUtil::ToUpperCase(AnsiString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::toupper); + return str.toUppercase(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp index adfd5da624..0bce1c4c51 100644 --- a/engines/wintermute/utils/crc.cpp +++ b/engines/wintermute/utils/crc.cpp @@ -222,9 +222,9 @@ crc crc_initialize(void) { return INITIAL_REMAINDER; } -crc crc_process_byte(unsigned char byte, crc remainder) { +crc crc_process_byte(unsigned char byteVal, crc remainder) { unsigned char data; - data = (unsigned char)(REFLECT_DATA(byte) ^ (remainder >> (WIDTH - 8))); + data = (unsigned char)(REFLECT_DATA(byteVal) ^ (remainder >> (WIDTH - 8))); remainder = crcTable[data] ^ (remainder << 8); return remainder; } diff --git a/engines/wintermute/utils/crc.h b/engines/wintermute/utils/crc.h index 578b423de8..cf7ea1a00c 100644 --- a/engines/wintermute/utils/crc.h +++ b/engines/wintermute/utils/crc.h @@ -74,7 +74,7 @@ crc crcSlow(unsigned char const message[], int nBytes); crc crcFast(unsigned char const message[], int nBytes); extern "C" crc crc_initialize(void); -extern "C" crc crc_process_byte(unsigned char byte, crc remainder); +extern "C" crc crc_process_byte(unsigned char byteVal, crc remainder); extern "C" crc crc_finalize(crc remainder); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 29c992f1ac..845c2e21c6 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -271,7 +271,7 @@ void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { //Delta RGB value float del_Max = var_Max - var_Min; - float H, S, L; + float H = 0.0f, S = 0.0f, L = 0.0f; L = (var_Max + var_Min) / 2.0f; -- cgit v1.2.3 From 71acc58f9cb67fb9c35109f1295e9bdad1f2cf8e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 23:08:25 +0200 Subject: WINTERMUTE: Make ScScript less endian-specific. --- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 74 ++++++++++++++++-------- engines/wintermute/Base/scriptables/ScScript.h | 10 +++- 3 files changed, 57 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 473fb487cc..a24475db7a 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -293,7 +293,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I } // needs to be compiled? - if (*(uint32 *)Buffer == SCRIPT_MAGIC) { + if (FROM_LE_32(*(uint32 *)Buffer) == SCRIPT_MAGIC) { CompBuffer = Buffer; CompSize = Size; } else { diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index a386c13229..62d5221184 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/Base/scriptables/ScStack.h" +#include "common/memstream.h" namespace WinterMute { @@ -41,6 +42,7 @@ IMPLEMENT_PERSISTENT(CScScript, false) CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { _buffer = NULL; _bufferSize = _iP = 0; + _scriptStream = NULL; _filename = NULL; _currentLine = 0; @@ -104,15 +106,26 @@ CScScript::~CScScript() { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::InitScript() { - TScriptHeader *Header = (TScriptHeader *)_buffer; - if (Header->magic != SCRIPT_MAGIC) { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.code_start = _scriptStream->readUint32LE(); + _header.func_table = _scriptStream->readUint32LE(); + _header.symbol_table = _scriptStream->readUint32LE(); + _header.event_table = _scriptStream->readUint32LE(); + _header.externals_table = _scriptStream->readUint32LE(); + _header.method_table = _scriptStream->readUint32LE(); + + if (_header.magic != SCRIPT_MAGIC) { Game->LOG(0, "File '%s' is not a valid compiled script", _filename); cleanup(); return E_FAIL; } - if (Header->version > SCRIPT_VERSION) { - Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, Header->version / 256, Header->version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + if (_header.version > SCRIPT_VERSION) { + Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); cleanup(); return E_FAIL; } @@ -130,7 +143,8 @@ HRESULT CScScript::InitScript() { // skip to the beginning - _iP = Header->code_start; + _iP = _header.code_start; + _scriptStream->seek(_iP); _currentLine = 0; // init breakpoints @@ -148,49 +162,45 @@ HRESULT CScScript::InitScript() { HRESULT CScScript::InitTables() { uint32 OrigIP = _iP; - TScriptHeader *Header = (TScriptHeader *)_buffer; - - int32 i; - // load symbol table - _iP = Header->symbol_table; + _iP = _header.symbol_table; _numSymbols = GetDWORD(); _symbols = new char*[_numSymbols]; - for (i = 0; i < _numSymbols; i++) { + for (uint32 i = 0; i < _numSymbols; i++) { uint32 index = GetDWORD(); _symbols[index] = GetString(); } // load functions table - _iP = Header->func_table; + _iP = _header.func_table; _numFunctions = GetDWORD(); _functions = new TFunctionPos[_numFunctions]; - for (i = 0; i < _numFunctions; i++) { + for (uint32 i = 0; i < _numFunctions; i++) { _functions[i].pos = GetDWORD(); _functions[i].name = GetString(); } // load events table - _iP = Header->event_table; + _iP = _header.event_table; _numEvents = GetDWORD(); _events = new TEventPos[_numEvents]; - for (i = 0; i < _numEvents; i++) { + for (uint32 i = 0; i < _numEvents; i++) { _events[i].pos = GetDWORD(); _events[i].name = GetString(); } // load externals - if (Header->version >= 0x0101) { - _iP = Header->externals_table; + if (_header.version >= 0x0101) { + _iP = _header.externals_table; _numExternals = GetDWORD(); _externals = new TExternalFunction[_numExternals]; - for (i = 0; i < _numExternals; i++) { + for (uint32 i = 0; i < _numExternals; i++) { _externals[i].dll_name = GetString(); _externals[i].name = GetString(); _externals[i].call_type = (TCallType)GetDWORD(); @@ -206,11 +216,11 @@ HRESULT CScScript::InitTables() { } // load method table - _iP = Header->method_table; + _iP = _header.method_table; _numMethods = GetDWORD(); _methods = new TMethodPos[_numMethods]; - for (i = 0; i < _numMethods; i++) { + for (uint32 i = 0; i < _numMethods; i++) { _methods[i].pos = GetDWORD(); _methods[i].name = GetString(); } @@ -283,6 +293,7 @@ HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char * // skip to the beginning of the event _iP = InitIP; + _scriptStream->seek(_iP); _timeSlice = Original->_timeSlice; _freezable = Original->_freezable; @@ -411,18 +422,29 @@ void CScScript::cleanup() { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::GetDWORD() { - uint32 ret = *(uint32 *)(_buffer + _iP); + _scriptStream->seek(_iP); + uint32 ret = _scriptStream->readUint32LE(); _iP += sizeof(uint32); - +// assert(oldRet == ret); return ret; } - ////////////////////////////////////////////////////////////////////////// double CScScript::GetFloat() { - double ret = *(double *)(_buffer + _iP); - _iP += sizeof(double); + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. return ret; } @@ -432,6 +454,7 @@ char *CScScript::GetString() { char *ret = (char *)(_buffer + _iP); while (*(char *)(_buffer + _iP) != '\0') _iP++; _iP++; // string terminator + _scriptStream->seek(_iP); return ret; } @@ -1172,6 +1195,7 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { if (_bufferSize > 0) { _buffer = new byte[_bufferSize]; persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); InitTables(); } else _buffer = NULL; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index fdf00bae82..3ce878aef9 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -102,6 +102,7 @@ public: uint32 method_table; } TScriptHeader; + TScriptHeader _header; typedef struct { char *name; @@ -142,8 +143,11 @@ public: void cleanup(); HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); uint32 _iP; +private: uint32 _bufferSize; byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; CScScript(CBGame *inGame, CScEngine *Engine); virtual ~CScScript(); char *_filename; @@ -154,9 +158,9 @@ public: TEventPos *_events; int _numExternals; TExternalFunction *_externals; - int _numFunctions; - int _numMethods; - int _numEvents; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; bool _thread; bool _methodThread; char *_threadEvent; -- cgit v1.2.3 From a994e879e5f142899b3a0b406e569530f0b6f2bf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 23:26:43 +0200 Subject: WINTERMUTE: Another warning-fix from [md5] --- engines/wintermute/Base/BRegistry.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index fcb20ad54f..26d62ff3d0 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -26,17 +26,15 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_ALLOW_ALL -#include #include "engines/wintermute/tinyxml/tinyxml.h" -#undef FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BRegistry.h" #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/tinyxml/tinyxml.h" #include "engines/wintermute/utils/utils.h" +#include "common/file.h" + namespace WinterMute { ////////////////////////////////////////////////////////////////////////// @@ -218,12 +216,12 @@ void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { TiXmlPrinter printer; doc.Accept(&printer); - std::ofstream stream; + Common::DumpFile stream; stream.open(fileName.c_str()); - if (!stream.is_open()) return; + if (!stream.isOpen()) return; else { - stream << printer.CStr(); + stream.write(printer.CStr(), printer.Size()); stream.close(); } } -- cgit v1.2.3 From 8ecb9d937d33787a7130062664649021a06989a4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 26 Jun 2012 23:29:20 +0200 Subject: WINTERMUTE: Remove another FORBIDDEN_SYMBOL_ALLOW_ALL with thanks to [md5] --- engines/wintermute/Base/BFileManager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 5ad65e8fe1..81434dd176 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -26,8 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ - -#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils/StringUtil.h" -- cgit v1.2.3 From dde2d92c69e73d02c185ca3390b5ba71c0cb7fa0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 27 Jun 2012 15:15:46 +0200 Subject: WINTERMUTE: Fix a savegame-regression --- engines/wintermute/Base/BPersistMgr.cpp | 2 ++ engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 29 +++++++++++++++++------- engines/wintermute/Base/scriptables/ScScript.h | 1 + engines/wintermute/Sys/SysClassRegistry.cpp | 1 + engines/wintermute/dcgf.h | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index e5479ea8f6..5a70fd3729 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -319,6 +319,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { Game->LOG(0, "ERROR: Saved game version is newer than current game"); + Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return E_FAIL; } @@ -329,6 +330,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return E_FAIL; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index a24475db7a..6ec70a561a 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -422,7 +422,7 @@ HRESULT CScEngine::Tick() { break; } default: - warning("CScEngine::Tick - Unhandled enum"); + //warning("CScEngine::Tick - Unhandled enum"); break; } // switch } // for each script diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 62d5221184..4060ad8472 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -102,13 +102,9 @@ CScScript::~CScScript() { cleanup(); } - - -////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::InitScript() { - if (!_scriptStream) { - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - } +void CScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); _header.magic = _scriptStream->readUint32LE(); _header.version = _scriptStream->readUint32LE(); _header.code_start = _scriptStream->readUint32LE(); @@ -117,6 +113,16 @@ HRESULT CScScript::InitScript() { _header.event_table = _scriptStream->readUint32LE(); _header.externals_table = _scriptStream->readUint32LE(); _header.method_table = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +HRESULT CScScript::InitScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); if (_header.magic != SCRIPT_MAGIC) { Game->LOG(0, "File '%s' is not a valid compiled script", _filename); @@ -162,6 +168,7 @@ HRESULT CScScript::InitScript() { HRESULT CScScript::InitTables() { uint32 OrigIP = _iP; + readHeader(); // load symbol table _iP = _header.symbol_table; @@ -1197,7 +1204,10 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { persistMgr->getBytes(_buffer, _bufferSize); _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); InitTables(); - } else _buffer = NULL; + } else { + _buffer = NULL; + _scriptStream = NULL; + } } persistMgr->transfer(TMEMBER(_callStack)); @@ -1617,6 +1627,9 @@ void CScScript::afterLoad() { _buffer = new byte [_bufferSize]; memcpy(_buffer, buffer, _bufferSize); + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + InitTables(); } } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 3ce878aef9..4f6cc50332 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -144,6 +144,7 @@ public: HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); uint32 _iP; private: + void readHeader(); uint32 _bufferSize; byte *_buffer; public: diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 88b45c3c3a..5ac5cb2ccf 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -37,6 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CSysClassRegistry::CSysClassRegistry() { + _count = 0; } diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 305ff0b5b7..8e222cfce3 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -32,7 +32,7 @@ ////////////////////////////////////////////////////////////////////////// #define DCGF_VER_MAJOR 1 -#define DCGF_VER_MINOR 0 +#define DCGF_VER_MINOR 1 #define DCGF_VER_BUILD 1 #define DCGF_VER_SUFFIX "beta" #define DCGF_VER_BETA true -- cgit v1.2.3 From ae714dc076def8efb6448c1d39058fbabb0e096f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 27 Jun 2012 22:03:15 +0200 Subject: WINTERMUTE: Fix a memory leak. --- engines/wintermute/Base/BImage.cpp | 3 +++ engines/wintermute/Base/BPersistMgr.cpp | 1 + 2 files changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index cbe134c7c6..95f6f5bbbf 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -61,6 +61,9 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { CBImage::~CBImage() { /* delete _bitmap; */ delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } delete _deletableSurface; #if 0 if (_bitmap) FreeImage_Unload(_bitmap); diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 5a70fd3729..8b037db926 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -93,6 +93,7 @@ void CBPersistMgr::cleanup() { _richBuffer = NULL; _richBufferSize = 0; + delete[] _savedDescription; _savedDescription = NULL; // ref to buffer // _savedTimestamp = 0; _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; -- cgit v1.2.3 From e49b43f7a9bbbe7bda7c4107b0279bf2add1aaaa Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 27 Jun 2012 23:32:57 +0200 Subject: WINTERMUTE: Fix almost all of the memory leaks that were left. --- engines/wintermute/Base/BFileManager.cpp | 23 ++++++++++++++++------ engines/wintermute/Base/BFileManager.h | 1 + engines/wintermute/Base/BPersistMgr.cpp | 17 +++++++++++++++- engines/wintermute/Base/BPersistMgr.h | 1 + engines/wintermute/Base/BSoundBuffer.cpp | 15 +++++++------- engines/wintermute/Base/BSoundMgr.cpp | 4 +--- engines/wintermute/Base/BSurfaceSDL.cpp | 6 +++--- engines/wintermute/Base/BSurfaceStorage.cpp | 7 ++----- engines/wintermute/Base/scriptables/ScScript.cpp | 2 ++ engines/wintermute/Sys/SysClassRegistry.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 5 +++++ .../wintermute/video/decoders/theora_decoder.cpp | 2 +- 12 files changed, 57 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 81434dd176..b346646841 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -763,6 +763,15 @@ CBFileEntry *CBFileManager::getPackageEntry(const Common::String &Filename) { return ret; } +bool CBFileManager::hasFile(const Common::String &filename) { + //TODO: Do this in a much simpler fashion + Common::SeekableReadStream *stream = openFile(filename, true, false); + if (!stream) { + return false; + } + delete stream; + return true; +} ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { @@ -801,16 +810,18 @@ HRESULT CBFileManager::closeFile(Common::SeekableReadStream *File) { Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &Filename) { restoreCurrentDir(); + Common::SeekableReadStream *ret = NULL; + if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->open(Filename))) return SaveThumbFile->getMemStream(); - else { - delete SaveThumbFile; - return NULL; - } + if (SUCCEEDED(SaveThumbFile->open(Filename))) { + ret = SaveThumbFile->getMemStream(); + } + delete SaveThumbFile; + return ret; } - Common::SeekableReadStream *ret = NULL; + ret = openDiskFile(Filename, this); if (ret) return ret; diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index fdeb9b732d..0ca9090a04 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -50,6 +50,7 @@ public: bool getFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *openFileRaw(const Common::String &filename); HRESULT closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); CBFileEntry *getPackageEntry(const Common::String &filename); Common::File *openSingleFile(const Common::String &name); diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 8b037db926..74c9fbd422 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -270,7 +270,7 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { if (Magic == SAVE_MAGIC_2) { _savedVerBuild = (byte)getDWORD(); - _savedName = getString(); + _savedName = getStringObj(); // load thumbnail _thumbnailDataSize = getDWORD(); @@ -393,6 +393,21 @@ void CBPersistMgr::putString(const Common::String &val) { } } +Common::String CBPersistMgr::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + delete[] ret; + + Common::String retString = ret; + + if (ret == "(null)") { + retString = ""; + } + + return retString; +} ////////////////////////////////////////////////////////////////////////// char *CBPersistMgr::getString() { diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 79ec12214a..90dcb12c75 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -55,6 +55,7 @@ public: uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); + Common::String getStringObj(); void putString(const Common::String &val); float getFloat(); void putFloat(float val); diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index a60b78ee33..80753c5f50 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -101,19 +101,18 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { _stream = NULL; } #endif - delete _stream; - _stream = NULL; - - if (_file) Game->_fileManager->closeFile(_file); + // If we already had a file, delete it. + delete _file; - _file = Game->_fileManager->openFile(Filename); + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = Game->_fileManager->openFile(Filename, true, false); if (!_file) { Game->LOG(0, "Error opening sound file '%s'", Filename); return E_FAIL; } Common::String strFilename(Filename); if (strFilename.hasSuffix(".ogg")) { - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::NO); + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); } else if (strFilename.hasSuffix(".wav")) { warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s", Filename); //_stream = Audio::makeWAVStream(_file, DisposeAfterUse::NO); @@ -193,10 +192,10 @@ HRESULT CBSoundBuffer::play(bool looping, uint32 startSample) { } if (_stream) { if (looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::YES); g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, loopStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); } else { - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); } } return S_OK; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 1702bfb8d1..ff5858c91e 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -138,10 +138,8 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); AnsiString newFile = PathUtil::Combine(path, name + "ogg"); - Common::SeekableReadStream *file = Game->_fileManager->openFile(newFile.c_str()); - if (file) { + if (Game->_fileManager->hasFile(newFile)) { Filename = newFile.c_str(); - Game->_fileManager->closeFile(file); } } diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 1a86bf8a90..b3757a2fb5 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -70,11 +70,10 @@ CBSurfaceSDL::~CBSurfaceSDL() { delete _scaledSurface; _scaledSurface = NULL; } -#if 0 - if (_texture) SDL_DestroyTexture(_texture); + delete[] _alphaMask; _alphaMask = NULL; -#endif + Game->AddMem(-_width * _height * 4); } @@ -151,6 +150,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + delete _surface; if (strFileName.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 8d30b01d19..53fd036d49 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -105,20 +105,17 @@ CBSurface *CBSurfaceStorage::addSurface(const char *Filename, bool default_ck, b } } - Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); - if (!File) { + if (!Game->_fileManager->hasFile(Filename)) { if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); if (Game->_dEBUG_DebugMode) return addSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else return addSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); - } else Game->_fileManager->closeFile(File); - + } CBSurface *surface; surface = new CBSurfaceSDL(Game); - if (!surface) return NULL; if (FAILED(surface->create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 4060ad8472..01827b378e 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -424,6 +424,8 @@ void CScScript::cleanup() { _waitScript = NULL; _parentScript = NULL; // ref only + + delete _scriptStream; } diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 5ac5cb2ccf..540008571f 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -214,7 +214,7 @@ HRESULT CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { Game->DisplayContentSimple(); Game->_renderer->flip(); - char *className = persistMgr->getString(); + Common::String className = persistMgr->getStringObj(); NameMap::iterator mapIt = _nameMap.find(className); if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(Game, persistMgr); } diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index aa0ace09c8..219cc295d9 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -108,6 +108,11 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { ////////////////////////////////////////////////////////////////////////// void CVidTheoraPlayer::cleanup() { + if (_file) { + Game->_fileManager->closeFile(_file); + _file = NULL; + } + _surface.free(); delete _theoraDecoder; _theoraDecoder = NULL; diff --git a/engines/wintermute/video/decoders/theora_decoder.cpp b/engines/wintermute/video/decoders/theora_decoder.cpp index 647d9aff08..a8e403c97c 100644 --- a/engines/wintermute/video/decoders/theora_decoder.cpp +++ b/engines/wintermute/video/decoders/theora_decoder.cpp @@ -456,7 +456,7 @@ bool TheoraDecoder::queueAudio() { #ifdef SCUMM_LITTLE_ENDIAN flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audStream->queueBuffer((byte *)_audiobuf, AUDIOFD_FRAGSIZE, DisposeAfterUse::NO, flags); + _audStream->queueBuffer((byte *)_audiobuf, AUDIOFD_FRAGSIZE, DisposeAfterUse::YES, flags); // The audio mixer is now responsible for the old audio buffer. // We need to create a new one. -- cgit v1.2.3 From 7d45960039326eed4e02f2fae502c79a5538ea0e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 28 Jun 2012 02:08:33 +0200 Subject: WINTERMUTE: Cap framerate at 25 fps for now. --- engines/wintermute/wintermute.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 7b987867c3..c57be85cf1 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -263,7 +263,13 @@ int WinterMuteEngine::init() { int WinterMuteEngine::messageLoop() { bool done = false; - + + uint32 prevTime = _system->getMillis(); + uint32 time = _system->getMillis(); + uint32 diff = 0; + + const uint32 maxFPS = 25; + const uint32 frameTime = (1.0/maxFPS) * 1000; while (!done) { Common::Event event; while (_system->getEventManager()->pollEvent(event)) { @@ -271,18 +277,22 @@ int WinterMuteEngine::messageLoop() { } if (_game && _game->_renderer->_active && _game->_renderer->_ready) { - _game->DisplayContent(); _game->DisplayQuickMsg(); - + _game->DisplayDebugInfo(); - + + time = _system->getMillis(); + diff = time - prevTime; + if (frameTime > diff) // Avoid overflows + _system->delayMillis(frameTime - diff); + // ***** flip if (!_game->_suspendedRendering) _game->_renderer->flip(); if (_game->_loading) _game->LoadGame(_game->_scheduledLoadSlot); + prevTime = time; } if (_game->_quitting) break; - } if (_game) { -- cgit v1.2.3 From 900bd7a77d7e29be7968ac014325489d4eca6d45 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 28 Jun 2012 02:35:38 +0200 Subject: WINTERMUTE: Avoid making a new Rect for the fill every screen. --- engines/wintermute/Base/BRenderSDL.cpp | 12 ++++-------- engines/wintermute/Base/BRenderSDL.h | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 6ddf200b9e..2920a4d00c 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -73,9 +73,10 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); #endif - _width = width; _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); _realWidth = width; _realHeight = height; @@ -247,14 +248,9 @@ HRESULT CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_RenderClear(_renderer); uint32 color = _renderSurface->format.ARGBToColor(0xFF, r, g, b); if (!rect) { - rect = new Common::Rect(); - rect->setWidth(_renderSurface->w); - rect->setHeight(_renderSurface->h); - _renderSurface->fillRect(*rect, color); - delete rect; - } else { - _renderSurface->fillRect(*rect, color); + rect = &_renderRect; } + _renderSurface->fillRect(*rect, color); return S_OK; } diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index e9ca53610a..ad32e9e1da 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -81,6 +81,7 @@ public: private: /* SDL_Renderer *_renderer; SDL_Window *_win;*/ + Common::Rect _renderRect; Graphics::Surface *_renderSurface; AnsiString _name; -- cgit v1.2.3 From 417ab2b47a62f1dd73524ab64e0dd654c0cfcdd7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 30 Jun 2012 03:52:31 +0200 Subject: WINTERMUTE: A first attempt at implementing dirty rects in WME --- engines/wintermute/Base/BRenderSDL.cpp | 297 ++++++++++++++++++++++---------- engines/wintermute/Base/BRenderSDL.h | 43 ++++- engines/wintermute/Base/BSurfaceSDL.cpp | 65 +++---- engines/wintermute/Base/BSurfaceSDL.h | 3 +- 4 files changed, 267 insertions(+), 141 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 2920a4d00c..2f2db5e10b 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -37,21 +37,66 @@ #include "engines/wintermute/Base/BSprite.h" #include "common/system.h" #include "engines/wintermute/graphics/transparentSurface.h" +#include "common/queue.h" namespace WinterMute { +RenderTicket::RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _mirrorX(mirrorX), _mirrorY(mirrorY), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { + _colorMod = 0; + if (surf) { + _surface = new Graphics::Surface(); + _surface->create(srcRect->width(), srcRect->height(), surf->format); + assert(_surface->format.bytesPerPixel == 4); + // Get a clipped copy of the surface + for (int i = 0; i < _surface->h; i++) { + memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); + } + // Then scale it if necessary + if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + TransparentSurface src(*_surface, false); + Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); + _surface->free(); + delete _surface; + _surface = temp; + } + } else { + _surface = NULL; + } +} + +RenderTicket::~RenderTicket() { + if (_surface) { + _surface->free(); + delete _surface; + } +} + +bool RenderTicket::operator==(RenderTicket &t) { + if ((t._srcRect != _srcRect) || + (t._dstRect != _dstRect) || + (t._mirrorX != _mirrorX) || + (t._mirrorY != _mirrorY) || + (t._hasAlpha != _hasAlpha)) { + return false; + } + return true; +} + // TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { - /* _renderer = NULL; - _win = NULL;*/ _renderSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; setAlphaMod(255); setColorMod(255, 255, 255); + _dirtyRect = NULL; + _disableDirtyRects = true; } ////////////////////////////////////////////////////////////////////////// @@ -177,6 +222,7 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); return S_OK; } @@ -195,49 +241,18 @@ void CBRenderSDL::setColorMod(byte r, byte g, byte b) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::flip() { - -#ifdef __IPHONEOS__ - // hack: until viewports work correctly, we just paint black bars instead - SDL_SetRenderDrawColor(_renderer, 0x00, 0x00, 0x00, 0xFF); - - static bool firstRefresh = true; // prevents a weird color glitch - if (firstRefresh) { - firstRefresh = false; - } else { - SDL_Rect rect; - if (_borderLeft > 0) { - rect.x = 0; - rect.y = 0; - rect.w = _borderLeft; - rect.h = _realHeight; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderRight > 0) { - rect.x = (_realWidth - _borderRight); - rect.y = 0; - rect.w = _borderRight; - rect.h = _realHeight; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderTop > 0) { - rect.x = 0; - rect.y = 0; - rect.w = _realWidth; - rect.h = _borderTop; - SDL_RenderFillRect(_renderer, &rect); - } - if (_borderBottom > 0) { - rect.x = 0; - rect.y = _realHeight - _borderBottom; - rect.w = _realWidth; - rect.h = _borderBottom; - SDL_RenderFillRect(_renderer, &rect); - } + if (!_disableDirtyRects) { + drawTickets(); } -#endif - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); - g_system->updateScreen(); - //SDL_RenderPresent(_renderer); + if (_needsFlip || _disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + delete _dirtyRect; + _dirtyRect = NULL; + g_system->updateScreen(); + _needsFlip = false; + } + _drawNum = 1; return S_OK; } @@ -246,11 +261,13 @@ HRESULT CBRenderSDL::flip() { HRESULT CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); - uint32 color = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) + return S_OK; if (!rect) { rect = &_renderRect; } - _renderSurface->fillRect(*rect, color); + _renderSurface->fillRect(*rect, _clearColor); return S_OK; } @@ -268,6 +285,7 @@ HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { + warning("CBRenderSDL::FadeToColor - Breaks when using dirty rects"); warning("Implement CBRenderSDL::FadeToColor"); // TODO. hasWarned = true; } @@ -305,61 +323,162 @@ HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { return S_OK; } -// Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { - TransparentSurface src(*surf, false); - int mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - mirror |= TransparentSurface::FLIP_H; - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, srcRect, _colorMod, dstRect->width(), dstRect->height()); -} - -void CBRenderSDL::drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { - TransparentSurface src(*surf, false); - TransparentSurface *img = NULL; - TransparentSurface *imgScaled = NULL; - byte *savedPixels = NULL; - if ((dstRect->width() != surf->w) || (dstRect->height() != surf->h)) { - img = imgScaled = src.scale(dstRect->width(), dstRect->height()); - savedPixels = (byte *)img->pixels; - } else { - img = &src; +void CBRenderSDL::drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { + if (_disableDirtyRects) { + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + // HINT: The surface-data contains other info than it should. + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL); + return; + } + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + ticket->_colorMod = _colorMod; + drawFromTicket(ticket); +} - int posX = dstRect->left; - int posY = dstRect->top; +void CBRenderSDL::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} - // Handle off-screen clipping - if (posY < 0) { - img->h = (uint16)(MAX(0, (int)img->h - -posY)); - img->pixels = (byte *)img->pixels + img->pitch * -posY; - posY = 0; +void CBRenderSDL::invalidateTicketsFromSurface(CBSurfaceSDL *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } } +} - if (posX < 0) { - img->w = (uint16)(MAX(0, (int)img->w - -posX)); - img->pixels = (byte *)img->pixels + (-posX * 4); - posX = 0; +void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { + renderTicket->_wantsDraw = true; + // New item + uint32 size = _renderQueue.size(); + // A new item always has _drawNum == 0 + if (renderTicket->_drawNum == 0) { + // In-order + if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { + renderTicket->_drawNum = _drawNum++; + _renderQueue.push_back(renderTicket); + addDirtyRect(renderTicket->_dstRect); + } else { + // Before something + Common::List::iterator pos; + for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { + if ((*pos)->_drawNum > _drawNum) { + break; + } + } + _renderQueue.insert(pos, renderTicket); + Common::List::iterator it; + renderTicket->_drawNum = _drawNum++; + + // Increment the following tickets, so they still are in line + for (it = pos; it != _renderQueue.end(); it++) { + (*it)->_drawNum++; + } + addDirtyRect(renderTicket->_dstRect); + } + } else { + // Was drawn last round, still in the same order + if (_drawNum == renderTicket->_drawNum) { + _drawNum++; + } else { + // Is not in order + renderTicket->_drawNum = _drawNum++; + addDirtyRect(renderTicket->_dstRect); + } } +} - img->w = (uint16)(CLIP((int)img->w, 0, (int)MAX((int)_renderSurface->w - posX, 0))); - img->h = (uint16)(CLIP((int)img->h, 0, (int)MAX((int)_renderSurface->h - posY, 0))); +void CBRenderSDL::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); +} - for (int i = 0; i < img->h; i++) { - void *destPtr = _renderSurface->getBasePtr(posX, posY + i); - void *srcPtr = img->getBasePtr(0, i); - memcpy(destPtr, srcPtr, _renderSurface->format.bytesPerPixel * img->w); +void CBRenderSDL::drawTickets() { + if (!_dirtyRect) + return; + RenderQueueIterator it = _renderQueue.begin(); + uint32 size = _renderQueue.size(); + // Clean out the old tickets + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false) { + RenderTicket* ticket = *it; + addDirtyRect((*it)->_dstRect); + it = _renderQueue.erase(it); + delete ticket; + } else { + it++; + } + } + // The color-mods are stored in the RenderTickets on add, since we set that state again during + // draw, we need to keep track of what it was prior to draw. + uint32 oldColorMod = _colorMod; +// warning("DirtyRect: %d %d %d %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom); + + // Apply the clear-color to the dirty rect. + _renderSurface->fillRect(*_dirtyRect, _clearColor); + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + RenderTicket *ticket = *it; + if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { + // dstClip is the area we want redrawn. + Common::Rect dstClip(ticket->_dstRect); + // reduce it to the dirty rect + dstClip.clip(*_dirtyRect); + // we need to keep track of the position to redraw the dirty rect + Common::Rect pos(dstClip); + int offsetX = ticket->_dstRect.left; + int offsetY = ticket->_dstRect.top; + // convert from screen-coords to surface-coords. + dstClip.translate(-offsetX, -offsetY); + + _colorMod = ticket->_colorMod; + drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirrorX, ticket->_mirrorX); + ticket->_wantsDraw = false; + _needsFlip = true; + } } + // Revert the colorMod-state. + _colorMod = oldColorMod; +} - if (imgScaled) { - imgScaled->pixels = savedPixels; - imgScaled->free(); - delete imgScaled; - imgScaled = NULL; +// Replacement for SDL2's SDL_RenderCopy +void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, bool mirrorX, bool mirrorY) { + TransparentSurface src(*surf, false); + int mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + mirror |= TransparentSurface::FLIP_H; + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(surf->w); + clipRect->setHeight(surf->h); } + + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) + delete clipRect; } + ////////////////////////////////////////////////////////////////////////// HRESULT CBRenderSDL::drawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { static bool hasWarned = false; diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index ad32e9e1da..a9abb18e9d 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -32,11 +32,30 @@ #include "engines/wintermute/Base/BRenderer.h" #include "common/rect.h" #include "graphics/surface.h" - -class SDL_Window; -class SDL_Renderer; +#include "common/list.h" namespace WinterMute { +class CBSurfaceSDL; +class RenderTicket { +public: + RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + Graphics::Surface *_surface; + Common::Rect _srcRect; + Common::Rect _dstRect; + bool _mirrorX; + bool _mirrorY; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + CBSurfaceSDL *_owner; + bool operator==(RenderTicket &a); +}; class CBRenderSDL : public CBRenderer { public: @@ -60,8 +79,9 @@ public: void setAlphaMod(byte alpha); void setColorMod(byte r, byte g, byte b); - void drawFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); - void drawOpaqueFromSurface(Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(CBSurfaceSDL *surf); + void drawFromTicket(RenderTicket *renderTicket); HRESULT setViewport(int left, int top, int right, int bottom); @@ -78,9 +98,16 @@ public: return _ratioY; } + void drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); private: - /* SDL_Renderer *_renderer; - SDL_Window *_win;*/ + void addDirtyRect(const Common::Rect &rect); + void drawTickets(); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, bool mirrorX = false, bool mirrorY = false); + typedef Common::List::iterator RenderQueueIterator; + Common::Rect *_dirtyRect; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; Common::Rect _renderRect; Graphics::Surface *_renderSurface; AnsiString _name; @@ -90,9 +117,11 @@ private: int _borderRight; int _borderBottom; + bool _disableDirtyRects; float _ratioX; float _ratioY; uint32 _colorMod; + uint32 _clearColor; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index b3757a2fb5..8dbe7c75b6 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -48,10 +48,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { _surface = new Graphics::Surface(); - _scaledSurface = NULL; _alphaMask = NULL; _hasAlpha = true; - _lockPixels = NULL; _lockPitch = 0; } @@ -65,16 +63,12 @@ CBSurfaceSDL::~CBSurfaceSDL() { _surface = NULL; } - if (_scaledSurface) { - _scaledSurface->free(); - delete _scaledSurface; - _scaledSurface = NULL; - } - delete[] _alphaMask; _alphaMask = NULL; Game->AddMem(-_width * _height * 4); + CBRenderSDL *renderer = static_cast(Game->_renderer); + renderer->invalidateTicketsFromSurface(this); } bool hasTransparency(Graphics::Surface *surf) { @@ -416,11 +410,8 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { HRESULT CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: - if (_scaledSurface) { - _scaledSurface->free(); - delete _scaledSurface; - _scaledSurface = NULL; - } + CBRenderSDL *renderer = static_cast(Game->_renderer); + renderer->invalidateTicketsFromSurface(this); return S_OK; } @@ -507,6 +498,13 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo position.top = y + offsetY; // TODO: Scaling... + if (position.left == -1) { + position.left = 0; // TODO: Something is wrong + } + if (position.top == -1) { + position.top = 0; // TODO: Something is wrong + } + position.setWidth((float)srcRect.width() * ZoomX / 100.f); position.setHeight((float)srcRect.height() * ZoomX / 100.f); @@ -517,40 +515,18 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. - Graphics::Surface drawSrc; - drawSrc.w = (uint16)position.width(); - drawSrc.h = (uint16)position.height(); - drawSrc.format = _surface->format; - - if (position.width() != srcRect.width() || position.height() != srcRect.height()) { - if (_scaledSurface && position.width() == _scaledSurface->w && position.height() == _scaledSurface->h) { - drawSrc.pixels = _scaledSurface->pixels; - drawSrc.pitch = _scaledSurface->pitch; - } else { - if (_scaledSurface) { - _scaledSurface->free(); - delete _scaledSurface; - _scaledSurface = NULL; - } - TransparentSurface src(*_surface, false); - _scaledSurface = src.scale(position.width(), position.height()); - drawSrc.pixels = _scaledSurface->pixels; - drawSrc.pitch = _scaledSurface->pitch; - } - } else { // No scaling - drawSrc.pitch = _surface->pitch; - drawSrc.pixels = &((char *)_surface->pixels)[srcRect.top * _surface->pitch + srcRect.left * 4]; - } - srcRect.left = 0; - srcRect.top = 0; - srcRect.setWidth(drawSrc.w); - srcRect.setHeight(drawSrc.h); + bool hasAlpha; if (_hasAlpha && !AlphaDisable) { - renderer->drawFromSurface(&drawSrc, &srcRect, &position, mirrorX, mirrorY); + hasAlpha = true; } else { - renderer->drawOpaqueFromSurface(&drawSrc, &srcRect, &position, mirrorX, mirrorY); + hasAlpha = false; + } + if (AlphaDisable) { + warning("CBSurfaceSDL::drawSprite - AlphaDisable ignored"); } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); #if 0 SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif @@ -561,6 +537,9 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo HRESULT CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _surface->copyFrom(surface); _hasAlpha = hasAlpha; + CBRenderSDL *renderer = static_cast(Game->_renderer); + renderer->invalidateTicketsFromSurface(this); + return S_OK; } diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index eba8b96af8..60052f70a1 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -31,6 +31,7 @@ #include "graphics/surface.h" #include "engines/wintermute/Base/BSurface.h" +#include "common/list.h" namespace WinterMute { struct TransparentSurface; @@ -75,9 +76,7 @@ public: } private: -// SDL_Texture *_texture; Graphics::Surface *_surface; - TransparentSurface *_scaledSurface; HRESULT drawSprite(int x, int y, RECT *Rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); -- cgit v1.2.3 From 17b9732a59ea512be368d045104fba6b219ed55e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 2 Jul 2012 23:40:06 +0200 Subject: WINTERMUTE: Fix a mistake in StringUtil toLowerCase was doing toUpperCase. --- engines/wintermute/utils/StringUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index d7cc2fde21..2ca392973b 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -35,7 +35,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// void StringUtil::ToLowerCase(AnsiString &str) { - return str.toUppercase(); + str.toLowercase(); } ////////////////////////////////////////////////////////////////////////// @@ -45,7 +45,7 @@ void StringUtil::ToLowerCase(AnsiString &str) { ////////////////////////////////////////////////////////////////////////// void StringUtil::ToUpperCase(AnsiString &str) { - return str.toUppercase(); + str.toUppercase(); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 453e597b31a11cec3f7f2af4d6ff4f66e9e9acf2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 04:03:02 +0200 Subject: WINTERMUTE: Rename VarName and FuncName -> varName and funcName in AdActor --- engines/wintermute/Ad/AdActor.cpp | 276 +++++++++++++++++++------------------- engines/wintermute/Ad/AdActor.h | 34 ++--- 2 files changed, 155 insertions(+), 155 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 84a727209d..9090f3038e 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -72,11 +72,11 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { _animSprite2 = NULL; - SetDefaultAnimNames(); + setDefaultAnimNames(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::SetDefaultAnimNames() { +HRESULT CAdActor::setDefaultAnimNames() { _talkAnimName = "talk"; _idleAnimName = "idle"; _walkAnimName = "walk"; @@ -123,19 +123,19 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdActor::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); delete [] Buffer; @@ -183,7 +183,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -227,18 +227,18 @@ HRESULT CAdActor::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { Game->LOG(0, "'ACTOR' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } CAdGame *AdGame = (CAdGame *)Game; CAdSpriteSet *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -460,7 +460,7 @@ HRESULT CAdActor::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -void CAdActor::TurnTo(TDirection dir) { +void CAdActor::turnTo(TDirection dir) { int delta1, delta2, delta3, delta; delta1 = dir - _dir; @@ -486,15 +486,15 @@ void CAdActor::TurnTo(TDirection dir) { ////////////////////////////////////////////////////////////////////////// -void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { - _afterWalkDir = AfterWalkDir; - if (X == _targetPoint->x && Y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; +void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { + _afterWalkDir = afterWalkDir; + if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; _path->Reset(); _path->SetReady(false); - _targetPoint->x = X; - _targetPoint->y = Y; + _targetPoint->x = x; + _targetPoint->y = y; ((CAdGame *)Game)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); @@ -507,33 +507,33 @@ void CAdActor::GoTo(int X, int Y, TDirection AfterWalkDir) { HRESULT CAdActor::display() { if (_active) updateSounds(); - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + uint32 alpha; + if (_alphaColor != 0) alpha = _alphaColor; + else alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); + float scaleX, scaleY; + GetScale(&scaleX, &scaleY); - float Rotate; + float rotate; if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; + if (_rotateValid) rotate = _rotate; + else rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } else rotate = 0.0f; if (_active) displaySpriteAttachments(true); if (_currentSprite && _active) { - bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; + bool reg = _registrable; + if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) reg = false; _currentSprite->display(_posX, _posY, - Reg ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, + reg ? _registerAlias : NULL, + scaleX, + scaleY, + alpha, + rotate, _blendMode); } @@ -582,7 +582,7 @@ HRESULT CAdActor::update() { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } @@ -615,7 +615,7 @@ HRESULT CAdActor::update() { if (_turnLeftSprite) { _tempSprite2 = _turnLeftSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(_turnLeftAnimName); + CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); if (Anim) _tempSprite2 = Anim->getSprite(_dir); } @@ -644,7 +644,7 @@ HRESULT CAdActor::update() { if (_turnRightSprite) { _tempSprite2 = _turnRightSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(_turnRightAnimName); + CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); if (Anim) _tempSprite2 = Anim->getSprite(_dir); } @@ -669,13 +669,13 @@ HRESULT CAdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_WAITING_PATH: // wait until the scene finished the path - if (_path->_ready) FollowPath(); + if (_path->_ready) followPath(); break; ////////////////////////////////////////////////////////////////////////// case STATE_FOLLOWING_PATH: - GetNextStep(); + getNextStep(); already_moved = true; break; @@ -714,7 +714,7 @@ HRESULT CAdActor::update() { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } @@ -747,7 +747,7 @@ HRESULT CAdActor::update() { ////////////////////////////////////////////////////////////////////////// -void CAdActor::FollowPath() { +void CAdActor::followPath() { // skip current position _path->GetFirst(); while (_path->GetCurrent() != NULL) { @@ -758,20 +758,20 @@ void CAdActor::FollowPath() { // are there points to follow? if (_path->GetCurrent() != NULL) { _state = STATE_FOLLOWING_PATH;; - InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + initLine(CBPoint(_posX, _posY), *_path->GetCurrent()); } else { - if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); else _state = STATE_READY; } } ////////////////////////////////////////////////////////////////////////// -void CAdActor::GetNextStep() { +void CAdActor::getNextStep() { if (_walkSprite) { _currentSprite = _walkSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = GetAnimByName(_walkAnimName); + CAdSpriteSet *Anim = getAnimByName(_walkAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } @@ -781,19 +781,19 @@ void CAdActor::GetNextStep() { if (!_currentSprite->_changed) return; - int MaxStepX, MaxStepY; - MaxStepX = abs(_currentSprite->_moveX); - MaxStepY = abs(_currentSprite->_moveY); + int maxStepX, maxStepY; + maxStepX = abs(_currentSprite->_moveX); + maxStepY = abs(_currentSprite->_moveY); - MaxStepX = MAX(MaxStepX, MaxStepY); - MaxStepX = MAX(MaxStepX, 1); + maxStepX = MAX(maxStepX, maxStepY); + maxStepX = MAX(maxStepX, 1); - while (_pFCount > 0 && MaxStepX >= 0) { + while (_pFCount > 0 && maxStepX >= 0) { _pFX += _pFStepX; _pFY += _pFStepY; _pFCount--; - MaxStepX--; + maxStepX--; } if (((CAdGame *)Game)->_scene->isBlockedAt(_pFX, _pFY, true, this)) { @@ -802,7 +802,7 @@ void CAdActor::GetNextStep() { _nextState = STATE_READY; return; } - GoTo(_targetPoint->x, _targetPoint->y); + goTo(_targetPoint->x, _targetPoint->y); return; } @@ -819,47 +819,47 @@ void CAdActor::GetNextStep() { _posY = _targetPoint->y; _path->Reset(); - if (_afterWalkDir != DI_NONE) TurnTo(_afterWalkDir); + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); else { _state = _nextState; _nextState = STATE_READY; } - } else InitLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + } else initLine(CBPoint(_posX, _posY), *_path->GetCurrent()); } } ////////////////////////////////////////////////////////////////////////// -void CAdActor::InitLine(CBPoint StartPt, CBPoint EndPt) { - _pFCount = MAX((abs(EndPt.x - StartPt.x)) , (abs(EndPt.y - StartPt.y))); +void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { + _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); - _pFStepX = (double)(EndPt.x - StartPt.x) / _pFCount; - _pFStepY = (double)(EndPt.y - StartPt.y) / _pFCount; + _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; + _pFStepY = (double)(endPt.y - startPt.y) / _pFCount; - _pFX = StartPt.x; - _pFY = StartPt.y; + _pFX = startPt.x; + _pFY = startPt.y; - int angle = (int)(atan2((double)(EndPt.y - StartPt.y), (double)(EndPt.x - StartPt.x)) * (180 / 3.14)); + int angle = (int)(atan2((double)(endPt.y - startPt.y), (double)(endPt.x - startPt.x)) * (180 / 3.14)); _nextState = STATE_FOLLOWING_PATH; - TurnTo(AngleToDirection(angle)); + turnTo(angleToDirection(angle)); } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GoTo") == 0 || strcmp(Name, "GoToAsync") == 0) { + if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { Stack->CorrectParams(2); int X = Stack->Pop()->GetInt(); int Y = Stack->Pop()->GetInt(); - GoTo(X, Y); - if (strcmp(Name, "GoToAsync") != 0) Script->WaitForExclusive(this); + goTo(X, Y); + if (strcmp(name, "GoToAsync") != 0) Script->WaitForExclusive(this); Stack->PushNULL(); return S_OK; } @@ -867,24 +867,24 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GoToObject / GoToObjectAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoToObject") == 0 || strcmp(Name, "GoToObjectAsync") == 0) { + else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { Stack->CorrectParams(1); CScValue *Val = Stack->Pop(); if (!Val->IsNative()) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Script->RuntimeError("actor.%s method accepts an entity refrence only", name); Stack->PushNULL(); return S_OK; } CAdObject *Obj = (CAdObject *)Val->GetNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", Name); + Script->RuntimeError("actor.%s method accepts an entity refrence only", name); Stack->PushNULL(); return S_OK; } CAdEntity *Ent = (CAdEntity *)Obj; - if (Ent->_walkToX == 0 && Ent->_walkToY == 0) GoTo(Ent->_posX, Ent->_posY); - else GoTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(Name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); + if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); + else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); + if (strcmp(name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); Stack->PushNULL(); return S_OK; } @@ -892,7 +892,7 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // TurnTo / TurnToAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnTo") == 0 || strcmp(Name, "TurnToAsync") == 0) { + else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { Stack->CorrectParams(1); int dir; CScValue *val = Stack->Pop(); @@ -901,14 +901,14 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { CBObject *obj = (CBObject *)val->GetNative(); int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); - dir = (int)AngleToDirection(angle); + dir = (int)angleToDirection(angle); } // otherwise turn to direction else dir = val->GetInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) { - TurnTo((TDirection)dir); - if (strcmp(Name, "TurnToAsync") != 0) Script->WaitForExclusive(this); + turnTo((TDirection)dir); + if (strcmp(name, "TurnToAsync") != 0) Script->WaitForExclusive(this); } Stack->PushNULL(); return S_OK; @@ -917,7 +917,7 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // IsWalking ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsWalking") == 0) { + else if (strcmp(name, "IsWalking") == 0) { Stack->CorrectParams(0); Stack->PushBool(_state == STATE_FOLLOWING_PATH); return S_OK; @@ -926,16 +926,16 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // MergeAnims ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MergeAnims") == 0) { + else if (strcmp(name, "MergeAnims") == 0) { Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(MergeAnims(Stack->Pop()->GetString()))); + Stack->PushBool(SUCCEEDED(mergeAnims(Stack->Pop()->GetString()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // UnloadAnim ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadAnim") == 0) { + else if (strcmp(name, "UnloadAnim") == 0) { Stack->CorrectParams(1); const char *AnimName = Stack->Pop()->GetString(); @@ -961,39 +961,39 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // HasAnim ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasAnim") == 0) { + else if (strcmp(name, "HasAnim") == 0) { Stack->CorrectParams(1); const char *AnimName = Stack->Pop()->GetString(); - Stack->PushBool(GetAnimByName(AnimName) != NULL); + Stack->PushBool(getAnimByName(AnimName) != NULL); return S_OK; } - else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::scGetProperty(const char *Name) { +CScValue *CAdActor::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Direction") == 0) { + if (strcmp(name, "Direction") == 0) { _scValue->SetInt(_dir); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Type") == 0) { + else if (strcmp(name, "Type") == 0) { _scValue->SetString("actor"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // TalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkAnimName") == 0) { + else if (strcmp(name, "TalkAnimName") == 0) { _scValue->SetString(_talkAnimName); return _scValue; } @@ -1001,7 +1001,7 @@ CScValue *CAdActor::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkAnimName") == 0) { + else if (strcmp(name, "WalkAnimName") == 0) { _scValue->SetString(_walkAnimName); return _scValue; } @@ -1009,7 +1009,7 @@ CScValue *CAdActor::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // IdleAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IdleAnimName") == 0) { + else if (strcmp(name, "IdleAnimName") == 0) { _scValue->SetString(_idleAnimName); return _scValue; } @@ -1017,7 +1017,7 @@ CScValue *CAdActor::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnLeftAnimName") == 0) { + else if (strcmp(name, "TurnLeftAnimName") == 0) { _scValue->SetString(_turnLeftAnimName); return _scValue; } @@ -1025,21 +1025,21 @@ CScValue *CAdActor::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnRightAnimName") == 0) { + else if (strcmp(name, "TurnRightAnimName") == 0) { _scValue->SetString(_turnRightAnimName); return _scValue; } - else return CAdTalkHolder::scGetProperty(Name); + else return CAdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Direction") == 0) { + if (strcmp(name, "Direction") == 0) { int dir = Value->GetInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; return S_OK; @@ -1048,7 +1048,7 @@ HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkAnimName") == 0) { + else if (strcmp(name, "TalkAnimName") == 0) { if (Value->IsNULL()) _talkAnimName = "talk"; else _talkAnimName = Value->GetString(); return S_OK; @@ -1057,7 +1057,7 @@ HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // WalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkAnimName") == 0) { + else if (strcmp(name, "WalkAnimName") == 0) { if (Value->IsNULL()) _walkAnimName = "walk"; else _walkAnimName = Value->GetString(); return S_OK; @@ -1066,7 +1066,7 @@ HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // IdleAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IdleAnimName") == 0) { + else if (strcmp(name, "IdleAnimName") == 0) { if (Value->IsNULL()) _idleAnimName = "idle"; else _idleAnimName = Value->GetString(); return S_OK; @@ -1075,7 +1075,7 @@ HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnLeftAnimName") == 0) { + else if (strcmp(name, "TurnLeftAnimName") == 0) { if (Value->IsNULL()) _turnLeftAnimName = "turnleft"; else _turnLeftAnimName = Value->GetString(); return S_OK; @@ -1084,13 +1084,13 @@ HRESULT CAdActor::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TurnRightAnimName") == 0) { + else if (strcmp(name, "TurnRightAnimName") == 0) { if (Value->IsNULL()) _turnRightAnimName = "turnright"; else _turnRightAnimName = Value->GetString(); return S_OK; } - else return CAdTalkHolder::scSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(name, Value); } @@ -1101,7 +1101,7 @@ const char *CAdActor::scToString() { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStance(const char *Stance) { +CBSprite *CAdActor::getTalkStance(const char *stance) { // forced stance? if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; @@ -1119,17 +1119,17 @@ CBSprite *CAdActor::getTalkStance(const char *Stance) { // old way if (_talkSprites.GetSize() > 0 || _talkSpritesEx.GetSize() > 0) - return GetTalkStanceOld(Stance); + return getTalkStanceOld(stance); // new way - CBSprite *Ret = NULL; + CBSprite *ret = NULL; // do we have an animation with this name? - CAdSpriteSet *Anim = GetAnimByName(Stance); - if (Anim) Ret = Anim->getSprite(_dir); + CAdSpriteSet *Anim = getAnimByName(stance); + if (Anim) ret = Anim->getSprite(_dir); // not - get a random talk - if (!Ret) { + if (!ret) { CBArray TalkAnims; for (int i = 0; i < _anims.GetSize(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) @@ -1138,26 +1138,26 @@ CBSprite *CAdActor::getTalkStance(const char *Stance) { if (TalkAnims.GetSize() > 0) { int rnd = g_wintermute->randInt(0, TalkAnims.GetSize() - 1); - Ret = TalkAnims[rnd]->getSprite(_dir); + ret = TalkAnims[rnd]->getSprite(_dir); } else { - if (_standSprite) Ret = _standSprite->getSprite(_dir); + if (_standSprite) ret = _standSprite->getSprite(_dir); else { - Anim = GetAnimByName(_idleAnimName); - if (Anim) Ret = Anim->getSprite(_dir); + Anim = getAnimByName(_idleAnimName); + if (Anim) ret = Anim->getSprite(_dir); } } } - return Ret; + return ret; } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { +CBSprite *CAdActor::getTalkStanceOld(const char *stance) { CBSprite *ret = NULL; - if (Stance != NULL) { + if (stance != NULL) { // search special stances for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, Stance) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { ret = _talkSpritesEx[i]->getSprite(_dir); break; } @@ -1165,7 +1165,7 @@ CBSprite *CAdActor::GetTalkStanceOld(const char *Stance) { if (ret == NULL) { // search generic stances for (int i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, Stance) == 0) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { ret = _talkSprites[i]->getSprite(_dir); break; } @@ -1221,17 +1221,17 @@ HRESULT CAdActor::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -TDirection CAdActor::AngleToDirection(int Angle) { +TDirection CAdActor::angleToDirection(int angle) { TDirection ret = DI_DOWN;; - if (Angle > -112 && Angle <= -67) ret = DI_UP; - else if (Angle > -67 && Angle <= -22) ret = DI_UPRIGHT; - else if (Angle > -22 && Angle <= 22) ret = DI_RIGHT; - else if (Angle > 22 && Angle <= 67) ret = DI_DOWNRIGHT; - else if (Angle > 67 && Angle <= 112) ret = DI_DOWN; - else if (Angle > 112 && Angle <= 157) ret = DI_DOWNLEFT; - else if ((Angle > 157 && Angle <= 180) || (Angle >= -180 && Angle <= -157)) ret = DI_LEFT; - else if (Angle > -157 && Angle <= -112) ret = DI_UPLEFT; + if (angle > -112 && angle <= -67) ret = DI_UP; + else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; + else if (angle > -22 && angle <= 22) ret = DI_RIGHT; + else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; + else if (angle > 67 && angle <= 112) ret = DI_DOWN; + else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; + else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; + else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; return ret; } @@ -1243,7 +1243,7 @@ int CAdActor::getHeight() { if (_currentSprite == NULL) { if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); else { - CAdSpriteSet *Anim = GetAnimByName(_idleAnimName); + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } @@ -1253,7 +1253,7 @@ int CAdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::GetAnimByName(const Common::String &animName) { +CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.GetSize(); i++) { if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) return _anims[i]; @@ -1262,26 +1262,26 @@ CAdSpriteSet *CAdActor::GetAnimByName(const Common::String &animName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { +HRESULT CAdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END - byte *FileBuffer = Game->_fileManager->readWholeFile(AnimsFilename); - if (FileBuffer == NULL) { - Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", AnimsFilename); + byte *fileBuffer = Game->_fileManager->readWholeFile(animsFilename); + if (fileBuffer == NULL) { + Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); return E_FAIL; } - byte *Buffer = FileBuffer; + byte *buffer = fileBuffer; byte *params; int cmd; CBParser parser(Game); HRESULT Ret = S_OK; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); @@ -1293,14 +1293,14 @@ HRESULT CAdActor::MergeAnims(const char *AnimsFilename) { break; } } - delete [] FileBuffer; + delete [] fileBuffer; return Ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::PlayAnim(const char *Filename) { +HRESULT CAdActor::playAnim(const char *filename) { // if we have an anim with this name, use it - CAdSpriteSet *Anim = GetAnimByName(Filename); + CAdSpriteSet *Anim = getAnimByName(filename); if (Anim) { _animSprite2 = Anim->getSprite(_dir); if (_animSprite2) { @@ -1310,7 +1310,7 @@ HRESULT CAdActor::PlayAnim(const char *Filename) { } } // otherwise call the standard handler - return CAdTalkHolder::playAnim(Filename); + return CAdTalkHolder::playAnim(filename); } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index 50444d844a..ab07bf3e77 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -46,17 +46,17 @@ class CAdSpriteSet; class CAdPath; class CAdActor : public CAdTalkHolder { public: - TDirection AngleToDirection(int Angle); + TDirection angleToDirection(int angle); DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) virtual int getHeight(); - CBSprite *getTalkStance(const char *Stance); - virtual void GoTo(int X, int Y, TDirection AfterWalkDir = DI_NONE); + CBSprite *getTalkStance(const char *stance); + virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); CBPoint *_targetPoint; virtual HRESULT update(); virtual HRESULT display(); TDirection _targetDir; TDirection _afterWalkDir; - virtual void TurnTo(TDirection dir); + virtual void turnTo(TDirection dir); CAdPath *_path; CAdSpriteSet *_walkSprite; CAdSpriteSet *_standSprite; @@ -67,8 +67,8 @@ public: TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); - HRESULT loadFile(const char *Filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *filename); + HRESULT loadBuffer(byte *buffer, bool complete = true); // new anim system Common::String _talkAnimName; @@ -77,24 +77,24 @@ public: Common::String _turnLeftAnimName; Common::String _turnRightAnimName; CBArray _anims; - virtual HRESULT PlayAnim(const char *Filename); - CAdSpriteSet *GetAnimByName(const Common::String &animName); + virtual HRESULT playAnim(const char *filename); + CAdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - HRESULT SetDefaultAnimNames(); - CBSprite *GetTalkStanceOld(const char *Stance); - HRESULT MergeAnims(const char *AnimsFilename); + HRESULT setDefaultAnimNames(); + CBSprite *getTalkStanceOld(const char *stance); + HRESULT mergeAnims(const char *animsFilename); CBSprite *_animSprite2; - void InitLine(CBPoint StartPt, CBPoint EndPt); - void GetNextStep(); - void FollowPath(); + void initLine(CBPoint startPt, CBPoint endPt); + void getNextStep(); + void followPath(); double _pFStepX; double _pFStepY; double _pFX; -- cgit v1.2.3 From f4f64a26a9010989fba2758fa53c4b913d37e142 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 04:31:32 +0200 Subject: WINTERMUTE: Mass rename varName->VarName --- engines/wintermute/Ad/AdActor.cpp | 58 +- engines/wintermute/Ad/AdEntity.cpp | 116 +- engines/wintermute/Ad/AdEntity.h | 6 +- engines/wintermute/Ad/AdGame.cpp | 426 ++++---- engines/wintermute/Ad/AdGame.h | 20 +- engines/wintermute/Ad/AdInventory.cpp | 14 +- engines/wintermute/Ad/AdInventory.h | 4 +- engines/wintermute/Ad/AdItem.cpp | 130 +-- engines/wintermute/Ad/AdItem.h | 6 +- engines/wintermute/Ad/AdLayer.cpp | 86 +- engines/wintermute/Ad/AdLayer.h | 6 +- engines/wintermute/Ad/AdNodeState.cpp | 4 +- engines/wintermute/Ad/AdNodeState.h | 2 +- engines/wintermute/Ad/AdObject.cpp | 242 ++-- engines/wintermute/Ad/AdRegion.cpp | 44 +- engines/wintermute/Ad/AdRegion.h | 6 +- engines/wintermute/Ad/AdScene.cpp | 338 +++--- engines/wintermute/Ad/AdScene.h | 8 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 14 +- engines/wintermute/Ad/AdWaypointGroup.h | 4 +- engines/wintermute/Base/BDebugger.cpp | 12 +- engines/wintermute/Base/BDebugger.h | 12 +- engines/wintermute/Base/BFileManager.cpp | 76 +- engines/wintermute/Base/BFrame.cpp | 134 +-- engines/wintermute/Base/BFrame.h | 6 +- engines/wintermute/Base/BGame.cpp | 1152 ++++++++++---------- engines/wintermute/Base/BGame.h | 12 +- engines/wintermute/Base/BKeyboardState.cpp | 36 +- engines/wintermute/Base/BKeyboardState.h | 6 +- engines/wintermute/Base/BObject.cpp | 298 ++--- engines/wintermute/Base/BObject.h | 6 +- engines/wintermute/Base/BRegion.cpp | 82 +- engines/wintermute/Base/BRegion.h | 6 +- engines/wintermute/Base/BRegistry.cpp | 12 +- engines/wintermute/Base/BRegistry.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 76 +- engines/wintermute/Base/BScriptable.cpp | 6 +- engines/wintermute/Base/BScriptable.h | 2 +- engines/wintermute/Base/BSprite.cpp | 92 +- engines/wintermute/Base/BSprite.h | 6 +- engines/wintermute/Base/BSubFrame.cpp | 68 +- engines/wintermute/Base/BSubFrame.h | 6 +- engines/wintermute/Base/PartEmitter.cpp | 268 ++--- engines/wintermute/Base/PartEmitter.h | 12 +- engines/wintermute/Base/scriptables/SXArray.cpp | 40 +- engines/wintermute/Base/scriptables/SXArray.h | 6 +- engines/wintermute/Base/scriptables/SXDate.cpp | 122 +-- engines/wintermute/Base/scriptables/SXDate.h | 6 +- engines/wintermute/Base/scriptables/SXFile.cpp | 306 +++--- engines/wintermute/Base/scriptables/SXFile.h | 6 +- engines/wintermute/Base/scriptables/SXMath.cpp | 136 +-- engines/wintermute/Base/scriptables/SXMath.h | 4 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 226 ++-- engines/wintermute/Base/scriptables/SXMemBuffer.h | 6 +- engines/wintermute/Base/scriptables/SXStore.h | 4 +- engines/wintermute/Base/scriptables/SXString.cpp | 86 +- engines/wintermute/Base/scriptables/SXString.h | 6 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 18 +- engines/wintermute/Base/scriptables/ScEngine.h | 10 +- engines/wintermute/Base/scriptables/ScScript.cpp | 74 +- engines/wintermute/Base/scriptables/ScScript.h | 12 +- engines/wintermute/Base/scriptables/ScValue.cpp | 36 +- engines/wintermute/Base/scriptables/ScValue.h | 10 +- engines/wintermute/Base/scriptables/SxObject.cpp | 6 +- engines/wintermute/UI/UIButton.cpp | 180 +-- engines/wintermute/UI/UIButton.h | 6 +- engines/wintermute/UI/UIEdit.cpp | 50 +- engines/wintermute/UI/UIEdit.h | 6 +- engines/wintermute/UI/UIEntity.cpp | 36 +- engines/wintermute/UI/UIEntity.h | 6 +- engines/wintermute/UI/UIObject.cpp | 124 +-- engines/wintermute/UI/UIObject.h | 6 +- engines/wintermute/UI/UIText.cpp | 34 +- engines/wintermute/UI/UIText.h | 6 +- engines/wintermute/UI/UIWindow.cpp | 186 ++-- engines/wintermute/UI/UIWindow.h | 10 +- engines/wintermute/wme_debugger.h | 2 +- 77 files changed, 2847 insertions(+), 2847 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 9090f3038e..7e76ab4737 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -850,17 +850,17 @@ void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *name) { +HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); goTo(X, Y); - if (strcmp(name, "GoToAsync") != 0) Script->WaitForExclusive(this); - Stack->PushNULL(); + if (strcmp(name, "GoToAsync") != 0) script->WaitForExclusive(this); + stack->PushNULL(); return S_OK; } @@ -868,24 +868,24 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // GoToObject / GoToObjectAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (!Val->IsNative()) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", name); - Stack->PushNULL(); + script->RuntimeError("actor.%s method accepts an entity refrence only", name); + stack->PushNULL(); return S_OK; } CAdObject *Obj = (CAdObject *)Val->GetNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { - Script->RuntimeError("actor.%s method accepts an entity refrence only", name); - Stack->PushNULL(); + script->RuntimeError("actor.%s method accepts an entity refrence only", name); + stack->PushNULL(); return S_OK; } CAdEntity *Ent = (CAdEntity *)Obj; if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(name, "GoToObjectAsync") != 0) Script->WaitForExclusive(this); - Stack->PushNULL(); + if (strcmp(name, "GoToObjectAsync") != 0) script->WaitForExclusive(this); + stack->PushNULL(); return S_OK; } @@ -893,9 +893,9 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // TurnTo / TurnToAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { - Stack->CorrectParams(1); + stack->CorrectParams(1); int dir; - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); // turn to object? if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { @@ -908,9 +908,9 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (dir >= 0 && dir < NUM_DIRECTIONS) { turnTo((TDirection)dir); - if (strcmp(name, "TurnToAsync") != 0) Script->WaitForExclusive(this); + if (strcmp(name, "TurnToAsync") != 0) script->WaitForExclusive(this); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -918,8 +918,8 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // IsWalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsWalking") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(_state == STATE_FOLLOWING_PATH); + stack->CorrectParams(0); + stack->PushBool(_state == STATE_FOLLOWING_PATH); return S_OK; } @@ -927,8 +927,8 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // MergeAnims ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MergeAnims") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(mergeAnims(Stack->Pop()->GetString()))); + stack->CorrectParams(1); + stack->PushBool(SUCCEEDED(mergeAnims(stack->Pop()->GetString()))); return S_OK; } @@ -936,8 +936,8 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // UnloadAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); + stack->CorrectParams(1); + const char *AnimName = stack->Pop()->GetString(); bool Found = false; for (int i = 0; i < _anims.GetSize(); i++) { @@ -954,7 +954,7 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Found = true; } } - Stack->PushBool(Found); + stack->PushBool(Found); return S_OK; } @@ -962,13 +962,13 @@ HRESULT CAdActor::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi // HasAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); - Stack->PushBool(getAnimByName(AnimName) != NULL); + stack->CorrectParams(1); + const char *AnimName = stack->Pop()->GetString(); + stack->PushBool(getAnimByName(AnimName) != NULL); return S_OK; } - else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, name); + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 22f85d58cf..d4252f9f55 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -625,27 +625,27 @@ HRESULT CAdEntity::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { - Stack->CorrectParams(0); + if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { + stack->CorrectParams(0); - if (FAILED(stopSFX(false))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(stopSFX(false))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PlayTheora ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayTheora") == 0) { - Stack->CorrectParams(4); - const char *Filename = Stack->Pop()->GetString(); - bool Looping = Stack->Pop()->GetBool(false); - CScValue *ValAlpha = Stack->Pop(); - int StartTime = Stack->Pop()->GetInt(); + else if (strcmp(name, "PlayTheora") == 0) { + stack->CorrectParams(4); + const char *Filename = stack->Pop()->GetString(); + bool Looping = stack->Pop()->GetBool(false); + CScValue *ValAlpha = stack->Pop(); + int StartTime = stack->Pop()->GetInt(); delete _theora; _theora = new CVidTheoraPlayer(Game); @@ -653,10 +653,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, Looping, StartTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; - Stack->PushBool(true); + stack->PushBool(true); } else { - Script->RuntimeError("Entity.PlayTheora - error playing video '%s'", Filename); - Stack->PushBool(false); + script->RuntimeError("Entity.PlayTheora - error playing video '%s'", Filename); + stack->PushBool(false); } return S_OK; @@ -665,14 +665,14 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // StopTheora ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopTheora") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "StopTheora") == 0) { + stack->CorrectParams(0); if (_theora) { _theora->stop(); delete _theora; _theora = NULL; - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -680,10 +680,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // IsTheoraPlaying ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTheoraPlaying") == 0) { - Stack->CorrectParams(0); - if (_theora && _theora->isPlaying()) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "IsTheoraPlaying") == 0) { + stack->CorrectParams(0); + if (_theora && _theora->isPlaying()) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -691,12 +691,12 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // PauseTheora ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseTheora") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "PauseTheora") == 0) { + stack->CorrectParams(0); if (_theora && _theora->isPlaying()) { _theora->pause(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -704,12 +704,12 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // ResumeTheora ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeTheora") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ResumeTheora") == 0) { + stack->CorrectParams(0); if (_theora && _theora->isPaused()) { _theora->resume(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -717,10 +717,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // IsTheoraPaused ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTheoraPaused") == 0) { - Stack->CorrectParams(0); - if (_theora && _theora->isPaused()) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "IsTheoraPaused") == 0) { + stack->CorrectParams(0); + if (_theora && _theora->isPaused()) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -729,14 +729,14 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // CreateRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateRegion") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "CreateRegion") == 0) { + stack->CorrectParams(0); if (!_region) { _region = new CBRegion(Game); Game->RegisterObject(_region); } - if (_region) Stack->PushNative(_region, true); - else Stack->PushNULL(); + if (_region) stack->PushNative(_region, true); + else stack->PushNULL(); return S_OK; } @@ -744,29 +744,29 @@ HRESULT CAdEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // DeleteRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteRegion") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DeleteRegion") == 0) { + stack->CorrectParams(0); if (_region) { Game->UnregisterObject(_region); _region = NULL; - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } - else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::scGetProperty(const char *Name) { +CScValue *CAdEntity::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("entity"); return _scValue; } @@ -774,7 +774,7 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Item") == 0) { + else if (strcmp(name, "Item") == 0) { if (_item) _scValue->SetString(_item); else _scValue->SetNULL(); @@ -784,7 +784,7 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Subtype (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtype") == 0) { + else if (strcmp(name, "Subtype") == 0) { if (_subtype == ENTITY_SOUND) _scValue->SetString("sound"); else @@ -796,7 +796,7 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WalkToX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToX") == 0) { + else if (strcmp(name, "WalkToX") == 0) { _scValue->SetInt(_walkToX); return _scValue; } @@ -804,7 +804,7 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WalkToY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToY") == 0) { + else if (strcmp(name, "WalkToY") == 0) { _scValue->SetInt(_walkToY); return _scValue; } @@ -812,7 +812,7 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WalkToDirection ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToDirection") == 0) { + else if (strcmp(name, "WalkToDirection") == 0) { _scValue->SetInt((int)_walkToDir); return _scValue; } @@ -820,23 +820,23 @@ CScValue *CAdEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Region (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Region") == 0) { + else if (strcmp(name, "Region") == 0) { if (_region) _scValue->SetNative(_region, true); else _scValue->SetNULL(); return _scValue; } - else return CAdTalkHolder::scGetProperty(Name); + else return CAdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdEntity::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Item") == 0) { + if (strcmp(name, "Item") == 0) { SetItem(Value->GetString()); return S_OK; } @@ -844,7 +844,7 @@ HRESULT CAdEntity::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // WalkToX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToX") == 0) { + else if (strcmp(name, "WalkToX") == 0) { _walkToX = Value->GetInt(); return S_OK; } @@ -852,7 +852,7 @@ HRESULT CAdEntity::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // WalkToY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToY") == 0) { + else if (strcmp(name, "WalkToY") == 0) { _walkToY = Value->GetInt(); return S_OK; } @@ -860,13 +860,13 @@ HRESULT CAdEntity::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // WalkToDirection ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WalkToDirection") == 0) { + else if (strcmp(name, "WalkToDirection") == 0) { int Dir = Value->GetInt(); if (Dir >= 0 && Dir < NUM_DIRECTIONS) _walkToDir = (TDirection)Dir; return S_OK; } - else return CAdTalkHolder::scSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 0d6864d8eb..380cf7fcae 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -56,9 +56,9 @@ public: TEntityType _subtype; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 7758737359..34d9c600a7 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -316,27 +316,27 @@ void CAdGame::FinishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "ChangeScene") == 0) { - Stack->CorrectParams(3); - const char *Filename = Stack->Pop()->GetString(); - CScValue *valFadeOut = Stack->Pop(); - CScValue *valFadeIn = Stack->Pop(); + if (strcmp(name, "ChangeScene") == 0) { + stack->CorrectParams(3); + const char *Filename = stack->Pop()->GetString(); + CScValue *valFadeOut = stack->Pop(); + CScValue *valFadeIn = stack->Pop(); bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); ScheduleChangeScene(Filename, TransIn); if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true); - Stack->PushNULL(); + stack->PushNULL(); - //HRESULT ret = ChangeScene(Stack->Pop()->GetString()); - //if(FAILED(ret)) Stack->PushBool(false); - //else Stack->PushBool(true); + //HRESULT ret = ChangeScene(stack->Pop()->GetString()); + //if(FAILED(ret)) stack->PushBool(false); + //else stack->PushBool(true); return S_OK; } @@ -344,16 +344,16 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadActor") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "LoadActor") == 0) { + stack->CorrectParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(Stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) { AddObject(act); - Stack->PushNative(act, true); + stack->PushNative(act, true); } else { delete act; act = NULL; - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; } @@ -361,16 +361,16 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // LoadEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadEntity") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "LoadEntity") == 0) { + stack->CorrectParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(Stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) { AddObject(ent); - Stack->PushNative(ent, true); + stack->PushNative(ent, true); } else { delete ent; ent = NULL; - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; } @@ -378,51 +378,51 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "DeleteEntity") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); CAdObject *obj = (CAdObject *)val->GetNative(); RemoveObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // CreateEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateEntity") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdEntity *Ent = new CAdEntity(Game); AddObject(Ent); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - Stack->PushNative(Ent, true); + stack->PushNative(Ent, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // CreateItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateItem") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdItem *Item = new CAdItem(Game); AddItem(Item); if (!Val->IsNULL()) Item->setName(Val->GetString()); - Stack->PushNative(Item, true); + stack->PushNative(Item, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "DeleteItem") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdItem *Item = NULL; if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); @@ -432,16 +432,16 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This DeleteItem(Item); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // QueryItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "QueryItem") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "QueryItem") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdItem *Item = NULL; if (Val->IsInt()) { @@ -451,8 +451,8 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This Item = GetItemByName(Val->GetString()); } - if (Item) Stack->PushNative(Item, true); - else Stack->PushNULL(); + if (Item) stack->PushNative(Item, true); + else stack->PushNULL(); return S_OK; } @@ -461,14 +461,14 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // AddResponse/AddResponseOnce/AddResponseOnceGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddResponse") == 0 || strcmp(Name, "AddResponseOnce") == 0 || strcmp(Name, "AddResponseOnceGame") == 0) { - Stack->CorrectParams(6); - int id = Stack->Pop()->GetInt(); - const char *text = Stack->Pop()->GetString(); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - CScValue *val3 = Stack->Pop(); - CScValue *val4 = Stack->Pop(); + else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { + stack->CorrectParams(6); + int id = stack->Pop()->GetInt(); + const char *text = stack->Pop()->GetString(); + CScValue *val1 = stack->Pop(); + CScValue *val2 = stack->Pop(); + CScValue *val3 = stack->Pop(); + CScValue *val4 = stack->Pop(); if (_responseBox) { CAdResponse *res = new CAdResponse(Game); @@ -481,15 +481,15 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); if (!val4->IsNULL()) res->SetFont(val4->GetString()); - if (strcmp(Name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; - else if (strcmp(Name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; + if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; + else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; _responseBox->_responses.Add(res); } } else { - Script->RuntimeError("Game.AddResponse: response box is not defined"); + script->RuntimeError("Game.AddResponse: response box is not defined"); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -497,56 +497,56 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ResetResponse ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResetResponse") == 0) { - Stack->CorrectParams(1); - int ID = Stack->Pop()->GetInt(-1); + else if (strcmp(name, "ResetResponse") == 0) { + stack->CorrectParams(1); + int ID = stack->Pop()->GetInt(-1); ResetResponse(ID); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ClearResponses ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClearResponses") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ClearResponses") == 0) { + stack->CorrectParams(0); _responseBox->clearResponses(); _responseBox->clearButtons(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetResponse ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetResponse") == 0) { - Stack->CorrectParams(1); - bool AutoSelectLast = Stack->Pop()->GetBool(); + else if (strcmp(name, "GetResponse") == 0) { + stack->CorrectParams(1); + bool AutoSelectLast = stack->Pop()->GetBool(); if (_responseBox) { _responseBox->weedResponses(); if (_responseBox->_responses.GetSize() == 0) { - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { - Stack->PushInt(_responseBox->_responses[0]->_iD); + stack->PushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); return S_OK; } _responseBox->createButtons(); - _responseBox->_waitingScript = Script; - Script->WaitForExclusive(_responseBox); + _responseBox->_waitingScript = script; + script->WaitForExclusive(_responseBox); _state = GAME_SEMI_FROZEN; _stateEx = GAME_WAITING_RESPONSE; } else { - Script->RuntimeError("Game.GetResponse: response box is not defined"); - Stack->PushNULL(); + script->RuntimeError("Game.GetResponse: response box is not defined"); + stack->PushNULL(); } return S_OK; } @@ -555,14 +555,14 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetNumResponses ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNumResponses") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetNumResponses") == 0) { + stack->CorrectParams(0); if (_responseBox) { _responseBox->weedResponses(); - Stack->PushInt(_responseBox->_responses.GetSize()); + stack->PushInt(_responseBox->_responses.GetSize()); } else { - Script->RuntimeError("Game.GetNumResponses: response box is not defined"); - Stack->PushNULL(); + script->RuntimeError("Game.GetNumResponses: response box is not defined"); + stack->PushNULL(); } return S_OK; } @@ -571,16 +571,16 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // StartDlgBranch ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartDlgBranch") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "StartDlgBranch") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); Common::String BranchName; if (Val->IsNULL()) { - BranchName.format("line%d", Script->_currentLine); + BranchName.format("line%d", script->_currentLine); } else BranchName = Val->GetString(); - StartDlgBranch(BranchName.c_str(), Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); - Stack->PushNULL(); + StartDlgBranch(BranchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + stack->PushNULL(); return S_OK; } @@ -588,15 +588,15 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // EndDlgBranch ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EndDlgBranch") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "EndDlgBranch") == 0) { + stack->CorrectParams(1); const char *BranchName = NULL; - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); if (!Val->IsNULL()) BranchName = Val->GetString(); - EndDlgBranch(BranchName, Script->_filename == NULL ? "" : Script->_filename, Script->_threadEvent == NULL ? "" : Script->_threadEvent); + EndDlgBranch(BranchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -604,12 +604,12 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetCurrentDlgBranch ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCurrentDlgBranch") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetCurrentDlgBranch") == 0) { + stack->CorrectParams(0); if (_dlgPendingBranches.GetSize() > 0) { - Stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); - } else Stack->PushNULL(); + stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); + } else stack->PushNULL(); return S_OK; } @@ -617,67 +617,67 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // TakeItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TakeItem") == 0) { - return _invObject->scCallMethod(Script, Stack, ThisStack, Name); + else if (strcmp(name, "TakeItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// // DropItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DropItem") == 0) { - return _invObject->scCallMethod(Script, Stack, ThisStack, Name); + else if (strcmp(name, "DropItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// // GetItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetItem") == 0) { - return _invObject->scCallMethod(Script, Stack, ThisStack, Name); + else if (strcmp(name, "GetItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// // HasItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasItem") == 0) { - return _invObject->scCallMethod(Script, Stack, ThisStack, Name); + else if (strcmp(name, "HasItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// // IsItemTaken ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsItemTaken") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "IsItemTaken") == 0) { + stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (!val->IsNULL()) { for (int i = 0; i < _inventories.GetSize(); i++) { CAdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { if (val->GetNative() == Inv->_takenItems[j]) { - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } } } - } else Script->RuntimeError("Game.IsItemTaken: item name expected"); + } else script->RuntimeError("Game.IsItemTaken: item name expected"); - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetInventoryWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInventoryWindow") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetInventoryWindow") == 0) { + stack->CorrectParams(0); if (_inventoryBox && _inventoryBox->_window) - Stack->PushNative(_inventoryBox->_window, true); + stack->PushNative(_inventoryBox->_window, true); else - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -685,12 +685,12 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetResponsesWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetResponsesWindow") == 0 || strcmp(Name, "GetResponseWindow") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { + stack->CorrectParams(0); if (_responseBox && _responseBox->_window) - Stack->PushNative(_responseBox->_window, true); + stack->PushNative(_responseBox->_window, true); else - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -698,19 +698,19 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // LoadResponseBox ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadResponseBox") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "LoadResponseBox") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); Game->UnregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); if (_responseBox && !FAILED(_responseBox->loadFile(Filename))) { RegisterObject(_responseBox); - Stack->PushBool(true); + stack->PushBool(true); } else { delete _responseBox; _responseBox = NULL; - Stack->PushBool(false); + stack->PushBool(false); } return S_OK; } @@ -718,19 +718,19 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // LoadInventoryBox ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadInventoryBox") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "LoadInventoryBox") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); Game->UnregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); if (_inventoryBox && !FAILED(_inventoryBox->loadFile(Filename))) { RegisterObject(_inventoryBox); - Stack->PushBool(true); + stack->PushBool(true); } else { delete _inventoryBox; _inventoryBox = NULL; - Stack->PushBool(false); + stack->PushBool(false); } return S_OK; } @@ -738,13 +738,13 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // LoadItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadItems") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool Merge = Stack->Pop()->GetBool(false); + else if (strcmp(name, "LoadItems") == 0) { + stack->CorrectParams(2); + const char *Filename = stack->Pop()->GetString(); + bool Merge = stack->Pop()->GetBool(false); HRESULT Ret = LoadItemsFile(Filename, Merge); - Stack->PushBool(SUCCEEDED(Ret)); + stack->PushBool(SUCCEEDED(Ret)); return S_OK; } @@ -752,10 +752,10 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // AddSpeechDir ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSpeechDir") == 0) { - Stack->CorrectParams(1); - const char *Dir = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); + else if (strcmp(name, "AddSpeechDir") == 0) { + stack->CorrectParams(1); + const char *Dir = stack->Pop()->GetString(); + stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); return S_OK; } @@ -763,10 +763,10 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // RemoveSpeechDir ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveSpeechDir") == 0) { - Stack->CorrectParams(1); - const char *Dir = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); + else if (strcmp(name, "RemoveSpeechDir") == 0) { + stack->CorrectParams(1); + const char *Dir = stack->Pop()->GetString(); + stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); return S_OK; } @@ -774,12 +774,12 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // SetSceneViewport ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSceneViewport") == 0) { - Stack->CorrectParams(4); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - int Width = Stack->Pop()->GetInt(); - int Height = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetSceneViewport") == 0) { + stack->CorrectParams(4); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + int Width = stack->Pop()->GetInt(); + int Height = stack->Pop()->GetInt(); if (Width <= 0) Width = _renderer->_width; if (Height <= 0) Height = _renderer->_height; @@ -787,31 +787,31 @@ HRESULT CAdGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(X, Y, X + Width, Y + Height); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } - else return CBGame::scCallMethod(Script, Stack, ThisStack, Name); + else return CBGame::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::scGetProperty(const char *Name) { +CScValue *CAdGame::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scene") == 0) { + else if (strcmp(name, "Scene") == 0) { if (_scene) _scValue->SetNative(_scene, true); else _scValue->SetNULL(); @@ -820,7 +820,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SelectedItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelectedItem") == 0) { + else if (strcmp(name, "SelectedItem") == 0) { //if(_selectedItem) _scValue->SetString(_selectedItem->_name); if (_selectedItem) _scValue->SetNative(_selectedItem, true); else _scValue->SetNULL(); @@ -830,14 +830,14 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumItems") == 0) { - return _invObject->scGetProperty(Name); + else if (strcmp(name, "NumItems") == 0) { + return _invObject->scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// // SmartItemCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SmartItemCursor") == 0) { + else if (strcmp(name, "SmartItemCursor") == 0) { _scValue->SetBool(_smartItemCursor); return _scValue; } @@ -845,7 +845,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // InventoryVisible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryVisible") == 0) { + else if (strcmp(name, "InventoryVisible") == 0) { _scValue->SetBool(_inventoryBox && _inventoryBox->_visible); return _scValue; } @@ -853,7 +853,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryScrollOffset") == 0) { + else if (strcmp(name, "InventoryScrollOffset") == 0) { if (_inventoryBox) _scValue->SetInt(_inventoryBox->_scrollOffset); else _scValue->SetInt(0); @@ -863,7 +863,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ResponsesVisible (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResponsesVisible") == 0) { + else if (strcmp(name, "ResponsesVisible") == 0) { _scValue->SetBool(_stateEx == GAME_WAITING_RESPONSE); return _scValue; } @@ -871,7 +871,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PrevScene / PreviousScene (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PrevScene") == 0 || strcmp(Name, "PreviousScene") == 0) { + else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { if (!_prevSceneName) _scValue->SetString(""); else _scValue->SetString(_prevSceneName); return _scValue; @@ -880,7 +880,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PrevSceneFilename / PreviousSceneFilename (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PrevSceneFilename") == 0 || strcmp(Name, "PreviousSceneFilename") == 0) { + else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { if (!_prevSceneFilename) _scValue->SetString(""); else _scValue->SetString(_prevSceneFilename); return _scValue; @@ -889,7 +889,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LastResponse") == 0) { + else if (strcmp(name, "LastResponse") == 0) { if (!_responseBox || !_responseBox->_lastResponseText) _scValue->SetString(""); else _scValue->SetString(_responseBox->_lastResponseText); return _scValue; @@ -898,7 +898,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LastResponseOrig") == 0) { + else if (strcmp(name, "LastResponseOrig") == 0) { if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->SetString(""); else _scValue->SetString(_responseBox->_lastResponseTextOrig); return _scValue; @@ -907,7 +907,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // InventoryObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryObject") == 0) { + else if (strcmp(name, "InventoryObject") == 0) { if (_inventoryOwner == _invObject) _scValue->SetNative(this, true); else _scValue->SetNative(_inventoryOwner, true); @@ -917,7 +917,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TotalNumItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TotalNumItems") == 0) { + else if (strcmp(name, "TotalNumItems") == 0) { _scValue->SetInt(_items.GetSize()); return _scValue; } @@ -925,7 +925,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TalkSkipButton ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkSkipButton") == 0) { + else if (strcmp(name, "TalkSkipButton") == 0) { _scValue->SetInt(_talkSkipButton); return _scValue; } @@ -933,7 +933,7 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ChangingScene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ChangingScene") == 0) { + else if (strcmp(name, "ChangingScene") == 0) { _scValue->SetBool(_scheduledScene != NULL); return _scValue; } @@ -941,23 +941,23 @@ CScValue *CAdGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // StartupScene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartupScene") == 0) { + else if (strcmp(name, "StartupScene") == 0) { if (!_startupScene) _scValue->SetNULL(); else _scValue->SetString(_startupScene); return _scValue; } - else return CBGame::scGetProperty(Name); + else return CBGame::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SelectedItem") == 0) { + if (strcmp(name, "SelectedItem") == 0) { if (Value->IsNULL()) _selectedItem = NULL; else { if (Value->IsNative()) { @@ -980,7 +980,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SmartItemCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SmartItemCursor") == 0) { + else if (strcmp(name, "SmartItemCursor") == 0) { _smartItemCursor = Value->GetBool(); return S_OK; } @@ -988,7 +988,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // InventoryVisible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryVisible") == 0) { + else if (strcmp(name, "InventoryVisible") == 0) { if (_inventoryBox) _inventoryBox->_visible = Value->GetBool(); return S_OK; } @@ -996,7 +996,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // InventoryObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryObject") == 0) { + else if (strcmp(name, "InventoryObject") == 0) { if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; if (Value->IsNULL()) _inventoryOwner = _invObject; @@ -1014,7 +1014,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InventoryScrollOffset") == 0) { + else if (strcmp(name, "InventoryScrollOffset") == 0) { if (_inventoryBox) _inventoryBox->_scrollOffset = Value->GetInt(); return S_OK; } @@ -1022,7 +1022,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TalkSkipButton ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TalkSkipButton") == 0) { + else if (strcmp(name, "TalkSkipButton") == 0) { int Val = Value->GetInt(); if (Val < 0) Val = 0; if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; @@ -1033,7 +1033,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // StartupScene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StartupScene") == 0) { + else if (strcmp(name, "StartupScene") == 0) { if (Value == NULL) { delete[] _startupScene; _startupScene = NULL; @@ -1042,7 +1042,7 @@ HRESULT CAdGame::scSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBGame::scSetProperty(Name, Value); + else return CBGame::scSetProperty(name, Value); } @@ -1058,35 +1058,35 @@ void CAdGame::PublishNatives() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *this_obj; ////////////////////////////////////////////////////////////////////////// // Actor ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Actor") == 0) { - Stack->CorrectParams(0); - this_obj = ThisStack->GetTop(); + if (strcmp(name, "Actor") == 0) { + stack->CorrectParams(0); + this_obj = thisStack->GetTop(); this_obj->SetNative(new CAdActor(Game)); - Stack->PushNULL(); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Entity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Entity") == 0) { - Stack->CorrectParams(0); - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "Entity") == 0) { + stack->CorrectParams(0); + this_obj = thisStack->GetTop(); this_obj->SetNative(new CAdEntity(Game)); - Stack->PushNULL(); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // call parent - else return CBGame::ExternalCall(Script, Stack, ThisStack, Name); + else return CBGame::ExternalCall(script, stack, thisStack, name); return S_OK; @@ -1334,23 +1334,23 @@ void CAdGame::AfterLoadScene(void *Scene, void *Data) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneName(const char *Name) { +void CAdGame::SetPrevSceneName(const char *name) { delete[] _prevSceneName; _prevSceneName = NULL; - if (Name) { - _prevSceneName = new char[strlen(Name) + 1]; - if (_prevSceneName) strcpy(_prevSceneName, Name); + if (name) { + _prevSceneName = new char[strlen(name) + 1]; + if (_prevSceneName) strcpy(_prevSceneName, name); } } ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneFilename(const char *Name) { +void CAdGame::SetPrevSceneFilename(const char *name) { delete[] _prevSceneFilename; _prevSceneFilename = NULL; - if (Name) { - _prevSceneFilename = new char[strlen(Name) + 1]; - if (_prevSceneFilename) strcpy(_prevSceneFilename, Name); + if (name) { + _prevSceneFilename = new char[strlen(name) + 1]; + if (_prevSceneFilename) strcpy(_prevSceneFilename, name); } } @@ -1518,14 +1518,14 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { - if (strcmp(Name, "CreateEntityContainer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); +HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) { + if (strcmp(name, "CreateEntityContainer") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIEntity *Ent = new CUIEntity(Game); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - Stack->PushNative(Ent, true); + stack->PushNative(Ent, true); Ent->_parent = Win; Win->_widgets.Add(Ent); @@ -1537,10 +1537,10 @@ HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScSt ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { - char *Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; - if (Name) { - sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); - _dlgPendingBranches.Add(Name); + char *name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", BranchName, ScriptName, EventName); + _dlgPendingBranches.Add(name); } return S_OK; } @@ -1548,26 +1548,26 @@ HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { - char *Name = NULL; + char *name = NULL; bool DeleteName = false; if (BranchName == NULL && _dlgPendingBranches.GetSize() > 0) { - Name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; + name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; } else { if (BranchName != NULL) { - Name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; - if (Name) { - sprintf(Name, "%s.%s.%s", BranchName, ScriptName, EventName); + name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", BranchName, ScriptName, EventName); DeleteName = true; } } } - if (Name == NULL) return S_OK; + if (name == NULL) return S_OK; int StartIndex = -1; for (int i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { - if (scumm_stricmp(Name, _dlgPendingBranches[i]) == 0) { + if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { StartIndex = i; break; } @@ -1587,16 +1587,16 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co _responsesBranch.RemoveAll(); } - if (DeleteName) delete [] Name; + if (DeleteName) delete [] name; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ClearBranchResponses(char *Name) { +HRESULT CAdGame::ClearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.GetSize(); i++) { - if (scumm_stricmp(Name, _responsesBranch[i]->_context) == 0) { + if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; _responsesBranch.RemoveAt(i); i--; @@ -1790,9 +1790,9 @@ bool CAdGame::IsItemTaken(char *ItemName) { } ////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::GetItemByName(const char *Name) { +CAdItem *CAdGame::GetItemByName(const char *name) { for (int i = 0; i < _items.GetSize(); i++) { - if (scumm_stricmp(_items[i]->_name, Name) == 0) return _items[i]; + if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; } return NULL; } @@ -2066,8 +2066,8 @@ HRESULT CAdGame::DisplayDebugInfo() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnScriptShutdown(CScScript *Script) { - if (_responseBox && _responseBox->_waitingScript == Script) +HRESULT CAdGame::OnScriptShutdown(CScScript *script) { + if (_responseBox && _responseBox->_waitingScript == script) _responseBox->_waitingScript = NULL; return S_OK; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 10f99b345a..c9fbbadc6f 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -44,7 +44,7 @@ class CAdResponseContext; class CAdResponseBox; class CAdGame : public CBGame { public: - virtual HRESULT OnScriptShutdown(CScScript *Script); + virtual HRESULT OnScriptShutdown(CScScript *script); virtual HRESULT OnMouseLeftDown(); virtual HRESULT OnMouseLeftUp(); @@ -70,7 +70,7 @@ public: bool _tempDisableSaveState; virtual HRESULT ResetContent(); HRESULT AddItem(CAdItem *Item); - CAdItem *GetItemByName(const char *Name); + CAdItem *GetItemByName(const char *name); CBArray _items; CAdObject *_inventoryOwner; bool IsItemTaken(char *ItemName); @@ -89,11 +89,11 @@ public: bool BranchResponseUsed(int ID); HRESULT AddBranchResponse(int ID); - HRESULT ClearBranchResponses(char *Name); + HRESULT ClearBranchResponses(char *name); HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); CAdSceneState *GetSceneState(const char *Filename, bool Saving); CBViewport *_sceneViewport; @@ -108,8 +108,8 @@ public: HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); char *_scheduledScene; bool _scheduledFadeIn; - void SetPrevSceneName(const char *Name); - void SetPrevSceneFilename(const char *Name); + void SetPrevSceneName(const char *name); + void SetPrevSceneFilename(const char *name); char *_prevSceneName; char *_prevSceneFilename; virtual HRESULT LoadGame(const char *Filename); @@ -148,12 +148,12 @@ public: virtual void PublishNatives(); - virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); bool ValidMouse(); }; diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index fd94d906e6..edc1fa65b9 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -49,15 +49,15 @@ CAdInventory::~CAdInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::InsertItem(const char *Name, const char *InsertAfter) { - if (Name == NULL) return E_FAIL; +HRESULT CAdInventory::InsertItem(const char *name, const char *InsertAfter) { + if (name == NULL) return E_FAIL; - CAdItem *item = ((CAdGame *)Game)->GetItemByName(Name); + CAdItem *item = ((CAdGame *)Game)->GetItemByName(name); if (item == NULL) return E_FAIL; int InsertIndex = -1; for (int i = 0; i < _takenItems.GetSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { _takenItems.RemoveAt(i); i--; continue; @@ -74,11 +74,11 @@ HRESULT CAdInventory::InsertItem(const char *Name, const char *InsertAfter) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(const char *Name) { - if (Name == NULL) return E_FAIL; +HRESULT CAdInventory::RemoveItem(const char *name) { + if (name == NULL) return E_FAIL; for (int i = 0; i < _takenItems.GetSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, Name) == 0) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; _takenItems.RemoveAt(i); return S_OK; diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h index 12aca999f7..f372fec6e9 100644 --- a/engines/wintermute/Ad/AdInventory.h +++ b/engines/wintermute/Ad/AdInventory.h @@ -38,9 +38,9 @@ class CAdItem; class CAdInventory : public CBObject { public: DECLARE_PERSISTENT(CAdInventory, CBObject) - HRESULT RemoveItem(const char *Name); + HRESULT RemoveItem(const char *name); HRESULT RemoveItem(CAdItem *Item); - HRESULT InsertItem(const char *Name, const char *InsertAfter = NULL); + HRESULT InsertItem(const char *name, const char *InsertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); CBArray _takenItems; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 11bfe39747..f9b92afba6 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -429,28 +429,28 @@ HRESULT CAdItem::display(int X, int Y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetHoverSprite") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "SetHoverSprite") == 0) { + stack->CorrectParams(1); bool SetCurrent = false; if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); delete _spriteHover; _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); + stack->PushBool(false); + script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); } else { _spriteHover = spr; if (SetCurrent) _currentSprite = _spriteHover; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -458,41 +458,41 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetHoverSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverSprite") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetHoverSprite") == 0) { + stack->CorrectParams(0); - if (!_spriteHover || !_spriteHover->_filename) Stack->PushNULL(); - else Stack->PushString(_spriteHover->_filename); + if (!_spriteHover || !_spriteHover->_filename) stack->PushNULL(); + else stack->PushString(_spriteHover->_filename); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetHoverSpriteObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverSpriteObject") == 0) { - Stack->CorrectParams(0); - if (!_spriteHover) Stack->PushNULL(); - else Stack->PushNative(_spriteHover, true); + else if (strcmp(name, "GetHoverSpriteObject") == 0) { + stack->CorrectParams(0); + if (!_spriteHover) stack->PushNULL(); + else stack->PushNative(_spriteHover, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetNormalCursor ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetNormalCursor") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "SetNormalCursor") == 0) { + stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); delete _cursorNormal; _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); + stack->PushBool(false); + script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); } else { _cursorNormal = spr; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -500,42 +500,42 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetNormalCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNormalCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetNormalCursor") == 0) { + stack->CorrectParams(0); - if (!_cursorNormal || !_cursorNormal->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorNormal->_filename); + if (!_cursorNormal || !_cursorNormal->_filename) stack->PushNULL(); + else stack->PushString(_cursorNormal->_filename); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetNormalCursorObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNormalCursorObject") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetNormalCursorObject") == 0) { + stack->CorrectParams(0); - if (!_cursorNormal) Stack->PushNULL(); - else Stack->PushNative(_cursorNormal, true); + if (!_cursorNormal) stack->PushNULL(); + else stack->PushNative(_cursorNormal, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetHoverCursor ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetHoverCursor") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "SetHoverCursor") == 0) { + stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); delete _cursorHover; _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(Filename))) { - Stack->PushBool(false); - Script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); + stack->PushBool(false); + script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); } else { _cursorHover = spr; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -543,37 +543,37 @@ HRESULT CAdItem::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // GetHoverCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetHoverCursor") == 0) { + stack->CorrectParams(0); - if (!_cursorHover || !_cursorHover->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorHover->_filename); + if (!_cursorHover || !_cursorHover->_filename) stack->PushNULL(); + else stack->PushString(_cursorHover->_filename); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetHoverCursorObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverCursorObject") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetHoverCursorObject") == 0) { + stack->CorrectParams(0); - if (!_cursorHover) Stack->PushNULL(); - else Stack->PushNative(_cursorHover, true); + if (!_cursorHover) stack->PushNULL(); + else stack->PushNative(_cursorHover, true); return S_OK; } - else return CAdTalkHolder::scCallMethod(Script, Stack, ThisStack, Name); + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::scGetProperty(const char *Name) { +CScValue *CAdItem::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("item"); return _scValue; } @@ -581,7 +581,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } @@ -589,7 +589,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // DisplayAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayAmount") == 0) { + else if (strcmp(name, "DisplayAmount") == 0) { _scValue->SetBool(_displayAmount); return _scValue; } @@ -597,7 +597,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Amount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Amount") == 0) { + else if (strcmp(name, "Amount") == 0) { _scValue->SetInt(_amount); return _scValue; } @@ -605,7 +605,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetX") == 0) { + else if (strcmp(name, "AmountOffsetX") == 0) { _scValue->SetInt(_amountOffsetX); return _scValue; } @@ -613,7 +613,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetY") == 0) { + else if (strcmp(name, "AmountOffsetY") == 0) { _scValue->SetInt(_amountOffsetY); return _scValue; } @@ -621,7 +621,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AmountAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountAlign") == 0) { + else if (strcmp(name, "AmountAlign") == 0) { _scValue->SetInt(_amountAlign); return _scValue; } @@ -629,7 +629,7 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AmountString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountString") == 0) { + else if (strcmp(name, "AmountString") == 0) { if (!_amountString) _scValue->SetNULL(); else _scValue->SetString(_amountString); return _scValue; @@ -638,21 +638,21 @@ CScValue *CAdItem::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CursorCombined ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorCombined") == 0) { + else if (strcmp(name, "CursorCombined") == 0) { _scValue->SetBool(_cursorCombined); return _scValue; } - else return CAdTalkHolder::scGetProperty(Name); + else return CAdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -660,7 +660,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // DisplayAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayAmount") == 0) { + else if (strcmp(name, "DisplayAmount") == 0) { _displayAmount = Value->GetBool(); return S_OK; } @@ -668,7 +668,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Amount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Amount") == 0) { + else if (strcmp(name, "Amount") == 0) { _amount = Value->GetInt(); return S_OK; } @@ -676,7 +676,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetX") == 0) { + else if (strcmp(name, "AmountOffsetX") == 0) { _amountOffsetX = Value->GetInt(); return S_OK; } @@ -684,7 +684,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountOffsetY") == 0) { + else if (strcmp(name, "AmountOffsetY") == 0) { _amountOffsetY = Value->GetInt(); return S_OK; } @@ -692,7 +692,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AmountAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountAlign") == 0) { + else if (strcmp(name, "AmountAlign") == 0) { _amountAlign = (TTextAlign)Value->GetInt(); return S_OK; } @@ -700,7 +700,7 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AmountString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AmountString") == 0) { + else if (strcmp(name, "AmountString") == 0) { if (Value->IsNULL()) { delete[] _amountString; _amountString = NULL; @@ -713,12 +713,12 @@ HRESULT CAdItem::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CursorCombined ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorCombined") == 0) { + else if (strcmp(name, "CursorCombined") == 0) { _cursorCombined = Value->GetBool(); return S_OK; } - else return CAdTalkHolder::scSetProperty(Name, Value); + else return CAdTalkHolder::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index 201e2450fb..c80cbee7d4 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -59,9 +59,9 @@ public: HRESULT loadBuffer(byte *Buffer, bool Complete = true); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 5f5ae728dd..7f1d09ef59 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -227,13 +227,13 @@ HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetNode") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + if (strcmp(name, "GetNode") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); int node = -1; if (val->_type == VAL_INT) node = val->GetInt(); @@ -247,17 +247,17 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } } - if (node < 0 || node >= _nodes.GetSize()) Stack->PushNULL(); + if (node < 0 || node >= _nodes.GetSize()) stack->PushNULL(); else { switch (_nodes[node]->_type) { case OBJECT_ENTITY: - Stack->PushNative(_nodes[node]->_entity, true); + stack->PushNative(_nodes[node]->_entity, true); break; case OBJECT_REGION: - Stack->PushNative(_nodes[node]->_region, true); + stack->PushNative(_nodes[node]->_region, true); break; default: - Stack->PushNULL(); + stack->PushNULL(); } } return S_OK; @@ -266,21 +266,21 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // AddRegion / AddEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddRegion") == 0 || strcmp(Name, "AddEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdSceneNode *Node = new CAdSceneNode(Game); - if (strcmp(Name, "AddRegion") == 0) { + if (strcmp(name, "AddRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->setRegion(Region); - Stack->PushNative(Region, true); + stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->setEntity(Entity); - Stack->PushNative(Entity, true); + stack->PushNative(Entity, true); } _nodes.Add(Node); return S_OK; @@ -289,22 +289,22 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // InsertRegion / InsertEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertRegion") == 0 || strcmp(Name, "InsertEntity") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { + stack->CorrectParams(2); + int Index = stack->Pop()->GetInt(); + CScValue *Val = stack->Pop(); CAdSceneNode *Node = new CAdSceneNode(Game); - if (strcmp(Name, "InsertRegion") == 0) { + if (strcmp(name, "InsertRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->setRegion(Region); - Stack->PushNative(Region, true); + stack->PushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->setEntity(Entity); - Stack->PushNative(Entity, true); + stack->PushNative(Entity, true); } if (Index < 0) Index = 0; if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); @@ -316,9 +316,9 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // DeleteNode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteNode") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "DeleteNode") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdSceneNode *ToDelete = NULL; if (Val->IsNative()) { @@ -336,7 +336,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } } if (ToDelete == NULL) { - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } @@ -348,22 +348,22 @@ HRESULT CAdLayer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi break; } } - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::scGetProperty(const char *Name) { +CScValue *CAdLayer::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("layer"); return _scValue; } @@ -371,7 +371,7 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumNodes") == 0) { + else if (strcmp(name, "NumNodes") == 0) { _scValue->SetInt(_nodes.GetSize()); return _scValue; } @@ -379,7 +379,7 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _scValue->SetInt(_width); return _scValue; } @@ -387,7 +387,7 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _scValue->SetInt(_height); return _scValue; } @@ -395,7 +395,7 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Main (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Main") == 0) { + else if (strcmp(name, "Main") == 0) { _scValue->SetBool(_main); return _scValue; } @@ -403,7 +403,7 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CloseUp ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CloseUp") == 0) { + else if (strcmp(name, "CloseUp") == 0) { _scValue->SetBool(_closeUp); return _scValue; } @@ -411,21 +411,21 @@ CScValue *CAdLayer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { _scValue->SetBool(_active); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -433,7 +433,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CloseUp ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CloseUp") == 0) { + else if (strcmp(name, "CloseUp") == 0) { _closeUp = Value->GetBool(); return S_OK; } @@ -441,7 +441,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _width = Value->GetInt(); if (_width < 0) _width = 0; return S_OK; @@ -450,7 +450,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _height = Value->GetInt(); if (_height < 0) _height = 0; return S_OK; @@ -459,7 +459,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { bool b = Value->GetBool(); if (b == false && _main) { Game->LOG(0, "Warning: cannot deactivate scene's main layer"); @@ -467,7 +467,7 @@ HRESULT CAdLayer::scSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 824e843828..059eac06dc 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -47,9 +47,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 0e6c718ae0..1eb831a1e0 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -68,10 +68,10 @@ CAdNodeState::~CAdNodeState() { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setName(const char *Name) { +void CAdNodeState::setName(const char *name) { delete[] _name; _name = NULL; - CBUtils::SetString(&_name, Name); + CBUtils::SetString(&_name, name); } diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index d180a3543e..9c75cf8092 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -36,7 +36,7 @@ class CAdEntity; class CAdNodeState : public CBBase { public: HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); - void setName(const char *Name); + void setName(const char *name); void setFilename(const char *Filename); void SetCursor(const char *Filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index e89e83905f..38c2ab94d7 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -187,17 +187,17 @@ HRESULT CAdObject::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "PlayAnim") == 0 || strcmp(Name, "PlayAnimAsync") == 0) { - Stack->CorrectParams(1); - if (FAILED(playAnim(Stack->Pop()->GetString()))) Stack->PushBool(false); + if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { + stack->CorrectParams(1); + if (FAILED(playAnim(stack->Pop()->GetString()))) stack->PushBool(false); else { - if (strcmp(Name, "PlayAnimAsync") != 0) Script->WaitFor(this); - Stack->PushBool(true); + if (strcmp(name, "PlayAnimAsync") != 0) script->WaitFor(this); + stack->PushBool(true); } return S_OK; } @@ -205,47 +205,47 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Reset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Reset") == 0) { + stack->CorrectParams(0); reset(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsTalking ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsTalking") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(_state == STATE_TALKING); + else if (strcmp(name, "IsTalking") == 0) { + stack->CorrectParams(0); + stack->PushBool(_state == STATE_TALKING); return S_OK; } ////////////////////////////////////////////////////////////////////////// // StopTalk / StopTalking ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopTalk") == 0 || strcmp(Name, "StopTalking") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { + stack->CorrectParams(0); if (_sentence) _sentence->finish(); if (_state == STATE_TALKING) { _state = _nextState; _nextState = STATE_READY; - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ForceTalkAnim ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ForceTalkAnim") == 0) { - Stack->CorrectParams(1); - const char *AnimName = Stack->Pop()->GetString(); + else if (strcmp(name, "ForceTalkAnim") == 0) { + stack->CorrectParams(1); + const char *AnimName = stack->Pop()->GetString(); delete[] _forcedTalkAnimName; _forcedTalkAnimName = new char[strlen(AnimName) + 1]; strcpy(_forcedTalkAnimName, AnimName); _forcedTalkAnimUsed = false; - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -253,18 +253,18 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Talk / TalkAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Talk") == 0 || strcmp(Name, "TalkAsync") == 0) { - Stack->CorrectParams(5); + else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { + stack->CorrectParams(5); - const char *Text = Stack->Pop()->GetString(); - CScValue *SoundVal = Stack->Pop(); - int Duration = Stack->Pop()->GetInt(); - CScValue *ValStances = Stack->Pop(); + const char *Text = stack->Pop()->GetString(); + CScValue *SoundVal = stack->Pop(); + int Duration = stack->Pop()->GetInt(); + CScValue *ValStances = stack->Pop(); const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); int Align; - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (val->IsNULL()) Align = TAL_CENTER; else Align = val->GetInt(); @@ -273,23 +273,23 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); talk(Text, Sound, Duration, Stances, (TTextAlign)Align); - if (strcmp(Name, "TalkAsync") != 0) Script->WaitForExclusive(this); + if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // StickToRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StickToRegion") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "StickToRegion") == 0) { + stack->CorrectParams(1); CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; bool RegFound = false; int i; - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); if (Val->IsNULL() || !Main) { _stickRegion = NULL; RegFound = true; @@ -316,106 +316,106 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } if (!RegFound) _stickRegion = NULL; - Stack->PushBool(RegFound); + stack->PushBool(RegFound); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (Val->IsNULL()) SetFont(NULL); else SetFont(Val->GetString()); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFont") == 0) { - Stack->CorrectParams(0); - if (_font && _font->_filename) Stack->PushString(_font->_filename); - else Stack->PushNULL(); + else if (strcmp(name, "GetFont") == 0) { + stack->CorrectParams(0); + if (_font && _font->_filename) stack->PushString(_font->_filename); + else stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // TakeItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TakeItem") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "TakeItem") == 0) { + stack->CorrectParams(2); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (!val->IsNULL()) { const char *ItemName = val->GetString(); - val = Stack->Pop(); + val = stack->Pop(); const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); - if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) Script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(ItemName, false); } - } else Script->RuntimeError("TakeItem: item name expected"); + } else script->RuntimeError("TakeItem: item name expected"); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DropItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DropItem") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "DropItem") == 0) { + stack->CorrectParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (!val->IsNULL()) { - if (FAILED(_inventory->RemoveItem(val->GetString()))) Script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); + if (FAILED(_inventory->RemoveItem(val->GetString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); else { // show associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(val->GetString(), true); } - } else Script->RuntimeError("DropItem: item name expected"); + } else script->RuntimeError("DropItem: item name expected"); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetItem") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetItem") == 0) { + stack->CorrectParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (val->_type == VAL_STRING) { CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); - if (item) Stack->PushNative(item, true); - else Stack->PushNULL(); + if (item) stack->PushNative(item, true); + else stack->PushNULL(); } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) - Stack->PushNULL(); + stack->PushNULL(); else - Stack->PushNative(_inventory->_takenItems[val->GetInt()], true); + stack->PushNative(_inventory->_takenItems[val->GetInt()], true); return S_OK; } @@ -423,43 +423,43 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // HasItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasItem") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "HasItem") == 0) { + stack->CorrectParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (!val->IsNULL()) { for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { if (val->GetNative() == _inventory->_takenItems[i]) { - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } } - } else Script->RuntimeError("HasItem: item name expected"); + } else script->RuntimeError("HasItem: item name expected"); - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // CreateParticleEmitter ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateParticleEmitter") == 0) { - Stack->CorrectParams(3); - bool FollowParent = Stack->Pop()->GetBool(); - int OffsetX = Stack->Pop()->GetInt(); - int OffsetY = Stack->Pop()->GetInt(); + else if (strcmp(name, "CreateParticleEmitter") == 0) { + stack->CorrectParams(3); + bool FollowParent = stack->Pop()->GetBool(); + int OffsetX = stack->Pop()->GetInt(); + int OffsetY = stack->Pop()->GetInt(); CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY); - if (Emitter) Stack->PushNative(_partEmitter, true); - else Stack->PushNULL(); + if (Emitter) stack->PushNative(_partEmitter, true); + else stack->PushNULL(); return S_OK; } @@ -467,13 +467,13 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // DeleteParticleEmitter ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteParticleEmitter") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DeleteParticleEmitter") == 0) { + stack->CorrectParams(0); if (_partEmitter) { Game->UnregisterObject(_partEmitter); _partEmitter = NULL; } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -481,20 +481,20 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // AddAttachment ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddAttachment") == 0) { - Stack->CorrectParams(4); - const char *Filename = Stack->Pop()->GetString(); - bool PreDisplay = Stack->Pop()->GetBool(true); - int OffsetX = Stack->Pop()->GetInt(); - int OffsetY = Stack->Pop()->GetInt(); + else if (strcmp(name, "AddAttachment") == 0) { + stack->CorrectParams(4); + const char *Filename = stack->Pop()->GetString(); + bool PreDisplay = stack->Pop()->GetBool(true); + int OffsetX = stack->Pop()->GetInt(); + int OffsetY = stack->Pop()->GetInt(); HRESULT res; CAdEntity *Ent = new CAdEntity(Game); if (FAILED(res = Ent->loadFile(Filename))) { delete Ent; Ent = NULL; - Script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); - Stack->PushBool(false); + script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); + stack->PushBool(false); } else { Game->RegisterObject(Ent); @@ -505,7 +505,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (PreDisplay) _attachmentsPre.Add(Ent); else _attachmentsPost.Add(Ent); - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; @@ -514,9 +514,9 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // RemoveAttachment ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveAttachment") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "RemoveAttachment") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); bool Found = false; if (Val->IsNative()) { CBScriptable *Obj = Val->GetNative(); @@ -555,7 +555,7 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } } } - Stack->PushBool(Found); + stack->PushBool(Found); return S_OK; } @@ -563,9 +563,9 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetAttachment ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetAttachment") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "GetAttachment") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdObject *Ret = NULL; if (Val->IsInt()) { @@ -597,24 +597,24 @@ HRESULT CAdObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th } } - if (Ret != NULL) Stack->PushNative(Ret, true); - else Stack->PushNULL(); + if (Ret != NULL) stack->PushNative(Ret, true); + else stack->PushNULL(); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::scGetProperty(const char *Name) { +CScValue *CAdObject::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("object"); return _scValue; } @@ -622,7 +622,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { _scValue->SetBool(_active); return _scValue; } @@ -630,7 +630,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // IgnoreItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IgnoreItems") == 0) { + else if (strcmp(name, "IgnoreItems") == 0) { _scValue->SetBool(_ignoreItems); return _scValue; } @@ -638,7 +638,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SceneIndependent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SceneIndependent") == 0) { + else if (strcmp(name, "SceneIndependent") == 0) { _scValue->SetBool(_sceneIndependent); return _scValue; } @@ -646,7 +646,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesWidth") == 0) { + else if (strcmp(name, "SubtitlesWidth") == 0) { _scValue->SetInt(_subtitlesWidth); return _scValue; } @@ -654,7 +654,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + else if (strcmp(name, "SubtitlesPosRelative") == 0) { _scValue->SetBool(_subtitlesModRelative); return _scValue; } @@ -662,7 +662,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosX") == 0) { + else if (strcmp(name, "SubtitlesPosX") == 0) { _scValue->SetInt(_subtitlesModX); return _scValue; } @@ -670,7 +670,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosY") == 0) { + else if (strcmp(name, "SubtitlesPosY") == 0) { _scValue->SetInt(_subtitlesModY); return _scValue; } @@ -678,7 +678,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { _scValue->SetBool(_subtitlesModXCenter); return _scValue; } @@ -686,7 +686,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumItems (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumItems") == 0) { + else if (strcmp(name, "NumItems") == 0) { _scValue->SetInt(getInventory()->_takenItems.GetSize()); return _scValue; } @@ -694,7 +694,7 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ParticleEmitter (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParticleEmitter") == 0) { + else if (strcmp(name, "ParticleEmitter") == 0) { if (_partEmitter) _scValue->SetNative(_partEmitter, true); else _scValue->SetNULL(); @@ -704,23 +704,23 @@ CScValue *CAdObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumAttachments") == 0) { + else if (strcmp(name, "NumAttachments") == 0) { _scValue->SetInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Active") == 0) { + if (strcmp(name, "Active") == 0) { _active = Value->GetBool(); return S_OK; } @@ -728,7 +728,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // IgnoreItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IgnoreItems") == 0) { + else if (strcmp(name, "IgnoreItems") == 0) { _ignoreItems = Value->GetBool(); return S_OK; } @@ -736,7 +736,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SceneIndependent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SceneIndependent") == 0) { + else if (strcmp(name, "SceneIndependent") == 0) { _sceneIndependent = Value->GetBool(); return S_OK; } @@ -744,7 +744,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesWidth") == 0) { + else if (strcmp(name, "SubtitlesWidth") == 0) { _subtitlesWidth = Value->GetInt(); return S_OK; } @@ -752,7 +752,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosRelative") == 0) { + else if (strcmp(name, "SubtitlesPosRelative") == 0) { _subtitlesModRelative = Value->GetBool(); return S_OK; } @@ -760,7 +760,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosX") == 0) { + else if (strcmp(name, "SubtitlesPosX") == 0) { _subtitlesModX = Value->GetInt(); return S_OK; } @@ -768,7 +768,7 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosY") == 0) { + else if (strcmp(name, "SubtitlesPosY") == 0) { _subtitlesModY = Value->GetInt(); return S_OK; } @@ -776,12 +776,12 @@ HRESULT CAdObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesPosXCenter") == 0) { + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { _subtitlesModXCenter = Value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 3e4fe2ea6d..44a7fb8e37 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -219,32 +219,32 @@ HRESULT CAdRegion::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SkipTo")==0) { - Stack->CorrectParams(2); - _posX = Stack->Pop()->GetInt(); - _posY = Stack->Pop()->GetInt(); - Stack->PushNULL(); + if (strcmp(name, "SkipTo")==0) { + stack->CorrectParams(2); + _posX = stack->Pop()->GetInt(); + _posY = stack->Pop()->GetInt(); + stack->PushNULL(); return S_OK; } - else*/ return CBRegion::scCallMethod(Script, Stack, ThisStack, Name); + else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::scGetProperty(const char *Name) { +CScValue *CAdRegion::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("ad region"); return _scValue; } @@ -252,7 +252,7 @@ CScValue *CAdRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } @@ -260,7 +260,7 @@ CScValue *CAdRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Blocked ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Blocked") == 0) { + else if (strcmp(name, "Blocked") == 0) { _scValue->SetBool(_blocked); return _scValue; } @@ -268,7 +268,7 @@ CScValue *CAdRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { + else if (strcmp(name, "Decoration") == 0) { _scValue->SetBool(_decoration); return _scValue; } @@ -276,7 +276,7 @@ CScValue *CAdRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { + else if (strcmp(name, "Scale") == 0) { _scValue->SetFloat(_zoom); return _scValue; } @@ -284,21 +284,21 @@ CScValue *CAdRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { + else if (strcmp(name, "AlphaColor") == 0) { _scValue->SetInt((int)_alpha); return _scValue; } - else return CBRegion::scGetProperty(Name); + else return CBRegion::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -306,7 +306,7 @@ HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Blocked ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Blocked") == 0) { + else if (strcmp(name, "Blocked") == 0) { _blocked = Value->GetBool(); return S_OK; } @@ -314,7 +314,7 @@ HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { + else if (strcmp(name, "Decoration") == 0) { _decoration = Value->GetBool(); return S_OK; } @@ -322,7 +322,7 @@ HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { + else if (strcmp(name, "Scale") == 0) { _zoom = Value->GetFloat(); return S_OK; } @@ -330,12 +330,12 @@ HRESULT CAdRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { + else if (strcmp(name, "AlphaColor") == 0) { _alpha = (uint32)Value->GetInt(); return S_OK; } - else return CBRegion::scSetProperty(Name, Value); + else return CBRegion::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 86bd577d3f..237936f578 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -47,9 +47,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 022924da84..1f86fa77fb 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1248,20 +1248,20 @@ void CAdScene::skipTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LoadActor") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "LoadActor") == 0) { + stack->CorrectParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(Stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) { addObject(act); - Stack->PushNative(act, true); + stack->PushNative(act, true); } else { delete act; act = NULL; - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; } @@ -1269,16 +1269,16 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // LoadEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadEntity") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "LoadEntity") == 0) { + stack->CorrectParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(Stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) { addObject(ent); - Stack->PushNative(ent, true); + stack->PushNative(ent, true); } else { delete ent; ent = NULL; - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; } @@ -1286,85 +1286,85 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // CreateEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEntity") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateEntity") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdEntity *Ent = new CAdEntity(Game); addObject(Ent); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - Stack->PushNative(Ent, true); + stack->PushNative(Ent, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0 || strcmp(Name, "UnloadActor") == 0 || strcmp(Name, "UnloadEntity") == 0 || strcmp(Name, "UnloadActor3D") == 0 || strcmp(Name, "DeleteEntity") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); CAdObject *obj = (CAdObject *)val->GetNative(); removeObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SkipTo ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SkipTo") == 0) { - Stack->CorrectParams(2); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); + else if (strcmp(name, "SkipTo") == 0) { + stack->CorrectParams(2); + CScValue *val1 = stack->Pop(); + CScValue *val2 = stack->Pop(); if (val1->IsNative()) { skipToObject((CBObject *)val1->GetNative()); } else { skipTo(val1->GetInt(), val2->GetInt()); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScrollTo / ScrollToAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollTo") == 0 || strcmp(Name, "ScrollToAsync") == 0) { - Stack->CorrectParams(2); - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); + else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { + stack->CorrectParams(2); + CScValue *val1 = stack->Pop(); + CScValue *val2 = stack->Pop(); if (val1->IsNative()) { scrollToObject((CBObject *)val1->GetNative()); } else { scrollTo(val1->GetInt(), val2->GetInt()); } - if (strcmp(Name, "ScrollTo") == 0) Script->WaitForExclusive(this); - Stack->PushNULL(); + if (strcmp(name, "ScrollTo") == 0) script->WaitForExclusive(this); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetLayer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetLayer") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "GetLayer") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); if (val->IsInt()) { int layer = val->GetInt(); - if (layer < 0 || layer >= _layers.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_layers[layer], true); + if (layer < 0 || layer >= _layers.GetSize()) stack->PushNULL(); + else stack->PushNative(_layers[layer], true); } else { const char *LayerName = val->GetString(); bool LayerFound = false; for (int i = 0; i < _layers.GetSize(); i++) { if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { - Stack->PushNative(_layers[i], true); + stack->PushNative(_layers[i], true); LayerFound = true; break; } } - if (!LayerFound) Stack->PushNULL(); + if (!LayerFound) stack->PushNULL(); } return S_OK; } @@ -1372,24 +1372,24 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetWaypointGroup ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaypointGroup") == 0) { - Stack->CorrectParams(1); - int group = Stack->Pop()->GetInt(); - if (group < 0 || group >= _waypointGroups.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_waypointGroups[group], true); + else if (strcmp(name, "GetWaypointGroup") == 0) { + stack->CorrectParams(1); + int group = stack->Pop()->GetInt(); + if (group < 0 || group >= _waypointGroups.GetSize()) stack->PushNULL(); + else stack->PushNative(_waypointGroups[group], true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetNode") == 0) { - Stack->CorrectParams(1); - const char *nodeName = Stack->Pop()->GetString(); + else if (strcmp(name, "GetNode") == 0) { + stack->CorrectParams(1); + const char *nodeName = stack->Pop()->GetString(); CBObject *node = getNodeByName(nodeName); - if (node) Stack->PushNative((CBScriptable *)node, true); - else Stack->PushNULL(); + if (node) stack->PushNative((CBScriptable *)node, true); + else stack->PushNULL(); return S_OK; } @@ -1397,9 +1397,9 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetFreeNode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFreeNode") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "GetFreeNode") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdObject *Ret = NULL; if (Val->IsInt()) { @@ -1414,8 +1414,8 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } } } - if (Ret) Stack->PushNative(Ret, true); - else Stack->PushNULL(); + if (Ret) stack->PushNative(Ret, true); + else stack->PushNULL(); return S_OK; } @@ -1423,11 +1423,11 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetRegionAt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRegionAt") == 0) { - Stack->CorrectParams(3); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "GetRegionAt") == 0) { + stack->CorrectParams(3); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + CScValue *Val = stack->Pop(); bool IncludeDecors = false; if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); @@ -1438,142 +1438,142 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { if (Node->_region->_decoration && !IncludeDecors) continue; - Stack->PushNative(Node->_region, true); + stack->PushNative(Node->_region, true); return S_OK; } } } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsBlockedAt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsBlockedAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "IsBlockedAt") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); - Stack->PushBool(isBlockedAt(X, Y)); + stack->PushBool(isBlockedAt(X, Y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsWalkableAt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsWalkableAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "IsWalkableAt") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); - Stack->PushBool(isWalkableAt(X, Y)); + stack->PushBool(isWalkableAt(X, Y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetScaleAt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetScaleAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "GetScaleAt") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); - Stack->PushFloat(getZoomAt(X, Y)); + stack->PushFloat(getZoomAt(X, Y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetRotationAt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRotationAt") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "GetRotationAt") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); - Stack->PushFloat(getRotationAt(X, Y)); + stack->PushFloat(getRotationAt(X, Y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsScrolling ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsScrolling") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "IsScrolling") == 0) { + stack->CorrectParams(0); bool Ret = false; if (_autoScroll) { if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; } - Stack->PushBool(Ret); + stack->PushBool(Ret); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOut / FadeOutAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { + stack->CorrectParams(5); + uint32 Duration = stack->Pop()->GetInt(500); + byte Red = stack->Pop()->GetInt(0); + byte Green = stack->Pop()->GetInt(0); + byte Blue = stack->Pop()->GetInt(0); + byte Alpha = stack->Pop()->GetInt(0xFF); _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeOutAsync") != 0) Script->WaitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeIn / FadeInAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { + stack->CorrectParams(5); + uint32 Duration = stack->Pop()->GetInt(500); + byte Red = stack->Pop()->GetInt(0); + byte Green = stack->Pop()->GetInt(0); + byte Blue = stack->Pop()->GetInt(0); + byte Alpha = stack->Pop()->GetInt(0xFF); _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); - if (strcmp(Name, "FadeInAsync") != 0) Script->WaitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetFadeColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFadeColor") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_fader->getCurrentColor()); + else if (strcmp(name, "GetFadeColor") == 0) { + stack->CorrectParams(0); + stack->PushInt(_fader->getCurrentColor()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsPointInViewport ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsPointInViewport") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - Stack->PushBool(pointInViewport(X, Y)); + else if (strcmp(name, "IsPointInViewport") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + stack->PushBool(pointInViewport(X, Y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetViewport ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetViewport") == 0) { - Stack->CorrectParams(4); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - int Width = Stack->Pop()->GetInt(); - int Height = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetViewport") == 0) { + stack->CorrectParams(4); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + int Width = stack->Pop()->GetInt(); + int Height = stack->Pop()->GetInt(); if (Width <= 0) Width = Game->_renderer->_width; if (Height <= 0) Height = Game->_renderer->_height; @@ -1581,7 +1581,7 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(X, Y, X + Width, Y + Height); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -1589,9 +1589,9 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // AddLayer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddLayer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "AddLayer") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->setName(Val->GetString()); @@ -1602,17 +1602,17 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi _layers.Add(Layer); Game->RegisterObject(Layer); - Stack->PushNative(Layer, true); + stack->PushNative(Layer, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // InsertLayer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertLayer") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "InsertLayer") == 0) { + stack->CorrectParams(2); + int Index = stack->Pop()->GetInt(); + CScValue *Val = stack->Pop(); CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->setName(Val->GetString()); @@ -1626,16 +1626,16 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi Game->RegisterObject(Layer); - Stack->PushNative(Layer, true); + stack->PushNative(Layer, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteLayer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteLayer") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "DeleteLayer") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CAdLayer *ToDelete = NULL; if (Val->IsNative()) { @@ -1653,13 +1653,13 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } } if (ToDelete == NULL) { - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } if (ToDelete->_main) { - Script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); - Stack->PushBool(false); + script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); + stack->PushBool(false); return S_OK; } @@ -1670,22 +1670,22 @@ HRESULT CAdScene::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi break; } } - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::scGetProperty(const char *Name) { +CScValue *CAdScene::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("scene"); return _scValue; } @@ -1693,7 +1693,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumLayers") == 0) { + else if (strcmp(name, "NumLayers") == 0) { _scValue->SetInt(_layers.GetSize()); return _scValue; } @@ -1701,7 +1701,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumWaypointGroups") == 0) { + else if (strcmp(name, "NumWaypointGroups") == 0) { _scValue->SetInt(_waypointGroups.GetSize()); return _scValue; } @@ -1709,7 +1709,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MainLayer (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainLayer") == 0) { + else if (strcmp(name, "MainLayer") == 0) { if (_mainLayer) _scValue->SetNative(_mainLayer, true); else _scValue->SetNULL(); @@ -1719,7 +1719,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumFreeNodes") == 0) { + else if (strcmp(name, "NumFreeNodes") == 0) { _scValue->SetInt(_objects.GetSize()); return _scValue; } @@ -1727,7 +1727,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MouseX (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { + else if (strcmp(name, "MouseX") == 0) { int ViewportX; getViewportOffset(&ViewportX); @@ -1738,7 +1738,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MouseY (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { + else if (strcmp(name, "MouseY") == 0) { int ViewportY; getViewportOffset(NULL, &ViewportY); @@ -1749,7 +1749,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AutoScroll ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoScroll") == 0) { + else if (strcmp(name, "AutoScroll") == 0) { _scValue->SetBool(_autoScroll); return _scValue; } @@ -1757,7 +1757,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PersistentState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentState") == 0) { + else if (strcmp(name, "PersistentState") == 0) { _scValue->SetBool(_persistentState); return _scValue; } @@ -1765,7 +1765,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentStateSprites") == 0) { + else if (strcmp(name, "PersistentStateSprites") == 0) { _scValue->SetBool(_persistentStateSprites); return _scValue; } @@ -1773,7 +1773,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsX") == 0) { + else if (strcmp(name, "ScrollPixelsX") == 0) { _scValue->SetInt(_scrollPixelsH); return _scValue; } @@ -1781,7 +1781,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsY") == 0) { + else if (strcmp(name, "ScrollPixelsY") == 0) { _scValue->SetInt(_scrollPixelsV); return _scValue; } @@ -1790,7 +1790,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedX") == 0) { + else if (strcmp(name, "ScrollSpeedX") == 0) { _scValue->SetInt(_scrollTimeH); return _scValue; } @@ -1798,7 +1798,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedY") == 0) { + else if (strcmp(name, "ScrollSpeedY") == 0) { _scValue->SetInt(_scrollTimeV); return _scValue; } @@ -1806,7 +1806,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // OffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetX") == 0) { + else if (strcmp(name, "OffsetX") == 0) { _scValue->SetInt(_offsetLeft); return _scValue; } @@ -1814,7 +1814,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // OffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetY") == 0) { + else if (strcmp(name, "OffsetY") == 0) { _scValue->SetInt(_offsetTop); return _scValue; } @@ -1822,7 +1822,7 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Width (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { if (_mainLayer) _scValue->SetInt(_mainLayer->_width); else _scValue->SetInt(0); return _scValue; @@ -1831,22 +1831,22 @@ CScValue *CAdScene::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { if (_mainLayer) _scValue->SetInt(_mainLayer->_height); else _scValue->SetInt(0); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -1854,7 +1854,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AutoScroll ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoScroll") == 0) { + else if (strcmp(name, "AutoScroll") == 0) { _autoScroll = Value->GetBool(); return S_OK; } @@ -1862,7 +1862,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // PersistentState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentState") == 0) { + else if (strcmp(name, "PersistentState") == 0) { _persistentState = Value->GetBool(); return S_OK; } @@ -1870,7 +1870,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PersistentStateSprites") == 0) { + else if (strcmp(name, "PersistentStateSprites") == 0) { _persistentStateSprites = Value->GetBool(); return S_OK; } @@ -1878,7 +1878,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsX") == 0) { + else if (strcmp(name, "ScrollPixelsX") == 0) { _scrollPixelsH = Value->GetInt(); return S_OK; } @@ -1886,7 +1886,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollPixelsY") == 0) { + else if (strcmp(name, "ScrollPixelsY") == 0) { _scrollPixelsV = Value->GetInt(); return S_OK; } @@ -1894,7 +1894,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedX") == 0) { + else if (strcmp(name, "ScrollSpeedX") == 0) { _scrollTimeH = Value->GetInt(); return S_OK; } @@ -1902,7 +1902,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScrollSpeedY") == 0) { + else if (strcmp(name, "ScrollSpeedY") == 0) { _scrollTimeV = Value->GetInt(); return S_OK; } @@ -1910,7 +1910,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // OffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetX") == 0) { + else if (strcmp(name, "OffsetX") == 0) { _offsetLeft = Value->GetInt(); int ViewportWidth, ViewportHeight; @@ -1926,7 +1926,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // OffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OffsetY") == 0) { + else if (strcmp(name, "OffsetY") == 0) { _offsetTop = Value->GetInt(); int ViewportWidth, ViewportHeight; @@ -1939,7 +1939,7 @@ HRESULT CAdScene::scSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } @@ -2428,7 +2428,7 @@ void CAdScene::setOffset(int OffsetLeft, int OffsetTop) { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNodeByName(const char *Name) { +CBObject *CAdScene::getNodeByName(const char *name) { int i; CBObject *ret = NULL; @@ -2437,8 +2437,8 @@ CBObject *CAdScene::getNodeByName(const char *Name) { CAdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.GetSize(); j++) { CAdSceneNode *node = layer->_nodes[j]; - if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(Name, node->_entity->_name)) || - (node->_type == OBJECT_REGION && !scumm_stricmp(Name, node->_region->_name))) { + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || + (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { switch (node->_type) { case OBJECT_ENTITY: ret = node->_entity; @@ -2456,14 +2456,14 @@ CBObject *CAdScene::getNodeByName(const char *Name) { // free entities for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(Name, _objects[i]->_name)) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { return _objects[i]; } } // waypoint groups for (i = 0; i < _waypointGroups.GetSize(); i++) { - if (!scumm_stricmp(Name, _waypointGroups[i]->_name)) { + if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { return _waypointGroups[i]; } } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index a9659c3849..6c6f16eea0 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -62,7 +62,7 @@ public: HRESULT saveState(); bool _persistentState; bool _persistentStateSprites; - CBObject *getNodeByName(const char *Name); + CBObject *getNodeByName(const char *name); void setOffset(int OffsetLeft, int OffsetTop); bool pointInViewport(int X, int Y); int getOffsetTop(); @@ -156,9 +156,9 @@ public: int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 8f7137b9e8..1e60c33b6a 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -200,13 +200,13 @@ HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::scGetProperty(const char *Name) { +CScValue *CAdWaypointGroup::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("waypoint-group"); return _scValue; } @@ -214,26 +214,26 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { _scValue->SetBool(_active); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Active") == 0) { + if (strcmp(name, "Active") == 0) { _active = Value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index e5203cc61d..fda11b88c4 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -49,8 +49,8 @@ public: virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index d55cb189b7..ab73493e69 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -71,23 +71,23 @@ HRESULT CBDebugger::OnLog(unsigned int ErrorCode, const char *Text) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptInit(CScScript *Script) { +HRESULT CBDebugger::OnScriptInit(CScScript *script) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { +HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name) { +HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptShutdown(CScScript *Script) { +HRESULT CBDebugger::OnScriptShutdown(CScScript *script) { return S_OK; } @@ -108,7 +108,7 @@ HRESULT CBDebugger::OnScriptShutdownScope(CScScript *Script, CScValue *Scope) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName) { +HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName) { return S_OK; } @@ -118,7 +118,7 @@ HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *Value) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *Script) { +HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *script) { return S_OK; } diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index 52bfc51c55..de9c8f6b7c 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -51,18 +51,18 @@ public: HRESULT OnGameShutdown(); HRESULT OnGameTick(); HRESULT OnLog(unsigned int ErrorCode, const char *Text); - HRESULT OnScriptInit(CScScript *Script); - HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); - HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *Name); + HRESULT OnScriptInit(CScScript *script); + HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); + HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); - HRESULT OnScriptShutdown(CScScript *Script); + HRESULT OnScriptShutdown(CScScript *script); HRESULT OnScriptChangeLine(CScScript *Script, int Line); HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); - HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *Script, CScValue *Scope, CScValue *Var, const char *VariableName); + HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName); HRESULT OnVariableChangeValue(CScValue *Var, CScValue *Value); - HRESULT OnScriptHitBreakpoint(CScScript *Script); + HRESULT OnScriptHitBreakpoint(CScScript *script); // IWmeDebugServer interface virtual bool AttachClient(IWmeDebugClient *Client); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index b346646841..9e98412021 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -448,9 +448,9 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea pkg->_boundToExe = BoundToExe; // read package info - byte NameLength = package->readByte(); - pkg->_name = new char[NameLength]; - package->read(pkg->_name, NameLength); + byte nameLength = package->readByte(); + pkg->_name = new char[nameLength]; + package->read(pkg->_name, nameLength); pkg->_cD = package->readByte(); pkg->_priority = hdr.Priority; @@ -462,26 +462,26 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea uint32 NumFiles = package->readUint32LE(); for (uint32 j = 0; j < NumFiles; j++) { - char *Name; + char *name; uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - NameLength = package->readByte(); - Name = new char[NameLength]; - package->read(Name, NameLength); + nameLength = package->readByte(); + name = new char[nameLength]; + package->read(name, nameLength); // v2 - xor name if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; } } // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory - Name[NameLength - 1] = '\0'; + name[nameLength - 1] = '\0'; - CBPlatform::strupr(Name); + CBPlatform::strupr(name); Offset = package->readUint32LE(); Offset += AbsoluteOffset; @@ -493,7 +493,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea TimeDate1 = package->readUint32LE(); TimeDate2 = package->readUint32LE(); } - _filesIter = _files.find(Name); + _filesIter = _files.find(name); if (_filesIter == _files.end()) { CBFileEntry *file = new CBFileEntry(Game); file->_package = pkg; @@ -502,7 +502,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea file->_compressedLength = CompLength; file->_flags = Flags; - _files[Name] = file; + _files[name] = file; } else { // current package has lower CD number or higher priority, than the registered if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { @@ -513,7 +513,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea _filesIter->_value->_flags = Flags; } } - delete [] Name; + delete [] name; } } @@ -522,12 +522,12 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool SearchSignature) { +HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool SearchSignature) { // TODO error("Implement RegisterPackage, this is the old one"); #if 0 char Filename[MAX_PATH]; - sprintf(Filename, "%s%s", Path, Name); + sprintf(Filename, "%s%s", Path, name); FILE *f = fopen(Filename, "rb"); if (!f) { @@ -577,10 +577,10 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool pkg->_boundToExe = BoundToExe; // read package info - byte NameLength; - fread(&NameLength, sizeof(byte), 1, f); - pkg->_name = new char[NameLength]; - fread(pkg->_name, NameLength, 1, f); + byte nameLength; + fread(&nameLength, sizeof(byte), 1, f); + pkg->_name = new char[nameLength]; + fread(pkg->_name, nameLength, 1, f); fread(&pkg->_cD, sizeof(byte), 1, f); pkg->_priority = hdr.Priority; @@ -593,26 +593,26 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool fread(&NumFiles, sizeof(uint32), 1, f); for (int j = 0; j < NumFiles; j++) { - char *Name; + char *name; uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - fread(&NameLength, sizeof(byte), 1, f); - Name = new char[NameLength]; - fread(Name, NameLength, 1, f); + fread(&nameLength, sizeof(byte), 1, f); + name = new char[nameLength]; + fread(name, nameLength, 1, f); // v2 - xor name if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < NameLength; k++) { - ((byte *)Name)[k] ^= 'D'; + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; } } // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory - Name[NameLength - 1] = '\0'; + name[nameLength - 1] = '\0'; - CBPlatform::strupr(Name); + CBPlatform::strupr(name); fread(&Offset, sizeof(uint32), 1, f); Offset += AbsoluteOffset; @@ -624,7 +624,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool fread(&TimeDate1, sizeof(uint32), 1, f); fread(&TimeDate2, sizeof(uint32), 1, f); } - _filesIter = _files.find(Name); + _filesIter = _files.find(name); if (_filesIter == _files.end()) { CBFileEntry *file = new CBFileEntry(Game); file->_package = pkg; @@ -633,7 +633,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool file->_compressedLength = CompLength; file->_flags = Flags; - _files[Name] = file; + _files[name] = file; } else { // current package has lower CD number or higher priority, than the registered if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { @@ -644,7 +644,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *Name, bool _filesIter->_value->_flags = Flags; } } - delete [] Name; + delete [] name; } } @@ -666,7 +666,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &Name) { +Common::File *CBFileManager::openPackage(const Common::String &name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -675,40 +675,40 @@ Common::File *CBFileManager::openPackage(const Common::String &Name) { char Filename[MAX_PATH]; for (int i = 0; i < _packagePaths.GetSize(); i++) { - sprintf(Filename, "%s%s.%s", _packagePaths[i], Name.c_str(), PACKAGE_EXTENSION); + sprintf(Filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(Filename); if (ret->isOpen()) { return ret; } } - sprintf(Filename, "%s.%s", Name.c_str(), PACKAGE_EXTENSION); + sprintf(Filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(Filename); if (ret->isOpen()) { return ret; } - warning("CBFileManager::OpenPackage - Couldn't load file %s", Name.c_str()); + warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &Name) { +Common::File *CBFileManager::openSingleFile(const Common::String &name) { restoreCurrentDir(); Common::File *ret = NULL; char Filename[MAX_PATH]; for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Filename, "%s%s", _singlePaths[i], Name.c_str()); + sprintf(Filename, "%s%s", _singlePaths[i], name.c_str()); ret->open(Filename); if (ret->isOpen()) return ret; } // didn't find in search paths, try to open directly - ret->open(Name); + ret->open(name); if (ret->isOpen()) { return ret; } else { diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 5dd5627e58..75cf1e02c2 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -401,49 +401,49 @@ HRESULT CBFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetSound ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetSound") == 0) { - Stack->CorrectParams(0); + if (strcmp(name, "GetSound") == 0) { + stack->CorrectParams(0); - if (_sound && _sound->_soundFilename) Stack->PushString(_sound->_soundFilename); - else Stack->PushNULL(); + if (_sound && _sound->_soundFilename) stack->PushString(_sound->_soundFilename); + else stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSound ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSound") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + if (strcmp(name, "SetSound") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); delete _sound; _sound = NULL; if (!Val->IsNULL()) { _sound = new CBSound(Game); if (!_sound || FAILED(_sound->setSound(Val->GetString(), SOUND_SFX, false))) { - Stack->PushBool(false); + stack->PushBool(false); delete _sound; _sound = NULL; - } else Stack->PushBool(true); - } else Stack->PushBool(true); + } else stack->PushBool(true); + } else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSubframe ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetSubframe") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); + if (strcmp(name, "GetSubframe") == 0) { + stack->CorrectParams(1); + int Index = stack->Pop()->GetInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { - Script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushNative(_subframes[Index], true); + script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); + stack->PushNULL(); + } else stack->PushNative(_subframes[Index], true); return S_OK; } @@ -451,13 +451,13 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // DeleteSubframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteSubframe") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { - Script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); + script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); } } else { CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); @@ -469,16 +469,16 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } } } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AddSubframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSubframe") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "AddSubframe") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -489,19 +489,19 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } _subframes.Add(Sub); - Stack->PushNative(Sub, true); + stack->PushNative(Sub, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // InsertSubframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertSubframe") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); + else if (strcmp(name, "InsertSubframe") == 0) { + stack->CorrectParams(2); + int Index = stack->Pop()->GetInt(); if (Index < 0) Index = 0; - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -513,46 +513,46 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (Index >= _subframes.GetSize()) _subframes.Add(Sub); else _subframes.InsertAt(Index, Sub); - Stack->PushNative(Sub, true); + stack->PushNative(Sub, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSubframe") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); + else if (strcmp(name, "GetSubframe") == 0) { + stack->CorrectParams(1); + int Index = stack->Pop()->GetInt(-1); if (Index < 0 || Index >= _applyEvent.GetSize()) { - Script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushString(_applyEvent[Index]); + script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); + stack->PushNULL(); + } else stack->PushString(_applyEvent[Index]); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AddEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddEvent") == 0) { - Stack->CorrectParams(1); - const char *Event = Stack->Pop()->GetString(); + else if (strcmp(name, "AddEvent") == 0) { + stack->CorrectParams(1); + const char *Event = stack->Pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } } _applyEvent.Add(Event); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteEvent") == 0) { - Stack->CorrectParams(1); - const char *Event = Stack->Pop()->GetString(); + else if (strcmp(name, "DeleteEvent") == 0) { + stack->CorrectParams(1); + const char *Event = stack->Pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { delete [] _applyEvent[i]; @@ -560,27 +560,27 @@ HRESULT CBFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This break; } } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scCallMethod(Script, Stack, ThisStack, Name); - else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); + if (_subframes.GetSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); } } ////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *Name) { +CScValue *CBFrame::scGetProperty(const char *name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("frame"); return _scValue; } @@ -588,7 +588,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Delay") == 0) { + else if (strcmp(name, "Delay") == 0) { _scValue->SetInt(_delay); return _scValue; } @@ -596,7 +596,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Keyframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyframe") == 0) { + else if (strcmp(name, "Keyframe") == 0) { _scValue->SetBool(_keyframe); return _scValue; } @@ -604,7 +604,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // KillSounds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KillSounds") == 0) { + else if (strcmp(name, "KillSounds") == 0) { _scValue->SetBool(_killSound); return _scValue; } @@ -612,7 +612,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MoveX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveX") == 0) { + else if (strcmp(name, "MoveX") == 0) { _scValue->SetInt(_moveX); return _scValue; } @@ -620,7 +620,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MoveY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveY") == 0) { + else if (strcmp(name, "MoveY") == 0) { _scValue->SetInt(_moveY); return _scValue; } @@ -628,7 +628,7 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumSubframes") == 0) { + else if (strcmp(name, "NumSubframes") == 0) { _scValue->SetInt(_subframes.GetSize()); return _scValue; } @@ -636,25 +636,25 @@ CScValue *CBFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumEvents") == 0) { + else if (strcmp(name, "NumEvents") == 0) { _scValue->SetInt(_applyEvent.GetSize()); return _scValue; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scGetProperty(Name); - else return CBScriptable::scGetProperty(Name); + if (_subframes.GetSize() == 1) return _subframes[0]->scGetProperty(name); + else return CBScriptable::scGetProperty(name); } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Delay") == 0) { + if (strcmp(name, "Delay") == 0) { _delay = MAX(0, Value->GetInt()); return S_OK; } @@ -662,7 +662,7 @@ HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Keyframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyframe") == 0) { + else if (strcmp(name, "Keyframe") == 0) { _keyframe = Value->GetBool(); return S_OK; } @@ -670,7 +670,7 @@ HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // KillSounds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KillSounds") == 0) { + else if (strcmp(name, "KillSounds") == 0) { _killSound = Value->GetBool(); return S_OK; } @@ -678,7 +678,7 @@ HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MoveX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveX") == 0) { + else if (strcmp(name, "MoveX") == 0) { _moveX = Value->GetInt(); return S_OK; } @@ -686,15 +686,15 @@ HRESULT CBFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MoveY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveY") == 0) { + else if (strcmp(name, "MoveY") == 0) { _moveY = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(Name, Value); - else return CBScriptable::scSetProperty(Name, Value); + if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(name, Value); + else return CBScriptable::scSetProperty(name, Value); } } diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index df33303d6d..3c0efae6db 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -61,9 +61,9 @@ public: CBArray _applyEvent; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 1321d31c67..30d67a8fe9 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -978,22 +978,22 @@ HRESULT CBGame::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LOG") == 0) { - Stack->CorrectParams(1); - LOG(0, Stack->Pop()->GetString()); - Stack->PushNULL(); + if (strcmp(name, "LOG") == 0) { + stack->CorrectParams(1); + LOG(0, stack->Pop()->GetString()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { - HRESULT res = CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else if (strcmp(name, "Caption") == 0) { + HRESULT res = CBObject::scCallMethod(script, stack, thisStack, name); SetWindowTitle(); return res; } @@ -1001,23 +1001,23 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // Msg ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Msg") == 0) { - Stack->CorrectParams(1); - QuickMessage(Stack->Pop()->GetString()); - Stack->PushNULL(); + else if (strcmp(name, "Msg") == 0) { + stack->CorrectParams(1); + QuickMessage(stack->Pop()->GetString()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RunScript ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RunScript") == 0) { + else if (strcmp(name, "RunScript") == 0) { Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - Stack->CorrectParams(1); - if (FAILED(addScript(Stack->Pop()->GetString()))) - Stack->PushBool(false); + stack->CorrectParams(1); + if (FAILED(addScript(stack->Pop()->GetString()))) + stack->PushBool(false); else - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -1025,19 +1025,19 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // LoadStringTable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadStringTable") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "LoadStringTable") == 0) { + stack->CorrectParams(2); + const char *Filename = stack->Pop()->GetString(); + CScValue *Val = stack->Pop(); bool ClearOld; if (Val->IsNULL()) ClearOld = true; else ClearOld = Val->GetBool(); if (FAILED(_stringTable->loadFile(Filename, ClearOld))) - Stack->PushBool(false); + stack->PushBool(false); else - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -1045,11 +1045,11 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // ValidObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ValidObject") == 0) { - Stack->CorrectParams(1); - CBScriptable *obj = Stack->Pop()->GetNative(); - if (ValidObject((CBObject *) obj)) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "ValidObject") == 0) { + stack->CorrectParams(1); + CBScriptable *obj = stack->Pop()->GetNative(); + if (ValidObject((CBObject *) obj)) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -1057,10 +1057,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // Reset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Reset") == 0) { + stack->CorrectParams(0); ResetContent(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -1069,31 +1069,31 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // UnloadObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UnloadObject") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "UnloadObject") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); CBObject *obj = (CBObject *)val->GetNative(); UnregisterObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LoadWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadWindow") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "LoadWindow") == 0) { + stack->CorrectParams(1); CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->loadFile(Stack->Pop()->GetString()))) { + if (win && SUCCEEDED(win->loadFile(stack->Pop()->GetString()))) { _windows.Add(win); RegisterObject(win); - Stack->PushNative(win, true); + stack->PushNative(win, true); } else { delete win; win = NULL; - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; } @@ -1101,13 +1101,13 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // ExpandString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExpandString") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "ExpandString") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); char *str = new char[strlen(val->GetString()) + 1]; strcpy(str, val->GetString()); _stringTable->Expand(&str); - Stack->PushString(str); + stack->PushString(str); delete [] str; return S_OK; } @@ -1115,91 +1115,91 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // PlayMusic / PlayMusicChannel ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayMusic") == 0 || strcmp(Name, "PlayMusicChannel") == 0) { + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { int Channel = 0; - if (strcmp(Name, "PlayMusic") == 0) Stack->CorrectParams(3); + if (strcmp(name, "PlayMusic") == 0) stack->CorrectParams(3); else { - Stack->CorrectParams(4); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(4); + Channel = stack->Pop()->GetInt(); } - const char *Filename = Stack->Pop()->GetString(); - CScValue *ValLooping = Stack->Pop(); + const char *Filename = stack->Pop()->GetString(); + CScValue *ValLooping = stack->Pop(); bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); - CScValue *ValLoopStart = Stack->Pop(); + CScValue *ValLoopStart = stack->Pop(); uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); - if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // StopMusic / StopMusicChannel ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopMusic") == 0 || strcmp(Name, "StopMusicChannel") == 0) { + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { int Channel = 0; - if (strcmp(Name, "StopMusic") == 0) Stack->CorrectParams(0); + if (strcmp(name, "StopMusic") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (FAILED(StopMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(StopMusic(Channel))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PauseMusic / PauseMusicChannel ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0 || strcmp(Name, "PauseMusicChannel") == 0) { + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { int Channel = 0; - if (strcmp(Name, "PauseMusic") == 0) Stack->CorrectParams(0); + if (strcmp(name, "PauseMusic") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (FAILED(PauseMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(PauseMusic(Channel))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ResumeMusic / ResumeMusicChannel ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeMusic") == 0 || strcmp(Name, "ResumeMusicChannel") == 0) { + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { int Channel = 0; - if (strcmp(Name, "ResumeMusic") == 0) Stack->CorrectParams(0); + if (strcmp(name, "ResumeMusic") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (FAILED(ResumeMusic(Channel))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(ResumeMusic(Channel))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMusic / GetMusicChannel ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusic") == 0 || strcmp(Name, "GetMusicChannel") == 0) { + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { int Channel = 0; - if (strcmp(Name, "GetMusic") == 0) Stack->CorrectParams(0); + if (strcmp(name, "GetMusic") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) Stack->PushNULL(); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) stack->PushNULL(); else { - if (!_music[Channel] || !_music[Channel]->_soundFilename) Stack->PushNULL(); - else Stack->PushString(_music[Channel]->_soundFilename); + if (!_music[Channel] || !_music[Channel]->_soundFilename) stack->PushNULL(); + else stack->PushString(_music[Channel]->_soundFilename); } return S_OK; } @@ -1207,18 +1207,18 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // SetMusicPosition / SetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMusicPosition") == 0 || strcmp(Name, "SetMusicChannelPosition") == 0 || strcmp(Name, "SetMusicPositionChannel") == 0) { + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { int Channel = 0; - if (strcmp(Name, "SetMusicPosition") == 0) Stack->CorrectParams(1); + if (strcmp(name, "SetMusicPosition") == 0) stack->CorrectParams(1); else { - Stack->CorrectParams(2); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(2); + Channel = stack->Pop()->GetInt(); } - uint32 Time = Stack->Pop()->GetInt(); + uint32 Time = stack->Pop()->GetInt(); - if (FAILED(SetMusicStartTime(Channel, Time))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(SetMusicStartTime(Channel, Time))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } @@ -1226,51 +1226,51 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetMusicPosition / GetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusicPosition") == 0 || strcmp(Name, "GetMusicChannelPosition") == 0) { + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { int Channel = 0; - if (strcmp(Name, "GetMusicPosition") == 0) Stack->CorrectParams(0); + if (strcmp(name, "GetMusicPosition") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->getPositionTime()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushInt(0); + else stack->PushInt(_music[Channel]->getPositionTime()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsMusicPlaying / IsMusicChannelPlaying ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsMusicPlaying") == 0 || strcmp(Name, "IsMusicChannelPlaying") == 0) { + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { int Channel = 0; - if (strcmp(Name, "IsMusicPlaying") == 0) Stack->CorrectParams(0); + if (strcmp(name, "IsMusicPlaying") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); - else Stack->PushBool(_music[Channel]->isPlaying()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushBool(false); + else stack->PushBool(_music[Channel]->isPlaying()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMusicVolume / SetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMusicVolume") == 0 || strcmp(Name, "SetMusicChannelVolume") == 0) { + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { int Channel = 0; - if (strcmp(Name, "SetMusicVolume") == 0) Stack->CorrectParams(1); + if (strcmp(name, "SetMusicVolume") == 0) stack->CorrectParams(1); else { - Stack->CorrectParams(2); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(2); + Channel = stack->Pop()->GetInt(); } - int Volume = Stack->Pop()->GetInt(); - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushBool(false); + int Volume = stack->Pop()->GetInt(); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushBool(false); else { - if (FAILED(_music[Channel]->setVolume(Volume))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(_music[Channel]->setVolume(Volume))) stack->PushBool(false); + else stack->PushBool(true); } return S_OK; } @@ -1278,16 +1278,16 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetMusicVolume / GetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMusicVolume") == 0 || strcmp(Name, "GetMusicChannelVolume") == 0) { + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { int Channel = 0; - if (strcmp(Name, "GetMusicVolume") == 0) Stack->CorrectParams(0); + if (strcmp(name, "GetMusicVolume") == 0) stack->CorrectParams(0); else { - Stack->CorrectParams(1); - Channel = Stack->Pop()->GetInt(); + stack->CorrectParams(1); + Channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) Stack->PushInt(0); - else Stack->PushInt(_music[Channel]->getVolume()); + if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushInt(0); + else stack->PushInt(_music[Channel]->getVolume()); return S_OK; } @@ -1295,16 +1295,16 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // MusicCrossfade ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicCrossfade") == 0) { - Stack->CorrectParams(4); - int Channel1 = Stack->Pop()->GetInt(0); - int Channel2 = Stack->Pop()->GetInt(0); - uint32 FadeLength = (uint32)Stack->Pop()->GetInt(0); - bool Swap = Stack->Pop()->GetBool(true); + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->CorrectParams(4); + int Channel1 = stack->Pop()->GetInt(0); + int Channel2 = stack->Pop()->GetInt(0); + uint32 FadeLength = (uint32)stack->Pop()->GetInt(0); + bool Swap = stack->Pop()->GetBool(true); if (_musicCrossfadeRunning) { - Script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - Stack->PushBool(false); + script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->PushBool(false); return S_OK; } @@ -1316,18 +1316,18 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS _musicCrossfadeRunning = true; - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSoundLength ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundLength") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetSoundLength") == 0) { + stack->CorrectParams(1); int Length = 0; - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); CBSound *Sound = new CBSound(Game); if (Sound && SUCCEEDED(Sound->setSound(Filename, SOUND_MUSIC, true))) { @@ -1335,17 +1335,17 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS delete Sound; Sound = NULL; } - Stack->PushInt(Length); + stack->PushInt(Length); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMousePos ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMousePos") == 0) { - Stack->CorrectParams(2); - int x = Stack->Pop()->GetInt(); - int y = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetMousePos") == 0) { + stack->CorrectParams(2); + int x = stack->Pop()->GetInt(); + int y = stack->Pop()->GetInt(); x = MAX(x, 0); x = MIN(x, _renderer->_width); y = MAX(y, 0); @@ -1356,35 +1356,35 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS CBPlatform::SetCursorPos(p.x, p.y); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LockMouseRect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LockMouseRect") == 0) { - Stack->CorrectParams(4); - int left = Stack->Pop()->GetInt(); - int top = Stack->Pop()->GetInt(); - int right = Stack->Pop()->GetInt(); - int bottom = Stack->Pop()->GetInt(); + else if (strcmp(name, "LockMouseRect") == 0) { + stack->CorrectParams(4); + int left = stack->Pop()->GetInt(); + int top = stack->Pop()->GetInt(); + int right = stack->Pop()->GetInt(); + int bottom = stack->Pop()->GetInt(); if (right < left) CBUtils::Swap(&left, &right); if (bottom < top) CBUtils::Swap(&top, &bottom); CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PlayVideo ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayVideo") == 0) { - /* Stack->CorrectParams(0); - Stack->PushBool(false); + else if (strcmp(name, "PlayVideo") == 0) { + /* stack->CorrectParams(0); + stack->PushBool(false); return S_OK; // TODO: ADDVIDEO @@ -1392,19 +1392,19 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - Stack->CorrectParams(6); - const char *Filename = Stack->Pop()->GetString(); + stack->CorrectParams(6); + const char *Filename = stack->Pop()->GetString(); warning("PlayVideo: %s - not implemented yet", Filename); - CScValue *valType = Stack->Pop(); + CScValue *valType = stack->Pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - bool FreezeMusic = Stack->Pop()->GetBool(true); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + bool FreezeMusic = stack->Pop()->GetBool(true); - CScValue *valSub = Stack->Pop(); + CScValue *valSub = stack->Pop(); const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) @@ -1412,10 +1412,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { - Stack->PushBool(true); - Script->Sleep(0); - } else Stack->PushBool(false); - } else Stack->PushBool(false); + stack->PushBool(true); + script->Sleep(0); + } else stack->PushBool(false); + } else stack->PushBool(false); return S_OK; } @@ -1423,27 +1423,27 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // PlayTheora ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlayTheora") == 0) { - /* Stack->CorrectParams(0); - Stack->PushBool(false); + else if (strcmp(name, "PlayTheora") == 0) { + /* stack->CorrectParams(0); + stack->PushBool(false); return S_OK;*/ // TODO: ADDVIDEO - Stack->CorrectParams(7); - const char *Filename = Stack->Pop()->GetString(); - CScValue *valType = Stack->Pop(); + stack->CorrectParams(7); + const char *Filename = stack->Pop()->GetString(); + CScValue *valType = stack->Pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); - bool FreezeMusic = Stack->Pop()->GetBool(true); - bool DropFrames = Stack->Pop()->GetBool(true); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); + bool FreezeMusic = stack->Pop()->GetBool(true); + bool DropFrames = stack->Pop()->GetBool(true); - CScValue *valSub = Stack->Pop(); + CScValue *valSub = stack->Pop(); const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; @@ -1453,11 +1453,11 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !DropFrames; if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { - Stack->PushBool(true); - Script->Sleep(0); - } else Stack->PushBool(false); + stack->PushBool(true); + script->Sleep(0); + } else stack->PushBool(false); } else { - Stack->PushBool(false); + stack->PushBool(false); delete _theoraPlayer; _theoraPlayer = NULL; } @@ -1468,9 +1468,9 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // QuitGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "QuitGame") == 0) { - Stack->CorrectParams(0); - Stack->PushNULL(); + else if (strcmp(name, "QuitGame") == 0) { + stack->CorrectParams(0); + stack->PushNULL(); _quitting = true; return S_OK; } @@ -1478,65 +1478,65 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // RegWriteNumber ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegWriteNumber") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - int Val = Stack->Pop()->GetInt(); + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->CorrectParams(2); + const char *Key = stack->Pop()->GetString(); + int Val = stack->Pop()->GetInt(); _registry->WriteInt("PrivateSettings", Key, Val); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RegReadNumber ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegReadNumber") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - int InitVal = Stack->Pop()->GetInt(); - Stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); + else if (strcmp(name, "RegReadNumber") == 0) { + stack->CorrectParams(2); + const char *Key = stack->Pop()->GetString(); + int InitVal = stack->Pop()->GetInt(); + stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RegWriteString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegWriteString") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - const char *Val = Stack->Pop()->GetString(); + else if (strcmp(name, "RegWriteString") == 0) { + stack->CorrectParams(2); + const char *Key = stack->Pop()->GetString(); + const char *Val = stack->Pop()->GetString(); _registry->WriteString("PrivateSettings", Key, Val); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RegReadString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RegReadString") == 0) { - Stack->CorrectParams(2); - const char *Key = Stack->Pop()->GetString(); - const char *InitVal = Stack->Pop()->GetString(); + else if (strcmp(name, "RegReadString") == 0) { + stack->CorrectParams(2); + const char *Key = stack->Pop()->GetString(); + const char *InitVal = stack->Pop()->GetString(); AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); - Stack->PushString(val.c_str()); + stack->PushString(val.c_str()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SaveGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveGame") == 0) { - Stack->CorrectParams(3); - int Slot = Stack->Pop()->GetInt(); - const char *xdesc = Stack->Pop()->GetString(); - bool quick = Stack->Pop()->GetBool(false); + else if (strcmp(name, "SaveGame") == 0) { + stack->CorrectParams(3); + int Slot = stack->Pop()->GetInt(); + const char *xdesc = stack->Pop()->GetString(); + bool quick = stack->Pop()->GetBool(false); char *Desc = new char[strlen(xdesc) + 1]; strcpy(Desc, xdesc); - Stack->PushBool(true); + stack->PushBool(true); if (FAILED(SaveGame(Slot, Desc, quick))) { - Stack->Pop(); - Stack->PushBool(false); + stack->Pop(); + stack->PushBool(false); } delete [] Desc; return S_OK; @@ -1545,132 +1545,132 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // LoadGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadGame") == 0) { - Stack->CorrectParams(1); - _scheduledLoadSlot = Stack->Pop()->GetInt(); + else if (strcmp(name, "LoadGame") == 0) { + stack->CorrectParams(1); + _scheduledLoadSlot = stack->Pop()->GetInt(); _loading = true; - Stack->PushBool(false); - Script->Sleep(0); + stack->PushBool(false); + script->Sleep(0); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsSaveSlotUsed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsSaveSlotUsed") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); - Stack->PushBool(IsSaveSlotUsed(Slot)); + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->CorrectParams(1); + int Slot = stack->Pop()->GetInt(); + stack->PushBool(IsSaveSlotUsed(Slot)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSaveSlotDescription ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSaveSlotDescription") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->CorrectParams(1); + int Slot = stack->Pop()->GetInt(); char Desc[512]; Desc[0] = '\0'; GetSaveSlotDescription(Slot, Desc); - Stack->PushString(Desc); + stack->PushString(Desc); return S_OK; } ////////////////////////////////////////////////////////////////////////// // EmptySaveSlot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmptySaveSlot") == 0) { - Stack->CorrectParams(1); - int Slot = Stack->Pop()->GetInt(); + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->CorrectParams(1); + int Slot = stack->Pop()->GetInt(); EmptySaveSlot(Slot); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetGlobalSFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalSFXVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->Pop()->GetInt()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetGlobalSpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalSpeechVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->Pop()->GetInt()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetGlobalMusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalMusicVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->CorrectParams(1); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->Pop()->GetInt()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetGlobalMasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetGlobalMasterVolume") == 0) { - Stack->CorrectParams(1); - Game->_soundMgr->setMasterVolumePercent((byte)Stack->Pop()->GetInt()); - Stack->PushNULL(); + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->CorrectParams(1); + Game->_soundMgr->setMasterVolumePercent((byte)stack->Pop()->GetInt()); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetGlobalSFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalSFXVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->CorrectParams(0); + stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetGlobalSpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalSpeechVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->CorrectParams(0); + stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetGlobalMusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalMusicVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->CorrectParams(0); + stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetGlobalMasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGlobalMasterVolume") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_soundMgr->getMasterVolumePercent()); + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->CorrectParams(0); + stack->PushInt(_soundMgr->getMasterVolumePercent()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetActiveCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetActiveCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(setActiveCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->CorrectParams(1); + if (SUCCEEDED(setActiveCursor(stack->Pop()->GetString()))) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -1678,10 +1678,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetActiveCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetActiveCursor") == 0) { - Stack->CorrectParams(0); - if (!_activeCursor || !_activeCursor->_filename) Stack->PushNULL(); - else Stack->PushString(_activeCursor->_filename); + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->CorrectParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->PushNULL(); + else stack->PushString(_activeCursor->_filename); return S_OK; } @@ -1689,10 +1689,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetActiveCursorObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetActiveCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_activeCursor) Stack->PushNULL(); - else Stack->PushNative(_activeCursor, true); + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->CorrectParams(0); + if (!_activeCursor) stack->PushNULL(); + else stack->PushNative(_activeCursor, true); return S_OK; } @@ -1700,11 +1700,11 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // RemoveActiveCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveActiveCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->CorrectParams(0); delete _activeCursor; _activeCursor = NULL; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -1712,11 +1712,11 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // HasActiveCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasActiveCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->CorrectParams(0); - if (_activeCursor) Stack->PushBool(true); - else Stack->PushBool(false); + if (_activeCursor) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -1724,15 +1724,15 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // FileExists ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FileExists") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "FileExists") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); - if (!File) Stack->PushBool(false); + if (!File) stack->PushBool(false); else { _fileManager->closeFile(File); - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -1740,60 +1740,60 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOut") == 0 || strcmp(Name, "FadeOutAsync") == 0 || strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->CorrectParams(5); + uint32 Duration = stack->Pop()->GetInt(500); + byte Red = stack->Pop()->GetInt(0); + byte Green = stack->Pop()->GetInt(0); + byte Blue = stack->Pop()->GetInt(0); + byte Alpha = stack->Pop()->GetInt(0xFF); - bool System = (strcmp(Name, "SystemFadeOut") == 0 || strcmp(Name, "SystemFadeOutAsync") == 0); + bool System = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeOutAsync") != 0 && strcmp(Name, "SystemFadeOutAsync") != 0) Script->WaitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->WaitFor(_fader); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeIn") == 0 || strcmp(Name, "FadeInAsync") == 0 || strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0) { - Stack->CorrectParams(5); - uint32 Duration = Stack->Pop()->GetInt(500); - byte Red = Stack->Pop()->GetInt(0); - byte Green = Stack->Pop()->GetInt(0); - byte Blue = Stack->Pop()->GetInt(0); - byte Alpha = Stack->Pop()->GetInt(0xFF); + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->CorrectParams(5); + uint32 Duration = stack->Pop()->GetInt(500); + byte Red = stack->Pop()->GetInt(0); + byte Green = stack->Pop()->GetInt(0); + byte Blue = stack->Pop()->GetInt(0); + byte Alpha = stack->Pop()->GetInt(0xFF); - bool System = (strcmp(Name, "SystemFadeIn") == 0 || strcmp(Name, "SystemFadeInAsync") == 0); + bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); - if (strcmp(Name, "FadeInAsync") != 0 && strcmp(Name, "SystemFadeInAsync") != 0) Script->WaitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->WaitFor(_fader); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetFadeColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFadeColor") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_fader->getCurrentColor()); + else if (strcmp(name, "GetFadeColor") == 0) { + stack->CorrectParams(0); + stack->PushInt(_fader->getCurrentColor()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Screenshot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Screenshot") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "Screenshot") == 0) { + stack->CorrectParams(1); char Filename[MAX_PATH]; - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int FileNum = 0; @@ -1812,18 +1812,18 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS delete Image; } else ret = false; - Stack->PushBool(ret); + stack->PushBool(ret); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScreenshotEx ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenshotEx") == 0) { - Stack->CorrectParams(3); - const char *Filename = Stack->Pop()->GetString(); - int SizeX = Stack->Pop()->GetInt(_renderer->_width); - int SizeY = Stack->Pop()->GetInt(_renderer->_height); + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->CorrectParams(3); + const char *Filename = stack->Pop()->GetString(); + int SizeX = stack->Pop()->GetInt(_renderer->_width); + int SizeY = stack->Pop()->GetInt(_renderer->_height); bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); @@ -1833,69 +1833,69 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS delete Image; } else ret = false; - Stack->PushBool(ret); + stack->PushBool(ret); return S_OK; } ////////////////////////////////////////////////////////////////////////// // CreateWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateWindow") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateWindow") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIWindow *Win = new CUIWindow(Game); _windows.Add(Win); RegisterObject(Win); if (!Val->IsNULL()) Win->setName(Val->GetString()); - Stack->PushNative(Win, true); + stack->PushNative(Win, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteWindow") == 0) { - Stack->CorrectParams(1); - CBObject *Obj = (CBObject *)Stack->Pop()->GetNative(); + else if (strcmp(name, "DeleteWindow") == 0) { + stack->CorrectParams(1); + CBObject *Obj = (CBObject *)stack->Pop()->GetNative(); for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i] == Obj) { UnregisterObject(_windows[i]); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } } - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // OpenDocument ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OpenDocument") == 0) { - Stack->CorrectParams(0); - Stack->PushNULL(); + else if (strcmp(name, "OpenDocument") == 0) { + stack->CorrectParams(0); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DEBUG_DumpClassRegistry ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DEBUG_DumpClassRegistry") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->CorrectParams(0); DEBUG_DumpClassRegistry(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetLoadingScreen ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetLoadingScreen") == 0) { - Stack->CorrectParams(3); - CScValue *Val = Stack->Pop(); - _loadImageX = Stack->Pop()->GetInt(); - _loadImageY = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->CorrectParams(3); + CScValue *Val = stack->Pop(); + _loadImageX = stack->Pop()->GetInt(); + _loadImageY = stack->Pop()->GetInt(); if (Val->IsNULL()) { delete[] _loadImageName; @@ -1903,18 +1903,18 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } else { CBUtils::SetString(&_loadImageName, Val->GetString()); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSavingScreen ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSavingScreen") == 0) { - Stack->CorrectParams(3); - CScValue *Val = Stack->Pop(); - _saveImageX = Stack->Pop()->GetInt(); - _saveImageY = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->CorrectParams(3); + CScValue *Val = stack->Pop(); + _saveImageX = stack->Pop()->GetInt(); + _saveImageY = stack->Pop()->GetInt(); if (Val->IsNULL()) { delete[] _saveImageName; @@ -1922,17 +1922,17 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS } else { CBUtils::SetString(&_saveImageName, Val->GetString()); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetWaitCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetWaitCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(SetWaitCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->CorrectParams(1); + if (SUCCEEDED(SetWaitCursor(stack->Pop()->GetString()))) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -1940,12 +1940,12 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // RemoveWaitCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveWaitCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->CorrectParams(0); delete _cursorNoninteractive; _cursorNoninteractive = NULL; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -1953,10 +1953,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetWaitCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaitCursor") == 0) { - Stack->CorrectParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) Stack->PushNULL(); - else Stack->PushString(_cursorNoninteractive->_filename); + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->CorrectParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->PushNULL(); + else stack->PushString(_cursorNoninteractive->_filename); return S_OK; } @@ -1964,10 +1964,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetWaitCursorObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWaitCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_cursorNoninteractive) Stack->PushNULL(); - else Stack->PushNative(_cursorNoninteractive, true); + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->CorrectParams(0); + if (!_cursorNoninteractive) stack->PushNULL(); + else stack->PushNative(_cursorNoninteractive, true); return S_OK; } @@ -1975,22 +1975,22 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // ClearScriptCache ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClearScriptCache") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->CorrectParams(0); + stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DisplayLoadingIcon ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisplayLoadingIcon") == 0) { - Stack->CorrectParams(4); + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->CorrectParams(4); - const char *Filename = Stack->Pop()->GetString(); - _loadingIconX = Stack->Pop()->GetInt(); - _loadingIconY = Stack->Pop()->GetInt(); - _loadingIconPersistent = Stack->Pop()->GetBool(); + const char *Filename = stack->Pop()->GetString(); + _loadingIconX = stack->Pop()->GetInt(); + _loadingIconY = stack->Pop()->GetInt(); + _loadingIconPersistent = stack->Pop()->GetBool(); delete _loadingIcon; _loadingIcon = new CBSprite(this); @@ -2002,7 +2002,7 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS Game->_renderer->flip(); Game->_renderer->initLoop(); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2010,38 +2010,38 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // HideLoadingIcon ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HideLoadingIcon") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->CorrectParams(0); delete _loadingIcon; _loadingIcon = NULL; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DumpTextureStats ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DumpTextureStats") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); _renderer->dumpData(Filename); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AccOutputText ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccOutputText") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "AccOutputText") == 0) { + stack->CorrectParams(2); /* const char *Str = */ - Stack->Pop()->GetString(); + stack->Pop()->GetString(); /* int Type = */ - Stack->Pop()->GetInt(); + stack->Pop()->GetInt(); // do nothing - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2049,15 +2049,15 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // StoreSaveThumbnail ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StoreSaveThumbnail") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->CorrectParams(0); delete _cachedThumbnail; _cachedThumbnail = new CBSaveThumbHelper(this); if (FAILED(_cachedThumbnail->StoreThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -2065,11 +2065,11 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // DeleteSaveThumbnail ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteSaveThumbnail") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->CorrectParams(0); delete _cachedThumbnail; _cachedThumbnail = NULL; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2077,10 +2077,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // GetFileChecksum ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFileChecksum") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool AsHex = Stack->Pop()->GetBool(false); + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->CorrectParams(2); + const char *Filename = stack->Pop()->GetString(); + bool AsHex = stack->Pop()->GetBool(false); Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); if (File) { @@ -2101,13 +2101,13 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if (AsHex) { char Hex[100]; sprintf(Hex, "%x", checksum); - Stack->PushString(Hex); + stack->PushString(Hex); } else - Stack->PushInt(checksum); + stack->PushInt(checksum); _fileManager->closeFile(File); File = NULL; - } else Stack->PushNULL(); + } else stack->PushNULL(); return S_OK; } @@ -2115,10 +2115,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // EnableScriptProfiling ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EnableScriptProfiling") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->CorrectParams(0); _scEngine->EnableProfiling(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2126,10 +2126,10 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // DisableScriptProfiling ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DisableScriptProfiling") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->CorrectParams(0); _scEngine->DisableProfiling(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2137,12 +2137,12 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // ShowStatusLine ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ShowStatusLine") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->CorrectParams(0); #ifdef __IPHONEOS__ IOS_ShowStatusLine(TRUE); #endif - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -2150,42 +2150,42 @@ HRESULT CBGame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS ////////////////////////////////////////////////////////////////////////// // HideStatusLine ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HideStatusLine") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "HideStatusLine") == 0) { + stack->CorrectParams(0); #ifdef __IPHONEOS__ IOS_ShowStatusLine(FALSE); #endif - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *Name) { +CScValue *CBGame::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Hwnd (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Hwnd") == 0) { + else if (strcmp(name, "Hwnd") == 0) { _scValue->SetInt((int)_renderer->_window); return _scValue; } @@ -2193,7 +2193,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CurrentTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CurrentTime") == 0) { + else if (strcmp(name, "CurrentTime") == 0) { _scValue->SetInt((int)_timer); return _scValue; } @@ -2201,7 +2201,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WindowsTime") == 0) { + else if (strcmp(name, "WindowsTime") == 0) { _scValue->SetInt((int)CBPlatform::GetTime()); return _scValue; } @@ -2209,7 +2209,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // WindowedMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WindowedMode") == 0) { + else if (strcmp(name, "WindowedMode") == 0) { _scValue->SetBool(_renderer->_windowed); return _scValue; } @@ -2217,7 +2217,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MouseX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { + else if (strcmp(name, "MouseX") == 0) { _scValue->SetInt(_mousePos.x); return _scValue; } @@ -2225,7 +2225,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MouseY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { + else if (strcmp(name, "MouseY") == 0) { _scValue->SetInt(_mousePos.y); return _scValue; } @@ -2233,7 +2233,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MainObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainObject") == 0) { + else if (strcmp(name, "MainObject") == 0) { _scValue->SetNative(_mainObject, true); return _scValue; } @@ -2241,7 +2241,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ActiveObject (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ActiveObject") == 0) { + else if (strcmp(name, "ActiveObject") == 0) { _scValue->SetNative(_activeObject, true); return _scValue; } @@ -2249,7 +2249,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScreenWidth (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenWidth") == 0) { + else if (strcmp(name, "ScreenWidth") == 0) { _scValue->SetInt(_renderer->_width); return _scValue; } @@ -2257,7 +2257,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScreenHeight (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScreenHeight") == 0) { + else if (strcmp(name, "ScreenHeight") == 0) { _scValue->SetInt(_renderer->_height); return _scValue; } @@ -2265,7 +2265,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Interactive") == 0) { + else if (strcmp(name, "Interactive") == 0) { _scValue->SetBool(_interactive); return _scValue; } @@ -2273,7 +2273,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DebugMode") == 0) { + else if (strcmp(name, "DebugMode") == 0) { _scValue->SetBool(_dEBUG_DebugMode); return _scValue; } @@ -2281,7 +2281,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SoundAvailable (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundAvailable") == 0) { + else if (strcmp(name, "SoundAvailable") == 0) { _scValue->SetBool(_soundMgr->_soundAvailable); return _scValue; } @@ -2289,7 +2289,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SFXVolume") == 0) { + else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SFX)); return _scValue; @@ -2298,7 +2298,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SpeechVolume") == 0) { + else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return _scValue; @@ -2307,7 +2307,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicVolume") == 0) { + else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return _scValue; @@ -2316,7 +2316,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MasterVolume") == 0) { + else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); _scValue->SetInt(_soundMgr->getMasterVolumePercent()); return _scValue; @@ -2325,7 +2325,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Keyboard") == 0) { + else if (strcmp(name, "Keyboard") == 0) { if (_keyboardState) _scValue->SetNative(_keyboardState, true); else _scValue->SetNULL(); @@ -2335,7 +2335,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtitles") == 0) { + else if (strcmp(name, "Subtitles") == 0) { _scValue->SetBool(_subtitles); return _scValue; } @@ -2343,14 +2343,14 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesSpeed") == 0) { + else if (strcmp(name, "SubtitlesSpeed") == 0) { _scValue->SetInt(_subtitlesSpeed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VideoSubtitles") == 0) { + else if (strcmp(name, "VideoSubtitles") == 0) { _scValue->SetBool(_videoSubtitles); return _scValue; } @@ -2358,7 +2358,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // FPS (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FPS") == 0) { + else if (strcmp(name, "FPS") == 0) { _scValue->SetInt(_fps); return _scValue; } @@ -2366,7 +2366,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AcceleratedMode / Accelerated (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AcceleratedMode") == 0 || strcmp(Name, "Accelerated") == 0) { + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { _scValue->SetBool(_useD3D); return _scValue; } @@ -2374,7 +2374,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TextEncoding ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextEncoding") == 0) { + else if (strcmp(name, "TextEncoding") == 0) { _scValue->SetInt(_textEncoding); return _scValue; } @@ -2382,7 +2382,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TextRTL ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextRTL") == 0) { + else if (strcmp(name, "TextRTL") == 0) { _scValue->SetBool(_textRTL); return _scValue; } @@ -2390,7 +2390,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SoundBufferSize ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundBufferSize") == 0) { + else if (strcmp(name, "SoundBufferSize") == 0) { _scValue->SetInt(_soundBufferSizeSec); return _scValue; } @@ -2398,7 +2398,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SuspendedRendering ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuspendedRendering") == 0) { + else if (strcmp(name, "SuspendedRendering") == 0) { _scValue->SetBool(_suspendedRendering); return _scValue; } @@ -2406,7 +2406,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuppressScriptErrors") == 0) { + else if (strcmp(name, "SuppressScriptErrors") == 0) { _scValue->SetBool(_suppressScriptErrors); return _scValue; } @@ -2415,7 +2415,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Frozen ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Frozen") == 0) { + else if (strcmp(name, "Frozen") == 0) { _scValue->SetBool(_state == GAME_FROZEN); return _scValue; } @@ -2423,7 +2423,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccTTSEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSEnabled") == 0) { + else if (strcmp(name, "AccTTSEnabled") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2431,7 +2431,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccTTSTalk ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSTalk") == 0) { + else if (strcmp(name, "AccTTSTalk") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2439,7 +2439,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccTTSCaptions ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSCaptions") == 0) { + else if (strcmp(name, "AccTTSCaptions") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2447,7 +2447,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccTTSKeypress ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccTTSKeypress") == 0) { + else if (strcmp(name, "AccTTSKeypress") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2455,7 +2455,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardEnabled") == 0) { + else if (strcmp(name, "AccKeyboardEnabled") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2463,7 +2463,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardCursorSkip ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardCursorSkip") == 0) { + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2471,7 +2471,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardPause ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccKeyboardPause") == 0) { + else if (strcmp(name, "AccKeyboardPause") == 0) { _scValue->SetBool(false); return _scValue; } @@ -2479,7 +2479,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AutorunDisabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutorunDisabled") == 0) { + else if (strcmp(name, "AutorunDisabled") == 0) { _scValue->SetBool(_autorunDisabled); return _scValue; } @@ -2487,7 +2487,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveDirectory") == 0) { + else if (strcmp(name, "SaveDirectory") == 0) { AnsiString dataDir = GetDataDir(); _scValue->SetString(dataDir.c_str()); return _scValue; @@ -2496,7 +2496,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveOnExit") == 0) { + else if (strcmp(name, "AutoSaveOnExit") == 0) { _scValue->SetBool(_autoSaveOnExit); return _scValue; } @@ -2504,7 +2504,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveSlot") == 0) { + else if (strcmp(name, "AutoSaveSlot") == 0) { _scValue->SetInt(_autoSaveSlot); return _scValue; } @@ -2512,7 +2512,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CursorHidden ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorHidden") == 0) { + else if (strcmp(name, "CursorHidden") == 0) { _scValue->SetBool(_cursorHidden); return _scValue; } @@ -2520,7 +2520,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Platform (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Platform") == 0) { + else if (strcmp(name, "Platform") == 0) { _scValue->SetString(CBPlatform::GetPlatformName().c_str()); return _scValue; } @@ -2528,7 +2528,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeviceType") == 0) { + else if (strcmp(name, "DeviceType") == 0) { _scValue->SetString(GetDeviceType().c_str()); return _scValue; } @@ -2536,7 +2536,7 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MostRecentSaveSlot") == 0) { + else if (strcmp(name, "MostRecentSaveSlot") == 0) { _scValue->SetInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -2544,23 +2544,23 @@ CScValue *CBGame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Store (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Store") == 0) { + else if (strcmp(name, "Store") == 0) { if (_store) _scValue->SetNative(_store, true); else _scValue->SetNULL(); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; @@ -2569,7 +2569,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MouseX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseX") == 0) { + else if (strcmp(name, "MouseX") == 0) { _mousePos.x = Value->GetInt(); ResetMousePos(); return S_OK; @@ -2578,7 +2578,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MouseY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MouseY") == 0) { + else if (strcmp(name, "MouseY") == 0) { _mousePos.y = Value->GetInt(); ResetMousePos(); return S_OK; @@ -2587,8 +2587,8 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { - HRESULT res = CBObject::scSetProperty(Name, Value); + else if (strcmp(name, "Name") == 0) { + HRESULT res = CBObject::scSetProperty(name, Value); SetWindowTitle(); return res; } @@ -2596,7 +2596,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MainObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MainObject") == 0) { + else if (strcmp(name, "MainObject") == 0) { CBScriptable *obj = Value->GetNative(); if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; return S_OK; @@ -2605,7 +2605,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Interactive") == 0) { + else if (strcmp(name, "Interactive") == 0) { SetInteractive(Value->GetBool()); return S_OK; } @@ -2613,7 +2613,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SFXVolume") == 0) { + else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Value->GetInt()); return S_OK; @@ -2622,7 +2622,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SpeechVolume") == 0) { + else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Value->GetInt()); return S_OK; @@ -2631,7 +2631,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MusicVolume") == 0) { + else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Value->GetInt()); return S_OK; @@ -2640,7 +2640,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MasterVolume") == 0) { + else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); Game->_soundMgr->setMasterVolumePercent((byte)Value->GetInt()); return S_OK; @@ -2649,7 +2649,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Subtitles") == 0) { + else if (strcmp(name, "Subtitles") == 0) { _subtitles = Value->GetBool(); return S_OK; } @@ -2657,7 +2657,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SubtitlesSpeed") == 0) { + else if (strcmp(name, "SubtitlesSpeed") == 0) { _subtitlesSpeed = Value->GetInt(); return S_OK; } @@ -2665,7 +2665,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VideoSubtitles") == 0) { + else if (strcmp(name, "VideoSubtitles") == 0) { _videoSubtitles = Value->GetBool(); return S_OK; } @@ -2673,7 +2673,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextEncoding ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextEncoding") == 0) { + else if (strcmp(name, "TextEncoding") == 0) { int Enc = Value->GetInt(); if (Enc < 0) Enc = 0; if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; @@ -2684,7 +2684,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextRTL ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextRTL") == 0) { + else if (strcmp(name, "TextRTL") == 0) { _textRTL = Value->GetBool(); return S_OK; } @@ -2692,7 +2692,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SoundBufferSize ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundBufferSize") == 0) { + else if (strcmp(name, "SoundBufferSize") == 0) { _soundBufferSizeSec = Value->GetInt(); _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); return S_OK; @@ -2701,7 +2701,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SuspendedRendering ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuspendedRendering") == 0) { + else if (strcmp(name, "SuspendedRendering") == 0) { _suspendedRendering = Value->GetBool(); return S_OK; } @@ -2709,7 +2709,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SuppressScriptErrors") == 0) { + else if (strcmp(name, "SuppressScriptErrors") == 0) { _suppressScriptErrors = Value->GetBool(); return S_OK; } @@ -2717,7 +2717,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AutorunDisabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutorunDisabled") == 0) { + else if (strcmp(name, "AutorunDisabled") == 0) { _autorunDisabled = Value->GetBool(); return S_OK; } @@ -2725,7 +2725,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveOnExit") == 0) { + else if (strcmp(name, "AutoSaveOnExit") == 0) { _autoSaveOnExit = Value->GetBool(); return S_OK; } @@ -2733,7 +2733,7 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AutoSaveSlot") == 0) { + else if (strcmp(name, "AutoSaveSlot") == 0) { _autoSaveSlot = Value->GetInt(); return S_OK; } @@ -2741,12 +2741,12 @@ HRESULT CBGame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CursorHidden ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorHidden") == 0) { + else if (strcmp(name, "CursorHidden") == 0) { _cursorHidden = Value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } @@ -2925,283 +2925,283 @@ void CBGame::PublishNatives() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { +HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *this_obj; ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "LOG") == 0) { - Stack->CorrectParams(1); - Game->LOG(0, "sc: %s", Stack->Pop()->GetString()); - Stack->PushNULL(); + if (strcmp(name, "LOG") == 0) { + stack->CorrectParams(1); + Game->LOG(0, "sc: %s", stack->Pop()->GetString()); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // String ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "String") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "String") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXString(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXString(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // MemBuffer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MemBuffer") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "MemBuffer") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXMemBuffer(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXMemBuffer(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // File ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "File") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "File") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXFile(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXFile(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Date ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Date") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "Date") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXDate(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXDate(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Array ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Array") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "Array") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXArray(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXArray(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Object ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Object") == 0) { - this_obj = ThisStack->GetTop(); + else if (strcmp(name, "Object") == 0) { + this_obj = thisStack->GetTop(); - this_obj->SetNative(makeSXObject(Game, Stack)); - Stack->PushNULL(); + this_obj->SetNative(makeSXObject(Game, stack)); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Sleep ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sleep") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "Sleep") == 0) { + stack->CorrectParams(1); - Script->Sleep((uint32)Stack->Pop()->GetInt()); - Stack->PushNULL(); + script->Sleep((uint32)stack->Pop()->GetInt()); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // WaitFor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WaitFor") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "WaitFor") == 0) { + stack->CorrectParams(1); - CBScriptable *obj = Stack->Pop()->GetNative(); - if (ValidObject((CBObject *)obj)) Script->WaitForExclusive((CBObject *)obj); - Stack->PushNULL(); + CBScriptable *obj = stack->Pop()->GetNative(); + if (ValidObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // Random ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Random") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "Random") == 0) { + stack->CorrectParams(2); - int from = Stack->Pop()->GetInt(); - int to = Stack->Pop()->GetInt(); + int from = stack->Pop()->GetInt(); + int to = stack->Pop()->GetInt(); - Stack->PushInt(CBUtils::RandomInt(from, to)); + stack->PushInt(CBUtils::RandomInt(from, to)); } ////////////////////////////////////////////////////////////////////////// // SetScriptTimeSlice ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetScriptTimeSlice") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->CorrectParams(1); - Script->_timeSlice = (uint32)Stack->Pop()->GetInt(); - Stack->PushNULL(); + script->_timeSlice = (uint32)stack->Pop()->GetInt(); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // MakeRGBA / MakeRGB / RGB ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MakeRGBA") == 0 || strcmp(Name, "MakeRGB") == 0 || strcmp(Name, "RGB") == 0) { - Stack->CorrectParams(4); - int r = Stack->Pop()->GetInt(); - int g = Stack->Pop()->GetInt(); - int b = Stack->Pop()->GetInt(); + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->CorrectParams(4); + int r = stack->Pop()->GetInt(); + int g = stack->Pop()->GetInt(); + int b = stack->Pop()->GetInt(); int a; - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); if (val->IsNULL()) a = 255; else a = val->GetInt(); - Stack->PushInt(DRGBA(r, g, b, a)); + stack->PushInt(DRGBA(r, g, b, a)); } ////////////////////////////////////////////////////////////////////////// // MakeHSL ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MakeHSL") == 0) { - Stack->CorrectParams(3); - int h = Stack->Pop()->GetInt(); - int s = Stack->Pop()->GetInt(); - int l = Stack->Pop()->GetInt(); + else if (strcmp(name, "MakeHSL") == 0) { + stack->CorrectParams(3); + int h = stack->Pop()->GetInt(); + int s = stack->Pop()->GetInt(); + int l = stack->Pop()->GetInt(); - Stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); + stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); } ////////////////////////////////////////////////////////////////////////// // GetRValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetRValue") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetRValue") == 0) { + stack->CorrectParams(1); - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetR(rgba)); + uint32 rgba = (uint32)stack->Pop()->GetInt(); + stack->PushInt(D3DCOLGetR(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetGValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetGValue") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetGValue") == 0) { + stack->CorrectParams(1); - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetG(rgba)); + uint32 rgba = (uint32)stack->Pop()->GetInt(); + stack->PushInt(D3DCOLGetG(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetBValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetBValue") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetBValue") == 0) { + stack->CorrectParams(1); - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetB(rgba)); + uint32 rgba = (uint32)stack->Pop()->GetInt(); + stack->PushInt(D3DCOLGetB(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetAValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetAValue") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "GetAValue") == 0) { + stack->CorrectParams(1); - uint32 rgba = (uint32)Stack->Pop()->GetInt(); - Stack->PushInt(D3DCOLGetA(rgba)); + uint32 rgba = (uint32)stack->Pop()->GetInt(); + stack->PushInt(D3DCOLGetA(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetHValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); + else if (strcmp(name, "GetHValue") == 0) { + stack->CorrectParams(1); + uint32 rgb = (uint32)stack->Pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(H); + stack->PushInt(H); } ////////////////////////////////////////////////////////////////////////// // GetSValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); + else if (strcmp(name, "GetSValue") == 0) { + stack->CorrectParams(1); + uint32 rgb = (uint32)stack->Pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(S); + stack->PushInt(S); } ////////////////////////////////////////////////////////////////////////// // GetLValue ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetLValue") == 0) { - Stack->CorrectParams(1); - uint32 rgb = (uint32)Stack->Pop()->GetInt(); + else if (strcmp(name, "GetLValue") == 0) { + stack->CorrectParams(1); + uint32 rgb = (uint32)stack->Pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - Stack->PushInt(L); + stack->PushInt(L); } ////////////////////////////////////////////////////////////////////////// // Debug ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Debug") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Debug") == 0) { + stack->CorrectParams(0); if (Game->GetDebugMgr()->_enabled) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(Script); - Script->Sleep(0); + Game->GetDebugMgr()->OnScriptHitBreakpoint(script); + script->Sleep(0); } - Stack->PushNULL(); + stack->PushNULL(); } ////////////////////////////////////////////////////////////////////////// // ToString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToString") == 0) { - Stack->CorrectParams(1); - const char *Str = Stack->Pop()->GetString(); + else if (strcmp(name, "ToString") == 0) { + stack->CorrectParams(1); + const char *Str = stack->Pop()->GetString(); char *Str2 = new char[strlen(Str) + 1]; strcpy(Str2, Str); - Stack->PushString(Str2); + stack->PushString(Str2); delete [] Str2; } ////////////////////////////////////////////////////////////////////////// // ToInt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToInt") == 0) { - Stack->CorrectParams(1); - int Val = Stack->Pop()->GetInt(); - Stack->PushInt(Val); + else if (strcmp(name, "ToInt") == 0) { + stack->CorrectParams(1); + int Val = stack->Pop()->GetInt(); + stack->PushInt(Val); } ////////////////////////////////////////////////////////////////////////// // ToFloat ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToFloat") == 0) { - Stack->CorrectParams(1); - double Val = Stack->Pop()->GetFloat(); - Stack->PushFloat(Val); + else if (strcmp(name, "ToFloat") == 0) { + stack->CorrectParams(1); + double Val = stack->Pop()->GetFloat(); + stack->PushFloat(Val); } ////////////////////////////////////////////////////////////////////////// // ToBool ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToBool") == 0) { - Stack->CorrectParams(1); - bool Val = Stack->Pop()->GetBool(); - Stack->PushBool(Val); + else if (strcmp(name, "ToBool") == 0) { + stack->CorrectParams(1); + bool Val = stack->Pop()->GetBool(); + stack->PushBool(Val); } ////////////////////////////////////////////////////////////////////////// // failure else { - Script->RuntimeError("Call to undefined function '%s'. Ignored.", Name); - Stack->CorrectParams(0); - Stack->PushNULL(); + script->RuntimeError("Call to undefined function '%s'. Ignored.", name); + stack->CorrectParams(0); + stack->PushNULL(); } return S_OK; @@ -4045,7 +4045,7 @@ HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name) { +HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) { return E_FAIL; } @@ -4500,7 +4500,7 @@ HRESULT CBGame::MiniUpdate() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnScriptShutdown(CScScript *Script) { +HRESULT CBGame::OnScriptShutdown(CScScript *script) { return S_OK; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 6c5776ef2e..0325785ce1 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -67,7 +67,7 @@ class CBGame: public CBObject { public: DECLARE_PERSISTENT(CBGame, CBObject) - virtual HRESULT OnScriptShutdown(CScScript *Script); + virtual HRESULT OnScriptShutdown(CScScript *script); virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); virtual HRESULT OnMouseLeftDown(); @@ -223,11 +223,11 @@ public: virtual HRESULT restoreDeviceObjects(); virtual void PublishNatives(); - virtual HRESULT ExternalCall(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name); + virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; @@ -335,7 +335,7 @@ public: int _subtitlesSpeed; void SetInteractive(bool State); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *Script, CScStack *Stack, const char *Name); + virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); HRESULT PopViewport(); diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 09d24453fa..490bf541fe 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -73,13 +73,13 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "IsKeyDown") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + if (strcmp(name, "IsKeyDown") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); int vKey; if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { @@ -94,22 +94,22 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *Script, CScStack *Stack, CScSta // SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); bool isDown = _keyStates[VKeyToKeyCode(vKey)]; - Stack->PushBool(isDown); + stack->PushBool(isDown); return S_OK; } - else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *Name) { +CScValue *CBKeyboardState::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("keyboard"); return _scValue; } @@ -117,7 +117,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Key ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Key") == 0) { + else if (strcmp(name, "Key") == 0) { if (_currentPrintable) { char key[2]; key[0] = (char)_currentCharCode; @@ -131,7 +131,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Printable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Printable") == 0) { + else if (strcmp(name, "Printable") == 0) { _scValue->SetBool(_currentPrintable); return _scValue; } @@ -139,7 +139,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // KeyCode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "KeyCode") == 0) { + else if (strcmp(name, "KeyCode") == 0) { _scValue->SetInt(_currentCharCode); return _scValue; } @@ -147,7 +147,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // IsShift ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsShift") == 0) { + else if (strcmp(name, "IsShift") == 0) { _scValue->SetBool(_currentShift); return _scValue; } @@ -155,7 +155,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // IsAlt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsAlt") == 0) { + else if (strcmp(name, "IsAlt") == 0) { _scValue->SetBool(_currentAlt); return _scValue; } @@ -163,28 +163,28 @@ CScValue *CBKeyboardState::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // IsControl ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsControl") == 0) { + else if (strcmp(name, "IsControl") == 0) { _scValue->SetBool(_currentControl); return _scValue; } - else return CBScriptable::scGetProperty(Name); + else return CBScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); if (_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } - else*/ return CBScriptable::scSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index d5b61cfb9a..27aeac6ad9 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -59,9 +59,9 @@ public: static bool IsAltDown(); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 6512a1f163..2665d25c97 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -165,17 +165,17 @@ HRESULT CBObject::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SkipTo") == 0) { - Stack->CorrectParams(2); - _posX = Stack->Pop()->GetInt(); - _posY = Stack->Pop()->GetInt(); + if (strcmp(name, "SkipTo") == 0) { + stack->CorrectParams(2); + _posX = stack->Pop()->GetInt(); + _posY = stack->Pop()->GetInt(); afterMove(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -183,9 +183,9 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { - Stack->CorrectParams(1); - Stack->PushString(getCaption(Stack->Pop()->GetInt())); + else if (strcmp(name, "Caption") == 0) { + stack->CorrectParams(1); + stack->PushString(getCaption(stack->Pop()->GetInt())); return S_OK; } @@ -193,10 +193,10 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SetCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCursor") == 0) { - Stack->CorrectParams(1); - if (SUCCEEDED(setCursor(Stack->Pop()->GetString()))) Stack->PushBool(true); - else Stack->PushBool(false); + else if (strcmp(name, "SetCursor") == 0) { + stack->CorrectParams(1); + if (SUCCEEDED(setCursor(stack->Pop()->GetString()))) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -204,8 +204,8 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // RemoveCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "RemoveCursor") == 0) { + stack->CorrectParams(0); if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -213,7 +213,7 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi _cursor = NULL; } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -221,10 +221,10 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCursor") == 0) { - Stack->CorrectParams(0); - if (!_cursor || !_cursor->_filename) Stack->PushNULL(); - else Stack->PushString(_cursor->_filename); + else if (strcmp(name, "GetCursor") == 0) { + stack->CorrectParams(0); + if (!_cursor || !_cursor->_filename) stack->PushNULL(); + else stack->PushString(_cursor->_filename); return S_OK; } @@ -232,10 +232,10 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetCursorObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetCursorObject") == 0) { - Stack->CorrectParams(0); - if (!_cursor) Stack->PushNULL(); - else Stack->PushNative(_cursor, true); + else if (strcmp(name, "GetCursorObject") == 0) { + stack->CorrectParams(0); + if (!_cursor) stack->PushNULL(); + else stack->PushNative(_cursor, true); return S_OK; } @@ -243,11 +243,11 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // HasCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HasCursor") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "HasCursor") == 0) { + stack->CorrectParams(0); - if (_cursor) Stack->PushBool(true); - else Stack->PushBool(false); + if (_cursor) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -255,10 +255,10 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SetCaption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCaption") == 0) { - Stack->CorrectParams(2); - setCaption(Stack->Pop()->GetString(), Stack->Pop()->GetInt()); - Stack->PushNULL(); + else if (strcmp(name, "SetCaption") == 0) { + stack->CorrectParams(2); + setCaption(stack->Pop()->GetString(), stack->Pop()->GetInt()); + stack->PushNULL(); return S_OK; } @@ -266,13 +266,13 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // LoadSound ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadSound") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "LoadSound") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); if (SUCCEEDED(playSFX(Filename, false, false))) - Stack->PushBool(true); + stack->PushBool(true); else - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } @@ -280,16 +280,16 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // PlaySound ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlaySound") == 0) { - Stack->CorrectParams(3); + else if (strcmp(name, "PlaySound") == 0) { + stack->CorrectParams(3); const char *Filename; bool Looping; uint32 LoopStart; - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); - CScValue *val3 = Stack->Pop(); + CScValue *val1 = stack->Pop(); + CScValue *val2 = stack->Pop(); + CScValue *val3 = stack->Pop(); if (val1->_type == VAL_BOOL) { Filename = NULL; @@ -302,22 +302,22 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi LoopStart = val3->GetInt(); } - if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PlaySoundEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PlaySoundEvent") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->CorrectParams(2); const char *Filename; const char *EventName; - CScValue *val1 = Stack->Pop(); - CScValue *val2 = Stack->Pop(); + CScValue *val1 = stack->Pop(); + CScValue *val2 = stack->Pop(); if (val2->IsNULL()) { Filename = NULL; @@ -327,98 +327,98 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi EventName = val2->GetString(); } - if (FAILED(playSFX(Filename, false, true, EventName))) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(playSFX(Filename, false, true, EventName))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "StopSound") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "StopSound") == 0) { + stack->CorrectParams(0); - if (FAILED(stopSFX())) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(stopSFX())) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PauseSound ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseSound") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "PauseSound") == 0) { + stack->CorrectParams(0); - if (FAILED(pauseSFX())) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(pauseSFX())) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ResumeSound ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ResumeSound") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ResumeSound") == 0) { + stack->CorrectParams(0); - if (FAILED(resumeSFX())) Stack->PushBool(false); - else Stack->PushBool(true); + if (FAILED(resumeSFX())) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // IsSoundPlaying ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsSoundPlaying") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->CorrectParams(0); - if (_sFX && _sFX->isPlaying()) Stack->PushBool(true); - else Stack->PushBool(false); + if (_sFX && _sFX->isPlaying()) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSoundPosition ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSoundPosition") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->CorrectParams(1); - uint32 Time = Stack->Pop()->GetInt(); - if (FAILED(setSFXTime(Time))) Stack->PushBool(false); - else Stack->PushBool(true); + uint32 Time = stack->Pop()->GetInt(); + if (FAILED(setSFXTime(Time))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSoundPosition ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundPosition") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->CorrectParams(0); - if (!_sFX) Stack->PushInt(0); - else Stack->PushInt(_sFX->getPositionTime()); + if (!_sFX) stack->PushInt(0); + else stack->PushInt(_sFX->getPositionTime()); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSoundVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSoundVolume") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->CorrectParams(1); - int Volume = Stack->Pop()->GetInt(); - if (FAILED(setSFXVolume(Volume))) Stack->PushBool(false); - else Stack->PushBool(true); + int Volume = stack->Pop()->GetInt(); + if (FAILED(setSFXVolume(Volume))) stack->PushBool(false); + else stack->PushBool(true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSoundVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSoundVolume") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->CorrectParams(0); - if (!_sFX) Stack->PushInt(_sFXVolume); - else Stack->PushInt(_sFX->getVolume()); + if (!_sFX) stack->PushInt(_sFXVolume); + else stack->PushInt(_sFX->getVolume()); return S_OK; } @@ -426,14 +426,14 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SoundFXNone ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXNone") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "SoundFXNone") == 0) { + stack->CorrectParams(0); _sFXType = SFX_NONE; _sFXParam1 = 0; _sFXParam2 = 0; _sFXParam3 = 0; _sFXParam4 = 0; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -441,14 +441,14 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SoundFXEcho ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXEcho") == 0) { - Stack->CorrectParams(4); + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->CorrectParams(4); _sFXType = SFX_ECHO; - _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)Stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)Stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) - Stack->PushNULL(); + _sFXParam1 = (float)stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->Pop()->GetFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + stack->PushNULL(); return S_OK; } @@ -456,30 +456,30 @@ HRESULT CBObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SoundFXReverb ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundFXReverb") == 0) { - Stack->CorrectParams(4); + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->CorrectParams(4); _sFXType = SFX_REVERB; - _sFXParam1 = (float)Stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)Stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)Stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)Stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - Stack->PushNULL(); + _sFXParam1 = (float)stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->PushNULL(); return S_OK; } - else return CBScriptHolder::scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *Name) { +CScValue *CBObject::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("object"); return _scValue; } @@ -487,7 +487,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Caption") == 0) { + else if (strcmp(name, "Caption") == 0) { _scValue->SetString(getCaption(1)); return _scValue; } @@ -495,7 +495,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { + else if (strcmp(name, "X") == 0) { _scValue->SetInt(_posX); return _scValue; } @@ -503,7 +503,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { + else if (strcmp(name, "Y") == 0) { _scValue->SetInt(_posY); return _scValue; } @@ -511,7 +511,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _scValue->SetInt(getHeight()); return _scValue; } @@ -519,7 +519,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Ready (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Ready") == 0) { + else if (strcmp(name, "Ready") == 0) { _scValue->SetBool(_ready); return _scValue; } @@ -527,7 +527,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Movable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Movable") == 0) { + else if (strcmp(name, "Movable") == 0) { _scValue->SetBool(_movable); return _scValue; } @@ -535,7 +535,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { _scValue->SetBool(_registrable); return _scValue; } @@ -543,21 +543,21 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { _scValue->SetBool(_zoomable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotatable") == 0) { + else if (strcmp(name, "Rotatable") == 0) { _scValue->SetBool(_rotatable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { + else if (strcmp(name, "AlphaColor") == 0) { _scValue->SetInt((int)_alphaColor); return _scValue; } @@ -565,7 +565,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // BlendMode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "BlendMode") == 0) { + else if (strcmp(name, "BlendMode") == 0) { _scValue->SetInt((int)_blendMode); return _scValue; } @@ -573,7 +573,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { + else if (strcmp(name, "Scale") == 0) { if (_scale < 0) _scValue->SetNULL(); else _scValue->SetFloat((double)_scale); return _scValue; @@ -582,7 +582,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScaleX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleX") == 0) { + else if (strcmp(name, "ScaleX") == 0) { if (_scaleX < 0) _scValue->SetNULL(); else _scValue->SetFloat((double)_scaleX); return _scValue; @@ -591,7 +591,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ScaleY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleY") == 0) { + else if (strcmp(name, "ScaleY") == 0) { if (_scaleY < 0) _scValue->SetNULL(); else _scValue->SetFloat((double)_scaleY); return _scValue; @@ -600,7 +600,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // RelativeScale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeScale") == 0) { + else if (strcmp(name, "RelativeScale") == 0) { _scValue->SetFloat((double)_relativeScale); return _scValue; } @@ -608,7 +608,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Rotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotate") == 0) { + else if (strcmp(name, "Rotate") == 0) { if (!_rotateValid) _scValue->SetNULL(); else _scValue->SetFloat((double)_rotate); return _scValue; @@ -617,7 +617,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // RelativeRotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeRotate") == 0) { + else if (strcmp(name, "RelativeRotate") == 0) { _scValue->SetFloat((double)_relativeRotate); return _scValue; } @@ -625,14 +625,14 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Colorable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Colorable") == 0) { + else if (strcmp(name, "Colorable") == 0) { _scValue->SetBool(_shadowable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundPanning") == 0) { + else if (strcmp(name, "SoundPanning") == 0) { _scValue->SetBool(_autoSoundPanning); return _scValue; } @@ -640,7 +640,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SaveState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveState") == 0) { + else if (strcmp(name, "SaveState") == 0) { _scValue->SetBool(_saveState); return _scValue; } @@ -648,7 +648,7 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NonIntMouseEvents") == 0) { + else if (strcmp(name, "NonIntMouseEvents") == 0) { _scValue->SetBool(_nonIntMouseEvents); return _scValue; } @@ -656,21 +656,21 @@ CScValue *CBObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccCaption") == 0) { + else if (strcmp(name, "AccCaption") == 0) { _scValue->SetNULL(); return _scValue; } - else return CBScriptHolder::scGetProperty(Name); + else return CBScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Caption") == 0) { + if (strcmp(name, "Caption") == 0) { setCaption(Value->GetString()); return S_OK; } @@ -678,7 +678,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { + else if (strcmp(name, "X") == 0) { _posX = Value->GetInt(); afterMove(); return S_OK; @@ -687,7 +687,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { + else if (strcmp(name, "Y") == 0) { _posY = Value->GetInt(); afterMove(); return S_OK; @@ -696,7 +696,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Movable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Movable") == 0) { + else if (strcmp(name, "Movable") == 0) { _movable = Value->GetBool(); return S_OK; } @@ -704,7 +704,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Registrable") == 0 || strcmp(Name, "Interactive") == 0) { + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { _registrable = Value->GetBool(); return S_OK; } @@ -712,7 +712,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Zoomable") == 0 || strcmp(Name, "Scalable") == 0) { + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { _zoomable = Value->GetBool(); return S_OK; } @@ -720,7 +720,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotatable") == 0) { + else if (strcmp(name, "Rotatable") == 0) { _rotatable = Value->GetBool(); return S_OK; } @@ -728,7 +728,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { + else if (strcmp(name, "AlphaColor") == 0) { _alphaColor = (uint32)Value->GetInt(); return S_OK; } @@ -736,7 +736,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // BlendMode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "BlendMode") == 0) { + else if (strcmp(name, "BlendMode") == 0) { int i = Value->GetInt(); if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; _blendMode = (TSpriteBlendMode)i; @@ -746,7 +746,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale") == 0) { + else if (strcmp(name, "Scale") == 0) { if (Value->IsNULL()) _scale = -1; else _scale = (float)Value->GetFloat(); return S_OK; @@ -755,7 +755,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScaleX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleX") == 0) { + else if (strcmp(name, "ScaleX") == 0) { if (Value->IsNULL()) _scaleX = -1; else _scaleX = (float)Value->GetFloat(); return S_OK; @@ -764,7 +764,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ScaleY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleY") == 0) { + else if (strcmp(name, "ScaleY") == 0) { if (Value->IsNULL()) _scaleY = -1; else _scaleY = (float)Value->GetFloat(); return S_OK; @@ -773,7 +773,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // RelativeScale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeScale") == 0) { + else if (strcmp(name, "RelativeScale") == 0) { _relativeScale = (float)Value->GetFloat(); return S_OK; } @@ -781,7 +781,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Rotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotate") == 0) { + else if (strcmp(name, "Rotate") == 0) { if (Value->IsNULL()) { _rotate = 0.0f; _rotateValid = false; @@ -795,7 +795,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // RelativeRotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RelativeRotate") == 0) { + else if (strcmp(name, "RelativeRotate") == 0) { _relativeRotate = (float)Value->GetFloat(); return S_OK; } @@ -803,7 +803,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Colorable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Colorable") == 0) { + else if (strcmp(name, "Colorable") == 0) { _shadowable = Value->GetBool(); return S_OK; } @@ -811,7 +811,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SoundPanning") == 0) { + else if (strcmp(name, "SoundPanning") == 0) { _autoSoundPanning = Value->GetBool(); if (!_autoSoundPanning) resetSoundPan(); return S_OK; @@ -820,7 +820,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SaveState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SaveState") == 0) { + else if (strcmp(name, "SaveState") == 0) { _saveState = Value->GetBool(); return S_OK; } @@ -828,7 +828,7 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NonIntMouseEvents") == 0) { + else if (strcmp(name, "NonIntMouseEvents") == 0) { _nonIntMouseEvents = Value->GetBool(); return S_OK; } @@ -836,11 +836,11 @@ HRESULT CBObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccCaption") == 0) { + else if (strcmp(name, "AccCaption") == 0) { return S_OK; } - else return CBScriptHolder::scSetProperty(Name, Value); + else return CBScriptHolder::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index c289bd1313..44bb8c86ca 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -133,9 +133,9 @@ public: public: // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 6fc11cb8a8..d85dfaaa2f 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -210,20 +210,20 @@ HRESULT CBRegion::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // AddPoint ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "AddPoint") == 0) { - Stack->CorrectParams(2); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + if (strcmp(name, "AddPoint") == 0) { + stack->CorrectParams(2); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); _points.Add(new CBPoint(X, Y)); CreateRegion(); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -231,18 +231,18 @@ HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // InsertPoint ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertPoint") == 0) { - Stack->CorrectParams(3); - int Index = Stack->Pop()->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "InsertPoint") == 0) { + stack->CorrectParams(3); + int Index = stack->Pop()->GetInt(); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { _points.InsertAt(Index, new CBPoint(X, Y)); CreateRegion(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -250,19 +250,19 @@ HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // SetPoint ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPoint") == 0) { - Stack->CorrectParams(3); - int Index = Stack->Pop()->GetInt(); - int X = Stack->Pop()->GetInt(); - int Y = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetPoint") == 0) { + stack->CorrectParams(3); + int Index = stack->Pop()->GetInt(); + int X = stack->Pop()->GetInt(); + int Y = stack->Pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { _points[Index]->x = X; _points[Index]->y = Y; CreateRegion(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -270,9 +270,9 @@ HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // RemovePoint ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemovePoint") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(); + else if (strcmp(name, "RemovePoint") == 0) { + stack->CorrectParams(1); + int Index = stack->Pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { delete _points[Index]; @@ -281,8 +281,8 @@ HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi _points.RemoveAt(Index); CreateRegion(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -290,33 +290,33 @@ HRESULT CBRegion::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // GetPoint ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPoint") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(); + else if (strcmp(name, "GetPoint") == 0) { + stack->CorrectParams(1); + int Index = stack->Pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { - CScValue *Val = Stack->GetPushValue(); + CScValue *Val = stack->GetPushValue(); if (Val) { Val->SetProperty("X", _points[Index]->x); Val->SetProperty("Y", _points[Index]->y); } - } else Stack->PushNULL(); + } else stack->PushNULL(); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *Name) { +CScValue *CBRegion::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("region"); return _scValue; } @@ -324,7 +324,7 @@ CScValue *CBRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } @@ -332,7 +332,7 @@ CScValue *CBRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { _scValue->SetBool(_active); return _scValue; } @@ -340,21 +340,21 @@ CScValue *CBRegion::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumPoints ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumPoints") == 0) { + else if (strcmp(name, "NumPoints") == 0) { _scValue->SetInt(_points.GetSize()); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBRegion::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -362,12 +362,12 @@ HRESULT CBRegion::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Active") == 0) { + else if (strcmp(name, "Active") == 0) { _active = Value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 6e8f8bbbb2..e4050c8ede 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -57,9 +57,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 26d62ff3d0..c39e1e69f1 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -117,16 +117,16 @@ bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetIniName(const char *Name) { +void CBRegistry::SetIniName(const char *name) { delete[] _iniName; _iniName = NULL; - if (strchr(Name, '\\') == NULL && strchr(Name, '/') == NULL) { - _iniName = new char [strlen(Name) + 3]; - sprintf(_iniName, "./%s", Name); + if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { + _iniName = new char [strlen(name) + 3]; + sprintf(_iniName, "./%s", name); } else { - _iniName = new char [strlen(Name) + 1]; - strcpy(_iniName, Name); + _iniName = new char [strlen(name) + 1]; + strcpy(_iniName, name); } } diff --git a/engines/wintermute/Base/BRegistry.h b/engines/wintermute/Base/BRegistry.h index 1b2b5846b1..ac54c7ea81 100644 --- a/engines/wintermute/Base/BRegistry.h +++ b/engines/wintermute/Base/BRegistry.h @@ -35,7 +35,7 @@ namespace WinterMute { class CBRegistry : public CBBase { public: - void SetIniName(const char *Name); + void SetIniName(const char *name); char *GetIniName(); bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 0b9bc27958..9d2c39e3cb 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -109,15 +109,15 @@ HRESULT CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "DEBUG_CrashMe") == 0) { - Stack->CorrectParams(0); + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->CorrectParams(0); byte *p = 0; *p = 10; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -125,14 +125,14 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // ApplyEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ApplyEvent") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "ApplyEvent") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); HRESULT ret; ret = applyEvent(val->GetString()); - if (SUCCEEDED(ret)) Stack->PushBool(true); - else Stack->PushBool(false); + if (SUCCEEDED(ret)) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -140,9 +140,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // CanHandleEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CanHandleEvent") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(canHandleEvent(Stack->Pop()->GetString())); + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->CorrectParams(1); + stack->PushBool(canHandleEvent(stack->Pop()->GetString())); return S_OK; } @@ -150,9 +150,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // CanHandleMethod ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CanHandleMethod") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(canHandleMethod(Stack->Pop()->GetString())); + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->CorrectParams(1); + stack->PushBool(canHandleMethod(stack->Pop()->GetString())); return S_OK; } @@ -160,9 +160,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // AttachScript ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AttachScript") == 0) { - Stack->CorrectParams(1); - Stack->PushBool(SUCCEEDED(addScript(Stack->Pop()->GetString()))); + else if (strcmp(name, "AttachScript") == 0) { + stack->CorrectParams(1); + stack->PushBool(SUCCEEDED(addScript(stack->Pop()->GetString()))); return S_OK; } @@ -170,10 +170,10 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // DetachScript ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DetachScript") == 0) { - Stack->CorrectParams(2); - const char *Filename = Stack->Pop()->GetString(); - bool KillThreads = Stack->Pop()->GetBool(false); + else if (strcmp(name, "DetachScript") == 0) { + stack->CorrectParams(2); + const char *Filename = stack->Pop()->GetString(); + bool KillThreads = stack->Pop()->GetBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { @@ -182,7 +182,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac break; } } - Stack->PushBool(ret); + stack->PushBool(ret); return S_OK; } @@ -190,9 +190,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac ////////////////////////////////////////////////////////////////////////// // IsScriptRunning ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IsScriptRunning") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { @@ -200,21 +200,21 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *Script, CScStack *Stack, CScStac break; } } - Stack->PushBool(ret); + stack->PushBool(ret); return S_OK; - } else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); + } else return CBScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *Name) { +CScValue *CBScriptHolder::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("script_holder"); return _scValue; } @@ -222,7 +222,7 @@ CScValue *CBScriptHolder::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } @@ -230,24 +230,24 @@ CScValue *CBScriptHolder::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Filename") == 0) { + else if (strcmp(name, "Filename") == 0) { _scValue->SetString(_filename); return _scValue; } - else return CBScriptable::scGetProperty(Name); + else return CBScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBScriptHolder::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; - } else return CBScriptable::scSetProperty(Name, Value); + } else return CBScriptable::scSetProperty(name, Value); } @@ -311,9 +311,9 @@ HRESULT CBScriptHolder::addScript(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::removeScript(CScScript *Script) { +HRESULT CBScriptHolder::removeScript(CScScript *script) { for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] == Script) { + if (_scripts[i] == script) { _scripts.RemoveAt(i); break; } diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index aa2bb7059c..20f64f7fba 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -63,9 +63,9 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* - Stack->CorrectParams(0); - Stack->PushNULL(); - Script->RuntimeError("Call to undefined method '%s'.", Name); + stack->CorrectParams(0); + stack->PushNULL(); + script->RuntimeError("Call to undefined method '%s'.", name); return S_OK; */ diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index 40e7460b92..742ec174a2 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -71,7 +71,7 @@ public: public: // IWmeDebugObject const char *DbgGetNativeClass(); - IWmeDebugProp *DbgGetProperty(const char *Name); + IWmeDebugProp *DbgGetProperty(const char *name); }; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 8683fbb496..89acae9b55 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -507,30 +507,30 @@ HRESULT CBSprite::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetFrame") == 0) { - Stack->CorrectParams(1); - int Index = Stack->Pop()->GetInt(-1); + if (strcmp(name, "GetFrame") == 0) { + stack->CorrectParams(1); + int Index = stack->Pop()->GetInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { - Script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - Stack->PushNULL(); - } else Stack->PushNative(_frames[Index], true); + script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + stack->PushNULL(); + } else stack->PushNative(_frames[Index], true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DeleteFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteFrame") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "DeleteFrame") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { - Script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { CBFrame *Frame = (CBFrame *)Val->GetNative(); @@ -543,26 +543,26 @@ HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } } } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Reset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Reset") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Reset") == 0) { + stack->CorrectParams(0); Reset(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AddFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddFrame") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "AddFrame") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -576,19 +576,19 @@ HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi } _frames.Add(Frame); - Stack->PushNative(Frame, true); + stack->PushNative(Frame, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // InsertFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InsertFrame") == 0) { - Stack->CorrectParams(2); - int Index = Stack->Pop()->GetInt(); + else if (strcmp(name, "InsertFrame") == 0) { + stack->CorrectParams(2); + int Index = stack->Pop()->GetInt(); if (Index < 0) Index = 0; - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -602,42 +602,42 @@ HRESULT CBSprite::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi if (Index >= _frames.GetSize()) _frames.Add(Frame); else _frames.InsertAt(Index, Frame); - Stack->PushNative(Frame, true); + stack->PushNative(Frame, true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pause ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pause") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Pause") == 0) { + stack->CorrectParams(0); _paused = true; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Play ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Play") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Play") == 0) { + stack->CorrectParams(0); _paused = false; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } - else return CBScriptHolder::scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *Name) { +CScValue *CBSprite::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("sprite"); return _scValue; } @@ -645,7 +645,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumFrames") == 0) { + else if (strcmp(name, "NumFrames") == 0) { _scValue->SetInt(_frames.GetSize()); return _scValue; } @@ -653,7 +653,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CurrentFrame") == 0) { + else if (strcmp(name, "CurrentFrame") == 0) { _scValue->SetInt(_currentFrame); return _scValue; } @@ -661,7 +661,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { + else if (strcmp(name, "PixelPerfect") == 0) { _scValue->SetBool(_precise); return _scValue; } @@ -669,7 +669,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Looping ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Looping") == 0) { + else if (strcmp(name, "Looping") == 0) { _scValue->SetBool(_looping); return _scValue; } @@ -677,7 +677,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Owner (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Owner") == 0) { + else if (strcmp(name, "Owner") == 0) { if (_owner == NULL) _scValue->SetNULL(); else _scValue->SetNative(_owner, true); return _scValue; @@ -686,7 +686,7 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Finished (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Finished") == 0) { + else if (strcmp(name, "Finished") == 0) { _scValue->SetBool(_finished); return _scValue; } @@ -694,21 +694,21 @@ CScValue *CBSprite::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Paused (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Paused") == 0) { + else if (strcmp(name, "Paused") == 0) { _scValue->SetBool(_paused); return _scValue; } - else return CBScriptHolder::scGetProperty(Name); + else return CBScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBSprite::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "CurrentFrame") == 0) { + if (strcmp(name, "CurrentFrame") == 0) { _currentFrame = Value->GetInt(0); if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { _currentFrame = -1; @@ -720,7 +720,7 @@ HRESULT CBSprite::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { + else if (strcmp(name, "PixelPerfect") == 0) { _precise = Value->GetBool(); return S_OK; } @@ -728,12 +728,12 @@ HRESULT CBSprite::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Looping ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Looping") == 0) { + else if (strcmp(name, "Looping") == 0) { _looping = Value->GetBool(); return S_OK; } - else return CBScriptHolder::scSetProperty(Name, Value); + else return CBScriptHolder::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 1e35a1555f..88bc8dbe2f 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -79,9 +79,9 @@ public: HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 2e1ddf2a12..89ca0c858b 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -342,55 +342,55 @@ HRESULT CBSubFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetImage ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetImage") == 0) { - Stack->CorrectParams(0); + if (strcmp(name, "GetImage") == 0) { + stack->CorrectParams(0); - if (!_surfaceFilename) Stack->PushNULL(); - else Stack->PushString(_surfaceFilename); + if (!_surfaceFilename) stack->PushNULL(); + else stack->PushString(_surfaceFilename); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetImage") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetImage") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (Val->IsNULL()) { if (_surface) Game->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { const char *Filename = Val->GetString(); if (SUCCEEDED(setSurface(Filename))) { setDefaultRect(); - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); } return S_OK; } - else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *Name) { +CScValue *CBSubFrame::scGetProperty(const char *name) { if (!_scValue) _scValue = new CScValue(Game); _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("subframe"); return _scValue; } @@ -398,7 +398,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaColor") == 0) { + else if (strcmp(name, "AlphaColor") == 0) { _scValue->SetInt((int)_alpha); return _scValue; @@ -407,7 +407,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TransparentColor (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TransparentColor") == 0) { + else if (strcmp(name, "TransparentColor") == 0) { _scValue->SetInt((int)_transparent); return _scValue; } @@ -415,7 +415,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Is2DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is2DOnly") == 0) { + else if (strcmp(name, "Is2DOnly") == 0) { _scValue->SetBool(_2DOnly); return _scValue; } @@ -423,7 +423,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Is3DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is3DOnly") == 0) { + else if (strcmp(name, "Is3DOnly") == 0) { _scValue->SetBool(_3DOnly); return _scValue; } @@ -431,7 +431,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MirrorX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorX") == 0) { + else if (strcmp(name, "MirrorX") == 0) { _scValue->SetBool(_mirrorX); return _scValue; } @@ -439,7 +439,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MirrorY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorY") == 0) { + else if (strcmp(name, "MirrorY") == 0) { _scValue->SetBool(_mirrorY); return _scValue; } @@ -447,7 +447,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { + else if (strcmp(name, "Decoration") == 0) { _scValue->SetBool(_decoration); return _scValue; } @@ -455,7 +455,7 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // HotspotX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotX") == 0) { + else if (strcmp(name, "HotspotX") == 0) { _scValue->SetInt(_hotspotX); return _scValue; } @@ -463,21 +463,21 @@ CScValue *CBSubFrame::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // HotspotY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotY") == 0) { + else if (strcmp(name, "HotspotY") == 0) { _scValue->SetInt(_hotspotY); return _scValue; } - else return CBScriptable::scGetProperty(Name); + else return CBScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "AlphaColor") == 0) { + if (strcmp(name, "AlphaColor") == 0) { _alpha = (uint32)Value->GetInt(); return S_OK; } @@ -485,7 +485,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Is2DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is2DOnly") == 0) { + else if (strcmp(name, "Is2DOnly") == 0) { _2DOnly = Value->GetBool(); return S_OK; } @@ -493,7 +493,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Is3DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Is3DOnly") == 0) { + else if (strcmp(name, "Is3DOnly") == 0) { _3DOnly = Value->GetBool(); return S_OK; } @@ -501,7 +501,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MirrorX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorX") == 0) { + else if (strcmp(name, "MirrorX") == 0) { _mirrorX = Value->GetBool(); return S_OK; } @@ -509,7 +509,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MirrorY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MirrorY") == 0) { + else if (strcmp(name, "MirrorY") == 0) { _mirrorY = Value->GetBool(); return S_OK; } @@ -517,7 +517,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Decoration") == 0) { + else if (strcmp(name, "Decoration") == 0) { _decoration = Value->GetBool(); return S_OK; } @@ -525,7 +525,7 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // HotspotX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotX") == 0) { + else if (strcmp(name, "HotspotX") == 0) { _hotspotX = Value->GetInt(); return S_OK; } @@ -533,12 +533,12 @@ HRESULT CBSubFrame::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // HotspotY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HotspotY") == 0) { + else if (strcmp(name, "HotspotY") == 0) { _hotspotY = Value->GetInt(); return S_OK; } - else return CBScriptable::scSetProperty(Name, Value); + else return CBScriptable::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 67f3201fa1..5d4547f722 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -74,9 +74,9 @@ public: CBSurface *_surface; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 9809e50695..68b919bbe5 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -364,11 +364,11 @@ HRESULT CPartEmitter::setBorderThickness(int ThicknessLeft, int ThicknessRight, } ////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *Name) { +CPartForce *CPartEmitter::addForceByName(const char *name) { CPartForce *Force = NULL; for (int i = 0; i < _forces.GetSize(); i++) { - if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { Force = _forces[i]; break; } @@ -376,7 +376,7 @@ CPartForce *CPartEmitter::addForceByName(const char *Name) { if (!Force) { Force = new CPartForce(Game); if (Force) { - Force->setName(Name); + Force->setName(name); _forces.Add(Force); } } @@ -385,8 +385,8 @@ CPartForce *CPartEmitter::addForceByName(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::addForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { - CPartForce *Force = addForceByName(Name); +HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { + CPartForce *Force = addForceByName(name); if (!Force) return E_FAIL; Force->_type = Type; @@ -401,9 +401,9 @@ HRESULT CPartEmitter::addForce(const char *Name, CPartForce::TForceType Type, in } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::removeForce(const char *Name) { +HRESULT CPartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.GetSize(); i++) { - if (scumm_stricmp(Name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; _forces.RemoveAt(i); return S_OK; @@ -416,52 +416,52 @@ HRESULT CPartEmitter::removeForce(const char *Name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetBorder") == 0) { - Stack->CorrectParams(4); - int BorderX = Stack->Pop()->GetInt(); - int BorderY = Stack->Pop()->GetInt(); - int BorderWidth = Stack->Pop()->GetInt(); - int BorderHeight = Stack->Pop()->GetInt(); + if (strcmp(name, "SetBorder") == 0) { + stack->CorrectParams(4); + int BorderX = stack->Pop()->GetInt(); + int BorderY = stack->Pop()->GetInt(); + int BorderWidth = stack->Pop()->GetInt(); + int BorderHeight = stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + stack->PushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetBorderThickness ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetBorderThickness") == 0) { - Stack->CorrectParams(4); - int Left = Stack->Pop()->GetInt(); - int Right = Stack->Pop()->GetInt(); - int Top = Stack->Pop()->GetInt(); - int Bottom = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->CorrectParams(4); + int Left = stack->Pop()->GetInt(); + int Right = stack->Pop()->GetInt(); + int Top = stack->Pop()->GetInt(); + int Bottom = stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); + stack->PushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AddSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddSprite") == 0) { - Stack->CorrectParams(1); - const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(addSprite(SpriteFile))); + else if (strcmp(name, "AddSprite") == 0) { + stack->CorrectParams(1); + const char *SpriteFile = stack->Pop()->GetString(); + stack->PushBool(SUCCEEDED(addSprite(SpriteFile))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RemoveSprite ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveSprite") == 0) { - Stack->CorrectParams(1); - const char *SpriteFile = Stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(removeSprite(SpriteFile))); + else if (strcmp(name, "RemoveSprite") == 0) { + stack->CorrectParams(1); + const char *SpriteFile = stack->Pop()->GetString(); + stack->PushBool(SUCCEEDED(removeSprite(SpriteFile))); return S_OK; } @@ -469,10 +469,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // Start ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Start") == 0) { - Stack->CorrectParams(1); - _overheadTime = Stack->Pop()->GetInt(); - Stack->PushBool(SUCCEEDED(start())); + else if (strcmp(name, "Start") == 0) { + stack->CorrectParams(1); + _overheadTime = stack->Pop()->GetInt(); + stack->PushBool(SUCCEEDED(start())); return S_OK; } @@ -480,8 +480,8 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // Stop ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Stop") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Stop") == 0) { + stack->CorrectParams(0); for (int i = 0; i < _particles.GetSize(); i++) { delete _particles[i]; @@ -489,7 +489,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack _particles.RemoveAll(); _running = false; - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -497,10 +497,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // Pause ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pause") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Pause") == 0) { + stack->CorrectParams(0); _running = false; - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -508,10 +508,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // Resume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Resume") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Resume") == 0) { + stack->CorrectParams(0); _running = true; - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -519,13 +519,13 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // AddGlobalForce ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddGlobalForce") == 0) { - Stack->CorrectParams(3); - const char *forceName = Stack->Pop()->GetString(); - float Angle = Stack->Pop()->GetFloat(); - float Strength = Stack->Pop()->GetFloat(); + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->CorrectParams(3); + const char *forceName = stack->Pop()->GetString(); + float Angle = stack->Pop()->GetFloat(); + float Strength = stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); return S_OK; } @@ -533,15 +533,15 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // AddPointForce ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AddPointForce") == 0) { - Stack->CorrectParams(5); - const char *forceName = Stack->Pop()->GetString(); - int PosX = Stack->Pop()->GetInt(); - int PosY = Stack->Pop()->GetInt(); - float Angle = Stack->Pop()->GetFloat(); - float Strength = Stack->Pop()->GetFloat(); + else if (strcmp(name, "AddPointForce") == 0) { + stack->CorrectParams(5); + const char *forceName = stack->Pop()->GetString(); + int PosX = stack->Pop()->GetInt(); + int PosY = stack->Pop()->GetInt(); + float Angle = stack->Pop()->GetFloat(); + float Strength = stack->Pop()->GetFloat(); - Stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); return S_OK; } @@ -549,54 +549,54 @@ HRESULT CPartEmitter::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // RemoveForce ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RemoveForce") == 0) { - Stack->CorrectParams(1); - const char *forceName = Stack->Pop()->GetString(); + else if (strcmp(name, "RemoveForce") == 0) { + stack->CorrectParams(1); + const char *forceName = stack->Pop()->GetString(); - Stack->PushBool(SUCCEEDED(removeForce(forceName))); + stack->PushBool(SUCCEEDED(removeForce(forceName))); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *Name) { +CScValue *CPartEmitter::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("particle-emitter"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "X") == 0) { + else if (strcmp(name, "X") == 0) { _scValue->SetInt(_posX); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { + else if (strcmp(name, "Y") == 0) { _scValue->SetInt(_posY); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _scValue->SetInt(_width); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _scValue->SetInt(_height); return _scValue; } @@ -604,21 +604,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Scale1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale1") == 0) { + else if (strcmp(name, "Scale1") == 0) { _scValue->SetFloat(_scale1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale2") == 0) { + else if (strcmp(name, "Scale2") == 0) { _scValue->SetFloat(_scale2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleZBased") == 0) { + else if (strcmp(name, "ScaleZBased") == 0) { _scValue->SetBool(_scaleZBased); return _scValue; } @@ -626,21 +626,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Velocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity1") == 0) { + else if (strcmp(name, "Velocity1") == 0) { _scValue->SetFloat(_velocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity2") == 0) { + else if (strcmp(name, "Velocity2") == 0) { _scValue->SetFloat(_velocity2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VelocityZBased") == 0) { + else if (strcmp(name, "VelocityZBased") == 0) { _scValue->SetBool(_velocityZBased); return _scValue; } @@ -648,21 +648,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // LifeTime1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime1") == 0) { + else if (strcmp(name, "LifeTime1") == 0) { _scValue->SetInt(_lifeTime1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime2") == 0) { + else if (strcmp(name, "LifeTime2") == 0) { _scValue->SetInt(_lifeTime2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTimeZBased") == 0) { + else if (strcmp(name, "LifeTimeZBased") == 0) { _scValue->SetBool(_lifeTimeZBased); return _scValue; } @@ -670,14 +670,14 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Angle1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle1") == 0) { + else if (strcmp(name, "Angle1") == 0) { _scValue->SetInt(_angle1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle2") == 0) { + else if (strcmp(name, "Angle2") == 0) { _scValue->SetInt(_angle2); return _scValue; } @@ -685,14 +685,14 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AngVelocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity1") == 0) { + else if (strcmp(name, "AngVelocity1") == 0) { _scValue->SetFloat(_angVelocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity2") == 0) { + else if (strcmp(name, "AngVelocity2") == 0) { _scValue->SetFloat(_angVelocity2); return _scValue; } @@ -700,14 +700,14 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Rotation1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation1") == 0) { + else if (strcmp(name, "Rotation1") == 0) { _scValue->SetFloat(_rotation1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation2") == 0) { + else if (strcmp(name, "Rotation2") == 0) { _scValue->SetFloat(_rotation2); return _scValue; } @@ -715,21 +715,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Alpha1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha1") == 0) { + else if (strcmp(name, "Alpha1") == 0) { _scValue->SetInt(_alpha1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha2") == 0) { + else if (strcmp(name, "Alpha2") == 0) { _scValue->SetInt(_alpha2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaTimeBased") == 0) { + else if (strcmp(name, "AlphaTimeBased") == 0) { _scValue->SetBool(_alphaTimeBased); return _scValue; } @@ -737,14 +737,14 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MaxParticles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxParticles") == 0) { + else if (strcmp(name, "MaxParticles") == 0) { _scValue->SetInt(_maxParticles); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumLiveParticles (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumLiveParticles") == 0) { + else if (strcmp(name, "NumLiveParticles") == 0) { int NumAlive = 0; for (int i = 0; i < _particles.GetSize(); i++) { if (_particles[i] && !_particles[i]->_isDead) NumAlive++; @@ -756,21 +756,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // GenerationInterval ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationInterval") == 0) { + else if (strcmp(name, "GenerationInterval") == 0) { _scValue->SetInt(_genInterval); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationAmount") == 0) { + else if (strcmp(name, "GenerationAmount") == 0) { _scValue->SetInt(_genAmount); return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxBatches") == 0) { + else if (strcmp(name, "MaxBatches") == 0) { _scValue->SetInt(_maxBatches); return _scValue; } @@ -778,14 +778,14 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // FadeInTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeInTime") == 0) { + else if (strcmp(name, "FadeInTime") == 0) { _scValue->SetInt(_fadeInTime); return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOutTime") == 0) { + else if (strcmp(name, "FadeOutTime") == 0) { _scValue->SetInt(_fadeOutTime); return _scValue; } @@ -793,21 +793,21 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // GrowthRate1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate1") == 0) { + else if (strcmp(name, "GrowthRate1") == 0) { _scValue->SetFloat(_growthRate1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate2") == 0) { + else if (strcmp(name, "GrowthRate2") == 0) { _scValue->SetFloat(_growthRate2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExponentialGrowth") == 0) { + else if (strcmp(name, "ExponentialGrowth") == 0) { _scValue->SetBool(_exponentialGrowth); return _scValue; } @@ -815,7 +815,7 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // UseRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UseRegion") == 0) { + else if (strcmp(name, "UseRegion") == 0) { _scValue->SetBool(_useRegion); return _scValue; } @@ -823,43 +823,43 @@ CScValue *CPartEmitter::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // EmitEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmitEvent") == 0) { + else if (strcmp(name, "EmitEvent") == 0) { if (!_emitEvent) _scValue->SetNULL(); else _scValue->SetString(_emitEvent); return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "X") == 0) { + if (strcmp(name, "X") == 0) { _posX = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Y") == 0) { + else if (strcmp(name, "Y") == 0) { _posY = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _width = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _height = Value->GetInt(); return S_OK; } @@ -867,21 +867,21 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Scale1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale1") == 0) { + else if (strcmp(name, "Scale1") == 0) { _scale1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Scale2") == 0) { + else if (strcmp(name, "Scale2") == 0) { _scale2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ScaleZBased") == 0) { + else if (strcmp(name, "ScaleZBased") == 0) { _scaleZBased = Value->GetBool(); return S_OK; } @@ -889,21 +889,21 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Velocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity1") == 0) { + else if (strcmp(name, "Velocity1") == 0) { _velocity1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Velocity2") == 0) { + else if (strcmp(name, "Velocity2") == 0) { _velocity2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VelocityZBased") == 0) { + else if (strcmp(name, "VelocityZBased") == 0) { _velocityZBased = Value->GetBool(); return S_OK; } @@ -911,21 +911,21 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // LifeTime1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime1") == 0) { + else if (strcmp(name, "LifeTime1") == 0) { _lifeTime1 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTime2") == 0) { + else if (strcmp(name, "LifeTime2") == 0) { _lifeTime2 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LifeTimeZBased") == 0) { + else if (strcmp(name, "LifeTimeZBased") == 0) { _lifeTimeZBased = Value->GetBool(); return S_OK; } @@ -933,14 +933,14 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Angle1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle1") == 0) { + else if (strcmp(name, "Angle1") == 0) { _angle1 = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Angle2") == 0) { + else if (strcmp(name, "Angle2") == 0) { _angle2 = Value->GetInt(); return S_OK; } @@ -948,14 +948,14 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AngVelocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity1") == 0) { + else if (strcmp(name, "AngVelocity1") == 0) { _angVelocity1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AngVelocity2") == 0) { + else if (strcmp(name, "AngVelocity2") == 0) { _angVelocity2 = Value->GetFloat(); return S_OK; } @@ -963,14 +963,14 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Rotation1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation1") == 0) { + else if (strcmp(name, "Rotation1") == 0) { _rotation1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Rotation2") == 0) { + else if (strcmp(name, "Rotation2") == 0) { _rotation2 = Value->GetFloat(); return S_OK; } @@ -978,7 +978,7 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Alpha1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha1") == 0) { + else if (strcmp(name, "Alpha1") == 0) { _alpha1 = Value->GetInt(); if (_alpha1 < 0) _alpha1 = 0; if (_alpha1 > 255) _alpha1 = 255; @@ -987,7 +987,7 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Alpha2") == 0) { + else if (strcmp(name, "Alpha2") == 0) { _alpha2 = Value->GetInt(); if (_alpha2 < 0) _alpha2 = 0; if (_alpha2 > 255) _alpha2 = 255; @@ -996,7 +996,7 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AlphaTimeBased") == 0) { + else if (strcmp(name, "AlphaTimeBased") == 0) { _alphaTimeBased = Value->GetBool(); return S_OK; } @@ -1004,7 +1004,7 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MaxParticles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxParticles") == 0) { + else if (strcmp(name, "MaxParticles") == 0) { _maxParticles = Value->GetInt(); return S_OK; } @@ -1012,21 +1012,21 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // GenerationInterval ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationInterval") == 0) { + else if (strcmp(name, "GenerationInterval") == 0) { _genInterval = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GenerationAmount") == 0) { + else if (strcmp(name, "GenerationAmount") == 0) { _genAmount = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxBatches") == 0) { + else if (strcmp(name, "MaxBatches") == 0) { _maxBatches = Value->GetInt(); return S_OK; } @@ -1034,14 +1034,14 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // FadeInTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeInTime") == 0) { + else if (strcmp(name, "FadeInTime") == 0) { _fadeInTime = Value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeOutTime") == 0) { + else if (strcmp(name, "FadeOutTime") == 0) { _fadeOutTime = Value->GetInt(); return S_OK; } @@ -1049,21 +1049,21 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // GrowthRate1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate1") == 0) { + else if (strcmp(name, "GrowthRate1") == 0) { _growthRate1 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GrowthRate2") == 0) { + else if (strcmp(name, "GrowthRate2") == 0) { _growthRate2 = Value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ExponentialGrowth") == 0) { + else if (strcmp(name, "ExponentialGrowth") == 0) { _exponentialGrowth = Value->GetBool(); return S_OK; } @@ -1071,7 +1071,7 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // UseRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "UseRegion") == 0) { + else if (strcmp(name, "UseRegion") == 0) { _useRegion = Value->GetBool(); return S_OK; } @@ -1079,14 +1079,14 @@ HRESULT CPartEmitter::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // EmitEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "EmitEvent") == 0) { + else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 1fd061f95b..b4e751be8f 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -112,20 +112,20 @@ public: HRESULT setBorder(int X, int Y, int Width, int Height); HRESULT setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); - HRESULT addForce(const char *Name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); - HRESULT removeForce(const char *Name); + HRESULT addForce(const char *name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT removeForce(const char *name); CBArray _forces; // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - CPartForce *addForceByName(const char *Name); + CPartForce *addForceByName(const char *name); int static compareZ(const void *Obj1, const void *Obj2); HRESULT initParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); HRESULT updateInternal(uint32 CurrentTime, uint32 TimerDelta); diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index b7d69bd2f2..5cabe598a5 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -41,19 +41,19 @@ CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { +CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; _values = new CScValue(Game); - int NumParams = Stack->Pop()->GetInt(0); + int NumParams = stack->Pop()->GetInt(0); - if (NumParams == 1) _length = Stack->Pop()->GetInt(0); + if (NumParams == 1) _length = stack->Pop()->GetInt(0); else if (NumParams > 1) { _length = NumParams; char ParamName[20]; for (int i = 0; i < NumParams; i++) { sprintf(ParamName, "%d", i); - _values->SetProp(ParamName, Stack->Pop()); + _values->SetProp(ParamName, stack->Pop()); } } } @@ -93,20 +93,20 @@ const char *CSXArray::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Push") == 0) { - int NumParams = Stack->Pop()->GetInt(0); + if (strcmp(name, "Push") == 0) { + int NumParams = stack->Pop()->GetInt(0); char ParamName[20]; for (int i = 0; i < NumParams; i++) { _length++; sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, Stack->Pop(), true); + _values->SetProp(ParamName, stack->Pop(), true); } - Stack->PushInt(_length); + stack->PushInt(_length); return S_OK; } @@ -114,17 +114,17 @@ HRESULT CSXArray::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// // Pop ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Pop") == 0) { + if (strcmp(name, "Pop") == 0) { - Stack->CorrectParams(0); + stack->CorrectParams(0); if (_length > 0) { char ParamName[20]; sprintf(ParamName, "%d", _length - 1); - Stack->Push(_values->GetProp(ParamName)); + stack->Push(_values->GetProp(ParamName)); _values->DeleteProp(ParamName); _length--; - } else Stack->PushNULL(); + } else stack->PushNULL(); return S_OK; } @@ -134,13 +134,13 @@ HRESULT CSXArray::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Thi ////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *Name) { +CScValue *CSXArray::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("array"); return _scValue; } @@ -148,7 +148,7 @@ CScValue *CSXArray::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { + else if (strcmp(name, "Length") == 0) { _scValue->SetInt(_length); return _scValue; } @@ -158,7 +158,7 @@ CScValue *CSXArray::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// else { char ParamName[20]; - if (ValidNumber(Name, ParamName)) { + if (ValidNumber(name, ParamName)) { return _values->GetProp(ParamName); } else return _scValue; } @@ -166,11 +166,11 @@ CScValue *CSXArray::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXArray::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Length") == 0) { + if (strcmp(name, "Length") == 0) { int OrigLength = _length; _length = MAX(Value->GetInt(0), 0); @@ -189,7 +189,7 @@ HRESULT CSXArray::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else { char ParamName[20]; - if (ValidNumber(Name, ParamName)) { + if (ValidNumber(name, ParamName)) { int Index = atoi(ParamName); if (Index >= _length) _length = Index + 1; return _values->SetProp(ParamName, Value); diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index 938e020d93..51e0a0047c 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -41,9 +41,9 @@ public: CSXArray(CBGame *inGame, CScStack *Stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); - CScValue *scGetProperty(const char *Name); - HRESULT scSetProperty(const char *Name, CScValue *Value); - HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + CScValue *scGetProperty(const char *name); + HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); int _length; CScValue *_values; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 4bb2a3b32a..039a9abe0a 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -39,18 +39,18 @@ CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(6); +CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->CorrectParams(6); memset(&_tm, 0, sizeof(_tm)); - CScValue *valYear = Stack->Pop(); + CScValue *valYear = stack->Pop(); _tm.tm_year = valYear->GetInt() - 1900; - _tm.tm_mon = Stack->Pop()->GetInt() - 1; - _tm.tm_mday = Stack->Pop()->GetInt(); - _tm.tm_hour = Stack->Pop()->GetInt(); - _tm.tm_min = Stack->Pop()->GetInt(); - _tm.tm_sec = Stack->Pop()->GetInt(); + _tm.tm_mon = stack->Pop()->GetInt() - 1; + _tm.tm_mday = stack->Pop()->GetInt(); + _tm.tm_hour = stack->Pop()->GetInt(); + _tm.tm_min = stack->Pop()->GetInt(); + _tm.tm_sec = stack->Pop()->GetInt(); if (valYear->IsNULL()) { g_system->getTimeAndDate(_tm); @@ -75,62 +75,62 @@ const char *CSXDate::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetYear") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_year + 1900); + if (strcmp(name, "GetYear") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_year + 1900); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMonth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMonth") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_mon + 1); + else if (strcmp(name, "GetMonth") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_mon + 1); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetDate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDate") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_mday); + else if (strcmp(name, "GetDate") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_mday); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetHours ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHours") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_hour); + else if (strcmp(name, "GetHours") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_hour); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMinutes ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetMinutes") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_min); + else if (strcmp(name, "GetMinutes") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_min); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSeconds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetSeconds") == 0) { - Stack->CorrectParams(0); - Stack->PushInt(_tm.tm_sec); + else if (strcmp(name, "GetSeconds") == 0) { + stack->CorrectParams(0); + stack->PushInt(_tm.tm_sec); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetWeekday ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetWeekday") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GetWeekday") == 0) { + stack->CorrectParams(0); warning("GetWeekday returns a wrong value on purpose"); - Stack->PushInt(_tm.tm_mday % 7); + stack->PushInt(_tm.tm_mday % 7); return S_OK; } @@ -138,55 +138,55 @@ HRESULT CSXDate::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // SetYear ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetYear") == 0) { - Stack->CorrectParams(1); - _tm.tm_year = Stack->Pop()->GetInt() - 1900; - Stack->PushNULL(); + else if (strcmp(name, "SetYear") == 0) { + stack->CorrectParams(1); + _tm.tm_year = stack->Pop()->GetInt() - 1900; + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMonth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMonth") == 0) { - Stack->CorrectParams(1); - _tm.tm_mon = Stack->Pop()->GetInt() - 1; - Stack->PushNULL(); + else if (strcmp(name, "SetMonth") == 0) { + stack->CorrectParams(1); + _tm.tm_mon = stack->Pop()->GetInt() - 1; + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetDate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDate") == 0) { - Stack->CorrectParams(1); - _tm.tm_mday = Stack->Pop()->GetInt(); - Stack->PushNULL(); + else if (strcmp(name, "SetDate") == 0) { + stack->CorrectParams(1); + _tm.tm_mday = stack->Pop()->GetInt(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetHours ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHours") == 0) { - Stack->CorrectParams(1); - _tm.tm_hour = Stack->Pop()->GetInt(); - Stack->PushNULL(); + else if (strcmp(name, "SetHours") == 0) { + stack->CorrectParams(1); + _tm.tm_hour = stack->Pop()->GetInt(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMinutes ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetMinutes") == 0) { - Stack->CorrectParams(1); - _tm.tm_min = Stack->Pop()->GetInt(); - Stack->PushNULL(); + else if (strcmp(name, "SetMinutes") == 0) { + stack->CorrectParams(1); + _tm.tm_min = stack->Pop()->GetInt(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSeconds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetSeconds") == 0) { - Stack->CorrectParams(1); - _tm.tm_sec = Stack->Pop()->GetInt(); - Stack->PushNULL(); + else if (strcmp(name, "SetSeconds") == 0) { + stack->CorrectParams(1); + _tm.tm_sec = stack->Pop()->GetInt(); + stack->PushNULL(); return S_OK; } @@ -194,10 +194,10 @@ HRESULT CSXDate::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // SetCurrentTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetCurrentTime") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->CorrectParams(0); g_system->getTimeAndDate(_tm); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -207,13 +207,13 @@ HRESULT CSXDate::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *Name) { +CScValue *CSXDate::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("date"); return _scValue; } @@ -223,12 +223,12 @@ CScValue *CSXDate::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXDate::scSetProperty(const char *name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Name")==0){ + if(strcmp(name, "Name")==0){ setName(Value->GetString()); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 28d2590c31..7d658ea826 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -40,9 +40,9 @@ public: DECLARE_PERSISTENT(CSXDate, CBScriptable) CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); - CScValue *scGetProperty(const char *Name); - HRESULT scSetProperty(const char *Name, CScValue *Value); - HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + CScValue *scGetProperty(const char *name); + HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); char *_string; TimeDate _tm; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index ec115ca50b..b7eb794e81 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -55,9 +55,9 @@ CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); +CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); _filename = NULL; if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); @@ -105,38 +105,38 @@ const char *CSXFile::scToString() { #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetFilename") == 0) { - Stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + if (strcmp(name, "SetFilename") == 0) { + stack->CorrectParams(1); + const char *Filename = stack->Pop()->GetString(); cleanup(); CBUtils::SetString(&_filename, Filename); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // OpenAsText / OpenAsBinary ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->CorrectParams(1); Close(); - _mode = Stack->Pop()->GetInt(1); + _mode = stack->Pop()->GetInt(1); if (_mode < 1 || _mode > 3) { - Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name); + script->RuntimeError("File.%s: invalid access mode. Setting read mode.", name); _mode = 1; } if (_mode == 1) { _readFile = Game->_fileManager->openFile(_filename); if (!_readFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + //script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); Close(); - } else _textMode = strcmp(Name, "OpenAsText") == 0; + } else _textMode = strcmp(name, "OpenAsText") == 0; } else { - if (strcmp(Name, "OpenAsText") == 0) { + if (strcmp(name, "OpenAsText") == 0) { if (_mode == 2) _writeFile = fopen(_filename, "w+"); else _writeFile = fopen(_filename, "a+"); } else { @@ -145,13 +145,13 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } if (!_writeFile) { - //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + //script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); Close(); - } else _textMode = strcmp(Name, "OpenAsText") == 0; + } else _textMode = strcmp(name, "OpenAsText") == 0; } - if (_readFile || _writeFile) Stack->PushBool(true); - else Stack->PushBool(false); + if (_readFile || _writeFile) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -159,24 +159,24 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // Close ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Close") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Close") == 0) { + stack->CorrectParams(0); Close(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetPosition ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPosition") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetPosition") == 0) { + stack->CorrectParams(1); if (_mode == 0) { - Script->RuntimeError("File.%s: File is not open", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File is not open", name); + stack->PushBool(false); } else { - int Pos = Stack->Pop()->GetInt(); - Stack->PushBool(SetPos(Pos)); + int Pos = stack->Pop()->GetInt(); + stack->PushBool(SetPos(Pos)); } return S_OK; } @@ -184,34 +184,34 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // Delete ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Delete") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Delete") == 0) { + stack->CorrectParams(0); Close(); - Stack->PushBool(CBPlatform::DeleteFile(_filename) != false); + stack->PushBool(CBPlatform::DeleteFile(_filename) != false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Copy ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Copy") == 0) { - Stack->CorrectParams(2); - const char *Dest = Stack->Pop()->GetString(); - bool Overwrite = Stack->Pop()->GetBool(true); + else if (strcmp(name, "Copy") == 0) { + stack->CorrectParams(2); + const char *Dest = stack->Pop()->GetString(); + bool Overwrite = stack->Pop()->GetBool(true); Close(); - Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); + stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ReadLine ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadLine") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadLine") == 0) { + stack->CorrectParams(0); if (!_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open in text mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open in text mode.", name); + stack->PushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -245,8 +245,8 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } Buf[Counter] = '\0'; - if (!FoundNewLine && Counter == 0) Stack->PushNULL(); - else Stack->PushString((char *)Buf); + if (!FoundNewLine && Counter == 0) stack->PushNULL(); + else stack->PushString((char *)Buf); free(Buf); @@ -256,13 +256,13 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadText ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadText") == 0) { - Stack->CorrectParams(1); - int TextLen = Stack->Pop()->GetInt(); + else if (strcmp(name, "ReadText") == 0) { + stack->CorrectParams(1); + int TextLen = stack->Pop()->GetInt(); if (!_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open in text mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open in text mode.", name); + stack->PushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -292,8 +292,8 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This } Buf[Counter] = '\0'; - if (TextLen > 0 && Counter == 0) Stack->PushNULL(); - else Stack->PushString((char *)Buf); + if (TextLen > 0 && Counter == 0) stack->PushNULL(); + else stack->PushString((char *)Buf); free(Buf); @@ -303,20 +303,20 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteLine / WriteText ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) { - Stack->CorrectParams(1); - const char *Line = Stack->Pop()->GetString(); + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->CorrectParams(1); + const char *Line = stack->Pop()->GetString(); if (!_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in text mode.", name); + stack->PushBool(false); return S_OK; } - if (strcmp(Name, "WriteLine") == 0) + if (strcmp(name, "WriteLine") == 0) fprintf((FILE *)_writeFile, "%s\n", Line); else fprintf((FILE *)_writeFile, "%s", Line); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -325,16 +325,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadBool ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadBool") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadBool") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } bool Val; - if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) Stack->PushBool(Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->PushBool(Val); + else stack->PushNULL(); return S_OK; } @@ -342,16 +342,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadByte ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadByte") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadByte") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } byte Val; - if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) Stack->PushInt(Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->PushInt(Val); + else stack->PushNULL(); return S_OK; } @@ -359,16 +359,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadShort ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadShort") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadShort") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } short Val; - if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) Stack->PushInt(65536 + Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->PushInt(65536 + Val); + else stack->PushNULL(); return S_OK; } @@ -376,16 +376,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadInt / ReadLong ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } int Val; - if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) Stack->PushInt(Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->PushInt(Val); + else stack->PushNULL(); return S_OK; } @@ -393,16 +393,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadFloat ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadFloat") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadFloat") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } float Val; - if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) Stack->PushFloat(Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->PushFloat(Val); + else stack->PushNULL(); return S_OK; } @@ -410,16 +410,16 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadDouble ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadDouble") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadDouble") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } double Val; - if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) Stack->PushFloat(Val); - else Stack->PushNULL(); + if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->PushFloat(Val); + else stack->PushNULL(); return S_OK; } @@ -427,11 +427,11 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // ReadString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ReadString") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ReadString") == 0) { + stack->CorrectParams(0); if (_textMode || !_readFile) { - Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name); - Stack->PushNULL(); + script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + stack->PushNULL(); return S_OK; } uint32 Size; @@ -440,11 +440,11 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This if (Str) { if (_readFile->read(Str, Size) == Size) { Str[Size] = '\0'; - Stack->PushString((char *)Str); + stack->PushString((char *)Str); } delete [] Str; - } else Stack->PushNULL(); - } else Stack->PushNULL(); + } else stack->PushNULL(); + } else stack->PushNULL(); return S_OK; } @@ -452,17 +452,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteBool ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteBool") == 0) { - Stack->CorrectParams(1); - bool Val = Stack->Pop()->GetBool(); + else if (strcmp(name, "WriteBool") == 0) { + stack->CorrectParams(1); + bool Val = stack->Pop()->GetBool(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -470,17 +470,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteByte ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteByte") == 0) { - Stack->CorrectParams(1); - byte Val = Stack->Pop()->GetInt(); + else if (strcmp(name, "WriteByte") == 0) { + stack->CorrectParams(1); + byte Val = stack->Pop()->GetInt(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -488,17 +488,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteShort ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteShort") == 0) { - Stack->CorrectParams(1); - short Val = Stack->Pop()->GetInt(); + else if (strcmp(name, "WriteShort") == 0) { + stack->CorrectParams(1); + short Val = stack->Pop()->GetInt(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -506,17 +506,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteInt / WriteLong ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteInt") == 0 || strcmp(Name, "WriteLong") == 0) { - Stack->CorrectParams(1); - int Val = Stack->Pop()->GetInt(); + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->CorrectParams(1); + int Val = stack->Pop()->GetInt(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -524,17 +524,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteFloat ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteFloat") == 0) { - Stack->CorrectParams(1); - float Val = Stack->Pop()->GetFloat(); + else if (strcmp(name, "WriteFloat") == 0) { + stack->CorrectParams(1); + float Val = stack->Pop()->GetFloat(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -542,17 +542,17 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteDouble ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteDouble") == 0) { - Stack->CorrectParams(1); - double Val = Stack->Pop()->GetFloat(); + else if (strcmp(name, "WriteDouble") == 0) { + stack->CorrectParams(1); + double Val = stack->Pop()->GetFloat(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -560,13 +560,13 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// // WriteString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "WriteString") == 0) { - Stack->CorrectParams(1); - const char *Val = Stack->Pop()->GetString(); + else if (strcmp(name, "WriteString") == 0) { + stack->CorrectParams(1); + const char *Val = stack->Pop()->GetString(); if (_textMode || !_writeFile) { - Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name); - Stack->PushBool(false); + script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + stack->PushBool(false); return S_OK; } @@ -574,24 +574,24 @@ HRESULT CSXFile::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile); fwrite(Val, Size, 1, (FILE *)_writeFile); - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } - else return CBScriptable::scCallMethod(Script, Stack, ThisStack, Name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *Name) { +CScValue *CSXFile::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("file"); return _scValue; } @@ -599,7 +599,7 @@ CScValue *CSXFile::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Filename") == 0) { + if (strcmp(name, "Filename") == 0) { _scValue->SetString(_filename); return _scValue; } @@ -607,7 +607,7 @@ CScValue *CSXFile::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Position (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Position") == 0) { + else if (strcmp(name, "Position") == 0) { _scValue->SetInt(GetPos()); return _scValue; } @@ -615,7 +615,7 @@ CScValue *CSXFile::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { + else if (strcmp(name, "Length") == 0) { _scValue->SetInt(GetLength()); return _scValue; } @@ -623,7 +623,7 @@ CScValue *CSXFile::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TextMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextMode") == 0) { + else if (strcmp(name, "TextMode") == 0) { _scValue->SetBool(_textMode); return _scValue; } @@ -631,22 +631,22 @@ CScValue *CSXFile::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // AccessMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "AccessMode") == 0) { + else if (strcmp(name, "AccessMode") == 0) { _scValue->SetInt(_mode); return _scValue; } - else return CBScriptable::scGetProperty(Name); + else return CBScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXFile::scSetProperty(const char *name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Length")==0){ + if(strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(Value->GetInt(0), 0); @@ -659,7 +659,7 @@ HRESULT CSXFile::scSetProperty(const char *Name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::scSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(name, Value); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index d3076620c2..39c7f7b954 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -40,9 +40,9 @@ class CBFile; class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *Name); - HRESULT scSetProperty(const char *Name, CScValue *Value); - HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + CScValue *scGetProperty(const char *name); + HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index f6ee46e33b..a9337af1a8 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -58,189 +58,189 @@ CSXMath::~CSXMath() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Abs") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(fabs(Stack->Pop()->GetFloat())); + if (strcmp(name, "Abs") == 0) { + stack->CorrectParams(1); + stack->PushFloat(fabs(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Acos ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Acos") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(acos(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Acos") == 0) { + stack->CorrectParams(1); + stack->PushFloat(acos(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Asin ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Asin") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(asin(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Asin") == 0) { + stack->CorrectParams(1); + stack->PushFloat(asin(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Atan ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Atan") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(atan(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Atan") == 0) { + stack->CorrectParams(1); + stack->PushFloat(atan(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Atan2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Atan2") == 0) { - Stack->CorrectParams(2); - double y = Stack->Pop()->GetFloat(); - double x = Stack->Pop()->GetFloat(); - Stack->PushFloat(atan2(y, x)); + else if (strcmp(name, "Atan2") == 0) { + stack->CorrectParams(2); + double y = stack->Pop()->GetFloat(); + double x = stack->Pop()->GetFloat(); + stack->PushFloat(atan2(y, x)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Ceil ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Ceil") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(ceil(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Ceil") == 0) { + stack->CorrectParams(1); + stack->PushFloat(ceil(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Cos ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Cos") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(cos(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Cos") == 0) { + stack->CorrectParams(1); + stack->PushFloat(cos(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Cosh ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Cosh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(cosh(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Cosh") == 0) { + stack->CorrectParams(1); + stack->PushFloat(cosh(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Exp ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exp") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(exp(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Exp") == 0) { + stack->CorrectParams(1); + stack->PushFloat(exp(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Floor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Floor") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(floor(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Floor") == 0) { + stack->CorrectParams(1); + stack->PushFloat(floor(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Log ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Log") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(log(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Log") == 0) { + stack->CorrectParams(1); + stack->PushFloat(log(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Log10 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Log10") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(log10(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Log10") == 0) { + stack->CorrectParams(1); + stack->PushFloat(log10(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pow") == 0) { - Stack->CorrectParams(2); - double x = Stack->Pop()->GetFloat(); - double y = Stack->Pop()->GetFloat(); + else if (strcmp(name, "Pow") == 0) { + stack->CorrectParams(2); + double x = stack->Pop()->GetFloat(); + double y = stack->Pop()->GetFloat(); - Stack->PushFloat(pow(x, y)); + stack->PushFloat(pow(x, y)); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Sin ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sin") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sin(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Sin") == 0) { + stack->CorrectParams(1); + stack->PushFloat(sin(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Sinh ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sinh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sinh(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Sinh") == 0) { + stack->CorrectParams(1); + stack->PushFloat(sinh(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Tan ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Tan") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(tan(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Tan") == 0) { + stack->CorrectParams(1); + stack->PushFloat(tan(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Tanh ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Tanh") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(tanh(DegreeToRadian(Stack->Pop()->GetFloat()))); + else if (strcmp(name, "Tanh") == 0) { + stack->CorrectParams(1); + stack->PushFloat(tanh(DegreeToRadian(stack->Pop()->GetFloat()))); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Sqrt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Sqrt") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(sqrt(Stack->Pop()->GetFloat())); + else if (strcmp(name, "Sqrt") == 0) { + stack->CorrectParams(1); + stack->PushFloat(sqrt(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DegToRad ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DegToRad") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(DegreeToRadian(Stack->Pop()->GetFloat())); + else if (strcmp(name, "DegToRad") == 0) { + stack->CorrectParams(1); + stack->PushFloat(DegreeToRadian(stack->Pop()->GetFloat())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // RadToDeg ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "RadToDeg") == 0) { - Stack->CorrectParams(1); - Stack->PushFloat(RadianToDegree(Stack->Pop()->GetFloat())); + else if (strcmp(name, "RadToDeg") == 0) { + stack->CorrectParams(1); + stack->PushFloat(RadianToDegree(stack->Pop()->GetFloat())); return S_OK; } @@ -249,13 +249,13 @@ HRESULT CSXMath::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *This ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *Name) { +CScValue *CSXMath::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("math"); return _scValue; } @@ -263,7 +263,7 @@ CScValue *CSXMath::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PI ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PI") == 0) { + else if (strcmp(name, "PI") == 0) { _scValue->SetFloat(PI); return _scValue; } diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index 355bb78890..ac3dc45115 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -39,8 +39,8 @@ public: DECLARE_PERSISTENT(CSXMath, CBScriptable) CSXMath(CBGame *inGame); virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); private: double DegreeToRadian(double Value); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 7a128d5899..f65f800a4e 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -42,12 +42,12 @@ CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { - Stack->CorrectParams(1); +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->CorrectParams(1); _buffer = NULL; _size = 0; - int NewSize = Stack->Pop()->GetInt(); + int NewSize = stack->Pop()->GetInt(); Resize(MAX(0, NewSize)); } @@ -102,15 +102,15 @@ HRESULT CSXMemBuffer::Resize(int NewSize) { } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::CheckBounds(CScScript *Script, int Start, int Length) { +bool CSXMemBuffer::CheckBounds(CScScript *script, int start, int length) { if (_buffer == NULL) { - Script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } if (_size == 0) return true; - if (Start < 0 || Length == 0 || Start + Length > _size) { - Script->RuntimeError("Set/Get method call is out of bounds"); + if (start < 0 || length == 0 || start + length > _size) { + script->RuntimeError("Set/Get method call is out of bounds"); return false; } else return true; } @@ -122,16 +122,16 @@ const char *CSXMemBuffer::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSize") == 0) { - Stack->CorrectParams(1); - int NewSize = Stack->Pop()->GetInt(); + if (strcmp(name, "SetSize") == 0) { + stack->CorrectParams(1); + int NewSize = stack->Pop()->GetInt(); NewSize = MAX(0, NewSize); - if (SUCCEEDED(Resize(NewSize))) Stack->PushBool(true); - else Stack->PushBool(false); + if (SUCCEEDED(Resize(NewSize))) stack->PushBool(true); + else stack->PushBool(false); return S_OK; } @@ -139,11 +139,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetBool ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetBool") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushNULL(); - else Stack->PushBool(*(bool *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetBool") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(bool))) stack->PushNULL(); + else stack->PushBool(*(bool *)((byte *)_buffer + Start)); return S_OK; } @@ -151,11 +151,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetByte ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetByte") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushNULL(); - else Stack->PushInt(*(byte *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetByte") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(byte))) stack->PushNULL(); + else stack->PushInt(*(byte *)((byte *)_buffer + Start)); return S_OK; } @@ -163,11 +163,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetShort ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetShort") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushNULL(); - else Stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetShort") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(short))) stack->PushNULL(); + else stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -175,11 +175,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetInt / GetLong ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInt") == 0 || strcmp(Name, "GetLong") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushNULL(); - else Stack->PushInt(*(int *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(int))) stack->PushNULL(); + else stack->PushInt(*(int *)((byte *)_buffer + Start)); return S_OK; } @@ -187,11 +187,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetFloat ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFloat") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushNULL(); - else Stack->PushFloat(*(float *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetFloat") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(float))) stack->PushNULL(); + else stack->PushFloat(*(float *)((byte *)_buffer + Start)); return S_OK; } @@ -199,11 +199,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetDouble ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDouble") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushNULL(); - else Stack->PushFloat(*(double *)((byte *)_buffer + Start)); + else if (strcmp(name, "GetDouble") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(double))) stack->PushNULL(); + else stack->PushFloat(*(double *)((byte *)_buffer + Start)); return S_OK; } @@ -211,10 +211,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetString") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - int Length = Stack->Pop()->GetInt(); + else if (strcmp(name, "GetString") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + int Length = stack->Pop()->GetInt(); // find end of string if (Length == 0 && Start >= 0 && Start < _size) { @@ -226,12 +226,12 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack } } - if (!CheckBounds(Script, Start, Length)) Stack->PushNULL(); + if (!CheckBounds(script, Start, Length)) stack->PushNULL(); else { char *Str = new char[Length + 1]; strncpy(Str, (const char *)_buffer + Start, Length); Str[Length] = '\0'; - Stack->PushString(Str); + stack->PushString(Str); delete [] Str; } return S_OK; @@ -240,14 +240,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // GetPointer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPointer") == 0) { - Stack->CorrectParams(1); - int Start = Stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushNULL(); + else if (strcmp(name, "GetPointer") == 0) { + stack->CorrectParams(1); + int Start = stack->Pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(void *))) stack->PushNULL(); else { void *Pointer = *(void **)((byte *)_buffer + Start); CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); - Stack->PushNative(Buf, false); + stack->PushNative(Buf, false); } return S_OK; } @@ -255,15 +255,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetBool ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetBool") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - bool Val = Stack->Pop()->GetBool(); + else if (strcmp(name, "SetBool") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + bool Val = stack->Pop()->GetBool(); - if (!CheckBounds(Script, Start, sizeof(bool))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(bool))) stack->PushBool(false); else { *(bool *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -271,15 +271,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetByte ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetByte") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - byte Val = (byte)Stack->Pop()->GetInt(); + else if (strcmp(name, "SetByte") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + byte Val = (byte)stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(byte))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(byte))) stack->PushBool(false); else { *(byte *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -287,15 +287,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetShort ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetShort") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - short Val = (short)Stack->Pop()->GetInt(); + else if (strcmp(name, "SetShort") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + short Val = (short)stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(short))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(short))) stack->PushBool(false); else { *(short *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -303,15 +303,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetInt / SetLong ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInt") == 0 || strcmp(Name, "SetLong") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - int Val = Stack->Pop()->GetInt(); + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + int Val = stack->Pop()->GetInt(); - if (!CheckBounds(Script, Start, sizeof(int))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(int))) stack->PushBool(false); else { *(int *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -319,15 +319,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetFloat ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFloat") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - float Val = (float)Stack->Pop()->GetFloat(); + else if (strcmp(name, "SetFloat") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + float Val = (float)stack->Pop()->GetFloat(); - if (!CheckBounds(Script, Start, sizeof(float))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(float))) stack->PushBool(false); else { *(float *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -335,15 +335,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetDouble ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDouble") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - double Val = Stack->Pop()->GetFloat(); + else if (strcmp(name, "SetDouble") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + double Val = stack->Pop()->GetFloat(); - if (!CheckBounds(Script, Start, sizeof(double))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(double))) stack->PushBool(false); else { *(double *)((byte *)_buffer + Start) = Val; - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -351,15 +351,15 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetString") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - const char *Val = Stack->Pop()->GetString(); + else if (strcmp(name, "SetString") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + const char *Val = stack->Pop()->GetString(); - if (!CheckBounds(Script, Start, strlen(Val) + 1)) Stack->PushBool(false); + if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->PushBool(false); else { memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); - Stack->PushBool(true); + stack->PushBool(true); } return S_OK; } @@ -367,20 +367,20 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // SetPointer ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPointer") == 0) { - Stack->CorrectParams(2); - int Start = Stack->Pop()->GetInt(); - /* CScValue *Val = */ Stack->Pop(); + else if (strcmp(name, "SetPointer") == 0) { + stack->CorrectParams(2); + int Start = stack->Pop()->GetInt(); + /* CScValue *Val = */ stack->Pop(); - if (!CheckBounds(Script, Start, sizeof(void *))) Stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(void *))) stack->PushBool(false); else { /* int Pointer = (int)Val->GetMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - Stack->PushBool(true); + stack->PushBool(true); */ // TODO fix - Stack->PushBool(false); + stack->PushBool(false); } return S_OK; @@ -389,8 +389,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// // DEBUG_Dump ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DEBUG_Dump") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->CorrectParams(0); if (_buffer && _size) { warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); Common::DumpFile f; @@ -398,7 +398,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack f.write(_buffer, _size); f.close(); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -407,13 +407,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *Script, CScStack *Stack, CScStack ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *Name) { +CScValue *CSXMemBuffer::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("membuffer"); return _scValue; } @@ -421,22 +421,22 @@ CScValue *CSXMemBuffer::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Size (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Size") == 0) { + if (strcmp(name, "Size") == 0) { _scValue->SetInt(_size); return _scValue; } - else return CBScriptable::scGetProperty(Name); + else return CBScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *Value) { /* ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(Name, "Length")==0){ + if(strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(Value->GetInt(0), 0); @@ -449,7 +449,7 @@ HRESULT CSXMemBuffer::scSetProperty(const char *Name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::scSetProperty(Name, Value); + else*/ return CBScriptable::scSetProperty(name, Value); } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index a14f09bfd6..ba62162cc4 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -38,9 +38,9 @@ class CSXMemBuffer : public CBScriptable { public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *Name); - HRESULT scSetProperty(const char *Name, CScValue *Value); - HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + CScValue *scGetProperty(const char *name); + HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXMemBuffer(CBGame *inGame, CScStack *Stack); CSXMemBuffer(CBGame *inGame, void *Buffer); diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index bb7f0eeb42..3c39b3f266 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -129,8 +129,8 @@ public: DECLARE_PERSISTENT(CSXStore, CBObject) CSXStore(CBGame *inGame); virtual ~CSXStore(); - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void afterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 35343d095a..4db6ad413c 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -44,12 +44,12 @@ CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) { +CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _string = NULL; _capacity = 0; - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (Val->IsInt()) { _capacity = MAX(0, Val->GetInt()); @@ -99,14 +99,14 @@ void CSXString::scSetString(const char *Val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Substring") == 0) { - Stack->CorrectParams(2); - int start = Stack->Pop()->GetInt(); - int end = Stack->Pop()->GetInt(); + if (strcmp(name, "Substring") == 0) { + stack->CorrectParams(2); + int start = stack->Pop()->GetInt(); + int end = stack->Pop()->GetInt(); if (end < start) CBUtils::Swap(&start, &end); @@ -121,11 +121,11 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th WideString subStr(str.c_str() + start, end - start + 1); if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { - // Stack->PushNULL(); + // stack->PushNULL(); // } return S_OK; @@ -134,15 +134,15 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Substr ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Substr") == 0) { - Stack->CorrectParams(2); - int start = Stack->Pop()->GetInt(); + else if (strcmp(name, "Substr") == 0) { + stack->CorrectParams(2); + int start = stack->Pop()->GetInt(); - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); int len = val->GetInt(); if (!val->IsNULL() && len <= 0) { - Stack->PushString(""); + stack->PushString(""); return S_OK; } @@ -159,11 +159,11 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th WideString subStr(str.c_str() + start, len); if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); else - Stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { -// Stack->PushNULL(); +// stack->PushNULL(); // } return S_OK; @@ -172,8 +172,8 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // ToUpperCase ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToUpperCase") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ToUpperCase") == 0) { + stack->CorrectParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -184,9 +184,9 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th StringUtil::ToUpperCase(str); if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->PushString(StringUtil::WideToUtf8(str).c_str()); else - Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->PushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -194,8 +194,8 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // ToLowerCase ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ToLowerCase") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "ToLowerCase") == 0) { + stack->CorrectParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -206,9 +206,9 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th StringUtil::ToLowerCase(str); if (Game->_textEncoding == TEXT_UTF8) - Stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->PushString(StringUtil::WideToUtf8(str).c_str()); else - Stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->PushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -216,11 +216,11 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // IndexOf ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "IndexOf") == 0) { - Stack->CorrectParams(2); + else if (strcmp(name, "IndexOf") == 0) { + stack->CorrectParams(2); - const char *strToFind = Stack->Pop()->GetString(); - int index = Stack->Pop()->GetInt(); + const char *strToFind = stack->Pop()->GetString(); + int index = stack->Pop()->GetInt(); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -235,7 +235,7 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th toFind = StringUtil::AnsiToWide(strToFind); int indexOf = StringUtil::IndexOf(str, toFind, index); - Stack->PushInt(indexOf); + stack->PushInt(indexOf); return S_OK; } @@ -243,15 +243,15 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Split ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Split") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "Split") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); char Separators[MAX_PATH] = ","; if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); CSXArray *Array = new CSXArray(Game); if (!Array) { - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } @@ -308,7 +308,7 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th Val = NULL; } - Stack->PushNative(Array, false); + stack->PushNative(Array, false); return S_OK; } @@ -317,20 +317,20 @@ HRESULT CSXString::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *Name) { +CScValue *CSXString::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("string"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Length") == 0) { + else if (strcmp(name, "Length") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(_string); _scValue->SetInt(wstr.size()); @@ -342,7 +342,7 @@ CScValue *CSXString::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Capacity") == 0) { + else if (strcmp(name, "Capacity") == 0) { _scValue->SetInt(_capacity); return _scValue; } @@ -352,11 +352,11 @@ CScValue *CSXString::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CSXString::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Capacity") == 0) { + if (strcmp(name, "Capacity") == 0) { int NewCap = Value->GetInt(); if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); else if (NewCap != _capacity) { diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index 1adc0cad1e..5f662c3289 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -38,9 +38,9 @@ class CSXString : public CBScriptable { public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *Name); - HRESULT scSetProperty(const char *Name, CScValue *Value); - HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + CScValue *scGetProperty(const char *name); + HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void scSetString(const char *Val); const char *scToString(); void SetStringVal(const char *Val); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 6ec70a561a..9c443df509 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -559,10 +559,10 @@ HRESULT CScEngine::ResetObject(CBObject *Object) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResetScript(CScScript *Script) { +HRESULT CScEngine::ResetScript(CScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == Script) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { _scripts[i]->finish(); } } @@ -639,9 +639,9 @@ void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *D ////////////////////////////////////////////////////////////////////////// -bool CScEngine::IsValidScript(CScScript *Script) { +bool CScEngine::IsValidScript(CScScript *script) { for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] == Script) return true; + if (_scripts[i] == script) return true; } return false; } @@ -735,18 +735,18 @@ HRESULT CScEngine::RefreshScriptBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { +HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *script) { if (!Game->GetDebugMgr()->_enabled) return S_OK; - if (!Script || !Script->_filename) return E_FAIL; + if (!script || !script->_filename) return E_FAIL; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), Script->_filename) == 0) { - Script->_breakpoints.Copy(_breakpoints[i]->_lines); + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { + script->_breakpoints.Copy(_breakpoints[i]->_lines); return S_OK; } } - if (Script->_breakpoints.GetSize() > 0) Script->_breakpoints.RemoveAll(); + if (script->_breakpoints.GetSize() > 0) script->_breakpoints.RemoveAll(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index c7fb8eb3a8..703034964e 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -42,8 +42,8 @@ typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSi typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); -typedef int (*DLL_DEFINE_FUNCTION)(const char *Name); /* Was non-const, changed to silence warnings */ -typedef int (*DLL_DEFINE_VARIABLE)(const char *Name); /* Was non-const, changed to silence warnings */ +typedef int (*DLL_DEFINE_FUNCTION)(const char *name); /* Was non-const, changed to silence warnings */ +typedef int (*DLL_DEFINE_VARIABLE)(const char *name); /* Was non-const, changed to silence warnings */ typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); @@ -99,14 +99,14 @@ public: HRESULT AddBreakpoint(const char *ScriptFilename, int Line); HRESULT RemoveBreakpoint(const char *ScriptFilename, int Line); HRESULT RefreshScriptBreakpoints(); - HRESULT RefreshScriptBreakpoints(CScScript *Script); + HRESULT RefreshScriptBreakpoints(CScScript *script); HRESULT SaveBreakpoints(); HRESULT LoadBreakpoints(); HRESULT ClearGlobals(bool IncludingNatives = false); HRESULT TickUnbreakable(); HRESULT RemoveFinishedScripts(); - bool IsValidScript(CScScript *Script); + bool IsValidScript(CScScript *script); void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); @@ -123,7 +123,7 @@ public: HRESULT PauseAll(); void editorCleanup(); HRESULT ResetObject(CBObject *Object); - HRESULT ResetScript(CScScript *Script); + HRESULT ResetScript(CScScript *script); HRESULT EmptyScriptCache(); byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 01827b378e..6e43ac6e0d 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1054,53 +1054,53 @@ HRESULT CScScript::ExecuteInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetFuncPos(const char *Name) { +uint32 CScScript::GetFuncPos(const char *name) { for (int i = 0; i < _numFunctions; i++) { - if (strcmp(Name, _functions[i].name) == 0) return _functions[i].pos; + if (strcmp(name, _functions[i].name) == 0) return _functions[i].pos; } return 0; } ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetMethodPos(const char *Name) { +uint32 CScScript::GetMethodPos(const char *name) { for (int i = 0; i < _numMethods; i++) { - if (strcmp(Name, _methods[i].name) == 0) return _methods[i].pos; + if (strcmp(name, _methods[i].name) == 0) return _methods[i].pos; } return 0; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::GetVar(char *Name) { +CScValue *CScScript::GetVar(char *name) { CScValue *ret = NULL; // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->GetTop()->PropExists(Name)) ret = _scopeStack->GetTop()->GetProp(Name); + if (_scopeStack->GetTop()->PropExists(name)) ret = _scopeStack->GetTop()->GetProp(name); } // script globals if (ret == NULL) { - if (_globals->PropExists(Name)) ret = _globals->GetProp(Name); + if (_globals->PropExists(name)) ret = _globals->GetProp(name); } // engine globals if (ret == NULL) { - if (_engine->_globals->PropExists(Name)) ret = _engine->_globals->GetProp(Name); + if (_engine->_globals->PropExists(name)) ret = _engine->_globals->GetProp(name); } if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", Name); - Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", Name, _filename, _currentLine); + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); CScValue *Val = new CScValue(Game); CScValue *Scope = _scopeStack->GetTop(); if (Scope) { - Scope->SetProp(Name, Val); - ret = _scopeStack->GetTop()->GetProp(Name); + Scope->SetProp(name, Val); + ret = _scopeStack->GetTop()->GetProp(name); } else { - _globals->SetProp(Name, Val); - ret = _globals->GetProp(Name); + _globals->SetProp(name, Val); + ret = _globals->GetProp(name); } delete Val; } @@ -1271,9 +1271,9 @@ CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetEventPos(const char *Name) { +uint32 CScScript::GetEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(Name, _events[i].name) == 0) return _events[i].pos; + if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; } return 0; } @@ -1317,22 +1317,22 @@ HRESULT CScScript::Resume() { ////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::GetExternal(char *Name) { +CScScript::TExternalFunction *CScScript::GetExternal(char *name) { for (int i = 0; i < _numExternals; i++) { - if (strcmp(Name, _externals[i].name) == 0) return &_externals[i]; + if (strcmp(name, _externals[i].name) == 0) return &_externals[i]; } return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function) { +HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *Function) { #ifndef __WIN32__ Game->LOG(0, "External functions are not supported on this platform."); - Stack->CorrectParams(0); - Stack->PushNULL(); + stack->CorrectParams(0); + stack->PushNULL(); return E_FAIL; #else @@ -1345,11 +1345,11 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: if (pFunc) { int i; Success = true; - Stack->CorrectParams(Function->nu_params); + stack->CorrectParams(Function->nu_params); CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); for (i = 0; i < Function->nu_params; i++) { - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); switch (Function->params[i]) { case TYPE_BOOL: Buffer->PutDWORD((uint32)Val->GetBool()); @@ -1399,34 +1399,34 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: // return switch (Function->returns) { case TYPE_BOOL: - Stack->PushBool((byte)ret != 0); + stack->PushBool((byte)ret != 0); break; case TYPE_LONG: - Stack->PushInt(ret); + stack->PushInt(ret); break; case TYPE_BYTE: - Stack->PushInt((byte)ret); + stack->PushInt((byte)ret); break; break; case TYPE_STRING: - Stack->PushString((char *)ret); + stack->PushString((char *)ret); break; case TYPE_MEMBUFFER: { CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); - Stack->PushNative(Buf, false); + stack->PushNative(Buf, false); } break; case TYPE_FLOAT: { uint32 dw = GetST0(); - Stack->PushFloat(*((float *)&dw)); + stack->PushFloat(*((float *)&dw)); break; } case TYPE_DOUBLE: - Stack->PushFloat(GetST0Double()); + stack->PushFloat(GetST0Double()); break; default: - Stack->PushNULL(); + stack->PushNULL(); } if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); @@ -1434,8 +1434,8 @@ HRESULT CScScript::ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript: } else RuntimeError("Error loading DLL '%s'", Function->dll_name); if (!Success) { - Stack->CorrectParams(0); - Stack->PushNULL(); + stack->CorrectParams(0); + stack->PushNULL(); } if (hDll) FreeLibrary(hDll); @@ -1525,15 +1525,15 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CopyParameters(CScStack *Stack) { +HRESULT CScScript::CopyParameters(CScStack *stack) { int i; - int NumParams = Stack->Pop()->GetInt(); + int NumParams = stack->Pop()->GetInt(); for (i = NumParams - 1; i >= 0; i--) { - _stack->Push(Stack->GetAt(i)); + _stack->Push(stack->GetAt(i)); } _stack->PushInt(NumParams); - for (i = 0; i < NumParams; i++) Stack->Pop(); + for (i = 0; i < NumParams; i++) stack->Pop(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 4f6cc50332..308c6d9a86 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -52,7 +52,7 @@ public: CScScript *_parentScript; bool _unbreakable; HRESULT FinishThreads(); - HRESULT CopyParameters(CScStack *Stack); + HRESULT CopyParameters(CScStack *stack); void afterLoad(); @@ -87,10 +87,10 @@ public: CScScript *_waitScript; TScriptState _state; TScriptState _origState; - CScValue *GetVar(char *Name); - uint32 GetFuncPos(const char *Name); - uint32 GetEventPos(const char *Name); - uint32 GetMethodPos(const char *Name); + CScValue *GetVar(char *name); + uint32 GetFuncPos(const char *name); + uint32 GetEventPos(const char *name); + uint32 GetMethodPos(const char *name); typedef struct { uint32 magic; uint32 version; @@ -166,7 +166,7 @@ public: bool _methodThread; char *_threadEvent; CBScriptHolder *_owner; - CScScript::TExternalFunction *GetExternal(char *Name); + CScScript::TExternalFunction *GetExternal(char *name); HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); private: HRESULT InitScript(); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index eab345f393..8409de7b96 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -156,10 +156,10 @@ CScValue::~CScValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::GetProp(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(Name); +CScValue *CScValue::GetProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(name); - if (_type == VAL_STRING && strcmp(Name, "Length") == 0) { + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { Game->_scValue->_type = VAL_INT; #if 0 // TODO: Remove FreeType-dependency @@ -178,20 +178,20 @@ CScValue *CScValue::GetProp(const char *Name) { CScValue *ret = NULL; - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(Name); + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); if (ret == NULL) { - _valIter = _valObject.find(Name); + _valIter = _valObject.find(name); if (_valIter != _valObject.end()) ret = _valIter->_value; } return ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DeleteProp(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(Name); +HRESULT CScValue::DeleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(name); - _valIter = _valObject.find(Name); + _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { delete _valIter->_value; _valIter->_value = NULL; @@ -203,18 +203,18 @@ HRESULT CScValue::DeleteProp(const char *Name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { - if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(Name, Val); +HRESULT CScValue::SetProp(const char *name, CScValue *Val, bool CopyWhole, bool SetAsConst) { + if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(name, Val); HRESULT ret = E_FAIL; if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(Name, Val); + ret = _valNative->scSetProperty(name, Val); } if (FAILED(ret)) { CScValue *val = NULL; - _valIter = _valObject.find(Name); + _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { val = _valIter->_value; } @@ -223,7 +223,7 @@ HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool val->Copy(Val, CopyWhole); val->_isConstVar = SetAsConst; - _valObject[Name] = val; + _valObject[name] = val; if (_type != VAL_NATIVE) _type = VAL_OBJECT; @@ -247,9 +247,9 @@ HRESULT CScValue::SetProp(const char *Name, CScValue *Val, bool CopyWhole, bool ////////////////////////////////////////////////////////////////////////// -bool CScValue::PropExists(const char *Name) { - if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(Name); - _valIter = _valObject.find(Name); +bool CScValue::PropExists(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(name); + _valIter = _valObject.find(name); return (_valIter != _valObject.end()); } @@ -861,10 +861,10 @@ int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID) { +HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *script, unsigned int ScopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - Client->OnVariableInit(Type, Script, ScopeID, _valIter->_value, _valIter->_key.c_str()); + Client->OnVariableInit(Type, script, ScopeID, _valIter->_value, _valIter->_key.c_str()); _valIter++; } return S_OK; diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 6ee0981020..90c783c9ce 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -43,7 +43,7 @@ class CBScriptable; class CScValue : public CBBase, public IWmeDebugProp { public: - HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *Script, unsigned int ScopeID); + HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *script, unsigned int ScopeID); static int Compare(CScValue *Val1, CScValue *Val2); static int CompareStrict(CScValue *Val1, CScValue *Val2); @@ -55,7 +55,7 @@ public: HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); void SetValue(CScValue *Val); bool _persistent; - bool PropExists(const char *Name); + bool PropExists(const char *name); void Copy(CScValue *orig, bool CopyWhole = false); void SetStringVal(const char *Val); TValType GetType(); @@ -65,7 +65,7 @@ public: const char *GetString(); void *GetMemBuffer(); CBScriptable *GetNative(); - HRESULT DeleteProp(const char *Name); + HRESULT DeleteProp(const char *name); void DeleteProps(); void CleanProps(bool IncludingNatives); void SetBool(bool Val); @@ -84,8 +84,8 @@ public: bool IsFloat(); bool IsInt(); bool IsObject(); - HRESULT SetProp(const char *Name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); - CScValue *GetProp(const char *Name); + HRESULT SetProp(const char *name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); + CScValue *GetProp(const char *name); CBScriptable *_valNative; CScValue *_valRef; protected: diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index d991085792..ff51134321 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -43,10 +43,10 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *Stack): CBObject(inGame) { - int NumParams = Stack->Pop()->GetInt(0); +CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { + int NumParams = stack->Pop()->GetInt(0); for (int i = 0; i < NumParams; i++) { - addScript(Stack->Pop()->GetString()); + addScript(stack->Pop()->GetString()); } } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 58440d0095..ea20e29490 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -666,21 +666,21 @@ void CUIButton::press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetDisabledFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + if (strcmp(name, "SetDisabledFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); if (Val->IsNULL()) { _fontDisable = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontDisable != NULL); + stack->PushBool(_fontDisable != NULL); } return S_OK; } @@ -688,17 +688,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetHoverFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHoverFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetHoverFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); if (Val->IsNULL()) { _fontHover = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { _fontHover = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontHover != NULL); + stack->PushBool(_fontHover != NULL); } return S_OK; } @@ -706,17 +706,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetPressedFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPressedFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetPressedFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); if (Val->IsNULL()) { _fontPress = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { _fontPress = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontPress != NULL); + stack->PushBool(_fontPress != NULL); } return S_OK; } @@ -724,17 +724,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetFocusedFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFocusedFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetFocusedFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); if (Val->IsNULL()) { _fontFocus = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_fontFocus != NULL); + stack->PushBool(_fontFocus != NULL); } return S_OK; } @@ -742,17 +742,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetDisabledImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetDisabledImage") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetDisabledImage") == 0) { + stack->CorrectParams(1); delete _imageDisable; _imageDisable = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) { delete _imageDisable; _imageDisable = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -760,10 +760,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetDisabledImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDisabledImage") == 0) { - Stack->CorrectParams(0); - if (!_imageDisable || !_imageDisable->_filename) Stack->PushNULL(); - else Stack->PushString(_imageDisable->_filename); + else if (strcmp(name, "GetDisabledImage") == 0) { + stack->CorrectParams(0); + if (!_imageDisable || !_imageDisable->_filename) stack->PushNULL(); + else stack->PushString(_imageDisable->_filename); return S_OK; } @@ -771,10 +771,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetDisabledImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetDisabledImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageDisable) Stack->PushNULL(); - else Stack->PushNative(_imageDisable, true); + else if (strcmp(name, "GetDisabledImageObject") == 0) { + stack->CorrectParams(0); + if (!_imageDisable) stack->PushNULL(); + else stack->PushNative(_imageDisable, true); return S_OK; } @@ -783,17 +783,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetHoverImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetHoverImage") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetHoverImage") == 0) { + stack->CorrectParams(1); delete _imageHover; _imageHover = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) { delete _imageHover; _imageHover = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -801,10 +801,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetHoverImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverImage") == 0) { - Stack->CorrectParams(0); - if (!_imageHover || !_imageHover->_filename) Stack->PushNULL(); - else Stack->PushString(_imageHover->_filename); + else if (strcmp(name, "GetHoverImage") == 0) { + stack->CorrectParams(0); + if (!_imageHover || !_imageHover->_filename) stack->PushNULL(); + else stack->PushString(_imageHover->_filename); return S_OK; } @@ -812,10 +812,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetHoverImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetHoverImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageHover) Stack->PushNULL(); - else Stack->PushNative(_imageHover, true); + else if (strcmp(name, "GetHoverImageObject") == 0) { + stack->CorrectParams(0); + if (!_imageHover) stack->PushNULL(); + else stack->PushNative(_imageHover, true); return S_OK; } @@ -823,17 +823,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetPressedImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetPressedImage") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetPressedImage") == 0) { + stack->CorrectParams(1); delete _imagePress; _imagePress = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) { delete _imagePress; _imagePress = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -841,10 +841,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetPressedImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPressedImage") == 0) { - Stack->CorrectParams(0); - if (!_imagePress || !_imagePress->_filename) Stack->PushNULL(); - else Stack->PushString(_imagePress->_filename); + else if (strcmp(name, "GetPressedImage") == 0) { + stack->CorrectParams(0); + if (!_imagePress || !_imagePress->_filename) stack->PushNULL(); + else stack->PushString(_imagePress->_filename); return S_OK; } @@ -852,10 +852,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetPressedImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetPressedImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imagePress) Stack->PushNULL(); - else Stack->PushNative(_imagePress, true); + else if (strcmp(name, "GetPressedImageObject") == 0) { + stack->CorrectParams(0); + if (!_imagePress) stack->PushNULL(); + else stack->PushNative(_imagePress, true); return S_OK; } @@ -863,17 +863,17 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetFocusedImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetFocusedImage") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetFocusedImage") == 0) { + stack->CorrectParams(1); delete _imageFocus; _imageFocus = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) { delete _imageFocus; _imageFocus = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -881,10 +881,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetFocusedImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFocusedImage") == 0) { - Stack->CorrectParams(0); - if (!_imageFocus || !_imageFocus->_filename) Stack->PushNULL(); - else Stack->PushString(_imageFocus->_filename); + else if (strcmp(name, "GetFocusedImage") == 0) { + stack->CorrectParams(0); + if (!_imageFocus || !_imageFocus->_filename) stack->PushNULL(); + else stack->PushString(_imageFocus->_filename); return S_OK; } @@ -892,10 +892,10 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetFocusedImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetFocusedImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageFocus) Stack->PushNULL(); - else Stack->PushNative(_imageFocus, true); + else if (strcmp(name, "GetFocusedImageObject") == 0) { + stack->CorrectParams(0); + if (!_imageFocus) stack->PushNULL(); + else stack->PushNative(_imageFocus, true); return S_OK; } @@ -903,31 +903,31 @@ HRESULT CUIButton::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Press ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Press") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Press") == 0) { + stack->CorrectParams(0); if (_visible && !_disable) { _oneTimePress = true; _oneTimePressTime = CBPlatform::GetTime(); } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } - else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::scGetProperty(const char *Name) { +CScValue *CUIButton::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("button"); return _scValue; } @@ -935,7 +935,7 @@ CScValue *CUIButton::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextAlign") == 0) { + else if (strcmp(name, "TextAlign") == 0) { _scValue->SetInt(_align); return _scValue; } @@ -943,35 +943,35 @@ CScValue *CUIButton::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Focusable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focusable") == 0) { + else if (strcmp(name, "Focusable") == 0) { _scValue->SetBool(_canFocus); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pressed") == 0) { + else if (strcmp(name, "Pressed") == 0) { _scValue->SetBool(_stayPressed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { + else if (strcmp(name, "PixelPerfect") == 0) { _scValue->SetBool(_pixelPerfect); return _scValue; } - else return CUIObject::scGetProperty(Name); + else return CUIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIButton::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "TextAlign") == 0) { + if (strcmp(name, "TextAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _align = (TTextAlign)i; @@ -981,26 +981,26 @@ HRESULT CUIButton::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Focusable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focusable") == 0) { + else if (strcmp(name, "Focusable") == 0) { _canFocus = Value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Pressed") == 0) { + else if (strcmp(name, "Pressed") == 0) { _stayPressed = Value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PixelPerfect") == 0) { + else if (strcmp(name, "PixelPerfect") == 0) { _pixelPerfect = Value->GetBool(); return S_OK; } - else return CUIObject::scSetProperty(Name, Value); + else return CUIObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index bc3ba87257..07bc18bc65 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -68,9 +68,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index cc98830898..4678f81d9a 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -361,32 +361,32 @@ HRESULT CUIEdit::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetSelectedFont") == 0) { - Stack->CorrectParams(1); + if (strcmp(name, "SetSelectedFont") == 0) { + stack->CorrectParams(1); if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(_fontSelected != NULL); + _fontSelected = Game->_fontStorage->AddFont(stack->Pop()->GetString()); + stack->PushBool(_fontSelected != NULL); return S_OK; } - else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::scGetProperty(const char *Name) { +CScValue *CUIEdit::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("editor"); return _scValue; } @@ -394,7 +394,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelStart") == 0) { + else if (strcmp(name, "SelStart") == 0) { _scValue->SetInt(_selStart); return _scValue; } @@ -402,7 +402,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SelEnd ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelEnd") == 0) { + else if (strcmp(name, "SelEnd") == 0) { _scValue->SetInt(_selEnd); return _scValue; } @@ -410,7 +410,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorBlinkRate") == 0) { + else if (strcmp(name, "CursorBlinkRate") == 0) { _scValue->SetInt(_cursorBlinkRate); return _scValue; } @@ -418,7 +418,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // CursorChar ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorChar") == 0) { + else if (strcmp(name, "CursorChar") == 0) { _scValue->SetString(_cursorChar); return _scValue; } @@ -426,7 +426,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // FrameWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FrameWidth") == 0) { + else if (strcmp(name, "FrameWidth") == 0) { _scValue->SetInt(_frameWidth); return _scValue; } @@ -434,7 +434,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // MaxLength ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxLength") == 0) { + else if (strcmp(name, "MaxLength") == 0) { _scValue->SetInt(_maxLength); return _scValue; } @@ -442,7 +442,7 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { + else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::AnsiToWide(_text); _scValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); @@ -452,16 +452,16 @@ CScValue *CUIEdit::scGetProperty(const char *Name) { return _scValue; } - else return CUIObject::scGetProperty(Name); + else return CUIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SelStart") == 0) { + if (strcmp(name, "SelStart") == 0) { _selStart = Value->GetInt(); _selStart = MAX(_selStart, 0); _selStart = MIN((size_t)_selStart, strlen(_text)); @@ -471,7 +471,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SelEnd ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SelEnd") == 0) { + else if (strcmp(name, "SelEnd") == 0) { _selEnd = Value->GetInt(); _selEnd = MAX(_selEnd, 0); _selEnd = MIN((size_t)_selEnd, strlen(_text)); @@ -481,7 +481,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorBlinkRate") == 0) { + else if (strcmp(name, "CursorBlinkRate") == 0) { _cursorBlinkRate = Value->GetInt(); return S_OK; } @@ -489,7 +489,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // CursorChar ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CursorChar") == 0) { + else if (strcmp(name, "CursorChar") == 0) { setCursorChar(Value->GetString()); return S_OK; } @@ -497,7 +497,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // FrameWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FrameWidth") == 0) { + else if (strcmp(name, "FrameWidth") == 0) { _frameWidth = Value->GetInt(); return S_OK; } @@ -505,7 +505,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // MaxLength ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MaxLength") == 0) { + else if (strcmp(name, "MaxLength") == 0) { _maxLength = Value->GetInt(); return S_OK; } @@ -513,7 +513,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { + else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); setText(StringUtil::WideToAnsi(wstr).c_str()); @@ -523,7 +523,7 @@ HRESULT CUIEdit::scSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::scSetProperty(Name, Value); + else return CUIObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 34f849f9fa..8477e6f9d5 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -61,9 +61,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index deefe965e3..afba22cc49 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -251,15 +251,15 @@ HRESULT CUIEntity::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetEntity") == 0) { - Stack->CorrectParams(0); + if (strcmp(name, "GetEntity") == 0) { + stack->CorrectParams(0); - if (_entity) Stack->PushNative(_entity, true); - else Stack->PushNULL(); + if (_entity) stack->PushNative(_entity, true); + else stack->PushNULL(); return S_OK; } @@ -267,31 +267,31 @@ HRESULT CUIEntity::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetEntity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetEntity") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetEntity") == 0) { + stack->CorrectParams(1); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (SUCCEEDED(setEntity(Filename))) - Stack->PushBool(true); + stack->PushBool(true); else - Stack->PushBool(false); + stack->PushBool(false); return S_OK; } - else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::scGetProperty(const char *Name) { +CScValue *CUIEntity::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("entity container"); return _scValue; } @@ -299,25 +299,25 @@ CScValue *CUIEntity::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Freezable") == 0) { + else if (strcmp(name, "Freezable") == 0) { if (_entity) _scValue->SetBool(_entity->_freezable); else _scValue->SetBool(false); return _scValue; } - else return CUIObject::scGetProperty(Name); + else return CUIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIEntity::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Freezable") == 0) { + if (strcmp(name, "Freezable") == 0) { if (_entity) _entity->makeFreezable(Value->GetBool()); return S_OK; - } else return CUIObject::scSetProperty(Name, Value); + } else return CUIObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index bd588f7d37..55c5790ef5 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -47,9 +47,9 @@ public: HRESULT setEntity(const char *Filename); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 46bfe399f2..c23415287c 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -137,21 +137,21 @@ void CUIObject::correctSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SetFont") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + if (strcmp(name, "SetFont") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); if (_font) Game->_fontStorage->RemoveFont(_font); if (Val->IsNULL()) { _font = NULL; - Stack->PushBool(true); + stack->PushBool(true); } else { _font = Game->_fontStorage->AddFont(Val->GetString()); - Stack->PushBool(_font != NULL); + stack->PushBool(_font != NULL); } return S_OK; } @@ -159,16 +159,16 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetImage") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "SetImage") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); /* const char *Filename = */ Val->GetString(); delete _image; _image = NULL; if (Val->IsNULL()) { - Stack->PushBool(true); + stack->PushBool(true); return S_OK; } @@ -176,8 +176,8 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (!_image || FAILED(_image->loadFile(Val->GetString()))) { delete _image; _image = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -185,10 +185,10 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetImage") == 0) { - Stack->CorrectParams(0); - if (!_image || !_image->_filename) Stack->PushNULL(); - else Stack->PushString(_image->_filename); + else if (strcmp(name, "GetImage") == 0) { + stack->CorrectParams(0); + if (!_image || !_image->_filename) stack->PushNULL(); + else stack->PushString(_image->_filename); return S_OK; } @@ -196,10 +196,10 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetImageObject") == 0) { - Stack->CorrectParams(0); - if (!_image) Stack->PushNULL(); - else Stack->PushNative(_image, true); + else if (strcmp(name, "GetImageObject") == 0) { + stack->CorrectParams(0); + if (!_image) stack->PushNULL(); + else stack->PushNative(_image, true); return S_OK; } @@ -207,25 +207,25 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Focus ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Focus") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Focus") == 0) { + stack->CorrectParams(0); focus(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // MoveAfter / MoveBefore ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveAfter") == 0 || strcmp(Name, "MoveBefore") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { + stack->CorrectParams(1); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; int i; bool found = false; - CScValue *val = Stack->Pop(); + CScValue *val = stack->Pop(); // find directly if (val->IsNative()) { CUIObject *widget = (CUIObject *)val->GetNative(); @@ -251,21 +251,21 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th bool done = false; for (int j = 0; j < win->_widgets.GetSize(); j++) { if (win->_widgets[j] == this) { - if (strcmp(Name, "MoveAfter") == 0) i++; + if (strcmp(name, "MoveAfter") == 0) i++; if (j >= i) j++; win->_widgets.InsertAt(i, this); win->_widgets.RemoveAt(j); done = true; - Stack->PushBool(true); + stack->PushBool(true); break; } } - if (!done) Stack->PushBool(false); - } else Stack->PushBool(false); + if (!done) stack->PushBool(false); + } else stack->PushBool(false); - } else Stack->PushBool(false); + } else stack->PushBool(false); return S_OK; } @@ -273,8 +273,8 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // MoveToBottom ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveToBottom") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "MoveToBottom") == 0) { + stack->CorrectParams(0); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; @@ -285,8 +285,8 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th break; } } - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } @@ -294,8 +294,8 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // MoveToTop ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "MoveToTop") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "MoveToTop") == 0) { + stack->CorrectParams(0); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; @@ -306,24 +306,24 @@ HRESULT CUIObject::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th break; } } - Stack->PushBool(true); - } else Stack->PushBool(false); + stack->PushBool(true); + } else stack->PushBool(false); return S_OK; } - else return CBObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CBObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::scGetProperty(const char *Name) { +CScValue *CUIObject::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("ui_object"); return _scValue; } @@ -331,7 +331,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Name") == 0) { + else if (strcmp(name, "Name") == 0) { _scValue->SetString(_name); return _scValue; } @@ -339,7 +339,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Parent (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Parent") == 0) { + else if (strcmp(name, "Parent") == 0) { _scValue->SetNative(_parent, true); return _scValue; } @@ -347,7 +347,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ParentNotify ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParentNotify") == 0) { + else if (strcmp(name, "ParentNotify") == 0) { _scValue->SetBool(_parentNotify); return _scValue; } @@ -355,7 +355,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _scValue->SetInt(_width); return _scValue; } @@ -363,7 +363,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _scValue->SetInt(_height); return _scValue; } @@ -371,7 +371,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Visible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Visible") == 0) { + else if (strcmp(name, "Visible") == 0) { _scValue->SetBool(_visible); return _scValue; } @@ -379,7 +379,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Disabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Disabled") == 0) { + else if (strcmp(name, "Disabled") == 0) { _scValue->SetBool(_disable); return _scValue; } @@ -387,7 +387,7 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { + else if (strcmp(name, "Text") == 0) { _scValue->SetString(_text); return _scValue; } @@ -395,13 +395,13 @@ CScValue *CUIObject::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NextSibling (RO) / PrevSibling (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NextSibling") == 0 || strcmp(Name, "PrevSibling") == 0) { + else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { _scValue->SetNULL(); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; for (int i = 0; i < win->_widgets.GetSize(); i++) { if (win->_widgets[i] == this) { - if (strcmp(Name, "NextSibling") == 0) { + if (strcmp(name, "NextSibling") == 0) { if (i < win->_widgets.GetSize() - 1) _scValue->SetNative(win->_widgets[i + 1], true); } else { if (i > 0) _scValue->SetNative(win->_widgets[i - 1], true); @@ -413,16 +413,16 @@ CScValue *CUIObject::scGetProperty(const char *Name) { return _scValue; } - else return CBObject::scGetProperty(Name); + else return CBObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -430,7 +430,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ParentNotify ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ParentNotify") == 0) { + else if (strcmp(name, "ParentNotify") == 0) { _parentNotify = Value->GetBool(); return S_OK; } @@ -438,7 +438,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Width") == 0) { + else if (strcmp(name, "Width") == 0) { _width = Value->GetInt(); return S_OK; } @@ -446,7 +446,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Height") == 0) { + else if (strcmp(name, "Height") == 0) { _height = Value->GetInt(); return S_OK; } @@ -454,7 +454,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Visible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Visible") == 0) { + else if (strcmp(name, "Visible") == 0) { _visible = Value->GetBool(); return S_OK; } @@ -462,7 +462,7 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Disabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Disabled") == 0) { + else if (strcmp(name, "Disabled") == 0) { _disable = Value->GetBool(); return S_OK; } @@ -470,12 +470,12 @@ HRESULT CUIObject::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Text") == 0) { + else if (strcmp(name, "Text") == 0) { setText(Value->GetString()); return S_OK; } - else return CBObject::scSetProperty(Name, Value); + else return CBObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 7e16041bbe..bc49c01a2f 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -72,9 +72,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 4eaa114a83..e5b89e15df 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -376,39 +376,39 @@ HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "SizeToFit") == 0) { - Stack->CorrectParams(0); + if (strcmp(name, "SizeToFit") == 0) { + stack->CorrectParams(0); SizeToFit(); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // HeightToFit ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "HeightToFit") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "HeightToFit") == 0) { + stack->CorrectParams(0); if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } - else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::scGetProperty(const char *Name) { +CScValue *CUIText::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("static"); return _scValue; } @@ -416,7 +416,7 @@ CScValue *CUIText::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "TextAlign") == 0) { + else if (strcmp(name, "TextAlign") == 0) { _scValue->SetInt(_textAlign); return _scValue; } @@ -424,21 +424,21 @@ CScValue *CUIText::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // VerticalAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VerticalAlign") == 0) { + else if (strcmp(name, "VerticalAlign") == 0) { _scValue->SetInt(_verticalAlign); return _scValue; } - else return CUIObject::scGetProperty(Name); + else return CUIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIText::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "TextAlign") == 0) { + if (strcmp(name, "TextAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _textAlign = (TTextAlign)i; @@ -448,14 +448,14 @@ HRESULT CUIText::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // VerticalAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "VerticalAlign") == 0) { + else if (strcmp(name, "VerticalAlign") == 0) { int i = Value->GetInt(); if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; _verticalAlign = (TVerticalAlign)i; return S_OK; } - else return CUIObject::scSetProperty(Name, Value); + else return CUIObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index aac9caf896..bb0b6a4d84 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -48,9 +48,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 38fefc4cc7..4e0590ab15 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -670,18 +670,18 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::enableWidget(const char *Name, bool Enable) { +HRESULT CUIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_disable = !Enable; + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::showWidget(const char *Name, bool Visible) { +HRESULT CUIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, Name) == 0) _widgets[i]->_visible = Visible; + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; } return S_OK; } @@ -690,25 +690,25 @@ HRESULT CUIWindow::showWidget(const char *Name, bool Visible) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name) { +HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "GetWidget") == 0 || strcmp(Name, "GetControl") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); if (val->GetType() == VAL_INT) { int widget = val->GetInt(); - if (widget < 0 || widget >= _widgets.GetSize()) Stack->PushNULL(); - else Stack->PushNative(_widgets[widget], true); + if (widget < 0 || widget >= _widgets.GetSize()) stack->PushNULL(); + else stack->PushNative(_widgets[widget], true); } else { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { - Stack->PushNative(_widgets[i], true); + stack->PushNative(_widgets[i], true); return S_OK; } } - Stack->PushNULL(); + stack->PushNULL(); } return S_OK; @@ -717,12 +717,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetInactiveFont ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInactiveFont") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetInactiveFont") == 0) { + stack->CorrectParams(1); if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont(Stack->Pop()->GetString()); - Stack->PushBool(_fontInactive != NULL); + _fontInactive = Game->_fontStorage->AddFont(stack->Pop()->GetString()); + stack->PushBool(_fontInactive != NULL); return S_OK; } @@ -730,17 +730,17 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // SetInactiveImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SetInactiveImage") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "SetInactiveImage") == 0) { + stack->CorrectParams(1); delete _imageInactive; _imageInactive = new CBSprite(Game); - const char *Filename = Stack->Pop()->GetString(); + const char *Filename = stack->Pop()->GetString(); if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) { delete _imageInactive; _imageInactive = NULL; - Stack->PushBool(false); - } else Stack->PushBool(true); + stack->PushBool(false); + } else stack->PushBool(true); return S_OK; } @@ -748,10 +748,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetInactiveImage ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInactiveImage") == 0) { - Stack->CorrectParams(0); - if (!_imageInactive || !_imageInactive->_filename) Stack->PushNULL(); - else Stack->PushString(_imageInactive->_filename); + else if (strcmp(name, "GetInactiveImage") == 0) { + stack->CorrectParams(0); + if (!_imageInactive || !_imageInactive->_filename) stack->PushNULL(); + else stack->PushString(_imageInactive->_filename); return S_OK; } @@ -759,10 +759,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // GetInactiveImageObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GetInactiveImageObject") == 0) { - Stack->CorrectParams(0); - if (!_imageInactive) Stack->PushNULL(); - else Stack->PushNative(_imageInactive, true); + else if (strcmp(name, "GetInactiveImageObject") == 0) { + stack->CorrectParams(0); + if (!_imageInactive) stack->PushNULL(); + else stack->PushNative(_imageInactive, true); return S_OK; } @@ -771,56 +771,56 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // Close ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Close") == 0) { - Stack->CorrectParams(0); - Stack->PushBool(SUCCEEDED(close())); + else if (strcmp(name, "Close") == 0) { + stack->CorrectParams(0); + stack->PushBool(SUCCEEDED(close())); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GoExclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoExclusive") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GoExclusive") == 0) { + stack->CorrectParams(0); goExclusive(); - Script->WaitFor(this); - Stack->PushNULL(); + script->WaitFor(this); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GoSystemExclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "GoSystemExclusive") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "GoSystemExclusive") == 0) { + stack->CorrectParams(0); goSystemExclusive(); - Script->WaitFor(this); - Stack->PushNULL(); + script->WaitFor(this); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Center ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Center") == 0) { - Stack->CorrectParams(0); + else if (strcmp(name, "Center") == 0) { + stack->CorrectParams(0); _posX = (Game->_renderer->_width - _width) / 2; _posY = (Game->_renderer->_height - _height) / 2; - Stack->PushNULL(); + stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LoadFromFile ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "LoadFromFile") == 0) { - Stack->CorrectParams(1); + else if (strcmp(name, "LoadFromFile") == 0) { + stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + CScValue *Val = stack->Pop(); cleanup(); if (!Val->IsNULL()) { - Stack->PushBool(SUCCEEDED(loadFile(Val->GetString()))); - } else Stack->PushBool(true); + stack->PushBool(SUCCEEDED(loadFile(Val->GetString()))); + } else stack->PushBool(true); return S_OK; } @@ -828,13 +828,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // CreateButton ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateButton") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateButton") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIButton *Btn = new CUIButton(Game); if (!Val->IsNULL()) Btn->setName(Val->GetString()); - Stack->PushNative(Btn, true); + stack->PushNative(Btn, true); Btn->_parent = this; _widgets.Add(Btn); @@ -845,13 +845,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // CreateStatic ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateStatic") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateStatic") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIText *Sta = new CUIText(Game); if (!Val->IsNULL()) Sta->setName(Val->GetString()); - Stack->PushNative(Sta, true); + stack->PushNative(Sta, true); Sta->_parent = this; _widgets.Add(Sta); @@ -862,13 +862,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // CreateEditor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateEditor") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateEditor") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIEdit *Edi = new CUIEdit(Game); if (!Val->IsNULL()) Edi->setName(Val->GetString()); - Stack->PushNative(Edi, true); + stack->PushNative(Edi, true); Edi->_parent = this; _widgets.Add(Edi); @@ -879,13 +879,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // CreateWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "CreateWindow") == 0) { - Stack->CorrectParams(1); - CScValue *Val = Stack->Pop(); + else if (strcmp(name, "CreateWindow") == 0) { + stack->CorrectParams(1); + CScValue *Val = stack->Pop(); CUIWindow *Win = new CUIWindow(Game); if (!Val->IsNULL()) Win->setName(Val->GetString()); - Stack->PushNative(Win, true); + stack->PushNative(Win, true); Win->_parent = this; _widgets.Add(Win); @@ -896,9 +896,9 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th ////////////////////////////////////////////////////////////////////////// // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "DeleteControl") == 0 || strcmp(Name, "DeleteButton") == 0 || strcmp(Name, "DeleteStatic") == 0 || strcmp(Name, "DeleteEditor") == 0 || strcmp(Name, "DeleteWindow") == 0) { - Stack->CorrectParams(1); - CScValue *val = Stack->Pop(); + else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { + stack->CorrectParams(1); + CScValue *val = stack->Pop(); CUIObject *obj = (CUIObject *)val->GetNative(); for (int i = 0; i < _widgets.GetSize(); i++) { @@ -908,22 +908,22 @@ HRESULT CUIWindow::scCallMethod(CScScript *Script, CScStack *Stack, CScStack *Th if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); } } - Stack->PushNULL(); + stack->PushNULL(); return S_OK; - } else if SUCCEEDED(Game->WindowScriptMethodHook(this, Script, Stack, Name)) return S_OK; + } else if SUCCEEDED(Game->WindowScriptMethodHook(this, script, stack, name)) return S_OK; - else return CUIObject::scCallMethod(Script, Stack, ThisStack, Name); + else return CUIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::scGetProperty(const char *Name) { +CScValue *CUIWindow::scGetProperty(const char *name) { _scValue->SetNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Type") == 0) { + if (strcmp(name, "Type") == 0) { _scValue->SetString("window"); return _scValue; } @@ -931,7 +931,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "NumWidgets") == 0 || strcmp(Name, "NumControls") == 0) { + else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { _scValue->SetInt(_widgets.GetSize()); return _scValue; } @@ -939,7 +939,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Exclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exclusive") == 0) { + else if (strcmp(name, "Exclusive") == 0) { _scValue->SetBool(_mode == WINDOW_EXCLUSIVE); return _scValue; } @@ -947,7 +947,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // SystemExclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SystemExclusive") == 0) { + else if (strcmp(name, "SystemExclusive") == 0) { _scValue->SetBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); return _scValue; } @@ -955,7 +955,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Menu ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Menu") == 0) { + else if (strcmp(name, "Menu") == 0) { _scValue->SetBool(_isMenu); return _scValue; } @@ -963,7 +963,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // InGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InGame") == 0) { + else if (strcmp(name, "InGame") == 0) { _scValue->SetBool(_inGame); return _scValue; } @@ -971,7 +971,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // PauseMusic ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0) { + else if (strcmp(name, "PauseMusic") == 0) { _scValue->SetBool(_pauseMusic); return _scValue; } @@ -979,7 +979,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // ClipContents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClipContents") == 0) { + else if (strcmp(name, "ClipContents") == 0) { _scValue->SetBool(_clipContents); return _scValue; } @@ -987,7 +987,7 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // Transparent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Transparent") == 0) { + else if (strcmp(name, "Transparent") == 0) { _scValue->SetBool(_transparent); return _scValue; } @@ -995,21 +995,21 @@ CScValue *CUIWindow::scGetProperty(const char *Name) { ////////////////////////////////////////////////////////////////////////// // FadeColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeColor") == 0) { + else if (strcmp(name, "FadeColor") == 0) { _scValue->SetInt((int)_fadeColor); return _scValue; } - else return CUIObject::scGetProperty(Name); + else return CUIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { +HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(Name, "Name") == 0) { + if (strcmp(name, "Name") == 0) { setName(Value->GetString()); return S_OK; } @@ -1017,7 +1017,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Menu ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Menu") == 0) { + else if (strcmp(name, "Menu") == 0) { _isMenu = Value->GetBool(); return S_OK; } @@ -1025,7 +1025,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // InGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "InGame") == 0) { + else if (strcmp(name, "InGame") == 0) { _inGame = Value->GetBool(); return S_OK; } @@ -1033,7 +1033,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // PauseMusic ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "PauseMusic") == 0) { + else if (strcmp(name, "PauseMusic") == 0) { _pauseMusic = Value->GetBool(); return S_OK; } @@ -1041,7 +1041,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // ClipContents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "ClipContents") == 0) { + else if (strcmp(name, "ClipContents") == 0) { _clipContents = Value->GetBool(); return S_OK; } @@ -1049,7 +1049,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Transparent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Transparent") == 0) { + else if (strcmp(name, "Transparent") == 0) { _transparent = Value->GetBool(); return S_OK; } @@ -1057,7 +1057,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // FadeColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "FadeColor") == 0) { + else if (strcmp(name, "FadeColor") == 0) { _fadeColor = (uint32)Value->GetInt(); _fadeBackground = (_fadeColor != 0); return S_OK; @@ -1066,7 +1066,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // Exclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "Exclusive") == 0) { + else if (strcmp(name, "Exclusive") == 0) { if (Value->GetBool()) goExclusive(); else { @@ -1079,7 +1079,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// // SystemExclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(Name, "SystemExclusive") == 0) { + else if (strcmp(name, "SystemExclusive") == 0) { if (Value->GetBool()) goSystemExclusive(); else { @@ -1089,7 +1089,7 @@ HRESULT CUIWindow::scSetProperty(const char *Name, CScValue *Value) { return S_OK; } - else return CUIObject::scSetProperty(Name, Value); + else return CUIObject::scSetProperty(name, Value); } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index e86409e43c..e22a09027d 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -63,8 +63,8 @@ public: bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - HRESULT showWidget(const char *Name, bool Visible = true); - HRESULT enableWidget(const char *Name, bool Enable = true); + HRESULT showWidget(const char *name, bool Visible = true); + HRESULT enableWidget(const char *name, bool Enable = true); RECT _titleRect; RECT _dragRect; virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); @@ -82,9 +82,9 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); // scripting interface - virtual CScValue *scGetProperty(const char *Name); - virtual HRESULT scSetProperty(const char *Name, CScValue *Value); - virtual HRESULT scCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, const char *Name); + virtual CScValue *scGetProperty(const char *name); + virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h index e89f9e55a2..e6cc39a73b 100644 --- a/engines/wintermute/wme_debugger.h +++ b/engines/wintermute/wme_debugger.h @@ -108,7 +108,7 @@ class IWmeDebugObject { public: virtual ~IWmeDebugObject() {} virtual const char *DbgGetNativeClass() = 0; - virtual IWmeDebugProp *DbgGetProperty(const char *Name) = 0; + virtual IWmeDebugProp *DbgGetProperty(const char *name) = 0; }; ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 13ec6b9bfe164029102fb777dd434a1dc0684a41 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 04:38:37 +0200 Subject: WINTERMUTE: Rename VarName->varName in AdEntity --- engines/wintermute/Ad/AdEntity.cpp | 152 +++++++++++++++++----------------- engines/wintermute/Ad/AdEntity.h | 12 +-- engines/wintermute/Ad/AdNodeState.cpp | 2 +- 3 files changed, 83 insertions(+), 83 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index d4252f9f55..e6ea8a24a6 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -84,22 +84,22 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", Filename); +HRESULT CAdEntity::loadFile(const char *filename) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", Filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -150,7 +150,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -200,18 +200,18 @@ HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { Game->LOG(0, "'ENTITY' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; CBSprite *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -236,14 +236,14 @@ HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { case TOKEN_TALK: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); } break; @@ -253,7 +253,7 @@ HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_ITEM: - SetItem((char *)params); + setItem((char *)params); break; case TOKEN_CAPTION: @@ -466,7 +466,7 @@ HRESULT CAdEntity::loadBuffer(byte *Buffer, bool Complete) { Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); } - UpdatePosition(); + updatePosition(); if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; @@ -642,20 +642,20 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { stack->CorrectParams(4); - const char *Filename = stack->Pop()->GetString(); - bool Looping = stack->Pop()->GetBool(false); - CScValue *ValAlpha = stack->Pop(); - int StartTime = stack->Pop()->GetInt(); + const char *filename = stack->Pop()->GetString(); + bool looping = stack->Pop()->GetBool(false); + CScValue *valAlpha = stack->Pop(); + int startTime = stack->Pop()->GetInt(); delete _theora; _theora = new CVidTheoraPlayer(Game); - if (_theora && SUCCEEDED(_theora->initialize(Filename))) { - if (!ValAlpha->IsNULL()) _theora->setAlphaImage(ValAlpha->GetString()); - _theora->play(VID_PLAY_POS, 0, 0, false, false, Looping, StartTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); + if (_theora && SUCCEEDED(_theora->initialize(filename))) { + if (!valAlpha->IsNULL()) _theora->setAlphaImage(valAlpha->GetString()); + _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; stack->PushBool(true); } else { - script->RuntimeError("Entity.PlayTheora - error playing video '%s'", Filename); + script->RuntimeError("Entity.PlayTheora - error playing video '%s'", filename); stack->PushBool(false); } @@ -831,13 +831,13 @@ CScValue *CAdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Item") == 0) { - SetItem(Value->GetString()); + setItem(value->GetString()); return S_OK; } @@ -845,7 +845,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *Value) { // WalkToX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToX") == 0) { - _walkToX = Value->GetInt(); + _walkToX = value->GetInt(); return S_OK; } @@ -853,7 +853,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *Value) { // WalkToY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToY") == 0) { - _walkToY = Value->GetInt(); + _walkToY = value->GetInt(); return S_OK; } @@ -861,12 +861,12 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *Value) { // WalkToDirection ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToDirection") == 0) { - int Dir = Value->GetInt(); - if (Dir >= 0 && Dir < NUM_DIRECTIONS) _walkToDir = (TDirection)Dir; + int dir = value->GetInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; return S_OK; } - else return CAdTalkHolder::scSetProperty(name, Value); + else return CAdTalkHolder::scSetProperty(name, value); } @@ -877,80 +877,80 @@ const char *CAdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "ENTITY {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); +HRESULT CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) - Buffer->putTextIndent(Indent + 2, "SUBTYPE=\"SOUND\"\n"); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); if (_ignoreItems) - Buffer->putTextIndent(Indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); if (_rotatable) - Buffer->putTextIndent(Indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); if (!_autoSoundPanning) - Buffer->putTextIndent(Indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); if (!_saveState) - Buffer->putTextIndent(Indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); - if (_item && _item[0] != '\0') Buffer->putTextIndent(Indent + 2, "ITEM=\"%s\"\n", _item); + if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); - Buffer->putTextIndent(Indent + 2, "WALK_TO_X=%d\n", _walkToX); - Buffer->putTextIndent(Indent + 2, "WALK_TO_Y=%d\n", _walkToY); + buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); + buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); if (_walkToDir != DI_NONE) - Buffer->putTextIndent(Indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - Buffer->putTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - Buffer->putTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); - Buffer->putTextIndent(Indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); - Buffer->putTextIndent(Indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); } if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) - Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); if (D3DCOLGetA(_alphaColor) != 0) - Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); if (_scale >= 0) - Buffer->putTextIndent(Indent + 2, "SCALE = %d\n", (int)_scale); + buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); if (_relativeScale != 0) - Buffer->putTextIndent(Indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - CAdTalkHolder::saveAsText(Buffer, Indent + 2); + CAdTalkHolder::saveAsText(buffer, indent + 2); - if (_region) _region->saveAsText(Buffer, Indent + 2); + if (_region) _region->saveAsText(buffer, indent + 2); - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); - CAdObject::saveAsText(Buffer, Indent + 2); + CAdObject::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } @@ -968,7 +968,7 @@ int CAdEntity::getHeight() { ////////////////////////////////////////////////////////////////////////// -void CAdEntity::UpdatePosition() { +void CAdEntity::updatePosition() { if (_region && !_sprite) { _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; _posY = _region->_rect.bottom; @@ -998,22 +998,22 @@ HRESULT CAdEntity::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdEntity::SetItem(const char *ItemName) { - CBUtils::SetString(&_item, ItemName); +void CAdEntity::setItem(const char *itemName) { + CBUtils::SetString(&_item, itemName); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::SetSprite(const char *Filename) { - bool SetCurrent = false; +HRESULT CAdEntity::setSprite(const char *filename) { + bool setCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; - SetCurrent = true; + setCurrent = true; } delete _sprite; _sprite = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { delete _sprite; _sprite = NULL; return E_FAIL; diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 380cf7fcae..f06814352d 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -36,23 +36,23 @@ class CVidTheoraPlayer; class CAdEntity : public CAdTalkHolder { public: CVidTheoraPlayer *_theora; - HRESULT SetSprite(const char *Filename); + HRESULT setSprite(const char *filename); int _walkToX; int _walkToY; TDirection _walkToDir; - void SetItem(const char *ItemName); + void setItem(const char *itemName); char *_item; DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) - void UpdatePosition(); + void updatePosition(); virtual int getHeight(); CBRegion *_region; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); virtual HRESULT update(); virtual HRESULT display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); - HRESULT loadFile(const char *Filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadFile(const char *filename); + HRESULT loadBuffer(byte *buffer, bool complete = true); TEntityType _subtype; // scripting interface diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 1eb831a1e0..611d3f4b83 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -152,7 +152,7 @@ HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, b } if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) - Entity->SetSprite(_filename); + Entity->setSprite(_filename); } if (_cursor) { if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) -- cgit v1.2.3 From 9b0fa0e9263d7d99d898321b125d7eea5c6cf23d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 04:52:18 +0200 Subject: WINTERMUTE: Rename a few VarName->varName in BGame --- engines/wintermute/Base/BGame.cpp | 417 +++++++++++++++++++------------------- engines/wintermute/Base/BGame.h | 6 +- engines/wintermute/wintermute.cpp | 6 +- 3 files changed, 214 insertions(+), 215 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 30d67a8fe9..d7cc2332a5 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -425,7 +425,7 @@ HRESULT CBGame::cleanup() { ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize1() { +HRESULT CBGame::initialize1() { _surfaceStorage = new CBSurfaceStorage(this); if (_surfaceStorage == NULL) goto init_fail; @@ -483,7 +483,7 @@ init_fail: ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize2() { // we know whether we are going to be accelerated +HRESULT CBGame::initialize2() { // we know whether we are going to be accelerated _renderer = new CBRenderSDL(this); if (_renderer == NULL) goto init_fail; @@ -496,7 +496,7 @@ init_fail: ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Initialize3() { // renderer is initialized +HRESULT CBGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; @@ -509,11 +509,11 @@ HRESULT CBGame::Initialize3() { // renderer is initialized ////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *Filename) { +void CBGame::DEBUG_DebugEnable(const char *filename) { _dEBUG_DebugMode = true; #ifndef __IPHONEOS__ - //if (Filename)_dEBUG_LogFile = fopen(Filename, "a+"); + //if (filename)_dEBUG_LogFile = fopen(filename, "a+"); //else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); if (!_dEBUG_LogFile) { @@ -597,9 +597,9 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback, void *Data) { - _engineLogCallback = Callback; - _engineLogCallbackData = Data; +void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; } @@ -674,35 +674,34 @@ int CBGame::GetSequence() { ////////////////////////////////////////////////////////////////////////// -void CBGame::SetOffset(int OffsetX, int OffsetY) { - _offsetX = OffsetX; - _offsetY = OffsetY; +void CBGame::SetOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; } ////////////////////////////////////////////////////////////////////////// -void CBGame::GetOffset(int *OffsetX, int *OffsetY) { - if (OffsetX != NULL) *OffsetX = _offsetX; - if (OffsetY != NULL) *OffsetY = _offsetY; +void CBGame::GetOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) *offsetX = _offsetX; + if (offsetY != NULL) *offsetY = _offsetY; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CBGame::LoadFile failed for file '%s'", Filename); +HRESULT CBGame::loadFile(const char *filename) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); - - delete [] Buffer; + delete [] buffer; return ret; } @@ -758,7 +757,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -798,15 +797,15 @@ HRESULT CBGame::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_GAME) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { Game->LOG(0, "'GAME' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -1027,14 +1026,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadStringTable") == 0) { stack->CorrectParams(2); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); CScValue *Val = stack->Pop(); bool ClearOld; if (Val->IsNULL()) ClearOld = true; else ClearOld = Val->GetBool(); - if (FAILED(_stringTable->loadFile(Filename, ClearOld))) + if (FAILED(_stringTable->loadFile(filename, ClearOld))) stack->PushBool(false); else stack->PushBool(true); @@ -1116,14 +1115,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // PlayMusic / PlayMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "PlayMusic") == 0) stack->CorrectParams(3); else { stack->CorrectParams(4); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); CScValue *ValLooping = stack->Pop(); bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); @@ -1131,7 +1130,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); - if (FAILED(PlayMusic(Channel, Filename, Looping, LoopStart))) stack->PushBool(false); + if (FAILED(PlayMusic(channel, filename, Looping, LoopStart))) stack->PushBool(false); else stack->PushBool(true); return S_OK; } @@ -1140,15 +1139,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // StopMusic / StopMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "StopMusic") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (FAILED(StopMusic(Channel))) stack->PushBool(false); + if (FAILED(StopMusic(channel))) stack->PushBool(false); else stack->PushBool(true); return S_OK; } @@ -1157,15 +1156,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // PauseMusic / PauseMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "PauseMusic") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (FAILED(PauseMusic(Channel))) stack->PushBool(false); + if (FAILED(PauseMusic(channel))) stack->PushBool(false); else stack->PushBool(true); return S_OK; } @@ -1174,14 +1173,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ResumeMusic / ResumeMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "ResumeMusic") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (FAILED(ResumeMusic(Channel))) stack->PushBool(false); + if (FAILED(ResumeMusic(channel))) stack->PushBool(false); else stack->PushBool(true); return S_OK; } @@ -1190,16 +1189,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetMusic / GetMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "GetMusic") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS) stack->PushNULL(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->PushNULL(); else { - if (!_music[Channel] || !_music[Channel]->_soundFilename) stack->PushNULL(); - else stack->PushString(_music[Channel]->_soundFilename); + if (!_music[channel] || !_music[channel]->_soundFilename) stack->PushNULL(); + else stack->PushString(_music[channel]->_soundFilename); } return S_OK; } @@ -1208,16 +1207,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetMusicPosition / SetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "SetMusicPosition") == 0) stack->CorrectParams(1); else { stack->CorrectParams(2); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } uint32 Time = stack->Pop()->GetInt(); - if (FAILED(SetMusicStartTime(Channel, Time))) stack->PushBool(false); + if (FAILED(SetMusicStartTime(channel, Time))) stack->PushBool(false); else stack->PushBool(true); return S_OK; @@ -1227,15 +1226,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetMusicPosition / GetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "GetMusicPosition") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushInt(0); - else stack->PushInt(_music[Channel]->getPositionTime()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushInt(0); + else stack->PushInt(_music[channel]->getPositionTime()); return S_OK; } @@ -1243,15 +1242,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // IsMusicPlaying / IsMusicChannelPlaying ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "IsMusicPlaying") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushBool(false); - else stack->PushBool(_music[Channel]->isPlaying()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushBool(false); + else stack->PushBool(_music[channel]->isPlaying()); return S_OK; } @@ -1259,17 +1258,17 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetMusicVolume / SetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "SetMusicVolume") == 0) stack->CorrectParams(1); else { stack->CorrectParams(2); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } int Volume = stack->Pop()->GetInt(); - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushBool(false); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushBool(false); else { - if (FAILED(_music[Channel]->setVolume(Volume))) stack->PushBool(false); + if (FAILED(_music[channel]->setVolume(Volume))) stack->PushBool(false); else stack->PushBool(true); } return S_OK; @@ -1279,15 +1278,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetMusicVolume / GetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { - int Channel = 0; + int channel = 0; if (strcmp(name, "GetMusicVolume") == 0) stack->CorrectParams(0); else { stack->CorrectParams(1); - Channel = stack->Pop()->GetInt(); + channel = stack->Pop()->GetInt(); } - if (Channel < 0 || Channel >= NUM_MUSIC_CHANNELS || !_music[Channel]) stack->PushInt(0); - else stack->PushInt(_music[Channel]->getVolume()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushInt(0); + else stack->PushInt(_music[channel]->getVolume()); return S_OK; } @@ -1297,8 +1296,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicCrossfade") == 0) { stack->CorrectParams(4); - int Channel1 = stack->Pop()->GetInt(0); - int Channel2 = stack->Pop()->GetInt(0); + int channel1 = stack->Pop()->GetInt(0); + int channel2 = stack->Pop()->GetInt(0); uint32 FadeLength = (uint32)stack->Pop()->GetInt(0); bool Swap = stack->Pop()->GetBool(true); @@ -1309,8 +1308,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = Channel1; - _musicCrossfadeChannel2 = Channel2; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; _musicCrossfadeLength = FadeLength; _musicCrossfadeSwap = Swap; @@ -1327,10 +1326,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->CorrectParams(1); int Length = 0; - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); CBSound *Sound = new CBSound(Game); - if (Sound && SUCCEEDED(Sound->setSound(Filename, SOUND_MUSIC, true))) { + if (Sound && SUCCEEDED(Sound->setSound(filename, SOUND_MUSIC, true))) { Length = Sound->getLength(); delete Sound; Sound = NULL; @@ -1393,8 +1392,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); stack->CorrectParams(6); - const char *Filename = stack->Pop()->GetString(); - warning("PlayVideo: %s - not implemented yet", Filename); + const char *filename = stack->Pop()->GetString(); + warning("PlayVideo: %s - not implemented yet", filename); CScValue *valType = stack->Pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; @@ -1410,7 +1409,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - if (SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { + if (SUCCEEDED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { stack->PushBool(true); script->Sleep(0); @@ -1431,7 +1430,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // TODO: ADDVIDEO stack->CorrectParams(7); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); CScValue *valType = stack->Pop(); int Type; if (valType->IsNULL()) @@ -1450,7 +1449,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete _theoraPlayer; _theoraPlayer = new CVidTheoraPlayer(this); - if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) { + if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !DropFrames; if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { stack->PushBool(true); @@ -1726,9 +1725,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FileExists") == 0) { stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); - Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->openFile(filename, false); if (!File) stack->PushBool(false); else { _fileManager->closeFile(File); @@ -1791,7 +1790,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Screenshot") == 0) { stack->CorrectParams(1); - char Filename[MAX_PATH]; + char filename[MAX_PATH]; CScValue *Val = stack->Pop(); @@ -1799,8 +1798,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int FileNum = 0; while (true) { - sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); - if (!Common::File::exists(Filename)) + sprintf(filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); + if (!Common::File::exists(filename)) break; FileNum++; } @@ -1808,7 +1807,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { - ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + ret = SUCCEEDED(Image->SaveBMPFile(filename)); delete Image; } else ret = false; @@ -1821,7 +1820,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScreenshotEx") == 0) { stack->CorrectParams(3); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); int SizeX = stack->Pop()->GetInt(_renderer->_width); int SizeY = stack->Pop()->GetInt(_renderer->_height); @@ -1829,7 +1828,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); - if (ret) ret = SUCCEEDED(Image->SaveBMPFile(Filename)); + if (ret) ret = SUCCEEDED(Image->SaveBMPFile(filename)); delete Image; } else ret = false; @@ -1987,14 +1986,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "DisplayLoadingIcon") == 0) { stack->CorrectParams(4); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); _loadingIconX = stack->Pop()->GetInt(); _loadingIconY = stack->Pop()->GetInt(); _loadingIconPersistent = stack->Pop()->GetBool(); delete _loadingIcon; _loadingIcon = new CBSprite(this); - if (!_loadingIcon || FAILED(_loadingIcon->loadFile(Filename))) { + if (!_loadingIcon || FAILED(_loadingIcon->loadFile(filename))) { delete _loadingIcon; _loadingIcon = NULL; } else { @@ -2023,9 +2022,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DumpTextureStats") == 0) { stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); - _renderer->dumpData(Filename); + _renderer->dumpData(filename); stack->PushNULL(); return S_OK; @@ -2079,10 +2078,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFileChecksum") == 0) { stack->CorrectParams(2); - const char *Filename = stack->Pop()->GetString(); + const char *filename = stack->Pop()->GetString(); bool AsHex = stack->Pop()->GetBool(false); - Common::SeekableReadStream *File = _fileManager->openFile(Filename, false); + Common::SeekableReadStream *File = _fileManager->openFile(filename, false); if (File) { crc remainder = crc_initialize(); byte Buf[1024]; @@ -2556,12 +2555,12 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -2570,7 +2569,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // MouseX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = Value->GetInt(); + _mousePos.x = value->GetInt(); ResetMousePos(); return S_OK; } @@ -2579,7 +2578,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // MouseY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = Value->GetInt(); + _mousePos.y = value->GetInt(); ResetMousePos(); return S_OK; } @@ -2588,7 +2587,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - HRESULT res = CBObject::scSetProperty(name, Value); + HRESULT res = CBObject::scSetProperty(name, value); SetWindowTitle(); return res; } @@ -2597,7 +2596,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = Value->GetNative(); + CBScriptable *obj = value->GetNative(); if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; return S_OK; } @@ -2606,7 +2605,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Interactive") == 0) { - SetInteractive(Value->GetBool()); + SetInteractive(value->GetBool()); return S_OK; } @@ -2615,7 +2614,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)value->GetInt()); return S_OK; } @@ -2624,7 +2623,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)value->GetInt()); return S_OK; } @@ -2633,7 +2632,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)Value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)value->GetInt()); return S_OK; } @@ -2642,7 +2641,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->setMasterVolumePercent((byte)Value->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte)value->GetInt()); return S_OK; } @@ -2650,7 +2649,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // Subtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtitles") == 0) { - _subtitles = Value->GetBool(); + _subtitles = value->GetBool(); return S_OK; } @@ -2658,7 +2657,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = Value->GetInt(); + _subtitlesSpeed = value->GetInt(); return S_OK; } @@ -2666,7 +2665,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // VideoSubtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = Value->GetBool(); + _videoSubtitles = value->GetBool(); return S_OK; } @@ -2674,7 +2673,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextEncoding") == 0) { - int Enc = Value->GetInt(); + int Enc = value->GetInt(); if (Enc < 0) Enc = 0; if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; _textEncoding = (TTextEncoding)Enc; @@ -2685,7 +2684,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // TextRTL ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextRTL") == 0) { - _textRTL = Value->GetBool(); + _textRTL = value->GetBool(); return S_OK; } @@ -2693,7 +2692,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // SoundBufferSize ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = Value->GetInt(); + _soundBufferSizeSec = value->GetInt(); _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); return S_OK; } @@ -2702,7 +2701,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // SuspendedRendering ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = Value->GetBool(); + _suspendedRendering = value->GetBool(); return S_OK; } @@ -2710,7 +2709,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = Value->GetBool(); + _suppressScriptErrors = value->GetBool(); return S_OK; } @@ -2718,7 +2717,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // AutorunDisabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = Value->GetBool(); + _autorunDisabled = value->GetBool(); return S_OK; } @@ -2726,7 +2725,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = Value->GetBool(); + _autoSaveOnExit = value->GetBool(); return S_OK; } @@ -2734,7 +2733,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = Value->GetInt(); + _autoSaveSlot = value->GetInt(); return S_OK; } @@ -2742,11 +2741,11 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *Value) { // CursorHidden ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = Value->GetBool(); + _cursorHidden = value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } @@ -2773,12 +2772,12 @@ HRESULT CBGame::DisplayQuickMsg() { } } - int PosY = 20; + int posY = 20; // display for (i = 0; i < _quickMessages.GetSize(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->GetText(), 0, PosY, _renderer->_width); - PosY += _systemFont->getTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); + _systemFont->drawText((byte *)_quickMessages[i]->GetText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); } return S_OK; } @@ -2786,12 +2785,12 @@ HRESULT CBGame::DisplayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessage(const char *Text) { +void CBGame::QuickMessage(const char *text) { if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.RemoveAt(0); } - _quickMessages.Add(new CBQuickMsg(Game, Text)); + _quickMessages.Add(new CBQuickMsg(Game, text)); } @@ -2809,44 +2808,44 @@ void CBGame::QuickMessageForm(LPSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::RegisterObject(CBObject *Object) { - _regObjects.Add(Object); +HRESULT CBGame::RegisterObject(CBObject *object) { + _regObjects.Add(object); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::UnregisterObject(CBObject *Object) { - if (!Object) return S_OK; +HRESULT CBGame::UnregisterObject(CBObject *object) { + if (!object) return S_OK; int i; // is it a window? for (i = 0; i < _windows.GetSize(); i++) { - if ((CBObject *)_windows[i] == Object) { + if ((CBObject *)_windows[i] == object) { _windows.RemoveAt(i); // get new focused window - if (_focusedWindow == Object) _focusedWindow = NULL; + if (_focusedWindow == object) _focusedWindow = NULL; break; } } // is it active object? - if (_activeObject == Object) _activeObject = NULL; + if (_activeObject == object) _activeObject = NULL; // is it main object? - if (_mainObject == Object) _mainObject = NULL; + if (_mainObject == object) _mainObject = NULL; - if (_store) _store->OnObjectDestroyed(Object); + if (_store) _store->OnObjectDestroyed(object); // destroy object for (i = 0; i < _regObjects.GetSize(); i++) { - if (_regObjects[i] == Object) { + if (_regObjects[i] == object) { _regObjects.RemoveAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(InvalidateValues, "CScValue", (void *)Object); - delete Object; + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(InvalidateValues, "CScValue", (void *)object); + delete object; return S_OK; } } @@ -2856,11 +2855,11 @@ HRESULT CBGame::UnregisterObject(CBObject *Object) { ////////////////////////////////////////////////////////////////////////// -void CBGame::InvalidateValues(void *Value, void *Data) { - CScValue *val = (CScValue *)Value; - if (val->IsNative() && val->GetNative() == Data) { - if (!val->_persistent && ((CBScriptable *)Data)->_refCount == 1) { - ((CBScriptable *)Data)->_refCount++; +void CBGame::InvalidateValues(void *value, void *data) { + CScValue *val = (CScValue *)value; + if (val->IsNative() && val->GetNative() == data) { + if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { + ((CBScriptable *)data)->_refCount++; } val->SetNative(NULL); val->SetNULL(); @@ -2870,12 +2869,12 @@ void CBGame::InvalidateValues(void *Value, void *Data) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::ValidObject(CBObject *Object) { - if (!Object) return false; - if (Object == this) return true; +bool CBGame::ValidObject(CBObject *object) { + if (!object) return false; + if (object == this) return true; for (int i = 0; i < _regObjects.GetSize(); i++) { - if (_regObjects[i] == Object) return true; + if (_regObjects[i] == object) return true; } return false; } @@ -3227,10 +3226,10 @@ HRESULT CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(slot, Filename); + char filename[MAX_PATH + 1]; + GetSaveSlotFilename(slot, filename); - LOG(0, "Saving game '%s'...", Filename); + LOG(0, "Saving game '%s'...", filename); Game->applyEvent("BeforeSave", true); @@ -3256,7 +3255,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { if (FAILED(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish; if (FAILED(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = pm->saveFile(Filename))) goto save_finish; + if (FAILED(ret = pm->saveFile(filename))) goto save_finish; _registry->WriteInt("System", "MostRecentSaveSlot", slot); @@ -3272,22 +3271,22 @@ save_finish: ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(int Slot) { +HRESULT CBGame::LoadGame(int slot) { //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); _loading = false; _scheduledLoadSlot = -1; - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); + char filename[MAX_PATH + 1]; + GetSaveSlotFilename(slot, filename); - return LoadGame(Filename); + return LoadGame(filename); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(const char *Filename) { - LOG(0, "Loading game '%s'...", Filename); +HRESULT CBGame::LoadGame(const char *filename) { + LOG(0, "Loading game '%s'...", filename); GetDebugMgr()->OnGameShutdown(); HRESULT ret; @@ -3309,7 +3308,7 @@ HRESULT CBGame::LoadGame(const char *Filename) { _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); _dEBUG_AbsolutePathWarning = false; - if (FAILED(ret = pm->initLoad(Filename))) goto load_finish; + if (FAILED(ret = pm->initLoad(filename))) goto load_finish; //if(FAILED(ret = cleanup())) goto load_finish; if (FAILED(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish; @@ -3414,87 +3413,87 @@ HRESULT CBGame::DisplayWindows(bool InGame) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PlayMusic(int Channel, const char *Filename, bool Looping, uint32 LoopStart) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); +HRESULT CBGame::PlayMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - delete _music[Channel]; - _music[Channel] = NULL; + delete _music[channel]; + _music[channel] = NULL; - _music[Channel] = new CBSound(Game); - if (_music[Channel] && SUCCEEDED(_music[Channel]->setSound(Filename, SOUND_MUSIC, true))) { - if (_musicStartTime[Channel]) { - _music[Channel]->setPositionTime(_musicStartTime[Channel]); - _musicStartTime[Channel] = 0; + _music[channel] = new CBSound(Game); + if (_music[channel] && SUCCEEDED(_music[channel]->setSound(filename, SOUND_MUSIC, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; } - if (LoopStart) _music[Channel]->setLoopStart(LoopStart); - return _music[Channel]->play(Looping); + if (loopStart) _music[channel]->setLoopStart(loopStart); + return _music[channel]->play(looping); } else { - delete _music[Channel]; - _music[Channel] = NULL; + delete _music[channel]; + _music[channel] = NULL; return E_FAIL; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::StopMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); +HRESULT CBGame::StopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - if (_music[Channel]) { - _music[Channel]->stop(); - delete _music[Channel]; - _music[Channel] = NULL; + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; return S_OK; } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PauseMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); +HRESULT CBGame::PauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - if (_music[Channel]) return _music[Channel]->pause(); + if (_music[channel]) return _music[channel]->pause(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ResumeMusic(int Channel) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); +HRESULT CBGame::ResumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - if (_music[Channel]) return _music[Channel]->resume(); + if (_music[channel]) return _music[channel]->resume(); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetMusicStartTime(int Channel, uint32 Time) { +HRESULT CBGame::SetMusicStartTime(int channel, uint32 Time) { - if (Channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", Channel, NUM_MUSIC_CHANNELS); + if (channel >= NUM_MUSIC_CHANNELS) { + Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - _musicStartTime[Channel] = Time; - if (_music[Channel] && _music[Channel]->isPlaying()) return _music[Channel]->setPositionTime(Time); + _musicStartTime[channel] = Time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(Time); else return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadSettings(const char *Filename) { +HRESULT CBGame::LoadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3515,9 +3514,9 @@ HRESULT CBGame::LoadSettings(const char *Filename) { TOKEN_TABLE_END - byte *OrigBuffer = Game->_fileManager->readWholeFile(Filename); + byte *OrigBuffer = Game->_fileManager->readWholeFile(filename); if (OrigBuffer == NULL) { - Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", Filename); + Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); return E_FAIL; } @@ -3598,11 +3597,11 @@ HRESULT CBGame::LoadSettings(const char *Filename) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in game settings '%s'", Filename); + Game->LOG(0, "Syntax error in game settings '%s'", filename); ret = E_FAIL; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading game settings '%s'", Filename); + Game->LOG(0, "Error loading game settings '%s'", filename); ret = E_FAIL; } @@ -3913,13 +3912,13 @@ AnsiString CBGame::GetDataDir() { HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { Buffer[0] = '\0'; - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); + char filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, filename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; _dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->initLoad(Filename))) { + if (FAILED(pm->initLoad(filename))) { _dEBUG_AbsolutePathWarning = true; delete pm; return E_FAIL; @@ -3934,12 +3933,12 @@ HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsSaveSlotUsed(int Slot) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); +bool CBGame::IsSaveSlotUsed(int slot) { + char filename[MAX_PATH + 1]; + GetSaveSlotFilename(slot, filename); - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", Slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(Filename); + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); if (!File) return false; delete File; return true; @@ -3948,10 +3947,10 @@ bool CBGame::IsSaveSlotUsed(int Slot) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::EmptySaveSlot(int Slot) { - char Filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, Filename); + char filename[MAX_PATH + 1]; + GetSaveSlotFilename(Slot, filename); - CBPlatform::DeleteFile(Filename); + CBPlatform::DeleteFile(filename); return S_OK; } @@ -4140,14 +4139,14 @@ HRESULT CBGame::UpdateMusicCrossfade() { if (_musicCrossfadeSwap) { // swap channels - CBSound *Dummy = _music[_musicCrossfadeChannel1]; - int DummyInt = _musicStartTime[_musicCrossfadeChannel1]; + CBSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - _music[_musicCrossfadeChannel2] = Dummy; - _musicStartTime[_musicCrossfadeChannel2] = DummyInt; + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; } } else { //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); @@ -4203,12 +4202,12 @@ HRESULT CBGame::restoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetWaitCursor(const char *Filename) { +HRESULT CBGame::SetWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile(Filename))) { + if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile(filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; return E_FAIL; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 0325785ce1..b67a440415 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -167,9 +167,9 @@ public: uint32 _deltaTime; CBFont *_systemFont; CBFont *_videoFont; - HRESULT Initialize1(); - HRESULT Initialize2(); - HRESULT Initialize3(); + HRESULT initialize1(); + HRESULT initialize2(); + HRESULT initialize3(); CBFileManager *_fileManager; CBTransitionMgr *_transMgr; CBDebugger *GetDebugMgr(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index c57be85cf1..fe8e653ca9 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -186,7 +186,7 @@ int WinterMuteEngine::init() { /* bool AllowDirectDraw = _game->_registry->ReadBool("Debug", "AllowDirectDraw", false);*/ // load general game settings - _game->Initialize1(); + _game->initialize1(); if (FAILED(_game->LoadSettings("startup.settings"))) { @@ -198,7 +198,7 @@ int WinterMuteEngine::init() { return 2; } - _game->Initialize2(); + _game->initialize2(); _game->GetDebugMgr()->OnGameInit(); _game->_scEngine->LoadBreakpoints(); @@ -217,7 +217,7 @@ int WinterMuteEngine::init() { return 3; } - _game->Initialize3(); + _game->initialize3(); #ifdef __IPHONEOS__ SDL_AddEventWatch(CBPlatform::SDLEventWatcher, NULL); -- cgit v1.2.3 From 6c6c0bb0167cbf004cf300a81dda71a952d93626 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:00:57 +0200 Subject: WINTERMUTE: Mass-rename "Value"->"value" --- engines/wintermute/Ad/AdActor.cpp | 26 ++++---- engines/wintermute/Ad/AdEntity.h | 2 +- engines/wintermute/Ad/AdGame.cpp | 30 +++++----- engines/wintermute/Ad/AdGame.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 22 +++---- engines/wintermute/Ad/AdItem.h | 2 +- engines/wintermute/Ad/AdLayer.cpp | 14 ++--- engines/wintermute/Ad/AdLayer.h | 2 +- engines/wintermute/Ad/AdObject.cpp | 20 +++---- engines/wintermute/Ad/AdRegion.cpp | 14 ++--- engines/wintermute/Ad/AdRegion.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 24 ++++---- engines/wintermute/Ad/AdScene.h | 2 +- engines/wintermute/Ad/AdTalkHolder.cpp | 2 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 6 +- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- engines/wintermute/Base/BDebugger.cpp | 2 +- engines/wintermute/Base/BDebugger.h | 2 +- engines/wintermute/Base/BFrame.cpp | 16 ++--- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BKeyboardState.cpp | 6 +- engines/wintermute/Base/BKeyboardState.h | 2 +- engines/wintermute/Base/BObject.cpp | 50 ++++++++-------- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BRegion.cpp | 8 +-- engines/wintermute/Base/BRegion.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 6 +- engines/wintermute/Base/BSprite.cpp | 10 ++-- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BSubFrame.cpp | 20 +++---- engines/wintermute/Base/BSubFrame.h | 2 +- engines/wintermute/Base/PartEmitter.cpp | 70 +++++++++++----------- engines/wintermute/Base/PartEmitter.h | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 6 +- engines/wintermute/Base/scriptables/SXArray.h | 2 +- engines/wintermute/Base/scriptables/SXDate.cpp | 4 +- engines/wintermute/Base/scriptables/SXDate.h | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 6 +- engines/wintermute/Base/scriptables/SXFile.h | 2 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 6 +- engines/wintermute/Base/scriptables/SXMemBuffer.h | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 4 +- engines/wintermute/Base/scriptables/SXString.h | 2 +- engines/wintermute/Base/scriptables/ScStack.cpp | 38 ++++++------ engines/wintermute/Base/scriptables/ScValue.cpp | 42 ++++++------- engines/wintermute/UI/UIButton.cpp | 12 ++-- engines/wintermute/UI/UIButton.h | 2 +- engines/wintermute/UI/UIEdit.cpp | 20 +++---- engines/wintermute/UI/UIEdit.h | 2 +- engines/wintermute/UI/UIEntity.cpp | 6 +- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/UI/UIObject.cpp | 18 +++--- engines/wintermute/UI/UIObject.h | 2 +- engines/wintermute/UI/UIText.cpp | 8 +-- engines/wintermute/UI/UIText.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 22 +++---- engines/wintermute/UI/UIWindow.h | 2 +- engines/wintermute/utils/utils.cpp | 10 ++-- 59 files changed, 301 insertions(+), 301 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 7e76ab4737..5653ed2f24 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -1035,12 +1035,12 @@ CScValue *CAdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Direction") == 0) { - int dir = Value->GetInt(); + int dir = value->GetInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; return S_OK; } @@ -1049,8 +1049,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkAnimName") == 0) { - if (Value->IsNULL()) _talkAnimName = "talk"; - else _talkAnimName = Value->GetString(); + if (value->IsNULL()) _talkAnimName = "talk"; + else _talkAnimName = value->GetString(); return S_OK; } @@ -1058,8 +1058,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkAnimName") == 0) { - if (Value->IsNULL()) _walkAnimName = "walk"; - else _walkAnimName = Value->GetString(); + if (value->IsNULL()) _walkAnimName = "walk"; + else _walkAnimName = value->GetString(); return S_OK; } @@ -1067,8 +1067,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IdleAnimName") == 0) { - if (Value->IsNULL()) _idleAnimName = "idle"; - else _idleAnimName = Value->GetString(); + if (value->IsNULL()) _idleAnimName = "idle"; + else _idleAnimName = value->GetString(); return S_OK; } @@ -1076,8 +1076,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnLeftAnimName") == 0) { - if (Value->IsNULL()) _turnLeftAnimName = "turnleft"; - else _turnLeftAnimName = Value->GetString(); + if (value->IsNULL()) _turnLeftAnimName = "turnleft"; + else _turnLeftAnimName = value->GetString(); return S_OK; } @@ -1085,12 +1085,12 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *Value) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnRightAnimName") == 0) { - if (Value->IsNULL()) _turnRightAnimName = "turnright"; - else _turnRightAnimName = Value->GetString(); + if (value->IsNULL()) _turnRightAnimName = "turnright"; + else _turnRightAnimName = value->GetString(); return S_OK; } - else return CAdTalkHolder::scSetProperty(name, Value); + else return CAdTalkHolder::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index f06814352d..c2d73a4204 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -57,7 +57,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 34d9c600a7..5bf1b6691c 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -952,25 +952,25 @@ CScValue *CAdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelectedItem") == 0) { - if (Value->IsNULL()) _selectedItem = NULL; + if (value->IsNULL()) _selectedItem = NULL; else { - if (Value->IsNative()) { + if (value->IsNative()) { _selectedItem = NULL; for (int i = 0; i < _items.GetSize(); i++) { - if (_items[i] == Value->GetNative()) { - _selectedItem = (CAdItem *)Value->GetNative(); + if (_items[i] == value->GetNative()) { + _selectedItem = (CAdItem *)value->GetNative(); break; } } } else { // try to get by name - _selectedItem = GetItemByName(Value->GetString()); + _selectedItem = GetItemByName(value->GetString()); } } @@ -981,7 +981,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { // SmartItemCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SmartItemCursor") == 0) { - _smartItemCursor = Value->GetBool(); + _smartItemCursor = value->GetBool(); return S_OK; } @@ -989,7 +989,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = Value->GetBool(); + if (_inventoryBox) _inventoryBox->_visible = value->GetBool(); return S_OK; } @@ -999,9 +999,9 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { else if (strcmp(name, "InventoryObject") == 0) { if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - if (Value->IsNULL()) _inventoryOwner = _invObject; + if (value->IsNULL()) _inventoryOwner = _invObject; else { - CBObject *Obj = (CBObject *)Value->GetNative(); + CBObject *Obj = (CBObject *)value->GetNative(); if (Obj == this) _inventoryOwner = _invObject; else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } @@ -1015,7 +1015,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = Value->GetInt(); + if (_inventoryBox) _inventoryBox->_scrollOffset = value->GetInt(); return S_OK; } @@ -1023,7 +1023,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { // TalkSkipButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkSkipButton") == 0) { - int Val = Value->GetInt(); + int Val = value->GetInt(); if (Val < 0) Val = 0; if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; _talkSkipButton = (TTalkSkipButton)Val; @@ -1034,15 +1034,15 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *Value) { // StartupScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartupScene") == 0) { - if (Value == NULL) { + if (value == NULL) { delete[] _startupScene; _startupScene = NULL; - } else CBUtils::SetString(&_startupScene, Value->GetString()); + } else CBUtils::SetString(&_startupScene, value->GetString()); return S_OK; } - else return CBGame::scSetProperty(name, Value); + else return CBGame::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index c9fbbadc6f..ad6785a8ff 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -152,7 +152,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); bool ValidMouse(); }; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index f9b92afba6..4388aef86c 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -648,12 +648,12 @@ CScValue *CAdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -661,7 +661,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // DisplayAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisplayAmount") == 0) { - _displayAmount = Value->GetBool(); + _displayAmount = value->GetBool(); return S_OK; } @@ -669,7 +669,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // Amount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Amount") == 0) { - _amount = Value->GetInt(); + _amount = value->GetInt(); return S_OK; } @@ -677,7 +677,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // AmountOffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetX") == 0) { - _amountOffsetX = Value->GetInt(); + _amountOffsetX = value->GetInt(); return S_OK; } @@ -685,7 +685,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // AmountOffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetY") == 0) { - _amountOffsetY = Value->GetInt(); + _amountOffsetY = value->GetInt(); return S_OK; } @@ -693,7 +693,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // AmountAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountAlign") == 0) { - _amountAlign = (TTextAlign)Value->GetInt(); + _amountAlign = (TTextAlign)value->GetInt(); return S_OK; } @@ -701,11 +701,11 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountString") == 0) { - if (Value->IsNULL()) { + if (value->IsNULL()) { delete[] _amountString; _amountString = NULL; } else { - CBUtils::SetString(&_amountString, Value->GetString()); + CBUtils::SetString(&_amountString, value->GetString()); } return S_OK; } @@ -714,11 +714,11 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *Value) { // CursorCombined ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorCombined") == 0) { - _cursorCombined = Value->GetBool(); + _cursorCombined = value->GetBool(); return S_OK; } - else return CAdTalkHolder::scSetProperty(name, Value); + else return CAdTalkHolder::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index c80cbee7d4..ad59048e53 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -60,7 +60,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 7f1d09ef59..cf82e9db87 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -421,12 +421,12 @@ CScValue *CAdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -434,7 +434,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { // CloseUp ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CloseUp") == 0) { - _closeUp = Value->GetBool(); + _closeUp = value->GetBool(); return S_OK; } @@ -442,7 +442,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = Value->GetInt(); + _width = value->GetInt(); if (_width < 0) _width = 0; return S_OK; } @@ -451,7 +451,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = Value->GetInt(); + _height = value->GetInt(); if (_height < 0) _height = 0; return S_OK; } @@ -460,14 +460,14 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *Value) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - bool b = Value->GetBool(); + bool b = value->GetBool(); if (b == false && _main) { Game->LOG(0, "Warning: cannot deactivate scene's main layer"); } else _active = b; return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 059eac06dc..7c2c595fa2 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -48,7 +48,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 38c2ab94d7..5af718db48 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -715,13 +715,13 @@ CScValue *CAdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { - _active = Value->GetBool(); + _active = value->GetBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // IgnoreItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IgnoreItems") == 0) { - _ignoreItems = Value->GetBool(); + _ignoreItems = value->GetBool(); return S_OK; } @@ -737,7 +737,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SceneIndependent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SceneIndependent") == 0) { - _sceneIndependent = Value->GetBool(); + _sceneIndependent = value->GetBool(); return S_OK; } @@ -745,7 +745,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesWidth") == 0) { - _subtitlesWidth = Value->GetInt(); + _subtitlesWidth = value->GetInt(); return S_OK; } @@ -753,7 +753,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _subtitlesModRelative = Value->GetBool(); + _subtitlesModRelative = value->GetBool(); return S_OK; } @@ -761,7 +761,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosX") == 0) { - _subtitlesModX = Value->GetInt(); + _subtitlesModX = value->GetInt(); return S_OK; } @@ -769,7 +769,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosY") == 0) { - _subtitlesModY = Value->GetInt(); + _subtitlesModY = value->GetInt(); return S_OK; } @@ -777,11 +777,11 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *Value) { // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _subtitlesModXCenter = Value->GetBool(); + _subtitlesModXCenter = value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 44a7fb8e37..462a53c9f7 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -294,12 +294,12 @@ CScValue *CAdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -307,7 +307,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { // Blocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Blocked") == 0) { - _blocked = Value->GetBool(); + _blocked = value->GetBool(); return S_OK; } @@ -315,7 +315,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _decoration = Value->GetBool(); + _decoration = value->GetBool(); return S_OK; } @@ -323,7 +323,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - _zoom = Value->GetFloat(); + _zoom = value->GetFloat(); return S_OK; } @@ -331,11 +331,11 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *Value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)Value->GetInt(); + _alpha = (uint32)value->GetInt(); return S_OK; } - else return CBRegion::scSetProperty(name, Value); + else return CBRegion::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 237936f578..15b794641b 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -48,7 +48,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 1f86fa77fb..69a95df4d2 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1842,12 +1842,12 @@ CScValue *CAdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -1855,7 +1855,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // AutoScroll ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoScroll") == 0) { - _autoScroll = Value->GetBool(); + _autoScroll = value->GetBool(); return S_OK; } @@ -1863,7 +1863,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // PersistentState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentState") == 0) { - _persistentState = Value->GetBool(); + _persistentState = value->GetBool(); return S_OK; } @@ -1871,7 +1871,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentStateSprites") == 0) { - _persistentStateSprites = Value->GetBool(); + _persistentStateSprites = value->GetBool(); return S_OK; } @@ -1879,7 +1879,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsX") == 0) { - _scrollPixelsH = Value->GetInt(); + _scrollPixelsH = value->GetInt(); return S_OK; } @@ -1887,7 +1887,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsY") == 0) { - _scrollPixelsV = Value->GetInt(); + _scrollPixelsV = value->GetInt(); return S_OK; } @@ -1895,7 +1895,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedX") == 0) { - _scrollTimeH = Value->GetInt(); + _scrollTimeH = value->GetInt(); return S_OK; } @@ -1903,7 +1903,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedY") == 0) { - _scrollTimeV = Value->GetInt(); + _scrollTimeV = value->GetInt(); return S_OK; } @@ -1911,7 +1911,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // OffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetX") == 0) { - _offsetLeft = Value->GetInt(); + _offsetLeft = value->GetInt(); int ViewportWidth, ViewportHeight; getViewportSize(&ViewportWidth, &ViewportHeight); @@ -1927,7 +1927,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { // OffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetY") == 0) { - _offsetTop = Value->GetInt(); + _offsetTop = value->GetInt(); int ViewportWidth, ViewportHeight; getViewportSize(&ViewportWidth, &ViewportHeight); @@ -1939,7 +1939,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *Value) { return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 6c6f16eea0..037e5abeca 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -157,7 +157,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 8c7ffdd49d..924dcb9b96 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -311,7 +311,7 @@ HRESULT CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { // Item ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Item")==0){ - SetItem(Value->GetString()); + SetItem(value->GetString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 1e60c33b6a..f3dd9581b6 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -224,16 +224,16 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *Value) { +HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { - _active = Value->GetBool(); + _active = value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index fda11b88c4..bc4b9420f1 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -50,7 +50,7 @@ public: CBArray _points; int _editorSelectedPoint; virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index ab73493e69..1a3b3fdb35 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -113,7 +113,7 @@ HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *scr } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *Value) { +HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *value) { return S_OK; } diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index de9c8f6b7c..db1b6784f7 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -60,7 +60,7 @@ public: HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName); - HRESULT OnVariableChangeValue(CScValue *Var, CScValue *Value); + HRESULT OnVariableChangeValue(CScValue *Var, CScValue *value); HRESULT OnScriptHitBreakpoint(CScScript *script); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 75cf1e02c2..755321de11 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -650,12 +650,12 @@ CScValue *CBFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, Value->GetInt()); + _delay = MAX(0, value->GetInt()); return S_OK; } @@ -663,7 +663,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { // Keyframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyframe") == 0) { - _keyframe = Value->GetBool(); + _keyframe = value->GetBool(); return S_OK; } @@ -671,7 +671,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { // KillSounds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "KillSounds") == 0) { - _killSound = Value->GetBool(); + _killSound = value->GetBool(); return S_OK; } @@ -679,7 +679,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { // MoveX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveX") == 0) { - _moveX = Value->GetInt(); + _moveX = value->GetInt(); return S_OK; } @@ -687,14 +687,14 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *Value) { // MoveY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveY") == 0) { - _moveY = Value->GetInt(); + _moveY = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(name, Value); - else return CBScriptable::scSetProperty(name, Value); + if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(name, value); + else return CBScriptable::scSetProperty(name, value); } } diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 3c0efae6db..18b6061cd6 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -62,7 +62,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index b67a440415..00cb8c16cf 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -226,7 +226,7 @@ public: virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 490bf541fe..ce5f5cf8ce 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -173,18 +173,18 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); if (_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } - else*/ return CBScriptable::scSetProperty(name, Value); + else*/ return CBScriptable::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index 27aeac6ad9..982dc2998f 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -60,7 +60,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 2665d25c97..edab7aa0d2 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -666,12 +666,12 @@ CScValue *CBObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Caption") == 0) { - setCaption(Value->GetString()); + setCaption(value->GetString()); return S_OK; } @@ -679,7 +679,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "X") == 0) { - _posX = Value->GetInt(); + _posX = value->GetInt(); afterMove(); return S_OK; } @@ -688,7 +688,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _posY = Value->GetInt(); + _posY = value->GetInt(); afterMove(); return S_OK; } @@ -697,7 +697,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Movable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Movable") == 0) { - _movable = Value->GetBool(); + _movable = value->GetBool(); return S_OK; } @@ -705,7 +705,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = Value->GetBool(); + _registrable = value->GetBool(); return S_OK; } @@ -713,7 +713,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = Value->GetBool(); + _zoomable = value->GetBool(); return S_OK; } @@ -721,7 +721,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Rotatable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotatable") == 0) { - _rotatable = Value->GetBool(); + _rotatable = value->GetBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)Value->GetInt(); + _alphaColor = (uint32)value->GetInt(); return S_OK; } @@ -737,7 +737,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // BlendMode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { - int i = Value->GetInt(); + int i = value->GetInt(); if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; _blendMode = (TSpriteBlendMode)i; return S_OK; @@ -747,8 +747,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (Value->IsNULL()) _scale = -1; - else _scale = (float)Value->GetFloat(); + if (value->IsNULL()) _scale = -1; + else _scale = (float)value->GetFloat(); return S_OK; } @@ -756,8 +756,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (Value->IsNULL()) _scaleX = -1; - else _scaleX = (float)Value->GetFloat(); + if (value->IsNULL()) _scaleX = -1; + else _scaleX = (float)value->GetFloat(); return S_OK; } @@ -765,8 +765,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (Value->IsNULL()) _scaleY = -1; - else _scaleY = (float)Value->GetFloat(); + if (value->IsNULL()) _scaleY = -1; + else _scaleY = (float)value->GetFloat(); return S_OK; } @@ -774,7 +774,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // RelativeScale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)Value->GetFloat(); + _relativeScale = (float)value->GetFloat(); return S_OK; } @@ -782,11 +782,11 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotate") == 0) { - if (Value->IsNULL()) { + if (value->IsNULL()) { _rotate = 0.0f; _rotateValid = false; } else { - _rotate = (float)Value->GetFloat(); + _rotate = (float)value->GetFloat(); _rotateValid = true; } return S_OK; @@ -796,7 +796,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // RelativeRotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)Value->GetFloat(); + _relativeRotate = (float)value->GetFloat(); return S_OK; } @@ -804,7 +804,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // Colorable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Colorable") == 0) { - _shadowable = Value->GetBool(); + _shadowable = value->GetBool(); return S_OK; } @@ -812,7 +812,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // SoundPanning ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = Value->GetBool(); + _autoSoundPanning = value->GetBool(); if (!_autoSoundPanning) resetSoundPan(); return S_OK; } @@ -821,7 +821,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // SaveState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveState") == 0) { - _saveState = Value->GetBool(); + _saveState = value->GetBool(); return S_OK; } @@ -829,7 +829,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = Value->GetBool(); + _nonIntMouseEvents = value->GetBool(); return S_OK; } @@ -840,7 +840,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *Value) { return S_OK; } - else return CBScriptHolder::scSetProperty(name, Value); + else return CBScriptHolder::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 44bb8c86ca..b217994ada 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -134,7 +134,7 @@ public: public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index d85dfaaa2f..0a3c9ce9f5 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -350,12 +350,12 @@ CScValue *CBRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -363,11 +363,11 @@ HRESULT CBRegion::scSetProperty(const char *name, CScValue *Value) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _active = Value->GetBool(); + _active = value->GetBool(); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index e4050c8ede..e63ae3a170 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -58,7 +58,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 9d2c39e3cb..e68716cbab 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -240,14 +240,14 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBScriptHolder::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; - } else return CBScriptable::scSetProperty(name, Value); + } else return CBScriptable::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 89acae9b55..257a71f255 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -704,12 +704,12 @@ CScValue *CBSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = Value->GetInt(0); + _currentFrame = value->GetInt(0); if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { _currentFrame = -1; } @@ -721,7 +721,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *Value) { // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _precise = Value->GetBool(); + _precise = value->GetBool(); return S_OK; } @@ -729,11 +729,11 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *Value) { // Looping ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Looping") == 0) { - _looping = Value->GetBool(); + _looping = value->GetBool(); return S_OK; } - else return CBScriptHolder::scSetProperty(name, Value); + else return CBScriptHolder::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 88bc8dbe2f..f65ed130c2 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -80,7 +80,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 89ca0c858b..341dcbbdd5 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -473,12 +473,12 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { +HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)Value->GetInt(); + _alpha = (uint32)value->GetInt(); return S_OK; } @@ -486,7 +486,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // Is2DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = Value->GetBool(); + _2DOnly = value->GetBool(); return S_OK; } @@ -494,7 +494,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // Is3DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = Value->GetBool(); + _3DOnly = value->GetBool(); return S_OK; } @@ -502,7 +502,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // MirrorX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = Value->GetBool(); + _mirrorX = value->GetBool(); return S_OK; } @@ -510,7 +510,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // MirrorY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = Value->GetBool(); + _mirrorY = value->GetBool(); return S_OK; } @@ -518,7 +518,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _decoration = Value->GetBool(); + _decoration = value->GetBool(); return S_OK; } @@ -526,7 +526,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // HotspotX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = Value->GetInt(); + _hotspotX = value->GetInt(); return S_OK; } @@ -534,11 +534,11 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *Value) { // HotspotY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = Value->GetInt(); + _hotspotY = value->GetInt(); return S_OK; } - else return CBScriptable::scSetProperty(name, Value); + else return CBScriptable::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 5d4547f722..25fce16159 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -75,7 +75,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 68b919bbe5..1c69f0ed3a 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -834,33 +834,33 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { +HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "X") == 0) { - _posX = Value->GetInt(); + _posX = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _posY = Value->GetInt(); + _posY = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = Value->GetInt(); + _width = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = Value->GetInt(); + _height = value->GetInt(); return S_OK; } @@ -868,21 +868,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Scale1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale1") == 0) { - _scale1 = Value->GetFloat(); + _scale1 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale2") == 0) { - _scale2 = Value->GetFloat(); + _scale2 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = Value->GetBool(); + _scaleZBased = value->GetBool(); return S_OK; } @@ -890,21 +890,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Velocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = Value->GetFloat(); + _velocity1 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = Value->GetFloat(); + _velocity2 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = Value->GetBool(); + _velocityZBased = value->GetBool(); return S_OK; } @@ -912,21 +912,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // LifeTime1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = Value->GetInt(); + _lifeTime1 = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = Value->GetInt(); + _lifeTime2 = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = Value->GetBool(); + _lifeTimeZBased = value->GetBool(); return S_OK; } @@ -934,14 +934,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Angle1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle1") == 0) { - _angle1 = Value->GetInt(); + _angle1 = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle2") == 0) { - _angle2 = Value->GetInt(); + _angle2 = value->GetInt(); return S_OK; } @@ -949,14 +949,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // AngVelocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = Value->GetFloat(); + _angVelocity1 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = Value->GetFloat(); + _angVelocity2 = value->GetFloat(); return S_OK; } @@ -964,14 +964,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Rotation1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = Value->GetFloat(); + _rotation1 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = Value->GetFloat(); + _rotation2 = value->GetFloat(); return S_OK; } @@ -979,7 +979,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Alpha1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = Value->GetInt(); + _alpha1 = value->GetInt(); if (_alpha1 < 0) _alpha1 = 0; if (_alpha1 > 255) _alpha1 = 255; return S_OK; @@ -988,7 +988,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // Alpha2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = Value->GetInt(); + _alpha2 = value->GetInt(); if (_alpha2 < 0) _alpha2 = 0; if (_alpha2 > 255) _alpha2 = 255; return S_OK; @@ -997,7 +997,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = Value->GetBool(); + _alphaTimeBased = value->GetBool(); return S_OK; } @@ -1005,7 +1005,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // MaxParticles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = Value->GetInt(); + _maxParticles = value->GetInt(); return S_OK; } @@ -1013,21 +1013,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // GenerationInterval ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = Value->GetInt(); + _genInterval = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = Value->GetInt(); + _genAmount = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = Value->GetInt(); + _maxBatches = value->GetInt(); return S_OK; } @@ -1035,14 +1035,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // FadeInTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = Value->GetInt(); + _fadeInTime = value->GetInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = Value->GetInt(); + _fadeOutTime = value->GetInt(); return S_OK; } @@ -1050,21 +1050,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // GrowthRate1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = Value->GetFloat(); + _growthRate1 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = Value->GetFloat(); + _growthRate2 = value->GetFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = Value->GetBool(); + _exponentialGrowth = value->GetBool(); return S_OK; } @@ -1072,7 +1072,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { // UseRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UseRegion") == 0) { - _useRegion = Value->GetBool(); + _useRegion = value->GetBool(); return S_OK; } @@ -1082,11 +1082,11 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *Value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!Value->IsNULL()) CBUtils::SetString(&_emitEvent, Value->GetString()); + if (!value->IsNULL()) CBUtils::SetString(&_emitEvent, value->GetString()); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index b4e751be8f..7464173eb3 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -119,7 +119,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 5cabe598a5..1a8dfdba64 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -166,13 +166,13 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::scSetProperty(const char *name, CScValue *Value) { +HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length") == 0) { int OrigLength = _length; - _length = MAX(Value->GetInt(0), 0); + _length = MAX(value->GetInt(0), 0); char PropName[20]; if (_length < OrigLength) { @@ -192,7 +192,7 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *Value) { if (ValidNumber(name, ParamName)) { int Index = atoi(ParamName); if (Index >= _length) _length = Index + 1; - return _values->SetProp(ParamName, Value); + return _values->SetProp(ParamName, value); } else return E_FAIL; } } diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index 51e0a0047c..deb52bd86a 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -42,7 +42,7 @@ public: CSXArray(CBGame *inGame); virtual ~CSXArray(); CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); int _length; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 039a9abe0a..5026ebdd8e 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -223,13 +223,13 @@ CScValue *CSXDate::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::scSetProperty(const char *name, CScValue *Value) { +HRESULT CSXDate::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Name")==0){ - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 7d658ea826..72e91e6136 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -41,7 +41,7 @@ public: CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); char *_string; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index b7eb794e81..b897ca9701 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -641,14 +641,14 @@ CScValue *CSXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::scSetProperty(const char *name, CScValue *Value) { +HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Length")==0){ int OrigLength = _length; - _length = max(Value->GetInt(0), 0); + _length = max(value->GetInt(0), 0); char PropName[20]; if(_length < OrigLength){ @@ -659,7 +659,7 @@ HRESULT CSXFile::scSetProperty(const char *name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::scSetProperty(name, Value); + else*/ return CBScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index 39c7f7b954..b28fca019e 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -41,7 +41,7 @@ class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXFile(CBGame *inGame, CScStack *Stack); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index f65f800a4e..82a9a1f5e2 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -431,14 +431,14 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *Value) { +HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Length")==0){ int OrigLength = _length; - _length = max(Value->GetInt(0), 0); + _length = max(value->GetInt(0), 0); char PropName[20]; if(_length < OrigLength){ @@ -449,7 +449,7 @@ HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *Value) { } return S_OK; } - else*/ return CBScriptable::scSetProperty(name, Value); + else*/ return CBScriptable::scSetProperty(name, value); } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index ba62162cc4..13b98b589d 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -39,7 +39,7 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXMemBuffer(CBGame *inGame, CScStack *Stack); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 4db6ad413c..4a912df5fe 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -352,12 +352,12 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::scSetProperty(const char *name, CScValue *Value) { +HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { - int NewCap = Value->GetInt(); + int NewCap = value->GetInt(); if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); else if (NewCap != _capacity) { char *NewStr = new char[NewCap]; diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index 5f662c3289..93bae35616 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -39,7 +39,7 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *Value); + HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void scSetString(const char *Val); const char *scToString(); diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 8dac129788..f10aa7085b 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -66,16 +66,16 @@ CScValue *CScStack::Pop() { ////////////////////////////////////////////////////////////////////////// -void CScStack::Push(CScValue *Val) { +void CScStack::Push(CScValue *val) { _sP++; if (_sP < _values.GetSize()) { _values[_sP]->cleanup(); - _values[_sP]->Copy(Val); + _values[_sP]->Copy(val); } else { - CScValue *val = new CScValue(Game); - val->Copy(Val); - _values.Add(val); + CScValue *copyVal = new CScValue(Game); + copyVal->Copy(val); + _values.Add(copyVal); } } @@ -102,10 +102,10 @@ CScValue *CScStack::GetTop() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetAt(int Index) { - Index = _sP - Index; - if (Index < 0 || Index >= _values.GetSize()) return NULL; - else return _values[Index]; +CScValue *CScStack::GetAt(int index) { + index = _sP - index; + if (index < 0 || index >= _values.GetSize()) return NULL; + else return _values[index]; } @@ -152,55 +152,55 @@ void CScStack::PushNULL() { ////////////////////////////////////////////////////////////////////////// -void CScStack::PushInt(int Val) { +void CScStack::PushInt(int val) { /* CScValue* val = new CScValue(Game); val->SetInt(Val); Push(val); delete val; */ - GetPushValue()->SetInt(Val); + GetPushValue()->SetInt(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushFloat(double Val) { +void CScStack::PushFloat(double val) { /* CScValue* val = new CScValue(Game); val->SetFloat(Val); Push(val); delete val; */ - GetPushValue()->SetFloat(Val); + GetPushValue()->SetFloat(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushBool(bool Val) { +void CScStack::PushBool(bool val) { /* CScValue* val = new CScValue(Game); val->SetBool(Val); Push(val); delete val; */ - GetPushValue()->SetBool(Val); + GetPushValue()->SetBool(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushString(const char *Val) { +void CScStack::PushString(const char *val) { /* CScValue* val = new CScValue(Game); val->SetString(Val); Push(val); delete val; */ - GetPushValue()->SetString(Val); + GetPushValue()->SetString(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushNative(CBScriptable *Val, bool Persistent) { +void CScStack::PushNative(CBScriptable *val, bool persistent) { /* CScValue* val = new CScValue(Game); val->SetNative(Val, Persistent); @@ -208,7 +208,7 @@ void CScStack::PushNative(CBScriptable *Val, bool Persistent) { delete val; */ - GetPushValue()->SetNative(Val, Persistent); + GetPushValue()->SetNative(val, persistent); } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 8409de7b96..aede849ecc 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -872,43 +872,43 @@ HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariable ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, int Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); +bool CScValue::SetProperty(const char *propName, int value) { + CScValue *Val = new CScValue(Game, value); + bool Ret = SUCCEEDED(SetProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, const char *Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); +bool CScValue::SetProperty(const char *propName, const char *value) { + CScValue *Val = new CScValue(Game, value); + bool Ret = SUCCEEDED(SetProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, double Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); +bool CScValue::SetProperty(const char *propName, double value) { + CScValue *Val = new CScValue(Game, value); + bool Ret = SUCCEEDED(SetProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName, bool Value) { - CScValue *Val = new CScValue(Game, Value); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); +bool CScValue::SetProperty(const char *propName, bool value) { + CScValue *Val = new CScValue(Game, value); + bool Ret = SUCCEEDED(SetProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *PropName) { +bool CScValue::SetProperty(const char *propName) { CScValue *Val = new CScValue(Game); - bool Ret = SUCCEEDED(SetProp(PropName, Val)); + bool Ret = SUCCEEDED(SetProp(propName, Val)); delete Val; return Ret; } @@ -1001,19 +1001,19 @@ int CScValue::DbgGetNumProperties() { } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(Index, Name, Value); +bool CScValue::DbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(index, name, value); else { - int Count = 0; + int count = 0; _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - if (Count == Index) { - *Name = _valIter->_key.c_str(); - *Value = _valIter->_value; + if (count == index) { + *name = _valIter->_key.c_str(); + *value = _valIter->_value; return true; } _valIter++; - Count++; + count++; } return false; } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index ea20e29490..9829114d3a 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -967,12 +967,12 @@ CScValue *CUIButton::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { - int i = Value->GetInt(); + int i = value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _align = (TTextAlign)i; return S_OK; @@ -982,25 +982,25 @@ HRESULT CUIButton::scSetProperty(const char *name, CScValue *Value) { // Focusable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Focusable") == 0) { - _canFocus = Value->GetBool(); + _canFocus = value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pressed") == 0) { - _stayPressed = Value->GetBool(); + _stayPressed = value->GetBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _pixelPerfect = Value->GetBool(); + _pixelPerfect = value->GetBool(); return S_OK; } - else return CUIObject::scSetProperty(name, Value); + else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 07bc18bc65..e89c37aa0c 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -69,7 +69,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 4678f81d9a..f0d4d62874 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -457,12 +457,12 @@ CScValue *CUIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelStart") == 0) { - _selStart = Value->GetInt(); + _selStart = value->GetInt(); _selStart = MAX(_selStart, 0); _selStart = MIN((size_t)_selStart, strlen(_text)); return S_OK; @@ -472,7 +472,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { // SelEnd ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelEnd") == 0) { - _selEnd = Value->GetInt(); + _selEnd = value->GetInt(); _selEnd = MAX(_selEnd, 0); _selEnd = MIN((size_t)_selEnd, strlen(_text)); return S_OK; @@ -482,7 +482,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = Value->GetInt(); + _cursorBlinkRate = value->GetInt(); return S_OK; } @@ -490,7 +490,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { // CursorChar ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorChar") == 0) { - setCursorChar(Value->GetString()); + setCursorChar(value->GetString()); return S_OK; } @@ -498,7 +498,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { // FrameWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FrameWidth") == 0) { - _frameWidth = Value->GetInt(); + _frameWidth = value->GetInt(); return S_OK; } @@ -506,7 +506,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { // MaxLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxLength") == 0) { - _maxLength = Value->GetInt(); + _maxLength = value->GetInt(); return S_OK; } @@ -515,15 +515,15 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *Value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Value->GetString()); + WideString wstr = StringUtil::Utf8ToWide(value->GetString()); setText(StringUtil::WideToAnsi(wstr).c_str()); } else { - setText(Value->GetString()); + setText(value->GetString()); } return S_OK; } - else return CUIObject::scSetProperty(name, Value); + else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 8477e6f9d5..2ee2d3ea3a 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -62,7 +62,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index afba22cc49..2db966f89d 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -310,14 +310,14 @@ CScValue *CUIEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Freezable") == 0) { - if (_entity) _entity->makeFreezable(Value->GetBool()); + if (_entity) _entity->makeFreezable(value->GetBool()); return S_OK; - } else return CUIObject::scSetProperty(name, Value); + } else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 55c5790ef5..670973fdeb 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -48,7 +48,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index c23415287c..45037ec490 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -418,12 +418,12 @@ CScValue *CUIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -431,7 +431,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // ParentNotify ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParentNotify") == 0) { - _parentNotify = Value->GetBool(); + _parentNotify = value->GetBool(); return S_OK; } @@ -439,7 +439,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = Value->GetInt(); + _width = value->GetInt(); return S_OK; } @@ -447,7 +447,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = Value->GetInt(); + _height = value->GetInt(); return S_OK; } @@ -455,7 +455,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // Visible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Visible") == 0) { - _visible = Value->GetBool(); + _visible = value->GetBool(); return S_OK; } @@ -463,7 +463,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // Disabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Disabled") == 0) { - _disable = Value->GetBool(); + _disable = value->GetBool(); return S_OK; } @@ -471,11 +471,11 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *Value) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { - setText(Value->GetString()); + setText(value->GetString()); return S_OK; } - else return CBObject::scSetProperty(name, Value); + else return CBObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index bc49c01a2f..f1ebd81f8c 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -73,7 +73,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index e5b89e15df..e73006c28d 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -434,12 +434,12 @@ CScValue *CUIText::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { - int i = Value->GetInt(); + int i = value->GetInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _textAlign = (TTextAlign)i; return S_OK; @@ -449,13 +449,13 @@ HRESULT CUIText::scSetProperty(const char *name, CScValue *Value) { // VerticalAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VerticalAlign") == 0) { - int i = Value->GetInt(); + int i = value->GetInt(); if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; _verticalAlign = (TVerticalAlign)i; return S_OK; } - else return CUIObject::scSetProperty(name, Value); + else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index bb0b6a4d84..1f5029e4a6 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -49,7 +49,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 4e0590ab15..26c60702cb 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1005,12 +1005,12 @@ CScValue *CUIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { +HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(Value->GetString()); + setName(value->GetString()); return S_OK; } @@ -1018,7 +1018,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // Menu ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Menu") == 0) { - _isMenu = Value->GetBool(); + _isMenu = value->GetBool(); return S_OK; } @@ -1026,7 +1026,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // InGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InGame") == 0) { - _inGame = Value->GetBool(); + _inGame = value->GetBool(); return S_OK; } @@ -1034,7 +1034,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // PauseMusic ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0) { - _pauseMusic = Value->GetBool(); + _pauseMusic = value->GetBool(); return S_OK; } @@ -1042,7 +1042,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // ClipContents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClipContents") == 0) { - _clipContents = Value->GetBool(); + _clipContents = value->GetBool(); return S_OK; } @@ -1050,7 +1050,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // Transparent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Transparent") == 0) { - _transparent = Value->GetBool(); + _transparent = value->GetBool(); return S_OK; } @@ -1058,7 +1058,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // FadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeColor") == 0) { - _fadeColor = (uint32)Value->GetInt(); + _fadeColor = (uint32)value->GetInt(); _fadeBackground = (_fadeColor != 0); return S_OK; } @@ -1067,7 +1067,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // Exclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exclusive") == 0) { - if (Value->GetBool()) + if (value->GetBool()) goExclusive(); else { close(); @@ -1080,7 +1080,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { // SystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SystemExclusive") == 0) { - if (Value->GetBool()) + if (value->GetBool()) goSystemExclusive(); else { close(); @@ -1089,7 +1089,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *Value) { return S_OK; } - else return CUIObject::scSetProperty(name, Value); + else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index e22a09027d..80dcda9333 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -83,7 +83,7 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *Value); + virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 845c2e21c6..2f66313bb0 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -120,11 +120,11 @@ void CBUtils::DebugMessage(HWND hWnd, const char *Text) { ////////////////////////////////////////////////////////////////////////// -char *CBUtils::SetString(char **String, const char *Value) { - delete[] *String; - *String = new char[strlen(Value) + 1]; - if (*String) strcpy(*String, Value); - return *String; +char *CBUtils::SetString(char **string, const char *value) { + delete[] *string; + *string = new char[strlen(value) + 1]; + if (*string) strcpy(*string, value); + return *string; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From c27d6585df61efc8b1ff5917de2dc3ae8b5d4248 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:08:59 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in ScStack --- engines/wintermute/Ad/AdActor.cpp | 44 +- engines/wintermute/Ad/AdEntity.cpp | 62 +- engines/wintermute/Ad/AdGame.cpp | 212 +++--- engines/wintermute/Ad/AdItem.cpp | 60 +- engines/wintermute/Ad/AdLayer.cpp | 38 +- engines/wintermute/Ad/AdObject.cpp | 138 ++-- engines/wintermute/Ad/AdRegion.cpp | 8 +- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdScene.cpp | 204 +++--- engines/wintermute/Ad/AdTalkHolder.cpp | 50 +- engines/wintermute/Base/BFrame.cpp | 66 +- engines/wintermute/Base/BGame.cpp | 752 ++++++++++----------- engines/wintermute/Base/BKeyboardState.cpp | 6 +- engines/wintermute/Base/BObject.cpp | 156 ++--- engines/wintermute/Base/BRegion.cpp | 48 +- engines/wintermute/Base/BScriptHolder.cpp | 38 +- engines/wintermute/Base/BScriptable.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 40 +- engines/wintermute/Base/BSubFrame.cpp | 16 +- engines/wintermute/Base/PartEmitter.cpp | 84 +-- engines/wintermute/Base/scriptables/SXArray.cpp | 18 +- engines/wintermute/Base/scriptables/SXDate.cpp | 82 +-- engines/wintermute/Base/scriptables/SXFile.cpp | 182 ++--- engines/wintermute/Base/scriptables/SXMath.cpp | 88 +-- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 164 ++--- engines/wintermute/Base/scriptables/SXStore.cpp | 66 +- engines/wintermute/Base/scriptables/SXString.cpp | 58 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 +- engines/wintermute/Base/scriptables/ScScript.cpp | 226 +++---- engines/wintermute/Base/scriptables/ScStack.cpp | 38 +- engines/wintermute/Base/scriptables/ScStack.h | 24 +- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- engines/wintermute/UI/UIButton.cpp | 116 ++-- engines/wintermute/UI/UIEdit.cpp | 6 +- engines/wintermute/UI/UIEntity.cpp | 14 +- engines/wintermute/UI/UIObject.cpp | 58 +- engines/wintermute/UI/UIText.cpp | 8 +- engines/wintermute/UI/UIWindow.cpp | 92 +-- 38 files changed, 1638 insertions(+), 1638 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 5653ed2f24..d6ed8a35c3 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -855,12 +855,12 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); goTo(X, Y); if (strcmp(name, "GoToAsync") != 0) script->WaitForExclusive(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -868,24 +868,24 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GoToObject / GoToObjectAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (!Val->IsNative()) { script->RuntimeError("actor.%s method accepts an entity refrence only", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } CAdObject *Obj = (CAdObject *)Val->GetNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { script->RuntimeError("actor.%s method accepts an entity refrence only", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } CAdEntity *Ent = (CAdEntity *)Obj; if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); if (strcmp(name, "GoToObjectAsync") != 0) script->WaitForExclusive(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -893,9 +893,9 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // TurnTo / TurnToAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); int dir; - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); // turn to object? if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { @@ -910,7 +910,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi turnTo((TDirection)dir); if (strcmp(name, "TurnToAsync") != 0) script->WaitForExclusive(this); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -918,8 +918,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsWalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsWalking") == 0) { - stack->CorrectParams(0); - stack->PushBool(_state == STATE_FOLLOWING_PATH); + stack->correctParams(0); + stack->pushBool(_state == STATE_FOLLOWING_PATH); return S_OK; } @@ -927,8 +927,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // MergeAnims ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MergeAnims") == 0) { - stack->CorrectParams(1); - stack->PushBool(SUCCEEDED(mergeAnims(stack->Pop()->GetString()))); + stack->correctParams(1); + stack->pushBool(SUCCEEDED(mergeAnims(stack->pop()->GetString()))); return S_OK; } @@ -936,8 +936,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // UnloadAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadAnim") == 0) { - stack->CorrectParams(1); - const char *AnimName = stack->Pop()->GetString(); + stack->correctParams(1); + const char *AnimName = stack->pop()->GetString(); bool Found = false; for (int i = 0; i < _anims.GetSize(); i++) { @@ -954,7 +954,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi Found = true; } } - stack->PushBool(Found); + stack->pushBool(Found); return S_OK; } @@ -962,9 +962,9 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // HasAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasAnim") == 0) { - stack->CorrectParams(1); - const char *AnimName = stack->Pop()->GetString(); - stack->PushBool(getAnimByName(AnimName) != NULL); + stack->correctParams(1); + const char *AnimName = stack->pop()->GetString(); + stack->pushBool(getAnimByName(AnimName) != NULL); return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index e6ea8a24a6..2b4a2871f0 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -630,10 +630,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // StopSound ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { - stack->CorrectParams(0); + stack->correctParams(0); - if (FAILED(stopSFX(false))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(stopSFX(false))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -641,11 +641,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { - stack->CorrectParams(4); - const char *filename = stack->Pop()->GetString(); - bool looping = stack->Pop()->GetBool(false); - CScValue *valAlpha = stack->Pop(); - int startTime = stack->Pop()->GetInt(); + stack->correctParams(4); + const char *filename = stack->pop()->GetString(); + bool looping = stack->pop()->GetBool(false); + CScValue *valAlpha = stack->pop(); + int startTime = stack->pop()->GetInt(); delete _theora; _theora = new CVidTheoraPlayer(Game); @@ -653,10 +653,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!valAlpha->IsNULL()) _theora->setAlphaImage(valAlpha->GetString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; - stack->PushBool(true); + stack->pushBool(true); } else { script->RuntimeError("Entity.PlayTheora - error playing video '%s'", filename); - stack->PushBool(false); + stack->pushBool(false); } return S_OK; @@ -666,13 +666,13 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // StopTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopTheora") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_theora) { _theora->stop(); delete _theora; _theora = NULL; - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -681,9 +681,9 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // IsTheoraPlaying ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTheoraPlaying") == 0) { - stack->CorrectParams(0); - if (_theora && _theora->isPlaying()) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(0); + if (_theora && _theora->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -692,11 +692,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // PauseTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseTheora") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_theora && _theora->isPlaying()) { _theora->pause(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -705,11 +705,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ResumeTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeTheora") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_theora && _theora->isPaused()) { _theora->resume(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -718,9 +718,9 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // IsTheoraPaused ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTheoraPaused") == 0) { - stack->CorrectParams(0); - if (_theora && _theora->isPaused()) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(0); + if (_theora && _theora->isPaused()) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -730,13 +730,13 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateRegion") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (!_region) { _region = new CBRegion(Game); Game->RegisterObject(_region); } - if (_region) stack->PushNative(_region, true); - else stack->PushNULL(); + if (_region) stack->pushNative(_region, true); + else stack->pushNULL(); return S_OK; } @@ -745,12 +745,12 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // DeleteRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteRegion") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_region) { Game->UnregisterObject(_region); _region = NULL; - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 5bf1b6691c..cbcf488abb 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -321,22 +321,22 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ChangeScene ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "ChangeScene") == 0) { - stack->CorrectParams(3); - const char *Filename = stack->Pop()->GetString(); - CScValue *valFadeOut = stack->Pop(); - CScValue *valFadeIn = stack->Pop(); + stack->correctParams(3); + const char *Filename = stack->pop()->GetString(); + CScValue *valFadeOut = stack->pop(); + CScValue *valFadeIn = stack->pop(); bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); ScheduleChangeScene(Filename, TransIn); if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true); - stack->PushNULL(); + stack->pushNULL(); - //HRESULT ret = ChangeScene(stack->Pop()->GetString()); - //if(FAILED(ret)) stack->PushBool(false); - //else stack->PushBool(true); + //HRESULT ret = ChangeScene(stack->pop()->GetString()); + //if(FAILED(ret)) stack->pushBool(false); + //else stack->pushBool(true); return S_OK; } @@ -345,15 +345,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // LoadActor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadActor") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) { AddObject(act); - stack->PushNative(act, true); + stack->pushNative(act, true); } else { delete act; act = NULL; - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -362,15 +362,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // LoadEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) { AddObject(ent); - stack->PushNative(ent, true); + stack->pushNative(ent, true); } else { delete ent; ent = NULL; - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -379,13 +379,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); CAdObject *obj = (CAdObject *)val->GetNative(); RemoveObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -393,13 +393,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // CreateEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdEntity *Ent = new CAdEntity(Game); AddObject(Ent); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - stack->PushNative(Ent, true); + stack->pushNative(Ent, true); return S_OK; } @@ -407,13 +407,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // CreateItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateItem") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdItem *Item = new CAdItem(Game); AddItem(Item); if (!Val->IsNULL()) Item->setName(Val->GetString()); - stack->PushNative(Item, true); + stack->pushNative(Item, true); return S_OK; } @@ -421,8 +421,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // DeleteItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteItem") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdItem *Item = NULL; if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); @@ -432,7 +432,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this DeleteItem(Item); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -440,8 +440,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // QueryItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "QueryItem") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdItem *Item = NULL; if (Val->IsInt()) { @@ -451,8 +451,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this Item = GetItemByName(Val->GetString()); } - if (Item) stack->PushNative(Item, true); - else stack->PushNULL(); + if (Item) stack->pushNative(Item, true); + else stack->pushNULL(); return S_OK; } @@ -462,13 +462,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // AddResponse/AddResponseOnce/AddResponseOnceGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { - stack->CorrectParams(6); - int id = stack->Pop()->GetInt(); - const char *text = stack->Pop()->GetString(); - CScValue *val1 = stack->Pop(); - CScValue *val2 = stack->Pop(); - CScValue *val3 = stack->Pop(); - CScValue *val4 = stack->Pop(); + stack->correctParams(6); + int id = stack->pop()->GetInt(); + const char *text = stack->pop()->GetString(); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + CScValue *val4 = stack->pop(); if (_responseBox) { CAdResponse *res = new CAdResponse(Game); @@ -489,7 +489,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } else { script->RuntimeError("Game.AddResponse: response box is not defined"); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -498,10 +498,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ResetResponse ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResetResponse") == 0) { - stack->CorrectParams(1); - int ID = stack->Pop()->GetInt(-1); + stack->correctParams(1); + int ID = stack->pop()->GetInt(-1); ResetResponse(ID); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -509,10 +509,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ClearResponses ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClearResponses") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _responseBox->clearResponses(); _responseBox->clearButtons(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -520,20 +520,20 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetResponse ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponse") == 0) { - stack->CorrectParams(1); - bool AutoSelectLast = stack->Pop()->GetBool(); + stack->correctParams(1); + bool AutoSelectLast = stack->pop()->GetBool(); if (_responseBox) { _responseBox->weedResponses(); if (_responseBox->_responses.GetSize() == 0) { - stack->PushNULL(); + stack->pushNULL(); return S_OK; } if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { - stack->PushInt(_responseBox->_responses[0]->_iD); + stack->pushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); return S_OK; @@ -546,7 +546,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _stateEx = GAME_WAITING_RESPONSE; } else { script->RuntimeError("Game.GetResponse: response box is not defined"); - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -556,13 +556,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetNumResponses ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetNumResponses") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_responseBox) { _responseBox->weedResponses(); - stack->PushInt(_responseBox->_responses.GetSize()); + stack->pushInt(_responseBox->_responses.GetSize()); } else { script->RuntimeError("Game.GetNumResponses: response box is not defined"); - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -572,15 +572,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // StartDlgBranch ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartDlgBranch") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); Common::String BranchName; if (Val->IsNULL()) { BranchName.format("line%d", script->_currentLine); } else BranchName = Val->GetString(); StartDlgBranch(BranchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -589,14 +589,14 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // EndDlgBranch ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EndDlgBranch") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); const char *BranchName = NULL; - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); if (!Val->IsNULL()) BranchName = Val->GetString(); EndDlgBranch(BranchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -605,11 +605,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetCurrentDlgBranch ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCurrentDlgBranch") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_dlgPendingBranches.GetSize() > 0) { - stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); - } else stack->PushNULL(); + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); + } else stack->pushNULL(); return S_OK; } @@ -646,26 +646,26 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // IsItemTaken ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsItemTaken") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (!val->IsNULL()) { for (int i = 0; i < _inventories.GetSize(); i++) { CAdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { if (val->GetNative() == Inv->_takenItems[j]) { - stack->PushBool(true); + stack->pushBool(true); return S_OK; } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { - stack->PushBool(true); + stack->pushBool(true); return S_OK; } } } } else script->RuntimeError("Game.IsItemTaken: item name expected"); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -673,11 +673,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetInventoryWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInventoryWindow") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_inventoryBox && _inventoryBox->_window) - stack->PushNative(_inventoryBox->_window, true); + stack->pushNative(_inventoryBox->_window, true); else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -686,11 +686,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetResponsesWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_responseBox && _responseBox->_window) - stack->PushNative(_responseBox->_window, true); + stack->pushNative(_responseBox->_window, true); else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -699,18 +699,18 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // LoadResponseBox ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadResponseBox") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); Game->UnregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); if (_responseBox && !FAILED(_responseBox->loadFile(Filename))) { RegisterObject(_responseBox); - stack->PushBool(true); + stack->pushBool(true); } else { delete _responseBox; _responseBox = NULL; - stack->PushBool(false); + stack->pushBool(false); } return S_OK; } @@ -719,18 +719,18 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // LoadInventoryBox ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadInventoryBox") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); Game->UnregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); if (_inventoryBox && !FAILED(_inventoryBox->loadFile(Filename))) { RegisterObject(_inventoryBox); - stack->PushBool(true); + stack->pushBool(true); } else { delete _inventoryBox; _inventoryBox = NULL; - stack->PushBool(false); + stack->pushBool(false); } return S_OK; } @@ -739,12 +739,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // LoadItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadItems") == 0) { - stack->CorrectParams(2); - const char *Filename = stack->Pop()->GetString(); - bool Merge = stack->Pop()->GetBool(false); + stack->correctParams(2); + const char *Filename = stack->pop()->GetString(); + bool Merge = stack->pop()->GetBool(false); HRESULT Ret = LoadItemsFile(Filename, Merge); - stack->PushBool(SUCCEEDED(Ret)); + stack->pushBool(SUCCEEDED(Ret)); return S_OK; } @@ -753,9 +753,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // AddSpeechDir ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSpeechDir") == 0) { - stack->CorrectParams(1); - const char *Dir = stack->Pop()->GetString(); - stack->PushBool(SUCCEEDED(AddSpeechDir(Dir))); + stack->correctParams(1); + const char *Dir = stack->pop()->GetString(); + stack->pushBool(SUCCEEDED(AddSpeechDir(Dir))); return S_OK; } @@ -764,9 +764,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // RemoveSpeechDir ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSpeechDir") == 0) { - stack->CorrectParams(1); - const char *Dir = stack->Pop()->GetString(); - stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir))); + stack->correctParams(1); + const char *Dir = stack->pop()->GetString(); + stack->pushBool(SUCCEEDED(RemoveSpeechDir(Dir))); return S_OK; } @@ -775,11 +775,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetSceneViewport ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSceneViewport") == 0) { - stack->CorrectParams(4); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - int Width = stack->Pop()->GetInt(); - int Height = stack->Pop()->GetInt(); + stack->correctParams(4); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + int Width = stack->pop()->GetInt(); + int Height = stack->pop()->GetInt(); if (Width <= 0) Width = _renderer->_width; if (Height <= 0) Height = _renderer->_height; @@ -787,7 +787,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(X, Y, X + Width, Y + Height); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -1065,22 +1065,22 @@ HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *this // Actor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Actor") == 0) { - stack->CorrectParams(0); - this_obj = thisStack->GetTop(); + stack->correctParams(0); + this_obj = thisStack->getTop(); this_obj->SetNative(new CAdActor(Game)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Entity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Entity") == 0) { - stack->CorrectParams(0); - this_obj = thisStack->GetTop(); + stack->correctParams(0); + this_obj = thisStack->getTop(); this_obj->SetNative(new CAdEntity(Game)); - stack->PushNULL(); + stack->pushNULL(); } @@ -1520,12 +1520,12 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) { if (strcmp(name, "CreateEntityContainer") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIEntity *Ent = new CUIEntity(Game); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - stack->PushNative(Ent, true); + stack->pushNative(Ent, true); Ent->_parent = Win; Win->_widgets.Add(Ent); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 4388aef86c..69d7e115da 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -434,23 +434,23 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetHoverSprite ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetHoverSprite") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); bool SetCurrent = false; if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); delete _spriteHover; _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { - stack->PushBool(false); + stack->pushBool(false); script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); } else { _spriteHover = spr; if (SetCurrent) _currentSprite = _spriteHover; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -459,10 +459,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetHoverSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverSprite") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_spriteHover || !_spriteHover->_filename) stack->PushNULL(); - else stack->PushString(_spriteHover->_filename); + if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); + else stack->pushString(_spriteHover->_filename); return S_OK; } @@ -470,9 +470,9 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetHoverSpriteObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverSpriteObject") == 0) { - stack->CorrectParams(0); - if (!_spriteHover) stack->PushNULL(); - else stack->PushNative(_spriteHover, true); + stack->correctParams(0); + if (!_spriteHover) stack->pushNULL(); + else stack->pushNative(_spriteHover, true); return S_OK; } @@ -480,19 +480,19 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetNormalCursor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetNormalCursor") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); delete _cursorNormal; _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(Filename))) { - stack->PushBool(false); + stack->pushBool(false); script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); } else { _cursorNormal = spr; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -501,10 +501,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetNormalCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetNormalCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_cursorNormal || !_cursorNormal->_filename) stack->PushNULL(); - else stack->PushString(_cursorNormal->_filename); + if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); + else stack->pushString(_cursorNormal->_filename); return S_OK; } @@ -512,10 +512,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetNormalCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetNormalCursorObject") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_cursorNormal) stack->PushNULL(); - else stack->PushNative(_cursorNormal, true); + if (!_cursorNormal) stack->pushNULL(); + else stack->pushNative(_cursorNormal, true); return S_OK; } @@ -523,19 +523,19 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetHoverCursor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetHoverCursor") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); delete _cursorHover; _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(Filename))) { - stack->PushBool(false); + stack->pushBool(false); script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); } else { _cursorHover = spr; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -544,10 +544,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetHoverCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_cursorHover || !_cursorHover->_filename) stack->PushNULL(); - else stack->PushString(_cursorHover->_filename); + if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); + else stack->pushString(_cursorHover->_filename); return S_OK; } @@ -555,10 +555,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetHoverCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverCursorObject") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_cursorHover) stack->PushNULL(); - else stack->PushNative(_cursorHover, true); + if (!_cursorHover) stack->pushNULL(); + else stack->pushNative(_cursorHover, true); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index cf82e9db87..25d292f44e 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -232,8 +232,8 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetNode ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetNode") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); int node = -1; if (val->_type == VAL_INT) node = val->GetInt(); @@ -247,17 +247,17 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } - if (node < 0 || node >= _nodes.GetSize()) stack->PushNULL(); + if (node < 0 || node >= _nodes.GetSize()) stack->pushNULL(); else { switch (_nodes[node]->_type) { case OBJECT_ENTITY: - stack->PushNative(_nodes[node]->_entity, true); + stack->pushNative(_nodes[node]->_entity, true); break; case OBJECT_REGION: - stack->PushNative(_nodes[node]->_region, true); + stack->pushNative(_nodes[node]->_region, true); break; default: - stack->PushNULL(); + stack->pushNULL(); } } return S_OK; @@ -267,20 +267,20 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // AddRegion / AddEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(name, "AddRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->setRegion(Region); - stack->PushNative(Region, true); + stack->pushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->setEntity(Entity); - stack->PushNative(Entity, true); + stack->pushNative(Entity, true); } _nodes.Add(Node); return S_OK; @@ -290,21 +290,21 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // InsertRegion / InsertEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { - stack->CorrectParams(2); - int Index = stack->Pop()->GetInt(); - CScValue *Val = stack->Pop(); + stack->correctParams(2); + int Index = stack->pop()->GetInt(); + CScValue *Val = stack->pop(); CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(name, "InsertRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); if (!Val->IsNULL()) Region->setName(Val->GetString()); Node->setRegion(Region); - stack->PushNative(Region, true); + stack->pushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); if (!Val->IsNULL()) Entity->setName(Val->GetString()); Node->setEntity(Entity); - stack->PushNative(Entity, true); + stack->pushNative(Entity, true); } if (Index < 0) Index = 0; if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); @@ -317,8 +317,8 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // DeleteNode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteNode") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdSceneNode *ToDelete = NULL; if (Val->IsNative()) { @@ -336,7 +336,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } if (ToDelete == NULL) { - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -348,7 +348,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi break; } } - stack->PushBool(true); + stack->pushBool(true); return S_OK; } diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 5af718db48..58c892dae8 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -193,11 +193,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // PlayAnim / PlayAnimAsync ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { - stack->CorrectParams(1); - if (FAILED(playAnim(stack->Pop()->GetString()))) stack->PushBool(false); + stack->correctParams(1); + if (FAILED(playAnim(stack->pop()->GetString()))) stack->pushBool(false); else { if (strcmp(name, "PlayAnimAsync") != 0) script->WaitFor(this); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -206,9 +206,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Reset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); reset(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -216,8 +216,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // IsTalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTalking") == 0) { - stack->CorrectParams(0); - stack->PushBool(_state == STATE_TALKING); + stack->correctParams(0); + stack->pushBool(_state == STATE_TALKING); return S_OK; } @@ -225,13 +225,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // StopTalk / StopTalking ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_sentence) _sentence->finish(); if (_state == STATE_TALKING) { _state = _nextState; _nextState = STATE_READY; - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -239,13 +239,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ForceTalkAnim ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ForceTalkAnim") == 0) { - stack->CorrectParams(1); - const char *AnimName = stack->Pop()->GetString(); + stack->correctParams(1); + const char *AnimName = stack->pop()->GetString(); delete[] _forcedTalkAnimName; _forcedTalkAnimName = new char[strlen(AnimName) + 1]; strcpy(_forcedTalkAnimName, AnimName); _forcedTalkAnimUsed = false; - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -254,17 +254,17 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Talk / TalkAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { - stack->CorrectParams(5); + stack->correctParams(5); - const char *Text = stack->Pop()->GetString(); - CScValue *SoundVal = stack->Pop(); - int Duration = stack->Pop()->GetInt(); - CScValue *ValStances = stack->Pop(); + const char *Text = stack->pop()->GetString(); + CScValue *SoundVal = stack->pop(); + int Duration = stack->pop()->GetInt(); + CScValue *ValStances = stack->pop(); const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); int Align; - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (val->IsNULL()) Align = TAL_CENTER; else Align = val->GetInt(); @@ -275,7 +275,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th talk(Text, Sound, Duration, Stances, (TTextAlign)Align); if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -283,13 +283,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // StickToRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StickToRegion") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; bool RegFound = false; int i; - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); if (Val->IsNULL() || !Main) { _stickRegion = NULL; RegFound = true; @@ -316,7 +316,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } if (!RegFound) _stickRegion = NULL; - stack->PushBool(RegFound); + stack->pushBool(RegFound); return S_OK; } @@ -324,13 +324,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsNULL()) SetFont(NULL); else SetFont(Val->GetString()); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -338,9 +338,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFont") == 0) { - stack->CorrectParams(0); - if (_font && _font->_filename) stack->PushString(_font->_filename); - else stack->PushNULL(); + stack->correctParams(0); + if (_font && _font->_filename) stack->pushString(_font->_filename); + else stack->pushNULL(); return S_OK; } @@ -348,17 +348,17 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // TakeItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TakeItem") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (!val->IsNULL()) { const char *ItemName = val->GetString(); - val = stack->Pop(); + val = stack->pop(); const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { @@ -368,7 +368,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } else script->RuntimeError("TakeItem: item name expected"); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -376,14 +376,14 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // DropItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DropItem") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (!val->IsNULL()) { if (FAILED(_inventory->RemoveItem(val->GetString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); else { @@ -392,7 +392,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } } else script->RuntimeError("DropItem: item name expected"); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -400,22 +400,22 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetItem") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (val->_type == VAL_STRING) { CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); - if (item) stack->PushNative(item, true); - else stack->PushNULL(); + if (item) stack->pushNative(item, true); + else stack->pushNULL(); } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) - stack->PushNULL(); + stack->pushNULL(); else - stack->PushNative(_inventory->_takenItems[val->GetInt()], true); + stack->pushNative(_inventory->_takenItems[val->GetInt()], true); return S_OK; } @@ -424,27 +424,27 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // HasItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasItem") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (!_inventory) { _inventory = new CAdInventory(Game); ((CAdGame *)Game)->RegisterInventory(_inventory); } - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (!val->IsNULL()) { for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { if (val->GetNative() == _inventory->_takenItems[i]) { - stack->PushBool(true); + stack->pushBool(true); return S_OK; } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { - stack->PushBool(true); + stack->pushBool(true); return S_OK; } } } else script->RuntimeError("HasItem: item name expected"); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -452,14 +452,14 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateParticleEmitter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateParticleEmitter") == 0) { - stack->CorrectParams(3); - bool FollowParent = stack->Pop()->GetBool(); - int OffsetX = stack->Pop()->GetInt(); - int OffsetY = stack->Pop()->GetInt(); + stack->correctParams(3); + bool FollowParent = stack->pop()->GetBool(); + int OffsetX = stack->pop()->GetInt(); + int OffsetY = stack->pop()->GetInt(); CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY); - if (Emitter) stack->PushNative(_partEmitter, true); - else stack->PushNULL(); + if (Emitter) stack->pushNative(_partEmitter, true); + else stack->pushNULL(); return S_OK; } @@ -468,12 +468,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // DeleteParticleEmitter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteParticleEmitter") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_partEmitter) { Game->UnregisterObject(_partEmitter); _partEmitter = NULL; } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -482,11 +482,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // AddAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddAttachment") == 0) { - stack->CorrectParams(4); - const char *Filename = stack->Pop()->GetString(); - bool PreDisplay = stack->Pop()->GetBool(true); - int OffsetX = stack->Pop()->GetInt(); - int OffsetY = stack->Pop()->GetInt(); + stack->correctParams(4); + const char *Filename = stack->pop()->GetString(); + bool PreDisplay = stack->pop()->GetBool(true); + int OffsetX = stack->pop()->GetInt(); + int OffsetY = stack->pop()->GetInt(); HRESULT res; CAdEntity *Ent = new CAdEntity(Game); @@ -494,7 +494,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete Ent; Ent = NULL; script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); - stack->PushBool(false); + stack->pushBool(false); } else { Game->RegisterObject(Ent); @@ -505,7 +505,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (PreDisplay) _attachmentsPre.Add(Ent); else _attachmentsPost.Add(Ent); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; @@ -515,8 +515,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // RemoveAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveAttachment") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); bool Found = false; if (Val->IsNative()) { CBScriptable *Obj = Val->GetNative(); @@ -555,7 +555,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } } } - stack->PushBool(Found); + stack->pushBool(Found); return S_OK; } @@ -564,8 +564,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetAttachment ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetAttachment") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdObject *Ret = NULL; if (Val->IsInt()) { @@ -597,8 +597,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } } - if (Ret != NULL) stack->PushNative(Ret, true); - else stack->PushNULL(); + if (Ret != NULL) stack->pushNative(Ret, true); + else stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 462a53c9f7..42730b2567 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -225,10 +225,10 @@ HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SkipTo ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SkipTo")==0) { - stack->CorrectParams(2); - _posX = stack->Pop()->GetInt(); - _posY = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(2); + _posX = stack->pop()->GetInt(); + _posY = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 1f226c0d5d..912022d7dd 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -492,7 +492,7 @@ HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { } else if (scumm_stricmp(obj->_name, "next") == 0) { _scrollOffset++; } else if (scumm_stricmp(obj->_name, "response") == 0) { - if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD); + if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); handleResponse(_responses[param2]); _waitingScript = NULL; Game->_state = GAME_RUNNING; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 69a95df4d2..f567a8b058 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1253,15 +1253,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // LoadActor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LoadActor") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) { addObject(act); - stack->PushNative(act, true); + stack->pushNative(act, true); } else { delete act; act = NULL; - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -1270,15 +1270,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // LoadEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) { addObject(ent); - stack->PushNative(ent, true); + stack->pushNative(ent, true); } else { delete ent; ent = NULL; - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -1287,13 +1287,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // CreateEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdEntity *Ent = new CAdEntity(Game); addObject(Ent); if (!Val->IsNULL()) Ent->setName(Val->GetString()); - stack->PushNative(Ent, true); + stack->pushNative(Ent, true); return S_OK; } @@ -1301,13 +1301,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); CAdObject *obj = (CAdObject *)val->GetNative(); removeObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1315,15 +1315,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SkipTo ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SkipTo") == 0) { - stack->CorrectParams(2); - CScValue *val1 = stack->Pop(); - CScValue *val2 = stack->Pop(); + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); if (val1->IsNative()) { skipToObject((CBObject *)val1->GetNative()); } else { skipTo(val1->GetInt(), val2->GetInt()); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1331,16 +1331,16 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // ScrollTo / ScrollToAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { - stack->CorrectParams(2); - CScValue *val1 = stack->Pop(); - CScValue *val2 = stack->Pop(); + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); if (val1->IsNative()) { scrollToObject((CBObject *)val1->GetNative()); } else { scrollTo(val1->GetInt(), val2->GetInt()); } if (strcmp(name, "ScrollTo") == 0) script->WaitForExclusive(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1348,23 +1348,23 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetLayer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetLayer") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); if (val->IsInt()) { int layer = val->GetInt(); - if (layer < 0 || layer >= _layers.GetSize()) stack->PushNULL(); - else stack->PushNative(_layers[layer], true); + if (layer < 0 || layer >= _layers.GetSize()) stack->pushNULL(); + else stack->pushNative(_layers[layer], true); } else { const char *LayerName = val->GetString(); bool LayerFound = false; for (int i = 0; i < _layers.GetSize(); i++) { if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { - stack->PushNative(_layers[i], true); + stack->pushNative(_layers[i], true); LayerFound = true; break; } } - if (!LayerFound) stack->PushNULL(); + if (!LayerFound) stack->pushNULL(); } return S_OK; } @@ -1373,10 +1373,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetWaypointGroup ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaypointGroup") == 0) { - stack->CorrectParams(1); - int group = stack->Pop()->GetInt(); - if (group < 0 || group >= _waypointGroups.GetSize()) stack->PushNULL(); - else stack->PushNative(_waypointGroups[group], true); + stack->correctParams(1); + int group = stack->pop()->GetInt(); + if (group < 0 || group >= _waypointGroups.GetSize()) stack->pushNULL(); + else stack->pushNative(_waypointGroups[group], true); return S_OK; } @@ -1384,12 +1384,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetNode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetNode") == 0) { - stack->CorrectParams(1); - const char *nodeName = stack->Pop()->GetString(); + stack->correctParams(1); + const char *nodeName = stack->pop()->GetString(); CBObject *node = getNodeByName(nodeName); - if (node) stack->PushNative((CBScriptable *)node, true); - else stack->PushNULL(); + if (node) stack->pushNative((CBScriptable *)node, true); + else stack->pushNULL(); return S_OK; } @@ -1398,8 +1398,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetFreeNode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFreeNode") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdObject *Ret = NULL; if (Val->IsInt()) { @@ -1414,8 +1414,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } } - if (Ret) stack->PushNative(Ret, true); - else stack->PushNULL(); + if (Ret) stack->pushNative(Ret, true); + else stack->pushNULL(); return S_OK; } @@ -1424,10 +1424,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetRegionAt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRegionAt") == 0) { - stack->CorrectParams(3); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - CScValue *Val = stack->Pop(); + stack->correctParams(3); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + CScValue *Val = stack->pop(); bool IncludeDecors = false; if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); @@ -1438,12 +1438,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { if (Node->_region->_decoration && !IncludeDecors) continue; - stack->PushNative(Node->_region, true); + stack->pushNative(Node->_region, true); return S_OK; } } } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1451,11 +1451,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsBlockedAt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsBlockedAt") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); - stack->PushBool(isBlockedAt(X, Y)); + stack->pushBool(isBlockedAt(X, Y)); return S_OK; } @@ -1463,11 +1463,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsWalkableAt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsWalkableAt") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); - stack->PushBool(isWalkableAt(X, Y)); + stack->pushBool(isWalkableAt(X, Y)); return S_OK; } @@ -1475,11 +1475,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetScaleAt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetScaleAt") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); - stack->PushFloat(getZoomAt(X, Y)); + stack->pushFloat(getZoomAt(X, Y)); return S_OK; } @@ -1487,11 +1487,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetRotationAt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRotationAt") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); - stack->PushFloat(getRotationAt(X, Y)); + stack->pushFloat(getRotationAt(X, Y)); return S_OK; } @@ -1499,13 +1499,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsScrolling ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScrolling") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); bool Ret = false; if (_autoScroll) { if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; } - stack->PushBool(Ret); + stack->pushBool(Ret); return S_OK; } @@ -1513,17 +1513,17 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // FadeOut / FadeOutAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { - stack->CorrectParams(5); - uint32 Duration = stack->Pop()->GetInt(500); - byte Red = stack->Pop()->GetInt(0); - byte Green = stack->Pop()->GetInt(0); - byte Blue = stack->Pop()->GetInt(0); - byte Alpha = stack->Pop()->GetInt(0xFF); + stack->correctParams(5); + uint32 Duration = stack->pop()->GetInt(500); + byte Red = stack->pop()->GetInt(0); + byte Green = stack->pop()->GetInt(0); + byte Blue = stack->pop()->GetInt(0); + byte Alpha = stack->pop()->GetInt(0xFF); _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1531,17 +1531,17 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // FadeIn / FadeInAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { - stack->CorrectParams(5); - uint32 Duration = stack->Pop()->GetInt(500); - byte Red = stack->Pop()->GetInt(0); - byte Green = stack->Pop()->GetInt(0); - byte Blue = stack->Pop()->GetInt(0); - byte Alpha = stack->Pop()->GetInt(0xFF); + stack->correctParams(5); + uint32 Duration = stack->pop()->GetInt(500); + byte Red = stack->pop()->GetInt(0); + byte Green = stack->pop()->GetInt(0); + byte Blue = stack->pop()->GetInt(0); + byte Alpha = stack->pop()->GetInt(0xFF); _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1549,8 +1549,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetFadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFadeColor") == 0) { - stack->CorrectParams(0); - stack->PushInt(_fader->getCurrentColor()); + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); return S_OK; } @@ -1558,10 +1558,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsPointInViewport ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsPointInViewport") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - stack->PushBool(pointInViewport(X, Y)); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + stack->pushBool(pointInViewport(X, Y)); return S_OK; } @@ -1569,11 +1569,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetViewport ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetViewport") == 0) { - stack->CorrectParams(4); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - int Width = stack->Pop()->GetInt(); - int Height = stack->Pop()->GetInt(); + stack->correctParams(4); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + int Width = stack->pop()->GetInt(); + int Height = stack->pop()->GetInt(); if (Width <= 0) Width = Game->_renderer->_width; if (Height <= 0) Height = Game->_renderer->_height; @@ -1581,7 +1581,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(X, Y, X + Width, Y + Height); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -1590,8 +1590,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // AddLayer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddLayer") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->setName(Val->GetString()); @@ -1602,7 +1602,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _layers.Add(Layer); Game->RegisterObject(Layer); - stack->PushNative(Layer, true); + stack->pushNative(Layer, true); return S_OK; } @@ -1610,9 +1610,9 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // InsertLayer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertLayer") == 0) { - stack->CorrectParams(2); - int Index = stack->Pop()->GetInt(); - CScValue *Val = stack->Pop(); + stack->correctParams(2); + int Index = stack->pop()->GetInt(); + CScValue *Val = stack->pop(); CAdLayer *Layer = new CAdLayer(Game); if (!Val->IsNULL()) Layer->setName(Val->GetString()); @@ -1626,7 +1626,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi Game->RegisterObject(Layer); - stack->PushNative(Layer, true); + stack->pushNative(Layer, true); return S_OK; } @@ -1634,8 +1634,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // DeleteLayer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteLayer") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CAdLayer *ToDelete = NULL; if (Val->IsNative()) { @@ -1653,13 +1653,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } if (ToDelete == NULL) { - stack->PushBool(false); + stack->pushBool(false); return S_OK; } if (ToDelete->_main) { script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -1670,7 +1670,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi break; } } - stack->PushBool(true); + stack->pushBool(true); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 924dcb9b96..67e225a444 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -123,9 +123,9 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetSprite ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSprite") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); bool SetCurrent = false; if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; @@ -136,17 +136,17 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (Val->IsNULL()) { _sprite = NULL; if (SetCurrent) _currentSprite = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { const char *Filename = Val->GetString(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { script->RuntimeError("SetSprite method failed for file '%s'", Filename); - stack->PushBool(false); + stack->pushBool(false); } else { _sprite = spr; if (SetCurrent) _currentSprite = _sprite; - stack->PushBool(true); + stack->pushBool(true); } } return S_OK; @@ -156,10 +156,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSprite") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_sprite || !_sprite->_filename) stack->PushNULL(); - else stack->PushString(_sprite->_filename); + if (!_sprite || !_sprite->_filename) stack->pushNULL(); + else stack->pushString(_sprite->_filename); return S_OK; } @@ -167,10 +167,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetSpriteObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSpriteObject") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_sprite) stack->PushNULL(); - else stack->PushNative(_sprite, true); + if (!_sprite) stack->pushNULL(); + else stack->pushNative(_sprite, true); return S_OK; } @@ -178,19 +178,19 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // AddTalkSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddTalkSprite") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - const char *Filename = stack->Pop()->GetString(); - bool Ex = stack->Pop()->GetBool(); + const char *Filename = stack->pop()->GetString(); + bool Ex = stack->pop()->GetBool(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { - stack->PushBool(false); + stack->pushBool(false); script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); } else { if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -199,10 +199,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // RemoveTalkSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveTalkSprite") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - const char *Filename = stack->Pop()->GetString(); - bool Ex = stack->Pop()->GetBool(); + const char *Filename = stack->pop()->GetString(); + bool Ex = stack->pop()->GetBool(); int i; bool SetCurrent = false; @@ -231,7 +231,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack } - stack->PushBool(true); + stack->pushBool(true); if (SetCurrent) _currentSprite = _sprite; if (SetTemp2) _tempSprite2 = _sprite; @@ -242,16 +242,16 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetTalkSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetTalkSprite") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - const char *Filename = stack->Pop()->GetString(); - bool Ex = stack->Pop()->GetBool(); + const char *Filename = stack->pop()->GetString(); + bool Ex = stack->pop()->GetBool(); bool SetCurrent = false; bool SetTemp2 = false; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { - stack->PushBool(false); + stack->pushBool(false); script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); } else { @@ -276,7 +276,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack // set new if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); - stack->PushBool(true); + stack->pushBool(true); if (SetCurrent) _currentSprite = spr; if (SetTemp2) _tempSprite2 = spr; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 755321de11..34b5ebbe47 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -407,10 +407,10 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetSound ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetSound") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (_sound && _sound->_soundFilename) stack->PushString(_sound->_soundFilename); - else stack->PushNULL(); + if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); + else stack->pushNULL(); return S_OK; } @@ -418,19 +418,19 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetSound ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSound") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); delete _sound; _sound = NULL; if (!Val->IsNULL()) { _sound = new CBSound(Game); if (!_sound || FAILED(_sound->setSound(Val->GetString(), SOUND_SFX, false))) { - stack->PushBool(false); + stack->pushBool(false); delete _sound; _sound = NULL; - } else stack->PushBool(true); - } else stack->PushBool(true); + } else stack->pushBool(true); + } else stack->pushBool(true); return S_OK; } @@ -438,12 +438,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetSubframe ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetSubframe") == 0) { - stack->CorrectParams(1); - int Index = stack->Pop()->GetInt(-1); + stack->correctParams(1); + int Index = stack->pop()->GetInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); - stack->PushNULL(); - } else stack->PushNative(_subframes[Index], true); + stack->pushNULL(); + } else stack->pushNative(_subframes[Index], true); return S_OK; } @@ -452,8 +452,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // DeleteSubframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteSubframe") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { @@ -469,7 +469,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } } } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -477,8 +477,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // AddSubframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSubframe") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -489,7 +489,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } _subframes.Add(Sub); - stack->PushNative(Sub, true); + stack->pushNative(Sub, true); return S_OK; } @@ -497,11 +497,11 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // InsertSubframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertSubframe") == 0) { - stack->CorrectParams(2); - int Index = stack->Pop()->GetInt(); + stack->correctParams(2); + int Index = stack->pop()->GetInt(); if (Index < 0) Index = 0; - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -513,7 +513,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (Index >= _subframes.GetSize()) _subframes.Add(Sub); else _subframes.InsertAt(Index, Sub); - stack->PushNative(Sub, true); + stack->pushNative(Sub, true); return S_OK; } @@ -521,12 +521,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSubframe") == 0) { - stack->CorrectParams(1); - int Index = stack->Pop()->GetInt(-1); + stack->correctParams(1); + int Index = stack->pop()->GetInt(-1); if (Index < 0 || Index >= _applyEvent.GetSize()) { script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); - stack->PushNULL(); - } else stack->PushString(_applyEvent[Index]); + stack->pushNULL(); + } else stack->pushString(_applyEvent[Index]); return S_OK; } @@ -534,16 +534,16 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // AddEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddEvent") == 0) { - stack->CorrectParams(1); - const char *Event = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Event = stack->pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { - stack->PushNULL(); + stack->pushNULL(); return S_OK; } } _applyEvent.Add(Event); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -551,8 +551,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // DeleteEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteEvent") == 0) { - stack->CorrectParams(1); - const char *Event = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Event = stack->pop()->GetString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { delete [] _applyEvent[i]; @@ -560,7 +560,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this break; } } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index d7cc2332a5..2c60521e54 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -982,9 +982,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // LOG ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LOG") == 0) { - stack->CorrectParams(1); - LOG(0, stack->Pop()->GetString()); - stack->PushNULL(); + stack->correctParams(1); + LOG(0, stack->pop()->GetString()); + stack->pushNULL(); return S_OK; } @@ -1001,9 +1001,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // Msg ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Msg") == 0) { - stack->CorrectParams(1); - QuickMessage(stack->Pop()->GetString()); - stack->PushNULL(); + stack->correctParams(1); + QuickMessage(stack->pop()->GetString()); + stack->pushNULL(); return S_OK; } @@ -1012,11 +1012,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RunScript") == 0) { Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - stack->CorrectParams(1); - if (FAILED(addScript(stack->Pop()->GetString()))) - stack->PushBool(false); + stack->correctParams(1); + if (FAILED(addScript(stack->pop()->GetString()))) + stack->pushBool(false); else - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -1025,18 +1025,18 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // LoadStringTable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadStringTable") == 0) { - stack->CorrectParams(2); - const char *filename = stack->Pop()->GetString(); - CScValue *Val = stack->Pop(); + stack->correctParams(2); + const char *filename = stack->pop()->GetString(); + CScValue *Val = stack->pop(); bool ClearOld; if (Val->IsNULL()) ClearOld = true; else ClearOld = Val->GetBool(); if (FAILED(_stringTable->loadFile(filename, ClearOld))) - stack->PushBool(false); + stack->pushBool(false); else - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -1045,10 +1045,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ValidObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidObject") == 0) { - stack->CorrectParams(1); - CBScriptable *obj = stack->Pop()->GetNative(); - if (ValidObject((CBObject *) obj)) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(1); + CBScriptable *obj = stack->pop()->GetNative(); + if (ValidObject((CBObject *) obj)) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -1057,9 +1057,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // Reset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); ResetContent(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1069,13 +1069,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // UnloadObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); CBObject *obj = (CBObject *)val->GetNative(); UnregisterObject(obj); if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1083,16 +1083,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // LoadWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadWindow") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->loadFile(stack->Pop()->GetString()))) { + if (win && SUCCEEDED(win->loadFile(stack->pop()->GetString()))) { _windows.Add(win); RegisterObject(win); - stack->PushNative(win, true); + stack->pushNative(win, true); } else { delete win; win = NULL; - stack->PushNULL(); + stack->pushNULL(); } return S_OK; } @@ -1101,12 +1101,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ExpandString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExpandString") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); char *str = new char[strlen(val->GetString()) + 1]; strcpy(str, val->GetString()); _stringTable->Expand(&str); - stack->PushString(str); + stack->pushString(str); delete [] str; return S_OK; } @@ -1116,22 +1116,22 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->CorrectParams(3); + if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); else { - stack->CorrectParams(4); - channel = stack->Pop()->GetInt(); + stack->correctParams(4); + channel = stack->pop()->GetInt(); } - const char *filename = stack->Pop()->GetString(); - CScValue *ValLooping = stack->Pop(); + const char *filename = stack->pop()->GetString(); + CScValue *ValLooping = stack->pop(); bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); - CScValue *ValLoopStart = stack->Pop(); + CScValue *ValLoopStart = stack->pop(); uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); - if (FAILED(PlayMusic(channel, filename, Looping, LoopStart))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(PlayMusic(channel, filename, Looping, LoopStart))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -1141,14 +1141,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "StopMusic") == 0) stack->CorrectParams(0); + if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (FAILED(StopMusic(channel))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(StopMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -1158,14 +1158,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PauseMusic") == 0) stack->CorrectParams(0); + if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (FAILED(PauseMusic(channel))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(PauseMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -1174,14 +1174,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->CorrectParams(0); + if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (FAILED(ResumeMusic(channel))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(ResumeMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -1190,15 +1190,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->CorrectParams(0); + if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->PushNULL(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->PushNULL(); - else stack->PushString(_music[channel]->_soundFilename); + if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); + else stack->pushString(_music[channel]->_soundFilename); } return S_OK; } @@ -1208,16 +1208,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->CorrectParams(1); + if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); else { - stack->CorrectParams(2); - channel = stack->Pop()->GetInt(); + stack->correctParams(2); + channel = stack->pop()->GetInt(); } - uint32 Time = stack->Pop()->GetInt(); + uint32 Time = stack->pop()->GetInt(); - if (FAILED(SetMusicStartTime(channel, Time))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(SetMusicStartTime(channel, Time))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -1227,14 +1227,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->CorrectParams(0); + if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushInt(0); - else stack->PushInt(_music[channel]->getPositionTime()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getPositionTime()); return S_OK; } @@ -1243,14 +1243,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->CorrectParams(0); + if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushBool(false); - else stack->PushBool(_music[channel]->isPlaying()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else stack->pushBool(_music[channel]->isPlaying()); return S_OK; } @@ -1259,17 +1259,17 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->CorrectParams(1); + if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); else { - stack->CorrectParams(2); - channel = stack->Pop()->GetInt(); + stack->correctParams(2); + channel = stack->pop()->GetInt(); } - int Volume = stack->Pop()->GetInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushBool(false); + int Volume = stack->pop()->GetInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else { - if (FAILED(_music[channel]->setVolume(Volume))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(_music[channel]->setVolume(Volume))) stack->pushBool(false); + else stack->pushBool(true); } return S_OK; } @@ -1279,14 +1279,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->CorrectParams(0); + if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); else { - stack->CorrectParams(1); - channel = stack->Pop()->GetInt(); + stack->correctParams(1); + channel = stack->pop()->GetInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->PushInt(0); - else stack->PushInt(_music[channel]->getVolume()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getVolume()); return S_OK; } @@ -1295,15 +1295,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // MusicCrossfade ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicCrossfade") == 0) { - stack->CorrectParams(4); - int channel1 = stack->Pop()->GetInt(0); - int channel2 = stack->Pop()->GetInt(0); - uint32 FadeLength = (uint32)stack->Pop()->GetInt(0); - bool Swap = stack->Pop()->GetBool(true); + stack->correctParams(4); + int channel1 = stack->pop()->GetInt(0); + int channel2 = stack->pop()->GetInt(0); + uint32 FadeLength = (uint32)stack->pop()->GetInt(0); + bool Swap = stack->pop()->GetBool(true); if (_musicCrossfadeRunning) { script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -1315,7 +1315,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _musicCrossfadeRunning = true; - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -1323,10 +1323,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetSoundLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundLength") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); int Length = 0; - const char *filename = stack->Pop()->GetString(); + const char *filename = stack->pop()->GetString(); CBSound *Sound = new CBSound(Game); if (Sound && SUCCEEDED(Sound->setSound(filename, SOUND_MUSIC, true))) { @@ -1334,7 +1334,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete Sound; Sound = NULL; } - stack->PushInt(Length); + stack->pushInt(Length); return S_OK; } @@ -1342,9 +1342,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetMousePos ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMousePos") == 0) { - stack->CorrectParams(2); - int x = stack->Pop()->GetInt(); - int y = stack->Pop()->GetInt(); + stack->correctParams(2); + int x = stack->pop()->GetInt(); + int y = stack->pop()->GetInt(); x = MAX(x, 0); x = MIN(x, _renderer->_width); y = MAX(y, 0); @@ -1355,7 +1355,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBPlatform::SetCursorPos(p.x, p.y); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1363,18 +1363,18 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // LockMouseRect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LockMouseRect") == 0) { - stack->CorrectParams(4); - int left = stack->Pop()->GetInt(); - int top = stack->Pop()->GetInt(); - int right = stack->Pop()->GetInt(); - int bottom = stack->Pop()->GetInt(); + stack->correctParams(4); + int left = stack->pop()->GetInt(); + int top = stack->pop()->GetInt(); + int right = stack->pop()->GetInt(); + int bottom = stack->pop()->GetInt(); if (right < left) CBUtils::Swap(&left, &right); if (bottom < top) CBUtils::Swap(&top, &bottom); CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1382,8 +1382,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // PlayVideo ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayVideo") == 0) { - /* stack->CorrectParams(0); - stack->PushBool(false); + /* stack->correctParams(0); + stack->pushBool(false); return S_OK; // TODO: ADDVIDEO @@ -1391,19 +1391,19 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - stack->CorrectParams(6); - const char *filename = stack->Pop()->GetString(); + stack->correctParams(6); + const char *filename = stack->pop()->GetString(); warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->Pop(); + CScValue *valType = stack->pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - bool FreezeMusic = stack->Pop()->GetBool(true); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + bool FreezeMusic = stack->pop()->GetBool(true); - CScValue *valSub = stack->Pop(); + CScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) @@ -1411,10 +1411,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (SUCCEEDED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { - stack->PushBool(true); + stack->pushBool(true); script->Sleep(0); - } else stack->PushBool(false); - } else stack->PushBool(false); + } else stack->pushBool(false); + } else stack->pushBool(false); return S_OK; } @@ -1423,26 +1423,26 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { - /* stack->CorrectParams(0); - stack->PushBool(false); + /* stack->correctParams(0); + stack->pushBool(false); return S_OK;*/ // TODO: ADDVIDEO - stack->CorrectParams(7); - const char *filename = stack->Pop()->GetString(); - CScValue *valType = stack->Pop(); + stack->correctParams(7); + const char *filename = stack->pop()->GetString(); + CScValue *valType = stack->pop(); int Type; if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->GetInt(); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); - bool FreezeMusic = stack->Pop()->GetBool(true); - bool DropFrames = stack->Pop()->GetBool(true); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); + bool FreezeMusic = stack->pop()->GetBool(true); + bool DropFrames = stack->pop()->GetBool(true); - CScValue *valSub = stack->Pop(); + CScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; @@ -1452,11 +1452,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !DropFrames; if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { - stack->PushBool(true); + stack->pushBool(true); script->Sleep(0); - } else stack->PushBool(false); + } else stack->pushBool(false); } else { - stack->PushBool(false); + stack->pushBool(false); delete _theoraPlayer; _theoraPlayer = NULL; } @@ -1468,8 +1468,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // QuitGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "QuitGame") == 0) { - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); _quitting = true; return S_OK; } @@ -1478,11 +1478,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RegWriteNumber ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteNumber") == 0) { - stack->CorrectParams(2); - const char *Key = stack->Pop()->GetString(); - int Val = stack->Pop()->GetInt(); + stack->correctParams(2); + const char *Key = stack->pop()->GetString(); + int Val = stack->pop()->GetInt(); _registry->WriteInt("PrivateSettings", Key, Val); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1490,10 +1490,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RegReadNumber ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadNumber") == 0) { - stack->CorrectParams(2); - const char *Key = stack->Pop()->GetString(); - int InitVal = stack->Pop()->GetInt(); - stack->PushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); + stack->correctParams(2); + const char *Key = stack->pop()->GetString(); + int InitVal = stack->pop()->GetInt(); + stack->pushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); return S_OK; } @@ -1501,11 +1501,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RegWriteString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteString") == 0) { - stack->CorrectParams(2); - const char *Key = stack->Pop()->GetString(); - const char *Val = stack->Pop()->GetString(); + stack->correctParams(2); + const char *Key = stack->pop()->GetString(); + const char *Val = stack->pop()->GetString(); _registry->WriteString("PrivateSettings", Key, Val); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1513,11 +1513,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RegReadString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadString") == 0) { - stack->CorrectParams(2); - const char *Key = stack->Pop()->GetString(); - const char *InitVal = stack->Pop()->GetString(); + stack->correctParams(2); + const char *Key = stack->pop()->GetString(); + const char *InitVal = stack->pop()->GetString(); AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); - stack->PushString(val.c_str()); + stack->pushString(val.c_str()); return S_OK; } @@ -1525,17 +1525,17 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SaveGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveGame") == 0) { - stack->CorrectParams(3); - int Slot = stack->Pop()->GetInt(); - const char *xdesc = stack->Pop()->GetString(); - bool quick = stack->Pop()->GetBool(false); + stack->correctParams(3); + int Slot = stack->pop()->GetInt(); + const char *xdesc = stack->pop()->GetString(); + bool quick = stack->pop()->GetBool(false); char *Desc = new char[strlen(xdesc) + 1]; strcpy(Desc, xdesc); - stack->PushBool(true); + stack->pushBool(true); if (FAILED(SaveGame(Slot, Desc, quick))) { - stack->Pop(); - stack->PushBool(false); + stack->pop(); + stack->pushBool(false); } delete [] Desc; return S_OK; @@ -1545,10 +1545,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // LoadGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadGame") == 0) { - stack->CorrectParams(1); - _scheduledLoadSlot = stack->Pop()->GetInt(); + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->GetInt(); _loading = true; - stack->PushBool(false); + stack->pushBool(false); script->Sleep(0); return S_OK; } @@ -1557,9 +1557,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // IsSaveSlotUsed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSaveSlotUsed") == 0) { - stack->CorrectParams(1); - int Slot = stack->Pop()->GetInt(); - stack->PushBool(IsSaveSlotUsed(Slot)); + stack->correctParams(1); + int Slot = stack->pop()->GetInt(); + stack->pushBool(IsSaveSlotUsed(Slot)); return S_OK; } @@ -1567,12 +1567,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetSaveSlotDescription ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSaveSlotDescription") == 0) { - stack->CorrectParams(1); - int Slot = stack->Pop()->GetInt(); + stack->correctParams(1); + int Slot = stack->pop()->GetInt(); char Desc[512]; Desc[0] = '\0'; GetSaveSlotDescription(Slot, Desc); - stack->PushString(Desc); + stack->pushString(Desc); return S_OK; } @@ -1580,10 +1580,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // EmptySaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->CorrectParams(1); - int Slot = stack->Pop()->GetInt(); + stack->correctParams(1); + int Slot = stack->pop()->GetInt(); EmptySaveSlot(Slot); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1591,9 +1591,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetGlobalSFXVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSFXVolume") == 0) { - stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->Pop()->GetInt()); - stack->PushNULL(); + stack->correctParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->pop()->GetInt()); + stack->pushNULL(); return S_OK; } @@ -1601,9 +1601,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetGlobalSpeechVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { - stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->Pop()->GetInt()); - stack->PushNULL(); + stack->correctParams(1); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->pop()->GetInt()); + stack->pushNULL(); return S_OK; } @@ -1611,9 +1611,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetGlobalMusicVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMusicVolume") == 0) { - stack->CorrectParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->Pop()->GetInt()); - stack->PushNULL(); + stack->correctParams(1); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->pop()->GetInt()); + stack->pushNULL(); return S_OK; } @@ -1621,9 +1621,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetGlobalMasterVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMasterVolume") == 0) { - stack->CorrectParams(1); - Game->_soundMgr->setMasterVolumePercent((byte)stack->Pop()->GetInt()); - stack->PushNULL(); + stack->correctParams(1); + Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->GetInt()); + stack->pushNULL(); return S_OK; } @@ -1631,8 +1631,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetGlobalSFXVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalSFXVolume") == 0) { - stack->CorrectParams(0); - stack->PushInt(_soundMgr->getVolumePercent(SOUND_SFX)); + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(SOUND_SFX)); return S_OK; } @@ -1640,8 +1640,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetGlobalSpeechVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { - stack->CorrectParams(0); - stack->PushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return S_OK; } @@ -1649,8 +1649,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetGlobalMusicVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalMusicVolume") == 0) { - stack->CorrectParams(0); - stack->PushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return S_OK; } @@ -1658,8 +1658,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetGlobalMasterVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalMasterVolume") == 0) { - stack->CorrectParams(0); - stack->PushInt(_soundMgr->getMasterVolumePercent()); + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); return S_OK; } @@ -1667,9 +1667,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetActiveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetActiveCursor") == 0) { - stack->CorrectParams(1); - if (SUCCEEDED(setActiveCursor(stack->Pop()->GetString()))) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(1); + if (SUCCEEDED(setActiveCursor(stack->pop()->GetString()))) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -1678,9 +1678,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetActiveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursor") == 0) { - stack->CorrectParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->PushNULL(); - else stack->PushString(_activeCursor->_filename); + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); + else stack->pushString(_activeCursor->_filename); return S_OK; } @@ -1689,9 +1689,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetActiveCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursorObject") == 0) { - stack->CorrectParams(0); - if (!_activeCursor) stack->PushNULL(); - else stack->PushNative(_activeCursor, true); + stack->correctParams(0); + if (!_activeCursor) stack->pushNULL(); + else stack->pushNative(_activeCursor, true); return S_OK; } @@ -1700,10 +1700,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RemoveActiveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveActiveCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); delete _activeCursor; _activeCursor = NULL; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1712,10 +1712,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // HasActiveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasActiveCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (_activeCursor) stack->PushBool(true); - else stack->PushBool(false); + if (_activeCursor) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -1724,14 +1724,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // FileExists ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FileExists") == 0) { - stack->CorrectParams(1); - const char *filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *filename = stack->pop()->GetString(); Common::SeekableReadStream *File = _fileManager->openFile(filename, false); - if (!File) stack->PushBool(false); + if (!File) stack->pushBool(false); else { _fileManager->closeFile(File); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -1740,19 +1740,19 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { - stack->CorrectParams(5); - uint32 Duration = stack->Pop()->GetInt(500); - byte Red = stack->Pop()->GetInt(0); - byte Green = stack->Pop()->GetInt(0); - byte Blue = stack->Pop()->GetInt(0); - byte Alpha = stack->Pop()->GetInt(0xFF); + stack->correctParams(5); + uint32 Duration = stack->pop()->GetInt(500); + byte Red = stack->pop()->GetInt(0); + byte Green = stack->pop()->GetInt(0); + byte Blue = stack->pop()->GetInt(0); + byte Alpha = stack->pop()->GetInt(0xFF); bool System = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->WaitFor(_fader); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1760,19 +1760,19 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { - stack->CorrectParams(5); - uint32 Duration = stack->Pop()->GetInt(500); - byte Red = stack->Pop()->GetInt(0); - byte Green = stack->Pop()->GetInt(0); - byte Blue = stack->Pop()->GetInt(0); - byte Alpha = stack->Pop()->GetInt(0xFF); + stack->correctParams(5); + uint32 Duration = stack->pop()->GetInt(500); + byte Red = stack->pop()->GetInt(0); + byte Green = stack->pop()->GetInt(0); + byte Blue = stack->pop()->GetInt(0); + byte Alpha = stack->pop()->GetInt(0xFF); bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->WaitFor(_fader); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1780,8 +1780,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetFadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFadeColor") == 0) { - stack->CorrectParams(0); - stack->PushInt(_fader->getCurrentColor()); + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); return S_OK; } @@ -1789,10 +1789,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // Screenshot ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Screenshot") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); char filename[MAX_PATH]; - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int FileNum = 0; @@ -1811,7 +1811,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete Image; } else ret = false; - stack->PushBool(ret); + stack->pushBool(ret); return S_OK; } @@ -1819,10 +1819,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ScreenshotEx ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScreenshotEx") == 0) { - stack->CorrectParams(3); - const char *filename = stack->Pop()->GetString(); - int SizeX = stack->Pop()->GetInt(_renderer->_width); - int SizeY = stack->Pop()->GetInt(_renderer->_height); + stack->correctParams(3); + const char *filename = stack->pop()->GetString(); + int SizeX = stack->pop()->GetInt(_renderer->_width); + int SizeY = stack->pop()->GetInt(_renderer->_height); bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); @@ -1832,7 +1832,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete Image; } else ret = false; - stack->PushBool(ret); + stack->pushBool(ret); return S_OK; } @@ -1840,14 +1840,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // CreateWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIWindow *Win = new CUIWindow(Game); _windows.Add(Win); RegisterObject(Win); if (!Val->IsNULL()) Win->setName(Val->GetString()); - stack->PushNative(Win, true); + stack->pushNative(Win, true); return S_OK; } @@ -1855,16 +1855,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DeleteWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteWindow") == 0) { - stack->CorrectParams(1); - CBObject *Obj = (CBObject *)stack->Pop()->GetNative(); + stack->correctParams(1); + CBObject *Obj = (CBObject *)stack->pop()->GetNative(); for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i] == Obj) { UnregisterObject(_windows[i]); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } } - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -1872,8 +1872,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // OpenDocument ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OpenDocument") == 0) { - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); return S_OK; } @@ -1881,9 +1881,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DEBUG_DumpClassRegistry ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); DEBUG_DumpClassRegistry(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1891,10 +1891,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetLoadingScreen ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetLoadingScreen") == 0) { - stack->CorrectParams(3); - CScValue *Val = stack->Pop(); - _loadImageX = stack->Pop()->GetInt(); - _loadImageY = stack->Pop()->GetInt(); + stack->correctParams(3); + CScValue *Val = stack->pop(); + _loadImageX = stack->pop()->GetInt(); + _loadImageY = stack->pop()->GetInt(); if (Val->IsNULL()) { delete[] _loadImageName; @@ -1902,7 +1902,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } else { CBUtils::SetString(&_loadImageName, Val->GetString()); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1910,10 +1910,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetSavingScreen ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSavingScreen") == 0) { - stack->CorrectParams(3); - CScValue *Val = stack->Pop(); - _saveImageX = stack->Pop()->GetInt(); - _saveImageY = stack->Pop()->GetInt(); + stack->correctParams(3); + CScValue *Val = stack->pop(); + _saveImageX = stack->pop()->GetInt(); + _saveImageY = stack->pop()->GetInt(); if (Val->IsNULL()) { delete[] _saveImageName; @@ -1921,7 +1921,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } else { CBUtils::SetString(&_saveImageName, Val->GetString()); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1929,9 +1929,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // SetWaitCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { - stack->CorrectParams(1); - if (SUCCEEDED(SetWaitCursor(stack->Pop()->GetString()))) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(1); + if (SUCCEEDED(SetWaitCursor(stack->pop()->GetString()))) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -1940,11 +1940,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // RemoveWaitCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveWaitCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); delete _cursorNoninteractive; _cursorNoninteractive = NULL; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -1953,9 +1953,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetWaitCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursor") == 0) { - stack->CorrectParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->PushNULL(); - else stack->PushString(_cursorNoninteractive->_filename); + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->_filename); return S_OK; } @@ -1964,9 +1964,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetWaitCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursorObject") == 0) { - stack->CorrectParams(0); - if (!_cursorNoninteractive) stack->PushNULL(); - else stack->PushNative(_cursorNoninteractive, true); + stack->correctParams(0); + if (!_cursorNoninteractive) stack->pushNULL(); + else stack->pushNative(_cursorNoninteractive, true); return S_OK; } @@ -1975,8 +1975,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ClearScriptCache ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClearScriptCache") == 0) { - stack->CorrectParams(0); - stack->PushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); + stack->correctParams(0); + stack->pushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); return S_OK; } @@ -1984,12 +1984,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DisplayLoadingIcon ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisplayLoadingIcon") == 0) { - stack->CorrectParams(4); + stack->correctParams(4); - const char *filename = stack->Pop()->GetString(); - _loadingIconX = stack->Pop()->GetInt(); - _loadingIconY = stack->Pop()->GetInt(); - _loadingIconPersistent = stack->Pop()->GetBool(); + const char *filename = stack->pop()->GetString(); + _loadingIconX = stack->pop()->GetInt(); + _loadingIconY = stack->pop()->GetInt(); + _loadingIconPersistent = stack->pop()->GetBool(); delete _loadingIcon; _loadingIcon = new CBSprite(this); @@ -2001,7 +2001,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS Game->_renderer->flip(); Game->_renderer->initLoop(); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2010,10 +2010,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // HideLoadingIcon ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideLoadingIcon") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); delete _loadingIcon; _loadingIcon = NULL; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2021,12 +2021,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DumpTextureStats ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DumpTextureStats") == 0) { - stack->CorrectParams(1); - const char *filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *filename = stack->pop()->GetString(); _renderer->dumpData(filename); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2034,13 +2034,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // AccOutputText ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccOutputText") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); /* const char *Str = */ - stack->Pop()->GetString(); + stack->pop()->GetString(); /* int Type = */ - stack->Pop()->GetInt(); + stack->pop()->GetInt(); // do nothing - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2049,14 +2049,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // StoreSaveThumbnail ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StoreSaveThumbnail") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); delete _cachedThumbnail; _cachedThumbnail = new CBSaveThumbHelper(this); if (FAILED(_cachedThumbnail->StoreThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -2065,10 +2065,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DeleteSaveThumbnail ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteSaveThumbnail") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); delete _cachedThumbnail; _cachedThumbnail = NULL; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2077,9 +2077,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // GetFileChecksum ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFileChecksum") == 0) { - stack->CorrectParams(2); - const char *filename = stack->Pop()->GetString(); - bool AsHex = stack->Pop()->GetBool(false); + stack->correctParams(2); + const char *filename = stack->pop()->GetString(); + bool AsHex = stack->pop()->GetBool(false); Common::SeekableReadStream *File = _fileManager->openFile(filename, false); if (File) { @@ -2100,13 +2100,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (AsHex) { char Hex[100]; sprintf(Hex, "%x", checksum); - stack->PushString(Hex); + stack->pushString(Hex); } else - stack->PushInt(checksum); + stack->pushInt(checksum); _fileManager->closeFile(File); File = NULL; - } else stack->PushNULL(); + } else stack->pushNULL(); return S_OK; } @@ -2115,9 +2115,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // EnableScriptProfiling ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EnableScriptProfiling") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _scEngine->EnableProfiling(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2126,9 +2126,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // DisableScriptProfiling ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisableScriptProfiling") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _scEngine->DisableProfiling(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2137,11 +2137,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // ShowStatusLine ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); #ifdef __IPHONEOS__ IOS_ShowStatusLine(TRUE); #endif - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2150,11 +2150,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // HideStatusLine ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); #ifdef __IPHONEOS__ IOS_ShowStatusLine(FALSE); #endif - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -2931,240 +2931,240 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // LOG ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LOG") == 0) { - stack->CorrectParams(1); - Game->LOG(0, "sc: %s", stack->Pop()->GetString()); - stack->PushNULL(); + stack->correctParams(1); + Game->LOG(0, "sc: %s", stack->pop()->GetString()); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // String ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "String") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXString(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // MemBuffer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MemBuffer") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXMemBuffer(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // File ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "File") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXFile(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Date ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Date") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXDate(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Array ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Array") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXArray(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Object ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Object") == 0) { - this_obj = thisStack->GetTop(); + this_obj = thisStack->getTop(); this_obj->SetNative(makeSXObject(Game, stack)); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Sleep ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sleep") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - script->Sleep((uint32)stack->Pop()->GetInt()); - stack->PushNULL(); + script->Sleep((uint32)stack->pop()->GetInt()); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // WaitFor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WaitFor") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - CBScriptable *obj = stack->Pop()->GetNative(); + CBScriptable *obj = stack->pop()->GetNative(); if (ValidObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // Random ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Random") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - int from = stack->Pop()->GetInt(); - int to = stack->Pop()->GetInt(); + int from = stack->pop()->GetInt(); + int to = stack->pop()->GetInt(); - stack->PushInt(CBUtils::RandomInt(from, to)); + stack->pushInt(CBUtils::RandomInt(from, to)); } ////////////////////////////////////////////////////////////////////////// // SetScriptTimeSlice ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetScriptTimeSlice") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - script->_timeSlice = (uint32)stack->Pop()->GetInt(); - stack->PushNULL(); + script->_timeSlice = (uint32)stack->pop()->GetInt(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // MakeRGBA / MakeRGB / RGB ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { - stack->CorrectParams(4); - int r = stack->Pop()->GetInt(); - int g = stack->Pop()->GetInt(); - int b = stack->Pop()->GetInt(); + stack->correctParams(4); + int r = stack->pop()->GetInt(); + int g = stack->pop()->GetInt(); + int b = stack->pop()->GetInt(); int a; - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); if (val->IsNULL()) a = 255; else a = val->GetInt(); - stack->PushInt(DRGBA(r, g, b, a)); + stack->pushInt(DRGBA(r, g, b, a)); } ////////////////////////////////////////////////////////////////////////// // MakeHSL ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MakeHSL") == 0) { - stack->CorrectParams(3); - int h = stack->Pop()->GetInt(); - int s = stack->Pop()->GetInt(); - int l = stack->Pop()->GetInt(); + stack->correctParams(3); + int h = stack->pop()->GetInt(); + int s = stack->pop()->GetInt(); + int l = stack->pop()->GetInt(); - stack->PushInt(CBUtils::HSLtoRGB(h, s, l)); + stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); } ////////////////////////////////////////////////////////////////////////// // GetRValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRValue") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - uint32 rgba = (uint32)stack->Pop()->GetInt(); - stack->PushInt(D3DCOLGetR(rgba)); + uint32 rgba = (uint32)stack->pop()->GetInt(); + stack->pushInt(D3DCOLGetR(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetGValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGValue") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - uint32 rgba = (uint32)stack->Pop()->GetInt(); - stack->PushInt(D3DCOLGetG(rgba)); + uint32 rgba = (uint32)stack->pop()->GetInt(); + stack->pushInt(D3DCOLGetG(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetBValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetBValue") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - uint32 rgba = (uint32)stack->Pop()->GetInt(); - stack->PushInt(D3DCOLGetB(rgba)); + uint32 rgba = (uint32)stack->pop()->GetInt(); + stack->pushInt(D3DCOLGetB(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetAValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetAValue") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - uint32 rgba = (uint32)stack->Pop()->GetInt(); - stack->PushInt(D3DCOLGetA(rgba)); + uint32 rgba = (uint32)stack->pop()->GetInt(); + stack->pushInt(D3DCOLGetA(rgba)); } ////////////////////////////////////////////////////////////////////////// // GetHValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHValue") == 0) { - stack->CorrectParams(1); - uint32 rgb = (uint32)stack->Pop()->GetInt(); + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->PushInt(H); + stack->pushInt(H); } ////////////////////////////////////////////////////////////////////////// // GetSValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSValue") == 0) { - stack->CorrectParams(1); - uint32 rgb = (uint32)stack->Pop()->GetInt(); + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->PushInt(S); + stack->pushInt(S); } ////////////////////////////////////////////////////////////////////////// // GetLValue ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetLValue") == 0) { - stack->CorrectParams(1); - uint32 rgb = (uint32)stack->Pop()->GetInt(); + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->GetInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->PushInt(L); + stack->pushInt(L); } ////////////////////////////////////////////////////////////////////////// // Debug ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Debug") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (Game->GetDebugMgr()->_enabled) { Game->GetDebugMgr()->OnScriptHitBreakpoint(script); script->Sleep(0); } - stack->PushNULL(); + stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // ToString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToString") == 0) { - stack->CorrectParams(1); - const char *Str = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Str = stack->pop()->GetString(); char *Str2 = new char[strlen(Str) + 1]; strcpy(Str2, Str); - stack->PushString(Str2); + stack->pushString(Str2); delete [] Str2; } @@ -3172,35 +3172,35 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // ToInt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToInt") == 0) { - stack->CorrectParams(1); - int Val = stack->Pop()->GetInt(); - stack->PushInt(Val); + stack->correctParams(1); + int Val = stack->pop()->GetInt(); + stack->pushInt(Val); } ////////////////////////////////////////////////////////////////////////// // ToFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToFloat") == 0) { - stack->CorrectParams(1); - double Val = stack->Pop()->GetFloat(); - stack->PushFloat(Val); + stack->correctParams(1); + double Val = stack->pop()->GetFloat(); + stack->pushFloat(Val); } ////////////////////////////////////////////////////////////////////////// // ToBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToBool") == 0) { - stack->CorrectParams(1); - bool Val = stack->Pop()->GetBool(); - stack->PushBool(Val); + stack->correctParams(1); + bool Val = stack->pop()->GetBool(); + stack->pushBool(Val); } ////////////////////////////////////////////////////////////////////////// // failure else { script->RuntimeError("Call to undefined function '%s'. Ignored.", name); - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); } return S_OK; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index ce5f5cf8ce..a3f742fd69 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -78,8 +78,8 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta // IsKeyDown ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "IsKeyDown") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); int vKey; if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { @@ -94,7 +94,7 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta // SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); bool isDown = _keyStates[VKeyToKeyCode(vKey)]; - stack->PushBool(isDown); + stack->pushBool(isDown); return S_OK; } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index edab7aa0d2..c84b58eecd 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -171,11 +171,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SkipTo ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SkipTo") == 0) { - stack->CorrectParams(2); - _posX = stack->Pop()->GetInt(); - _posY = stack->Pop()->GetInt(); + stack->correctParams(2); + _posX = stack->pop()->GetInt(); + _posY = stack->pop()->GetInt(); afterMove(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -184,8 +184,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - stack->CorrectParams(1); - stack->PushString(getCaption(stack->Pop()->GetInt())); + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->GetInt())); return S_OK; } @@ -194,9 +194,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { - stack->CorrectParams(1); - if (SUCCEEDED(setCursor(stack->Pop()->GetString()))) stack->PushBool(true); - else stack->PushBool(false); + stack->correctParams(1); + if (SUCCEEDED(setCursor(stack->pop()->GetString()))) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -205,7 +205,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // RemoveCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -213,7 +213,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _cursor = NULL; } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -222,9 +222,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { - stack->CorrectParams(0); - if (!_cursor || !_cursor->_filename) stack->PushNULL(); - else stack->PushString(_cursor->_filename); + stack->correctParams(0); + if (!_cursor || !_cursor->_filename) stack->pushNULL(); + else stack->pushString(_cursor->_filename); return S_OK; } @@ -233,9 +233,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetCursorObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursorObject") == 0) { - stack->CorrectParams(0); - if (!_cursor) stack->PushNULL(); - else stack->PushNative(_cursor, true); + stack->correctParams(0); + if (!_cursor) stack->pushNULL(); + else stack->pushNative(_cursor, true); return S_OK; } @@ -244,10 +244,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // HasCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasCursor") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (_cursor) stack->PushBool(true); - else stack->PushBool(false); + if (_cursor) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -256,9 +256,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetCaption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCaption") == 0) { - stack->CorrectParams(2); - setCaption(stack->Pop()->GetString(), stack->Pop()->GetInt()); - stack->PushNULL(); + stack->correctParams(2); + setCaption(stack->pop()->GetString(), stack->pop()->GetInt()); + stack->pushNULL(); return S_OK; } @@ -267,12 +267,12 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // LoadSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadSound") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); if (SUCCEEDED(playSFX(Filename, false, false))) - stack->PushBool(true); + stack->pushBool(true); else - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -281,15 +281,15 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // PlaySound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlaySound") == 0) { - stack->CorrectParams(3); + stack->correctParams(3); const char *Filename; bool Looping; uint32 LoopStart; - CScValue *val1 = stack->Pop(); - CScValue *val2 = stack->Pop(); - CScValue *val3 = stack->Pop(); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); if (val1->_type == VAL_BOOL) { Filename = NULL; @@ -302,8 +302,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi LoopStart = val3->GetInt(); } - if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -311,13 +311,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // PlaySoundEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlaySoundEvent") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); const char *Filename; const char *EventName; - CScValue *val1 = stack->Pop(); - CScValue *val2 = stack->Pop(); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); if (val2->IsNULL()) { Filename = NULL; @@ -327,8 +327,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi EventName = val2->GetString(); } - if (FAILED(playSFX(Filename, false, true, EventName))) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(playSFX(Filename, false, true, EventName))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -336,10 +336,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // StopSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopSound") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (FAILED(stopSFX())) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(stopSFX())) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -347,10 +347,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // PauseSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseSound") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (FAILED(pauseSFX())) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(pauseSFX())) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -358,10 +358,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // ResumeSound ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeSound") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (FAILED(resumeSFX())) stack->PushBool(false); - else stack->PushBool(true); + if (FAILED(resumeSFX())) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -369,10 +369,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsSoundPlaying ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSoundPlaying") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (_sFX && _sFX->isPlaying()) stack->PushBool(true); - else stack->PushBool(false); + if (_sFX && _sFX->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -380,11 +380,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetSoundPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSoundPosition") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - uint32 Time = stack->Pop()->GetInt(); - if (FAILED(setSFXTime(Time))) stack->PushBool(false); - else stack->PushBool(true); + uint32 Time = stack->pop()->GetInt(); + if (FAILED(setSFXTime(Time))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -392,10 +392,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetSoundPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundPosition") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_sFX) stack->PushInt(0); - else stack->PushInt(_sFX->getPositionTime()); + if (!_sFX) stack->pushInt(0); + else stack->pushInt(_sFX->getPositionTime()); return S_OK; } @@ -403,11 +403,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetSoundVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSoundVolume") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - int Volume = stack->Pop()->GetInt(); - if (FAILED(setSFXVolume(Volume))) stack->PushBool(false); - else stack->PushBool(true); + int Volume = stack->pop()->GetInt(); + if (FAILED(setSFXVolume(Volume))) stack->pushBool(false); + else stack->pushBool(true); return S_OK; } @@ -415,10 +415,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetSoundVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundVolume") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_sFX) stack->PushInt(_sFXVolume); - else stack->PushInt(_sFX->getVolume()); + if (!_sFX) stack->pushInt(_sFXVolume); + else stack->pushInt(_sFX->getVolume()); return S_OK; } @@ -427,13 +427,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SoundFXNone ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXNone") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _sFXType = SFX_NONE; _sFXParam1 = 0; _sFXParam2 = 0; _sFXParam3 = 0; _sFXParam4 = 0; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -442,13 +442,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SoundFXEcho ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXEcho") == 0) { - stack->CorrectParams(4); + stack->correctParams(4); _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->Pop()->GetFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) - stack->PushNULL(); + _sFXParam1 = (float)stack->pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->GetFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); return S_OK; } @@ -457,13 +457,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SoundFXReverb ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundFXReverb") == 0) { - stack->CorrectParams(4); + stack->correctParams(4); _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - stack->PushNULL(); + _sFXParam1 = (float)stack->pop()->GetFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 0a3c9ce9f5..dd0f06334d 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -216,14 +216,14 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // AddPoint ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AddPoint") == 0) { - stack->CorrectParams(2); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(2); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); _points.Add(new CBPoint(X, Y)); CreateRegion(); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -232,17 +232,17 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // InsertPoint ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertPoint") == 0) { - stack->CorrectParams(3); - int Index = stack->Pop()->GetInt(); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(3); + int Index = stack->pop()->GetInt(); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { _points.InsertAt(Index, new CBPoint(X, Y)); CreateRegion(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -251,18 +251,18 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // SetPoint ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPoint") == 0) { - stack->CorrectParams(3); - int Index = stack->Pop()->GetInt(); - int X = stack->Pop()->GetInt(); - int Y = stack->Pop()->GetInt(); + stack->correctParams(3); + int Index = stack->pop()->GetInt(); + int X = stack->pop()->GetInt(); + int Y = stack->pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { _points[Index]->x = X; _points[Index]->y = Y; CreateRegion(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -271,8 +271,8 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // RemovePoint ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemovePoint") == 0) { - stack->CorrectParams(1); - int Index = stack->Pop()->GetInt(); + stack->correctParams(1); + int Index = stack->pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { delete _points[Index]; @@ -281,8 +281,8 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _points.RemoveAt(Index); CreateRegion(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -291,16 +291,16 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetPoint ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPoint") == 0) { - stack->CorrectParams(1); - int Index = stack->Pop()->GetInt(); + stack->correctParams(1); + int Index = stack->pop()->GetInt(); if (Index >= 0 && Index < _points.GetSize()) { - CScValue *Val = stack->GetPushValue(); + CScValue *Val = stack->getPushValue(); if (Val) { Val->SetProperty("X", _points[Index]->x); Val->SetProperty("Y", _points[Index]->y); } - } else stack->PushNULL(); + } else stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index e68716cbab..4557c8d2b3 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -114,10 +114,10 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "DEBUG_CrashMe") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); byte *p = 0; *p = 10; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -126,13 +126,13 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // ApplyEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ApplyEvent") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); HRESULT ret; ret = applyEvent(val->GetString()); - if (SUCCEEDED(ret)) stack->PushBool(true); - else stack->PushBool(false); + if (SUCCEEDED(ret)) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -141,8 +141,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // CanHandleEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleEvent") == 0) { - stack->CorrectParams(1); - stack->PushBool(canHandleEvent(stack->Pop()->GetString())); + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->GetString())); return S_OK; } @@ -151,8 +151,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // CanHandleMethod ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleMethod") == 0) { - stack->CorrectParams(1); - stack->PushBool(canHandleMethod(stack->Pop()->GetString())); + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->GetString())); return S_OK; } @@ -161,8 +161,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // AttachScript ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AttachScript") == 0) { - stack->CorrectParams(1); - stack->PushBool(SUCCEEDED(addScript(stack->Pop()->GetString()))); + stack->correctParams(1); + stack->pushBool(SUCCEEDED(addScript(stack->pop()->GetString()))); return S_OK; } @@ -171,9 +171,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // DetachScript ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DetachScript") == 0) { - stack->CorrectParams(2); - const char *Filename = stack->Pop()->GetString(); - bool KillThreads = stack->Pop()->GetBool(false); + stack->correctParams(2); + const char *Filename = stack->pop()->GetString(); + bool KillThreads = stack->pop()->GetBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { @@ -182,7 +182,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac break; } } - stack->PushBool(ret); + stack->pushBool(ret); return S_OK; } @@ -191,8 +191,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac // IsScriptRunning ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScriptRunning") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { @@ -200,7 +200,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac break; } } - stack->PushBool(ret); + stack->pushBool(ret); return S_OK; } else return CBScriptable::scCallMethod(script, stack, thisStack, name); diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 20f64f7fba..8d8c13df29 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -63,8 +63,8 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); script->RuntimeError("Call to undefined method '%s'.", name); return S_OK; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 257a71f255..901d592a02 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -512,12 +512,12 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetFrame ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetFrame") == 0) { - stack->CorrectParams(1); - int Index = stack->Pop()->GetInt(-1); + stack->correctParams(1); + int Index = stack->pop()->GetInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - stack->PushNULL(); - } else stack->PushNative(_frames[Index], true); + stack->pushNULL(); + } else stack->pushNative(_frames[Index], true); return S_OK; } @@ -525,8 +525,8 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // DeleteFrame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteFrame") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsInt()) { int Index = Val->GetInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { @@ -543,7 +543,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -551,9 +551,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Reset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); Reset(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -561,8 +561,8 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // AddFrame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddFrame") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -576,7 +576,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } _frames.Add(Frame); - stack->PushNative(Frame, true); + stack->pushNative(Frame, true); return S_OK; } @@ -584,11 +584,11 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // InsertFrame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertFrame") == 0) { - stack->CorrectParams(2); - int Index = stack->Pop()->GetInt(); + stack->correctParams(2); + int Index = stack->pop()->GetInt(); if (Index < 0) Index = 0; - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); const char *Filename = NULL; if (!Val->IsNULL()) Filename = Val->GetString(); @@ -602,7 +602,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Index >= _frames.GetSize()) _frames.Add(Frame); else _frames.InsertAt(Index, Frame); - stack->PushNative(Frame, true); + stack->pushNative(Frame, true); return S_OK; } @@ -610,9 +610,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Pause ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pause") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _paused = true; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -620,9 +620,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Play ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Play") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _paused = false; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 341dcbbdd5..0c7048b7bd 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -348,10 +348,10 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t // GetImage ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetImage") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (!_surfaceFilename) stack->PushNULL(); - else stack->PushString(_surfaceFilename); + if (!_surfaceFilename) stack->pushNULL(); + else stack->pushString(_surfaceFilename); return S_OK; } @@ -359,20 +359,20 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t // SetImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsNULL()) { if (_surface) Game->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { const char *Filename = Val->GetString(); if (SUCCEEDED(setSurface(Filename))) { setDefaultRect(); - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); } return S_OK; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 1c69f0ed3a..e9c597c429 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -421,13 +421,13 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetBorder ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetBorder") == 0) { - stack->CorrectParams(4); - int BorderX = stack->Pop()->GetInt(); - int BorderY = stack->Pop()->GetInt(); - int BorderWidth = stack->Pop()->GetInt(); - int BorderHeight = stack->Pop()->GetInt(); + stack->correctParams(4); + int BorderX = stack->pop()->GetInt(); + int BorderY = stack->pop()->GetInt(); + int BorderWidth = stack->pop()->GetInt(); + int BorderHeight = stack->pop()->GetInt(); - stack->PushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + stack->pushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); return S_OK; } @@ -435,13 +435,13 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetBorderThickness ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBorderThickness") == 0) { - stack->CorrectParams(4); - int Left = stack->Pop()->GetInt(); - int Right = stack->Pop()->GetInt(); - int Top = stack->Pop()->GetInt(); - int Bottom = stack->Pop()->GetInt(); + stack->correctParams(4); + int Left = stack->pop()->GetInt(); + int Right = stack->pop()->GetInt(); + int Top = stack->pop()->GetInt(); + int Bottom = stack->pop()->GetInt(); - stack->PushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); + stack->pushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); return S_OK; } @@ -449,9 +449,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // AddSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSprite") == 0) { - stack->CorrectParams(1); - const char *SpriteFile = stack->Pop()->GetString(); - stack->PushBool(SUCCEEDED(addSprite(SpriteFile))); + stack->correctParams(1); + const char *SpriteFile = stack->pop()->GetString(); + stack->pushBool(SUCCEEDED(addSprite(SpriteFile))); return S_OK; } @@ -459,9 +459,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // RemoveSprite ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSprite") == 0) { - stack->CorrectParams(1); - const char *SpriteFile = stack->Pop()->GetString(); - stack->PushBool(SUCCEEDED(removeSprite(SpriteFile))); + stack->correctParams(1); + const char *SpriteFile = stack->pop()->GetString(); + stack->pushBool(SUCCEEDED(removeSprite(SpriteFile))); return S_OK; } @@ -470,9 +470,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // Start ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Start") == 0) { - stack->CorrectParams(1); - _overheadTime = stack->Pop()->GetInt(); - stack->PushBool(SUCCEEDED(start())); + stack->correctParams(1); + _overheadTime = stack->pop()->GetInt(); + stack->pushBool(SUCCEEDED(start())); return S_OK; } @@ -481,7 +481,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // Stop ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Stop") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); for (int i = 0; i < _particles.GetSize(); i++) { delete _particles[i]; @@ -489,7 +489,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack _particles.RemoveAll(); _running = false; - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -498,9 +498,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // Pause ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pause") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _running = false; - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -509,9 +509,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // Resume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Resume") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _running = true; - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -520,12 +520,12 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // AddGlobalForce ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddGlobalForce") == 0) { - stack->CorrectParams(3); - const char *forceName = stack->Pop()->GetString(); - float Angle = stack->Pop()->GetFloat(); - float Strength = stack->Pop()->GetFloat(); + stack->correctParams(3); + const char *forceName = stack->pop()->GetString(); + float Angle = stack->pop()->GetFloat(); + float Strength = stack->pop()->GetFloat(); - stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); return S_OK; } @@ -534,14 +534,14 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // AddPointForce ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddPointForce") == 0) { - stack->CorrectParams(5); - const char *forceName = stack->Pop()->GetString(); - int PosX = stack->Pop()->GetInt(); - int PosY = stack->Pop()->GetInt(); - float Angle = stack->Pop()->GetFloat(); - float Strength = stack->Pop()->GetFloat(); + stack->correctParams(5); + const char *forceName = stack->pop()->GetString(); + int PosX = stack->pop()->GetInt(); + int PosY = stack->pop()->GetInt(); + float Angle = stack->pop()->GetFloat(); + float Strength = stack->pop()->GetFloat(); - stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); return S_OK; } @@ -550,10 +550,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack // RemoveForce ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveForce") == 0) { - stack->CorrectParams(1); - const char *forceName = stack->Pop()->GetString(); + stack->correctParams(1); + const char *forceName = stack->pop()->GetString(); - stack->PushBool(SUCCEEDED(removeForce(forceName))); + stack->pushBool(SUCCEEDED(removeForce(forceName))); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 1a8dfdba64..c22dd9e4b5 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -45,15 +45,15 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; _values = new CScValue(Game); - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); - if (NumParams == 1) _length = stack->Pop()->GetInt(0); + if (NumParams == 1) _length = stack->pop()->GetInt(0); else if (NumParams > 1) { _length = NumParams; char ParamName[20]; for (int i = 0; i < NumParams; i++) { sprintf(ParamName, "%d", i); - _values->SetProp(ParamName, stack->Pop()); + _values->SetProp(ParamName, stack->pop()); } } } @@ -98,15 +98,15 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Push ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Push") == 0) { - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); char ParamName[20]; for (int i = 0; i < NumParams; i++) { _length++; sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, stack->Pop(), true); + _values->SetProp(ParamName, stack->pop(), true); } - stack->PushInt(_length); + stack->pushInt(_length); return S_OK; } @@ -116,15 +116,15 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Pop") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_length > 0) { char ParamName[20]; sprintf(ParamName, "%d", _length - 1); - stack->Push(_values->GetProp(ParamName)); + stack->push(_values->GetProp(ParamName)); _values->DeleteProp(ParamName); _length--; - } else stack->PushNULL(); + } else stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 5026ebdd8e..61a646df43 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -40,17 +40,17 @@ CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(6); + stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); - CScValue *valYear = stack->Pop(); + CScValue *valYear = stack->pop(); _tm.tm_year = valYear->GetInt() - 1900; - _tm.tm_mon = stack->Pop()->GetInt() - 1; - _tm.tm_mday = stack->Pop()->GetInt(); - _tm.tm_hour = stack->Pop()->GetInt(); - _tm.tm_min = stack->Pop()->GetInt(); - _tm.tm_sec = stack->Pop()->GetInt(); + _tm.tm_mon = stack->pop()->GetInt() - 1; + _tm.tm_mday = stack->pop()->GetInt(); + _tm.tm_hour = stack->pop()->GetInt(); + _tm.tm_min = stack->pop()->GetInt(); + _tm.tm_sec = stack->pop()->GetInt(); if (valYear->IsNULL()) { g_system->getTimeAndDate(_tm); @@ -80,57 +80,57 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetYear ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetYear") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_year + 1900); + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMonth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMonth") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_mon + 1); + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetDate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDate") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_mday); + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetHours ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHours") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_hour); + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMinutes ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMinutes") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_min); + stack->correctParams(0); + stack->pushInt(_tm.tm_min); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSeconds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSeconds") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_sec); + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetWeekday ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWeekday") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); warning("GetWeekday returns a wrong value on purpose"); - stack->PushInt(_tm.tm_mday % 7); + stack->pushInt(_tm.tm_mday % 7); return S_OK; } @@ -139,54 +139,54 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetYear ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetYear") == 0) { - stack->CorrectParams(1); - _tm.tm_year = stack->Pop()->GetInt() - 1900; - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_year = stack->pop()->GetInt() - 1900; + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMonth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMonth") == 0) { - stack->CorrectParams(1); - _tm.tm_mon = stack->Pop()->GetInt() - 1; - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_mon = stack->pop()->GetInt() - 1; + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetDate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDate") == 0) { - stack->CorrectParams(1); - _tm.tm_mday = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_mday = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetHours ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHours") == 0) { - stack->CorrectParams(1); - _tm.tm_hour = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_hour = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMinutes ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMinutes") == 0) { - stack->CorrectParams(1); - _tm.tm_min = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_min = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSeconds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSeconds") == 0) { - stack->CorrectParams(1); - _tm.tm_sec = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_sec = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } @@ -195,9 +195,9 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetCurrentTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCurrentTime") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); g_system->getTimeAndDate(_tm); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index b897ca9701..fc2fca1991 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -56,8 +56,8 @@ CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); _filename = NULL; if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); @@ -110,11 +110,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetFilename ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFilename") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); cleanup(); CBUtils::SetString(&_filename, Filename); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -122,9 +122,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // OpenAsText / OpenAsBinary ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); Close(); - _mode = stack->Pop()->GetInt(1); + _mode = stack->pop()->GetInt(1); if (_mode < 1 || _mode > 3) { script->RuntimeError("File.%s: invalid access mode. Setting read mode.", name); _mode = 1; @@ -150,8 +150,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } else _textMode = strcmp(name, "OpenAsText") == 0; } - if (_readFile || _writeFile) stack->PushBool(true); - else stack->PushBool(false); + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -160,9 +160,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Close ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Close") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); Close(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -170,13 +170,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPosition") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (_mode == 0) { script->RuntimeError("File.%s: File is not open", name); - stack->PushBool(false); + stack->pushBool(false); } else { - int Pos = stack->Pop()->GetInt(); - stack->PushBool(SetPos(Pos)); + int Pos = stack->pop()->GetInt(); + stack->pushBool(SetPos(Pos)); } return S_OK; } @@ -185,9 +185,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Delete ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Delete") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); Close(); - stack->PushBool(CBPlatform::DeleteFile(_filename) != false); + stack->pushBool(CBPlatform::DeleteFile(_filename) != false); return S_OK; } @@ -195,12 +195,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Copy ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { - stack->CorrectParams(2); - const char *Dest = stack->Pop()->GetString(); - bool Overwrite = stack->Pop()->GetBool(true); + stack->correctParams(2); + const char *Dest = stack->pop()->GetString(); + bool Overwrite = stack->pop()->GetBool(true); Close(); - stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); return S_OK; } @@ -208,10 +208,10 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadLine ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadLine") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (!_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open in text mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -245,8 +245,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } Buf[Counter] = '\0'; - if (!FoundNewLine && Counter == 0) stack->PushNULL(); - else stack->PushString((char *)Buf); + if (!FoundNewLine && Counter == 0) stack->pushNULL(); + else stack->pushString((char *)Buf); free(Buf); @@ -257,12 +257,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadText ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadText") == 0) { - stack->CorrectParams(1); - int TextLen = stack->Pop()->GetInt(); + stack->correctParams(1); + int TextLen = stack->pop()->GetInt(); if (!_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open in text mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -292,8 +292,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } Buf[Counter] = '\0'; - if (TextLen > 0 && Counter == 0) stack->PushNULL(); - else stack->PushString((char *)Buf); + if (TextLen > 0 && Counter == 0) stack->pushNULL(); + else stack->pushString((char *)Buf); free(Buf); @@ -304,11 +304,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteLine / WriteText ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->CorrectParams(1); - const char *Line = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Line = stack->pop()->GetString(); if (!_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in text mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } if (strcmp(name, "WriteLine") == 0) @@ -316,7 +316,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else fprintf((FILE *)_writeFile, "%s", Line); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -326,15 +326,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadBool") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } bool Val; - if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->PushBool(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->pushBool(Val); + else stack->pushNULL(); return S_OK; } @@ -343,15 +343,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadByte") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } byte Val; - if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->PushInt(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->pushInt(Val); + else stack->pushNULL(); return S_OK; } @@ -360,15 +360,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadShort") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } short Val; - if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->PushInt(65536 + Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + Val); + else stack->pushNULL(); return S_OK; } @@ -377,15 +377,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadInt / ReadLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } int Val; - if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->PushInt(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->pushInt(Val); + else stack->pushNULL(); return S_OK; } @@ -394,15 +394,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadFloat") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } float Val; - if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->PushFloat(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->pushFloat(Val); + else stack->pushNULL(); return S_OK; } @@ -411,15 +411,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadDouble") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } double Val; - if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->PushFloat(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->pushFloat(Val); + else stack->pushNULL(); return S_OK; } @@ -428,10 +428,10 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadString") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 Size; @@ -440,11 +440,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (Str) { if (_readFile->read(Str, Size) == Size) { Str[Size] = '\0'; - stack->PushString((char *)Str); + stack->pushString((char *)Str); } delete [] Str; - } else stack->PushNULL(); - } else stack->PushNULL(); + } else stack->pushNULL(); + } else stack->pushNULL(); return S_OK; } @@ -453,16 +453,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteBool") == 0) { - stack->CorrectParams(1); - bool Val = stack->Pop()->GetBool(); + stack->correctParams(1); + bool Val = stack->pop()->GetBool(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -471,16 +471,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteByte") == 0) { - stack->CorrectParams(1); - byte Val = stack->Pop()->GetInt(); + stack->correctParams(1); + byte Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -489,16 +489,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteShort") == 0) { - stack->CorrectParams(1); - short Val = stack->Pop()->GetInt(); + stack->correctParams(1); + short Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -507,16 +507,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteInt / WriteLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->CorrectParams(1); - int Val = stack->Pop()->GetInt(); + stack->correctParams(1); + int Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -525,16 +525,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteFloat") == 0) { - stack->CorrectParams(1); - float Val = stack->Pop()->GetFloat(); + stack->correctParams(1); + float Val = stack->pop()->GetFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -543,16 +543,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteDouble") == 0) { - stack->CorrectParams(1); - double Val = stack->Pop()->GetFloat(); + stack->correctParams(1); + double Val = stack->pop()->GetFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -561,12 +561,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteString") == 0) { - stack->CorrectParams(1); - const char *Val = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Val = stack->pop()->GetString(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -574,7 +574,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile); fwrite(Val, Size, 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index a9337af1a8..110330d4ef 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -63,8 +63,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Abs ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Abs") == 0) { - stack->CorrectParams(1); - stack->PushFloat(fabs(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->GetFloat())); return S_OK; } @@ -72,8 +72,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Acos ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Acos") == 0) { - stack->CorrectParams(1); - stack->PushFloat(acos(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->GetFloat())); return S_OK; } @@ -81,8 +81,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Asin ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Asin") == 0) { - stack->CorrectParams(1); - stack->PushFloat(asin(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->GetFloat())); return S_OK; } @@ -90,8 +90,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Atan ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan") == 0) { - stack->CorrectParams(1); - stack->PushFloat(atan(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->GetFloat())); return S_OK; } @@ -99,10 +99,10 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Atan2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan2") == 0) { - stack->CorrectParams(2); - double y = stack->Pop()->GetFloat(); - double x = stack->Pop()->GetFloat(); - stack->PushFloat(atan2(y, x)); + stack->correctParams(2); + double y = stack->pop()->GetFloat(); + double x = stack->pop()->GetFloat(); + stack->pushFloat(atan2(y, x)); return S_OK; } @@ -110,8 +110,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Ceil ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Ceil") == 0) { - stack->CorrectParams(1); - stack->PushFloat(ceil(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->GetFloat())); return S_OK; } @@ -119,8 +119,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Cos ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cos") == 0) { - stack->CorrectParams(1); - stack->PushFloat(cos(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(cos(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -128,8 +128,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Cosh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cosh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(cosh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(cosh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -137,8 +137,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Exp ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exp") == 0) { - stack->CorrectParams(1); - stack->PushFloat(exp(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->GetFloat())); return S_OK; } @@ -146,8 +146,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Floor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Floor") == 0) { - stack->CorrectParams(1); - stack->PushFloat(floor(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->GetFloat())); return S_OK; } @@ -155,8 +155,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Log ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log") == 0) { - stack->CorrectParams(1); - stack->PushFloat(log(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->GetFloat())); return S_OK; } @@ -164,8 +164,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Log10 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log10") == 0) { - stack->CorrectParams(1); - stack->PushFloat(log10(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->GetFloat())); return S_OK; } @@ -173,11 +173,11 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Pow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pow") == 0) { - stack->CorrectParams(2); - double x = stack->Pop()->GetFloat(); - double y = stack->Pop()->GetFloat(); + stack->correctParams(2); + double x = stack->pop()->GetFloat(); + double y = stack->pop()->GetFloat(); - stack->PushFloat(pow(x, y)); + stack->pushFloat(pow(x, y)); return S_OK; } @@ -185,8 +185,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sin ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sin") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sin(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(sin(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -194,8 +194,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sinh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sinh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sinh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(sinh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -203,8 +203,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Tan ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tan") == 0) { - stack->CorrectParams(1); - stack->PushFloat(tan(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(tan(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -212,8 +212,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Tanh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tanh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(tanh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(tanh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -221,8 +221,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sqrt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sqrt") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sqrt(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->GetFloat())); return S_OK; } @@ -230,8 +230,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // DegToRad ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DegToRad") == 0) { - stack->CorrectParams(1); - stack->PushFloat(DegreeToRadian(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(DegreeToRadian(stack->pop()->GetFloat())); return S_OK; } @@ -239,8 +239,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // RadToDeg ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RadToDeg") == 0) { - stack->CorrectParams(1); - stack->PushFloat(RadianToDegree(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(RadianToDegree(stack->pop()->GetFloat())); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 82a9a1f5e2..7dcb6ea1a7 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -43,11 +43,11 @@ CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(1); + stack->correctParams(1); _buffer = NULL; _size = 0; - int NewSize = stack->Pop()->GetInt(); + int NewSize = stack->pop()->GetInt(); Resize(MAX(0, NewSize)); } @@ -127,11 +127,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetSize ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSize") == 0) { - stack->CorrectParams(1); - int NewSize = stack->Pop()->GetInt(); + stack->correctParams(1); + int NewSize = stack->pop()->GetInt(); NewSize = MAX(0, NewSize); - if (SUCCEEDED(Resize(NewSize))) stack->PushBool(true); - else stack->PushBool(false); + if (SUCCEEDED(Resize(NewSize))) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -140,10 +140,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetBool") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->PushNULL(); - else stack->PushBool(*(bool *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(bool))) stack->pushNULL(); + else stack->pushBool(*(bool *)((byte *)_buffer + Start)); return S_OK; } @@ -152,10 +152,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetByte") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->PushNULL(); - else stack->PushInt(*(byte *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(byte))) stack->pushNULL(); + else stack->pushInt(*(byte *)((byte *)_buffer + Start)); return S_OK; } @@ -164,10 +164,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetShort") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->PushNULL(); - else stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(short))) stack->pushNULL(); + else stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -176,10 +176,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetInt / GetLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->PushNULL(); - else stack->PushInt(*(int *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(int))) stack->pushNULL(); + else stack->pushInt(*(int *)((byte *)_buffer + Start)); return S_OK; } @@ -188,10 +188,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFloat") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(float))) stack->PushNULL(); - else stack->PushFloat(*(float *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(float))) stack->pushNULL(); + else stack->pushFloat(*(float *)((byte *)_buffer + Start)); return S_OK; } @@ -200,10 +200,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDouble") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(double))) stack->PushNULL(); - else stack->PushFloat(*(double *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(double))) stack->pushNULL(); + else stack->pushFloat(*(double *)((byte *)_buffer + Start)); return S_OK; } @@ -212,9 +212,9 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetString") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - int Length = stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + int Length = stack->pop()->GetInt(); // find end of string if (Length == 0 && Start >= 0 && Start < _size) { @@ -226,12 +226,12 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack } } - if (!CheckBounds(script, Start, Length)) stack->PushNULL(); + if (!CheckBounds(script, Start, Length)) stack->pushNULL(); else { char *Str = new char[Length + 1]; strncpy(Str, (const char *)_buffer + Start, Length); Str[Length] = '\0'; - stack->PushString(Str); + stack->pushString(Str); delete [] Str; } return S_OK; @@ -241,13 +241,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetPointer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPointer") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->PushNULL(); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(void *))) stack->pushNULL(); else { void *Pointer = *(void **)((byte *)_buffer + Start); CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); - stack->PushNative(Buf, false); + stack->pushNative(Buf, false); } return S_OK; } @@ -256,14 +256,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBool") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - bool Val = stack->Pop()->GetBool(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + bool Val = stack->pop()->GetBool(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(bool))) stack->pushBool(false); else { *(bool *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -272,14 +272,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetByte") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - byte Val = (byte)stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + byte Val = (byte)stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(byte))) stack->pushBool(false); else { *(byte *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -288,14 +288,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetShort") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - short Val = (short)stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + short Val = (short)stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(short))) stack->pushBool(false); else { *(short *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -304,14 +304,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetInt / SetLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - int Val = stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + int Val = stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(int))) stack->pushBool(false); else { *(int *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -320,14 +320,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFloat") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - float Val = (float)stack->Pop()->GetFloat(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + float Val = (float)stack->pop()->GetFloat(); - if (!CheckBounds(script, Start, sizeof(float))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(float))) stack->pushBool(false); else { *(float *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -336,14 +336,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDouble") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - double Val = stack->Pop()->GetFloat(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + double Val = stack->pop()->GetFloat(); - if (!CheckBounds(script, Start, sizeof(double))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(double))) stack->pushBool(false); else { *(double *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -352,14 +352,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetString") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - const char *Val = stack->Pop()->GetString(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + const char *Val = stack->pop()->GetString(); - if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->PushBool(false); + if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->pushBool(false); else { memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -368,19 +368,19 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetPointer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPointer") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - /* CScValue *Val = */ stack->Pop(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + /* CScValue *Val = */ stack->pop(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(void *))) stack->pushBool(false); else { /* int Pointer = (int)Val->GetMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->PushBool(true); + stack->pushBool(true); */ // TODO fix - stack->PushBool(false); + stack->pushBool(false); } return S_OK; @@ -390,7 +390,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // DEBUG_Dump ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_buffer && _size) { warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); Common::DumpFile f; @@ -398,7 +398,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack f.write(_buffer, _size); f.close(); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index bfdbd212c7..a1d41c2db6 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -89,39 +89,39 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // EnableEvents ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "EnableEvents") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); SetEventsEnabled(script, true); - stack->PushBool(GetEventsEnabled() == true); + stack->pushBool(GetEventsEnabled() == true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DisableEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisableEvents") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); SetEventsEnabled(script, false); - stack->PushBool(GetEventsEnabled() == false); + stack->pushBool(GetEventsEnabled() == false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ValidateProducts ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidateProducts") == 0) { - stack->CorrectParams(1); - const char *prodIdList = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodIdList = stack->pop()->GetString(); _lastProductRequestOwner = script->_owner; ValidateProducts(prodIdList); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetValidProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetValidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _validProducts.GetSize()) { - CScValue *prod = stack->GetPushValue(); + CScValue *prod = stack->getPushValue(); if (prod) { prod->SetProperty("Id", _validProducts[index]->GetId()); prod->SetProperty("Name", _validProducts[index]->GetName()); @@ -129,7 +129,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi prod->SetProperty("Price", _validProducts[index]->GetPrice()); } } else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -137,12 +137,12 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetInvalidProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInvalidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _invalidProducts.size()) - stack->PushString(_invalidProducts[index].c_str()); + stack->pushString(_invalidProducts[index].c_str()); else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -150,17 +150,17 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetTransaction ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetTransaction") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _transactions.GetSize()) { - CScValue *trans = stack->GetPushValue(); + CScValue *trans = stack->getPushValue(); if (trans) { trans->SetProperty("Id", _transactions[index]->GetId()); trans->SetProperty("ProductId", _transactions[index]->GetProductId()); trans->SetProperty("State", _transactions[index]->GetState()); } } else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -168,9 +168,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Purchase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Purchase") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); - stack->PushBool(Purchase(script, prodId)); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); + stack->pushBool(Purchase(script, prodId)); return S_OK; } @@ -178,9 +178,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // FinishTransaction ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FinishTransaction") == 0) { - stack->CorrectParams(1); - const char *transId = stack->Pop()->GetString(); - stack->PushBool(FinishTransaction(script, transId)); + stack->correctParams(1); + const char *transId = stack->pop()->GetString(); + stack->pushBool(FinishTransaction(script, transId)); return S_OK; } @@ -188,9 +188,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // RestoreTransactions ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RestoreTransactions") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); RestoreTransactions(script); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -199,13 +199,13 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // UnlockProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnlockProduct") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); Game->_registry->WriteBool("Purchases", prodId, true); Game->_registry->SaveValues(); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -214,10 +214,10 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsProductUnlocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsProductUnlocked") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); - stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); + stack->pushBool(Game->_registry->ReadBool("Purchases", prodId, false)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 4a912df5fe..36dc257229 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -48,8 +48,8 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _string = NULL; _capacity = 0; - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsInt()) { _capacity = MAX(0, Val->GetInt()); @@ -104,9 +104,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Substring ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Substring") == 0) { - stack->CorrectParams(2); - int start = stack->Pop()->GetInt(); - int end = stack->Pop()->GetInt(); + stack->correctParams(2); + int start = stack->pop()->GetInt(); + int end = stack->pop()->GetInt(); if (end < start) CBUtils::Swap(&start, &end); @@ -121,11 +121,11 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString subStr(str.c_str() + start, end - start + 1); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); else - stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { - // stack->PushNULL(); + // stack->pushNULL(); // } return S_OK; @@ -135,14 +135,14 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Substr ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Substr") == 0) { - stack->CorrectParams(2); - int start = stack->Pop()->GetInt(); + stack->correctParams(2); + int start = stack->pop()->GetInt(); - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); int len = val->GetInt(); if (!val->IsNULL() && len <= 0) { - stack->PushString(""); + stack->pushString(""); return S_OK; } @@ -159,11 +159,11 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString subStr(str.c_str() + start, len); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); else - stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { -// stack->PushNULL(); +// stack->pushNULL(); // } return S_OK; @@ -173,7 +173,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ToUpperCase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToUpperCase") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -184,9 +184,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th StringUtil::ToUpperCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::WideToUtf8(str).c_str()); else - stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ToLowerCase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToLowerCase") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -206,9 +206,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th StringUtil::ToLowerCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::WideToUtf8(str).c_str()); else - stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -217,10 +217,10 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // IndexOf ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IndexOf") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - const char *strToFind = stack->Pop()->GetString(); - int index = stack->Pop()->GetInt(); + const char *strToFind = stack->pop()->GetString(); + int index = stack->pop()->GetInt(); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -235,7 +235,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th toFind = StringUtil::AnsiToWide(strToFind); int indexOf = StringUtil::IndexOf(str, toFind, index); - stack->PushInt(indexOf); + stack->pushInt(indexOf); return S_OK; } @@ -244,14 +244,14 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Split ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Split") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); char Separators[MAX_PATH] = ","; if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); CSXArray *Array = new CSXArray(Game); if (!Array) { - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -308,7 +308,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th Val = NULL; } - stack->PushNative(Array, false); + stack->pushNative(Array, false); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 9c443df509..e840d0cd78 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -407,13 +407,13 @@ HRESULT CScEngine::Tick() { case SCRIPT_WAITING_SCRIPT: { if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { // fake return value - _scripts[i]->_stack->PushNULL(); + _scripts[i]->_stack->pushNULL(); _scripts[i]->_waitScript = NULL; _scripts[i]->Run(); } else { if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { // copy return value - _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); _scripts[i]->Run(); _scripts[i]->_waitScript->finish(); _scripts[i]->_waitScript = NULL; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 6e43ac6e0d..61e1e91282 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -493,9 +493,9 @@ HRESULT CScScript::ExecuteInstruction() { if (Game->GetDebugMgr()->_enabled) Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); } else { - _scopeStack->GetTop()->SetProp(_symbols[dw], _operand); + _scopeStack->getTop()->SetProp(_symbols[dw], _operand); if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->GetTop(), _scopeStack->GetTop()->GetProp(_symbols[dw]), _symbols[dw]); + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->GetProp(_symbols[dw]), _symbols[dw]); } break; @@ -517,13 +517,13 @@ HRESULT CScScript::ExecuteInstruction() { case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->GetTop()); + Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); - _scopeStack->Pop(); - _iP = (uint32)_callStack->Pop()->GetInt(); + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->GetInt(); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -544,7 +544,7 @@ HRESULT CScScript::ExecuteInstruction() { dw = GetDWORD(); _operand->SetInt(_iP); - _callStack->Push(_operand); + _callStack->push(_operand); _iP = dw; @@ -553,11 +553,11 @@ HRESULT CScScript::ExecuteInstruction() { case II_CALL_BY_EXP: { // push var // push string - str = _stack->Pop()->GetString(); + str = _stack->pop()->GetString(); char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); - CScValue *var = _stack->Pop(); + CScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; HRESULT res = E_FAIL; @@ -574,18 +574,18 @@ HRESULT CScScript::ExecuteInstruction() { if (!_unbreakable) { _waitScript = var->GetNative()->invokeMethodThread(MethodName); if (!_waitScript) { - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Error invoking method '%s'.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } else { _state = SCRIPT_WAITING_SCRIPT; _waitScript->CopyParameters(_stack); } } else { // can call methods in unbreakable mode - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } delete [] MethodName; break; @@ -616,9 +616,9 @@ HRESULT CScScript::ExecuteInstruction() { if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); if (FAILED(res)) { - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } } } @@ -638,40 +638,40 @@ HRESULT CScScript::ExecuteInstruction() { } case II_SCOPE: _operand->SetNULL(); - _scopeStack->Push(_operand); + _scopeStack->push(_operand); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); break; case II_CORRECT_STACK: dw = GetDWORD(); // params expected - _stack->CorrectParams(dw); + _stack->correctParams(dw); break; case II_CREATE_OBJECT: _operand->SetObject(); - _stack->Push(_operand); + _stack->push(_operand); break; case II_POP_EMPTY: - _stack->Pop(); + _stack->pop(); break; case II_PUSH_VAR: { CScValue *var = GetVar(_symbols[GetDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->SetReference(var); - _stack->Push(_operand); - } else _stack->Push(var); + _stack->push(_operand); + } else _stack->push(var); break; } case II_PUSH_VAR_REF: { CScValue *var = GetVar(_symbols[GetDWORD()]); _operand->SetReference(var); - _stack->Push(_operand); + _stack->push(_operand); break; } @@ -679,7 +679,7 @@ HRESULT CScScript::ExecuteInstruction() { char *VarName = _symbols[GetDWORD()]; CScValue *var = GetVar(VarName); if (var) { - CScValue *val = _stack->Pop(); + CScValue *val = _stack->pop(); if (!val) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->SetNULL(); @@ -699,58 +699,58 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_VAR_THIS: - _stack->Push(_thisStack->GetTop()); + _stack->push(_thisStack->getTop()); break; case II_PUSH_INT: - _stack->PushInt((int)GetDWORD()); + _stack->pushInt((int)GetDWORD()); break; case II_PUSH_FLOAT: - _stack->PushFloat(GetFloat()); + _stack->pushFloat(GetFloat()); break; case II_PUSH_BOOL: - _stack->PushBool(GetDWORD() != 0); + _stack->pushBool(GetDWORD() != 0); break; case II_PUSH_STRING: - _stack->PushString(GetString()); + _stack->pushString(GetString()); break; case II_PUSH_NULL: - _stack->PushNULL(); + _stack->pushNULL(); break; case II_PUSH_THIS_FROM_STACK: - _operand->SetReference(_stack->GetTop()); - _thisStack->Push(_operand); + _operand->SetReference(_stack->getTop()); + _thisStack->push(_operand); break; case II_PUSH_THIS: _operand->SetReference(GetVar(_symbols[GetDWORD()])); - _thisStack->Push(_operand); + _thisStack->push(_operand); break; case II_POP_THIS: - _thisStack->Pop(); + _thisStack->pop(); break; case II_PUSH_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *val = _stack->Pop()->GetProp(str); - if (val) _stack->Push(val); - else _stack->PushNULL(); + str = _stack->pop()->GetString(); + CScValue *val = _stack->pop()->GetProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); break; } case II_POP_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *var = _stack->Pop(); - CScValue *val = _stack->Pop(); + str = _stack->pop()->GetString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); if (val == NULL) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); @@ -764,11 +764,11 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_REG1: - _stack->Push(_reg1); + _stack->push(_reg1); break; case II_POP_REG1: - _reg1->Copy(_stack->Pop()); + _reg1->Copy(_stack->pop()); break; case II_JMP: @@ -777,8 +777,8 @@ HRESULT CScScript::ExecuteInstruction() { case II_JMP_FALSE: { dw = GetDWORD(); - //if(!_stack->Pop()->GetBool()) _iP = dw; - CScValue *Val = _stack->Pop(); + //if(!_stack->pop()->GetBool()) _iP = dw; + CScValue *Val = _stack->pop(); if (!Val) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { @@ -788,8 +788,8 @@ HRESULT CScScript::ExecuteInstruction() { } case II_ADD: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { @@ -802,98 +802,98 @@ HRESULT CScScript::ExecuteInstruction() { _operand->SetInt(op1->GetInt() + op2->GetInt()); else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_SUB: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() - op2->GetInt()); else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_MUL: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() * op2->GetInt()); else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_DIV: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_MODULO: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op2->GetInt() == 0) RuntimeError("Division by zero."); if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); else _operand->SetInt(op1->GetInt() % op2->GetInt()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_NOT: - op1 = _stack->Pop(); + op1 = _stack->pop(); //if(op1->IsNULL()) _operand->SetNULL(); if (op1->IsNULL()) _operand->SetBool(true); else _operand->SetBool(!op1->GetBool()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_AND: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->SetBool(false); } else { _operand->SetBool(op1->GetBool() && op2->GetBool()); } - _stack->Push(_operand); + _stack->push(_operand); break; case II_OR: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->SetBool(false); } else { _operand->SetBool(op1->GetBool() || op2->GetBool()); } - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); @@ -912,12 +912,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) == 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); @@ -936,12 +936,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) != 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_L: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -951,12 +951,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) < 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_G: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -966,12 +966,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) > 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_LE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -981,12 +981,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) <= 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_GE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -996,26 +996,26 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) >= 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_STRICT_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_STRICT_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_DBG_LINE: { @@ -1077,7 +1077,7 @@ CScValue *CScScript::GetVar(char *name) { // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->GetTop()->PropExists(name)) ret = _scopeStack->GetTop()->GetProp(name); + if (_scopeStack->getTop()->PropExists(name)) ret = _scopeStack->getTop()->GetProp(name); } // script globals @@ -1094,10 +1094,10 @@ CScValue *CScScript::GetVar(char *name) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); CScValue *Val = new CScValue(Game); - CScValue *Scope = _scopeStack->GetTop(); + CScValue *Scope = _scopeStack->getTop(); if (Scope) { Scope->SetProp(name, Val); - ret = _scopeStack->GetTop()->GetProp(name); + ret = _scopeStack->getTop()->GetProp(name); } else { _globals->SetProp(name, Val); ret = _globals->GetProp(name); @@ -1331,8 +1331,8 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: #ifndef __WIN32__ Game->LOG(0, "External functions are not supported on this platform."); - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); return E_FAIL; #else @@ -1345,11 +1345,11 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: if (pFunc) { int i; Success = true; - stack->CorrectParams(Function->nu_params); + stack->correctParams(Function->nu_params); CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); for (i = 0; i < Function->nu_params; i++) { - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); switch (Function->params[i]) { case TYPE_BOOL: Buffer->PutDWORD((uint32)Val->GetBool()); @@ -1399,34 +1399,34 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: // return switch (Function->returns) { case TYPE_BOOL: - stack->PushBool((byte)ret != 0); + stack->pushBool((byte)ret != 0); break; case TYPE_LONG: - stack->PushInt(ret); + stack->pushInt(ret); break; case TYPE_BYTE: - stack->PushInt((byte)ret); + stack->pushInt((byte)ret); break; break; case TYPE_STRING: - stack->PushString((char *)ret); + stack->pushString((char *)ret); break; case TYPE_MEMBUFFER: { CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); - stack->PushNative(Buf, false); + stack->pushNative(Buf, false); } break; case TYPE_FLOAT: { uint32 dw = GetST0(); - stack->PushFloat(*((float *)&dw)); + stack->pushFloat(*((float *)&dw)); break; } case TYPE_DOUBLE: - stack->PushFloat(GetST0Double()); + stack->pushFloat(GetST0Double()); break; default: - stack->PushNULL(); + stack->pushNULL(); } if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); @@ -1434,8 +1434,8 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: } else RuntimeError("Error loading DLL '%s'", Function->dll_name); if (!Success) { - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); } if (hDll) FreeLibrary(hDll); @@ -1527,13 +1527,13 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::CopyParameters(CScStack *stack) { int i; - int NumParams = stack->Pop()->GetInt(); + int NumParams = stack->pop()->GetInt(); for (i = NumParams - 1; i >= 0; i--) { - _stack->Push(stack->GetAt(i)); + _stack->push(stack->getAt(i)); } - _stack->PushInt(NumParams); + _stack->pushInt(NumParams); - for (i = 0; i < NumParams; i++) stack->Pop(); + for (i = 0; i < NumParams; i++) stack->pop(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index f10aa7085b..dc953ed8d0 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -55,7 +55,7 @@ CScStack::~CScStack() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::Pop() { +CScValue *CScStack::pop() { if (_sP < 0) { Game->LOG(0, "Fatal: Stack underflow"); return NULL; @@ -66,7 +66,7 @@ CScValue *CScStack::Pop() { ////////////////////////////////////////////////////////////////////////// -void CScStack::Push(CScValue *val) { +void CScStack::push(CScValue *val) { _sP++; if (_sP < _values.GetSize()) { @@ -81,7 +81,7 @@ void CScStack::Push(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetPushValue() { +CScValue *CScStack::getPushValue() { _sP++; if (_sP >= _values.GetSize()) { @@ -95,14 +95,14 @@ CScValue *CScStack::GetPushValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetTop() { +CScValue *CScStack::getTop() { if (_sP < 0 || _sP >= _values.GetSize()) return NULL; else return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetAt(int index) { +CScValue *CScStack::getAt(int index) { index = _sP - index; if (index < 0 || index >= _values.GetSize()) return NULL; else return _values[index]; @@ -110,8 +110,8 @@ CScValue *CScStack::GetAt(int index) { ////////////////////////////////////////////////////////////////////////// -void CScStack::CorrectParams(uint32 expected_params) { - int nu_params = Pop()->GetInt(); +void CScStack::correctParams(uint32 expected_params) { + int nu_params = pop()->GetInt(); if (expected_params < nu_params) { // too many params while (expected_params < nu_params) { @@ -140,67 +140,67 @@ void CScStack::CorrectParams(uint32 expected_params) { ////////////////////////////////////////////////////////////////////////// -void CScStack::PushNULL() { +void CScStack::pushNULL() { /* CScValue* val = new CScValue(Game); val->SetNULL(); Push(val); delete val; */ - GetPushValue()->SetNULL(); + getPushValue()->SetNULL(); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushInt(int val) { +void CScStack::pushInt(int val) { /* CScValue* val = new CScValue(Game); val->SetInt(Val); Push(val); delete val; */ - GetPushValue()->SetInt(val); + getPushValue()->SetInt(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushFloat(double val) { +void CScStack::pushFloat(double val) { /* CScValue* val = new CScValue(Game); val->SetFloat(Val); Push(val); delete val; */ - GetPushValue()->SetFloat(val); + getPushValue()->SetFloat(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushBool(bool val) { +void CScStack::pushBool(bool val) { /* CScValue* val = new CScValue(Game); val->SetBool(Val); Push(val); delete val; */ - GetPushValue()->SetBool(val); + getPushValue()->SetBool(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushString(const char *val) { +void CScStack::pushString(const char *val) { /* CScValue* val = new CScValue(Game); val->SetString(Val); Push(val); delete val; */ - GetPushValue()->SetString(val); + getPushValue()->SetString(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushNative(CBScriptable *val, bool persistent) { +void CScStack::pushNative(CBScriptable *val, bool persistent) { /* CScValue* val = new CScValue(Game); val->SetNative(Val, Persistent); @@ -208,7 +208,7 @@ void CScStack::PushNative(CBScriptable *val, bool persistent) { delete val; */ - GetPushValue()->SetNative(val, persistent); + getPushValue()->SetNative(val, persistent); } diff --git a/engines/wintermute/Base/scriptables/ScStack.h b/engines/wintermute/Base/scriptables/ScStack.h index 3e7f557cdd..b2d5f15c1c 100644 --- a/engines/wintermute/Base/scriptables/ScStack.h +++ b/engines/wintermute/Base/scriptables/ScStack.h @@ -41,19 +41,19 @@ class CBScriptable; class CScStack : public CBBase { public: - CScValue *GetAt(int Index); - CScValue *GetPushValue(); + CScValue *getAt(int Index); + CScValue *getPushValue(); DECLARE_PERSISTENT(CScStack, CBBase) - void PushNative(CBScriptable *Val, bool Persistent); - void PushString(const char *Val); - void PushBool(bool Val); - void PushInt(int Val); - void PushFloat(double Val); - void PushNULL(); - void CorrectParams(uint32 expected_params); - CScValue *GetTop(); - void Push(CScValue *Val); - CScValue *Pop(); + void pushNative(CBScriptable *Val, bool Persistent); + void pushString(const char *Val); + void pushBool(bool Val); + void pushInt(int Val); + void pushFloat(double Val); + void pushNULL(); + void correctParams(uint32 expected_params); + CScValue *getTop(); + void push(CScValue *Val); + CScValue *pop(); CScStack(CBGame *inGame); virtual ~CScStack(); CBArray _values; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index ff51134321..b4fd782f76 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -44,9 +44,9 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); for (int i = 0; i < NumParams; i++) { - addScript(stack->Pop()->GetString()); + addScript(stack->pop()->GetString()); } } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 9829114d3a..538f8eb886 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -671,16 +671,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetDisabledFont ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetDisabledFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); if (Val->IsNULL()) { _fontDisable = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); - stack->PushBool(_fontDisable != NULL); + stack->pushBool(_fontDisable != NULL); } return S_OK; } @@ -689,16 +689,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetHoverFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHoverFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); if (Val->IsNULL()) { _fontHover = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { _fontHover = Game->_fontStorage->AddFont(Val->GetString()); - stack->PushBool(_fontHover != NULL); + stack->pushBool(_fontHover != NULL); } return S_OK; } @@ -707,16 +707,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetPressedFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPressedFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); if (Val->IsNULL()) { _fontPress = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { _fontPress = Game->_fontStorage->AddFont(Val->GetString()); - stack->PushBool(_fontPress != NULL); + stack->pushBool(_fontPress != NULL); } return S_OK; } @@ -725,16 +725,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetFocusedFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFocusedFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); if (Val->IsNULL()) { _fontFocus = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); - stack->PushBool(_fontFocus != NULL); + stack->pushBool(_fontFocus != NULL); } return S_OK; } @@ -743,16 +743,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetDisabledImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDisabledImage") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); delete _imageDisable; _imageDisable = new CBSprite(Game); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) { delete _imageDisable; _imageDisable = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -761,9 +761,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetDisabledImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDisabledImage") == 0) { - stack->CorrectParams(0); - if (!_imageDisable || !_imageDisable->_filename) stack->PushNULL(); - else stack->PushString(_imageDisable->_filename); + stack->correctParams(0); + if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); + else stack->pushString(_imageDisable->_filename); return S_OK; } @@ -772,9 +772,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetDisabledImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDisabledImageObject") == 0) { - stack->CorrectParams(0); - if (!_imageDisable) stack->PushNULL(); - else stack->PushNative(_imageDisable, true); + stack->correctParams(0); + if (!_imageDisable) stack->pushNULL(); + else stack->pushNative(_imageDisable, true); return S_OK; } @@ -784,16 +784,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetHoverImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHoverImage") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); delete _imageHover; _imageHover = new CBSprite(Game); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) { delete _imageHover; _imageHover = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -802,9 +802,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetHoverImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverImage") == 0) { - stack->CorrectParams(0); - if (!_imageHover || !_imageHover->_filename) stack->PushNULL(); - else stack->PushString(_imageHover->_filename); + stack->correctParams(0); + if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); + else stack->pushString(_imageHover->_filename); return S_OK; } @@ -813,9 +813,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetHoverImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverImageObject") == 0) { - stack->CorrectParams(0); - if (!_imageHover) stack->PushNULL(); - else stack->PushNative(_imageHover, true); + stack->correctParams(0); + if (!_imageHover) stack->pushNULL(); + else stack->pushNative(_imageHover, true); return S_OK; } @@ -824,16 +824,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetPressedImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPressedImage") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); delete _imagePress; _imagePress = new CBSprite(Game); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) { delete _imagePress; _imagePress = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -842,9 +842,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetPressedImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPressedImage") == 0) { - stack->CorrectParams(0); - if (!_imagePress || !_imagePress->_filename) stack->PushNULL(); - else stack->PushString(_imagePress->_filename); + stack->correctParams(0); + if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); + else stack->pushString(_imagePress->_filename); return S_OK; } @@ -853,9 +853,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetPressedImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPressedImageObject") == 0) { - stack->CorrectParams(0); - if (!_imagePress) stack->PushNULL(); - else stack->PushNative(_imagePress, true); + stack->correctParams(0); + if (!_imagePress) stack->pushNULL(); + else stack->pushNative(_imagePress, true); return S_OK; } @@ -864,16 +864,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetFocusedImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFocusedImage") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); delete _imageFocus; _imageFocus = new CBSprite(Game); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) { delete _imageFocus; _imageFocus = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -882,9 +882,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetFocusedImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFocusedImage") == 0) { - stack->CorrectParams(0); - if (!_imageFocus || !_imageFocus->_filename) stack->PushNULL(); - else stack->PushString(_imageFocus->_filename); + stack->correctParams(0); + if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); + else stack->pushString(_imageFocus->_filename); return S_OK; } @@ -893,9 +893,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetFocusedImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFocusedImageObject") == 0) { - stack->CorrectParams(0); - if (!_imageFocus) stack->PushNULL(); - else stack->PushNative(_imageFocus, true); + stack->correctParams(0); + if (!_imageFocus) stack->pushNULL(); + else stack->pushNative(_imageFocus, true); return S_OK; } @@ -904,13 +904,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Press ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Press") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_visible && !_disable) { _oneTimePress = true; _oneTimePressTime = CBPlatform::GetTime(); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index f0d4d62874..eb59724089 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -366,11 +366,11 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetSelectedFont ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSelectedFont") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont(stack->Pop()->GetString()); - stack->PushBool(_fontSelected != NULL); + _fontSelected = Game->_fontStorage->AddFont(stack->pop()->GetString()); + stack->pushBool(_fontSelected != NULL); return S_OK; } diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 2db966f89d..305f9642a5 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -256,10 +256,10 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetEntity ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetEntity") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); - if (_entity) stack->PushNative(_entity, true); - else stack->PushNULL(); + if (_entity) stack->pushNative(_entity, true); + else stack->pushNULL(); return S_OK; } @@ -268,14 +268,14 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetEntity") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (SUCCEEDED(setEntity(Filename))) - stack->PushBool(true); + stack->pushBool(true); else - stack->PushBool(false); + stack->pushBool(false); return S_OK; } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 45037ec490..a713649604 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -142,16 +142,16 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetFont ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFont") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (_font) Game->_fontStorage->RemoveFont(_font); if (Val->IsNULL()) { _font = NULL; - stack->PushBool(true); + stack->pushBool(true); } else { _font = Game->_fontStorage->AddFont(Val->GetString()); - stack->PushBool(_font != NULL); + stack->pushBool(_font != NULL); } return S_OK; } @@ -160,15 +160,15 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); /* const char *Filename = */ Val->GetString(); delete _image; _image = NULL; if (Val->IsNULL()) { - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -176,8 +176,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_image || FAILED(_image->loadFile(Val->GetString()))) { delete _image; _image = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -186,9 +186,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetImage") == 0) { - stack->CorrectParams(0); - if (!_image || !_image->_filename) stack->PushNULL(); - else stack->PushString(_image->_filename); + stack->correctParams(0); + if (!_image || !_image->_filename) stack->pushNULL(); + else stack->pushString(_image->_filename); return S_OK; } @@ -197,9 +197,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetImageObject") == 0) { - stack->CorrectParams(0); - if (!_image) stack->PushNULL(); - else stack->PushNative(_image, true); + stack->correctParams(0); + if (!_image) stack->pushNULL(); + else stack->pushNative(_image, true); return S_OK; } @@ -208,9 +208,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Focus ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Focus") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); focus(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -218,14 +218,14 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // MoveAfter / MoveBefore ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; int i; bool found = false; - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); // find directly if (val->IsNative()) { CUIObject *widget = (CUIObject *)val->GetNative(); @@ -258,14 +258,14 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th win->_widgets.RemoveAt(j); done = true; - stack->PushBool(true); + stack->pushBool(true); break; } } - if (!done) stack->PushBool(false); - } else stack->PushBool(false); + if (!done) stack->pushBool(false); + } else stack->pushBool(false); - } else stack->PushBool(false); + } else stack->pushBool(false); return S_OK; } @@ -274,7 +274,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // MoveToBottom ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveToBottom") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; @@ -285,8 +285,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th break; } } - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } @@ -295,7 +295,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // MoveToTop ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveToTop") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; @@ -306,8 +306,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th break; } } - stack->PushBool(true); - } else stack->PushBool(false); + stack->pushBool(true); + } else stack->pushBool(false); return S_OK; } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index e73006c28d..414a237556 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -381,9 +381,9 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SizeToFit ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SizeToFit") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); SizeToFit(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -391,9 +391,9 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // HeightToFit ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HeightToFit") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 26c60702cb..24e2255d2b 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -695,20 +695,20 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); if (val->GetType() == VAL_INT) { int widget = val->GetInt(); - if (widget < 0 || widget >= _widgets.GetSize()) stack->PushNULL(); - else stack->PushNative(_widgets[widget], true); + if (widget < 0 || widget >= _widgets.GetSize()) stack->pushNULL(); + else stack->pushNative(_widgets[widget], true); } else { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { - stack->PushNative(_widgets[i], true); + stack->pushNative(_widgets[i], true); return S_OK; } } - stack->PushNULL(); + stack->pushNULL(); } return S_OK; @@ -718,11 +718,11 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetInactiveFont ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInactiveFont") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont(stack->Pop()->GetString()); - stack->PushBool(_fontInactive != NULL); + _fontInactive = Game->_fontStorage->AddFont(stack->pop()->GetString()); + stack->pushBool(_fontInactive != NULL); return S_OK; } @@ -731,16 +731,16 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // SetInactiveImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInactiveImage") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); delete _imageInactive; _imageInactive = new CBSprite(Game); - const char *Filename = stack->Pop()->GetString(); + const char *Filename = stack->pop()->GetString(); if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) { delete _imageInactive; _imageInactive = NULL; - stack->PushBool(false); - } else stack->PushBool(true); + stack->pushBool(false); + } else stack->pushBool(true); return S_OK; } @@ -749,9 +749,9 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetInactiveImage ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInactiveImage") == 0) { - stack->CorrectParams(0); - if (!_imageInactive || !_imageInactive->_filename) stack->PushNULL(); - else stack->PushString(_imageInactive->_filename); + stack->correctParams(0); + if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); + else stack->pushString(_imageInactive->_filename); return S_OK; } @@ -760,9 +760,9 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GetInactiveImageObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInactiveImageObject") == 0) { - stack->CorrectParams(0); - if (!_imageInactive) stack->PushNULL(); - else stack->PushNative(_imageInactive, true); + stack->correctParams(0); + if (!_imageInactive) stack->pushNULL(); + else stack->pushNative(_imageInactive, true); return S_OK; } @@ -772,8 +772,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Close ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Close") == 0) { - stack->CorrectParams(0); - stack->PushBool(SUCCEEDED(close())); + stack->correctParams(0); + stack->pushBool(SUCCEEDED(close())); return S_OK; } @@ -781,10 +781,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GoExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoExclusive") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); goExclusive(); script->WaitFor(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -792,10 +792,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // GoSystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoSystemExclusive") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); goSystemExclusive(); script->WaitFor(this); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -803,10 +803,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Center ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Center") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); _posX = (Game->_renderer->_width - _width) / 2; _posY = (Game->_renderer->_height - _height) / 2; - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -814,13 +814,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // LoadFromFile ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadFromFile") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); cleanup(); if (!Val->IsNULL()) { - stack->PushBool(SUCCEEDED(loadFile(Val->GetString()))); - } else stack->PushBool(true); + stack->pushBool(SUCCEEDED(loadFile(Val->GetString()))); + } else stack->pushBool(true); return S_OK; } @@ -829,12 +829,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateButton") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIButton *Btn = new CUIButton(Game); if (!Val->IsNULL()) Btn->setName(Val->GetString()); - stack->PushNative(Btn, true); + stack->pushNative(Btn, true); Btn->_parent = this; _widgets.Add(Btn); @@ -846,12 +846,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateStatic ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateStatic") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIText *Sta = new CUIText(Game); if (!Val->IsNULL()) Sta->setName(Val->GetString()); - stack->PushNative(Sta, true); + stack->pushNative(Sta, true); Sta->_parent = this; _widgets.Add(Sta); @@ -863,12 +863,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateEditor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEditor") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIEdit *Edi = new CUIEdit(Game); if (!Val->IsNULL()) Edi->setName(Val->GetString()); - stack->PushNative(Edi, true); + stack->pushNative(Edi, true); Edi->_parent = this; _widgets.Add(Edi); @@ -880,12 +880,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // CreateWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); CUIWindow *Win = new CUIWindow(Game); if (!Val->IsNULL()) Win->setName(Val->GetString()); - stack->PushNative(Win, true); + stack->pushNative(Win, true); Win->_parent = this; _widgets.Add(Win); @@ -897,8 +897,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { - stack->CorrectParams(1); - CScValue *val = stack->Pop(); + stack->correctParams(1); + CScValue *val = stack->pop(); CUIObject *obj = (CUIObject *)val->GetNative(); for (int i = 0; i < _widgets.GetSize(); i++) { @@ -908,7 +908,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); } } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } else if SUCCEEDED(Game->WindowScriptMethodHook(this, script, stack, name)) return S_OK; -- cgit v1.2.3 From 2f90dd76f99a827ce1bf5ea8ee6d653396756e1b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:37:08 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in CScValue --- engines/wintermute/Ad/AdActor.cpp | 58 +-- engines/wintermute/Ad/AdEntity.cpp | 38 +- engines/wintermute/Ad/AdGame.cpp | 162 ++++---- engines/wintermute/Ad/AdItem.cpp | 46 +-- engines/wintermute/Ad/AdLayer.cpp | 48 +-- engines/wintermute/Ad/AdObject.cpp | 124 +++--- engines/wintermute/Ad/AdRegion.cpp | 28 +- engines/wintermute/Ad/AdScene.cpp | 168 ++++---- engines/wintermute/Ad/AdTalkHolder.cpp | 22 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 8 +- engines/wintermute/Base/BFrame.cpp | 52 +-- engines/wintermute/Base/BGame.cpp | 426 ++++++++++----------- engines/wintermute/Base/BKeyboardState.cpp | 26 +- engines/wintermute/Base/BObject.cpp | 154 ++++---- engines/wintermute/Base/BRegion.cpp | 38 +- engines/wintermute/Base/BScriptHolder.cpp | 26 +- engines/wintermute/Base/BScriptable.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 40 +- engines/wintermute/Base/BSubFrame.cpp | 42 +- engines/wintermute/Base/PartEmitter.cpp | 180 ++++----- engines/wintermute/Base/scriptables/SXArray.cpp | 36 +- engines/wintermute/Base/scriptables/SXDate.cpp | 34 +- engines/wintermute/Base/scriptables/SXFile.cpp | 46 +-- engines/wintermute/Base/scriptables/SXMath.cpp | 50 +-- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 62 +-- engines/wintermute/Base/scriptables/SXStore.cpp | 44 +-- engines/wintermute/Base/scriptables/SXString.cpp | 36 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 20 +- engines/wintermute/Base/scriptables/ScScript.cpp | 246 ++++++------ engines/wintermute/Base/scriptables/ScStack.cpp | 32 +- engines/wintermute/Base/scriptables/ScValue.cpp | 318 +++++++-------- engines/wintermute/Base/scriptables/ScValue.h | 82 ++-- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- engines/wintermute/UI/UIButton.cpp | 44 +-- engines/wintermute/UI/UIEdit.cpp | 38 +- engines/wintermute/UI/UIEntity.cpp | 12 +- engines/wintermute/UI/UIObject.cpp | 56 +-- engines/wintermute/UI/UIText.cpp | 12 +- engines/wintermute/UI/UIWindow.cpp | 66 ++-- 39 files changed, 1464 insertions(+), 1464 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index d6ed8a35c3..f553128d79 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -856,8 +856,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); goTo(X, Y); if (strcmp(name, "GoToAsync") != 0) script->WaitForExclusive(this); stack->pushNULL(); @@ -870,12 +870,12 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { stack->correctParams(1); CScValue *Val = stack->pop(); - if (!Val->IsNative()) { + if (!Val->isNative()) { script->RuntimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return S_OK; } - CAdObject *Obj = (CAdObject *)Val->GetNative(); + CAdObject *Obj = (CAdObject *)Val->getNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { script->RuntimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); @@ -898,13 +898,13 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val = stack->pop(); // turn to object? - if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) { - CBObject *obj = (CBObject *)val->GetNative(); + if (val->isNative() && Game->ValidObject((CBObject *)val->getNative())) { + CBObject *obj = (CBObject *)val->getNative(); int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); dir = (int)angleToDirection(angle); } // otherwise turn to direction - else dir = val->GetInt(); + else dir = val->getInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) { turnTo((TDirection)dir); @@ -928,7 +928,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MergeAnims") == 0) { stack->correctParams(1); - stack->pushBool(SUCCEEDED(mergeAnims(stack->pop()->GetString()))); + stack->pushBool(SUCCEEDED(mergeAnims(stack->pop()->getString()))); return S_OK; } @@ -937,7 +937,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->GetString(); + const char *AnimName = stack->pop()->getString(); bool Found = false; for (int i = 0; i < _anims.GetSize(); i++) { @@ -963,7 +963,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->GetString(); + const char *AnimName = stack->pop()->getString(); stack->pushBool(getAnimByName(AnimName) != NULL); return S_OK; } @@ -974,27 +974,27 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdActor::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Direction") == 0) { - _scValue->SetInt(_dir); + _scValue->setInt(_dir); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Type") == 0) { - _scValue->SetString("actor"); + _scValue->setString("actor"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkAnimName") == 0) { - _scValue->SetString(_talkAnimName); + _scValue->setString(_talkAnimName); return _scValue; } @@ -1002,7 +1002,7 @@ CScValue *CAdActor::scGetProperty(const char *name) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkAnimName") == 0) { - _scValue->SetString(_walkAnimName); + _scValue->setString(_walkAnimName); return _scValue; } @@ -1010,7 +1010,7 @@ CScValue *CAdActor::scGetProperty(const char *name) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IdleAnimName") == 0) { - _scValue->SetString(_idleAnimName); + _scValue->setString(_idleAnimName); return _scValue; } @@ -1018,7 +1018,7 @@ CScValue *CAdActor::scGetProperty(const char *name) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnLeftAnimName") == 0) { - _scValue->SetString(_turnLeftAnimName); + _scValue->setString(_turnLeftAnimName); return _scValue; } @@ -1026,7 +1026,7 @@ CScValue *CAdActor::scGetProperty(const char *name) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnRightAnimName") == 0) { - _scValue->SetString(_turnRightAnimName); + _scValue->setString(_turnRightAnimName); return _scValue; } @@ -1040,7 +1040,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // Direction ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Direction") == 0) { - int dir = value->GetInt(); + int dir = value->getInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; return S_OK; } @@ -1049,8 +1049,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkAnimName") == 0) { - if (value->IsNULL()) _talkAnimName = "talk"; - else _talkAnimName = value->GetString(); + if (value->isNULL()) _talkAnimName = "talk"; + else _talkAnimName = value->getString(); return S_OK; } @@ -1058,8 +1058,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkAnimName") == 0) { - if (value->IsNULL()) _walkAnimName = "walk"; - else _walkAnimName = value->GetString(); + if (value->isNULL()) _walkAnimName = "walk"; + else _walkAnimName = value->getString(); return S_OK; } @@ -1067,8 +1067,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IdleAnimName") == 0) { - if (value->IsNULL()) _idleAnimName = "idle"; - else _idleAnimName = value->GetString(); + if (value->isNULL()) _idleAnimName = "idle"; + else _idleAnimName = value->getString(); return S_OK; } @@ -1076,8 +1076,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnLeftAnimName") == 0) { - if (value->IsNULL()) _turnLeftAnimName = "turnleft"; - else _turnLeftAnimName = value->GetString(); + if (value->isNULL()) _turnLeftAnimName = "turnleft"; + else _turnLeftAnimName = value->getString(); return S_OK; } @@ -1085,8 +1085,8 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnRightAnimName") == 0) { - if (value->IsNULL()) _turnRightAnimName = "turnright"; - else _turnRightAnimName = value->GetString(); + if (value->isNULL()) _turnRightAnimName = "turnright"; + else _turnRightAnimName = value->getString(); return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 2b4a2871f0..d3074c1562 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -642,15 +642,15 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { stack->correctParams(4); - const char *filename = stack->pop()->GetString(); - bool looping = stack->pop()->GetBool(false); + const char *filename = stack->pop()->getString(); + bool looping = stack->pop()->getBool(false); CScValue *valAlpha = stack->pop(); - int startTime = stack->pop()->GetInt(); + int startTime = stack->pop()->getInt(); delete _theora; _theora = new CVidTheoraPlayer(Game); if (_theora && SUCCEEDED(_theora->initialize(filename))) { - if (!valAlpha->IsNULL()) _theora->setAlphaImage(valAlpha->GetString()); + if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; stack->pushBool(true); @@ -761,13 +761,13 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CAdEntity::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("entity"); + _scValue->setString("entity"); return _scValue; } @@ -775,8 +775,8 @@ CScValue *CAdEntity::scGetProperty(const char *name) { // Item ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Item") == 0) { - if (_item) _scValue->SetString(_item); - else _scValue->SetNULL(); + if (_item) _scValue->setString(_item); + else _scValue->setNULL(); return _scValue; } @@ -786,9 +786,9 @@ CScValue *CAdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtype") == 0) { if (_subtype == ENTITY_SOUND) - _scValue->SetString("sound"); + _scValue->setString("sound"); else - _scValue->SetString("normal"); + _scValue->setString("normal"); return _scValue; } @@ -797,7 +797,7 @@ CScValue *CAdEntity::scGetProperty(const char *name) { // WalkToX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToX") == 0) { - _scValue->SetInt(_walkToX); + _scValue->setInt(_walkToX); return _scValue; } @@ -805,7 +805,7 @@ CScValue *CAdEntity::scGetProperty(const char *name) { // WalkToY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToY") == 0) { - _scValue->SetInt(_walkToY); + _scValue->setInt(_walkToY); return _scValue; } @@ -813,7 +813,7 @@ CScValue *CAdEntity::scGetProperty(const char *name) { // WalkToDirection ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToDirection") == 0) { - _scValue->SetInt((int)_walkToDir); + _scValue->setInt((int)_walkToDir); return _scValue; } @@ -821,8 +821,8 @@ CScValue *CAdEntity::scGetProperty(const char *name) { // Region (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Region") == 0) { - if (_region) _scValue->SetNative(_region, true); - else _scValue->SetNULL(); + if (_region) _scValue->setNative(_region, true); + else _scValue->setNULL(); return _scValue; } @@ -837,7 +837,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { // Item ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Item") == 0) { - setItem(value->GetString()); + setItem(value->getString()); return S_OK; } @@ -845,7 +845,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { // WalkToX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToX") == 0) { - _walkToX = value->GetInt(); + _walkToX = value->getInt(); return S_OK; } @@ -853,7 +853,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { // WalkToY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToY") == 0) { - _walkToY = value->GetInt(); + _walkToY = value->getInt(); return S_OK; } @@ -861,7 +861,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { // WalkToDirection ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToDirection") == 0) { - int dir = value->GetInt(); + int dir = value->getInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; return S_OK; } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index cbcf488abb..ee8e3ca6c1 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -322,19 +322,19 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "ChangeScene") == 0) { stack->correctParams(3); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); CScValue *valFadeOut = stack->pop(); CScValue *valFadeIn = stack->pop(); - bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool(); - bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool(); + bool TransOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); + bool TransIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); ScheduleChangeScene(Filename, TransIn); if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true); stack->pushNULL(); - //HRESULT ret = ChangeScene(stack->pop()->GetString()); + //HRESULT ret = ChangeScene(stack->pop()->getString()); //if(FAILED(ret)) stack->pushBool(false); //else stack->pushBool(true); @@ -347,7 +347,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->pop()->getString()))) { AddObject(act); stack->pushNative(act, true); } else { @@ -364,7 +364,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->pop()->getString()))) { AddObject(ent); stack->pushNative(ent, true); } else { @@ -381,9 +381,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->GetNative(); + CAdObject *obj = (CAdObject *)val->getNative(); RemoveObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); return S_OK; @@ -398,7 +398,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CAdEntity *Ent = new CAdEntity(Game); AddObject(Ent); - if (!Val->IsNULL()) Ent->setName(Val->GetString()); + if (!Val->isNULL()) Ent->setName(Val->getString()); stack->pushNative(Ent, true); return S_OK; } @@ -412,7 +412,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CAdItem *Item = new CAdItem(Game); AddItem(Item); - if (!Val->IsNULL()) Item->setName(Val->GetString()); + if (!Val->isNULL()) Item->setName(Val->getString()); stack->pushNative(Item, true); return S_OK; } @@ -425,8 +425,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CScValue *Val = stack->pop(); CAdItem *Item = NULL; - if (Val->IsNative()) Item = (CAdItem *)Val->GetNative(); - else Item = GetItemByName(Val->GetString()); + if (Val->isNative()) Item = (CAdItem *)Val->getNative(); + else Item = GetItemByName(Val->getString()); if (Item) { DeleteItem(Item); @@ -444,11 +444,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CScValue *Val = stack->pop(); CAdItem *Item = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); + if (Val->isInt()) { + int Index = Val->getInt(); if (Index >= 0 && Index < _items.GetSize()) Item = _items[Index]; } else { - Item = GetItemByName(Val->GetString()); + Item = GetItemByName(Val->getString()); } if (Item) stack->pushNative(Item, true); @@ -463,8 +463,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { stack->correctParams(6); - int id = stack->pop()->GetInt(); - const char *text = stack->pop()->GetString(); + int id = stack->pop()->getInt(); + const char *text = stack->pop()->getString(); CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); CScValue *val3 = stack->pop(); @@ -476,10 +476,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this res->_iD = id; res->SetText(text); _stringTable->Expand(&res->_text); - if (!val1->IsNULL()) res->SetIcon(val1->GetString()); - if (!val2->IsNULL()) res->SetIconHover(val2->GetString()); - if (!val3->IsNULL()) res->SetIconPressed(val3->GetString()); - if (!val4->IsNULL()) res->SetFont(val4->GetString()); + if (!val1->isNULL()) res->SetIcon(val1->getString()); + if (!val2->isNULL()) res->SetIconHover(val2->getString()); + if (!val3->isNULL()) res->SetIconPressed(val3->getString()); + if (!val4->isNULL()) res->SetFont(val4->getString()); if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; @@ -499,7 +499,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResetResponse") == 0) { stack->correctParams(1); - int ID = stack->pop()->GetInt(-1); + int ID = stack->pop()->getInt(-1); ResetResponse(ID); stack->pushNULL(); return S_OK; @@ -521,7 +521,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponse") == 0) { stack->correctParams(1); - bool AutoSelectLast = stack->pop()->GetBool(); + bool AutoSelectLast = stack->pop()->getBool(); if (_responseBox) { _responseBox->weedResponses(); @@ -575,9 +575,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CScValue *Val = stack->pop(); Common::String BranchName; - if (Val->IsNULL()) { + if (Val->isNULL()) { BranchName.format("line%d", script->_currentLine); - } else BranchName = Val->GetString(); + } else BranchName = Val->getString(); StartDlgBranch(BranchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); @@ -593,7 +593,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this const char *BranchName = NULL; CScValue *Val = stack->pop(); - if (!Val->IsNULL()) BranchName = Val->GetString(); + if (!Val->isNULL()) BranchName = Val->getString(); EndDlgBranch(BranchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); @@ -649,15 +649,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CScValue *val = stack->pop(); - if (!val->IsNULL()) { + if (!val->isNULL()) { for (int i = 0; i < _inventories.GetSize(); i++) { CAdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { - if (val->GetNative() == Inv->_takenItems[j]) { + if (val->getNative() == Inv->_takenItems[j]) { stack->pushBool(true); return S_OK; - } else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) { + } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { stack->pushBool(true); return S_OK; } @@ -700,7 +700,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadResponseBox") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); Game->UnregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); @@ -720,7 +720,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadInventoryBox") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); Game->UnregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); @@ -740,8 +740,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadItems") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->GetString(); - bool Merge = stack->pop()->GetBool(false); + const char *Filename = stack->pop()->getString(); + bool Merge = stack->pop()->getBool(false); HRESULT Ret = LoadItemsFile(Filename, Merge); stack->pushBool(SUCCEEDED(Ret)); @@ -754,7 +754,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSpeechDir") == 0) { stack->correctParams(1); - const char *Dir = stack->pop()->GetString(); + const char *Dir = stack->pop()->getString(); stack->pushBool(SUCCEEDED(AddSpeechDir(Dir))); return S_OK; @@ -765,7 +765,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSpeechDir") == 0) { stack->correctParams(1); - const char *Dir = stack->pop()->GetString(); + const char *Dir = stack->pop()->getString(); stack->pushBool(SUCCEEDED(RemoveSpeechDir(Dir))); return S_OK; @@ -776,10 +776,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSceneViewport") == 0) { stack->correctParams(4); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); - int Width = stack->pop()->GetInt(); - int Height = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + int Width = stack->pop()->getInt(); + int Height = stack->pop()->getInt(); if (Width <= 0) Width = _renderer->_width; if (Height <= 0) Height = _renderer->_height; @@ -799,21 +799,21 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CAdGame::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("game"); + _scValue->setString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scene") == 0) { - if (_scene) _scValue->SetNative(_scene, true); - else _scValue->SetNULL(); + if (_scene) _scValue->setNative(_scene, true); + else _scValue->setNULL(); return _scValue; } @@ -821,9 +821,9 @@ CScValue *CAdGame::scGetProperty(const char *name) { // SelectedItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelectedItem") == 0) { - //if(_selectedItem) _scValue->SetString(_selectedItem->_name); - if (_selectedItem) _scValue->SetNative(_selectedItem, true); - else _scValue->SetNULL(); + //if(_selectedItem) _scValue->setString(_selectedItem->_name); + if (_selectedItem) _scValue->setNative(_selectedItem, true); + else _scValue->setNULL(); return _scValue; } @@ -838,7 +838,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // SmartItemCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SmartItemCursor") == 0) { - _scValue->SetBool(_smartItemCursor); + _scValue->setBool(_smartItemCursor); return _scValue; } @@ -846,7 +846,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryVisible") == 0) { - _scValue->SetBool(_inventoryBox && _inventoryBox->_visible); + _scValue->setBool(_inventoryBox && _inventoryBox->_visible); return _scValue; } @@ -854,8 +854,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _scValue->SetInt(_inventoryBox->_scrollOffset); - else _scValue->SetInt(0); + if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); + else _scValue->setInt(0); return _scValue; } @@ -864,7 +864,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // ResponsesVisible (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResponsesVisible") == 0) { - _scValue->SetBool(_stateEx == GAME_WAITING_RESPONSE); + _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); return _scValue; } @@ -872,8 +872,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // PrevScene / PreviousScene (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { - if (!_prevSceneName) _scValue->SetString(""); - else _scValue->SetString(_prevSceneName); + if (!_prevSceneName) _scValue->setString(""); + else _scValue->setString(_prevSceneName); return _scValue; } @@ -881,8 +881,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // PrevSceneFilename / PreviousSceneFilename (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { - if (!_prevSceneFilename) _scValue->SetString(""); - else _scValue->SetString(_prevSceneFilename); + if (!_prevSceneFilename) _scValue->setString(""); + else _scValue->setString(_prevSceneFilename); return _scValue; } @@ -890,8 +890,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LastResponse") == 0) { - if (!_responseBox || !_responseBox->_lastResponseText) _scValue->SetString(""); - else _scValue->SetString(_responseBox->_lastResponseText); + if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseText); return _scValue; } @@ -899,8 +899,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LastResponseOrig") == 0) { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->SetString(""); - else _scValue->SetString(_responseBox->_lastResponseTextOrig); + if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseTextOrig); return _scValue; } @@ -908,8 +908,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner == _invObject) _scValue->SetNative(this, true); - else _scValue->SetNative(_inventoryOwner, true); + if (_inventoryOwner == _invObject) _scValue->setNative(this, true); + else _scValue->setNative(_inventoryOwner, true); return _scValue; } @@ -918,7 +918,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // TotalNumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TotalNumItems") == 0) { - _scValue->SetInt(_items.GetSize()); + _scValue->setInt(_items.GetSize()); return _scValue; } @@ -926,7 +926,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // TalkSkipButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkSkipButton") == 0) { - _scValue->SetInt(_talkSkipButton); + _scValue->setInt(_talkSkipButton); return _scValue; } @@ -934,7 +934,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // ChangingScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ChangingScene") == 0) { - _scValue->SetBool(_scheduledScene != NULL); + _scValue->setBool(_scheduledScene != NULL); return _scValue; } @@ -942,8 +942,8 @@ CScValue *CAdGame::scGetProperty(const char *name) { // StartupScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartupScene") == 0) { - if (!_startupScene) _scValue->SetNULL(); - else _scValue->SetString(_startupScene); + if (!_startupScene) _scValue->setNULL(); + else _scValue->setString(_startupScene); return _scValue; } @@ -958,19 +958,19 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { // SelectedItem ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelectedItem") == 0) { - if (value->IsNULL()) _selectedItem = NULL; + if (value->isNULL()) _selectedItem = NULL; else { - if (value->IsNative()) { + if (value->isNative()) { _selectedItem = NULL; for (int i = 0; i < _items.GetSize(); i++) { - if (_items[i] == value->GetNative()) { - _selectedItem = (CAdItem *)value->GetNative(); + if (_items[i] == value->getNative()) { + _selectedItem = (CAdItem *)value->getNative(); break; } } } else { // try to get by name - _selectedItem = GetItemByName(value->GetString()); + _selectedItem = GetItemByName(value->getString()); } } @@ -981,7 +981,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { // SmartItemCursor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SmartItemCursor") == 0) { - _smartItemCursor = value->GetBool(); + _smartItemCursor = value->getBool(); return S_OK; } @@ -989,7 +989,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = value->GetBool(); + if (_inventoryBox) _inventoryBox->_visible = value->getBool(); return S_OK; } @@ -999,9 +999,9 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "InventoryObject") == 0) { if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - if (value->IsNULL()) _inventoryOwner = _invObject; + if (value->isNULL()) _inventoryOwner = _invObject; else { - CBObject *Obj = (CBObject *)value->GetNative(); + CBObject *Obj = (CBObject *)value->getNative(); if (Obj == this) _inventoryOwner = _invObject; else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } @@ -1015,7 +1015,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = value->GetInt(); + if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); return S_OK; } @@ -1023,7 +1023,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { // TalkSkipButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkSkipButton") == 0) { - int Val = value->GetInt(); + int Val = value->getInt(); if (Val < 0) Val = 0; if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; _talkSkipButton = (TTalkSkipButton)Val; @@ -1037,7 +1037,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { if (value == NULL) { delete[] _startupScene; _startupScene = NULL; - } else CBUtils::SetString(&_startupScene, value->GetString()); + } else CBUtils::SetString(&_startupScene, value->getString()); return S_OK; } @@ -1068,7 +1068,7 @@ HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->SetNative(new CAdActor(Game)); + this_obj->setNative(new CAdActor(Game)); stack->pushNULL(); } @@ -1079,7 +1079,7 @@ HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->SetNative(new CAdEntity(Game)); + this_obj->setNative(new CAdEntity(Game)); stack->pushNULL(); } @@ -1524,7 +1524,7 @@ HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScSt CScValue *Val = stack->pop(); CUIEntity *Ent = new CUIEntity(Game); - if (!Val->IsNULL()) Ent->setName(Val->GetString()); + if (!Val->isNULL()) Ent->setName(Val->getString()); stack->pushNative(Ent, true); Ent->_parent = Win; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 69d7e115da..a6c990528f 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -439,7 +439,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this bool SetCurrent = false; if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); delete _spriteHover; _spriteHover = NULL; @@ -482,7 +482,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetNormalCursor") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); delete _cursorNormal; _cursorNormal = NULL; @@ -525,7 +525,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetHoverCursor") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); delete _cursorHover; _cursorHover = NULL; @@ -568,13 +568,13 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CAdItem::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("item"); + _scValue->setString("item"); return _scValue; } @@ -582,7 +582,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } @@ -590,7 +590,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // DisplayAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisplayAmount") == 0) { - _scValue->SetBool(_displayAmount); + _scValue->setBool(_displayAmount); return _scValue; } @@ -598,7 +598,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // Amount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Amount") == 0) { - _scValue->SetInt(_amount); + _scValue->setInt(_amount); return _scValue; } @@ -606,7 +606,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // AmountOffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetX") == 0) { - _scValue->SetInt(_amountOffsetX); + _scValue->setInt(_amountOffsetX); return _scValue; } @@ -614,7 +614,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // AmountOffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetY") == 0) { - _scValue->SetInt(_amountOffsetY); + _scValue->setInt(_amountOffsetY); return _scValue; } @@ -622,7 +622,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // AmountAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountAlign") == 0) { - _scValue->SetInt(_amountAlign); + _scValue->setInt(_amountAlign); return _scValue; } @@ -630,8 +630,8 @@ CScValue *CAdItem::scGetProperty(const char *name) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountString") == 0) { - if (!_amountString) _scValue->SetNULL(); - else _scValue->SetString(_amountString); + if (!_amountString) _scValue->setNULL(); + else _scValue->setString(_amountString); return _scValue; } @@ -639,7 +639,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { // CursorCombined ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorCombined") == 0) { - _scValue->SetBool(_cursorCombined); + _scValue->setBool(_cursorCombined); return _scValue; } @@ -653,7 +653,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -661,7 +661,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // DisplayAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisplayAmount") == 0) { - _displayAmount = value->GetBool(); + _displayAmount = value->getBool(); return S_OK; } @@ -669,7 +669,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // Amount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Amount") == 0) { - _amount = value->GetInt(); + _amount = value->getInt(); return S_OK; } @@ -677,7 +677,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // AmountOffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetX") == 0) { - _amountOffsetX = value->GetInt(); + _amountOffsetX = value->getInt(); return S_OK; } @@ -685,7 +685,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // AmountOffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetY") == 0) { - _amountOffsetY = value->GetInt(); + _amountOffsetY = value->getInt(); return S_OK; } @@ -693,7 +693,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // AmountAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountAlign") == 0) { - _amountAlign = (TTextAlign)value->GetInt(); + _amountAlign = (TTextAlign)value->getInt(); return S_OK; } @@ -701,11 +701,11 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountString") == 0) { - if (value->IsNULL()) { + if (value->isNULL()) { delete[] _amountString; _amountString = NULL; } else { - CBUtils::SetString(&_amountString, value->GetString()); + CBUtils::SetString(&_amountString, value->getString()); } return S_OK; } @@ -714,7 +714,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { // CursorCombined ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorCombined") == 0) { - _cursorCombined = value->GetBool(); + _cursorCombined = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 25d292f44e..b462d23963 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -236,11 +236,11 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val = stack->pop(); int node = -1; - if (val->_type == VAL_INT) node = val->GetInt(); + if (val->_type == VAL_INT) node = val->getInt(); else { // get by name for (int i = 0; i < _nodes.GetSize(); i++) { - if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->GetString()) == 0) || - (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->GetString()) == 0)) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { node = i; break; } @@ -273,12 +273,12 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(name, "AddRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->setName(Val->GetString()); + if (!Val->isNULL()) Region->setName(Val->getString()); Node->setRegion(Region); stack->pushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->setName(Val->GetString()); + if (!Val->isNULL()) Entity->setName(Val->getString()); Node->setEntity(Entity); stack->pushNative(Entity, true); } @@ -291,18 +291,18 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { stack->correctParams(2); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); CScValue *Val = stack->pop(); CAdSceneNode *Node = new CAdSceneNode(Game); if (strcmp(name, "InsertRegion") == 0) { CAdRegion *Region = new CAdRegion(Game); - if (!Val->IsNULL()) Region->setName(Val->GetString()); + if (!Val->isNULL()) Region->setName(Val->getString()); Node->setRegion(Region); stack->pushNative(Region, true); } else { CAdEntity *Entity = new CAdEntity(Game); - if (!Val->IsNULL()) Entity->setName(Val->GetString()); + if (!Val->isNULL()) Entity->setName(Val->getString()); Node->setEntity(Entity); stack->pushNative(Entity, true); } @@ -321,8 +321,8 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *Val = stack->pop(); CAdSceneNode *ToDelete = NULL; - if (Val->IsNative()) { - CBScriptable *Temp = Val->GetNative(); + if (Val->isNative()) { + CBScriptable *Temp = Val->getNative(); for (int i = 0; i < _nodes.GetSize(); i++) { if (_nodes[i]->_region == Temp || _nodes[i]->_entity == Temp) { ToDelete = _nodes[i]; @@ -330,7 +330,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } } else { - int Index = Val->GetInt(); + int Index = Val->getInt(); if (Index >= 0 && Index < _nodes.GetSize()) { ToDelete = _nodes[Index]; } @@ -358,13 +358,13 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdLayer::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("layer"); + _scValue->setString("layer"); return _scValue; } @@ -372,7 +372,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumNodes") == 0) { - _scValue->SetInt(_nodes.GetSize()); + _scValue->setInt(_nodes.GetSize()); return _scValue; } @@ -380,7 +380,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _scValue->SetInt(_width); + _scValue->setInt(_width); return _scValue; } @@ -388,7 +388,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _scValue->SetInt(_height); + _scValue->setInt(_height); return _scValue; } @@ -396,7 +396,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // Main (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Main") == 0) { - _scValue->SetBool(_main); + _scValue->setBool(_main); return _scValue; } @@ -404,7 +404,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // CloseUp ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CloseUp") == 0) { - _scValue->SetBool(_closeUp); + _scValue->setBool(_closeUp); return _scValue; } @@ -412,7 +412,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _scValue->SetBool(_active); + _scValue->setBool(_active); return _scValue; } @@ -426,7 +426,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -434,7 +434,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { // CloseUp ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CloseUp") == 0) { - _closeUp = value->GetBool(); + _closeUp = value->getBool(); return S_OK; } @@ -442,7 +442,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = value->GetInt(); + _width = value->getInt(); if (_width < 0) _width = 0; return S_OK; } @@ -451,7 +451,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = value->GetInt(); + _height = value->getInt(); if (_height < 0) _height = 0; return S_OK; } @@ -460,7 +460,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - bool b = value->GetBool(); + bool b = value->getBool(); if (b == false && _main) { Game->LOG(0, "Warning: cannot deactivate scene's main layer"); } else _active = b; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 58c892dae8..2f72a2dcbe 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -194,7 +194,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { stack->correctParams(1); - if (FAILED(playAnim(stack->pop()->GetString()))) stack->pushBool(false); + if (FAILED(playAnim(stack->pop()->getString()))) stack->pushBool(false); else { if (strcmp(name, "PlayAnimAsync") != 0) script->WaitFor(this); stack->pushBool(true); @@ -240,7 +240,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ForceTalkAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->GetString(); + const char *AnimName = stack->pop()->getString(); delete[] _forcedTalkAnimName; _forcedTalkAnimName = new char[strlen(AnimName) + 1]; strcpy(_forcedTalkAnimName, AnimName); @@ -256,21 +256,21 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { stack->correctParams(5); - const char *Text = stack->pop()->GetString(); + const char *Text = stack->pop()->getString(); CScValue *SoundVal = stack->pop(); - int Duration = stack->pop()->GetInt(); + int Duration = stack->pop()->getInt(); CScValue *ValStances = stack->pop(); - const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString(); + const char *Stances = ValStances->isNULL() ? NULL : ValStances->getString(); int Align; CScValue *val = stack->pop(); - if (val->IsNULL()) Align = TAL_CENTER; - else Align = val->GetInt(); + if (val->isNULL()) Align = TAL_CENTER; + else Align = val->getInt(); Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); - const char *Sound = SoundVal->IsNULL() ? NULL : SoundVal->GetString(); + const char *Sound = SoundVal->isNULL() ? NULL : SoundVal->getString(); talk(Text, Sound, Duration, Stances, (TTextAlign)Align); if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this); @@ -290,11 +290,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th int i; CScValue *Val = stack->pop(); - if (Val->IsNULL() || !Main) { + if (Val->isNULL() || !Main) { _stickRegion = NULL; RegFound = true; - } else if (Val->IsString()) { - const char *RegionName = Val->GetString(); + } else if (Val->isString()) { + const char *RegionName = Val->getString(); for (i = 0; i < Main->_nodes.GetSize(); i++) { if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { _stickRegion = Main->_nodes[i]->_region; @@ -302,8 +302,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th break; } } - } else if (Val->IsNative()) { - CBScriptable *Obj = Val->GetNative(); + } else if (Val->isNative()) { + CBScriptable *Obj = Val->getNative(); for (i = 0; i < Main->_nodes.GetSize(); i++) { if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region == Obj) { @@ -327,8 +327,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (Val->IsNULL()) SetFont(NULL); - else SetFont(Val->GetString()); + if (Val->isNULL()) SetFont(NULL); + else SetFont(Val->getString()); stack->pushNULL(); return S_OK; @@ -356,10 +356,10 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } CScValue *val = stack->pop(); - if (!val->IsNULL()) { - const char *ItemName = val->GetString(); + if (!val->isNULL()) { + const char *ItemName = val->getString(); val = stack->pop(); - const char *InsertAfter = val->IsNULL() ? NULL : val->GetString(); + const char *InsertAfter = val->isNULL() ? NULL : val->getString(); if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities @@ -384,11 +384,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } CScValue *val = stack->pop(); - if (!val->IsNULL()) { - if (FAILED(_inventory->RemoveItem(val->GetString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString()); + if (!val->isNULL()) { + if (FAILED(_inventory->RemoveItem(val->getString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities - ((CAdGame *)Game)->_scene->handleItemAssociations(val->GetString(), true); + ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true); } } else script->RuntimeError("DropItem: item name expected"); @@ -409,13 +409,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString()); + CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->getString()); if (item) stack->pushNative(item, true); else stack->pushNULL(); - } else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize()) + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.GetSize()) stack->pushNULL(); else - stack->pushNative(_inventory->_takenItems[val->GetInt()], true); + stack->pushNative(_inventory->_takenItems[val->getInt()], true); return S_OK; } @@ -432,12 +432,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } CScValue *val = stack->pop(); - if (!val->IsNULL()) { + if (!val->isNULL()) { for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { - if (val->GetNative() == _inventory->_takenItems[i]) { + if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); return S_OK; - } else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) { + } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { stack->pushBool(true); return S_OK; } @@ -453,9 +453,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateParticleEmitter") == 0) { stack->correctParams(3); - bool FollowParent = stack->pop()->GetBool(); - int OffsetX = stack->pop()->GetInt(); - int OffsetY = stack->pop()->GetInt(); + bool FollowParent = stack->pop()->getBool(); + int OffsetX = stack->pop()->getInt(); + int OffsetY = stack->pop()->getInt(); CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY); if (Emitter) stack->pushNative(_partEmitter, true); @@ -483,10 +483,10 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddAttachment") == 0) { stack->correctParams(4); - const char *Filename = stack->pop()->GetString(); - bool PreDisplay = stack->pop()->GetBool(true); - int OffsetX = stack->pop()->GetInt(); - int OffsetY = stack->pop()->GetInt(); + const char *Filename = stack->pop()->getString(); + bool PreDisplay = stack->pop()->getBool(true); + int OffsetX = stack->pop()->getInt(); + int OffsetY = stack->pop()->getInt(); HRESULT res; CAdEntity *Ent = new CAdEntity(Game); @@ -518,8 +518,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); bool Found = false; - if (Val->IsNative()) { - CBScriptable *Obj = Val->GetNative(); + if (Val->isNative()) { + CBScriptable *Obj = Val->getNative(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i] == Obj) { Found = true; @@ -537,7 +537,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } } } else { - const char *attachmentName = Val->GetString(); + const char *attachmentName = Val->getString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { Found = true; @@ -568,8 +568,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); CAdObject *Ret = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); + if (Val->isInt()) { + int Index = Val->getInt(); int CurrIndex = 0; for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (CurrIndex == Index) Ret = _attachmentsPre[i]; @@ -580,7 +580,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CurrIndex++; } } else { - const char *attachmentName = Val->GetString(); + const char *attachmentName = Val->getString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { Ret = _attachmentsPre[i]; @@ -609,13 +609,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CAdObject::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("object"); + _scValue->setString("object"); return _scValue; } @@ -623,7 +623,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _scValue->SetBool(_active); + _scValue->setBool(_active); return _scValue; } @@ -631,7 +631,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // IgnoreItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IgnoreItems") == 0) { - _scValue->SetBool(_ignoreItems); + _scValue->setBool(_ignoreItems); return _scValue; } @@ -639,7 +639,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SceneIndependent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SceneIndependent") == 0) { - _scValue->SetBool(_sceneIndependent); + _scValue->setBool(_sceneIndependent); return _scValue; } @@ -647,7 +647,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesWidth") == 0) { - _scValue->SetInt(_subtitlesWidth); + _scValue->setInt(_subtitlesWidth); return _scValue; } @@ -655,7 +655,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _scValue->SetBool(_subtitlesModRelative); + _scValue->setBool(_subtitlesModRelative); return _scValue; } @@ -663,7 +663,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosX") == 0) { - _scValue->SetInt(_subtitlesModX); + _scValue->setInt(_subtitlesModX); return _scValue; } @@ -671,7 +671,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosY") == 0) { - _scValue->SetInt(_subtitlesModY); + _scValue->setInt(_subtitlesModY); return _scValue; } @@ -679,7 +679,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _scValue->SetBool(_subtitlesModXCenter); + _scValue->setBool(_subtitlesModXCenter); return _scValue; } @@ -687,7 +687,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // NumItems (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumItems") == 0) { - _scValue->SetInt(getInventory()->_takenItems.GetSize()); + _scValue->setInt(getInventory()->_takenItems.GetSize()); return _scValue; } @@ -695,8 +695,8 @@ CScValue *CAdObject::scGetProperty(const char *name) { // ParticleEmitter (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParticleEmitter") == 0) { - if (_partEmitter) _scValue->SetNative(_partEmitter, true); - else _scValue->SetNULL(); + if (_partEmitter) _scValue->setNative(_partEmitter, true); + else _scValue->setNULL(); return _scValue; } @@ -705,7 +705,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumAttachments") == 0) { - _scValue->SetInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); + _scValue->setInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); return _scValue; } @@ -721,7 +721,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { - _active = value->GetBool(); + _active = value->getBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // IgnoreItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IgnoreItems") == 0) { - _ignoreItems = value->GetBool(); + _ignoreItems = value->getBool(); return S_OK; } @@ -737,7 +737,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SceneIndependent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SceneIndependent") == 0) { - _sceneIndependent = value->GetBool(); + _sceneIndependent = value->getBool(); return S_OK; } @@ -745,7 +745,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesWidth") == 0) { - _subtitlesWidth = value->GetInt(); + _subtitlesWidth = value->getInt(); return S_OK; } @@ -753,7 +753,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _subtitlesModRelative = value->GetBool(); + _subtitlesModRelative = value->getBool(); return S_OK; } @@ -761,7 +761,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosX") == 0) { - _subtitlesModX = value->GetInt(); + _subtitlesModX = value->getInt(); return S_OK; } @@ -769,7 +769,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosY") == 0) { - _subtitlesModY = value->GetInt(); + _subtitlesModY = value->getInt(); return S_OK; } @@ -777,7 +777,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _subtitlesModXCenter = value->GetBool(); + _subtitlesModXCenter = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 42730b2567..9522ebbb61 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -226,8 +226,8 @@ HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SkipTo")==0) { stack->correctParams(2); - _posX = stack->pop()->GetInt(); - _posY = stack->pop()->GetInt(); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); stack->pushNULL(); return S_OK; @@ -239,13 +239,13 @@ HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CAdRegion::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("ad region"); + _scValue->setString("ad region"); return _scValue; } @@ -253,7 +253,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } @@ -261,7 +261,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { // Blocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Blocked") == 0) { - _scValue->SetBool(_blocked); + _scValue->setBool(_blocked); return _scValue; } @@ -269,7 +269,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _scValue->SetBool(_decoration); + _scValue->setBool(_decoration); return _scValue; } @@ -277,7 +277,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - _scValue->SetFloat(_zoom); + _scValue->setFloat(_zoom); return _scValue; } @@ -285,7 +285,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _scValue->SetInt((int)_alpha); + _scValue->setInt((int)_alpha); return _scValue; } @@ -299,7 +299,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -307,7 +307,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { // Blocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Blocked") == 0) { - _blocked = value->GetBool(); + _blocked = value->getBool(); return S_OK; } @@ -315,7 +315,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _decoration = value->GetBool(); + _decoration = value->getBool(); return S_OK; } @@ -323,7 +323,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - _zoom = value->GetFloat(); + _zoom = value->getFloat(); return S_OK; } @@ -331,7 +331,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->GetInt(); + _alpha = (uint32)value->getInt(); return S_OK; } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f567a8b058..04d3887f6c 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1255,7 +1255,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) { + if (act && SUCCEEDED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); } else { @@ -1272,7 +1272,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) { + if (ent && SUCCEEDED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); } else { @@ -1292,7 +1292,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CAdEntity *Ent = new CAdEntity(Game); addObject(Ent); - if (!Val->IsNULL()) Ent->setName(Val->GetString()); + if (!Val->isNULL()) Ent->setName(Val->getString()); stack->pushNative(Ent, true); return S_OK; } @@ -1303,9 +1303,9 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->GetNative(); + CAdObject *obj = (CAdObject *)val->getNative(); removeObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); return S_OK; @@ -1318,10 +1318,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(2); CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); - if (val1->IsNative()) { - skipToObject((CBObject *)val1->GetNative()); + if (val1->isNative()) { + skipToObject((CBObject *)val1->getNative()); } else { - skipTo(val1->GetInt(), val2->GetInt()); + skipTo(val1->getInt(), val2->getInt()); } stack->pushNULL(); return S_OK; @@ -1334,10 +1334,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(2); CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); - if (val1->IsNative()) { - scrollToObject((CBObject *)val1->GetNative()); + if (val1->isNative()) { + scrollToObject((CBObject *)val1->getNative()); } else { - scrollTo(val1->GetInt(), val2->GetInt()); + scrollTo(val1->getInt(), val2->getInt()); } if (strcmp(name, "ScrollTo") == 0) script->WaitForExclusive(this); stack->pushNULL(); @@ -1350,12 +1350,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetLayer") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - if (val->IsInt()) { - int layer = val->GetInt(); + if (val->isInt()) { + int layer = val->getInt(); if (layer < 0 || layer >= _layers.GetSize()) stack->pushNULL(); else stack->pushNative(_layers[layer], true); } else { - const char *LayerName = val->GetString(); + const char *LayerName = val->getString(); bool LayerFound = false; for (int i = 0; i < _layers.GetSize(); i++) { if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { @@ -1374,7 +1374,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaypointGroup") == 0) { stack->correctParams(1); - int group = stack->pop()->GetInt(); + int group = stack->pop()->getInt(); if (group < 0 || group >= _waypointGroups.GetSize()) stack->pushNULL(); else stack->pushNative(_waypointGroups[group], true); return S_OK; @@ -1385,7 +1385,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetNode") == 0) { stack->correctParams(1); - const char *nodeName = stack->pop()->GetString(); + const char *nodeName = stack->pop()->getString(); CBObject *node = getNodeByName(nodeName); if (node) stack->pushNative((CBScriptable *)node, true); @@ -1402,11 +1402,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *Val = stack->pop(); CAdObject *Ret = NULL; - if (Val->IsInt()) { - int Index = Val->GetInt(); + if (Val->isInt()) { + int Index = Val->getInt(); if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; } else { - const char *nodeName = Val->GetString(); + const char *nodeName = Val->getString(); for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { Ret = _objects[i]; @@ -1425,12 +1425,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRegionAt") == 0) { stack->correctParams(3); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); CScValue *Val = stack->pop(); bool IncludeDecors = false; - if (!Val->IsNULL()) IncludeDecors = Val->GetBool(); + if (!Val->isNULL()) IncludeDecors = Val->getBool(); if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { @@ -1452,8 +1452,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsBlockedAt") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); stack->pushBool(isBlockedAt(X, Y)); return S_OK; @@ -1464,8 +1464,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsWalkableAt") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); stack->pushBool(isWalkableAt(X, Y)); return S_OK; @@ -1476,8 +1476,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetScaleAt") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); stack->pushFloat(getZoomAt(X, Y)); return S_OK; @@ -1488,8 +1488,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRotationAt") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); stack->pushFloat(getRotationAt(X, Y)); return S_OK; @@ -1514,11 +1514,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->GetInt(500); - byte Red = stack->pop()->GetInt(0); - byte Green = stack->pop()->GetInt(0); - byte Blue = stack->pop()->GetInt(0); - byte Alpha = stack->pop()->GetInt(0xFF); + uint32 Duration = stack->pop()->getInt(500); + byte Red = stack->pop()->getInt(0); + byte Green = stack->pop()->getInt(0); + byte Blue = stack->pop()->getInt(0); + byte Alpha = stack->pop()->getInt(0xFF); _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader); @@ -1532,11 +1532,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->GetInt(500); - byte Red = stack->pop()->GetInt(0); - byte Green = stack->pop()->GetInt(0); - byte Blue = stack->pop()->GetInt(0); - byte Alpha = stack->pop()->GetInt(0xFF); + uint32 Duration = stack->pop()->getInt(500); + byte Red = stack->pop()->getInt(0); + byte Green = stack->pop()->getInt(0); + byte Blue = stack->pop()->getInt(0); + byte Alpha = stack->pop()->getInt(0xFF); _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader); @@ -1559,8 +1559,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsPointInViewport") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); stack->pushBool(pointInViewport(X, Y)); return S_OK; } @@ -1570,10 +1570,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetViewport") == 0) { stack->correctParams(4); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); - int Width = stack->pop()->GetInt(); - int Height = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + int Width = stack->pop()->getInt(); + int Height = stack->pop()->getInt(); if (Width <= 0) Width = Game->_renderer->_width; if (Height <= 0) Height = Game->_renderer->_height; @@ -1594,7 +1594,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *Val = stack->pop(); CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->setName(Val->GetString()); + if (!Val->isNULL()) Layer->setName(Val->getString()); if (_mainLayer) { Layer->_width = _mainLayer->_width; Layer->_height = _mainLayer->_height; @@ -1611,11 +1611,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertLayer") == 0) { stack->correctParams(2); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); CScValue *Val = stack->pop(); CAdLayer *Layer = new CAdLayer(Game); - if (!Val->IsNULL()) Layer->setName(Val->GetString()); + if (!Val->isNULL()) Layer->setName(Val->getString()); if (_mainLayer) { Layer->_width = _mainLayer->_width; Layer->_height = _mainLayer->_height; @@ -1638,8 +1638,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *Val = stack->pop(); CAdLayer *ToDelete = NULL; - if (Val->IsNative()) { - CBScriptable *Temp = Val->GetNative(); + if (Val->isNative()) { + CBScriptable *Temp = Val->getNative(); for (int i = 0; i < _layers.GetSize(); i++) { if (_layers[i] == Temp) { ToDelete = _layers[i]; @@ -1647,7 +1647,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } } else { - int Index = Val->GetInt(); + int Index = Val->getInt(); if (Index >= 0 && Index < _layers.GetSize()) { ToDelete = _layers[Index]; } @@ -1680,13 +1680,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CAdScene::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("scene"); + _scValue->setString("scene"); return _scValue; } @@ -1694,7 +1694,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLayers") == 0) { - _scValue->SetInt(_layers.GetSize()); + _scValue->setInt(_layers.GetSize()); return _scValue; } @@ -1702,7 +1702,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->SetInt(_waypointGroups.GetSize()); + _scValue->setInt(_waypointGroups.GetSize()); return _scValue; } @@ -1710,8 +1710,8 @@ CScValue *CAdScene::scGetProperty(const char *name) { // MainLayer (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainLayer") == 0) { - if (_mainLayer) _scValue->SetNative(_mainLayer, true); - else _scValue->SetNULL(); + if (_mainLayer) _scValue->setNative(_mainLayer, true); + else _scValue->setNULL(); return _scValue; } @@ -1720,7 +1720,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFreeNodes") == 0) { - _scValue->SetInt(_objects.GetSize()); + _scValue->setInt(_objects.GetSize()); return _scValue; } @@ -1731,7 +1731,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int ViewportX; getViewportOffset(&ViewportX); - _scValue->SetInt(Game->_mousePos.x + _offsetLeft - ViewportX); + _scValue->setInt(Game->_mousePos.x + _offsetLeft - ViewportX); return _scValue; } @@ -1742,7 +1742,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int ViewportY; getViewportOffset(NULL, &ViewportY); - _scValue->SetInt(Game->_mousePos.y + _offsetTop - ViewportY); + _scValue->setInt(Game->_mousePos.y + _offsetTop - ViewportY); return _scValue; } @@ -1750,7 +1750,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // AutoScroll ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoScroll") == 0) { - _scValue->SetBool(_autoScroll); + _scValue->setBool(_autoScroll); return _scValue; } @@ -1758,7 +1758,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // PersistentState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentState") == 0) { - _scValue->SetBool(_persistentState); + _scValue->setBool(_persistentState); return _scValue; } @@ -1766,7 +1766,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentStateSprites") == 0) { - _scValue->SetBool(_persistentStateSprites); + _scValue->setBool(_persistentStateSprites); return _scValue; } @@ -1774,7 +1774,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsX") == 0) { - _scValue->SetInt(_scrollPixelsH); + _scValue->setInt(_scrollPixelsH); return _scValue; } @@ -1782,7 +1782,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsY") == 0) { - _scValue->SetInt(_scrollPixelsV); + _scValue->setInt(_scrollPixelsV); return _scValue; } @@ -1791,7 +1791,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedX") == 0) { - _scValue->SetInt(_scrollTimeH); + _scValue->setInt(_scrollTimeH); return _scValue; } @@ -1799,7 +1799,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedY") == 0) { - _scValue->SetInt(_scrollTimeV); + _scValue->setInt(_scrollTimeV); return _scValue; } @@ -1807,7 +1807,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // OffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetX") == 0) { - _scValue->SetInt(_offsetLeft); + _scValue->setInt(_offsetLeft); return _scValue; } @@ -1815,7 +1815,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // OffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetY") == 0) { - _scValue->SetInt(_offsetTop); + _scValue->setInt(_offsetTop); return _scValue; } @@ -1823,8 +1823,8 @@ CScValue *CAdScene::scGetProperty(const char *name) { // Width (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - if (_mainLayer) _scValue->SetInt(_mainLayer->_width); - else _scValue->SetInt(0); + if (_mainLayer) _scValue->setInt(_mainLayer->_width); + else _scValue->setInt(0); return _scValue; } @@ -1832,8 +1832,8 @@ CScValue *CAdScene::scGetProperty(const char *name) { // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - if (_mainLayer) _scValue->SetInt(_mainLayer->_height); - else _scValue->SetInt(0); + if (_mainLayer) _scValue->setInt(_mainLayer->_height); + else _scValue->setInt(0); return _scValue; } @@ -1847,7 +1847,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -1855,7 +1855,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // AutoScroll ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoScroll") == 0) { - _autoScroll = value->GetBool(); + _autoScroll = value->getBool(); return S_OK; } @@ -1863,7 +1863,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // PersistentState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentState") == 0) { - _persistentState = value->GetBool(); + _persistentState = value->getBool(); return S_OK; } @@ -1871,7 +1871,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentStateSprites") == 0) { - _persistentStateSprites = value->GetBool(); + _persistentStateSprites = value->getBool(); return S_OK; } @@ -1879,7 +1879,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsX") == 0) { - _scrollPixelsH = value->GetInt(); + _scrollPixelsH = value->getInt(); return S_OK; } @@ -1887,7 +1887,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsY") == 0) { - _scrollPixelsV = value->GetInt(); + _scrollPixelsV = value->getInt(); return S_OK; } @@ -1895,7 +1895,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedX") == 0) { - _scrollTimeH = value->GetInt(); + _scrollTimeH = value->getInt(); return S_OK; } @@ -1903,7 +1903,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedY") == 0) { - _scrollTimeV = value->GetInt(); + _scrollTimeV = value->getInt(); return S_OK; } @@ -1911,7 +1911,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // OffsetX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetX") == 0) { - _offsetLeft = value->GetInt(); + _offsetLeft = value->getInt(); int ViewportWidth, ViewportHeight; getViewportSize(&ViewportWidth, &ViewportHeight); @@ -1927,7 +1927,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { // OffsetY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OffsetY") == 0) { - _offsetTop = value->GetInt(); + _offsetTop = value->getInt(); int ViewportWidth, ViewportHeight; getViewportSize(&ViewportWidth, &ViewportHeight); diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 67e225a444..4f5ad76880 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -133,12 +133,12 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack delete _sprite; _sprite = NULL; - if (Val->IsNULL()) { + if (Val->isNULL()) { _sprite = NULL; if (SetCurrent) _currentSprite = NULL; stack->pushBool(true); } else { - const char *Filename = Val->GetString(); + const char *Filename = Val->getString(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { script->RuntimeError("SetSprite method failed for file '%s'", Filename); @@ -180,8 +180,8 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "AddTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->GetString(); - bool Ex = stack->pop()->GetBool(); + const char *Filename = stack->pop()->getString(); + bool Ex = stack->pop()->getBool(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(Filename))) { @@ -201,8 +201,8 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "RemoveTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->GetString(); - bool Ex = stack->pop()->GetBool(); + const char *Filename = stack->pop()->getString(); + bool Ex = stack->pop()->getBool(); int i; bool SetCurrent = false; @@ -244,8 +244,8 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "SetTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->GetString(); - bool Ex = stack->pop()->GetBool(); + const char *Filename = stack->pop()->getString(); + bool Ex = stack->pop()->getBool(); bool SetCurrent = false; bool SetTemp2 = false; @@ -290,13 +290,13 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CAdTalkHolder::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("talk-holder"); + _scValue->setString("talk-holder"); return _scValue; } @@ -311,7 +311,7 @@ HRESULT CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { // Item ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Item")==0){ - SetItem(value->GetString()); + SetItem(value->getString()); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index f3dd9581b6..da21cf0ba6 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -201,13 +201,13 @@ HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// CScValue *CAdWaypointGroup::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("waypoint-group"); + _scValue->setString("waypoint-group"); return _scValue; } @@ -215,7 +215,7 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *name) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _scValue->SetBool(_active); + _scValue->setBool(_active); return _scValue; } @@ -229,7 +229,7 @@ HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { - _active = value->GetBool(); + _active = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 34b5ebbe47..3e034cc499 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -423,9 +423,9 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this delete _sound; _sound = NULL; - if (!Val->IsNULL()) { + if (!Val->isNULL()) { _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->setSound(Val->GetString(), SOUND_SFX, false))) { + if (!_sound || FAILED(_sound->setSound(Val->getString(), SOUND_SFX, false))) { stack->pushBool(false); delete _sound; _sound = NULL; @@ -439,7 +439,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); - int Index = stack->pop()->GetInt(-1); + int Index = stack->pop()->getInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); stack->pushNULL(); @@ -454,13 +454,13 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "DeleteSubframe") == 0) { stack->correctParams(1); CScValue *Val = stack->pop(); - if (Val->IsInt()) { - int Index = Val->GetInt(-1); + if (Val->isInt()) { + int Index = Val->getInt(-1); if (Index < 0 || Index >= _subframes.GetSize()) { script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); } } else { - CBSubFrame *Sub = (CBSubFrame *)Val->GetNative(); + CBSubFrame *Sub = (CBSubFrame *)Val->getNative(); for (int i = 0; i < _subframes.GetSize(); i++) { if (_subframes[i] == Sub) { delete _subframes[i]; @@ -480,7 +480,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CScValue *Val = stack->pop(); const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); + if (!Val->isNULL()) Filename = Val->getString(); CBSubFrame *Sub = new CBSubFrame(Game); if (Filename != NULL) { @@ -498,12 +498,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertSubframe") == 0) { stack->correctParams(2); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); if (Index < 0) Index = 0; CScValue *Val = stack->pop(); const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); + if (!Val->isNULL()) Filename = Val->getString(); CBSubFrame *Sub = new CBSubFrame(Game); if (Filename != NULL) { @@ -522,7 +522,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); - int Index = stack->pop()->GetInt(-1); + int Index = stack->pop()->getInt(-1); if (Index < 0 || Index >= _applyEvent.GetSize()) { script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); stack->pushNULL(); @@ -535,7 +535,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddEvent") == 0) { stack->correctParams(1); - const char *Event = stack->pop()->GetString(); + const char *Event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { stack->pushNULL(); @@ -552,7 +552,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteEvent") == 0) { stack->correctParams(1); - const char *Event = stack->pop()->GetString(); + const char *Event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], Event) == 0) { delete [] _applyEvent[i]; @@ -575,13 +575,13 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CBFrame::scGetProperty(const char *name) { if (!_scValue) _scValue = new CScValue(Game); - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("frame"); + _scValue->setString("frame"); return _scValue; } @@ -589,7 +589,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // Delay ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Delay") == 0) { - _scValue->SetInt(_delay); + _scValue->setInt(_delay); return _scValue; } @@ -597,7 +597,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // Keyframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyframe") == 0) { - _scValue->SetBool(_keyframe); + _scValue->setBool(_keyframe); return _scValue; } @@ -605,7 +605,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // KillSounds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "KillSounds") == 0) { - _scValue->SetBool(_killSound); + _scValue->setBool(_killSound); return _scValue; } @@ -613,7 +613,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // MoveX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveX") == 0) { - _scValue->SetInt(_moveX); + _scValue->setInt(_moveX); return _scValue; } @@ -621,7 +621,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // MoveY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveY") == 0) { - _scValue->SetInt(_moveY); + _scValue->setInt(_moveY); return _scValue; } @@ -629,7 +629,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumSubframes") == 0) { - _scValue->SetInt(_subframes.GetSize()); + _scValue->setInt(_subframes.GetSize()); return _scValue; } @@ -637,7 +637,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumEvents") == 0) { - _scValue->SetInt(_applyEvent.GetSize()); + _scValue->setInt(_applyEvent.GetSize()); return _scValue; } @@ -655,7 +655,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { // Delay ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, value->GetInt()); + _delay = MAX(0, value->getInt()); return S_OK; } @@ -663,7 +663,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { // Keyframe ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyframe") == 0) { - _keyframe = value->GetBool(); + _keyframe = value->getBool(); return S_OK; } @@ -671,7 +671,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { // KillSounds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "KillSounds") == 0) { - _killSound = value->GetBool(); + _killSound = value->getBool(); return S_OK; } @@ -679,7 +679,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { // MoveX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveX") == 0) { - _moveX = value->GetInt(); + _moveX = value->getInt(); return S_OK; } @@ -687,7 +687,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { // MoveY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveY") == 0) { - _moveY = value->GetInt(); + _moveY = value->getInt(); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 2c60521e54..93c063a3b3 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -983,7 +983,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LOG") == 0) { stack->correctParams(1); - LOG(0, stack->pop()->GetString()); + LOG(0, stack->pop()->getString()); stack->pushNULL(); return S_OK; } @@ -1002,7 +1002,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Msg") == 0) { stack->correctParams(1); - QuickMessage(stack->pop()->GetString()); + QuickMessage(stack->pop()->getString()); stack->pushNULL(); return S_OK; } @@ -1013,7 +1013,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "RunScript") == 0) { Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); stack->correctParams(1); - if (FAILED(addScript(stack->pop()->GetString()))) + if (FAILED(addScript(stack->pop()->getString()))) stack->pushBool(false); else stack->pushBool(true); @@ -1026,12 +1026,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadStringTable") == 0) { stack->correctParams(2); - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); CScValue *Val = stack->pop(); bool ClearOld; - if (Val->IsNULL()) ClearOld = true; - else ClearOld = Val->GetBool(); + if (Val->isNULL()) ClearOld = true; + else ClearOld = Val->getBool(); if (FAILED(_stringTable->loadFile(filename, ClearOld))) stack->pushBool(false); @@ -1046,7 +1046,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->GetNative(); + CBScriptable *obj = stack->pop()->getNative(); if (ValidObject((CBObject *) obj)) stack->pushBool(true); else stack->pushBool(false); @@ -1071,9 +1071,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "UnloadObject") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->GetNative(); + CBObject *obj = (CBObject *)val->getNative(); UnregisterObject(obj); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); return S_OK; @@ -1085,7 +1085,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "LoadWindow") == 0) { stack->correctParams(1); CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->loadFile(stack->pop()->GetString()))) { + if (win && SUCCEEDED(win->loadFile(stack->pop()->getString()))) { _windows.Add(win); RegisterObject(win); stack->pushNative(win, true); @@ -1103,8 +1103,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "ExpandString") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - char *str = new char[strlen(val->GetString()) + 1]; - strcpy(str, val->GetString()); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); _stringTable->Expand(&str); stack->pushString(str); delete [] str; @@ -1119,15 +1119,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); else { stack->correctParams(4); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); CScValue *ValLooping = stack->pop(); - bool Looping = ValLooping->IsNULL() ? true : ValLooping->GetBool(); + bool Looping = ValLooping->isNULL() ? true : ValLooping->getBool(); CScValue *ValLoopStart = stack->pop(); - uint32 LoopStart = (uint32)(ValLoopStart->IsNULL() ? 0 : ValLoopStart->GetInt()); + uint32 LoopStart = (uint32)(ValLoopStart->isNULL() ? 0 : ValLoopStart->getInt()); if (FAILED(PlayMusic(channel, filename, Looping, LoopStart))) stack->pushBool(false); @@ -1144,7 +1144,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (FAILED(StopMusic(channel))) stack->pushBool(false); @@ -1161,7 +1161,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (FAILED(PauseMusic(channel))) stack->pushBool(false); @@ -1177,7 +1177,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (FAILED(ResumeMusic(channel))) stack->pushBool(false); @@ -1193,7 +1193,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); else { @@ -1211,10 +1211,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); else { stack->correctParams(2); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } - uint32 Time = stack->pop()->GetInt(); + uint32 Time = stack->pop()->getInt(); if (FAILED(SetMusicStartTime(channel, Time))) stack->pushBool(false); else stack->pushBool(true); @@ -1230,7 +1230,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); @@ -1246,7 +1246,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); @@ -1262,10 +1262,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); else { stack->correctParams(2); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } - int Volume = stack->pop()->GetInt(); + int Volume = stack->pop()->getInt(); if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else { if (FAILED(_music[channel]->setVolume(Volume))) stack->pushBool(false); @@ -1282,7 +1282,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); else { stack->correctParams(1); - channel = stack->pop()->GetInt(); + channel = stack->pop()->getInt(); } if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); @@ -1296,10 +1296,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicCrossfade") == 0) { stack->correctParams(4); - int channel1 = stack->pop()->GetInt(0); - int channel2 = stack->pop()->GetInt(0); - uint32 FadeLength = (uint32)stack->pop()->GetInt(0); - bool Swap = stack->pop()->GetBool(true); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 FadeLength = (uint32)stack->pop()->getInt(0); + bool Swap = stack->pop()->getBool(true); if (_musicCrossfadeRunning) { script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); @@ -1326,7 +1326,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); int Length = 0; - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); CBSound *Sound = new CBSound(Game); if (Sound && SUCCEEDED(Sound->setSound(filename, SOUND_MUSIC, true))) { @@ -1343,8 +1343,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMousePos") == 0) { stack->correctParams(2); - int x = stack->pop()->GetInt(); - int y = stack->pop()->GetInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); x = MAX(x, 0); x = MIN(x, _renderer->_width); y = MAX(y, 0); @@ -1364,10 +1364,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LockMouseRect") == 0) { stack->correctParams(4); - int left = stack->pop()->GetInt(); - int top = stack->pop()->GetInt(); - int right = stack->pop()->GetInt(); - int bottom = stack->pop()->GetInt(); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); if (right < left) CBUtils::Swap(&left, &right); if (bottom < top) CBUtils::Swap(&top, &bottom); @@ -1392,19 +1392,19 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); stack->correctParams(6); - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); warning("PlayVideo: %s - not implemented yet", filename); CScValue *valType = stack->pop(); int Type; - if (valType->IsNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->GetInt(); + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->getInt(); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); - bool FreezeMusic = stack->pop()->GetBool(true); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; @@ -1430,20 +1430,20 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // TODO: ADDVIDEO stack->correctParams(7); - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); CScValue *valType = stack->pop(); int Type; - if (valType->IsNULL()) + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->GetInt(); + else Type = valType->getInt(); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); - bool FreezeMusic = stack->pop()->GetBool(true); - bool DropFrames = stack->pop()->GetBool(true); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); + bool DropFrames = stack->pop()->getBool(true); CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->IsNULL() ? NULL : valSub->GetString(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; @@ -1479,8 +1479,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteNumber") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->GetString(); - int Val = stack->pop()->GetInt(); + const char *Key = stack->pop()->getString(); + int Val = stack->pop()->getInt(); _registry->WriteInt("PrivateSettings", Key, Val); stack->pushNULL(); return S_OK; @@ -1491,8 +1491,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadNumber") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->GetString(); - int InitVal = stack->pop()->GetInt(); + const char *Key = stack->pop()->getString(); + int InitVal = stack->pop()->getInt(); stack->pushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); return S_OK; } @@ -1502,8 +1502,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteString") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->GetString(); - const char *Val = stack->pop()->GetString(); + const char *Key = stack->pop()->getString(); + const char *Val = stack->pop()->getString(); _registry->WriteString("PrivateSettings", Key, Val); stack->pushNULL(); return S_OK; @@ -1514,8 +1514,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadString") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->GetString(); - const char *InitVal = stack->pop()->GetString(); + const char *Key = stack->pop()->getString(); + const char *InitVal = stack->pop()->getString(); AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); stack->pushString(val.c_str()); return S_OK; @@ -1526,9 +1526,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveGame") == 0) { stack->correctParams(3); - int Slot = stack->pop()->GetInt(); - const char *xdesc = stack->pop()->GetString(); - bool quick = stack->pop()->GetBool(false); + int Slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); char *Desc = new char[strlen(xdesc) + 1]; strcpy(Desc, xdesc); @@ -1546,7 +1546,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadGame") == 0) { stack->correctParams(1); - _scheduledLoadSlot = stack->pop()->GetInt(); + _scheduledLoadSlot = stack->pop()->getInt(); _loading = true; stack->pushBool(false); script->Sleep(0); @@ -1558,7 +1558,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); - int Slot = stack->pop()->GetInt(); + int Slot = stack->pop()->getInt(); stack->pushBool(IsSaveSlotUsed(Slot)); return S_OK; } @@ -1568,7 +1568,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSaveSlotDescription") == 0) { stack->correctParams(1); - int Slot = stack->pop()->GetInt(); + int Slot = stack->pop()->getInt(); char Desc[512]; Desc[0] = '\0'; GetSaveSlotDescription(Slot, Desc); @@ -1581,7 +1581,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmptySaveSlot") == 0) { stack->correctParams(1); - int Slot = stack->pop()->GetInt(); + int Slot = stack->pop()->getInt(); EmptySaveSlot(Slot); stack->pushNULL(); return S_OK; @@ -1592,7 +1592,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSFXVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->pop()->getInt()); stack->pushNULL(); return S_OK; } @@ -1602,7 +1602,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->pop()->getInt()); stack->pushNULL(); return S_OK; } @@ -1612,7 +1612,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMusicVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->pop()->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->pop()->getInt()); stack->pushNULL(); return S_OK; } @@ -1622,7 +1622,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMasterVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); stack->pushNULL(); return S_OK; } @@ -1668,7 +1668,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetActiveCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(setActiveCursor(stack->pop()->GetString()))) stack->pushBool(true); + if (SUCCEEDED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); return S_OK; @@ -1725,7 +1725,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FileExists") == 0) { stack->correctParams(1); - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); Common::SeekableReadStream *File = _fileManager->openFile(filename, false); if (!File) stack->pushBool(false); @@ -1741,11 +1741,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->GetInt(500); - byte Red = stack->pop()->GetInt(0); - byte Green = stack->pop()->GetInt(0); - byte Blue = stack->pop()->GetInt(0); - byte Alpha = stack->pop()->GetInt(0xFF); + uint32 Duration = stack->pop()->getInt(500); + byte Red = stack->pop()->getInt(0); + byte Green = stack->pop()->getInt(0); + byte Blue = stack->pop()->getInt(0); + byte Alpha = stack->pop()->getInt(0xFF); bool System = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); @@ -1761,11 +1761,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->GetInt(500); - byte Red = stack->pop()->GetInt(0); - byte Green = stack->pop()->GetInt(0); - byte Blue = stack->pop()->GetInt(0); - byte Alpha = stack->pop()->GetInt(0xFF); + uint32 Duration = stack->pop()->getInt(500); + byte Red = stack->pop()->getInt(0); + byte Green = stack->pop()->getInt(0); + byte Blue = stack->pop()->getInt(0); + byte Alpha = stack->pop()->getInt(0xFF); bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); @@ -1798,7 +1798,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int FileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum); + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), FileNum); if (!Common::File::exists(filename)) break; FileNum++; @@ -1820,9 +1820,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScreenshotEx") == 0) { stack->correctParams(3); - const char *filename = stack->pop()->GetString(); - int SizeX = stack->pop()->GetInt(_renderer->_width); - int SizeY = stack->pop()->GetInt(_renderer->_height); + const char *filename = stack->pop()->getString(); + int SizeX = stack->pop()->getInt(_renderer->_width); + int SizeY = stack->pop()->getInt(_renderer->_height); bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); @@ -1846,7 +1846,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CUIWindow *Win = new CUIWindow(Game); _windows.Add(Win); RegisterObject(Win); - if (!Val->IsNULL()) Win->setName(Val->GetString()); + if (!Val->isNULL()) Win->setName(Val->getString()); stack->pushNative(Win, true); return S_OK; } @@ -1856,7 +1856,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); - CBObject *Obj = (CBObject *)stack->pop()->GetNative(); + CBObject *Obj = (CBObject *)stack->pop()->getNative(); for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i] == Obj) { UnregisterObject(_windows[i]); @@ -1893,14 +1893,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); CScValue *Val = stack->pop(); - _loadImageX = stack->pop()->GetInt(); - _loadImageY = stack->pop()->GetInt(); + _loadImageX = stack->pop()->getInt(); + _loadImageY = stack->pop()->getInt(); - if (Val->IsNULL()) { + if (Val->isNULL()) { delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::SetString(&_loadImageName, Val->GetString()); + CBUtils::SetString(&_loadImageName, Val->getString()); } stack->pushNULL(); return S_OK; @@ -1912,14 +1912,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); CScValue *Val = stack->pop(); - _saveImageX = stack->pop()->GetInt(); - _saveImageY = stack->pop()->GetInt(); + _saveImageX = stack->pop()->getInt(); + _saveImageY = stack->pop()->getInt(); - if (Val->IsNULL()) { + if (Val->isNULL()) { delete[] _saveImageName; _saveImageName = NULL; } else { - CBUtils::SetString(&_saveImageName, Val->GetString()); + CBUtils::SetString(&_saveImageName, Val->getString()); } stack->pushNULL(); return S_OK; @@ -1930,7 +1930,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(SetWaitCursor(stack->pop()->GetString()))) stack->pushBool(true); + if (SUCCEEDED(SetWaitCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); return S_OK; @@ -1986,10 +1986,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "DisplayLoadingIcon") == 0) { stack->correctParams(4); - const char *filename = stack->pop()->GetString(); - _loadingIconX = stack->pop()->GetInt(); - _loadingIconY = stack->pop()->GetInt(); - _loadingIconPersistent = stack->pop()->GetBool(); + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); delete _loadingIcon; _loadingIcon = new CBSprite(this); @@ -2022,7 +2022,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DumpTextureStats") == 0) { stack->correctParams(1); - const char *filename = stack->pop()->GetString(); + const char *filename = stack->pop()->getString(); _renderer->dumpData(filename); @@ -2036,9 +2036,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "AccOutputText") == 0) { stack->correctParams(2); /* const char *Str = */ - stack->pop()->GetString(); + stack->pop()->getString(); /* int Type = */ - stack->pop()->GetInt(); + stack->pop()->getInt(); // do nothing stack->pushNULL(); @@ -2078,8 +2078,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFileChecksum") == 0) { stack->correctParams(2); - const char *filename = stack->pop()->GetString(); - bool AsHex = stack->pop()->GetBool(false); + const char *filename = stack->pop()->getString(); + bool AsHex = stack->pop()->getBool(false); Common::SeekableReadStream *File = _fileManager->openFile(filename, false); if (File) { @@ -2165,27 +2165,27 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// CScValue *CBGame::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("game"); + _scValue->setString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Hwnd (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Hwnd") == 0) { - _scValue->SetInt((int)_renderer->_window); + _scValue->setInt((int)_renderer->_window); return _scValue; } @@ -2193,7 +2193,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // CurrentTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CurrentTime") == 0) { - _scValue->SetInt((int)_timer); + _scValue->setInt((int)_timer); return _scValue; } @@ -2201,7 +2201,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->SetInt((int)CBPlatform::GetTime()); + _scValue->setInt((int)CBPlatform::GetTime()); return _scValue; } @@ -2209,7 +2209,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // WindowedMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowedMode") == 0) { - _scValue->SetBool(_renderer->_windowed); + _scValue->setBool(_renderer->_windowed); return _scValue; } @@ -2217,7 +2217,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MouseX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseX") == 0) { - _scValue->SetInt(_mousePos.x); + _scValue->setInt(_mousePos.x); return _scValue; } @@ -2225,7 +2225,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MouseY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseY") == 0) { - _scValue->SetInt(_mousePos.y); + _scValue->setInt(_mousePos.y); return _scValue; } @@ -2233,7 +2233,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { - _scValue->SetNative(_mainObject, true); + _scValue->setNative(_mainObject, true); return _scValue; } @@ -2241,7 +2241,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // ActiveObject (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ActiveObject") == 0) { - _scValue->SetNative(_activeObject, true); + _scValue->setNative(_activeObject, true); return _scValue; } @@ -2249,7 +2249,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // ScreenWidth (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScreenWidth") == 0) { - _scValue->SetInt(_renderer->_width); + _scValue->setInt(_renderer->_width); return _scValue; } @@ -2257,7 +2257,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // ScreenHeight (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScreenHeight") == 0) { - _scValue->SetInt(_renderer->_height); + _scValue->setInt(_renderer->_height); return _scValue; } @@ -2265,7 +2265,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Interactive") == 0) { - _scValue->SetBool(_interactive); + _scValue->setBool(_interactive); return _scValue; } @@ -2273,7 +2273,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DebugMode") == 0) { - _scValue->SetBool(_dEBUG_DebugMode); + _scValue->setBool(_dEBUG_DebugMode); return _scValue; } @@ -2281,7 +2281,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SoundAvailable (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundAvailable") == 0) { - _scValue->SetBool(_soundMgr->_soundAvailable); + _scValue->setBool(_soundMgr->_soundAvailable); return _scValue; } @@ -2290,7 +2290,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SFX)); + _scValue->setInt(_soundMgr->getVolumePercent(SOUND_SFX)); return _scValue; } @@ -2299,7 +2299,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + _scValue->setInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); return _scValue; } @@ -2308,7 +2308,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + _scValue->setInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); return _scValue; } @@ -2317,7 +2317,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->SetInt(_soundMgr->getMasterVolumePercent()); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); return _scValue; } @@ -2325,8 +2325,8 @@ CScValue *CBGame::scGetProperty(const char *name) { // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->SetNative(_keyboardState, true); - else _scValue->SetNULL(); + if (_keyboardState) _scValue->setNative(_keyboardState, true); + else _scValue->setNULL(); return _scValue; } @@ -2335,7 +2335,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Subtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtitles") == 0) { - _scValue->SetBool(_subtitles); + _scValue->setBool(_subtitles); return _scValue; } @@ -2343,14 +2343,14 @@ CScValue *CBGame::scGetProperty(const char *name) { // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesSpeed") == 0) { - _scValue->SetInt(_subtitlesSpeed); + _scValue->setInt(_subtitlesSpeed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VideoSubtitles") == 0) { - _scValue->SetBool(_videoSubtitles); + _scValue->setBool(_videoSubtitles); return _scValue; } @@ -2358,7 +2358,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // FPS (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FPS") == 0) { - _scValue->SetInt(_fps); + _scValue->setInt(_fps); return _scValue; } @@ -2366,7 +2366,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AcceleratedMode / Accelerated (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { - _scValue->SetBool(_useD3D); + _scValue->setBool(_useD3D); return _scValue; } @@ -2374,7 +2374,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextEncoding") == 0) { - _scValue->SetInt(_textEncoding); + _scValue->setInt(_textEncoding); return _scValue; } @@ -2382,7 +2382,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // TextRTL ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextRTL") == 0) { - _scValue->SetBool(_textRTL); + _scValue->setBool(_textRTL); return _scValue; } @@ -2390,7 +2390,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SoundBufferSize ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundBufferSize") == 0) { - _scValue->SetInt(_soundBufferSizeSec); + _scValue->setInt(_soundBufferSizeSec); return _scValue; } @@ -2398,7 +2398,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SuspendedRendering ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuspendedRendering") == 0) { - _scValue->SetBool(_suspendedRendering); + _scValue->setBool(_suspendedRendering); return _scValue; } @@ -2406,7 +2406,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuppressScriptErrors") == 0) { - _scValue->SetBool(_suppressScriptErrors); + _scValue->setBool(_suppressScriptErrors); return _scValue; } @@ -2415,7 +2415,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Frozen ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Frozen") == 0) { - _scValue->SetBool(_state == GAME_FROZEN); + _scValue->setBool(_state == GAME_FROZEN); return _scValue; } @@ -2423,7 +2423,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccTTSEnabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccTTSEnabled") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2431,7 +2431,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccTTSTalk ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccTTSTalk") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2439,7 +2439,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccTTSCaptions ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccTTSCaptions") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2447,7 +2447,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccTTSKeypress ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccTTSKeypress") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2455,7 +2455,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccKeyboardEnabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccKeyboardEnabled") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2463,7 +2463,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccKeyboardCursorSkip ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2471,7 +2471,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AccKeyboardPause ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccKeyboardPause") == 0) { - _scValue->SetBool(false); + _scValue->setBool(false); return _scValue; } @@ -2479,7 +2479,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AutorunDisabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutorunDisabled") == 0) { - _scValue->SetBool(_autorunDisabled); + _scValue->setBool(_autorunDisabled); return _scValue; } @@ -2488,7 +2488,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveDirectory") == 0) { AnsiString dataDir = GetDataDir(); - _scValue->SetString(dataDir.c_str()); + _scValue->setString(dataDir.c_str()); return _scValue; } @@ -2496,7 +2496,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveOnExit") == 0) { - _scValue->SetBool(_autoSaveOnExit); + _scValue->setBool(_autoSaveOnExit); return _scValue; } @@ -2504,7 +2504,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveSlot") == 0) { - _scValue->SetInt(_autoSaveSlot); + _scValue->setInt(_autoSaveSlot); return _scValue; } @@ -2512,7 +2512,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // CursorHidden ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorHidden") == 0) { - _scValue->SetBool(_cursorHidden); + _scValue->setBool(_cursorHidden); return _scValue; } @@ -2520,7 +2520,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Platform (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Platform") == 0) { - _scValue->SetString(CBPlatform::GetPlatformName().c_str()); + _scValue->setString(CBPlatform::GetPlatformName().c_str()); return _scValue; } @@ -2528,7 +2528,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeviceType") == 0) { - _scValue->SetString(GetDeviceType().c_str()); + _scValue->setString(GetDeviceType().c_str()); return _scValue; } @@ -2536,7 +2536,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->SetInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -2544,8 +2544,8 @@ CScValue *CBGame::scGetProperty(const char *name) { // Store (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Store") == 0) { - if (_store) _scValue->SetNative(_store, true); - else _scValue->SetNULL(); + if (_store) _scValue->setNative(_store, true); + else _scValue->setNULL(); return _scValue; } @@ -2560,7 +2560,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -2569,7 +2569,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // MouseX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = value->GetInt(); + _mousePos.x = value->getInt(); ResetMousePos(); return S_OK; } @@ -2578,7 +2578,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // MouseY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = value->GetInt(); + _mousePos.y = value->getInt(); ResetMousePos(); return S_OK; } @@ -2596,7 +2596,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->GetNative(); + CBScriptable *obj = value->getNative(); if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; return S_OK; } @@ -2605,7 +2605,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Interactive") == 0) { - SetInteractive(value->GetBool()); + SetInteractive(value->getBool()); return S_OK; } @@ -2614,7 +2614,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)value->getInt()); return S_OK; } @@ -2623,7 +2623,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)value->getInt()); return S_OK; } @@ -2632,7 +2632,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)value->GetInt()); + Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)value->getInt()); return S_OK; } @@ -2641,7 +2641,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->setMasterVolumePercent((byte)value->GetInt()); + Game->_soundMgr->setMasterVolumePercent((byte)value->getInt()); return S_OK; } @@ -2649,7 +2649,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // Subtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtitles") == 0) { - _subtitles = value->GetBool(); + _subtitles = value->getBool(); return S_OK; } @@ -2657,7 +2657,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = value->GetInt(); + _subtitlesSpeed = value->getInt(); return S_OK; } @@ -2665,7 +2665,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // VideoSubtitles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = value->GetBool(); + _videoSubtitles = value->getBool(); return S_OK; } @@ -2673,7 +2673,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->GetInt(); + int Enc = value->getInt(); if (Enc < 0) Enc = 0; if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; _textEncoding = (TTextEncoding)Enc; @@ -2684,7 +2684,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // TextRTL ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextRTL") == 0) { - _textRTL = value->GetBool(); + _textRTL = value->getBool(); return S_OK; } @@ -2692,7 +2692,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // SoundBufferSize ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = value->GetInt(); + _soundBufferSizeSec = value->getInt(); _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); return S_OK; } @@ -2701,7 +2701,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // SuspendedRendering ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = value->GetBool(); + _suspendedRendering = value->getBool(); return S_OK; } @@ -2709,7 +2709,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = value->GetBool(); + _suppressScriptErrors = value->getBool(); return S_OK; } @@ -2717,7 +2717,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // AutorunDisabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = value->GetBool(); + _autorunDisabled = value->getBool(); return S_OK; } @@ -2725,7 +2725,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = value->GetBool(); + _autoSaveOnExit = value->getBool(); return S_OK; } @@ -2733,7 +2733,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = value->GetInt(); + _autoSaveSlot = value->getInt(); return S_OK; } @@ -2741,7 +2741,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // CursorHidden ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = value->GetBool(); + _cursorHidden = value->getBool(); return S_OK; } @@ -2857,12 +2857,12 @@ HRESULT CBGame::UnregisterObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// void CBGame::InvalidateValues(void *value, void *data) { CScValue *val = (CScValue *)value; - if (val->IsNative() && val->GetNative() == data) { + if (val->isNative() && val->getNative() == data) { if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { ((CBScriptable *)data)->_refCount++; } - val->SetNative(NULL); - val->SetNULL(); + val->setNative(NULL); + val->setNULL(); } } @@ -2932,7 +2932,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LOG") == 0) { stack->correctParams(1); - Game->LOG(0, "sc: %s", stack->pop()->GetString()); + Game->LOG(0, "sc: %s", stack->pop()->getString()); stack->pushNULL(); } @@ -2942,7 +2942,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "String") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXString(Game, stack)); + this_obj->setNative(makeSXString(Game, stack)); stack->pushNULL(); } @@ -2952,7 +2952,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "MemBuffer") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXMemBuffer(Game, stack)); + this_obj->setNative(makeSXMemBuffer(Game, stack)); stack->pushNULL(); } @@ -2962,7 +2962,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "File") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXFile(Game, stack)); + this_obj->setNative(makeSXFile(Game, stack)); stack->pushNULL(); } @@ -2972,7 +2972,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Date") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXDate(Game, stack)); + this_obj->setNative(makeSXDate(Game, stack)); stack->pushNULL(); } @@ -2982,7 +2982,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Array") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXArray(Game, stack)); + this_obj->setNative(makeSXArray(Game, stack)); stack->pushNULL(); } @@ -2992,7 +2992,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Object") == 0) { this_obj = thisStack->getTop(); - this_obj->SetNative(makeSXObject(Game, stack)); + this_obj->setNative(makeSXObject(Game, stack)); stack->pushNULL(); } @@ -3002,7 +3002,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Sleep") == 0) { stack->correctParams(1); - script->Sleep((uint32)stack->pop()->GetInt()); + script->Sleep((uint32)stack->pop()->getInt()); stack->pushNULL(); } @@ -3012,7 +3012,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "WaitFor") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->GetNative(); + CBScriptable *obj = stack->pop()->getNative(); if (ValidObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); stack->pushNULL(); } @@ -3023,8 +3023,8 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Random") == 0) { stack->correctParams(2); - int from = stack->pop()->GetInt(); - int to = stack->pop()->GetInt(); + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); stack->pushInt(CBUtils::RandomInt(from, to)); } @@ -3035,7 +3035,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "SetScriptTimeSlice") == 0) { stack->correctParams(1); - script->_timeSlice = (uint32)stack->pop()->GetInt(); + script->_timeSlice = (uint32)stack->pop()->getInt(); stack->pushNULL(); } @@ -3044,13 +3044,13 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { stack->correctParams(4); - int r = stack->pop()->GetInt(); - int g = stack->pop()->GetInt(); - int b = stack->pop()->GetInt(); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); int a; CScValue *val = stack->pop(); - if (val->IsNULL()) a = 255; - else a = val->GetInt(); + if (val->isNULL()) a = 255; + else a = val->getInt(); stack->pushInt(DRGBA(r, g, b, a)); } @@ -3060,9 +3060,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MakeHSL") == 0) { stack->correctParams(3); - int h = stack->pop()->GetInt(); - int s = stack->pop()->GetInt(); - int l = stack->pop()->GetInt(); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); } @@ -3073,7 +3073,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetRValue") == 0) { stack->correctParams(1); - uint32 rgba = (uint32)stack->pop()->GetInt(); + uint32 rgba = (uint32)stack->pop()->getInt(); stack->pushInt(D3DCOLGetR(rgba)); } @@ -3083,7 +3083,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetGValue") == 0) { stack->correctParams(1); - uint32 rgba = (uint32)stack->pop()->GetInt(); + uint32 rgba = (uint32)stack->pop()->getInt(); stack->pushInt(D3DCOLGetG(rgba)); } @@ -3093,7 +3093,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetBValue") == 0) { stack->correctParams(1); - uint32 rgba = (uint32)stack->pop()->GetInt(); + uint32 rgba = (uint32)stack->pop()->getInt(); stack->pushInt(D3DCOLGetB(rgba)); } @@ -3103,7 +3103,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetAValue") == 0) { stack->correctParams(1); - uint32 rgba = (uint32)stack->pop()->GetInt(); + uint32 rgba = (uint32)stack->pop()->getInt(); stack->pushInt(D3DCOLGetA(rgba)); } @@ -3112,7 +3112,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHValue") == 0) { stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->GetInt(); + uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); @@ -3124,7 +3124,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSValue") == 0) { stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->GetInt(); + uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); @@ -3136,7 +3136,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetLValue") == 0) { stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->GetInt(); + uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; CBUtils::RGBtoHSL(rgb, &H, &S, &L); @@ -3161,7 +3161,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToString") == 0) { stack->correctParams(1); - const char *Str = stack->pop()->GetString(); + const char *Str = stack->pop()->getString(); char *Str2 = new char[strlen(Str) + 1]; strcpy(Str2, Str); stack->pushString(Str2); @@ -3173,7 +3173,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToInt") == 0) { stack->correctParams(1); - int Val = stack->pop()->GetInt(); + int Val = stack->pop()->getInt(); stack->pushInt(Val); } @@ -3182,7 +3182,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToFloat") == 0) { stack->correctParams(1); - double Val = stack->pop()->GetFloat(); + double Val = stack->pop()->getFloat(); stack->pushFloat(Val); } @@ -3191,7 +3191,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToBool") == 0) { stack->correctParams(1); - bool Val = stack->pop()->GetBool(); + bool Val = stack->pop()->getBool(); stack->pushBool(Val); } diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index a3f742fd69..94b015f5e9 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -82,12 +82,12 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta CScValue *val = stack->pop(); int vKey; - if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) { - const char *str = val->GetString(); + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); char temp = str[0]; if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); vKey = (int)temp; - } else vKey = val->GetInt(); + } else vKey = val->getInt(); warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; // Uint8 *state = SDL_GetKeyboardState(NULL); @@ -104,13 +104,13 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta ////////////////////////////////////////////////////////////////////////// CScValue *CBKeyboardState::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("keyboard"); + _scValue->setString("keyboard"); return _scValue; } @@ -122,8 +122,8 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { char key[2]; key[0] = (char)_currentCharCode; key[1] = '\0'; - _scValue->SetString(key); - } else _scValue->SetString(""); + _scValue->setString(key); + } else _scValue->setString(""); return _scValue; } @@ -132,7 +132,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { // Printable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Printable") == 0) { - _scValue->SetBool(_currentPrintable); + _scValue->setBool(_currentPrintable); return _scValue; } @@ -140,7 +140,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { // KeyCode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "KeyCode") == 0) { - _scValue->SetInt(_currentCharCode); + _scValue->setInt(_currentCharCode); return _scValue; } @@ -148,7 +148,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { // IsShift ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsShift") == 0) { - _scValue->SetBool(_currentShift); + _scValue->setBool(_currentShift); return _scValue; } @@ -156,7 +156,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { // IsAlt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsAlt") == 0) { - _scValue->SetBool(_currentAlt); + _scValue->setBool(_currentAlt); return _scValue; } @@ -164,7 +164,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { // IsControl ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsControl") == 0) { - _scValue->SetBool(_currentControl); + _scValue->setBool(_currentControl); return _scValue; } @@ -179,7 +179,7 @@ HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); if (_renderer) SetWindowText(_renderer->_window, _name); return S_OK; } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index c84b58eecd..ab30ce33b0 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -172,8 +172,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SkipTo") == 0) { stack->correctParams(2); - _posX = stack->pop()->GetInt(); - _posY = stack->pop()->GetInt(); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); afterMove(); stack->pushNULL(); @@ -185,7 +185,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { stack->correctParams(1); - stack->pushString(getCaption(stack->pop()->GetInt())); + stack->pushString(getCaption(stack->pop()->getInt())); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(setCursor(stack->pop()->GetString()))) stack->pushBool(true); + if (SUCCEEDED(setCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); return S_OK; @@ -257,7 +257,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCaption") == 0) { stack->correctParams(2); - setCaption(stack->pop()->GetString(), stack->pop()->GetInt()); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); stack->pushNULL(); return S_OK; @@ -268,7 +268,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (SUCCEEDED(playSFX(Filename, false, false))) stack->pushBool(true); else @@ -293,13 +293,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (val1->_type == VAL_BOOL) { Filename = NULL; - Looping = val1->GetBool(); - LoopStart = val2->GetInt(); + Looping = val1->getBool(); + LoopStart = val2->getInt(); } else { - if (val1->IsNULL()) Filename = NULL; - else Filename = val1->GetString(); - Looping = val2->IsNULL() ? false : val2->GetBool(); - LoopStart = val3->GetInt(); + if (val1->isNULL()) Filename = NULL; + else Filename = val1->getString(); + Looping = val2->isNULL() ? false : val2->getBool(); + LoopStart = val3->getInt(); } if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->pushBool(false); @@ -319,12 +319,12 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); - if (val2->IsNULL()) { + if (val2->isNULL()) { Filename = NULL; - EventName = val1->GetString(); + EventName = val1->getString(); } else { - Filename = val1->GetString(); - EventName = val2->GetString(); + Filename = val1->getString(); + EventName = val2->getString(); } if (FAILED(playSFX(Filename, false, true, EventName))) stack->pushBool(false); @@ -382,7 +382,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SetSoundPosition") == 0) { stack->correctParams(1); - uint32 Time = stack->pop()->GetInt(); + uint32 Time = stack->pop()->getInt(); if (FAILED(setSFXTime(Time))) stack->pushBool(false); else stack->pushBool(true); return S_OK; @@ -405,7 +405,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SetSoundVolume") == 0) { stack->correctParams(1); - int Volume = stack->pop()->GetInt(); + int Volume = stack->pop()->getInt(); if (FAILED(setSFXVolume(Volume))) stack->pushBool(false); else stack->pushBool(true); return S_OK; @@ -444,10 +444,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SoundFXEcho") == 0) { stack->correctParams(4); _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->pop()->GetFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000) + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) stack->pushNULL(); return S_OK; @@ -459,10 +459,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SoundFXReverb") == 0) { stack->correctParams(4); _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->pop()->GetFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) stack->pushNULL(); return S_OK; @@ -474,13 +474,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CBObject::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("object"); + _scValue->setString("object"); return _scValue; } @@ -488,7 +488,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - _scValue->SetString(getCaption(1)); + _scValue->setString(getCaption(1)); return _scValue; } @@ -496,7 +496,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "X") == 0) { - _scValue->SetInt(_posX); + _scValue->setInt(_posX); return _scValue; } @@ -504,7 +504,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _scValue->SetInt(_posY); + _scValue->setInt(_posY); return _scValue; } @@ -512,7 +512,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _scValue->SetInt(getHeight()); + _scValue->setInt(getHeight()); return _scValue; } @@ -520,7 +520,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Ready (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Ready") == 0) { - _scValue->SetBool(_ready); + _scValue->setBool(_ready); return _scValue; } @@ -528,7 +528,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Movable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Movable") == 0) { - _scValue->SetBool(_movable); + _scValue->setBool(_movable); return _scValue; } @@ -536,7 +536,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _scValue->SetBool(_registrable); + _scValue->setBool(_registrable); return _scValue; } @@ -544,21 +544,21 @@ CScValue *CBObject::scGetProperty(const char *name) { // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _scValue->SetBool(_zoomable); + _scValue->setBool(_zoomable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotatable") == 0) { - _scValue->SetBool(_rotatable); + _scValue->setBool(_rotatable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _scValue->SetInt((int)_alphaColor); + _scValue->setInt((int)_alphaColor); return _scValue; } @@ -566,7 +566,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // BlendMode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { - _scValue->SetInt((int)_blendMode); + _scValue->setInt((int)_blendMode); return _scValue; } @@ -574,8 +574,8 @@ CScValue *CBObject::scGetProperty(const char *name) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scale); + if (_scale < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scale); return _scValue; } @@ -583,8 +583,8 @@ CScValue *CBObject::scGetProperty(const char *name) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scaleX); + if (_scaleX < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleX); return _scValue; } @@ -592,8 +592,8 @@ CScValue *CBObject::scGetProperty(const char *name) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->SetNULL(); - else _scValue->SetFloat((double)_scaleY); + if (_scaleY < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleY); return _scValue; } @@ -601,7 +601,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // RelativeScale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeScale") == 0) { - _scValue->SetFloat((double)_relativeScale); + _scValue->setFloat((double)_relativeScale); return _scValue; } @@ -609,8 +609,8 @@ CScValue *CBObject::scGetProperty(const char *name) { // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->SetNULL(); - else _scValue->SetFloat((double)_rotate); + if (!_rotateValid) _scValue->setNULL(); + else _scValue->setFloat((double)_rotate); return _scValue; } @@ -618,7 +618,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // RelativeRotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeRotate") == 0) { - _scValue->SetFloat((double)_relativeRotate); + _scValue->setFloat((double)_relativeRotate); return _scValue; } @@ -626,14 +626,14 @@ CScValue *CBObject::scGetProperty(const char *name) { // Colorable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Colorable") == 0) { - _scValue->SetBool(_shadowable); + _scValue->setBool(_shadowable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundPanning") == 0) { - _scValue->SetBool(_autoSoundPanning); + _scValue->setBool(_autoSoundPanning); return _scValue; } @@ -641,7 +641,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // SaveState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveState") == 0) { - _scValue->SetBool(_saveState); + _scValue->setBool(_saveState); return _scValue; } @@ -649,7 +649,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NonIntMouseEvents") == 0) { - _scValue->SetBool(_nonIntMouseEvents); + _scValue->setBool(_nonIntMouseEvents); return _scValue; } @@ -657,7 +657,7 @@ CScValue *CBObject::scGetProperty(const char *name) { // AccCaption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccCaption") == 0) { - _scValue->SetNULL(); + _scValue->setNULL(); return _scValue; } @@ -671,7 +671,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Caption ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Caption") == 0) { - setCaption(value->GetString()); + setCaption(value->getString()); return S_OK; } @@ -679,7 +679,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "X") == 0) { - _posX = value->GetInt(); + _posX = value->getInt(); afterMove(); return S_OK; } @@ -688,7 +688,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _posY = value->GetInt(); + _posY = value->getInt(); afterMove(); return S_OK; } @@ -697,7 +697,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Movable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Movable") == 0) { - _movable = value->GetBool(); + _movable = value->getBool(); return S_OK; } @@ -705,7 +705,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = value->GetBool(); + _registrable = value->getBool(); return S_OK; } @@ -713,7 +713,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = value->GetBool(); + _zoomable = value->getBool(); return S_OK; } @@ -721,7 +721,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Rotatable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotatable") == 0) { - _rotatable = value->GetBool(); + _rotatable = value->getBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)value->GetInt(); + _alphaColor = (uint32)value->getInt(); return S_OK; } @@ -737,7 +737,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // BlendMode ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { - int i = value->GetInt(); + int i = value->getInt(); if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; _blendMode = (TSpriteBlendMode)i; return S_OK; @@ -747,8 +747,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (value->IsNULL()) _scale = -1; - else _scale = (float)value->GetFloat(); + if (value->isNULL()) _scale = -1; + else _scale = (float)value->getFloat(); return S_OK; } @@ -756,8 +756,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (value->IsNULL()) _scaleX = -1; - else _scaleX = (float)value->GetFloat(); + if (value->isNULL()) _scaleX = -1; + else _scaleX = (float)value->getFloat(); return S_OK; } @@ -765,8 +765,8 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (value->IsNULL()) _scaleY = -1; - else _scaleY = (float)value->GetFloat(); + if (value->isNULL()) _scaleY = -1; + else _scaleY = (float)value->getFloat(); return S_OK; } @@ -774,7 +774,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // RelativeScale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)value->GetFloat(); + _relativeScale = (float)value->getFloat(); return S_OK; } @@ -782,11 +782,11 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotate") == 0) { - if (value->IsNULL()) { + if (value->isNULL()) { _rotate = 0.0f; _rotateValid = false; } else { - _rotate = (float)value->GetFloat(); + _rotate = (float)value->getFloat(); _rotateValid = true; } return S_OK; @@ -796,7 +796,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // RelativeRotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)value->GetFloat(); + _relativeRotate = (float)value->getFloat(); return S_OK; } @@ -804,7 +804,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // Colorable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Colorable") == 0) { - _shadowable = value->GetBool(); + _shadowable = value->getBool(); return S_OK; } @@ -812,7 +812,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // SoundPanning ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = value->GetBool(); + _autoSoundPanning = value->getBool(); if (!_autoSoundPanning) resetSoundPan(); return S_OK; } @@ -821,7 +821,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // SaveState ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveState") == 0) { - _saveState = value->GetBool(); + _saveState = value->getBool(); return S_OK; } @@ -829,7 +829,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = value->GetBool(); + _nonIntMouseEvents = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index dd0f06334d..c100a2c765 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -217,8 +217,8 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AddPoint") == 0) { stack->correctParams(2); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); _points.Add(new CBPoint(X, Y)); CreateRegion(); @@ -233,9 +233,9 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->GetInt(); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { _points.InsertAt(Index, new CBPoint(X, Y)); @@ -252,9 +252,9 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->GetInt(); - int X = stack->pop()->GetInt(); - int Y = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { _points[Index]->x = X; @@ -272,7 +272,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemovePoint") == 0) { stack->correctParams(1); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { delete _points[Index]; @@ -292,13 +292,13 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPoint") == 0) { stack->correctParams(1); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { CScValue *Val = stack->getPushValue(); if (Val) { - Val->SetProperty("X", _points[Index]->x); - Val->SetProperty("Y", _points[Index]->y); + Val->setProperty("X", _points[Index]->x); + Val->setProperty("Y", _points[Index]->y); } } else stack->pushNULL(); @@ -311,13 +311,13 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CBRegion::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("region"); + _scValue->setString("region"); return _scValue; } @@ -325,7 +325,7 @@ CScValue *CBRegion::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } @@ -333,7 +333,7 @@ CScValue *CBRegion::scGetProperty(const char *name) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _scValue->SetBool(_active); + _scValue->setBool(_active); return _scValue; } @@ -341,7 +341,7 @@ CScValue *CBRegion::scGetProperty(const char *name) { // NumPoints ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumPoints") == 0) { - _scValue->SetInt(_points.GetSize()); + _scValue->setInt(_points.GetSize()); return _scValue; } @@ -355,7 +355,7 @@ HRESULT CBRegion::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -363,7 +363,7 @@ HRESULT CBRegion::scSetProperty(const char *name, CScValue *value) { // Active ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { - _active = value->GetBool(); + _active = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 4557c8d2b3..6165008bc1 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -129,7 +129,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac stack->correctParams(1); CScValue *val = stack->pop(); HRESULT ret; - ret = applyEvent(val->GetString()); + ret = applyEvent(val->getString()); if (SUCCEEDED(ret)) stack->pushBool(true); else stack->pushBool(false); @@ -142,7 +142,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleEvent") == 0) { stack->correctParams(1); - stack->pushBool(canHandleEvent(stack->pop()->GetString())); + stack->pushBool(canHandleEvent(stack->pop()->getString())); return S_OK; } @@ -152,7 +152,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleMethod") == 0) { stack->correctParams(1); - stack->pushBool(canHandleMethod(stack->pop()->GetString())); + stack->pushBool(canHandleMethod(stack->pop()->getString())); return S_OK; } @@ -162,7 +162,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AttachScript") == 0) { stack->correctParams(1); - stack->pushBool(SUCCEEDED(addScript(stack->pop()->GetString()))); + stack->pushBool(SUCCEEDED(addScript(stack->pop()->getString()))); return S_OK; } @@ -172,8 +172,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DetachScript") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->GetString(); - bool KillThreads = stack->pop()->GetBool(false); + const char *Filename = stack->pop()->getString(); + bool KillThreads = stack->pop()->getBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { @@ -192,7 +192,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScriptRunning") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { @@ -209,13 +209,13 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// CScValue *CBScriptHolder::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("script_holder"); + _scValue->setString("script_holder"); return _scValue; } @@ -223,7 +223,7 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } @@ -231,7 +231,7 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { // Filename (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Filename") == 0) { - _scValue->SetString(_filename); + _scValue->setString(_filename); return _scValue; } @@ -245,7 +245,7 @@ HRESULT CBScriptHolder::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } else return CBScriptable::scSetProperty(name, value); } @@ -404,7 +404,7 @@ HRESULT CBScriptHolder::parseProperty(byte *Buffer, bool Complete) { CScValue *val = new CScValue(Game); - val->SetString(PropValue); + val->setString(PropValue); scSetProperty(PropName, val); delete val; diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 8d8c13df29..bd0018de24 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -76,7 +76,7 @@ HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CBScriptable::scGetProperty(const char *name) { if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->GetProp(name); + if (_scProp) return _scProp->getProp(name); else return NULL; } @@ -84,7 +84,7 @@ CScValue *CBScriptable::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// HRESULT CBScriptable::scSetProperty(const char *name, CScValue *value) { if (!_scProp) _scProp = new CScValue(Game); - if (_scProp) return _scProp->SetProp(name, value); + if (_scProp) return _scProp->setProp(name, value); else return E_FAIL; } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 901d592a02..07b8bc8b1d 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -513,7 +513,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); - int Index = stack->pop()->GetInt(-1); + int Index = stack->pop()->getInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); @@ -527,13 +527,13 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "DeleteFrame") == 0) { stack->correctParams(1); CScValue *Val = stack->pop(); - if (Val->IsInt()) { - int Index = Val->GetInt(-1); + if (Val->isInt()) { + int Index = Val->getInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { - CBFrame *Frame = (CBFrame *)Val->GetNative(); + CBFrame *Frame = (CBFrame *)Val->getNative(); for (int i = 0; i < _frames.GetSize(); i++) { if (_frames[i] == Frame) { if (i == _currentFrame) _lastFrameTime = 0; @@ -564,7 +564,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); CScValue *Val = stack->pop(); const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); + if (!Val->isNULL()) Filename = Val->getString(); CBFrame *Frame = new CBFrame(Game); if (Filename != NULL) { @@ -585,12 +585,12 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); - int Index = stack->pop()->GetInt(); + int Index = stack->pop()->getInt(); if (Index < 0) Index = 0; CScValue *Val = stack->pop(); const char *Filename = NULL; - if (!Val->IsNULL()) Filename = Val->GetString(); + if (!Val->isNULL()) Filename = Val->getString(); CBFrame *Frame = new CBFrame(Game); if (Filename != NULL) { @@ -632,13 +632,13 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CBSprite::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("sprite"); + _scValue->setString("sprite"); return _scValue; } @@ -646,7 +646,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFrames") == 0) { - _scValue->SetInt(_frames.GetSize()); + _scValue->setInt(_frames.GetSize()); return _scValue; } @@ -654,7 +654,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // CurrentFrame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CurrentFrame") == 0) { - _scValue->SetInt(_currentFrame); + _scValue->setInt(_currentFrame); return _scValue; } @@ -662,7 +662,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->SetBool(_precise); + _scValue->setBool(_precise); return _scValue; } @@ -670,7 +670,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // Looping ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Looping") == 0) { - _scValue->SetBool(_looping); + _scValue->setBool(_looping); return _scValue; } @@ -678,8 +678,8 @@ CScValue *CBSprite::scGetProperty(const char *name) { // Owner (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->SetNULL(); - else _scValue->SetNative(_owner, true); + if (_owner == NULL) _scValue->setNULL(); + else _scValue->setNative(_owner, true); return _scValue; } @@ -687,7 +687,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // Finished (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Finished") == 0) { - _scValue->SetBool(_finished); + _scValue->setBool(_finished); return _scValue; } @@ -695,7 +695,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // Paused (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Paused") == 0) { - _scValue->SetBool(_paused); + _scValue->setBool(_paused); return _scValue; } @@ -709,7 +709,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { // CurrentFrame ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->GetInt(0); + _currentFrame = value->getInt(0); if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { _currentFrame = -1; } @@ -721,7 +721,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _precise = value->GetBool(); + _precise = value->getBool(); return S_OK; } @@ -729,7 +729,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { // Looping ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Looping") == 0) { - _looping = value->GetBool(); + _looping = value->getBool(); return S_OK; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 0c7048b7bd..5a46237239 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -362,13 +362,13 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); CScValue *Val = stack->pop(); - if (Val->IsNULL()) { + if (Val->isNULL()) { if (_surface) Game->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; stack->pushBool(true); } else { - const char *Filename = Val->GetString(); + const char *Filename = Val->getString(); if (SUCCEEDED(setSurface(Filename))) { setDefaultRect(); stack->pushBool(true); @@ -385,13 +385,13 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t ////////////////////////////////////////////////////////////////////////// CScValue *CBSubFrame::scGetProperty(const char *name) { if (!_scValue) _scValue = new CScValue(Game); - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("subframe"); + _scValue->setString("subframe"); return _scValue; } @@ -400,7 +400,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { - _scValue->SetInt((int)_alpha); + _scValue->setInt((int)_alpha); return _scValue; } @@ -408,7 +408,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // TransparentColor (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TransparentColor") == 0) { - _scValue->SetInt((int)_transparent); + _scValue->setInt((int)_transparent); return _scValue; } @@ -416,7 +416,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // Is2DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is2DOnly") == 0) { - _scValue->SetBool(_2DOnly); + _scValue->setBool(_2DOnly); return _scValue; } @@ -424,7 +424,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // Is3DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is3DOnly") == 0) { - _scValue->SetBool(_3DOnly); + _scValue->setBool(_3DOnly); return _scValue; } @@ -432,7 +432,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // MirrorX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorX") == 0) { - _scValue->SetBool(_mirrorX); + _scValue->setBool(_mirrorX); return _scValue; } @@ -440,7 +440,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // MirrorY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorY") == 0) { - _scValue->SetBool(_mirrorY); + _scValue->setBool(_mirrorY); return _scValue; } @@ -448,7 +448,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _scValue->SetBool(_decoration); + _scValue->setBool(_decoration); return _scValue; } @@ -456,7 +456,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // HotspotX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotX") == 0) { - _scValue->SetInt(_hotspotX); + _scValue->setInt(_hotspotX); return _scValue; } @@ -464,7 +464,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { // HotspotY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotY") == 0) { - _scValue->SetInt(_hotspotY); + _scValue->setInt(_hotspotY); return _scValue; } @@ -478,7 +478,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // AlphaColor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->GetInt(); + _alpha = (uint32)value->getInt(); return S_OK; } @@ -486,7 +486,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // Is2DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = value->GetBool(); + _2DOnly = value->getBool(); return S_OK; } @@ -494,7 +494,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // Is3DOnly ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = value->GetBool(); + _3DOnly = value->getBool(); return S_OK; } @@ -502,7 +502,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // MirrorX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = value->GetBool(); + _mirrorX = value->getBool(); return S_OK; } @@ -510,7 +510,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // MirrorY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = value->GetBool(); + _mirrorY = value->getBool(); return S_OK; } @@ -518,7 +518,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // Decoration ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { - _decoration = value->GetBool(); + _decoration = value->getBool(); return S_OK; } @@ -526,7 +526,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // HotspotX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = value->GetInt(); + _hotspotX = value->getInt(); return S_OK; } @@ -534,7 +534,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { // HotspotY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = value->GetInt(); + _hotspotY = value->getInt(); return S_OK; } diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index e9c597c429..276540a14f 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -422,10 +422,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetBorder") == 0) { stack->correctParams(4); - int BorderX = stack->pop()->GetInt(); - int BorderY = stack->pop()->GetInt(); - int BorderWidth = stack->pop()->GetInt(); - int BorderHeight = stack->pop()->GetInt(); + int BorderX = stack->pop()->getInt(); + int BorderY = stack->pop()->getInt(); + int BorderWidth = stack->pop()->getInt(); + int BorderHeight = stack->pop()->getInt(); stack->pushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); @@ -436,10 +436,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBorderThickness") == 0) { stack->correctParams(4); - int Left = stack->pop()->GetInt(); - int Right = stack->pop()->GetInt(); - int Top = stack->pop()->GetInt(); - int Bottom = stack->pop()->GetInt(); + int Left = stack->pop()->getInt(); + int Right = stack->pop()->getInt(); + int Top = stack->pop()->getInt(); + int Bottom = stack->pop()->getInt(); stack->pushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); @@ -450,7 +450,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSprite") == 0) { stack->correctParams(1); - const char *SpriteFile = stack->pop()->GetString(); + const char *SpriteFile = stack->pop()->getString(); stack->pushBool(SUCCEEDED(addSprite(SpriteFile))); return S_OK; @@ -460,7 +460,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSprite") == 0) { stack->correctParams(1); - const char *SpriteFile = stack->pop()->GetString(); + const char *SpriteFile = stack->pop()->getString(); stack->pushBool(SUCCEEDED(removeSprite(SpriteFile))); return S_OK; @@ -471,7 +471,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Start") == 0) { stack->correctParams(1); - _overheadTime = stack->pop()->GetInt(); + _overheadTime = stack->pop()->getInt(); stack->pushBool(SUCCEEDED(start())); return S_OK; @@ -521,9 +521,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddGlobalForce") == 0) { stack->correctParams(3); - const char *forceName = stack->pop()->GetString(); - float Angle = stack->pop()->GetFloat(); - float Strength = stack->pop()->GetFloat(); + const char *forceName = stack->pop()->getString(); + float Angle = stack->pop()->getFloat(); + float Strength = stack->pop()->getFloat(); stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); @@ -535,11 +535,11 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddPointForce") == 0) { stack->correctParams(5); - const char *forceName = stack->pop()->GetString(); - int PosX = stack->pop()->GetInt(); - int PosY = stack->pop()->GetInt(); - float Angle = stack->pop()->GetFloat(); - float Strength = stack->pop()->GetFloat(); + const char *forceName = stack->pop()->getString(); + int PosX = stack->pop()->getInt(); + int PosY = stack->pop()->getInt(); + float Angle = stack->pop()->getFloat(); + float Strength = stack->pop()->getFloat(); stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); @@ -551,7 +551,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveForce") == 0) { stack->correctParams(1); - const char *forceName = stack->pop()->GetString(); + const char *forceName = stack->pop()->getString(); stack->pushBool(SUCCEEDED(removeForce(forceName))); @@ -563,41 +563,41 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CPartEmitter::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("particle-emitter"); + _scValue->setString("particle-emitter"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "X") == 0) { - _scValue->SetInt(_posX); + _scValue->setInt(_posX); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _scValue->SetInt(_posY); + _scValue->setInt(_posY); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _scValue->SetInt(_width); + _scValue->setInt(_width); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _scValue->SetInt(_height); + _scValue->setInt(_height); return _scValue; } @@ -605,21 +605,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // Scale1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale1") == 0) { - _scValue->SetFloat(_scale1); + _scValue->setFloat(_scale1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale2") == 0) { - _scValue->SetFloat(_scale2); + _scValue->setFloat(_scale2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->SetBool(_scaleZBased); + _scValue->setBool(_scaleZBased); return _scValue; } @@ -627,21 +627,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // Velocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity1") == 0) { - _scValue->SetFloat(_velocity1); + _scValue->setFloat(_velocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity2") == 0) { - _scValue->SetFloat(_velocity2); + _scValue->setFloat(_velocity2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->SetBool(_velocityZBased); + _scValue->setBool(_velocityZBased); return _scValue; } @@ -649,21 +649,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // LifeTime1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime1") == 0) { - _scValue->SetInt(_lifeTime1); + _scValue->setInt(_lifeTime1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime2") == 0) { - _scValue->SetInt(_lifeTime2); + _scValue->setInt(_lifeTime2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->SetBool(_lifeTimeZBased); + _scValue->setBool(_lifeTimeZBased); return _scValue; } @@ -671,14 +671,14 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // Angle1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle1") == 0) { - _scValue->SetInt(_angle1); + _scValue->setInt(_angle1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle2") == 0) { - _scValue->SetInt(_angle2); + _scValue->setInt(_angle2); return _scValue; } @@ -686,14 +686,14 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // AngVelocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->SetFloat(_angVelocity1); + _scValue->setFloat(_angVelocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->SetFloat(_angVelocity2); + _scValue->setFloat(_angVelocity2); return _scValue; } @@ -701,14 +701,14 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // Rotation1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation1") == 0) { - _scValue->SetFloat(_rotation1); + _scValue->setFloat(_rotation1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation2") == 0) { - _scValue->SetFloat(_rotation2); + _scValue->setFloat(_rotation2); return _scValue; } @@ -716,21 +716,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // Alpha1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha1") == 0) { - _scValue->SetInt(_alpha1); + _scValue->setInt(_alpha1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha2") == 0) { - _scValue->SetInt(_alpha2); + _scValue->setInt(_alpha2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->SetBool(_alphaTimeBased); + _scValue->setBool(_alphaTimeBased); return _scValue; } @@ -738,7 +738,7 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // MaxParticles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxParticles") == 0) { - _scValue->SetInt(_maxParticles); + _scValue->setInt(_maxParticles); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -749,7 +749,7 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { for (int i = 0; i < _particles.GetSize(); i++) { if (_particles[i] && !_particles[i]->_isDead) NumAlive++; } - _scValue->SetInt(NumAlive); + _scValue->setInt(NumAlive); return _scValue; } @@ -757,21 +757,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // GenerationInterval ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->SetInt(_genInterval); + _scValue->setInt(_genInterval); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->SetInt(_genAmount); + _scValue->setInt(_genAmount); return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxBatches") == 0) { - _scValue->SetInt(_maxBatches); + _scValue->setInt(_maxBatches); return _scValue; } @@ -779,14 +779,14 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // FadeInTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeInTime") == 0) { - _scValue->SetInt(_fadeInTime); + _scValue->setInt(_fadeInTime); return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->SetInt(_fadeOutTime); + _scValue->setInt(_fadeOutTime); return _scValue; } @@ -794,21 +794,21 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // GrowthRate1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->SetFloat(_growthRate1); + _scValue->setFloat(_growthRate1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->SetFloat(_growthRate2); + _scValue->setFloat(_growthRate2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->SetBool(_exponentialGrowth); + _scValue->setBool(_exponentialGrowth); return _scValue; } @@ -816,7 +816,7 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // UseRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UseRegion") == 0) { - _scValue->SetBool(_useRegion); + _scValue->setBool(_useRegion); return _scValue; } @@ -824,8 +824,8 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->SetNULL(); - else _scValue->SetString(_emitEvent); + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); return _scValue; } @@ -839,28 +839,28 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // X ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "X") == 0) { - _posX = value->GetInt(); + _posX = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { - _posY = value->GetInt(); + _posY = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = value->GetInt(); + _width = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = value->GetInt(); + _height = value->getInt(); return S_OK; } @@ -868,21 +868,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Scale1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->GetFloat(); + _scale1 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->GetFloat(); + _scale2 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->GetBool(); + _scaleZBased = value->getBool(); return S_OK; } @@ -890,21 +890,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Velocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->GetFloat(); + _velocity1 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->GetFloat(); + _velocity2 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->GetBool(); + _velocityZBased = value->getBool(); return S_OK; } @@ -912,21 +912,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // LifeTime1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->GetInt(); + _lifeTime1 = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->GetInt(); + _lifeTime2 = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->GetBool(); + _lifeTimeZBased = value->getBool(); return S_OK; } @@ -934,14 +934,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Angle1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->GetInt(); + _angle1 = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->GetInt(); + _angle2 = value->getInt(); return S_OK; } @@ -949,14 +949,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // AngVelocity1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->GetFloat(); + _angVelocity1 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->GetFloat(); + _angVelocity2 = value->getFloat(); return S_OK; } @@ -964,14 +964,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Rotation1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->GetFloat(); + _rotation1 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->GetFloat(); + _rotation2 = value->getFloat(); return S_OK; } @@ -979,7 +979,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Alpha1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->GetInt(); + _alpha1 = value->getInt(); if (_alpha1 < 0) _alpha1 = 0; if (_alpha1 > 255) _alpha1 = 255; return S_OK; @@ -988,7 +988,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // Alpha2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->GetInt(); + _alpha2 = value->getInt(); if (_alpha2 < 0) _alpha2 = 0; if (_alpha2 > 255) _alpha2 = 255; return S_OK; @@ -997,7 +997,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->GetBool(); + _alphaTimeBased = value->getBool(); return S_OK; } @@ -1005,7 +1005,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // MaxParticles ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->GetInt(); + _maxParticles = value->getInt(); return S_OK; } @@ -1013,21 +1013,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // GenerationInterval ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->GetInt(); + _genInterval = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->GetInt(); + _genAmount = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->GetInt(); + _maxBatches = value->getInt(); return S_OK; } @@ -1035,14 +1035,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // FadeInTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->GetInt(); + _fadeInTime = value->getInt(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->GetInt(); + _fadeOutTime = value->getInt(); return S_OK; } @@ -1050,21 +1050,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // GrowthRate1 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->GetFloat(); + _growthRate1 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->GetFloat(); + _growthRate2 = value->getFloat(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->GetBool(); + _exponentialGrowth = value->getBool(); return S_OK; } @@ -1072,7 +1072,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { // UseRegion ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->GetBool(); + _useRegion = value->getBool(); return S_OK; } @@ -1082,7 +1082,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->IsNULL()) CBUtils::SetString(&_emitEvent, value->GetString()); + if (!value->isNULL()) CBUtils::SetString(&_emitEvent, value->getString()); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index c22dd9e4b5..72c848f747 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -45,15 +45,15 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; _values = new CScValue(Game); - int NumParams = stack->pop()->GetInt(0); + int NumParams = stack->pop()->getInt(0); - if (NumParams == 1) _length = stack->pop()->GetInt(0); + if (NumParams == 1) _length = stack->pop()->getInt(0); else if (NumParams > 1) { _length = NumParams; char ParamName[20]; for (int i = 0; i < NumParams; i++) { sprintf(ParamName, "%d", i); - _values->SetProp(ParamName, stack->pop()); + _values->setProp(ParamName, stack->pop()); } } } @@ -79,10 +79,10 @@ const char *CSXArray::scToString() { char PropName[20]; for (int i = 0; i < _length; i++) { sprintf(PropName, "%d", i); - CScValue *val = _values->GetProp(PropName); + CScValue *val = _values->getProp(PropName); if (val) { - if (strlen(Dummy) + strlen(val->GetString()) < 32768) { - strcat(Dummy, val->GetString()); + if (strlen(Dummy) + strlen(val->getString()) < 32768) { + strcat(Dummy, val->getString()); } } @@ -98,13 +98,13 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Push ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Push") == 0) { - int NumParams = stack->pop()->GetInt(0); + int NumParams = stack->pop()->getInt(0); char ParamName[20]; for (int i = 0; i < NumParams; i++) { _length++; sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, stack->pop(), true); + _values->setProp(ParamName, stack->pop(), true); } stack->pushInt(_length); @@ -121,8 +121,8 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (_length > 0) { char ParamName[20]; sprintf(ParamName, "%d", _length - 1); - stack->push(_values->GetProp(ParamName)); - _values->DeleteProp(ParamName); + stack->push(_values->getProp(ParamName)); + _values->deleteProp(ParamName); _length--; } else stack->pushNULL(); @@ -135,13 +135,13 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CSXArray::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("array"); + _scValue->setString("array"); return _scValue; } @@ -149,7 +149,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { // Length ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Length") == 0) { - _scValue->SetInt(_length); + _scValue->setInt(_length); return _scValue; } @@ -159,7 +159,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { else { char ParamName[20]; if (ValidNumber(name, ParamName)) { - return _values->GetProp(ParamName); + return _values->getProp(ParamName); } else return _scValue; } } @@ -172,13 +172,13 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length") == 0) { int OrigLength = _length; - _length = MAX(value->GetInt(0), 0); + _length = MAX(value->getInt(0), 0); char PropName[20]; if (_length < OrigLength) { for (int i = _length; i < OrigLength; i++) { sprintf(PropName, "%d", i); - _values->DeleteProp(PropName); + _values->deleteProp(PropName); } } return S_OK; @@ -192,7 +192,7 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { if (ValidNumber(name, ParamName)) { int Index = atoi(ParamName); if (Index >= _length) _length = Index + 1; - return _values->SetProp(ParamName, value); + return _values->setProp(ParamName, value); } else return E_FAIL; } } @@ -231,7 +231,7 @@ HRESULT CSXArray::Push(CScValue *Val) { char ParamName[20]; _length++; sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, Val, true); + _values->setProp(ParamName, Val, true); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 61a646df43..e108c03a6e 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -45,14 +45,14 @@ CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { memset(&_tm, 0, sizeof(_tm)); CScValue *valYear = stack->pop(); - _tm.tm_year = valYear->GetInt() - 1900; - _tm.tm_mon = stack->pop()->GetInt() - 1; - _tm.tm_mday = stack->pop()->GetInt(); - _tm.tm_hour = stack->pop()->GetInt(); - _tm.tm_min = stack->pop()->GetInt(); - _tm.tm_sec = stack->pop()->GetInt(); - - if (valYear->IsNULL()) { + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { g_system->getTimeAndDate(_tm); } } @@ -140,7 +140,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetYear") == 0) { stack->correctParams(1); - _tm.tm_year = stack->pop()->GetInt() - 1900; + _tm.tm_year = stack->pop()->getInt() - 1900; stack->pushNULL(); return S_OK; } @@ -149,7 +149,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMonth") == 0) { stack->correctParams(1); - _tm.tm_mon = stack->pop()->GetInt() - 1; + _tm.tm_mon = stack->pop()->getInt() - 1; stack->pushNULL(); return S_OK; } @@ -158,7 +158,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDate") == 0) { stack->correctParams(1); - _tm.tm_mday = stack->pop()->GetInt(); + _tm.tm_mday = stack->pop()->getInt(); stack->pushNULL(); return S_OK; } @@ -167,7 +167,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHours") == 0) { stack->correctParams(1); - _tm.tm_hour = stack->pop()->GetInt(); + _tm.tm_hour = stack->pop()->getInt(); stack->pushNULL(); return S_OK; } @@ -176,7 +176,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMinutes") == 0) { stack->correctParams(1); - _tm.tm_min = stack->pop()->GetInt(); + _tm.tm_min = stack->pop()->getInt(); stack->pushNULL(); return S_OK; } @@ -185,7 +185,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSeconds") == 0) { stack->correctParams(1); - _tm.tm_sec = stack->pop()->GetInt(); + _tm.tm_sec = stack->pop()->getInt(); stack->pushNULL(); return S_OK; } @@ -208,13 +208,13 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CSXDate::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("date"); + _scValue->setString("date"); return _scValue; } @@ -229,7 +229,7 @@ HRESULT CSXDate::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Name")==0){ - setName(value->GetString()); + setName(value->getString()); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index fc2fca1991..6738df0301 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -60,7 +60,7 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { CScValue *Val = stack->pop(); _filename = NULL; - if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); + if (!Val->isNULL()) CBUtils::SetString(&_filename, Val->getString()); _readFile = NULL; _writeFile = NULL; @@ -111,7 +111,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFilename") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); cleanup(); CBUtils::SetString(&_filename, Filename); stack->pushNULL(); @@ -124,7 +124,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { stack->correctParams(1); Close(); - _mode = stack->pop()->GetInt(1); + _mode = stack->pop()->getInt(1); if (_mode < 1 || _mode > 3) { script->RuntimeError("File.%s: invalid access mode. Setting read mode.", name); _mode = 1; @@ -175,7 +175,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this script->RuntimeError("File.%s: File is not open", name); stack->pushBool(false); } else { - int Pos = stack->pop()->GetInt(); + int Pos = stack->pop()->getInt(); stack->pushBool(SetPos(Pos)); } return S_OK; @@ -196,8 +196,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { stack->correctParams(2); - const char *Dest = stack->pop()->GetString(); - bool Overwrite = stack->pop()->GetBool(true); + const char *Dest = stack->pop()->getString(); + bool Overwrite = stack->pop()->getBool(true); Close(); stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); @@ -258,7 +258,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadText") == 0) { stack->correctParams(1); - int TextLen = stack->pop()->GetInt(); + int TextLen = stack->pop()->getInt(); if (!_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open in text mode.", name); @@ -305,7 +305,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { stack->correctParams(1); - const char *Line = stack->pop()->GetString(); + const char *Line = stack->pop()->getString(); if (!_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in text mode.", name); stack->pushBool(false); @@ -454,7 +454,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteBool") == 0) { stack->correctParams(1); - bool Val = stack->pop()->GetBool(); + bool Val = stack->pop()->getBool(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -472,7 +472,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteByte") == 0) { stack->correctParams(1); - byte Val = stack->pop()->GetInt(); + byte Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -490,7 +490,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteShort") == 0) { stack->correctParams(1); - short Val = stack->pop()->GetInt(); + short Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -508,7 +508,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { stack->correctParams(1); - int Val = stack->pop()->GetInt(); + int Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -526,7 +526,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteFloat") == 0) { stack->correctParams(1); - float Val = stack->pop()->GetFloat(); + float Val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -544,7 +544,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteDouble") == 0) { stack->correctParams(1); - double Val = stack->pop()->GetFloat(); + double Val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -562,7 +562,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteString") == 0) { stack->correctParams(1); - const char *Val = stack->pop()->GetString(); + const char *Val = stack->pop()->getString(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); @@ -586,13 +586,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CSXFile::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("file"); + _scValue->setString("file"); return _scValue; } @@ -600,7 +600,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // Filename (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Filename") == 0) { - _scValue->SetString(_filename); + _scValue->setString(_filename); return _scValue; } @@ -608,7 +608,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // Position (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Position") == 0) { - _scValue->SetInt(GetPos()); + _scValue->setInt(GetPos()); return _scValue; } @@ -616,7 +616,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // Length (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Length") == 0) { - _scValue->SetInt(GetLength()); + _scValue->setInt(GetLength()); return _scValue; } @@ -624,7 +624,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // TextMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextMode") == 0) { - _scValue->SetBool(_textMode); + _scValue->setBool(_textMode); return _scValue; } @@ -632,7 +632,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // AccessMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccessMode") == 0) { - _scValue->SetInt(_mode); + _scValue->setInt(_mode); return _scValue; } @@ -648,7 +648,7 @@ HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Length")==0){ int OrigLength = _length; - _length = max(value->GetInt(0), 0); + _length = max(value->getInt(0), 0); char PropName[20]; if(_length < OrigLength){ diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 110330d4ef..92e6823534 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -64,7 +64,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Abs") == 0) { stack->correctParams(1); - stack->pushFloat(fabs(stack->pop()->GetFloat())); + stack->pushFloat(fabs(stack->pop()->getFloat())); return S_OK; } @@ -73,7 +73,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Acos") == 0) { stack->correctParams(1); - stack->pushFloat(acos(stack->pop()->GetFloat())); + stack->pushFloat(acos(stack->pop()->getFloat())); return S_OK; } @@ -82,7 +82,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Asin") == 0) { stack->correctParams(1); - stack->pushFloat(asin(stack->pop()->GetFloat())); + stack->pushFloat(asin(stack->pop()->getFloat())); return S_OK; } @@ -91,7 +91,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan") == 0) { stack->correctParams(1); - stack->pushFloat(atan(stack->pop()->GetFloat())); + stack->pushFloat(atan(stack->pop()->getFloat())); return S_OK; } @@ -100,8 +100,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan2") == 0) { stack->correctParams(2); - double y = stack->pop()->GetFloat(); - double x = stack->pop()->GetFloat(); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); stack->pushFloat(atan2(y, x)); return S_OK; } @@ -111,7 +111,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Ceil") == 0) { stack->correctParams(1); - stack->pushFloat(ceil(stack->pop()->GetFloat())); + stack->pushFloat(ceil(stack->pop()->getFloat())); return S_OK; } @@ -120,7 +120,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cos") == 0) { stack->correctParams(1); - stack->pushFloat(cos(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(cos(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -129,7 +129,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cosh") == 0) { stack->correctParams(1); - stack->pushFloat(cosh(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(cosh(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -138,7 +138,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exp") == 0) { stack->correctParams(1); - stack->pushFloat(exp(stack->pop()->GetFloat())); + stack->pushFloat(exp(stack->pop()->getFloat())); return S_OK; } @@ -147,7 +147,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Floor") == 0) { stack->correctParams(1); - stack->pushFloat(floor(stack->pop()->GetFloat())); + stack->pushFloat(floor(stack->pop()->getFloat())); return S_OK; } @@ -156,7 +156,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log") == 0) { stack->correctParams(1); - stack->pushFloat(log(stack->pop()->GetFloat())); + stack->pushFloat(log(stack->pop()->getFloat())); return S_OK; } @@ -165,7 +165,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log10") == 0) { stack->correctParams(1); - stack->pushFloat(log10(stack->pop()->GetFloat())); + stack->pushFloat(log10(stack->pop()->getFloat())); return S_OK; } @@ -174,8 +174,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pow") == 0) { stack->correctParams(2); - double x = stack->pop()->GetFloat(); - double y = stack->pop()->GetFloat(); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); stack->pushFloat(pow(x, y)); return S_OK; @@ -186,7 +186,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sin") == 0) { stack->correctParams(1); - stack->pushFloat(sin(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(sin(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sinh") == 0) { stack->correctParams(1); - stack->pushFloat(sinh(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(sinh(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -204,7 +204,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tan") == 0) { stack->correctParams(1); - stack->pushFloat(tan(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(tan(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -213,7 +213,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tanh") == 0) { stack->correctParams(1); - stack->pushFloat(tanh(DegreeToRadian(stack->pop()->GetFloat()))); + stack->pushFloat(tanh(DegreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -222,7 +222,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sqrt") == 0) { stack->correctParams(1); - stack->pushFloat(sqrt(stack->pop()->GetFloat())); + stack->pushFloat(sqrt(stack->pop()->getFloat())); return S_OK; } @@ -231,7 +231,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DegToRad") == 0) { stack->correctParams(1); - stack->pushFloat(DegreeToRadian(stack->pop()->GetFloat())); + stack->pushFloat(DegreeToRadian(stack->pop()->getFloat())); return S_OK; } @@ -240,7 +240,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RadToDeg") == 0) { stack->correctParams(1); - stack->pushFloat(RadianToDegree(stack->pop()->GetFloat())); + stack->pushFloat(RadianToDegree(stack->pop()->getFloat())); return S_OK; } @@ -250,13 +250,13 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CSXMath::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("math"); + _scValue->setString("math"); return _scValue; } @@ -264,7 +264,7 @@ CScValue *CSXMath::scGetProperty(const char *name) { // PI ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PI") == 0) { - _scValue->SetFloat(PI); + _scValue->setFloat(PI); return _scValue; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 7dcb6ea1a7..0afdf08450 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -47,7 +47,7 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame _buffer = NULL; _size = 0; - int NewSize = stack->pop()->GetInt(); + int NewSize = stack->pop()->getInt(); Resize(MAX(0, NewSize)); } @@ -128,7 +128,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSize") == 0) { stack->correctParams(1); - int NewSize = stack->pop()->GetInt(); + int NewSize = stack->pop()->getInt(); NewSize = MAX(0, NewSize); if (SUCCEEDED(Resize(NewSize))) stack->pushBool(true); else stack->pushBool(false); @@ -141,7 +141,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetBool") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(bool))) stack->pushNULL(); else stack->pushBool(*(bool *)((byte *)_buffer + Start)); @@ -153,7 +153,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetByte") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(byte))) stack->pushNULL(); else stack->pushInt(*(byte *)((byte *)_buffer + Start)); @@ -165,7 +165,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(short))) stack->pushNULL(); else stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); @@ -177,7 +177,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(int))) stack->pushNULL(); else stack->pushInt(*(int *)((byte *)_buffer + Start)); @@ -189,7 +189,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFloat") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(float))) stack->pushNULL(); else stack->pushFloat(*(float *)((byte *)_buffer + Start)); @@ -201,7 +201,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDouble") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(double))) stack->pushNULL(); else stack->pushFloat(*(double *)((byte *)_buffer + Start)); @@ -213,8 +213,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetString") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - int Length = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); + int Length = stack->pop()->getInt(); // find end of string if (Length == 0 && Start >= 0 && Start < _size) { @@ -242,7 +242,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPointer") == 0) { stack->correctParams(1); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(void *))) stack->pushNULL(); else { void *Pointer = *(void **)((byte *)_buffer + Start); @@ -257,8 +257,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBool") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - bool Val = stack->pop()->GetBool(); + int Start = stack->pop()->getInt(); + bool Val = stack->pop()->getBool(); if (!CheckBounds(script, Start, sizeof(bool))) stack->pushBool(false); else { @@ -273,8 +273,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetByte") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - byte Val = (byte)stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); + byte Val = (byte)stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(byte))) stack->pushBool(false); else { @@ -289,8 +289,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetShort") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - short Val = (short)stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); + short Val = (short)stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(short))) stack->pushBool(false); else { @@ -305,8 +305,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - int Val = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); + int Val = stack->pop()->getInt(); if (!CheckBounds(script, Start, sizeof(int))) stack->pushBool(false); else { @@ -321,8 +321,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFloat") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - float Val = (float)stack->pop()->GetFloat(); + int Start = stack->pop()->getInt(); + float Val = (float)stack->pop()->getFloat(); if (!CheckBounds(script, Start, sizeof(float))) stack->pushBool(false); else { @@ -337,8 +337,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDouble") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - double Val = stack->pop()->GetFloat(); + int Start = stack->pop()->getInt(); + double Val = stack->pop()->getFloat(); if (!CheckBounds(script, Start, sizeof(double))) stack->pushBool(false); else { @@ -353,8 +353,8 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetString") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); - const char *Val = stack->pop()->GetString(); + int Start = stack->pop()->getInt(); + const char *Val = stack->pop()->getString(); if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->pushBool(false); else { @@ -369,13 +369,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); - int Start = stack->pop()->GetInt(); + int Start = stack->pop()->getInt(); /* CScValue *Val = */ stack->pop(); if (!CheckBounds(script, Start, sizeof(void *))) stack->pushBool(false); else { /* - int Pointer = (int)Val->GetMemBuffer(); + int Pointer = (int)Val->getMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); stack->pushBool(true); */ @@ -408,13 +408,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CSXMemBuffer::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("membuffer"); + _scValue->setString("membuffer"); return _scValue; } @@ -422,7 +422,7 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { // Size (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Size") == 0) { - _scValue->SetInt(_size); + _scValue->setInt(_size); return _scValue; } @@ -438,7 +438,7 @@ HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Length")==0){ int OrigLength = _length; - _length = max(value->GetInt(0), 0); + _length = max(value->getInt(0), 0); char PropName[20]; if(_length < OrigLength){ diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index a1d41c2db6..6d0461df54 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -108,7 +108,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidateProducts") == 0) { stack->correctParams(1); - const char *prodIdList = stack->pop()->GetString(); + const char *prodIdList = stack->pop()->getString(); _lastProductRequestOwner = script->_owner; ValidateProducts(prodIdList); stack->pushNULL(); @@ -119,14 +119,14 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetValidProduct") == 0) { stack->correctParams(1); - int index = stack->pop()->GetInt(); + int index = stack->pop()->getInt(); if (index >= 0 && index < _validProducts.GetSize()) { CScValue *prod = stack->getPushValue(); if (prod) { - prod->SetProperty("Id", _validProducts[index]->GetId()); - prod->SetProperty("Name", _validProducts[index]->GetName()); - prod->SetProperty("Description", _validProducts[index]->GetDesc()); - prod->SetProperty("Price", _validProducts[index]->GetPrice()); + prod->setProperty("Id", _validProducts[index]->GetId()); + prod->setProperty("Name", _validProducts[index]->GetName()); + prod->setProperty("Description", _validProducts[index]->GetDesc()); + prod->setProperty("Price", _validProducts[index]->GetPrice()); } } else stack->pushNULL(); @@ -138,7 +138,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInvalidProduct") == 0) { stack->correctParams(1); - int index = stack->pop()->GetInt(); + int index = stack->pop()->getInt(); if (index >= 0 && index < _invalidProducts.size()) stack->pushString(_invalidProducts[index].c_str()); else @@ -151,13 +151,13 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetTransaction") == 0) { stack->correctParams(1); - int index = stack->pop()->GetInt(); + int index = stack->pop()->getInt(); if (index >= 0 && index < _transactions.GetSize()) { CScValue *trans = stack->getPushValue(); if (trans) { - trans->SetProperty("Id", _transactions[index]->GetId()); - trans->SetProperty("ProductId", _transactions[index]->GetProductId()); - trans->SetProperty("State", _transactions[index]->GetState()); + trans->setProperty("Id", _transactions[index]->GetId()); + trans->setProperty("ProductId", _transactions[index]->GetProductId()); + trans->setProperty("State", _transactions[index]->GetState()); } } else stack->pushNULL(); @@ -169,7 +169,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Purchase") == 0) { stack->correctParams(1); - const char *prodId = stack->pop()->GetString(); + const char *prodId = stack->pop()->getString(); stack->pushBool(Purchase(script, prodId)); return S_OK; @@ -179,7 +179,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FinishTransaction") == 0) { stack->correctParams(1); - const char *transId = stack->pop()->GetString(); + const char *transId = stack->pop()->getString(); stack->pushBool(FinishTransaction(script, transId)); return S_OK; @@ -200,7 +200,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnlockProduct") == 0) { stack->correctParams(1); - const char *prodId = stack->pop()->GetString(); + const char *prodId = stack->pop()->getString(); Game->_registry->WriteBool("Purchases", prodId, true); Game->_registry->SaveValues(); @@ -215,7 +215,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsProductUnlocked") == 0) { stack->correctParams(1); - const char *prodId = stack->pop()->GetString(); + const char *prodId = stack->pop()->getString(); stack->pushBool(Game->_registry->ReadBool("Purchases", prodId, false)); @@ -228,48 +228,48 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// CScValue *CSXStore::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("store"); + _scValue->setString("store"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Available (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Available") == 0) { - _scValue->SetBool(IsAvailable()); + _scValue->setBool(IsAvailable()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // EventsEnabled (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EventsEnabled") == 0) { - _scValue->SetBool(GetEventsEnabled()); + _scValue->setBool(GetEventsEnabled()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumValidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumValidProducts") == 0) { - _scValue->SetInt(_validProducts.GetSize()); + _scValue->setInt(_validProducts.GetSize()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumInvalidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumInvalidProducts") == 0) { - _scValue->SetInt(_invalidProducts.size()); + _scValue->setInt(_invalidProducts.size()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumTransactions (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumTransactions") == 0) { - _scValue->SetInt(_transactions.GetSize()); + _scValue->setInt(_transactions.GetSize()); return _scValue; } diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 36dc257229..4f6bd5a33d 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -51,14 +51,14 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { stack->correctParams(1); CScValue *Val = stack->pop(); - if (Val->IsInt()) { - _capacity = MAX(0, Val->GetInt()); + if (Val->isInt()) { + _capacity = MAX(0, Val->getInt()); if (_capacity > 0) { _string = new char[_capacity]; memset(_string, 0, _capacity); } } else { - SetStringVal(Val->GetString()); + SetStringVal(Val->getString()); } if (_capacity == 0) SetStringVal(""); @@ -105,8 +105,8 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Substring") == 0) { stack->correctParams(2); - int start = stack->pop()->GetInt(); - int end = stack->pop()->GetInt(); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); if (end < start) CBUtils::Swap(&start, &end); @@ -136,17 +136,17 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Substr") == 0) { stack->correctParams(2); - int start = stack->pop()->GetInt(); + int start = stack->pop()->getInt(); CScValue *val = stack->pop(); - int len = val->GetInt(); + int len = val->getInt(); - if (!val->IsNULL() && len <= 0) { + if (!val->isNULL() && len <= 0) { stack->pushString(""); return S_OK; } - if (val->IsNULL()) len = strlen(_string) - start; + if (val->isNULL()) len = strlen(_string) - start; // try { WideString str; @@ -219,8 +219,8 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "IndexOf") == 0) { stack->correctParams(2); - const char *strToFind = stack->pop()->GetString(); - int index = stack->pop()->GetInt(); + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -247,7 +247,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); char Separators[MAX_PATH] = ","; - if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); + if (!Val->isNULL()) strcpy(Separators, Val->getString()); CSXArray *Array = new CSXArray(Game); if (!Array) { @@ -318,13 +318,13 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CSXString::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("string"); + _scValue->setString("string"); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -333,9 +333,9 @@ CScValue *CSXString::scGetProperty(const char *name) { else if (strcmp(name, "Length") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::Utf8ToWide(_string); - _scValue->SetInt(wstr.size()); + _scValue->setInt(wstr.size()); } else - _scValue->SetInt(strlen(_string)); + _scValue->setInt(strlen(_string)); return _scValue; } @@ -343,7 +343,7 @@ CScValue *CSXString::scGetProperty(const char *name) { // Capacity ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Capacity") == 0) { - _scValue->SetInt(_capacity); + _scValue->setInt(_capacity); return _scValue; } @@ -357,7 +357,7 @@ HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { // Capacity ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { - int NewCap = value->GetInt(); + int NewCap = value->getInt(); if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); else if (NewCap != _capacity) { char *NewStr = new char[NewCap]; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index e840d0cd78..8aca4c9edf 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -105,17 +105,17 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { // register 'Game' as global variable - if (!_globals->PropExists("Game")) { + if (!_globals->propExists("Game")) { CScValue val(Game); - val.SetNative(Game, true); - _globals->SetProp("Game", &val); + val.setNative(Game, true); + _globals->setProp("Game", &val); } // register 'Math' as global variable - if (!_globals->PropExists("Math")) { + if (!_globals->propExists("Math")) { CScValue val(Game); - val.SetNative(Game->_mathClass, true); - _globals->SetProp("Math", &val); + val.setNative(Game->_mathClass, true); + _globals->setProp("Math", &val); } // prepare script cache @@ -250,11 +250,11 @@ CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { } else { // publish the "self" pseudo-variable CScValue val(Game); - if (Owner)val.SetNative(Owner, true); - else val.SetNULL(); + if (Owner)val.setNative(Owner, true); + else val.setNULL(); - script->_globals->SetProp("self", &val); - script->_globals->SetProp("this", &val); + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); _scripts.Add(script); Game->GetDebugMgr()->OnScriptInit(script); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 61e1e91282..217233534c 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -486,16 +486,16 @@ HRESULT CScScript::ExecuteInstruction() { switch (inst) { case II_DEF_VAR: - _operand->SetNULL(); + _operand->setNULL(); dw = GetDWORD(); if (_scopeStack->_sP < 0) { - _globals->SetProp(_symbols[dw], _operand); + _globals->setProp(_symbols[dw], _operand); if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); } else { - _scopeStack->getTop()->SetProp(_symbols[dw], _operand); + _scopeStack->getTop()->setProp(_symbols[dw], _operand); if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->GetProp(_symbols[dw]), _symbols[dw]); + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); } break; @@ -505,12 +505,12 @@ HRESULT CScScript::ExecuteInstruction() { dw = GetDWORD(); /* char *Temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist - if (!_engine->_globals->PropExists(_symbols[dw])) { - _operand->SetNULL(); - _engine->_globals->SetProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->GetProp(_symbols[dw]), _symbols[dw]); + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); } break; } @@ -520,7 +520,7 @@ HRESULT CScScript::ExecuteInstruction() { Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->GetInt(); + _iP = (uint32)_callStack->pop()->getInt(); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); @@ -543,7 +543,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_CALL: dw = GetDWORD(); - _operand->SetInt(_iP); + _operand->setInt(_iP); _callStack->push(_operand); _iP = dw; @@ -553,7 +553,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_CALL_BY_EXP: { // push var // push string - str = _stack->pop()->GetString(); + str = _stack->pop()->getString(); char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); @@ -564,15 +564,15 @@ HRESULT CScScript::ExecuteInstruction() { bool TriedNative = false; // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->GetNative()) { + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { TriedNative = true; res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); } if (FAILED(res)) { - if (var->IsNative() && var->GetNative()->canHandleMethod(MethodName)) { + if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { if (!_unbreakable) { - _waitScript = var->GetNative()->invokeMethodThread(MethodName); + _waitScript = var->getNative()->invokeMethodThread(MethodName); if (!_waitScript) { _stack->correctParams(0); RuntimeError("Error invoking method '%s'.", MethodName); @@ -591,21 +591,21 @@ HRESULT CScScript::ExecuteInstruction() { break; } /* - CScValue* val = var->GetProp(MethodName); + CScValue* val = var->getProp(MethodName); if(val){ - dw = GetFuncPos(val->GetString()); + dw = GetFuncPos(val->getString()); if(dw==0){ - TExternalFunction* f = GetExternal(val->GetString()); + TExternalFunction* f = GetExternal(val->getString()); if(f){ ExternalCall(_stack, _thisStack, f); } else{ // not an internal nor external, try for native function - Game->ExternalCall(this, _stack, _thisStack, val->GetString()); + Game->ExternalCall(this, _stack, _thisStack, val->getString()); } } else{ - _operand->SetInt(_iP); + _operand->setInt(_iP); _callStack->Push(_operand); _iP = dw; } @@ -637,7 +637,7 @@ HRESULT CScScript::ExecuteInstruction() { break; } case II_SCOPE: - _operand->SetNULL(); + _operand->setNULL(); _scopeStack->push(_operand); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); @@ -651,7 +651,7 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_CREATE_OBJECT: - _operand->SetObject(); + _operand->setObject(); _stack->push(_operand); break; @@ -662,7 +662,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_PUSH_VAR: { CScValue *var = GetVar(_symbols[GetDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->SetReference(var); + _operand->setReference(var); _stack->push(_operand); } else _stack->push(var); break; @@ -670,7 +670,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_PUSH_VAR_REF: { CScValue *var = GetVar(_symbols[GetDWORD()]); - _operand->SetReference(var); + _operand->setReference(var); _stack->push(_operand); break; } @@ -682,12 +682,12 @@ HRESULT CScScript::ExecuteInstruction() { CScValue *val = _stack->pop(); if (!val) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->SetNULL(); + var->setNULL(); } else { - if (val->GetType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->SetValue(val); + if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->setValue(val); else { - var->Copy(val); + var->copy(val); } } @@ -725,12 +725,12 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_PUSH_THIS_FROM_STACK: - _operand->SetReference(_stack->getTop()); + _operand->setReference(_stack->getTop()); _thisStack->push(_operand); break; case II_PUSH_THIS: - _operand->SetReference(GetVar(_symbols[GetDWORD()])); + _operand->setReference(GetVar(_symbols[GetDWORD()])); _thisStack->push(_operand); break; @@ -739,8 +739,8 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_PUSH_BY_EXP: { - str = _stack->pop()->GetString(); - CScValue *val = _stack->pop()->GetProp(str); + str = _stack->pop()->getString(); + CScValue *val = _stack->pop()->getProp(str); if (val) _stack->push(val); else _stack->pushNULL(); @@ -748,14 +748,14 @@ HRESULT CScScript::ExecuteInstruction() { } case II_POP_BY_EXP: { - str = _stack->pop()->GetString(); + str = _stack->pop()->getString(); CScValue *var = _stack->pop(); CScValue *val = _stack->pop(); if (val == NULL) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->SetNULL(); - } else var->SetProp(str, val); + var->setNULL(); + } else var->setProp(str, val); if (Game->GetDebugMgr()->_enabled) Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); @@ -768,7 +768,7 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_POP_REG1: - _reg1->Copy(_stack->pop()); + _reg1->copy(_stack->pop()); break; case II_JMP: @@ -777,12 +777,12 @@ HRESULT CScScript::ExecuteInstruction() { case II_JMP_FALSE: { dw = GetDWORD(); - //if(!_stack->pop()->GetBool()) _iP = dw; + //if(!_stack->pop()->getBool()) _iP = dw; CScValue *Val = _stack->pop(); if (!Val) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { - if (!Val->GetBool()) _iP = dw; + if (!Val->getBool()) _iP = dw; } break; } @@ -791,16 +791,16 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->GetString()) + strlen(op2->GetString()) + 1]; - strcpy(tempStr, op1->GetString()); - strcat(tempStr, op2->GetString()); - _operand->SetString(tempStr); + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); delete [] tempStr; - } else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() + op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() + op2->getInt()); + else _operand->setFloat(op1->getFloat() + op2->getFloat()); _stack->push(_operand); @@ -810,10 +810,10 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() - op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() - op2->getInt()); + else _operand->setFloat(op1->getFloat() - op2->getFloat()); _stack->push(_operand); @@ -823,10 +823,10 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); - else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) - _operand->SetInt(op1->GetInt() * op2->GetInt()); - else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() * op2->getInt()); + else _operand->setFloat(op1->getFloat() * op2->getFloat()); _stack->push(_operand); @@ -836,10 +836,10 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); + if (op2->getFloat() == 0.0f) RuntimeError("Division by zero."); - if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); - else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); + else _operand->setFloat(op1->getFloat() / op2->getFloat()); _stack->push(_operand); @@ -849,10 +849,10 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->GetInt() == 0) RuntimeError("Division by zero."); + if (op2->getInt() == 0) RuntimeError("Division by zero."); - if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); - else _operand->SetInt(op1->GetInt() % op2->GetInt()); + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) _operand->setNULL(); + else _operand->setInt(op1->getInt() % op2->getInt()); _stack->push(_operand); @@ -860,9 +860,9 @@ HRESULT CScScript::ExecuteInstruction() { case II_NOT: op1 = _stack->pop(); - //if(op1->IsNULL()) _operand->SetNULL(); - if (op1->IsNULL()) _operand->SetBool(true); - else _operand->SetBool(!op1->GetBool()); + //if(op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) _operand->setBool(true); + else _operand->setBool(!op1->getBool()); _stack->push(_operand); break; @@ -872,9 +872,9 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->SetBool(false); + _operand->setBool(false); } else { - _operand->SetBool(op1->GetBool() && op2->GetBool()); + _operand->setBool(op1->getBool() && op2->getBool()); } _stack->push(_operand); break; @@ -884,9 +884,9 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->SetBool(false); + _operand->setBool(false); } else { - _operand->SetBool(op1->GetBool() || op2->GetBool()); + _operand->setBool(op1->getBool() || op2->getBool()); } _stack->push(_operand); break; @@ -896,22 +896,22 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); - else if(op1->IsNative() && op2->IsNative()){ - _operand->SetBool(op1->GetNative() == op2->GetNative()); + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); } - else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())==0); + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); } - else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() == op2->GetFloat()); + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); } else{ - _operand->SetBool(op1->GetInt() == op2->GetInt()); + _operand->setBool(op1->getInt() == op2->getInt()); } */ - _operand->SetBool(CScValue::Compare(op1, op2) == 0); + _operand->setBool(CScValue::compare(op1, op2) == 0); _stack->push(_operand); break; @@ -920,22 +920,22 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); - else if(op1->IsNative() && op2->IsNative()){ - _operand->SetBool(op1->GetNative() != op2->GetNative()); + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); } - else if(op1->GetType()==VAL_STRING || op2->GetType()==VAL_STRING){ - _operand->SetBool(scumm_stricmp(op1->GetString(), op2->GetString())!=0); + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); } - else if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() != op2->GetFloat()); + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); } else{ - _operand->SetBool(op1->GetInt() != op2->GetInt()); + _operand->setBool(op1->getInt() != op2->getInt()); } */ - _operand->SetBool(CScValue::Compare(op1, op2) != 0); + _operand->setBool(CScValue::compare(op1, op2) != 0); _stack->push(_operand); break; @@ -944,13 +944,13 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() < op2->GetFloat()); + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); } - else _operand->SetBool(op1->GetInt() < op2->GetInt()); + else _operand->setBool(op1->getInt() < op2->getInt()); */ - _operand->SetBool(CScValue::Compare(op1, op2) < 0); + _operand->setBool(CScValue::compare(op1, op2) < 0); _stack->push(_operand); break; @@ -959,13 +959,13 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() > op2->GetFloat()); + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); } - else _operand->SetBool(op1->GetInt() > op2->GetInt()); + else _operand->setBool(op1->getInt() > op2->getInt()); */ - _operand->SetBool(CScValue::Compare(op1, op2) > 0); + _operand->setBool(CScValue::compare(op1, op2) > 0); _stack->push(_operand); break; @@ -974,13 +974,13 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() <= op2->GetFloat()); + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); } - else _operand->SetBool(op1->GetInt() <= op2->GetInt()); + else _operand->setBool(op1->getInt() <= op2->getInt()); */ - _operand->SetBool(CScValue::Compare(op1, op2) <= 0); + _operand->setBool(CScValue::compare(op1, op2) <= 0); _stack->push(_operand); break; @@ -989,13 +989,13 @@ HRESULT CScScript::ExecuteInstruction() { op1 = _stack->pop(); /* - if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ - _operand->SetBool(op1->GetFloat() >= op2->GetFloat()); + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); } - else _operand->SetBool(op1->GetInt() >= op2->GetInt()); + else _operand->setBool(op1->getInt() >= op2->getInt()); */ - _operand->SetBool(CScValue::Compare(op1, op2) >= 0); + _operand->setBool(CScValue::compare(op1, op2) >= 0); _stack->push(_operand); break; @@ -1003,8 +1003,8 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); - _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) == 0); _stack->push(_operand); break; @@ -1013,8 +1013,8 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); - _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) != 0); _stack->push(_operand); break; @@ -1077,17 +1077,17 @@ CScValue *CScScript::GetVar(char *name) { // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->PropExists(name)) ret = _scopeStack->getTop()->GetProp(name); + if (_scopeStack->getTop()->propExists(name)) ret = _scopeStack->getTop()->getProp(name); } // script globals if (ret == NULL) { - if (_globals->PropExists(name)) ret = _globals->GetProp(name); + if (_globals->propExists(name)) ret = _globals->getProp(name); } // engine globals if (ret == NULL) { - if (_engine->_globals->PropExists(name)) ret = _engine->_globals->GetProp(name); + if (_engine->_globals->propExists(name)) ret = _engine->_globals->getProp(name); } if (ret == NULL) { @@ -1096,11 +1096,11 @@ CScValue *CScScript::GetVar(char *name) { CScValue *Val = new CScValue(Game); CScValue *Scope = _scopeStack->getTop(); if (Scope) { - Scope->SetProp(name, Val); - ret = _scopeStack->getTop()->GetProp(name); + Scope->setProp(name, Val); + ret = _scopeStack->getTop()->getProp(name); } else { - _globals->SetProp(name, Val); - ret = _globals->GetProp(name); + _globals->setProp(name, Val); + ret = _globals->getProp(name); } delete Val; } @@ -1352,29 +1352,29 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: CScValue *Val = stack->pop(); switch (Function->params[i]) { case TYPE_BOOL: - Buffer->PutDWORD((uint32)Val->GetBool()); + Buffer->PutDWORD((uint32)Val->getBool()); break; case TYPE_LONG: - Buffer->PutDWORD(Val->GetInt()); + Buffer->PutDWORD(Val->getInt()); break; case TYPE_BYTE: - Buffer->PutDWORD((byte)Val->GetInt()); + Buffer->PutDWORD((byte)Val->getInt()); break; case TYPE_STRING: - if (Val->IsNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->GetString()); + if (Val->isNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->getString()); break; case TYPE_MEMBUFFER: - if (Val->IsNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->GetMemBuffer()); + if (Val->isNULL()) Buffer->PutDWORD(0); + else Buffer->PutDWORD((uint32)Val->getMemBuffer()); break; case TYPE_FLOAT: { - float f = Val->GetFloat(); + float f = Val->getFloat(); Buffer->PutDWORD(*((uint32 *)&f)); break; } case TYPE_DOUBLE: { - double d = Val->GetFloat(); + double d = Val->getFloat(); uint32 *pd = (uint32 *)&d; Buffer->PutDWORD(pd[0]); @@ -1527,7 +1527,7 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::CopyParameters(CScStack *stack) { int i; - int NumParams = stack->pop()->GetInt(); + int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { _stack->push(stack->getAt(i)); } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index dc953ed8d0..c00f0656e0 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -71,10 +71,10 @@ void CScStack::push(CScValue *val) { if (_sP < _values.GetSize()) { _values[_sP]->cleanup(); - _values[_sP]->Copy(val); + _values[_sP]->copy(val); } else { CScValue *copyVal = new CScValue(Game); - copyVal->Copy(val); + copyVal->copy(val); _values.Add(copyVal); } } @@ -111,7 +111,7 @@ CScValue *CScStack::getAt(int index) { ////////////////////////////////////////////////////////////////////////// void CScStack::correctParams(uint32 expected_params) { - int nu_params = pop()->GetInt(); + int nu_params = pop()->getInt(); if (expected_params < nu_params) { // too many params while (expected_params < nu_params) { @@ -125,7 +125,7 @@ void CScStack::correctParams(uint32 expected_params) { while (expected_params > nu_params) { //Push(null_val); CScValue *null_val = new CScValue(Game); - null_val->SetNULL(); + null_val->setNULL(); _values.InsertAt(_sP - nu_params + 1, null_val); nu_params++; _sP++; @@ -143,11 +143,11 @@ void CScStack::correctParams(uint32 expected_params) { void CScStack::pushNULL() { /* CScValue* val = new CScValue(Game); - val->SetNULL(); + val->setNULL(); Push(val); delete val; */ - getPushValue()->SetNULL(); + getPushValue()->setNULL(); } @@ -155,11 +155,11 @@ void CScStack::pushNULL() { void CScStack::pushInt(int val) { /* CScValue* val = new CScValue(Game); - val->SetInt(Val); + val->setInt(Val); Push(val); delete val; */ - getPushValue()->SetInt(val); + getPushValue()->setInt(val); } @@ -167,11 +167,11 @@ void CScStack::pushInt(int val) { void CScStack::pushFloat(double val) { /* CScValue* val = new CScValue(Game); - val->SetFloat(Val); + val->setFloat(Val); Push(val); delete val; */ - getPushValue()->SetFloat(val); + getPushValue()->setFloat(val); } @@ -179,11 +179,11 @@ void CScStack::pushFloat(double val) { void CScStack::pushBool(bool val) { /* CScValue* val = new CScValue(Game); - val->SetBool(Val); + val->setBool(Val); Push(val); delete val; */ - getPushValue()->SetBool(val); + getPushValue()->setBool(val); } @@ -191,11 +191,11 @@ void CScStack::pushBool(bool val) { void CScStack::pushString(const char *val) { /* CScValue* val = new CScValue(Game); - val->SetString(Val); + val->setString(Val); Push(val); delete val; */ - getPushValue()->SetString(val); + getPushValue()->setString(val); } @@ -203,12 +203,12 @@ void CScStack::pushString(const char *val) { void CScStack::pushNative(CBScriptable *val, bool persistent) { /* CScValue* val = new CScValue(Game); - val->SetNative(Val, Persistent); + val->setNative(Val, Persistent); Push(val); delete val; */ - getPushValue()->SetNative(val, persistent); + getPushValue()->setNative(val, persistent); } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index aede849ecc..04872fb4ae 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -58,9 +58,9 @@ CScValue::CScValue(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { +CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { _type = VAL_BOOL; - _valBool = Val; + _valBool = val; _valInt = 0; _valFloat = 0.0f; @@ -73,9 +73,9 @@ CScValue::CScValue(CBGame *inGame, bool Val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { +CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { _type = VAL_INT; - _valInt = Val; + _valInt = val; _valFloat = 0.0f; _valBool = false; @@ -88,9 +88,9 @@ CScValue::CScValue(CBGame *inGame, int Val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { +CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { _type = VAL_FLOAT; - _valFloat = Val; + _valFloat = val; _valInt = 0; _valBool = false; @@ -103,10 +103,10 @@ CScValue::CScValue(CBGame *inGame, double Val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { +CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { _type = VAL_STRING; _valString = NULL; - SetStringVal(Val); + setStringVal(val); _valBool = false; _valInt = 0; @@ -119,12 +119,12 @@ CScValue::CScValue(CBGame *inGame, const char *Val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool IgnoreNatives) { - DeleteProps(); +void CScValue::cleanup(bool ignoreNatives) { + deleteProps(); if (_valString) delete [] _valString; - if (!IgnoreNatives) { + if (!ignoreNatives) { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { @@ -156,8 +156,8 @@ CScValue::~CScValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::GetProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetProp(name); +CScValue *CScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); if (_type == VAL_STRING && strcmp(name, "Length") == 0) { Game->_scValue->_type = VAL_INT; @@ -167,10 +167,10 @@ CScValue *CScValue::GetProp(const char *name) { #else if (true) { #endif - Game->_scValue->SetInt(strlen(_valString)); + Game->_scValue->setInt(strlen(_valString)); } else { WideString wstr = StringUtil::Utf8ToWide(_valString); - Game->_scValue->SetInt(wstr.size()); + Game->_scValue->setInt(wstr.size()); } return Game->_scValue; @@ -188,8 +188,8 @@ CScValue *CScValue::GetProp(const char *name) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DeleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->DeleteProp(name); +HRESULT CScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { @@ -203,8 +203,8 @@ HRESULT CScValue::DeleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::SetProp(const char *name, CScValue *Val, bool CopyWhole, bool SetAsConst) { - if (_type == VAL_VARIABLE_REF) return _valRef->SetProp(name, Val); +HRESULT CScValue::setProp(const char *name, CScValue *Val, bool CopyWhole, bool SetAsConst) { + if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, Val); HRESULT ret = E_FAIL; if (_type == VAL_NATIVE && _valNative) { @@ -221,7 +221,7 @@ HRESULT CScValue::SetProp(const char *name, CScValue *Val, bool CopyWhole, bool if (!val) val = new CScValue(Game); else val->cleanup(); - val->Copy(Val, CopyWhole); + val->copy(Val, CopyWhole); val->_isConstVar = SetAsConst; _valObject[name] = val; @@ -247,8 +247,8 @@ HRESULT CScValue::SetProp(const char *name, CScValue *Val, bool CopyWhole, bool ////////////////////////////////////////////////////////////////////////// -bool CScValue::PropExists(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->PropExists(name); +bool CScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->propExists(name); _valIter = _valObject.find(name); return (_valIter != _valObject.end()); @@ -256,7 +256,7 @@ bool CScValue::PropExists(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CScValue::DeleteProps() { +void CScValue::deleteProps() { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { delete(CScValue *)_valIter->_value; @@ -270,170 +270,170 @@ void CScValue::DeleteProps() { void CScValue::CleanProps(bool IncludingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->IsNative() || IncludingNatives)) _valIter->_value->SetNULL(); + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || IncludingNatives)) _valIter->_value->setNULL(); _valIter++; } } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsNULL() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsNULL(); +bool CScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) return _valRef->isNULL(); return (_type == VAL_NULL); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsNative(); +bool CScValue::isNative() { + if (_type == VAL_VARIABLE_REF) return _valRef->isNative(); return (_type == VAL_NATIVE); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsString() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsString(); +bool CScValue::isString() { + if (_type == VAL_VARIABLE_REF) return _valRef->isString(); return (_type == VAL_STRING); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsFloat() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsFloat(); +bool CScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) return _valRef->isFloat(); return (_type == VAL_FLOAT); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsInt() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsInt(); +bool CScValue::isInt() { + if (_type == VAL_VARIABLE_REF) return _valRef->isInt(); return (_type == VAL_INT); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsBool() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsBool(); +bool CScValue::isBool() { + if (_type == VAL_VARIABLE_REF) return _valRef->isBool(); return (_type == VAL_BOOL); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::IsObject() { - if (_type == VAL_VARIABLE_REF) return _valRef->IsObject(); +bool CScValue::isObject() { + if (_type == VAL_VARIABLE_REF) return _valRef->isObject(); return (_type == VAL_OBJECT); } ////////////////////////////////////////////////////////////////////////// -TValType CScValue::GetTypeTolerant() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetType(); +TValType CScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) return _valRef->getType(); return _type; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetBool(bool Val) { +void CScValue::setBool(bool val) { if (_type == VAL_VARIABLE_REF) { - _valRef->SetBool(Val); + _valRef->setBool(val); return; } if (_type == VAL_NATIVE) { - _valNative->scSetBool(Val); + _valNative->scSetBool(val); return; } - _valBool = Val; + _valBool = val; _type = VAL_BOOL; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetInt(int Val) { +void CScValue::setInt(int val) { if (_type == VAL_VARIABLE_REF) { - _valRef->SetInt(Val); + _valRef->setInt(val); return; } if (_type == VAL_NATIVE) { - _valNative->scSetInt(Val); + _valNative->scSetInt(val); return; } - _valInt = Val; + _valInt = val; _type = VAL_INT; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetFloat(double Val) { +void CScValue::setFloat(double val) { if (_type == VAL_VARIABLE_REF) { - _valRef->SetFloat(Val); + _valRef->setFloat(val); return; } if (_type == VAL_NATIVE) { - _valNative->scSetFloat(Val); + _valNative->scSetFloat(val); return; } - _valFloat = Val; + _valFloat = val; _type = VAL_FLOAT; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetString(const char *Val) { +void CScValue::setString(const char *val) { if (_type == VAL_VARIABLE_REF) { - _valRef->SetString(Val); + _valRef->setString(val); return; } if (_type == VAL_NATIVE) { - _valNative->scSetString(Val); + _valNative->scSetString(val); return; } - SetStringVal(Val); + setStringVal(val); if (_valString) _type = VAL_STRING; else _type = VAL_NULL; } -void CScValue::SetString(const Common::String &Val) { - SetString(Val.c_str()); +void CScValue::setString(const Common::String &val) { + setString(val.c_str()); } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetStringVal(const char *Val) { +void CScValue::setStringVal(const char *val) { if (_valString) { delete [] _valString; _valString = NULL; } - if (Val == NULL) { + if (val == NULL) { _valString = NULL; return; } - _valString = new char [strlen(Val) + 1]; + _valString = new char [strlen(val) + 1]; if (_valString) { - strcpy(_valString, Val); + strcpy(_valString, val); } } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetNULL() { +void CScValue::setNULL() { if (_type == VAL_VARIABLE_REF) { - _valRef->SetNULL(); + _valRef->setNULL(); return; } @@ -442,21 +442,21 @@ void CScValue::SetNULL() { if (_valNative->_refCount <= 0) delete _valNative; } _valNative = NULL; - DeleteProps(); + deleteProps(); _type = VAL_NULL; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetNative(CBScriptable *Val, bool Persistent) { +void CScValue::setNative(CBScriptable *Val, bool Persistent) { if (_type == VAL_VARIABLE_REF) { - _valRef->SetNative(Val, Persistent); + _valRef->setNative(Val, Persistent); return; } if (Val == NULL) { - SetNULL(); + setNULL(); } else { if (_valNative && !_persistent) { _valNative->_refCount--; @@ -476,27 +476,27 @@ void CScValue::SetNative(CBScriptable *Val, bool Persistent) { ////////////////////////////////////////////////////////////////////////// -void CScValue::SetObject() { +void CScValue::setObject() { if (_type == VAL_VARIABLE_REF) { - _valRef->SetObject(); + _valRef->setObject(); return; } - DeleteProps(); + deleteProps(); _type = VAL_OBJECT; } ////////////////////////////////////////////////////////////////////////// -void CScValue::SetReference(CScValue *Val) { +void CScValue::setReference(CScValue *Val) { _valRef = Val; _type = VAL_VARIABLE_REF; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::GetBool(bool Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetBool(); +bool CScValue::getBool(bool Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->getBool(); switch (_type) { case VAL_BOOL: @@ -521,8 +521,8 @@ bool CScValue::GetBool(bool Default) { ////////////////////////////////////////////////////////////////////////// -int CScValue::GetInt(int Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetInt(); +int CScValue::getInt(int Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); switch (_type) { case VAL_BOOL: @@ -547,8 +547,8 @@ int CScValue::GetInt(int Default) { ////////////////////////////////////////////////////////////////////////// -double CScValue::GetFloat(double Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->GetFloat(); +double CScValue::getFloat(double Default) { + if (_type == VAL_VARIABLE_REF) return _valRef->getFloat(); switch (_type) { case VAL_BOOL: @@ -572,8 +572,8 @@ double CScValue::GetFloat(double Default) { } ////////////////////////////////////////////////////////////////////////// -void *CScValue::GetMemBuffer() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetMemBuffer(); +void *CScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) return _valRef->getMemBuffer(); if (_type == VAL_NATIVE) return _valNative->scToMemBuffer(); else return (void *)NULL; @@ -581,40 +581,40 @@ void *CScValue::GetMemBuffer() { ////////////////////////////////////////////////////////////////////////// -const char *CScValue::GetString() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetString(); +const char *CScValue::getString() { + if (_type == VAL_VARIABLE_REF) return _valRef->getString(); switch (_type) { case VAL_OBJECT: - SetStringVal("[object]"); + setStringVal("[object]"); break; case VAL_NULL: - SetStringVal("[null]"); + setStringVal("[null]"); break; case VAL_NATIVE: { const char *StrVal = _valNative->scToString(); - SetStringVal(StrVal); + setStringVal(StrVal); return StrVal; break; } case VAL_BOOL: - SetStringVal(_valBool ? "yes" : "no"); + setStringVal(_valBool ? "yes" : "no"); break; case VAL_INT: { char dummy[50]; sprintf(dummy, "%d", _valInt); - SetStringVal(dummy); + setStringVal(dummy); break; } case VAL_FLOAT: { char dummy[50]; sprintf(dummy, "%f", _valFloat); - SetStringVal(dummy); + setStringVal(dummy); break; } @@ -622,7 +622,7 @@ const char *CScValue::GetString() { break; default: - SetStringVal(""); + setStringVal(""); } return _valString; @@ -630,8 +630,8 @@ const char *CScValue::GetString() { ////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::GetNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->GetNative(); +CBScriptable *CScValue::getNative() { + if (_type == VAL_VARIABLE_REF) return _valRef->getNative(); if (_type == VAL_NATIVE) return _valNative; else return NULL; @@ -639,13 +639,13 @@ CBScriptable *CScValue::GetNative() { ////////////////////////////////////////////////////////////////////////// -TValType CScValue::GetType() { +TValType CScValue::getType() { return _type; } ////////////////////////////////////////////////////////////////////////// -void CScValue::Copy(CScValue *orig, bool CopyWhole) { +void CScValue::copy(CScValue *orig, bool copyWhole) { Game = orig->Game; if (_valNative && !_persistent) { @@ -656,7 +656,7 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { } } - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && CopyWhole) orig = orig->_valRef; + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; cleanup(true); @@ -664,7 +664,7 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { _valBool = orig->_valBool; _valInt = orig->_valInt; _valFloat = orig->_valFloat; - SetStringVal(orig->_valString); + setStringVal(orig->_valString); _valRef = orig->_valRef; _persistent = orig->_persistent; @@ -678,7 +678,7 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { orig->_valIter = orig->_valObject.begin(); while (orig->_valIter != orig->_valObject.end()) { _valObject[orig->_valIter->_key] = new CScValue(Game); - _valObject[orig->_valIter->_key]->Copy(orig->_valIter->_value); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } } else _valObject.clear(); @@ -686,34 +686,34 @@ void CScValue::Copy(CScValue *orig, bool CopyWhole) { ////////////////////////////////////////////////////////////////////////// -void CScValue::SetValue(CScValue *Val) { - if (Val->_type == VAL_VARIABLE_REF) { - SetValue(Val->_valRef); +void CScValue::setValue(CScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); return; } // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (Val->_type == VAL_INT || Val->_type == VAL_STRING || Val->_type == VAL_BOOL)) { - switch (Val->_type) { + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { case VAL_INT: - _valNative->scSetInt(Val->GetInt()); + _valNative->scSetInt(val->getInt()); break; case VAL_FLOAT: - _valNative->scSetFloat(Val->GetFloat()); + _valNative->scSetFloat(val->getFloat()); break; case VAL_BOOL: - _valNative->scSetBool(Val->GetBool()); + _valNative->scSetBool(val->getBool()); break; case VAL_STRING: - _valNative->scSetString(Val->GetString()); + _valNative->scSetString(val->getString()); break; default: - warning("CScValue::SetValue - unhandled enum"); + warning("CScValue::setValue - unhandled enum"); break; } } // otherwise just copy everything - else Copy(Val); + else copy(val); } @@ -802,13 +802,13 @@ HRESULT CScValue::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::saveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CScValue::saveAsText(CBDynBuffer *buffer, int indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - Buffer->putTextIndent(Indent, "PROPERTY {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _valIter->_value->GetString()); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); _valIter++; } @@ -818,45 +818,45 @@ HRESULT CScValue::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// // -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::Compare(CScValue *Val1, CScValue *Val2) { +int CScValue::compare(CScValue *val1, CScValue *val2) { // both natives? - if (Val1->IsNative() && Val2->IsNative()) { + if (val1->isNative() && val2->isNative()) { // same class? - if (strcmp(Val1->GetNative()->getClassName(), Val2->GetNative()->getClassName()) == 0) { - return Val1->GetNative()->scCompare(Val2->GetNative()); - } else return strcmp(Val1->GetString(), Val2->GetString()); + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else return strcmp(val1->getString(), val2->getString()); } // both objects? - if (Val1->IsObject() && Val2->IsObject()) return -1; + if (val1->isObject() && val2->isObject()) return -1; // null states - if (Val1->IsNULL() && !Val2->IsNULL()) return -1; - else if (!Val1->IsNULL() && Val2->IsNULL()) return 1; - else if (Val1->IsNULL() && Val2->IsNULL()) return 0; + if (val1->isNULL() && !val2->isNULL()) return -1; + else if (!val1->isNULL() && val2->isNULL()) return 1; + else if (val1->isNULL() && val2->isNULL()) return 0; // one of them is string? convert both to string - if (Val1->IsString() || Val2->IsString()) return strcmp(Val1->GetString(), Val2->GetString()); + if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); // one of them is float? - if (Val1->IsFloat() || Val2->IsFloat()) { - if (Val1->GetFloat() < Val2->GetFloat()) return -1; - else if (Val1->GetFloat() > Val2->GetFloat()) return 1; + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) return -1; + else if (val1->getFloat() > val2->getFloat()) return 1; else return 0; } // otherwise compare as int's - if (Val1->GetInt() < Val2->GetInt()) return -1; - else if (Val1->GetInt() > Val2->GetInt()) return 1; + if (val1->getInt() < val2->getInt()) return -1; + else if (val1->getInt() > val2->getInt()) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -int CScValue::CompareStrict(CScValue *Val1, CScValue *Val2) { - if (Val1->GetTypeTolerant() != Val2->GetTypeTolerant()) return -1; - else return CScValue::Compare(Val1, Val2); +int CScValue::compareStrict(CScValue *val1, CScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; + else return CScValue::compare(val1, val2); } @@ -872,43 +872,43 @@ HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariable ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *propName, int value) { +bool CScValue::setProperty(const char *propName, int value) { CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(SetProp(propName, Val)); + bool Ret = SUCCEEDED(setProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *propName, const char *value) { +bool CScValue::setProperty(const char *propName, const char *value) { CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(SetProp(propName, Val)); + bool Ret = SUCCEEDED(setProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *propName, double value) { +bool CScValue::setProperty(const char *propName, double value) { CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(SetProp(propName, Val)); + bool Ret = SUCCEEDED(setProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *propName, bool value) { +bool CScValue::setProperty(const char *propName, bool value) { CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(SetProp(propName, Val)); + bool Ret = SUCCEEDED(setProp(propName, Val)); delete Val; return Ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::SetProperty(const char *propName) { +bool CScValue::setProperty(const char *propName) { CScValue *Val = new CScValue(Game); - bool Ret = SUCCEEDED(SetProp(propName, Val)); + bool Ret = SUCCEEDED(setProp(propName, Val)); delete Val; return Ret; } @@ -918,7 +918,7 @@ bool CScValue::SetProperty(const char *propName) { // IWmeDebugProp ////////////////////////////////////////////////////////////////////////// EWmeDebuggerPropType CScValue::DbgGetType() { - switch (GetType()) { + switch (getType()) { case VAL_NULL: return WME_DBGPROP_NULL; case VAL_STRING: @@ -940,56 +940,56 @@ EWmeDebuggerPropType CScValue::DbgGetType() { ////////////////////////////////////////////////////////////////////////// int CScValue::DbgGetValInt() { - return GetInt(); + return getInt(); } ////////////////////////////////////////////////////////////////////////// double CScValue::DbgGetValFloat() { - return GetFloat(); + return getFloat(); } ////////////////////////////////////////////////////////////////////////// bool CScValue::DbgGetValBool() { - return GetBool(); + return getBool(); } ////////////////////////////////////////////////////////////////////////// const char *CScValue::DbgGetValString() { - return GetString(); + return getString(); } ////////////////////////////////////////////////////////////////////////// IWmeDebugObject *CScValue::DbgGetValNative() { - return GetNative(); + return getNative(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(int Value) { - SetInt(Value); +bool CScValue::DbgSetVal(int value) { + setInt(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(double Value) { - SetFloat(Value); +bool CScValue::DbgSetVal(double value) { + setFloat(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(bool Value) { - SetBool(Value); +bool CScValue::DbgSetVal(bool value) { + setBool(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(const char *Value) { - SetString(Value); +bool CScValue::DbgSetVal(const char *value) { + setString(value); return true; } ////////////////////////////////////////////////////////////////////////// bool CScValue::DbgSetVal() { - SetNULL(); + setNULL(); return true; } @@ -1020,13 +1020,13 @@ bool CScValue::DbgGetProperty(int index, const char **name, IWmeDebugProp **valu } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetDescription(char *Buf, int BufSize) { - if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(Buf, BufSize); +bool CScValue::DbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(buf, bufSize); if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(Buf, BufSize); + _valNative->scDebuggerDesc(buf, bufSize); } else { - strncpy(Buf, GetString(), BufSize); + strncpy(buf, getString(), bufSize); } return true; } diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 90c783c9ce..3c25a4d1e7 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -43,49 +43,49 @@ class CBScriptable; class CScValue : public CBBase, public IWmeDebugProp { public: - HRESULT DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *script, unsigned int ScopeID); + HRESULT DbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); - static int Compare(CScValue *Val1, CScValue *Val2); - static int CompareStrict(CScValue *Val1, CScValue *Val2); - TValType GetTypeTolerant(); + static int compare(CScValue *Val1, CScValue *Val2); + static int compareStrict(CScValue *Val1, CScValue *Val2); + TValType getTypeTolerant(); void cleanup(bool IgnoreNatives = false); DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - void SetValue(CScValue *Val); + void setValue(CScValue *Val); bool _persistent; - bool PropExists(const char *name); - void Copy(CScValue *orig, bool CopyWhole = false); - void SetStringVal(const char *Val); - TValType GetType(); - bool GetBool(bool Default = false); - int GetInt(int Default = 0); - double GetFloat(double Default = 0.0f); - const char *GetString(); - void *GetMemBuffer(); - CBScriptable *GetNative(); - HRESULT DeleteProp(const char *name); - void DeleteProps(); - void CleanProps(bool IncludingNatives); - void SetBool(bool Val); - void SetInt(int Val); - void SetFloat(double Val); - void SetString(const char *Val); - void SetString(const Common::String &Val); - void SetNULL(); - void SetNative(CBScriptable *Val, bool Persistent = false); - void SetObject(); - void SetReference(CScValue *Val); - bool IsNULL(); - bool IsNative(); - bool IsString(); - bool IsBool(); - bool IsFloat(); - bool IsInt(); - bool IsObject(); - HRESULT SetProp(const char *name, CScValue *Val, bool CopyWhole = false, bool SetAsConst = false); - CScValue *GetProp(const char *name); + bool propExists(const char *name); + void copy(CScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool Default = false); + int getInt(int Default = 0); + double getFloat(double Default = 0.0f); + const char *getString(); + void *getMemBuffer(); + CBScriptable *getNative(); + HRESULT deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(CBScriptable *val, bool persistent = false); + void setObject(); + void setReference(CScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + HRESULT setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + CScValue *getProp(const char *name); CBScriptable *_valNative; CScValue *_valRef; protected: @@ -104,11 +104,11 @@ public: Common::HashMap _valObject; Common::HashMap::iterator _valIter; - bool SetProperty(const char *PropName, int Value); - bool SetProperty(const char *PropName, const char *Value); - bool SetProperty(const char *PropName, double Value); - bool SetProperty(const char *PropName, bool Value); - bool SetProperty(const char *PropName); + bool setProperty(const char *PropName, int Value); + bool setProperty(const char *PropName, const char *Value); + bool setProperty(const char *PropName, double Value); + bool setProperty(const char *PropName, bool Value); + bool setProperty(const char *PropName); // IWmeDebugProp interface implementation diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index b4fd782f76..7f61a81b19 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -44,9 +44,9 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int NumParams = stack->pop()->GetInt(0); + int NumParams = stack->pop()->getInt(0); for (int i = 0; i < NumParams; i++) { - addScript(stack->pop()->GetString()); + addScript(stack->pop()->getString()); } } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 538f8eb886..69809874bf 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -675,11 +675,11 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - if (Val->IsNULL()) { + if (Val->isNULL()) { _fontDisable = NULL; stack->pushBool(true); } else { - _fontDisable = Game->_fontStorage->AddFont(Val->GetString()); + _fontDisable = Game->_fontStorage->AddFont(Val->getString()); stack->pushBool(_fontDisable != NULL); } return S_OK; @@ -693,11 +693,11 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - if (Val->IsNULL()) { + if (Val->isNULL()) { _fontHover = NULL; stack->pushBool(true); } else { - _fontHover = Game->_fontStorage->AddFont(Val->GetString()); + _fontHover = Game->_fontStorage->AddFont(Val->getString()); stack->pushBool(_fontHover != NULL); } return S_OK; @@ -711,11 +711,11 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - if (Val->IsNULL()) { + if (Val->isNULL()) { _fontPress = NULL; stack->pushBool(true); } else { - _fontPress = Game->_fontStorage->AddFont(Val->GetString()); + _fontPress = Game->_fontStorage->AddFont(Val->getString()); stack->pushBool(_fontPress != NULL); } return S_OK; @@ -729,11 +729,11 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); - if (Val->IsNULL()) { + if (Val->isNULL()) { _fontFocus = NULL; stack->pushBool(true); } else { - _fontFocus = Game->_fontStorage->AddFont(Val->GetString()); + _fontFocus = Game->_fontStorage->AddFont(Val->getString()); stack->pushBool(_fontFocus != NULL); } return S_OK; @@ -747,7 +747,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageDisable; _imageDisable = new CBSprite(Game); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) { delete _imageDisable; _imageDisable = NULL; @@ -788,7 +788,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageHover; _imageHover = new CBSprite(Game); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) { delete _imageHover; _imageHover = NULL; @@ -828,7 +828,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imagePress; _imagePress = new CBSprite(Game); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) { delete _imagePress; _imagePress = NULL; @@ -868,7 +868,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageFocus; _imageFocus = new CBSprite(Game); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) { delete _imageFocus; _imageFocus = NULL; @@ -922,13 +922,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CUIButton::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("button"); + _scValue->setString("button"); return _scValue; } @@ -936,7 +936,7 @@ CScValue *CUIButton::scGetProperty(const char *name) { // TextAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextAlign") == 0) { - _scValue->SetInt(_align); + _scValue->setInt(_align); return _scValue; } @@ -944,21 +944,21 @@ CScValue *CUIButton::scGetProperty(const char *name) { // Focusable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Focusable") == 0) { - _scValue->SetBool(_canFocus); + _scValue->setBool(_canFocus); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pressed") == 0) { - _scValue->SetBool(_stayPressed); + _scValue->setBool(_stayPressed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->SetBool(_pixelPerfect); + _scValue->setBool(_pixelPerfect); return _scValue; } @@ -972,7 +972,7 @@ HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { // TextAlign ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { - int i = value->GetInt(); + int i = value->getInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _align = (TTextAlign)i; return S_OK; @@ -982,21 +982,21 @@ HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { // Focusable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Focusable") == 0) { - _canFocus = value->GetBool(); + _canFocus = value->getBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pressed") == 0) { - _stayPressed = value->GetBool(); + _stayPressed = value->getBool(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { - _pixelPerfect = value->GetBool(); + _pixelPerfect = value->getBool(); return S_OK; } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index eb59724089..c17bd405ab 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -369,7 +369,7 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont(stack->pop()->GetString()); + _fontSelected = Game->_fontStorage->AddFont(stack->pop()->getString()); stack->pushBool(_fontSelected != NULL); return S_OK; @@ -381,13 +381,13 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CUIEdit::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("editor"); + _scValue->setString("editor"); return _scValue; } @@ -395,7 +395,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // SelStart ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelStart") == 0) { - _scValue->SetInt(_selStart); + _scValue->setInt(_selStart); return _scValue; } @@ -403,7 +403,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // SelEnd ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelEnd") == 0) { - _scValue->SetInt(_selEnd); + _scValue->setInt(_selEnd); return _scValue; } @@ -411,7 +411,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorBlinkRate") == 0) { - _scValue->SetInt(_cursorBlinkRate); + _scValue->setInt(_cursorBlinkRate); return _scValue; } @@ -419,7 +419,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // CursorChar ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorChar") == 0) { - _scValue->SetString(_cursorChar); + _scValue->setString(_cursorChar); return _scValue; } @@ -427,7 +427,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // FrameWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FrameWidth") == 0) { - _scValue->SetInt(_frameWidth); + _scValue->setInt(_frameWidth); return _scValue; } @@ -435,7 +435,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // MaxLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxLength") == 0) { - _scValue->SetInt(_maxLength); + _scValue->setInt(_maxLength); return _scValue; } @@ -445,9 +445,9 @@ CScValue *CUIEdit::scGetProperty(const char *name) { else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::AnsiToWide(_text); - _scValue->SetString(StringUtil::WideToUtf8(wstr).c_str()); + _scValue->setString(StringUtil::WideToUtf8(wstr).c_str()); } else { - _scValue->SetString(_text); + _scValue->setString(_text); } return _scValue; } @@ -462,7 +462,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // SelStart ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelStart") == 0) { - _selStart = value->GetInt(); + _selStart = value->getInt(); _selStart = MAX(_selStart, 0); _selStart = MIN((size_t)_selStart, strlen(_text)); return S_OK; @@ -472,7 +472,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // SelEnd ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelEnd") == 0) { - _selEnd = value->GetInt(); + _selEnd = value->getInt(); _selEnd = MAX(_selEnd, 0); _selEnd = MIN((size_t)_selEnd, strlen(_text)); return S_OK; @@ -482,7 +482,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = value->GetInt(); + _cursorBlinkRate = value->getInt(); return S_OK; } @@ -490,7 +490,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // CursorChar ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorChar") == 0) { - setCursorChar(value->GetString()); + setCursorChar(value->getString()); return S_OK; } @@ -498,7 +498,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // FrameWidth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FrameWidth") == 0) { - _frameWidth = value->GetInt(); + _frameWidth = value->getInt(); return S_OK; } @@ -506,7 +506,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { // MaxLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxLength") == 0) { - _maxLength = value->GetInt(); + _maxLength = value->getInt(); return S_OK; } @@ -515,10 +515,10 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(value->GetString()); + WideString wstr = StringUtil::Utf8ToWide(value->getString()); setText(StringUtil::WideToAnsi(wstr).c_str()); } else { - setText(value->GetString()); + setText(value->getString()); } return S_OK; } diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 305f9642a5..a2b065dd3d 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -270,7 +270,7 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "SetEntity") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (SUCCEEDED(setEntity(Filename))) stack->pushBool(true); @@ -286,13 +286,13 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CUIEntity::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("entity container"); + _scValue->setString("entity container"); return _scValue; } @@ -300,8 +300,8 @@ CScValue *CUIEntity::scGetProperty(const char *name) { // Freezable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Freezable") == 0) { - if (_entity) _scValue->SetBool(_entity->_freezable); - else _scValue->SetBool(false); + if (_entity) _scValue->setBool(_entity->_freezable); + else _scValue->setBool(false); return _scValue; } @@ -315,7 +315,7 @@ HRESULT CUIEntity::scSetProperty(const char *name, CScValue *value) { // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Freezable") == 0) { - if (_entity) _entity->makeFreezable(value->GetBool()); + if (_entity) _entity->makeFreezable(value->getBool()); return S_OK; } else return CUIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index a713649604..0a387c48c8 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -146,11 +146,11 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); if (_font) Game->_fontStorage->RemoveFont(_font); - if (Val->IsNULL()) { + if (Val->isNULL()) { _font = NULL; stack->pushBool(true); } else { - _font = Game->_fontStorage->AddFont(Val->GetString()); + _font = Game->_fontStorage->AddFont(Val->getString()); stack->pushBool(_font != NULL); } return S_OK; @@ -163,17 +163,17 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - /* const char *Filename = */ Val->GetString(); + /* const char *Filename = */ Val->getString(); delete _image; _image = NULL; - if (Val->IsNULL()) { + if (Val->isNULL()) { stack->pushBool(true); return S_OK; } _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile(Val->GetString()))) { + if (!_image || FAILED(_image->loadFile(Val->getString()))) { delete _image; _image = NULL; stack->pushBool(false); @@ -227,8 +227,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th bool found = false; CScValue *val = stack->pop(); // find directly - if (val->IsNative()) { - CUIObject *widget = (CUIObject *)val->GetNative(); + if (val->isNative()) { + CUIObject *widget = (CUIObject *)val->getNative(); for (i = 0; i < win->_widgets.GetSize(); i++) { if (win->_widgets[i] == widget) { found = true; @@ -238,7 +238,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } // find by name else { - const char *name = val->GetString(); + const char *name = val->getString(); for (i = 0; i < win->_widgets.GetSize(); i++) { if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { found = true; @@ -318,13 +318,13 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CUIObject::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("ui_object"); + _scValue->setString("ui_object"); return _scValue; } @@ -332,7 +332,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->SetString(_name); + _scValue->setString(_name); return _scValue; } @@ -340,7 +340,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Parent (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Parent") == 0) { - _scValue->SetNative(_parent, true); + _scValue->setNative(_parent, true); return _scValue; } @@ -348,7 +348,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // ParentNotify ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParentNotify") == 0) { - _scValue->SetBool(_parentNotify); + _scValue->setBool(_parentNotify); return _scValue; } @@ -356,7 +356,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _scValue->SetInt(_width); + _scValue->setInt(_width); return _scValue; } @@ -364,7 +364,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _scValue->SetInt(_height); + _scValue->setInt(_height); return _scValue; } @@ -372,7 +372,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Visible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Visible") == 0) { - _scValue->SetBool(_visible); + _scValue->setBool(_visible); return _scValue; } @@ -380,7 +380,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Disabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Disabled") == 0) { - _scValue->SetBool(_disable); + _scValue->setBool(_disable); return _scValue; } @@ -388,7 +388,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { - _scValue->SetString(_text); + _scValue->setString(_text); return _scValue; } @@ -396,15 +396,15 @@ CScValue *CUIObject::scGetProperty(const char *name) { // NextSibling (RO) / PrevSibling (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { - _scValue->SetNULL(); + _scValue->setNULL(); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; for (int i = 0; i < win->_widgets.GetSize(); i++) { if (win->_widgets[i] == this) { if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.GetSize() - 1) _scValue->SetNative(win->_widgets[i + 1], true); + if (i < win->_widgets.GetSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); } else { - if (i > 0) _scValue->SetNative(win->_widgets[i - 1], true); + if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); } break; } @@ -423,7 +423,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -431,7 +431,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // ParentNotify ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParentNotify") == 0) { - _parentNotify = value->GetBool(); + _parentNotify = value->getBool(); return S_OK; } @@ -439,7 +439,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - _width = value->GetInt(); + _width = value->getInt(); return S_OK; } @@ -447,7 +447,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - _height = value->GetInt(); + _height = value->getInt(); return S_OK; } @@ -455,7 +455,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Visible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Visible") == 0) { - _visible = value->GetBool(); + _visible = value->getBool(); return S_OK; } @@ -463,7 +463,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Disabled ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Disabled") == 0) { - _disable = value->GetBool(); + _disable = value->getBool(); return S_OK; } @@ -471,7 +471,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { - setText(value->GetString()); + setText(value->getString()); return S_OK; } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 414a237556..0d7966188e 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -403,13 +403,13 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// CScValue *CUIText::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("static"); + _scValue->setString("static"); return _scValue; } @@ -417,7 +417,7 @@ CScValue *CUIText::scGetProperty(const char *name) { // TextAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextAlign") == 0) { - _scValue->SetInt(_textAlign); + _scValue->setInt(_textAlign); return _scValue; } @@ -425,7 +425,7 @@ CScValue *CUIText::scGetProperty(const char *name) { // VerticalAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VerticalAlign") == 0) { - _scValue->SetInt(_verticalAlign); + _scValue->setInt(_verticalAlign); return _scValue; } @@ -439,7 +439,7 @@ HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { // TextAlign ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { - int i = value->GetInt(); + int i = value->getInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _textAlign = (TTextAlign)i; return S_OK; @@ -449,7 +449,7 @@ HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { // VerticalAlign ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VerticalAlign") == 0) { - int i = value->GetInt(); + int i = value->getInt(); if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; _verticalAlign = (TVerticalAlign)i; return S_OK; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 24e2255d2b..ffa3df97c4 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -697,13 +697,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - if (val->GetType() == VAL_INT) { - int widget = val->GetInt(); + if (val->getType() == VAL_INT) { + int widget = val->getInt(); if (widget < 0 || widget >= _widgets.GetSize()) stack->pushNULL(); else stack->pushNative(_widgets[widget], true); } else { for (int i = 0; i < _widgets.GetSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) { + if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { stack->pushNative(_widgets[i], true); return S_OK; } @@ -721,7 +721,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont(stack->pop()->GetString()); + _fontInactive = Game->_fontStorage->AddFont(stack->pop()->getString()); stack->pushBool(_fontInactive != NULL); return S_OK; @@ -735,7 +735,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageInactive; _imageInactive = new CBSprite(Game); - const char *Filename = stack->pop()->GetString(); + const char *Filename = stack->pop()->getString(); if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) { delete _imageInactive; _imageInactive = NULL; @@ -818,8 +818,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); cleanup(); - if (!Val->IsNULL()) { - stack->pushBool(SUCCEEDED(loadFile(Val->GetString()))); + if (!Val->isNULL()) { + stack->pushBool(SUCCEEDED(loadFile(Val->getString()))); } else stack->pushBool(true); return S_OK; @@ -833,7 +833,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); CUIButton *Btn = new CUIButton(Game); - if (!Val->IsNULL()) Btn->setName(Val->GetString()); + if (!Val->isNULL()) Btn->setName(Val->getString()); stack->pushNative(Btn, true); Btn->_parent = this; @@ -850,7 +850,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); CUIText *Sta = new CUIText(Game); - if (!Val->IsNULL()) Sta->setName(Val->GetString()); + if (!Val->isNULL()) Sta->setName(Val->getString()); stack->pushNative(Sta, true); Sta->_parent = this; @@ -867,7 +867,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); CUIEdit *Edi = new CUIEdit(Game); - if (!Val->IsNULL()) Edi->setName(Val->GetString()); + if (!Val->isNULL()) Edi->setName(Val->getString()); stack->pushNative(Edi, true); Edi->_parent = this; @@ -884,7 +884,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *Val = stack->pop(); CUIWindow *Win = new CUIWindow(Game); - if (!Val->IsNULL()) Win->setName(Val->GetString()); + if (!Val->isNULL()) Win->setName(Val->getString()); stack->pushNative(Win, true); Win->_parent = this; @@ -899,13 +899,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - CUIObject *obj = (CUIObject *)val->GetNative(); + CUIObject *obj = (CUIObject *)val->getNative(); for (int i = 0; i < _widgets.GetSize(); i++) { if (_widgets[i] == obj) { delete _widgets[i]; _widgets.RemoveAt(i); - if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL(); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); } } stack->pushNULL(); @@ -918,13 +918,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CUIWindow::scGetProperty(const char *name) { - _scValue->SetNULL(); + _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Type") == 0) { - _scValue->SetString("window"); + _scValue->setString("window"); return _scValue; } @@ -932,7 +932,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { - _scValue->SetInt(_widgets.GetSize()); + _scValue->setInt(_widgets.GetSize()); return _scValue; } @@ -940,7 +940,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // Exclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exclusive") == 0) { - _scValue->SetBool(_mode == WINDOW_EXCLUSIVE); + _scValue->setBool(_mode == WINDOW_EXCLUSIVE); return _scValue; } @@ -948,7 +948,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // SystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SystemExclusive") == 0) { - _scValue->SetBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); + _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); return _scValue; } @@ -956,7 +956,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // Menu ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Menu") == 0) { - _scValue->SetBool(_isMenu); + _scValue->setBool(_isMenu); return _scValue; } @@ -964,7 +964,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // InGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InGame") == 0) { - _scValue->SetBool(_inGame); + _scValue->setBool(_inGame); return _scValue; } @@ -972,7 +972,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // PauseMusic ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0) { - _scValue->SetBool(_pauseMusic); + _scValue->setBool(_pauseMusic); return _scValue; } @@ -980,7 +980,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // ClipContents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClipContents") == 0) { - _scValue->SetBool(_clipContents); + _scValue->setBool(_clipContents); return _scValue; } @@ -988,7 +988,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // Transparent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Transparent") == 0) { - _scValue->SetBool(_transparent); + _scValue->setBool(_transparent); return _scValue; } @@ -996,7 +996,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // FadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeColor") == 0) { - _scValue->SetInt((int)_fadeColor); + _scValue->setInt((int)_fadeColor); return _scValue; } @@ -1010,7 +1010,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { - setName(value->GetString()); + setName(value->getString()); return S_OK; } @@ -1018,7 +1018,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // Menu ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Menu") == 0) { - _isMenu = value->GetBool(); + _isMenu = value->getBool(); return S_OK; } @@ -1026,7 +1026,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // InGame ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InGame") == 0) { - _inGame = value->GetBool(); + _inGame = value->getBool(); return S_OK; } @@ -1034,7 +1034,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // PauseMusic ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0) { - _pauseMusic = value->GetBool(); + _pauseMusic = value->getBool(); return S_OK; } @@ -1042,7 +1042,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // ClipContents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClipContents") == 0) { - _clipContents = value->GetBool(); + _clipContents = value->getBool(); return S_OK; } @@ -1050,7 +1050,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // Transparent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Transparent") == 0) { - _transparent = value->GetBool(); + _transparent = value->getBool(); return S_OK; } @@ -1058,7 +1058,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // FadeColor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeColor") == 0) { - _fadeColor = (uint32)value->GetInt(); + _fadeColor = (uint32)value->getInt(); _fadeBackground = (_fadeColor != 0); return S_OK; } @@ -1067,7 +1067,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // Exclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exclusive") == 0) { - if (value->GetBool()) + if (value->getBool()) goExclusive(); else { close(); @@ -1080,7 +1080,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { // SystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SystemExclusive") == 0) { - if (value->GetBool()) + if (value->getBool()) goSystemExclusive(); else { close(); -- cgit v1.2.3 From 13b16c1dc94df99e02a9ff6800d812e73c2fc922 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:39:30 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in SXMath --- engines/wintermute/Base/scriptables/SXMath.cpp | 24 ++++++++++++------------ engines/wintermute/Base/scriptables/SXMath.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index 92e6823534..b5a696ece2 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -120,7 +120,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cos") == 0) { stack->correctParams(1); - stack->pushFloat(cos(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -129,7 +129,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cosh") == 0) { stack->correctParams(1); - stack->pushFloat(cosh(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -186,7 +186,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sin") == 0) { stack->correctParams(1); - stack->pushFloat(sin(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sinh") == 0) { stack->correctParams(1); - stack->pushFloat(sinh(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -204,7 +204,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tan") == 0) { stack->correctParams(1); - stack->pushFloat(tan(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -213,7 +213,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tanh") == 0) { stack->correctParams(1); - stack->pushFloat(tanh(DegreeToRadian(stack->pop()->getFloat()))); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); return S_OK; } @@ -231,7 +231,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DegToRad") == 0) { stack->correctParams(1); - stack->pushFloat(DegreeToRadian(stack->pop()->getFloat())); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); return S_OK; } @@ -240,7 +240,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RadToDeg") == 0) { stack->correctParams(1); - stack->pushFloat(RadianToDegree(stack->pop()->getFloat())); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); return S_OK; } @@ -273,14 +273,14 @@ CScValue *CSXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -double CSXMath::DegreeToRadian(double Value) { - return Value * (PI / 180.0f); +double CSXMath::degreeToRadian(double value) { + return value * (PI / 180.0f); } ////////////////////////////////////////////////////////////////////////// -double CSXMath::RadianToDegree(double Value) { - return Value * (180.0f / PI); +double CSXMath::radianToDegree(double value) { + return value * (180.0f / PI); } diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index ac3dc45115..704b93a897 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -43,8 +43,8 @@ public: virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); private: - double DegreeToRadian(double Value); - double RadianToDegree(double Value); + double degreeToRadian(double Value); + double radianToDegree(double Value); }; -- cgit v1.2.3 From 6fb4151b9f4d4bbd6100756752ebf25d4dd6514c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:42:05 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in SXString --- engines/wintermute/Base/scriptables/SXString.cpp | 40 ++++++++++++------------ engines/wintermute/Base/scriptables/SXString.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 4f6bd5a33d..41aa395949 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -58,10 +58,10 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { memset(_string, 0, _capacity); } } else { - SetStringVal(Val->getString()); + setStringVal(Val->getString()); } - if (_capacity == 0) SetStringVal(""); + if (_capacity == 0) setStringVal(""); } @@ -72,16 +72,16 @@ CSXString::~CSXString() { ////////////////////////////////////////////////////////////////////////// -void CSXString::SetStringVal(const char *Val) { - int Len = strlen(Val); - if (Len >= _capacity) { - _capacity = Len + 1; +void CSXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; delete[] _string; _string = NULL; _string = new char[_capacity]; memset(_string, 0, _capacity); } - strcpy(_string, Val); + strcpy(_string, val); } @@ -93,8 +93,8 @@ const char *CSXString::scToString() { ////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *Val) { - SetStringVal(Val); +void CSXString::scSetString(const char *val) { + setStringVal(val); } @@ -357,16 +357,16 @@ HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { // Capacity ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { - int NewCap = value->getInt(); - if (NewCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); - else if (NewCap != _capacity) { - char *NewStr = new char[NewCap]; - if (NewStr) { - memset(NewStr, 0, NewCap); - strcpy(NewStr, _string); + int newCap = value->getInt(); + if (newCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); + else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); delete[] _string; - _string = NewStr; - _capacity = NewCap; + _string = newStr; + _capacity = newCap; } } return S_OK; @@ -397,8 +397,8 @@ HRESULT CSXString::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *Val) { - return strcmp(_string, ((CSXString *)Val)->_string); +int CSXString::scCompare(CBScriptable *val) { + return strcmp(_string, ((CSXString *)val)->_string); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index 93bae35616..73969f8fdc 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -43,7 +43,7 @@ public: HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void scSetString(const char *Val); const char *scToString(); - void SetStringVal(const char *Val); + void setStringVal(const char *Val); CSXString(CBGame *inGame, CScStack *Stack); virtual ~CSXString(); -- cgit v1.2.3 From 317e53aca7aafcd5ed356a25795ad994152a4fc8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:46:34 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in SXArray --- engines/wintermute/Base/scriptables/SXArray.cpp | 82 ++++++++++++------------ engines/wintermute/Base/scriptables/SXArray.h | 6 +- engines/wintermute/Base/scriptables/SXString.cpp | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 72c848f747..0b3c6a80d5 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -45,15 +45,15 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; _values = new CScValue(Game); - int NumParams = stack->pop()->getInt(0); - - if (NumParams == 1) _length = stack->pop()->getInt(0); - else if (NumParams > 1) { - _length = NumParams; - char ParamName[20]; - for (int i = 0; i < NumParams; i++) { - sprintf(ParamName, "%d", i); - _values->setProp(ParamName, stack->pop()); + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) _length = stack->pop()->getInt(0); + else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); } } } @@ -74,21 +74,21 @@ CSXArray::~CSXArray() { ////////////////////////////////////////////////////////////////////////// const char *CSXArray::scToString() { - static char Dummy[32768]; - strcpy(Dummy, ""); - char PropName[20]; + static char dummy[32768]; // TODO: Get rid of static. + strcpy(dummy, ""); + char propName[20]; for (int i = 0; i < _length; i++) { - sprintf(PropName, "%d", i); - CScValue *val = _values->getProp(PropName); + sprintf(propName, "%d", i); + CScValue *val = _values->getProp(propName); if (val) { - if (strlen(Dummy) + strlen(val->getString()) < 32768) { - strcat(Dummy, val->getString()); + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); } } - if (i < _length - 1 && strlen(Dummy) + 1 < 32768) strcat(Dummy, ","); + if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); } - return Dummy; + return dummy; } @@ -98,13 +98,13 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Push ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Push") == 0) { - int NumParams = stack->pop()->getInt(0); - char ParamName[20]; + int numParams = stack->pop()->getInt(0); + char paramName[20]; - for (int i = 0; i < NumParams; i++) { + for (int i = 0; i < numParams; i++) { _length++; - sprintf(ParamName, "%d", _length - 1); - _values->setProp(ParamName, stack->pop(), true); + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); } stack->pushInt(_length); @@ -119,10 +119,10 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); if (_length > 0) { - char ParamName[20]; - sprintf(ParamName, "%d", _length - 1); - stack->push(_values->getProp(ParamName)); - _values->deleteProp(ParamName); + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); _length--; } else stack->pushNULL(); @@ -158,7 +158,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { char ParamName[20]; - if (ValidNumber(name, ParamName)) { + if (validNumber(name, ParamName)) { return _values->getProp(ParamName); } else return _scValue; } @@ -188,11 +188,11 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { // [number] ////////////////////////////////////////////////////////////////////////// else { - char ParamName[20]; - if (ValidNumber(name, ParamName)) { - int Index = atoi(ParamName); + char paramName[20]; + if (validNumber(name, paramName)) { + int Index = atoi(paramName); if (Index >= _length) _length = Index + 1; - return _values->setProp(ParamName, value); + return _values->setProp(paramName, value); } else return E_FAIL; } } @@ -210,28 +210,28 @@ HRESULT CSXArray::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::ValidNumber(const char *OrigStr, char *OutStr) { +bool CSXArray::validNumber(const char *origStr, char *outStr) { bool IsNumber = true; - for (int i = 0; i < strlen(OrigStr); i++) { - if (!(OrigStr[i] >= '0' && OrigStr[i] <= '9')) { + for (int i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { IsNumber = false; break; } } if (IsNumber) { - int Index = atoi(OrigStr); - sprintf(OutStr, "%d", Index); + int Index = atoi(origStr); + sprintf(outStr, "%d", Index); return true; } else return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::Push(CScValue *Val) { - char ParamName[20]; +HRESULT CSXArray::push(CScValue *val) { + char paramName[20]; _length++; - sprintf(ParamName, "%d", _length - 1); - _values->setProp(ParamName, Val, true); + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index deb52bd86a..81599892d9 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -35,10 +35,10 @@ namespace WinterMute { class CSXArray : public CBScriptable { public: - HRESULT Push(CScValue *Val); - bool ValidNumber(const char *OrigStr, char *OutStr); + HRESULT push(CScValue *Val); + bool validNumber(const char *origStr, char *outStr); DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *Stack); + CSXArray(CBGame *inGame, CScStack *stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 41aa395949..1e3b1b0bf9 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -303,7 +303,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); - Array->Push(Val); + Array->push(Val); delete Val; Val = NULL; } -- cgit v1.2.3 From 8596c6a91e7189a2c23d92c0282e8fbb8b66b08b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 06:07:22 +0200 Subject: WINTERMUTE: Rename most functions in BGame FuncName->funcName --- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 16 +- engines/wintermute/Ad/AdScene.cpp | 14 +- engines/wintermute/Base/BActiveRect.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 228 +++++++++++------------ engines/wintermute/Base/BGame.h | 90 ++++----- engines/wintermute/Base/BObject.cpp | 4 +- engines/wintermute/Base/BRenderSDL.cpp | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 4 +- engines/wintermute/Base/BSurfaceSDL.cpp | 6 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 18 +- engines/wintermute/Base/scriptables/ScScript.cpp | 42 ++--- engines/wintermute/PlatformSDL.cpp | 4 +- engines/wintermute/UI/UIObject.cpp | 4 +- engines/wintermute/UI/UIWindow.cpp | 12 +- engines/wintermute/video/VidTheoraPlayer.cpp | 8 +- engines/wintermute/wintermute.cpp | 4 +- 17 files changed, 230 insertions(+), 230 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index d3074c1562..89506045b8 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -603,7 +603,7 @@ HRESULT CAdEntity::update() { if (_theora) { int OffsetX, OffsetY; - Game->GetOffset(&OffsetX, &OffsetY); + Game->getOffset(&OffsetX, &OffsetY); _theora->_posX = _posX - OffsetX; _theora->_posY = _posY - OffsetY; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index ee8e3ca6c1..cd493c9471 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -206,7 +206,7 @@ HRESULT CAdGame::InitLoop() { HRESULT res; - res = CBGame::InitLoop(); + res = CBGame::initLoop(); if (FAILED(res)) return res; if (_scene) res = _scene->initLoop(); @@ -1105,10 +1105,10 @@ HRESULT CAdGame::showCursor() { } if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) - return DrawCursor(_selectedItem->_cursorHover); + return drawCursor(_selectedItem->_cursorHover); else - return DrawCursor(_selectedItem->_cursorNormal); - } else return DrawCursor(_selectedItem->_cursorNormal); + return drawCursor(_selectedItem->_cursorNormal); + } else return drawCursor(_selectedItem->_cursorNormal); } else return CBGame::showCursor(); } @@ -1316,7 +1316,7 @@ HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::LoadGame(const char *Filename) { HRESULT ret = CBGame::LoadGame(Filename); - if (SUCCEEDED(ret)) CSysClassRegistry::getInstance()->enumInstances(AfterLoadRegion, "CAdRegion", NULL); + if (SUCCEEDED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); return ret; } @@ -1710,7 +1710,7 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { if (Update) _scEngine->Tick(); POINT p; - GetMousePos(&p); + getMousePos(&p); _scene->update(); _scene->display(); @@ -1720,14 +1720,14 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { DisplayWindows(true); if (_inventoryBox) _inventoryBox->display(); if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); - if (_indicatorDisplay) DisplayIndicator(); + if (_indicatorDisplay) displayIndicator(); if (Update || DisplayAll) { // display normal windows DisplayWindows(false); - SetActiveObject(Game->_renderer->getObjectAt(p.x, p.y)); + setActiveObject(Game->_renderer->getObjectAt(p.x, p.y)); // textual info DisplaySentences(_state == GAME_FROZEN); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 04d3887f6c..205f7f12a5 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -870,10 +870,10 @@ HRESULT CAdScene::traverseNodes(bool Update) { // prepare viewport bool PopViewport = false; if (_viewport && !Game->_editorMode) { - Game->PushViewport(_viewport); + Game->pushViewport(_viewport); PopViewport = true; } else if (AdGame->_sceneViewport && !Game->_editorMode) { - Game->PushViewport(AdGame->_sceneViewport); + Game->pushViewport(AdGame->_sceneViewport); PopViewport = true; } @@ -934,7 +934,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)ScrollableY); int OrigX, OrigY; - Game->GetOffset(&OrigX, &OrigY); + Game->getOffset(&OrigX, &OrigY); @@ -965,14 +965,14 @@ HRESULT CAdScene::traverseNodes(bool Update) { if (_paralaxScrolling) { int OffsetX = (int)(WidthRatio * (_layers[j]->_width - ViewportWidth) - ViewportX); int OffsetY = (int)(HeightRatio * (_layers[j]->_height - ViewportHeight) - ViewportY); - Game->SetOffset(OffsetX, OffsetY); + Game->setOffset(OffsetX, OffsetY); Game->_offsetPercentX = (float)OffsetX / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; Game->_offsetPercentY = (float)OffsetY / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); } else { - Game->SetOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); + Game->setOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); Game->_offsetPercentX = (float)(_offsetLeft - ViewportX) / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; Game->_offsetPercentY = (float)(_offsetTop - ViewportY) / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; @@ -1017,7 +1017,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { // restore state - Game->SetOffset(OrigX, OrigY); + Game->setOffset(OrigX, OrigY); Game->_renderer->setup2D(); // display/update fader @@ -1026,7 +1026,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { else _fader->display(); } - if (PopViewport) Game->PopViewport(); + if (PopViewport) Game->popViewport(); return S_OK; } diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 46dd6ed51f..72962dbf1e 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -88,7 +88,7 @@ CBActiveRect::~CBActiveRect() { void CBActiveRect::clipRect() { RECT rc; bool CustomViewport; - Game->GetCurrentViewportRect(&rc, &CustomViewport); + Game->getCurrentViewportRect(&rc, &CustomViewport); CBRenderer *Rend = Game->_renderer; if (!CustomViewport) { diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 93c063a3b3..92c611698b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -284,7 +284,7 @@ CBGame::~CBGame() { LOG(0, ""); LOG(0, "Shutting down..."); - GetDebugMgr()->OnGameShutdown(); + getDebugMgr()->OnGameShutdown(); _registry->WriteBool("System", "LastRun", true); @@ -597,19 +597,19 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBGame::SetEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { +void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { _engineLogCallback = callback; _engineLogCallbackData = data; } ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitLoop() { +HRESULT CBGame::initLoop() { _viewportSP = -1; _currentTime = CBPlatform::GetTime(); - GetDebugMgr()->OnGameTick(); + getDebugMgr()->OnGameTick(); _renderer->initLoop(); _soundMgr->initLoop(); UpdateMusicCrossfade(); @@ -643,7 +643,7 @@ HRESULT CBGame::InitLoop() { } //Game->LOG(0, "%d", _fps); - GetMousePos(&_mousePos); + getMousePos(&_mousePos); _focusedWindow = NULL; for (int i = _windows.GetSize() - 1; i >= 0; i--) { @@ -662,25 +662,25 @@ HRESULT CBGame::InitLoop() { ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitInput(HINSTANCE hInst, HWND hWnd) { +HRESULT CBGame::initInput(HINSTANCE hInst, HWND hWnd) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -int CBGame::GetSequence() { +int CBGame::getSequence() { return ++_sequence; } ////////////////////////////////////////////////////////////////////////// -void CBGame::SetOffset(int offsetX, int offsetY) { +void CBGame::setOffset(int offsetX, int offsetY) { _offsetX = offsetX; _offsetY = offsetY; } ////////////////////////////////////////////////////////////////////////// -void CBGame::GetOffset(int *offsetX, int *offsetY) { +void CBGame::getOffset(int *offsetX, int *offsetY) { if (offsetX != NULL) *offsetX = _offsetX; if (offsetY != NULL) *offsetY = _offsetY; } @@ -1002,7 +1002,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Msg") == 0) { stack->correctParams(1); - QuickMessage(stack->pop()->getString()); + quickMessage(stack->pop()->getString()); stack->pushNULL(); return S_OK; } @@ -1130,7 +1130,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS uint32 LoopStart = (uint32)(ValLoopStart->isNULL() ? 0 : ValLoopStart->getInt()); - if (FAILED(PlayMusic(channel, filename, Looping, LoopStart))) stack->pushBool(false); + if (FAILED(playMusic(channel, filename, Looping, LoopStart))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -1147,7 +1147,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(StopMusic(channel))) stack->pushBool(false); + if (FAILED(stopMusic(channel))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -1164,7 +1164,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(PauseMusic(channel))) stack->pushBool(false); + if (FAILED(pauseMusic(channel))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -1180,7 +1180,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(ResumeMusic(channel))) stack->pushBool(false); + if (FAILED(resumeMusic(channel))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -1214,9 +1214,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - uint32 Time = stack->pop()->getInt(); + uint32 time = stack->pop()->getInt(); - if (FAILED(SetMusicStartTime(channel, Time))) stack->pushBool(false); + if (FAILED(setMusicStartTime(channel, time))) stack->pushBool(false); else stack->pushBool(true); return S_OK; @@ -1930,7 +1930,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(SetWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + if (SUCCEEDED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); return S_OK; @@ -2570,7 +2570,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseX") == 0) { _mousePos.x = value->getInt(); - ResetMousePos(); + resetMousePos(); return S_OK; } @@ -2579,7 +2579,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseY") == 0) { _mousePos.y = value->getInt(); - ResetMousePos(); + resetMousePos(); return S_OK; } @@ -2785,7 +2785,7 @@ HRESULT CBGame::DisplayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessage(const char *text) { +void CBGame::quickMessage(const char *text) { if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.RemoveAt(0); @@ -2795,7 +2795,7 @@ void CBGame::QuickMessage(const char *text) { ////////////////////////////////////////////////////////////////////////// -void CBGame::QuickMessageForm(LPSTR fmt, ...) { +void CBGame::quickMessageForm(LPSTR fmt, ...) { char buff[256]; va_list va; @@ -2803,7 +2803,7 @@ void CBGame::QuickMessageForm(LPSTR fmt, ...) { vsprintf(buff, fmt, va); va_end(va); - QuickMessage(buff); + quickMessage(buff); } @@ -2844,7 +2844,7 @@ HRESULT CBGame::UnregisterObject(CBObject *object) { for (i = 0; i < _regObjects.GetSize(); i++) { if (_regObjects[i] == object) { _regObjects.RemoveAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(InvalidateValues, "CScValue", (void *)object); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); delete object; return S_OK; } @@ -2855,7 +2855,7 @@ HRESULT CBGame::UnregisterObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -void CBGame::InvalidateValues(void *value, void *data) { +void CBGame::invalidateValues(void *value, void *data) { CScValue *val = (CScValue *)value; if (val->isNative() && val->getNative() == data) { if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { @@ -3149,8 +3149,8 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Debug") == 0) { stack->correctParams(0); - if (Game->GetDebugMgr()->_enabled) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(script); + if (Game->getDebugMgr()->_enabled) { + Game->getDebugMgr()->OnScriptHitBreakpoint(script); script->Sleep(0); } stack->pushNULL(); @@ -3212,12 +3212,12 @@ HRESULT CBGame::showCursor() { if (_cursorHidden) return S_OK; if (!_interactive && Game->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return DrawCursor(_cursorNoninteractive); + if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); } else { if (_activeObject && !FAILED(_activeObject->showCursor())) return S_OK; else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return DrawCursor(_activeCursor); - else if (_cursor) return DrawCursor(_cursor); + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); + else if (_cursor) return drawCursor(_cursor); } } return E_FAIL; @@ -3287,7 +3287,7 @@ HRESULT CBGame::LoadGame(int slot) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::LoadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); - GetDebugMgr()->OnGameShutdown(); + getDebugMgr()->OnGameShutdown(); HRESULT ret; @@ -3322,7 +3322,7 @@ HRESULT CBGame::LoadGame(const char *filename) { DisplayContent(true, false); //_renderer->flip(); - GetDebugMgr()->OnGameInit(); + getDebugMgr()->OnGameInit(); load_finish: _dEBUG_AbsolutePathWarning = true; @@ -3342,11 +3342,11 @@ load_finish: ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::InitAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(AfterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(AfterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(AfterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(AfterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(AfterLoadScript, "CScScript", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); _scEngine->RefreshScriptBreakpoints(); if (_store) _store->afterLoad(); @@ -3355,35 +3355,35 @@ HRESULT CBGame::InitAfterLoad() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadRegion(void *Region, void *Data) { - ((CBRegion *)Region)->CreateRegion(); +void CBGame::afterLoadRegion(void *region, void *data) { + ((CBRegion *)region)->CreateRegion(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadSubFrame(void *Subframe, void *Data) { - ((CBSubFrame *)Subframe)->setSurfaceSimple(); +void CBGame::afterLoadSubFrame(void *subframe, void *data) { + ((CBSubFrame *)subframe)->setSurfaceSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadSound(void *Sound, void *Data) { - ((CBSound *)Sound)->setSoundSimple(); +void CBGame::afterLoadSound(void *sound, void *data) { + ((CBSound *)sound)->setSoundSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadFont(void *Font, void *Data) { - ((CBFont *)Font)->afterLoad(); +void CBGame::afterLoadFont(void *font, void *data) { + ((CBFont *)font)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::AfterLoadScript(void *script, void *data) { +void CBGame::afterLoadScript(void *script, void *data) { ((CScScript *)script)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayWindows(bool InGame) { +HRESULT CBGame::DisplayWindows(bool inGame) { HRESULT res; int i; @@ -3401,7 +3401,7 @@ HRESULT CBGame::DisplayWindows(bool InGame) { // display all windows for (i = 0; i < _windows.GetSize(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == InGame) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); if (FAILED(res)) return res; @@ -3413,7 +3413,7 @@ HRESULT CBGame::DisplayWindows(bool InGame) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PlayMusic(int channel, const char *filename, bool looping, uint32 loopStart) { +HRESULT CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3439,7 +3439,7 @@ HRESULT CBGame::PlayMusic(int channel, const char *filename, bool looping, uint3 ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::StopMusic(int channel) { +HRESULT CBGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3455,7 +3455,7 @@ HRESULT CBGame::StopMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PauseMusic(int channel) { +HRESULT CBGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3467,7 +3467,7 @@ HRESULT CBGame::PauseMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ResumeMusic(int channel) { +HRESULT CBGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3479,21 +3479,21 @@ HRESULT CBGame::ResumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetMusicStartTime(int channel, uint32 Time) { +HRESULT CBGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; } - _musicStartTime[channel] = Time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(Time); + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); else return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadSettings(const char *filename) { +HRESULT CBGame::loadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3712,7 +3712,7 @@ HRESULT CBGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::FocusWindow(CUIWindow *Window) { +HRESULT CBGame::focusWindow(CUIWindow *Window) { CUIWindow *Prev = _focusedWindow; int i; @@ -3726,7 +3726,7 @@ HRESULT CBGame::FocusWindow(CUIWindow *Window) { } if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return FocusWindow(Prev); + return focusWindow(Prev); else return S_OK; } } @@ -3735,10 +3735,10 @@ HRESULT CBGame::FocusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Freeze(bool IncludingMusic) { +HRESULT CBGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { _scEngine->PauseAll(); - _soundMgr->pauseAll(IncludingMusic); + _soundMgr->pauseAll(includingMusic); _origState = _state; _origInteractive = _interactive; _interactive = true; @@ -3751,7 +3751,7 @@ HRESULT CBGame::Freeze(bool IncludingMusic) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::Unfreeze() { +HRESULT CBGame::unfreeze() { if (_freezeLevel == 0) return S_OK; _freezeLevel--; @@ -3957,17 +3957,17 @@ HRESULT CBGame::EmptySaveSlot(int Slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetActiveObject(CBObject *Obj) { +HRESULT CBGame::setActiveObject(CBObject *obj) { // not-active when game is frozen - if (Obj && !Game->_interactive && !Obj->_nonIntMouseEvents) { - Obj = NULL; + if (obj && !Game->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; } - if (Obj == _activeObject) return S_OK; + if (obj == _activeObject) return S_OK; if (_activeObject) _activeObject->applyEvent("MouseLeave"); //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); - _activeObject = Obj; + _activeObject = obj; if (_activeObject) { _activeObject->applyEvent("MouseEntry"); } @@ -3977,19 +3977,19 @@ HRESULT CBGame::SetActiveObject(CBObject *Obj) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PushViewport(CBViewport *Viewport) { +HRESULT CBGame::pushViewport(CBViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(Viewport); - else _viewportStack[_viewportSP] = Viewport; + if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(viewport); + else _viewportStack[_viewportSP] = viewport; - _renderer->setViewport(Viewport->getRect()); + _renderer->setViewport(viewport->getRect()); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::PopViewport() { +HRESULT CBGame::popViewport() { _viewportSP--; if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); @@ -4004,18 +4004,18 @@ HRESULT CBGame::PopViewport() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { - if (Rect == NULL) return E_FAIL; +HRESULT CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { + if (rect == NULL) return E_FAIL; else { if (_viewportSP >= 0) { - CBPlatform::CopyRect(Rect, _viewportStack[_viewportSP]->getRect()); - if (Custom) *Custom = true; + CBPlatform::CopyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) *custom = true; } else { - CBPlatform::SetRect(Rect, _renderer->_drawOffsetX, + CBPlatform::SetRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); - if (Custom) *Custom = false; + if (custom) *custom = false; } return S_OK; @@ -4024,13 +4024,13 @@ HRESULT CBGame::GetCurrentViewportRect(RECT *Rect, bool *Custom) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { +HRESULT CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { - if (OffsetX) *OffsetX = _viewportStack[_viewportSP]->_offsetX; - if (OffsetY) *OffsetY = _viewportStack[_viewportSP]->_offsetY; + if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; + if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; } else { - if (OffsetX) *OffsetX = 0; - if (OffsetY) *OffsetY = 0; + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; } return S_OK; @@ -4038,26 +4038,26 @@ HRESULT CBGame::GetCurrentViewportOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowLoadHook(CUIWindow *Win, char **Buf, char **Params) { +HRESULT CBGame::WindowLoadHook(CUIWindow *win, char **Buf, char **Params) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) { +HRESULT CBGame::WindowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -void CBGame::SetInteractive(bool State) { - _interactive = State; - if (_transMgr) _transMgr->_origInteractive = State; +void CBGame::SetInteractive(bool state) { + _interactive = state; + if (_transMgr) _transMgr->_origInteractive = state; } ////////////////////////////////////////////////////////////////////////// -void CBGame::ResetMousePos() { +void CBGame::resetMousePos() { POINT p; p.x = _mousePos.x + _renderer->_drawOffsetX; p.y = _mousePos.y + _renderer->_drawOffsetY; @@ -4067,8 +4067,8 @@ void CBGame::ResetMousePos() { ////////////////////////////////////////////////////////////////////////// -void CBGame::SetResourceModule(HMODULE ResModule) { - _resourceModule = ResModule; +void CBGame::setResourceModule(HMODULE resModule) { + _resourceModule = resModule; } @@ -4082,14 +4082,14 @@ HRESULT CBGame::DisplayContent(bool update, bool displayAll) { HRESULT CBGame::DisplayContentSimple() { // fill black _renderer->fill(0, 0, 0); - if (_indicatorDisplay) DisplayIndicator(); + if (_indicatorDisplay) displayIndicator(); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayIndicator() { +HRESULT CBGame::displayIndicator() { if (_saveLoadImage) { RECT rc; CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); @@ -4180,7 +4180,7 @@ void CBGame::DEBUG_DumpClassRegistry() { f->close(); delete f; - Game->QuickMessage("Classes dump completed."); + Game->quickMessage("Classes dump completed."); } @@ -4202,7 +4202,7 @@ HRESULT CBGame::restoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SetWaitCursor(const char *filename) { +HRESULT CBGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -4234,7 +4234,7 @@ HRESULT CBGame::StopVideo() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DrawCursor(CBSprite *Cursor) { +HRESULT CBGame::drawCursor(CBSprite *Cursor) { if (!Cursor) return E_FAIL; if (Cursor != _lastCursor) { Cursor->Reset(); @@ -4253,8 +4253,8 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { if (RefreshMouse) { POINT p; - GetMousePos(&p); - SetActiveObject(_renderer->getObjectAt(p.x, p.y)); + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); } if (Activate) _soundMgr->resumeAll(); @@ -4443,18 +4443,18 @@ HRESULT CBGame::DisplayDebugInfo() { } ////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::GetDebugMgr() { +CBDebugger *CBGame::getDebugMgr() { if (!_debugMgr) _debugMgr = new CBDebugger(this); return _debugMgr; } ////////////////////////////////////////////////////////////////////////// -void CBGame::GetMousePos(POINT *Pos) { - CBPlatform::GetCursorPos(Pos); +void CBGame::getMousePos(POINT *pos) { + CBPlatform::GetCursorPos(pos); - Pos->x -= _renderer->_drawOffsetX; - Pos->y -= _renderer->_drawOffsetY; + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; /* // Windows can squish maximized window if it's larger than desktop @@ -4470,19 +4470,19 @@ void CBGame::GetMousePos(POINT *Pos) { */ if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::PtInRect(&_mouseLockRect, *Pos)) { - Pos->x = MAX(_mouseLockRect.left, Pos->x); - Pos->y = MAX(_mouseLockRect.top, Pos->y); + if (!CBPlatform::PtInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); - Pos->x = MIN(_mouseLockRect.right, Pos->x); - Pos->y = MIN(_mouseLockRect.bottom, Pos->y); + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); - POINT NewPos = *Pos; + POINT newPos = *pos; - NewPos.x += _renderer->_drawOffsetX; - NewPos.y += _renderer->_drawOffsetY; + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; - CBPlatform::SetCursorPos(NewPos.x, NewPos.y); + CBPlatform::SetCursorPos(newPos.x, newPos.y); } } } @@ -4504,12 +4504,12 @@ HRESULT CBGame::OnScriptShutdown(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsLeftDoubleClick() { +bool CBGame::isLeftDoubleClick() { return IsDoubleClick(0); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsRightDoubleClick() { +bool CBGame::isRightDoubleClick() { return IsDoubleClick(1); } @@ -4543,7 +4543,7 @@ bool CBGame::IsDoubleClick(int buttonIndex) { } ////////////////////////////////////////////////////////////////////////// -void CBGame::AutoSaveOnExit() { +void CBGame::autoSaveOnExit() { _soundMgr->saveSettings(); _registry->SaveValues(); @@ -4554,7 +4554,7 @@ void CBGame::AutoSaveOnExit() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::AddMem(int bytes) { +void CBGame::addMem(int bytes) { _usedMem += bytes; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 00cb8c16cf..799abc7b5c 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -81,8 +81,8 @@ public: virtual HRESULT OnPaint(); virtual HRESULT OnWindowClose(); - bool IsLeftDoubleClick(); - bool IsRightDoubleClick(); + bool isLeftDoubleClick(); + bool isRightDoubleClick(); bool _autorunDisabled; @@ -91,7 +91,7 @@ public: virtual HRESULT MiniUpdate(); - void GetMousePos(POINT *Pos); + void getMousePos(POINT *Pos); RECT _mouseLockRect; bool _shuttingDown; @@ -113,7 +113,7 @@ public: virtual HRESULT ResetContent(); void DEBUG_DumpClassRegistry(); - HRESULT SetWaitCursor(const char *Filename); + HRESULT setWaitCursor(const char *Filename); char *_localSaveDir; bool _saveDirChecked; @@ -137,32 +137,32 @@ public: int _loadImageY; CBSurface *_saveLoadImage; - HRESULT DisplayIndicator(); + HRESULT displayIndicator(); int _thumbnailWidth; int _thumbnailHeight; bool _reportTextureFormat; HMODULE _resourceModule; - void SetResourceModule(HMODULE ResModule); + void setResourceModule(HMODULE ResModule); - void SetEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); + void setEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); ENGINE_LOG_CALLBACK _engineLogCallback; void *_engineLogCallbackData; bool _editorMode; bool _doNotExpandStrings; - void GetOffset(int *OffsetX, int *OffsetY); - void SetOffset(int OffsetX, int OffsetY); - int GetSequence(); + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); int _offsetY; int _offsetX; float _offsetPercentX; float _offsetPercentY; CBObject *_mainObject; - HRESULT InitInput(HINSTANCE hInst, HWND hWnd); - HRESULT InitLoop(); + HRESULT initInput(HINSTANCE hInst, HWND hWnd); + HRESULT initLoop(); uint32 _currentTime; uint32 _deltaTime; CBFont *_systemFont; @@ -172,7 +172,7 @@ public: HRESULT initialize3(); CBFileManager *_fileManager; CBTransitionMgr *_transMgr; - CBDebugger *GetDebugMgr(); + CBDebugger *getDebugMgr(); void LOG(HRESULT res, LPCSTR fmt, ...); @@ -187,13 +187,13 @@ public: virtual ~CBGame(); void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *Filename = NULL); + void DEBUG_DebugEnable(const char *filename = NULL); bool _dEBUG_DebugMode; bool _dEBUG_AbsolutePathWarning; void *_dEBUG_LogFile; int _sequence; - virtual HRESULT loadFile(const char *Filename); + virtual HRESULT loadFile(const char *filename); virtual HRESULT loadBuffer(byte *Buffer, bool Complete = true); CBArray _quickMessages; CBArray _windows; @@ -260,27 +260,27 @@ public: virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); int _freezeLevel; - HRESULT Unfreeze(); - HRESULT Freeze(bool IncludingMusic = true); - HRESULT FocusWindow(CUIWindow *Window); + HRESULT unfreeze(); + HRESULT freeze(bool IncludingMusic = true); + HRESULT focusWindow(CUIWindow *Window); CVidPlayer *_videoPlayer; CVidTheoraPlayer *_theoraPlayer; bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; - static void AfterLoadRegion(void *Region, void *Data); - static void AfterLoadSubFrame(void *Subframe, void *Data); - static void AfterLoadSound(void *Sound, void *Data); - static void AfterLoadFont(void *Font, void *Data); - static void AfterLoadScript(void *script, void *data); - static void InvalidateValues(void *Value, void *Data); - - HRESULT LoadSettings(const char *Filename); - HRESULT ResumeMusic(int Channel); - HRESULT SetMusicStartTime(int Channel, uint32 Time); - HRESULT PauseMusic(int Channel); - HRESULT StopMusic(int Channel); - HRESULT PlayMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); + static void afterLoadRegion(void *Region, void *Data); + static void afterLoadSubFrame(void *Subframe, void *Data); + static void afterLoadSound(void *Sound, void *Data); + static void afterLoadFont(void *Font, void *Data); + static void afterLoadScript(void *script, void *data); + static void invalidateValues(void *Value, void *Data); + + HRESULT loadSettings(const char *Filename); + HRESULT resumeMusic(int Channel); + HRESULT setMusicStartTime(int Channel, uint32 Time); + HRESULT pauseMusic(int Channel); + HRESULT stopMusic(int Channel); + HRESULT playMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); CBSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; @@ -314,11 +314,11 @@ public: CBObject *_capturedObject; POINT _mousePos; - bool ValidObject(CBObject *Object); - HRESULT UnregisterObject(CBObject *Object); - HRESULT RegisterObject(CBObject *Object); - void QuickMessage(const char *Text); - void QuickMessageForm(LPSTR fmt, ...); + bool ValidObject(CBObject *object); + HRESULT UnregisterObject(CBObject *object); + HRESULT RegisterObject(CBObject *object); + void quickMessage(const char *text); + void quickMessageForm(LPSTR fmt, ...); HRESULT DisplayQuickMsg(); uint32 _fps; HRESULT UpdateMusicCrossfade(); @@ -331,23 +331,23 @@ public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); virtual HRESULT DisplayContentSimple(); bool _forceNonStreamedSounds; - void ResetMousePos(); + void resetMousePos(); int _subtitlesSpeed; void SetInteractive(bool State); virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); - HRESULT GetCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - HRESULT GetCurrentViewportRect(RECT *Rect, bool *Custom = NULL); - HRESULT PopViewport(); - HRESULT PushViewport(CBViewport *Viewport); - HRESULT SetActiveObject(CBObject *Obj); + HRESULT getCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + HRESULT getCurrentViewportRect(RECT *Rect, bool *Custom = NULL); + HRESULT popViewport(); + HRESULT pushViewport(CBViewport *Viewport); + HRESULT setActiveObject(CBObject *Obj); CBSprite *_lastCursor; - HRESULT DrawCursor(CBSprite *Cursor); + HRESULT drawCursor(CBSprite *Cursor); virtual HRESULT InitAfterLoad(); CBSaveThumbHelper *_cachedThumbnail; AnsiString GetDataDir(); - void AddMem(int bytes); + void addMem(int bytes); bool _touchInterface; bool _constrainedMemory; @@ -380,7 +380,7 @@ protected: bool _cursorHidden; public: - void AutoSaveOnExit(); + void autoSaveOnExit(); }; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index ab30ce33b0..a352b11bf0 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -63,7 +63,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _soundEvent = NULL; - _iD = Game->GetSequence(); + _iD = Game->getSequence(); CBPlatform::SetRectEmpty(&_rect); _rectSet = false; @@ -852,7 +852,7 @@ const char *CBObject::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::showCursor() { - if (_cursor) return Game->DrawCursor(_cursor); + if (_cursor) return Game->drawCursor(_cursor); else return E_FAIL; } diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 2f2db5e10b..1427b31aae 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -299,7 +299,7 @@ HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setHeight(rect->height()); } else { RECT rc; - Game->GetCurrentViewportRect(&rc); + Game->getCurrentViewportRect(&rc); fillRect.left = (int16)rc.left; fillRect.top = (int16)rc.top; fillRect.setWidth((int16)(rc.right - rc.left)); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 6165008bc1..b6495931aa 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -297,7 +297,7 @@ HRESULT CBScriptHolder::addScript(const char *Filename) { scr->_owner = this; _scripts.Add(scr); Game->_scEngine->_scripts.Add(scr); - Game->GetDebugMgr()->OnScriptInit(scr); + Game->getDebugMgr()->OnScriptInit(scr); return S_OK; } @@ -436,7 +436,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { HRESULT ret = thread->CreateMethodThread(_scripts[i], methodName); if (SUCCEEDED(ret)) { _scripts[i]->_engine->_scripts.Add(thread); - Game->GetDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], methodName); + Game->getDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], methodName); return thread; } else { diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 8dbe7c75b6..34f47b5d64 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -66,7 +66,7 @@ CBSurfaceSDL::~CBSurfaceSDL() { delete[] _alphaMask; _alphaMask = NULL; - Game->AddMem(-_width * _height * 4); + Game->addMem(-_width * _height * 4); CBRenderSDL *renderer = static_cast(Game->_renderer); renderer->invalidateTicketsFromSurface(this); } @@ -203,7 +203,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, _valid = true; - Game->AddMem(_width * _height * 4); + Game->addMem(_width * _height * 4); delete image; @@ -302,7 +302,7 @@ HRESULT CBSurfaceSDL::create(int width, int height) { _width = width; _height = height; - Game->AddMem(_width * _height * 4); + Game->addMem(_width * _height * 4); _valid = true; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 8aca4c9edf..b7ab360b82 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -257,7 +257,7 @@ CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { script->_globals->setProp("this", &val); _scripts.Add(script); - Game->GetDebugMgr()->OnScriptInit(script); + Game->getDebugMgr()->OnScriptInit(script); return script; } @@ -324,7 +324,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I CompBuffer = ExtCompileFile(tempFileName, &CompSize); delete[] tempFileName; if (!CompBuffer) { - Game->QuickMessage("Script compiler error. View log for details."); + Game->quickMessage("Script compiler error. View log for details."); delete [] Buffer; return NULL; } @@ -490,7 +490,7 @@ HRESULT CScEngine::RemoveFinishedScripts() { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - Game->GetDebugMgr()->OnScriptShutdown(_scripts[i]); + Game->getDebugMgr()->OnScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.RemoveAt(i); i--; @@ -674,7 +674,7 @@ HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; CScBreakpoint *Bp = NULL; for (int i = 0; i < _breakpoints.GetSize(); i++) { @@ -701,7 +701,7 @@ HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { @@ -726,7 +726,7 @@ HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RefreshScriptBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _scripts.GetSize(); i++) { RefreshScriptBreakpoints(_scripts[i]); @@ -736,7 +736,7 @@ HRESULT CScEngine::RefreshScriptBreakpoints() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *script) { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; if (!script || !script->_filename) return E_FAIL; @@ -753,7 +753,7 @@ HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *script) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::SaveBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; char Text[512]; @@ -776,7 +776,7 @@ HRESULT CScEngine::SaveBreakpoints() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::LoadBreakpoints() { - if (!Game->GetDebugMgr()->_enabled) return S_OK; + if (!Game->getDebugMgr()->_enabled) return S_OK; char Key[100]; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 217233534c..f255d2aa8a 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -490,12 +490,12 @@ HRESULT CScScript::ExecuteInstruction() { dw = GetDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + if (Game->getDebugMgr()->_enabled) + Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + if (Game->getDebugMgr()->_enabled) + Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); } break; @@ -509,21 +509,21 @@ HRESULT CScScript::ExecuteInstruction() { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + if (Game->getDebugMgr()->_enabled) + Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); } break; } case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); + Game->getDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) Game->getDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->getDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -640,8 +640,8 @@ HRESULT CScScript::ExecuteInstruction() { _operand->setNULL(); _scopeStack->push(_operand); - if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) Game->getDebugMgr()->OnScriptChangeScope(this, NULL); + else Game->getDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); break; @@ -691,8 +691,8 @@ HRESULT CScScript::ExecuteInstruction() { } } - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableChangeValue(var, val); + if (Game->getDebugMgr()->_enabled) + Game->getDebugMgr()->OnVariableChangeValue(var, val); } break; @@ -757,8 +757,8 @@ HRESULT CScScript::ExecuteInstruction() { var->setNULL(); } else var->setProp(str, val); - if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableChangeValue(var, NULL); + if (Game->getDebugMgr()->_enabled) + Game->getDebugMgr()->OnVariableChangeValue(var, NULL); break; } @@ -1022,17 +1022,17 @@ HRESULT CScScript::ExecuteInstruction() { int NewLine = GetDWORD(); if (NewLine != _currentLine) { _currentLine = NewLine; - if (Game->GetDebugMgr()->_enabled) { - Game->GetDebugMgr()->OnScriptChangeLine(this, _currentLine); + if (Game->getDebugMgr()->_enabled) { + Game->getDebugMgr()->OnScriptChangeLine(this, _currentLine); for (int i = 0; i < _breakpoints.GetSize(); i++) { if (_breakpoints[i] == _currentLine) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Game->getDebugMgr()->OnScriptHitBreakpoint(this); Sleep(0); break; } } if (_tracingMode) { - Game->GetDebugMgr()->OnScriptHitBreakpoint(this); + Game->getDebugMgr()->OnScriptHitBreakpoint(this); Sleep(0); break; } @@ -1180,7 +1180,7 @@ void CScScript::RuntimeError(LPCSTR fmt, ...) { Game->LOG(0, " %s", buff); if (!Game->_suppressScriptErrors) - Game->QuickMessage("Script runtime error. View log for details."); + Game->quickMessage("Script runtime error. View log for details."); } @@ -1259,7 +1259,7 @@ CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable if (SUCCEEDED(ret)) { thread->_unbreakable = Unbreakable; _engine->_scripts.Add(thread); - Game->GetDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); + Game->getDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); return thread; } else { delete thread; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 6f330e35e8..5f373498aa 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -54,13 +54,13 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_LBUTTONDOWN: if (Game) { - if (Game->IsLeftDoubleClick()) Game->OnMouseLeftDblClick(); + if (Game->isLeftDoubleClick()) Game->OnMouseLeftDblClick(); else Game->OnMouseLeftDown(); } break; case Common::EVENT_RBUTTONDOWN: if (Game) { - if (Game->IsRightDoubleClick()) Game->OnMouseRightDblClick(); + if (Game->isRightDoubleClick()) Game->OnMouseRightDblClick(); else Game->OnMouseRightDown(); } break; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 0a387c48c8..7a3cd3e8a0 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -71,7 +71,7 @@ CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIObject::~CUIObject() { - if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::InvalidateValues, "CScValue", (void *)this); + if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); if (_back) delete _back; if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); @@ -526,7 +526,7 @@ HRESULT CUIObject::focus() { if (obj->_parent) { if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; } else { - if (obj->_type == UI_WINDOW) Game->FocusWindow((CUIWindow *)obj); + if (obj->_type == UI_WINDOW) Game->focusWindow((CUIWindow *)obj); } obj = obj->_parent; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index ffa3df97c4..5ed33ffd7a 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -161,7 +161,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) { _viewport->setRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); - Game->PushViewport(_viewport); + Game->pushViewport(_viewport); PopViewport = true; } } @@ -193,7 +193,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; - if (PopViewport) Game->PopViewport(); + if (PopViewport) Game->popViewport(); return S_OK; } @@ -1230,7 +1230,7 @@ HRESULT CUIWindow::goExclusive() { _mode = WINDOW_EXCLUSIVE; _visible = true; _disable = false; - Game->FocusWindow(this); + Game->focusWindow(this); return S_OK; } else return E_FAIL; } @@ -1246,9 +1246,9 @@ HRESULT CUIWindow::goSystemExclusive() { _ready = false; _visible = true; _disable = false; - Game->FocusWindow(this); + Game->focusWindow(this); - Game->Freeze(_pauseMusic); + Game->freeze(_pauseMusic); return S_OK; } @@ -1256,7 +1256,7 @@ HRESULT CUIWindow::goSystemExclusive() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - Game->Unfreeze(); + Game->unfreeze(); } _mode = WINDOW_NORMAL; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 219cc295d9..2c93e2ee33 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -357,7 +357,7 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam _freezeGame = freezeGame; if (!_playbackStarted && _freezeGame) - Game->Freeze(freezeMusic); + Game->freeze(freezeMusic); _playbackStarted = false; float width, height; @@ -455,7 +455,7 @@ HRESULT CVidTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { - Game->Unfreeze(); + Game->unfreeze(); } #if 0 if (m_Sound) m_Sound->Stop(); @@ -483,7 +483,7 @@ HRESULT CVidTheoraPlayer::update() { warning("Finished movie"); _state = THEORA_STATE_FINISHED; _playbackStarted = false; - if (_freezeGame) Game->Unfreeze(); + if (_freezeGame) Game->unfreeze(); } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { @@ -500,7 +500,7 @@ HRESULT CVidTheoraPlayer::update() { // end playback if (!_looping) { _state = THEORA_STATE_FINISHED; - if (_freezeGame) Game->Unfreeze(); + if (_freezeGame) Game->unfreeze(); return S_OK; } else { resetStream(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index fe8e653ca9..031b081075 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -189,7 +189,7 @@ int WinterMuteEngine::init() { _game->initialize1(); - if (FAILED(_game->LoadSettings("startup.settings"))) { + if (FAILED(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); delete _game; _game = NULL; @@ -200,7 +200,7 @@ int WinterMuteEngine::init() { _game->initialize2(); - _game->GetDebugMgr()->OnGameInit(); + _game->getDebugMgr()->OnGameInit(); _game->_scEngine->LoadBreakpoints(); -- cgit v1.2.3 From 2457d3860470a757ccf7f008c5638c6a7b5af1de Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 06:20:09 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in PathUtil and StringUtil --- engines/wintermute/Ad/AdSentence.cpp | 6 +-- engines/wintermute/Base/BFileManager.cpp | 6 +-- engines/wintermute/Base/BFontBitmap.cpp | 8 ++-- engines/wintermute/Base/BFontTT.cpp | 10 ++-- engines/wintermute/Base/BGame.cpp | 6 +-- engines/wintermute/Base/BImage.cpp | 2 +- engines/wintermute/Base/BRegistry.cpp | 8 ++-- engines/wintermute/Base/BSoundMgr.cpp | 10 ++-- engines/wintermute/Base/BSprite.cpp | 4 +- engines/wintermute/Base/BStringTable.cpp | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 60 ++++++++++++------------ engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/Base/scriptables/ScValue.cpp | 2 +- engines/wintermute/UI/UIEdit.cpp | 10 ++-- engines/wintermute/utils/PathUtil.cpp | 50 ++++++++++---------- engines/wintermute/utils/PathUtil.h | 28 +++++------ engines/wintermute/utils/StringUtil.cpp | 50 ++++++++++---------- engines/wintermute/utils/StringUtil.h | 44 ++++++++--------- engines/wintermute/utils/utils.cpp | 6 +-- 19 files changed, 157 insertions(+), 157 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 41d4c3745d..d95fd313e0 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -246,10 +246,10 @@ HRESULT CAdSentence::setupTalkFile(const char *soundFilename) { if (!soundFilename) return S_OK; - AnsiString path = PathUtil::GetDirectoryName(soundFilename); - AnsiString name = PathUtil::GetFileNameWithoutExtension(soundFilename); + AnsiString path = PathUtil::getDirectoryName(soundFilename); + AnsiString name = PathUtil::getFileNameWithoutExtension(soundFilename); - AnsiString talkDefFileName = PathUtil::Combine(path, name + ".talk"); + AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); Common::SeekableReadStream *file = Game->_fileManager->openFile(talkDefFileName.c_str()); if (file) { diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 9e98412021..12167624ae 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -656,11 +656,11 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool ////////////////////////////////////////////////////////////////////////// bool CBFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::GetFileNameWithoutExtension(fileName); + AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); // check for device-type specific packages - if (StringUtil::StartsWith(plainName, "xdevice_", true)) { - return StringUtil::CompareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); + if (StringUtil::startsWith(plainName, "xdevice_", true)) { + return StringUtil::compareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); } return true; } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index b12116446f..ccbeb6dd80 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -86,8 +86,8 @@ int CBFontBitmap::getTextWidth(byte *text, int MaxLength) { AnsiString str; if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); - str = StringUtil::WideToAnsi(wstr); + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); } else { str = AnsiString((char *)text); } @@ -116,8 +116,8 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlig AnsiString str; if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(Utf8String((char *)text)); - str = StringUtil::WideToAnsi(wstr); + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); } else { str = AnsiString((char *)text); } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 2eee39e9c9..9b4bb3ddff 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -124,8 +124,8 @@ void CBFontTT::initLoop() { int CBFontTT::getTextWidth(byte *Text, int MaxLength) { WideString text; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); + else text = StringUtil::ansiToWide((char *)Text); if (MaxLength >= 0 && text.size() > MaxLength) text = Common::String(text.c_str(), MaxLength); @@ -141,8 +141,8 @@ int CBFontTT::getTextWidth(byte *Text, int MaxLength) { int CBFontTT::getTextHeight(byte *Text, int Width) { WideString text; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); + else text = StringUtil::ansiToWide((char *)Text); int textWidth, textHeight; @@ -640,7 +640,7 @@ HRESULT CBFontTT::initFont() { Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::Combine(CBPlatform::GetSystemFontPath(), PathUtil::GetFileName(_fontFile)); + AnsiString fontFileName = PathUtil::combine(CBPlatform::GetSystemFontPath(), PathUtil::getFileName(_fontFile)); file = Game->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 92c611698b..f2908c9d96 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -517,7 +517,7 @@ void CBGame::DEBUG_DebugEnable(const char *filename) { //else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); if (!_dEBUG_LogFile) { - AnsiString safeLogFileName = PathUtil::GetSafeLogFileName(); + AnsiString safeLogFileName = PathUtil::getSafeLogFileName(); //_dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); } @@ -3898,12 +3898,12 @@ HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { ////////////////////////////////////////////////////////////////////////// AnsiString CBGame::GetDataDir() { - AnsiString userDir = PathUtil::GetUserDirectory(); + AnsiString userDir = PathUtil::getUserDirectory(); #ifdef __IPHONEOS__ return userDir; #else AnsiString baseDir = _registry->GetBasePath(); - return PathUtil::Combine(userDir, baseDir); + return PathUtil::combine(userDir, baseDir); #endif } diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 95f6f5bbbf..31a3772964 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -73,7 +73,7 @@ CBImage::~CBImage() { HRESULT CBImage::loadFile(const Common::String &filename) { _filename = filename; - if (StringUtil::StartsWith(filename, "savegame:", true)) { + if (StringUtil::startsWith(filename, "savegame:", true)) { _decoder = new Graphics::BitmapDecoder(); } else if (filename.hasSuffix(".png")) { _decoder = new Graphics::PNGDecoder(); diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index c39e1e69f1..efc2c77d88 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -99,7 +99,7 @@ int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int ini ////////////////////////////////////////////////////////////////////////// bool CBRegistry::WriteInt(const AnsiString &subKey, const AnsiString &key, int value) { - WriteString(subKey, key, StringUtil::ToString(value)); + WriteString(subKey, key, StringUtil::toString(value)); return true; } @@ -139,17 +139,17 @@ char *CBRegistry::GetIniName() { ////////////////////////////////////////////////////////////////////////// void CBRegistry::LoadValues(bool local) { if (local) LoadXml("settings.xml", _localValues); - else LoadXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); + else LoadXml(PathUtil::combine(Game->GetDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::SaveValues() { - SaveXml(PathUtil::Combine(Game->GetDataDir(), "settings.xml"), _values); + SaveXml(PathUtil::combine(Game->GetDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::SetBasePath(const char *basePath) { - _basePath = PathUtil::GetFileNameWithoutExtension(basePath); + _basePath = PathUtil::getFileNameWithoutExtension(basePath); LoadValues(false); } diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index ff5858c91e..18e674687c 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -132,12 +132,12 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool CBSoundBuffer *sound; // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::CompareNoCase(ext, "wav")) { - AnsiString path = PathUtil::GetDirectoryName(Filename); - AnsiString name = PathUtil::GetFileNameWithoutExtension(Filename); + AnsiString ext = PathUtil::getExtension(Filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(Filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(Filename); - AnsiString newFile = PathUtil::Combine(path, name + "ogg"); + AnsiString newFile = PathUtil::combine(path, name + "ogg"); if (Game->_fileManager->hasFile(newFile)) { Filename = newFile.c_str(); } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 07b8bc8b1d..ae5a185cc4 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -135,8 +135,8 @@ HRESULT CBSprite::loadFile(const char *Filename, int LifeTime, TSpriteCacheType HRESULT ret; - AnsiString ext = PathUtil::GetExtension(Filename); - if (StringUtil::StartsWith(Filename, "savegame:", true) || StringUtil::CompareNoCase(ext, "bmp") || StringUtil::CompareNoCase(ext, "tga") || StringUtil::CompareNoCase(ext, "png") || StringUtil::CompareNoCase(ext, "jpg")) { + AnsiString ext = PathUtil::getExtension(Filename); + if (StringUtil::startsWith(Filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); subframe->setSurface(Filename, true, 0, 0, 0, LifeTime, true); diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 794af32ab7..be8707b41f 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -59,7 +59,7 @@ HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDu } Common::String final_key = Key; - StringUtil::ToLowerCase(final_key); + StringUtil::toLowerCase(final_key); _stringsIter = _strings.find(final_key); if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 1e3b1b0bf9..58cce4d7bb 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -113,17 +113,17 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th //try { WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); //WideString subStr = str.substr(start, end - start + 1); WideString subStr(str.c_str() + start, end - start + 1); if (Game->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); else - stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); // } catch (std::exception &) { // stack->pushNULL(); // } @@ -151,17 +151,17 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // try { WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); // WideString subStr = str.substr(start, len); WideString subStr(str.c_str() + start, len); if (Game->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); else - stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); // } catch (std::exception &) { // stack->pushNULL(); // } @@ -177,16 +177,16 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); - StringUtil::ToUpperCase(str); + StringUtil::toUpperCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::wideToUtf8(str).c_str()); else - stack->pushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::wideToAnsi(str).c_str()); return S_OK; } @@ -199,16 +199,16 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); - StringUtil::ToLowerCase(str); + StringUtil::toLowerCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::wideToUtf8(str).c_str()); else - stack->pushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::wideToAnsi(str).c_str()); return S_OK; } @@ -224,17 +224,17 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); WideString toFind; if (Game->_textEncoding == TEXT_UTF8) - toFind = StringUtil::Utf8ToWide(strToFind); + toFind = StringUtil::utf8ToWide(strToFind); else - toFind = StringUtil::AnsiToWide(strToFind); + toFind = StringUtil::ansiToWide(strToFind); - int indexOf = StringUtil::IndexOf(str, toFind, index); + int indexOf = StringUtil::indexOf(str, toFind, index); stack->pushInt(indexOf); return S_OK; @@ -258,15 +258,15 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString str; if (Game->_textEncoding == TEXT_UTF8) - str = StringUtil::Utf8ToWide(_string); + str = StringUtil::utf8ToWide(_string); else - str = StringUtil::AnsiToWide(_string); + str = StringUtil::ansiToWide(_string); WideString delims; if (Game->_textEncoding == TEXT_UTF8) - delims = StringUtil::Utf8ToWide(Separators); + delims = StringUtil::utf8ToWide(Separators); else - delims = StringUtil::AnsiToWide(Separators); + delims = StringUtil::ansiToWide(Separators); Common::Array parts; @@ -299,9 +299,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString &part = (*it); if (Game->_textEncoding == TEXT_UTF8) - Val = new CScValue(Game, StringUtil::WideToUtf8(part).c_str()); + Val = new CScValue(Game, StringUtil::wideToUtf8(part).c_str()); else - Val = new CScValue(Game, StringUtil::WideToAnsi(part).c_str()); + Val = new CScValue(Game, StringUtil::wideToAnsi(part).c_str()); Array->push(Val); delete Val; @@ -332,7 +332,7 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Length") == 0) { if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(_string); + WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); } else _scValue->setInt(strlen(_string)); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index b7ab360b82..deeaeb1443 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -805,7 +805,7 @@ void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { if (!_isProfiling) return; AnsiString fileName = Filename; - StringUtil::ToLowerCase(fileName); + StringUtil::toLowerCase(fileName); _scriptTimes[fileName] += Time; } diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 04872fb4ae..d762f14feb 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -169,7 +169,7 @@ CScValue *CScValue::getProp(const char *name) { #endif Game->_scValue->setInt(strlen(_valString)); } else { - WideString wstr = StringUtil::Utf8ToWide(_valString); + WideString wstr = StringUtil::utf8ToWide(_valString); Game->_scValue->setInt(wstr.size()); } diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index c17bd405ab..2dec9c139f 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -444,8 +444,8 @@ CScValue *CUIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::AnsiToWide(_text); - _scValue->setString(StringUtil::WideToUtf8(wstr).c_str()); + WideString wstr = StringUtil::ansiToWide(_text); + _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); } else { _scValue->setString(_text); } @@ -515,8 +515,8 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::Utf8ToWide(value->getString()); - setText(StringUtil::WideToAnsi(wstr).c_str()); + WideString wstr = StringUtil::utf8ToWide(value->getString()); + setText(StringUtil::wideToAnsi(wstr).c_str()); } else { setText(value->getString()); } @@ -775,7 +775,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); WideString wstr; wstr += (char)event->kbd.ascii; - _selEnd += insertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1); + _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); if (Game->_textRTL) _selEnd = _selStart; else _selStart = _selEnd; diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index f975ea6199..cc1f2f3d44 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::UnifySeparators(const AnsiString &path) { +AnsiString PathUtil::unifySeparators(const AnsiString &path) { AnsiString newPath = path; AnsiString::iterator it; @@ -45,37 +45,37 @@ AnsiString PathUtil::UnifySeparators(const AnsiString &path) { } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::NormalizeFileName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); - StringUtil::ToLowerCase(newPath); +AnsiString PathUtil::normalizeFileName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + StringUtil::toLowerCase(newPath); return newPath; } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::Combine(const AnsiString &path1, const AnsiString &path2) { - AnsiString newPath1 = UnifySeparators(path1); - AnsiString newPath2 = UnifySeparators(path2); +AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { + AnsiString newPath1 = unifySeparators(path1); + AnsiString newPath2 = unifySeparators(path2); - if (!StringUtil::EndsWith(newPath1, "/", true) && !StringUtil::StartsWith(newPath2, "/", true)) + if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) newPath1 += "/"; return newPath1 + newPath2; } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetDirectoryName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); +AnsiString PathUtil::getDirectoryName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); //size_t pos = newPath.find_last_of(L'/'); - Common::String filename = GetFileName(path); + Common::String filename = getFileName(path); return Common::String(path.c_str(), path.size() - filename.size()); //if (pos == AnsiString::npos) return ""; //else return newPath.substr(0, pos + 1); } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetFileName(const AnsiString &path) { - AnsiString newPath = UnifySeparators(path); +AnsiString PathUtil::getFileName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. Common::String lastPart = Common::lastPathComponent(path, '/'); @@ -88,8 +88,8 @@ AnsiString PathUtil::GetFileName(const AnsiString &path) { } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { - AnsiString fileName = GetFileName(path); +AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! // TODO: Prettify this. @@ -101,8 +101,8 @@ AnsiString PathUtil::GetFileNameWithoutExtension(const AnsiString &path) { } ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetExtension(const AnsiString &path) { - AnsiString fileName = GetFileName(path); +AnsiString PathUtil::getExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); //size_t pos = fileName.find_last_of('.'); return Common::lastPathComponent(path, '.'); @@ -112,8 +112,8 @@ AnsiString PathUtil::GetExtension(const AnsiString &path) { ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetSafeLogFileName() { - AnsiString logFileName = GetUserDirectory(); +AnsiString PathUtil::getSafeLogFileName() { + AnsiString logFileName = getUserDirectory(); #ifdef __WIN32__ char moduleName[MAX_PATH]; @@ -125,25 +125,25 @@ AnsiString PathUtil::GetSafeLogFileName() { #else // !PORTME - logFileName = Combine(logFileName, "/Wintermute Engine/wme.log"); + logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); #endif - CreateDirectory(GetDirectoryName(logFileName)); + createDirectory(getDirectoryName(logFileName)); return logFileName; } ////////////////////////////////////////////////////////////////////////// -bool PathUtil::CreateDirectory(const AnsiString &path) { +bool PathUtil::createDirectory(const AnsiString &path) { return false; } ////////////////////////////////////////////////////////////////////////// -bool PathUtil::MatchesMask(const AnsiString &fileName, const AnsiString &mask) { +bool PathUtil::matchesMask(const AnsiString &fileName, const AnsiString &mask) { return false; } ////////////////////////////////////////////////////////////////////////// -bool PathUtil::FileExists(const AnsiString &fileName) { +bool PathUtil::fileExists(const AnsiString &fileName) { warning("PathUtil::FileExists(%s)", fileName.c_str()); Common::File stream; @@ -157,7 +157,7 @@ bool PathUtil::FileExists(const AnsiString &fileName) { ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::GetUserDirectory() { +AnsiString PathUtil::getUserDirectory() { warning("PathUtil::GetUserDirectory - stubbed"); AnsiString userDir = "./"; #if 0 diff --git a/engines/wintermute/utils/PathUtil.h b/engines/wintermute/utils/PathUtil.h index 0bc883a1fa..13e9e46652 100644 --- a/engines/wintermute/utils/PathUtil.h +++ b/engines/wintermute/utils/PathUtil.h @@ -35,20 +35,20 @@ namespace WinterMute { class PathUtil { public: - static AnsiString UnifySeparators(const AnsiString &path); - static AnsiString NormalizeFileName(const AnsiString &path); - static AnsiString Combine(const AnsiString &path1, const AnsiString &path2); - static AnsiString GetDirectoryName(const AnsiString &path); - static AnsiString GetFileName(const AnsiString &path); - static AnsiString GetFileNameWithoutExtension(const AnsiString &path); - static AnsiString GetExtension(const AnsiString &path); - static bool CreateDirectory(const AnsiString &path); - static bool MatchesMask(const AnsiString &fileName, const AnsiString &mask); - - static bool FileExists(const AnsiString &fileName); - - static AnsiString GetSafeLogFileName(); - static AnsiString GetUserDirectory(); + static AnsiString unifySeparators(const AnsiString &path); + static AnsiString normalizeFileName(const AnsiString &path); + static AnsiString combine(const AnsiString &path1, const AnsiString &path2); + static AnsiString getDirectoryName(const AnsiString &path); + static AnsiString getFileName(const AnsiString &path); + static AnsiString getFileNameWithoutExtension(const AnsiString &path); + static AnsiString getExtension(const AnsiString &path); + static bool createDirectory(const AnsiString &path); + static bool matchesMask(const AnsiString &fileName, const AnsiString &mask); + + static bool fileExists(const AnsiString &fileName); + + static AnsiString getSafeLogFileName(); + static AnsiString getUserDirectory(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 2ca392973b..53ad4c8add 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -34,32 +34,32 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -void StringUtil::ToLowerCase(AnsiString &str) { +void StringUtil::toLowerCase(AnsiString &str) { str.toLowercase(); } ////////////////////////////////////////////////////////////////////////// -/*void StringUtil::ToLowerCase(WideString &str) { +/*void StringUtil::toLowerCase(WideString &str) { std::transform(str.begin(), str.end(), str.begin(), ::towlower); }*/ ////////////////////////////////////////////////////////////////////////// -void StringUtil::ToUpperCase(AnsiString &str) { +void StringUtil::toUpperCase(AnsiString &str) { str.toUppercase(); } ////////////////////////////////////////////////////////////////////////// -/*void StringUtil::ToUpperCase(WideString &str) { +/*void StringUtil::toUpperCase(WideString &str) { std::transform(str.begin(), str.end(), str.begin(), ::towupper); }*/ ////////////////////////////////////////////////////////////////////////// -bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { +bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { AnsiString str1lc = str1; AnsiString str2lc = str2; - ToLowerCase(str1lc); - ToLowerCase(str2lc); + toLowerCase(str1lc); + toLowerCase(str2lc); return (str1lc == str2lc); } @@ -76,7 +76,7 @@ bool StringUtil::CompareNoCase(const AnsiString &str1, const AnsiString &str2) { }*/ ////////////////////////////////////////////////////////////////////////// -WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { +WideString StringUtil::utf8ToWide(const Utf8String &Utf8Str) { error("StringUtil::Utf8ToWide - WideString not supported yet"); /* size_t WideSize = Utf8Str.size(); @@ -125,8 +125,8 @@ WideString StringUtil::Utf8ToWide(const Utf8String &Utf8Str) { } ////////////////////////////////////////////////////////////////////////// -Utf8String StringUtil::WideToUtf8(const WideString &WideStr) { - error("StringUtil::WideToUtf8 - Widestring not supported yet"); +Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { + error("StringUtil::wideToUtf8 - Widestring not supported yet"); /* size_t WideSize = WideStr.length(); if (sizeof(wchar_t) == 2) { @@ -187,7 +187,7 @@ char simpleAnsiToWide(const AnsiString &str, uint32 &offset) { } ////////////////////////////////////////////////////////////////////////// -WideString StringUtil::AnsiToWide(const AnsiString &str) { +WideString StringUtil::ansiToWide(const AnsiString &str) { // TODO: This function gets called a lot, so warnings like these drown out the usefull information static bool hasWarned = false; if (!hasWarned) { @@ -212,7 +212,7 @@ WideString StringUtil::AnsiToWide(const AnsiString &str) { } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::WideToAnsi(const WideString &wstr) { +AnsiString StringUtil::wideToAnsi(const WideString &wstr) { // using default os locale! // TODO: This function gets called a lot, so warnings like these drown out the usefull information static bool hasWarned = false; @@ -231,7 +231,7 @@ AnsiString StringUtil::WideToAnsi(const WideString &wstr) { } ////////////////////////////////////////////////////////////////////////// -bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { +bool StringUtil::startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { /* size_t strLength = str.size(); size_t patternLength = pattern.size(); @@ -258,7 +258,7 @@ bool StringUtil::StartsWith(const AnsiString &str, const AnsiString &pattern, bo } ////////////////////////////////////////////////////////////////////////// -bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { +bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { /* size_t strLength = str.size(); // TODO: Remove size_t patternLength = pattern.size(); @@ -285,13 +285,13 @@ bool StringUtil::EndsWith(const AnsiString &str, const AnsiString &pattern, bool } ////////////////////////////////////////////////////////////////////////// -bool StringUtil::IsUtf8BOM(const byte *Buffer, uint32 BufferSize) { +bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; else return false; } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { +AnsiString StringUtil::replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { if (from.empty() || from == to) return str; AnsiString result = str; @@ -317,7 +317,7 @@ AnsiString StringUtil::Replace(const AnsiString &str, const AnsiString &from, co } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { +AnsiString StringUtil::trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { AnsiString trimmedStr = str; if (fromRight) { @@ -325,7 +325,7 @@ AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight warning("fromRight-trim not implemented yet, %s", chars.c_str()); } if (fromLeft) { - uint32 lastOf = LastIndexOf(str, chars, 0); + uint32 lastOf = lastIndexOf(str, chars, 0); trimmedStr = Common::String(trimmedStr.c_str() + lastOf); //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); } @@ -333,7 +333,7 @@ AnsiString StringUtil::Trim(const AnsiString &str, bool fromLeft, bool fromRight } ////////////////////////////////////////////////////////////////////////// -int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { +int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { /*size_t pos = str.find(toFind, startFrom); if (pos == str.npos) return -1; else return pos;*/ @@ -345,7 +345,7 @@ int StringUtil::IndexOf(const WideString &str, const WideString &toFind, size_t } ////////////////////////////////////////////////////////////////////////// -int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { +int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { /*size_t pos = str.rfind(toFind, startFrom); if (pos == str.npos) return -1; else return pos;*/ @@ -368,7 +368,7 @@ int StringUtil::LastIndexOf(const WideString &str, const WideString &toFind, siz } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(size_t val) { +AnsiString StringUtil::toString(size_t val) { /* std::ostringstream str; str << val; return str.str();*/ @@ -376,7 +376,7 @@ AnsiString StringUtil::ToString(size_t val) { } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(int val) { +AnsiString StringUtil::toString(int val) { /* std::ostringstream str; str << val; return str.str();*/ @@ -384,7 +384,7 @@ AnsiString StringUtil::ToString(int val) { } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(float val) { +AnsiString StringUtil::toString(float val) { /* std::ostringstream str; str << val; return str.str();*/ @@ -392,7 +392,7 @@ AnsiString StringUtil::ToString(float val) { } ////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::ToString(double val) { +AnsiString StringUtil::toString(double val) { /* std::ostringstream str; str << val; return str.str();*/ @@ -401,7 +401,7 @@ AnsiString StringUtil::ToString(double val) { ////////////////////////////////////////////////////////////////////////// -void StringUtil::Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { +void StringUtil::split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { result.clear(); //TODO: Verify this, wrt keepEmptyItems. Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h index a4727fabbe..e06551b09a 100644 --- a/engines/wintermute/utils/StringUtil.h +++ b/engines/wintermute/utils/StringUtil.h @@ -35,34 +35,34 @@ namespace WinterMute { class StringUtil { public: - static void ToLowerCase(AnsiString &str); - //static void ToLowerCase(WideString &str); - static void ToUpperCase(AnsiString &str); - //static void ToUpperCase(WideString &str); - static bool CompareNoCase(const AnsiString &str1, const AnsiString &str2); - //static bool CompareNoCase(const WideString &str1, const WideString &str2); - static WideString Utf8ToWide(const Utf8String &Utf8Str); - static Utf8String WideToUtf8(const WideString &WideStr); - static WideString AnsiToWide(const AnsiString &str); - static AnsiString WideToAnsi(const WideString &str); + static void toLowerCase(AnsiString &str); + //static void toLowerCase(WideString &str); + static void toUpperCase(AnsiString &str); + //static void toUpperCase(WideString &str); + static bool compareNoCase(const AnsiString &str1, const AnsiString &str2); + //static bool compareNoCase(const WideString &str1, const WideString &str2); + static WideString utf8ToWide(const Utf8String &Utf8Str); + static Utf8String wideToUtf8(const WideString &WideStr); + static WideString ansiToWide(const AnsiString &str); + static AnsiString wideToAnsi(const WideString &str); - static bool StartsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool EndsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + static bool startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + static bool endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool IsUtf8BOM(const byte *buffer, uint32 bufferSize); + static bool isUtf8BOM(const byte *buffer, uint32 bufferSize); - static AnsiString Replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); - static AnsiString Trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); + static AnsiString replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); + static AnsiString trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); - static int IndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static int LastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); + static int lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static AnsiString ToString(size_t val); - static AnsiString ToString(int val); - static AnsiString ToString(float val); - static AnsiString ToString(double val); + static AnsiString toString(size_t val); + static AnsiString toString(int val); + static AnsiString toString(float val); + static AnsiString toString(double val); - static void Split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); + static void split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); }; } // end of namespace WinterMute diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 2f66313bb0..ae456b25e7 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -101,7 +101,7 @@ float CBUtils::NormalizeAngle(float Angle) { void CBUtils::CreatePath(const char *Path, bool PathOnly) { AnsiString path; - if (!PathOnly) path = PathUtil::GetDirectoryName(Path); + if (!PathOnly) path = PathUtil::getDirectoryName(Path); else path = Path; // try { @@ -237,7 +237,7 @@ bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { ////////////////////////////////////////////////////////////////////////// char *CBUtils::GetPath(const char *Filename) { - AnsiString path = PathUtil::GetDirectoryName(Filename); + AnsiString path = PathUtil::getDirectoryName(Filename); //path = boost::filesystem::syste_complete(path).string(); warning("CBUtils::GetPath: (%s), not implemented", Filename); char *ret = new char[path.size() + 1]; @@ -248,7 +248,7 @@ char *CBUtils::GetPath(const char *Filename) { ////////////////////////////////////////////////////////////////////////// char *CBUtils::GetFilename(const char *Filename) { - AnsiString path = PathUtil::GetFileName(Filename); + AnsiString path = PathUtil::getFileName(Filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); return ret; -- cgit v1.2.3 From 370355f85ec1ac55b7a1467899ecfbff788ec1c7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 06:32:19 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in utils --- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 8 +- engines/wintermute/Ad/AdItem.cpp | 4 +- engines/wintermute/Ad/AdNodeState.cpp | 6 +- engines/wintermute/Ad/AdResponse.cpp | 4 +- engines/wintermute/Ad/AdResponseBox.cpp | 4 +- engines/wintermute/Ad/AdScene.cpp | 8 +- engines/wintermute/Ad/AdTalkDef.cpp | 6 +- engines/wintermute/Ad/AdTalkNode.cpp | 6 +- engines/wintermute/Base/BFileManager.cpp | 8 +- engines/wintermute/Base/BFontTT.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 22 ++-- engines/wintermute/Base/BRegistry.cpp | 2 +- engines/wintermute/Base/BSoundBuffer.cpp | 4 +- engines/wintermute/Base/PartEmitter.cpp | 30 ++--- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 4 +- engines/wintermute/Base/scriptables/SXStore.h | 14 +-- engines/wintermute/Base/scriptables/SXString.cpp | 2 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 +- engines/wintermute/UI/UIEdit.cpp | 2 +- engines/wintermute/utils/utils.cpp | 142 +++++++++++------------ engines/wintermute/utils/utils.h | 30 ++--- engines/wintermute/video/VidTheoraPlayer.cpp | 6 +- 24 files changed, 162 insertions(+), 162 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 89506045b8..0623327e0a 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -999,7 +999,7 @@ HRESULT CAdEntity::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// void CAdEntity::setItem(const char *itemName) { - CBUtils::SetString(&_item, itemName); + CBUtils::setString(&_item, itemName); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index cd493c9471..901a60ba35 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1037,7 +1037,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { if (value == NULL) { delete[] _startupScene; _startupScene = NULL; - } else CBUtils::SetString(&_startupScene, value->getString()); + } else CBUtils::setString(&_startupScene, value->getString()); return S_OK; } @@ -1206,7 +1206,7 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { case TOKEN_ITEMS: ItemsFound = true; - CBUtils::SetString(&_itemsFile, (char *)params2); + CBUtils::setString(&_itemsFile, (char *)params2); if (FAILED(LoadItemsFile(_itemsFile))) { delete[] _itemsFile; _itemsFile = NULL; @@ -1233,11 +1233,11 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_STARTUP_SCENE: - CBUtils::SetString(&_startupScene, (char *)params2); + CBUtils::setString(&_startupScene, (char *)params2); break; case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::SetString(&_debugStartupScene, (char *)params2); + CBUtils::setString(&_debugStartupScene, (char *)params2); break; } } diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index a6c990528f..c105478045 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -238,7 +238,7 @@ HRESULT CAdItem::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_AMOUNT_STRING: - CBUtils::SetString(&_amountString, (char *)params); + CBUtils::setString(&_amountString, (char *)params); break; case TOKEN_TALK: { @@ -705,7 +705,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { delete[] _amountString; _amountString = NULL; } else { - CBUtils::SetString(&_amountString, value->getString()); + CBUtils::setString(&_amountString, value->getString()); } return S_OK; } diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 611d3f4b83..f732067471 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -71,7 +71,7 @@ CAdNodeState::~CAdNodeState() { void CAdNodeState::setName(const char *name) { delete[] _name; _name = NULL; - CBUtils::SetString(&_name, name); + CBUtils::setString(&_name, name); } @@ -79,7 +79,7 @@ void CAdNodeState::setName(const char *name) { void CAdNodeState::setFilename(const char *Filename) { delete[] _filename; _filename = NULL; - CBUtils::SetString(&_filename, Filename); + CBUtils::setString(&_filename, Filename); } @@ -87,7 +87,7 @@ void CAdNodeState::setFilename(const char *Filename) { void CAdNodeState::SetCursor(const char *Filename) { delete[] _cursor; _cursor = NULL; - CBUtils::SetString(&_cursor, Filename); + CBUtils::setString(&_cursor, Filename); } diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 2b1b9efded..36b6ce454a 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -66,8 +66,8 @@ CAdResponse::~CAdResponse() { ////////////////////////////////////////////////////////////////////////// void CAdResponse::SetText(const char *Text) { - CBUtils::SetString(&_text, Text); - CBUtils::SetString(&_textOrig, Text); + CBUtils::setString(&_text, Text); + CBUtils::setString(&_textOrig, Text); } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 912022d7dd..b73465590e 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -567,8 +567,8 @@ HRESULT CAdResponseBox::weedResponses() { ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::setLastResponseText(const char *Text, const char *TextOrig) { - CBUtils::SetString(&_lastResponseText, Text); - CBUtils::SetString(&_lastResponseTextOrig, TextOrig); + CBUtils::setString(&_lastResponseText, Text); + CBUtils::setString(&_lastResponseTextOrig, TextOrig); } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 205f7f12a5..2b5aed2777 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -409,8 +409,8 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { if (xLength > yLength) { if (X1 > X2) { - CBUtils::Swap(&X1, &X2); - CBUtils::Swap(&Y1, &Y2); + CBUtils::swap(&X1, &X2); + CBUtils::swap(&Y1, &Y2); } yStep = (double)(Y2 - Y1) / (double)(X2 - X1); @@ -422,8 +422,8 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { } } else { if (Y1 > Y2) { - CBUtils::Swap(&X1, &X2); - CBUtils::Swap(&Y1, &Y2); + CBUtils::swap(&X1, &X2); + CBUtils::swap(&Y1, &Y2); } xStep = (double)(X2 - X1) / (double)(Y2 - Y1); diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 679da816c0..6a1e0a1d15 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -78,7 +78,7 @@ HRESULT CAdTalkDef::loadFile(const char *Filename) { HRESULT ret; - CBUtils::SetString(&_filename, Filename); + CBUtils::setString(&_filename, Filename); if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); @@ -139,11 +139,11 @@ HRESULT CAdTalkDef::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_DEFAULT_SPRITE: - CBUtils::SetString(&_defaultSpriteFilename, (char *)params); + CBUtils::setString(&_defaultSpriteFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::SetString(&_defaultSpriteSetFilename, (char *)params); + CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET: { diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 291721662a..8b093922e9 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -112,11 +112,11 @@ HRESULT CAdTalkNode::loadBuffer(byte *Buffer, bool Complete) { while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: - CBUtils::SetString(&_spriteFilename, (char *)params); + CBUtils::setString(&_spriteFilename, (char *)params); break; case TOKEN_SPRITESET_FILE: - CBUtils::SetString(&_spriteSetFilename, (char *)params); + CBUtils::setString(&_spriteSetFilename, (char *)params); break; case TOKEN_SPRITESET: { @@ -143,7 +143,7 @@ HRESULT CAdTalkNode::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_COMMENT: - if (Game->_editorMode) CBUtils::SetString(&_comment, (char *)params); + if (Game->_editorMode) CBUtils::setString(&_comment, (char *)params); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 12167624ae..1fe1c7546a 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -287,10 +287,10 @@ HRESULT CBFileManager::initPaths() { // single files paths pathList = Game->_registry->ReadString("Resource", "CustomPaths", ""); - numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_SINGLE, path); } @@ -331,10 +331,10 @@ HRESULT CBFileManager::initPaths() { pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); - numPaths = CBUtils::StrNumEntries(pathList.c_str(), ';'); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::StrEntry(i, pathList.c_str(), ';'); + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_PACKAGE, path); } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 9b4bb3ddff..cc373961e2 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -480,7 +480,7 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { break; case TOKEN_FILENAME: - CBUtils::SetString(&_fontFile, params); + CBUtils::setString(&_fontFile, params); break; case TOKEN_BOLD: @@ -542,7 +542,7 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { _layers.Add(Layer); } - if (!_fontFile) CBUtils::SetString(&_fontFile, "arial.ttf"); + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); return initFont(); } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index f2908c9d96..b3c4c87ecd 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -212,7 +212,7 @@ CBGame::CBGame(): CBObject(this) { _indicatorHeight = 8; _richSavedGames = false; _savedGameExt = NULL; - CBUtils::SetString(&_savedGameExt, "dsv"); + CBUtils::setString(&_savedGameExt, "dsv"); _musicCrossfadeRunning = false; _musicCrossfadeStartTime = 0; @@ -229,7 +229,7 @@ CBGame::CBGame(): CBObject(this) { _loadImageX = _loadImageY = 0; _localSaveDir = NULL; - CBUtils::SetString(&_localSaveDir, "saves"); + CBUtils::setString(&_localSaveDir, "saves"); _saveDirChecked = false; _loadingIcon = NULL; @@ -925,7 +925,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SAVE_IMAGE: - CBUtils::SetString(&_saveImageName, (char *)params); + CBUtils::setString(&_saveImageName, (char *)params); break; case TOKEN_SAVE_IMAGE_X: @@ -937,7 +937,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOAD_IMAGE: - CBUtils::SetString(&_loadImageName, (char *)params); + CBUtils::setString(&_loadImageName, (char *)params); break; case TOKEN_LOAD_IMAGE_X: @@ -949,7 +949,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOCAL_SAVE_DIR: - CBUtils::SetString(&_localSaveDir, (char *)params); + CBUtils::setString(&_localSaveDir, (char *)params); break; case TOKEN_COMPAT_KILL_METHOD_THREADS: @@ -1369,8 +1369,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int right = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - if (right < left) CBUtils::Swap(&left, &right); - if (bottom < top) CBUtils::Swap(&top, &bottom); + if (right < left) CBUtils::swap(&left, &right); + if (bottom < top) CBUtils::swap(&top, &bottom); CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); @@ -1900,7 +1900,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::SetString(&_loadImageName, Val->getString()); + CBUtils::setString(&_loadImageName, Val->getString()); } stack->pushNULL(); return S_OK; @@ -1919,7 +1919,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete[] _saveImageName; _saveImageName = NULL; } else { - CBUtils::SetString(&_saveImageName, Val->getString()); + CBUtils::setString(&_saveImageName, Val->getString()); } stack->pushNULL(); return S_OK; @@ -3026,7 +3026,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS int from = stack->pop()->getInt(); int to = stack->pop()->getInt(); - stack->pushInt(CBUtils::RandomInt(from, to)); + stack->pushInt(CBUtils::randomInt(from, to)); } ////////////////////////////////////////////////////////////////////////// @@ -3589,7 +3589,7 @@ HRESULT CBGame::loadSettings(const char *filename) { break; case TOKEN_SAVED_GAME_EXT: - CBUtils::SetString(&_savedGameExt, (char *)params); + CBUtils::setString(&_savedGameExt, (char *)params); break; case TOKEN_GUID: diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index efc2c77d88..7a77e17fc7 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -188,7 +188,7 @@ void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { ////////////////////////////////////////////////////////////////////////// void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::CreatePath(fileName.c_str()); + CBUtils::createPath(fileName.c_str()); TiXmlDocument doc; doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 80753c5f50..55db2a0f89 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -122,7 +122,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { if (!_stream) { return E_FAIL; } - CBUtils::SetString(&_filename, Filename); + CBUtils::setString(&_filename, Filename); return S_OK; #if 0 @@ -138,7 +138,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { return E_FAIL; } - CBUtils::SetString(&_filename, Filename); + CBUtils::setString(&_filename, Filename); /* HRESULT res; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 276540a14f..785e8738b5 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -155,28 +155,28 @@ HRESULT CPartEmitter::initParticle(CPartParticle *Particle, uint32 CurrentTime, if (!Particle) return E_FAIL; if (_sprites.GetSize() == 0) return E_FAIL; - int PosX = CBUtils::RandomInt(_posX, _posX + _width); - int PosY = CBUtils::RandomInt(_posY, _posY + _height); - float PosZ = CBUtils::RandomFloat(0.0f, 100.0f); + int PosX = CBUtils::randomInt(_posX, _posX + _width); + int PosY = CBUtils::randomInt(_posY, _posY + _height); + float PosZ = CBUtils::randomFloat(0.0f, 100.0f); float Velocity; if (_velocityZBased) Velocity = _velocity1 + PosZ * (_velocity2 - _velocity1) / 100; - else Velocity = CBUtils::RandomFloat(_velocity1, _velocity2); + else Velocity = CBUtils::randomFloat(_velocity1, _velocity2); float Scale; if (_scaleZBased) Scale = _scale1 + PosZ * (_scale2 - _scale1) / 100; - else Scale = CBUtils::RandomFloat(_scale1, _scale2); + else Scale = CBUtils::randomFloat(_scale1, _scale2); int LifeTime; if (_lifeTimeZBased) LifeTime = _lifeTime2 - PosZ * (_lifeTime2 - _lifeTime1) / 100; - else LifeTime = CBUtils::RandomInt(_lifeTime1, _lifeTime2); + else LifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - float Angle = CBUtils::RandomAngle(_angle1, _angle2); - int SpriteIndex = CBUtils::RandomInt(0, _sprites.GetSize() - 1); + float Angle = CBUtils::randomAngle(_angle1, _angle2); + int SpriteIndex = CBUtils::randomInt(0, _sprites.GetSize() - 1); - float Rotation = CBUtils::RandomAngle(_rotation1, _rotation2); - float AngVelocity = CBUtils::RandomFloat(_angVelocity1, _angVelocity2); - float GrowthRate = CBUtils::RandomFloat(_growthRate1, _growthRate2); + float Rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float AngVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float GrowthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); if (!CBPlatform::IsRectEmpty(&_border)) { int ThicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f); @@ -195,14 +195,14 @@ HRESULT CPartEmitter::initParticle(CPartParticle *Particle, uint32 CurrentTime, Vector2 VecVel(0, Velocity); Matrix4 MatRot; - MatRot.RotationZ(Common::deg2rad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.RotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); MatRot.TransformVector2(VecVel); if (_alphaTimeBased) { Particle->_alpha1 = _alpha1; Particle->_alpha2 = _alpha2; } else { - int Alpha = CBUtils::RandomInt(_alpha1, _alpha2); + int Alpha = CBUtils::randomInt(_alpha1, _alpha2); Particle->_alpha1 = Alpha; Particle->_alpha2 = Alpha; } @@ -394,7 +394,7 @@ HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType Type, in Force->_direction = Vector2(0, Strength); Matrix4 MatRot; - MatRot.RotationZ(Common::deg2rad(CBUtils::NormalizeAngle(Angle - 180))); + MatRot.RotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); MatRot.TransformVector2(Force->_direction); return S_OK; @@ -1082,7 +1082,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->isNULL()) CBUtils::SetString(&_emitEvent, value->getString()); + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); return S_OK; } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index b348521808..604e113b90 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -164,7 +164,7 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 // update rotation _rotation += _angVelocity * ElapsedTime; - _rotation = CBUtils::NormalizeAngle(_rotation); + _rotation = CBUtils::normalizeAngle(_rotation); // update scale if (_exponentialGrowth) diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 6738df0301..e31afde2e9 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -60,7 +60,7 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { CScValue *Val = stack->pop(); _filename = NULL; - if (!Val->isNULL()) CBUtils::SetString(&_filename, Val->getString()); + if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); _readFile = NULL; _writeFile = NULL; @@ -113,7 +113,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); const char *Filename = stack->pop()->getString(); cleanup(); - CBUtils::SetString(&_filename, Filename); + CBUtils::setString(&_filename, Filename); stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 3c39b3f266..43d36553a7 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -47,10 +47,10 @@ public: CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { _id = _name = _desc = _price = NULL; - CBUtils::SetString(&_id, id); - CBUtils::SetString(&_name, name); - CBUtils::SetString(&_desc, desc); - CBUtils::SetString(&_price, price); + CBUtils::setString(&_id, id); + CBUtils::setString(&_name, name); + CBUtils::setString(&_desc, desc); + CBUtils::setString(&_price, price); } ~CBStoreProduct() { @@ -98,9 +98,9 @@ public: CBStoreTransaction(const char *id, const char *productId, const char *state) { _id = _productId = _state = NULL; - CBUtils::SetString(&_id, id); - CBUtils::SetString(&_productId, productId); - CBUtils::SetString(&_state, state); + CBUtils::setString(&_id, id); + CBUtils::setString(&_productId, productId); + CBUtils::setString(&_state, state); } ~CBStoreTransaction() { diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 58cce4d7bb..f5981bb73d 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -108,7 +108,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th int start = stack->pop()->getInt(); int end = stack->pop()->getInt(); - if (end < start) CBUtils::Swap(&start, &end); + if (end < start) CBUtils::swap(&start, &end); //try { WideString str; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index deeaeb1443..b0fb447e17 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -786,8 +786,8 @@ HRESULT CScEngine::LoadBreakpoints() { sprintf(Key, "Breakpoint%d", i); AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); - char *Path = CBUtils::StrEntry(0, breakpoint.c_str(), ':'); - char *Line = CBUtils::StrEntry(1, breakpoint.c_str(), ':'); + char *Path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *Line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); delete[] Path; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 2dec9c139f..d87eeea630 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -790,7 +790,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// int CUIEdit::deleteChars(int Start, int End) { - if (Start > End) CBUtils::Swap(&Start, &End); + if (Start > End) CBUtils::swap(&Start, &End); Start = MAX(Start, (int)0); End = MIN((size_t)End, strlen(_text)); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ae456b25e7..ab7ebac565 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -45,30 +45,30 @@ static inline unsigned Sqr(int x) { ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect) { +void CBUtils::clip(int *destX, int *destY, RECT *srcRect, RECT *destRect) { // If it's partly off the right side of the screen - if (*DestX + (SrcRect->right - SrcRect->left) > DestRect->right) - SrcRect->right -= *DestX + (SrcRect->right - SrcRect->left) - DestRect->right; + if (*destX + (srcRect->right - srcRect->left) > destRect->right) + srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; - if (SrcRect->right < 0) SrcRect->right = 0; + if (srcRect->right < 0) srcRect->right = 0; // Partly off the left side of the screen - if (*DestX < DestRect->left) { - SrcRect->left += DestRect->left - *DestX; - *DestX = DestRect->left; + if (*destX < destRect->left) { + srcRect->left += destRect->left - *destX; + *destX = destRect->left; } // Partly off the top of the screen - if (*DestY < DestRect->top) { - SrcRect->top += DestRect->top - *DestY; - *DestY = DestRect->top; + if (*destY < destRect->top) { + srcRect->top += destRect->top - *destY; + *destY = destRect->top; } // If it's partly off the bottom side of the screen - if (*DestY + (SrcRect->bottom - SrcRect->top) > DestRect->bottom) - SrcRect->bottom -= ((SrcRect->bottom - SrcRect->top) + *DestY) - DestRect->bottom; + if (*destY + (srcRect->bottom - srcRect->top) > destRect->bottom) + srcRect->bottom -= ((srcRect->bottom - srcRect->top) + *destY) - destRect->bottom; - if (SrcRect->bottom < 0) SrcRect->bottom = 0; + if (srcRect->bottom < 0) srcRect->bottom = 0; return; } @@ -76,36 +76,36 @@ void CBUtils::Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect) { ////////////////////////////////////////////////////////////////////////////////// // Swap - swaps two integers ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::Swap(int *a, int *b) { +void CBUtils::swap(int *a, int *b) { int Temp = *a; *a = *b; *b = Temp; } ////////////////////////////////////////////////////////////////////////// -bool CBUtils::StrBeginsI(const char *String, const char *Fragment) { - return (scumm_strnicmp(String, Fragment, strlen(Fragment)) == 0); +bool CBUtils::strBeginsI(const char *string, const char *fragment) { + return (scumm_strnicmp(string, fragment, strlen(fragment)) == 0); } ////////////////////////////////////////////////////////////////////////// -float CBUtils::NormalizeAngle(float Angle) { - while (Angle > 360) Angle -= 360; - while (Angle < 0) Angle += 360; +float CBUtils::normalizeAngle(float angle) { + while (angle > 360) angle -= 360; + while (angle < 0) angle += 360; - return Angle; + return angle; } //////////////////////////////////////////////////////////////////////////////// -void CBUtils::CreatePath(const char *Path, bool PathOnly) { - AnsiString path; +void CBUtils::createPath(const char *path, bool pathOnly) { + AnsiString pathStr; - if (!PathOnly) path = PathUtil::getDirectoryName(Path); - else path = Path; + if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); + else pathStr = path; // try { - warning("CBUtils::CreatePath - not implemented: %s", Path); + warning("CBUtils::CreatePath - not implemented: %s", path); // boost::filesystem::create_directories(path); // } catch (...) { return; @@ -114,13 +114,13 @@ void CBUtils::CreatePath(const char *Path, bool PathOnly) { ////////////////////////////////////////////////////////////////////////// -void CBUtils::DebugMessage(HWND hWnd, const char *Text) { +void CBUtils::debugMessage(HWND hWnd, const char *text) { //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::SetString(char **string, const char *value) { +char *CBUtils::setString(char **string, const char *value) { delete[] *string; *string = new char[strlen(value) + 1]; if (*string) strcpy(*string, value); @@ -128,34 +128,34 @@ char *CBUtils::SetString(char **string, const char *value) { } ////////////////////////////////////////////////////////////////////////// -int CBUtils::StrNumEntries(const char *Str, const char Delim) { - int NumEntries = 1; - for (uint32 i = 0; i < strlen(Str); i++) { - if (Str[i] == Delim) NumEntries++; +int CBUtils::strNumEntries(const char *str, const char delim) { + int numEntries = 1; + for (uint32 i = 0; i < strlen(str); i++) { + if (str[i] == delim) numEntries++; } - return NumEntries; + return numEntries; } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { - int NumEntries = 0; +char *CBUtils::strEntry(int entry, const char *str, const char delim) { + int numEntries = 0; - const char *Start = NULL; - int Len = 0; + const char *start = NULL; + int len = 0; - for (uint32 i = 0; i <= strlen(Str); i++) { - if (NumEntries == Entry) { - if (!Start) Start = Str + i; - else Len++; + for (uint32 i = 0; i <= strlen(str); i++) { + if (numEntries == entry) { + if (!start) start = str + i; + else len++; } - if (Str[i] == Delim || Str[i] == '\0') { - NumEntries++; - if (Start) { - char *Ret = new char[Len + 1]; - memset(Ret, 0, Len + 1); - strncpy(Ret, Start, Len); - return Ret; + if (str[i] == delim || str[i] == '\0') { + numEntries++; + if (start) { + char *ret = new char[len + 1]; + memset(ret, 0, len + 1); + strncpy(ret, start, len); + return ret; } } } @@ -163,7 +163,7 @@ char *CBUtils::StrEntry(int Entry, const char *Str, const char Delim) { } ////////////////////////////////////////////////////////////////////////// -int CBUtils::RandomInt(int from, int to) { +int CBUtils::randomInt(int from, int to) { if (to < from) { int i = to; to = from; @@ -174,27 +174,27 @@ int CBUtils::RandomInt(int from, int to) { } ////////////////////////////////////////////////////////////////////////// -float CBUtils::RandomFloat(float from, float to) { +float CBUtils::randomFloat(float from, float to) { const uint32 randMax = RAND_MAX; float randNum = (float)g_wintermute->randInt(0, randMax) / (float)randMax; return from + (to - from) * randNum; } ////////////////////////////////////////////////////////////////////////// -float CBUtils::RandomAngle(float From, float To) { +float CBUtils::randomAngle(float From, float To) { while (To < From) { To += 360; } - return NormalizeAngle(RandomFloat(From, To)); + return normalizeAngle(randomFloat(From, To)); } ////////////////////////////////////////////////////////////////////////// -bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { +bool CBUtils::matchesPattern(const char *pattern, const char *string) { char stringc, patternc; - for (;; ++String) { - stringc = toupper(*String); - patternc = toupper(*Pattern++); + for (;; ++string) { + stringc = toupper(*string); + patternc = toupper(*pattern++); switch (patternc) { case 0: @@ -205,29 +205,29 @@ bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { break; case '*': - if (!*Pattern) return true; + if (!*pattern) return true; - if (*Pattern == '.') { + if (*pattern == '.') { char *dot; - if (Pattern[1] == '*' && Pattern[2] == 0) return true; - dot = (char *)strchr(String, '.'); - if (Pattern[1] == 0) return (dot == NULL || dot[1] == 0); + if (pattern[1] == '*' && pattern[2] == 0) return true; + dot = (char *)strchr(string, '.'); + if (pattern[1] == 0) return (dot == NULL || dot[1] == 0); if (dot != NULL) { - String = dot; - if (strpbrk(Pattern, "*?[") == NULL && strchr(String + 1, '.') == NULL) - return(scumm_stricmp(Pattern + 1, String + 1) == 0); + string = dot; + if (strpbrk(pattern, "*?[") == NULL && strchr(string + 1, '.') == NULL) + return(scumm_stricmp(pattern + 1, string + 1) == 0); } } - while (*String) - if (CBUtils::MatchesPattern(Pattern, String++)) + while (*string) + if (CBUtils::matchesPattern(pattern, string++)) return true; return false; default: if (patternc != stringc) if (patternc == '.' && stringc == 0) - return(CBUtils::MatchesPattern(Pattern, String)); + return(CBUtils::matchesPattern(pattern, string)); else return false; break; @@ -236,10 +236,10 @@ bool CBUtils::MatchesPattern(const char *Pattern, const char *String) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetPath(const char *Filename) { - AnsiString path = PathUtil::getDirectoryName(Filename); +char *CBUtils::getPath(const char *filename) { + AnsiString path = PathUtil::getDirectoryName(filename); //path = boost::filesystem::syste_complete(path).string(); - warning("CBUtils::GetPath: (%s), not implemented", Filename); + warning("CBUtils::GetPath: (%s), not implemented", filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); @@ -247,8 +247,8 @@ char *CBUtils::GetPath(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::GetFilename(const char *Filename) { - AnsiString path = PathUtil::getFileName(Filename); +char *CBUtils::getFilename(const char *filename) { + AnsiString path = PathUtil::getFileName(filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); return ret; diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 46e895ff4d..219cacd249 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -37,27 +37,27 @@ class CBGame; class CBUtils { public: - static void Clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); - static void Swap(int *a, int *b); - static bool StrBeginsI(const char *String, const char *Fragment); - static float NormalizeAngle(float Angle); + static void clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); + static void swap(int *a, int *b); + static bool strBeginsI(const char *String, const char *Fragment); + static float normalizeAngle(float Angle); - static void CreatePath(const char *Path, bool PathOnly = false); + static void createPath(const char *Path, bool PathOnly = false); - static void DebugMessage(HWND hWnd, const char *Text); - static char *SetString(char **String, const char *Value); + static void debugMessage(HWND hWnd, const char *Text); + static char *setString(char **String, const char *Value); - static int StrNumEntries(const char *Str, const char Delim = ','); - static char *StrEntry(int Entry, const char *Str, const char Delim = ','); + static int strNumEntries(const char *Str, const char Delim = ','); + static char *strEntry(int Entry, const char *Str, const char Delim = ','); - static int RandomInt(int From, int To); - static float RandomFloat(float From, float To); - static float RandomAngle(float From, float To); + static int randomInt(int From, int To); + static float randomFloat(float From, float To); + static float randomAngle(float From, float To); - static bool MatchesPattern(const char *pattern, const char *string); + static bool matchesPattern(const char *pattern, const char *string); - static char *GetPath(const char *Filename); - static char *GetFilename(const char *Filename); + static char *getPath(const char *Filename); + static char *getFilename(const char *Filename); static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); static uint32 HSLtoRGB(byte H, byte S, byte L); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 2c93e2ee33..d47f3b3ae5 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -140,7 +140,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _file = Game->_fileManager->openFile(filename, true, false); if (!_file) return E_FAIL; - //if (Filename != _filename) CBUtils::SetString(&_filename, Filename); + //if (Filename != _filename) CBUtils::setString(&_filename, Filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else @@ -167,7 +167,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _file = Game->_fileManager->openFile(Filename); if (!_file) return E_FAIL; - if (Filename != _filename) CBUtils::SetString(&_filename, Filename); + if (Filename != _filename) CBUtils::setString(&_filename, Filename); // start up Ogg stream synchronization layer ogg_sync_init(&m_OggSyncState); @@ -691,7 +691,7 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { SAFE_DELETE_ARRAY(m_AlphaFilename); return E_FAIL; } - if (m_AlphaFilename != Filename) CBUtils::SetString(&m_AlphaFilename, Filename); + if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, Filename); m_AlphaImage->Convert(IMG_TRUECOLOR); #endif return S_OK; -- cgit v1.2.3 From 46d2428dabb1637218b924753e9a3942d4d73b69 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 06:34:48 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in Math-classes --- engines/wintermute/Base/PartEmitter.cpp | 8 ++++---- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/math/MathUtil.cpp | 4 ++-- engines/wintermute/math/MathUtil.h | 4 ++-- engines/wintermute/math/Matrix4.cpp | 8 ++++---- engines/wintermute/math/Matrix4.h | 6 +++--- engines/wintermute/math/Vector2.cpp | 2 +- engines/wintermute/math/Vector2.h | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 785e8738b5..e38abb5005 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -195,8 +195,8 @@ HRESULT CPartEmitter::initParticle(CPartParticle *Particle, uint32 CurrentTime, Vector2 VecVel(0, Velocity); Matrix4 MatRot; - MatRot.RotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); - MatRot.TransformVector2(VecVel); + MatRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); + MatRot.transformVector2(VecVel); if (_alphaTimeBased) { Particle->_alpha1 = _alpha1; @@ -394,8 +394,8 @@ HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType Type, in Force->_direction = Vector2(0, Strength); Matrix4 MatRot; - MatRot.RotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); - MatRot.TransformVector2(Force->_direction); + MatRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); + MatRot.transformVector2(Force->_direction); return S_OK; } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 604e113b90..9c938ac835 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -151,7 +151,7 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 case CPartForce::FORCE_POINT: { Vector2 VecDist = Force->_pos - _pos; - float Dist = fabs(VecDist.Length()); + float Dist = fabs(VecDist.length()); Dist = 100.0f / Dist; diff --git a/engines/wintermute/math/MathUtil.cpp b/engines/wintermute/math/MathUtil.cpp index d6b526f5b6..47b472d9cf 100644 --- a/engines/wintermute/math/MathUtil.cpp +++ b/engines/wintermute/math/MathUtil.cpp @@ -32,14 +32,14 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -float MathUtil::Round(float val) { +float MathUtil::round(float val) { float result = floor(val); if (val - result >= 0.5) result += 1.0; return result; } ////////////////////////////////////////////////////////////////////////// -float MathUtil::RoundUp(float val) { +float MathUtil::roundUp(float val) { float result = floor(val); if (val - result > 0) result += 1.0; return result; diff --git a/engines/wintermute/math/MathUtil.h b/engines/wintermute/math/MathUtil.h index bacf975d62..db814a59ac 100644 --- a/engines/wintermute/math/MathUtil.h +++ b/engines/wintermute/math/MathUtil.h @@ -33,8 +33,8 @@ namespace WinterMute { class MathUtil { public: - static float Round(float val); - static float RoundUp(float val); + static float round(float val); + static float roundUp(float val); }; } // end of namespace WinterMute diff --git a/engines/wintermute/math/Matrix4.cpp b/engines/wintermute/math/Matrix4.cpp index d9d17b613b..557f0d5c9a 100644 --- a/engines/wintermute/math/Matrix4.cpp +++ b/engines/wintermute/math/Matrix4.cpp @@ -47,7 +47,7 @@ Matrix4::~Matrix4() { ////////////////////////////////////////////////////////////////////////// -void Matrix4::Identity() { +void Matrix4::identity() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { m[i][j] = 0.0f; @@ -61,8 +61,8 @@ void Matrix4::Identity() { } ////////////////////////////////////////////////////////////////////////// -void Matrix4::RotationZ(float angle) { - Identity(); +void Matrix4::rotationZ(float angle) { + identity(); m[0][0] = cos(angle); m[1][1] = cos(angle); @@ -71,7 +71,7 @@ void Matrix4::RotationZ(float angle) { } ////////////////////////////////////////////////////////////////////////// -void Matrix4::TransformVector2(Vector2 &vec) { +void Matrix4::transformVector2(Vector2 &vec) { float norm; norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; diff --git a/engines/wintermute/math/Matrix4.h b/engines/wintermute/math/Matrix4.h index da5fd1393a..5def8dfe97 100644 --- a/engines/wintermute/math/Matrix4.h +++ b/engines/wintermute/math/Matrix4.h @@ -38,9 +38,9 @@ public: Matrix4(); ~Matrix4(); - void Identity(); - void RotationZ(float angle); - void TransformVector2(Vector2 &vec); + void identity(); + void rotationZ(float angle); + void transformVector2(Vector2 &vec); /* union { struct { diff --git a/engines/wintermute/math/Vector2.cpp b/engines/wintermute/math/Vector2.cpp index a72fb51e79..8bd10320a8 100644 --- a/engines/wintermute/math/Vector2.cpp +++ b/engines/wintermute/math/Vector2.cpp @@ -48,7 +48,7 @@ Vector2::~Vector2() { ////////////////////////////////////////////////////////////////////////// -float Vector2::Length() const { +float Vector2::length() const { return (float)sqrt(x * x + y * y); } diff --git a/engines/wintermute/math/Vector2.h b/engines/wintermute/math/Vector2.h index aa3fe5aa86..96d3a3827d 100644 --- a/engines/wintermute/math/Vector2.h +++ b/engines/wintermute/math/Vector2.h @@ -37,7 +37,7 @@ public: Vector2(float x, float y); ~Vector2(); - float Length() const; + float length() const; inline Vector2 &operator= (const Vector2 &other) { x = other.x; -- cgit v1.2.3 From 0f249f55db2f2d4b6f94b9eea195d42e49a74248 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 13:15:47 +0200 Subject: WINTERMUTE: Rename FuncName->funcName and VarName->varName mainly in AdGame. (But also all const char* Filename->filename) --- engines/wintermute/Ad/AdActor.cpp | 6 +- engines/wintermute/Ad/AdEntity.cpp | 16 +- engines/wintermute/Ad/AdGame.cpp | 582 +++++++++++------------ engines/wintermute/Ad/AdGame.h | 100 ++-- engines/wintermute/Ad/AdInventory.cpp | 2 +- engines/wintermute/Ad/AdInventoryBox.cpp | 16 +- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 34 +- engines/wintermute/Ad/AdItem.h | 2 +- engines/wintermute/Ad/AdLayer.cpp | 12 +- engines/wintermute/Ad/AdLayer.h | 2 +- engines/wintermute/Ad/AdNodeState.cpp | 8 +- engines/wintermute/Ad/AdNodeState.h | 4 +- engines/wintermute/Ad/AdObject.cpp | 58 +-- engines/wintermute/Ad/AdRegion.cpp | 12 +- engines/wintermute/Ad/AdRegion.h | 2 +- engines/wintermute/Ad/AdResponse.cpp | 24 +- engines/wintermute/Ad/AdResponse.h | 8 +- engines/wintermute/Ad/AdResponseBox.cpp | 20 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 12 +- engines/wintermute/Ad/AdRotLevel.h | 2 +- engines/wintermute/Ad/AdScaleLevel.cpp | 12 +- engines/wintermute/Ad/AdScaleLevel.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 52 +- engines/wintermute/Ad/AdScene.h | 2 +- engines/wintermute/Ad/AdSceneNode.cpp | 8 +- engines/wintermute/Ad/AdTalkDef.cpp | 10 +- engines/wintermute/Ad/AdTalkHolder.cpp | 24 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 12 +- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- engines/wintermute/Base/BDebugger.cpp | 28 +- engines/wintermute/Base/BDebugger.h | 32 +- engines/wintermute/Base/BFileManager.cpp | 84 ++-- engines/wintermute/Base/BFont.cpp | 22 +- engines/wintermute/Base/BFont.h | 4 +- engines/wintermute/Base/BFontBitmap.cpp | 12 +- engines/wintermute/Base/BFontBitmap.h | 2 +- engines/wintermute/Base/BFontStorage.cpp | 10 +- engines/wintermute/Base/BFontStorage.h | 2 +- engines/wintermute/Base/BFontTT.cpp | 12 +- engines/wintermute/Base/BFrame.cpp | 16 +- engines/wintermute/Base/BGame.cpp | 172 +++---- engines/wintermute/Base/BGame.h | 110 ++--- engines/wintermute/Base/BImage.cpp | 4 +- engines/wintermute/Base/BImage.h | 2 +- engines/wintermute/Base/BObject.cpp | 22 +- engines/wintermute/Base/BObject.h | 6 +- engines/wintermute/Base/BPersistMgr.cpp | 4 +- engines/wintermute/Base/BRegion.cpp | 12 +- engines/wintermute/Base/BRegion.h | 2 +- engines/wintermute/Base/BRegistry.cpp | 4 +- engines/wintermute/Base/BRenderSDL.cpp | 6 +- engines/wintermute/Base/BRenderSDL.h | 2 +- engines/wintermute/Base/BRenderer.h | 2 +- engines/wintermute/Base/BSaveThumbHelper.cpp | 4 +- engines/wintermute/Base/BScriptHolder.cpp | 30 +- engines/wintermute/Base/BSoundBuffer.cpp | 30 +- engines/wintermute/Base/BSoundBuffer.h | 2 +- engines/wintermute/Base/BSoundMgr.cpp | 14 +- engines/wintermute/Base/BSoundMgr.h | 2 +- engines/wintermute/Base/BSprite.cpp | 38 +- engines/wintermute/Base/BSprite.h | 4 +- engines/wintermute/Base/BStringTable.cpp | 6 +- engines/wintermute/Base/BStringTable.h | 2 +- engines/wintermute/Base/BSubFrame.cpp | 12 +- engines/wintermute/Base/BSubFrame.h | 2 +- engines/wintermute/Base/BSurface.h | 4 +- engines/wintermute/Base/BSurfaceStorage.cpp | 10 +- engines/wintermute/Base/BSurfaceStorage.h | 2 +- engines/wintermute/Base/PartEmitter.cpp | 18 +- engines/wintermute/Base/PartEmitter.h | 4 +- engines/wintermute/Base/PartParticle.cpp | 16 +- engines/wintermute/Base/PartParticle.h | 2 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXFile.cpp | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 56 +-- engines/wintermute/Base/scriptables/ScEngine.h | 16 +- engines/wintermute/Base/scriptables/ScScript.cpp | 34 +- engines/wintermute/Base/scriptables/ScScript.h | 2 +- engines/wintermute/PlatformSDL.cpp | 18 +- engines/wintermute/Sys/SysClassRegistry.cpp | 8 +- engines/wintermute/UI/UIButton.cpp | 28 +- engines/wintermute/UI/UIButton.h | 2 +- engines/wintermute/UI/UIEdit.cpp | 12 +- engines/wintermute/UI/UIEdit.h | 2 +- engines/wintermute/UI/UIEntity.cpp | 22 +- engines/wintermute/UI/UIEntity.h | 4 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 12 +- engines/wintermute/UI/UIText.h | 2 +- engines/wintermute/UI/UITiledImage.cpp | 12 +- engines/wintermute/UI/UITiledImage.h | 2 +- engines/wintermute/UI/UIWindow.cpp | 20 +- engines/wintermute/UI/UIWindow.h | 2 +- engines/wintermute/utils/utils.h | 4 +- engines/wintermute/video/VidPlayer.cpp | 20 +- engines/wintermute/video/VidPlayer.h | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 14 +- engines/wintermute/wintermute.cpp | 16 +- 100 files changed, 1069 insertions(+), 1073 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index f553128d79..1af137e96f 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -696,12 +696,12 @@ HRESULT CAdActor::update() { if (_tempSprite2) { _tempSprite2->Reset(); _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } break; @@ -898,7 +898,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val = stack->pop(); // turn to object? - if (val->isNative() && Game->ValidObject((CBObject *)val->getNative())) { + if (val->isNative() && Game->validObject((CBObject *)val->getNative())) { CBObject *obj = (CBObject *)val->getNative(); int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); dir = (int)angleToDirection(angle); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 0623327e0a..27509a529c 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -73,7 +73,7 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { ////////////////////////////////////////////////////////////////////////// CAdEntity::~CAdEntity() { - Game->UnregisterObject(_region); + Game->unregisterObject(_region); delete _theora; _theora = NULL; @@ -318,13 +318,13 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_REGION: { - if (_region) Game->UnregisterObject(_region); + if (_region) Game->unregisterObject(_region); _region = NULL; CBRegion *rgn = new CBRegion(Game); if (!rgn || FAILED(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else { _region = rgn; - Game->RegisterObject(_region); + Game->registerObject(_region); } } break; @@ -474,7 +474,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { _alphaColor = DRGBA(ar, ag, ab, alpha); _state = STATE_READY; - if (_item && ((CAdGame *)Game)->IsItemTaken(_item)) _active = false; + if (_item && ((CAdGame *)Game)->isItemTaken(_item)) _active = false; return S_OK; } @@ -577,11 +577,11 @@ HRESULT CAdEntity::update() { _tempSprite2->Reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } break; @@ -733,7 +733,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); if (!_region) { _region = new CBRegion(Game); - Game->RegisterObject(_region); + Game->registerObject(_region); } if (_region) stack->pushNative(_region, true); else stack->pushNULL(); @@ -747,7 +747,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "DeleteRegion") == 0) { stack->correctParams(0); if (_region) { - Game->UnregisterObject(_region); + Game->unregisterObject(_region); _region = NULL; stack->pushBool(true); } else stack->pushBool(false); diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 901a60ba35..969a03456d 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -72,7 +72,7 @@ CAdGame::CAdGame(): CBGame() { _scene = new CAdScene(Game); _scene->setName(""); - RegisterObject(_scene); + registerObject(_scene); _prevSceneName = NULL; _prevSceneFilename = NULL; @@ -106,7 +106,7 @@ CAdGame::CAdGame(): CBGame() { _smartItemCursor = false; - AddSpeechDir("speech"); + addSpeechDir("speech"); } @@ -121,7 +121,7 @@ HRESULT CAdGame::cleanup() { int i; for (i = 0; i < _objects.GetSize(); i++) { - UnregisterObject(_objects[i]); + unregisterObject(_objects[i]); _objects[i] = NULL; } _objects.RemoveAll(); @@ -138,11 +138,11 @@ HRESULT CAdGame::cleanup() { _speechDirs.RemoveAll(); - UnregisterObject(_scene); + unregisterObject(_scene); _scene = NULL; // remove items - for (i = 0; i < _items.GetSize(); i++) Game->UnregisterObject(_items[i]); + for (i = 0; i < _items.GetSize(); i++) Game->unregisterObject(_items[i]); _items.RemoveAll(); @@ -157,12 +157,12 @@ HRESULT CAdGame::cleanup() { if (_responseBox) { - Game->UnregisterObject(_responseBox); + Game->unregisterObject(_responseBox); _responseBox = NULL; } if (_inventoryBox) { - Game->UnregisterObject(_inventoryBox); + Game->unregisterObject(_inventoryBox); _inventoryBox = NULL; } @@ -195,9 +195,9 @@ HRESULT CAdGame::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::InitLoop() { +HRESULT CAdGame::initLoop() { if (_scheduledScene && _transMgr->isReady()) { - ChangeScene(_scheduledScene, _scheduledFadeIn); + changeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; _scheduledScene = NULL; @@ -218,40 +218,40 @@ HRESULT CAdGame::InitLoop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddObject(CAdObject *Object) { - _objects.Add(Object); - return RegisterObject(Object); +HRESULT CAdGame::addObject(CAdObject *object) { + _objects.Add(object); + return registerObject(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RemoveObject(CAdObject *Object) { +HRESULT CAdGame::removeObject(CAdObject *object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { - HRESULT Res = _scene->removeObject(Object); + HRESULT Res = _scene->removeObject(object); if (SUCCEEDED(Res)) return Res; } for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] == Object) { + if (_objects[i] == object) { _objects.RemoveAt(i); break; } } - return UnregisterObject(Object); + return unregisterObject(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { +HRESULT CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene == NULL) { _scene = new CAdScene(Game); - RegisterObject(_scene); + registerObject(_scene); } else { _scene->applyEvent("SceneShutdown", true); - SetPrevSceneName(_scene->_name); - SetPrevSceneFilename(_scene->_filename); + setPrevSceneName(_scene->_name); + setPrevSceneFilename(_scene->_filename); if (!_tempDisableSaveState) _scene->saveState(); _tempDisableSaveState = false; @@ -269,7 +269,7 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { _initialScene = false; ret = _scene->loadFile(_debugStartupScene); - } else ret = _scene->loadFile(Filename); + } else ret = _scene->loadFile(filename); if (SUCCEEDED(ret)) { // invalidate references to the original scene @@ -280,22 +280,22 @@ HRESULT CAdGame::ChangeScene(const char *Filename, bool FadeIn) { _scene->loadState(); } - if (FadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); + if (fadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); return ret; } else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -void CAdGame::AddSentence(CAdSentence *Sentence) { - _sentences.Add(Sentence); +void CAdGame::addSentence(CAdSentence *sentence) { + _sentences.Add(sentence); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplaySentences(bool Frozen) { +HRESULT CAdGame::displaySentences(bool frozen) { for (int i = 0; i < _sentences.GetSize(); i++) { - if (Frozen && _sentences[i]->_freezable) continue; + if (frozen && _sentences[i]->_freezable) continue; else _sentences[i]->display(); } return S_OK; @@ -303,7 +303,7 @@ HRESULT CAdGame::DisplaySentences(bool Frozen) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::FinishSentences() { +void CAdGame::finishSentences() { for (int i = 0; i < _sentences.GetSize(); i++) { if (_sentences[i]->CanSkip()) { _sentences[i]->_duration = 0; @@ -322,15 +322,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "ChangeScene") == 0) { stack->correctParams(3); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); CScValue *valFadeOut = stack->pop(); CScValue *valFadeIn = stack->pop(); - bool TransOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); - bool TransIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); + bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); + bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); - ScheduleChangeScene(Filename, TransIn); - if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true); + scheduleChangeScene(filename, transIn); + if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); stack->pushNULL(); @@ -348,7 +348,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CAdActor *act = new CAdActor(Game); if (act && SUCCEEDED(act->loadFile(stack->pop()->getString()))) { - AddObject(act); + addObject(act); stack->pushNative(act, true); } else { delete act; @@ -365,7 +365,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); if (ent && SUCCEEDED(ent->loadFile(stack->pop()->getString()))) { - AddObject(ent); + addObject(ent); stack->pushNative(ent, true); } else { delete ent; @@ -382,7 +382,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); CScValue *val = stack->pop(); CAdObject *obj = (CAdObject *)val->getNative(); - RemoveObject(obj); + removeObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); @@ -394,12 +394,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdEntity *Ent = new CAdEntity(Game); - AddObject(Ent); - if (!Val->isNULL()) Ent->setName(Val->getString()); - stack->pushNative(Ent, true); + CAdEntity *ent = new CAdEntity(Game); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); return S_OK; } @@ -408,12 +408,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateItem") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdItem *Item = new CAdItem(Game); - AddItem(Item); - if (!Val->isNULL()) Item->setName(Val->getString()); - stack->pushNative(Item, true); + CAdItem *item = new CAdItem(Game); + addItem(item); + if (!val->isNULL()) item->setName(val->getString()); + stack->pushNative(item, true); return S_OK; } @@ -422,14 +422,14 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteItem") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdItem *Item = NULL; - if (Val->isNative()) Item = (CAdItem *)Val->getNative(); - else Item = GetItemByName(Val->getString()); + CAdItem *item = NULL; + if (val->isNative()) item = (CAdItem *)val->getNative(); + else item = getItemByName(val->getString()); - if (Item) { - DeleteItem(Item); + if (item) { + deleteItem(item); } stack->pushNULL(); @@ -441,17 +441,17 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "QueryItem") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdItem *Item = NULL; - if (Val->isInt()) { - int Index = Val->getInt(); - if (Index >= 0 && Index < _items.GetSize()) Item = _items[Index]; + CAdItem *item = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _items.GetSize()) item = _items[index]; } else { - Item = GetItemByName(Val->getString()); + item = getItemByName(val->getString()); } - if (Item) stack->pushNative(Item, true); + if (item) stack->pushNative(item, true); else stack->pushNULL(); return S_OK; @@ -500,7 +500,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ResetResponse") == 0) { stack->correctParams(1); int ID = stack->pop()->getInt(-1); - ResetResponse(ID); + resetResponse(ID); stack->pushNULL(); return S_OK; } @@ -521,7 +521,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponse") == 0) { stack->correctParams(1); - bool AutoSelectLast = stack->pop()->getBool(); + bool autoSelectLast = stack->pop()->getBool(); if (_responseBox) { _responseBox->weedResponses(); @@ -532,7 +532,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } - if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) { + if (_responseBox->_responses.GetSize() == 1 && autoSelectLast) { stack->pushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); @@ -573,13 +573,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartDlgBranch") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); - Common::String BranchName; - if (Val->isNULL()) { - BranchName.format("line%d", script->_currentLine); - } else BranchName = Val->getString(); + CScValue *val = stack->pop(); + Common::String branchName; + if (val->isNULL()) { + branchName.format("line%d", script->_currentLine); + } else branchName = val->getString(); - StartDlgBranch(BranchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); return S_OK; @@ -591,10 +591,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "EndDlgBranch") == 0) { stack->correctParams(1); - const char *BranchName = NULL; - CScValue *Val = stack->pop(); - if (!Val->isNULL()) BranchName = Val->getString(); - EndDlgBranch(BranchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + const char *branchName = NULL; + CScValue *val = stack->pop(); + if (!val->isNULL()) branchName = val->getString(); + endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); @@ -700,12 +700,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadResponseBox") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); - Game->UnregisterObject(_responseBox); + Game->unregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->loadFile(Filename))) { - RegisterObject(_responseBox); + if (_responseBox && !FAILED(_responseBox->loadFile(filename))) { + registerObject(_responseBox); stack->pushBool(true); } else { delete _responseBox; @@ -720,12 +720,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadInventoryBox") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); - Game->UnregisterObject(_inventoryBox); + Game->unregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->loadFile(Filename))) { - RegisterObject(_inventoryBox); + if (_inventoryBox && !FAILED(_inventoryBox->loadFile(filename))) { + registerObject(_inventoryBox); stack->pushBool(true); } else { delete _inventoryBox; @@ -740,11 +740,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadItems") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->getString(); - bool Merge = stack->pop()->getBool(false); + const char *filename = stack->pop()->getString(); + bool merge = stack->pop()->getBool(false); - HRESULT Ret = LoadItemsFile(Filename, Merge); - stack->pushBool(SUCCEEDED(Ret)); + HRESULT ret = loadItemsFile(filename, merge); + stack->pushBool(SUCCEEDED(ret)); return S_OK; } @@ -754,8 +754,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSpeechDir") == 0) { stack->correctParams(1); - const char *Dir = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(AddSpeechDir(Dir))); + const char *dir = stack->pop()->getString(); + stack->pushBool(SUCCEEDED(addSpeechDir(dir))); return S_OK; } @@ -765,8 +765,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSpeechDir") == 0) { stack->correctParams(1); - const char *Dir = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(RemoveSpeechDir(Dir))); + const char *dir = stack->pop()->getString(); + stack->pushBool(SUCCEEDED(removeSpeechDir(dir))); return S_OK; } @@ -776,16 +776,16 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSceneViewport") == 0) { stack->correctParams(4); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - int Width = stack->pop()->getInt(); - int Height = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); - if (Width <= 0) Width = _renderer->_width; - if (Height <= 0) Height = _renderer->_height; + if (width <= 0) width = _renderer->_width; + if (height <= 0) height = _renderer->_height; if (!_sceneViewport) _sceneViewport = new CBViewport(Game); - if (_sceneViewport) _sceneViewport->setRect(X, Y, X + Width, Y + Height); + if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -970,7 +970,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { } } else { // try to get by name - _selectedItem = GetItemByName(value->getString()); + _selectedItem = getItemByName(value->getString()); } } @@ -1003,7 +1003,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { else { CBObject *Obj = (CBObject *)value->getNative(); if (Obj == this) _inventoryOwner = _invObject; - else if (Game->ValidObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + else if (Game->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; @@ -1099,9 +1099,9 @@ HRESULT CAdGame::showCursor() { if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { - CBSprite *OrigLastCursor = _lastCursor; + CBSprite *origLastCursor = _lastCursor; CBGame::showCursor(); - _lastCursor = OrigLastCursor; + _lastCursor = origLastCursor; } if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) @@ -1114,22 +1114,22 @@ HRESULT CAdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadFile(const char *Filename) { - byte *Buffer = _fileManager->readWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", Filename); +HRESULT CAdGame::loadFile(const char *filename) { + byte *buffer = _fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", Filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -1150,7 +1150,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1169,9 +1169,9 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { int cmd = 1; CBParser parser(Game); - bool ItemFound = false, ItemsFound = false; + bool itemFound = false, itemsFound = false; - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: if (FAILED(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; @@ -1184,7 +1184,7 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { delete _responseBox; _responseBox = new CAdResponseBox(Game); if (_responseBox && !FAILED(_responseBox->loadFile((char *)params2))) - RegisterObject(_responseBox); + registerObject(_responseBox); else { delete _responseBox; _responseBox = NULL; @@ -1196,7 +1196,7 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { delete _inventoryBox; _inventoryBox = new CAdInventoryBox(Game); if (_inventoryBox && !FAILED(_inventoryBox->loadFile((char *)params2))) - RegisterObject(_inventoryBox); + registerObject(_inventoryBox); else { delete _inventoryBox; _inventoryBox = NULL; @@ -1205,9 +1205,9 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { break; case TOKEN_ITEMS: - ItemsFound = true; + itemsFound = true; CBUtils::setString(&_itemsFile, (char *)params2); - if (FAILED(LoadItemsFile(_itemsFile))) { + if (FAILED(loadItemsFile(_itemsFile))) { delete[] _itemsFile; _itemsFile = NULL; cmd = PARSERR_GENERIC; @@ -1254,7 +1254,7 @@ HRESULT CAdGame::loadBuffer(byte *Buffer, bool Complete) { return E_FAIL; } - if (ItemFound && !ItemsFound) { + if (itemFound && !itemsFound) { Game->LOG(0, "**Warning** Please put the items definition to a separate file."); } @@ -1314,27 +1314,27 @@ HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadGame(const char *Filename) { - HRESULT ret = CBGame::LoadGame(Filename); +HRESULT CAdGame::loadGame(const char *filename) { + HRESULT ret = CBGame::loadGame(filename); if (SUCCEEDED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); return ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::InitAfterLoad() { - CBGame::InitAfterLoad(); - CSysClassRegistry::getInstance()->enumInstances(AfterLoadScene, "CAdScene", NULL); +HRESULT CAdGame::initAfterLoad() { + CBGame::initAfterLoad(); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CAdGame::AfterLoadScene(void *Scene, void *Data) { - ((CAdScene *)Scene)->afterLoad(); +void CAdGame::afterLoadScene(void *scene, void *data) { + ((CAdScene *)scene)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneName(const char *name) { +void CAdGame::setPrevSceneName(const char *name) { delete[] _prevSceneName; _prevSceneName = NULL; if (name) { @@ -1345,7 +1345,7 @@ void CAdGame::SetPrevSceneName(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::SetPrevSceneFilename(const char *name) { +void CAdGame::setPrevSceneFilename(const char *name) { delete[] _prevSceneFilename; _prevSceneFilename = NULL; if (name) { @@ -1356,16 +1356,16 @@ void CAdGame::SetPrevSceneFilename(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ScheduleChangeScene(const char *Filename, bool FadeIn) { +HRESULT CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; - if (_scene && !_scene->_initialized) return ChangeScene(Filename, FadeIn); + if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); else { - _scheduledScene = new char [strlen(Filename) + 1]; - strcpy(_scheduledScene, Filename); + _scheduledScene = new char [strlen(filename) + 1]; + strcpy(_scheduledScene, filename); - _scheduledFadeIn = FadeIn; + _scheduledFadeIn = fadeIn; return S_OK; } @@ -1373,40 +1373,40 @@ HRESULT CAdGame::ScheduleChangeScene(const char *Filename, bool FadeIn) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { - CBGame::GetVersion(VerMajor, VerMinor, NULL, NULL); +HRESULT CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + CBGame::getVersion(verMajor, verMinor, NULL, NULL); - if (ExtMajor) *ExtMajor = 0; - if (ExtMinor) *ExtMinor = 0; + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadItemsFile(const char *Filename, bool Merge) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); - if (Buffer == NULL) { - Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", Filename); +HRESULT CAdGame::loadItemsFile(const char *filename, bool merge) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - //_filename = new char [strlen(Filename)+1]; - //strcpy(_filename, Filename); + //_filename = new char [strlen(filename)+1]; + //strcpy(_filename, filename); - if (FAILED(ret = LoadItemsBuffer(Buffer, Merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", Filename); + if (FAILED(ret = loadItemsBuffer(buffer, merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { +HRESULT CAdGame::loadItemsBuffer(byte *buffer, bool merge) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE_END @@ -1415,21 +1415,21 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { int cmd; CBParser parser(Game); - if (!Merge) { - while (_items.GetSize() > 0) DeleteItem(_items[0]); + if (!merge) { + while (_items.GetSize() > 0) deleteItem(_items[0]); } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ITEM: { CAdItem *item = new CAdItem(Game); if (item && !FAILED(item->loadBuffer(params, false))) { // delete item with the same name, if exists - if (Merge) { - CAdItem *PrevItem = GetItemByName(item->_name); - if (PrevItem) DeleteItem(PrevItem); + if (merge) { + CAdItem *PrevItem = getItemByName(item->_name); + if (PrevItem) deleteItem(PrevItem); } - AddItem(item); + addItem(item); } else { delete item; item = NULL; @@ -1454,37 +1454,37 @@ HRESULT CAdGame::LoadItemsBuffer(byte *Buffer, bool Merge) { ////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::GetSceneState(const char *Filename, bool Saving) { - char *FilenameCor = new char[strlen(Filename) + 1]; - strcpy(FilenameCor, Filename); - for (uint32 i = 0; i < strlen(FilenameCor); i++) { - if (FilenameCor[i] == '/') FilenameCor[i] = '\\'; +CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { + char *filenameCor = new char[strlen(filename) + 1]; + strcpy(filenameCor, filename); + for (uint32 i = 0; i < strlen(filenameCor); i++) { + if (filenameCor[i] == '/') filenameCor[i] = '\\'; } for (int i = 0; i < _sceneStates.GetSize(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, FilenameCor) == 0) { - delete [] FilenameCor; + if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { + delete [] filenameCor; return _sceneStates[i]; } } - if (Saving) { + if (saving) { CAdSceneState *ret = new CAdSceneState(Game); - ret->setFilename(FilenameCor); + ret->setFilename(filenameCor); _sceneStates.Add(ret); - delete [] FilenameCor; + delete [] filenameCor; return ret; } else { - delete [] FilenameCor; + delete [] filenameCor; return NULL; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { +HRESULT CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE_END @@ -1492,7 +1492,7 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { int cmd = PARSERR_GENERIC; CBParser parser(Game); - cmd = parser.GetCommand(Buffer, commands, params); + cmd = parser.GetCommand(buffer, commands, params); switch (cmd) { case TOKEN_ENTITY_CONTAINER: { CUIEntity *ent = new CUIEntity(Game); @@ -1501,8 +1501,8 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ent = NULL; cmd = PARSERR_GENERIC; } else { - ent->_parent = Win; - Win->_widgets.Add(ent); + ent->_parent = win; + win->_widgets.Add(ent); } } break; @@ -1518,17 +1518,17 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) { +HRESULT CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { if (strcmp(name, "CreateEntityContainer") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIEntity *Ent = new CUIEntity(Game); - if (!Val->isNULL()) Ent->setName(Val->getString()); - stack->pushNative(Ent, true); + CUIEntity *ent = new CUIEntity(Game); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); - Ent->_parent = Win; - Win->_widgets.Add(Ent); + ent->_parent = win; + win->_widgets.Add(ent); return S_OK; } else return E_FAIL; @@ -1536,10 +1536,10 @@ HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScSt ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { - char *name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; +HRESULT CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { - sprintf(name, "%s.%s.%s", BranchName, ScriptName, EventName); + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); _dlgPendingBranches.Add(name); } return S_OK; @@ -1547,17 +1547,17 @@ HRESULT CAdGame::StartDlgBranch(const char *BranchName, const char *ScriptName, ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName) { +HRESULT CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; - bool DeleteName = false; - if (BranchName == NULL && _dlgPendingBranches.GetSize() > 0) { + bool deleteName = false; + if (branchName == NULL && _dlgPendingBranches.GetSize() > 0) { name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; } else { - if (BranchName != NULL) { - name = new char[strlen(BranchName) + 1 + strlen(ScriptName) + 1 + strlen(EventName) + 1]; + if (branchName != NULL) { + name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { - sprintf(name, "%s.%s.%s", BranchName, ScriptName, EventName); - DeleteName = true; + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); + deleteName = true; } } } @@ -1565,20 +1565,20 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co if (name == NULL) return S_OK; - int StartIndex = -1; + int startIndex = -1; for (int i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { - StartIndex = i; + startIndex = i; break; } } - if (StartIndex >= 0) { - for (int i = StartIndex; i < _dlgPendingBranches.GetSize(); i++) { + if (startIndex >= 0) { + for (int i = startIndex; i < _dlgPendingBranches.GetSize(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); delete [] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; } - _dlgPendingBranches.RemoveAt(StartIndex, _dlgPendingBranches.GetSize() - StartIndex); + _dlgPendingBranches.RemoveAt(startIndex, _dlgPendingBranches.GetSize() - startIndex); } // dialogue is over, forget selected responses @@ -1587,14 +1587,14 @@ HRESULT CAdGame::EndDlgBranch(const char *BranchName, const char *ScriptName, co _responsesBranch.RemoveAll(); } - if (DeleteName) delete [] name; + if (deleteName) delete [] name; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ClearBranchResponses(char *name) { +HRESULT CAdGame::clearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.GetSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; @@ -1607,8 +1607,8 @@ HRESULT CAdGame::ClearBranchResponses(char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddBranchResponse(int ID) { - if (BranchResponseUsed(ID)) return S_OK; +HRESULT CAdGame::addBranchResponse(int ID) { + if (branchResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); @@ -1618,7 +1618,7 @@ HRESULT CAdGame::AddBranchResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::BranchResponseUsed(int ID) { +bool CAdGame::branchResponseUsed(int ID) { char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; for (int i = 0; i < _responsesBranch.GetSize(); i++) { if (_responsesBranch[i]->_iD == ID) { @@ -1630,8 +1630,8 @@ bool CAdGame::BranchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddGameResponse(int ID) { - if (GameResponseUsed(ID)) return S_OK; +HRESULT CAdGame::addGameResponse(int ID) { + if (gameResponseUsed(ID)) return S_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); @@ -1641,7 +1641,7 @@ HRESULT CAdGame::AddGameResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::GameResponseUsed(int ID) { +bool CAdGame::gameResponseUsed(int ID) { char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; for (int i = 0; i < _responsesGame.GetSize(); i++) { CAdResponseContext *RespContext = _responsesGame[i]; @@ -1654,7 +1654,7 @@ bool CAdGame::GameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ResetResponse(int ID) { +HRESULT CAdGame::resetResponse(int ID) { char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; int i; @@ -1683,9 +1683,9 @@ HRESULT CAdGame::ResetResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { +HRESULT CAdGame::displayContent(bool update, bool displayAll) { // init - if (Update) InitLoop(); + if (update) initLoop(); // fill black _renderer->fill(0, 0, 0); @@ -1693,11 +1693,11 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // playing exclusive video? if (_videoPlayer->isPlaying()) { - if (Update) _videoPlayer->update(); + if (update) _videoPlayer->update(); _videoPlayer->display(); } else if (_theoraPlayer) { if (_theoraPlayer->isPlaying()) { - if (Update) _theoraPlayer->update(); + if (update) _theoraPlayer->update(); _theoraPlayer->display(); } if (_theoraPlayer->isFinished()) { @@ -1707,7 +1707,7 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { } else { // process scripts - if (Update) _scEngine->Tick(); + if (update) _scEngine->Tick(); POINT p; getMousePos(&p); @@ -1717,20 +1717,20 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { // display in-game windows - DisplayWindows(true); + displayWindows(true); if (_inventoryBox) _inventoryBox->display(); if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); if (_indicatorDisplay) displayIndicator(); - if (Update || DisplayAll) { + if (update || displayAll) { // display normal windows - DisplayWindows(false); + displayWindows(false); setActiveObject(Game->_renderer->getObjectAt(p.x, p.y)); // textual info - DisplaySentences(_state == GAME_FROZEN); + displaySentences(_state == GAME_FROZEN); showCursor(); @@ -1751,21 +1751,21 @@ HRESULT CAdGame::DisplayContent(bool Update, bool DisplayAll) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RegisterInventory(CAdInventory *Inv) { +HRESULT CAdGame::registerInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.GetSize(); i++) { - if (_inventories[i] == Inv) return S_OK; + if (_inventories[i] == inv) return S_OK; } - RegisterObject(Inv); - _inventories.Add(Inv); + registerObject(inv); + _inventories.Add(inv); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { +HRESULT CAdGame::unregisterInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.GetSize(); i++) { - if (_inventories[i] == Inv) { - UnregisterObject(_inventories[i]); + if (_inventories[i] == inv) { + unregisterObject(_inventories[i]); _inventories.RemoveAt(i); return S_OK; } @@ -1774,14 +1774,12 @@ HRESULT CAdGame::UnregisterInventory(CAdInventory *Inv) { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::IsItemTaken(char *ItemName) { - int i; - - for (i = 0; i < _inventories.GetSize(); i++) { +bool CAdGame::isItemTaken(char *itemName) { + for (int i = 0; i < _inventories.GetSize(); i++) { CAdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { - if (scumm_stricmp(ItemName, Inv->_takenItems[j]->_name) == 0) { + if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { return true; } } @@ -1790,7 +1788,7 @@ bool CAdGame::IsItemTaken(char *ItemName) { } ////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::GetItemByName(const char *name) { +CAdItem *CAdGame::getItemByName(const char *name) { for (int i = 0; i < _items.GetSize(); i++) { if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; } @@ -1799,65 +1797,63 @@ CAdItem *CAdGame::GetItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddItem(CAdItem *Item) { - _items.Add(Item); - return Game->RegisterObject(Item); +HRESULT CAdGame::addItem(CAdItem *item) { + _items.Add(item); + return Game->registerObject(item); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ResetContent() { - int i; - +HRESULT CAdGame::resetContent() { // clear pending dialogs - for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + for (int i = 0; i < _dlgPendingBranches.GetSize(); i++) { delete [] _dlgPendingBranches[i]; } _dlgPendingBranches.RemoveAll(); // clear inventories - for (i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.GetSize(); i++) { _inventories[i]->_takenItems.RemoveAll(); } // clear scene states - for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; + for (int i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; _sceneStates.RemoveAll(); // clear once responses - for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; + for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; _responsesBranch.RemoveAll(); // clear once game responses - for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; + for (int i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; _responsesGame.RemoveAll(); // reload inventory items - if (_itemsFile) LoadItemsFile(_itemsFile); + if (_itemsFile) loadItemsFile(_itemsFile); _tempDisableSaveState = true; - return CBGame::ResetContent(); + return CBGame::resetContent(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DeleteItem(CAdItem *Item) { - if (!Item) return E_FAIL; +HRESULT CAdGame::deleteItem(CAdItem *item) { + if (!item) return E_FAIL; - if (_selectedItem == Item) _selectedItem = NULL; - _scene->handleItemAssociations(Item->_name, false); + if (_selectedItem == item) _selectedItem = NULL; + _scene->handleItemAssociations(item->_name, false); // remove from all inventories for (int i = 0; i < _inventories.GetSize(); i++) { - _inventories[i]->RemoveItem(Item); + _inventories[i]->RemoveItem(item); } // remove object for (int i = 0; i < _items.GetSize(); i++) { - if (_items[i] == Item) { - UnregisterObject(_items[i]); + if (_items[i] == item) { + unregisterObject(_items[i]); _items.RemoveAt(i); break; } @@ -1868,45 +1864,45 @@ HRESULT CAdGame::DeleteItem(CAdItem *Item) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::AddSpeechDir(const char *Dir) { - if (!Dir || Dir[0] == '\0') return E_FAIL; +HRESULT CAdGame::addSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return E_FAIL; - char *Temp = new char[strlen(Dir) + 2]; - strcpy(Temp, Dir); - if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') - strcat(Temp, "\\"); + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); for (int i = 0; i < _speechDirs.GetSize(); i++) { - if (scumm_stricmp(_speechDirs[i], Temp) == 0) { - delete [] Temp; + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete [] temp; return S_OK; } } - _speechDirs.Add(Temp); + _speechDirs.Add(temp); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::RemoveSpeechDir(const char *Dir) { - if (!Dir || Dir[0] == '\0') return E_FAIL; +HRESULT CAdGame::removeSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return E_FAIL; - char *Temp = new char[strlen(Dir) + 2]; - strcpy(Temp, Dir); - if (Temp[strlen(Temp) - 1] != '\\' && Temp[strlen(Temp) - 1] != '/') - strcat(Temp, "\\"); + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); bool Found = false; for (int i = 0; i < _speechDirs.GetSize(); i++) { - if (scumm_stricmp(_speechDirs[i], Temp) == 0) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete [] _speechDirs[i]; _speechDirs.RemoveAt(i); Found = true; break; } } - delete [] Temp; + delete [] temp; if (Found) return S_OK; else return E_FAIL; @@ -1914,51 +1910,51 @@ HRESULT CAdGame::RemoveSpeechDir(const char *Dir) { ////////////////////////////////////////////////////////////////////////// -char *CAdGame::FindSpeechFile(char *StringID) { - char *Ret = new char[MAX_PATH]; +char *CAdGame::findSpeechFile(char *stringID) { + char *ret = new char[MAX_PATH]; for (int i = 0; i < _speechDirs.GetSize(); i++) { - sprintf(Ret, "%s%s.ogg", _speechDirs[i], StringID); - Common::SeekableReadStream *File = _fileManager->openFile(Ret); - if (File) { - _fileManager->closeFile(File); - return Ret; + sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); + Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile + if (file) { + _fileManager->closeFile(file); + return ret; } - sprintf(Ret, "%s%s.wav", _speechDirs[i], StringID); - File = _fileManager->openFile(Ret); - if (File) { - _fileManager->closeFile(File); - return Ret; + sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); + file = _fileManager->openFile(ret); + if (file) { + _fileManager->closeFile(file); + return ret; } } - delete [] Ret; + delete [] ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::ValidMouse() { - POINT Pos; - CBPlatform::GetCursorPos(&Pos); +bool CAdGame::validMouse() { + POINT pos; + CBPlatform::GetCursorPos(&pos); - return _renderer->pointInViewport(&Pos); + return _renderer->pointInViewport(&pos); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftDown() { - if (!ValidMouse()) return S_OK; +HRESULT CAdGame::onMouseLeftDown() { + if (!validMouse()) return S_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { - FinishSentences(); + finishSentences(); } return S_OK; } if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { @@ -1974,15 +1970,15 @@ HRESULT CAdGame::OnMouseLeftDown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftUp() { +HRESULT CAdGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; - bool Handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(applyEvent("LeftRelease")); - if (!Handled) { + bool handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(applyEvent("LeftRelease")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { @@ -1993,15 +1989,15 @@ HRESULT CAdGame::OnMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseLeftDblClick() { - if (!ValidMouse()) return S_OK; +HRESULT CAdGame::onMouseLeftDblClick() { + if (!validMouse()) return S_OK; if (_state == GAME_RUNNING && !_interactive) return S_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftDoubleClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { @@ -2012,11 +2008,11 @@ HRESULT CAdGame::OnMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseRightDown() { - if (!ValidMouse()) return S_OK; +HRESULT CAdGame::onMouseRightDown() { + if (!validMouse()) return S_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { - FinishSentences(); + finishSentences(); } return S_OK; } @@ -2025,8 +2021,8 @@ HRESULT CAdGame::OnMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { @@ -2037,11 +2033,11 @@ HRESULT CAdGame::OnMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnMouseRightUp() { +HRESULT CAdGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { @@ -2052,7 +2048,7 @@ HRESULT CAdGame::OnMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::DisplayDebugInfo() { +HRESULT CAdGame::displayDebugInfo() { char str[100]; if (Game->_dEBUG_DebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); @@ -2061,12 +2057,12 @@ HRESULT CAdGame::DisplayDebugInfo() { sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } - return CBGame::DisplayDebugInfo(); + return CBGame::displayDebugInfo(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::OnScriptShutdown(CScScript *script) { +HRESULT CAdGame::onScriptShutdown(CScScript *script) { if (_responseBox && _responseBox->_waitingScript == script) _responseBox->_waitingScript = NULL; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index ad6785a8ff..df4d26eaf5 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -44,58 +44,58 @@ class CAdResponseContext; class CAdResponseBox; class CAdGame : public CBGame { public: - virtual HRESULT OnScriptShutdown(CScScript *script); + virtual HRESULT onScriptShutdown(CScScript *script); - virtual HRESULT OnMouseLeftDown(); - virtual HRESULT OnMouseLeftUp(); - virtual HRESULT OnMouseLeftDblClick(); - virtual HRESULT OnMouseRightDown(); - virtual HRESULT OnMouseRightUp(); + virtual HRESULT onMouseLeftDown(); + virtual HRESULT onMouseLeftUp(); + virtual HRESULT onMouseLeftDblClick(); + virtual HRESULT onMouseRightDown(); + virtual HRESULT onMouseRightUp(); - virtual HRESULT DisplayDebugInfo(); + virtual HRESULT displayDebugInfo(); - virtual HRESULT InitAfterLoad(); - static void AfterLoadScene(void *Scene, void *Data); + virtual HRESULT initAfterLoad(); + static void afterLoadScene(void *scene, void *data); bool _smartItemCursor; CBArray _speechDirs; - HRESULT AddSpeechDir(const char *Dir); - HRESULT RemoveSpeechDir(const char *Dir); - char *FindSpeechFile(char *StringID); + HRESULT addSpeechDir(const char *dir); + HRESULT removeSpeechDir(const char *dir); + char *findSpeechFile(char *StringID); - HRESULT DeleteItem(CAdItem *Item); + HRESULT deleteItem(CAdItem *Item); char *_itemsFile; bool _tempDisableSaveState; - virtual HRESULT ResetContent(); - HRESULT AddItem(CAdItem *Item); - CAdItem *GetItemByName(const char *name); + virtual HRESULT resetContent(); + HRESULT addItem(CAdItem *item); + CAdItem *getItemByName(const char *name); CBArray _items; CAdObject *_inventoryOwner; - bool IsItemTaken(char *ItemName); - HRESULT RegisterInventory(CAdInventory *Inv); - HRESULT UnregisterInventory(CAdInventory *Inv); + bool isItemTaken(char *itemName); + HRESULT registerInventory(CAdInventory *inv); + HRESULT unregisterInventory(CAdInventory *inv); CAdObject *_invObject; CBArray _inventories; - virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); + virtual HRESULT displayContent(bool update = true, bool displayAll = false); char *_debugStartupScene; char *_startupScene; bool _initialScene; - bool GameResponseUsed(int ID); - HRESULT AddGameResponse(int ID); - HRESULT ResetResponse(int ID); - - bool BranchResponseUsed(int ID); - HRESULT AddBranchResponse(int ID); - HRESULT ClearBranchResponses(char *name); - HRESULT StartDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); - HRESULT EndDlgBranch(const char *BranchName, const char *ScriptName, const char *EventName); - virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); - - CAdSceneState *GetSceneState(const char *Filename, bool Saving); + bool gameResponseUsed(int ID); + HRESULT addGameResponse(int ID); + HRESULT resetResponse(int ID); + + bool branchResponseUsed(int ID); + HRESULT addBranchResponse(int ID); + HRESULT clearBranchResponses(char *name); + HRESULT startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + HRESULT endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + virtual HRESULT windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual HRESULT windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + + CAdSceneState *getSceneState(const char *filename, bool saving); CBViewport *_sceneViewport; int _texItemLifeTime; int _texWalkLifeTime; @@ -104,31 +104,31 @@ public: TTalkSkipButton _talkSkipButton; - virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); - HRESULT ScheduleChangeScene(const char *Filename, bool FadeIn); + virtual HRESULT getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + HRESULT scheduleChangeScene(const char *filename, bool fadeIn); char *_scheduledScene; bool _scheduledFadeIn; - void SetPrevSceneName(const char *name); - void SetPrevSceneFilename(const char *name); + void setPrevSceneName(const char *name); + void setPrevSceneFilename(const char *name); char *_prevSceneName; char *_prevSceneFilename; - virtual HRESULT LoadGame(const char *Filename); + virtual HRESULT loadGame(const char *filename); CAdItem *_selectedItem; HRESULT cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) - void FinishSentences(); + void finishSentences(); HRESULT showCursor(); TGameStateEx _stateEx; CAdResponseBox *_responseBox; CAdInventoryBox *_inventoryBox; - HRESULT DisplaySentences(bool Frozen); - void AddSentence(CAdSentence *Sentence); - HRESULT ChangeScene(const char *Filename, bool FadeIn); - HRESULT RemoveObject(CAdObject *Object); - HRESULT AddObject(CAdObject *Object); + HRESULT displaySentences(bool frozen); + void addSentence(CAdSentence *sentence); + HRESULT changeScene(const char *filename, bool fadeIn); + HRESULT removeObject(CAdObject *object); + HRESULT addObject(CAdObject *object); CAdScene *_scene; - HRESULT InitLoop(); + HRESULT initLoop(); CAdGame(); virtual ~CAdGame(); CBArray _objects; @@ -140,11 +140,11 @@ public: CBArray _responsesBranch; CBArray _responsesGame; - virtual HRESULT loadFile(const char *Filename); - virtual HRESULT loadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT loadFile(const char *filename); + virtual HRESULT loadBuffer(byte *buffer, bool complete = true); - HRESULT LoadItemsFile(const char *Filename, bool Merge = false); - HRESULT LoadItemsBuffer(byte *Buffer, bool Merge = false); + HRESULT loadItemsFile(const char *filename, bool merge = false); + HRESULT loadItemsBuffer(byte *buffer, bool merge = false); virtual void PublishNatives(); @@ -154,7 +154,7 @@ public: virtual CScValue *scGetProperty(const char *name); virtual HRESULT scSetProperty(const char *name, CScValue *value); virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - bool ValidMouse(); + bool validMouse(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index edc1fa65b9..a453343a56 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -52,7 +52,7 @@ CAdInventory::~CAdInventory() { HRESULT CAdInventory::InsertItem(const char *name, const char *InsertAfter) { if (name == NULL) return E_FAIL; - CAdItem *item = ((CAdGame *)Game)->GetItemByName(name); + CAdItem *item = ((CAdGame *)Game)->getItemByName(name); if (item == NULL) return E_FAIL; int InsertIndex = -1; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 60b0a77692..7af618e548 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -64,7 +64,7 @@ CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::~CAdInventoryBox() { - Game->UnregisterObject(_window); + Game->unregisterObject(_window); _window = NULL; delete _closeButton; @@ -154,19 +154,19 @@ HRESULT CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdInventoryBox::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); delete [] Buffer; @@ -245,7 +245,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; - } else Game->RegisterObject(_window); + } else Game->registerObject(_window); break; case TOKEN_AREA: diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index 3e8714ae8f..903a3ff8e9 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -53,7 +53,7 @@ public: CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index c105478045..77e6aa5a4a 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -84,19 +84,19 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdItem::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); delete [] Buffer; @@ -369,11 +369,11 @@ HRESULT CAdItem::update() { _tempSprite2->Reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->AddSentence(_sentence); + ((CAdGame *)Game)->addSentence(_sentence); } } default: @@ -439,14 +439,14 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this bool SetCurrent = false; if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); delete _spriteHover; _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename); + script->RuntimeError("Item.SetHoverSprite failed for file '%s'", filename); } else { _spriteHover = spr; if (SetCurrent) _currentSprite = _spriteHover; @@ -482,14 +482,14 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetNormalCursor") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); delete _cursorNormal; _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename); + script->RuntimeError("Item.SetNormalCursor failed for file '%s'", filename); } else { _cursorNormal = spr; stack->pushBool(true); @@ -525,14 +525,14 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetHoverCursor") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); delete _cursorHover; _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename); + script->RuntimeError("Item.SetHoverCursor failed for file '%s'", filename); } else { _cursorHover = spr; stack->pushBool(true); diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index ad59048e53..31460319e7 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -55,7 +55,7 @@ public: CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); // scripting interface diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index b462d23963..4329c7b36a 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -61,19 +61,19 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdLayer::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 7c2c595fa2..0b8aa3958d 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -42,7 +42,7 @@ public: CAdLayer(CBGame *inGame); virtual ~CAdLayer(); CBArray _nodes; - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index f732067471..87f4e7d72f 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -76,18 +76,18 @@ void CAdNodeState::setName(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setFilename(const char *Filename) { +void CAdNodeState::setFilename(const char *filename) { delete[] _filename; _filename = NULL; - CBUtils::setString(&_filename, Filename); + CBUtils::setString(&_filename, filename); } ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCursor(const char *Filename) { +void CAdNodeState::SetCursor(const char *filename) { delete[] _cursor; _cursor = NULL; - CBUtils::setString(&_cursor, Filename); + CBUtils::setString(&_cursor, filename); } diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index 9c75cf8092..7d9b1c6d90 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -37,8 +37,8 @@ class CAdNodeState : public CBBase { public: HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); void setName(const char *name); - void setFilename(const char *Filename); - void SetCursor(const char *Filename); + void setFilename(const char *filename); + void SetCursor(const char *filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) CAdNodeState(CBGame *inGame); virtual ~CAdNodeState(); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 2f72a2dcbe..d59e575d8e 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -130,38 +130,38 @@ CAdObject::~CAdObject() { if (_font) Game->_fontStorage->RemoveFont(_font); if (_inventory) { - ((CAdGame *)Game)->UnregisterInventory(_inventory); + ((CAdGame *)Game)->unregisterInventory(_inventory); _inventory = NULL; } if (_partEmitter) - Game->UnregisterObject(_partEmitter); + Game->unregisterObject(_partEmitter); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - Game->UnregisterObject(_attachmentsPre[i]); + Game->unregisterObject(_attachmentsPre[i]); } _attachmentsPre.RemoveAll(); for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - Game->UnregisterObject(_attachmentsPost[i]); + Game->unregisterObject(_attachmentsPost[i]); } _attachmentsPost.RemoveAll(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::playAnim(const char *Filename) { +HRESULT CAdObject::playAnim(const char *filename) { delete _animSprite; _animSprite = NULL; _animSprite = new CBSprite(Game, this); if (!_animSprite) { - Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); + Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); return E_FAIL; } - HRESULT res = _animSprite->loadFile(Filename); + HRESULT res = _animSprite->loadFile(filename); if (FAILED(res)) { - Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, Filename); + Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); delete _animSprite; _animSprite = NULL; return res; @@ -352,7 +352,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_inventory) { _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); + ((CAdGame *)Game)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -380,7 +380,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_inventory) { _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); + ((CAdGame *)Game)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -404,12 +404,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_inventory) { _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); + ((CAdGame *)Game)->registerInventory(_inventory); } CScValue *val = stack->pop(); if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->getString()); + CAdItem *item = ((CAdGame *)Game)->getItemByName(val->getString()); if (item) stack->pushNative(item, true); else stack->pushNULL(); } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.GetSize()) @@ -428,7 +428,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_inventory) { _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); + ((CAdGame *)Game)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -470,7 +470,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "DeleteParticleEmitter") == 0) { stack->correctParams(0); if (_partEmitter) { - Game->UnregisterObject(_partEmitter); + Game->unregisterObject(_partEmitter); _partEmitter = NULL; } stack->pushNULL(); @@ -483,20 +483,20 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddAttachment") == 0) { stack->correctParams(4); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool PreDisplay = stack->pop()->getBool(true); int OffsetX = stack->pop()->getInt(); int OffsetY = stack->pop()->getInt(); HRESULT res; CAdEntity *Ent = new CAdEntity(Game); - if (FAILED(res = Ent->loadFile(Filename))) { + if (FAILED(res = Ent->loadFile(filename))) { delete Ent; Ent = NULL; - script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename); + script->RuntimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { - Game->RegisterObject(Ent); + Game->registerObject(Ent); Ent->_posX = OffsetX; Ent->_posY = OffsetY; @@ -523,7 +523,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i] == Obj) { Found = true; - Game->UnregisterObject(_attachmentsPre[i]); + Game->unregisterObject(_attachmentsPre[i]); _attachmentsPre.RemoveAt(i); i--; } @@ -531,7 +531,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _attachmentsPost.GetSize(); i++) { if (_attachmentsPost[i] == Obj) { Found = true; - Game->UnregisterObject(_attachmentsPost[i]); + Game->unregisterObject(_attachmentsPost[i]); _attachmentsPost.RemoveAt(i); i--; } @@ -541,7 +541,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { Found = true; - Game->UnregisterObject(_attachmentsPre[i]); + Game->unregisterObject(_attachmentsPre[i]); _attachmentsPre.RemoveAt(i); i--; } @@ -549,7 +549,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _attachmentsPost.GetSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { Found = true; - Game->UnregisterObject(_attachmentsPost[i]); + Game->unregisterObject(_attachmentsPost[i]); _attachmentsPost.RemoveAt(i); i--; } @@ -792,10 +792,10 @@ const char *CAdObject::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SetFont(const char *Filename) { +HRESULT CAdObject::SetFont(const char *filename) { if (_font) Game->_fontStorage->RemoveFont(_font); - if (Filename) { - _font = Game->_fontStorage->AddFont(Filename); + if (filename) { + _font = Game->_fontStorage->AddFont(filename); return _font == NULL ? E_FAIL : S_OK; } else { _font = NULL; @@ -852,7 +852,7 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const if (!Sound) { char *Key = Game->_stringTable->GetKey(Text); if (Key) { - Sound = ((CAdGame *)Game)->FindSpeechFile(Key); + Sound = ((CAdGame *)Game)->findSpeechFile(Key); delete [] Key; if (Sound) DeleteSound = true; @@ -1052,7 +1052,7 @@ HRESULT CAdObject::updateBlockRegion() { CAdInventory *CAdObject::getInventory() { if (!_inventory) { _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->RegisterInventory(_inventory); + ((CAdGame *)Game)->registerInventory(_inventory); } return _inventory; } @@ -1077,7 +1077,7 @@ HRESULT CAdObject::afterMove() { } for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (_currentRegions[i] && Game->ValidObject(_currentRegions[i])) { + if (_currentRegions[i] && Game->validObject(_currentRegions[i])) { _currentRegions[i]->applyEvent("ActorLeave"); } _currentRegions[i] = NewRegions[i]; @@ -1179,7 +1179,7 @@ CPartEmitter *CAdObject::createParticleEmitter(bool FollowParent, int OffsetX, i if (!_partEmitter) { _partEmitter = new CPartEmitter(Game, this); if (_partEmitter) { - Game->RegisterObject(_partEmitter); + Game->registerObject(_partEmitter); } } updatePartEmitter(); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 9522ebbb61..5f57a0d967 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -54,19 +54,19 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdRegion::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 15b794641b..9a9d0e1055 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -42,7 +42,7 @@ public: bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 36b6ce454a..e8923f2179 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -72,11 +72,11 @@ void CAdResponse::SetText(const char *Text) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIcon(const char *Filename) { +HRESULT CAdResponse::SetIcon(const char *filename) { delete _icon; _icon = new CBSprite(Game); - if (!_icon || FAILED(_icon->loadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", Filename); + if (!_icon || FAILED(_icon->loadFile(filename))) { + Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", filename); delete _icon; _icon = NULL; return E_FAIL; @@ -85,22 +85,22 @@ HRESULT CAdResponse::SetIcon(const char *Filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetFont(const char *Filename) { +HRESULT CAdResponse::SetFont(const char *filename) { if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont(Filename); + _font = Game->_fontStorage->AddFont(filename); if (!_font) { - Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", Filename); + Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", filename); return E_FAIL; } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconHover(const char *Filename) { +HRESULT CAdResponse::SetIconHover(const char *filename) { delete _iconHover; _iconHover = new CBSprite(Game); - if (!_iconHover || FAILED(_iconHover->loadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", Filename); + if (!_iconHover || FAILED(_iconHover->loadFile(filename))) { + Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", filename); delete _iconHover; _iconHover = NULL; return E_FAIL; @@ -110,11 +110,11 @@ HRESULT CAdResponse::SetIconHover(const char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconPressed(const char *Filename) { +HRESULT CAdResponse::SetIconPressed(const char *filename) { delete _iconPressed; _iconPressed = new CBSprite(Game); - if (!_iconPressed || FAILED(_iconPressed->loadFile(Filename))) { - Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", Filename); + if (!_iconPressed || FAILED(_iconPressed->loadFile(filename))) { + Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", filename); delete _iconPressed; _iconPressed = NULL; return E_FAIL; diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h index 42f2f90b14..84ec6a086a 100644 --- a/engines/wintermute/Ad/AdResponse.h +++ b/engines/wintermute/Ad/AdResponse.h @@ -38,10 +38,10 @@ class CBFont; class CAdResponse : public CBObject { public: DECLARE_PERSISTENT(CAdResponse, CBObject) - HRESULT SetIcon(const char *Filename); - HRESULT SetFont(const char *Filename); - HRESULT SetIconHover(const char *Filename); - HRESULT SetIconPressed(const char *Filename); + HRESULT SetIcon(const char *filename); + HRESULT SetFont(const char *filename); + HRESULT SetIconHover(const char *filename); + HRESULT SetIconPressed(const char *filename); void SetText(const char *Text); int _iD; CBSprite *_icon; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index b73465590e..80ab26392c 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -187,19 +187,19 @@ HRESULT CAdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdResponseBox::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); delete [] Buffer; @@ -542,7 +542,7 @@ HRESULT CAdResponseBox::weedResponses() { for (int i = 0; i < _responses.GetSize(); i++) { switch (_responses[i]->_responseType) { case RESPONSE_ONCE: - if (AdGame->BranchResponseUsed(_responses[i]->_iD)) { + if (AdGame->branchResponseUsed(_responses[i]->_iD)) { delete _responses[i]; _responses.RemoveAt(i); i--; @@ -550,7 +550,7 @@ HRESULT CAdResponseBox::weedResponses() { break; case RESPONSE_ONCE_GAME: - if (AdGame->GameResponseUsed(_responses[i]->_iD)) { + if (AdGame->gameResponseUsed(_responses[i]->_iD)) { delete _responses[i]; _responses.RemoveAt(i); i--; @@ -580,11 +580,11 @@ HRESULT CAdResponseBox::handleResponse(CAdResponse *Response) { switch (Response->_responseType) { case RESPONSE_ONCE: - AdGame->AddBranchResponse(Response->_iD); + AdGame->addBranchResponse(Response->_iD); break; case RESPONSE_ONCE_GAME: - AdGame->AddGameResponse(Response->_iD); + AdGame->addGameResponse(Response->_iD); break; default: warning("CAdResponseBox::HandleResponse - Unhandled enum"); diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 17778beaba..2fcf7ab7a6 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -75,7 +75,7 @@ public: RECT _responseArea; int _verticalAlign; TTextAlign _align; - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); }; diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index f1c866c91e..84a13260ae 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -53,19 +53,19 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdRotLevel::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index cfa6f88f1c..dffca612c8 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -40,7 +40,7 @@ public: virtual ~CAdRotLevel(); float _rotation; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index e7a54eb927..1e686545ff 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -51,19 +51,19 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdScaleLevel::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index a00197620c..6cb336aae5 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -41,7 +41,7 @@ public: CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); }; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 2b5aed2777..02888c07e6 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -74,7 +74,7 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdScene::~CAdScene() { cleanup(); - Game->UnregisterObject(_fader); + Game->unregisterObject(_fader); delete _pfTarget; _pfTarget = NULL; } @@ -129,7 +129,7 @@ void CAdScene::setDefaults() { _shieldWindow = NULL; _fader = new CBFader(Game); - Game->RegisterObject(_fader); + Game->registerObject(_fader); _viewport = NULL; } @@ -146,24 +146,24 @@ void CAdScene::cleanup() { delete _shieldWindow; _shieldWindow = NULL; - Game->UnregisterObject(_fader); + Game->unregisterObject(_fader); _fader = NULL; for (i = 0; i < _layers.GetSize(); i++) - Game->UnregisterObject(_layers[i]); + Game->unregisterObject(_layers[i]); _layers.RemoveAll(); for (i = 0; i < _waypointGroups.GetSize(); i++) - Game->UnregisterObject(_waypointGroups[i]); + Game->unregisterObject(_waypointGroups[i]); _waypointGroups.RemoveAll(); for (i = 0; i < _scaleLevels.GetSize(); i++) - Game->UnregisterObject(_scaleLevels[i]); + Game->unregisterObject(_scaleLevels[i]); _scaleLevels.RemoveAll(); for (i = 0; i < _rotLevels.GetSize(); i++) - Game->UnregisterObject(_rotLevels[i]); + Game->unregisterObject(_rotLevels[i]); _rotLevels.RemoveAll(); @@ -173,7 +173,7 @@ void CAdScene::cleanup() { _pfPointsNum = 0; for (i = 0; i < _objects.GetSize(); i++) - Game->UnregisterObject(_objects[i]); + Game->unregisterObject(_objects[i]); _objects.RemoveAll(); delete _viewport; @@ -503,23 +503,23 @@ HRESULT CAdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdScene::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; delete[] _filename; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); delete [] Buffer; @@ -648,7 +648,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { delete layer; layer = NULL; } else { - Game->RegisterObject(layer); + Game->registerObject(layer); _layers.Add(layer); if (layer->_main) { _mainLayer = layer; @@ -666,7 +666,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { delete wpt; wpt = NULL; } else { - Game->RegisterObject(wpt); + Game->registerObject(wpt); _waypointGroups.Add(wpt); } } @@ -679,7 +679,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { delete sl; sl = NULL; } else { - Game->RegisterObject(sl); + Game->registerObject(sl); _scaleLevels.Add(sl); } } @@ -692,7 +692,7 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { delete rl; rl = NULL; } else { - Game->RegisterObject(rl); + Game->registerObject(rl); _rotLevels.Add(rl); } } @@ -1600,7 +1600,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi Layer->_height = _mainLayer->_height; } _layers.Add(Layer); - Game->RegisterObject(Layer); + Game->registerObject(Layer); stack->pushNative(Layer, true); return S_OK; @@ -1624,7 +1624,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Index <= _layers.GetSize() - 1) _layers.InsertAt(Index, Layer); else _layers.Add(Layer); - Game->RegisterObject(Layer); + Game->registerObject(Layer); stack->pushNative(Layer, true); return S_OK; @@ -1666,7 +1666,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi for (int i = 0; i < _layers.GetSize(); i++) { if (_layers[i] == ToDelete) { _layers.RemoveAt(i); - Game->UnregisterObject(ToDelete); + Game->unregisterObject(ToDelete); break; } } @@ -1952,7 +1952,7 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::addObject(CAdObject *Object) { _objects.Add(Object); - return Game->RegisterObject(Object); + return Game->registerObject(Object); } @@ -1961,7 +1961,7 @@ HRESULT CAdScene::removeObject(CAdObject *Object) { for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] == Object) { _objects.RemoveAt(i); - return Game->UnregisterObject(Object); + return Game->unregisterObject(Object); } } return E_FAIL; @@ -2489,7 +2489,7 @@ HRESULT CAdScene::persistState(bool Saving) { if (!_persistentState) return S_OK; CAdGame *AdGame = (CAdGame *)Game; - CAdSceneState *State = AdGame->GetSceneState(_filename, Saving); + CAdSceneState *State = AdGame->getSceneState(_filename, Saving); if (!State) return S_OK; diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index 037e5abeca..ae4750b612 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -123,7 +123,7 @@ public: CBArray _layers; CBArray _objects; CBArray _waypointGroups; - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); int _width; int _height; diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index dbb4a0054f..2c734bf87b 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -44,10 +44,10 @@ CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdSceneNode::~CAdSceneNode() { - Game->UnregisterObject(_region); + Game->unregisterObject(_region); _region = NULL; - Game->UnregisterObject(_entity); + Game->unregisterObject(_entity); _entity = NULL; } @@ -56,7 +56,7 @@ CAdSceneNode::~CAdSceneNode() { HRESULT CAdSceneNode::setEntity(CAdEntity *Entity) { _type = OBJECT_ENTITY; _entity = Entity; - return Game->RegisterObject(Entity); + return Game->registerObject(Entity); } @@ -64,7 +64,7 @@ HRESULT CAdSceneNode::setEntity(CAdEntity *Entity) { HRESULT CAdSceneNode::setRegion(CAdRegion *Region) { _type = OBJECT_REGION; _region = Region; - return Game->RegisterObject(Region); + return Game->registerObject(Region); } diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 6a1e0a1d15..11e2b1e2af 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -69,18 +69,18 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdTalkDef::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - CBUtils::setString(&_filename, Filename); + CBUtils::setString(&_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 4f5ad76880..d5746a4530 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -138,10 +138,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (SetCurrent) _currentSprite = NULL; stack->pushBool(true); } else { - const char *Filename = Val->getString(); + const char *filename = Val->getString(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(Filename))) { - script->RuntimeError("SetSprite method failed for file '%s'", Filename); + if (!spr || FAILED(spr->loadFile(filename))) { + script->RuntimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); } else { _sprite = spr; @@ -180,13 +180,13 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "AddTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool Ex = stack->pop()->getBool(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename); + script->RuntimeError("AddTalkSprite method failed for file '%s'", filename); } else { if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); @@ -201,7 +201,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "RemoveTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool Ex = stack->pop()->getBool(); int i; @@ -210,7 +210,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (Ex) { for (i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { if (_currentSprite == _talkSpritesEx[i]) SetCurrent = true; if (_tempSprite2 == _talkSpritesEx[i]) SetTemp2 = true; delete _talkSpritesEx[i]; @@ -220,7 +220,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack } } else { for (i = 0; i < _talkSprites.GetSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { if (_currentSprite == _talkSprites[i]) SetCurrent = true; if (_tempSprite2 == _talkSprites[i]) SetTemp2 = true; delete _talkSprites[i]; @@ -244,15 +244,15 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "SetTalkSprite") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool Ex = stack->pop()->getBool(); bool SetCurrent = false; bool SetTemp2 = false; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(Filename))) { + if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename); + script->RuntimeError("SetTalkSprite method failed for file '%s'", filename); } else { // delete current diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index da21cf0ba6..a0004e978b 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -64,19 +64,19 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CAdWaypointGroup::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index bc4b9420f1..dc4a5650e9 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -44,7 +44,7 @@ public: virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); bool _active; CAdWaypointGroup(CBGame *inGame); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual ~CAdWaypointGroup(); CBArray _points; diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index 1a3b3fdb35..aa4ac7cf3e 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -51,74 +51,74 @@ HRESULT CBDebugger::Shutdown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameInit() { +HRESULT CBDebugger::onGameInit() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameShutdown() { +HRESULT CBDebugger::onGameShutdown() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnGameTick() { +HRESULT CBDebugger::onGameTick() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnLog(unsigned int ErrorCode, const char *Text) { +HRESULT CBDebugger::onLog(unsigned int errorCode, const char *text) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptInit(CScScript *script) { +HRESULT CBDebugger::onScriptInit(CScScript *script) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name) { +HRESULT CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name) { +HRESULT CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptShutdown(CScScript *script) { +HRESULT CBDebugger::onScriptShutdown(CScScript *script) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptChangeLine(CScScript *Script, int Line) { +HRESULT CBDebugger::onScriptChangeLine(CScScript *Script, int Line) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptChangeScope(CScScript *Script, CScValue *Scope) { +HRESULT CBDebugger::onScriptChangeScope(CScScript *Script, CScValue *Scope) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptShutdownScope(CScScript *Script, CScValue *Scope) { +HRESULT CBDebugger::onScriptShutdownScope(CScScript *Script, CScValue *Scope) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName) { +HRESULT CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnVariableChangeValue(CScValue *Var, CScValue *value) { +HRESULT CBDebugger::onVariableChangeValue(CScValue *Var, CScValue *value) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::OnScriptHitBreakpoint(CScScript *script) { +HRESULT CBDebugger::onScriptHitBreakpoint(CScScript *script) { return S_OK; } diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index db1b6784f7..e448a72651 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -47,22 +47,22 @@ public: HRESULT Shutdown(); // internal interface - HRESULT OnGameInit(); - HRESULT OnGameShutdown(); - HRESULT OnGameTick(); - HRESULT OnLog(unsigned int ErrorCode, const char *Text); - HRESULT OnScriptInit(CScScript *script); - HRESULT OnScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); - HRESULT OnScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); - - HRESULT OnScriptShutdown(CScScript *script); - HRESULT OnScriptChangeLine(CScScript *Script, int Line); - HRESULT OnScriptChangeScope(CScScript *Script, CScValue *Scope); - HRESULT OnScriptShutdownScope(CScScript *Script, CScValue *Scope); - HRESULT OnVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName); - HRESULT OnVariableChangeValue(CScValue *Var, CScValue *value); - - HRESULT OnScriptHitBreakpoint(CScScript *script); + HRESULT onGameInit(); + HRESULT onGameShutdown(); + HRESULT onGameTick(); + HRESULT onLog(unsigned int ErrorCode, const char *Text); + HRESULT onScriptInit(CScScript *script); + HRESULT onScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); + HRESULT onScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); + + HRESULT onScriptShutdown(CScScript *script); + HRESULT onScriptChangeLine(CScScript *Script, int Line); + HRESULT onScriptChangeScope(CScScript *Script, CScValue *Scope); + HRESULT onScriptShutdownScope(CScScript *Script, CScValue *Scope); + HRESULT onVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName); + HRESULT onVariableChangeValue(CScValue *Var, CScValue *value); + + HRESULT onScriptHitBreakpoint(CScScript *script); // IWmeDebugServer interface virtual bool AttachClient(IWmeDebugClient *Client); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 1fe1c7546a..7fcdb2e26b 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -116,13 +116,13 @@ HRESULT CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &Filename, uint32 *Size, bool MustExist) { +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *Size, bool MustExist) { byte *buffer = NULL; - Common::SeekableReadStream *File = openFile(Filename); + Common::SeekableReadStream *File = openFile(filename); if (!File) { - if (MustExist) Game->LOG(0, "Error opening file '%s'", Filename.c_str()); + if (MustExist) Game->LOG(0, "Error opening file '%s'", filename.c_str()); return NULL; } @@ -137,13 +137,13 @@ byte *CBFileManager::readWholeFile(const Common::String &Filename, uint32 *Size, buffer = new byte[File->size() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", Filename.c_str(), File->size() + 1); + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), File->size() + 1); closeFile(File); return NULL; } if (File->read(buffer, File->size()) != File->size()) { - Game->LOG(0, "Error reading file '%s'", Filename.c_str()); + Game->LOG(0, "Error reading file '%s'", filename.c_str()); closeFile(File); delete [] buffer; return NULL; @@ -163,12 +163,12 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::saveFile(const Common::String &Filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(Filename); + Common::OutSaveFile *file = saveMan->openForSaving(filename); file->write(PrefixBuffer, PrefixSize); file->write(Buffer, BufferSize); file->finalize(); @@ -176,11 +176,11 @@ HRESULT CBFileManager::saveFile(const Common::String &Filename, byte *Buffer, ui #if 0 RestoreCurrentDir(); - CBUtils::CreatePath(Filename, false); + CBUtils::CreatePath(filename, false); - FILE *f = fopen(Filename, "wb"); + FILE *f = fopen(filename, "wb"); if (!f) { - Game->LOG(0, "Error opening file '%s' for writing.", Filename); + Game->LOG(0, "Error opening file '%s' for writing.", filename); return E_FAIL; } @@ -192,7 +192,7 @@ HRESULT CBFileManager::saveFile(const Common::String &Filename, byte *Buffer, ui uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { - Game->LOG(0, "Error allocating compression buffer while saving '%s'", Filename); + Game->LOG(0, "Error allocating compression buffer while saving '%s'", filename); Compressed = false; } else { if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { @@ -209,7 +209,7 @@ HRESULT CBFileManager::saveFile(const Common::String &Filename, byte *Buffer, ui fwrite(CompBuffer, CompSize, 1, f); } else { - Game->LOG(0, "Error compressing data while saving '%s'", Filename); + Game->LOG(0, "Error compressing data while saving '%s'", filename); Compressed = false; } @@ -396,19 +396,19 @@ HRESULT CBFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool SearchSignature) { -// FILE *f = fopen(Filename, "rb"); +HRESULT CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +// FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); - package->open(Filename); + package->open(filename); if (!package->isOpen()) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename.c_str()); + Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); return S_OK; } uint32 AbsoluteOffset = 0; bool BoundToExe = false; - if (SearchSignature) { + if (searchSignature) { uint32 Offset; if (!findPackageSignature(package, &Offset)) { delete package; @@ -424,13 +424,13 @@ HRESULT CBFileManager::registerPackage(const Common::String &Filename , bool Sea hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename.c_str()); + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return S_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", Filename.c_str()); + Game->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 @@ -527,11 +527,11 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool error("Implement RegisterPackage, this is the old one"); #if 0 char Filename[MAX_PATH]; - sprintf(Filename, "%s%s", Path, name); + sprintf(filename, "%s%s", Path, name); - FILE *f = fopen(Filename, "rb"); + FILE *f = fopen(filename, "rb"); if (!f) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", Filename); + Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename); return S_OK; } @@ -553,13 +553,13 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool TPackageHeader hdr; fread(&hdr, sizeof(TPackageHeader), 1, f); if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", Filename); + Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename); fclose(f); return S_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", Filename); + Game->LOG(0, " Warning: package file '%s' is outdated.", filename); } // new in v2 @@ -672,18 +672,18 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { //RestoreCurrentDir(); Common::File *ret = new Common::File(); - char Filename[MAX_PATH]; + char filename[MAX_PATH]; for (int i = 0; i < _packagePaths.GetSize(); i++) { - sprintf(Filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(Filename); + sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); if (ret->isOpen()) { return ret; } } - sprintf(Filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(Filename); + sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); if (ret->isOpen()) { return ret; } @@ -698,11 +698,11 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { restoreCurrentDir(); Common::File *ret = NULL; - char Filename[MAX_PATH]; + char filename[MAX_PATH]; for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(Filename); + sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); + ret->open(filename); if (ret->isOpen()) return ret; } @@ -776,13 +776,13 @@ bool CBFileManager::hasFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; - //Game->LOG(0, "open file: %s", Filename); + //Game->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { char Drive[_MAX_DRIVE]; - _splitpath(Filename, Drive, NULL, NULL, NULL); + _splitpath(filename, Drive, NULL, NULL, NULL); if (Drive[0] != '\0') { - Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", Filename); + Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); } } #endif*/ @@ -807,14 +807,14 @@ HRESULT CBFileManager::closeFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &Filename) { +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { restoreCurrentDir(); Common::SeekableReadStream *ret = NULL; - if (scumm_strnicmp(Filename.c_str(), "savegame:", 9) == 0) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->open(Filename))) { + if (SUCCEEDED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); } delete SaveThumbFile; @@ -823,16 +823,16 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &Fil - ret = openDiskFile(Filename, this); + ret = openDiskFile(filename, this); if (ret) return ret; - ret = openPkgFile(Filename, this); + ret = openPkgFile(filename, this); if (ret) return ret; - ret = CBResources::getFile(Filename); + ret = CBResources::getFile(filename); if (ret) return ret; - warning("BFileManager::OpenFileRaw - Failed to open %s", Filename.c_str()); + warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 7c832becf2..7286c9179d 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -73,18 +73,18 @@ int CBFont::getTextWidth(byte *text, int MaxLenght) { ////////////////////////////////////////////////////////////////////// HRESULT CBFont::loadFile(const char * Filename) { - BYTE* Buffer = Game->_fileManager->readWholeFile(Filename); + BYTE* Buffer = Game->_fileManager->readWholeFile(filename); if(Buffer==NULL){ - Game->LOG(0, "CBFont::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename)+1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); - if(FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + if(FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); delete [] Buffer; @@ -152,11 +152,11 @@ HRESULT CBFont::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *Game, const char *Filename) { - if (isTrueType(Game, Filename)) { +CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { + if (isTrueType(Game, filename)) { CBFontTT *Font = new CBFontTT(Game); if (Font) { - if (FAILED(Font->loadFile(Filename))) { + if (FAILED(Font->loadFile(filename))) { delete Font; return NULL; } @@ -165,7 +165,7 @@ CBFont *CBFont::createFromFile(CBGame *Game, const char *Filename) { } else { CBFontBitmap *Font = new CBFontBitmap(Game); if (Font) { - if (FAILED(Font->loadFile(Filename))) { + if (FAILED(Font->loadFile(filename))) { delete Font; return NULL; } @@ -180,14 +180,14 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *Game, const char *Filename) { +bool CBFont::isTrueType(CBGame *Game, const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) TOKEN_TABLE_END - byte *Buffer = Game->_fileManager->readWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) return false; byte *WorkBuffer = Buffer; diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index a8d613b92e..93bc426ed9 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -48,12 +48,12 @@ public: CBFont(CBGame *inGame); virtual ~CBFont(); - static CBFont *createFromFile(CBGame *Game, const char *Filename); + static CBFont *createFromFile(CBGame *Game, const char *filename); private: //HRESULT loadBuffer(byte * Buffer); //HRESULT loadFile(const char* Filename); - static bool isTrueType(CBGame *Game, const char *Filename); + static bool isTrueType(CBGame *Game, const char *filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index ccbeb6dd80..16a1274e18 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -245,19 +245,19 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CBFontBitmap::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h index f64ef05a64..c1ccddd3bf 100644 --- a/engines/wintermute/Base/BFontBitmap.h +++ b/engines/wintermute/Base/BFontBitmap.h @@ -38,7 +38,7 @@ class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) HRESULT loadBuffer(byte *Buffer); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); virtual int getTextWidth(byte *text, int MaxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index fa08bb44fc..00aa67cb20 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -90,11 +90,11 @@ HRESULT CBFontStorage::InitLoop() { } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::AddFont(const char *Filename) { - if (!Filename) return NULL; +CBFont *CBFontStorage::AddFont(const char *filename) { + if (!filename) return NULL; for (int i = 0; i < _fonts.GetSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { _fonts[i]->_refCount++; return _fonts[i]; } @@ -104,7 +104,7 @@ CBFont *CBFontStorage::AddFont(const char *Filename) { CBFont* font = new CBFont(Game); if (!font) return NULL; - if (FAILED(font->loadFile(Filename))) { + if (FAILED(font->loadFile(filename))) { delete font; return NULL; } @@ -114,7 +114,7 @@ CBFont *CBFontStorage::AddFont(const char *Filename) { return font; } */ - CBFont *font = CBFont::createFromFile(Game, Filename); + CBFont *font = CBFont::createFromFile(Game, filename); if (font) { font->_refCount = 1; _fonts.Add(font); diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index 110f4634c8..b337d2d6d5 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -43,7 +43,7 @@ public: DECLARE_PERSISTENT(CBFontStorage, CBBase) HRESULT cleanup(bool Warn = false); HRESULT RemoveFont(CBFont *Font); - CBFont *AddFont(const char *Filename); + CBFont *AddFont(const char *filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); CBArray _fonts; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index cc373961e2..a5081f91f9 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -404,19 +404,19 @@ int CBFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CBFontTT::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 3e034cc499..8a20b87299 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -479,12 +479,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "AddSubframe") == 0) { stack->correctParams(1); CScValue *Val = stack->pop(); - const char *Filename = NULL; - if (!Val->isNULL()) Filename = Val->getString(); + const char *filename = NULL; + if (!Val->isNULL()) filename = Val->getString(); CBSubFrame *Sub = new CBSubFrame(Game); - if (Filename != NULL) { - Sub->setSurface(Filename); + if (filename != NULL) { + Sub->setSurface(filename); Sub->setDefaultRect(); } _subframes.Add(Sub); @@ -502,12 +502,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (Index < 0) Index = 0; CScValue *Val = stack->pop(); - const char *Filename = NULL; - if (!Val->isNULL()) Filename = Val->getString(); + const char *filename = NULL; + if (!Val->isNULL()) filename = Val->getString(); CBSubFrame *Sub = new CBSubFrame(Game); - if (Filename != NULL) { - Sub->setSurface(Filename); + if (filename != NULL) { + Sub->setSurface(filename); } if (Index >= _subframes.GetSize()) _subframes.Add(Sub); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index b3c4c87ecd..7037e19c31 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -284,7 +284,7 @@ CBGame::~CBGame() { LOG(0, ""); LOG(0, "Shutting down..."); - getDebugMgr()->OnGameShutdown(); + getDebugMgr()->onGameShutdown(); _registry->WriteBool("System", "LastRun", true); @@ -356,10 +356,10 @@ HRESULT CBGame::cleanup() { _musicStartTime[i] = 0; } - UnregisterObject(_store); + unregisterObject(_store); _store = NULL; - UnregisterObject(_fader); + unregisterObject(_fader); _fader = NULL; for (int i = 0; i < _regObjects.GetSize(); i++) { @@ -458,11 +458,11 @@ HRESULT CBGame::initialize1() { _fader = new CBFader(this); if (_fader == NULL) goto init_fail; - RegisterObject(_fader); + registerObject(_fader); _store = new CSXStore(this); if (_store == NULL) goto init_fail; - RegisterObject(_store); + registerObject(_store); return S_OK; @@ -585,7 +585,7 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } - if (_debugMgr) _debugMgr->OnLog(res, buff); + if (_debugMgr) _debugMgr->onLog(res, buff); debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); @@ -609,10 +609,10 @@ HRESULT CBGame::initLoop() { _currentTime = CBPlatform::GetTime(); - getDebugMgr()->OnGameTick(); + getDebugMgr()->onGameTick(); _renderer->initLoop(); _soundMgr->initLoop(); - UpdateMusicCrossfade(); + updateMusicCrossfade(); _surfaceStorage->initLoop(); _fontStorage->InitLoop(); @@ -993,7 +993,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { HRESULT res = CBObject::scCallMethod(script, stack, thisStack, name); - SetWindowTitle(); + setWindowTitle(); return res; } @@ -1047,7 +1047,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); CBScriptable *obj = stack->pop()->getNative(); - if (ValidObject((CBObject *) obj)) stack->pushBool(true); + if (validObject((CBObject *) obj)) stack->pushBool(true); else stack->pushBool(false); return S_OK; @@ -1058,7 +1058,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { stack->correctParams(0); - ResetContent(); + resetContent(); stack->pushNULL(); return S_OK; @@ -1072,7 +1072,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); CScValue *val = stack->pop(); CBObject *obj = (CBObject *)val->getNative(); - UnregisterObject(obj); + unregisterObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); @@ -1087,7 +1087,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CUIWindow *win = new CUIWindow(Game); if (win && SUCCEEDED(win->loadFile(stack->pop()->getString()))) { _windows.Add(win); - RegisterObject(win); + registerObject(win); stack->pushNative(win, true); } else { delete win; @@ -1559,7 +1559,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); int Slot = stack->pop()->getInt(); - stack->pushBool(IsSaveSlotUsed(Slot)); + stack->pushBool(isSaveSlotUsed(Slot)); return S_OK; } @@ -1571,7 +1571,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int Slot = stack->pop()->getInt(); char Desc[512]; Desc[0] = '\0'; - GetSaveSlotDescription(Slot, Desc); + getSaveSlotDescription(Slot, Desc); stack->pushString(Desc); return S_OK; } @@ -1582,7 +1582,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "EmptySaveSlot") == 0) { stack->correctParams(1); int Slot = stack->pop()->getInt(); - EmptySaveSlot(Slot); + emptySaveSlot(Slot); stack->pushNULL(); return S_OK; } @@ -1845,7 +1845,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CUIWindow *Win = new CUIWindow(Game); _windows.Add(Win); - RegisterObject(Win); + registerObject(Win); if (!Val->isNULL()) Win->setName(Val->getString()); stack->pushNative(Win, true); return S_OK; @@ -1859,7 +1859,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBObject *Obj = (CBObject *)stack->pop()->getNative(); for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i] == Obj) { - UnregisterObject(_windows[i]); + unregisterObject(_windows[i]); stack->pushBool(true); return S_OK; } @@ -1997,7 +1997,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete _loadingIcon; _loadingIcon = NULL; } else { - DisplayContent(false, true); + displayContent(false, true); Game->_renderer->flip(); Game->_renderer->initLoop(); } @@ -2487,7 +2487,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = GetDataDir(); + AnsiString dataDir = getDataDir(); _scValue->setString(dataDir.c_str()); return _scValue; } @@ -2588,7 +2588,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { HRESULT res = CBObject::scSetProperty(name, value); - SetWindowTitle(); + setWindowTitle(); return res; } @@ -2597,7 +2597,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { CBScriptable *obj = value->getNative(); - if (obj == NULL || ValidObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; return S_OK; } @@ -2758,7 +2758,7 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayQuickMsg() { +HRESULT CBGame::displayQuickMsg() { if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; int i; @@ -2808,14 +2808,14 @@ void CBGame::quickMessageForm(LPSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::RegisterObject(CBObject *object) { +HRESULT CBGame::registerObject(CBObject *object) { _regObjects.Add(object); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::UnregisterObject(CBObject *object) { +HRESULT CBGame::unregisterObject(CBObject *object) { if (!object) return S_OK; int i; @@ -2869,7 +2869,7 @@ void CBGame::invalidateValues(void *value, void *data) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::ValidObject(CBObject *object) { +bool CBGame::validObject(CBObject *object) { if (!object) return false; if (object == this) return true; @@ -3013,7 +3013,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); CBScriptable *obj = stack->pop()->getNative(); - if (ValidObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); + if (validObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); stack->pushNULL(); } @@ -3150,7 +3150,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); if (Game->getDebugMgr()->_enabled) { - Game->getDebugMgr()->OnScriptHitBreakpoint(script); + Game->getDebugMgr()->onScriptHitBreakpoint(script); script->Sleep(0); } stack->pushNULL(); @@ -3227,7 +3227,7 @@ HRESULT CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH + 1]; - GetSaveSlotFilename(slot, filename); + getSaveSlotFilename(slot, filename); LOG(0, "Saving game '%s'...", filename); @@ -3271,23 +3271,23 @@ save_finish: ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(int slot) { +HRESULT CBGame::loadGame(int slot) { //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); _loading = false; _scheduledLoadSlot = -1; char filename[MAX_PATH + 1]; - GetSaveSlotFilename(slot, filename); + getSaveSlotFilename(slot, filename); - return LoadGame(filename); + return loadGame(filename); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::LoadGame(const char *filename) { +HRESULT CBGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->OnGameShutdown(); + getDebugMgr()->onGameShutdown(); HRESULT ret; @@ -3315,14 +3315,14 @@ HRESULT CBGame::LoadGame(const char *filename) { if (FAILED(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish; // data initialization after load - InitAfterLoad(); + initAfterLoad(); Game->applyEvent("AfterLoad", true); - DisplayContent(true, false); + displayContent(true, false); //_renderer->flip(); - getDebugMgr()->OnGameInit(); + getDebugMgr()->onGameInit(); load_finish: _dEBUG_AbsolutePathWarning = true; @@ -3341,7 +3341,7 @@ load_finish: ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::InitAfterLoad() { +HRESULT CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); @@ -3383,7 +3383,7 @@ void CBGame::afterLoadScript(void *script, void *data) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayWindows(bool inGame) { +HRESULT CBGame::displayWindows(bool inGame) { HRESULT res; int i; @@ -3725,7 +3725,7 @@ HRESULT CBGame::focusWindow(CUIWindow *Window) { Game->_focusedWindow = Window; } - if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->ValidObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) return focusWindow(Prev); else return S_OK; } @@ -3768,16 +3768,16 @@ HRESULT CBGame::unfreeze() { ////////////////////////////////////////////////////////////////////////// bool CBGame::handleKeypress(Common::Event *event, bool printable) { - if (IsVideoPlaying()) { + if (isVideoPlaying()) { if (event->kbd.keycode == Common::KEYCODE_ESCAPE) - StopVideo(); + stopVideo(); return true; } #ifdef __WIN32__ // TODO: Do we really need to handle this in-engine? // handle Alt+F4 on windows if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) { - OnWindowClose(); + onWindowClose(); return true; //TODO } @@ -3848,19 +3848,19 @@ bool CBGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor) { - if (VerMajor) *VerMajor = DCGF_VER_MAJOR; - if (VerMinor) *VerMinor = DCGF_VER_MINOR; +HRESULT CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) *verMajor = DCGF_VER_MAJOR; + if (verMinor) *verMinor = DCGF_VER_MINOR; - if (ExtMajor) *ExtMajor = 0; - if (ExtMinor) *ExtMinor = 0; + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CBGame::SetWindowTitle() { +void CBGame::setWindowTitle() { if (_renderer) { char Title[512]; strcpy(Title, _caption[0]); @@ -3888,8 +3888,8 @@ void CBGame::SetWindowTitle() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { - AnsiString dataDir = GetDataDir(); +HRESULT CBGame::getSaveSlotFilename(int Slot, char *Buffer) { + AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); sprintf(Buffer, "save%03d.%s", Slot, _savedGameExt); warning("Saving %s - we really should prefix these things to avoid collisions.", Buffer); @@ -3897,7 +3897,7 @@ HRESULT CBGame::GetSaveSlotFilename(int Slot, char *Buffer) { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::GetDataDir() { +AnsiString CBGame::getDataDir() { AnsiString userDir = PathUtil::getUserDirectory(); #ifdef __IPHONEOS__ return userDir; @@ -3909,11 +3909,11 @@ AnsiString CBGame::GetDataDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { - Buffer[0] = '\0'; +HRESULT CBGame::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; char filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, filename); + getSaveSlotFilename(slot, filename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; @@ -3925,7 +3925,7 @@ HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { } _dEBUG_AbsolutePathWarning = true; - strcpy(Buffer, pm->_savedDescription); + strcpy(buffer, pm->_savedDescription); delete pm; return S_OK; @@ -3933,9 +3933,9 @@ HRESULT CBGame::GetSaveSlotDescription(int Slot, char *Buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsSaveSlotUsed(int slot) { +bool CBGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH + 1]; - GetSaveSlotFilename(slot, filename); + getSaveSlotFilename(slot, filename); warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); @@ -3946,9 +3946,9 @@ bool CBGame::IsSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::EmptySaveSlot(int Slot) { +HRESULT CBGame::emptySaveSlot(int Slot) { char filename[MAX_PATH + 1]; - GetSaveSlotFilename(Slot, filename); + getSaveSlotFilename(Slot, filename); CBPlatform::DeleteFile(filename); @@ -4038,13 +4038,13 @@ HRESULT CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowLoadHook(CUIWindow *win, char **Buf, char **Params) { +HRESULT CBGame::windowLoadHook(CUIWindow *win, char **Buf, char **Params) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::WindowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +HRESULT CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { return E_FAIL; } @@ -4073,13 +4073,13 @@ void CBGame::setResourceModule(HMODULE resModule) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayContent(bool update, bool displayAll) { +HRESULT CBGame::displayContent(bool update, bool displayAll) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayContentSimple() { +HRESULT CBGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); if (_indicatorDisplay) displayIndicator(); @@ -4107,7 +4107,7 @@ HRESULT CBGame::displayIndicator() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::UpdateMusicCrossfade() { +HRESULT CBGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) return S_OK; @@ -4162,7 +4162,7 @@ HRESULT CBGame::UpdateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ResetContent() { +HRESULT CBGame::resetContent() { _scEngine->ClearGlobals(); //_timer = 0; //_liveTimer = 0; @@ -4215,14 +4215,14 @@ HRESULT CBGame::setWaitCursor(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsVideoPlaying() { +bool CBGame::isVideoPlaying() { if (_videoPlayer->isPlaying()) return true; if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; return false; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::StopVideo() { +HRESULT CBGame::stopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); @@ -4246,7 +4246,7 @@ HRESULT CBGame::drawCursor(CBSprite *Cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { +HRESULT CBGame::onActivate(bool Activate, bool RefreshMouse) { if (_shuttingDown || !_renderer) return S_OK; _renderer->_active = Activate; @@ -4264,7 +4264,7 @@ HRESULT CBGame::OnActivate(bool Activate, bool RefreshMouse) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftDown() { +HRESULT CBGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); @@ -4282,7 +4282,7 @@ HRESULT CBGame::OnMouseLeftDown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftUp() { +HRESULT CBGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::ReleaseCapture(); @@ -4299,7 +4299,7 @@ HRESULT CBGame::OnMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseLeftDblClick() { +HRESULT CBGame::onMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return S_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); @@ -4314,7 +4314,7 @@ HRESULT CBGame::OnMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightDblClick() { +HRESULT CBGame::onMouseRightDblClick() { if (_state == GAME_RUNNING && !_interactive) return S_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); @@ -4329,7 +4329,7 @@ HRESULT CBGame::OnMouseRightDblClick() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightDown() { +HRESULT CBGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); @@ -4342,7 +4342,7 @@ HRESULT CBGame::OnMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseRightUp() { +HRESULT CBGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); @@ -4355,7 +4355,7 @@ HRESULT CBGame::OnMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseMiddleDown() { +HRESULT CBGame::onMouseMiddleDown() { if (_state == GAME_RUNNING && !_interactive) return S_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); @@ -4370,7 +4370,7 @@ HRESULT CBGame::OnMouseMiddleDown() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnMouseMiddleUp() { +HRESULT CBGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); @@ -4383,18 +4383,18 @@ HRESULT CBGame::OnMouseMiddleUp() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnPaint() { +HRESULT CBGame::onPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { _renderer->initLoop(); - DisplayContent(false, true); - DisplayDebugInfo(); + displayContent(false, true); + displayDebugInfo(); _renderer->windowedBlt(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnWindowClose() { +HRESULT CBGame::onWindowClose() { if (canHandleEvent("QuitGame")) { if (_state != GAME_FROZEN) Game->applyEvent("QuitGame"); return S_OK; @@ -4402,7 +4402,7 @@ HRESULT CBGame::OnWindowClose() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::DisplayDebugInfo() { +HRESULT CBGame::displayDebugInfo() { char str[100]; if (_dEBUG_ShowFPS) { @@ -4499,22 +4499,22 @@ HRESULT CBGame::MiniUpdate() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::OnScriptShutdown(CScScript *script) { +HRESULT CBGame::onScriptShutdown(CScScript *script) { return S_OK; } ////////////////////////////////////////////////////////////////////////// bool CBGame::isLeftDoubleClick() { - return IsDoubleClick(0); + return isDoubleClick(0); } ////////////////////////////////////////////////////////////////////////// bool CBGame::isRightDoubleClick() { - return IsDoubleClick(1); + return isDoubleClick(1); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::IsDoubleClick(int buttonIndex) { +bool CBGame::isDoubleClick(int buttonIndex) { uint32 maxDoubleCLickTime = 500; int maxMoveX = 4; int maxMoveY = 4; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 799abc7b5c..055e2d1410 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -67,19 +67,19 @@ class CBGame: public CBObject { public: DECLARE_PERSISTENT(CBGame, CBObject) - virtual HRESULT OnScriptShutdown(CScScript *script); - - virtual HRESULT OnActivate(bool Activate, bool RefreshMouse); - virtual HRESULT OnMouseLeftDown(); - virtual HRESULT OnMouseLeftUp(); - virtual HRESULT OnMouseLeftDblClick(); - virtual HRESULT OnMouseRightDblClick(); - virtual HRESULT OnMouseRightDown(); - virtual HRESULT OnMouseRightUp(); - virtual HRESULT OnMouseMiddleDown(); - virtual HRESULT OnMouseMiddleUp(); - virtual HRESULT OnPaint(); - virtual HRESULT OnWindowClose(); + virtual HRESULT onScriptShutdown(CScScript *script); + + virtual HRESULT onActivate(bool activate, bool refreshMouse); + virtual HRESULT onMouseLeftDown(); + virtual HRESULT onMouseLeftUp(); + virtual HRESULT onMouseLeftDblClick(); + virtual HRESULT onMouseRightDblClick(); + virtual HRESULT onMouseRightDown(); + virtual HRESULT onMouseRightUp(); + virtual HRESULT onMouseMiddleDown(); + virtual HRESULT onMouseMiddleUp(); + virtual HRESULT onPaint(); + virtual HRESULT onWindowClose(); bool isLeftDoubleClick(); bool isRightDoubleClick(); @@ -96,7 +96,7 @@ public: bool _shuttingDown; - virtual HRESULT DisplayDebugInfo(); + virtual HRESULT displayDebugInfo(); bool _dEBUG_ShowFPS; bool _suspendedRendering; @@ -110,10 +110,10 @@ public: int _loadingIconY; int _loadingIconPersistent; - virtual HRESULT ResetContent(); + virtual HRESULT resetContent(); void DEBUG_DumpClassRegistry(); - HRESULT setWaitCursor(const char *Filename); + HRESULT setWaitCursor(const char *filename); char *_localSaveDir; bool _saveDirChecked; @@ -248,39 +248,39 @@ public: int _scheduledLoadSlot; bool _loading; bool _personalizedSave; - HRESULT EmptySaveSlot(int Slot); - bool IsSaveSlotUsed(int Slot); - HRESULT GetSaveSlotDescription(int Slot, char *Buffer); - HRESULT GetSaveSlotFilename(int Slot, char *Buffer); - void SetWindowTitle(); + HRESULT emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + HRESULT getSaveSlotDescription(int slot, char *buffer); + HRESULT getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); virtual bool handleMouseWheel(int Delta); bool _quitting; - virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor); + virtual HRESULT getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); int _freezeLevel; HRESULT unfreeze(); - HRESULT freeze(bool IncludingMusic = true); - HRESULT focusWindow(CUIWindow *Window); + HRESULT freeze(bool includingMusic = true); + HRESULT focusWindow(CUIWindow *window); CVidPlayer *_videoPlayer; CVidTheoraPlayer *_theoraPlayer; bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; - static void afterLoadRegion(void *Region, void *Data); - static void afterLoadSubFrame(void *Subframe, void *Data); - static void afterLoadSound(void *Sound, void *Data); - static void afterLoadFont(void *Font, void *Data); + static void afterLoadRegion(void *region, void *data); + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); static void afterLoadScript(void *script, void *data); - static void invalidateValues(void *Value, void *Data); - - HRESULT loadSettings(const char *Filename); - HRESULT resumeMusic(int Channel); - HRESULT setMusicStartTime(int Channel, uint32 Time); - HRESULT pauseMusic(int Channel); - HRESULT stopMusic(int Channel); - HRESULT playMusic(int Channel, const char *Filename, bool Looping = true, uint32 LoopStart = 0); + static void invalidateValues(void *value, void *data); + + HRESULT loadSettings(const char *filename); + HRESULT resumeMusic(int channel); + HRESULT setMusicStartTime(int channel, uint32 time); + HRESULT pauseMusic(int channel); + HRESULT stopMusic(int channel); + HRESULT playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); CBSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; @@ -288,12 +288,12 @@ public: uint32 _musicCrossfadeLength; int _musicCrossfadeChannel1; int _musicCrossfadeChannel2; - HRESULT DisplayWindows(bool InGame = false); + HRESULT displayWindows(bool inGame = false); CBRegistry *_registry; bool _useD3D; virtual HRESULT cleanup(); - virtual HRESULT LoadGame(int Slot); - virtual HRESULT LoadGame(const char *Filename); + virtual HRESULT loadGame(int slot); + virtual HRESULT loadGame(const char *filename); virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); virtual HRESULT showCursor(); @@ -314,39 +314,39 @@ public: CBObject *_capturedObject; POINT _mousePos; - bool ValidObject(CBObject *object); - HRESULT UnregisterObject(CBObject *object); - HRESULT RegisterObject(CBObject *object); + bool validObject(CBObject *object); + HRESULT unregisterObject(CBObject *object); + HRESULT registerObject(CBObject *object); void quickMessage(const char *text); void quickMessageForm(LPSTR fmt, ...); - HRESULT DisplayQuickMsg(); + HRESULT displayQuickMsg(); uint32 _fps; - HRESULT UpdateMusicCrossfade(); + HRESULT updateMusicCrossfade(); - bool IsVideoPlaying(); - HRESULT StopVideo(); + bool isVideoPlaying(); + HRESULT stopVideo(); CBArray _regObjects; public: - virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); - virtual HRESULT DisplayContentSimple(); + virtual HRESULT displayContent(bool update = true, bool displayAll = false); + virtual HRESULT displayContentSimple(); bool _forceNonStreamedSounds; void resetMousePos(); int _subtitlesSpeed; void SetInteractive(bool State); - virtual HRESULT WindowLoadHook(CUIWindow *Win, char **Buf, char **Params); - virtual HRESULT WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); - HRESULT getCurrentViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - HRESULT getCurrentViewportRect(RECT *Rect, bool *Custom = NULL); + virtual HRESULT windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual HRESULT windowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); + HRESULT getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + HRESULT getCurrentViewportRect(RECT *rect, bool *custom = NULL); HRESULT popViewport(); HRESULT pushViewport(CBViewport *Viewport); HRESULT setActiveObject(CBObject *Obj); CBSprite *_lastCursor; HRESULT drawCursor(CBSprite *Cursor); - virtual HRESULT InitAfterLoad(); + virtual HRESULT initAfterLoad(); CBSaveThumbHelper *_cachedThumbnail; - AnsiString GetDataDir(); + AnsiString getDataDir(); void addMem(int bytes); bool _touchInterface; @@ -368,7 +368,7 @@ private: }; LastClickInfo _lastClick[2]; - bool IsDoubleClick(int buttonIndex); + bool isDoubleClick(int buttonIndex); uint32 _usedMem; diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 31a3772964..11be19683f 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -112,11 +112,11 @@ void CBImage::copyFrom(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::SaveBMPFile(const char *Filename) { +HRESULT CBImage::SaveBMPFile(const char *filename) { #if 0 if (!_bitmap) return E_FAIL; - if (FreeImage_Save(FIF_BMP, _bitmap, Filename)) return S_OK; + if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return S_OK; else return E_FAIL; #endif return E_FAIL; diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 8b2cf70cc1..2472af718c 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -57,7 +57,7 @@ public: byte getAlphaAt(int x, int y); bool writeBMPToStream(Common::WriteStream *stream); HRESULT Resize(int NewWidth, int NewHeight); - HRESULT SaveBMPFile(const char *Filename); + HRESULT SaveBMPFile(const char *filename); HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); void copyFrom(Graphics::Surface *surface); private: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index a352b11bf0..8b92721a4e 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -268,8 +268,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); - if (SUCCEEDED(playSFX(Filename, false, false))) + const char *filename = stack->pop()->getString(); + if (SUCCEEDED(playSFX(filename, false, false))) stack->pushBool(true); else stack->pushBool(false); @@ -283,7 +283,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "PlaySound") == 0) { stack->correctParams(3); - const char *Filename; + const char *filename; bool Looping; uint32 LoopStart; @@ -292,17 +292,17 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val3 = stack->pop(); if (val1->_type == VAL_BOOL) { - Filename = NULL; + filename = NULL; Looping = val1->getBool(); LoopStart = val2->getInt(); } else { - if (val1->isNULL()) Filename = NULL; - else Filename = val1->getString(); + if (val1->isNULL()) filename = NULL; + else filename = val1->getString(); Looping = val2->isNULL() ? false : val2->getBool(); LoopStart = val3->getInt(); } - if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->pushBool(false); + if (FAILED(playSFX(filename, Looping, true, NULL, LoopStart))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -313,21 +313,21 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "PlaySoundEvent") == 0) { stack->correctParams(2); - const char *Filename; + const char *filename; const char *EventName; CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); if (val2->isNULL()) { - Filename = NULL; + filename = NULL; EventName = val1->getString(); } else { - Filename = val1->getString(); + filename = val1->getString(); EventName = val2->getString(); } - if (FAILED(playSFX(Filename, false, true, EventName))) stack->pushBool(false); + if (FAILED(playSFX(filename, false, true, EventName))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index b217994ada..ef4d8f3909 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -70,7 +70,7 @@ public: HRESULT resumeSFX(); HRESULT pauseSFX(); HRESULT stopSFX(bool DeleteSound = true); - HRESULT playSFX(const char *Filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); + HRESULT playSFX(const char *filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -83,8 +83,8 @@ public: virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual int getHeight(); - HRESULT setCursor(const char *Filename); - HRESULT setActiveCursor(const char *Filename); + HRESULT setCursor(const char *filename); + HRESULT setActiveCursor(const char *filename); HRESULT cleanup(); char *getCaption(int Case = 1); void setCaption(const char *Caption, int Case = 1); diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 74c9fbd422..dc04d1624e 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -195,7 +195,7 @@ HRESULT CBPersistMgr::initSave(const char *desc) { putDWORD(magic); byte VerMajor, VerMinor, ExtMajor, ExtMinor; - Game->GetVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + Game->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); _saveStream->writeByte(VerMajor); _saveStream->writeByte(VerMinor); @@ -250,7 +250,7 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { _saving = false; _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = Game->_fileManager->readWholeFile(Filename, &_bufferSize); + //_buffer = Game->_fileManager->readWholeFile(filename, &_bufferSize); if (_loadStream) { uint32 Magic; Magic = getDWORD(); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index c100a2c765..3efd913da8 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -95,19 +95,19 @@ bool CBRegion::PointInRegion(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CBRegion::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index e63ae3a170..fb725e814b 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -50,7 +50,7 @@ public: virtual ~CBRegion(); bool PointInRegion(int X, int Y); bool CreateRegion(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); RECT _rect; CBArray _points; diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 7a77e17fc7..64f2a0093c 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -139,12 +139,12 @@ char *CBRegistry::GetIniName() { ////////////////////////////////////////////////////////////////////////// void CBRegistry::LoadValues(bool local) { if (local) LoadXml("settings.xml", _localValues); - else LoadXml(PathUtil::combine(Game->GetDataDir(), "settings.xml"), _values); + else LoadXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::SaveValues() { - SaveXml(PathUtil::combine(Game->GetDataDir(), "settings.xml"), _values); + SaveXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 1427b31aae..acbd8a645e 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -621,10 +621,10 @@ void CBRenderSDL::pointToScreen(POINT *point) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::dumpData(const char *Filename) { - warning("CBRenderSDL::DumpData(%s) - not reimplemented yet", Filename); // TODO +void CBRenderSDL::dumpData(const char *filename) { + warning("CBRenderSDL::DumpData(%s) - not reimplemented yet", filename); // TODO #if 0 - FILE *f = fopen(Filename, "wt"); + FILE *f = fopen(filename, "wt"); if (!f) return; CBSurfaceStorage *Mgr = Game->_surfaceStorage; diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index a9abb18e9d..0f3cf82a31 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -89,7 +89,7 @@ public: void pointFromScreen(POINT *point); void pointToScreen(POINT *point); - void dumpData(const char *Filename); + void dumpData(const char *filename); float getScaleRatioX() const { return _ratioX; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 38925fc57a..5caa707e54 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -47,7 +47,7 @@ public: int _drawOffsetX; int _drawOffsetY; - virtual void dumpData(const char *Filename) {}; + virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); virtual HRESULT setViewport(int left, int top, int right, int bottom); virtual HRESULT setViewport(RECT *Rect); diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 1e54470924..9e5466b323 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -53,10 +53,10 @@ HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { if (DoFlip) { // when using opengl on windows it seems to be necessary to do this twice // works normally for direct3d - Game->DisplayContent(false); + Game->displayContent(false); Game->_renderer->flip(); - Game->DisplayContent(false); + Game->displayContent(false); Game->_renderer->flip(); } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index b6495931aa..6353352b8d 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -71,11 +71,11 @@ HRESULT CBScriptHolder::cleanup() { } ////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *Filename) { +void CBScriptHolder::setFilename(const char *filename) { if (_filename != NULL) delete [] _filename; - _filename = new char [strlen(Filename) + 1]; - if (_filename != NULL) strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) strcpy(_filename, filename); } @@ -172,11 +172,11 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DetachScript") == 0) { stack->correctParams(2); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool KillThreads = stack->pop()->getBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { _scripts[i]->finish(KillThreads); ret = true; break; @@ -192,10 +192,10 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScriptRunning") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; } @@ -276,28 +276,28 @@ HRESULT CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::addScript(const char *Filename) { +HRESULT CBScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.GetSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", Filename, _name); + Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); return S_OK; } } } - CScScript *scr = Game->_scEngine->RunScript(Filename, this); + CScScript *scr = Game->_scEngine->RunScript(filename, this); if (!scr) { if (Game->_editorForceScripts) { // editor hack scr = new CScScript(Game, Game->_scEngine); - scr->_filename = new char[strlen(Filename) + 1]; - strcpy(scr->_filename, Filename); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); scr->_state = SCRIPT_ERROR; scr->_owner = this; _scripts.Add(scr); Game->_scEngine->_scripts.Add(scr); - Game->getDebugMgr()->OnScriptInit(scr); + Game->getDebugMgr()->onScriptInit(scr); return S_OK; } @@ -436,7 +436,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { HRESULT ret = thread->CreateMethodThread(_scripts[i], methodName); if (SUCCEEDED(ret)) { _scripts[i]->_engine->_scripts.Add(thread); - Game->getDebugMgr()->OnScriptMethodThreadInit(thread, _scripts[i], methodName); + Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); return thread; } else { diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 55db2a0f89..44d51cd360 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -93,8 +93,8 @@ void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSi ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload); +HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); #if 0 if (_stream) { BASS_StreamFree(_stream); @@ -105,24 +105,24 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { delete _file; // Load a file, but avoid having the File-manager handle the disposal of it. - _file = Game->_fileManager->openFile(Filename, true, false); + _file = Game->_fileManager->openFile(filename, true, false); if (!_file) { - Game->LOG(0, "Error opening sound file '%s'", Filename); + Game->LOG(0, "Error opening sound file '%s'", filename); return E_FAIL; } - Common::String strFilename(Filename); + Common::String strFilename(filename); if (strFilename.hasSuffix(".ogg")) { _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); } else if (strFilename.hasSuffix(".wav")) { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s", Filename); + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s", filename); //_stream = Audio::makeWAVStream(_file, DisposeAfterUse::NO); } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", Filename); + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); } if (!_stream) { return E_FAIL; } - CBUtils::setString(&_filename, Filename); + CBUtils::setString(&_filename, filename); return S_OK; #if 0 @@ -134,20 +134,20 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); if (!_stream) { - Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), Filename); + Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); return E_FAIL; } - CBUtils::setString(&_filename, Filename); + CBUtils::setString(&_filename, filename); /* HRESULT res; bool NewlyCreated = false; if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = Game->_fileManager->openFile(Filename); + if(!_file) _file = Game->_fileManager->openFile(filename); if(!_file){ - Game->LOG(0, "Error opening sound file '%s'", Filename); + Game->LOG(0, "Error opening sound file '%s'", filename); return E_FAIL; } // switch to streamed for big files @@ -160,7 +160,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { res = InitializeBuffer(_file); if(FAILED(res)){ - Game->LOG(res, "Error creating sound buffer for file '%s'", Filename); + Game->LOG(res, "Error creating sound buffer for file '%s'", filename); return res; } } @@ -169,8 +169,8 @@ HRESULT CBSoundBuffer::loadFromFile(const char *Filename, bool ForceReload) { // store filename if(!_filename){ - _filename = new char[strlen(Filename)+1]; - strcpy(_filename, Filename); + _filename = new char[strlen(filename)+1]; + strcpy(_filename, filename); } // close file (if not streaming) diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 1e59ef0971..264c5856b2 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -71,7 +71,7 @@ public: void setType(TSoundType Type); - HRESULT loadFromFile(const char *Filename, bool ForceReload = false); + HRESULT loadFromFile(const char *filename, bool ForceReload = false); void setStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); HRESULT applyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 18e674687c..27e96f7d75 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -126,20 +126,20 @@ HRESULT CBSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool Streamed) { +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType Type, bool Streamed) { if (!_soundAvailable) return NULL; CBSoundBuffer *sound; // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::getExtension(Filename); + AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::compareNoCase(ext, "wav")) { - AnsiString path = PathUtil::getDirectoryName(Filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(Filename); + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); AnsiString newFile = PathUtil::combine(path, name + "ogg"); if (Game->_fileManager->hasFile(newFile)) { - Filename = newFile.c_str(); + filename = newFile.c_str(); } } @@ -150,9 +150,9 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *Filename, TSoundType Type, bool sound->setType(Type); - HRESULT res = sound->loadFromFile(Filename); + HRESULT res = sound->loadFromFile(filename); if (FAILED(res)) { - Game->LOG(res, "Error loading sound '%s'", Filename); + Game->LOG(res, "Error loading sound '%s'", filename); delete sound; return NULL; } diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index 313823449d..ca00ca43ee 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -52,7 +52,7 @@ public: int _volumeSpeech; int _volumeSFX; HRESULT removeSound(CBSoundBuffer *Sound); - CBSoundBuffer *addSound(const char *Filename, TSoundType Type = SOUND_SFX, bool Streamed = false); + CBSoundBuffer *addSound(const char *filename, TSoundType Type = SOUND_SFX, bool Streamed = false); HRESULT addSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); HRESULT initLoop(); HRESULT initialize(); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index ae5a185cc4..5c44fcf546 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -122,10 +122,10 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::loadFile(const char *Filename, int LifeTime, TSpriteCacheType CacheType) { - Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); +HRESULT CBSprite::loadFile(const char *filename, int LifeTime, TSpriteCacheType CacheType) { + Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); if (!File) { - Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", LifeTime, CacheType); else return loadFile("invalid.bmp", LifeTime, CacheType); } else { @@ -135,13 +135,13 @@ HRESULT CBSprite::loadFile(const char *Filename, int LifeTime, TSpriteCacheType HRESULT ret; - AnsiString ext = PathUtil::getExtension(Filename); - if (StringUtil::startsWith(Filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); - subframe->setSurface(Filename, true, 0, 0, 0, LifeTime, true); + subframe->setSurface(filename, true, 0, 0, 0, LifeTime, true); if (subframe->_surface == NULL) { - Game->LOG(0, "Error loading simple sprite '%s'", Filename); + Game->LOG(0, "Error loading simple sprite '%s'", filename); ret = E_FAIL; delete frame; delete subframe; @@ -153,15 +153,15 @@ HRESULT CBSprite::loadFile(const char *Filename, int LifeTime, TSpriteCacheType ret = S_OK; } } else { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer) { - if (FAILED(ret = loadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); delete [] Buffer; } } - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); return ret; @@ -563,13 +563,13 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "AddFrame") == 0) { stack->correctParams(1); CScValue *Val = stack->pop(); - const char *Filename = NULL; - if (!Val->isNULL()) Filename = Val->getString(); + const char *filename = NULL; + if (!Val->isNULL()) filename = Val->getString(); CBFrame *Frame = new CBFrame(Game); - if (Filename != NULL) { + if (filename != NULL) { CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->setSurface(Filename))) { + if (SUCCEEDED(Sub->setSurface(filename))) { Sub->setDefaultRect(); Frame->_subframes.Add(Sub); } else delete Sub; @@ -589,13 +589,13 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Index < 0) Index = 0; CScValue *Val = stack->pop(); - const char *Filename = NULL; - if (!Val->isNULL()) Filename = Val->getString(); + const char *filename = NULL; + if (!Val->isNULL()) filename = Val->getString(); CBFrame *Frame = new CBFrame(Game); - if (Filename != NULL) { + if (filename != NULL) { CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->setSurface(Filename))) Frame->_subframes.Add(Sub); + if (SUCCEEDED(Sub->setSurface(filename))) Frame->_subframes.Add(Sub); else delete Sub; } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index f65ed130c2..3857be14de 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -67,12 +67,12 @@ public: bool _paused; bool _finished; HRESULT loadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT loadFile(const char *Filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadFile(const char *filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); uint32 _lastFrameTime; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - HRESULT AddFrame(const char *Filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); + HRESULT AddFrame(const char *filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); CBSprite(CBGame *inGame, CBObject *Owner = NULL); virtual ~CBSprite(); CBArray _frames; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index be8707b41f..3c51866948 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -169,15 +169,15 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::loadFile(const char *Filename, bool ClearOld) { +HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { Game->LOG(0, "Loading string table..."); if (ClearOld) _strings.clear(); uint32 Size; - byte *Buffer = Game->_fileManager->readWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->readWholeFile(filename, &Size); if (Buffer == NULL) { - Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); return E_FAIL; } diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index 7a6177098c..ea35cf817b 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -38,7 +38,7 @@ namespace WinterMute { class CBStringTable : public CBBase { public: const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT loadFile(const char *Filename, bool DeleteAll = true); + HRESULT loadFile(const char *filename, bool DeleteAll = true); void Expand(char **Str, bool ForceExpand = false); HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); CBStringTable(CBGame *inGame); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 5a46237239..ac7ecc8b20 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -368,8 +368,8 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t _surfaceFilename = NULL; stack->pushBool(true); } else { - const char *Filename = Val->getString(); - if (SUCCEEDED(setSurface(Filename))) { + const char *filename = Val->getString(); + if (SUCCEEDED(setSurface(filename))) { setDefaultRect(); stack->pushBool(true); } else stack->pushBool(false); @@ -549,7 +549,7 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::setSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::setSurface(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { if (_surface) { Game->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -558,10 +558,10 @@ HRESULT CBSubFrame::setSurface(const char *Filename, bool default_ck, byte ck_re delete[] _surfaceFilename; _surfaceFilename = NULL; - _surface = Game->_surfaceStorage->addSurface(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + _surface = Game->_surfaceStorage->addSurface(filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); if (_surface) { - _surfaceFilename = new char[strlen(Filename) + 1]; - strcpy(_surfaceFilename, Filename); + _surfaceFilename = new char[strlen(filename) + 1]; + strcpy(_surfaceFilename, filename); _cKDefault = default_ck; _cKRed = ck_red; diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 25fce16159..a54dedefb0 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -41,7 +41,7 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - HRESULT setSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT setSurface(const char *filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); HRESULT setSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void setDefaultRect(); diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 2e745b8ed4..2bfba077ce 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -61,7 +61,7 @@ public: virtual HRESULT displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual HRESULT restore(); - virtual HRESULT create(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; + virtual HRESULT create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; virtual HRESULT create(int Width, int Height); virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return E_FAIL; @@ -72,7 +72,7 @@ public: virtual HRESULT startPixelOp(); virtual HRESULT endPixelOp(); virtual bool isTransparentAtLite(int x, int y); - void setFilename(const char *Filename); + void setFilename(const char *filename); void setSize(int width, int height); int _referenceCount; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 53fd036d49..2e98e494b1 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -97,16 +97,16 @@ HRESULT CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *Filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { for (int i = 0; i < _surfaces.GetSize(); i++) { - if (scumm_stricmp(_surfaces[i]->_filename, Filename) == 0) { + if (scumm_stricmp(_surfaces[i]->_filename, filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; } } - if (!Game->_fileManager->hasFile(Filename)) { - if (Filename) Game->LOG(0, "Missing image: '%s'", Filename); + if (!Game->_fileManager->hasFile(filename)) { + if (filename) Game->LOG(0, "Missing image: '%s'", filename); if (Game->_dEBUG_DebugMode) return addSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); else @@ -118,7 +118,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *Filename, bool default_ck, b if (!surface) return NULL; - if (FAILED(surface->create(Filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { + if (FAILED(surface->create(filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { delete surface; return NULL; } else { diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index ac624e70d1..adeb87c50f 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -45,7 +45,7 @@ public: //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); HRESULT restoreAll(); - CBSurface *addSurface(const char *Filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool keepLoaded = false); + CBSurface *addSurface(const char *filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool keepLoaded = false); HRESULT removeSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index e38abb5005..b80d6b0b68 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -116,32 +116,32 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::addSprite(const char *Filename) { - if (!Filename) return E_FAIL; +HRESULT CPartEmitter::addSprite(const char *filename) { + if (!filename) return E_FAIL; // do we already have the file? for (int i = 0; i < _sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, _sprites[i]) == 0) return S_OK; + if (scumm_stricmp(filename, _sprites[i]) == 0) return S_OK; } // check if file exists - Common::SeekableReadStream *File = Game->_fileManager->openFile(Filename); + Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); if (!File) { - Game->LOG(0, "Sprite '%s' not found", Filename); + Game->LOG(0, "Sprite '%s' not found", filename); return E_FAIL; } else Game->_fileManager->closeFile(File); - char *Str = new char[strlen(Filename) + 1]; - strcpy(Str, Filename); + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); _sprites.Add(Str); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::removeSprite(const char *Filename) { +HRESULT CPartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.GetSize(); i++) { - if (scumm_stricmp(Filename, _sprites[i]) == 0) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; _sprites.RemoveAt(i); return S_OK; diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 7464173eb3..b088ee3920 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -107,8 +107,8 @@ public: HRESULT display(CBRegion *Region); HRESULT sortParticlesByZ(); - HRESULT addSprite(const char *Filename); - HRESULT removeSprite(const char *Filename); + HRESULT addSprite(const char *filename); + HRESULT removeSprite(const char *filename); HRESULT setBorder(int X, int Y, int Width, int Height); HRESULT setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 9c938ac835..236481aec2 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -72,8 +72,8 @@ CPartParticle::~CPartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::setSprite(const char *Filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(Filename, _sprite->_filename) == 0) { +HRESULT CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { _sprite->Reset(); return S_OK; } @@ -83,7 +83,7 @@ HRESULT CPartParticle::setSprite(const char *Filename) { CSysClassRegistry::getInstance()->_disabled = true; _sprite = new CBSprite(Game, Game); - if (_sprite && SUCCEEDED(_sprite->loadFile(Filename))) { + if (_sprite && SUCCEEDED(_sprite->loadFile(filename))) { CSysClassRegistry::getInstance()->_disabled = false; return S_OK; } else { @@ -240,13 +240,13 @@ HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving) { persistMgr->transfer(TMEMBER(_sprite->_filename)); } else { - char *Filename; - persistMgr->transfer(TMEMBER(Filename)); + char *filename; + persistMgr->transfer(TMEMBER(filename)); CSysClassRegistry::getInstance()->_disabled = true; - setSprite(Filename); + setSprite(filename); CSysClassRegistry::getInstance()->_disabled = false; - delete[] Filename; - Filename = NULL; + delete[] filename; + filename = NULL; } return S_OK; diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 9edc999426..e20413726a 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -71,7 +71,7 @@ public: HRESULT update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); HRESULT display(CPartEmitter *Emitter); - HRESULT setSprite(const char *Filename); + HRESULT setSprite(const char *filename); HRESULT fadeIn(uint32 CurrentTime, int FadeTime); HRESULT fadeOut(uint32 CurrentTime, int FadeTime); diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 5f70f7636f..b64efe9ab6 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -70,7 +70,7 @@ HRESULT CBSaveThumbFile::open(const Common::String &filename) { delete [] tempFilename; char slotFilename[MAX_PATH + 1]; - Game->GetSaveSlotFilename(slot, slotFilename); + Game->getSaveSlotFilename(slot, slotFilename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return E_FAIL; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index e31afde2e9..dab7786e66 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -111,9 +111,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFilename") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); cleanup(); - CBUtils::setString(&_filename, Filename); + CBUtils::setString(&_filename, filename); stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index b0fb447e17..c9c62e5dbe 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -189,9 +189,9 @@ HRESULT CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// -byte *WINAPI CScEngine::loadFile(void *Data, char *Filename, uint32 *Size) { - CBGame *Game = (CBGame *)Data; - return Game->_fileManager->readWholeFile(Filename, Size); +byte *WINAPI CScEngine::loadFile(void *data, char *filename, uint32 *size) { + CBGame *Game = (CBGame *)data; + return Game->_fileManager->readWholeFile(filename, size); } @@ -232,32 +232,32 @@ void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *Elemen ////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { - byte *CompBuffer; - uint32 CompSize; +CScScript *CScEngine::RunScript(const char *filename, CBScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; // get script from cache - CompBuffer = GetCompiledScript(Filename, &CompSize); - if (!CompBuffer) return NULL; + compBuffer = GetCompiledScript(filename, &compSize); + if (!compBuffer) return NULL; // add new script CScScript *script = new CScScript(Game, this); - HRESULT ret = script->Create(Filename, CompBuffer, CompSize, Owner); + HRESULT ret = script->Create(filename, compBuffer, compSize, owner); if (FAILED(ret)) { - Game->LOG(ret, "Error running script '%s'...", Filename); + Game->LOG(ret, "Error running script '%s'...", filename); delete script; return NULL; } else { // publish the "self" pseudo-variable CScValue val(Game); - if (Owner)val.setNative(Owner, true); + if (owner)val.setNative(owner, true); else val.setNULL(); script->_globals->setProp("self", &val); script->_globals->setProp("this", &val); _scripts.Add(script); - Game->getDebugMgr()->OnScriptInit(script); + Game->getDebugMgr()->onScriptInit(script); return script; } @@ -265,13 +265,13 @@ CScScript *CScEngine::RunScript(const char *Filename, CBScriptHolder *Owner) { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache) { +byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool IgnoreCache) { int i; // is script in cache? if (!IgnoreCache) { for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), Filename) == 0) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); *OutSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; @@ -286,9 +286,9 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I uint32 Size; - byte *Buffer = Game->_fileManager->readWholeFile(Filename, &Size); + byte *Buffer = Game->_fileManager->readWholeFile(filename, &Size); if (!Buffer) { - Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", Filename); + Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; } @@ -298,7 +298,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I CompSize = Size; } else { if (!_compilerAvailable) { - Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", Filename); + Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); delete [] Buffer; return NULL; } @@ -317,10 +317,10 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I Game->PublishNatives(); // We have const char* everywhere but in the DLL-interfaces... - char *tempFileName = new char[strlen(Filename) + 1]; - memcpy(tempFileName, Filename, strlen(Filename) + 1); + char *tempFileName = new char[strlen(filename) + 1]; + memcpy(tempFileName, filename, strlen(filename) + 1); - SetFileToCompile(Filename); + SetFileToCompile(filename); CompBuffer = ExtCompileFile(tempFileName, &CompSize); delete[] tempFileName; if (!CompBuffer) { @@ -333,7 +333,7 @@ byte *CScEngine::GetCompiledScript(const char *Filename, uint32 *OutSize, bool I byte *ret = NULL; // add script to cache - CScCachedScript *CachedScript = new CScCachedScript(Filename, CompBuffer, CompSize); + CScCachedScript *CachedScript = new CScCachedScript(filename, CompBuffer, CompSize); if (CachedScript) { int index = 0; uint32 MinTime = CBPlatform::GetTime(); @@ -389,7 +389,7 @@ HRESULT CScEngine::Tick() { } if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ - if (Game->ValidObject(_scripts[i]->_waitObject)) { + if (Game->validObject(_scripts[i]->_waitObject)) { if (_scripts[i]->_waitObject->isReady()) _scripts[i]->Run(); } else _scripts[i]->finish(); break; @@ -490,7 +490,7 @@ HRESULT CScEngine::RemoveFinishedScripts() { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - Game->getDebugMgr()->OnScriptShutdown(_scripts[i]); + Game->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.RemoveAt(i); i--; @@ -615,11 +615,11 @@ HRESULT CScEngine::ResumeAll() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SetFileToCompile(const char *Filename) { +HRESULT CScEngine::SetFileToCompile(const char *filename) { delete[] _fileToCompile; - _fileToCompile = new char[strlen(Filename) + 1]; + _fileToCompile = new char[strlen(filename) + 1]; if (_fileToCompile) { - strcpy(_fileToCompile, Filename); + strcpy(_fileToCompile, filename); return S_OK; } else return E_FAIL; } @@ -801,10 +801,10 @@ HRESULT CScEngine::LoadBreakpoints() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::AddScriptTime(const char *Filename, uint32 Time) { +void CScEngine::AddScriptTime(const char *filename, uint32 Time) { if (!_isProfiling) return; - AnsiString fileName = Filename; + AnsiString fileName = filename; StringUtil::toLowerCase(fileName); _scriptTimes[fileName] += Time; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 703034964e..42440c8a2d 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -57,12 +57,12 @@ class CScEngine : public CBBase { public: class CScCachedScript { public: - CScCachedScript(const char *Filename, byte *Buffer, uint32 Size) { + CScCachedScript(const char *filename, byte *Buffer, uint32 Size) { _timestamp = CBPlatform::GetTime(); _buffer = new byte[Size]; if (_buffer) memcpy(_buffer, Buffer, Size); _size = Size; - _filename = Filename; + _filename = filename; }; ~CScCachedScript() { @@ -77,8 +77,8 @@ public: class CScBreakpoint { public: - CScBreakpoint(const char *Filename) { - _filename = Filename; + CScBreakpoint(const char *filename) { + _filename = filename; } ~CScBreakpoint() { @@ -116,7 +116,7 @@ public: PARSE_ELEMENT_CALLBACK _parseElementCallback; void *_parseElementCallbackData; - HRESULT SetFileToCompile(const char *Filename); + HRESULT SetFileToCompile(const char *filename); char *_fileToCompile; CScScript *_currentScript; HRESULT ResumeAll(); @@ -125,13 +125,13 @@ public: HRESULT ResetObject(CBObject *Object); HRESULT ResetScript(CScScript *script); HRESULT EmptyScriptCache(); - byte *GetCompiledScript(const char *Filename, uint32 *OutSize, bool IgnoreCache = false); + byte *GetCompiledScript(const char *filename, uint32 *OutSize, bool IgnoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) HRESULT cleanup(); int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); HRESULT Tick(); CScValue *_globals; - CScScript *RunScript(const char *Filename, CBScriptHolder *Owner = NULL); + CScScript *RunScript(const char *filename, CBScriptHolder *Owner = NULL); bool _compilerAvailable; HINSTANCE _compilerDLL; CScEngine(CBGame *inGame); @@ -155,7 +155,7 @@ public: return _isProfiling; } - void AddScriptTime(const char *Filename, uint32 Time); + void AddScriptTime(const char *filename, uint32 Time); void DumpStats(); private: diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index f255d2aa8a..ddb862460b 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -240,7 +240,7 @@ HRESULT CScScript::InitTables() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { +HRESULT CScScript::Create(const char *filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { cleanup(); _thread = false; @@ -249,8 +249,8 @@ HRESULT CScScript::Create(const char *Filename, byte *Buffer, uint32 Size, CBScr delete[] _threadEvent; _threadEvent = NULL; - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); _buffer = new byte [Size]; if (!_buffer) return E_FAIL; @@ -491,11 +491,11 @@ HRESULT CScScript::ExecuteInstruction() { if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); } break; @@ -510,20 +510,20 @@ HRESULT CScScript::ExecuteInstruction() { _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->OnVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + Game->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); } break; } case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->getDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); + Game->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - if (_scopeStack->_sP < 0) Game->getDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->getDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL); + else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -640,8 +640,8 @@ HRESULT CScScript::ExecuteInstruction() { _operand->setNULL(); _scopeStack->push(_operand); - if (_scopeStack->_sP < 0) Game->getDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->getDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL); + else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); break; @@ -692,7 +692,7 @@ HRESULT CScScript::ExecuteInstruction() { } if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->OnVariableChangeValue(var, val); + Game->getDebugMgr()->onVariableChangeValue(var, val); } break; @@ -758,7 +758,7 @@ HRESULT CScScript::ExecuteInstruction() { } else var->setProp(str, val); if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->OnVariableChangeValue(var, NULL); + Game->getDebugMgr()->onVariableChangeValue(var, NULL); break; } @@ -1023,16 +1023,16 @@ HRESULT CScScript::ExecuteInstruction() { if (NewLine != _currentLine) { _currentLine = NewLine; if (Game->getDebugMgr()->_enabled) { - Game->getDebugMgr()->OnScriptChangeLine(this, _currentLine); + Game->getDebugMgr()->onScriptChangeLine(this, _currentLine); for (int i = 0; i < _breakpoints.GetSize(); i++) { if (_breakpoints[i] == _currentLine) { - Game->getDebugMgr()->OnScriptHitBreakpoint(this); + Game->getDebugMgr()->onScriptHitBreakpoint(this); Sleep(0); break; } } if (_tracingMode) { - Game->getDebugMgr()->OnScriptHitBreakpoint(this); + Game->getDebugMgr()->onScriptHitBreakpoint(this); Sleep(0); break; } @@ -1259,7 +1259,7 @@ CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable if (SUCCEEDED(ret)) { thread->_unbreakable = Unbreakable; _engine->_scripts.Add(thread); - Game->getDebugMgr()->OnScriptEventThreadInit(thread, this, EventName); + Game->getDebugMgr()->onScriptEventThreadInit(thread, this, EventName); return thread; } else { delete thread; diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 308c6d9a86..812ce0359f 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -141,7 +141,7 @@ public: uint32 GetDWORD(); double GetFloat(); void cleanup(); - HRESULT Create(const char *Filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); + HRESULT Create(const char *filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); uint32 _iP; private: void readHeader(); diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 5f373498aa..ff839bb637 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -54,27 +54,27 @@ void CBPlatform::HandleEvent(Common::Event *event) { case Common::EVENT_LBUTTONDOWN: if (Game) { - if (Game->isLeftDoubleClick()) Game->OnMouseLeftDblClick(); - else Game->OnMouseLeftDown(); + if (Game->isLeftDoubleClick()) Game->onMouseLeftDblClick(); + else Game->onMouseLeftDown(); } break; case Common::EVENT_RBUTTONDOWN: if (Game) { - if (Game->isRightDoubleClick()) Game->OnMouseRightDblClick(); - else Game->OnMouseRightDown(); + if (Game->isRightDoubleClick()) Game->onMouseRightDblClick(); + else Game->onMouseRightDown(); } break; case Common::EVENT_MBUTTONDOWN: - if (Game) Game->OnMouseMiddleDown(); + if (Game) Game->onMouseMiddleDown(); break; case Common::EVENT_LBUTTONUP: - if (Game) Game->OnMouseLeftUp(); + if (Game) Game->onMouseLeftUp(); break; case Common::EVENT_RBUTTONUP: - if (Game) Game->OnMouseRightUp(); + if (Game) Game->onMouseRightUp(); break; case Common::EVENT_MBUTTONUP: - if (Game) Game->OnMouseMiddleUp(); + if (Game) Game->onMouseMiddleUp(); break; case Common::EVENT_KEYDOWN: if (Game) Game->handleKeypress(event); @@ -139,7 +139,7 @@ void CBPlatform::HandleEvent(Common::Event *event) { Game->_quitting = true; } #else - if (Game) Game->OnWindowClose(); + if (Game) Game->onWindowClose(); #endif break; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 540008571f..340c22edda 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -179,7 +179,7 @@ HRESULT CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, boo if (!quickSave) { Game->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); - Game->DisplayContent(false); + Game->displayContent(false); Game->_renderer->flip(); } @@ -211,7 +211,7 @@ HRESULT CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { for (uint32 i = 0; i < numClasses; i++) { Game->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); - Game->DisplayContentSimple(); + Game->displayContentSimple(); Game->_renderer->flip(); Common::String className = persistMgr->getStringObj(); @@ -245,7 +245,7 @@ HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, if (!quickSave) { if (counter % 20 == 0) { Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); - Game->DisplayContent(false); + Game->displayContent(false); Game->_renderer->flip(); } } @@ -265,7 +265,7 @@ HRESULT CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); - Game->DisplayContentSimple(); + Game->displayContentSimple(); Game->_renderer->flip(); } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 69809874bf..dffb9532da 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -95,19 +95,19 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUIButton::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); delete [] Buffer; @@ -747,8 +747,8 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageDisable; _imageDisable = new CBSprite(Game); - const char *Filename = stack->pop()->getString(); - if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) { + const char *filename = stack->pop()->getString(); + if (!_imageDisable || FAILED(_imageDisable->loadFile(filename))) { delete _imageDisable; _imageDisable = NULL; stack->pushBool(false); @@ -788,8 +788,8 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageHover; _imageHover = new CBSprite(Game); - const char *Filename = stack->pop()->getString(); - if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) { + const char *filename = stack->pop()->getString(); + if (!_imageHover || FAILED(_imageHover->loadFile(filename))) { delete _imageHover; _imageHover = NULL; stack->pushBool(false); @@ -828,8 +828,8 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imagePress; _imagePress = new CBSprite(Game); - const char *Filename = stack->pop()->getString(); - if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) { + const char *filename = stack->pop()->getString(); + if (!_imagePress || FAILED(_imagePress->loadFile(filename))) { delete _imagePress; _imagePress = NULL; stack->pushBool(false); @@ -868,8 +868,8 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageFocus; _imageFocus = new CBSprite(Game); - const char *Filename = stack->pop()->getString(); - if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) { + const char *filename = stack->pop()->getString(); + if (!_imageFocus || FAILED(_imageFocus->loadFile(filename))) { delete _imageFocus; _imageFocus = NULL; stack->pushBool(false); diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index e89c37aa0c..856afc5be0 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -63,7 +63,7 @@ public: CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index d87eeea630..87d70c8f88 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -94,19 +94,19 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUIEdit::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 2ee2d3ea3a..0db087e4df 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -56,7 +56,7 @@ public: CUIEdit(CBGame *inGame); virtual ~CUIEdit(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index a2b065dd3d..a396ae0560 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -49,25 +49,25 @@ CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIEntity::~CUIEntity() { - if (_entity) Game->UnregisterObject(_entity); + if (_entity) Game->unregisterObject(_entity); _entity = NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUIEntity::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); delete [] Buffer; @@ -209,7 +209,7 @@ HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::setEntity(const char *filename) { - if (_entity) Game->UnregisterObject(_entity); + if (_entity) Game->unregisterObject(_entity); _entity = new CAdEntity(Game); if (!_entity || FAILED(_entity->loadFile(filename))) { delete _entity; @@ -219,7 +219,7 @@ HRESULT CUIEntity::setEntity(const char *filename) { _entity->_nonIntMouseEvents = true; _entity->_sceneIndependent = true; _entity->makeFreezable(false); - Game->RegisterObject(_entity); + Game->registerObject(_entity); } return S_OK; } @@ -270,9 +270,9 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "SetEntity") == 0) { stack->correctParams(1); - const char *Filename = stack->pop()->getString(); + const char *filename = stack->pop()->getString(); - if (SUCCEEDED(setEntity(Filename))) + if (SUCCEEDED(setEntity(filename))) stack->pushBool(true); else stack->pushBool(false); diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 670973fdeb..8722ac304b 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -38,13 +38,13 @@ public: DECLARE_PERSISTENT(CUIEntity, CUIObject) CUIEntity(CBGame *inGame); virtual ~CUIEntity(); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; - HRESULT setEntity(const char *Filename); + HRESULT setEntity(const char *filename); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 7a3cd3e8a0..26d903990d 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -163,7 +163,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - /* const char *Filename = */ Val->getString(); + /* const char *filename = */ Val->getString(); delete _image; _image = NULL; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 0d7966188e..afb6a6976c 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -95,19 +95,19 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUIText::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUIText::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 1f5029e4a6..5ef3c85df9 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -43,7 +43,7 @@ public: virtual ~CUIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index e7734acdc5..d0f9cdb0f2 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -119,19 +119,19 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUITiledImage::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); delete [] Buffer; diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index d571f1354f..16712746c5 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -38,7 +38,7 @@ class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void correctSize(int *Width, int *Height); - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 5ed33ffd7a..fd36971847 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -200,19 +200,19 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::loadFile(const char *Filename) { - byte *Buffer = Game->_fileManager->readWholeFile(Filename); +HRESULT CUIWindow::loadFile(const char *filename) { + byte *Buffer = Game->_fileManager->readWholeFile(filename); if (Buffer == NULL) { - Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", Filename); + Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - _filename = new char [strlen(Filename) + 1]; - strcpy(_filename, Filename); + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", Filename); + if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); delete [] Buffer; @@ -538,7 +538,7 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { default: - if (FAILED(Game->WindowLoadHook(this, (char **)&Buffer, (char **)params))) { + if (FAILED(Game->windowLoadHook(this, (char **)&Buffer, (char **)params))) { cmd = PARSERR_GENERIC; } } @@ -735,8 +735,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageInactive; _imageInactive = new CBSprite(Game); - const char *Filename = stack->pop()->getString(); - if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) { + const char *filename = stack->pop()->getString(); + if (!_imageInactive || FAILED(_imageInactive->loadFile(filename))) { delete _imageInactive; _imageInactive = NULL; stack->pushBool(false); @@ -910,7 +910,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } stack->pushNULL(); return S_OK; - } else if SUCCEEDED(Game->WindowScriptMethodHook(this, script, stack, name)) return S_OK; + } else if SUCCEEDED(Game->windowScriptMethodHook(this, script, stack, name)) return S_OK; else return CUIObject::scCallMethod(script, stack, thisStack, name); } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 80dcda9333..c29038860d 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -73,7 +73,7 @@ public: virtual bool handleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; - HRESULT loadFile(const char *Filename); + HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 219cacd249..ed6c2f3bc5 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -56,8 +56,8 @@ public: static bool matchesPattern(const char *pattern, const char *string); - static char *getPath(const char *Filename); - static char *getFilename(const char *Filename); + static char *getPath(const char *filename); + static char *getFilename(const char *filename); static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); static uint32 HSLtoRGB(byte H, byte S, byte L); diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index e511f52284..1e4b25e143 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -129,17 +129,17 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) cleanup(); char Filename[MAX_PATH]; - Game->_fileManager->GetFullPath(inFilename, Filename); + Game->_fileManager->GetFullPath(inFilename, filename); // open file if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - Game->LOG(0, "Error opening AVI file '%s'", Filename); + Game->LOG(0, "Error opening AVI file '%s'", filename); return E_FAIL; } // get video stream if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - Game->LOG(0, "Error finding video stream in AVI file '%s'", Filename); + Game->LOG(0, "Error finding video stream in AVI file '%s'", filename); return E_FAIL; } _totalVideoTime = AVIStreamEndTime(_videoStream); @@ -155,7 +155,7 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) // get video format if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", Filename); + Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); return E_FAIL; } _videoFormat = (LPBITMAPINFO)new BYTE[Size]; @@ -176,7 +176,7 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) m_VidRenderer = new CVidRendererDD(Game); if (!m_VidRenderer || FAILED(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - Game->LOG(0, "Error initializing video renderer for AVI file '%s'", Filename); + Game->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); SAFE_DELETE(m_VidRenderer); return E_FAIL; } @@ -190,14 +190,14 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) if (FAILED(res = _sound->InitializeBuffer(_audioStream))) { SAFE_DELETE(_sound); _soundAvailable = false; - Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", Filename); + Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); } } if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); - _filename = new char[strlen(Filename) + 1]; - if (_filename) strcpy(_filename, Filename); + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); #endif return S_OK; } @@ -378,7 +378,7 @@ bool CVidPlayer::isPlaying() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::loadSubtitles(const char *Filename, const char *SubtitleFile) { +HRESULT CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { #if 0 if (!Filename) return S_OK; @@ -390,7 +390,7 @@ HRESULT CVidPlayer::loadSubtitles(const char *Filename, const char *SubtitleFile if (SubtitleFile) { strcpy(NewFile, SubtitleFile); } else { - _splitpath(Filename, drive, dir, fname, NULL); + _splitpath(filename, drive, dir, fname, NULL); _makepath(NewFile, drive, dir, fname, ".SUB"); } diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index f3dfa97e33..b1afa080bd 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -46,7 +46,7 @@ class CVidPlayer : public CBBase { public: bool _showSubtitle; int _currentSubtitle; - HRESULT loadSubtitles(const char *Filename, const char *SubtitleFile); + HRESULT loadSubtitles(const char *filename, const char *SubtitleFile); bool _slowRendering; bool isPlaying(); char *_filename; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d47f3b3ae5..b8a9886105 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -140,7 +140,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _file = Game->_fileManager->openFile(filename, true, false); if (!_file) return E_FAIL; - //if (Filename != _filename) CBUtils::setString(&_filename, Filename); + //if (Filename != _filename) CBUtils::setString(&_filename, filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else @@ -164,10 +164,10 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo #if 0 cleanup(); - _file = Game->_fileManager->openFile(Filename); + _file = Game->_fileManager->openFile(filename); if (!_file) return E_FAIL; - if (Filename != _filename) CBUtils::setString(&_filename, Filename); + if (Filename != _filename) CBUtils::setString(&_filename, filename); // start up Ogg stream synchronization layer ogg_sync_init(&m_OggSyncState); @@ -303,7 +303,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo if (FAILED(Res = m_Sound->InitializeBuffer(this))) { Game->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; - Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", Filename); + Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); } else { SAFE_DELETE_ARRAY(m_AudioBuf); m_AudioBufSize = m_Sound->m_StreamBlockSize; @@ -325,7 +325,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(Filename, SubtitleFile); + if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); return Res; #endif @@ -686,12 +686,12 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); - if (!m_AlphaImage || FAILED(m_AlphaImage->loadFile(Filename))) { + if (!m_AlphaImage || FAILED(m_AlphaImage->loadFile(filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); return E_FAIL; } - if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, Filename); + if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, filename); m_AlphaImage->Convert(IMG_TRUECOLOR); #endif return S_OK; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 031b081075..cc472d32da 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -200,7 +200,7 @@ int WinterMuteEngine::init() { _game->initialize2(); - _game->getDebugMgr()->OnGameInit(); + _game->getDebugMgr()->onGameInit(); _game->_scEngine->LoadBreakpoints(); @@ -239,7 +239,7 @@ int WinterMuteEngine::init() { _game = NULL; return false; } - _game->SetWindowTitle(); + _game->setWindowTitle(); _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; @@ -249,11 +249,11 @@ int WinterMuteEngine::init() { if (ConfMan.hasKey("save_slot")) { int slot = ConfMan.getInt("save_slot"); Common::String str = Common::String::format("save00%d.DirtySplitSav", slot); - _game->LoadGame(str.c_str()); + _game->loadGame(str.c_str()); } if (SaveGame) { - _game->LoadGame(SaveGame); + _game->loadGame(SaveGame); delete [] SaveGame; } @@ -277,10 +277,10 @@ int WinterMuteEngine::messageLoop() { } if (_game && _game->_renderer->_active && _game->_renderer->_ready) { - _game->DisplayContent(); - _game->DisplayQuickMsg(); + _game->displayContent(); + _game->displayQuickMsg(); - _game->DisplayDebugInfo(); + _game->displayDebugInfo(); time = _system->getMillis(); diff = time - prevTime; @@ -289,7 +289,7 @@ int WinterMuteEngine::messageLoop() { // ***** flip if (!_game->_suspendedRendering) _game->_renderer->flip(); - if (_game->_loading) _game->LoadGame(_game->_scheduledLoadSlot); + if (_game->_loading) _game->loadGame(_game->_scheduledLoadSlot); prevTime = time; } if (_game->_quitting) break; -- cgit v1.2.3 From be4ceeb44e455882a33dd81a76dc91d3a378dbfb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 13:18:05 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in AdInventory --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdInventory.cpp | 18 +++++++++--------- engines/wintermute/Ad/AdInventory.h | 6 +++--- engines/wintermute/Ad/AdObject.cpp | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 969a03456d..fabeda7dea 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1847,7 +1847,7 @@ HRESULT CAdGame::deleteItem(CAdItem *item) { // remove from all inventories for (int i = 0; i < _inventories.GetSize(); i++) { - _inventories[i]->RemoveItem(item); + _inventories[i]->removeItem(item); } // remove object diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index a453343a56..6260e23778 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -49,32 +49,32 @@ CAdInventory::~CAdInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::InsertItem(const char *name, const char *InsertAfter) { +HRESULT CAdInventory::insertItem(const char *name, const char *insertAfter) { if (name == NULL) return E_FAIL; CAdItem *item = ((CAdGame *)Game)->getItemByName(name); if (item == NULL) return E_FAIL; - int InsertIndex = -1; + int insertIndex = -1; for (int i = 0; i < _takenItems.GetSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { _takenItems.RemoveAt(i); i--; continue; } - if (InsertAfter && scumm_stricmp(_takenItems[i]->_name, InsertAfter) == 0) InsertIndex = i + 1; + if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; } - if (InsertIndex == -1) _takenItems.Add(item); - else _takenItems.InsertAt(InsertIndex, item); + if (insertIndex == -1) _takenItems.Add(item); + else _takenItems.InsertAt(insertIndex, item); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(const char *name) { +HRESULT CAdInventory::removeItem(const char *name) { if (name == NULL) return E_FAIL; for (int i = 0; i < _takenItems.GetSize(); i++) { @@ -91,11 +91,11 @@ HRESULT CAdInventory::RemoveItem(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::RemoveItem(CAdItem *Item) { - if (Item == NULL) return E_FAIL; +HRESULT CAdInventory::removeItem(CAdItem *item) { + if (item == NULL) return E_FAIL; for (int i = 0; i < _takenItems.GetSize(); i++) { - if (_takenItems[i] == Item) { + if (_takenItems[i] == item) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; _takenItems.RemoveAt(i); return S_OK; diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h index f372fec6e9..6ba48a59c9 100644 --- a/engines/wintermute/Ad/AdInventory.h +++ b/engines/wintermute/Ad/AdInventory.h @@ -38,9 +38,9 @@ class CAdItem; class CAdInventory : public CBObject { public: DECLARE_PERSISTENT(CAdInventory, CBObject) - HRESULT RemoveItem(const char *name); - HRESULT RemoveItem(CAdItem *Item); - HRESULT InsertItem(const char *name, const char *InsertAfter = NULL); + HRESULT removeItem(const char *name); + HRESULT removeItem(CAdItem *Item); + HRESULT insertItem(const char *name, const char *insertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); CBArray _takenItems; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index d59e575d8e..5068bdf5dc 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -360,7 +360,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *ItemName = val->getString(); val = stack->pop(); const char *InsertAfter = val->isNULL() ? NULL : val->getString(); - if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + if (FAILED(_inventory->insertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); else { // hide associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(ItemName, false); @@ -385,7 +385,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (!val->isNULL()) { - if (FAILED(_inventory->RemoveItem(val->getString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->getString()); + if (FAILED(_inventory->removeItem(val->getString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true); -- cgit v1.2.3 From 3f22d4372f2846d64b3801a892c8873e9811f5d5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 19:23:41 +0200 Subject: WINTERMUTE: Mass rename VarName/FuncName -> varName/funcName alphabetically up until AdScene --- engines/wintermute/Ad/AdActor.cpp | 42 +-- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 10 +- engines/wintermute/Ad/AdInventoryBox.cpp | 62 ++--- engines/wintermute/Ad/AdInventoryBox.h | 4 +- engines/wintermute/Ad/AdItem.cpp | 62 ++--- engines/wintermute/Ad/AdItem.h | 6 +- engines/wintermute/Ad/AdLayer.cpp | 123 +++++---- engines/wintermute/Ad/AdLayer.h | 4 +- engines/wintermute/Ad/AdNodeState.cpp | 64 ++--- engines/wintermute/Ad/AdNodeState.h | 8 +- engines/wintermute/Ad/AdObject.cpp | 316 +++++++++++------------ engines/wintermute/Ad/AdObject.h | 4 +- engines/wintermute/Ad/AdPath.cpp | 14 +- engines/wintermute/Ad/AdPath.h | 12 +- engines/wintermute/Ad/AdRegion.cpp | 50 ++-- engines/wintermute/Ad/AdRegion.h | 4 +- engines/wintermute/Ad/AdResponse.cpp | 22 +- engines/wintermute/Ad/AdResponse.h | 10 +- engines/wintermute/Ad/AdResponseBox.cpp | 130 +++++----- engines/wintermute/Ad/AdResponseBox.h | 14 +- engines/wintermute/Ad/AdResponseContext.cpp | 8 +- engines/wintermute/Ad/AdResponseContext.h | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 30 +-- engines/wintermute/Ad/AdRotLevel.h | 4 +- engines/wintermute/Ad/AdScaleLevel.cpp | 30 +-- engines/wintermute/Ad/AdScaleLevel.h | 4 +- engines/wintermute/Ad/AdScene.cpp | 258 +++++++++--------- engines/wintermute/Ad/AdScene.h | 4 +- engines/wintermute/Ad/AdSpriteSet.cpp | 8 +- engines/wintermute/Ad/AdTalkDef.cpp | 18 +- engines/wintermute/Ad/AdTalkNode.cpp | 36 +-- engines/wintermute/Ad/AdWaypointGroup.cpp | 36 +-- engines/wintermute/Ad/AdWaypointGroup.h | 4 +- engines/wintermute/Base/BBase.cpp | 26 +- engines/wintermute/Base/BFont.cpp | 8 +- engines/wintermute/Base/BFontBitmap.cpp | 16 +- engines/wintermute/Base/BFontTT.cpp | 20 +- engines/wintermute/Base/BFrame.cpp | 26 +- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 8 +- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BRegion.cpp | 40 +-- engines/wintermute/Base/BRegion.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 14 +- engines/wintermute/Base/BSprite.cpp | 62 ++--- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BStringTable.cpp | 12 +- engines/wintermute/Base/BSubFrame.cpp | 36 +-- engines/wintermute/Base/scriptables/ScScript.cpp | 24 +- engines/wintermute/Base/scriptables/ScValue.h | 2 +- engines/wintermute/UI/UIButton.cpp | 106 ++++---- engines/wintermute/UI/UIButton.h | 4 +- engines/wintermute/UI/UIEdit.cpp | 74 +++--- engines/wintermute/UI/UIEdit.h | 4 +- engines/wintermute/UI/UIEntity.cpp | 48 ++-- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIObject.h | 2 +- engines/wintermute/UI/UIText.cpp | 78 +++--- engines/wintermute/UI/UIText.h | 4 +- engines/wintermute/UI/UITiledImage.cpp | 34 +-- engines/wintermute/UI/UITiledImage.h | 4 +- engines/wintermute/UI/UIWindow.cpp | 108 ++++---- engines/wintermute/UI/UIWindow.h | 4 +- 66 files changed, 1090 insertions(+), 1093 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 1af137e96f..04152db456 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -124,8 +124,8 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdActor::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -135,10 +135,10 @@ HRESULT CAdActor::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -235,7 +235,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { buffer = params; } - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; CAdSpriteSet *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -291,19 +291,19 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _walkSprite; _walkSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; else _walkSprite = spr; break; case TOKEN_TALK: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); break; case TOKEN_TALK_SPECIAL: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); break; @@ -311,7 +311,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _standSprite; _standSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, AdGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; else _standSprite = spr; break; @@ -490,8 +490,8 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { _afterWalkDir = afterWalkDir; if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; - _path->Reset(); - _path->SetReady(false); + _path->reset(); + _path->setReady(false); _targetPoint->x = x; _targetPoint->y = y; @@ -512,7 +512,7 @@ HRESULT CAdActor::display() { else alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; float scaleX, scaleY; - GetScale(&scaleX, &scaleY); + getScale(&scaleX, &scaleY); float rotate; @@ -749,16 +749,16 @@ HRESULT CAdActor::update() { ////////////////////////////////////////////////////////////////////////// void CAdActor::followPath() { // skip current position - _path->GetFirst(); - while (_path->GetCurrent() != NULL) { - if (_path->GetCurrent()->x != _posX || _path->GetCurrent()->y != _posY) break; - _path->GetNext(); + _path->getFirst(); + while (_path->getCurrent() != NULL) { + if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; + _path->getNext(); } // are there points to follow? - if (_path->GetCurrent() != NULL) { + if (_path->getCurrent() != NULL) { _state = STATE_FOLLOWING_PATH;; - initLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + initLine(CBPoint(_posX, _posY), *_path->getCurrent()); } else { if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); else _state = STATE_READY; @@ -814,17 +814,17 @@ void CAdActor::getNextStep() { if (_pFCount == 0) { - if (_path->GetNext() == NULL) { + if (_path->getNext() == NULL) { _posX = _targetPoint->x; _posY = _targetPoint->y; - _path->Reset(); + _path->reset(); if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); else { _state = _nextState; _nextState = STATE_READY; } - } else initLine(CBPoint(_posX, _posY), *_path->GetCurrent()); + } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); } } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 27509a529c..c4de591706 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -490,7 +490,7 @@ HRESULT CAdEntity::display() { else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); + getScale(&ScaleX, &ScaleY); float Rotate; if (_rotatable) { diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index fabeda7dea..c890033e18 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -474,12 +474,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CAdResponse *res = new CAdResponse(Game); if (res) { res->_iD = id; - res->SetText(text); + res->setText(text); _stringTable->Expand(&res->_text); - if (!val1->isNULL()) res->SetIcon(val1->getString()); - if (!val2->isNULL()) res->SetIconHover(val2->getString()); - if (!val3->isNULL()) res->SetIconPressed(val3->getString()); - if (!val4->isNULL()) res->SetFont(val4->getString()); + if (!val1->isNULL()) res->setIcon(val1->getString()); + if (!val2->isNULL()) res->setIconHover(val2->getString()); + if (!val3->isNULL()) res->setIconPressed(val3->getString()); + if (!val4->isNULL()) res->setFont(val4->getString()); if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 7af618e548..7ebcc4457f 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -98,7 +98,7 @@ HRESULT CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdInventoryBox::display() { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; if (!_visible) return S_OK; @@ -108,7 +108,7 @@ HRESULT CAdInventoryBox::display() { if (_window) { _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); + _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < adGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); } @@ -135,8 +135,8 @@ HRESULT CAdInventoryBox::display() { int xxx = rect.left; for (int i = 0; i < ItemsX; i++) { int ItemIndex = _scrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < AdGame->_inventoryOwner->getInventory()->_takenItems.GetSize()) { - CAdItem *item = AdGame->_inventoryOwner->getInventory()->_takenItems[ItemIndex]; + if (ItemIndex >= 0 && ItemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.GetSize()) { + CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[ItemIndex]; if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { item->update(); item->display(xxx, yyy); @@ -155,8 +155,8 @@ HRESULT CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdInventoryBox::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -166,10 +166,10 @@ HRESULT CAdInventoryBox::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -192,7 +192,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -216,15 +216,15 @@ HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { bool always_visible = false; _exclusive = false; - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { Game->LOG(0, "'INVENTORY_BOX' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -317,34 +317,34 @@ HRESULT CAdInventoryBox::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "INVENTORY_BOX\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "INVENTORY_BOX\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - Buffer->putTextIndent(Indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "SPACING=%d\n", _spacing); - Buffer->putTextIndent(Indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); - Buffer->putTextIndent(Indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); - Buffer->putTextIndent(Indent + 2, "SCROLL_BY=%d\n", _scrollBy); + buffer->putTextIndent(indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); + buffer->putTextIndent(indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + buffer->putTextIndent(indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + buffer->putTextIndent(indent + 2, "SCROLL_BY=%d\n", _scrollBy); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // window - if (_window) _window->saveAsText(Buffer, Indent + 2); + if (_window) _window->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index 903a3ff8e9..e05c001da8 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -54,8 +54,8 @@ public: CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 77e6aa5a4a..2ef7f0c200 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -85,8 +85,8 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdItem::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -96,10 +96,10 @@ HRESULT CAdItem::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -168,16 +168,16 @@ HRESULT CAdItem::loadBuffer(byte *Buffer, bool Complete) { int cmd = 2; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { Game->LOG(0, "'ITEM' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -386,38 +386,38 @@ HRESULT CAdItem::update() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::display(int X, int Y) { - int Width = 0; +HRESULT CAdItem::display(int x, int y) { + int width = 0; if (_currentSprite) { RECT rc; _currentSprite->GetBoundingRect(&rc, 0, 0); - Width = rc.right - rc.left; + width = rc.right - rc.left; } - _posX = X + Width / 2; - _posY = Y; + _posX = x + width / 2; + _posY = y; HRESULT ret; - if (_currentSprite) ret = _currentSprite->Draw(X, Y, this, 100, 100, _alphaColor); + if (_currentSprite) ret = _currentSprite->Draw(x, y, this, 100, 100, _alphaColor); else ret = S_OK; if (_displayAmount) { - int AmountX = X; - int AmountY = Y + _amountOffsetY; + int amountX = x; + int amountY = y + _amountOffsetY; if (_amountAlign == TAL_RIGHT) { - Width -= _amountOffsetX; - AmountX -= _amountOffsetX; + width -= _amountOffsetX; + amountX -= _amountOffsetX; } - AmountX += _amountOffsetX; + amountX += _amountOffsetX; - CBFont *Font = _font ? _font : Game->_systemFont; - if (Font) { - if (_amountString) Font->drawText((byte *)_amountString, AmountX, AmountY, Width, _amountAlign); + CBFont *font = _font ? _font : Game->_systemFont; + if (font) { + if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); else { char Str[256]; sprintf(Str, "%d", _amount); - Font->drawText((byte *)Str, AmountX, AmountY, Width, _amountAlign); + font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); } } } @@ -436,8 +436,8 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetHoverSprite") == 0) { stack->correctParams(1); - bool SetCurrent = false; - if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true; + bool setCurrent = false; + if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; const char *filename = stack->pop()->getString(); @@ -449,7 +449,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this script->RuntimeError("Item.SetHoverSprite failed for file '%s'", filename); } else { _spriteHover = spr; - if (SetCurrent) _currentSprite = _spriteHover; + if (setCurrent) _currentSprite = _spriteHover; stack->pushBool(true); } return S_OK; @@ -750,10 +750,10 @@ HRESULT CAdItem::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::getExtendedFlag(const char *FlagName) { - if (!FlagName) return false; - else if (strcmp(FlagName, "usable") == 0) return true; - else return CAdObject::getExtendedFlag(FlagName); +bool CAdItem::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; + else return CAdObject::getExtendedFlag(flagName); } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index 31460319e7..fa2e99fa5a 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -46,8 +46,8 @@ public: HRESULT update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - HRESULT display(int X, int Y); - bool getExtendedFlag(const char *FlagName); + HRESULT display(int x, int y); + bool getExtendedFlag(const char *flagName); bool _inInventory; bool _cursorCombined; CBSprite *_spriteHover; @@ -56,7 +56,7 @@ public: CAdItem(CBGame *inGame); virtual ~CAdItem(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 4329c7b36a..e71a31587c 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -62,8 +62,8 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdLayer::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -73,10 +73,9 @@ HRESULT CAdLayer::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); - - delete [] Buffer; + delete [] buffer; return ret; } @@ -100,7 +99,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -123,15 +122,15 @@ HRESULT CAdLayer::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { Game->LOG(0, "'LAYER' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -268,21 +267,21 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdSceneNode *Node = new CAdSceneNode(Game); + CAdSceneNode *node = new CAdSceneNode(Game); if (strcmp(name, "AddRegion") == 0) { - CAdRegion *Region = new CAdRegion(Game); - if (!Val->isNULL()) Region->setName(Val->getString()); - Node->setRegion(Region); - stack->pushNative(Region, true); + CAdRegion *region = new CAdRegion(Game); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); } else { - CAdEntity *Entity = new CAdEntity(Game); - if (!Val->isNULL()) Entity->setName(Val->getString()); - Node->setEntity(Entity); - stack->pushNative(Entity, true); + CAdEntity *entity = new CAdEntity(Game); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); } - _nodes.Add(Node); + _nodes.Add(node); return S_OK; } @@ -291,24 +290,24 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { stack->correctParams(2); - int Index = stack->pop()->getInt(); - CScValue *Val = stack->pop(); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); - CAdSceneNode *Node = new CAdSceneNode(Game); + CAdSceneNode *node = new CAdSceneNode(Game); if (strcmp(name, "InsertRegion") == 0) { - CAdRegion *Region = new CAdRegion(Game); - if (!Val->isNULL()) Region->setName(Val->getString()); - Node->setRegion(Region); - stack->pushNative(Region, true); + CAdRegion *region = new CAdRegion(Game); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); } else { - CAdEntity *Entity = new CAdEntity(Game); - if (!Val->isNULL()) Entity->setName(Val->getString()); - Node->setEntity(Entity); - stack->pushNative(Entity, true); + CAdEntity *entity = new CAdEntity(Game); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); } - if (Index < 0) Index = 0; - if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node); - else _nodes.Add(Node); + if (index < 0) index = 0; + if (index <= _nodes.GetSize() - 1) _nodes.InsertAt(index, node); + else _nodes.Add(node); return S_OK; } @@ -318,30 +317,30 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteNode") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdSceneNode *ToDelete = NULL; - if (Val->isNative()) { - CBScriptable *Temp = Val->getNative(); + CAdSceneNode *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); for (int i = 0; i < _nodes.GetSize(); i++) { - if (_nodes[i]->_region == Temp || _nodes[i]->_entity == Temp) { - ToDelete = _nodes[i]; + if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { + toDelete = _nodes[i]; break; } } } else { - int Index = Val->getInt(); - if (Index >= 0 && Index < _nodes.GetSize()) { - ToDelete = _nodes[Index]; + int index = val->getInt(); + if (index >= 0 && index < _nodes.GetSize()) { + toDelete = _nodes[index]; } } - if (ToDelete == NULL) { + if (toDelete == NULL) { stack->pushBool(false); return S_OK; } for (int i = 0; i < _nodes.GetSize(); i++) { - if (_nodes[i] == ToDelete) { + if (_nodes[i] == toDelete) { delete _nodes[i]; _nodes[i] = NULL; _nodes.RemoveAt(i); @@ -478,33 +477,33 @@ const char *CAdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "LAYER {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); +HRESULT CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "LAYER {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); if (_closeUp) - Buffer->putTextIndent(Indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); for (i = 0; i < _nodes.GetSize(); i++) { switch (_nodes[i]->_type) { case OBJECT_ENTITY: - _nodes[i]->_entity->saveAsText(Buffer, Indent + 2); + _nodes[i]->_entity->saveAsText(buffer, indent + 2); break; case OBJECT_REGION: - _nodes[i]->_region->saveAsText(Buffer, Indent + 2); + _nodes[i]->_region->saveAsText(buffer, indent + 2); break; default: error("CAdLayer::SaveAsText - Unhandled enum"); @@ -512,9 +511,9 @@ HRESULT CAdLayer::saveAsText(CBDynBuffer *Buffer, int Indent) { } } - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 0b8aa3958d..1090d253e1 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -43,8 +43,8 @@ public: virtual ~CAdLayer(); CBArray _nodes; HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 87f4e7d72f..266adc9378 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -84,7 +84,7 @@ void CAdNodeState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::SetCursor(const char *filename) { +void CAdNodeState::setCursor(const char *filename) { delete[] _cursor; _cursor = NULL; CBUtils::setString(&_cursor, filename); @@ -107,60 +107,60 @@ HRESULT CAdNodeState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCaption(const char *Caption, int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) return; - - delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(Caption) + 1]; - if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], Caption); - Game->_stringTable->Expand(&_caption[Case - 1]); +void CAdNodeState::setCaption(const char *caption, int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7) return; + + delete[] _caption[caseVal- 1]; + _caption[caseVal- 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal- 1]) { + strcpy(_caption[caseVal- 1], caption); + Game->_stringTable->Expand(&_caption[caseVal- 1]); } } ////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::getCaption(int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; - else return _caption[Case - 1]; +char *CAdNodeState::getCaption(int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; + else return _caption[caseVal- 1]; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving) { - if (!Entity) return E_FAIL; +HRESULT CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { + if (!entity) return E_FAIL; // hack! - if (this->Game != Entity->Game) this->Game = Entity->Game; + if (this->Game != entity->Game) this->Game = entity->Game; - if (Saving) { + if (saving) { for (int i = 0; i < 7; i++) { - if (Entity->_caption[i]) setCaption(Entity->_caption[i], i); + if (entity->_caption[i]) setCaption(entity->_caption[i], i); } - if (!Entity->_region && Entity->_sprite && Entity->_sprite->_filename) { - if (IncludingSprites) setFilename(Entity->_sprite->_filename); + if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { + if (includingSprites) setFilename(entity->_sprite->_filename); else setFilename(""); } - if (Entity->_cursor && Entity->_cursor->_filename) SetCursor(Entity->_cursor->_filename); - _alphaColor = Entity->_alphaColor; - _active = Entity->_active; + if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); + _alphaColor = entity->_alphaColor; + _active = entity->_active; } else { for (int i = 0; i < 7; i++) { - if (_caption[i]) Entity->setCaption(_caption[i], i); + if (_caption[i]) entity->setCaption(_caption[i], i); } - if (_filename && !Entity->_region && IncludingSprites && strcmp(_filename, "") != 0) { - if (!Entity->_sprite || !Entity->_sprite->_filename || scumm_stricmp(Entity->_sprite->_filename, _filename) != 0) - Entity->setSprite(_filename); + if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { + if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) + entity->setSprite(_filename); } if (_cursor) { - if (!Entity->_cursor || !Entity->_cursor->_filename || scumm_stricmp(Entity->_cursor->_filename, _cursor) != 0) - Entity->setCursor(_cursor); + if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) + entity->setCursor(_cursor); } - Entity->_active = _active; - Entity->_alphaColor = _alphaColor; + entity->_active = _active; + entity->_alphaColor = _alphaColor; } return S_OK; diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index 7d9b1c6d90..a5456b3407 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -35,18 +35,18 @@ class CAdEntity; class CAdNodeState : public CBBase { public: - HRESULT TransferEntity(CAdEntity *Entity, bool IncludingSprites, bool Saving); + HRESULT transferEntity(CAdEntity *entity, bool includingSprites, bool saving); void setName(const char *name); void setFilename(const char *filename); - void SetCursor(const char *filename); + void setCursor(const char *filename); DECLARE_PERSISTENT(CAdNodeState, CBBase) CAdNodeState(CBGame *inGame); virtual ~CAdNodeState(); char *_name; bool _active; char *_caption[7]; - void setCaption(const char *Caption, int Case); - char *getCaption(int Case); + void setCaption(const char *caption, int caseVal); + char *getCaption(int caseVal); uint32 _alphaColor; char *_filename; char *_cursor; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 5068bdf5dc..d7d829445b 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -240,10 +240,10 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ForceTalkAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); + const char *animName = stack->pop()->getString(); delete[] _forcedTalkAnimName; - _forcedTalkAnimName = new char[strlen(AnimName) + 1]; - strcpy(_forcedTalkAnimName, AnimName); + _forcedTalkAnimName = new char[strlen(animName) + 1]; + strcpy(_forcedTalkAnimName, animName); _forcedTalkAnimUsed = false; stack->pushBool(true); return S_OK; @@ -256,23 +256,23 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { stack->correctParams(5); - const char *Text = stack->pop()->getString(); - CScValue *SoundVal = stack->pop(); - int Duration = stack->pop()->getInt(); - CScValue *ValStances = stack->pop(); + const char *text = stack->pop()->getString(); + CScValue *soundVal = stack->pop(); + int duration = stack->pop()->getInt(); + CScValue *valStances = stack->pop(); - const char *Stances = ValStances->isNULL() ? NULL : ValStances->getString(); + const char *stances = valStances->isNULL() ? NULL : valStances->getString(); - int Align; + int align = 0; CScValue *val = stack->pop(); - if (val->isNULL()) Align = TAL_CENTER; - else Align = val->getInt(); + if (val->isNULL()) align = TAL_CENTER; + else align = val->getInt(); - Align = MIN(MAX(0, Align), NUM_TEXT_ALIGN - 1); + align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); - const char *Sound = SoundVal->isNULL() ? NULL : SoundVal->getString(); + const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); - talk(Text, Sound, Duration, Stances, (TTextAlign)Align); + talk(text, sound, duration, stances, (TTextAlign)align); if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this); stack->pushNULL(); @@ -285,38 +285,38 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "StickToRegion") == 0) { stack->correctParams(1); - CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer; - bool RegFound = false; + CAdLayer *main = ((CAdGame *)Game)->_scene->_mainLayer; + bool regFound = false; int i; - CScValue *Val = stack->pop(); - if (Val->isNULL() || !Main) { + CScValue *val = stack->pop(); + if (val->isNULL() || !main) { _stickRegion = NULL; - RegFound = true; - } else if (Val->isString()) { - const char *RegionName = Val->getString(); - for (i = 0; i < Main->_nodes.GetSize(); i++) { - if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region->_name && scumm_stricmp(Main->_nodes[i]->_region->_name, RegionName) == 0) { - _stickRegion = Main->_nodes[i]->_region; - RegFound = true; + regFound = true; + } else if (val->isString()) { + const char *regionName = val->getString(); + for (i = 0; i < main->_nodes.GetSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; break; } } - } else if (Val->isNative()) { - CBScriptable *Obj = Val->getNative(); + } else if (val->isNative()) { + CBScriptable *obj = val->getNative(); - for (i = 0; i < Main->_nodes.GetSize(); i++) { - if (Main->_nodes[i]->_type == OBJECT_REGION && Main->_nodes[i]->_region == Obj) { - _stickRegion = Main->_nodes[i]->_region; - RegFound = true; + for (i = 0; i < main->_nodes.GetSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; break; } } } - if (!RegFound) _stickRegion = NULL; - stack->pushBool(RegFound); + if (!regFound) _stickRegion = NULL; + stack->pushBool(regFound); return S_OK; } @@ -325,10 +325,10 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - if (Val->isNULL()) SetFont(NULL); - else SetFont(Val->getString()); + if (val->isNULL()) SetFont(NULL); + else SetFont(val->getString()); stack->pushNULL(); return S_OK; @@ -357,13 +357,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (!val->isNULL()) { - const char *ItemName = val->getString(); + const char *itemName = val->getString(); val = stack->pop(); - const char *InsertAfter = val->isNULL() ? NULL : val->getString(); - if (FAILED(_inventory->insertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName); + const char *insertAfter = val->isNULL() ? NULL : val->getString(); + if (FAILED(_inventory->insertItem(itemName, insertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", itemName); else { // hide associated entities - ((CAdGame *)Game)->_scene->handleItemAssociations(ItemName, false); + ((CAdGame *)Game)->_scene->handleItemAssociations(itemName, false); } } else script->RuntimeError("TakeItem: item name expected"); @@ -453,12 +453,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateParticleEmitter") == 0) { stack->correctParams(3); - bool FollowParent = stack->pop()->getBool(); - int OffsetX = stack->pop()->getInt(); - int OffsetY = stack->pop()->getInt(); + bool followParent = stack->pop()->getBool(); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); - CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY); - if (Emitter) stack->pushNative(_partEmitter, true); + CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); + if (emitter) stack->pushNative(_partEmitter, true); else stack->pushNULL(); return S_OK; @@ -484,26 +484,26 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "AddAttachment") == 0) { stack->correctParams(4); const char *filename = stack->pop()->getString(); - bool PreDisplay = stack->pop()->getBool(true); - int OffsetX = stack->pop()->getInt(); - int OffsetY = stack->pop()->getInt(); + bool preDisplay = stack->pop()->getBool(true); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); HRESULT res; - CAdEntity *Ent = new CAdEntity(Game); - if (FAILED(res = Ent->loadFile(filename))) { - delete Ent; - Ent = NULL; + CAdEntity *ent = new CAdEntity(Game); + if (FAILED(res = ent->loadFile(filename))) { + delete ent; + ent = NULL; script->RuntimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { - Game->registerObject(Ent); + Game->registerObject(ent); - Ent->_posX = OffsetX; - Ent->_posY = OffsetY; - Ent->_active = true; + ent->_posX = offsetX; + ent->_posY = offsetY; + ent->_active = true; - if (PreDisplay) _attachmentsPre.Add(Ent); - else _attachmentsPost.Add(Ent); + if (preDisplay) _attachmentsPre.Add(ent); + else _attachmentsPost.Add(ent); stack->pushBool(true); } @@ -516,31 +516,31 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveAttachment") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); - bool Found = false; - if (Val->isNative()) { - CBScriptable *Obj = Val->getNative(); + CScValue *val = stack->pop(); + bool found = false; + if (val->isNative()) { + CBScriptable *obj = val->getNative(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (_attachmentsPre[i] == Obj) { - Found = true; + if (_attachmentsPre[i] == obj) { + found = true; Game->unregisterObject(_attachmentsPre[i]); _attachmentsPre.RemoveAt(i); i--; } } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (_attachmentsPost[i] == Obj) { - Found = true; + if (_attachmentsPost[i] == obj) { + found = true; Game->unregisterObject(_attachmentsPost[i]); _attachmentsPost.RemoveAt(i); i--; } } } else { - const char *attachmentName = Val->getString(); + const char *attachmentName = val->getString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - Found = true; + found = true; Game->unregisterObject(_attachmentsPre[i]); _attachmentsPre.RemoveAt(i); i--; @@ -548,14 +548,14 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - Found = true; + found = true; Game->unregisterObject(_attachmentsPost[i]); _attachmentsPost.RemoveAt(i); i--; } } } - stack->pushBool(Found); + stack->pushBool(found); return S_OK; } @@ -565,39 +565,39 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetAttachment") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdObject *Ret = NULL; - if (Val->isInt()) { - int Index = Val->getInt(); - int CurrIndex = 0; + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + int currIndex = 0; for (int i = 0; i < _attachmentsPre.GetSize(); i++) { - if (CurrIndex == Index) Ret = _attachmentsPre[i]; - CurrIndex++; + if (currIndex == index) ret = _attachmentsPre[i]; + currIndex++; } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { - if (CurrIndex == Index) Ret = _attachmentsPost[i]; - CurrIndex++; + if (currIndex == index) ret = _attachmentsPost[i]; + currIndex++; } } else { - const char *attachmentName = Val->getString(); + const char *attachmentName = val->getString(); for (int i = 0; i < _attachmentsPre.GetSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - Ret = _attachmentsPre[i]; + ret = _attachmentsPre[i]; break; } } - if (!Ret) { + if (!ret) { for (int i = 0; i < _attachmentsPost.GetSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - Ret = _attachmentsPre[i]; + ret = _attachmentsPre[i]; break; } } } } - if (Ret != NULL) stack->pushNative(Ret, true); + if (ret != NULL) stack->pushNative(ret, true); else stack->pushNULL(); return S_OK; @@ -824,7 +824,7 @@ int CAdObject::getHeight() { ////////////////////////////////////////////////////////////////////////// -void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const char *Stances, TTextAlign Align) { +void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { if (!_sentence) _sentence = new CAdSentence(Game); if (!_sentence) return; @@ -837,10 +837,10 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const delete(_sentence->_sound); _sentence->_sound = NULL; - _sentence->setText(Text); + _sentence->setText(text); Game->_stringTable->Expand(&_sentence->_text); - _sentence->setStances(Stances); - _sentence->_duration = Duration; + _sentence->setStances(stances); + _sentence->_duration = duration; _sentence->_align = Align; _sentence->_startTime = Game->_timer; _sentence->_currentStance = -1; @@ -848,21 +848,21 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const _sentence->_freezable = _freezable; // try to locate speech file automatically - bool DeleteSound = false; - if (!Sound) { - char *Key = Game->_stringTable->GetKey(Text); - if (Key) { - Sound = ((CAdGame *)Game)->findSpeechFile(Key); - delete [] Key; - - if (Sound) DeleteSound = true; + bool deleteSound = false; + if (!sound) { + char *key = Game->_stringTable->GetKey(text); + if (key) { + sound = ((CAdGame *)Game)->findSpeechFile(key); + delete [] key; + + if (sound) deleteSound = true; } } // load sound and set duration appropriately - if (Sound) { + if (sound) { CBSound *snd = new CBSound(Game); - if (snd && SUCCEEDED(snd->setSound(Sound, SOUND_SPEECH, true))) { + if (snd && SUCCEEDED(snd->setSound(sound, SOUND_SPEECH, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { uint32 Length = snd->getLength(); @@ -927,11 +927,11 @@ void CAdObject::talk(const char *Text, const char *Sound, uint32 Duration, const _sentence->_fixedPos = !_subtitlesModRelative; - _sentence->setupTalkFile(Sound); + _sentence->setupTalkFile(sound); _state = STATE_TALKING; - if (DeleteSound) delete [] Sound; + if (deleteSound) delete [] sound; } @@ -1016,20 +1016,20 @@ HRESULT CAdObject::resetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::getExtendedFlag(const char *FlagName) { - if (!FlagName) return false; - else if (strcmp(FlagName, "usable") == 0) return true; +bool CAdObject::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; - else return CBObject::getExtendedFlag(FlagName); + else return CBObject::getExtendedFlag(flagName); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::saveAsText(CBDynBuffer *Buffer, int Indent) { - if (_blockRegion) _blockRegion->saveAsText(Buffer, Indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->saveAsText(Buffer, Indent + 2); +HRESULT CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { + if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); return S_OK; } @@ -1037,13 +1037,13 @@ HRESULT CAdObject::saveAsText(CBDynBuffer *Buffer, int Indent) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::updateBlockRegion() { - CAdGame *AdGame = (CAdGame *)Game; - if (AdGame->_scene) { + CAdGame *adGame = (CAdGame *)Game; + if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->Mimic(_blockRegion, _zoomable ? AdGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + _currentBlockRegion->Mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); if (_wptGroup && _currentWptGroup) - _currentWptGroup->Mimic(_wptGroup, _zoomable ? AdGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + _currentWptGroup->Mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); } return S_OK; } @@ -1060,27 +1060,27 @@ CAdInventory *CAdObject::getInventory() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::afterMove() { - CAdRegion *NewRegions[MAX_NUM_REGIONS]; + CAdRegion *newRegions[MAX_NUM_REGIONS]; - ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, NewRegions, MAX_NUM_REGIONS); + ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (!NewRegions[i]) break; - bool RegFound = false; + if (!newRegions[i]) break; + bool regFound = false; for (int j = 0; j < MAX_NUM_REGIONS; j++) { - if (_currentRegions[j] == NewRegions[i]) { + if (_currentRegions[j] == newRegions[i]) { _currentRegions[j] = NULL; - RegFound = true; + regFound = true; break; } } - if (!RegFound) NewRegions[i]->applyEvent("ActorEntry"); + if (!regFound) newRegions[i]->applyEvent("ActorEntry"); } for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (_currentRegions[i] && Game->validObject(_currentRegions[i])) { _currentRegions[i]->applyEvent("ActorLeave"); } - _currentRegions[i] = NewRegions[i]; + _currentRegions[i] = newRegions[i]; } return S_OK; @@ -1094,15 +1094,15 @@ HRESULT CAdObject::invalidateCurrRegions() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::GetScale(float *ScaleX, float *ScaleY) { +HRESULT CAdObject::getScale(float *scaleX, float *scaleY) { if (_zoomable) { if (_scaleX >= 0 || _scaleY >= 0) { - *ScaleX = _scaleX < 0 ? 100 : _scaleX; - *ScaleY = _scaleY < 0 ? 100 : _scaleY; - } else if (_scale >= 0) *ScaleX = *ScaleY = _scale; - else *ScaleX = *ScaleY = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + *scaleX = _scaleX < 0 ? 100 : _scaleX; + *scaleY = _scaleY < 0 ? 100 : _scaleY; + } else if (_scale >= 0) *scaleX = *scaleY = _scale; + else *scaleX = *scaleY = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) + _relativeScale; } else { - *ScaleX = *ScaleY = 100; + *scaleX = *scaleY = 100; } return S_OK; } @@ -1119,8 +1119,8 @@ HRESULT CAdObject::updateSpriteAttachments() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::displaySpriteAttachments(bool PreDisplay) { - if (PreDisplay) { +HRESULT CAdObject::displaySpriteAttachments(bool preDisplay) { + if (preDisplay) { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { displaySpriteAttachment(_attachmentsPre[i]); } @@ -1133,48 +1133,48 @@ HRESULT CAdObject::displaySpriteAttachments(bool PreDisplay) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::displaySpriteAttachment(CAdObject *Attachment) { - if (!Attachment->_active) return S_OK; +HRESULT CAdObject::displaySpriteAttachment(CAdObject *attachment) { + if (!attachment->_active) return S_OK; - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); + float scaleX, scaleY; + getScale(&scaleX, &scaleY); - int OrigX = Attachment->_posX; - int OrigY = Attachment->_posY; + int origX = attachment->_posX; + int origY = attachment->_posY; // inherit position from owner - Attachment->_posX = (int)(this->_posX + Attachment->_posX * ScaleX / 100.0f); - Attachment->_posY = (int)(this->_posY + Attachment->_posY * ScaleY / 100.0f); + attachment->_posX = (int)(this->_posX + attachment->_posX * scaleX / 100.0f); + attachment->_posY = (int)(this->_posY + attachment->_posY * scaleY / 100.0f); // inherit other props - Attachment->_alphaColor = this->_alphaColor; - Attachment->_blendMode = this->_blendMode; + attachment->_alphaColor = this->_alphaColor; + attachment->_blendMode = this->_blendMode; - Attachment->_scale = this->_scale; - Attachment->_relativeScale = this->_relativeScale; - Attachment->_scaleX = this->_scaleX; - Attachment->_scaleY = this->_scaleY; + attachment->_scale = this->_scale; + attachment->_relativeScale = this->_relativeScale; + attachment->_scaleX = this->_scaleX; + attachment->_scaleY = this->_scaleY; - Attachment->_rotate = this->_rotate; - Attachment->_relativeRotate = this->_relativeRotate; - Attachment->_rotateValid = this->_rotateValid; + attachment->_rotate = this->_rotate; + attachment->_relativeRotate = this->_relativeRotate; + attachment->_rotateValid = this->_rotateValid; - Attachment->_registerAlias = this; - Attachment->_registrable = this->_registrable; + attachment->_registerAlias = this; + attachment->_registrable = this->_registrable; - HRESULT ret = Attachment->display(); + HRESULT ret = attachment->display(); - Attachment->_posX = OrigX; - Attachment->_posY = OrigY; + attachment->_posX = origX; + attachment->_posY = origY; return ret; } ////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::createParticleEmitter(bool FollowParent, int OffsetX, int OffsetY) { - _partFollowParent = FollowParent; - _partOffsetX = OffsetX; - _partOffsetY = OffsetY; +CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { + _partFollowParent = followParent; + _partOffsetX = offsetX; + _partOffsetY = offsetY; if (!_partEmitter) { _partEmitter = new CPartEmitter(Game, this); @@ -1191,11 +1191,11 @@ HRESULT CAdObject::updatePartEmitter() { if (!_partEmitter) return E_FAIL; if (_partFollowParent) { - float ScaleX, ScaleY; - GetScale(&ScaleX, &ScaleY); + float scaleX, scaleY; + getScale(&scaleX, &scaleY); - _partEmitter->_posX = (int)(_posX + (ScaleX / 100.0f) * _partOffsetX); - _partEmitter->_posY = (int)(_posY + (ScaleY / 100.0f) * _partOffsetY); + _partEmitter->_posX = (int)(_posX + (scaleX / 100.0f) * _partOffsetX); + _partEmitter->_posY = (int)(_posY + (scaleY / 100.0f) * _partOffsetY); } return _partEmitter->update(); } diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index 05548c6dbd..def28eff1d 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -111,11 +111,11 @@ public: HRESULT displaySpriteAttachments(bool preDisplay); CAdObject *_registerAlias; private: - HRESULT displaySpriteAttachment(CAdObject *Attachment); + HRESULT displaySpriteAttachment(CAdObject *attachment); CAdInventory *_inventory; protected: - HRESULT GetScale(float *ScaleX, float *ScaleY); + HRESULT getScale(float *scaleX, float *scaleY); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 620ea5c38c..ca7adf0461 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -43,12 +43,12 @@ CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CAdPath::~CAdPath() { - Reset(); + reset(); } ////////////////////////////////////////////////////////////////////////// -void CAdPath::Reset() { +void CAdPath::reset() { for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; @@ -59,7 +59,7 @@ void CAdPath::Reset() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetFirst() { +CBPoint *CAdPath::getFirst() { if (_points.GetSize() > 0) { _currIndex = 0; return _points[_currIndex]; @@ -68,7 +68,7 @@ CBPoint *CAdPath::GetFirst() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetNext() { +CBPoint *CAdPath::getNext() { _currIndex++; if (_currIndex < _points.GetSize()) return _points[_currIndex]; else return NULL; @@ -76,20 +76,20 @@ CBPoint *CAdPath::GetNext() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::GetCurrent() { +CBPoint *CAdPath::getCurrent() { if (_currIndex >= 0 && _currIndex < _points.GetSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// -void CAdPath::AddPoint(CBPoint *point) { +void CAdPath::addPoint(CBPoint *point) { _points.Add(point); } ////////////////////////////////////////////////////////////////////////// -bool CAdPath::SetReady(bool ready) { +bool CAdPath::setReady(bool ready) { bool orig = _ready; _ready = ready; diff --git a/engines/wintermute/Ad/AdPath.h b/engines/wintermute/Ad/AdPath.h index dbc769117a..2e150175f3 100644 --- a/engines/wintermute/Ad/AdPath.h +++ b/engines/wintermute/Ad/AdPath.h @@ -38,12 +38,12 @@ class CBPoint; class CAdPath : public CBBase { public: DECLARE_PERSISTENT(CAdPath, CBBase) - CBPoint *GetCurrent(); - bool SetReady(bool ready = true); - void AddPoint(CBPoint *point); - CBPoint *GetNext(); - CBPoint *GetFirst(); - void Reset(); + CBPoint *getCurrent(); + bool setReady(bool ready = true); + void addPoint(CBPoint *point); + CBPoint *getNext(); + CBPoint *getFirst(); + void reset(); CAdPath(CBGame *inGame); virtual ~CAdPath(); CBArray _points; diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 5f57a0d967..7e681ada72 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -55,8 +55,8 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRegion::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -66,10 +66,10 @@ HRESULT CAdRegion::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -95,7 +95,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -120,12 +120,12 @@ HRESULT CAdRegion::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; @@ -133,7 +133,7 @@ HRESULT CAdRegion::loadBuffer(byte *Buffer, bool Complete) { int ar = 255, ag = 255, ab = 255, alpha = 255; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -346,32 +346,32 @@ const char *CAdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "REGION {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "SCALE=%d\n", (int)_zoom); - Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); +HRESULT CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "REGION {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); for (i = 0; i < _points.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 9a9d0e1055..0e5700828a 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -43,8 +43,8 @@ public: CAdRegion(CBGame *inGame); virtual ~CAdRegion(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index e8923f2179..7c6a768c21 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -65,18 +65,18 @@ CAdResponse::~CAdResponse() { ////////////////////////////////////////////////////////////////////////// -void CAdResponse::SetText(const char *Text) { - CBUtils::setString(&_text, Text); - CBUtils::setString(&_textOrig, Text); +void CAdResponse::setText(const char *text) { + CBUtils::setString(&_text, text); + CBUtils::setString(&_textOrig, text); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIcon(const char *filename) { +HRESULT CAdResponse::setIcon(const char *filename) { delete _icon; _icon = new CBSprite(Game); if (!_icon || FAILED(_icon->loadFile(filename))) { - Game->LOG(0, "CAdResponse::SetIcon failed for file '%s'", filename); + Game->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); delete _icon; _icon = NULL; return E_FAIL; @@ -85,22 +85,22 @@ HRESULT CAdResponse::SetIcon(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetFont(const char *filename) { +HRESULT CAdResponse::setFont(const char *filename) { if (_font) Game->_fontStorage->RemoveFont(_font); _font = Game->_fontStorage->AddFont(filename); if (!_font) { - Game->LOG(0, "CAdResponse::SetFont failed for file '%s'", filename); + Game->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); return E_FAIL; } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconHover(const char *filename) { +HRESULT CAdResponse::setIconHover(const char *filename) { delete _iconHover; _iconHover = new CBSprite(Game); if (!_iconHover || FAILED(_iconHover->loadFile(filename))) { - Game->LOG(0, "CAdResponse::SetIconHover failed for file '%s'", filename); + Game->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); delete _iconHover; _iconHover = NULL; return E_FAIL; @@ -110,11 +110,11 @@ HRESULT CAdResponse::SetIconHover(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::SetIconPressed(const char *filename) { +HRESULT CAdResponse::setIconPressed(const char *filename) { delete _iconPressed; _iconPressed = new CBSprite(Game); if (!_iconPressed || FAILED(_iconPressed->loadFile(filename))) { - Game->LOG(0, "CAdResponse::SetIconPressed failed for file '%s'", filename); + Game->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); delete _iconPressed; _iconPressed = NULL; return E_FAIL; diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h index 84ec6a086a..8774267a97 100644 --- a/engines/wintermute/Ad/AdResponse.h +++ b/engines/wintermute/Ad/AdResponse.h @@ -38,11 +38,11 @@ class CBFont; class CAdResponse : public CBObject { public: DECLARE_PERSISTENT(CAdResponse, CBObject) - HRESULT SetIcon(const char *filename); - HRESULT SetFont(const char *filename); - HRESULT SetIconHover(const char *filename); - HRESULT SetIconPressed(const char *filename); - void SetText(const char *Text); + HRESULT setIcon(const char *filename); + HRESULT setFont(const char *filename); + HRESULT setIconHover(const char *filename); + HRESULT setIconPressed(const char *filename); + void setText(const char *text); int _iD; CBSprite *_icon; CBSprite *_iconHover; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 80ab26392c..9f498b49a5 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -188,8 +188,8 @@ HRESULT CAdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -199,10 +199,10 @@ HRESULT CAdResponseBox::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -223,7 +223,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -244,15 +244,15 @@ HRESULT CAdResponseBox::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { Game->LOG(0, "'RESPONSE_BOX' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -335,31 +335,31 @@ HRESULT CAdResponseBox::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "RESPONSE_BOX\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "RESPONSE_BOX\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontHover && _fontHover->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->putTextIndent(Indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); switch (_align) { case TAL_LEFT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: error("CAdResponseBox::SaveAsText - Unhandled enum"); @@ -368,29 +368,29 @@ HRESULT CAdResponseBox::saveAsText(CBDynBuffer *Buffer, int Indent) { switch (_verticalAlign) { case VAL_TOP: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; case VAL_BOTTOM: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); break; case VAL_CENTER: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); break; } - Buffer->putTextIndent(Indent + 2, "SPACING=%d\n", _spacing); + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // window - if (_window) _window->saveAsText(Buffer, Indent + 2); + if (_window) _window->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } @@ -432,12 +432,12 @@ HRESULT CAdResponseBox::display() { } // prepare response buttons - bool scroll_needed = false; + bool scrollNeeded = false; for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { - scroll_needed = true; + scrollNeeded = true; _respButtons[i]->_visible = false; break; } @@ -456,7 +456,7 @@ HRESULT CAdResponseBox::display() { // show appropriate scroll buttons if (_window) { _window->showWidget("prev", _scrollOffset > 0); - _window->showWidget("next", scroll_needed); + _window->showWidget("next", scrollNeeded); } // go exclusive @@ -537,12 +537,12 @@ HRESULT CAdResponseBox::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponseBox::weedResponses() { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; for (int i = 0; i < _responses.GetSize(); i++) { switch (_responses[i]->_responseType) { case RESPONSE_ONCE: - if (AdGame->branchResponseUsed(_responses[i]->_iD)) { + if (adGame->branchResponseUsed(_responses[i]->_iD)) { delete _responses[i]; _responses.RemoveAt(i); i--; @@ -550,7 +550,7 @@ HRESULT CAdResponseBox::weedResponses() { break; case RESPONSE_ONCE_GAME: - if (AdGame->gameResponseUsed(_responses[i]->_iD)) { + if (adGame->gameResponseUsed(_responses[i]->_iD)) { delete _responses[i]; _responses.RemoveAt(i); i--; @@ -566,25 +566,25 @@ HRESULT CAdResponseBox::weedResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::setLastResponseText(const char *Text, const char *TextOrig) { - CBUtils::setString(&_lastResponseText, Text); - CBUtils::setString(&_lastResponseTextOrig, TextOrig); +void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { + CBUtils::setString(&_lastResponseText, text); + CBUtils::setString(&_lastResponseTextOrig, textOrig); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::handleResponse(CAdResponse *Response) { - setLastResponseText(Response->_text, Response->_textOrig); +HRESULT CAdResponseBox::handleResponse(CAdResponse *response) { + setLastResponseText(response->_text, response->_textOrig); - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; - switch (Response->_responseType) { + switch (response->_responseType) { case RESPONSE_ONCE: - AdGame->addBranchResponse(Response->_iD); + adGame->addBranchResponse(response->_iD); break; case RESPONSE_ONCE_GAME: - AdGame->addGameResponse(Response->_iD); + adGame->addGameResponse(response->_iD); break; default: warning("CAdResponseBox::HandleResponse - Unhandled enum"); @@ -595,51 +595,51 @@ HRESULT CAdResponseBox::handleResponse(CAdResponse *Response) { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getNextAccessObject(CBObject *CurrObject) { - CBArray Objects; - getObjects(Objects, true); +CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); - if (Objects.GetSize() == 0) return NULL; + if (objects.GetSize() == 0) return NULL; else { - if (CurrObject != NULL) { - for (int i = 0; i < Objects.GetSize(); i++) { - if (Objects[i] == CurrObject) { - if (i < Objects.GetSize() - 1) return Objects[i + 1]; + if (currObject != NULL) { + for (int i = 0; i < objects.GetSize(); i++) { + if (objects[i] == currObject) { + if (i < objects.GetSize() - 1) return objects[i + 1]; else break; } } } - return Objects[0]; + return objects[0]; } return NULL; } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getPrevAccessObject(CBObject *CurrObject) { - CBArray Objects; - getObjects(Objects, true); +CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); - if (Objects.GetSize() == 0) return NULL; + if (objects.GetSize() == 0) return NULL; else { - if (CurrObject != NULL) { - for (int i = Objects.GetSize() - 1; i >= 0; i--) { - if (Objects[i] == CurrObject) { - if (i > 0) return Objects[i - 1]; + if (currObject != NULL) { + for (int i = objects.GetSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; else break; } } } - return Objects[Objects.GetSize() - 1]; + return objects[objects.GetSize() - 1]; } return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::getObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _respButtons.GetSize(); i++) { - Objects.Add(_respButtons[i]); + objects.Add(_respButtons[i]); } - if (_window) _window->getWindowObjects(Objects, InteractiveOnly); + if (_window) _window->getWindowObjects(objects, interactiveOnly); return S_OK; } diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 2fcf7ab7a6..3d8a8bb7a6 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -42,17 +42,19 @@ class CAdResponseBox : public CBObject { public: CBObject *getNextAccessObject(CBObject *CurrObject); CBObject *getPrevAccessObject(CBObject *CurrObject); - HRESULT getObjects(CBArray &Objects, bool InteractiveOnly); + HRESULT getObjects(CBArray &objects, bool interactiveOnly); - HRESULT handleResponse(CAdResponse *Response); - void setLastResponseText(const char *Text, const char *TextOrig); + HRESULT handleResponse(CAdResponse *response); + void setLastResponseText(const char *text, const char *textOrig); char *_lastResponseText; char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) CScScript *_waitingScript; virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); typedef enum { - EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE } TResponseEvent; HRESULT weedResponses(); @@ -76,8 +78,8 @@ public: int _verticalAlign; TTextAlign _align; HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index d757010023..60df7734e1 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -58,12 +58,12 @@ HRESULT CAdResponseContext::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::setContext(const char *Context) { +void CAdResponseContext::setContext(const char *context) { delete[] _context; _context = NULL; - if (Context) { - _context = new char [strlen(Context) + 1]; - if (_context) strcpy(_context, Context); + if (context) { + _context = new char [strlen(context) + 1]; + if (_context) strcpy(_context, context); } } diff --git a/engines/wintermute/Ad/AdResponseContext.h b/engines/wintermute/Ad/AdResponseContext.h index d6ad9a9d17..a39e2127d5 100644 --- a/engines/wintermute/Ad/AdResponseContext.h +++ b/engines/wintermute/Ad/AdResponseContext.h @@ -36,7 +36,7 @@ namespace WinterMute { class CAdResponseContext : public CBBase { public: - void setContext(const char *Context); + void setContext(const char *context); int _iD; char *_context; DECLARE_PERSISTENT(CAdResponseContext, CBBase) diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 84a13260ae..356771d0fa 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -54,8 +54,8 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdRotLevel::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -65,10 +65,10 @@ HRESULT CAdRotLevel::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -95,15 +95,15 @@ HRESULT CAdRotLevel::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -135,12 +135,12 @@ HRESULT CAdRotLevel::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "ROTATION_LEVEL {\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::saveAsText(Buffer, Indent + 2); - Buffer->putTextIndent(Indent, "}\n"); +HRESULT CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index dffca612c8..3c02cddc34 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -39,9 +39,9 @@ public: CAdRotLevel(CBGame *inGame); virtual ~CAdRotLevel(); float _rotation; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 1e686545ff..ba3a9806c6 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -52,8 +52,8 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScaleLevel::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -63,10 +63,10 @@ HRESULT CAdScaleLevel::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -80,7 +80,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -93,15 +93,15 @@ HRESULT CAdScaleLevel::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { Game->LOG(0, "'SCALE_LEVEL' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -133,12 +133,12 @@ HRESULT CAdScaleLevel::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "SCALE_LEVEL {\n"); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::saveAsText(Buffer, Indent + 2); - Buffer->putTextIndent(Indent, "}\n"); +HRESULT CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index 6cb336aae5..31e67f05d8 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -40,9 +40,9 @@ public: float _scale; CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 02888c07e6..182d0bb1b1 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -192,8 +192,8 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * _pfTargetPath = path; _pfRequester = requester; - _pfTargetPath->Reset(); - _pfTargetPath->SetReady(false); + _pfTargetPath->reset(); + _pfTargetPath->setReady(false); // prepare working path int i; @@ -453,7 +453,7 @@ void CAdScene::pathFinderStep() { if (lowest_pt == NULL) { // no path -> terminate PathFinder _pfReady = true; - _pfTargetPath->SetReady(true); + _pfTargetPath->setReady(true); return; } @@ -467,7 +467,7 @@ void CAdScene::pathFinderStep() { } _pfReady = true; - _pfTargetPath->SetReady(true); + _pfTargetPath->setReady(true); return; } @@ -504,8 +504,8 @@ HRESULT CAdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -516,13 +516,13 @@ HRESULT CAdScene::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -568,7 +568,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -615,19 +615,19 @@ HRESULT CAdScene::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { Game->LOG(0, "'SCENE' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } int ar, ag, ab, aa; char camera[MAX_PATH] = ""; /* float WaypointHeight = -1.0f; */ - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -863,7 +863,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { if (!_initialized) return S_OK; int j, k; - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; ////////////////////////////////////////////////////////////////////////// @@ -872,8 +872,8 @@ HRESULT CAdScene::traverseNodes(bool Update) { if (_viewport && !Game->_editorMode) { Game->pushViewport(_viewport); PopViewport = true; - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - Game->pushViewport(AdGame->_sceneViewport); + } else if (adGame->_sceneViewport && !Game->_editorMode) { + Game->pushViewport(adGame->_sceneViewport); PopViewport = true; } @@ -1039,18 +1039,18 @@ HRESULT CAdScene::display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::updateFreeObjects() { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; int i; bool Is3DSet; // *** update all active objects Is3DSet = false; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (!AdGame->_objects[i]->_active) continue; + for (i = 0; i < adGame->_objects.GetSize(); i++) { + if (!adGame->_objects[i]->_active) continue; - AdGame->_objects[i]->update(); - AdGame->_objects[i]->_drawn = false; + adGame->_objects[i]->update(); + adGame->_objects[i]->_drawn = false; } @@ -1073,15 +1073,15 @@ HRESULT CAdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::displayRegionContent(CAdRegion *Region, bool Display3DOnly) { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; CBArray Objects; CAdObject *Obj; int i; // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - Obj = AdGame->_objects[i]; + for (i = 0; i < adGame->_objects.GetSize(); i++) { + Obj = adGame->_objects[i]; if (Obj->_active && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { Objects.Add(Obj); } @@ -1138,7 +1138,7 @@ int CAdScene::compareObjs(const void *Obj1, const void *Obj2) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; CAdObject *obj; int i; @@ -1148,10 +1148,10 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { int minY = INT_MAX; // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && !AdGame->_objects[i]->_drawn && AdGame->_objects[i]->_posY < minY && (AdGame->_objects[i]->_stickRegion == Region || Region == NULL || (AdGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(AdGame->_objects[i]->_posX, AdGame->_objects[i]->_posY)))) { - obj = AdGame->_objects[i]; - minY = AdGame->_objects[i]->_posY; + for (i = 0; i < adGame->_objects.GetSize(); i++) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == Region || Region == NULL || (adGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + obj = adGame->_objects[i]; + minY = adGame->_objects[i]->_posY; } } @@ -1969,99 +1969,99 @@ HRESULT CAdScene::removeObject(CAdObject *Object) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::saveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { int i; - Buffer->putTextIndent(Indent, "SCENE {\n"); + buffer->putTextIndent(indent, "SCENE {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); if (_persistentState) - Buffer->putTextIndent(Indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); if (!_persistentStateSprites) - Buffer->putTextIndent(Indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); // scripts for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // properties - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); // viewport if (_viewport) { RECT *rc = _viewport->getRect(); - Buffer->putTextIndent(Indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } // editor settings - Buffer->putTextIndent(Indent + 2, "; ----- editor settings\n"); - Buffer->putTextIndent(Indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); - Buffer->putTextIndent(Indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); - Buffer->putTextIndent(Indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); - - Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); - - Buffer->putTextIndent(Indent + 2, "\n"); - - CBBase::saveAsText(Buffer, Indent + 2); + buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); + + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + CBBase::saveAsText(buffer, indent + 2); // waypoints - Buffer->putTextIndent(Indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->saveAsText(Buffer, Indent + 2); + buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); + for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // layers - Buffer->putTextIndent(Indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.GetSize(); i++) _layers[i]->saveAsText(Buffer, Indent + 2); + buffer->putTextIndent(indent + 2, "; ----- layers\n"); + for (i = 0; i < _layers.GetSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); // scale levels - Buffer->putTextIndent(Indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->saveAsText(Buffer, Indent + 2); + buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); + for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); // rotation levels - Buffer->putTextIndent(Indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->saveAsText(Buffer, Indent + 2); + buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); + for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // free entities - Buffer->putTextIndent(Indent + 2, "; ----- free entities\n"); + buffer->putTextIndent(indent + 2, "; ----- free entities\n"); for (i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { - _objects[i]->saveAsText(Buffer, Indent + 2); + _objects[i]->saveAsText(buffer, indent + 2); } } - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } @@ -2359,13 +2359,13 @@ void CAdScene::pfPointsAdd(int X, int Y, int Distance) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::getViewportOffset(int *OffsetX, int *OffsetY) { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (OffsetX) *OffsetX = _viewport->_offsetX; if (OffsetY) *OffsetY = _viewport->_offsetY; - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - if (OffsetX) *OffsetX = AdGame->_sceneViewport->_offsetX; - if (OffsetY) *OffsetY = AdGame->_sceneViewport->_offsetY; + } else if (adGame->_sceneViewport && !Game->_editorMode) { + if (OffsetX) *OffsetX = adGame->_sceneViewport->_offsetX; + if (OffsetY) *OffsetY = adGame->_sceneViewport->_offsetY; } else { if (OffsetX) *OffsetX = 0; if (OffsetY) *OffsetY = 0; @@ -2376,13 +2376,13 @@ HRESULT CAdScene::getViewportOffset(int *OffsetX, int *OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::getViewportSize(int *Width, int *Height) { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (Width) *Width = _viewport->getWidth(); if (Height) *Height = _viewport->getHeight(); - } else if (AdGame->_sceneViewport && !Game->_editorMode) { - if (Width) *Width = AdGame->_sceneViewport->getWidth(); - if (Height) *Height = AdGame->_sceneViewport->getHeight(); + } else if (adGame->_sceneViewport && !Game->_editorMode) { + if (Width) *Width = adGame->_sceneViewport->getWidth(); + if (Height) *Height = adGame->_sceneViewport->getHeight(); } else { if (Width) *Width = Game->_renderer->_width; if (Height) *Height = Game->_renderer->_height; @@ -2485,38 +2485,36 @@ HRESULT CAdScene::loadState() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::persistState(bool Saving) { +HRESULT CAdScene::persistState(bool saving) { if (!_persistentState) return S_OK; - CAdGame *AdGame = (CAdGame *)Game; - CAdSceneState *State = AdGame->getSceneState(_filename, Saving); - if (!State) return S_OK; - + CAdGame *adGame = (CAdGame *)Game; + CAdSceneState *state = adGame->getSceneState(_filename, saving); + if (!state) return S_OK; - int i; - CAdNodeState *NodeState; + CAdNodeState *nodeState; // dependent objects - for (i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.GetSize(); i++) { CAdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.GetSize(); j++) { CAdSceneNode *node = layer->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: if (!node->_entity->_saveState) continue; - NodeState = State->getNodeState(node->_entity->_name, Saving); - if (NodeState) { - NodeState->TransferEntity(node->_entity, _persistentStateSprites, Saving); + nodeState = state->getNodeState(node->_entity->_name, saving); + if (nodeState) { + nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); //if(Saving) NodeState->_active = node->_entity->_active; //else node->_entity->_active = NodeState->_active; } break; case OBJECT_REGION: if (!node->_region->_saveState) continue; - NodeState = State->getNodeState(node->_region->_name, Saving); - if (NodeState) { - if (Saving) NodeState->_active = node->_region->_active; - else node->_region->_active = NodeState->_active; + nodeState = state->getNodeState(node->_region->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = node->_region->_active; + else node->_region->_active = nodeState->_active; } break; default: @@ -2527,12 +2525,12 @@ HRESULT CAdScene::persistState(bool Saving) { } // free entities - for (i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.GetSize(); i++) { if (!_objects[i]->_saveState) continue; if (_objects[i]->_type == OBJECT_ENTITY) { - NodeState = State->getNodeState(_objects[i]->_name, Saving); - if (NodeState) { - NodeState->TransferEntity((CAdEntity *)_objects[i], _persistentStateSprites, Saving); + nodeState = state->getNodeState(_objects[i]->_name, saving); + if (nodeState) { + nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); //if(Saving) NodeState->_active = _objects[i]->_active; //else _objects[i]->_active = NodeState->_active; } @@ -2540,11 +2538,11 @@ HRESULT CAdScene::persistState(bool Saving) { } // waypoint groups - for (i = 0; i < _waypointGroups.GetSize(); i++) { - NodeState = State->getNodeState(_waypointGroups[i]->_name, Saving); - if (NodeState) { - if (Saving) NodeState->_active = _waypointGroups[i]->_active; - else _waypointGroups[i]->_active = NodeState->_active; + for (int i = 0; i < _waypointGroups.GetSize(); i++) { + nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = _waypointGroups[i]->_active; + else _waypointGroups[i]->_active = nodeState->_active; } } @@ -2553,14 +2551,14 @@ HRESULT CAdScene::persistState(bool Saving) { ////////////////////////////////////////////////////////////////////////// -float CAdScene::getRotationAt(int X, int Y) { +float CAdScene::getRotationAt(int x, int y) { CAdRotLevel *prev = NULL; CAdRotLevel *next = NULL; for (int i = 0; i < _rotLevels.GetSize(); i++) { /* CAdRotLevel *xxx = _rotLevels[i]; int j = _rotLevels.GetSize();*/ - if (_rotLevels[i]->_posX < X) prev = _rotLevels[i]; + if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; else { next = _rotLevels[i]; break; @@ -2571,32 +2569,30 @@ float CAdScene::getRotationAt(int X, int Y) { int delta_x = next->_posX - prev->_posX; float delta_rot = next->_rotation - prev->_rotation; - X -= prev->_posX; + x -= prev->_posX; - float percent = (float)X / ((float)delta_x / 100.0f); + float percent = (float)x / ((float)delta_x / 100.0f); return prev->_rotation + delta_rot / 100 * percent; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::handleItemAssociations(const char *ItemName, bool Show) { - int i; - - for (i = 0; i < _layers.GetSize(); i++) { +HRESULT CAdScene::handleItemAssociations(const char *itemName, bool show) { + for (int i = 0; i < _layers.GetSize(); i++) { CAdLayer *Layer = _layers[i]; for (int j = 0; j < Layer->_nodes.GetSize(); j++) { if (Layer->_nodes[j]->_type == OBJECT_ENTITY) { CAdEntity *Ent = Layer->_nodes[j]->_entity; - if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; + if (Ent->_item && strcmp(Ent->_item, itemName) == 0) Ent->_active = show; } } } - for (i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { - CAdEntity *Ent = (CAdEntity *)_objects[i]; - if (Ent->_item && strcmp(Ent->_item, ItemName) == 0) Ent->_active = Show; + CAdEntity *ent = (CAdEntity *)_objects[i]; + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; } } @@ -2634,20 +2630,20 @@ HRESULT CAdScene::restoreDeviceObjects() { ////////////////////////////////////////////////////////////////////////// CBObject *CAdScene::getNextAccessObject(CBObject *CurrObject) { - CBArray Objects; - getSceneObjects(Objects, true); + CBArray objects; + getSceneObjects(objects, true); - if (Objects.GetSize() == 0) return NULL; + if (objects.GetSize() == 0) return NULL; else { if (CurrObject != NULL) { - for (int i = 0; i < Objects.GetSize(); i++) { - if (Objects[i] == CurrObject) { - if (i < Objects.GetSize() - 1) return Objects[i + 1]; + for (int i = 0; i < objects.GetSize(); i++) { + if (objects[i] == CurrObject) { + if (i < objects.GetSize() - 1) return objects[i + 1]; else break; } } } - return Objects[0]; + return objects[0]; } return NULL; } @@ -2734,14 +2730,14 @@ HRESULT CAdScene::getSceneObjects(CBArray &Objects, bo ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { - CAdGame *AdGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)Game; CAdObject *Obj; int i; // global objects - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - Obj = AdGame->_objects[i]; + for (i = 0; i < adGame->_objects.GetSize(); i++) { + Obj = adGame->_objects[i]; if (Obj->_active && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { if (InteractiveOnly && !Obj->_registrable) continue; diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index ae4750b612..e89d4540f1 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -87,7 +87,7 @@ public: float getScaleAt(int Y); HRESULT sortScaleLevels(); HRESULT sortRotLevels(); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; void skipTo(int OffsetX, int OffsetY); @@ -124,7 +124,7 @@ public: CBArray _objects; CBArray _waypointGroups; HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); int _width; int _height; HRESULT addObject(CAdObject *Object); diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index d51bdc3d02..111f7ff535 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -59,17 +59,17 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); return E_FAIL; } HRESULT ret; - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 11e2b1e2af..5b7f4b5e7a 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -70,8 +70,8 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdTalkDef::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -80,9 +80,9 @@ HRESULT CAdTalkDef::loadFile(const char *filename) { CBUtils::setString(&_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -98,7 +98,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -113,15 +113,15 @@ HRESULT CAdTalkDef::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TALK) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { Game->LOG(0, "'TALK' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 8b093922e9..0880e1f7ac 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -80,7 +80,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -97,19 +97,19 @@ HRESULT CAdTalkNode::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { Game->LOG(0, "'ACTION' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } _endTime = 0; _playToEnd = false; _preCache = false; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: CBUtils::setString(&_spriteFilename, (char *)params); @@ -198,19 +198,19 @@ HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "ACTION {\n"); - if (_comment) Buffer->putTextIndent(Indent + 2, "COMMENT=\"%s\"\n", _comment); - Buffer->putTextIndent(Indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) Buffer->putTextIndent(Indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) Buffer->putTextIndent(Indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) Buffer->putTextIndent(Indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->saveAsText(Buffer, Indent + 2); - if (_preCache) Buffer->putTextIndent(Indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - - CBBase::saveAsText(Buffer, Indent + 2); - - Buffer->putTextIndent(Indent, "}\n"); +HRESULT CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ACTION {\n"); + if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); + buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); + if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index a0004e978b..22727834c5 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -65,8 +65,8 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdWaypointGroup::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -76,10 +76,10 @@ HRESULT CAdWaypointGroup::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -96,7 +96,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -112,15 +112,15 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { Game->LOG(0, "'WAYPOINTS' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -164,20 +164,20 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "WAYPOINTS {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); +HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WAYPOINTS {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); - CBBase::saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + CBBase::saveAsText(buffer, indent + 2); for (int i = 0; i < _points.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index dc4a5650e9..690bdf972d 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -41,11 +41,11 @@ public: void cleanup(); HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); bool _active; CAdWaypointGroup(CBGame *inGame); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index bcd6a43e23..08baa337ed 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::parseEditorProperty(byte *Buffer, bool Complete) { +HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -99,18 +99,18 @@ HRESULT CBBase::parseEditorProperty(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } char *PropName = NULL; char *PropValue = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] PropName; @@ -158,16 +158,16 @@ HRESULT CBBase::parseEditorProperty(byte *Buffer, bool Complete) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::saveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CBBase::saveAsText(CBDynBuffer *buffer, int indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { - Buffer->putTextIndent(Indent, "EDITOR_PROPERTY\n"); - Buffer->putTextIndent(Indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //Buffer->putTextIndent(Indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + buffer->putTextIndent(indent, "}\n\n"); _editorPropsIter++; } diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 7286c9179d..6158ac6430 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -187,10 +187,10 @@ bool CBFont::isTrueType(CBGame *Game, const char *filename) { TOKEN_TABLE_END - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) return false; + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; - byte *WorkBuffer = Buffer; + byte *WorkBuffer = buffer; char *params; CBParser parser(Game); @@ -199,7 +199,7 @@ bool CBFont::isTrueType(CBGame *Game, const char *filename) { if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) Ret = true; - delete [] Buffer; + delete [] buffer; return Ret; } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 16a1274e18..714b66f990 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -246,8 +246,8 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// HRESULT CBFontBitmap::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -257,9 +257,9 @@ HRESULT CBFontBitmap::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -284,7 +284,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::loadBuffer(byte *Buffer) { +HRESULT CBFontBitmap::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -308,11 +308,11 @@ HRESULT CBFontBitmap::loadBuffer(byte *Buffer) { int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_FONT) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { Game->LOG(0, "'FONT' keyword expected."); return E_FAIL; } - Buffer = (byte *)params; + buffer = (byte *)params; int widths[300]; int num = 0, default_width = 8; @@ -327,7 +327,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *Buffer) { int SpaceWidth = 0; int ExpandWidth = 0; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index a5081f91f9..ed8a1c7771 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -405,8 +405,8 @@ int CBFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// HRESULT CBFontTT::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -416,9 +416,9 @@ HRESULT CBFontTT::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -441,7 +441,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::loadBuffer(byte *Buffer) { +HRESULT CBFontTT::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -461,15 +461,15 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { Game->LOG(0, "'TTFONT' keyword expected."); return E_FAIL; } - Buffer = (byte *)params; + buffer = (byte *)params; uint32 BaseColor = 0x00000000; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SIZE: parser.ScanStr(params, "%d", &_fontHeight); @@ -549,7 +549,7 @@ HRESULT CBFontTT::loadBuffer(byte *Buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *Buffer) { +HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -561,7 +561,7 @@ HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *Buffer) { int cmd; CBParser parser(Game); - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_OFFSET_X: parser.ScanStr(params, "%d", &Layer->_offsetX); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 8a20b87299..7818d40396 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -342,39 +342,39 @@ bool CBFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sca ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "FRAME {\n"); - Buffer->putTextIndent(Indent + 2, "DELAY = %d\n", _delay); +HRESULT CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); if (_moveX != 0 || _moveY != 0) - Buffer->putTextIndent(Indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); if (_sound && _sound->_soundFilename) - Buffer->putTextIndent(Indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - Buffer->putTextIndent(Indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); if (_killSound) - Buffer->putTextIndent(Indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); if (_editorExpanded) - Buffer->putTextIndent(Indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(Buffer, Indent, false); + if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); int i; for (i = 1; i < _subframes.GetSize(); i++) { - _subframes[i]->saveAsText(Buffer, Indent + 2); + _subframes[i]->saveAsText(buffer, indent + 2); } for (i = 0; i < _applyEvent.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 18b6061cd6..8c75fc50c6 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -47,7 +47,7 @@ public: CBSound *_sound; bool _editorExpanded; bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); - HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7037e19c31..6e36df929f 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3522,17 +3522,17 @@ HRESULT CBGame::loadSettings(const char *filename) { HRESULT ret = S_OK; - byte *Buffer = OrigBuffer; + byte *buffer = OrigBuffer; byte *params; int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); return E_FAIL; } - Buffer = params; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + buffer = params; + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: delete[] _settingsGameFile; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 055e2d1410..86b72d5730 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -194,7 +194,7 @@ public: void *_dEBUG_LogFile; int _sequence; virtual HRESULT loadFile(const char *filename); - virtual HRESULT loadBuffer(byte *Buffer, bool Complete = true); + virtual HRESULT loadBuffer(byte *buffer, bool complete = true); CBArray _quickMessages; CBArray _windows; CBArray _viewportStack; diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index ef4d8f3909..a77bde0896 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -97,7 +97,7 @@ public: CBSprite *_cursor; bool _sharedCursors; CBSprite *_activeCursor; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 3efd913da8..6194346093 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -96,8 +96,8 @@ bool CBRegion::PointInRegion(int X, int Y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -107,10 +107,10 @@ HRESULT CBRegion::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -145,12 +145,12 @@ HRESULT CBRegion::loadBuffer(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } int i; @@ -158,7 +158,7 @@ HRESULT CBRegion::loadBuffer(byte *Buffer, bool Complete) { for (i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -378,28 +378,28 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride) { - if (!NameOverride) Buffer->putTextIndent(Indent, "REGION {\n"); - else Buffer->putTextIndent(Indent, "%s {\n", NameOverride); +HRESULT CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *NameOverride) { + if (!NameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", NameOverride); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); int i; for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } for (i = 0; i < _points.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - if (_scProp) _scProp->saveAsText(Buffer, Indent + 2); + if (_scProp) _scProp->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index fb725e814b..2ac783ca7b 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -51,7 +51,7 @@ public: bool PointInRegion(int X, int Y); bool CreateRegion(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); RECT _rect; CBArray _points; virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 6353352b8d..a740fde2fc 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -257,8 +257,8 @@ const char *CBScriptHolder::scToString() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::saveAsText(CBDynBuffer *Buffer, int Indent) { - return CBBase::saveAsText(Buffer, Indent); +HRESULT CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { + return CBBase::saveAsText(buffer, indent); } @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::parseProperty(byte *Buffer, bool Complete) { +HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -356,18 +356,18 @@ HRESULT CBScriptHolder::parseProperty(byte *Buffer, bool Complete) { int cmd; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { Game->LOG(0, "'PROPERTY' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } char *PropName = NULL; char *PropValue = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] PropName; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 5c44fcf546..859dfb74aa 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -153,10 +153,10 @@ HRESULT CBSprite::loadFile(const char *filename, int LifeTime, TSpriteCacheType ret = S_OK; } } else { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer) { - if (FAILED(ret = loadBuffer(Buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] Buffer; + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer) { + if (FAILED(ret = loadBuffer(buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); + delete [] buffer; } } @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::loadBuffer(byte *Buffer, bool Complete, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -213,17 +213,17 @@ HRESULT CBSprite::loadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite cleanup(); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { Game->LOG(0, "'SPRITE' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } int frame_count = 1; CBFrame *frame; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: parser.ScanStr((char *)params, "%b", &_continuous); @@ -247,9 +247,9 @@ HRESULT CBSprite::loadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite case TOKEN_STREAMED: parser.ScanStr((char *)params, "%b", &_streamed); - if (_streamed && LifeTime == -1) { - LifeTime = 500; - CacheType = CACHE_ALL; + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; } break; @@ -284,8 +284,8 @@ HRESULT CBSprite::loadBuffer(byte *Buffer, bool Complete, int LifeTime, TSprite break; case TOKEN_FRAME: { - int FrameLifeTime = LifeTime; - if (CacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; + int FrameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; frame = new CBFrame(Game); @@ -428,44 +428,44 @@ bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float Sc } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "SPRITE {\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); +HRESULT CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); if (_streamed) { - Buffer->putTextIndent(Indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); if (_streamedKeepLoaded) - Buffer->putTextIndent(Indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); } if (_editorMuted) - Buffer->putTextIndent(Indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); if (_editorBgFile) { - Buffer->putTextIndent(Indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - Buffer->putTextIndent(Indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - Buffer->putTextIndent(Indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - Buffer->putTextIndent(Indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } - CBScriptHolder::saveAsText(Buffer, Indent + 2); + CBScriptHolder::saveAsText(buffer, indent + 2); int i; // scripts for (i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } for (i = 0; i < _frames.GetSize(); i++) { - _frames[i]->saveAsText(Buffer, Indent + 2); + _frames[i]->saveAsText(buffer, indent + 2); } - Buffer->putTextIndent(Indent, "}\n\n"); + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 3857be14de..da69fb6566 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -76,7 +76,7 @@ public: CBSprite(CBGame *inGame, CBObject *Owner = NULL); virtual ~CBSprite(); CBArray _frames; - HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 3c51866948..72b5535714 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -175,15 +175,15 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { if (ClearOld) _strings.clear(); uint32 Size; - byte *Buffer = Game->_fileManager->readWholeFile(filename, &Size); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename, &Size); + if (buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); return E_FAIL; } int Pos = 0; - if (Size > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { + if (Size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { Pos += 3; if (Game->_textEncoding != TEXT_UTF8) { Game->_textEncoding = TEXT_UTF8; @@ -195,11 +195,11 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { int LineLength = 0; while (Pos < Size) { LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + while (Pos + LineLength < Size && buffer[Pos + LineLength] != '\n' && buffer[Pos + LineLength] != '\0') LineLength++; int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); char *line = new char[RealLength + 1]; - strncpy(line, (char *)&Buffer[Pos], RealLength); + strncpy(line, (char *)&buffer[Pos], RealLength); line[RealLength] = '\0'; char *value = strchr(line, '\t'); if (value == NULL) value = strchr(line, ' '); @@ -219,7 +219,7 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { Pos += LineLength + 1; } - delete [] Buffer; + delete [] buffer; Game->LOG(0, " %d strings loaded", _strings.size()); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index ac7ecc8b20..a561d55345 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -249,53 +249,53 @@ bool CBSubFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::saveAsText(CBDynBuffer *Buffer, int Indent, bool Complete) { - if (Complete) - Buffer->putTextIndent(Indent, "SUBFRAME {\n"); +HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { + if (complete) + buffer->putTextIndent(indent, "SUBFRAME {\n"); if (_surface && _surface->_filename != NULL) - Buffer->putTextIndent(Indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); if (_transparent != 0xFFFF00FF) - Buffer->putTextIndent(Indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); RECT rect; CBPlatform::SetRectEmpty(&rect); if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::EqualRect(&rect, &_rect)) - Buffer->putTextIndent(Indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) - Buffer->putTextIndent(Indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); if (_alpha != 0xFFFFFFFF) { - Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - Buffer->putTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); } if (_mirrorX) - Buffer->putTextIndent(Indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); if (_mirrorY) - Buffer->putTextIndent(Indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); if (_2DOnly) - Buffer->putTextIndent(Indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); if (_3DOnly) - Buffer->putTextIndent(Indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); if (_decoration) - Buffer->putTextIndent(Indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); if (_editorSelected) - Buffer->putTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - if (Complete) - Buffer->putTextIndent(Indent, "}\n\n"); + if (complete) + buffer->putTextIndent(indent, "}\n\n"); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index ddb862460b..4e59893d1d 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1352,33 +1352,33 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: CScValue *Val = stack->pop(); switch (Function->params[i]) { case TYPE_BOOL: - Buffer->PutDWORD((uint32)Val->getBool()); + buffer->PutDWORD((uint32)Val->getBool()); break; case TYPE_LONG: - Buffer->PutDWORD(Val->getInt()); + buffer->PutDWORD(Val->getInt()); break; case TYPE_BYTE: - Buffer->PutDWORD((byte)Val->getInt()); + buffer->PutDWORD((byte)Val->getInt()); break; case TYPE_STRING: - if (Val->isNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->getString()); + if (Val->isNULL()) buffer->PutDWORD(0); + else buffer->PutDWORD((uint32)Val->getString()); break; case TYPE_MEMBUFFER: - if (Val->isNULL()) Buffer->PutDWORD(0); - else Buffer->PutDWORD((uint32)Val->getMemBuffer()); + if (Val->isNULL()) buffer->PutDWORD(0); + else buffer->PutDWORD((uint32)Val->getMemBuffer()); break; case TYPE_FLOAT: { float f = Val->getFloat(); - Buffer->PutDWORD(*((uint32 *)&f)); + buffer->PutDWORD(*((uint32 *)&f)); break; } case TYPE_DOUBLE: { double d = Val->getFloat(); uint32 *pd = (uint32 *)&d; - Buffer->PutDWORD(pd[0]); - Buffer->PutDWORD(pd[1]); + buffer->PutDWORD(pd[0]); + buffer->PutDWORD(pd[1]); break; } } @@ -1389,10 +1389,10 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: bool StackCorrupted = false; switch (Function->call_type) { case CALL_CDECL: - ret = Call_cdecl(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + ret = Call_cdecl(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted); break; default: - ret = Call_stdcall(Buffer->_buffer, Buffer->GetSize(), (uint32)pFunc, &StackCorrupted); + ret = Call_stdcall(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted); } delete Buffer; diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 3c25a4d1e7..887a39e50f 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -52,7 +52,7 @@ public: DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; - HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT saveAsText(CBDynBuffer *buffer, int indent); void setValue(CScValue *Val); bool _persistent; bool propExists(const char *name); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index dffb9532da..0131f0bd02 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -96,8 +96,8 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIButton::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -107,10 +107,10 @@ HRESULT CUIButton::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -155,7 +155,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -199,15 +199,15 @@ HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { int cmd = 2; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { Game->LOG(0, "'BUTTON' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -440,101 +440,101 @@ HRESULT CUIButton::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "BUTTON\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "BUTTON\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_back && _back->_filename) - Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_backHover && _backHover->_filename) - Buffer->putTextIndent(Indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); if (_backPress && _backPress->_filename) - Buffer->putTextIndent(Indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); if (_backDisable && _backDisable->_filename) - Buffer->putTextIndent(Indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); if (_backFocus && _backFocus->_filename) - Buffer->putTextIndent(Indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); if (_image && _image->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_imageHover && _imageHover->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); if (_imagePress && _imagePress->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); if (_imageDisable && _imageDisable->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); if (_imageFocus && _imageFocus->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontHover && _fontHover->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); if (_fontPress && _fontPress->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); if (_fontDisable && _fontDisable->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); if (_fontFocus && _fontFocus->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_text) - Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); switch (_align) { case TAL_LEFT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: warning("CUIButton::SaveAsText - unhandled enum"); break; } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 856afc5be0..cb14a68d5c 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -64,8 +64,8 @@ public: CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 87d70c8f88..5ad3c3fcdf 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -95,8 +95,8 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEdit::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -106,9 +106,9 @@ HRESULT CUIEdit::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -139,7 +139,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -169,15 +169,15 @@ HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { int cmd = 2; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { Game->LOG(0, "'EDIT' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -302,59 +302,59 @@ HRESULT CUIEdit::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "EDIT\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "EDIT\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_back && _back->_filename) - Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_image && _image->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontSelected && _fontSelected->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_text) - Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); - Buffer->putTextIndent(Indent + 2, "MAX_LENGTH=%d\n", _maxLength); - Buffer->putTextIndent(Indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); - Buffer->putTextIndent(Indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "MAX_LENGTH=%d\n", _maxLength); + buffer->putTextIndent(indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + buffer->putTextIndent(indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 0db087e4df..936cf0b72d 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -57,8 +57,8 @@ public: virtual ~CUIEdit(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index a396ae0560..e9d3662471 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -56,8 +56,8 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -67,10 +67,10 @@ HRESULT CUIEntity::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -89,7 +89,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -107,15 +107,15 @@ HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { int cmd = 2; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -174,36 +174,36 @@ HRESULT CUIEntity::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "ENTITY_CONTAINER\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); if (_entity && _entity->_filename) - Buffer->putTextIndent(Indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 8722ac304b..f096af390c 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -40,7 +40,7 @@ public: virtual ~CUIEntity(); HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *Buffer, bool Complete); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); CAdEntity *_entity; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 26d903990d..aad8e23900 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -582,7 +582,7 @@ HRESULT CUIObject::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::saveAsText(CBDynBuffer *Buffer, int Indent) { +HRESULT CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { return E_FAIL; } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index f1ebd81f8c..ad7384860e 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -69,7 +69,7 @@ public: uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; CUIObject *_focusedWidget; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index afb6a6976c..dce7f48731 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -96,8 +96,8 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIText::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -107,9 +107,9 @@ HRESULT CUIText::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -138,7 +138,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -166,15 +166,15 @@ HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { int cmd = 2; CBParser parser(Game); - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { Game->LOG(0, "'STATIC' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -293,39 +293,39 @@ HRESULT CUIText::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "STATIC\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUIText::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "STATIC\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_back && _back->_filename) - Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_image && _image->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); if (_text) - Buffer->putTextIndent(Indent + 2, "TEXT=\"%s\"\n", _text); + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); switch (_textAlign) { case TAL_LEFT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->putTextIndent(Indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: error("CUIText::SaveAsText - Unhandled enum"); @@ -334,42 +334,42 @@ HRESULT CUIText::saveAsText(CBDynBuffer *Buffer, int Indent) { switch (_verticalAlign) { case VAL_TOP: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); break; case VAL_BOTTOM: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); break; case VAL_CENTER: - Buffer->putTextIndent(Indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); break; default: error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 5ef3c85df9..876b6762f7 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -44,8 +44,8 @@ public: TTextAlign _textAlign; TVerticalAlign _verticalAlign; HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index d0f9cdb0f2..a56d3af9c1 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -120,8 +120,8 @@ HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { ////////////////////////////////////////////////////////////////////////// HRESULT CUITiledImage::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -131,10 +131,10 @@ HRESULT CUITiledImage::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -158,7 +158,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -184,15 +184,15 @@ HRESULT CUITiledImage::loadBuffer(byte *Buffer, bool Complete) { int H1 = 0, H2 = 0, H3 = 0; int V1 = 0, V2 = 0, V3 = 0; - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { Game->LOG(0, "'TILED_IMAGE' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while ((cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -307,12 +307,12 @@ HRESULT CUITiledImage::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "TILED_IMAGE\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TILED_IMAGE\n"); + buffer->putTextIndent(indent, "{\n"); if (_image && _image->_surfaceFilename) - Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); int H1, H2, H3; int V1, V2, V3; @@ -326,13 +326,13 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *Buffer, int Indent) { V3 = _downLeft.bottom - _downLeft.top; - Buffer->putTextIndent(Indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); - Buffer->putTextIndent(Indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); + buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); + buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 16712746c5..60b95c12d9 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -39,8 +39,8 @@ public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void correctSize(int *Width, int *Height); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); HRESULT display(int X, int Y, int Width, int Height); CUITiledImage(CBGame *inGame = NULL); diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index fd36971847..c2eef79210 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -201,8 +201,8 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// HRESULT CUIWindow::loadFile(const char *filename) { - byte *Buffer = Game->_fileManager->readWholeFile(filename); - if (Buffer == NULL) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); return E_FAIL; } @@ -212,9 +212,9 @@ HRESULT CUIWindow::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(Buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); - delete [] Buffer; + delete [] buffer; return ret; } @@ -259,7 +259,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { +HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -306,15 +306,15 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { int FadeR = 0, FadeG = 0, FadeB = 0, FadeA = 0; int ar = 0, ag = 0, ab = 0, alpha = 0; - if (Complete) { - if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + if (complete) { + if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { Game->LOG(0, "'WINDOW' keyword expected."); return E_FAIL; } - Buffer = params; + buffer = params; } - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -538,7 +538,7 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { default: - if (FAILED(Game->windowLoadHook(this, (char **)&Buffer, (char **)params))) { + if (FAILED(Game->windowLoadHook(this, (char **)&buffer, (char **)params))) { cmd = PARSERR_GENERIC; } } @@ -567,105 +567,105 @@ HRESULT CUIWindow::loadBuffer(byte *Buffer, bool Complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::saveAsText(CBDynBuffer *Buffer, int Indent) { - Buffer->putTextIndent(Indent, "WINDOW\n"); - Buffer->putTextIndent(Indent, "{\n"); +HRESULT CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WINDOW\n"); + buffer->putTextIndent(indent, "{\n"); - Buffer->putTextIndent(Indent + 2, "NAME=\"%s\"\n", _name); - Buffer->putTextIndent(Indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_back && _back->_filename) - Buffer->putTextIndent(Indent + 2, "BACK=\"%s\"\n", _back->_filename); + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); if (_backInactive && _backInactive->_filename) - Buffer->putTextIndent(Indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); if (_image && _image->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); if (_imageInactive && _imageInactive->_filename) - Buffer->putTextIndent(Indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); if (_font && _font->_filename) - Buffer->putTextIndent(Indent + 2, "FONT=\"%s\"\n", _font->_filename); + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); if (_fontInactive && _fontInactive->_filename) - Buffer->putTextIndent(Indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); if (_cursor && _cursor->_filename) - Buffer->putTextIndent(Indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_text) - Buffer->putTextIndent(Indent + 2, "TITLE=\"%s\"\n", _text); + buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); switch (_titleAlign) { case TAL_LEFT: - Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); break; case TAL_RIGHT: - Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); break; case TAL_CENTER: - Buffer->putTextIndent(Indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); break; default: error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } if (!CBPlatform::IsRectEmpty(&_titleRect)) { - Buffer->putTextIndent(Indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } if (!CBPlatform::IsRectEmpty(&_dragRect)) { - Buffer->putTextIndent(Indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); + buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); - Buffer->putTextIndent(Indent + 2, "X=%d\n", _posX); - Buffer->putTextIndent(Indent + 2, "Y=%d\n", _posY); - Buffer->putTextIndent(Indent + 2, "WIDTH=%d\n", _width); - Buffer->putTextIndent(Indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - Buffer->putTextIndent(Indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); if (_fadeBackground) { - Buffer->putTextIndent(Indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); - Buffer->putTextIndent(Indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); } - Buffer->putTextIndent(Indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - Buffer->putTextIndent(Indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // scripts for (int i = 0; i < _scripts.GetSize(); i++) { - Buffer->putTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - Buffer->putTextIndent(Indent + 2, "\n"); + buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(Buffer, Indent + 2); + CBBase::saveAsText(buffer, indent + 2); // controls for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->saveAsText(Buffer, Indent + 2); + _widgets[i]->saveAsText(buffer, indent + 2); - Buffer->putTextIndent(Indent, "}\n"); + buffer->putTextIndent(indent, "}\n"); return S_OK; } diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index c29038860d..6f639cc603 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -74,12 +74,12 @@ public: CBArray _widgets; TTextAlign _titleAlign; HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; CBSprite *_imageInactive; virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); -- cgit v1.2.3 From ae44b2b4ddf828f74f3b588fa78036650b638e6a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 21:32:29 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in AdScene --- engines/wintermute/Ad/AdScene.cpp | 882 +++++++++++++++++++------------------- 1 file changed, 435 insertions(+), 447 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 182d0bb1b1..8a15175ca5 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -203,27 +203,27 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * //_pfPath.Add(new CAdPathPoint(source.x, source.y, 0)); // if we're one pixel stuck, get unstuck - int StartX = source.x; - int StartY = source.y; - int BestDistance = 1000; - if (isBlockedAt(StartX, StartY, true, requester)) { - int Tolerance = 2; - for (int xxx = StartX - Tolerance; xxx <= StartX + Tolerance; xxx++) { - for (int yyy = StartY - Tolerance; yyy <= StartY + Tolerance; yyy++) { + int startX = source.x; + int startY = source.y; + int bestDistance = 1000; + if (isBlockedAt(startX, startY, true, requester)) { + int tolerance = 2; + for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) { + for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) { if (isWalkableAt(xxx, yyy, true, requester)) { - int Distance = abs(xxx - source.x) + abs(yyy - source.y); - if (Distance < BestDistance) { - StartX = xxx; - StartY = yyy; + int distance = abs(xxx - source.x) + abs(yyy - source.y); + if (distance < bestDistance) { + startX = xxx; + startY = yyy; - BestDistance = Distance; + bestDistance = distance; } } } } } - pfPointsAdd(StartX, StartY, 0); + pfPointsAdd(startX, startY, 0); //CorrectTargetPoint(&target.x, &target.y); @@ -245,10 +245,10 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != requester && AdGame->_objects[i]->_currentWptGroup) { - pfAddWaypointGroup(AdGame->_objects[i]->_currentWptGroup, requester); + CAdGame *adGame = (CAdGame *)Game; + for (i = 0; i < adGame->_objects.GetSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { + pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); } } @@ -258,54 +258,54 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * ////////////////////////////////////////////////////////////////////////// -void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester) { - if (!Wpt->_active) return; +void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { + if (!wpt->_active) return; - for (int i = 0; i < Wpt->_points.GetSize(); i++) { - if (isBlockedAt(Wpt->_points[i]->x, Wpt->_points[i]->y, true, Requester)) continue; + for (int i = 0; i < wpt->_points.GetSize(); i++) { + if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; //_pfPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); - pfPointsAdd(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX); + pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); } } ////////////////////////////////////////////////////////////////////////// -float CAdScene::getZoomAt(int X, int Y) { +float CAdScene::getZoomAt(int x, int y) { float ret = 100; bool found = false; if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_zoom != 0) { - ret = Node->_region->_zoom; + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->PointInRegion(x, y)) { + if (node->_region->_zoom != 0) { + ret = node->_region->_zoom; found = true; break; } } } } - if (!found) ret = getScaleAt(Y); + if (!found) ret = getScaleAt(y); return ret; } ////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::getAlphaAt(int X, int Y, bool ColorCheck) { - if (!Game->_dEBUG_DebugMode) ColorCheck = false; +uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { + if (!Game->_dEBUG_DebugMode) colorCheck = false; uint32 ret; - if (ColorCheck) ret = 0xFFFF0000; + if (colorCheck) ret = 0xFFFF0000; else ret = 0xFFFFFFFF; if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && (ColorCheck || !Node->_region->_blocked) && Node->_region->PointInRegion(X, Y)) { - if (!Node->_region->_blocked) ret = Node->_region->_alpha; + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->PointInRegion(x, y)) { + if (!node->_region->_blocked) ret = node->_region->_alpha; break; } } @@ -315,21 +315,20 @@ uint32 CAdScene::getAlphaAt(int X, int Y, bool ColorCheck) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::isBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { +bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { bool ret = true; - if (CheckFreeObjects) { - int i; - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; + if (checkFreeObjects) { + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return true; } } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { - if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return true; + CAdGame *adGame = (CAdGame *)Game; + for (int i = 0; i < adGame->_objects.GetSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return true; } } } @@ -337,7 +336,7 @@ bool CAdScene::isBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques if (_mainLayer) { for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; + CAdSceneNode *node = _mainLayer->_nodes[i]; /* if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { @@ -345,8 +344,8 @@ bool CAdScene::isBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques break; } */ - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_blocked) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->PointInRegion(x, y)) { + if (node->_region->_blocked) { ret = true; break; } else ret = false; @@ -358,21 +357,19 @@ bool CAdScene::isBlockedAt(int X, int Y, bool CheckFreeObjects, CBObject *Reques ////////////////////////////////////////////////////////////////////////// -bool CAdScene::isWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Requester) { +bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { bool ret = false; - - if (CheckFreeObjects) { - int i; - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && _objects[i] != Requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; + if (checkFreeObjects) { + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return false; } } - CAdGame *AdGame = (CAdGame *)Game; - for (i = 0; i < AdGame->_objects.GetSize(); i++) { - if (AdGame->_objects[i]->_active && AdGame->_objects[i] != Requester && AdGame->_objects[i]->_currentBlockRegion) { - if (AdGame->_objects[i]->_currentBlockRegion->PointInRegion(X, Y)) return false; + CAdGame *adGame = (CAdGame *)Game; + for (int i = 0; i < adGame->_objects.GetSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return false; } } } @@ -380,9 +377,9 @@ bool CAdScene::isWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Reque if (_mainLayer) { for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && !Node->_region->_decoration && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_blocked) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->PointInRegion(x, y)) { + if (node->_region->_blocked) { ret = false; break; } else ret = true; @@ -395,43 +392,43 @@ bool CAdScene::isWalkableAt(int X, int Y, bool CheckFreeObjects, CBObject *Reque ////////////////////////////////////////////////////////////////////////// int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { - double xStep, yStep, X, Y; + double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; - int X1, Y1, X2, Y2; + int x1, y1, x2, y2; - X1 = p1.x; - Y1 = p1.y; - X2 = p2.x; - Y2 = p2.y; + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; - xLength = abs(X2 - X1); - yLength = abs(Y2 - Y1); + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); if (xLength > yLength) { - if (X1 > X2) { - CBUtils::swap(&X1, &X2); - CBUtils::swap(&Y1, &Y2); + if (x1 > x2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); } - yStep = (double)(Y2 - Y1) / (double)(X2 - X1); - Y = Y1; + yStep = (double)(y2 - y1) / (double)(x2 - x1); + y = y1; - for (xCount = X1; xCount < X2; xCount++) { - if (isBlockedAt(xCount, (int)Y, true, requester)) return -1; - Y += yStep; + for (xCount = x1; xCount < x2; xCount++) { + if (isBlockedAt(xCount, (int)y, true, requester)) return -1; + y += yStep; } } else { - if (Y1 > Y2) { - CBUtils::swap(&X1, &X2); - CBUtils::swap(&Y1, &Y2); + if (y1 > y2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); } - xStep = (double)(X2 - X1) / (double)(Y2 - Y1); - X = X1; + xStep = (double)(x2 - x1) / (double)(y2 - y1); + x = x1; - for (yCount = Y1; yCount < Y2; yCount++) { - if (isBlockedAt((int)X, yCount, true, requester)) return -1; - X += xStep; + for (yCount = y1; yCount < y2; yCount++) { + if (isBlockedAt((int)x, yCount, true, requester)) return -1; + x += xStep; } } return MAX(xLength, yLength); @@ -442,28 +439,28 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { void CAdScene::pathFinderStep() { int i; // get lowest unmarked - int lowest_dist = INT_MAX; - CAdPathPoint *lowest_pt = NULL; + int lowestDist = INT_MAX; + CAdPathPoint *lowestPt = NULL; for (i = 0; i < _pfPointsNum; i++) - if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowest_dist) { - lowest_dist = _pfPath[i]->_distance; - lowest_pt = _pfPath[i]; + if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { + lowestDist = _pfPath[i]->_distance; + lowestPt = _pfPath[i]; } - if (lowest_pt == NULL) { // no path -> terminate PathFinder + if (lowestPt == NULL) { // no path -> terminate PathFinder _pfReady = true; _pfTargetPath->setReady(true); return; } - lowest_pt->_marked = true; + lowestPt->_marked = true; // target point marked, generate path and terminate - if (lowest_pt->x == _pfTarget->x && lowest_pt->y == _pfTarget->y) { - while (lowest_pt != NULL) { - _pfTargetPath->_points.InsertAt(0, new CBPoint(lowest_pt->x, lowest_pt->y)); - lowest_pt = lowest_pt->_origin; + if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { + while (lowestPt != NULL) { + _pfTargetPath->_points.InsertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); + lowestPt = lowestPt->_origin; } _pfReady = true; @@ -474,10 +471,10 @@ void CAdScene::pathFinderStep() { // otherwise keep on searching for (i = 0; i < _pfPointsNum; i++) if (!_pfPath[i]->_marked) { - int j = getPointsDist(*lowest_pt, *_pfPath[i], _pfRequester); - if (j != -1 && lowest_pt->_distance + j < _pfPath[i]->_distance) { - _pfPath[i]->_distance = lowest_pt->_distance + j; - _pfPath[i]->_origin = lowest_pt; + int j = getPointsDist(*lowestPt, *_pfPath[i], _pfRequester); + if (j != -1 && lowestPt->_distance + j < _pfPath[i]->_distance) { + _pfPath[i]->_distance = lowestPt->_distance + j; + _pfPath[i]->_origin = lowestPt; } } } @@ -859,7 +856,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::traverseNodes(bool Update) { +HRESULT CAdScene::traverseNodes(bool update) { if (!_initialized) return S_OK; int j, k; @@ -880,7 +877,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// // *** adjust scroll offset - if (Update) { + if (update) { /* if (_autoScroll && Game->_mainObject != NULL) { @@ -921,20 +918,20 @@ HRESULT CAdScene::traverseNodes(bool Update) { ////////////////////////////////////////////////////////////////////////// - int ViewportWidth, ViewportHeight; - getViewportSize(&ViewportWidth, &ViewportHeight); + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); - int ViewportX, ViewportY; - getViewportOffset(&ViewportX, &ViewportY); + int viewportX, viewportY; + getViewportOffset(&viewportX, &viewportY); - int ScrollableX = _width - ViewportWidth; - int ScrollableY = _height - ViewportHeight; + int scrollableX = _width - viewportWidth; + int scrollableY = _height - viewportHeight; - double WidthRatio = ScrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)ScrollableX); - double HeightRatio = ScrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)ScrollableY); + double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); + double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); - int OrigX, OrigY; - Game->getOffset(&OrigX, &OrigY); + int origX, origY; + Game->getOffset(&origX, &origY); @@ -950,7 +947,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { if (!_layers[j]->_active) continue; // make layer exclusive - if (!Update) { + if (!update) { if (_layers[j]->_closeUp && !Game->_editorMode) { if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); if (_shieldWindow) { @@ -963,40 +960,40 @@ HRESULT CAdScene::traverseNodes(bool Update) { } if (_paralaxScrolling) { - int OffsetX = (int)(WidthRatio * (_layers[j]->_width - ViewportWidth) - ViewportX); - int OffsetY = (int)(HeightRatio * (_layers[j]->_height - ViewportHeight) - ViewportY); - Game->setOffset(OffsetX, OffsetY); + int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); + int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); + Game->setOffset(offsetX, offsetY); - Game->_offsetPercentX = (float)OffsetX / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; - Game->_offsetPercentY = (float)OffsetY / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; + Game->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + Game->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); } else { - Game->setOffset(_offsetLeft - ViewportX, _offsetTop - ViewportY); + Game->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); - Game->_offsetPercentX = (float)(_offsetLeft - ViewportX) / ((float)_layers[j]->_width - ViewportWidth) * 100.0f; - Game->_offsetPercentY = (float)(_offsetTop - ViewportY) / ((float)_layers[j]->_height - ViewportHeight) * 100.0f; + Game->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + Game->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; } // for each node for (k = 0; k < _layers[j]->_nodes.GetSize(); k++) { - CAdSceneNode *Node = _layers[j]->_nodes[k]; - switch (Node->_type) { + CAdSceneNode *node = _layers[j]->_nodes[k]; + switch (node->_type) { case OBJECT_ENTITY: - if (Node->_entity->_active && (Game->_editorMode || !Node->_entity->_editorOnly)) { + if (node->_entity->_active && (Game->_editorMode || !node->_entity->_editorOnly)) { Game->_renderer->setup2D(); - if (Update) Node->_entity->update(); - else Node->_entity->display(); + if (update) node->_entity->update(); + else node->_entity->display(); } break; case OBJECT_REGION: { - if (Node->_region->_blocked) break; - if (Node->_region->_decoration) break; + if (node->_region->_blocked) break; + if (node->_region->_decoration) break; - if (!Update) displayRegionContent(Node->_region); + if (!update) displayRegionContent(node->_region); } break; default: @@ -1007,7 +1004,7 @@ HRESULT CAdScene::traverseNodes(bool Update) { // display/update all objects which are off-regions if (_layers[j]->_main) { - if (Update) { + if (update) { updateFreeObjects(); } else { displayRegionContent(NULL); @@ -1017,12 +1014,12 @@ HRESULT CAdScene::traverseNodes(bool Update) { // restore state - Game->setOffset(OrigX, OrigY); + Game->setOffset(origX, origY); Game->_renderer->setup2D(); // display/update fader if (_fader) { - if (Update) _fader->update(); + if (update) _fader->update(); else _fader->display(); } @@ -1040,13 +1037,11 @@ HRESULT CAdScene::display() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::updateFreeObjects() { CAdGame *adGame = (CAdGame *)Game; - int i; - - bool Is3DSet; + bool is3DSet; // *** update all active objects - Is3DSet = false; - for (i = 0; i < adGame->_objects.GetSize(); i++) { + is3DSet = false; + for (int i = 0; i < adGame->_objects.GetSize(); i++) { if (!adGame->_objects[i]->_active) continue; adGame->_objects[i]->update(); @@ -1054,7 +1049,7 @@ HRESULT CAdScene::updateFreeObjects() { } - for (i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.GetSize(); i++) { if (!_objects[i]->_active) continue; _objects[i]->update(); @@ -1072,49 +1067,47 @@ HRESULT CAdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::displayRegionContent(CAdRegion *Region, bool Display3DOnly) { +HRESULT CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { CAdGame *adGame = (CAdGame *)Game; - CBArray Objects; - CAdObject *Obj; - - int i; + CBArray objects; + CAdObject *obj; // global objects - for (i = 0; i < adGame->_objects.GetSize(); i++) { - Obj = adGame->_objects[i]; - if (Obj->_active && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - Objects.Add(Obj); + for (int i = 0; i < adGame->_objects.GetSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + objects.Add(obj); } } // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - Obj = _objects[i]; - if (Obj->_active && !Obj->_editorOnly && !Obj->_drawn && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - Objects.Add(Obj); + for (int i = 0; i < _objects.GetSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + objects.Add(obj); } } // sort by _posY - qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); + qsort(objects.GetData(), objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); // display them - for (i = 0; i < Objects.GetSize(); i++) { - Obj = Objects[i]; + for (int i = 0; i < objects.GetSize(); i++) { + obj = objects[i]; - if (Display3DOnly && !Obj->_is3D) continue; + if (display3DOnly && !obj->_is3D) continue; Game->_renderer->setup2D(); - if (Game->_editorMode || !Obj->_editorOnly) Obj->display(); - Obj->_drawn = true; + if (Game->_editorMode || !obj->_editorOnly) obj->display(); + obj->_drawn = true; } // display design only objects - if (!Display3DOnly) { - if (Game->_editorMode && Region == NULL) { - for (i = 0; i < _objects.GetSize(); i++) { + if (!display3DOnly) { + if (Game->_editorMode && region == NULL) { + for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1127,20 +1120,19 @@ HRESULT CAdScene::displayRegionContent(CAdRegion *Region, bool Display3DOnly) { } ////////////////////////////////////////////////////////////////////////// -int CAdScene::compareObjs(const void *Obj1, const void *Obj2) { - CAdObject *Object1 = *(CAdObject **)Obj1; - CAdObject *Object2 = *(CAdObject **)Obj2; +int CAdScene::compareObjs(const void *obj1, const void *obj2) { + CAdObject *object1 = *(CAdObject **)obj1; + CAdObject *object2 = *(CAdObject **)obj2; - if (Object1->_posY < Object2->_posY) return -1; - else if (Object1->_posY > Object2->_posY) return 1; + if (object1->_posY < object2->_posY) return -1; + else if (object1->_posY > object2->_posY) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { +HRESULT CAdScene::displayRegionContentOld(CAdRegion *region) { CAdGame *adGame = (CAdGame *)Game; CAdObject *obj; - int i; // display all objects in region sorted by _posY do { @@ -1148,16 +1140,16 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { int minY = INT_MAX; // global objects - for (i = 0; i < adGame->_objects.GetSize(); i++) { - if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == Region || Region == NULL || (adGame->_objects[i]->_stickRegion == NULL && Region->PointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + for (int i = 0; i < adGame->_objects.GetSize(); i++) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->PointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { obj = adGame->_objects[i]; minY = adGame->_objects[i]->_posY; } } // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == Region || Region == NULL || (_objects[i]->_stickRegion == NULL && Region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + for (int i = 0; i < _objects.GetSize(); i++) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { obj = _objects[i]; minY = _objects[i]->_posY; } @@ -1174,8 +1166,8 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *Region) { // design only objects - if (Game->_editorMode && Region == NULL) { - for (i = 0; i < _objects.GetSize(); i++) { + if (Game->_editorMode && region == NULL) { + for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1193,23 +1185,23 @@ HRESULT CAdScene::update() { } ////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollTo(int OffsetX, int OffsetY) { - int ViewportWidth, ViewportHeight; - getViewportSize(&ViewportWidth, &ViewportHeight); +void CAdScene::scrollTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); - int OrigOffsetLeft = _targetOffsetLeft; - int OrigOffsetTop = _targetOffsetTop; + int origOffsetLeft = _targetOffsetLeft; + int origOffsetTop = _targetOffsetTop; - _targetOffsetLeft = MAX(0, OffsetX - ViewportWidth / 2); - _targetOffsetLeft = MIN(_targetOffsetLeft, _width - ViewportWidth); + _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); + _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); - _targetOffsetTop = MAX(0, OffsetY - ViewportHeight / 2); - _targetOffsetTop = MIN(_targetOffsetTop, _height - ViewportHeight); + _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); + _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); if (Game->_mainObject && Game->_mainObject->_is3D) { - if (abs(OrigOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = OrigOffsetLeft; - if (abs(OrigOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = OrigOffsetTop; + if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; + if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; //_targetOffsetTop = 0; } @@ -1218,27 +1210,27 @@ void CAdScene::scrollTo(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollToObject(CBObject *Object) { - if (Object) scrollTo(Object->_posX, Object->_posY - Object->getHeight() / 2); +void CAdScene::scrollToObject(CBObject *object) { + if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::skipToObject(CBObject *Object) { - if (Object) skipTo(Object->_posX, Object->_posY - Object->getHeight() / 2); +void CAdScene::skipToObject(CBObject *object) { + if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::skipTo(int OffsetX, int OffsetY) { - int ViewportWidth, ViewportHeight; - getViewportSize(&ViewportWidth, &ViewportHeight); +void CAdScene::skipTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); - _offsetLeft = MAX(0, OffsetX - ViewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); + _offsetLeft = MAX(0, offsetX - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - _offsetTop = MAX(0, OffsetY - ViewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - ViewportHeight); + _offsetTop = MAX(0, offsetY - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); _targetOffsetLeft = _offsetLeft; _targetOffsetTop = _offsetTop; @@ -1288,12 +1280,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdEntity *Ent = new CAdEntity(Game); - addObject(Ent); - if (!Val->isNULL()) Ent->setName(Val->getString()); - stack->pushNative(Ent, true); + CAdEntity *ent = new CAdEntity(Game); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); return S_OK; } @@ -1399,22 +1391,22 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFreeNode") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdObject *Ret = NULL; - if (Val->isInt()) { - int Index = Val->getInt(); - if (Index >= 0 && Index < _objects.GetSize()) Ret = _objects[Index]; + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _objects.GetSize()) ret = _objects[index]; } else { - const char *nodeName = Val->getString(); + const char *nodeName = val->getString(); for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { - Ret = _objects[i]; + ret = _objects[i]; break; } } } - if (Ret) stack->pushNative(Ret, true); + if (ret) stack->pushNative(ret, true); else stack->pushNULL(); return S_OK; @@ -1425,20 +1417,20 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRegionAt") == 0) { stack->correctParams(3); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - CScValue *Val = stack->pop(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + CScValue *val = stack->pop(); - bool IncludeDecors = false; - if (!Val->isNULL()) IncludeDecors = Val->getBool(); + bool includeDecors = false; + if (!val->isNULL()) includeDecors = val->getBool(); if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { - if (Node->_region->_decoration && !IncludeDecors) continue; + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->PointInRegion(x, y)) { + if (node->_region->_decoration && !includeDecors) continue; - stack->pushNative(Node->_region, true); + stack->pushNative(node->_region, true); return S_OK; } } @@ -1452,10 +1444,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsBlockedAt") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); - stack->pushBool(isBlockedAt(X, Y)); + stack->pushBool(isBlockedAt(x, y)); return S_OK; } @@ -1464,10 +1456,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsWalkableAt") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); - stack->pushBool(isWalkableAt(X, Y)); + stack->pushBool(isWalkableAt(x, y)); return S_OK; } @@ -1476,10 +1468,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetScaleAt") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); - stack->pushFloat(getZoomAt(X, Y)); + stack->pushFloat(getZoomAt(x, y)); return S_OK; } @@ -1488,10 +1480,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetRotationAt") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); - stack->pushFloat(getRotationAt(X, Y)); + stack->pushFloat(getRotationAt(x, y)); return S_OK; } @@ -1500,12 +1492,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScrolling") == 0) { stack->correctParams(0); - bool Ret = false; + bool ret = false; if (_autoScroll) { - if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true; + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; } - stack->pushBool(Ret); + stack->pushBool(ret); return S_OK; } @@ -1514,13 +1506,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->getInt(500); - byte Red = stack->pop()->getInt(0); - byte Green = stack->pop()->getInt(0); - byte Blue = stack->pop()->getInt(0); - byte Alpha = stack->pop()->getInt(0xFF); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); - _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration); + _fader->fadeOut(DRGBA(red, green, blue, alpha), duration); if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader); stack->pushNULL(); @@ -1532,13 +1524,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->getInt(500); - byte Red = stack->pop()->getInt(0); - byte Green = stack->pop()->getInt(0); - byte Blue = stack->pop()->getInt(0); - byte Alpha = stack->pop()->getInt(0xFF); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); - _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration); + _fader->fadeIn(DRGBA(red, green, blue, alpha), duration); if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader); stack->pushNULL(); @@ -1559,9 +1551,9 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsPointInViewport") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - stack->pushBool(pointInViewport(X, Y)); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + stack->pushBool(pointInViewport(x, y)); return S_OK; } @@ -1570,16 +1562,16 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetViewport") == 0) { stack->correctParams(4); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - int Width = stack->pop()->getInt(); - int Height = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); - if (Width <= 0) Width = Game->_renderer->_width; - if (Height <= 0) Height = Game->_renderer->_height; + if (width <= 0) width = Game->_renderer->_width; + if (height <= 0) height = Game->_renderer->_height; if (!_viewport) _viewport = new CBViewport(Game); - if (_viewport) _viewport->setRect(X, Y, X + Width, Y + Height); + if (_viewport) _viewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -1591,18 +1583,18 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddLayer") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdLayer *Layer = new CAdLayer(Game); - if (!Val->isNULL()) Layer->setName(Val->getString()); + CAdLayer *layer = new CAdLayer(Game); + if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { - Layer->_width = _mainLayer->_width; - Layer->_height = _mainLayer->_height; + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; } - _layers.Add(Layer); - Game->registerObject(Layer); + _layers.Add(layer); + Game->registerObject(layer); - stack->pushNative(Layer, true); + stack->pushNative(layer, true); return S_OK; } @@ -1611,22 +1603,22 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertLayer") == 0) { stack->correctParams(2); - int Index = stack->pop()->getInt(); - CScValue *Val = stack->pop(); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); - CAdLayer *Layer = new CAdLayer(Game); - if (!Val->isNULL()) Layer->setName(Val->getString()); + CAdLayer *layer = new CAdLayer(Game); + if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { - Layer->_width = _mainLayer->_width; - Layer->_height = _mainLayer->_height; + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; } - if (Index < 0) Index = 0; - if (Index <= _layers.GetSize() - 1) _layers.InsertAt(Index, Layer); - else _layers.Add(Layer); + if (index < 0) index = 0; + if (index <= _layers.GetSize() - 1) _layers.InsertAt(index, layer); + else _layers.Add(layer); - Game->registerObject(Layer); + Game->registerObject(layer); - stack->pushNative(Layer, true); + stack->pushNative(layer, true); return S_OK; } @@ -1635,38 +1627,38 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteLayer") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CAdLayer *ToDelete = NULL; - if (Val->isNative()) { - CBScriptable *Temp = Val->getNative(); + CAdLayer *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); for (int i = 0; i < _layers.GetSize(); i++) { - if (_layers[i] == Temp) { - ToDelete = _layers[i]; + if (_layers[i] == temp) { + toDelete = _layers[i]; break; } } } else { - int Index = Val->getInt(); - if (Index >= 0 && Index < _layers.GetSize()) { - ToDelete = _layers[Index]; + int index = val->getInt(); + if (index >= 0 && index < _layers.GetSize()) { + toDelete = _layers[index]; } } - if (ToDelete == NULL) { + if (toDelete == NULL) { stack->pushBool(false); return S_OK; } - if (ToDelete->_main) { + if (toDelete->_main) { script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); stack->pushBool(false); return S_OK; } for (int i = 0; i < _layers.GetSize(); i++) { - if (_layers[i] == ToDelete) { + if (_layers[i] == toDelete) { _layers.RemoveAt(i); - Game->unregisterObject(ToDelete); + Game->unregisterObject(toDelete); break; } } @@ -1728,10 +1720,10 @@ CScValue *CAdScene::scGetProperty(const char *name) { // MouseX (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseX") == 0) { - int ViewportX; - getViewportOffset(&ViewportX); + int viewportX; + getViewportOffset(&viewportX); - _scValue->setInt(Game->_mousePos.x + _offsetLeft - ViewportX); + _scValue->setInt(Game->_mousePos.x + _offsetLeft - viewportX); return _scValue; } @@ -1739,10 +1731,10 @@ CScValue *CAdScene::scGetProperty(const char *name) { // MouseY (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MouseY") == 0) { - int ViewportY; - getViewportOffset(NULL, &ViewportY); + int viewportY; + getViewportOffset(NULL, &viewportY); - _scValue->setInt(Game->_mousePos.y + _offsetTop - ViewportY); + _scValue->setInt(Game->_mousePos.y + _offsetTop - viewportY); return _scValue; } @@ -1913,11 +1905,11 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "OffsetX") == 0) { _offsetLeft = value->getInt(); - int ViewportWidth, ViewportHeight; - getViewportSize(&ViewportWidth, &ViewportHeight); + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); - _offsetLeft = MAX(0, _offsetLeft - ViewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - ViewportWidth); + _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); _targetOffsetLeft = _offsetLeft; return S_OK; @@ -1929,11 +1921,11 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "OffsetY") == 0) { _offsetTop = value->getInt(); - int ViewportWidth, ViewportHeight; - getViewportSize(&ViewportWidth, &ViewportHeight); + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); - _offsetTop = MAX(0, _offsetTop - ViewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - ViewportHeight); + _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); _targetOffsetTop = _offsetTop; return S_OK; @@ -1950,18 +1942,18 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::addObject(CAdObject *Object) { - _objects.Add(Object); - return Game->registerObject(Object); +HRESULT CAdScene::addObject(CAdObject *object) { + _objects.Add(object); + return Game->registerObject(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::removeObject(CAdObject *Object) { +HRESULT CAdScene::removeObject(CAdObject *object) { for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i] == Object) { + if (_objects[i] == object) { _objects.RemoveAt(i); - return Game->unregisterObject(Object); + return Game->unregisterObject(object); } } return E_FAIL; @@ -2200,19 +2192,19 @@ HRESULT CAdScene::afterLoad() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester) { - double xStep, yStep, X, Y; +HRESULT CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { + double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; - int X1, Y1, X2, Y2; + int x1, y1, x2, y2; - X1 = *TargetX; - Y1 = *TargetY; - X2 = StartX; - Y2 = StartY; + x1 = *targetX; + y1 = *targetY; + x2 = startX; + y2 = startY; - xLength = abs(X2 - X1); - yLength = abs(Y2 - Y1); + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); if (xLength > yLength) { /* @@ -2223,16 +2215,16 @@ HRESULT CAdScene::correctTargetPoint2(int StartX, int StartY, int *TargetX, int } */ - yStep = fabs((double)(Y2 - Y1) / (double)(X2 - X1)); - Y = Y1; + yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); + y = y1; - for (xCount = X1; xCount < X2; xCount++) { - if (isWalkableAt(xCount, (int)Y, CheckFreeObjects, Requester)) { - *TargetX = xCount; - *TargetY = (int)Y; + for (xCount = x1; xCount < x2; xCount++) { + if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { + *targetX = xCount; + *targetY = (int)y; return S_OK; } - Y += yStep; + y += yStep; } } else { /* @@ -2242,16 +2234,16 @@ HRESULT CAdScene::correctTargetPoint2(int StartX, int StartY, int *TargetX, int } */ - xStep = fabs((double)(X2 - X1) / (double)(Y2 - Y1)); - X = X1; + xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); + x = x1; - for (yCount = Y1; yCount < Y2; yCount++) { - if (isWalkableAt((int)X, yCount, CheckFreeObjects, Requester)) { - *TargetX = (int)X; - *TargetY = yCount; + for (yCount = y1; yCount < y2; yCount++) { + if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { + *targetX = (int)x; + *targetY = yCount; return S_OK; } - X += xStep; + x += xStep; } } @@ -2259,19 +2251,19 @@ HRESULT CAdScene::correctTargetPoint2(int StartX, int StartY, int *TargetX, int } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects, CBObject *Requester) { - int x = *X; - int y = *Y; +HRESULT CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { + int x = *argX; + int y = *argY; - if (isWalkableAt(x, y, CheckFreeObjects, Requester) || !_mainLayer) { + if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { return S_OK; } // right int length_right = 0; bool found_right = false; - for (x = *X, y = *Y; x < _mainLayer->_width; x++, length_right++) { - if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x - 5, y, CheckFreeObjects, Requester)) { + for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { found_right = true; break; } @@ -2280,8 +2272,8 @@ HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, boo // left int length_left = 0; bool found_left = false; - for (x = *X, y = *Y; x >= 0; x--, length_left--) { - if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x + 5, y, CheckFreeObjects, Requester)) { + for (x = *argX, y = *argY; x >= 0; x--, length_left--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { found_left = true; break; } @@ -2290,8 +2282,8 @@ HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, boo // up int length_up = 0; bool found_up = false; - for (x = *X, y = *Y; y >= 0; y--, length_up--) { - if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x, y + 5, CheckFreeObjects, Requester)) { + for (x = *argX, y = *argY; y >= 0; y--, length_up--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { found_up = true; break; } @@ -2300,8 +2292,8 @@ HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, boo // down int length_down = 0; bool found_down = false; - for (x = *X, y = *Y; y < _mainLayer->_height; y++, length_down++) { - if (isWalkableAt(x, y, CheckFreeObjects, Requester) && isWalkableAt(x, y - 5, CheckFreeObjects, Requester)) { + for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { found_down = true; break; } @@ -2326,11 +2318,11 @@ HRESULT CAdScene::correctTargetPoint(int StartX, int StartY, int *X, int *Y, boo else if (found_down) OffsetY = length_down; if (abs(OffsetX) < abs(OffsetY)) - *X = *X + OffsetX; + *argX = *argX + OffsetX; else - *Y = *Y + OffsetY; + *argY = *argY + OffsetY; - if (!isWalkableAt(*X, *Y)) return correctTargetPoint2(StartX, StartY, X, Y, CheckFreeObjects, Requester); + if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); else return S_OK; } @@ -2342,13 +2334,13 @@ void CAdScene::pfPointsStart() { ////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsAdd(int X, int Y, int Distance) { +void CAdScene::pfPointsAdd(int x, int y, int distance) { if (_pfPointsNum >= _pfPath.GetSize()) { - _pfPath.Add(new CAdPathPoint(X, Y, Distance)); + _pfPath.Add(new CAdPathPoint(x, y, distance)); } else { - _pfPath[_pfPointsNum]->x = X; - _pfPath[_pfPointsNum]->y = Y; - _pfPath[_pfPointsNum]->_distance = Distance; + _pfPath[_pfPointsNum]->x = x; + _pfPath[_pfPointsNum]->y = y; + _pfPath[_pfPointsNum]->_distance = distance; _pfPath[_pfPointsNum]->_marked = false; _pfPath[_pfPointsNum]->_origin = NULL; } @@ -2358,34 +2350,34 @@ void CAdScene::pfPointsAdd(int X, int Y, int Distance) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getViewportOffset(int *OffsetX, int *OffsetY) { +HRESULT CAdScene::getViewportOffset(int *offsetX, int *offsetY) { CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { - if (OffsetX) *OffsetX = _viewport->_offsetX; - if (OffsetY) *OffsetY = _viewport->_offsetY; + if (offsetX) *offsetX = _viewport->_offsetX; + if (offsetY) *offsetY = _viewport->_offsetY; } else if (adGame->_sceneViewport && !Game->_editorMode) { - if (OffsetX) *OffsetX = adGame->_sceneViewport->_offsetX; - if (OffsetY) *OffsetY = adGame->_sceneViewport->_offsetY; + if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; + if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; } else { - if (OffsetX) *OffsetX = 0; - if (OffsetY) *OffsetY = 0; + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getViewportSize(int *Width, int *Height) { +HRESULT CAdScene::getViewportSize(int *width, int *height) { CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { - if (Width) *Width = _viewport->getWidth(); - if (Height) *Height = _viewport->getHeight(); + if (width) *width = _viewport->getWidth(); + if (height) *height = _viewport->getHeight(); } else if (adGame->_sceneViewport && !Game->_editorMode) { - if (Width) *Width = adGame->_sceneViewport->getWidth(); - if (Height) *Height = adGame->_sceneViewport->getHeight(); + if (width) *width = adGame->_sceneViewport->getWidth(); + if (height) *height = adGame->_sceneViewport->getHeight(); } else { - if (Width) *Width = Game->_renderer->_width; - if (Height) *Height = Game->_renderer->_height; + if (width) *width = Game->_renderer->_width; + if (height) *height = Game->_renderer->_height; } return S_OK; } @@ -2393,47 +2385,46 @@ HRESULT CAdScene::getViewportSize(int *Width, int *Height) { ////////////////////////////////////////////////////////////////////////// int CAdScene::getOffsetLeft() { - int ViewportX; - getViewportOffset(&ViewportX); + int viewportX; + getViewportOffset(&viewportX); - return _offsetLeft - ViewportX; + return _offsetLeft - viewportX; } ////////////////////////////////////////////////////////////////////////// int CAdScene::getOffsetTop() { - int ViewportY; - getViewportOffset(NULL, &ViewportY); + int viewportY; + getViewportOffset(NULL, &viewportY); - return _offsetTop - ViewportY; + return _offsetTop - viewportY; } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::pointInViewport(int X, int Y) { - int Left, Top, Width, Height; +bool CAdScene::pointInViewport(int x, int y) { + int left, top, width, height; - getViewportOffset(&Left, &Top); - getViewportSize(&Width, &Height); + getViewportOffset(&left, &top); + getViewportSize(&width, &height); - return X >= Left && X <= Left + Width && Y >= Top && Y <= Top + Height; + return x >= left && x <= left + width && y >= top && y <= top + height; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::setOffset(int OffsetLeft, int OffsetTop) { - _offsetLeft = OffsetLeft; - _offsetTop = OffsetTop; +void CAdScene::setOffset(int offsetLeft, int offsetTop) { + _offsetLeft = offsetLeft; + _offsetTop = offsetTop; } ////////////////////////////////////////////////////////////////////////// CBObject *CAdScene::getNodeByName(const char *name) { - int i; CBObject *ret = NULL; // dependent objects - for (i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.GetSize(); i++) { CAdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.GetSize(); j++) { CAdSceneNode *node = layer->_nodes[j]; @@ -2455,14 +2446,14 @@ CBObject *CAdScene::getNodeByName(const char *name) { } // free entities - for (i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { return _objects[i]; } } // waypoint groups - for (i = 0; i < _waypointGroups.GetSize(); i++) { + for (int i = 0; i < _waypointGroups.GetSize(); i++) { if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { return _waypointGroups[i]; } @@ -2579,12 +2570,12 @@ float CAdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _layers.GetSize(); i++) { - CAdLayer *Layer = _layers[i]; - for (int j = 0; j < Layer->_nodes.GetSize(); j++) { - if (Layer->_nodes[j]->_type == OBJECT_ENTITY) { - CAdEntity *Ent = Layer->_nodes[j]->_entity; + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.GetSize(); j++) { + if (layer->_nodes[j]->_type == OBJECT_ENTITY) { + CAdEntity *ent = layer->_nodes[j]->_entity; - if (Ent->_item && strcmp(Ent->_item, itemName) == 0) Ent->_active = show; + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; } } } @@ -2601,22 +2592,21 @@ HRESULT CAdScene::handleItemAssociations(const char *itemName, bool show) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions) { - int i; - int NumUsed = 0; +HRESULT CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { + int numUsed = 0; if (_mainLayer) { - for (i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { - CAdSceneNode *Node = _mainLayer->_nodes[i]; - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) { - if (NumUsed < NumRegions - 1) { - RegionList[NumUsed] = Node->_region; - NumUsed++; + for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->PointInRegion(x, y)) { + if (numUsed < numRegions - 1) { + regionList[numUsed] = node->_region; + numUsed++; } else break; } } } - for (i = NumUsed; i < NumRegions; i++) { - RegionList[i] = NULL; + for (int i = numUsed; i < numRegions; i++) { + regionList[i] = NULL; } return S_OK; @@ -2629,15 +2619,15 @@ HRESULT CAdScene::restoreDeviceObjects() { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNextAccessObject(CBObject *CurrObject) { +CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { CBArray objects; getSceneObjects(objects, true); if (objects.GetSize() == 0) return NULL; else { - if (CurrObject != NULL) { + if (currObject != NULL) { for (int i = 0; i < objects.GetSize(); i++) { - if (objects[i] == CurrObject) { + if (objects[i] == currObject) { if (i < objects.GetSize() - 1) return objects[i + 1]; else break; } @@ -2649,55 +2639,55 @@ CBObject *CAdScene::getNextAccessObject(CBObject *CurrObject) { } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getPrevAccessObject(CBObject *CurrObject) { - CBArray Objects; - getSceneObjects(Objects, true); +CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getSceneObjects(objects, true); - if (Objects.GetSize() == 0) return NULL; + if (objects.GetSize() == 0) return NULL; else { - if (CurrObject != NULL) { - for (int i = Objects.GetSize() - 1; i >= 0; i--) { - if (Objects[i] == CurrObject) { - if (i > 0) return Objects[i - 1]; + if (currObject != NULL) { + for (int i = objects.GetSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; else break; } } } - return Objects[Objects.GetSize() - 1]; + return objects[objects.GetSize() - 1]; } return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getSceneObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.GetSize(); i++) { // close-up layer -> remove everything below it - if (InteractiveOnly && _layers[i]->_closeUp) Objects.RemoveAll(); + if (interactiveOnly && _layers[i]->_closeUp) objects.RemoveAll(); for (int j = 0; j < _layers[i]->_nodes.GetSize(); j++) { - CAdSceneNode *Node = _layers[i]->_nodes[j]; - switch (Node->_type) { + CAdSceneNode *node = _layers[i]->_nodes[j]; + switch (node->_type) { case OBJECT_ENTITY: { - CAdEntity *Ent = Node->_entity; - if (Ent->_active && (Ent->_registrable || !InteractiveOnly)) - Objects.Add(Ent); + CAdEntity *ent = node->_entity; + if (ent->_active && (ent->_registrable || !interactiveOnly)) + objects.Add(ent); } break; case OBJECT_REGION: { - CBArray RegionObj; - getRegionObjects(Node->_region, RegionObj, InteractiveOnly); - for (int New = 0; New < RegionObj.GetSize(); New++) { - bool Found = false; - for (int Old = 0; Old < Objects.GetSize(); Old++) { - if (Objects[Old] == RegionObj[New]) { - Found = true; + CBArray regionObj; + getRegionObjects(node->_region, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.GetSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.GetSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; break; } } - if (!Found) Objects.Add(RegionObj[New]); + if (!found) objects.Add(regionObj[newIndex]); } //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); } @@ -2710,17 +2700,17 @@ HRESULT CAdScene::getSceneObjects(CBArray &Objects, bo } // objects outside any region - CBArray RegionObj; - getRegionObjects(NULL, RegionObj, InteractiveOnly); - for (int New = 0; New < RegionObj.GetSize(); New++) { - bool Found = false; - for (int Old = 0; Old < Objects.GetSize(); Old++) { - if (Objects[Old] == RegionObj[New]) { - Found = true; + CBArray regionObj; + getRegionObjects(NULL, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.GetSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.GetSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; break; } } - if (!Found) Objects.Add(RegionObj[New]); + if (!found) objects.Add(regionObj[newIndex]); } @@ -2729,34 +2719,32 @@ HRESULT CAdScene::getSceneObjects(CBArray &Objects, bo ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly) { +HRESULT CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { CAdGame *adGame = (CAdGame *)Game; - CAdObject *Obj; - - int i; + CAdObject *obj; // global objects - for (i = 0; i < adGame->_objects.GetSize(); i++) { - Obj = adGame->_objects[i]; - if (Obj->_active && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - if (InteractiveOnly && !Obj->_registrable) continue; + for (int i = 0; i < adGame->_objects.GetSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; - Objects.Add(Obj); + objects.Add(obj); } } // scene objects - for (i = 0; i < _objects.GetSize(); i++) { - Obj = _objects[i]; - if (Obj->_active && !Obj->_editorOnly && (Obj->_stickRegion == Region || Region == NULL || (Obj->_stickRegion == NULL && Region->PointInRegion(Obj->_posX, Obj->_posY)))) { - if (InteractiveOnly && !Obj->_registrable) continue; + for (int i = 0; i < _objects.GetSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; - Objects.Add(Obj); + objects.Add(obj); } } // sort by _posY - qsort(Objects.GetData(), Objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); + qsort(objects.GetData(), objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); return S_OK; } -- cgit v1.2.3 From de74b1d018d8271081ea1c0127f8fa90b678dd02 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 21:57:21 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in the rest of the Ad-classes. --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Ad/AdSceneNode.cpp | 12 ++--- engines/wintermute/Ad/AdSceneNode.h | 4 +- engines/wintermute/Ad/AdSentence.cpp | 34 ++++++------ engines/wintermute/Ad/AdSentence.h | 2 +- engines/wintermute/Ad/AdSpriteSet.cpp | 47 ++++++++--------- engines/wintermute/Ad/AdSpriteSet.h | 2 +- engines/wintermute/Ad/AdTalkHolder.cpp | 87 +++++++++++++++++-------------- engines/wintermute/Ad/AdTalkNode.cpp | 25 +++++---- engines/wintermute/Ad/AdTypes.h | 40 +++++++++----- engines/wintermute/Ad/AdWaypointGroup.cpp | 23 ++++---- engines/wintermute/Ad/AdWaypointGroup.h | 2 +- 14 files changed, 155 insertions(+), 129 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 04152db456..4724be5c1d 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -410,7 +410,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { } else { _wptGroup = wpt; _currentWptGroup = cwpt; - _currentWptGroup->Mimic(_wptGroup); + _currentWptGroup->mimic(_wptGroup); } } break; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index c4de591706..ef87d90a32 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -366,7 +366,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { } else { _wptGroup = wpt; _currentWptGroup = cwpt; - _currentWptGroup->Mimic(_wptGroup); + _currentWptGroup->mimic(_wptGroup); } } break; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index d7d829445b..f594f91100 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -1043,7 +1043,7 @@ HRESULT CAdObject::updateBlockRegion() { _currentBlockRegion->Mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); if (_wptGroup && _currentWptGroup) - _currentWptGroup->Mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); } return S_OK; } diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 2c734bf87b..0fc4a6a7d6 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -53,18 +53,18 @@ CAdSceneNode::~CAdSceneNode() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::setEntity(CAdEntity *Entity) { +HRESULT CAdSceneNode::setEntity(CAdEntity *entity) { _type = OBJECT_ENTITY; - _entity = Entity; - return Game->registerObject(Entity); + _entity = entity; + return Game->registerObject(entity); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::setRegion(CAdRegion *Region) { +HRESULT CAdSceneNode::setRegion(CAdRegion *region) { _type = OBJECT_REGION; - _region = Region; - return Game->registerObject(Region); + _region = region; + return Game->registerObject(region); } diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h index 198a83beb8..0ba0c5d7b6 100644 --- a/engines/wintermute/Ad/AdSceneNode.h +++ b/engines/wintermute/Ad/AdSceneNode.h @@ -39,8 +39,8 @@ namespace WinterMute { class CAdSceneNode : public CBObject { public: DECLARE_PERSISTENT(CAdSceneNode, CBObject) - HRESULT setRegion(CAdRegion *Region); - HRESULT setEntity(CAdEntity *Entity); + HRESULT setRegion(CAdRegion *region); + HRESULT setEntity(CAdEntity *entity); CAdEntity *_entity; CAdRegion *_region; TObjectType _type; diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index d95fd313e0..7548655ee6 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -122,7 +122,7 @@ char *CAdSentence::getNextStance() { ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getStance(int Stance) { +char *CAdSentence::getStance(int stance) { if (_stances == NULL) return NULL; if (_tempStance) delete [] _tempStance; @@ -132,17 +132,17 @@ char *CAdSentence::getStance(int Stance) { char *curr; int pos; - if (Stance == 0) start = _stances; + if (stance == 0) start = _stances; else { pos = 0; start = NULL; curr = _stances; - while (pos < Stance) { + while (pos < stance) { if (*curr == '\0') break; if (*curr == ',') pos++; curr++; } - if (pos == Stance) start = curr; + if (pos == stance) start = curr; } if (start == NULL) return NULL; @@ -273,23 +273,23 @@ HRESULT CAdSentence::setupTalkFile(const char *soundFilename) { HRESULT CAdSentence::update(TDirection dir) { if (!_talkDef) return S_OK; - uint32 CurrentTime; + uint32 currentTime; // if sound is available, synchronize with sound, otherwise use timer /* if (_sound) CurrentTime = _sound->GetPositionTime(); else CurrentTime = Game->_timer - _startTime; */ - CurrentTime = Game->_timer - _startTime; + currentTime = Game->_timer - _startTime; - bool TalkNodeFound = false; + bool talkNodeFound = false; for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { - if (_talkDef->_nodes[i]->isInTimeInterval(CurrentTime, dir)) { - TalkNodeFound = true; + if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { + talkNodeFound = true; - CBSprite *NewSprite = _talkDef->_nodes[i]->getSprite(dir); - if (NewSprite != _currentSprite) NewSprite->Reset(); - _currentSprite = NewSprite; + CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); + if (newSprite != _currentSprite) newSprite->Reset(); + _currentSprite = newSprite; if (!_talkDef->_nodes[i]->_playToEnd) break; } @@ -297,11 +297,11 @@ HRESULT CAdSentence::update(TDirection dir) { // no talk node, try to use default sprite instead (if any) - if (!TalkNodeFound) { - CBSprite *NewSprite = _talkDef->getDefaultSprite(dir); - if (NewSprite) { - if (NewSprite != _currentSprite) NewSprite->Reset(); - _currentSprite = NewSprite; + if (!talkNodeFound) { + CBSprite *newSprite = _talkDef->getDefaultSprite(dir); + if (newSprite) { + if (newSprite != _currentSprite) newSprite->Reset(); + _currentSprite = newSprite; } else _currentSprite = NULL; } diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 7a5fe6e891..38b44bd619 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -74,7 +74,7 @@ public: private: char *_tempStance; - char *getStance(int Stance); + char *getStance(int stance); }; diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 111f7ff535..26844667d9 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -38,8 +38,8 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(CAdSpriteSet, false) ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *Owner): CBObject(inGame) { - _owner = Owner; +CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { + _owner = owner; for (int i = 0; i < NUM_DIRECTIONS; i++) _sprites[i] = NULL; @@ -90,7 +90,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpriteCacheType CacheType) { +HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -122,7 +122,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (FAILED(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -133,7 +133,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_LEFT] = spr; break; @@ -141,7 +141,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_RIGHT] = spr; break; @@ -149,7 +149,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UP] = spr; break; @@ -157,7 +157,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWN] = spr; break; @@ -165,7 +165,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPLEFT] = spr; break; @@ -173,7 +173,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPRIGHT] = spr; break; @@ -181,7 +181,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNLEFT] = spr; break; @@ -189,7 +189,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int LifeTime, TSpr delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, LifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNRIGHT] = spr; break; @@ -229,26 +229,25 @@ HRESULT CAdSpriteSet::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// CBSprite *CAdSpriteSet::getSprite(TDirection direction) { - int Dir = (int)direction; - if (Dir < 0) Dir = 0; - if (Dir >= NUM_DIRECTIONS) Dir = NUM_DIRECTIONS - 1; + int dir = (int)direction; + if (dir < 0) dir = 0; + if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; CBSprite *ret = NULL; // find nearest set sprite - int i; - int NumSteps = 0; - for (i = Dir, NumSteps = 0; i >= 0; i--) { + int numSteps = 0; + for (int i = dir, NumSteps = 0; i >= 0; i--) { if (_sprites[i] != NULL) { ret = _sprites[i]; - NumSteps = Dir - i; + numSteps = dir - i; break; } } - for (i = Dir; i < NUM_DIRECTIONS; i++) { + for (int i = dir; i < NUM_DIRECTIONS; i++) { if (_sprites[i] != NULL) { - if (ret == NULL || NumSteps > i - Dir) return _sprites[i]; + if (ret == NULL || numSteps > i - dir) return _sprites[i]; else return ret; } } @@ -301,11 +300,11 @@ HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::containsSprite(CBSprite *Sprite) { - if (!Sprite) return false; +bool CAdSpriteSet::containsSprite(CBSprite *sprite) { + if (!sprite) return false; for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] == Sprite) return true; + if (_sprites[i] == sprite) return true; } return false; } diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index e1e527c267..7d457048df 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -45,7 +45,7 @@ public: CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); virtual ~CAdSpriteSet(); HRESULT loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - HRESULT loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + HRESULT loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); CBSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index d5746a4530..9d4c4c8e8b 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -53,11 +53,12 @@ CAdTalkHolder::~CAdTalkHolder() { delete _sprite; _sprite = NULL; - int i; - for (i = 0; i < _talkSprites.GetSize(); i++) delete _talkSprites[i]; + for (int i = 0; i < _talkSprites.GetSize(); i++) + delete _talkSprites[i]; _talkSprites.RemoveAll(); - for (i = 0; i < _talkSpritesEx.GetSize(); i++) delete _talkSpritesEx[i]; + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) + delete _talkSpritesEx[i]; _talkSpritesEx.RemoveAll(); } @@ -125,27 +126,27 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (strcmp(name, "SetSprite") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - bool SetCurrent = false; - if (_currentSprite && _currentSprite == _sprite) SetCurrent = true; + bool setCurrent = false; + if (_currentSprite && _currentSprite == _sprite) setCurrent = true; delete _sprite; _sprite = NULL; - if (Val->isNULL()) { + if (val->isNULL()) { _sprite = NULL; - if (SetCurrent) _currentSprite = NULL; + if (setCurrent) _currentSprite = NULL; stack->pushBool(true); } else { - const char *filename = Val->getString(); + const char *filename = val->getString(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { script->RuntimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); } else { _sprite = spr; - if (SetCurrent) _currentSprite = _sprite; + if (setCurrent) _currentSprite = _sprite; stack->pushBool(true); } } @@ -202,27 +203,30 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->correctParams(2); const char *filename = stack->pop()->getString(); - bool Ex = stack->pop()->getBool(); - int i; + bool ex = stack->pop()->getBool(); - bool SetCurrent = false; - bool SetTemp2 = false; + bool setCurrent = false; + bool setTemp2 = false; - if (Ex) { - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (ex) { + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) SetCurrent = true; - if (_tempSprite2 == _talkSpritesEx[i]) SetTemp2 = true; + if (_currentSprite == _talkSpritesEx[i]) + setCurrent = true; + if (_tempSprite2 == _talkSpritesEx[i]) + setTemp2 = true; delete _talkSpritesEx[i]; _talkSpritesEx.RemoveAt(i); break; } } } else { - for (i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.GetSize(); i++) { if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSprites[i]) SetCurrent = true; - if (_tempSprite2 == _talkSprites[i]) SetTemp2 = true; + if (_currentSprite == _talkSprites[i]) + setCurrent = true; + if (_tempSprite2 == _talkSprites[i]) + setTemp2 = true; delete _talkSprites[i]; _talkSprites.RemoveAt(i); break; @@ -232,8 +236,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack } stack->pushBool(true); - if (SetCurrent) _currentSprite = _sprite; - if (SetTemp2) _tempSprite2 = _sprite; + if (setCurrent) + _currentSprite = _sprite; + if (setTemp2) + _tempSprite2 = _sprite; return S_OK; } @@ -245,9 +251,9 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->correctParams(2); const char *filename = stack->pop()->getString(); - bool Ex = stack->pop()->getBool(); - bool SetCurrent = false; - bool SetTemp2 = false; + bool ex = stack->pop()->getBool(); + bool setCurrent = false; + bool setTemp2 = false; CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { @@ -256,30 +262,35 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack } else { // delete current - int i; - if (Ex) { - for (i = 0; i < _talkSpritesEx.GetSize(); i++) { - if (_talkSpritesEx[i] == _currentSprite) SetCurrent = true; - if (_talkSpritesEx[i] == _tempSprite2) SetTemp2 = true; + if (ex) { + for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + if (_talkSpritesEx[i] == _currentSprite) + setCurrent = true; + if (_talkSpritesEx[i] == _tempSprite2) + setTemp2 = true; delete _talkSpritesEx[i]; } _talkSpritesEx.RemoveAll(); } else { - for (i = 0; i < _talkSprites.GetSize(); i++) { - if (_talkSprites[i] == _currentSprite) SetCurrent = true; - if (_talkSprites[i] == _tempSprite2) SetTemp2 = true; + for (int i = 0; i < _talkSprites.GetSize(); i++) { + if (_talkSprites[i] == _currentSprite) setCurrent = true; + if (_talkSprites[i] == _tempSprite2) setTemp2 = true; delete _talkSprites[i]; } _talkSprites.RemoveAll(); } // set new - if (Ex) _talkSpritesEx.Add(spr); - else _talkSprites.Add(spr); + if (ex) + _talkSpritesEx.Add(spr); + else + _talkSprites.Add(spr); stack->pushBool(true); - if (SetCurrent) _currentSprite = spr; - if (SetTemp2) _tempSprite2 = spr; + if (setCurrent) + _currentSprite = spr; + if (setTemp2) + _tempSprite2 = spr; } return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 0880e1f7ac..0cfadf396a 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -161,22 +161,25 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { return E_FAIL; } - if (_endTime == 0) _playToEnd = true; - else _playToEnd = false; + if (_endTime == 0) + _playToEnd = true; + else + _playToEnd = false; if (_preCache && _spriteFilename) { delete _sprite; _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) return E_FAIL; + if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) + return E_FAIL; } if (_preCache && _spriteSetFilename) { delete _spriteSet; _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) return E_FAIL; + if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) + return E_FAIL; } - return S_OK; } @@ -241,22 +244,22 @@ HRESULT CAdTalkNode::loadSprite() { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::isInTimeInterval(uint32 Time, TDirection Dir) { - if (Time >= _startTime) { +bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { + if (time >= _startTime) { if (_playToEnd) { if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(Dir) && _spriteSet->getSprite(Dir)->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; else return false; - } else return _endTime >= Time; + } else return _endTime >= time; } else return false; } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::getSprite(TDirection Dir) { +CBSprite *CAdTalkNode::getSprite(TDirection dir) { loadSprite(); if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->getSprite(Dir); + else if (_spriteSet) return _spriteSet->getSprite(dir); else return NULL; } diff --git a/engines/wintermute/Ad/AdTypes.h b/engines/wintermute/Ad/AdTypes.h index 6531927350..b88d6fe259 100644 --- a/engines/wintermute/Ad/AdTypes.h +++ b/engines/wintermute/Ad/AdTypes.h @@ -32,20 +32,22 @@ namespace WinterMute { typedef enum { - GAME_NORMAL, GAME_WAITING_RESPONSE + GAME_NORMAL, + GAME_WAITING_RESPONSE } TGameStateEx; - typedef enum { - OBJECT_ENTITY, OBJECT_REGION, OBJECT_ACTOR, OBJECT_NONE + OBJECT_ENTITY, + OBJECT_REGION, + OBJECT_ACTOR, + OBJECT_NONE } TObjectType; - typedef enum { - ENTITY_NORMAL, ENTITY_SOUND + ENTITY_NORMAL, + ENTITY_SOUND } TEntityType; - typedef enum { STATE_NONE, STATE_IDLE, @@ -63,29 +65,41 @@ typedef enum { } TObjectState; typedef enum { - DIRECT_WALK_NONE, DIRECT_WALK_FW, DIRECT_WALK_BK + DIRECT_WALK_NONE, + DIRECT_WALK_FW, + DIRECT_WALK_BK } TDirectWalkMode; typedef enum { - DIRECT_TURN_NONE, DIRECT_TURN_CW, DIRECT_TURN_CCW + DIRECT_TURN_NONE, + DIRECT_TURN_CW, + DIRECT_TURN_CCW } TDirectTurnMode; typedef enum { - RESPONSE_TEXT, RESPONSE_ICON + RESPONSE_TEXT, + RESPONSE_ICON } TResponseStyle; typedef enum { - RESPONSE_ALWAYS, RESPONSE_ONCE, RESPONSE_ONCE_GAME + RESPONSE_ALWAYS, + RESPONSE_ONCE, + RESPONSE_ONCE_GAME } TResponseType; typedef enum { - TALK_SKIP_LEFT = 0, TALK_SKIP_RIGHT = 1, TALK_SKIP_BOTH = 2, TALK_SKIP_NONE = 3 + TALK_SKIP_LEFT = 0, + TALK_SKIP_RIGHT = 1, + TALK_SKIP_BOTH = 2, + TALK_SKIP_NONE = 3 } TTalkSkipButton; - typedef enum { - GEOM_WAYPOINT, GEOM_WALKPLANE, GEOM_BLOCKED, GEOM_GENERIC + GEOM_WAYPOINT, + GEOM_WALKPLANE, + GEOM_BLOCKED, + GEOM_GENERIC } TGeomNodeType; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 22727834c5..0dde814fed 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -170,7 +170,8 @@ HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) + _scProp->saveAsText(buffer, indent + 2); CBBase::saveAsText(buffer, indent + 2); for (int i = 0; i < _points.GetSize(); i++) { @@ -238,23 +239,21 @@ HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::Mimic(CAdWaypointGroup *Wpt, float Scale, int X, int Y) { - if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; +HRESULT CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { + if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return S_OK; cleanup(); - for (int i = 0; i < Wpt->_points.GetSize(); i++) { - int x, y; + for (int i = 0; i < wpt->_points.GetSize(); i++) { + int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); + int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); - x = (int)((float)Wpt->_points[i]->x * Scale / 100.0f); - y = (int)((float)Wpt->_points[i]->y * Scale / 100.0f); - - _points.Add(new CBPoint(x + X, y + Y)); + _points.Add(new CBPoint(x + argX, y + argY)); } - _lastMimicScale = Scale; - _lastMimicX = X; - _lastMimicY = Y; + _lastMimicScale = scale; + _lastMimicX = argX; + _lastMimicY = argY; return S_OK; } diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 690bdf972d..6b4d65f0dd 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -39,7 +39,7 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - HRESULT Mimic(CAdWaypointGroup *Wpt, float Scale = 100.0f, int X = 0, int Y = 0); + HRESULT mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); bool _active; -- cgit v1.2.3 From a2bf9c78f8e28bcfd3659035f3b72e1855dd162f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 22:02:42 +0200 Subject: WINTERMUTE: Rename VarName->varName in the File-classes. --- engines/wintermute/Base/file/BDiskFile.cpp | 22 +++++++++++----------- engines/wintermute/Base/file/BDiskFile.h | 2 +- engines/wintermute/Base/file/BPkgFile.cpp | 4 ++-- engines/wintermute/Base/file/BPkgFile.h | 2 +- engines/wintermute/Base/file/BSaveThumbFile.h | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index c26b3f02c6..f2706bbfb5 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -45,16 +45,16 @@ void correctSlashes(char *fileName) { } } -Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager) { - char FullPath[MAX_PATH]; +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { + char fullPath[MAX_PATH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; for (int i = 0; i < fileManager->_singlePaths.GetSize(); i++) { - sprintf(FullPath, "%s%s", fileManager->_singlePaths[i], Filename.c_str()); - correctSlashes(FullPath); + sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); + correctSlashes(fullPath); Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { + if (tempFile->open(fullPath)) { file = tempFile; } else { delete tempFile; @@ -63,11 +63,11 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM // if we didn't find it in search paths, try to open directly if (!file) { - strcpy(FullPath, Filename.c_str()); - correctSlashes(FullPath); + strcpy(fullPath, filename.c_str()); + correctSlashes(fullPath); Common::File *tempFile = new Common::File(); - if (tempFile->open(FullPath)) { + if (tempFile->open(fullPath)) { file = tempFile; } else { delete tempFile; @@ -90,14 +90,14 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { - error("Error allocating memory for compressed file '%s'", Filename.c_str()); + error("Error allocating memory for compressed file '%s'", filename.c_str()); delete file; return NULL; } byte *data = new byte[UncompSize]; if (!data) { - error("Error allocating buffer for file '%s'", Filename.c_str()); + error("Error allocating buffer for file '%s'", filename.c_str()); delete [] CompBuffer; delete file; return NULL; @@ -106,7 +106,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileM file->read(CompBuffer, CompSize); if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { - error("Error uncompressing file '%s'", Filename.c_str()); + error("Error uncompressing file '%s'", filename.c_str()); delete [] CompBuffer; delete file; return NULL; diff --git a/engines/wintermute/Base/file/BDiskFile.h b/engines/wintermute/Base/file/BDiskFile.h index ebe1400128..23e1a0a315 100644 --- a/engines/wintermute/Base/file/BDiskFile.h +++ b/engines/wintermute/Base/file/BDiskFile.h @@ -35,7 +35,7 @@ class SeekableReadStream; namespace WinterMute { -Common::SeekableReadStream *openDiskFile(const Common::String &Filename, CBFileManager *fileManager); +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index a7f634be25..2ca74c1ac7 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -65,11 +65,11 @@ public: } }; -Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileManager *fileManager) { +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { CBFileEntry *fileEntry; Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH]; - strcpy(fileName, Filename.c_str()); + strcpy(fileName, filename.c_str()); // correct slashes for (uint32 i = 0; i < strlen(fileName); i++) { diff --git a/engines/wintermute/Base/file/BPkgFile.h b/engines/wintermute/Base/file/BPkgFile.h index e2d90e2b50..0d1916594a 100644 --- a/engines/wintermute/Base/file/BPkgFile.h +++ b/engines/wintermute/Base/file/BPkgFile.h @@ -39,7 +39,7 @@ class File; namespace WinterMute { class CBFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &Filename, CBFileManager *fileManager); +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 280a5a1447..8be98c1cc8 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -39,10 +39,10 @@ class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); virtual ~CBSaveThumbFile(); - virtual HRESULT seek(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); - virtual HRESULT read(void *Buffer, uint32 Size); + virtual HRESULT seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); + virtual HRESULT read(void *buffer, uint32 size); virtual HRESULT close(); - virtual HRESULT open(const Common::String &Filename); + virtual HRESULT open(const Common::String &filename); private: byte *_data; }; -- cgit v1.2.3 From 3fa0bb4c7a2079d9f8f6d5787d20cecfb0883146 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 22:06:10 +0200 Subject: WINTERMUTE: Rename VarName->varName in BActiveRect. --- engines/wintermute/Base/BActiveRect.cpp | 34 ++++++++++++++++----------------- engines/wintermute/Base/BActiveRect.h | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 72962dbf1e..eb4f60b0d0 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -48,31 +48,31 @@ CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise): CBBase(inGame) { - _owner = Owner; - _frame = Frame; - CBPlatform::SetRect(&_rect, X, Y, X + Width, Y + Height); - _zoomX = ZoomX; - _zoomY = ZoomY; - _precise = Precise; +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { + _owner = owner; + _frame = frame; + CBPlatform::SetRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; _region = NULL; _offsetX = _offsetY = 0; clipRect(); } ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY): CBBase(inGame) { - _owner = Owner; - _region = Region; - CBPlatform::CopyRect(&_rect, &Region->_rect); - CBPlatform::OffsetRect(&_rect, -OffsetX, -OffsetY); +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { + _owner = owner; + _region = region; + CBPlatform::CopyRect(&_rect, ®ion->_rect); + CBPlatform::OffsetRect(&_rect, -offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; _frame = NULL; clipRect(); - _offsetX = OffsetX; - _offsetY = OffsetY; + _offsetX = offsetX; + _offsetY = offsetY; } @@ -87,11 +87,11 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// void CBActiveRect::clipRect() { RECT rc; - bool CustomViewport; - Game->getCurrentViewportRect(&rc, &CustomViewport); + bool customViewport; + Game->getCurrentViewportRect(&rc, &customViewport); CBRenderer *Rend = Game->_renderer; - if (!CustomViewport) { + if (!customViewport) { rc.left -= Rend->_drawOffsetX; rc.right -= Rend->_drawOffsetX; rc.top -= Rend->_drawOffsetY; diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index 1577c2d9b2..a65f0cea7a 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -48,8 +48,8 @@ public: int _offsetY; RECT _rect; CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *Owner, CBSubFrame *Frame, int X, int Y, int Width, int Height, float ZoomX = 100, float ZoomY = 100, bool Precise = true); - CBActiveRect(CBGame *inGame, CBObject *Owner, CBRegion *Region, int OffsetX, int OffsetY); + CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); virtual ~CBActiveRect(); }; -- cgit v1.2.3 From 3f6f944473211d5a1788671ca66f6fba103b4d40 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 4 Jul 2012 22:08:57 +0200 Subject: WINTERMUTE: Rename VarName->varName in BBase. --- engines/wintermute/Base/BBase.cpp | 63 ++++++++++++++++++++------------------- engines/wintermute/Base/BBase.h | 8 ++--- 2 files changed, 36 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index 08baa337ed..3ca29e9dcd 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -55,23 +55,23 @@ CBBase::~CBBase() { ////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *PropName, const char *InitVal) { - _editorPropsIter = _editorProps.find(PropName); +const char *CBBase::getEditorProp(const char *propName, const char *initVal) { + _editorPropsIter = _editorProps.find(propName); if (_editorPropsIter != _editorProps.end()) return _editorPropsIter->_value.c_str(); //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return InitVal; + else return initVal; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::setEditorProp(const char *PropName, const char *PropValue) { - if (PropName == NULL) return E_FAIL; +HRESULT CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return E_FAIL; - if (PropValue == NULL) { - _editorProps.erase(PropName); + if (propValue == NULL) { + _editorProps.erase(propName); } else { - _editorProps[PropName] = PropValue; + _editorProps[propName] = propValue; } return S_OK; } @@ -92,7 +92,8 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_END - if (!Game->_editorMode) return S_OK; + if (!Game->_editorMode) + return S_OK; byte *params; @@ -107,51 +108,51 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { buffer = params; } - char *PropName = NULL; - char *PropValue = NULL; + char *propName = NULL; + char *propValue = NULL; while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: - delete[] PropName; - PropName = new char[strlen((char *)params) + 1]; - if (PropName) strcpy(PropName, (char *)params); + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); else cmd = PARSERR_GENERIC; break; case TOKEN_VALUE: - delete[] PropValue; - PropValue = new char[strlen((char *)params) + 1]; - if (PropValue) strcpy(PropValue, (char *)params); + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); else cmd = PARSERR_GENERIC; break; } } if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); return E_FAIL; } - if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); return E_FAIL; } - setEditorProp(PropName, PropValue); + setEditorProp(propName, propValue); - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; return S_OK; } diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index 15bc768bfd..73eabb5d62 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -43,11 +43,11 @@ class CBDynBuffer; class CBBase { public: bool _persistable; - HRESULT setEditorProp(const char *PropName, const char *PropValue); - const char *getEditorProp(const char *PropName, const char *InitVal = NULL); + HRESULT setEditorProp(const char *propName, const char *propValue); + const char *getEditorProp(const char *propName, const char *initVal = NULL); CBBase(TDynamicConstructor, TDynamicConstructor) {}; - HRESULT parseEditorProperty(byte *Buffer, bool Complete = true); - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent = 0); + HRESULT parseEditorProperty(byte *buffer, bool complete = true); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); CBBase(); CBGame *Game; CBBase(CBGame *GameOwner); -- cgit v1.2.3 From 616a5bbd627908a3bba981830080fd3a0bb2654e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 6 Jul 2012 18:19:09 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BDebugger --- engines/wintermute/Base/BDebugger.cpp | 42 ++++----- engines/wintermute/Base/BDebugger.h | 52 ++++++------ engines/wintermute/Base/BScriptable.cpp | 4 +- engines/wintermute/Base/BScriptable.h | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 6 +- engines/wintermute/Base/scriptables/ScEngine.h | 4 +- engines/wintermute/Base/scriptables/ScScript.cpp | 20 ++--- engines/wintermute/Base/scriptables/ScScript.h | 16 ++-- engines/wintermute/Base/scriptables/ScValue.cpp | 36 ++++---- engines/wintermute/Base/scriptables/ScValue.h | 28 +++--- engines/wintermute/wme_debugger.h | 104 +++++++++++------------ 11 files changed, 159 insertions(+), 157 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index aa4ac7cf3e..e720f8430d 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -41,12 +41,12 @@ CBDebugger::~CBDebugger(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::Initialize() { +HRESULT CBDebugger::initialize() { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::Shutdown() { +HRESULT CBDebugger::shutdown() { return S_OK; } @@ -92,18 +92,18 @@ HRESULT CBDebugger::onScriptShutdown(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptChangeLine(CScScript *Script, int Line) { +HRESULT CBDebugger::onScriptChangeLine(CScScript *script, int Line) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptChangeScope(CScScript *Script, CScValue *Scope) { +HRESULT CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptShutdownScope(CScScript *Script, CScValue *Scope) { +HRESULT CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { return S_OK; } @@ -113,7 +113,7 @@ HRESULT CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *scr } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onVariableChangeValue(CScValue *Var, CScValue *value) { +HRESULT CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { return S_OK; } @@ -124,79 +124,79 @@ HRESULT CBDebugger::onScriptHitBreakpoint(CScScript *script) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugServer interface implementation -bool CBDebugger::AttachClient(IWmeDebugClient *Client) { +bool CBDebugger::attachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::DetachClient(IWmeDebugClient *Client) { +bool CBDebugger::detachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::QueryData(IWmeDebugClient *Client) { +bool CBDebugger::queryData(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -int CBDebugger::GetPropInt(const char *PropName) { +int CBDebugger::getPropInt(const char *propName) { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBDebugger::GetPropFloat(const char *PropName) { +double CBDebugger::getPropFloat(const char *propName) { return 0.0; } ////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::GetPropString(const char *PropName) { +const char *CBDebugger::getPropString(const char *propName) { return ""; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::GetPropBool(const char *PropName) { +bool CBDebugger::getPropBool(const char *propName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, int PropValue) { +bool CBDebugger::setProp(const char *propName, int propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, double PropValue) { +bool CBDebugger::setProp(const char *propName, double propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, const char *PropValue) { +bool CBDebugger::setProp(const char *propName, const char *propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::SetProp(const char *PropName, bool PropValue) { +bool CBDebugger::setProp(const char *propName, bool propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) { +bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::AddBreakpoint(const char *ScriptFilename, int Line) { +bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::RemoveBreakpoint(const char *ScriptFilename, int Line) { +bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::ContinueExecution() { +bool CBDebugger::continueExecution() { return false; } diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index e448a72651..79f3fba816 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -33,6 +33,8 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/wme_debugger.h" +// TODO: The entire debugger should possibly be removed + namespace WinterMute { class CScScript; class CScValue; @@ -43,48 +45,48 @@ public: // initialization bool _enabled; - HRESULT Initialize(); - HRESULT Shutdown(); + HRESULT initialize(); + HRESULT shutdown(); // internal interface HRESULT onGameInit(); HRESULT onGameShutdown(); HRESULT onGameTick(); - HRESULT onLog(unsigned int ErrorCode, const char *Text); + HRESULT onLog(unsigned int errorCode, const char *text); HRESULT onScriptInit(CScScript *script); - HRESULT onScriptEventThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); - HRESULT onScriptMethodThreadInit(CScScript *Script, CScScript *ParentScript, const char *name); + HRESULT onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + HRESULT onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); HRESULT onScriptShutdown(CScScript *script); - HRESULT onScriptChangeLine(CScScript *Script, int Line); - HRESULT onScriptChangeScope(CScScript *Script, CScValue *Scope); - HRESULT onScriptShutdownScope(CScScript *Script, CScValue *Scope); - HRESULT onVariableInit(EWmeDebuggerVariableType Type, CScScript *script, CScValue *Scope, CScValue *Var, const char *VariableName); - HRESULT onVariableChangeValue(CScValue *Var, CScValue *value); + HRESULT onScriptChangeLine(CScScript *script, int line); + HRESULT onScriptChangeScope(CScScript *script, CScValue *scope); + HRESULT onScriptShutdownScope(CScScript *script, CScValue *scope); + HRESULT onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + HRESULT onVariableChangeValue(CScValue *var, CScValue *value); HRESULT onScriptHitBreakpoint(CScScript *script); // IWmeDebugServer interface - virtual bool AttachClient(IWmeDebugClient *Client); - virtual bool DetachClient(IWmeDebugClient *Client); - virtual bool QueryData(IWmeDebugClient *Client); + virtual bool attachClient(IWmeDebugClient *client); + virtual bool detachClient(IWmeDebugClient *client); + virtual bool queryData(IWmeDebugClient *client); - virtual int GetPropInt(const char *PropName); - virtual double GetPropFloat(const char *PropName); - virtual const char *GetPropString(const char *PropName); - virtual bool GetPropBool(const char *PropName); + virtual int getPropInt(const char *propName); + virtual double getPropFloat(const char *propName); + virtual const char *getPropString(const char *propName); + virtual bool getPropBool(const char *propName); - virtual bool SetProp(const char *PropName, int PropValue); - virtual bool SetProp(const char *PropName, double PropValue); - virtual bool SetProp(const char *PropName, const char *PropValue); - virtual bool SetProp(const char *PropName, bool PropValue); + virtual bool setProp(const char *propName, int propValue); + virtual bool setProp(const char *propName, double propValue); + virtual bool setProp(const char *propName, const char *propValue); + virtual bool setProp(const char *propName, bool propValue); - virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize); + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - virtual bool AddBreakpoint(const char *ScriptFilename, int Line); - virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line); + virtual bool addBreakpoint(const char *scriptFilename, int line); + virtual bool removeBreakpoint(const char *scriptFilename, int line); - virtual bool ContinueExecution(); + virtual bool continueExecution(); private: }; diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index bd0018de24..ea6aca21c2 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -176,12 +176,12 @@ CScScript *CBScriptable::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugObject ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::DbgGetNativeClass() { +const char *CBScriptable::dbgGetNativeClass() { return getClassName(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::DbgGetProperty(const char *name) { +IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { return scGetProperty(name); } diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index 742ec174a2..d0c91800f1 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -70,8 +70,8 @@ public: public: // IWmeDebugObject - const char *DbgGetNativeClass(); - IWmeDebugProp *DbgGetProperty(const char *name); + const char *dbgGetNativeClass(); + IWmeDebugProp *dbgGetProperty(const char *name); }; diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index c9c62e5dbe..781e08d0d1 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -673,7 +673,7 @@ HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { +HRESULT CScEngine::addBreakpoint(const char *ScriptFilename, int Line) { if (!Game->getDebugMgr()->_enabled) return S_OK; CScBreakpoint *Bp = NULL; @@ -700,7 +700,7 @@ HRESULT CScEngine::AddBreakpoint(const char *ScriptFilename, int Line) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RemoveBreakpoint(const char *ScriptFilename, int Line) { +HRESULT CScEngine::removeBreakpoint(const char *ScriptFilename, int Line) { if (!Game->getDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { @@ -789,7 +789,7 @@ HRESULT CScEngine::LoadBreakpoints() { char *Path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); char *Line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); - if (Path != NULL && Line != NULL) AddBreakpoint(Path, atoi(Line)); + if (Path != NULL && Line != NULL) addBreakpoint(Path, atoi(Line)); delete[] Path; delete[] Line; Path = NULL; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 42440c8a2d..3b527e4032 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -96,8 +96,8 @@ public: HRESULT DbgSendScripts(IWmeDebugClient *Client); CBArray _breakpoints; - HRESULT AddBreakpoint(const char *ScriptFilename, int Line); - HRESULT RemoveBreakpoint(const char *ScriptFilename, int Line); + HRESULT addBreakpoint(const char *ScriptFilename, int Line); + HRESULT removeBreakpoint(const char *ScriptFilename, int Line); HRESULT RefreshScriptBreakpoints(); HRESULT RefreshScriptBreakpoints(CScScript *script); HRESULT SaveBreakpoints(); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 4e59893d1d..397ebe4c24 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1552,21 +1552,21 @@ HRESULT CScScript::FinishThreads() { ////////////////////////////////////////////////////////////////////////// // IWmeDebugScript interface implementation -int CScScript::DbgGetLine() { +int CScScript::dbgGetLine() { return _currentLine; } ////////////////////////////////////////////////////////////////////////// -const char *CScScript::DbgGetFilename() { +const char *CScScript::dbgGetFilename() { return _filename; } ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { - if (_methodThread) Client->OnScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) Client->OnScriptEventThreadInit(this, _parentScript, _threadEvent); - else Client->OnScriptInit(this); + if (_methodThread) Client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) Client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else Client->onScriptInit(this); return DbgSendVariables(Client); return S_OK; @@ -1589,29 +1589,29 @@ HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { ////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::DbgGetState() { +TScriptState CScScript::dbgGetState() { return _state; } ////////////////////////////////////////////////////////////////////////// -int CScScript::DbgGetNumBreakpoints() { +int CScScript::dbgGetNumBreakpoints() { return _breakpoints.GetSize(); } ////////////////////////////////////////////////////////////////////////// -int CScScript::DbgGetBreakpoint(int Index) { +int CScScript::dbgGetBreakpoint(int Index) { if (Index >= 0 && Index < _breakpoints.GetSize()) return _breakpoints[Index]; else return -1; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::DbgSetTracingMode(bool IsTracing) { +bool CScScript::dbgSetTracingMode(bool IsTracing) { _tracingMode = IsTracing; return true; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::DbgGetTracingMode() { +bool CScScript::dbgGetTracingMode() { return _tracingMode; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 812ce0359f..12f9ae518a 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -175,14 +175,14 @@ private: // IWmeDebugScript interface implementation public: - virtual int DbgGetLine(); - virtual const char *DbgGetFilename(); - virtual TScriptState DbgGetState(); - virtual int DbgGetNumBreakpoints(); - virtual int DbgGetBreakpoint(int Index); - - virtual bool DbgSetTracingMode(bool IsTracing); - virtual bool DbgGetTracingMode(); + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); + virtual TScriptState dbgGetState(); + virtual int dbgGetNumBreakpoints(); + virtual int dbgGetBreakpoint(int Index); + + virtual bool dbgSetTracingMode(bool IsTracing); + virtual bool dbgGetTracingMode(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index d762f14feb..5e7f3fbbc1 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -864,7 +864,7 @@ int CScValue::compareStrict(CScValue *val1, CScValue *val2) { HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *script, unsigned int ScopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - Client->OnVariableInit(Type, script, ScopeID, _valIter->_value, _valIter->_key.c_str()); + Client->onVariableInit(Type, script, ScopeID, _valIter->_value, _valIter->_key.c_str()); _valIter++; } return S_OK; @@ -917,7 +917,7 @@ bool CScValue::setProperty(const char *propName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugProp ////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::DbgGetType() { +EWmeDebuggerPropType CScValue::dbgGetType() { switch (getType()) { case VAL_NULL: return WME_DBGPROP_NULL; @@ -939,70 +939,70 @@ EWmeDebuggerPropType CScValue::DbgGetType() { } ////////////////////////////////////////////////////////////////////////// -int CScValue::DbgGetValInt() { +int CScValue::dbgGetValInt() { return getInt(); } ////////////////////////////////////////////////////////////////////////// -double CScValue::DbgGetValFloat() { +double CScValue::dbgGetValFloat() { return getFloat(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetValBool() { +bool CScValue::dbgGetValBool() { return getBool(); } ////////////////////////////////////////////////////////////////////////// -const char *CScValue::DbgGetValString() { +const char *CScValue::dbgGetValString() { return getString(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::DbgGetValNative() { +IWmeDebugObject *CScValue::dbgGetValNative() { return getNative(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(int value) { +bool CScValue::dbgSetVal(int value) { setInt(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(double value) { +bool CScValue::dbgSetVal(double value) { setFloat(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(bool value) { +bool CScValue::dbgSetVal(bool value) { setBool(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal(const char *value) { +bool CScValue::dbgSetVal(const char *value) { setString(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgSetVal() { +bool CScValue::dbgSetVal() { setNULL(); return true; } ////////////////////////////////////////////////////////////////////////// -int CScValue::DbgGetNumProperties() { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetNumProperties(); +int CScValue::dbgGetNumProperties() { + if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetNumProperties(); else return _valObject.size(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->DbgGetProperty(index, name, value); +bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetProperty(index, name, value); else { int count = 0; _valIter = _valObject.begin(); @@ -1020,8 +1020,8 @@ bool CScValue::DbgGetProperty(int index, const char **name, IWmeDebugProp **valu } ////////////////////////////////////////////////////////////////////////// -bool CScValue::DbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) return _valRef->DbgGetDescription(buf, bufSize); +bool CScValue::dbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) return _valRef->dbgGetDescription(buf, bufSize); if (_type == VAL_NATIVE) { _valNative->scDebuggerDesc(buf, bufSize); diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 887a39e50f..bad5b18e84 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -113,27 +113,27 @@ public: // IWmeDebugProp interface implementation public: - virtual EWmeDebuggerPropType DbgGetType(); + virtual EWmeDebuggerPropType dbgGetType(); // getters - virtual int DbgGetValInt(); - virtual double DbgGetValFloat(); - virtual bool DbgGetValBool(); - virtual const char *DbgGetValString(); - virtual IWmeDebugObject *DbgGetValNative(); + virtual int dbgGetValInt(); + virtual double dbgGetValFloat(); + virtual bool dbgGetValBool(); + virtual const char *dbgGetValString(); + virtual IWmeDebugObject *dbgGetValNative(); // setters - virtual bool DbgSetVal(int Value); - virtual bool DbgSetVal(double Value); - virtual bool DbgSetVal(bool Value); - virtual bool DbgSetVal(const char *Value); - virtual bool DbgSetVal(); + virtual bool dbgSetVal(int Value); + virtual bool dbgSetVal(double Value); + virtual bool dbgSetVal(bool Value); + virtual bool dbgSetVal(const char *Value); + virtual bool dbgSetVal(); // properties - virtual int DbgGetNumProperties(); - virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); + virtual int dbgGetNumProperties(); + virtual bool dbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); - virtual bool DbgGetDescription(char *Buf, int BufSize); + virtual bool dbgGetDescription(char *Buf, int BufSize); }; } // end of namespace WinterMute diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h index e6cc39a73b..75f57339db 100644 --- a/engines/wintermute/wme_debugger.h +++ b/engines/wintermute/wme_debugger.h @@ -65,102 +65,102 @@ EWmeDebuggerVariableType; class IWmeDebugScript { public: virtual ~IWmeDebugScript() {} - virtual int DbgGetLine() = 0; - virtual const char *DbgGetFilename() = 0; - virtual TScriptState DbgGetState() = 0; + virtual int dbgGetLine() = 0; + virtual const char *dbgGetFilename() = 0; + virtual TScriptState dbgGetState() = 0; - virtual int DbgGetNumBreakpoints() = 0; - virtual int DbgGetBreakpoint(int Index) = 0; + virtual int dbgGetNumBreakpoints() = 0; + virtual int dbgGetBreakpoint(int index) = 0; - virtual bool DbgSetTracingMode(bool IsTracing) = 0; - virtual bool DbgGetTracingMode() = 0; + virtual bool dbgSetTracingMode(bool isTracing) = 0; + virtual bool dbgGetTracingMode() = 0; }; ////////////////////////////////////////////////////////////////////////// class IWmeDebugProp { public: - virtual EWmeDebuggerPropType DbgGetType() = 0; + virtual EWmeDebuggerPropType dbgGetType() = 0; virtual ~IWmeDebugProp() {} // getters - virtual int DbgGetValInt() = 0; - virtual double DbgGetValFloat() = 0; - virtual bool DbgGetValBool() = 0; - virtual const char *DbgGetValString() = 0; - virtual IWmeDebugObject *DbgGetValNative() = 0; + virtual int dbgGetValInt() = 0; + virtual double dbgGetValFloat() = 0; + virtual bool dbgGetValBool() = 0; + virtual const char *dbgGetValString() = 0; + virtual IWmeDebugObject *dbgGetValNative() = 0; // setters - virtual bool DbgSetVal(int Value) = 0; - virtual bool DbgSetVal(double Value) = 0; - virtual bool DbgSetVal(bool Value) = 0; - virtual bool DbgSetVal(const char *Value) = 0; - virtual bool DbgSetVal() = 0; + virtual bool dbgSetVal(int value) = 0; + virtual bool dbgSetVal(double value) = 0; + virtual bool dbgSetVal(bool value) = 0; + virtual bool dbgSetVal(const char *value) = 0; + virtual bool dbgSetVal() = 0; // properties - virtual int DbgGetNumProperties() = 0; - virtual bool DbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value) = 0; + virtual int dbgGetNumProperties() = 0; + virtual bool dbgGetProperty(int index, const char **name, IWmeDebugProp **value) = 0; - virtual bool DbgGetDescription(char *Buf, int BufSize) = 0; + virtual bool dbgGetDescription(char *buf, int bufSize) = 0; }; ////////////////////////////////////////////////////////////////////////// class IWmeDebugObject { public: virtual ~IWmeDebugObject() {} - virtual const char *DbgGetNativeClass() = 0; - virtual IWmeDebugProp *DbgGetProperty(const char *name) = 0; + virtual const char *dbgGetNativeClass() = 0; + virtual IWmeDebugProp *dbgGetProperty(const char *name) = 0; }; ////////////////////////////////////////////////////////////////////////// class IWmeDebugClient { public: virtual ~IWmeDebugClient() {} - virtual bool OnGameInit() = 0; - virtual bool OnGameShutdown() = 0; + virtual bool onGameInit() = 0; + virtual bool onGameShutdown() = 0; - virtual bool OnGameTick() = 0; + virtual bool onGameTick() = 0; - virtual bool OnLog(unsigned int ErrorCode, const char *Text) = 0; + virtual bool onLog(unsigned int errorCode, const char *text) = 0; - virtual bool OnScriptInit(IWmeDebugScript *Script) = 0; - virtual bool OnScriptEventThreadInit(IWmeDebugScript *Script, IWmeDebugScript *ParentScript, const char *EventName) = 0; - virtual bool OnScriptMethodThreadInit(IWmeDebugScript *Script, IWmeDebugScript *ParentScript, const char *MethodName) = 0; - virtual bool OnScriptShutdown(IWmeDebugScript *Script) = 0; - virtual bool OnScriptChangeLine(IWmeDebugScript *Script, int Line) = 0; - virtual bool OnScriptChangeScope(IWmeDebugScript *Script, unsigned int ScopeID) = 0; - virtual bool OnScriptShutdownScope(IWmeDebugScript *Script, unsigned int ScopeID) = 0; + virtual bool onScriptInit(IWmeDebugScript *script) = 0; + virtual bool onScriptEventThreadInit(IWmeDebugScript *script, IWmeDebugScript *ParentScript, const char *EventName) = 0; + virtual bool onScriptMethodThreadInit(IWmeDebugScript *script, IWmeDebugScript *ParentScript, const char *MethodName) = 0; + virtual bool onScriptShutdown(IWmeDebugScript *script) = 0; + virtual bool onScriptChangeLine(IWmeDebugScript *script, int Line) = 0; + virtual bool onScriptChangeScope(IWmeDebugScript *script, unsigned int scopeID) = 0; + virtual bool onScriptShutdownScope(IWmeDebugScript *script, unsigned int scopeID) = 0; - virtual bool OnVariableInit(EWmeDebuggerVariableType Type, IWmeDebugScript *Script, unsigned int ScopeID, IWmeDebugProp *Variable, const char *VariableName) = 0; - virtual bool OnVariableChangeValue(IWmeDebugProp *Variable, IWmeDebugProp *Value) = 0; + virtual bool onVariableInit(EWmeDebuggerVariableType Type, IWmeDebugScript *script, unsigned int scopeID, IWmeDebugProp *variable, const char *variableName) = 0; + virtual bool onVariableChangeValue(IWmeDebugProp *variable, IWmeDebugProp *value) = 0; - virtual bool OnScriptHitBreakpoint(IWmeDebugScript *Script, int Line) = 0; + virtual bool onScriptHitBreakpoint(IWmeDebugScript *script, int line) = 0; }; ////////////////////////////////////////////////////////////////////////// class IWmeDebugServer { public: virtual ~IWmeDebugServer() {} - virtual bool AttachClient(IWmeDebugClient *Client) = 0; - virtual bool DetachClient(IWmeDebugClient *Client) = 0; + virtual bool attachClient(IWmeDebugClient *client) = 0; + virtual bool detachClient(IWmeDebugClient *client) = 0; - virtual bool QueryData(IWmeDebugClient *Client) = 0; + virtual bool queryData(IWmeDebugClient *client) = 0; - virtual int GetPropInt(const char *PropName) = 0; - virtual double GetPropFloat(const char *PropName) = 0; - virtual const char *GetPropString(const char *PropName) = 0; - virtual bool GetPropBool(const char *PropName) = 0; + virtual int getPropInt(const char *propName) = 0; + virtual double getPropFloat(const char *propName) = 0; + virtual const char *getPropString(const char *propName) = 0; + virtual bool getPropBool(const char *propName) = 0; - virtual bool SetProp(const char *PropName, int PropValue) = 0; - virtual bool SetProp(const char *PropName, double PropValue) = 0; - virtual bool SetProp(const char *PropName, const char *PropValue) = 0; - virtual bool SetProp(const char *PropName, bool PropValue) = 0; + virtual bool setProp(const char *propName, int propValue) = 0; + virtual bool setProp(const char *propName, double propValue) = 0; + virtual bool setProp(const char *propName, const char *propValue) = 0; + virtual bool setProp(const char *propName, bool propValue) = 0; - virtual bool ResolveFilename(const char *RelativeFilename, char *AbsFilenameBuf, int AbsBufSize) = 0; + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) = 0; - virtual bool AddBreakpoint(const char *ScriptFilename, int Line) = 0; - virtual bool RemoveBreakpoint(const char *ScriptFilename, int Line) = 0; + virtual bool addBreakpoint(const char *scriptFilename, int line) = 0; + virtual bool removeBreakpoint(const char *scriptFilename, int line) = 0; - virtual bool ContinueExecution() = 0; + virtual bool continueExecution() = 0; }; -- cgit v1.2.3 From bd3632fb4dfa1f4a815a9dc793f0ac7deb0413ce Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 6 Jul 2012 18:58:12 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName->varName in BDynBuffer, BFader and BFileManager. --- engines/wintermute/Base/BDynBuffer.cpp | 6 +- engines/wintermute/Base/BDynBuffer.h | 2 +- engines/wintermute/Base/BFader.cpp | 32 +++---- engines/wintermute/Base/BFader.h | 4 +- engines/wintermute/Base/BFileManager.cpp | 150 +++++++++++++++---------------- engines/wintermute/Base/BFileManager.h | 14 +-- 6 files changed, 103 insertions(+), 105 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index 7a4a5afeec..25bf9be93d 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -164,7 +164,7 @@ void CBDynBuffer::putText(LPCSTR fmt, ...) { va_list va; va_start(va, fmt); - PutTextForm(fmt, va); + putTextForm(fmt, va); va_end(va); } @@ -177,13 +177,13 @@ void CBDynBuffer::putTextIndent(int indent, LPCSTR fmt, ...) { putText("%*s", indent, ""); va_start(va, fmt); - PutTextForm(fmt, va); + putTextForm(fmt, va); va_end(va); } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::PutTextForm(const char *format, va_list argptr) { +void CBDynBuffer::putTextForm(const char *format, va_list argptr) { char buff[32768]; vsprintf(buff, format, argptr); putBytes((byte *)buff, strlen(buff)); diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index 4d11b2fe6a..1fd8fa6748 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -58,7 +58,7 @@ private: uint32 _growBy; uint32 _initSize; uint32 _offset; - void PutTextForm(const char *format, va_list argptr); + void putTextForm(const char *format, va_list argptr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index 55937dbcfa..2f6a79028f 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -63,7 +63,7 @@ CBFader::~CBFader() { HRESULT CBFader::update() { if (!_active) return S_OK; - int AlphaDelta = _targetAlpha - _sourceAlpha; + int alphaDelta = _targetAlpha - _sourceAlpha; uint32 time; @@ -72,7 +72,7 @@ HRESULT CBFader::update() { if (time >= _duration) _currentAlpha = _targetAlpha; else { - _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * AlphaDelta); + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); } _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean @@ -101,19 +101,19 @@ HRESULT CBFader::deactivate() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::fadeIn(uint32 SourceColor, uint32 Duration, bool System) { +HRESULT CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _ready = false; _active = true; - _red = D3DCOLGetR(SourceColor); - _green = D3DCOLGetG(SourceColor); - _blue = D3DCOLGetB(SourceColor); + _red = D3DCOLGetR(sourceColor); + _green = D3DCOLGetG(sourceColor); + _blue = D3DCOLGetB(sourceColor); - _sourceAlpha = D3DCOLGetA(SourceColor); + _sourceAlpha = D3DCOLGetA(sourceColor); _targetAlpha = 0; - _duration = Duration; - _system = System; + _duration = duration; + _system = system; if (_system) _startTime = CBPlatform::GetTime(); else _startTime = Game->_timer; @@ -123,20 +123,20 @@ HRESULT CBFader::fadeIn(uint32 SourceColor, uint32 Duration, bool System) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::fadeOut(uint32 TargetColor, uint32 Duration, bool System) { +HRESULT CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _ready = false; _active = true; - _red = D3DCOLGetR(TargetColor); - _green = D3DCOLGetG(TargetColor); - _blue = D3DCOLGetB(TargetColor); + _red = D3DCOLGetR(targetColor); + _green = D3DCOLGetG(targetColor); + _blue = D3DCOLGetB(targetColor); //_sourceAlpha = 0; _sourceAlpha = _currentAlpha; - _targetAlpha = D3DCOLGetA(TargetColor); + _targetAlpha = D3DCOLGetA(targetColor); - _duration = Duration; - _system = System; + _duration = duration; + _system = system; if (_system) _startTime = CBPlatform::GetTime(); else _startTime = Game->_timer; diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h index 8a98bea8fe..b42feae43f 100644 --- a/engines/wintermute/Base/BFader.h +++ b/engines/wintermute/Base/BFader.h @@ -38,8 +38,8 @@ class CBFader : public CBObject { public: bool _system; uint32 getCurrentColor(); - HRESULT fadeOut(uint32 TargetColor, uint32 Duration, bool System = false); - HRESULT fadeIn(uint32 SourceColor, uint32 Duration, bool System = false); + HRESULT fadeOut(uint32 targetColor, uint32 duration, bool system = false); + HRESULT fadeIn(uint32 sourceColor, uint32 duration, bool system = false); HRESULT deactivate(); HRESULT display(); HRESULT update(); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 7fcdb2e26b..7afe2e8e40 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -74,14 +74,12 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// HRESULT CBFileManager::cleanup() { - int i; - // delete registered paths - for (i = 0; i < _singlePaths.GetSize(); i++) + for (int i = 0; i < _singlePaths.GetSize(); i++) delete [] _singlePaths[i]; _singlePaths.RemoveAll(); - for (i = 0; i < _packagePaths.GetSize(); i++) + for (int i = 0; i < _packagePaths.GetSize(); i++) delete [] _packagePaths[i]; _packagePaths.RemoveAll(); @@ -95,14 +93,14 @@ HRESULT CBFileManager::cleanup() { _files.clear(); // close open files - for (i = 0; i < _openFiles.GetSize(); i++) { + for (int i = 0; i < _openFiles.GetSize(); i++) { delete _openFiles[i]; } _openFiles.RemoveAll(); // delete packages - for (i = 0; i < _packages.GetSize(); i++) + for (int i = 0; i < _packages.GetSize(); i++) delete _packages[i]; _packages.RemoveAll(); @@ -116,13 +114,13 @@ HRESULT CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *Size, bool MustExist) { +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; - Common::SeekableReadStream *File = openFile(filename); - if (!File) { - if (MustExist) Game->LOG(0, "Error opening file '%s'", filename.c_str()); + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) Game->LOG(0, "Error opening file '%s'", filename.c_str()); return NULL; } @@ -135,23 +133,23 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *Size, */ - buffer = new byte[File->size() + 1]; + buffer = new byte[file->size() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), File->size() + 1); - closeFile(File); + Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); return NULL; } - if (File->read(buffer, File->size()) != File->size()) { + if (file->read(buffer, file->size()) != file->size()) { Game->LOG(0, "Error reading file '%s'", filename.c_str()); - closeFile(File); + closeFile(file); delete [] buffer; return NULL; }; - buffer[File->size()] = '\0'; - if (Size != NULL) *Size = File->size(); - closeFile(File); + buffer[file->size()] = '\0'; + if (size != NULL) *size = file->size(); + closeFile(file); return buffer; } @@ -226,7 +224,7 @@ HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, ui ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::requestCD(int CD, char *PackageFile, char *Filename) { +HRESULT CBFileManager::requestCD(int cd, char *packageFile, char *filename) { // unmount all non-local packages for (int i = 0; i < _packages.GetSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); @@ -238,19 +236,19 @@ HRESULT CBFileManager::requestCD(int CD, char *PackageFile, char *Filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::addPath(TPathType Type, const Common::String &Path) { - if (Path.c_str() == NULL || strlen(Path.c_str()) < 1) return E_FAIL; +HRESULT CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return E_FAIL; - bool slashed = (Path[Path.size() - 1] == '\\' || Path[Path.size() - 1] == '/'); + bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - char *buffer = new char [strlen(Path.c_str()) + 1 + (slashed ? 0 : 1)]; + char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; if (buffer == NULL) return E_FAIL; - strcpy(buffer, Path.c_str()); + strcpy(buffer, path.c_str()); if (!slashed) strcat(buffer, "\\"); //CBPlatform::strlwr(buffer); - switch (Type) { + switch (type) { case PATH_SINGLE: _singlePaths.Add(buffer); break; @@ -405,8 +403,8 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea return S_OK; } - uint32 AbsoluteOffset = 0; - bool BoundToExe = false; + uint32 absoluteOffset = 0; + bool boundToExe = false; if (searchSignature) { uint32 Offset; @@ -415,8 +413,8 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea return S_OK; } else { package->seek(Offset, SEEK_SET); - AbsoluteOffset = Offset; - BoundToExe = true; + absoluteOffset = Offset; + boundToExe = true; } } @@ -435,17 +433,17 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea // new in v2 if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 DirOffset; - DirOffset = package->readUint32LE(); - DirOffset += AbsoluteOffset; - package->seek(DirOffset, SEEK_SET); + uint32 dirOffset; + dirOffset = package->readUint32LE(); + dirOffset += absoluteOffset; + package->seek(dirOffset, SEEK_SET); } for (uint32 i = 0; i < hdr.NumDirs; i++) { CBPackage *pkg = new CBPackage(Game); if (!pkg) return E_FAIL; - pkg->_boundToExe = BoundToExe; + pkg->_boundToExe = boundToExe; // read package info byte nameLength = package->readByte(); @@ -463,7 +461,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea for (uint32 j = 0; j < NumFiles; j++) { char *name; - uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; nameLength = package->readByte(); name = new char[nameLength]; @@ -483,34 +481,34 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea CBPlatform::strupr(name); - Offset = package->readUint32LE(); - Offset += AbsoluteOffset; - Length = package->readUint32LE(); - CompLength = package->readUint32LE(); - Flags = package->readUint32LE(); + offset = package->readUint32LE(); + offset += absoluteOffset; + length = package->readUint32LE(); + compLength = package->readUint32LE(); + flags = package->readUint32LE(); if (hdr.PackageVersion == PACKAGE_VERSION) { - TimeDate1 = package->readUint32LE(); - TimeDate2 = package->readUint32LE(); + timeDate1 = package->readUint32LE(); + timeDate2 = package->readUint32LE(); } _filesIter = _files.find(name); if (_filesIter == _files.end()) { CBFileEntry *file = new CBFileEntry(Game); file->_package = pkg; - file->_offset = Offset; - file->_length = Length; - file->_compressedLength = CompLength; - file->_flags = Flags; + file->_offset = offset; + file->_length = length; + file->_compressedLength = compLength; + file->_flags = flags; _files[name] = file; } else { // current package has lower CD number or higher priority, than the registered if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = Offset; - _filesIter->_value->_length = Length; - _filesIter->_value->_compressedLength = CompLength; - _filesIter->_value->_flags = Flags; + _filesIter->_value->_offset = offset; + _filesIter->_value->_length = length; + _filesIter->_value->_compressedLength = compLength; + _filesIter->_value->_flags = flags; } } delete [] name; @@ -719,15 +717,15 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *Fullname) { +bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { restoreCurrentDir(); Common::File f; bool found = false; for (int i = 0; i < _singlePaths.GetSize(); i++) { - sprintf(Fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(Fullname); + sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); + f.open(fullname); if (f.isOpen()) { f.close(); found = true; @@ -740,7 +738,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *Fullname) if (f.isOpen()) { f.close(); found = true; - strcpy(Fullname, filename.c_str()); + strcpy(fullname, filename.c_str()); } } @@ -749,9 +747,9 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *Fullname) ////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &Filename) { - char *upc_name = new char[strlen(Filename.c_str()) + 1]; - strcpy(upc_name, Filename.c_str()); +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { + char *upc_name = new char[strlen(filename.c_str()) + 1]; + strcpy(upc_name, filename.c_str()); CBPlatform::strupr(upc_name); CBFileEntry *ret = NULL; @@ -774,7 +772,7 @@ bool CBFileManager::hasFile(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool AbsPathWarning, bool keepTrackOf) { +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; //Game->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ @@ -850,12 +848,12 @@ HRESULT CBFileManager::restoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::setBasePath(const Common::String &Path) { +HRESULT CBFileManager::setBasePath(const Common::String &path) { cleanup(); - if (Path.c_str()) { - _basePath = new char[Path.size() + 1]; - strcpy(_basePath, Path.c_str()); + if (path.c_str()) { + _basePath = new char[path.size() + 1]; + strcpy(_basePath, path.c_str()); } initPaths(); @@ -866,33 +864,33 @@ HRESULT CBFileManager::setBasePath(const Common::String &Path) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *Offset) { +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { byte buf[32768]; - byte Signature[8]; - ((uint32 *)Signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)Signature)[1] = PACKAGE_MAGIC_2; + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - uint32 FileSize = f->size(); + uint32 fileSize = f->size(); - int StartPos = 1024 * 1024; + int startPos = 1024 * 1024; - uint32 BytesRead = StartPos; + uint32 bytesRead = startPos; - while (BytesRead < FileSize - 16) { - int ToRead = MIN((unsigned int)32768, FileSize - BytesRead); - f->seek(StartPos, SEEK_SET); + while (bytesRead < fileSize - 16) { + int ToRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek(startPos, SEEK_SET); int ActuallyRead = f->read(buf, ToRead); if (ActuallyRead != ToRead) return false; for (int i = 0; i < ToRead - 8; i++) - if (!memcmp(buf + i, Signature, 8)) { - *Offset = StartPos + i; + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; return true; } - BytesRead = BytesRead + ToRead - 16; - StartPos = StartPos + ToRead - 16; + bytesRead = bytesRead + ToRead - 16; + startPos = startPos + ToRead - 16; } return false; diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 0ca9090a04..1b5c50c127 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -42,7 +42,7 @@ namespace WinterMute { class CBFile; class CBFileManager: CBBase { public: - bool findPackageSignature(Common::File *f, uint32 *Offset); + bool findPackageSignature(Common::File *f, uint32 *offset); HRESULT cleanup(); HRESULT setBasePath(const Common::String &path); HRESULT restoreCurrentDir(); @@ -61,11 +61,11 @@ public: typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - HRESULT addPath(TPathType Type, const Common::String &path); - HRESULT requestCD(int CD, char *PackageFile, char *Filename); + HRESULT addPath(TPathType type, const Common::String &path); + HRESULT requestCD(int cd, char *packageFile, char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - HRESULT saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed = false, byte *PrefixBuffer = NULL, uint32 PrefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *Size = NULL, bool MustExist = true); + HRESULT saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); CBArray _singlePaths; @@ -75,8 +75,8 @@ public: Common::HashMap _files; private: - HRESULT registerPackage(const char *Path, const char *Name, bool SearchSignature = false); - HRESULT registerPackage(const Common::String &filename, bool SearchSignature = false); + HRESULT registerPackage(const char *path, const char *name, bool searchSignature = false); + HRESULT registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; -- cgit v1.2.3 From d4c57e6d98700fae6f781d967b7e3c9043248731 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 6 Jul 2012 19:14:17 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BFont and BFontBitmap. Also adjust a few "byte *" to "byte *" --- engines/wintermute/Ad/AdActor.h | 2 +- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdGame.h | 2 +- engines/wintermute/Ad/AdTalkDef.h | 2 +- engines/wintermute/Base/BFont.cpp | 34 +++---- engines/wintermute/Base/BFont.h | 10 +-- engines/wintermute/Base/BFontBitmap.cpp | 120 ++++++++++++------------- engines/wintermute/Base/BFontBitmap.h | 12 +-- engines/wintermute/Base/BFontTT.cpp | 6 +- engines/wintermute/Base/BFontTT.h | 6 +- engines/wintermute/Base/BFrame.cpp | 2 +- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BPersistMgr.h | 4 +- engines/wintermute/Base/BScriptHolder.h | 2 +- engines/wintermute/Base/BSprite.h | 2 +- engines/wintermute/Base/BSubFrame.cpp | 2 +- engines/wintermute/Base/BSubFrame.h | 2 +- engines/wintermute/Base/scriptables/ScEngine.h | 2 +- engines/wintermute/UI/UIEntity.h | 2 +- engines/wintermute/graphics/tga.cpp | 2 +- 21 files changed, 110 insertions(+), 110 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index ab07bf3e77..7ff65a0cae 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -68,7 +68,7 @@ public: CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); // new anim system Common::String _talkAnimName; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index c890033e18..2e8e77d36e 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1373,7 +1373,7 @@ HRESULT CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +HRESULT CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { CBGame::getVersion(verMajor, verMinor, NULL, NULL); if (extMajor) *extMajor = 0; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index df4d26eaf5..4eef4b8df4 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -144,7 +144,7 @@ public: virtual HRESULT loadBuffer(byte *buffer, bool complete = true); HRESULT loadItemsFile(const char *filename, bool merge = false); - HRESULT loadItemsBuffer(byte *buffer, bool merge = false); + HRESULT loadItemsBuffer(byte *buffer, bool merge = false); virtual void PublishNatives(); diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 46bcd0da9c..91d1c218e2 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -46,7 +46,7 @@ public: CAdTalkDef(CBGame *inGame); virtual ~CAdTalkDef(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + HRESULT loadBuffer(byte *buffer, bool complete = true); CBArray _nodes; char *_defaultSpriteFilename; CBSprite *_defaultSprite; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 6158ac6430..490b4be35d 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -54,18 +54,18 @@ CBFont::~CBFont() { ////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { +int CBFont::getTextHeight(byte *text, int width) { return 0; } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int MaxLenght) { +int CBFont::getTextWidth(byte *text, int maxLength) { return 0; } @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::loadBuffer(byte * Buffer) +HRESULT CBFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -154,23 +154,23 @@ HRESULT CBFont::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { if (isTrueType(Game, filename)) { - CBFontTT *Font = new CBFontTT(Game); - if (Font) { - if (FAILED(Font->loadFile(filename))) { - delete Font; + CBFontTT *font = new CBFontTT(Game); + if (font) { + if (FAILED(font->loadFile(filename))) { + delete font; return NULL; } } - return Font; + return font; } else { - CBFontBitmap *Font = new CBFontBitmap(Game); - if (Font) { - if (FAILED(Font->loadFile(filename))) { - delete Font; + CBFontBitmap *font = new CBFontBitmap(Game); + if (font) { + if (FAILED(font->loadFile(filename))) { + delete font; return NULL; } } - return Font; + return font; } } @@ -195,12 +195,12 @@ bool CBFont::isTrueType(CBGame *Game, const char *filename) { char *params; CBParser parser(Game); - bool Ret = false; + bool ret = false; if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - Ret = true; + ret = true; delete [] buffer; - return Ret; + return ret; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index 93bc426ed9..0c7e1950b1 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -38,9 +38,9 @@ namespace WinterMute { class CBFont: public CBObject { public: DECLARE_PERSISTENT(CBFont, CBObject) - virtual int getTextWidth(byte *text, int MaxLenght = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); virtual void initLoop() {}; @@ -48,12 +48,12 @@ public: CBFont(CBGame *inGame); virtual ~CBFont(); - static CBFont *createFromFile(CBGame *Game, const char *filename); + static CBFont *createFromFile(CBGame *game, const char *filename); private: //HRESULT loadBuffer(byte * Buffer); //HRESULT loadFile(const char* Filename); - static bool isTrueType(CBGame *Game, const char *filename); + static bool isTrueType(CBGame *game, const char *filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 714b66f990..4f60dea478 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -70,19 +70,19 @@ CBFontBitmap::~CBFontBitmap() { ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int MaxLenght) { - textHeightDraw(text, x, y, width, align, true, max_height, MaxLenght); +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { +int CBFontBitmap::getTextHeight(byte *text, int width) { return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int MaxLength) { +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { AnsiString str; if (Game->_textEncoding == TEXT_UTF8) { @@ -92,22 +92,22 @@ int CBFontBitmap::getTextWidth(byte *text, int MaxLength) { str = AnsiString((char *)text); } - if (MaxLength >= 0 && str.size() > MaxLength) - str = Common::String(str.c_str(), MaxLength); - //str.substr(0, MaxLength); // TODO: Remove + if (maxLength >= 0 && str.size() > maxLength) + str = Common::String(str.c_str(), maxLength); + //str.substr(0, maxLength); // TODO: Remove - int TextWidth = 0; + int textWidth = 0; for (size_t i = 0; i < str.size(); i++) { - TextWidth += getCharWidth(str[i]); + textWidth += getCharWidth(str[i]); } - return TextWidth; + return textWidth; } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height, int MaxLenght) { - if (MaxLenght == 0) return 0; +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; if (text == NULL || text[0] == '\0') return _tileHeight; @@ -141,14 +141,14 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlig if (draw) Game->_renderer->startSpriteBatch(); while (!done) { - if (max_height > 0 && (NumLines + 1)*_tileHeight > max_height) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { if (draw) Game->_renderer->endSpriteBatch(); return NumLines * _tileHeight; } index++; - if (str[index] == ' ' && (max_height < 0 || max_height / _tileHeight > 1)) { + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { end = index - 1; RealLength = LineLength; } @@ -166,7 +166,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlig long_line = true; } - if (str.size() == (index + 1) || (MaxLenght >= 0 && index == MaxLenght - 1)) { + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { done = true; if (!new_line) { end = index; @@ -215,7 +215,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlig ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { +void CBFontBitmap::drawChar(byte c, int x, int y) { if (_fontextFix) c--; int row, col; @@ -225,22 +225,22 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { RECT rect; /* l t r b */ - int TileWidth; - if (_wholeCell) TileWidth = _tileWidth; - else TileWidth = _widths[c]; + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; - CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + TileWidth, (row + 1)*_tileHeight); - bool Handled = false; + CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; if (_sprite) { _sprite->GetCurrentFrame(); if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); } - Handled = true; + handled = true; } } - if (!Handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); } @@ -316,37 +316,37 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { int widths[300]; int num = 0, default_width = 8; - int last_width = 0; + int lastWidth = 0; int i; int r = 255, g = 255, b = 255; - bool custo_trans = false; - char *surface_file = NULL; - char *sprite_file = NULL; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; - bool AutoWidth = false; - int SpaceWidth = 0; - int ExpandWidth = 0; + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: - surface_file = (char *)params; + surfaceFile = (char *)params; break; case TOKEN_SPRITE: - sprite_file = (char *)params; + spriteFile = (char *)params; break; case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; + custoTrans = true; break; case TOKEN_WIDTHS: parser.ScanStr(params, "%D", widths, &num); - for (i = 0; last_width < NUM_CHARACTERS, num > 0; last_width++, num--, i++) { - _widths[last_width] = (byte)widths[i]; + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; } break; @@ -371,7 +371,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_AUTO_WIDTH: - parser.ScanStr(params, "%b", &AutoWidth); + parser.ScanStr(params, "%b", &autoWidth); break; case TOKEN_FONTEXT_FIX: @@ -383,11 +383,11 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_SPACE_WIDTH: - parser.ScanStr(params, "%d", &SpaceWidth); + parser.ScanStr(params, "%d", &spaceWidth); break; case TOKEN_EXPAND_WIDTH: - parser.ScanStr(params, "%d", &ExpandWidth); + parser.ScanStr(params, "%d", &expandWidth); break; case TOKEN_EDITOR_PROPERTY: @@ -401,19 +401,19 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { return E_FAIL; } - if (sprite_file != NULL) { + if (spriteFile != NULL) { delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->loadFile(sprite_file))) { + if (!_sprite || FAILED(_sprite->loadFile(spriteFile))) { delete _sprite; _sprite = NULL; } } - if (surface_file != NULL && !_sprite) { + if (surfaceFile != NULL && !_sprite) { _subframe = new CBSubFrame(Game); - if (custo_trans) _subframe->setSurface(surface_file, false, r, g, b); - else _subframe->setSurface(surface_file); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); } @@ -422,14 +422,14 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { return E_FAIL; } - if (AutoWidth) { + if (autoWidth) { // calculate characters width getWidths(); // do we need to modify widths? - if (ExpandWidth != 0) { + if (expandWidth != 0) { for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + ExpandWidth; + int NewWidth = (int)_widths[i] + expandWidth; if (NewWidth < 0) NewWidth = 0; _widths[i] = (byte)NewWidth; @@ -437,17 +437,17 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { } // handle space character - char SpaceChar = ' '; - if (_fontextFix) SpaceChar--; + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; - if (SpaceWidth != 0) _widths[SpaceChar] = SpaceWidth; + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; else { - if (_widths[SpaceChar] == ExpandWidth || _widths[SpaceChar] == 0) { - _widths[SpaceChar] = (_widths['m'] + _widths['i']) / 2; + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; } } } else { - for (i = last_width; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; } @@ -482,9 +482,9 @@ HRESULT CBFontBitmap::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte Index) { - if (_fontextFix) Index--; - return _widths[Index]; +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; } @@ -508,20 +508,20 @@ HRESULT CBFontBitmap::getWidths() { int yyy = (i / _numColumns) * _tileHeight; - int min_col = -1; + int minCol = -1; for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= min_col + 1; col--) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; - min_col = MAX(col, min_col); + minCol = MAX(col, minCol); break; } } - if (min_col == _tileWidth - 1) break; + if (minCol == _tileWidth - 1) break; } - _widths[i] = min_col + 1; + _widths[i] = minCol + 1; } surf->endPixelOp(); /* diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h index c1ccddd3bf..aba1690db5 100644 --- a/engines/wintermute/Base/BFontBitmap.h +++ b/engines/wintermute/Base/BFontBitmap.h @@ -37,11 +37,11 @@ class CBSubFrame; class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) - HRESULT loadBuffer(byte *Buffer); + HRESULT loadBuffer(byte *Buffer); HRESULT loadFile(const char *filename); - virtual int getTextWidth(byte *text, int MaxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int MaxLenght = -1); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); CBFontBitmap(CBGame *inGame); @@ -60,10 +60,10 @@ public: bool _wholeCell; private: - int getCharWidth(byte Index); + int getCharWidth(byte index); void drawChar(byte c, int x, int y); - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLenght = -1); + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); }; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index ed8a1c7771..4f6aff43b6 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -121,7 +121,7 @@ void CBFontTT::initLoop() { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *Text, int MaxLength) { +int CBFontTT::getTextWidth(byte *Text, int MaxLength) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); @@ -138,7 +138,7 @@ int CBFontTT::getTextWidth(byte *Text, int MaxLength) { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *Text, int Width) { +int CBFontTT::getTextHeight(byte *Text, int Width) { WideString text; if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); @@ -153,7 +153,7 @@ int CBFontTT::getTextHeight(byte *Text, int Width) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { +void CBFontTT::drawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { if (Text == NULL || strcmp((char *)Text, "") == 0) return; WideString text = (char *)Text; diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 9ae713f6f4..7fefaad9df 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -118,9 +118,9 @@ public: CBFontTT(CBGame *inGame); virtual ~CBFontTT(void); - virtual int getTextWidth(byte *text, int maxLenght = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLenght = -1); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); HRESULT loadBuffer(byte *buffer); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 7818d40396..f179914bc1 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -132,7 +132,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 8c75fc50c6..4bfbe0bd17 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -53,7 +53,7 @@ public: uint32 _delay; CBArray _subframes; HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6e36df929f..9f8a67490e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -757,7 +757,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { +HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 90dcb12c75..f2f428fb25 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -68,8 +68,8 @@ public: bool getSaveExists(int slot); HRESULT initLoad(const char *filename); HRESULT initSave(const char *desc); - HRESULT getBytes(byte *buffer, uint32 size); - HRESULT putBytes(byte *buffer, uint32 size); + HRESULT getBytes(byte *buffer, uint32 size); + HRESULT putBytes(byte *buffer, uint32 size); uint32 _offset; bool _saving; diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index 688e13c7e3..f417cc7e51 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -52,7 +52,7 @@ public: virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); HRESULT applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); - HRESULT parseProperty(byte *buffer, bool complete = true); + HRESULT parseProperty(byte *buffer, bool complete = true); char *_filename; bool _freezable; bool _ready; diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index da69fb6566..5a9cbc1515 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -66,7 +66,7 @@ public: bool _changed; bool _paused; bool _finished; - HRESULT loadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); HRESULT loadFile(const char *filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); uint32 _lastFrameTime; HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index a561d55345..02395da74a 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index a54dedefb0..3b90cb3c8a 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -51,7 +51,7 @@ public: bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); - HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 3b527e4032..91644052bb 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -38,7 +38,7 @@ namespace WinterMute { -typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); +typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index f096af390c..eba931b57f 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -39,7 +39,7 @@ public: CUIEntity(CBGame *inGame); virtual ~CUIEntity(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete); + HRESULT loadBuffer(byte *Buffer, bool Complete); virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp index 1c0d73c6cd..1bf4383ccf 100644 --- a/engines/wintermute/graphics/tga.cpp +++ b/engines/wintermute/graphics/tga.cpp @@ -145,7 +145,7 @@ bool TGA::readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDe } else if (imageType == 3) { _surface.create(_surface.w, _surface.h, _surface.format); - byte *data = (byte *)_surface.pixels; + byte *data = (byte *)_surface.pixels; uint32 count = _surface.w * _surface.h; while (count-- > 0) { -- cgit v1.2.3 From a9f0852e2daaca84204186dd91f6d85b3bf40963 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 6 Jul 2012 19:19:26 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BFontStorage --- engines/wintermute/Ad/AdObject.cpp | 6 ++--- engines/wintermute/Ad/AdResponse.cpp | 6 ++--- engines/wintermute/Ad/AdResponseBox.cpp | 12 ++++----- engines/wintermute/Base/BFontStorage.cpp | 24 ++++++++--------- engines/wintermute/Base/BFontStorage.h | 10 ++++---- engines/wintermute/Base/BGame.cpp | 16 ++++++------ engines/wintermute/UI/UIButton.cpp | 44 ++++++++++++++++---------------- engines/wintermute/UI/UIEdit.cpp | 14 +++++----- engines/wintermute/UI/UIObject.cpp | 6 ++--- engines/wintermute/UI/UIText.cpp | 4 +-- engines/wintermute/UI/UIWindow.cpp | 14 +++++----- 11 files changed, 77 insertions(+), 79 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index f594f91100..b132bec46e 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -127,7 +127,7 @@ CAdObject::~CAdObject() { _tempSprite2 = NULL; // reference only _stickRegion = NULL; - if (_font) Game->_fontStorage->RemoveFont(_font); + if (_font) Game->_fontStorage->removeFont(_font); if (_inventory) { ((CAdGame *)Game)->unregisterInventory(_inventory); @@ -793,9 +793,9 @@ const char *CAdObject::scToString() { ////////////////////////////////////////////////////////////////////////// HRESULT CAdObject::SetFont(const char *filename) { - if (_font) Game->_fontStorage->RemoveFont(_font); + if (_font) Game->_fontStorage->removeFont(_font); if (filename) { - _font = Game->_fontStorage->AddFont(filename); + _font = Game->_fontStorage->addFont(filename); return _font == NULL ? E_FAIL : S_OK; } else { _font = NULL; diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 7c6a768c21..320f026863 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -60,7 +60,7 @@ CAdResponse::~CAdResponse() { _icon = NULL; _iconHover = NULL; _iconPressed = NULL; - if (_font) Game->_fontStorage->RemoveFont(_font); + if (_font) Game->_fontStorage->removeFont(_font); } @@ -86,8 +86,8 @@ HRESULT CAdResponse::setIcon(const char *filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CAdResponse::setFont(const char *filename) { - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont(filename); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont(filename); if (!_font) { Game->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); return E_FAIL; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 9f498b49a5..6841705701 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -82,8 +82,8 @@ CAdResponseBox::~CAdResponseBox() { delete[] _lastResponseTextOrig; _lastResponseTextOrig = NULL; - if (_font) Game->_fontStorage->RemoveFont(_font); - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + if (_font) Game->_fontStorage->removeFont(_font); + if (_fontHover) Game->_fontStorage->removeFont(_fontHover); clearResponses(); clearButtons(); @@ -269,14 +269,14 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - _fontHover = Game->_fontStorage->AddFont((char *)params); + if (_fontHover) Game->_fontStorage->removeFont(_fontHover); + _fontHover = Game->_fontStorage->addFont((char *)params); if (!_fontHover) cmd = PARSERR_GENERIC; break; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 00aa67cb20..0ec51b1317 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -44,7 +44,7 @@ IMPLEMENT_PERSISTENT(CBFontStorage, true) ////////////////////////////////////////////////////////////////////////// CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { // _fTLibrary = NULL; - InitFreeType(); + initFreeType(); } @@ -55,7 +55,7 @@ CBFontStorage::~CBFontStorage() { ////////////////////////////////////////////////////////////////////////// -void CBFontStorage::InitFreeType() { +void CBFontStorage::initFreeType() { #if 0 FT_Error error = FT_Init_FreeType(&_fTLibrary); if (error) { @@ -65,11 +65,9 @@ void CBFontStorage::InitFreeType() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::cleanup(bool Warn) { - int i; - - for (i = 0; i < _fonts.GetSize(); i++) { - if (Warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); +HRESULT CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.GetSize(); i++) { + if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; } _fonts.RemoveAll(); @@ -82,7 +80,7 @@ HRESULT CBFontStorage::cleanup(bool Warn) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::InitLoop() { +HRESULT CBFontStorage::initLoop() { for (int i = 0; i < _fonts.GetSize(); i++) { _fonts[i]->initLoop(); } @@ -90,7 +88,7 @@ HRESULT CBFontStorage::InitLoop() { } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::AddFont(const char *filename) { +CBFont *CBFontStorage::addFont(const char *filename) { if (!filename) return NULL; for (int i = 0; i < _fonts.GetSize(); i++) { @@ -124,11 +122,11 @@ CBFont *CBFontStorage::AddFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::RemoveFont(CBFont *Font) { - if (!Font) return E_FAIL; +HRESULT CBFontStorage::removeFont(CBFont *font) { + if (!font) return E_FAIL; for (int i = 0; i < _fonts.GetSize(); i++) { - if (_fonts[i] == Font) { + if (_fonts[i] == font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { delete _fonts[i]; @@ -149,7 +147,7 @@ HRESULT CBFontStorage::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); _fonts.persist(persistMgr); - if (!persistMgr->_saving) InitFreeType(); + if (!persistMgr->_saving) initFreeType(); return S_OK; } diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index b337d2d6d5..bbbcf529c2 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -41,20 +41,20 @@ class CBFont; class CBFontStorage : public CBBase { public: DECLARE_PERSISTENT(CBFontStorage, CBBase) - HRESULT cleanup(bool Warn = false); - HRESULT RemoveFont(CBFont *Font); - CBFont *AddFont(const char *filename); + HRESULT cleanup(bool warn = false); + HRESULT removeFont(CBFont *font); + CBFont *addFont(const char *filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); CBArray _fonts; - HRESULT InitLoop(); + HRESULT initLoop(); /* FT_Library GetFTLibrary() const { return _fTLibrary; }*/ private: - void InitFreeType(); + void initFreeType(); //FT_Library _fTLibrary; }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 9f8a67490e..eeb50e4f0d 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -394,10 +394,10 @@ HRESULT CBGame::cleanup() { } _scripts.RemoveAll(); - _fontStorage->RemoveFont(_systemFont); + _fontStorage->removeFont(_systemFont); _systemFont = NULL; - _fontStorage->RemoveFont(_videoFont); + _fontStorage->removeFont(_videoFont); _videoFont = NULL; for (int i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; @@ -615,7 +615,7 @@ HRESULT CBGame::initLoop() { updateMusicCrossfade(); _surfaceStorage->initLoop(); - _fontStorage->InitLoop(); + _fontStorage->initLoop(); //_activeObject = NULL; @@ -820,17 +820,17 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->RemoveFont(_systemFont); + if (_systemFont) _fontStorage->removeFont(_systemFont); _systemFont = NULL; - _systemFont = Game->_fontStorage->AddFont((char *)params); + _systemFont = Game->_fontStorage->addFont((char *)params); break; case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->RemoveFont(_videoFont); + if (_videoFont) _fontStorage->removeFont(_videoFont); _videoFont = NULL; - _videoFont = Game->_fontStorage->AddFont((char *)params); + _videoFont = Game->_fontStorage->addFont((char *)params); break; @@ -958,7 +958,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { } } - if (!_systemFont) _systemFont = Game->_fontStorage->AddFont("system_font.fnt"); + if (!_systemFont) _systemFont = Game->_fontStorage->addFont("system_font.fnt"); if (cmd == PARSERR_TOKENNOTFOUND) { diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 0131f0bd02..1504796378 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -79,10 +79,10 @@ CUIButton::~CUIButton() { if (_backFocus) delete _backFocus; if (!_sharedFonts) { - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + if (_fontHover) Game->_fontStorage->removeFont(_fontHover); + if (_fontPress) Game->_fontStorage->removeFont(_fontPress); + if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); + if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); } if (!_sharedImages) { @@ -322,32 +322,32 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); - _fontHover = Game->_fontStorage->AddFont((char *)params); + if (_fontHover) Game->_fontStorage->removeFont(_fontHover); + _fontHover = Game->_fontStorage->addFont((char *)params); if (!_fontHover) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_PRESS: - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); - _fontPress = Game->_fontStorage->AddFont((char *)params); + if (_fontPress) Game->_fontStorage->removeFont(_fontPress); + _fontPress = Game->_fontStorage->addFont((char *)params); if (!_fontPress) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_DISABLE: - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); - _fontDisable = Game->_fontStorage->AddFont((char *)params); + if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); + _fontDisable = Game->_fontStorage->addFont((char *)params); if (!_fontDisable) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_FOCUS: - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); - _fontFocus = Game->_fontStorage->AddFont((char *)params); + if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); + _fontFocus = Game->_fontStorage->addFont((char *)params); if (!_fontFocus) cmd = PARSERR_GENERIC; break; @@ -674,12 +674,12 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable); + if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); if (Val->isNULL()) { _fontDisable = NULL; stack->pushBool(true); } else { - _fontDisable = Game->_fontStorage->AddFont(Val->getString()); + _fontDisable = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontDisable != NULL); } return S_OK; @@ -692,12 +692,12 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover); + if (_fontHover) Game->_fontStorage->removeFont(_fontHover); if (Val->isNULL()) { _fontHover = NULL; stack->pushBool(true); } else { - _fontHover = Game->_fontStorage->AddFont(Val->getString()); + _fontHover = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontHover != NULL); } return S_OK; @@ -710,12 +710,12 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress); + if (_fontPress) Game->_fontStorage->removeFont(_fontPress); if (Val->isNULL()) { _fontPress = NULL; stack->pushBool(true); } else { - _fontPress = Game->_fontStorage->AddFont(Val->getString()); + _fontPress = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontPress != NULL); } return S_OK; @@ -728,12 +728,12 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus); + if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); if (Val->isNULL()) { _fontFocus = NULL; stack->pushBool(true); } else { - _fontFocus = Game->_fontStorage->AddFont(Val->getString()); + _fontFocus = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontFocus != NULL); } return S_OK; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 5ad3c3fcdf..4bb3684b3c 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -85,7 +85,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIEdit::~CUIEdit() { if (!_sharedFonts) { - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); + if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); } delete[] _cursorChar; @@ -208,14 +208,14 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_SELECTED: - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont((char *)params); + if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); + _fontSelected = Game->_fontStorage->addFont((char *)params); if (!_fontSelected) cmd = PARSERR_GENERIC; break; @@ -368,8 +368,8 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (strcmp(name, "SetSelectedFont") == 0) { stack->correctParams(1); - if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected); - _fontSelected = Game->_fontStorage->AddFont(stack->pop()->getString()); + if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); + _fontSelected = Game->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontSelected != NULL); return S_OK; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index aad8e23900..52a24aa79c 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -74,7 +74,7 @@ CUIObject::~CUIObject() { if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); if (_back) delete _back; - if (_font && !_sharedFonts) Game->_fontStorage->RemoveFont(_font); + if (_font && !_sharedFonts) Game->_fontStorage->removeFont(_font); if (_image && !_sharedImages) delete _image; @@ -145,12 +145,12 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *Val = stack->pop(); - if (_font) Game->_fontStorage->RemoveFont(_font); + if (_font) Game->_fontStorage->removeFont(_font); if (Val->isNULL()) { _font = NULL; stack->pushBool(true); } else { - _font = Game->_fontStorage->AddFont(Val->getString()); + _font = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_font != NULL); } return S_OK; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index dce7f48731..5f81a228c3 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -209,8 +209,8 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index c2eef79210..b4043a0d41 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -104,7 +104,7 @@ void CUIWindow::cleanup() { _viewport = NULL; if (_backInactive) delete _backInactive; - if (!_sharedFonts && _fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); + if (!_sharedFonts && _fontInactive) Game->_fontStorage->removeFont(_fontInactive); if (!_sharedImages && _imageInactive) delete _imageInactive; for (int i = 0; i < _widgets.GetSize(); i++) delete _widgets[i]; @@ -369,14 +369,14 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->RemoveFont(_font); - _font = Game->_fontStorage->AddFont((char *)params); + if (_font) Game->_fontStorage->removeFont(_font); + _font = Game->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_INACTIVE: - if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont((char *)params); + if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive); + _fontInactive = Game->_fontStorage->addFont((char *)params); if (!_fontInactive) cmd = PARSERR_GENERIC; break; @@ -720,8 +720,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "SetInactiveFont") == 0) { stack->correctParams(1); - if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive); - _fontInactive = Game->_fontStorage->AddFont(stack->pop()->getString()); + if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive); + _fontInactive = Game->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontInactive != NULL); return S_OK; -- cgit v1.2.3 From eaa5f2e41531cca8801ae3ec77882f8f7c4565e5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 6 Jul 2012 19:21:46 +0200 Subject: WINTERMUTE: Clean out the FreeType-initialization-code from BFontStorage. --- engines/wintermute/Base/BFontStorage.cpp | 20 -------------------- engines/wintermute/Base/BFontStorage.h | 8 -------- 2 files changed, 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 0ec51b1317..3749161137 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -43,27 +43,13 @@ IMPLEMENT_PERSISTENT(CBFontStorage, true) ////////////////////////////////////////////////////////////////////////// CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -// _fTLibrary = NULL; - initFreeType(); } - ////////////////////////////////////////////////////////////////////////// CBFontStorage::~CBFontStorage() { cleanup(true); } - -////////////////////////////////////////////////////////////////////////// -void CBFontStorage::initFreeType() { -#if 0 - FT_Error error = FT_Init_FreeType(&_fTLibrary); - if (error) { - Game->LOG(0, "Error initializing FreeType library."); - } -#endif -} - ////////////////////////////////////////////////////////////////////////// HRESULT CBFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.GetSize(); i++) { @@ -72,10 +58,6 @@ HRESULT CBFontStorage::cleanup(bool warn) { } _fonts.RemoveAll(); -#if 0 - if (_fTLibrary) FT_Done_FreeType(_fTLibrary); -#endif - return S_OK; } @@ -147,8 +129,6 @@ HRESULT CBFontStorage::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); _fonts.persist(persistMgr); - if (!persistMgr->_saving) initFreeType(); - return S_OK; } diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index bbbcf529c2..e5f96fd3bc 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -48,14 +48,6 @@ public: virtual ~CBFontStorage(); CBArray _fonts; HRESULT initLoop(); - - /* FT_Library GetFTLibrary() const { - return _fTLibrary; - }*/ - -private: - void initFreeType(); - //FT_Library _fTLibrary; }; } // end of namespace WinterMute -- cgit v1.2.3 From b682d7863a0a942a7806a56a554c16336f9e7a62 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 7 Jul 2012 17:36:47 +0200 Subject: WINTERMUTE: Rename VarName->varName in BFontTT --- engines/wintermute/Base/BFontTT.cpp | 131 ++++++++++++++++++------------------ engines/wintermute/Base/BFontTT.h | 4 +- 2 files changed, 67 insertions(+), 68 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 4f6aff43b6..36231b5622 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -101,7 +101,6 @@ void CBFontTT::clearCache() { if (_cachedTexts[i]) delete _cachedTexts[i]; _cachedTexts[i] = NULL; } - } ////////////////////////////////////////////////////////////////////////// @@ -121,115 +120,115 @@ void CBFontTT::initLoop() { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *Text, int MaxLength) { - WideString text; +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); - else text = StringUtil::ansiToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); - if (MaxLength >= 0 && text.size() > MaxLength) - text = Common::String(text.c_str(), MaxLength); + if (maxLength >= 0 && textStr.size() > maxLength) + textStr = Common::String(textStr.c_str(), maxLength); //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; - measureText(text, -1, -1, textWidth, textHeight); + measureText(textStr, -1, -1, textWidth, textHeight); return textWidth; } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *Text, int Width) { - WideString text; +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; - if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::utf8ToWide((char *)Text); - else text = StringUtil::ansiToWide((char *)Text); + if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); int textWidth, textHeight; - measureText(text, Width, -1, textWidth, textHeight); + measureText(textStr, width, -1, textWidth, textHeight); return textHeight; } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { - if (Text == NULL || strcmp((char *)Text, "") == 0) return; +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; - WideString text = (char *)Text; + WideString textStr = (char *)text; // TODO: Why do we still insist on Widestrings everywhere? /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ - if (MaxLength >= 0 && text.size() > MaxLength) - text = Common::String(text.c_str(), MaxLength); + if (maxLength >= 0 && textStr.size() > maxLength) + textStr = Common::String(textStr.c_str(), maxLength); //text = text.substr(0, MaxLength); // TODO: Remove CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; // find cached surface, if exists - int MinPriority = INT_MAX; - int MinIndex = -1; - CBSurface *Surface = NULL; + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; int textOffset = 0; for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i] == NULL) { - MinPriority = 0; - MinIndex = i; + minPriority = 0; + minIndex = i; } else { - if (_cachedTexts[i]->_text == text && _cachedTexts[i]->_align == Align && _cachedTexts[i]->_width == Width && _cachedTexts[i]->_maxHeight == MaxHeight && _cachedTexts[i]->_maxLength == MaxLength) { - Surface = _cachedTexts[i]->_surface; + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; textOffset = _cachedTexts[i]->_textOffset; _cachedTexts[i]->_priority++; _cachedTexts[i]->_marked = true; break; } else { - if (_cachedTexts[i]->_priority < MinPriority) { - MinPriority = _cachedTexts[i]->_priority; - MinIndex = i; + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; } } } } // not found, create one - if (!Surface) { - warning("Draw text: %s", Text); - Surface = renderTextToTexture(text, Width, Align, MaxHeight, textOffset); - if (Surface) { + if (!surface) { + warning("Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { // write surface to cache - if (_cachedTexts[MinIndex] != NULL) delete _cachedTexts[MinIndex]; - _cachedTexts[MinIndex] = new CBCachedTTFontText; - - _cachedTexts[MinIndex]->_surface = Surface; - _cachedTexts[MinIndex]->_align = Align; - _cachedTexts[MinIndex]->_width = Width; - _cachedTexts[MinIndex]->_maxHeight = MaxHeight; - _cachedTexts[MinIndex]->_maxLength = MaxLength; - _cachedTexts[MinIndex]->_priority = 1; - _cachedTexts[MinIndex]->_text = text; - _cachedTexts[MinIndex]->_textOffset = textOffset; - _cachedTexts[MinIndex]->_marked = true; + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; } } // and paint it - if (Surface) { + if (surface) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, Surface->getWidth(), Surface->getHeight()); + CBPlatform::SetRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.GetSize(); i++) { - uint32 Color = _layers[i]->_color; - uint32 OrigForceAlpha = _renderer->_forceAlphaColor; + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = _renderer->_forceAlphaColor; if (_renderer->_forceAlphaColor != 0) { - Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(_renderer->_forceAlphaColor)); + color = DRGBA(D3DCOLGetR(color), D3DCOLGetG(color), D3DCOLGetB(color), D3DCOLGetA(_renderer->_forceAlphaColor)); _renderer->_forceAlphaColor = 0; } - Surface->displayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - _renderer->_forceAlphaColor = OrigForceAlpha; + _renderer->_forceAlphaColor = origForceAlpha; } } @@ -549,7 +548,7 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *buffer) { +HRESULT CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -564,24 +563,24 @@ HRESULT CBFontTT::parseLayer(CBTTFontLayer *Layer, byte *buffer) { while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_OFFSET_X: - parser.ScanStr(params, "%d", &Layer->_offsetX); + parser.ScanStr(params, "%d", &layer->_offsetX); break; case TOKEN_OFFSET_Y: - parser.ScanStr(params, "%d", &Layer->_offsetY); + parser.ScanStr(params, "%d", &layer->_offsetY); break; case TOKEN_COLOR: { int r, g, b; parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - Layer->_color = DRGBA(r, g, b, D3DCOLGetA(Layer->_color)); + layer->_color = DRGBA(r, g, b, D3DCOLGetA(layer->_color)); } break; case TOKEN_ALPHA: { int a; parser.ScanStr(params, "%d", &a); - Layer->_color = DRGBA(D3DCOLGetR(Layer->_color), D3DCOLGetG(Layer->_color), D3DCOLGetB(Layer->_color), a); + layer->_color = DRGBA(D3DCOLGetR(layer->_color), D3DCOLGetG(layer->_color), D3DCOLGetB(layer->_color), a); } break; } @@ -604,18 +603,18 @@ HRESULT CBFontTT::persist(CBPersistMgr *persistMgr) { // persist layers - int NumLayers; + int numLayers; if (persistMgr->_saving) { - NumLayers = _layers.GetSize(); - persistMgr->transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) _layers[i]->persist(persistMgr); + numLayers = _layers.GetSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); } else { - NumLayers = _layers.GetSize(); - persistMgr->transfer(TMEMBER(NumLayers)); - for (int i = 0; i < NumLayers; i++) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->persist(persistMgr); - _layers.Add(Layer); + numLayers = _layers.GetSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.Add(layer); } } diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index 7fefaad9df..a2157cb216 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -100,10 +100,10 @@ public: _width = width; } - const WideString &GetText() const { + const WideString getText() const { return _text; } - int GetWidth() const { + int getWidth() const { return _width; } private: -- cgit v1.2.3 From 6d56caef091538ddba2f6fa60df66e22ff3db6b6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 7 Jul 2012 17:43:11 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in BQuickMsg --- engines/wintermute/Base/BGame.cpp | 4 ++-- engines/wintermute/Base/BQuickMsg.cpp | 8 ++++---- engines/wintermute/Base/BQuickMsg.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index eeb50e4f0d..3054bc9151 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -2776,8 +2776,8 @@ HRESULT CBGame::displayQuickMsg() { // display for (i = 0; i < _quickMessages.GetSize(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->GetText(), 0, posY, _renderer->_width); - posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->GetText(), _renderer->_width); + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } return S_OK; } diff --git a/engines/wintermute/Base/BQuickMsg.cpp b/engines/wintermute/Base/BQuickMsg.cpp index e425368929..cee37a0222 100644 --- a/engines/wintermute/Base/BQuickMsg.cpp +++ b/engines/wintermute/Base/BQuickMsg.cpp @@ -33,9 +33,9 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *Text): CBBase(inGame) { - _text = new char [strlen(Text) + 1]; - if (_text) strcpy(_text, Text); +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) strcpy(_text, text); _startTime = Game->_currentTime; } @@ -47,7 +47,7 @@ CBQuickMsg::~CBQuickMsg() { ////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::GetText() { +char *CBQuickMsg::getText() { return _text; } diff --git a/engines/wintermute/Base/BQuickMsg.h b/engines/wintermute/Base/BQuickMsg.h index 3f03ef21fc..46f44b291f 100644 --- a/engines/wintermute/Base/BQuickMsg.h +++ b/engines/wintermute/Base/BQuickMsg.h @@ -35,7 +35,7 @@ namespace WinterMute { class CBQuickMsg : public CBBase { public: - char *GetText(); + char *getText(); uint32 _startTime; char *_text; CBQuickMsg(CBGame *inGame, const char *Text); -- cgit v1.2.3 From 2e20cd0f45e903c82537e84b31869ddd2b87d954 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 7 Jul 2012 17:52:08 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in BRegion --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Ad/AdRegion.cpp | 2 +- engines/wintermute/Ad/AdScene.cpp | 32 ++++----- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BRegion.cpp | 115 ++++++++++++++++---------------- engines/wintermute/Base/BRegion.h | 12 ++-- engines/wintermute/Base/BRenderer.cpp | 2 +- engines/wintermute/Base/PartEmitter.cpp | 2 +- 10 files changed, 86 insertions(+), 87 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 4724be5c1d..915399ea67 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -389,7 +389,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { } else { _blockRegion = rgn; _currentBlockRegion = crgn; - _currentBlockRegion->Mimic(_blockRegion); + _currentBlockRegion->mimic(_blockRegion); } } break; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index ef87d90a32..5e2fb233d4 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -345,7 +345,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { } else { _blockRegion = rgn; _currentBlockRegion = crgn; - _currentBlockRegion->Mimic(_blockRegion); + _currentBlockRegion->mimic(_blockRegion); } } break; diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index b132bec46e..4bea6921b9 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -1040,7 +1040,7 @@ HRESULT CAdObject::updateBlockRegion() { CAdGame *adGame = (CAdGame *)Game; if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->Mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); if (_wptGroup && _currentWptGroup) _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 7e681ada72..6aa201c60d 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -208,7 +208,7 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { return E_FAIL; } - CreateRegion(); + createRegion(); _alpha = DRGBA(ar, ag, ab, alpha); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 8a15175ca5..3c73d1b33a 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -278,7 +278,7 @@ float CAdScene::getZoomAt(int x, int y) { if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { if (node->_region->_zoom != 0) { ret = node->_region->_zoom; found = true; @@ -304,7 +304,7 @@ uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { if (!node->_region->_blocked) ret = node->_region->_alpha; break; } @@ -322,13 +322,13 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (checkFreeObjects) { for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return true; + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } } CAdGame *adGame = (CAdGame *)Game; for (int i = 0; i < adGame->_objects.GetSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return true; + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } } } @@ -344,7 +344,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques break; } */ - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { if (node->_region->_blocked) { ret = true; break; @@ -363,13 +363,13 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (checkFreeObjects) { for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return false; + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } } CAdGame *adGame = (CAdGame *)Game; for (int i = 0; i < adGame->_objects.GetSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->PointInRegion(x, y)) return false; + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } } } @@ -378,7 +378,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_mainLayer) { for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { if (node->_region->_blocked) { ret = false; break; @@ -1075,7 +1075,7 @@ HRESULT CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { // global objects for (int i = 0; i < adGame->_objects.GetSize(); i++) { obj = adGame->_objects[i]; - if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { objects.Add(obj); } } @@ -1083,7 +1083,7 @@ HRESULT CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { // scene objects for (int i = 0; i < _objects.GetSize(); i++) { obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { objects.Add(obj); } } @@ -1141,7 +1141,7 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *region) { // global objects for (int i = 0; i < adGame->_objects.GetSize(); i++) { - if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->PointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { obj = adGame->_objects[i]; minY = adGame->_objects[i]->_posY; } @@ -1149,7 +1149,7 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *region) { // scene objects for (int i = 0; i < _objects.GetSize(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->PointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { obj = _objects[i]; minY = _objects[i]->_posY; } @@ -1427,7 +1427,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (node->_region->_decoration && !includeDecors) continue; stack->pushNative(node->_region, true); @@ -2597,7 +2597,7 @@ HRESULT CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegi if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->PointInRegion(x, y)) { + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (numUsed < numRegions - 1) { regionList[numUsed] = node->_region; numUsed++; @@ -2726,7 +2726,7 @@ HRESULT CAdScene::getRegionObjects(CAdRegion *region, CBArray_objects.GetSize(); i++) { obj = adGame->_objects[i]; - if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) continue; objects.Add(obj); @@ -2736,7 +2736,7 @@ HRESULT CAdScene::getRegionObjects(CAdRegion *region, CBArray_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->PointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) continue; objects.Add(obj); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3054bc9151..220f3359bc 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3356,7 +3356,7 @@ HRESULT CBGame::initAfterLoad() { ////////////////////////////////////////////////////////////////////////// void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->CreateRegion(); + ((CBRegion *)region)->createRegion(); } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 6194346093..ea3ecda58e 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -70,26 +70,26 @@ void CBRegion::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CBRegion::CreateRegion() { - return SUCCEEDED(GetBoundingRect(&_rect)); +bool CBRegion::createRegion() { + return SUCCEEDED(getBoundingRect(&_rect)); } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::PointInRegion(int X, int Y) { +bool CBRegion::pointInRegion(int x, int y) { if (_points.GetSize() < 3) return false; POINT pt; - pt.x = X; - pt.y = Y; + pt.x = x; + pt.y = y; RECT rect; - rect.left = X - 1; - rect.right = X + 2; - rect.top = Y - 1; - rect.bottom = Y + 2; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; - if (CBPlatform::PtInRect(&_rect, pt)) return PtInPolygon(X, Y); + if (CBPlatform::PtInRect(&_rect, pt)) return ptInPolygon(x, y); else return false; } @@ -201,7 +201,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { return E_FAIL; } - CreateRegion(); + createRegion(); return S_OK; } @@ -217,11 +217,11 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AddPoint") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); - _points.Add(new CBPoint(X, Y)); - CreateRegion(); + _points.Add(new CBPoint(x, y)); + createRegion(); stack->pushBool(true); @@ -234,12 +234,12 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "InsertPoint") == 0) { stack->correctParams(3); int Index = stack->pop()->getInt(); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { - _points.InsertAt(Index, new CBPoint(X, Y)); - CreateRegion(); + _points.InsertAt(Index, new CBPoint(x, y)); + createRegion(); stack->pushBool(true); } else stack->pushBool(false); @@ -253,13 +253,13 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SetPoint") == 0) { stack->correctParams(3); int Index = stack->pop()->getInt(); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.GetSize()) { - _points[Index]->x = X; - _points[Index]->y = Y; - CreateRegion(); + _points[Index]->x = x; + _points[Index]->y = y; + createRegion(); stack->pushBool(true); } else stack->pushBool(false); @@ -272,14 +272,14 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemovePoint") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.GetSize()) { - delete _points[Index]; - _points[Index] = NULL; + if (index >= 0 && index < _points.GetSize()) { + delete _points[index]; + _points[index] = NULL; - _points.RemoveAt(Index); - CreateRegion(); + _points.RemoveAt(index); + createRegion(); stack->pushBool(true); } else stack->pushBool(false); @@ -292,13 +292,13 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPoint") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.GetSize()) { - CScValue *Val = stack->getPushValue(); - if (Val) { - Val->setProperty("X", _points[Index]->x); - Val->setProperty("Y", _points[Index]->y); + if (index >= 0 && index < _points.GetSize()) { + CScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); } } else stack->pushNULL(); @@ -378,9 +378,9 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *NameOverride) { - if (!NameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", NameOverride); +HRESULT CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", nameOverride); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -426,21 +426,20 @@ typedef struct { } dPoint; ////////////////////////////////////////////////////////////////////////// -bool CBRegion::PtInPolygon(int X, int Y) { +bool CBRegion::ptInPolygon(int x, int y) { if (_points.GetSize() < 3) return false; int counter = 0; - int i; double xinters; dPoint p, p1, p2; - p.x = (double)X; - p.y = (double)Y; + p.x = (double)x; + p.y = (double)y; p1.x = (double)_points[0]->x; p1.y = (double)_points[0]->y; - for (i = 1; i <= _points.GetSize(); i++) { + for (int i = 1; i <= _points.GetSize(); i++) { p2.x = (double)_points[i % _points.GetSize()]->x; p2.y = (double)_points[i % _points.GetSize()]->y; @@ -466,8 +465,8 @@ bool CBRegion::PtInPolygon(int X, int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::GetBoundingRect(RECT *Rect) { - if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(Rect); +HRESULT CBRegion::getBoundingRect(RECT *rect) { + if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -478,32 +477,32 @@ HRESULT CBRegion::GetBoundingRect(RECT *Rect) { MaxX = MAX(MaxX, _points[i]->x); MaxY = MAX(MaxY, _points[i]->y); } - CBPlatform::SetRect(Rect, MinX, MinY, MaxX, MaxY); + CBPlatform::SetRect(rect, MinX, MinY, MaxX, MaxY); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::Mimic(CBRegion *Region, float Scale, int X, int Y) { - if (Scale == _lastMimicScale && X == _lastMimicX && Y == _lastMimicY) return S_OK; +HRESULT CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return S_OK; cleanup(); - for (int i = 0; i < Region->_points.GetSize(); i++) { - int x, y; + for (int i = 0; i < region->_points.GetSize(); i++) { + int xVal, yVal; - x = (int)((float)Region->_points[i]->x * Scale / 100.0f); - y = (int)((float)Region->_points[i]->y * Scale / 100.0f); + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - _points.Add(new CBPoint(x + X, y + Y)); + _points.Add(new CBPoint(xVal + x, yVal + y)); } - _lastMimicScale = Scale; - _lastMimicX = X; - _lastMimicY = Y; + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; - return CreateRegion() ? S_OK : E_FAIL; + return createRegion() ? S_OK : E_FAIL; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 2ac783ca7b..0b005eb1de 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -40,21 +40,21 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - HRESULT Mimic(CBRegion *Region, float Scale = 100.0f, int X = 0, int Y = 0); - HRESULT GetBoundingRect(RECT *Rect); - bool PtInPolygon(int X, int Y); + HRESULT mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + HRESULT getBoundingRect(RECT *rect); + bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; int _editorSelectedPoint; CBRegion(CBGame *inGame); virtual ~CBRegion(); - bool PointInRegion(int X, int Y); - bool CreateRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *buffer, bool complete = true); RECT _rect; CBArray _points; - virtual HRESULT saveAsText(CBDynBuffer *Buffer, int Indent, const char *NameOverride = NULL); + virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 690f16016c..5ccd04f1fd 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -95,7 +95,7 @@ CBObject *CBRenderer::getObjectAt(int X, int Y) { } // region else if (_rectList[i]->_region) { - if (_rectList[i]->_region->PointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + if (_rectList[i]->_region->pointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; } } else return _rectList[i]->_owner; } diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index b80d6b0b68..7c49177039 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -293,7 +293,7 @@ HRESULT CPartEmitter::display(CBRegion *Region) { for (int i = 0; i < _particles.GetSize(); i++) { if (Region != NULL && _useRegion) { - if (!Region->PointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; + if (!Region->pointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; } _particles[i]->display(this); -- cgit v1.2.3 From 31043124d5fae105a8289ed50558e5693c5b0b6c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 18:32:57 +0200 Subject: WINTERMUTE: Add detection for Five Lethal Demons --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 610f34c643..7423b74c0a 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -84,6 +84,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_DEMO, GUIO0() }, + { + "wintermute", + "Five Lethal Demons", + AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, { "wintermute", "the white chamber", -- cgit v1.2.3 From a339c24946a3a928f809087c4947750b07140e98 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 18:38:31 +0200 Subject: WINTERMUTE: Add detection for Pigeons in the Park --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 7423b74c0a..f06330da59 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -94,6 +94,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_USEEXTRAASTITLE, GUIO0() }, + { + "wintermute", + "Pigeons in the Park", + AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, { "wintermute", "the white chamber", -- cgit v1.2.3 From df0188d911816159a31f9ac277dbb07efc4c08d9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 18:38:50 +0200 Subject: WINTERMUTE: Add detection for Chivalry is Not Dead --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index f06330da59..a9a188e2e4 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -33,6 +33,16 @@ namespace WinterMute { static const ADGameDescription gameDescriptions[] = { + { + "wintermute", + "Chivalry is Not Dead", + AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, { "wintermute", "Dirty Split", -- cgit v1.2.3 From 2ac6cfbc8ad7f57dcd8a74479451276e700102a2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:00:31 +0200 Subject: WINTERMUTE: Rename VarName->varName in BFrame --- engines/wintermute/Base/BFrame.cpp | 176 ++++++++++++++++++------------------- engines/wintermute/Base/BFrame.h | 8 +- 2 files changed, 91 insertions(+), 93 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index f179914bc1..b5dce4f041 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -62,12 +62,11 @@ CBFrame::~CBFrame() { delete _sound; _sound = NULL; - int i; - - for (i = 0; i < _subframes.GetSize(); i++) delete _subframes[i]; + for (int i = 0; i < _subframes.GetSize(); i++) + delete _subframes[i]; _subframes.RemoveAll(); - for (i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.GetSize(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } @@ -76,11 +75,11 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, bool AllFrames, float Rotate, TSpriteBlendMode BlendMode) { +HRESULT CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { HRESULT res; for (int i = 0; i < _subframes.GetSize(); i++) { - res = _subframes[i]->draw(X, Y, Register, ZoomX, ZoomY, Precise, Alpha, Rotate, BlendMode); + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); if (FAILED(res)) return res; } return S_OK; @@ -88,9 +87,9 @@ HRESULT CBFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::oneTimeDisplay(CBObject *Owner, bool Muted) { - if (_sound && !Muted) { - if (Owner) Owner->updateOneSound(_sound); +HRESULT CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) owner->updateOneSound(_sound); _sound->play(); /* if (Game->_state == GAME_FROZEN) { @@ -98,9 +97,9 @@ HRESULT CBFrame::oneTimeDisplay(CBObject *Owner, bool Muted) { } */ } - if (Owner) { + if (owner) { for (int i = 0; i < _applyEvent.GetSize(); i++) { - Owner->applyEvent(_applyEvent[i]); + owner->applyEvent(_applyEvent[i]); } } return S_OK; @@ -132,7 +131,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -163,18 +162,18 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { RECT rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; - int HotspotX = 0, HotspotY = 0; - bool custo_trans = false; - bool editor_selected = false; - bool Is2DOnly = false; - bool Is3DOnly = false; - bool Decoration = false; - bool MirrorX = false; - bool MirrorY = false; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; CBPlatform::SetRectEmpty(&rect); char *surface_file = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.GetCommand((char **)&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_DELAY: parser.ScanStr(params, "%d", &_delay); @@ -186,7 +185,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_TRANSPARENT: parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; + custoTrans = true; break; case TOKEN_RECT: @@ -194,7 +193,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &HotspotX, &HotspotY); + parser.ScanStr(params, "%d,%d", &hotspotX, &hotspotY); break; case TOKEN_MOVE: @@ -202,19 +201,19 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &Is2DOnly); + parser.ScanStr(params, "%b", &is2DOnly); break; case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &Is3DOnly); + parser.ScanStr(params, "%b", &is3DOnly); break; case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &MirrorX); + parser.ScanStr(params, "%b", &mirrorX); break; case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &MirrorY); + parser.ScanStr(params, "%b", &mirrorY); break; case TOKEN_ALPHA_COLOR: @@ -226,7 +225,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &editor_selected); + parser.ScanStr(params, "%b", &editorSelected); break; case TOKEN_EDITOR_EXPANDED: @@ -239,7 +238,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { case TOKEN_SUBFRAME: { CBSubFrame *subframe = new CBSubFrame(Game); - if (!subframe || FAILED(subframe->loadBuffer((byte *)params, LifeTime, KeepLoaded))) { + if (!subframe || FAILED(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; } else _subframes.Add(subframe); @@ -272,7 +271,7 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { break; case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &Decoration); + parser.ScanStr(params, "%b", &decoration); break; case TOKEN_EDITOR_PROPERTY: @@ -293,8 +292,8 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { CBSubFrame *sub = new CBSubFrame(Game); if (surface_file != NULL) { - if (custo_trans) sub->setSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); if (!sub->_surface) { delete sub; @@ -303,22 +302,22 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { } sub->_alpha = DRGBA(ar, ag, ab, alpha); - if (custo_trans) sub->_transparent = DRGBA(r, g, b, 0xFF); + if (custoTrans) sub->_transparent = DRGBA(r, g, b, 0xFF); } if (CBPlatform::IsRectEmpty(&rect)) sub->setDefaultRect(); else sub->_rect = rect; - sub->_hotspotX = HotspotX; - sub->_hotspotY = HotspotY; - sub->_2DOnly = Is2DOnly; - sub->_3DOnly = Is3DOnly; - sub->_decoration = Decoration; - sub->_mirrorX = MirrorX; - sub->_mirrorY = MirrorY; + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; - sub->_editorSelected = editor_selected; + sub->_editorSelected = editorSelected; _subframes.InsertAt(0, sub); return S_OK; @@ -326,15 +325,15 @@ HRESULT CBFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; - CBPlatform::SetRectEmpty(Rect); +bool CBFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + CBPlatform::SetRectEmpty(rect); - RECT SubRect; + RECT subRect; for (int i = 0; i < _subframes.GetSize(); i++) { - _subframes[i]->getBoundingRect(&SubRect, X, Y, ScaleX, ScaleY); - CBPlatform::UnionRect(Rect, Rect, &SubRect); + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + CBPlatform::UnionRect(rect, rect, &subRect); } return true; } @@ -362,12 +361,11 @@ HRESULT CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); - int i; - for (i = 1; i < _subframes.GetSize(); i++) { + for (int i = 1; i < _subframes.GetSize(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); } - for (i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.GetSize(); i++) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } @@ -419,13 +417,13 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSound") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); delete _sound; _sound = NULL; - if (!Val->isNULL()) { + if (!val->isNULL()) { _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->setSound(Val->getString(), SOUND_SFX, false))) { + if (!_sound || FAILED(_sound->setSound(val->getString(), SOUND_SFX, false))) { stack->pushBool(false); delete _sound; _sound = NULL; @@ -439,11 +437,11 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _subframes.GetSize()) { - script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _subframes.GetSize()) { + script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); - } else stack->pushNative(_subframes[Index], true); + } else stack->pushNative(_subframes[index], true); return S_OK; } @@ -453,16 +451,16 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteSubframe") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _subframes.GetSize()) { - script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", Index); + CScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _subframes.GetSize()) { + script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { - CBSubFrame *Sub = (CBSubFrame *)Val->getNative(); + CBSubFrame *sub = (CBSubFrame *)val->getNative(); for (int i = 0; i < _subframes.GetSize(); i++) { - if (_subframes[i] == Sub) { + if (_subframes[i] == sub) { delete _subframes[i]; _subframes.RemoveAt(i); break; @@ -478,18 +476,18 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSubframe") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); const char *filename = NULL; - if (!Val->isNULL()) filename = Val->getString(); + if (!val->isNULL()) filename = val->getString(); - CBSubFrame *Sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(Game); if (filename != NULL) { - Sub->setSurface(filename); - Sub->setDefaultRect(); + sub->setSurface(filename); + sub->setDefaultRect(); } - _subframes.Add(Sub); + _subframes.Add(sub); - stack->pushNative(Sub, true); + stack->pushNative(sub, true); return S_OK; } @@ -498,22 +496,22 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertSubframe") == 0) { stack->correctParams(2); - int Index = stack->pop()->getInt(); - if (Index < 0) Index = 0; + int index = stack->pop()->getInt(); + if (index < 0) index = 0; - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); const char *filename = NULL; - if (!Val->isNULL()) filename = Val->getString(); + if (!val->isNULL()) filename = val->getString(); - CBSubFrame *Sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(Game); if (filename != NULL) { - Sub->setSurface(filename); + sub->setSurface(filename); } - if (Index >= _subframes.GetSize()) _subframes.Add(Sub); - else _subframes.InsertAt(Index, Sub); + if (index >= _subframes.GetSize()) _subframes.Add(sub); + else _subframes.InsertAt(index, sub); - stack->pushNative(Sub, true); + stack->pushNative(sub, true); return S_OK; } @@ -522,11 +520,11 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _applyEvent.GetSize()) { - script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _applyEvent.GetSize()) { + script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); - } else stack->pushString(_applyEvent[Index]); + } else stack->pushString(_applyEvent[index]); return S_OK; } @@ -535,14 +533,14 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddEvent") == 0) { stack->correctParams(1); - const char *Event = stack->pop()->getString(); + const char *event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { - if (scumm_stricmp(_applyEvent[i], Event) == 0) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { stack->pushNULL(); return S_OK; } } - _applyEvent.Add(Event); + _applyEvent.Add(event); stack->pushNULL(); return S_OK; } @@ -552,9 +550,9 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteEvent") == 0) { stack->correctParams(1); - const char *Event = stack->pop()->getString(); + const char *event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.GetSize(); i++) { - if (scumm_stricmp(_applyEvent[i], Event) == 0) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { delete [] _applyEvent[i]; _applyEvent.RemoveAt(i); break; diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 4bfbe0bd17..cc42b77661 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -42,18 +42,18 @@ class CBFrame: public CBScriptable { public: bool _killSound; bool _keyframe; - HRESULT oneTimeDisplay(CBObject *Owner, bool Muted = false); + HRESULT oneTimeDisplay(CBObject *owner, bool muted = false); DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; - bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); HRESULT saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; CBArray _subframes; - HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, bool AllFrames = false, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); + HRESULT draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + HRESULT loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); -- cgit v1.2.3 From 7a40ed244626218d654daaf85d54294d652f0ab7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:08:05 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in BImage --- engines/wintermute/Base/BGame.cpp | 6 +++--- engines/wintermute/Base/BImage.cpp | 14 +++++++------- engines/wintermute/Base/BImage.h | 6 +++--- engines/wintermute/Base/BSaveThumbHelper.cpp | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 220f3359bc..6b3d9fdbed 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1807,7 +1807,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { - ret = SUCCEEDED(Image->SaveBMPFile(filename)); + ret = SUCCEEDED(Image->saveBMPFile(filename)); delete Image; } else ret = false; @@ -1827,8 +1827,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool ret = false; CBImage *Image = Game->_renderer->takeScreenshot(); if (Image) { - ret = SUCCEEDED(Image->Resize(SizeX, SizeY)); - if (ret) ret = SUCCEEDED(Image->SaveBMPFile(filename)); + ret = SUCCEEDED(Image->resize(SizeX, SizeY)); + if (ret) ret = SUCCEEDED(Image->saveBMPFile(filename)); delete Image; } else ret = false; diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 11be19683f..c119e023c1 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -112,7 +112,7 @@ void CBImage::copyFrom(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::SaveBMPFile(const char *filename) { +HRESULT CBImage::saveBMPFile(const char *filename) { #if 0 if (!_bitmap) return E_FAIL; @@ -124,12 +124,12 @@ HRESULT CBImage::SaveBMPFile(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::Resize(int NewWidth, int NewHeight) { +HRESULT CBImage::resize(int newWidth, int newHeight) { #if 0 if (!_bitmap) return E_FAIL; - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); @@ -248,7 +248,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { +HRESULT CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { #if 0 if (_bitmap) FreeImage_Unload(_bitmap); @@ -257,13 +257,13 @@ HRESULT CBImage::CopyFrom(CBImage *OrigImage, int NewWidth, int NewHeight) { _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); #endif - TransparentSurface temp(*OrigImage->_surface, false); + TransparentSurface temp(*origImage->_surface, false); if (_deletableSurface) { _deletableSurface->free(); delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scale(NewWidth, NewHeight); + _surface = _deletableSurface = temp.scale(newWidth, newHeight); return S_OK; } diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 2472af718c..8edde54d3f 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -56,9 +56,9 @@ public: } byte getAlphaAt(int x, int y); bool writeBMPToStream(Common::WriteStream *stream); - HRESULT Resize(int NewWidth, int NewHeight); - HRESULT SaveBMPFile(const char *filename); - HRESULT CopyFrom(CBImage *OrigImage, int NewWidth = 0, int NewHeight = 0); + HRESULT resize(int newWidth, int newHeight); + HRESULT saveBMPFile(const char *filename); + HRESULT copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); void copyFrom(Graphics::Surface *surface); private: Common::String _filename; diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 9e5466b323..60bb2d9dfa 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -66,7 +66,7 @@ HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { // normal thumbnail if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { _thumbnail = new CBImage(Game); - _thumbnail->CopyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); + _thumbnail->copyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); } -- cgit v1.2.3 From 63ad1c9b9b644f469a246401affbea6ee1d6d8e8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:11:33 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BKeyboardState --- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BKeyboardState.cpp | 22 +++++++++++----------- engines/wintermute/Base/BKeyboardState.h | 12 ++++++------ engines/wintermute/UI/UIEdit.cpp | 14 +++++++------- engines/wintermute/UI/UIWindow.cpp | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6b3d9fdbed..03a278476c 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3791,7 +3791,7 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { _keyboardState->handleKeyPress(event); - _keyboardState->ReadKey(event); + _keyboardState->readKey(event); // TODO if (_focusedWindow) { diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 94b015f5e9..36a208b317 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -92,7 +92,7 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; // Uint8 *state = SDL_GetKeyboardState(NULL); // SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); - bool isDown = _keyStates[VKeyToKeyCode(vKey)]; + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; stack->pushBool(isDown); return S_OK; @@ -195,9 +195,9 @@ const char *CBKeyboardState::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::ReadKey(Common::Event *event) { +HRESULT CBKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = KeyCodeToVKey(event); + _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { _currentPrintable = true; @@ -206,9 +206,9 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) { } //_currentKeyData = KeyData; - _currentControl = IsControlDown(); - _currentAlt = IsAltDown(); - _currentShift = IsShiftDown(); + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); return S_OK; } @@ -237,25 +237,25 @@ HRESULT CBKeyboardState::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsShiftDown() { +bool CBKeyboardState::isShiftDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_SHIFT); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsControlDown() { +bool CBKeyboardState::isControlDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_CTRL); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::IsAltDown() { +bool CBKeyboardState::isAltDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_ALT); } ////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::KeyCodeToVKey(Common::Event *event) { +uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { if (event->type != Common::EVENT_KEYDOWN) return 0; switch (event->kbd.keycode) { @@ -267,7 +267,7 @@ uint32 CBKeyboardState::KeyCodeToVKey(Common::Event *event) { } ////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::VKeyToKeyCode(uint32 vkey) { +Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo return (Common::KeyCode)vkey; } diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index 982dc2998f..da324b86a3 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -50,13 +50,13 @@ public: DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) CBKeyboardState(CBGame *inGame); virtual ~CBKeyboardState(); - HRESULT ReadKey(Common::Event *event); + HRESULT readKey(Common::Event *event); void handleKeyPress(Common::Event *event); void handleKeyRelease(Common::Event *event); - static bool IsShiftDown(); - static bool IsControlDown(); - static bool IsAltDown(); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); // scripting interface virtual CScValue *scGetProperty(const char *name); @@ -66,8 +66,8 @@ public: private: uint8 *_keyStates; - uint32 KeyCodeToVKey(Common::Event *event); - Common::KeyCode VKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 4bb3684b3c..39f8e993b2 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -698,7 +698,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { // ctrl+A case Common::KEYCODE_a: - if (CBKeyboardState::IsControlDown()) { + if (CBKeyboardState::isControlDown()) { _selStart = 0; _selEnd = strlen(_text); Handled = true; @@ -719,24 +719,24 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_LEFT: case Common::KEYCODE_UP: _selEnd--; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; Handled = true; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_DOWN: _selEnd++; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; Handled = true; break; case Common::KEYCODE_HOME: if (Game->_textRTL) { _selEnd = strlen(_text); - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } else { _selEnd = 0; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } Handled = true; break; @@ -744,10 +744,10 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_END: if (Game->_textRTL) { _selEnd = 0; - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } else { _selEnd = strlen(_text); - if (!CBKeyboardState::IsShiftDown()) _selStart = _selEnd; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } Handled = true; break; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index b4043a0d41..9cda6072db 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1103,7 +1103,7 @@ const char *CUIWindow::scToString() { bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return SUCCEEDED(moveFocus(!CBKeyboardState::IsShiftDown())); + return SUCCEEDED(moveFocus(!CBKeyboardState::isShiftDown())); } else { if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); else return false; -- cgit v1.2.3 From bc8657c5beb982ac8e18195bf6027342b87f3c2e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:20:31 +0200 Subject: WINTERMUTE: Remove 2 gotos in BGame --- engines/wintermute/Base/BGame.cpp | 107 +++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 47 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 03a278476c..44aa3f5ac0 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -426,72 +426,85 @@ HRESULT CBGame::cleanup() { ////////////////////////////////////////////////////////////////////// HRESULT CBGame::initialize1() { - _surfaceStorage = new CBSurfaceStorage(this); - if (_surfaceStorage == NULL) goto init_fail; - - _fontStorage = new CBFontStorage(this); - if (_fontStorage == NULL) goto init_fail; - - _fileManager = new CBFileManager(this); - if (_fileManager == NULL) goto init_fail; + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) + break; - _soundMgr = new CBSoundMgr(this); - if (_soundMgr == NULL) goto init_fail; + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) + break; - _debugMgr = new CBDebugger(this); - if (_debugMgr == NULL) goto init_fail; + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) + break; - _mathClass = new CSXMath(this); - if (_mathClass == NULL) goto init_fail; + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) + break; - _scEngine = new CScEngine(this); - if (_scEngine == NULL) goto init_fail; + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) + break; - _videoPlayer = new CVidPlayer(this); - if (_videoPlayer == NULL) goto init_fail; + _mathClass = new CSXMath(this); + if (_mathClass == NULL) + break; - _transMgr = new CBTransitionMgr(this); - if (_transMgr == NULL) goto init_fail; + _scEngine = new CScEngine(this); + if (_scEngine == NULL) + break; - _keyboardState = new CBKeyboardState(this); - if (_keyboardState == NULL) goto init_fail; + _videoPlayer = new CVidPlayer(this); + if (_videoPlayer == NULL) + break; - _fader = new CBFader(this); - if (_fader == NULL) goto init_fail; - registerObject(_fader); + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) + break; - _store = new CSXStore(this); - if (_store == NULL) goto init_fail; - registerObject(_store); + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) + break; - return S_OK; + _fader = new CBFader(this); + if (_fader == NULL) + break; + registerObject(_fader); -init_fail: - if (_mathClass) delete _mathClass; - if (_store) delete _store; - if (_keyboardState) delete _keyboardState; - if (_transMgr) delete _transMgr; - if (_debugMgr) delete _debugMgr; - if (_surfaceStorage) delete _surfaceStorage; - if (_fontStorage) delete _fontStorage; - if (_soundMgr) delete _soundMgr; - if (_fileManager) delete _fileManager; - if (_scEngine) delete _scEngine; - if (_videoPlayer) delete _videoPlayer; - return E_FAIL; + _store = new CSXStore(this); + if (_store == NULL) + break; + registerObject(_store); + + loaded = true; + } + if (loaded == true) { + return S_OK; + } else { + delete _mathClass; + delete _store; + delete _keyboardState; + delete _transMgr; + delete _debugMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _fileManager; + delete _scEngine; + delete _videoPlayer; + return E_FAIL; + } } ////////////////////////////////////////////////////////////////////// HRESULT CBGame::initialize2() { // we know whether we are going to be accelerated _renderer = new CBRenderSDL(this); - if (_renderer == NULL) goto init_fail; + if (_renderer == NULL) return E_FAIL; return S_OK; - -init_fail: - if (_renderer) delete _renderer; - return E_FAIL; } -- cgit v1.2.3 From 6e06a2dd980bbb1ba54ebd770a84c1c0a3cd62f9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:43:05 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in BGame --- engines/wintermute/Base/BFileManager.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 425 ++++++++++++++-------------- engines/wintermute/Base/BGame.h | 14 +- engines/wintermute/Base/BParser.cpp | 2 +- engines/wintermute/Sys/SysClassRegistry.cpp | 2 +- 5 files changed, 220 insertions(+), 225 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 7afe2e8e40..3617d8a344 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -658,7 +658,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const { // check for device-type specific packages if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + Game->GetDeviceType()); + return StringUtil::compareNoCase(plainName, "xdevice_" + Game->getDeviceType()); } return true; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 44aa3f5ac0..f9819e9e27 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1136,14 +1136,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } const char *filename = stack->pop()->getString(); - CScValue *ValLooping = stack->pop(); - bool Looping = ValLooping->isNULL() ? true : ValLooping->getBool(); + CScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - CScValue *ValLoopStart = stack->pop(); - uint32 LoopStart = (uint32)(ValLoopStart->isNULL() ? 0 : ValLoopStart->getInt()); + CScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - if (FAILED(playMusic(channel, filename, Looping, LoopStart))) stack->pushBool(false); + if (FAILED(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -1278,10 +1278,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - int Volume = stack->pop()->getInt(); + int volume = stack->pop()->getInt(); if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else { - if (FAILED(_music[channel]->setVolume(Volume))) stack->pushBool(false); + if (FAILED(_music[channel]->setVolume(volume))) stack->pushBool(false); else stack->pushBool(true); } return S_OK; @@ -1311,8 +1311,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(4); int channel1 = stack->pop()->getInt(0); int channel2 = stack->pop()->getInt(0); - uint32 FadeLength = (uint32)stack->pop()->getInt(0); - bool Swap = stack->pop()->getBool(true); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); if (_musicCrossfadeRunning) { script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); @@ -1323,8 +1323,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _musicCrossfadeStartTime = _liveTimer; _musicCrossfadeChannel1 = channel1; _musicCrossfadeChannel2 = channel2; - _musicCrossfadeLength = FadeLength; - _musicCrossfadeSwap = Swap; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; _musicCrossfadeRunning = true; @@ -1338,16 +1338,16 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetSoundLength") == 0) { stack->correctParams(1); - int Length = 0; + int length = 0; const char *filename = stack->pop()->getString(); - CBSound *Sound = new CBSound(Game); - if (Sound && SUCCEEDED(Sound->setSound(filename, SOUND_MUSIC, true))) { - Length = Sound->getLength(); - delete Sound; - Sound = NULL; + CBSound *sound = new CBSound(Game); + if (sound && SUCCEEDED(sound->setSound(filename, SOUND_MUSIC, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; } - stack->pushInt(Length); + stack->pushInt(length); return S_OK; } @@ -1412,8 +1412,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->getInt(); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); bool FreezeMusic = stack->pop()->getBool(true); CScValue *valSub = stack->pop(); @@ -1423,7 +1423,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS Type = (int)VID_PLAY_STRETCH; if (SUCCEEDED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { - if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { + if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { stack->pushBool(true); script->Sleep(0); } else stack->pushBool(false); @@ -1445,26 +1445,26 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(7); const char *filename = stack->pop()->getString(); CScValue *valType = stack->pop(); - int Type; + int type; if (valType->isNULL()) - Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); + type = (int)VID_PLAY_STRETCH; + else type = valType->getInt(); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); - bool DropFrames = stack->pop()->getBool(true); + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); CScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; delete _theoraPlayer; _theoraPlayer = new CVidTheoraPlayer(this); if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(filename, SubtitleFile))) { - _theoraPlayer->_dontDropFrames = !DropFrames; - if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); script->Sleep(0); } else stack->pushBool(false); @@ -1492,9 +1492,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteNumber") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->getString(); - int Val = stack->pop()->getInt(); - _registry->WriteInt("PrivateSettings", Key, Val); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + _registry->WriteInt("PrivateSettings", key, val); stack->pushNULL(); return S_OK; } @@ -1504,9 +1504,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadNumber") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->getString(); - int InitVal = stack->pop()->getInt(); - stack->pushInt(_registry->ReadInt("PrivateSettings", Key, InitVal)); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + stack->pushInt(_registry->ReadInt("PrivateSettings", key, initVal)); return S_OK; } @@ -1515,9 +1515,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegWriteString") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->getString(); - const char *Val = stack->pop()->getString(); - _registry->WriteString("PrivateSettings", Key, Val); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + _registry->WriteString("PrivateSettings", key, val); stack->pushNULL(); return S_OK; } @@ -1527,9 +1527,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RegReadString") == 0) { stack->correctParams(2); - const char *Key = stack->pop()->getString(); - const char *InitVal = stack->pop()->getString(); - AnsiString val = _registry->ReadString("PrivateSettings", Key, InitVal); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + AnsiString val = _registry->ReadString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return S_OK; } @@ -1539,18 +1539,18 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveGame") == 0) { stack->correctParams(3); - int Slot = stack->pop()->getInt(); + int slot = stack->pop()->getInt(); const char *xdesc = stack->pop()->getString(); bool quick = stack->pop()->getBool(false); - char *Desc = new char[strlen(xdesc) + 1]; - strcpy(Desc, xdesc); + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); stack->pushBool(true); - if (FAILED(SaveGame(Slot, Desc, quick))) { + if (FAILED(SaveGame(slot, desc, quick))) { stack->pop(); stack->pushBool(false); } - delete [] Desc; + delete [] desc; return S_OK; } @@ -1581,11 +1581,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSaveSlotDescription") == 0) { stack->correctParams(1); - int Slot = stack->pop()->getInt(); - char Desc[512]; - Desc[0] = '\0'; - getSaveSlotDescription(Slot, Desc); - stack->pushString(Desc); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + getSaveSlotDescription(slot, desc); + stack->pushString(desc); return S_OK; } @@ -1594,8 +1594,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmptySaveSlot") == 0) { stack->correctParams(1); - int Slot = stack->pop()->getInt(); - emptySaveSlot(Slot); + int slot = stack->pop()->getInt(); + emptySaveSlot(slot); stack->pushNULL(); return S_OK; } @@ -1740,10 +1740,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); const char *filename = stack->pop()->getString(); - Common::SeekableReadStream *File = _fileManager->openFile(filename, false); - if (!File) stack->pushBool(false); + // TODO: Replace with fileExists + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (!file) stack->pushBool(false); else { - _fileManager->closeFile(File); + _fileManager->closeFile(file); stack->pushBool(true); } return S_OK; @@ -1754,15 +1755,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->getInt(500); - byte Red = stack->pop()->getInt(0); - byte Green = stack->pop()->getInt(0); - byte Blue = stack->pop()->getInt(0); - byte Alpha = stack->pop()->getInt(0xFF); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); - bool System = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - _fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration, System); + _fader->fadeOut(DRGBA(red, green, blue, alpha), duration, system); if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->WaitFor(_fader); stack->pushNULL(); @@ -1774,15 +1775,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { stack->correctParams(5); - uint32 Duration = stack->pop()->getInt(500); - byte Red = stack->pop()->getInt(0); - byte Green = stack->pop()->getInt(0); - byte Blue = stack->pop()->getInt(0); - byte Alpha = stack->pop()->getInt(0xFF); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - _fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration, System); + _fader->fadeIn(DRGBA(red, green, blue, alpha), duration, system); if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->WaitFor(_fader); stack->pushNULL(); @@ -1808,20 +1809,20 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CScValue *Val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO - int FileNum = 0; + int fileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), FileNum); + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); if (!Common::File::exists(filename)) break; - FileNum++; + fileNum++; } bool ret = false; - CBImage *Image = Game->_renderer->takeScreenshot(); - if (Image) { - ret = SUCCEEDED(Image->saveBMPFile(filename)); - delete Image; + CBImage *image = Game->_renderer->takeScreenshot(); + if (image) { + ret = SUCCEEDED(image->saveBMPFile(filename)); + delete image; } else ret = false; stack->pushBool(ret); @@ -1834,15 +1835,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "ScreenshotEx") == 0) { stack->correctParams(3); const char *filename = stack->pop()->getString(); - int SizeX = stack->pop()->getInt(_renderer->_width); - int SizeY = stack->pop()->getInt(_renderer->_height); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); bool ret = false; - CBImage *Image = Game->_renderer->takeScreenshot(); - if (Image) { - ret = SUCCEEDED(Image->resize(SizeX, SizeY)); - if (ret) ret = SUCCEEDED(Image->saveBMPFile(filename)); - delete Image; + CBImage *image = Game->_renderer->takeScreenshot(); + if (image) { + ret = SUCCEEDED(image->resize(sizeX, sizeY)); + if (ret) ret = SUCCEEDED(image->saveBMPFile(filename)); + delete image; } else ret = false; stack->pushBool(ret); @@ -1854,13 +1855,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIWindow *Win = new CUIWindow(Game); - _windows.Add(Win); - registerObject(Win); - if (!Val->isNULL()) Win->setName(Val->getString()); - stack->pushNative(Win, true); + CUIWindow *win = new CUIWindow(Game); + _windows.Add(win); + registerObject(win); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); return S_OK; } @@ -1869,9 +1870,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); - CBObject *Obj = (CBObject *)stack->pop()->getNative(); + CBObject *obj = (CBObject *)stack->pop()->getNative(); for (int i = 0; i < _windows.GetSize(); i++) { - if (_windows[i] == Obj) { + if (_windows[i] == obj) { unregisterObject(_windows[i]); stack->pushBool(true); return S_OK; @@ -1905,15 +1906,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); _loadImageX = stack->pop()->getInt(); _loadImageY = stack->pop()->getInt(); - if (Val->isNULL()) { + if (val->isNULL()) { delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::setString(&_loadImageName, Val->getString()); + CBUtils::setString(&_loadImageName, val->getString()); } stack->pushNULL(); return S_OK; @@ -1924,15 +1925,15 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); _saveImageX = stack->pop()->getInt(); _saveImageY = stack->pop()->getInt(); - if (Val->isNULL()) { + if (val->isNULL()) { delete[] _saveImageName; _saveImageName = NULL; } else { - CBUtils::setString(&_saveImageName, Val->getString()); + CBUtils::setString(&_saveImageName, val->getString()); } stack->pushNULL(); return S_OK; @@ -2092,33 +2093,33 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetFileChecksum") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - bool AsHex = stack->pop()->getBool(false); + bool asHex = stack->pop()->getBool(false); - Common::SeekableReadStream *File = _fileManager->openFile(filename, false); - if (File) { + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (file) { crc remainder = crc_initialize(); - byte Buf[1024]; - int BytesRead = 0; + byte buf[1024]; + int bytesRead = 0; - while (BytesRead < File->size()) { - int BufSize = MIN((uint32)1024, (uint32)(File->size() - BytesRead)); - BytesRead += File->read(Buf, BufSize); + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); - for (int i = 0; i < BufSize; i++) { - remainder = crc_process_byte(Buf[i], remainder); + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); } } crc checksum = crc_finalize(remainder); - if (AsHex) { + if (asHex) { char Hex[100]; sprintf(Hex, "%x", checksum); stack->pushString(Hex); } else stack->pushInt(checksum); - _fileManager->closeFile(File); - File = NULL; + _fileManager->closeFile(file); + file = NULL; } else stack->pushNULL(); return S_OK; @@ -2541,7 +2542,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeviceType") == 0) { - _scValue->setString(GetDeviceType().c_str()); + _scValue->setString(getDeviceType().c_str()); return _scValue; } @@ -2618,7 +2619,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { // Interactive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Interactive") == 0) { - SetInteractive(value->getBool()); + setInteractive(value->getBool()); return S_OK; } @@ -2774,10 +2775,8 @@ const char *CBGame::scToString() { HRESULT CBGame::displayQuickMsg() { if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; - int i; - // update - for (i = 0; i < _quickMessages.GetSize(); i++) { + for (int i = 0; i < _quickMessages.GetSize(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; _quickMessages.RemoveAt(i); @@ -2788,7 +2787,7 @@ HRESULT CBGame::displayQuickMsg() { int posY = 20; // display - for (i = 0; i < _quickMessages.GetSize(); i++) { + for (int i = 0; i < _quickMessages.GetSize(); i++) { _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } @@ -2831,10 +2830,8 @@ HRESULT CBGame::registerObject(CBObject *object) { HRESULT CBGame::unregisterObject(CBObject *object) { if (!object) return S_OK; - int i; - // is it a window? - for (i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.GetSize(); i++) { if ((CBObject *)_windows[i] == object) { _windows.RemoveAt(i); @@ -2854,7 +2851,7 @@ HRESULT CBGame::unregisterObject(CBObject *object) { if (_store) _store->OnObjectDestroyed(object); // destroy object - for (i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.GetSize(); i++) { if (_regObjects[i] == object) { _regObjects.RemoveAt(i); if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); @@ -2938,7 +2935,7 @@ void CBGame::PublishNatives() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *this_obj; + CScValue *thisObj; ////////////////////////////////////////////////////////////////////////// // LOG @@ -2953,9 +2950,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // String ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "String") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXString(Game, stack)); + thisObj->setNative(makeSXString(Game, stack)); stack->pushNULL(); } @@ -2963,9 +2960,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // MemBuffer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MemBuffer") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXMemBuffer(Game, stack)); + thisObj->setNative(makeSXMemBuffer(Game, stack)); stack->pushNULL(); } @@ -2973,9 +2970,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // File ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "File") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXFile(Game, stack)); + thisObj->setNative(makeSXFile(Game, stack)); stack->pushNULL(); } @@ -2983,9 +2980,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // Date ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Date") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXDate(Game, stack)); + thisObj->setNative(makeSXDate(Game, stack)); stack->pushNULL(); } @@ -2993,9 +2990,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // Array ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Array") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXArray(Game, stack)); + thisObj->setNative(makeSXArray(Game, stack)); stack->pushNULL(); } @@ -3003,9 +3000,9 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS // Object ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Object") == 0) { - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(makeSXObject(Game, stack)); + thisObj->setNative(makeSXObject(Game, stack)); stack->pushNULL(); } @@ -3174,11 +3171,11 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToString") == 0) { stack->correctParams(1); - const char *Str = stack->pop()->getString(); - char *Str2 = new char[strlen(Str) + 1]; - strcpy(Str2, Str); - stack->pushString(Str2); - delete [] Str2; + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete [] str2; } ////////////////////////////////////////////////////////////////////////// @@ -3186,8 +3183,8 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToInt") == 0) { stack->correctParams(1); - int Val = stack->pop()->getInt(); - stack->pushInt(Val); + int val = stack->pop()->getInt(); + stack->pushInt(val); } ////////////////////////////////////////////////////////////////////////// @@ -3195,8 +3192,8 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToFloat") == 0) { stack->correctParams(1); - double Val = stack->pop()->getFloat(); - stack->pushFloat(Val); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); } ////////////////////////////////////////////////////////////////////////// @@ -3204,8 +3201,8 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToBool") == 0) { stack->correctParams(1); - bool Val = stack->pop()->getBool(); - stack->pushBool(Val); + bool val = stack->pop()->getBool(); + stack->pushBool(val); } ////////////////////////////////////////////////////////////////////////// @@ -3272,7 +3269,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { _registry->WriteInt("System", "MostRecentSaveSlot", slot); -save_finish: +save_finish: // TODO: Remove gotos delete pm; _indicatorDisplay = false; @@ -3399,12 +3396,10 @@ void CBGame::afterLoadScript(void *script, void *data) { HRESULT CBGame::displayWindows(bool inGame) { HRESULT res; - int i; - // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { _focusedWindow = NULL; - for (i = _windows.GetSize() - 1; i >= 0; i--) { + for (int i = _windows.GetSize() - 1; i >= 0; i--) { if (_windows[i]->_visible && !_windows[i]->_disable) { _focusedWindow = _windows[i]; break; @@ -3413,7 +3408,7 @@ HRESULT CBGame::displayWindows(bool inGame) { } // display all windows - for (i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); @@ -3493,7 +3488,6 @@ HRESULT CBGame::resumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::setMusicStartTime(int channel, uint32 time) { - if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return E_FAIL; @@ -3527,15 +3521,15 @@ HRESULT CBGame::loadSettings(const char *filename) { TOKEN_TABLE_END - byte *OrigBuffer = Game->_fileManager->readWholeFile(filename); - if (OrigBuffer == NULL) { + byte *origBuffer = Game->_fileManager->readWholeFile(filename); + if (origBuffer == NULL) { Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); return E_FAIL; } HRESULT ret = S_OK; - byte *buffer = OrigBuffer; + byte *buffer = origBuffer; byte *params; int cmd; CBParser parser(Game); @@ -3622,7 +3616,7 @@ HRESULT CBGame::loadSettings(const char *filename) { _compressedSavegames = _registry->ReadBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; - delete [] OrigBuffer; + delete [] origBuffer; return ret; } @@ -3630,7 +3624,8 @@ HRESULT CBGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); + if (!persistMgr->_saving) + cleanup(); CBObject::persist(persistMgr); @@ -3718,7 +3713,8 @@ HRESULT CBGame::persist(CBPersistMgr *persistMgr) { else _store = NULL; - if (!persistMgr->_saving) _quitting = false; + if (!persistMgr->_saving) + _quitting = false; return S_OK; } @@ -3728,8 +3724,7 @@ HRESULT CBGame::persist(CBPersistMgr *persistMgr) { HRESULT CBGame::focusWindow(CUIWindow *Window) { CUIWindow *Prev = _focusedWindow; - int i; - for (i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.GetSize(); i++) { if (_windows[i] == Window) { if (i < _windows.GetSize() - 1) { _windows.RemoveAt(i); @@ -3832,23 +3827,23 @@ void CBGame::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// bool CBGame::handleMouseWheel(int Delta) { - bool Handled = false; + bool handled = false; if (_focusedWindow) { - Handled = Game->_focusedWindow->handleMouseWheel(Delta); + handled = Game->_focusedWindow->handleMouseWheel(Delta); - if (!Handled) { + if (!handled) { if (Delta < 0 && Game->_focusedWindow->canHandleEvent("MouseWheelDown")) { Game->_focusedWindow->applyEvent("MouseWheelDown"); - Handled = true; + handled = true; } else if (Game->_focusedWindow->canHandleEvent("MouseWheelUp")) { Game->_focusedWindow->applyEvent("MouseWheelUp"); - Handled = true; + handled = true; } } } - if (!Handled) { + if (!handled) { if (Delta < 0) { applyEvent("MouseWheelDown"); } else { @@ -3875,18 +3870,18 @@ HRESULT CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte ////////////////////////////////////////////////////////////////////////// void CBGame::setWindowTitle() { if (_renderer) { - char Title[512]; - strcpy(Title, _caption[0]); - if (Title[0] != '\0') strcat(Title, " - "); - strcat(Title, "WME Lite"); + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') strcat(title, " - "); + strcat(title, "WME Lite"); - Utf8String title; + Utf8String utf8Title; if (_textEncoding == TEXT_UTF8) { - title = Utf8String(Title); + utf8Title = Utf8String(title); } else { warning("CBGame::SetWindowTitle -Ignoring textencoding"); - title = Utf8String(Title); + utf8Title = Utf8String(title); /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } @@ -3901,11 +3896,11 @@ void CBGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getSaveSlotFilename(int Slot, char *Buffer) { +HRESULT CBGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - sprintf(Buffer, "save%03d.%s", Slot, _savedGameExt); - warning("Saving %s - we really should prefix these things to avoid collisions.", Buffer); + sprintf(buffer, "save%03d.%s", slot, _savedGameExt); + warning("Saving %s - we really should prefix these things to avoid collisions.", buffer); return S_OK; } @@ -3959,9 +3954,9 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::emptySaveSlot(int Slot) { +HRESULT CBGame::emptySaveSlot(int slot) { char filename[MAX_PATH + 1]; - getSaveSlotFilename(Slot, filename); + getSaveSlotFilename(slot, filename); CBPlatform::DeleteFile(filename); @@ -4051,7 +4046,7 @@ HRESULT CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::windowLoadHook(CUIWindow *win, char **Buf, char **Params) { +HRESULT CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { return E_FAIL; } @@ -4063,7 +4058,7 @@ HRESULT CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScSta ////////////////////////////////////////////////////////////////////////// -void CBGame::SetInteractive(bool state) { +void CBGame::setInteractive(bool state) { _interactive = state; if (_transMgr) _transMgr->_origInteractive = state; } @@ -4138,9 +4133,9 @@ HRESULT CBGame::updateMusicCrossfade() { if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); - uint32 CurrentTime = Game->_liveTimer - _musicCrossfadeStartTime; + uint32 currentTime = Game->_liveTimer - _musicCrossfadeStartTime; - if (CurrentTime >= _musicCrossfadeLength) { + if (currentTime >= _musicCrossfadeLength) { _musicCrossfadeRunning = false; //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); _music[_musicCrossfadeChannel2]->setVolume(100); @@ -4164,8 +4159,8 @@ HRESULT CBGame::updateMusicCrossfade() { } else { //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolume(100 - (float)CurrentTime / (float)_musicCrossfadeLength * 100); - _music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel1]->setVolume(100 - (float)currentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel2]->setVolume((float)currentTime / (float)_musicCrossfadeLength * 100); //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } @@ -4247,30 +4242,30 @@ HRESULT CBGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::drawCursor(CBSprite *Cursor) { - if (!Cursor) return E_FAIL; - if (Cursor != _lastCursor) { - Cursor->Reset(); - _lastCursor = Cursor; +HRESULT CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return E_FAIL; + if (cursor != _lastCursor) { + cursor->Reset(); + _lastCursor = cursor; } - return Cursor->Draw(_mousePos.x, _mousePos.y); + return cursor->Draw(_mousePos.x, _mousePos.y); } ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onActivate(bool Activate, bool RefreshMouse) { +HRESULT CBGame::onActivate(bool activate, bool refreshMouse) { if (_shuttingDown || !_renderer) return S_OK; - _renderer->_active = Activate; + _renderer->_active = activate; - if (RefreshMouse) { + if (refreshMouse) { POINT p; getMousePos(&p); setActiveObject(_renderer->getObjectAt(p.x, p.y)); } - if (Activate) _soundMgr->resumeAll(); + if (activate) _soundMgr->resumeAll(); else _soundMgr->pauseAll(); return S_OK; @@ -4280,8 +4275,8 @@ HRESULT CBGame::onActivate(bool Activate, bool RefreshMouse) { HRESULT CBGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftClick"); } @@ -4302,8 +4297,8 @@ HRESULT CBGame::onMouseLeftUp() { _capturedObject = NULL; _mouseLeftDown = false; - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftRelease")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftRelease")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftRelease"); } @@ -4317,8 +4312,8 @@ HRESULT CBGame::onMouseLeftDblClick() { if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftDoubleClick"); } @@ -4332,8 +4327,8 @@ HRESULT CBGame::onMouseRightDblClick() { if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightDoubleClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightDoubleClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightDoubleClick"); } @@ -4345,8 +4340,8 @@ HRESULT CBGame::onMouseRightDblClick() { HRESULT CBGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightClick"); } @@ -4358,8 +4353,8 @@ HRESULT CBGame::onMouseRightDown() { HRESULT CBGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightRelease"); } @@ -4373,8 +4368,8 @@ HRESULT CBGame::onMouseMiddleDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleClick")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleClick")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("MiddleClick"); } @@ -4386,8 +4381,8 @@ HRESULT CBGame::onMouseMiddleDown() { HRESULT CBGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - bool Handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); - if (!Handled) { + bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); + if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("MiddleRelease"); } @@ -4436,9 +4431,9 @@ HRESULT CBGame::displayDebugInfo() { _renderer->displayDebugInfo(); - int ScrTotal, ScrRunning, ScrWaiting, ScrPersistent; - ScrTotal = _scEngine->GetNumScripts(&ScrRunning, &ScrWaiting, &ScrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", ScrTotal, ScrRunning, ScrWaiting, ScrPersistent); + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->GetNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); @@ -4501,7 +4496,7 @@ void CBGame::getMousePos(POINT *pos) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::MiniUpdate() { +HRESULT CBGame::miniUpdate() { if (!_miniUpdateEnabled) return S_OK; if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { @@ -4572,7 +4567,7 @@ void CBGame::addMem(int bytes) { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::GetDeviceType() const { +AnsiString CBGame::getDeviceType() const { #ifdef __IPHONEOS__ char devType[128]; IOS_GetDeviceType(devType); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 86b72d5730..6ece353ee7 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -89,7 +89,7 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - virtual HRESULT MiniUpdate(); + virtual HRESULT miniUpdate(); void getMousePos(POINT *Pos); RECT _mouseLockRect; @@ -144,9 +144,9 @@ public: bool _reportTextureFormat; HMODULE _resourceModule; - void setResourceModule(HMODULE ResModule); + void setResourceModule(HMODULE resModule); - void setEngineLogCallback(ENGINE_LOG_CALLBACK Callback = NULL, void *Data = NULL); + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); ENGINE_LOG_CALLBACK _engineLogCallback; void *_engineLogCallbackData; bool _editorMode; @@ -253,7 +253,7 @@ public: HRESULT getSaveSlotDescription(int slot, char *buffer); HRESULT getSaveSlotFilename(int slot, char *buffer); void setWindowTitle(); - virtual bool handleMouseWheel(int Delta); + virtual bool handleMouseWheel(int delta); bool _quitting; virtual HRESULT getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); @@ -333,9 +333,9 @@ public: bool _forceNonStreamedSounds; void resetMousePos(); int _subtitlesSpeed; - void SetInteractive(bool State); + void setInteractive(bool state); virtual HRESULT windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual HRESULT windowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name); + virtual HRESULT windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); HRESULT getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); HRESULT getCurrentViewportRect(RECT *rect, bool *custom = NULL); HRESULT popViewport(); @@ -351,7 +351,7 @@ public: bool _touchInterface; bool _constrainedMemory; - AnsiString GetDeviceType() const; + AnsiString getDeviceType() const; private: CBDebugger *_debugMgr; diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp index d7d58241cc..b5593a3e9c 100644 --- a/engines/wintermute/Base/BParser.cpp +++ b/engines/wintermute/Base/BParser.cpp @@ -115,7 +115,7 @@ long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data ////////////////////////////////////////////////////////////////////// long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; - Game->MiniUpdate(); + Game->miniUpdate(); char *name; return GetObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 340c22edda..d9441c20e4 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -249,7 +249,7 @@ HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, Game->_renderer->flip(); } } - Game->MiniUpdate(); + Game->miniUpdate(); (it->_value)->saveInstances(Game, persistMgr); } -- cgit v1.2.3 From f821b5c0a83e8b0b962db877238f2e8e7480bcc1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:48:18 +0200 Subject: WINTERMUTE: Rename VarName->varName in BObject --- engines/wintermute/Base/BObject.cpp | 54 ++++++++++++++++++++----------------- engines/wintermute/Base/BObject.h | 22 +++++++-------- 2 files changed, 41 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 8b92721a4e..49c4a19fcc 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -86,7 +86,8 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _rotateValid = false; _relativeRotate = 0.0f; - for (int i = 0; i < 7; i++) _caption[i] = NULL; + for (int i = 0; i < 7; i++) + _caption[i] = NULL; _saveState = true; _nonIntMouseEvents = false; @@ -107,7 +108,8 @@ CBObject::~CBObject() { ////////////////////////////////////////////////////////////////////////// HRESULT CBObject::cleanup() { - if (Game && Game->_activeObject == this) Game->_activeObject = NULL; + if (Game && Game->_activeObject == this) + Game->_activeObject = NULL; CBScriptHolder::cleanup(); delete[] _soundEvent; @@ -137,7 +139,8 @@ HRESULT CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// void CBObject::setCaption(const char *caption, int Case) { // TODO: rename Case to something usefull if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) return; + if (Case < 1 || Case > 7) + return; delete[] _caption[Case - 1]; _caption[Case - 1] = new char[strlen(caption) + 1]; @@ -149,10 +152,11 @@ void CBObject::setCaption(const char *caption, int Case) { // TODO: rename Case ////////////////////////////////////////////////////////////////////////// -char *CBObject::getCaption(int Case) { - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7 || _caption[Case - 1] == NULL) return ""; - else return _caption[Case - 1]; +char *CBObject::getCaption(int caseVal) { + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else return _caption[caseVal - 1]; } @@ -284,8 +288,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(3); const char *filename; - bool Looping; - uint32 LoopStart; + bool looping; + uint32 loopStart; CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); @@ -293,16 +297,17 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (val1->_type == VAL_BOOL) { filename = NULL; - Looping = val1->getBool(); - LoopStart = val2->getInt(); + looping = val1->getBool(); + loopStart = val2->getInt(); } else { if (val1->isNULL()) filename = NULL; else filename = val1->getString(); - Looping = val2->isNULL() ? false : val2->getBool(); - LoopStart = val3->getInt(); + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); } - if (FAILED(playSFX(filename, Looping, true, NULL, LoopStart))) stack->pushBool(false); + if (FAILED(playSFX(filename, looping, true, NULL, loopStart))) + stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -314,20 +319,20 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(2); const char *filename; - const char *EventName; + const char *eventName; CScValue *val1 = stack->pop(); CScValue *val2 = stack->pop(); if (val2->isNULL()) { filename = NULL; - EventName = val1->getString(); + eventName = val1->getString(); } else { filename = val1->getString(); - EventName = val2->getString(); + eventName = val2->getString(); } - if (FAILED(playSFX(filename, false, true, EventName))) stack->pushBool(false); + if (FAILED(playSFX(filename, false, true, eventName))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -405,8 +410,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "SetSoundVolume") == 0) { stack->correctParams(1); - int Volume = stack->pop()->getInt(); - if (FAILED(setSFXVolume(Volume))) stack->pushBool(false); + int volume = stack->pop()->getInt(); + if (FAILED(setSFXVolume(volume))) stack->pushBool(false); else stack->pushBool(true); return S_OK; } @@ -867,7 +872,8 @@ HRESULT CBObject::saveAsText(CBDynBuffer *buffer, int indent) { HRESULT CBObject::persist(CBPersistMgr *persistMgr) { CBScriptHolder::persist(persistMgr); - for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); persistMgr->transfer(TMEMBER(_activeCursor)); persistMgr->transfer(TMEMBER(_alphaColor)); persistMgr->transfer(TMEMBER(_autoSoundPanning)); @@ -1049,9 +1055,9 @@ HRESULT CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::setSFXVolume(int Volume) { - _sFXVolume = Volume; - if (_sFX) return _sFX->setVolume(Volume); +HRESULT CBObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) return _sFX->setVolume(volume); else return S_OK; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index a77bde0896..48d2ea667b 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -50,7 +50,7 @@ public: float _relativeRotate; bool _rotateValid; float _rotate; - void setSoundEvent(const char *EventName); + void setSoundEvent(const char *eventName); bool _rotatable; uint32 _alphaColor; float _scale; @@ -58,19 +58,19 @@ public: float _scaleY; float _relativeScale; virtual bool isReady(); - virtual bool getExtendedFlag(const char *FlagName); + virtual bool getExtendedFlag(const char *flagName); virtual HRESULT resetSoundPan(); virtual HRESULT updateSounds(); - HRESULT updateOneSound(CBSound *Sound); + HRESULT updateOneSound(CBSound *sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; - HRESULT setSFXTime(uint32 Time); - HRESULT setSFXVolume(int Volume); + HRESULT setSFXTime(uint32 time); + HRESULT setSFXVolume(int volume); HRESULT resumeSFX(); HRESULT pauseSFX(); - HRESULT stopSFX(bool DeleteSound = true); - HRESULT playSFX(const char *filename, bool Looping = false, bool PlayNow = true, const char *EventName = NULL, uint32 LoopStart = 0); + HRESULT stopSFX(bool deleteSound = true); + HRESULT playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -79,15 +79,15 @@ public: float _sFXParam3; float _sFXParam4; - virtual bool handleMouseWheel(int Delta); - virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); + virtual bool handleMouseWheel(int delta); + virtual HRESULT handleMouse(TMouseEvent event, TMouseButton button); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual int getHeight(); HRESULT setCursor(const char *filename); HRESULT setActiveCursor(const char *filename); HRESULT cleanup(); - char *getCaption(int Case = 1); - void setCaption(const char *Caption, int Case = 1); + char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); bool _editorSelected; bool _editorAlwaysRegister; bool _editorOnly; -- cgit v1.2.3 From 952998bac51400131d08de5bb4ee6720d270a6df Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:49:37 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BPackage --- engines/wintermute/Base/BPackage.cpp | 8 ++++---- engines/wintermute/Base/BPackage.h | 4 ++-- engines/wintermute/Base/file/BPkgFile.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index 69ae1c6eff..e75e537df5 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -52,7 +52,7 @@ CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBPackage::~CBPackage() { if (_name) delete [] _name; - CloseFilePointer(_file); + closeFilePointer(_file); } @@ -60,7 +60,7 @@ CBPackage::~CBPackage() { HRESULT CBPackage::open() { if (_file) return S_OK; else { - _file = GetFilePointer(); + _file = getFilePointer(); return _file ? S_OK : E_FAIL; } } @@ -86,7 +86,7 @@ HRESULT CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *b } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::GetFilePointer() { +Common::SeekableReadStream *CBPackage::getFilePointer() { Common::File *file = Game->_fileManager->openPackage(_name); if (!file) { Game->_fileManager->requestCD(_cD, _name, ""); @@ -96,7 +96,7 @@ Common::SeekableReadStream *CBPackage::GetFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::CloseFilePointer(Common::SeekableReadStream *&file) { +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { delete file; file = NULL; } diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h index 7b4e8a4d6c..6135e5324a 100644 --- a/engines/wintermute/Base/BPackage.h +++ b/engines/wintermute/Base/BPackage.h @@ -40,8 +40,8 @@ namespace WinterMute { class CBPackage : public CBBase { public: - Common::SeekableReadStream *GetFilePointer(); - void CloseFilePointer(Common::SeekableReadStream *&file); + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); bool _boundToExe; byte _priority; diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index 2ca74c1ac7..08a92b52f6 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -79,7 +79,7 @@ Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileMa fileEntry = fileManager->getPackageEntry(fileName); if (!fileEntry) return NULL; - file = fileEntry->_package->GetFilePointer(); + file = fileEntry->_package->getFilePointer(); if (!file) return NULL; // TODO: Cleanup -- cgit v1.2.3 From d634b7d42789dfb73adae634df01ea224dead37d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:55:35 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BParser --- engines/wintermute/Ad/AdActor.cpp | 34 +++++++++--------- engines/wintermute/Ad/AdEntity.cpp | 44 +++++++++++------------ engines/wintermute/Ad/AdGame.cpp | 10 +++--- engines/wintermute/Ad/AdInventoryBox.cpp | 20 +++++------ engines/wintermute/Ad/AdItem.cpp | 18 +++++----- engines/wintermute/Ad/AdLayer.cpp | 16 ++++----- engines/wintermute/Ad/AdRegion.cpp | 22 ++++++------ engines/wintermute/Ad/AdResponseBox.cpp | 10 +++--- engines/wintermute/Ad/AdRotLevel.cpp | 8 ++--- engines/wintermute/Ad/AdScaleLevel.cpp | 8 ++--- engines/wintermute/Ad/AdScene.cpp | 48 ++++++++++++------------- engines/wintermute/Ad/AdSpriteSet.cpp | 4 +-- engines/wintermute/Ad/AdTalkDef.cpp | 4 +-- engines/wintermute/Ad/AdTalkNode.cpp | 10 +++--- engines/wintermute/Ad/AdWaypointGroup.cpp | 10 +++--- engines/wintermute/Base/BBase.cpp | 4 +-- engines/wintermute/Base/BFont.cpp | 4 +-- engines/wintermute/Base/BFontBitmap.cpp | 28 +++++++-------- engines/wintermute/Base/BFontTT.cpp | 28 +++++++-------- engines/wintermute/Base/BFrame.cpp | 34 +++++++++--------- engines/wintermute/Base/BGame.cpp | 60 +++++++++++++++---------------- engines/wintermute/Base/BParser.cpp | 48 ++++++++++++------------- engines/wintermute/Base/BParser.h | 27 +++++++------- engines/wintermute/Base/BRegion.cpp | 10 +++--- engines/wintermute/Base/BScriptHolder.cpp | 4 +-- engines/wintermute/Base/BSprite.cpp | 22 ++++++------ engines/wintermute/Base/BSubFrame.cpp | 24 ++++++------- engines/wintermute/UI/UIButton.cpp | 26 +++++++------- engines/wintermute/UI/UIEdit.cpp | 24 ++++++------- engines/wintermute/UI/UIEntity.cpp | 12 +++---- engines/wintermute/UI/UIText.cpp | 18 +++++----- engines/wintermute/UI/UITiledImage.cpp | 26 +++++++------- engines/wintermute/UI/UIWindow.cpp | 40 ++++++++++----------- 33 files changed, 353 insertions(+), 352 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 915399ea67..116f8e9794 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -228,7 +228,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { Game->LOG(0, "'ACTOR' keyword expected."); return E_FAIL; } @@ -238,18 +238,18 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { CAdGame *adGame = (CAdGame *)Game; CAdSpriteSet *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_NAME: @@ -265,26 +265,26 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &_zoomable); + parser.scanStr((char *)params, "%b", &_zoomable); break; case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &_rotatable); + parser.scanStr((char *)params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &_registrable); + parser.scanStr((char *)params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &_shadowable); + parser.scanStr((char *)params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); + parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_WALK: @@ -346,12 +346,12 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &_sFXVolume); + parser.scanStr((char *)params, "%d", &_sFXVolume); break; case TOKEN_SCALE: { int s; - parser.ScanStr((char *)params, "%d", &s); + parser.scanStr((char *)params, "%d", &s); _scale = (float)s; } @@ -359,14 +359,14 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_RELATIVE_SCALE: { int s; - parser.ScanStr((char *)params, "%d", &s); + parser.scanStr((char *)params, "%d", &s); _relativeScale = (float)s; } break; case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &_autoSoundPanning); + parser.scanStr((char *)params, "%b", &_autoSoundPanning); break; case TOKEN_PROPERTY: @@ -416,15 +416,15 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &_ignoreItems); + parser.scanStr((char *)params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); + parser.scanStr((char *)params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: @@ -1281,7 +1281,7 @@ HRESULT CAdActor::mergeAnims(const char *animsFilename) { HRESULT Ret = S_OK; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 5e2fb233d4..c5edae5a8f 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -201,7 +201,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { Game->LOG(0, "'ENTITY' keyword expected."); return E_FAIL; } @@ -211,18 +211,18 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { CAdGame *adGame = (CAdGame *)Game; CBSprite *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_SPRITE: { @@ -265,12 +265,12 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCALABLE: - parser.ScanStr((char *)params, "%b", &_zoomable); + parser.scanStr((char *)params, "%b", &_zoomable); break; case TOKEN_SCALE: { int s; - parser.ScanStr((char *)params, "%d", &s); + parser.scanStr((char *)params, "%d", &s); _scale = (float)s; } @@ -278,7 +278,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_RELATIVE_SCALE: { int s; - parser.ScanStr((char *)params, "%d", &s); + parser.scanStr((char *)params, "%d", &s); _relativeScale = (float)s; } @@ -286,21 +286,21 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_ROTABLE: case TOKEN_ROTATABLE: - parser.ScanStr((char *)params, "%b", &_rotatable); + parser.scanStr((char *)params, "%b", &_rotatable); break; case TOKEN_REGISTRABLE: case TOKEN_INTERACTIVE: - parser.ScanStr((char *)params, "%b", &_registrable); + parser.scanStr((char *)params, "%b", &_registrable); break; case TOKEN_SHADOWABLE: case TOKEN_COLORABLE: - parser.ScanStr((char *)params, "%b", &_shadowable); + parser.scanStr((char *)params, "%b", &_shadowable); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); + parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_CURSOR: @@ -314,7 +314,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); + parser.scanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_REGION: { @@ -399,19 +399,19 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SOUND_START_TIME: - parser.ScanStr((char *)params, "%d", &_sFXStart); + parser.scanStr((char *)params, "%d", &_sFXStart); break; case TOKEN_SOUND_VOLUME: - parser.ScanStr((char *)params, "%d", &_sFXVolume); + parser.scanStr((char *)params, "%d", &_sFXVolume); break; case TOKEN_SOUND_PANNING: - parser.ScanStr((char *)params, "%b", &_autoSoundPanning); + parser.scanStr((char *)params, "%b", &_autoSoundPanning); break; case TOKEN_SAVE_STATE: - parser.ScanStr((char *)params, "%b", &_saveState); + parser.scanStr((char *)params, "%b", &_saveState); break; case TOKEN_PROPERTY: @@ -419,15 +419,15 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_IGNORE_ITEMS: - parser.ScanStr((char *)params, "%b", &_ignoreItems); + parser.scanStr((char *)params, "%b", &_ignoreItems); break; case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); + parser.scanStr((char *)params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: @@ -435,16 +435,16 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WALK_TO_X: - parser.ScanStr((char *)params, "%d", &_walkToX); + parser.scanStr((char *)params, "%d", &_walkToX); break; case TOKEN_WALK_TO_Y: - parser.ScanStr((char *)params, "%d", &_walkToY); + parser.scanStr((char *)params, "%d", &_walkToY); break; case TOKEN_WALK_TO_DIR: { int i; - parser.ScanStr((char *)params, "%d", &i); + parser.scanStr((char *)params, "%d", &i); if (i < 0) i = 0; if (i >= NUM_DIRECTIONS) i = DI_NONE; _walkToDir = (TDirection)i; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 2e8e77d36e..58b3250deb 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1171,14 +1171,14 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { bool itemFound = false, itemsFound = false; - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: if (FAILED(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; break; case TOKEN_AD_GAME: - while (cmd > 0 && (cmd = parser.GetCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { switch (cmd) { case TOKEN_RESPONSE_BOX: delete _responseBox; @@ -1222,7 +1222,7 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCENE_VIEWPORT: { RECT rc; - parser.ScanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); } @@ -1419,7 +1419,7 @@ HRESULT CAdGame::loadItemsBuffer(byte *buffer, bool merge) { while (_items.GetSize() > 0) deleteItem(_items[0]); } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ITEM: { CAdItem *item = new CAdItem(Game); @@ -1492,7 +1492,7 @@ HRESULT CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { int cmd = PARSERR_GENERIC; CBParser parser(Game); - cmd = parser.GetCommand(buffer, commands, params); + cmd = parser.getCommand(buffer, commands, params); switch (cmd) { case TOKEN_ENTITY_CONTAINER: { CUIEntity *ent = new CUIEntity(Game); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 7ebcc4457f..8472ab122e 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -217,14 +217,14 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { _exclusive = false; if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { Game->LOG(0, "'INVENTORY_BOX' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -249,35 +249,35 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); break; case TOKEN_EXCLUSIVE: - parser.ScanStr((char *)params, "%b", &_exclusive); + parser.scanStr((char *)params, "%b", &_exclusive); break; case TOKEN_HIDE_SELECTED: - parser.ScanStr((char *)params, "%b", &_hideSelected); + parser.scanStr((char *)params, "%b", &_hideSelected); break; case TOKEN_ALWAYS_VISIBLE: - parser.ScanStr((char *)params, "%b", &always_visible); + parser.scanStr((char *)params, "%b", &always_visible); break; case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &_spacing); + parser.scanStr((char *)params, "%d", &_spacing); break; case TOKEN_ITEM_WIDTH: - parser.ScanStr((char *)params, "%d", &_itemWidth); + parser.scanStr((char *)params, "%d", &_itemWidth); break; case TOKEN_ITEM_HEIGHT: - parser.ScanStr((char *)params, "%d", &_itemHeight); + parser.scanStr((char *)params, "%d", &_itemHeight); break; case TOKEN_SCROLL_BY: - parser.ScanStr((char *)params, "%d", &_scrollBy); + parser.scanStr((char *)params, "%d", &_scrollBy); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 2ef7f0c200..e431ca78cf 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -169,7 +169,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { Game->LOG(0, "'ITEM' keyword expected."); return E_FAIL; } @@ -177,7 +177,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { } int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -216,19 +216,19 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AMOUNT: - parser.ScanStr((char *)params, "%d", &_amount); + parser.scanStr((char *)params, "%d", &_amount); break; case TOKEN_DISPLAY_AMOUNT: - parser.ScanStr((char *)params, "%b", &_displayAmount); + parser.scanStr((char *)params, "%b", &_displayAmount); break; case TOKEN_AMOUNT_OFFSET_X: - parser.ScanStr((char *)params, "%d", &_amountOffsetX); + parser.scanStr((char *)params, "%d", &_amountOffsetX); break; case TOKEN_AMOUNT_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &_amountOffsetY); + parser.scanStr((char *)params, "%d", &_amountOffsetY); break; case TOKEN_AMOUNT_ALIGN: @@ -276,7 +276,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_CURSOR_COMBINED: - parser.ScanStr((char *)params, "%b", &_cursorCombined); + parser.scanStr((char *)params, "%b", &_cursorCombined); break; case TOKEN_SCRIPT: @@ -288,11 +288,11 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); + parser.scanStr((char *)params, "%d", &alpha); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index e71a31587c..64d36e67db 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -123,14 +123,14 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { Game->LOG(0, "'LAYER' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -145,23 +145,23 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_MAIN: - parser.ScanStr((char *)params, "%b", &_main); + parser.scanStr((char *)params, "%b", &_main); break; case TOKEN_CLOSE_UP: - parser.ScanStr((char *)params, "%b", &_closeUp); + parser.scanStr((char *)params, "%b", &_closeUp); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); + parser.scanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); + parser.scanStr((char *)params, "%d", &_height); break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); + parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_REGION: { @@ -198,7 +198,7 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); + parser.scanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_SCRIPT: diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 6aa201c60d..0ea0bb9ed1 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -121,7 +121,7 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); return E_FAIL; } @@ -133,7 +133,7 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { int ar = 255, ag = 255, ab = 255, alpha = 255; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -148,46 +148,46 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); + parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_BLOCKED: - parser.ScanStr((char *)params, "%b", &_blocked); + parser.scanStr((char *)params, "%b", &_blocked); break; case TOKEN_DECORATION: - parser.ScanStr((char *)params, "%b", &_decoration); + parser.scanStr((char *)params, "%b", &_decoration); break; case TOKEN_ZOOM: case TOKEN_SCALE: { int j; - parser.ScanStr((char *)params, "%d", &j); + parser.scanStr((char *)params, "%d", &j); _zoom = (float)j; } break; case TOKEN_POINT: { int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr((char *)params, "%d,%d", &x, &y); _points.Add(new CBPoint(x, y)); } break; case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); + parser.scanStr((char *)params, "%d", &alpha); break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); + parser.scanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_SCRIPT: diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 6841705701..eb9912fb14 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -245,14 +245,14 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { Game->LOG(0, "'RESPONSE_BOX' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -281,11 +281,11 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AREA: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); break; case TOKEN_HORIZONTAL: - parser.ScanStr((char *)params, "%b", &_horizontal); + parser.scanStr((char *)params, "%b", &_horizontal); break; case TOKEN_TEXT_ALIGN: @@ -301,7 +301,7 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SPACING: - parser.ScanStr((char *)params, "%d", &_spacing); + parser.scanStr((char *)params, "%d", &_spacing); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 356771d0fa..dbe00460dc 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -96,26 +96,26 @@ HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_ROTATION: { int i; - parser.ScanStr((char *)params, "%d", &i); + parser.scanStr((char *)params, "%d", &i); _rotation = (float)i; } break; diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index ba3a9806c6..d0f1d479b3 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -94,26 +94,26 @@ HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { Game->LOG(0, "'SCALE_LEVEL' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_SCALE: { int i; - parser.ScanStr((char *)params, "%d", &i); + parser.scanStr((char *)params, "%d", &i); _scale = (float)i; } break; diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 3c73d1b33a..7415de6add 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -613,7 +613,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { Game->LOG(0, "'SCENE' keyword expected."); return E_FAIL; } @@ -624,7 +624,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { char camera[MAX_PATH] = ""; /* float WaypointHeight = -1.0f; */ - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -722,91 +722,91 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_MARGIN_H: - parser.ScanStr((char *)params, "%d", &_editorMarginH); + parser.scanStr((char *)params, "%d", &_editorMarginH); break; case TOKEN_EDITOR_MARGIN_V: - parser.ScanStr((char *)params, "%d", &_editorMarginV); + parser.scanStr((char *)params, "%d", &_editorMarginV); break; case TOKEN_EDITOR_COLOR_FRAME: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColFrame = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColEntity = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColEntitySel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColRegionSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColDecorSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColBlockedSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColWaypointsSel = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColRegion = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColDecor = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColBlocked = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColWaypoints = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_SCALE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); _editorColScale = DRGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_SHOW_REGIONS: - parser.ScanStr((char *)params, "%b", &_editorShowRegions); + parser.scanStr((char *)params, "%b", &_editorShowRegions); break; case TOKEN_EDITOR_SHOW_BLOCKED: - parser.ScanStr((char *)params, "%b", &_editorShowBlocked); + parser.scanStr((char *)params, "%b", &_editorShowBlocked); break; case TOKEN_EDITOR_SHOW_DECORATION: - parser.ScanStr((char *)params, "%b", &_editorShowDecor); + parser.scanStr((char *)params, "%b", &_editorShowDecor); break; case TOKEN_EDITOR_SHOW_ENTITIES: - parser.ScanStr((char *)params, "%b", &_editorShowEntities); + parser.scanStr((char *)params, "%b", &_editorShowEntities); break; case TOKEN_EDITOR_SHOW_SCALE: - parser.ScanStr((char *)params, "%b", &_editorShowScale); + parser.scanStr((char *)params, "%b", &_editorShowScale); break; case TOKEN_SCRIPT: @@ -819,17 +819,17 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: { RECT rc; - parser.ScanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); } case TOKEN_PERSISTENT_STATE: - parser.ScanStr((char *)params, "%b", &_persistentState); + parser.scanStr((char *)params, "%b", &_persistentState); break; case TOKEN_PERSISTENT_STATE_SPRITES: - parser.ScanStr((char *)params, "%b", &_persistentStateSprites); + parser.scanStr((char *)params, "%b", &_persistentStateSprites); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 26844667d9..296511491d 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -111,7 +111,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { Game->LOG(0, "'SPRITESET' keyword expected."); return E_FAIL; } @@ -119,7 +119,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr } CBSprite *spr = NULL; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 5b7f4b5e7a..8c48942de5 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -114,14 +114,14 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { Game->LOG(0, "'TALK' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 0cfadf396a..b398f84cfe 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -98,7 +98,7 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { Game->LOG(0, "'ACTION' keyword expected."); return E_FAIL; } @@ -109,7 +109,7 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { _playToEnd = false; _preCache = false; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: CBUtils::setString(&_spriteFilename, (char *)params); @@ -131,15 +131,15 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_START_TIME: - parser.ScanStr((char *)params, "%d", &_startTime); + parser.scanStr((char *)params, "%d", &_startTime); break; case TOKEN_END_TIME: - parser.ScanStr((char *)params, "%d", &_endTime); + parser.scanStr((char *)params, "%d", &_endTime); break; case TOKEN_PRECACHE: - parser.ScanStr((char *)params, "%b", &_preCache); + parser.scanStr((char *)params, "%b", &_preCache); break; case TOKEN_COMMENT: diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 0dde814fed..b845f4e02e 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -113,14 +113,14 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { Game->LOG(0, "'WAYPOINTS' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -132,17 +132,17 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr((char *)params, "%d,%d", &x, &y); _points.Add(new CBPoint(x, y)); } break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr((char *)params, "%b", &_editorSelected); + parser.scanStr((char *)params, "%b", &_editorSelected); break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index 3ca29e9dcd..f101eea69f 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -101,7 +101,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); return E_FAIL; } @@ -111,7 +111,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { char *propName = NULL; char *propValue = NULL; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] propName; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index 490b4be35d..d394f3e21b 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -121,7 +121,7 @@ HRESULT CBFont::loadBuffer(byte * Buffer) break; case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); custo_trans = true; break; } @@ -196,7 +196,7 @@ bool CBFont::isTrueType(CBGame *Game, const char *filename) { CBParser parser(Game); bool ret = false; - if (parser.GetCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) ret = true; delete [] buffer; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 4f60dea478..06c6055101 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -308,7 +308,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { Game->LOG(0, "'FONT' keyword expected."); return E_FAIL; } @@ -327,7 +327,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { int spaceWidth = 0; int expandWidth = 0; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: @@ -339,55 +339,55 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); custoTrans = true; break; case TOKEN_WIDTHS: - parser.ScanStr(params, "%D", widths, &num); + parser.scanStr(params, "%D", widths, &num); for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { _widths[lastWidth] = (byte)widths[i]; } break; case TOKEN_DEFAULT_WIDTH: - parser.ScanStr(params, "%d", &default_width); + parser.scanStr(params, "%d", &default_width); break; case TOKEN_WIDTHS_FRAME: - parser.ScanStr(params, "%d", &_widthsFrame); + parser.scanStr(params, "%d", &_widthsFrame); break; case TOKEN_COLUMNS: - parser.ScanStr(params, "%d", &_numColumns); + parser.scanStr(params, "%d", &_numColumns); break; case TOKEN_TILE_WIDTH: - parser.ScanStr(params, "%d", &_tileWidth); + parser.scanStr(params, "%d", &_tileWidth); break; case TOKEN_TILE_HEIGHT: - parser.ScanStr(params, "%d", &_tileHeight); + parser.scanStr(params, "%d", &_tileHeight); break; case TOKEN_AUTO_WIDTH: - parser.ScanStr(params, "%b", &autoWidth); + parser.scanStr(params, "%b", &autoWidth); break; case TOKEN_FONTEXT_FIX: - parser.ScanStr(params, "%b", &_fontextFix); + parser.scanStr(params, "%b", &_fontextFix); break; case TOKEN_PAINT_WHOLE_CELL: - parser.ScanStr(params, "%b", &_wholeCell); + parser.scanStr(params, "%b", &_wholeCell); break; case TOKEN_SPACE_WIDTH: - parser.ScanStr(params, "%d", &spaceWidth); + parser.scanStr(params, "%d", &spaceWidth); break; case TOKEN_EXPAND_WIDTH: - parser.ScanStr(params, "%d", &expandWidth); + parser.scanStr(params, "%d", &expandWidth); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 36231b5622..7eafd5fd90 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -460,7 +460,7 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { Game->LOG(0, "'TTFONT' keyword expected."); return E_FAIL; } @@ -468,10 +468,10 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { uint32 BaseColor = 0x00000000; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SIZE: - parser.ScanStr(params, "%d", &_fontHeight); + parser.scanStr(params, "%d", &_fontHeight); break; case TOKEN_FACE: @@ -483,19 +483,19 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { break; case TOKEN_BOLD: - parser.ScanStr(params, "%b", &_isBold); + parser.scanStr(params, "%b", &_isBold); break; case TOKEN_ITALIC: - parser.ScanStr(params, "%b", &_isItalic); + parser.scanStr(params, "%b", &_isItalic); break; case TOKEN_UNDERLINE: - parser.ScanStr(params, "%b", &_isUnderline); + parser.scanStr(params, "%b", &_isUnderline); break; case TOKEN_STRIKE: - parser.ScanStr(params, "%b", &_isStriked); + parser.scanStr(params, "%b", &_isStriked); break; case TOKEN_CHARSET: @@ -504,14 +504,14 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { case TOKEN_COLOR: { int r, g, b; - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); BaseColor = DRGBA(r, g, b, D3DCOLGetA(BaseColor)); } break; case TOKEN_ALPHA: { int a; - parser.ScanStr(params, "%d", &a); + parser.scanStr(params, "%d", &a); BaseColor = DRGBA(D3DCOLGetR(BaseColor), D3DCOLGetG(BaseColor), D3DCOLGetB(BaseColor), a); } break; @@ -560,26 +560,26 @@ HRESULT CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { int cmd; CBParser parser(Game); - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_OFFSET_X: - parser.ScanStr(params, "%d", &layer->_offsetX); + parser.scanStr(params, "%d", &layer->_offsetX); break; case TOKEN_OFFSET_Y: - parser.ScanStr(params, "%d", &layer->_offsetY); + parser.scanStr(params, "%d", &layer->_offsetY); break; case TOKEN_COLOR: { int r, g, b; - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); layer->_color = DRGBA(r, g, b, D3DCOLGetA(layer->_color)); } break; case TOKEN_ALPHA: { int a; - parser.ScanStr(params, "%d", &a); + parser.scanStr(params, "%d", &a); layer->_color = DRGBA(D3DCOLGetR(layer->_color), D3DCOLGetG(layer->_color), D3DCOLGetB(layer->_color), a); } break; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index b5dce4f041..58b0b5384b 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -173,10 +173,10 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { CBPlatform::SetRectEmpty(&rect); char *surface_file = NULL; - while ((cmd = parser.GetCommand((char **)&buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_DELAY: - parser.ScanStr(params, "%d", &_delay); + parser.scanStr(params, "%d", &_delay); break; case TOKEN_IMAGE: @@ -184,56 +184,56 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); custoTrans = true; break; case TOKEN_RECT: - parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); break; case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &hotspotX, &hotspotY); + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); break; case TOKEN_MOVE: - parser.ScanStr(params, "%d,%d", &_moveX, &_moveY); + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); break; case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &is2DOnly); + parser.scanStr(params, "%b", &is2DOnly); break; case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &is3DOnly); + parser.scanStr(params, "%b", &is3DOnly); break; case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &mirrorX); + parser.scanStr(params, "%b", &mirrorX); break; case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &mirrorY); + parser.scanStr(params, "%b", &mirrorY); break; case TOKEN_ALPHA_COLOR: - parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr(params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &editorSelected); + parser.scanStr(params, "%b", &editorSelected); break; case TOKEN_EDITOR_EXPANDED: - parser.ScanStr(params, "%b", &_editorExpanded); + parser.scanStr(params, "%b", &_editorExpanded); break; case TOKEN_KILL_SOUND: - parser.ScanStr(params, "%b", &_killSound); + parser.scanStr(params, "%b", &_killSound); break; case TOKEN_SUBFRAME: { @@ -267,11 +267,11 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_KEYFRAME: - parser.ScanStr(params, "%b", &_keyframe); + parser.scanStr(params, "%b", &_keyframe); break; case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &decoration); + parser.scanStr(params, "%b", &decoration); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index f9819e9e27..a44c5c7e52 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -811,14 +811,14 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { Game->LOG(0, "'GAME' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -883,19 +883,19 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_PERSONAL_SAVEGAMES: - parser.ScanStr((char *)params, "%b", &_personalizedSave); + parser.scanStr((char *)params, "%b", &_personalizedSave); break; case TOKEN_SUBTITLES: - parser.ScanStr((char *)params, "%b", &_subtitles); + parser.scanStr((char *)params, "%b", &_subtitles); break; case TOKEN_SUBTITLES_SPEED: - parser.ScanStr((char *)params, "%d", &_subtitlesSpeed); + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); break; case TOKEN_VIDEO_SUBTITLES: - parser.ScanStr((char *)params, "%b", &_videoSubtitles); + parser.scanStr((char *)params, "%b", &_videoSubtitles); break; case TOKEN_PROPERTY: @@ -907,34 +907,34 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_THUMBNAIL_WIDTH: - parser.ScanStr((char *)params, "%d", &_thumbnailWidth); + parser.scanStr((char *)params, "%d", &_thumbnailWidth); break; case TOKEN_THUMBNAIL_HEIGHT: - parser.ScanStr((char *)params, "%d", &_thumbnailHeight); + parser.scanStr((char *)params, "%d", &_thumbnailHeight); break; case TOKEN_INDICATOR_X: - parser.ScanStr((char *)params, "%d", &_indicatorX); + parser.scanStr((char *)params, "%d", &_indicatorX); break; case TOKEN_INDICATOR_Y: - parser.ScanStr((char *)params, "%d", &_indicatorY); + parser.scanStr((char *)params, "%d", &_indicatorY); break; case TOKEN_INDICATOR_COLOR: { int r, g, b, a; - parser.ScanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); _indicatorColor = DRGBA(r, g, b, a); } break; case TOKEN_INDICATOR_WIDTH: - parser.ScanStr((char *)params, "%d", &_indicatorWidth); + parser.scanStr((char *)params, "%d", &_indicatorWidth); break; case TOKEN_INDICATOR_HEIGHT: - parser.ScanStr((char *)params, "%d", &_indicatorHeight); + parser.scanStr((char *)params, "%d", &_indicatorHeight); break; case TOKEN_SAVE_IMAGE: @@ -942,11 +942,11 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SAVE_IMAGE_X: - parser.ScanStr((char *)params, "%d", &_saveImageX); + parser.scanStr((char *)params, "%d", &_saveImageX); break; case TOKEN_SAVE_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &_saveImageY); + parser.scanStr((char *)params, "%d", &_saveImageY); break; case TOKEN_LOAD_IMAGE: @@ -954,11 +954,11 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOAD_IMAGE_X: - parser.ScanStr((char *)params, "%d", &_loadImageX); + parser.scanStr((char *)params, "%d", &_loadImageX); break; case TOKEN_LOAD_IMAGE_Y: - parser.ScanStr((char *)params, "%d", &_loadImageY); + parser.scanStr((char *)params, "%d", &_loadImageY); break; case TOKEN_LOCAL_SAVE_DIR: @@ -966,7 +966,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.ScanStr((char *)params, "%b", &_compatKillMethodThreads); + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); break; } } @@ -3534,12 +3534,12 @@ HRESULT CBGame::loadSettings(const char *filename) { int cmd; CBParser parser(Game); - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); return E_FAIL; } buffer = params; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: delete[] _settingsGameFile; @@ -3552,39 +3552,39 @@ HRESULT CBGame::loadSettings(const char *filename) { break; case TOKEN_RESOLUTION: - parser.ScanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); break; case TOKEN_REQUIRE_3D_ACCELERATION: - parser.ScanStr((char *)params, "%b", &_settingsRequireAcceleration); + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); break; case TOKEN_REQUIRE_SOUND: - parser.ScanStr((char *)params, "%b", &_settingsRequireSound); + parser.scanStr((char *)params, "%b", &_settingsRequireSound); break; case TOKEN_HWTL_MODE: - parser.ScanStr((char *)params, "%d", &_settingsTLMode); + parser.scanStr((char *)params, "%d", &_settingsTLMode); break; case TOKEN_ALLOW_WINDOWED_MODE: - parser.ScanStr((char *)params, "%b", &_settingsAllowWindowed); + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); break; case TOKEN_ALLOW_DESKTOP_RES: - parser.ScanStr((char *)params, "%b", &_settingsAllowDesktopRes); + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); break; case TOKEN_ALLOW_ADVANCED: - parser.ScanStr((char *)params, "%b", &_settingsAllowAdvanced); + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); break; case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.ScanStr((char *)params, "%b", &_settingsAllowAccessTab); + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); break; case TOKEN_ALLOW_ABOUT_TAB: - parser.ScanStr((char *)params, "%b", &_settingsAllowAboutTab); + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); break; case TOKEN_REGISTRY_PATH: @@ -3592,7 +3592,7 @@ HRESULT CBGame::loadSettings(const char *filename) { break; case TOKEN_RICH_SAVED_GAMES: - parser.ScanStr((char *)params, "%b", &_richSavedGames); + parser.scanStr((char *)params, "%b", &_richSavedGames); break; case TOKEN_SAVED_GAME_EXT: diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp index b5593a3e9c..4354c5620d 100644 --- a/engines/wintermute/Base/BParser.cpp +++ b/engines/wintermute/Base/BParser.cpp @@ -56,20 +56,20 @@ CBParser::~CBParser() { ////////////////////////////////////////////////////////////////////// -char *CBParser::GetLastOffender() { +char *CBParser::getLastOffender() { return _lastOffender; } ////////////////////////////////////////////////////////////////////// -long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { - SkipCharacters(buf, _whiteSpace); +long CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); // skip comment lines. while (**buf == ';') { *buf = strchr(*buf, '\n'); _parserLine++; - SkipCharacters(buf, _whiteSpace); + skipCharacters(buf, _whiteSpace); } if (! **buf) // at end of file @@ -96,33 +96,33 @@ long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data } // skip the token *buf += strlen(tokens->token); - SkipCharacters(buf, _whiteSpace); + skipCharacters(buf, _whiteSpace); // get optional name - *name = GetSubText(buf, '\'', '\''); // single quotes - SkipCharacters(buf, _whiteSpace); + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); // get optional data if (**buf == '=') // An assignment rather than a command/object. - *data = GetAssignmentText(buf); + *data = getAssignmentText(buf); else - *data = GetSubText(buf, '{', '}'); + *data = getSubText(buf, '{', '}'); return tokens->id; } ////////////////////////////////////////////////////////////////////// -long CBParser::GetCommand(char **buf, TokenDesc *tokens, char **params) { +long CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; Game->miniUpdate(); char *name; - return GetObject(buf, tokens, &name, params); + return getObject(buf, tokens, &name, params); } ////////////////////////////////////////////////////////////////////// -void CBParser::SkipCharacters(char **buf, const char *toSkip) { +void CBParser::skipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { if (ch == '\n') _parserLine++; @@ -135,7 +135,7 @@ void CBParser::SkipCharacters(char **buf, const char *toSkip) { ////////////////////////////////////////////////////////////////////// -char *CBParser::GetSubText(char **buf, char open, char close) { +char *CBParser::getSubText(char **buf, char open, char close) { if (**buf == 0 || **buf != open) return 0; ++*buf; // skip opening delimiter @@ -164,14 +164,14 @@ char *CBParser::GetSubText(char **buf, char open, char close) { ////////////////////////////////////////////////////////////////////// -char *CBParser::GetAssignmentText(char **buf) { +char *CBParser::getAssignmentText(char **buf) { ++*buf; // skip the '=' - SkipCharacters(buf, _whiteSpace); + skipCharacters(buf, _whiteSpace); char *result = *buf; if (*result == '"') { - result = GetSubText(buf, '"', '"'); + result = getSubText(buf, '"', '"'); } else { // now, we need to find the next whitespace to end the data char theChar; @@ -192,7 +192,7 @@ char *CBParser::GetAssignmentText(char **buf) { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *CBParser::GetToken(char **buf) { +char *CBParser::getToken(char **buf) { static char token[100]; char *b = *buf, * t = token; while (true) { @@ -240,8 +240,8 @@ char *CBParser::GetToken(char **buf) { ////////////////////////////////////////////////////////////////////// -float CBParser::GetTokenFloat(char **buf) { - char *t = GetToken(buf); +float CBParser::getTokenFloat(char **buf) { + char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. return 0.; @@ -252,8 +252,8 @@ float CBParser::GetTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// -int CBParser::GetTokenInt(char **buf) { - char *t = GetToken(buf); +int CBParser::getTokenInt(char **buf) { + char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. return 0; @@ -264,14 +264,14 @@ int CBParser::GetTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// -void CBParser::SkipToken(char **buf, char *tok, char * /*msg*/) { - char *t = GetToken(buf); +void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { + char *t = getToken(buf); if (strcmp(t, tok)) return; // Error } ////////////////////////////////////////////////////////////////////// -int CBParser::ScanStr(const char *in, const char *format, ...) { +int CBParser::scanStr(const char *in, const char *format, ...) { va_list arg; va_start(arg, format); diff --git a/engines/wintermute/Base/BParser.h b/engines/wintermute/Base/BParser.h index 07764a97da..f5aa0393e7 100644 --- a/engines/wintermute/Base/BParser.h +++ b/engines/wintermute/Base/BParser.h @@ -65,21 +65,22 @@ public: }; public: - int ScanStr(const char *in, const char *format, ...); - char *GetLastOffender(); - void SkipToken(char **buf, char *tok, char *msg = NULL); - int GetTokenInt(char **buf); - float GetTokenFloat(char **buf); - char *GetToken(char **buf); - char *GetAssignmentText(char **buf); - char *GetSubText(char **buf, char open, char close); - void SkipCharacters(char **buf, const char *toSkip); - long GetCommand(char **buf, TokenDesc *tokens, char **params); - long GetObject(char **buf, TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; + int scanStr(const char *in, const char *format, ...); + long getCommand(char **buf, TokenDesc *tokens, char **params); CBParser(CBGame *inGame = NULL); virtual ~CBParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + char *getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + long getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; char *_whiteSpace; }; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index ea3ecda58e..878b73e5e3 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -146,7 +146,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); return E_FAIL; } @@ -158,7 +158,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { for (i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -173,12 +173,12 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ACTIVE: - parser.ScanStr((char *)params, "%b", &_active); + parser.scanStr((char *)params, "%b", &_active); break; case TOKEN_POINT: { int x, y; - parser.ScanStr((char *)params, "%d,%d", &x, &y); + parser.scanStr((char *)params, "%d,%d", &x, &y); _points.Add(new CBPoint(x, y)); } break; @@ -188,7 +188,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDITOR_SELECTED_POINT: - parser.ScanStr((char *)params, "%d", &_editorSelectedPoint); + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); break; case TOKEN_PROPERTY: diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index a740fde2fc..131cec631f 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -357,7 +357,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { Game->LOG(0, "'PROPERTY' keyword expected."); return E_FAIL; } @@ -367,7 +367,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { char *PropName = NULL; char *PropValue = NULL; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: delete[] PropName; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 859dfb74aa..5adbaf9d14 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -214,7 +214,7 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { Game->LOG(0, "'SPRITE' keyword expected."); return E_FAIL; } @@ -223,14 +223,14 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC int frame_count = 1; CBFrame *frame; - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: - parser.ScanStr((char *)params, "%b", &_continuous); + parser.scanStr((char *)params, "%b", &_continuous); break; case TOKEN_EDITOR_MUTED: - parser.ScanStr((char *)params, "%b", &_editorMuted); + parser.scanStr((char *)params, "%b", &_editorMuted); break; case TOKEN_SCRIPT: @@ -238,15 +238,15 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC break; case TOKEN_LOOPING: - parser.ScanStr((char *)params, "%b", &_looping); + parser.scanStr((char *)params, "%b", &_looping); break; case TOKEN_PRECISE: - parser.ScanStr((char *)params, "%b", &_precise); + parser.scanStr((char *)params, "%b", &_precise); break; case TOKEN_STREAMED: - parser.ScanStr((char *)params, "%b", &_streamed); + parser.scanStr((char *)params, "%b", &_streamed); if (_streamed && lifeTime == -1) { lifeTime = 500; cacheType = CACHE_ALL; @@ -254,7 +254,7 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC break; case TOKEN_STREAMED_KEEP_LOADED: - parser.ScanStr((char *)params, "%b", &_streamedKeepLoaded); + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); break; case TOKEN_NAME: @@ -270,15 +270,15 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC break; case TOKEN_EDITOR_BG_OFFSET_X: - parser.ScanStr((char *)params, "%d", &_editorBgOffsetX); + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); break; case TOKEN_EDITOR_BG_OFFSET_Y: - parser.ScanStr((char *)params, "%d", &_editorBgOffsetY); + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); break; case TOKEN_EDITOR_BG_ALPHA: - parser.ScanStr((char *)params, "%d", &_editorBgAlpha); + parser.scanStr((char *)params, "%d", &_editorBgAlpha); _editorBgAlpha = MIN(_editorBgAlpha, 255); _editorBgAlpha = MAX(_editorBgAlpha, 0); break; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 02395da74a..b3d40d7c67 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -120,55 +120,55 @@ HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { delete _surface; _surface = NULL; - while ((cmd = parser.GetCommand((char **)&Buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&Buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: surface_file = params; break; case TOKEN_TRANSPARENT: - parser.ScanStr(params, "%d,%d,%d", &r, &g, &b); + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); custo_trans = true; break; case TOKEN_RECT: - parser.ScanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); break; case TOKEN_HOTSPOT: - parser.ScanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); break; case TOKEN_2D_ONLY: - parser.ScanStr(params, "%b", &_2DOnly); + parser.scanStr(params, "%b", &_2DOnly); break; case TOKEN_3D_ONLY: - parser.ScanStr(params, "%b", &_3DOnly); + parser.scanStr(params, "%b", &_3DOnly); break; case TOKEN_MIRROR_X: - parser.ScanStr(params, "%b", &_mirrorX); + parser.scanStr(params, "%b", &_mirrorX); break; case TOKEN_MIRROR_Y: - parser.ScanStr(params, "%b", &_mirrorY); + parser.scanStr(params, "%b", &_mirrorY); break; case TOKEN_DECORATION: - parser.ScanStr(params, "%b", &_decoration); + parser.scanStr(params, "%b", &_decoration); break; case TOKEN_ALPHA_COLOR: - parser.ScanStr(params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr(params, "%d", &alpha); + parser.scanStr(params, "%d", &alpha); break; case TOKEN_EDITOR_SELECTED: - parser.ScanStr(params, "%b", &_editorSelected); + parser.scanStr(params, "%b", &_editorSelected); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 1504796378..374317993b 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -200,14 +200,14 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { Game->LOG(0, "'BUTTON' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -363,19 +363,19 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); + parser.scanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); + parser.scanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: @@ -393,31 +393,31 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); + parser.scanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); + parser.scanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); + parser.scanStr((char *)params, "%b", &_visible); break; case TOKEN_FOCUSABLE: - parser.ScanStr((char *)params, "%b", &_canFocus); + parser.scanStr((char *)params, "%b", &_canFocus); break; case TOKEN_CENTER_IMAGE: - parser.ScanStr((char *)params, "%b", &_centerImage); + parser.scanStr((char *)params, "%b", &_centerImage); break; case TOKEN_PRESSED: - parser.ScanStr((char *)params, "%b", &_stayPressed); + parser.scanStr((char *)params, "%b", &_stayPressed); break; case TOKEN_PIXEL_PERFECT: - parser.ScanStr((char *)params, "%b", &_pixelPerfect); + parser.scanStr((char *)params, "%b", &_pixelPerfect); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 39f8e993b2..8594deb05c 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -170,14 +170,14 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { Game->LOG(0, "'EDIT' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -225,23 +225,23 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); + parser.scanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); + parser.scanStr((char *)params, "%d", &_height); break; case TOKEN_MAX_LENGTH: - parser.ScanStr((char *)params, "%d", &_maxLength); + parser.scanStr((char *)params, "%d", &_maxLength); break; case TOKEN_CAPTION: @@ -259,11 +259,11 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_CURSOR_BLINK_RATE: - parser.ScanStr((char *)params, "%d", &_cursorBlinkRate); + parser.scanStr((char *)params, "%d", &_cursorBlinkRate); break; case TOKEN_FRAME_WIDTH: - parser.ScanStr((char *)params, "%d", &_frameWidth); + parser.scanStr((char *)params, "%d", &_frameWidth); break; case TOKEN_SCRIPT: @@ -271,15 +271,15 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); + parser.scanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); + parser.scanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); + parser.scanStr((char *)params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index e9d3662471..6c63ce4897 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -108,14 +108,14 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -126,19 +126,19 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); + parser.scanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); + parser.scanStr((char *)params, "%b", &_visible); break; case TOKEN_ENTITY: diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 5f81a228c3..f8e35c5ada 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -167,14 +167,14 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { CBParser parser(Game); if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { Game->LOG(0, "'STATIC' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd > 0 && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -232,19 +232,19 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); + parser.scanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); + parser.scanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: @@ -262,15 +262,15 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); + parser.scanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); + parser.scanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); + parser.scanStr((char *)params, "%b", &_visible); break; case TOKEN_EDITOR_PROPERTY: diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index a56d3af9c1..aa599f548d 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -185,14 +185,14 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { int V1 = 0, V2 = 0, V3 = 0; if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { Game->LOG(0, "'TILED_IMAGE' keyword expected."); return E_FAIL; } buffer = params; } - while ((cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -209,48 +209,48 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_UP_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); break; case TOKEN_UP_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); break; case TOKEN_UP_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); break; case TOKEN_DOWN_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); break; case TOKEN_DOWN_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); break; case TOKEN_DOWN_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); break; case TOKEN_MIDDLE_LEFT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); break; case TOKEN_MIDDLE_RIGHT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); break; case TOKEN_MIDDLE_MIDDLE: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); break; case TOKEN_HORIZONTAL_TILES: - parser.ScanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); + parser.scanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); HTiles = true; break; case TOKEN_VERTICAL_TILES: - parser.ScanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); + parser.scanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); VTiles = true; break; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 9cda6072db..b244d13490 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -307,14 +307,14 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { int ar = 0, ag = 0, ab = 0, alpha = 0; if (complete) { - if (parser.GetCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { Game->LOG(0, "'WINDOW' keyword expected."); return E_FAIL; } buffer = params; } - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.GetCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; @@ -392,27 +392,27 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TITLE_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); break; case TOKEN_DRAG_RECT: - parser.ScanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); + parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); break; case TOKEN_X: - parser.ScanStr((char *)params, "%d", &_posX); + parser.scanStr((char *)params, "%d", &_posX); break; case TOKEN_Y: - parser.ScanStr((char *)params, "%d", &_posY); + parser.scanStr((char *)params, "%d", &_posY); break; case TOKEN_WIDTH: - parser.ScanStr((char *)params, "%d", &_width); + parser.scanStr((char *)params, "%d", &_width); break; case TOKEN_HEIGHT: - parser.ScanStr((char *)params, "%d", &_height); + parser.scanStr((char *)params, "%d", &_height); break; case TOKEN_CURSOR: @@ -479,7 +479,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_TRANSPARENT: - parser.ScanStr((char *)params, "%b", &_transparent); + parser.scanStr((char *)params, "%b", &_transparent); break; case TOKEN_SCRIPT: @@ -487,40 +487,40 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_PARENT_NOTIFY: - parser.ScanStr((char *)params, "%b", &_parentNotify); + parser.scanStr((char *)params, "%b", &_parentNotify); break; case TOKEN_PAUSE_MUSIC: - parser.ScanStr((char *)params, "%b", &_pauseMusic); + parser.scanStr((char *)params, "%b", &_pauseMusic); break; case TOKEN_DISABLED: - parser.ScanStr((char *)params, "%b", &_disable); + parser.scanStr((char *)params, "%b", &_disable); break; case TOKEN_VISIBLE: - parser.ScanStr((char *)params, "%b", &_visible); + parser.scanStr((char *)params, "%b", &_visible); break; case TOKEN_MENU: - parser.ScanStr((char *)params, "%b", &_isMenu); + parser.scanStr((char *)params, "%b", &_isMenu); break; case TOKEN_IN_GAME: - parser.ScanStr((char *)params, "%b", &_inGame); + parser.scanStr((char *)params, "%b", &_inGame); break; case TOKEN_CLIP_CONTENTS: - parser.ScanStr((char *)params, "%b", &_clipContents); + parser.scanStr((char *)params, "%b", &_clipContents); break; case TOKEN_FADE_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); + parser.scanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); _fadeBackground = true; break; case TOKEN_FADE_ALPHA: - parser.ScanStr((char *)params, "%d", &FadeA); + parser.scanStr((char *)params, "%d", &FadeA); _fadeBackground = true; break; @@ -529,11 +529,11 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ALPHA_COLOR: - parser.ScanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); break; case TOKEN_ALPHA: - parser.ScanStr((char *)params, "%d", &alpha); + parser.scanStr((char *)params, "%d", &alpha); break; -- cgit v1.2.3 From cf63cea1e85a7999e4502dabf3d129ed4d293249 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 19:59:14 +0200 Subject: WINTERMUTE: Rename VarName->varName in BPersistMgr --- engines/wintermute/Base/BPersistMgr.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index dc04d1624e..af115ef386 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -252,23 +252,23 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { _loadStream = g_system->getSavefileManager()->openForLoading(filename); //_buffer = Game->_fileManager->readWholeFile(filename, &_bufferSize); if (_loadStream) { - uint32 Magic; - Magic = getDWORD(); + uint32 magic; + magic = getDWORD(); - if (Magic != DCGF_MAGIC) { + if (magic != DCGF_MAGIC) { cleanup(); return E_FAIL; } - Magic = getDWORD(); + magic = getDWORD(); - if (Magic == SAVE_MAGIC || Magic == SAVE_MAGIC_2) { + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { _savedVerMajor = _loadStream->readByte(); _savedVerMinor = _loadStream->readByte(); _savedExtMajor = _loadStream->readByte(); _savedExtMinor = _loadStream->readByte(); - if (Magic == SAVE_MAGIC_2) { + if (magic == SAVE_MAGIC_2) { _savedVerBuild = (byte)getDWORD(); _savedName = getStringObj(); @@ -300,8 +300,6 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CBPersistMgr::initLoad(const char *filename) { - - if (FAILED(readHeader(filename))) { cleanup(); return E_FAIL; @@ -735,21 +733,21 @@ HRESULT CBPersistMgr::transfer(const char *name, Vector2 *val) { ////////////////////////////////////////////////////////////////////////// // generic pointer HRESULT CBPersistMgr::transfer(const char *name, void *val) { - int ClassID = -1, InstanceID = -1; + int classID = -1, instanceID = -1; if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &ClassID, &InstanceID); - if (*(void **)val != NULL && (ClassID == -1 || InstanceID == -1)) { + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { Game->LOG(0, "Warning: invalid instance '%s'", name); } - _saveStream->writeUint32LE(ClassID); - _saveStream->writeUint32LE(InstanceID); + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); } else { - ClassID = _loadStream->readUint32LE(); - InstanceID = _loadStream->readUint32LE(); + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(ClassID, InstanceID); + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); } return S_OK; -- cgit v1.2.3 From 5afd4c966e99c4bd7f413f61efa2a0cf8fee4ecc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:07:01 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in BRegistry --- engines/wintermute/Base/BFileManager.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 24 +++++------ engines/wintermute/Base/BRegistry.cpp | 54 ++++++++++++------------ engines/wintermute/Base/BRegistry.h | 30 ++++++------- engines/wintermute/Base/BRenderSDL.cpp | 8 ++-- engines/wintermute/Base/BSoundMgr.cpp | 16 +++---- engines/wintermute/Base/scriptables/SXStore.cpp | 6 +-- engines/wintermute/Base/scriptables/ScEngine.cpp | 8 ++-- engines/wintermute/wintermute.cpp | 12 +++--- 9 files changed, 81 insertions(+), 81 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 3617d8a344..19f162315d 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -284,7 +284,7 @@ HRESULT CBFileManager::initPaths() { int numPaths; // single files paths - pathList = Game->_registry->ReadString("Resource", "CustomPaths", ""); + pathList = Game->_registry->readString("Resource", "CustomPaths", ""); numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { @@ -328,7 +328,7 @@ HRESULT CBFileManager::initPaths() { #endif*/ - pathList = Game->_registry->ReadString("Resource", "PackagePaths", ""); + pathList = Game->_registry->readString("Resource", "PackagePaths", ""); numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index a44c5c7e52..0545cf9168 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -286,7 +286,7 @@ CBGame::~CBGame() { getDebugMgr()->onGameShutdown(); - _registry->WriteBool("System", "LastRun", true); + _registry->writeBool("System", "LastRun", true); cleanup(); @@ -1494,7 +1494,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - _registry->WriteInt("PrivateSettings", key, val); + _registry->writeInt("PrivateSettings", key, val); stack->pushNULL(); return S_OK; } @@ -1506,7 +1506,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->ReadInt("PrivateSettings", key, initVal)); + stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); return S_OK; } @@ -1517,7 +1517,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - _registry->WriteString("PrivateSettings", key, val); + _registry->writeString("PrivateSettings", key, val); stack->pushNULL(); return S_OK; } @@ -1529,7 +1529,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->ReadString("PrivateSettings", key, initVal); + AnsiString val = _registry->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return S_OK; } @@ -2550,7 +2550,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->ReadInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -3267,7 +3267,7 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { if (FAILED(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; if (FAILED(ret = pm->saveFile(filename))) goto save_finish; - _registry->WriteInt("System", "MostRecentSaveSlot", slot); + _registry->writeInt("System", "MostRecentSaveSlot", slot); save_finish: // TODO: Remove gotos delete pm; @@ -3588,7 +3588,7 @@ HRESULT CBGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - _registry->SetBasePath((char *)params); + _registry->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3612,8 +3612,8 @@ HRESULT CBGame::loadSettings(const char *filename) { ret = E_FAIL; } - _settingsAllowWindowed = _registry->ReadBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->ReadBool("Debug", "CompressedSavegames", _compressedSavegames); + _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; delete [] origBuffer; @@ -3910,7 +3910,7 @@ AnsiString CBGame::getDataDir() { #ifdef __IPHONEOS__ return userDir; #else - AnsiString baseDir = _registry->GetBasePath(); + AnsiString baseDir = _registry->getBasePath(); return PathUtil::combine(userDir, baseDir); #endif } @@ -4553,7 +4553,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void CBGame::autoSaveOnExit() { _soundMgr->saveSettings(); - _registry->SaveValues(); + _registry->saveValues(); if (!_autoSaveOnExit) return; if (_state == GAME_FROZEN) return; diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 64f2a0093c..fe1baee9e6 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -41,14 +41,14 @@ namespace WinterMute { CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { _iniName = NULL; - SetIniName("./wme.ini"); - LoadValues(true); + setIniName("./wme.ini"); + loadValues(true); } ////////////////////////////////////////////////////////////////////////// CBRegistry::~CBRegistry() { - SaveValues(); + saveValues(); delete[] _iniName; _iniName = NULL; } @@ -56,7 +56,7 @@ CBRegistry::~CBRegistry() { ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { +AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { AnsiString ret = ""; #ifdef __WIN32__ @@ -69,8 +69,8 @@ AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &ke #endif bool found = false; - ret = GetValue(_localValues, subKey, key, found); - if (!found) ret = GetValue(_values, subKey, key, found); + ret = getValue(_localValues, subKey, key, found); + if (!found) ret = getValue(_values, subKey, key, found); if (!found) ret = init; return ret; @@ -78,46 +78,46 @@ AnsiString CBRegistry::ReadString(const AnsiString &subKey, const AnsiString &ke ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { +bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { _values[subKey][key] = value; return true; } ////////////////////////////////////////////////////////////////////////// -int CBRegistry::ReadInt(const AnsiString &subKey, const AnsiString &key, int init) { +int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { #ifdef __WIN32__ int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName); if (ret != init) return ret; #endif - AnsiString val = ReadString(subKey, key, ""); + AnsiString val = readString(subKey, key, ""); if (val.empty()) return init; else return atoi(val.c_str()); } ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteInt(const AnsiString &subKey, const AnsiString &key, int value) { - WriteString(subKey, key, StringUtil::toString(value)); +bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + writeString(subKey, key, StringUtil::toString(value)); return true; } ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::ReadBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (ReadInt(subKey, key, (int)init) != 0); +bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (readInt(subKey, key, (int)init) != 0); } ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::WriteBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return WriteInt(subKey, key, (int)value); +bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return writeInt(subKey, key, (int)value); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetIniName(const char *name) { +void CBRegistry::setIniName(const char *name) { delete[] _iniName; _iniName = NULL; @@ -132,30 +132,30 @@ void CBRegistry::SetIniName(const char *name) { ////////////////////////////////////////////////////////////////////////// -char *CBRegistry::GetIniName() { +char *CBRegistry::getIniName() { return _iniName; } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::LoadValues(bool local) { - if (local) LoadXml("settings.xml", _localValues); - else LoadXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); +void CBRegistry::loadValues(bool local) { + if (local) loadXml("settings.xml", _localValues); + else loadXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SaveValues() { - SaveXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); +void CBRegistry::saveValues() { + saveXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SetBasePath(const char *basePath) { +void CBRegistry::setBasePath(const char *basePath) { _basePath = PathUtil::getFileNameWithoutExtension(basePath); - LoadValues(false); + loadValues(false); } ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { +AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { found = false; PathValueMap::iterator it = values.find(path); if (it == values.end()) return ""; @@ -170,7 +170,7 @@ AnsiString CBRegistry::GetValue(PathValueMap &values, const AnsiString path, con } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { +void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { TiXmlDocument doc(fileName.c_str()); if (!doc.LoadFile()) return; @@ -187,7 +187,7 @@ void CBRegistry::LoadXml(const AnsiString fileName, PathValueMap &values) { ////////////////////////////////////////////////////////////////////////// -void CBRegistry::SaveXml(const AnsiString fileName, PathValueMap &values) { +void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { CBUtils::createPath(fileName.c_str()); TiXmlDocument doc; diff --git a/engines/wintermute/Base/BRegistry.h b/engines/wintermute/Base/BRegistry.h index ac54c7ea81..a07f6be8d4 100644 --- a/engines/wintermute/Base/BRegistry.h +++ b/engines/wintermute/Base/BRegistry.h @@ -35,24 +35,24 @@ namespace WinterMute { class CBRegistry : public CBBase { public: - void SetIniName(const char *name); - char *GetIniName(); - bool WriteBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool ReadBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool WriteInt(const AnsiString &subKey, const AnsiString &key, int value); - int ReadInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool WriteString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString ReadString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + void setIniName(const char *name); + char *getIniName(); + bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); + int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); CBRegistry(CBGame *inGame); virtual ~CBRegistry(); - void SetBasePath(const char *basePath); - AnsiString GetBasePath() const { + void setBasePath(const char *basePath); + AnsiString getBasePath() const { return _basePath; } - void LoadValues(bool local); - void SaveValues(); + void loadValues(bool local); + void saveValues(); private: char *_iniName; @@ -65,10 +65,10 @@ private: AnsiString _basePath; - void LoadXml(const AnsiString fileName, PathValueMap &values); - void SaveXml(const AnsiString fileName, PathValueMap &values); + void loadXml(const AnsiString fileName, PathValueMap &values); + void saveXml(const AnsiString fileName, PathValueMap &values); - AnsiString GetValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); + AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index acbd8a645e..56df72c8b3 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -144,8 +144,8 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { } } #else - _realWidth = Game->_registry->ReadInt("Debug", "ForceResWidth", _width); - _realHeight = Game->_registry->ReadInt("Debug", "ForceResHeight", _height); + _realWidth = Game->_registry->readInt("Debug", "ForceResWidth", _width); + _realHeight = Game->_registry->readInt("Debug", "ForceResHeight", _height); #endif /* @@ -184,7 +184,7 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; #endif - //_windowed = Game->_registry->ReadBool("Video", "Windowed", true); + //_windowed = Game->_registry->readBool("Video", "Windowed", true); // if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); @@ -549,7 +549,7 @@ HRESULT CBRenderSDL::switchFullscreen() { _windowed = !_windowed; */ - Game->_registry->WriteBool("Video", "Windowed", _windowed); + Game->_registry->writeBool("Video", "Windowed", _windowed); return S_OK; } diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 27e96f7d75..7cebbdfc2e 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -71,11 +71,11 @@ HRESULT CBSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void CBSoundMgr::saveSettings() { if (_soundAvailable) { - Game->_registry->WriteInt("Audio", "MasterVolume", _volumeMaster); + Game->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); - Game->_registry->WriteInt("Audio", "SFXVolume", _volumeSFX); - Game->_registry->WriteInt("Audio", "SpeechVolume", _volumeSpeech); - Game->_registry->WriteInt("Audio", "MusicVolume", _volumeMusic); + Game->_registry->writeInt("Audio", "SFXVolume", _volumeSFX); + Game->_registry->writeInt("Audio", "SpeechVolume", _volumeSpeech); + Game->_registry->writeInt("Audio", "MusicVolume", _volumeMusic); } } @@ -101,11 +101,11 @@ HRESULT CBSoundMgr::initialize() { } #endif - _volumeMaster = Game->_registry->ReadInt("Audio", "MasterVolume", 100); + _volumeMaster = Game->_registry->readInt("Audio", "MasterVolume", 100); - _volumeSFX = Game->_registry->ReadInt("Audio", "SFXVolume", 100); - _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100); - _volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100); + _volumeSFX = Game->_registry->readInt("Audio", "SFXVolume", 100); + _volumeSpeech = Game->_registry->readInt("Audio", "SpeechVolume", 100); + _volumeMusic = Game->_registry->readInt("Audio", "MusicVolume", 100); _soundAvailable = true; setMasterVolumePercent(_volumeMaster); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 6d0461df54..2996da4b79 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -202,8 +202,8 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); const char *prodId = stack->pop()->getString(); - Game->_registry->WriteBool("Purchases", prodId, true); - Game->_registry->SaveValues(); + Game->_registry->writeBool("Purchases", prodId, true); + Game->_registry->saveValues(); stack->pushBool(true); @@ -217,7 +217,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); const char *prodId = stack->pop()->getString(); - stack->pushBool(Game->_registry->ReadBool("Purchases", prodId, false)); + stack->pushBool(Game->_registry->readBool("Purchases", prodId, false)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 781e08d0d1..51098f0ef2 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -766,10 +766,10 @@ HRESULT CScEngine::SaveBreakpoints() { sprintf(Key, "Breakpoint%d", Count); sprintf(Text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - Game->_registry->WriteString("Debug", Key, Text); + Game->_registry->writeString("Debug", Key, Text); } } - Game->_registry->WriteInt("Debug", "NumBreakpoints", Count); + Game->_registry->writeInt("Debug", "NumBreakpoints", Count); return S_OK; } @@ -780,11 +780,11 @@ HRESULT CScEngine::LoadBreakpoints() { char Key[100]; - int Count = Game->_registry->ReadInt("Debug", "NumBreakpoints", 0); + int Count = Game->_registry->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= Count; i++) { /* uint32 BufSize = 512; */ sprintf(Key, "Breakpoint%d", i); - AnsiString breakpoint = Game->_registry->ReadString("Debug", Key, ""); + AnsiString breakpoint = Game->_registry->readString("Debug", Key, ""); char *Path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); char *Line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index cc472d32da..65e997f0bb 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -174,16 +174,16 @@ int WinterMuteEngine::init() { }*/ - if (_game->_registry->ReadBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); + if (_game->_registry->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); - _game->_dEBUG_ShowFPS = _game->_registry->ReadBool("Debug", "ShowFPS"); + _game->_dEBUG_ShowFPS = _game->_registry->readBool("Debug", "ShowFPS"); - if (_game->_registry->ReadBool("Debug", "DisableSmartCache")) { + if (_game->_registry->readBool("Debug", "DisableSmartCache")) { _game->LOG(0, "Smart cache is DISABLED"); _game->_smartCache = false; } - /* bool AllowDirectDraw = _game->_registry->ReadBool("Debug", "AllowDirectDraw", false);*/ + /* bool AllowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ // load general game settings _game->initialize1(); @@ -307,8 +307,8 @@ int WinterMuteEngine::messageLoop() { PosX -= _game->_renderer->_monitorRect.left; PosY -= _game->_renderer->_monitorRect.top; - _game->_registry->WriteInt("Video", "WindowPosX", PosX); - _game->_registry->WriteInt("Video", "WindowPosY", PosY); + _game->_registry->writeInt("Video", "WindowPosX", PosX); + _game->_registry->writeInt("Video", "WindowPosY", PosY); } } */ -- cgit v1.2.3 From 5b70ee9e82f94948f7df7ad40384b851502d97d6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:16:48 +0200 Subject: WINTERMUTE: Fix the "was drawn last time, in different order now"-case for dirty rects. --- engines/wintermute/Base/BRenderSDL.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 56df72c8b3..1607161ab3 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -394,9 +394,19 @@ void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { if (_drawNum == renderTicket->_drawNum) { _drawNum++; } else { - // Is not in order - renderTicket->_drawNum = _drawNum++; - addDirtyRect(renderTicket->_dstRect); + // Remove the ticket from the list + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it) == renderTicket) { + it = _renderQueue.erase(it); + break; + } else { + it++; + } + } + // Is not in order, so readd it as if it was a new ticket + renderTicket->_drawNum = 0; + drawFromTicket(renderTicket); } } } -- cgit v1.2.3 From 6329178e85c3c83d5bc733dfda1622537fb1e43a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:22:05 +0200 Subject: WINTERMUTE: Rename VarName->varName in BRenderer --- engines/wintermute/Base/BRenderer.cpp | 60 +++++++++++++++++------------------ engines/wintermute/Base/BRenderer.h | 8 ++--- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 5ccd04f1fd..e7d5ec55cb 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -68,34 +68,34 @@ void CBRenderer::initLoop() { ////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::getObjectAt(int X, int Y) { +CBObject *CBRenderer::getObjectAt(int x, int y) { POINT point; - point.x = X; - point.y = Y; + point.x = x; + point.y = y; for (int i = _rectList.GetSize() - 1; i >= 0; i--) { if (CBPlatform::PtInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { - int XX = (int)((_rectList[i]->_frame->_rect.left + X - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int YY = (int)((_rectList[i]->_frame->_rect.top + Y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); if (_rectList[i]->_frame->_mirrorX) { - int Width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; - XX = Width - XX; + int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + xx = width - xx; } if (_rectList[i]->_frame->_mirrorY) { - int Height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; - YY = Height - YY; + int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + yy = height - yy; } - if (!_rectList[i]->_frame->_surface->isTransparentAt(XX, YY)) return _rectList[i]->_owner; + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; } // region else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(X + _rectList[i]->_offsetX, Y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; } } else return _rectList[i]->_owner; } @@ -161,32 +161,32 @@ HRESULT CBRenderer::setupLines() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::drawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { +HRESULT CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::drawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) { - for (int i = 0; i < Width; i++) { - drawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up - drawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down +HRESULT CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { + for (int i = 0; i < width; i++) { + drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up + drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down - drawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left - drawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right + drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left + drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::fade(uint16 Alpha) { +HRESULT CBRenderer::fade(uint16 alpha) { return E_FAIL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::fadeToColor(uint32 Color, Common::Rect *rect) { +HRESULT CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { return E_FAIL; } @@ -204,11 +204,11 @@ HRESULT CBRenderer::setScreenViewport() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setViewport(RECT *Rect) { - return setViewport(Rect->left + _drawOffsetX, - Rect->top + _drawOffsetY, - Rect->right + _drawOffsetX, - Rect->bottom + _drawOffsetY); +HRESULT CBRenderer::setViewport(RECT *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); } @@ -246,11 +246,11 @@ HRESULT CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(POINT *P) { - if (P->x < _drawOffsetX) return false; - if (P->y < _drawOffsetY) return false; - if (P->x > _drawOffsetX + _width) return false; - if (P->y > _drawOffsetY + _height) return false; +bool CBRenderer::pointInViewport(POINT *p) { + if (p->x < _drawOffsetX) return false; + if (p->y < _drawOffsetY) return false; + if (p->x > _drawOffsetX + _width) return false; + if (p->y > _drawOffsetY + _height) return false; return true; } diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 5caa707e54..0822e0d521 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -54,8 +54,8 @@ public: virtual HRESULT setScreenViewport(); virtual HRESULT fade(uint16 Alpha); virtual HRESULT fadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual HRESULT drawLine(int X1, int Y1, int X2, int Y2, uint32 Color); - virtual HRESULT drawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width = 1); + virtual HRESULT drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual HRESULT drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); CBRenderer(CBGame *inGame = NULL); virtual ~CBRenderer(); virtual HRESULT setProjection() { @@ -69,7 +69,7 @@ public: virtual HRESULT flip(); virtual void initLoop(); virtual HRESULT switchFullscreen(); - virtual HRESULT setup2D(bool Force = false); + virtual HRESULT setup2D(bool force = false); virtual HRESULT setupLines(); virtual const char *getName() { @@ -92,7 +92,7 @@ public: HRESULT clipCursor(); HRESULT unclipCursor(); - CBObject *getObjectAt(int X, int Y); + CBObject *getObjectAt(int x, int y); void deleteRectList(); virtual HRESULT startSpriteBatch() { -- cgit v1.2.3 From e675d9fd20b4adfb04ee760d1efd106dccd7f17e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:26:22 +0200 Subject: WINTERMUTE: Rename VarName->varName in BRenderSDL --- engines/wintermute/Base/BRenderSDL.cpp | 22 +++++++++++----------- engines/wintermute/Base/BRenderSDL.h | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 1607161ab3..e156a76002 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -490,32 +490,32 @@ void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *s } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::drawLine(int X1, int Y1, int X2, int Y2, uint32 Color) { +HRESULT CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { warning("CBRenderSDL::DrawLine - not fully ported yet"); hasWarned = true; } - byte r = D3DCOLGetR(Color); - byte g = D3DCOLGetG(Color); - byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color); + byte r = D3DCOLGetR(color); + byte g = D3DCOLGetG(color); + byte b = D3DCOLGetB(color); + byte a = D3DCOLGetA(color); //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); POINT point1, point2; - point1.x = X1; - point1.y = Y1; + point1.x = x1; + point1.y = y1; pointToScreen(&point1); - point2.x = X2; - point2.y = Y2; + point2.x = x2; + point2.y = y2; pointToScreen(&point2); // TODO: This thing is mostly here until I'm sure about the final color-format. - uint32 color = _renderSurface->format.ARGBToColor(a, r, g, b); - _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, color); + uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); return S_OK; } diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 0f3cf82a31..67999fe867 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -68,12 +68,12 @@ public: HRESULT flip(); HRESULT fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - HRESULT fade(uint16 Alpha); - HRESULT fadeToColor(uint32 Color, Common::Rect *rect = NULL); + HRESULT fade(uint16 alpha); + HRESULT fadeToColor(uint32 color, Common::Rect *rect = NULL); HRESULT switchFullscreen(); - HRESULT drawLine(int X1, int Y1, int X2, int Y2, uint32 Color); + HRESULT drawLine(int x1, int y1, int x2, int y2, uint32 color); CBImage *takeScreenshot(); -- cgit v1.2.3 From f1319eb4fc89acfabda791524cd02a77ac7e25f1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:29:49 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in BSaveThumbHelper --- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Base/BSaveThumbHelper.cpp | 14 +++++++------- engines/wintermute/Base/BSaveThumbHelper.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 0545cf9168..3422e860ce 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -2066,7 +2066,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); delete _cachedThumbnail; _cachedThumbnail = new CBSaveThumbHelper(this); - if (FAILED(_cachedThumbnail->StoreThumbnail())) { + if (FAILED(_cachedThumbnail->storeThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; stack->pushBool(false); diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index af115ef386..01ebb596b9 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -182,7 +182,7 @@ HRESULT CBPersistMgr::initSave(const char *desc) { // get thumbnails if (!Game->_cachedThumbnail) { Game->_cachedThumbnail = new CBSaveThumbHelper(Game); - if (FAILED(Game->_cachedThumbnail->StoreThumbnail(true))) { + if (FAILED(Game->_cachedThumbnail->storeThumbnail(true))) { delete Game->_cachedThumbnail; Game->_cachedThumbnail = NULL; } diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 60bb2d9dfa..16485fd9ef 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -45,12 +45,12 @@ CBSaveThumbHelper::~CBSaveThumbHelper(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { +HRESULT CBSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { - if (DoFlip) { + if (doFlip) { // when using opengl on windows it seems to be necessary to do this twice // works normally for direct3d Game->displayContent(false); @@ -60,18 +60,18 @@ HRESULT CBSaveThumbHelper::StoreThumbnail(bool DoFlip) { Game->_renderer->flip(); } - CBImage *Screenshot = Game->_renderer->takeScreenshot(); - if (!Screenshot) return E_FAIL; + CBImage *screenshot = Game->_renderer->takeScreenshot(); + if (!screenshot) return E_FAIL; // normal thumbnail if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { _thumbnail = new CBImage(Game); - _thumbnail->copyFrom(Screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); + _thumbnail->copyFrom(screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); } - delete Screenshot; - Screenshot = NULL; + delete screenshot; + screenshot = NULL; } return S_OK; } diff --git a/engines/wintermute/Base/BSaveThumbHelper.h b/engines/wintermute/Base/BSaveThumbHelper.h index 36c21363c4..f3a2f914ef 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.h +++ b/engines/wintermute/Base/BSaveThumbHelper.h @@ -39,7 +39,7 @@ class CBSaveThumbHelper : public CBBase { public: CBSaveThumbHelper(CBGame *inGame); virtual ~CBSaveThumbHelper(void); - HRESULT StoreThumbnail(bool DoFlip = false); + HRESULT storeThumbnail(bool doFlip = false); CBImage *_thumbnail; CBImage *_richThumbnail; -- cgit v1.2.3 From 38f8ad562a017c75f50daf0841f311c2e74b6a3a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:31:06 +0200 Subject: WINTERMUTE: Rename VarName->varName in BScriptable --- engines/wintermute/Base/BScriptable.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index ea6aca21c2..16470ebf3c 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -150,9 +150,9 @@ HRESULT CBScriptable::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *Val) { - if (this < Val) return -1; - else if (this > Val) return 1; +int CBScriptable::scCompare(CBScriptable *val) { + if (this < val) return -1; + else if (this > val) return 1; else return 0; } -- cgit v1.2.3 From 3551a7c64ea98402d5bc180cee1071c15ebd2b74 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:37:15 +0200 Subject: WINTERMUTE: Rename VarName->varName in BScriptHolder --- engines/wintermute/Base/BScriptHolder.cpp | 82 +++++++++++++++---------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 131cec631f..f44cfde02c 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -80,21 +80,21 @@ void CBScriptHolder::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::applyEvent(const char *EventName, bool Unbreakable) { - int NumHandlers = 0; +HRESULT CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; HRESULT ret = E_FAIL; for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->InvokeEventHandler(EventName, Unbreakable); + CScScript *handler = _scripts[i]->InvokeEventHandler(eventName, unbreakable); if (handler) { //_scripts.Add(handler); - NumHandlers++; + numHandlers++; ret = S_OK; } } } - if (NumHandlers > 0 && Unbreakable) Game->_scEngine->TickUnbreakable(); + if (numHandlers > 0 && unbreakable) Game->_scEngine->TickUnbreakable(); return ret; } @@ -173,11 +173,11 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac else if (strcmp(name, "DetachScript") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - bool KillThreads = stack->pop()->getBool(false); + bool killThreads = stack->pop()->getBool(false); bool ret = false; for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - _scripts[i]->finish(KillThreads); + _scripts[i]->finish(killThreads); ret = true; break; } @@ -364,64 +364,64 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { buffer = params; } - char *PropName = NULL; - char *PropValue = NULL; + char *propName = NULL; + char *propValue = NULL; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_NAME: - delete[] PropName; - PropName = new char[strlen((char *)params) + 1]; - if (PropName) strcpy(PropName, (char *)params); + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); else cmd = PARSERR_GENERIC; break; case TOKEN_VALUE: - delete[] PropValue; - PropValue = new char[strlen((char *)params) + 1]; - if (PropValue) strcpy(PropValue, (char *)params); + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); else cmd = PARSERR_GENERIC; break; } } if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; Game->LOG(0, "Syntax error in PROPERTY definition"); return E_FAIL; } - if (cmd == PARSERR_GENERIC || PropName == NULL || PropValue == NULL) { - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; Game->LOG(0, "Error loading PROPERTY definition"); return E_FAIL; } CScValue *val = new CScValue(Game); - val->setString(PropValue); - scSetProperty(PropName, val); + val->setString(propValue); + scSetProperty(propName, val); delete val; - delete[] PropName; - delete[] PropValue; - PropName = NULL; - PropValue = NULL; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool Freezable) { - _freezable = Freezable; +void CBScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; for (int i = 0; i < _scripts.GetSize(); i++) - _scripts[i]->_freezable = Freezable; + _scripts[i]->_freezable = freezable; } @@ -450,15 +450,15 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *Buf, int BufSize) { - strcpy(Buf, scToString()); +void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); if (_name && strcmp(_name, "") != 0) { - strcat(Buf, " Name: "); - strcat(Buf, _name); + strcat(buf, " Name: "); + strcat(buf, _name); } if (_filename) { - strcat(Buf, " File: "); - strcat(Buf, _filename); + strcat(buf, " File: "); + strcat(buf, _filename); } } @@ -466,8 +466,8 @@ void CBScriptHolder::scDebuggerDesc(char *Buf, int BufSize) { ////////////////////////////////////////////////////////////////////////// // IWmeObject ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *EventName) { - return SUCCEEDED(applyEvent(EventName)); +bool CBScriptHolder::sendEvent(const char *eventName) { + return SUCCEEDED(applyEvent(eventName)); } } // end of namespace WinterMute -- cgit v1.2.3 From 6be4d55f0145b6388c9833f7394127bee5d4284c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:46:15 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSound --- engines/wintermute/Base/BSound.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index e6ba15ee3a..c3ed1a8e26 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -152,7 +152,8 @@ HRESULT CBSound::persist(CBPersistMgr *persistMgr) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) _soundPosition = _sound->getPosition(); + if (_soundPlaying) + _soundPosition = _sound->getPosition(); _soundLoopStart = _sound->_loopStart; _soundFreezePaused = _sound->_freezePaused; } @@ -196,7 +197,8 @@ HRESULT CBSound::setPositionTime(uint32 time) { if (!_sound) return E_FAIL; _soundPosition = time; HRESULT ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) _soundPosition = 0; + if (_sound->isPlaying()) + _soundPosition = 0; return ret; } @@ -205,33 +207,38 @@ HRESULT CBSound::setPositionTime(uint32 time) { uint32 CBSound::getPositionTime() { if (!_sound) return 0; - if (!_sound->isPlaying()) return 0; + if (!_sound->isPlaying()) + return 0; else return _sound->getPosition(); } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::setVolume(int volume) { - if (!_sound) return E_FAIL; + if (!_sound) + return E_FAIL; else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::setPrivateVolume(int volume) { - if (!_sound) return E_FAIL; + if (!_sound) + return E_FAIL; else return _sound->_privateVolume = volume; } ////////////////////////////////////////////////////////////////////////// int CBSound::getVolume() { - if (!_sound) return 0; + if (!_sound) + return 0; else return _sound->_privateVolume; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::setLoopStart(uint32 pos) { - if (!_sound) return E_FAIL; + if (!_sound) + return E_FAIL; else { _sound->setLoopStart(pos); return S_OK; @@ -240,17 +247,19 @@ HRESULT CBSound::setLoopStart(uint32 pos) { ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::setPan(float pan) { - if (_sound) return _sound->setPan(pan); + if (_sound) + return _sound->setPan(pan); else return E_FAIL; } ////////////////////////////////////////////////////////////////////////// HRESULT CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) return S_OK; + if (!_sound) + return S_OK; if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - HRESULT Ret = _sound->applyFX(type, param1, param2, param3, param4); + HRESULT ret = _sound->applyFX(type, param1, param2, param3, param4); _sFXType = type; _sFXParam1 = param1; @@ -258,7 +267,7 @@ HRESULT CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3 _sFXParam3 = param3; _sFXParam4 = param4; - return Ret; + return ret; } return S_OK; } -- cgit v1.2.3 From eedd542a8acdd97f339a9bf97cd133d73b400518 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 20:52:39 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSoundBuffer --- engines/wintermute/Base/BSoundBuffer.cpp | 28 ++++++++++++++-------------- engines/wintermute/Base/BSoundBuffer.h | 18 +++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 44d51cd360..92881ab01a 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -251,15 +251,15 @@ uint32 CBSoundBuffer::getLength() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(TSoundType Type) { - _type = Type; +void CBSoundBuffer::setType(TSoundType type) { + _type = type; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setVolume(int Volume) { +HRESULT CBSoundBuffer::setVolume(int volume) { if (_stream && _handle) { - byte vol = (byte)(Volume / 100.f * Audio::Mixer::kMaxChannelVolume); + byte vol = (byte)(volume / 100.f * Audio::Mixer::kMaxChannelVolume); g_system->getMixer()->setChannelVolume(*_handle, vol); } return S_OK; @@ -267,23 +267,23 @@ HRESULT CBSoundBuffer::setVolume(int Volume) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setPrivateVolume(int Volume) { +HRESULT CBSoundBuffer::setPrivateVolume(int volume) { #if 0 _privateVolume = Volume; switch (_type) { case SOUND_SFX: - Volume = Game->_soundMgr->_volumeSFX; + volume = Game->_soundMgr->_volumeSFX; break; case SOUND_SPEECH: - Volume = Game->_soundMgr->_volumeSpeech; + volume = Game->_soundMgr->_volumeSpeech; break; case SOUND_MUSIC: - Volume = Game->_soundMgr->_volumeMusic; + volume = Game->_soundMgr->_volumeMusic; break; } #endif - return setVolume(Volume); + return setVolume(volume); } @@ -308,7 +308,7 @@ uint32 CBSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setPosition(uint32 Pos) { +HRESULT CBSoundBuffer::setPosition(uint32 pos) { warning("CBSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { @@ -320,8 +320,8 @@ HRESULT CBSoundBuffer::setPosition(uint32 Pos) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setLoopStart(uint32 Pos) { - _loopStart = Pos; +HRESULT CBSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; #if 0 if (_stream) { if (_sync) { @@ -355,10 +355,10 @@ HRESULT CBSoundBuffer::setPan(float pan) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::applyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4) { +HRESULT CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { warning("CBSoundBuffer::ApplyFX - not implemented yet"); #if 0 - switch (Type) { + switch (type) { case SFX_ECHO: break; diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 264c5856b2..359c89e59e 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -49,7 +49,7 @@ public: HRESULT pause(); - HRESULT play(bool Looping = false, uint32 StartSample = 0); + HRESULT play(bool looping = false, uint32 startSample = 0); HRESULT resume(); HRESULT stop(); bool isPlaying(); @@ -57,23 +57,23 @@ public: void setLooping(bool looping); uint32 getPosition(); - HRESULT setPosition(uint32 Pos); + HRESULT setPosition(uint32 pos); uint32 getLength(); - HRESULT setLoopStart(uint32 Pos); + HRESULT setLoopStart(uint32 pos); uint32 getLoopStart() const { return _loopStart; } - HRESULT setPan(float Pan); - HRESULT setPrivateVolume(int Volume); - HRESULT setVolume(int Volume); + HRESULT setPan(float pan); + HRESULT setPrivateVolume(int colume); + HRESULT setVolume(int colume); void setType(TSoundType Type); - HRESULT loadFromFile(const char *filename, bool ForceReload = false); - void setStreaming(bool Streamed, uint32 NumBlocks = 0, uint32 BlockSize = 0); - HRESULT applyFX(TSFXType Type, float Param1, float Param2, float Param3, float Param4); + HRESULT loadFromFile(const char *filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + HRESULT applyFX(TSFXType type, float param1, float param2, float param3, float param4); //HSTREAM _stream; //HSYNC _sync; -- cgit v1.2.3 From 11e60e35a238118331c129f3797a2d791cbdb353 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 21:58:01 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSoundMgr --- engines/wintermute/Base/BSoundMgr.cpp | 82 ++++++++++++++++++----------------- engines/wintermute/Base/BSoundMgr.h | 18 ++++---- 2 files changed, 52 insertions(+), 48 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 7cebbdfc2e..1f801aca7a 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -60,7 +60,8 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; + for (int i = 0; i < _sounds.GetSize(); i++) + delete _sounds[i]; _sounds.RemoveAll(); #if 0 BASS_Free(); @@ -116,7 +117,8 @@ HRESULT CBSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundMgr::initLoop() { - if (!_soundAvailable) return S_OK; + if (!_soundAvailable) + return S_OK; #if 0 BASS_Update(500); @@ -126,8 +128,9 @@ HRESULT CBSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType Type, bool Streamed) { - if (!_soundAvailable) return NULL; +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool streamed) { + if (!_soundAvailable) + return NULL; CBSoundBuffer *sound; @@ -146,8 +149,8 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType Type, bool sound = new CBSoundBuffer(Game); if (!sound) return NULL; - sound->setStreaming(Streamed); - sound->setType(Type); + sound->setStreaming(streamed); + sound->setType(type); HRESULT res = sound->loadFromFile(filename); @@ -158,7 +161,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType Type, bool } // set volume appropriately - switch (Type) { + switch (type) { case SOUND_SFX: sound->setVolume(_volumeSFX); break; @@ -179,33 +182,33 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType Type, bool } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::addSound(CBSoundBuffer *Sound, TSoundType Type) { - if (!Sound) return E_FAIL; +HRESULT CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { + if (!sound) + return E_FAIL; // set volume appropriately - switch (Type) { + switch (type) { case SOUND_SFX: - Sound->setVolume(_volumeSFX); + sound->setVolume(_volumeSFX); break; case SOUND_SPEECH: - Sound->setVolume(_volumeSpeech); + sound->setVolume(_volumeSpeech); break; case SOUND_MUSIC: - Sound->setVolume(_volumeMusic); + sound->setVolume(_volumeMusic); break; } // register sound - _sounds.Add(Sound); + _sounds.Add(sound); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::removeSound(CBSoundBuffer *Sound) { - +HRESULT CBSoundMgr::removeSound(CBSoundBuffer *sound) { for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i] == Sound) { + if (_sounds[i] == sound) { delete _sounds[i]; _sounds.RemoveAt(i); return S_OK; @@ -217,59 +220,60 @@ HRESULT CBSoundMgr::removeSound(CBSoundBuffer *Sound) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolume(TSoundType Type, int Volume) { - if (!_soundAvailable) return S_OK; +HRESULT CBSoundMgr::setVolume(TSoundType type, int volume) { + if (!_soundAvailable) + return S_OK; - switch (Type) { + switch (type) { case SOUND_SFX: - _volumeSFX = Volume; + _volumeSFX = volume; break; case SOUND_SPEECH: - _volumeSpeech = Volume; + _volumeSpeech = volume; break; case SOUND_MUSIC: - _volumeMusic = Volume; + _volumeMusic = volume; break; } for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->_type == Type) _sounds[i]->setVolume(Volume); + if (_sounds[i]->_type == type) _sounds[i]->setVolume(volume); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolumePercent(TSoundType Type, byte Percent) { - return setVolume(Type, Percent); +HRESULT CBSoundMgr::setVolumePercent(TSoundType type, byte percent) { + return setVolume(type, percent); } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(TSoundType Type) { - int Volume = 0; - switch (Type) { +byte CBSoundMgr::getVolumePercent(TSoundType type) { + int volume = 0; + switch (type) { case SOUND_SFX: - Volume = _volumeSFX; + volume = _volumeSFX; break; case SOUND_SPEECH: - Volume = _volumeSpeech; + volume = _volumeSpeech; break; case SOUND_MUSIC: - Volume = _volumeMusic; + volume = _volumeMusic; break; default: error("Sound-type not set"); break; } - return (byte)Volume; + return (byte)volume; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setMasterVolumePercent(byte Percent) { - _volumeMaster = Percent; +HRESULT CBSoundMgr::setMasterVolumePercent(byte percent) { + _volumeMaster = percent; #if 0 BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); #endif @@ -289,10 +293,10 @@ byte CBSoundMgr::getMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::pauseAll(bool IncludingMusic) { +HRESULT CBSoundMgr::pauseAll(bool includingMusic) { for (int i = 0; i < _sounds.GetSize(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; } @@ -317,8 +321,8 @@ HRESULT CBSoundMgr::resumeAll() { ////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int X, int Y) { - float relPos = (float)X / ((float)Game->_renderer->_width); +float CBSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)Game->_renderer->_width); float minPan = -0.7f; float maxPan = 0.7f; diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index ca00ca43ee..e271508a50 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -36,24 +36,24 @@ namespace WinterMute { class CBSoundBuffer; class CBSoundMgr : public CBBase { public: - float posToPan(int X, int Y); + float posToPan(int x, int y); HRESULT resumeAll(); - HRESULT pauseAll(bool IncludingMusic = true); + HRESULT pauseAll(bool includingMusic = true); HRESULT cleanup(); //DECLARE_PERSISTENT(CBSoundMgr, CBBase); byte getMasterVolumePercent(); - HRESULT setMasterVolumePercent(byte Percent); - byte getVolumePercent(TSoundType Type); - HRESULT setVolumePercent(TSoundType Type, byte Percent); - HRESULT setVolume(TSoundType Type, int Volume); + HRESULT setMasterVolumePercent(byte percent); + byte getVolumePercent(TSoundType type); + HRESULT setVolumePercent(TSoundType type, byte percent); + HRESULT setVolume(TSoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; int _volumeMusic; int _volumeSpeech; int _volumeSFX; - HRESULT removeSound(CBSoundBuffer *Sound); - CBSoundBuffer *addSound(const char *filename, TSoundType Type = SOUND_SFX, bool Streamed = false); - HRESULT addSound(CBSoundBuffer *Sound, TSoundType Type = SOUND_SFX); + HRESULT removeSound(CBSoundBuffer *sound); + CBSoundBuffer *addSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); + HRESULT addSound(CBSoundBuffer *sound, TSoundType type = SOUND_SFX); HRESULT initLoop(); HRESULT initialize(); bool _soundAvailable; -- cgit v1.2.3 From 5f7b45de34d4f34c543d47e1feead84c79654965 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:10:15 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BSprite --- engines/wintermute/Ad/AdActor.cpp | 8 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdItem.cpp | 5 +- engines/wintermute/Ad/AdSentence.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 126 ++++++++++++++++--------------- engines/wintermute/Base/BSprite.h | 24 +++--- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/UI/UIButton.cpp | 12 +-- engines/wintermute/UI/UIEdit.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 2 +- engines/wintermute/UI/UIWindow.cpp | 2 +- 12 files changed, 99 insertions(+), 94 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 116f8e9794..d4d41c0fa6 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -620,7 +620,7 @@ HRESULT CAdActor::update() { } if (_tempSprite2) { - _tempSprite2->Reset(); + _tempSprite2->reset(); if (_tempSprite2->_looping) _tempSprite2->_looping = false; } _currentSprite = _tempSprite2; @@ -649,7 +649,7 @@ HRESULT CAdActor::update() { } if (_tempSprite2) { - _tempSprite2->Reset(); + _tempSprite2->reset(); if (_tempSprite2->_looping) _tempSprite2->_looping = false; } _currentSprite = _tempSprite2; @@ -694,7 +694,7 @@ HRESULT CAdActor::update() { } else { _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { - _tempSprite2->Reset(); + _tempSprite2->reset(); _currentSprite = _tempSprite2; ((CAdGame *)Game)->addSentence(_sentence); } @@ -1304,7 +1304,7 @@ HRESULT CAdActor::playAnim(const char *filename) { if (Anim) { _animSprite2 = Anim->getSprite(_dir); if (_animSprite2) { - _animSprite2->Reset(); + _animSprite2->reset(); _state = STATE_PLAYING_ANIM_SET; return S_OK; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index c5edae5a8f..4686e655ce 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -574,7 +574,7 @@ HRESULT CAdEntity::update() { } else { _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { - _tempSprite2->Reset(); + _tempSprite2->reset(); _currentSprite = _tempSprite2; } ((CAdGame *)Game)->addSentence(_sentence); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index e431ca78cf..36daeefd91 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -366,7 +366,7 @@ HRESULT CAdItem::update() { } else { _tempSprite2 = getTalkStance(_sentence->getNextStance()); if (_tempSprite2) { - _tempSprite2->Reset(); + _tempSprite2->reset(); _currentSprite = _tempSprite2; } ((CAdGame *)Game)->addSentence(_sentence); @@ -398,7 +398,8 @@ HRESULT CAdItem::display(int x, int y) { _posY = y; HRESULT ret; - if (_currentSprite) ret = _currentSprite->Draw(x, y, this, 100, 100, _alphaColor); + if (_currentSprite) + ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); else ret = S_OK; if (_displayAmount) { diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 7548655ee6..88b0f26d92 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -288,7 +288,7 @@ HRESULT CAdSentence::update(TDirection dir) { talkNodeFound = true; CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); - if (newSprite != _currentSprite) newSprite->Reset(); + if (newSprite != _currentSprite) newSprite->reset(); _currentSprite = newSprite; if (!_talkDef->_nodes[i]->_playToEnd) break; @@ -300,7 +300,7 @@ HRESULT CAdSentence::update(TDirection dir) { if (!talkNodeFound) { CBSprite *newSprite = _talkDef->getDefaultSprite(dir); if (newSprite) { - if (newSprite != _currentSprite) newSprite->Reset(); + if (newSprite != _currentSprite) newSprite->reset(); _currentSprite = newSprite; } else _currentSprite = NULL; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3422e860ce..088aebe4a3 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -4245,10 +4245,10 @@ HRESULT CBGame::stopVideo() { HRESULT CBGame::drawCursor(CBSprite *cursor) { if (!cursor) return E_FAIL; if (cursor != _lastCursor) { - cursor->Reset(); + cursor->reset(); _lastCursor = cursor; } - return cursor->Draw(_mousePos.x, _mousePos.y); + return cursor->draw(_mousePos.x, _mousePos.y); } diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 5adbaf9d14..79d35d948b 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -51,7 +51,7 @@ IMPLEMENT_PERSISTENT(CBSprite, false) CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { _editorAllFrames = false; _owner = Owner; - SetDefaults(); + setDefaults(); } @@ -62,7 +62,7 @@ CBSprite::~CBSprite() { ////////////////////////////////////////////////////////////////////////// -void CBSprite::SetDefaults() { +void CBSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; @@ -97,13 +97,13 @@ void CBSprite::cleanup() { delete[] _editorBgFile; _editorBgFile = NULL; - SetDefaults(); + setDefaults(); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha) { - GetCurrentFrame(ZoomX, ZoomY); +HRESULT CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + GetCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; // move owner if allowed to @@ -112,25 +112,25 @@ HRESULT CBSprite::Draw(int X, int Y, CBObject *Register, float ZoomX, float Zoom _owner->_posY += _moveY; _owner->afterMove(); - X = _owner->_posX; - Y = _owner->_posY; + x = _owner->_posX; + y = _owner->_posY; } // draw frame - return display(X, Y, Register, ZoomX, ZoomY, Alpha); + return display(x, y, registerOwner, zoomX, zoomY, alpha); } ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::loadFile(const char *filename, int LifeTime, TSpriteCacheType CacheType) { - Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); - if (!File) { +HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = Game->_fileManager->openFile(filename); + if (!file) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", LifeTime, CacheType); - else return loadFile("invalid.bmp", LifeTime, CacheType); + if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + else return loadFile("invalid.bmp", lifeTime, cacheType); } else { - Game->_fileManager->closeFile(File); - File = NULL; + Game->_fileManager->closeFile(file); + file = NULL; } HRESULT ret; @@ -139,7 +139,7 @@ HRESULT CBSprite::loadFile(const char *filename, int LifeTime, TSpriteCacheType if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { CBFrame *frame = new CBFrame(Game); CBSubFrame *subframe = new CBSubFrame(Game); - subframe->setSurface(filename, true, 0, 0, 0, LifeTime, true); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { Game->LOG(0, "Error loading simple sprite '%s'", filename); ret = E_FAIL; @@ -155,7 +155,7 @@ HRESULT CBSprite::loadFile(const char *filename, int LifeTime, TSpriteCacheType } else { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer) { - if (FAILED(ret = loadBuffer(buffer, true, LifeTime, CacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); + if (FAILED(ret = loadBuffer(buffer, true, lifeTime, cacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); delete [] buffer; } } @@ -221,7 +221,7 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC buffer = params; } - int frame_count = 1; + int frameCount = 1; CBFrame *frame; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -285,18 +285,18 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_FRAME: { int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frame_count % 2 != 1) FrameLifeTime = -1; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; frame = new CBFrame(Game); if (FAILED(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; - Game->LOG(0, "Error parsing frame %d", frame_count); + Game->LOG(0, "Error parsing frame %d", frameCount); return E_FAIL; } _frames.Add(frame); - frame_count++; + frameCount++; if (_currentFrame == -1) _currentFrame = 0; } break; @@ -318,11 +318,11 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC ////////////////////////////////////////////////////////////////////// -void CBSprite::Reset() { +void CBSprite::reset() { if (_frames.GetSize() > 0) _currentFrame = 0; else _currentFrame = -1; - KillAllSounds(); + killAllSounds(); _lastFrameTime = 0; _finished = false; @@ -331,7 +331,7 @@ void CBSprite::Reset() { ////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { +bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; @@ -340,7 +340,7 @@ bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { if (_owner && _owner->_freezable) timer = Game->_timer; else timer = Game->_liveTimer; - int LastFrame = _currentFrame; + int lastFrame = _currentFrame; // get current frame if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { @@ -360,7 +360,7 @@ bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { _lastFrameTime = timer; } - _changed = (LastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); + _changed = (lastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); if (_lastFrameTime == 0) { _lastFrameTime = timer; @@ -372,9 +372,9 @@ bool CBSprite::GetCurrentFrame(float ZoomX, float ZoomY) { _moveX = _frames[_currentFrame]->_moveX; _moveY = _frames[_currentFrame]->_moveY; - if (ZoomX != 100 || ZoomY != 100) { - _moveX = (int)((float)_moveX * (float)(ZoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(ZoomY / 100.0f)); + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); } } @@ -389,7 +389,7 @@ HRESULT CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float Z // on change... if (_changed) { if (_frames[_currentFrame]->_killSound) { - KillAllSounds(); + killAllSounds(); } applyEvent("FrameChanged"); _frames[_currentFrame]->oneTimeDisplay(_owner, Game->_editorMode && _editorMuted); @@ -401,7 +401,7 @@ HRESULT CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float Z ////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::GetSurface() { +CBSurface *CBSprite::getSurface() { // only used for animated textures for 3D models if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return NULL; CBFrame *Frame = _frames[_currentFrame]; @@ -413,16 +413,16 @@ CBSurface *CBSprite::GetSurface() { } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; +bool CBSprite::GetBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; - CBPlatform::SetRectEmpty(Rect); + CBPlatform::SetRectEmpty(rect); for (int i = 0; i < _frames.GetSize(); i++) { RECT frame; RECT temp; - CBPlatform::CopyRect(&temp, Rect); - _frames[i]->getBoundingRect(&frame, X, Y, ScaleX, ScaleY); - CBPlatform::UnionRect(Rect, &temp, &frame); + CBPlatform::CopyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + CBPlatform::UnionRect(rect, &temp, &frame); } return true; } @@ -552,7 +552,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Reset") == 0) { stack->correctParams(0); - Reset(); + reset(); stack->pushNULL(); return S_OK; } @@ -562,21 +562,21 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddFrame") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); const char *filename = NULL; - if (!Val->isNULL()) filename = Val->getString(); + if (!val->isNULL()) filename = val->getString(); - CBFrame *Frame = new CBFrame(Game); + CBFrame *frame = new CBFrame(Game); if (filename != NULL) { - CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->setSurface(filename))) { - Sub->setDefaultRect(); - Frame->_subframes.Add(Sub); - } else delete Sub; + CBSubFrame *sub = new CBSubFrame(Game); + if (SUCCEEDED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.Add(sub); + } else delete sub; } - _frames.Add(Frame); + _frames.Add(frame); - stack->pushNative(Frame, true); + stack->pushNative(frame, true); return S_OK; } @@ -585,24 +585,27 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); - int Index = stack->pop()->getInt(); - if (Index < 0) Index = 0; + int index = stack->pop()->getInt(); + if (index < 0) + index = 0; - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); const char *filename = NULL; - if (!Val->isNULL()) filename = Val->getString(); + if (!val->isNULL()) + filename = val->getString(); - CBFrame *Frame = new CBFrame(Game); + CBFrame *frame = new CBFrame(Game); if (filename != NULL) { - CBSubFrame *Sub = new CBSubFrame(Game); - if (SUCCEEDED(Sub->setSurface(filename))) Frame->_subframes.Add(Sub); - else delete Sub; + CBSubFrame *sub = new CBSubFrame(Game); + if (SUCCEEDED(sub->setSurface(filename))) frame->_subframes.Add(sub); + else delete sub; } - if (Index >= _frames.GetSize()) _frames.Add(Frame); - else _frames.InsertAt(Index, Frame); + if (index >= _frames.GetSize()) + _frames.Add(frame); + else _frames.InsertAt(index, frame); - stack->pushNative(Frame, true); + stack->pushNative(frame, true); return S_OK; } @@ -744,9 +747,10 @@ const char *CBSprite::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::KillAllSounds() { +HRESULT CBSprite::killAllSounds() { for (int i = 0; i < _frames.GetSize(); i++) { - if (_frames[i]->_sound) _frames[i]->_sound->stop(); + if (_frames[i]->_sound) + _frames[i]->_sound->stop(); } return S_OK; } diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 5a9cbc1515..4bfa720289 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -39,8 +39,8 @@ class CBSurface; class CBObject; class CBSprite: public CBScriptHolder { public: - HRESULT KillAllSounds(); - CBSurface *GetSurface(); + HRESULT killAllSounds(); + CBSurface *getSurface(); char *_editorBgFile; int _editorBgOffsetX; int _editorBgOffsetY; @@ -48,32 +48,32 @@ public: bool _streamed; bool _streamedKeepLoaded; void cleanup(); - void SetDefaults(); + void setDefaults(); bool _precise; DECLARE_PERSISTENT(CBSprite, CBScriptHolder) bool _editorAllFrames; - bool GetBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + bool GetBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; - HRESULT display(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - bool GetCurrentFrame(float ZoomX = 100, float ZoomY = 100); + HRESULT display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; bool _continuous; - void Reset(); + void reset(); CBObject *_owner; bool _changed; bool _paused; bool _finished; - HRESULT loadBuffer(byte *Buffer, bool Compete = true, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); - HRESULT loadFile(const char *filename, int LifeTime = -1, TSpriteCacheType CacheType = CACHE_ALL); + HRESULT loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + HRESULT loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; - HRESULT Draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, uint32 Alpha = 0xFFFFFFFF); + HRESULT draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - HRESULT AddFrame(const char *filename, uint32 Delay = 0, int HotspotX = 0, int HotspotY = 0, RECT *Rect = NULL); - CBSprite(CBGame *inGame, CBObject *Owner = NULL); + HRESULT addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, RECT *rect = NULL); + CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; HRESULT saveAsText(CBDynBuffer *buffer, int indent); diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 236481aec2..055ba0785d 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -74,7 +74,7 @@ CPartParticle::~CPartParticle(void) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::setSprite(const char *filename) { if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { - _sprite->Reset(); + _sprite->reset(); return S_OK; } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 374317993b..d10d4c7c89 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -631,7 +631,7 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { if (back) back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->Draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + if (image) image->draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); if (font && _text) { int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; @@ -641,11 +641,11 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites - if (_image && _image != image) _image->Reset(); - if (_imageDisable && _imageDisable != image) _imageDisable->Reset(); - if (_imageFocus && _imageFocus != image) _imageFocus->Reset(); - if (_imagePress && _imagePress != image) _imagePress->Reset(); - if (_imageHover && _imageHover != image) _imageHover->Reset(); + if (_image && _image != image) _image->reset(); + if (_imageDisable && _imageDisable != image) _imageDisable->reset(); + if (_imageFocus && _imageFocus != image) _imageFocus->reset(); + if (_imagePress && _imagePress != image) _imagePress->reset(); + if (_imageHover && _imageHover != image) _imageHover->reset(); _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 8594deb05c..5403081df0 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -552,7 +552,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { Game->_textEncoding = TEXT_ANSI; if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); + if (_image) _image->draw(OffsetX + _posX, OffsetY + _posY, NULL); // prepare fonts CBFont *font; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index f8e35c5ada..c52af0cf43 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -70,7 +70,7 @@ HRESULT CUIText::display(int OffsetX, int OffsetY) { if (!font) font = Game->_systemFont; if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->Draw(OffsetX + _posX, OffsetY + _posY, NULL); + if (_image) _image->draw(OffsetX + _posX, OffsetY + _posY, NULL); if (font && _text) { int text_offset; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index b244d13490..44d2bc5743 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -179,7 +179,7 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; if (back) back->display(_posX + OffsetX, _posY + OffsetY, _width, _height); - if (image) image->Draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); + if (image) image->draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { font->drawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); -- cgit v1.2.3 From 595f140cd82b06346dbfa668cdfa672fc402a9a9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:18:18 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BStringTable --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdNodeState.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BObject.cpp | 16 ++--- engines/wintermute/Base/BStringTable.cpp | 100 +++++++++++++++---------------- engines/wintermute/Base/BStringTable.h | 10 ++-- engines/wintermute/UI/UIButton.cpp | 2 +- engines/wintermute/UI/UIEdit.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 2 +- engines/wintermute/UI/UIWindow.cpp | 2 +- 11 files changed, 72 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 58b3250deb..66dd247a76 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -475,7 +475,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (res) { res->_iD = id; res->setText(text); - _stringTable->Expand(&res->_text); + _stringTable->expand(&res->_text); if (!val1->isNULL()) res->setIcon(val1->getString()); if (!val2->isNULL()) res->setIconHover(val2->getString()); if (!val3->isNULL()) res->setIconPressed(val3->getString()); diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 266adc9378..954c12c9fc 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -115,7 +115,7 @@ void CAdNodeState::setCaption(const char *caption, int caseVal) { _caption[caseVal- 1] = new char[strlen(caption) + 1]; if (_caption[caseVal- 1]) { strcpy(_caption[caseVal- 1], caption); - Game->_stringTable->Expand(&_caption[caseVal- 1]); + Game->_stringTable->expand(&_caption[caseVal- 1]); } } diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 4bea6921b9..978c4d2c04 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -838,7 +838,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const _sentence->_sound = NULL; _sentence->setText(text); - Game->_stringTable->Expand(&_sentence->_text); + Game->_stringTable->expand(&_sentence->_text); _sentence->setStances(stances); _sentence->_duration = duration; _sentence->_align = Align; @@ -850,7 +850,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // try to locate speech file automatically bool deleteSound = false; if (!sound) { - char *key = Game->_stringTable->GetKey(text); + char *key = Game->_stringTable->getKey(text); if (key) { sound = ((CAdGame *)Game)->findSpeechFile(key); delete [] key; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 088aebe4a3..7f24352b5e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1118,7 +1118,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CScValue *val = stack->pop(); char *str = new char[strlen(val->getString()) + 1]; strcpy(str, val->getString()); - _stringTable->Expand(&str); + _stringTable->expand(&str); stack->pushString(str); delete [] str; return S_OK; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 49c4a19fcc..6b4b0f5da2 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -137,16 +137,16 @@ HRESULT CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int Case) { // TODO: rename Case to something usefull - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) return; - delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(caption) + 1]; - if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], caption); - Game->_stringTable->Expand(&_caption[Case - 1]); + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + Game->_stringTable->expand(&_caption[caseVal - 1]); } } diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 72b5535714..ed33e4d776 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -50,35 +50,35 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDuplicities) { - if (Key == NULL || Val == NULL) return E_FAIL; +HRESULT CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return E_FAIL; - if (scumm_stricmp(Key, "@right-to-left") == 0) { + if (scumm_stricmp(key, "@right-to-left") == 0) { Game->_textRTL = true; return S_OK; } - Common::String final_key = Key; + Common::String final_key = key; StringUtil::toLowerCase(final_key); _stringsIter = _strings.find(final_key); - if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); - _strings[final_key] = Val; + _strings[final_key] = val; return S_OK; } ////////////////////////////////////////////////////////////////////////// -char *CBStringTable::GetKey(const char *Str) { - if (Str == NULL || Str[0] != '/') return NULL; +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; - const char *value = strchr(Str + 1, '/'); + const char *value = strchr(str + 1, '/'); if (value == NULL) return NULL; - char *key = new char[value - Str]; - strncpy(key, Str + 1, value - Str - 1); - key[value - Str - 1] = '\0'; + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; CBPlatform::strlwr(key); char *new_str; @@ -89,7 +89,7 @@ char *CBStringTable::GetKey(const char *Str) { strcpy(new_str, _stringsIter->_value.c_str()); if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { delete [] key; - char *Ret = GetKey(new_str); + char *Ret = getKey(new_str); delete [] new_str; return Ret; } else { @@ -102,17 +102,17 @@ char *CBStringTable::GetKey(const char *Str) { } ////////////////////////////////////////////////////////////////////////// -void CBStringTable::Expand(char **Str, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return; +void CBStringTable::expand(char **str, bool forceExpand) { + if (Game->_doNotExpandStrings && !forceExpand) return; - if (Str == NULL || *Str == NULL || *Str[0] != '/') return; + if (str == NULL || *str == NULL || *str[0] != '/') return; - char *value = strchr(*Str + 1, '/'); + char *value = strchr(*str + 1, '/'); if (value == NULL) return; - char *key = new char[value - *Str]; - strncpy(key, *Str + 1, value - *Str - 1); - key[value - *Str - 1] = '\0'; + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; CBPlatform::strlwr(key); value++; @@ -129,25 +129,25 @@ void CBStringTable::Expand(char **Str, bool ForceExpand) { } delete [] key; - delete [] *Str; - *Str = new_str; + delete [] *str; + *str = new_str; - if (strlen(*Str) > 0 && *Str[0] == '/') Expand(Str, ForceExpand); + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); } ////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return String; +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (Game->_doNotExpandStrings && !forceExpand) return string; - if (String == NULL || String[0] == '\0' || String[0] != '/') return String; + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; - const char *value = strchr(String + 1, '/'); - if (value == NULL) return String; + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; - char *key = new char[value - String]; - strncpy(key, String + 1, value - String - 1); - key[value - String - 1] = '\0'; + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; CBPlatform::strlwr(key); value++; @@ -163,28 +163,28 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { delete [] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return ExpandStatic(new_str, ForceExpand); + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); else return new_str; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { +HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { Game->LOG(0, "Loading string table..."); - if (ClearOld) _strings.clear(); + if (clearOld) _strings.clear(); - uint32 Size; - byte *buffer = Game->_fileManager->readWholeFile(filename, &Size); + uint32 size; + byte *buffer = Game->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); return E_FAIL; } - int Pos = 0; + int pos = 0; - if (Size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - Pos += 3; + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; if (Game->_textEncoding != TEXT_UTF8) { Game->_textEncoding = TEXT_UTF8; //Game->_textEncoding = TEXT_ANSI; @@ -192,15 +192,15 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { } } else Game->_textEncoding = TEXT_ANSI; - int LineLength = 0; - while (Pos < Size) { - LineLength = 0; - while (Pos + LineLength < Size && buffer[Pos + LineLength] != '\n' && buffer[Pos + LineLength] != '\0') LineLength++; + int lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *line = new char[RealLength + 1]; - strncpy(line, (char *)&buffer[Pos], RealLength); - line[RealLength] = '\0'; + int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; char *value = strchr(line, '\t'); if (value == NULL) value = strchr(line, ' '); @@ -211,12 +211,12 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { for (int i = 0; i < strlen(value); i++) { if (value[i] == '|') value[i] = '\n'; } - AddString(line, value, ClearOld); - } else if (line[0] != '\0') AddString(line, "", ClearOld); + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); } delete [] line; - Pos += LineLength + 1; + pos += lineLength + 1; } delete [] buffer; diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index ea35cf817b..059ff6fec0 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -37,14 +37,14 @@ namespace WinterMute { class CBStringTable : public CBBase { public: - const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT loadFile(const char *filename, bool DeleteAll = true); - void Expand(char **Str, bool ForceExpand = false); - HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); + const char *expandStatic(const char *string, bool forceExpand = false); + HRESULT loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + HRESULT addString(const char *key, const char *val, bool reportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); Common::HashMap _strings; - char *GetKey(const char *Str); + char *getKey(const char *str); private: Common::HashMap::iterator _stringsIter; diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index d10d4c7c89..4c16d708de 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -353,7 +353,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 5403081df0..ee583c8b89 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -221,7 +221,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_X: diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index c52af0cf43..82f7701b80 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -216,7 +216,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 44d2bc5743..52c15ba904 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -382,7 +382,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_TITLE: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TITLE_ALIGN: -- cgit v1.2.3 From 2faa444b31c89de217ebe1b292f238fa9a206f54 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:26:30 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSubFrame --- engines/wintermute/Base/BSubFrame.cpp | 74 +++++++++++++++++------------------ engines/wintermute/Base/BSubFrame.h | 8 ++-- 2 files changed, 41 insertions(+), 41 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index b3d40d7c67..182a2b0e37 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -113,22 +113,22 @@ HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { RECT rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custo_trans = false; + bool custoTrans = false; CBPlatform::SetRectEmpty(&rect); - char *surface_file = NULL; + char *surfaceFile = NULL; delete _surface; _surface = NULL; - while ((cmd = parser.getCommand((char **)&Buffer, commands, ¶ms)) > 0) { + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { switch (cmd) { case TOKEN_IMAGE: - surface_file = params; + surfaceFile = params; break; case TOKEN_TRANSPARENT: parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; + custoTrans = true; break; case TOKEN_RECT: @@ -181,13 +181,13 @@ HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { return E_FAIL; } - if (surface_file != NULL) { - if (custo_trans) setSurface(surface_file, false, r, g, b, LifeTime, KeepLoaded); - else setSurface(surface_file, true, 0, 0, 0, LifeTime, KeepLoaded); + if (surfaceFile != NULL) { + if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); } _alpha = DRGBA(ar, ag, ab, alpha); - if (custo_trans) _transparent = DRGBA(r, g, b, 0xFF); + if (custoTrans) _transparent = DRGBA(r, g, b, 0xFF); /* if(_surface == NULL) @@ -204,14 +204,14 @@ HRESULT CBSubFrame::loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded) { ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, bool Precise, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +HRESULT CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (!_surface) return S_OK; - if (Register != NULL && !_decoration) { - if (ZoomX == 100 && ZoomY == 100) { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, X - _hotspotX + _rect.left, Y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, ZoomX, ZoomY, Precise)); + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + Game->_renderer->_rectList.Add(new CBActiveRect(Game, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, Register, this, (int)(X - (_hotspotX + _rect.left) * (ZoomX / 100)), (int)(Y - (_hotspotY + _rect.top) * (ZoomY / 100)), (int)((_rect.right - _rect.left) * (ZoomX / 100)), (int)((_rect.bottom - _rect.top) * (ZoomY / 100)), ZoomX, ZoomY, Precise)); + Game->_renderer->_rectList.Add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (Game->_suspendedRendering) return S_OK; @@ -219,13 +219,13 @@ HRESULT CBSubFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float Zo HRESULT res; //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) Alpha = _alpha; + if (_alpha != 0xFFFFFFFF) alpha = _alpha; - if (Rotate != 0.0f) { - res = _surface->displayTransform((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _hotspotX, _hotspotY, _rect, ZoomX, ZoomY, Alpha, Rotate, BlendMode, _mirrorX, _mirrorY); + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); } else { - if (ZoomX == 100 && ZoomY == 100) res = _surface->displayTrans(X - _hotspotX, Y - _hotspotY, _rect, Alpha, BlendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(X - _hotspotX * (ZoomX / 100)), (int)(Y - _hotspotY * (ZoomY / 100)), _rect, ZoomX, ZoomY, Alpha, BlendMode, _mirrorX, _mirrorY); + if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); } return res; @@ -233,17 +233,17 @@ HRESULT CBSubFrame::draw(int X, int Y, CBObject *Register, float ZoomX, float Zo ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX, float ScaleY) { - if (!Rect) return false; +bool CBSubFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; - float RatioX = ScaleX / 100.0f; - float RatioY = ScaleY / 100.0f; + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; - CBPlatform::SetRect(Rect, - (int)(X - _hotspotX * RatioX), - (int)(Y - _hotspotY * RatioY), - (int)(X - _hotspotX * RatioX + (_rect.right - _rect.left)*RatioX), - (int)(Y - _hotspotY * RatioY + (_rect.bottom - _rect.top)*RatioY)); + CBPlatform::SetRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); return true; } @@ -549,7 +549,7 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::setSurface(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +HRESULT CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { Game->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -558,17 +558,17 @@ HRESULT CBSubFrame::setSurface(const char *filename, bool default_ck, byte ck_re delete[] _surfaceFilename; _surfaceFilename = NULL; - _surface = Game->_surfaceStorage->addSurface(filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + _surface = Game->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); if (_surface) { _surfaceFilename = new char[strlen(filename) + 1]; strcpy(_surfaceFilename, filename); - _cKDefault = default_ck; - _cKRed = ck_red; - _cKGreen = ck_green; - _cKBlue = ck_blue; - _lifeTime = LifeTime; - _keepLoaded = KeepLoaded; + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; return S_OK; } else return E_FAIL; diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 3b90cb3c8a..575c91fd0f 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -41,7 +41,7 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - HRESULT setSurface(const char *filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool KeepLoaded = false); + HRESULT setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); HRESULT setSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void setDefaultRect(); @@ -51,9 +51,9 @@ public: bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); - HRESULT loadBuffer(byte *Buffer, int LifeTime, bool KeepLoaded); - HRESULT draw(int X, int Y, CBObject *Register = NULL, float ZoomX = 100, float ZoomY = 100, bool Precise = true, uint32 Alpha = 0xFFFFFFFF, float Rotate = 0.0f, TSpriteBlendMode BlendMode = BLEND_NORMAL); - bool getBoundingRect(LPRECT Rect, int X, int Y, float ScaleX = 100, float ScaleY = 100); + HRESULT loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + HRESULT draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; int _hotspotY; -- cgit v1.2.3 From f028c3eaef427e076823d0d62636d03c815c2ff7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:28:31 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSurface --- engines/wintermute/Base/BSurface.cpp | 8 ++++---- engines/wintermute/Base/BSurface.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 299218fd4b..8a325a4d7f 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -60,7 +60,7 @@ CBSurface::~CBSurface() { ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { +HRESULT CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { return E_FAIL; } @@ -155,9 +155,9 @@ void CBSurface::setFilename(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -void CBSurface::setSize(int Width, int Height) { - _width = Width; - _height = Height; +void CBSurface::setSize(int width, int height) { + _width = width; + _height = height; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 2bfba077ce..9962b095c3 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -61,7 +61,7 @@ public: virtual HRESULT displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual HRESULT restore(); - virtual HRESULT create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime = -1, bool KeepLoaded = false) = 0; + virtual HRESULT create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual HRESULT create(int Width, int Height); virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return E_FAIL; -- cgit v1.2.3 From 8f27dd3f8960cc5566686420728da4fbe8a0f354 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:32:52 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSurfaceSDL --- engines/wintermute/Base/BSurfaceSDL.cpp | 48 ++++++++++++++++----------------- engines/wintermute/Base/BSurfaceSDL.h | 8 +++--- 2 files changed, 28 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 34f47b5d64..67304db0af 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -90,17 +90,17 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime, bool keepLoaded) { +HRESULT CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(filename); CBImage *image = new CBImage(Game); image->loadFile(strFileName); // const Graphics::Surface *surface = image->getSurface(); - if (default_ck) { - ck_red = 255; - ck_green = 0; - ck_blue = 255; + if (defaultCK) { + ckRed = 255; + ckGreen = 0; + ckBlue = 255; } _width = image->getSurface()->w; @@ -148,11 +148,11 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool default_ck, byte ck_red, if (strFileName.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); - trans.applyColorKey(ck_red, ck_green, ck_blue); + trans.applyColorKey(ckRed, ckGreen, ckBlue); } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); - trans.applyColorKey(ck_red, ck_green, ck_blue, true); + trans.applyColorKey(ckRed, ckGreen, ckBlue, true); } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); } else { @@ -351,7 +351,7 @@ bool CBSurfaceSDL::isTransparentAt(int x, int y) { StartPixelOp(); - bool ret = IsTransparentAtLite(X, Y); + bool ret = isTransparentAtLite(X, Y); EndPixelOp(); return ret; @@ -451,15 +451,15 @@ HRESULT CBSurfaceSDL::displayZoom(int x, int y, RECT rect, float zoomX, float zo ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayTransform(int x, int y, int HotX, int HotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &Rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +HRESULT CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); - if (renderer->_forceAlphaColor != 0) Alpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) alpha = renderer->_forceAlphaColor; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. @@ -469,10 +469,10 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo hasWarned = true; } - byte r = D3DCOLGetR(Alpha); - byte g = D3DCOLGetG(Alpha); - byte b = D3DCOLGetB(Alpha); - byte a = D3DCOLGetA(Alpha); + byte r = D3DCOLGetR(alpha); + byte g = D3DCOLGetG(alpha); + byte b = D3DCOLGetB(alpha); + byte a = D3DCOLGetA(alpha); renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); @@ -488,10 +488,10 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. Common::Rect srcRect; - srcRect.left = Rect->left; - srcRect.top = Rect->top; - srcRect.setWidth(Rect->right - Rect->left); - srcRect.setHeight(Rect->bottom - Rect->top); + srcRect.left = rect->left; + srcRect.top = rect->top; + srcRect.setWidth(rect->right - rect->left); + srcRect.setHeight(rect->bottom - rect->top); Common::Rect position; position.left = x + offsetX; @@ -505,8 +505,8 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo position.top = 0; // TODO: Something is wrong } - position.setWidth((float)srcRect.width() * ZoomX / 100.f); - position.setHeight((float)srcRect.height() * ZoomX / 100.f); + position.setWidth((float)srcRect.width() * zoomX / 100.f); + position.setHeight((float)srcRect.height() * zoomX / 100.f); renderer->modTargetRect(&position); @@ -517,12 +517,12 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *Rect, float ZoomX, float Zo // But no checking is in place for that yet. bool hasAlpha; - if (_hasAlpha && !AlphaDisable) { + if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; } - if (AlphaDisable) { + if (alphaDisable) { warning("CBSurfaceSDL::drawSprite - AlphaDisable ignored"); } diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 60052f70a1..50ce364beb 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -40,8 +40,8 @@ public: CBSurfaceSDL(CBGame *inGame); ~CBSurfaceSDL(); - HRESULT create(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int lifeTime = -1, bool keepLoaded = false); - HRESULT create(int Width, int Height); + HRESULT create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + HRESULT create(int width, int height); HRESULT createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function @@ -57,7 +57,7 @@ public: HRESULT displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); HRESULT displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - HRESULT displayTransform(int x, int y, int HotX, int HotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float Rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); @@ -78,7 +78,7 @@ public: private: Graphics::Surface *_surface; - HRESULT drawSprite(int x, int y, RECT *Rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + HRESULT drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); -- cgit v1.2.3 From 9542846803c0ec0c78e376c667a26fd578e1cd5d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:35:43 +0200 Subject: WINTERMUTE: Rename VarName->varName in BSurfaceStorage --- engines/wintermute/Base/BSurfaceStorage.cpp | 12 ++++++------ engines/wintermute/Base/BSurfaceStorage.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 2e98e494b1..d6009ac9e3 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -51,9 +51,9 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::cleanup(bool Warn) { +HRESULT CBSurfaceStorage::cleanup(bool warn) { for (int i = 0; i < _surfaces.GetSize(); i++) { - if (Warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); + if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.RemoveAll(); @@ -97,7 +97,7 @@ HRESULT CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool default_ck, byte ck_red, byte ck_green, byte ck_blue, int LifeTime, bool KeepLoaded) { +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (scumm_stricmp(_surfaces[i]->_filename, filename) == 0) { _surfaces[i]->_referenceCount++; @@ -108,9 +108,9 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool default_ck, b if (!Game->_fileManager->hasFile(filename)) { if (filename) Game->LOG(0, "Missing image: '%s'", filename); if (Game->_dEBUG_DebugMode) - return addSurface("invalid_debug.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); else - return addSurface("invalid.bmp", default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded); + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); } CBSurface *surface; @@ -118,7 +118,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool default_ck, b if (!surface) return NULL; - if (FAILED(surface->create(filename, default_ck, ck_red, ck_green, ck_blue, LifeTime, KeepLoaded))) { + if (FAILED(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { delete surface; return NULL; } else { diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index adeb87c50f..cb000cf38c 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -45,7 +45,7 @@ public: //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); HRESULT restoreAll(); - CBSurface *addSurface(const char *filename, bool default_ck = true, byte ck_red = 0, byte ck_green = 0, byte ck_blue = 0, int LifeTime = -1, bool keepLoaded = false); + CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); HRESULT removeSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); -- cgit v1.2.3 From 685ee29640e3f778999ece7b903fe56b7d212724 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:37:15 +0200 Subject: WINTERMUTE: Rename VarName->varName in BTransitionMgr --- engines/wintermute/Base/BTransitionMgr.cpp | 21 ++++++++++++--------- engines/wintermute/Base/BTransitionMgr.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 7ddbf21ec9..dd20e6b687 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -97,21 +97,23 @@ HRESULT CBTransitionMgr::update() { case TRANSITION_FADE_OUT: { uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); - Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->fade((uint16)Alpha); + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + Game->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) _state = TRANS_MGR_READY; + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; } break; case TRANSITION_FADE_IN: { uint32 time = CBPlatform::GetTime() - _lastTime; - int Alpha = (int)((float)time / (float)FADE_DURATION * 255); - Alpha = MIN(255, MAX(Alpha, 0)); - Game->_renderer->fade((uint16)Alpha); + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + Game->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) _state = TRANS_MGR_READY; + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; } break; default: @@ -119,7 +121,8 @@ HRESULT CBTransitionMgr::update() { } if (isReady()) { - if (_preserveInteractive) Game->_interactive = _origInteractive; + if (_preserveInteractive) + Game->_interactive = _origInteractive; } return S_OK; } diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h index 402ee32310..11949cf8a3 100644 --- a/engines/wintermute/Base/BTransitionMgr.h +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -40,7 +40,7 @@ public: bool _origInteractive; bool _preserveInteractive; HRESULT update(); - HRESULT start(TTransitionType Type, bool NonInteractive = false); + HRESULT start(TTransitionType type, bool nonInteractive = false); bool isReady(); TTransMgrState _state; CBTransitionMgr(CBGame *inGame); -- cgit v1.2.3 From 58f2d2575de59f88a9a6fd3152f895332e53ddd1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:38:08 +0200 Subject: WINTERMUTE: Rename VarName->varName in BViewport --- engines/wintermute/Base/BViewport.cpp | 4 ++-- engines/wintermute/Base/BViewport.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index 5ac5e375d9..8292f5e145 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -63,8 +63,8 @@ HRESULT CBViewport::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool NoCheck) { - if (!NoCheck) { +HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); right = MIN(right, Game->_renderer->_width); diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 6be57b712d..0360cb9957 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -39,7 +39,7 @@ public: int getHeight(); int getWidth(); RECT *getRect(); - HRESULT setRect(int left, int top, int right, int bottom, bool NoCheck = false); + HRESULT setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; int _offsetX; -- cgit v1.2.3 From 08b4dad26add6461137ec760584b0aaaea689ee4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:50:02 +0200 Subject: WINTERMUTE: Rename VarName->varName in PartEmitter --- engines/wintermute/Base/PartEmitter.cpp | 311 ++++++++++++++++---------------- engines/wintermute/Base/PartEmitter.h | 14 +- 2 files changed, 162 insertions(+), 163 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index 7c49177039..d3d7843f57 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -151,77 +151,77 @@ HRESULT CPartEmitter::removeSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::initParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta) { - if (!Particle) return E_FAIL; +HRESULT CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return E_FAIL; if (_sprites.GetSize() == 0) return E_FAIL; - int PosX = CBUtils::randomInt(_posX, _posX + _width); - int PosY = CBUtils::randomInt(_posY, _posY + _height); - float PosZ = CBUtils::randomFloat(0.0f, 100.0f); + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); - float Velocity; - if (_velocityZBased) Velocity = _velocity1 + PosZ * (_velocity2 - _velocity1) / 100; - else Velocity = CBUtils::randomFloat(_velocity1, _velocity2); + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); - float Scale; - if (_scaleZBased) Scale = _scale1 + PosZ * (_scale2 - _scale1) / 100; - else Scale = CBUtils::randomFloat(_scale1, _scale2); + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); - int LifeTime; - if (_lifeTimeZBased) LifeTime = _lifeTime2 - PosZ * (_lifeTime2 - _lifeTime1) / 100; - else LifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - float Angle = CBUtils::randomAngle(_angle1, _angle2); - int SpriteIndex = CBUtils::randomInt(0, _sprites.GetSize() - 1); + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.GetSize() - 1); - float Rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float AngVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float GrowthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); if (!CBPlatform::IsRectEmpty(&_border)) { - int ThicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * PosZ / 100.0f); - int ThicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * PosZ / 100.0f); - int ThicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * PosZ / 100.0f); - int ThicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * PosZ / 100.0f); + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - Particle->_border = _border; - Particle->_border.left += ThicknessLeft; - Particle->_border.right -= ThicknessRight; - Particle->_border.top += ThicknessTop; - Particle->_border.bottom -= ThicknessBottom; + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; } - Vector2 VecPos((float)PosX, (float)PosY); - Vector2 VecVel(0, Velocity); + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); - Matrix4 MatRot; - MatRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); - MatRot.transformVector2(VecVel); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); if (_alphaTimeBased) { - Particle->_alpha1 = _alpha1; - Particle->_alpha2 = _alpha2; + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; } else { - int Alpha = CBUtils::randomInt(_alpha1, _alpha2); - Particle->_alpha1 = Alpha; - Particle->_alpha2 = Alpha; - } - - Particle->_creationTime = CurrentTime; - Particle->_pos = VecPos; - Particle->_posZ = PosZ; - Particle->_velocity = VecVel; - Particle->_scale = Scale; - Particle->_lifeTime = LifeTime; - Particle->_rotation = Rotation; - Particle->_angVelocity = AngVelocity; - Particle->_growthRate = GrowthRate; - Particle->_exponentialGrowth = _exponentialGrowth; - Particle->_isDead = FAILED(Particle->setSprite(_sprites[SpriteIndex])); - Particle->fadeIn(CurrentTime, _fadeInTime); - - - if (Particle->_isDead) return E_FAIL; + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = FAILED(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return E_FAIL; else return S_OK; } @@ -232,54 +232,54 @@ HRESULT CPartEmitter::update() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::updateInternal(uint32 CurrentTime, uint32 TimerDelta) { - int NumLive = 0; +HRESULT CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; for (int i = 0; i < _particles.GetSize(); i++) { - _particles[i]->update(this, CurrentTime, TimerDelta); + _particles[i]->update(this, currentTime, timerDelta); - if (!_particles[i]->_isDead) NumLive++; + if (!_particles[i]->_isDead) numLive++; } // we're understaffed - if (NumLive < _maxParticles) { - bool NeedsSort = false; - if (CurrentTime - _lastGenTime > _genInterval) { - _lastGenTime = CurrentTime; + if (numLive < _maxParticles) { + bool needsSort = false; + if (currentTime - _lastGenTime > _genInterval) { + _lastGenTime = currentTime; _batchesGenerated++; if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { return S_OK; } - int ToGen = MIN(_genAmount, _maxParticles - NumLive); - while (ToGen > 0) { - int FirstDeadIndex = -1; + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; for (int i = 0; i < _particles.GetSize(); i++) { if (_particles[i]->_isDead) { - FirstDeadIndex = i; + firstDeadIndex = i; break; } } - CPartParticle *Particle; - if (FirstDeadIndex >= 0) Particle = _particles[FirstDeadIndex]; + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; else { - Particle = new CPartParticle(Game); - _particles.Add(Particle); + particle = new CPartParticle(Game); + _particles.Add(particle); } - initParticle(Particle, CurrentTime, TimerDelta); - NeedsSort = true; + initParticle(particle, currentTime, timerDelta); + needsSort = true; - ToGen--; + toGen--; } } - if (NeedsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) sortParticlesByZ(); // we actually generated some particles and we're not in fast-forward mode - if (NeedsSort && _overheadTime == 0) { + if (needsSort && _overheadTime == 0) { if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); } } @@ -288,12 +288,12 @@ HRESULT CPartEmitter::updateInternal(uint32 CurrentTime, uint32 TimerDelta) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::display(CBRegion *Region) { +HRESULT CPartEmitter::display(CBRegion *region) { if (_sprites.GetSize() <= 1) Game->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.GetSize(); i++) { - if (Region != NULL && _useRegion) { - if (!Region->pointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; + if (region != NULL && _useRegion) { + if (!region->pointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; } _particles[i]->display(this); @@ -314,18 +314,17 @@ HRESULT CPartEmitter::start() { if (_overheadTime > 0) { - uint32 Delta = 500; - int Steps = _overheadTime / Delta; - uint32 CurrentTime = Game->_timer - _overheadTime; + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = Game->_timer - _overheadTime; - for (int i = 0; i < Steps; i++) { - updateInternal(CurrentTime, Delta); - CurrentTime += Delta; + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; } _overheadTime = 0; } - return S_OK; } @@ -337,65 +336,65 @@ HRESULT CPartEmitter::sortParticlesByZ() { } ////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *Obj1, const void *Obj2) { - CPartParticle *P1 = *(CPartParticle **)Obj1; - CPartParticle *P2 = *(CPartParticle **)Obj2; +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; - if (P1->_posZ < P2->_posZ) return -1; - else if (P1->_posZ > P2->_posZ) return 1; + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::setBorder(int X, int Y, int Width, int Height) { - CBPlatform::SetRect(&_border, X, Y, X + Width, Y + Height); +HRESULT CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::SetRect(&_border, x, y, x + width, y + height); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom) { - _borderThicknessLeft = ThicknessLeft; - _borderThicknessRight = ThicknessRight; - _borderThicknessTop = ThicknessTop; - _borderThicknessBottom = ThicknessBottom; +HRESULT CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; return S_OK; } ////////////////////////////////////////////////////////////////////////// CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *Force = NULL; + CPartForce *force = NULL; for (int i = 0; i < _forces.GetSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { - Force = _forces[i]; + force = _forces[i]; break; } } - if (!Force) { - Force = new CPartForce(Game); - if (Force) { - Force->setName(name); - _forces.Add(Force); + if (!force) { + force = new CPartForce(Game); + if (force) { + force->setName(name); + _forces.Add(force); } } - return Force; + return force; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength) { - CPartForce *Force = addForceByName(name); - if (!Force) return E_FAIL; +HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return E_FAIL; - Force->_type = Type; - Force->_pos = Vector2(PosX, PosY); + force->_type = type; + force->_pos = Vector2(posX, posY); - Force->_direction = Vector2(0, Strength); - Matrix4 MatRot; - MatRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(Angle - 180))); - MatRot.transformVector2(Force->_direction); + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); return S_OK; } @@ -422,12 +421,12 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetBorder") == 0) { stack->correctParams(4); - int BorderX = stack->pop()->getInt(); - int BorderY = stack->pop()->getInt(); - int BorderWidth = stack->pop()->getInt(); - int BorderHeight = stack->pop()->getInt(); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); - stack->pushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight))); + stack->pushBool(SUCCEEDED(setBorder(borderX, borderY, borderWidth, borderHeight))); return S_OK; } @@ -436,12 +435,12 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBorderThickness") == 0) { stack->correctParams(4); - int Left = stack->pop()->getInt(); - int Right = stack->pop()->getInt(); - int Top = stack->pop()->getInt(); - int Bottom = stack->pop()->getInt(); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); - stack->pushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom))); + stack->pushBool(SUCCEEDED(setBorderThickness(left, right, top, bottom))); return S_OK; } @@ -450,8 +449,8 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSprite") == 0) { stack->correctParams(1); - const char *SpriteFile = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(addSprite(SpriteFile))); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(SUCCEEDED(addSprite(spriteFile))); return S_OK; } @@ -460,8 +459,8 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveSprite") == 0) { stack->correctParams(1); - const char *SpriteFile = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(removeSprite(SpriteFile))); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(SUCCEEDED(removeSprite(spriteFile))); return S_OK; } @@ -522,10 +521,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "AddGlobalForce") == 0) { stack->correctParams(3); const char *forceName = stack->pop()->getString(); - float Angle = stack->pop()->getFloat(); - float Strength = stack->pop()->getFloat(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); - stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength))); + stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); return S_OK; } @@ -536,12 +535,12 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "AddPointForce") == 0) { stack->correctParams(5); const char *forceName = stack->pop()->getString(); - int PosX = stack->pop()->getInt(); - int PosY = stack->pop()->getInt(); - float Angle = stack->pop()->getFloat(); - float Strength = stack->pop()->getFloat(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); - stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength))); + stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); return S_OK; } @@ -745,11 +744,11 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { // NumLiveParticles (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLiveParticles") == 0) { - int NumAlive = 0; + int numAlive = 0; for (int i = 0; i < _particles.GetSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) NumAlive++; + if (_particles[i] && !_particles[i]->_isDead) numAlive++; } - _scValue->setInt(NumAlive); + _scValue->setInt(numAlive); return _scValue; } @@ -1162,35 +1161,35 @@ HRESULT CPartEmitter::persist(CBPersistMgr *persistMgr) { _sprites.persist(persistMgr); - int NumForces; + int numForces; if (persistMgr->_saving) { - NumForces = _forces.GetSize(); - persistMgr->transfer(TMEMBER(NumForces)); + numForces = _forces.GetSize(); + persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < _forces.GetSize(); i++) { _forces[i]->persist(persistMgr); } } else { - persistMgr->transfer(TMEMBER(NumForces)); - for (int i = 0; i < NumForces; i++) { - CPartForce *Force = new CPartForce(Game); - Force->persist(persistMgr); - _forces.Add(Force); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(Game); + force->persist(persistMgr); + _forces.Add(force); } } - int NumParticles; + int numParticles; if (persistMgr->_saving) { - NumParticles = _particles.GetSize(); - persistMgr->transfer(TMEMBER(NumParticles)); + numParticles = _particles.GetSize(); + persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < _particles.GetSize(); i++) { _particles[i]->persist(persistMgr); } } else { - persistMgr->transfer(TMEMBER(NumParticles)); - for (int i = 0; i < NumParticles; i++) { - CPartParticle *Particle = new CPartParticle(Game); - Particle->persist(persistMgr); - _particles.Add(Particle); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(Game); + particle->persist(persistMgr); + _particles.Add(particle); } } diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index b088ee3920..5160b7fb25 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -104,15 +104,15 @@ public: HRESULT update(); HRESULT display() { return display(NULL); } // To avoid shadowing the inherited display-function. - HRESULT display(CBRegion *Region); + HRESULT display(CBRegion *region); HRESULT sortParticlesByZ(); HRESULT addSprite(const char *filename); HRESULT removeSprite(const char *filename); - HRESULT setBorder(int X, int Y, int Width, int Height); - HRESULT setBorderThickness(int ThicknessLeft, int ThicknessRight, int ThicknessTop, int ThicknessBottom); + HRESULT setBorder(int x, int y, int width, int height); + HRESULT setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - HRESULT addForce(const char *name, CPartForce::TForceType Type, int PosX, int PosY, float Angle, float Strength); + HRESULT addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); HRESULT removeForce(const char *name); CBArray _forces; @@ -126,9 +126,9 @@ public: private: CPartForce *addForceByName(const char *name); - int static compareZ(const void *Obj1, const void *Obj2); - HRESULT initParticle(CPartParticle *Particle, uint32 CurrentTime, uint32 TimerDelta); - HRESULT updateInternal(uint32 CurrentTime, uint32 TimerDelta); + int static compareZ(const void *obj1, const void *obj2); + HRESULT initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + HRESULT updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; CBArray _particles; CBArray _sprites; -- cgit v1.2.3 From c598adf9ace21da21b7f12478c57f6b34f29e653 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:54:15 +0200 Subject: WINTERMUTE: Rename VarName->varName in PartParticle --- engines/wintermute/Base/PartParticle.cpp | 70 ++++++++++++++++---------------- engines/wintermute/Base/PartParticle.h | 8 ++-- 2 files changed, 40 insertions(+), 38 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 055ba0785d..956c9bf2df 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -96,27 +96,27 @@ HRESULT CPartParticle::setSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta) { +HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { - if (CurrentTime - _fadeStart >= _fadeTime) { + if (currentTime - _fadeStart >= _fadeTime) { _state = PARTICLE_NORMAL; _currentAlpha = _alpha1; - } else _currentAlpha = ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; + } else _currentAlpha = ((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; return S_OK; } else if (_state == PARTICLE_FADEOUT) { - if (CurrentTime - _fadeStart >= _fadeTime) { + if (currentTime - _fadeStart >= _fadeTime) { _isDead = true; return S_OK; - } else _currentAlpha = _fadeStartAlpha - ((float)CurrentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; + } else _currentAlpha = _fadeStartAlpha - ((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; return S_OK; } else { // time is up if (_lifeTime > 0) { - if (CurrentTime - _creationTime >= _lifeTime) { - if (Emitter->_fadeOutTime > 0) - fadeOut(CurrentTime, Emitter->_fadeOutTime); + if (currentTime - _creationTime >= _lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); else _isDead = true; } @@ -127,52 +127,54 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 POINT p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!CBPlatform::PtInRect(&_border, p)) fadeOut(CurrentTime, Emitter->_fadeOutTime); + if (!CBPlatform::PtInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return S_OK; // update alpha if (_lifeTime > 0) { - int Age = (int)(CurrentTime - _creationTime); - int AlphaDelta = (int)(_alpha2 - _alpha1); + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); - _currentAlpha = _alpha1 + ((float)AlphaDelta / (float)_lifeTime * (float)Age); + _currentAlpha = _alpha1 + ((float)alphaDelta / (float)_lifeTime * (float)age); } // update position - float ElapsedTime = (float)TimerDelta / 1000.f; + float elapsedTime = (float)timerDelta / 1000.f; - for (int i = 0; i < Emitter->_forces.GetSize(); i++) { - CPartForce *Force = Emitter->_forces[i]; - switch (Force->_type) { + for (int i = 0; i < emitter->_forces.GetSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { case CPartForce::FORCE_GLOBAL: - _velocity += Force->_direction * ElapsedTime; + _velocity += force->_direction * elapsedTime; break; case CPartForce::FORCE_POINT: { - Vector2 VecDist = Force->_pos - _pos; - float Dist = fabs(VecDist.length()); + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); - Dist = 100.0f / Dist; + dist = 100.0f / dist; - _velocity += Force->_direction * Dist * ElapsedTime; + _velocity += force->_direction * dist * elapsedTime; } break; } } - _pos += _velocity * ElapsedTime; + _pos += _velocity * elapsedTime; // update rotation - _rotation += _angVelocity * ElapsedTime; + _rotation += _angVelocity * elapsedTime; _rotation = CBUtils::normalizeAngle(_rotation); // update scale if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * ElapsedTime; + _scale += _scale / 100.0f * _growthRate * elapsedTime; else - _scale += _growthRate * ElapsedTime; + _scale += _growthRate * elapsedTime; - if (_scale <= 0.0f) _isDead = true; + if (_scale <= 0.0f) + _isDead = true; return S_OK; @@ -180,7 +182,7 @@ HRESULT CPartParticle::update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::display(CPartEmitter *Emitter) { +HRESULT CPartParticle::display(CPartEmitter *emitter) { if (!_sprite) return E_FAIL; if (_isDead) return S_OK; @@ -190,26 +192,26 @@ HRESULT CPartParticle::display(CPartEmitter *Emitter) { _scale, _scale, DRGBA(255, 255, 255, _currentAlpha), _rotation, - Emitter->_blendMode); + emitter->_blendMode); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::fadeIn(uint32 CurrentTime, int FadeTime) { +HRESULT CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { _currentAlpha = 0; - _fadeStart = CurrentTime; - _fadeTime = FadeTime; + _fadeStart = currentTime; + _fadeTime = fadeTime; _state = PARTICLE_FADEIN; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::fadeOut(uint32 CurrentTime, int FadeTime) { +HRESULT CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; - _fadeStart = CurrentTime; - _fadeTime = FadeTime; + _fadeStart = currentTime; + _fadeTime = fadeTime; _state = PARTICLE_FADEOUT; return S_OK; diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index e20413726a..e6a34c8a21 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -68,13 +68,13 @@ public: bool _isDead; TParticleState _state; - HRESULT update(CPartEmitter *Emitter, uint32 CurrentTime, uint32 TimerDelta); - HRESULT display(CPartEmitter *Emitter); + HRESULT update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + HRESULT display(CPartEmitter *emitter); HRESULT setSprite(const char *filename); - HRESULT fadeIn(uint32 CurrentTime, int FadeTime); - HRESULT fadeOut(uint32 CurrentTime, int FadeTime); + HRESULT fadeIn(uint32 currentTime, int fadeTime); + HRESULT fadeOut(uint32 currentTime, int fadeTime); HRESULT persist(CBPersistMgr *PersistMgr); private: -- cgit v1.2.3 From 19243980be3ba6b3955954d03e8292c69a7f67b2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:59:59 +0200 Subject: WINTERMUTE: Rename VarName->varName in UIButton --- engines/wintermute/UI/UIButton.cpp | 50 +++++++++++++++++++------------------- engines/wintermute/UI/UIButton.h | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 4c16d708de..b5f22b29fc 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -73,10 +73,10 @@ CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIButton::~CUIButton() { - if (_backPress) delete _backPress; - if (_backHover) delete _backHover; - if (_backDisable) delete _backDisable; - if (_backFocus) delete _backFocus; + delete _backPress; + delete _backHover; + delete _backDisable; + delete _backFocus; if (!_sharedFonts) { if (_fontHover) Game->_fontStorage->removeFont(_fontHover); @@ -86,10 +86,10 @@ CUIButton::~CUIButton() { } if (!_sharedImages) { - if (_imageHover) delete _imageHover; - if (_imagePress) delete _imagePress; - if (_imageDisable) delete _imageDisable; - if (_imageFocus) delete _imageFocus; + delete _imageHover; + delete _imagePress; + delete _imageDisable; + delete _imageFocus; } } @@ -109,7 +109,6 @@ HRESULT CUIButton::loadFile(const char *filename) { if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); - delete [] buffer; return ret; @@ -578,8 +577,9 @@ void CUIButton::correctSize() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::display(int OffsetX, int OffsetY) { - if (!_visible) return S_OK; +HRESULT CUIButton::display(int offsetX, int offsetY) { + if (!_visible) + return S_OK; CUITiledImage *back = NULL; CBSprite *image = NULL; @@ -619,26 +619,26 @@ HRESULT CUIButton::display(int OffsetX, int OffsetY) { else font = Game->_systemFont; } - int ImageX = OffsetX + _posX; - int ImageY = OffsetY + _posY; + int imageX = offsetX + _posX; + int imageY = offsetY + _posY; if (image && _centerImage) { RECT rc; image->GetBoundingRect(&rc, 0, 0); - ImageX += (_width - (rc.right - rc.left)) / 2; - ImageY += (_height - (rc.bottom - rc.top)) / 2; + imageX += (_width - (rc.right - rc.left)) / 2; + imageY += (_height - (rc.bottom - rc.top)) / 2; } - if (back) back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); + if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->draw(ImageX + ((_press || _oneTimePress) && back ? 1 : 0), ImageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); if (font && _text) { int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; - font->drawText((byte *)_text, OffsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), OffsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites if (_image && _image != image) _image->reset(); @@ -690,14 +690,14 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHoverFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); if (_fontHover) Game->_fontStorage->removeFont(_fontHover); - if (Val->isNULL()) { + if (val->isNULL()) { _fontHover = NULL; stack->pushBool(true); } else { - _fontHover = Game->_fontStorage->addFont(Val->getString()); + _fontHover = Game->_fontStorage->addFont(val->getString()); stack->pushBool(_fontHover != NULL); } return S_OK; @@ -726,14 +726,14 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFocusedFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); - if (Val->isNULL()) { + if (val->isNULL()) { _fontFocus = NULL; stack->pushBool(true); } else { - _fontFocus = Game->_fontStorage->addFont(Val->getString()); + _fontFocus = Game->_fontStorage->addFont(val->getString()); stack->pushBool(_fontFocus != NULL); } return S_OK; diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index cb14a68d5c..2c16c4b5d0 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -44,7 +44,7 @@ public: uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) void press(); - virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int offsetX = 0, int offsetY = 0); bool _press; bool _hover; void correctSize(); -- cgit v1.2.3 From dd99e2278446f047dd6678b01a98d359a8ad5f69 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:05:15 +0200 Subject: WINTERMUTE: Rename VarName->varName in UIEdit --- engines/wintermute/UI/UIEdit.cpp | 100 +++++++++++++++++++-------------------- engines/wintermute/UI/UIEdit.h | 8 ++-- 2 files changed, 54 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index ee583c8b89..c1971b342d 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -534,16 +534,16 @@ const char *CUIEdit::scToString() { ////////////////////////////////////////////////////////////////////////// -void CUIEdit::setCursorChar(const char *Char) { - if (!Char) return; +void CUIEdit::setCursorChar(const char *character) { + if (!character) return; delete[] _cursorChar; - _cursorChar = new char [strlen(Char) + 1]; - if (_cursorChar) strcpy(_cursorChar, Char); + _cursorChar = new char [strlen(character) + 1]; + if (_cursorChar) strcpy(_cursorChar, character); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::display(int OffsetX, int OffsetY) { +HRESULT CUIEdit::display(int offsetX, int offsetY) { if (!_visible) return S_OK; @@ -551,8 +551,8 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { TTextEncoding OrigEncoding = Game->_textEncoding; Game->_textEncoding = TEXT_ANSI; - if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->draw(OffsetX + _posX, OffsetY + _posY, NULL); + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); // prepare fonts CBFont *font; @@ -573,13 +573,13 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { _selEnd = MIN((size_t)_selEnd, strlen(_text)); //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int CursorWidth = font->getTextWidth((byte *)_cursorChar); + int cursorWidth = font->getTextWidth((byte *)_cursorChar); int s1, s2; - bool CurFirst; + bool curFirst; // modify scroll offset if (_selStart >= _selEnd) { - while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - CursorWidth - 2 * _frameWidth) { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= (int)strlen(_text)) break; } @@ -588,12 +588,12 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { s1 = _selEnd; s2 = _selStart; - CurFirst = true; + curFirst = true; } else { while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - > _width - CursorWidth - 2 * _frameWidth) { + > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; if (_scrollOffset >= (int)strlen(_text)) break; } @@ -602,7 +602,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { s1 = _selStart; s2 = _selEnd; - CurFirst = false; + curFirst = false; } @@ -612,10 +612,10 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { // draw text int xxx, yyy, width, height; - xxx = _posX + _frameWidth + OffsetX; - yyy = _posY + _frameWidth + OffsetY; + xxx = _posX + _frameWidth + offsetX; + yyy = _posY + _frameWidth + offsetY; - width = _posX + _width + OffsetX - _frameWidth; + width = _posX + _width + offsetX - _frameWidth; height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); if (Game->_textRTL) xxx += AlignOffset; @@ -631,7 +631,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { } // cursor - if (focused && CurFirst) { + if (focused && curFirst) { if (Count) { if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { _lastBlinkTime = CBPlatform::GetTime(); @@ -640,8 +640,8 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { if (_cursorVisible) font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } - xxx += CursorWidth; - AlignOffset += CursorWidth; + xxx += cursorWidth; + AlignOffset += cursorWidth; } // selected @@ -654,7 +654,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { } // cursor - if (focused && !CurFirst) { + if (focused && !curFirst) { if (Count) { if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { _lastBlinkTime = CBPlatform::GetTime(); @@ -663,8 +663,8 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { if (_cursorVisible) font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); } - xxx += CursorWidth; - AlignOffset += CursorWidth; + xxx += cursorWidth; + AlignOffset += cursorWidth; } // unselected 2 @@ -676,7 +676,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { } - Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); Game->_textEncoding = OrigEncoding; @@ -687,7 +687,7 @@ HRESULT CUIEdit::display(int OffsetX, int OffsetY) { ////////////////////////////////////////////////////////////////////////// bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { - bool Handled = false; + bool handled = false; if (event->type == Common::EVENT_KEYDOWN && !printable) { switch (event->kbd.keycode) { @@ -701,7 +701,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { if (CBKeyboardState::isControlDown()) { _selStart = 0; _selEnd = strlen(_text); - Handled = true; + handled = true; } break; @@ -713,21 +713,21 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); _selStart = _selEnd; - Handled = true; + handled = true; break; case Common::KEYCODE_LEFT: case Common::KEYCODE_UP: _selEnd--; if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - Handled = true; + handled = true; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_DOWN: _selEnd++; if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - Handled = true; + handled = true; break; case Common::KEYCODE_HOME: @@ -738,7 +738,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { _selEnd = 0; if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } - Handled = true; + handled = true; break; case Common::KEYCODE_END: @@ -749,7 +749,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { _selEnd = strlen(_text); if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } - Handled = true; + handled = true; break; case Common::KEYCODE_DELETE: @@ -763,12 +763,12 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); _selStart = _selEnd; - Handled = true; + handled = true; break; default: break; } - return Handled; + return handled; } else if (event->type == Common::EVENT_KEYDOWN && printable) { if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); @@ -789,48 +789,48 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// -int CUIEdit::deleteChars(int Start, int End) { - if (Start > End) CBUtils::swap(&Start, &End); +int CUIEdit::deleteChars(int start, int end) { + if (start > end) CBUtils::swap(&start, &end); - Start = MAX(Start, (int)0); - End = MIN((size_t)End, strlen(_text)); + start = MAX(start, (int)0); + end = MIN((size_t)end, strlen(_text)); - char *str = new char[strlen(_text) - (End - Start) + 1]; + char *str = new char[strlen(_text) - (end - start) + 1]; if (str) { - if (Start > 0) memcpy(str, _text, Start); - memcpy(str + MAX(0, Start), _text + End, strlen(_text) - End + 1); + if (start > 0) memcpy(str, _text, start); + memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); delete[] _text; _text = str; } if (_parentNotify && _parent) _parent->applyEvent(_name); - return End - Start; + return end - start; } ////////////////////////////////////////////////////////////////////////// -int CUIEdit::insertChars(int Pos, byte *Chars, int Num) { - if ((int)strlen(_text) + Num > _maxLength) { - Num -= (strlen(_text) + Num - _maxLength); +int CUIEdit::insertChars(int pos, byte *chars, int num) { + if ((int)strlen(_text) + num > _maxLength) { + num -= (strlen(_text) + num - _maxLength); } - Pos = MAX(Pos, (int)0); - Pos = MIN((size_t)Pos, strlen(_text)); + pos = MAX(pos, (int)0); + pos = MIN((size_t)pos, strlen(_text)); - char *str = new char[strlen(_text) + Num + 1]; + char *str = new char[strlen(_text) + num + 1]; if (str) { - if (Pos > 0) memcpy(str, _text, Pos); - memcpy(str + Pos + Num, _text + Pos, strlen(_text) - Pos + 1); + if (pos > 0) memcpy(str, _text, pos); + memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); - memcpy(str + Pos, Chars, Num); + memcpy(str + pos, chars, num); delete[] _text; _text = str; } if (_parentNotify && _parent) _parent->applyEvent(_name); - return Num; + return num; } diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index 936cf0b72d..f011072ae3 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -39,16 +39,16 @@ class CUIEdit : public CUIObject { public: DECLARE_PERSISTENT(CUIEdit, CUIObject) int _maxLength; - int insertChars(int Pos, byte *Chars, int Num); - int deleteChars(int Start, int End); + int insertChars(int pos, byte *chars, int num); + int deleteChars(int start, int end); bool _cursorVisible; uint32 _lastBlinkTime; - virtual HRESULT display(int OffsetX, int OffsetY); + virtual HRESULT display(int offsetX, int offsetY); virtual bool handleKeypress(Common::Event *event, bool printable = false); int _scrollOffset; int _frameWidth; uint32 _cursorBlinkRate; - void setCursorChar(const char *Char); + void setCursorChar(const char *character); char *_cursorChar; int _selEnd; int _selStart; -- cgit v1.2.3 From efc26fc6fa0c2c88fc39558bc3c9524fef5974f6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:07:18 +0200 Subject: WINTERMUTE: Rename VarName->varName in UIEntity --- engines/wintermute/UI/UIEntity.cpp | 10 +++++----- engines/wintermute/UI/UIEntity.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 6c63ce4897..3d00b9251c 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -225,23 +225,23 @@ HRESULT CUIEntity::setEntity(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::display(int OffsetX, int OffsetY) { +HRESULT CUIEntity::display(int offsetX, int offsetY) { if (!_visible) return S_OK; if (_entity) { - _entity->_posX = OffsetX + _posX; - _entity->_posY = OffsetY + _posY; + _entity->_posX = offsetX + _posX; + _entity->_posY = offsetY + _posY; if (_entity->_scale < 0) _entity->_zoomable = false; _entity->_shadowable = false; _entity->update(); - bool OrigReg = _entity->_registrable; + bool origReg = _entity->_registrable; if (_entity->_registrable && _disable) _entity->_registrable = false; _entity->display(); - _entity->_registrable = OrigReg; + _entity->_registrable = origReg; } return S_OK; diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index eba931b57f..59bcc67bf3 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -39,10 +39,10 @@ public: CUIEntity(CBGame *inGame); virtual ~CUIEntity(); HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *Buffer, bool Complete); + HRESULT loadBuffer(byte *buffer, bool complete); virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int offsetX = 0, int offsetY = 0); CAdEntity *_entity; HRESULT setEntity(const char *filename); -- cgit v1.2.3 From 922e34bb80db1619ea07050c640ec7be044fcd9d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:12:27 +0200 Subject: WINTERMUTE: Rename VarName->varName in UIObject --- engines/wintermute/UI/UIObject.cpp | 42 +++++++++++++++++++------------------- engines/wintermute/UI/UIObject.h | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 52a24aa79c..519b4d214b 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -85,11 +85,11 @@ CUIObject::~CUIObject() { ////////////////////////////////////////////////////////////////////////// -void CUIObject::setText(const char *Text) { +void CUIObject::setText(const char *text) { if (_text) delete [] _text; - _text = new char [strlen(Text) + 1]; + _text = new char [strlen(text) + 1]; if (_text) { - strcpy(_text, Text); + strcpy(_text, text); for (int i = 0; i < strlen(_text); i++) { if (_text[i] == '|') _text[i] = '\n'; } @@ -98,16 +98,16 @@ void CUIObject::setText(const char *Text) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::display(int OffsetX, int OffsetY) { +HRESULT CUIObject::display(int offsetX, int offsetY) { return S_OK; } ////////////////////////////////////////////////////////////////////////// -void CUIObject::setListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam) { - _listenerObject = Object; - _listenerParamObject = ListenerObject; - _listenerParamDWORD = ListenerParam; +void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { + _listenerObject = object; + _listenerParamObject = listenerObject; + _listenerParamDWORD = listenerParam; } @@ -161,19 +161,19 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - /* const char *filename = */ Val->getString(); + /* const char *filename = */ val->getString(); delete _image; _image = NULL; - if (Val->isNULL()) { + if (val->isNULL()) { stack->pushBool(true); return S_OK; } _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile(Val->getString()))) { + if (!_image || FAILED(_image->loadFile(val->getString()))) { delete _image; _image = NULL; stack->pushBool(false); @@ -500,12 +500,12 @@ bool CUIObject::isFocused() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::handleMouse(TMouseEvent Event, TMouseButton Button) { +HRESULT CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { // handle focus change - if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { focus(); } - return CBObject::handleMouse(Event, Button); + return CBObject::handleMouse(event, button); } @@ -537,18 +537,18 @@ HRESULT CUIObject::focus() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::getTotalOffset(int *OffsetX, int *OffsetY) { - int OffX = 0, OffY = 0; +HRESULT CUIObject::getTotalOffset(int *offsetX, int *offsetY) { + int offX = 0, offY = 0; CUIObject *obj = _parent; while (obj) { - OffX += obj->_posX; - OffY += obj->_posY; + offX += obj->_posX; + offY += obj->_posY; obj = obj->_parent; } - if (OffsetX) *OffsetX = OffX; - if (OffsetY) *OffsetY = OffY; + if (offsetX) *offsetX = offX; + if (offsetY) *offsetY = offY; return S_OK; } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index ad7384860e..1a682527ac 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -43,7 +43,7 @@ public: HRESULT getTotalOffset(int *offsetX, int *offsetY); bool _canFocus; HRESULT focus(); - virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); + virtual HRESULT handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) @@ -64,7 +64,7 @@ public: int _height; TUIObjectType _type; CBSprite *_image; - void setListener(CBScriptHolder *Object, CBScriptHolder *ListenerObject, uint32 ListenerParam); + void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); CBScriptHolder *_listenerParamObject; uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; -- cgit v1.2.3 From 2c56b31996de7a1deaf6f4ed3e5802cfcf024e7c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:15:05 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in UIText --- engines/wintermute/UI/UIText.cpp | 20 ++++++++++---------- engines/wintermute/UI/UIText.h | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 82f7701b80..d5f44391ab 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -62,29 +62,29 @@ CUIText::~CUIText() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::display(int OffsetX, int OffsetY) { +HRESULT CUIText::display(int offsetX, int offsetY) { if (!_visible) return S_OK; CBFont *font = _font; if (!font) font = Game->_systemFont; - if (_back) _back->display(OffsetX + _posX, OffsetY + _posY, _width, _height); - if (_image) _image->draw(OffsetX + _posX, OffsetY + _posY, NULL); + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); if (font && _text) { - int text_offset; + int textOffset; switch (_verticalAlign) { case VAL_TOP: - text_offset = 0; + textOffset = 0; break; case VAL_BOTTOM: - text_offset = _height - font->getTextHeight((byte *)_text, _width); + textOffset = _height - font->getTextHeight((byte *)_text, _width); break; default: - text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + textOffset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; } - font->drawText((byte *)_text, OffsetX + _posX, OffsetY + _posY + text_offset, _width, _textAlign, _height); + font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); } //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); @@ -382,7 +382,7 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SizeToFit") == 0) { stack->correctParams(0); - SizeToFit(); + sizeToFit(); stack->pushNULL(); return S_OK; } @@ -478,7 +478,7 @@ HRESULT CUIText::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::SizeToFit() { +HRESULT CUIText::sizeToFit() { if (_font && _text) { _width = _font->getTextWidth((byte *)_text); _height = _font->getTextHeight((byte *)_text, _width); diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 876b6762f7..383f15f47d 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -35,9 +35,10 @@ namespace WinterMute { class CUIText : public CUIObject { +private: + HRESULT sizeToFit(); public: - HRESULT SizeToFit(); - virtual HRESULT display(int OffsetX, int OffsetY); + virtual HRESULT display(int offsetX, int offsetY); DECLARE_PERSISTENT(CUIText, CUIObject) CUIText(CBGame *inGame = NULL); virtual ~CUIText(); -- cgit v1.2.3 From 59af5428b52a871612e19f9d908753453cc31811 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:27:19 +0200 Subject: WINTERMUTE: Rename VarName->varName in UITiledImage --- engines/wintermute/UI/UITiledImage.cpp | 140 ++++++++++++++++----------------- engines/wintermute/UI/UITiledImage.h | 4 +- 2 files changed, 72 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index aa599f548d..05426bd01c 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -64,52 +64,52 @@ CUITiledImage::~CUITiledImage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::display(int X, int Y, int Width, int Height) { +HRESULT CUITiledImage::display(int x, int y, int width, int height) { if (!_image) return E_FAIL; - int tile_width = _middleMiddle.right - _middleMiddle.left; - int tile_height = _middleMiddle.bottom - _middleMiddle.top; + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - int nu_columns = (Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; - int nu_rows = (Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; + int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; int col, row; Game->_renderer->startSpriteBatch(); // top left/right - _image->_surface->displayTrans(X, Y, _upLeft); - _image->_surface->displayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y, _upRight); + _image->_surface->displayTrans(x, y, _upLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y, _upRight); // bottom left/right - _image->_surface->displayTrans(X, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downLeft); - _image->_surface->displayTrans(X + (_upLeft.right - _upLeft.left) + nu_columns * tile_width, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downRight); + _image->_surface->displayTrans(x, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); // left/right - int yyy = Y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nu_rows; row++) { - _image->_surface->displayTrans(X, yyy, _middleLeft); - _image->_surface->displayTrans(X + (_middleLeft.right - _middleLeft.left) + nu_columns * tile_width, yyy, _middleRight); - yyy += tile_width; + int yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + _image->_surface->displayTrans(x, yyy, _middleLeft); + _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); + yyy += tileWidth; } // top/bottom - int xxx = X + (_upLeft.right - _upLeft.left); - for (col = 0; col < nu_columns; col++) { - _image->_surface->displayTrans(xxx, Y, _upMiddle); - _image->_surface->displayTrans(xxx, Y + (_upMiddle.bottom - _upMiddle.top) + nu_rows * tile_height, _downMiddle); - xxx += tile_width; + int xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { + _image->_surface->displayTrans(xxx, y, _upMiddle); + _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); + xxx += tileWidth; } // tiles - yyy = Y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nu_rows; row++) { - xxx = X + (_upLeft.right - _upLeft.left); - for (col = 0; col < nu_columns; col++) { + yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { _image->_surface->displayTrans(xxx, yyy, _middleMiddle); - xxx += tile_width; + xxx += tileWidth; } - yyy += tile_width; + yyy += tileWidth; } Game->_renderer->endSpriteBatch(); @@ -180,9 +180,9 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; CBParser parser(Game); - bool HTiles = false, VTiles = false; - int H1 = 0, H2 = 0, H3 = 0; - int V1 = 0, V2 = 0, V3 = 0; + bool hTiles = false, vTiles = false; + int h1 = 0, h2 = 0, h3 = 0; + int v1 = 0, v2 = 0, v3 = 0; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { @@ -245,13 +245,13 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_HORIZONTAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &H1, &H2, &H3); - HTiles = true; + parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); + hTiles = true; break; case TOKEN_VERTICAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &V1, &V2, &V3); - VTiles = true; + parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); + vTiles = true; break; case TOKEN_EDITOR_PROPERTY: @@ -268,39 +268,39 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { return E_FAIL; } - if (VTiles && HTiles) { + if (vTiles && hTiles) { // up row - CBPlatform::SetRect(&_upLeft, 0, 0, H1, V1); - CBPlatform::SetRect(&_upMiddle, H1, 0, H1 + H2, V1); - CBPlatform::SetRect(&_upRight, H1 + H2, 0, H1 + H2 + H3, V1); + CBPlatform::SetRect(&_upLeft, 0, 0, h1, v1); + CBPlatform::SetRect(&_upMiddle, h1, 0, h1 + h2, v1); + CBPlatform::SetRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); // middle row - CBPlatform::SetRect(&_middleLeft, 0, V1, H1, V1 + V2); - CBPlatform::SetRect(&_middleMiddle, H1, V1, H1 + H2, V1 + V2); - CBPlatform::SetRect(&_middleRight, H1 + H2, V1, H1 + H2 + H3, V1 + V2); + CBPlatform::SetRect(&_middleLeft, 0, v1, h1, v1 + v2); + CBPlatform::SetRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); + CBPlatform::SetRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); // down row - CBPlatform::SetRect(&_downLeft, 0, V1 + V2, H1, V1 + V2 + V3); - CBPlatform::SetRect(&_downMiddle, H1, V1 + V2, H1 + H2, V1 + V2 + V3); - CBPlatform::SetRect(&_downRight, H1 + H2, V1 + V2, H1 + H2 + H3, V1 + V2 + V3); + CBPlatform::SetRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); + CBPlatform::SetRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); + CBPlatform::SetRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); } // default if (_image && _image->_surface) { - int Width = _image->_surface->getWidth() / 3; - int Height = _image->_surface->getHeight() / 3; + int width = _image->_surface->getWidth() / 3; + int height = _image->_surface->getHeight() / 3; - if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, Width, Height); - if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, Width, 0, 2 * Width, Height); - if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * Width, 0, 3 * Width, Height); + if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, width, height); + if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, width, 0, 2 * width, height); + if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * width, 0, 3 * width, height); - if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, Height, Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, Width, Height, 2 * Width, 2 * Height); - if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * Width, Height, 3 * Width, 2 * Height); + if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, height, width, 2 * height); + if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); - if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * Height, Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, Width, 2 * Height, 2 * Width, 3 * Height); - if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * Width, 2 * Height, 3 * Width, 3 * Height); + if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); } return S_OK; @@ -314,20 +314,20 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { if (_image && _image->_surfaceFilename) buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); - int H1, H2, H3; - int V1, V2, V3; + int h1, h2, h3; + int v1, v2, v3; - H1 = _upLeft.right; - H2 = _upMiddle.right - _upMiddle.left; - H3 = _upRight.right - _upRight.left; + h1 = _upLeft.right; + h2 = _upMiddle.right - _upMiddle.left; + h3 = _upRight.right - _upRight.left; - V1 = _upLeft.bottom; - V2 = _middleLeft.bottom - _middleLeft.top; - V3 = _downLeft.bottom - _downLeft.top; + v1 = _upLeft.bottom; + v2 = _middleLeft.bottom - _middleLeft.top; + v3 = _downLeft.bottom - _downLeft.top; - buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", V1, V2, V3); - buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", H1, H2, H3); + buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", v1, v2, v3); + buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); // editor properties CBBase::saveAsText(buffer, indent + 2); @@ -337,15 +337,15 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -void CUITiledImage::correctSize(int *Width, int *Height) { - int tile_width = _middleMiddle.right - _middleMiddle.left; - int tile_height = _middleMiddle.bottom - _middleMiddle.top; +void CUITiledImage::correctSize(int *width, int *height) { + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - int nu_columns = (*Width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tile_width; - int nu_rows = (*Height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tile_height; + int nuColumns = (*width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (*height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - *Width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nu_columns * tile_width; - *Height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nu_rows * tile_height; + *width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nuColumns * tileWidth; + *height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nuRows * tileHeight; } diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 60b95c12d9..583184cb51 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -37,12 +37,12 @@ class CBSubFrame; class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) - void correctSize(int *Width, int *Height); + void correctSize(int *width, int *height); HRESULT loadFile(const char *filename); HRESULT loadBuffer(byte *buffer, bool complete = true); virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - HRESULT display(int X, int Y, int Width, int Height); + HRESULT display(int x, int y, int width, int height); CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; -- cgit v1.2.3 From f29bc84bdb7d58d376655720436d53c2560c77f2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:34:45 +0200 Subject: WINTERMUTE: Rename VarName->varName in UIWindow --- engines/wintermute/UI/UIWindow.cpp | 146 +++++++++++++++++++------------------ engines/wintermute/UI/UIWindow.h | 12 +-- 2 files changed, 83 insertions(+), 75 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 52c15ba904..0c007f94fb 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -103,7 +103,7 @@ void CUIWindow::cleanup() { _shieldButton = NULL; _viewport = NULL; - if (_backInactive) delete _backInactive; + delete _backInactive; if (!_sharedFonts && _fontInactive) Game->_fontStorage->removeFont(_fontInactive); if (!_sharedImages && _imageInactive) delete _imageInactive; @@ -113,7 +113,7 @@ void CUIWindow::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::display(int OffsetX, int OffsetY) { +HRESULT CUIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); @@ -140,7 +140,8 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { } } - if (!_visible) return S_OK; + if (!_visible) + return S_OK; if (_fadeBackground) Game->_renderer->fadeToColor(_fadeColor); @@ -156,13 +157,13 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { moveFocus(); } - bool PopViewport = false; + bool popViewport = false; if (_clipContents) { if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) { - _viewport->setRect(_posX + OffsetX, _posY + OffsetY, _posX + _width + OffsetX, _posY + _height + OffsetY); + _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); Game->pushViewport(_viewport); - PopViewport = true; + popViewport = true; } } @@ -177,23 +178,29 @@ HRESULT CUIWindow::display(int OffsetX, int OffsetY) { if (_fontInactive) font = _fontInactive; } - if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = _alphaColor; - if (back) back->display(_posX + OffsetX, _posY + OffsetY, _width, _height); - if (image) image->draw(_posX + OffsetX, _posY + OffsetY, _transparent ? NULL : this); + if (_alphaColor != 0) + Game->_renderer->_forceAlphaColor = _alphaColor; + if (back) + back->display(_posX + offsetX, _posY + offsetY, _width, _height); + if (image) + image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { - font->drawText((byte *)_text, _posX + OffsetX + _titleRect.left, _posY + OffsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } - if (!_transparent && !image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + OffsetX, _posY + OffsetY, _width, _height, 100, 100, false)); + if (!_transparent && !image) + Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); for (int i = 0; i < _widgets.GetSize(); i++) { - _widgets[i]->display(_posX + OffsetX, _posY + OffsetY); + _widgets[i]->display(_posX + offsetX, _posY + offsetY); } - if (_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; + if (_alphaColor != 0) + Game->_renderer->_forceAlphaColor = 0; - if (PopViewport) Game->popViewport(); + if (popViewport) + Game->popViewport(); return S_OK; } @@ -303,7 +310,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { int cmd = 2; CBParser parser(Game); - int FadeR = 0, FadeG = 0, FadeB = 0, FadeA = 0; + int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; int ar = 0, ag = 0, ab = 0, alpha = 0; if (complete) { @@ -515,12 +522,12 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FADE_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &FadeR, &FadeG, &FadeB); + parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); _fadeBackground = true; break; case TOKEN_FADE_ALPHA: - parser.scanStr((char *)params, "%d", &FadeA); + parser.scanStr((char *)params, "%d", &fadeA); _fadeBackground = true; break; @@ -559,7 +566,8 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { } _alphaColor = DRGBA(ar, ag, ab, alpha); - if (_fadeBackground) _fadeColor = DRGBA(FadeR, FadeG, FadeB, FadeA); + if (_fadeBackground) + _fadeColor = DRGBA(fadeR, fadeG, fadeB, fadeA); _focusedWidget = NULL; @@ -816,10 +824,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "LoadFromFile") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); cleanup(); - if (!Val->isNULL()) { - stack->pushBool(SUCCEEDED(loadFile(Val->getString()))); + if (!val->isNULL()) { + stack->pushBool(SUCCEEDED(loadFile(val->getString()))); } else stack->pushBool(true); return S_OK; @@ -830,14 +838,14 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateButton") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIButton *Btn = new CUIButton(Game); - if (!Val->isNULL()) Btn->setName(Val->getString()); - stack->pushNative(Btn, true); + CUIButton *btn = new CUIButton(Game); + if (!val->isNULL()) btn->setName(val->getString()); + stack->pushNative(btn, true); - Btn->_parent = this; - _widgets.Add(Btn); + btn->_parent = this; + _widgets.Add(btn); return S_OK; } @@ -847,14 +855,14 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateStatic") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIText *Sta = new CUIText(Game); - if (!Val->isNULL()) Sta->setName(Val->getString()); - stack->pushNative(Sta, true); + CUIText *sta = new CUIText(Game); + if (!val->isNULL()) sta->setName(val->getString()); + stack->pushNative(sta, true); - Sta->_parent = this; - _widgets.Add(Sta); + sta->_parent = this; + _widgets.Add(sta); return S_OK; } @@ -864,14 +872,14 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEditor") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIEdit *Edi = new CUIEdit(Game); - if (!Val->isNULL()) Edi->setName(Val->getString()); - stack->pushNative(Edi, true); + CUIEdit *edi = new CUIEdit(Game); + if (!val->isNULL()) edi->setName(val->getString()); + stack->pushNative(edi, true); - Edi->_parent = this; - _widgets.Add(Edi); + edi->_parent = this; + _widgets.Add(edi); return S_OK; } @@ -881,14 +889,14 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - CUIWindow *Win = new CUIWindow(Game); - if (!Val->isNULL()) Win->setName(Val->getString()); - stack->pushNative(Win, true); + CUIWindow *win = new CUIWindow(Game); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); - Win->_parent = this; - _widgets.Add(Win); + win->_parent = this; + _widgets.Add(win); return S_OK; } @@ -1120,26 +1128,26 @@ bool CUIWindow::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::handleMouse(TMouseEvent Event, TMouseButton Button) { - HRESULT res = CUIObject::handleMouse(Event, Button); +HRESULT CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + HRESULT res = CUIObject::handleMouse(event, button); // handle window dragging if (!CBPlatform::IsRectEmpty(&_dragRect)) { // start drag - if (Event == MOUSE_CLICK && Button == MOUSE_BUTTON_LEFT) { - RECT DragRect = _dragRect; - int OffsetX, OffsetY; - getTotalOffset(&OffsetX, &OffsetY); - CBPlatform::OffsetRect(&DragRect, _posX + OffsetX, _posY + OffsetY); + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + RECT dragRect = _dragRect; + int offsetX, offsetY; + getTotalOffset(&offsetX, &offsetY); + CBPlatform::OffsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - if (CBPlatform::PtInRect(&DragRect, Game->_mousePos)) { + if (CBPlatform::PtInRect(&dragRect, Game->_mousePos)) { _dragFrom.x = Game->_mousePos.x; _dragFrom.y = Game->_mousePos.y; _dragging = true; } } // end drag - else if (_dragging && Event == MOUSE_RELEASE && Button == MOUSE_BUTTON_LEFT) { + else if (_dragging && event == MOUSE_RELEASE && button == MOUSE_BUTTON_LEFT) { _dragging = false; } } @@ -1181,7 +1189,7 @@ HRESULT CUIWindow::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::moveFocus(bool Forward) { +HRESULT CUIWindow::moveFocus(bool forward) { int i; bool found = false; for (i = 0; i < _widgets.GetSize(); i++) { @@ -1197,24 +1205,24 @@ HRESULT CUIWindow::moveFocus(bool Forward) { else return S_OK; } - int NumTries = 0; + int numTries = 0; bool done = false; - while (NumTries <= _widgets.GetSize()) { + while (numTries <= _widgets.GetSize()) { if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { _focusedWidget = _widgets[i]; done = true; break; } - if (Forward) { + if (forward) { i++; if (i >= _widgets.GetSize()) i = 0; } else { i--; if (i < 0) i = _widgets.GetSize() - 1; } - NumTries++; + numTries++; } return done ? S_OK : E_FAIL; @@ -1285,32 +1293,32 @@ HRESULT CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -void CUIWindow::makeFreezable(bool Freezable) { +void CUIWindow::makeFreezable(bool freezable) { for (int i = 0; i < _widgets.GetSize(); i++) - _widgets[i]->makeFreezable(Freezable); + _widgets[i]->makeFreezable(freezable); - CBObject::makeFreezable(Freezable); + CBObject::makeFreezable(freezable); } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::getWindowObjects(CBArray &Objects, bool InteractiveOnly) { +HRESULT CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.GetSize(); i++) { - CUIObject *Control = _widgets[i]; - if (Control->_disable && InteractiveOnly) continue; + CUIObject *control = _widgets[i]; + if (control->_disable && interactiveOnly) continue; - switch (Control->_type) { + switch (control->_type) { case UI_WINDOW: - ((CUIWindow *)Control)->getWindowObjects(Objects, InteractiveOnly); + ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); break; case UI_BUTTON: case UI_EDIT: - Objects.Add(Control); + objects.Add(control); break; default: - if (!InteractiveOnly) Objects.Add(Control); + if (!interactiveOnly) objects.Add(control); } } return S_OK; diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 6f639cc603..a7492ae8ef 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -43,31 +43,31 @@ public: bool _pauseMusic; void cleanup(); - virtual void makeFreezable(bool Freezable); + virtual void makeFreezable(bool freezable); CBViewport *_viewport; bool _clipContents; bool _inGame; bool _isMenu; bool _fadeBackground; uint32 _fadeColor; - virtual bool handleMouseWheel(int Delta); + virtual bool handleMouseWheel(int delta); CUIWindow *_shieldWindow; CUIButton *_shieldButton; HRESULT close(); HRESULT goSystemExclusive(); HRESULT goExclusive(); TWindowMode _mode; - HRESULT moveFocus(bool Forward = true); + HRESULT moveFocus(bool forward = true); virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); POINT _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - HRESULT showWidget(const char *name, bool Visible = true); - HRESULT enableWidget(const char *name, bool Enable = true); + HRESULT showWidget(const char *name, bool visible = true); + HRESULT enableWidget(const char *name, bool enable = true); RECT _titleRect; RECT _dragRect; - virtual HRESULT display(int OffsetX = 0, int OffsetY = 0); + virtual HRESULT display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false); -- cgit v1.2.3 From cb06b9feecc2aa591a9a107061f97ee74168f12e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 23:51:47 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in ScEngine --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 16 +- engines/wintermute/Base/BScriptHolder.cpp | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 266 +++++++++++------------ engines/wintermute/Base/scriptables/ScEngine.h | 84 +++---- engines/wintermute/Base/scriptables/ScScript.cpp | 6 +- engines/wintermute/wintermute.cpp | 2 +- 8 files changed, 190 insertions(+), 192 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 66dd247a76..62c2def022 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1707,7 +1707,7 @@ HRESULT CAdGame::displayContent(bool update, bool displayAll) { } else { // process scripts - if (update) _scEngine->Tick(); + if (update) _scEngine->tick(); POINT p; getMousePos(&p); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 978c4d2c04..2fa7df10a2 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -946,7 +946,7 @@ HRESULT CAdObject::reset() { _state = _nextState = STATE_READY; - Game->_scEngine->ResetObject(this); + Game->_scEngine->resetObject(this); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7f24352b5e..d34c526a23 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1990,7 +1990,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClearScriptCache") == 0) { stack->correctParams(0); - stack->pushBool(SUCCEEDED(_scEngine->EmptyScriptCache())); + stack->pushBool(SUCCEEDED(_scEngine->emptyScriptCache())); return S_OK; } @@ -2130,7 +2130,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EnableScriptProfiling") == 0) { stack->correctParams(0); - _scEngine->EnableProfiling(); + _scEngine->enableProfiling(); stack->pushNULL(); return S_OK; @@ -2141,7 +2141,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisableScriptProfiling") == 0) { stack->correctParams(0); - _scEngine->DisableProfiling(); + _scEngine->disableProfiling(); stack->pushNULL(); return S_OK; @@ -3358,7 +3358,7 @@ HRESULT CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); - _scEngine->RefreshScriptBreakpoints(); + _scEngine->refreshScriptBreakpoints(); if (_store) _store->afterLoad(); return S_OK; @@ -3745,7 +3745,7 @@ HRESULT CBGame::focusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { - _scEngine->PauseAll(); + _scEngine->pauseAll(); _soundMgr->pauseAll(includingMusic); _origState = _state; _origInteractive = _interactive; @@ -3766,7 +3766,7 @@ HRESULT CBGame::unfreeze() { if (_freezeLevel == 0) { _state = _origState; _interactive = _origInteractive; - _scEngine->ResumeAll(); + _scEngine->resumeAll(); _soundMgr->resumeAll(); } @@ -4171,7 +4171,7 @@ HRESULT CBGame::updateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::resetContent() { - _scEngine->ClearGlobals(); + _scEngine->clearGlobals(); //_timer = 0; //_liveTimer = 0; @@ -4432,7 +4432,7 @@ HRESULT CBGame::displayDebugInfo() { _renderer->displayDebugInfo(); int scrTotal, scrRunning, scrWaiting, scrPersistent; - scrTotal = _scEngine->GetNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index f44cfde02c..f07e2575dd 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -94,7 +94,7 @@ HRESULT CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { } } } - if (numHandlers > 0 && unbreakable) Game->_scEngine->TickUnbreakable(); + if (numHandlers > 0 && unbreakable) Game->_scEngine->tickUnbreakable(); return ret; } @@ -286,7 +286,7 @@ HRESULT CBScriptHolder::addScript(const char *filename) { } } - CScScript *scr = Game->_scEngine->RunScript(filename, this); + CScScript *scr = Game->_scEngine->runScript(filename, this); if (!scr) { if (Game->_editorForceScripts) { // editor hack diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 51098f0ef2..8cae017381 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -141,9 +141,9 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CScEngine::~CScEngine() { Game->LOG(0, "Shutting down scripting engine"); - SaveBreakpoints(); + saveBreakpoints(); - DisableProfiling(); + disableProfiling(); #ifdef __WIN32__ if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); #endif @@ -171,7 +171,7 @@ HRESULT CScEngine::cleanup() { delete _globals; _globals = NULL; - EmptyScriptCache(); + emptyScriptCache(); _currentScript = NULL; // ref only @@ -189,55 +189,55 @@ HRESULT CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// -byte *WINAPI CScEngine::loadFile(void *data, char *filename, uint32 *size) { +byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { CBGame *Game = (CBGame *)data; return Game->_fileManager->readWholeFile(filename, size); } ////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::CloseFile(void *Data, byte *Buffer) { - delete [] Buffer; +void CScEngine::closeFile(void *data, byte *buffer) { + delete [] buffer; } ////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::AddError(void *Data, int Line, char *Text) { - CBGame *Game = (CBGame *)Data; +void CScEngine::addError(void *data, int line, char *text) { + CBGame *Game = (CBGame *)data; if (Game) { if (Game->_scEngine && Game->_scEngine->_fileToCompile) Game->LOG(0, "Compiling script '%s'...", Game->_scEngine->_fileToCompile); - Game->LOG(0, " Error@line %d: %s", Line, Text); + Game->LOG(0, " Error@line %d: %s", line, text); // redirect to an engine's own callback if (Game->_scEngine && Game->_scEngine->_compileErrorCallback) { - Game->_scEngine->_compileErrorCallback(Line, Text, Game->_scEngine->_compileErrorCallbackData); + Game->_scEngine->_compileErrorCallback(line, text, Game->_scEngine->_compileErrorCallbackData); } } } ////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::ParseElement(void *Data, int Line, int Type, void *ElementData) { - CBGame *Game = (CBGame *)Data; +void WINAPI CScEngine::parseElement(void *data, int line, int type, void *elementData) { + CBGame *Game = (CBGame *)data; if (Game) { // redirect to an engine's own callback if (Game->_scEngine && Game->_scEngine->_parseElementCallback) { - Game->_scEngine->_parseElementCallback(Line, Type, ElementData, Game->_scEngine->_compileErrorCallbackData); + Game->_scEngine->_parseElementCallback(line, type, elementData, Game->_scEngine->_compileErrorCallbackData); } } } ////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::RunScript(const char *filename, CBScriptHolder *owner) { +CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { byte *compBuffer; uint32 compSize; // get script from cache - compBuffer = GetCompiledScript(filename, &compSize); + compBuffer = getCompiledScript(filename, &compSize); if (!compBuffer) return NULL; // add new script @@ -265,52 +265,50 @@ CScScript *CScEngine::RunScript(const char *filename, CBScriptHolder *owner) { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool IgnoreCache) { - int i; - +byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { // is script in cache? - if (!IgnoreCache) { - for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); - *OutSize = _cachedScripts[i]->_size; + *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } } } // nope, load it - byte *CompBuffer; - uint32 CompSize; - bool CompiledNow = false; + byte *compBuffer; + uint32 compSize; + bool compiledNow = false; - uint32 Size; + uint32 size; - byte *Buffer = Game->_fileManager->readWholeFile(filename, &Size); - if (!Buffer) { + byte *buffer = Game->_fileManager->readWholeFile(filename, &size); + if (!buffer) { Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; } // needs to be compiled? - if (FROM_LE_32(*(uint32 *)Buffer) == SCRIPT_MAGIC) { - CompBuffer = Buffer; - CompSize = Size; + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; } else { if (!_compilerAvailable) { Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] Buffer; + delete [] buffer; return NULL; } - CompiledNow = true; + compiledNow = true; // publish external methods to the compiler CALLBACKS c; - c.Dll_AddError = AddError; - c.Dll_CloseFile = CloseFile; + c.Dll_AddError = addError; + c.Dll_CloseFile = closeFile; c.Dll_LoadFile = loadFile; - c.Dll_ParseElement = ParseElement; + c.Dll_ParseElement = parseElement; ExtSetCallbacks(&c, Game); // publish native interfaces @@ -320,12 +318,12 @@ byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool I char *tempFileName = new char[strlen(filename) + 1]; memcpy(tempFileName, filename, strlen(filename) + 1); - SetFileToCompile(filename); - CompBuffer = ExtCompileFile(tempFileName, &CompSize); + setFileToCompile(filename); + compBuffer = ExtCompileFile(tempFileName, &compSize); delete[] tempFileName; - if (!CompBuffer) { + if (!compBuffer) { Game->quickMessage("Script compiler error. View log for details."); - delete [] Buffer; + delete [] buffer; return NULL; } } @@ -333,11 +331,11 @@ byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool I byte *ret = NULL; // add script to cache - CScCachedScript *CachedScript = new CScCachedScript(filename, CompBuffer, CompSize); - if (CachedScript) { + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { int index = 0; uint32 MinTime = CBPlatform::GetTime(); - for (i = 0; i < MAX_CACHED_SCRIPTS; i++) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; break; @@ -348,16 +346,16 @@ byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool I } if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; - _cachedScripts[index] = CachedScript; + _cachedScripts[index] = cachedScript; - ret = CachedScript->_buffer; - *OutSize = CachedScript->_size; + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; } // cleanup - delete [] Buffer; - if (CompiledNow) ExtReleaseBuffer(CompBuffer); + delete [] buffer; + if (compiledNow) ExtReleaseBuffer(compBuffer); return ret; } @@ -365,14 +363,14 @@ byte *CScEngine::GetCompiledScript(const char *filename, uint32 *OutSize, bool I ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::Tick() { - int i; +HRESULT CScEngine::tick() { + if (_scripts.GetSize() == 0) return S_OK; // resolve waiting scripts - for (i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.GetSize(); i++) { switch (_scripts[i]->_state) { case SCRIPT_WAITING: { @@ -405,7 +403,7 @@ HRESULT CScEngine::Tick() { } case SCRIPT_WAITING_SCRIPT: { - if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { // fake return value _scripts[i]->_stack->pushNULL(); _scripts[i]->_waitScript = NULL; @@ -429,7 +427,7 @@ HRESULT CScEngine::Tick() { // execute scripts - for (i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.GetSize(); i++) { // skip paused scripts if (_scripts[i]->_state == SCRIPT_PAUSED) continue; @@ -441,7 +439,7 @@ HRESULT CScEngine::Tick() { _currentScript = _scripts[i]; _scripts[i]->ExecuteInstruction(); } - if (_isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } // normal script @@ -454,19 +452,19 @@ HRESULT CScEngine::Tick() { _currentScript = _scripts[i]; _scripts[i]->ExecuteInstruction(); } - if (isProfiling && _scripts[i]->_filename) AddScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } _currentScript = NULL; } - RemoveFinishedScripts(); + removeFinishedScripts(); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::TickUnbreakable() { +HRESULT CScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_unbreakable) continue; @@ -478,14 +476,14 @@ HRESULT CScEngine::TickUnbreakable() { _scripts[i]->finish(); _currentScript = NULL; } - RemoveFinishedScripts(); + removeFinishedScripts(); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RemoveFinishedScripts() { +HRESULT CScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { @@ -501,8 +499,8 @@ HRESULT CScEngine::RemoveFinishedScripts() { ////////////////////////////////////////////////////////////////////////// -int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { - int running = 0, waiting = 0, persistent = 0, total = 0; +int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED) continue; @@ -510,30 +508,30 @@ int CScEngine::GetNumScripts(int *Running, int *Waiting, int *Persistent) { case SCRIPT_RUNNING: case SCRIPT_SLEEPING: case SCRIPT_PAUSED: - running++; + numRunning++; break; case SCRIPT_WAITING: - waiting++; + numWaiting++; break; case SCRIPT_PERSISTENT: - persistent++; + numPersistent++; break; default: warning("CScEngine::GetNumScripts - unhandled enum"); break; } - total++; + numTotal++; } - if (Running) *Running = running; - if (Waiting) *Waiting = waiting; - if (Persistent) *Persistent = persistent; + if (running) *running = numRunning; + if (waiting) *waiting = numWaiting; + if (persistent) *persistent = numPersistent; - return total; + return numTotal; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::EmptyScriptCache() { +HRESULT CScEngine::emptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i]) { delete _cachedScripts[i]; @@ -545,11 +543,11 @@ HRESULT CScEngine::EmptyScriptCache() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResetObject(CBObject *Object) { +HRESULT CScEngine::resetObject(CBObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!Game->_compatKillMethodThreads) ResetScript(_scripts[i]); + if (!Game->_compatKillMethodThreads) resetScript(_scripts[i]); bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well @@ -559,7 +557,7 @@ HRESULT CScEngine::ResetObject(CBObject *Object) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResetScript(CScScript *script) { +HRESULT CScEngine::resetScript(CScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { @@ -596,7 +594,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::PauseAll() { +HRESULT CScEngine::pauseAll() { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->Pause(); } @@ -606,7 +604,7 @@ HRESULT CScEngine::PauseAll() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ResumeAll() { +HRESULT CScEngine::resumeAll() { for (int i = 0; i < _scripts.GetSize(); i++) _scripts[i]->Resume(); @@ -615,7 +613,7 @@ HRESULT CScEngine::ResumeAll() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SetFileToCompile(const char *filename) { +HRESULT CScEngine::setFileToCompile(const char *filename) { delete[] _fileToCompile; _fileToCompile = new char[strlen(filename) + 1]; if (_fileToCompile) { @@ -626,20 +624,20 @@ HRESULT CScEngine::SetFileToCompile(const char *filename) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data) { - _compileErrorCallback = Callback; - _compileErrorCallbackData = Data; +void CScEngine::setCompileErrorCallback(COMPILE_ERROR_CALLBACK callback, void *data) { + _compileErrorCallback = callback; + _compileErrorCallbackData = data; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data) { - _parseElementCallback = Callback; - _parseElementCallbackData = Data; +void CScEngine::setParseElementCallback(PARSE_ELEMENT_CALLBACK callback, void *data) { + _parseElementCallback = callback; + _parseElementCallbackData = data; } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::IsValidScript(CScScript *script) { +bool CScEngine::isValidScript(CScScript *script) { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i] == script) return true; } @@ -647,73 +645,73 @@ bool CScEngine::IsValidScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::ClearGlobals(bool IncludingNatives) { - _globals->CleanProps(IncludingNatives); +HRESULT CScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::DbgSendScripts(IWmeDebugClient *Client) { +HRESULT CScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables - _globals->DbgSendVariables(Client, WME_DBGVAR_GLOBAL, NULL, 0); + _globals->DbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); // process normal scripts first for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->DbgSendScript(Client); + _scripts[i]->DbgSendScript(client); } // and threads later for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->DbgSendScript(Client); + _scripts[i]->DbgSendScript(client); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::addBreakpoint(const char *ScriptFilename, int Line) { +HRESULT CScEngine::addBreakpoint(const char *scriptFilename, int line) { if (!Game->getDebugMgr()->_enabled) return S_OK; - CScBreakpoint *Bp = NULL; + CScBreakpoint *bp = NULL; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { - Bp = _breakpoints[i]; + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + bp = _breakpoints[i]; break; } } - if (Bp == NULL) { - Bp = new CScBreakpoint(ScriptFilename); - _breakpoints.Add(Bp); + if (bp == NULL) { + bp = new CScBreakpoint(scriptFilename); + _breakpoints.Add(bp); } - for (int i = 0; i < Bp->_lines.GetSize(); i++) { - if (Bp->_lines[i] == Line) return S_OK; + for (int i = 0; i < bp->_lines.GetSize(); i++) { + if (bp->_lines[i] == line) return S_OK; } - Bp->_lines.Add(Line); + bp->_lines.Add(line); // refresh changes - RefreshScriptBreakpoints(); + refreshScriptBreakpoints(); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::removeBreakpoint(const char *ScriptFilename, int Line) { +HRESULT CScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (!Game->getDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { - if (_breakpoints[i]->_lines[j] == Line) { + if (_breakpoints[i]->_lines[j] == line) { _breakpoints[i]->_lines.RemoveAt(j); if (_breakpoints[i]->_lines.GetSize() == 0) { delete _breakpoints[i]; _breakpoints.RemoveAt(i); } // refresh changes - RefreshScriptBreakpoints(); + refreshScriptBreakpoints(); return S_OK; } @@ -725,17 +723,17 @@ HRESULT CScEngine::removeBreakpoint(const char *ScriptFilename, int Line) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RefreshScriptBreakpoints() { +HRESULT CScEngine::refreshScriptBreakpoints() { if (!Game->getDebugMgr()->_enabled) return S_OK; for (int i = 0; i < _scripts.GetSize(); i++) { - RefreshScriptBreakpoints(_scripts[i]); + refreshScriptBreakpoints(_scripts[i]); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *script) { +HRESULT CScEngine::refreshScriptBreakpoints(CScScript *script) { if (!Game->getDebugMgr()->_enabled) return S_OK; if (!script || !script->_filename) return E_FAIL; @@ -752,48 +750,48 @@ HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::SaveBreakpoints() { +HRESULT CScEngine::saveBreakpoints() { if (!Game->getDebugMgr()->_enabled) return S_OK; - char Text[512]; - char Key[100]; + char text[512]; + char key[100]; - int Count = 0; + int count = 0; for (int i = 0; i < _breakpoints.GetSize(); i++) { for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { - Count++; - sprintf(Key, "Breakpoint%d", Count); - sprintf(Text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + count++; + sprintf(key, "Breakpoint%d", count); + sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - Game->_registry->writeString("Debug", Key, Text); + Game->_registry->writeString("Debug", key, text); } } - Game->_registry->writeInt("Debug", "NumBreakpoints", Count); + Game->_registry->writeInt("Debug", "NumBreakpoints", count); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::LoadBreakpoints() { +HRESULT CScEngine::loadBreakpoints() { if (!Game->getDebugMgr()->_enabled) return S_OK; - char Key[100]; + char key[100]; - int Count = Game->_registry->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= Count; i++) { + int count = Game->_registry->readInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= count; i++) { /* uint32 BufSize = 512; */ - sprintf(Key, "Breakpoint%d", i); - AnsiString breakpoint = Game->_registry->readString("Debug", Key, ""); + sprintf(key, "Breakpoint%d", i); + AnsiString breakpoint = Game->_registry->readString("Debug", key, ""); - char *Path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *Line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); - if (Path != NULL && Line != NULL) addBreakpoint(Path, atoi(Line)); - delete[] Path; - delete[] Line; - Path = NULL; - Line = NULL; + if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + delete[] path; + delete[] line; + path = NULL; + line = NULL; } return S_OK; @@ -801,17 +799,17 @@ HRESULT CScEngine::LoadBreakpoints() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::AddScriptTime(const char *filename, uint32 Time) { +void CScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) return; AnsiString fileName = filename; StringUtil::toLowerCase(fileName); - _scriptTimes[fileName] += Time; + _scriptTimes[fileName] += time; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::EnableProfiling() { +void CScEngine::enableProfiling() { if (_isProfiling) return; // destroy old data, if any @@ -823,16 +821,16 @@ void CScEngine::EnableProfiling() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::DisableProfiling() { +void CScEngine::disableProfiling() { if (!_isProfiling) return; - DumpStats(); + dumpStats(); _isProfiling = false; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::DumpStats() { +void CScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); /* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 91644052bb..d49e474ea8 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -38,15 +38,15 @@ namespace WinterMute { -typedef byte *(*DLL_COMPILE_BUFFER)(byte *Buffer, char *Source, uint32 BufferSize, uint32 *CompiledSize); -typedef byte *(*DLL_COMPILE_FILE)(char *Filename, uint32 *CompiledSize); -typedef void (*DLL_RELEASE_BUFFER)(unsigned char *Buffer); +typedef byte *(*DLL_COMPILE_BUFFER)(byte *buffer, char *source, uint32 bufferSize, uint32 *compiledSize); +typedef byte *(*DLL_COMPILE_FILE)(char *filename, uint32 *compiledSize); +typedef void (*DLL_RELEASE_BUFFER)(unsigned char *buffer); typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); typedef int (*DLL_DEFINE_FUNCTION)(const char *name); /* Was non-const, changed to silence warnings */ typedef int (*DLL_DEFINE_VARIABLE)(const char *name); /* Was non-const, changed to silence warnings */ -typedef void (*COMPILE_ERROR_CALLBACK)(int Line, char *Text , void *Data); -typedef void (*PARSE_ELEMENT_CALLBACK)(int Line, int Type, void *ElementData, void *Data); +typedef void (*COMPILE_ERROR_CALLBACK)(int line, char *text , void *data); +typedef void (*PARSE_ELEMENT_CALLBACK)(int line, int type, void *elementData, void *data); #define MAX_CACHED_SCRIPTS 20 class CScScript; @@ -57,11 +57,11 @@ class CScEngine : public CBBase { public: class CScCachedScript { public: - CScCachedScript(const char *filename, byte *Buffer, uint32 Size) { + CScCachedScript(const char *filename, byte *buffer, uint32 size) { _timestamp = CBPlatform::GetTime(); - _buffer = new byte[Size]; - if (_buffer) memcpy(_buffer, Buffer, Size); - _size = Size; + _buffer = new byte[size]; + if (_buffer) memcpy(_buffer, buffer, size); + _size = size; _filename = filename; }; @@ -93,22 +93,22 @@ public: public: - HRESULT DbgSendScripts(IWmeDebugClient *Client); + HRESULT dbgSendScripts(IWmeDebugClient *client); CBArray _breakpoints; - HRESULT addBreakpoint(const char *ScriptFilename, int Line); - HRESULT removeBreakpoint(const char *ScriptFilename, int Line); - HRESULT RefreshScriptBreakpoints(); - HRESULT RefreshScriptBreakpoints(CScScript *script); - HRESULT SaveBreakpoints(); - HRESULT LoadBreakpoints(); - - HRESULT ClearGlobals(bool IncludingNatives = false); - HRESULT TickUnbreakable(); - HRESULT RemoveFinishedScripts(); - bool IsValidScript(CScScript *script); - void SetCompileErrorCallback(COMPILE_ERROR_CALLBACK Callback, void *Data); - void SetParseElementCallback(PARSE_ELEMENT_CALLBACK Callback, void *Data); + HRESULT addBreakpoint(const char *scriptFilename, int line); + HRESULT removeBreakpoint(const char *scriptFilename, int line); + HRESULT refreshScriptBreakpoints(); + HRESULT refreshScriptBreakpoints(CScScript *script); + HRESULT saveBreakpoints(); + HRESULT loadBreakpoints(); + + HRESULT clearGlobals(bool includingNatives = false); + HRESULT tickUnbreakable(); + HRESULT removeFinishedScripts(); + bool isValidScript(CScScript *script); + void setCompileErrorCallback(COMPILE_ERROR_CALLBACK callback, void *data); + void setParseElementCallback(PARSE_ELEMENT_CALLBACK callback, void *data); COMPILE_ERROR_CALLBACK _compileErrorCallback; void *_compileErrorCallbackData; @@ -116,30 +116,30 @@ public: PARSE_ELEMENT_CALLBACK _parseElementCallback; void *_parseElementCallbackData; - HRESULT SetFileToCompile(const char *filename); + HRESULT setFileToCompile(const char *filename); char *_fileToCompile; CScScript *_currentScript; - HRESULT ResumeAll(); - HRESULT PauseAll(); + HRESULT resumeAll(); + HRESULT pauseAll(); void editorCleanup(); - HRESULT ResetObject(CBObject *Object); - HRESULT ResetScript(CScScript *script); - HRESULT EmptyScriptCache(); - byte *GetCompiledScript(const char *filename, uint32 *OutSize, bool IgnoreCache = false); + HRESULT resetObject(CBObject *Object); + HRESULT resetScript(CScScript *script); + HRESULT emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) HRESULT cleanup(); - int GetNumScripts(int *Running = NULL, int *Waiting = NULL, int *Persistent = NULL); - HRESULT Tick(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + HRESULT tick(); CScValue *_globals; - CScScript *RunScript(const char *filename, CBScriptHolder *Owner = NULL); + CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); bool _compilerAvailable; HINSTANCE _compilerDLL; CScEngine(CBGame *inGame); virtual ~CScEngine(); - static void WINAPI AddError(void *Data, int Line, char *Text); - static byte *WINAPI loadFile(void *Data, char *Filename, uint32 *Size); - static void WINAPI CloseFile(void *Data, byte *Buffer); - static void WINAPI ParseElement(void *Data, int Line, int Type, void *ElementData); + static void addError(void *data, int line, char *text); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); DLL_COMPILE_BUFFER ExtCompileBuffer; DLL_COMPILE_FILE ExtCompileFile; DLL_RELEASE_BUFFER ExtReleaseBuffer; @@ -149,14 +149,14 @@ public: CBArray _scripts; - void EnableProfiling(); - void DisableProfiling(); - bool IsProfiling() { + void enableProfiling(); + void disableProfiling(); + bool isProfiling() { return _isProfiling; } - void AddScriptTime(const char *filename, uint32 Time); - void DumpStats(); + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); private: diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 397ebe4c24..58b590744a 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -154,7 +154,7 @@ HRESULT CScScript::InitScript() { _currentLine = 0; // init breakpoints - _engine->RefreshScriptBreakpoints(this); + _engine->refreshScriptBreakpoints(this); // ready to rumble... @@ -1124,7 +1124,7 @@ HRESULT CScScript::WaitFor(CBObject *Object) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::WaitForExclusive(CBObject *Object) { - _engine->ResetObject(Object); + _engine->resetObject(Object); return WaitFor(Object); } @@ -1619,7 +1619,7 @@ bool CScScript::dbgGetTracingMode() { ////////////////////////////////////////////////////////////////////////// void CScScript::afterLoad() { if (_buffer == NULL) { - byte *buffer = _engine->GetCompiledScript(_filename, &_bufferSize); + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); if (!buffer) { Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); _state = SCRIPT_ERROR; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 65e997f0bb..4d56b3c69e 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -201,7 +201,7 @@ int WinterMuteEngine::init() { _game->initialize2(); _game->getDebugMgr()->onGameInit(); - _game->_scEngine->LoadBreakpoints(); + _game->_scEngine->loadBreakpoints(); -- cgit v1.2.3 From fa3868518d1769353ccf335b7435a9c7a90154f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:11:20 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in ScScript --- engines/wintermute/Ad/AdActor.cpp | 10 +- engines/wintermute/Ad/AdEntity.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 10 +- engines/wintermute/Ad/AdItem.cpp | 6 +- engines/wintermute/Ad/AdObject.cpp | 16 +- engines/wintermute/Ad/AdScene.cpp | 8 +- engines/wintermute/Ad/AdTalkHolder.cpp | 6 +- engines/wintermute/Base/BFrame.cpp | 6 +- engines/wintermute/Base/BGame.cpp | 20 +- engines/wintermute/Base/BScriptHolder.cpp | 4 +- engines/wintermute/Base/BScriptable.cpp | 2 +- engines/wintermute/Base/BSprite.cpp | 4 +- engines/wintermute/Base/scriptables/SXFile.cpp | 42 +-- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 4 +- engines/wintermute/Base/scriptables/SXStore.cpp | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 26 +- engines/wintermute/Base/scriptables/ScScript.cpp | 357 +++++++++++---------- engines/wintermute/Base/scriptables/ScScript.h | 60 ++-- engines/wintermute/UI/UIWindow.cpp | 4 +- 19 files changed, 301 insertions(+), 290 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index d4d41c0fa6..821c66f6fc 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -859,7 +859,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int X = stack->pop()->getInt(); int Y = stack->pop()->getInt(); goTo(X, Y); - if (strcmp(name, "GoToAsync") != 0) script->WaitForExclusive(this); + if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); return S_OK; } @@ -871,20 +871,20 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); CScValue *Val = stack->pop(); if (!Val->isNative()) { - script->RuntimeError("actor.%s method accepts an entity refrence only", name); + script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return S_OK; } CAdObject *Obj = (CAdObject *)Val->getNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { - script->RuntimeError("actor.%s method accepts an entity refrence only", name); + script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return S_OK; } CAdEntity *Ent = (CAdEntity *)Obj; if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(name, "GoToObjectAsync") != 0) script->WaitForExclusive(this); + if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); return S_OK; } @@ -908,7 +908,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (dir >= 0 && dir < NUM_DIRECTIONS) { turnTo((TDirection)dir); - if (strcmp(name, "TurnToAsync") != 0) script->WaitForExclusive(this); + if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); } stack->pushNULL(); return S_OK; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 4686e655ce..d839dfec3b 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -655,7 +655,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; stack->pushBool(true); } else { - script->RuntimeError("Entity.PlayTheora - error playing video '%s'", filename); + script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); stack->pushBool(false); } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 62c2def022..d6485f5cd4 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -487,7 +487,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _responseBox->_responses.Add(res); } } else { - script->RuntimeError("Game.AddResponse: response box is not defined"); + script->runtimeError("Game.AddResponse: response box is not defined"); } stack->pushNULL(); @@ -541,11 +541,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _responseBox->createButtons(); _responseBox->_waitingScript = script; - script->WaitForExclusive(_responseBox); + script->waitForExclusive(_responseBox); _state = GAME_SEMI_FROZEN; _stateEx = GAME_WAITING_RESPONSE; } else { - script->RuntimeError("Game.GetResponse: response box is not defined"); + script->runtimeError("Game.GetResponse: response box is not defined"); stack->pushNULL(); } return S_OK; @@ -561,7 +561,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _responseBox->weedResponses(); stack->pushInt(_responseBox->_responses.GetSize()); } else { - script->RuntimeError("Game.GetNumResponses: response box is not defined"); + script->runtimeError("Game.GetNumResponses: response box is not defined"); stack->pushNULL(); } return S_OK; @@ -663,7 +663,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } } } - } else script->RuntimeError("Game.IsItemTaken: item name expected"); + } else script->runtimeError("Game.IsItemTaken: item name expected"); stack->pushBool(false); return S_OK; diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 36daeefd91..c05e18daf1 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -447,7 +447,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetHoverSprite failed for file '%s'", filename); + script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); } else { _spriteHover = spr; if (setCurrent) _currentSprite = _spriteHover; @@ -490,7 +490,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetNormalCursor failed for file '%s'", filename); + script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); } else { _cursorNormal = spr; stack->pushBool(true); @@ -533,7 +533,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this CBSprite *spr = new CBSprite(Game); if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("Item.SetHoverCursor failed for file '%s'", filename); + script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); } else { _cursorHover = spr; stack->pushBool(true); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 2fa7df10a2..cdb84a35da 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -196,7 +196,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); if (FAILED(playAnim(stack->pop()->getString()))) stack->pushBool(false); else { - if (strcmp(name, "PlayAnimAsync") != 0) script->WaitFor(this); + if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); stack->pushBool(true); } return S_OK; @@ -273,7 +273,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); talk(text, sound, duration, stances, (TTextAlign)align); - if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this); + if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); return S_OK; @@ -360,13 +360,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *itemName = val->getString(); val = stack->pop(); const char *insertAfter = val->isNULL() ? NULL : val->getString(); - if (FAILED(_inventory->insertItem(itemName, insertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", itemName); + if (FAILED(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); else { // hide associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(itemName, false); } - } else script->RuntimeError("TakeItem: item name expected"); + } else script->runtimeError("TakeItem: item name expected"); stack->pushNULL(); return S_OK; @@ -385,12 +385,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (!val->isNULL()) { - if (FAILED(_inventory->removeItem(val->getString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->getString()); + if (FAILED(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true); } - } else script->RuntimeError("DropItem: item name expected"); + } else script->runtimeError("DropItem: item name expected"); stack->pushNULL(); return S_OK; @@ -442,7 +442,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th return S_OK; } } - } else script->RuntimeError("HasItem: item name expected"); + } else script->runtimeError("HasItem: item name expected"); stack->pushBool(false); return S_OK; @@ -493,7 +493,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (FAILED(res = ent->loadFile(filename))) { delete ent; ent = NULL; - script->RuntimeError("AddAttachment() failed loading entity '%s'", filename); + script->runtimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { Game->registerObject(ent); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 7415de6add..2e99b93e88 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -1331,7 +1331,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } else { scrollTo(val1->getInt(), val2->getInt()); } - if (strcmp(name, "ScrollTo") == 0) script->WaitForExclusive(this); + if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); stack->pushNULL(); return S_OK; } @@ -1513,7 +1513,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi byte alpha = stack->pop()->getInt(0xFF); _fader->fadeOut(DRGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); stack->pushNULL(); return S_OK; @@ -1531,7 +1531,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi byte alpha = stack->pop()->getInt(0xFF); _fader->fadeIn(DRGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); stack->pushNULL(); return S_OK; @@ -1650,7 +1650,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (toDelete->_main) { - script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer"); + script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); stack->pushBool(false); return S_OK; } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 9d4c4c8e8b..5516117004 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -142,7 +142,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack const char *filename = val->getString(); CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { - script->RuntimeError("SetSprite method failed for file '%s'", filename); + script->runtimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); } else { _sprite = spr; @@ -187,7 +187,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("AddTalkSprite method failed for file '%s'", filename); + script->runtimeError("AddTalkSprite method failed for file '%s'", filename); } else { if (Ex) _talkSpritesEx.Add(spr); else _talkSprites.Add(spr); @@ -258,7 +258,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack CBSprite *spr = new CBSprite(Game, this); if (!spr || FAILED(spr->loadFile(filename))) { stack->pushBool(false); - script->RuntimeError("SetTalkSprite method failed for file '%s'", filename); + script->runtimeError("SetTalkSprite method failed for file '%s'", filename); } else { // delete current diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 58b0b5384b..65d2d55f6a 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -439,7 +439,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); int index = stack->pop()->getInt(-1); if (index < 0 || index >= _subframes.GetSize()) { - script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else stack->pushNative(_subframes[index], true); @@ -455,7 +455,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (val->isInt()) { int index = val->getInt(-1); if (index < 0 || index >= _subframes.GetSize()) { - script->RuntimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { CBSubFrame *sub = (CBSubFrame *)val->getNative(); @@ -522,7 +522,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); int index = stack->pop()->getInt(-1); if (index < 0 || index >= _applyEvent.GetSize()) { - script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", index); + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else stack->pushString(_applyEvent[index]); return S_OK; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index d34c526a23..2117e18f8b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1315,7 +1315,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool swap = stack->pop()->getBool(true); if (_musicCrossfadeRunning) { - script->RuntimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); stack->pushBool(false); return S_OK; } @@ -1425,7 +1425,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (SUCCEEDED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { stack->pushBool(true); - script->Sleep(0); + script->sleep(0); } else stack->pushBool(false); } else stack->pushBool(false); @@ -1466,7 +1466,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _theoraPlayer->_dontDropFrames = !dropFrames; if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); - script->Sleep(0); + script->sleep(0); } else stack->pushBool(false); } else { stack->pushBool(false); @@ -1562,7 +1562,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _scheduledLoadSlot = stack->pop()->getInt(); _loading = true; stack->pushBool(false); - script->Sleep(0); + script->sleep(0); return S_OK; } @@ -1764,7 +1764,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); _fader->fadeOut(DRGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->WaitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); stack->pushNULL(); return S_OK; @@ -1784,7 +1784,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(DRGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->WaitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); stack->pushNULL(); return S_OK; @@ -3012,7 +3012,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "Sleep") == 0) { stack->correctParams(1); - script->Sleep((uint32)stack->pop()->getInt()); + script->sleep((uint32)stack->pop()->getInt()); stack->pushNULL(); } @@ -3023,7 +3023,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->WaitForExclusive((CBObject *)obj); + if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); stack->pushNULL(); } @@ -3161,7 +3161,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS if (Game->getDebugMgr()->_enabled) { Game->getDebugMgr()->onScriptHitBreakpoint(script); - script->Sleep(0); + script->sleep(0); } stack->pushNULL(); } @@ -3208,7 +3208,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// // failure else { - script->RuntimeError("Call to undefined function '%s'. Ignored.", name); + script->runtimeError("Call to undefined function '%s'. Ignored.", name); stack->correctParams(0); stack->pushNULL(); } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index f07e2575dd..2049287be5 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -86,7 +86,7 @@ HRESULT CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { HRESULT ret = E_FAIL; for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->InvokeEventHandler(eventName, unbreakable); + CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { //_scripts.Add(handler); numHandlers++; @@ -433,7 +433,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { CScScript *thread = new CScScript(Game, _scripts[i]->_engine); if (thread) { - HRESULT ret = thread->CreateMethodThread(_scripts[i], methodName); + HRESULT ret = thread->createMethodThread(_scripts[i], methodName); if (SUCCEEDED(ret)) { _scripts[i]->_engine->_scripts.Add(thread); Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 16470ebf3c..0e0ca7d45b 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -65,7 +65,7 @@ HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack /* stack->correctParams(0); stack->pushNULL(); - script->RuntimeError("Call to undefined method '%s'.", name); + script->runtimeError("Call to undefined method '%s'.", name); return S_OK; */ diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 79d35d948b..0b12e2cb5a 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -515,7 +515,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); int Index = stack->pop()->getInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { - script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); } else stack->pushNative(_frames[Index], true); return S_OK; @@ -530,7 +530,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Val->isInt()) { int Index = Val->getInt(-1); if (Index < 0 || Index >= _frames.GetSize()) { - script->RuntimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { CBFrame *Frame = (CBFrame *)Val->getNative(); diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index dab7786e66..34d133e330 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -126,13 +126,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this Close(); _mode = stack->pop()->getInt(1); if (_mode < 1 || _mode > 3) { - script->RuntimeError("File.%s: invalid access mode. Setting read mode.", name); + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); _mode = 1; } if (_mode == 1) { _readFile = Game->_fileManager->openFile(_filename); if (!_readFile) { - //script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); Close(); } else _textMode = strcmp(name, "OpenAsText") == 0; } else { @@ -145,7 +145,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } if (!_writeFile) { - //script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); Close(); } else _textMode = strcmp(name, "OpenAsText") == 0; } @@ -172,7 +172,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "SetPosition") == 0) { stack->correctParams(1); if (_mode == 0) { - script->RuntimeError("File.%s: File is not open", name); + script->runtimeError("File.%s: File is not open", name); stack->pushBool(false); } else { int Pos = stack->pop()->getInt(); @@ -210,7 +210,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadLine") == 0) { stack->correctParams(0); if (!_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open in text mode.", name); + script->runtimeError("File.%s: File must be open in text mode.", name); stack->pushNULL(); return S_OK; } @@ -261,7 +261,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this int TextLen = stack->pop()->getInt(); if (!_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open in text mode.", name); + script->runtimeError("File.%s: File must be open in text mode.", name); stack->pushNULL(); return S_OK; } @@ -307,7 +307,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); const char *Line = stack->pop()->getString(); if (!_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in text mode.", name); + script->runtimeError("File.%s: File must be open for writing in text mode.", name); stack->pushBool(false); return S_OK; } @@ -328,7 +328,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadBool") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -345,7 +345,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadByte") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -362,7 +362,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadShort") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -379,7 +379,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -396,7 +396,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadFloat") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -413,7 +413,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadDouble") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -430,7 +430,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "ReadString") == 0) { stack->correctParams(0); if (_textMode || !_readFile) { - script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); return S_OK; } @@ -457,7 +457,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this bool Val = stack->pop()->getBool(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -475,7 +475,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this byte Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -493,7 +493,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this short Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -511,7 +511,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this int Val = stack->pop()->getInt(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -529,7 +529,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this float Val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -547,7 +547,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this double Val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } @@ -565,7 +565,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this const char *Val = stack->pop()->getString(); if (_textMode || !_writeFile) { - script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 0afdf08450..8abf336f55 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -104,13 +104,13 @@ HRESULT CSXMemBuffer::Resize(int NewSize) { ////////////////////////////////////////////////////////////////////////// bool CSXMemBuffer::CheckBounds(CScScript *script, int start, int length) { if (_buffer == NULL) { - script->RuntimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } if (_size == 0) return true; if (start < 0 || length == 0 || start + length > _size) { - script->RuntimeError("Set/Get method call is out of bounds"); + script->runtimeError("Set/Get method call is out of bounds"); return false; } else return true; } diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 2996da4b79..30ff22f6dc 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -419,7 +419,7 @@ bool CSXStore::Purchase(CScScript *script, const char *productId) { } } #endif - script->RuntimeError("Store.Purchase() - '%s' is not a valid product id", productId); + script->runtimeError("Store.Purchase() - '%s' is not a valid product id", productId); return false; } @@ -437,7 +437,7 @@ bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { } } #endif - script->RuntimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); + script->runtimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); return false; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 8cae017381..414b4a56c3 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -242,7 +242,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { // add new script CScScript *script = new CScScript(Game, this); - HRESULT ret = script->Create(filename, compBuffer, compSize, owner); + HRESULT ret = script->create(filename, compBuffer, compSize, owner); if (FAILED(ret)) { Game->LOG(ret, "Error running script '%s'...", filename); delete script; @@ -388,16 +388,16 @@ HRESULT CScEngine::tick() { if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (Game->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->Run(); + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); } else _scripts[i]->finish(); break; } case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->Run(); + if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->run(); } else { - if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->Run(); + if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->run(); } break; } @@ -407,12 +407,12 @@ HRESULT CScEngine::tick() { // fake return value _scripts[i]->_stack->pushNULL(); _scripts[i]->_waitScript = NULL; - _scripts[i]->Run(); + _scripts[i]->run(); } else { if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { // copy return value _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); - _scripts[i]->Run(); + _scripts[i]->run(); _scripts[i]->_waitScript->finish(); _scripts[i]->_waitScript = NULL; } @@ -437,7 +437,7 @@ HRESULT CScEngine::tick() { uint32 StartTime = CBPlatform::GetTime(); while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); + _scripts[i]->executeInstruction(); } if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } @@ -450,7 +450,7 @@ HRESULT CScEngine::tick() { while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); + _scripts[i]->executeInstruction(); } if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); } @@ -471,7 +471,7 @@ HRESULT CScEngine::tickUnbreakable() { while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; - _scripts[i]->ExecuteInstruction(); + _scripts[i]->executeInstruction(); } _scripts[i]->finish(); _currentScript = NULL; @@ -596,7 +596,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::pauseAll() { for (int i = 0; i < _scripts.GetSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->Pause(); + if (_scripts[i] != _currentScript) _scripts[i]->pause(); } return S_OK; @@ -606,7 +606,7 @@ HRESULT CScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::resumeAll() { for (int i = 0; i < _scripts.GetSize(); i++) - _scripts[i]->Resume(); + _scripts[i]->resume(); return S_OK; } @@ -658,13 +658,13 @@ HRESULT CScEngine::dbgSendScripts(IWmeDebugClient *client) { // process normal scripts first for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->DbgSendScript(client); + _scripts[i]->dbgSendScript(client); } // and threads later for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->DbgSendScript(client); + _scripts[i]->dbgSendScript(client); } return S_OK; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 58b590744a..42aacb87e4 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -118,7 +118,7 @@ void CScScript::readHeader() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::InitScript() { +HRESULT CScScript::initScript() { if (!_scriptStream) { _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); } @@ -136,7 +136,7 @@ HRESULT CScScript::InitScript() { return E_FAIL; } - InitTables(); + initTables(); // init stacks _scopeStack = new CScStack(Game); @@ -165,39 +165,39 @@ HRESULT CScScript::InitScript() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::InitTables() { +HRESULT CScScript::initTables() { uint32 OrigIP = _iP; readHeader(); // load symbol table _iP = _header.symbol_table; - _numSymbols = GetDWORD(); + _numSymbols = getDWORD(); _symbols = new char*[_numSymbols]; for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = GetDWORD(); - _symbols[index] = GetString(); + uint32 index = getDWORD(); + _symbols[index] = getString(); } // load functions table _iP = _header.func_table; - _numFunctions = GetDWORD(); + _numFunctions = getDWORD(); _functions = new TFunctionPos[_numFunctions]; for (uint32 i = 0; i < _numFunctions; i++) { - _functions[i].pos = GetDWORD(); - _functions[i].name = GetString(); + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); } // load events table _iP = _header.event_table; - _numEvents = GetDWORD(); + _numEvents = getDWORD(); _events = new TEventPos[_numEvents]; for (uint32 i = 0; i < _numEvents; i++) { - _events[i].pos = GetDWORD(); - _events[i].name = GetString(); + _events[i].pos = getDWORD(); + _events[i].name = getString(); } @@ -205,18 +205,18 @@ HRESULT CScScript::InitTables() { if (_header.version >= 0x0101) { _iP = _header.externals_table; - _numExternals = GetDWORD(); + _numExternals = getDWORD(); _externals = new TExternalFunction[_numExternals]; for (uint32 i = 0; i < _numExternals; i++) { - _externals[i].dll_name = GetString(); - _externals[i].name = GetString(); - _externals[i].call_type = (TCallType)GetDWORD(); - _externals[i].returns = (TExternalType)GetDWORD(); - _externals[i].nu_params = GetDWORD(); + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); if (_externals[i].nu_params > 0) { _externals[i].params = new TExternalType[_externals[i].nu_params]; for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)GetDWORD(); + _externals[i].params[j] = (TExternalType)getDWORD(); } } } @@ -225,11 +225,11 @@ HRESULT CScScript::InitTables() { // load method table _iP = _header.method_table; - _numMethods = GetDWORD(); + _numMethods = getDWORD(); _methods = new TMethodPos[_numMethods]; for (uint32 i = 0; i < _numMethods; i++) { - _methods[i].pos = GetDWORD(); - _methods[i].name = GetString(); + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); } @@ -240,7 +240,7 @@ HRESULT CScScript::InitTables() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Create(const char *filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner) { +HRESULT CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { cleanup(); _thread = false; @@ -252,62 +252,62 @@ HRESULT CScScript::Create(const char *filename, byte *Buffer, uint32 Size, CBScr _filename = new char[strlen(filename) + 1]; if (_filename) strcpy(_filename, filename); - _buffer = new byte [Size]; + _buffer = new byte [size]; if (!_buffer) return E_FAIL; - memcpy(_buffer, Buffer, Size); + memcpy(_buffer, buffer, size); - _bufferSize = Size; + _bufferSize = size; - HRESULT res = InitScript(); + HRESULT res = initScript(); if (FAILED(res)) return res; // establish global variables table _globals = new CScValue(Game); - _owner = Owner; + _owner = owner; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char *EventName) { +HRESULT CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { cleanup(); _thread = true; _methodThread = false; - _threadEvent = new char[strlen(EventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, EventName); + _threadEvent = new char[strlen(eventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, eventName); // copy filename - _filename = new char[strlen(Original->_filename) + 1]; - if (_filename) strcpy(_filename, Original->_filename); + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); // copy buffer - _buffer = new byte [Original->_bufferSize]; + _buffer = new byte [original->_bufferSize]; if (!_buffer) return E_FAIL; - memcpy(_buffer, Original->_buffer, Original->_bufferSize); - _bufferSize = Original->_bufferSize; + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; // initialize - HRESULT res = InitScript(); + HRESULT res = initScript(); if (FAILED(res)) return res; // copy globals - _globals = Original->_globals; + _globals = original->_globals; // skip to the beginning of the event - _iP = InitIP; + _iP = initIP; _scriptStream->seek(_iP); - _timeSlice = Original->_timeSlice; - _freezable = Original->_freezable; - _owner = Original->_owner; + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; - _engine = Original->_engine; - _parentScript = Original; + _engine = original->_engine; + _parentScript = original; return S_OK; } @@ -316,44 +316,44 @@ HRESULT CScScript::CreateThread(CScScript *Original, uint32 InitIP, const char * ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CreateMethodThread(CScScript *Original, const char *MethodName) { - uint32 IP = Original->GetMethodPos(MethodName); - if (IP == 0) return E_FAIL; +HRESULT CScScript::createMethodThread(CScScript *original, const char *methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) return E_FAIL; cleanup(); _thread = true; _methodThread = true; - _threadEvent = new char[strlen(MethodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, MethodName); + _threadEvent = new char[strlen(methodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, methodName); // copy filename - _filename = new char[strlen(Original->_filename) + 1]; - if (_filename) strcpy(_filename, Original->_filename); + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); // copy buffer - _buffer = new byte [Original->_bufferSize]; + _buffer = new byte [original->_bufferSize]; if (!_buffer) return E_FAIL; - memcpy(_buffer, Original->_buffer, Original->_bufferSize); - _bufferSize = Original->_bufferSize; + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; // initialize - HRESULT res = InitScript(); + HRESULT res = initScript(); if (FAILED(res)) return res; // copy globals - _globals = Original->_globals; + _globals = original->_globals; // skip to the beginning of the event - _iP = IP; + _iP = ip; - _timeSlice = Original->_timeSlice; - _freezable = Original->_freezable; - _owner = Original->_owner; + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; - _engine = Original->_engine; - _parentScript = Original; + _engine = original->_engine; + _parentScript = original; return S_OK; } @@ -374,16 +374,16 @@ void CScScript::cleanup() { if (_globals && !_thread) delete _globals; _globals = NULL; - if (_scopeStack) delete _scopeStack; + delete _scopeStack; _scopeStack = NULL; - if (_callStack) delete _callStack; + delete _callStack; _callStack = NULL; - if (_thisStack) delete _thisStack; + delete _thisStack; _thisStack = NULL; - if (_stack) delete _stack; + delete _stack; _stack = NULL; if (_functions) delete [] _functions; @@ -430,7 +430,7 @@ void CScScript::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetDWORD() { +uint32 CScScript::getDWORD() { _scriptStream->seek(_iP); uint32 ret = _scriptStream->readUint32LE(); _iP += sizeof(uint32); @@ -439,7 +439,7 @@ uint32 CScScript::GetDWORD() { } ////////////////////////////////////////////////////////////////////////// -double CScScript::GetFloat() { +double CScScript::getFloat() { _scriptStream->seek((int32)_iP); byte buffer[8]; _scriptStream->read(buffer, 8); @@ -459,7 +459,7 @@ double CScScript::GetFloat() { ////////////////////////////////////////////////////////////////////////// -char *CScScript::GetString() { +char *CScScript::getString() { char *ret = (char *)(_buffer + _iP); while (*(char *)(_buffer + _iP) != '\0') _iP++; _iP++; // string terminator @@ -470,7 +470,7 @@ char *CScScript::GetString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::ExecuteInstruction() { +HRESULT CScScript::executeInstruction() { HRESULT ret = S_OK; uint32 dw; @@ -482,12 +482,12 @@ HRESULT CScScript::ExecuteInstruction() { CScValue *op1; CScValue *op2; - uint32 inst = GetDWORD(); + uint32 inst = getDWORD(); switch (inst) { case II_DEF_VAR: _operand->setNULL(); - dw = GetDWORD(); + dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); if (Game->getDebugMgr()->_enabled) @@ -502,7 +502,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { - dw = GetDWORD(); + dw = getDWORD(); /* char *Temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist if (!_engine->_globals->propExists(_symbols[dw])) { @@ -541,7 +541,7 @@ HRESULT CScScript::ExecuteInstruction() { case II_CALL: - dw = GetDWORD(); + dw = getDWORD(); _operand->setInt(_iP); _callStack->push(_operand); @@ -575,16 +575,16 @@ HRESULT CScScript::ExecuteInstruction() { _waitScript = var->getNative()->invokeMethodThread(MethodName); if (!_waitScript) { _stack->correctParams(0); - RuntimeError("Error invoking method '%s'.", MethodName); + runtimeError("Error invoking method '%s'.", MethodName); _stack->pushNULL(); } else { _state = SCRIPT_WAITING_SCRIPT; - _waitScript->CopyParameters(_stack); + _waitScript->copyParameters(_stack); } } else { // can call methods in unbreakable mode _stack->correctParams(0); - RuntimeError("Cannot call method '%s'. Ignored.", MethodName); + runtimeError("Cannot call method '%s'. Ignored.", MethodName); _stack->pushNULL(); } delete [] MethodName; @@ -617,7 +617,7 @@ HRESULT CScScript::ExecuteInstruction() { if (FAILED(res)) { _stack->correctParams(0); - RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); + runtimeError("Call to undefined method '%s'. Ignored.", MethodName); _stack->pushNULL(); } } @@ -627,11 +627,11 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_EXTERNAL_CALL: { - uint32 SymbolIndex = GetDWORD(); + uint32 SymbolIndex = getDWORD(); - TExternalFunction *f = GetExternal(_symbols[SymbolIndex]); + TExternalFunction *f = getExternal(_symbols[SymbolIndex]); if (f) { - ExternalCall(_stack, _thisStack, f); + externalCall(_stack, _thisStack, f); } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); break; @@ -646,7 +646,7 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_CORRECT_STACK: - dw = GetDWORD(); // params expected + dw = getDWORD(); // params expected _stack->correctParams(dw); break; @@ -660,7 +660,7 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_PUSH_VAR: { - CScValue *var = GetVar(_symbols[GetDWORD()]); + CScValue *var = getVar(_symbols[getDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->setReference(var); _stack->push(_operand); @@ -669,19 +669,19 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_VAR_REF: { - CScValue *var = GetVar(_symbols[GetDWORD()]); + CScValue *var = getVar(_symbols[getDWORD()]); _operand->setReference(var); _stack->push(_operand); break; } case II_POP_VAR: { - char *VarName = _symbols[GetDWORD()]; - CScValue *var = GetVar(VarName); + char *VarName = _symbols[getDWORD()]; + CScValue *var = getVar(VarName); if (var) { CScValue *val = _stack->pop(); if (!val) { - RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); } else { if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; @@ -703,21 +703,21 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_PUSH_INT: - _stack->pushInt((int)GetDWORD()); + _stack->pushInt((int)getDWORD()); break; case II_PUSH_FLOAT: - _stack->pushFloat(GetFloat()); + _stack->pushFloat(getFloat()); break; case II_PUSH_BOOL: - _stack->pushBool(GetDWORD() != 0); + _stack->pushBool(getDWORD() != 0); break; case II_PUSH_STRING: - _stack->pushString(GetString()); + _stack->pushString(getString()); break; case II_PUSH_NULL: @@ -730,7 +730,7 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_PUSH_THIS: - _operand->setReference(GetVar(_symbols[GetDWORD()])); + _operand->setReference(getVar(_symbols[getDWORD()])); _thisStack->push(_operand); break; @@ -753,7 +753,7 @@ HRESULT CScScript::ExecuteInstruction() { CScValue *val = _stack->pop(); if (val == NULL) { - RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); } else var->setProp(str, val); @@ -772,17 +772,17 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_JMP: - _iP = GetDWORD(); + _iP = getDWORD(); break; case II_JMP_FALSE: { - dw = GetDWORD(); + dw = getDWORD(); //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *Val = _stack->pop(); - if (!Val) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { - if (!Val->getBool()) _iP = dw; + if (!val->getBool()) _iP = dw; } break; } @@ -791,7 +791,8 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; strcpy(tempStr, op1->getString()); @@ -810,7 +811,8 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) _operand->setInt(op1->getInt() - op2->getInt()); else _operand->setFloat(op1->getFloat() - op2->getFloat()); @@ -836,7 +838,8 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getFloat() == 0.0f) RuntimeError("Division by zero."); + if (op2->getFloat() == 0.0f) + runtimeError("Division by zero."); if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); else _operand->setFloat(op1->getFloat() / op2->getFloat()); @@ -849,9 +852,11 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getInt() == 0) RuntimeError("Division by zero."); + if (op2->getInt() == 0) + runtimeError("Division by zero."); - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) _operand->setNULL(); + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + _operand->setNULL(); else _operand->setInt(op1->getInt() % op2->getInt()); _stack->push(_operand); @@ -871,7 +876,7 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->setBool(false); } else { _operand->setBool(op1->getBool() && op2->getBool()); @@ -883,7 +888,7 @@ HRESULT CScScript::ExecuteInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { - RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->setBool(false); } else { _operand->setBool(op1->getBool() || op2->getBool()); @@ -1019,21 +1024,21 @@ HRESULT CScScript::ExecuteInstruction() { break; case II_DBG_LINE: { - int NewLine = GetDWORD(); - if (NewLine != _currentLine) { - _currentLine = NewLine; + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; if (Game->getDebugMgr()->_enabled) { Game->getDebugMgr()->onScriptChangeLine(this, _currentLine); for (int i = 0; i < _breakpoints.GetSize(); i++) { if (_breakpoints[i] == _currentLine) { Game->getDebugMgr()->onScriptHitBreakpoint(this); - Sleep(0); + sleep(0); break; } } if (_tracingMode) { Game->getDebugMgr()->onScriptHitBreakpoint(this); - Sleep(0); + sleep(0); break; } } @@ -1054,55 +1059,60 @@ HRESULT CScScript::ExecuteInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetFuncPos(const char *name) { +uint32 CScScript::getFuncPos(const char *name) { for (int i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) return _functions[i].pos; + if (strcmp(name, _functions[i].name) == 0) + return _functions[i].pos; } return 0; } ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetMethodPos(const char *name) { +uint32 CScScript::getMethodPos(const char *name) { for (int i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) return _methods[i].pos; + if (strcmp(name, _methods[i].name) == 0) + return _methods[i].pos; } return 0; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::GetVar(char *name) { +CScValue *CScScript::getVar(char *name) { CScValue *ret = NULL; // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) ret = _scopeStack->getTop()->getProp(name); + if (_scopeStack->getTop()->propExists(name)) + ret = _scopeStack->getTop()->getProp(name); } // script globals if (ret == NULL) { - if (_globals->propExists(name)) ret = _globals->getProp(name); + if (_globals->propExists(name)) + ret = _globals->getProp(name); } // engine globals if (ret == NULL) { - if (_engine->_globals->propExists(name)) ret = _engine->_globals->getProp(name); + if (_engine->_globals->propExists(name)) + ret = _engine->_globals->getProp(name); } if (ret == NULL) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *Val = new CScValue(Game); - CScValue *Scope = _scopeStack->getTop(); - if (Scope) { - Scope->setProp(name, Val); + CScValue *val = new CScValue(Game); + CScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); ret = _scopeStack->getTop()->getProp(name); } else { - _globals->setProp(name, Val); + _globals->setProp(name, val); ret = _globals->getProp(name); } - delete Val; + delete val; } return ret; @@ -1110,38 +1120,38 @@ CScValue *CScScript::GetVar(char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::WaitFor(CBObject *Object) { +HRESULT CScScript::waitFor(CBObject *object) { if (_unbreakable) { - RuntimeError("Script cannot be interrupted."); + runtimeError("Script cannot be interrupted."); return S_OK; } _state = SCRIPT_WAITING; - _waitObject = Object; + _waitObject = object; return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::WaitForExclusive(CBObject *Object) { - _engine->resetObject(Object); - return WaitFor(Object); +HRESULT CScScript::waitForExclusive(CBObject *object) { + _engine->resetObject(object); + return waitFor(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Sleep(uint32 Duration) { +HRESULT CScScript::sleep(uint32 duration) { if (_unbreakable) { - RuntimeError("Script cannot be interrupted."); + runtimeError("Script cannot be interrupted."); return S_OK; } _state = SCRIPT_SLEEPING; if (Game->_state == GAME_FROZEN) { - _waitTime = CBPlatform::GetTime() + Duration; + _waitTime = CBPlatform::GetTime() + duration; _waitFrozen = true; } else { - _waitTime = Game->_timer + Duration; + _waitTime = Game->_timer + duration; _waitFrozen = false; } return S_OK; @@ -1149,10 +1159,10 @@ HRESULT CScScript::Sleep(uint32 Duration) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::finish(bool IncludingThreads) { - if (_state != SCRIPT_FINISHED && IncludingThreads) { +HRESULT CScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; - FinishThreads(); + finishThreads(); } else _state = SCRIPT_FINISHED; @@ -1161,14 +1171,14 @@ HRESULT CScScript::finish(bool IncludingThreads) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Run() { +HRESULT CScScript::run() { _state = SCRIPT_RUNNING; return S_OK; } ////////////////////////////////////////////////////////////////////// -void CScScript::RuntimeError(LPCSTR fmt, ...) { +void CScScript::runtimeError(LPCSTR fmt, ...) { char buff[256]; va_list va; @@ -1205,7 +1215,7 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { _buffer = new byte[_bufferSize]; persistMgr->getBytes(_buffer, _bufferSize); _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - InitTables(); + initTables(); } else { _buffer = NULL; _scriptStream = NULL; @@ -1247,19 +1257,19 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable) { +CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { //if(_state!=SCRIPT_PERSISTENT) return NULL; - uint32 pos = GetEventPos(EventName); + uint32 pos = getEventPos(eventName); if (!pos) return NULL; CScScript *thread = new CScScript(Game, _engine); if (thread) { - HRESULT ret = thread->CreateThread(this, pos, EventName); + HRESULT ret = thread->createThread(this, pos, eventName); if (SUCCEEDED(ret)) { - thread->_unbreakable = Unbreakable; + thread->_unbreakable = unbreakable; _engine->_scripts.Add(thread); - Game->getDebugMgr()->onScriptEventThreadInit(thread, this, EventName); + Game->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); return thread; } else { delete thread; @@ -1271,7 +1281,7 @@ CScScript *CScScript::InvokeEventHandler(const char *EventName, bool Unbreakable ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::GetEventPos(const char *name) { +uint32 CScScript::getEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; } @@ -1280,19 +1290,19 @@ uint32 CScScript::GetEventPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *EventName) { - return GetEventPos(EventName) != 0; +bool CScScript::canHandleEvent(const char *eventName) { + return getEventPos(eventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *MethodName) { - return GetMethodPos(MethodName) != 0; +bool CScScript::canHandleMethod(const char *methodName) { + return getMethodPos(methodName) != 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Pause() { +HRESULT CScScript::pause() { if (_state == SCRIPT_PAUSED) { Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return E_FAIL; @@ -1308,7 +1318,7 @@ HRESULT CScScript::Pause() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::Resume() { +HRESULT CScScript::resume() { if (_state != SCRIPT_PAUSED) return S_OK; _state = _origState; @@ -1317,16 +1327,17 @@ HRESULT CScScript::Resume() { ////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::GetExternal(char *name) { +CScScript::TExternalFunction *CScScript::getExternal(char *name) { for (int i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) return &_externals[i]; + if (strcmp(name, _externals[i].name) == 0) + return &_externals[i]; } return NULL; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *Function) { +HRESULT CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { #ifndef __WIN32__ @@ -1525,7 +1536,7 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::CopyParameters(CScStack *stack) { +HRESULT CScScript::copyParameters(CScStack *stack) { int i; int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { @@ -1540,11 +1551,11 @@ HRESULT CScScript::CopyParameters(CScStack *stack) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::FinishThreads() { +HRESULT CScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.GetSize(); i++) { - CScScript *Scr = _engine->_scripts[i]; - if (Scr->_thread && Scr->_state != SCRIPT_FINISHED && Scr->_owner == _owner && scumm_stricmp(Scr->_filename, _filename) == 0) - Scr->finish(true); + CScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + scr->finish(true); } return S_OK; } @@ -1563,19 +1574,19 @@ const char *CScScript::dbgGetFilename() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::DbgSendScript(IWmeDebugClient *Client) { - if (_methodThread) Client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) Client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else Client->onScriptInit(this); +HRESULT CScScript::dbgSendScript(IWmeDebugClient *client) { + if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else client->onScriptInit(this); - return DbgSendVariables(Client); + return dbgSendVariables(client); return S_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::DbgSendVariables(IWmeDebugClient *Client) { +HRESULT CScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals - _globals->DbgSendVariables(Client, WME_DBGVAR_SCRIPT, this, 0); + _globals->DbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); // send scope variables if (_scopeStack->_sP >= 0) { @@ -1599,14 +1610,14 @@ int CScScript::dbgGetNumBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int Index) { - if (Index >= 0 && Index < _breakpoints.GetSize()) return _breakpoints[Index]; +int CScScript::dbgGetBreakpoint(int index) { + if (index >= 0 && index < _breakpoints.GetSize()) return _breakpoints[index]; else return -1; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool IsTracing) { - _tracingMode = IsTracing; +bool CScScript::dbgSetTracingMode(bool isTracing) { + _tracingMode = isTracing; return true; } @@ -1632,7 +1643,7 @@ void CScScript::afterLoad() { delete _scriptStream; _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - InitTables(); + initTables(); } } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 12f9ae518a..9dbc7d4522 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -43,16 +43,16 @@ class CScEngine; class CScStack; class CScScript : public CBBase, public IWmeDebugScript { public: - HRESULT DbgSendScript(IWmeDebugClient *Client); - HRESULT DbgSendVariables(IWmeDebugClient *Client); + HRESULT dbgSendScript(IWmeDebugClient *client); + HRESULT dbgSendVariables(IWmeDebugClient *client); CBArray _breakpoints; bool _tracingMode; CScScript *_parentScript; bool _unbreakable; - HRESULT FinishThreads(); - HRESULT CopyParameters(CScStack *stack); + HRESULT finishThreads(); + HRESULT copyParameters(CScStack *stack); void afterLoad(); @@ -66,31 +66,31 @@ public: CScValue *_operand; CScValue *_reg1; bool _freezable; - HRESULT Resume(); - HRESULT Pause(); - bool canHandleEvent(const char *EventName); - bool canHandleMethod(const char *MethodName); - HRESULT CreateThread(CScScript *Original, uint32 InitIP, const char *EventName); - HRESULT CreateMethodThread(CScScript *Original, const char *MethodName); - CScScript *InvokeEventHandler(const char *EventName, bool Unbreakable = false); + HRESULT resume(); + HRESULT pause(); + bool canHandleEvent(const char *eventName); + bool canHandleMethod(const char *methodName); + HRESULT createThread(CScScript *original, uint32 initIP, const char *eventName); + HRESULT createMethodThread(CScScript *original, const char *methodName); + CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(CScScript, CBBase) - void RuntimeError(LPCSTR fmt, ...); - HRESULT Run(); - HRESULT finish(bool IncludingThreads = false); - HRESULT Sleep(uint32 Duration); - HRESULT WaitForExclusive(CBObject *Object); - HRESULT WaitFor(CBObject *Object); + void runtimeError(LPCSTR fmt, ...); + HRESULT run(); + HRESULT finish(bool includingThreads = false); + HRESULT sleep(uint32 duration); + HRESULT waitForExclusive(CBObject *object); + HRESULT waitFor(CBObject *object); uint32 _waitTime; bool _waitFrozen; CBObject *_waitObject; CScScript *_waitScript; TScriptState _state; TScriptState _origState; - CScValue *GetVar(char *name); - uint32 GetFuncPos(const char *name); - uint32 GetEventPos(const char *name); - uint32 GetMethodPos(const char *name); + CScValue *getVar(char *name); + uint32 getFuncPos(const char *name); + uint32 getEventPos(const char *name); + uint32 getMethodPos(const char *name); typedef struct { uint32 magic; uint32 version; @@ -136,12 +136,12 @@ public: CScValue *_globals; CScEngine *_engine; int _currentLine; - HRESULT ExecuteInstruction(); - char *GetString(); - uint32 GetDWORD(); - double GetFloat(); + HRESULT executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); void cleanup(); - HRESULT Create(const char *filename, byte *Buffer, uint32 Size, CBScriptHolder *Owner); + HRESULT create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); uint32 _iP; private: void readHeader(); @@ -166,11 +166,11 @@ public: bool _methodThread; char *_threadEvent; CBScriptHolder *_owner; - CScScript::TExternalFunction *GetExternal(char *name); - HRESULT ExternalCall(CScStack *Stack, CScStack *ThisStack, CScScript::TExternalFunction *Function); + CScScript::TExternalFunction *getExternal(char *name); + HRESULT externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); private: - HRESULT InitScript(); - HRESULT InitTables(); + HRESULT initScript(); + HRESULT initTables(); // IWmeDebugScript interface implementation diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 0c007f94fb..5d1bf05bfb 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -791,7 +791,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "GoExclusive") == 0) { stack->correctParams(0); goExclusive(); - script->WaitFor(this); + script->waitFor(this); stack->pushNULL(); return S_OK; } @@ -802,7 +802,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "GoSystemExclusive") == 0) { stack->correctParams(0); goSystemExclusive(); - script->WaitFor(this); + script->waitFor(this); stack->pushNULL(); return S_OK; } -- cgit v1.2.3 From ce2e578368e15c3d7248716c92489f5a2f5005ac Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:13:37 +0200 Subject: WINTERMUTE: Rename VarName->varName in ScStack --- engines/wintermute/Base/scriptables/ScStack.cpp | 26 ++++++++++++------------- engines/wintermute/Base/scriptables/ScStack.h | 14 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index c00f0656e0..498a8472cc 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -110,24 +110,24 @@ CScValue *CScStack::getAt(int index) { ////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expected_params) { - int nu_params = pop()->getInt(); +void CScStack::correctParams(uint32 expectedParams) { + int nuParams = pop()->getInt(); - if (expected_params < nu_params) { // too many params - while (expected_params < nu_params) { + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { //Pop(); - delete _values[_sP - expected_params]; - _values.RemoveAt(_sP - expected_params); - nu_params--; + delete _values[_sP - expectedParams]; + _values.RemoveAt(_sP - expectedParams); + nuParams--; _sP--; } - } else if (expected_params > nu_params) { // need more params - while (expected_params > nu_params) { + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { //Push(null_val); - CScValue *null_val = new CScValue(Game); - null_val->setNULL(); - _values.InsertAt(_sP - nu_params + 1, null_val); - nu_params++; + CScValue *nullVal = new CScValue(Game); + nullVal->setNULL(); + _values.InsertAt(_sP - nuParams + 1, nullVal); + nuParams++; _sP++; if (_values.GetSize() > _sP + 1) { diff --git a/engines/wintermute/Base/scriptables/ScStack.h b/engines/wintermute/Base/scriptables/ScStack.h index b2d5f15c1c..739f78424a 100644 --- a/engines/wintermute/Base/scriptables/ScStack.h +++ b/engines/wintermute/Base/scriptables/ScStack.h @@ -44,15 +44,15 @@ public: CScValue *getAt(int Index); CScValue *getPushValue(); DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *Val, bool Persistent); - void pushString(const char *Val); - void pushBool(bool Val); - void pushInt(int Val); - void pushFloat(double Val); + void pushNative(CBScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); void pushNULL(); - void correctParams(uint32 expected_params); + void correctParams(uint32 expectedParams); CScValue *getTop(); - void push(CScValue *Val); + void push(CScValue *val); CScValue *pop(); CScStack(CBGame *inGame); virtual ~CScStack(); -- cgit v1.2.3 From 9c4b8f88f9360217617ab7960d79d5eaf60f7d25 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:23:31 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in ScValue --- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- engines/wintermute/Base/scriptables/ScValue.cpp | 158 +++++++++++++---------- engines/wintermute/Base/scriptables/ScValue.h | 38 +++--- 4 files changed, 110 insertions(+), 90 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 414b4a56c3..53e62e2b9d 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -653,7 +653,7 @@ HRESULT CScEngine::clearGlobals(bool includingNatives) { ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables - _globals->DbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); + _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); // process normal scripts first for (int i = 0; i < _scripts.GetSize(); i++) { diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 42aacb87e4..6c7f7d0a05 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1586,7 +1586,7 @@ HRESULT CScScript::dbgSendScript(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals - _globals->DbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); + _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); // send scope variables if (_scopeStack->_sP >= 0) { diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 5e7f3fbbc1..d88e0dd694 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -203,27 +203,29 @@ HRESULT CScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::setProp(const char *name, CScValue *Val, bool CopyWhole, bool SetAsConst) { - if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, Val); +HRESULT CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) + return _valRef->setProp(name, val); HRESULT ret = E_FAIL; if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(name, Val); + ret = _valNative->scSetProperty(name, val); } if (FAILED(ret)) { - CScValue *val = NULL; + CScValue *newVal = NULL; _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { - val = _valIter->_value; + newVal = _valIter->_value; } - if (!val) val = new CScValue(Game); - else val->cleanup(); + if (!newVal) + newVal = new CScValue(Game); + else newVal->cleanup(); - val->copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[name] = val; + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; if (_type != VAL_NATIVE) _type = VAL_OBJECT; @@ -248,7 +250,8 @@ HRESULT CScValue::setProp(const char *name, CScValue *Val, bool CopyWhole, bool ////////////////////////////////////////////////////////////////////////// bool CScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->propExists(name); + if (_type == VAL_VARIABLE_REF) + return _valRef->propExists(name); _valIter = _valObject.find(name); return (_valIter != _valObject.end()); @@ -267,17 +270,18 @@ void CScValue::deleteProps() { ////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool IncludingNatives) { +void CScValue::CleanProps(bool includingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || IncludingNatives)) _valIter->_value->setNULL(); + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); _valIter++; } } ////////////////////////////////////////////////////////////////////////// bool CScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) return _valRef->isNULL(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isNULL(); return (_type == VAL_NULL); } @@ -285,7 +289,8 @@ bool CScValue::isNULL() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->isNative(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isNative(); return (_type == VAL_NATIVE); } @@ -293,7 +298,8 @@ bool CScValue::isNative() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isString() { - if (_type == VAL_VARIABLE_REF) return _valRef->isString(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isString(); return (_type == VAL_STRING); } @@ -301,7 +307,8 @@ bool CScValue::isString() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) return _valRef->isFloat(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isFloat(); return (_type == VAL_FLOAT); } @@ -309,7 +316,8 @@ bool CScValue::isFloat() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isInt() { - if (_type == VAL_VARIABLE_REF) return _valRef->isInt(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isInt(); return (_type == VAL_INT); } @@ -317,7 +325,8 @@ bool CScValue::isInt() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isBool() { - if (_type == VAL_VARIABLE_REF) return _valRef->isBool(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isBool(); return (_type == VAL_BOOL); } @@ -325,7 +334,8 @@ bool CScValue::isBool() { ////////////////////////////////////////////////////////////////////////// bool CScValue::isObject() { - if (_type == VAL_VARIABLE_REF) return _valRef->isObject(); + if (_type == VAL_VARIABLE_REF) + return _valRef->isObject(); return (_type == VAL_OBJECT); } @@ -333,7 +343,8 @@ bool CScValue::isObject() { ////////////////////////////////////////////////////////////////////////// TValType CScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) return _valRef->getType(); + if (_type == VAL_VARIABLE_REF) + return _valRef->getType(); return _type; } @@ -449,27 +460,27 @@ void CScValue::setNULL() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *Val, bool Persistent) { +void CScValue::setNative(CBScriptable *val, bool persistent) { if (_type == VAL_VARIABLE_REF) { - _valRef->setNative(Val, Persistent); + _valRef->setNative(val, persistent); return; } - if (Val == NULL) { + if (val == NULL) { setNULL(); } else { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { - if (_valNative != Val) delete _valNative; + if (_valNative != val) delete _valNative; _valNative = NULL; } } _type = VAL_NATIVE; - _persistent = Persistent; + _persistent = persistent; - _valNative = Val; + _valNative = val; if (_valNative && !_persistent) _valNative->_refCount++; } } @@ -488,15 +499,16 @@ void CScValue::setObject() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *Val) { - _valRef = Val; +void CScValue::setReference(CScValue *val) { + _valRef = val; _type = VAL_VARIABLE_REF; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->getBool(); +bool CScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getBool(); switch (_type) { case VAL_BOOL: @@ -515,13 +527,13 @@ bool CScValue::getBool(bool Default) { return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); default: - return Default; + return defaultVal; } } ////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int Default) { +int CScValue::getInt(int defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); switch (_type) { @@ -541,14 +553,15 @@ int CScValue::getInt(int Default) { return atoi(_valString); default: - return Default; + return defaultVal; } } ////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double Default) { - if (_type == VAL_VARIABLE_REF) return _valRef->getFloat(); +double CScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getFloat(); switch (_type) { case VAL_BOOL: @@ -567,22 +580,25 @@ double CScValue::getFloat(double Default) { return atof(_valString); default: - return Default; + return defaultVal; } } ////////////////////////////////////////////////////////////////////////// void *CScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) return _valRef->getMemBuffer(); + if (_type == VAL_VARIABLE_REF) + return _valRef->getMemBuffer(); - if (_type == VAL_NATIVE) return _valNative->scToMemBuffer(); + if (_type == VAL_NATIVE) + return _valNative->scToMemBuffer(); else return (void *)NULL; } ////////////////////////////////////////////////////////////////////////// const char *CScValue::getString() { - if (_type == VAL_VARIABLE_REF) return _valRef->getString(); + if (_type == VAL_VARIABLE_REF) + return _valRef->getString(); switch (_type) { case VAL_OBJECT: @@ -594,9 +610,9 @@ const char *CScValue::getString() { break; case VAL_NATIVE: { - const char *StrVal = _valNative->scToString(); - setStringVal(StrVal); - return StrVal; + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; break; } @@ -631,7 +647,8 @@ const char *CScValue::getString() { ////////////////////////////////////////////////////////////////////////// CBScriptable *CScValue::getNative() { - if (_type == VAL_VARIABLE_REF) return _valRef->getNative(); + if (_type == VAL_VARIABLE_REF) + return _valRef->getNative(); if (_type == VAL_NATIVE) return _valNative; else return NULL; @@ -861,10 +878,10 @@ int CScValue::compareStrict(CScValue *val1, CScValue *val2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariableType Type, CScScript *script, unsigned int ScopeID) { +HRESULT CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - Client->onVariableInit(Type, script, ScopeID, _valIter->_value, _valIter->_key.c_str()); + client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); _valIter++; } return S_OK; @@ -873,44 +890,44 @@ HRESULT CScValue::DbgSendVariables(IWmeDebugClient *Client, EWmeDebuggerVariable ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, int value) { - CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(setProp(propName, Val)); - delete Val; - return Ret; + CScValue *val = new CScValue(Game, value); + bool ret = SUCCEEDED(setProp(propName, val)); + delete val; + return ret; } ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(setProp(propName, Val)); - delete Val; - return Ret; + CScValue *val = new CScValue(Game, value); + bool ret = SUCCEEDED(setProp(propName, val)); + delete val; + return ret; } ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, double value) { - CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(setProp(propName, Val)); - delete Val; - return Ret; + CScValue *val = new CScValue(Game, value); + bool ret = SUCCEEDED(setProp(propName, val)); + delete val; + return ret; } ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, bool value) { - CScValue *Val = new CScValue(Game, value); - bool Ret = SUCCEEDED(setProp(propName, Val)); - delete Val; - return Ret; + CScValue *val = new CScValue(Game, value); + bool ret = SUCCEEDED(setProp(propName, val)); + delete val; + return ret; } ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName) { - CScValue *Val = new CScValue(Game); - bool Ret = SUCCEEDED(setProp(propName, Val)); - delete Val; - return Ret; + CScValue *val = new CScValue(Game); + bool ret = SUCCEEDED(setProp(propName, val)); + delete val; + return ret; } @@ -996,13 +1013,15 @@ bool CScValue::dbgSetVal() { ////////////////////////////////////////////////////////////////////////// int CScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetNumProperties(); + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetNumProperties(); else return _valObject.size(); } ////////////////////////////////////////////////////////////////////////// bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetProperty(index, name, value); + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetProperty(index, name, value); else { int count = 0; _valIter = _valObject.begin(); @@ -1021,7 +1040,8 @@ bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **valu ////////////////////////////////////////////////////////////////////////// bool CScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) return _valRef->dbgGetDescription(buf, bufSize); + if (_type == VAL_VARIABLE_REF) + return _valRef->dbgGetDescription(buf, bufSize); if (_type == VAL_NATIVE) { _valNative->scDebuggerDesc(buf, bufSize); diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index bad5b18e84..0ff2a79ce6 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -43,25 +43,25 @@ class CBScriptable; class CScValue : public CBBase, public IWmeDebugProp { public: - HRESULT DbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + HRESULT dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); - static int compare(CScValue *Val1, CScValue *Val2); - static int compareStrict(CScValue *Val1, CScValue *Val2); + static int compare(CScValue *val1, CScValue *val2); + static int compareStrict(CScValue *val1, CScValue *val2); TValType getTypeTolerant(); - void cleanup(bool IgnoreNatives = false); + void cleanup(bool ignoreNatives = false); DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; HRESULT saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *Val); + void setValue(CScValue *val); bool _persistent; bool propExists(const char *name); void copy(CScValue *orig, bool copyWhole = false); void setStringVal(const char *val); TValType getType(); - bool getBool(bool Default = false); - int getInt(int Default = 0); - double getFloat(double Default = 0.0f); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); const char *getString(); void *getMemBuffer(); CBScriptable *getNative(); @@ -104,11 +104,11 @@ public: Common::HashMap _valObject; Common::HashMap::iterator _valIter; - bool setProperty(const char *PropName, int Value); - bool setProperty(const char *PropName, const char *Value); - bool setProperty(const char *PropName, double Value); - bool setProperty(const char *PropName, bool Value); - bool setProperty(const char *PropName); + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); // IWmeDebugProp interface implementation @@ -123,17 +123,17 @@ public: virtual IWmeDebugObject *dbgGetValNative(); // setters - virtual bool dbgSetVal(int Value); - virtual bool dbgSetVal(double Value); - virtual bool dbgSetVal(bool Value); - virtual bool dbgSetVal(const char *Value); + virtual bool dbgSetVal(int value); + virtual bool dbgSetVal(double value); + virtual bool dbgSetVal(bool value); + virtual bool dbgSetVal(const char *value); virtual bool dbgSetVal(); // properties virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int Index, const char **Name, IWmeDebugProp **Value); + virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - virtual bool dbgGetDescription(char *Buf, int BufSize); + virtual bool dbgGetDescription(char *buf, int bufSize); }; } // end of namespace WinterMute -- cgit v1.2.3 From 11d3bbceb0748229f4b4839ca7f89348953aa680 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:33:13 +0200 Subject: WINTERMUTE: Rename FuncName/VarName->funcName/varName in SXFile --- engines/wintermute/Base/scriptables/SXFile.cpp | 227 +++++++++++++------------ engines/wintermute/Base/scriptables/SXFile.h | 8 +- 2 files changed, 122 insertions(+), 113 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 34d133e330..b29c82853b 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -79,12 +79,12 @@ CSXFile::~CSXFile() { void CSXFile::cleanup() { delete[] _filename; _filename = NULL; - Close(); + close(); } ////////////////////////////////////////////////////////////////////////// -void CSXFile::Close() { +void CSXFile::close() { if (_readFile) { Game->_fileManager->closeFile(_readFile); _readFile = NULL; @@ -123,7 +123,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { stack->correctParams(1); - Close(); + close(); _mode = stack->pop()->getInt(1); if (_mode < 1 || _mode > 3) { script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); @@ -133,7 +133,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _readFile = Game->_fileManager->openFile(_filename); if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - Close(); + close(); } else _textMode = strcmp(name, "OpenAsText") == 0; } else { if (strcmp(name, "OpenAsText") == 0) { @@ -146,7 +146,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_writeFile) { //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - Close(); + close(); } else _textMode = strcmp(name, "OpenAsText") == 0; } @@ -161,7 +161,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Close") == 0) { stack->correctParams(0); - Close(); + close(); stack->pushNULL(); return S_OK; } @@ -176,7 +176,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushBool(false); } else { int Pos = stack->pop()->getInt(); - stack->pushBool(SetPos(Pos)); + stack->pushBool(setPos(Pos)); } return S_OK; } @@ -186,7 +186,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); - Close(); + close(); stack->pushBool(CBPlatform::DeleteFile(_filename) != false); return S_OK; } @@ -199,7 +199,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this const char *Dest = stack->pop()->getString(); bool Overwrite = stack->pop()->getBool(true); - Close(); + close(); stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); return S_OK; } @@ -214,41 +214,41 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); - uint32 Counter = 0; + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; byte b; - bool FoundNewLine = false; - HRESULT Ret = E_FAIL; + bool foundNewLine = false; + HRESULT ret = E_FAIL; do { - Ret = _readFile->read(&b, 1); - if (Ret != 1) break; + ret = _readFile->read(&b, 1); + if (ret != 1) break; - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; } if (b == '\n') { - Buf[Counter] = '\0'; - FoundNewLine = true; + buf[counter] = '\0'; + foundNewLine = true; break; } else if (b == 0x0D) continue; else { - Buf[Counter] = b; - Counter++; + buf[counter] = b; + counter++; } - } while (SUCCEEDED(Ret)); + } while (SUCCEEDED(ret)); - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; } - Buf[Counter] = '\0'; + buf[counter] = '\0'; - if (!FoundNewLine && Counter == 0) stack->pushNULL(); - else stack->pushString((char *)Buf); + if (!foundNewLine && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); - free(Buf); + free(buf); return S_OK; } @@ -258,44 +258,44 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadText") == 0) { stack->correctParams(1); - int TextLen = stack->pop()->getInt(); + int textLen = stack->pop()->getInt(); if (!_textMode || !_readFile) { script->runtimeError("File.%s: File must be open in text mode.", name); stack->pushNULL(); return S_OK; } - uint32 BufSize = FILE_BUFFER_SIZE; - byte *Buf = (byte *)malloc(BufSize); - uint32 Counter = 0; + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; byte b; - HRESULT Ret = E_FAIL; - while (Counter < TextLen) { - Ret = _readFile->read(&b, 1); - if (Ret != 1) break; + HRESULT ret = E_FAIL; + while (counter < textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) break; - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; } if (b == 0x0D) continue; else { - Buf[Counter] = b; - Counter++; + buf[counter] = b; + counter++; } } - if (Counter > BufSize) { - Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE); - BufSize += FILE_BUFFER_SIZE; + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; } - Buf[Counter] = '\0'; + buf[counter] = '\0'; - if (TextLen > 0 && Counter == 0) stack->pushNULL(); - else stack->pushString((char *)Buf); + if (textLen > 0 && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); - free(Buf); + free(buf); return S_OK; } @@ -305,16 +305,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { stack->correctParams(1); - const char *Line = stack->pop()->getString(); + const char *line = stack->pop()->getString(); if (!_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in text mode.", name); stack->pushBool(false); return S_OK; } if (strcmp(name, "WriteLine") == 0) - fprintf((FILE *)_writeFile, "%s\n", Line); + fprintf((FILE *)_writeFile, "%s\n", line); else - fprintf((FILE *)_writeFile, "%s", Line); + fprintf((FILE *)_writeFile, "%s", line); stack->pushBool(true); @@ -332,8 +332,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - bool Val; - if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->pushBool(Val); + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); else stack->pushNULL(); return S_OK; @@ -349,8 +349,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - byte Val; - if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->pushInt(Val); + byte val; + if (_readFile->read(&val, sizeof(byte)) == sizeof(byte)) stack->pushInt(val); else stack->pushNULL(); return S_OK; @@ -366,8 +366,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - short Val; - if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + Val); + short val; + if (_readFile->read(&val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + val); else stack->pushNULL(); return S_OK; @@ -383,8 +383,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - int Val; - if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->pushInt(Val); + int val; + if (_readFile->read(&val, sizeof(int)) == sizeof(int)) stack->pushInt(val); else stack->pushNULL(); return S_OK; @@ -400,8 +400,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - float Val; - if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->pushFloat(Val); + float val; + if (_readFile->read(&val, sizeof(float)) == sizeof(float)) stack->pushFloat(val); else stack->pushNULL(); return S_OK; @@ -417,8 +417,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - double Val; - if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->pushFloat(Val); + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); else stack->pushNULL(); return S_OK; @@ -434,15 +434,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); return S_OK; } - uint32 Size; - if (_readFile->read(&Size, sizeof(uint32)) == sizeof(uint32)) { - byte *Str = new byte[Size + 1]; - if (Str) { - if (_readFile->read(Str, Size) == Size) { - Str[Size] = '\0'; - stack->pushString((char *)Str); + uint32 size; + if (_readFile->read(&size, sizeof(uint32)) == sizeof(uint32)) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); } - delete [] Str; + delete [] str; } else stack->pushNULL(); } else stack->pushNULL(); @@ -454,14 +454,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteBool") == 0) { stack->correctParams(1); - bool Val = stack->pop()->getBool(); + bool val = stack->pop()->getBool(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -472,14 +472,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteByte") == 0) { stack->correctParams(1); - byte Val = stack->pop()->getInt(); + byte val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -490,14 +490,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteShort") == 0) { stack->correctParams(1); - short Val = stack->pop()->getInt(); + short val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -508,14 +508,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { stack->correctParams(1); - int Val = stack->pop()->getInt(); + int val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -526,14 +526,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteFloat") == 0) { stack->correctParams(1); - float Val = stack->pop()->getFloat(); + float val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -544,14 +544,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteDouble") == 0) { stack->correctParams(1); - double Val = stack->pop()->getFloat(); + double val = stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return S_OK; } - fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); + fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return S_OK; @@ -562,7 +562,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteString") == 0) { stack->correctParams(1); - const char *Val = stack->pop()->getString(); + const char *val = stack->pop()->getString(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); @@ -570,9 +570,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this return S_OK; } - uint32 Size = strlen(Val); - fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile); - fwrite(Val, Size, 1, (FILE *)_writeFile); + uint32 size = strlen(val); + fwrite(&size, sizeof(size), 1, (FILE *)_writeFile); + fwrite(val, size, 1, (FILE *)_writeFile); stack->pushBool(true); @@ -608,7 +608,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // Position (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Position") == 0) { - _scValue->setInt(GetPos()); + _scValue->setInt(getPos()); return _scValue; } @@ -616,7 +616,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { // Length (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Length") == 0) { - _scValue->setInt(GetLength()); + _scValue->setInt(getLength()); return _scValue; } @@ -663,22 +663,25 @@ HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) { } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::GetPos() { - if (_mode == 1 && _readFile) return _readFile->pos(); +uint32 CSXFile::getPos() { + if (_mode == 1 && _readFile) + return _readFile->pos(); else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE *)_writeFile); else return 0; } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::SetPos(uint32 pos, TSeek origin) { - if (_mode == 1 && _readFile) return _readFile->seek(pos, origin); +bool CSXFile::setPos(uint32 pos, TSeek origin) { + if (_mode == 1 && _readFile) + return _readFile->seek(pos, origin); else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE *)_writeFile, pos, (int)origin) == 0; else return false; } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::GetLength() { - if (_mode == 1 && _readFile) return _readFile->size(); +uint32 CSXFile::getLength() { + if (_mode == 1 && _readFile) + return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { uint32 CurrentPos = ftell((FILE *)_writeFile); fseek((FILE *)_writeFile, 0, SEEK_END); @@ -697,12 +700,12 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_mode)); persistMgr->transfer(TMEMBER(_textMode)); - uint32 Pos = 0; + uint32 pos = 0; if (persistMgr->_saving) { - Pos = GetPos(); - persistMgr->transfer(TMEMBER(Pos)); + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); } else { - persistMgr->transfer(TMEMBER(Pos)); + persistMgr->transfer(TMEMBER(pos)); // try to re-open file if needed _writeFile = NULL; @@ -712,20 +715,26 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { // open for reading if (_mode == 1) { _readFile = Game->_fileManager->openFile(_filename); - if (!_readFile) Close(); + if (!_readFile) + close(); } // open for writing / appending else { if (_textMode) { - if (_mode == 2) _writeFile = fopen(_filename, "w+"); - else _writeFile = fopen(_filename, "a+"); + if (_mode == 2) + _writeFile = fopen(_filename, "w+"); + else + _writeFile = fopen(_filename, "a+"); } else { - if (_mode == 2) _writeFile = fopen(_filename, "wb+"); - else _writeFile = fopen(_filename, "ab+"); + if (_mode == 2) + _writeFile = fopen(_filename, "wb+"); + else + _writeFile = fopen(_filename, "ab+"); } - if (_writeFile) Close(); + if (_writeFile) + close(); } - SetPos(Pos); + setPos(pos); } } diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index b28fca019e..efa06b7023 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -51,11 +51,11 @@ private: void *_writeFile; int _mode; // 0..none, 1..read, 2..write, 3..append bool _textMode; - void Close(); + void close(); void cleanup(); - uint32 GetPos(); - uint32 GetLength(); - bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); char *_filename; }; -- cgit v1.2.3 From 149a890f76c609539bf533191bf4667f21892fb5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:42:41 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in SXMath and SXMemBuffer --- engines/wintermute/Base/scriptables/SXMath.h | 4 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 198 ++++++++++++--------- engines/wintermute/Base/scriptables/SXMemBuffer.h | 8 +- 3 files changed, 118 insertions(+), 92 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index 704b93a897..477e8aca4f 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -43,8 +43,8 @@ public: virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); private: - double degreeToRadian(double Value); - double radianToDegree(double Value); + double degreeToRadian(double value); + double radianToDegree(double value); }; diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 8abf336f55..f719ee5a47 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -48,7 +48,7 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame _size = 0; int NewSize = stack->pop()->getInt(); - Resize(MAX(0, NewSize)); + resize(MAX(0, NewSize)); } ////////////////////////////////////////////////////////////////////////// @@ -76,43 +76,45 @@ void CSXMemBuffer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::Resize(int NewSize) { - int OldSize = _size; +HRESULT CSXMemBuffer::resize(int newSize) { + int oldSize = _size; if (_size == 0) { - _buffer = malloc(NewSize); - if (_buffer) _size = NewSize; + _buffer = malloc(newSize); + if (_buffer) _size = newSize; } else { - void *NewBuf = realloc(_buffer, NewSize); - if (!NewBuf) { - if (NewSize == 0) { - _buffer = NewBuf; - _size = NewSize; + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; } else return E_FAIL; } else { - _buffer = NewBuf; - _size = NewSize; + _buffer = newBuf; + _size = newSize; } } - if (_buffer && _size > OldSize) { - memset((byte *)_buffer + OldSize, 0, _size - OldSize); + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); } return S_OK; } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::CheckBounds(CScScript *script, int start, int length) { +bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { if (_buffer == NULL) { script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } - if (_size == 0) return true; + if (_size == 0) + return true; if (start < 0 || length == 0 || start + length > _size) { script->runtimeError("Set/Get method call is out of bounds"); return false; - } else return true; + } else + return true; } ////////////////////////////////////////////////////////////////////////// @@ -128,10 +130,12 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSize") == 0) { stack->correctParams(1); - int NewSize = stack->pop()->getInt(); - NewSize = MAX(0, NewSize); - if (SUCCEEDED(Resize(NewSize))) stack->pushBool(true); - else stack->pushBool(false); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (SUCCEEDED(resize(newSize))) + stack->pushBool(true); + else + stack->pushBool(false); return S_OK; } @@ -141,9 +145,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetBool") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->pushNULL(); - else stack->pushBool(*(bool *)((byte *)_buffer + Start)); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushNULL(); + else + stack->pushBool(*(bool *)((byte *)_buffer + start)); return S_OK; } @@ -153,9 +159,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetByte") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->pushNULL(); - else stack->pushInt(*(byte *)((byte *)_buffer + Start)); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushNULL(); + else + stack->pushInt(*(byte *)((byte *)_buffer + start)); return S_OK; } @@ -166,8 +174,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->pushNULL(); - else stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + if (!checkBounds(script, Start, sizeof(short))) + stack->pushNULL(); + else + stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -177,9 +187,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->pushNULL(); - else stack->pushInt(*(int *)((byte *)_buffer + Start)); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) + stack->pushNULL(); + else + stack->pushInt(*(int *)((byte *)_buffer + start)); return S_OK; } @@ -189,9 +201,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFloat") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(float))) stack->pushNULL(); - else stack->pushFloat(*(float *)((byte *)_buffer + Start)); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) + stack->pushNULL(); + else + stack->pushFloat(*(float *)((byte *)_buffer + start)); return S_OK; } @@ -201,9 +215,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDouble") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(double))) stack->pushNULL(); - else stack->pushFloat(*(double *)((byte *)_buffer + Start)); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) + stack->pushNULL(); + else + stack->pushFloat(*(double *)((byte *)_buffer + start)); return S_OK; } @@ -213,26 +229,27 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetString") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - int Length = stack->pop()->getInt(); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); // find end of string - if (Length == 0 && Start >= 0 && Start < _size) { - for (int i = Start; i < _size; i++) { + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { if (((char *)_buffer)[i] == '\0') { - Length = i - Start; + length = i - start; break; } } } - if (!CheckBounds(script, Start, Length)) stack->pushNULL(); + if (!checkBounds(script, start, length)) + stack->pushNULL(); else { - char *Str = new char[Length + 1]; - strncpy(Str, (const char *)_buffer + Start, Length); - Str[Length] = '\0'; - stack->pushString(Str); - delete [] Str; + char *str = new char[length + 1]; + strncpy(str, (const char *)_buffer + start, length); + str[length] = '\0'; + stack->pushString(str); + delete [] str; } return S_OK; } @@ -242,12 +259,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPointer") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->pushNULL(); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushNULL(); else { - void *Pointer = *(void **)((byte *)_buffer + Start); - CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); - stack->pushNative(Buf, false); + void *pointer = *(void **)((byte *)_buffer + start); + CSXMemBuffer *buf = new CSXMemBuffer(Game, pointer); + stack->pushNative(buf, false); } return S_OK; } @@ -257,12 +275,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBool") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - bool Val = stack->pop()->getBool(); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushBool(false); else { - *(bool *)((byte *)_buffer + Start) = Val; + *(bool *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -273,12 +292,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetByte") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - byte Val = (byte)stack->pop()->getInt(); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushBool(false); else { - *(byte *)((byte *)_buffer + Start) = Val; + *(byte *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -289,12 +309,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetShort") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - short Val = (short)stack->pop()->getInt(); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(short))) + stack->pushBool(false); else { - *(short *)((byte *)_buffer + Start) = Val; + *(short *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -305,12 +326,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - int Val = stack->pop()->getInt(); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(int))) + stack->pushBool(false); else { - *(int *)((byte *)_buffer + Start) = Val; + *(int *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -321,12 +343,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFloat") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - float Val = (float)stack->pop()->getFloat(); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); - if (!CheckBounds(script, Start, sizeof(float))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(float))) + stack->pushBool(false); else { - *(float *)((byte *)_buffer + Start) = Val; + *(float *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -337,12 +360,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDouble") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - double Val = stack->pop()->getFloat(); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); - if (!CheckBounds(script, Start, sizeof(double))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(double))) + stack->pushBool(false); else { - *(double *)((byte *)_buffer + Start) = Val; + *(double *)((byte *)_buffer + start) = val; stack->pushBool(true); } return S_OK; @@ -353,12 +377,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetString") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); - const char *Val = stack->pop()->getString(); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); - if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->pushBool(false); + if (!checkBounds(script, start, strlen(val) + 1)) + stack->pushBool(false); else { - memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); + memcpy((byte *)_buffer + start, val, strlen(val) + 1); stack->pushBool(true); } return S_OK; @@ -369,10 +394,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); - int Start = stack->pop()->getInt(); + int start = stack->pop()->getInt(); /* CScValue *Val = */ stack->pop(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->pushBool(false); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushBool(false); else { /* int Pointer = (int)Val->getMemBuffer(); @@ -474,8 +500,8 @@ HRESULT CSXMemBuffer::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *Val) { - if (_buffer == Val->scToMemBuffer()) return 0; +int CSXMemBuffer::scCompare(CBScriptable *val) { + if (_buffer == val->scToMemBuffer()) return 0; else return 1; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index 13b98b589d..d76257fca7 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -42,16 +42,16 @@ public: HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *Stack); - CSXMemBuffer(CBGame *inGame, void *Buffer); + CSXMemBuffer(CBGame *inGame, CScStack *stack); + CSXMemBuffer(CBGame *inGame, void *buffer); virtual ~CSXMemBuffer(); virtual void *scToMemBuffer(); int _size; private: - HRESULT Resize(int NewSize); + HRESULT resize(int newSize); void *_buffer; void cleanup(); - bool CheckBounds(CScScript *Script, int Start, int Length); + bool checkBounds(CScScript *script, int start, int length); }; } // end of namespace WinterMute -- cgit v1.2.3 From b6e271f7150be92044cb6b902760205ec74d12bf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:48:13 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in SXStore/SXObject --- engines/wintermute/Base/scriptables/SXStore.cpp | 75 ++++++++++++------------ engines/wintermute/Base/scriptables/SXStore.h | 44 +++++++------- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- 3 files changed, 63 insertions(+), 60 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 30ff22f6dc..585a54fc6a 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -66,7 +66,7 @@ CSXStore::~CSXStore() { ////////////////////////////////////////////////////////////////////////// void CSXStore::cleanup() { - SetEventsEnabled(NULL, false); + setEventsEnabled(NULL, false); for (int i = 0; i < _validProducts.GetSize(); i++) { delete _validProducts[i]; @@ -90,8 +90,8 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "EnableEvents") == 0) { stack->correctParams(0); - SetEventsEnabled(script, true); - stack->pushBool(GetEventsEnabled() == true); + setEventsEnabled(script, true); + stack->pushBool(getEventsEnabled() == true); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -99,8 +99,8 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisableEvents") == 0) { stack->correctParams(0); - SetEventsEnabled(script, false); - stack->pushBool(GetEventsEnabled() == false); + setEventsEnabled(script, false); + stack->pushBool(getEventsEnabled() == false); return S_OK; } ////////////////////////////////////////////////////////////////////////// @@ -110,7 +110,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); const char *prodIdList = stack->pop()->getString(); _lastProductRequestOwner = script->_owner; - ValidateProducts(prodIdList); + validateProducts(prodIdList); stack->pushNULL(); return S_OK; } @@ -123,10 +123,10 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (index >= 0 && index < _validProducts.GetSize()) { CScValue *prod = stack->getPushValue(); if (prod) { - prod->setProperty("Id", _validProducts[index]->GetId()); - prod->setProperty("Name", _validProducts[index]->GetName()); - prod->setProperty("Description", _validProducts[index]->GetDesc()); - prod->setProperty("Price", _validProducts[index]->GetPrice()); + prod->setProperty("Id", _validProducts[index]->getId()); + prod->setProperty("Name", _validProducts[index]->getName()); + prod->setProperty("Description", _validProducts[index]->getDesc()); + prod->setProperty("Price", _validProducts[index]->getPrice()); } } else stack->pushNULL(); @@ -155,9 +155,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (index >= 0 && index < _transactions.GetSize()) { CScValue *trans = stack->getPushValue(); if (trans) { - trans->setProperty("Id", _transactions[index]->GetId()); - trans->setProperty("ProductId", _transactions[index]->GetProductId()); - trans->setProperty("State", _transactions[index]->GetState()); + trans->setProperty("Id", _transactions[index]->getId()); + trans->setProperty("ProductId", _transactions[index]->getProductId()); + trans->setProperty("State", _transactions[index]->getState()); } } else stack->pushNULL(); @@ -170,7 +170,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "Purchase") == 0) { stack->correctParams(1); const char *prodId = stack->pop()->getString(); - stack->pushBool(Purchase(script, prodId)); + stack->pushBool(purchase(script, prodId)); return S_OK; } @@ -180,7 +180,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "FinishTransaction") == 0) { stack->correctParams(1); const char *transId = stack->pop()->getString(); - stack->pushBool(FinishTransaction(script, transId)); + stack->pushBool(finishTransaction(script, transId)); return S_OK; } @@ -189,7 +189,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RestoreTransactions") == 0) { stack->correctParams(0); - RestoreTransactions(script); + restoreTransactions(script); stack->pushNULL(); return S_OK; @@ -241,14 +241,14 @@ CScValue *CSXStore::scGetProperty(const char *name) { // Available (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Available") == 0) { - _scValue->setBool(IsAvailable()); + _scValue->setBool(isAvailable()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // EventsEnabled (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EventsEnabled") == 0) { - _scValue->setBool(GetEventsEnabled()); + _scValue->setBool(getEventsEnabled()); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -279,7 +279,8 @@ CScValue *CSXStore::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); + if (!persistMgr->_saving) + cleanup(); CBObject::persist(persistMgr); @@ -312,7 +313,7 @@ HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// void CSXStore::afterLoad() { if (_eventsEnabled) { - SetEventsEnabled(NULL, true); + setEventsEnabled(NULL, true); } #ifdef __IPHONEOS__ StoreKit_SetExternalData((void *)this); @@ -327,7 +328,7 @@ void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::SetEventsEnabled(CScScript *script, bool val) { +void CSXStore::setEventsEnabled(CScScript *script, bool val) { _eventsEnabled = val; if (val) { @@ -344,14 +345,14 @@ void CSXStore::SetEventsEnabled(CScScript *script, bool val) { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::ValidateProducts(const char *prodIdList) { +void CSXStore::validateProducts(const char *prodIdList) { #ifdef __IPHONEOS__ StoreKit_ValidateProducts(prodIdList); #endif } ////////////////////////////////////////////////////////////////////////// -bool CSXStore::IsAvailable() { +bool CSXStore::isAvailable() { #ifdef __IPHONEOS__ return StoreKit_IsStoreAvailable() > 0; #else @@ -360,7 +361,7 @@ bool CSXStore::IsAvailable() { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveProductsStart() { +void CSXStore::receiveProductsStart() { for (int i = 0; i < _validProducts.GetSize(); i++) { delete _validProducts[i]; } @@ -370,23 +371,23 @@ void CSXStore::ReceiveProductsStart() { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveProductsEnd() { +void CSXStore::receiveProductsEnd() { if (_lastProductRequestOwner) _lastProductRequestOwner->applyEvent("ProductsValidated"); } ////////////////////////////////////////////////////////////////////////// -void CSXStore::AddValidProduct(const char *id, const char *name, const char *desc, const char *price) { +void CSXStore::addValidProduct(const char *id, const char *name, const char *desc, const char *price) { CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); _validProducts.Add(prod); } ////////////////////////////////////////////////////////////////////////// -void CSXStore::AddInvalidProduct(const char *id) { +void CSXStore::addInvalidProduct(const char *id) { _invalidProducts.push_back(id); } ////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveTransactionsStart() { +void CSXStore::receiveTransactionsStart() { for (int i = 0; i < _transactions.GetSize(); i++) { delete _transactions[i]; } @@ -394,19 +395,21 @@ void CSXStore::ReceiveTransactionsStart() { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::ReceiveTransactionsEnd() { - if (_lastPurchaseOwner) _lastPurchaseOwner->applyEvent("TransactionsUpdated"); - else Game->applyEvent("TransactionsUpdated"); +void CSXStore::receiveTransactionsEnd() { + if (_lastPurchaseOwner) + _lastPurchaseOwner->applyEvent("TransactionsUpdated"); + else + Game->applyEvent("TransactionsUpdated"); } ////////////////////////////////////////////////////////////////////////// -void CSXStore::AddTransaction(const char *id, const char *productId, const char *state) { +void CSXStore::addTransaction(const char *id, const char *productId, const char *state) { CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); _transactions.Add(trans); } ////////////////////////////////////////////////////////////////////////// -bool CSXStore::Purchase(CScScript *script, const char *productId) { +bool CSXStore::purchase(CScScript *script, const char *productId) { if (!productId) return false; #ifdef __IPHONEOS__ @@ -424,7 +427,7 @@ bool CSXStore::Purchase(CScScript *script, const char *productId) { } ////////////////////////////////////////////////////////////////////////// -bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { +bool CSXStore::finishTransaction(CScScript *script, const char *transId) { if (!transId) return false; #ifdef __IPHONEOS__ for (int i = 0; i < _transactions.GetSize(); i++) { @@ -442,7 +445,7 @@ bool CSXStore::FinishTransaction(CScScript *script, const char *transId) { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::RestoreTransactions(CScScript *script) { +void CSXStore::restoreTransactions(CScScript *script) { _lastRestoreOwner = script->_owner; #ifdef __IPHONEOS__ StoreKit_RestoreTransactions(); @@ -450,7 +453,7 @@ void CSXStore::RestoreTransactions(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -void CSXStore::OnRestoreFinished(bool error) { +void CSXStore::onRestoreFinished(bool error) { if (_lastRestoreOwner) { if (error) _lastRestoreOwner->applyEvent("TransactionsRestoreFailed"); else _lastRestoreOwner->applyEvent("TransactionsRestoreFinished"); diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index 43d36553a7..fafd007003 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -68,16 +68,16 @@ public: return S_OK; } - const char *GetId() { + const char *getId() { return _id; } - const char *GetName() { + const char *getName() { return _name; } - const char *GetDesc() { + const char *getDesc() { return _desc; } - const char *GetPrice() { + const char *getPrice() { return _price; } @@ -109,13 +109,13 @@ public: delete [] _state; } - const char *GetId() { + const char *getId() { return _id; } - const char *GetProductId() { + const char *getProductId() { return _productId; } - const char *GetState() { + const char *getState() { return _state; } @@ -135,29 +135,29 @@ public: void afterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); - bool IsAvailable(); - void SetEventsEnabled(CScScript *script, bool val); - bool GetEventsEnabled() const { + bool isAvailable(); + void setEventsEnabled(CScScript *script, bool val); + bool getEventsEnabled() const { return _eventsEnabled; } - void ValidateProducts(const char *prodIdList); + void validateProducts(const char *prodIdList); - void ReceiveTransactionsStart(); - void ReceiveTransactionsEnd(); - void AddTransaction(const char *id, const char *productId, const char *state); + void receiveTransactionsStart(); + void receiveTransactionsEnd(); + void addTransaction(const char *id, const char *productId, const char *state); - void ReceiveProductsStart(); - void ReceiveProductsEnd(); - void AddValidProduct(const char *id, const char *name, const char *desc, const char *price); - void AddInvalidProduct(const char *id); + void receiveProductsStart(); + void receiveProductsEnd(); + void addValidProduct(const char *id, const char *name, const char *desc, const char *price); + void addInvalidProduct(const char *id); - void OnRestoreFinished(bool error); + void onRestoreFinished(bool error); private: void cleanup(); - bool Purchase(CScScript *script, const char *productId); - bool FinishTransaction(CScScript *script, const char *transId); - void RestoreTransactions(CScScript *script); + bool purchase(CScScript *script, const char *productId); + bool finishTransaction(CScScript *script, const char *transId); + void restoreTransactions(CScScript *script); bool _eventsEnabled; CBArray _validProducts; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 7f61a81b19..7382c5c949 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -44,8 +44,8 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int NumParams = stack->pop()->getInt(0); - for (int i = 0; i < NumParams; i++) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { addScript(stack->pop()->getString()); } } -- cgit v1.2.3 From a77ab4be6d35ac035540e94fddb3aac1ba63187d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 00:50:25 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in SXString --- engines/wintermute/Base/scriptables/SXString.cpp | 34 ++++++++++++------------ engines/wintermute/Base/scriptables/SXString.h | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index f5981bb73d..60a58d3cfd 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -49,16 +49,16 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _capacity = 0; stack->correctParams(1); - CScValue *Val = stack->pop(); + CScValue *val = stack->pop(); - if (Val->isInt()) { - _capacity = MAX(0, Val->getInt()); + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); if (_capacity > 0) { _string = new char[_capacity]; memset(_string, 0, _capacity); } } else { - setStringVal(Val->getString()); + setStringVal(val->getString()); } if (_capacity == 0) setStringVal(""); @@ -245,12 +245,12 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Split") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); - char Separators[MAX_PATH] = ","; - if (!Val->isNULL()) strcpy(Separators, Val->getString()); + CScValue *val = stack->pop(); + char separators[MAX_PATH] = ","; + if (!val->isNULL()) strcpy(separators, val->getString()); - CSXArray *Array = new CSXArray(Game); - if (!Array) { + CSXArray *array = new CSXArray(Game); + if (!array) { stack->pushNULL(); return S_OK; } @@ -264,9 +264,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString delims; if (Game->_textEncoding == TEXT_UTF8) - delims = StringUtil::utf8ToWide(Separators); + delims = StringUtil::utf8ToWide(separators); else - delims = StringUtil::ansiToWide(Separators); + delims = StringUtil::ansiToWide(separators); Common::Array parts; @@ -299,16 +299,16 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString &part = (*it); if (Game->_textEncoding == TEXT_UTF8) - Val = new CScValue(Game, StringUtil::wideToUtf8(part).c_str()); + val = new CScValue(Game, StringUtil::wideToUtf8(part).c_str()); else - Val = new CScValue(Game, StringUtil::wideToAnsi(part).c_str()); + val = new CScValue(Game, StringUtil::wideToAnsi(part).c_str()); - Array->push(Val); - delete Val; - Val = NULL; + array->push(val); + delete val; + val = NULL; } - stack->pushNative(Array, false); + stack->pushNative(array, false); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index 73969f8fdc..d7279d17cf 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -41,9 +41,9 @@ public: CScValue *scGetProperty(const char *name); HRESULT scSetProperty(const char *name, CScValue *value); HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - void scSetString(const char *Val); + void scSetString(const char *val); const char *scToString(); - void setStringVal(const char *Val); + void setStringVal(const char *val); CSXString(CBGame *inGame, CScStack *Stack); virtual ~CSXString(); -- cgit v1.2.3 From c4fac37bd0035ac19ab0279941d4f1a2eb118409 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 01:23:20 +0200 Subject: WINTERMUTE: Start removing useless Windows-only code, and the compiler-references. --- engines/wintermute/Ad/AdGame.cpp | 11 --- engines/wintermute/Ad/AdGame.h | 1 - engines/wintermute/Base/BGame.cpp | 51 -------------- engines/wintermute/Base/BGame.h | 3 - engines/wintermute/Base/scriptables/ScEngine.cpp | 85 ++---------------------- engines/wintermute/Base/scriptables/ScEngine.h | 4 +- engines/wintermute/dcscript.h | 8 +-- engines/wintermute/persistent.h | 8 +-- engines/wintermute/wintypes.h | 4 -- 9 files changed, 15 insertions(+), 160 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index d6485f5cd4..da64c19fe9 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1046,17 +1046,6 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { } -////////////////////////////////////////////////////////////////////////// -void CAdGame::PublishNatives() { - if (!_scEngine || !_scEngine->_compilerAvailable) return; - - CBGame::PublishNatives(); - - _scEngine->ExtDefineFunction("Actor"); - _scEngine->ExtDefineFunction("Entity"); -} - - ////////////////////////////////////////////////////////////////////////// HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *this_obj; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 4eef4b8df4..ed5f5b3f73 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -147,7 +147,6 @@ public: HRESULT loadItemsBuffer(byte *buffer, bool merge = false); - virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 2117e18f8b..bebccec08f 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -197,8 +197,6 @@ CBGame::CBGame(): CBObject(this) { _subtitlesSpeed = 70; - _resourceModule = 0; - _forceNonStreamedSounds = false; _thumbnailWidth = _thumbnailHeight = 0; @@ -2890,49 +2888,6 @@ bool CBGame::validObject(CBObject *object) { } -////////////////////////////////////////////////////////////////////////// -void CBGame::PublishNatives() { - if (!_scEngine || !_scEngine->_compilerAvailable) return; - - _scEngine->ExtDefineFunction("LOG"); - _scEngine->ExtDefineFunction("String"); - _scEngine->ExtDefineFunction("MemBuffer"); - _scEngine->ExtDefineFunction("File"); - _scEngine->ExtDefineFunction("Date"); - _scEngine->ExtDefineFunction("Array"); - _scEngine->ExtDefineFunction("TcpClient"); - _scEngine->ExtDefineFunction("Object"); - //_scEngine->ExtDefineFunction("Game"); - _scEngine->ExtDefineFunction("Sleep"); - _scEngine->ExtDefineFunction("WaitFor"); - _scEngine->ExtDefineFunction("Random"); - _scEngine->ExtDefineFunction("SetScriptTimeSlice"); - _scEngine->ExtDefineFunction("MakeRGBA"); - _scEngine->ExtDefineFunction("MakeRGB"); - _scEngine->ExtDefineFunction("MakeHSL"); - _scEngine->ExtDefineFunction("RGB"); - _scEngine->ExtDefineFunction("GetRValue"); - _scEngine->ExtDefineFunction("GetGValue"); - _scEngine->ExtDefineFunction("GetBValue"); - _scEngine->ExtDefineFunction("GetAValue"); - _scEngine->ExtDefineFunction("GetHValue"); - _scEngine->ExtDefineFunction("GetSValue"); - _scEngine->ExtDefineFunction("GetLValue"); - _scEngine->ExtDefineFunction("Debug"); - - _scEngine->ExtDefineFunction("ToString"); - _scEngine->ExtDefineFunction("ToInt"); - _scEngine->ExtDefineFunction("ToBool"); - _scEngine->ExtDefineFunction("ToFloat"); - - _scEngine->ExtDefineVariable("Game"); - _scEngine->ExtDefineVariable("Math"); - _scEngine->ExtDefineVariable("Directory"); - _scEngine->ExtDefineVariable("self"); - _scEngine->ExtDefineVariable("this"); -} - - ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *thisObj; @@ -4074,12 +4029,6 @@ void CBGame::resetMousePos() { } -////////////////////////////////////////////////////////////////////////// -void CBGame::setResourceModule(HMODULE resModule) { - _resourceModule = resModule; -} - - ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::displayContent(bool update, bool displayAll) { return S_OK; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 6ece353ee7..70ae0d5be1 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -143,8 +143,6 @@ public: int _thumbnailHeight; bool _reportTextureFormat; - HMODULE _resourceModule; - void setResourceModule(HMODULE resModule); void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); ENGINE_LOG_CALLBACK _engineLogCallback; @@ -222,7 +220,6 @@ public: virtual HRESULT invalidateDeviceObjects(); virtual HRESULT restoreDeviceObjects(); - virtual void PublishNatives(); virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 53e62e2b9d..b70f04f568 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -48,56 +48,6 @@ IMPLEMENT_PERSISTENT(CScEngine, true) CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { Game->LOG(0, "Initializing scripting engine..."); - /* - #ifdef __WIN32__ - char CompilerPath[MAX_PATH]; - strcpy(CompilerPath, COMPILER_DLL); - - _compilerDLL = ::LoadLibrary(CompilerPath); - if (_compilerDLL == NULL) { - char ModuleName[MAX_PATH]; - ::GetModuleFileName(NULL, ModuleName, MAX_PATH); - - // switch to exe's dir - char *ExeDir = CBUtils::GetPath(ModuleName); - sprintf(CompilerPath, "%s%s", ExeDir, COMPILER_DLL); - _compilerDLL = ::LoadLibrary(CompilerPath); - - delete [] ExeDir; - } - if (_compilerDLL != NULL) { - // bind compiler's functionality - ExtCompileBuffer = (DLL_COMPILE_BUFFER) ::GetProcAddress(_compilerDLL, "CompileBuffer"); - ExtCompileFile = (DLL_COMPILE_FILE) ::GetProcAddress(_compilerDLL, "CompileFile"); - ExtReleaseBuffer = (DLL_RELEASE_BUFFER) ::GetProcAddress(_compilerDLL, "ReleaseBuffer"); - ExtSetCallbacks = (DLL_SET_CALLBACKS) ::GetProcAddress(_compilerDLL, "SetCallbacks"); - ExtDefineFunction = (DLL_DEFINE_FUNCTION)::GetProcAddress(_compilerDLL, "DefineFunction"); - ExtDefineVariable = (DLL_DEFINE_VARIABLE)::GetProcAddress(_compilerDLL, "DefineVariable"); - - if (!ExtCompileBuffer || !ExtCompileFile || !ExtReleaseBuffer || !ExtSetCallbacks || !ExtDefineFunction || !ExtDefineVariable) { - _compilerAvailable = false; - ::FreeLibrary(_compilerDLL); - _compilerDLL = NULL; - } else { - */ /* - // publish external methods to the compiler - CALLBACKS c; - c.Dll_AddError = AddError; - c.Dll_CloseFile = CloseFile; - c.Dll_LoadFile = LoadFile; - ExtSetCallbacks(&c, Game); - */ - /* - _compilerAvailable = true; - } - } else _compilerAvailable = false; - #else - */ - _compilerAvailable = false; - _compilerDLL = 0; -//#endif - - if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); else Game->LOG(0, " Script compiler is NOT available"); @@ -144,9 +94,7 @@ CScEngine::~CScEngine() { saveBreakpoints(); disableProfiling(); -#ifdef __WIN32__ - if (_compilerAvailable && _compilerDLL) ::FreeLibrary(_compilerDLL); -#endif + cleanup(); for (int i = 0; i < _breakpoints.GetSize(); i++) { @@ -219,7 +167,7 @@ void CScEngine::addError(void *data, int line, char *text) { ////////////////////////////////////////////////////////////////////////// -void WINAPI CScEngine::parseElement(void *data, int line, int type, void *elementData) { +void CScEngine::parseElement(void *data, int line, int type, void *elementData) { CBGame *Game = (CBGame *)data; if (Game) { @@ -300,32 +248,9 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i delete [] buffer; return NULL; } - - compiledNow = true; - - // publish external methods to the compiler - CALLBACKS c; - c.Dll_AddError = addError; - c.Dll_CloseFile = closeFile; - c.Dll_LoadFile = loadFile; - c.Dll_ParseElement = parseElement; - ExtSetCallbacks(&c, Game); - - // publish native interfaces - Game->PublishNatives(); - - // We have const char* everywhere but in the DLL-interfaces... - char *tempFileName = new char[strlen(filename) + 1]; - memcpy(tempFileName, filename, strlen(filename) + 1); - - setFileToCompile(filename); - compBuffer = ExtCompileFile(tempFileName, &compSize); - delete[] tempFileName; - if (!compBuffer) { - Game->quickMessage("Script compiler error. View log for details."); - delete [] buffer; - return NULL; - } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); } byte *ret = NULL; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index d49e474ea8..479c77a77a 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -132,8 +132,8 @@ public: HRESULT tick(); CScValue *_globals; CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); - bool _compilerAvailable; - HINSTANCE _compilerDLL; + static const bool _compilerAvailable = false; + CScEngine(CBGame *inGame); virtual ~CScEngine(); static void addError(void *data, int line, char *text); diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h index a4a608da46..7969e049b0 100644 --- a/engines/wintermute/dcscript.h +++ b/engines/wintermute/dcscript.h @@ -139,10 +139,10 @@ typedef enum { // compiler interface -typedef byte *(WINAPI DLL_LOAD_FILE)(void *Data, char *Filename, uint32 *Size); -typedef void (WINAPI DLL_CLOSE_FILE)(void *Data, byte *Buffer); -typedef void (WINAPI DLL_ADD_ERROR)(void *Data, int Line, char *Text); -typedef void (WINAPI DLL_PARSE_ELEMENT)(void *Data, int Line, int Type, void *ElementData); +typedef byte *(DLL_LOAD_FILE)(void *data, char *filename, uint32 *size); +typedef void (DLL_CLOSE_FILE)(void *data, byte *buffer); +typedef void (DLL_ADD_ERROR)(void *data, int line, char *text); +typedef void (DLL_PARSE_ELEMENT)(void *data, int line, int type, void *elementData); typedef struct { DLL_LOAD_FILE *Dll_LoadFile; diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 5d81ff51e9..5d4acda210 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -36,8 +36,8 @@ namespace WinterMute { class CBPersistMgr; // persistence support -typedef void *(WINAPI *PERSISTBUILD)(void); -typedef HRESULT(WINAPI *PERSISTLOAD)(void *, CBPersistMgr *); +typedef void *(*PERSISTBUILD)(void); +typedef HRESULT(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute @@ -48,9 +48,9 @@ namespace WinterMute { #define DECLARE_PERSISTENT(class_name, parent_class)\ static const char _className[];\ - static void* WINAPI persistBuild(void);\ + static void* persistBuild(void);\ virtual const char* getClassName();\ - static HRESULT WINAPI persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + static HRESULT persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ virtual HRESULT persist(CBPersistMgr* PersistMgr);\ void* operator new (size_t size);\ diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 82134f7725..efddc13614 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -35,9 +35,6 @@ #ifndef __WIN32__ -#define WINAPI -#define CALLBACK - #define PI ((float) 3.141592653589793f) #define DRGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) @@ -69,7 +66,6 @@ typedef struct tagPOINT { typedef uint32 HINSTANCE; -typedef uint32 HMODULE; typedef uint32 HWND; typedef int32 HRESULT; -- cgit v1.2.3 From 0273e495e1495d6abbcac4dde4cfa7e6ca2c29d7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 01:35:53 +0200 Subject: WINTERMUTE: Cleanup and rename functions in PlatformSDL. --- engines/wintermute/Ad/AdGame.cpp | 6 +-- engines/wintermute/Ad/AdInventoryBox.cpp | 4 +- engines/wintermute/Ad/AdResponseBox.cpp | 4 +- engines/wintermute/Ad/AdScene.cpp | 4 +- engines/wintermute/Base/BActiveRect.cpp | 10 ++-- engines/wintermute/Base/BFader.cpp | 6 +-- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 4 +- engines/wintermute/Base/BFrame.cpp | 8 +-- engines/wintermute/Base/BGame.cpp | 46 ++++++++--------- engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BRegion.cpp | 10 ++-- engines/wintermute/Base/BRenderer.cpp | 4 +- engines/wintermute/Base/BSprite.cpp | 8 +-- engines/wintermute/Base/BSubFrame.cpp | 18 +++---- engines/wintermute/Base/BTransitionMgr.cpp | 6 +-- engines/wintermute/Base/BViewport.cpp | 4 +- engines/wintermute/Base/PartEmitter.cpp | 6 +-- engines/wintermute/Base/PartParticle.cpp | 6 +-- engines/wintermute/Base/scriptables/SXFile.cpp | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 20 ++++---- engines/wintermute/Base/scriptables/ScEngine.h | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- engines/wintermute/PlatformSDL.cpp | 65 +++++++++++------------- engines/wintermute/PlatformSDL.h | 49 +++++++++--------- engines/wintermute/Sys/SysClassRegistry.cpp | 2 +- engines/wintermute/UI/UIButton.cpp | 8 +-- engines/wintermute/UI/UIEdit.cpp | 8 +-- engines/wintermute/UI/UITiledImage.cpp | 54 ++++++++++---------- engines/wintermute/UI/UIWindow.cpp | 16 +++--- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/wintermute.cpp | 8 +-- 32 files changed, 196 insertions(+), 202 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index da64c19fe9..55cb3b876b 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1925,7 +1925,7 @@ char *CAdGame::findSpeechFile(char *stringID) { ////////////////////////////////////////////////////////////////////////// bool CAdGame::validMouse() { POINT pos; - CBPlatform::GetCursorPos(&pos); + CBPlatform::getCursorPos(&pos); return _renderer->pointInViewport(&pos); } @@ -1953,7 +1953,7 @@ HRESULT CAdGame::onMouseLeftDown() { if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; _mouseLeftDown = true; - CBPlatform::SetCapture(_renderer->_window); + CBPlatform::setCapture(_renderer->_window); return S_OK; } @@ -1962,7 +1962,7 @@ HRESULT CAdGame::onMouseLeftDown() { HRESULT CAdGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - CBPlatform::ReleaseCapture(); + CBPlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 8472ab122e..81a8f7db2b 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -46,7 +46,7 @@ IMPLEMENT_PERSISTENT(CAdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - CBPlatform::SetRectEmpty(&_itemsArea); + CBPlatform::setRectEmpty(&_itemsArea); _scrollOffset = 0; _spacing = 0; _itemWidth = _itemHeight = 50; @@ -124,7 +124,7 @@ HRESULT CAdInventoryBox::display() { // display window RECT rect = _itemsArea; if (_window) { - CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); _window->display(); } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index eb9912fb14..eea61a4268 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -57,7 +57,7 @@ CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { _shieldWindow = new CUIWindow(Game); _horizontal = false; - CBPlatform::SetRectEmpty(&_responseArea); + CBPlatform::setRectEmpty(&_responseArea); _scrollOffset = 0; _spacing = 0; @@ -399,7 +399,7 @@ HRESULT CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { HRESULT CAdResponseBox::display() { RECT rect = _responseArea; if (_window) { - CBPlatform::OffsetRect(&rect, _window->_posX, _window->_posY); + CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); //_window->display(); } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 2e99b93e88..3f6d724ac4 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -485,14 +485,14 @@ HRESULT CAdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = Game->_currentTime; - while (!_pfReady && CBPlatform::GetTime() - start <= _pfMaxTime) { + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { PathFinderStep(); nu_steps++; } if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); #else uint32 start = Game->_currentTime; - while (!_pfReady && CBPlatform::GetTime() - start <= _pfMaxTime) pathFinderStep(); + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); #endif return S_OK; diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index eb4f60b0d0..86a441c317 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); _owner = NULL; _frame = NULL; _region = NULL; @@ -51,7 +51,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { _owner = owner; _frame = frame; - CBPlatform::SetRect(&_rect, x, y, x + width, y + height); + CBPlatform::setRect(&_rect, x, y, x + width, y + height); _zoomX = zoomX; _zoomY = zoomY; _precise = precise; @@ -64,8 +64,8 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, i CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { _owner = owner; _region = region; - CBPlatform::CopyRect(&_rect, ®ion->_rect); - CBPlatform::OffsetRect(&_rect, -offsetX, -offsetY); + CBPlatform::copyRect(&_rect, ®ion->_rect); + CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; @@ -101,7 +101,7 @@ void CBActiveRect::clipRect() { if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - CBPlatform::IntersectRect(&_rect, &_rect, &rc); + CBPlatform::intersectRect(&_rect, &_rect, &rc); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index 2f6a79028f..ef0208c44d 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -67,7 +67,7 @@ HRESULT CBFader::update() { uint32 time; - if (_system) time = CBPlatform::GetTime() - _startTime; + if (_system) time = CBPlatform::getTime() - _startTime; else time = Game->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; @@ -115,7 +115,7 @@ HRESULT CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::GetTime(); + if (_system) _startTime = CBPlatform::getTime(); else _startTime = Game->_timer; return S_OK; @@ -138,7 +138,7 @@ HRESULT CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::GetTime(); + if (_system) _startTime = CBPlatform::getTime(); else _startTime = Game->_timer; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 06c6055101..45c2efbdb7 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -229,7 +229,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { if (_wholeCell) tileWidth = _tileWidth; else tileWidth = _widths[c]; - CBPlatform::SetRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; if (_sprite) { _sprite->GetCurrentFrame(); diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 7eafd5fd90..e2240f28bb 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -218,7 +218,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.GetSize(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = _renderer->_forceAlphaColor; @@ -639,7 +639,7 @@ HRESULT CBFontTT::initFont() { Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::GetSystemFontPath(), PathUtil::getFileName(_fontFile)); + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = Game->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 65d2d55f6a..ebb5fe0e6c 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -170,7 +170,7 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { bool decoration = false; bool mirrorX = false; bool mirrorY = false; - CBPlatform::SetRectEmpty(&rect); + CBPlatform::setRectEmpty(&rect); char *surface_file = NULL; while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { @@ -305,7 +305,7 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (custoTrans) sub->_transparent = DRGBA(r, g, b, 0xFF); } - if (CBPlatform::IsRectEmpty(&rect)) sub->setDefaultRect(); + if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); else sub->_rect = rect; sub->_hotspotX = hotspotX; @@ -327,13 +327,13 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// bool CBFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::SetRectEmpty(rect); + CBPlatform::setRectEmpty(rect); RECT subRect; for (int i = 0; i < _subframes.GetSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::UnionRect(rect, rect, &subRect); + CBPlatform::unionRect(rect, rect, &subRect); } return true; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index bebccec08f..94f105926b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -243,7 +243,7 @@ CBGame::CBGame(): CBObject(this) { _lastCursor = NULL; - CBPlatform::SetRectEmpty(&_mouseLockRect); + CBPlatform::setRectEmpty(&_mouseLockRect); _suppressScriptErrors = false; _lastMiniUpdate = 0; @@ -336,7 +336,7 @@ CBGame::~CBGame() { _stringTable = NULL; DEBUG_DebugDisable(); - CBPlatform::OutputDebugString("--- shutting down normally ---\n"); + CBPlatform::outputDebugString("--- shutting down normally ---\n"); } @@ -560,7 +560,7 @@ void CBGame::DEBUG_DebugEnable(const char *filename) { LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - AnsiString platform = CBPlatform::GetPlatformName(); + AnsiString platform = CBPlatform::getPlatformName(); LOG(0, "Platform: %s", platform.c_str()); LOG(0, ""); } @@ -618,7 +618,7 @@ void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { HRESULT CBGame::initLoop() { _viewportSP = -1; - _currentTime = CBPlatform::GetTime(); + _currentTime = CBPlatform::getTime(); getDebugMgr()->onGameTick(); _renderer->initLoop(); @@ -1364,7 +1364,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; - CBPlatform::SetCursorPos(p.x, p.y); + CBPlatform::setCursorPos(p.x, p.y); stack->pushNULL(); return S_OK; @@ -1383,7 +1383,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (right < left) CBUtils::swap(&left, &right); if (bottom < top) CBUtils::swap(&top, &bottom); - CBPlatform::SetRect(&_mouseLockRect, left, top, right, bottom); + CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); stack->pushNULL(); return S_OK; @@ -2213,7 +2213,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::GetTime()); + _scValue->setInt((int)CBPlatform::getTime()); return _scValue; } @@ -2532,7 +2532,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Platform (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::GetPlatformName().c_str()); + _scValue->setString(CBPlatform::getPlatformName().c_str()); return _scValue; } @@ -3913,7 +3913,7 @@ HRESULT CBGame::emptySaveSlot(int slot) { char filename[MAX_PATH + 1]; getSaveSlotFilename(slot, filename); - CBPlatform::DeleteFile(filename); + CBPlatform::deleteFile(filename); return S_OK; } @@ -3971,10 +3971,10 @@ HRESULT CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { if (rect == NULL) return E_FAIL; else { if (_viewportSP >= 0) { - CBPlatform::CopyRect(rect, _viewportStack[_viewportSP]->getRect()); + CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); if (custom) *custom = true; } else { - CBPlatform::SetRect(rect, _renderer->_drawOffsetX, + CBPlatform::setRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); @@ -4025,7 +4025,7 @@ void CBGame::resetMousePos() { p.x = _mousePos.x + _renderer->_drawOffsetX; p.y = _mousePos.y + _renderer->_drawOffsetY; - CBPlatform::SetCursorPos(p.x, p.y); + CBPlatform::setCursorPos(p.x, p.y); } @@ -4049,7 +4049,7 @@ HRESULT CBGame::displayContentSimple() { HRESULT CBGame::displayIndicator() { if (_saveLoadImage) { RECT rc; - CBPlatform::SetRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } @@ -4233,7 +4233,7 @@ HRESULT CBGame::onMouseLeftDown() { if (_activeObject != NULL) _capturedObject = _activeObject; _mouseLeftDown = true; - CBPlatform::SetCapture(_renderer->_window); + CBPlatform::setCapture(_renderer->_window); return S_OK; } @@ -4242,7 +4242,7 @@ HRESULT CBGame::onMouseLeftDown() { HRESULT CBGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - CBPlatform::ReleaseCapture(); + CBPlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; @@ -4408,7 +4408,7 @@ CBDebugger *CBGame::getDebugMgr() { ////////////////////////////////////////////////////////////////////////// void CBGame::getMousePos(POINT *pos) { - CBPlatform::GetCursorPos(pos); + CBPlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; pos->y -= _renderer->_drawOffsetY; @@ -4427,7 +4427,7 @@ void CBGame::getMousePos(POINT *pos) { */ if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::PtInRect(&_mouseLockRect, *pos)) { + if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { pos->x = MAX(_mouseLockRect.left, pos->x); pos->y = MAX(_mouseLockRect.top, pos->y); @@ -4439,7 +4439,7 @@ void CBGame::getMousePos(POINT *pos) { newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; - CBPlatform::SetCursorPos(newPos.x, newPos.y); + CBPlatform::setCursorPos(newPos.x, newPos.y); } } } @@ -4448,9 +4448,9 @@ void CBGame::getMousePos(POINT *pos) { HRESULT CBGame::miniUpdate() { if (!_miniUpdateEnabled) return S_OK; - if (CBPlatform::GetTime() - _lastMiniUpdate > 200) { + if (CBPlatform::getTime() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::GetTime(); + _lastMiniUpdate = CBPlatform::getTime(); } return S_OK; } @@ -4482,14 +4482,14 @@ bool CBGame::isDoubleClick(int buttonIndex) { #endif POINT pos; - CBPlatform::GetCursorPos(&pos); + CBPlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); int moveY = abs(pos.y - _lastClick[buttonIndex].PosY); - if (_lastClick[buttonIndex].Time == 0 || CBPlatform::GetTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].Time = CBPlatform::GetTime(); + if (_lastClick[buttonIndex].Time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].Time = CBPlatform::getTime(); _lastClick[buttonIndex].PosX = pos.x; _lastClick[buttonIndex].PosY = pos.y; return false; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 6b4b0f5da2..ac45d9827a 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -65,7 +65,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _iD = Game->getSequence(); - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); _rectSet = false; _cursor = NULL; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 878b73e5e3..1b89988ba8 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -49,7 +49,7 @@ CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { _lastMimicScale = -1; _lastMimicX = _lastMimicY = INT_MIN; - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); } @@ -64,7 +64,7 @@ void CBRegion::cleanup() { for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; _points.RemoveAll(); - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; } @@ -89,7 +89,7 @@ bool CBRegion::pointInRegion(int x, int y) { rect.top = y - 1; rect.bottom = y + 2; - if (CBPlatform::PtInRect(&_rect, pt)) return ptInPolygon(x, y); + if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); else return false; } @@ -466,7 +466,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// HRESULT CBRegion::getBoundingRect(RECT *rect) { - if (_points.GetSize() == 0) CBPlatform::SetRectEmpty(rect); + if (_points.GetSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -477,7 +477,7 @@ HRESULT CBRegion::getBoundingRect(RECT *rect) { MaxX = MAX(MaxX, _points[i]->x); MaxY = MAX(MaxY, _points[i]->y); } - CBPlatform::SetRect(rect, MinX, MinY, MaxX, MaxY); + CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); } return S_OK; } diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index e7d5ec55cb..6708fb65b9 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -47,7 +47,7 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { _forceAlphaColor = 0x00; _width = _height = _bPP = 0; - CBPlatform::SetRectEmpty(&_monitorRect); + CBPlatform::setRectEmpty(&_monitorRect); _realWidth = _realHeight = 0; _drawOffsetX = _drawOffsetY = 0; @@ -74,7 +74,7 @@ CBObject *CBRenderer::getObjectAt(int x, int y) { point.y = y; for (int i = _rectList.GetSize() - 1; i >= 0; i--) { - if (CBPlatform::PtInRect(&_rectList[i]->_rect, point)) { + if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 0b12e2cb5a..e022d75d84 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -146,7 +146,7 @@ HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType delete frame; delete subframe; } else { - CBPlatform::SetRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); frame->_subframes.Add(subframe); _frames.Add(frame); _currentFrame = 0; @@ -416,13 +416,13 @@ CBSurface *CBSprite::getSurface() { bool CBSprite::GetBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::SetRectEmpty(rect); + CBPlatform::setRectEmpty(rect); for (int i = 0; i < _frames.GetSize(); i++) { RECT frame; RECT temp; - CBPlatform::CopyRect(&temp, rect); + CBPlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::UnionRect(rect, &temp, &frame); + CBPlatform::unionRect(rect, &temp, &frame); } return true; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 182a2b0e37..36eb2f4063 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -49,7 +49,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { _alpha = 0xFFFFFFFF; _transparent = 0xFFFF00FF; - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); _editorSelected = false; @@ -114,7 +114,7 @@ HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; - CBPlatform::SetRectEmpty(&rect); + CBPlatform::setRectEmpty(&rect); char *surfaceFile = NULL; delete _surface; @@ -196,7 +196,7 @@ HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return E_FAIL; } */ - if (CBPlatform::IsRectEmpty(&rect)) setDefaultRect(); + if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); else _rect = rect; return S_OK; @@ -239,7 +239,7 @@ bool CBSubFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; - CBPlatform::SetRect(rect, + CBPlatform::setRect(rect, (int)(x - _hotspotX * ratioX), (int)(y - _hotspotY * ratioY), (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), @@ -260,9 +260,9 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); RECT rect; - CBPlatform::SetRectEmpty(&rect); - if (_surface) CBPlatform::SetRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::EqualRect(&rect, &_rect)) + CBPlatform::setRectEmpty(&rect); + if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!CBPlatform::equalRect(&rect, &_rect)) buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) @@ -304,8 +304,8 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { ////////////////////////////////////////////////////////////////////////// void CBSubFrame::setDefaultRect() { if (_surface) { - CBPlatform::SetRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else CBPlatform::setRectEmpty(&_rect); } diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index dd20e6b687..f2da9b7351 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -87,7 +87,7 @@ HRESULT CBTransitionMgr::update() { if (!_started) { _started = true; - _lastTime = CBPlatform::GetTime(); + _lastTime = CBPlatform::getTime(); } switch (_type) { @@ -96,7 +96,7 @@ HRESULT CBTransitionMgr::update() { break; case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::GetTime() - _lastTime; + uint32 time = CBPlatform::getTime() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); Game->_renderer->fade((uint16)alpha); @@ -107,7 +107,7 @@ HRESULT CBTransitionMgr::update() { break; case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::GetTime() - _lastTime; + uint32 time = CBPlatform::getTime() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); Game->_renderer->fade((uint16)alpha); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index 8292f5e145..64e138cb33 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -36,7 +36,7 @@ IMPLEMENT_PERSISTENT(CBViewport, false) ////////////////////////////////////////////////////////////////////////// CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::SetRectEmpty(&_rect); + CBPlatform::setRectEmpty(&_rect); _mainObject = NULL; _offsetX = _offsetY = 0; } @@ -71,7 +71,7 @@ HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool noChe bottom = MIN(bottom, Game->_renderer->_height); } - CBPlatform::SetRect(&_rect, left, top, right, bottom); + CBPlatform::setRect(&_rect, left, top, right, bottom); _offsetX = left; _offsetY = top; return S_OK; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index d3d7843f57..ca19651ac9 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -49,7 +49,7 @@ IMPLEMENT_PERSISTENT(CPartEmitter, false) CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { _width = _height = 0; - CBPlatform::SetRectEmpty(&_border); + CBPlatform::setRectEmpty(&_border); _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; _angle1 = _angle2 = 0; @@ -178,7 +178,7 @@ HRESULT CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); - if (!CBPlatform::IsRectEmpty(&_border)) { + if (!CBPlatform::isRectEmpty(&_border)) { int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); @@ -347,7 +347,7 @@ int CPartEmitter::compareZ(const void *obj1, const void *obj2) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::SetRect(&_border, x, y, x + width, y + height); + CBPlatform::setRect(&_border, x, y, x + width, y + height); return S_OK; } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 956c9bf2df..f69446f36f 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -48,7 +48,7 @@ CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { _creationTime = 0; _lifeTime = 0; _isDead = true; - CBPlatform::SetRectEmpty(&_border); + CBPlatform::setRectEmpty(&_border); _state = PARTICLE_NORMAL; _fadeStart = 0; @@ -123,11 +123,11 @@ HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 } // particle hit the border - if (!_isDead && !CBPlatform::IsRectEmpty(&_border)) { + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { POINT p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!CBPlatform::PtInRect(&_border, p)) + if (!CBPlatform::ptInRect(&_border, p)) fadeOut(currentTime, emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return S_OK; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index b29c82853b..83e9302678 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -187,7 +187,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); close(); - stack->pushBool(CBPlatform::DeleteFile(_filename) != false); + stack->pushBool(CBPlatform::deleteFile(_filename) != false); return S_OK; } @@ -200,7 +200,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this bool Overwrite = stack->pop()->getBool(true); close(); - stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index b70f04f568..9b51cb2fe2 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -218,7 +218,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i if (!ignoreCache) { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::GetTime(); + _cachedScripts[i]->_timestamp = CBPlatform::getTime(); *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } @@ -259,7 +259,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = CBPlatform::GetTime(); + uint32 MinTime = CBPlatform::getTime(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; @@ -320,7 +320,7 @@ HRESULT CScEngine::tick() { case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::GetTime()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); } else { if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->run(); } @@ -359,25 +359,25 @@ HRESULT CScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::GetTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::GetTime() - StartTime < _scripts[i]->_timeSlice) { + uint32 StartTime = CBPlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); } // normal script else { uint32 StartTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) StartTime = CBPlatform::GetTime(); + if (isProfiling) StartTime = CBPlatform::getTime(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::GetTime() - StartTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); } _currentScript = NULL; } @@ -740,7 +740,7 @@ void CScEngine::enableProfiling() { // destroy old data, if any _scriptTimes.clear(); - _profilingStartTime = CBPlatform::GetTime(); + _profilingStartTime = CBPlatform::getTime(); _isProfiling = true; } @@ -757,7 +757,7 @@ void CScEngine::disableProfiling() { ////////////////////////////////////////////////////////////////////////// void CScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::GetTime() - _profilingStartTime; + /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 479c77a77a..6b290e4e94 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -58,7 +58,7 @@ public: class CScCachedScript { public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::GetTime(); + _timestamp = CBPlatform::getTime(); _buffer = new byte[size]; if (_buffer) memcpy(_buffer, buffer, size); _size = size; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 6c7f7d0a05..180d3d884b 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1148,7 +1148,7 @@ HRESULT CScScript::sleep(uint32 duration) { _state = SCRIPT_SLEEPING; if (Game->_state == GAME_FROZEN) { - _waitTime = CBPlatform::GetTime() + duration; + _waitTime = CBPlatform::getTime() + duration; _waitFrozen = true; } else { _waitTime = Game->_timer + duration; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index ff839bb637..b31c825244 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -43,13 +43,13 @@ namespace WinterMute { CBGame *CBPlatform::Game = NULL; #define CLASS_NAME "GF_FRAME" -int CBPlatform::Initialize(CBGame *inGame, int argc, char *argv[]) { +int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) { Game = inGame; return true; } ////////////////////////////////////////////////////////////////////////// -void CBPlatform::HandleEvent(Common::Event *event) { +void CBPlatform::handleEvent(Common::Event *event) { switch (event->type) { case Common::EVENT_LBUTTONDOWN: @@ -166,12 +166,7 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // Win32 API bindings ////////////////////////////////////////////////////////////////////////// -HINSTANCE CBPlatform::ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBPlatform::OutputDebugString(LPCSTR lpOutputString) { +void CBPlatform::outputDebugString(LPCSTR lpOutputString) { /* #ifdef __WIN32__ ::OutputDebugString(lpOutputString); @@ -181,12 +176,12 @@ void CBPlatform::OutputDebugString(LPCSTR lpOutputString) { ////////////////////////////////////////////////////////////////////////// -uint32 CBPlatform::GetTime() { +uint32 CBPlatform::getTime() { return g_system->getMillis(); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::GetCursorPos(LPPOINT lpPoint) { +bool CBPlatform::getCursorPos(LPPOINT lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); @@ -199,7 +194,7 @@ bool CBPlatform::GetCursorPos(LPPOINT lpPoint) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::SetCursorPos(int X, int Y) { +bool CBPlatform::setCursorPos(int X, int Y) { CBRenderSDL *renderer = static_cast(Game->_renderer); POINT p; @@ -212,19 +207,19 @@ bool CBPlatform::SetCursorPos(int X, int Y) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ShowWindow(HWND hWnd, int nCmdShow) { +bool CBPlatform::showWindow(HWND hWnd, int nCmdShow) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::DeleteFile(const char *lpFileName) { +bool CBPlatform::deleteFile(const char *lpFileName) { return remove(lpFileName) ? true : false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::CopyFile(const char *from, const char *to, bool failIfExists) { +bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { // try { - warning("CBPlatform::CopyFile(%s, %s, %d) - not implemented", from, to, failIfExists); + warning("CBPlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); return false; // if (failIfExists && boost::filesystem::exists(to)) return false; // boost::filesystem::copy_file(from, to); @@ -235,38 +230,38 @@ bool CBPlatform::CopyFile(const char *from, const char *to, bool failIfExists) { } ////////////////////////////////////////////////////////////////////////// -HWND CBPlatform::SetCapture(HWND hWnd) { +HWND CBPlatform::setCapture(HWND hWnd) { return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ReleaseCapture() { +bool CBPlatform::releaseCapture() { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::SetForegroundWindow(HWND hWnd) { +bool CBPlatform::setForegroundWindow(HWND hWnd) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::SetRectEmpty(LPRECT lprc) { +bool CBPlatform::setRectEmpty(LPRECT lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; return true; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::IsRectEmpty(const LPRECT lprc) { +bool CBPlatform::isRectEmpty(const LPRECT lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::PtInRect(LPRECT lprc, POINT p) { +bool CBPlatform::ptInRect(LPRECT lprc, POINT p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::SetRect(LPRECT lprc, int left, int top, int right, int bottom) { +bool CBPlatform::setRect(LPRECT lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; @@ -276,11 +271,11 @@ bool CBPlatform::SetRect(LPRECT lprc, int left, int top, int right, int bottom) } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2) { - if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) || +bool CBPlatform::intersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2) { + if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { - SetRectEmpty(lprcDst); + setRectEmpty(lprcDst); return false; } lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); @@ -292,16 +287,16 @@ bool CBPlatform::IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRE } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { - if (IsRectEmpty(lprcSrc1)) { - if (IsRectEmpty(lprcSrc2)) { - SetRectEmpty(lprcDst); +bool CBPlatform::unionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { + if (isRectEmpty(lprcSrc1)) { + if (isRectEmpty(lprcSrc2)) { + setRectEmpty(lprcDst); return false; } else { *lprcDst = *lprcSrc2; } } else { - if (IsRectEmpty(lprcSrc2)) { + if (isRectEmpty(lprcSrc2)) { *lprcDst = *lprcSrc1; } else { lprcDst->left = MIN(lprcSrc1->left, lprcSrc2->left); @@ -315,7 +310,7 @@ bool CBPlatform::UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::CopyRect(LPRECT lprcDst, RECT *lprcSrc) { +bool CBPlatform::copyRect(LPRECT lprcDst, RECT *lprcSrc) { if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; @@ -323,7 +318,7 @@ bool CBPlatform::CopyRect(LPRECT lprcDst, RECT *lprcSrc) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::OffsetRect(LPRECT lprc, int dx, int dy) { +bool CBPlatform::offsetRect(LPRECT lprc, int dx, int dy) { if (lprc == NULL) return false; lprc->left += dx; @@ -335,13 +330,13 @@ bool CBPlatform::OffsetRect(LPRECT lprc, int dx, int dy) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::EqualRect(LPRECT rect1, LPRECT rect2) { +bool CBPlatform::equalRect(LPRECT rect1, LPRECT rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } ////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::GetSystemFontPath() { +AnsiString CBPlatform::getSystemFontPath() { #ifdef __WIN32__ // we're looking for something like "c:\windows\fonts\"; char winDir[MAX_PATH + 1]; @@ -356,7 +351,7 @@ AnsiString CBPlatform::GetSystemFontPath() { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::GetPlatformName() { +AnsiString CBPlatform::getPlatformName() { // TODO: Should conform to the WME-spec. //return AnsiString(SDL_GetPlatform()); return AnsiString("ScummVM"); diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 6adba29ae8..9b567c8b30 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -41,34 +41,33 @@ class CBGame; ////////////////////////////////////////////////////////////////////////// class CBPlatform { public: - static int Initialize(CBGame *inGame, int argc, char *argv[]); - static void HandleEvent(Common::Event *event); + static int initialize(CBGame *inGame, int argc, char *argv[]); + static void handleEvent(Common::Event *event); - static AnsiString GetSystemFontPath(); - static AnsiString GetPlatformName(); + static AnsiString getSystemFontPath(); + static AnsiString getPlatformName(); // Win32 API bindings - static HINSTANCE ShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int nShowCmd); - static void OutputDebugString(LPCSTR lpOutputString); - static uint32 GetTime(); - static bool GetCursorPos(LPPOINT lpPoint); - static bool SetCursorPos(int X, int Y); - static bool ShowWindow(HWND hWnd, int nCmdShow); - static bool DeleteFile(const char *lpFileName); - static bool CopyFile(const char *from, const char *to, bool failIfExists); - static HWND SetCapture(HWND hWnd); - static bool ReleaseCapture(); - static bool SetForegroundWindow(HWND hWnd); - - static bool SetRectEmpty(LPRECT lprc); - static bool IsRectEmpty(const LPRECT lprc); - static bool PtInRect(LPRECT lprc, POINT p); - static bool SetRect(LPRECT lprc, int left, int top, int right, int bottom); - static bool IntersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); - static bool UnionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); - static bool CopyRect(LPRECT lprcDst, RECT *lprcSrc); - static bool OffsetRect(LPRECT lprc, int dx, int dy); - static bool EqualRect(LPRECT rect1, LPRECT rect2); + static void outputDebugString(LPCSTR lpOutputString); + static uint32 getTime(); + static bool getCursorPos(LPPOINT lpPoint); + static bool setCursorPos(int X, int Y); + static bool showWindow(HWND hWnd, int nCmdShow); + static bool deleteFile(const char *lpFileName); + static bool copyFile(const char *from, const char *to, bool failIfExists); + static HWND setCapture(HWND hWnd); + static bool releaseCapture(); + static bool setForegroundWindow(HWND hWnd); + + static bool setRectEmpty(LPRECT lprc); + static bool isRectEmpty(const LPRECT lprc); + static bool ptInRect(LPRECT lprc, POINT p); + static bool setRect(LPRECT lprc, int left, int top, int right, int bottom); + static bool intersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); + static bool unionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); + static bool copyRect(LPRECT lprcDst, RECT *lprcSrc); + static bool offsetRect(LPRECT lprc, int dx, int dy); + static bool equalRect(LPRECT rect1, LPRECT rect2); // string functions diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index d9441c20e4..59528f13f1 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -80,7 +80,7 @@ bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { if (classObj->getNumInstances() != 0) { char str[MAX_PATH]; sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - CBPlatform::OutputDebugString(str); + CBPlatform::outputDebugString(str); } _classes.erase(it); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index b5f22b29fc..ce432d8f4a 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -586,12 +586,12 @@ HRESULT CUIButton::display(int offsetX, int offsetY) { CBFont *font = 0; //RECT rect; - //CBPlatform::SetRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::PtInRect(&rect, Game->_mousePos)!=FALSE); + //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && CBPlatform::ptInRect(&rect, Game->_mousePos)!=FALSE); _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !Game->_mouseLeftDown) || - (_oneTimePress && CBPlatform::GetTime() - _oneTimePressTime >= 100)) press(); + (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); if (_disable) { @@ -908,7 +908,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_visible && !_disable) { _oneTimePress = true; - _oneTimePressTime = CBPlatform::GetTime(); + _oneTimePressTime = CBPlatform::getTime(); } stack->pushNULL(); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index c1971b342d..0aac35a366 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -633,8 +633,8 @@ HRESULT CUIEdit::display(int offsetX, int offsetY) { // cursor if (focused && curFirst) { if (Count) { - if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::GetTime(); + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) @@ -656,8 +656,8 @@ HRESULT CUIEdit::display(int offsetX, int offsetY) { // cursor if (focused && !curFirst) { if (Count) { - if (CBPlatform::GetTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::GetTime(); + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 05426bd01c..4b115c98e3 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -44,15 +44,15 @@ IMPLEMENT_PERSISTENT(CUITiledImage, false) CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { _image = NULL; - CBPlatform::SetRectEmpty(&_upLeft); - CBPlatform::SetRectEmpty(&_upMiddle); - CBPlatform::SetRectEmpty(&_upRight); - CBPlatform::SetRectEmpty(&_middleLeft); - CBPlatform::SetRectEmpty(&_middleMiddle); - CBPlatform::SetRectEmpty(&_middleRight); - CBPlatform::SetRectEmpty(&_downLeft); - CBPlatform::SetRectEmpty(&_downMiddle); - CBPlatform::SetRectEmpty(&_downRight); + CBPlatform::setRectEmpty(&_upLeft); + CBPlatform::setRectEmpty(&_upMiddle); + CBPlatform::setRectEmpty(&_upRight); + CBPlatform::setRectEmpty(&_middleLeft); + CBPlatform::setRectEmpty(&_middleMiddle); + CBPlatform::setRectEmpty(&_middleRight); + CBPlatform::setRectEmpty(&_downLeft); + CBPlatform::setRectEmpty(&_downMiddle); + CBPlatform::setRectEmpty(&_downRight); } @@ -270,19 +270,19 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { if (vTiles && hTiles) { // up row - CBPlatform::SetRect(&_upLeft, 0, 0, h1, v1); - CBPlatform::SetRect(&_upMiddle, h1, 0, h1 + h2, v1); - CBPlatform::SetRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); + CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); + CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); + CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); // middle row - CBPlatform::SetRect(&_middleLeft, 0, v1, h1, v1 + v2); - CBPlatform::SetRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); - CBPlatform::SetRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); + CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); + CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); + CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); // down row - CBPlatform::SetRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); - CBPlatform::SetRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); - CBPlatform::SetRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); + CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); + CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); + CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); } // default @@ -290,17 +290,17 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { int width = _image->_surface->getWidth() / 3; int height = _image->_surface->getHeight() / 3; - if (CBPlatform::IsRectEmpty(&_upLeft)) CBPlatform::SetRect(&_upLeft, 0, 0, width, height); - if (CBPlatform::IsRectEmpty(&_upMiddle)) CBPlatform::SetRect(&_upMiddle, width, 0, 2 * width, height); - if (CBPlatform::IsRectEmpty(&_upRight)) CBPlatform::SetRect(&_upRight, 2 * width, 0, 3 * width, height); + if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); + if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); - if (CBPlatform::IsRectEmpty(&_middleLeft)) CBPlatform::SetRect(&_middleLeft, 0, height, width, 2 * height); - if (CBPlatform::IsRectEmpty(&_middleMiddle)) CBPlatform::SetRect(&_middleMiddle, width, height, 2 * width, 2 * height); - if (CBPlatform::IsRectEmpty(&_middleRight)) CBPlatform::SetRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); - if (CBPlatform::IsRectEmpty(&_downLeft)) CBPlatform::SetRect(&_downLeft, 0, 2 * height, width, 3 * height); - if (CBPlatform::IsRectEmpty(&_downMiddle)) CBPlatform::SetRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); - if (CBPlatform::IsRectEmpty(&_downRight)) CBPlatform::SetRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); } return S_OK; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 5d1bf05bfb..c93a00402b 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -54,8 +54,8 @@ IMPLEMENT_PERSISTENT(CUIWindow, false) ////////////////////////////////////////////////////////////////////////// CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::SetRectEmpty(&_titleRect); - CBPlatform::SetRectEmpty(&_dragRect); + CBPlatform::setRectEmpty(&_titleRect); + CBPlatform::setRectEmpty(&_dragRect); _titleAlign = TAL_LEFT; _transparent = false; @@ -185,7 +185,7 @@ HRESULT CUIWindow::display(int offsetX, int offsetY) { if (image) image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); - if (!CBPlatform::IsRectEmpty(&_titleRect) && font && _text) { + if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } @@ -621,11 +621,11 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } - if (!CBPlatform::IsRectEmpty(&_titleRect)) { + if (!CBPlatform::isRectEmpty(&_titleRect)) { buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } - if (!CBPlatform::IsRectEmpty(&_dragRect)) { + if (!CBPlatform::isRectEmpty(&_dragRect)) { buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } @@ -1132,15 +1132,15 @@ HRESULT CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { HRESULT res = CUIObject::handleMouse(event, button); // handle window dragging - if (!CBPlatform::IsRectEmpty(&_dragRect)) { + if (!CBPlatform::isRectEmpty(&_dragRect)) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { RECT dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); - CBPlatform::OffsetRect(&dragRect, _posX + offsetX, _posY + offsetY); + CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - if (CBPlatform::PtInRect(&dragRect, Game->_mousePos)) { + if (CBPlatform::ptInRect(&dragRect, Game->_mousePos)) { _dragFrom.x = Game->_mousePos.x; _dragFrom.y = Game->_mousePos.y; _dragging = true; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index b8a9886105..f1c3de9283 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -656,7 +656,7 @@ HRESULT CVidTheoraPlayer::display(uint32 alpha) { HRESULT res; if (_texture && _videoFrameReady) { - CBPlatform::SetRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); + CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); } else res = E_FAIL; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 4d56b3c69e..2d1f1fdf00 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -142,7 +142,7 @@ int WinterMuteEngine::init() { _game = new CAdGame; if (!_game) return 1; - CBPlatform::Initialize(_game, 0, NULL); + CBPlatform::initialize(_game, 0, NULL); bool windowedMode = !ConfMan.getBool("fullscreen"); @@ -231,7 +231,7 @@ int WinterMuteEngine::init() { // load game - uint32 DataInitStart = CBPlatform::GetTime(); + uint32 DataInitStart = CBPlatform::getTime(); if (FAILED(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); @@ -243,7 +243,7 @@ int WinterMuteEngine::init() { _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; - _game->LOG(0, "Engine initialized in %d ms", CBPlatform::GetTime() - DataInitStart); + _game->LOG(0, "Engine initialized in %d ms", CBPlatform::getTime() - DataInitStart); _game->LOG(0, ""); if (ConfMan.hasKey("save_slot")) { @@ -273,7 +273,7 @@ int WinterMuteEngine::messageLoop() { while (!done) { Common::Event event; while (_system->getEventManager()->pollEvent(event)) { - CBPlatform::HandleEvent(&event); + CBPlatform::handleEvent(&event); } if (_game && _game->_renderer->_active && _game->_renderer->_ready) { -- cgit v1.2.3 From 5224ebef2c8013bc9ff5cc6f9bdefbcf635b456c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 02:50:15 +0200 Subject: WINTERMUTE: Silence most warnings --- engines/wintermute/Ad/AdActor.cpp | 2 +- engines/wintermute/Ad/AdGame.cpp | 12 ++++++------ engines/wintermute/Ad/AdScene.cpp | 14 +++++++------- engines/wintermute/Ad/AdSpriteSet.cpp | 2 +- engines/wintermute/Base/BFileManager.cpp | 4 ++-- engines/wintermute/Base/BFileManager.h | 2 +- engines/wintermute/Base/BFontBitmap.cpp | 6 ++---- engines/wintermute/Base/BFontTT.cpp | 8 ++++---- engines/wintermute/Base/BGame.cpp | 8 ++++---- engines/wintermute/Base/BObject.cpp | 2 +- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BParser.cpp | 4 ++-- engines/wintermute/Base/BParser.h | 8 ++++---- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Base/BRenderSDL.cpp | 5 +---- engines/wintermute/Base/BSoundBuffer.cpp | 2 +- engines/wintermute/Base/BStringTable.cpp | 8 ++++---- engines/wintermute/Base/BSurfaceSDL.cpp | 4 ++-- engines/wintermute/Base/BTransitionMgr.cpp | 3 ++- engines/wintermute/Base/PartEmitter.cpp | 4 ++-- engines/wintermute/Base/PartParticle.cpp | 12 ++++++------ engines/wintermute/Base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 12 ++++++------ engines/wintermute/Base/scriptables/SXFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXStore.cpp | 6 +++--- engines/wintermute/Base/scriptables/SXString.cpp | 4 ++-- engines/wintermute/Base/scriptables/ScEngine.cpp | 11 +++++------ engines/wintermute/Base/scriptables/ScEngine.h | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 10 +++++----- engines/wintermute/Base/scriptables/ScScript.h | 4 ++-- engines/wintermute/Base/scriptables/ScStack.cpp | 2 +- engines/wintermute/Sys/SysClassRegistry.cpp | 4 ++-- engines/wintermute/UI/UIObject.cpp | 4 ++-- engines/wintermute/wintermute.cpp | 2 +- 34 files changed, 87 insertions(+), 92 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 821c66f6fc..b07e444439 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -796,7 +796,7 @@ void CAdActor::getNextStep() { maxStepX--; } - if (((CAdGame *)Game)->_scene->isBlockedAt(_pFX, _pFY, true, this)) { + if (((CAdGame *)Game)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { if (_pFCount == 0) { _state = _nextState; _nextState = STATE_READY; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 55cb3b876b..3485b3eecd 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1672,9 +1672,9 @@ HRESULT CAdGame::resetResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::displayContent(bool update, bool displayAll) { +HRESULT CAdGame::displayContent(bool doUpdate, bool displayAll) { // init - if (update) initLoop(); + if (doUpdate) initLoop(); // fill black _renderer->fill(0, 0, 0); @@ -1682,11 +1682,11 @@ HRESULT CAdGame::displayContent(bool update, bool displayAll) { // playing exclusive video? if (_videoPlayer->isPlaying()) { - if (update) _videoPlayer->update(); + if (doUpdate) _videoPlayer->update(); _videoPlayer->display(); } else if (_theoraPlayer) { if (_theoraPlayer->isPlaying()) { - if (update) _theoraPlayer->update(); + if (doUpdate) _theoraPlayer->update(); _theoraPlayer->display(); } if (_theoraPlayer->isFinished()) { @@ -1696,7 +1696,7 @@ HRESULT CAdGame::displayContent(bool update, bool displayAll) { } else { // process scripts - if (update) _scEngine->tick(); + if (doUpdate) _scEngine->tick(); POINT p; getMousePos(&p); @@ -1712,7 +1712,7 @@ HRESULT CAdGame::displayContent(bool update, bool displayAll) { if (_indicatorDisplay) displayIndicator(); - if (update || displayAll) { + if (doUpdate || displayAll) { // display normal windows displayWindows(false); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 3f6d724ac4..fe8295abad 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -856,7 +856,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::traverseNodes(bool update) { +HRESULT CAdScene::traverseNodes(bool doUpdate) { if (!_initialized) return S_OK; int j, k; @@ -877,7 +877,7 @@ HRESULT CAdScene::traverseNodes(bool update) { ////////////////////////////////////////////////////////////////////////// // *** adjust scroll offset - if (update) { + if (doUpdate) { /* if (_autoScroll && Game->_mainObject != NULL) { @@ -947,7 +947,7 @@ HRESULT CAdScene::traverseNodes(bool update) { if (!_layers[j]->_active) continue; // make layer exclusive - if (!update) { + if (!doUpdate) { if (_layers[j]->_closeUp && !Game->_editorMode) { if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); if (_shieldWindow) { @@ -984,7 +984,7 @@ HRESULT CAdScene::traverseNodes(bool update) { if (node->_entity->_active && (Game->_editorMode || !node->_entity->_editorOnly)) { Game->_renderer->setup2D(); - if (update) node->_entity->update(); + if (doUpdate) node->_entity->update(); else node->_entity->display(); } break; @@ -993,7 +993,7 @@ HRESULT CAdScene::traverseNodes(bool update) { if (node->_region->_blocked) break; if (node->_region->_decoration) break; - if (!update) displayRegionContent(node->_region); + if (!doUpdate) displayRegionContent(node->_region); } break; default: @@ -1004,7 +1004,7 @@ HRESULT CAdScene::traverseNodes(bool update) { // display/update all objects which are off-regions if (_layers[j]->_main) { - if (update) { + if (doUpdate) { updateFreeObjects(); } else { displayRegionContent(NULL); @@ -1019,7 +1019,7 @@ HRESULT CAdScene::traverseNodes(bool update) { // display/update fader if (_fader) { - if (update) _fader->update(); + if (doUpdate) _fader->update(); else _fader->display(); } diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 296511491d..c02ba32ea1 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -237,7 +237,7 @@ CBSprite *CAdSpriteSet::getSprite(TDirection direction) { // find nearest set sprite int numSteps = 0; - for (int i = dir, NumSteps = 0; i >= 0; i--) { + for (int i = dir; i >= 0; i--) { if (_sprites[i] != NULL) { ret = _sprites[i]; numSteps = dir - i; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 19f162315d..fdb43e28f5 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -140,7 +140,7 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, return NULL; } - if (file->read(buffer, file->size()) != file->size()) { + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { Game->LOG(0, "Error reading file '%s'", filename.c_str()); closeFile(file); delete [] buffer; @@ -224,7 +224,7 @@ HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, ui ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::requestCD(int cd, char *packageFile, char *filename) { +HRESULT CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (int i = 0; i < _packages.GetSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 1b5c50c127..2c7415642f 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -62,7 +62,7 @@ public: PATH_PACKAGE, PATH_SINGLE } TPathType; HRESULT addPath(TPathType type, const Common::String &path); - HRESULT requestCD(int cd, char *packageFile, char *filename); + HRESULT requestCD(int cd, char *packageFile, const char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); HRESULT saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 45c2efbdb7..4e01134a9a 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -92,8 +92,8 @@ int CBFontBitmap::getTextWidth(byte *text, int maxLength) { str = AnsiString((char *)text); } - if (maxLength >= 0 && str.size() > maxLength) - str = Common::String(str.c_str(), maxLength); + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; @@ -111,8 +111,6 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign if (text == NULL || text[0] == '\0') return _tileHeight; - - AnsiString str; if (Game->_textEncoding == TEXT_UTF8) { diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index e2240f28bb..353620bc24 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -126,8 +126,8 @@ int CBFontTT::getTextWidth(byte *text, int maxLength) { if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); else textStr = StringUtil::ansiToWide((char *)text); - if (maxLength >= 0 && textStr.size() > maxLength) - textStr = Common::String(textStr.c_str(), maxLength); + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; @@ -161,8 +161,8 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ - if (maxLength >= 0 && textStr.size() > maxLength) - textStr = Common::String(textStr.c_str(), maxLength); + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 94f105926b..def660274a 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1779,7 +1779,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS byte blue = stack->pop()->getInt(0); byte alpha = stack->pop()->getInt(0xFF); - bool System = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(DRGBA(red, green, blue, alpha), duration, system); if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); @@ -4030,7 +4030,7 @@ void CBGame::resetMousePos() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayContent(bool update, bool displayAll) { +HRESULT CBGame::displayContent(bool doUpdate, bool displayAll) { return S_OK; } @@ -4108,8 +4108,8 @@ HRESULT CBGame::updateMusicCrossfade() { } else { //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolume(100 - (float)currentTime / (float)_musicCrossfadeLength * 100); - _music[_musicCrossfadeChannel2]->setVolume((float)currentTime / (float)_musicCrossfadeLength * 100); + _music[_musicCrossfadeChannel1]->setVolume((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolume((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index ac45d9827a..af688a4514 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -152,7 +152,7 @@ void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Ca ////////////////////////////////////////////////////////////////////////// -char *CBObject::getCaption(int caseVal) { +const char *CBObject::getCaption(int caseVal) { if (caseVal == 0) caseVal = 1; if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) return ""; diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 48d2ea667b..db2bd2f290 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -86,7 +86,7 @@ public: HRESULT setCursor(const char *filename); HRESULT setActiveCursor(const char *filename); HRESULT cleanup(); - char *getCaption(int caseVal = 1); + const char *getCaption(int caseVal = 1); void setCaption(const char *caption, int caseVal = 1); bool _editorSelected; bool _editorAlwaysRegister; diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp index 4354c5620d..45c0577f92 100644 --- a/engines/wintermute/Base/BParser.cpp +++ b/engines/wintermute/Base/BParser.cpp @@ -62,7 +62,7 @@ char *CBParser::getLastOffender() { ////////////////////////////////////////////////////////////////////// -long CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -113,7 +113,7 @@ long CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data ////////////////////////////////////////////////////////////////////// -long CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; Game->miniUpdate(); char *name; diff --git a/engines/wintermute/Base/BParser.h b/engines/wintermute/Base/BParser.h index f5aa0393e7..01d40067cc 100644 --- a/engines/wintermute/Base/BParser.h +++ b/engines/wintermute/Base/BParser.h @@ -60,13 +60,13 @@ namespace WinterMute { class CBParser : public CBBase { public: struct TokenDesc { - long id; - const char *token; + int32 id; + const char *token; }; public: int scanStr(const char *in, const char *format, ...); - long getCommand(char **buf, TokenDesc *tokens, char **params); + int32 getCommand(char **buf, TokenDesc *tokens, char **params); CBParser(CBGame *inGame = NULL); virtual ~CBParser(); private: @@ -78,7 +78,7 @@ private: char *getAssignmentText(char **buf); char *getSubText(char **buf, char open, char close); void skipCharacters(char **buf, const char *toSkip); - long getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); int _parserLine; char _lastOffender[255]; char *_whiteSpace; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 01ebb596b9..6491e821ae 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -400,7 +400,7 @@ Common::String CBPersistMgr::getStringObj() { Common::String retString = ret; - if (ret == "(null)") { + if (retString == "(null)") { retString = ""; } diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index e156a76002..b6de4e2bf5 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -46,7 +46,7 @@ RenderTicket::RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, C _colorMod = 0; if (surf) { _surface = new Graphics::Surface(); - _surface->create(srcRect->width(), srcRect->height(), surf->format); + _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); assert(_surface->format.bytesPerPixel == 4); // Get a clipped copy of the surface for (int i = 0; i < _surface->h; i++) { @@ -362,8 +362,6 @@ void CBRenderSDL::invalidateTicketsFromSurface(CBSurfaceSDL *surf) { void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { renderTicket->_wantsDraw = true; - // New item - uint32 size = _renderQueue.size(); // A new item always has _drawNum == 0 if (renderTicket->_drawNum == 0) { // In-order @@ -425,7 +423,6 @@ void CBRenderSDL::drawTickets() { if (!_dirtyRect) return; RenderQueueIterator it = _renderQueue.begin(); - uint32 size = _renderQueue.size(); // Clean out the old tickets while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false) { diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 92881ab01a..40793efc98 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -349,7 +349,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void ////////////////////////////////////////////////////////////////////////// HRESULT CBSoundBuffer::setPan(float pan) { if (_stream) { - g_system->getMixer()->setChannelBalance(*_handle, pan * 127); + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } return S_OK; } diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index ed33e4d776..00e791dc5e 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -181,7 +181,7 @@ HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { return E_FAIL; } - int pos = 0; + uint32 pos = 0; if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { pos += 3; @@ -192,12 +192,12 @@ HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { } } else Game->_textEncoding = TEXT_ANSI; - int lineLength = 0; + uint32 lineLength = 0; while (pos < size) { lineLength = 0; while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); char *line = new char[realLength + 1]; strncpy(line, (char *)&buffer[pos], realLength); line[realLength] = '\0'; @@ -208,7 +208,7 @@ HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { if (value != NULL) { value[0] = '\0'; value++; - for (int i = 0; i < strlen(value); i++) { + for (uint32 i = 0; i < strlen(value); i++) { if (value[i] == '|') value[i] = '\n'; } addString(line, value, clearOld); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 67304db0af..de61d638a0 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -505,8 +505,8 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zo position.top = 0; // TODO: Something is wrong } - position.setWidth((float)srcRect.width() * zoomX / 100.f); - position.setHeight((float)srcRect.height() * zoomX / 100.f); + position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); + position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); renderer->modTargetRect(&position); diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index f2da9b7351..02d6891528 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -70,7 +70,8 @@ HRESULT CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { _preserveInteractive = true; _origInteractive = Game->_interactive; Game->_interactive = false; - } else _preserveInteractive; + } /*else _preserveInteractive */; + _type = type; _state = TRANS_MGR_RUNNING; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index ca19651ac9..b5e12ca6d2 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -245,7 +245,7 @@ HRESULT CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { // we're understaffed if (numLive < _maxParticles) { bool needsSort = false; - if (currentTime - _lastGenTime > _genInterval) { + if ((int)(currentTime - _lastGenTime) > _genInterval) { _lastGenTime = currentTime; _batchesGenerated++; @@ -293,7 +293,7 @@ HRESULT CPartEmitter::display(CBRegion *region) { for (int i = 0; i < _particles.GetSize(); i++) { if (region != NULL && _useRegion) { - if (!region->pointInRegion(_particles[i]->_pos.x, _particles[i]->_pos.y)) continue; + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; } _particles[i]->display(this); diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index f69446f36f..aad7594775 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -98,23 +98,23 @@ HRESULT CPartParticle::setSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= _fadeTime) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; _currentAlpha = _alpha1; - } else _currentAlpha = ((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); return S_OK; } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= _fadeTime) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { _isDead = true; return S_OK; - } else _currentAlpha = _fadeStartAlpha - ((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); return S_OK; } else { // time is up if (_lifeTime > 0) { - if (currentTime - _creationTime >= _lifeTime) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { if (emitter->_fadeOutTime > 0) fadeOut(currentTime, emitter->_fadeOutTime); else @@ -137,7 +137,7 @@ HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 int age = (int)(currentTime - _creationTime); int alphaDelta = (int)(_alpha2 - _alpha1); - _currentAlpha = _alpha1 + ((float)alphaDelta / (float)_lifeTime * (float)age); + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); } // update position diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index b64efe9ab6..c51cff366a 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -58,7 +58,7 @@ HRESULT CBSaveThumbFile::open(const Common::String &filename) { char *tempFilename = new char[strlen(filename.c_str()) - 8]; strcpy(tempFilename, filename.c_str() + 9); - for (int i = 0; i < strlen(tempFilename); i++) { + for (uint32 i = 0; i < strlen(tempFilename); i++) { if (tempFilename[i] < '0' || tempFilename[i] > '9') { tempFilename[i] = '\0'; break; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 0b3c6a80d5..67466a2489 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -211,17 +211,17 @@ HRESULT CSXArray::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool CSXArray::validNumber(const char *origStr, char *outStr) { - bool IsNumber = true; - for (int i = 0; i < strlen(origStr); i++) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { if (!(origStr[i] >= '0' && origStr[i] <= '9')) { - IsNumber = false; + isNumber = false; break; } } - if (IsNumber) { - int Index = atoi(origStr); - sprintf(outStr, "%d", Index); + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); return true; } else return false; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 83e9302678..58768db80f 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -271,7 +271,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this byte b; HRESULT ret = E_FAIL; - while (counter < textLen) { + while (counter < (uint32)textLen) { ret = _readFile->read(&b, 1); if (ret != 1) break; diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 585a54fc6a..f987e950d8 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -139,8 +139,8 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetInvalidProduct") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _invalidProducts.size()) - stack->pushString(_invalidProducts[index].c_str()); + if (index >= 0 && (uint32)index < _invalidProducts.size()) + stack->pushString(_invalidProducts[(uint32)index].c_str()); else stack->pushNULL(); @@ -262,7 +262,7 @@ CScValue *CSXStore::scGetProperty(const char *name) { // NumInvalidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumInvalidProducts") == 0) { - _scValue->setInt(_invalidProducts.size()); + _scValue->setInt((int)_invalidProducts.size()); return _scValue; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 60a58d3cfd..172ae32ad1 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -357,8 +357,8 @@ HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { // Capacity ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { - int newCap = value->getInt(); - if (newCap < strlen(_string) + 1) Game->LOG(0, "Warning: cannot lower string capacity"); + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) Game->LOG(0, "Warning: cannot lower string capacity"); else if (newCap != _capacity) { char *newStr = new char[newCap]; if (newStr) { diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 9b51cb2fe2..665829b6c0 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -289,9 +289,8 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// HRESULT CScEngine::tick() { - - - if (_scripts.GetSize() == 0) return S_OK; + if (_scripts.GetSize() == 0) + return S_OK; // resolve waiting scripts @@ -369,15 +368,15 @@ HRESULT CScEngine::tick() { // normal script else { - uint32 StartTime = 0; + uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) StartTime = CBPlatform::getTime(); + if (isProfiling) startTime = CBPlatform::getTime(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); } _currentScript = NULL; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 6b290e4e94..ac59f6e31a 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -151,7 +151,7 @@ public: void enableProfiling(); void disableProfiling(); - bool isProfiling() { + bool getIsProfiling() { return _isProfiling; } diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 180d3d884b..58e61ca3f0 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -400,7 +400,7 @@ void CScScript::cleanup() { if (_externals) { - for (int i = 0; i < _numExternals; i++) { + for (uint32 i = 0; i < _numExternals; i++) { if (_externals[i].nu_params > 0) delete [] _externals[i].params; } delete [] _externals; @@ -431,7 +431,7 @@ void CScScript::cleanup() { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::getDWORD() { - _scriptStream->seek(_iP); + _scriptStream->seek((int32)_iP); uint32 ret = _scriptStream->readUint32LE(); _iP += sizeof(uint32); // assert(oldRet == ret); @@ -1060,7 +1060,7 @@ HRESULT CScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::getFuncPos(const char *name) { - for (int i = 0; i < _numFunctions; i++) { + for (uint32 i = 0; i < _numFunctions; i++) { if (strcmp(name, _functions[i].name) == 0) return _functions[i].pos; } @@ -1070,7 +1070,7 @@ uint32 CScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// uint32 CScScript::getMethodPos(const char *name) { - for (int i = 0; i < _numMethods; i++) { + for (uint32 i = 0; i < _numMethods; i++) { if (strcmp(name, _methods[i].name) == 0) return _methods[i].pos; } @@ -1328,7 +1328,7 @@ HRESULT CScScript::resume() { ////////////////////////////////////////////////////////////////////////// CScScript::TExternalFunction *CScScript::getExternal(char *name) { - for (int i = 0; i < _numExternals; i++) { + for (uint32 i = 0; i < _numExternals; i++) { if (strcmp(name, _externals[i].name) == 0) return &_externals[i]; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 9dbc7d4522..8fd3383ee1 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -153,11 +153,11 @@ public: virtual ~CScScript(); char *_filename; char **_symbols; - int _numSymbols; + uint32 _numSymbols; TFunctionPos *_functions; TMethodPos *_methods; TEventPos *_events; - int _numExternals; + uint32 _numExternals; TExternalFunction *_externals; uint32 _numFunctions; uint32 _numMethods; diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 498a8472cc..38efd393ad 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -111,7 +111,7 @@ CScValue *CScStack::getAt(int index) { ////////////////////////////////////////////////////////////////////////// void CScStack::correctParams(uint32 expectedParams) { - int nuParams = pop()->getInt(); + uint32 nuParams = (uint32)pop()->getInt(); if (expectedParams < nuParams) { // too many params while (expectedParams < nuParams) { diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 59528f13f1..c29bc19578 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -244,7 +244,7 @@ HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, if (!quickSave) { if (counter % 20 == 0) { - Game->_indicatorProgress = 50 + 50.0f / (float)((float)_classes.size() / (float)counter); + Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); Game->displayContent(false); Game->_renderer->flip(); } @@ -264,7 +264,7 @@ HRESULT CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { - Game->_indicatorProgress = 50 + 50.0f / (float)((float)numInstances / (float)i); + Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); Game->displayContentSimple(); Game->_renderer->flip(); } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 519b4d214b..d56e93e4b4 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -238,9 +238,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } // find by name else { - const char *name = val->getString(); + const char *findName = val->getString(); for (i = 0; i < win->_widgets.GetSize(); i++) { - if (scumm_stricmp(win->_widgets[i]->_name, name) == 0) { + if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { found = true; break; } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 2d1f1fdf00..7745589f55 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -269,7 +269,7 @@ int WinterMuteEngine::messageLoop() { uint32 diff = 0; const uint32 maxFPS = 25; - const uint32 frameTime = (1.0/maxFPS) * 1000; + const uint32 frameTime = (uint32)((1.0/maxFPS) * 1000); while (!done) { Common::Event event; while (_system->getEventManager()->pollEvent(event)) { -- cgit v1.2.3 From 48118cb94056245c3d0bc902ea9a88c3864e2989 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 02:52:47 +0200 Subject: WINTERMUTE: Compile ConvertUTF as C++ --- engines/wintermute/utils/ConvertUTF.c | 612 -------------------------------- engines/wintermute/utils/ConvertUTF.cpp | 612 ++++++++++++++++++++++++++++++++ 2 files changed, 612 insertions(+), 612 deletions(-) delete mode 100644 engines/wintermute/utils/ConvertUTF.c create mode 100644 engines/wintermute/utils/ConvertUTF.cpp (limited to 'engines') diff --git a/engines/wintermute/utils/ConvertUTF.c b/engines/wintermute/utils/ConvertUTF.c deleted file mode 100644 index 8f7d6d2124..0000000000 --- a/engines/wintermute/utils/ConvertUTF.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Source code file. - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Sept 2001: fixed const & error conditions per - mods suggested by S. Parent & A. Lillich. - June 2002: Tim Dodd added detection and handling of incomplete - source sequences, enhanced error detection, added casts - to eliminate compiler warnings. - July 2003: slight mods to back out aggressive FFFE detection. - Jan 2004: updated switches in from-UTF8 conversions. - Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. - - See the header file "ConvertUTF.h" for complete documentation. - ------------------------------------------------------------------------- */ - - -#include "ConvertUTF.h" -#ifdef CVTUTF_DEBUG -#include -#endif - -static const int halfShift = 10; /* used for shifting by 10 bits */ - -static const UTF32 halfBase = 0x0010000UL; -static const UTF32 halfMask = 0x3FFUL; - -#define UNI_SUR_HIGH_START (UTF32)0xD800 -#define UNI_SUR_HIGH_END (UTF32)0xDBFF -#define UNI_SUR_LOW_START (UTF32)0xDC00 -#define UNI_SUR_LOW_END (UTF32)0xDFFF -#define false 0 -#define true 1 - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - if (target >= targetEnd) { - result = targetExhausted; - break; - } - ch = *source++; - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_LEGAL_UTF32) { - if (flags == strictConversion) { - result = sourceIllegal; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - --source; /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF32 *target = *targetStart; - UTF32 ch, ch2; - while (source < sourceEnd) { - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - if (target >= targetEnd) { - source = oldSource; /* Back up source pointer! */ - result = targetExhausted; - break; - } - *target++ = ch; - } - *sourceStart = source; - *targetStart = target; -#ifdef CVTUTF_DEBUG - if (result == sourceIllegal) { - fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); - fflush(stderr); - } -#endif - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Index into the table below with the first byte of a UTF-8 sequence to - * get the number of trailing bytes that are supposed to follow it. - * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is - * left as-is for anyone who may want to do such conversion, which was - * allowed in earlier algorithms. - */ -static const char trailingBytesForUTF8[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 -}; - -/* - * Magic values subtracted from a buffer value during UTF8 conversion. - * This table contains as many values as there might be trailing bytes - * in a UTF-8 sequence. - */ -static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL - }; - -/* - * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed - * into the first byte, depending on how many bytes follow. There are - * as many entries in this table as there are UTF-8 sequence types. - * (I.e., one byte sequence, two byte... etc.). Remember that sequencs - * for *legal* UTF-8 will be 4 or fewer bytes total. - */ -static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -/* --------------------------------------------------------------------- */ - -/* The interface converts a whole buffer to avoid function-call overhead. - * Constants have been gathered. Loops & conditionals have been removed as - * much as possible for efficiency, in favor of drop-through switches. - * (See "Note A" at the bottom of the file for equivalent code.) - * If your compiler supports it, the "isLegalUTF8" call can be turned - * into an inline function. - */ - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - UTF32 ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* Figure out how many bytes the result will require */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch < (UTF32)0x110000) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - } - - target += bytesToWrite; - if (target > targetEnd) { - source = oldSource; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Utility routine to tell whether a sequence of bytes is legal UTF-8. - * This must be called with the length pre-determined by the first byte. - * If not calling this from ConvertUTF8to*, then the length can be set by: - * length = trailingBytesForUTF8[*source]+1; - * and the sequence is illegal right away if there aren't that many bytes - * available. - * If presented with a length > 4, this returns false. The Unicode - * definition of UTF-8 goes up to 4-byte sequences. - */ - -static Boolean isLegalUTF8(const UTF8 *source, int length) { - UTF8 a; - const UTF8 *srcptr = source + length; - switch (length) { - default: - return false; - /* Everything else falls through when "true"... */ - case 4: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: - if ((a = (*--srcptr)) > 0xBF) return false; - - switch (*source) { - /* no fall-through in this inner switch */ - case 0xE0: - if (a < 0xA0) return false; - break; - case 0xED: - if (a > 0x9F) return false; - break; - case 0xF0: - if (a < 0x90) return false; - break; - case 0xF4: - if (a > 0x8F) return false; - break; - default: - if (a < 0x80) return false; - } - - case 1: - if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; -} - -/* --------------------------------------------------------------------- */ - -/* - * Exported function to return whether a UTF-8 sequence is legal or not. - * This is not used here; it's just exported. - */ -Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { - int length = trailingBytesForUTF8[*source] + 1; - if (source + length > sourceEnd) { - return false; - } - return isLegalUTF8(source, length); -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 4: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_UTF16) { - if (flags == strictConversion) { - result = sourceIllegal; - source -= (extraBytesToRead + 1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - ch = *source++; - if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* - * Figure out how many bytes the result will require. Turn any - * illegally large UTF32 things (> Plane 17) into replacement chars. - */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch <= UNI_MAX_LEGAL_UTF32) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - result = sourceIllegal; - } - - target += bytesToWrite; - if (target > targetEnd) { - --source; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF32 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; - case 4: - ch += *source++; - ch <<= 6; - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up the source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_LEGAL_UTF32) { - /* - * UTF-16 surrogate values are illegal in UTF-32, and anything - * over Plane 17 (> 0x10FFFF) is illegal. - */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = ch; - } - } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ - result = sourceIllegal; - *target++ = UNI_REPLACEMENT_CHAR; - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- - - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - In UTF-8 writing code, the switches on "bytesToWrite" are - similarly unrolled loops. - - --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/ConvertUTF.cpp b/engines/wintermute/utils/ConvertUTF.cpp new file mode 100644 index 0000000000..8f7d6d2124 --- /dev/null +++ b/engines/wintermute/utils/ConvertUTF.cpp @@ -0,0 +1,612 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "ConvertUTF.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; + break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF32 *target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; + break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG + if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); + } +#endif + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source + length; + switch (length) { + default: + return false; + /* Everything else falls through when "true"... */ + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) return false; + break; + case 0xED: + if (a > 0x9F) return false; + break; + case 0xF0: + if (a < 0x90) return false; + break; + case 0xF4: + if (a > 0x8F) return false; + break; + default: + if (a < 0x80) return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source] + 1; + if (source + length > sourceEnd) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 4: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF32 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; + case 4: + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up the source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_LEGAL_UTF32) { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = ch; + } + } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ -- cgit v1.2.3 From 45e97705efd2501a42f7b0af3ddf1a3bcb23cedf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 03:02:36 +0200 Subject: WINTERMUTE: Remove the rest of the compiler-references --- engines/wintermute/Base/scriptables/ScEngine.cpp | 69 ------------------------ engines/wintermute/Base/scriptables/ScEngine.h | 27 ---------- engines/wintermute/dcscript.h | 15 ------ 3 files changed, 111 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 665829b6c0..58ecc20a0e 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -73,14 +73,6 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { _currentScript = NULL; - _fileToCompile = NULL; - - _compileErrorCallback = NULL; - _compileErrorCallbackData = NULL; - - _parseElementCallback = NULL; - _parseElementCallbackData = NULL; - _isProfiling = false; _profilingStartTime = 0; @@ -123,15 +115,6 @@ HRESULT CScEngine::cleanup() { _currentScript = NULL; // ref only - delete[] _fileToCompile; - _fileToCompile = NULL; - - _compileErrorCallback = NULL; - _compileErrorCallbackData = NULL; - - _parseElementCallback = NULL; - _parseElementCallbackData = NULL; - return S_OK; } @@ -148,34 +131,9 @@ void CScEngine::closeFile(void *data, byte *buffer) { delete [] buffer; } -////////////////////////////////////////////////////////////////////////// -void CScEngine::addError(void *data, int line, char *text) { - CBGame *Game = (CBGame *)data; - - if (Game) { - if (Game->_scEngine && Game->_scEngine->_fileToCompile) - Game->LOG(0, "Compiling script '%s'...", Game->_scEngine->_fileToCompile); - Game->LOG(0, " Error@line %d: %s", line, text); - - - // redirect to an engine's own callback - if (Game->_scEngine && Game->_scEngine->_compileErrorCallback) { - Game->_scEngine->_compileErrorCallback(line, text, Game->_scEngine->_compileErrorCallbackData); - } - } -} - ////////////////////////////////////////////////////////////////////////// void CScEngine::parseElement(void *data, int line, int type, void *elementData) { - CBGame *Game = (CBGame *)data; - - if (Game) { - // redirect to an engine's own callback - if (Game->_scEngine && Game->_scEngine->_parseElementCallback) { - Game->_scEngine->_parseElementCallback(line, type, elementData, Game->_scEngine->_compileErrorCallbackData); - } - } } @@ -228,7 +186,6 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i // nope, load it byte *compBuffer; uint32 compSize; - bool compiledNow = false; uint32 size; @@ -280,7 +237,6 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i // cleanup delete [] buffer; - if (compiledNow) ExtReleaseBuffer(compBuffer); return ret; } @@ -497,7 +453,6 @@ HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_fileToCompile)); persistMgr->transfer(TMEMBER(_globals)); _scripts.persist(persistMgr); @@ -536,30 +491,6 @@ HRESULT CScEngine::resumeAll() { } -////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::setFileToCompile(const char *filename) { - delete[] _fileToCompile; - _fileToCompile = new char[strlen(filename) + 1]; - if (_fileToCompile) { - strcpy(_fileToCompile, filename); - return S_OK; - } else return E_FAIL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::setCompileErrorCallback(COMPILE_ERROR_CALLBACK callback, void *data) { - _compileErrorCallback = callback; - _compileErrorCallbackData = data; -} - -////////////////////////////////////////////////////////////////////////// -void CScEngine::setParseElementCallback(PARSE_ELEMENT_CALLBACK callback, void *data) { - _parseElementCallback = callback; - _parseElementCallbackData = data; -} - - ////////////////////////////////////////////////////////////////////////// bool CScEngine::isValidScript(CScScript *script) { for (int i = 0; i < _scripts.GetSize(); i++) { diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index ac59f6e31a..454e3cce62 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -38,16 +38,6 @@ namespace WinterMute { -typedef byte *(*DLL_COMPILE_BUFFER)(byte *buffer, char *source, uint32 bufferSize, uint32 *compiledSize); -typedef byte *(*DLL_COMPILE_FILE)(char *filename, uint32 *compiledSize); -typedef void (*DLL_RELEASE_BUFFER)(unsigned char *buffer); -typedef void (*DLL_SET_CALLBACKS)(CALLBACKS *callbacks, void *Data); -typedef int (*DLL_DEFINE_FUNCTION)(const char *name); /* Was non-const, changed to silence warnings */ -typedef int (*DLL_DEFINE_VARIABLE)(const char *name); /* Was non-const, changed to silence warnings */ - -typedef void (*COMPILE_ERROR_CALLBACK)(int line, char *text , void *data); -typedef void (*PARSE_ELEMENT_CALLBACK)(int line, int type, void *elementData, void *data); - #define MAX_CACHED_SCRIPTS 20 class CScScript; class CScValue; @@ -107,17 +97,7 @@ public: HRESULT tickUnbreakable(); HRESULT removeFinishedScripts(); bool isValidScript(CScScript *script); - void setCompileErrorCallback(COMPILE_ERROR_CALLBACK callback, void *data); - void setParseElementCallback(PARSE_ELEMENT_CALLBACK callback, void *data); - - COMPILE_ERROR_CALLBACK _compileErrorCallback; - void *_compileErrorCallbackData; - - PARSE_ELEMENT_CALLBACK _parseElementCallback; - void *_parseElementCallbackData; - HRESULT setFileToCompile(const char *filename); - char *_fileToCompile; CScScript *_currentScript; HRESULT resumeAll(); HRESULT pauseAll(); @@ -136,16 +116,9 @@ public: CScEngine(CBGame *inGame); virtual ~CScEngine(); - static void addError(void *data, int line, char *text); static byte *loadFile(void *data, char *filename, uint32 *size); static void closeFile(void *data, byte *buffer); static void parseElement(void *data, int line, int type, void *elementData); - DLL_COMPILE_BUFFER ExtCompileBuffer; - DLL_COMPILE_FILE ExtCompileFile; - DLL_RELEASE_BUFFER ExtReleaseBuffer; - DLL_SET_CALLBACKS ExtSetCallbacks; - DLL_DEFINE_FUNCTION ExtDefineFunction; - DLL_DEFINE_VARIABLE ExtDefineVariable; CBArray _scripts; diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h index 7969e049b0..36d84b45d9 100644 --- a/engines/wintermute/dcscript.h +++ b/engines/wintermute/dcscript.h @@ -136,21 +136,6 @@ typedef enum { ELEMENT_STRING = 0 } TElementType; - - -// compiler interface -typedef byte *(DLL_LOAD_FILE)(void *data, char *filename, uint32 *size); -typedef void (DLL_CLOSE_FILE)(void *data, byte *buffer); -typedef void (DLL_ADD_ERROR)(void *data, int line, char *text); -typedef void (DLL_PARSE_ELEMENT)(void *data, int line, int type, void *elementData); - -typedef struct { - DLL_LOAD_FILE *Dll_LoadFile; - DLL_CLOSE_FILE *Dll_CloseFile; - DLL_ADD_ERROR *Dll_AddError; - DLL_PARSE_ELEMENT *Dll_ParseElement; -} CALLBACKS; - } // end of namespace WinterMute #endif -- cgit v1.2.3 From 7f1296e9dc5060fd49286b6a916483c200611983 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 03:07:30 +0200 Subject: WINTERMUTE: Remove references to HWND --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 4 ++-- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BRenderer.h | 4 ++-- engines/wintermute/PlatformSDL.cpp | 8 ++++---- engines/wintermute/PlatformSDL.h | 6 +++--- engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/utils/utils.h | 2 +- engines/wintermute/wintypes.h | 1 - 9 files changed, 15 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 3485b3eecd..bfeac84f94 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1953,7 +1953,7 @@ HRESULT CAdGame::onMouseLeftDown() { if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; _mouseLeftDown = true; - CBPlatform::setCapture(_renderer->_window); + CBPlatform::setCapture(/*_renderer->_window*/); return S_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index def660274a..7946bf8bbc 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -673,7 +673,7 @@ HRESULT CBGame::initLoop() { ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initInput(HINSTANCE hInst, HWND hWnd) { +HRESULT CBGame::initInput() { return S_OK; } @@ -4233,7 +4233,7 @@ HRESULT CBGame::onMouseLeftDown() { if (_activeObject != NULL) _capturedObject = _activeObject; _mouseLeftDown = true; - CBPlatform::setCapture(_renderer->_window); + CBPlatform::setCapture(/*_renderer->_window*/); return S_OK; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 70ae0d5be1..0d1d0fe15d 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -159,7 +159,7 @@ public: float _offsetPercentY; CBObject *_mainObject; - HRESULT initInput(HINSTANCE hInst, HWND hWnd); + HRESULT initInput(); HRESULT initLoop(); uint32 _currentTime; uint32 _deltaTime; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 0822e0d521..e9c397c9e4 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -104,8 +104,8 @@ public: bool pointInViewport(POINT *P); uint32 _forceAlphaColor; HINSTANCE _instance; - HWND _window; - HWND _clipperWindow; + uint32 _window; + uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index b31c825244..cbfa93c488 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -207,7 +207,7 @@ bool CBPlatform::setCursorPos(int X, int Y) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::showWindow(HWND hWnd, int nCmdShow) { +bool CBPlatform::showWindow(int nCmdShow) { return false; } @@ -230,8 +230,8 @@ bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { } ////////////////////////////////////////////////////////////////////////// -HWND CBPlatform::setCapture(HWND hWnd) { - return 0; +void CBPlatform::setCapture() { + return; } ////////////////////////////////////////////////////////////////////////// @@ -240,7 +240,7 @@ bool CBPlatform::releaseCapture() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setForegroundWindow(HWND hWnd) { +bool CBPlatform::setForegroundWindow() { return false; } diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 9b567c8b30..6b8879328a 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -52,12 +52,12 @@ public: static uint32 getTime(); static bool getCursorPos(LPPOINT lpPoint); static bool setCursorPos(int X, int Y); - static bool showWindow(HWND hWnd, int nCmdShow); + static bool showWindow(int nCmdShow); static bool deleteFile(const char *lpFileName); static bool copyFile(const char *from, const char *to, bool failIfExists); - static HWND setCapture(HWND hWnd); + static void setCapture(); static bool releaseCapture(); - static bool setForegroundWindow(HWND hWnd); + static bool setForegroundWindow(); static bool setRectEmpty(LPRECT lprc); static bool isRectEmpty(const LPRECT lprc); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ab7ebac565..46e5a8da36 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -114,7 +114,7 @@ void CBUtils::createPath(const char *path, bool pathOnly) { ////////////////////////////////////////////////////////////////////////// -void CBUtils::debugMessage(HWND hWnd, const char *text) { +void CBUtils::debugMessage(const char *text) { //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); } diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index ed6c2f3bc5..52678a3e9f 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -44,7 +44,7 @@ public: static void createPath(const char *Path, bool PathOnly = false); - static void debugMessage(HWND hWnd, const char *Text); + static void debugMessage(const char *Text); static char *setString(char **String, const char *Value); static int strNumEntries(const char *Str, const char Delim = ','); diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index efddc13614..9f4d5e035a 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -66,7 +66,6 @@ typedef struct tagPOINT { typedef uint32 HINSTANCE; -typedef uint32 HWND; typedef int32 HRESULT; -- cgit v1.2.3 From 932bd45da5600c0a3f8b36d407fde38f60039432 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 03:09:50 +0200 Subject: WINTERMUTE: Remove references to HINSTANCE. --- engines/wintermute/Base/BRenderer.cpp | 1 - engines/wintermute/Base/BRenderer.h | 1 - engines/wintermute/wintypes.h | 3 --- 3 files changed, 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 6708fb65b9..26e7f3de5a 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -38,7 +38,6 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - _instance = 0; _window = 0; _clipperWindow = 0; _active = false; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index e9c397c9e4..e8067bee7e 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -103,7 +103,6 @@ public: }; bool pointInViewport(POINT *P); uint32 _forceAlphaColor; - HINSTANCE _instance; uint32 _window; uint32 _clipperWindow; bool _active; diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 9f4d5e035a..e15ba1c329 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -64,9 +64,6 @@ typedef struct tagPOINT { int32 y; } POINT, *LPPOINT; - -typedef uint32 HINSTANCE; - typedef int32 HRESULT; #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -- cgit v1.2.3 From 1eea9ad1a3ae577195363abe475cfbbee33d153b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 03:27:21 +0200 Subject: WINTERMUTE: Remove most of the wintype-definitions. --- engines/wintermute/Ad/AdActor.cpp | 112 ++-- engines/wintermute/Ad/AdActor.h | 18 +- engines/wintermute/Ad/AdEntity.cpp | 104 ++-- engines/wintermute/Ad/AdEntity.h | 16 +- engines/wintermute/Ad/AdGame.cpp | 332 +++++------ engines/wintermute/Ad/AdGame.h | 82 +-- engines/wintermute/Ad/AdInventory.cpp | 28 +- engines/wintermute/Ad/AdInventory.h | 6 +- engines/wintermute/Ad/AdInventoryBox.cpp | 40 +- engines/wintermute/Ad/AdInventoryBox.h | 10 +- engines/wintermute/Ad/AdItem.cpp | 92 +-- engines/wintermute/Ad/AdItem.h | 12 +- engines/wintermute/Ad/AdLayer.cpp | 54 +- engines/wintermute/Ad/AdLayer.h | 10 +- engines/wintermute/Ad/AdNodeState.cpp | 10 +- engines/wintermute/Ad/AdNodeState.h | 2 +- engines/wintermute/Ad/AdObject.cpp | 146 ++--- engines/wintermute/Ad/AdObject.h | 36 +- engines/wintermute/Ad/AdPath.cpp | 4 +- engines/wintermute/Ad/AdPathPoint.cpp | 4 +- engines/wintermute/Ad/AdRegion.cpp | 48 +- engines/wintermute/Ad/AdRegion.h | 10 +- engines/wintermute/Ad/AdResponse.cpp | 34 +- engines/wintermute/Ad/AdResponse.h | 8 +- engines/wintermute/Ad/AdResponseBox.cpp | 58 +- engines/wintermute/Ad/AdResponseBox.h | 20 +- engines/wintermute/Ad/AdResponseContext.cpp | 4 +- engines/wintermute/Ad/AdRotLevel.cpp | 26 +- engines/wintermute/Ad/AdRotLevel.h | 6 +- engines/wintermute/Ad/AdScaleLevel.cpp | 26 +- engines/wintermute/Ad/AdScaleLevel.h | 6 +- engines/wintermute/Ad/AdScene.cpp | 272 ++++----- engines/wintermute/Ad/AdScene.h | 58 +- engines/wintermute/Ad/AdSceneNode.cpp | 8 +- engines/wintermute/Ad/AdSceneNode.h | 4 +- engines/wintermute/Ad/AdSceneState.cpp | 4 +- engines/wintermute/Ad/AdSentence.cpp | 32 +- engines/wintermute/Ad/AdSentence.h | 8 +- engines/wintermute/Ad/AdSpriteSet.cpp | 44 +- engines/wintermute/Ad/AdSpriteSet.h | 6 +- engines/wintermute/Ad/AdTalkDef.cpp | 52 +- engines/wintermute/Ad/AdTalkDef.h | 8 +- engines/wintermute/Ad/AdTalkHolder.cpp | 36 +- engines/wintermute/Ad/AdTalkHolder.h | 6 +- engines/wintermute/Ad/AdTalkNode.cpp | 44 +- engines/wintermute/Ad/AdTalkNode.h | 6 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 36 +- engines/wintermute/Ad/AdWaypointGroup.h | 10 +- engines/wintermute/Base/BBase.cpp | 22 +- engines/wintermute/Base/BBase.h | 6 +- engines/wintermute/Base/BDebugger.cpp | 64 +- engines/wintermute/Base/BDebugger.h | 36 +- engines/wintermute/Base/BDynBuffer.cpp | 18 +- engines/wintermute/Base/BDynBuffer.h | 6 +- engines/wintermute/Base/BFader.cpp | 48 +- engines/wintermute/Base/BFader.h | 10 +- engines/wintermute/Base/BFileManager.cpp | 78 +-- engines/wintermute/Base/BFileManager.h | 24 +- engines/wintermute/Base/BFont.cpp | 24 +- engines/wintermute/Base/BFont.h | 4 +- engines/wintermute/Base/BFontBitmap.cpp | 30 +- engines/wintermute/Base/BFontBitmap.h | 6 +- engines/wintermute/Base/BFontStorage.cpp | 20 +- engines/wintermute/Base/BFontStorage.h | 6 +- engines/wintermute/Base/BFontTT.cpp | 54 +- engines/wintermute/Base/BFontTT.h | 12 +- engines/wintermute/Base/BFrame.cpp | 74 +-- engines/wintermute/Base/BFrame.h | 12 +- engines/wintermute/Base/BGame.cpp | 662 ++++++++++----------- engines/wintermute/Base/BGame.h | 132 ++-- engines/wintermute/Base/BImage.cpp | 30 +- engines/wintermute/Base/BImage.h | 8 +- engines/wintermute/Base/BKeyboardState.cpp | 16 +- engines/wintermute/Base/BKeyboardState.h | 6 +- engines/wintermute/Base/BObject.cpp | 196 +++--- engines/wintermute/Base/BObject.h | 54 +- engines/wintermute/Base/BPackage.cpp | 22 +- engines/wintermute/Base/BPackage.h | 6 +- engines/wintermute/Base/BPersistMgr.cpp | 178 +++--- engines/wintermute/Base/BPersistMgr.h | 42 +- engines/wintermute/Base/BPoint.cpp | 4 +- engines/wintermute/Base/BRegion.cpp | 56 +- engines/wintermute/Base/BRegion.h | 14 +- engines/wintermute/Base/BRenderSDL.cpp | 64 +- engines/wintermute/Base/BRenderSDL.h | 16 +- engines/wintermute/Base/BRenderer.cpp | 60 +- engines/wintermute/Base/BRenderer.h | 52 +- engines/wintermute/Base/BSaveThumbHelper.cpp | 6 +- engines/wintermute/Base/BSaveThumbHelper.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 76 +-- engines/wintermute/Base/BScriptHolder.h | 18 +- engines/wintermute/Base/BScriptable.cpp | 14 +- engines/wintermute/Base/BScriptable.h | 4 +- engines/wintermute/Base/BSound.cpp | 64 +- engines/wintermute/Base/BSound.h | 24 +- engines/wintermute/Base/BSoundBuffer.cpp | 56 +- engines/wintermute/Base/BSoundBuffer.h | 22 +- engines/wintermute/Base/BSoundMgr.cpp | 54 +- engines/wintermute/Base/BSoundMgr.h | 20 +- engines/wintermute/Base/BSprite.cpp | 70 +-- engines/wintermute/Base/BSprite.h | 18 +- engines/wintermute/Base/BStringTable.cpp | 14 +- engines/wintermute/Base/BStringTable.h | 4 +- engines/wintermute/Base/BSubFrame.cpp | 74 +-- engines/wintermute/Base/BSubFrame.h | 16 +- engines/wintermute/Base/BSurface.cpp | 42 +- engines/wintermute/Base/BSurface.h | 36 +- engines/wintermute/Base/BSurfaceSDL.cpp | 50 +- engines/wintermute/Base/BSurfaceSDL.h | 26 +- engines/wintermute/Base/BSurfaceStorage.cpp | 30 +- engines/wintermute/Base/BSurfaceStorage.h | 10 +- engines/wintermute/Base/BTransitionMgr.cpp | 14 +- engines/wintermute/Base/BTransitionMgr.h | 4 +- engines/wintermute/Base/BViewport.cpp | 8 +- engines/wintermute/Base/BViewport.h | 2 +- engines/wintermute/Base/PartEmitter.cpp | 182 +++--- engines/wintermute/Base/PartEmitter.h | 30 +- engines/wintermute/Base/PartForce.cpp | 4 +- engines/wintermute/Base/PartForce.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 42 +- engines/wintermute/Base/PartParticle.h | 12 +- engines/wintermute/Base/file/BFile.h | 8 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 34 +- engines/wintermute/Base/file/BSaveThumbFile.h | 8 +- engines/wintermute/Base/scriptables/SXArray.cpp | 22 +- engines/wintermute/Base/scriptables/SXArray.h | 6 +- engines/wintermute/Base/scriptables/SXDate.cpp | 42 +- engines/wintermute/Base/scriptables/SXDate.h | 4 +- engines/wintermute/Base/scriptables/SXFile.cpp | 96 +-- engines/wintermute/Base/scriptables/SXFile.h | 4 +- engines/wintermute/Base/scriptables/SXMath.cpp | 55 +- engines/wintermute/Base/scriptables/SXMath.h | 2 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 56 +- engines/wintermute/Base/scriptables/SXMemBuffer.h | 6 +- engines/wintermute/Base/scriptables/SXStore.cpp | 30 +- engines/wintermute/Base/scriptables/SXStore.h | 6 +- engines/wintermute/Base/scriptables/SXString.cpp | 30 +- engines/wintermute/Base/scriptables/SXString.h | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 98 +-- engines/wintermute/Base/scriptables/ScEngine.h | 36 +- engines/wintermute/Base/scriptables/ScScript.cpp | 124 ++-- engines/wintermute/Base/scriptables/ScScript.h | 36 +- engines/wintermute/Base/scriptables/ScStack.cpp | 4 +- engines/wintermute/Base/scriptables/ScValue.cpp | 34 +- engines/wintermute/Base/scriptables/ScValue.h | 8 +- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- engines/wintermute/Sys/SysClassRegistry.cpp | 22 +- engines/wintermute/Sys/SysClassRegistry.h | 10 +- engines/wintermute/UI/UIButton.cpp | 110 ++-- engines/wintermute/UI/UIButton.h | 12 +- engines/wintermute/UI/UIEdit.cpp | 60 +- engines/wintermute/UI/UIEdit.h | 12 +- engines/wintermute/UI/UIEntity.cpp | 56 +- engines/wintermute/UI/UIEntity.h | 14 +- engines/wintermute/UI/UIObject.cpp | 60 +- engines/wintermute/UI/UIObject.h | 14 +- engines/wintermute/UI/UIText.cpp | 56 +- engines/wintermute/UI/UIText.h | 14 +- engines/wintermute/UI/UITiledImage.cpp | 36 +- engines/wintermute/UI/UITiledImage.h | 8 +- engines/wintermute/UI/UIWindow.cpp | 174 +++--- engines/wintermute/UI/UIWindow.h | 30 +- engines/wintermute/coll_templ.h | 6 +- engines/wintermute/persistent.h | 8 +- engines/wintermute/utils/PathUtil.cpp | 2 +- engines/wintermute/utils/utils.cpp | 8 +- engines/wintermute/video/VidPlayer.cpp | 68 +-- engines/wintermute/video/VidPlayer.h | 16 +- engines/wintermute/video/VidTheoraPlayer.cpp | 120 ++-- engines/wintermute/video/VidTheoraPlayer.h | 26 +- engines/wintermute/wintermute.cpp | 10 +- engines/wintermute/wintypes.h | 34 +- 172 files changed, 3482 insertions(+), 3481 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index b07e444439..a823a18dde 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -76,13 +76,13 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::setDefaultAnimNames() { +ERRORCODE CAdActor::setDefaultAnimNames() { _talkAnimName = "talk"; _idleAnimName = "idle"; _walkAnimName = "walk"; _turnLeftAnimName = "turnleft"; _turnRightAnimName = "turnright"; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -123,19 +123,19 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::loadFile(const char *filename) { +ERRORCODE CAdActor::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); delete [] buffer; @@ -183,7 +183,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -230,7 +230,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { Game->LOG(0, "'ACTOR' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -241,7 +241,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: @@ -291,19 +291,19 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _walkSprite; _walkSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; else _walkSprite = spr; break; case TOKEN_TALK: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); break; case TOKEN_TALK_SPECIAL: spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); break; @@ -311,7 +311,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _standSprite; _standSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; else _standSprite = spr; break; @@ -319,7 +319,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _turnLeftSprite; _turnLeftSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnLeftSprite = spr; break; @@ -327,7 +327,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { delete _turnRightSprite; _turnRightSprite = NULL; spr = new CAdSpriteSet(Game, this); - if (!spr || FAILED(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnRightSprite = spr; break; @@ -338,7 +338,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -380,7 +380,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->loadBuffer(params, false))) { + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; delete _currentBlockRegion; _blockRegion = NULL; @@ -401,7 +401,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->loadBuffer(params, false))) { + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; delete _currentWptGroup; _wptGroup = NULL; @@ -433,7 +433,7 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else _anims.Add(Anim); } break; @@ -441,21 +441,21 @@ HRESULT CAdActor::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ACTOR definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { if (spr) delete spr; Game->LOG(0, "Error loading ACTOR definition"); - return E_FAIL; + return STATUS_FAILED; } if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - _alphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = _nextState = STATE_READY; - return S_OK; + return STATUS_OK; } @@ -504,7 +504,7 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::display() { +ERRORCODE CAdActor::display() { if (_active) updateSounds(); uint32 alpha; @@ -542,12 +542,12 @@ HRESULT CAdActor::display() { if (_active && _partEmitter) _partEmitter->display(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::update() { +ERRORCODE CAdActor::update() { _currentSprite = NULL; if (_state == STATE_READY) { @@ -742,7 +742,7 @@ HRESULT CAdActor::update() { updatePartEmitter(); updateSpriteAttachments(); - return S_OK; + return STATUS_OK; } @@ -850,7 +850,7 @@ void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// @@ -861,7 +861,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi goTo(X, Y); if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -873,20 +873,20 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!Val->isNative()) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } CAdObject *Obj = (CAdObject *)Val->getNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } CAdEntity *Ent = (CAdEntity *)Obj; if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -911,7 +911,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -920,7 +920,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "IsWalking") == 0) { stack->correctParams(0); stack->pushBool(_state == STATE_FOLLOWING_PATH); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -928,8 +928,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MergeAnims") == 0) { stack->correctParams(1); - stack->pushBool(SUCCEEDED(mergeAnims(stack->pop()->getString()))); - return S_OK; + stack->pushBool(DID_SUCCEED(mergeAnims(stack->pop()->getString()))); + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -955,7 +955,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } stack->pushBool(Found); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -965,7 +965,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); const char *AnimName = stack->pop()->getString(); stack->pushBool(getAnimByName(AnimName) != NULL); - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); @@ -1035,14 +1035,14 @@ CScValue *CAdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdActor::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Direction") == 0) { int dir = value->getInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1051,7 +1051,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "TalkAnimName") == 0) { if (value->isNULL()) _talkAnimName = "talk"; else _talkAnimName = value->getString(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1060,7 +1060,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "WalkAnimName") == 0) { if (value->isNULL()) _walkAnimName = "walk"; else _walkAnimName = value->getString(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1069,7 +1069,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "IdleAnimName") == 0) { if (value->isNULL()) _idleAnimName = "idle"; else _idleAnimName = value->getString(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1078,7 +1078,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "TurnLeftAnimName") == 0) { if (value->isNULL()) _turnLeftAnimName = "turnleft"; else _turnLeftAnimName = value->getString(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1087,7 +1087,7 @@ HRESULT CAdActor::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "TurnRightAnimName") == 0) { if (value->isNULL()) _turnRightAnimName = "turnright"; else _turnRightAnimName = value->getString(); - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scSetProperty(name, value); @@ -1108,8 +1108,8 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { delete _animSprite; _animSprite = new CBSprite(Game, this); if (_animSprite) { - HRESULT res = _animSprite->loadFile(_forcedTalkAnimName); - if (FAILED(res)) { + ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; @@ -1187,7 +1187,7 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdActor::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_dir)); @@ -1216,7 +1216,7 @@ HRESULT CAdActor::persist(CBPersistMgr *persistMgr) { _anims.persist(persistMgr); - return S_OK; + return STATUS_OK; } @@ -1262,7 +1262,7 @@ CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::mergeAnims(const char *animsFilename) { +ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END @@ -1271,7 +1271,7 @@ HRESULT CAdActor::mergeAnims(const char *animsFilename) { byte *fileBuffer = Game->_fileManager->readWholeFile(animsFilename); if (fileBuffer == NULL) { Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); - return E_FAIL; + return STATUS_FAILED; } byte *buffer = fileBuffer; @@ -1279,15 +1279,15 @@ HRESULT CAdActor::mergeAnims(const char *animsFilename) { int cmd; CBParser parser(Game); - HRESULT Ret = S_OK; + ERRORCODE Ret = STATUS_OK; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); - if (!Anim || FAILED(Anim->loadBuffer(params, false))) { + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; - Ret = E_FAIL; + Ret = STATUS_FAILED; } else _anims.Add(Anim); } break; @@ -1298,7 +1298,7 @@ HRESULT CAdActor::mergeAnims(const char *animsFilename) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdActor::playAnim(const char *filename) { +ERRORCODE CAdActor::playAnim(const char *filename) { // if we have an anim with this name, use it CAdSpriteSet *Anim = getAnimByName(filename); if (Anim) { @@ -1306,7 +1306,7 @@ HRESULT CAdActor::playAnim(const char *filename) { if (_animSprite2) { _animSprite2->reset(); _state = STATE_PLAYING_ANIM_SET; - return S_OK; + return STATUS_OK; } } // otherwise call the standard handler diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index 7ff65a0cae..d767ecd381 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -52,8 +52,8 @@ public: CBSprite *getTalkStance(const char *stance); virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); CBPoint *_targetPoint; - virtual HRESULT update(); - virtual HRESULT display(); + virtual ERRORCODE update(); + virtual ERRORCODE display(); TDirection _targetDir; TDirection _afterWalkDir; virtual void turnTo(TDirection dir); @@ -67,8 +67,8 @@ public: TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); // new anim system Common::String _talkAnimName; @@ -77,19 +77,19 @@ public: Common::String _turnLeftAnimName; Common::String _turnRightAnimName; CBArray _anims; - virtual HRESULT playAnim(const char *filename); + virtual ERRORCODE playAnim(const char *filename); CAdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - HRESULT setDefaultAnimNames(); + ERRORCODE setDefaultAnimNames(); CBSprite *getTalkStanceOld(const char *stance); - HRESULT mergeAnims(const char *animsFilename); + ERRORCODE mergeAnims(const char *animsFilename); CBSprite *_animSprite2; void initLine(CBPoint startPt, CBPoint endPt); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index d839dfec3b..a5fb78858c 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -84,19 +84,19 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::loadFile(const char *filename) { +ERRORCODE CAdEntity::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", filename); delete [] buffer; @@ -150,7 +150,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -203,7 +203,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { Game->LOG(0, "'ENTITY' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -214,7 +214,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: @@ -229,21 +229,21 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { delete _sprite; _sprite = NULL; spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; else _sprite = spr; } break; case TOKEN_TALK: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); } break; @@ -306,7 +306,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -321,7 +321,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { if (_region) Game->unregisterObject(_region); _region = NULL; CBRegion *rgn = new CBRegion(Game); - if (!rgn || FAILED(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else { _region = rgn; Game->registerObject(_region); @@ -336,7 +336,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { _currentBlockRegion = NULL; CBRegion *rgn = new CBRegion(Game); CBRegion *crgn = new CBRegion(Game); - if (!rgn || !crgn || FAILED(rgn->loadBuffer(params, false))) { + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; _blockRegion = NULL; delete _currentBlockRegion; @@ -357,7 +357,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { _currentWptGroup = NULL; CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); - if (!wpt || !cwpt || FAILED(wpt->loadBuffer(params, false))) { + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; _wptGroup = NULL; delete _currentWptGroup; @@ -381,7 +381,7 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { _sprite = NULL; if (Game->_editorMode) { spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; else _sprite = spr; } if (Game->_editorMode) _editorOnly = true; @@ -454,12 +454,12 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ENTITY definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ENTITY definition"); if (spr) delete spr; - return E_FAIL; + return STATUS_FAILED; } if (_region && _sprite) { @@ -471,17 +471,17 @@ HRESULT CAdEntity::loadBuffer(byte *buffer, bool complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - _alphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = STATE_READY; if (_item && ((CAdGame *)Game)->isItemTaken(_item)) _active = false; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::display() { +ERRORCODE CAdEntity::display() { if (_active) { updateSounds(); @@ -524,12 +524,12 @@ HRESULT CAdEntity::display() { if (_partEmitter) _partEmitter->display(_region); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::update() { +ERRORCODE CAdEntity::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -618,23 +618,23 @@ HRESULT CAdEntity::update() { updatePartEmitter(); updateSpriteAttachments(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { stack->correctParams(0); - if (FAILED(stopSFX(false))) stack->pushBool(false); + if (DID_FAIL(stopSFX(false))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -649,7 +649,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _theora; _theora = new CVidTheoraPlayer(Game); - if (_theora && SUCCEEDED(_theora->initialize(filename))) { + if (_theora && DID_SUCCEED(_theora->initialize(filename))) { if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; @@ -659,7 +659,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -674,7 +674,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -685,7 +685,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_theora && _theora->isPlaying()) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -698,7 +698,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -711,7 +711,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -722,7 +722,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_theora && _theora->isPaused()) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } @@ -738,7 +738,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_region) stack->pushNative(_region, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -752,7 +752,7 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); @@ -831,14 +831,14 @@ CScValue *CAdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Item") == 0) { setItem(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -846,7 +846,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToX") == 0) { _walkToX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -854,7 +854,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToY") == 0) { _walkToY = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -863,7 +863,7 @@ HRESULT CAdEntity::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "WalkToDirection") == 0) { int dir = value->getInt(); if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scSetProperty(name, value); @@ -877,7 +877,7 @@ const char *CAdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) @@ -924,11 +924,11 @@ HRESULT CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { } - if (D3DCOLGetR(_alphaColor) != 0 || D3DCOLGetG(_alphaColor) != 0 || D3DCOLGetB(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); + if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); - if (D3DCOLGetA(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alphaColor)); + if (RGBCOLGetA(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); if (_scale >= 0) buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); @@ -952,7 +952,7 @@ HRESULT CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } @@ -977,7 +977,7 @@ void CAdEntity::updatePosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdEntity::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_item)); @@ -993,7 +993,7 @@ HRESULT CAdEntity::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_theora)); - return S_OK; + return STATUS_OK; } @@ -1003,7 +1003,7 @@ void CAdEntity::setItem(const char *itemName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdEntity::setSprite(const char *filename) { +ERRORCODE CAdEntity::setSprite(const char *filename) { bool setCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; @@ -1013,14 +1013,14 @@ HRESULT CAdEntity::setSprite(const char *filename) { delete _sprite; _sprite = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { delete _sprite; _sprite = NULL; - return E_FAIL; + return STATUS_FAILED; } else { _sprite = spr; _currentSprite = _sprite; - return S_OK; + return STATUS_OK; } } diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index c2d73a4204..9a53f8195b 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -36,7 +36,7 @@ class CVidTheoraPlayer; class CAdEntity : public CAdTalkHolder { public: CVidTheoraPlayer *_theora; - HRESULT setSprite(const char *filename); + ERRORCODE setSprite(const char *filename); int _walkToX; int _walkToY; TDirection _walkToDir; @@ -46,19 +46,19 @@ public: void updatePosition(); virtual int getHeight(); CBRegion *_region; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT update(); - virtual HRESULT display(); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE update(); + virtual ERRORCODE display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); TEntityType _subtype; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index bfeac84f94..bf4bb41c75 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -117,7 +117,7 @@ CAdGame::~CAdGame() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::cleanup() { +ERRORCODE CAdGame::cleanup() { int i; for (i = 0; i < _objects.GetSize(); i++) { @@ -195,7 +195,7 @@ HRESULT CAdGame::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::initLoop() { +ERRORCODE CAdGame::initLoop() { if (_scheduledScene && _transMgr->isReady()) { changeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; @@ -205,9 +205,9 @@ HRESULT CAdGame::initLoop() { } - HRESULT res; + ERRORCODE res; res = CBGame::initLoop(); - if (FAILED(res)) return res; + if (DID_FAIL(res)) return res; if (_scene) res = _scene->initLoop(); @@ -218,18 +218,18 @@ HRESULT CAdGame::initLoop() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::addObject(CAdObject *object) { +ERRORCODE CAdGame::addObject(CAdObject *object) { _objects.Add(object); return registerObject(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::removeObject(CAdObject *object) { +ERRORCODE CAdGame::removeObject(CAdObject *object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { - HRESULT Res = _scene->removeObject(object); - if (SUCCEEDED(Res)) return Res; + ERRORCODE Res = _scene->removeObject(object); + if (DID_SUCCEED(Res)) return Res; } for (int i = 0; i < _objects.GetSize(); i++) { @@ -243,7 +243,7 @@ HRESULT CAdGame::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::changeScene(const char *filename, bool fadeIn) { +ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene == NULL) { _scene = new CAdScene(Game); registerObject(_scene); @@ -265,13 +265,13 @@ HRESULT CAdGame::changeScene(const char *filename, bool fadeIn) { _scene->_sFXVolume = 100; if (_scene->_scProp) _scene->_scProp->cleanup(); - HRESULT ret; + ERRORCODE ret; if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { _initialScene = false; ret = _scene->loadFile(_debugStartupScene); } else ret = _scene->loadFile(filename); - if (SUCCEEDED(ret)) { + if (DID_SUCCEED(ret)) { // invalidate references to the original scene for (int i = 0; i < _objects.GetSize(); i++) { _objects[i]->invalidateCurrRegions(); @@ -282,7 +282,7 @@ HRESULT CAdGame::changeScene(const char *filename, bool fadeIn) { } if (fadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); return ret; - } else return E_FAIL; + } else return STATUS_FAILED; } @@ -293,12 +293,12 @@ void CAdGame::addSentence(CAdSentence *sentence) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::displaySentences(bool frozen) { +ERRORCODE CAdGame::displaySentences(bool frozen) { for (int i = 0; i < _sentences.GetSize(); i++) { if (frozen && _sentences[i]->_freezable) continue; else _sentences[i]->display(); } - return S_OK; + return STATUS_OK; } @@ -316,7 +316,7 @@ void CAdGame::finishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// @@ -334,11 +334,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); - //HRESULT ret = ChangeScene(stack->pop()->getString()); - //if(FAILED(ret)) stack->pushBool(false); + //ERRORCODE ret = ChangeScene(stack->pop()->getString()); + //if(DID_FAIL(ret)) stack->pushBool(false); //else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -347,7 +347,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->pop()->getString()))) { + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); } else { @@ -355,7 +355,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this act = NULL; stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -364,7 +364,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->pop()->getString()))) { + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); } else { @@ -372,7 +372,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ent = NULL; stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -386,7 +386,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -400,7 +400,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -414,7 +414,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this addItem(item); if (!val->isNULL()) item->setName(val->getString()); stack->pushNative(item, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -433,7 +433,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -454,7 +454,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (item) stack->pushNative(item, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -491,7 +491,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -502,7 +502,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this int ID = stack->pop()->getInt(-1); resetResponse(ID); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -513,7 +513,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _responseBox->clearResponses(); _responseBox->clearButtons(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -528,7 +528,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_responseBox->_responses.GetSize() == 0) { stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -536,7 +536,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); - return S_OK; + return STATUS_OK; } _responseBox->createButtons(); @@ -548,7 +548,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this script->runtimeError("Game.GetResponse: response box is not defined"); stack->pushNULL(); } - return S_OK; + return STATUS_OK; } @@ -564,7 +564,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this script->runtimeError("Game.GetNumResponses: response box is not defined"); stack->pushNULL(); } - return S_OK; + return STATUS_OK; } @@ -582,7 +582,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -598,7 +598,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -611,7 +611,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -656,17 +656,17 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { if (val->getNative() == Inv->_takenItems[j]) { stack->pushBool(true); - return S_OK; + return STATUS_OK; } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { stack->pushBool(true); - return S_OK; + return STATUS_OK; } } } } else script->runtimeError("Game.IsItemTaken: item name expected"); stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -679,7 +679,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -692,7 +692,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -704,7 +704,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this Game->unregisterObject(_responseBox); _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->loadFile(filename))) { + if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { registerObject(_responseBox); stack->pushBool(true); } else { @@ -712,7 +712,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _responseBox = NULL; stack->pushBool(false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -724,7 +724,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this Game->unregisterObject(_inventoryBox); _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->loadFile(filename))) { + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { registerObject(_inventoryBox); stack->pushBool(true); } else { @@ -732,7 +732,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _inventoryBox = NULL; stack->pushBool(false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -743,10 +743,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this const char *filename = stack->pop()->getString(); bool merge = stack->pop()->getBool(false); - HRESULT ret = loadItemsFile(filename, merge); - stack->pushBool(SUCCEEDED(ret)); + ERRORCODE ret = loadItemsFile(filename, merge); + stack->pushBool(DID_SUCCEED(ret)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -755,9 +755,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "AddSpeechDir") == 0) { stack->correctParams(1); const char *dir = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(addSpeechDir(dir))); + stack->pushBool(DID_SUCCEED(addSpeechDir(dir))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -766,9 +766,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "RemoveSpeechDir") == 0) { stack->correctParams(1); const char *dir = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(removeSpeechDir(dir))); + stack->pushBool(DID_SUCCEED(removeSpeechDir(dir))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -789,7 +789,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushBool(true); - return S_OK; + return STATUS_OK; } @@ -952,7 +952,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem @@ -974,7 +974,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -982,7 +982,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SmartItemCursor") == 0) { _smartItemCursor = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -990,7 +990,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryVisible") == 0) { if (_inventoryBox) _inventoryBox->_visible = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1008,7 +1008,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1016,7 +1016,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1027,7 +1027,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { if (Val < 0) Val = 0; if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; _talkSkipButton = (TTalkSkipButton)Val; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1039,7 +1039,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { _startupScene = NULL; } else CBUtils::setString(&_startupScene, value->getString()); - return S_OK; + return STATUS_OK; } else return CBGame::scSetProperty(name, value); @@ -1047,7 +1047,7 @@ HRESULT CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { +ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *this_obj; ////////////////////////////////////////////////////////////////////////// @@ -1078,13 +1078,13 @@ HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *this else return CBGame::ExternalCall(script, stack, thisStack, name); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::showCursor() { - if (_cursorHidden) return S_OK; +ERRORCODE CAdGame::showCursor() { + if (_cursorHidden) return STATUS_OK; if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { @@ -1103,19 +1103,19 @@ HRESULT CAdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadFile(const char *filename) { +ERRORCODE CAdGame::loadFile(const char *filename) { byte *buffer = _fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); delete [] buffer; @@ -1139,7 +1139,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1163,7 +1163,7 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - if (FAILED(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; break; case TOKEN_AD_GAME: @@ -1172,7 +1172,7 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_RESPONSE_BOX: delete _responseBox; _responseBox = new CAdResponseBox(Game); - if (_responseBox && !FAILED(_responseBox->loadFile((char *)params2))) + if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) registerObject(_responseBox); else { delete _responseBox; @@ -1184,7 +1184,7 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; _inventoryBox = new CAdInventoryBox(Game); - if (_inventoryBox && !FAILED(_inventoryBox->loadFile((char *)params2))) + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) registerObject(_inventoryBox); else { delete _inventoryBox; @@ -1196,7 +1196,7 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ITEMS: itemsFound = true; CBUtils::setString(&_itemsFile, (char *)params2); - if (FAILED(loadItemsFile(_itemsFile))) { + if (DID_FAIL(loadItemsFile(_itemsFile))) { delete[] _itemsFile; _itemsFile = NULL; cmd = PARSERR_GENERIC; @@ -1236,23 +1236,23 @@ HRESULT CAdGame::loadBuffer(byte *buffer, bool complete) { if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in GAME definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading GAME definition"); - return E_FAIL; + return STATUS_FAILED; } if (itemFound && !itemsFound) { Game->LOG(0, "**Warning** Please put the items definition to a separate file."); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); CBGame::persist(persistMgr); @@ -1298,22 +1298,22 @@ HRESULT CAdGame::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_startupScene)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadGame(const char *filename) { - HRESULT ret = CBGame::loadGame(filename); - if (SUCCEEDED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); +ERRORCODE CAdGame::loadGame(const char *filename) { + ERRORCODE ret = CBGame::loadGame(filename); + if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); return ret; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::initAfterLoad() { +ERRORCODE CAdGame::initAfterLoad() { CBGame::initAfterLoad(); CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1345,7 +1345,7 @@ void CAdGame::setPrevSceneFilename(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { +ERRORCODE CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; @@ -1356,36 +1356,36 @@ HRESULT CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { _scheduledFadeIn = fadeIn; - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +ERRORCODE CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { CBGame::getVersion(verMajor, verMinor, NULL, NULL); if (extMajor) *extMajor = 0; if (extMinor) *extMinor = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadItemsFile(const char *filename, bool merge) { +ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; //_filename = new char [strlen(filename)+1]; //strcpy(_filename, filename); - if (FAILED(ret = loadItemsBuffer(buffer, merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", filename); + if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", filename); delete [] buffer; @@ -1395,7 +1395,7 @@ HRESULT CAdGame::loadItemsFile(const char *filename, bool merge) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::loadItemsBuffer(byte *buffer, bool merge) { +ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE_END @@ -1412,7 +1412,7 @@ HRESULT CAdGame::loadItemsBuffer(byte *buffer, bool merge) { switch (cmd) { case TOKEN_ITEM: { CAdItem *item = new CAdItem(Game); - if (item && !FAILED(item->loadBuffer(params, false))) { + if (item && !DID_FAIL(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (merge) { CAdItem *PrevItem = getItemByName(item->_name); @@ -1431,14 +1431,14 @@ HRESULT CAdGame::loadItemsBuffer(byte *buffer, bool merge) { if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ITEMS definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ITEMS definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } @@ -1473,7 +1473,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { +ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE_END @@ -1485,7 +1485,7 @@ HRESULT CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { switch (cmd) { case TOKEN_ENTITY_CONTAINER: { CUIEntity *ent = new CUIEntity(Game); - if (!ent || FAILED(ent->loadBuffer((byte *)*params, false))) { + if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { delete ent; ent = NULL; cmd = PARSERR_GENERIC; @@ -1498,16 +1498,16 @@ HRESULT CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { } if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { if (strcmp(name, "CreateEntityContainer") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); @@ -1519,24 +1519,24 @@ HRESULT CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScSt ent->_parent = win; win->_widgets.Add(ent); - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +ERRORCODE CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); _dlgPendingBranches.Add(name); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; bool deleteName = false; if (branchName == NULL && _dlgPendingBranches.GetSize() > 0) { @@ -1551,7 +1551,7 @@ HRESULT CAdGame::endDlgBranch(const char *branchName, const char *scriptName, co } } - if (name == NULL) return S_OK; + if (name == NULL) return STATUS_OK; int startIndex = -1; @@ -1578,12 +1578,12 @@ HRESULT CAdGame::endDlgBranch(const char *branchName, const char *scriptName, co if (deleteName) delete [] name; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::clearBranchResponses(char *name) { +ERRORCODE CAdGame::clearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.GetSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; @@ -1591,18 +1591,18 @@ HRESULT CAdGame::clearBranchResponses(char *name) { i--; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::addBranchResponse(int ID) { - if (branchResponseUsed(ID)) return S_OK; +ERRORCODE CAdGame::addBranchResponse(int ID) { + if (branchResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); _responsesBranch.Add(r); - return S_OK; + return STATUS_OK; } @@ -1619,13 +1619,13 @@ bool CAdGame::branchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::addGameResponse(int ID) { - if (gameResponseUsed(ID)) return S_OK; +ERRORCODE CAdGame::addGameResponse(int ID) { + if (gameResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); _responsesGame.Add(r); - return S_OK; + return STATUS_OK; } @@ -1643,7 +1643,7 @@ bool CAdGame::gameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::resetResponse(int ID) { +ERRORCODE CAdGame::resetResponse(int ID) { char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; int i; @@ -1667,12 +1667,12 @@ HRESULT CAdGame::resetResponse(int ID) { } } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::displayContent(bool doUpdate, bool displayAll) { +ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // init if (doUpdate) initLoop(); @@ -1736,30 +1736,30 @@ HRESULT CAdGame::displayContent(bool doUpdate, bool displayAll) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::registerInventory(CAdInventory *inv) { +ERRORCODE CAdGame::registerInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.GetSize(); i++) { - if (_inventories[i] == inv) return S_OK; + if (_inventories[i] == inv) return STATUS_OK; } registerObject(inv); _inventories.Add(inv); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::unregisterInventory(CAdInventory *inv) { +ERRORCODE CAdGame::unregisterInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.GetSize(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); _inventories.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1786,14 +1786,14 @@ CAdItem *CAdGame::getItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::addItem(CAdItem *item) { +ERRORCODE CAdGame::addItem(CAdItem *item) { _items.Add(item); return Game->registerObject(item); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::resetContent() { +ERRORCODE CAdGame::resetContent() { // clear pending dialogs for (int i = 0; i < _dlgPendingBranches.GetSize(); i++) { delete [] _dlgPendingBranches[i]; @@ -1828,8 +1828,8 @@ HRESULT CAdGame::resetContent() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::deleteItem(CAdItem *item) { - if (!item) return E_FAIL; +ERRORCODE CAdGame::deleteItem(CAdItem *item) { + if (!item) return STATUS_FAILED; if (_selectedItem == item) _selectedItem = NULL; _scene->handleItemAssociations(item->_name, false); @@ -1848,13 +1848,13 @@ HRESULT CAdGame::deleteItem(CAdItem *item) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::addSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return E_FAIL; +ERRORCODE CAdGame::addSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; strcpy(temp, dir); @@ -1864,18 +1864,18 @@ HRESULT CAdGame::addSpeechDir(const char *dir) { for (int i = 0; i < _speechDirs.GetSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete [] temp; - return S_OK; + return STATUS_OK; } } _speechDirs.Add(temp); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::removeSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return E_FAIL; +ERRORCODE CAdGame::removeSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; strcpy(temp, dir); @@ -1893,8 +1893,8 @@ HRESULT CAdGame::removeSpeechDir(const char *dir) { } delete [] temp; - if (Found) return S_OK; - else return E_FAIL; + if (Found) return STATUS_OK; + else return STATUS_FAILED; } @@ -1931,18 +1931,18 @@ bool CAdGame::validMouse() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onMouseLeftDown() { - if (!validMouse()) return S_OK; +ERRORCODE CAdGame::onMouseLeftDown() { + if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { finishSentences(); } - return S_OK; + return STATUS_OK; } if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftClick"); @@ -1955,18 +1955,18 @@ HRESULT CAdGame::onMouseLeftDown() { _mouseLeftDown = true; CBPlatform::setCapture(/*_renderer->_window*/); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onMouseLeftUp() { +ERRORCODE CAdGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; - bool handled = /*_state==GAME_RUNNING &&*/ SUCCEEDED(applyEvent("LeftRelease")); + bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftRelease"); @@ -1974,18 +1974,18 @@ HRESULT CAdGame::onMouseLeftUp() { _scene->applyEvent("LeftRelease"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onMouseLeftDblClick() { - if (!validMouse()) return S_OK; +ERRORCODE CAdGame::onMouseLeftDblClick() { + if (!validMouse()) return STATUS_OK; - if (_state == GAME_RUNNING && !_interactive) return S_OK; + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftDoubleClick"); @@ -1993,24 +1993,24 @@ HRESULT CAdGame::onMouseLeftDblClick() { _scene->applyEvent("LeftDoubleClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onMouseRightDown() { - if (!validMouse()) return S_OK; +ERRORCODE CAdGame::onMouseRightDown() { + if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { finishSentences(); } - return S_OK; + return STATUS_OK; } - if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return S_OK; + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightClick"); @@ -2018,14 +2018,14 @@ HRESULT CAdGame::onMouseRightDown() { _scene->applyEvent("RightClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onMouseRightUp() { +ERRORCODE CAdGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightRelease"); @@ -2033,11 +2033,11 @@ HRESULT CAdGame::onMouseRightUp() { _scene->applyEvent("RightRelease"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::displayDebugInfo() { +ERRORCODE CAdGame::displayDebugInfo() { char str[100]; if (Game->_dEBUG_DebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); @@ -2051,11 +2051,11 @@ HRESULT CAdGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdGame::onScriptShutdown(CScScript *script) { +ERRORCODE CAdGame::onScriptShutdown(CScScript *script) { if (_responseBox && _responseBox->_waitingScript == script) _responseBox->_waitingScript = NULL; - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index ed5f5b3f73..80a7bb7ea0 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -44,56 +44,56 @@ class CAdResponseContext; class CAdResponseBox; class CAdGame : public CBGame { public: - virtual HRESULT onScriptShutdown(CScScript *script); + virtual ERRORCODE onScriptShutdown(CScScript *script); - virtual HRESULT onMouseLeftDown(); - virtual HRESULT onMouseLeftUp(); - virtual HRESULT onMouseLeftDblClick(); - virtual HRESULT onMouseRightDown(); - virtual HRESULT onMouseRightUp(); + virtual ERRORCODE onMouseLeftDown(); + virtual ERRORCODE onMouseLeftUp(); + virtual ERRORCODE onMouseLeftDblClick(); + virtual ERRORCODE onMouseRightDown(); + virtual ERRORCODE onMouseRightUp(); - virtual HRESULT displayDebugInfo(); + virtual ERRORCODE displayDebugInfo(); - virtual HRESULT initAfterLoad(); + virtual ERRORCODE initAfterLoad(); static void afterLoadScene(void *scene, void *data); bool _smartItemCursor; CBArray _speechDirs; - HRESULT addSpeechDir(const char *dir); - HRESULT removeSpeechDir(const char *dir); + ERRORCODE addSpeechDir(const char *dir); + ERRORCODE removeSpeechDir(const char *dir); char *findSpeechFile(char *StringID); - HRESULT deleteItem(CAdItem *Item); + ERRORCODE deleteItem(CAdItem *Item); char *_itemsFile; bool _tempDisableSaveState; - virtual HRESULT resetContent(); - HRESULT addItem(CAdItem *item); + virtual ERRORCODE resetContent(); + ERRORCODE addItem(CAdItem *item); CAdItem *getItemByName(const char *name); CBArray _items; CAdObject *_inventoryOwner; bool isItemTaken(char *itemName); - HRESULT registerInventory(CAdInventory *inv); - HRESULT unregisterInventory(CAdInventory *inv); + ERRORCODE registerInventory(CAdInventory *inv); + ERRORCODE unregisterInventory(CAdInventory *inv); CAdObject *_invObject; CBArray _inventories; - virtual HRESULT displayContent(bool update = true, bool displayAll = false); + virtual ERRORCODE displayContent(bool update = true, bool displayAll = false); char *_debugStartupScene; char *_startupScene; bool _initialScene; bool gameResponseUsed(int ID); - HRESULT addGameResponse(int ID); - HRESULT resetResponse(int ID); + ERRORCODE addGameResponse(int ID); + ERRORCODE resetResponse(int ID); bool branchResponseUsed(int ID); - HRESULT addBranchResponse(int ID); - HRESULT clearBranchResponses(char *name); - HRESULT startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - HRESULT endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual HRESULT windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual HRESULT windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + ERRORCODE addBranchResponse(int ID); + ERRORCODE clearBranchResponses(char *name); + ERRORCODE startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + ERRORCODE endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); CAdSceneState *getSceneState(const char *filename, bool saving); CBViewport *_sceneViewport; @@ -104,31 +104,31 @@ public: TTalkSkipButton _talkSkipButton; - virtual HRESULT getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - HRESULT scheduleChangeScene(const char *filename, bool fadeIn); + virtual ERRORCODE getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + ERRORCODE scheduleChangeScene(const char *filename, bool fadeIn); char *_scheduledScene; bool _scheduledFadeIn; void setPrevSceneName(const char *name); void setPrevSceneFilename(const char *name); char *_prevSceneName; char *_prevSceneFilename; - virtual HRESULT loadGame(const char *filename); + virtual ERRORCODE loadGame(const char *filename); CAdItem *_selectedItem; - HRESULT cleanup(); + ERRORCODE cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) void finishSentences(); - HRESULT showCursor(); + ERRORCODE showCursor(); TGameStateEx _stateEx; CAdResponseBox *_responseBox; CAdInventoryBox *_inventoryBox; - HRESULT displaySentences(bool frozen); + ERRORCODE displaySentences(bool frozen); void addSentence(CAdSentence *sentence); - HRESULT changeScene(const char *filename, bool fadeIn); - HRESULT removeObject(CAdObject *object); - HRESULT addObject(CAdObject *object); + ERRORCODE changeScene(const char *filename, bool fadeIn); + ERRORCODE removeObject(CAdObject *object); + ERRORCODE addObject(CAdObject *object); CAdScene *_scene; - HRESULT initLoop(); + ERRORCODE initLoop(); CAdGame(); virtual ~CAdGame(); CBArray _objects; @@ -140,19 +140,19 @@ public: CBArray _responsesBranch; CBArray _responsesGame; - virtual HRESULT loadFile(const char *filename); - virtual HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE loadFile(const char *filename); + virtual ERRORCODE loadBuffer(byte *buffer, bool complete = true); - HRESULT loadItemsFile(const char *filename, bool merge = false); - HRESULT loadItemsBuffer(byte *buffer, bool merge = false); + ERRORCODE loadItemsFile(const char *filename, bool merge = false); + ERRORCODE loadItemsBuffer(byte *buffer, bool merge = false); - virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); bool validMouse(); }; diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 6260e23778..41e9a89ed5 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -49,11 +49,11 @@ CAdInventory::~CAdInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) return E_FAIL; +ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { + if (name == NULL) return STATUS_FAILED; CAdItem *item = ((CAdGame *)Game)->getItemByName(name); - if (item == NULL) return E_FAIL; + if (item == NULL) return STATUS_FAILED; int insertIndex = -1; for (int i = 0; i < _takenItems.GetSize(); i++) { @@ -69,51 +69,51 @@ HRESULT CAdInventory::insertItem(const char *name, const char *insertAfter) { if (insertIndex == -1) _takenItems.Add(item); else _takenItems.InsertAt(insertIndex, item); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::removeItem(const char *name) { - if (name == NULL) return E_FAIL; +ERRORCODE CAdInventory::removeItem(const char *name) { + if (name == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.GetSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; _takenItems.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::removeItem(CAdItem *item) { - if (item == NULL) return E_FAIL; +ERRORCODE CAdInventory::removeItem(CAdItem *item) { + if (item == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.GetSize(); i++) { if (_takenItems[i] == item) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; _takenItems.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventory::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdInventory::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); _takenItems.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollOffset)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h index 6ba48a59c9..d78b78d89d 100644 --- a/engines/wintermute/Ad/AdInventory.h +++ b/engines/wintermute/Ad/AdInventory.h @@ -38,9 +38,9 @@ class CAdItem; class CAdInventory : public CBObject { public: DECLARE_PERSISTENT(CAdInventory, CBObject) - HRESULT removeItem(const char *name); - HRESULT removeItem(CAdItem *Item); - HRESULT insertItem(const char *name, const char *insertAfter = NULL); + ERRORCODE removeItem(const char *name); + ERRORCODE removeItem(CAdItem *Item); + ERRORCODE insertItem(const char *name, const char *insertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); CBArray _takenItems; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 81a8f7db2b..9cb26d8e53 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -73,7 +73,7 @@ CAdInventoryBox::~CAdInventoryBox() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { +ERRORCODE CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -92,15 +92,15 @@ HRESULT CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { break; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::display() { +ERRORCODE CAdInventoryBox::display() { CAdGame *adGame = (CAdGame *)Game; - if (!_visible) return S_OK; + if (!_visible) return STATUS_OK; int ItemsX, ItemsY; ItemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); @@ -149,24 +149,24 @@ HRESULT CAdInventoryBox::display() { } if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::loadFile(const char *filename) { +ERRORCODE CAdInventoryBox::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); delete [] buffer; @@ -192,7 +192,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -219,7 +219,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { Game->LOG(0, "'INVENTORY_BOX' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -227,7 +227,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -241,7 +241,7 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: delete _window; _window = new CUIWindow(Game); - if (!_window || FAILED(_window->loadBuffer(params, false))) { + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; @@ -287,11 +287,11 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in INVENTORY_BOX definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading INVENTORY_BOX definition"); - return E_FAIL; + return STATUS_FAILED; } if (_exclusive) { @@ -313,11 +313,11 @@ HRESULT CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "INVENTORY_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -345,12 +345,12 @@ HRESULT CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdInventoryBox::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdInventoryBox::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_closeButton)); @@ -365,7 +365,7 @@ HRESULT CAdInventoryBox::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_window)); persistMgr->transfer(TMEMBER(_exclusive)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index e05c001da8..536f60130e 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -44,18 +44,18 @@ public: int _itemHeight; int _itemWidth; bool _visible; - virtual HRESULT display(); + virtual ERRORCODE display(); CUIButton *_closeButton; int _spacing; int _scrollOffset; RECT _itemsArea; - HRESULT listen(CBScriptHolder *param1, uint32 param2); + ERRORCODE listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index c05e18daf1..3b17cfd963 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -84,19 +84,19 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::loadFile(const char *filename) { +ERRORCODE CAdItem::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); delete [] buffer; @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -171,7 +171,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { Game->LOG(0, "'ITEM' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -180,7 +180,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -199,7 +199,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE: delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _sprite; cmd = PARSERR_GENERIC; } @@ -209,7 +209,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE_HOVER: delete _spriteHover; _spriteHover = new CBSprite(Game, this); - if (!_spriteHover || FAILED(_spriteHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _spriteHover; cmd = PARSERR_GENERIC; } @@ -243,14 +243,14 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.Add(spr); } break; case TOKEN_TALK_SPECIAL: { CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.Add(spr); } break; @@ -258,7 +258,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursorNormal; _cursorNormal = new CBSprite(Game); - if (!_cursorNormal || FAILED(_cursorNormal->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _cursorNormal; _cursorNormal = NULL; cmd = PARSERR_GENERIC; @@ -268,7 +268,7 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR_HOVER: delete _cursorHover; _cursorHover = new CBSprite(Game); - if (!_cursorHover || FAILED(_cursorHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { delete _cursorHover; _cursorHover = NULL; cmd = PARSERR_GENERIC; @@ -302,24 +302,24 @@ HRESULT CAdItem::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ITEM definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ITEM definition"); - return E_FAIL; + return STATUS_FAILED; } if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - _alphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::update() { +ERRORCODE CAdItem::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -381,12 +381,12 @@ HRESULT CAdItem::update() { } _ready = (_state == STATE_READY); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::display(int x, int y) { +ERRORCODE CAdItem::display(int x, int y) { int width = 0; if (_currentSprite) { RECT rc; @@ -397,10 +397,10 @@ HRESULT CAdItem::display(int x, int y) { _posX = x + width / 2; _posY = y; - HRESULT ret; + ERRORCODE ret; if (_currentSprite) ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); - else ret = S_OK; + else ret = STATUS_OK; if (_displayAmount) { int amountX = x; @@ -430,7 +430,7 @@ HRESULT CAdItem::display(int x, int y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// @@ -445,7 +445,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this delete _spriteHover; _spriteHover = NULL; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); } else { @@ -453,7 +453,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (setCurrent) _currentSprite = _spriteHover; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -464,7 +464,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); else stack->pushString(_spriteHover->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -474,7 +474,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); if (!_spriteHover) stack->pushNULL(); else stack->pushNative(_spriteHover, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -488,14 +488,14 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this delete _cursorNormal; _cursorNormal = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); } else { _cursorNormal = spr; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -506,7 +506,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); else stack->pushString(_cursorNormal->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -517,7 +517,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_cursorNormal) stack->pushNULL(); else stack->pushNative(_cursorNormal, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -531,14 +531,14 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this delete _cursorHover; _cursorHover = NULL; CBSprite *spr = new CBSprite(Game); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); } else { _cursorHover = spr; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -549,7 +549,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); else stack->pushString(_cursorHover->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -560,7 +560,7 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_cursorHover) stack->pushNULL(); else stack->pushNative(_cursorHover, true); - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); @@ -649,13 +649,13 @@ CScValue *CAdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -663,7 +663,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisplayAmount") == 0) { _displayAmount = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -671,7 +671,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Amount") == 0) { _amount = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -679,7 +679,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetX") == 0) { _amountOffsetX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -687,7 +687,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountOffsetY") == 0) { _amountOffsetY = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -695,7 +695,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountAlign") == 0) { _amountAlign = (TTextAlign)value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -708,7 +708,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { } else { CBUtils::setString(&_amountString, value->getString()); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -716,7 +716,7 @@ HRESULT CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorCombined") == 0) { _cursorCombined = value->getBool(); - return S_OK; + return STATUS_OK; } else return CAdTalkHolder::scSetProperty(name, value); @@ -730,7 +730,7 @@ const char *CAdItem::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdItem::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdItem::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); @@ -746,7 +746,7 @@ HRESULT CAdItem::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER_INT(_amountAlign)); persistMgr->transfer(TMEMBER(_amountString)); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index fa2e99fa5a..f0810d95d1 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -44,9 +44,9 @@ public: char *_amountString; - HRESULT update(); + ERRORCODE update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - HRESULT display(int x, int y); + ERRORCODE display(int x, int y); bool getExtendedFlag(const char *flagName); bool _inInventory; bool _cursorCombined; @@ -55,13 +55,13 @@ public: CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 64d36e67db..06765b6cba 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -61,19 +61,19 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::loadFile(const char *filename) { +ERRORCODE CAdLayer::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); delete [] buffer; @@ -99,7 +99,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -125,7 +125,7 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { Game->LOG(0, "'LAYER' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -133,7 +133,7 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -167,7 +167,7 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { case TOKEN_REGION: { CAdRegion *region = new CAdRegion(Game); CAdSceneNode *node = new CAdSceneNode(Game); - if (!region || !node || FAILED(region->loadBuffer(params, false))) { + if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete region; delete node; @@ -184,7 +184,7 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { CAdEntity *entity = new CAdEntity(Game); CAdSceneNode *node = new CAdSceneNode(Game); if (entity) entity->_zoomable = false; // scene entites default to NOT zoom - if (!entity || !node || FAILED(entity->loadBuffer(params, false))) { + if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; delete node; @@ -216,17 +216,17 @@ HRESULT CAdLayer::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in LAYER definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// @@ -259,7 +259,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushNULL(); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -282,7 +282,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushNative(entity, true); } _nodes.Add(node); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -309,7 +309,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (index <= _nodes.GetSize() - 1) _nodes.InsertAt(index, node); else _nodes.Add(node); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -336,7 +336,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (toDelete == NULL) { stack->pushBool(false); - return S_OK; + return STATUS_OK; } for (int i = 0; i < _nodes.GetSize(); i++) { @@ -348,7 +348,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } stack->pushBool(true); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -420,13 +420,13 @@ CScValue *CAdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdLayer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -434,7 +434,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CloseUp") == 0) { _closeUp = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -443,7 +443,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Width") == 0) { _width = value->getInt(); if (_width < 0) _width = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -452,7 +452,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Height") == 0) { _height = value->getInt(); if (_height < 0) _height = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -463,7 +463,7 @@ HRESULT CAdLayer::scSetProperty(const char *name, CScValue *value) { if (b == false && _main) { Game->LOG(0, "Warning: cannot deactivate scene's main layer"); } else _active = b; - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -477,7 +477,7 @@ const char *CAdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "LAYER {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -515,12 +515,12 @@ HRESULT CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdLayer::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdLayer::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -531,7 +531,7 @@ HRESULT CAdLayer::persist(CBPersistMgr *persistMgr) { _nodes.persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 1090d253e1..29df4c0c34 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -42,14 +42,14 @@ public: CAdLayer(CBGame *inGame); virtual ~CAdLayer(); CBArray _nodes; - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 954c12c9fc..7c190285ae 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -92,7 +92,7 @@ void CAdNodeState::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdNodeState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_active)); @@ -102,7 +102,7 @@ HRESULT CAdNodeState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_alphaColor)); for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); - return S_OK; + return STATUS_OK; } @@ -129,8 +129,8 @@ char *CAdNodeState::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { - if (!entity) return E_FAIL; +ERRORCODE CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { + if (!entity) return STATUS_FAILED; // hack! if (this->Game != entity->Game) this->Game = entity->Game; @@ -163,7 +163,7 @@ HRESULT CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, b entity->_alphaColor = _alphaColor; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index a5456b3407..fcd1f1402b 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -35,7 +35,7 @@ class CAdEntity; class CAdNodeState : public CBBase { public: - HRESULT transferEntity(CAdEntity *entity, bool includingSprites, bool saving); + ERRORCODE transferEntity(CAdEntity *entity, bool includingSprites, bool saving); void setName(const char *name); void setFilename(const char *filename); void setCursor(const char *filename); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index cdb84a35da..038cacefad 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -151,16 +151,16 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::playAnim(const char *filename) { +ERRORCODE CAdObject::playAnim(const char *filename) { delete _animSprite; _animSprite = NULL; _animSprite = new CBSprite(Game, this); if (!_animSprite) { Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT res = _animSprite->loadFile(filename); - if (FAILED(res)) { + ERRORCODE res = _animSprite->loadFile(filename); + if (DID_FAIL(res)) { Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); delete _animSprite; _animSprite = NULL; @@ -168,38 +168,38 @@ HRESULT CAdObject::playAnim(const char *filename) { } _state = STATE_PLAYING_ANIM; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::display() { - return S_OK; +ERRORCODE CAdObject::display() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::update() { - return S_OK; +ERRORCODE CAdObject::update() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { stack->correctParams(1); - if (FAILED(playAnim(stack->pop()->getString()))) stack->pushBool(false); + if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); else { if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -209,7 +209,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); reset(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -218,7 +218,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "IsTalking") == 0) { stack->correctParams(0); stack->pushBool(_state == STATE_TALKING); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -232,7 +232,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _nextState = STATE_READY; stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -246,7 +246,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th strcpy(_forcedTalkAnimName, animName); _forcedTalkAnimUsed = false; stack->pushBool(true); - return S_OK; + return STATUS_OK; } @@ -276,7 +276,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -317,7 +317,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!regFound) _stickRegion = NULL; stack->pushBool(regFound); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -331,7 +331,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else SetFont(val->getString()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -341,7 +341,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); if (_font && _font->_filename) stack->pushString(_font->_filename); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -360,7 +360,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *itemName = val->getString(); val = stack->pop(); const char *insertAfter = val->isNULL() ? NULL : val->getString(); - if (FAILED(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); + if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); else { // hide associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(itemName, false); @@ -369,7 +369,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } else script->runtimeError("TakeItem: item name expected"); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -385,7 +385,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (!val->isNULL()) { - if (FAILED(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); + if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true); @@ -393,7 +393,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } else script->runtimeError("DropItem: item name expected"); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -417,7 +417,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else stack->pushNative(_inventory->_takenItems[val->getInt()], true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -436,16 +436,16 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); - return S_OK; + return STATUS_OK; } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { stack->pushBool(true); - return S_OK; + return STATUS_OK; } } } else script->runtimeError("HasItem: item name expected"); stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -461,7 +461,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (emitter) stack->pushNative(_partEmitter, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -475,7 +475,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -488,9 +488,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th int offsetX = stack->pop()->getInt(); int offsetY = stack->pop()->getInt(); - HRESULT res; + ERRORCODE res; CAdEntity *ent = new CAdEntity(Game); - if (FAILED(res = ent->loadFile(filename))) { + if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; ent = NULL; script->runtimeError("AddAttachment() failed loading entity '%s'", filename); @@ -508,7 +508,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -557,7 +557,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } stack->pushBool(found); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -600,7 +600,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (ret != NULL) stack->pushNative(ret, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -715,14 +715,14 @@ CScValue *CAdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { _active = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -730,7 +730,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IgnoreItems") == 0) { _ignoreItems = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -738,7 +738,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SceneIndependent") == 0) { _sceneIndependent = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -746,7 +746,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesWidth") == 0) { _subtitlesWidth = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -754,7 +754,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosRelative") == 0) { _subtitlesModRelative = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -762,7 +762,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosX") == 0) { _subtitlesModX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -770,7 +770,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosY") == 0) { _subtitlesModY = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -778,7 +778,7 @@ HRESULT CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesPosXCenter") == 0) { _subtitlesModXCenter = value->getBool(); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -792,14 +792,14 @@ const char *CAdObject::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::SetFont(const char *filename) { +ERRORCODE CAdObject::SetFont(const char *filename) { if (_font) Game->_fontStorage->removeFont(_font); if (filename) { _font = Game->_fontStorage->addFont(filename); - return _font == NULL ? E_FAIL : S_OK; + return _font == NULL ? STATUS_FAILED : STATUS_OK; } else { _font = NULL; - return S_OK; + return STATUS_OK; } } @@ -862,7 +862,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // load sound and set duration appropriately if (sound) { CBSound *snd = new CBSound(Game); - if (snd && SUCCEEDED(snd->setSound(sound, SOUND_SPEECH, true))) { + if (snd && DID_SUCCEED(snd->setSound(sound, SOUND_SPEECH, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { uint32 Length = snd->getLength(); @@ -936,7 +936,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::reset() { +ERRORCODE CAdObject::reset() { if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { delete _animSprite; _animSprite = NULL; @@ -948,12 +948,12 @@ HRESULT CAdObject::reset() { Game->_scEngine->resetObject(this); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); @@ -993,12 +993,12 @@ HRESULT CAdObject::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_partOffsetX)); persistMgr->transfer(TMEMBER(_partOffsetY)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::updateSounds() { +ERRORCODE CAdObject::updateSounds() { if (_sentence && _sentence->_sound) updateOneSound(_sentence->_sound); @@ -1007,7 +1007,7 @@ HRESULT CAdObject::updateSounds() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::resetSoundPan() { +ERRORCODE CAdObject::resetSoundPan() { if (_sentence && _sentence->_sound) { _sentence->_sound->setPan(0.0f); } @@ -1025,18 +1025,18 @@ bool CAdObject::getExtendedFlag(const char *flagName) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); CBBase::saveAsText(buffer, indent + 2); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::updateBlockRegion() { +ERRORCODE CAdObject::updateBlockRegion() { CAdGame *adGame = (CAdGame *)Game; if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) @@ -1045,7 +1045,7 @@ HRESULT CAdObject::updateBlockRegion() { if (_wptGroup && _currentWptGroup) _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1059,7 +1059,7 @@ CAdInventory *CAdObject::getInventory() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::afterMove() { +ERRORCODE CAdObject::afterMove() { CAdRegion *newRegions[MAX_NUM_REGIONS]; ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); @@ -1083,18 +1083,18 @@ HRESULT CAdObject::afterMove() { _currentRegions[i] = newRegions[i]; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::invalidateCurrRegions() { +ERRORCODE CAdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::getScale(float *scaleX, float *scaleY) { +ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { if (_zoomable) { if (_scaleX >= 0 || _scaleY >= 0) { *scaleX = _scaleX < 0 ? 100 : _scaleX; @@ -1104,22 +1104,22 @@ HRESULT CAdObject::getScale(float *scaleX, float *scaleY) { } else { *scaleX = *scaleY = 100; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::updateSpriteAttachments() { +ERRORCODE CAdObject::updateSpriteAttachments() { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { _attachmentsPre[i]->update(); } for (int i = 0; i < _attachmentsPost.GetSize(); i++) { _attachmentsPost[i]->update(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::displaySpriteAttachments(bool preDisplay) { +ERRORCODE CAdObject::displaySpriteAttachments(bool preDisplay) { if (preDisplay) { for (int i = 0; i < _attachmentsPre.GetSize(); i++) { displaySpriteAttachment(_attachmentsPre[i]); @@ -1129,12 +1129,12 @@ HRESULT CAdObject::displaySpriteAttachments(bool preDisplay) { displaySpriteAttachment(_attachmentsPost[i]); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::displaySpriteAttachment(CAdObject *attachment) { - if (!attachment->_active) return S_OK; +ERRORCODE CAdObject::displaySpriteAttachment(CAdObject *attachment) { + if (!attachment->_active) return STATUS_OK; float scaleX, scaleY; getScale(&scaleX, &scaleY); @@ -1162,7 +1162,7 @@ HRESULT CAdObject::displaySpriteAttachment(CAdObject *attachment) { attachment->_registerAlias = this; attachment->_registrable = this->_registrable; - HRESULT ret = attachment->display(); + ERRORCODE ret = attachment->display(); attachment->_posX = origX; attachment->_posY = origY; @@ -1187,8 +1187,8 @@ CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, i } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdObject::updatePartEmitter() { - if (!_partEmitter) return E_FAIL; +ERRORCODE CAdObject::updatePartEmitter() { + if (!_partEmitter) return STATUS_FAILED; if (_partFollowParent) { float scaleX, scaleY; diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index def28eff1d..c71efce1a5 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -47,12 +47,12 @@ class CAdObject : public CBObject { public: CPartEmitter *_partEmitter; virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); - virtual HRESULT updatePartEmitter(); + virtual ERRORCODE updatePartEmitter(); bool _partFollowParent; int _partOffsetX; int _partOffsetY; - HRESULT invalidateCurrRegions(); + ERRORCODE invalidateCurrRegions(); bool _subtitlesModRelative; bool _subtitlesModXCenter; int _subtitlesModX; @@ -61,23 +61,23 @@ public: CAdRegion *_stickRegion; bool _sceneIndependent; bool _ignoreItems; - HRESULT updateBlockRegion(); + ERRORCODE updateBlockRegion(); bool _forcedTalkAnimUsed; char *_forcedTalkAnimName; virtual bool getExtendedFlag(const char *flagName); - virtual HRESULT resetSoundPan(); - virtual HRESULT updateSounds(); - HRESULT reset(); + virtual ERRORCODE resetSoundPan(); + virtual ERRORCODE updateSounds(); + ERRORCODE reset(); DECLARE_PERSISTENT(CAdObject, CBObject) virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); virtual int getHeight(); CAdSentence *_sentence; - HRESULT SetFont(const char *filename); - virtual HRESULT update(); - virtual HRESULT display(); + ERRORCODE SetFont(const char *filename); + virtual ERRORCODE update(); + virtual ERRORCODE display(); bool _drawn; bool _active; - virtual HRESULT playAnim(const char *filename); + virtual ERRORCODE playAnim(const char *filename); CBSprite *_animSprite; CBSprite *_currentSprite; TObjectState _state; @@ -93,29 +93,29 @@ public: CAdWaypointGroup *_currentWptGroup; CAdInventory *getInventory(); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT afterMove(); + virtual ERRORCODE afterMove(); CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); CBArray _attachmentsPre; CBArray _attachmentsPost; - HRESULT updateSpriteAttachments(); - HRESULT displaySpriteAttachments(bool preDisplay); + ERRORCODE updateSpriteAttachments(); + ERRORCODE displaySpriteAttachments(bool preDisplay); CAdObject *_registerAlias; private: - HRESULT displaySpriteAttachment(CAdObject *attachment); + ERRORCODE displaySpriteAttachment(CAdObject *attachment); CAdInventory *_inventory; protected: - HRESULT getScale(float *scaleX, float *scaleY); + ERRORCODE getScale(float *scaleX, float *scaleY); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index ca7adf0461..bac9681cef 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -98,7 +98,7 @@ bool CAdPath::setReady(bool ready) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPath::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdPath::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); @@ -106,7 +106,7 @@ HRESULT CAdPath::persist(CBPersistMgr *persistMgr) { _points.persist(persistMgr); persistMgr->transfer(TMEMBER(_ready)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp index 4f82f8e7f4..17c2e41fb1 100644 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -61,7 +61,7 @@ CAdPathPoint::~CAdPathPoint() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdPathPoint::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdPathPoint::persist(CBPersistMgr *persistMgr) { CBPoint::persist(persistMgr); @@ -69,7 +69,7 @@ HRESULT CAdPathPoint::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_marked)); persistMgr->transfer(TMEMBER(_origin)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 0ea0bb9ed1..ec6017759a 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -54,19 +54,19 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::loadFile(const char *filename) { +ERRORCODE CAdRegion::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); delete [] buffer; @@ -95,7 +95,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -123,7 +123,7 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -136,7 +136,7 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -205,21 +205,21 @@ HRESULT CAdRegion::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in REGION definition"); - return E_FAIL; + return STATUS_FAILED; } createRegion(); - _alpha = DRGBA(ar, ag, ab, alpha); + _alpha = BYTETORGBA(ar, ag, ab, alpha); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -230,7 +230,7 @@ HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _posY = stack->pop()->getInt(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); @@ -294,13 +294,13 @@ CScValue *CAdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -308,7 +308,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Blocked") == 0) { _blocked = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -316,7 +316,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { _decoration = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -324,7 +324,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { _zoom = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -332,7 +332,7 @@ HRESULT CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { _alpha = (uint32)value->getInt(); - return S_OK; + return STATUS_OK; } else return CBRegion::scSetProperty(name, value); @@ -346,7 +346,7 @@ const char *CAdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "REGION {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -354,8 +354,8 @@ HRESULT CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); int i; @@ -373,12 +373,12 @@ HRESULT CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRegion::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdRegion::persist(CBPersistMgr *persistMgr) { CBRegion::persist(persistMgr); persistMgr->transfer(TMEMBER(_alpha)); @@ -386,7 +386,7 @@ HRESULT CAdRegion::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_decoration)); persistMgr->transfer(TMEMBER(_zoom)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 0e5700828a..2b8d13b587 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -42,14 +42,14 @@ public: bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 320f026863..7c6d3f56c9 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -72,59 +72,59 @@ void CAdResponse::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::setIcon(const char *filename) { +ERRORCODE CAdResponse::setIcon(const char *filename) { delete _icon; _icon = new CBSprite(Game); - if (!_icon || FAILED(_icon->loadFile(filename))) { + if (!_icon || DID_FAIL(_icon->loadFile(filename))) { Game->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); delete _icon; _icon = NULL; - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::setFont(const char *filename) { +ERRORCODE CAdResponse::setFont(const char *filename) { if (_font) Game->_fontStorage->removeFont(_font); _font = Game->_fontStorage->addFont(filename); if (!_font) { Game->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::setIconHover(const char *filename) { +ERRORCODE CAdResponse::setIconHover(const char *filename) { delete _iconHover; _iconHover = new CBSprite(Game); - if (!_iconHover || FAILED(_iconHover->loadFile(filename))) { + if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { Game->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); delete _iconHover; _iconHover = NULL; - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::setIconPressed(const char *filename) { +ERRORCODE CAdResponse::setIconPressed(const char *filename) { delete _iconPressed; _iconPressed = new CBSprite(Game); - if (!_iconPressed || FAILED(_iconPressed->loadFile(filename))) { + if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { Game->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); delete _iconPressed; _iconPressed = NULL; - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponse::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdResponse::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -137,7 +137,7 @@ HRESULT CAdResponse::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER_INT(_responseType)); persistMgr->transfer(TMEMBER(_font)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h index 8774267a97..46f16ea98f 100644 --- a/engines/wintermute/Ad/AdResponse.h +++ b/engines/wintermute/Ad/AdResponse.h @@ -38,10 +38,10 @@ class CBFont; class CAdResponse : public CBObject { public: DECLARE_PERSISTENT(CAdResponse, CBObject) - HRESULT setIcon(const char *filename); - HRESULT setFont(const char *filename); - HRESULT setIconHover(const char *filename); - HRESULT setIconPressed(const char *filename); + ERRORCODE setIcon(const char *filename); + ERRORCODE setFont(const char *filename); + ERRORCODE setIconHover(const char *filename); + ERRORCODE setIconPressed(const char *filename); void setText(const char *text); int _iD; CBSprite *_icon; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index eea61a4268..0eeadd72bc 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -111,7 +111,7 @@ void CAdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::invalidateButtons() { +ERRORCODE CAdResponseBox::invalidateButtons() { for (int i = 0; i < _respButtons.GetSize(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; @@ -120,12 +120,12 @@ HRESULT CAdResponseBox::invalidateButtons() { _respButtons[i]->_fontPress = NULL; _respButtons[i]->setText(""); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::createButtons() { +ERRORCODE CAdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; @@ -182,24 +182,24 @@ HRESULT CAdResponseBox::createButtons() { } _ready = false; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::loadFile(const char *filename) { +ERRORCODE CAdResponseBox::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); delete [] buffer; @@ -223,7 +223,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -247,7 +247,7 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { Game->LOG(0, "'RESPONSE_BOX' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -255,13 +255,13 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_WINDOW: delete _window; _window = new CUIWindow(Game); - if (!_window || FAILED(_window->loadBuffer(params, false))) { + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; @@ -311,7 +311,7 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -321,7 +321,7 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in RESPONSE_BOX definition"); - return E_FAIL; + return STATUS_FAILED; } if (_window) { @@ -331,11 +331,11 @@ HRESULT CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "RESPONSE_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -391,12 +391,12 @@ HRESULT CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::display() { +ERRORCODE CAdResponseBox::display() { RECT rect = _responseArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); @@ -477,12 +477,12 @@ HRESULT CAdResponseBox::display() { _respButtons[i]->display(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { +ERRORCODE CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -506,12 +506,12 @@ HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { error("AdResponseBox::Listen - Unhandled enum"); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_font)); @@ -531,12 +531,12 @@ HRESULT CAdResponseBox::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER_INT(_verticalAlign)); persistMgr->transfer(TMEMBER_INT(_align)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::weedResponses() { +ERRORCODE CAdResponseBox::weedResponses() { CAdGame *adGame = (CAdGame *)Game; for (int i = 0; i < _responses.GetSize(); i++) { @@ -561,7 +561,7 @@ HRESULT CAdResponseBox::weedResponses() { break; } } - return S_OK; + return STATUS_OK; } @@ -573,7 +573,7 @@ void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::handleResponse(CAdResponse *response) { +ERRORCODE CAdResponseBox::handleResponse(CAdResponse *response) { setLastResponseText(response->_text, response->_textOrig); CAdGame *adGame = (CAdGame *)Game; @@ -590,7 +590,7 @@ HRESULT CAdResponseBox::handleResponse(CAdResponse *response) { warning("CAdResponseBox::HandleResponse - Unhandled enum"); } - return S_OK; + return STATUS_OK; } @@ -635,13 +635,13 @@ CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { +ERRORCODE CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _respButtons.GetSize(); i++) { objects.Add(_respButtons[i]); } if (_window) _window->getWindowObjects(objects, interactiveOnly); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 3d8a8bb7a6..de21921fde 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -42,29 +42,29 @@ class CAdResponseBox : public CBObject { public: CBObject *getNextAccessObject(CBObject *CurrObject); CBObject *getPrevAccessObject(CBObject *CurrObject); - HRESULT getObjects(CBArray &objects, bool interactiveOnly); + ERRORCODE getObjects(CBArray &objects, bool interactiveOnly); - HRESULT handleResponse(CAdResponse *response); + ERRORCODE handleResponse(CAdResponse *response); void setLastResponseText(const char *text, const char *textOrig); char *_lastResponseText; char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) CScScript *_waitingScript; - virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); + virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); typedef enum { EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE } TResponseEvent; - HRESULT weedResponses(); - HRESULT display(); + ERRORCODE weedResponses(); + ERRORCODE display(); int _spacing; int _scrollOffset; CBFont *_fontHover; CBFont *_font; - HRESULT createButtons(); - HRESULT invalidateButtons(); + ERRORCODE createButtons(); + ERRORCODE invalidateButtons(); void clearButtons(); void clearResponses(); CAdResponseBox(CBGame *inGame); @@ -77,9 +77,9 @@ public: RECT _responseArea; int _verticalAlign; TTextAlign _align; - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 60df7734e1..5615777daf 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -49,12 +49,12 @@ CAdResponseContext::~CAdResponseContext() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdResponseContext::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdResponseContext::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_iD)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index dbe00460dc..26e4bca48d 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -53,19 +53,19 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::loadFile(const char *filename) { +ERRORCODE CAdRotLevel::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); delete [] buffer; @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -98,7 +98,7 @@ HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -106,7 +106,7 @@ HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_X: @@ -127,33 +127,33 @@ HRESULT CAdRotLevel::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ROTATION_LEVEL definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); buffer->putTextIndent(indent + 2, "X=%d\n", _posX); buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdRotLevel::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdRotLevel::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_rotation)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index 3c02cddc34..76e2484b07 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -39,9 +39,9 @@ public: CAdRotLevel(CBGame *inGame); virtual ~CAdRotLevel(); float _rotation; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index d0f1d479b3..2cfbbb05e1 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -51,19 +51,19 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::loadFile(const char *filename) { +ERRORCODE CAdScaleLevel::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); delete [] buffer; @@ -80,7 +80,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -96,7 +96,7 @@ HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { Game->LOG(0, "'SCALE_LEVEL' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -104,7 +104,7 @@ HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_Y: @@ -125,33 +125,33 @@ HRESULT CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in SCALE_LEVEL definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScaleLevel::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdScaleLevel::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_scale)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index 31e67f05d8..b62e18e344 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -40,9 +40,9 @@ public: float _scale; CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index fe8295abad..9362830a54 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -481,7 +481,7 @@ void CAdScene::pathFinderStep() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::initLoop() { +ERRORCODE CAdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = Game->_currentTime; @@ -495,25 +495,25 @@ HRESULT CAdScene::initLoop() { while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::loadFile(const char *filename) { +ERRORCODE CAdScene::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; delete[] _filename; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -565,7 +565,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -615,7 +615,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { Game->LOG(0, "'SCENE' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -627,7 +627,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -640,7 +640,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_LAYER: { CAdLayer *layer = new CAdLayer(Game); - if (!layer || FAILED(layer->loadBuffer(params, false))) { + if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete layer; layer = NULL; @@ -658,7 +658,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_WAYPOINTS: { CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - if (!wpt || FAILED(wpt->loadBuffer(params, false))) { + if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete wpt; wpt = NULL; @@ -671,7 +671,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCALE_LEVEL: { CAdScaleLevel *sl = new CAdScaleLevel(Game); - if (!sl || FAILED(sl->loadBuffer(params, false))) { + if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete sl; sl = NULL; @@ -684,7 +684,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_ROTATION_LEVEL: { CAdRotLevel *rl = new CAdRotLevel(Game); - if (!rl || FAILED(rl->loadBuffer(params, false))) { + if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete rl; rl = NULL; @@ -697,7 +697,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_ENTITY: { CAdEntity *entity = new CAdEntity(Game); - if (!entity || FAILED(entity->loadBuffer(params, false))) { + if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; entity = NULL; @@ -710,7 +710,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -731,62 +731,62 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_EDITOR_COLOR_FRAME: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColFrame = DRGBA(ar, ag, ab, aa); + _editorColFrame = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntity = DRGBA(ar, ag, ab, aa); + _editorColEntity = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_ENTITY_SEL: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntitySel = DRGBA(ar, ag, ab, aa); + _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION_SEL: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegionSel = DRGBA(ar, ag, ab, aa); + _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION_SEL: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecorSel = DRGBA(ar, ag, ab, aa); + _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED_SEL: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlockedSel = DRGBA(ar, ag, ab, aa); + _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypointsSel = DRGBA(ar, ag, ab, aa); + _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_REGION: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegion = DRGBA(ar, ag, ab, aa); + _editorColRegion = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_DECORATION: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecor = DRGBA(ar, ag, ab, aa); + _editorColDecor = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_BLOCKED: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlocked = DRGBA(ar, ag, ab, aa); + _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_WAYPOINTS: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypoints = DRGBA(ar, ag, ab, aa); + _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_COLOR_SCALE: parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColScale = DRGBA(ar, ag, ab, aa); + _editorColScale = BYTETORGBA(ar, ag, ab, aa); break; case TOKEN_EDITOR_SHOW_REGIONS: @@ -840,7 +840,7 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in SCENE definition"); - return E_FAIL; + return STATUS_FAILED; } if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); @@ -852,12 +852,12 @@ HRESULT CAdScene::loadBuffer(byte *buffer, bool complete) { _initialized = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::traverseNodes(bool doUpdate) { - if (!_initialized) return S_OK; +ERRORCODE CAdScene::traverseNodes(bool doUpdate) { + if (!_initialized) return STATUS_OK; int j, k; CAdGame *adGame = (CAdGame *)Game; @@ -1025,17 +1025,17 @@ HRESULT CAdScene::traverseNodes(bool doUpdate) { if (PopViewport) Game->popViewport(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::display() { +ERRORCODE CAdScene::display() { return traverseNodes(false); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::updateFreeObjects() { +ERRORCODE CAdScene::updateFreeObjects() { CAdGame *adGame = (CAdGame *)Game; bool is3DSet; @@ -1062,12 +1062,12 @@ HRESULT CAdScene::updateFreeObjects() { } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { +ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { CAdGame *adGame = (CAdGame *)Game; CBArray objects; CAdObject *obj; @@ -1116,7 +1116,7 @@ HRESULT CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1130,7 +1130,7 @@ int CAdScene::compareObjs(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::displayRegionContentOld(CAdRegion *region) { +ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { CAdGame *adGame = (CAdGame *)Game; CAdObject *obj; @@ -1175,12 +1175,12 @@ HRESULT CAdScene::displayRegionContentOld(CAdRegion *region) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::update() { +ERRORCODE CAdScene::update() { return traverseNodes(true); } @@ -1240,14 +1240,14 @@ void CAdScene::skipTo(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); CAdActor *act = new CAdActor(Game); - if (act && SUCCEEDED(act->loadFile(stack->pop()->getString()))) { + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); } else { @@ -1255,7 +1255,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi act = NULL; stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1264,7 +1264,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); CAdEntity *ent = new CAdEntity(Game); - if (ent && SUCCEEDED(ent->loadFile(stack->pop()->getString()))) { + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); } else { @@ -1272,7 +1272,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ent = NULL; stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1286,7 +1286,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1300,7 +1300,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1316,7 +1316,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi skipTo(val1->getInt(), val2->getInt()); } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1333,7 +1333,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1358,7 +1358,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (!LayerFound) stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1369,7 +1369,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int group = stack->pop()->getInt(); if (group < 0 || group >= _waypointGroups.GetSize()) stack->pushNULL(); else stack->pushNative(_waypointGroups[group], true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1383,7 +1383,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (node) stack->pushNative((CBScriptable *)node, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1409,7 +1409,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (ret) stack->pushNative(ret, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1431,12 +1431,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (node->_region->_decoration && !includeDecors) continue; stack->pushNative(node->_region, true); - return S_OK; + return STATUS_OK; } } } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1448,7 +1448,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int y = stack->pop()->getInt(); stack->pushBool(isBlockedAt(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1460,7 +1460,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int y = stack->pop()->getInt(); stack->pushBool(isWalkableAt(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1472,7 +1472,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int y = stack->pop()->getInt(); stack->pushFloat(getZoomAt(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1484,7 +1484,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int y = stack->pop()->getInt(); stack->pushFloat(getRotationAt(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1498,7 +1498,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } stack->pushBool(ret); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1512,11 +1512,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi byte blue = stack->pop()->getInt(0); byte alpha = stack->pop()->getInt(0xFF); - _fader->fadeOut(DRGBA(red, green, blue, alpha), duration); + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1530,11 +1530,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi byte blue = stack->pop()->getInt(0); byte alpha = stack->pop()->getInt(0xFF); - _fader->fadeIn(DRGBA(red, green, blue, alpha), duration); + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1543,7 +1543,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "GetFadeColor") == 0) { stack->correctParams(0); stack->pushInt(_fader->getCurrentColor()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1554,7 +1554,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); stack->pushBool(pointInViewport(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1575,7 +1575,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1595,7 +1595,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi Game->registerObject(layer); stack->pushNative(layer, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1619,7 +1619,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi Game->registerObject(layer); stack->pushNative(layer, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1646,13 +1646,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (toDelete == NULL) { stack->pushBool(false); - return S_OK; + return STATUS_OK; } if (toDelete->_main) { script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); stack->pushBool(false); - return S_OK; + return STATUS_OK; } for (int i = 0; i < _layers.GetSize(); i++) { @@ -1663,7 +1663,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } stack->pushBool(true); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -1834,13 +1834,13 @@ CScValue *CAdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1848,7 +1848,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoScroll") == 0) { _autoScroll = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1856,7 +1856,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentState") == 0) { _persistentState = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1864,7 +1864,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PersistentStateSprites") == 0) { _persistentStateSprites = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1872,7 +1872,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsX") == 0) { _scrollPixelsH = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1880,7 +1880,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollPixelsY") == 0) { _scrollPixelsV = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1888,7 +1888,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedX") == 0) { _scrollTimeH = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1896,7 +1896,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollSpeedY") == 0) { _scrollTimeV = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1912,7 +1912,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); _targetOffsetLeft = _offsetLeft; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1928,7 +1928,7 @@ HRESULT CAdScene::scSetProperty(const char *name, CScValue *value) { _offsetTop = MIN(_offsetTop, _height - viewportHeight); _targetOffsetTop = _offsetTop; - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -1942,26 +1942,26 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::addObject(CAdObject *object) { +ERRORCODE CAdScene::addObject(CAdObject *object) { _objects.Add(object); return Game->registerObject(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::removeObject(CAdObject *object) { +ERRORCODE CAdScene::removeObject(CAdObject *object) { for (int i = 0; i < _objects.GetSize(); i++) { if (_objects[i] == object) { _objects.RemoveAt(i); return Game->unregisterObject(object); } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { int i; buffer->putTextIndent(indent, "SCENE {\n"); @@ -1998,18 +1998,18 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColFrame), D3DCOLGetG(_editorColFrame), D3DCOLGetB(_editorColFrame), D3DCOLGetA(_editorColFrame)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntitySel), D3DCOLGetG(_editorColEntitySel), D3DCOLGetB(_editorColEntitySel), D3DCOLGetA(_editorColEntitySel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegionSel), D3DCOLGetG(_editorColRegionSel), D3DCOLGetB(_editorColRegionSel), D3DCOLGetA(_editorColRegionSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlockedSel), D3DCOLGetG(_editorColBlockedSel), D3DCOLGetB(_editorColBlockedSel), D3DCOLGetA(_editorColBlockedSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecorSel), D3DCOLGetG(_editorColDecorSel), D3DCOLGetB(_editorColDecorSel), D3DCOLGetA(_editorColDecorSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypointsSel), D3DCOLGetG(_editorColWaypointsSel), D3DCOLGetB(_editorColWaypointsSel), D3DCOLGetA(_editorColWaypointsSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColEntity), D3DCOLGetG(_editorColEntity), D3DCOLGetB(_editorColEntity), D3DCOLGetA(_editorColEntity)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColRegion), D3DCOLGetG(_editorColRegion), D3DCOLGetB(_editorColRegion), D3DCOLGetA(_editorColRegion)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColDecor), D3DCOLGetG(_editorColDecor), D3DCOLGetB(_editorColDecor), D3DCOLGetA(_editorColDecor)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColBlocked), D3DCOLGetG(_editorColBlocked), D3DCOLGetB(_editorColBlocked), D3DCOLGetA(_editorColBlocked)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColWaypoints), D3DCOLGetG(_editorColWaypoints), D3DCOLGetB(_editorColWaypoints), D3DCOLGetA(_editorColWaypoints)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", D3DCOLGetR(_editorColScale), D3DCOLGetG(_editorColScale), D3DCOLGetB(_editorColScale), D3DCOLGetA(_editorColScale)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColFrame), RGBCOLGetG(_editorColFrame), RGBCOLGetB(_editorColFrame), RGBCOLGetA(_editorColFrame)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntitySel), RGBCOLGetG(_editorColEntitySel), RGBCOLGetB(_editorColEntitySel), RGBCOLGetA(_editorColEntitySel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegionSel), RGBCOLGetG(_editorColRegionSel), RGBCOLGetB(_editorColRegionSel), RGBCOLGetA(_editorColRegionSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlockedSel), RGBCOLGetG(_editorColBlockedSel), RGBCOLGetB(_editorColBlockedSel), RGBCOLGetA(_editorColBlockedSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecorSel), RGBCOLGetG(_editorColDecorSel), RGBCOLGetB(_editorColDecorSel), RGBCOLGetA(_editorColDecorSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypointsSel), RGBCOLGetG(_editorColWaypointsSel), RGBCOLGetB(_editorColWaypointsSel), RGBCOLGetA(_editorColWaypointsSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntity), RGBCOLGetG(_editorColEntity), RGBCOLGetB(_editorColEntity), RGBCOLGetA(_editorColEntity)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegion), RGBCOLGetG(_editorColRegion), RGBCOLGetB(_editorColRegion), RGBCOLGetA(_editorColRegion)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecor), RGBCOLGetG(_editorColDecor), RGBCOLGetB(_editorColDecor), RGBCOLGetA(_editorColDecor)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlocked), RGBCOLGetG(_editorColBlocked), RGBCOLGetB(_editorColBlocked), RGBCOLGetA(_editorColBlocked)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypoints), RGBCOLGetG(_editorColWaypoints), RGBCOLGetB(_editorColWaypoints), RGBCOLGetA(_editorColWaypoints)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColScale), RGBCOLGetG(_editorColScale), RGBCOLGetB(_editorColScale), RGBCOLGetA(_editorColScale)); buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); @@ -2054,12 +2054,12 @@ HRESULT CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::sortScaleLevels() { +ERRORCODE CAdScene::sortScaleLevels() { bool changed; do { changed = false; @@ -2075,12 +2075,12 @@ HRESULT CAdScene::sortScaleLevels() { } while (changed); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::sortRotLevels() { +ERRORCODE CAdScene::sortRotLevels() { bool changed; do { changed = false; @@ -2096,7 +2096,7 @@ HRESULT CAdScene::sortRotLevels() { } while (changed); - return S_OK; + return STATUS_OK; } @@ -2127,7 +2127,7 @@ float CAdScene::getScaleAt(int Y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdScene::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_autoScroll)); @@ -2183,16 +2183,16 @@ HRESULT CAdScene::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_viewport)); persistMgr->transfer(TMEMBER(_width)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::afterLoad() { - return S_OK; +ERRORCODE CAdScene::afterLoad() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { +ERRORCODE CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; int x1, y1, x2, y2; @@ -2222,7 +2222,7 @@ HRESULT CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { *targetX = xCount; *targetY = (int)y; - return S_OK; + return STATUS_OK; } y += yStep; } @@ -2241,22 +2241,22 @@ HRESULT CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { *targetX = (int)x; *targetY = yCount; - return S_OK; + return STATUS_OK; } x += xStep; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { +ERRORCODE CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { int x = *argX; int y = *argY; if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { - return S_OK; + return STATUS_OK; } // right @@ -2300,7 +2300,7 @@ HRESULT CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *arg } if (!found_left && !found_right && !found_up && !found_down) { - return S_OK; + return STATUS_OK; } int OffsetX = INT_MAX, OffsetY = INT_MAX; @@ -2323,7 +2323,7 @@ HRESULT CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *arg *argY = *argY + OffsetY; if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); - else return S_OK; + else return STATUS_OK; } @@ -2350,7 +2350,7 @@ void CAdScene::pfPointsAdd(int x, int y, int distance) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getViewportOffset(int *offsetX, int *offsetY) { +ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (offsetX) *offsetX = _viewport->_offsetX; @@ -2362,12 +2362,12 @@ HRESULT CAdScene::getViewportOffset(int *offsetX, int *offsetY) { if (offsetX) *offsetX = 0; if (offsetY) *offsetY = 0; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getViewportSize(int *width, int *height) { +ERRORCODE CAdScene::getViewportSize(int *width, int *height) { CAdGame *adGame = (CAdGame *)Game; if (_viewport && !Game->_editorMode) { if (width) *width = _viewport->getWidth(); @@ -2379,7 +2379,7 @@ HRESULT CAdScene::getViewportSize(int *width, int *height) { if (width) *width = Game->_renderer->_width; if (height) *height = Game->_renderer->_height; } - return S_OK; + return STATUS_OK; } @@ -2464,24 +2464,24 @@ CBObject *CAdScene::getNodeByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::saveState() { +ERRORCODE CAdScene::saveState() { return persistState(true); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::loadState() { +ERRORCODE CAdScene::loadState() { return persistState(false); } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::persistState(bool saving) { - if (!_persistentState) return S_OK; +ERRORCODE CAdScene::persistState(bool saving) { + if (!_persistentState) return STATUS_OK; CAdGame *adGame = (CAdGame *)Game; CAdSceneState *state = adGame->getSceneState(_filename, saving); - if (!state) return S_OK; + if (!state) return STATUS_OK; CAdNodeState *nodeState; @@ -2537,7 +2537,7 @@ HRESULT CAdScene::persistState(bool saving) { } } - return S_OK; + return STATUS_OK; } @@ -2568,7 +2568,7 @@ float CAdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::handleItemAssociations(const char *itemName, bool show) { +ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _layers.GetSize(); i++) { CAdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.GetSize(); j++) { @@ -2587,12 +2587,12 @@ HRESULT CAdScene::handleItemAssociations(const char *itemName, bool show) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { +ERRORCODE CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { int numUsed = 0; if (_mainLayer) { for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { @@ -2609,12 +2609,12 @@ HRESULT CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegi regionList[i] = NULL; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::restoreDeviceObjects() { - return S_OK; +ERRORCODE CAdScene::restoreDeviceObjects() { + return STATUS_OK; } @@ -2660,7 +2660,7 @@ CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { +ERRORCODE CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.GetSize(); i++) { // close-up layer -> remove everything below it if (interactiveOnly && _layers[i]->_closeUp) objects.RemoveAll(); @@ -2714,12 +2714,12 @@ HRESULT CAdScene::getSceneObjects(CBArray &objects, bo } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { +ERRORCODE CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { CAdGame *adGame = (CAdGame *)Game; CAdObject *obj; @@ -2746,7 +2746,7 @@ HRESULT CAdScene::getRegionObjects(CAdRegion *region, CBArray &Objects, bool InteractiveOnly); - HRESULT getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + ERRORCODE getSceneObjects(CBArray &Objects, bool InteractiveOnly); + ERRORCODE getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - HRESULT afterLoad(); + ERRORCODE afterLoad(); - HRESULT getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - HRESULT handleItemAssociations(const char *ItemName, bool Show); + ERRORCODE getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + ERRORCODE handleItemAssociations(const char *ItemName, bool Show); CUIWindow *_shieldWindow; float getRotationAt(int X, int Y); - HRESULT loadState(); - HRESULT saveState(); + ERRORCODE loadState(); + ERRORCODE saveState(); bool _persistentState; bool _persistentStateSprites; CBObject *getNodeByName(const char *name); @@ -67,27 +67,27 @@ public: bool pointInViewport(int X, int Y); int getOffsetTop(); int getOffsetLeft(); - HRESULT getViewportSize(int *Width = NULL, int *Height = NULL); - HRESULT getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + ERRORCODE getViewportSize(int *Width = NULL, int *Height = NULL); + ERRORCODE getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); CBViewport *_viewport; CBFader *_fader; int _pfPointsNum; void pfPointsAdd(int X, int Y, int Distance); void pfPointsStart(); bool _initialized; - HRESULT correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - HRESULT correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + ERRORCODE correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + ERRORCODE correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); DECLARE_PERSISTENT(CAdScene, CBObject) - HRESULT displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - HRESULT displayRegionContentOld(CAdRegion *Region = NULL); + ERRORCODE displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + ERRORCODE displayRegionContentOld(CAdRegion *Region = NULL); static int compareObjs(const void *Obj1, const void *Obj2); - HRESULT updateFreeObjects(); - HRESULT traverseNodes(bool Update = false); + ERRORCODE updateFreeObjects(); + ERRORCODE traverseNodes(bool Update = false); float getScaleAt(int Y); - HRESULT sortScaleLevels(); - HRESULT sortRotLevels(); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE sortScaleLevels(); + ERRORCODE sortRotLevels(); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; void skipTo(int OffsetX, int OffsetY); @@ -96,7 +96,7 @@ public: void skipToObject(CBObject *Object); void scrollToObject(CBObject *Object); void scrollTo(int OffsetX, int OffsetY); - virtual HRESULT update(); + virtual ERRORCODE update(); bool _autoScroll; int _targetOffsetTop; int _targetOffsetLeft; @@ -109,9 +109,9 @@ public: uint32 _scrollTimeH; uint32 _lastTimeH; - virtual HRESULT display(); + virtual ERRORCODE display(); uint32 _pfMaxTime; - HRESULT initLoop(); + ERRORCODE initLoop(); void pathFinderStep(); bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); @@ -123,12 +123,12 @@ public: CBArray _layers; CBArray _objects; CBArray _waypointGroups; - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); int _width; int _height; - HRESULT addObject(CAdObject *Object); - HRESULT removeObject(CAdObject *Object); + ERRORCODE addObject(CAdObject *Object); + ERRORCODE removeObject(CAdObject *Object); int _editorMarginH; int _editorMarginV; uint32 _editorColFrame; @@ -152,18 +152,18 @@ public: CBArray _scaleLevels; CBArray _rotLevels; - virtual HRESULT restoreDeviceObjects(); + virtual ERRORCODE restoreDeviceObjects(); int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - HRESULT persistState(bool Saving = true); + ERRORCODE persistState(bool Saving = true); void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); bool _pfReady; CBPoint *_pfTarget; diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 0fc4a6a7d6..60ab2891f5 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -53,7 +53,7 @@ CAdSceneNode::~CAdSceneNode() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::setEntity(CAdEntity *entity) { +ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { _type = OBJECT_ENTITY; _entity = entity; return Game->registerObject(entity); @@ -61,7 +61,7 @@ HRESULT CAdSceneNode::setEntity(CAdEntity *entity) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::setRegion(CAdRegion *region) { +ERRORCODE CAdSceneNode::setRegion(CAdRegion *region) { _type = OBJECT_REGION; _region = region; return Game->registerObject(region); @@ -69,7 +69,7 @@ HRESULT CAdSceneNode::setRegion(CAdRegion *region) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneNode::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdSceneNode::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -77,7 +77,7 @@ HRESULT CAdSceneNode::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_region)); persistMgr->transfer(TMEMBER_INT(_type)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h index 0ba0c5d7b6..931d859cca 100644 --- a/engines/wintermute/Ad/AdSceneNode.h +++ b/engines/wintermute/Ad/AdSceneNode.h @@ -39,8 +39,8 @@ namespace WinterMute { class CAdSceneNode : public CBObject { public: DECLARE_PERSISTENT(CAdSceneNode, CBObject) - HRESULT setRegion(CAdRegion *region); - HRESULT setEntity(CAdEntity *entity); + ERRORCODE setRegion(CAdRegion *region); + ERRORCODE setEntity(CAdEntity *entity); CAdEntity *_entity; CAdRegion *_region; TObjectType _type; diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index ffa1dfe84f..9778e8919d 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -54,11 +54,11 @@ CAdSceneState::~CAdSceneState() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSceneState::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdSceneState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); _nodeStates.persist(persistMgr); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 88b0f26d92..341f47a503 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -165,8 +165,8 @@ char *CAdSentence::getStance(int stance) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::display() { - if (!_font || !_text) return E_FAIL; +ERRORCODE CAdSentence::display() { + if (!_font || !_text) return STATUS_FAILED; if (_sound && !_soundStarted) { _sound->play(); @@ -190,7 +190,7 @@ HRESULT CAdSentence::display() { _font->drawText((byte *)_text, x, y, _width, _align); } - return S_OK; + return STATUS_OK; } @@ -204,14 +204,14 @@ void CAdSentence::setSound(CBSound *sound) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::finish() { +ERRORCODE CAdSentence::finish() { if (_sound) _sound->stop(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdSentence::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); @@ -233,17 +233,17 @@ HRESULT CAdSentence::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_fixedPos)); persistMgr->transfer(TMEMBER(_freezable)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::setupTalkFile(const char *soundFilename) { +ERRORCODE CAdSentence::setupTalkFile(const char *soundFilename) { delete _talkDef; _talkDef = NULL; _currentSprite = NULL; - if (!soundFilename) return S_OK; + if (!soundFilename) return STATUS_OK; AnsiString path = PathUtil::getDirectoryName(soundFilename); @@ -254,24 +254,24 @@ HRESULT CAdSentence::setupTalkFile(const char *soundFilename) { Common::SeekableReadStream *file = Game->_fileManager->openFile(talkDefFileName.c_str()); if (file) { Game->_fileManager->closeFile(file); - } else return S_OK; // no talk def file found + } else return STATUS_OK; // no talk def file found _talkDef = new CAdTalkDef(Game); - if (!_talkDef || FAILED(_talkDef->loadFile(talkDefFileName.c_str()))) { + if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { delete _talkDef; _talkDef = NULL; - return E_FAIL; + return STATUS_FAILED; } //Game->LOG(0, "Using .talk file: %s", TalkDefFile); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSentence::update(TDirection dir) { - if (!_talkDef) return S_OK; +ERRORCODE CAdSentence::update(TDirection dir) { + if (!_talkDef) return STATUS_OK; uint32 currentTime; // if sound is available, synchronize with sound, otherwise use timer @@ -305,7 +305,7 @@ HRESULT CAdSentence::update(TDirection dir) { } else _currentSprite = NULL; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 38b44bd619..a8b08433c1 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -45,15 +45,15 @@ public: bool _fixedPos; CBSprite *_currentSprite; char *_currentSkelAnim; - HRESULT update(TDirection dir = DI_DOWN); - HRESULT setupTalkFile(const char *soundFilename); + ERRORCODE update(TDirection dir = DI_DOWN); + ERRORCODE setupTalkFile(const char *soundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) - HRESULT finish(); + ERRORCODE finish(); void setSound(CBSound *Sound); bool _soundStarted; CBSound *_sound; TTextAlign _align; - HRESULT display(); + ERRORCODE display(); int _width; POINT _pos; CBFont *_font; diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index c02ba32ea1..29026a9508 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -58,16 +58,16 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +ERRORCODE CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); delete [] buffer; @@ -90,7 +90,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { +ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -113,7 +113,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { Game->LOG(0, "'SPRITESET' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -122,7 +122,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -133,7 +133,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_LEFT] = spr; break; @@ -141,7 +141,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_RIGHT] = spr; break; @@ -149,7 +149,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UP] = spr; break; @@ -157,7 +157,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWN] = spr; break; @@ -165,7 +165,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPLEFT] = spr; break; @@ -173,7 +173,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPRIGHT] = spr; break; @@ -181,7 +181,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNLEFT] = spr; break; @@ -189,7 +189,7 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; spr = new CBSprite(Game, _owner); - if (!spr || FAILED(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNRIGHT] = spr; break; @@ -200,21 +200,21 @@ HRESULT CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpr } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in SPRITESET definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading SPRITESET definition"); if (spr) delete spr; - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdSpriteSet::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -223,7 +223,7 @@ HRESULT CAdSpriteSet::persist(CBPersistMgr *persistMgr) { persistMgr->transfer("", &_sprites[i]); } - return S_OK; + return STATUS_OK; } @@ -258,7 +258,7 @@ CBSprite *CAdSpriteSet::getSprite(TDirection direction) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITESET {\n"); if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { @@ -296,7 +296,7 @@ HRESULT CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index 7d457048df..2329c955e1 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -38,14 +38,14 @@ namespace WinterMute { class CAdSpriteSet : public CBObject { public: bool containsSprite(CBSprite *sprite); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); CBSprite *getSprite(TDirection direction); DECLARE_PERSISTENT(CAdSpriteSet, CBObject) CBObject *_owner; CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); virtual ~CAdSpriteSet(); - HRESULT loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - HRESULT loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + ERRORCODE loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + ERRORCODE loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); CBSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 8c48942de5..0f16241e99 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -69,18 +69,18 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::loadFile(const char *filename) { +ERRORCODE CAdTalkDef::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; CBUtils::setString(&_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); delete [] buffer; @@ -98,7 +98,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -116,7 +116,7 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { Game->LOG(0, "'TALK' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -124,12 +124,12 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_ACTION: { CAdTalkNode *Node = new CAdTalkNode(Game); - if (Node && SUCCEEDED(Node->loadBuffer(params, false))) _nodes.Add(Node); + if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.Add(Node); else { delete Node; Node = NULL; @@ -149,7 +149,7 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { case TOKEN_DEFAULT_SPRITESET: { delete _defaultSpriteSet; _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadBuffer(params, false))) { + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; cmd = PARSERR_GENERIC; @@ -165,12 +165,12 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in TALK definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading TALK definition"); - return E_FAIL; + return STATUS_FAILED; } delete _defaultSprite; @@ -180,21 +180,21 @@ HRESULT CAdTalkDef::loadBuffer(byte *buffer, bool complete) { if (_defaultSpriteFilename) { _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->loadFile(_defaultSpriteFilename))) return E_FAIL; + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; } if (_defaultSpriteSetFilename) { _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return E_FAIL; + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdTalkDef::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -205,12 +205,12 @@ HRESULT CAdTalkDef::persist(CBPersistMgr *persistMgr) { _nodes.persist(persistMgr); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TALK {\n"); if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); @@ -225,27 +225,27 @@ HRESULT CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkDef::loadDefaultSprite() { +ERRORCODE CAdTalkDef::loadDefaultSprite() { if (_defaultSpriteFilename && !_defaultSprite) { _defaultSprite = new CBSprite(Game); - if (!_defaultSprite || FAILED(_defaultSprite->loadFile(_defaultSpriteFilename))) { + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { delete _defaultSprite; _defaultSprite = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { _defaultSpriteSet = new CAdSpriteSet(Game); - if (!_defaultSpriteSet || FAILED(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; - return E_FAIL; - } else return S_OK; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; + } else return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 91d1c218e2..1a0cc4d7d8 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -40,17 +40,17 @@ public: char *_defaultSpriteSetFilename; CAdSpriteSet *_defaultSpriteSet; CBSprite *getDefaultSprite(TDirection Dir); - HRESULT loadDefaultSprite(); + ERRORCODE loadDefaultSprite(); DECLARE_PERSISTENT(CAdTalkDef, CBObject) CAdTalkDef(CBGame *inGame); virtual ~CAdTalkDef(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); CBArray _nodes; char *_defaultSpriteFilename; CBSprite *_defaultSprite; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 5516117004..5e25431d1a 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -73,8 +73,8 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { delete _animSprite; _animSprite = new CBSprite(Game, this); if (_animSprite) { - HRESULT res = _animSprite->loadFile(_forcedTalkAnimName); - if (FAILED(res)) { + ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; @@ -119,7 +119,7 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// @@ -141,7 +141,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack } else { const char *filename = val->getString(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { script->runtimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); } else { @@ -150,7 +150,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->pushBool(true); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -161,7 +161,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (!_sprite || !_sprite->_filename) stack->pushNULL(); else stack->pushString(_sprite->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -172,7 +172,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (!_sprite) stack->pushNULL(); else stack->pushNative(_sprite, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -185,7 +185,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack bool Ex = stack->pop()->getBool(); CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("AddTalkSprite method failed for file '%s'", filename); } else { @@ -193,7 +193,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack else _talkSprites.Add(spr); stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (setTemp2) _tempSprite2 = _sprite; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -256,7 +256,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack bool setTemp2 = false; CBSprite *spr = new CBSprite(Game, this); - if (!spr || FAILED(spr->loadFile(filename))) { + if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("SetTalkSprite method failed for file '%s'", filename); } else { @@ -292,7 +292,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack if (setTemp2) _tempSprite2 = spr; } - return S_OK; + return STATUS_OK; } else return CAdObject::scCallMethod(script, stack, thisStack, name); @@ -316,14 +316,14 @@ CScValue *CAdTalkHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Item")==0){ SetItem(value->getString()); - return S_OK; + return STATUS_OK; } else*/ return CAdObject::scSetProperty(name, value); @@ -337,7 +337,7 @@ const char *CAdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { for (int i = 0; i < _talkSprites.GetSize(); i++) { if (_talkSprites[i]->_filename) buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); @@ -348,19 +348,19 @@ HRESULT CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkHolder::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdTalkHolder::persist(CBPersistMgr *persistMgr) { CAdObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_sprite)); _talkSprites.persist(persistMgr); _talkSpritesEx.persist(persistMgr); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h index d2d51a7213..ab3904a1cb 100644 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -37,7 +37,7 @@ class CAdTalkHolder : public CAdObject { public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) virtual CBSprite *getTalkStance(const char *stance); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); CBSprite *_sprite; CBArray _talkSprites; CBArray _talkSpritesEx; @@ -46,8 +46,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index b398f84cfe..7f4198b0f1 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -80,7 +80,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -100,7 +100,7 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { Game->LOG(0, "'ACTION' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -122,7 +122,7 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITESET: { delete _spriteSet; _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->loadBuffer(params, false))) { + if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { delete _spriteSet; _spriteSet = NULL; cmd = PARSERR_GENERIC; @@ -153,12 +153,12 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ACTION definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ACTION definition"); - return E_FAIL; + return STATUS_FAILED; } if (_endTime == 0) @@ -169,24 +169,24 @@ HRESULT CAdTalkNode::loadBuffer(byte *buffer, bool complete) { if (_preCache && _spriteFilename) { delete _sprite; _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) - return E_FAIL; + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) + return STATUS_FAILED; } if (_preCache && _spriteSetFilename) { delete _spriteSet; _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) - return E_FAIL; + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdTalkNode::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_comment)); persistMgr->transfer(TMEMBER(_startTime)); persistMgr->transfer(TMEMBER(_endTime)); @@ -196,12 +196,12 @@ HRESULT CAdTalkNode::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_spriteSet)); persistMgr->transfer(TMEMBER(_spriteSetFilename)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ACTION {\n"); if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); @@ -215,31 +215,31 @@ HRESULT CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdTalkNode::loadSprite() { +ERRORCODE CAdTalkNode::loadSprite() { if (_spriteFilename && !_sprite) { _sprite = new CBSprite(Game); - if (!_sprite || FAILED(_sprite->loadFile(_spriteFilename))) { + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { delete _sprite; _sprite = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } else if (_spriteSetFilename && !_spriteSet) { _spriteSet = new CAdSpriteSet(Game); - if (!_spriteSet || FAILED(_spriteSet->loadFile(_spriteSetFilename))) { + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; _spriteSet = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } - else return S_OK; + else return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h index 57cce1deb4..3d763ea0f0 100644 --- a/engines/wintermute/Ad/AdTalkNode.h +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -41,13 +41,13 @@ public: CAdSpriteSet *_spriteSet; CBSprite *getSprite(TDirection dir); bool isInTimeInterval(uint32 time, TDirection dir); - HRESULT loadSprite(); + ERRORCODE loadSprite(); DECLARE_PERSISTENT(CAdTalkNode, CBBase) CAdTalkNode(CBGame *inGame); virtual ~CAdTalkNode(); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); char *_spriteFilename; CBSprite *_sprite; uint32 _startTime; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index b845f4e02e..e9e18e5101 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -64,19 +64,19 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::loadFile(const char *filename) { +ERRORCODE CAdWaypointGroup::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); delete [] buffer; @@ -96,7 +96,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -115,7 +115,7 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { Game->LOG(0, "'WAYPOINTS' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -123,7 +123,7 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -156,15 +156,15 @@ HRESULT CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in WAYPOINTS definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WAYPOINTS {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); @@ -180,12 +180,12 @@ HRESULT CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { +ERRORCODE CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -196,7 +196,7 @@ HRESULT CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_lastMimicY)); _points.persist(persistMgr); - return S_OK; + return STATUS_OK; } @@ -225,13 +225,13 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Active") == 0) { _active = value->getBool(); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -239,8 +239,8 @@ HRESULT CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -HRESULT CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { - if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return S_OK; +ERRORCODE CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { + if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; cleanup(); @@ -255,7 +255,7 @@ HRESULT CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, in _lastMimicX = argX; _lastMimicY = argY; - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 6b4d65f0dd..7e06ef661d 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -39,18 +39,18 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - HRESULT mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); + ERRORCODE mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); bool _active; CAdWaypointGroup(CBGame *inGame); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index f101eea69f..a43a9d78db 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -65,15 +65,15 @@ const char *CBBase::getEditorProp(const char *propName, const char *initVal) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return E_FAIL; +ERRORCODE CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return STATUS_FAILED; if (propValue == NULL) { _editorProps.erase(propName); } else { _editorProps[propName] = propValue; } - return S_OK; + return STATUS_OK; } @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { +ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -93,7 +93,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { if (!Game->_editorMode) - return S_OK; + return STATUS_OK; byte *params; @@ -103,7 +103,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -135,7 +135,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { delete[] propName; @@ -143,7 +143,7 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return E_FAIL; + return STATUS_FAILED; } @@ -154,12 +154,12 @@ HRESULT CBBase::parseEditorProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBBase::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CBBase::saveAsText(CBDynBuffer *buffer, int indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); @@ -172,7 +172,7 @@ HRESULT CBBase::saveAsText(CBDynBuffer *buffer, int indent) { _editorPropsIter++; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index 73eabb5d62..d505ec0b1d 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -43,11 +43,11 @@ class CBDynBuffer; class CBBase { public: bool _persistable; - HRESULT setEditorProp(const char *propName, const char *propValue); + ERRORCODE setEditorProp(const char *propName, const char *propValue); const char *getEditorProp(const char *propName, const char *initVal = NULL); CBBase(TDynamicConstructor, TDynamicConstructor) {}; - HRESULT parseEditorProperty(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent = 0); + ERRORCODE parseEditorProperty(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); CBBase(); CBGame *Game; CBBase(CBGame *GameOwner); diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index e720f8430d..1d3f0c4826 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -41,85 +41,85 @@ CBDebugger::~CBDebugger(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::initialize() { - return S_OK; +ERRORCODE CBDebugger::initialize() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::shutdown() { - return S_OK; +ERRORCODE CBDebugger::shutdown() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onGameInit() { - return S_OK; +ERRORCODE CBDebugger::onGameInit() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onGameShutdown() { - return S_OK; +ERRORCODE CBDebugger::onGameShutdown() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onGameTick() { - return S_OK; +ERRORCODE CBDebugger::onGameTick() { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onLog(unsigned int errorCode, const char *text) { - return S_OK; +ERRORCODE CBDebugger::onLog(unsigned int errorCode, const char *text) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptInit(CScScript *script) { - return S_OK; +ERRORCODE CBDebugger::onScriptInit(CScScript *script) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return S_OK; +ERRORCODE CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return S_OK; +ERRORCODE CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptShutdown(CScScript *script) { - return S_OK; +ERRORCODE CBDebugger::onScriptShutdown(CScScript *script) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptChangeLine(CScScript *script, int Line) { - return S_OK; +ERRORCODE CBDebugger::onScriptChangeLine(CScScript *script, int Line) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { - return S_OK; +ERRORCODE CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { - return S_OK; +ERRORCODE CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { - return S_OK; +ERRORCODE CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { - return S_OK; +ERRORCODE CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDebugger::onScriptHitBreakpoint(CScScript *script) { - return S_OK; +ERRORCODE CBDebugger::onScriptHitBreakpoint(CScScript *script) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index 79f3fba816..a3da66cc9f 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -45,26 +45,26 @@ public: // initialization bool _enabled; - HRESULT initialize(); - HRESULT shutdown(); + ERRORCODE initialize(); + ERRORCODE shutdown(); // internal interface - HRESULT onGameInit(); - HRESULT onGameShutdown(); - HRESULT onGameTick(); - HRESULT onLog(unsigned int errorCode, const char *text); - HRESULT onScriptInit(CScScript *script); - HRESULT onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - HRESULT onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - HRESULT onScriptShutdown(CScScript *script); - HRESULT onScriptChangeLine(CScScript *script, int line); - HRESULT onScriptChangeScope(CScScript *script, CScValue *scope); - HRESULT onScriptShutdownScope(CScScript *script, CScValue *scope); - HRESULT onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - HRESULT onVariableChangeValue(CScValue *var, CScValue *value); - - HRESULT onScriptHitBreakpoint(CScScript *script); + ERRORCODE onGameInit(); + ERRORCODE onGameShutdown(); + ERRORCODE onGameTick(); + ERRORCODE onLog(unsigned int errorCode, const char *text); + ERRORCODE onScriptInit(CScScript *script); + ERRORCODE onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + ERRORCODE onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + ERRORCODE onScriptShutdown(CScScript *script); + ERRORCODE onScriptChangeLine(CScScript *script, int line); + ERRORCODE onScriptChangeScope(CScScript *script, CScValue *scope); + ERRORCODE onScriptShutdownScope(CScScript *script, CScValue *scope); + ERRORCODE onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + ERRORCODE onVariableChangeValue(CScValue *var, CScValue *value); + + ERRORCODE onScriptHitBreakpoint(CScScript *script); // IWmeDebugServer interface virtual bool attachClient(IWmeDebugClient *client); diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index 25bf9be93d..d0d4cfeafb 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -69,7 +69,7 @@ uint32 CBDynBuffer::getSize() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::init(uint32 initSize) { +ERRORCODE CBDynBuffer::init(uint32 initSize) { cleanup(); if (initSize == 0) initSize = _initSize; @@ -77,18 +77,18 @@ HRESULT CBDynBuffer::init(uint32 initSize) { _buffer = (byte *)malloc(initSize); if (!_buffer) { Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); - return E_FAIL; + return STATUS_FAILED; } _realSize = initSize; _initialized = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::putBytes(byte *buffer, uint32 size) { +ERRORCODE CBDynBuffer::putBytes(byte *buffer, uint32 size) { if (!_initialized) init(); while (_offset + size > _realSize) { @@ -96,7 +96,7 @@ HRESULT CBDynBuffer::putBytes(byte *buffer, uint32 size) { _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return E_FAIL; + return STATUS_FAILED; } } @@ -104,23 +104,23 @@ HRESULT CBDynBuffer::putBytes(byte *buffer, uint32 size) { _offset += size; _size += size; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBDynBuffer::getBytes(byte *buffer, uint32 size) { +ERRORCODE CBDynBuffer::getBytes(byte *buffer, uint32 size) { if (!_initialized) init(); if (_offset + size > _size) { Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); - return E_FAIL; + return STATUS_FAILED; } memcpy(buffer, _buffer + _offset, size); _offset += size; - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index 1fd8fa6748..c29e6ac275 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -43,10 +43,10 @@ public: void putDWORD(uint32 val); char *getString(); void putString(const char *val); - HRESULT getBytes(byte *buffer, uint32 size); - HRESULT putBytes(byte *buffer, uint32 size); + ERRORCODE getBytes(byte *buffer, uint32 size); + ERRORCODE putBytes(byte *buffer, uint32 size); uint32 getSize(); - HRESULT init(uint32 initSize = 0); + ERRORCODE init(uint32 initSize = 0); void cleanup(); uint32 _size; byte *_buffer; diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index ef0208c44d..9538e4b398 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -60,8 +60,8 @@ CBFader::~CBFader() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::update() { - if (!_active) return S_OK; +ERRORCODE CBFader::update() { + if (!_active) return STATUS_OK; int alphaDelta = _targetAlpha - _sourceAlpha; @@ -79,37 +79,37 @@ HRESULT CBFader::update() { _ready = time >= _duration; if (_ready && _currentAlpha == 0x00) _active = false; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::display() { - if (!_active) return S_OK; +ERRORCODE CBFader::display() { + if (!_active) return STATUS_OK; - if (_currentAlpha > 0x00) return Game->_renderer->fadeToColor(DRGBA(_red, _green, _blue, _currentAlpha)); - else return S_OK; + if (_currentAlpha > 0x00) return Game->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::deactivate() { +ERRORCODE CBFader::deactivate() { _active = false; _ready = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { +ERRORCODE CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _ready = false; _active = true; - _red = D3DCOLGetR(sourceColor); - _green = D3DCOLGetG(sourceColor); - _blue = D3DCOLGetB(sourceColor); + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); - _sourceAlpha = D3DCOLGetA(sourceColor); + _sourceAlpha = RGBCOLGetA(sourceColor); _targetAlpha = 0; _duration = duration; @@ -118,22 +118,22 @@ HRESULT CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { if (_system) _startTime = CBPlatform::getTime(); else _startTime = Game->_timer; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { +ERRORCODE CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _ready = false; _active = true; - _red = D3DCOLGetR(targetColor); - _green = D3DCOLGetG(targetColor); - _blue = D3DCOLGetB(targetColor); + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); //_sourceAlpha = 0; _sourceAlpha = _currentAlpha; - _targetAlpha = D3DCOLGetA(targetColor); + _targetAlpha = RGBCOLGetA(targetColor); _duration = duration; _system = system; @@ -142,19 +142,19 @@ HRESULT CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { else _startTime = Game->_timer; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// uint32 CBFader::getCurrentColor() { - return DRGBA(_red, _green, _blue, _currentAlpha); + return BYTETORGBA(_red, _green, _blue, _currentAlpha); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFader::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFader::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); @@ -170,7 +170,7 @@ HRESULT CBFader::persist(CBPersistMgr *persistMgr) { if (_system && !persistMgr->_saving) _startTime = 0; - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h index b42feae43f..623bd220bc 100644 --- a/engines/wintermute/Base/BFader.h +++ b/engines/wintermute/Base/BFader.h @@ -38,11 +38,11 @@ class CBFader : public CBObject { public: bool _system; uint32 getCurrentColor(); - HRESULT fadeOut(uint32 targetColor, uint32 duration, bool system = false); - HRESULT fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - HRESULT deactivate(); - HRESULT display(); - HRESULT update(); + ERRORCODE fadeOut(uint32 targetColor, uint32 duration, bool system = false); + ERRORCODE fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + ERRORCODE deactivate(); + ERRORCODE display(); + ERRORCODE update(); DECLARE_PERSISTENT(CBFader, CBObject) CBFader(CBGame *inGame); virtual ~CBFader(); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index fdb43e28f5..8c68bc9263 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -73,7 +73,7 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::cleanup() { +ERRORCODE CBFileManager::cleanup() { // delete registered paths for (int i = 0; i < _singlePaths.GetSize(); i++) delete [] _singlePaths[i]; @@ -107,7 +107,7 @@ HRESULT CBFileManager::cleanup() { delete[] _basePath; _basePath = NULL; - return S_OK; + return STATUS_OK; } @@ -161,7 +161,7 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { // TODO warning("Implement SaveFile"); @@ -179,7 +179,7 @@ HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, ui FILE *f = fopen(filename, "wb"); if (!f) { Game->LOG(0, "Error opening file '%s' for writing.", filename); - return E_FAIL; + return STATUS_FAILED; } if (PrefixBuffer && PrefixSize) { @@ -219,30 +219,30 @@ HRESULT CBFileManager::saveFile(const Common::String &filename, byte *Buffer, ui fclose(f); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { +ERRORCODE CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (int i = 0; i < _packages.GetSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return E_FAIL; +ERRORCODE CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return E_FAIL; + if (buffer == NULL) return STATUS_FAILED; strcpy(buffer, path.c_str()); if (!slashed) strcat(buffer, "\\"); @@ -257,11 +257,11 @@ HRESULT CBFileManager::addPath(TPathType type, const Common::String &path) { break; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::reloadPaths() { +ERRORCODE CBFileManager::reloadPaths() { // delete registered paths for (int i = 0; i < _singlePaths.GetSize(); i++) delete [] _singlePaths[i]; @@ -277,7 +277,7 @@ HRESULT CBFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::initPaths() { +ERRORCODE CBFileManager::initPaths() { restoreCurrentDir(); AnsiString pathList; @@ -341,12 +341,12 @@ HRESULT CBFileManager::initPaths() { } addPath(PATH_PACKAGE, "data"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::registerPackages() { +ERRORCODE CBFileManager::registerPackages() { restoreCurrentDir(); Game->LOG(0, "Scanning packages..."); @@ -390,17 +390,17 @@ HRESULT CBFileManager::registerPackages() { Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { // FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return S_OK; + return STATUS_OK; } uint32 absoluteOffset = 0; @@ -410,7 +410,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea uint32 Offset; if (!findPackageSignature(package, &Offset)) { delete package; - return S_OK; + return STATUS_OK; } else { package->seek(Offset, SEEK_SET); absoluteOffset = Offset; @@ -424,7 +424,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; - return S_OK; + return STATUS_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { @@ -441,7 +441,7 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea for (uint32 i = 0; i < hdr.NumDirs; i++) { CBPackage *pkg = new CBPackage(Game); - if (!pkg) return E_FAIL; + if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; @@ -517,10 +517,10 @@ HRESULT CBFileManager::registerPackage(const Common::String &filename , bool sea delete package; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool SearchSignature) { +ERRORCODE CBFileManager::registerPackage(const char *Path, const char *name, bool SearchSignature) { // TODO error("Implement RegisterPackage, this is the old one"); #if 0 @@ -530,7 +530,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool FILE *f = fopen(filename, "rb"); if (!f) { Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename); - return S_OK; + return STATUS_OK; } uint32 AbsoluteOffset = 0; @@ -540,7 +540,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool uint32 Offset; if (!FindPackageSignature(f, &Offset)) { fclose(f); - return S_OK; + return STATUS_OK; } else { fseek(f, Offset, SEEK_SET); AbsoluteOffset = Offset; @@ -553,7 +553,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename); fclose(f); - return S_OK; + return STATUS_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { @@ -570,7 +570,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool for (int i = 0; i < hdr.NumDirs; i++) { CBPackage *pkg = new CBPackage(Game); - if (!pkg) return E_FAIL; + if (!pkg) return STATUS_FAILED; pkg->_boundToExe = BoundToExe; @@ -649,7 +649,7 @@ HRESULT CBFileManager::registerPackage(const char *Path, const char *name, bool fclose(f); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -792,15 +792,15 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::closeFile(Common::SeekableReadStream *File) { +ERRORCODE CBFileManager::closeFile(Common::SeekableReadStream *File) { for (int i = 0; i < _openFiles.GetSize(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; _openFiles.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } @@ -812,7 +812,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); - if (SUCCEEDED(SaveThumbFile->open(filename))) { + if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); } delete SaveThumbFile; @@ -836,19 +836,19 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::restoreCurrentDir() { - if (!_basePath) return S_OK; +ERRORCODE CBFileManager::restoreCurrentDir() { + if (!_basePath) return STATUS_OK; else { - /*if (!chdir(_basePath)) return S_OK; - else return E_FAIL;*/ + /*if (!chdir(_basePath)) return STATUS_OK; + else return STATUS_FAILED;*/ warning("CBFileManager::RestoreCurrentDir - ignored"); - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFileManager::setBasePath(const Common::String &path) { +ERRORCODE CBFileManager::setBasePath(const Common::String &path) { cleanup(); if (path.c_str()) { @@ -859,7 +859,7 @@ HRESULT CBFileManager::setBasePath(const Common::String &path) { initPaths(); registerPackages(); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 2c7415642f..2b54679b29 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -43,28 +43,28 @@ class CBFile; class CBFileManager: CBBase { public: bool findPackageSignature(Common::File *f, uint32 *offset); - HRESULT cleanup(); - HRESULT setBasePath(const Common::String &path); - HRESULT restoreCurrentDir(); + ERRORCODE cleanup(); + ERRORCODE setBasePath(const Common::String &path); + ERRORCODE restoreCurrentDir(); char *_basePath; bool getFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *openFileRaw(const Common::String &filename); - HRESULT closeFile(Common::SeekableReadStream *File); + ERRORCODE closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); CBFileEntry *getPackageEntry(const Common::String &filename); Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); - HRESULT registerPackages(); - HRESULT initPaths(); - HRESULT reloadPaths(); + ERRORCODE registerPackages(); + ERRORCODE initPaths(); + ERRORCODE reloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - HRESULT addPath(TPathType type, const Common::String &path); - HRESULT requestCD(int cd, char *packageFile, const char *filename); + ERRORCODE addPath(TPathType type, const Common::String &path); + ERRORCODE requestCD(int cd, char *packageFile, const char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - HRESULT saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + ERRORCODE saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); @@ -75,8 +75,8 @@ public: Common::HashMap _files; private: - HRESULT registerPackage(const char *path, const char *name, bool searchSignature = false); - HRESULT registerPackage(const Common::String &filename, bool searchSignature = false); + ERRORCODE registerPackage(const char *path, const char *name, bool searchSignature = false); + ERRORCODE registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp index d394f3e21b..1849401e53 100644 --- a/engines/wintermute/Base/BFont.cpp +++ b/engines/wintermute/Base/BFont.cpp @@ -71,20 +71,20 @@ int CBFont::getTextWidth(byte *text, int maxLength) { /* ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::loadFile(const char * Filename) +ERRORCODE CBFont::loadFile(const char * Filename) { BYTE* Buffer = Game->_fileManager->readWholeFile(filename); if(Buffer==NULL){ Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename)+1]; strcpy(_filename, filename); - if(FAILED(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + if(DID_FAIL(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); delete [] Buffer; @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFont::loadBuffer(byte * Buffer) +ERRORCODE CBFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -108,7 +108,7 @@ HRESULT CBFont::loadBuffer(byte * Buffer) if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ Game->LOG(0, "'FONT' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } Buffer = (byte *)params; @@ -130,10 +130,10 @@ HRESULT CBFont::loadBuffer(byte * Buffer) } if (cmd == PARSERR_TOKENNOTFOUND){ Game->LOG(0, "Syntax error in FONT definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } */ @@ -144,10 +144,10 @@ int CBFont::getLetterHeight() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFont::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); - return S_OK; + return STATUS_OK; } @@ -156,7 +156,7 @@ CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { if (isTrueType(Game, filename)) { CBFontTT *font = new CBFontTT(Game); if (font) { - if (FAILED(font->loadFile(filename))) { + if (DID_FAIL(font->loadFile(filename))) { delete font; return NULL; } @@ -165,7 +165,7 @@ CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { } else { CBFontBitmap *font = new CBFontBitmap(Game); if (font) { - if (FAILED(font->loadFile(filename))) { + if (DID_FAIL(font->loadFile(filename))) { delete font; return NULL; } diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h index 0c7e1950b1..ac5a79299d 100644 --- a/engines/wintermute/Base/BFont.h +++ b/engines/wintermute/Base/BFont.h @@ -51,8 +51,8 @@ public: static CBFont *createFromFile(CBGame *game, const char *filename); private: - //HRESULT loadBuffer(byte * Buffer); - //HRESULT loadFile(const char* Filename); + //ERRORCODE loadBuffer(byte * Buffer); + //ERRORCODE loadFile(const char* Filename); static bool isTrueType(CBGame *game, const char *filename); }; diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 4e01134a9a..c2b7cfef1a 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -243,19 +243,19 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::loadFile(const char *filename) { +ERRORCODE CBFontBitmap::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); delete [] buffer; @@ -282,7 +282,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::loadBuffer(byte *buffer) { +ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -308,7 +308,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { Game->LOG(0, "'FONT' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = (byte *)params; @@ -396,13 +396,13 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in FONT definition"); - return E_FAIL; + return STATUS_FAILED; } if (spriteFile != NULL) { delete _sprite; _sprite = new CBSprite(Game, this); - if (!_sprite || FAILED(_sprite->loadFile(spriteFile))) { + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { delete _sprite; _sprite = NULL; } @@ -417,7 +417,7 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { Game->LOG(0, "Incomplete font definition"); - return E_FAIL; + return STATUS_FAILED; } if (autoWidth) { @@ -449,12 +449,12 @@ HRESULT CBFontBitmap::loadBuffer(byte *buffer) { } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFontBitmap::persist(CBPersistMgr *persistMgr) { CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_numColumns)); @@ -475,7 +475,7 @@ HRESULT CBFontBitmap::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_wholeCell)); - return S_OK; + return STATUS_OK; } @@ -487,7 +487,7 @@ int CBFontBitmap::getCharWidth(byte index) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontBitmap::getWidths() { +ERRORCODE CBFontBitmap::getWidths() { CBSurface *surf = NULL; if (_sprite) { @@ -498,7 +498,7 @@ HRESULT CBFontBitmap::getWidths() { } } if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || FAILED(surf->startPixelOp())) return E_FAIL; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; for (int i = 0; i < NUM_CHARACTERS; i++) { @@ -529,7 +529,7 @@ HRESULT CBFontBitmap::getWidths() { Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); } */ - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h index aba1690db5..3cd0d91e77 100644 --- a/engines/wintermute/Base/BFontBitmap.h +++ b/engines/wintermute/Base/BFontBitmap.h @@ -37,8 +37,8 @@ class CBSubFrame; class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) - HRESULT loadBuffer(byte *Buffer); - HRESULT loadFile(const char *filename); + ERRORCODE loadBuffer(byte *Buffer); + ERRORCODE loadFile(const char *filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); @@ -48,7 +48,7 @@ public: virtual ~CBFontBitmap(); - HRESULT getWidths(); + ERRORCODE getWidths(); CBSprite *_sprite; int _widthsFrame; bool _fontextFix; diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 3749161137..7642a88bac 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -51,22 +51,22 @@ CBFontStorage::~CBFontStorage() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::cleanup(bool warn) { +ERRORCODE CBFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.GetSize(); i++) { if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; } _fonts.RemoveAll(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::initLoop() { +ERRORCODE CBFontStorage::initLoop() { for (int i = 0; i < _fonts.GetSize(); i++) { _fonts[i]->initLoop(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -84,7 +84,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { CBFont* font = new CBFont(Game); if (!font) return NULL; - if (FAILED(font->loadFile(filename))) { + if (DID_FAIL(font->loadFile(filename))) { delete font; return NULL; } @@ -104,8 +104,8 @@ CBFont *CBFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::removeFont(CBFont *font) { - if (!font) return E_FAIL; +ERRORCODE CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; for (int i = 0; i < _fonts.GetSize(); i++) { if (_fonts[i] == font) { @@ -117,19 +117,19 @@ HRESULT CBFontStorage::removeFont(CBFont *font) { break; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontStorage::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(false); persistMgr->transfer(TMEMBER(Game)); _fonts.persist(persistMgr); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h index e5f96fd3bc..33a1bb056f 100644 --- a/engines/wintermute/Base/BFontStorage.h +++ b/engines/wintermute/Base/BFontStorage.h @@ -41,13 +41,13 @@ class CBFont; class CBFontStorage : public CBBase { public: DECLARE_PERSISTENT(CBFontStorage, CBBase) - HRESULT cleanup(bool warn = false); - HRESULT removeFont(CBFont *font); + ERRORCODE cleanup(bool warn = false); + ERRORCODE removeFont(CBFont *font); CBFont *addFont(const char *filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); CBArray _fonts; - HRESULT initLoop(); + ERRORCODE initLoop(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 353620bc24..8f665a51fd 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -223,7 +223,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i uint32 color = _layers[i]->_color; uint32 origForceAlpha = _renderer->_forceAlphaColor; if (_renderer->_forceAlphaColor != 0) { - color = DRGBA(D3DCOLGetR(color), D3DCOLGetG(color), D3DCOLGetB(color), D3DCOLGetA(_renderer->_forceAlphaColor)); + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(_renderer->_forceAlphaColor)); _renderer->_forceAlphaColor = 0; } surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); @@ -257,7 +257,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex hasWarned = true; warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); } - warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color), D3DCOLGetB(_layers[0]->_color), D3DCOLGetA(_layers[0]->_color)); + warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); @@ -360,7 +360,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex } CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); - if (SUCCEEDED(wmeSurface->CreateFromSDLSurface(surface))) { + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { SDL_FreeSurface(surface); return wmeSurface; } else { @@ -403,19 +403,19 @@ int CBFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::loadFile(const char *filename) { +ERRORCODE CBFontTT::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); delete [] buffer; @@ -440,7 +440,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::loadBuffer(byte *buffer) { +ERRORCODE CBFontTT::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -462,7 +462,7 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { Game->LOG(0, "'TTFONT' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = (byte *)params; @@ -505,20 +505,20 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { case TOKEN_COLOR: { int r, g, b; parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = DRGBA(r, g, b, D3DCOLGetA(BaseColor)); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); } break; case TOKEN_ALPHA: { int a; parser.scanStr(params, "%d", &a); - BaseColor = DRGBA(D3DCOLGetR(BaseColor), D3DCOLGetG(BaseColor), D3DCOLGetB(BaseColor), a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); } break; case TOKEN_LAYER: { CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && SUCCEEDED(parseLayer(Layer, (byte *)params))) _layers.Add(Layer); + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.Add(Layer); else { delete Layer; Layer = NULL; @@ -531,7 +531,7 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in TTFONT definition"); - return E_FAIL; + return STATUS_FAILED; } // create at least one layer @@ -548,7 +548,7 @@ HRESULT CBFontTT::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { +ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -573,25 +573,25 @@ HRESULT CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { case TOKEN_COLOR: { int r, g, b; parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = DRGBA(r, g, b, D3DCOLGetA(layer->_color)); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); } break; case TOKEN_ALPHA: { int a; parser.scanStr(params, "%d", &a); - layer->_color = DRGBA(D3DCOLGetR(layer->_color), D3DCOLGetG(layer->_color), D3DCOLGetB(layer->_color), a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); } break; } } - if (cmd != PARSERR_EOF) return E_FAIL; - else return S_OK; + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFontTT::persist(CBPersistMgr *persistMgr) { CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_isBold)); @@ -623,7 +623,7 @@ HRESULT CBFontTT::persist(CBPersistMgr *persistMgr) { _fallbackFont = _font = _deletableFont = NULL; } - return S_OK; + return STATUS_OK; } @@ -633,8 +633,8 @@ void CBFontTT::afterLoad() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFontTT::initFont() { - if (!_fontFile) return E_FAIL; +ERRORCODE CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); if (!file) { @@ -643,7 +643,7 @@ HRESULT CBFontTT::initFont() { file = Game->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return E_FAIL; + //return STATUS_FAILED; } } @@ -658,7 +658,7 @@ HRESULT CBFontTT::initFont() { warning("BFontTT::InitFont - Couldn't load %s", _fontFile); } _lineHeight = _font->getFontHeight(); - return S_OK; + return STATUS_OK; #if 0 FT_Error error; @@ -682,14 +682,14 @@ HRESULT CBFontTT::initFont() { if (error) { SAFE_DELETE_ARRAY(_fTStream); Game->_fileManager->closeFile(file); - return E_FAIL; + return STATUS_FAILED; } error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); if (error) { FT_Done_Face(_fTFace); _fTFace = NULL; - return E_FAIL; + return STATUS_FAILED; } // http://en.wikipedia.org/wiki/E_(typography) @@ -717,7 +717,7 @@ HRESULT CBFontTT::initFont() { _glyphCache->Initialize(); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h index a2157cb216..c585ca2070 100644 --- a/engines/wintermute/Base/BFontTT.h +++ b/engines/wintermute/Base/BFontTT.h @@ -80,11 +80,11 @@ public: _color = 0x00000000; } - HRESULT persist(CBPersistMgr *persistMgr) { + ERRORCODE persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_offsetX)); persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_color)); - return S_OK; + return STATUS_OK; } int _offsetX; @@ -123,8 +123,8 @@ public: virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - HRESULT loadBuffer(byte *buffer); - HRESULT loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer); + ERRORCODE loadFile(const char *filename); float getLineHeight() const { return _lineHeight; @@ -134,7 +134,7 @@ public: void initLoop(); private: - HRESULT parseLayer(CBTTFontLayer *layer, byte *buffer); + ERRORCODE parseLayer(CBTTFontLayer *layer, byte *buffer); void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); @@ -145,7 +145,7 @@ private: CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - HRESULT initFont(); + ERRORCODE initFont(); Graphics::Font *_deletableFont; const Graphics::Font *_font; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index ebb5fe0e6c..9f0c89c39c 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -75,19 +75,19 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - HRESULT res; +ERRORCODE CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + ERRORCODE res; for (int i = 0; i < _subframes.GetSize(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (FAILED(res)) return res; + if (DID_FAIL(res)) return res; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { +ERRORCODE CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { if (_sound && !muted) { if (owner) owner->updateOneSound(_sound); _sound->play(); @@ -102,7 +102,7 @@ HRESULT CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { owner->applyEvent(_applyEvent[i]); } } - return S_OK; + return STATUS_OK; } @@ -131,7 +131,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -238,7 +238,7 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { case TOKEN_SUBFRAME: { CBSubFrame *subframe = new CBSubFrame(Game); - if (!subframe || FAILED(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; } else _subframes.Add(subframe); @@ -251,7 +251,7 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { _sound = NULL; } _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->setSound(params, SOUND_SFX, false))) { + if (!_sound || DID_FAIL(_sound->setSound(params, SOUND_SFX, false))) { if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); delete _sound; _sound = NULL; @@ -281,12 +281,12 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in FRAME definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading FRAME definition"); - return E_FAIL; + return STATUS_FAILED; } @@ -298,11 +298,11 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (!sub->_surface) { delete sub; Game->LOG(0, "Error loading SUBFRAME"); - return E_FAIL; + return STATUS_FAILED; } - sub->_alpha = DRGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = DRGBA(r, g, b, 0xFF); + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); } if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); @@ -320,7 +320,7 @@ HRESULT CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { sub->_editorSelected = editorSelected; _subframes.InsertAt(0, sub); - return S_OK; + return STATUS_OK; } @@ -341,7 +341,7 @@ bool CBFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float sca ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); @@ -374,12 +374,12 @@ HRESULT CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBFrame::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); _applyEvent.persist(persistMgr); @@ -392,14 +392,14 @@ HRESULT CBFrame::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_sound)); _subframes.persist(persistMgr); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -409,7 +409,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -423,13 +423,13 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!val->isNULL()) { _sound = new CBSound(Game); - if (!_sound || FAILED(_sound->setSound(val->getString(), SOUND_SFX, false))) { + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), SOUND_SFX, false))) { stack->pushBool(false); delete _sound; _sound = NULL; } else stack->pushBool(true); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -443,7 +443,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushNULL(); } else stack->pushNative(_subframes[index], true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -468,7 +468,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -488,7 +488,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _subframes.Add(sub); stack->pushNative(sub, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -512,7 +512,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else _subframes.InsertAt(index, sub); stack->pushNative(sub, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -525,7 +525,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else stack->pushString(_applyEvent[index]); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -537,12 +537,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this for (int i = 0; i < _applyEvent.GetSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { stack->pushNULL(); - return S_OK; + return STATUS_OK; } } _applyEvent.Add(event); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -559,7 +559,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -648,13 +648,13 @@ CScValue *CBFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Delay") == 0) { _delay = MAX(0, value->getInt()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -662,7 +662,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyframe") == 0) { _keyframe = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -670,7 +670,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "KillSounds") == 0) { _killSound = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -678,7 +678,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveX") == 0) { _moveX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -686,7 +686,7 @@ HRESULT CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MoveY") == 0) { _moveY = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index cc42b77661..55ade445e3 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -42,18 +42,18 @@ class CBFrame: public CBScriptable { public: bool _killSound; bool _keyframe; - HRESULT oneTimeDisplay(CBObject *owner, bool muted = false); + ERRORCODE oneTimeDisplay(CBObject *owner, bool muted = false); DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); - HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; CBArray _subframes; - HRESULT draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - HRESULT loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); @@ -62,8 +62,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7946bf8bbc..41cc62ba3e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -202,7 +202,7 @@ CBGame::CBGame(): CBObject(this) { _thumbnailWidth = _thumbnailHeight = 0; _indicatorDisplay = false; - _indicatorColor = DRGBA(255, 0, 0, 128); + _indicatorColor = BYTETORGBA(255, 0, 0, 128); _indicatorProgress = 0; _indicatorX = -1; _indicatorY = -1; @@ -341,7 +341,7 @@ CBGame::~CBGame() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::cleanup() { +ERRORCODE CBGame::cleanup() { delete _loadingIcon; _loadingIcon = NULL; @@ -418,12 +418,12 @@ HRESULT CBGame::cleanup() { delete _keyboardState; _keyboardState = NULL; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initialize1() { +ERRORCODE CBGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { _surfaceStorage = new CBSurfaceStorage(this); @@ -479,7 +479,7 @@ HRESULT CBGame::initialize1() { loaded = true; } if (loaded == true) { - return S_OK; + return STATUS_OK; } else { delete _mathClass; delete _store; @@ -492,22 +492,22 @@ HRESULT CBGame::initialize1() { delete _fileManager; delete _scEngine; delete _videoPlayer; - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initialize2() { // we know whether we are going to be accelerated +ERRORCODE CBGame::initialize2() { // we know whether we are going to be accelerated _renderer = new CBRenderSDL(this); - if (_renderer == NULL) return E_FAIL; + if (_renderer == NULL) return STATUS_FAILED; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initialize3() { // renderer is initialized +ERRORCODE CBGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; @@ -515,7 +515,7 @@ HRESULT CBGame::initialize3() { // renderer is initialized if (_indicatorX == -1) _indicatorX = 0; if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; - return S_OK; + return STATUS_OK; } @@ -578,7 +578,7 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// -void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) { +void CBGame::LOG(ERRORCODE res, LPCSTR fmt, ...) { uint32 secs = g_system->getMillis() / 1000; uint32 hours = secs / 3600; secs = secs % 3600; @@ -615,7 +615,7 @@ void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initLoop() { +ERRORCODE CBGame::initLoop() { _viewportSP = -1; _currentTime = CBPlatform::getTime(); @@ -668,13 +668,13 @@ HRESULT CBGame::initLoop() { if (_fader) _fader->update(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initInput() { - return S_OK; +ERRORCODE CBGame::initInput() { + return STATUS_OK; } @@ -698,19 +698,19 @@ void CBGame::getOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadFile(const char *filename) { +ERRORCODE CBGame::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); delete [] buffer; @@ -768,7 +768,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -811,7 +811,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { Game->LOG(0, "'GAME' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -819,7 +819,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -848,7 +848,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -859,7 +859,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { delete _activeCursor; _activeCursor = NULL; _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->loadFile((char *)params))) { + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { delete _activeCursor; _activeCursor = NULL; cmd = PARSERR_GENERIC; @@ -869,7 +869,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile((char *)params))) { + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; cmd = PARSERR_GENERIC; @@ -923,7 +923,7 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INDICATOR_COLOR: { int r, g, b, a; parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = DRGBA(r, g, b, a); + _indicatorColor = BYTETORGBA(r, g, b, a); } break; @@ -974,21 +974,21 @@ HRESULT CBGame::loadBuffer(byte *buffer, bool complete) { if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in GAME definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading GAME definition"); - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -996,14 +996,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); LOG(0, stack->pop()->getString()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - HRESULT res = CBObject::scCallMethod(script, stack, thisStack, name); + ERRORCODE res = CBObject::scCallMethod(script, stack, thisStack, name); setWindowTitle(); return res; } @@ -1015,7 +1015,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); quickMessage(stack->pop()->getString()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1024,12 +1024,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "RunScript") == 0) { Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); stack->correctParams(1); - if (FAILED(addScript(stack->pop()->getString()))) + if (DID_FAIL(addScript(stack->pop()->getString()))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1044,12 +1044,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (Val->isNULL()) ClearOld = true; else ClearOld = Val->getBool(); - if (FAILED(_stringTable->loadFile(filename, ClearOld))) + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1061,7 +1061,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (validObject((CBObject *) obj)) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1072,7 +1072,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS resetContent(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -1087,7 +1087,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1096,7 +1096,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "LoadWindow") == 0) { stack->correctParams(1); CUIWindow *win = new CUIWindow(Game); - if (win && SUCCEEDED(win->loadFile(stack->pop()->getString()))) { + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { _windows.Add(win); registerObject(win); stack->pushNative(win, true); @@ -1105,7 +1105,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS win = NULL; stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1119,7 +1119,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _stringTable->expand(&str); stack->pushString(str); delete [] str; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1141,9 +1141,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - if (FAILED(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1158,9 +1158,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(stopMusic(channel))) stack->pushBool(false); + if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1175,9 +1175,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(pauseMusic(channel))) stack->pushBool(false); + if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1191,9 +1191,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS channel = stack->pop()->getInt(); } - if (FAILED(resumeMusic(channel))) stack->pushBool(false); + if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1211,7 +1211,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); else stack->pushString(_music[channel]->_soundFilename); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1227,10 +1227,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS uint32 time = stack->pop()->getInt(); - if (FAILED(setMusicStartTime(channel, time))) stack->pushBool(false); + if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1246,7 +1246,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); else stack->pushInt(_music[channel]->getPositionTime()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1262,7 +1262,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else stack->pushBool(_music[channel]->isPlaying()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1279,10 +1279,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int volume = stack->pop()->getInt(); if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else { - if (FAILED(_music[channel]->setVolume(volume))) stack->pushBool(false); + if (DID_FAIL(_music[channel]->setVolume(volume))) stack->pushBool(false); else stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1299,7 +1299,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); else stack->pushInt(_music[channel]->getVolume()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1315,7 +1315,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (_musicCrossfadeRunning) { script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); stack->pushBool(false); - return S_OK; + return STATUS_OK; } _musicCrossfadeStartTime = _liveTimer; @@ -1327,7 +1327,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _musicCrossfadeRunning = true; stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1340,13 +1340,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS const char *filename = stack->pop()->getString(); CBSound *sound = new CBSound(Game); - if (sound && SUCCEEDED(sound->setSound(filename, SOUND_MUSIC, true))) { + if (sound && DID_SUCCEED(sound->setSound(filename, SOUND_MUSIC, true))) { length = sound->getLength(); delete sound; sound = NULL; } stack->pushInt(length); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1367,7 +1367,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBPlatform::setCursorPos(p.x, p.y); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1386,7 +1386,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1396,7 +1396,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS /* stack->correctParams(0); stack->pushBool(false); - return S_OK; + return STATUS_OK; // TODO: ADDVIDEO */ @@ -1420,14 +1420,14 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - if (SUCCEEDED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { - if (SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + if (DID_SUCCEED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { stack->pushBool(true); script->sleep(0); } else stack->pushBool(false); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1437,7 +1437,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS /* stack->correctParams(0); stack->pushBool(false); - return S_OK;*/ + return STATUS_OK;*/ // TODO: ADDVIDEO stack->correctParams(7); @@ -1460,9 +1460,9 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete _theoraPlayer; _theoraPlayer = new CVidTheoraPlayer(this); - if (_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(filename, SubtitleFile))) { + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !dropFrames; - if (SUCCEEDED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); script->sleep(0); } else stack->pushBool(false); @@ -1472,7 +1472,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _theoraPlayer = NULL; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1482,7 +1482,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); stack->pushNULL(); _quitting = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1494,7 +1494,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int val = stack->pop()->getInt(); _registry->writeInt("PrivateSettings", key, val); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1505,7 +1505,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1517,7 +1517,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS const char *val = stack->pop()->getString(); _registry->writeString("PrivateSettings", key, val); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1529,7 +1529,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS const char *initVal = stack->pop()->getString(); AnsiString val = _registry->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1544,12 +1544,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS char *desc = new char[strlen(xdesc) + 1]; strcpy(desc, xdesc); stack->pushBool(true); - if (FAILED(SaveGame(slot, desc, quick))) { + if (DID_FAIL(SaveGame(slot, desc, quick))) { stack->pop(); stack->pushBool(false); } delete [] desc; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1561,7 +1561,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _loading = true; stack->pushBool(false); script->sleep(0); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1571,7 +1571,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); int Slot = stack->pop()->getInt(); stack->pushBool(isSaveSlotUsed(Slot)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1584,7 +1584,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS desc[0] = '\0'; getSaveSlotDescription(slot, desc); stack->pushString(desc); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1595,7 +1595,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int slot = stack->pop()->getInt(); emptySaveSlot(slot); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1605,7 +1605,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->pop()->getInt()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1615,7 +1615,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->pop()->getInt()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1625,7 +1625,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->pop()->getInt()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1635,7 +1635,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1644,7 +1644,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetGlobalSFXVolume") == 0) { stack->correctParams(0); stack->pushInt(_soundMgr->getVolumePercent(SOUND_SFX)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1653,7 +1653,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { stack->correctParams(0); stack->pushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1662,7 +1662,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetGlobalMusicVolume") == 0) { stack->correctParams(0); stack->pushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1671,7 +1671,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetGlobalMasterVolume") == 0) { stack->correctParams(0); stack->pushInt(_soundMgr->getMasterVolumePercent()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1679,10 +1679,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetActiveCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1693,7 +1693,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); else stack->pushString(_activeCursor->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1704,7 +1704,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (!_activeCursor) stack->pushNULL(); else stack->pushNative(_activeCursor, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1716,7 +1716,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _activeCursor = NULL; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1728,7 +1728,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (_activeCursor) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1745,7 +1745,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _fileManager->closeFile(file); stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1761,11 +1761,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - _fader->fadeOut(DRGBA(red, green, blue, alpha), duration, system); + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1781,11 +1781,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - _fader->fadeIn(DRGBA(red, green, blue, alpha), duration, system); + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1794,7 +1794,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "GetFadeColor") == 0) { stack->correctParams(0); stack->pushInt(_fader->getCurrentColor()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1819,12 +1819,12 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool ret = false; CBImage *image = Game->_renderer->takeScreenshot(); if (image) { - ret = SUCCEEDED(image->saveBMPFile(filename)); + ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; } else ret = false; stack->pushBool(ret); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1839,13 +1839,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS bool ret = false; CBImage *image = Game->_renderer->takeScreenshot(); if (image) { - ret = SUCCEEDED(image->resize(sizeX, sizeY)); - if (ret) ret = SUCCEEDED(image->saveBMPFile(filename)); + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; } else ret = false; stack->pushBool(ret); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1860,7 +1860,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS registerObject(win); if (!val->isNULL()) win->setName(val->getString()); stack->pushNative(win, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1873,11 +1873,11 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (_windows[i] == obj) { unregisterObject(_windows[i]); stack->pushBool(true); - return S_OK; + return STATUS_OK; } } stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1886,7 +1886,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "OpenDocument") == 0) { stack->correctParams(0); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1896,7 +1896,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); DEBUG_DumpClassRegistry(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1915,7 +1915,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBUtils::setString(&_loadImageName, val->getString()); } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1934,7 +1934,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CBUtils::setString(&_saveImageName, val->getString()); } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1942,10 +1942,10 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1958,7 +1958,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1969,7 +1969,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); else stack->pushString(_cursorNoninteractive->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1980,7 +1980,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (!_cursorNoninteractive) stack->pushNULL(); else stack->pushNative(_cursorNoninteractive, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1988,8 +1988,8 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClearScriptCache") == 0) { stack->correctParams(0); - stack->pushBool(SUCCEEDED(_scEngine->emptyScriptCache())); - return S_OK; + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2005,7 +2005,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete _loadingIcon; _loadingIcon = new CBSprite(this); - if (!_loadingIcon || FAILED(_loadingIcon->loadFile(filename))) { + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { delete _loadingIcon; _loadingIcon = NULL; } else { @@ -2015,7 +2015,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2026,7 +2026,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS delete _loadingIcon; _loadingIcon = NULL; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2039,7 +2039,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _renderer->dumpData(filename); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2054,7 +2054,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS // do nothing stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2064,13 +2064,13 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); delete _cachedThumbnail; _cachedThumbnail = new CBSaveThumbHelper(this); - if (FAILED(_cachedThumbnail->storeThumbnail())) { + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2082,7 +2082,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _cachedThumbnail = NULL; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2120,7 +2120,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS file = NULL; } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2131,7 +2131,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _scEngine->enableProfiling(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2142,7 +2142,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS _scEngine->disableProfiling(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2155,7 +2155,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS #endif stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2168,7 +2168,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS #endif stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -2567,14 +2567,14 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2583,7 +2583,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "MouseX") == 0) { _mousePos.x = value->getInt(); resetMousePos(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2592,14 +2592,14 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "MouseY") == 0) { _mousePos.y = value->getInt(); resetMousePos(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - HRESULT res = CBObject::scSetProperty(name, value); + ERRORCODE res = CBObject::scSetProperty(name, value); setWindowTitle(); return res; } @@ -2610,7 +2610,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "MainObject") == 0) { CBScriptable *obj = value->getNative(); if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2618,7 +2618,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Interactive") == 0) { setInteractive(value->getBool()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2627,7 +2627,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)value->getInt()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2636,7 +2636,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)value->getInt()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2645,7 +2645,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)value->getInt()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2654,7 +2654,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "MasterVolume") == 0) { Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); Game->_soundMgr->setMasterVolumePercent((byte)value->getInt()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2662,7 +2662,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtitles") == 0) { _subtitles = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2670,7 +2670,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SubtitlesSpeed") == 0) { _subtitlesSpeed = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2678,7 +2678,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VideoSubtitles") == 0) { _videoSubtitles = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2689,7 +2689,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { if (Enc < 0) Enc = 0; if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; _textEncoding = (TTextEncoding)Enc; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2697,7 +2697,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextRTL") == 0) { _textRTL = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2706,7 +2706,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "SoundBufferSize") == 0) { _soundBufferSizeSec = value->getInt(); _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2714,7 +2714,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuspendedRendering") == 0) { _suspendedRendering = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2722,7 +2722,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SuppressScriptErrors") == 0) { _suppressScriptErrors = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2730,7 +2730,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutorunDisabled") == 0) { _autorunDisabled = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2738,7 +2738,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveOnExit") == 0) { _autoSaveOnExit = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2746,7 +2746,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AutoSaveSlot") == 0) { _autoSaveSlot = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -2754,7 +2754,7 @@ HRESULT CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorHidden") == 0) { _cursorHidden = value->getBool(); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -2770,8 +2770,8 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayQuickMsg() { - if (_quickMessages.GetSize() == 0 || !_systemFont) return S_OK; +ERRORCODE CBGame::displayQuickMsg() { + if (_quickMessages.GetSize() == 0 || !_systemFont) return STATUS_OK; // update for (int i = 0; i < _quickMessages.GetSize(); i++) { @@ -2789,7 +2789,7 @@ HRESULT CBGame::displayQuickMsg() { _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } - return S_OK; + return STATUS_OK; } @@ -2818,15 +2818,15 @@ void CBGame::quickMessageForm(LPSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::registerObject(CBObject *object) { +ERRORCODE CBGame::registerObject(CBObject *object) { _regObjects.Add(object); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::unregisterObject(CBObject *object) { - if (!object) return S_OK; +ERRORCODE CBGame::unregisterObject(CBObject *object) { + if (!object) return STATUS_OK; // is it a window? for (int i = 0; i < _windows.GetSize(); i++) { @@ -2854,11 +2854,11 @@ HRESULT CBGame::unregisterObject(CBObject *object) { _regObjects.RemoveAt(i); if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); delete object; - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } @@ -2889,7 +2889,7 @@ bool CBGame::validObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { +ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *thisObj; ////////////////////////////////////////////////////////////////////////// @@ -3017,7 +3017,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS if (val->isNULL()) a = 255; else a = val->getInt(); - stack->pushInt(DRGBA(r, g, b, a)); + stack->pushInt(BYTETORGBA(r, g, b, a)); } ////////////////////////////////////////////////////////////////////////// @@ -3039,7 +3039,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(D3DCOLGetR(rgba)); + stack->pushInt(RGBCOLGetR(rgba)); } ////////////////////////////////////////////////////////////////////////// @@ -3049,7 +3049,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(D3DCOLGetG(rgba)); + stack->pushInt(RGBCOLGetG(rgba)); } ////////////////////////////////////////////////////////////////////////// @@ -3059,7 +3059,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(D3DCOLGetB(rgba)); + stack->pushInt(RGBCOLGetB(rgba)); } ////////////////////////////////////////////////////////////////////////// @@ -3069,7 +3069,7 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(D3DCOLGetA(rgba)); + stack->pushInt(RGBCOLGetA(rgba)); } ////////////////////////////////////////////////////////////////////////// @@ -3168,29 +3168,29 @@ HRESULT CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisS stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::showCursor() { - if (_cursorHidden) return S_OK; +ERRORCODE CBGame::showCursor() { + if (_cursorHidden) return STATUS_OK; if (!_interactive && Game->_state == GAME_RUNNING) { if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); } else { - if (_activeObject && !FAILED(_activeObject->showCursor())) return S_OK; + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; else { if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); else if (_cursor) return drawCursor(_cursor); } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { +ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH + 1]; getSaveSlotFilename(slot, filename); @@ -3198,12 +3198,12 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { Game->applyEvent("BeforeSave", true); - HRESULT ret; + ERRORCODE ret; _indicatorDisplay = true; _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); - if (FAILED(ret = pm->initSave(desc))) goto save_finish; + if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; if (!quickSave) { delete _saveLoadImage; @@ -3211,16 +3211,16 @@ HRESULT CBGame::SaveGame(int slot, const char *desc, bool quickSave) { if (_saveImageName) { _saveLoadImage = new CBSurfaceSDL(this); - if (!_saveLoadImage || FAILED(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; } } } - if (FAILED(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; - if (FAILED(ret = pm->saveFile(filename))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3236,7 +3236,7 @@ save_finish: // TODO: Remove gotos ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadGame(int slot) { +ERRORCODE CBGame::loadGame(int slot) { //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); _loading = false; @@ -3250,18 +3250,18 @@ HRESULT CBGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadGame(const char *filename) { +ERRORCODE CBGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); getDebugMgr()->onGameShutdown(); - HRESULT ret; + ERRORCODE ret; delete _saveLoadImage; _saveLoadImage = NULL; if (_loadImageName) { _saveLoadImage = new CBSurfaceSDL(this); - if (!_saveLoadImage || FAILED(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; } @@ -3273,11 +3273,11 @@ HRESULT CBGame::loadGame(const char *filename) { _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(Game); _dEBUG_AbsolutePathWarning = false; - if (FAILED(ret = pm->initLoad(filename))) goto load_finish; + if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - //if(FAILED(ret = cleanup())) goto load_finish; - if (FAILED(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish; - if (FAILED(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish; + //if(DID_FAIL(ret = cleanup())) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish; // data initialization after load initAfterLoad(); @@ -3306,7 +3306,7 @@ load_finish: ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::initAfterLoad() { +ERRORCODE CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); @@ -3316,7 +3316,7 @@ HRESULT CBGame::initAfterLoad() { _scEngine->refreshScriptBreakpoints(); if (_store) _store->afterLoad(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -3348,8 +3348,8 @@ void CBGame::afterLoadScript(void *script, void *data) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayWindows(bool inGame) { - HRESULT res; +ERRORCODE CBGame::displayWindows(bool inGame) { + ERRORCODE res; // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { @@ -3367,26 +3367,26 @@ HRESULT CBGame::displayWindows(bool inGame) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); - if (FAILED(res)) return res; + if (DID_FAIL(res)) return res; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { +ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return E_FAIL; + return STATUS_FAILED; } delete _music[channel]; _music[channel] = NULL; _music[channel] = new CBSound(Game); - if (_music[channel] && SUCCEEDED(_music[channel]->setSound(filename, SOUND_MUSIC, true))) { + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, SOUND_MUSIC, true))) { if (_musicStartTime[channel]) { _music[channel]->setPositionTime(_musicStartTime[channel]); _musicStartTime[channel] = 0; @@ -3396,66 +3396,66 @@ HRESULT CBGame::playMusic(int channel, const char *filename, bool looping, uint3 } else { delete _music[channel]; _music[channel] = NULL; - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::stopMusic(int channel) { +ERRORCODE CBGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return E_FAIL; + return STATUS_FAILED; } if (_music[channel]) { _music[channel]->stop(); delete _music[channel]; _music[channel] = NULL; - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::pauseMusic(int channel) { +ERRORCODE CBGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return E_FAIL; + return STATUS_FAILED; } if (_music[channel]) return _music[channel]->pause(); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::resumeMusic(int channel) { +ERRORCODE CBGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return E_FAIL; + return STATUS_FAILED; } if (_music[channel]) return _music[channel]->resume(); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::setMusicStartTime(int channel, uint32 time) { +ERRORCODE CBGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return E_FAIL; + return STATUS_FAILED; } _musicStartTime[channel] = time; if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return S_OK; + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::loadSettings(const char *filename) { +ERRORCODE CBGame::loadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3479,10 +3479,10 @@ HRESULT CBGame::loadSettings(const char *filename) { byte *origBuffer = Game->_fileManager->readWholeFile(filename); if (origBuffer == NULL) { Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret = S_OK; + ERRORCODE ret = STATUS_OK; byte *buffer = origBuffer; byte *params; @@ -3491,7 +3491,7 @@ HRESULT CBGame::loadSettings(const char *filename) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -3503,7 +3503,7 @@ HRESULT CBGame::loadSettings(const char *filename) { break; case TOKEN_STRING_TABLE: - if (FAILED(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_RESOLUTION: @@ -3560,11 +3560,11 @@ HRESULT CBGame::loadSettings(const char *filename) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in game settings '%s'", filename); - ret = E_FAIL; + ret = STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading game settings '%s'", filename); - ret = E_FAIL; + ret = STATUS_FAILED; } _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); @@ -3578,7 +3578,7 @@ HRESULT CBGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); @@ -3671,12 +3671,12 @@ HRESULT CBGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) _quitting = false; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::focusWindow(CUIWindow *Window) { +ERRORCODE CBGame::focusWindow(CUIWindow *Window) { CUIWindow *Prev = _focusedWindow; for (int i = 0; i < _windows.GetSize(); i++) { @@ -3690,15 +3690,15 @@ HRESULT CBGame::focusWindow(CUIWindow *Window) { if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) return focusWindow(Prev); - else return S_OK; + else return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::freeze(bool includingMusic) { +ERRORCODE CBGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { _scEngine->pauseAll(); _soundMgr->pauseAll(includingMusic); @@ -3709,13 +3709,13 @@ HRESULT CBGame::freeze(bool includingMusic) { _state = GAME_FROZEN; _freezeLevel++; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::unfreeze() { - if (_freezeLevel == 0) return S_OK; +ERRORCODE CBGame::unfreeze() { + if (_freezeLevel == 0) return STATUS_OK; _freezeLevel--; if (_freezeLevel == 0) { @@ -3725,7 +3725,7 @@ HRESULT CBGame::unfreeze() { _soundMgr->resumeAll(); } - return S_OK; + return STATUS_OK; } @@ -3811,14 +3811,14 @@ bool CBGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +ERRORCODE CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { if (verMajor) *verMajor = DCGF_VER_MAJOR; if (verMinor) *verMinor = DCGF_VER_MINOR; if (extMajor) *extMajor = 0; if (extMinor) *extMinor = 0; - return S_OK; + return STATUS_OK; } @@ -3851,12 +3851,12 @@ void CBGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getSaveSlotFilename(int slot, char *buffer) { +ERRORCODE CBGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); sprintf(buffer, "save%03d.%s", slot, _savedGameExt); warning("Saving %s - we really should prefix these things to avoid collisions.", buffer); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -3872,26 +3872,26 @@ AnsiString CBGame::getDataDir() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getSaveSlotDescription(int slot, char *buffer) { +ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; char filename[MAX_PATH + 1]; getSaveSlotFilename(slot, filename); CBPersistMgr *pm = new CBPersistMgr(Game); - if (!pm) return E_FAIL; + if (!pm) return STATUS_FAILED; _dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->initLoad(filename))) { + if (DID_FAIL(pm->initLoad(filename))) { _dEBUG_AbsolutePathWarning = true; delete pm; - return E_FAIL; + return STATUS_FAILED; } _dEBUG_AbsolutePathWarning = true; strcpy(buffer, pm->_savedDescription); delete pm; - return S_OK; + return STATUS_OK; } @@ -3909,24 +3909,24 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::emptySaveSlot(int slot) { +ERRORCODE CBGame::emptySaveSlot(int slot) { char filename[MAX_PATH + 1]; getSaveSlotFilename(slot, filename); CBPlatform::deleteFile(filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::setActiveObject(CBObject *obj) { +ERRORCODE CBGame::setActiveObject(CBObject *obj) { // not-active when game is frozen if (obj && !Game->_interactive && !obj->_nonIntMouseEvents) { obj = NULL; } - if (obj == _activeObject) return S_OK; + if (obj == _activeObject) return STATUS_OK; if (_activeObject) _activeObject->applyEvent("MouseLeave"); //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); @@ -3935,24 +3935,24 @@ HRESULT CBGame::setActiveObject(CBObject *obj) { _activeObject->applyEvent("MouseEntry"); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::pushViewport(CBViewport *viewport) { +ERRORCODE CBGame::pushViewport(CBViewport *viewport) { _viewportSP++; if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(viewport); else _viewportStack[_viewportSP] = viewport; _renderer->setViewport(viewport->getRect()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::popViewport() { +ERRORCODE CBGame::popViewport() { _viewportSP--; if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); @@ -3962,13 +3962,13 @@ HRESULT CBGame::popViewport() { _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { - if (rect == NULL) return E_FAIL; +ERRORCODE CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { + if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); @@ -3981,13 +3981,13 @@ HRESULT CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { if (custom) *custom = false; } - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { +ERRORCODE CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; @@ -3996,19 +3996,19 @@ HRESULT CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (offsetY) *offsetY = 0; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { - return E_FAIL; +ERRORCODE CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - return E_FAIL; +ERRORCODE CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + return STATUS_FAILED; } @@ -4030,23 +4030,23 @@ void CBGame::resetMousePos() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayContent(bool doUpdate, bool displayAll) { - return S_OK; +ERRORCODE CBGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayContentSimple() { +ERRORCODE CBGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); if (_indicatorDisplay) displayIndicator(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayIndicator() { +ERRORCODE CBGame::displayIndicator() { if (_saveLoadImage) { RECT rc; CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); @@ -4054,29 +4054,29 @@ HRESULT CBGame::displayIndicator() { else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return S_OK; + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; _renderer->setupLines(); for (int i = 0; i < _indicatorHeight; i++) _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); _renderer->setup2D(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::updateMusicCrossfade() { +ERRORCODE CBGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - if (!_musicCrossfadeRunning) return S_OK; - if (_state == GAME_FROZEN) return S_OK; + if (!_musicCrossfadeRunning) return STATUS_OK; + if (_state == GAME_FROZEN) return STATUS_OK; if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { _musicCrossfadeRunning = false; - return S_OK; + return STATUS_OK; } if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { _musicCrossfadeRunning = false; - return S_OK; + return STATUS_OK; } if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); @@ -4114,17 +4114,17 @@ HRESULT CBGame::updateMusicCrossfade() { //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::resetContent() { +ERRORCODE CBGame::resetContent() { _scEngine->clearGlobals(); //_timer = 0; //_liveTimer = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -4142,33 +4142,33 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::invalidateDeviceObjects() { +ERRORCODE CBGame::invalidateDeviceObjects() { for (int i = 0; i < _regObjects.GetSize(); i++) { _regObjects[i]->invalidateDeviceObjects(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::restoreDeviceObjects() { +ERRORCODE CBGame::restoreDeviceObjects() { for (int i = 0; i < _regObjects.GetSize(); i++) { _regObjects[i]->restoreDeviceObjects(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::setWaitCursor(const char *filename) { +ERRORCODE CBGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; _cursorNoninteractive = new CBSprite(Game); - if (!_cursorNoninteractive || FAILED(_cursorNoninteractive->loadFile(filename))) { + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -4179,20 +4179,20 @@ bool CBGame::isVideoPlaying() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::stopVideo() { +ERRORCODE CBGame::stopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); delete _theoraPlayer; _theoraPlayer = NULL; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::drawCursor(CBSprite *cursor) { - if (!cursor) return E_FAIL; +ERRORCODE CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return STATUS_FAILED; if (cursor != _lastCursor) { cursor->reset(); _lastCursor = cursor; @@ -4203,8 +4203,8 @@ HRESULT CBGame::drawCursor(CBSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return S_OK; +ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) return STATUS_OK; _renderer->_active = activate; @@ -4217,14 +4217,14 @@ HRESULT CBGame::onActivate(bool activate, bool refreshMouse) { if (activate) _soundMgr->resumeAll(); else _soundMgr->pauseAll(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseLeftDown() { +ERRORCODE CBGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftClick"); @@ -4235,131 +4235,131 @@ HRESULT CBGame::onMouseLeftDown() { _mouseLeftDown = true; CBPlatform::setCapture(/*_renderer->_window*/); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseLeftUp() { +ERRORCODE CBGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftRelease")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftRelease"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; +ERRORCODE CBGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("LeftDoubleClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("LeftDoubleClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; +ERRORCODE CBGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightDoubleClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightDoubleClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseRightDown() { +ERRORCODE CBGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseRightUp() { +ERRORCODE CBGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("RightRelease")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("RightRelease"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return S_OK; +ERRORCODE CBGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleClick")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("MiddleClick"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onMouseMiddleUp() { +ERRORCODE CBGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - bool handled = _state == GAME_RUNNING && SUCCEEDED(applyEvent("MiddleRelease")); + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); if (!handled) { if (_activeObject != NULL) { _activeObject->applyEvent("MiddleRelease"); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onPaint() { +ERRORCODE CBGame::onPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { _renderer->initLoop(); displayContent(false, true); displayDebugInfo(); _renderer->windowedBlt(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onWindowClose() { +ERRORCODE CBGame::onWindowClose() { if (canHandleEvent("QuitGame")) { if (_state != GAME_FROZEN) Game->applyEvent("QuitGame"); - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::displayDebugInfo() { +ERRORCODE CBGame::displayDebugInfo() { char str[100]; if (_dEBUG_ShowFPS) { @@ -4396,7 +4396,7 @@ HRESULT CBGame::displayDebugInfo() { } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -4445,19 +4445,19 @@ void CBGame::getMousePos(POINT *pos) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::miniUpdate() { - if (!_miniUpdateEnabled) return S_OK; +ERRORCODE CBGame::miniUpdate() { + if (!_miniUpdateEnabled) return STATUS_OK; if (CBPlatform::getTime() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); _lastMiniUpdate = CBPlatform::getTime(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBGame::onScriptShutdown(CScScript *script) { - return S_OK; +ERRORCODE CBGame::onScriptShutdown(CScScript *script) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 0d1d0fe15d..44b5b4a86d 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -38,7 +38,7 @@ namespace WinterMute { -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, HRESULT Result, void *Data); +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, ERRORCODE Result, void *Data); class CBSoundMgr; class CBFader; @@ -67,19 +67,19 @@ class CBGame: public CBObject { public: DECLARE_PERSISTENT(CBGame, CBObject) - virtual HRESULT onScriptShutdown(CScScript *script); + virtual ERRORCODE onScriptShutdown(CScScript *script); - virtual HRESULT onActivate(bool activate, bool refreshMouse); - virtual HRESULT onMouseLeftDown(); - virtual HRESULT onMouseLeftUp(); - virtual HRESULT onMouseLeftDblClick(); - virtual HRESULT onMouseRightDblClick(); - virtual HRESULT onMouseRightDown(); - virtual HRESULT onMouseRightUp(); - virtual HRESULT onMouseMiddleDown(); - virtual HRESULT onMouseMiddleUp(); - virtual HRESULT onPaint(); - virtual HRESULT onWindowClose(); + virtual ERRORCODE onActivate(bool activate, bool refreshMouse); + virtual ERRORCODE onMouseLeftDown(); + virtual ERRORCODE onMouseLeftUp(); + virtual ERRORCODE onMouseLeftDblClick(); + virtual ERRORCODE onMouseRightDblClick(); + virtual ERRORCODE onMouseRightDown(); + virtual ERRORCODE onMouseRightUp(); + virtual ERRORCODE onMouseMiddleDown(); + virtual ERRORCODE onMouseMiddleUp(); + virtual ERRORCODE onPaint(); + virtual ERRORCODE onWindowClose(); bool isLeftDoubleClick(); bool isRightDoubleClick(); @@ -89,14 +89,14 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - virtual HRESULT miniUpdate(); + virtual ERRORCODE miniUpdate(); void getMousePos(POINT *Pos); RECT _mouseLockRect; bool _shuttingDown; - virtual HRESULT displayDebugInfo(); + virtual ERRORCODE displayDebugInfo(); bool _dEBUG_ShowFPS; bool _suspendedRendering; @@ -110,10 +110,10 @@ public: int _loadingIconY; int _loadingIconPersistent; - virtual HRESULT resetContent(); + virtual ERRORCODE resetContent(); void DEBUG_DumpClassRegistry(); - HRESULT setWaitCursor(const char *filename); + ERRORCODE setWaitCursor(const char *filename); char *_localSaveDir; bool _saveDirChecked; @@ -137,7 +137,7 @@ public: int _loadImageY; CBSurface *_saveLoadImage; - HRESULT displayIndicator(); + ERRORCODE displayIndicator(); int _thumbnailWidth; int _thumbnailHeight; @@ -159,20 +159,20 @@ public: float _offsetPercentY; CBObject *_mainObject; - HRESULT initInput(); - HRESULT initLoop(); + ERRORCODE initInput(); + ERRORCODE initLoop(); uint32 _currentTime; uint32 _deltaTime; CBFont *_systemFont; CBFont *_videoFont; - HRESULT initialize1(); - HRESULT initialize2(); - HRESULT initialize3(); + ERRORCODE initialize1(); + ERRORCODE initialize2(); + ERRORCODE initialize3(); CBFileManager *_fileManager; CBTransitionMgr *_transMgr; CBDebugger *getDebugMgr(); - void LOG(HRESULT res, LPCSTR fmt, ...); + void LOG(ERRORCODE res, LPCSTR fmt, ...); CBRenderer *_renderer; CBSoundMgr *_soundMgr; @@ -191,8 +191,8 @@ public: void *_dEBUG_LogFile; int _sequence; - virtual HRESULT loadFile(const char *filename); - virtual HRESULT loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE loadFile(const char *filename); + virtual ERRORCODE loadBuffer(byte *buffer, bool complete = true); CBArray _quickMessages; CBArray _windows; CBArray _viewportStack; @@ -217,14 +217,14 @@ public: CBFader *_fader; bool _suppressScriptErrors; - virtual HRESULT invalidateDeviceObjects(); - virtual HRESULT restoreDeviceObjects(); + virtual ERRORCODE invalidateDeviceObjects(); + virtual ERRORCODE restoreDeviceObjects(); - virtual HRESULT ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; @@ -245,21 +245,21 @@ public: int _scheduledLoadSlot; bool _loading; bool _personalizedSave; - HRESULT emptySaveSlot(int slot); + ERRORCODE emptySaveSlot(int slot); bool isSaveSlotUsed(int slot); - HRESULT getSaveSlotDescription(int slot, char *buffer); - HRESULT getSaveSlotFilename(int slot, char *buffer); + ERRORCODE getSaveSlotDescription(int slot, char *buffer); + ERRORCODE getSaveSlotFilename(int slot, char *buffer); void setWindowTitle(); virtual bool handleMouseWheel(int delta); bool _quitting; - virtual HRESULT getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + virtual ERRORCODE getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); int _freezeLevel; - HRESULT unfreeze(); - HRESULT freeze(bool includingMusic = true); - HRESULT focusWindow(CUIWindow *window); + ERRORCODE unfreeze(); + ERRORCODE freeze(bool includingMusic = true); + ERRORCODE focusWindow(CUIWindow *window); CVidPlayer *_videoPlayer; CVidTheoraPlayer *_theoraPlayer; bool _loadInProgress; @@ -272,12 +272,12 @@ public: static void afterLoadScript(void *script, void *data); static void invalidateValues(void *value, void *data); - HRESULT loadSettings(const char *filename); - HRESULT resumeMusic(int channel); - HRESULT setMusicStartTime(int channel, uint32 time); - HRESULT pauseMusic(int channel); - HRESULT stopMusic(int channel); - HRESULT playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + ERRORCODE loadSettings(const char *filename); + ERRORCODE resumeMusic(int channel); + ERRORCODE setMusicStartTime(int channel, uint32 time); + ERRORCODE pauseMusic(int channel); + ERRORCODE stopMusic(int channel); + ERRORCODE playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); CBSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; @@ -285,14 +285,14 @@ public: uint32 _musicCrossfadeLength; int _musicCrossfadeChannel1; int _musicCrossfadeChannel2; - HRESULT displayWindows(bool inGame = false); + ERRORCODE displayWindows(bool inGame = false); CBRegistry *_registry; bool _useD3D; - virtual HRESULT cleanup(); - virtual HRESULT loadGame(int slot); - virtual HRESULT loadGame(const char *filename); - virtual HRESULT SaveGame(int slot, const char *desc, bool quickSave = false); - virtual HRESULT showCursor(); + virtual ERRORCODE cleanup(); + virtual ERRORCODE loadGame(int slot); + virtual ERRORCODE loadGame(const char *filename); + virtual ERRORCODE SaveGame(int slot, const char *desc, bool quickSave = false); + virtual ERRORCODE showCursor(); CBSprite *_cursorNoninteractive; CBObject *_activeObject; @@ -312,36 +312,36 @@ public: CBObject *_capturedObject; POINT _mousePos; bool validObject(CBObject *object); - HRESULT unregisterObject(CBObject *object); - HRESULT registerObject(CBObject *object); + ERRORCODE unregisterObject(CBObject *object); + ERRORCODE registerObject(CBObject *object); void quickMessage(const char *text); void quickMessageForm(LPSTR fmt, ...); - HRESULT displayQuickMsg(); + ERRORCODE displayQuickMsg(); uint32 _fps; - HRESULT updateMusicCrossfade(); + ERRORCODE updateMusicCrossfade(); bool isVideoPlaying(); - HRESULT stopVideo(); + ERRORCODE stopVideo(); CBArray _regObjects; public: - virtual HRESULT displayContent(bool update = true, bool displayAll = false); - virtual HRESULT displayContentSimple(); + virtual ERRORCODE displayContent(bool update = true, bool displayAll = false); + virtual ERRORCODE displayContentSimple(); bool _forceNonStreamedSounds; void resetMousePos(); int _subtitlesSpeed; void setInteractive(bool state); - virtual HRESULT windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual HRESULT windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - HRESULT getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - HRESULT getCurrentViewportRect(RECT *rect, bool *custom = NULL); - HRESULT popViewport(); - HRESULT pushViewport(CBViewport *Viewport); - HRESULT setActiveObject(CBObject *Obj); + virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + ERRORCODE getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + ERRORCODE getCurrentViewportRect(RECT *rect, bool *custom = NULL); + ERRORCODE popViewport(); + ERRORCODE pushViewport(CBViewport *Viewport); + ERRORCODE setActiveObject(CBObject *Obj); CBSprite *_lastCursor; - HRESULT drawCursor(CBSprite *Cursor); + ERRORCODE drawCursor(CBSprite *Cursor); - virtual HRESULT initAfterLoad(); + virtual ERRORCODE initAfterLoad(); CBSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index c119e023c1..c28577087b 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -70,7 +70,7 @@ CBImage::~CBImage() { #endif } -HRESULT CBImage::loadFile(const Common::String &filename) { +ERRORCODE CBImage::loadFile(const Common::String &filename) { _filename = filename; if (StringUtil::startsWith(filename, "savegame:", true)) { @@ -88,14 +88,14 @@ HRESULT CBImage::loadFile(const Common::String &filename) { } Common::SeekableReadStream *file = Game->_fileManager->openFile(filename.c_str()); - if (!file) return E_FAIL; + if (!file) return STATUS_FAILED; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); Game->_fileManager->closeFile(file); - return S_OK; + return STATUS_OK; } byte CBImage::getAlphaAt(int x, int y) { @@ -112,21 +112,21 @@ void CBImage::copyFrom(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::saveBMPFile(const char *filename) { +ERRORCODE CBImage::saveBMPFile(const char *filename) { #if 0 - if (!_bitmap) return E_FAIL; + if (!_bitmap) return STATUS_FAILED; - if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return S_OK; - else return E_FAIL; + if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; + else return STATUS_FAILED; #endif - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::resize(int newWidth, int newHeight) { +ERRORCODE CBImage::resize(int newWidth, int newHeight) { #if 0 - if (!_bitmap) return E_FAIL; + if (!_bitmap) return STATUS_FAILED; if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); @@ -136,10 +136,10 @@ HRESULT CBImage::resize(int newWidth, int newHeight) { if (newImg) { FreeImage_Unload(_bitmap); _bitmap = newImg; - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; #endif - return E_FAIL; + return STATUS_FAILED; } @@ -248,7 +248,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +ERRORCODE CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { #if 0 if (_bitmap) FreeImage_Unload(_bitmap); @@ -264,7 +264,7 @@ HRESULT CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { _deletableSurface = NULL; } _surface = _deletableSurface = temp.scale(newWidth, newHeight); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index 8edde54d3f..c66f6f4ca3 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -47,7 +47,7 @@ public: CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); ~CBImage(); - HRESULT loadFile(const Common::String &filename); + ERRORCODE loadFile(const Common::String &filename); const Graphics::Surface *getSurface() const { return _surface; }; @@ -56,9 +56,9 @@ public: } byte getAlphaAt(int x, int y); bool writeBMPToStream(Common::WriteStream *stream); - HRESULT resize(int newWidth, int newHeight); - HRESULT saveBMPFile(const char *filename); - HRESULT copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + ERRORCODE resize(int newWidth, int newHeight); + ERRORCODE saveBMPFile(const char *filename); + ERRORCODE copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); void copyFrom(Graphics::Surface *surface); private: Common::String _filename; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index 36a208b317..f67833eb5e 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -73,7 +73,7 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// @@ -95,7 +95,7 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta bool isDown = _keyStates[vKeyToKeyCode(vKey)]; stack->pushBool(isDown); - return S_OK; + return STATUS_OK; } else return CBScriptable::scCallMethod(script, stack, thisStack, name); @@ -173,7 +173,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBKeyboardState::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -181,7 +181,7 @@ HRESULT CBKeyboardState::scSetProperty(const char *name, CScValue *value) { if (strcmp(name, "Name") == 0) { setName(value->getString()); if (_renderer) SetWindowText(_renderer->_window, _name); - return S_OK; + return STATUS_OK; } else*/ return CBScriptable::scSetProperty(name, value); @@ -195,7 +195,7 @@ const char *CBKeyboardState::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::readKey(Common::Event *event) { +ERRORCODE CBKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || @@ -210,12 +210,12 @@ HRESULT CBKeyboardState::readKey(Common::Event *event) { _currentAlt = isAltDown(); _currentShift = isShiftDown(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBKeyboardState::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBKeyboardState::persist(CBPersistMgr *persistMgr) { //if(!persistMgr->_saving) cleanup(); CBScriptable::persist(persistMgr); @@ -233,7 +233,7 @@ HRESULT CBKeyboardState::persist(CBPersistMgr *persistMgr) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index da324b86a3..29844e5d09 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -50,7 +50,7 @@ public: DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) CBKeyboardState(CBGame *inGame); virtual ~CBKeyboardState(); - HRESULT readKey(Common::Event *event); + ERRORCODE readKey(Common::Event *event); void handleKeyPress(Common::Event *event); void handleKeyRelease(Common::Event *event); @@ -60,8 +60,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index af688a4514..abced32767 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -107,7 +107,7 @@ CBObject::~CBObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::cleanup() { +ERRORCODE CBObject::cleanup() { if (Game && Game->_activeObject == this) Game->_activeObject = NULL; @@ -132,7 +132,7 @@ HRESULT CBObject::cleanup() { _sFXType = SFX_NONE; _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - return S_OK; + return STATUS_OK; } @@ -161,15 +161,15 @@ const char *CBObject::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::listen(CBScriptHolder *param1, uint32 param2) { - return E_FAIL; +ERRORCODE CBObject::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -181,7 +181,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi afterMove(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -191,7 +191,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); stack->pushString(getCaption(stack->pop()->getInt())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -199,10 +199,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { stack->correctParams(1); - if (SUCCEEDED(setCursor(stack->pop()->getString()))) stack->pushBool(true); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -219,7 +219,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -230,7 +230,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!_cursor || !_cursor->_filename) stack->pushNULL(); else stack->pushString(_cursor->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!_cursor) stack->pushNULL(); else stack->pushNative(_cursor, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -253,7 +253,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (_cursor) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -264,7 +264,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi setCaption(stack->pop()->getString(), stack->pop()->getInt()); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -273,12 +273,12 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); const char *filename = stack->pop()->getString(); - if (SUCCEEDED(playSFX(filename, false, false))) + if (DID_SUCCEED(playSFX(filename, false, false))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -306,10 +306,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi loopStart = val3->getInt(); } - if (FAILED(playSFX(filename, looping, true, NULL, loopStart))) + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -332,9 +332,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi eventName = val2->getString(); } - if (FAILED(playSFX(filename, false, true, eventName))) stack->pushBool(false); + if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -343,9 +343,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "StopSound") == 0) { stack->correctParams(0); - if (FAILED(stopSFX())) stack->pushBool(false); + if (DID_FAIL(stopSFX())) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -354,9 +354,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "PauseSound") == 0) { stack->correctParams(0); - if (FAILED(pauseSFX())) stack->pushBool(false); + if (DID_FAIL(pauseSFX())) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -365,9 +365,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "ResumeSound") == 0) { stack->correctParams(0); - if (FAILED(resumeSFX())) stack->pushBool(false); + if (DID_FAIL(resumeSFX())) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -378,7 +378,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (_sFX && _sFX->isPlaying()) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -388,9 +388,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); uint32 Time = stack->pop()->getInt(); - if (FAILED(setSFXTime(Time))) stack->pushBool(false); + if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -401,7 +401,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!_sFX) stack->pushInt(0); else stack->pushInt(_sFX->getPositionTime()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -411,9 +411,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); int volume = stack->pop()->getInt(); - if (FAILED(setSFXVolume(volume))) stack->pushBool(false); + if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -424,7 +424,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (!_sFX) stack->pushInt(_sFXVolume); else stack->pushInt(_sFX->getVolume()); - return S_OK; + return STATUS_OK; } @@ -440,7 +440,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _sFXParam4 = 0; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -455,7 +455,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -470,7 +470,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); @@ -671,13 +671,13 @@ CScValue *CBObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Caption") == 0) { setCaption(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -686,7 +686,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "X") == 0) { _posX = value->getInt(); afterMove(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -695,7 +695,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Y") == 0) { _posY = value->getInt(); afterMove(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -703,7 +703,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Movable") == 0) { _movable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -711,7 +711,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { _registrable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -719,7 +719,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { _zoomable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -727,7 +727,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotatable") == 0) { _rotatable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -735,7 +735,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaColor") == 0) { _alphaColor = (uint32)value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -745,7 +745,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { int i = value->getInt(); if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; _blendMode = (TSpriteBlendMode)i; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -754,7 +754,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Scale") == 0) { if (value->isNULL()) _scale = -1; else _scale = (float)value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -763,7 +763,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "ScaleX") == 0) { if (value->isNULL()) _scaleX = -1; else _scaleX = (float)value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -772,7 +772,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "ScaleY") == 0) { if (value->isNULL()) _scaleY = -1; else _scaleY = (float)value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -780,7 +780,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeScale") == 0) { _relativeScale = (float)value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -794,7 +794,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { _rotate = (float)value->getFloat(); _rotateValid = true; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -802,7 +802,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RelativeRotate") == 0) { _relativeRotate = (float)value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -810,7 +810,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Colorable") == 0) { _shadowable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -819,7 +819,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "SoundPanning") == 0) { _autoSoundPanning = value->getBool(); if (!_autoSoundPanning) resetSoundPan(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -827,7 +827,7 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveState") == 0) { _saveState = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -835,14 +835,14 @@ HRESULT CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NonIntMouseEvents") == 0) { _nonIntMouseEvents = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccCaption") == 0) { - return S_OK; + return STATUS_OK; } else return CBScriptHolder::scSetProperty(name, value); @@ -856,20 +856,20 @@ const char *CBObject::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::showCursor() { +ERRORCODE CBObject::showCursor() { if (_cursor) return Game->drawCursor(_cursor); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::saveAsText(CBDynBuffer *buffer, int indent) { - return S_OK; +ERRORCODE CBObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBObject::persist(CBPersistMgr *persistMgr) { CBScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) @@ -920,12 +920,12 @@ HRESULT CBObject::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER_INT(_blendMode)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::setCursor(const char *filename) { +ERRORCODE CBObject::setCursor(const char *filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -933,23 +933,23 @@ HRESULT CBObject::setCursor(const char *filename) { _sharedCursors = false; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile(filename))) { + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { delete _cursor; _cursor = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::setActiveCursor(const char *filename) { +ERRORCODE CBObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = new CBSprite(Game); - if (!_activeCursor || FAILED(_activeCursor->loadFile(filename))) { + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { delete _activeCursor; _activeCursor = NULL; - return E_FAIL; - } else return S_OK; + return STATUS_FAILED; + } else return STATUS_OK; } @@ -960,8 +960,8 @@ int CBObject::getHeight() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::handleMouse(TMouseEvent event, TMouseButton button) { - return S_OK; +ERRORCODE CBObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; } @@ -978,7 +978,7 @@ bool CBObject::handleMouseWheel(int delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { +ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound if (filename == NULL && _sFX) { if (Game->_editorMode || _sFXStart) { @@ -990,16 +990,16 @@ HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, cons setSoundEvent(eventName); if (loopStart) _sFX->setLoopStart(loopStart); return _sFX->play(looping); - } else return S_OK; + } else return STATUS_OK; } - if (filename == NULL) return E_FAIL; + if (filename == NULL) return STATUS_FAILED; // create new sound delete _sFX; _sFX = new CBSound(Game); - if (_sFX && SUCCEEDED(_sFX->setSound(filename, SOUND_SFX, true))) { + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, SOUND_SFX, true))) { _sFX->setVolume(_sFXVolume); if (_sFXStart) { _sFX->setPositionTime(_sFXStart); @@ -1010,60 +1010,60 @@ HRESULT CBObject::playSFX(const char *filename, bool looping, bool playNow, cons setSoundEvent(eventName); if (loopStart) _sFX->setLoopStart(loopStart); return _sFX->play(looping); - } else return S_OK; + } else return STATUS_OK; } else { delete _sFX; _sFX = NULL; - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::stopSFX(bool deleteSound) { +ERRORCODE CBObject::stopSFX(bool deleteSound) { if (_sFX) { _sFX->stop(); if (deleteSound) { delete _sFX; _sFX = NULL; } - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::pauseSFX() { +ERRORCODE CBObject::pauseSFX() { if (_sFX) return _sFX->pause(); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::resumeSFX() { +ERRORCODE CBObject::resumeSFX() { if (_sFX) return _sFX->resume(); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::setSFXTime(uint32 time) { +ERRORCODE CBObject::setSFXTime(uint32 time) { _sFXStart = time; if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return S_OK; + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::setSFXVolume(int volume) { +ERRORCODE CBObject::setSFXVolume(int volume) { _sFXVolume = volume; if (_sFX) return _sFX->setVolume(volume); - else return S_OK; + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::updateSounds() { +ERRORCODE CBObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); @@ -1073,12 +1073,12 @@ HRESULT CBObject::updateSounds() { if (_sFX) updateOneSound(_sFX); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::updateOneSound(CBSound *sound) { - HRESULT Ret = S_OK; +ERRORCODE CBObject::updateOneSound(CBSound *sound) { + ERRORCODE Ret = STATUS_OK; if (sound) { if (_autoSoundPanning) @@ -1090,8 +1090,8 @@ HRESULT CBObject::updateOneSound(CBSound *sound) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::resetSoundPan() { - if (!_sFX) return S_OK; +ERRORCODE CBObject::resetSoundPan() { + if (!_sFX) return STATUS_OK; else { return _sFX->setPan(0.0f); } @@ -1121,8 +1121,8 @@ void CBObject::setSoundEvent(const char *eventName) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBObject::afterMove() { - return S_OK; +ERRORCODE CBObject::afterMove() { + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index db2bd2f290..ff876a3035 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -46,7 +46,7 @@ class CScScript; class CBObject : public CBScriptHolder { public: TSpriteBlendMode _blendMode; - virtual HRESULT afterMove(); + virtual ERRORCODE afterMove(); float _relativeRotate; bool _rotateValid; float _rotate; @@ -59,18 +59,18 @@ public: float _relativeScale; virtual bool isReady(); virtual bool getExtendedFlag(const char *flagName); - virtual HRESULT resetSoundPan(); - virtual HRESULT updateSounds(); - HRESULT updateOneSound(CBSound *sound); + virtual ERRORCODE resetSoundPan(); + virtual ERRORCODE updateSounds(); + ERRORCODE updateOneSound(CBSound *sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; - HRESULT setSFXTime(uint32 time); - HRESULT setSFXVolume(int volume); - HRESULT resumeSFX(); - HRESULT pauseSFX(); - HRESULT stopSFX(bool deleteSound = true); - HRESULT playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + ERRORCODE setSFXTime(uint32 time); + ERRORCODE setSFXVolume(int volume); + ERRORCODE resumeSFX(); + ERRORCODE pauseSFX(); + ERRORCODE stopSFX(bool deleteSound = true); + ERRORCODE playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -80,12 +80,12 @@ public: float _sFXParam4; virtual bool handleMouseWheel(int delta); - virtual HRESULT handleMouse(TMouseEvent event, TMouseButton button); + virtual ERRORCODE handleMouse(TMouseEvent event, TMouseButton button); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual int getHeight(); - HRESULT setCursor(const char *filename); - HRESULT setActiveCursor(const char *filename); - HRESULT cleanup(); + ERRORCODE setCursor(const char *filename); + ERRORCODE setActiveCursor(const char *filename); + ERRORCODE cleanup(); const char *getCaption(int caseVal = 1); void setCaption(const char *caption, int caseVal = 1); bool _editorSelected; @@ -93,12 +93,12 @@ public: bool _editorOnly; bool _is3D; DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual HRESULT showCursor(); + virtual ERRORCODE showCursor(); CBSprite *_cursor; bool _sharedCursors; CBSprite *_activeCursor; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; bool _zoomable; @@ -116,17 +116,17 @@ public: bool _saveState; // base - virtual HRESULT update() { - return E_FAIL; + virtual ERRORCODE update() { + return STATUS_FAILED; }; - virtual HRESULT display() { - return E_FAIL; + virtual ERRORCODE display() { + return STATUS_FAILED; }; - virtual HRESULT invalidateDeviceObjects() { - return S_OK; + virtual ERRORCODE invalidateDeviceObjects() { + return STATUS_OK; }; - virtual HRESULT restoreDeviceObjects() { - return S_OK; + virtual ERRORCODE restoreDeviceObjects() { + return STATUS_OK; }; bool _nonIntMouseEvents; @@ -134,8 +134,8 @@ public: public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index e75e537df5..1122ebc16d 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -57,31 +57,31 @@ CBPackage::~CBPackage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::open() { - if (_file) return S_OK; +ERRORCODE CBPackage::open() { + if (_file) return STATUS_OK; else { _file = getFilePointer(); - return _file ? S_OK : E_FAIL; + return _file ? STATUS_OK : STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::close() { +ERRORCODE CBPackage::close() { delete _file; _file = NULL; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - HRESULT ret; - if (FAILED(ret = open())) return ret; +ERRORCODE CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + ERRORCODE ret; + if (DID_FAIL(ret = open())) return ret; else { - if (file->seek(offset, SEEK_SET)) return E_FAIL; - if (file->read(buffer, size) != 1) return E_FAIL; - else return S_OK; + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; } } diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h index 6135e5324a..cb56717b71 100644 --- a/engines/wintermute/Base/BPackage.h +++ b/engines/wintermute/Base/BPackage.h @@ -45,9 +45,9 @@ public: bool _boundToExe; byte _priority; - HRESULT read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - HRESULT close(); - HRESULT open(); + ERRORCODE read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + ERRORCODE close(); + ERRORCODE open(); char *_name; int _cD; Common::SeekableReadStream *_file; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 6491e821ae..bbe532d819 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -119,7 +119,7 @@ Common::String CBPersistMgr::getFilenameForSlot(int slot) { void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (FAILED(readHeader(filename))) { + if (DID_FAIL(readHeader(filename))) { warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); return; } @@ -163,15 +163,15 @@ uint32 CBPersistMgr::getMaxUsedSlot() { bool CBPersistMgr::getSaveExists(int slot) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (FAILED(readHeader(filename))) { + if (DID_FAIL(readHeader(filename))) { return false; } return true; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::initSave(const char *desc) { - if (!desc) return E_FAIL; +ERRORCODE CBPersistMgr::initSave(const char *desc) { + if (!desc) return STATUS_FAILED; cleanup(); _saving = true; @@ -182,7 +182,7 @@ HRESULT CBPersistMgr::initSave(const char *desc) { // get thumbnails if (!Game->_cachedThumbnail) { Game->_cachedThumbnail = new CBSaveThumbHelper(Game); - if (FAILED(Game->_cachedThumbnail->storeThumbnail(true))) { + if (DID_FAIL(Game->_cachedThumbnail->storeThumbnail(true))) { delete Game->_cachedThumbnail; Game->_cachedThumbnail = NULL; } @@ -241,10 +241,10 @@ HRESULT CBPersistMgr::initSave(const char *desc) { _savedPlayTime = g_system->getMillis(); _saveStream->writeUint32LE(_savedPlayTime); } - return S_OK; + return STATUS_OK; } -HRESULT CBPersistMgr::readHeader(const Common::String &filename) { +ERRORCODE CBPersistMgr::readHeader(const Common::String &filename) { cleanup(); _saving = false; @@ -257,7 +257,7 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { if (magic != DCGF_MAGIC) { cleanup(); - return E_FAIL; + return STATUS_FAILED; } magic = getDWORD(); @@ -290,26 +290,26 @@ HRESULT CBPersistMgr::readHeader(const Common::String &filename) { _offset = dataOffset; - return S_OK; + return STATUS_OK; } } cleanup(); - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::initLoad(const char *filename) { - if (FAILED(readHeader(filename))) { +ERRORCODE CBPersistMgr::initLoad(const char *filename) { + if (DID_FAIL(readHeader(filename))) { cleanup(); - return E_FAIL; + return STATUS_FAILED; } _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), Game->_name) != 0) { Game->LOG(0, "ERROR: Saved game name doesn't match current game"); cleanup(); - return E_FAIL; + return STATUS_FAILED; } // if save is newer version than we are, fail @@ -320,7 +320,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { Game->LOG(0, "ERROR: Saved game version is newer than current game"); Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); - return E_FAIL; + return STATUS_FAILED; } // if save is older than the minimal version we support @@ -331,7 +331,7 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); - return E_FAIL; + return STATUS_FAILED; } @@ -343,30 +343,30 @@ HRESULT CBPersistMgr::initLoad(const char *filename) { } */ - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::saveFile(const char *filename) { +ERRORCODE CBPersistMgr::saveFile(const char *filename) { return Game->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::putBytes(byte *buffer, uint32 size) { +ERRORCODE CBPersistMgr::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::getBytes(byte *buffer, uint32 size) { +ERRORCODE CBPersistMgr::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -420,7 +420,7 @@ char *CBPersistMgr::getString() { } else return ret; } -HRESULT CBPersistMgr::putTimeDate(const TimeDate &t) { +ERRORCODE CBPersistMgr::putTimeDate(const TimeDate &t) { _saveStream->writeSint32LE(t.tm_sec); _saveStream->writeSint32LE(t.tm_min); _saveStream->writeSint32LE(t.tm_hour); @@ -430,9 +430,9 @@ HRESULT CBPersistMgr::putTimeDate(const TimeDate &t) { // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next if (_saveStream->err()) { - return E_FAIL; + return STATUS_FAILED; } - return S_OK; + return STATUS_OK; } TimeDate CBPersistMgr::getTimeDate() { @@ -484,134 +484,134 @@ double CBPersistMgr::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -HRESULT CBPersistMgr::transfer(const char *name, bool *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = _loadStream->readByte(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // int -HRESULT CBPersistMgr::transfer(const char *name, int *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = _loadStream->readSint32LE(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // DWORD -HRESULT CBPersistMgr::transfer(const char *name, uint32 *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = _loadStream->readUint32LE(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // float -HRESULT CBPersistMgr::transfer(const char *name, float *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = getFloat(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // double -HRESULT CBPersistMgr::transfer(const char *name, double *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = getDouble(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // char* -HRESULT CBPersistMgr::transfer(const char *name, char **val) { +ERRORCODE CBPersistMgr::transfer(const char *name, char **val) { if (_saving) { putString(*val); - return S_OK; + return STATUS_OK; } else { char *str = getString(); if (_loadStream->err()) { delete[] str; - return E_FAIL; + return STATUS_FAILED; } *val = str; - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // const char* -HRESULT CBPersistMgr::transfer(const char *name, const char **val) { +ERRORCODE CBPersistMgr::transfer(const char *name, const char **val) { if (_saving) { putString(*val); - return S_OK; + return STATUS_OK; } else { char *str = getString(); if (_loadStream->err()) { delete[] str; - return E_FAIL; + return STATUS_FAILED; } *val = str; - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // Common::String -HRESULT CBPersistMgr::transfer(const char *name, Common::String *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Common::String *val) { if (_saving) { putString(*val); - return S_OK; + return STATUS_OK; } else { char *str = getString(); if (_loadStream->err()) { delete[] str; - return E_FAIL; + return STATUS_FAILED; } if (str) { *val = str; @@ -619,12 +619,12 @@ HRESULT CBPersistMgr::transfer(const char *name, Common::String *val) { } else { *val = ""; } - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { +ERRORCODE CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { size_t size; if (_saving) { @@ -642,97 +642,97 @@ HRESULT CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { char *str = getString(); if (_loadStream->err()) { delete[] str; - return E_FAIL; + return STATUS_FAILED; } if (str) val.push_back(str); delete[] str; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // BYTE -HRESULT CBPersistMgr::transfer(const char *name, byte *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { *val = _loadStream->readByte(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // RECT -HRESULT CBPersistMgr::transfer(const char *name, RECT *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, RECT *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); _saveStream->writeSint32LE(val->right); _saveStream->writeSint32LE(val->bottom); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { val->left = _loadStream->readSint32LE(); val->top = _loadStream->readSint32LE(); val->right = _loadStream->readSint32LE(); val->bottom = _loadStream->readSint32LE(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // POINT -HRESULT CBPersistMgr::transfer(const char *name, POINT *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, POINT *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { val->x = _loadStream->readSint32LE(); val->y = _loadStream->readSint32LE(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // Vector2 -HRESULT CBPersistMgr::transfer(const char *name, Vector2 *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); if (_saveStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } else { val->x = getFloat(); val->y = getFloat(); if (_loadStream->err()) - return E_FAIL; - return S_OK; + return STATUS_FAILED; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// // generic pointer -HRESULT CBPersistMgr::transfer(const char *name, void *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, void *val) { int classID = -1, instanceID = -1; if (_saving) { @@ -750,7 +750,7 @@ HRESULT CBPersistMgr::transfer(const char *name, void *val) { *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index f2f428fb25..9559dc7490 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -51,7 +51,7 @@ public: byte _savedExtMajor; byte _savedExtMinor; Common::String _savedName; - HRESULT saveFile(const char *filename); + ERRORCODE saveFile(const char *filename); uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); @@ -66,10 +66,10 @@ public: void deleteSaveSlot(int slot); uint32 getMaxUsedSlot(); bool getSaveExists(int slot); - HRESULT initLoad(const char *filename); - HRESULT initSave(const char *desc); - HRESULT getBytes(byte *buffer, uint32 size); - HRESULT putBytes(byte *buffer, uint32 size); + ERRORCODE initLoad(const char *filename); + ERRORCODE initSave(const char *desc); + ERRORCODE getBytes(byte *buffer, uint32 size); + ERRORCODE putBytes(byte *buffer, uint32 size); uint32 _offset; bool _saving; @@ -77,20 +77,20 @@ public: uint32 _richBufferSize; byte *_richBuffer; - HRESULT transfer(const char *name, void *val); - HRESULT transfer(const char *name, int *val); - HRESULT transfer(const char *name, uint32 *val); - HRESULT transfer(const char *name, float *val); - HRESULT transfer(const char *name, double *val); - HRESULT transfer(const char *name, bool *val); - HRESULT transfer(const char *name, byte *val); - HRESULT transfer(const char *name, RECT *val); - HRESULT transfer(const char *name, POINT *val); - HRESULT transfer(const char *name, const char **val); - HRESULT transfer(const char *name, char **val); - HRESULT transfer(const char *name, Common::String *val); - HRESULT transfer(const char *name, Vector2 *val); - HRESULT transfer(const char *name, AnsiStringArray &Val); + ERRORCODE transfer(const char *name, void *val); + ERRORCODE transfer(const char *name, int *val); + ERRORCODE transfer(const char *name, uint32 *val); + ERRORCODE transfer(const char *name, float *val); + ERRORCODE transfer(const char *name, double *val); + ERRORCODE transfer(const char *name, bool *val); + ERRORCODE transfer(const char *name, byte *val); + ERRORCODE transfer(const char *name, RECT *val); + ERRORCODE transfer(const char *name, POINT *val); + ERRORCODE transfer(const char *name, const char **val); + ERRORCODE transfer(const char *name, char **val); + ERRORCODE transfer(const char *name, Common::String *val); + ERRORCODE transfer(const char *name, Vector2 *val); + ERRORCODE transfer(const char *name, AnsiStringArray &Val); CBPersistMgr(CBGame *inGame = NULL); virtual ~CBPersistMgr(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); @@ -99,9 +99,9 @@ public: byte *_thumbnailData; private: Common::String getFilenameForSlot(int slot); - HRESULT readHeader(const Common::String &filename); + ERRORCODE readHeader(const Common::String &filename); TimeDate getTimeDate(); - HRESULT putTimeDate(const TimeDate &t); + ERRORCODE putTimeDate(const TimeDate &t); Common::WriteStream *_saveStream; Common::SeekableReadStream *_loadStream; }; diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp index 92cfccd87a..b6b8c4e572 100644 --- a/engines/wintermute/Base/BPoint.cpp +++ b/engines/wintermute/Base/BPoint.cpp @@ -53,12 +53,12 @@ CBPoint::CBPoint(int initX, int initY) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBPoint::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBPoint::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(x)); persistMgr->transfer(TMEMBER(y)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 1b89988ba8..32eb383de0 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -71,7 +71,7 @@ void CBRegion::cleanup() { ////////////////////////////////////////////////////////////////////////// bool CBRegion::createRegion() { - return SUCCEEDED(getBoundingRect(&_rect)); + return DID_SUCCEED(getBoundingRect(&_rect)); } @@ -95,19 +95,19 @@ bool CBRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::loadFile(const char *filename) { +ERRORCODE CBRegion::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); delete [] buffer; @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -148,7 +148,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { Game->LOG(0, "'REGION' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -161,7 +161,7 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -198,19 +198,19 @@ HRESULT CBRegion::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in REGION definition"); - return E_FAIL; + return STATUS_FAILED; } createRegion(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -225,7 +225,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -244,7 +244,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -264,7 +264,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -284,7 +284,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -302,7 +302,7 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -350,13 +350,13 @@ CScValue *CBRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -364,7 +364,7 @@ HRESULT CBRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Active") == 0) { _active = value->getBool(); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -378,7 +378,7 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { +ERRORCODE CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); @@ -401,12 +401,12 @@ HRESULT CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOv buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBRegion::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -417,7 +417,7 @@ HRESULT CBRegion::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_lastMimicY)); _points.persist(persistMgr); - return S_OK; + return STATUS_OK; } @@ -465,7 +465,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::getBoundingRect(RECT *rect) { +ERRORCODE CBRegion::getBoundingRect(RECT *rect) { if (_points.GetSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -479,13 +479,13 @@ HRESULT CBRegion::getBoundingRect(RECT *rect) { } CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRegion::mimic(CBRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return S_OK; +ERRORCODE CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; cleanup(); @@ -502,7 +502,7 @@ HRESULT CBRegion::mimic(CBRegion *region, float scale, int x, int y) { _lastMimicX = x; _lastMimicY = y; - return createRegion() ? S_OK : E_FAIL; + return createRegion() ? STATUS_OK : STATUS_FAILED; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 0b005eb1de..5f6b79e17f 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -40,8 +40,8 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - HRESULT mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - HRESULT getBoundingRect(RECT *rect); + ERRORCODE mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + ERRORCODE getBoundingRect(RECT *rect); bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; @@ -50,16 +50,16 @@ public: virtual ~CBRegion(); bool pointInRegion(int x, int y); bool createRegion(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); RECT _rect; CBArray _points; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index b6de4e2bf5..e2ddc38d98 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -111,8 +111,8 @@ CBRenderSDL::~CBRenderSDL() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return E_FAIL; +ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; #if 0 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); @@ -194,7 +194,7 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { if (gfxError != OSystem::kTransactionSuccess) { warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return E_FAIL; + return STATUS_FAILED; } #if 0 _win = SDL_CreateWindow("WME Lite", @@ -203,7 +203,7 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { _realWidth, _realHeight, flags); - if (!_win) return E_FAIL; + if (!_win) return STATUS_FAILED; #endif g_system->showMouse(false); @@ -217,30 +217,30 @@ HRESULT CBRenderSDL::initRenderer(int width, int height, bool windowed) { #if 0 _renderer = SDL_CreateRenderer(_win, -1, 0); - if (!_renderer) return E_FAIL; + if (!_renderer) return STATUS_FAILED; #endif _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); - return S_OK; + return STATUS_OK; } void CBRenderSDL::setAlphaMod(byte alpha) { - byte r = D3DCOLGetR(_colorMod); - byte g = D3DCOLGetB(_colorMod); - byte b = D3DCOLGetB(_colorMod); + byte r = RGBCOLGetR(_colorMod); + byte g = RGBCOLGetB(_colorMod); + byte b = RGBCOLGetB(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } void CBRenderSDL::setColorMod(byte r, byte g, byte b) { - byte alpha = D3DCOLGetA(_colorMod); + byte alpha = RGBCOLGetA(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::flip() { +ERRORCODE CBRenderSDL::flip() { if (!_disableDirtyRects) { drawTickets(); } @@ -254,33 +254,33 @@ HRESULT CBRenderSDL::flip() { } _drawNum = 1; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { +ERRORCODE CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); if (!_disableDirtyRects) - return S_OK; + return STATUS_OK; if (!rect) { rect = &_renderRect; } _renderSurface->fillRect(*rect, _clearColor); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::fade(uint16 Alpha) { +ERRORCODE CBRenderSDL::fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; return fadeToColor(dwAlpha << 24); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { +ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -307,10 +307,10 @@ HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { } modTargetRect(&fillRect); - byte r = D3DCOLGetR(Color); - byte g = D3DCOLGetG(Color); - byte b = D3DCOLGetB(Color); - byte a = D3DCOLGetA(Color); + byte r = RGBCOLGetR(Color); + byte g = RGBCOLGetG(Color); + byte b = RGBCOLGetB(Color); + byte a = RGBCOLGetA(Color); //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); @@ -320,7 +320,7 @@ HRESULT CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); - return S_OK; + return STATUS_OK; } void CBRenderSDL::drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { @@ -487,16 +487,16 @@ void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *s } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { warning("CBRenderSDL::DrawLine - not fully ported yet"); hasWarned = true; } - byte r = D3DCOLGetR(color); - byte g = D3DCOLGetG(color); - byte b = D3DCOLGetB(color); - byte a = D3DCOLGetA(color); + byte r = RGBCOLGetR(color); + byte g = RGBCOLGetG(color); + byte b = RGBCOLGetB(color); + byte a = RGBCOLGetA(color); //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); @@ -514,7 +514,7 @@ HRESULT CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -550,7 +550,7 @@ CBImage *CBRenderSDL::takeScreenshot() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::switchFullscreen() { +ERRORCODE CBRenderSDL::switchFullscreen() { /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); else SDL_SetWindowFullscreen(_win, SDL_FALSE); @@ -558,7 +558,7 @@ HRESULT CBRenderSDL::switchFullscreen() { */ Game->_registry->writeBool("Video", "Windowed", _windowed); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -576,7 +576,7 @@ const char *CBRenderSDL::getName() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderSDL::setViewport(int left, int top, int right, int bottom) { +ERRORCODE CBRenderSDL::setViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. rect.left = (int16)(left + _borderLeft); @@ -588,7 +588,7 @@ HRESULT CBRenderSDL::setViewport(int left, int top, int right, int bottom) { #ifndef __IPHONEOS__ //SDL_RenderSetViewport(GetSdlRenderer(), &rect); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 67999fe867..f7659e3e84 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -64,16 +64,16 @@ public: const char *getName(); - HRESULT initRenderer(int width, int height, bool windowed); - HRESULT flip(); - HRESULT fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + ERRORCODE initRenderer(int width, int height, bool windowed); + ERRORCODE flip(); + ERRORCODE fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - HRESULT fade(uint16 alpha); - HRESULT fadeToColor(uint32 color, Common::Rect *rect = NULL); + ERRORCODE fade(uint16 alpha); + ERRORCODE fadeToColor(uint32 color, Common::Rect *rect = NULL); - HRESULT switchFullscreen(); + ERRORCODE switchFullscreen(); - HRESULT drawLine(int x1, int y1, int x2, int y2, uint32 color); + ERRORCODE drawLine(int x1, int y1, int x2, int y2, uint32 color); CBImage *takeScreenshot(); @@ -83,7 +83,7 @@ public: void invalidateTicketsFromSurface(CBSurfaceSDL *surf); void drawFromTicket(RenderTicket *renderTicket); - HRESULT setViewport(int left, int top, int right, int bottom); + ERRORCODE setViewport(int left, int top, int right, int bottom); void modTargetRect(Common::Rect *rect); void pointFromScreen(POINT *point); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 26e7f3de5a..9038d8364e 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -115,19 +115,19 @@ void CBRenderer::deleteRectList() { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::switchFullscreen() { - return E_FAIL; +ERRORCODE CBRenderer::switchFullscreen() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::flip() { - return E_FAIL; +ERRORCODE CBRenderer::flip() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::initRenderer(int width, int height, bool windowed) { - return E_FAIL; +ERRORCODE CBRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; } @@ -137,36 +137,36 @@ void CBRenderer::onWindowChange() { ////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { - return E_FAIL; +ERRORCODE CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::windowedBlt() { - return E_FAIL; +ERRORCODE CBRenderer::windowedBlt() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setup2D(bool Force) { - return E_FAIL; +ERRORCODE CBRenderer::setup2D(bool Force) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setupLines() { - return E_FAIL; +ERRORCODE CBRenderer::setupLines() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - return E_FAIL; +ERRORCODE CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { +ERRORCODE CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { for (int i = 0; i < width; i++) { drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down @@ -174,36 +174,36 @@ HRESULT CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int w drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::fade(uint16 alpha) { - return E_FAIL; +ERRORCODE CBRenderer::fade(uint16 alpha) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { - return E_FAIL; +ERRORCODE CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setViewport(int left, int top, int right, int bottom) { - return E_FAIL; +ERRORCODE CBRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setScreenViewport() { +ERRORCODE CBRenderer::setScreenViewport() { return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::setViewport(RECT *rect) { +ERRORCODE CBRenderer::setViewport(RECT *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -218,7 +218,7 @@ CBImage *CBRenderer::takeScreenshot() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::clipCursor() { +ERRORCODE CBRenderer::clipCursor() { /* if (!_windowed) { RECT rc; @@ -233,15 +233,15 @@ HRESULT CBRenderer::clipCursor() { ::ClipCursor(&rc); } */ - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBRenderer::unclipCursor() { +ERRORCODE CBRenderer::unclipCursor() { /* if (!_windowed) ::ClipCursor(NULL); */ - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index e8067bee7e..5d290eedd6 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -49,37 +49,37 @@ public: virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); - virtual HRESULT setViewport(int left, int top, int right, int bottom); - virtual HRESULT setViewport(RECT *Rect); - virtual HRESULT setScreenViewport(); - virtual HRESULT fade(uint16 Alpha); - virtual HRESULT fadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual HRESULT drawLine(int x1, int y1, int x2, int y2, uint32 color); - virtual HRESULT drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + virtual ERRORCODE setViewport(int left, int top, int right, int bottom); + virtual ERRORCODE setViewport(RECT *Rect); + virtual ERRORCODE setScreenViewport(); + virtual ERRORCODE fade(uint16 Alpha); + virtual ERRORCODE fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual ERRORCODE drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual ERRORCODE drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); CBRenderer(CBGame *inGame = NULL); virtual ~CBRenderer(); - virtual HRESULT setProjection() { - return S_OK; + virtual ERRORCODE setProjection() { + return STATUS_OK; }; - virtual HRESULT windowedBlt(); - virtual HRESULT fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual ERRORCODE windowedBlt(); + virtual ERRORCODE fill(byte r, byte g, byte b, Common::Rect *rect = NULL); virtual void onWindowChange(); - virtual HRESULT initRenderer(int width, int height, bool windowed); - virtual HRESULT flip(); + virtual ERRORCODE initRenderer(int width, int height, bool windowed); + virtual ERRORCODE flip(); virtual void initLoop(); - virtual HRESULT switchFullscreen(); - virtual HRESULT setup2D(bool force = false); - virtual HRESULT setupLines(); + virtual ERRORCODE switchFullscreen(); + virtual ERRORCODE setup2D(bool force = false); + virtual ERRORCODE setupLines(); virtual const char *getName() { return ""; }; - virtual HRESULT displayDebugInfo() { - return E_FAIL; + virtual ERRORCODE displayDebugInfo() { + return STATUS_FAILED; }; - virtual HRESULT drawShaderQuad() { - return E_FAIL; + virtual ERRORCODE drawShaderQuad() { + return STATUS_FAILED; } virtual float getScaleRatioX() const { @@ -89,17 +89,17 @@ public: return 1.0f; } - HRESULT clipCursor(); - HRESULT unclipCursor(); + ERRORCODE clipCursor(); + ERRORCODE unclipCursor(); CBObject *getObjectAt(int x, int y); void deleteRectList(); - virtual HRESULT startSpriteBatch() { - return S_OK; + virtual ERRORCODE startSpriteBatch() { + return STATUS_OK; }; - virtual HRESULT endSpriteBatch() { - return S_OK; + virtual ERRORCODE endSpriteBatch() { + return STATUS_OK; }; bool pointInViewport(POINT *P); uint32 _forceAlphaColor; diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 16485fd9ef..f53ffda52c 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -45,7 +45,7 @@ CBSaveThumbHelper::~CBSaveThumbHelper(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbHelper::storeThumbnail(bool doFlip) { +ERRORCODE CBSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; @@ -61,7 +61,7 @@ HRESULT CBSaveThumbHelper::storeThumbnail(bool doFlip) { } CBImage *screenshot = Game->_renderer->takeScreenshot(); - if (!screenshot) return E_FAIL; + if (!screenshot) return STATUS_FAILED; // normal thumbnail if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { @@ -73,7 +73,7 @@ HRESULT CBSaveThumbHelper::storeThumbnail(bool doFlip) { delete screenshot; screenshot = NULL; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbHelper.h b/engines/wintermute/Base/BSaveThumbHelper.h index f3a2f914ef..27163af30f 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.h +++ b/engines/wintermute/Base/BSaveThumbHelper.h @@ -39,7 +39,7 @@ class CBSaveThumbHelper : public CBBase { public: CBSaveThumbHelper(CBGame *inGame); virtual ~CBSaveThumbHelper(void); - HRESULT storeThumbnail(bool doFlip = false); + ERRORCODE storeThumbnail(bool doFlip = false); CBImage *_thumbnail; CBImage *_richThumbnail; diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 2049287be5..160ba7e2cd 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -55,7 +55,7 @@ CBScriptHolder::~CBScriptHolder() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::cleanup() { +ERRORCODE CBScriptHolder::cleanup() { delete[] _filename; _filename = NULL; @@ -67,7 +67,7 @@ HRESULT CBScriptHolder::cleanup() { } _scripts.RemoveAll(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// @@ -80,17 +80,17 @@ void CBScriptHolder::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { +ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; - HRESULT ret = E_FAIL; + ERRORCODE ret = STATUS_FAILED; for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread) { CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { //_scripts.Add(handler); numHandlers++; - ret = S_OK; + ret = STATUS_OK; } } } @@ -101,15 +101,15 @@ HRESULT CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { - return E_FAIL; +ERRORCODE CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac *p = 10; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -128,13 +128,13 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac else if (strcmp(name, "ApplyEvent") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - HRESULT ret; + ERRORCODE ret; ret = applyEvent(val->getString()); - if (SUCCEEDED(ret)) stack->pushBool(true); + if (DID_SUCCEED(ret)) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -144,7 +144,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac stack->correctParams(1); stack->pushBool(canHandleEvent(stack->pop()->getString())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -154,7 +154,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac stack->correctParams(1); stack->pushBool(canHandleMethod(stack->pop()->getString())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -162,9 +162,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AttachScript") == 0) { stack->correctParams(1); - stack->pushBool(SUCCEEDED(addScript(stack->pop()->getString()))); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -184,7 +184,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac } stack->pushBool(ret); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -202,7 +202,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac } stack->pushBool(ret); - return S_OK; + return STATUS_OK; } else return CBScriptable::scCallMethod(script, stack, thisStack, name); } @@ -240,13 +240,13 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBScriptHolder::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } else return CBScriptable::scSetProperty(name, value); } @@ -257,13 +257,13 @@ const char *CBScriptHolder::scToString() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { return CBBase::saveAsText(buffer, indent); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBScriptHolder::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); @@ -271,17 +271,17 @@ HRESULT CBScriptHolder::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_name)); _scripts.persist(persistMgr); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::addScript(const char *filename) { +ERRORCODE CBScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.GetSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); - return S_OK; + return STATUS_OK; } } } @@ -299,26 +299,26 @@ HRESULT CBScriptHolder::addScript(const char *filename) { Game->_scEngine->_scripts.Add(scr); Game->getDebugMgr()->onScriptInit(scr); - return S_OK; + return STATUS_OK; } - return E_FAIL; + return STATUS_FAILED; } else { scr->_freezable = _freezable; _scripts.Add(scr); - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::removeScript(CScScript *script) { +ERRORCODE CBScriptHolder::removeScript(CScScript *script) { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i] == script) { _scripts.RemoveAt(i); break; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { +ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -359,7 +359,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { Game->LOG(0, "'PROPERTY' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -391,7 +391,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; Game->LOG(0, "Syntax error in PROPERTY definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { delete[] propName; @@ -399,7 +399,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; Game->LOG(0, "Error loading PROPERTY definition"); - return E_FAIL; + return STATUS_FAILED; } @@ -413,7 +413,7 @@ HRESULT CBScriptHolder::parseProperty(byte *buffer, bool complete) { propName = NULL; propValue = NULL; - return S_OK; + return STATUS_OK; } @@ -433,8 +433,8 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { CScScript *thread = new CScScript(Game, _scripts[i]->_engine); if (thread) { - HRESULT ret = thread->createMethodThread(_scripts[i], methodName); - if (SUCCEEDED(ret)) { + ERRORCODE ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { _scripts[i]->_engine->_scripts.Add(thread); Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); @@ -467,7 +467,7 @@ void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { // IWmeObject ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::sendEvent(const char *eventName) { - return SUCCEEDED(applyEvent(eventName)); + return DID_SUCCEED(applyEvent(eventName)); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index f417cc7e51..dabaf52dd3 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -45,14 +45,14 @@ public: virtual void makeFreezable(bool freezable); bool canHandleEvent(const char *eventName); virtual bool canHandleMethod(const char *eventMethod); - HRESULT cleanup(); - HRESULT removeScript(CScScript *script); - HRESULT addScript(const char *filename); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); - HRESULT applyEvent(const char *eventName, bool unbreakable = false); + ERRORCODE cleanup(); + ERRORCODE removeScript(CScScript *script); + ERRORCODE addScript(const char *filename); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); + ERRORCODE applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); - HRESULT parseProperty(byte *buffer, bool complete = true); + ERRORCODE parseProperty(byte *buffer, bool complete = true); char *_filename; bool _freezable; bool _ready; @@ -60,8 +60,8 @@ public: CBArray _scripts; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 0e0ca7d45b..8e93a8914e 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -61,15 +61,15 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* stack->correctParams(0); stack->pushNULL(); script->runtimeError("Call to undefined method '%s'.", name); - return S_OK; + return STATUS_OK; */ - return E_FAIL; + return STATUS_FAILED; } @@ -82,10 +82,10 @@ CScValue *CBScriptable::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBScriptable::scSetProperty(const char *name, CScValue *value) { if (!_scProp) _scProp = new CScValue(Game); if (_scProp) return _scProp->setProp(name, value); - else return E_FAIL; + else return STATUS_FAILED; } @@ -139,13 +139,13 @@ void CBScriptable::scSetBool(bool val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBScriptable::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBScriptable::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); persistMgr->transfer(TMEMBER(_scValue)); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index d0c91800f1..a65e3d20b6 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -50,9 +50,9 @@ public: // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); - virtual HRESULT scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); virtual int scToInt(); diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index c3ed1a8e26..b4536e7f9e 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -65,7 +65,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setSound(const char *filename, TSoundType type, bool streamed) { +ERRORCODE CBSound::setSound(const char *filename, TSoundType type, bool streamed) { if (_sound) { Game->_soundMgr->removeSound(_sound); _sound = NULL; @@ -81,13 +81,13 @@ HRESULT CBSound::setSound(const char *filename, TSoundType type, bool streamed) _soundType = type; _soundStreamed = streamed; - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setSoundSimple() { +ERRORCODE CBSound::setSoundSimple() { _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->setPosition(_soundPosition); @@ -96,8 +96,8 @@ HRESULT CBSound::setSoundSimple() { _sound->setLoopStart(_soundLoopStart); _sound->_freezePaused = _soundFreezePaused; if (_soundPlaying) return _sound->resume(); - else return S_OK; - } else return E_FAIL; + else return STATUS_OK; + } else return STATUS_FAILED; } @@ -110,44 +110,44 @@ uint32 CBSound::getLength() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::play(bool looping) { +ERRORCODE CBSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); - } else return E_FAIL; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::stop() { +ERRORCODE CBSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); - } else return E_FAIL; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::pause(bool freezePaused) { +ERRORCODE CBSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; if (freezePaused) _sound->_freezePaused = true; return _sound->pause(); - } else return E_FAIL; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::resume() { +ERRORCODE CBSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); - } else return E_FAIL; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBSound::persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; @@ -176,7 +176,7 @@ HRESULT CBSound::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER_INT(_soundType)); persistMgr->transfer(TMEMBER(_soundLoopStart)); - return S_OK; + return STATUS_OK; } @@ -193,10 +193,10 @@ bool CBSound::isPaused() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setPositionTime(uint32 time) { - if (!_sound) return E_FAIL; +ERRORCODE CBSound::setPositionTime(uint32 time) { + if (!_sound) return STATUS_FAILED; _soundPosition = time; - HRESULT ret = _sound->setPosition(_soundPosition); + ERRORCODE ret = _sound->setPosition(_soundPosition); if (_sound->isPlaying()) _soundPosition = 0; return ret; @@ -214,16 +214,16 @@ uint32 CBSound::getPositionTime() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setVolume(int volume) { +ERRORCODE CBSound::setVolume(int volume) { if (!_sound) - return E_FAIL; + return STATUS_FAILED; else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setPrivateVolume(int volume) { +ERRORCODE CBSound::setPrivateVolume(int volume) { if (!_sound) - return E_FAIL; + return STATUS_FAILED; else return _sound->_privateVolume = volume; } @@ -236,30 +236,30 @@ int CBSound::getVolume() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setLoopStart(uint32 pos) { +ERRORCODE CBSound::setLoopStart(uint32 pos) { if (!_sound) - return E_FAIL; + return STATUS_FAILED; else { _sound->setLoopStart(pos); - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::setPan(float pan) { +ERRORCODE CBSound::setPan(float pan) { if (_sound) return _sound->setPan(pan); - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { +ERRORCODE CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) - return S_OK; + return STATUS_OK; if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - HRESULT ret = _sound->applyFX(type, param1, param2, param3, param4); + ERRORCODE ret = _sound->applyFX(type, param1, param2, param3, param4); _sFXType = type; _sFXParam1 = param1; @@ -269,7 +269,7 @@ HRESULT CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3 return ret; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h index 4bc3f25c19..dd08e32b54 100644 --- a/engines/wintermute/Base/BSound.h +++ b/engines/wintermute/Base/BSound.h @@ -38,14 +38,14 @@ namespace WinterMute { class CBSound : public CBBase { public: - HRESULT setPan(float pan); + ERRORCODE setPan(float pan); int _soundPrivateVolume; int getVolume(); - HRESULT setVolume(int volume); - HRESULT setPrivateVolume(int volume); - HRESULT setLoopStart(uint32 pos); + ERRORCODE setVolume(int volume); + ERRORCODE setPrivateVolume(int volume); + ERRORCODE setLoopStart(uint32 pos); uint32 getPositionTime(); - HRESULT setPositionTime(uint32 time); + ERRORCODE setPositionTime(uint32 time); bool _soundPaused; bool _soundFreezePaused; bool isPlaying(); @@ -55,20 +55,20 @@ public: uint32 _soundLoopStart; uint32 _soundPosition; DECLARE_PERSISTENT(CBSound, CBBase) - HRESULT resume(); - HRESULT pause(bool freezePaused = false); - HRESULT stop(); - HRESULT play(bool looping = false); + ERRORCODE resume(); + ERRORCODE pause(bool freezePaused = false); + ERRORCODE stop(); + ERRORCODE play(bool looping = false); uint32 getLength(); bool _soundStreamed; TSoundType _soundType; char *_soundFilename; - HRESULT setSoundSimple(); - HRESULT setSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); + ERRORCODE setSoundSimple(); + ERRORCODE setSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); CBSound(CBGame *inGame); virtual ~CBSound(); - HRESULT ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + ERRORCODE ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); private: TSFXType _sFXType; diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 40793efc98..1bdb0f3adc 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -93,7 +93,7 @@ void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSi ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { +ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); #if 0 if (_stream) { @@ -108,7 +108,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _file = Game->_fileManager->openFile(filename, true, false); if (!_file) { Game->LOG(0, "Error opening sound file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } Common::String strFilename(filename); if (strFilename.hasSuffix(".ogg")) { @@ -120,11 +120,11 @@ HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); } if (!_stream) { - return E_FAIL; + return STATUS_FAILED; } CBUtils::setString(&_filename, filename); - return S_OK; + return STATUS_OK; #if 0 BASS_FILEPROCS fileProc; fileProc.close = CBSoundBuffer::FileCloseProc; @@ -135,20 +135,20 @@ HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); if (!_stream) { Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return E_FAIL; + return STATUS_FAILED; } CBUtils::setString(&_filename, filename); /* - HRESULT res; + ERRORCODE res; bool NewlyCreated = false; if(!_soundBuffer || ForceReload || _streamed){ if(!_file) _file = Game->_fileManager->openFile(filename); if(!_file){ Game->LOG(0, "Error opening sound file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } // switch to streamed for big files if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true); @@ -159,7 +159,7 @@ HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { NewlyCreated = true; res = InitializeBuffer(_file); - if(FAILED(res)){ + if(DID_FAIL(res)){ Game->LOG(res, "Error creating sound buffer for file '%s'", filename); return res; } @@ -180,13 +180,13 @@ HRESULT CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { } */ - return S_OK; + return STATUS_OK; #endif } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::play(bool looping, uint32 startSample) { +ERRORCODE CBSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } @@ -198,7 +198,7 @@ HRESULT CBSoundBuffer::play(bool looping, uint32 startSample) { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -214,29 +214,29 @@ void CBSoundBuffer::setLooping(bool looping) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::resume() { +ERRORCODE CBSoundBuffer::resume() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::stop() { +ERRORCODE CBSoundBuffer::stop() { if (_stream && _handle) { g_system->getMixer()->stopHandle(*_handle); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::pause() { +ERRORCODE CBSoundBuffer::pause() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, true); } - return S_OK; + return STATUS_OK; } @@ -257,17 +257,17 @@ void CBSoundBuffer::setType(TSoundType type) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setVolume(int volume) { +ERRORCODE CBSoundBuffer::setVolume(int volume) { if (_stream && _handle) { byte vol = (byte)(volume / 100.f * Audio::Mixer::kMaxChannelVolume); g_system->getMixer()->setChannelVolume(*_handle, vol); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setPrivateVolume(int volume) { +ERRORCODE CBSoundBuffer::setPrivateVolume(int volume) { #if 0 _privateVolume = Volume; @@ -308,7 +308,7 @@ uint32 CBSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setPosition(uint32 pos) { +ERRORCODE CBSoundBuffer::setPosition(uint32 pos) { warning("CBSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { @@ -316,11 +316,11 @@ HRESULT CBSoundBuffer::setPosition(uint32 pos) { BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); } #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setLoopStart(uint32 pos) { +ERRORCODE CBSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; #if 0 if (_stream) { @@ -334,7 +334,7 @@ HRESULT CBSoundBuffer::setLoopStart(uint32 pos) { } } #endif - return S_OK; + return STATUS_OK; } #if 0 ////////////////////////////////////////////////////////////////////////// @@ -347,15 +347,15 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::setPan(float pan) { +ERRORCODE CBSoundBuffer::setPan(float pan) { if (_stream) { g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { +ERRORCODE CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { warning("CBSoundBuffer::ApplyFX - not implemented yet"); #if 0 switch (type) { @@ -369,7 +369,7 @@ HRESULT CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float break; } #endif - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 359c89e59e..22c4fd63da 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -48,32 +48,32 @@ public: virtual ~CBSoundBuffer(); - HRESULT pause(); - HRESULT play(bool looping = false, uint32 startSample = 0); - HRESULT resume(); - HRESULT stop(); + ERRORCODE pause(); + ERRORCODE play(bool looping = false, uint32 startSample = 0); + ERRORCODE resume(); + ERRORCODE stop(); bool isPlaying(); void setLooping(bool looping); uint32 getPosition(); - HRESULT setPosition(uint32 pos); + ERRORCODE setPosition(uint32 pos); uint32 getLength(); - HRESULT setLoopStart(uint32 pos); + ERRORCODE setLoopStart(uint32 pos); uint32 getLoopStart() const { return _loopStart; } - HRESULT setPan(float pan); - HRESULT setPrivateVolume(int colume); - HRESULT setVolume(int colume); + ERRORCODE setPan(float pan); + ERRORCODE setPrivateVolume(int colume); + ERRORCODE setVolume(int colume); void setType(TSoundType Type); - HRESULT loadFromFile(const char *filename, bool forceReload = false); + ERRORCODE loadFromFile(const char *filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - HRESULT applyFX(TSFXType type, float param1, float param2, float param3, float param4); + ERRORCODE applyFX(TSFXType type, float param1, float param2, float param3, float param4); //HSTREAM _stream; //HSYNC _sync; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 1f801aca7a..9e038fd5fc 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -59,14 +59,14 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::cleanup() { +ERRORCODE CBSoundMgr::cleanup() { for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i]; _sounds.RemoveAll(); #if 0 BASS_Free(); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ void CBSoundMgr::saveSettings() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::initialize() { +ERRORCODE CBSoundMgr::initialize() { _soundAvailable = false; #if 0 @@ -93,12 +93,12 @@ HRESULT CBSoundMgr::initialize() { if (HIWORD(BASS_GetVersion()) != BASSVERSION) { Game->LOG(0, "An incorrect version of BASS was loaded"); - return E_FAIL; + return STATUS_FAILED; } if (!BASS_Init(-1, 44100, 0, 0, NULL)) { Game->LOG(0, "Can't initialize sound device"); - return E_FAIL; + return STATUS_FAILED; } #endif @@ -111,19 +111,19 @@ HRESULT CBSoundMgr::initialize() { _soundAvailable = true; setMasterVolumePercent(_volumeMaster); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::initLoop() { +ERRORCODE CBSoundMgr::initLoop() { if (!_soundAvailable) - return S_OK; + return STATUS_OK; #if 0 BASS_Update(500); #endif - return S_OK; + return STATUS_OK; } @@ -153,8 +153,8 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool sound->setType(type); - HRESULT res = sound->loadFromFile(filename); - if (FAILED(res)) { + ERRORCODE res = sound->loadFromFile(filename); + if (DID_FAIL(res)) { Game->LOG(res, "Error loading sound '%s'", filename); delete sound; return NULL; @@ -182,9 +182,9 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { +ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { if (!sound) - return E_FAIL; + return STATUS_FAILED; // set volume appropriately switch (type) { @@ -202,27 +202,27 @@ HRESULT CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { // register sound _sounds.Add(sound); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::removeSound(CBSoundBuffer *sound) { +ERRORCODE CBSoundMgr::removeSound(CBSoundBuffer *sound) { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; _sounds.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolume(TSoundType type, int volume) { +ERRORCODE CBSoundMgr::setVolume(TSoundType type, int volume) { if (!_soundAvailable) - return S_OK; + return STATUS_OK; switch (type) { case SOUND_SFX: @@ -240,11 +240,11 @@ HRESULT CBSoundMgr::setVolume(TSoundType type, int volume) { if (_sounds[i]->_type == type) _sounds[i]->setVolume(volume); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setVolumePercent(TSoundType type, byte percent) { +ERRORCODE CBSoundMgr::setVolumePercent(TSoundType type, byte percent) { return setVolume(type, percent); } @@ -272,12 +272,12 @@ byte CBSoundMgr::getVolumePercent(TSoundType type) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::setMasterVolumePercent(byte percent) { +ERRORCODE CBSoundMgr::setMasterVolumePercent(byte percent) { _volumeMaster = percent; #if 0 BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); #endif - return S_OK; + return STATUS_OK; } @@ -293,7 +293,7 @@ byte CBSoundMgr::getMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::pauseAll(bool includingMusic) { +ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || includingMusic)) { @@ -302,12 +302,12 @@ HRESULT CBSoundMgr::pauseAll(bool includingMusic) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundMgr::resumeAll() { +ERRORCODE CBSoundMgr::resumeAll() { for (int i = 0; i < _sounds.GetSize(); i++) { if (_sounds[i]->_freezePaused) { @@ -316,7 +316,7 @@ HRESULT CBSoundMgr::resumeAll() { } } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index e271508a50..9e8106e973 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -37,25 +37,25 @@ class CBSoundBuffer; class CBSoundMgr : public CBBase { public: float posToPan(int x, int y); - HRESULT resumeAll(); - HRESULT pauseAll(bool includingMusic = true); - HRESULT cleanup(); + ERRORCODE resumeAll(); + ERRORCODE pauseAll(bool includingMusic = true); + ERRORCODE cleanup(); //DECLARE_PERSISTENT(CBSoundMgr, CBBase); byte getMasterVolumePercent(); - HRESULT setMasterVolumePercent(byte percent); + ERRORCODE setMasterVolumePercent(byte percent); byte getVolumePercent(TSoundType type); - HRESULT setVolumePercent(TSoundType type, byte percent); - HRESULT setVolume(TSoundType type, int volume); + ERRORCODE setVolumePercent(TSoundType type, byte percent); + ERRORCODE setVolume(TSoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; int _volumeMusic; int _volumeSpeech; int _volumeSFX; - HRESULT removeSound(CBSoundBuffer *sound); + ERRORCODE removeSound(CBSoundBuffer *sound); CBSoundBuffer *addSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); - HRESULT addSound(CBSoundBuffer *sound, TSoundType type = SOUND_SFX); - HRESULT initLoop(); - HRESULT initialize(); + ERRORCODE addSound(CBSoundBuffer *sound, TSoundType type = SOUND_SFX); + ERRORCODE initLoop(); + ERRORCODE initialize(); bool _soundAvailable; CBSoundMgr(CBGame *inGame); virtual ~CBSoundMgr(); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index e022d75d84..6d595ffbe8 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -102,9 +102,9 @@ void CBSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { +ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return STATUS_OK; // move owner if allowed to if (_changed && _owner && _owner->_movable) { @@ -122,7 +122,7 @@ HRESULT CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = Game->_fileManager->openFile(filename); if (!file) { Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); @@ -133,7 +133,7 @@ HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType file = NULL; } - HRESULT ret; + ERRORCODE ret; AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { @@ -142,7 +142,7 @@ HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { Game->LOG(0, "Error loading simple sprite '%s'", filename); - ret = E_FAIL; + ret = STATUS_FAILED; delete frame; delete subframe; } else { @@ -150,12 +150,12 @@ HRESULT CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType frame->_subframes.Add(subframe); _frames.Add(frame); _currentFrame = 0; - ret = S_OK; + ret = STATUS_OK; } } else { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer) { - if (FAILED(ret = loadBuffer(buffer, true, lifeTime, cacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); delete [] buffer; } } @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -216,7 +216,7 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { Game->LOG(0, "'SPRITE' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -289,10 +289,10 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC frame = new CBFrame(Game); - if (FAILED(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; Game->LOG(0, "Error parsing frame %d", frameCount); - return E_FAIL; + return STATUS_FAILED; } _frames.Add(frame); @@ -309,11 +309,11 @@ HRESULT CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in SPRITE definition"); - return E_FAIL; + return STATUS_FAILED; } _canBreak = !_continuous; - return S_OK; + return STATUS_OK; } @@ -383,8 +383,8 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return S_OK; +ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return STATUS_OK; // on change... if (_changed) { @@ -428,7 +428,7 @@ bool CBSprite::GetBoundingRect(LPRECT rect, int x, int y, float scaleX, float sc } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); @@ -467,12 +467,12 @@ HRESULT CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBSprite::persist(CBPersistMgr *persistMgr) { CBScriptHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_canBreak)); @@ -500,14 +500,14 @@ HRESULT CBSprite::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -518,7 +518,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); } else stack->pushNative(_frames[Index], true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -544,7 +544,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } } stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -554,7 +554,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); reset(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -569,7 +569,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CBFrame *frame = new CBFrame(Game); if (filename != NULL) { CBSubFrame *sub = new CBSubFrame(Game); - if (SUCCEEDED(sub->setSurface(filename))) { + if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.Add(sub); } else delete sub; @@ -577,7 +577,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _frames.Add(frame); stack->pushNative(frame, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -597,7 +597,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CBFrame *frame = new CBFrame(Game); if (filename != NULL) { CBSubFrame *sub = new CBSubFrame(Game); - if (SUCCEEDED(sub->setSurface(filename))) frame->_subframes.Add(sub); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.Add(sub); else delete sub; } @@ -606,7 +606,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else _frames.InsertAt(index, frame); stack->pushNative(frame, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -616,7 +616,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); _paused = true; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -626,7 +626,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); _paused = false; stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); @@ -707,7 +707,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// @@ -717,7 +717,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { _currentFrame = -1; } _lastFrameTime = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -725,7 +725,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { _precise = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -733,7 +733,7 @@ HRESULT CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Looping") == 0) { _looping = value->getBool(); - return S_OK; + return STATUS_OK; } else return CBScriptHolder::scSetProperty(name, value); @@ -747,12 +747,12 @@ const char *CBSprite::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSprite::killAllSounds() { +ERRORCODE CBSprite::killAllSounds() { for (int i = 0; i < _frames.GetSize(); i++) { if (_frames[i]->_sound) _frames[i]->_sound->stop(); } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 4bfa720289..a9ca84d358 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -39,7 +39,7 @@ class CBSurface; class CBObject; class CBSprite: public CBScriptHolder { public: - HRESULT killAllSounds(); + ERRORCODE killAllSounds(); CBSurface *getSurface(); char *_editorBgFile; int _editorBgOffsetX; @@ -56,7 +56,7 @@ public: bool GetBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; - HRESULT display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + ERRORCODE display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; @@ -66,22 +66,22 @@ public: bool _changed; bool _paused; bool _finished; - HRESULT loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - HRESULT loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + ERRORCODE loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + ERRORCODE loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; - HRESULT draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + ERRORCODE draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - HRESULT addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, RECT *rect = NULL); + ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, RECT *rect = NULL); CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; - HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 00e791dc5e..8d8b6b0fd1 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -50,12 +50,12 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return E_FAIL; +ERRORCODE CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { Game->_textRTL = true; - return S_OK; + return STATUS_OK; } Common::String final_key = key; @@ -66,7 +66,7 @@ HRESULT CBStringTable::addString(const char *key, const char *val, bool reportDu _strings[final_key] = val; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -169,7 +169,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { +ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) { Game->LOG(0, "Loading string table..."); if (clearOld) _strings.clear(); @@ -178,7 +178,7 @@ HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { byte *buffer = Game->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } uint32 pos = 0; @@ -223,7 +223,7 @@ HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { Game->LOG(0, " %d strings loaded", _strings.size()); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index 059ff6fec0..94547ffbfc 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -38,9 +38,9 @@ namespace WinterMute { class CBStringTable : public CBBase { public: const char *expandStatic(const char *string, bool forceExpand = false); - HRESULT loadFile(const char *filename, bool deleteAll = true); + ERRORCODE loadFile(const char *filename, bool deleteAll = true); void expand(char **str, bool forceExpand = false); - HRESULT addString(const char *key, const char *val, bool reportDuplicities = true); + ERRORCODE addString(const char *key, const char *val, bool reportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); Common::HashMap _strings; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 36eb2f4063..af7bb128a5 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -178,7 +178,7 @@ HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in SUBFRAME definition"); - return E_FAIL; + return STATUS_FAILED; } if (surfaceFile != NULL) { @@ -186,26 +186,26 @@ HRESULT CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); } - _alpha = DRGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = DRGBA(r, g, b, 0xFF); + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); /* if(_surface == NULL) { Game->LOG(0, "Error parsing sub-frame. Image not set."); - return E_FAIL; + return STATUS_FAILED; } */ if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); else _rect = rect; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return S_OK; +ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) return STATUS_OK; if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { @@ -214,9 +214,9 @@ HRESULT CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, flo Game->_renderer->_rectList.Add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } - if (Game->_suspendedRendering) return S_OK; + if (Game->_suspendedRendering) return STATUS_OK; - HRESULT res; + ERRORCODE res; //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) if (_alpha != 0xFFFFFFFF) alpha = _alpha; @@ -249,7 +249,7 @@ bool CBSubFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { +ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); @@ -257,7 +257,7 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); if (_transparent != 0xFFFF00FF) - buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", D3DCOLGetR(_transparent), D3DCOLGetG(_transparent), D3DCOLGetB(_transparent)); + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); RECT rect; CBPlatform::setRectEmpty(&rect); @@ -269,8 +269,8 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); if (_alpha != 0xFFFFFFFF) { - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(_alpha), D3DCOLGetG(_alpha), D3DCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", D3DCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); } if (_mirrorX) @@ -297,7 +297,7 @@ HRESULT CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { if (complete) buffer->putTextIndent(indent, "}\n\n"); - return S_OK; + return STATUS_OK; } @@ -310,7 +310,7 @@ void CBSubFrame::setDefaultRect() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBSubFrame::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); @@ -335,14 +335,14 @@ HRESULT CBSubFrame::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_mirrorY)); persistMgr->transfer(TMEMBER(_transparent)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -352,7 +352,7 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (!_surfaceFilename) stack->pushNULL(); else stack->pushString(_surfaceFilename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -369,13 +369,13 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->pushBool(true); } else { const char *filename = Val->getString(); - if (SUCCEEDED(setSurface(filename))) { + if (DID_SUCCEED(setSurface(filename))) { setDefaultRect(); stack->pushBool(true); } else stack->pushBool(false); } - return S_OK; + return STATUS_OK; } else return CBScriptable::scCallMethod(script, stack, thisStack, name); @@ -473,13 +473,13 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "AlphaColor") == 0) { _alpha = (uint32)value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -487,7 +487,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is2DOnly") == 0) { _2DOnly = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -495,7 +495,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Is3DOnly") == 0) { _3DOnly = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -503,7 +503,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorX") == 0) { _mirrorX = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -511,7 +511,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MirrorY") == 0) { _mirrorY = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -519,7 +519,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Decoration") == 0) { _decoration = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -527,7 +527,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotX") == 0) { _hotspotX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -535,7 +535,7 @@ HRESULT CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HotspotY") == 0) { _hotspotY = value->getInt(); - return S_OK; + return STATUS_OK; } else return CBScriptable::scSetProperty(name, value); @@ -549,7 +549,7 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +ERRORCODE CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { Game->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -570,20 +570,20 @@ HRESULT CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, _lifeTime = lifeTime; _keepLoaded = keepLoaded; - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSubFrame::setSurfaceSimple() { +ERRORCODE CBSubFrame::setSurfaceSimple() { if (!_surfaceFilename) { _surface = NULL; - return S_OK; + return STATUS_OK; } _surface = Game->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return S_OK; - else return E_FAIL; + if (_surface) return STATUS_OK; + else return STATUS_FAILED; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 575c91fd0f..b1503e3506 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -41,18 +41,18 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - HRESULT setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - HRESULT setSurfaceSimple(); + ERRORCODE setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + ERRORCODE setSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void setDefaultRect(); uint32 _transparent; - HRESULT saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - HRESULT saveAsText(CBDynBuffer *buffer, int indent, bool complete); + ERRORCODE saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, bool complete); bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); - HRESULT loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - HRESULT draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; @@ -75,8 +75,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 8a325a4d7f..0cf5292afb 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -60,14 +60,14 @@ CBSurface::~CBSurface() { ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - return E_FAIL; +ERRORCODE CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::restore() { - return E_FAIL; +ERRORCODE CBSurface::restore() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// @@ -76,41 +76,41 @@ bool CBSurface::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::displayHalfTrans(int x, int y, RECT rect) { - return E_FAIL; +ERRORCODE CBSurface::displayHalfTrans(int x, int y, RECT rect) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::create(int Width, int Height) { - return E_FAIL; +ERRORCODE CBSurface::create(int Width, int Height) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::startPixelOp() { - return E_FAIL; +ERRORCODE CBSurface::startPixelOp() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::endPixelOp() { - return E_FAIL; +ERRORCODE CBSurface::endPixelOp() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { - return E_FAIL; +ERRORCODE CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { - return E_FAIL; +ERRORCODE CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; } @@ -127,20 +127,20 @@ bool CBSurface::isTransparentAtLite(int x, int y) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::invalidate() { - return E_FAIL; +ERRORCODE CBSurface::invalidate() { + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurface::prepareToDraw() { +ERRORCODE CBSurface::prepareToDraw() { _lastUsedTime = Game->_liveTimer; if (!_valid) { //Game->LOG(0, "Reviving: %s", _filename); return create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - } else return S_OK; + } else return STATUS_OK; } diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 9962b095c3..6a4dd89af6 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -36,8 +36,8 @@ namespace WinterMute { class CBSurface: public CBBase { public: - virtual HRESULT invalidate(); - virtual HRESULT prepareToDraw(); + virtual ERRORCODE invalidate(); + virtual ERRORCODE prepareToDraw(); bool _cKDefault; byte _cKRed; byte _cKGreen; @@ -52,25 +52,25 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual HRESULT displayHalfTrans(int x, int y, RECT rect); + virtual ERRORCODE displayHalfTrans(int x, int y, RECT rect); virtual bool isTransparentAt(int x, int y); - virtual HRESULT displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual HRESULT displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual HRESULT displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual HRESULT displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual HRESULT restore(); - virtual HRESULT create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual HRESULT create(int Width, int Height); - virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { - return E_FAIL; + virtual ERRORCODE displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual ERRORCODE display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual ERRORCODE displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE restore(); + virtual ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual ERRORCODE create(int Width, int Height); + virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return STATUS_FAILED; } - virtual HRESULT putPixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual HRESULT getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual ERRORCODE putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual ERRORCODE getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual HRESULT startPixelOp(); - virtual HRESULT endPixelOp(); + virtual ERRORCODE startPixelOp(); + virtual ERRORCODE endPixelOp(); virtual bool isTransparentAtLite(int x, int y); void setFilename(const char *filename); void setSize(int width, int height); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index de61d638a0..27bd7fd334 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -90,7 +90,7 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ Common::String strFileName(filename); CBImage *image = new CBImage(Game); @@ -177,7 +177,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, b if (!_texture) { SDL_FreeSurface(surf); delete imgDecoder; - return E_FAIL; + return STATUS_FAILED; } GenAlphaMask(surf); @@ -207,7 +207,7 @@ HRESULT CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, b delete image; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -293,7 +293,7 @@ uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::create(int width, int height) { +ERRORCODE CBSurfaceSDL::create(int width, int height) { warning("SurfaceSDL::Create not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); @@ -306,11 +306,11 @@ HRESULT CBSurfaceSDL::create(int width, int height) { _valid = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { +ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(Game->_renderer); @@ -330,7 +330,7 @@ HRESULT CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { #endif _valid = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -407,56 +407,56 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::startPixelOp() { +ERRORCODE CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: CBRenderSDL *renderer = static_cast(Game->_renderer); renderer->invalidateTicketsFromSurface(this); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::endPixelOp() { +ERRORCODE CBSurfaceSDL::endPixelOp() { //SDL_UnlockTexture(_texture); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::display(int x, int y, RECT rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::display(int x, int y, RECT rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayTrans(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayTransOffset(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); if (renderer->_forceAlphaColor != 0) alpha = renderer->_forceAlphaColor; @@ -469,10 +469,10 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zo hasWarned = true; } - byte r = D3DCOLGetR(alpha); - byte g = D3DCOLGetG(alpha); - byte b = D3DCOLGetB(alpha); - byte a = D3DCOLGetA(alpha); + byte r = RGBCOLGetR(alpha); + byte g = RGBCOLGetG(alpha); + byte b = RGBCOLGetB(alpha); + byte a = RGBCOLGetA(alpha); renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); @@ -531,16 +531,16 @@ HRESULT CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zo SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); #endif - return S_OK; + return STATUS_OK; } -HRESULT CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { +ERRORCODE CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _surface->copyFrom(surface); _hasAlpha = hasAlpha; CBRenderSDL *renderer = static_cast(Game->_renderer); renderer->invalidateTicketsFromSurface(this); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 50ce364beb..544473ced5 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -40,25 +40,25 @@ public: CBSurfaceSDL(CBGame *inGame); ~CBSurfaceSDL(); - HRESULT create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); - HRESULT create(int width, int height); + ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + ERRORCODE create(int width, int height); - HRESULT createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + ERRORCODE createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function bool isTransparentAt(int x, int y); bool isTransparentAtLite(int x, int y); - HRESULT startPixelOp(); - HRESULT endPixelOp(); + ERRORCODE startPixelOp(); + ERRORCODE endPixelOp(); - HRESULT displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - HRESULT displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - HRESULT displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - HRESULT display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - HRESULT displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - HRESULT displayTransform(int x, int y, int hotX, int hotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual HRESULT putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + ERRORCODE displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + ERRORCODE display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransform(int x, int y, int hotX, int hotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ @@ -78,7 +78,7 @@ public: private: Graphics::Surface *_surface; - HRESULT drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + ERRORCODE drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index d6009ac9e3..eedfbca178 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -51,19 +51,19 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::cleanup(bool warn) { +ERRORCODE CBSurfaceStorage::cleanup(bool warn) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.RemoveAll(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::initLoop() { +ERRORCODE CBSurfaceStorage::initLoop() { if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { _lastCleanupTime = Game->_liveTimer; sortSurfaces(); @@ -76,12 +76,12 @@ HRESULT CBSurfaceStorage::initLoop() { } } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::removeSurface(CBSurface *surface) { +ERRORCODE CBSurfaceStorage::removeSurface(CBSurface *surface) { for (int i = 0; i < _surfaces.GetSize(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; @@ -92,7 +92,7 @@ HRESULT CBSurfaceStorage::removeSurface(CBSurface *surface) { break; } } - return S_OK; + return STATUS_OK; } @@ -118,7 +118,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by if (!surface) return NULL; - if (FAILED(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { delete surface; return NULL; } else { @@ -130,22 +130,22 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::restoreAll() { - HRESULT ret; +ERRORCODE CBSurfaceStorage::restoreAll() { + ERRORCODE ret; for (int i = 0; i < _surfaces.GetSize(); i++) { ret = _surfaces[i]->restore(); - if (ret != S_OK) { + if (ret != STATUS_OK) { Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); return ret; } } - return S_OK; + return STATUS_OK; } /* ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr) { if(!persistMgr->_saving) cleanup(false); @@ -154,15 +154,15 @@ HRESULT CBSurfaceStorage::persist(CBPersistMgr *persistMgr) //_surfaces.persist(persistMgr); - return S_OK; + return STATUS_OK; } */ ////////////////////////////////////////////////////////////////////////// -HRESULT CBSurfaceStorage::sortSurfaces() { +ERRORCODE CBSurfaceStorage::sortSurfaces() { qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), surfaceSortCB); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index cb000cf38c..d93c82bf19 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -38,15 +38,15 @@ class CBSurface; class CBSurfaceStorage : public CBBase { public: uint32 _lastCleanupTime; - HRESULT initLoop(); - HRESULT sortSurfaces(); + ERRORCODE initLoop(); + ERRORCODE sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); - HRESULT cleanup(bool Warn = false); + ERRORCODE cleanup(bool Warn = false); //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - HRESULT restoreAll(); + ERRORCODE restoreAll(); CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - HRESULT removeSurface(CBSurface *surface); + ERRORCODE removeSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 02d6891528..778ac33a3f 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -58,12 +58,12 @@ bool CBTransitionMgr::isReady() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return S_OK; +ERRORCODE CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) return STATUS_OK; if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { _state = TRANS_MGR_READY; - return S_OK; + return STATUS_OK; } if (nonInteractive) { @@ -77,14 +77,14 @@ HRESULT CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { _state = TRANS_MGR_RUNNING; _started = false; - return S_OK; + return STATUS_OK; } #define FADE_DURATION 200 ////////////////////////////////////////////////////////////////////////// -HRESULT CBTransitionMgr::update() { - if (isReady()) return S_OK; +ERRORCODE CBTransitionMgr::update() { + if (isReady()) return STATUS_OK; if (!_started) { _started = true; @@ -125,7 +125,7 @@ HRESULT CBTransitionMgr::update() { if (_preserveInteractive) Game->_interactive = _origInteractive; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h index 11949cf8a3..5999ac3391 100644 --- a/engines/wintermute/Base/BTransitionMgr.h +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -39,8 +39,8 @@ public: uint32 _lastTime; bool _origInteractive; bool _preserveInteractive; - HRESULT update(); - HRESULT start(TTransitionType type, bool nonInteractive = false); + ERRORCODE update(); + ERRORCODE start(TTransitionType type, bool nonInteractive = false); bool isReady(); TTransMgrState _state; CBTransitionMgr(CBGame *inGame); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index 64e138cb33..7542e6bbfc 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -49,7 +49,7 @@ CBViewport::~CBViewport() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBViewport::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); @@ -58,12 +58,12 @@ HRESULT CBViewport::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_rect)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { +ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); @@ -74,7 +74,7 @@ HRESULT CBViewport::setRect(int left, int top, int right, int bottom, bool noChe CBPlatform::setRect(&_rect, left, top, right, bottom); _offsetX = left; _offsetY = top; - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 0360cb9957..f2e960943a 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -39,7 +39,7 @@ public: int getHeight(); int getWidth(); RECT *getRect(); - HRESULT setRect(int left, int top, int right, int bottom, bool noCheck = false); + ERRORCODE setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; int _offsetX; diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index b5e12ca6d2..a07b5a90c7 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -116,44 +116,44 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::addSprite(const char *filename) { - if (!filename) return E_FAIL; +ERRORCODE CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; // do we already have the file? for (int i = 0; i < _sprites.GetSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return S_OK; + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; } // check if file exists Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); if (!File) { Game->LOG(0, "Sprite '%s' not found", filename); - return E_FAIL; + return STATUS_FAILED; } else Game->_fileManager->closeFile(File); char *Str = new char[strlen(filename) + 1]; strcpy(Str, filename); _sprites.Add(Str); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::removeSprite(const char *filename) { +ERRORCODE CPartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.GetSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; _sprites.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return E_FAIL; - if (_sprites.GetSize() == 0) return E_FAIL; +ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.GetSize() == 0) return STATUS_FAILED; int posX = CBUtils::randomInt(_posX, _posX + _width); int posY = CBUtils::randomInt(_posY, _posY + _height); @@ -217,22 +217,22 @@ HRESULT CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, particle->_angVelocity = angVelocity; particle->_growthRate = growthRate; particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = FAILED(particle->setSprite(_sprites[spriteIndex])); + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); particle->fadeIn(currentTime, _fadeInTime); - if (particle->_isDead) return E_FAIL; - else return S_OK; + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::update() { - if (!_running) return S_OK; +ERRORCODE CPartEmitter::update() { + if (!_running) return STATUS_OK; else return updateInternal(Game->_timer, Game->_timerDelta); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { +ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; for (int i = 0; i < _particles.GetSize(); i++) { @@ -250,7 +250,7 @@ HRESULT CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { _batchesGenerated++; if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return S_OK; + return STATUS_OK; } int toGen = MIN(_genAmount, _maxParticles - numLive); @@ -284,11 +284,11 @@ HRESULT CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::display(CBRegion *region) { +ERRORCODE CPartEmitter::display(CBRegion *region) { if (_sprites.GetSize() <= 1) Game->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.GetSize(); i++) { @@ -301,11 +301,11 @@ HRESULT CPartEmitter::display(CBRegion *region) { if (_sprites.GetSize() <= 1) Game->_renderer->endSpriteBatch(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::start() { +ERRORCODE CPartEmitter::start() { for (int i = 0; i < _particles.GetSize(); i++) { _particles[i]->_isDead = true; } @@ -325,14 +325,14 @@ HRESULT CPartEmitter::start() { _overheadTime = 0; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::sortParticlesByZ() { +ERRORCODE CPartEmitter::sortParticlesByZ() { // sort particles by _posY qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -346,20 +346,20 @@ int CPartEmitter::compareZ(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::setBorder(int x, int y, int width, int height) { +ERRORCODE CPartEmitter::setBorder(int x, int y, int width, int height) { CBPlatform::setRect(&_border, x, y, x + width, y + height); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { +ERRORCODE CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { _borderThicknessLeft = thicknessLeft; _borderThicknessRight = thicknessRight; _borderThicknessTop = thicknessTop; _borderThicknessBottom = thicknessBottom; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -384,9 +384,9 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { +ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { CPartForce *force = addForceByName(name); - if (!force) return E_FAIL; + if (!force) return STATUS_FAILED; force->_type = type; force->_pos = Vector2(posX, posY); @@ -396,26 +396,26 @@ HRESULT CPartEmitter::addForce(const char *name, CPartForce::TForceType type, in matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); matRot.transformVector2(force->_direction); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::removeForce(const char *name) { +ERRORCODE CPartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.GetSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; _forces.RemoveAt(i); - return S_OK; + return STATUS_OK; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -426,9 +426,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack int borderWidth = stack->pop()->getInt(); int borderHeight = stack->pop()->getInt(); - stack->pushBool(SUCCEEDED(setBorder(borderX, borderY, borderWidth, borderHeight))); + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetBorderThickness @@ -440,9 +440,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack int top = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - stack->pushBool(SUCCEEDED(setBorderThickness(left, right, top, bottom))); + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AddSprite @@ -450,9 +450,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "AddSprite") == 0) { stack->correctParams(1); const char *spriteFile = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(addSprite(spriteFile))); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // RemoveSprite @@ -460,9 +460,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "RemoveSprite") == 0) { stack->correctParams(1); const char *spriteFile = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(removeSprite(spriteFile))); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -471,9 +471,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack else if (strcmp(name, "Start") == 0) { stack->correctParams(1); _overheadTime = stack->pop()->getInt(); - stack->pushBool(SUCCEEDED(start())); + stack->pushBool(DID_SUCCEED(start())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack _running = false; stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -501,7 +501,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack _running = false; stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -512,7 +512,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack _running = true; stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -524,9 +524,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -540,9 +540,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -552,9 +552,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->correctParams(1); const char *forceName = stack->pop()->getString(); - stack->pushBool(SUCCEEDED(removeForce(forceName))); + stack->pushBool(DID_SUCCEED(removeForce(forceName))); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -833,34 +833,34 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "X") == 0) { _posX = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Y") == 0) { _posY = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { _width = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { _height = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -868,21 +868,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale1") == 0) { _scale1 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale2") == 0) { _scale2 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleZBased") == 0) { _scaleZBased = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -890,21 +890,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity1") == 0) { _velocity1 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Velocity2") == 0) { _velocity2 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VelocityZBased") == 0) { _velocityZBased = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -912,21 +912,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime1") == 0) { _lifeTime1 = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTime2") == 0) { _lifeTime2 = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LifeTimeZBased") == 0) { _lifeTimeZBased = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -934,14 +934,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle1") == 0) { _angle1 = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Angle2") == 0) { _angle2 = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -949,14 +949,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity1") == 0) { _angVelocity1 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AngVelocity2") == 0) { _angVelocity2 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -964,14 +964,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation1") == 0) { _rotation1 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotation2") == 0) { _rotation2 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -981,7 +981,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { _alpha1 = value->getInt(); if (_alpha1 < 0) _alpha1 = 0; if (_alpha1 > 255) _alpha1 = 255; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Alpha2 @@ -990,14 +990,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { _alpha2 = value->getInt(); if (_alpha2 < 0) _alpha2 = 0; if (_alpha2 > 255) _alpha2 = 255; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AlphaTimeBased") == 0) { _alphaTimeBased = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1005,7 +1005,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxParticles") == 0) { _maxParticles = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1013,21 +1013,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationInterval") == 0) { _genInterval = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GenerationAmount") == 0) { _genAmount = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxBatches") == 0) { _maxBatches = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1035,14 +1035,14 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeInTime") == 0) { _fadeInTime = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FadeOutTime") == 0) { _fadeOutTime = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1050,21 +1050,21 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate1") == 0) { _growthRate1 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GrowthRate2") == 0) { _growthRate2 = value->getFloat(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExponentialGrowth") == 0) { _exponentialGrowth = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1072,7 +1072,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UseRegion") == 0) { _useRegion = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1082,7 +1082,7 @@ HRESULT CPartEmitter::scSetProperty(const char *name, CScValue *value) { delete[] _emitEvent; _emitEvent = NULL; if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -1098,7 +1098,7 @@ const char *CPartEmitter::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartEmitter::persist(CBPersistMgr *persistMgr) { +ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); @@ -1193,7 +1193,7 @@ HRESULT CPartEmitter::persist(CBPersistMgr *persistMgr) { } } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 5160b7fb25..984ef78820 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -100,35 +100,35 @@ public: char *_emitEvent; CBScriptHolder *_owner; - HRESULT start(); + ERRORCODE start(); - HRESULT update(); - HRESULT display() { return display(NULL); } // To avoid shadowing the inherited display-function. - HRESULT display(CBRegion *region); + ERRORCODE update(); + ERRORCODE display() { return display(NULL); } // To avoid shadowing the inherited display-function. + ERRORCODE display(CBRegion *region); - HRESULT sortParticlesByZ(); - HRESULT addSprite(const char *filename); - HRESULT removeSprite(const char *filename); - HRESULT setBorder(int x, int y, int width, int height); - HRESULT setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + ERRORCODE sortParticlesByZ(); + ERRORCODE addSprite(const char *filename); + ERRORCODE removeSprite(const char *filename); + ERRORCODE setBorder(int x, int y, int width, int height); + ERRORCODE setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - HRESULT addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - HRESULT removeForce(const char *name); + ERRORCODE addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + ERRORCODE removeForce(const char *name); CBArray _forces; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: CPartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); - HRESULT initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - HRESULT updateInternal(uint32 currentTime, uint32 timerDelta); + ERRORCODE initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + ERRORCODE updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; CBArray _particles; CBArray _sprites; diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp index f6be20be93..b60d5447d9 100644 --- a/engines/wintermute/Base/PartForce.cpp +++ b/engines/wintermute/Base/PartForce.cpp @@ -47,13 +47,13 @@ CPartForce::~CPartForce(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CPartForce::persist(CBPersistMgr *persistMgr) { +ERRORCODE CPartForce::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); persistMgr->transfer(TMEMBER_INT(_type)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h index 548803a4a8..cf5d697a79 100644 --- a/engines/wintermute/Base/PartForce.h +++ b/engines/wintermute/Base/PartForce.h @@ -49,7 +49,7 @@ public: Vector2 _direction; TForceType _type; - HRESULT persist(CBPersistMgr *PersistMgr); + ERRORCODE persist(CBPersistMgr *PersistMgr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index aad7594775..0cf05e88a1 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -72,10 +72,10 @@ CPartParticle::~CPartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::setSprite(const char *filename) { +ERRORCODE CPartParticle::setSprite(const char *filename) { if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { _sprite->reset(); - return S_OK; + return STATUS_OK; } delete _sprite; @@ -83,34 +83,34 @@ HRESULT CPartParticle::setSprite(const char *filename) { CSysClassRegistry::getInstance()->_disabled = true; _sprite = new CBSprite(Game, Game); - if (_sprite && SUCCEEDED(_sprite->loadFile(filename))) { + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { CSysClassRegistry::getInstance()->_disabled = false; - return S_OK; + return STATUS_OK; } else { delete _sprite; _sprite = NULL; CSysClassRegistry::getInstance()->_disabled = false; - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { +ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; _currentAlpha = _alpha1; } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - return S_OK; + return STATUS_OK; } else if (_state == PARTICLE_FADEOUT) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _isDead = true; - return S_OK; + return STATUS_OK; } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - return S_OK; + return STATUS_OK; } else { // time is up if (_lifeTime > 0) { @@ -130,7 +130,7 @@ HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 if (!CBPlatform::ptInRect(&_border, p)) fadeOut(currentTime, emitter->_fadeOutTime); } - if (_state != PARTICLE_NORMAL) return S_OK; + if (_state != PARTICLE_NORMAL) return STATUS_OK; // update alpha if (_lifeTime > 0) { @@ -177,48 +177,48 @@ HRESULT CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 _isDead = true; - return S_OK; + return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::display(CPartEmitter *emitter) { - if (!_sprite) return E_FAIL; - if (_isDead) return S_OK; +ERRORCODE CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; _sprite->GetCurrentFrame(); return _sprite->display(_pos.x, _pos.y, NULL, _scale, _scale, - DRGBA(255, 255, 255, _currentAlpha), + BYTETORGBA(255, 255, 255, _currentAlpha), _rotation, emitter->_blendMode); } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { +ERRORCODE CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { _currentAlpha = 0; _fadeStart = currentTime; _fadeTime = fadeTime; _state = PARTICLE_FADEIN; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { +ERRORCODE CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; _fadeStart = currentTime; _fadeTime = fadeTime; _state = PARTICLE_FADEOUT; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { +ERRORCODE CPartParticle::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_alpha1)); persistMgr->transfer(TMEMBER(_alpha2)); persistMgr->transfer(TMEMBER(_border)); @@ -251,7 +251,7 @@ HRESULT CPartParticle::persist(CBPersistMgr *persistMgr) { filename = NULL; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index e6a34c8a21..3f495a432b 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -68,15 +68,15 @@ public: bool _isDead; TParticleState _state; - HRESULT update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - HRESULT display(CPartEmitter *emitter); + ERRORCODE update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + ERRORCODE display(CPartEmitter *emitter); - HRESULT setSprite(const char *filename); + ERRORCODE setSprite(const char *filename); - HRESULT fadeIn(uint32 currentTime, int fadeTime); - HRESULT fadeOut(uint32 currentTime, int fadeTime); + ERRORCODE fadeIn(uint32 currentTime, int fadeTime); + ERRORCODE fadeOut(uint32 currentTime, int fadeTime); - HRESULT persist(CBPersistMgr *PersistMgr); + ERRORCODE persist(CBPersistMgr *PersistMgr); private: uint32 _fadeStart; int _fadeTime; diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index 16b51a50fc..0a7214f6ba 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -51,10 +51,10 @@ public: virtual uint32 getPos() { return _pos; }; - virtual HRESULT seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; - virtual HRESULT read(void *buffer, uint32 size) = 0; - virtual HRESULT close() = 0; - virtual HRESULT open(const Common::String &filename) = 0; + virtual ERRORCODE seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; + virtual ERRORCODE read(void *buffer, uint32 size) = 0; + virtual ERRORCODE close() = 0; + virtual ERRORCODE open(const Common::String &filename) = 0; virtual bool isEOF(); CBFile(CBGame *inGame); virtual ~CBFile(); diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index c51cff366a..6f31a424c0 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -51,10 +51,10 @@ CBSaveThumbFile::~CBSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::open(const Common::String &filename) { +ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { close(); - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return E_FAIL; + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; char *tempFilename = new char[strlen(filename.c_str()) - 8]; strcpy(tempFilename, filename.c_str() + 9); @@ -72,24 +72,24 @@ HRESULT CBSaveThumbFile::open(const Common::String &filename) { char slotFilename[MAX_PATH + 1]; Game->getSaveSlotFilename(slot, slotFilename); CBPersistMgr *pm = new CBPersistMgr(Game); - if (!pm) return E_FAIL; + if (!pm) return STATUS_FAILED; Game->_dEBUG_AbsolutePathWarning = false; - if (FAILED(pm->initLoad(slotFilename))) { + if (DID_FAIL(pm->initLoad(slotFilename))) { Game->_dEBUG_AbsolutePathWarning = true; delete pm; - return E_FAIL; + return STATUS_FAILED; } Game->_dEBUG_AbsolutePathWarning = true; - HRESULT res; + ERRORCODE res; if (pm->_thumbnailDataSize != 0) { _data = new byte[pm->_thumbnailDataSize]; memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); _size = pm->_thumbnailDataSize; - res = S_OK; - } else res = E_FAIL; + res = STATUS_OK; + } else res = STATUS_FAILED; delete pm; return res; @@ -97,31 +97,31 @@ HRESULT CBSaveThumbFile::open(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::close() { +ERRORCODE CBSaveThumbFile::close() { delete[] _data; _data = NULL; _pos = 0; _size = 0; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return E_FAIL; +ERRORCODE CBSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return STATUS_FAILED; memcpy(buffer, (byte *)_data + _pos, size); _pos += size; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBSaveThumbFile::seek(uint32 pos, TSeek origin) { - if (!_data) return E_FAIL; +ERRORCODE CBSaveThumbFile::seek(uint32 pos, TSeek origin) { + if (!_data) return STATUS_FAILED; uint32 newPos = 0; @@ -137,10 +137,10 @@ HRESULT CBSaveThumbFile::seek(uint32 pos, TSeek origin) { break; } - if (newPos > _size) return E_FAIL; + if (newPos > _size) return STATUS_FAILED; else _pos = newPos; - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 8be98c1cc8..6540438de3 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -39,10 +39,10 @@ class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); virtual ~CBSaveThumbFile(); - virtual HRESULT seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); - virtual HRESULT read(void *buffer, uint32 size); - virtual HRESULT close(); - virtual HRESULT open(const Common::String &filename); + virtual ERRORCODE seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); + virtual ERRORCODE read(void *buffer, uint32 size); + virtual ERRORCODE close(); + virtual ERRORCODE open(const Common::String &filename); private: byte *_data; }; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 67466a2489..204a1170e2 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -93,7 +93,7 @@ const char *CSXArray::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } stack->pushInt(_length); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -126,10 +126,10 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _length--; } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } @@ -166,7 +166,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// @@ -181,7 +181,7 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { _values->deleteProp(PropName); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -193,19 +193,19 @@ HRESULT CSXArray::scSetProperty(const char *name, CScValue *value) { int Index = atoi(paramName); if (Index >= _length) _length = Index + 1; return _values->setProp(paramName, value); - } else return E_FAIL; + } else return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXArray::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_length)); persistMgr->transfer(TMEMBER(_values)); - return S_OK; + return STATUS_OK; } @@ -227,12 +227,12 @@ bool CSXArray::validNumber(const char *origStr, char *outStr) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXArray::push(CScValue *val) { +ERRORCODE CSXArray::push(CScValue *val) { char paramName[20]; _length++; sprintf(paramName, "%d", _length - 1); _values->setProp(paramName, val, true); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index 81599892d9..040fbaf481 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -35,15 +35,15 @@ namespace WinterMute { class CSXArray : public CBScriptable { public: - HRESULT push(CScValue *Val); + ERRORCODE push(CScValue *Val); bool validNumber(const char *origStr, char *outStr); DECLARE_PERSISTENT(CSXArray, CBScriptable) CSXArray(CBGame *inGame, CScStack *stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *value); - HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + ERRORCODE scSetProperty(const char *name, CScValue *value); + ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); int _length; CScValue *_values; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index e108c03a6e..a9ffaf5dd5 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -75,14 +75,14 @@ const char *CSXDate::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetYear") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_year + 1900); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetMonth @@ -90,7 +90,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "GetMonth") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_mon + 1); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetDate @@ -98,7 +98,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "GetDate") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_mday); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetHours @@ -106,7 +106,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "GetHours") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_hour); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetMinutes @@ -114,7 +114,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "GetMinutes") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_min); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetSeconds @@ -122,7 +122,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "GetSeconds") == 0) { stack->correctParams(0); stack->pushInt(_tm.tm_sec); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetWeekday @@ -131,7 +131,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); warning("GetWeekday returns a wrong value on purpose"); stack->pushInt(_tm.tm_mday % 7); - return S_OK; + return STATUS_OK; } @@ -142,7 +142,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_year = stack->pop()->getInt() - 1900; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetMonth @@ -151,7 +151,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_mon = stack->pop()->getInt() - 1; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetDate @@ -160,7 +160,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_mday = stack->pop()->getInt(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetHours @@ -169,7 +169,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_hour = stack->pop()->getInt(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetMinutes @@ -178,7 +178,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_min = stack->pop()->getInt(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // SetSeconds @@ -187,7 +187,7 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(1); _tm.tm_sec = stack->pop()->getInt(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -198,11 +198,11 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); g_system->getTimeAndDate(_tm); stack->pushNULL(); - return S_OK; + return STATUS_OK; } else - return E_FAIL; + return STATUS_FAILED; } @@ -223,22 +223,22 @@ CScValue *CSXDate::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CSXDate::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if(strcmp(name, "Name")==0){ setName(value->getString()); - return S_OK; + return STATUS_OK; } - else*/ return E_FAIL; + else*/ return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXDate::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXDate::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_tm.tm_year)); @@ -247,7 +247,7 @@ HRESULT CSXDate::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_tm.tm_hour)); persistMgr->transfer(TMEMBER(_tm.tm_min)); persistMgr->transfer(TMEMBER(_tm.tm_sec)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 72e91e6136..324e711e82 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -41,8 +41,8 @@ public: CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *value); - HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + ERRORCODE scSetProperty(const char *name, CScValue *value); + ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); char *_string; TimeDate _tm; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 58768db80f..329c595b5d 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -105,7 +105,7 @@ const char *CSXFile::scToString() { #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -115,7 +115,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this cleanup(); CBUtils::setString(&_filename, filename); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -153,7 +153,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_readFile || _writeFile) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); close(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -178,7 +178,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this int Pos = stack->pop()->getInt(); stack->pushBool(setPos(Pos)); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -188,7 +188,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); close(); stack->pushBool(CBPlatform::deleteFile(_filename) != false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -201,7 +201,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this close(); stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -212,14 +212,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_textMode || !_readFile) { script->runtimeError("File.%s: File must be open in text mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } uint32 bufSize = FILE_BUFFER_SIZE; byte *buf = (byte *)malloc(bufSize); uint32 counter = 0; byte b; bool foundNewLine = false; - HRESULT ret = E_FAIL; + ERRORCODE ret = STATUS_FAILED; do { ret = _readFile->read(&b, 1); if (ret != 1) break; @@ -237,7 +237,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this buf[counter] = b; counter++; } - } while (SUCCEEDED(ret)); + } while (DID_SUCCEED(ret)); if (counter > bufSize) { buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); @@ -250,7 +250,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this free(buf); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -263,14 +263,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_textMode || !_readFile) { script->runtimeError("File.%s: File must be open in text mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } uint32 bufSize = FILE_BUFFER_SIZE; byte *buf = (byte *)malloc(bufSize); uint32 counter = 0; byte b; - HRESULT ret = E_FAIL; + ERRORCODE ret = STATUS_FAILED; while (counter < (uint32)textLen) { ret = _readFile->read(&b, 1); if (ret != 1) break; @@ -297,7 +297,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this free(buf); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -309,7 +309,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (!_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in text mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } if (strcmp(name, "WriteLine") == 0) fprintf((FILE *)_writeFile, "%s\n", line); @@ -318,7 +318,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -330,13 +330,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } bool val; if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -347,13 +347,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } byte val; if (_readFile->read(&val, sizeof(byte)) == sizeof(byte)) stack->pushInt(val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -364,13 +364,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } short val; if (_readFile->read(&val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -381,13 +381,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } int val; if (_readFile->read(&val, sizeof(int)) == sizeof(int)) stack->pushInt(val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -398,13 +398,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } float val; if (_readFile->read(&val, sizeof(float)) == sizeof(float)) stack->pushFloat(val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -415,13 +415,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } double val; if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -432,7 +432,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); stack->pushNULL(); - return S_OK; + return STATUS_OK; } uint32 size; if (_readFile->read(&size, sizeof(uint32)) == sizeof(uint32)) { @@ -446,7 +446,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } else stack->pushNULL(); } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -459,12 +459,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -477,12 +477,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -495,12 +495,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -513,12 +513,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -531,12 +531,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -549,12 +549,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -567,7 +567,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); - return S_OK; + return STATUS_OK; } uint32 size = strlen(val); @@ -576,7 +576,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->pushBool(true); - return S_OK; + return STATUS_OK; } @@ -641,7 +641,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CSXFile::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -657,7 +657,7 @@ HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) { _values->DeleteProp(PropName); } } - return S_OK; + return STATUS_OK; } else*/ return CBScriptable::scSetProperty(name, value); } @@ -692,7 +692,7 @@ uint32 CSXFile::getLength() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); @@ -738,7 +738,7 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) { } } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index efa06b7023..12e0eb74b0 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -41,8 +41,8 @@ class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *value); - HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + ERRORCODE scSetProperty(const char *name, CScValue *value); + ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index b5a696ece2..aba58e2aa7 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/persistent.h" +#include "common/math.h" #include namespace WinterMute { @@ -58,14 +59,14 @@ CSXMath::~CSXMath() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Abs") == 0) { stack->correctParams(1); stack->pushFloat(fabs(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -74,7 +75,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Acos") == 0) { stack->correctParams(1); stack->pushFloat(acos(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -83,7 +84,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Asin") == 0) { stack->correctParams(1); stack->pushFloat(asin(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -92,7 +93,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Atan") == 0) { stack->correctParams(1); stack->pushFloat(atan(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -103,7 +104,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this double y = stack->pop()->getFloat(); double x = stack->pop()->getFloat(); stack->pushFloat(atan2(y, x)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -112,7 +113,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Ceil") == 0) { stack->correctParams(1); stack->pushFloat(ceil(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -121,7 +122,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Cos") == 0) { stack->correctParams(1); stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -130,7 +131,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Cosh") == 0) { stack->correctParams(1); stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -139,7 +140,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Exp") == 0) { stack->correctParams(1); stack->pushFloat(exp(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -148,7 +149,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Floor") == 0) { stack->correctParams(1); stack->pushFloat(floor(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -157,7 +158,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Log") == 0) { stack->correctParams(1); stack->pushFloat(log(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -166,7 +167,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Log10") == 0) { stack->correctParams(1); stack->pushFloat(log10(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -178,7 +179,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this double y = stack->pop()->getFloat(); stack->pushFloat(pow(x, y)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -187,7 +188,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Sin") == 0) { stack->correctParams(1); stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -196,7 +197,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Sinh") == 0) { stack->correctParams(1); stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -205,7 +206,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Tan") == 0) { stack->correctParams(1); stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -214,7 +215,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Tanh") == 0) { stack->correctParams(1); stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -223,7 +224,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "Sqrt") == 0) { stack->correctParams(1); stack->pushFloat(sqrt(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -232,7 +233,7 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "DegToRad") == 0) { stack->correctParams(1); stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -241,10 +242,10 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else if (strcmp(name, "RadToDeg") == 0) { stack->correctParams(1); stack->pushFloat(radianToDegree(stack->pop()->getFloat())); - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } @@ -264,7 +265,7 @@ CScValue *CSXMath::scGetProperty(const char *name) { // PI ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PI") == 0) { - _scValue->setFloat(PI); + _scValue->setFloat(M_PI); return _scValue; } @@ -274,21 +275,21 @@ CScValue *CSXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// double CSXMath::degreeToRadian(double value) { - return value * (PI / 180.0f); + return value * (M_PI / 180.0f); } ////////////////////////////////////////////////////////////////////////// double CSXMath::radianToDegree(double value) { - return value * (180.0f / PI); + return value * (180.0f / M_PI); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMath::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXMath::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index 477e8aca4f..aceca5ea08 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -40,7 +40,7 @@ public: CSXMath(CBGame *inGame); virtual ~CSXMath(); virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); private: double degreeToRadian(double value); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index f719ee5a47..0854cfb505 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -76,7 +76,7 @@ void CSXMemBuffer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::resize(int newSize) { +ERRORCODE CSXMemBuffer::resize(int newSize) { int oldSize = _size; if (_size == 0) { @@ -88,7 +88,7 @@ HRESULT CSXMemBuffer::resize(int newSize) { if (newSize == 0) { _buffer = newBuf; _size = newSize; - } else return E_FAIL; + } else return STATUS_FAILED; } else { _buffer = newBuf; _size = newSize; @@ -98,7 +98,7 @@ HRESULT CSXMemBuffer::resize(int newSize) { if (_buffer && _size > oldSize) { memset((byte *)_buffer + oldSize, 0, _size - oldSize); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -124,7 +124,7 @@ const char *CSXMemBuffer::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -132,12 +132,12 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->correctParams(1); int newSize = stack->pop()->getInt(); newSize = MAX(0, newSize); - if (SUCCEEDED(resize(newSize))) + if (DID_SUCCEED(resize(newSize))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushBool(*(bool *)((byte *)_buffer + start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -165,7 +165,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushInt(*(byte *)((byte *)_buffer + start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -179,7 +179,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -193,7 +193,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushInt(*(int *)((byte *)_buffer + start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushFloat(*(float *)((byte *)_buffer + start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -221,7 +221,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack else stack->pushFloat(*(double *)((byte *)_buffer + start)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -251,7 +251,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->pushString(str); delete [] str; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -267,7 +267,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack CSXMemBuffer *buf = new CSXMemBuffer(Game, pointer); stack->pushNative(buf, false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -284,7 +284,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(bool *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -301,7 +301,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(byte *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -318,7 +318,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(short *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -335,7 +335,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(int *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(float *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -369,7 +369,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *(double *)((byte *)_buffer + start) = val; stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -386,7 +386,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack memcpy((byte *)_buffer + start, val, strlen(val) + 1); stack->pushBool(true); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -409,7 +409,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack stack->pushBool(false); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -425,10 +425,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack f.close(); } stack->pushNULL(); - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } @@ -457,7 +457,7 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -473,14 +473,14 @@ HRESULT CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { _values->DeleteProp(PropName); } } - return S_OK; + return STATUS_OK; } else*/ return CBScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXMemBuffer::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXMemBuffer::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); @@ -495,7 +495,7 @@ HRESULT CSXMemBuffer::persist(CBPersistMgr *persistMgr) { } else _buffer = NULL; } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index d76257fca7..775f8247b2 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -39,8 +39,8 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *value); - HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + ERRORCODE scSetProperty(const char *name, CScValue *value); + ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXMemBuffer(CBGame *inGame, CScStack *stack); CSXMemBuffer(CBGame *inGame, void *buffer); @@ -48,7 +48,7 @@ public: virtual void *scToMemBuffer(); int _size; private: - HRESULT resize(int newSize); + ERRORCODE resize(int newSize); void *_buffer; void cleanup(); bool checkBounds(CScScript *script, int start, int length); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index f987e950d8..4658f48216 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -84,7 +84,7 @@ void CSXStore::cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // EnableEvents ////////////////////////////////////////////////////////////////////////// @@ -92,7 +92,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); setEventsEnabled(script, true); stack->pushBool(getEventsEnabled() == true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // DisableEvents @@ -101,7 +101,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(0); setEventsEnabled(script, false); stack->pushBool(getEventsEnabled() == false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ValidateProducts @@ -112,7 +112,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _lastProductRequestOwner = script->_owner; validateProducts(prodIdList); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetValidProduct @@ -131,7 +131,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetInvalidProduct @@ -144,7 +144,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // GetTransaction @@ -162,7 +162,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Purchase @@ -172,7 +172,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi const char *prodId = stack->pop()->getString(); stack->pushBool(purchase(script, prodId)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // FinishTransaction @@ -182,7 +182,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi const char *transId = stack->pop()->getString(); stack->pushBool(finishTransaction(script, transId)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // RestoreTransactions @@ -192,7 +192,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi restoreTransactions(script); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -219,10 +219,10 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->pushBool(Game->_registry->readBool("Purchases", prodId, false)); - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } @@ -278,7 +278,7 @@ CScValue *CSXStore::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXStore::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); @@ -306,7 +306,7 @@ HRESULT CSXStore::persist(CBPersistMgr *persistMgr) { } } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h index fafd007003..a6268689c6 100644 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ b/engines/wintermute/Base/scriptables/SXStore.h @@ -60,12 +60,12 @@ public: delete [] _price; } - HRESULT persist(CBPersistMgr *persistMgr) { + ERRORCODE persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_id)); persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_desc)); persistMgr->transfer(TMEMBER(_price)); - return S_OK; + return STATUS_OK; } const char *getId() { @@ -130,7 +130,7 @@ public: CSXStore(CBGame *inGame); virtual ~CSXStore(); virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void afterLoad(); void OnObjectDestroyed(CBScriptHolder *obj); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 172ae32ad1..f4bb610c64 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -99,7 +99,7 @@ void CSXString::scSetString(const char *val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -128,7 +128,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // stack->pushNULL(); // } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -143,7 +143,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!val->isNULL() && len <= 0) { stack->pushString(""); - return S_OK; + return STATUS_OK; } if (val->isNULL()) len = strlen(_string) - start; @@ -166,7 +166,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // stack->pushNULL(); // } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -188,7 +188,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else stack->pushString(StringUtil::wideToAnsi(str).c_str()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -210,7 +210,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else stack->pushString(StringUtil::wideToAnsi(str).c_str()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +237,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th int indexOf = StringUtil::indexOf(str, toFind, index); stack->pushInt(indexOf); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -252,7 +252,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CSXArray *array = new CSXArray(Game); if (!array) { stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -309,10 +309,10 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } stack->pushNative(array, false); - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } @@ -352,7 +352,7 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// @@ -369,15 +369,15 @@ HRESULT CSXString::scSetProperty(const char *name, CScValue *value) { _capacity = newCap; } } - return S_OK; + return STATUS_OK; } - else return E_FAIL; + else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSXString::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXString::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); @@ -392,7 +392,7 @@ HRESULT CSXString::persist(CBPersistMgr *persistMgr) { } else _string = NULL; } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index d7279d17cf..c9fcad6463 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -39,8 +39,8 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) CScValue *scGetProperty(const char *name); - HRESULT scSetProperty(const char *name, CScValue *value); - HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + ERRORCODE scSetProperty(const char *name, CScValue *value); + ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void scSetString(const char *val); const char *scToString(); void setStringVal(const char *val); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 58ecc20a0e..639fd0d6cd 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -98,7 +98,7 @@ CScEngine::~CScEngine() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::cleanup() { +ERRORCODE CScEngine::cleanup() { for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; @@ -115,7 +115,7 @@ HRESULT CScEngine::cleanup() { _currentScript = NULL; // ref only - return S_OK; + return STATUS_OK; } @@ -148,8 +148,8 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { // add new script CScScript *script = new CScScript(Game, this); - HRESULT ret = script->create(filename, compBuffer, compSize, owner); - if (FAILED(ret)) { + ERRORCODE ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { Game->LOG(ret, "Error running script '%s'...", filename); delete script; return NULL; @@ -244,9 +244,9 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::tick() { +ERRORCODE CScEngine::tick() { if (_scripts.GetSize() == 0) - return S_OK; + return STATUS_OK; // resolve waiting scripts @@ -339,12 +339,12 @@ HRESULT CScEngine::tick() { removeFinishedScripts(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::tickUnbreakable() { +ERRORCODE CScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.GetSize(); i++) { if (!_scripts[i]->_unbreakable) continue; @@ -358,12 +358,12 @@ HRESULT CScEngine::tickUnbreakable() { } removeFinishedScripts(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::removeFinishedScripts() { +ERRORCODE CScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { @@ -374,7 +374,7 @@ HRESULT CScEngine::removeFinishedScripts() { i--; } } - return S_OK; + return STATUS_OK; } @@ -411,19 +411,19 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::emptyScriptCache() { +ERRORCODE CScEngine::emptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i]) { delete _cachedScripts[i]; _cachedScripts[i] = NULL; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::resetObject(CBObject *Object) { +ERRORCODE CScEngine::resetObject(CBObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { @@ -433,22 +433,22 @@ HRESULT CScEngine::resetObject(CBObject *Object) { _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::resetScript(CScScript *script) { +ERRORCODE CScEngine::resetScript(CScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { _scripts[i]->finish(); } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { +ERRORCODE CScEngine::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); persistMgr->transfer(TMEMBER(Game)); @@ -456,7 +456,7 @@ HRESULT CScEngine::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_globals)); _scripts.persist(persistMgr); - return S_OK; + return STATUS_OK; } @@ -473,21 +473,21 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::pauseAll() { +ERRORCODE CScEngine::pauseAll() { for (int i = 0; i < _scripts.GetSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->pause(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::resumeAll() { +ERRORCODE CScEngine::resumeAll() { for (int i = 0; i < _scripts.GetSize(); i++) _scripts[i]->resume(); - return S_OK; + return STATUS_OK; } @@ -500,13 +500,13 @@ bool CScEngine::isValidScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::clearGlobals(bool includingNatives) { +ERRORCODE CScEngine::clearGlobals(bool includingNatives) { _globals->CleanProps(includingNatives); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::dbgSendScripts(IWmeDebugClient *client) { +ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); @@ -522,12 +522,12 @@ HRESULT CScEngine::dbgSendScripts(IWmeDebugClient *client) { _scripts[i]->dbgSendScript(client); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; for (int i = 0; i < _breakpoints.GetSize(); i++) { @@ -542,19 +542,19 @@ HRESULT CScEngine::addBreakpoint(const char *scriptFilename, int line) { } for (int i = 0; i < bp->_lines.GetSize(); i++) { - if (bp->_lines[i] == line) return S_OK; + if (bp->_lines[i] == line) return STATUS_OK; } bp->_lines.Add(line); // refresh changes refreshScriptBreakpoints(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _breakpoints.GetSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { @@ -568,45 +568,45 @@ HRESULT CScEngine::removeBreakpoint(const char *scriptFilename, int line) { // refresh changes refreshScriptBreakpoints(); - return S_OK; + return STATUS_OK; } } break; } } - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::refreshScriptBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::refreshScriptBreakpoints() { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _scripts.GetSize(); i++) { refreshScriptBreakpoints(_scripts[i]); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::refreshScriptBreakpoints(CScScript *script) { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; - if (!script || !script->_filename) return E_FAIL; + if (!script || !script->_filename) return STATUS_FAILED; for (int i = 0; i < _breakpoints.GetSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { script->_breakpoints.Copy(_breakpoints[i]->_lines); - return S_OK; + return STATUS_OK; } } if (script->_breakpoints.GetSize() > 0) script->_breakpoints.RemoveAll(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::saveBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::saveBreakpoints() { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; char text[512]; @@ -624,12 +624,12 @@ HRESULT CScEngine::saveBreakpoints() { } Game->_registry->writeInt("Debug", "NumBreakpoints", count); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScEngine::loadBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return S_OK; +ERRORCODE CScEngine::loadBreakpoints() { + if (!Game->getDebugMgr()->_enabled) return STATUS_OK; char key[100]; @@ -649,7 +649,7 @@ HRESULT CScEngine::loadBreakpoints() { line = NULL; } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index 454e3cce62..d4112be47b 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -83,33 +83,33 @@ public: public: - HRESULT dbgSendScripts(IWmeDebugClient *client); + ERRORCODE dbgSendScripts(IWmeDebugClient *client); CBArray _breakpoints; - HRESULT addBreakpoint(const char *scriptFilename, int line); - HRESULT removeBreakpoint(const char *scriptFilename, int line); - HRESULT refreshScriptBreakpoints(); - HRESULT refreshScriptBreakpoints(CScScript *script); - HRESULT saveBreakpoints(); - HRESULT loadBreakpoints(); - - HRESULT clearGlobals(bool includingNatives = false); - HRESULT tickUnbreakable(); - HRESULT removeFinishedScripts(); + ERRORCODE addBreakpoint(const char *scriptFilename, int line); + ERRORCODE removeBreakpoint(const char *scriptFilename, int line); + ERRORCODE refreshScriptBreakpoints(); + ERRORCODE refreshScriptBreakpoints(CScScript *script); + ERRORCODE saveBreakpoints(); + ERRORCODE loadBreakpoints(); + + ERRORCODE clearGlobals(bool includingNatives = false); + ERRORCODE tickUnbreakable(); + ERRORCODE removeFinishedScripts(); bool isValidScript(CScScript *script); CScScript *_currentScript; - HRESULT resumeAll(); - HRESULT pauseAll(); + ERRORCODE resumeAll(); + ERRORCODE pauseAll(); void editorCleanup(); - HRESULT resetObject(CBObject *Object); - HRESULT resetScript(CScScript *script); - HRESULT emptyScriptCache(); + ERRORCODE resetObject(CBObject *Object); + ERRORCODE resetScript(CScScript *script); + ERRORCODE emptyScriptCache(); byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) - HRESULT cleanup(); + ERRORCODE cleanup(); int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - HRESULT tick(); + ERRORCODE tick(); CScValue *_globals; CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); static const bool _compilerAvailable = false; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 58e61ca3f0..19f1fb29a1 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -118,7 +118,7 @@ void CScScript::readHeader() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::initScript() { +ERRORCODE CScScript::initScript() { if (!_scriptStream) { _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); } @@ -127,13 +127,13 @@ HRESULT CScScript::initScript() { if (_header.magic != SCRIPT_MAGIC) { Game->LOG(0, "File '%s' is not a valid compiled script", _filename); cleanup(); - return E_FAIL; + return STATUS_FAILED; } if (_header.version > SCRIPT_VERSION) { Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); cleanup(); - return E_FAIL; + return STATUS_FAILED; } initTables(); @@ -160,12 +160,12 @@ HRESULT CScScript::initScript() { // ready to rumble... _state = SCRIPT_RUNNING; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::initTables() { +ERRORCODE CScScript::initTables() { uint32 OrigIP = _iP; readHeader(); @@ -235,12 +235,12 @@ HRESULT CScScript::initTables() { _iP = OrigIP; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { +ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { cleanup(); _thread = false; @@ -253,26 +253,26 @@ HRESULT CScScript::create(const char *filename, byte *buffer, uint32 size, CBScr if (_filename) strcpy(_filename, filename); _buffer = new byte [size]; - if (!_buffer) return E_FAIL; + if (!_buffer) return STATUS_FAILED; memcpy(_buffer, buffer, size); _bufferSize = size; - HRESULT res = initScript(); - if (FAILED(res)) return res; + ERRORCODE res = initScript(); + if (DID_FAIL(res)) return res; // establish global variables table _globals = new CScValue(Game); _owner = owner; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { +ERRORCODE CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { cleanup(); _thread = true; @@ -286,14 +286,14 @@ HRESULT CScScript::createThread(CScScript *original, uint32 initIP, const char * // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return E_FAIL; + if (!_buffer) return STATUS_FAILED; memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize - HRESULT res = initScript(); - if (FAILED(res)) return res; + ERRORCODE res = initScript(); + if (DID_FAIL(res)) return res; // copy globals _globals = original->_globals; @@ -309,16 +309,16 @@ HRESULT CScScript::createThread(CScScript *original, uint32 initIP, const char * _engine = original->_engine; _parentScript = original; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::createMethodThread(CScScript *original, const char *methodName) { +ERRORCODE CScScript::createMethodThread(CScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return E_FAIL; + if (ip == 0) return STATUS_FAILED; cleanup(); @@ -333,14 +333,14 @@ HRESULT CScScript::createMethodThread(CScScript *original, const char *methodNam // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return E_FAIL; + if (!_buffer) return STATUS_FAILED; memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize - HRESULT res = initScript(); - if (FAILED(res)) return res; + ERRORCODE res = initScript(); + if (DID_FAIL(res)) return res; // copy globals _globals = original->_globals; @@ -355,7 +355,7 @@ HRESULT CScScript::createMethodThread(CScScript *original, const char *methodNam _engine = original->_engine; _parentScript = original; - return S_OK; + return STATUS_OK; } @@ -470,8 +470,8 @@ char *CScScript::getString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::executeInstruction() { - HRESULT ret = S_OK; +ERRORCODE CScScript::executeInstruction() { + ERRORCODE ret = STATUS_OK; uint32 dw; const char *str = NULL; @@ -560,7 +560,7 @@ HRESULT CScScript::executeInstruction() { CScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - HRESULT res = E_FAIL; + ERRORCODE res = STATUS_FAILED; bool TriedNative = false; // we are already calling this method, try native @@ -569,7 +569,7 @@ HRESULT CScScript::executeInstruction() { res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); } - if (FAILED(res)) { + if (DID_FAIL(res)) { if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { if (!_unbreakable) { _waitScript = var->getNative()->invokeMethodThread(MethodName); @@ -612,10 +612,10 @@ HRESULT CScScript::executeInstruction() { } */ else { - res = E_FAIL; + res = STATUS_FAILED; if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - if (FAILED(res)) { + if (DID_FAIL(res)) { _stack->correctParams(0); runtimeError("Call to undefined method '%s'. Ignored.", MethodName); _stack->pushNULL(); @@ -1049,7 +1049,7 @@ HRESULT CScScript::executeInstruction() { default: Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); _state = SCRIPT_FINISHED; - ret = E_FAIL; + ret = STATUS_FAILED; } // switch(instruction) //delete op; @@ -1120,30 +1120,30 @@ CScValue *CScScript::getVar(char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::waitFor(CBObject *object) { +ERRORCODE CScScript::waitFor(CBObject *object) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); - return S_OK; + return STATUS_OK; } _state = SCRIPT_WAITING; _waitObject = object; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::waitForExclusive(CBObject *object) { +ERRORCODE CScScript::waitForExclusive(CBObject *object) { _engine->resetObject(object); return waitFor(object); } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::sleep(uint32 duration) { +ERRORCODE CScScript::sleep(uint32 duration) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); - return S_OK; + return STATUS_OK; } _state = SCRIPT_SLEEPING; @@ -1154,26 +1154,26 @@ HRESULT CScScript::sleep(uint32 duration) { _waitTime = Game->_timer + duration; _waitFrozen = false; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::finish(bool includingThreads) { +ERRORCODE CScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); } else _state = SCRIPT_FINISHED; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::run() { +ERRORCODE CScScript::run() { _state = SCRIPT_RUNNING; - return S_OK; + return STATUS_OK; } @@ -1195,7 +1195,7 @@ void CScScript::runtimeError(LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::persist(CBPersistMgr *persistMgr) { +ERRORCODE CScScript::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); @@ -1252,7 +1252,7 @@ HRESULT CScScript::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) _tracingMode = false; - return S_OK; + return STATUS_OK; } @@ -1265,8 +1265,8 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable CScScript *thread = new CScScript(Game, _engine); if (thread) { - HRESULT ret = thread->createThread(this, pos, eventName); - if (SUCCEEDED(ret)) { + ERRORCODE ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.Add(thread); Game->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); @@ -1302,27 +1302,27 @@ bool CScScript::canHandleMethod(const char *methodName) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::pause() { +ERRORCODE CScScript::pause() { if (_state == SCRIPT_PAUSED) { Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return E_FAIL; + return STATUS_FAILED; } - if (!_freezable || _state == SCRIPT_PERSISTENT) return S_OK; + if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; _origState = _state; _state = SCRIPT_PAUSED; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::resume() { - if (_state != SCRIPT_PAUSED) return S_OK; +ERRORCODE CScScript::resume() { + if (_state != SCRIPT_PAUSED) return STATUS_OK; _state = _origState; - return S_OK; + return STATUS_OK; } @@ -1337,14 +1337,14 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { +ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { #ifndef __WIN32__ Game->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); stack->pushNULL(); - return E_FAIL; + return STATUS_FAILED; #else @@ -1451,7 +1451,7 @@ HRESULT CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript: if (hDll) FreeLibrary(hDll); - return Success ? S_OK : E_FAIL; + return Success ? STATUS_OK : STATUS_FAILED; #endif } @@ -1536,7 +1536,7 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::copyParameters(CScStack *stack) { +ERRORCODE CScScript::copyParameters(CScStack *stack) { int i; int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { @@ -1546,18 +1546,18 @@ HRESULT CScScript::copyParameters(CScStack *stack) { for (i = 0; i < NumParams; i++) stack->pop(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::finishThreads() { +ERRORCODE CScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.GetSize(); i++) { CScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) scr->finish(true); } - return S_OK; + return STATUS_OK; } @@ -1574,17 +1574,17 @@ const char *CScScript::dbgGetFilename() { ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::dbgSendScript(IWmeDebugClient *client) { +ERRORCODE CScScript::dbgSendScript(IWmeDebugClient *client) { if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); else client->onScriptInit(this); return dbgSendVariables(client); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScScript::dbgSendVariables(IWmeDebugClient *client) { +ERRORCODE CScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); @@ -1595,7 +1595,7 @@ HRESULT CScScript::dbgSendVariables(IWmeDebugClient *client) { //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 8fd3383ee1..6bd1d26142 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -43,16 +43,16 @@ class CScEngine; class CScStack; class CScScript : public CBBase, public IWmeDebugScript { public: - HRESULT dbgSendScript(IWmeDebugClient *client); - HRESULT dbgSendVariables(IWmeDebugClient *client); + ERRORCODE dbgSendScript(IWmeDebugClient *client); + ERRORCODE dbgSendVariables(IWmeDebugClient *client); CBArray _breakpoints; bool _tracingMode; CScScript *_parentScript; bool _unbreakable; - HRESULT finishThreads(); - HRESULT copyParameters(CScStack *stack); + ERRORCODE finishThreads(); + ERRORCODE copyParameters(CScStack *stack); void afterLoad(); @@ -66,21 +66,21 @@ public: CScValue *_operand; CScValue *_reg1; bool _freezable; - HRESULT resume(); - HRESULT pause(); + ERRORCODE resume(); + ERRORCODE pause(); bool canHandleEvent(const char *eventName); bool canHandleMethod(const char *methodName); - HRESULT createThread(CScScript *original, uint32 initIP, const char *eventName); - HRESULT createMethodThread(CScScript *original, const char *methodName); + ERRORCODE createThread(CScScript *original, uint32 initIP, const char *eventName); + ERRORCODE createMethodThread(CScScript *original, const char *methodName); CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(CScScript, CBBase) void runtimeError(LPCSTR fmt, ...); - HRESULT run(); - HRESULT finish(bool includingThreads = false); - HRESULT sleep(uint32 duration); - HRESULT waitForExclusive(CBObject *object); - HRESULT waitFor(CBObject *object); + ERRORCODE run(); + ERRORCODE finish(bool includingThreads = false); + ERRORCODE sleep(uint32 duration); + ERRORCODE waitForExclusive(CBObject *object); + ERRORCODE waitFor(CBObject *object); uint32 _waitTime; bool _waitFrozen; CBObject *_waitObject; @@ -136,12 +136,12 @@ public: CScValue *_globals; CScEngine *_engine; int _currentLine; - HRESULT executeInstruction(); + ERRORCODE executeInstruction(); char *getString(); uint32 getDWORD(); double getFloat(); void cleanup(); - HRESULT create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + ERRORCODE create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); uint32 _iP; private: void readHeader(); @@ -167,10 +167,10 @@ public: char *_threadEvent; CBScriptHolder *_owner; CScScript::TExternalFunction *getExternal(char *name); - HRESULT externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); + ERRORCODE externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); private: - HRESULT initScript(); - HRESULT initTables(); + ERRORCODE initScript(); + ERRORCODE initTables(); // IWmeDebugScript interface implementation diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 38efd393ad..7bc44838f3 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -213,14 +213,14 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScStack::persist(CBPersistMgr *persistMgr) { +ERRORCODE CScStack::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_sP)); _values.persist(persistMgr); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index d88e0dd694..ba698fdd8d 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -188,7 +188,7 @@ CScValue *CScValue::getProp(const char *name) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::deleteProp(const char *name) { +ERRORCODE CScValue::deleteProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); _valIter = _valObject.find(name); @@ -197,22 +197,22 @@ HRESULT CScValue::deleteProp(const char *name) { _valIter->_value = NULL; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { +ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, val); - HRESULT ret = E_FAIL; + ERRORCODE ret = STATUS_FAILED; if (_type == VAL_NATIVE && _valNative) { ret = _valNative->scSetProperty(name, val); } - if (FAILED(ret)) { + if (DID_FAIL(ret)) { CScValue *newVal = NULL; _valIter = _valObject.find(name); @@ -244,7 +244,7 @@ HRESULT CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool */ } - return S_OK; + return STATUS_OK; } @@ -735,7 +735,7 @@ void CScValue::setValue(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::persist(CBPersistMgr *persistMgr) { +ERRORCODE CScValue::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(Game)); persistMgr->transfer(TMEMBER(_persistent)); @@ -814,12 +814,12 @@ HRESULT CScValue::persist(CBPersistMgr *persistMgr) { fclose(f); */ - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CScValue::saveAsText(CBDynBuffer *buffer, int indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { buffer->putTextIndent(indent, "PROPERTY {\n"); @@ -829,7 +829,7 @@ HRESULT CScValue::saveAsText(CBDynBuffer *buffer, int indent) { _valIter++; } - return S_OK; + return STATUS_OK; } @@ -878,20 +878,20 @@ int CScValue::compareStrict(CScValue *val1, CScValue *val2) { ////////////////////////////////////////////////////////////////////////// -HRESULT CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { +ERRORCODE CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); _valIter++; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, int value) { CScValue *val = new CScValue(Game, value); - bool ret = SUCCEEDED(setProp(propName, val)); + bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } @@ -899,7 +899,7 @@ bool CScValue::setProperty(const char *propName, int value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, const char *value) { CScValue *val = new CScValue(Game, value); - bool ret = SUCCEEDED(setProp(propName, val)); + bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } @@ -907,7 +907,7 @@ bool CScValue::setProperty(const char *propName, const char *value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, double value) { CScValue *val = new CScValue(Game, value); - bool ret = SUCCEEDED(setProp(propName, val)); + bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } @@ -916,7 +916,7 @@ bool CScValue::setProperty(const char *propName, double value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, bool value) { CScValue *val = new CScValue(Game, value); - bool ret = SUCCEEDED(setProp(propName, val)); + bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } @@ -925,7 +925,7 @@ bool CScValue::setProperty(const char *propName, bool value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName) { CScValue *val = new CScValue(Game); - bool ret = SUCCEEDED(setProp(propName, val)); + bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 0ff2a79ce6..2f946dffc5 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -43,7 +43,7 @@ class CBScriptable; class CScValue : public CBBase, public IWmeDebugProp { public: - HRESULT dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + ERRORCODE dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); static int compare(CScValue *val1, CScValue *val2); static int compareStrict(CScValue *val1, CScValue *val2); @@ -52,7 +52,7 @@ public: DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; - HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); void setValue(CScValue *val); bool _persistent; bool propExists(const char *name); @@ -65,7 +65,7 @@ public: const char *getString(); void *getMemBuffer(); CBScriptable *getNative(); - HRESULT deleteProp(const char *name); + ERRORCODE deleteProp(const char *name); void deleteProps(); void CleanProps(bool includingNatives); void setBool(bool val); @@ -84,7 +84,7 @@ public: bool isFloat(); bool isInt(); bool isObject(); - HRESULT setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + ERRORCODE setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); CScValue *getProp(const char *name); CBScriptable *_valNative; CScValue *_valRef; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 7382c5c949..966eb0da09 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -58,10 +58,10 @@ CSXObject::~CSXObject() { ////////////////////////////////////////////////////////////////////////// -HRESULT CSXObject::persist(CBPersistMgr *persistMgr) { +ERRORCODE CSXObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index c29bc19578..1ebcccf6e1 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -167,7 +167,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { persistMgr->putString(""); persistMgr->putDWORD(_classes.size()); @@ -186,12 +186,12 @@ HRESULT CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, boo (it->_value)->saveTable(Game, persistMgr); } persistMgr->putString(""); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { +ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { checkHeader("", persistMgr); // reset SavedID of current instances @@ -221,12 +221,12 @@ HRESULT CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { checkHeader("", persistMgr); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +ERRORCODE CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { Classes::iterator it; @@ -254,11 +254,11 @@ HRESULT CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, (it->_value)->saveInstances(Game, persistMgr); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) { +ERRORCODE CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) { // get total instances int numInstances = persistMgr->getDWORD(); @@ -289,17 +289,17 @@ HRESULT CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) _savedInstanceMap.clear(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { +ERRORCODE CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return E_FAIL; + if (mapIt == _nameMap.end()) return STATUS_FAILED; (*mapIt)._value->instanceCallback(lpCallback, lpData); - return S_OK; + return STATUS_OK; } diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 92dfa5214b..679c92030e 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -66,11 +66,11 @@ public: CSysClassRegistry(); virtual ~CSysClassRegistry(); - HRESULT enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - HRESULT loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - HRESULT loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - HRESULT saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + ERRORCODE enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + ERRORCODE loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + ERRORCODE saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + ERRORCODE loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + ERRORCODE saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); void *idToPointer(int classID, int instanceID); bool getPointerID(void *pointer, int *classID, int *instanceID); bool registerClass(CSysClass *classObj); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index ce432d8f4a..2dfb688e46 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -95,19 +95,19 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::loadFile(const char *filename) { +ERRORCODE CUIButton::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); delete [] buffer; @@ -154,7 +154,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -201,7 +201,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { Game->LOG(0, "'BUTTON' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -209,7 +209,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -223,7 +223,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -233,7 +233,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_HOVER: delete _backHover; _backHover = new CUITiledImage(Game); - if (!_backHover || FAILED(_backHover->loadFile((char *)params))) { + if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { delete _backHover; _backHover = NULL; cmd = PARSERR_GENERIC; @@ -243,7 +243,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_PRESS: delete _backPress; _backPress = new CUITiledImage(Game); - if (!_backPress || FAILED(_backPress->loadFile((char *)params))) { + if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { delete _backPress; _backPress = NULL; cmd = PARSERR_GENERIC; @@ -253,7 +253,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_DISABLE: delete _backDisable; _backDisable = new CUITiledImage(Game); - if (!_backDisable || FAILED(_backDisable->loadFile((char *)params))) { + if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { delete _backDisable; _backDisable = NULL; cmd = PARSERR_GENERIC; @@ -263,7 +263,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_FOCUS: delete _backFocus; _backFocus = new CUITiledImage(Game); - if (!_backFocus || FAILED(_backFocus->loadFile((char *)params))) { + if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { delete _backFocus; _backFocus = NULL; cmd = PARSERR_GENERIC; @@ -273,7 +273,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -283,7 +283,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: delete _imageHover; _imageHover = new CBSprite(Game); - if (!_imageHover || FAILED(_imageHover->loadFile((char *)params))) { + if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { delete _imageHover; _imageHover = NULL; cmd = PARSERR_GENERIC; @@ -293,7 +293,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_PRESS: delete _imagePress; _imagePress = new CBSprite(Game); - if (!_imagePress || FAILED(_imagePress->loadFile((char *)params))) { + if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { delete _imagePress; _imagePress = NULL; cmd = PARSERR_GENERIC; @@ -303,7 +303,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_DISABLE: delete _imageDisable; _imageDisable = new CBSprite(Game); - if (!_imageDisable || FAILED(_imageDisable->loadFile((char *)params))) { + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { delete _imageDisable; _imageDisable = NULL; cmd = PARSERR_GENERIC; @@ -313,7 +313,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_FOCUS: delete _imageFocus; _imageFocus = new CBSprite(Game); - if (!_imageFocus || FAILED(_imageFocus->loadFile((char *)params))) { + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { delete _imageFocus; _imageFocus = NULL; cmd = PARSERR_GENERIC; @@ -380,7 +380,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -426,20 +426,20 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in BUTTON definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading BUTTON definition"); - return E_FAIL; + return STATUS_FAILED; } correctSize(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "BUTTON\n"); buffer->putTextIndent(indent, "{\n"); @@ -534,7 +534,7 @@ HRESULT CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -577,9 +577,9 @@ void CUIButton::correctSize() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::display(int offsetX, int offsetY) { +ERRORCODE CUIButton::display(int offsetX, int offsetY) { if (!_visible) - return S_OK; + return STATUS_OK; CUITiledImage *back = NULL; CBSprite *image = NULL; @@ -649,7 +649,7 @@ HRESULT CUIButton::display(int offsetX, int offsetY) { _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; - return S_OK; + return STATUS_OK; } @@ -666,7 +666,7 @@ void CUIButton::press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// @@ -682,7 +682,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _fontDisable = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontDisable != NULL); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -700,7 +700,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _fontHover = Game->_fontStorage->addFont(val->getString()); stack->pushBool(_fontHover != NULL); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -718,7 +718,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _fontPress = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontPress != NULL); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -736,7 +736,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _fontFocus = Game->_fontStorage->addFont(val->getString()); stack->pushBool(_fontFocus != NULL); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -748,13 +748,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageDisable; _imageDisable = new CBSprite(Game); const char *filename = stack->pop()->getString(); - if (!_imageDisable || FAILED(_imageDisable->loadFile(filename))) { + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { delete _imageDisable; _imageDisable = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -765,7 +765,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); else stack->pushString(_imageDisable->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -776,7 +776,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageDisable) stack->pushNULL(); else stack->pushNative(_imageDisable, true); - return S_OK; + return STATUS_OK; } @@ -789,13 +789,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageHover; _imageHover = new CBSprite(Game); const char *filename = stack->pop()->getString(); - if (!_imageHover || FAILED(_imageHover->loadFile(filename))) { + if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { delete _imageHover; _imageHover = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -806,7 +806,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); else stack->pushString(_imageHover->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -817,7 +817,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageHover) stack->pushNULL(); else stack->pushNative(_imageHover, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -829,13 +829,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imagePress; _imagePress = new CBSprite(Game); const char *filename = stack->pop()->getString(); - if (!_imagePress || FAILED(_imagePress->loadFile(filename))) { + if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { delete _imagePress; _imagePress = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -846,7 +846,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); else stack->pushString(_imagePress->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -857,7 +857,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imagePress) stack->pushNULL(); else stack->pushNative(_imagePress, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -869,13 +869,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageFocus; _imageFocus = new CBSprite(Game); const char *filename = stack->pop()->getString(); - if (!_imageFocus || FAILED(_imageFocus->loadFile(filename))) { + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { delete _imageFocus; _imageFocus = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -886,7 +886,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); else stack->pushString(_imageFocus->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -897,7 +897,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageFocus) stack->pushNULL(); else stack->pushNative(_imageFocus, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -912,7 +912,7 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } stack->pushNULL(); - return S_OK; + return STATUS_OK; } @@ -967,7 +967,7 @@ CScValue *CUIButton::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIButton::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -975,7 +975,7 @@ HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { int i = value->getInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _align = (TTextAlign)i; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -983,21 +983,21 @@ HRESULT CUIButton::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Focusable") == 0) { _canFocus = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pressed") == 0) { _stayPressed = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PixelPerfect") == 0) { _pixelPerfect = value->getBool(); - return S_OK; + return STATUS_OK; } else return CUIObject::scSetProperty(name, value); @@ -1011,7 +1011,7 @@ const char *CUIButton::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIButton::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIButton::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); @@ -1040,7 +1040,7 @@ HRESULT CUIButton::persist(CBPersistMgr *persistMgr) { _oneTimePressTime = 0; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index 2c16c4b5d0..a857e8ed2a 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -44,7 +44,7 @@ public: uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) void press(); - virtual HRESULT display(int offsetX = 0, int offsetY = 0); + virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); bool _press; bool _hover; void correctSize(); @@ -63,14 +63,14 @@ public: CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 0aac35a366..ca6f3416bc 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -94,19 +94,19 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::loadFile(const char *filename) { +ERRORCODE CUIEdit::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); delete [] buffer; @@ -139,7 +139,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -172,7 +172,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { Game->LOG(0, "'EDIT' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -180,7 +180,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -190,7 +190,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -200,7 +200,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -251,7 +251,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -289,20 +289,20 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in EDIT definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading EDIT definition"); - return E_FAIL; + return STATUS_FAILED; } correctSize(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "EDIT\n"); buffer->putTextIndent(indent, "{\n"); @@ -355,13 +355,13 @@ HRESULT CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// @@ -372,7 +372,7 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this _fontSelected = Game->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontSelected != NULL); - return S_OK; + return STATUS_OK; } else return CUIObject::scCallMethod(script, stack, thisStack, name); @@ -457,7 +457,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// @@ -465,7 +465,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { _selStart = value->getInt(); _selStart = MAX(_selStart, 0); _selStart = MIN((size_t)_selStart, strlen(_text)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -475,7 +475,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { _selEnd = value->getInt(); _selEnd = MAX(_selEnd, 0); _selEnd = MIN((size_t)_selEnd, strlen(_text)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -483,7 +483,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorBlinkRate") == 0) { _cursorBlinkRate = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -491,7 +491,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorChar") == 0) { setCursorChar(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -499,7 +499,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FrameWidth") == 0) { _frameWidth = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -507,7 +507,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MaxLength") == 0) { _maxLength = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -520,7 +520,7 @@ HRESULT CUIEdit::scSetProperty(const char *name, CScValue *value) { } else { setText(value->getString()); } - return S_OK; + return STATUS_OK; } else return CUIObject::scSetProperty(name, value); @@ -543,8 +543,8 @@ void CUIEdit::setCursorChar(const char *character) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::display(int offsetX, int offsetY) { - if (!_visible) return S_OK; +ERRORCODE CUIEdit::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; // hack! @@ -681,7 +681,7 @@ HRESULT CUIEdit::display(int offsetX, int offsetY) { Game->_textEncoding = OrigEncoding; - return S_OK; + return STATUS_OK; } @@ -836,7 +836,7 @@ int CUIEdit::insertChars(int pos, byte *chars, int num) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEdit::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIEdit::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); @@ -854,7 +854,7 @@ HRESULT CUIEdit::persist(CBPersistMgr *persistMgr) { _lastBlinkTime = 0; } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index f011072ae3..d47066c8f0 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -43,7 +43,7 @@ public: int deleteChars(int start, int end); bool _cursorVisible; uint32 _lastBlinkTime; - virtual HRESULT display(int offsetX, int offsetY); + virtual ERRORCODE display(int offsetX, int offsetY); virtual bool handleKeypress(Common::Event *event, bool printable = false); int _scrollOffset; int _frameWidth; @@ -56,14 +56,14 @@ public: CUIEdit(CBGame *inGame); virtual ~CUIEdit(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 3d00b9251c..faaaf375c0 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -55,19 +55,19 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::loadFile(const char *filename) { +ERRORCODE CUIEntity::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); delete [] buffer; @@ -89,7 +89,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -110,7 +110,7 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -118,7 +118,7 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -142,7 +142,7 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ENTITY: - if (FAILED(setEntity((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_SCRIPT: @@ -156,11 +156,11 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); - return E_FAIL; + return STATUS_FAILED; } correctSize(); @@ -170,11 +170,11 @@ HRESULT CUIEntity::loadBuffer(byte *buffer, bool complete) { _height = 50; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); buffer->putTextIndent(indent, "{\n"); @@ -204,29 +204,29 @@ HRESULT CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::setEntity(const char *filename) { +ERRORCODE CUIEntity::setEntity(const char *filename) { if (_entity) Game->unregisterObject(_entity); _entity = new CAdEntity(Game); - if (!_entity || FAILED(_entity->loadFile(filename))) { + if (!_entity || DID_FAIL(_entity->loadFile(filename))) { delete _entity; _entity = NULL; - return E_FAIL; + return STATUS_FAILED; } else { _entity->_nonIntMouseEvents = true; _entity->_sceneIndependent = true; _entity->makeFreezable(false); Game->registerObject(_entity); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::display(int offsetX, int offsetY) { - if (!_visible) return S_OK; +ERRORCODE CUIEntity::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; if (_entity) { _entity->_posX = offsetX + _posX; @@ -244,14 +244,14 @@ HRESULT CUIEntity::display(int offsetX, int offsetY) { _entity->_registrable = origReg; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// @@ -261,7 +261,7 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_entity) stack->pushNative(_entity, true); else stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -272,12 +272,12 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *filename = stack->pop()->getString(); - if (SUCCEEDED(setEntity(filename))) + if (DID_SUCCEED(setEntity(filename))) stack->pushBool(true); else stack->pushBool(false); - return S_OK; + return STATUS_OK; } else return CUIObject::scCallMethod(script, stack, thisStack, name); @@ -310,13 +310,13 @@ CScValue *CUIEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Freezable") == 0) { if (_entity) _entity->makeFreezable(value->getBool()); - return S_OK; + return STATUS_OK; } else return CUIObject::scSetProperty(name, value); } @@ -328,12 +328,12 @@ const char *CUIEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIEntity::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIEntity::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_entity)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index 59bcc67bf3..bef73b5e05 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -38,18 +38,18 @@ public: DECLARE_PERSISTENT(CUIEntity, CUIObject) CUIEntity(CBGame *inGame); virtual ~CUIEntity(); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - virtual HRESULT display(int offsetX = 0, int offsetY = 0); + virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); CAdEntity *_entity; - HRESULT setEntity(const char *filename); + ERRORCODE setEntity(const char *filename); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index d56e93e4b4..7ed8ffb74f 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -98,8 +98,8 @@ void CUIObject::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::display(int offsetX, int offsetY) { - return S_OK; +ERRORCODE CUIObject::display(int offsetX, int offsetY) { + return STATUS_OK; } @@ -137,7 +137,7 @@ void CUIObject::correctSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// @@ -153,7 +153,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _font = Game->_fontStorage->addFont(Val->getString()); stack->pushBool(_font != NULL); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -169,17 +169,17 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _image = NULL; if (val->isNULL()) { stack->pushBool(true); - return S_OK; + return STATUS_OK; } _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile(val->getString()))) { + if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { delete _image; _image = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -190,7 +190,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_image || !_image->_filename) stack->pushNULL(); else stack->pushString(_image->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -201,7 +201,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_image) stack->pushNULL(); else stack->pushNative(_image, true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -211,7 +211,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); focus(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -267,7 +267,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -288,7 +288,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -309,7 +309,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(true); } else stack->pushBool(false); - return S_OK; + return STATUS_OK; } else return CBObject::scCallMethod(script, stack, thisStack, name); @@ -418,13 +418,13 @@ CScValue *CUIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -432,7 +432,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParentNotify") == 0) { _parentNotify = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -440,7 +440,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { _width = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -448,7 +448,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { _height = value->getInt(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -456,7 +456,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Visible") == 0) { _visible = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -464,7 +464,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Disabled") == 0) { _disable = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -472,7 +472,7 @@ HRESULT CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { setText(value->getString()); - return S_OK; + return STATUS_OK; } else return CBObject::scSetProperty(name, value); @@ -500,7 +500,7 @@ bool CUIObject::isFocused() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { +ERRORCODE CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { // handle focus change if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { focus(); @@ -510,7 +510,7 @@ HRESULT CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::focus() { +ERRORCODE CUIObject::focus() { CUIObject *obj = this; bool disabled = false; while (obj) { @@ -532,12 +532,12 @@ HRESULT CUIObject::focus() { obj = obj->_parent; } } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::getTotalOffset(int *offsetX, int *offsetY) { +ERRORCODE CUIObject::getTotalOffset(int *offsetX, int *offsetY) { int offX = 0, offY = 0; CUIObject *obj = _parent; @@ -550,12 +550,12 @@ HRESULT CUIObject::getTotalOffset(int *offsetX, int *offsetY) { if (offsetX) *offsetX = offX; if (offsetY) *offsetY = offY; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -578,12 +578,12 @@ HRESULT CUIObject::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_visible)); persistMgr->transfer(TMEMBER(_width)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { - return E_FAIL; +ERRORCODE CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_FAILED; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 1a682527ac..92dc84eeef 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -40,15 +40,15 @@ class CBFont; class CUIObject : public CBObject { public: - HRESULT getTotalOffset(int *offsetX, int *offsetY); + ERRORCODE getTotalOffset(int *offsetX, int *offsetY); bool _canFocus; - HRESULT focus(); - virtual HRESULT handleMouse(TMouseEvent event, TMouseButton button); + ERRORCODE focus(); + virtual ERRORCODE handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) CUIObject *_parent; - virtual HRESULT display(int offsetX = 0, int offsetY = 0); + virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); virtual void correctSize(); bool _sharedFonts; bool _sharedImages; @@ -69,12 +69,12 @@ public: uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; CUIObject *_focusedWidget; - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index d5f44391ab..884d241e07 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -62,8 +62,8 @@ CUIText::~CUIText() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::display(int offsetX, int offsetY) { - if (!_visible) return S_OK; +ERRORCODE CUIText::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; CBFont *font = _font; @@ -89,25 +89,25 @@ HRESULT CUIText::display(int offsetX, int offsetY) { //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::loadFile(const char *filename) { +ERRORCODE CUIText::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); delete [] buffer; @@ -138,7 +138,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -169,7 +169,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { Game->LOG(0, "'STATIC' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -177,7 +177,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -191,7 +191,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -201,7 +201,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -250,7 +250,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -280,20 +280,20 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in STATIC definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading STATIC definition"); - return E_FAIL; + return STATUS_FAILED; } correctSize(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUIText::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "STATIC\n"); buffer->putTextIndent(indent, "{\n"); @@ -370,13 +370,13 @@ HRESULT CUIText::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// @@ -384,7 +384,7 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); sizeToFit(); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -394,7 +394,7 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this stack->correctParams(0); if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); stack->pushNULL(); - return S_OK; + return STATUS_OK; } else return CUIObject::scCallMethod(script, stack, thisStack, name); @@ -434,7 +434,7 @@ CScValue *CUIText::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIText::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -442,7 +442,7 @@ HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { int i = value->getInt(); if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; _textAlign = (TTextAlign)i; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -452,7 +452,7 @@ HRESULT CUIText::scSetProperty(const char *name, CScValue *value) { int i = value->getInt(); if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; _verticalAlign = (TVerticalAlign)i; - return S_OK; + return STATUS_OK; } else return CUIObject::scSetProperty(name, value); @@ -467,23 +467,23 @@ const char *CUIText::scToString() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIText::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_textAlign)); persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIText::sizeToFit() { +ERRORCODE CUIText::sizeToFit() { if (_font && _text) { _width = _font->getTextWidth((byte *)_text); _height = _font->getTextHeight((byte *)_text, _width); } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 383f15f47d..35428fc283 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -36,22 +36,22 @@ namespace WinterMute { class CUIText : public CUIObject { private: - HRESULT sizeToFit(); + ERRORCODE sizeToFit(); public: - virtual HRESULT display(int offsetX, int offsetY); + virtual ERRORCODE display(int offsetX, int offsetY); DECLARE_PERSISTENT(CUIText, CUIObject) CUIText(CBGame *inGame = NULL); virtual ~CUIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 4b115c98e3..05f6a0bed5 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -64,8 +64,8 @@ CUITiledImage::~CUITiledImage() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::display(int x, int y, int width, int height) { - if (!_image) return E_FAIL; +ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { + if (!_image) return STATUS_FAILED; int tileWidth = _middleMiddle.right - _middleMiddle.left; int tileHeight = _middleMiddle.bottom - _middleMiddle.top; @@ -114,24 +114,24 @@ HRESULT CUITiledImage::display(int x, int y, int width, int height) { Game->_renderer->endSpriteBatch(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::loadFile(const char *filename) { +ERRORCODE CUITiledImage::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); delete [] buffer; @@ -158,7 +158,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -187,7 +187,7 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { Game->LOG(0, "'TILED_IMAGE' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -195,13 +195,13 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_IMAGE: delete _image; _image = new CBSubFrame(Game); - if (!_image || FAILED(_image->setSurface((char *)params))) { + if (!_image || DID_FAIL(_image->setSurface((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -261,11 +261,11 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in TILED_IMAGE definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading TILED_IMAGE definition"); - return E_FAIL; + return STATUS_FAILED; } if (vTiles && hTiles) { @@ -303,11 +303,11 @@ HRESULT CUITiledImage::loadBuffer(byte *buffer, bool complete) { if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TILED_IMAGE\n"); buffer->putTextIndent(indent, "{\n"); @@ -333,7 +333,7 @@ HRESULT CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -350,7 +350,7 @@ void CUITiledImage::correctSize(int *width, int *height) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUITiledImage::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUITiledImage::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_downLeft)); @@ -364,7 +364,7 @@ HRESULT CUITiledImage::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_upMiddle)); persistMgr->transfer(TMEMBER(_upRight)); - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 583184cb51..22f472dc28 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -38,11 +38,11 @@ class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void correctSize(int *width, int *height); - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - HRESULT display(int x, int y, int width, int height); + ERRORCODE display(int x, int y, int width, int height); CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index c93a00402b..d00d07a819 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -113,7 +113,7 @@ void CUIWindow::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::display(int offsetX, int offsetY) { +ERRORCODE CUIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); @@ -141,7 +141,7 @@ HRESULT CUIWindow::display(int offsetX, int offsetY) { } if (!_visible) - return S_OK; + return STATUS_OK; if (_fadeBackground) Game->_renderer->fadeToColor(_fadeColor); @@ -202,24 +202,24 @@ HRESULT CUIWindow::display(int offsetX, int offsetY) { if (popViewport) Game->popViewport(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::loadFile(const char *filename) { +ERRORCODE CUIWindow::loadFile(const char *filename) { byte *buffer = Game->_fileManager->readWholeFile(filename); if (buffer == NULL) { Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } - HRESULT ret; + ERRORCODE ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (FAILED(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); delete [] buffer; @@ -266,7 +266,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { +ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -316,7 +316,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { Game->LOG(0, "'WINDOW' keyword expected."); - return E_FAIL; + return STATUS_FAILED; } buffer = params; } @@ -324,7 +324,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: - if (FAILED(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: @@ -338,7 +338,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; _back = new CUITiledImage(Game); - if (!_back || FAILED(_back->loadFile((char *)params))) { + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; cmd = PARSERR_GENERIC; @@ -348,7 +348,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_INACTIVE: delete _backInactive; _backInactive = new CUITiledImage(Game); - if (!_backInactive || FAILED(_backInactive->loadFile((char *)params))) { + if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { delete _backInactive; _backInactive = NULL; cmd = PARSERR_GENERIC; @@ -358,7 +358,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; _image = new CBSprite(Game); - if (!_image || FAILED(_image->loadFile((char *)params))) { + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; cmd = PARSERR_GENERIC; @@ -368,7 +368,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_INACTIVE: delete _imageInactive, _imageInactive = new CBSprite(Game); - if (!_imageInactive || FAILED(_imageInactive->loadFile((char *)params))) { + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { delete _imageInactive; _imageInactive = NULL; cmd = PARSERR_GENERIC; @@ -425,7 +425,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; _cursor = new CBSprite(Game); - if (!_cursor || FAILED(_cursor->loadFile((char *)params))) { + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; cmd = PARSERR_GENERIC; @@ -434,7 +434,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BUTTON: { CUIButton *btn = new CUIButton(Game); - if (!btn || FAILED(btn->loadBuffer(params, false))) { + if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { delete btn; btn = NULL; cmd = PARSERR_GENERIC; @@ -447,7 +447,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_STATIC: { CUIText *text = new CUIText(Game); - if (!text || FAILED(text->loadBuffer(params, false))) { + if (!text || DID_FAIL(text->loadBuffer(params, false))) { delete text; text = NULL; cmd = PARSERR_GENERIC; @@ -460,7 +460,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_EDIT: { CUIEdit *edit = new CUIEdit(Game); - if (!edit || FAILED(edit->loadBuffer(params, false))) { + if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { delete edit; edit = NULL; cmd = PARSERR_GENERIC; @@ -473,7 +473,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: { CUIWindow *win = new CUIWindow(Game); - if (!win || FAILED(win->loadBuffer(params, false))) { + if (!win || DID_FAIL(win->loadBuffer(params, false))) { delete win; win = NULL; cmd = PARSERR_GENERIC; @@ -545,18 +545,18 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { default: - if (FAILED(Game->windowLoadHook(this, (char **)&buffer, (char **)params))) { + if (DID_FAIL(Game->windowLoadHook(this, (char **)&buffer, (char **)params))) { cmd = PARSERR_GENERIC; } } } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in WINDOW definition"); - return E_FAIL; + return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading WINDOW definition"); - return E_FAIL; + return STATUS_FAILED; } correctSize(); @@ -564,18 +564,18 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { ar = ag = ab = 255; } - _alphaColor = DRGBA(ar, ag, ab, alpha); + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); if (_fadeBackground) - _fadeColor = DRGBA(fadeR, fadeG, fadeB, fadeA); + _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); _focusedWidget = NULL; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { +ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WINDOW\n"); buffer->putTextIndent(indent, "{\n"); @@ -649,12 +649,12 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); if (_fadeBackground) { - buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(_fadeColor), D3DCOLGetG(_fadeColor), D3DCOLGetB(_fadeColor)); - buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", D3DCOLGetA(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", RGBCOLGetA(_fadeColor)); } - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(_alphaColor), D3DCOLGetG(_alphaColor), D3DCOLGetB(_alphaColor)); - buffer->putTextIndent(indent + 2, "ALPHA=%d\n", D3DCOLGetA(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA=%d\n", RGBCOLGetA(_alphaColor)); buffer->putTextIndent(indent + 2, "\n"); @@ -674,31 +674,31 @@ HRESULT CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "}\n"); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::enableWidget(const char *name, bool Enable) { +ERRORCODE CUIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::showWidget(const char *name, bool Visible) { +ERRORCODE CUIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// @@ -713,13 +713,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th for (int i = 0; i < _widgets.GetSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { stack->pushNative(_widgets[i], true); - return S_OK; + return STATUS_OK; } } stack->pushNULL(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -732,7 +732,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _fontInactive = Game->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontInactive != NULL); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -744,13 +744,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _imageInactive; _imageInactive = new CBSprite(Game); const char *filename = stack->pop()->getString(); - if (!_imageInactive || FAILED(_imageInactive->loadFile(filename))) { + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { delete _imageInactive; _imageInactive = NULL; stack->pushBool(false); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -761,7 +761,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); else stack->pushString(_imageInactive->_filename); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -772,7 +772,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!_imageInactive) stack->pushNULL(); else stack->pushNative(_imageInactive, true); - return S_OK; + return STATUS_OK; } @@ -781,8 +781,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Close") == 0) { stack->correctParams(0); - stack->pushBool(SUCCEEDED(close())); - return S_OK; + stack->pushBool(DID_SUCCEED(close())); + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -793,7 +793,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th goExclusive(); script->waitFor(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -804,7 +804,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th goSystemExclusive(); script->waitFor(this); stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -815,7 +815,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _posX = (Game->_renderer->_width - _width) / 2; _posY = (Game->_renderer->_height - _height) / 2; stack->pushNULL(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -827,10 +827,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); cleanup(); if (!val->isNULL()) { - stack->pushBool(SUCCEEDED(loadFile(val->getString()))); + stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); } else stack->pushBool(true); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -847,7 +847,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th btn->_parent = this; _widgets.Add(btn); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -864,7 +864,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th sta->_parent = this; _widgets.Add(sta); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -881,7 +881,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th edi->_parent = this; _widgets.Add(edi); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -898,7 +898,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th win->_parent = this; _widgets.Add(win); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -917,8 +917,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } } stack->pushNULL(); - return S_OK; - } else if SUCCEEDED(Game->windowScriptMethodHook(this, script, stack, name)) return S_OK; + return STATUS_OK; + } else if DID_SUCCEED(Game->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; else return CUIObject::scCallMethod(script, stack, thisStack, name); } @@ -1013,13 +1013,13 @@ CScValue *CUIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { +ERRORCODE CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1027,7 +1027,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Menu") == 0) { _isMenu = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1035,7 +1035,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InGame") == 0) { _inGame = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1043,7 +1043,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0) { _pauseMusic = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1051,7 +1051,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ClipContents") == 0) { _clipContents = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1059,7 +1059,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Transparent") == 0) { _transparent = value->getBool(); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1068,7 +1068,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "FadeColor") == 0) { _fadeColor = (uint32)value->getInt(); _fadeBackground = (_fadeColor != 0); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1081,7 +1081,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { close(); _visible = true; } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1094,7 +1094,7 @@ HRESULT CUIWindow::scSetProperty(const char *name, CScValue *value) { close(); _visible = true; } - return S_OK; + return STATUS_OK; } else return CUIObject::scSetProperty(name, value); @@ -1111,7 +1111,7 @@ const char *CUIWindow::scToString() { bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return SUCCEEDED(moveFocus(!CBKeyboardState::isShiftDown())); + return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); } else { if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); else return false; @@ -1128,8 +1128,8 @@ bool CUIWindow::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - HRESULT res = CUIObject::handleMouse(event, button); +ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + ERRORCODE res = CUIObject::handleMouse(event, button); // handle window dragging if (!CBPlatform::isRectEmpty(&_dragRect)) { @@ -1158,7 +1158,7 @@ HRESULT CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::persist(CBPersistMgr *persistMgr) { +ERRORCODE CUIWindow::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); @@ -1184,12 +1184,12 @@ HRESULT CUIWindow::persist(CBPersistMgr *persistMgr) { _widgets.persist(persistMgr); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::moveFocus(bool forward) { +ERRORCODE CUIWindow::moveFocus(bool forward) { int i; bool found = false; for (i = 0; i < _widgets.GetSize(); i++) { @@ -1202,7 +1202,7 @@ HRESULT CUIWindow::moveFocus(bool forward) { if (!_focusedWidget) { if (_widgets.GetSize() > 0) i = 0; - else return S_OK; + else return STATUS_OK; } int numTries = 0; @@ -1225,13 +1225,13 @@ HRESULT CUIWindow::moveFocus(bool forward) { numTries++; } - return done ? S_OK : E_FAIL; + return done ? STATUS_OK : STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::goExclusive() { - if (_mode == WINDOW_EXCLUSIVE) return S_OK; +ERRORCODE CUIWindow::goExclusive() { + if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; if (_mode == WINDOW_NORMAL) { _ready = false; @@ -1239,14 +1239,14 @@ HRESULT CUIWindow::goExclusive() { _visible = true; _disable = false; Game->focusWindow(this); - return S_OK; - } else return E_FAIL; + return STATUS_OK; + } else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::goSystemExclusive() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return S_OK; +ERRORCODE CUIWindow::goSystemExclusive() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; makeFreezable(false); @@ -1257,12 +1257,12 @@ HRESULT CUIWindow::goSystemExclusive() { Game->focusWindow(this); Game->freeze(_pauseMusic); - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::close() { +ERRORCODE CUIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { Game->unfreeze(); } @@ -1271,12 +1271,12 @@ HRESULT CUIWindow::close() { _visible = false; _ready = true; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { +ERRORCODE CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -1288,7 +1288,7 @@ HRESULT CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { return CBObject::listen(param1, param2); } - return S_OK; + return STATUS_OK; } @@ -1302,7 +1302,7 @@ void CUIWindow::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// -HRESULT CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { +ERRORCODE CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.GetSize(); i++) { CUIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) continue; @@ -1321,7 +1321,7 @@ HRESULT CUIWindow::getWindowObjects(CBArray &objects, if (!interactiveOnly) objects.Add(control); } } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index a7492ae8ef..80e5761ddc 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -39,7 +39,7 @@ class CUIButton; class CBViewport; class CUIWindow : public CUIObject { public: - HRESULT getWindowObjects(CBArray &Objects, bool InteractiveOnly); + ERRORCODE getWindowObjects(CBArray &Objects, bool InteractiveOnly); bool _pauseMusic; void cleanup(); @@ -53,38 +53,38 @@ public: virtual bool handleMouseWheel(int delta); CUIWindow *_shieldWindow; CUIButton *_shieldButton; - HRESULT close(); - HRESULT goSystemExclusive(); - HRESULT goExclusive(); + ERRORCODE close(); + ERRORCODE goSystemExclusive(); + ERRORCODE goExclusive(); TWindowMode _mode; - HRESULT moveFocus(bool forward = true); - virtual HRESULT handleMouse(TMouseEvent Event, TMouseButton Button); + ERRORCODE moveFocus(bool forward = true); + virtual ERRORCODE handleMouse(TMouseEvent Event, TMouseButton Button); POINT _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - HRESULT showWidget(const char *name, bool visible = true); - HRESULT enableWidget(const char *name, bool enable = true); + ERRORCODE showWidget(const char *name, bool visible = true); + ERRORCODE enableWidget(const char *name, bool enable = true); RECT _titleRect; RECT _dragRect; - virtual HRESULT display(int offsetX = 0, int offsetY = 0); + virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; - HRESULT loadFile(const char *filename); - HRESULT loadBuffer(byte *buffer, bool complete = true); + ERRORCODE loadFile(const char *filename); + ERRORCODE loadBuffer(byte *buffer, bool complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; CBSprite *_imageInactive; - virtual HRESULT listen(CBScriptHolder *param1, uint32 param2); - virtual HRESULT saveAsText(CBDynBuffer *buffer, int indent); + virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); + virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual HRESULT scSetProperty(const char *name, CScValue *value); - virtual HRESULT scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index c9e85253e5..59d0241419 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -88,7 +88,7 @@ public: // Clean up void FreeExtra(); void RemoveAll(); - HRESULT persist(CBPersistMgr *persistMgr); + ERRORCODE persist(CBPersistMgr *persistMgr); // Accessing elements TYPE GetAt(int nIndex) const; @@ -346,7 +346,7 @@ void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { ///////////////////////////////////////////////////////////////////////////// template -HRESULT CBArray::persist(CBPersistMgr *persistMgr) { +ERRORCODE CBArray::persist(CBPersistMgr *persistMgr) { int i, j; if (persistMgr->_saving) { j = GetSize(); @@ -364,7 +364,7 @@ HRESULT CBArray::persist(CBPersistMgr *persistMgr) { Add(obj); } } - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 5d4acda210..efdd651154 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -37,7 +37,7 @@ class CBPersistMgr; // persistence support typedef void *(*PERSISTBUILD)(void); -typedef HRESULT(*PERSISTLOAD)(void *, CBPersistMgr *); +typedef ERRORCODE(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute @@ -50,9 +50,9 @@ namespace WinterMute { static const char _className[];\ static void* persistBuild(void);\ virtual const char* getClassName();\ - static HRESULT persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + static ERRORCODE persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ - virtual HRESULT persist(CBPersistMgr* PersistMgr);\ + virtual ERRORCODE persist(CBPersistMgr* PersistMgr);\ void* operator new (size_t size);\ void operator delete(void* p);\ @@ -63,7 +63,7 @@ namespace WinterMute { return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ }\ \ - HRESULT class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ + ERRORCODE class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ return ((class_name*)Instance)->persist(PersistMgr);\ }\ \ diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index cc1f2f3d44..cfc3db916e 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -166,7 +166,7 @@ AnsiString PathUtil::getUserDirectory() { buffer[0] = '\0'; LPITEMIDLIST pidl = NULL; LPMALLOC pMalloc; - if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + if (DID_SUCCEED(SHGetMalloc(&pMalloc))) { SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); if (pidl) { SHGetPathFromIDList(pidl, buffer); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 46e5a8da36..ca68b3c691 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -256,9 +256,9 @@ char *CBUtils::getFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { - float var_R = (D3DCOLGetR(RGBColor) / 255.0f); - float var_G = (D3DCOLGetG(RGBColor) / 255.0f); - float var_B = (D3DCOLGetB(RGBColor) / 255.0f); + float var_R = (RGBCOLGetR(RGBColor) / 255.0f); + float var_G = (RGBCOLGetG(RGBColor) / 255.0f); + float var_B = (RGBCOLGetB(RGBColor) / 255.0f); //Min. value of RGB float var_Min = MIN(var_R, var_G); @@ -328,7 +328,7 @@ uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { G = (byte)(255 * Hue2RGB(var_1, var_2, H)); B = (byte)(255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f))); } - return DRGBA(255, R, G, B); + return BYTETORGBA(255, R, G, B); } diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 1e4b25e143..51453fb34b 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -45,7 +45,7 @@ CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::SetDefaults() { +ERRORCODE CVidPlayer::SetDefaults() { _playing = false; /* _aviFile = NULL; @@ -80,7 +80,7 @@ HRESULT CVidPlayer::SetDefaults() { _currentSubtitle = 0; _showSubtitle = false; - return S_OK; + return STATUS_OK; } @@ -91,7 +91,7 @@ CVidPlayer::~CVidPlayer() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::cleanup() { +ERRORCODE CVidPlayer::cleanup() { #if 0 if (_sound) _sound->Stop(); if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); @@ -124,7 +124,7 @@ HRESULT CVidPlayer::cleanup() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { +ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 cleanup(); @@ -134,13 +134,13 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) // open file if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { Game->LOG(0, "Error opening AVI file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } // get video stream if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { Game->LOG(0, "Error finding video stream in AVI file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } _totalVideoTime = AVIStreamEndTime(_videoStream); @@ -156,7 +156,7 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) // get video format if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); - return E_FAIL; + return STATUS_FAILED; } _videoFormat = (LPBITMAPINFO)new BYTE[Size]; AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); @@ -175,19 +175,19 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) else m_VidRenderer = new CVidRendererDD(Game); - if (!m_VidRenderer || FAILED(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { + if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { Game->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); SAFE_DELETE(m_VidRenderer); - return E_FAIL; + return STATUS_FAILED; } // create sound buffer - HRESULT res; + ERRORCODE res; if (_soundAvailable) { _sound = new CBSoundAVI(Game); - if (FAILED(res = _sound->InitializeBuffer(_audioStream))) { + if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { SAFE_DELETE(_sound); _soundAvailable = false; Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); @@ -199,20 +199,20 @@ HRESULT CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) _filename = new char[strlen(filename) + 1]; if (_filename) strcpy(_filename, filename); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::update() { +ERRORCODE CVidPlayer::update() { #if 0 - if (!m_Playing) return S_OK; + if (!m_Playing) return STATUS_OK; - HRESULT res; + ERRORCODE res; if (_soundAvailable && m_Sound) { res = _sound->update(); - if (FAILED(res)) return res; + if (DID_FAIL(res)) return res; } @@ -231,7 +231,7 @@ HRESULT CVidPlayer::update() { if (CurrentTime >= _totalVideoTime) { Stop(); - return S_OK; + return STATUS_OK; } @@ -266,21 +266,21 @@ HRESULT CVidPlayer::update() { if (FrameData) { if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); else return _vidRenderer->ProcessFrame(FrameData); - } else return E_FAIL; - } else return S_OK; + } else return STATUS_FAILED; + } else return STATUS_OK; #endif return 0; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::display() { +ERRORCODE CVidPlayer::display() { #if 0 - if (!m_Playing) return S_OK; + if (!m_Playing) return STATUS_OK; - HRESULT res; + ERRORCODE res; if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); - else res = E_FAIL; + else res = STATUS_FAILED; // display subtitle if (m_ShowSubtitle) { @@ -298,9 +298,9 @@ HRESULT CVidPlayer::display() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { #if 0 - if (!_videoStream || !_vidRenderer) return E_FAIL; + if (!_videoStream || !_vidRenderer) return STATUS_FAILED; switch (Type) { case VID_PLAY_POS: @@ -335,7 +335,7 @@ HRESULT CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { if (!_videoPGF) { Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); cleanup(); - return E_FAIL; + return STATUS_FAILED; } else { Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); _slowRendering = true; @@ -354,20 +354,20 @@ HRESULT CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { if (_sound) _sound->Play(); _startTime = timeGetTime(); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::stop() { +ERRORCODE CVidPlayer::stop() { #if 0 - if (!_playing) return S_OK; + if (!_playing) return STATUS_OK; cleanup(); Game->Unfreeze(); #endif - return S_OK; + return STATUS_OK; } @@ -378,9 +378,9 @@ bool CVidPlayer::isPlaying() { ////////////////////////////////////////////////////////////////////////// -HRESULT CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { +ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { #if 0 - if (!Filename) return S_OK; + if (!Filename) return STATUS_OK; char NewFile[MAX_PATH]; char drive[_MAX_DRIVE]; @@ -396,7 +396,7 @@ HRESULT CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile DWORD Size; BYTE *Buffer = Game->m_FileManager->readWholeFile(NewFile, &Size, false); - if (Buffer == NULL) return S_OK; // no subtitles + if (Buffer == NULL) return STATUS_OK; // no subtitles LONG Start, End; @@ -464,7 +464,7 @@ HRESULT CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile delete [] Buffer; #endif - return S_OK; + return STATUS_OK; } } // end of namespace WinterMute diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index b1afa080bd..6b729cac20 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -46,23 +46,23 @@ class CVidPlayer : public CBBase { public: bool _showSubtitle; int _currentSubtitle; - HRESULT loadSubtitles(const char *filename, const char *SubtitleFile); + ERRORCODE loadSubtitles(const char *filename, const char *SubtitleFile); bool _slowRendering; bool isPlaying(); char *_filename; - HRESULT stop(); - HRESULT play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + ERRORCODE stop(); + ERRORCODE play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); uint32 _totalVideoTime; uint32 _startTime; //CVidRenderer *_vidRenderer; //CBSoundAVI *_sound; bool _soundAvailable; - HRESULT SetDefaults(); + ERRORCODE SetDefaults(); bool _playing; - HRESULT display(); - HRESULT update(); - HRESULT initialize(const char *inFilename, const char *SubtitleFile = NULL); - HRESULT cleanup(); + ERRORCODE display(); + ERRORCODE update(); + ERRORCODE initialize(const char *inFilename, const char *SubtitleFile = NULL); + ERRORCODE cleanup(); CVidPlayer(CBGame *inGame); virtual ~CVidPlayer(); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index f1c3de9283..6b71c2a2fd 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -133,23 +133,23 @@ void CVidTheoraPlayer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { +ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { cleanup(); _filename = filename; _file = Game->_fileManager->openFile(filename, true, false); - if (!_file) return E_FAIL; + if (!_file) return STATUS_FAILED; //if (Filename != _filename) CBUtils::setString(&_filename, filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else - return E_FAIL; + return STATUS_FAILED; #endif _theoraDecoder->loadStream(_file); if (!_theoraDecoder->isVideoLoaded()) - return E_FAIL; + return STATUS_FAILED; _state = THEORA_STATE_PAUSED; @@ -160,12 +160,12 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo _state = THEORA_STATE_PLAYING; _playZoom = 100; - return S_OK; + return STATUS_OK; #if 0 cleanup(); _file = Game->_fileManager->openFile(filename); - if (!_file) return E_FAIL; + if (!_file) return STATUS_FAILED; if (Filename != _filename) CBUtils::setString(&_filename, filename); @@ -233,11 +233,11 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { if (Ret < 0) { Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return E_FAIL; + return STATUS_FAILED; } if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return E_FAIL; + return STATUS_FAILED; } m_TheoraStreams++; if (m_TheoraStreams == 3) break; @@ -247,11 +247,11 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { if (Ret < 0) { Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return E_FAIL; + return STATUS_FAILED; } if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return E_FAIL; + return STATUS_FAILED; } m_VorbisStreams++; if (m_VorbisStreams == 3) break; @@ -268,7 +268,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo int Ret = BufferData(&m_OggSyncState); // someone needs more data if (Ret == 0) { Game->LOG(0, "End of file while searching for codec headers"); - return E_FAIL; + return STATUS_FAILED; } } } @@ -294,13 +294,13 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo vorbis_comment_clear(&m_VorbisComment); } - HRESULT Res = S_OK; + ERRORCODE Res = STATUS_OK; // create sound buffer if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { m_Sound = new CBSoundTheora(Game); Game->m_SoundMgr->AddSound(m_Sound); - if (FAILED(Res = m_Sound->InitializeBuffer(this))) { + if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { Game->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); @@ -318,7 +318,7 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo else m_Texture = new CBSurfaceDD(Game); - if (!m_Texture || FAILED(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { + if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { SAFE_DELETE(m_Texture); } } @@ -329,12 +329,12 @@ HRESULT CVidTheoraPlayer::initialize(const Common::String &filename, const Commo return Res; #endif - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::resetStream() { +ERRORCODE CVidTheoraPlayer::resetStream() { warning("VidTheoraPlayer::resetStream - stubbed"); #if 0 if (_sound) _sound->Stop(); @@ -343,11 +343,11 @@ HRESULT CVidTheoraPlayer::resetStream() { Initialize(m_Filename); Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { +ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) @@ -402,7 +402,7 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam _posY = (int)((Game->_renderer->_height - height) / 2); break; } - return S_OK; + return STATUS_OK; #if 0 m_State = THEORA_STATE_PLAYING; @@ -447,11 +447,11 @@ HRESULT CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGam Update(); #endif - return E_FAIL; + return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::stop() { +ERRORCODE CVidTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { @@ -462,18 +462,18 @@ HRESULT CVidTheoraPlayer::stop() { m_State = THEORA_STATE_FINISHED; if (m_FreezeGame) Game->Unfreeze(); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::update() { +ERRORCODE CVidTheoraPlayer::update() { _currentTime = _freezeGame ? Game->_liveTimer : Game->_timer; - if (!isPlaying()) return S_OK; + if (!isPlaying()) return STATUS_OK; - if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return S_OK; + if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; - if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return S_OK; + if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return STATUS_OK; if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { @@ -492,7 +492,7 @@ HRESULT CVidTheoraPlayer::update() { WriteVideo(); } } - return S_OK; + return STATUS_OK; } } // Skip the busy-loop? @@ -501,21 +501,21 @@ HRESULT CVidTheoraPlayer::update() { if (!_looping) { _state = THEORA_STATE_FINISHED; if (_freezeGame) Game->unfreeze(); - return S_OK; + return STATUS_OK; } else { resetStream(); - return S_OK; + return STATUS_OK; } } #if 0 m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; - if (!IsPlaying()) return S_OK; + if (!IsPlaying()) return STATUS_OK; - if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return S_OK; + if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; - if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return S_OK; + if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return STATUS_OK; int Counter = 0; while (true) { @@ -534,7 +534,7 @@ HRESULT CVidTheoraPlayer::update() { break; } else { ResetStream(); - return S_OK; + return STATUS_OK; } } @@ -585,7 +585,7 @@ HRESULT CVidTheoraPlayer::update() { if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -614,8 +614,8 @@ uint32 CVidTheoraPlayer::getMovieFrame() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::WriteVideo() { - if (!_texture) return E_FAIL; +ERRORCODE CVidTheoraPlayer::WriteVideo() { + if (!_texture) return STATUS_FAILED; _texture->startPixelOp(); @@ -630,7 +630,7 @@ HRESULT CVidTheoraPlayer::WriteVideo() { _texture->endPixelOp(); _videoFrameReady = true; - return S_OK; + return STATUS_OK; } void CVidTheoraPlayer::writeAlpha() { @@ -651,15 +651,15 @@ void CVidTheoraPlayer::writeAlpha() { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::display(uint32 alpha) { +ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { RECT rc; - HRESULT res; + ERRORCODE res; if (_texture && _videoFrameReady) { CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); - } else res = E_FAIL; + } else res = STATUS_FAILED; #if 0 if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->display(); #endif @@ -667,16 +667,16 @@ HRESULT CVidTheoraPlayer::display(uint32 alpha) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { +ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; _alphaImage = new CBImage(Game); - if (!_alphaImage || FAILED(_alphaImage->loadFile(filename))) { + if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; _alphaFilename = ""; - return E_FAIL; + return STATUS_FAILED; } if (_alphaFilename != filename) { @@ -686,15 +686,15 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); - if (!m_AlphaImage || FAILED(m_AlphaImage->loadFile(filename))) { + if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); - return E_FAIL; + return STATUS_FAILED; } if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, filename); m_AlphaImage->Convert(IMG_TRUECOLOR); #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -716,10 +716,10 @@ inline int intlog(int num) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::SeekToTime(uint32 time) { +ERRORCODE CVidTheoraPlayer::SeekToTime(uint32 time) { warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); #if 0 - if (!m_TheoraStreams) return E_FAIL; + if (!m_TheoraStreams) return STATUS_FAILED; float TargetTime = Time / 1000.0f; @@ -776,33 +776,33 @@ finish: //theora_packet_iskeyframe #endif - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::pause() { +ERRORCODE CVidTheoraPlayer::pause() { if (_state == THEORA_STATE_PLAYING) { _state = THEORA_STATE_PAUSED; _theoraDecoder->pauseVideo(true); - return S_OK; + return STATUS_OK; } else { - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::resume() { +ERRORCODE CVidTheoraPlayer::resume() { if (_state == THEORA_STATE_PAUSED) { _state = THEORA_STATE_PLAYING; _theoraDecoder->pauseVideo(false); - return S_OK; + return STATUS_OK; } else { - return E_FAIL; + return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { +ERRORCODE CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { //CBBase::persist(persistMgr); if (persistMgr->_saving) { @@ -828,17 +828,17 @@ HRESULT CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { initializeSimple(); } - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::initializeSimple() { - if (SUCCEEDED(initialize(_filename))) { +ERRORCODE CVidTheoraPlayer::initializeSimple() { + if (DID_SUCCEED(initialize(_filename))) { if (_alphaFilename != "") setAlphaImage(_alphaFilename); play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); } else _state = THEORA_STATE_FINISHED; - return S_OK; + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 437a72db67..6061ad3199 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -63,16 +63,16 @@ public: //CVidSubtitler *_subtitler; // control methods - HRESULT initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); - HRESULT initializeSimple(); - HRESULT update(); - HRESULT play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); - HRESULT stop(); - HRESULT display(uint32 alpha = 0xFFFFFFFF); - //HRESULT RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + ERRORCODE initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); + ERRORCODE initializeSimple(); + ERRORCODE update(); + ERRORCODE play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); + ERRORCODE stop(); + ERRORCODE display(uint32 alpha = 0xFFFFFFFF); + //ERRORCODE RenderFrame(CBSurface *Texture, yuv_buffer *yuv); - HRESULT pause(); - HRESULT resume(); + ERRORCODE pause(); + ERRORCODE resume(); bool isPlaying() { return _state == THEORA_STATE_PLAYING; @@ -99,15 +99,15 @@ public: // alpha related CBImage *_alphaImage; Common::String _alphaFilename; - HRESULT setAlphaImage(const Common::String &filename); + ERRORCODE setAlphaImage(const Common::String &filename); __inline byte getAlphaAt(int x, int y); void writeAlpha(); - HRESULT SeekToTime(uint32 Time); + ERRORCODE SeekToTime(uint32 Time); void cleanup(); - HRESULT resetStream(); + ERRORCODE resetStream(); // video properties TVideoPlayback _playbackType; @@ -137,7 +137,7 @@ private: bool _videoFrameReady; float _videobufTime; - HRESULT WriteVideo(); + ERRORCODE WriteVideo(); bool _playbackStarted; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 7745589f55..b6330ff01f 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -189,7 +189,7 @@ int WinterMuteEngine::init() { _game->initialize1(); - if (FAILED(_game->loadSettings("startup.settings"))) { + if (DID_FAIL(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); delete _game; _game = NULL; @@ -205,11 +205,11 @@ int WinterMuteEngine::init() { - HRESULT ret; + ERRORCODE ret; // initialize the renderer ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); - if (FAILED(ret)) { + if (DID_FAIL(ret)) { _game->LOG(ret, "Error initializing renderer. Exiting."); delete _game; @@ -225,7 +225,7 @@ int WinterMuteEngine::init() { // initialize sound manager (non-fatal if we fail) ret = _game->_soundMgr->initialize(); - if (FAILED(ret)) { + if (DID_FAIL(ret)) { _game->LOG(ret, "Sound is NOT available."); } @@ -233,7 +233,7 @@ int WinterMuteEngine::init() { // load game uint32 DataInitStart = CBPlatform::getTime(); - if (FAILED(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { + if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); delete _game; _game = NULL; diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index e15ba1c329..b4d2830c20 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -31,17 +31,24 @@ #include "common/scummsys.h" -//namespace WinterMute { +namespace WinterMute { -#ifndef __WIN32__ +#define BYTETORGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) + +#define RGBCOLGetB(rgb) ((byte )(rgb)) +#define RGBCOLGetG(rgb) ((byte )(((uint16)(rgb)) >> 8)) +#define RGBCOLGetR(rgb) ((byte )((rgb)>>16)) +#define RGBCOLGetA(rgb) ((byte )((rgb)>>24)) + +typedef bool ERRORCODE; + +#define DID_SUCCEED(hr) ((ERRORCODE)(hr)) +#define DID_FAIL(hr) (!((ERRORCODE)(hr))) -#define PI ((float) 3.141592653589793f) -#define DRGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define STATUS_OK (true) +#define STATUS_FAILED (false) -#define D3DCOLGetB(rgb) ((byte )(rgb)) -#define D3DCOLGetG(rgb) ((byte )(((uint16)(rgb)) >> 8)) -#define D3DCOLGetR(rgb) ((byte )((rgb)>>16)) -#define D3DCOLGetA(rgb) ((byte )((rgb)>>24)) +#ifndef __WIN32__ #define MAX_PATH 512 @@ -64,17 +71,10 @@ typedef struct tagPOINT { int32 y; } POINT, *LPPOINT; -typedef int32 HRESULT; - -#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -#define FAILED(hr) (((HRESULT)(hr)) < 0) +#endif // __WIN32__ -#define S_OK ((HRESULT)0) -//#define S_FALSE ((HRESULT)1) -#define E_FAIL ((HRESULT)-1) -#endif // __WIN32__ -//} // end of namespace WinterMute +} // end of namespace WinterMute #endif // WINTERMUTE_WINTYPES_H -- cgit v1.2.3 From 7c984d24a8cd2ebe5a7860e21cda392edada34b3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:09:15 +0200 Subject: WINTERMUTE: Change RECT -> Common::Rect and POINT-> Common::Point, completing the removal of Windows-specifics in wintypes.h --- engines/wintermute/Ad/AdGame.cpp | 8 +++--- engines/wintermute/Ad/AdInventoryBox.cpp | 3 ++- engines/wintermute/Ad/AdInventoryBox.h | 3 ++- engines/wintermute/Ad/AdItem.cpp | 6 ++--- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 6 ++--- engines/wintermute/Ad/AdSentence.h | 3 ++- engines/wintermute/Base/BActiveRect.cpp | 2 +- engines/wintermute/Base/BActiveRect.h | 2 +- engines/wintermute/Base/BDynBuffer.cpp | 4 +-- engines/wintermute/Base/BDynBuffer.h | 4 +-- engines/wintermute/Base/BFileManager.cpp | 8 +++--- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BFrame.cpp | 6 ++--- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 34 ++++++++++++------------ engines/wintermute/Base/BGame.h | 12 ++++----- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 4 +-- engines/wintermute/Base/BPersistMgr.h | 5 ++-- engines/wintermute/Base/BRegion.cpp | 6 ++--- engines/wintermute/Base/BRegion.h | 4 +-- engines/wintermute/Base/BRenderSDL.cpp | 8 +++--- engines/wintermute/Base/BRenderSDL.h | 4 +-- engines/wintermute/Base/BRenderer.cpp | 8 +++--- engines/wintermute/Base/BRenderer.h | 12 ++++----- engines/wintermute/Base/BSprite.cpp | 6 ++--- engines/wintermute/Base/BSprite.h | 4 +-- engines/wintermute/Base/BSubFrame.cpp | 6 ++--- engines/wintermute/Base/BSubFrame.h | 4 +-- engines/wintermute/Base/BSurface.cpp | 4 +-- engines/wintermute/Base/BSurface.h | 14 +++++----- engines/wintermute/Base/BSurfaceSDL.cpp | 14 +++++----- engines/wintermute/Base/BSurfaceSDL.h | 14 +++++----- engines/wintermute/Base/BViewport.cpp | 2 +- engines/wintermute/Base/BViewport.h | 4 +-- engines/wintermute/Base/PartEmitter.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/PartParticle.h | 2 +- engines/wintermute/Base/file/BDiskFile.cpp | 2 +- engines/wintermute/Base/file/BPkgFile.cpp | 2 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 2 +- engines/wintermute/Base/scriptables/ScScript.h | 2 +- engines/wintermute/PlatformSDL.cpp | 30 ++++++++++----------- engines/wintermute/PlatformSDL.h | 22 +++++++-------- engines/wintermute/Sys/SysClassRegistry.cpp | 2 +- engines/wintermute/UI/UIButton.cpp | 10 +++---- engines/wintermute/UI/UIObject.cpp | 6 ++--- engines/wintermute/UI/UITiledImage.h | 19 ++++++------- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/UI/UIWindow.h | 6 ++--- engines/wintermute/utils/PathUtil.cpp | 10 +++---- engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/utils/utils.h | 2 +- engines/wintermute/video/VidPlayer.cpp | 4 +-- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/wintypes.h | 28 ++----------------- 61 files changed, 190 insertions(+), 209 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index bf4bb41c75..69a31575cb 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1210,7 +1210,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCENE_VIEWPORT: { - RECT rc; + Common::Rect rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); @@ -1698,7 +1698,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // process scripts if (doUpdate) _scEngine->tick(); - POINT p; + Common::Point p; getMousePos(&p); _scene->update(); @@ -1900,7 +1900,7 @@ ERRORCODE CAdGame::removeSpeechDir(const char *dir) { ////////////////////////////////////////////////////////////////////////// char *CAdGame::findSpeechFile(char *stringID) { - char *ret = new char[MAX_PATH]; + char *ret = new char[MAX_PATH_LENGTH]; for (int i = 0; i < _speechDirs.GetSize(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); @@ -1924,7 +1924,7 @@ char *CAdGame::findSpeechFile(char *stringID) { ////////////////////////////////////////////////////////////////////////// bool CAdGame::validMouse() { - POINT pos; + Common::Point pos; CBPlatform::getCursorPos(&pos); return _renderer->pointInViewport(&pos); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 9cb26d8e53..3b887c4737 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -39,6 +39,7 @@ #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/PlatformSDL.h" #include "common/str.h" +#include "common/rect.h" namespace WinterMute { @@ -122,7 +123,7 @@ ERRORCODE CAdInventoryBox::display() { // display window - RECT rect = _itemsArea; + Common::Rect rect = _itemsArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); _window->display(); diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index 536f60130e..e3aec3a20b 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -30,6 +30,7 @@ #define WINTERMUTE_ADINVENTORYBOX_H #include "engines/wintermute/Base/BObject.h" +#include "common/rect.h" namespace WinterMute { class CUIButton; @@ -48,7 +49,7 @@ public: CUIButton *_closeButton; int _spacing; int _scrollOffset; - RECT _itemsArea; + Common::Rect _itemsArea; ERRORCODE listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 3b17cfd963..e2e7374f68 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -389,9 +389,9 @@ ERRORCODE CAdItem::update() { ERRORCODE CAdItem::display(int x, int y) { int width = 0; if (_currentSprite) { - RECT rc; - _currentSprite->GetBoundingRect(&rc, 0, 0); - width = rc.right - rc.left; + Common::Rect rc; + _currentSprite->getBoundingRect(&rc, 0, 0); + width = rc.width(); } _posX = x + width / 2; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 0eeadd72bc..9ab669ba14 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -397,7 +397,7 @@ ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::display() { - RECT rect = _responseArea; + Common::Rect rect = _responseArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); //_window->display(); diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index de21921fde..31076c056c 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -74,7 +74,7 @@ public: CUIWindow *_window; CUIWindow *_shieldWindow; bool _horizontal; - RECT _responseArea; + Common::Rect _responseArea; int _verticalAlign; TTextAlign _align; ERRORCODE loadFile(const char *filename); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 9362830a54..c6a3b971ed 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -621,7 +621,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { } int ar, ag, ab, aa; - char camera[MAX_PATH] = ""; + char camera[MAX_PATH_LENGTH] = ""; /* float WaypointHeight = -1.0f; */ while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -818,7 +818,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_VIEWPORT: { - RECT rc; + Common::Rect rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); @@ -1988,7 +1988,7 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { // viewport if (_viewport) { - RECT *rc = _viewport->getRect(); + Common::Rect *rc = _viewport->getRect(); buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index a8b08433c1..8ec0ca55e4 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -33,6 +33,7 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dctypes.h" // Added by ClassView +#include "common/rect.h" namespace WinterMute { class CAdTalkDef; @@ -55,7 +56,7 @@ public: TTextAlign _align; ERRORCODE display(); int _width; - POINT _pos; + Common::Point _pos; CBFont *_font; char *getNextStance(); char *getCurrentStance(); diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 86a441c317..5e1af264d9 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -86,7 +86,7 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// void CBActiveRect::clipRect() { - RECT rc; + Common::Rect rc; bool customViewport; Game->getCurrentViewportRect(&rc, &customViewport); CBRenderer *Rend = Game->_renderer; diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index a65f0cea7a..cbb617342c 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -46,7 +46,7 @@ public: CBRegion *_region; int _offsetX; int _offsetY; - RECT _rect; + Common::Rect _rect; CBActiveRect(CBGame *inGameOwner = NULL); CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index d0d4cfeafb..291712c6c8 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -160,7 +160,7 @@ char *CBDynBuffer::getString() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(LPCSTR fmt, ...) { +void CBDynBuffer::putText(const char *fmt, ...) { va_list va; va_start(va, fmt); @@ -171,7 +171,7 @@ void CBDynBuffer::putText(LPCSTR fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, LPCSTR fmt, ...) { +void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { va_list va; putText("%*s", indent, ""); diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index c29e6ac275..1826a81c30 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -37,8 +37,8 @@ namespace WinterMute { class CBDynBuffer : public CBBase { public: bool _initialized; - void putText(LPCSTR fmt, ...); - void putTextIndent(int indent, LPCSTR fmt, ...); + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 8c68bc9263..621089d803 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -311,7 +311,7 @@ ERRORCODE CBFileManager::initPaths() { AddPath(PATH_PACKAGE, pathPtr); AddPath(PATH_SINGLE, pathPtr); #else - char bundlePath[MAX_PATH]; + char bundlePath[MAX_PATH_LENGTH]; sprintf(bundlePath, "%s/../", pathPtr); AddPath(PATH_PACKAGE, bundlePath); @@ -524,7 +524,7 @@ ERRORCODE CBFileManager::registerPackage(const char *Path, const char *name, boo // TODO error("Implement RegisterPackage, this is the old one"); #if 0 - char Filename[MAX_PATH]; + char Filename[MAX_PATH_LENGTH]; sprintf(filename, "%s%s", Path, name); FILE *f = fopen(filename, "rb"); @@ -670,7 +670,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { //RestoreCurrentDir(); Common::File *ret = new Common::File(); - char filename[MAX_PATH]; + char filename[MAX_PATH_LENGTH]; for (int i = 0; i < _packagePaths.GetSize(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); @@ -696,7 +696,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { restoreCurrentDir(); Common::File *ret = NULL; - char filename[MAX_PATH]; + char filename[MAX_PATH_LENGTH]; for (int i = 0; i < _singlePaths.GetSize(); i++) { sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index c2b7cfef1a..56e969d7e7 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -221,7 +221,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { row = c / _numColumns; col = c % _numColumns; - RECT rect; + Common::Rect rect; /* l t r b */ int tileWidth; if (_wholeCell) tileWidth = _tileWidth; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 8f665a51fd..22f16a53f6 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -217,7 +217,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { - RECT rc; + Common::Rect rc; CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.GetSize(); i++) { uint32 color = _layers[i]->_color; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 9f0c89c39c..5f516c3735 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -159,7 +159,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - RECT rect; + Common::Rect rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; int hotspotX = 0, hotspotY = 0; @@ -325,11 +325,11 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { +bool CBFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); - RECT subRect; + Common::Rect subRect; for (int i = 0; i < _subframes.GetSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 55ade445e3..4c43db142d 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -46,7 +46,7 @@ public: DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; - bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 41cc62ba3e..b227a56dc8 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -578,7 +578,7 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// -void CBGame::LOG(ERRORCODE res, LPCSTR fmt, ...) { +void CBGame::LOG(ERRORCODE res, const char *fmt, ...) { uint32 secs = g_system->getMillis() / 1000; uint32 hours = secs / 3600; secs = secs % 3600; @@ -1360,7 +1360,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi x = MIN(x, _renderer->_width); y = MAX(y, 0); y = MIN(y, _renderer->_height); - POINT p; + Common::Point p; p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; @@ -1802,7 +1802,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Screenshot") == 0) { stack->correctParams(1); - char filename[MAX_PATH]; + char filename[MAX_PATH_LENGTH]; CScValue *Val = stack->pop(); @@ -2805,7 +2805,7 @@ void CBGame::quickMessage(const char *text) { ////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(LPSTR fmt, ...) { +void CBGame::quickMessageForm(char *fmt, ...) { char buff[256]; va_list va; @@ -3191,7 +3191,7 @@ ERRORCODE CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH + 1]; + char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); LOG(0, "Saving game '%s'...", filename); @@ -3242,7 +3242,7 @@ ERRORCODE CBGame::loadGame(int slot) { _loading = false; _scheduledLoadSlot = -1; - char filename[MAX_PATH + 1]; + char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); return loadGame(filename); @@ -3875,7 +3875,7 @@ AnsiString CBGame::getDataDir() { ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; - char filename[MAX_PATH + 1]; + char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return STATUS_FAILED; @@ -3897,7 +3897,7 @@ ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { ////////////////////////////////////////////////////////////////////////// bool CBGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH + 1]; + char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); @@ -3910,7 +3910,7 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::emptySaveSlot(int slot) { - char filename[MAX_PATH + 1]; + char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); CBPlatform::deleteFile(filename); @@ -3967,7 +3967,7 @@ ERRORCODE CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getCurrentViewportRect(RECT *rect, bool *custom) { +ERRORCODE CBGame::getCurrentViewportRect(Common::Rect *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { @@ -4021,7 +4021,7 @@ void CBGame::setInteractive(bool state) { ////////////////////////////////////////////////////////////////////////// void CBGame::resetMousePos() { - POINT p; + Common::Point p; p.x = _mousePos.x + _renderer->_drawOffsetX; p.y = _mousePos.y + _renderer->_drawOffsetY; @@ -4048,7 +4048,7 @@ ERRORCODE CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::displayIndicator() { if (_saveLoadImage) { - RECT rc; + Common::Rect rc; CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); @@ -4209,7 +4209,7 @@ ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { _renderer->_active = activate; if (refreshMouse) { - POINT p; + Common::Point p; getMousePos(&p); setActiveObject(_renderer->getObjectAt(p.x, p.y)); } @@ -4407,7 +4407,7 @@ CBDebugger *CBGame::getDebugMgr() { ////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(POINT *pos) { +void CBGame::getMousePos(Common::Point *pos) { CBPlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; @@ -4417,7 +4417,7 @@ void CBGame::getMousePos(POINT *pos) { // Windows can squish maximized window if it's larger than desktop // so we need to modify mouse position appropriately (tnx mRax) if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { - RECT rc; + Common::Rect rc; ::GetClientRect(_renderer->_window, &rc); Pos->x *= Game->_renderer->_realWidth; Pos->x /= (rc.right - rc.left); @@ -4434,7 +4434,7 @@ void CBGame::getMousePos(POINT *pos) { pos->x = MIN(_mouseLockRect.right, pos->x); pos->y = MIN(_mouseLockRect.bottom, pos->y); - POINT newPos = *pos; + Common::Point newPos = *pos; newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; @@ -4481,7 +4481,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { maxMoveY = 16; #endif - POINT pos; + Common::Point pos; CBPlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 44b5b4a86d..867700db9b 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -91,8 +91,8 @@ public: virtual ERRORCODE miniUpdate(); - void getMousePos(POINT *Pos); - RECT _mouseLockRect; + void getMousePos(Common::Point *Pos); + Common::Rect _mouseLockRect; bool _shuttingDown; @@ -172,7 +172,7 @@ public: CBTransitionMgr *_transMgr; CBDebugger *getDebugMgr(); - void LOG(ERRORCODE res, LPCSTR fmt, ...); + void LOG(ERRORCODE res, const char *fmt, ...); CBRenderer *_renderer; CBSoundMgr *_soundMgr; @@ -310,12 +310,12 @@ public: uint32 _liveTimerLast; CBObject *_capturedObject; - POINT _mousePos; + Common::Point _mousePos; bool validObject(CBObject *object); ERRORCODE unregisterObject(CBObject *object); ERRORCODE registerObject(CBObject *object); void quickMessage(const char *text); - void quickMessageForm(LPSTR fmt, ...); + void quickMessageForm(char *fmt, ...); ERRORCODE displayQuickMsg(); uint32 _fps; ERRORCODE updateMusicCrossfade(); @@ -334,7 +334,7 @@ public: virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); ERRORCODE getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - ERRORCODE getCurrentViewportRect(RECT *rect, bool *custom = NULL); + ERRORCODE getCurrentViewportRect(Common::Rect *rect, bool *custom = NULL); ERRORCODE popViewport(); ERRORCODE pushViewport(CBViewport *Viewport); ERRORCODE setActiveObject(CBObject *Obj); diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index ff876a3035..3a82cbe128 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -103,7 +103,7 @@ public: bool _registrable; bool _zoomable; bool _shadowable; - RECT _rect; + Common::Rect _rect; bool _rectSet; int _iD; bool _movable; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index bbe532d819..412aa88312 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -671,7 +671,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -ERRORCODE CBPersistMgr::transfer(const char *name, RECT *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Common::Rect *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -694,7 +694,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, RECT *val) { ////////////////////////////////////////////////////////////////////////// // POINT -ERRORCODE CBPersistMgr::transfer(const char *name, POINT *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Common::Point *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 9559dc7490..dc4c2173de 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -35,6 +35,7 @@ #include "common/stream.h" #include "common/str.h" #include "common/system.h" +#include "common/rect.h" namespace WinterMute { @@ -84,8 +85,8 @@ public: ERRORCODE transfer(const char *name, double *val); ERRORCODE transfer(const char *name, bool *val); ERRORCODE transfer(const char *name, byte *val); - ERRORCODE transfer(const char *name, RECT *val); - ERRORCODE transfer(const char *name, POINT *val); + ERRORCODE transfer(const char *name, Common::Rect *val); + ERRORCODE transfer(const char *name, Common::Point *val); ERRORCODE transfer(const char *name, const char **val); ERRORCODE transfer(const char *name, char **val); ERRORCODE transfer(const char *name, Common::String *val); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 32eb383de0..45b202e35f 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -79,11 +79,11 @@ bool CBRegion::createRegion() { bool CBRegion::pointInRegion(int x, int y) { if (_points.GetSize() < 3) return false; - POINT pt; + Common::Point pt; pt.x = x; pt.y = y; - RECT rect; + Common::Rect rect; rect.left = x - 1; rect.right = x + 2; rect.top = y - 1; @@ -465,7 +465,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::getBoundingRect(RECT *rect) { +ERRORCODE CBRegion::getBoundingRect(Common::Rect *rect) { if (_points.GetSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 5f6b79e17f..4aa491d7c9 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -41,7 +41,7 @@ public: int _lastMimicY; void cleanup(); ERRORCODE mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - ERRORCODE getBoundingRect(RECT *rect); + ERRORCODE getBoundingRect(Common::Rect *rect); bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; @@ -52,7 +52,7 @@ public: bool createRegion(); ERRORCODE loadFile(const char *filename); ERRORCODE loadBuffer(byte *buffer, bool complete = true); - RECT _rect; + Common::Rect _rect; CBArray _points; virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index e2ddc38d98..323c6cc7be 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -298,7 +298,7 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setWidth(rect->width()); fillRect.setHeight(rect->height()); } else { - RECT rc; + Common::Rect rc; Game->getCurrentViewportRect(&rc); fillRect.left = (int16)rc.left; fillRect.top = (int16)rc.top; @@ -501,7 +501,7 @@ ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - POINT point1, point2; + Common::Point point1, point2; point1.x = x1; point1.y = y1; pointToScreen(&point1); @@ -605,7 +605,7 @@ void CBRenderSDL::modTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointFromScreen(POINT *point) { +void CBRenderSDL::pointFromScreen(Common::Point *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -617,7 +617,7 @@ void CBRenderSDL::pointFromScreen(POINT *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointToScreen(POINT *point) { +void CBRenderSDL::pointToScreen(Common::Point *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index f7659e3e84..6c88feb059 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -86,8 +86,8 @@ public: ERRORCODE setViewport(int left, int top, int right, int bottom); void modTargetRect(Common::Rect *rect); - void pointFromScreen(POINT *point); - void pointToScreen(POINT *point); + void pointFromScreen(Common::Point *point); + void pointToScreen(Common::Point *point); void dumpData(const char *filename); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 9038d8364e..a3774e3770 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -68,7 +68,7 @@ void CBRenderer::initLoop() { ////////////////////////////////////////////////////////////////////// CBObject *CBRenderer::getObjectAt(int x, int y) { - POINT point; + Common::Point point; point.x = x; point.y = y; @@ -203,7 +203,7 @@ ERRORCODE CBRenderer::setScreenViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setViewport(RECT *rect) { +ERRORCODE CBRenderer::setViewport(Common::Rect *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -221,7 +221,7 @@ CBImage *CBRenderer::takeScreenshot() { ERRORCODE CBRenderer::clipCursor() { /* if (!_windowed) { - RECT rc; + Common::Rect rc; GetWindowRect(_window, &rc); // if "maintain aspect ratio" is in effect, lock mouse to visible area @@ -245,7 +245,7 @@ ERRORCODE CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(POINT *p) { +bool CBRenderer::pointInViewport(Common::Point *p) { if (p->x < _drawOffsetX) return false; if (p->y < _drawOffsetY) return false; if (p->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 5d290eedd6..c32a4d6bc1 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -50,7 +50,7 @@ public: virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); virtual ERRORCODE setViewport(int left, int top, int right, int bottom); - virtual ERRORCODE setViewport(RECT *Rect); + virtual ERRORCODE setViewport(Common::Rect *Rect); virtual ERRORCODE setScreenViewport(); virtual ERRORCODE fade(uint16 Alpha); virtual ERRORCODE fadeToColor(uint32 Color, Common::Rect *rect = NULL); @@ -101,17 +101,17 @@ public: virtual ERRORCODE endSpriteBatch() { return STATUS_OK; }; - bool pointInViewport(POINT *P); + bool pointInViewport(Common::Point *P); uint32 _forceAlphaColor; uint32 _window; uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; - RECT _windowRect; - RECT _viewportRect; - RECT _screenRect; - RECT _monitorRect; + Common::Rect _windowRect; + Common::Rect _viewportRect; + Common::Rect _screenRect; + Common::Rect _monitorRect; int _bPP; int _height; int _width; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6d595ffbe8..349cb1e2f5 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -413,13 +413,13 @@ CBSurface *CBSprite::getSurface() { } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::GetBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { +bool CBSprite::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); for (int i = 0; i < _frames.GetSize(); i++) { - RECT frame; - RECT temp; + Common::Rect frame; + Common::Rect temp; CBPlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); CBPlatform::unionRect(rect, &temp, &frame); diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index a9ca84d358..2b705b689a 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -53,7 +53,7 @@ public: DECLARE_PERSISTENT(CBSprite, CBScriptHolder) bool _editorAllFrames; - bool GetBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; ERRORCODE display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); @@ -72,7 +72,7 @@ public: ERRORCODE draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, RECT *rect = NULL); + ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Common::Rect *rect = NULL); CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index af7bb128a5..4a1a5ec1f0 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -110,7 +110,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - RECT rect; + Common::Rect rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; @@ -233,7 +233,7 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(LPRECT rect, int x, int y, float scaleX, float scaleY) { +bool CBSubFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; float ratioX = scaleX / 100.0f; @@ -259,7 +259,7 @@ ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) if (_transparent != 0xFFFF00FF) buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - RECT rect; + Common::Rect rect; CBPlatform::setRectEmpty(&rect); if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::equalRect(&rect, &_rect)) diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index b1503e3506..a13a5fa196 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -53,12 +53,12 @@ public: virtual ~CBSubFrame(); ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(LPRECT rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; int _hotspotY; uint32 _alpha; - RECT _rect; + Common::Rect _rect; bool _cKDefault; byte _cKRed; diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 0cf5292afb..dd7f17a895 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -76,12 +76,12 @@ bool CBSurface::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayHalfTrans(int x, int y, RECT rect) { +ERRORCODE CBSurface::displayHalfTrans(int x, int y, Common::Rect rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 6a4dd89af6..4351e163e5 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -52,14 +52,14 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual ERRORCODE displayHalfTrans(int x, int y, RECT rect); + virtual ERRORCODE displayHalfTrans(int x, int y, Common::Rect rect); virtual bool isTransparentAt(int x, int y); - virtual ERRORCODE displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual ERRORCODE display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual ERRORCODE displayZoom(int x, int y, RECT rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual ERRORCODE displayZoom(int x, int y, Common::Rect rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual ERRORCODE restore(); virtual ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual ERRORCODE create(int Width, int Height); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 27bd7fd334..7bddcdf04c 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -423,40 +423,40 @@ ERRORCODE CBSurfaceSDL::endPixelOp() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::display(int x, int y, RECT rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, RECT rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, RECT rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); if (renderer->_forceAlphaColor != 0) alpha = renderer->_forceAlphaColor; diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 544473ced5..91a75f27b7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -52,12 +52,12 @@ public: ERRORCODE endPixelOp(); - ERRORCODE displayTransZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTrans(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransOffset(int x, int y, RECT rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - ERRORCODE display(int x, int y, RECT rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayZoom(int x, int y, RECT rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransform(int x, int y, int hotX, int hotY, RECT Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); @@ -78,7 +78,7 @@ public: private: Graphics::Surface *_surface; - ERRORCODE drawSprite(int x, int y, RECT *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + ERRORCODE drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index 7542e6bbfc..ad89bc0697 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -79,7 +79,7 @@ ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noC ////////////////////////////////////////////////////////////////////////// -RECT *CBViewport::getRect() { +Common::Rect *CBViewport::getRect() { return &_rect; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index f2e960943a..0ace6791bc 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -38,7 +38,7 @@ class CBViewport : public CBBase { public: int getHeight(); int getWidth(); - RECT *getRect(); + Common::Rect *getRect(); ERRORCODE setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; @@ -47,7 +47,7 @@ public: CBViewport(CBGame *inGame = NULL); virtual ~CBViewport(); private: - RECT _rect; + Common::Rect _rect; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 984ef78820..2f72d96103 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -82,7 +82,7 @@ public: int _maxBatches; int _batchesGenerated; - RECT _border; + Common::Rect _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 0cf05e88a1..9d667bdca8 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -124,7 +124,7 @@ ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint3 // particle hit the border if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - POINT p; + Common::Point p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; if (!CBPlatform::ptInRect(&_border, p)) diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 3f495a432b..229bc11935 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -57,7 +57,7 @@ public: int _alpha1; int _alpha2; - RECT _border; + Common::Rect _border; Vector2 _pos; float _posZ; Vector2 _velocity; diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index f2706bbfb5..1e9ec96e66 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -46,7 +46,7 @@ void correctSlashes(char *fileName) { } Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { - char fullPath[MAX_PATH]; + char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp index 08a92b52f6..fcacfdfd40 100644 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ b/engines/wintermute/Base/file/BPkgFile.cpp @@ -68,7 +68,7 @@ public: Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { CBFileEntry *fileEntry; Common::SeekableReadStream *file = NULL; - char fileName[MAX_PATH]; + char fileName[MAX_PATH_LENGTH]; strcpy(fileName, filename.c_str()); // correct slashes diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 6f31a424c0..a7a844fc9d 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -69,7 +69,7 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename); delete [] tempFilename; - char slotFilename[MAX_PATH + 1]; + char slotFilename[MAX_PATH_LENGTH + 1]; Game->getSaveSlotFilename(slot, slotFilename); CBPersistMgr *pm = new CBPersistMgr(Game); if (!pm) return STATUS_FAILED; diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index f4bb610c64..1ddec89ee6 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -246,7 +246,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "Split") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - char separators[MAX_PATH] = ","; + char separators[MAX_PATH_LENGTH] = ","; if (!val->isNULL()) strcpy(separators, val->getString()); CSXArray *array = new CSXArray(Game); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 19f1fb29a1..0abd9a1ff9 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1178,7 +1178,7 @@ ERRORCODE CScScript::run() { ////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(LPCSTR fmt, ...) { +void CScScript::runtimeError(const char *fmt, ...) { char buff[256]; va_list va; diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 6bd1d26142..6635970dc5 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -75,7 +75,7 @@ public: CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(CScScript, CBBase) - void runtimeError(LPCSTR fmt, ...); + void runtimeError(const char *fmt, ...); ERRORCODE run(); ERRORCODE finish(bool includingThreads = false); ERRORCODE sleep(uint32 duration); diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index cbfa93c488..9803ffb928 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -166,7 +166,7 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // Win32 API bindings ////////////////////////////////////////////////////////////////////////// -void CBPlatform::outputDebugString(LPCSTR lpOutputString) { +void CBPlatform::outputDebugString(const char *lpOutputString) { /* #ifdef __WIN32__ ::OutputDebugString(lpOutputString); @@ -181,7 +181,7 @@ uint32 CBPlatform::getTime() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::getCursorPos(LPPOINT lpPoint) { +bool CBPlatform::getCursorPos(Common::Point *lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); @@ -197,7 +197,7 @@ bool CBPlatform::getCursorPos(LPPOINT lpPoint) { bool CBPlatform::setCursorPos(int X, int Y) { CBRenderSDL *renderer = static_cast(Game->_renderer); - POINT p; + Common::Point p; p.x = X; p.y = Y; renderer->pointToScreen(&p); @@ -245,23 +245,23 @@ bool CBPlatform::setForegroundWindow() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRectEmpty(LPRECT lprc) { +bool CBPlatform::setRectEmpty(Common::Rect *lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; return true; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::isRectEmpty(const LPRECT lprc) { +bool CBPlatform::isRectEmpty(const Common::Rect *lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ptInRect(LPRECT lprc, POINT p) { +bool CBPlatform::ptInRect(Common::Rect *lprc, Common::Point p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRect(LPRECT lprc, int left, int top, int right, int bottom) { +bool CBPlatform::setRect(Common::Rect *lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; @@ -271,7 +271,7 @@ bool CBPlatform::setRect(LPRECT lprc, int left, int top, int right, int bottom) } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::intersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2) { +bool CBPlatform::intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2) { if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { @@ -287,7 +287,7 @@ bool CBPlatform::intersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRE } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::unionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { +bool CBPlatform::unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2) { if (isRectEmpty(lprcSrc1)) { if (isRectEmpty(lprcSrc2)) { setRectEmpty(lprcDst); @@ -310,7 +310,7 @@ bool CBPlatform::unionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyRect(LPRECT lprcDst, RECT *lprcSrc) { +bool CBPlatform::copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc) { if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; @@ -318,7 +318,7 @@ bool CBPlatform::copyRect(LPRECT lprcDst, RECT *lprcSrc) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::offsetRect(LPRECT lprc, int dx, int dy) { +bool CBPlatform::offsetRect(Common::Rect *lprc, int dx, int dy) { if (lprc == NULL) return false; lprc->left += dx; @@ -330,7 +330,7 @@ bool CBPlatform::offsetRect(LPRECT lprc, int dx, int dy) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::equalRect(LPRECT rect1, LPRECT rect2) { +bool CBPlatform::equalRect(Common::Rect *rect1, Common::Rect *rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } @@ -339,9 +339,9 @@ bool CBPlatform::equalRect(LPRECT rect1, LPRECT rect2) { AnsiString CBPlatform::getSystemFontPath() { #ifdef __WIN32__ // we're looking for something like "c:\windows\fonts\"; - char winDir[MAX_PATH + 1]; - winDir[MAX_PATH] = '\0'; - ::GetWindowsDirectory(winDir, MAX_PATH); + char winDir[MAX_PATH_LENGTH + 1]; + winDir[MAX_PATH_LENGTH] = '\0'; + ::GetWindowsDirectory(winDir, MAX_PATH_LENGTH); return PathUtil::Combine(AnsiString(winDir), "fonts"); #else // !PORTME diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 6b8879328a..fc2e60a7a4 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -48,9 +48,9 @@ public: static AnsiString getPlatformName(); // Win32 API bindings - static void outputDebugString(LPCSTR lpOutputString); + static void outputDebugString(const char *lpOutputString); static uint32 getTime(); - static bool getCursorPos(LPPOINT lpPoint); + static bool getCursorPos(Common::Point *lpPoint); static bool setCursorPos(int X, int Y); static bool showWindow(int nCmdShow); static bool deleteFile(const char *lpFileName); @@ -59,15 +59,15 @@ public: static bool releaseCapture(); static bool setForegroundWindow(); - static bool setRectEmpty(LPRECT lprc); - static bool isRectEmpty(const LPRECT lprc); - static bool ptInRect(LPRECT lprc, POINT p); - static bool setRect(LPRECT lprc, int left, int top, int right, int bottom); - static bool intersectRect(LPRECT lprcDst, const LPRECT lprcSrc1, const LPRECT lprcSrc2); - static bool unionRect(LPRECT lprcDst, RECT *lprcSrc1, RECT *lprcSrc2); - static bool copyRect(LPRECT lprcDst, RECT *lprcSrc); - static bool offsetRect(LPRECT lprc, int dx, int dy); - static bool equalRect(LPRECT rect1, LPRECT rect2); + static bool setRectEmpty(Common::Rect *lprc); + static bool isRectEmpty(const Common::Rect *lprc); + static bool ptInRect(Common::Rect *lprc, Common::Point p); + static bool setRect(Common::Rect *lprc, int left, int top, int right, int bottom); + static bool intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2); + static bool unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2); + static bool copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc); + static bool offsetRect(Common::Rect *lprc, int dx, int dy); + static bool equalRect(Common::Rect *rect1, Common::Rect *rect2); // string functions diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 1ebcccf6e1..4bdb571df4 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -78,7 +78,7 @@ bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { if (it == _classes.end()) return false; if (classObj->getNumInstances() != 0) { - char str[MAX_PATH]; + char str[MAX_PATH_LENGTH]; sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); CBPlatform::outputDebugString(str); } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 2dfb688e46..930157ebf5 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -539,7 +539,7 @@ ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// void CUIButton::correctSize() { - RECT rect; + Common::Rect rect; CBSprite *img = NULL; if (_image) img = _image; @@ -550,14 +550,14 @@ void CUIButton::correctSize() { if (_width <= 0) { if (img) { - img->GetBoundingRect(&rect, 0, 0); + img->getBoundingRect(&rect, 0, 0); _width = rect.right - rect.left; } else _width = 100; } if (_height <= 0) { if (img) { - img->GetBoundingRect(&rect, 0, 0); + img->getBoundingRect(&rect, 0, 0); _height = rect.bottom - rect.top; } } @@ -623,8 +623,8 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { int imageY = offsetY + _posY; if (image && _centerImage) { - RECT rc; - image->GetBoundingRect(&rc, 0, 0); + Common::Rect rc; + image->getBoundingRect(&rc, 0, 0); imageX += (_width - (rc.right - rc.left)) / 2; imageY += (_height - (rc.bottom - rc.top)) / 2; } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 7ed8ffb74f..1a00748a98 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -113,18 +113,18 @@ void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObje ////////////////////////////////////////////////////////////////////////// void CUIObject::correctSize() { - RECT rect; + Common::Rect rect; if (_width <= 0) { if (_image) { - _image->GetBoundingRect(&rect, 0, 0); + _image->getBoundingRect(&rect, 0, 0); _width = rect.right - rect.left; } else _width = 100; } if (_height <= 0) { if (_image) { - _image->GetBoundingRect(&rect, 0, 0); + _image->getBoundingRect(&rect, 0, 0); _height = rect.bottom - rect.top; } } diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 22f472dc28..297a868ed0 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -31,6 +31,7 @@ #include "UIObject.h" +#include "common/rect.h" namespace WinterMute { class CBSubFrame; @@ -46,15 +47,15 @@ public: CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; - RECT _upLeft; - RECT _upMiddle; - RECT _upRight; - RECT _middleLeft; - RECT _middleMiddle; - RECT _middleRight; - RECT _downLeft; - RECT _downMiddle; - RECT _downRight; + Common::Rect _upLeft; + Common::Rect _upMiddle; + Common::Rect _upRight; + Common::Rect _middleLeft; + Common::Rect _middleMiddle; + Common::Rect _middleRight; + Common::Rect _downLeft; + Common::Rect _downMiddle; + Common::Rect _downRight; }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index d00d07a819..5f63390519 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1135,7 +1135,7 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { if (!CBPlatform::isRectEmpty(&_dragRect)) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - RECT dragRect = _dragRect; + Common::Rect dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 80e5761ddc..79e1ce09be 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -59,14 +59,14 @@ public: TWindowMode _mode; ERRORCODE moveFocus(bool forward = true); virtual ERRORCODE handleMouse(TMouseEvent Event, TMouseButton Button); - POINT _dragFrom; + Common::Point _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; ERRORCODE showWidget(const char *name, bool visible = true); ERRORCODE enableWidget(const char *name, bool enable = true); - RECT _titleRect; - RECT _dragRect; + Common::Rect _titleRect; + Common::Rect _dragRect; virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index cfc3db916e..5c12a71c33 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -116,8 +116,8 @@ AnsiString PathUtil::getSafeLogFileName() { AnsiString logFileName = getUserDirectory(); #ifdef __WIN32__ - char moduleName[MAX_PATH]; - ::GetModuleFileName(NULL, moduleName, MAX_PATH); + char moduleName[MAX_PATH_LENGTH]; + ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; fileName = Combine("/Wintermute Engine/Logs/", fileName); @@ -162,7 +162,7 @@ AnsiString PathUtil::getUserDirectory() { AnsiString userDir = "./"; #if 0 #ifdef __WIN32__ - char buffer[MAX_PATH]; + char buffer[MAX_PATH_LENGTH]; buffer[0] = '\0'; LPITEMIDLIST pidl = NULL; LPMALLOC pMalloc; @@ -178,14 +178,14 @@ AnsiString PathUtil::getUserDirectory() { FSRef fileRef; OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); if (error == noErr) { - char buffer[MAX_PATH]; + char buffer[MAX_PATH_LENGTH]; error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); if (error == noErr) userDir = buffer; } #elif __IPHONEOS__ - char path[MAX_PATH]; + char path[MAX_PATH_LENGTH]; IOS_GetDataDir(path); userDir = AnsiString(path); #endif diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ca68b3c691..d672656973 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -45,7 +45,7 @@ static inline unsigned Sqr(int x) { ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::clip(int *destX, int *destY, RECT *srcRect, RECT *destRect) { +void CBUtils::clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect) { // If it's partly off the right side of the screen if (*destX + (srcRect->right - srcRect->left) > destRect->right) srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 52678a3e9f..50665dad1f 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -37,7 +37,7 @@ class CBGame; class CBUtils { public: - static void clip(int *DestX, int *DestY, RECT *SrcRect, RECT *DestRect); + static void clip(int *DestX, int *DestY, Common::Rect *SrcRect, Common::Rect *DestRect); static void swap(int *a, int *b); static bool strBeginsI(const char *String, const char *Fragment); static float normalizeAngle(float Angle); diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 51453fb34b..7fa8e6e218 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -128,7 +128,7 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil #if 0 cleanup(); - char Filename[MAX_PATH]; + char Filename[MAX_PATH_LENGTH]; Game->_fileManager->GetFullPath(inFilename, filename); // open file @@ -382,7 +382,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi #if 0 if (!Filename) return STATUS_OK; - char NewFile[MAX_PATH]; + char NewFile[MAX_PATH_LENGTH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 6b71c2a2fd..c57049e177 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -652,7 +652,7 @@ void CVidTheoraPlayer::writeAlpha() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { - RECT rc; + Common::Rect rc; ERRORCODE res; if (_texture && _videoFrameReady) { diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index b4d2830c20..678fb6bb6b 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -30,6 +30,7 @@ #define WINTERMUTE_WINTYPES_H #include "common/scummsys.h" +#include "common/rect.h" namespace WinterMute { @@ -48,32 +49,7 @@ typedef bool ERRORCODE; #define STATUS_OK (true) #define STATUS_FAILED (false) -#ifndef __WIN32__ - -#define MAX_PATH 512 - -typedef char *NPSTR, *LPSTR, *PSTR; -typedef PSTR *PZPSTR; -typedef const PSTR *PCZPSTR; -typedef const char *LPCSTR, *PCSTR; -typedef PCSTR *PZPCSTR; - -typedef struct tagRECT { - int32 left; - int32 top; - int32 right; - int32 bottom; -} RECT, *LPRECT; - - -typedef struct tagPOINT { - int32 x; - int32 y; -} POINT, *LPPOINT; - -#endif // __WIN32__ - - +#define MAX_PATH_LENGTH 512 } // end of namespace WinterMute -- cgit v1.2.3 From 01d6ff21212a2d323717a3a1dc9e7b72cdd6adb7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:17:28 +0200 Subject: WINTERMUTE: Cleanup and simplify StringUtil a bit. --- engines/wintermute/Base/BStringTable.cpp | 10 +++--- engines/wintermute/Base/scriptables/SXString.cpp | 4 +-- engines/wintermute/Base/scriptables/ScEngine.cpp | 2 +- engines/wintermute/utils/PathUtil.cpp | 2 +- engines/wintermute/utils/StringUtil.cpp | 40 +----------------------- engines/wintermute/utils/StringUtil.h | 4 --- 6 files changed, 10 insertions(+), 52 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 8d8b6b0fd1..9098994054 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -58,13 +58,13 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report return STATUS_OK; } - Common::String final_key = key; - StringUtil::toLowerCase(final_key); + Common::String finalKey = key; + finalKey.toLowercase(); - _stringsIter = _strings.find(final_key); - if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + _stringsIter = _strings.find(finalKey); + if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); - _strings[final_key] = val; + _strings[finalKey] = val; return STATUS_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 1ddec89ee6..2ad8a36ff7 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -181,7 +181,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * else str = StringUtil::ansiToWide(_string); - StringUtil::toUpperCase(str); + str.toUppercase(); if (Game->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(str).c_str()); @@ -203,7 +203,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * else str = StringUtil::ansiToWide(_string); - StringUtil::toLowerCase(str); + str.toLowercase(); if (Game->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(str).c_str()); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 639fd0d6cd..089978ece3 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -658,7 +658,7 @@ void CScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) return; AnsiString fileName = filename; - StringUtil::toLowerCase(fileName); + fileName.toLowercase(); _scriptTimes[fileName] += time; } diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index 5c12a71c33..b148c80300 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -47,7 +47,7 @@ AnsiString PathUtil::unifySeparators(const AnsiString &path) { ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::normalizeFileName(const AnsiString &path) { AnsiString newPath = unifySeparators(path); - StringUtil::toLowerCase(newPath); + newPath.toLowercase(); return newPath; } diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index 53ad4c8add..c5ad025939 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -33,35 +33,9 @@ namespace WinterMute { -////////////////////////////////////////////////////////////////////////// -void StringUtil::toLowerCase(AnsiString &str) { - str.toLowercase(); -} - -////////////////////////////////////////////////////////////////////////// -/*void StringUtil::toLowerCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towlower); -}*/ - -////////////////////////////////////////////////////////////////////////// -void StringUtil::toUpperCase(AnsiString &str) { - str.toUppercase(); -} - -////////////////////////////////////////////////////////////////////////// -/*void StringUtil::toUpperCase(WideString &str) { - std::transform(str.begin(), str.end(), str.begin(), ::towupper); -}*/ - ////////////////////////////////////////////////////////////////////////// bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { - AnsiString str1lc = str1; - AnsiString str2lc = str2; - - toLowerCase(str1lc); - toLowerCase(str2lc); - - return (str1lc == str2lc); + return (str1.compareToIgnoreCase(str2) == 0); } ////////////////////////////////////////////////////////////////////////// @@ -369,33 +343,21 @@ int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, siz ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::toString(size_t val) { - /* std::ostringstream str; - str << val; - return str.str();*/ return Common::String::format("%u", (uint32)val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::toString(int val) { - /* std::ostringstream str; - str << val; - return str.str();*/ return Common::String::format("%d", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::toString(float val) { - /* std::ostringstream str; - str << val; - return str.str();*/ return Common::String::format("%f", val); } ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::toString(double val) { - /* std::ostringstream str; - str << val; - return str.str();*/ return Common::String::format("%f", val); } diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h index e06551b09a..794007276b 100644 --- a/engines/wintermute/utils/StringUtil.h +++ b/engines/wintermute/utils/StringUtil.h @@ -35,10 +35,6 @@ namespace WinterMute { class StringUtil { public: - static void toLowerCase(AnsiString &str); - //static void toLowerCase(WideString &str); - static void toUpperCase(AnsiString &str); - //static void toUpperCase(WideString &str); static bool compareNoCase(const AnsiString &str1, const AnsiString &str2); //static bool compareNoCase(const WideString &str1, const WideString &str2); static WideString utf8ToWide(const Utf8String &Utf8Str); -- cgit v1.2.3 From 99ed2b2ae1c57419fd22f766fec5784c9a01ea19 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:21:48 +0200 Subject: WINTERMUTE: Remove the rest of the WIN32-specifics --- engines/wintermute/Base/BGame.cpp | 8 +- engines/wintermute/Base/BRegistry.cpp | 14 -- engines/wintermute/Base/scriptables/ScScript.cpp | 189 ----------------------- engines/wintermute/Base/scriptables/ScScript.h | 7 - engines/wintermute/PlatformSDL.cpp | 6 +- engines/wintermute/UI/UIEdit.cpp | 5 +- engines/wintermute/utils/PathUtil.cpp | 6 +- 7 files changed, 9 insertions(+), 226 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index b227a56dc8..26afb8a7d9 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3736,15 +3736,11 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { stopVideo(); return true; } -#ifdef __WIN32__ - // TODO: Do we really need to handle this in-engine? - // handle Alt+F4 on windows - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) { + + if (event->type == Common::EVENT_QUIT) { onWindowClose(); return true; - //TODO } -#endif if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { // TODO: Handle alt-enter as well as alt-return. diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index fe1baee9e6..6d73ac73ac 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -59,15 +59,6 @@ CBRegistry::~CBRegistry() { AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { AnsiString ret = ""; -#ifdef __WIN32__ - // check ini file first (so what we can use project files on windows) - char buffer[32768]; - GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, _iniName); - ret = AnsiString(buffer); - - if (buffer != init) return ret; -#endif - bool found = false; ret = getValue(_localValues, subKey, key, found); if (!found) ret = getValue(_values, subKey, key, found); @@ -86,11 +77,6 @@ bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, co ////////////////////////////////////////////////////////////////////////// int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { -#ifdef __WIN32__ - int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName); - if (ret != init) return ret; -#endif - AnsiString val = readString(subKey, key, ""); if (val.empty()) return init; else return atoi(val.c_str()); diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 0abd9a1ff9..ebb68654fd 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1339,202 +1339,13 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { -#ifndef __WIN32__ - Game->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); stack->pushNULL(); return STATUS_FAILED; - -#else - - bool Success = false; - HMODULE hDll = LoadLibrary(Function->dll_name); - - if (hDll) { - FARPROC pFunc = GetProcAddress(hDll, Function->name); - if (pFunc) { - int i; - Success = true; - stack->correctParams(Function->nu_params); - CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); - - for (i = 0; i < Function->nu_params; i++) { - CScValue *Val = stack->pop(); - switch (Function->params[i]) { - case TYPE_BOOL: - buffer->PutDWORD((uint32)Val->getBool()); - break; - case TYPE_LONG: - buffer->PutDWORD(Val->getInt()); - break; - case TYPE_BYTE: - buffer->PutDWORD((byte)Val->getInt()); - break; - case TYPE_STRING: - if (Val->isNULL()) buffer->PutDWORD(0); - else buffer->PutDWORD((uint32)Val->getString()); - break; - case TYPE_MEMBUFFER: - if (Val->isNULL()) buffer->PutDWORD(0); - else buffer->PutDWORD((uint32)Val->getMemBuffer()); - break; - case TYPE_FLOAT: { - float f = Val->getFloat(); - buffer->PutDWORD(*((uint32 *)&f)); - break; - } - case TYPE_DOUBLE: { - double d = Val->getFloat(); - uint32 *pd = (uint32 *)&d; - - buffer->PutDWORD(pd[0]); - buffer->PutDWORD(pd[1]); - break; - } - } - } - - // call - uint32 ret; - bool StackCorrupted = false; - switch (Function->call_type) { - case CALL_CDECL: - ret = Call_cdecl(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted); - break; - default: - ret = Call_stdcall(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted); - } - delete Buffer; - - // return - switch (Function->returns) { - case TYPE_BOOL: - stack->pushBool((byte)ret != 0); - break; - case TYPE_LONG: - stack->pushInt(ret); - break; - case TYPE_BYTE: - stack->pushInt((byte)ret); - break; - break; - case TYPE_STRING: - stack->pushString((char *)ret); - break; - case TYPE_MEMBUFFER: { - CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); - stack->pushNative(Buf, false); - } - break; - case TYPE_FLOAT: { - uint32 dw = GetST0(); - stack->pushFloat(*((float *)&dw)); - break; - } - case TYPE_DOUBLE: - stack->pushFloat(GetST0Double()); - break; - - default: - stack->pushNULL(); - } - - if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); - } else RuntimeError("Exported function '%s' not found in '%s'", Function->name, Function->dll_name); - } else RuntimeError("Error loading DLL '%s'", Function->dll_name); - - if (!Success) { - stack->correctParams(0); - stack->pushNULL(); - } - - if (hDll) FreeLibrary(hDll); - - return Success ? STATUS_OK : STATUS_FAILED; -#endif -} - -#ifdef __WIN32__ -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { - uint32 rc; // here's our return value... - uint32 OrigESP; - bool StkCorrupt = false; - __asm { - mov OrigESP, esp - mov ecx, sz // get size of buffer - mov esi, args // get buffer - sub esp, ecx // allocate stack space - mov edi, esp // start of destination stack frame - shr ecx, 2 // make it dwords - rep movsd // copy params to real stack - call [func] // call the function - mov rc, eax // save the return value - add esp, sz // restore the stack pointer - cmp esp, OrigESP - jz finish - mov esp, OrigESP - mov StkCorrupt, 1 - finish: - } - - if (StackCorrupt) *StackCorrupt = StkCorrupt; - return rc; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt) { - uint32 rc; // here's our return value... - uint32 OrigESP; - bool StkCorrupt = false; - - __asm { - mov OrigESP, esp - mov ecx, sz // get size of buffer - mov esi, args // get buffer - sub esp, ecx // allocate stack space - mov edi, esp // start of destination stack frame - shr ecx, 2 // make it dwords - rep movsd // copy it - call [func] // call the function - mov rc, eax // save the return value - cmp esp, OrigESP - jz finish - mov esp, OrigESP - mov StkCorrupt, 1 - finish: - } - - if (StackCorrupt) *StackCorrupt = StkCorrupt; - return rc; } -////////////////////////////////////////////////////////////////////////// -__declspec(naked) uint32 CScScript::GetST0(void) { - uint32 f; // temp var - __asm { - fstp uint32 ptr [f] // pop ST0 into f - mov eax, uint32 ptr [f] // copy into eax - ret // done - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScScript::GetST0Double(void) { - double d; // temp var - __asm { - fstp qword ptr [d] // get ST0 into d - } - return d; -} -#endif - - ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::copyParameters(CScStack *stack) { int i; diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 6635970dc5..666edb8309 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -56,13 +56,6 @@ public: void afterLoad(); -#ifdef __WIN32__ - static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt); - static uint32 Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt); - static uint32 GetST0(void); - static double GetST0Double(void); -#endif - CScValue *_operand; CScValue *_reg1; bool _freezable; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 9803ffb928..175cb1d68a 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -337,17 +337,17 @@ bool CBPlatform::equalRect(Common::Rect *rect1, Common::Rect *rect2) { ////////////////////////////////////////////////////////////////////////// AnsiString CBPlatform::getSystemFontPath() { -#ifdef __WIN32__ +/*#ifdef __WIN32__ // we're looking for something like "c:\windows\fonts\"; char winDir[MAX_PATH_LENGTH + 1]; winDir[MAX_PATH_LENGTH] = '\0'; ::GetWindowsDirectory(winDir, MAX_PATH_LENGTH); return PathUtil::Combine(AnsiString(winDir), "fonts"); -#else +#else*/ // !PORTME //return "/Library/Fonts/"; return ""; -#endif +//#endif } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index ca6f3416bc..09ca50699e 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -64,11 +64,8 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { _cursorChar = NULL; setCursorChar("|"); -#ifdef __WIN32__ - _cursorBlinkRate = GetCaretBlinkTime(); -#else _cursorBlinkRate = 600; -#endif + _frameWidth = 0; setText(""); diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp index b148c80300..7fa06cf682 100644 --- a/engines/wintermute/utils/PathUtil.cpp +++ b/engines/wintermute/utils/PathUtil.cpp @@ -115,7 +115,7 @@ AnsiString PathUtil::getExtension(const AnsiString &path) { AnsiString PathUtil::getSafeLogFileName() { AnsiString logFileName = getUserDirectory(); -#ifdef __WIN32__ +/*#ifdef __WIN32__ char moduleName[MAX_PATH_LENGTH]; ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); @@ -123,10 +123,10 @@ AnsiString PathUtil::getSafeLogFileName() { fileName = Combine("/Wintermute Engine/Logs/", fileName); logFileName = Combine(logFileName, fileName); -#else +#else*/ // !PORTME logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); -#endif +//#endif createDirectory(getDirectoryName(logFileName)); return logFileName; -- cgit v1.2.3 From 0ef77c57b6f6889471c7c5d902999fcf34c47a89 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:36:25 +0200 Subject: WINTERMUTE: Rename VarName->varName in WinterMute::Utils --- engines/wintermute/utils/utils.cpp | 44 +++++++++++++++++++------------------- engines/wintermute/utils/utils.h | 24 ++++++++++----------- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index d672656973..ae64cd0686 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -255,51 +255,51 @@ char *CBUtils::getFilename(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -void CBUtils::RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL) { - float var_R = (RGBCOLGetR(RGBColor) / 255.0f); - float var_G = (RGBCOLGetG(RGBColor) / 255.0f); - float var_B = (RGBCOLGetB(RGBColor) / 255.0f); +void CBUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { + float varR = (RGBCOLGetR(RGBColor) / 255.0f); + float varG = (RGBCOLGetG(RGBColor) / 255.0f); + float varB = (RGBCOLGetB(RGBColor) / 255.0f); //Min. value of RGB - float var_Min = MIN(var_R, var_G); - var_Min = MIN(var_Min, var_B); + float varMin = MIN(varR, varG); + varMin = MIN(varMin, varB); //Max. value of RGB - float var_Max = MAX(var_R, var_G); - var_Max = MAX(var_Max, var_B); + float varMax = MAX(varR, varG); + varMax = MAX(varMax, varB); //Delta RGB value - float del_Max = var_Max - var_Min; + float delMax = varMax - varMin; float H = 0.0f, S = 0.0f, L = 0.0f; - L = (var_Max + var_Min) / 2.0f; + L = (varMax + varMin) / 2.0f; //This is a gray, no chroma... - if (del_Max == 0) { + if (delMax == 0) { H = 0; S = 0; } //Chromatic data... else { - if (L < 0.5f) S = del_Max / (var_Max + var_Min); - else S = del_Max / (2.0f - var_Max - var_Min); + if (L < 0.5f) S = delMax / (varMax + varMin); + else S = delMax / (2.0f - varMax - varMin); - float del_R = (((var_Max - var_R) / 6.0f) + (del_Max / 2.0f)) / del_Max; - float del_G = (((var_Max - var_G) / 6.0f) + (del_Max / 2.0f)) / del_Max; - float del_B = (((var_Max - var_B) / 6.0f) + (del_Max / 2.0f)) / del_Max; + float delR = (((varMax - varR) / 6.0f) + (delMax / 2.0f)) / delMax; + float delG = (((varMax - varG) / 6.0f) + (delMax / 2.0f)) / delMax; + float delB = (((varMax - varB) / 6.0f) + (delMax / 2.0f)) / delMax; - if (var_R == var_Max) H = del_B - del_G; - else if (var_G == var_Max) H = (1.0f / 3.0f) + del_R - del_B; - else if (var_B == var_Max) H = (2.0f / 3.0f) + del_G - del_R; + if (varR == varMax) H = delB - delG; + else if (varG == varMax) H = (1.0f / 3.0f) + delR - delB; + else if (varB == varMax) H = (2.0f / 3.0f) + delG - delR; if (H < 0) H += 1; if (H > 1) H -= 1; } - *OutH = (byte)(H * 255); - *OutS = (byte)(S * 255); - *OutL = (byte)(L * 255); + *outH = (byte)(H * 255); + *outS = (byte)(S * 255); + *outL = (byte)(L * 255); } diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 50665dad1f..e178d35853 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -37,22 +37,22 @@ class CBGame; class CBUtils { public: - static void clip(int *DestX, int *DestY, Common::Rect *SrcRect, Common::Rect *DestRect); + static void clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect); static void swap(int *a, int *b); - static bool strBeginsI(const char *String, const char *Fragment); - static float normalizeAngle(float Angle); + static bool strBeginsI(const char *string, const char *fragment); + static float normalizeAngle(float angle); - static void createPath(const char *Path, bool PathOnly = false); + static void createPath(const char *path, bool pathOnly = false); - static void debugMessage(const char *Text); - static char *setString(char **String, const char *Value); + static void debugMessage(const char *text); + static char *setString(char **string, const char *value); - static int strNumEntries(const char *Str, const char Delim = ','); - static char *strEntry(int Entry, const char *Str, const char Delim = ','); + static int strNumEntries(const char *str, const char delim = ','); + static char *strEntry(int entry, const char *str, const char delim = ','); - static int randomInt(int From, int To); - static float randomFloat(float From, float To); - static float randomAngle(float From, float To); + static int randomInt(int from, int to); + static float randomFloat(float from, float to); + static float randomAngle(float from, float to); static bool matchesPattern(const char *pattern, const char *string); @@ -60,7 +60,7 @@ public: static char *getFilename(const char *filename); static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); - static uint32 HSLtoRGB(byte H, byte S, byte L); + static uint32 HSLtoRGB(byte H, byte S, byte L); private: static float Hue2RGB(float v1, float v2, float vH); -- cgit v1.2.3 From 0a43bba003c5e5cbf302a667e8515d4066d72407 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:50:38 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in coll_templ.h --- engines/wintermute/Ad/AdActor.cpp | 44 ++--- engines/wintermute/Ad/AdEntity.cpp | 8 +- engines/wintermute/Ad/AdGame.cpp | 182 +++++++++--------- engines/wintermute/Ad/AdInventory.cpp | 18 +- engines/wintermute/Ad/AdInventoryBox.cpp | 6 +- engines/wintermute/Ad/AdItem.cpp | 4 +- engines/wintermute/Ad/AdLayer.cpp | 32 ++-- engines/wintermute/Ad/AdObject.cpp | 58 +++--- engines/wintermute/Ad/AdPath.cpp | 12 +- engines/wintermute/Ad/AdRegion.cpp | 10 +- engines/wintermute/Ad/AdResponseBox.cpp | 44 ++--- engines/wintermute/Ad/AdScene.cpp | 226 +++++++++++------------ engines/wintermute/Ad/AdSceneState.cpp | 8 +- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Ad/AdTalkDef.cpp | 8 +- engines/wintermute/Ad/AdTalkHolder.cpp | 44 ++--- engines/wintermute/Ad/AdWaypointGroup.cpp | 12 +- engines/wintermute/Base/BFileManager.cpp | 54 +++--- engines/wintermute/Base/BFontBitmap.cpp | 8 +- engines/wintermute/Base/BFontStorage.cpp | 16 +- engines/wintermute/Base/BFontTT.cpp | 18 +- engines/wintermute/Base/BFrame.cpp | 60 +++--- engines/wintermute/Base/BGame.cpp | 70 +++---- engines/wintermute/Base/BRegion.cpp | 48 ++--- engines/wintermute/Base/BRenderSDL.cpp | 4 +- engines/wintermute/Base/BRenderer.cpp | 6 +- engines/wintermute/Base/BScriptHolder.cpp | 34 ++-- engines/wintermute/Base/BSoundMgr.cpp | 18 +- engines/wintermute/Base/BSprite.cpp | 60 +++--- engines/wintermute/Base/BSubFrame.cpp | 4 +- engines/wintermute/Base/BSurfaceStorage.cpp | 18 +- engines/wintermute/Base/PartEmitter.cpp | 66 +++---- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/file/BDiskFile.cpp | 2 +- engines/wintermute/Base/scriptables/SXStore.cpp | 40 ++-- engines/wintermute/Base/scriptables/ScEngine.cpp | 76 ++++---- engines/wintermute/Base/scriptables/ScEngine.h | 2 +- engines/wintermute/Base/scriptables/ScScript.cpp | 10 +- engines/wintermute/Base/scriptables/ScStack.cpp | 28 +-- engines/wintermute/UI/UIButton.cpp | 4 +- engines/wintermute/UI/UIEdit.cpp | 4 +- engines/wintermute/UI/UIEntity.cpp | 2 +- engines/wintermute/UI/UIObject.cpp | 26 +-- engines/wintermute/UI/UIText.cpp | 4 +- engines/wintermute/UI/UIWindow.cpp | 60 +++--- engines/wintermute/coll_templ.h | 96 +++++----- engines/wintermute/video/VidPlayer.cpp | 10 +- 47 files changed, 784 insertions(+), 784 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index a823a18dde..16ea49f6ff 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -103,21 +103,21 @@ CAdActor::~CAdActor() { _animSprite2 = NULL; // ref only - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { delete _talkSprites[i]; } - _talkSprites.RemoveAll(); + _talkSprites.removeAll(); - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { delete _talkSpritesEx[i]; } - _talkSpritesEx.RemoveAll(); + _talkSpritesEx.removeAll(); - for (int i = 0; i < _anims.GetSize(); i++) { + for (int i = 0; i < _anims.getSize(); i++) { delete _anims[i]; _anims[i] = NULL; } - _anims.RemoveAll(); + _anims.removeAll(); } @@ -298,13 +298,13 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: spr = new CAdSpriteSet(Game, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); + else _talkSprites.add(spr); break; case TOKEN_TALK_SPECIAL: spr = new CAdSpriteSet(Game, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); + else _talkSpritesEx.add(spr); break; case TOKEN_STAND: @@ -434,7 +434,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_ANIMATION: { CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else _anims.Add(Anim); + else _anims.add(Anim); } break; } @@ -940,7 +940,7 @@ ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *t const char *AnimName = stack->pop()->getString(); bool Found = false; - for (int i = 0; i < _anims.GetSize(); i++) { + for (int i = 0; i < _anims.getSize(); i++) { if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; @@ -949,7 +949,7 @@ ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *t delete _anims[i]; _anims[i] = NULL; - _anims.RemoveAt(i); + _anims.removeAt(i); i--; Found = true; } @@ -1118,7 +1118,7 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { } // old way - if (_talkSprites.GetSize() > 0 || _talkSpritesEx.GetSize() > 0) + if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) return getTalkStanceOld(stance); // new way @@ -1131,13 +1131,13 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { // not - get a random talk if (!ret) { CBArray TalkAnims; - for (int i = 0; i < _anims.GetSize(); i++) { + for (int i = 0; i < _anims.getSize(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) - TalkAnims.Add(_anims[i]); + TalkAnims.add(_anims[i]); } - if (TalkAnims.GetSize() > 0) { - int rnd = g_wintermute->randInt(0, TalkAnims.GetSize() - 1); + if (TalkAnims.getSize() > 0) { + int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); ret = TalkAnims[rnd]->getSprite(_dir); } else { if (_standSprite) ret = _standSprite->getSprite(_dir); @@ -1156,7 +1156,7 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { if (stance != NULL) { // search special stances - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { ret = _talkSpritesEx[i]->getSprite(_dir); break; @@ -1164,7 +1164,7 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { } if (ret == NULL) { // search generic stances - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { ret = _talkSprites[i]->getSprite(_dir); break; @@ -1175,10 +1175,10 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.GetSize() < 1) ret = _standSprite->getSprite(_dir); + if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); else { // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.GetSize() - 1); + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]->getSprite(_dir); } } @@ -1254,7 +1254,7 @@ int CAdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { - for (int i = 0; i < _anims.GetSize(); i++) { + for (int i = 0; i < _anims.getSize(); i++) { if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) return _anims[i]; } @@ -1288,7 +1288,7 @@ ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = STATUS_FAILED; - } else _anims.Add(Anim); + } else _anims.add(Anim); } break; } diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index a5fb78858c..599afee626 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -237,14 +237,14 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: { spr = new CBSprite(Game, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); + else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { spr = new CBSprite(Game, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); + else _talkSpritesEx.add(spr); } break; @@ -503,7 +503,7 @@ ERRORCODE CAdEntity::display() { if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; if (_region && (Reg || _editorAlwaysRegister)) { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); + Game->_renderer->_rectList.add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); } displaySpriteAttachments(true); @@ -910,7 +910,7 @@ ERRORCODE CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { int i; - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 69a31575cb..6a58f99881 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -120,40 +120,40 @@ CAdGame::~CAdGame() { ERRORCODE CAdGame::cleanup() { int i; - for (i = 0; i < _objects.GetSize(); i++) { + for (i = 0; i < _objects.getSize(); i++) { unregisterObject(_objects[i]); _objects[i] = NULL; } - _objects.RemoveAll(); + _objects.removeAll(); - for (i = 0; i < _dlgPendingBranches.GetSize(); i++) { + for (i = 0; i < _dlgPendingBranches.getSize(); i++) { delete [] _dlgPendingBranches[i]; } - _dlgPendingBranches.RemoveAll(); + _dlgPendingBranches.removeAll(); - for (i = 0; i < _speechDirs.GetSize(); i++) { + for (i = 0; i < _speechDirs.getSize(); i++) { delete [] _speechDirs[i]; } - _speechDirs.RemoveAll(); + _speechDirs.removeAll(); unregisterObject(_scene); _scene = NULL; // remove items - for (i = 0; i < _items.GetSize(); i++) Game->unregisterObject(_items[i]); - _items.RemoveAll(); + for (i = 0; i < _items.getSize(); i++) Game->unregisterObject(_items[i]); + _items.removeAll(); // clear remaining inventories delete _invObject; _invObject = NULL; - for (i = 0; i < _inventories.GetSize(); i++) { + for (i = 0; i < _inventories.getSize(); i++) { delete _inventories[i]; } - _inventories.RemoveAll(); + _inventories.removeAll(); if (_responseBox) { @@ -181,14 +181,14 @@ ERRORCODE CAdGame::cleanup() { delete _sceneViewport; _sceneViewport = NULL; - for (i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; - _sceneStates.RemoveAll(); + for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); - for (i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); + for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); - for (i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; - _responsesGame.RemoveAll(); + for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); return CBGame::cleanup(); } @@ -211,7 +211,7 @@ ERRORCODE CAdGame::initLoop() { if (_scene) res = _scene->initLoop(); - _sentences.RemoveAll(); + _sentences.removeAll(); return res; } @@ -219,7 +219,7 @@ ERRORCODE CAdGame::initLoop() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::addObject(CAdObject *object) { - _objects.Add(object); + _objects.add(object); return registerObject(object); } @@ -232,9 +232,9 @@ ERRORCODE CAdGame::removeObject(CAdObject *object) { if (DID_SUCCEED(Res)) return Res; } - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { - _objects.RemoveAt(i); + _objects.removeAt(i); break; } } @@ -259,7 +259,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene) { // reset objects - for (int i = 0; i < _objects.GetSize(); i++) _objects[i]->reset(); + for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); // reset scene properties _scene->_sFXVolume = 100; @@ -273,7 +273,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { if (DID_SUCCEED(ret)) { // invalidate references to the original scene - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { _objects[i]->invalidateCurrRegions(); _objects[i]->_stickRegion = NULL; } @@ -288,13 +288,13 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// void CAdGame::addSentence(CAdSentence *sentence) { - _sentences.Add(sentence); + _sentences.add(sentence); } ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::displaySentences(bool frozen) { - for (int i = 0; i < _sentences.GetSize(); i++) { + for (int i = 0; i < _sentences.getSize(); i++) { if (frozen && _sentences[i]->_freezable) continue; else _sentences[i]->display(); } @@ -304,7 +304,7 @@ ERRORCODE CAdGame::displaySentences(bool frozen) { ////////////////////////////////////////////////////////////////////////// void CAdGame::finishSentences() { - for (int i = 0; i < _sentences.GetSize(); i++) { + for (int i = 0; i < _sentences.getSize(); i++) { if (_sentences[i]->CanSkip()) { _sentences[i]->_duration = 0; if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); @@ -446,7 +446,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CAdItem *item = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _items.GetSize()) item = _items[index]; + if (index >= 0 && index < _items.getSize()) item = _items[index]; } else { item = getItemByName(val->getString()); } @@ -484,7 +484,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; - _responseBox->_responses.Add(res); + _responseBox->_responses.add(res); } } else { script->runtimeError("Game.AddResponse: response box is not defined"); @@ -526,13 +526,13 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (_responseBox) { _responseBox->weedResponses(); - if (_responseBox->_responses.GetSize() == 0) { + if (_responseBox->_responses.getSize() == 0) { stack->pushNULL(); return STATUS_OK; } - if (_responseBox->_responses.GetSize() == 1 && autoSelectLast) { + if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { stack->pushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); @@ -559,7 +559,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); if (_responseBox) { _responseBox->weedResponses(); - stack->pushInt(_responseBox->_responses.GetSize()); + stack->pushInt(_responseBox->_responses.getSize()); } else { script->runtimeError("Game.GetNumResponses: response box is not defined"); stack->pushNULL(); @@ -607,8 +607,8 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "GetCurrentDlgBranch") == 0) { stack->correctParams(0); - if (_dlgPendingBranches.GetSize() > 0) { - stack->pushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]); + if (_dlgPendingBranches.getSize() > 0) { + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); } else stack->pushNULL(); return STATUS_OK; @@ -650,10 +650,10 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (!val->isNULL()) { - for (int i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.getSize(); i++) { CAdInventory *Inv = _inventories[i]; - for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { if (val->getNative() == Inv->_takenItems[j]) { stack->pushBool(true); return STATUS_OK; @@ -918,7 +918,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { // TotalNumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TotalNumItems") == 0) { - _scValue->setInt(_items.GetSize()); + _scValue->setInt(_items.getSize()); return _scValue; } @@ -962,7 +962,7 @@ ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { else { if (value->isNative()) { _selectedItem = NULL; - for (int i = 0; i < _items.GetSize(); i++) { + for (int i = 0; i < _items.getSize(); i++) { if (_items[i] == value->getNative()) { _selectedItem = (CAdItem *)value->getNative(); break; @@ -1405,7 +1405,7 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { CBParser parser(Game); if (!merge) { - while (_items.GetSize() > 0) deleteItem(_items[0]); + while (_items.getSize() > 0) deleteItem(_items[0]); } while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -1450,7 +1450,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { if (filenameCor[i] == '/') filenameCor[i] = '\\'; } - for (int i = 0; i < _sceneStates.GetSize(); i++) { + for (int i = 0; i < _sceneStates.getSize(); i++) { if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { delete [] filenameCor; return _sceneStates[i]; @@ -1461,7 +1461,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { CAdSceneState *ret = new CAdSceneState(Game); ret->setFilename(filenameCor); - _sceneStates.Add(ret); + _sceneStates.add(ret); delete [] filenameCor; return ret; @@ -1491,7 +1491,7 @@ ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) cmd = PARSERR_GENERIC; } else { ent->_parent = win; - win->_widgets.Add(ent); + win->_widgets.add(ent); } } break; @@ -1517,7 +1517,7 @@ ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CSc stack->pushNative(ent, true); ent->_parent = win; - win->_widgets.Add(ent); + win->_widgets.add(ent); return STATUS_OK; } else return STATUS_FAILED; @@ -1529,7 +1529,7 @@ ERRORCODE CAdGame::startDlgBranch(const char *branchName, const char *scriptName char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); - _dlgPendingBranches.Add(name); + _dlgPendingBranches.add(name); } return STATUS_OK; } @@ -1539,8 +1539,8 @@ ERRORCODE CAdGame::startDlgBranch(const char *branchName, const char *scriptName ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; bool deleteName = false; - if (branchName == NULL && _dlgPendingBranches.GetSize() > 0) { - name = _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]; + if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { + name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; } else { if (branchName != NULL) { name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; @@ -1555,25 +1555,25 @@ ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, int startIndex = -1; - for (int i = _dlgPendingBranches.GetSize() - 1; i >= 0; i--) { + for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { startIndex = i; break; } } if (startIndex >= 0) { - for (int i = startIndex; i < _dlgPendingBranches.GetSize(); i++) { + for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); delete [] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; } - _dlgPendingBranches.RemoveAt(startIndex, _dlgPendingBranches.GetSize() - startIndex); + _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); } // dialogue is over, forget selected responses - if (_dlgPendingBranches.GetSize() == 0) { - for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); + if (_dlgPendingBranches.getSize() == 0) { + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); } if (deleteName) delete [] name; @@ -1584,10 +1584,10 @@ ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::clearBranchResponses(char *name) { - for (int i = 0; i < _responsesBranch.GetSize(); i++) { + for (int i = 0; i < _responsesBranch.getSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; - _responsesBranch.RemoveAt(i); + _responsesBranch.removeAt(i); i--; } } @@ -1600,16 +1600,16 @@ ERRORCODE CAdGame::addBranchResponse(int ID) { if (branchResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; - r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); - _responsesBranch.Add(r); + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesBranch.add(r); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool CAdGame::branchResponseUsed(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < _responsesBranch.GetSize(); i++) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesBranch.getSize(); i++) { if (_responsesBranch[i]->_iD == ID) { if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; } @@ -1623,16 +1623,16 @@ ERRORCODE CAdGame::addGameResponse(int ID) { if (gameResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(Game); r->_iD = ID; - r->setContext(_dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL); - _responsesGame.Add(r); + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesGame.add(r); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool CAdGame::gameResponseUsed(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; - for (int i = 0; i < _responsesGame.GetSize(); i++) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesGame.getSize(); i++) { CAdResponseContext *RespContext = _responsesGame[i]; if (RespContext->_iD == ID) { if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; @@ -1644,25 +1644,25 @@ bool CAdGame::gameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::resetResponse(int ID) { - char *Context = _dlgPendingBranches.GetSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.GetSize() - 1] : NULL; + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; int i; - for (i = 0; i < _responsesGame.GetSize(); i++) { + for (i = 0; i < _responsesGame.getSize(); i++) { if (_responsesGame[i]->_iD == ID) { if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { delete _responsesGame[i]; - _responsesGame.RemoveAt(i); + _responsesGame.removeAt(i); break; } } } - for (i = 0; i < _responsesBranch.GetSize(); i++) { + for (i = 0; i < _responsesBranch.getSize(); i++) { if (_responsesBranch[i]->_iD == ID) { if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; - _responsesBranch.RemoveAt(i); + _responsesBranch.removeAt(i); break; } } @@ -1741,21 +1741,21 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::registerInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) return STATUS_OK; } registerObject(inv); - _inventories.Add(inv); + _inventories.add(inv); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::unregisterInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); - _inventories.RemoveAt(i); + _inventories.removeAt(i); return STATUS_OK; } } @@ -1764,10 +1764,10 @@ ERRORCODE CAdGame::unregisterInventory(CAdInventory *inv) { ////////////////////////////////////////////////////////////////////////// bool CAdGame::isItemTaken(char *itemName) { - for (int i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.getSize(); i++) { CAdInventory *Inv = _inventories[i]; - for (int j = 0; j < Inv->_takenItems.GetSize(); j++) { + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { return true; } @@ -1778,7 +1778,7 @@ bool CAdGame::isItemTaken(char *itemName) { ////////////////////////////////////////////////////////////////////////// CAdItem *CAdGame::getItemByName(const char *name) { - for (int i = 0; i < _items.GetSize(); i++) { + for (int i = 0; i < _items.getSize(); i++) { if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; } return NULL; @@ -1787,7 +1787,7 @@ CAdItem *CAdGame::getItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::addItem(CAdItem *item) { - _items.Add(item); + _items.add(item); return Game->registerObject(item); } @@ -1795,28 +1795,28 @@ ERRORCODE CAdGame::addItem(CAdItem *item) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::resetContent() { // clear pending dialogs - for (int i = 0; i < _dlgPendingBranches.GetSize(); i++) { + for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { delete [] _dlgPendingBranches[i]; } - _dlgPendingBranches.RemoveAll(); + _dlgPendingBranches.removeAll(); // clear inventories - for (int i = 0; i < _inventories.GetSize(); i++) { - _inventories[i]->_takenItems.RemoveAll(); + for (int i = 0; i < _inventories.getSize(); i++) { + _inventories[i]->_takenItems.removeAll(); } // clear scene states - for (int i = 0; i < _sceneStates.GetSize(); i++) delete _sceneStates[i]; - _sceneStates.RemoveAll(); + for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); // clear once responses - for (int i = 0; i < _responsesBranch.GetSize(); i++) delete _responsesBranch[i]; - _responsesBranch.RemoveAll(); + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); // clear once game responses - for (int i = 0; i < _responsesGame.GetSize(); i++) delete _responsesGame[i]; - _responsesGame.RemoveAll(); + for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); // reload inventory items if (_itemsFile) loadItemsFile(_itemsFile); @@ -1835,15 +1835,15 @@ ERRORCODE CAdGame::deleteItem(CAdItem *item) { _scene->handleItemAssociations(item->_name, false); // remove from all inventories - for (int i = 0; i < _inventories.GetSize(); i++) { + for (int i = 0; i < _inventories.getSize(); i++) { _inventories[i]->removeItem(item); } // remove object - for (int i = 0; i < _items.GetSize(); i++) { + for (int i = 0; i < _items.getSize(); i++) { if (_items[i] == item) { unregisterObject(_items[i]); - _items.RemoveAt(i); + _items.removeAt(i); break; } } @@ -1861,13 +1861,13 @@ ERRORCODE CAdGame::addSpeechDir(const char *dir) { if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') strcat(temp, "\\"); - for (int i = 0; i < _speechDirs.GetSize(); i++) { + for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete [] temp; return STATUS_OK; } } - _speechDirs.Add(temp); + _speechDirs.add(temp); return STATUS_OK; } @@ -1883,10 +1883,10 @@ ERRORCODE CAdGame::removeSpeechDir(const char *dir) { strcat(temp, "\\"); bool Found = false; - for (int i = 0; i < _speechDirs.GetSize(); i++) { + for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete [] _speechDirs[i]; - _speechDirs.RemoveAt(i); + _speechDirs.removeAt(i); Found = true; break; } @@ -1902,7 +1902,7 @@ ERRORCODE CAdGame::removeSpeechDir(const char *dir) { char *CAdGame::findSpeechFile(char *stringID) { char *ret = new char[MAX_PATH_LENGTH]; - for (int i = 0; i < _speechDirs.GetSize(); i++) { + for (int i = 0; i < _speechDirs.getSize(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile if (file) { diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 41e9a89ed5..1c14cb710c 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -44,7 +44,7 @@ CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdInventory::~CAdInventory() { - _takenItems.RemoveAll(); // ref only + _takenItems.removeAll(); // ref only } @@ -56,9 +56,9 @@ ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { if (item == NULL) return STATUS_FAILED; int insertIndex = -1; - for (int i = 0; i < _takenItems.GetSize(); i++) { + for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - _takenItems.RemoveAt(i); + _takenItems.removeAt(i); i--; continue; } @@ -66,8 +66,8 @@ ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { } - if (insertIndex == -1) _takenItems.Add(item); - else _takenItems.InsertAt(insertIndex, item); + if (insertIndex == -1) _takenItems.add(item); + else _takenItems.insertAt(insertIndex, item); return STATUS_OK; } @@ -77,10 +77,10 @@ ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { ERRORCODE CAdInventory::removeItem(const char *name) { if (name == NULL) return STATUS_FAILED; - for (int i = 0; i < _takenItems.GetSize(); i++) { + for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; - _takenItems.RemoveAt(i); + _takenItems.removeAt(i); return STATUS_OK; } } @@ -94,10 +94,10 @@ ERRORCODE CAdInventory::removeItem(const char *name) { ERRORCODE CAdInventory::removeItem(CAdItem *item) { if (item == NULL) return STATUS_FAILED; - for (int i = 0; i < _takenItems.GetSize(); i++) { + for (int i = 0; i < _takenItems.getSize(); i++) { if (_takenItems[i] == item) { if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; - _takenItems.RemoveAt(i); + _takenItems.removeAt(i); return STATUS_OK; } } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 3b887c4737..fe3a9b8a09 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -109,7 +109,7 @@ ERRORCODE CAdInventoryBox::display() { if (_window) { _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < adGame->_inventoryOwner->getInventory()->_takenItems.GetSize()); + _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); } @@ -136,7 +136,7 @@ ERRORCODE CAdInventoryBox::display() { int xxx = rect.left; for (int i = 0; i < ItemsX; i++) { int ItemIndex = _scrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.GetSize()) { + if (ItemIndex >= 0 && ItemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[ItemIndex]; if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { item->update(); @@ -308,7 +308,7 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { _visible = always_visible; if (_window) { - for (int i = 0; i < _window->_widgets.GetSize(); i++) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { if (!_window->_widgets[i]->_listenerObject) _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index e2e7374f68..435947e96d 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -244,14 +244,14 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: { CBSprite *spr = new CBSprite(Game, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.Add(spr); + else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { CBSprite *spr = new CBSprite(Game, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.Add(spr); + else _talkSpritesEx.add(spr); } break; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index 06765b6cba..fd37d21550 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -54,9 +54,9 @@ CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdLayer::~CAdLayer() { - for (int i = 0; i < _nodes.GetSize(); i++) + for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; - _nodes.RemoveAll(); + _nodes.removeAll(); } @@ -175,7 +175,7 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { node = NULL; } else { node->setRegion(region); - _nodes.Add(node); + _nodes.add(node); } } break; @@ -192,7 +192,7 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { node = NULL; } else { node->setEntity(entity); - _nodes.Add(node); + _nodes.add(node); } } break; @@ -237,7 +237,7 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (val->_type == VAL_INT) node = val->getInt(); else { // get by name - for (int i = 0; i < _nodes.GetSize(); i++) { + for (int i = 0; i < _nodes.getSize(); i++) { if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { node = i; @@ -246,7 +246,7 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t } } - if (node < 0 || node >= _nodes.GetSize()) stack->pushNULL(); + if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); else { switch (_nodes[node]->_type) { case OBJECT_ENTITY: @@ -281,7 +281,7 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t node->setEntity(entity); stack->pushNative(entity, true); } - _nodes.Add(node); + _nodes.add(node); return STATUS_OK; } @@ -306,8 +306,8 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->pushNative(entity, true); } if (index < 0) index = 0; - if (index <= _nodes.GetSize() - 1) _nodes.InsertAt(index, node); - else _nodes.Add(node); + if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); + else _nodes.add(node); return STATUS_OK; } @@ -322,7 +322,7 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CAdSceneNode *toDelete = NULL; if (val->isNative()) { CBScriptable *temp = val->getNative(); - for (int i = 0; i < _nodes.GetSize(); i++) { + for (int i = 0; i < _nodes.getSize(); i++) { if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { toDelete = _nodes[i]; break; @@ -330,7 +330,7 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t } } else { int index = val->getInt(); - if (index >= 0 && index < _nodes.GetSize()) { + if (index >= 0 && index < _nodes.getSize()) { toDelete = _nodes[index]; } } @@ -339,11 +339,11 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t return STATUS_OK; } - for (int i = 0; i < _nodes.GetSize(); i++) { + for (int i = 0; i < _nodes.getSize(); i++) { if (_nodes[i] == toDelete) { delete _nodes[i]; _nodes[i] = NULL; - _nodes.RemoveAt(i); + _nodes.removeAt(i); break; } } @@ -371,7 +371,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumNodes") == 0) { - _scValue->setInt(_nodes.GetSize()); + _scValue->setInt(_nodes.getSize()); return _scValue; } @@ -491,13 +491,13 @@ ERRORCODE CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { int i; - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_scProp) _scProp->saveAsText(buffer, indent + 2); - for (i = 0; i < _nodes.GetSize(); i++) { + for (i = 0; i < _nodes.getSize(); i++) { switch (_nodes[i]->_type) { case OBJECT_ENTITY: _nodes[i]->_entity->saveAsText(buffer, indent + 2); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 038cacefad..06c63a4d1b 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -138,15 +138,15 @@ CAdObject::~CAdObject() { Game->unregisterObject(_partEmitter); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { Game->unregisterObject(_attachmentsPre[i]); } - _attachmentsPre.RemoveAll(); + _attachmentsPre.removeAll(); - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { Game->unregisterObject(_attachmentsPost[i]); } - _attachmentsPost.RemoveAll(); + _attachmentsPost.removeAll(); } @@ -295,7 +295,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * regFound = true; } else if (val->isString()) { const char *regionName = val->getString(); - for (i = 0; i < main->_nodes.GetSize(); i++) { + for (i = 0; i < main->_nodes.getSize(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { _stickRegion = main->_nodes[i]->_region; regFound = true; @@ -305,7 +305,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * } else if (val->isNative()) { CBScriptable *obj = val->getNative(); - for (i = 0; i < main->_nodes.GetSize(); i++) { + for (i = 0; i < main->_nodes.getSize(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { _stickRegion = main->_nodes[i]->_region; regFound = true; @@ -412,7 +412,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * CAdItem *item = ((CAdGame *)Game)->getItemByName(val->getString()); if (item) stack->pushNative(item, true); else stack->pushNULL(); - } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.GetSize()) + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) stack->pushNULL(); else stack->pushNative(_inventory->_takenItems[val->getInt()], true); @@ -433,7 +433,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * CScValue *val = stack->pop(); if (!val->isNULL()) { - for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) { + for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); return STATUS_OK; @@ -502,8 +502,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * ent->_posY = offsetY; ent->_active = true; - if (preDisplay) _attachmentsPre.Add(ent); - else _attachmentsPost.Add(ent); + if (preDisplay) _attachmentsPre.add(ent); + else _attachmentsPost.add(ent); stack->pushBool(true); } @@ -520,37 +520,37 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * bool found = false; if (val->isNative()) { CBScriptable *obj = val->getNative(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i] == obj) { found = true; Game->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.RemoveAt(i); + _attachmentsPre.removeAt(i); i--; } } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (_attachmentsPost[i] == obj) { found = true; Game->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.RemoveAt(i); + _attachmentsPost.removeAt(i); i--; } } } else { const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { found = true; Game->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.RemoveAt(i); + _attachmentsPre.removeAt(i); i--; } } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { found = true; Game->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.RemoveAt(i); + _attachmentsPost.removeAt(i); i--; } } @@ -571,24 +571,24 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (val->isInt()) { int index = val->getInt(); int currIndex = 0; - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (currIndex == index) ret = _attachmentsPre[i]; currIndex++; } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (currIndex == index) ret = _attachmentsPost[i]; currIndex++; } } else { const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { ret = _attachmentsPre[i]; break; } } if (!ret) { - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { ret = _attachmentsPre[i]; break; @@ -687,7 +687,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // NumItems (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumItems") == 0) { - _scValue->setInt(getInventory()->_takenItems.GetSize()); + _scValue->setInt(getInventory()->_takenItems.getSize()); return _scValue; } @@ -705,7 +705,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumAttachments") == 0) { - _scValue->setInt(_attachmentsPre.GetSize() + _attachmentsPost.GetSize()); + _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); return _scValue; } @@ -810,7 +810,7 @@ int CAdObject::getHeight() { else { CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; int ret = 0; - for (int i = 0; i < frame->_subframes.GetSize(); i++) { + for (int i = 0; i < frame->_subframes.getSize(); i++) { ret = MAX(ret, frame->_subframes[i]->_hotspotY); } @@ -1109,10 +1109,10 @@ ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdObject::updateSpriteAttachments() { - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { _attachmentsPre[i]->update(); } - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { _attachmentsPost[i]->update(); } return STATUS_OK; @@ -1121,11 +1121,11 @@ ERRORCODE CAdObject::updateSpriteAttachments() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdObject::displaySpriteAttachments(bool preDisplay) { if (preDisplay) { - for (int i = 0; i < _attachmentsPre.GetSize(); i++) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { displaySpriteAttachment(_attachmentsPre[i]); } } else { - for (int i = 0; i < _attachmentsPost.GetSize(); i++) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { displaySpriteAttachment(_attachmentsPost[i]); } } diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index bac9681cef..5ce603609f 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -49,10 +49,10 @@ CAdPath::~CAdPath() { ////////////////////////////////////////////////////////////////////////// void CAdPath::reset() { - for (int i = 0; i < _points.GetSize(); i++) + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.RemoveAll(); + _points.removeAll(); _currIndex = -1; _ready = false; } @@ -60,7 +60,7 @@ void CAdPath::reset() { ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::getFirst() { - if (_points.GetSize() > 0) { + if (_points.getSize() > 0) { _currIndex = 0; return _points[_currIndex]; } else return NULL; @@ -70,21 +70,21 @@ CBPoint *CAdPath::getFirst() { ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::getNext() { _currIndex++; - if (_currIndex < _points.GetSize()) return _points[_currIndex]; + if (_currIndex < _points.getSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// CBPoint *CAdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < _points.GetSize()) return _points[_currIndex]; + if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// void CAdPath::addPoint(CBPoint *point) { - _points.Add(point); + _points.add(point); } diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index ec6017759a..5ca4a56367 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -128,8 +128,8 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { buffer = params; } - for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -170,7 +170,7 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); + _points.add(new CBPoint(x, y)); } break; @@ -359,13 +359,13 @@ ERRORCODE CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); int i; - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } if (_scProp) _scProp->saveAsText(buffer, indent + 2); - for (i = 0; i < _points.GetSize(); i++) { + for (i = 0; i < _points.getSize(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index 9ab669ba14..f2162012e0 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -94,25 +94,25 @@ CAdResponseBox::~CAdResponseBox() { ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::clearResponses() { - for (int i = 0; i < _responses.GetSize(); i++) { + for (int i = 0; i < _responses.getSize(); i++) { delete _responses[i]; } - _responses.RemoveAll(); + _responses.removeAll(); } ////////////////////////////////////////////////////////////////////////// void CAdResponseBox::clearButtons() { - for (int i = 0; i < _respButtons.GetSize(); i++) { + for (int i = 0; i < _respButtons.getSize(); i++) { delete _respButtons[i]; } - _respButtons.RemoveAll(); + _respButtons.removeAll(); } ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::invalidateButtons() { - for (int i = 0; i < _respButtons.GetSize(); i++) { + for (int i = 0; i < _respButtons.getSize(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; _respButtons[i]->_font = NULL; @@ -129,7 +129,7 @@ ERRORCODE CAdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; - for (int i = 0; i < _responses.GetSize(); i++) { + for (int i = 0; i < _responses.getSize(); i++) { CUIButton *btn = new CUIButton(Game); if (btn) { btn->_parent = _window; @@ -172,7 +172,7 @@ ERRORCODE CAdResponseBox::createButtons() { //btn->SetListener(this, btn, _responses[i]->_iD); btn->setListener(this, btn, i); btn->_visible = false; - _respButtons.Add(btn); + _respButtons.add(btn); if (_responseArea.bottom - _responseArea.top < btn->_height) { Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); @@ -325,7 +325,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } if (_window) { - for (int i = 0; i < _window->_widgets.GetSize(); i++) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { if (!_window->_widgets[i]->_listenerObject) _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } @@ -411,7 +411,7 @@ ERRORCODE CAdResponseBox::display() { // shift down if needed if (!_horizontal) { int total_height = 0; - for (i = 0; i < _respButtons.GetSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); total_height -= _spacing; switch (_verticalAlign) { @@ -433,7 +433,7 @@ ERRORCODE CAdResponseBox::display() { // prepare response buttons bool scrollNeeded = false; - for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { @@ -473,7 +473,7 @@ ERRORCODE CAdResponseBox::display() { // display response buttons - for (i = _scrollOffset; i < _respButtons.GetSize(); i++) { + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { _respButtons[i]->display(); } @@ -539,12 +539,12 @@ ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { ERRORCODE CAdResponseBox::weedResponses() { CAdGame *adGame = (CAdGame *)Game; - for (int i = 0; i < _responses.GetSize(); i++) { + for (int i = 0; i < _responses.getSize(); i++) { switch (_responses[i]->_responseType) { case RESPONSE_ONCE: if (adGame->branchResponseUsed(_responses[i]->_iD)) { delete _responses[i]; - _responses.RemoveAt(i); + _responses.removeAt(i); i--; } break; @@ -552,7 +552,7 @@ ERRORCODE CAdResponseBox::weedResponses() { case RESPONSE_ONCE_GAME: if (adGame->gameResponseUsed(_responses[i]->_iD)) { delete _responses[i]; - _responses.RemoveAt(i); + _responses.removeAt(i); i--; } break; @@ -599,12 +599,12 @@ CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { CBArray objects; getObjects(objects, true); - if (objects.GetSize() == 0) return NULL; + if (objects.getSize() == 0) return NULL; else { if (currObject != NULL) { - for (int i = 0; i < objects.GetSize(); i++) { + for (int i = 0; i < objects.getSize(); i++) { if (objects[i] == currObject) { - if (i < objects.GetSize() - 1) return objects[i + 1]; + if (i < objects.getSize() - 1) return objects[i + 1]; else break; } } @@ -619,25 +619,25 @@ CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { CBArray objects; getObjects(objects, true); - if (objects.GetSize() == 0) return NULL; + if (objects.getSize() == 0) return NULL; else { if (currObject != NULL) { - for (int i = objects.GetSize() - 1; i >= 0; i--) { + for (int i = objects.getSize() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) return objects[i - 1]; else break; } } } - return objects[objects.GetSize() - 1]; + return objects[objects.getSize() - 1]; } return NULL; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _respButtons.GetSize(); i++) { - objects.Add(_respButtons[i]); + for (int i = 0; i < _respButtons.getSize(); i++) { + objects.add(_respButtons[i]); } if (_window) _window->getWindowObjects(objects, interactiveOnly); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index c6a3b971ed..f674e92274 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -149,32 +149,32 @@ void CAdScene::cleanup() { Game->unregisterObject(_fader); _fader = NULL; - for (i = 0; i < _layers.GetSize(); i++) + for (i = 0; i < _layers.getSize(); i++) Game->unregisterObject(_layers[i]); - _layers.RemoveAll(); + _layers.removeAll(); - for (i = 0; i < _waypointGroups.GetSize(); i++) + for (i = 0; i < _waypointGroups.getSize(); i++) Game->unregisterObject(_waypointGroups[i]); - _waypointGroups.RemoveAll(); + _waypointGroups.removeAll(); - for (i = 0; i < _scaleLevels.GetSize(); i++) + for (i = 0; i < _scaleLevels.getSize(); i++) Game->unregisterObject(_scaleLevels[i]); - _scaleLevels.RemoveAll(); + _scaleLevels.removeAll(); - for (i = 0; i < _rotLevels.GetSize(); i++) + for (i = 0; i < _rotLevels.getSize(); i++) Game->unregisterObject(_rotLevels[i]); - _rotLevels.RemoveAll(); + _rotLevels.removeAll(); - for (i = 0; i < _pfPath.GetSize(); i++) + for (i = 0; i < _pfPath.getSize(); i++) delete _pfPath[i]; - _pfPath.RemoveAll(); + _pfPath.removeAll(); _pfPointsNum = 0; - for (i = 0; i < _objects.GetSize(); i++) + for (i = 0; i < _objects.getSize(); i++) Game->unregisterObject(_objects[i]); - _objects.RemoveAll(); + _objects.removeAll(); delete _viewport; _viewport = NULL; @@ -200,7 +200,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfPointsStart(); // first point - //_pfPath.Add(new CAdPathPoint(source.x, source.y, 0)); + //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); // if we're one pixel stuck, get unstuck int startX = source.x; @@ -228,11 +228,11 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * //CorrectTargetPoint(&target.x, &target.y); // last point - //_pfPath.Add(new CAdPathPoint(target.x, target.y, INT_MAX)); + //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); pfPointsAdd(target.x, target.y, INT_MAX); // active waypoints - for (i = 0; i < _waypointGroups.GetSize(); i++) { + for (i = 0; i < _waypointGroups.getSize(); i++) { if (_waypointGroups[i]->_active) { pfAddWaypointGroup(_waypointGroups[i], requester); } @@ -240,13 +240,13 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * // free waypoints - for (i = 0; i < _objects.GetSize(); i++) { + for (i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } CAdGame *adGame = (CAdGame *)Game; - for (i = 0; i < adGame->_objects.GetSize(); i++) { + for (i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); } @@ -261,10 +261,10 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { if (!wpt->_active) return; - for (int i = 0; i < wpt->_points.GetSize(); i++) { + for (int i = 0; i < wpt->_points.getSize(); i++) { if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; - //_pfPath.Add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); } } @@ -276,7 +276,7 @@ float CAdScene::getZoomAt(int x, int y) { bool found = false; if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { if (node->_region->_zoom != 0) { @@ -302,7 +302,7 @@ uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { else ret = 0xFFFFFFFF; if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { if (!node->_region->_blocked) ret = node->_region->_alpha; @@ -320,13 +320,13 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (checkFreeObjects) { - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } } CAdGame *adGame = (CAdGame *)Game; - for (int i = 0; i < adGame->_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } @@ -335,7 +335,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { CAdSceneNode *node = _mainLayer->_nodes[i]; /* if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) @@ -361,13 +361,13 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque bool ret = false; if (checkFreeObjects) { - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } } CAdGame *adGame = (CAdGame *)Game; - for (int i = 0; i < adGame->_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } @@ -376,7 +376,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.GetSize(); i++) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { CAdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { if (node->_region->_blocked) { @@ -459,7 +459,7 @@ void CAdScene::pathFinderStep() { // target point marked, generate path and terminate if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { while (lowestPt != NULL) { - _pfTargetPath->_points.InsertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); + _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); lowestPt = lowestPt->_origin; } @@ -646,7 +646,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { layer = NULL; } else { Game->registerObject(layer); - _layers.Add(layer); + _layers.add(layer); if (layer->_main) { _mainLayer = layer; _width = layer->_width; @@ -664,7 +664,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { wpt = NULL; } else { Game->registerObject(wpt); - _waypointGroups.Add(wpt); + _waypointGroups.add(wpt); } } break; @@ -677,7 +677,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { sl = NULL; } else { Game->registerObject(sl); - _scaleLevels.Add(sl); + _scaleLevels.add(sl); } } break; @@ -690,7 +690,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { rl = NULL; } else { Game->registerObject(rl); - _rotLevels.Add(rl); + _rotLevels.add(rl); } } break; @@ -943,7 +943,7 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { /* int MainOffsetX = 0; */ /* int MainOffsetY = 0; */ - for (j = 0; j < _layers.GetSize(); j++) { + for (j = 0; j < _layers.getSize(); j++) { if (!_layers[j]->_active) continue; // make layer exclusive @@ -977,7 +977,7 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // for each node - for (k = 0; k < _layers[j]->_nodes.GetSize(); k++) { + for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { CAdSceneNode *node = _layers[j]->_nodes[k]; switch (node->_type) { case OBJECT_ENTITY: @@ -1041,7 +1041,7 @@ ERRORCODE CAdScene::updateFreeObjects() { // *** update all active objects is3DSet = false; - for (int i = 0; i < adGame->_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { if (!adGame->_objects[i]->_active) continue; adGame->_objects[i]->update(); @@ -1049,7 +1049,7 @@ ERRORCODE CAdScene::updateFreeObjects() { } - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (!_objects[i]->_active) continue; _objects[i]->update(); @@ -1073,26 +1073,26 @@ ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) CAdObject *obj; // global objects - for (int i = 0; i < adGame->_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { obj = adGame->_objects[i]; if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.Add(obj); + objects.add(obj); } } // scene objects - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { obj = _objects[i]; if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.Add(obj); + objects.add(obj); } } // sort by _posY - qsort(objects.GetData(), objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); // display them - for (int i = 0; i < objects.GetSize(); i++) { + for (int i = 0; i < objects.getSize(); i++) { obj = objects[i]; if (display3DOnly && !obj->_is3D) continue; @@ -1107,7 +1107,7 @@ ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) // display design only objects if (!display3DOnly) { if (Game->_editorMode && region == NULL) { - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1140,7 +1140,7 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { int minY = INT_MAX; // global objects - for (int i = 0; i < adGame->_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { obj = adGame->_objects[i]; minY = adGame->_objects[i]->_posY; @@ -1148,7 +1148,7 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { } // scene objects - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { obj = _objects[i]; minY = _objects[i]->_posY; @@ -1167,7 +1167,7 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { // design only objects if (Game->_editorMode && region == NULL) { - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1344,12 +1344,12 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CScValue *val = stack->pop(); if (val->isInt()) { int layer = val->getInt(); - if (layer < 0 || layer >= _layers.GetSize()) stack->pushNULL(); + if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); else stack->pushNative(_layers[layer], true); } else { const char *LayerName = val->getString(); bool LayerFound = false; - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { stack->pushNative(_layers[i], true); LayerFound = true; @@ -1367,7 +1367,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t else if (strcmp(name, "GetWaypointGroup") == 0) { stack->correctParams(1); int group = stack->pop()->getInt(); - if (group < 0 || group >= _waypointGroups.GetSize()) stack->pushNULL(); + if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); else stack->pushNative(_waypointGroups[group], true); return STATUS_OK; } @@ -1396,10 +1396,10 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CAdObject *ret = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _objects.GetSize()) ret = _objects[index]; + if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; } else { const char *nodeName = val->getString(); - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { ret = _objects[i]; break; @@ -1425,7 +1425,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (!val->isNULL()) includeDecors = val->getBool(); if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (node->_region->_decoration && !includeDecors) continue; @@ -1591,7 +1591,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t layer->_width = _mainLayer->_width; layer->_height = _mainLayer->_height; } - _layers.Add(layer); + _layers.add(layer); Game->registerObject(layer); stack->pushNative(layer, true); @@ -1613,8 +1613,8 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t layer->_height = _mainLayer->_height; } if (index < 0) index = 0; - if (index <= _layers.GetSize() - 1) _layers.InsertAt(index, layer); - else _layers.Add(layer); + if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); + else _layers.add(layer); Game->registerObject(layer); @@ -1632,7 +1632,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CAdLayer *toDelete = NULL; if (val->isNative()) { CBScriptable *temp = val->getNative(); - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { if (_layers[i] == temp) { toDelete = _layers[i]; break; @@ -1640,7 +1640,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t } } else { int index = val->getInt(); - if (index >= 0 && index < _layers.GetSize()) { + if (index >= 0 && index < _layers.getSize()) { toDelete = _layers[index]; } } @@ -1655,9 +1655,9 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t return STATUS_OK; } - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { if (_layers[i] == toDelete) { - _layers.RemoveAt(i); + _layers.removeAt(i); Game->unregisterObject(toDelete); break; } @@ -1686,7 +1686,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLayers") == 0) { - _scValue->setInt(_layers.GetSize()); + _scValue->setInt(_layers.getSize()); return _scValue; } @@ -1694,7 +1694,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->setInt(_waypointGroups.GetSize()); + _scValue->setInt(_waypointGroups.getSize()); return _scValue; } @@ -1712,7 +1712,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFreeNodes") == 0) { - _scValue->setInt(_objects.GetSize()); + _scValue->setInt(_objects.getSize()); return _scValue; } @@ -1943,16 +1943,16 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::addObject(CAdObject *object) { - _objects.Add(object); + _objects.add(object); return Game->registerObject(object); } ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::removeObject(CAdObject *object) { - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { - _objects.RemoveAt(i); + _objects.removeAt(i); return Game->unregisterObject(object); } } @@ -1977,7 +1977,7 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { // scripts - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -2023,28 +2023,28 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { // waypoints buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.GetSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); buffer->putTextIndent(indent + 2, "\n"); // layers buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.GetSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); // scale levels buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.GetSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); // rotation levels buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.GetSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); buffer->putTextIndent(indent + 2, "\n"); // free entities buffer->putTextIndent(indent + 2, "; ----- free entities\n"); - for (i = 0; i < _objects.GetSize(); i++) { + for (i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { _objects[i]->saveAsText(buffer, indent + 2); @@ -2063,7 +2063,7 @@ ERRORCODE CAdScene::sortScaleLevels() { bool changed; do { changed = false; - for (int i = 0; i < _scaleLevels.GetSize() - 1; i++) { + for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { CAdScaleLevel *sl = _scaleLevels[i]; _scaleLevels[i] = _scaleLevels[i + 1]; @@ -2084,7 +2084,7 @@ ERRORCODE CAdScene::sortRotLevels() { bool changed; do { changed = false; - for (int i = 0; i < _rotLevels.GetSize() - 1; i++) { + for (int i = 0; i < _rotLevels.getSize() - 1; i++) { if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { CAdRotLevel *rl = _rotLevels[i]; _rotLevels[i] = _rotLevels[i + 1]; @@ -2105,9 +2105,9 @@ float CAdScene::getScaleAt(int Y) { CAdScaleLevel *prev = NULL; CAdScaleLevel *next = NULL; - for (int i = 0; i < _scaleLevels.GetSize(); i++) { + for (int i = 0; i < _scaleLevels.getSize(); i++) { /* CAdScaleLevel *xxx = _scaleLevels[i];*/ - /* int j = _scaleLevels.GetSize(); */ + /* int j = _scaleLevels.getSize(); */ if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; else { next = _scaleLevels[i]; @@ -2335,8 +2335,8 @@ void CAdScene::pfPointsStart() { ////////////////////////////////////////////////////////////////////////// void CAdScene::pfPointsAdd(int x, int y, int distance) { - if (_pfPointsNum >= _pfPath.GetSize()) { - _pfPath.Add(new CAdPathPoint(x, y, distance)); + if (_pfPointsNum >= _pfPath.getSize()) { + _pfPath.add(new CAdPathPoint(x, y, distance)); } else { _pfPath[_pfPointsNum]->x = x; _pfPath[_pfPointsNum]->y = y; @@ -2424,9 +2424,9 @@ CBObject *CAdScene::getNodeByName(const char *name) { CBObject *ret = NULL; // dependent objects - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.GetSize(); j++) { + for (int j = 0; j < layer->_nodes.getSize(); j++) { CAdSceneNode *node = layer->_nodes[j]; if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { @@ -2446,14 +2446,14 @@ CBObject *CAdScene::getNodeByName(const char *name) { } // free entities - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { return _objects[i]; } } // waypoint groups - for (int i = 0; i < _waypointGroups.GetSize(); i++) { + for (int i = 0; i < _waypointGroups.getSize(); i++) { if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { return _waypointGroups[i]; } @@ -2486,9 +2486,9 @@ ERRORCODE CAdScene::persistState(bool saving) { CAdNodeState *nodeState; // dependent objects - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.GetSize(); j++) { + for (int j = 0; j < layer->_nodes.getSize(); j++) { CAdSceneNode *node = layer->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: @@ -2516,7 +2516,7 @@ ERRORCODE CAdScene::persistState(bool saving) { } // free entities - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (!_objects[i]->_saveState) continue; if (_objects[i]->_type == OBJECT_ENTITY) { nodeState = state->getNodeState(_objects[i]->_name, saving); @@ -2529,7 +2529,7 @@ ERRORCODE CAdScene::persistState(bool saving) { } // waypoint groups - for (int i = 0; i < _waypointGroups.GetSize(); i++) { + for (int i = 0; i < _waypointGroups.getSize(); i++) { nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); if (nodeState) { if (saving) nodeState->_active = _waypointGroups[i]->_active; @@ -2546,9 +2546,9 @@ float CAdScene::getRotationAt(int x, int y) { CAdRotLevel *prev = NULL; CAdRotLevel *next = NULL; - for (int i = 0; i < _rotLevels.GetSize(); i++) { + for (int i = 0; i < _rotLevels.getSize(); i++) { /* CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.GetSize();*/ + int j = _rotLevels.getSize();*/ if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; else { next = _rotLevels[i]; @@ -2569,9 +2569,9 @@ float CAdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.GetSize(); j++) { + for (int j = 0; j < layer->_nodes.getSize(); j++) { if (layer->_nodes[j]->_type == OBJECT_ENTITY) { CAdEntity *ent = layer->_nodes[j]->_entity; @@ -2580,7 +2580,7 @@ ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { } } - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { CAdEntity *ent = (CAdEntity *)_objects[i]; if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; @@ -2595,7 +2595,7 @@ ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { ERRORCODE CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { int numUsed = 0; if (_mainLayer) { - for (int i = _mainLayer->_nodes.GetSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { CAdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (numUsed < numRegions - 1) { @@ -2623,12 +2623,12 @@ CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { CBArray objects; getSceneObjects(objects, true); - if (objects.GetSize() == 0) return NULL; + if (objects.getSize() == 0) return NULL; else { if (currObject != NULL) { - for (int i = 0; i < objects.GetSize(); i++) { + for (int i = 0; i < objects.getSize(); i++) { if (objects[i] == currObject) { - if (i < objects.GetSize() - 1) return objects[i + 1]; + if (i < objects.getSize() - 1) return objects[i + 1]; else break; } } @@ -2643,17 +2643,17 @@ CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { CBArray objects; getSceneObjects(objects, true); - if (objects.GetSize() == 0) return NULL; + if (objects.getSize() == 0) return NULL; else { if (currObject != NULL) { - for (int i = objects.GetSize() - 1; i >= 0; i--) { + for (int i = objects.getSize() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) return objects[i - 1]; else break; } } } - return objects[objects.GetSize() - 1]; + return objects[objects.getSize() - 1]; } return NULL; } @@ -2661,35 +2661,35 @@ CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { // close-up layer -> remove everything below it - if (interactiveOnly && _layers[i]->_closeUp) objects.RemoveAll(); + if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); - for (int j = 0; j < _layers[i]->_nodes.GetSize(); j++) { + for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { CAdSceneNode *node = _layers[i]->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: { CAdEntity *ent = node->_entity; if (ent->_active && (ent->_registrable || !interactiveOnly)) - objects.Add(ent); + objects.add(ent); } break; case OBJECT_REGION: { CBArray regionObj; getRegionObjects(node->_region, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.GetSize(); newIndex++) { + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; - for (int old = 0; old < objects.GetSize(); old++) { + for (int old = 0; old < objects.getSize(); old++) { if (objects[old] == regionObj[newIndex]) { found = true; break; } } - if (!found) objects.Add(regionObj[newIndex]); + if (!found) objects.add(regionObj[newIndex]); } - //if(RegionObj.GetSize() > 0) Objects.Append(RegionObj); + //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); } break; default: @@ -2702,15 +2702,15 @@ ERRORCODE CAdScene::getSceneObjects(CBArray &objects, // objects outside any region CBArray regionObj; getRegionObjects(NULL, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.GetSize(); newIndex++) { + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; - for (int old = 0; old < objects.GetSize(); old++) { + for (int old = 0; old < objects.getSize(); old++) { if (objects[old] == regionObj[newIndex]) { found = true; break; } } - if (!found) objects.Add(regionObj[newIndex]); + if (!found) objects.add(regionObj[newIndex]); } @@ -2724,27 +2724,27 @@ ERRORCODE CAdScene::getRegionObjects(CAdRegion *region, CBArray_objects.GetSize(); i++) { + for (int i = 0; i < adGame->_objects.getSize(); i++) { obj = adGame->_objects[i]; if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) continue; - objects.Add(obj); + objects.add(obj); } } // scene objects - for (int i = 0; i < _objects.GetSize(); i++) { + for (int i = 0; i < _objects.getSize(); i++) { obj = _objects[i]; if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) continue; - objects.Add(obj); + objects.add(obj); } } // sort by _posY - qsort(objects.GetData(), objects.GetSize(), sizeof(CAdObject *), CAdScene::compareObjs); + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 9778e8919d..00b1b6c250 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -48,8 +48,8 @@ CAdSceneState::~CAdSceneState() { delete[] _filename; _filename = NULL; - for (int i = 0; i < _nodeStates.GetSize(); i++) delete _nodeStates[i]; - _nodeStates.RemoveAll(); + for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; + _nodeStates.removeAll(); } @@ -72,14 +72,14 @@ void CAdSceneState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { - for (int i = 0; i < _nodeStates.GetSize(); i++) { + for (int i = 0; i < _nodeStates.getSize(); i++) { if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; } if (saving) { CAdNodeState *ret = new CAdNodeState(Game); ret->setName(name); - _nodeStates.Add(ret); + _nodeStates.add(ret); return ret; } else return NULL; diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 341f47a503..ed43630e0c 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -283,7 +283,7 @@ ERRORCODE CAdSentence::update(TDirection dir) { currentTime = Game->_timer - _startTime; bool talkNodeFound = false; - for (int i = 0; i < _talkDef->_nodes.GetSize(); i++) { + for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { talkNodeFound = true; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 0f16241e99..62b6ea8b67 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -53,8 +53,8 @@ CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdTalkDef::~CAdTalkDef() { - for (int i = 0; i < _nodes.GetSize(); i++) delete _nodes[i]; - _nodes.RemoveAll(); + for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; + _nodes.removeAll(); delete[] _defaultSpriteFilename; delete _defaultSprite; @@ -129,7 +129,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { case TOKEN_ACTION: { CAdTalkNode *Node = new CAdTalkNode(Game); - if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.Add(Node); + if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); else { delete Node; Node = NULL; @@ -217,7 +217,7 @@ ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); - for (int i = 0; i < _nodes.GetSize(); i++) { + for (int i = 0; i < _nodes.getSize(); i++) { _nodes[i]->saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "\n"); } diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index 5e25431d1a..eb4860b5d6 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -53,13 +53,13 @@ CAdTalkHolder::~CAdTalkHolder() { delete _sprite; _sprite = NULL; - for (int i = 0; i < _talkSprites.GetSize(); i++) + for (int i = 0; i < _talkSprites.getSize(); i++) delete _talkSprites[i]; - _talkSprites.RemoveAll(); + _talkSprites.removeAll(); - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) + for (int i = 0; i < _talkSpritesEx.getSize(); i++) delete _talkSpritesEx[i]; - _talkSpritesEx.RemoveAll(); + _talkSpritesEx.removeAll(); } ////////////////////////////////////////////////////////////////////////// @@ -85,7 +85,7 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { if (stance != NULL) { // search special talk stances - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { ret = _talkSpritesEx[i]; break; @@ -93,7 +93,7 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { } if (ret == NULL) { // serach generic talk stances - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { ret = _talkSprites[i]; break; @@ -104,10 +104,10 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.GetSize() < 1) ret = _sprite; + if (_talkSprites.getSize() < 1) ret = _sprite; else { // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.GetSize() - 1); + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]; } } @@ -189,8 +189,8 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta stack->pushBool(false); script->runtimeError("AddTalkSprite method failed for file '%s'", filename); } else { - if (Ex) _talkSpritesEx.Add(spr); - else _talkSprites.Add(spr); + if (Ex) _talkSpritesEx.add(spr); + else _talkSprites.add(spr); stack->pushBool(true); } return STATUS_OK; @@ -209,26 +209,26 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta bool setTemp2 = false; if (ex) { - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { if (_currentSprite == _talkSpritesEx[i]) setCurrent = true; if (_tempSprite2 == _talkSpritesEx[i]) setTemp2 = true; delete _talkSpritesEx[i]; - _talkSpritesEx.RemoveAt(i); + _talkSpritesEx.removeAt(i); break; } } } else { - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { if (_currentSprite == _talkSprites[i]) setCurrent = true; if (_tempSprite2 == _talkSprites[i]) setTemp2 = true; delete _talkSprites[i]; - _talkSprites.RemoveAt(i); + _talkSprites.removeAt(i); break; } } @@ -263,28 +263,28 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta // delete current if (ex) { - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (_talkSpritesEx[i] == _currentSprite) setCurrent = true; if (_talkSpritesEx[i] == _tempSprite2) setTemp2 = true; delete _talkSpritesEx[i]; } - _talkSpritesEx.RemoveAll(); + _talkSpritesEx.removeAll(); } else { - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { if (_talkSprites[i] == _currentSprite) setCurrent = true; if (_talkSprites[i] == _tempSprite2) setTemp2 = true; delete _talkSprites[i]; } - _talkSprites.RemoveAll(); + _talkSprites.removeAll(); } // set new if (ex) - _talkSpritesEx.Add(spr); + _talkSpritesEx.add(spr); else - _talkSprites.Add(spr); + _talkSprites.add(spr); stack->pushBool(true); if (setCurrent) @@ -338,12 +338,12 @@ const char *CAdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { - for (int i = 0; i < _talkSprites.GetSize(); i++) { + for (int i = 0; i < _talkSprites.getSize(); i++) { if (_talkSprites[i]->_filename) buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); } - for (int i = 0; i < _talkSpritesEx.GetSize(); i++) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (_talkSpritesEx[i]->_filename) buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); } diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index e9e18e5101..4ad2dc1749 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -56,9 +56,9 @@ CAdWaypointGroup::~CAdWaypointGroup() { ////////////////////////////////////////////////////////////////////////// void CAdWaypointGroup::cleanup() { - for (int i = 0; i < _points.GetSize(); i++) + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.RemoveAll(); + _points.removeAll(); _editorSelectedPoint = -1; } @@ -133,7 +133,7 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); + _points.add(new CBPoint(x, y)); } break; @@ -174,7 +174,7 @@ ERRORCODE CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { _scProp->saveAsText(buffer, indent + 2); CBBase::saveAsText(buffer, indent + 2); - for (int i = 0; i < _points.GetSize(); i++) { + for (int i = 0; i < _points.getSize(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } @@ -244,11 +244,11 @@ ERRORCODE CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, cleanup(); - for (int i = 0; i < wpt->_points.GetSize(); i++) { + for (int i = 0; i < wpt->_points.getSize(); i++) { int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); - _points.Add(new CBPoint(x + argX, y + argY)); + _points.add(new CBPoint(x + argX, y + argY)); } _lastMimicScale = scale; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 621089d803..706da2a93b 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -75,13 +75,13 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFileManager::cleanup() { // delete registered paths - for (int i = 0; i < _singlePaths.GetSize(); i++) + for (int i = 0; i < _singlePaths.getSize(); i++) delete [] _singlePaths[i]; - _singlePaths.RemoveAll(); + _singlePaths.removeAll(); - for (int i = 0; i < _packagePaths.GetSize(); i++) + for (int i = 0; i < _packagePaths.getSize(); i++) delete [] _packagePaths[i]; - _packagePaths.RemoveAll(); + _packagePaths.removeAll(); // delete file entries @@ -93,16 +93,16 @@ ERRORCODE CBFileManager::cleanup() { _files.clear(); // close open files - for (int i = 0; i < _openFiles.GetSize(); i++) { + for (int i = 0; i < _openFiles.getSize(); i++) { delete _openFiles[i]; } - _openFiles.RemoveAll(); + _openFiles.removeAll(); // delete packages - for (int i = 0; i < _packages.GetSize(); i++) + for (int i = 0; i < _packages.getSize(); i++) delete _packages[i]; - _packages.RemoveAll(); + _packages.removeAll(); delete[] _basePath; _basePath = NULL; @@ -226,7 +226,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *Buffer, ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages - for (int i = 0; i < _packages.GetSize(); i++) { + for (int i = 0; i < _packages.getSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); } @@ -250,10 +250,10 @@ ERRORCODE CBFileManager::addPath(TPathType type, const Common::String &path) { switch (type) { case PATH_SINGLE: - _singlePaths.Add(buffer); + _singlePaths.add(buffer); break; case PATH_PACKAGE: - _packagePaths.Add(buffer); + _packagePaths.add(buffer); break; } @@ -263,13 +263,13 @@ ERRORCODE CBFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFileManager::reloadPaths() { // delete registered paths - for (int i = 0; i < _singlePaths.GetSize(); i++) + for (int i = 0; i < _singlePaths.getSize(); i++) delete [] _singlePaths[i]; - _singlePaths.RemoveAll(); + _singlePaths.removeAll(); - for (int i = 0; i < _packagePaths.GetSize(); i++) + for (int i = 0; i < _packagePaths.getSize(); i++) delete [] _packagePaths[i]; - _packagePaths.RemoveAll(); + _packagePaths.removeAll(); return initPaths(); } @@ -361,7 +361,7 @@ ERRORCODE CBFileManager::registerPackages() { #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); - for (int i = 0; i < _packagePaths.GetSize(); i++) { + for (int i = 0; i < _packagePaths.getSize(); i++) { boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); @@ -386,10 +386,10 @@ ERRORCODE CBFileManager::registerPackages() { } } #endif - warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); - Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); + warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); + Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); - warning(" Registered %d files in %d package(s)", _files.size(), _packages.GetSize()); + warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); return STATUS_OK; } @@ -453,7 +453,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s pkg->_priority = hdr.Priority; if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.Add(pkg); + _packages.add(pkg); // read file entries @@ -583,7 +583,7 @@ ERRORCODE CBFileManager::registerPackage(const char *Path, const char *name, boo pkg->_priority = hdr.Priority; if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.Add(pkg); + _packages.add(pkg); // read file entries @@ -672,7 +672,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _packagePaths.GetSize(); i++) { + for (int i = 0; i < _packagePaths.getSize(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { @@ -698,7 +698,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { Common::File *ret = NULL; char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _singlePaths.GetSize(); i++) { + for (int i = 0; i < _singlePaths.getSize(); i++) { sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); ret->open(filename); if (ret->isOpen()) @@ -723,7 +723,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) Common::File f; bool found = false; - for (int i = 0; i < _singlePaths.GetSize(); i++) { + for (int i = 0; i < _singlePaths.getSize(); i++) { sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); f.open(fullname); if (f.isOpen()) { @@ -786,17 +786,17 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena #endif*/ Common::SeekableReadStream *File = openFileRaw(filename); - if (File && keepTrackOf) _openFiles.Add(File); + if (File && keepTrackOf) _openFiles.add(File); return File; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (int i = 0; i < _openFiles.GetSize(); i++) { + for (int i = 0; i < _openFiles.getSize(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; - _openFiles.RemoveAt(i); + _openFiles.removeAt(i); return STATUS_OK; } } diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 56e969d7e7..0af81f7ed4 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -231,8 +231,8 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { bool handled = false; if (_sprite) { _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.GetSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.GetSize() > 0) { + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); } handled = true; @@ -491,8 +491,8 @@ ERRORCODE CBFontBitmap::getWidths() { CBSurface *surf = NULL; if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.GetSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.GetSize() > 0) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; } } diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp index 7642a88bac..8b43510708 100644 --- a/engines/wintermute/Base/BFontStorage.cpp +++ b/engines/wintermute/Base/BFontStorage.cpp @@ -52,18 +52,18 @@ CBFontStorage::~CBFontStorage() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.GetSize(); i++) { + for (int i = 0; i < _fonts.getSize(); i++) { if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; } - _fonts.RemoveAll(); + _fonts.removeAll(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFontStorage::initLoop() { - for (int i = 0; i < _fonts.GetSize(); i++) { + for (int i = 0; i < _fonts.getSize(); i++) { _fonts[i]->initLoop(); } return STATUS_OK; @@ -73,7 +73,7 @@ ERRORCODE CBFontStorage::initLoop() { CBFont *CBFontStorage::addFont(const char *filename) { if (!filename) return NULL; - for (int i = 0; i < _fonts.GetSize(); i++) { + for (int i = 0; i < _fonts.getSize(); i++) { if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { _fonts[i]->_refCount++; return _fonts[i]; @@ -90,14 +90,14 @@ CBFont *CBFontStorage::addFont(const char *filename) { } else { font->_refCount = 1; - _fonts.Add(font); + _fonts.add(font); return font; } */ CBFont *font = CBFont::createFromFile(Game, filename); if (font) { font->_refCount = 1; - _fonts.Add(font); + _fonts.add(font); } return font; } @@ -107,12 +107,12 @@ CBFont *CBFontStorage::addFont(const char *filename) { ERRORCODE CBFontStorage::removeFont(CBFont *font) { if (!font) return STATUS_FAILED; - for (int i = 0; i < _fonts.GetSize(); i++) { + for (int i = 0; i < _fonts.getSize(); i++) { if (_fonts[i] == font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { delete _fonts[i]; - _fonts.RemoveAt(i); + _fonts.removeAt(i); } break; } diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 22f16a53f6..998aead064 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -73,10 +73,10 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { CBFontTT::~CBFontTT(void) { clearCache(); - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { delete _layers[i]; } - _layers.RemoveAll(); + _layers.removeAll(); delete[] _fontFile; _fontFile = NULL; @@ -219,7 +219,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i if (surface) { Common::Rect rc; CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.GetSize(); i++) { + for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = _renderer->_forceAlphaColor; if (_renderer->_forceAlphaColor != 0) { @@ -518,7 +518,7 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) { case TOKEN_LAYER: { CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.Add(Layer); + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); else { delete Layer; Layer = NULL; @@ -535,10 +535,10 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) { } // create at least one layer - if (_layers.GetSize() == 0) { + if (_layers.getSize() == 0) { CBTTFontLayer *Layer = new CBTTFontLayer; Layer->_color = BaseColor; - _layers.Add(Layer); + _layers.add(Layer); } if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); @@ -605,16 +605,16 @@ ERRORCODE CBFontTT::persist(CBPersistMgr *persistMgr) { // persist layers int numLayers; if (persistMgr->_saving) { - numLayers = _layers.GetSize(); + numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); } else { - numLayers = _layers.GetSize(); + numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { CBTTFontLayer *layer = new CBTTFontLayer; layer->persist(persistMgr); - _layers.Add(layer); + _layers.add(layer); } } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 5f516c3735..7680671434 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -62,15 +62,15 @@ CBFrame::~CBFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.GetSize(); i++) + for (int i = 0; i < _subframes.getSize(); i++) delete _subframes[i]; - _subframes.RemoveAll(); + _subframes.removeAll(); - for (int i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.getSize(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } - _applyEvent.RemoveAll(); + _applyEvent.removeAll(); } @@ -78,7 +78,7 @@ CBFrame::~CBFrame() { ERRORCODE CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { ERRORCODE res; - for (int i = 0; i < _subframes.GetSize(); i++) { + for (int i = 0; i < _subframes.getSize(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); if (DID_FAIL(res)) return res; } @@ -98,7 +98,7 @@ ERRORCODE CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { */ } if (owner) { - for (int i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.getSize(); i++) { owner->applyEvent(_applyEvent[i]); } } @@ -241,7 +241,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; - } else _subframes.Add(subframe); + } else _subframes.add(subframe); } break; @@ -262,7 +262,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { case TOKEN_APPLY_EVENT: { char *Event = new char[strlen(params) + 1]; strcpy(Event, params); - _applyEvent.Add(Event); + _applyEvent.add(Event); } break; @@ -318,7 +318,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { sub->_editorSelected = editorSelected; - _subframes.InsertAt(0, sub); + _subframes.insertAt(0, sub); return STATUS_OK; } @@ -331,7 +331,7 @@ bool CBFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, fl Common::Rect subRect; - for (int i = 0; i < _subframes.GetSize(); i++) { + for (int i = 0; i < _subframes.getSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); CBPlatform::unionRect(rect, rect, &subRect); } @@ -359,13 +359,13 @@ ERRORCODE CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { if (_editorExpanded) buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - if (_subframes.GetSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); - for (int i = 1; i < _subframes.GetSize(); i++) { + for (int i = 1; i < _subframes.getSize(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); } - for (int i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.getSize(); i++) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } @@ -438,7 +438,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.GetSize()) { + if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else stack->pushNative(_subframes[index], true); @@ -454,15 +454,15 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _subframes.GetSize()) { + if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { CBSubFrame *sub = (CBSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.GetSize(); i++) { + for (int i = 0; i < _subframes.getSize(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; - _subframes.RemoveAt(i); + _subframes.removeAt(i); break; } } @@ -485,7 +485,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th sub->setSurface(filename); sub->setDefaultRect(); } - _subframes.Add(sub); + _subframes.add(sub); stack->pushNative(sub, true); return STATUS_OK; @@ -508,8 +508,8 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th sub->setSurface(filename); } - if (index >= _subframes.GetSize()) _subframes.Add(sub); - else _subframes.InsertAt(index, sub); + if (index >= _subframes.getSize()) _subframes.add(sub); + else _subframes.insertAt(index, sub); stack->pushNative(sub, true); return STATUS_OK; @@ -521,7 +521,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.GetSize()) { + if (index < 0 || index >= _applyEvent.getSize()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else stack->pushString(_applyEvent[index]); @@ -534,13 +534,13 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "AddEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { stack->pushNULL(); return STATUS_OK; } } - _applyEvent.Add(event); + _applyEvent.add(event); stack->pushNULL(); return STATUS_OK; } @@ -551,10 +551,10 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "DeleteEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.GetSize(); i++) { + for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { delete [] _applyEvent[i]; - _applyEvent.RemoveAt(i); + _applyEvent.removeAt(i); break; } } @@ -564,7 +564,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); else return CBScriptable::scCallMethod(script, stack, thisStack, name); } } @@ -627,7 +627,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.GetSize()); + _scValue->setInt(_subframes.getSize()); return _scValue; } @@ -635,13 +635,13 @@ CScValue *CBFrame::scGetProperty(const char *name) { // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.GetSize()); + _scValue->setInt(_applyEvent.getSize()); return _scValue; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scGetProperty(name); + if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); else return CBScriptable::scGetProperty(name); } } @@ -691,7 +691,7 @@ ERRORCODE CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.GetSize() == 1) return _subframes[0]->scSetProperty(name, value); + if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); else return CBScriptable::scSetProperty(name, value); } } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 26afb8a7d9..d1ade0e3fd 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -360,13 +360,13 @@ ERRORCODE CBGame::cleanup() { unregisterObject(_fader); _fader = NULL; - for (int i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.getSize(); i++) { delete _regObjects[i]; _regObjects[i] = NULL; } - _regObjects.RemoveAll(); + _regObjects.removeAll(); - _windows.RemoveAll(); // refs only + _windows.removeAll(); // refs only _focusedWindow = NULL; // ref only delete[] _saveImageName; @@ -386,11 +386,11 @@ ERRORCODE CBGame::cleanup() { _scValue = NULL; _sFX = NULL; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { _scripts[i]->_owner = NULL; _scripts[i]->finish(); } - _scripts.RemoveAll(); + _scripts.removeAll(); _fontStorage->removeFont(_systemFont); _systemFont = NULL; @@ -398,10 +398,10 @@ ERRORCODE CBGame::cleanup() { _fontStorage->removeFont(_videoFont); _videoFont = NULL; - for (int i = 0; i < _quickMessages.GetSize(); i++) delete _quickMessages[i]; - _quickMessages.RemoveAll(); + for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + _quickMessages.removeAll(); - _viewportStack.RemoveAll(); + _viewportStack.removeAll(); _viewportSP = -1; delete[] _name; @@ -657,7 +657,7 @@ ERRORCODE CBGame::initLoop() { getMousePos(&_mousePos); _focusedWindow = NULL; - for (int i = _windows.GetSize() - 1; i >= 0; i--) { + for (int i = _windows.getSize() - 1; i >= 0; i--) { if (_windows[i]->_visible) { _focusedWindow = _windows[i]; break; @@ -1097,7 +1097,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); CUIWindow *win = new CUIWindow(Game); if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { - _windows.Add(win); + _windows.add(win); registerObject(win); stack->pushNative(win, true); } else { @@ -1856,7 +1856,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi CScValue *val = stack->pop(); CUIWindow *win = new CUIWindow(Game); - _windows.Add(win); + _windows.add(win); registerObject(win); if (!val->isNULL()) win->setName(val->getString()); stack->pushNative(win, true); @@ -1869,7 +1869,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); CBObject *obj = (CBObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == obj) { unregisterObject(_windows[i]); stack->pushBool(true); @@ -2771,13 +2771,13 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::displayQuickMsg() { - if (_quickMessages.GetSize() == 0 || !_systemFont) return STATUS_OK; + if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; // update - for (int i = 0; i < _quickMessages.GetSize(); i++) { + for (int i = 0; i < _quickMessages.getSize(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; - _quickMessages.RemoveAt(i); + _quickMessages.removeAt(i); i--; } } @@ -2785,7 +2785,7 @@ ERRORCODE CBGame::displayQuickMsg() { int posY = 20; // display - for (int i = 0; i < _quickMessages.GetSize(); i++) { + for (int i = 0; i < _quickMessages.getSize(); i++) { _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } @@ -2796,11 +2796,11 @@ ERRORCODE CBGame::displayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// void CBGame::quickMessage(const char *text) { - if (_quickMessages.GetSize() >= MAX_QUICK_MSG) { + if (_quickMessages.getSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; - _quickMessages.RemoveAt(0); + _quickMessages.removeAt(0); } - _quickMessages.Add(new CBQuickMsg(Game, text)); + _quickMessages.add(new CBQuickMsg(Game, text)); } @@ -2819,7 +2819,7 @@ void CBGame::quickMessageForm(char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::registerObject(CBObject *object) { - _regObjects.Add(object); + _regObjects.add(object); return STATUS_OK; } @@ -2829,9 +2829,9 @@ ERRORCODE CBGame::unregisterObject(CBObject *object) { if (!object) return STATUS_OK; // is it a window? - for (int i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.getSize(); i++) { if ((CBObject *)_windows[i] == object) { - _windows.RemoveAt(i); + _windows.removeAt(i); // get new focused window if (_focusedWindow == object) _focusedWindow = NULL; @@ -2849,9 +2849,9 @@ ERRORCODE CBGame::unregisterObject(CBObject *object) { if (_store) _store->OnObjectDestroyed(object); // destroy object - for (int i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { - _regObjects.RemoveAt(i); + _regObjects.removeAt(i); if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); delete object; return STATUS_OK; @@ -2881,7 +2881,7 @@ bool CBGame::validObject(CBObject *object) { if (!object) return false; if (object == this) return true; - for (int i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) return true; } return false; @@ -3354,7 +3354,7 @@ ERRORCODE CBGame::displayWindows(bool inGame) { // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { _focusedWindow = NULL; - for (int i = _windows.GetSize() - 1; i >= 0; i--) { + for (int i = _windows.getSize() - 1; i >= 0; i--) { if (_windows[i]->_visible && !_windows[i]->_disable) { _focusedWindow = _windows[i]; break; @@ -3363,7 +3363,7 @@ ERRORCODE CBGame::displayWindows(bool inGame) { } // display all windows - for (int i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); @@ -3679,11 +3679,11 @@ ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { ERRORCODE CBGame::focusWindow(CUIWindow *Window) { CUIWindow *Prev = _focusedWindow; - for (int i = 0; i < _windows.GetSize(); i++) { + for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == Window) { - if (i < _windows.GetSize() - 1) { - _windows.RemoveAt(i); - _windows.Add(Window); + if (i < _windows.getSize() - 1) { + _windows.removeAt(i); + _windows.add(Window); Game->_focusedWindow = Window; } @@ -3938,7 +3938,7 @@ ERRORCODE CBGame::setActiveObject(CBObject *obj) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::pushViewport(CBViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.GetSize()) _viewportStack.Add(viewport); + if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); else _viewportStack[_viewportSP] = viewport; _renderer->setViewport(viewport->getRect()); @@ -3952,7 +3952,7 @@ ERRORCODE CBGame::popViewport() { _viewportSP--; if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); - if (_viewportSP >= 0 && _viewportSP < _viewportStack.GetSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); else _renderer->setViewport(_renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, @@ -4139,7 +4139,7 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->invalidateDeviceObjects(); } return STATUS_OK; @@ -4148,7 +4148,7 @@ ERRORCODE CBGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.GetSize(); i++) { + for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->restoreDeviceObjects(); } return STATUS_OK; diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 45b202e35f..63e862a569 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -61,8 +61,8 @@ CBRegion::~CBRegion() { ////////////////////////////////////////////////////////////////////////// void CBRegion::cleanup() { - for (int i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); CBPlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; @@ -77,7 +77,7 @@ bool CBRegion::createRegion() { ////////////////////////////////////////////////////////////////////////// bool CBRegion::pointInRegion(int x, int y) { - if (_points.GetSize() < 3) return false; + if (_points.getSize() < 3) return false; Common::Point pt; pt.x = x; @@ -155,8 +155,8 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { int i; - for (i = 0; i < _points.GetSize(); i++) delete _points[i]; - _points.RemoveAll(); + for (i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -179,7 +179,7 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.Add(new CBPoint(x, y)); + _points.add(new CBPoint(x, y)); } break; @@ -220,7 +220,7 @@ ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - _points.Add(new CBPoint(x, y)); + _points.add(new CBPoint(x, y)); createRegion(); stack->pushBool(true); @@ -237,8 +237,8 @@ ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.GetSize()) { - _points.InsertAt(Index, new CBPoint(x, y)); + if (Index >= 0 && Index < _points.getSize()) { + _points.insertAt(Index, new CBPoint(x, y)); createRegion(); stack->pushBool(true); @@ -256,7 +256,7 @@ ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.GetSize()) { + if (Index >= 0 && Index < _points.getSize()) { _points[Index]->x = x; _points[Index]->y = y; createRegion(); @@ -274,11 +274,11 @@ ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.GetSize()) { + if (index >= 0 && index < _points.getSize()) { delete _points[index]; _points[index] = NULL; - _points.RemoveAt(index); + _points.removeAt(index); createRegion(); stack->pushBool(true); @@ -294,7 +294,7 @@ ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.GetSize()) { + if (index >= 0 && index < _points.getSize()) { CScValue *val = stack->getPushValue(); if (val) { val->setProperty("X", _points[index]->x); @@ -341,7 +341,7 @@ CScValue *CBRegion::scGetProperty(const char *name) { // NumPoints ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.GetSize()); + _scValue->setInt(_points.getSize()); return _scValue; } @@ -389,11 +389,11 @@ ERRORCODE CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *name int i; - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < _points.GetSize(); i++) { + for (i = 0; i < _points.getSize(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } @@ -427,7 +427,7 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool CBRegion::ptInPolygon(int x, int y) { - if (_points.GetSize() < 3) return false; + if (_points.getSize() < 3) return false; int counter = 0; double xinters; @@ -439,9 +439,9 @@ bool CBRegion::ptInPolygon(int x, int y) { p1.x = (double)_points[0]->x; p1.y = (double)_points[0]->y; - for (int i = 1; i <= _points.GetSize(); i++) { - p2.x = (double)_points[i % _points.GetSize()]->x; - p2.y = (double)_points[i % _points.GetSize()]->y; + for (int i = 1; i <= _points.getSize(); i++) { + p2.x = (double)_points[i % _points.getSize()]->x; + p2.y = (double)_points[i % _points.getSize()]->y; if (p.y > MIN(p1.y, p2.y)) { if (p.y <= MAX(p1.y, p2.y)) { @@ -466,11 +466,11 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBRegion::getBoundingRect(Common::Rect *rect) { - if (_points.GetSize() == 0) CBPlatform::setRectEmpty(rect); + if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - for (int i = 0; i < _points.GetSize(); i++) { + for (int i = 0; i < _points.getSize(); i++) { MinX = MIN(MinX, _points[i]->x); MinY = MIN(MinY, _points[i]->y); @@ -489,13 +489,13 @@ ERRORCODE CBRegion::mimic(CBRegion *region, float scale, int x, int y) { cleanup(); - for (int i = 0; i < region->_points.GetSize(); i++) { + for (int i = 0; i < region->_points.getSize(); i++) { int xVal, yVal; xVal = (int)((float)region->_points[i]->x * scale / 100.0f); yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - _points.Add(new CBPoint(xVal + x, yVal + y)); + _points.add(new CBPoint(xVal + x, yVal + y)); } _lastMimicScale = scale; diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 323c6cc7be..51202d26ef 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -639,7 +639,7 @@ void CBRenderSDL::dumpData(const char *filename) { int TotalKB = 0; int TotalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.GetSize(); i++) { + for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->_surfaces[i]; if (!Surf->_filename) continue; if (!Surf->_valid) continue; @@ -653,7 +653,7 @@ void CBRenderSDL::dumpData(const char *filename) { fprintf(f, "%d;", kb); fprintf(f, "\n"); } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.GetSize(), TotalKB); + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); fclose(f); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index a3774e3770..b593161c41 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -72,7 +72,7 @@ CBObject *CBRenderer::getObjectAt(int x, int y) { point.x = x; point.y = y; - for (int i = _rectList.GetSize() - 1; i >= 0; i--) { + for (int i = _rectList.getSize() - 1; i >= 0; i--) { if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame @@ -106,10 +106,10 @@ CBObject *CBRenderer::getObjectAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// void CBRenderer::deleteRectList() { - for (int i = 0; i < _rectList.GetSize(); i++) { + for (int i = 0; i < _rectList.getSize(); i++) { delete _rectList[i]; } - _rectList.RemoveAll(); + _rectList.removeAll(); } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 160ba7e2cd..40e7d5d392 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -61,11 +61,11 @@ ERRORCODE CBScriptHolder::cleanup() { int i; - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } - _scripts.RemoveAll(); + _scripts.removeAll(); return STATUS_OK; } @@ -84,11 +84,11 @@ ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; ERRORCODE ret = STATUS_FAILED; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread) { CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { - //_scripts.Add(handler); + //_scripts.add(handler); numHandlers++; ret = STATUS_OK; } @@ -175,7 +175,7 @@ ERRORCODE CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScSt const char *filename = stack->pop()->getString(); bool killThreads = stack->pop()->getBool(false); bool ret = false; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { _scripts[i]->finish(killThreads); ret = true; @@ -194,7 +194,7 @@ ERRORCODE CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScSt stack->correctParams(1); const char *filename = stack->pop()->getString(); bool ret = false; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; @@ -277,7 +277,7 @@ ERRORCODE CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); @@ -295,8 +295,8 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) { strcpy(scr->_filename, filename); scr->_state = SCRIPT_ERROR; scr->_owner = this; - _scripts.Add(scr); - Game->_scEngine->_scripts.Add(scr); + _scripts.add(scr); + Game->_scEngine->_scripts.add(scr); Game->getDebugMgr()->onScriptInit(scr); return STATUS_OK; @@ -304,7 +304,7 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) { return STATUS_FAILED; } else { scr->_freezable = _freezable; - _scripts.Add(scr); + _scripts.add(scr); return STATUS_OK; } } @@ -312,9 +312,9 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBScriptHolder::removeScript(CScScript *script) { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { - _scripts.RemoveAt(i); + _scripts.removeAt(i); break; } } @@ -323,7 +323,7 @@ ERRORCODE CBScriptHolder::removeScript(CScScript *script) { ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; } return false; @@ -332,7 +332,7 @@ bool CBScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// bool CBScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; } return false; @@ -420,7 +420,7 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// void CBScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; - for (int i = 0; i < _scripts.GetSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->_freezable = freezable; } @@ -428,14 +428,14 @@ void CBScriptHolder::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.GetSize() - 1; i >= 0; i--) { + for (int i = _scripts.getSize() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { CScScript *thread = new CScScript(Game, _scripts[i]->_engine); if (thread) { ERRORCODE ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.Add(thread); + _scripts[i]->_engine->_scripts.add(thread); Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); return thread; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 9e038fd5fc..b8393bc0f2 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -60,9 +60,9 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.GetSize(); i++) + for (int i = 0; i < _sounds.getSize(); i++) delete _sounds[i]; - _sounds.RemoveAll(); + _sounds.removeAll(); #if 0 BASS_Free(); #endif @@ -174,7 +174,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool } // register sound - _sounds.Add(sound); + _sounds.add(sound); return sound; @@ -200,17 +200,17 @@ ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { } // register sound - _sounds.Add(sound); + _sounds.add(sound); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (int i = 0; i < _sounds.GetSize(); i++) { + for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; - _sounds.RemoveAt(i); + _sounds.removeAt(i); return STATUS_OK; } } @@ -236,7 +236,7 @@ ERRORCODE CBSoundMgr::setVolume(TSoundType type, int volume) { break; } - for (int i = 0; i < _sounds.GetSize(); i++) { + for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i]->_type == type) _sounds[i]->setVolume(volume); } @@ -295,7 +295,7 @@ byte CBSoundMgr::getMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { - for (int i = 0; i < _sounds.GetSize(); i++) { + for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; @@ -309,7 +309,7 @@ ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::resumeAll() { - for (int i = 0; i < _sounds.GetSize(); i++) { + for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i]->_freezePaused) { _sounds[i]->resume(); _sounds[i]->_freezePaused = false; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 349cb1e2f5..6fd5152d70 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -90,9 +90,9 @@ void CBSprite::setDefaults() { void CBSprite::cleanup() { CBScriptHolder::cleanup(); - for (int i = 0; i < _frames.GetSize(); i++) + for (int i = 0; i < _frames.getSize(); i++) delete _frames[i]; - _frames.RemoveAll(); + _frames.removeAll(); delete[] _editorBgFile; _editorBgFile = NULL; @@ -104,7 +104,7 @@ void CBSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; // move owner if allowed to if (_changed && _owner && _owner->_movable) { @@ -147,8 +147,8 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp delete subframe; } else { CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); - frame->_subframes.Add(subframe); - _frames.Add(frame); + frame->_subframes.add(subframe); + _frames.add(frame); _currentFrame = 0; ret = STATUS_OK; } @@ -295,7 +295,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit return STATUS_FAILED; } - _frames.Add(frame); + _frames.add(frame); frameCount++; if (_currentFrame == -1) _currentFrame = 0; } @@ -319,7 +319,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit ////////////////////////////////////////////////////////////////////// void CBSprite::reset() { - if (_frames.GetSize() > 0) _currentFrame = 0; + if (_frames.getSize() > 0) _currentFrame = 0; else _currentFrame = -1; killAllSounds(); @@ -344,9 +344,9 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { // get current frame if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.GetSize() - 1) { + if (_currentFrame < _frames.getSize() - 1) { _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); } else { if (_looping) { _currentFrame = 0; @@ -360,12 +360,12 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { _lastFrameTime = timer; } - _changed = (lastFrame != _currentFrame || (_looping && _frames.GetSize() == 1)); + _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); if (_lastFrameTime == 0) { _lastFrameTime = timer; _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.GetSize() - 1); + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); } if (_changed) { @@ -384,7 +384,7 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; // on change... if (_changed) { @@ -403,9 +403,9 @@ ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ////////////////////////////////////////////////////////////////////////// CBSurface *CBSprite::getSurface() { // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.GetSize()) return NULL; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; CBFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.GetSize() > 0) { + if (Frame && Frame->_subframes.getSize() > 0) { CBSubFrame *Subframe = Frame->_subframes[0]; if (Subframe) return Subframe->_surface; else return NULL; @@ -417,7 +417,7 @@ bool CBSprite::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, f if (!rect) return false; CBPlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.GetSize(); i++) { + for (int i = 0; i < _frames.getSize(); i++) { Common::Rect frame; Common::Rect temp; CBPlatform::copyRect(&temp, rect); @@ -456,12 +456,12 @@ ERRORCODE CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { int i; // scripts - for (i = 0; i < _scripts.GetSize(); i++) { + for (i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < _frames.GetSize(); i++) { + for (i = 0; i < _frames.getSize(); i++) { _frames[i]->saveAsText(buffer, indent + 2); } @@ -514,7 +514,7 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.GetSize()) { + if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); } else stack->pushNative(_frames[Index], true); @@ -529,16 +529,16 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CScValue *Val = stack->pop(); if (Val->isInt()) { int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.GetSize()) { + if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { CBFrame *Frame = (CBFrame *)Val->getNative(); - for (int i = 0; i < _frames.GetSize(); i++) { + for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i] == Frame) { if (i == _currentFrame) _lastFrameTime = 0; delete _frames[i]; - _frames.RemoveAt(i); + _frames.removeAt(i); break; } } @@ -571,10 +571,10 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CBSubFrame *sub = new CBSubFrame(Game); if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); - frame->_subframes.Add(sub); + frame->_subframes.add(sub); } else delete sub; } - _frames.Add(frame); + _frames.add(frame); stack->pushNative(frame, true); return STATUS_OK; @@ -597,13 +597,13 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CBFrame *frame = new CBFrame(Game); if (filename != NULL) { CBSubFrame *sub = new CBSubFrame(Game); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.Add(sub); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); else delete sub; } - if (index >= _frames.GetSize()) - _frames.Add(frame); - else _frames.InsertAt(index, frame); + if (index >= _frames.getSize()) + _frames.add(frame); + else _frames.insertAt(index, frame); stack->pushNative(frame, true); return STATUS_OK; @@ -649,7 +649,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.GetSize()); + _scValue->setInt(_frames.getSize()); return _scValue; } @@ -713,7 +713,7 @@ ERRORCODE CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "CurrentFrame") == 0) { _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.GetSize() || _currentFrame < 0) { + if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { _currentFrame = -1; } _lastFrameTime = 0; @@ -748,7 +748,7 @@ const char *CBSprite::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSprite::killAllSounds() { - for (int i = 0; i < _frames.GetSize(); i++) { + for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i]->_sound) _frames[i]->_sound->stop(); } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 4a1a5ec1f0..11450a1349 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -209,9 +209,9 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - Game->_renderer->_rectList.Add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (Game->_suspendedRendering) return STATUS_OK; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index eedfbca178..1c6bb33af3 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -52,11 +52,11 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::cleanup(bool warn) { - for (int i = 0; i < _surfaces.GetSize(); i++) { + for (int i = 0; i < _surfaces.getSize(); i++) { if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); delete _surfaces[i]; } - _surfaces.RemoveAll(); + _surfaces.removeAll(); return STATUS_OK; } @@ -67,7 +67,7 @@ ERRORCODE CBSurfaceStorage::initLoop() { if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { _lastCleanupTime = Game->_liveTimer; sortSurfaces(); - for (int i = 0; i < _surfaces.GetSize(); i++) { + for (int i = 0; i < _surfaces.getSize(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { @@ -82,12 +82,12 @@ ERRORCODE CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.GetSize(); i++) { + for (int i = 0; i < _surfaces.getSize(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; if (_surfaces[i]->_referenceCount <= 0) { delete _surfaces[i]; - _surfaces.RemoveAt(i); + _surfaces.removeAt(i); } break; } @@ -98,7 +98,7 @@ ERRORCODE CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (int i = 0; i < _surfaces.GetSize(); i++) { + for (int i = 0; i < _surfaces.getSize(); i++) { if (scumm_stricmp(_surfaces[i]->_filename, filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; @@ -123,7 +123,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by return NULL; } else { surface->_referenceCount = 1; - _surfaces.Add(surface); + _surfaces.add(surface); return surface; } } @@ -132,7 +132,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::restoreAll() { ERRORCODE ret; - for (int i = 0; i < _surfaces.GetSize(); i++) { + for (int i = 0; i < _surfaces.getSize(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); @@ -161,7 +161,7 @@ ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::sortSurfaces() { - qsort(_surfaces.GetData(), _surfaces.GetSize(), sizeof(CBSurface *), surfaceSortCB); + qsort(_surfaces.getData(), _surfaces.getSize(), sizeof(CBSurface *), surfaceSortCB); return STATUS_OK; } diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp index a07b5a90c7..c3efc74eec 100644 --- a/engines/wintermute/Base/PartEmitter.cpp +++ b/engines/wintermute/Base/PartEmitter.cpp @@ -95,21 +95,21 @@ CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inG ////////////////////////////////////////////////////////////////////////// CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.RemoveAll(); + _particles.removeAll(); - for (int i = 0; i < _forces.GetSize(); i++) { + for (int i = 0; i < _forces.getSize(); i++) { delete _forces[i]; } - _forces.RemoveAll(); + _forces.removeAll(); - for (int i = 0; i < _sprites.GetSize(); i++) { + for (int i = 0; i < _sprites.getSize(); i++) { delete [] _sprites[i]; } - _sprites.RemoveAll(); + _sprites.removeAll(); delete[] _emitEvent; _emitEvent = NULL; @@ -120,7 +120,7 @@ ERRORCODE CPartEmitter::addSprite(const char *filename) { if (!filename) return STATUS_FAILED; // do we already have the file? - for (int i = 0; i < _sprites.GetSize(); i++) { + for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; } @@ -133,17 +133,17 @@ ERRORCODE CPartEmitter::addSprite(const char *filename) { char *Str = new char[strlen(filename) + 1]; strcpy(Str, filename); - _sprites.Add(Str); + _sprites.add(Str); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.GetSize(); i++) { + for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; - _sprites.RemoveAt(i); + _sprites.removeAt(i); return STATUS_OK; } } @@ -153,7 +153,7 @@ ERRORCODE CPartEmitter::removeSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { if (!particle) return STATUS_FAILED; - if (_sprites.GetSize() == 0) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; int posX = CBUtils::randomInt(_posX, _posX + _width); int posY = CBUtils::randomInt(_posY, _posY + _height); @@ -172,7 +172,7 @@ ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.GetSize() - 1); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); float rotation = CBUtils::randomAngle(_rotation1, _rotation2); float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); @@ -235,7 +235,7 @@ ERRORCODE CPartEmitter::update() { ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->update(this, currentTime, timerDelta); if (!_particles[i]->_isDead) numLive++; @@ -256,7 +256,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int toGen = MIN(_genAmount, _maxParticles - numLive); while (toGen > 0) { int firstDeadIndex = -1; - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { if (_particles[i]->_isDead) { firstDeadIndex = i; break; @@ -267,7 +267,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; else { particle = new CPartParticle(Game); - _particles.Add(particle); + _particles.add(particle); } initParticle(particle, currentTime, timerDelta); needsSort = true; @@ -289,9 +289,9 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::display(CBRegion *region) { - if (_sprites.GetSize() <= 1) Game->_renderer->startSpriteBatch(); + if (_sprites.getSize() <= 1) Game->_renderer->startSpriteBatch(); - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { if (region != NULL && _useRegion) { if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; } @@ -299,14 +299,14 @@ ERRORCODE CPartEmitter::display(CBRegion *region) { _particles[i]->display(this); } - if (_sprites.GetSize() <= 1) Game->_renderer->endSpriteBatch(); + if (_sprites.getSize() <= 1) Game->_renderer->endSpriteBatch(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::start() { - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->_isDead = true; } _running = true; @@ -331,7 +331,7 @@ ERRORCODE CPartEmitter::start() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.GetData(), _particles.GetSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); return STATUS_OK; } @@ -366,7 +366,7 @@ ERRORCODE CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight CPartForce *CPartEmitter::addForceByName(const char *name) { CPartForce *force = NULL; - for (int i = 0; i < _forces.GetSize(); i++) { + for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { force = _forces[i]; break; @@ -376,7 +376,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { force = new CPartForce(Game); if (force) { force->setName(name); - _forces.Add(force); + _forces.add(force); } } return force; @@ -401,10 +401,10 @@ ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::removeForce(const char *name) { - for (int i = 0; i < _forces.GetSize(); i++) { + for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; - _forces.RemoveAt(i); + _forces.removeAt(i); return STATUS_OK; } } @@ -482,10 +482,10 @@ ERRORCODE CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStac else if (strcmp(name, "Stop") == 0) { stack->correctParams(0); - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.RemoveAll(); + _particles.removeAll(); _running = false; stack->pushBool(true); @@ -745,7 +745,7 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLiveParticles") == 0) { int numAlive = 0; - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { if (_particles[i] && !_particles[i]->_isDead) numAlive++; } _scValue->setInt(numAlive); @@ -1163,9 +1163,9 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { int numForces; if (persistMgr->_saving) { - numForces = _forces.GetSize(); + numForces = _forces.getSize(); persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.GetSize(); i++) { + for (int i = 0; i < _forces.getSize(); i++) { _forces[i]->persist(persistMgr); } } else { @@ -1173,15 +1173,15 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { for (int i = 0; i < numForces; i++) { CPartForce *force = new CPartForce(Game); force->persist(persistMgr); - _forces.Add(force); + _forces.add(force); } } int numParticles; if (persistMgr->_saving) { - numParticles = _particles.GetSize(); + numParticles = _particles.getSize(); persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.GetSize(); i++) { + for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->persist(persistMgr); } } else { @@ -1189,7 +1189,7 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { for (int i = 0; i < numParticles; i++) { CPartParticle *particle = new CPartParticle(Game); particle->persist(persistMgr); - _particles.Add(particle); + _particles.add(particle); } } diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 9d667bdca8..3eaa546d29 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -143,7 +143,7 @@ ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint3 // update position float elapsedTime = (float)timerDelta / 1000.f; - for (int i = 0; i < emitter->_forces.GetSize(); i++) { + for (int i = 0; i < emitter->_forces.getSize(); i++) { CPartForce *force = emitter->_forces[i]; switch (force->_type) { case CPartForce::FORCE_GLOBAL: diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index 1e9ec96e66..4287458b8e 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -50,7 +50,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileM uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (int i = 0; i < fileManager->_singlePaths.GetSize(); i++) { + for (int i = 0; i < fileManager->_singlePaths.getSize(); i++) { sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); correctSlashes(fullPath); Common::File *tempFile = new Common::File(); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index 4658f48216..065fac5255 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -68,16 +68,16 @@ CSXStore::~CSXStore() { void CSXStore::cleanup() { setEventsEnabled(NULL, false); - for (int i = 0; i < _validProducts.GetSize(); i++) { + for (int i = 0; i < _validProducts.getSize(); i++) { delete _validProducts[i]; } - _validProducts.RemoveAll(); + _validProducts.removeAll(); - for (int i = 0; i < _transactions.GetSize(); i++) { + for (int i = 0; i < _transactions.getSize(); i++) { delete _transactions[i]; } - _transactions.RemoveAll(); + _transactions.removeAll(); _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL; @@ -120,7 +120,7 @@ ERRORCODE CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *t else if (strcmp(name, "GetValidProduct") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _validProducts.GetSize()) { + if (index >= 0 && index < _validProducts.getSize()) { CScValue *prod = stack->getPushValue(); if (prod) { prod->setProperty("Id", _validProducts[index]->getId()); @@ -152,7 +152,7 @@ ERRORCODE CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *t else if (strcmp(name, "GetTransaction") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _transactions.GetSize()) { + if (index >= 0 && index < _transactions.getSize()) { CScValue *trans = stack->getPushValue(); if (trans) { trans->setProperty("Id", _transactions[index]->getId()); @@ -255,7 +255,7 @@ CScValue *CSXStore::scGetProperty(const char *name) { // NumValidProducts (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumValidProducts") == 0) { - _scValue->setInt(_validProducts.GetSize()); + _scValue->setInt(_validProducts.getSize()); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -269,7 +269,7 @@ CScValue *CSXStore::scGetProperty(const char *name) { // NumTransactions (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumTransactions") == 0) { - _scValue->setInt(_transactions.GetSize()); + _scValue->setInt(_transactions.getSize()); return _scValue; } @@ -293,16 +293,16 @@ ERRORCODE CSXStore::persist(CBPersistMgr *persistMgr) { // persist valid products int numProducts; if (persistMgr->_saving) { - numProducts = _validProducts.GetSize(); + numProducts = _validProducts.getSize(); persistMgr->transfer(TMEMBER(numProducts)); for (int i = 0; i < numProducts; i++) _validProducts[i]->persist(persistMgr); } else { - numProducts = _validProducts.GetSize(); + numProducts = _validProducts.getSize(); persistMgr->transfer(TMEMBER(numProducts)); for (int i = 0; i < numProducts; i++) { CBStoreProduct *prod = new CBStoreProduct; prod->persist(persistMgr); - _validProducts.Add(prod); + _validProducts.add(prod); } } @@ -362,10 +362,10 @@ bool CSXStore::isAvailable() { ////////////////////////////////////////////////////////////////////////// void CSXStore::receiveProductsStart() { - for (int i = 0; i < _validProducts.GetSize(); i++) { + for (int i = 0; i < _validProducts.getSize(); i++) { delete _validProducts[i]; } - _validProducts.RemoveAll(); + _validProducts.removeAll(); _invalidProducts.clear(); } @@ -378,7 +378,7 @@ void CSXStore::receiveProductsEnd() { ////////////////////////////////////////////////////////////////////////// void CSXStore::addValidProduct(const char *id, const char *name, const char *desc, const char *price) { CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); - _validProducts.Add(prod); + _validProducts.add(prod); } ////////////////////////////////////////////////////////////////////////// @@ -388,10 +388,10 @@ void CSXStore::addInvalidProduct(const char *id) { ////////////////////////////////////////////////////////////////////////// void CSXStore::receiveTransactionsStart() { - for (int i = 0; i < _transactions.GetSize(); i++) { + for (int i = 0; i < _transactions.getSize(); i++) { delete _transactions[i]; } - _transactions.RemoveAll(); + _transactions.removeAll(); } ////////////////////////////////////////////////////////////////////////// @@ -405,7 +405,7 @@ void CSXStore::receiveTransactionsEnd() { ////////////////////////////////////////////////////////////////////////// void CSXStore::addTransaction(const char *id, const char *productId, const char *state) { CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); - _transactions.Add(trans); + _transactions.add(trans); } ////////////////////////////////////////////////////////////////////////// @@ -413,7 +413,7 @@ bool CSXStore::purchase(CScScript *script, const char *productId) { if (!productId) return false; #ifdef __IPHONEOS__ - for (int i = 0; i < _validProducts.GetSize(); i++) { + for (int i = 0; i < _validProducts.getSize(); i++) { if (strcmp(productId, _validProducts[i]->GetId()) == 0) { _lastPurchaseOwner = script->_owner; @@ -430,11 +430,11 @@ bool CSXStore::purchase(CScScript *script, const char *productId) { bool CSXStore::finishTransaction(CScScript *script, const char *transId) { if (!transId) return false; #ifdef __IPHONEOS__ - for (int i = 0; i < _transactions.GetSize(); i++) { + for (int i = 0; i < _transactions.getSize(); i++) { if (strcmp(transId, _transactions[i]->GetId()) == 0) { if (StoreKit_FinishTransaction(transId) > 0) { SAFE_DELETE(_transactions[i]); - _transactions.RemoveAt(i); + _transactions.removeAt(i); return true; } else return false; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 089978ece3..ea651e69bf 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -89,24 +89,24 @@ CScEngine::~CScEngine() { cleanup(); - for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { delete _breakpoints[i]; _breakpoints[i] = NULL; } - _breakpoints.RemoveAll(); + _breakpoints.removeAll(); } ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::cleanup() { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; - _scripts.RemoveAt(i); + _scripts.removeAt(i); i--; } - _scripts.RemoveAll(); + _scripts.removeAll(); delete _globals; _globals = NULL; @@ -162,7 +162,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { script->_globals->setProp("self", &val); script->_globals->setProp("this", &val); - _scripts.Add(script); + _scripts.add(script); Game->getDebugMgr()->onScriptInit(script); return script; @@ -245,18 +245,18 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::tick() { - if (_scripts.GetSize() == 0) + if (_scripts.getSize() == 0) return STATUS_OK; // resolve waiting scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { switch (_scripts[i]->_state) { case SCRIPT_WAITING: { /* bool obj_found=false; - for(int j=0; j_regObjects.GetSize(); j++) + for(int j=0; j_regObjects.getSize(); j++) { if(Game->_regObjects[j] == _scripts[i]->_waitObject) { @@ -307,7 +307,7 @@ ERRORCODE CScEngine::tick() { // execute scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { // skip paused scripts if (_scripts[i]->_state == SCRIPT_PAUSED) continue; @@ -346,7 +346,7 @@ ERRORCODE CScEngine::tick() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::tickUnbreakable() { // execute unbreakable scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_unbreakable) continue; while (_scripts[i]->_state == SCRIPT_RUNNING) { @@ -365,12 +365,12 @@ ERRORCODE CScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::removeFinishedScripts() { // remove finished scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); Game->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; - _scripts.RemoveAt(i); + _scripts.removeAt(i); i--; } } @@ -382,7 +382,7 @@ ERRORCODE CScEngine::removeFinishedScripts() { int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED) continue; switch (_scripts[i]->_state) { case SCRIPT_RUNNING: @@ -425,7 +425,7 @@ ERRORCODE CScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::resetObject(CBObject *Object) { // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { if (!Game->_compatKillMethodThreads) resetScript(_scripts[i]); @@ -439,7 +439,7 @@ ERRORCODE CScEngine::resetObject(CBObject *Object) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::resetScript(CScScript *script) { // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { _scripts[i]->finish(); } @@ -462,10 +462,10 @@ ERRORCODE CScEngine::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// void CScEngine::editorCleanup() { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; - _scripts.RemoveAt(i); + _scripts.removeAt(i); i--; } } @@ -474,7 +474,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::pauseAll() { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->pause(); } @@ -484,7 +484,7 @@ ERRORCODE CScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::resumeAll() { - for (int i = 0; i < _scripts.GetSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->resume(); return STATUS_OK; @@ -493,7 +493,7 @@ ERRORCODE CScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// bool CScEngine::isValidScript(CScScript *script) { - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) return true; } return false; @@ -511,13 +511,13 @@ ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) { _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); // process normal scripts first - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; _scripts[i]->dbgSendScript(client); } // and threads later - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_thread || _scripts[i]->_methodThread) _scripts[i]->dbgSendScript(client); } @@ -530,7 +530,7 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { if (!Game->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { bp = _breakpoints[i]; break; @@ -538,13 +538,13 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { } if (bp == NULL) { bp = new CScBreakpoint(scriptFilename); - _breakpoints.Add(bp); + _breakpoints.add(bp); } - for (int i = 0; i < bp->_lines.GetSize(); i++) { + for (int i = 0; i < bp->_lines.getSize(); i++) { if (bp->_lines[i] == line) return STATUS_OK; } - bp->_lines.Add(line); + bp->_lines.add(line); // refresh changes refreshScriptBreakpoints(); @@ -556,14 +556,14 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (!Game->getDebugMgr()->_enabled) return STATUS_OK; - for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.RemoveAt(j); - if (_breakpoints[i]->_lines.GetSize() == 0) { + _breakpoints[i]->_lines.removeAt(j); + if (_breakpoints[i]->_lines.getSize() == 0) { delete _breakpoints[i]; - _breakpoints.RemoveAt(i); + _breakpoints.removeAt(i); } // refresh changes refreshScriptBreakpoints(); @@ -581,7 +581,7 @@ ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { ERRORCODE CScEngine::refreshScriptBreakpoints() { if (!Game->getDebugMgr()->_enabled) return STATUS_OK; - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { refreshScriptBreakpoints(_scripts[i]); } return STATUS_OK; @@ -593,13 +593,13 @@ ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { if (!script || !script->_filename) return STATUS_FAILED; - for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.Copy(_breakpoints[i]->_lines); + script->_breakpoints.copy(_breakpoints[i]->_lines); return STATUS_OK; } } - if (script->_breakpoints.GetSize() > 0) script->_breakpoints.RemoveAll(); + if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); return STATUS_OK; } @@ -613,8 +613,8 @@ ERRORCODE CScEngine::saveBreakpoints() { char key[100]; int count = 0; - for (int i = 0; i < _breakpoints.GetSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { count++; sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index d4112be47b..d439ab8eab 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -72,7 +72,7 @@ public: } ~CScBreakpoint() { - _lines.RemoveAll(); + _lines.removeAll(); } Common::String _filename; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index ebb68654fd..40803cded6 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -1029,7 +1029,7 @@ ERRORCODE CScScript::executeInstruction() { _currentLine = newLine; if (Game->getDebugMgr()->_enabled) { Game->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.GetSize(); i++) { + for (int i = 0; i < _breakpoints.getSize(); i++) { if (_breakpoints[i] == _currentLine) { Game->getDebugMgr()->onScriptHitBreakpoint(this); sleep(0); @@ -1268,7 +1268,7 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable ERRORCODE ret = thread->createThread(this, pos, eventName); if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; - _engine->_scripts.Add(thread); + _engine->_scripts.add(thread); Game->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); return thread; } else { @@ -1363,7 +1363,7 @@ ERRORCODE CScScript::copyParameters(CScStack *stack) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.GetSize(); i++) { + for (int i = 0; i < _engine->_scripts.getSize(); i++) { CScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) scr->finish(true); @@ -1417,12 +1417,12 @@ TScriptState CScScript::dbgGetState() { ////////////////////////////////////////////////////////////////////////// int CScScript::dbgGetNumBreakpoints() { - return _breakpoints.GetSize(); + return _breakpoints.getSize(); } ////////////////////////////////////////////////////////////////////////// int CScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.GetSize()) return _breakpoints[index]; + if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; else return -1; } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 7bc44838f3..33fe9f44e8 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -44,13 +44,13 @@ CScStack::CScStack(CBGame *inGame): CBBase(inGame) { CScStack::~CScStack() { #if _DEBUG - //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.GetSize(), _sP); + //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); #endif - for (int i = 0; i < _values.GetSize(); i++) { + for (int i = 0; i < _values.getSize(); i++) { delete _values[i]; } - _values.RemoveAll(); + _values.removeAll(); } @@ -69,13 +69,13 @@ CScValue *CScStack::pop() { void CScStack::push(CScValue *val) { _sP++; - if (_sP < _values.GetSize()) { + if (_sP < _values.getSize()) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { CScValue *copyVal = new CScValue(Game); copyVal->copy(val); - _values.Add(copyVal); + _values.add(copyVal); } } @@ -84,9 +84,9 @@ void CScStack::push(CScValue *val) { CScValue *CScStack::getPushValue() { _sP++; - if (_sP >= _values.GetSize()) { + if (_sP >= _values.getSize()) { CScValue *val = new CScValue(Game); - _values.Add(val); + _values.add(val); } _values[_sP]->cleanup(); return _values[_sP]; @@ -96,7 +96,7 @@ CScValue *CScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::getTop() { - if (_sP < 0 || _sP >= _values.GetSize()) return NULL; + if (_sP < 0 || _sP >= _values.getSize()) return NULL; else return _values[_sP]; } @@ -104,7 +104,7 @@ CScValue *CScStack::getTop() { ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::getAt(int index) { index = _sP - index; - if (index < 0 || index >= _values.GetSize()) return NULL; + if (index < 0 || index >= _values.getSize()) return NULL; else return _values[index]; } @@ -117,7 +117,7 @@ void CScStack::correctParams(uint32 expectedParams) { while (expectedParams < nuParams) { //Pop(); delete _values[_sP - expectedParams]; - _values.RemoveAt(_sP - expectedParams); + _values.removeAt(_sP - expectedParams); nuParams--; _sP--; } @@ -126,13 +126,13 @@ void CScStack::correctParams(uint32 expectedParams) { //Push(null_val); CScValue *nullVal = new CScValue(Game); nullVal->setNULL(); - _values.InsertAt(_sP - nuParams + 1, nullVal); + _values.insertAt(_sP - nuParams + 1, nullVal); nuParams++; _sP++; - if (_values.GetSize() > _sP + 1) { - delete _values[_values.GetSize() - 1]; - _values.RemoveAt(_values.GetSize() - 1); + if (_values.getSize() > _sP + 1) { + delete _values[_values.getSize() - 1]; + _values.removeAt(_values.getSize() - 1); } } } diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 930157ebf5..43e1262ce3 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -524,7 +524,7 @@ ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -638,7 +638,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites if (_image && _image != image) _image->reset(); diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 09ca50699e..778e084ab9 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -342,7 +342,7 @@ ERRORCODE CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -673,7 +673,7 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { } - Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); Game->_textEncoding = OrigEncoding; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index faaaf375c0..f30aca122c 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -194,7 +194,7 @@ ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 1a00748a98..7af29a9eac 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -229,7 +229,7 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * // find directly if (val->isNative()) { CUIObject *widget = (CUIObject *)val->getNative(); - for (i = 0; i < win->_widgets.GetSize(); i++) { + for (i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == widget) { found = true; break; @@ -239,7 +239,7 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * // find by name else { const char *findName = val->getString(); - for (i = 0; i < win->_widgets.GetSize(); i++) { + for (i = 0; i < win->_widgets.getSize(); i++) { if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { found = true; break; @@ -249,13 +249,13 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (found) { bool done = false; - for (int j = 0; j < win->_widgets.GetSize(); j++) { + for (int j = 0; j < win->_widgets.getSize(); j++) { if (win->_widgets[j] == this) { if (strcmp(name, "MoveAfter") == 0) i++; if (j >= i) j++; - win->_widgets.InsertAt(i, this); - win->_widgets.RemoveAt(j); + win->_widgets.insertAt(i, this); + win->_widgets.removeAt(j); done = true; stack->pushBool(true); @@ -278,10 +278,10 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { + for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { - win->_widgets.RemoveAt(i); - win->_widgets.InsertAt(0, this); + win->_widgets.removeAt(i); + win->_widgets.insertAt(0, this); break; } } @@ -299,10 +299,10 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { + for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { - win->_widgets.RemoveAt(i); - win->_widgets.Add(this); + win->_widgets.removeAt(i); + win->_widgets.add(this); break; } } @@ -399,10 +399,10 @@ CScValue *CUIObject::scGetProperty(const char *name) { _scValue->setNULL(); if (_parent && _parent->_type == UI_WINDOW) { CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.GetSize(); i++) { + for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.GetSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); + if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); } else { if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); } diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 884d241e07..44fb695687 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -87,7 +87,7 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); } - //Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + //Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); return STATUS_OK; } @@ -360,7 +360,7 @@ ERRORCODE CUIText::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 5f63390519..cc8d966bc2 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -107,8 +107,8 @@ void CUIWindow::cleanup() { if (!_sharedFonts && _fontInactive) Game->_fontStorage->removeFont(_fontInactive); if (!_sharedImages && _imageInactive) delete _imageInactive; - for (int i = 0; i < _widgets.GetSize(); i++) delete _widgets[i]; - _widgets.RemoveAll(); + for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; + _widgets.removeAll(); } @@ -190,9 +190,9 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { } if (!_transparent && !image) - Game->_renderer->_rectList.Add(new CBActiveRect(Game, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); } @@ -440,7 +440,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; } else { btn->_parent = this; - _widgets.Add(btn); + _widgets.add(btn); } } break; @@ -453,7 +453,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; } else { text->_parent = this; - _widgets.Add(text); + _widgets.add(text); } } break; @@ -466,7 +466,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; } else { edit->_parent = this; - _widgets.Add(edit); + _widgets.add(edit); } } break; @@ -479,7 +479,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; } else { win->_parent = this; - _widgets.Add(win); + _widgets.add(win); } } break; @@ -659,7 +659,7 @@ ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.GetSize(); i++) { + for (int i = 0; i < _scripts.getSize(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -669,7 +669,7 @@ ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { CBBase::saveAsText(buffer, indent + 2); // controls - for (int i = 0; i < _widgets.GetSize(); i++) + for (int i = 0; i < _widgets.getSize(); i++) _widgets[i]->saveAsText(buffer, indent + 2); @@ -679,7 +679,7 @@ ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIWindow::enableWidget(const char *name, bool Enable) { - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; } return STATUS_OK; @@ -688,7 +688,7 @@ ERRORCODE CUIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIWindow::showWidget(const char *name, bool Visible) { - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; } return STATUS_OK; @@ -707,10 +707,10 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * CScValue *val = stack->pop(); if (val->getType() == VAL_INT) { int widget = val->getInt(); - if (widget < 0 || widget >= _widgets.GetSize()) stack->pushNULL(); + if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); else stack->pushNative(_widgets[widget], true); } else { - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { stack->pushNative(_widgets[i], true); return STATUS_OK; @@ -845,7 +845,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushNative(btn, true); btn->_parent = this; - _widgets.Add(btn); + _widgets.add(btn); return STATUS_OK; } @@ -862,7 +862,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushNative(sta, true); sta->_parent = this; - _widgets.Add(sta); + _widgets.add(sta); return STATUS_OK; } @@ -879,7 +879,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushNative(edi, true); edi->_parent = this; - _widgets.Add(edi); + _widgets.add(edi); return STATUS_OK; } @@ -896,7 +896,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushNative(win, true); win->_parent = this; - _widgets.Add(win); + _widgets.add(win); return STATUS_OK; } @@ -909,10 +909,10 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * CScValue *val = stack->pop(); CUIObject *obj = (CUIObject *)val->getNative(); - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { if (_widgets[i] == obj) { delete _widgets[i]; - _widgets.RemoveAt(i); + _widgets.removeAt(i); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); } } @@ -940,7 +940,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { - _scValue->setInt(_widgets.GetSize()); + _scValue->setInt(_widgets.getSize()); return _scValue; } @@ -1192,7 +1192,7 @@ ERRORCODE CUIWindow::persist(CBPersistMgr *persistMgr) { ERRORCODE CUIWindow::moveFocus(bool forward) { int i; bool found = false; - for (i = 0; i < _widgets.GetSize(); i++) { + for (i = 0; i < _widgets.getSize(); i++) { if (_widgets[i] == _focusedWidget) { found = true; break; @@ -1201,14 +1201,14 @@ ERRORCODE CUIWindow::moveFocus(bool forward) { if (!found) _focusedWidget = NULL; if (!_focusedWidget) { - if (_widgets.GetSize() > 0) i = 0; + if (_widgets.getSize() > 0) i = 0; else return STATUS_OK; } int numTries = 0; bool done = false; - while (numTries <= _widgets.GetSize()) { + while (numTries <= _widgets.getSize()) { if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { _focusedWidget = _widgets[i]; done = true; @@ -1217,10 +1217,10 @@ ERRORCODE CUIWindow::moveFocus(bool forward) { if (forward) { i++; - if (i >= _widgets.GetSize()) i = 0; + if (i >= _widgets.getSize()) i = 0; } else { i--; - if (i < 0) i = _widgets.GetSize() - 1; + if (i < 0) i = _widgets.getSize() - 1; } numTries++; } @@ -1294,7 +1294,7 @@ ERRORCODE CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// void CUIWindow::makeFreezable(bool freezable) { - for (int i = 0; i < _widgets.GetSize(); i++) + for (int i = 0; i < _widgets.getSize(); i++) _widgets[i]->makeFreezable(freezable); CBObject::makeFreezable(freezable); @@ -1303,7 +1303,7 @@ void CUIWindow::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _widgets.GetSize(); i++) { + for (int i = 0; i < _widgets.getSize(); i++) { CUIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) continue; @@ -1314,11 +1314,11 @@ ERRORCODE CUIWindow::getWindowObjects(CBArray &objects case UI_BUTTON: case UI_EDIT: - objects.Add(control); + objects.add(control); break; default: - if (!interactiveOnly) objects.Add(control); + if (!interactiveOnly) objects.add(control); } } return STATUS_OK; diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 59d0241419..0c71b3ec6e 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -80,39 +80,39 @@ public: CBArray(); // Attributes - int GetSize() const; - int GetUpperBound() const; - void SetSize(int nNewSize, int nGrowBy = -1); + int getSize() const; + int getUpperBound() const; + void setSize(int nNewSize, int nGrowBy = -1); // Operations // Clean up - void FreeExtra(); - void RemoveAll(); + void freeExtra(); + void removeAll(); ERRORCODE persist(CBPersistMgr *persistMgr); // Accessing elements - TYPE GetAt(int nIndex) const; - void SetAt(int nIndex, ARG_TYPE newElement); - TYPE &ElementAt(int nIndex); + TYPE getAt(int nIndex) const; + void setAt(int nIndex, ARG_TYPE newElement); + TYPE &elementAt(int nIndex); // Direct Access to the element data (may return NULL) - const TYPE *GetData() const; - TYPE *GetData(); + const TYPE *getData() const; + TYPE *getData(); // Potentially growing the array - void SetAtGrow(int nIndex, ARG_TYPE newElement); - int Add(ARG_TYPE newElement); - int Append(const CBArray &src); - void Copy(const CBArray &src); + void setAtGrow(int nIndex, ARG_TYPE newElement); + int add(ARG_TYPE newElement); + int append(const CBArray &src); + void copy(const CBArray &src); // overloaded operator helpers TYPE operator[](int nIndex) const; TYPE &operator[](int nIndex); // Operations that move elements around - void InsertAt(int nIndex, ARG_TYPE newElement, int nCount = 1); - void RemoveAt(int nIndex, int nCount = 1); - void InsertAt(int nStartIndex, CBArray *pNewArray); + void insertAt(int nIndex, ARG_TYPE newElement, int nCount = 1); + void removeAt(int nIndex, int nCount = 1); + void insertAt(int nStartIndex, CBArray *pNewArray); // Implementation protected: @@ -129,50 +129,50 @@ public: // CBArray inline functions ///////////////////////////////////////////////////////////////////////////// template -inline int CBArray::GetSize() const { +inline int CBArray::getSize() const { return _nSize; } template -inline int CBArray::GetUpperBound() const { +inline int CBArray::getUpperBound() const { return _nSize - 1; } template -inline void CBArray::RemoveAll() { - SetSize(0, -1); +inline void CBArray::removeAll() { + setSize(0, -1); } template -inline TYPE CBArray::GetAt(int nIndex) const { +inline TYPE CBArray::getAt(int nIndex) const { return _pData[nIndex]; } template -inline void CBArray::SetAt(int nIndex, ARG_TYPE newElement) { +inline void CBArray::setAt(int nIndex, ARG_TYPE newElement) { _pData[nIndex] = newElement; } template -inline TYPE &CBArray::ElementAt(int nIndex) { +inline TYPE &CBArray::elementAt(int nIndex) { return _pData[nIndex]; } template -inline const TYPE *CBArray::GetData() const { +inline const TYPE *CBArray::getData() const { return (const TYPE *)_pData; } template -inline TYPE *CBArray::GetData() { +inline TYPE *CBArray::getData() { return (TYPE *)_pData; } template -inline int CBArray::Add(ARG_TYPE newElement) { +inline int CBArray::add(ARG_TYPE newElement) { int nIndex = _nSize; - SetAtGrow(nIndex, newElement); + setAtGrow(nIndex, newElement); return nIndex; } template inline TYPE CBArray::operator[](int nIndex) const { - return GetAt(nIndex); + return getAt(nIndex); } template inline TYPE &CBArray::operator[](int nIndex) { - return ElementAt(nIndex); + return elementAt(nIndex); } ///////////////////////////////////////////////////////////////////////////// @@ -195,7 +195,7 @@ CBArray::~CBArray() { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::SetSize(int nNewSize, int nGrowBy) { +void CBArray::setSize(int nNewSize, int nGrowBy) { if (nGrowBy != -1) _nGrowBy = nGrowBy; // set new size @@ -255,23 +255,23 @@ void CBArray::SetSize(int nNewSize, int nGrowBy) { ///////////////////////////////////////////////////////////////////////////// template -int CBArray::Append(const CBArray &src) { +int CBArray::append(const CBArray &src) { int nOldSize = _nSize; - SetSize(_nSize + src._nSize); + setSize(_nSize + src._nSize); DCCopyElements(_pData + nOldSize, src._pData, src._nSize); return nOldSize; } ///////////////////////////////////////////////////////////////////////////// template -void CBArray::Copy(const CBArray &src) { - SetSize(src._nSize); +void CBArray::copy(const CBArray &src) { + setSize(src._nSize); DCCopyElements(_pData, src._pData, src._nSize); } ///////////////////////////////////////////////////////////////////////////// template -void CBArray::FreeExtra() { +void CBArray::freeExtra() { if (_nSize != _nMaxSize) { // shrink to desired size TYPE *pNewData = NULL; @@ -290,22 +290,22 @@ void CBArray::FreeExtra() { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::SetAtGrow(int nIndex, ARG_TYPE newElement) { +void CBArray::setAtGrow(int nIndex, ARG_TYPE newElement) { if (nIndex >= _nSize) - SetSize(nIndex + 1, -1); + setSize(nIndex + 1, -1); _pData[nIndex] = newElement; } ///////////////////////////////////////////////////////////////////////////// template -void CBArray::InsertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { +void CBArray::insertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { if (nIndex >= _nSize) { // adding after the end of the array - SetSize(nIndex + nCount, -1); // grow so nIndex is valid + setSize(nIndex + nCount, -1); // grow so nIndex is valid } else { // inserting in the middle of the array int nOldSize = _nSize; - SetSize(_nSize + nCount, -1); // grow it to new size + setSize(_nSize + nCount, -1); // grow it to new size // destroy intial data before copying over it DCDestructElements(&_pData[nOldSize], nCount); // shift old data up to fill gap @@ -323,7 +323,7 @@ void CBArray::InsertAt(int nIndex, ARG_TYPE newElement, int nCou ///////////////////////////////////////////////////////////////////////////// template -void CBArray::RemoveAt(int nIndex, int nCount) { +void CBArray::removeAt(int nIndex, int nCount) { // just remove a range int nMoveCount = _nSize - (nIndex + nCount); DCDestructElements(&_pData[nIndex], nCount); @@ -335,11 +335,11 @@ void CBArray::RemoveAt(int nIndex, int nCount) { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::InsertAt(int nStartIndex, CBArray *pNewArray) { +void CBArray::insertAt(int nStartIndex, CBArray *pNewArray) { if (pNewArray->GetSize() > 0) { InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize()); for (int i = 0; i < pNewArray->GetSize(); i++) - SetAt(nStartIndex + i, pNewArray->GetAt(i)); + setAt(nStartIndex + i, pNewArray->GetAt(i)); } } @@ -349,19 +349,19 @@ template ERRORCODE CBArray::persist(CBPersistMgr *persistMgr) { int i, j; if (persistMgr->_saving) { - j = GetSize(); + j = getSize(); persistMgr->transfer("ArraySize", &j); for (i = 0; i < j; i++) { - ARG_TYPE obj = GetAt(i); + ARG_TYPE obj = getAt(i); persistMgr->transfer("", &obj); } } else { - SetSize(0, -1); + setSize(0, -1); persistMgr->transfer("ArraySize", &j); for (i = 0; i < j; i++) { ARG_TYPE obj; persistMgr->transfer("", &obj); - Add(obj); + add(obj); } } return STATUS_OK; diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index 7fa8e6e218..eed2ddce86 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -114,8 +114,8 @@ ERRORCODE CVidPlayer::cleanup() { SAFE_DELETE_ARRAY(_filename); - for (int i = 0; i < _subtitles.GetSize(); i++) delete _subtitles[i]; - _subtitles.RemoveAll(); + for (int i = 0; i < _subtitles.getSize(); i++) delete _subtitles[i]; + _subtitles.removeAll(); return SetDefaults(); #endif @@ -242,10 +242,10 @@ ERRORCODE CVidPlayer::update() { // process subtitles _showSubtitle = false; - while (_currentSubtitle < _subtitles.GetSize()) { + while (_currentSubtitle < _subtitles.getSize()) { int End = _subtitles[_currentSubtitle]->m_EndFrame; - bool NextFrameOK = (_currentSubtitle < _subtitles.GetSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); + bool NextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); if (sample > End) { if (NextFrameOK) { @@ -455,7 +455,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi } Text[TextLength] = '\0'; - if (Start != -1 && TextLength > 0) _subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(Game, Text, Start, End)); delete [] Text; -- cgit v1.2.3 From f147d0409dc97add9b1e182e07d746a4c7da0294 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 04:56:27 +0200 Subject: WINTERMUTE: Rename a few missed VarNames -> varNames in BFileManager --- engines/wintermute/Base/BFileManager.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 706da2a93b..7fb1234a8d 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -161,14 +161,14 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *Buffer, uint32 BufferSize, bool Compressed, byte *PrefixBuffer, uint32 PrefixSize) { +ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { // TODO warning("Implement SaveFile"); Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(PrefixBuffer, PrefixSize); - file->write(Buffer, BufferSize); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); file->finalize(); delete file; #if 0 @@ -871,26 +871,24 @@ bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - uint32 fileSize = f->size(); - - int startPos = 1024 * 1024; - + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; uint32 bytesRead = startPos; while (bytesRead < fileSize - 16) { - int ToRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek(startPos, SEEK_SET); - int ActuallyRead = f->read(buf, ToRead); - if (ActuallyRead != ToRead) return false; + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; - for (int i = 0; i < ToRead - 8; i++) + for (uint32 i = 0; i < toRead - 8; i++) if (!memcmp(buf + i, signature, 8)) { *offset = startPos + i; return true; } - bytesRead = bytesRead + ToRead - 16; - startPos = startPos + ToRead - 16; + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; } return false; -- cgit v1.2.3 From acc2a95aca8943aae9d3d5eea3549885bf2f2c79 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 05:27:50 +0200 Subject: WINTERMUTE: Delay Image-load until the data is needed. --- engines/wintermute/Base/BFileManager.cpp | 1 - engines/wintermute/Base/BSubFrame.cpp | 4 +-- engines/wintermute/Base/BSurface.cpp | 19 +++------- engines/wintermute/Base/BSurface.h | 12 +++---- engines/wintermute/Base/BSurfaceSDL.cpp | 56 ++++++++++++++++------------- engines/wintermute/Base/BSurfaceSDL.h | 10 +++++- engines/wintermute/Base/BSurfaceStorage.cpp | 4 +-- 7 files changed, 55 insertions(+), 51 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 7fb1234a8d..88dad41e50 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -115,7 +115,6 @@ ERRORCODE CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; Common::SeekableReadStream *file = openFile(filename); diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 11450a1349..33c6c32f8f 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -253,8 +253,8 @@ ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); - if (_surface && _surface->_filename != NULL) - buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->_filename); + if (_surface && _surface->getFileName() != "") + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); if (_transparent != 0xFFFF00FF) buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index dd7f17a895..f67808a47f 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -38,12 +38,12 @@ CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { _width = _height = 0; - _filename = NULL; + _filename = ""; _pixelOpReady = false; - _cKDefault = true; - _cKRed = _cKGreen = _cKBlue = 0; + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; _lifeTime = 0; _keepLoaded = false; @@ -55,7 +55,6 @@ CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// CBSurface::~CBSurface() { if (_pixelOpReady) endPixelOp(); - if (_filename) delete [] _filename; } @@ -139,21 +138,11 @@ ERRORCODE CBSurface::prepareToDraw() { if (!_valid) { //Game->LOG(0, "Reviving: %s", _filename); - return create(_filename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); } else return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -void CBSurface::setFilename(const char *filename) { - delete[] _filename; - _filename = NULL; - if (!filename) return; - - _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); -} - ////////////////////////////////////////////////////////////////////////// void CBSurface::setSize(int width, int height) { _width = width; diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index 4351e163e5..a22f1d7606 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -38,10 +38,10 @@ class CBSurface: public CBBase { public: virtual ERRORCODE invalidate(); virtual ERRORCODE prepareToDraw(); - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; uint32 _lastUsedTime; bool _valid; @@ -72,11 +72,9 @@ public: virtual ERRORCODE startPixelOp(); virtual ERRORCODE endPixelOp(); virtual bool isTransparentAtLite(int x, int y); - void setFilename(const char *filename); void setSize(int width, int height); int _referenceCount; - char *_filename; virtual int getWidth() { return _width; @@ -84,9 +82,11 @@ public: virtual int getHeight() { return _height; } + const char* getFileName() { return _filename.c_str(); } //void SetWidth(int Width){ _width = Width; } //void SetHeight(int Height){ _height = Height; } protected: + Common::String _filename; int _height; int _width; diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 7bddcdf04c..f5f4ee9a1f 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -52,6 +52,7 @@ CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { _hasAlpha = true; _lockPixels = NULL; _lockPitch = 0; + _loaded = false; } ////////////////////////////////////////////////////////////////////////// @@ -92,9 +93,7 @@ bool hasTransparency(Graphics::Surface *surf) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ - Common::String strFileName(filename); - CBImage *image = new CBImage(Game); - image->loadFile(strFileName); + _filename = filename; // const Graphics::Surface *surface = image->getSurface(); if (defaultCK) { @@ -103,10 +102,28 @@ ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, ckBlue = 255; } + _ckDefault = defaultCK; + _ckRed = ckRed; + _ckGreen = ckGreen; + _ckBlue = ckBlue; + + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + _lifeTime = lifeTime; + + _keepLoaded = keepLoaded; + if (_keepLoaded) _lifeTime = -1; + + return STATUS_OK; +} + +void CBSurfaceSDL::finishLoad() { + CBImage *image = new CBImage(Game); + image->loadFile(_filename); + _width = image->getSurface()->w; _height = image->getSurface()->h; - bool isSaveGameGrayscale = scumm_strnicmp(filename, "savegame:", 9) == 0 && (filename[strFileName.size() - 1] == 'g' || filename[strFileName.size() - 1] == 'G'); + bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); @@ -145,14 +162,14 @@ ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. delete _surface; - if (strFileName.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); - trans.applyColorKey(ckRed, ckGreen, ckBlue); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); - trans.applyColorKey(ckRed, ckGreen, ckBlue, true); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); } else { @@ -184,30 +201,15 @@ ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, SDL_FreeSurface(surf); delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. - - _cKDefault = default_ck; - _cKRed = ck_red; - _cKGreen = ck_green; - _cKBlue = ck_blue; #endif - if (!_filename || scumm_stricmp(_filename, filename) != 0) { - setFilename(filename); - } - - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) - _lifeTime = lifeTime; - - _keepLoaded = keepLoaded; - if (_keepLoaded) _lifeTime = -1; - _valid = true; Game->addMem(_width * _height * 4); delete image; - return STATUS_OK; + _loaded = true; } ////////////////////////////////////////////////////////////////////////// @@ -459,7 +461,12 @@ ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Commo ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); - if (renderer->_forceAlphaColor != 0) alpha = renderer->_forceAlphaColor; + if (!_loaded) { + finishLoad(); + } + + if (renderer->_forceAlphaColor != 0) + alpha = renderer->_forceAlphaColor; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. @@ -535,6 +542,7 @@ ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Common::Rect *rect, float zoomX } ERRORCODE CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; _surface->copyFrom(surface); _hasAlpha = hasAlpha; CBRenderSDL *renderer = static_cast(Game->_renderer); diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 91a75f27b7..0bfda92866 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -35,6 +35,7 @@ namespace WinterMute { struct TransparentSurface; +class CBImage; class CBSurfaceSDL : public CBSurface { public: CBSurfaceSDL(CBGame *inGame); @@ -63,12 +64,18 @@ public: static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ virtual int getWidth() { + if (!_loaded) { + finishLoad(); + } if (_surface) { return _surface->w; } return _width; } virtual int getHeight() { + if (!_loaded) { + finishLoad(); + } if (_surface) { return _surface->h; } @@ -77,7 +84,8 @@ public: private: Graphics::Surface *_surface; - + bool _loaded; + void finishLoad(); ERRORCODE drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 1c6bb33af3..20a905b62a 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -53,7 +53,7 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::cleanup(bool warn) { for (int i = 0; i < _surfaces.getSize(); i++) { - if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->_filename, _surfaces[i]->_referenceCount); + if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.removeAll(); @@ -99,7 +99,7 @@ ERRORCODE CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (int i = 0; i < _surfaces.getSize(); i++) { - if (scumm_stricmp(_surfaces[i]->_filename, filename) == 0) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; } -- cgit v1.2.3 From ca90ddf497c9f9578b1dcbec3dd5d2671dd29dff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 05:31:20 +0200 Subject: WINTERMUTE: Clean out some commented code in BSurfaceSDL --- engines/wintermute/Base/BSurfaceSDL.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index f5f4ee9a1f..07e552138c 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -133,28 +133,6 @@ void CBSurfaceSDL::finishLoad() { }*/ } - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - /* if (FreeImage_GetBPP(img) != 32 || (imgFormat == FIF_BMP && FreeImage_GetBPP(img) != 24)) { - FIBITMAP *newImg = FreeImage_ConvertTo24Bits(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - } else { - FreeImage_Unload(img); - return -1; - } - } - - FreeImage_FlipVertical(img);*/ - - //TODO: This is rather endian-specific, but should be replaced by non-SDL-code anyhow: - /* uint32 rmask = surface->format.rMax() << surface->format.rShift; - uint32 gmask = surface->format.gMax() << surface->format.gShift; - uint32 bmask = surface->format.bMax() << surface->format.bShift; - uint32 amask = surface->format.aMax();*/ - -// SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(surface->pixels, _width, _height, surface->format.bytesPerPixel * 8, surface->pitch, rmask, gmask, bmask, amask); - // no alpha, set color key /* if (surface->format.bytesPerPixel != 4) SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ -- cgit v1.2.3 From 3809d9a9ea8a18512235420b720fad424d0f9986 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 05:36:53 +0200 Subject: WINTERMUTE: Use correct logic in drawFromTicket --- engines/wintermute/Base/BRenderSDL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 51202d26ef..936549a6c4 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -373,7 +373,7 @@ void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { // Before something Common::List::iterator pos; for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { - if ((*pos)->_drawNum > _drawNum) { + if ((*pos)->_drawNum >= _drawNum) { break; } } -- cgit v1.2.3 From 2959065e49390ab1da0b00a277a464d991ff10ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 09:45:56 +0200 Subject: WINTERMUTE: Reduce the includes and visibility in BGame a bit. --- engines/wintermute/Base/BFontTT.cpp | 18 +++++++++--------- engines/wintermute/Base/BGame.cpp | 10 +++++----- engines/wintermute/Base/BGame.h | 30 +++++++++++++++++------------- engines/wintermute/Base/BImage.cpp | 1 - engines/wintermute/Base/BRenderSDL.cpp | 8 ++++++++ engines/wintermute/Base/BRenderSDL.h | 1 + engines/wintermute/Base/BRenderer.h | 6 +++++- 7 files changed, 45 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 998aead064..50cb8984d1 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -32,8 +32,8 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/BRenderSDL.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BRenderer.h" +#include "engines/wintermute/Base/BSurface.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" @@ -165,7 +165,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove - CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer; + CBRenderer *renderer = Game->_renderer; // find cached surface, if exists int minPriority = INT_MAX; @@ -221,14 +221,14 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; - uint32 origForceAlpha = _renderer->_forceAlphaColor; - if (_renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(_renderer->_forceAlphaColor)); - _renderer->_forceAlphaColor = 0; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; } surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - _renderer->_forceAlphaColor = origForceAlpha; + renderer->_forceAlphaColor = origForceAlpha; } } @@ -270,7 +270,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex heightOffset += (int)_lineHeight; } - CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game); + CBSurface *retSurface = Game->_renderer->createSurface(); Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index d1ade0e3fd..7ad692ad7f 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -37,12 +37,12 @@ #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BQuickMsg.h" #include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/BRenderer.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/BSurface.h" #include "engines/wintermute/Base/BTransitionMgr.h" #include "engines/wintermute/Base/BViewport.h" #include "engines/wintermute/Base/BStringTable.h" @@ -499,7 +499,7 @@ ERRORCODE CBGame::initialize1() { ////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::initialize2() { // we know whether we are going to be accelerated - _renderer = new CBRenderSDL(this); + _renderer = makeSDLRenderer(this); if (_renderer == NULL) return STATUS_FAILED; return STATUS_OK; @@ -3209,7 +3209,7 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { delete _saveLoadImage; _saveLoadImage = NULL; if (_saveImageName) { - _saveLoadImage = new CBSurfaceSDL(this); + _saveLoadImage = _renderer->createSurface(); if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { delete _saveLoadImage; @@ -3259,7 +3259,7 @@ ERRORCODE CBGame::loadGame(const char *filename) { delete _saveLoadImage; _saveLoadImage = NULL; if (_loadImageName) { - _saveLoadImage = new CBSurfaceSDL(this); + _saveLoadImage = _renderer->createSurface(); if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { delete _saveLoadImage; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 867700db9b..6650767600 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -117,10 +117,10 @@ public: char *_localSaveDir; bool _saveDirChecked; - + int _indicatorProgress; +protected: bool _indicatorDisplay; uint32 _indicatorColor; - int _indicatorProgress; int _indicatorX; int _indicatorY; int _indicatorWidth; @@ -135,15 +135,15 @@ public: int _saveImageY; int _loadImageX; int _loadImageY; - CBSurface *_saveLoadImage; + CBSurface *_saveLoadImage; ERRORCODE displayIndicator(); + bool _reportTextureFormat; +public: int _thumbnailWidth; int _thumbnailHeight; - bool _reportTextureFormat; - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); ENGINE_LOG_CALLBACK _engineLogCallback; void *_engineLogCallbackData; @@ -198,13 +198,16 @@ public: CBArray _viewportStack; int _viewportSP; - bool _mouseLeftDown; - bool _mouseRightDown; - bool _mouseMidlleDown; - CBStringTable *_stringTable; + CBStringTable *_stringTable; int _settingsResWidth; int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; +protected: + bool _mouseRightDown; + bool _mouseMidlleDown; bool _settingsRequireAcceleration; bool _settingsAllowWindowed; bool _settingsAllowAdvanced; @@ -213,13 +216,10 @@ public: bool _settingsRequireSound; bool _settingsAllowDesktopRes; int _settingsTLMode; - char *_settingsGameFile; CBFader *_fader; - bool _suppressScriptErrors; - virtual ERRORCODE invalidateDeviceObjects(); virtual ERRORCODE restoreDeviceObjects(); - +public: virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); @@ -256,7 +256,9 @@ public: virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); +protected: int _freezeLevel; +public: ERRORCODE unfreeze(); ERRORCODE freeze(bool includingMusic = true); ERRORCODE focusWindow(CUIWindow *window); @@ -265,11 +267,13 @@ public: bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; +protected: static void afterLoadRegion(void *region, void *data); static void afterLoadSubFrame(void *subframe, void *data); static void afterLoadSound(void *sound, void *data); static void afterLoadFont(void *font, void *data); static void afterLoadScript(void *script, void *data); +public: static void invalidateValues(void *value, void *data); ERRORCODE loadSettings(const char *filename); diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index c28577087b..9dd9dbf300 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BImage.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/graphics/transparentSurface.h" diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 936549a6c4..26ae8c5787 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -83,6 +83,10 @@ bool RenderTicket::operator==(RenderTicket &t) { return true; } +CBRenderer *makeSDLRenderer(CBGame *inGame) { + return new CBRenderSDL(inGame); +} + // TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// @@ -662,4 +666,8 @@ void CBRenderSDL::dumpData(const char *filename) { #endif } +CBSurface *CBRenderSDL::createSurface() { + return new CBSurfaceSDL(Game); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 6c88feb059..aa5b390ede 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -99,6 +99,7 @@ public: } void drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + CBSurface *createSurface(); private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index c32a4d6bc1..43a2e14ea2 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -39,7 +39,7 @@ namespace WinterMute { class CBImage; class CBActiveRect; class CBObject; - +class CBSurface; class CBRenderer: public CBBase { public: int _realWidth; @@ -89,6 +89,8 @@ public: return 1.0f; } + virtual CBSurface *createSurface() = 0; + ERRORCODE clipCursor(); ERRORCODE unclipCursor(); @@ -119,6 +121,8 @@ public: CBArray _rectList; }; +CBRenderer *makeSDLRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp + } // end of namespace WinterMute #endif -- cgit v1.2.3 From 07cebdbf2b70e02b12d32880d23dbe293ab12358 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 12:27:06 +0200 Subject: WINTERMUTE: Change usage of Common::Rect to our own 32-bit variant. --- engines/wintermute/Ad/AdGame.cpp | 6 +- engines/wintermute/Ad/AdInventoryBox.cpp | 6 +- engines/wintermute/Ad/AdInventoryBox.h | 2 +- engines/wintermute/Ad/AdItem.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.h | 2 +- engines/wintermute/Ad/AdScene.cpp | 4 +- engines/wintermute/Ad/AdSentence.h | 3 +- engines/wintermute/Base/BActiveRect.cpp | 2 +- engines/wintermute/Base/BActiveRect.h | 3 +- engines/wintermute/Base/BFontBitmap.cpp | 2 +- engines/wintermute/Base/BFontTT.cpp | 2 +- engines/wintermute/Base/BFrame.cpp | 6 +- engines/wintermute/Base/BFrame.h | 2 +- engines/wintermute/Base/BGame.cpp | 14 ++--- engines/wintermute/Base/BGame.h | 9 +-- engines/wintermute/Base/BObject.h | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 4 +- engines/wintermute/Base/BPersistMgr.h | 5 +- engines/wintermute/Base/BRegion.cpp | 6 +- engines/wintermute/Base/BRegion.h | 4 +- engines/wintermute/Base/BRenderSDL.cpp | 8 +-- engines/wintermute/Base/BRenderSDL.h | 4 +- engines/wintermute/Base/BRenderer.cpp | 8 +-- engines/wintermute/Base/BRenderer.h | 12 ++-- engines/wintermute/Base/BSprite.cpp | 6 +- engines/wintermute/Base/BSprite.h | 4 +- engines/wintermute/Base/BSubFrame.cpp | 6 +- engines/wintermute/Base/BSubFrame.h | 4 +- engines/wintermute/Base/BSurface.cpp | 4 +- engines/wintermute/Base/BSurface.h | 15 ++--- engines/wintermute/Base/BSurfaceSDL.cpp | 14 ++--- engines/wintermute/Base/BSurfaceSDL.h | 14 ++--- engines/wintermute/Base/BViewport.cpp | 2 +- engines/wintermute/Base/BViewport.h | 4 +- engines/wintermute/Base/PartEmitter.h | 2 +- engines/wintermute/Base/PartParticle.cpp | 2 +- engines/wintermute/Base/PartParticle.h | 3 +- engines/wintermute/PlatformSDL.cpp | 22 +++---- engines/wintermute/PlatformSDL.h | 22 +++---- engines/wintermute/UI/UIButton.cpp | 4 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UITiledImage.h | 18 +++--- engines/wintermute/UI/UIWindow.cpp | 2 +- engines/wintermute/UI/UIWindow.h | 6 +- engines/wintermute/math/Rect32.h | 86 ++++++++++++++++++++++++++++ engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/utils/utils.h | 3 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- 49 files changed, 231 insertions(+), 138 deletions(-) create mode 100644 engines/wintermute/math/Rect32.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 6a58f99881..ed31cd3acb 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -1210,7 +1210,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCENE_VIEWPORT: { - Common::Rect rc; + Rect32 rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_sceneViewport) _sceneViewport = new CBViewport(Game); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); @@ -1698,7 +1698,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // process scripts if (doUpdate) _scEngine->tick(); - Common::Point p; + Point32 p; getMousePos(&p); _scene->update(); @@ -1924,7 +1924,7 @@ char *CAdGame::findSpeechFile(char *stringID) { ////////////////////////////////////////////////////////////////////////// bool CAdGame::validMouse() { - Common::Point pos; + Point32 pos; CBPlatform::getCursorPos(&pos); return _renderer->pointInViewport(&pos); diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index fe3a9b8a09..a528167e8c 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -47,7 +47,7 @@ IMPLEMENT_PERSISTENT(CAdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - CBPlatform::setRectEmpty(&_itemsArea); + _itemsArea.setEmpty(); _scrollOffset = 0; _spacing = 0; _itemWidth = _itemHeight = 50; @@ -123,9 +123,9 @@ ERRORCODE CAdInventoryBox::display() { // display window - Common::Rect rect = _itemsArea; + Rect32 rect = _itemsArea; if (_window) { - CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); + rect.offsetRect(_window->_posX, _window->_posY); _window->display(); } diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index e3aec3a20b..857abd5d35 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -49,7 +49,7 @@ public: CUIButton *_closeButton; int _spacing; int _scrollOffset; - Common::Rect _itemsArea; + Rect32 _itemsArea; ERRORCODE listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 435947e96d..e8c32607dc 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -389,7 +389,7 @@ ERRORCODE CAdItem::update() { ERRORCODE CAdItem::display(int x, int y) { int width = 0; if (_currentSprite) { - Common::Rect rc; + Rect32 rc; _currentSprite->getBoundingRect(&rc, 0, 0); width = rc.width(); } diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index f2162012e0..cb9a0496d1 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -397,7 +397,7 @@ ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::display() { - Common::Rect rect = _responseArea; + Rect32 rect = _responseArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); //_window->display(); diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 31076c056c..86fe8ed947 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -74,7 +74,7 @@ public: CUIWindow *_window; CUIWindow *_shieldWindow; bool _horizontal; - Common::Rect _responseArea; + Rect32 _responseArea; int _verticalAlign; TTextAlign _align; ERRORCODE loadFile(const char *filename); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f674e92274..41b413cc14 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -818,7 +818,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_VIEWPORT: { - Common::Rect rc; + Rect32 rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); if (!_viewport) _viewport = new CBViewport(Game); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); @@ -1988,7 +1988,7 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { // viewport if (_viewport) { - Common::Rect *rc = _viewport->getRect(); + Rect32 *rc = _viewport->getRect(); buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); } diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 8ec0ca55e4..86a3c57c99 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -32,6 +32,7 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/dctypes.h" // Added by ClassView #include "common/rect.h" @@ -56,7 +57,7 @@ public: TTextAlign _align; ERRORCODE display(); int _width; - Common::Point _pos; + Point32 _pos; CBFont *_font; char *getNextStance(); char *getCurrentStance(); diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index 5e1af264d9..be9c543469 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -86,7 +86,7 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// void CBActiveRect::clipRect() { - Common::Rect rc; + Rect32 rc; bool customViewport; Game->getCurrentViewportRect(&rc, &customViewport); CBRenderer *Rend = Game->_renderer; diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index cbb617342c..abb00c301f 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -29,6 +29,7 @@ #ifndef WINTERMUTE_BACTIVERECT_H #define WINTERMUTE_BACTIVERECT_H +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/Base/BBase.h" namespace WinterMute { @@ -46,7 +47,7 @@ public: CBRegion *_region; int _offsetX; int _offsetY; - Common::Rect _rect; + Rect32 _rect; CBActiveRect(CBGame *inGameOwner = NULL); CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp index 0af81f7ed4..b913eea3ee 100644 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ b/engines/wintermute/Base/BFontBitmap.cpp @@ -221,7 +221,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { row = c / _numColumns; col = c % _numColumns; - Common::Rect rect; + Rect32 rect; /* l t r b */ int tileWidth; if (_wholeCell) tileWidth = _tileWidth; diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp index 50cb8984d1..10d552d4e2 100644 --- a/engines/wintermute/Base/BFontTT.cpp +++ b/engines/wintermute/Base/BFontTT.cpp @@ -217,7 +217,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { - Common::Rect rc; + Rect32 rc; CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index 7680671434..a0d7d5a1e0 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -159,7 +159,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - Common::Rect rect; + Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; int hotspotX = 0, hotspotY = 0; @@ -325,11 +325,11 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); - Common::Rect subRect; + Rect32 subRect; for (int i = 0; i < _subframes.getSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 4c43db142d..715a97ea69 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -46,7 +46,7 @@ public: DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 7ad692ad7f..bf1bc5c34b 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1360,7 +1360,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi x = MIN(x, _renderer->_width); y = MAX(y, 0); y = MIN(y, _renderer->_height); - Common::Point p; + Point32 p; p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; @@ -3963,7 +3963,7 @@ ERRORCODE CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getCurrentViewportRect(Common::Rect *rect, bool *custom) { +ERRORCODE CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { @@ -4044,7 +4044,7 @@ ERRORCODE CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::displayIndicator() { if (_saveLoadImage) { - Common::Rect rc; + Rect32 rc; CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); @@ -4205,7 +4205,7 @@ ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { _renderer->_active = activate; if (refreshMouse) { - Common::Point p; + Point32 p; getMousePos(&p); setActiveObject(_renderer->getObjectAt(p.x, p.y)); } @@ -4403,7 +4403,7 @@ CBDebugger *CBGame::getDebugMgr() { ////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Common::Point *pos) { +void CBGame::getMousePos(Point32 *pos) { CBPlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; @@ -4430,7 +4430,7 @@ void CBGame::getMousePos(Common::Point *pos) { pos->x = MIN(_mouseLockRect.right, pos->x); pos->y = MIN(_mouseLockRect.bottom, pos->y); - Common::Point newPos = *pos; + Point32 newPos = *pos; newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; @@ -4477,7 +4477,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { maxMoveY = 16; #endif - Common::Point pos; + Point32 pos; CBPlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 6650767600..dc1e476134 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -34,6 +34,7 @@ #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Math/Rect32.h" #include "common/events.h" namespace WinterMute { @@ -91,8 +92,8 @@ public: virtual ERRORCODE miniUpdate(); - void getMousePos(Common::Point *Pos); - Common::Rect _mouseLockRect; + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; bool _shuttingDown; @@ -314,7 +315,7 @@ public: uint32 _liveTimerLast; CBObject *_capturedObject; - Common::Point _mousePos; + Point32 _mousePos; bool validObject(CBObject *object); ERRORCODE unregisterObject(CBObject *object); ERRORCODE registerObject(CBObject *object); @@ -338,7 +339,7 @@ public: virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); ERRORCODE getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - ERRORCODE getCurrentViewportRect(Common::Rect *rect, bool *custom = NULL); + ERRORCODE getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); ERRORCODE popViewport(); ERRORCODE pushViewport(CBViewport *Viewport); ERRORCODE setActiveObject(CBObject *Obj); diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 3a82cbe128..15ccdbef44 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -103,7 +103,7 @@ public: bool _registrable; bool _zoomable; bool _shadowable; - Common::Rect _rect; + Rect32 _rect; bool _rectSet; int _iD; bool _movable; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 412aa88312..7308a8bbb7 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -671,7 +671,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -ERRORCODE CBPersistMgr::transfer(const char *name, Common::Rect *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -694,7 +694,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Common::Rect *val) { ////////////////////////////////////////////////////////////////////////// // POINT -ERRORCODE CBPersistMgr::transfer(const char *name, Common::Point *val) { +ERRORCODE CBPersistMgr::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index dc4c2173de..d2aca60cf9 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/savestate.h" #include "common/stream.h" #include "common/str.h" @@ -85,8 +86,8 @@ public: ERRORCODE transfer(const char *name, double *val); ERRORCODE transfer(const char *name, bool *val); ERRORCODE transfer(const char *name, byte *val); - ERRORCODE transfer(const char *name, Common::Rect *val); - ERRORCODE transfer(const char *name, Common::Point *val); + ERRORCODE transfer(const char *name, Rect32 *val); + ERRORCODE transfer(const char *name, Point32 *val); ERRORCODE transfer(const char *name, const char **val); ERRORCODE transfer(const char *name, char **val); ERRORCODE transfer(const char *name, Common::String *val); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 63e862a569..65ba2c8825 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -79,11 +79,11 @@ bool CBRegion::createRegion() { bool CBRegion::pointInRegion(int x, int y) { if (_points.getSize() < 3) return false; - Common::Point pt; + Point32 pt; pt.x = x; pt.y = y; - Common::Rect rect; + Rect32 rect; rect.left = x - 1; rect.right = x + 2; rect.top = y - 1; @@ -465,7 +465,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::getBoundingRect(Common::Rect *rect) { +ERRORCODE CBRegion::getBoundingRect(Rect32 *rect) { if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 4aa491d7c9..6c79abc8f3 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -41,7 +41,7 @@ public: int _lastMimicY; void cleanup(); ERRORCODE mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - ERRORCODE getBoundingRect(Common::Rect *rect); + ERRORCODE getBoundingRect(Rect32 *rect); bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; @@ -52,7 +52,7 @@ public: bool createRegion(); ERRORCODE loadFile(const char *filename); ERRORCODE loadBuffer(byte *buffer, bool complete = true); - Common::Rect _rect; + Rect32 _rect; CBArray _points; virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 26ae8c5787..c2319d1b7a 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -302,7 +302,7 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setWidth(rect->width()); fillRect.setHeight(rect->height()); } else { - Common::Rect rc; + Rect32 rc; Game->getCurrentViewportRect(&rc); fillRect.left = (int16)rc.left; fillRect.top = (int16)rc.top; @@ -505,7 +505,7 @@ ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - Common::Point point1, point2; + Point32 point1, point2; point1.x = x1; point1.y = y1; pointToScreen(&point1); @@ -609,7 +609,7 @@ void CBRenderSDL::modTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointFromScreen(Common::Point *point) { +void CBRenderSDL::pointFromScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -621,7 +621,7 @@ void CBRenderSDL::pointFromScreen(Common::Point *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointToScreen(Common::Point *point) { +void CBRenderSDL::pointToScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index aa5b390ede..1e7acf51f3 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -86,8 +86,8 @@ public: ERRORCODE setViewport(int left, int top, int right, int bottom); void modTargetRect(Common::Rect *rect); - void pointFromScreen(Common::Point *point); - void pointToScreen(Common::Point *point); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); void dumpData(const char *filename); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index b593161c41..d3d313faee 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -68,7 +68,7 @@ void CBRenderer::initLoop() { ////////////////////////////////////////////////////////////////////// CBObject *CBRenderer::getObjectAt(int x, int y) { - Common::Point point; + Point32 point; point.x = x; point.y = y; @@ -203,7 +203,7 @@ ERRORCODE CBRenderer::setScreenViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setViewport(Common::Rect *rect) { +ERRORCODE CBRenderer::setViewport(Rect32 *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -221,7 +221,7 @@ CBImage *CBRenderer::takeScreenshot() { ERRORCODE CBRenderer::clipCursor() { /* if (!_windowed) { - Common::Rect rc; + Rect32 rc; GetWindowRect(_window, &rc); // if "maintain aspect ratio" is in effect, lock mouse to visible area @@ -245,7 +245,7 @@ ERRORCODE CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Common::Point *p) { +bool CBRenderer::pointInViewport(Point32 *p) { if (p->x < _drawOffsetX) return false; if (p->y < _drawOffsetY) return false; if (p->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index 43a2e14ea2..e7a9518c50 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -50,7 +50,7 @@ public: virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); virtual ERRORCODE setViewport(int left, int top, int right, int bottom); - virtual ERRORCODE setViewport(Common::Rect *Rect); + virtual ERRORCODE setViewport(Rect32 *Rect); virtual ERRORCODE setScreenViewport(); virtual ERRORCODE fade(uint16 Alpha); virtual ERRORCODE fadeToColor(uint32 Color, Common::Rect *rect = NULL); @@ -103,17 +103,17 @@ public: virtual ERRORCODE endSpriteBatch() { return STATUS_OK; }; - bool pointInViewport(Common::Point *P); + bool pointInViewport(Point32 *P); uint32 _forceAlphaColor; uint32 _window; uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; - Common::Rect _windowRect; - Common::Rect _viewportRect; - Common::Rect _screenRect; - Common::Rect _monitorRect; + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; int _bPP; int _height; int _width; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 6fd5152d70..f33b5764c6 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -413,13 +413,13 @@ CBSurface *CBSprite::getSurface() { } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; CBPlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { - Common::Rect frame; - Common::Rect temp; + Rect32 frame; + Rect32 temp; CBPlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); CBPlatform::unionRect(rect, &temp, &frame); diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index 2b705b689a..bf40bbc6c6 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -53,7 +53,7 @@ public: DECLARE_PERSISTENT(CBSprite, CBScriptHolder) bool _editorAllFrames; - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; ERRORCODE display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); @@ -72,7 +72,7 @@ public: ERRORCODE draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Common::Rect *rect = NULL); + ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 33c6c32f8f..aa8ce926dc 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -110,7 +110,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; CBParser parser(Game); - Common::Rect rect; + Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; @@ -233,7 +233,7 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Common::Rect *rect, int x, int y, float scaleX, float scaleY) { +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; float ratioX = scaleX / 100.0f; @@ -259,7 +259,7 @@ ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) if (_transparent != 0xFFFF00FF) buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - Common::Rect rect; + Rect32 rect; CBPlatform::setRectEmpty(&rect); if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); if (!CBPlatform::equalRect(&rect, &_rect)) diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index a13a5fa196..46ee948e64 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -53,12 +53,12 @@ public: virtual ~CBSubFrame(); ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Common::Rect *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; int _hotspotY; uint32 _alpha; - Common::Rect _rect; + Rect32 _rect; bool _cKDefault; byte _cKRed; diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index f67808a47f..0d96a73d41 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -75,12 +75,12 @@ bool CBSurface::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayHalfTrans(int x, int y, Common::Rect rect) { +ERRORCODE CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index a22f1d7606..cb19a23271 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BSURFACE_H #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "graphics/surface.h" namespace WinterMute { @@ -52,14 +53,14 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual ERRORCODE displayHalfTrans(int x, int y, Common::Rect rect); + virtual ERRORCODE displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); - virtual ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual ERRORCODE displayZoom(int x, int y, Common::Rect rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual ERRORCODE displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual ERRORCODE restore(); virtual ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual ERRORCODE create(int Width, int Height); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 07e552138c..bbdfeca3d7 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -403,40 +403,40 @@ ERRORCODE CBSurfaceSDL::endPixelOp() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Common::Rect rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(Game->_renderer); if (!_loaded) { diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 0bfda92866..289f75eaf3 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -53,12 +53,12 @@ public: ERRORCODE endPixelOp(); - ERRORCODE displayTransZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTrans(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransOffset(int x, int y, Common::Rect rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - ERRORCODE display(int x, int y, Common::Rect rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayZoom(int x, int y, Common::Rect rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Common::Rect Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); @@ -86,7 +86,7 @@ private: Graphics::Surface *_surface; bool _loaded; void finishLoad(); - ERRORCODE drawSprite(int x, int y, Common::Rect *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + ERRORCODE drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index ad89bc0697..f1f28bc78b 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -79,7 +79,7 @@ ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noC ////////////////////////////////////////////////////////////////////////// -Common::Rect *CBViewport::getRect() { +Rect32 *CBViewport::getRect() { return &_rect; } diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 0ace6791bc..83e89a6014 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -38,7 +38,7 @@ class CBViewport : public CBBase { public: int getHeight(); int getWidth(); - Common::Rect *getRect(); + Rect32 *getRect(); ERRORCODE setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; @@ -47,7 +47,7 @@ public: CBViewport(CBGame *inGame = NULL); virtual ~CBViewport(); private: - Common::Rect _rect; + Rect32 _rect; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h index 2f72d96103..e2de466e42 100644 --- a/engines/wintermute/Base/PartEmitter.h +++ b/engines/wintermute/Base/PartEmitter.h @@ -82,7 +82,7 @@ public: int _maxBatches; int _batchesGenerated; - Common::Rect _border; + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp index 3eaa546d29..f3a8de9ece 100644 --- a/engines/wintermute/Base/PartParticle.cpp +++ b/engines/wintermute/Base/PartParticle.cpp @@ -124,7 +124,7 @@ ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint3 // particle hit the border if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Common::Point p; + Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; if (!CBPlatform::ptInRect(&_border, p)) diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h index 229bc11935..aed559d337 100644 --- a/engines/wintermute/Base/PartParticle.h +++ b/engines/wintermute/Base/PartParticle.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/math/Vector2.h" namespace WinterMute { @@ -57,7 +58,7 @@ public: int _alpha1; int _alpha2; - Common::Rect _border; + Rect32 _border; Vector2 _pos; float _posZ; Vector2 _velocity; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 175cb1d68a..9edd8f2152 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -181,7 +181,7 @@ uint32 CBPlatform::getTime() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::getCursorPos(Common::Point *lpPoint) { +bool CBPlatform::getCursorPos(Point32 *lpPoint) { CBRenderSDL *renderer = static_cast(Game->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); @@ -197,7 +197,7 @@ bool CBPlatform::getCursorPos(Common::Point *lpPoint) { bool CBPlatform::setCursorPos(int X, int Y) { CBRenderSDL *renderer = static_cast(Game->_renderer); - Common::Point p; + Point32 p; p.x = X; p.y = Y; renderer->pointToScreen(&p); @@ -245,23 +245,23 @@ bool CBPlatform::setForegroundWindow() { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRectEmpty(Common::Rect *lprc) { +bool CBPlatform::setRectEmpty(Rect32 *lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; return true; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::isRectEmpty(const Common::Rect *lprc) { +bool CBPlatform::isRectEmpty(const Rect32 *lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ptInRect(Common::Rect *lprc, Common::Point p) { +bool CBPlatform::ptInRect(Rect32 *lprc, Point32 p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRect(Common::Rect *lprc, int left, int top, int right, int bottom) { +bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; @@ -271,7 +271,7 @@ bool CBPlatform::setRect(Common::Rect *lprc, int left, int top, int right, int b } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2) { +bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { @@ -287,7 +287,7 @@ bool CBPlatform::intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSr } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2) { +bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1)) { if (isRectEmpty(lprcSrc2)) { setRectEmpty(lprcDst); @@ -310,7 +310,7 @@ bool CBPlatform::unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc) { +bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; @@ -318,7 +318,7 @@ bool CBPlatform::copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::offsetRect(Common::Rect *lprc, int dx, int dy) { +bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { if (lprc == NULL) return false; lprc->left += dx; @@ -330,7 +330,7 @@ bool CBPlatform::offsetRect(Common::Rect *lprc, int dx, int dy) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::equalRect(Common::Rect *rect1, Common::Rect *rect2) { +bool CBPlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index fc2e60a7a4..547f6b81b1 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -30,7 +30,7 @@ #define WINTERMUTE_PLATFORMSDL_H #include "engines/wintermute/dctypes.h" - +#include "engines/wintermute/Math/Rect32.h" #include "engines/wintermute/wintypes.h" #include "common/events.h" @@ -50,7 +50,7 @@ public: // Win32 API bindings static void outputDebugString(const char *lpOutputString); static uint32 getTime(); - static bool getCursorPos(Common::Point *lpPoint); + static bool getCursorPos(Point32 *lpPoint); static bool setCursorPos(int X, int Y); static bool showWindow(int nCmdShow); static bool deleteFile(const char *lpFileName); @@ -59,15 +59,15 @@ public: static bool releaseCapture(); static bool setForegroundWindow(); - static bool setRectEmpty(Common::Rect *lprc); - static bool isRectEmpty(const Common::Rect *lprc); - static bool ptInRect(Common::Rect *lprc, Common::Point p); - static bool setRect(Common::Rect *lprc, int left, int top, int right, int bottom); - static bool intersectRect(Common::Rect *lprcDst, const Common::Rect *lprcSrc1, const Common::Rect *lprcSrc2); - static bool unionRect(Common::Rect *lprcDst, Common::Rect *lprcSrc1, Common::Rect *lprcSrc2); - static bool copyRect(Common::Rect *lprcDst, Common::Rect *lprcSrc); - static bool offsetRect(Common::Rect *lprc, int dx, int dy); - static bool equalRect(Common::Rect *rect1, Common::Rect *rect2); + static bool setRectEmpty(Rect32 *lprc); + static bool isRectEmpty(const Rect32 *lprc); + static bool ptInRect(Rect32 *lprc, Point32 p); + static bool setRect(Rect32 *lprc, int left, int top, int right, int bottom); + static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); + static bool unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2); + static bool copyRect(Rect32 *lprcDst, Rect32 *lprcSrc); + static bool offsetRect(Rect32 *lprc, int dx, int dy); + static bool equalRect(Rect32 *rect1, Rect32 *rect2); // string functions diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 43e1262ce3..65a643b9d3 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -539,7 +539,7 @@ ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// void CUIButton::correctSize() { - Common::Rect rect; + Rect32 rect; CBSprite *img = NULL; if (_image) img = _image; @@ -623,7 +623,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { int imageY = offsetY + _posY; if (image && _centerImage) { - Common::Rect rc; + Rect32 rc; image->getBoundingRect(&rc, 0, 0); imageX += (_width - (rc.right - rc.left)) / 2; imageY += (_height - (rc.bottom - rc.top)) / 2; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 7af29a9eac..668d4eb234 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -113,7 +113,7 @@ void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObje ////////////////////////////////////////////////////////////////////////// void CUIObject::correctSize() { - Common::Rect rect; + Rect32 rect; if (_width <= 0) { if (_image) { diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 297a868ed0..35083c15a8 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -47,15 +47,15 @@ public: CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; - Common::Rect _upLeft; - Common::Rect _upMiddle; - Common::Rect _upRight; - Common::Rect _middleLeft; - Common::Rect _middleMiddle; - Common::Rect _middleRight; - Common::Rect _downLeft; - Common::Rect _downMiddle; - Common::Rect _downRight; + Rect32 _upLeft; + Rect32 _upMiddle; + Rect32 _upRight; + Rect32 _middleLeft; + Rect32 _middleMiddle; + Rect32 _middleRight; + Rect32 _downLeft; + Rect32 _downMiddle; + Rect32 _downRight; }; } // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index cc8d966bc2..de17966ac5 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -1135,7 +1135,7 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { if (!CBPlatform::isRectEmpty(&_dragRect)) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - Common::Rect dragRect = _dragRect; + Rect32 dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index 79e1ce09be..e597debaaa 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -59,14 +59,14 @@ public: TWindowMode _mode; ERRORCODE moveFocus(bool forward = true); virtual ERRORCODE handleMouse(TMouseEvent Event, TMouseButton Button); - Common::Point _dragFrom; + Point32 _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; ERRORCODE showWidget(const char *name, bool visible = true); ERRORCODE enableWidget(const char *name, bool enable = true); - Common::Rect _titleRect; - Common::Rect _dragRect; + Rect32 _titleRect; + Rect32 _dragRect; virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); diff --git a/engines/wintermute/math/Rect32.h b/engines/wintermute/math/Rect32.h new file mode 100644 index 0000000000..e0babcbbb9 --- /dev/null +++ b/engines/wintermute/math/Rect32.h @@ -0,0 +1,86 @@ +/* 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. + * + */ + +#ifndef WINTERMUTE_RECT32_H +#define WINTERMUTE_RECT32_H + +#include "common/system.h" + +namespace WinterMute { + +struct Point32 { + int32 x; + int32 y; +}; + +struct Rect32 { + int32 top, left; ///< The point at the top left of the rectangle (part of the rect). + int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). + + Rect32() : top(0), left(0), bottom(0), right(0) {} + Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} + Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { + assert(isValidRect()); + } + bool operator==(const Rect32 &rhs) const { return equals(rhs); } + bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } + + int16 width() const { return right - left; } + int16 height() const { return bottom - top; } + + void setWidth(int16 aWidth) { + right = left + aWidth; + } + + void setHeight(int16 aHeight) { + bottom = top + aHeight; + } + + void setEmpty() { + left = right = top = bottom = 0; + } + + void offsetRect(int dx, int dy) { + left += dx; + top += dy; + right += dx; + bottom += dy; + } + /** + * Check if the given rect is equal to this one. + * + * @param r The rectangle to check + * + * @return true if the given rect is equal, false otherwise + */ + bool equals(const Rect32 &r) const { + return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); + } + + bool isValidRect() const { + return (left <= right && top <= bottom); + } +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ae64cd0686..9efc7b8935 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -45,7 +45,7 @@ static inline unsigned Sqr(int x) { ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect) { +void CBUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { // If it's partly off the right side of the screen if (*destX + (srcRect->right - srcRect->left) > destRect->right) srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index e178d35853..d75bb8c550 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -30,6 +30,7 @@ #define WINTERMUTE_UTILS_H #include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Math/Rect32.h" namespace WinterMute { @@ -37,7 +38,7 @@ class CBGame; class CBUtils { public: - static void clip(int *destX, int *destY, Common::Rect *srcRect, Common::Rect *destRect); + static void clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect); static void swap(int *a, int *b); static bool strBeginsI(const char *string, const char *fragment); static float normalizeAngle(float angle); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index c57049e177..99acdc24e4 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -652,7 +652,7 @@ void CVidTheoraPlayer::writeAlpha() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { - Common::Rect rc; + Rect32 rc; ERRORCODE res; if (_texture && _videoFrameReady) { -- cgit v1.2.3 From 370c458efdf40d31d66eb61094f7475cdd32132c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 12:29:00 +0200 Subject: WINTERMUTE: Rename a few missed VarName->varNames in AdInventoryBox --- engines/wintermute/Ad/AdInventoryBox.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index a528167e8c..222d91800d 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -103,13 +103,13 @@ ERRORCODE CAdInventoryBox::display() { if (!_visible) return STATUS_OK; - int ItemsX, ItemsY; - ItemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); - ItemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); + int itemsX, itemsY; + itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + itemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); if (_window) { _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + ItemsX * ItemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); + _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); } @@ -132,12 +132,12 @@ ERRORCODE CAdInventoryBox::display() { // display items if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor; int yyy = rect.top; - for (int j = 0; j < ItemsY; j++) { + for (int j = 0; j < itemsY; j++) { int xxx = rect.left; - for (int i = 0; i < ItemsX; i++) { - int ItemIndex = _scrollOffset + j * ItemsX + i; - if (ItemIndex >= 0 && ItemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { - CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[ItemIndex]; + for (int i = 0; i < itemsX; i++) { + int itemIndex = _scrollOffset + j * itemsX + i; + if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { + CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { item->update(); item->display(xxx, yyy); -- cgit v1.2.3 From bd3b22b14b4251ea644cceba96334205f797e720 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 9 Jul 2012 13:36:37 +0200 Subject: WINTERMUTE: Move font & particle emitter-related code to it's own subfolder --- engines/wintermute/Ad/AdEntity.cpp | 4 +- engines/wintermute/Ad/AdGame.cpp | 4 +- engines/wintermute/Ad/AdItem.cpp | 4 +- engines/wintermute/Ad/AdObject.cpp | 4 +- engines/wintermute/Ad/AdObject.h | 2 +- engines/wintermute/Ad/AdResponse.cpp | 2 +- engines/wintermute/Ad/AdResponseBox.cpp | 4 +- engines/wintermute/Ad/AdScene.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 2 +- engines/wintermute/Base/BFont.cpp | 206 ---- engines/wintermute/Base/BFont.h | 61 - engines/wintermute/Base/BFontBitmap.cpp | 540 --------- engines/wintermute/Base/BFontBitmap.h | 72 -- engines/wintermute/Base/BFontStorage.cpp | 135 --- engines/wintermute/Base/BFontStorage.h | 55 - engines/wintermute/Base/BFontTT.cpp | 758 ------------- engines/wintermute/Base/BFontTT.h | 180 --- engines/wintermute/Base/BGame.cpp | 4 +- engines/wintermute/Base/PartEmitter.cpp | 1199 -------------------- engines/wintermute/Base/PartEmitter.h | 139 --- engines/wintermute/Base/PartForce.cpp | 59 - engines/wintermute/Base/PartForce.h | 57 - engines/wintermute/Base/PartParticle.cpp | 257 ----- engines/wintermute/Base/PartParticle.h | 90 -- engines/wintermute/Base/font/BFont.cpp | 206 ++++ engines/wintermute/Base/font/BFont.h | 61 + engines/wintermute/Base/font/BFontBitmap.cpp | 540 +++++++++ engines/wintermute/Base/font/BFontBitmap.h | 72 ++ engines/wintermute/Base/font/BFontStorage.cpp | 135 +++ engines/wintermute/Base/font/BFontStorage.h | 55 + engines/wintermute/Base/font/BFontTT.cpp | 758 +++++++++++++ engines/wintermute/Base/font/BFontTT.h | 180 +++ engines/wintermute/Base/particles/PartEmitter.cpp | 1199 ++++++++++++++++++++ engines/wintermute/Base/particles/PartEmitter.h | 139 +++ engines/wintermute/Base/particles/PartForce.cpp | 59 + engines/wintermute/Base/particles/PartForce.h | 57 + engines/wintermute/Base/particles/PartParticle.cpp | 257 +++++ engines/wintermute/Base/particles/PartParticle.h | 90 ++ engines/wintermute/UI/UIButton.cpp | 4 +- engines/wintermute/UI/UIEdit.cpp | 4 +- engines/wintermute/UI/UIObject.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 4 +- engines/wintermute/UI/UIWindow.cpp | 4 +- engines/wintermute/module.mk | 14 +- engines/wintermute/persistent.cpp | 6 +- 45 files changed, 3843 insertions(+), 3843 deletions(-) delete mode 100644 engines/wintermute/Base/BFont.cpp delete mode 100644 engines/wintermute/Base/BFont.h delete mode 100644 engines/wintermute/Base/BFontBitmap.cpp delete mode 100644 engines/wintermute/Base/BFontBitmap.h delete mode 100644 engines/wintermute/Base/BFontStorage.cpp delete mode 100644 engines/wintermute/Base/BFontStorage.h delete mode 100644 engines/wintermute/Base/BFontTT.cpp delete mode 100644 engines/wintermute/Base/BFontTT.h delete mode 100644 engines/wintermute/Base/PartEmitter.cpp delete mode 100644 engines/wintermute/Base/PartEmitter.h delete mode 100644 engines/wintermute/Base/PartForce.cpp delete mode 100644 engines/wintermute/Base/PartForce.h delete mode 100644 engines/wintermute/Base/PartParticle.cpp delete mode 100644 engines/wintermute/Base/PartParticle.h create mode 100644 engines/wintermute/Base/font/BFont.cpp create mode 100644 engines/wintermute/Base/font/BFont.h create mode 100644 engines/wintermute/Base/font/BFontBitmap.cpp create mode 100644 engines/wintermute/Base/font/BFontBitmap.h create mode 100644 engines/wintermute/Base/font/BFontStorage.cpp create mode 100644 engines/wintermute/Base/font/BFontStorage.h create mode 100644 engines/wintermute/Base/font/BFontTT.cpp create mode 100644 engines/wintermute/Base/font/BFontTT.h create mode 100644 engines/wintermute/Base/particles/PartEmitter.cpp create mode 100644 engines/wintermute/Base/particles/PartEmitter.h create mode 100644 engines/wintermute/Base/particles/PartForce.cpp create mode 100644 engines/wintermute/Base/particles/PartForce.h create mode 100644 engines/wintermute/Base/particles/PartParticle.cpp create mode 100644 engines/wintermute/Base/particles/PartParticle.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 599afee626..3d9c7f5055 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -39,8 +39,8 @@ #include "engines/wintermute/Ad/AdScene.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Ad/AdSentence.h" #include "engines/wintermute/Base/BRegion.h" #include "engines/wintermute/Base/BSprite.h" diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index ed31cd3acb..759c212de8 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -40,7 +40,7 @@ #include "engines/wintermute/Ad/AdSceneState.h" #include "engines/wintermute/Ad/AdSentence.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BSound.h" @@ -49,7 +49,7 @@ #include "engines/wintermute/Base/BTransitionMgr.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Base/particles/PartEmitter.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index e8c32607dc..a728a8d048 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -30,8 +30,8 @@ #include "engines/wintermute/Ad/AdItem.h" #include "engines/wintermute/Ad/AdGame.h" #include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BParser.h" diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 06c63a4d1b..4dd6f4ce4b 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -41,8 +41,8 @@ #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/scriptables/ScEngine.h" diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index c71efce1a5..546089bada 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADOBJECT_H #include "engines/wintermute/Ad/AdTypes.h" -#include "engines/wintermute/Base/PartEmitter.h" +#include "engines/wintermute/Base/particles/PartEmitter.h" namespace WinterMute { diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 7c6d3f56c9..0b0bea2f57 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Ad/AdResponse.h" #include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/utils/utils.h" diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index cb9a0496d1..c055c2f363 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -34,8 +34,8 @@ #include "engines/wintermute/UI/UIButton.h" #include "engines/wintermute/UI/UIWindow.h" #include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Ad/AdResponse.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index 41b413cc14..b338232c98 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -43,7 +43,7 @@ #include "engines/wintermute/Ad/AdWaypointGroup.h" #include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/Base/BParser.h" diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index ed43630e0c..7d37efce49 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" diff --git a/engines/wintermute/Base/BFont.cpp b/engines/wintermute/Base/BFont.cpp deleted file mode 100644 index 1849401e53..0000000000 --- a/engines/wintermute/Base/BFont.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontBitmap.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFontTT.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFont, false) - -////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { -} - - -////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - -/* -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::loadFile(const char * Filename) -{ - BYTE* Buffer = Game->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ - Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - ERRORCODE ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if(DID_FAIL(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - CBParser parser(Game); - - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - Game->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - Game->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ - -////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { - if (isTrueType(Game, filename)) { - CBFontTT *font = new CBFontTT(Game); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - CBFontBitmap *font = new CBFontBitmap(Game); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *Game, const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = Game->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; - - byte *WorkBuffer = buffer; - - char *params; - CBParser parser(Game); - - bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - ret = true; - - delete [] buffer; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFont.h b/engines/wintermute/Base/BFont.h deleted file mode 100644 index ac5a79299d..0000000000 --- a/engines/wintermute/Base/BFont.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H - -#include "engines/wintermute/Base/BObject.h" - -#define NUM_CHARACTERS 256 - -namespace WinterMute { - -class CBFont: public CBObject { -public: - DECLARE_PERSISTENT(CBFont, CBObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - virtual void initLoop() {}; - virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); - - static CBFont *createFromFile(CBGame *game, const char *filename); - -private: - //ERRORCODE loadBuffer(byte * Buffer); - //ERRORCODE loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFontBitmap.cpp b/engines/wintermute/Base/BFontBitmap.cpp deleted file mode 100644 index b913eea3ee..0000000000 --- a/engines/wintermute/Base/BFontBitmap.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFontBitmap.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { - AnsiString str; - - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (maxLength >= 0 && str.size() > (uint32)maxLength) - str = Common::String(str.c_str(), (uint32)maxLength); - //str.substr(0, maxLength); // TODO: Remove - - int textWidth = 0; - for (size_t i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; - - if (text == NULL || text[0] == '\0') return _tileHeight; - - AnsiString str; - - if (Game->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - if (str.empty()) return 0; - - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool new_line = false; - bool long_line = false; - - if (draw) Game->_renderer->startSpriteBatch(); - - while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) Game->_renderer->endSpriteBatch(); - return NumLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { - end = index - 1; - RealLength = LineLength; - } - - if (str[index] == '\n') { - end = index - 1; - RealLength = LineLength; - new_line = true; - } - - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; - } - - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!new_line) { - end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; - } - } else LineLength += getCharWidth(str[index]); - - if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; - int StartX; - switch (align) { - case TAL_CENTER: - StartX = x + (width - RealLength) / 2; - break; - case TAL_RIGHT: - StartX = x + width - RealLength; - break; - case TAL_LEFT: - StartX = x; - break; - default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); - StartX += getCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (long_line) end--; - start = end + 2; - index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; - } - } - - if (draw) Game->_renderer->endSpriteBatch(); - - return NumLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - Rect32 rect; - /* l t r b */ - int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; - - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); - bool handled = false; - if (_sprite) { - _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); - } - handled = true; - } - } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); -} - - -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - ERRORCODE ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - Game->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - int widths[300]; - int num = 0, default_width = 8; - int lastWidth = 0; - int i; - int r = 255, g = 255, b = 255; - bool custoTrans = false; - char *surfaceFile = NULL; - char *spriteFile = NULL; - - bool autoWidth = false; - int spaceWidth = 0; - int expandWidth = 0; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = (char *)params; - break; - - case TOKEN_SPRITE: - spriteFile = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_WIDTHS: - parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { - _widths[lastWidth] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); - break; - - case TOKEN_WIDTHS_FRAME: - parser.scanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.scanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.scanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.scanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.scanStr(params, "%b", &autoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.scanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.scanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.scanStr(params, "%d", &spaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.scanStr(params, "%d", &expandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - if (spriteFile != NULL) { - delete _sprite; - _sprite = new CBSprite(Game, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(Game); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - Game->LOG(0, "Incomplete font definition"); - return STATUS_FAILED; - } - - if (autoWidth) { - // calculate characters width - getWidths(); - - // do we need to modify widths? - if (expandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; - - _widths[i] = (byte)NewWidth; - } - } - - // handle space character - uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; - - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { - if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { - _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::persist(CBPersistMgr *persistMgr) { - - CBFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); - - persistMgr->transfer(TMEMBER(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); - - if (persistMgr->_saving) - persistMgr->putBytes(_widths, sizeof(_widths)); - else - persistMgr->getBytes(_widths, sizeof(_widths)); - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::getWidths() { - CBSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int minCol = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; - if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - minCol = MAX(col, minCol); - break; - } - } - if (minCol == _tileWidth - 1) break; - } - - _widths[i] = minCol + 1; - } - surf->endPixelOp(); - /* - Game->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontBitmap.h b/engines/wintermute/Base/BFontBitmap.h deleted file mode 100644 index 3cd0d91e77..0000000000 --- a/engines/wintermute/Base/BFontBitmap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H - - -#include "engines/wintermute/Base/BFont.h" - -namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { -public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) - ERRORCODE loadBuffer(byte *Buffer); - ERRORCODE loadFile(const char *filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); - - - ERRORCODE getWidths(); - CBSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; - bool _wholeCell; - -private: - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFontStorage.cpp b/engines/wintermute/Base/BFontStorage.cpp deleted file mode 100644 index 8b43510708..0000000000 --- a/engines/wintermute/Base/BFontStorage.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); - delete _fonts[i]; - } - _fonts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { - if (!filename) return NULL; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - CBFont* font = new CBFont(Game); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - CBFont *font = CBFont::createFromFile(Game, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::removeFont(CBFont *font) { - if (!font) return STATUS_FAILED; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.removeAt(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) { - - if (!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(Game)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontStorage.h b/engines/wintermute/Base/BFontStorage.h deleted file mode 100644 index 33a1bb056f..0000000000 --- a/engines/wintermute/Base/BFontStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBFont; - -class CBFontStorage : public CBBase { -public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) - ERRORCODE cleanup(bool warn = false); - ERRORCODE removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; - ERRORCODE initLoop(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp deleted file mode 100644 index 10d552d4e2..0000000000 --- a/engines/wintermute/Base/BFontTT.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BFontTT.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/BRenderer.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFontTT, false) - -////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - _deletableFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { - clearCache(); - - for (int i = 0; i < _layers.getSize(); i++) { - delete _layers[i]; - } - _layers.removeAll(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (Game->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; - } - } -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { - WideString textStr; - - if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - measureText(textStr, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { - WideString textStr; - - if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - - int textWidth, textHeight; - measureText(textStr, width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; - - WideString textStr = (char *)text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - CBRenderer *renderer = Game->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - CBSurface *surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - minPriority = 0; - minIndex = i; - } else { - if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { - surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; - minIndex = i; - } - } - } - } - - // not found, create one - if (!surface) { - warning("Draw text: %s", text); - surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); - if (surface) { - // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; - - _cachedTexts[minIndex]->_surface = surface; - _cachedTexts[minIndex]->_align = align; - _cachedTexts[minIndex]->_width = width; - _cachedTexts[minIndex]->_maxHeight = maxHeight; - _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; - _cachedTexts[minIndex]->_text = textStr; - _cachedTexts[minIndex]->_textOffset = textOffset; - _cachedTexts[minIndex]->_marked = true; - } - } - - - // and paint it - if (surface) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { - uint32 color = _layers[i]->_color; - uint32 origForceAlpha = renderer->_forceAlphaColor; - if (renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); - renderer->_forceAlphaColor = 0; - } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - renderer->_forceAlphaColor = origForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO - //WrapText(text, width, maxHeight, lines); - Common::Array lines; - _font->wordWrapText(text, width, lines); - - Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; - if (align == TAL_LEFT) { - alignment = Graphics::kTextAlignLeft; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - alignment = Graphics::kTextAlignRight; - } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); - } - warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); -// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; - Graphics::Surface *surface = new Graphics::Surface(); - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); - - uint16 useColor = 0xffff; - Common::Array::iterator it; - int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += (int)_lineHeight; - } - - CBSurface *retSurface = Game->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - ERRORCODE ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - Game->LOG(0, "'TTFONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - uint32 BaseColor = 0x00000000; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.scanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.scanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.scanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.scanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.scanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); - } - break; - - case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TTFONT definition"); - return STATUS_FAILED; - } - - // create at least one layer - if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); - } - - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(Game); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.scanStr(params, "%d", &layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.scanStr(params, "%d", &layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); - - - // persist layers - int numLayers; - if (persistMgr->_saving) { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); - } else { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->_saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; - - Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); - if (!file) { - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = Game->_fileManager->openFile(fontFileName.c_str(), false); - if (!file) { - Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; - } - } - - if (file) { -#ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - Game->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } - if (maxWidth >= 0) { - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - Common::Array::iterator it; - textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { - textWidth = MAX(textWidth, _font->getStringWidth(*it)); - } - - //WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * getLineHeight()); - } else { - textWidth = _font->getStringWidth(text); - textHeight = _fontHeight; - } - /* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFontTT.h b/engines/wintermute/Base/BFontTT.h deleted file mode 100644 index c585ca2070..0000000000 --- a/engines/wintermute/Base/BFontTT.h +++ /dev/null @@ -1,180 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H - -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BSurface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace WinterMute { - -class CBFontTT : public CBFont { -private: - ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - CBSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - CBCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~CBCachedTTFontText() { - if (_surface) delete _surface; - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { - public: - CBTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - ERRORCODE persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - -public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); - - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - ERRORCODE loadBuffer(byte *buffer); - ERRORCODE loadFile(const char *filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - ERRORCODE parseLayer(CBTTFontLayer *layer, byte *buffer); - - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - - - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - ERRORCODE initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _ascender; - float _descender; - float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - CBArray _layers; - void clearCache(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index bf1bc5c34b..cd7dc07925 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -30,8 +30,8 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFader.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/Base/BKeyboardState.h" #include "engines/wintermute/Base/BParser.h" diff --git a/engines/wintermute/Base/PartEmitter.cpp b/engines/wintermute/Base/PartEmitter.cpp deleted file mode 100644 index c3efc74eec..0000000000 --- a/engines/wintermute/Base/PartEmitter.cpp +++ /dev/null @@ -1,1199 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/PartEmitter.h" -#include "engines/wintermute/Base/PartParticle.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include "common/math.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CPartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - _width = _height = 0; - - CBPlatform::setRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = Owner; -} - - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - for (int i = 0; i < _forces.getSize(); i++) { - delete _forces[i]; - } - _forces.removeAll(); - - - for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; - } - _sprites.removeAll(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; - - // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; - } - - // check if file exists - Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); - if (!File) { - Game->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else Game->_fileManager->closeFile(File); - - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; - _sprites.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; - - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); - - float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); - - float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); - - int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); - - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); - - if (!CBPlatform::isRectEmpty(&_border)) { - int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); - int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); - int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); - int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - - particle->_border = _border; - particle->_border.left += thicknessLeft; - particle->_border.right -= thicknessRight; - particle->_border.top += thicknessTop; - particle->_border.bottom -= thicknessBottom; - } - - Vector2 vecPos((float)posX, (float)posY); - Vector2 vecVel(0, velocity); - - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); - particle->_alpha1 = alpha; - particle->_alpha2 = alpha; - } - - particle->_creationTime = currentTime; - particle->_pos = vecPos; - particle->_posZ = posZ; - particle->_velocity = vecVel; - particle->_scale = scale; - particle->_lifeTime = lifeTime; - particle->_rotation = rotation; - particle->_angVelocity = angVelocity; - particle->_growthRate = growthRate; - particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); - particle->fadeIn(currentTime, _fadeInTime); - - - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(Game->_timer, Game->_timerDelta); -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->update(this, currentTime, timerDelta); - - if (!_particles[i]->_isDead) numLive++; - } - - - // we're understaffed - if (numLive < _maxParticles) { - bool needsSort = false; - if ((int)(currentTime - _lastGenTime) > _genInterval) { - _lastGenTime = currentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return STATUS_OK; - } - - int toGen = MIN(_genAmount, _maxParticles - numLive); - while (toGen > 0) { - int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - CPartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { - particle = new CPartParticle(Game); - _particles.add(particle); - } - initParticle(particle, currentTime, timerDelta); - needsSort = true; - - toGen--; - } - } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - sortParticlesByZ(); - - // we actually generated some particles and we're not in fast-forward mode - if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::display(CBRegion *region) { - if (_sprites.getSize() <= 1) Game->_renderer->startSpriteBatch(); - - for (int i = 0; i < _particles.getSize(); i++) { - if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; - } - - _particles[i]->display(this); - } - - if (_sprites.getSize() <= 1) Game->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 delta = 500; - int steps = _overheadTime / delta; - uint32 currentTime = Game->_timer - _overheadTime; - - for (int i = 0; i < steps; i++) { - updateInternal(currentTime, delta); - currentTime += delta; - } - _overheadTime = 0; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::sortParticlesByZ() { - // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; - - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; - - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new CPartForce(Game); - if (force) { - force->setName(name); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::removeForce(const char *name) { - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - delete _forces[i]; - _forces.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetBorder") == 0) { - stack->correctParams(4); - int borderX = stack->pop()->getInt(); - int borderY = stack->pop()->getInt(); - int borderWidth = stack->pop()->getInt(); - int borderHeight = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBorderThickness") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Start") == 0) { - stack->correctParams(1); - _overheadTime = stack->pop()->getInt(); - stack->pushBool(DID_SUCCEED(start())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Stop") == 0) { - stack->correctParams(0); - - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Resume") == 0) { - stack->correctParams(0); - _running = true; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddGlobalForce") == 0) { - stack->correctParams(3); - const char *forceName = stack->pop()->getString(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddPointForce") == 0) { - stack->correctParams(5); - const char *forceName = stack->pop()->getString(); - int posX = stack->pop()->getInt(); - int posY = stack->pop()->getInt(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveForce") == 0) { - stack->correctParams(1); - const char *forceName = stack->pop()->getString(); - - stack->pushBool(DID_SUCCEED(removeForce(forceName))); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - -////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scValue->setFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scValue->setFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->setBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _scValue->setFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _scValue->setFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->setBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _scValue->setInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _scValue->setInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->setBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _scValue->setInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _scValue->setInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->setFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->setFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _scValue->setFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _scValue->setFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _scValue->setInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _scValue->setInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->setBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _scValue->setInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { - int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; - } - _scValue->setInt(numAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->setInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->setInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _scValue->setInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _scValue->setInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->setInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->setFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->setFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->setBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _scValue->setBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); - - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); - - persistMgr->transfer(TMEMBER(_velocity1)); - persistMgr->transfer(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); - - persistMgr->transfer(TMEMBER(_scale1)); - persistMgr->transfer(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); - - persistMgr->transfer(TMEMBER(_maxParticles)); - - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); - - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); - - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); - - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); - - persistMgr->transfer(TMEMBER(_angVelocity1)); - persistMgr->transfer(TMEMBER(_angVelocity2)); - - persistMgr->transfer(TMEMBER(_rotation1)); - persistMgr->transfer(TMEMBER(_rotation2)); - - persistMgr->transfer(TMEMBER(_growthRate1)); - persistMgr->transfer(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - - persistMgr->transfer(TMEMBER(_useRegion)); - - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - - persistMgr->transfer(TMEMBER(_emitEvent)); - persistMgr->transfer(TMEMBER(_owner)); - - - _sprites.persist(persistMgr); - - int numForces; - if (persistMgr->_saving) { - numForces = _forces.getSize(); - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(Game); - force->persist(persistMgr); - _forces.add(force); - } - } - - int numParticles; - if (persistMgr->_saving) { - numParticles = _particles.getSize(); - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(Game); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartEmitter.h b/engines/wintermute/Base/PartEmitter.h deleted file mode 100644 index e2de466e42..0000000000 --- a/engines/wintermute/Base/PartEmitter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/PartForce.h" - -namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { -public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) - - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); - - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - Rect32 _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - int _fadeOutTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - CBScriptHolder *_owner; - - ERRORCODE start(); - - ERRORCODE update(); - ERRORCODE display() { return display(NULL); } // To avoid shadowing the inherited display-function. - ERRORCODE display(CBRegion *region); - - ERRORCODE sortParticlesByZ(); - ERRORCODE addSprite(const char *filename); - ERRORCODE removeSprite(const char *filename); - ERRORCODE setBorder(int x, int y, int width, int height); - ERRORCODE setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - ERRORCODE addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - ERRORCODE removeForce(const char *name); - - CBArray _forces; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - CPartForce *addForceByName(const char *name); - int static compareZ(const void *obj1, const void *obj2); - ERRORCODE initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - ERRORCODE updateInternal(uint32 currentTime, uint32 timerDelta); - uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/PartForce.cpp b/engines/wintermute/Base/PartForce.cpp deleted file mode 100644 index b60d5447d9..0000000000 --- a/engines/wintermute/Base/PartForce.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/PartForce.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartForce::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartForce.h b/engines/wintermute/Base/PartForce.h deleted file mode 100644 index cf5d697a79..0000000000 --- a/engines/wintermute/Base/PartForce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BNamedObject.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartForce : public CBNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - ERRORCODE persist(CBPersistMgr *PersistMgr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/PartParticle.cpp b/engines/wintermute/Base/PartParticle.cpp deleted file mode 100644 index f3a8de9ece..0000000000 --- a/engines/wintermute/Base/PartParticle.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/PartParticle.h" -#include "engines/wintermute/Base/PartEmitter.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - CBPlatform::setRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(Game, Game); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { - if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - - return STATUS_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _isDead = true; - return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - - return STATUS_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) - fadeOut(currentTime, emitter->_fadeOutTime); - else - _isDead = true; - } - } - - // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) - fadeOut(currentTime, emitter->_fadeOutTime); - } - if (_state != PARTICLE_NORMAL) return STATUS_OK; - - // update alpha - if (_lifeTime > 0) { - int age = (int)(currentTime - _creationTime); - int alphaDelta = (int)(_alpha2 - _alpha1); - - _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); - } - - // update position - float elapsedTime = (float)timerDelta / 1000.f; - - for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; - switch (force->_type) { - case CPartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case CPartForce::FORCE_POINT: { - Vector2 vecDist = force->_pos - _pos; - float dist = fabs(vecDist.length()); - - dist = 100.0f / dist; - - _velocity += force->_direction * dist * elapsedTime; - } - break; - } - } - _pos += _velocity * elapsedTime; - - // update rotation - _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * elapsedTime; - else - _scale += _growthRate * elapsedTime; - - if (_scale <= 0.0f) - _isDead = true; - - - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::display(CPartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; - - _sprite->GetCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_angVelocity)); - persistMgr->transfer(TMEMBER(_rotation)); - persistMgr->transfer(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - - if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/PartParticle.h b/engines/wintermute/Base/PartParticle.h deleted file mode 100644 index aed559d337..0000000000 --- a/engines/wintermute/Base/PartParticle.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTPARTICLE_H -#define WINTERMUTE_PARTPARTICLE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Math/Rect32.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartEmitter; -class CBSprite; -class CBPersistMgr; - -class CPartParticle : public CBBase { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - CBSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - ERRORCODE update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - ERRORCODE display(CPartEmitter *emitter); - - ERRORCODE setSprite(const char *filename); - - ERRORCODE fadeIn(uint32 currentTime, int fadeTime); - ERRORCODE fadeOut(uint32 currentTime, int fadeTime); - - ERRORCODE persist(CBPersistMgr *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/font/BFont.cpp b/engines/wintermute/Base/font/BFont.cpp new file mode 100644 index 0000000000..b59188d0c1 --- /dev/null +++ b/engines/wintermute/Base/font/BFont.cpp @@ -0,0 +1,206 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/font/BFontBitmap.h" +#include "engines/wintermute/Base/font/BFontTT.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFont::loadFile(const char * Filename) +{ + BYTE* Buffer = Game->_fileManager->readWholeFile(filename); + if(Buffer==NULL){ + Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + ERRORCODE ret; + + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); + + if(DID_FAIL(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFont::loadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(Game); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + Game->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + Game->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { + if (isTrueType(Game, filename)) { + CBFontTT *font = new CBFontTT(Game); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + CBFontBitmap *font = new CBFontBitmap(Game); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::isTrueType(CBGame *Game, const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; + + byte *WorkBuffer = buffer; + + char *params; + CBParser parser(Game); + + bool ret = false; + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + ret = true; + + delete [] buffer; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFont.h b/engines/wintermute/Base/font/BFont.h new file mode 100644 index 0000000000..ac5a79299d --- /dev/null +++ b/engines/wintermute/Base/font/BFont.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/Base/BObject.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {}; + virtual void afterLoad() {}; + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *createFromFile(CBGame *game, const char *filename); + +private: + //ERRORCODE loadBuffer(byte * Buffer); + //ERRORCODE loadFile(const char* Filename); + static bool isTrueType(CBGame *game, const char *filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp new file mode 100644 index 0000000000..681f2580bf --- /dev/null +++ b/engines/wintermute/Base/font/BFontBitmap.cpp @@ -0,0 +1,540 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/font/BFontBitmap.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BFrame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (size_t i = 0; i < str.size(); i++) { + textWidth += getCharWidth(str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + AnsiString str; + + if (Game->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) Game->_renderer->startSpriteBatch(); + + while (!done) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (draw) Game->_renderer->endSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += getCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += getCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) Game->_renderer->endSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; + + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontBitmap::loadFile(const char *filename) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + ERRORCODE ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + Game->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new CBSprite(Game, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new CBSubFrame(Game); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + Game->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + expandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; + + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; + else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontBitmap::persist(CBPersistMgr *persistMgr) { + + CBFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); + else + persistMgr->getBytes(_widths, sizeof(_widths)); + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontBitmap::getWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) break; + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + Game->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontBitmap.h b/engines/wintermute/Base/font/BFontBitmap.h new file mode 100644 index 0000000000..b834f919b9 --- /dev/null +++ b/engines/wintermute/Base/font/BFontBitmap.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/Base/font/BFont.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + ERRORCODE loadBuffer(byte *Buffer); + ERRORCODE loadFile(const char *filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + ERRORCODE getWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/font/BFontStorage.cpp b/engines/wintermute/Base/font/BFontStorage.cpp new file mode 100644 index 0000000000..5a0a1e327f --- /dev/null +++ b/engines/wintermute/Base/font/BFontStorage.cpp @@ -0,0 +1,135 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.getSize(); i++) { + if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontStorage::initLoop() { + for (int i = 0; i < _fonts.getSize(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::addFont(const char *filename) { + if (!filename) return NULL; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(Game); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + CBFont *font = CBFont::createFromFile(Game, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.removeAt(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) { + + if (!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(Game)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontStorage.h b/engines/wintermute/Base/font/BFontStorage.h new file mode 100644 index 0000000000..33a1bb056f --- /dev/null +++ b/engines/wintermute/Base/font/BFontStorage.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + ERRORCODE cleanup(bool warn = false); + ERRORCODE removeFont(CBFont *font); + CBFont *addFont(const char *filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + ERRORCODE initLoop(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp new file mode 100644 index 0000000000..ec20c0e393 --- /dev/null +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -0,0 +1,758 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/file/BFile.h" +#include "engines/wintermute/Base/font/BFontTT.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/Base/BRenderer.h" +#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/BParser.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + clearCache(); + + for (int i = 0; i < _layers.getSize(); i++) { + delete _layers[i]; + } + _layers.removeAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; + +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (Game->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; + + WideString textStr = (char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderer *renderer = Game->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + warning("Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (int i = 0; i < _layers.getSize(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } + warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + + uint16 useColor = 0xffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + CBSurface *retSurface = Game->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontTT::loadFile(const char *filename) { + byte *buffer = Game->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + ERRORCODE ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + Game->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + Game->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.getSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.add(Layer); + } + + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(Game); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->_saving) { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + } else { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; + + Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = Game->_fileManager->openFile(fontFileName.c_str(), false); + if (!file) { + Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + } + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + Game->_fileManager->closeFile(file); + return STATUS_FAILED; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return STATUS_FAILED; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontTT.h b/engines/wintermute/Base/font/BFontTT.h new file mode 100644 index 0000000000..1ee9f1d105 --- /dev/null +++ b/engines/wintermute/Base/font/BFontTT.h @@ -0,0 +1,180 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/BSurface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + ERRORCODE persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString getText() const { + return _text; + } + int getWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + ERRORCODE loadBuffer(byte *buffer); + ERRORCODE loadFile(const char *filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + ERRORCODE parseLayer(CBTTFontLayer *layer, byte *buffer); + + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + ERRORCODE initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void clearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/particles/PartEmitter.cpp b/engines/wintermute/Base/particles/PartEmitter.cpp new file mode 100644 index 0000000000..9a92d2aa6e --- /dev/null +++ b/engines/wintermute/Base/particles/PartEmitter.cpp @@ -0,0 +1,1199 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/particles/PartEmitter.h" +#include "engines/wintermute/Base/particles/PartParticle.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/Base/scriptables/ScValue.h" +#include "engines/wintermute/Base/scriptables/ScStack.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/math.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + for (int i = 0; i < _forces.getSize(); i++) { + delete _forces[i]; + } + _forces.removeAll(); + + + for (int i = 0; i < _sprites.getSize(); i++) { + delete [] _sprites[i]; + } + _sprites.removeAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; + + // do we already have the file? + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + } + + // check if file exists + Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); + if (!File) { + Game->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else Game->_fileManager->closeFile(File); + + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); + _sprites.add(Str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::removeSprite(const char *filename) { + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; + + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); + + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::update() { + if (!_running) return STATUS_OK; + else return updateInternal(Game->_timer, Game->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) numLive++; + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; + else { + particle = new CPartParticle(Game); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + sortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::display(CBRegion *region) { + if (_sprites.getSize() <= 1) Game->_renderer->startSpriteBatch(); + + for (int i = 0; i < _particles.getSize(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + } + + _particles[i]->display(this); + } + + if (_sprites.getSize() <= 1) Game->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::start() { + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = Game->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::sortParticlesByZ() { + // sort particles by _posY + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; + + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::addForceByName(const char *name) { + CPartForce *force = NULL; + + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new CPartForce(Game); + if (force) { + force->setName(name); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return STATUS_FAILED; + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::removeForce(const char *name) { + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) numAlive++; + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + int numForces; + if (persistMgr->_saving) { + numForces = _forces.getSize(); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < _forces.getSize(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(Game); + force->persist(persistMgr); + _forces.add(force); + } + } + + int numParticles; + if (persistMgr->_saving) { + numParticles = _particles.getSize(); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(Game); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartEmitter.h b/engines/wintermute/Base/particles/PartEmitter.h new file mode 100644 index 0000000000..6f517bf357 --- /dev/null +++ b/engines/wintermute/Base/particles/PartEmitter.h @@ -0,0 +1,139 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/Base/BObject.h" +#include "engines/wintermute/Base/particles/PartForce.h" + +namespace WinterMute { +class CBRegion; +class CPartParticle; +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + ERRORCODE start(); + + ERRORCODE update(); + ERRORCODE display() { return display(NULL); } // To avoid shadowing the inherited display-function. + ERRORCODE display(CBRegion *region); + + ERRORCODE sortParticlesByZ(); + ERRORCODE addSprite(const char *filename); + ERRORCODE removeSprite(const char *filename); + ERRORCODE setBorder(int x, int y, int width, int height); + ERRORCODE setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + ERRORCODE addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + ERRORCODE removeForce(const char *name); + + CBArray _forces; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + CPartForce *addForceByName(const char *name); + int static compareZ(const void *obj1, const void *obj2); + ERRORCODE initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + ERRORCODE updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/particles/PartForce.cpp b/engines/wintermute/Base/particles/PartForce.cpp new file mode 100644 index 0000000000..2da74da14d --- /dev/null +++ b/engines/wintermute/Base/particles/PartForce.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/Base/particles/PartForce.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartForce::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartForce.h b/engines/wintermute/Base/particles/PartForce.h new file mode 100644 index 0000000000..cf5d697a79 --- /dev/null +++ b/engines/wintermute/Base/particles/PartForce.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Base/BNamedObject.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + ERRORCODE persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/particles/PartParticle.cpp b/engines/wintermute/Base/particles/PartParticle.cpp new file mode 100644 index 0000000000..10a8e6f51b --- /dev/null +++ b/engines/wintermute/Base/particles/PartParticle.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/particles/PartParticle.h" +#include "engines/wintermute/Base/particles/PartEmitter.h" +#include "engines/wintermute/Base/BSprite.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::getInstance()->_disabled = true; + _sprite = new CBSprite(Game, Game); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!CBPlatform::ptInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return STATUS_OK; + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (int i = 0; i < emitter->_forces.getSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = CBUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * elapsedTime; + else + _scale += _growthRate * elapsedTime; + + if (_scale <= 0.0f) + _isDead = true; + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; + + _sprite->GetCurrentFrame(); + return _sprite->display(_pos.x, _pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +ERRORCODE CPartParticle::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + CSysClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + CSysClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartParticle.h b/engines/wintermute/Base/particles/PartParticle.h new file mode 100644 index 0000000000..aed559d337 --- /dev/null +++ b/engines/wintermute/Base/particles/PartParticle.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + ERRORCODE update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + ERRORCODE display(CPartEmitter *emitter); + + ERRORCODE setSprite(const char *filename); + + ERRORCODE fadeIn(uint32 currentTime, int fadeTime); + ERRORCODE fadeOut(uint32 currentTime, int fadeTime); + + ERRORCODE persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 65a643b9d3..85932ca603 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -33,8 +33,8 @@ #include "engines/wintermute/UI/UITiledImage.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BFileManager.h" diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 778e084ab9..b47885b4dc 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -32,8 +32,8 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BActiveRect.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/BKeyboardState.h" #include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/Base/BParser.h" diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 668d4eb234..6c33bd9509 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/scriptables/ScValue.h" #include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFontStorage.h" namespace WinterMute { diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index 44fb695687..ba8191c204 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -33,8 +33,8 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BFont.h" -#include "engines/wintermute/Base/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index de17966ac5..f16e3afba1 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -39,8 +39,8 @@ #include "engines/wintermute/UI/UIText.h" #include "engines/wintermute/UI/UITiledImage.h" #include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFont.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/BStringTable.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/ScStack.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 8dbdd94b0a..a185f08e13 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -43,6 +43,13 @@ MODULE_OBJS := \ Base/file/BFile.o \ Base/file/BSaveThumbFile.o \ Base/file/BPkgFile.o \ + Base/font/BFontBitmap.o \ + Base/font/BFontTT.o \ + Base/font/BFont.o \ + Base/font/BFontStorage.o \ + Base/particles/PartParticle.o \ + Base/particles/PartEmitter.o \ + Base/particles/PartForce.o \ Base/BActiveRect.o \ Base/BBase.o \ Base/BDebugger.o \ @@ -51,10 +58,6 @@ MODULE_OBJS := \ Base/BFileEntry.o \ Base/BFileManager.o \ Base/BGame.o \ - Base/BFont.o \ - Base/BFontBitmap.o \ - Base/BFontStorage.o \ - Base/BFontTT.o \ Base/BFrame.o \ Base/BImage.o \ Base/BKeyboardState.o \ @@ -84,9 +87,6 @@ MODULE_OBJS := \ Base/BSurfaceStorage.o \ Base/BTransitionMgr.o \ Base/BViewport.o \ - Base/PartParticle.o \ - Base/PartEmitter.o \ - Base/PartForce.o \ detection.o \ graphics/transparentSurface.o \ graphics/tga.o \ diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 8d451aad7b..b753b58d26 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -53,9 +53,9 @@ #include "engines/wintermute/Ad/AdTalkNode.h" #include "engines/wintermute/Ad/AdWaypointGroup.h" #include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/BFontBitmap.h" -#include "engines/wintermute/Base/BFontStorage.h" -#include "engines/wintermute/Base/BFontTT.h" +#include "engines/wintermute/Base/font/BFontBitmap.h" +#include "engines/wintermute/Base/font/BFontStorage.h" +#include "engines/wintermute/Base/font/BFontTT.h" #include "engines/wintermute/Base/BFrame.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BKeyboardState.h" -- cgit v1.2.3 From 2c70a0054da7a95e267aae4cc656cc90ada29e00 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 10 Jul 2012 02:54:52 +0200 Subject: WINTERMUTE: Add detection for J.U.L.I.A. --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index a9a188e2e4..aac6ea9f3a 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -83,6 +83,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_USEEXTRAASTITLE, GUIO0() }, + { + "wintermute", + "J.U.L.I.A.", + AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_USEEXTRAASTITLE, + GUIO0() + }, { "wintermute", "J.U.L.I.A. Demo", -- cgit v1.2.3 From e8d3f0b020718ce37be7f8dbe38f1702228a2c7f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 13:56:18 +0200 Subject: WINTERMUTE: Use 32bpp surfaces for drawing TTF-fonts. --- engines/wintermute/Base/font/BFontTT.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index ec20c0e393..bf59007e0e 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -260,9 +260,9 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15)); + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - uint16 useColor = 0xffff; + uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; for (it = lines.begin(); it != lines.end(); it++) { -- cgit v1.2.3 From e12bfeef7502e20888a0059288a6de09e95a36f7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 13:57:43 +0200 Subject: WINTERMUTE: Readd const to transparentSurface-shifts, and remove branches for mask-less blit. --- engines/wintermute/graphics/transparentSurface.cpp | 234 ++++++++++++++------- 1 file changed, 157 insertions(+), 77 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index 33f2043839..e25efecacf 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -43,6 +43,74 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur } } +void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, uint32 inStep, uint32 inoStep) { + byte *in, *out; + + const int bShift = 8;//img->format.bShift; + const int gShift = 16;//img->format.gShift; + const int rShift = 24;//img->format.rShift; + const int aShift = 0;//img->format.aShift; + + const int bShiftTarget = 8;//target.format.bShift; + const int gShiftTarget = 16;//target.format.gShift; + const int rShiftTarget = 24;//target.format.rShift; + + for (int i = 0; i < height; i++) { + out = outo; + in = ino; + for (int j = 0; j < width; j++) { + uint32 pix = *(uint32 *)in; + uint32 o_pix = *(uint32 *) out; + int b = (pix >> bShift) & 0xff; + int g = (pix >> gShift) & 0xff; + int r = (pix >> rShift) & 0xff; + int a = (pix >> aShift) & 0xff; + int o_b, o_g, o_r, o_a; + in += inStep; + + /* if (ca != 255) { + a = a * ca >> 8; + }*/ + + switch (a) { + case 0: // Full transparency + out += 4; + break; + case 255: // Full opacity + o_b = b; + o_g = g; + o_r = r; + o_a = a; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[0] = o_a; + out[1] = o_b; + out[2] = o_g; + out[3] = o_r; + out += 4; + break; + + default: // alpha blending + o_a = 255; + o_b = (o_pix >> bShiftTarget) & 0xff; + o_g = (o_pix >> gShiftTarget) & 0xff; + o_r = (o_pix >> rShiftTarget) & 0xff; + o_b += ((b - o_b) * a) >> 8; + o_g += ((g - o_g) * a) >> 8; + o_r += ((r - o_r) * a) >> 8; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[0] = o_a; + out[1] = o_b; + out[2] = o_g; + out[3] = o_r; + out += 4; + } + } + outo += pitch; + ino += inoStep; + } +} + + Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height) { int ca = (color >> 24) & 0xff; @@ -145,85 +213,97 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p byte *outo = (byte *)target.getBasePtr(posX, posY); byte *in, *out; - int bShift = img->format.bShift; - int gShift = img->format.gShift; - int rShift = img->format.rShift; - int aShift = img->format.aShift; - - int bShiftTarget = target.format.bShift; - int gShiftTarget = target.format.gShift; - int rShiftTarget = target.format.rShift; - - for (int i = 0; i < img->h; i++) { - out = outo; - in = ino; - for (int j = 0; j < img->w; j++) { - uint32 pix = *(uint32 *)in; - uint32 o_pix = *(uint32 *) out; - int b = (pix >> bShift) & 0xff; - int g = (pix >> gShift) & 0xff; - int r = (pix >> rShift) & 0xff; - int a = (pix >> aShift) & 0xff; - int o_b, o_g, o_r, o_a; - in += inStep; - - if (ca != 255) { - a = a * ca >> 8; - } - - switch (a) { - case 0: // Full transparency - out += 4; - break; - case 255: // Full opacity - if (cb != 255) - o_b = (b * cb) >> 8; - else - o_b = b; - - if (cg != 255) - o_g = (g * cg) >> 8; - else - o_g = g; - - if (cr != 255) - o_r = (r * cr) >> 8; - else - o_r = r; - o_a = a; - *(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out += 4; - break; - - default: // alpha blending - o_a = 255; - o_b = (o_pix >> bShiftTarget) & 0xff; - o_g = (o_pix >> gShiftTarget) & 0xff; - o_r = (o_pix >> rShiftTarget) & 0xff; - if (cb == 0) - o_b = 0; - else if (cb != 255) - o_b += ((b - o_b) * a * cb) >> 16; - else - o_b += ((b - o_b) * a) >> 8; - if (cg == 0) - o_g = 0; - else if (cg != 255) - o_g += ((g - o_g) * a * cg) >> 16; - else - o_g += ((g - o_g) * a) >> 8; - if (cr == 0) - o_r = 0; - else if (cr != 255) - o_r += ((r - o_r) * a * cr) >> 16; - else - o_r += ((r - o_r) * a) >> 8; - *(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out += 4; + const int bShift = 8;//img->format.bShift; + const int gShift = 16;//img->format.gShift; + const int rShift = 24;//img->format.rShift; + const int aShift = 0;//img->format.aShift; + + const int bShiftTarget = 8;//target.format.bShift; + const int gShiftTarget = 16;//target.format.gShift; + const int rShiftTarget = 24;//target.format.rShift; + + if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { + doBlit(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } else { + for (int i = 0; i < img->h; i++) { + out = outo; + in = ino; + for (int j = 0; j < img->w; j++) { + uint32 pix = *(uint32 *)in; + uint32 o_pix = *(uint32 *) out; + int b = (pix >> bShift) & 0xff; + int g = (pix >> gShift) & 0xff; + int r = (pix >> rShift) & 0xff; + int a = (pix >> aShift) & 0xff; + int o_b, o_g, o_r, o_a; + in += inStep; + + if (ca != 255) { + a = a * ca >> 8; + } + + switch (a) { + case 0: // Full transparency + out += 4; + break; + case 255: // Full opacity + if (cb != 255) + o_b = (b * cb) >> 8; + else + o_b = b; + + if (cg != 255) + o_g = (g * cg) >> 8; + else + o_g = g; + + if (cr != 255) + o_r = (r * cr) >> 8; + else + o_r = r; + o_a = a; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[0] = o_a; + out[1] = o_b; + out[2] = o_g; + out[3] = o_r; + out += 4; + break; + + default: // alpha blending + o_a = 255; + o_b = (o_pix >> bShiftTarget) & 0xff; + o_g = (o_pix >> gShiftTarget) & 0xff; + o_r = (o_pix >> rShiftTarget) & 0xff; + if (cb == 0) + o_b = 0; + else if (cb != 255) + o_b += ((b - o_b) * a * cb) >> 16; + else + o_b += ((b - o_b) * a) >> 8; + if (cg == 0) + o_g = 0; + else if (cg != 255) + o_g += ((g - o_g) * a * cg) >> 16; + else + o_g += ((g - o_g) * a) >> 8; + if (cr == 0) + o_r = 0; + else if (cr != 255) + o_r += ((r - o_r) * a * cr) >> 16; + else + o_r += ((r - o_r) * a) >> 8; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[0] = o_a; + out[1] = o_b; + out[2] = o_g; + out[3] = o_r; + out += 4; + } } + outo += target.pitch; + ino += inoStep; } - outo += target.pitch; - ino += inoStep; } } -- cgit v1.2.3 From 9c55f4e42e02de692792a004367dda215737a33c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 16:59:32 +0200 Subject: WINTERMUTE: Make dirty-rect code do partial screen-updates instead of a single full-rect update. --- engines/wintermute/Base/BRenderSDL.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index c2319d1b7a..08d24b8a26 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -77,6 +77,7 @@ bool RenderTicket::operator==(RenderTicket &t) { (t._dstRect != _dstRect) || (t._mirrorX != _mirrorX) || (t._mirrorY != _mirrorY) || + (t._owner != _owner) || (t._hasAlpha != _hasAlpha)) { return false; } @@ -249,7 +250,9 @@ ERRORCODE CBRenderSDL::flip() { drawTickets(); } if (_needsFlip || _disableDirtyRects) { - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + if (_disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + } // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); delete _dirtyRect; _dirtyRect = NULL; @@ -424,8 +427,6 @@ void CBRenderSDL::addDirtyRect(const Common::Rect &rect) { } void CBRenderSDL::drawTickets() { - if (!_dirtyRect) - return; RenderQueueIterator it = _renderQueue.begin(); // Clean out the old tickets while (it != _renderQueue.end()) { @@ -438,6 +439,8 @@ void CBRenderSDL::drawTickets() { it++; } } + if (!_dirtyRect) + return; // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; @@ -486,6 +489,8 @@ void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *s } src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (!_disableDirtyRects) + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(dstRect->left, dstRect->top), _renderSurface->pitch, dstRect->left, dstRect->top, dstRect->width(), dstRect->height()); if (doDelete) delete clipRect; } -- cgit v1.2.3 From b5de9967edba817f57704dacfe95bbfe935d7be9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 17:06:11 +0200 Subject: WINTERMUTE: Default to 1x Scaler --- engines/wintermute/wintermute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index b6330ff01f..147234eaaf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -92,7 +92,7 @@ bool WinterMuteEngine::hasFeature(EngineFeature f) const { Common::Error WinterMuteEngine::run() { // Initialize graphics using following: Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - initGraphics(800, 600, false, &format); + initGraphics(800, 600, true, &format); if (g_system->getScreenFormat() != format) { error("Wintermute currently REQUIRES 32bpp"); } -- cgit v1.2.3 From 2aa6fa4d58726bd81c28f1fd432b8197965644d3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 22:16:56 +0200 Subject: WINTERMUTE: Fix a few issues with the renderTicket-solution, and enable it by default. --- engines/wintermute/Base/BRenderSDL.cpp | 68 ++++++++++++++++++++++------------ engines/wintermute/Base/BRenderSDL.h | 5 +-- engines/wintermute/wintermute.cpp | 2 +- 3 files changed, 47 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 08d24b8a26..f539b06668 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -42,8 +42,13 @@ namespace WinterMute { RenderTicket::RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _mirrorX(mirrorX), _mirrorY(mirrorY), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -75,10 +80,10 @@ RenderTicket::~RenderTicket() { bool RenderTicket::operator==(RenderTicket &t) { if ((t._srcRect != _srcRect) || (t._dstRect != _dstRect) || - (t._mirrorX != _mirrorX) || - (t._mirrorY != _mirrorY) || + (t._mirror != _mirror) || (t._owner != _owner) || - (t._hasAlpha != _hasAlpha)) { + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { return false; } return true; @@ -101,7 +106,7 @@ CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { setAlphaMod(255); setColorMod(255, 255, 255); _dirtyRect = NULL; - _disableDirtyRects = true; + _disableDirtyRects = false; } ////////////////////////////////////////////////////////////////////////// @@ -321,8 +326,20 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - _renderSurface->fillRect(fillRect, col); - + if (_disableDirtyRects) + _renderSurface->fillRect(fillRect, col); + else { + setAlphaMod(a); + setColorMod(r, g, b); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + _clearColor = col; + } //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); @@ -335,10 +352,16 @@ void CBRenderSDL::drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL); + drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + return; + } + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; } + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { @@ -387,10 +410,10 @@ void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { _renderQueue.insert(pos, renderTicket); Common::List::iterator it; renderTicket->_drawNum = _drawNum++; - // Increment the following tickets, so they still are in line for (it = pos; it != _renderQueue.end(); it++) { (*it)->_drawNum++; + (*it)->_wantsDraw = false; } addDirtyRect(renderTicket->_dstRect); } @@ -430,21 +453,22 @@ void CBRenderSDL::drawTickets() { RenderQueueIterator it = _renderQueue.begin(); // Clean out the old tickets while (it != _renderQueue.end()) { - if ((*it)->_wantsDraw == false) { + if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { RenderTicket* ticket = *it; addDirtyRect((*it)->_dstRect); + //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); delete ticket; } else { it++; } } - if (!_dirtyRect) + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) return; // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; -// warning("DirtyRect: %d %d %d %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom); +// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); @@ -457,29 +481,27 @@ void CBRenderSDL::drawTickets() { dstClip.clip(*_dirtyRect); // we need to keep track of the position to redraw the dirty rect Common::Rect pos(dstClip); - int offsetX = ticket->_dstRect.left; - int offsetY = ticket->_dstRect.top; + int16 offsetX = ticket->_dstRect.left; + int16 offsetY = ticket->_dstRect.top; // convert from screen-coords to surface-coords. dstClip.translate(-offsetX, -offsetY); _colorMod = ticket->_colorMod; - drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirrorX, ticket->_mirrorX); - ticket->_wantsDraw = false; + drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); _needsFlip = true; } + // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) + ticket->_wantsDraw = false; } + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + // Revert the colorMod-state. _colorMod = oldColorMod; } // Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, bool mirrorX, bool mirrorY) { +void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { TransparentSurface src(*surf, false); - int mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - mirror |= TransparentSurface::FLIP_H; bool doDelete = false; if (!clipRect) { doDelete = true; @@ -489,8 +511,6 @@ void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *s } src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (!_disableDirtyRects) - g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(dstRect->left, dstRect->top), _renderSurface->pitch, dstRect->left, dstRect->top, dstRect->width(), dstRect->height()); if (doDelete) delete clipRect; } diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 1e7acf51f3..8d23a5bb12 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -44,8 +44,7 @@ public: Graphics::Surface *_surface; Common::Rect _srcRect; Common::Rect _dstRect; - bool _mirrorX; - bool _mirrorY; + uint32 _mirror; bool _hasAlpha; bool _isValid; @@ -103,7 +102,7 @@ public: private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); - void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, bool mirrorX = false, bool mirrorY = false); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); typedef Common::List::iterator RenderQueueIterator; Common::Rect *_dirtyRect; Common::List _renderQueue; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 147234eaaf..9d1f5f731d 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -268,7 +268,7 @@ int WinterMuteEngine::messageLoop() { uint32 time = _system->getMillis(); uint32 diff = 0; - const uint32 maxFPS = 25; + const uint32 maxFPS = 60; const uint32 frameTime = (uint32)((1.0/maxFPS) * 1000); while (!done) { Common::Event event; -- cgit v1.2.3 From 9bc7fa7376074ed6fd251e93f1435e29d74ba2ff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 16 Jul 2012 23:30:40 +0200 Subject: WINTERMUTE: Fix a regression with sprite-mirroring. --- engines/wintermute/graphics/transparentSurface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index e25efecacf..4c646a6779 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -43,7 +43,7 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur } } -void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, uint32 inStep, uint32 inoStep) { +void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; const int bShift = 8;//img->format.bShift; -- cgit v1.2.3 From 67638343817f98b02de2beccb67637b2093a6b7c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 17:19:58 +0200 Subject: WINTERMUTE: Put in the VKEYs necessary to complete the white chamber. --- engines/wintermute/Base/BKeyboardState.cpp | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index f67833eb5e..ba8d807462 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -266,10 +266,39 @@ uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { } } +enum VKeyCodes { + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 +}; + ////////////////////////////////////////////////////////////////////////// Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo - return (Common::KeyCode)vkey; + switch (vkey) { + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + } } // end of namespace WinterMute -- cgit v1.2.3 From e8ad0f3b234c6d06576e802b478c59bad00898c0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 18:42:30 +0200 Subject: WINTERMUTE: Revamp the sound-system, adding WAV-support and following the ScummVM-volume settings. --- engines/wintermute/Ad/AdObject.cpp | 2 +- engines/wintermute/Base/BFrame.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 40 ++++---- engines/wintermute/Base/BObject.cpp | 10 +- engines/wintermute/Base/BRegistry.cpp | 44 ++++++++- engines/wintermute/Base/BSound.cpp | 17 +++- engines/wintermute/Base/BSound.h | 9 +- engines/wintermute/Base/BSoundBuffer.cpp | 86 +++++++++-------- engines/wintermute/Base/BSoundBuffer.h | 16 ++-- engines/wintermute/Base/BSoundMgr.cpp | 135 +++++++++------------------ engines/wintermute/Base/BSoundMgr.h | 16 ++-- engines/wintermute/dctypes.h | 6 -- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- 13 files changed, 200 insertions(+), 187 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 4dd6f4ce4b..2f536cd74a 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -862,7 +862,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // load sound and set duration appropriately if (sound) { CBSound *snd = new CBSound(Game); - if (snd && DID_SUCCEED(snd->setSound(sound, SOUND_SPEECH, true))) { + if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { uint32 Length = snd->getLength(); diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index a0d7d5a1e0..b57d2e41f3 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -251,7 +251,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { _sound = NULL; } _sound = new CBSound(Game); - if (!_sound || DID_FAIL(_sound->setSound(params, SOUND_SFX, false))) { + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); delete _sound; _sound = NULL; @@ -423,7 +423,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (!val->isNULL()) { _sound = new CBSound(Game); - if (!_sound || DID_FAIL(_sound->setSound(val->getString(), SOUND_SFX, false))) { + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { stack->pushBool(false); delete _sound; _sound = NULL; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index cd7dc07925..3a3aad50e6 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1279,7 +1279,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int volume = stack->pop()->getInt(); if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); else { - if (DID_FAIL(_music[channel]->setVolume(volume))) stack->pushBool(false); + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); else stack->pushBool(true); } return STATUS_OK; @@ -1297,7 +1297,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolume()); + else stack->pushInt(_music[channel]->getVolumePercent()); return STATUS_OK; } @@ -1340,7 +1340,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi const char *filename = stack->pop()->getString(); CBSound *sound = new CBSound(Game); - if (sound && DID_SUCCEED(sound->setSound(filename, SOUND_MUSIC, true))) { + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { length = sound->getLength(); delete sound; sound = NULL; @@ -1603,7 +1603,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSFXVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)stack->pop()->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1613,7 +1613,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)stack->pop()->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1623,7 +1623,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMusicVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)stack->pop()->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1643,7 +1643,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalSFXVolume") == 0) { stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(SOUND_SFX)); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); return STATUS_OK; } @@ -1652,7 +1652,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); return STATUS_OK; } @@ -1661,7 +1661,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetGlobalMusicVolume") == 0) { stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); return STATUS_OK; } @@ -2302,7 +2302,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(SOUND_SFX)); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); return _scValue; } @@ -2311,7 +2311,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(SOUND_SPEECH)); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); return _scValue; } @@ -2320,7 +2320,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(SOUND_MUSIC)); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); return _scValue; } @@ -2626,7 +2626,7 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SFX, (byte)value->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -2635,7 +2635,7 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_SPEECH, (byte)value->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -2644,7 +2644,7 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(SOUND_MUSIC, (byte)value->getInt()); + Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -3386,7 +3386,7 @@ ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uin _music[channel] = NULL; _music[channel] = new CBSound(Game); - if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, SOUND_MUSIC, true))) { + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { if (_musicStartTime[channel]) { _music[channel]->setPositionTime(_musicStartTime[channel]); _musicStartTime[channel] = 0; @@ -4083,11 +4083,11 @@ ERRORCODE CBGame::updateMusicCrossfade() { if (currentTime >= _musicCrossfadeLength) { _musicCrossfadeRunning = false; //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->setVolume(100); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); _music[_musicCrossfadeChannel1]->stop(); //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolume(100); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); if (_musicCrossfadeSwap) { @@ -4104,8 +4104,8 @@ ERRORCODE CBGame::updateMusicCrossfade() { } else { //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolume((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - _music[_musicCrossfadeChannel2]->setVolume((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index abced32767..60a9fe7f32 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -423,7 +423,7 @@ ERRORCODE CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(0); if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolume()); + else stack->pushInt(_sFX->getVolumePercent()); return STATUS_OK; } @@ -982,7 +982,7 @@ ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, co // just play loaded sound if (filename == NULL && _sFX) { if (Game->_editorMode || _sFXStart) { - _sFX->setVolume(_sFXVolume); + _sFX->setVolumePercent(_sFXVolume); _sFX->setPositionTime(_sFXStart); if (!Game->_editorMode) _sFXStart = 0; } @@ -999,8 +999,8 @@ ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, co delete _sFX; _sFX = new CBSound(Game); - if (_sFX && DID_SUCCEED(_sFX->setSound(filename, SOUND_SFX, true))) { - _sFX->setVolume(_sFXVolume); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); if (_sFXStart) { _sFX->setPositionTime(_sFXStart); _sFXStart = 0; @@ -1057,7 +1057,7 @@ ERRORCODE CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBObject::setSFXVolume(int volume) { _sFXVolume = volume; - if (_sFX) return _sFX->setVolume(volume); + if (_sFX) return _sFX->setVolumePercent(volume); else return STATUS_OK; } diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index 6d73ac73ac..b8520b07fd 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/utils/utils.h" - +#include "common/config-manager.h" #include "common/file.h" namespace WinterMute { @@ -77,6 +77,33 @@ bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, co ////////////////////////////////////////////////////////////////////////// int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + if (ConfMan.hasKey("master_volume")) { + return ConfMan.getInt("master_volume"); + } else { + return init; + } + } else if (key == "SFXVolume") { + if (ConfMan.hasKey("sfx_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "SpeechVolume") { + if (ConfMan.hasKey("speech_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "MusicVolume") { + if (ConfMan.hasKey("music_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } + } AnsiString val = readString(subKey, key, ""); if (val.empty()) return init; else return atoi(val.c_str()); @@ -85,6 +112,21 @@ int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int ini ////////////////////////////////////////////////////////////////////////// bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + ConfMan.setInt("master_volume", value); + return true; + } else if (key == "SFXVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "SpeechVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "MusicVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } + } writeString(subKey, key, StringUtil::toString(value)); return true; } diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index b4536e7f9e..c5fdb11ade 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/Base/BSoundBuffer.h" namespace WinterMute { @@ -39,7 +40,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { _sound = NULL; _soundFilename = NULL; - _soundType = SOUND_SFX; + _soundType = Audio::Mixer::kSFXSoundType; _soundStreamed = false; _soundLooping = false; _soundPlaying = false; @@ -65,7 +66,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setSound(const char *filename, TSoundType type, bool streamed) { +ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { Game->_soundMgr->removeSound(_sound); _sound = NULL; @@ -212,6 +213,12 @@ uint32 CBSound::getPositionTime() { else return _sound->getPosition(); } +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBSound::setVolumePercent(int percent) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(percent * 255 / 100); +} ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSound::setVolume(int volume) { @@ -227,6 +234,12 @@ ERRORCODE CBSound::setPrivateVolume(int volume) { else return _sound->_privateVolume = volume; } +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolumePercent() { + if (!_sound) + return 0; + else return _sound->_privateVolume * 100 / 255; +} ////////////////////////////////////////////////////////////////////////// int CBSound::getVolume() { diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h index dd08e32b54..3dc9dadf68 100644 --- a/engines/wintermute/Base/BSound.h +++ b/engines/wintermute/Base/BSound.h @@ -31,16 +31,19 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/Base/BSoundBuffer.h" #include "engines/wintermute/persistent.h" +#include "audio/mixer.h" namespace WinterMute { +class CBSoundBuffer; class CBSound : public CBBase { public: ERRORCODE setPan(float pan); int _soundPrivateVolume; int getVolume(); + int getVolumePercent(); + ERRORCODE setVolumePercent(int percent); ERRORCODE setVolume(int volume); ERRORCODE setPrivateVolume(int volume); ERRORCODE setLoopStart(uint32 pos); @@ -61,10 +64,10 @@ public: ERRORCODE play(bool looping = false); uint32 getLength(); bool _soundStreamed; - TSoundType _soundType; + Audio::Mixer::SoundType _soundType; char *_soundFilename; ERRORCODE setSoundSimple(); - ERRORCODE setSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); + ERRORCODE setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); CBSound(CBGame *inGame); virtual ~CBSound(); diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 1bdb0f3adc..2448451784 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -37,7 +37,9 @@ #include "audio/mixer.h" #include "audio/decoders/vorbis.h" #include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" #include "common/system.h" +#include "common/substream.h" namespace WinterMute { @@ -50,18 +52,19 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { _stream = NULL; - _handle = new Audio::SoundHandle; + _handle = NULL; // _sync = NULL; _streamed = false; _filename = NULL; _file = NULL; - _privateVolume = 100; + _privateVolume = 255; + _volume = 255; _looping = false; _loopStart = 0; - _type = SOUND_SFX; + _type = Audio::Mixer::kSFXSoundType; _freezePaused = false; } @@ -72,14 +75,12 @@ CBSoundBuffer::~CBSoundBuffer() { stop(); if (_handle) { + g_system->getMixer()->stopHandle(*_handle); delete _handle; _handle = NULL; } - - if (_file) { - Game->_fileManager->closeFile(_file); - _file = NULL; - } + delete _stream; + _stream = NULL; delete[] _filename; _filename = NULL; @@ -101,8 +102,6 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _stream = NULL; } #endif - // If we already had a file, delete it. - delete _file; // Load a file, but avoid having the File-manager handle the disposal of it. _file = Game->_fileManager->openFile(filename, true, false); @@ -114,8 +113,19 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { if (strFilename.hasSuffix(".ogg")) { _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); } else if (strFilename.hasSuffix(".wav")) { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s", filename); - //_stream = Audio::makeWAVStream(_file, DisposeAfterUse::NO); + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + } + } } else { warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); } @@ -190,22 +200,31 @@ ERRORCODE CBSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; if (looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::YES); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, loopStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); } else { - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); } - } + } + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - not implemented yet", looping); -#if 0 + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); _looping = looping; +#if 0 + if (_stream) { BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); @@ -251,15 +270,20 @@ uint32 CBSoundBuffer::getLength() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(TSoundType type) { +void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { _type = type; } +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundBuffer::setVolume(int volume) { + _volume = volume * Game->_soundMgr->getMasterVolume() / 255; if (_stream && _handle) { - byte vol = (byte)(volume / 100.f * Audio::Mixer::kMaxChannelVolume); + byte vol = (byte)(_volume); g_system->getMixer()->setChannelVolume(*_handle, vol); } return STATUS_OK; @@ -268,22 +292,8 @@ ERRORCODE CBSoundBuffer::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundBuffer::setPrivateVolume(int volume) { -#if 0 - _privateVolume = Volume; - - switch (_type) { - case SOUND_SFX: - volume = Game->_soundMgr->_volumeSFX; - break; - case SOUND_SPEECH: - volume = Game->_soundMgr->_volumeSpeech; - break; - case SOUND_MUSIC: - volume = Game->_soundMgr->_volumeMusic; - break; - } -#endif - return setVolume(volume); + _privateVolume = volume; + return setVolume(_privateVolume); } @@ -348,7 +358,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void #endif ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundBuffer::setPan(float pan) { - if (_stream) { + if (_handle) { g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } return STATUS_OK; @@ -357,7 +367,6 @@ ERRORCODE CBSoundBuffer::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { warning("CBSoundBuffer::ApplyFX - not implemented yet"); -#if 0 switch (type) { case SFX_ECHO: break; @@ -368,7 +377,6 @@ ERRORCODE CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, floa default: break; } -#endif return STATUS_OK; } diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index 22c4fd63da..f65ea1d40f 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -31,6 +31,7 @@ #include "engines/wintermute/Base/BBase.h" +#include "audio/mixer.h" #include "common/stream.h" namespace Audio { @@ -68,8 +69,9 @@ public: ERRORCODE setPan(float pan); ERRORCODE setPrivateVolume(int colume); ERRORCODE setVolume(int colume); + void updateVolume(); - void setType(TSoundType Type); + void setType(Audio::Mixer::SoundType Type); ERRORCODE loadFromFile(const char *filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); @@ -82,19 +84,15 @@ public: bool _freezePaused; uint32 _loopStart; - TSoundType _type; + Audio::Mixer::SoundType _type; bool _looping; Common::SeekableReadStream *_file; char *_filename; bool _streamed; - int _privateVolume; - - /*static void CALLBACK LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user); - static void CALLBACK FileCloseProc(void *user); - static QWORD CALLBACK FileLenProc(void *user); - static uint32 CALLBACK FileReadProc(void *buffer, uint32 length, void *user); - static BOOL CALLBACK FileSeekProc(QWORD offset, void *user);*/ + int _privateVolume; +private: + int _volume; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index b8393bc0f2..6346971c54 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -34,6 +34,9 @@ #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/BSoundBuffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" namespace WinterMute { @@ -46,8 +49,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { _soundAvailable = false; - - _volumeSFX = _volumeSpeech = _volumeMusic = _volumeMaster = 100; + _volumeMaster = 255; } @@ -73,43 +75,18 @@ ERRORCODE CBSoundMgr::cleanup() { void CBSoundMgr::saveSettings() { if (_soundAvailable) { Game->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); - - Game->_registry->writeInt("Audio", "SFXVolume", _volumeSFX); - Game->_registry->writeInt("Audio", "SpeechVolume", _volumeSpeech); - Game->_registry->writeInt("Audio", "MusicVolume", _volumeMusic); } } ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::initialize() { _soundAvailable = false; -#if 0 - -#ifdef __IPHONEOS__ -#define BASS_CONFIG_IOS_MIXAUDIO 34 - BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); -#endif - - - if (HIWORD(BASS_GetVersion()) != BASSVERSION) { - Game->LOG(0, "An incorrect version of BASS was loaded"); + + if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - - if (!BASS_Init(-1, 44100, 0, 0, NULL)) { - Game->LOG(0, "Can't initialize sound device"); - return STATUS_FAILED; - } -#endif - - _volumeMaster = Game->_registry->readInt("Audio", "MasterVolume", 100); - - _volumeSFX = Game->_registry->readInt("Audio", "SFXVolume", 100); - _volumeSpeech = Game->_registry->readInt("Audio", "SpeechVolume", 100); - _volumeMusic = Game->_registry->readInt("Audio", "MusicVolume", 100); - + _volumeMaster = Game->_registry->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; - setMasterVolumePercent(_volumeMaster); return STATUS_OK; } @@ -128,7 +105,7 @@ ERRORCODE CBSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool streamed) { +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) return NULL; @@ -160,18 +137,8 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool return NULL; } - // set volume appropriately - switch (type) { - case SOUND_SFX: - sound->setVolume(_volumeSFX); - break; - case SOUND_SPEECH: - sound->setVolume(_volumeSpeech); - break; - case SOUND_MUSIC: - sound->setVolume(_volumeMusic); - break; - } + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); // register sound _sounds.add(sound); @@ -182,22 +149,12 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, TSoundType type, bool } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, TSoundType type) { +ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { if (!sound) return STATUS_FAILED; - // set volume appropriately - switch (type) { - case SOUND_SFX: - sound->setVolume(_volumeSFX); - break; - case SOUND_SPEECH: - sound->setVolume(_volumeSpeech); - break; - case SOUND_MUSIC: - sound->setVolume(_volumeMusic); - break; - } + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); // register sound _sounds.add(sound); @@ -220,83 +177,81 @@ ERRORCODE CBSoundMgr::removeSound(CBSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setVolume(TSoundType type, int volume) { +ERRORCODE CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { if (!_soundAvailable) return STATUS_OK; switch (type) { - case SOUND_SFX: - _volumeSFX = volume; + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); break; - case SOUND_SPEECH: - _volumeSpeech = volume; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); break; - case SOUND_MUSIC: - _volumeMusic = volume; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); break; } - - for (int i = 0; i < _sounds.getSize(); i++) { - if (_sounds[i]->_type == type) _sounds[i]->setVolume(volume); - } + g_wintermute->syncSoundSettings(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setVolumePercent(TSoundType type, byte percent) { - return setVolume(type, percent); +ERRORCODE CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(TSoundType type) { +byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { int volume = 0; + switch (type) { - case SOUND_SFX: - volume = _volumeSFX; - break; - case SOUND_SPEECH: - volume = _volumeSpeech; - break; - case SOUND_MUSIC: - volume = _volumeMusic; + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); break; default: error("Sound-type not set"); break; } - return (byte)volume; + return (byte)(volume * 100 / 255); } +////////////////////////////////////////////////////////////////////////// +ERRORCODE CBSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (int i = 0; i < _sounds.getSize(); i++) { + _sounds[i]->updateVolume(); + } +} + ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::setMasterVolumePercent(byte percent) { - _volumeMaster = percent; -#if 0 - BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, (uint32)(10000.0f / 100.0f * (float)Percent)); -#endif - return STATUS_OK; + setMasterVolume(percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// byte CBSoundMgr::getMasterVolumePercent() { -#if 0 - uint32 val = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM); - return (float)val / 10000.0f * 100.0f; -#endif - return 0; + return getMasterVolume() * 100 / 255; } +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolume() { + return _volumeMaster; +} ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { for (int i = 0; i < _sounds.getSize(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != SOUND_MUSIC || includingMusic)) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; } diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index 9e8106e973..1ae7b7709a 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -31,6 +31,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" +#include "audio/mixer.h" namespace WinterMute { class CBSoundBuffer; @@ -42,18 +43,17 @@ public: ERRORCODE cleanup(); //DECLARE_PERSISTENT(CBSoundMgr, CBBase); byte getMasterVolumePercent(); + byte getMasterVolume(); + ERRORCODE setMasterVolume(byte percent); ERRORCODE setMasterVolumePercent(byte percent); - byte getVolumePercent(TSoundType type); - ERRORCODE setVolumePercent(TSoundType type, byte percent); - ERRORCODE setVolume(TSoundType type, int volume); + byte getVolumePercent(Audio::Mixer::SoundType type); + ERRORCODE setVolumePercent(Audio::Mixer::SoundType type, byte percent); + ERRORCODE setVolume(Audio::Mixer::SoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; - int _volumeMusic; - int _volumeSpeech; - int _volumeSFX; ERRORCODE removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false); - ERRORCODE addSound(CBSoundBuffer *sound, TSoundType type = SOUND_SFX); + CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + ERRORCODE addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); ERRORCODE initLoop(); ERRORCODE initialize(); bool _soundAvailable; diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index 988f865f21..1dde068013 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -140,12 +140,6 @@ enum TSeek { SEEK_TO_END = SEEK_END }; -enum TSoundType { - SOUND_SFX, - SOUND_MUSIC, - SOUND_SPEECH -}; - enum TVideoMode { VIDEO_WINDOW, VIDEO_FULLSCREEN, diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 99acdc24e4..0250aac5b2 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -351,7 +351,7 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) - _volume = Game->_soundMgr->getVolumePercent(SOUND_SFX); + _volume = Game->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); else _volume = volume; _freezeGame = freezeGame; -- cgit v1.2.3 From 841db8da820d2db3d46f4d4f8f77186c290ce8d5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 18:48:21 +0200 Subject: WINTERMUTE: Remove old unused function from BFileManager --- engines/wintermute/Base/BFileManager.cpp | 132 ------------------------------- engines/wintermute/Base/BFileManager.h | 1 - 2 files changed, 133 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 88dad41e50..a143231abc 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -518,138 +518,6 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s delete package; return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::registerPackage(const char *Path, const char *name, bool SearchSignature) { -// TODO - error("Implement RegisterPackage, this is the old one"); -#if 0 - char Filename[MAX_PATH_LENGTH]; - sprintf(filename, "%s%s", Path, name); - - FILE *f = fopen(filename, "rb"); - if (!f) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename); - return STATUS_OK; - } - - uint32 AbsoluteOffset = 0; - bool BoundToExe = false; - - if (SearchSignature) { - uint32 Offset; - if (!FindPackageSignature(f, &Offset)) { - fclose(f); - return STATUS_OK; - } else { - fseek(f, Offset, SEEK_SET); - AbsoluteOffset = Offset; - BoundToExe = true; - } - } - - TPackageHeader hdr; - fread(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename); - fclose(f); - return STATUS_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", filename); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 DirOffset; - fread(&DirOffset, sizeof(uint32), 1, f); - DirOffset += AbsoluteOffset; - fseek(f, DirOffset, SEEK_SET); - } - - for (int i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(Game); - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = BoundToExe; - - // read package info - byte nameLength; - fread(&nameLength, sizeof(byte), 1, f); - pkg->_name = new char[nameLength]; - fread(pkg->_name, nameLength, 1, f); - fread(&pkg->_cD, sizeof(byte), 1, f); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.add(pkg); - - - // read file entries - uint32 NumFiles; - fread(&NumFiles, sizeof(uint32), 1, f); - - for (int j = 0; j < NumFiles; j++) { - char *name; - uint32 Offset, Length, CompLength, Flags, TimeDate1, TimeDate2; - - fread(&nameLength, sizeof(byte), 1, f); - name = new char[nameLength]; - fread(name, nameLength, 1, f); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - - CBPlatform::strupr(name); - - fread(&Offset, sizeof(uint32), 1, f); - Offset += AbsoluteOffset; - fread(&Length, sizeof(uint32), 1, f); - fread(&CompLength, sizeof(uint32), 1, f); - fread(&Flags, sizeof(uint32), 1, f); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - fread(&TimeDate1, sizeof(uint32), 1, f); - fread(&TimeDate2, sizeof(uint32), 1, f); - } - _filesIter = _files.find(name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(Game); - file->_package = pkg; - file->_offset = Offset; - file->_length = Length; - file->_compressedLength = CompLength; - file->_flags = Flags; - - _files[name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = Offset; - _filesIter->_value->_length = Length; - _filesIter->_value->_compressedLength = CompLength; - _filesIter->_value->_flags = Flags; - } - } - delete [] name; - } - } - - - fclose(f); -#endif - return STATUS_OK; -} ////////////////////////////////////////////////////////////////////////// bool CBFileManager::isValidPackage(const AnsiString &fileName) const { diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 2b54679b29..06c812199c 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -75,7 +75,6 @@ public: Common::HashMap _files; private: - ERRORCODE registerPackage(const char *path, const char *name, bool searchSignature = false); ERRORCODE registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; -- cgit v1.2.3 From ad58ccc7bb8667a0da4c4ef0cae288eda919db24 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 18:52:52 +0200 Subject: WINTERMUTE: Fix a few warnings from the past 2 commits. --- engines/wintermute/Base/BSoundMgr.cpp | 6 +++++- engines/wintermute/Base/BSubFrame.cpp | 2 +- engines/wintermute/Base/BSurface.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 6346971c54..0cc0020e1e 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -191,6 +191,8 @@ ERRORCODE CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { case Audio::Mixer::kMusicSoundType: ConfMan.setInt("music_volume", volume); break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); } g_wintermute->syncSoundSettings(); @@ -228,11 +230,13 @@ ERRORCODE CBSoundMgr::setMasterVolume(byte value) { for (int i = 0; i < _sounds.getSize(); i++) { _sounds[i]->updateVolume(); } + return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundMgr::setMasterVolumePercent(byte percent) { setMasterVolume(percent * 255 / 100); + return STATUS_OK; } @@ -243,7 +247,7 @@ byte CBSoundMgr::getMasterVolumePercent() { ////////////////////////////////////////////////////////////////////////// byte CBSoundMgr::getMasterVolume() { - return _volumeMaster; + return (byte)_volumeMaster; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index aa8ce926dc..19c1bcc5f2 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -253,7 +253,7 @@ ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); - if (_surface && _surface->getFileName() != "") + if (_surface && _surface->getFileNameStr() != "") buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); if (_transparent != 0xFFFF00FF) diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index cb19a23271..fe00348488 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -83,6 +83,7 @@ public: virtual int getHeight() { return _height; } + Common::String getFileNameStr() { return _filename; } const char* getFileName() { return _filename.c_str(); } //void SetWidth(int Width){ _width = Width; } //void SetHeight(int Height){ _height = Height; } -- cgit v1.2.3 From 0e9d92a7aff5e03a3cdea26efc2cb8e01f2c21db Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 22:49:30 +0200 Subject: WINTERMUTE: Atleast stub SXFile to avoid using FORBIDDEN_SYMBOL_EXCEPTIONs. --- engines/wintermute/Base/scriptables/SXFile.cpp | 147 +++++++++++++++---------- engines/wintermute/Base/scriptables/SXFile.h | 6 +- 2 files changed, 95 insertions(+), 58 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index 329c595b5d..caab59a89e 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -26,14 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#define FORBIDDEN_SYMBOL_EXCEPTION_fclose -#define FORBIDDEN_SYMBOL_EXCEPTION_fopen -#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite -#define FORBIDDEN_SYMBOL_EXCEPTION_ftell -#define FORBIDDEN_SYMBOL_EXCEPTION_fseek -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_FILE - #include "engines/wintermute/Sys/SysClassRegistry.h" #include "engines/wintermute/Sys/SysClass.h" #include "engines/wintermute/Base/scriptables/ScStack.h" @@ -46,6 +38,8 @@ #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/scriptables/SXFile.h" +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + namespace WinterMute { IMPLEMENT_PERSISTENT(CSXFile, false) @@ -89,8 +83,9 @@ void CSXFile::close() { Game->_fileManager->closeFile(_readFile); _readFile = NULL; } - if ((FILE *)_writeFile) { - fclose((FILE *)_writeFile); + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; _writeFile = NULL; } _mode = 0; @@ -137,11 +132,11 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } else _textMode = strcmp(name, "OpenAsText") == 0; } else { if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = fopen(_filename, "w+"); - else _writeFile = fopen(_filename, "a+"); + if (_mode == 2) _writeFile = openForWrite(_filename, false); + else _writeFile = openForAppend(_filename, false); } else { - if (_mode == 2) _writeFile = fopen(_filename, "wb+"); - else _writeFile = fopen(_filename, "ab+"); + if (_mode == 2) _writeFile = openForWrite(_filename, true); + else _writeFile = openForAppend(_filename, true); } if (!_writeFile) { @@ -311,11 +306,14 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); return STATUS_OK; } - if (strcmp(name, "WriteLine") == 0) - fprintf((FILE *)_writeFile, "%s\n", line); - else - fprintf((FILE *)_writeFile, "%s", line); - + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); stack->pushBool(true); return STATUS_OK; @@ -349,9 +347,12 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); return STATUS_OK; } - byte val; - if (_readFile->read(&val, sizeof(byte)) == sizeof(byte)) stack->pushInt(val); - else stack->pushNULL(); + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -366,10 +367,12 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); return STATUS_OK; } - short val; - if (_readFile->read(&val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + val); - else stack->pushNULL(); - + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -383,9 +386,12 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); return STATUS_OK; } - int val; - if (_readFile->read(&val, sizeof(int)) == sizeof(int)) stack->pushInt(val); - else stack->pushNULL(); + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -401,8 +407,12 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th return STATUS_OK; } float val; - if (_readFile->read(&val, sizeof(float)) == sizeof(float)) stack->pushFloat(val); - else stack->pushNULL(); + (*(uint32*)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -410,7 +420,8 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// // ReadDouble ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadDouble") == 0) { + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); stack->correctParams(0); if (_textMode || !_readFile) { script->runtimeError("File.%s: File must be open for reading in binary mode.", name); @@ -434,8 +445,8 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); return STATUS_OK; } - uint32 size; - if (_readFile->read(&size, sizeof(uint32)) == sizeof(uint32)) { + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { byte *str = new byte[size + 1]; if (str) { if (_readFile->read(str, size) == size) { @@ -461,7 +472,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + _writeFile->writeByte(val); stack->pushBool(true); return STATUS_OK; @@ -479,7 +490,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + _writeFile->writeByte(val); stack->pushBool(true); return STATUS_OK; @@ -490,14 +501,14 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteShort") == 0) { stack->correctParams(1); - short val = stack->pop()->getInt(); + int16 val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + _writeFile->writeSint16LE(val); stack->pushBool(true); return STATUS_OK; @@ -508,14 +519,14 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { stack->correctParams(1); - int val = stack->pop()->getInt(); + int32 val = stack->pop()->getInt(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + _writeFile->writeSint32LE(val); stack->pushBool(true); return STATUS_OK; @@ -533,7 +544,8 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + uint32 *ptr = (uint32*)&val; + _writeFile->writeUint32LE(*ptr); stack->pushBool(true); return STATUS_OK; @@ -543,6 +555,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // WriteDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); stack->correctParams(1); double val = stack->pop()->getFloat(); @@ -551,7 +564,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushBool(false); return STATUS_OK; } - fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); stack->pushBool(true); return STATUS_OK; @@ -571,8 +584,8 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th } uint32 size = strlen(val); - fwrite(&size, sizeof(size), 1, (FILE *)_writeFile); - fwrite(val, size, 1, (FILE *)_writeFile); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); stack->pushBool(true); @@ -666,15 +679,24 @@ ERRORCODE CSXFile::scSetProperty(const char *name, CScValue *value) { uint32 CSXFile::getPos() { if (_mode == 1 && _readFile) return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE *)_writeFile); - else return 0; + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, TSeek origin) { +bool CSXFile::setPos(uint32 pos, int whence) { if (_mode == 1 && _readFile) - return _readFile->seek(pos, origin); - else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + return _readFile->seek(pos, whence); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } else return false; } @@ -683,11 +705,14 @@ uint32 CSXFile::getLength() { if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { - uint32 CurrentPos = ftell((FILE *)_writeFile); + error("CSXFile - reading length for WriteFile not supported"); + return 0; +/* + uint32 currentPos = ftell((FILE *)_writeFile); fseek((FILE *)_writeFile, 0, SEEK_END); - int Ret = ftell((FILE *)_writeFile); + int ret = ftell((FILE *)_writeFile); fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret; + return Ret;*/ } else return 0; } @@ -722,14 +747,14 @@ ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) { else { if (_textMode) { if (_mode == 2) - _writeFile = fopen(_filename, "w+"); + _writeFile = openForWrite(_filename, false); else - _writeFile = fopen(_filename, "a+"); + _writeFile = openForAppend(_filename, false); } else { if (_mode == 2) - _writeFile = fopen(_filename, "wb+"); + _writeFile = openForWrite(_filename, true); else - _writeFile = fopen(_filename, "ab+"); + _writeFile = openForAppend(_filename, true); } if (_writeFile) close(); @@ -741,4 +766,14 @@ ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) { return STATUS_OK; } +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index 12e0eb74b0..f07e2a56cf 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -48,15 +48,17 @@ public: virtual ~CSXFile(); private: Common::SeekableReadStream *_readFile; - void *_writeFile; + Common::WriteStream *_writeFile; int _mode; // 0..none, 1..read, 2..write, 3..append bool _textMode; void close(); void cleanup(); uint32 getPos(); uint32 getLength(); - bool setPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN); + bool setPos(uint32 Pos, int whence = SEEK_SET); char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); }; } // end of namespace WinterMute -- cgit v1.2.3 From 10c4aa8cecd5fed3acc15cf6c8e7762a6722afc6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 22:56:08 +0200 Subject: WINTERMUTE: Remove SXStore, since it's only usefull on iOS. --- engines/wintermute/Base/BGame.cpp | 23 +- engines/wintermute/Base/BGame.h | 2 - engines/wintermute/Base/scriptables/SXStore.cpp | 518 ------------------------ engines/wintermute/Base/scriptables/SXStore.h | 175 -------- engines/wintermute/persistent.cpp | 2 - 5 files changed, 2 insertions(+), 718 deletions(-) delete mode 100644 engines/wintermute/Base/scriptables/SXStore.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXStore.h (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 3a3aad50e6..4ff0980e84 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -58,7 +58,6 @@ #include "engines/wintermute/Base/scriptables/ScStack.h" #include "engines/wintermute/Base/scriptables/ScScript.h" #include "engines/wintermute/Base/scriptables/SXMath.h" -#include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/video/VidPlayer.h" #include "engines/wintermute/video/VidTheoraPlayer.h" #include "engines/wintermute/wintermute.h" @@ -271,7 +270,6 @@ CBGame::CBGame(): CBObject(this) { _constrainedMemory = false; #endif - _store = NULL; } @@ -354,9 +352,6 @@ ERRORCODE CBGame::cleanup() { _musicStartTime[i] = 0; } - unregisterObject(_store); - _store = NULL; - unregisterObject(_fader); _fader = NULL; @@ -470,11 +465,6 @@ ERRORCODE CBGame::initialize1() { if (_fader == NULL) break; registerObject(_fader); - - _store = new CSXStore(this); - if (_store == NULL) - break; - registerObject(_store); loaded = true; } @@ -482,7 +472,6 @@ ERRORCODE CBGame::initialize1() { return STATUS_OK; } else { delete _mathClass; - delete _store; delete _keyboardState; delete _transMgr; delete _debugMgr; @@ -2556,8 +2545,8 @@ CScValue *CBGame::scGetProperty(const char *name) { // Store (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Store") == 0) { - if (_store) _scValue->setNative(_store, true); - else _scValue->setNULL(); + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); return _scValue; } @@ -2846,8 +2835,6 @@ ERRORCODE CBGame::unregisterObject(CBObject *object) { // is it main object? if (_mainObject == object) _mainObject = NULL; - if (_store) _store->OnObjectDestroyed(object); - // destroy object for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { @@ -3314,7 +3301,6 @@ ERRORCODE CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); _scEngine->refreshScriptBreakpoints(); - if (_store) _store->afterLoad(); return STATUS_OK; } @@ -3663,11 +3649,6 @@ ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot)); persistMgr->transfer(TMEMBER(_cursorHidden)); - if (persistMgr->checkVersion(1, 0, 1)) - persistMgr->transfer(TMEMBER(_store)); - else - _store = NULL; - if (!persistMgr->_saving) _quitting = false; diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index dc1e476134..3bee3d134b 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -56,7 +56,6 @@ class CBRenderer; class CBRegistry; class CBSaveThumbHelper; class CBSurfaceStorage; -class CSXStore; class CSXMath; class CBKeyboardState; class CVidPlayer; @@ -179,7 +178,6 @@ public: CBSoundMgr *_soundMgr; CScEngine *_scEngine; CSXMath *_mathClass; - CSXStore *_store; CBSurfaceStorage *_surfaceStorage; CBFontStorage *_fontStorage; CBGame(); diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp deleted file mode 100644 index 065fac5255..0000000000 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/scriptables/SXStore.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/utils/StringUtil.h" - -#ifdef __IPHONEOS__ -# include "IOS_StoreKit_interface.h" -#endif - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXStore, false) - -CBScriptable *makeSXStore(CBGame *inGame, CScStack *stack) { - return new CSXStore(inGame); -} - -////////////////////////////////////////////////////////////////////////// -CSXStore::CSXStore(CBGame *inGame) : CBObject(inGame) { -#ifdef __IPHONEOS__ - StoreKit_SetExternalData((void *)this); -#endif - - _eventsEnabled = false; - _lastProductRequestOwner = NULL; - _lastPurchaseOwner = NULL; - _lastRestoreOwner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CSXStore::~CSXStore() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::cleanup() { - setEventsEnabled(NULL, false); - - for (int i = 0; i < _validProducts.getSize(); i++) { - delete _validProducts[i]; - } - _validProducts.removeAll(); - - - for (int i = 0; i < _transactions.getSize(); i++) { - delete _transactions[i]; - } - _transactions.removeAll(); - - - _lastProductRequestOwner = _lastPurchaseOwner = _lastRestoreOwner = NULL; -} - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // EnableEvents - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "EnableEvents") == 0) { - stack->correctParams(0); - setEventsEnabled(script, true); - stack->pushBool(getEventsEnabled() == true); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // DisableEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableEvents") == 0) { - stack->correctParams(0); - setEventsEnabled(script, false); - stack->pushBool(getEventsEnabled() == false); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ValidateProducts - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidateProducts") == 0) { - stack->correctParams(1); - const char *prodIdList = stack->pop()->getString(); - _lastProductRequestOwner = script->_owner; - validateProducts(prodIdList); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetValidProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetValidProduct") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - if (index >= 0 && index < _validProducts.getSize()) { - CScValue *prod = stack->getPushValue(); - if (prod) { - prod->setProperty("Id", _validProducts[index]->getId()); - prod->setProperty("Name", _validProducts[index]->getName()); - prod->setProperty("Description", _validProducts[index]->getDesc()); - prod->setProperty("Price", _validProducts[index]->getPrice()); - } - } else - stack->pushNULL(); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetInvalidProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInvalidProduct") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - if (index >= 0 && (uint32)index < _invalidProducts.size()) - stack->pushString(_invalidProducts[(uint32)index].c_str()); - else - stack->pushNULL(); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetTransaction - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetTransaction") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - if (index >= 0 && index < _transactions.getSize()) { - CScValue *trans = stack->getPushValue(); - if (trans) { - trans->setProperty("Id", _transactions[index]->getId()); - trans->setProperty("ProductId", _transactions[index]->getProductId()); - trans->setProperty("State", _transactions[index]->getState()); - } - } else - stack->pushNULL(); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Purchase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Purchase") == 0) { - stack->correctParams(1); - const char *prodId = stack->pop()->getString(); - stack->pushBool(purchase(script, prodId)); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FinishTransaction - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FinishTransaction") == 0) { - stack->correctParams(1); - const char *transId = stack->pop()->getString(); - stack->pushBool(finishTransaction(script, transId)); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RestoreTransactions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RestoreTransactions") == 0) { - stack->correctParams(0); - restoreTransactions(script); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnlockProduct - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnlockProduct") == 0) { - stack->correctParams(1); - const char *prodId = stack->pop()->getString(); - - Game->_registry->writeBool("Purchases", prodId, true); - Game->_registry->saveValues(); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsProductUnlocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsProductUnlocked") == 0) { - stack->correctParams(1); - const char *prodId = stack->pop()->getString(); - - stack->pushBool(Game->_registry->readBool("Purchases", prodId, false)); - - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXStore::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("store"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Available (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Available") == 0) { - _scValue->setBool(isAvailable()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // EventsEnabled (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EventsEnabled") == 0) { - _scValue->setBool(getEventsEnabled()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumValidProducts (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumValidProducts") == 0) { - _scValue->setInt(_validProducts.getSize()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumInvalidProducts (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumInvalidProducts") == 0) { - _scValue->setInt((int)_invalidProducts.size()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumTransactions (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumTransactions") == 0) { - _scValue->setInt(_transactions.getSize()); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXStore::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) - cleanup(); - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_eventsEnabled)); - persistMgr->transfer(TMEMBER(_lastProductRequestOwner)); - persistMgr->transfer(TMEMBER(_lastPurchaseOwner)); - persistMgr->transfer(TMEMBER(_lastRestoreOwner)); - persistMgr->transfer(TMEMBER(_invalidProducts)); - - // persist valid products - int numProducts; - if (persistMgr->_saving) { - numProducts = _validProducts.getSize(); - persistMgr->transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) _validProducts[i]->persist(persistMgr); - } else { - numProducts = _validProducts.getSize(); - persistMgr->transfer(TMEMBER(numProducts)); - for (int i = 0; i < numProducts; i++) { - CBStoreProduct *prod = new CBStoreProduct; - prod->persist(persistMgr); - _validProducts.add(prod); - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXStore::afterLoad() { - if (_eventsEnabled) { - setEventsEnabled(NULL, true); - } -#ifdef __IPHONEOS__ - StoreKit_SetExternalData((void *)this); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::OnObjectDestroyed(CBScriptHolder *obj) { - if (_lastProductRequestOwner == obj) _lastProductRequestOwner = NULL; - if (_lastPurchaseOwner == obj) _lastPurchaseOwner = NULL; - if (_lastRestoreOwner == obj) _lastRestoreOwner = NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::setEventsEnabled(CScScript *script, bool val) { - _eventsEnabled = val; - - if (val) { - if (script) _lastPurchaseOwner = script->_owner; -#ifdef __IPHONEOS__ - StoreKit_EnableEvents(); -#endif - } else { - _lastPurchaseOwner = NULL; -#ifdef __IPHONEOS__ - StoreKit_DisableEvents(); -#endif - } -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::validateProducts(const char *prodIdList) { -#ifdef __IPHONEOS__ - StoreKit_ValidateProducts(prodIdList); -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::isAvailable() { -#ifdef __IPHONEOS__ - return StoreKit_IsStoreAvailable() > 0; -#else - return false; -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::receiveProductsStart() { - for (int i = 0; i < _validProducts.getSize(); i++) { - delete _validProducts[i]; - } - _validProducts.removeAll(); - - _invalidProducts.clear(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::receiveProductsEnd() { - if (_lastProductRequestOwner) _lastProductRequestOwner->applyEvent("ProductsValidated"); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::addValidProduct(const char *id, const char *name, const char *desc, const char *price) { - CBStoreProduct *prod = new CBStoreProduct(id, name, desc, price); - _validProducts.add(prod); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::addInvalidProduct(const char *id) { - _invalidProducts.push_back(id); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::receiveTransactionsStart() { - for (int i = 0; i < _transactions.getSize(); i++) { - delete _transactions[i]; - } - _transactions.removeAll(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::receiveTransactionsEnd() { - if (_lastPurchaseOwner) - _lastPurchaseOwner->applyEvent("TransactionsUpdated"); - else - Game->applyEvent("TransactionsUpdated"); -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::addTransaction(const char *id, const char *productId, const char *state) { - CBStoreTransaction *trans = new CBStoreTransaction(id, productId, state); - _transactions.add(trans); -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::purchase(CScScript *script, const char *productId) { - if (!productId) return false; - -#ifdef __IPHONEOS__ - for (int i = 0; i < _validProducts.getSize(); i++) { - if (strcmp(productId, _validProducts[i]->GetId()) == 0) { - _lastPurchaseOwner = script->_owner; - - StoreKit_Purchase(productId); - return true; - } - } -#endif - script->runtimeError("Store.Purchase() - '%s' is not a valid product id", productId); - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXStore::finishTransaction(CScScript *script, const char *transId) { - if (!transId) return false; -#ifdef __IPHONEOS__ - for (int i = 0; i < _transactions.getSize(); i++) { - if (strcmp(transId, _transactions[i]->GetId()) == 0) { - if (StoreKit_FinishTransaction(transId) > 0) { - SAFE_DELETE(_transactions[i]); - _transactions.removeAt(i); - return true; - } else return false; - } - } -#endif - script->runtimeError("Store.FinishTransaction() - '%s' is not a valid transaction id", transId); - return false; -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::restoreTransactions(CScScript *script) { - _lastRestoreOwner = script->_owner; -#ifdef __IPHONEOS__ - StoreKit_RestoreTransactions(); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CSXStore::onRestoreFinished(bool error) { - if (_lastRestoreOwner) { - if (error) _lastRestoreOwner->applyEvent("TransactionsRestoreFailed"); - else _lastRestoreOwner->applyEvent("TransactionsRestoreFinished"); - } -} - - - -#ifdef __IPHONEOS__ - -////////////////////////////////////////////////////////////////////////// -// StoreKit callbacks (called from ObjC) -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddValidProductCallback(const char *id, const char *name, const char *desc, const char *price, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddValidProduct(id, name, desc, price); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddInvalidProductCallback(const char *id, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddInvalidProduct(id); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveProductsStartCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveProductsStart(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveProductsEndCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveProductsEnd(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_AddTransactionCallback(const char *id, const char *productId, const char *state, void *data) { - CSXStore *store = static_cast(data); - if (store) store->AddTransaction(id, productId, state); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveTransactionsStartCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveTransactionsStart(); -} - -////////////////////////////////////////////////////////////////////////// -void StoreKit_ReceiveTransactionsEndCallback(void *data) { - CSXStore *store = static_cast(data); - if (store) store->ReceiveTransactionsEnd(); -} -////////////////////////////////////////////////////////////////////////// -void StoreKit_RestoreFinishedCallback(void *data, int error) { - CSXStore *store = static_cast(data); - if (store) store->OnRestoreFinished(error > 0); -} - -#endif // __IPHONEOS__ - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXStore.h b/engines/wintermute/Base/scriptables/SXStore.h deleted file mode 100644 index a6268689c6..0000000000 --- a/engines/wintermute/Base/scriptables/SXStore.h +++ /dev/null @@ -1,175 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTORE_H -#define WINTERMUTE_SXSTORE_H -#include "engines/wintermute/Base/BPersistMgr.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CSXStore : public CBObject { -public: - - ////////////////////////////////////////////////////////////////////////// - class CBStoreProduct { - public: - CBStoreProduct() { - _id = _name = _desc = _price = NULL; - } - - CBStoreProduct(const char *id, const char *name, const char *desc, const char *price) { - _id = _name = _desc = _price = NULL; - - CBUtils::setString(&_id, id); - CBUtils::setString(&_name, name); - CBUtils::setString(&_desc, desc); - CBUtils::setString(&_price, price); - } - - ~CBStoreProduct() { - delete [] _id; - delete [] _name; - delete [] _desc; - delete [] _price; - } - - ERRORCODE persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_id)); - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_desc)); - persistMgr->transfer(TMEMBER(_price)); - return STATUS_OK; - } - - const char *getId() { - return _id; - } - const char *getName() { - return _name; - } - const char *getDesc() { - return _desc; - } - const char *getPrice() { - return _price; - } - - private: - char *_id; - char *_name; - char *_desc; - char *_price; - }; - - ////////////////////////////////////////////////////////////////////////// - class CBStoreTransaction { - public: - CBStoreTransaction() { - _id = _productId = _state = NULL; - } - - CBStoreTransaction(const char *id, const char *productId, const char *state) { - _id = _productId = _state = NULL; - - CBUtils::setString(&_id, id); - CBUtils::setString(&_productId, productId); - CBUtils::setString(&_state, state); - } - - ~CBStoreTransaction() { - delete [] _id; - delete [] _productId; - delete [] _state; - } - - const char *getId() { - return _id; - } - const char *getProductId() { - return _productId; - } - const char *getState() { - return _state; - } - - private: - char *_id; - char *_productId; - char *_state; - }; - - - DECLARE_PERSISTENT(CSXStore, CBObject) - CSXStore(CBGame *inGame); - virtual ~CSXStore(); - virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - - void afterLoad(); - void OnObjectDestroyed(CBScriptHolder *obj); - - bool isAvailable(); - void setEventsEnabled(CScScript *script, bool val); - bool getEventsEnabled() const { - return _eventsEnabled; - } - void validateProducts(const char *prodIdList); - - void receiveTransactionsStart(); - void receiveTransactionsEnd(); - void addTransaction(const char *id, const char *productId, const char *state); - - void receiveProductsStart(); - void receiveProductsEnd(); - void addValidProduct(const char *id, const char *name, const char *desc, const char *price); - void addInvalidProduct(const char *id); - - void onRestoreFinished(bool error); - -private: - void cleanup(); - bool purchase(CScScript *script, const char *productId); - bool finishTransaction(CScScript *script, const char *transId); - void restoreTransactions(CScScript *script); - - bool _eventsEnabled; - CBArray _validProducts; - AnsiStringArray _invalidProducts; - CBScriptHolder *_lastProductRequestOwner; - CBScriptHolder *_lastPurchaseOwner; - CBScriptHolder *_lastRestoreOwner; - - CBArray _transactions; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index b753b58d26..5c09022746 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -78,7 +78,6 @@ #include "engines/wintermute/Base/scriptables/SXMath.h" #include "engines/wintermute/Base/scriptables/SXMemBuffer.h" #include "engines/wintermute/Base/scriptables/SxObject.h" -#include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/Base/scriptables/SXString.h" #include "engines/wintermute/UI/UIButton.h" #include "engines/wintermute/UI/UIEdit.h" @@ -152,7 +151,6 @@ void CSysClassRegistry::registerClasses() { REGISTER_CLASS(CSXMath, true) REGISTER_CLASS(CSXMemBuffer, false) REGISTER_CLASS(CSXObject, false) - REGISTER_CLASS(CSXStore, false) REGISTER_CLASS(CSXString, false) REGISTER_CLASS(CUIButton, false) -- cgit v1.2.3 From 642714dc192d9fddd02dd8fa7790a153f6fd1247 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 23:16:04 +0200 Subject: WINTERMUTE: Remove/comment out all ifdef __IPHONE occurences --- engines/wintermute/Base/BFileManager.cpp | 27 ------------------- engines/wintermute/Base/BGame.cpp | 46 +++++--------------------------- engines/wintermute/Base/BRenderSDL.cpp | 10 +++---- engines/wintermute/PlatformSDL.cpp | 6 ++--- engines/wintermute/wintermute.cpp | 4 --- 5 files changed, 15 insertions(+), 78 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index a143231abc..61017a9850 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -300,33 +300,6 @@ ERRORCODE CBFileManager::initPaths() { // package files paths addPath(PATH_PACKAGE, "./"); - /*#ifdef __APPLE__ - // search .app path and Resources dir in the bundle - CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); - const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()); - - #ifdef __IPHONE__ - AddPath(PATH_PACKAGE, pathPtr); - AddPath(PATH_SINGLE, pathPtr); - #else - char bundlePath[MAX_PATH_LENGTH]; - - sprintf(bundlePath, "%s/../", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); - - sprintf(bundlePath, "%s/Contents/Resources/", pathPtr); - AddPath(PATH_PACKAGE, bundlePath); - AddPath(PATH_SINGLE, bundlePath); - - - CFRelease(appUrlRef); - CFRelease(macPath); - #endif - #endif*/ - - pathList = Game->_registry->readString("Resource", "PackagePaths", ""); numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 4ff0980e84..c262c6de91 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -68,10 +68,6 @@ #include "common/system.h" #include "common/file.h" -#ifdef __IPHONEOS__ -# include "ios_utils.h" -#endif - namespace WinterMute { ////////////////////////////////////////////////////////////////////// @@ -262,13 +258,13 @@ CBGame::CBGame(): CBObject(this) { _autoSaveSlot = 999; _cursorHidden = false; -#ifdef __IPHONEOS__ +/*#ifdef __IPHONEOS__ _touchInterface = true; _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else +#else*/ _touchInterface = false; _constrainedMemory = false; -#endif +//#endif } @@ -512,19 +508,6 @@ ERRORCODE CBGame::initialize3() { // renderer is initialized void CBGame::DEBUG_DebugEnable(const char *filename) { _dEBUG_DebugMode = true; -#ifndef __IPHONEOS__ - //if (filename)_dEBUG_LogFile = fopen(filename, "a+"); - //else _dEBUG_LogFile = fopen("./zz_debug.log", "a+"); - - if (!_dEBUG_LogFile) { - AnsiString safeLogFileName = PathUtil::getSafeLogFileName(); - //_dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+"); - } - - //if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n"); - warning("BGame::DEBUG_DebugEnable - No logfile is currently created"); //TODO: Use a dumpfile? -#endif - /* time_t timeNow; time(&timeNow); struct tm *tm = localtime(&timeNow); @@ -2139,9 +2122,9 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { stack->correctParams(0); -#ifdef __IPHONEOS__ +/*#ifdef __IPHONEOS__ IOS_ShowStatusLine(TRUE); -#endif +#endif*/ stack->pushNULL(); return STATUS_OK; @@ -2152,9 +2135,9 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { stack->correctParams(0); -#ifdef __IPHONEOS__ +/*#ifdef __IPHONEOS__ IOS_ShowStatusLine(FALSE); -#endif +#endif*/ stack->pushNULL(); return STATUS_OK; @@ -3839,12 +3822,8 @@ ERRORCODE CBGame::getSaveSlotFilename(int slot, char *buffer) { ////////////////////////////////////////////////////////////////////////// AnsiString CBGame::getDataDir() { AnsiString userDir = PathUtil::getUserDirectory(); -#ifdef __IPHONEOS__ - return userDir; -#else AnsiString baseDir = _registry->getBasePath(); return PathUtil::combine(userDir, baseDir); -#endif } @@ -4453,11 +4432,6 @@ bool CBGame::isDoubleClick(int buttonIndex) { int maxMoveX = 4; int maxMoveY = 4; -#if __IPHONEOS__ - maxMoveX = 16; - maxMoveY = 16; -#endif - Point32 pos; CBPlatform::getCursorPos(&pos); @@ -4494,13 +4468,7 @@ void CBGame::addMem(int bytes) { ////////////////////////////////////////////////////////////////////////// AnsiString CBGame::getDeviceType() const { -#ifdef __IPHONEOS__ - char devType[128]; - IOS_GetDeviceType(devType); - return AnsiString(devType); -#else return "computer"; -#endif } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index f539b06668..8898c97328 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -138,7 +138,7 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { // find suitable resolution -#ifdef __IPHONEOS__ +/*#ifdef __IPHONEOS__ _realWidth = 480; _realHeight = 320; @@ -153,10 +153,10 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { break; } } -#else +#else*/ _realWidth = Game->_registry->readInt("Debug", "ForceResWidth", _width); _realHeight = Game->_registry->readInt("Debug", "ForceResHeight", _height); -#endif +//#endif /* _realWidth = 480; @@ -191,7 +191,7 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { Uint32 flags = SDL_WINDOW_SHOWN; #endif #ifdef __IPHONEOS__ - flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; + //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; #endif //_windowed = Game->_registry->readBool("Video", "Windowed", true); @@ -220,7 +220,7 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { #ifdef __IPHONEOS__ // SDL defaults to OGL ES2, which doesn't work on old devices - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); #else //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); #endif diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 9edd8f2152..0bf3f95e9e 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -133,14 +133,14 @@ void CBPlatform::handleEvent(Common::Event *event) { */ case Common::EVENT_QUIT: case Common::EVENT_RTL: -#ifdef __IPHONEOS__ +/*#ifdef __IPHONEOS__ if (Game) { Game->AutoSaveOnExit(); Game->_quitting = true; } -#else +#else*/ if (Game) Game->onWindowClose(); -#endif +//#endif break; default: diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 9d1f5f731d..3f8472e6d6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -219,10 +219,6 @@ int WinterMuteEngine::init() { _game->initialize3(); -#ifdef __IPHONEOS__ - SDL_AddEventWatch(CBPlatform::SDLEventWatcher, NULL); -#endif - // initialize sound manager (non-fatal if we fail) ret = _game->_soundMgr->initialize(); if (DID_FAIL(ret)) { -- cgit v1.2.3 From 90024a502a8a0c55aa624089a860b70aea2bf4c6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 23:19:12 +0200 Subject: WINTERMUTE: Remove TSeek enum --- engines/wintermute/Base/file/BFile.h | 2 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 10 +++++----- engines/wintermute/Base/file/BSaveThumbFile.h | 2 +- engines/wintermute/dctypes.h | 5 ----- 4 files changed, 7 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index 0a7214f6ba..1ff3c109f8 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -51,7 +51,7 @@ public: virtual uint32 getPos() { return _pos; }; - virtual ERRORCODE seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN) = 0; + virtual ERRORCODE seek(uint32 pos, int whence = SEEK_SET) = 0; virtual ERRORCODE read(void *buffer, uint32 size) = 0; virtual ERRORCODE close() = 0; virtual ERRORCODE open(const Common::String &filename) = 0; diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index a7a844fc9d..266d19b46c 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -120,19 +120,19 @@ ERRORCODE CBSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbFile::seek(uint32 pos, TSeek origin) { +ERRORCODE CBSaveThumbFile::seek(uint32 pos, int whence) { if (!_data) return STATUS_FAILED; uint32 newPos = 0; - switch (origin) { - case SEEK_TO_BEGIN: + switch (whence) { + case SEEK_SET: newPos = pos; break; - case SEEK_TO_END: + case SEEK_END: newPos = _size + pos; break; - case SEEK_TO_CURRENT: + case SEEK_CUR: newPos = _pos + pos; break; } diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 6540438de3..7ec07824f9 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -39,7 +39,7 @@ class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); virtual ~CBSaveThumbFile(); - virtual ERRORCODE seek(uint32 pos, TSeek origin = SEEK_TO_BEGIN); + virtual ERRORCODE seek(uint32 pos, int whence = SEEK_SET); virtual ERRORCODE read(void *buffer, uint32 size); virtual ERRORCODE close(); virtual ERRORCODE open(const Common::String &filename); diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index 1dde068013..4d56ac1459 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -134,11 +134,6 @@ enum TDynamicConstructor { DYNAMIC_CONSTRUCTOR }; -enum TSeek { - SEEK_TO_BEGIN = SEEK_SET, - SEEK_TO_CURRENT = SEEK_CUR, - SEEK_TO_END = SEEK_END -}; enum TVideoMode { VIDEO_WINDOW, -- cgit v1.2.3 From 8d375f054ff07cafb595bbb8ced729589815d65b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 17 Jul 2012 23:40:30 +0200 Subject: WINTERMUTE: Fix a VarName->varName in BFileManager --- engines/wintermute/Base/BFileManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 61017a9850..1e477e9038 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -625,9 +625,9 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena } #endif*/ - Common::SeekableReadStream *File = openFileRaw(filename); - if (File && keepTrackOf) _openFiles.add(File); - return File; + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) _openFiles.add(file); + return file; } -- cgit v1.2.3 From 764b7edee4b05804ef42c5991b450f606afeaaab Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 12:48:37 +0200 Subject: WINTERMUTE: Put some useable data in the BMP-headers used in saves, so the code can double as debug-dumps for graphics. --- engines/wintermute/Base/BImage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 9dd9dbf300..deb0547b3d 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -152,7 +152,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { /* Since we don't care during reads, we don't care during writes: */ /* uint32 fileSize = */ - stream->writeUint32LE(0); + stream->writeUint32LE(54 + _surface->h * _surface->pitch); /* uint16 res1 = */ stream->writeUint16LE(0); /* uint16 res2 = */ @@ -176,7 +176,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { return false; } - /* uint16 planes = */ stream->writeUint16LE(0); + /* uint16 planes = */ stream->writeUint16LE(1); const uint16 bitsPerPixel = 24; stream->writeUint16LE(bitsPerPixel); @@ -184,7 +184,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { stream->writeUint32LE(compression); /* uint32 imageSize = */ - stream->writeUint32LE(0); + stream->writeUint32LE(_surface->h * _surface->pitch); /* uint32 pixelsPerMeterX = */ stream->writeUint32LE(0); /* uint32 pixelsPerMeterY = */ -- cgit v1.2.3 From 9a37c9805fb93ea6ef49b2af28eee80c1d281882 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 13:00:43 +0200 Subject: WINTERMUTE: Decrement the following tickets when removing an unused ticket. --- engines/wintermute/Base/BRenderSDL.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 8898c97328..8a8a55e2ff 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -452,6 +452,7 @@ void CBRenderSDL::addDirtyRect(const Common::Rect &rect) { void CBRenderSDL::drawTickets() { RenderQueueIterator it = _renderQueue.begin(); // Clean out the old tickets + int decrement = 0; while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { RenderTicket* ticket = *it; @@ -459,7 +460,9 @@ void CBRenderSDL::drawTickets() { //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); delete ticket; + decrement++; } else { + (*it)->_drawNum -= decrement; it++; } } -- cgit v1.2.3 From 2cac6deb94186820de6cbabd6ceb058c8fc4e092 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 13:01:17 +0200 Subject: WINTERMUTE: Select PixelFormat for BFonTT depending on if we actually have a TTF, or a fallback. --- engines/wintermute/Base/font/BFontTT.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index bf59007e0e..c87a5b4a5f 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -260,8 +260,10 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - + if (_deletableFont) // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + else // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; -- cgit v1.2.3 From 19720786a02cb555b0c26634a9f693eb927d9d2f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 16:15:31 +0200 Subject: WINTERMUTE: Use proper gameids in detection. --- engines/wintermute/detection.cpp | 112 ++++++++++++++++---------------------- engines/wintermute/wintermute.cpp | 4 +- engines/wintermute/wintermute.h | 4 +- 3 files changed, 51 insertions(+), 69 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index aac6ea9f3a..8b67245291 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -32,106 +32,109 @@ namespace WinterMute { +static const PlainGameDescriptor wintermuteGames[] = { + {"5ld", "Five Lethal Demons"}, + {"5ma", "Five Magical Amulets"}, + {"chivalry", "Chivalry is Not Dead"}, + {"dirtysplit", "Dirty Split"}, + {"julia", "J.U.L.I.A."}, + {"pigeons", "Pigeons in the Park"}, + {"rosemary", "Rosemary"}, + {"twc", "the white chamber"}, + {"wintermute", "Wintermute engine game"}, + {0, 0} +}; + static const ADGameDescription gameDescriptions[] = { { - "wintermute", - "Chivalry is Not Dead", + "chivalry", + "", AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "Dirty Split", + "dirtysplit", + "", AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "Dirty Split", + "dirtysplit", + "", AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), Common::DE_DEU, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "Five Magical Amulets", + "5ma", + "", AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "Rosemary", + "rosemary", + "", AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "J.U.L.I.A.", + "julia", + "", AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "J.U.L.I.A. Demo", + "julia", + "Demo", AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE | ADGF_DEMO, GUIO0() }, { - "wintermute", - "Five Lethal Demons", + "5ld", + "", AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "Pigeons in the Park", + "pigeons", + "", AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, { - "wintermute", - "the white chamber", + "twc", + "", AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), Common::EN_ANY, Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_USEEXTRAASTITLE, + ADGF_UNSTABLE, GUIO0() }, AD_TABLE_END_MARKER @@ -139,14 +142,10 @@ static const ADGameDescription gameDescriptions[] = { } -static const PlainGameDescriptor wintermuteGames[] = { - { "wintermute", "Wintermute - Unspecified game" }, - { 0, 0 } -}; - class WinterMuteMetaEngine : public AdvancedMetaEngine { public: - WinterMuteMetaEngine() : AdvancedMetaEngine(WinterMute::gameDescriptions, sizeof(ADGameDescription), wintermuteGames) { + WinterMuteMetaEngine() : AdvancedMetaEngine(WinterMute::gameDescriptions, sizeof(ADGameDescription), WinterMute::wintermuteGames) { + _singleid = "wintermute"; } virtual const char *getName() const { return "Wintermute"; @@ -198,27 +197,8 @@ public: assert(syst); assert(engine); - // Scan the target directory for files (error out if it does not exist) - Common::FSList fslist; - Common::FSNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FSNode::kListAll)) { - return Common::kNoGameDataFoundError; - } - - // Invoke the detector - Common::String gameid = ConfMan.get("gameid"); - GameList detectedGames = detectGames(fslist); - - for (uint i = 0; i < detectedGames.size(); i++) { - if (detectedGames[i].gameid() == gameid) { - // At this point you may want to perform additional sanity checks. - *engine = new WinterMute::WinterMuteEngine(syst); - return true; - } - } - - // Failed to find any game data - return false; + *engine = new WinterMute::WinterMuteEngine(syst, desc); + return true; } bool hasFeature(MetaEngineFeature f) const { diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 3f8472e6d6..ceea7128cf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -43,8 +43,8 @@ namespace WinterMute { WinterMuteEngine *g_wintermute; -WinterMuteEngine::WinterMuteEngine(OSystem *syst) - : Engine(syst) { +WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) + : Engine(syst), _gameDescription(desc) { // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you // need to do such things, do them from init(). diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 0b607301d1..bfa4c73125 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -25,6 +25,7 @@ #include "common/random.h" #include "engines/engine.h" +#include "engines/advancedDetector.h" #include "gui/debugger.h" namespace WinterMute { @@ -42,7 +43,7 @@ enum { class WinterMuteEngine : public Engine { public: - WinterMuteEngine(OSystem *syst); + WinterMuteEngine(OSystem *syst, const ADGameDescription *desc); ~WinterMuteEngine(); virtual Common::Error run(); @@ -59,6 +60,7 @@ private: CSysClassRegistry *_classReg; // We need random numbers Common::RandomSource *_rnd; + const ADGameDescription *_gameDescription; }; // Example console class -- cgit v1.2.3 From 701def717fcdea5e4b1e5b00928b54a1153b5f41 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 16:28:16 +0200 Subject: WINTERMUTE: Add detection for Actual Destination, Mirage and Ghost in the Sheet-demo --- engines/wintermute/detection.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 8b67245291..5748da955e 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -35,9 +35,12 @@ namespace WinterMute { static const PlainGameDescriptor wintermuteGames[] = { {"5ld", "Five Lethal Demons"}, {"5ma", "Five Magical Amulets"}, + {"actualdest", "Actual Destination"}, {"chivalry", "Chivalry is Not Dead"}, {"dirtysplit", "Dirty Split"}, + {"ghostsheet", "Ghost in the Sheet"}, {"julia", "J.U.L.I.A."}, + {"mirage", "Mirage"}, {"pigeons", "Pigeons in the Park"}, {"rosemary", "Rosemary"}, {"twc", "the white chamber"}, @@ -46,6 +49,15 @@ static const PlainGameDescriptor wintermuteGames[] = { }; static const ADGameDescription gameDescriptions[] = { + { + "actualdest", + "", + AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "chivalry", "", @@ -82,6 +94,25 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "ghostsheet", + "Demo", + AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + { + "mirage", + "", + AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "rosemary", "", -- cgit v1.2.3 From 6d43745e360c456ffa0e3217822e7c5191bb7eeb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 16:31:02 +0200 Subject: WINTERMUTE: Alphabetize detection-tables. --- engines/wintermute/detection.cpp | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 5748da955e..246ca4be64 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -49,6 +49,24 @@ static const PlainGameDescriptor wintermuteGames[] = { }; static const ADGameDescription gameDescriptions[] = { + { + "5ld", + "", + AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + { + "5ma", + "", + AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "actualdest", "", @@ -85,15 +103,6 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, - { - "5ma", - "", - AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, { "ghostsheet", "Demo", @@ -104,24 +113,6 @@ static const ADGameDescription gameDescriptions[] = { ADGF_DEMO, GUIO0() }, - { - "mirage", - "", - AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "rosemary", - "", - AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, { "julia", "", @@ -142,9 +133,9 @@ static const ADGameDescription gameDescriptions[] = { GUIO0() }, { - "5ld", + "mirage", "", - AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), + AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, @@ -159,6 +150,15 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "rosemary", + "", + AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "twc", "", -- cgit v1.2.3 From bcb32c4e1f9243f18825756bc96a0f1d47b703ac Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 16:42:52 +0200 Subject: WINTERMUTE: Make Image-decoder-selection case-insensitive --- engines/wintermute/Base/BImage.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index deb0547b3d..337a157536 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -71,21 +71,21 @@ CBImage::~CBImage() { ERRORCODE CBImage::loadFile(const Common::String &filename) { _filename = filename; - + _filename.toLowercase(); if (StringUtil::startsWith(filename, "savegame:", true)) { _decoder = new Graphics::BitmapDecoder(); - } else if (filename.hasSuffix(".png")) { + } else if (_filename.hasSuffix(".png")) { _decoder = new Graphics::PNGDecoder(); - } else if (filename.hasSuffix(".bmp")) { + } else if (_filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); - } else if (filename.hasSuffix(".tga")) { + } else if (_filename.hasSuffix(".tga")) { _decoder = new WinterMute::TGA(); - } else if (filename.hasSuffix(".jpg")) { + } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); } - + _filename = filename; Common::SeekableReadStream *file = Game->_fileManager->openFile(filename.c_str()); if (!file) return STATUS_FAILED; -- cgit v1.2.3 From 1973d745afa320fac5f8c0772faa3c67c15d0dbb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 16:43:11 +0200 Subject: WINTERMUTE: Add detection for Hamlet or the last game without MMORPS features, shaders and product placement --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 246ca4be64..b91f57f0c8 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -39,6 +39,7 @@ static const PlainGameDescriptor wintermuteGames[] = { {"chivalry", "Chivalry is Not Dead"}, {"dirtysplit", "Dirty Split"}, {"ghostsheet", "Ghost in the Sheet"}, + {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, {"julia", "J.U.L.I.A."}, {"mirage", "Mirage"}, {"pigeons", "Pigeons in the Park"}, @@ -113,6 +114,15 @@ static const ADGameDescription gameDescriptions[] = { ADGF_DEMO, GUIO0() }, + { + "hamlet", + "", + AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "julia", "", -- cgit v1.2.3 From 33994420c10251e26a864963fd7314145d25b4e3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 17:00:22 +0200 Subject: WINTERMUTE: Add detection for The Box --- engines/wintermute/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index b91f57f0c8..5a6b696d0d 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -44,6 +44,7 @@ static const PlainGameDescriptor wintermuteGames[] = { {"mirage", "Mirage"}, {"pigeons", "Pigeons in the Park"}, {"rosemary", "Rosemary"}, + {"thebox", "The Box"}, {"twc", "the white chamber"}, {"wintermute", "Wintermute engine game"}, {0, 0} @@ -169,6 +170,15 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "thebox", + "", + AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "twc", "", -- cgit v1.2.3 From 88e2285149650f5c0e485bcd14e5c7994b47fcc6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 17:00:39 +0200 Subject: WINTERMUTE: Disable dirty rects for now. --- engines/wintermute/Base/BRenderSDL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 8a8a55e2ff..5d7c16849c 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -106,7 +106,7 @@ CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { setAlphaMod(255); setColorMod(255, 255, 255); _dirtyRect = NULL; - _disableDirtyRects = false; + _disableDirtyRects = true; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 23c9bff22637c5bb1e3c3caf93adab7088a2e711 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 17:57:05 +0200 Subject: WINTERMUTE: Add detection for Reversion, Dead City and East Side Story (demo) --- engines/wintermute/detection.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 5a6b696d0d..ef28fedd2b 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -37,12 +37,15 @@ static const PlainGameDescriptor wintermuteGames[] = { {"5ma", "Five Magical Amulets"}, {"actualdest", "Actual Destination"}, {"chivalry", "Chivalry is Not Dead"}, + {"deadcity", "Dead City"}, {"dirtysplit", "Dirty Split"}, + {"eastside", "East Side Story"}, {"ghostsheet", "Ghost in the Sheet"}, {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, {"julia", "J.U.L.I.A."}, {"mirage", "Mirage"}, {"pigeons", "Pigeons in the Park"}, + {"reversion", "Reversion"}, {"rosemary", "Rosemary"}, {"thebox", "The Box"}, {"twc", "the white chamber"}, @@ -87,6 +90,15 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "deadcity", + "", + AD_ENTRY1s("data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "dirtysplit", "", @@ -105,6 +117,16 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "eastside", + "Demo", + AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, { "ghostsheet", "Demo", @@ -161,6 +183,15 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, + { + "reversion", + "", + AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, { "rosemary", "", -- cgit v1.2.3 From 301af17d4c8b7746fde6592dce558d968753c3f0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 18:25:09 +0200 Subject: WINTERMUTE: Rename the Game-variable to _gameRef/gameRef --- engines/wintermute/Ad/AdActor.cpp | 80 ++++----- engines/wintermute/Ad/AdEntity.cpp | 80 ++++----- engines/wintermute/Ad/AdGame.cpp | 94 +++++----- engines/wintermute/Ad/AdInventory.cpp | 6 +- engines/wintermute/Ad/AdInventoryBox.cpp | 34 ++-- engines/wintermute/Ad/AdItem.cpp | 54 +++--- engines/wintermute/Ad/AdLayer.cpp | 34 ++-- engines/wintermute/Ad/AdNodeState.cpp | 6 +- engines/wintermute/Ad/AdObject.cpp | 112 ++++++------ engines/wintermute/Ad/AdPath.cpp | 2 +- engines/wintermute/Ad/AdRegion.cpp | 12 +- engines/wintermute/Ad/AdResponse.cpp | 20 +-- engines/wintermute/Ad/AdResponseBox.cpp | 58 +++--- engines/wintermute/Ad/AdResponseContext.cpp | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 12 +- engines/wintermute/Ad/AdScaleLevel.cpp | 12 +- engines/wintermute/Ad/AdScene.cpp | 200 ++++++++++----------- engines/wintermute/Ad/AdSceneNode.cpp | 8 +- engines/wintermute/Ad/AdSceneState.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 26 +-- engines/wintermute/Ad/AdSpriteSet.cpp | 30 ++-- engines/wintermute/Ad/AdTalkDef.cpp | 26 +-- engines/wintermute/Ad/AdTalkHolder.cpp | 10 +- engines/wintermute/Ad/AdTalkNode.cpp | 20 +-- engines/wintermute/Ad/AdWaypointGroup.cpp | 12 +- engines/wintermute/Base/BActiveRect.cpp | 4 +- engines/wintermute/Base/BBase.cpp | 16 +- engines/wintermute/Base/BBase.h | 2 +- engines/wintermute/Base/BDynBuffer.cpp | 6 +- engines/wintermute/Base/BFader.cpp | 8 +- engines/wintermute/Base/BFileManager.cpp | 44 ++--- engines/wintermute/Base/BFrame.cpp | 26 +-- engines/wintermute/Base/BGame.cpp | 196 ++++++++++---------- engines/wintermute/Base/BImage.cpp | 4 +- engines/wintermute/Base/BObject.cpp | 22 +-- engines/wintermute/Base/BPackage.cpp | 6 +- engines/wintermute/Base/BParser.cpp | 2 +- engines/wintermute/Base/BPersistMgr.cpp | 44 ++--- engines/wintermute/Base/BQuickMsg.cpp | 2 +- engines/wintermute/Base/BRegion.cpp | 12 +- engines/wintermute/Base/BRegistry.cpp | 4 +- engines/wintermute/Base/BRenderSDL.cpp | 22 +-- engines/wintermute/Base/BSaveThumbHelper.cpp | 18 +- engines/wintermute/Base/BScriptHolder.cpp | 28 +-- engines/wintermute/Base/BScriptable.cpp | 10 +- engines/wintermute/Base/BSound.cpp | 10 +- engines/wintermute/Base/BSoundBuffer.cpp | 18 +- engines/wintermute/Base/BSoundMgr.cpp | 12 +- engines/wintermute/Base/BSprite.cpp | 48 ++--- engines/wintermute/Base/BStringTable.cpp | 26 +-- engines/wintermute/Base/BSubFrame.cpp | 24 +-- engines/wintermute/Base/BSurface.cpp | 4 +- engines/wintermute/Base/BSurfaceSDL.cpp | 24 +-- engines/wintermute/Base/BSurfaceStorage.cpp | 22 +-- engines/wintermute/Base/BTransitionMgr.cpp | 10 +- engines/wintermute/Base/BViewport.cpp | 6 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 10 +- engines/wintermute/Base/font/BFont.cpp | 26 +-- engines/wintermute/Base/font/BFontBitmap.cpp | 32 ++-- engines/wintermute/Base/font/BFontStorage.cpp | 8 +- engines/wintermute/Base/font/BFontTT.cpp | 38 ++-- engines/wintermute/Base/particles/PartEmitter.cpp | 22 +-- engines/wintermute/Base/particles/PartParticle.cpp | 2 +- engines/wintermute/Base/scriptables/SXArray.cpp | 4 +- engines/wintermute/Base/scriptables/SXFile.cpp | 6 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 2 +- engines/wintermute/Base/scriptables/SXString.cpp | 36 ++-- engines/wintermute/Base/scriptables/ScEngine.cpp | 78 ++++---- engines/wintermute/Base/scriptables/ScScript.cpp | 92 +++++----- engines/wintermute/Base/scriptables/ScStack.cpp | 24 +-- engines/wintermute/Base/scriptables/ScValue.cpp | 30 ++-- engines/wintermute/PlatformSDL.cpp | 62 +++---- engines/wintermute/PlatformSDL.h | 2 +- engines/wintermute/Sys/SysClass.cpp | 8 +- engines/wintermute/Sys/SysClassRegistry.cpp | 40 ++--- engines/wintermute/UI/UIButton.cpp | 104 +++++------ engines/wintermute/UI/UIEdit.cpp | 62 +++---- engines/wintermute/UI/UIEntity.cpp | 24 +-- engines/wintermute/UI/UIObject.cpp | 18 +- engines/wintermute/UI/UIText.cpp | 30 ++-- engines/wintermute/UI/UITiledImage.cpp | 20 +-- engines/wintermute/UI/UIWindow.cpp | 114 ++++++------ engines/wintermute/video/VidPlayer.cpp | 54 +++--- engines/wintermute/video/VidTheoraPlayer.cpp | 106 +++++------ 84 files changed, 1343 insertions(+), 1343 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 16ea49f6ff..55a8ac8443 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -57,7 +57,7 @@ IMPLEMENT_PERSISTENT(CAdActor, false) ////////////////////////////////////////////////////////////////////////// CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - _path = new CAdPath(Game); + _path = new CAdPath(_gameRef); _type = OBJECT_ACTOR; _dir = DI_LEFT; @@ -124,9 +124,9 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdActor::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -135,7 +135,7 @@ ERRORCODE CAdActor::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ACTOR file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); delete [] buffer; @@ -225,17 +225,17 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { - Game->LOG(0, "'ACTOR' keyword expected."); + _gameRef->LOG(0, "'ACTOR' keyword expected."); return STATUS_FAILED; } buffer = params; } - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CAdSpriteSet *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -290,19 +290,19 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_WALK: delete _walkSprite; _walkSprite = NULL; - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; else _walkSprite = spr; break; case TOKEN_TALK: - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); break; case TOKEN_TALK_SPECIAL: - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); break; @@ -310,7 +310,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_STAND: delete _standSprite; _standSprite = NULL; - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; else _standSprite = spr; break; @@ -318,7 +318,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_LEFT: delete _turnLeftSprite; _turnLeftSprite = NULL; - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnLeftSprite = spr; break; @@ -326,7 +326,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_RIGHT: delete _turnRightSprite; _turnRightSprite = NULL; - spr = new CAdSpriteSet(Game, this); + spr = new CAdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnRightSprite = spr; break; @@ -337,7 +337,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -378,8 +378,8 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentBlockRegion; _blockRegion = NULL; _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(Game); - CBRegion *crgn = new CBRegion(Game); + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; delete _currentBlockRegion; @@ -399,8 +399,8 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentWptGroup; _wptGroup = NULL; _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; delete _currentWptGroup; @@ -432,7 +432,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else _anims.add(Anim); } @@ -440,12 +440,12 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ACTOR definition"); + _gameRef->LOG(0, "Syntax error in ACTOR definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { if (spr) delete spr; - Game->LOG(0, "Error loading ACTOR definition"); + _gameRef->LOG(0, "Error loading ACTOR definition"); return STATUS_FAILED; } @@ -496,7 +496,7 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { _targetPoint->x = x; _targetPoint->y = y; - ((CAdGame *)Game)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); _state = STATE_SEARCHING_PATH; @@ -509,7 +509,7 @@ ERRORCODE CAdActor::display() { uint32 alpha; if (_alphaColor != 0) alpha = _alphaColor; - else alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; float scaleX, scaleY; getScale(&scaleX, &scaleY); @@ -518,14 +518,14 @@ ERRORCODE CAdActor::display() { float rotate; if (_rotatable) { if (_rotateValid) rotate = _rotate; - else rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else rotate = 0.0f; if (_active) displaySpriteAttachments(true); if (_currentSprite && _active) { bool reg = _registrable; - if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) reg = false; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; _currentSprite->display(_posX, _posY, @@ -661,7 +661,7 @@ ERRORCODE CAdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_SEARCHING_PATH: // keep asking scene for the path - if (((CAdGame *)Game)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) _state = STATE_WAITING_PATH; break; @@ -684,7 +684,7 @@ ERRORCODE CAdActor::update() { _sentence->update(_dir); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->finish(); @@ -696,12 +696,12 @@ ERRORCODE CAdActor::update() { if (_tempSprite2) { _tempSprite2->reset(); _currentSprite = _tempSprite2; - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } break; @@ -726,7 +726,7 @@ ERRORCODE CAdActor::update() { if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -734,7 +734,7 @@ ERRORCODE CAdActor::update() { } } - //Game->QuickMessageForm("%s", _currentSprite->_filename); + //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); updateBlockRegion(); _ready = (_state == STATE_READY); @@ -777,7 +777,7 @@ void CAdActor::getNextStep() { if (!_currentSprite) return; - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (!_currentSprite->_changed) return; @@ -796,7 +796,7 @@ void CAdActor::getNextStep() { maxStepX--; } - if (((CAdGame *)Game)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { + if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { if (_pFCount == 0) { _state = _nextState; _nextState = STATE_READY; @@ -898,7 +898,7 @@ ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CScValue *val = stack->pop(); // turn to object? - if (val->isNative() && Game->validObject((CBObject *)val->getNative())) { + if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { CBObject *obj = (CBObject *)val->getNative(); int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); dir = (int)angleToDirection(angle); @@ -1106,11 +1106,11 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; delete _animSprite; - _animSprite = new CBSprite(Game, this); + _animSprite = new CBSprite(_gameRef, this); if (_animSprite) { ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -1268,23 +1268,23 @@ ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_END - byte *fileBuffer = Game->_fileManager->readWholeFile(animsFilename); + byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); if (fileBuffer == NULL) { - Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); + _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); return STATUS_FAILED; } byte *buffer = fileBuffer; byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); ERRORCODE Ret = STATUS_OK; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(Game, this); + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = STATUS_FAILED; diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 3d9c7f5055..ccffe58efe 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -73,7 +73,7 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { ////////////////////////////////////////////////////////////////////////// CAdEntity::~CAdEntity() { - Game->unregisterObject(_region); + _gameRef->unregisterObject(_region); delete _theora; _theora = NULL; @@ -85,9 +85,9 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdEntity::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -96,7 +96,7 @@ ERRORCODE CAdEntity::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); delete [] buffer; @@ -198,17 +198,17 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { - Game->LOG(0, "'ENTITY' keyword expected."); + _gameRef->LOG(0, "'ENTITY' keyword expected."); return STATUS_FAILED; } buffer = params; } - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CBSprite *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -228,21 +228,21 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE: { delete _sprite; _sprite = NULL; - spr = new CBSprite(Game, this); + spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; else _sprite = spr; } break; case TOKEN_TALK: { - spr = new CBSprite(Game, this); + spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { - spr = new CBSprite(Game, this); + spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); } @@ -305,7 +305,7 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -318,13 +318,13 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_REGION: { - if (_region) Game->unregisterObject(_region); + if (_region) _gameRef->unregisterObject(_region); _region = NULL; - CBRegion *rgn = new CBRegion(Game); + CBRegion *rgn = new CBRegion(_gameRef); if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else { _region = rgn; - Game->registerObject(_region); + _gameRef->registerObject(_region); } } break; @@ -334,8 +334,8 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _blockRegion = NULL; delete _currentBlockRegion; _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(Game); - CBRegion *crgn = new CBRegion(Game); + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; _blockRegion = NULL; @@ -355,8 +355,8 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _wptGroup = NULL; delete _currentWptGroup; _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; _wptGroup = NULL; @@ -379,15 +379,15 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { if (scumm_stricmp((char *)params, "sound") == 0) { delete _sprite; _sprite = NULL; - if (Game->_editorMode) { - spr = new CBSprite(Game, this); + if (_gameRef->_editorMode) { + spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; else _sprite = spr; } - if (Game->_editorMode) _editorOnly = true; + if (_gameRef->_editorMode) _editorOnly = true; _zoomable = false; _rotatable = false; - _registrable = Game->_editorMode; + _registrable = _gameRef->_editorMode; _shadowable = false; _subtype = ENTITY_SOUND; } @@ -453,17 +453,17 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ENTITY definition"); + _gameRef->LOG(0, "Syntax error in ENTITY definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ENTITY definition"); + _gameRef->LOG(0, "Error loading ENTITY definition"); if (spr) delete spr; return STATUS_FAILED; } if (_region && _sprite) { - Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); + _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); } updatePosition(); @@ -474,7 +474,7 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = STATE_READY; - if (_item && ((CAdGame *)Game)->isItemTaken(_item)) _active = false; + if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; return STATUS_OK; } @@ -487,7 +487,7 @@ ERRORCODE CAdEntity::display() { uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; float ScaleX, ScaleY; getScale(&ScaleX, &ScaleY); @@ -495,15 +495,15 @@ ERRORCODE CAdEntity::display() { float Rotate; if (_rotatable) { if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; if (_region && (Reg || _editorAlwaysRegister)) { - Game->_renderer->_rectList.add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY)); + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); } displaySpriteAttachments(true); @@ -565,7 +565,7 @@ ERRORCODE CAdEntity::update() { _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->finish(); @@ -577,11 +577,11 @@ ERRORCODE CAdEntity::update() { _tempSprite2->reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } break; @@ -591,7 +591,7 @@ ERRORCODE CAdEntity::update() { if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -603,7 +603,7 @@ ERRORCODE CAdEntity::update() { if (_theora) { int OffsetX, OffsetY; - Game->getOffset(&OffsetX, &OffsetY); + _gameRef->getOffset(&OffsetX, &OffsetY); _theora->_posX = _posX - OffsetX; _theora->_posY = _posY - OffsetY; @@ -648,7 +648,7 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * int startTime = stack->pop()->getInt(); delete _theora; - _theora = new CVidTheoraPlayer(Game); + _theora = new CVidTheoraPlayer(_gameRef); if (_theora && DID_SUCCEED(_theora->initialize(filename))) { if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); @@ -732,8 +732,8 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "CreateRegion") == 0) { stack->correctParams(0); if (!_region) { - _region = new CBRegion(Game); - Game->registerObject(_region); + _region = new CBRegion(_gameRef); + _gameRef->registerObject(_region); } if (_region) stack->pushNative(_region, true); else stack->pushNULL(); @@ -747,7 +747,7 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "DeleteRegion") == 0) { stack->correctParams(0); if (_region) { - Game->unregisterObject(_region); + _gameRef->unregisterObject(_region); _region = NULL; stack->pushBool(true); } else stack->pushBool(false); @@ -1012,7 +1012,7 @@ ERRORCODE CAdEntity::setSprite(const char *filename) { delete _sprite; _sprite = NULL; - CBSprite *spr = new CBSprite(Game, this); + CBSprite *spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { delete _sprite; _sprite = NULL; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 759c212de8..953dd92179 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -70,7 +70,7 @@ CAdGame::CAdGame(): CBGame() { _responseBox = NULL; _inventoryBox = NULL; - _scene = new CAdScene(Game); + _scene = new CAdScene(_gameRef); _scene->setName(""); registerObject(_scene); @@ -142,7 +142,7 @@ ERRORCODE CAdGame::cleanup() { _scene = NULL; // remove items - for (i = 0; i < _items.getSize(); i++) Game->unregisterObject(_items[i]); + for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); _items.removeAll(); @@ -157,12 +157,12 @@ ERRORCODE CAdGame::cleanup() { if (_responseBox) { - Game->unregisterObject(_responseBox); + _gameRef->unregisterObject(_responseBox); _responseBox = NULL; } if (_inventoryBox) { - Game->unregisterObject(_inventoryBox); + _gameRef->unregisterObject(_inventoryBox); _inventoryBox = NULL; } @@ -201,7 +201,7 @@ ERRORCODE CAdGame::initLoop() { delete[] _scheduledScene; _scheduledScene = NULL; - Game->_activeObject = NULL; + _gameRef->_activeObject = NULL; } @@ -245,7 +245,7 @@ ERRORCODE CAdGame::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene == NULL) { - _scene = new CAdScene(Game); + _scene = new CAdScene(_gameRef); registerObject(_scene); } else { _scene->applyEvent("SceneShutdown", true); @@ -280,7 +280,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { _scene->loadState(); } - if (fadeIn) Game->_transMgr->start(TRANSITION_FADE_IN); + if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); return ret; } else return STATUS_FAILED; } @@ -346,7 +346,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); - CAdActor *act = new CAdActor(Game); + CAdActor *act = new CAdActor(_gameRef); if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); @@ -363,7 +363,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); - CAdEntity *ent = new CAdEntity(Game); + CAdEntity *ent = new CAdEntity(_gameRef); if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); @@ -396,7 +396,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *val = stack->pop(); - CAdEntity *ent = new CAdEntity(Game); + CAdEntity *ent = new CAdEntity(_gameRef); addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -410,7 +410,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); CScValue *val = stack->pop(); - CAdItem *item = new CAdItem(Game); + CAdItem *item = new CAdItem(_gameRef); addItem(item); if (!val->isNULL()) item->setName(val->getString()); stack->pushNative(item, true); @@ -471,7 +471,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val4 = stack->pop(); if (_responseBox) { - CAdResponse *res = new CAdResponse(Game); + CAdResponse *res = new CAdResponse(_gameRef); if (res) { res->_iD = id; res->setText(text); @@ -702,8 +702,8 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); const char *filename = stack->pop()->getString(); - Game->unregisterObject(_responseBox); - _responseBox = new CAdResponseBox(Game); + _gameRef->unregisterObject(_responseBox); + _responseBox = new CAdResponseBox(_gameRef); if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { registerObject(_responseBox); stack->pushBool(true); @@ -722,8 +722,8 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1); const char *filename = stack->pop()->getString(); - Game->unregisterObject(_inventoryBox); - _inventoryBox = new CAdInventoryBox(Game); + _gameRef->unregisterObject(_inventoryBox); + _inventoryBox = new CAdInventoryBox(_gameRef); if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { registerObject(_inventoryBox); stack->pushBool(true); @@ -784,7 +784,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (width <= 0) width = _renderer->_width; if (height <= 0) height = _renderer->_height; - if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -1003,7 +1003,7 @@ ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { else { CBObject *Obj = (CBObject *)value->getNative(); if (Obj == this) _inventoryOwner = _invObject; - else if (Game->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; } if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; @@ -1057,7 +1057,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->setNative(new CAdActor(Game)); + this_obj->setNative(new CAdActor(_gameRef)); stack->pushNULL(); } @@ -1068,7 +1068,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->setNative(new CAdEntity(Game)); + this_obj->setNative(new CAdEntity(_gameRef)); stack->pushNULL(); } @@ -1086,7 +1086,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th ERRORCODE CAdGame::showCursor() { if (_cursorHidden) return STATUS_OK; - if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { CBSprite *origLastCursor = _lastCursor; CBGame::showCursor(); @@ -1106,7 +1106,7 @@ ERRORCODE CAdGame::showCursor() { ERRORCODE CAdGame::loadFile(const char *filename) { byte *buffer = _fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1115,7 +1115,7 @@ ERRORCODE CAdGame::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); delete [] buffer; @@ -1156,7 +1156,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { byte *params; byte *params2; int cmd = 1; - CBParser parser(Game); + CBParser parser(_gameRef); bool itemFound = false, itemsFound = false; @@ -1171,7 +1171,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { switch (cmd) { case TOKEN_RESPONSE_BOX: delete _responseBox; - _responseBox = new CAdResponseBox(Game); + _responseBox = new CAdResponseBox(_gameRef); if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) registerObject(_responseBox); else { @@ -1183,7 +1183,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; - _inventoryBox = new CAdInventoryBox(Game); + _inventoryBox = new CAdInventoryBox(_gameRef); if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) registerObject(_inventoryBox); else { @@ -1212,7 +1212,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCENE_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new CBViewport(Game); + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); } break; @@ -1235,16 +1235,16 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in GAME definition"); + _gameRef->LOG(0, "Syntax error in GAME definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading GAME definition"); + _gameRef->LOG(0, "Error loading GAME definition"); return STATUS_FAILED; } if (itemFound && !itemsFound) { - Game->LOG(0, "**Warning** Please put the items definition to a separate file."); + _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file."); } return STATUS_OK; @@ -1374,9 +1374,9 @@ ERRORCODE CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, by ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1385,7 +1385,7 @@ ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { //_filename = new char [strlen(filename)+1]; //strcpy(_filename, filename); - if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", filename); + if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); delete [] buffer; @@ -1402,7 +1402,7 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (!merge) { while (_items.getSize() > 0) deleteItem(_items[0]); @@ -1411,7 +1411,7 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ITEM: { - CAdItem *item = new CAdItem(Game); + CAdItem *item = new CAdItem(_gameRef); if (item && !DID_FAIL(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (merge) { @@ -1430,11 +1430,11 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ITEMS definition"); + _gameRef->LOG(0, "Syntax error in ITEMS definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ITEMS definition"); + _gameRef->LOG(0, "Error loading ITEMS definition"); return STATUS_FAILED; } @@ -1458,7 +1458,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { } if (saving) { - CAdSceneState *ret = new CAdSceneState(Game); + CAdSceneState *ret = new CAdSceneState(_gameRef); ret->setFilename(filenameCor); _sceneStates.add(ret); @@ -1479,12 +1479,12 @@ ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) TOKEN_TABLE_END int cmd = PARSERR_GENERIC; - CBParser parser(Game); + CBParser parser(_gameRef); cmd = parser.getCommand(buffer, commands, params); switch (cmd) { case TOKEN_ENTITY_CONTAINER: { - CUIEntity *ent = new CUIEntity(Game); + CUIEntity *ent = new CUIEntity(_gameRef); if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { delete ent; ent = NULL; @@ -1512,7 +1512,7 @@ ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CSc stack->correctParams(1); CScValue *val = stack->pop(); - CUIEntity *ent = new CUIEntity(Game); + CUIEntity *ent = new CUIEntity(_gameRef); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -1598,7 +1598,7 @@ ERRORCODE CAdGame::clearBranchResponses(char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::addBranchResponse(int ID) { if (branchResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(Game); + CAdResponseContext *r = new CAdResponseContext(_gameRef); r->_iD = ID; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesBranch.add(r); @@ -1621,7 +1621,7 @@ bool CAdGame::branchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::addGameResponse(int ID) { if (gameResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(Game); + CAdResponseContext *r = new CAdResponseContext(_gameRef); r->_iD = ID; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesGame.add(r); @@ -1716,7 +1716,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // display normal windows displayWindows(false); - setActiveObject(Game->_renderer->getObjectAt(p.x, p.y)); + setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); // textual info displaySentences(_state == GAME_FROZEN); @@ -1788,7 +1788,7 @@ CAdItem *CAdGame::getItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::addItem(CAdItem *item) { _items.add(item); - return Game->registerObject(item); + return _gameRef->registerObject(item); } @@ -1951,7 +1951,7 @@ ERRORCODE CAdGame::onMouseLeftDown() { } } - if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject; + if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; _mouseLeftDown = true; CBPlatform::setCapture(/*_renderer->_window*/); @@ -2039,7 +2039,7 @@ ERRORCODE CAdGame::onMouseRightUp() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::displayDebugInfo() { char str[100]; - if (Game->_dEBUG_DebugMode) { + if (_gameRef->_dEBUG_DebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 1c14cb710c..24cf919165 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -52,7 +52,7 @@ CAdInventory::~CAdInventory() { ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { if (name == NULL) return STATUS_FAILED; - CAdItem *item = ((CAdGame *)Game)->getItemByName(name); + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); if (item == NULL) return STATUS_FAILED; int insertIndex = -1; @@ -79,7 +79,7 @@ ERRORCODE CAdInventory::removeItem(const char *name) { for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; _takenItems.removeAt(i); return STATUS_OK; } @@ -96,7 +96,7 @@ ERRORCODE CAdInventory::removeItem(CAdItem *item) { for (int i = 0; i < _takenItems.getSize(); i++) { if (_takenItems[i] == item) { - if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL; + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; _takenItems.removeAt(i); return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 222d91800d..3b38903bbf 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -65,7 +65,7 @@ CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdInventoryBox::~CAdInventoryBox() { - Game->unregisterObject(_window); + _gameRef->unregisterObject(_window); _window = NULL; delete _closeButton; @@ -99,7 +99,7 @@ ERRORCODE CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdInventoryBox::display() { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; if (!_visible) return STATUS_OK; @@ -115,8 +115,8 @@ ERRORCODE CAdInventoryBox::display() { if (_closeButton) { _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = Game->_renderer->_width; - _closeButton->_height = Game->_renderer->_height; + _closeButton->_width = _gameRef->_renderer->_width; + _closeButton->_height = _gameRef->_renderer->_height; _closeButton->display(); } @@ -130,7 +130,7 @@ ERRORCODE CAdInventoryBox::display() { } // display items - if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor; + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; int yyy = rect.top; for (int j = 0; j < itemsY; j++) { int xxx = rect.left; @@ -138,7 +138,7 @@ ERRORCODE CAdInventoryBox::display() { int itemIndex = _scrollOffset + j * itemsX + i; if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; - if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) { + if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { item->update(); item->display(xxx, yyy); } @@ -148,7 +148,7 @@ ERRORCODE CAdInventoryBox::display() { } yyy += (_itemHeight + _spacing); } - if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0; + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; return STATUS_OK; } @@ -156,9 +156,9 @@ ERRORCODE CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdInventoryBox::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -167,7 +167,7 @@ ERRORCODE CAdInventoryBox::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); delete [] buffer; @@ -213,13 +213,13 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); bool always_visible = false; _exclusive = false; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { - Game->LOG(0, "'INVENTORY_BOX' keyword expected."); + _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -241,12 +241,12 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: delete _window; - _window = new CUIWindow(Game); + _window = new CUIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; - } else Game->registerObject(_window); + } else _gameRef->registerObject(_window); break; case TOKEN_AREA: @@ -287,17 +287,17 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in INVENTORY_BOX definition"); + _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading INVENTORY_BOX definition"); + _gameRef->LOG(0, "Error loading INVENTORY_BOX definition"); return STATUS_FAILED; } if (_exclusive) { delete _closeButton; - _closeButton = new CUIButton(Game); + _closeButton = new CUIButton(_gameRef); if (_closeButton) { _closeButton->setName("close"); _closeButton->setListener(this, _closeButton, 0); diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index a728a8d048..1727950191 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -85,9 +85,9 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdItem::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -96,7 +96,7 @@ ERRORCODE CAdItem::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ITEM file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); delete [] buffer; @@ -166,11 +166,11 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { - Game->LOG(0, "'ITEM' keyword expected."); + _gameRef->LOG(0, "'ITEM' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -198,8 +198,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: case TOKEN_SPRITE: delete _sprite; - _sprite = new CBSprite(Game, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { delete _sprite; cmd = PARSERR_GENERIC; } @@ -208,8 +208,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: case TOKEN_SPRITE_HOVER: delete _spriteHover; - _spriteHover = new CBSprite(Game, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + _spriteHover = new CBSprite(_gameRef, this); + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { delete _spriteHover; cmd = PARSERR_GENERIC; } @@ -242,23 +242,23 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TALK: { - CBSprite *spr = new CBSprite(Game, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { - CBSprite *spr = new CBSprite(Game, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); } break; case TOKEN_CURSOR: delete _cursorNormal; - _cursorNormal = new CBSprite(Game); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + _cursorNormal = new CBSprite(_gameRef); + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorNormal; _cursorNormal = NULL; cmd = PARSERR_GENERIC; @@ -267,8 +267,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR_HOVER: delete _cursorHover; - _cursorHover = new CBSprite(Game); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) { + _cursorHover = new CBSprite(_gameRef); + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorHover; _cursorHover = NULL; cmd = PARSERR_GENERIC; @@ -301,11 +301,11 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ITEM definition"); + _gameRef->LOG(0, "Syntax error in ITEM definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ITEM definition"); + _gameRef->LOG(0, "Error loading ITEM definition"); return STATUS_FAILED; } @@ -347,7 +347,7 @@ ERRORCODE CAdItem::update() { ////////////////////////////////////////////////////////////////////////// case STATE_READY: if (!_animSprite) { - if (Game->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; + if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; else _currentSprite = _sprite; } break; @@ -357,7 +357,7 @@ ERRORCODE CAdItem::update() { _sentence->update(); if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime); + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { if (TimeIsUp) { _sentence->finish(); @@ -369,11 +369,11 @@ ERRORCODE CAdItem::update() { _tempSprite2->reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)Game)->addSentence(_sentence); + ((CAdGame *)_gameRef)->addSentence(_sentence); } } default: @@ -412,7 +412,7 @@ ERRORCODE CAdItem::display(int x, int y) { } amountX += _amountOffsetX; - CBFont *font = _font ? _font : Game->_systemFont; + CBFont *font = _font ? _font : _gameRef->_systemFont; if (font) { if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); else { @@ -444,7 +444,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _spriteHover; _spriteHover = NULL; - CBSprite *spr = new CBSprite(Game, this); + CBSprite *spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); @@ -487,7 +487,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _cursorNormal; _cursorNormal = NULL; - CBSprite *spr = new CBSprite(Game); + CBSprite *spr = new CBSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); @@ -530,7 +530,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _cursorHover; _cursorHover = NULL; - CBSprite *spr = new CBSprite(Game); + CBSprite *spr = new CBSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index fd37d21550..b7d8eb3cc2 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -62,9 +62,9 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdLayer::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -73,7 +73,7 @@ ERRORCODE CAdLayer::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing LAYER file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); delete [] buffer; @@ -120,11 +120,11 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { - Game->LOG(0, "'LAYER' keyword expected."); + _gameRef->LOG(0, "'LAYER' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -165,8 +165,8 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_REGION: { - CAdRegion *region = new CAdRegion(Game); - CAdSceneNode *node = new CAdSceneNode(Game); + CAdRegion *region = new CAdRegion(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete region; @@ -181,8 +181,8 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(Game); - CAdSceneNode *node = new CAdSceneNode(Game); + CAdEntity *entity = new CAdEntity(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); if (entity) entity->_zoomable = false; // scene entites default to NOT zoom if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; @@ -215,7 +215,7 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in LAYER definition"); + _gameRef->LOG(0, "Syntax error in LAYER definition"); return STATUS_FAILED; } @@ -269,14 +269,14 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); CScValue *val = stack->pop(); - CAdSceneNode *node = new CAdSceneNode(Game); + CAdSceneNode *node = new CAdSceneNode(_gameRef); if (strcmp(name, "AddRegion") == 0) { - CAdRegion *region = new CAdRegion(Game); + CAdRegion *region = new CAdRegion(_gameRef); if (!val->isNULL()) region->setName(val->getString()); node->setRegion(region); stack->pushNative(region, true); } else { - CAdEntity *entity = new CAdEntity(Game); + CAdEntity *entity = new CAdEntity(_gameRef); if (!val->isNULL()) entity->setName(val->getString()); node->setEntity(entity); stack->pushNative(entity, true); @@ -293,14 +293,14 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int index = stack->pop()->getInt(); CScValue *val = stack->pop(); - CAdSceneNode *node = new CAdSceneNode(Game); + CAdSceneNode *node = new CAdSceneNode(_gameRef); if (strcmp(name, "InsertRegion") == 0) { - CAdRegion *region = new CAdRegion(Game); + CAdRegion *region = new CAdRegion(_gameRef); if (!val->isNULL()) region->setName(val->getString()); node->setRegion(region); stack->pushNative(region, true); } else { - CAdEntity *entity = new CAdEntity(Game); + CAdEntity *entity = new CAdEntity(_gameRef); if (!val->isNULL()) entity->setName(val->getString()); node->setEntity(entity); stack->pushNative(entity, true); @@ -461,7 +461,7 @@ ERRORCODE CAdLayer::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Active") == 0) { bool b = value->getBool(); if (b == false && _main) { - Game->LOG(0, "Warning: cannot deactivate scene's main layer"); + _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); } else _active = b; return STATUS_OK; } diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 7c190285ae..6d96c041a1 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -93,7 +93,7 @@ void CAdNodeState::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdNodeState::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_name)); @@ -115,7 +115,7 @@ void CAdNodeState::setCaption(const char *caption, int caseVal) { _caption[caseVal- 1] = new char[strlen(caption) + 1]; if (_caption[caseVal- 1]) { strcpy(_caption[caseVal- 1], caption); - Game->_stringTable->expand(&_caption[caseVal- 1]); + _gameRef->_stringTable->expand(&_caption[caseVal- 1]); } } @@ -133,7 +133,7 @@ ERRORCODE CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, if (!entity) return STATUS_FAILED; // hack! - if (this->Game != entity->Game) this->Game = entity->Game; + if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; if (saving) { for (int i = 0; i < 7; i++) { diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 2f536cd74a..3321e5871f 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -127,24 +127,24 @@ CAdObject::~CAdObject() { _tempSprite2 = NULL; // reference only _stickRegion = NULL; - if (_font) Game->_fontStorage->removeFont(_font); + if (_font) _gameRef->_fontStorage->removeFont(_font); if (_inventory) { - ((CAdGame *)Game)->unregisterInventory(_inventory); + ((CAdGame *)_gameRef)->unregisterInventory(_inventory); _inventory = NULL; } if (_partEmitter) - Game->unregisterObject(_partEmitter); + _gameRef->unregisterObject(_partEmitter); for (int i = 0; i < _attachmentsPre.getSize(); i++) { - Game->unregisterObject(_attachmentsPre[i]); + _gameRef->unregisterObject(_attachmentsPre[i]); } _attachmentsPre.removeAll(); for (int i = 0; i < _attachmentsPost.getSize(); i++) { - Game->unregisterObject(_attachmentsPost[i]); + _gameRef->unregisterObject(_attachmentsPost[i]); } _attachmentsPost.removeAll(); } @@ -154,14 +154,14 @@ CAdObject::~CAdObject() { ERRORCODE CAdObject::playAnim(const char *filename) { delete _animSprite; _animSprite = NULL; - _animSprite = new CBSprite(Game, this); + _animSprite = new CBSprite(_gameRef, this); if (!_animSprite) { - Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); return STATUS_FAILED; } ERRORCODE res = _animSprite->loadFile(filename); if (DID_FAIL(res)) { - Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); delete _animSprite; _animSprite = NULL; return res; @@ -285,7 +285,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "StickToRegion") == 0) { stack->correctParams(1); - CAdLayer *main = ((CAdGame *)Game)->_scene->_mainLayer; + CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; bool regFound = false; int i; @@ -351,8 +351,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(2); if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->registerInventory(_inventory); + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -363,7 +363,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); else { // hide associated entities - ((CAdGame *)Game)->_scene->handleItemAssociations(itemName, false); + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); } } else script->runtimeError("TakeItem: item name expected"); @@ -379,8 +379,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->registerInventory(_inventory); + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -388,7 +388,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities - ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true); + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); } } else script->runtimeError("DropItem: item name expected"); @@ -403,13 +403,13 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->registerInventory(_inventory); + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); } CScValue *val = stack->pop(); if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)Game)->getItemByName(val->getString()); + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); if (item) stack->pushNative(item, true); else stack->pushNULL(); } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) @@ -427,8 +427,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->registerInventory(_inventory); + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); } CScValue *val = stack->pop(); @@ -470,7 +470,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "DeleteParticleEmitter") == 0) { stack->correctParams(0); if (_partEmitter) { - Game->unregisterObject(_partEmitter); + _gameRef->unregisterObject(_partEmitter); _partEmitter = NULL; } stack->pushNULL(); @@ -489,14 +489,14 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * int offsetY = stack->pop()->getInt(); ERRORCODE res; - CAdEntity *ent = new CAdEntity(Game); + CAdEntity *ent = new CAdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; ent = NULL; script->runtimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { - Game->registerObject(ent); + _gameRef->registerObject(ent); ent->_posX = offsetX; ent->_posY = offsetY; @@ -523,7 +523,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i] == obj) { found = true; - Game->unregisterObject(_attachmentsPre[i]); + _gameRef->unregisterObject(_attachmentsPre[i]); _attachmentsPre.removeAt(i); i--; } @@ -531,7 +531,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (_attachmentsPost[i] == obj) { found = true; - Game->unregisterObject(_attachmentsPost[i]); + _gameRef->unregisterObject(_attachmentsPost[i]); _attachmentsPost.removeAt(i); i--; } @@ -541,7 +541,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { found = true; - Game->unregisterObject(_attachmentsPre[i]); + _gameRef->unregisterObject(_attachmentsPre[i]); _attachmentsPre.removeAt(i); i--; } @@ -549,7 +549,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPost.getSize(); i++) { if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { found = true; - Game->unregisterObject(_attachmentsPost[i]); + _gameRef->unregisterObject(_attachmentsPost[i]); _attachmentsPost.removeAt(i); i--; } @@ -793,9 +793,9 @@ const char *CAdObject::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdObject::SetFont(const char *filename) { - if (_font) Game->_fontStorage->removeFont(_font); + if (_font) _gameRef->_fontStorage->removeFont(_font); if (filename) { - _font = Game->_fontStorage->addFont(filename); + _font = _gameRef->_fontStorage->addFont(filename); return _font == NULL ? STATUS_FAILED : STATUS_OK; } else { _font = NULL; @@ -815,7 +815,7 @@ int CAdObject::getHeight() { } if (_zoomable) { - float zoom = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY); + float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); ret = (int)(ret * zoom / 100); } return ret; @@ -825,7 +825,7 @@ int CAdObject::getHeight() { ////////////////////////////////////////////////////////////////////////// void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { - if (!_sentence) _sentence = new CAdSentence(Game); + if (!_sentence) _sentence = new CAdSentence(_gameRef); if (!_sentence) return; if (_forcedTalkAnimName && _forcedTalkAnimUsed) { @@ -838,21 +838,21 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const _sentence->_sound = NULL; _sentence->setText(text); - Game->_stringTable->expand(&_sentence->_text); + _gameRef->_stringTable->expand(&_sentence->_text); _sentence->setStances(stances); _sentence->_duration = duration; _sentence->_align = Align; - _sentence->_startTime = Game->_timer; + _sentence->_startTime = _gameRef->_timer; _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? Game->_systemFont : _font; + _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; _sentence->_freezable = _freezable; // try to locate speech file automatically bool deleteSound = false; if (!sound) { - char *key = Game->_stringTable->getKey(text); + char *key = _gameRef->_stringTable->getKey(text); if (key) { - sound = ((CAdGame *)Game)->findSpeechFile(key); + sound = ((CAdGame *)_gameRef)->findSpeechFile(key); delete [] key; if (sound) deleteSound = true; @@ -861,7 +861,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // load sound and set duration appropriately if (sound) { - CBSound *snd = new CBSound(Game); + CBSound *snd = new CBSound(_gameRef); if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { @@ -873,7 +873,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // set duration by text length if (_sentence->_duration <= 0) {// TODO: Avoid longs. - _sentence->_duration = MAX((size_t)1000, Game->_subtitlesSpeed * strlen(_sentence->_text)); + _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); } @@ -883,16 +883,16 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const y = _posY; if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)Game)->_scene->getOffsetLeft(); - y -= ((CAdGame *)Game)->_scene->getOffsetTop(); + x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); } if (_subtitlesWidth > 0) width = _subtitlesWidth; else { - if ((x < Game->_renderer->_width / 4 || x > Game->_renderer->_width * 0.75) && !Game->_touchInterface) { - width = MAX(Game->_renderer->_width / 4, MIN(x * 2, (Game->_renderer->_width - x) * 2)); - } else width = Game->_renderer->_width / 2; + if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { + width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); + } else width = _gameRef->_renderer->_width / 2; } height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); @@ -909,8 +909,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const x = x - width / 2; - x = MIN(MAX(0, x), Game->_renderer->_width - width); - y = MIN(MAX(0, y), Game->_renderer->_height - height); + x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); + y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); _sentence->_width = width; @@ -920,8 +920,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)Game)->_scene->getOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)Game)->_scene->getOffsetTop(); + _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); } _sentence->_fixedPos = !_subtitlesModRelative; @@ -946,7 +946,7 @@ ERRORCODE CAdObject::reset() { _state = _nextState = STATE_READY; - Game->_scEngine->resetObject(this); + _gameRef->_scEngine->resetObject(this); return STATUS_OK; } @@ -1037,7 +1037,7 @@ ERRORCODE CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdObject::updateBlockRegion() { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); @@ -1051,8 +1051,8 @@ ERRORCODE CAdObject::updateBlockRegion() { ////////////////////////////////////////////////////////////////////////// CAdInventory *CAdObject::getInventory() { if (!_inventory) { - _inventory = new CAdInventory(Game); - ((CAdGame *)Game)->registerInventory(_inventory); + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); } return _inventory; } @@ -1062,7 +1062,7 @@ CAdInventory *CAdObject::getInventory() { ERRORCODE CAdObject::afterMove() { CAdRegion *newRegions[MAX_NUM_REGIONS]; - ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); + ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (!newRegions[i]) break; bool regFound = false; @@ -1077,7 +1077,7 @@ ERRORCODE CAdObject::afterMove() { } for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (_currentRegions[i] && Game->validObject(_currentRegions[i])) { + if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) { _currentRegions[i]->applyEvent("ActorLeave"); } _currentRegions[i] = newRegions[i]; @@ -1100,7 +1100,7 @@ ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { *scaleX = _scaleX < 0 ? 100 : _scaleX; *scaleY = _scaleY < 0 ? 100 : _scaleY; } else if (_scale >= 0) *scaleX = *scaleY = _scale; - else *scaleX = *scaleY = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; } else { *scaleX = *scaleY = 100; } @@ -1177,9 +1177,9 @@ CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, i _partOffsetY = offsetY; if (!_partEmitter) { - _partEmitter = new CPartEmitter(Game, this); + _partEmitter = new CPartEmitter(_gameRef, this); if (_partEmitter) { - Game->registerObject(_partEmitter); + _gameRef->registerObject(_partEmitter); } } updatePartEmitter(); diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 5ce603609f..0aced4cabc 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -100,7 +100,7 @@ bool CAdPath::setReady(bool ready) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdPath::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currIndex)); _points.persist(persistMgr); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 5ca4a56367..a37386e7b3 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -55,9 +55,9 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdRegion::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -66,7 +66,7 @@ ERRORCODE CAdRegion::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); delete [] buffer; @@ -118,11 +118,11 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - Game->LOG(0, "'REGION' keyword expected."); + _gameRef->LOG(0, "'REGION' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -204,7 +204,7 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in REGION definition"); + _gameRef->LOG(0, "Syntax error in REGION definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 0b0bea2f57..0fd2245282 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -60,7 +60,7 @@ CAdResponse::~CAdResponse() { _icon = NULL; _iconHover = NULL; _iconPressed = NULL; - if (_font) Game->_fontStorage->removeFont(_font); + if (_font) _gameRef->_fontStorage->removeFont(_font); } @@ -74,9 +74,9 @@ void CAdResponse::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponse::setIcon(const char *filename) { delete _icon; - _icon = new CBSprite(Game); + _icon = new CBSprite(_gameRef); if (!_icon || DID_FAIL(_icon->loadFile(filename))) { - Game->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); + _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); delete _icon; _icon = NULL; return STATUS_FAILED; @@ -86,10 +86,10 @@ ERRORCODE CAdResponse::setIcon(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponse::setFont(const char *filename) { - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont(filename); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont(filename); if (!_font) { - Game->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); + _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); return STATUS_FAILED; } return STATUS_OK; @@ -98,9 +98,9 @@ ERRORCODE CAdResponse::setFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponse::setIconHover(const char *filename) { delete _iconHover; - _iconHover = new CBSprite(Game); + _iconHover = new CBSprite(_gameRef); if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { - Game->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); + _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); delete _iconHover; _iconHover = NULL; return STATUS_FAILED; @@ -112,9 +112,9 @@ ERRORCODE CAdResponse::setIconHover(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponse::setIconPressed(const char *filename) { delete _iconPressed; - _iconPressed = new CBSprite(Game); + _iconPressed = new CBSprite(_gameRef); if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { - Game->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); + _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); delete _iconPressed; _iconPressed = NULL; return STATUS_FAILED; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index c055c2f363..ef9d3a32c6 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -54,7 +54,7 @@ CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { _font = _fontHover = NULL; _window = NULL; - _shieldWindow = new CUIWindow(Game); + _shieldWindow = new CUIWindow(_gameRef); _horizontal = false; CBPlatform::setRectEmpty(&_responseArea); @@ -82,8 +82,8 @@ CAdResponseBox::~CAdResponseBox() { delete[] _lastResponseTextOrig; _lastResponseTextOrig = NULL; - if (_font) Game->_fontStorage->removeFont(_font); - if (_fontHover) Game->_fontStorage->removeFont(_fontHover); + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); clearResponses(); clearButtons(); @@ -130,7 +130,7 @@ ERRORCODE CAdResponseBox::createButtons() { _scrollOffset = 0; for (int i = 0; i < _responses.getSize(); i++) { - CUIButton *btn = new CUIButton(Game); + CUIButton *btn = new CUIButton(_gameRef); if (btn) { btn->_parent = _window; btn->_sharedFonts = btn->_sharedImages = true; @@ -143,30 +143,30 @@ ERRORCODE CAdResponseBox::createButtons() { btn->setCaption(_responses[i]->_text); if (_cursor) btn->_cursor = _cursor; - else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor; + else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; } // textual else { btn->setText(_responses[i]->_text); - btn->_font = (_font == NULL) ? Game->_systemFont : _font; - btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover; + btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; + btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; btn->_fontPress = btn->_fontHover; btn->_align = _align; - if (Game->_touchInterface) + if (_gameRef->_touchInterface) btn->_fontHover = btn->_font; if (_responses[i]->_font) btn->_font = _responses[i]->_font; btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) btn->_width = Game->_renderer->_width; + if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; } btn->setName("response"); btn->correctSize(); // make the responses touchable - if (Game->_touchInterface) + if (_gameRef->_touchInterface) btn->_height = MAX(btn->_height, 50); //btn->SetListener(this, btn, _responses[i]->_iD); @@ -175,7 +175,7 @@ ERRORCODE CAdResponseBox::createButtons() { _respButtons.add(btn); if (_responseArea.bottom - _responseArea.top < btn->_height) { - Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); + _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); } } @@ -188,9 +188,9 @@ ERRORCODE CAdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -199,7 +199,7 @@ ERRORCODE CAdResponseBox::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); delete [] buffer; @@ -242,11 +242,11 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { - Game->LOG(0, "'RESPONSE_BOX' keyword expected."); + _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -260,7 +260,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: delete _window; - _window = new CUIWindow(Game); + _window = new CUIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; @@ -269,14 +269,14 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont((char *)params); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->removeFont(_fontHover); - _fontHover = Game->_fontStorage->addFont((char *)params); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); if (!_fontHover) cmd = PARSERR_GENERIC; break; @@ -310,7 +310,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -320,7 +320,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in RESPONSE_BOX definition"); + _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition"); return STATUS_FAILED; } @@ -462,8 +462,8 @@ ERRORCODE CAdResponseBox::display() { // go exclusive if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; _shieldWindow->display(); } @@ -495,8 +495,8 @@ ERRORCODE CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); handleResponse(_responses[param2]); _waitingScript = NULL; - Game->_state = GAME_RUNNING; - ((CAdGame *)Game)->_stateEx = GAME_NORMAL; + _gameRef->_state = GAME_RUNNING; + ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; _ready = true; invalidateButtons(); clearResponses(); @@ -537,7 +537,7 @@ ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseBox::weedResponses() { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; for (int i = 0; i < _responses.getSize(); i++) { switch (_responses[i]->_responseType) { @@ -576,7 +576,7 @@ void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) ERRORCODE CAdResponseBox::handleResponse(CAdResponse *response) { setLastResponseText(response->_text, response->_textOrig); - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; switch (response->_responseType) { case RESPONSE_ONCE: diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 5615777daf..d44eb33403 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -50,7 +50,7 @@ CAdResponseContext::~CAdResponseContext() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdResponseContext::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_iD)); diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 26e4bca48d..aa1727cc3e 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -54,9 +54,9 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdRotLevel::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -65,7 +65,7 @@ ERRORCODE CAdRotLevel::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); delete [] buffer; @@ -93,11 +93,11 @@ ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { - Game->LOG(0, "'ROTATION_LEVEL' keyword expected."); + _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -126,7 +126,7 @@ ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ROTATION_LEVEL definition"); + _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 2cfbbb05e1..c756219382 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -52,9 +52,9 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScaleLevel::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -63,7 +63,7 @@ ERRORCODE CAdScaleLevel::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); delete [] buffer; @@ -91,11 +91,11 @@ ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { - Game->LOG(0, "'SCALE_LEVEL' keyword expected."); + _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -124,7 +124,7 @@ ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SCALE_LEVEL definition"); + _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index b338232c98..f50b854db3 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -74,7 +74,7 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdScene::~CAdScene() { cleanup(); - Game->unregisterObject(_fader); + _gameRef->unregisterObject(_fader); delete _pfTarget; _pfTarget = NULL; } @@ -128,8 +128,8 @@ void CAdScene::setDefaults() { _shieldWindow = NULL; - _fader = new CBFader(Game); - Game->registerObject(_fader); + _fader = new CBFader(_gameRef); + _gameRef->registerObject(_fader); _viewport = NULL; } @@ -146,24 +146,24 @@ void CAdScene::cleanup() { delete _shieldWindow; _shieldWindow = NULL; - Game->unregisterObject(_fader); + _gameRef->unregisterObject(_fader); _fader = NULL; for (i = 0; i < _layers.getSize(); i++) - Game->unregisterObject(_layers[i]); + _gameRef->unregisterObject(_layers[i]); _layers.removeAll(); for (i = 0; i < _waypointGroups.getSize(); i++) - Game->unregisterObject(_waypointGroups[i]); + _gameRef->unregisterObject(_waypointGroups[i]); _waypointGroups.removeAll(); for (i = 0; i < _scaleLevels.getSize(); i++) - Game->unregisterObject(_scaleLevels[i]); + _gameRef->unregisterObject(_scaleLevels[i]); _scaleLevels.removeAll(); for (i = 0; i < _rotLevels.getSize(); i++) - Game->unregisterObject(_rotLevels[i]); + _gameRef->unregisterObject(_rotLevels[i]); _rotLevels.removeAll(); @@ -173,7 +173,7 @@ void CAdScene::cleanup() { _pfPointsNum = 0; for (i = 0; i < _objects.getSize(); i++) - Game->unregisterObject(_objects[i]); + _gameRef->unregisterObject(_objects[i]); _objects.removeAll(); delete _viewport; @@ -245,7 +245,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; for (i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); @@ -295,7 +295,7 @@ float CAdScene::getZoomAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { - if (!Game->_dEBUG_DebugMode) colorCheck = false; + if (!_gameRef->_dEBUG_DebugMode) colorCheck = false; uint32 ret; if (colorCheck) ret = 0xFFFF0000; @@ -325,7 +325,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } } - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; @@ -366,7 +366,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } } - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; @@ -484,14 +484,14 @@ void CAdScene::pathFinderStep() { ERRORCODE CAdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; - uint32 start = Game->_currentTime; + uint32 start = _gameRef->_currentTime; while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { PathFinderStep(); nu_steps++; } - if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); + if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); #else - uint32 start = Game->_currentTime; + uint32 start = _gameRef->_currentTime; while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); #endif @@ -501,9 +501,9 @@ ERRORCODE CAdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -513,7 +513,7 @@ ERRORCODE CAdScene::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SCENE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -610,11 +610,11 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { - Game->LOG(0, "'SCENE' keyword expected."); + _gameRef->LOG(0, "'SCENE' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -639,13 +639,13 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LAYER: { - CAdLayer *layer = new CAdLayer(Game); + CAdLayer *layer = new CAdLayer(_gameRef); if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete layer; layer = NULL; } else { - Game->registerObject(layer); + _gameRef->registerObject(layer); _layers.add(layer); if (layer->_main) { _mainLayer = layer; @@ -657,46 +657,46 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WAYPOINTS: { - CAdWaypointGroup *wpt = new CAdWaypointGroup(Game); + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete wpt; wpt = NULL; } else { - Game->registerObject(wpt); + _gameRef->registerObject(wpt); _waypointGroups.add(wpt); } } break; case TOKEN_SCALE_LEVEL: { - CAdScaleLevel *sl = new CAdScaleLevel(Game); + CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete sl; sl = NULL; } else { - Game->registerObject(sl); + _gameRef->registerObject(sl); _scaleLevels.add(sl); } } break; case TOKEN_ROTATION_LEVEL: { - CAdRotLevel *rl = new CAdRotLevel(Game); + CAdRotLevel *rl = new CAdRotLevel(_gameRef); if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete rl; rl = NULL; } else { - Game->registerObject(rl); + _gameRef->registerObject(rl); _rotLevels.add(rl); } } break; case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(Game); + CAdEntity *entity = new CAdEntity(_gameRef); if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; @@ -709,7 +709,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -820,7 +820,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new CBViewport(Game); + if (!_viewport) _viewport = new CBViewport(_gameRef); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); } @@ -839,11 +839,11 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SCENE definition"); + _gameRef->LOG(0, "Syntax error in SCENE definition"); return STATUS_FAILED; } - if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename); + if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); sortScaleLevels(); @@ -860,17 +860,17 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { if (!_initialized) return STATUS_OK; int j, k; - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; ////////////////////////////////////////////////////////////////////////// // prepare viewport bool PopViewport = false; - if (_viewport && !Game->_editorMode) { - Game->pushViewport(_viewport); + if (_viewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(_viewport); PopViewport = true; - } else if (adGame->_sceneViewport && !Game->_editorMode) { - Game->pushViewport(adGame->_sceneViewport); + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(adGame->_sceneViewport); PopViewport = true; } @@ -879,16 +879,16 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // *** adjust scroll offset if (doUpdate) { /* - if (_autoScroll && Game->_mainObject != NULL) + if (_autoScroll && _gameRef->_mainObject != NULL) { - ScrollToObject(Game->_mainObject); + ScrollToObject(_gameRef->_mainObject); } */ if (_autoScroll) { // adjust horizontal scroll - if (Game->_timer - _lastTimeH >= _scrollTimeH) { - _lastTimeH = Game->_timer; + if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { + _lastTimeH = _gameRef->_timer; if (_offsetLeft < _targetOffsetLeft) { _offsetLeft += _scrollPixelsH; _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); @@ -899,8 +899,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { } // adjust vertical scroll - if (Game->_timer - _lastTimeV >= _scrollTimeV) { - _lastTimeV = Game->_timer; + if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { + _lastTimeV = _gameRef->_timer; if (_offsetTop < _targetOffsetTop) { _offsetTop += _scrollPixelsV; _offsetTop = MIN(_offsetTop, _targetOffsetTop); @@ -931,13 +931,13 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); int origX, origY; - Game->getOffset(&origX, &origY); + _gameRef->getOffset(&origX, &origY); ////////////////////////////////////////////////////////////////////////// // *** display/update everything - Game->_renderer->setup2D(); + _gameRef->_renderer->setup2D(); // for each layer /* int MainOffsetX = 0; */ @@ -948,12 +948,12 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // make layer exclusive if (!doUpdate) { - if (_layers[j]->_closeUp && !Game->_editorMode) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (_layers[j]->_closeUp && !_gameRef->_editorMode) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; _shieldWindow->display(); } } @@ -962,17 +962,17 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { if (_paralaxScrolling) { int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); - Game->setOffset(offsetX, offsetY); + _gameRef->setOffset(offsetX, offsetY); - Game->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - Game->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; - //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX); + //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX); } else { - Game->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); + _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); - Game->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - Game->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; } @@ -981,8 +981,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { CAdSceneNode *node = _layers[j]->_nodes[k]; switch (node->_type) { case OBJECT_ENTITY: - if (node->_entity->_active && (Game->_editorMode || !node->_entity->_editorOnly)) { - Game->_renderer->setup2D(); + if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { + _gameRef->_renderer->setup2D(); if (doUpdate) node->_entity->update(); else node->_entity->display(); @@ -1014,8 +1014,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // restore state - Game->setOffset(origX, origY); - Game->_renderer->setup2D(); + _gameRef->setOffset(origX, origY); + _gameRef->_renderer->setup2D(); // display/update fader if (_fader) { @@ -1023,7 +1023,7 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { else _fader->display(); } - if (PopViewport) Game->popViewport(); + if (PopViewport) _gameRef->popViewport(); return STATUS_OK; } @@ -1036,7 +1036,7 @@ ERRORCODE CAdScene::display() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::updateFreeObjects() { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; bool is3DSet; // *** update all active objects @@ -1057,8 +1057,8 @@ ERRORCODE CAdScene::updateFreeObjects() { } - if (_autoScroll && Game->_mainObject != NULL) { - scrollToObject(Game->_mainObject); + if (_autoScroll && _gameRef->_mainObject != NULL) { + scrollToObject(_gameRef->_mainObject); } @@ -1068,7 +1068,7 @@ ERRORCODE CAdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CBArray objects; CAdObject *obj; @@ -1097,16 +1097,16 @@ ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) if (display3DOnly && !obj->_is3D) continue; - Game->_renderer->setup2D(); + _gameRef->_renderer->setup2D(); - if (Game->_editorMode || !obj->_editorOnly) obj->display(); + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); obj->_drawn = true; } // display design only objects if (!display3DOnly) { - if (Game->_editorMode && region == NULL) { + if (_gameRef->_editorMode && region == NULL) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); @@ -1131,7 +1131,7 @@ int CAdScene::compareObjs(const void *obj1, const void *obj2) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CAdObject *obj; // display all objects in region sorted by _posY @@ -1157,16 +1157,16 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { if (obj != NULL) { - Game->_renderer->setup2D(); + _gameRef->_renderer->setup2D(); - if (Game->_editorMode || !obj->_editorOnly) obj->display(); + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); obj->_drawn = true; } } while (obj != NULL); // design only objects - if (Game->_editorMode && region == NULL) { + if (_gameRef->_editorMode && region == NULL) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); @@ -1199,7 +1199,7 @@ void CAdScene::scrollTo(int offsetX, int offsetY) { _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); - if (Game->_mainObject && Game->_mainObject->_is3D) { + if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; //_targetOffsetTop = 0; @@ -1246,7 +1246,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); - CAdActor *act = new CAdActor(Game); + CAdActor *act = new CAdActor(_gameRef); if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); @@ -1263,7 +1263,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); - CAdEntity *ent = new CAdEntity(Game); + CAdEntity *ent = new CAdEntity(_gameRef); if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); @@ -1282,7 +1282,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); CScValue *val = stack->pop(); - CAdEntity *ent = new CAdEntity(Game); + CAdEntity *ent = new CAdEntity(_gameRef); addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -1567,10 +1567,10 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int width = stack->pop()->getInt(); int height = stack->pop()->getInt(); - if (width <= 0) width = Game->_renderer->_width; - if (height <= 0) height = Game->_renderer->_height; + if (width <= 0) width = _gameRef->_renderer->_width; + if (height <= 0) height = _gameRef->_renderer->_height; - if (!_viewport) _viewport = new CBViewport(Game); + if (!_viewport) _viewport = new CBViewport(_gameRef); if (_viewport) _viewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -1585,14 +1585,14 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1); CScValue *val = stack->pop(); - CAdLayer *layer = new CAdLayer(Game); + CAdLayer *layer = new CAdLayer(_gameRef); if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { layer->_width = _mainLayer->_width; layer->_height = _mainLayer->_height; } _layers.add(layer); - Game->registerObject(layer); + _gameRef->registerObject(layer); stack->pushNative(layer, true); return STATUS_OK; @@ -1606,7 +1606,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int index = stack->pop()->getInt(); CScValue *val = stack->pop(); - CAdLayer *layer = new CAdLayer(Game); + CAdLayer *layer = new CAdLayer(_gameRef); if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { layer->_width = _mainLayer->_width; @@ -1616,7 +1616,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); else _layers.add(layer); - Game->registerObject(layer); + _gameRef->registerObject(layer); stack->pushNative(layer, true); return STATUS_OK; @@ -1658,7 +1658,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t for (int i = 0; i < _layers.getSize(); i++) { if (_layers[i] == toDelete) { _layers.removeAt(i); - Game->unregisterObject(toDelete); + _gameRef->unregisterObject(toDelete); break; } } @@ -1723,7 +1723,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int viewportX; getViewportOffset(&viewportX); - _scValue->setInt(Game->_mousePos.x + _offsetLeft - viewportX); + _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); return _scValue; } @@ -1734,7 +1734,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int viewportY; getViewportOffset(NULL, &viewportY); - _scValue->setInt(Game->_mousePos.y + _offsetTop - viewportY); + _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); return _scValue; } @@ -1944,7 +1944,7 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::addObject(CAdObject *object) { _objects.add(object); - return Game->registerObject(object); + return _gameRef->registerObject(object); } @@ -1953,7 +1953,7 @@ ERRORCODE CAdScene::removeObject(CAdObject *object) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { _objects.removeAt(i); - return Game->unregisterObject(object); + return _gameRef->unregisterObject(object); } } return STATUS_FAILED; @@ -2351,11 +2351,11 @@ void CAdScene::pfPointsAdd(int x, int y, int distance) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { - CAdGame *adGame = (CAdGame *)Game; - if (_viewport && !Game->_editorMode) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { if (offsetX) *offsetX = _viewport->_offsetX; if (offsetY) *offsetY = _viewport->_offsetY; - } else if (adGame->_sceneViewport && !Game->_editorMode) { + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; } else { @@ -2368,16 +2368,16 @@ ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::getViewportSize(int *width, int *height) { - CAdGame *adGame = (CAdGame *)Game; - if (_viewport && !Game->_editorMode) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { if (width) *width = _viewport->getWidth(); if (height) *height = _viewport->getHeight(); - } else if (adGame->_sceneViewport && !Game->_editorMode) { + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { if (width) *width = adGame->_sceneViewport->getWidth(); if (height) *height = adGame->_sceneViewport->getHeight(); } else { - if (width) *width = Game->_renderer->_width; - if (height) *height = Game->_renderer->_height; + if (width) *width = _gameRef->_renderer->_width; + if (height) *height = _gameRef->_renderer->_height; } return STATUS_OK; } @@ -2479,7 +2479,7 @@ ERRORCODE CAdScene::loadState() { ERRORCODE CAdScene::persistState(bool saving) { if (!_persistentState) return STATUS_OK; - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CAdSceneState *state = adGame->getSceneState(_filename, saving); if (!state) return STATUS_OK; @@ -2720,7 +2720,7 @@ ERRORCODE CAdScene::getSceneObjects(CBArray &objects, ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { - CAdGame *adGame = (CAdGame *)Game; + CAdGame *adGame = (CAdGame *)_gameRef; CAdObject *obj; // global objects diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 60ab2891f5..687dbdaeef 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -44,10 +44,10 @@ CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CAdSceneNode::~CAdSceneNode() { - Game->unregisterObject(_region); + _gameRef->unregisterObject(_region); _region = NULL; - Game->unregisterObject(_entity); + _gameRef->unregisterObject(_entity); _entity = NULL; } @@ -56,7 +56,7 @@ CAdSceneNode::~CAdSceneNode() { ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { _type = OBJECT_ENTITY; _entity = entity; - return Game->registerObject(entity); + return _gameRef->registerObject(entity); } @@ -64,7 +64,7 @@ ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { ERRORCODE CAdSceneNode::setRegion(CAdRegion *region) { _type = OBJECT_REGION; _region = region; - return Game->registerObject(region); + return _gameRef->registerObject(region); } diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 00b1b6c250..b10da397b8 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -77,7 +77,7 @@ CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { } if (saving) { - CAdNodeState *ret = new CAdNodeState(Game); + CAdNodeState *ret = new CAdNodeState(_gameRef); ret->setName(name); _nodeStates.add(ret); diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 7d37efce49..cfff93b488 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -56,7 +56,7 @@ CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { _font = NULL; _pos.x = _pos.y = 0; - _width = Game->_renderer->_width; + _width = _gameRef->_renderer->_width; _align = (TTextAlign)TAL_CENTER; @@ -173,18 +173,18 @@ ERRORCODE CAdSentence::display() { _soundStarted = true; } - if (Game->_subtitles) { + if (_gameRef->_subtitles) { int x = _pos.x; int y = _pos.y; if (!_fixedPos) { - x = x - ((CAdGame *)Game)->_scene->getOffsetLeft(); - y = y - ((CAdGame *)Game)->_scene->getOffsetTop(); + x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); } x = MAX(x, 0); - x = MIN(x, Game->_renderer->_width - _width); + x = MIN(x, _gameRef->_renderer->_width - _width); y = MAX(y, 0); _font->drawText((byte *)_text, x, y, _width, _align); @@ -213,7 +213,7 @@ ERRORCODE CAdSentence::finish() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdSentence::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER_INT(_align)); persistMgr->transfer(TMEMBER(_currentStance)); @@ -251,19 +251,19 @@ ERRORCODE CAdSentence::setupTalkFile(const char *soundFilename) { AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - Common::SeekableReadStream *file = Game->_fileManager->openFile(talkDefFileName.c_str()); + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); if (file) { - Game->_fileManager->closeFile(file); + _gameRef->_fileManager->closeFile(file); } else return STATUS_OK; // no talk def file found - _talkDef = new CAdTalkDef(Game); + _talkDef = new CAdTalkDef(_gameRef); if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { delete _talkDef; _talkDef = NULL; return STATUS_FAILED; } - //Game->LOG(0, "Using .talk file: %s", TalkDefFile); + //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); return STATUS_OK; } @@ -278,9 +278,9 @@ ERRORCODE CAdSentence::update(TDirection dir) { /* if (_sound) CurrentTime = _sound->GetPositionTime(); - else CurrentTime = Game->_timer - _startTime; + else CurrentTime = _gameRef->_timer - _startTime; */ - currentTime = Game->_timer - _startTime; + currentTime = _gameRef->_timer - _startTime; bool talkNodeFound = false; for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { @@ -311,7 +311,7 @@ ERRORCODE CAdSentence::update(TDirection dir) { ////////////////////////////////////////////////////////////////////////// bool CAdSentence::CanSkip() { // prevent accidental sentence skipping (TODO make configurable) - return (Game->_timer - _startTime) > 300; + return (_gameRef->_timer - _startTime) > 300; } } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 29026a9508..f93530c449 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -59,15 +59,15 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } ERRORCODE ret; - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); delete [] buffer; @@ -108,11 +108,11 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { - Game->LOG(0, "'SPRITESET' keyword expected."); + _gameRef->LOG(0, "'SPRITESET' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -132,7 +132,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_LEFT: delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_LEFT] = spr; break; @@ -140,7 +140,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_RIGHT: delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_RIGHT] = spr; break; @@ -148,7 +148,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP: delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UP] = spr; break; @@ -156,7 +156,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN: delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWN] = spr; break; @@ -164,7 +164,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP_LEFT: delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPLEFT] = spr; break; @@ -172,7 +172,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP_RIGHT: delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPRIGHT] = spr; break; @@ -180,7 +180,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN_LEFT: delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNLEFT] = spr; break; @@ -188,7 +188,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN_RIGHT: delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(Game, _owner); + spr = new CBSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNRIGHT] = spr; break; @@ -199,12 +199,12 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SPRITESET definition"); + _gameRef->LOG(0, "Syntax error in SPRITESET definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading SPRITESET definition"); + _gameRef->LOG(0, "Error loading SPRITESET definition"); if (spr) delete spr; return STATUS_FAILED; } diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 62b6ea8b67..09ef66a946 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -70,9 +70,9 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdTalkDef::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -80,7 +80,7 @@ ERRORCODE CAdTalkDef::loadFile(const char *filename) { CBUtils::setString(&_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); delete [] buffer; @@ -111,11 +111,11 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { - Game->LOG(0, "'TALK' keyword expected."); + _gameRef->LOG(0, "'TALK' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -128,7 +128,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ACTION: { - CAdTalkNode *Node = new CAdTalkNode(Game); + CAdTalkNode *Node = new CAdTalkNode(_gameRef); if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); else { delete Node; @@ -148,7 +148,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { case TOKEN_DEFAULT_SPRITESET: { delete _defaultSpriteSet; - _defaultSpriteSet = new CAdSpriteSet(Game); + _defaultSpriteSet = new CAdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; @@ -164,12 +164,12 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TALK definition"); + _gameRef->LOG(0, "Syntax error in TALK definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading TALK definition"); + _gameRef->LOG(0, "Error loading TALK definition"); return STATUS_FAILED; } @@ -179,12 +179,12 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { _defaultSpriteSet = NULL; if (_defaultSpriteFilename) { - _defaultSprite = new CBSprite(Game); + _defaultSprite = new CBSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; } if (_defaultSpriteSetFilename) { - _defaultSpriteSet = new CAdSpriteSet(Game); + _defaultSpriteSet = new CAdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; } @@ -232,14 +232,14 @@ ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdTalkDef::loadDefaultSprite() { if (_defaultSpriteFilename && !_defaultSprite) { - _defaultSprite = new CBSprite(Game); + _defaultSprite = new CBSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { delete _defaultSprite; _defaultSprite = NULL; return STATUS_FAILED; } else return STATUS_OK; } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { - _defaultSpriteSet = new CAdSpriteSet(Game); + _defaultSpriteSet = new CAdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index eb4860b5d6..d7e13a5af4 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -71,11 +71,11 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; delete _animSprite; - _animSprite = new CBSprite(Game, this); + _animSprite = new CBSprite(_gameRef, this); if (_animSprite) { ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -140,7 +140,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta stack->pushBool(true); } else { const char *filename = val->getString(); - CBSprite *spr = new CBSprite(Game, this); + CBSprite *spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { script->runtimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); @@ -184,7 +184,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta const char *filename = stack->pop()->getString(); bool Ex = stack->pop()->getBool(); - CBSprite *spr = new CBSprite(Game, this); + CBSprite *spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("AddTalkSprite method failed for file '%s'", filename); @@ -255,7 +255,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta bool setCurrent = false; bool setTemp2 = false; - CBSprite *spr = new CBSprite(Game, this); + CBSprite *spr = new CBSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("SetTalkSprite method failed for file '%s'", filename); diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 7f4198b0f1..30c32c4db4 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -95,11 +95,11 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { - Game->LOG(0, "'ACTION' keyword expected."); + _gameRef->LOG(0, "'ACTION' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -121,7 +121,7 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITESET: { delete _spriteSet; - _spriteSet = new CAdSpriteSet(Game); + _spriteSet = new CAdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { delete _spriteSet; _spriteSet = NULL; @@ -143,7 +143,7 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_COMMENT: - if (Game->_editorMode) CBUtils::setString(&_comment, (char *)params); + if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); break; case TOKEN_EDITOR_PROPERTY: @@ -152,12 +152,12 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ACTION definition"); + _gameRef->LOG(0, "Syntax error in ACTION definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ACTION definition"); + _gameRef->LOG(0, "Error loading ACTION definition"); return STATUS_FAILED; } @@ -168,14 +168,14 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { if (_preCache && _spriteFilename) { delete _sprite; - _sprite = new CBSprite(Game); + _sprite = new CBSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) return STATUS_FAILED; } if (_preCache && _spriteSetFilename) { delete _spriteSet; - _spriteSet = new CAdSpriteSet(Game); + _spriteSet = new CAdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) return STATUS_FAILED; } @@ -222,7 +222,7 @@ ERRORCODE CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdTalkNode::loadSprite() { if (_spriteFilename && !_sprite) { - _sprite = new CBSprite(Game); + _sprite = new CBSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { delete _sprite; _sprite = NULL; @@ -231,7 +231,7 @@ ERRORCODE CAdTalkNode::loadSprite() { } else if (_spriteSetFilename && !_spriteSet) { - _spriteSet = new CAdSpriteSet(Game); + _spriteSet = new CAdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; _spriteSet = NULL; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 4ad2dc1749..0210095c28 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -65,9 +65,9 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdWaypointGroup::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -76,7 +76,7 @@ ERRORCODE CAdWaypointGroup::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); delete [] buffer; @@ -110,11 +110,11 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { - Game->LOG(0, "'WAYPOINTS' keyword expected."); + _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -155,7 +155,7 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in WAYPOINTS definition"); + _gameRef->LOG(0, "Syntax error in WAYPOINTS definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp index be9c543469..ca0dcddc28 100644 --- a/engines/wintermute/Base/BActiveRect.cpp +++ b/engines/wintermute/Base/BActiveRect.cpp @@ -88,8 +88,8 @@ CBActiveRect::~CBActiveRect() { void CBActiveRect::clipRect() { Rect32 rc; bool customViewport; - Game->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = Game->_renderer; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + CBRenderer *Rend = _gameRef->_renderer; if (!customViewport) { rc.left -= Rend->_drawOffsetX; diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index a43a9d78db..bdfcfccdd5 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -35,15 +35,15 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *GameOwner) { - Game = GameOwner; +CBBase::CBBase(CBGame *gameOwner) { + _gameRef = gameOwner; _persistable = true; } ////////////////////////////////////////////////////////////////////////// CBBase::CBBase() { - Game = NULL; + _gameRef = NULL; _persistable = true; } @@ -92,17 +92,17 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_END - if (!Game->_editorMode) + if (!_gameRef->_editorMode) return STATUS_OK; byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - Game->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -134,7 +134,7 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { delete[] propValue; propName = NULL; propValue = NULL; - Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { @@ -142,7 +142,7 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { delete[] propValue; propName = NULL; propValue = NULL; - Game->LOG(0, "Error loading EDITOR_PROPERTY definition"); + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index d505ec0b1d..afbe277529 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -49,7 +49,7 @@ public: ERRORCODE parseEditorProperty(byte *buffer, bool complete = true); virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); CBBase(); - CBGame *Game; + CBGame *_gameRef; CBBase(CBGame *GameOwner); virtual ~CBBase(); diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index 291712c6c8..ff13f96d6c 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -76,7 +76,7 @@ ERRORCODE CBDynBuffer::init(uint32 initSize) { _buffer = (byte *)malloc(initSize); if (!_buffer) { - Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); return STATUS_FAILED; } @@ -95,7 +95,7 @@ ERRORCODE CBDynBuffer::putBytes(byte *buffer, uint32 size) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { - Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return STATUS_FAILED; } } @@ -113,7 +113,7 @@ ERRORCODE CBDynBuffer::getBytes(byte *buffer, uint32 size) { if (!_initialized) init(); if (_offset + size > _size) { - Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index 9538e4b398..d8bfbf412d 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -68,7 +68,7 @@ ERRORCODE CBFader::update() { uint32 time; if (_system) time = CBPlatform::getTime() - _startTime; - else time = Game->_timer - _startTime; + else time = _gameRef->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; else { @@ -87,7 +87,7 @@ ERRORCODE CBFader::update() { ERRORCODE CBFader::display() { if (!_active) return STATUS_OK; - if (_currentAlpha > 0x00) return Game->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); else return STATUS_OK; } @@ -116,7 +116,7 @@ ERRORCODE CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _system = system; if (_system) _startTime = CBPlatform::getTime(); - else _startTime = Game->_timer; + else _startTime = _gameRef->_timer; return STATUS_OK; } @@ -139,7 +139,7 @@ ERRORCODE CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _system = system; if (_system) _startTime = CBPlatform::getTime(); - else _startTime = Game->_timer; + else _startTime = _gameRef->_timer; return STATUS_OK; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 1e477e9038..e652ff8301 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -119,13 +119,13 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, Common::SeekableReadStream *file = openFile(filename); if (!file) { - if (mustExist) Game->LOG(0, "Error opening file '%s'", filename.c_str()); + if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); return NULL; } /* if (File->GetSize() > MAX_FILE_SIZE) { - Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); CloseFile(File); return NULL; } @@ -134,13 +134,13 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, buffer = new byte[file->size() + 1]; if (buffer == NULL) { - Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); closeFile(file); return NULL; } if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - Game->LOG(0, "Error reading file '%s'", filename.c_str()); + _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); closeFile(file); delete [] buffer; return NULL; @@ -177,7 +177,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, FILE *f = fopen(filename, "wb"); if (!f) { - Game->LOG(0, "Error opening file '%s' for writing.", filename); + _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); return STATUS_FAILED; } @@ -189,7 +189,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space byte *CompBuffer = new byte[CompSize]; if (!CompBuffer) { - Game->LOG(0, "Error allocating compression buffer while saving '%s'", filename); + _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); Compressed = false; } else { if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { @@ -206,7 +206,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, fwrite(CompBuffer, CompSize, 1, f); } else { - Game->LOG(0, "Error compressing data while saving '%s'", filename); + _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); Compressed = false; } @@ -283,7 +283,7 @@ ERRORCODE CBFileManager::initPaths() { int numPaths; // single files paths - pathList = Game->_registry->readString("Resource", "CustomPaths", ""); + pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { @@ -300,7 +300,7 @@ ERRORCODE CBFileManager::initPaths() { // package files paths addPath(PATH_PACKAGE, "./"); - pathList = Game->_registry->readString("Resource", "PackagePaths", ""); + pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { @@ -321,7 +321,7 @@ ERRORCODE CBFileManager::initPaths() { ERRORCODE CBFileManager::registerPackages() { restoreCurrentDir(); - Game->LOG(0, "Scanning packages..."); + _gameRef->LOG(0, "Scanning packages..."); warning("Scanning packages"); Common::ArchiveMemberList files; @@ -336,7 +336,7 @@ ERRORCODE CBFileManager::registerPackages() { for (int i = 0; i < _packagePaths.getSize(); i++) { boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - //Game->LOG(0, "Scanning: %s", absPath.string().c_str()); + //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); //printf("Scanning: %s\n", absPath.string().c_str()); if (!exists(absPath)) continue; @@ -359,7 +359,7 @@ ERRORCODE CBFileManager::registerPackages() { } #endif warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); - Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); return STATUS_OK; @@ -371,7 +371,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { - Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); return STATUS_OK; } @@ -394,13 +394,13 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return STATUS_OK; } if (hdr.PackageVersion != PACKAGE_VERSION) { - Game->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 @@ -412,7 +412,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s } for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(Game); + CBPackage *pkg = new CBPackage(_gameRef); if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; @@ -465,7 +465,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s } _filesIter = _files.find(name); if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(Game); + CBFileEntry *file = new CBFileEntry(_gameRef); file->_package = pkg; file->_offset = offset; file->_length = length; @@ -498,7 +498,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const { // check for device-type specific packages if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + Game->getDeviceType()); + return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); } return true; } @@ -614,13 +614,13 @@ bool CBFileManager::hasFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; - //Game->LOG(0, "open file: %s", filename); + //_gameRef->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ - if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) { + if (_gameRef->_dEBUG_DebugMode && _gameRef->_dEBUG_AbsolutePathWarning && AbsPathWarning) { char Drive[_MAX_DRIVE]; _splitpath(filename, Drive, NULL, NULL, NULL); if (Drive[0] != '\0') { - Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); + _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); } } #endif*/ @@ -651,7 +651,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game); + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); } diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index b57d2e41f3..e77235efa7 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -92,7 +92,7 @@ ERRORCODE CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { if (owner) owner->updateOneSound(_sound); _sound->play(); /* - if (Game->_state == GAME_FROZEN) { + if (_gameRef->_state == GAME_FROZEN) { _sound->Pause(true); } */ @@ -158,7 +158,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -237,7 +237,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(Game); + CBSubFrame *subframe = new CBSubFrame(_gameRef); if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; @@ -250,9 +250,9 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { delete _sound; _sound = NULL; } - _sound = new CBSound(Game); + _sound = new CBSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params); + if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); delete _sound; _sound = NULL; } @@ -280,24 +280,24 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in FRAME definition"); + _gameRef->LOG(0, "Syntax error in FRAME definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading FRAME definition"); + _gameRef->LOG(0, "Error loading FRAME definition"); return STATUS_FAILED; } - CBSubFrame *sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(_gameRef); if (surface_file != NULL) { if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); if (!sub->_surface) { delete sub; - Game->LOG(0, "Error loading SUBFRAME"); + _gameRef->LOG(0, "Error loading SUBFRAME"); return STATUS_FAILED; } @@ -422,7 +422,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _sound = NULL; if (!val->isNULL()) { - _sound = new CBSound(Game); + _sound = new CBSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { stack->pushBool(false); delete _sound; @@ -480,7 +480,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); sub->setDefaultRect(); @@ -503,7 +503,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); } @@ -572,7 +572,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(Game); + if (!_scValue) _scValue = new CScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index c262c6de91..4abfdf4507 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -624,7 +624,7 @@ ERRORCODE CBGame::initLoop() { _framesRendered = 0; _fpsTime = 0; } - //Game->LOG(0, "%d", _fps); + //_gameRef->LOG(0, "%d", _fps); getMousePos(&_mousePos); @@ -671,9 +671,9 @@ void CBGame::getOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -682,7 +682,7 @@ ERRORCODE CBGame::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); delete [] buffer; @@ -778,11 +778,11 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { - Game->LOG(0, "'GAME' keyword expected."); + _gameRef->LOG(0, "'GAME' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -806,20 +806,20 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { if (_systemFont) _fontStorage->removeFont(_systemFont); _systemFont = NULL; - _systemFont = Game->_fontStorage->addFont((char *)params); + _systemFont = _gameRef->_fontStorage->addFont((char *)params); break; case TOKEN_VIDEO_FONT: if (_videoFont) _fontStorage->removeFont(_videoFont); _videoFont = NULL; - _videoFont = Game->_fontStorage->addFont((char *)params); + _videoFont = _gameRef->_fontStorage->addFont((char *)params); break; case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -830,7 +830,7 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ACTIVE_CURSOR: delete _activeCursor; _activeCursor = NULL; - _activeCursor = new CBSprite(Game); + _activeCursor = new CBSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { delete _activeCursor; _activeCursor = NULL; @@ -840,7 +840,7 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(Game); + _cursorNoninteractive = new CBSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -941,15 +941,15 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { } } - if (!_systemFont) _systemFont = Game->_fontStorage->addFont("system_font.fnt"); + if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in GAME definition"); + _gameRef->LOG(0, "Syntax error in GAME definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading GAME definition"); + _gameRef->LOG(0, "Error loading GAME definition"); return STATUS_FAILED; } @@ -994,7 +994,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // RunScript ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RunScript") == 0) { - Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); stack->correctParams(1); if (DID_FAIL(addScript(stack->pop()->getString()))) stack->pushBool(false); @@ -1067,7 +1067,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadWindow") == 0) { stack->correctParams(1); - CUIWindow *win = new CUIWindow(Game); + CUIWindow *win = new CUIWindow(_gameRef); if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { _windows.add(win); registerObject(win); @@ -1311,7 +1311,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int length = 0; const char *filename = stack->pop()->getString(); - CBSound *sound = new CBSound(Game); + CBSound *sound = new CBSound(_gameRef); if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { length = sound->getLength(); delete sound; @@ -1372,7 +1372,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // TODO: ADDVIDEO */ - Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); stack->correctParams(6); const char *filename = stack->pop()->getString(); @@ -1392,8 +1392,8 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - if (DID_SUCCEED(Game->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { stack->pushBool(true); script->sleep(0); } else stack->pushBool(false); @@ -1575,7 +1575,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSFXVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1585,7 +1585,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1595,7 +1595,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMusicVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1605,7 +1605,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetGlobalMasterVolume") == 0) { stack->correctParams(1); - Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); stack->pushNULL(); return STATUS_OK; } @@ -1789,7 +1789,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi } bool ret = false; - CBImage *image = Game->_renderer->takeScreenshot(); + CBImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; @@ -1809,7 +1809,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi int sizeY = stack->pop()->getInt(_renderer->_height); bool ret = false; - CBImage *image = Game->_renderer->takeScreenshot(); + CBImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->resize(sizeX, sizeY)); if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); @@ -1827,7 +1827,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi stack->correctParams(1); CScValue *val = stack->pop(); - CUIWindow *win = new CUIWindow(Game); + CUIWindow *win = new CUIWindow(_gameRef); _windows.add(win); registerObject(win); if (!val->isNULL()) win->setName(val->getString()); @@ -1982,8 +1982,8 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi _loadingIcon = NULL; } else { displayContent(false, true); - Game->_renderer->flip(); - Game->_renderer->initLoop(); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); } stack->pushNULL(); @@ -2273,7 +2273,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SFXVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { - Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); return _scValue; } @@ -2282,7 +2282,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // SpeechVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { - Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); return _scValue; } @@ -2291,7 +2291,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MusicVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { - Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); return _scValue; } @@ -2300,7 +2300,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // MasterVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MasterVolume") == 0) { - Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getMasterVolumePercent()); return _scValue; } @@ -2597,8 +2597,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { // SFXVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SFXVolume") == 0) { - Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -2606,8 +2606,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { // SpeechVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SpeechVolume") == 0) { - Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -2615,8 +2615,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { // MusicVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MusicVolume") == 0) { - Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); return STATUS_OK; } @@ -2624,8 +2624,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { // MasterVolume ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MasterVolume") == 0) { - Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - Game->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); return STATUS_OK; } @@ -2772,7 +2772,7 @@ void CBGame::quickMessage(const char *text) { delete _quickMessages[0]; _quickMessages.removeAt(0); } - _quickMessages.add(new CBQuickMsg(Game, text)); + _quickMessages.add(new CBQuickMsg(_gameRef, text)); } @@ -2867,7 +2867,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LOG") == 0) { stack->correctParams(1); - Game->LOG(0, "sc: %s", stack->pop()->getString()); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); stack->pushNULL(); } @@ -2877,7 +2877,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "String") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXString(Game, stack)); + thisObj->setNative(makeSXString(_gameRef, stack)); stack->pushNULL(); } @@ -2887,7 +2887,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "MemBuffer") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXMemBuffer(Game, stack)); + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); stack->pushNULL(); } @@ -2897,7 +2897,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "File") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXFile(Game, stack)); + thisObj->setNative(makeSXFile(_gameRef, stack)); stack->pushNULL(); } @@ -2907,7 +2907,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "Date") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXDate(Game, stack)); + thisObj->setNative(makeSXDate(_gameRef, stack)); stack->pushNULL(); } @@ -2917,7 +2917,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "Array") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXArray(Game, stack)); + thisObj->setNative(makeSXArray(_gameRef, stack)); stack->pushNULL(); } @@ -2927,7 +2927,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "Object") == 0) { thisObj = thisStack->getTop(); - thisObj->setNative(makeSXObject(Game, stack)); + thisObj->setNative(makeSXObject(_gameRef, stack)); stack->pushNULL(); } @@ -3084,8 +3084,8 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi else if (strcmp(name, "Debug") == 0) { stack->correctParams(0); - if (Game->getDebugMgr()->_enabled) { - Game->getDebugMgr()->onScriptHitBreakpoint(script); + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); script->sleep(0); } stack->pushNULL(); @@ -3146,7 +3146,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi ERRORCODE CBGame::showCursor() { if (_cursorHidden) return STATUS_OK; - if (!_interactive && Game->_state == GAME_RUNNING) { + if (!_interactive && _gameRef->_state == GAME_RUNNING) { if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); } else { if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; @@ -3166,13 +3166,13 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { LOG(0, "Saving game '%s'...", filename); - Game->applyEvent("BeforeSave", true); + _gameRef->applyEvent("BeforeSave", true); ERRORCODE ret; _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(Game); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; if (!quickSave) { @@ -3188,8 +3188,8 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { } } - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3207,7 +3207,7 @@ save_finish: // TODO: Remove gotos ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::loadGame(int slot) { - //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); _loading = false; _scheduledLoadSlot = -1; @@ -3241,18 +3241,18 @@ ERRORCODE CBGame::loadGame(const char *filename) { _loadInProgress = true; _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(Game); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); _dEBUG_AbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; // data initialization after load initAfterLoad(); - Game->applyEvent("AfterLoad", true); + _gameRef->applyEvent("AfterLoad", true); displayContent(true, false); //_renderer->flip(); @@ -3269,7 +3269,7 @@ load_finish: delete _saveLoadImage; _saveLoadImage = NULL; - //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); return ret; } @@ -3347,14 +3347,14 @@ ERRORCODE CBGame::displayWindows(bool inGame) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } delete _music[channel]; _music[channel] = NULL; - _music[channel] = new CBSound(Game); + _music[channel] = new CBSound(_gameRef); if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { if (_musicStartTime[channel]) { _music[channel]->setPositionTime(_musicStartTime[channel]); @@ -3373,7 +3373,7 @@ ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uin ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } @@ -3389,7 +3389,7 @@ ERRORCODE CBGame::stopMusic(int channel) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } @@ -3401,7 +3401,7 @@ ERRORCODE CBGame::pauseMusic(int channel) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } @@ -3413,7 +3413,7 @@ ERRORCODE CBGame::resumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { - Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } @@ -3445,9 +3445,9 @@ ERRORCODE CBGame::loadSettings(const char *filename) { TOKEN_TABLE_END - byte *origBuffer = Game->_fileManager->readWholeFile(filename); + byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); if (origBuffer == NULL) { - Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; } @@ -3456,10 +3456,10 @@ ERRORCODE CBGame::loadSettings(const char *filename) { byte *buffer = origBuffer; byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - Game->LOG(0, "'SETTINGS' keyword expected in game settings file."); + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); return STATUS_FAILED; } buffer = params; @@ -3528,11 +3528,11 @@ ERRORCODE CBGame::loadSettings(const char *filename) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in game settings '%s'", filename); + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); ret = STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading game settings '%s'", filename); + _gameRef->LOG(0, "Error loading game settings '%s'", filename); ret = STATUS_FAILED; } @@ -3649,10 +3649,10 @@ ERRORCODE CBGame::focusWindow(CUIWindow *Window) { _windows.removeAt(i); _windows.add(Window); - Game->_focusedWindow = Window; + _gameRef->_focusedWindow = Window; } - if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) return focusWindow(Prev); else return STATUS_OK; } @@ -3718,10 +3718,10 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { // TODO if (_focusedWindow) { - if (!Game->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ - if (Game->_focusedWindow->canHandleEvent("Keypress")) - Game->_focusedWindow->applyEvent("Keypress"); + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + _gameRef->_focusedWindow->applyEvent("Keypress"); else applyEvent("Keypress"); /*}*/ @@ -3744,14 +3744,14 @@ void CBGame::handleKeyRelease(Common::Event *event) { bool CBGame::handleMouseWheel(int Delta) { bool handled = false; if (_focusedWindow) { - handled = Game->_focusedWindow->handleMouseWheel(Delta); + handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); if (!handled) { - if (Delta < 0 && Game->_focusedWindow->canHandleEvent("MouseWheelDown")) { - Game->_focusedWindow->applyEvent("MouseWheelDown"); + if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); handled = true; - } else if (Game->_focusedWindow->canHandleEvent("MouseWheelUp")) { - Game->_focusedWindow->applyEvent("MouseWheelUp"); + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); handled = true; } @@ -3833,7 +3833,7 @@ ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(Game); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); if (!pm) return STATUS_FAILED; _dEBUG_AbsolutePathWarning = false; @@ -3878,7 +3878,7 @@ ERRORCODE CBGame::emptySaveSlot(int slot) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::setActiveObject(CBObject *obj) { // not-active when game is frozen - if (obj && !Game->_interactive && !obj->_nonIntMouseEvents) { + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { obj = NULL; } @@ -3910,7 +3910,7 @@ ERRORCODE CBGame::pushViewport(CBViewport *viewport) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::popViewport() { _viewportSP--; - if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!"); + if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); else _renderer->setViewport(_renderer->_drawOffsetX, @@ -4038,7 +4038,7 @@ ERRORCODE CBGame::updateMusicCrossfade() { if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); - uint32 currentTime = Game->_liveTimer - _musicCrossfadeStartTime; + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; if (currentTime >= _musicCrossfadeLength) { _musicCrossfadeRunning = false; @@ -4067,7 +4067,7 @@ ERRORCODE CBGame::updateMusicCrossfade() { _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } return STATUS_OK; @@ -4093,7 +4093,7 @@ void CBGame::DEBUG_DumpClassRegistry() { f->close(); delete f; - Game->quickMessage("Classes dump completed."); + _gameRef->quickMessage("Classes dump completed."); } @@ -4119,7 +4119,7 @@ ERRORCODE CBGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; - _cursorNoninteractive = new CBSprite(Game); + _cursorNoninteractive = new CBSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -4309,7 +4309,7 @@ ERRORCODE CBGame::onPaint() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBGame::onWindowClose() { if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) Game->applyEvent("QuitGame"); + if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); return STATUS_OK; } else return STATUS_FAILED; } @@ -4319,12 +4319,12 @@ ERRORCODE CBGame::displayDebugInfo() { char str[100]; if (_dEBUG_ShowFPS) { - sprintf(str, "FPS: %d", Game->_fps); + sprintf(str, "FPS: %d", _gameRef->_fps); _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); } - if (Game->_dEBUG_DebugMode) { - if (!Game->_renderer->_windowed) + if (_gameRef->_dEBUG_DebugMode) { + if (!_gameRef->_renderer->_windowed) sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); else sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); @@ -4343,7 +4343,7 @@ ERRORCODE CBGame::displayDebugInfo() { sprintf(str, "Timer: %d", _timer); - Game->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); @@ -4375,9 +4375,9 @@ void CBGame::getMousePos(Point32 *pos) { if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { Common::Rect rc; ::GetClientRect(_renderer->_window, &rc); - Pos->x *= Game->_renderer->_realWidth; + Pos->x *= _gameRef->_renderer->_realWidth; Pos->x /= (rc.right - rc.left); - Pos->y *= Game->_renderer->_realHeight; + Pos->y *= _gameRef->_renderer->_realHeight; Pos->y /= (rc.bottom - rc.top); } */ diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 337a157536..57a2694aa8 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -86,13 +86,13 @@ ERRORCODE CBImage::loadFile(const Common::String &filename) { error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); } _filename = filename; - Common::SeekableReadStream *file = Game->_fileManager->openFile(filename.c_str()); + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); if (!file) return STATUS_FAILED; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); - Game->_fileManager->closeFile(file); + _gameRef->_fileManager->closeFile(file); return STATUS_OK; } diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 60a9fe7f32..35a2e257d6 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -63,7 +63,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _soundEvent = NULL; - _iD = Game->getSequence(); + _iD = _gameRef->getSequence(); CBPlatform::setRectEmpty(&_rect); _rectSet = false; @@ -108,8 +108,8 @@ CBObject::~CBObject() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBObject::cleanup() { - if (Game && Game->_activeObject == this) - Game->_activeObject = NULL; + if (_gameRef && _gameRef->_activeObject == this) + _gameRef->_activeObject = NULL; CBScriptHolder::cleanup(); delete[] _soundEvent; @@ -146,7 +146,7 @@ void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Ca _caption[caseVal - 1] = new char[strlen(caption) + 1]; if (_caption[caseVal - 1]) { strcpy(_caption[caseVal - 1], caption); - Game->_stringTable->expand(&_caption[caseVal - 1]); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); } } @@ -857,7 +857,7 @@ const char *CBObject::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBObject::showCursor() { - if (_cursor) return Game->drawCursor(_cursor); + if (_cursor) return _gameRef->drawCursor(_cursor); else return STATUS_FAILED; } @@ -932,7 +932,7 @@ ERRORCODE CBObject::setCursor(const char *filename) { } _sharedCursors = false; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { delete _cursor; _cursor = NULL; @@ -944,7 +944,7 @@ ERRORCODE CBObject::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBObject::setActiveCursor(const char *filename) { delete _activeCursor; - _activeCursor = new CBSprite(Game); + _activeCursor = new CBSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { delete _activeCursor; _activeCursor = NULL; @@ -981,10 +981,10 @@ bool CBObject::handleMouseWheel(int delta) { ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound if (filename == NULL && _sFX) { - if (Game->_editorMode || _sFXStart) { + if (_gameRef->_editorMode || _sFXStart) { _sFX->setVolumePercent(_sFXVolume); _sFX->setPositionTime(_sFXStart); - if (!Game->_editorMode) _sFXStart = 0; + if (!_gameRef->_editorMode) _sFXStart = 0; } if (playNow) { setSoundEvent(eventName); @@ -998,7 +998,7 @@ ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, co // create new sound delete _sFX; - _sFX = new CBSound(Game); + _sFX = new CBSound(_gameRef); if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { _sFX->setVolumePercent(_sFXVolume); if (_sFXStart) { @@ -1082,7 +1082,7 @@ ERRORCODE CBObject::updateOneSound(CBSound *sound) { if (sound) { if (_autoSoundPanning) - Ret = sound->setPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY)); + Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index 1122ebc16d..0727417025 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -87,10 +87,10 @@ ERRORCODE CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = Game->_fileManager->openPackage(_name); + Common::File *file = _gameRef->_fileManager->openPackage(_name); if (!file) { - Game->_fileManager->requestCD(_cD, _name, ""); - file = Game->_fileManager->openPackage(_name); + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); } return file; } diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp index 45c0577f92..114c5054ca 100644 --- a/engines/wintermute/Base/BParser.cpp +++ b/engines/wintermute/Base/BParser.cpp @@ -115,7 +115,7 @@ int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **dat ////////////////////////////////////////////////////////////////////// int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; - Game->miniUpdate(); + _gameRef->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 7308a8bbb7..b58534ea90 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -180,11 +180,11 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) { if (_saveStream) { // get thumbnails - if (!Game->_cachedThumbnail) { - Game->_cachedThumbnail = new CBSaveThumbHelper(Game); - if (DID_FAIL(Game->_cachedThumbnail->storeThumbnail(true))) { - delete Game->_cachedThumbnail; - Game->_cachedThumbnail = NULL; + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; } } @@ -195,7 +195,7 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) { putDWORD(magic); byte VerMajor, VerMinor, ExtMajor, ExtMinor; - Game->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); _saveStream->writeByte(VerMajor); _saveStream->writeByte(VerMinor); @@ -204,15 +204,15 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) { // new in ver 2 putDWORD((uint32)DCGF_VER_BUILD); - putString(Game->_name); + putString(_gameRef->_name); // thumbnail data size bool thumbnailOK = false; - if (Game->_cachedThumbnail) { - if (Game->_cachedThumbnail->_thumbnail) { + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); - if (Game->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { _saveStream->writeUint32LE(thumbStream.size()); _saveStream->write(thumbStream.getData(), thumbStream.size()); } else { @@ -225,8 +225,8 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) { if (!thumbnailOK) putDWORD(0); // in any case, destroy the cached thumbnail once used - delete Game->_cachedThumbnail; - Game->_cachedThumbnail = NULL; + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; uint32 dataOffset = _offset + sizeof(uint32) + // data offset @@ -250,7 +250,7 @@ ERRORCODE CBPersistMgr::readHeader(const Common::String &filename) { _saving = false; _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = Game->_fileManager->readWholeFile(filename, &_bufferSize); + //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); if (_loadStream) { uint32 magic; magic = getDWORD(); @@ -306,8 +306,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { } _saving = false; - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), Game->_name) != 0) { - Game->LOG(0, "ERROR: Saved game name doesn't match current game"); + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; } @@ -317,8 +317,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { - Game->LOG(0, "ERROR: Saved game version is newer than current game"); - Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; } @@ -328,8 +328,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { - Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; @@ -338,7 +338,7 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { /* if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) { - Game->LOG(0, "ERROR: Saved game is created by other WME version"); + _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); goto init_fail; } */ @@ -349,7 +349,7 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBPersistMgr::saveFile(const char *filename) { - return Game->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize); + return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); } @@ -738,7 +738,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, void *val) { if (_saving) { CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - Game->LOG(0, "Warning: invalid instance '%s'", name); + _gameRef->LOG(0, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(classID); diff --git a/engines/wintermute/Base/BQuickMsg.cpp b/engines/wintermute/Base/BQuickMsg.cpp index cee37a0222..dd87a10dad 100644 --- a/engines/wintermute/Base/BQuickMsg.cpp +++ b/engines/wintermute/Base/BQuickMsg.cpp @@ -36,7 +36,7 @@ namespace WinterMute { CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { _text = new char [strlen(text) + 1]; if (_text) strcpy(_text, text); - _startTime = Game->_currentTime; + _startTime = _gameRef->_currentTime; } diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 65ba2c8825..1db15abae0 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -96,9 +96,9 @@ bool CBRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBRegion::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -107,7 +107,7 @@ ERRORCODE CBRegion::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); delete [] buffer; @@ -143,11 +143,11 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - Game->LOG(0, "'REGION' keyword expected."); + _gameRef->LOG(0, "'REGION' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -197,7 +197,7 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in REGION definition"); + _gameRef->LOG(0, "Syntax error in REGION definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp index b8520b07fd..c7ec0c2675 100644 --- a/engines/wintermute/Base/BRegistry.cpp +++ b/engines/wintermute/Base/BRegistry.cpp @@ -167,12 +167,12 @@ char *CBRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void CBRegistry::loadValues(bool local) { if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); + else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// void CBRegistry::saveValues() { - saveXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values); + saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 5d7c16849c..4174bab71b 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -154,8 +154,8 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { } } #else*/ - _realWidth = Game->_registry->readInt("Debug", "ForceResWidth", _width); - _realHeight = Game->_registry->readInt("Debug", "ForceResHeight", _height); + _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); + _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); //#endif /* @@ -194,7 +194,7 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; #endif - //_windowed = Game->_registry->readBool("Video", "Windowed", true); + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); // if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); @@ -311,7 +311,7 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { fillRect.setHeight(rect->height()); } else { Rect32 rc; - Game->getCurrentViewportRect(&rc); + _gameRef->getCurrentViewportRect(&rc); fillRect.left = (int16)rc.left; fillRect.top = (int16)rc.top; fillRect.setWidth((int16)(rc.right - rc.left)); @@ -553,7 +553,7 @@ ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { CBImage *CBRenderSDL::takeScreenshot() { // TODO: Fix this warning("CBRenderSDL::TakeScreenshot() - not ported yet"); - CBImage *screenshot = new CBImage(Game); + CBImage *screenshot = new CBImage(_gameRef); screenshot->copyFrom(_renderSurface); return screenshot; #if 0 @@ -576,7 +576,7 @@ CBImage *CBRenderSDL::takeScreenshot() { memcpy(bits, src, bytespp * viewport.w); } - return new CBImage(Game, dib); + return new CBImage(_gameRef, dib); #endif return NULL; } @@ -588,7 +588,7 @@ ERRORCODE CBRenderSDL::switchFullscreen() { _windowed = !_windowed; */ - Game->_registry->writeBool("Video", "Windowed", _windowed); + _gameRef->_registry->writeBool("Video", "Windowed", _windowed); return STATUS_OK; } @@ -666,7 +666,7 @@ void CBRenderSDL::dumpData(const char *filename) { FILE *f = fopen(filename, "wt"); if (!f) return; - CBSurfaceStorage *Mgr = Game->_surfaceStorage; + CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; int TotalKB = 0; int TotalLoss = 0; @@ -689,13 +689,13 @@ void CBRenderSDL::dumpData(const char *filename) { fclose(f); - Game->LOG(0, "Texture Stats Dump completed."); - Game->QuickMessage("Texture Stats Dump completed."); + _gameRef->LOG(0, "Texture Stats Dump completed."); + _gameRef->QuickMessage("Texture Stats Dump completed."); #endif } CBSurface *CBRenderSDL::createSurface() { - return new CBSurfaceSDL(Game); + return new CBSurfaceSDL(_gameRef); } } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index f53ffda52c..6c7b572475 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -49,24 +49,24 @@ ERRORCODE CBSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; - if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { if (doFlip) { // when using opengl on windows it seems to be necessary to do this twice // works normally for direct3d - Game->displayContent(false); - Game->_renderer->flip(); + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); - Game->displayContent(false); - Game->_renderer->flip(); + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); } - CBImage *screenshot = Game->_renderer->takeScreenshot(); + CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); if (!screenshot) return STATUS_FAILED; // normal thumbnail - if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) { - _thumbnail = new CBImage(Game); - _thumbnail->copyFrom(screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight); + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new CBImage(_gameRef); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 40e7d5d392..8e2a8f6adb 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -94,7 +94,7 @@ ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { } } } - if (numHandlers > 0 && unbreakable) Game->_scEngine->tickUnbreakable(); + if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); return ret; } @@ -280,24 +280,24 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); return STATUS_OK; } } } - CScScript *scr = Game->_scEngine->runScript(filename, this); + CScScript *scr = _gameRef->_scEngine->runScript(filename, this); if (!scr) { - if (Game->_editorForceScripts) { + if (_gameRef->_editorForceScripts) { // editor hack - scr = new CScScript(Game, Game->_scEngine); + scr = new CScScript(_gameRef, _gameRef->_scEngine); scr->_filename = new char[strlen(filename) + 1]; strcpy(scr->_filename, filename); scr->_state = SCRIPT_ERROR; scr->_owner = this; _scripts.add(scr); - Game->_scEngine->_scripts.add(scr); - Game->getDebugMgr()->onScriptInit(scr); + _gameRef->_scEngine->_scripts.add(scr); + _gameRef->getDebugMgr()->onScriptInit(scr); return STATUS_OK; } @@ -354,11 +354,11 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - Game->LOG(0, "'PROPERTY' keyword expected."); + _gameRef->LOG(0, "'PROPERTY' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -390,7 +390,7 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { delete[] propValue; propName = NULL; propValue = NULL; - Game->LOG(0, "Syntax error in PROPERTY definition"); + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { @@ -398,12 +398,12 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { delete[] propValue; propName = NULL; propValue = NULL; - Game->LOG(0, "Error loading PROPERTY definition"); + _gameRef->LOG(0, "Error loading PROPERTY definition"); return STATUS_FAILED; } - CScValue *val = new CScValue(Game); + CScValue *val = new CScValue(_gameRef); val->setString(propValue); scSetProperty(propName, val); @@ -431,12 +431,12 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { for (int i = _scripts.getSize() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { - CScScript *thread = new CScScript(Game, _scripts[i]->_engine); + CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); if (thread) { ERRORCODE ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { _scripts[i]->_engine->_scripts.add(thread); - Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); + _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); return thread; } else { diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index 8e93a8914e..b61398c9b2 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -40,7 +40,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa _refCount = 0; if (noValue) _scValue = NULL; - else _scValue = new CScValue(Game); + else _scValue = new CScValue(_gameRef); _persistable = persistable; @@ -50,7 +50,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa ////////////////////////////////////////////////////////////////////////// CBScriptable::~CBScriptable() { - //if(_refCount>0) Game->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); delete _scValue; delete _scProp; _scValue = NULL; @@ -75,7 +75,7 @@ ERRORCODE CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStac ////////////////////////////////////////////////////////////////////////// CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(Game); + if (!_scProp) _scProp = new CScValue(_gameRef); if (_scProp) return _scProp->getProp(name); else return NULL; } @@ -83,7 +83,7 @@ CScValue *CBScriptable::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(Game); + if (!_scProp) _scProp = new CScValue(_gameRef); if (_scProp) return _scProp->setProp(name, value); else return STATUS_FAILED; } @@ -140,7 +140,7 @@ void CBScriptable::scSetBool(bool val) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBScriptable::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); persistMgr->transfer(TMEMBER(_scValue)); diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index c5fdb11ade..9f9fa1a050 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -57,7 +57,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CBSound::~CBSound() { - if (_sound) Game->_soundMgr->removeSound(_sound); + if (_sound) _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; delete[] _soundFilename; @@ -68,13 +68,13 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { - Game->_soundMgr->removeSound(_sound); + _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; } delete[] _soundFilename; _soundFilename = NULL; - _sound = Game->_soundMgr->addSound(filename, type, streamed); + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); if (_sound) { _soundFilename = new char[strlen(filename) + 1]; strcpy(_soundFilename, filename); @@ -89,7 +89,7 @@ ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSound::setSoundSimple() { - _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->setPosition(_soundPosition); _sound->setLooping(_soundLooping); @@ -164,7 +164,7 @@ ERRORCODE CBSound::persist(CBPersistMgr *persistMgr) { _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_soundFilename)); persistMgr->transfer(TMEMBER(_soundLooping)); diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 2448451784..77ff119e7b 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -104,9 +104,9 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { #endif // Load a file, but avoid having the File-manager handle the disposal of it. - _file = Game->_fileManager->openFile(filename, true, false); + _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) { - Game->LOG(0, "Error opening sound file '%s'", filename); + _gameRef->LOG(0, "Error opening sound file '%s'", filename); return STATUS_FAILED; } Common::String strFilename(filename); @@ -144,7 +144,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); if (!_stream) { - Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); + _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); return STATUS_FAILED; } @@ -155,13 +155,13 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { bool NewlyCreated = false; if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = Game->_fileManager->openFile(filename); + if(!_file) _file = _gameRef->_fileManager->openFile(filename); if(!_file){ - Game->LOG(0, "Error opening sound file '%s'", filename); + _gameRef->LOG(0, "Error opening sound file '%s'", filename); return STATUS_FAILED; } // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true); + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); } // create buffer @@ -170,7 +170,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { res = InitializeBuffer(_file); if(DID_FAIL(res)){ - Game->LOG(res, "Error creating sound buffer for file '%s'", filename); + _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); return res; } } @@ -185,7 +185,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { // close file (if not streaming) if(!_streamed && _file){ - Game->_fileManager->closeFile(_file); + _gameRef->_fileManager->closeFile(_file); _file = NULL; } */ @@ -281,7 +281,7 @@ void CBSoundBuffer::updateVolume() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSoundBuffer::setVolume(int volume) { - _volume = volume * Game->_soundMgr->getMasterVolume() / 255; + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; if (_stream && _handle) { byte vol = (byte)(_volume); g_system->getMixer()->setChannelVolume(*_handle, vol); diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 0cc0020e1e..02fd146701 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -74,7 +74,7 @@ ERRORCODE CBSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void CBSoundMgr::saveSettings() { if (_soundAvailable) { - Game->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); } } @@ -85,7 +85,7 @@ ERRORCODE CBSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = Game->_registry->readInt("Audio", "MasterVolume", 255); + _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; return STATUS_OK; @@ -118,12 +118,12 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp AnsiString name = PathUtil::getFileNameWithoutExtension(filename); AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (Game->_fileManager->hasFile(newFile)) { + if (_gameRef->_fileManager->hasFile(newFile)) { filename = newFile.c_str(); } } - sound = new CBSoundBuffer(Game); + sound = new CBSoundBuffer(_gameRef); if (!sound) return NULL; sound->setStreaming(streamed); @@ -132,7 +132,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp ERRORCODE res = sound->loadFromFile(filename); if (DID_FAIL(res)) { - Game->LOG(res, "Error loading sound '%s'", filename); + _gameRef->LOG(res, "Error loading sound '%s'", filename); delete sound; return NULL; } @@ -281,7 +281,7 @@ ERRORCODE CBSoundMgr::resumeAll() { ////////////////////////////////////////////////////////////////////////// float CBSoundMgr::posToPan(int x, int y) { - float relPos = (float)x / ((float)Game->_renderer->_width); + float relPos = (float)x / ((float)_gameRef->_renderer->_width); float minPan = -0.7f; float maxPan = 0.7f; diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index f33b5764c6..d2dd619517 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -123,13 +123,13 @@ ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, flo ////////////////////////////////////////////////////////////////////// ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = Game->_fileManager->openFile(filename); + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { - Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + if (_gameRef->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); else return loadFile("invalid.bmp", lifeTime, cacheType); } else { - Game->_fileManager->closeFile(file); + _gameRef->_fileManager->closeFile(file); file = NULL; } @@ -137,11 +137,11 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(Game); - CBSubFrame *subframe = new CBSubFrame(Game); + CBFrame *frame = new CBFrame(_gameRef); + CBSubFrame *subframe = new CBSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { - Game->LOG(0, "Error loading simple sprite '%s'", filename); + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); ret = STATUS_FAILED; delete frame; delete subframe; @@ -153,9 +153,9 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp ret = STATUS_OK; } } else { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); delete [] buffer; } } @@ -208,14 +208,14 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); cleanup(); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - Game->LOG(0, "'SPRITE' keyword expected."); + _gameRef->LOG(0, "'SPRITE' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -262,7 +262,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit break; case TOKEN_EDITOR_BG_FILE: - if (Game->_editorMode) { + if (_gameRef->_editorMode) { delete[] _editorBgFile; _editorBgFile = new char[strlen((char *)params) + 1]; if (_editorBgFile) strcpy(_editorBgFile, (char *)params); @@ -287,11 +287,11 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit int FrameLifeTime = lifeTime; if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - frame = new CBFrame(Game); + frame = new CBFrame(_gameRef); if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; - Game->LOG(0, "Error parsing frame %d", frameCount); + _gameRef->LOG(0, "Error parsing frame %d", frameCount); return STATUS_FAILED; } @@ -308,7 +308,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SPRITE definition"); + _gameRef->LOG(0, "Syntax error in SPRITE definition"); return STATUS_FAILED; } _canBreak = !_continuous; @@ -332,13 +332,13 @@ void CBSprite::reset() { ////////////////////////////////////////////////////////////////////// bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true; + //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; uint32 timer; - if (_owner && _owner->_freezable) timer = Game->_timer; - else timer = Game->_liveTimer; + if (_owner && _owner->_freezable) timer = _gameRef->_timer; + else timer = _gameRef->_liveTimer; int lastFrame = _currentFrame; @@ -392,11 +392,11 @@ ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float killAllSounds(); } applyEvent("FrameChanged"); - _frames[_currentFrame]->oneTimeDisplay(_owner, Game->_editorMode && _editorMuted); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); } // draw frame - return _frames[_currentFrame]->draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); + return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); } @@ -566,9 +566,9 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(Game); + CBFrame *frame = new CBFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.add(sub); @@ -594,9 +594,9 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(Game); + CBFrame *frame = new CBFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(Game); + CBSubFrame *sub = new CBSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); else delete sub; } diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 9098994054..e2cbec3691 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -54,7 +54,7 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report if (key == NULL || val == NULL) return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { - Game->_textRTL = true; + _gameRef->_textRTL = true; return STATUS_OK; } @@ -62,7 +62,7 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report finalKey.toLowercase(); _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); _strings[finalKey] = val; @@ -103,7 +103,7 @@ char *CBStringTable::getKey(const char *str) { ////////////////////////////////////////////////////////////////////////// void CBStringTable::expand(char **str, bool forceExpand) { - if (Game->_doNotExpandStrings && !forceExpand) return; + if (_gameRef->_doNotExpandStrings && !forceExpand) return; if (str == NULL || *str == NULL || *str[0] != '/') return; @@ -138,7 +138,7 @@ void CBStringTable::expand(char **str, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { - if (Game->_doNotExpandStrings && !forceExpand) return string; + if (_gameRef->_doNotExpandStrings && !forceExpand) return string; if (string == NULL || string[0] == '\0' || string[0] != '/') return string; @@ -170,14 +170,14 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) { - Game->LOG(0, "Loading string table..."); + _gameRef->LOG(0, "Loading string table..."); if (clearOld) _strings.clear(); uint32 size; - byte *buffer = Game->_fileManager->readWholeFile(filename, &size); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { - Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -185,12 +185,12 @@ ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) { if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { pos += 3; - if (Game->_textEncoding != TEXT_UTF8) { - Game->_textEncoding = TEXT_UTF8; - //Game->_textEncoding = TEXT_ANSI; - Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); } - } else Game->_textEncoding = TEXT_ANSI; + } else _gameRef->_textEncoding = TEXT_ANSI; uint32 lineLength = 0; while (pos < size) { @@ -221,7 +221,7 @@ ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) { delete [] buffer; - Game->LOG(0, " %d strings loaded", _strings.size()); + _gameRef->LOG(0, " %d strings loaded", _strings.size()); return STATUS_OK; } diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 19c1bcc5f2..62bf0d9f87 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -68,7 +68,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// CBSubFrame::~CBSubFrame() { - if (_surface) Game->_surfaceStorage->removeSurface(_surface); + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; } @@ -109,7 +109,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -177,7 +177,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in SUBFRAME definition"); + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); return STATUS_FAILED; } @@ -192,7 +192,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { /* if(_surface == NULL) { - Game->LOG(0, "Error parsing sub-frame. Image not set."); + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); return STATUS_FAILED; } */ @@ -209,12 +209,12 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } - if (Game->_suspendedRendering) return STATUS_OK; + if (_gameRef->_suspendedRendering) return STATUS_OK; ERRORCODE res; @@ -363,7 +363,7 @@ ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack CScValue *Val = stack->pop(); if (Val->isNULL()) { - if (_surface) Game->_surfaceStorage->removeSurface(_surface); + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; stack->pushBool(true); @@ -384,7 +384,7 @@ ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack ////////////////////////////////////////////////////////////////////////// CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(Game); + if (!_scValue) _scValue = new CScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -551,14 +551,14 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { - Game->_surfaceStorage->removeSurface(_surface); + _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; } delete[] _surfaceFilename; _surfaceFilename = NULL; - _surface = Game->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); if (_surface) { _surfaceFilename = new char[strlen(filename) + 1]; strcpy(_surfaceFilename, filename); @@ -581,7 +581,7 @@ ERRORCODE CBSubFrame::setSurfaceSimple() { _surface = NULL; return STATUS_OK; } - _surface = Game->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); if (_surface) return STATUS_OK; else return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 0d96a73d41..8a6d2b2f1d 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -134,10 +134,10 @@ ERRORCODE CBSurface::invalidate() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurface::prepareToDraw() { - _lastUsedTime = Game->_liveTimer; + _lastUsedTime = _gameRef->_liveTimer; if (!_valid) { - //Game->LOG(0, "Reviving: %s", _filename); + //_gameRef->LOG(0, "Reviving: %s", _filename); return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); } else return STATUS_OK; } diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index bbdfeca3d7..58a09dbe56 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -67,8 +67,8 @@ CBSurfaceSDL::~CBSurfaceSDL() { delete[] _alphaMask; _alphaMask = NULL; - Game->addMem(-_width * _height * 4); - CBRenderSDL *renderer = static_cast(Game->_renderer); + _gameRef->addMem(-_width * _height * 4); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); } @@ -92,7 +92,7 @@ bool hasTransparency(Graphics::Surface *surf) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* CBRenderSDL *renderer = static_cast(Game->_renderer); */ + /* CBRenderSDL *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); @@ -117,7 +117,7 @@ ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, } void CBSurfaceSDL::finishLoad() { - CBImage *image = new CBImage(Game); + CBImage *image = new CBImage(_gameRef); image->loadFile(_filename); _width = image->getSurface()->w; @@ -183,7 +183,7 @@ void CBSurfaceSDL::finishLoad() { _valid = true; - Game->addMem(_width * _height * 4); + _gameRef->addMem(_width * _height * 4); delete image; @@ -276,13 +276,13 @@ uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { ERRORCODE CBSurfaceSDL::create(int width, int height) { warning("SurfaceSDL::Create not ported yet"); //TODO #if 0 - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); #endif _width = width; _height = height; - Game->addMem(_width * _height * 4); + _gameRef->addMem(_width * _height * 4); _valid = true; @@ -293,7 +293,7 @@ ERRORCODE CBSurfaceSDL::create(int width, int height) { ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); #endif if (_surface) { @@ -306,7 +306,7 @@ ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { _width = surface->w; _height = surface->h; #if 0 - Game->AddMem(_width * _height * 4); + _gameRef->AddMem(_width * _height * 4); #endif _valid = true; @@ -390,7 +390,7 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { ERRORCODE CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; } @@ -437,7 +437,7 @@ ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect3 ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); if (!_loaded) { finishLoad(); @@ -523,7 +523,7 @@ ERRORCODE CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlp _loaded = true; _surface->copyFrom(surface); _hasAlpha = hasAlpha; - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 20a905b62a..cb48f3657b 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -53,7 +53,7 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::cleanup(bool warn) { for (int i = 0; i < _surfaces.getSize(); i++) { - if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.removeAll(); @@ -64,14 +64,14 @@ ERRORCODE CBSurfaceStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBSurfaceStorage::initLoop() { - if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) { - _lastCleanupTime = Game->_liveTimer; + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); for (int i = 0; i < _surfaces.getSize(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { - //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } } @@ -105,16 +105,16 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by } } - if (!Game->_fileManager->hasFile(filename)) { - if (filename) Game->LOG(0, "Missing image: '%s'", filename); - if (Game->_dEBUG_DebugMode) + if (!_gameRef->_fileManager->hasFile(filename)) { + if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); + if (_gameRef->_dEBUG_DebugMode) return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); else return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); } CBSurface *surface; - surface = new CBSurfaceSDL(Game); + surface = new CBSurfaceSDL(_gameRef); if (!surface) return NULL; @@ -135,7 +135,7 @@ ERRORCODE CBSurfaceStorage::restoreAll() { for (int i = 0; i < _surfaces.getSize(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { - Game->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); return ret; } } @@ -150,7 +150,7 @@ ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr) if(!persistMgr->_saving) cleanup(false); - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); //_surfaces.persist(persistMgr); diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 778ac33a3f..537fb0f2f5 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -68,8 +68,8 @@ ERRORCODE CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { if (nonInteractive) { _preserveInteractive = true; - _origInteractive = Game->_interactive; - Game->_interactive = false; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; } /*else _preserveInteractive */; @@ -100,7 +100,7 @@ ERRORCODE CBTransitionMgr::update() { uint32 time = CBPlatform::getTime() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); - Game->_renderer->fade((uint16)alpha); + _gameRef->_renderer->fade((uint16)alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; @@ -111,7 +111,7 @@ ERRORCODE CBTransitionMgr::update() { uint32 time = CBPlatform::getTime() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); - Game->_renderer->fade((uint16)alpha); + _gameRef->_renderer->fade((uint16)alpha); if (time > FADE_DURATION) _state = TRANS_MGR_READY; @@ -123,7 +123,7 @@ ERRORCODE CBTransitionMgr::update() { if (isReady()) { if (_preserveInteractive) - Game->_interactive = _origInteractive; + _gameRef->_interactive = _origInteractive; } return STATUS_OK; } diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index f1f28bc78b..a245baf26d 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -51,7 +51,7 @@ CBViewport::~CBViewport() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBViewport::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_mainObject)); persistMgr->transfer(TMEMBER(_offsetX)); @@ -67,8 +67,8 @@ ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noC if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); - right = MIN(right, Game->_renderer->_width); - bottom = MIN(bottom, Game->_renderer->_height); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); } CBPlatform::setRect(&_rect, left, top, right, bottom); diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 266d19b46c..3768578987 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -70,17 +70,17 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { delete [] tempFilename; char slotFilename[MAX_PATH_LENGTH + 1]; - Game->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(Game); + _gameRef->getSaveSlotFilename(slot, slotFilename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); if (!pm) return STATUS_FAILED; - Game->_dEBUG_AbsolutePathWarning = false; + _gameRef->_dEBUG_AbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(slotFilename))) { - Game->_dEBUG_AbsolutePathWarning = true; + _gameRef->_dEBUG_AbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - Game->_dEBUG_AbsolutePathWarning = true; + _gameRef->_dEBUG_AbsolutePathWarning = true; ERRORCODE res; diff --git a/engines/wintermute/Base/font/BFont.cpp b/engines/wintermute/Base/font/BFont.cpp index b59188d0c1..b910bdbd90 100644 --- a/engines/wintermute/Base/font/BFont.cpp +++ b/engines/wintermute/Base/font/BFont.cpp @@ -73,9 +73,9 @@ int CBFont::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// ERRORCODE CBFont::loadFile(const char * Filename) { - BYTE* Buffer = Game->_fileManager->readWholeFile(filename); + BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); if(Buffer==NULL){ - Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -84,7 +84,7 @@ ERRORCODE CBFont::loadFile(const char * Filename) _filename = new char [strlen(filename)+1]; strcpy(_filename, filename); - if(DID_FAIL(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); delete [] Buffer; @@ -104,10 +104,10 @@ ERRORCODE CBFont::loadBuffer(byte * Buffer) char* params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - Game->LOG(0, "'FONT' keyword expected."); + _gameRef->LOG(0, "'FONT' keyword expected."); return STATUS_FAILED; } Buffer = (byte *)params; @@ -129,7 +129,7 @@ ERRORCODE CBFont::loadBuffer(byte * Buffer) } if (cmd == PARSERR_TOKENNOTFOUND){ - Game->LOG(0, "Syntax error in FONT definition"); + _gameRef->LOG(0, "Syntax error in FONT definition"); return STATUS_FAILED; } @@ -152,9 +152,9 @@ ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { - if (isTrueType(Game, filename)) { - CBFontTT *font = new CBFontTT(Game); +CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { + if (isTrueType(gameRef, filename)) { + CBFontTT *font = new CBFontTT(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -163,7 +163,7 @@ CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) { } return font; } else { - CBFontBitmap *font = new CBFontBitmap(Game); + CBFontBitmap *font = new CBFontBitmap(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -180,20 +180,20 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *Game, const char *filename) { +bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) TOKEN_TABLE_END - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) return false; byte *WorkBuffer = buffer; char *params; - CBParser parser(Game); + CBParser parser(gameRef); bool ret = false; if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp index 681f2580bf..96a6387070 100644 --- a/engines/wintermute/Base/font/BFontBitmap.cpp +++ b/engines/wintermute/Base/font/BFontBitmap.cpp @@ -85,7 +85,7 @@ int CBFontBitmap::getTextHeight(byte *text, int width) { int CBFontBitmap::getTextWidth(byte *text, int maxLength) { AnsiString str; - if (Game->_textEncoding == TEXT_UTF8) { + if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); str = StringUtil::wideToAnsi(wstr); } else { @@ -113,7 +113,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign AnsiString str; - if (Game->_textEncoding == TEXT_UTF8) { + if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); str = StringUtil::wideToAnsi(wstr); } else { @@ -136,11 +136,11 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign bool new_line = false; bool long_line = false; - if (draw) Game->_renderer->startSpriteBatch(); + if (draw) _gameRef->_renderer->startSpriteBatch(); while (!done) { if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) Game->_renderer->endSpriteBatch(); + if (draw) _gameRef->_renderer->endSpriteBatch(); return NumLines * _tileHeight; } @@ -206,7 +206,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign } } - if (draw) Game->_renderer->endSpriteBatch(); + if (draw) _gameRef->_renderer->endSpriteBatch(); return NumLines * _tileHeight; } @@ -244,9 +244,9 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// ERRORCODE CBFontBitmap::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -255,7 +255,7 @@ ERRORCODE CBFontBitmap::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); delete [] buffer; @@ -304,10 +304,10 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - Game->LOG(0, "'FONT' keyword expected."); + _gameRef->LOG(0, "'FONT' keyword expected."); return STATUS_FAILED; } buffer = (byte *)params; @@ -395,13 +395,13 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in FONT definition"); + _gameRef->LOG(0, "Syntax error in FONT definition"); return STATUS_FAILED; } if (spriteFile != NULL) { delete _sprite; - _sprite = new CBSprite(Game, this); + _sprite = new CBSprite(_gameRef, this); if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { delete _sprite; _sprite = NULL; @@ -409,14 +409,14 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { } if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(Game); + _subframe = new CBSubFrame(_gameRef); if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); else _subframe->setSurface(surfaceFile); } if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - Game->LOG(0, "Incomplete font definition"); + _gameRef->LOG(0, "Incomplete font definition"); return STATUS_FAILED; } @@ -523,10 +523,10 @@ ERRORCODE CBFontBitmap::getWidths() { } surf->endPixelOp(); /* - Game->LOG(0, "----- %s ------", _filename); + _gameRef->LOG(0, "----- %s ------", _filename); for(int j=0; j<16; j++) { - Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); } */ return STATUS_OK; diff --git a/engines/wintermute/Base/font/BFontStorage.cpp b/engines/wintermute/Base/font/BFontStorage.cpp index 5a0a1e327f..c9c6df9f6e 100644 --- a/engines/wintermute/Base/font/BFontStorage.cpp +++ b/engines/wintermute/Base/font/BFontStorage.cpp @@ -53,7 +53,7 @@ CBFontStorage::~CBFontStorage() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CBFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; } _fonts.removeAll(); @@ -81,7 +81,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { } /* - CBFont* font = new CBFont(Game); + CBFont* font = new CBFont(_gameRef); if (!font) return NULL; if (DID_FAIL(font->loadFile(filename))) { @@ -94,7 +94,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { return font; } */ - CBFont *font = CBFont::createFromFile(Game, filename); + CBFont *font = CBFont::createFromFile(_gameRef, filename); if (font) { font->_refCount = 1; _fonts.add(font); @@ -126,7 +126,7 @@ ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(false); - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); _fonts.persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index c87a5b4a5f..e77d95985b 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -106,7 +106,7 @@ void CBFontTT::clearCache() { ////////////////////////////////////////////////////////////////////////// void CBFontTT::initLoop() { // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (Game->_constrainedMemory) { + if (_gameRef->_constrainedMemory) { // purge all cached images not used in the last frame for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i] == NULL) continue; @@ -123,7 +123,7 @@ void CBFontTT::initLoop() { int CBFontTT::getTextWidth(byte *text, int maxLength) { WideString textStr; - if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); else textStr = StringUtil::ansiToWide((char *)text); if (maxLength >= 0 && textStr.size() > (uint32)maxLength) @@ -140,7 +140,7 @@ int CBFontTT::getTextWidth(byte *text, int maxLength) { int CBFontTT::getTextHeight(byte *text, int width) { WideString textStr; - if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); else textStr = StringUtil::ansiToWide((char *)text); @@ -158,14 +158,14 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i WideString textStr = (char *)text; // TODO: Why do we still insist on Widestrings everywhere? - /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ if (maxLength >= 0 && textStr.size() > (uint32)maxLength) textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove - CBRenderer *renderer = Game->_renderer; + CBRenderer *renderer = _gameRef->_renderer; // find cached surface, if exists int minPriority = INT_MAX; @@ -272,7 +272,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex heightOffset += (int)_lineHeight; } - CBSurface *retSurface = Game->_renderer->createSurface(); + CBSurface *retSurface = _gameRef->_renderer->createSurface(); Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); @@ -361,7 +361,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex posY += GetLineHeight(); } - CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game); + CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(_gameRef); if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { SDL_FreeSurface(surface); return wmeSurface; @@ -406,9 +406,9 @@ int CBFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// ERRORCODE CBFontTT::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -417,7 +417,7 @@ ERRORCODE CBFontTT::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); delete [] buffer; @@ -460,10 +460,10 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - Game->LOG(0, "'TTFONT' keyword expected."); + _gameRef->LOG(0, "'TTFONT' keyword expected."); return STATUS_FAILED; } buffer = (byte *)params; @@ -532,7 +532,7 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TTFONT definition"); + _gameRef->LOG(0, "Syntax error in TTFONT definition"); return STATUS_FAILED; } @@ -560,7 +560,7 @@ ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { char *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -638,13 +638,13 @@ void CBFontTT::afterLoad() { ERRORCODE CBFontTT::initFont() { if (!_fontFile) return STATUS_FAILED; - Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile); + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = Game->_fileManager->openFile(fontFileName.c_str(), false); + file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { - Game->LOG(0, "Error loading TrueType font '%s'", _fontFile); + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return STATUS_FAILED; } } @@ -680,10 +680,10 @@ ERRORCODE CBFontTT::initFont() { args.flags = FT_OPEN_STREAM; args.stream = _fTStream; - error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); if (error) { SAFE_DELETE_ARRAY(_fTStream); - Game->_fileManager->closeFile(file); + _gameRef->_fileManager->closeFile(file); return STATUS_FAILED; } diff --git a/engines/wintermute/Base/particles/PartEmitter.cpp b/engines/wintermute/Base/particles/PartEmitter.cpp index 9a92d2aa6e..dc76dd696d 100644 --- a/engines/wintermute/Base/particles/PartEmitter.cpp +++ b/engines/wintermute/Base/particles/PartEmitter.cpp @@ -125,11 +125,11 @@ ERRORCODE CPartEmitter::addSprite(const char *filename) { } // check if file exists - Common::SeekableReadStream *File = Game->_fileManager->openFile(filename); + Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); if (!File) { - Game->LOG(0, "Sprite '%s' not found", filename); + _gameRef->LOG(0, "Sprite '%s' not found", filename); return STATUS_FAILED; - } else Game->_fileManager->closeFile(File); + } else _gameRef->_fileManager->closeFile(File); char *Str = new char[strlen(filename) + 1]; strcpy(Str, filename); @@ -228,7 +228,7 @@ ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::update() { if (!_running) return STATUS_OK; - else return updateInternal(Game->_timer, Game->_timerDelta); + else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); } ////////////////////////////////////////////////////////////////////////// @@ -266,7 +266,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { CPartParticle *particle; if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; else { - particle = new CPartParticle(Game); + particle = new CPartParticle(_gameRef); _particles.add(particle); } initParticle(particle, currentTime, timerDelta); @@ -289,7 +289,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CPartEmitter::display(CBRegion *region) { - if (_sprites.getSize() <= 1) Game->_renderer->startSpriteBatch(); + if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.getSize(); i++) { if (region != NULL && _useRegion) { @@ -299,7 +299,7 @@ ERRORCODE CPartEmitter::display(CBRegion *region) { _particles[i]->display(this); } - if (_sprites.getSize() <= 1) Game->_renderer->endSpriteBatch(); + if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); return STATUS_OK; } @@ -316,7 +316,7 @@ ERRORCODE CPartEmitter::start() { if (_overheadTime > 0) { uint32 delta = 500; int steps = _overheadTime / delta; - uint32 currentTime = Game->_timer - _overheadTime; + uint32 currentTime = _gameRef->_timer - _overheadTime; for (int i = 0; i < steps; i++) { updateInternal(currentTime, delta); @@ -373,7 +373,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { } } if (!force) { - force = new CPartForce(Game); + force = new CPartForce(_gameRef); if (force) { force->setName(name); _forces.add(force); @@ -1171,7 +1171,7 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(Game); + CPartForce *force = new CPartForce(_gameRef); force->persist(persistMgr); _forces.add(force); } @@ -1187,7 +1187,7 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(Game); + CPartParticle *particle = new CPartParticle(_gameRef); particle->persist(persistMgr); _particles.add(particle); } diff --git a/engines/wintermute/Base/particles/PartParticle.cpp b/engines/wintermute/Base/particles/PartParticle.cpp index 10a8e6f51b..ebb7fe9f7a 100644 --- a/engines/wintermute/Base/particles/PartParticle.cpp +++ b/engines/wintermute/Base/particles/PartParticle.cpp @@ -82,7 +82,7 @@ ERRORCODE CPartParticle::setSprite(const char *filename) { _sprite = NULL; CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(Game, Game); + _sprite = new CBSprite(_gameRef, _gameRef); if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { CSysClassRegistry::getInstance()->_disabled = false; return STATUS_OK; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 204a1170e2..a52a83db0a 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -43,7 +43,7 @@ CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; - _values = new CScValue(Game); + _values = new CScValue(_gameRef); int numParams = stack->pop()->getInt(0); @@ -61,7 +61,7 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { _length = 0; - _values = new CScValue(Game); + _values = new CScValue(_gameRef); } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index caab59a89e..cc30c14e93 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -80,7 +80,7 @@ void CSXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// void CSXFile::close() { if (_readFile) { - Game->_fileManager->closeFile(_readFile); + _gameRef->_fileManager->closeFile(_readFile); _readFile = NULL; } if (_writeFile) { @@ -125,7 +125,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th _mode = 1; } if (_mode == 1) { - _readFile = Game->_fileManager->openFile(_filename); + _readFile = _gameRef->_fileManager->openFile(_filename); if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); close(); @@ -739,7 +739,7 @@ ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) { if (_mode != 0) { // open for reading if (_mode == 1) { - _readFile = Game->_fileManager->openFile(_filename); + _readFile = _gameRef->_fileManager->openFile(_filename); if (!_readFile) close(); } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 0854cfb505..428a58a997 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -264,7 +264,7 @@ ERRORCODE CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStac stack->pushNULL(); else { void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(Game, pointer); + CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); stack->pushNative(buf, false); } return STATUS_OK; diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 2ad8a36ff7..5e7043ee19 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -112,7 +112,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * //try { WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); @@ -120,7 +120,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * //WideString subStr = str.substr(start, end - start + 1); WideString subStr(str.c_str() + start, end - start + 1); - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); else stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); @@ -150,7 +150,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * // try { WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); @@ -158,7 +158,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * // WideString subStr = str.substr(start, len); WideString subStr(str.c_str() + start, len); - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); else stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); @@ -176,14 +176,14 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(0); WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); str.toUppercase(); - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(str).c_str()); else stack->pushString(StringUtil::wideToAnsi(str).c_str()); @@ -198,14 +198,14 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(0); WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); str.toLowercase(); - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) stack->pushString(StringUtil::wideToUtf8(str).c_str()); else stack->pushString(StringUtil::wideToAnsi(str).c_str()); @@ -223,13 +223,13 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * int index = stack->pop()->getInt(); WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); WideString toFind; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) toFind = StringUtil::utf8ToWide(strToFind); else toFind = StringUtil::ansiToWide(strToFind); @@ -249,7 +249,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * char separators[MAX_PATH_LENGTH] = ","; if (!val->isNULL()) strcpy(separators, val->getString()); - CSXArray *array = new CSXArray(Game); + CSXArray *array = new CSXArray(_gameRef); if (!array) { stack->pushNULL(); return STATUS_OK; @@ -257,13 +257,13 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * WideString str; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) str = StringUtil::utf8ToWide(_string); else str = StringUtil::ansiToWide(_string); WideString delims; - if (Game->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) delims = StringUtil::utf8ToWide(separators); else delims = StringUtil::ansiToWide(separators); @@ -298,10 +298,10 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); - if (Game->_textEncoding == TEXT_UTF8) - val = new CScValue(Game, StringUtil::wideToUtf8(part).c_str()); + if (_gameRef->_textEncoding == TEXT_UTF8) + val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); else - val = new CScValue(Game, StringUtil::wideToAnsi(part).c_str()); + val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); array->push(val); delete val; @@ -331,7 +331,7 @@ CScValue *CSXString::scGetProperty(const char *name) { // Length (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Length") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { + if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); } else @@ -358,7 +358,7 @@ ERRORCODE CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) Game->LOG(0, "Warning: cannot lower string capacity"); + if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); else if (newCap != _capacity) { char *newStr = new char[newCap]; if (newStr) { diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index ea651e69bf..d976707ce2 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -46,25 +46,25 @@ IMPLEMENT_PERSISTENT(CScEngine, true) #define COMPILER_DLL "dcscomp.dll" ////////////////////////////////////////////////////////////////////////// CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { - Game->LOG(0, "Initializing scripting engine..."); + _gameRef->LOG(0, "Initializing scripting engine..."); - if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly"); - else Game->LOG(0, " Script compiler is NOT available"); + if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); + else _gameRef->LOG(0, " Script compiler is NOT available"); - _globals = new CScValue(Game); + _globals = new CScValue(_gameRef); // register 'Game' as global variable if (!_globals->propExists("Game")) { - CScValue val(Game); - val.setNative(Game, true); + CScValue val(_gameRef); + val.setNative(_gameRef, true); _globals->setProp("Game", &val); } // register 'Math' as global variable if (!_globals->propExists("Math")) { - CScValue val(Game); - val.setNative(Game->_mathClass, true); + CScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); _globals->setProp("Math", &val); } @@ -82,7 +82,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// CScEngine::~CScEngine() { - Game->LOG(0, "Shutting down scripting engine"); + _gameRef->LOG(0, "Shutting down scripting engine"); saveBreakpoints(); disableProfiling(); @@ -121,8 +121,8 @@ ERRORCODE CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *Game = (CBGame *)data; - return Game->_fileManager->readWholeFile(filename, size); + CBGame *gameRef = (CBGame *)data; + return gameRef->_fileManager->readWholeFile(filename, size); } @@ -147,15 +147,15 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { if (!compBuffer) return NULL; // add new script - CScScript *script = new CScScript(Game, this); + CScScript *script = new CScScript(_gameRef, this); ERRORCODE ret = script->create(filename, compBuffer, compSize, owner); if (DID_FAIL(ret)) { - Game->LOG(ret, "Error running script '%s'...", filename); + _gameRef->LOG(ret, "Error running script '%s'...", filename); delete script; return NULL; } else { // publish the "self" pseudo-variable - CScValue val(Game); + CScValue val(_gameRef); if (owner)val.setNative(owner, true); else val.setNULL(); @@ -163,7 +163,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { script->_globals->setProp("this", &val); _scripts.add(script); - Game->getDebugMgr()->onScriptInit(script); + _gameRef->getDebugMgr()->onScriptInit(script); return script; } @@ -189,9 +189,9 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i uint32 size; - byte *buffer = Game->_fileManager->readWholeFile(filename, &size); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (!buffer) { - Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; } @@ -201,7 +201,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i compSize = size; } else { if (!_compilerAvailable) { - Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); delete [] buffer; return NULL; } @@ -256,18 +256,18 @@ ERRORCODE CScEngine::tick() { case SCRIPT_WAITING: { /* bool obj_found=false; - for(int j=0; j_regObjects.getSize(); j++) + for(int j=0; j<_gameRef->_regObjects.getSize(); j++) { - if(Game->_regObjects[j] == _scripts[i]->_waitObject) + if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) { - if(Game->_regObjects[j]->IsReady()) _scripts[i]->Run(); + if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); obj_found = true; break; } } if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ - if (Game->validObject(_scripts[i]->_waitObject)) { + if (_gameRef->validObject(_scripts[i]->_waitObject)) { if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); } else _scripts[i]->finish(); break; @@ -277,7 +277,7 @@ ERRORCODE CScEngine::tick() { if (_scripts[i]->_waitFrozen) { if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); } else { - if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); } break; } @@ -368,7 +368,7 @@ ERRORCODE CScEngine::removeFinishedScripts() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - Game->getDebugMgr()->onScriptShutdown(_scripts[i]); + _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.removeAt(i); i--; @@ -427,7 +427,7 @@ ERRORCODE CScEngine::resetObject(CBObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!Game->_compatKillMethodThreads) resetScript(_scripts[i]); + if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well @@ -451,7 +451,7 @@ ERRORCODE CScEngine::resetScript(CScScript *script) { ERRORCODE CScEngine::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currentScript)); persistMgr->transfer(TMEMBER(_globals)); _scripts.persist(persistMgr); @@ -527,7 +527,7 @@ ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -554,7 +554,7 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { @@ -579,7 +579,7 @@ ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::refreshScriptBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _scripts.getSize(); i++) { refreshScriptBreakpoints(_scripts[i]); @@ -589,7 +589,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; if (!script || !script->_filename) return STATUS_FAILED; @@ -606,7 +606,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::saveBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; char text[512]; @@ -619,25 +619,25 @@ ERRORCODE CScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - Game->_registry->writeString("Debug", key, text); + _gameRef->_registry->writeString("Debug", key, text); } } - Game->_registry->writeInt("Debug", "NumBreakpoints", count); + _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CScEngine::loadBreakpoints() { - if (!Game->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; char key[100]; - int count = Game->_registry->readInt("Debug", "NumBreakpoints", 0); + int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { /* uint32 BufSize = 512; */ sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = Game->_registry->readString("Debug", key, ""); + AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); @@ -701,11 +701,11 @@ void CScEngine::dumpStats() { TimeVector::reverse_iterator tit; - Game->LOG(0, "***** Script profiling information: *****"); - Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); for (tit = times.rbegin(); tit != times.rend(); tit++) { - Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); }*/ } diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 40803cded6..e1cf791e31 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -125,13 +125,13 @@ ERRORCODE CScScript::initScript() { readHeader(); if (_header.magic != SCRIPT_MAGIC) { - Game->LOG(0, "File '%s' is not a valid compiled script", _filename); + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); cleanup(); return STATUS_FAILED; } if (_header.version > SCRIPT_VERSION) { - Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); cleanup(); return STATUS_FAILED; } @@ -139,13 +139,13 @@ ERRORCODE CScScript::initScript() { initTables(); // init stacks - _scopeStack = new CScStack(Game); - _callStack = new CScStack(Game); - _thisStack = new CScStack(Game); - _stack = new CScStack(Game); + _scopeStack = new CScStack(_gameRef); + _callStack = new CScStack(_gameRef); + _thisStack = new CScStack(_gameRef); + _stack = new CScStack(_gameRef); - _operand = new CScValue(Game); - _reg1 = new CScValue(Game); + _operand = new CScValue(_gameRef); + _reg1 = new CScValue(_gameRef); // skip to the beginning @@ -263,7 +263,7 @@ ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBS if (DID_FAIL(res)) return res; // establish global variables table - _globals = new CScValue(Game); + _globals = new CScValue(_gameRef); _owner = owner; @@ -476,7 +476,7 @@ ERRORCODE CScScript::executeInstruction() { uint32 dw; const char *str = NULL; - //CScValue* op = new CScValue(Game); + //CScValue* op = new CScValue(_gameRef); _operand->cleanup(); CScValue *op1; @@ -490,12 +490,12 @@ ERRORCODE CScScript::executeInstruction() { dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); } break; @@ -509,21 +509,21 @@ ERRORCODE CScScript::executeInstruction() { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); } break; } case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); + _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL); - else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -601,7 +601,7 @@ ERRORCODE CScScript::executeInstruction() { } else{ // not an internal nor external, try for native function - Game->ExternalCall(this, _stack, _thisStack, val->getString()); + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); } } else{ @@ -632,7 +632,7 @@ ERRORCODE CScScript::executeInstruction() { TExternalFunction *f = getExternal(_symbols[SymbolIndex]); if (f) { externalCall(_stack, _thisStack, f); - } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); break; } @@ -640,8 +640,8 @@ ERRORCODE CScScript::executeInstruction() { _operand->setNULL(); _scopeStack->push(_operand); - if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL); - else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); break; @@ -691,8 +691,8 @@ ERRORCODE CScScript::executeInstruction() { } } - if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->onVariableChangeValue(var, val); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, val); } break; @@ -757,8 +757,8 @@ ERRORCODE CScScript::executeInstruction() { var->setNULL(); } else var->setProp(str, val); - if (Game->getDebugMgr()->_enabled) - Game->getDebugMgr()->onVariableChangeValue(var, NULL); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); break; } @@ -1027,17 +1027,17 @@ ERRORCODE CScScript::executeInstruction() { int newLine = getDWORD(); if (newLine != _currentLine) { _currentLine = newLine; - if (Game->getDebugMgr()->_enabled) { - Game->getDebugMgr()->onScriptChangeLine(this, _currentLine); + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); for (int i = 0; i < _breakpoints.getSize(); i++) { if (_breakpoints[i] == _currentLine) { - Game->getDebugMgr()->onScriptHitBreakpoint(this); + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); sleep(0); break; } } if (_tracingMode) { - Game->getDebugMgr()->onScriptHitBreakpoint(this); + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); sleep(0); break; } @@ -1047,7 +1047,7 @@ ERRORCODE CScScript::executeInstruction() { } default: - Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); _state = SCRIPT_FINISHED; ret = STATUS_FAILED; } // switch(instruction) @@ -1102,8 +1102,8 @@ CScValue *CScScript::getVar(char *name) { if (ret == NULL) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); - Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(Game); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + CScValue *val = new CScValue(_gameRef); CScValue *scope = _scopeStack->getTop(); if (scope) { scope->setProp(name, val); @@ -1147,11 +1147,11 @@ ERRORCODE CScScript::sleep(uint32 duration) { } _state = SCRIPT_SLEEPING; - if (Game->_state == GAME_FROZEN) { + if (_gameRef->_state == GAME_FROZEN) { _waitTime = CBPlatform::getTime() + duration; _waitFrozen = true; } else { - _waitTime = Game->_timer + duration; + _waitTime = _gameRef->_timer + duration; _waitFrozen = false; } return STATUS_OK; @@ -1186,18 +1186,18 @@ void CScScript::runtimeError(const char *fmt, ...) { vsprintf(buff, fmt, va); va_end(va); - Game->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - Game->LOG(0, " %s", buff); + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); - if (!Game->_suppressScriptErrors) - Game->quickMessage("Script runtime error. View log for details."); + if (!_gameRef->_suppressScriptErrors) + _gameRef->quickMessage("Script runtime error. View log for details."); } ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); // buffer if (persistMgr->_saving) { @@ -1263,13 +1263,13 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable uint32 pos = getEventPos(eventName); if (!pos) return NULL; - CScScript *thread = new CScScript(Game, _engine); + CScScript *thread = new CScScript(_gameRef, _engine); if (thread) { ERRORCODE ret = thread->createThread(this, pos, eventName); if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); - Game->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); return thread; } else { delete thread; @@ -1304,7 +1304,7 @@ bool CScScript::canHandleMethod(const char *methodName) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::pause() { if (_state == SCRIPT_PAUSED) { - Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return STATUS_FAILED; } @@ -1339,7 +1339,7 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { - Game->LOG(0, "External functions are not supported on this platform."); + _gameRef->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); stack->pushNULL(); return STATUS_FAILED; @@ -1443,7 +1443,7 @@ void CScScript::afterLoad() { if (_buffer == NULL) { byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); if (!buffer) { - Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); _state = SCRIPT_ERROR; return; } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index 33fe9f44e8..c889b5ea9e 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -44,7 +44,7 @@ CScStack::CScStack(CBGame *inGame): CBBase(inGame) { CScStack::~CScStack() { #if _DEBUG - //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); #endif for (int i = 0; i < _values.getSize(); i++) { @@ -57,7 +57,7 @@ CScStack::~CScStack() { ////////////////////////////////////////////////////////////////////////// CScValue *CScStack::pop() { if (_sP < 0) { - Game->LOG(0, "Fatal: Stack underflow"); + _gameRef->LOG(0, "Fatal: Stack underflow"); return NULL; } @@ -73,7 +73,7 @@ void CScStack::push(CScValue *val) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { - CScValue *copyVal = new CScValue(Game); + CScValue *copyVal = new CScValue(_gameRef); copyVal->copy(val); _values.add(copyVal); } @@ -85,7 +85,7 @@ CScValue *CScStack::getPushValue() { _sP++; if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(Game); + CScValue *val = new CScValue(_gameRef); _values.add(val); } _values[_sP]->cleanup(); @@ -124,7 +124,7 @@ void CScStack::correctParams(uint32 expectedParams) { } else if (expectedParams > nuParams) { // need more params while (expectedParams > nuParams) { //Push(null_val); - CScValue *nullVal = new CScValue(Game); + CScValue *nullVal = new CScValue(_gameRef); nullVal->setNULL(); _values.insertAt(_sP - nuParams + 1, nullVal); nuParams++; @@ -142,7 +142,7 @@ void CScStack::correctParams(uint32 expectedParams) { ////////////////////////////////////////////////////////////////////////// void CScStack::pushNULL() { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setNULL(); Push(val); delete val; @@ -154,7 +154,7 @@ void CScStack::pushNULL() { ////////////////////////////////////////////////////////////////////////// void CScStack::pushInt(int val) { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setInt(Val); Push(val); delete val; @@ -166,7 +166,7 @@ void CScStack::pushInt(int val) { ////////////////////////////////////////////////////////////////////////// void CScStack::pushFloat(double val) { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setFloat(Val); Push(val); delete val; @@ -178,7 +178,7 @@ void CScStack::pushFloat(double val) { ////////////////////////////////////////////////////////////////////////// void CScStack::pushBool(bool val) { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setBool(Val); Push(val); delete val; @@ -190,7 +190,7 @@ void CScStack::pushBool(bool val) { ////////////////////////////////////////////////////////////////////////// void CScStack::pushString(const char *val) { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setString(Val); Push(val); delete val; @@ -202,7 +202,7 @@ void CScStack::pushString(const char *val) { ////////////////////////////////////////////////////////////////////////// void CScStack::pushNative(CBScriptable *val, bool persistent) { /* - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->setNative(Val, Persistent); Push(val); delete val; @@ -215,7 +215,7 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScStack::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_sP)); _values.persist(persistMgr); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index ba698fdd8d..2c5f388c3d 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -160,20 +160,20 @@ CScValue *CScValue::getProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); if (_type == VAL_STRING && strcmp(name, "Length") == 0) { - Game->_scValue->_type = VAL_INT; + _gameRef->_scValue->_type = VAL_INT; #if 0 // TODO: Remove FreeType-dependency - if (Game->_textEncoding == TEXT_ANSI) { + if (_gameRef->_textEncoding == TEXT_ANSI) { #else if (true) { #endif - Game->_scValue->setInt(strlen(_valString)); + _gameRef->_scValue->setInt(strlen(_valString)); } else { WideString wstr = StringUtil::utf8ToWide(_valString); - Game->_scValue->setInt(wstr.size()); + _gameRef->_scValue->setInt(wstr.size()); } - return Game->_scValue; + return _gameRef->_scValue; } CScValue *ret = NULL; @@ -220,7 +220,7 @@ ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, boo newVal = _valIter->_value; } if (!newVal) - newVal = new CScValue(Game); + newVal = new CScValue(_gameRef); else newVal->cleanup(); newVal->copy(val, copyWhole); @@ -235,7 +235,7 @@ ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, boo delete _valIter->_value; _valIter->_value = NULL; } - CScValue* val = new CScValue(Game); + CScValue* val = new CScValue(_gameRef); val->Copy(Val, CopyWhole); val->_isConstVar = SetAsConst; _valObject[Name] = val; @@ -663,7 +663,7 @@ TValType CScValue::getType() { ////////////////////////////////////////////////////////////////////////// void CScValue::copy(CScValue *orig, bool copyWhole) { - Game = orig->Game; + _gameRef = orig->_gameRef; if (_valNative && !_persistent) { _valNative->_refCount--; @@ -694,7 +694,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) { if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { orig->_valIter = orig->_valObject.begin(); while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(Game); + _valObject[orig->_valIter->_key] = new CScValue(_gameRef); _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } @@ -736,7 +736,7 @@ void CScValue::setValue(CScValue *val) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CScValue::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_persistent)); persistMgr->transfer(TMEMBER(_isConstVar)); @@ -890,7 +890,7 @@ ERRORCODE CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariab ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(Game, value); + CScValue *val = new CScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -898,7 +898,7 @@ bool CScValue::setProperty(const char *propName, int value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(Game, value); + CScValue *val = new CScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -906,7 +906,7 @@ bool CScValue::setProperty(const char *propName, const char *value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(Game, value); + CScValue *val = new CScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -915,7 +915,7 @@ bool CScValue::setProperty(const char *propName, double value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(Game, value); + CScValue *val = new CScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -924,7 +924,7 @@ bool CScValue::setProperty(const char *propName, bool value) { ////////////////////////////////////////////////////////////////////////// bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(Game); + CScValue *val = new CScValue(_gameRef); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 0bf3f95e9e..df656d13f6 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -40,11 +40,11 @@ namespace WinterMute { -CBGame *CBPlatform::Game = NULL; +CBGame *CBPlatform::_gameRef = NULL; #define CLASS_NAME "GF_FRAME" int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) { - Game = inGame; + _gameRef = inGame; return true; } @@ -53,48 +53,48 @@ void CBPlatform::handleEvent(Common::Event *event) { switch (event->type) { case Common::EVENT_LBUTTONDOWN: - if (Game) { - if (Game->isLeftDoubleClick()) Game->onMouseLeftDblClick(); - else Game->onMouseLeftDown(); + if (_gameRef) { + if (_gameRef->isLeftDoubleClick()) _gameRef->onMouseLeftDblClick(); + else _gameRef->onMouseLeftDown(); } break; case Common::EVENT_RBUTTONDOWN: - if (Game) { - if (Game->isRightDoubleClick()) Game->onMouseRightDblClick(); - else Game->onMouseRightDown(); + if (_gameRef) { + if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick(); + else _gameRef->onMouseRightDown(); } break; case Common::EVENT_MBUTTONDOWN: - if (Game) Game->onMouseMiddleDown(); + if (_gameRef) _gameRef->onMouseMiddleDown(); break; case Common::EVENT_LBUTTONUP: - if (Game) Game->onMouseLeftUp(); + if (_gameRef) _gameRef->onMouseLeftUp(); break; case Common::EVENT_RBUTTONUP: - if (Game) Game->onMouseRightUp(); + if (_gameRef) _gameRef->onMouseRightUp(); break; case Common::EVENT_MBUTTONUP: - if (Game) Game->onMouseMiddleUp(); + if (_gameRef) _gameRef->onMouseMiddleUp(); break; case Common::EVENT_KEYDOWN: - if (Game) Game->handleKeypress(event); + if (_gameRef) _gameRef->handleKeypress(event); break; case Common::EVENT_KEYUP: - if (Game) Game->handleKeyRelease(event); + if (_gameRef) _gameRef->handleKeyRelease(event); break; case Common::EVENT_WHEELUP: case Common::EVENT_WHEELDOWN: - if (Game) Game->handleMouseWheel(event->mouse.y); + if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); break; /*#ifdef __IPHONEOS__ { - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); POINT p; GetCursorPos(&p); - Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); + _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - if (Game->_activeObject != NULL && strcmp(Game->_activeObject->getClassName(), "CUIButton") == 0) { - CUIButton *btn = static_cast(Game->_activeObject); + if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "CUIButton") == 0) { + CUIButton *btn = static_cast(_gameRef->_activeObject); if (btn->_visible && !btn->_disable) btn->_press = true; } } @@ -102,25 +102,25 @@ void CBPlatform::handleEvent(Common::Event *event) { //TODO /* case SDL_MOUSEWHEEL: - if (Game) Game->handleMouseWheel(event->wheel.y); + if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y); break; case SDL_KEYDOWN: case SDL_TEXTINPUT: - if (Game) Game->handleKeypress(event); + if (_gameRef) _gameRef->handleKeypress(event); break; case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_RESTORED: - if (Game) Game->OnActivate(true, true); + if (_gameRef) _gameRef->OnActivate(true, true); SDL_ShowCursor(SDL_DISABLE); break; case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_MINIMIZED: #ifndef __IPHONEOS__ - if (Game) Game->OnActivate(false, false); + if (_gameRef) _gameRef->OnActivate(false, false); SDL_ShowCursor(SDL_ENABLE); #endif break; @@ -134,12 +134,12 @@ void CBPlatform::handleEvent(Common::Event *event) { case Common::EVENT_QUIT: case Common::EVENT_RTL: /*#ifdef __IPHONEOS__ - if (Game) { - Game->AutoSaveOnExit(); - Game->_quitting = true; + if (_gameRef) { + _gameRef->AutoSaveOnExit(); + _gameRef->_quitting = true; } #else*/ - if (Game) Game->onWindowClose(); + if (_gameRef) _gameRef->onWindowClose(); //#endif break; @@ -154,8 +154,8 @@ void CBPlatform::handleEvent(Common::Event *event) { int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { //TODO /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { - if (Game) Game->AutoSaveOnExit(); - if (Game) Game->OnActivate(false, false); + if (_gameRef) _gameRef->AutoSaveOnExit(); + if (_gameRef) _gameRef->OnActivate(false, false); SDL_ShowCursor(SDL_ENABLE); } */ @@ -182,7 +182,7 @@ uint32 CBPlatform::getTime() { ////////////////////////////////////////////////////////////////////////// bool CBPlatform::getCursorPos(Point32 *lpPoint) { - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); lpPoint->x = p.x; @@ -195,7 +195,7 @@ bool CBPlatform::getCursorPos(Point32 *lpPoint) { ////////////////////////////////////////////////////////////////////////// bool CBPlatform::setCursorPos(int X, int Y) { - CBRenderSDL *renderer = static_cast(Game->_renderer); + CBRenderSDL *renderer = static_cast(_gameRef->_renderer); Point32 p; p.x = X; diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 547f6b81b1..155c4e0f06 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -80,7 +80,7 @@ public: static int SDLEventWatcher(void *userdata, Common::Event *event); private: - static CBGame *Game; + static CBGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index 91639bc0ba..dee4b7d2d0 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -128,7 +128,7 @@ void CSysClass::dump(Common::WriteStream *stream) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::saveTable(CBGame *Game, CBPersistMgr *persistMgr) { +void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { persistMgr->putString(_name.c_str()); persistMgr->putDWORD(_iD); persistMgr->putDWORD(_instances.size()); @@ -140,7 +140,7 @@ void CSysClass::saveTable(CBGame *Game, CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { +void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { _savedID = persistMgr->getDWORD(); int numInstances = persistMgr->getDWORD(); @@ -149,7 +149,7 @@ void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { if (_persistent) { if (i > 0) { - Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); + gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); continue; } @@ -157,7 +157,7 @@ void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { if (it != _instances.end()) { (it->_value)->setSavedID(instID); CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); - } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); } // normal instances, create empty objects else { diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 4bdb571df4..b829aece35 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -167,7 +167,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +ERRORCODE CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { persistMgr->putString(""); persistMgr->putDWORD(_classes.size()); @@ -178,12 +178,12 @@ ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, b counter++; if (!quickSave) { - Game->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); - Game->displayContent(false); - Game->_renderer->flip(); + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); } - (it->_value)->saveTable(Game, persistMgr); + (it->_value)->saveTable(gameRef, persistMgr); } persistMgr->putString(""); return STATUS_OK; @@ -191,7 +191,7 @@ ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, b ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { +ERRORCODE CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { checkHeader("", persistMgr); // reset SavedID of current instances @@ -210,13 +210,13 @@ ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { uint32 numClasses = persistMgr->getDWORD(); for (uint32 i = 0; i < numClasses; i++) { - Game->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); - Game->displayContentSimple(); - Game->_renderer->flip(); + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); Common::String className = persistMgr->getStringObj(); NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(Game, persistMgr); + if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); } checkHeader("", persistMgr); @@ -226,7 +226,7 @@ ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) { +ERRORCODE CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { Classes::iterator it; @@ -244,29 +244,29 @@ ERRORCODE CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMg if (!quickSave) { if (counter % 20 == 0) { - Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); - Game->displayContent(false); - Game->_renderer->flip(); + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); } } - Game->miniUpdate(); + gameRef->miniUpdate(); - (it->_value)->saveInstances(Game, persistMgr); + (it->_value)->saveInstances(gameRef, persistMgr); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) { +ERRORCODE CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { // get total instances int numInstances = persistMgr->getDWORD(); for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { - Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); - Game->displayContentSimple(); - Game->_renderer->flip(); + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); } checkHeader("", persistMgr); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 85932ca603..5a8b994344 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -79,10 +79,10 @@ CUIButton::~CUIButton() { delete _backFocus; if (!_sharedFonts) { - if (_fontHover) Game->_fontStorage->removeFont(_fontHover); - if (_fontPress) Game->_fontStorage->removeFont(_fontPress); - if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); - if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); } if (!_sharedImages) { @@ -96,9 +96,9 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIButton::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -107,7 +107,7 @@ ERRORCODE CUIButton::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing BUTTON file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); delete [] buffer; @@ -196,11 +196,11 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { - Game->LOG(0, "'BUTTON' keyword expected."); + _gameRef->LOG(0, "'BUTTON' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -222,7 +222,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(Game); + _back = new CUITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -232,7 +232,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_HOVER: delete _backHover; - _backHover = new CUITiledImage(Game); + _backHover = new CUITiledImage(_gameRef); if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { delete _backHover; _backHover = NULL; @@ -242,7 +242,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_PRESS: delete _backPress; - _backPress = new CUITiledImage(Game); + _backPress = new CUITiledImage(_gameRef); if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { delete _backPress; _backPress = NULL; @@ -252,7 +252,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_DISABLE: delete _backDisable; - _backDisable = new CUITiledImage(Game); + _backDisable = new CUITiledImage(_gameRef); if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { delete _backDisable; _backDisable = NULL; @@ -262,7 +262,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_FOCUS: delete _backFocus; - _backFocus = new CUITiledImage(Game); + _backFocus = new CUITiledImage(_gameRef); if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { delete _backFocus; _backFocus = NULL; @@ -272,7 +272,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(Game); + _image = new CBSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -282,7 +282,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: delete _imageHover; - _imageHover = new CBSprite(Game); + _imageHover = new CBSprite(_gameRef); if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { delete _imageHover; _imageHover = NULL; @@ -292,7 +292,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_PRESS: delete _imagePress; - _imagePress = new CBSprite(Game); + _imagePress = new CBSprite(_gameRef); if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { delete _imagePress; _imagePress = NULL; @@ -302,7 +302,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_DISABLE: delete _imageDisable; - _imageDisable = new CBSprite(Game); + _imageDisable = new CBSprite(_gameRef); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { delete _imageDisable; _imageDisable = NULL; @@ -312,7 +312,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_FOCUS: delete _imageFocus; - _imageFocus = new CBSprite(Game); + _imageFocus = new CBSprite(_gameRef); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { delete _imageFocus; _imageFocus = NULL; @@ -321,38 +321,38 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont((char *)params); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_HOVER: - if (_fontHover) Game->_fontStorage->removeFont(_fontHover); - _fontHover = Game->_fontStorage->addFont((char *)params); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); if (!_fontHover) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_PRESS: - if (_fontPress) Game->_fontStorage->removeFont(_fontPress); - _fontPress = Game->_fontStorage->addFont((char *)params); + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + _fontPress = _gameRef->_fontStorage->addFont((char *)params); if (!_fontPress) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_DISABLE: - if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); - _fontDisable = Game->_fontStorage->addFont((char *)params); + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + _fontDisable = _gameRef->_fontStorage->addFont((char *)params); if (!_fontDisable) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_FOCUS: - if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); - _fontFocus = Game->_fontStorage->addFont((char *)params); + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + _fontFocus = _gameRef->_fontStorage->addFont((char *)params); if (!_fontFocus) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->expand(&_text); + _gameRef->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: @@ -379,7 +379,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -425,11 +425,11 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in BUTTON definition"); + _gameRef->LOG(0, "Syntax error in BUTTON definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading BUTTON definition"); + _gameRef->LOG(0, "Error loading BUTTON definition"); return STATUS_FAILED; } @@ -565,7 +565,7 @@ void CUIButton::correctSize() { if (_text) { int text_height; if (_font) text_height = _font->getTextHeight((byte *)_text, _width); - else text_height = Game->_systemFont->getTextHeight((byte *)_text, _width); + else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); if (text_height > _height) _height = text_height; } @@ -587,10 +587,10 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { //RECT rect; //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::ptInRect(&rect, Game->_mousePos)!=FALSE); - _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN)); + //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); + _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); - if ((_press && _hover && !Game->_mouseLeftDown) || + if ((_press && _hover && !_gameRef->_mouseLeftDown) || (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); @@ -616,7 +616,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { if (!image && _image) image = _image; if (_text && !font) { if (_font) font = _font; - else font = Game->_systemFont; + else font = _gameRef->_systemFont; } int imageX = offsetX + _posX; @@ -638,7 +638,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites if (_image && _image != image) _image->reset(); @@ -647,7 +647,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { if (_imagePress && _imagePress != image) _imagePress->reset(); if (_imageHover && _imageHover != image) _imageHover->reset(); - _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this; + _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; return STATUS_OK; } @@ -674,12 +674,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable); + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); if (Val->isNULL()) { _fontDisable = NULL; stack->pushBool(true); } else { - _fontDisable = Game->_fontStorage->addFont(Val->getString()); + _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontDisable != NULL); } return STATUS_OK; @@ -692,12 +692,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - if (_fontHover) Game->_fontStorage->removeFont(_fontHover); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); if (val->isNULL()) { _fontHover = NULL; stack->pushBool(true); } else { - _fontHover = Game->_fontStorage->addFont(val->getString()); + _fontHover = _gameRef->_fontStorage->addFont(val->getString()); stack->pushBool(_fontHover != NULL); } return STATUS_OK; @@ -710,12 +710,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *Val = stack->pop(); - if (_fontPress) Game->_fontStorage->removeFont(_fontPress); + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); if (Val->isNULL()) { _fontPress = NULL; stack->pushBool(true); } else { - _fontPress = Game->_fontStorage->addFont(Val->getString()); + _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); stack->pushBool(_fontPress != NULL); } return STATUS_OK; @@ -728,12 +728,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus); + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); if (val->isNULL()) { _fontFocus = NULL; stack->pushBool(true); } else { - _fontFocus = Game->_fontStorage->addFont(val->getString()); + _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); stack->pushBool(_fontFocus != NULL); } return STATUS_OK; @@ -746,7 +746,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); delete _imageDisable; - _imageDisable = new CBSprite(Game); + _imageDisable = new CBSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { delete _imageDisable; @@ -787,7 +787,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); delete _imageHover; - _imageHover = new CBSprite(Game); + _imageHover = new CBSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { delete _imageHover; @@ -827,7 +827,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); delete _imagePress; - _imagePress = new CBSprite(Game); + _imagePress = new CBSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { delete _imagePress; @@ -867,7 +867,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); delete _imageFocus; - _imageFocus = new CBSprite(Game); + _imageFocus = new CBSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { delete _imageFocus; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index b47885b4dc..c3cb3ad810 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -82,7 +82,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIEdit::~CUIEdit() { if (!_sharedFonts) { - if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); } delete[] _cursorChar; @@ -92,9 +92,9 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIEdit::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -103,7 +103,7 @@ ERRORCODE CUIEdit::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing EDIT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); delete [] buffer; @@ -164,11 +164,11 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { - Game->LOG(0, "'EDIT' keyword expected."); + _gameRef->LOG(0, "'EDIT' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -186,7 +186,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(Game); + _back = new CUITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -196,7 +196,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(Game); + _image = new CBSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -205,20 +205,20 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont((char *)params); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_SELECTED: - if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); - _fontSelected = Game->_fontStorage->addFont((char *)params); + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont((char *)params); if (!_fontSelected) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->expand(&_text); + _gameRef->_stringTable->expand(&_text); break; case TOKEN_X: @@ -247,7 +247,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -285,11 +285,11 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in EDIT definition"); + _gameRef->LOG(0, "Syntax error in EDIT definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading EDIT definition"); + _gameRef->LOG(0, "Error loading EDIT definition"); return STATUS_FAILED; } @@ -365,8 +365,8 @@ ERRORCODE CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "SetSelectedFont") == 0) { stack->correctParams(1); - if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected); - _fontSelected = Game->_fontStorage->addFont(stack->pop()->getString()); + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontSelected != NULL); return STATUS_OK; @@ -440,7 +440,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { + if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::ansiToWide(_text); _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); } else { @@ -511,7 +511,7 @@ ERRORCODE CUIEdit::scSetProperty(const char *name, CScValue *value) { // Text ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Text") == 0) { - if (Game->_textEncoding == TEXT_UTF8) { + if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(value->getString()); setText(StringUtil::wideToAnsi(wstr).c_str()); } else { @@ -545,8 +545,8 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { // hack! - TTextEncoding OrigEncoding = Game->_textEncoding; - Game->_textEncoding = TEXT_ANSI; + TTextEncoding OrigEncoding = _gameRef->_textEncoding; + _gameRef->_textEncoding = TEXT_ANSI; if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); @@ -556,7 +556,7 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { CBFont *sfont; if (_font) font = _font; - else font = Game->_systemFont; + else font = _gameRef->_systemFont; if (_fontSelected) sfont = _fontSelected; else sfont = font; @@ -615,7 +615,7 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { width = _posX + _width + offsetX - _frameWidth; height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); - if (Game->_textRTL) xxx += AlignOffset; + if (_gameRef->_textRTL) xxx += AlignOffset; TTextAlign Align = TAL_LEFT; @@ -673,10 +673,10 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { } - Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - Game->_textEncoding = OrigEncoding; + _gameRef->_textEncoding = OrigEncoding; return STATUS_OK; } @@ -704,7 +704,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_BACKSPACE: if (_selStart == _selEnd) { - if (Game->_textRTL) deleteChars(_selStart, _selStart + 1); + if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); else deleteChars(_selStart - 1, _selStart); } else deleteChars(_selStart, _selEnd); if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); @@ -728,7 +728,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { break; case Common::KEYCODE_HOME: - if (Game->_textRTL) { + if (_gameRef->_textRTL) { _selEnd = strlen(_text); if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } else { @@ -739,7 +739,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { break; case Common::KEYCODE_END: - if (Game->_textRTL) { + if (_gameRef->_textRTL) { _selEnd = 0; if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; } else { @@ -751,7 +751,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_DELETE: if (_selStart == _selEnd) { - if (Game->_textRTL) { + if (_gameRef->_textRTL) { deleteChars(_selStart - 1, _selStart); _selEnd--; if (_selEnd < 0) _selEnd = 0; @@ -774,7 +774,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { wstr += (char)event->kbd.ascii; _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); - if (Game->_textRTL) _selEnd = _selStart; + if (_gameRef->_textRTL) _selEnd = _selStart; else _selStart = _selEnd; return true; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index f30aca122c..7df6493fd5 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -49,16 +49,16 @@ CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIEntity::~CUIEntity() { - if (_entity) Game->unregisterObject(_entity); + if (_entity) _gameRef->unregisterObject(_entity); _entity = NULL; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIEntity::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -67,7 +67,7 @@ ERRORCODE CUIEntity::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing ENTITY container file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); delete [] buffer; @@ -105,11 +105,11 @@ ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { - Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); + _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -155,17 +155,17 @@ ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); + _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); + _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition"); return STATUS_FAILED; } correctSize(); - if (Game->_editorMode) { + if (_gameRef->_editorMode) { _width = 50; _height = 50; } @@ -209,8 +209,8 @@ ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIEntity::setEntity(const char *filename) { - if (_entity) Game->unregisterObject(_entity); - _entity = new CAdEntity(Game); + if (_entity) _gameRef->unregisterObject(_entity); + _entity = new CAdEntity(_gameRef); if (!_entity || DID_FAIL(_entity->loadFile(filename))) { delete _entity; _entity = NULL; @@ -219,7 +219,7 @@ ERRORCODE CUIEntity::setEntity(const char *filename) { _entity->_nonIntMouseEvents = true; _entity->_sceneIndependent = true; _entity->makeFreezable(false); - Game->registerObject(_entity); + _gameRef->registerObject(_entity); } return STATUS_OK; } diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 6c33bd9509..e7e6fa3b7a 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -71,10 +71,10 @@ CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// CUIObject::~CUIObject() { - if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); + if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); if (_back) delete _back; - if (_font && !_sharedFonts) Game->_fontStorage->removeFont(_font); + if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); if (_image && !_sharedImages) delete _image; @@ -145,12 +145,12 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *Val = stack->pop(); - if (_font) Game->_fontStorage->removeFont(_font); + if (_font) _gameRef->_fontStorage->removeFont(_font); if (Val->isNULL()) { _font = NULL; stack->pushBool(true); } else { - _font = Game->_fontStorage->addFont(Val->getString()); + _font = _gameRef->_fontStorage->addFont(Val->getString()); stack->pushBool(_font != NULL); } return STATUS_OK; @@ -172,7 +172,7 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * return STATUS_OK; } - _image = new CBSprite(Game); + _image = new CBSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { delete _image; _image = NULL; @@ -487,10 +487,10 @@ const char *CUIObject::scToString() { ////////////////////////////////////////////////////////////////////////// bool CUIObject::isFocused() { - if (!Game->_focusedWindow) return false; - if (Game->_focusedWindow == this) return true; + if (!_gameRef->_focusedWindow) return false; + if (_gameRef->_focusedWindow == this) return true; - CUIObject *obj = Game->_focusedWindow; + CUIObject *obj = _gameRef->_focusedWindow; while (obj) { if (obj == this) return true; else obj = obj->_focusedWidget; @@ -526,7 +526,7 @@ ERRORCODE CUIObject::focus() { if (obj->_parent) { if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; } else { - if (obj->_type == UI_WINDOW) Game->focusWindow((CUIWindow *)obj); + if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); } obj = obj->_parent; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index ba8191c204..e219adb262 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -67,7 +67,7 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { CBFont *font = _font; - if (!font) font = Game->_systemFont; + if (!font) font = _gameRef->_systemFont; if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); @@ -87,7 +87,7 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); } - //Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); return STATUS_OK; } @@ -96,9 +96,9 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIText::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -107,7 +107,7 @@ ERRORCODE CUIText::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing STATIC file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); delete [] buffer; @@ -164,11 +164,11 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { - Game->LOG(0, "'STATIC' keyword expected."); + _gameRef->LOG(0, "'STATIC' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -190,7 +190,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(Game); + _back = new CUITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -200,7 +200,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(Game); + _image = new CBSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -209,14 +209,14 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont((char *)params); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->expand(&_text); + _gameRef->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: @@ -249,7 +249,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -279,11 +279,11 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in STATIC definition"); + _gameRef->LOG(0, "Syntax error in STATIC definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading STATIC definition"); + _gameRef->LOG(0, "Error loading STATIC definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 05f6a0bed5..fc8f43ee2f 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -75,7 +75,7 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { int col, row; - Game->_renderer->startSpriteBatch(); + _gameRef->_renderer->startSpriteBatch(); // top left/right _image->_surface->displayTrans(x, y, _upLeft); @@ -112,7 +112,7 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { yyy += tileWidth; } - Game->_renderer->endSpriteBatch(); + _gameRef->_renderer->endSpriteBatch(); return STATUS_OK; } @@ -120,9 +120,9 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUITiledImage::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -131,7 +131,7 @@ ERRORCODE CUITiledImage::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); delete [] buffer; @@ -179,14 +179,14 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(Game); + CBParser parser(_gameRef); bool hTiles = false, vTiles = false; int h1 = 0, h2 = 0, h3 = 0; int v1 = 0, v2 = 0, v3 = 0; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { - Game->LOG(0, "'TILED_IMAGE' keyword expected."); + _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -200,7 +200,7 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSubFrame(Game); + _image = new CBSubFrame(_gameRef); if (!_image || DID_FAIL(_image->setSurface((char *)params))) { delete _image; _image = NULL; @@ -260,11 +260,11 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in TILED_IMAGE definition"); + _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading TILED_IMAGE definition"); + _gameRef->LOG(0, "Error loading TILED_IMAGE definition"); return STATUS_FAILED; } diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index f16e3afba1..9126a1ca7b 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -104,7 +104,7 @@ void CUIWindow::cleanup() { _viewport = NULL; delete _backInactive; - if (!_sharedFonts && _fontInactive) Game->_fontStorage->removeFont(_fontInactive); + if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); if (!_sharedImages && _imageInactive) delete _imageInactive; for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; @@ -116,25 +116,25 @@ void CUIWindow::cleanup() { ERRORCODE CUIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(Game); + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = Game->_renderer->_width; - _shieldWindow->_height = Game->_renderer->_height; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; _shieldWindow->display(); } } else if (_isMenu) { if (!_shieldButton) { - _shieldButton = new CUIButton(Game); + _shieldButton = new CUIButton(_gameRef); _shieldButton->setName("close"); _shieldButton->setListener(this, _shieldButton, 0); _shieldButton->_parent = this; } if (_shieldButton) { _shieldButton->_posX = _shieldButton->_posY = 0; - _shieldButton->_width = Game->_renderer->_width; - _shieldButton->_height = Game->_renderer->_height; + _shieldButton->_width = _gameRef->_renderer->_width; + _shieldButton->_height = _gameRef->_renderer->_height; _shieldButton->display(); } @@ -143,14 +143,14 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; - if (_fadeBackground) Game->_renderer->fadeToColor(_fadeColor); + if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); if (_dragging) { - _posX += (Game->_mousePos.x - _dragFrom.x); - _posY += (Game->_mousePos.y - _dragFrom.y); + _posX += (_gameRef->_mousePos.x - _dragFrom.x); + _posY += (_gameRef->_mousePos.y - _dragFrom.y); - _dragFrom.x = Game->_mousePos.x; - _dragFrom.y = Game->_mousePos.y; + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; } if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { @@ -159,10 +159,10 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { bool popViewport = false; if (_clipContents) { - if (!_viewport) _viewport = new CBViewport(Game); + if (!_viewport) _viewport = new CBViewport(_gameRef); if (_viewport) { _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); - Game->pushViewport(_viewport); + _gameRef->pushViewport(_viewport); popViewport = true; } } @@ -179,7 +179,7 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { } if (_alphaColor != 0) - Game->_renderer->_forceAlphaColor = _alphaColor; + _gameRef->_renderer->_forceAlphaColor = _alphaColor; if (back) back->display(_posX + offsetX, _posY + offsetY, _width, _height); if (image) @@ -190,17 +190,17 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { } if (!_transparent && !image) - Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); } if (_alphaColor != 0) - Game->_renderer->_forceAlphaColor = 0; + _gameRef->_renderer->_forceAlphaColor = 0; if (popViewport) - Game->popViewport(); + _gameRef->popViewport(); return STATUS_OK; } @@ -208,9 +208,9 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIWindow::loadFile(const char *filename) { - byte *buffer = Game->_fileManager->readWholeFile(filename); + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -219,7 +219,7 @@ ERRORCODE CUIWindow::loadFile(const char *filename) { _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing WINDOW file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); delete [] buffer; @@ -308,14 +308,14 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(Game); + CBParser parser(_gameRef); int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; int ar = 0, ag = 0, ab = 0, alpha = 0; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { - Game->LOG(0, "'WINDOW' keyword expected."); + _gameRef->LOG(0, "'WINDOW' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -337,7 +337,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(Game); + _back = new CUITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -347,7 +347,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_INACTIVE: delete _backInactive; - _backInactive = new CUITiledImage(Game); + _backInactive = new CUITiledImage(_gameRef); if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { delete _backInactive; _backInactive = NULL; @@ -357,7 +357,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(Game); + _image = new CBSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -367,7 +367,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_INACTIVE: delete _imageInactive, - _imageInactive = new CBSprite(Game); + _imageInactive = new CBSprite(_gameRef); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { delete _imageInactive; _imageInactive = NULL; @@ -376,20 +376,20 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) Game->_fontStorage->removeFont(_font); - _font = Game->_fontStorage->addFont((char *)params); + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); if (!_font) cmd = PARSERR_GENERIC; break; case TOKEN_FONT_INACTIVE: - if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive); - _fontInactive = Game->_fontStorage->addFont((char *)params); + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont((char *)params); if (!_fontInactive) cmd = PARSERR_GENERIC; break; case TOKEN_TITLE: setText((char *)params); - Game->_stringTable->expand(&_text); + _gameRef->_stringTable->expand(&_text); break; case TOKEN_TITLE_ALIGN: @@ -424,7 +424,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(Game); + _cursor = new CBSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -433,7 +433,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_BUTTON: { - CUIButton *btn = new CUIButton(Game); + CUIButton *btn = new CUIButton(_gameRef); if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { delete btn; btn = NULL; @@ -446,7 +446,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_STATIC: { - CUIText *text = new CUIText(Game); + CUIText *text = new CUIText(_gameRef); if (!text || DID_FAIL(text->loadBuffer(params, false))) { delete text; text = NULL; @@ -459,7 +459,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDIT: { - CUIEdit *edit = new CUIEdit(Game); + CUIEdit *edit = new CUIEdit(_gameRef); if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { delete edit; edit = NULL; @@ -472,7 +472,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WINDOW: { - CUIWindow *win = new CUIWindow(Game); + CUIWindow *win = new CUIWindow(_gameRef); if (!win || DID_FAIL(win->loadBuffer(params, false))) { delete win; win = NULL; @@ -545,17 +545,17 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { default: - if (DID_FAIL(Game->windowLoadHook(this, (char **)&buffer, (char **)params))) { + if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { cmd = PARSERR_GENERIC; } } } if (cmd == PARSERR_TOKENNOTFOUND) { - Game->LOG(0, "Syntax error in WINDOW definition"); + _gameRef->LOG(0, "Syntax error in WINDOW definition"); return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - Game->LOG(0, "Error loading WINDOW definition"); + _gameRef->LOG(0, "Error loading WINDOW definition"); return STATUS_FAILED; } @@ -728,8 +728,8 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "SetInactiveFont") == 0) { stack->correctParams(1); - if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive); - _fontInactive = Game->_fontStorage->addFont(stack->pop()->getString()); + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontInactive != NULL); return STATUS_OK; @@ -742,7 +742,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); delete _imageInactive; - _imageInactive = new CBSprite(Game); + _imageInactive = new CBSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { delete _imageInactive; @@ -812,8 +812,8 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Center") == 0) { stack->correctParams(0); - _posX = (Game->_renderer->_width - _width) / 2; - _posY = (Game->_renderer->_height - _height) / 2; + _posX = (_gameRef->_renderer->_width - _width) / 2; + _posY = (_gameRef->_renderer->_height - _height) / 2; stack->pushNULL(); return STATUS_OK; } @@ -840,7 +840,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - CUIButton *btn = new CUIButton(Game); + CUIButton *btn = new CUIButton(_gameRef); if (!val->isNULL()) btn->setName(val->getString()); stack->pushNative(btn, true); @@ -857,7 +857,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - CUIText *sta = new CUIText(Game); + CUIText *sta = new CUIText(_gameRef); if (!val->isNULL()) sta->setName(val->getString()); stack->pushNative(sta, true); @@ -874,7 +874,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - CUIEdit *edi = new CUIEdit(Game); + CUIEdit *edi = new CUIEdit(_gameRef); if (!val->isNULL()) edi->setName(val->getString()); stack->pushNative(edi, true); @@ -891,7 +891,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1); CScValue *val = stack->pop(); - CUIWindow *win = new CUIWindow(Game); + CUIWindow *win = new CUIWindow(_gameRef); if (!val->isNULL()) win->setName(val->getString()); stack->pushNative(win, true); @@ -918,7 +918,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * } stack->pushNULL(); return STATUS_OK; - } else if DID_SUCCEED(Game->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; + } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; else return CUIObject::scCallMethod(script, stack, thisStack, name); } @@ -1140,9 +1140,9 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { getTotalOffset(&offsetX, &offsetY); CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - if (CBPlatform::ptInRect(&dragRect, Game->_mousePos)) { - _dragFrom.x = Game->_mousePos.x; - _dragFrom.y = Game->_mousePos.y; + if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; _dragging = true; } } @@ -1238,7 +1238,7 @@ ERRORCODE CUIWindow::goExclusive() { _mode = WINDOW_EXCLUSIVE; _visible = true; _disable = false; - Game->focusWindow(this); + _gameRef->focusWindow(this); return STATUS_OK; } else return STATUS_FAILED; } @@ -1254,9 +1254,9 @@ ERRORCODE CUIWindow::goSystemExclusive() { _ready = false; _visible = true; _disable = false; - Game->focusWindow(this); + _gameRef->focusWindow(this); - Game->freeze(_pauseMusic); + _gameRef->freeze(_pauseMusic); return STATUS_OK; } @@ -1264,7 +1264,7 @@ ERRORCODE CUIWindow::goSystemExclusive() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CUIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - Game->unfreeze(); + _gameRef->unfreeze(); } _mode = WINDOW_NORMAL; diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index eed2ddce86..a962608691 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -129,23 +129,23 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil cleanup(); char Filename[MAX_PATH_LENGTH]; - Game->_fileManager->GetFullPath(inFilename, filename); + _gameRef->_fileManager->GetFullPath(inFilename, filename); // open file if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - Game->LOG(0, "Error opening AVI file '%s'", filename); + _gameRef->LOG(0, "Error opening AVI file '%s'", filename); return STATUS_FAILED; } // get video stream if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - Game->LOG(0, "Error finding video stream in AVI file '%s'", filename); + _gameRef->LOG(0, "Error finding video stream in AVI file '%s'", filename); return STATUS_FAILED; } _totalVideoTime = AVIStreamEndTime(_videoStream); // get audio stream - if (Game->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) _soundAvailable = true; else _soundAvailable = false; @@ -155,7 +155,7 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil // get video format if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); + _gameRef->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); return STATUS_FAILED; } _videoFormat = (LPBITMAPINFO)new BYTE[Size]; @@ -170,13 +170,13 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil m_TargetFormat->bV4BitCount = 24; m_TargetFormat->bV4V4Compression = BI_RGB; - if (Game->m_UseD3D) - m_VidRenderer = new CVidRendererD3D(Game); + if (_gameRef->m_UseD3D) + m_VidRenderer = new CVidRendererD3D(_gameRef); else - m_VidRenderer = new CVidRendererDD(Game); + m_VidRenderer = new CVidRendererDD(_gameRef); if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - Game->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); + _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); SAFE_DELETE(m_VidRenderer); return STATUS_FAILED; } @@ -186,15 +186,15 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil ERRORCODE res; if (_soundAvailable) { - _sound = new CBSoundAVI(Game); + _sound = new CBSoundAVI(_gameRef); if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { SAFE_DELETE(_sound); _soundAvailable = false; - Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); + _gameRef->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); } } - if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + if (_gameRef->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); _filename = new char[strlen(filename) + 1]; if (_filename) strcpy(_filename, filename); @@ -284,9 +284,9 @@ ERRORCODE CVidPlayer::display() { // display subtitle if (m_ShowSubtitle) { - CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); - font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); + CBFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); + font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); } return res; @@ -310,18 +310,18 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float ZoomY = (float)((float)Game->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + float ZoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float ZoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); _playZoom = min(ZoomX, ZoomY); - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; break; } @@ -333,11 +333,11 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) if (!_videoPGF) { _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); if (!_videoPGF) { - Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); + _gameRef->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); cleanup(); return STATUS_FAILED; } else { - Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); + _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); _slowRendering = true; } } else _slowRendering = false; @@ -348,7 +348,7 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) _currentSubtitle = 0; - Game->Freeze(FreezeMusic); + _gameRef->Freeze(FreezeMusic); _playing = true; if (_sound) _sound->Play(); @@ -365,7 +365,7 @@ ERRORCODE CVidPlayer::stop() { cleanup(); - Game->Unfreeze(); + _gameRef->Unfreeze(); #endif return STATUS_OK; } @@ -395,7 +395,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi } DWORD Size; - BYTE *Buffer = Game->m_FileManager->readWholeFile(NewFile, &Size, false); + BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); if (Buffer == NULL) return STATUS_OK; // no subtitles @@ -455,7 +455,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi } Text[TextLength] = '\0'; - if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(Game, Text, Start, End)); + if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); delete [] Text; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 0250aac5b2..6a622449ab 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -109,7 +109,7 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { ////////////////////////////////////////////////////////////////////////// void CVidTheoraPlayer::cleanup() { if (_file) { - Game->_fileManager->closeFile(_file); + _gameRef->_fileManager->closeFile(_file); _file = NULL; } @@ -122,7 +122,7 @@ void CVidTheoraPlayer::cleanup() { _texture = NULL; #if 0 if (m_Sound) { - Game->m_SoundMgr->RemoveSound(m_Sound); + _gameRef->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; } @@ -137,7 +137,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com cleanup(); _filename = filename; - _file = Game->_fileManager->openFile(filename, true, false); + _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) return STATUS_FAILED; //if (Filename != _filename) CBUtils::setString(&_filename, filename); @@ -155,7 +155,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // Additional setup. _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); - _texture = new CBSurfaceSDL(Game); + _texture = new CBSurfaceSDL(_gameRef); _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; @@ -164,7 +164,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com #if 0 cleanup(); - _file = Game->_fileManager->openFile(filename); + _file = _gameRef->_fileManager->openFile(filename); if (!_file) return STATUS_FAILED; if (Filename != _filename) CBUtils::setString(&_filename, filename); @@ -232,11 +232,11 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // look for further theora headers while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { if (Ret < 0) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); return STATUS_FAILED; } if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); return STATUS_FAILED; } m_TheoraStreams++; @@ -246,11 +246,11 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com /* look for more vorbis header packets */ while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { if (Ret < 0) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); return STATUS_FAILED; } if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); return STATUS_FAILED; } m_VorbisStreams++; @@ -267,7 +267,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com } else { int Ret = BufferData(&m_OggSyncState); // someone needs more data if (Ret == 0) { - Game->LOG(0, "End of file while searching for codec headers"); + _gameRef->LOG(0, "End of file while searching for codec headers"); return STATUS_FAILED; } } @@ -297,13 +297,13 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com ERRORCODE Res = STATUS_OK; // create sound buffer - if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { - m_Sound = new CBSoundTheora(Game); - Game->m_SoundMgr->AddSound(m_Sound); + if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { + m_Sound = new CBSoundTheora(_gameRef); + _gameRef->m_SoundMgr->AddSound(m_Sound); if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { - Game->m_SoundMgr->RemoveSound(m_Sound); + _gameRef->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; - Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); + _gameRef->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); } else { SAFE_DELETE_ARRAY(m_AudioBuf); m_AudioBufSize = m_Sound->m_StreamBlockSize; @@ -313,10 +313,10 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // create texture if (m_TheoraStreams && !m_Texture) { - if (Game->m_UseD3D) - m_Texture = new CBSurfaceD3D(Game); + if (_gameRef->m_UseD3D) + m_Texture = new CBSurfaceD3D(_gameRef); else - m_Texture = new CBSurfaceDD(Game); + m_Texture = new CBSurfaceDD(_gameRef); if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { SAFE_DELETE(m_Texture); @@ -324,8 +324,8 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com } - if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); + if (!m_Subtitler) m_Subtitler = new CVidSubtitler(_gameRef); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); return Res; #endif @@ -351,13 +351,13 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) - _volume = Game->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); + _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); else _volume = volume; _freezeGame = freezeGame; if (!_playbackStarted && _freezeGame) - Game->freeze(freezeMusic); + _gameRef->freeze(freezeMusic); _playbackStarted = false; float width, height; @@ -376,8 +376,8 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG width = (float)_theoraDecoder->getWidth(); height = (float)_theoraDecoder->getHeight(); } else { - width = (float)Game->_renderer->_width; - height = (float)Game->_renderer->_height; + width = (float)_gameRef->_renderer->_width; + height = (float)_gameRef->_renderer->_height; } switch (type) { @@ -388,18 +388,18 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->_width / width * 100); - float ZoomY = (float)((float)Game->_renderer->_height / height * 100); + float ZoomX = (float)((float)_gameRef->_renderer->_width / width * 100); + float ZoomY = (float)((float)_gameRef->_renderer->_height / height * 100); _playZoom = MIN(ZoomX, ZoomY); - _posX = (int)((Game->_renderer->_width - width * (_playZoom / 100)) / 2); - _posY = (int)((Game->_renderer->_height - height * (_playZoom / 100)) / 2); + _posX = (int)((_gameRef->_renderer->_width - width * (_playZoom / 100)) / 2); + _posY = (int)((_gameRef->_renderer->_height - height * (_playZoom / 100)) / 2); } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _posX = (int)((Game->_renderer->_width - width) / 2); - _posY = (int)((Game->_renderer->_height - height) / 2); + _posX = (int)((_gameRef->_renderer->_width - width) / 2); + _posY = (int)((_gameRef->_renderer->_height - height) / 2); break; } return STATUS_OK; @@ -415,8 +415,8 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG Width = (float)m_TheoraInfo.width; Height = (float)m_TheoraInfo.height; } else { - Width = (float)Game->m_Renderer->m_Width; - Height = (float)Game->m_Renderer->m_Height; + Width = (float)_gameRef->m_Renderer->m_Width; + Height = (float)_gameRef->m_Renderer->m_Height; } switch (Type) { @@ -427,18 +427,18 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->m_Renderer->m_Width / Width * 100); - float ZoomY = (float)((float)Game->m_Renderer->m_Height / Height * 100); + float ZoomX = (float)((float)_gameRef->m_Renderer->m_Width / Width * 100); + float ZoomY = (float)((float)_gameRef->m_Renderer->m_Height / Height * 100); m_PlayZoom = min(ZoomX, ZoomY); - m_PosX = (Game->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; + m_PosX = (_gameRef->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; } break; case VID_PLAY_CENTER: m_PlayZoom = 100.0f; - m_PosX = (Game->m_Renderer->m_Width - Width) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height) / 2; + m_PosX = (_gameRef->m_Renderer->m_Width - Width) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height) / 2; break; } @@ -455,25 +455,25 @@ ERRORCODE CVidTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { - Game->unfreeze(); + _gameRef->unfreeze(); } #if 0 if (m_Sound) m_Sound->Stop(); m_State = THEORA_STATE_FINISHED; - if (m_FreezeGame) Game->Unfreeze(); + if (m_FreezeGame) _gameRef->Unfreeze(); #endif return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CVidTheoraPlayer::update() { - _currentTime = _freezeGame ? Game->_liveTimer : Game->_timer; + _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; if (!isPlaying()) return STATUS_OK; if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; - if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return STATUS_OK; + if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) return STATUS_OK; if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { @@ -483,7 +483,7 @@ ERRORCODE CVidTheoraPlayer::update() { warning("Finished movie"); _state = THEORA_STATE_FINISHED; _playbackStarted = false; - if (_freezeGame) Game->unfreeze(); + if (_freezeGame) _gameRef->unfreeze(); } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { @@ -500,7 +500,7 @@ ERRORCODE CVidTheoraPlayer::update() { // end playback if (!_looping) { _state = THEORA_STATE_FINISHED; - if (_freezeGame) Game->unfreeze(); + if (_freezeGame) _gameRef->unfreeze(); return STATUS_OK; } else { resetStream(); @@ -509,13 +509,13 @@ ERRORCODE CVidTheoraPlayer::update() { } #if 0 - m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; + m_CurrentTime = m_FreezeGame ? _gameRef->m_LiveTimer : _gameRef->m_Timer; if (!IsPlaying()) return STATUS_OK; if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; - if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return STATUS_OK; + if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; int Counter = 0; while (true) { @@ -530,7 +530,7 @@ ERRORCODE CVidTheoraPlayer::update() { if (!m_Looping) { m_State = THEORA_STATE_FINISHED; if (m_Sound) m_Sound->Stop(); - if (m_FreezeGame) Game->Unfreeze(); + if (m_FreezeGame) _gameRef->Unfreeze(); break; } else { ResetStream(); @@ -551,7 +551,7 @@ ERRORCODE CVidTheoraPlayer::update() { // are we at or past time for this video frame? if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { - //Game->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); + //_gameRef->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); if (m_Texture) WriteVideo(); m_VideoFrameReady = false; @@ -583,7 +583,7 @@ ERRORCODE CVidTheoraPlayer::update() { m_PlaybackStarted = true; } - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); #endif return STATUS_OK; } @@ -661,7 +661,7 @@ ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); } else res = STATUS_FAILED; #if 0 - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->display(); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->display(); #endif return res; } @@ -671,7 +671,7 @@ ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; - _alphaImage = new CBImage(Game); + _alphaImage = new CBImage(_gameRef); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; @@ -685,7 +685,7 @@ ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { //TODO: Conversion. #if 0 SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new CBImage(Game); + m_AlphaImage = new CBImage(_gameRef); if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); @@ -812,7 +812,7 @@ ERRORCODE CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { SetDefaults(); } - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_savedPos)); persistMgr->transfer(TMEMBER(_savedState)); persistMgr->transfer(TMEMBER(_filename)); -- cgit v1.2.3 From 95c0efb93720fa2415693cd138b14144cd7b0bb6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 18:28:38 +0200 Subject: WINTERMUTE: Rename _dEBUG_ -> _debug --- engines/wintermute/Ad/AdGame.cpp | 4 +-- engines/wintermute/Ad/AdScene.cpp | 2 +- engines/wintermute/Base/BFileManager.cpp | 2 +- engines/wintermute/Base/BGame.cpp | 38 ++++++++++++------------- engines/wintermute/Base/BGame.h | 8 +++--- engines/wintermute/Base/BSprite.cpp | 2 +- engines/wintermute/Base/BSurfaceStorage.cpp | 2 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 6 ++-- engines/wintermute/wintermute.cpp | 2 +- 9 files changed, 33 insertions(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 953dd92179..b5c049dc75 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -266,7 +266,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene->_scProp) _scene->_scProp->cleanup(); ERRORCODE ret; - if (_initialScene && _dEBUG_DebugMode && _debugStartupScene) { + if (_initialScene && _debugDebugMode && _debugStartupScene) { _initialScene = false; ret = _scene->loadFile(_debugStartupScene); } else ret = _scene->loadFile(filename); @@ -2039,7 +2039,7 @@ ERRORCODE CAdGame::onMouseRightUp() { ////////////////////////////////////////////////////////////////////////// ERRORCODE CAdGame::displayDebugInfo() { char str[100]; - if (_gameRef->_dEBUG_DebugMode) { + if (_gameRef->_debugDebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index f50b854db3..e72b3211de 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -295,7 +295,7 @@ float CAdScene::getZoomAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { - if (!_gameRef->_dEBUG_DebugMode) colorCheck = false; + if (!_gameRef->_debugDebugMode) colorCheck = false; uint32 ret; if (colorCheck) ret = 0xFFFF0000; diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index e652ff8301..113dbbe5d0 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -616,7 +616,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena if (strcmp(filename.c_str(), "") == 0) return NULL; //_gameRef->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ - if (_gameRef->_dEBUG_DebugMode && _gameRef->_dEBUG_AbsolutePathWarning && AbsPathWarning) { + if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { char Drive[_MAX_DRIVE]; _splitpath(filename, Drive, NULL, NULL, NULL); if (Drive[0] != '\0') { diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 4abfdf4507..4acd916e94 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -100,10 +100,10 @@ CBGame::CBGame(): CBObject(this) { _mathClass = NULL; - _dEBUG_LogFile = NULL; - _dEBUG_DebugMode = false; - _dEBUG_AbsolutePathWarning = true; - _dEBUG_ShowFPS = false; + _debugLogFile = NULL; + _debugDebugMode = false; + _debugAbsolutePathWarning = true; + _debugShowFPS = false; _systemFont = NULL; _videoFont = NULL; @@ -506,7 +506,7 @@ ERRORCODE CBGame::initialize3() { // renderer is initialized ////////////////////////////////////////////////////////////////////// void CBGame::DEBUG_DebugEnable(const char *filename) { - _dEBUG_DebugMode = true; + _debugDebugMode = true; /* time_t timeNow; time(&timeNow); @@ -540,12 +540,12 @@ void CBGame::DEBUG_DebugEnable(const char *filename) { ////////////////////////////////////////////////////////////////////// void CBGame::DEBUG_DebugDisable() { - if (_dEBUG_LogFile != NULL) { + if (_debugLogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_dEBUG_LogFile); - _dEBUG_LogFile = NULL; + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; } - _dEBUG_DebugMode = false; + _debugDebugMode = false; } @@ -572,8 +572,8 @@ void CBGame::LOG(ERRORCODE res, const char *fmt, ...) { debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fflush((FILE *)_dEBUG_LogFile); + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); //QuickMessage(buff); } @@ -2257,7 +2257,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DebugMode") == 0) { - _scValue->setBool(_dEBUG_DebugMode); + _scValue->setBool(_debugDebugMode); return _scValue; } @@ -3242,7 +3242,7 @@ ERRORCODE CBGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; CBPersistMgr *pm = new CBPersistMgr(_gameRef); - _dEBUG_AbsolutePathWarning = false; + _debugAbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; @@ -3260,7 +3260,7 @@ ERRORCODE CBGame::loadGame(const char *filename) { getDebugMgr()->onGameInit(); load_finish: - _dEBUG_AbsolutePathWarning = true; + _debugAbsolutePathWarning = true; _indicatorDisplay = false; delete pm; @@ -3836,14 +3836,14 @@ ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { CBPersistMgr *pm = new CBPersistMgr(_gameRef); if (!pm) return STATUS_FAILED; - _dEBUG_AbsolutePathWarning = false; + _debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(filename))) { - _dEBUG_AbsolutePathWarning = true; + _debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _dEBUG_AbsolutePathWarning = true; + _debugAbsolutePathWarning = true; strcpy(buffer, pm->_savedDescription); delete pm; @@ -4318,12 +4318,12 @@ ERRORCODE CBGame::onWindowClose() { ERRORCODE CBGame::displayDebugInfo() { char str[100]; - if (_dEBUG_ShowFPS) { + if (_debugShowFPS) { sprintf(str, "FPS: %d", _gameRef->_fps); _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); } - if (_gameRef->_dEBUG_DebugMode) { + if (_gameRef->_debugDebugMode) { if (!_gameRef->_renderer->_windowed) sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); else diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 3bee3d134b..e78fd80118 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -97,7 +97,7 @@ public: bool _shuttingDown; virtual ERRORCODE displayDebugInfo(); - bool _dEBUG_ShowFPS; + bool _debugShowFPS; bool _suspendedRendering; int _soundBufferSizeSec; @@ -185,10 +185,10 @@ public: virtual ~CBGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *filename = NULL); - bool _dEBUG_DebugMode; - bool _dEBUG_AbsolutePathWarning; + bool _debugDebugMode; + bool _debugAbsolutePathWarning; - void *_dEBUG_LogFile; + void *_debugLogFile; int _sequence; virtual ERRORCODE loadFile(const char *filename); virtual ERRORCODE loadBuffer(byte *buffer, bool complete = true); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index d2dd619517..2e6787d27b 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -126,7 +126,7 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); else return loadFile("invalid.bmp", lifeTime, cacheType); } else { _gameRef->_fileManager->closeFile(file); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index cb48f3657b..0ffeb7a81c 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -107,7 +107,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by if (!_gameRef->_fileManager->hasFile(filename)) { if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_dEBUG_DebugMode) + if (_gameRef->_debugDebugMode) return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); else return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 3768578987..1784c1f53d 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -74,13 +74,13 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { CBPersistMgr *pm = new CBPersistMgr(_gameRef); if (!pm) return STATUS_FAILED; - _gameRef->_dEBUG_AbsolutePathWarning = false; + _gameRef->_debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_dEBUG_AbsolutePathWarning = true; + _gameRef->_debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _gameRef->_dEBUG_AbsolutePathWarning = true; + _gameRef->_debugAbsolutePathWarning = true; ERRORCODE res; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index ceea7128cf..60abe21cc6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -176,7 +176,7 @@ int WinterMuteEngine::init() { if (_game->_registry->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); - _game->_dEBUG_ShowFPS = _game->_registry->readBool("Debug", "ShowFPS"); + _game->_debugShowFPS = _game->_registry->readBool("Debug", "ShowFPS"); if (_game->_registry->readBool("Debug", "DisableSmartCache")) { _game->LOG(0, "Smart cache is DISABLED"); -- cgit v1.2.3 From 136ae9857f3401f5dea13c63c3c0702b08040e2a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 18:31:56 +0200 Subject: WINTERMUTE: Rename ERRORCODE (formerly HRESULT) to bool --- engines/wintermute/Ad/AdActor.cpp | 26 ++-- engines/wintermute/Ad/AdActor.h | 18 +-- engines/wintermute/Ad/AdEntity.cpp | 20 +-- engines/wintermute/Ad/AdEntity.h | 16 +-- engines/wintermute/Ad/AdGame.cpp | 100 +++++++------- engines/wintermute/Ad/AdGame.h | 82 ++++++------ engines/wintermute/Ad/AdInventory.cpp | 8 +- engines/wintermute/Ad/AdInventory.h | 6 +- engines/wintermute/Ad/AdInventoryBox.cpp | 14 +- engines/wintermute/Ad/AdInventoryBox.h | 10 +- engines/wintermute/Ad/AdItem.cpp | 18 +-- engines/wintermute/Ad/AdItem.h | 12 +- engines/wintermute/Ad/AdLayer.cpp | 14 +- engines/wintermute/Ad/AdLayer.h | 10 +- engines/wintermute/Ad/AdNodeState.cpp | 4 +- engines/wintermute/Ad/AdNodeState.h | 2 +- engines/wintermute/Ad/AdObject.cpp | 44 +++---- engines/wintermute/Ad/AdObject.h | 36 ++--- engines/wintermute/Ad/AdPath.cpp | 2 +- engines/wintermute/Ad/AdPathPoint.cpp | 2 +- engines/wintermute/Ad/AdRegion.cpp | 14 +- engines/wintermute/Ad/AdRegion.h | 10 +- engines/wintermute/Ad/AdResponse.cpp | 10 +- engines/wintermute/Ad/AdResponse.h | 8 +- engines/wintermute/Ad/AdResponseBox.cpp | 24 ++-- engines/wintermute/Ad/AdResponseBox.h | 20 +-- engines/wintermute/Ad/AdResponseContext.cpp | 2 +- engines/wintermute/Ad/AdRotLevel.cpp | 10 +- engines/wintermute/Ad/AdRotLevel.h | 6 +- engines/wintermute/Ad/AdScaleLevel.cpp | 10 +- engines/wintermute/Ad/AdScaleLevel.h | 6 +- engines/wintermute/Ad/AdScene.cpp | 62 ++++----- engines/wintermute/Ad/AdScene.h | 58 ++++---- engines/wintermute/Ad/AdSceneNode.cpp | 6 +- engines/wintermute/Ad/AdSceneNode.h | 4 +- engines/wintermute/Ad/AdSceneState.cpp | 2 +- engines/wintermute/Ad/AdSentence.cpp | 10 +- engines/wintermute/Ad/AdSentence.h | 8 +- engines/wintermute/Ad/AdSpriteSet.cpp | 10 +- engines/wintermute/Ad/AdSpriteSet.h | 6 +- engines/wintermute/Ad/AdTalkDef.cpp | 12 +- engines/wintermute/Ad/AdTalkDef.h | 8 +- engines/wintermute/Ad/AdTalkHolder.cpp | 10 +- engines/wintermute/Ad/AdTalkHolder.h | 6 +- engines/wintermute/Ad/AdTalkNode.cpp | 8 +- engines/wintermute/Ad/AdTalkNode.h | 6 +- engines/wintermute/Ad/AdWaypointGroup.cpp | 14 +- engines/wintermute/Ad/AdWaypointGroup.h | 10 +- engines/wintermute/Base/BBase.cpp | 6 +- engines/wintermute/Base/BBase.h | 6 +- engines/wintermute/Base/BDebugger.cpp | 32 ++--- engines/wintermute/Base/BDebugger.h | 36 ++--- engines/wintermute/Base/BDynBuffer.cpp | 6 +- engines/wintermute/Base/BDynBuffer.h | 6 +- engines/wintermute/Base/BFader.cpp | 12 +- engines/wintermute/Base/BFader.h | 10 +- engines/wintermute/Base/BFileManager.cpp | 22 ++-- engines/wintermute/Base/BFileManager.h | 22 ++-- engines/wintermute/Base/BFrame.cpp | 16 +-- engines/wintermute/Base/BFrame.h | 12 +- engines/wintermute/Base/BGame.cpp | 146 ++++++++++----------- engines/wintermute/Base/BGame.h | 132 +++++++++---------- engines/wintermute/Base/BImage.cpp | 8 +- engines/wintermute/Base/BImage.h | 8 +- engines/wintermute/Base/BKeyboardState.cpp | 8 +- engines/wintermute/Base/BKeyboardState.h | 6 +- engines/wintermute/Base/BObject.cpp | 42 +++--- engines/wintermute/Base/BObject.h | 46 +++---- engines/wintermute/Base/BPackage.cpp | 8 +- engines/wintermute/Base/BPackage.h | 6 +- engines/wintermute/Base/BPersistMgr.cpp | 42 +++--- engines/wintermute/Base/BPersistMgr.h | 42 +++--- engines/wintermute/Base/BPoint.cpp | 2 +- engines/wintermute/Base/BRegion.cpp | 18 +-- engines/wintermute/Base/BRegion.h | 14 +- engines/wintermute/Base/BRenderSDL.cpp | 16 +-- engines/wintermute/Base/BRenderSDL.h | 16 +-- engines/wintermute/Base/BRenderer.cpp | 32 ++--- engines/wintermute/Base/BRenderer.h | 42 +++--- engines/wintermute/Base/BSaveThumbHelper.cpp | 2 +- engines/wintermute/Base/BSaveThumbHelper.h | 2 +- engines/wintermute/Base/BScriptHolder.cpp | 26 ++-- engines/wintermute/Base/BScriptHolder.h | 18 +-- engines/wintermute/Base/BScriptable.cpp | 6 +- engines/wintermute/Base/BScriptable.h | 4 +- engines/wintermute/Base/BSound.cpp | 32 ++--- engines/wintermute/Base/BSound.h | 26 ++-- engines/wintermute/Base/BSoundBuffer.cpp | 24 ++-- engines/wintermute/Base/BSoundBuffer.h | 22 ++-- engines/wintermute/Base/BSoundMgr.cpp | 24 ++-- engines/wintermute/Base/BSoundMgr.h | 22 ++-- engines/wintermute/Base/BSprite.cpp | 20 +-- engines/wintermute/Base/BSprite.h | 18 +-- engines/wintermute/Base/BStringTable.cpp | 4 +- engines/wintermute/Base/BStringTable.h | 4 +- engines/wintermute/Base/BSubFrame.cpp | 18 +-- engines/wintermute/Base/BSubFrame.h | 16 +-- engines/wintermute/Base/BSurface.cpp | 22 ++-- engines/wintermute/Base/BSurface.h | 34 ++--- engines/wintermute/Base/BSurfaceSDL.cpp | 26 ++-- engines/wintermute/Base/BSurfaceSDL.h | 26 ++-- engines/wintermute/Base/BSurfaceStorage.cpp | 14 +- engines/wintermute/Base/BSurfaceStorage.h | 10 +- engines/wintermute/Base/BTransitionMgr.cpp | 4 +- engines/wintermute/Base/BTransitionMgr.h | 4 +- engines/wintermute/Base/BViewport.cpp | 4 +- engines/wintermute/Base/BViewport.h | 2 +- engines/wintermute/Base/file/BFile.h | 8 +- engines/wintermute/Base/file/BSaveThumbFile.cpp | 10 +- engines/wintermute/Base/file/BSaveThumbFile.h | 8 +- engines/wintermute/Base/font/BFont.cpp | 8 +- engines/wintermute/Base/font/BFont.h | 4 +- engines/wintermute/Base/font/BFontBitmap.cpp | 10 +- engines/wintermute/Base/font/BFontBitmap.h | 6 +- engines/wintermute/Base/font/BFontStorage.cpp | 8 +- engines/wintermute/Base/font/BFontStorage.h | 6 +- engines/wintermute/Base/font/BFontTT.cpp | 12 +- engines/wintermute/Base/font/BFontTT.h | 10 +- engines/wintermute/Base/particles/PartEmitter.cpp | 30 ++--- engines/wintermute/Base/particles/PartEmitter.h | 30 ++--- engines/wintermute/Base/particles/PartForce.cpp | 2 +- engines/wintermute/Base/particles/PartForce.h | 2 +- engines/wintermute/Base/particles/PartParticle.cpp | 12 +- engines/wintermute/Base/particles/PartParticle.h | 12 +- engines/wintermute/Base/scriptables/SXArray.cpp | 8 +- engines/wintermute/Base/scriptables/SXArray.h | 6 +- engines/wintermute/Base/scriptables/SXDate.cpp | 6 +- engines/wintermute/Base/scriptables/SXDate.h | 4 +- engines/wintermute/Base/scriptables/SXFile.cpp | 10 +- engines/wintermute/Base/scriptables/SXFile.h | 4 +- engines/wintermute/Base/scriptables/SXMath.cpp | 4 +- engines/wintermute/Base/scriptables/SXMath.h | 2 +- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 8 +- engines/wintermute/Base/scriptables/SXMemBuffer.h | 6 +- engines/wintermute/Base/scriptables/SXString.cpp | 6 +- engines/wintermute/Base/scriptables/SXString.h | 4 +- engines/wintermute/Base/scriptables/ScEngine.cpp | 38 +++--- engines/wintermute/Base/scriptables/ScEngine.h | 36 ++--- engines/wintermute/Base/scriptables/ScScript.cpp | 50 +++---- engines/wintermute/Base/scriptables/ScScript.h | 36 ++--- engines/wintermute/Base/scriptables/ScStack.cpp | 2 +- engines/wintermute/Base/scriptables/ScValue.cpp | 12 +- engines/wintermute/Base/scriptables/ScValue.h | 8 +- engines/wintermute/Base/scriptables/SxObject.cpp | 2 +- engines/wintermute/Sys/SysClassRegistry.cpp | 10 +- engines/wintermute/Sys/SysClassRegistry.h | 10 +- engines/wintermute/UI/UIButton.cpp | 16 +-- engines/wintermute/UI/UIButton.h | 12 +- engines/wintermute/UI/UIEdit.cpp | 16 +-- engines/wintermute/UI/UIEdit.h | 12 +- engines/wintermute/UI/UIEntity.cpp | 18 +-- engines/wintermute/UI/UIEntity.h | 14 +- engines/wintermute/UI/UIObject.cpp | 16 +-- engines/wintermute/UI/UIObject.h | 14 +- engines/wintermute/UI/UIText.cpp | 18 +-- engines/wintermute/UI/UIText.h | 14 +- engines/wintermute/UI/UITiledImage.cpp | 12 +- engines/wintermute/UI/UITiledImage.h | 8 +- engines/wintermute/UI/UIWindow.cpp | 36 ++--- engines/wintermute/UI/UIWindow.h | 30 ++--- engines/wintermute/coll_templ.h | 4 +- engines/wintermute/persistent.h | 8 +- engines/wintermute/video/VidPlayer.cpp | 22 ++-- engines/wintermute/video/VidPlayer.h | 16 +-- engines/wintermute/video/VidTheoraPlayer.cpp | 30 ++--- engines/wintermute/video/VidTheoraPlayer.h | 26 ++-- engines/wintermute/wintermute.cpp | 2 +- engines/wintermute/wintypes.h | 6 +- 168 files changed, 1428 insertions(+), 1430 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 55a8ac8443..17bd166796 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -76,7 +76,7 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::setDefaultAnimNames() { +bool CAdActor::setDefaultAnimNames() { _talkAnimName = "talk"; _idleAnimName = "idle"; _walkAnimName = "walk"; @@ -123,14 +123,14 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::loadFile(const char *filename) { +bool CAdActor::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -183,7 +183,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { +bool CAdActor::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -504,7 +504,7 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::display() { +bool CAdActor::display() { if (_active) updateSounds(); uint32 alpha; @@ -547,7 +547,7 @@ ERRORCODE CAdActor::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::update() { +bool CAdActor::update() { _currentSprite = NULL; if (_state == STATE_READY) { @@ -850,7 +850,7 @@ void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// @@ -1035,7 +1035,7 @@ CScValue *CAdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::scSetProperty(const char *name, CScValue *value) { +bool CAdActor::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// @@ -1108,7 +1108,7 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { delete _animSprite; _animSprite = new CBSprite(_gameRef, this); if (_animSprite) { - ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); + bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; @@ -1187,7 +1187,7 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::persist(CBPersistMgr *persistMgr) { +bool CAdActor::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_dir)); @@ -1262,7 +1262,7 @@ CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { +bool CAdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END @@ -1279,7 +1279,7 @@ ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { int cmd; CBParser parser(_gameRef); - ERRORCODE Ret = STATUS_OK; + bool Ret = STATUS_OK; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -1298,7 +1298,7 @@ ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdActor::playAnim(const char *filename) { +bool CAdActor::playAnim(const char *filename) { // if we have an anim with this name, use it CAdSpriteSet *Anim = getAnimByName(filename); if (Anim) { diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h index d767ecd381..114ee04ae8 100644 --- a/engines/wintermute/Ad/AdActor.h +++ b/engines/wintermute/Ad/AdActor.h @@ -52,8 +52,8 @@ public: CBSprite *getTalkStance(const char *stance); virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); CBPoint *_targetPoint; - virtual ERRORCODE update(); - virtual ERRORCODE display(); + virtual bool update(); + virtual bool display(); TDirection _targetDir; TDirection _afterWalkDir; virtual void turnTo(TDirection dir); @@ -67,8 +67,8 @@ public: TDirection _dir; CAdActor(CBGame *inGame/*=NULL*/); virtual ~CAdActor(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); // new anim system Common::String _talkAnimName; @@ -77,19 +77,19 @@ public: Common::String _turnLeftAnimName; Common::String _turnRightAnimName; CBArray _anims; - virtual ERRORCODE playAnim(const char *filename); + virtual bool playAnim(const char *filename); CAdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - ERRORCODE setDefaultAnimNames(); + bool setDefaultAnimNames(); CBSprite *getTalkStanceOld(const char *stance); - ERRORCODE mergeAnims(const char *animsFilename); + bool mergeAnims(const char *animsFilename); CBSprite *_animSprite2; void initLine(CBPoint startPt, CBPoint endPt); diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index ccffe58efe..20c16e3dd5 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -84,14 +84,14 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::loadFile(const char *filename) { +bool CAdEntity::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -150,7 +150,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { +bool CAdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -481,7 +481,7 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::display() { +bool CAdEntity::display() { if (_active) { updateSounds(); @@ -529,7 +529,7 @@ ERRORCODE CAdEntity::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::update() { +bool CAdEntity::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -625,7 +625,7 @@ ERRORCODE CAdEntity::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// @@ -831,7 +831,7 @@ CScValue *CAdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::scSetProperty(const char *name, CScValue *value) { +bool CAdEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item @@ -877,7 +877,7 @@ const char *CAdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) @@ -977,7 +977,7 @@ void CAdEntity::updatePosition() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::persist(CBPersistMgr *persistMgr) { +bool CAdEntity::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_item)); @@ -1003,7 +1003,7 @@ void CAdEntity::setItem(const char *itemName) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdEntity::setSprite(const char *filename) { +bool CAdEntity::setSprite(const char *filename) { bool setCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h index 9a53f8195b..43007c645a 100644 --- a/engines/wintermute/Ad/AdEntity.h +++ b/engines/wintermute/Ad/AdEntity.h @@ -36,7 +36,7 @@ class CVidTheoraPlayer; class CAdEntity : public CAdTalkHolder { public: CVidTheoraPlayer *_theora; - ERRORCODE setSprite(const char *filename); + bool setSprite(const char *filename); int _walkToX; int _walkToY; TDirection _walkToDir; @@ -46,19 +46,19 @@ public: void updatePosition(); virtual int getHeight(); CBRegion *_region; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - virtual ERRORCODE update(); - virtual ERRORCODE display(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool update(); + virtual bool display(); CAdEntity(CBGame *inGame); virtual ~CAdEntity(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); TEntityType _subtype; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index b5c049dc75..af752e3ced 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -117,7 +117,7 @@ CAdGame::~CAdGame() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::cleanup() { +bool CAdGame::cleanup() { int i; for (i = 0; i < _objects.getSize(); i++) { @@ -195,7 +195,7 @@ ERRORCODE CAdGame::cleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::initLoop() { +bool CAdGame::initLoop() { if (_scheduledScene && _transMgr->isReady()) { changeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; @@ -205,7 +205,7 @@ ERRORCODE CAdGame::initLoop() { } - ERRORCODE res; + bool res; res = CBGame::initLoop(); if (DID_FAIL(res)) return res; @@ -218,17 +218,17 @@ ERRORCODE CAdGame::initLoop() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::addObject(CAdObject *object) { +bool CAdGame::addObject(CAdObject *object) { _objects.add(object); return registerObject(object); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::removeObject(CAdObject *object) { +bool CAdGame::removeObject(CAdObject *object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { - ERRORCODE Res = _scene->removeObject(object); + bool Res = _scene->removeObject(object); if (DID_SUCCEED(Res)) return Res; } @@ -243,7 +243,7 @@ ERRORCODE CAdGame::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { +bool CAdGame::changeScene(const char *filename, bool fadeIn) { if (_scene == NULL) { _scene = new CAdScene(_gameRef); registerObject(_scene); @@ -265,7 +265,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { _scene->_sFXVolume = 100; if (_scene->_scProp) _scene->_scProp->cleanup(); - ERRORCODE ret; + bool ret; if (_initialScene && _debugDebugMode && _debugStartupScene) { _initialScene = false; ret = _scene->loadFile(_debugStartupScene); @@ -293,7 +293,7 @@ void CAdGame::addSentence(CAdSentence *sentence) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::displaySentences(bool frozen) { +bool CAdGame::displaySentences(bool frozen) { for (int i = 0; i < _sentences.getSize(); i++) { if (frozen && _sentences[i]->_freezable) continue; else _sentences[i]->display(); @@ -316,7 +316,7 @@ void CAdGame::finishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// @@ -334,7 +334,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); - //ERRORCODE ret = ChangeScene(stack->pop()->getString()); + //bool ret = ChangeScene(stack->pop()->getString()); //if(DID_FAIL(ret)) stack->pushBool(false); //else stack->pushBool(true); @@ -743,7 +743,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th const char *filename = stack->pop()->getString(); bool merge = stack->pop()->getBool(false); - ERRORCODE ret = loadItemsFile(filename, merge); + bool ret = loadItemsFile(filename, merge); stack->pushBool(DID_SUCCEED(ret)); return STATUS_OK; @@ -952,7 +952,7 @@ CScValue *CAdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { +bool CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem @@ -1047,7 +1047,7 @@ ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { +bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *this_obj; ////////////////////////////////////////////////////////////////////////// @@ -1083,7 +1083,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::showCursor() { +bool CAdGame::showCursor() { if (_cursorHidden) return STATUS_OK; if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { @@ -1103,14 +1103,14 @@ ERRORCODE CAdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::loadFile(const char *filename) { +bool CAdGame::loadFile(const char *filename) { byte *buffer = _fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -1139,7 +1139,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { +bool CAdGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1252,7 +1252,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::persist(CBPersistMgr *persistMgr) { +bool CAdGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); CBGame::persist(persistMgr); @@ -1303,14 +1303,14 @@ ERRORCODE CAdGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::loadGame(const char *filename) { - ERRORCODE ret = CBGame::loadGame(filename); +bool CAdGame::loadGame(const char *filename) { + bool ret = CBGame::loadGame(filename); if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); return ret; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::initAfterLoad() { +bool CAdGame::initAfterLoad() { CBGame::initAfterLoad(); CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); return STATUS_OK; @@ -1345,7 +1345,7 @@ void CAdGame::setPrevSceneFilename(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { +bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; @@ -1362,7 +1362,7 @@ ERRORCODE CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { CBGame::getVersion(verMajor, verMinor, NULL, NULL); if (extMajor) *extMajor = 0; @@ -1373,14 +1373,14 @@ ERRORCODE CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, by ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { +bool CAdGame::loadItemsFile(const char *filename, bool merge) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; //_filename = new char [strlen(filename)+1]; //strcpy(_filename, filename); @@ -1395,7 +1395,7 @@ ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { +bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE_END @@ -1473,7 +1473,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { +bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE_END @@ -1507,7 +1507,7 @@ ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { if (strcmp(name, "CreateEntityContainer") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); @@ -1525,7 +1525,7 @@ ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CSc ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); @@ -1536,7 +1536,7 @@ ERRORCODE CAdGame::startDlgBranch(const char *branchName, const char *scriptName ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; bool deleteName = false; if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { @@ -1583,7 +1583,7 @@ ERRORCODE CAdGame::endDlgBranch(const char *branchName, const char *scriptName, ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::clearBranchResponses(char *name) { +bool CAdGame::clearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.getSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; @@ -1596,7 +1596,7 @@ ERRORCODE CAdGame::clearBranchResponses(char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::addBranchResponse(int ID) { +bool CAdGame::addBranchResponse(int ID) { if (branchResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(_gameRef); r->_iD = ID; @@ -1619,7 +1619,7 @@ bool CAdGame::branchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::addGameResponse(int ID) { +bool CAdGame::addGameResponse(int ID) { if (gameResponseUsed(ID)) return STATUS_OK; CAdResponseContext *r = new CAdResponseContext(_gameRef); r->_iD = ID; @@ -1643,7 +1643,7 @@ bool CAdGame::gameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::resetResponse(int ID) { +bool CAdGame::resetResponse(int ID) { char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; int i; @@ -1672,7 +1672,7 @@ ERRORCODE CAdGame::resetResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { +bool CAdGame::displayContent(bool doUpdate, bool displayAll) { // init if (doUpdate) initLoop(); @@ -1740,7 +1740,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::registerInventory(CAdInventory *inv) { +bool CAdGame::registerInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) return STATUS_OK; } @@ -1751,7 +1751,7 @@ ERRORCODE CAdGame::registerInventory(CAdInventory *inv) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::unregisterInventory(CAdInventory *inv) { +bool CAdGame::unregisterInventory(CAdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); @@ -1786,14 +1786,14 @@ CAdItem *CAdGame::getItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::addItem(CAdItem *item) { +bool CAdGame::addItem(CAdItem *item) { _items.add(item); return _gameRef->registerObject(item); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::resetContent() { +bool CAdGame::resetContent() { // clear pending dialogs for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { delete [] _dlgPendingBranches[i]; @@ -1828,7 +1828,7 @@ ERRORCODE CAdGame::resetContent() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::deleteItem(CAdItem *item) { +bool CAdGame::deleteItem(CAdItem *item) { if (!item) return STATUS_FAILED; if (_selectedItem == item) _selectedItem = NULL; @@ -1853,7 +1853,7 @@ ERRORCODE CAdGame::deleteItem(CAdItem *item) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::addSpeechDir(const char *dir) { +bool CAdGame::addSpeechDir(const char *dir) { if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; @@ -1874,7 +1874,7 @@ ERRORCODE CAdGame::addSpeechDir(const char *dir) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::removeSpeechDir(const char *dir) { +bool CAdGame::removeSpeechDir(const char *dir) { if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; @@ -1931,7 +1931,7 @@ bool CAdGame::validMouse() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onMouseLeftDown() { +bool CAdGame::onMouseLeftDown() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { @@ -1959,7 +1959,7 @@ ERRORCODE CAdGame::onMouseLeftDown() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onMouseLeftUp() { +bool CAdGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::releaseCapture(); @@ -1978,7 +1978,7 @@ ERRORCODE CAdGame::onMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onMouseLeftDblClick() { +bool CAdGame::onMouseLeftDblClick() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; @@ -1997,7 +1997,7 @@ ERRORCODE CAdGame::onMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onMouseRightDown() { +bool CAdGame::onMouseRightDown() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { @@ -2022,7 +2022,7 @@ ERRORCODE CAdGame::onMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onMouseRightUp() { +bool CAdGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); @@ -2037,7 +2037,7 @@ ERRORCODE CAdGame::onMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::displayDebugInfo() { +bool CAdGame::displayDebugInfo() { char str[100]; if (_gameRef->_debugDebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); @@ -2051,7 +2051,7 @@ ERRORCODE CAdGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdGame::onScriptShutdown(CScScript *script) { +bool CAdGame::onScriptShutdown(CScScript *script) { if (_responseBox && _responseBox->_waitingScript == script) _responseBox->_waitingScript = NULL; diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h index 80a7bb7ea0..d677083db0 100644 --- a/engines/wintermute/Ad/AdGame.h +++ b/engines/wintermute/Ad/AdGame.h @@ -44,56 +44,56 @@ class CAdResponseContext; class CAdResponseBox; class CAdGame : public CBGame { public: - virtual ERRORCODE onScriptShutdown(CScScript *script); + virtual bool onScriptShutdown(CScScript *script); - virtual ERRORCODE onMouseLeftDown(); - virtual ERRORCODE onMouseLeftUp(); - virtual ERRORCODE onMouseLeftDblClick(); - virtual ERRORCODE onMouseRightDown(); - virtual ERRORCODE onMouseRightUp(); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); - virtual ERRORCODE displayDebugInfo(); + virtual bool displayDebugInfo(); - virtual ERRORCODE initAfterLoad(); + virtual bool initAfterLoad(); static void afterLoadScene(void *scene, void *data); bool _smartItemCursor; CBArray _speechDirs; - ERRORCODE addSpeechDir(const char *dir); - ERRORCODE removeSpeechDir(const char *dir); + bool addSpeechDir(const char *dir); + bool removeSpeechDir(const char *dir); char *findSpeechFile(char *StringID); - ERRORCODE deleteItem(CAdItem *Item); + bool deleteItem(CAdItem *Item); char *_itemsFile; bool _tempDisableSaveState; - virtual ERRORCODE resetContent(); - ERRORCODE addItem(CAdItem *item); + virtual bool resetContent(); + bool addItem(CAdItem *item); CAdItem *getItemByName(const char *name); CBArray _items; CAdObject *_inventoryOwner; bool isItemTaken(char *itemName); - ERRORCODE registerInventory(CAdInventory *inv); - ERRORCODE unregisterInventory(CAdInventory *inv); + bool registerInventory(CAdInventory *inv); + bool unregisterInventory(CAdInventory *inv); CAdObject *_invObject; CBArray _inventories; - virtual ERRORCODE displayContent(bool update = true, bool displayAll = false); + virtual bool displayContent(bool update = true, bool displayAll = false); char *_debugStartupScene; char *_startupScene; bool _initialScene; bool gameResponseUsed(int ID); - ERRORCODE addGameResponse(int ID); - ERRORCODE resetResponse(int ID); + bool addGameResponse(int ID); + bool resetResponse(int ID); bool branchResponseUsed(int ID); - ERRORCODE addBranchResponse(int ID); - ERRORCODE clearBranchResponses(char *name); - ERRORCODE startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - ERRORCODE endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool addBranchResponse(int ID); + bool clearBranchResponses(char *name); + bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); CAdSceneState *getSceneState(const char *filename, bool saving); CBViewport *_sceneViewport; @@ -104,31 +104,31 @@ public: TTalkSkipButton _talkSkipButton; - virtual ERRORCODE getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - ERRORCODE scheduleChangeScene(const char *filename, bool fadeIn); + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + bool scheduleChangeScene(const char *filename, bool fadeIn); char *_scheduledScene; bool _scheduledFadeIn; void setPrevSceneName(const char *name); void setPrevSceneFilename(const char *name); char *_prevSceneName; char *_prevSceneFilename; - virtual ERRORCODE loadGame(const char *filename); + virtual bool loadGame(const char *filename); CAdItem *_selectedItem; - ERRORCODE cleanup(); + bool cleanup(); DECLARE_PERSISTENT(CAdGame, CBGame) void finishSentences(); - ERRORCODE showCursor(); + bool showCursor(); TGameStateEx _stateEx; CAdResponseBox *_responseBox; CAdInventoryBox *_inventoryBox; - ERRORCODE displaySentences(bool frozen); + bool displaySentences(bool frozen); void addSentence(CAdSentence *sentence); - ERRORCODE changeScene(const char *filename, bool fadeIn); - ERRORCODE removeObject(CAdObject *object); - ERRORCODE addObject(CAdObject *object); + bool changeScene(const char *filename, bool fadeIn); + bool removeObject(CAdObject *object); + bool addObject(CAdObject *object); CAdScene *_scene; - ERRORCODE initLoop(); + bool initLoop(); CAdGame(); virtual ~CAdGame(); CBArray _objects; @@ -140,19 +140,19 @@ public: CBArray _responsesBranch; CBArray _responsesGame; - virtual ERRORCODE loadFile(const char *filename); - virtual ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); - ERRORCODE loadItemsFile(const char *filename, bool merge = false); - ERRORCODE loadItemsBuffer(byte *buffer, bool merge = false); + bool loadItemsFile(const char *filename, bool merge = false); + bool loadItemsBuffer(byte *buffer, bool merge = false); - virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); bool validMouse(); }; diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 24cf919165..30cb5e5b77 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -49,7 +49,7 @@ CAdInventory::~CAdInventory() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { +bool CAdInventory::insertItem(const char *name, const char *insertAfter) { if (name == NULL) return STATUS_FAILED; CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); @@ -74,7 +74,7 @@ ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventory::removeItem(const char *name) { +bool CAdInventory::removeItem(const char *name) { if (name == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.getSize(); i++) { @@ -91,7 +91,7 @@ ERRORCODE CAdInventory::removeItem(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventory::removeItem(CAdItem *item) { +bool CAdInventory::removeItem(CAdItem *item) { if (item == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.getSize(); i++) { @@ -106,7 +106,7 @@ ERRORCODE CAdInventory::removeItem(CAdItem *item) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventory::persist(CBPersistMgr *persistMgr) { +bool CAdInventory::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h index d78b78d89d..14929c8c4b 100644 --- a/engines/wintermute/Ad/AdInventory.h +++ b/engines/wintermute/Ad/AdInventory.h @@ -38,9 +38,9 @@ class CAdItem; class CAdInventory : public CBObject { public: DECLARE_PERSISTENT(CAdInventory, CBObject) - ERRORCODE removeItem(const char *name); - ERRORCODE removeItem(CAdItem *Item); - ERRORCODE insertItem(const char *name, const char *insertAfter = NULL); + bool removeItem(const char *name); + bool removeItem(CAdItem *Item); + bool insertItem(const char *name, const char *insertAfter = NULL); CAdInventory(CBGame *inGame); virtual ~CAdInventory(); CBArray _takenItems; diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 3b38903bbf..2e767574da 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -74,7 +74,7 @@ CAdInventoryBox::~CAdInventoryBox() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { +bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -98,7 +98,7 @@ ERRORCODE CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::display() { +bool CAdInventoryBox::display() { CAdGame *adGame = (CAdGame *)_gameRef; if (!_visible) return STATUS_OK; @@ -155,14 +155,14 @@ ERRORCODE CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::loadFile(const char *filename) { +bool CAdInventoryBox::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -193,7 +193,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { +bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -318,7 +318,7 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "INVENTORY_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -351,7 +351,7 @@ ERRORCODE CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdInventoryBox::persist(CBPersistMgr *persistMgr) { +bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_closeButton)); diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h index 857abd5d35..f6beae2d46 100644 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ b/engines/wintermute/Ad/AdInventoryBox.h @@ -45,18 +45,18 @@ public: int _itemHeight; int _itemWidth; bool _visible; - virtual ERRORCODE display(); + virtual bool display(); CUIButton *_closeButton; int _spacing; int _scrollOffset; Rect32 _itemsArea; - ERRORCODE listen(CBScriptHolder *param1, uint32 param2); + bool listen(CBScriptHolder *param1, uint32 param2); CUIWindow *_window; CAdInventoryBox(CBGame *inGame); virtual ~CAdInventoryBox(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index 1727950191..be2177456f 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -84,14 +84,14 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::loadFile(const char *filename) { +bool CAdItem::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { +bool CAdItem::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -319,7 +319,7 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::update() { +bool CAdItem::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -386,7 +386,7 @@ ERRORCODE CAdItem::update() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::display(int x, int y) { +bool CAdItem::display(int x, int y) { int width = 0; if (_currentSprite) { Rect32 rc; @@ -397,7 +397,7 @@ ERRORCODE CAdItem::display(int x, int y) { _posX = x + width / 2; _posY = y; - ERRORCODE ret; + bool ret; if (_currentSprite) ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); else ret = STATUS_OK; @@ -430,7 +430,7 @@ ERRORCODE CAdItem::display(int x, int y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// @@ -649,7 +649,7 @@ CScValue *CAdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::scSetProperty(const char *name, CScValue *value) { +bool CAdItem::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -730,7 +730,7 @@ const char *CAdItem::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdItem::persist(CBPersistMgr *persistMgr) { +bool CAdItem::persist(CBPersistMgr *persistMgr) { CAdTalkHolder::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h index f0810d95d1..fbbcd608d1 100644 --- a/engines/wintermute/Ad/AdItem.h +++ b/engines/wintermute/Ad/AdItem.h @@ -44,9 +44,9 @@ public: char *_amountString; - ERRORCODE update(); + bool update(); DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - ERRORCODE display(int x, int y); + bool display(int x, int y); bool getExtendedFlag(const char *flagName); bool _inInventory; bool _cursorCombined; @@ -55,13 +55,13 @@ public: CBSprite *_cursorHover; CAdItem(CBGame *inGame); virtual ~CAdItem(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index b7d8eb3cc2..1dd1efb8a6 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -61,14 +61,14 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::loadFile(const char *filename) { +bool CAdLayer::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -99,7 +99,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { +bool CAdLayer::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -226,7 +226,7 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// @@ -420,7 +420,7 @@ CScValue *CAdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::scSetProperty(const char *name, CScValue *value) { +bool CAdLayer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -477,7 +477,7 @@ const char *CAdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "LAYER {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -520,7 +520,7 @@ ERRORCODE CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdLayer::persist(CBPersistMgr *persistMgr) { +bool CAdLayer::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h index 29df4c0c34..0ccdb13ae7 100644 --- a/engines/wintermute/Ad/AdLayer.h +++ b/engines/wintermute/Ad/AdLayer.h @@ -42,14 +42,14 @@ public: CAdLayer(CBGame *inGame); virtual ~CAdLayer(); CBArray _nodes; - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 6d96c041a1..5037ec0272 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -92,7 +92,7 @@ void CAdNodeState::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdNodeState::persist(CBPersistMgr *persistMgr) { +bool CAdNodeState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_active)); @@ -129,7 +129,7 @@ char *CAdNodeState::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { +bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { if (!entity) return STATUS_FAILED; // hack! diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h index fcd1f1402b..186f2ebbb2 100644 --- a/engines/wintermute/Ad/AdNodeState.h +++ b/engines/wintermute/Ad/AdNodeState.h @@ -35,7 +35,7 @@ class CAdEntity; class CAdNodeState : public CBBase { public: - ERRORCODE transferEntity(CAdEntity *entity, bool includingSprites, bool saving); + bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); void setName(const char *name); void setFilename(const char *filename); void setCursor(const char *filename); diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 3321e5871f..451fca7fa6 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -151,7 +151,7 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::playAnim(const char *filename) { +bool CAdObject::playAnim(const char *filename) { delete _animSprite; _animSprite = NULL; _animSprite = new CBSprite(_gameRef, this); @@ -159,7 +159,7 @@ ERRORCODE CAdObject::playAnim(const char *filename) { _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); return STATUS_FAILED; } - ERRORCODE res = _animSprite->loadFile(filename); + bool res = _animSprite->loadFile(filename); if (DID_FAIL(res)) { _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); delete _animSprite; @@ -173,13 +173,13 @@ ERRORCODE CAdObject::playAnim(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::display() { +bool CAdObject::display() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::update() { +bool CAdObject::update() { return STATUS_OK; } @@ -187,7 +187,7 @@ ERRORCODE CAdObject::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync @@ -488,7 +488,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * int offsetX = stack->pop()->getInt(); int offsetY = stack->pop()->getInt(); - ERRORCODE res; + bool res; CAdEntity *ent = new CAdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; @@ -715,7 +715,7 @@ CScValue *CAdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::scSetProperty(const char *name, CScValue *value) { +bool CAdObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active @@ -792,7 +792,7 @@ const char *CAdObject::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::SetFont(const char *filename) { +bool CAdObject::SetFont(const char *filename) { if (_font) _gameRef->_fontStorage->removeFont(_font); if (filename) { _font = _gameRef->_fontStorage->addFont(filename); @@ -936,7 +936,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::reset() { +bool CAdObject::reset() { if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { delete _animSprite; _animSprite = NULL; @@ -953,7 +953,7 @@ ERRORCODE CAdObject::reset() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::persist(CBPersistMgr *persistMgr) { +bool CAdObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); @@ -998,7 +998,7 @@ ERRORCODE CAdObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::updateSounds() { +bool CAdObject::updateSounds() { if (_sentence && _sentence->_sound) updateOneSound(_sentence->_sound); @@ -1007,7 +1007,7 @@ ERRORCODE CAdObject::updateSounds() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::resetSoundPan() { +bool CAdObject::resetSoundPan() { if (_sentence && _sentence->_sound) { _sentence->_sound->setPan(0.0f); } @@ -1025,7 +1025,7 @@ bool CAdObject::getExtendedFlag(const char *flagName) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); @@ -1036,7 +1036,7 @@ ERRORCODE CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::updateBlockRegion() { +bool CAdObject::updateBlockRegion() { CAdGame *adGame = (CAdGame *)_gameRef; if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) @@ -1059,7 +1059,7 @@ CAdInventory *CAdObject::getInventory() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::afterMove() { +bool CAdObject::afterMove() { CAdRegion *newRegions[MAX_NUM_REGIONS]; ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); @@ -1087,14 +1087,14 @@ ERRORCODE CAdObject::afterMove() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::invalidateCurrRegions() { +bool CAdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { +bool CAdObject::getScale(float *scaleX, float *scaleY) { if (_zoomable) { if (_scaleX >= 0 || _scaleY >= 0) { *scaleX = _scaleX < 0 ? 100 : _scaleX; @@ -1108,7 +1108,7 @@ ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::updateSpriteAttachments() { +bool CAdObject::updateSpriteAttachments() { for (int i = 0; i < _attachmentsPre.getSize(); i++) { _attachmentsPre[i]->update(); } @@ -1119,7 +1119,7 @@ ERRORCODE CAdObject::updateSpriteAttachments() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::displaySpriteAttachments(bool preDisplay) { +bool CAdObject::displaySpriteAttachments(bool preDisplay) { if (preDisplay) { for (int i = 0; i < _attachmentsPre.getSize(); i++) { displaySpriteAttachment(_attachmentsPre[i]); @@ -1133,7 +1133,7 @@ ERRORCODE CAdObject::displaySpriteAttachments(bool preDisplay) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::displaySpriteAttachment(CAdObject *attachment) { +bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { if (!attachment->_active) return STATUS_OK; float scaleX, scaleY; @@ -1162,7 +1162,7 @@ ERRORCODE CAdObject::displaySpriteAttachment(CAdObject *attachment) { attachment->_registerAlias = this; attachment->_registrable = this->_registrable; - ERRORCODE ret = attachment->display(); + bool ret = attachment->display(); attachment->_posX = origX; attachment->_posY = origY; @@ -1187,7 +1187,7 @@ CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, i } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdObject::updatePartEmitter() { +bool CAdObject::updatePartEmitter() { if (!_partEmitter) return STATUS_FAILED; if (_partFollowParent) { diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h index 546089bada..6fb7c02b0f 100644 --- a/engines/wintermute/Ad/AdObject.h +++ b/engines/wintermute/Ad/AdObject.h @@ -47,12 +47,12 @@ class CAdObject : public CBObject { public: CPartEmitter *_partEmitter; virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); - virtual ERRORCODE updatePartEmitter(); + virtual bool updatePartEmitter(); bool _partFollowParent; int _partOffsetX; int _partOffsetY; - ERRORCODE invalidateCurrRegions(); + bool invalidateCurrRegions(); bool _subtitlesModRelative; bool _subtitlesModXCenter; int _subtitlesModX; @@ -61,23 +61,23 @@ public: CAdRegion *_stickRegion; bool _sceneIndependent; bool _ignoreItems; - ERRORCODE updateBlockRegion(); + bool updateBlockRegion(); bool _forcedTalkAnimUsed; char *_forcedTalkAnimName; virtual bool getExtendedFlag(const char *flagName); - virtual ERRORCODE resetSoundPan(); - virtual ERRORCODE updateSounds(); - ERRORCODE reset(); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool reset(); DECLARE_PERSISTENT(CAdObject, CBObject) virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); virtual int getHeight(); CAdSentence *_sentence; - ERRORCODE SetFont(const char *filename); - virtual ERRORCODE update(); - virtual ERRORCODE display(); + bool SetFont(const char *filename); + virtual bool update(); + virtual bool display(); bool _drawn; bool _active; - virtual ERRORCODE playAnim(const char *filename); + virtual bool playAnim(const char *filename); CBSprite *_animSprite; CBSprite *_currentSprite; TObjectState _state; @@ -93,29 +93,29 @@ public: CAdWaypointGroup *_currentWptGroup; CAdInventory *getInventory(); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual ERRORCODE afterMove(); + virtual bool afterMove(); CAdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); CBArray _attachmentsPre; CBArray _attachmentsPost; - ERRORCODE updateSpriteAttachments(); - ERRORCODE displaySpriteAttachments(bool preDisplay); + bool updateSpriteAttachments(); + bool displaySpriteAttachments(bool preDisplay); CAdObject *_registerAlias; private: - ERRORCODE displaySpriteAttachment(CAdObject *attachment); + bool displaySpriteAttachment(CAdObject *attachment); CAdInventory *_inventory; protected: - ERRORCODE getScale(float *scaleX, float *scaleY); + bool getScale(float *scaleX, float *scaleY); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 0aced4cabc..4f0c996157 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -98,7 +98,7 @@ bool CAdPath::setReady(bool ready) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdPath::persist(CBPersistMgr *persistMgr) { +bool CAdPath::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp index 17c2e41fb1..25e62b80e9 100644 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ b/engines/wintermute/Ad/AdPathPoint.cpp @@ -61,7 +61,7 @@ CAdPathPoint::~CAdPathPoint() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdPathPoint::persist(CBPersistMgr *persistMgr) { +bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { CBPoint::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index a37386e7b3..2c481db96d 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -54,14 +54,14 @@ CAdRegion::~CAdRegion() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::loadFile(const char *filename) { +bool CAdRegion::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -95,7 +95,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { +bool CAdRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -219,7 +219,7 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -294,7 +294,7 @@ CScValue *CAdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::scSetProperty(const char *name, CScValue *value) { +bool CAdRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -346,7 +346,7 @@ const char *CAdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "REGION {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -378,7 +378,7 @@ ERRORCODE CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRegion::persist(CBPersistMgr *persistMgr) { +bool CAdRegion::persist(CBPersistMgr *persistMgr) { CBRegion::persist(persistMgr); persistMgr->transfer(TMEMBER(_alpha)); diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h index 2b8d13b587..a565641de4 100644 --- a/engines/wintermute/Ad/AdRegion.h +++ b/engines/wintermute/Ad/AdRegion.h @@ -42,14 +42,14 @@ public: bool _decoration; CAdRegion(CBGame *inGame); virtual ~CAdRegion(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 0fd2245282..a74d1b960e 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -72,7 +72,7 @@ void CAdResponse::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponse::setIcon(const char *filename) { +bool CAdResponse::setIcon(const char *filename) { delete _icon; _icon = new CBSprite(_gameRef); if (!_icon || DID_FAIL(_icon->loadFile(filename))) { @@ -85,7 +85,7 @@ ERRORCODE CAdResponse::setIcon(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponse::setFont(const char *filename) { +bool CAdResponse::setFont(const char *filename) { if (_font) _gameRef->_fontStorage->removeFont(_font); _font = _gameRef->_fontStorage->addFont(filename); if (!_font) { @@ -96,7 +96,7 @@ ERRORCODE CAdResponse::setFont(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponse::setIconHover(const char *filename) { +bool CAdResponse::setIconHover(const char *filename) { delete _iconHover; _iconHover = new CBSprite(_gameRef); if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { @@ -110,7 +110,7 @@ ERRORCODE CAdResponse::setIconHover(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponse::setIconPressed(const char *filename) { +bool CAdResponse::setIconPressed(const char *filename) { delete _iconPressed; _iconPressed = new CBSprite(_gameRef); if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { @@ -124,7 +124,7 @@ ERRORCODE CAdResponse::setIconPressed(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponse::persist(CBPersistMgr *persistMgr) { +bool CAdResponse::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h index 46f16ea98f..f5ca08639b 100644 --- a/engines/wintermute/Ad/AdResponse.h +++ b/engines/wintermute/Ad/AdResponse.h @@ -38,10 +38,10 @@ class CBFont; class CAdResponse : public CBObject { public: DECLARE_PERSISTENT(CAdResponse, CBObject) - ERRORCODE setIcon(const char *filename); - ERRORCODE setFont(const char *filename); - ERRORCODE setIconHover(const char *filename); - ERRORCODE setIconPressed(const char *filename); + bool setIcon(const char *filename); + bool setFont(const char *filename); + bool setIconHover(const char *filename); + bool setIconPressed(const char *filename); void setText(const char *text); int _iD; CBSprite *_icon; diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index ef9d3a32c6..4e0bab38c7 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -111,7 +111,7 @@ void CAdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::invalidateButtons() { +bool CAdResponseBox::invalidateButtons() { for (int i = 0; i < _respButtons.getSize(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; @@ -125,7 +125,7 @@ ERRORCODE CAdResponseBox::invalidateButtons() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::createButtons() { +bool CAdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; @@ -187,14 +187,14 @@ ERRORCODE CAdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::loadFile(const char *filename) { +bool CAdResponseBox::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -223,7 +223,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { +bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -335,7 +335,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "RESPONSE_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -396,7 +396,7 @@ ERRORCODE CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::display() { +bool CAdResponseBox::display() { Rect32 rect = _responseArea; if (_window) { CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); @@ -482,7 +482,7 @@ ERRORCODE CAdResponseBox::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { +bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -511,7 +511,7 @@ ERRORCODE CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { +bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_font)); @@ -536,7 +536,7 @@ ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::weedResponses() { +bool CAdResponseBox::weedResponses() { CAdGame *adGame = (CAdGame *)_gameRef; for (int i = 0; i < _responses.getSize(); i++) { @@ -573,7 +573,7 @@ void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::handleResponse(CAdResponse *response) { +bool CAdResponseBox::handleResponse(CAdResponse *response) { setLastResponseText(response->_text, response->_textOrig); CAdGame *adGame = (CAdGame *)_gameRef; @@ -635,7 +635,7 @@ CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { +bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _respButtons.getSize(); i++) { objects.add(_respButtons[i]); } diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h index 86fe8ed947..ba2962a8f7 100644 --- a/engines/wintermute/Ad/AdResponseBox.h +++ b/engines/wintermute/Ad/AdResponseBox.h @@ -42,29 +42,29 @@ class CAdResponseBox : public CBObject { public: CBObject *getNextAccessObject(CBObject *CurrObject); CBObject *getPrevAccessObject(CBObject *CurrObject); - ERRORCODE getObjects(CBArray &objects, bool interactiveOnly); + bool getObjects(CBArray &objects, bool interactiveOnly); - ERRORCODE handleResponse(CAdResponse *response); + bool handleResponse(CAdResponse *response); void setLastResponseText(const char *text, const char *textOrig); char *_lastResponseText; char *_lastResponseTextOrig; DECLARE_PERSISTENT(CAdResponseBox, CBObject) CScScript *_waitingScript; - virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); + virtual bool listen(CBScriptHolder *param1, uint32 param2); typedef enum { EVENT_PREV, EVENT_NEXT, EVENT_RESPONSE } TResponseEvent; - ERRORCODE weedResponses(); - ERRORCODE display(); + bool weedResponses(); + bool display(); int _spacing; int _scrollOffset; CBFont *_fontHover; CBFont *_font; - ERRORCODE createButtons(); - ERRORCODE invalidateButtons(); + bool createButtons(); + bool invalidateButtons(); void clearButtons(); void clearResponses(); CAdResponseBox(CBGame *inGame); @@ -77,9 +77,9 @@ public: Rect32 _responseArea; int _verticalAlign; TTextAlign _align; - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index d44eb33403..77a84e651d 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -49,7 +49,7 @@ CAdResponseContext::~CAdResponseContext() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdResponseContext::persist(CBPersistMgr *persistMgr) { +bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_iD)); diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index aa1727cc3e..956a3efcab 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -53,14 +53,14 @@ CAdRotLevel::~CAdRotLevel() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRotLevel::loadFile(const char *filename) { +bool CAdRotLevel::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { +bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -135,7 +135,7 @@ ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); buffer->putTextIndent(indent + 2, "X=%d\n", _posX); buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); @@ -147,7 +147,7 @@ ERRORCODE CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdRotLevel::persist(CBPersistMgr *persistMgr) { +bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h index 76e2484b07..88b0b08aeb 100644 --- a/engines/wintermute/Ad/AdRotLevel.h +++ b/engines/wintermute/Ad/AdRotLevel.h @@ -39,9 +39,9 @@ public: CAdRotLevel(CBGame *inGame); virtual ~CAdRotLevel(); float _rotation; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index c756219382..58e62bd9b4 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -51,14 +51,14 @@ CAdScaleLevel::~CAdScaleLevel() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScaleLevel::loadFile(const char *filename) { +bool CAdScaleLevel::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -80,7 +80,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { +bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -133,7 +133,7 @@ ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); @@ -145,7 +145,7 @@ ERRORCODE CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScaleLevel::persist(CBPersistMgr *persistMgr) { +bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h index b62e18e344..5377325ed5 100644 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ b/engines/wintermute/Ad/AdScaleLevel.h @@ -40,9 +40,9 @@ public: float _scale; CAdScaleLevel(CBGame *inGame); virtual ~CAdScaleLevel(); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index e72b3211de..aad3ffdd1d 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -481,7 +481,7 @@ void CAdScene::pathFinderStep() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::initLoop() { +bool CAdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = _gameRef->_currentTime; @@ -500,14 +500,14 @@ ERRORCODE CAdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::loadFile(const char *filename) { +bool CAdScene::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; delete[] _filename; _filename = new char [strlen(filename) + 1]; @@ -565,7 +565,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { +bool CAdScene::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -856,7 +856,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::traverseNodes(bool doUpdate) { +bool CAdScene::traverseNodes(bool doUpdate) { if (!_initialized) return STATUS_OK; int j, k; @@ -1030,12 +1030,12 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::display() { +bool CAdScene::display() { return traverseNodes(false); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::updateFreeObjects() { +bool CAdScene::updateFreeObjects() { CAdGame *adGame = (CAdGame *)_gameRef; bool is3DSet; @@ -1067,7 +1067,7 @@ ERRORCODE CAdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { +bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { CAdGame *adGame = (CAdGame *)_gameRef; CBArray objects; CAdObject *obj; @@ -1130,7 +1130,7 @@ int CAdScene::compareObjs(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { +bool CAdScene::displayRegionContentOld(CAdRegion *region) { CAdGame *adGame = (CAdGame *)_gameRef; CAdObject *obj; @@ -1180,7 +1180,7 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::update() { +bool CAdScene::update() { return traverseNodes(true); } @@ -1240,7 +1240,7 @@ void CAdScene::skipTo(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// @@ -1834,7 +1834,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::scSetProperty(const char *name, CScValue *value) { +bool CAdScene::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1942,14 +1942,14 @@ const char *CAdScene::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::addObject(CAdObject *object) { +bool CAdScene::addObject(CAdObject *object) { _objects.add(object); return _gameRef->registerObject(object); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::removeObject(CAdObject *object) { +bool CAdScene::removeObject(CAdObject *object) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { _objects.removeAt(i); @@ -1961,7 +1961,7 @@ ERRORCODE CAdScene::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { int i; buffer->putTextIndent(indent, "SCENE {\n"); @@ -2059,7 +2059,7 @@ ERRORCODE CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::sortScaleLevels() { +bool CAdScene::sortScaleLevels() { bool changed; do { changed = false; @@ -2080,7 +2080,7 @@ ERRORCODE CAdScene::sortScaleLevels() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::sortRotLevels() { +bool CAdScene::sortRotLevels() { bool changed; do { changed = false; @@ -2127,7 +2127,7 @@ float CAdScene::getScaleAt(int Y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::persist(CBPersistMgr *persistMgr) { +bool CAdScene::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_autoScroll)); @@ -2187,12 +2187,12 @@ ERRORCODE CAdScene::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::afterLoad() { +bool CAdScene::afterLoad() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { +bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; int x1, y1, x2, y2; @@ -2251,7 +2251,7 @@ ERRORCODE CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, in } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { +bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { int x = *argX; int y = *argY; @@ -2350,7 +2350,7 @@ void CAdScene::pfPointsAdd(int x, int y, int distance) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { +bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { CAdGame *adGame = (CAdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (offsetX) *offsetX = _viewport->_offsetX; @@ -2367,7 +2367,7 @@ ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::getViewportSize(int *width, int *height) { +bool CAdScene::getViewportSize(int *width, int *height) { CAdGame *adGame = (CAdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (width) *width = _viewport->getWidth(); @@ -2464,19 +2464,19 @@ CBObject *CAdScene::getNodeByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::saveState() { +bool CAdScene::saveState() { return persistState(true); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::loadState() { +bool CAdScene::loadState() { return persistState(false); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::persistState(bool saving) { +bool CAdScene::persistState(bool saving) { if (!_persistentState) return STATUS_OK; CAdGame *adGame = (CAdGame *)_gameRef; @@ -2568,7 +2568,7 @@ float CAdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { +bool CAdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _layers.getSize(); i++) { CAdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.getSize(); j++) { @@ -2592,7 +2592,7 @@ ERRORCODE CAdScene::handleItemAssociations(const char *itemName, bool show) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { +bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { int numUsed = 0; if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { @@ -2613,7 +2613,7 @@ ERRORCODE CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRe } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::restoreDeviceObjects() { +bool CAdScene::restoreDeviceObjects() { return STATUS_OK; } @@ -2660,7 +2660,7 @@ CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { +bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.getSize(); i++) { // close-up layer -> remove everything below it if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); @@ -2719,7 +2719,7 @@ ERRORCODE CAdScene::getSceneObjects(CBArray &objects, ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { +bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { CAdGame *adGame = (CAdGame *)_gameRef; CAdObject *obj; diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h index d47d727884..72c69e668a 100644 --- a/engines/wintermute/Ad/AdScene.h +++ b/engines/wintermute/Ad/AdScene.h @@ -49,17 +49,17 @@ public: CBObject *getNextAccessObject(CBObject *CurrObject); CBObject *getPrevAccessObject(CBObject *CurrObject); - ERRORCODE getSceneObjects(CBArray &Objects, bool InteractiveOnly); - ERRORCODE getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + bool getSceneObjects(CBArray &Objects, bool InteractiveOnly); + bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - ERRORCODE afterLoad(); + bool afterLoad(); - ERRORCODE getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - ERRORCODE handleItemAssociations(const char *ItemName, bool Show); + bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + bool handleItemAssociations(const char *ItemName, bool Show); CUIWindow *_shieldWindow; float getRotationAt(int X, int Y); - ERRORCODE loadState(); - ERRORCODE saveState(); + bool loadState(); + bool saveState(); bool _persistentState; bool _persistentStateSprites; CBObject *getNodeByName(const char *name); @@ -67,27 +67,27 @@ public: bool pointInViewport(int X, int Y); int getOffsetTop(); int getOffsetLeft(); - ERRORCODE getViewportSize(int *Width = NULL, int *Height = NULL); - ERRORCODE getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + bool getViewportSize(int *Width = NULL, int *Height = NULL); + bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); CBViewport *_viewport; CBFader *_fader; int _pfPointsNum; void pfPointsAdd(int X, int Y, int Distance); void pfPointsStart(); bool _initialized; - ERRORCODE correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - ERRORCODE correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); DECLARE_PERSISTENT(CAdScene, CBObject) - ERRORCODE displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - ERRORCODE displayRegionContentOld(CAdRegion *Region = NULL); + bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + bool displayRegionContentOld(CAdRegion *Region = NULL); static int compareObjs(const void *Obj1, const void *Obj2); - ERRORCODE updateFreeObjects(); - ERRORCODE traverseNodes(bool Update = false); + bool updateFreeObjects(); + bool traverseNodes(bool Update = false); float getScaleAt(int Y); - ERRORCODE sortScaleLevels(); - ERRORCODE sortRotLevels(); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool sortScaleLevels(); + bool sortRotLevels(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; void skipTo(int OffsetX, int OffsetY); @@ -96,7 +96,7 @@ public: void skipToObject(CBObject *Object); void scrollToObject(CBObject *Object); void scrollTo(int OffsetX, int OffsetY); - virtual ERRORCODE update(); + virtual bool update(); bool _autoScroll; int _targetOffsetTop; int _targetOffsetLeft; @@ -109,9 +109,9 @@ public: uint32 _scrollTimeH; uint32 _lastTimeH; - virtual ERRORCODE display(); + virtual bool display(); uint32 _pfMaxTime; - ERRORCODE initLoop(); + bool initLoop(); void pathFinderStep(); bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); @@ -123,12 +123,12 @@ public: CBArray _layers; CBArray _objects; CBArray _waypointGroups; - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); int _width; int _height; - ERRORCODE addObject(CAdObject *Object); - ERRORCODE removeObject(CAdObject *Object); + bool addObject(CAdObject *Object); + bool removeObject(CAdObject *Object); int _editorMarginH; int _editorMarginV; uint32 _editorColFrame; @@ -152,18 +152,18 @@ public: CBArray _scaleLevels; CBArray _rotLevels; - virtual ERRORCODE restoreDeviceObjects(); + virtual bool restoreDeviceObjects(); int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: - ERRORCODE persistState(bool Saving = true); + bool persistState(bool Saving = true); void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); bool _pfReady; CBPoint *_pfTarget; diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 687dbdaeef..38de185918 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -53,7 +53,7 @@ CAdSceneNode::~CAdSceneNode() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { +bool CAdSceneNode::setEntity(CAdEntity *entity) { _type = OBJECT_ENTITY; _entity = entity; return _gameRef->registerObject(entity); @@ -61,7 +61,7 @@ ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSceneNode::setRegion(CAdRegion *region) { +bool CAdSceneNode::setRegion(CAdRegion *region) { _type = OBJECT_REGION; _region = region; return _gameRef->registerObject(region); @@ -69,7 +69,7 @@ ERRORCODE CAdSceneNode::setRegion(CAdRegion *region) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSceneNode::persist(CBPersistMgr *persistMgr) { +bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h index 931d859cca..808bfceef4 100644 --- a/engines/wintermute/Ad/AdSceneNode.h +++ b/engines/wintermute/Ad/AdSceneNode.h @@ -39,8 +39,8 @@ namespace WinterMute { class CAdSceneNode : public CBObject { public: DECLARE_PERSISTENT(CAdSceneNode, CBObject) - ERRORCODE setRegion(CAdRegion *region); - ERRORCODE setEntity(CAdEntity *entity); + bool setRegion(CAdRegion *region); + bool setEntity(CAdEntity *entity); CAdEntity *_entity; CAdRegion *_region; TObjectType _type; diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index b10da397b8..e56c5f479a 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -54,7 +54,7 @@ CAdSceneState::~CAdSceneState() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSceneState::persist(CBPersistMgr *persistMgr) { +bool CAdSceneState::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); _nodeStates.persist(persistMgr); diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index cfff93b488..8c830a15f1 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -165,7 +165,7 @@ char *CAdSentence::getStance(int stance) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSentence::display() { +bool CAdSentence::display() { if (!_font || !_text) return STATUS_FAILED; if (_sound && !_soundStarted) { @@ -204,14 +204,14 @@ void CAdSentence::setSound(CBSound *sound) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSentence::finish() { +bool CAdSentence::finish() { if (_sound) _sound->stop(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSentence::persist(CBPersistMgr *persistMgr) { +bool CAdSentence::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -238,7 +238,7 @@ ERRORCODE CAdSentence::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSentence::setupTalkFile(const char *soundFilename) { +bool CAdSentence::setupTalkFile(const char *soundFilename) { delete _talkDef; _talkDef = NULL; _currentSprite = NULL; @@ -270,7 +270,7 @@ ERRORCODE CAdSentence::setupTalkFile(const char *soundFilename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSentence::update(TDirection dir) { +bool CAdSentence::update(TDirection dir) { if (!_talkDef) return STATUS_OK; uint32 currentTime; diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 86a3c57c99..22a6cae39d 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -47,15 +47,15 @@ public: bool _fixedPos; CBSprite *_currentSprite; char *_currentSkelAnim; - ERRORCODE update(TDirection dir = DI_DOWN); - ERRORCODE setupTalkFile(const char *soundFilename); + bool update(TDirection dir = DI_DOWN); + bool setupTalkFile(const char *soundFilename); DECLARE_PERSISTENT(CAdSentence, CBBase) - ERRORCODE finish(); + bool finish(); void setSound(CBSound *Sound); bool _soundStarted; CBSound *_sound; TTextAlign _align; - ERRORCODE display(); + bool display(); int _width; Point32 _pos; CBFont *_font; diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index f93530c449..a5ed4feb0c 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -58,14 +58,14 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); @@ -90,7 +90,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { +bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -214,7 +214,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSpriteSet::persist(CBPersistMgr *persistMgr) { +bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -258,7 +258,7 @@ CBSprite *CAdSpriteSet::getSprite(TDirection direction) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITESET {\n"); if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h index 2329c955e1..1c559fb77b 100644 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ b/engines/wintermute/Ad/AdSpriteSet.h @@ -38,14 +38,14 @@ namespace WinterMute { class CAdSpriteSet : public CBObject { public: bool containsSprite(CBSprite *sprite); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); CBSprite *getSprite(TDirection direction); DECLARE_PERSISTENT(CAdSpriteSet, CBObject) CBObject *_owner; CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); virtual ~CAdSpriteSet(); - ERRORCODE loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - ERRORCODE loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); CBSprite *_sprites[NUM_DIRECTIONS]; }; diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 09ef66a946..9f31d9f61e 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -69,14 +69,14 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkDef::loadFile(const char *filename) { +bool CAdTalkDef::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; CBUtils::setString(&_filename, filename); @@ -98,7 +98,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { +bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -194,7 +194,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkDef::persist(CBPersistMgr *persistMgr) { +bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -210,7 +210,7 @@ ERRORCODE CAdTalkDef::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TALK {\n"); if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); @@ -230,7 +230,7 @@ ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkDef::loadDefaultSprite() { +bool CAdTalkDef::loadDefaultSprite() { if (_defaultSpriteFilename && !_defaultSprite) { _defaultSprite = new CBSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h index 1a0cc4d7d8..cece5be4da 100644 --- a/engines/wintermute/Ad/AdTalkDef.h +++ b/engines/wintermute/Ad/AdTalkDef.h @@ -40,17 +40,17 @@ public: char *_defaultSpriteSetFilename; CAdSpriteSet *_defaultSpriteSet; CBSprite *getDefaultSprite(TDirection Dir); - ERRORCODE loadDefaultSprite(); + bool loadDefaultSprite(); DECLARE_PERSISTENT(CAdTalkDef, CBObject) CAdTalkDef(CBGame *inGame); virtual ~CAdTalkDef(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); CBArray _nodes; char *_defaultSpriteFilename; CBSprite *_defaultSprite; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index d7e13a5af4..2626021054 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -73,7 +73,7 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { delete _animSprite; _animSprite = new CBSprite(_gameRef, this); if (_animSprite) { - ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName); + bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; @@ -119,7 +119,7 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// @@ -316,7 +316,7 @@ CScValue *CAdTalkHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { +bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Item @@ -337,7 +337,7 @@ const char *CAdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { for (int i = 0; i < _talkSprites.getSize(); i++) { if (_talkSprites[i]->_filename) buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); @@ -353,7 +353,7 @@ ERRORCODE CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkHolder::persist(CBPersistMgr *persistMgr) { +bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { CAdObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_sprite)); diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h index ab3904a1cb..a427c9eb04 100644 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ b/engines/wintermute/Ad/AdTalkHolder.h @@ -37,7 +37,7 @@ class CAdTalkHolder : public CAdObject { public: DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) virtual CBSprite *getTalkStance(const char *stance); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); CBSprite *_sprite; CBArray _talkSprites; CBArray _talkSpritesEx; @@ -46,8 +46,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 30c32c4db4..58644e7ca0 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -80,7 +80,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { +bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -186,7 +186,7 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkNode::persist(CBPersistMgr *persistMgr) { +bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_comment)); persistMgr->transfer(TMEMBER(_startTime)); persistMgr->transfer(TMEMBER(_endTime)); @@ -201,7 +201,7 @@ ERRORCODE CAdTalkNode::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ACTION {\n"); if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); @@ -220,7 +220,7 @@ ERRORCODE CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdTalkNode::loadSprite() { +bool CAdTalkNode::loadSprite() { if (_spriteFilename && !_sprite) { _sprite = new CBSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h index 3d763ea0f0..3718340c0e 100644 --- a/engines/wintermute/Ad/AdTalkNode.h +++ b/engines/wintermute/Ad/AdTalkNode.h @@ -41,13 +41,13 @@ public: CAdSpriteSet *_spriteSet; CBSprite *getSprite(TDirection dir); bool isInTimeInterval(uint32 time, TDirection dir); - ERRORCODE loadSprite(); + bool loadSprite(); DECLARE_PERSISTENT(CAdTalkNode, CBBase) CAdTalkNode(CBGame *inGame); virtual ~CAdTalkNode(); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); char *_spriteFilename; CBSprite *_sprite; uint32 _startTime; diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 0210095c28..ec0d66d468 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -64,14 +64,14 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::loadFile(const char *filename) { +bool CAdWaypointGroup::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -96,7 +96,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { +bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -164,7 +164,7 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { +bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WAYPOINTS {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); @@ -185,7 +185,7 @@ ERRORCODE CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { +bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -225,7 +225,7 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { +bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// @@ -239,7 +239,7 @@ ERRORCODE CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { +bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; cleanup(); diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h index 7e06ef661d..26a3c9a627 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ b/engines/wintermute/Ad/AdWaypointGroup.h @@ -39,18 +39,18 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - ERRORCODE mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); + bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); bool _active; CAdWaypointGroup(CBGame *inGame); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); virtual ~CAdWaypointGroup(); CBArray _points; int _editorSelectedPoint; virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual bool scSetProperty(const char *name, CScValue *value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp index bdfcfccdd5..63fddba489 100644 --- a/engines/wintermute/Base/BBase.cpp +++ b/engines/wintermute/Base/BBase.cpp @@ -65,7 +65,7 @@ const char *CBBase::getEditorProp(const char *propName, const char *initVal) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBBase::setEditorProp(const char *propName, const char *propValue) { +bool CBBase::setEditorProp(const char *propName, const char *propValue) { if (propName == NULL) return STATUS_FAILED; if (propValue == NULL) { @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { +bool CBBase::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -159,7 +159,7 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBBase::saveAsText(CBDynBuffer *buffer, int indent) { +bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h index afbe277529..e8c87f1f9e 100644 --- a/engines/wintermute/Base/BBase.h +++ b/engines/wintermute/Base/BBase.h @@ -43,11 +43,11 @@ class CBDynBuffer; class CBBase { public: bool _persistable; - ERRORCODE setEditorProp(const char *propName, const char *propValue); + bool setEditorProp(const char *propName, const char *propValue); const char *getEditorProp(const char *propName, const char *initVal = NULL); CBBase(TDynamicConstructor, TDynamicConstructor) {}; - ERRORCODE parseEditorProperty(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0); + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); CBBase(); CBGame *_gameRef; CBBase(CBGame *GameOwner); diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp index 1d3f0c4826..4e83579d04 100644 --- a/engines/wintermute/Base/BDebugger.cpp +++ b/engines/wintermute/Base/BDebugger.cpp @@ -41,84 +41,84 @@ CBDebugger::~CBDebugger(void) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::initialize() { +bool CBDebugger::initialize() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::shutdown() { +bool CBDebugger::shutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onGameInit() { +bool CBDebugger::onGameInit() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onGameShutdown() { +bool CBDebugger::onGameShutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onGameTick() { +bool CBDebugger::onGameTick() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onLog(unsigned int errorCode, const char *text) { +bool CBDebugger::onLog(unsigned int errorCode, const char *text) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptInit(CScScript *script) { +bool CBDebugger::onScriptInit(CScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptShutdown(CScScript *script) { +bool CBDebugger::onScriptShutdown(CScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptChangeLine(CScScript *script, int Line) { +bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { +bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { +bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { +bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { +bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDebugger::onScriptHitBreakpoint(CScScript *script) { +bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { return STATUS_OK; } diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h index a3da66cc9f..548519b0a0 100644 --- a/engines/wintermute/Base/BDebugger.h +++ b/engines/wintermute/Base/BDebugger.h @@ -45,26 +45,26 @@ public: // initialization bool _enabled; - ERRORCODE initialize(); - ERRORCODE shutdown(); + bool initialize(); + bool shutdown(); // internal interface - ERRORCODE onGameInit(); - ERRORCODE onGameShutdown(); - ERRORCODE onGameTick(); - ERRORCODE onLog(unsigned int errorCode, const char *text); - ERRORCODE onScriptInit(CScScript *script); - ERRORCODE onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - ERRORCODE onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - ERRORCODE onScriptShutdown(CScScript *script); - ERRORCODE onScriptChangeLine(CScScript *script, int line); - ERRORCODE onScriptChangeScope(CScScript *script, CScValue *scope); - ERRORCODE onScriptShutdownScope(CScScript *script, CScValue *scope); - ERRORCODE onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - ERRORCODE onVariableChangeValue(CScValue *var, CScValue *value); - - ERRORCODE onScriptHitBreakpoint(CScScript *script); + bool onGameInit(); + bool onGameShutdown(); + bool onGameTick(); + bool onLog(unsigned int errorCode, const char *text); + bool onScriptInit(CScScript *script); + bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + bool onScriptShutdown(CScScript *script); + bool onScriptChangeLine(CScScript *script, int line); + bool onScriptChangeScope(CScScript *script, CScValue *scope); + bool onScriptShutdownScope(CScScript *script, CScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + bool onVariableChangeValue(CScValue *var, CScValue *value); + + bool onScriptHitBreakpoint(CScScript *script); // IWmeDebugServer interface virtual bool attachClient(IWmeDebugClient *client); diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp index ff13f96d6c..fec49e3c8f 100644 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ b/engines/wintermute/Base/BDynBuffer.cpp @@ -69,7 +69,7 @@ uint32 CBDynBuffer::getSize() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDynBuffer::init(uint32 initSize) { +bool CBDynBuffer::init(uint32 initSize) { cleanup(); if (initSize == 0) initSize = _initSize; @@ -88,7 +88,7 @@ ERRORCODE CBDynBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDynBuffer::putBytes(byte *buffer, uint32 size) { +bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { if (!_initialized) init(); while (_offset + size > _realSize) { @@ -109,7 +109,7 @@ ERRORCODE CBDynBuffer::putBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBDynBuffer::getBytes(byte *buffer, uint32 size) { +bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { if (!_initialized) init(); if (_offset + size > _size) { diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h index 1826a81c30..6df01903c7 100644 --- a/engines/wintermute/Base/BDynBuffer.h +++ b/engines/wintermute/Base/BDynBuffer.h @@ -43,10 +43,10 @@ public: void putDWORD(uint32 val); char *getString(); void putString(const char *val); - ERRORCODE getBytes(byte *buffer, uint32 size); - ERRORCODE putBytes(byte *buffer, uint32 size); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); uint32 getSize(); - ERRORCODE init(uint32 initSize = 0); + bool init(uint32 initSize = 0); void cleanup(); uint32 _size; byte *_buffer; diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp index d8bfbf412d..b99244af55 100644 --- a/engines/wintermute/Base/BFader.cpp +++ b/engines/wintermute/Base/BFader.cpp @@ -60,7 +60,7 @@ CBFader::~CBFader() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::update() { +bool CBFader::update() { if (!_active) return STATUS_OK; int alphaDelta = _targetAlpha - _sourceAlpha; @@ -84,7 +84,7 @@ ERRORCODE CBFader::update() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::display() { +bool CBFader::display() { if (!_active) return STATUS_OK; if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); @@ -93,7 +93,7 @@ ERRORCODE CBFader::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::deactivate() { +bool CBFader::deactivate() { _active = false; _ready = true; return STATUS_OK; @@ -101,7 +101,7 @@ ERRORCODE CBFader::deactivate() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { +bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -123,7 +123,7 @@ ERRORCODE CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { +bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -154,7 +154,7 @@ uint32 CBFader::getCurrentColor() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFader::persist(CBPersistMgr *persistMgr) { +bool CBFader::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h index 623bd220bc..8c9d7d0a7c 100644 --- a/engines/wintermute/Base/BFader.h +++ b/engines/wintermute/Base/BFader.h @@ -38,11 +38,11 @@ class CBFader : public CBObject { public: bool _system; uint32 getCurrentColor(); - ERRORCODE fadeOut(uint32 targetColor, uint32 duration, bool system = false); - ERRORCODE fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - ERRORCODE deactivate(); - ERRORCODE display(); - ERRORCODE update(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); DECLARE_PERSISTENT(CBFader, CBObject) CBFader(CBGame *inGame); virtual ~CBFader(); diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 113dbbe5d0..7dd7d6f0e8 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -73,7 +73,7 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::cleanup() { +bool CBFileManager::cleanup() { // delete registered paths for (int i = 0; i < _singlePaths.getSize(); i++) delete [] _singlePaths[i]; @@ -160,7 +160,7 @@ Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &fi } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { +bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { // TODO warning("Implement SaveFile"); @@ -223,7 +223,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer, ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { +bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (int i = 0; i < _packages.getSize(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); @@ -235,7 +235,7 @@ ERRORCODE CBFileManager::requestCD(int cd, char *packageFile, const char *filena ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::addPath(TPathType type, const Common::String &path) { +bool CBFileManager::addPath(TPathType type, const Common::String &path) { if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); @@ -260,7 +260,7 @@ ERRORCODE CBFileManager::addPath(TPathType type, const Common::String &path) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::reloadPaths() { +bool CBFileManager::reloadPaths() { // delete registered paths for (int i = 0; i < _singlePaths.getSize(); i++) delete [] _singlePaths[i]; @@ -276,7 +276,7 @@ ERRORCODE CBFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::initPaths() { +bool CBFileManager::initPaths() { restoreCurrentDir(); AnsiString pathList; @@ -318,7 +318,7 @@ ERRORCODE CBFileManager::initPaths() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::registerPackages() { +bool CBFileManager::registerPackages() { restoreCurrentDir(); _gameRef->LOG(0, "Scanning packages..."); @@ -366,7 +366,7 @@ ERRORCODE CBFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { // FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); @@ -632,7 +632,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::closeFile(Common::SeekableReadStream *File) { +bool CBFileManager::closeFile(Common::SeekableReadStream *File) { for (int i = 0; i < _openFiles.getSize(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; @@ -676,7 +676,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::restoreCurrentDir() { +bool CBFileManager::restoreCurrentDir() { if (!_basePath) return STATUS_OK; else { /*if (!chdir(_basePath)) return STATUS_OK; @@ -688,7 +688,7 @@ ERRORCODE CBFileManager::restoreCurrentDir() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFileManager::setBasePath(const Common::String &path) { +bool CBFileManager::setBasePath(const Common::String &path) { cleanup(); if (path.c_str()) { diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index 06c812199c..aebaa6f3fc 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -43,28 +43,28 @@ class CBFile; class CBFileManager: CBBase { public: bool findPackageSignature(Common::File *f, uint32 *offset); - ERRORCODE cleanup(); - ERRORCODE setBasePath(const Common::String &path); - ERRORCODE restoreCurrentDir(); + bool cleanup(); + bool setBasePath(const Common::String &path); + bool restoreCurrentDir(); char *_basePath; bool getFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *openFileRaw(const Common::String &filename); - ERRORCODE closeFile(Common::SeekableReadStream *File); + bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); CBFileEntry *getPackageEntry(const Common::String &filename); Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); - ERRORCODE registerPackages(); - ERRORCODE initPaths(); - ERRORCODE reloadPaths(); + bool registerPackages(); + bool initPaths(); + bool reloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - ERRORCODE addPath(TPathType type, const Common::String &path); - ERRORCODE requestCD(int cd, char *packageFile, const char *filename); + bool addPath(TPathType type, const Common::String &path); + bool requestCD(int cd, char *packageFile, const char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - ERRORCODE saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); @@ -75,7 +75,7 @@ public: Common::HashMap _files; private: - ERRORCODE registerPackage(const Common::String &filename, bool searchSignature = false); + bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp index e77235efa7..66a63c6a8f 100644 --- a/engines/wintermute/Base/BFrame.cpp +++ b/engines/wintermute/Base/BFrame.cpp @@ -75,8 +75,8 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - ERRORCODE res; +bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; for (int i = 0; i < _subframes.getSize(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); @@ -87,7 +87,7 @@ ERRORCODE CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, floa ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { +bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { if (_sound && !muted) { if (owner) owner->updateOneSound(_sound); _sound->play(); @@ -131,7 +131,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -341,7 +341,7 @@ bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float sc ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { +bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); @@ -379,7 +379,7 @@ ERRORCODE CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::persist(CBPersistMgr *persistMgr) { +bool CBFrame::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); _applyEvent.persist(persistMgr); @@ -399,7 +399,7 @@ ERRORCODE CBFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -648,7 +648,7 @@ CScValue *CBFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFrame::scSetProperty(const char *name, CScValue *value) { +bool CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h index 715a97ea69..537471c953 100644 --- a/engines/wintermute/Base/BFrame.h +++ b/engines/wintermute/Base/BFrame.h @@ -42,18 +42,18 @@ class CBFrame: public CBScriptable { public: bool _killSound; bool _keyframe; - ERRORCODE oneTimeDisplay(CBObject *owner, bool muted = false); + bool oneTimeDisplay(CBObject *owner, bool muted = false); DECLARE_PERSISTENT(CBFrame, CBScriptable) CBSound *_sound; bool _editorExpanded; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool saveAsText(CBDynBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; CBArray _subframes; - ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); CBFrame(CBGame *inGame); virtual ~CBFrame(); @@ -62,8 +62,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 4acd916e94..02af945d8c 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -335,7 +335,7 @@ CBGame::~CBGame() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::cleanup() { +bool CBGame::cleanup() { delete _loadingIcon; _loadingIcon = NULL; @@ -414,7 +414,7 @@ ERRORCODE CBGame::cleanup() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initialize1() { +bool CBGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { _surfaceStorage = new CBSurfaceStorage(this); @@ -483,7 +483,7 @@ ERRORCODE CBGame::initialize1() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initialize2() { // we know whether we are going to be accelerated +bool CBGame::initialize2() { // we know whether we are going to be accelerated _renderer = makeSDLRenderer(this); if (_renderer == NULL) return STATUS_FAILED; @@ -492,7 +492,7 @@ ERRORCODE CBGame::initialize2() { // we know whether we are going to be accelera ////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initialize3() { // renderer is initialized +bool CBGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; @@ -550,7 +550,7 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// -void CBGame::LOG(ERRORCODE res, const char *fmt, ...) { +void CBGame::LOG(bool res, const char *fmt, ...) { uint32 secs = g_system->getMillis() / 1000; uint32 hours = secs / 3600; secs = secs % 3600; @@ -587,7 +587,7 @@ void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initLoop() { +bool CBGame::initLoop() { _viewportSP = -1; _currentTime = CBPlatform::getTime(); @@ -645,7 +645,7 @@ ERRORCODE CBGame::initLoop() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initInput() { +bool CBGame::initInput() { return STATUS_OK; } @@ -670,14 +670,14 @@ void CBGame::getOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::loadFile(const char *filename) { +bool CBGame::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -740,7 +740,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { +bool CBGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -960,7 +960,7 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -975,7 +975,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - ERRORCODE res = CBObject::scCallMethod(script, stack, thisStack, name); + bool res = CBObject::scCallMethod(script, stack, thisStack, name); setWindowTitle(); return res; } @@ -2539,7 +2539,7 @@ CScValue *CBGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { +bool CBGame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -2571,7 +2571,7 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - ERRORCODE res = CBObject::scSetProperty(name, value); + bool res = CBObject::scSetProperty(name, value); setWindowTitle(); return res; } @@ -2742,7 +2742,7 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayQuickMsg() { +bool CBGame::displayQuickMsg() { if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; // update @@ -2790,14 +2790,14 @@ void CBGame::quickMessageForm(char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::registerObject(CBObject *object) { +bool CBGame::registerObject(CBObject *object) { _regObjects.add(object); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::unregisterObject(CBObject *object) { +bool CBGame::unregisterObject(CBObject *object) { if (!object) return STATUS_OK; // is it a window? @@ -2859,7 +2859,7 @@ bool CBGame::validObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { +bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { CScValue *thisObj; ////////////////////////////////////////////////////////////////////////// @@ -3143,7 +3143,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::showCursor() { +bool CBGame::showCursor() { if (_cursorHidden) return STATUS_OK; if (!_interactive && _gameRef->_state == GAME_RUNNING) { @@ -3160,7 +3160,7 @@ ERRORCODE CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { +bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -3168,7 +3168,7 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) { _gameRef->applyEvent("BeforeSave", true); - ERRORCODE ret; + bool ret; _indicatorDisplay = true; _indicatorProgress = 0; @@ -3206,7 +3206,7 @@ save_finish: // TODO: Remove gotos ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::loadGame(int slot) { +bool CBGame::loadGame(int slot) { //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); _loading = false; @@ -3220,11 +3220,11 @@ ERRORCODE CBGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::loadGame(const char *filename) { +bool CBGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); getDebugMgr()->onGameShutdown(); - ERRORCODE ret; + bool ret; delete _saveLoadImage; _saveLoadImage = NULL; @@ -3276,7 +3276,7 @@ load_finish: ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::initAfterLoad() { +bool CBGame::initAfterLoad() { CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); @@ -3317,8 +3317,8 @@ void CBGame::afterLoadScript(void *script, void *data) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayWindows(bool inGame) { - ERRORCODE res; +bool CBGame::displayWindows(bool inGame) { + bool res; // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { @@ -3345,7 +3345,7 @@ ERRORCODE CBGame::displayWindows(bool inGame) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { +bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3371,7 +3371,7 @@ ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uin ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::stopMusic(int channel) { +bool CBGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3387,7 +3387,7 @@ ERRORCODE CBGame::stopMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::pauseMusic(int channel) { +bool CBGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3399,7 +3399,7 @@ ERRORCODE CBGame::pauseMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::resumeMusic(int channel) { +bool CBGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3411,7 +3411,7 @@ ERRORCODE CBGame::resumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::setMusicStartTime(int channel, uint32 time) { +bool CBGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3424,7 +3424,7 @@ ERRORCODE CBGame::setMusicStartTime(int channel, uint32 time) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::loadSettings(const char *filename) { +bool CBGame::loadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3451,7 +3451,7 @@ ERRORCODE CBGame::loadSettings(const char *filename) { return STATUS_FAILED; } - ERRORCODE ret = STATUS_OK; + bool ret = STATUS_OK; byte *buffer = origBuffer; byte *params; @@ -3547,7 +3547,7 @@ ERRORCODE CBGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { +bool CBGame::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); @@ -3640,7 +3640,7 @@ ERRORCODE CBGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::focusWindow(CUIWindow *Window) { +bool CBGame::focusWindow(CUIWindow *Window) { CUIWindow *Prev = _focusedWindow; for (int i = 0; i < _windows.getSize(); i++) { @@ -3662,7 +3662,7 @@ ERRORCODE CBGame::focusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::freeze(bool includingMusic) { +bool CBGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { _scEngine->pauseAll(); _soundMgr->pauseAll(includingMusic); @@ -3678,7 +3678,7 @@ ERRORCODE CBGame::freeze(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::unfreeze() { +bool CBGame::unfreeze() { if (_freezeLevel == 0) return STATUS_OK; _freezeLevel--; @@ -3771,7 +3771,7 @@ bool CBGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { if (verMajor) *verMajor = DCGF_VER_MAJOR; if (verMinor) *verMinor = DCGF_VER_MINOR; @@ -3811,7 +3811,7 @@ void CBGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getSaveSlotFilename(int slot, char *buffer) { +bool CBGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); sprintf(buffer, "save%03d.%s", slot, _savedGameExt); @@ -3828,7 +3828,7 @@ AnsiString CBGame::getDataDir() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) { +bool CBGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; char filename[MAX_PATH_LENGTH + 1]; @@ -3865,7 +3865,7 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::emptySaveSlot(int slot) { +bool CBGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -3876,7 +3876,7 @@ ERRORCODE CBGame::emptySaveSlot(int slot) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::setActiveObject(CBObject *obj) { +bool CBGame::setActiveObject(CBObject *obj) { // not-active when game is frozen if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { obj = NULL; @@ -3896,7 +3896,7 @@ ERRORCODE CBGame::setActiveObject(CBObject *obj) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::pushViewport(CBViewport *viewport) { +bool CBGame::pushViewport(CBViewport *viewport) { _viewportSP++; if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); else _viewportStack[_viewportSP] = viewport; @@ -3908,7 +3908,7 @@ ERRORCODE CBGame::pushViewport(CBViewport *viewport) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::popViewport() { +bool CBGame::popViewport() { _viewportSP--; if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); @@ -3923,7 +3923,7 @@ ERRORCODE CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { +bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { @@ -3943,7 +3943,7 @@ ERRORCODE CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { +bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; @@ -3957,13 +3957,13 @@ ERRORCODE CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { +bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { return STATUS_FAILED; } @@ -3986,13 +3986,13 @@ void CBGame::resetMousePos() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayContent(bool doUpdate, bool displayAll) { +bool CBGame::displayContent(bool doUpdate, bool displayAll) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayContentSimple() { +bool CBGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); if (_indicatorDisplay) displayIndicator(); @@ -4002,7 +4002,7 @@ ERRORCODE CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayIndicator() { +bool CBGame::displayIndicator() { if (_saveLoadImage) { Rect32 rc; CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); @@ -4020,7 +4020,7 @@ ERRORCODE CBGame::displayIndicator() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::updateMusicCrossfade() { +bool CBGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) return STATUS_OK; @@ -4075,7 +4075,7 @@ ERRORCODE CBGame::updateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::resetContent() { +bool CBGame::resetContent() { _scEngine->clearGlobals(); //_timer = 0; //_liveTimer = 0; @@ -4098,7 +4098,7 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::invalidateDeviceObjects() { +bool CBGame::invalidateDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->invalidateDeviceObjects(); } @@ -4107,7 +4107,7 @@ ERRORCODE CBGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::restoreDeviceObjects() { +bool CBGame::restoreDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->restoreDeviceObjects(); } @@ -4115,7 +4115,7 @@ ERRORCODE CBGame::restoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::setWaitCursor(const char *filename) { +bool CBGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -4135,7 +4135,7 @@ bool CBGame::isVideoPlaying() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::stopVideo() { +bool CBGame::stopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); @@ -4147,7 +4147,7 @@ ERRORCODE CBGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::drawCursor(CBSprite *cursor) { +bool CBGame::drawCursor(CBSprite *cursor) { if (!cursor) return STATUS_FAILED; if (cursor != _lastCursor) { cursor->reset(); @@ -4159,7 +4159,7 @@ ERRORCODE CBGame::drawCursor(CBSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { +bool CBGame::onActivate(bool activate, bool refreshMouse) { if (_shuttingDown || !_renderer) return STATUS_OK; _renderer->_active = activate; @@ -4177,7 +4177,7 @@ ERRORCODE CBGame::onActivate(bool activate, bool refreshMouse) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseLeftDown() { +bool CBGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); @@ -4195,7 +4195,7 @@ ERRORCODE CBGame::onMouseLeftDown() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseLeftUp() { +bool CBGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); CBPlatform::releaseCapture(); @@ -4212,7 +4212,7 @@ ERRORCODE CBGame::onMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseLeftDblClick() { +bool CBGame::onMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); @@ -4227,7 +4227,7 @@ ERRORCODE CBGame::onMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseRightDblClick() { +bool CBGame::onMouseRightDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); @@ -4242,7 +4242,7 @@ ERRORCODE CBGame::onMouseRightDblClick() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseRightDown() { +bool CBGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); @@ -4255,7 +4255,7 @@ ERRORCODE CBGame::onMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseRightUp() { +bool CBGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); @@ -4268,7 +4268,7 @@ ERRORCODE CBGame::onMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseMiddleDown() { +bool CBGame::onMouseMiddleDown() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); @@ -4283,7 +4283,7 @@ ERRORCODE CBGame::onMouseMiddleDown() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onMouseMiddleUp() { +bool CBGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); @@ -4296,7 +4296,7 @@ ERRORCODE CBGame::onMouseMiddleUp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onPaint() { +bool CBGame::onPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { _renderer->initLoop(); displayContent(false, true); @@ -4307,7 +4307,7 @@ ERRORCODE CBGame::onPaint() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onWindowClose() { +bool CBGame::onWindowClose() { if (canHandleEvent("QuitGame")) { if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); return STATUS_OK; @@ -4315,7 +4315,7 @@ ERRORCODE CBGame::onWindowClose() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::displayDebugInfo() { +bool CBGame::displayDebugInfo() { char str[100]; if (_debugShowFPS) { @@ -4401,7 +4401,7 @@ void CBGame::getMousePos(Point32 *pos) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::miniUpdate() { +bool CBGame::miniUpdate() { if (!_miniUpdateEnabled) return STATUS_OK; if (CBPlatform::getTime() - _lastMiniUpdate > 200) { @@ -4412,7 +4412,7 @@ ERRORCODE CBGame::miniUpdate() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBGame::onScriptShutdown(CScScript *script) { +bool CBGame::onScriptShutdown(CScScript *script) { return STATUS_OK; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index e78fd80118..bb8cdce402 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -39,7 +39,7 @@ namespace WinterMute { -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, ERRORCODE Result, void *Data); +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); class CBSoundMgr; class CBFader; @@ -67,19 +67,19 @@ class CBGame: public CBObject { public: DECLARE_PERSISTENT(CBGame, CBObject) - virtual ERRORCODE onScriptShutdown(CScScript *script); + virtual bool onScriptShutdown(CScScript *script); - virtual ERRORCODE onActivate(bool activate, bool refreshMouse); - virtual ERRORCODE onMouseLeftDown(); - virtual ERRORCODE onMouseLeftUp(); - virtual ERRORCODE onMouseLeftDblClick(); - virtual ERRORCODE onMouseRightDblClick(); - virtual ERRORCODE onMouseRightDown(); - virtual ERRORCODE onMouseRightUp(); - virtual ERRORCODE onMouseMiddleDown(); - virtual ERRORCODE onMouseMiddleUp(); - virtual ERRORCODE onPaint(); - virtual ERRORCODE onWindowClose(); + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); bool isLeftDoubleClick(); bool isRightDoubleClick(); @@ -89,14 +89,14 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - virtual ERRORCODE miniUpdate(); + virtual bool miniUpdate(); void getMousePos(Point32 *Pos); Rect32 _mouseLockRect; bool _shuttingDown; - virtual ERRORCODE displayDebugInfo(); + virtual bool displayDebugInfo(); bool _debugShowFPS; bool _suspendedRendering; @@ -110,10 +110,10 @@ public: int _loadingIconY; int _loadingIconPersistent; - virtual ERRORCODE resetContent(); + virtual bool resetContent(); void DEBUG_DumpClassRegistry(); - ERRORCODE setWaitCursor(const char *filename); + bool setWaitCursor(const char *filename); char *_localSaveDir; bool _saveDirChecked; @@ -137,7 +137,7 @@ protected: int _loadImageY; CBSurface *_saveLoadImage; - ERRORCODE displayIndicator(); + bool displayIndicator(); bool _reportTextureFormat; public: @@ -159,20 +159,20 @@ public: float _offsetPercentY; CBObject *_mainObject; - ERRORCODE initInput(); - ERRORCODE initLoop(); + bool initInput(); + bool initLoop(); uint32 _currentTime; uint32 _deltaTime; CBFont *_systemFont; CBFont *_videoFont; - ERRORCODE initialize1(); - ERRORCODE initialize2(); - ERRORCODE initialize3(); + bool initialize1(); + bool initialize2(); + bool initialize3(); CBFileManager *_fileManager; CBTransitionMgr *_transMgr; CBDebugger *getDebugMgr(); - void LOG(ERRORCODE res, const char *fmt, ...); + void LOG(bool res, const char *fmt, ...); CBRenderer *_renderer; CBSoundMgr *_soundMgr; @@ -190,8 +190,8 @@ public: void *_debugLogFile; int _sequence; - virtual ERRORCODE loadFile(const char *filename); - virtual ERRORCODE loadBuffer(byte *buffer, bool complete = true); + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); CBArray _quickMessages; CBArray _windows; CBArray _viewportStack; @@ -216,14 +216,14 @@ protected: bool _settingsAllowDesktopRes; int _settingsTLMode; CBFader *_fader; - virtual ERRORCODE invalidateDeviceObjects(); - virtual ERRORCODE restoreDeviceObjects(); + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); public: - virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; @@ -244,23 +244,23 @@ public: int _scheduledLoadSlot; bool _loading; bool _personalizedSave; - ERRORCODE emptySaveSlot(int slot); + bool emptySaveSlot(int slot); bool isSaveSlotUsed(int slot); - ERRORCODE getSaveSlotDescription(int slot, char *buffer); - ERRORCODE getSaveSlotFilename(int slot, char *buffer); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); void setWindowTitle(); virtual bool handleMouseWheel(int delta); bool _quitting; - virtual ERRORCODE getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); protected: int _freezeLevel; public: - ERRORCODE unfreeze(); - ERRORCODE freeze(bool includingMusic = true); - ERRORCODE focusWindow(CUIWindow *window); + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(CUIWindow *window); CVidPlayer *_videoPlayer; CVidTheoraPlayer *_theoraPlayer; bool _loadInProgress; @@ -275,12 +275,12 @@ protected: public: static void invalidateValues(void *value, void *data); - ERRORCODE loadSettings(const char *filename); - ERRORCODE resumeMusic(int channel); - ERRORCODE setMusicStartTime(int channel, uint32 time); - ERRORCODE pauseMusic(int channel); - ERRORCODE stopMusic(int channel); - ERRORCODE playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + bool loadSettings(const char *filename); + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); CBSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; @@ -288,14 +288,14 @@ public: uint32 _musicCrossfadeLength; int _musicCrossfadeChannel1; int _musicCrossfadeChannel2; - ERRORCODE displayWindows(bool inGame = false); + bool displayWindows(bool inGame = false); CBRegistry *_registry; bool _useD3D; - virtual ERRORCODE cleanup(); - virtual ERRORCODE loadGame(int slot); - virtual ERRORCODE loadGame(const char *filename); - virtual ERRORCODE SaveGame(int slot, const char *desc, bool quickSave = false); - virtual ERRORCODE showCursor(); + virtual bool cleanup(); + virtual bool loadGame(int slot); + virtual bool loadGame(const char *filename); + virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); CBSprite *_cursorNoninteractive; CBObject *_activeObject; @@ -315,36 +315,36 @@ public: CBObject *_capturedObject; Point32 _mousePos; bool validObject(CBObject *object); - ERRORCODE unregisterObject(CBObject *object); - ERRORCODE registerObject(CBObject *object); + bool unregisterObject(CBObject *object); + bool registerObject(CBObject *object); void quickMessage(const char *text); void quickMessageForm(char *fmt, ...); - ERRORCODE displayQuickMsg(); + bool displayQuickMsg(); uint32 _fps; - ERRORCODE updateMusicCrossfade(); + bool updateMusicCrossfade(); bool isVideoPlaying(); - ERRORCODE stopVideo(); + bool stopVideo(); CBArray _regObjects; public: - virtual ERRORCODE displayContent(bool update = true, bool displayAll = false); - virtual ERRORCODE displayContentSimple(); + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); bool _forceNonStreamedSounds; void resetMousePos(); int _subtitlesSpeed; void setInteractive(bool state); - virtual ERRORCODE windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual ERRORCODE windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - ERRORCODE getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - ERRORCODE getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); - ERRORCODE popViewport(); - ERRORCODE pushViewport(CBViewport *Viewport); - ERRORCODE setActiveObject(CBObject *Obj); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(CBViewport *Viewport); + bool setActiveObject(CBObject *Obj); CBSprite *_lastCursor; - ERRORCODE drawCursor(CBSprite *Cursor); + bool drawCursor(CBSprite *Cursor); - virtual ERRORCODE initAfterLoad(); + virtual bool initAfterLoad(); CBSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp index 57a2694aa8..41a1eff753 100644 --- a/engines/wintermute/Base/BImage.cpp +++ b/engines/wintermute/Base/BImage.cpp @@ -69,7 +69,7 @@ CBImage::~CBImage() { #endif } -ERRORCODE CBImage::loadFile(const Common::String &filename) { +bool CBImage::loadFile(const Common::String &filename) { _filename = filename; _filename.toLowercase(); if (StringUtil::startsWith(filename, "savegame:", true)) { @@ -111,7 +111,7 @@ void CBImage::copyFrom(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBImage::saveBMPFile(const char *filename) { +bool CBImage::saveBMPFile(const char *filename) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -123,7 +123,7 @@ ERRORCODE CBImage::saveBMPFile(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBImage::resize(int newWidth, int newHeight) { +bool CBImage::resize(int newWidth, int newHeight) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -247,7 +247,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { #if 0 if (_bitmap) FreeImage_Unload(_bitmap); diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h index c66f6f4ca3..29455d3f7a 100644 --- a/engines/wintermute/Base/BImage.h +++ b/engines/wintermute/Base/BImage.h @@ -47,7 +47,7 @@ public: CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); ~CBImage(); - ERRORCODE loadFile(const Common::String &filename); + bool loadFile(const Common::String &filename); const Graphics::Surface *getSurface() const { return _surface; }; @@ -56,9 +56,9 @@ public: } byte getAlphaAt(int x, int y); bool writeBMPToStream(Common::WriteStream *stream); - ERRORCODE resize(int newWidth, int newHeight); - ERRORCODE saveBMPFile(const char *filename); - ERRORCODE copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename); + bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); void copyFrom(Graphics::Surface *surface); private: Common::String _filename; diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp index ba8d807462..83deaa0306 100644 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ b/engines/wintermute/Base/BKeyboardState.cpp @@ -73,7 +73,7 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// @@ -173,7 +173,7 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBKeyboardState::scSetProperty(const char *name, CScValue *value) { +bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -195,7 +195,7 @@ const char *CBKeyboardState::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBKeyboardState::readKey(Common::Event *event) { +bool CBKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || @@ -215,7 +215,7 @@ ERRORCODE CBKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBKeyboardState::persist(CBPersistMgr *persistMgr) { +bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { //if(!persistMgr->_saving) cleanup(); CBScriptable::persist(persistMgr); diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h index 29844e5d09..84bbab5339 100644 --- a/engines/wintermute/Base/BKeyboardState.h +++ b/engines/wintermute/Base/BKeyboardState.h @@ -50,7 +50,7 @@ public: DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) CBKeyboardState(CBGame *inGame); virtual ~CBKeyboardState(); - ERRORCODE readKey(Common::Event *event); + bool readKey(Common::Event *event); void handleKeyPress(Common::Event *event); void handleKeyRelease(Common::Event *event); @@ -60,8 +60,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 35a2e257d6..6640602443 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -107,7 +107,7 @@ CBObject::~CBObject() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::cleanup() { +bool CBObject::cleanup() { if (_gameRef && _gameRef->_activeObject == this) _gameRef->_activeObject = NULL; @@ -161,7 +161,7 @@ const char *CBObject::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::listen(CBScriptHolder *param1, uint32 param2) { +bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -169,7 +169,7 @@ ERRORCODE CBObject::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -671,7 +671,7 @@ CScValue *CBObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::scSetProperty(const char *name, CScValue *value) { +bool CBObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// @@ -856,20 +856,20 @@ const char *CBObject::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::showCursor() { +bool CBObject::showCursor() { if (_cursor) return _gameRef->drawCursor(_cursor); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::persist(CBPersistMgr *persistMgr) { +bool CBObject::persist(CBPersistMgr *persistMgr) { CBScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) @@ -925,7 +925,7 @@ ERRORCODE CBObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::setCursor(const char *filename) { +bool CBObject::setCursor(const char *filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; @@ -942,7 +942,7 @@ ERRORCODE CBObject::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::setActiveCursor(const char *filename) { +bool CBObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = new CBSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { @@ -960,7 +960,7 @@ int CBObject::getHeight() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::handleMouse(TMouseEvent event, TMouseButton button) { +bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { return STATUS_OK; } @@ -978,7 +978,7 @@ bool CBObject::handleMouseWheel(int delta) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { +bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound if (filename == NULL && _sFX) { if (_gameRef->_editorMode || _sFXStart) { @@ -1020,7 +1020,7 @@ ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, co ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::stopSFX(bool deleteSound) { +bool CBObject::stopSFX(bool deleteSound) { if (_sFX) { _sFX->stop(); if (deleteSound) { @@ -1033,21 +1033,21 @@ ERRORCODE CBObject::stopSFX(bool deleteSound) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::pauseSFX() { +bool CBObject::pauseSFX() { if (_sFX) return _sFX->pause(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::resumeSFX() { +bool CBObject::resumeSFX() { if (_sFX) return _sFX->resume(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::setSFXTime(uint32 time) { +bool CBObject::setSFXTime(uint32 time) { _sFXStart = time; if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); else return STATUS_OK; @@ -1055,7 +1055,7 @@ ERRORCODE CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::setSFXVolume(int volume) { +bool CBObject::setSFXVolume(int volume) { _sFXVolume = volume; if (_sFX) return _sFX->setVolumePercent(volume); else return STATUS_OK; @@ -1063,7 +1063,7 @@ ERRORCODE CBObject::setSFXVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::updateSounds() { +bool CBObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); @@ -1077,8 +1077,8 @@ ERRORCODE CBObject::updateSounds() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::updateOneSound(CBSound *sound) { - ERRORCODE Ret = STATUS_OK; +bool CBObject::updateOneSound(CBSound *sound) { + bool Ret = STATUS_OK; if (sound) { if (_autoSoundPanning) @@ -1090,7 +1090,7 @@ ERRORCODE CBObject::updateOneSound(CBSound *sound) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::resetSoundPan() { +bool CBObject::resetSoundPan() { if (!_sFX) return STATUS_OK; else { return _sFX->setPan(0.0f); @@ -1121,7 +1121,7 @@ void CBObject::setSoundEvent(const char *eventName) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBObject::afterMove() { +bool CBObject::afterMove() { return STATUS_OK; } diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h index 15ccdbef44..6e3c632bac 100644 --- a/engines/wintermute/Base/BObject.h +++ b/engines/wintermute/Base/BObject.h @@ -46,7 +46,7 @@ class CScScript; class CBObject : public CBScriptHolder { public: TSpriteBlendMode _blendMode; - virtual ERRORCODE afterMove(); + virtual bool afterMove(); float _relativeRotate; bool _rotateValid; float _rotate; @@ -59,18 +59,18 @@ public: float _relativeScale; virtual bool isReady(); virtual bool getExtendedFlag(const char *flagName); - virtual ERRORCODE resetSoundPan(); - virtual ERRORCODE updateSounds(); - ERRORCODE updateOneSound(CBSound *sound); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(CBSound *sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; - ERRORCODE setSFXTime(uint32 time); - ERRORCODE setSFXVolume(int volume); - ERRORCODE resumeSFX(); - ERRORCODE pauseSFX(); - ERRORCODE stopSFX(bool deleteSound = true); - ERRORCODE playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); CBSound *_sFX; TSFXType _sFXType; @@ -80,12 +80,12 @@ public: float _sFXParam4; virtual bool handleMouseWheel(int delta); - virtual ERRORCODE handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual int getHeight(); - ERRORCODE setCursor(const char *filename); - ERRORCODE setActiveCursor(const char *filename); - ERRORCODE cleanup(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); const char *getCaption(int caseVal = 1); void setCaption(const char *caption, int caseVal = 1); bool _editorSelected; @@ -93,12 +93,12 @@ public: bool _editorOnly; bool _is3D; DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual ERRORCODE showCursor(); + virtual bool showCursor(); CBSprite *_cursor; bool _sharedCursors; CBSprite *_activeCursor; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; bool _zoomable; @@ -116,16 +116,16 @@ public: bool _saveState; // base - virtual ERRORCODE update() { + virtual bool update() { return STATUS_FAILED; }; - virtual ERRORCODE display() { + virtual bool display() { return STATUS_FAILED; }; - virtual ERRORCODE invalidateDeviceObjects() { + virtual bool invalidateDeviceObjects() { return STATUS_OK; }; - virtual ERRORCODE restoreDeviceObjects() { + virtual bool restoreDeviceObjects() { return STATUS_OK; }; bool _nonIntMouseEvents; @@ -134,8 +134,8 @@ public: public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp index 0727417025..9dcdd38cdc 100644 --- a/engines/wintermute/Base/BPackage.cpp +++ b/engines/wintermute/Base/BPackage.cpp @@ -57,7 +57,7 @@ CBPackage::~CBPackage() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPackage::open() { +bool CBPackage::open() { if (_file) return STATUS_OK; else { _file = getFilePointer(); @@ -67,7 +67,7 @@ ERRORCODE CBPackage::open() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPackage::close() { +bool CBPackage::close() { delete _file; _file = NULL; return STATUS_OK; @@ -75,8 +75,8 @@ ERRORCODE CBPackage::close() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - ERRORCODE ret; +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; if (DID_FAIL(ret = open())) return ret; else { if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h index cb56717b71..117b0c522d 100644 --- a/engines/wintermute/Base/BPackage.h +++ b/engines/wintermute/Base/BPackage.h @@ -45,9 +45,9 @@ public: bool _boundToExe; byte _priority; - ERRORCODE read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - ERRORCODE close(); - ERRORCODE open(); + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); char *_name; int _cD; Common::SeekableReadStream *_file; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index b58534ea90..700b63479a 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -170,7 +170,7 @@ bool CBPersistMgr::getSaveExists(int slot) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::initSave(const char *desc) { +bool CBPersistMgr::initSave(const char *desc) { if (!desc) return STATUS_FAILED; cleanup(); @@ -244,7 +244,7 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) { return STATUS_OK; } -ERRORCODE CBPersistMgr::readHeader(const Common::String &filename) { +bool CBPersistMgr::readHeader(const Common::String &filename) { cleanup(); _saving = false; @@ -299,7 +299,7 @@ ERRORCODE CBPersistMgr::readHeader(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::initLoad(const char *filename) { +bool CBPersistMgr::initLoad(const char *filename) { if (DID_FAIL(readHeader(filename))) { cleanup(); return STATUS_FAILED; @@ -348,13 +348,13 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::saveFile(const char *filename) { +bool CBPersistMgr::saveFile(const char *filename) { return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::putBytes(byte *buffer, uint32 size) { +bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); if (_saveStream->err()) return STATUS_FAILED; @@ -362,7 +362,7 @@ ERRORCODE CBPersistMgr::putBytes(byte *buffer, uint32 size) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::getBytes(byte *buffer, uint32 size) { +bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); if (_loadStream->err()) return STATUS_FAILED; @@ -420,7 +420,7 @@ char *CBPersistMgr::getString() { } else return ret; } -ERRORCODE CBPersistMgr::putTimeDate(const TimeDate &t) { +bool CBPersistMgr::putTimeDate(const TimeDate &t) { _saveStream->writeSint32LE(t.tm_sec); _saveStream->writeSint32LE(t.tm_min); _saveStream->writeSint32LE(t.tm_hour); @@ -484,7 +484,7 @@ double CBPersistMgr::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -ERRORCODE CBPersistMgr::transfer(const char *name, bool *val) { +bool CBPersistMgr::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -501,7 +501,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, bool *val) { ////////////////////////////////////////////////////////////////////////// // int -ERRORCODE CBPersistMgr::transfer(const char *name, int *val) { +bool CBPersistMgr::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); if (_saveStream->err()) @@ -518,7 +518,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, int *val) { ////////////////////////////////////////////////////////////////////////// // DWORD -ERRORCODE CBPersistMgr::transfer(const char *name, uint32 *val) { +bool CBPersistMgr::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); if (_saveStream->err()) @@ -535,7 +535,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, uint32 *val) { ////////////////////////////////////////////////////////////////////////// // float -ERRORCODE CBPersistMgr::transfer(const char *name, float *val) { +bool CBPersistMgr::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); if (_saveStream->err()) @@ -552,7 +552,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, float *val) { ////////////////////////////////////////////////////////////////////////// // double -ERRORCODE CBPersistMgr::transfer(const char *name, double *val) { +bool CBPersistMgr::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) @@ -569,7 +569,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, double *val) { ////////////////////////////////////////////////////////////////////////// // char* -ERRORCODE CBPersistMgr::transfer(const char *name, char **val) { +bool CBPersistMgr::transfer(const char *name, char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -586,7 +586,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, char **val) { ////////////////////////////////////////////////////////////////////////// // const char* -ERRORCODE CBPersistMgr::transfer(const char *name, const char **val) { +bool CBPersistMgr::transfer(const char *name, const char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -603,7 +603,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, const char **val) { ////////////////////////////////////////////////////////////////////////// // Common::String -ERRORCODE CBPersistMgr::transfer(const char *name, Common::String *val) { +bool CBPersistMgr::transfer(const char *name, Common::String *val) { if (_saving) { putString(*val); return STATUS_OK; @@ -624,7 +624,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Common::String *val) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { +bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { size_t size; if (_saving) { @@ -654,7 +654,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { ////////////////////////////////////////////////////////////////////////// // BYTE -ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { +bool CBPersistMgr::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -671,7 +671,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -ERRORCODE CBPersistMgr::transfer(const char *name, Rect32 *val) { +bool CBPersistMgr::transfer(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -694,7 +694,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Rect32 *val) { ////////////////////////////////////////////////////////////////////////// // POINT -ERRORCODE CBPersistMgr::transfer(const char *name, Point32 *val) { +bool CBPersistMgr::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); @@ -713,7 +713,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Point32 *val) { ////////////////////////////////////////////////////////////////////////// // Vector2 -ERRORCODE CBPersistMgr::transfer(const char *name, Vector2 *val) { +bool CBPersistMgr::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); @@ -732,7 +732,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, Vector2 *val) { ////////////////////////////////////////////////////////////////////////// // generic pointer -ERRORCODE CBPersistMgr::transfer(const char *name, void *val) { +bool CBPersistMgr::transfer(const char *name, void *val) { int classID = -1, instanceID = -1; if (_saving) { diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index d2aca60cf9..ee834c005e 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -53,7 +53,7 @@ public: byte _savedExtMajor; byte _savedExtMinor; Common::String _savedName; - ERRORCODE saveFile(const char *filename); + bool saveFile(const char *filename); uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); @@ -68,10 +68,10 @@ public: void deleteSaveSlot(int slot); uint32 getMaxUsedSlot(); bool getSaveExists(int slot); - ERRORCODE initLoad(const char *filename); - ERRORCODE initSave(const char *desc); - ERRORCODE getBytes(byte *buffer, uint32 size); - ERRORCODE putBytes(byte *buffer, uint32 size); + bool initLoad(const char *filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); uint32 _offset; bool _saving; @@ -79,20 +79,20 @@ public: uint32 _richBufferSize; byte *_richBuffer; - ERRORCODE transfer(const char *name, void *val); - ERRORCODE transfer(const char *name, int *val); - ERRORCODE transfer(const char *name, uint32 *val); - ERRORCODE transfer(const char *name, float *val); - ERRORCODE transfer(const char *name, double *val); - ERRORCODE transfer(const char *name, bool *val); - ERRORCODE transfer(const char *name, byte *val); - ERRORCODE transfer(const char *name, Rect32 *val); - ERRORCODE transfer(const char *name, Point32 *val); - ERRORCODE transfer(const char *name, const char **val); - ERRORCODE transfer(const char *name, char **val); - ERRORCODE transfer(const char *name, Common::String *val); - ERRORCODE transfer(const char *name, Vector2 *val); - ERRORCODE transfer(const char *name, AnsiStringArray &Val); + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); CBPersistMgr(CBGame *inGame = NULL); virtual ~CBPersistMgr(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); @@ -101,9 +101,9 @@ public: byte *_thumbnailData; private: Common::String getFilenameForSlot(int slot); - ERRORCODE readHeader(const Common::String &filename); + bool readHeader(const Common::String &filename); TimeDate getTimeDate(); - ERRORCODE putTimeDate(const TimeDate &t); + bool putTimeDate(const TimeDate &t); Common::WriteStream *_saveStream; Common::SeekableReadStream *_loadStream; }; diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp index b6b8c4e572..abb170d0b5 100644 --- a/engines/wintermute/Base/BPoint.cpp +++ b/engines/wintermute/Base/BPoint.cpp @@ -53,7 +53,7 @@ CBPoint::CBPoint(int initX, int initY) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBPoint::persist(CBPersistMgr *persistMgr) { +bool CBPoint::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(x)); persistMgr->transfer(TMEMBER(y)); diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp index 1db15abae0..3dc14df05f 100644 --- a/engines/wintermute/Base/BRegion.cpp +++ b/engines/wintermute/Base/BRegion.cpp @@ -95,14 +95,14 @@ bool CBRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::loadFile(const char *filename) { +bool CBRegion::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { +bool CBRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -210,7 +210,7 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -350,7 +350,7 @@ CScValue *CBRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::scSetProperty(const char *name, CScValue *value) { +bool CBRegion::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -378,7 +378,7 @@ const char *CBRegion::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { +bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); @@ -406,7 +406,7 @@ ERRORCODE CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *name ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::persist(CBPersistMgr *persistMgr) { +bool CBRegion::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -465,7 +465,7 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::getBoundingRect(Rect32 *rect) { +bool CBRegion::getBoundingRect(Rect32 *rect) { if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -484,7 +484,7 @@ ERRORCODE CBRegion::getBoundingRect(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRegion::mimic(CBRegion *region, float scale, int x, int y) { +bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; cleanup(); diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h index 6c79abc8f3..d2f06cbed9 100644 --- a/engines/wintermute/Base/BRegion.h +++ b/engines/wintermute/Base/BRegion.h @@ -40,8 +40,8 @@ public: int _lastMimicX; int _lastMimicY; void cleanup(); - ERRORCODE mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - ERRORCODE getBoundingRect(Rect32 *rect); + bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); bool ptInPolygon(int x, int y); DECLARE_PERSISTENT(CBRegion, CBObject) bool _active; @@ -50,16 +50,16 @@ public: virtual ~CBRegion(); bool pointInRegion(int x, int y); bool createRegion(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; CBArray _points; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp index 4174bab71b..68c04d9d46 100644 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ b/engines/wintermute/Base/BRenderSDL.cpp @@ -121,7 +121,7 @@ CBRenderSDL::~CBRenderSDL() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) { +bool CBRenderSDL::initRenderer(int width, int height, bool windowed) { //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; #if 0 @@ -250,7 +250,7 @@ void CBRenderSDL::setColorMod(byte r, byte g, byte b) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::flip() { +bool CBRenderSDL::flip() { if (!_disableDirtyRects) { drawTickets(); } @@ -270,7 +270,7 @@ ERRORCODE CBRenderSDL::flip() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); @@ -285,14 +285,14 @@ ERRORCODE CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::fade(uint16 Alpha) { +bool CBRenderSDL::fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; return fadeToColor(dwAlpha << 24); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { +bool CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -519,7 +519,7 @@ void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *s } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { warning("CBRenderSDL::DrawLine - not fully ported yet"); @@ -582,7 +582,7 @@ CBImage *CBRenderSDL::takeScreenshot() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::switchFullscreen() { +bool CBRenderSDL::switchFullscreen() { /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); else SDL_SetWindowFullscreen(_win, SDL_FALSE); @@ -608,7 +608,7 @@ const char *CBRenderSDL::getName() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderSDL::setViewport(int left, int top, int right, int bottom) { +bool CBRenderSDL::setViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. rect.left = (int16)(left + _borderLeft); diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 8d23a5bb12..0192849afa 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -63,16 +63,16 @@ public: const char *getName(); - ERRORCODE initRenderer(int width, int height, bool windowed); - ERRORCODE flip(); - ERRORCODE fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + bool initRenderer(int width, int height, bool windowed); + bool flip(); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - ERRORCODE fade(uint16 alpha); - ERRORCODE fadeToColor(uint32 color, Common::Rect *rect = NULL); + bool fade(uint16 alpha); + bool fadeToColor(uint32 color, Common::Rect *rect = NULL); - ERRORCODE switchFullscreen(); + bool switchFullscreen(); - ERRORCODE drawLine(int x1, int y1, int x2, int y2, uint32 color); + bool drawLine(int x1, int y1, int x2, int y2, uint32 color); CBImage *takeScreenshot(); @@ -82,7 +82,7 @@ public: void invalidateTicketsFromSurface(CBSurfaceSDL *surf); void drawFromTicket(RenderTicket *renderTicket); - ERRORCODE setViewport(int left, int top, int right, int bottom); + bool setViewport(int left, int top, int right, int bottom); void modTargetRect(Common::Rect *rect); void pointFromScreen(Point32 *point); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index d3d313faee..49eb8db69a 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -115,18 +115,18 @@ void CBRenderer::deleteRectList() { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::switchFullscreen() { +bool CBRenderer::switchFullscreen() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::flip() { +bool CBRenderer::flip() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::initRenderer(int width, int height, bool windowed) { +bool CBRenderer::initRenderer(int width, int height, bool windowed) { return STATUS_FAILED; } @@ -137,36 +137,36 @@ void CBRenderer::onWindowChange() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::windowedBlt() { +bool CBRenderer::windowedBlt() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setup2D(bool Force) { +bool CBRenderer::setup2D(bool Force) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setupLines() { +bool CBRenderer::setupLines() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { +bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { for (int i = 0; i < width; i++) { drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down @@ -179,31 +179,31 @@ ERRORCODE CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::fade(uint16 alpha) { +bool CBRenderer::fade(uint16 alpha) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { +bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setViewport(int left, int top, int right, int bottom) { +bool CBRenderer::setViewport(int left, int top, int right, int bottom) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setScreenViewport() { +bool CBRenderer::setScreenViewport() { return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::setViewport(Rect32 *rect) { +bool CBRenderer::setViewport(Rect32 *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -218,7 +218,7 @@ CBImage *CBRenderer::takeScreenshot() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::clipCursor() { +bool CBRenderer::clipCursor() { /* if (!_windowed) { Rect32 rc; @@ -237,7 +237,7 @@ ERRORCODE CBRenderer::clipCursor() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBRenderer::unclipCursor() { +bool CBRenderer::unclipCursor() { /* if (!_windowed) ::ClipCursor(NULL); */ diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index e7a9518c50..ddf2a3a808 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -49,36 +49,36 @@ public: virtual void dumpData(const char *filename) {}; virtual CBImage *takeScreenshot(); - virtual ERRORCODE setViewport(int left, int top, int right, int bottom); - virtual ERRORCODE setViewport(Rect32 *Rect); - virtual ERRORCODE setScreenViewport(); - virtual ERRORCODE fade(uint16 Alpha); - virtual ERRORCODE fadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual ERRORCODE drawLine(int x1, int y1, int x2, int y2, uint32 color); - virtual ERRORCODE drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + virtual bool setViewport(int left, int top, int right, int bottom); + virtual bool setViewport(Rect32 *Rect); + virtual bool setScreenViewport(); + virtual bool fade(uint16 Alpha); + virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); CBRenderer(CBGame *inGame = NULL); virtual ~CBRenderer(); - virtual ERRORCODE setProjection() { + virtual bool setProjection() { return STATUS_OK; }; - virtual ERRORCODE windowedBlt(); - virtual ERRORCODE fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual bool windowedBlt(); + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); virtual void onWindowChange(); - virtual ERRORCODE initRenderer(int width, int height, bool windowed); - virtual ERRORCODE flip(); + virtual bool initRenderer(int width, int height, bool windowed); + virtual bool flip(); virtual void initLoop(); - virtual ERRORCODE switchFullscreen(); - virtual ERRORCODE setup2D(bool force = false); - virtual ERRORCODE setupLines(); + virtual bool switchFullscreen(); + virtual bool setup2D(bool force = false); + virtual bool setupLines(); virtual const char *getName() { return ""; }; - virtual ERRORCODE displayDebugInfo() { + virtual bool displayDebugInfo() { return STATUS_FAILED; }; - virtual ERRORCODE drawShaderQuad() { + virtual bool drawShaderQuad() { return STATUS_FAILED; } @@ -91,16 +91,16 @@ public: virtual CBSurface *createSurface() = 0; - ERRORCODE clipCursor(); - ERRORCODE unclipCursor(); + bool clipCursor(); + bool unclipCursor(); CBObject *getObjectAt(int x, int y); void deleteRectList(); - virtual ERRORCODE startSpriteBatch() { + virtual bool startSpriteBatch() { return STATUS_OK; }; - virtual ERRORCODE endSpriteBatch() { + virtual bool endSpriteBatch() { return STATUS_OK; }; bool pointInViewport(Point32 *P); diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index 6c7b572475..a1653449ff 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -45,7 +45,7 @@ CBSaveThumbHelper::~CBSaveThumbHelper(void) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbHelper::storeThumbnail(bool doFlip) { +bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; diff --git a/engines/wintermute/Base/BSaveThumbHelper.h b/engines/wintermute/Base/BSaveThumbHelper.h index 27163af30f..c7c7e13982 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.h +++ b/engines/wintermute/Base/BSaveThumbHelper.h @@ -39,7 +39,7 @@ class CBSaveThumbHelper : public CBBase { public: CBSaveThumbHelper(CBGame *inGame); virtual ~CBSaveThumbHelper(void); - ERRORCODE storeThumbnail(bool doFlip = false); + bool storeThumbnail(bool doFlip = false); CBImage *_thumbnail; CBImage *_richThumbnail; diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp index 8e2a8f6adb..45cbc5d23b 100644 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ b/engines/wintermute/Base/BScriptHolder.cpp @@ -55,7 +55,7 @@ CBScriptHolder::~CBScriptHolder() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::cleanup() { +bool CBScriptHolder::cleanup() { delete[] _filename; _filename = NULL; @@ -80,10 +80,10 @@ void CBScriptHolder::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { +bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; - ERRORCODE ret = STATUS_FAILED; + bool ret = STATUS_FAILED; for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread) { CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); @@ -101,7 +101,7 @@ ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { +bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -109,7 +109,7 @@ ERRORCODE CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -128,7 +128,7 @@ ERRORCODE CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScSt else if (strcmp(name, "ApplyEvent") == 0) { stack->correctParams(1); CScValue *val = stack->pop(); - ERRORCODE ret; + bool ret; ret = applyEvent(val->getString()); if (DID_SUCCEED(ret)) stack->pushBool(true); @@ -240,7 +240,7 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::scSetProperty(const char *name, CScValue *value) { +bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -257,13 +257,13 @@ const char *CBScriptHolder::scToString() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { +bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { return CBBase::saveAsText(buffer, indent); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::persist(CBPersistMgr *persistMgr) { +bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); @@ -276,7 +276,7 @@ ERRORCODE CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::addScript(const char *filename) { +bool CBScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { @@ -311,7 +311,7 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::removeScript(CScScript *script) { +bool CBScriptHolder::removeScript(CScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { _scripts.removeAt(i); @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) { +bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -433,7 +433,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); if (thread) { - ERRORCODE ret = thread->createMethodThread(_scripts[i], methodName); + bool ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { _scripts[i]->_engine->_scripts.add(thread); _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h index dabaf52dd3..77f0f386cb 100644 --- a/engines/wintermute/Base/BScriptHolder.h +++ b/engines/wintermute/Base/BScriptHolder.h @@ -45,14 +45,14 @@ public: virtual void makeFreezable(bool freezable); bool canHandleEvent(const char *eventName); virtual bool canHandleMethod(const char *eventMethod); - ERRORCODE cleanup(); - ERRORCODE removeScript(CScScript *script); - ERRORCODE addScript(const char *filename); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); - virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); - ERRORCODE applyEvent(const char *eventName, bool unbreakable = false); + bool cleanup(); + bool removeScript(CScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); - ERRORCODE parseProperty(byte *buffer, bool complete = true); + bool parseProperty(byte *buffer, bool complete = true); char *_filename; bool _freezable; bool _ready; @@ -60,8 +60,8 @@ public: CBArray _scripts; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp index b61398c9b2..e9416cfaf3 100644 --- a/engines/wintermute/Base/BScriptable.cpp +++ b/engines/wintermute/Base/BScriptable.cpp @@ -61,7 +61,7 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { /* stack->correctParams(0); stack->pushNULL(); @@ -82,7 +82,7 @@ CScValue *CBScriptable::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptable::scSetProperty(const char *name, CScValue *value) { +bool CBScriptable::scSetProperty(const char *name, CScValue *value) { if (!_scProp) _scProp = new CScValue(_gameRef); if (_scProp) return _scProp->setProp(name, value); else return STATUS_FAILED; @@ -139,7 +139,7 @@ void CBScriptable::scSetBool(bool val) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBScriptable::persist(CBPersistMgr *persistMgr) { +bool CBScriptable::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h index a65e3d20b6..e806b83fac 100644 --- a/engines/wintermute/Base/BScriptable.h +++ b/engines/wintermute/Base/BScriptable.h @@ -50,9 +50,9 @@ public: // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); + virtual bool scSetProperty(const char *name, CScValue *value); virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); virtual int scToInt(); diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp index 9f9fa1a050..315a073301 100644 --- a/engines/wintermute/Base/BSound.cpp +++ b/engines/wintermute/Base/BSound.cpp @@ -66,7 +66,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; @@ -88,7 +88,7 @@ ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setSoundSimple() { +bool CBSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->setPosition(_soundPosition); @@ -111,7 +111,7 @@ uint32 CBSound::getLength() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::play(bool looping) { +bool CBSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); @@ -120,7 +120,7 @@ ERRORCODE CBSound::play(bool looping) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::stop() { +bool CBSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); @@ -129,7 +129,7 @@ ERRORCODE CBSound::stop() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::pause(bool freezePaused) { +bool CBSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; if (freezePaused) _sound->_freezePaused = true; @@ -139,7 +139,7 @@ ERRORCODE CBSound::pause(bool freezePaused) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::resume() { +bool CBSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); @@ -148,7 +148,7 @@ ERRORCODE CBSound::resume() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::persist(CBPersistMgr *persistMgr) { +bool CBSound::persist(CBPersistMgr *persistMgr) { if (persistMgr->_saving && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; @@ -194,10 +194,10 @@ bool CBSound::isPaused() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setPositionTime(uint32 time) { +bool CBSound::setPositionTime(uint32 time) { if (!_sound) return STATUS_FAILED; _soundPosition = time; - ERRORCODE ret = _sound->setPosition(_soundPosition); + bool ret = _sound->setPosition(_soundPosition); if (_sound->isPlaying()) _soundPosition = 0; return ret; @@ -214,21 +214,21 @@ uint32 CBSound::getPositionTime() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setVolumePercent(int percent) { +bool CBSound::setVolumePercent(int percent) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setVolume(int volume) { +bool CBSound::setVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setPrivateVolume(int volume) { +bool CBSound::setPrivateVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->_privateVolume = volume; @@ -249,7 +249,7 @@ int CBSound::getVolume() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setLoopStart(uint32 pos) { +bool CBSound::setLoopStart(uint32 pos) { if (!_sound) return STATUS_FAILED; else { @@ -259,7 +259,7 @@ ERRORCODE CBSound::setLoopStart(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::setPan(float pan) { +bool CBSound::setPan(float pan) { if (_sound) return _sound->setPan(pan); else return STATUS_FAILED; @@ -267,12 +267,12 @@ ERRORCODE CBSound::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { +bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) return STATUS_OK; if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - ERRORCODE ret = _sound->applyFX(type, param1, param2, param3, param4); + bool ret = _sound->applyFX(type, param1, param2, param3, param4); _sFXType = type; _sFXParam1 = param1; diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h index 3dc9dadf68..697c49600d 100644 --- a/engines/wintermute/Base/BSound.h +++ b/engines/wintermute/Base/BSound.h @@ -39,16 +39,16 @@ namespace WinterMute { class CBSoundBuffer; class CBSound : public CBBase { public: - ERRORCODE setPan(float pan); + bool setPan(float pan); int _soundPrivateVolume; int getVolume(); int getVolumePercent(); - ERRORCODE setVolumePercent(int percent); - ERRORCODE setVolume(int volume); - ERRORCODE setPrivateVolume(int volume); - ERRORCODE setLoopStart(uint32 pos); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); uint32 getPositionTime(); - ERRORCODE setPositionTime(uint32 time); + bool setPositionTime(uint32 time); bool _soundPaused; bool _soundFreezePaused; bool isPlaying(); @@ -58,20 +58,20 @@ public: uint32 _soundLoopStart; uint32 _soundPosition; DECLARE_PERSISTENT(CBSound, CBBase) - ERRORCODE resume(); - ERRORCODE pause(bool freezePaused = false); - ERRORCODE stop(); - ERRORCODE play(bool looping = false); + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); uint32 getLength(); bool _soundStreamed; Audio::Mixer::SoundType _soundType; char *_soundFilename; - ERRORCODE setSoundSimple(); - ERRORCODE setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool setSoundSimple(); + bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); CBSound(CBGame *inGame); virtual ~CBSound(); - ERRORCODE ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); private: TSFXType _sFXType; diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 77ff119e7b..0fc9a9158c 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -94,7 +94,7 @@ void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSi ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { +bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); #if 0 if (_stream) { @@ -151,7 +151,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { CBUtils::setString(&_filename, filename); /* - ERRORCODE res; + bool res; bool NewlyCreated = false; if(!_soundBuffer || ForceReload || _streamed){ @@ -196,7 +196,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::play(bool looping, uint32 startSample) { +bool CBSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } @@ -233,7 +233,7 @@ void CBSoundBuffer::setLooping(bool looping) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::resume() { +bool CBSoundBuffer::resume() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); } @@ -242,7 +242,7 @@ ERRORCODE CBSoundBuffer::resume() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::stop() { +bool CBSoundBuffer::stop() { if (_stream && _handle) { g_system->getMixer()->stopHandle(*_handle); } @@ -251,7 +251,7 @@ ERRORCODE CBSoundBuffer::stop() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::pause() { +bool CBSoundBuffer::pause() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, true); } @@ -280,7 +280,7 @@ void CBSoundBuffer::updateVolume() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::setVolume(int volume) { +bool CBSoundBuffer::setVolume(int volume) { _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; if (_stream && _handle) { byte vol = (byte)(_volume); @@ -291,7 +291,7 @@ ERRORCODE CBSoundBuffer::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::setPrivateVolume(int volume) { +bool CBSoundBuffer::setPrivateVolume(int volume) { _privateVolume = volume; return setVolume(_privateVolume); } @@ -318,7 +318,7 @@ uint32 CBSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::setPosition(uint32 pos) { +bool CBSoundBuffer::setPosition(uint32 pos) { warning("CBSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { @@ -330,7 +330,7 @@ ERRORCODE CBSoundBuffer::setPosition(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::setLoopStart(uint32 pos) { +bool CBSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; #if 0 if (_stream) { @@ -357,7 +357,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::setPan(float pan) { +bool CBSoundBuffer::setPan(float pan) { if (_handle) { g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } @@ -365,7 +365,7 @@ ERRORCODE CBSoundBuffer::setPan(float pan) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { +bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { warning("CBSoundBuffer::ApplyFX - not implemented yet"); switch (type) { case SFX_ECHO: diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h index f65ea1d40f..632c53008a 100644 --- a/engines/wintermute/Base/BSoundBuffer.h +++ b/engines/wintermute/Base/BSoundBuffer.h @@ -49,33 +49,33 @@ public: virtual ~CBSoundBuffer(); - ERRORCODE pause(); - ERRORCODE play(bool looping = false, uint32 startSample = 0); - ERRORCODE resume(); - ERRORCODE stop(); + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); bool isPlaying(); void setLooping(bool looping); uint32 getPosition(); - ERRORCODE setPosition(uint32 pos); + bool setPosition(uint32 pos); uint32 getLength(); - ERRORCODE setLoopStart(uint32 pos); + bool setLoopStart(uint32 pos); uint32 getLoopStart() const { return _loopStart; } - ERRORCODE setPan(float pan); - ERRORCODE setPrivateVolume(int colume); - ERRORCODE setVolume(int colume); + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); void updateVolume(); void setType(Audio::Mixer::SoundType Type); - ERRORCODE loadFromFile(const char *filename, bool forceReload = false); + bool loadFromFile(const char *filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - ERRORCODE applyFX(TSFXType type, float param1, float param2, float param3, float param4); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); //HSTREAM _stream; //HSYNC _sync; diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 02fd146701..98a5e69d7b 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -61,7 +61,7 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::cleanup() { +bool CBSoundMgr::cleanup() { for (int i = 0; i < _sounds.getSize(); i++) delete _sounds[i]; _sounds.removeAll(); @@ -79,7 +79,7 @@ void CBSoundMgr::saveSettings() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::initialize() { +bool CBSoundMgr::initialize() { _soundAvailable = false; if (!g_system->getMixer()->isReady()) { @@ -93,7 +93,7 @@ ERRORCODE CBSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::initLoop() { +bool CBSoundMgr::initLoop() { if (!_soundAvailable) return STATUS_OK; #if 0 @@ -130,7 +130,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp sound->setType(type); - ERRORCODE res = sound->loadFromFile(filename); + bool res = sound->loadFromFile(filename); if (DID_FAIL(res)) { _gameRef->LOG(res, "Error loading sound '%s'", filename); delete sound; @@ -149,7 +149,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { +bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { if (!sound) return STATUS_FAILED; @@ -163,7 +163,7 @@ ERRORCODE CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType typ } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::removeSound(CBSoundBuffer *sound) { +bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; @@ -177,7 +177,7 @@ ERRORCODE CBSoundMgr::removeSound(CBSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { +bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { if (!_soundAvailable) return STATUS_OK; @@ -200,7 +200,7 @@ ERRORCODE CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { +bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { return setVolume(type, percent * 255 / 100); } @@ -225,7 +225,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setMasterVolume(byte value) { +bool CBSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; for (int i = 0; i < _sounds.getSize(); i++) { _sounds[i]->updateVolume(); @@ -234,7 +234,7 @@ ERRORCODE CBSoundMgr::setMasterVolume(byte value) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::setMasterVolumePercent(byte percent) { +bool CBSoundMgr::setMasterVolumePercent(byte percent) { setMasterVolume(percent * 255 / 100); return STATUS_OK; } @@ -252,7 +252,7 @@ byte CBSoundMgr::getMasterVolume() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { +bool CBSoundMgr::pauseAll(bool includingMusic) { for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { @@ -266,7 +266,7 @@ ERRORCODE CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSoundMgr::resumeAll() { +bool CBSoundMgr::resumeAll() { for (int i = 0; i < _sounds.getSize(); i++) { if (_sounds[i]->_freezePaused) { diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index 1ae7b7709a..13e3957fce 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -38,24 +38,24 @@ class CBSoundBuffer; class CBSoundMgr : public CBBase { public: float posToPan(int x, int y); - ERRORCODE resumeAll(); - ERRORCODE pauseAll(bool includingMusic = true); - ERRORCODE cleanup(); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); //DECLARE_PERSISTENT(CBSoundMgr, CBBase); byte getMasterVolumePercent(); byte getMasterVolume(); - ERRORCODE setMasterVolume(byte percent); - ERRORCODE setMasterVolumePercent(byte percent); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); byte getVolumePercent(Audio::Mixer::SoundType type); - ERRORCODE setVolumePercent(Audio::Mixer::SoundType type, byte percent); - ERRORCODE setVolume(Audio::Mixer::SoundType type, int volume); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; - ERRORCODE removeSound(CBSoundBuffer *sound); + bool removeSound(CBSoundBuffer *sound); CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - ERRORCODE addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - ERRORCODE initLoop(); - ERRORCODE initialize(); + bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initLoop(); + bool initialize(); bool _soundAvailable; CBSoundMgr(CBGame *inGame); virtual ~CBSoundMgr(); diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 2e6787d27b..1abea36c6b 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -102,7 +102,7 @@ void CBSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { +bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; @@ -122,7 +122,7 @@ ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, flo ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); @@ -133,7 +133,7 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp file = NULL; } - ERRORCODE ret; + bool ret; AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -383,7 +383,7 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; // on change... @@ -428,7 +428,7 @@ bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float s } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { +bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); @@ -472,7 +472,7 @@ ERRORCODE CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::persist(CBPersistMgr *persistMgr) { +bool CBSprite::persist(CBPersistMgr *persistMgr) { CBScriptHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_canBreak)); @@ -507,7 +507,7 @@ ERRORCODE CBSprite::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -707,7 +707,7 @@ CScValue *CBSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::scSetProperty(const char *name, CScValue *value) { +bool CBSprite::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// @@ -747,7 +747,7 @@ const char *CBSprite::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSprite::killAllSounds() { +bool CBSprite::killAllSounds() { for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i]->_sound) _frames[i]->_sound->stop(); diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h index bf40bbc6c6..30698b62c1 100644 --- a/engines/wintermute/Base/BSprite.h +++ b/engines/wintermute/Base/BSprite.h @@ -39,7 +39,7 @@ class CBSurface; class CBObject; class CBSprite: public CBScriptHolder { public: - ERRORCODE killAllSounds(); + bool killAllSounds(); CBSurface *getSurface(); char *_editorBgFile; int _editorBgOffsetX; @@ -56,7 +56,7 @@ public: bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; - ERRORCODE display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; @@ -66,22 +66,22 @@ public: bool _changed; bool _paused; bool _finished; - ERRORCODE loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - ERRORCODE loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; - ERRORCODE draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; - ERRORCODE addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); CBSprite(CBGame *inGame, CBObject *owner = NULL); virtual ~CBSprite(); CBArray _frames; - ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index e2cbec3691..f9d4094004 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -50,7 +50,7 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { +bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { if (key == NULL || val == NULL) return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { @@ -169,7 +169,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) { +bool CBStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); if (clearOld) _strings.clear(); diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index 94547ffbfc..4bdbcdc203 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -38,9 +38,9 @@ namespace WinterMute { class CBStringTable : public CBBase { public: const char *expandStatic(const char *string, bool forceExpand = false); - ERRORCODE loadFile(const char *filename, bool deleteAll = true); + bool loadFile(const char *filename, bool deleteAll = true); void expand(char **str, bool forceExpand = false); - ERRORCODE addString(const char *key, const char *val, bool reportDuplicities = true); + bool addString(const char *key, const char *val, bool reportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); Common::HashMap _strings; diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index 62bf0d9f87..fe6695c7c2 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -204,7 +204,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { +bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (!_surface) return STATUS_OK; if (registerOwner != NULL && !_decoration) { @@ -216,7 +216,7 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f } if (_gameRef->_suspendedRendering) return STATUS_OK; - ERRORCODE res; + bool res; //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) if (_alpha != 0xFFFFFFFF) alpha = _alpha; @@ -249,7 +249,7 @@ bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { +bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); @@ -310,7 +310,7 @@ void CBSubFrame::setDefaultRect() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::persist(CBPersistMgr *persistMgr) { +bool CBSubFrame::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); @@ -342,7 +342,7 @@ ERRORCODE CBSubFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -473,7 +473,7 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::scSetProperty(const char *name, CScValue *value) { +bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// @@ -549,7 +549,7 @@ const char *CBSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -576,7 +576,7 @@ ERRORCODE CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRe ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSubFrame::setSurfaceSimple() { +bool CBSubFrame::setSurfaceSimple() { if (!_surfaceFilename) { _surface = NULL; return STATUS_OK; diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h index 46ee948e64..5ff000ea2f 100644 --- a/engines/wintermute/Base/BSubFrame.h +++ b/engines/wintermute/Base/BSubFrame.h @@ -41,18 +41,18 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - ERRORCODE setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - ERRORCODE setSurfaceSimple(); + bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); DECLARE_PERSISTENT(CBSubFrame, CBScriptable) void setDefaultRect(); uint32 _transparent; - ERRORCODE saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - ERRORCODE saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); bool _editorSelected; CBSubFrame(CBGame *inGame); virtual ~CBSubFrame(); - ERRORCODE loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - ERRORCODE draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; @@ -75,8 +75,8 @@ public: // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp index 8a6d2b2f1d..3ba2a773a9 100644 --- a/engines/wintermute/Base/BSurface.cpp +++ b/engines/wintermute/Base/BSurface.cpp @@ -59,13 +59,13 @@ CBSurface::~CBSurface() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::restore() { +bool CBSurface::restore() { return STATUS_FAILED; } @@ -75,40 +75,40 @@ bool CBSurface::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { +bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::create(int Width, int Height) { +bool CBSurface::create(int Width, int Height) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::startPixelOp() { +bool CBSurface::startPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::endPixelOp() { +bool CBSurface::endPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { +bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { +bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { return STATUS_FAILED; } @@ -126,14 +126,14 @@ bool CBSurface::isTransparentAtLite(int x, int y) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::invalidate() { +bool CBSurface::invalidate() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurface::prepareToDraw() { +bool CBSurface::prepareToDraw() { _lastUsedTime = _gameRef->_liveTimer; if (!_valid) { diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index fe00348488..c31ad5643f 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -37,8 +37,8 @@ namespace WinterMute { class CBSurface: public CBBase { public: - virtual ERRORCODE invalidate(); - virtual ERRORCODE prepareToDraw(); + virtual bool invalidate(); + virtual bool prepareToDraw(); bool _ckDefault; byte _ckRed; byte _ckGreen; @@ -53,25 +53,25 @@ public: CBSurface(CBGame *inGame); virtual ~CBSurface(); - virtual ERRORCODE displayHalfTrans(int x, int y, Rect32 rect); + virtual bool displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); - virtual ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual ERRORCODE displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual ERRORCODE restore(); - virtual ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual ERRORCODE create(int Width, int Height); - virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool restore(); + virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(int Width, int Height); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return STATUS_FAILED; } - virtual ERRORCODE putPixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual ERRORCODE getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual ERRORCODE startPixelOp(); - virtual ERRORCODE endPixelOp(); + virtual bool startPixelOp(); + virtual bool endPixelOp(); virtual bool isTransparentAtLite(int x, int y); void setSize(int width, int height); diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp index 58a09dbe56..c8b22511fa 100644 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ b/engines/wintermute/Base/BSurfaceSDL.cpp @@ -91,7 +91,7 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* CBRenderSDL *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); @@ -273,7 +273,7 @@ uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::create(int width, int height) { +bool CBSurfaceSDL::create(int width, int height) { warning("SurfaceSDL::Create not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(_gameRef->_renderer); @@ -290,7 +290,7 @@ ERRORCODE CBSurfaceSDL::create(int width, int height) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { +bool CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO #if 0 CBRenderSDL *renderer = static_cast(_gameRef->_renderer); @@ -387,7 +387,7 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::startPixelOp() { +bool CBSurfaceSDL::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: CBRenderSDL *renderer = static_cast(_gameRef->_renderer); @@ -396,47 +396,47 @@ ERRORCODE CBSurfaceSDL::startPixelOp() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::endPixelOp() { +bool CBSurfaceSDL::endPixelOp() { //SDL_UnlockTexture(_texture); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurfaceSDL::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurfaceSDL::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +bool CBSurfaceSDL::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurfaceSDL::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurfaceSDL::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +bool CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { CBRenderSDL *renderer = static_cast(_gameRef->_renderer); if (!_loaded) { @@ -519,7 +519,7 @@ ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, floa return STATUS_OK; } -ERRORCODE CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { +bool CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->copyFrom(surface); _hasAlpha = hasAlpha; diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h index 289f75eaf3..fa70c97fdf 100644 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ b/engines/wintermute/Base/BSurfaceSDL.h @@ -41,25 +41,25 @@ public: CBSurfaceSDL(CBGame *inGame); ~CBSurfaceSDL(); - ERRORCODE create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); - ERRORCODE create(int width, int height); + bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(int width, int height); - ERRORCODE createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function bool isTransparentAt(int x, int y); bool isTransparentAtLite(int x, int y); - ERRORCODE startPixelOp(); - ERRORCODE endPixelOp(); + bool startPixelOp(); + bool endPixelOp(); - ERRORCODE displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - ERRORCODE display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - ERRORCODE displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual ERRORCODE putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); static long DLL_CALLCONV TellProc(fi_handle handle);*/ @@ -86,7 +86,7 @@ private: Graphics::Surface *_surface; bool _loaded; void finishLoad(); - ERRORCODE drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 0ffeb7a81c..34721c40f6 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -51,7 +51,7 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::cleanup(bool warn) { +bool CBSurfaceStorage::cleanup(bool warn) { for (int i = 0; i < _surfaces.getSize(); i++) { if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; @@ -63,7 +63,7 @@ ERRORCODE CBSurfaceStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::initLoop() { +bool CBSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); @@ -81,7 +81,7 @@ ERRORCODE CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::removeSurface(CBSurface *surface) { +bool CBSurfaceStorage::removeSurface(CBSurface *surface) { for (int i = 0; i < _surfaces.getSize(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; @@ -130,8 +130,8 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::restoreAll() { - ERRORCODE ret; +bool CBSurfaceStorage::restoreAll() { + bool ret; for (int i = 0; i < _surfaces.getSize(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { @@ -145,7 +145,7 @@ ERRORCODE CBSurfaceStorage::restoreAll() { /* ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) { if(!persistMgr->_saving) cleanup(false); @@ -160,7 +160,7 @@ ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSurfaceStorage::sortSurfaces() { +bool CBSurfaceStorage::sortSurfaces() { qsort(_surfaces.getData(), _surfaces.getSize(), sizeof(CBSurface *), surfaceSortCB); return STATUS_OK; } diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index d93c82bf19..1e8074dc99 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -38,15 +38,15 @@ class CBSurface; class CBSurfaceStorage : public CBBase { public: uint32 _lastCleanupTime; - ERRORCODE initLoop(); - ERRORCODE sortSurfaces(); + bool initLoop(); + bool sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); - ERRORCODE cleanup(bool Warn = false); + bool cleanup(bool Warn = false); //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - ERRORCODE restoreAll(); + bool restoreAll(); CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - ERRORCODE removeSurface(CBSurface *surface); + bool removeSurface(CBSurface *surface); CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp index 537fb0f2f5..81d80c40aa 100644 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ b/engines/wintermute/Base/BTransitionMgr.cpp @@ -58,7 +58,7 @@ bool CBTransitionMgr::isReady() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { +bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { if (_state != TRANS_MGR_READY) return STATUS_OK; if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { @@ -83,7 +83,7 @@ ERRORCODE CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { #define FADE_DURATION 200 ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBTransitionMgr::update() { +bool CBTransitionMgr::update() { if (isReady()) return STATUS_OK; if (!_started) { diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h index 5999ac3391..8219afeb46 100644 --- a/engines/wintermute/Base/BTransitionMgr.h +++ b/engines/wintermute/Base/BTransitionMgr.h @@ -39,8 +39,8 @@ public: uint32 _lastTime; bool _origInteractive; bool _preserveInteractive; - ERRORCODE update(); - ERRORCODE start(TTransitionType type, bool nonInteractive = false); + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); bool isReady(); TTransMgrState _state; CBTransitionMgr(CBGame *inGame); diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp index a245baf26d..8f0680dfb6 100644 --- a/engines/wintermute/Base/BViewport.cpp +++ b/engines/wintermute/Base/BViewport.cpp @@ -49,7 +49,7 @@ CBViewport::~CBViewport() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBViewport::persist(CBPersistMgr *persistMgr) { +bool CBViewport::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -63,7 +63,7 @@ ERRORCODE CBViewport::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { +bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h index 83e89a6014..667d181dcd 100644 --- a/engines/wintermute/Base/BViewport.h +++ b/engines/wintermute/Base/BViewport.h @@ -39,7 +39,7 @@ public: int getHeight(); int getWidth(); Rect32 *getRect(); - ERRORCODE setRect(int left, int top, int right, int bottom, bool noCheck = false); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); DECLARE_PERSISTENT(CBViewport, CBBase) int _offsetY; int _offsetX; diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h index 1ff3c109f8..cbdd0b1ff1 100644 --- a/engines/wintermute/Base/file/BFile.h +++ b/engines/wintermute/Base/file/BFile.h @@ -51,10 +51,10 @@ public: virtual uint32 getPos() { return _pos; }; - virtual ERRORCODE seek(uint32 pos, int whence = SEEK_SET) = 0; - virtual ERRORCODE read(void *buffer, uint32 size) = 0; - virtual ERRORCODE close() = 0; - virtual ERRORCODE open(const Common::String &filename) = 0; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; virtual bool isEOF(); CBFile(CBGame *inGame); virtual ~CBFile(); diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp index 1784c1f53d..b61c2a586f 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp @@ -51,7 +51,7 @@ CBSaveThumbFile::~CBSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { +bool CBSaveThumbFile::open(const Common::String &filename) { close(); if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; @@ -82,7 +82,7 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { } _gameRef->_debugAbsolutePathWarning = true; - ERRORCODE res; + bool res; if (pm->_thumbnailDataSize != 0) { _data = new byte[pm->_thumbnailDataSize]; @@ -97,7 +97,7 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbFile::close() { +bool CBSaveThumbFile::close() { delete[] _data; _data = NULL; @@ -109,7 +109,7 @@ ERRORCODE CBSaveThumbFile::close() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbFile::read(void *buffer, uint32 size) { +bool CBSaveThumbFile::read(void *buffer, uint32 size) { if (!_data || _pos + size > _size) return STATUS_FAILED; memcpy(buffer, (byte *)_data + _pos, size); @@ -120,7 +120,7 @@ ERRORCODE CBSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBSaveThumbFile::seek(uint32 pos, int whence) { +bool CBSaveThumbFile::seek(uint32 pos, int whence) { if (!_data) return STATUS_FAILED; uint32 newPos = 0; diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h index 7ec07824f9..777a4df903 100644 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ b/engines/wintermute/Base/file/BSaveThumbFile.h @@ -39,10 +39,10 @@ class CBSaveThumbFile : public CBFile { public: CBSaveThumbFile(CBGame *Game); virtual ~CBSaveThumbFile(); - virtual ERRORCODE seek(uint32 pos, int whence = SEEK_SET); - virtual ERRORCODE read(void *buffer, uint32 size); - virtual ERRORCODE close(); - virtual ERRORCODE open(const Common::String &filename); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); private: byte *_data; }; diff --git a/engines/wintermute/Base/font/BFont.cpp b/engines/wintermute/Base/font/BFont.cpp index b910bdbd90..f797d49c5b 100644 --- a/engines/wintermute/Base/font/BFont.cpp +++ b/engines/wintermute/Base/font/BFont.cpp @@ -71,7 +71,7 @@ int CBFont::getTextWidth(byte *text, int maxLength) { /* ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::loadFile(const char * Filename) +bool CBFont::loadFile(const char * Filename) { BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); if(Buffer==NULL){ @@ -79,7 +79,7 @@ ERRORCODE CBFont::loadFile(const char * Filename) return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename)+1]; strcpy(_filename, filename); @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::loadBuffer(byte * Buffer) +bool CBFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -144,7 +144,7 @@ int CBFont::getLetterHeight() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) { +bool CBFont::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/Base/font/BFont.h b/engines/wintermute/Base/font/BFont.h index ac5a79299d..5fa9bf3c1c 100644 --- a/engines/wintermute/Base/font/BFont.h +++ b/engines/wintermute/Base/font/BFont.h @@ -51,8 +51,8 @@ public: static CBFont *createFromFile(CBGame *game, const char *filename); private: - //ERRORCODE loadBuffer(byte * Buffer); - //ERRORCODE loadFile(const char* Filename); + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); static bool isTrueType(CBGame *game, const char *filename); }; diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp index 96a6387070..badf5ac646 100644 --- a/engines/wintermute/Base/font/BFontBitmap.cpp +++ b/engines/wintermute/Base/font/BFontBitmap.cpp @@ -243,14 +243,14 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::loadFile(const char *filename) { +bool CBFontBitmap::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -282,7 +282,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { +bool CBFontBitmap::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -454,7 +454,7 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::persist(CBPersistMgr *persistMgr) { +bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_numColumns)); @@ -487,7 +487,7 @@ int CBFontBitmap::getCharWidth(byte index) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontBitmap::getWidths() { +bool CBFontBitmap::getWidths() { CBSurface *surf = NULL; if (_sprite) { diff --git a/engines/wintermute/Base/font/BFontBitmap.h b/engines/wintermute/Base/font/BFontBitmap.h index b834f919b9..94569e4dc7 100644 --- a/engines/wintermute/Base/font/BFontBitmap.h +++ b/engines/wintermute/Base/font/BFontBitmap.h @@ -37,8 +37,8 @@ class CBSubFrame; class CBFontBitmap : public CBFont { public: DECLARE_PERSISTENT(CBFontBitmap, CBFont) - ERRORCODE loadBuffer(byte *Buffer); - ERRORCODE loadFile(const char *filename); + bool loadBuffer(byte *Buffer); + bool loadFile(const char *filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); @@ -48,7 +48,7 @@ public: virtual ~CBFontBitmap(); - ERRORCODE getWidths(); + bool getWidths(); CBSprite *_sprite; int _widthsFrame; bool _fontextFix; diff --git a/engines/wintermute/Base/font/BFontStorage.cpp b/engines/wintermute/Base/font/BFontStorage.cpp index c9c6df9f6e..0e2e0af84d 100644 --- a/engines/wintermute/Base/font/BFontStorage.cpp +++ b/engines/wintermute/Base/font/BFontStorage.cpp @@ -51,7 +51,7 @@ CBFontStorage::~CBFontStorage() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::cleanup(bool warn) { +bool CBFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; @@ -62,7 +62,7 @@ ERRORCODE CBFontStorage::cleanup(bool warn) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::initLoop() { +bool CBFontStorage::initLoop() { for (int i = 0; i < _fonts.getSize(); i++) { _fonts[i]->initLoop(); } @@ -104,7 +104,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::removeFont(CBFont *font) { +bool CBFontStorage::removeFont(CBFont *font) { if (!font) return STATUS_FAILED; for (int i = 0; i < _fonts.getSize(); i++) { @@ -122,7 +122,7 @@ ERRORCODE CBFontStorage::removeFont(CBFont *font) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) { +bool CBFontStorage::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(false); diff --git a/engines/wintermute/Base/font/BFontStorage.h b/engines/wintermute/Base/font/BFontStorage.h index 33a1bb056f..4f360c84c5 100644 --- a/engines/wintermute/Base/font/BFontStorage.h +++ b/engines/wintermute/Base/font/BFontStorage.h @@ -41,13 +41,13 @@ class CBFont; class CBFontStorage : public CBBase { public: DECLARE_PERSISTENT(CBFontStorage, CBBase) - ERRORCODE cleanup(bool warn = false); - ERRORCODE removeFont(CBFont *font); + bool cleanup(bool warn = false); + bool removeFont(CBFont *font); CBFont *addFont(const char *filename); CBFontStorage(CBGame *inGame); virtual ~CBFontStorage(); CBArray _fonts; - ERRORCODE initLoop(); + bool initLoop(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index e77d95985b..e4bd7cc719 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -405,14 +405,14 @@ int CBFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::loadFile(const char *filename) { +bool CBFontTT::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -442,7 +442,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::loadBuffer(byte *buffer) { +bool CBFontTT::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -550,7 +550,7 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { +bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -593,7 +593,7 @@ ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::persist(CBPersistMgr *persistMgr) { +bool CBFontTT::persist(CBPersistMgr *persistMgr) { CBFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_isBold)); @@ -635,7 +635,7 @@ void CBFontTT::afterLoad() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CBFontTT::initFont() { +bool CBFontTT::initFont() { if (!_fontFile) return STATUS_FAILED; Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); diff --git a/engines/wintermute/Base/font/BFontTT.h b/engines/wintermute/Base/font/BFontTT.h index 1ee9f1d105..058fc28755 100644 --- a/engines/wintermute/Base/font/BFontTT.h +++ b/engines/wintermute/Base/font/BFontTT.h @@ -80,7 +80,7 @@ public: _color = 0x00000000; } - ERRORCODE persist(CBPersistMgr *persistMgr) { + bool persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_offsetX)); persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_color)); @@ -123,8 +123,8 @@ public: virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - ERRORCODE loadBuffer(byte *buffer); - ERRORCODE loadFile(const char *filename); + bool loadBuffer(byte *buffer); + bool loadFile(const char *filename); float getLineHeight() const { return _lineHeight; @@ -134,7 +134,7 @@ public: void initLoop(); private: - ERRORCODE parseLayer(CBTTFontLayer *layer, byte *buffer); + bool parseLayer(CBTTFontLayer *layer, byte *buffer); void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); @@ -145,7 +145,7 @@ private: CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - ERRORCODE initFont(); + bool initFont(); Graphics::Font *_deletableFont; const Graphics::Font *_font; diff --git a/engines/wintermute/Base/particles/PartEmitter.cpp b/engines/wintermute/Base/particles/PartEmitter.cpp index dc76dd696d..e113ab7399 100644 --- a/engines/wintermute/Base/particles/PartEmitter.cpp +++ b/engines/wintermute/Base/particles/PartEmitter.cpp @@ -116,7 +116,7 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::addSprite(const char *filename) { +bool CPartEmitter::addSprite(const char *filename) { if (!filename) return STATUS_FAILED; // do we already have the file? @@ -139,7 +139,7 @@ ERRORCODE CPartEmitter::addSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::removeSprite(const char *filename) { +bool CPartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; @@ -151,7 +151,7 @@ ERRORCODE CPartEmitter::removeSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { +bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { if (!particle) return STATUS_FAILED; if (_sprites.getSize() == 0) return STATUS_FAILED; @@ -226,13 +226,13 @@ ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::update() { +bool CPartEmitter::update() { if (!_running) return STATUS_OK; else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { +bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; for (int i = 0; i < _particles.getSize(); i++) { @@ -288,7 +288,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::display(CBRegion *region) { +bool CPartEmitter::display(CBRegion *region) { if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.getSize(); i++) { @@ -305,7 +305,7 @@ ERRORCODE CPartEmitter::display(CBRegion *region) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::start() { +bool CPartEmitter::start() { for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->_isDead = true; } @@ -329,7 +329,7 @@ ERRORCODE CPartEmitter::start() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::sortParticlesByZ() { +bool CPartEmitter::sortParticlesByZ() { // sort particles by _posY qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); return STATUS_OK; @@ -346,14 +346,14 @@ int CPartEmitter::compareZ(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::setBorder(int x, int y, int width, int height) { +bool CPartEmitter::setBorder(int x, int y, int width, int height) { CBPlatform::setRect(&_border, x, y, x + width, y + height); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { +bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { _borderThicknessLeft = thicknessLeft; _borderThicknessRight = thicknessRight; _borderThicknessTop = thicknessTop; @@ -384,7 +384,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { +bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { CPartForce *force = addForceByName(name); if (!force) return STATUS_FAILED; @@ -400,7 +400,7 @@ ERRORCODE CPartEmitter::addForce(const char *name, CPartForce::TForceType type, } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::removeForce(const char *name) { +bool CPartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; @@ -415,7 +415,7 @@ ERRORCODE CPartEmitter::removeForce(const char *name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -833,7 +833,7 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::scSetProperty(const char *name, CScValue *value) { +bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// @@ -1098,7 +1098,7 @@ const char *CPartEmitter::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) { +bool CPartEmitter::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); diff --git a/engines/wintermute/Base/particles/PartEmitter.h b/engines/wintermute/Base/particles/PartEmitter.h index 6f517bf357..92918927ea 100644 --- a/engines/wintermute/Base/particles/PartEmitter.h +++ b/engines/wintermute/Base/particles/PartEmitter.h @@ -100,35 +100,35 @@ public: char *_emitEvent; CBScriptHolder *_owner; - ERRORCODE start(); + bool start(); - ERRORCODE update(); - ERRORCODE display() { return display(NULL); } // To avoid shadowing the inherited display-function. - ERRORCODE display(CBRegion *region); + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(CBRegion *region); - ERRORCODE sortParticlesByZ(); - ERRORCODE addSprite(const char *filename); - ERRORCODE removeSprite(const char *filename); - ERRORCODE setBorder(int x, int y, int width, int height); - ERRORCODE setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - ERRORCODE addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - ERRORCODE removeForce(const char *name); + bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); CBArray _forces; // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); private: CPartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); - ERRORCODE initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - ERRORCODE updateInternal(uint32 currentTime, uint32 timerDelta); + bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; CBArray _particles; CBArray _sprites; diff --git a/engines/wintermute/Base/particles/PartForce.cpp b/engines/wintermute/Base/particles/PartForce.cpp index 2da74da14d..69f3f274d3 100644 --- a/engines/wintermute/Base/particles/PartForce.cpp +++ b/engines/wintermute/Base/particles/PartForce.cpp @@ -47,7 +47,7 @@ CPartForce::~CPartForce(void) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartForce::persist(CBPersistMgr *persistMgr) { +bool CPartForce::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); diff --git a/engines/wintermute/Base/particles/PartForce.h b/engines/wintermute/Base/particles/PartForce.h index cf5d697a79..d895e22ee7 100644 --- a/engines/wintermute/Base/particles/PartForce.h +++ b/engines/wintermute/Base/particles/PartForce.h @@ -49,7 +49,7 @@ public: Vector2 _direction; TForceType _type; - ERRORCODE persist(CBPersistMgr *PersistMgr); + bool persist(CBPersistMgr *PersistMgr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartParticle.cpp b/engines/wintermute/Base/particles/PartParticle.cpp index ebb7fe9f7a..37f9796fe7 100644 --- a/engines/wintermute/Base/particles/PartParticle.cpp +++ b/engines/wintermute/Base/particles/PartParticle.cpp @@ -72,7 +72,7 @@ CPartParticle::~CPartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::setSprite(const char *filename) { +bool CPartParticle::setSprite(const char *filename) { if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { _sprite->reset(); return STATUS_OK; @@ -96,7 +96,7 @@ ERRORCODE CPartParticle::setSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { +bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; @@ -182,7 +182,7 @@ ERRORCODE CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint3 } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::display(CPartEmitter *emitter) { +bool CPartParticle::display(CPartEmitter *emitter) { if (!_sprite) return STATUS_FAILED; if (_isDead) return STATUS_OK; @@ -197,7 +197,7 @@ ERRORCODE CPartParticle::display(CPartEmitter *emitter) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { +bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { _currentAlpha = 0; _fadeStart = currentTime; _fadeTime = fadeTime; @@ -207,7 +207,7 @@ ERRORCODE CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { +bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; _fadeStart = currentTime; @@ -218,7 +218,7 @@ ERRORCODE CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CPartParticle::persist(CBPersistMgr *persistMgr) { +bool CPartParticle::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_alpha1)); persistMgr->transfer(TMEMBER(_alpha2)); persistMgr->transfer(TMEMBER(_border)); diff --git a/engines/wintermute/Base/particles/PartParticle.h b/engines/wintermute/Base/particles/PartParticle.h index aed559d337..c8ad1181d7 100644 --- a/engines/wintermute/Base/particles/PartParticle.h +++ b/engines/wintermute/Base/particles/PartParticle.h @@ -69,15 +69,15 @@ public: bool _isDead; TParticleState _state; - ERRORCODE update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - ERRORCODE display(CPartEmitter *emitter); + bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(CPartEmitter *emitter); - ERRORCODE setSprite(const char *filename); + bool setSprite(const char *filename); - ERRORCODE fadeIn(uint32 currentTime, int fadeTime); - ERRORCODE fadeOut(uint32 currentTime, int fadeTime); + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); - ERRORCODE persist(CBPersistMgr *PersistMgr); + bool persist(CBPersistMgr *PersistMgr); private: uint32 _fadeStart; int _fadeTime; diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index a52a83db0a..e825e5ff97 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -93,7 +93,7 @@ const char *CSXArray::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXArray::scSetProperty(const char *name, CScValue *value) { +bool CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// @@ -199,7 +199,7 @@ ERRORCODE CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXArray::persist(CBPersistMgr *persistMgr) { +bool CSXArray::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_length)); @@ -227,7 +227,7 @@ bool CSXArray::validNumber(const char *origStr, char *outStr) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXArray::push(CScValue *val) { +bool CSXArray::push(CScValue *val) { char paramName[20]; _length++; sprintf(paramName, "%d", _length - 1); diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h index 040fbaf481..fcf29f7032 100644 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ b/engines/wintermute/Base/scriptables/SXArray.h @@ -35,15 +35,15 @@ namespace WinterMute { class CSXArray : public CBScriptable { public: - ERRORCODE push(CScValue *Val); + bool push(CScValue *Val); bool validNumber(const char *origStr, char *outStr); DECLARE_PERSISTENT(CSXArray, CBScriptable) CSXArray(CBGame *inGame, CScStack *stack); CSXArray(CBGame *inGame); virtual ~CSXArray(); CScValue *scGetProperty(const char *name); - ERRORCODE scSetProperty(const char *name, CScValue *value); - ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); int _length; CScValue *_values; diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index a9ffaf5dd5..214de237fe 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -75,7 +75,7 @@ const char *CSXDate::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ CScValue *CSXDate::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXDate::scSetProperty(const char *name, CScValue *value) { +bool CSXDate::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -238,7 +238,7 @@ ERRORCODE CSXDate::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXDate::persist(CBPersistMgr *persistMgr) { +bool CSXDate::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_tm.tm_year)); diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h index 324e711e82..cb1ac4f98f 100644 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ b/engines/wintermute/Base/scriptables/SXDate.h @@ -41,8 +41,8 @@ public: CSXDate(CBGame *inGame, CScStack *Stack); virtual ~CSXDate(); CScValue *scGetProperty(const char *name); - ERRORCODE scSetProperty(const char *name, CScValue *value); - ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); char *_string; TimeDate _tm; diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index cc30c14e93..f6c34545d0 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -100,7 +100,7 @@ const char *CSXFile::scToString() { #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -214,7 +214,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th uint32 counter = 0; byte b; bool foundNewLine = false; - ERRORCODE ret = STATUS_FAILED; + bool ret = STATUS_FAILED; do { ret = _readFile->read(&b, 1); if (ret != 1) break; @@ -265,7 +265,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th uint32 counter = 0; byte b; - ERRORCODE ret = STATUS_FAILED; + bool ret = STATUS_FAILED; while (counter < (uint32)textLen) { ret = _readFile->read(&b, 1); if (ret != 1) break; @@ -654,7 +654,7 @@ CScValue *CSXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXFile::scSetProperty(const char *name, CScValue *value) { +bool CSXFile::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -717,7 +717,7 @@ uint32 CSXFile::getLength() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) { +bool CSXFile::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h index f07e2a56cf..f772473dd6 100644 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ b/engines/wintermute/Base/scriptables/SXFile.h @@ -41,8 +41,8 @@ class CSXFile : public CBScriptable { public: DECLARE_PERSISTENT(CSXFile, CBScriptable) CScValue *scGetProperty(const char *name); - ERRORCODE scSetProperty(const char *name, CScValue *value); - ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXFile(CBGame *inGame, CScStack *Stack); virtual ~CSXFile(); diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index aba58e2aa7..40e185d6cc 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -59,7 +59,7 @@ CSXMath::~CSXMath() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// @@ -286,7 +286,7 @@ double CSXMath::radianToDegree(double value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMath::persist(CBPersistMgr *persistMgr) { +bool CSXMath::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h index aceca5ea08..eb11b94f34 100644 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ b/engines/wintermute/Base/scriptables/SXMath.h @@ -40,7 +40,7 @@ public: CSXMath(CBGame *inGame); virtual ~CSXMath(); virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); private: double degreeToRadian(double value); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 428a58a997..296326ebe5 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -76,7 +76,7 @@ void CSXMemBuffer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMemBuffer::resize(int newSize) { +bool CSXMemBuffer::resize(int newSize) { int oldSize = _size; if (_size == 0) { @@ -124,7 +124,7 @@ const char *CSXMemBuffer::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -457,7 +457,7 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { +bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -480,7 +480,7 @@ ERRORCODE CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXMemBuffer::persist(CBPersistMgr *persistMgr) { +bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h index 775f8247b2..9a8746288c 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.h @@ -39,8 +39,8 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) CScValue *scGetProperty(const char *name); - ERRORCODE scSetProperty(const char *name, CScValue *value); - ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); const char *scToString(); CSXMemBuffer(CBGame *inGame, CScStack *stack); CSXMemBuffer(CBGame *inGame, void *buffer); @@ -48,7 +48,7 @@ public: virtual void *scToMemBuffer(); int _size; private: - ERRORCODE resize(int newSize); + bool resize(int newSize); void *_buffer; void cleanup(); bool checkBounds(CScScript *script, int start, int length); diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 5e7043ee19..ba70551dde 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -99,7 +99,7 @@ void CSXString::scSetString(const char *val) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,7 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXString::scSetProperty(const char *name, CScValue *value) { +bool CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// @@ -377,7 +377,7 @@ ERRORCODE CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXString::persist(CBPersistMgr *persistMgr) { +bool CSXString::persist(CBPersistMgr *persistMgr) { CBScriptable::persist(persistMgr); diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h index c9fcad6463..04f9bc80c3 100644 --- a/engines/wintermute/Base/scriptables/SXString.h +++ b/engines/wintermute/Base/scriptables/SXString.h @@ -39,8 +39,8 @@ public: virtual int scCompare(CBScriptable *Val); DECLARE_PERSISTENT(CSXString, CBScriptable) CScValue *scGetProperty(const char *name); - ERRORCODE scSetProperty(const char *name, CScValue *value); - ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); void scSetString(const char *val); const char *scToString(); void setStringVal(const char *val); diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index d976707ce2..8e57c9a3eb 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -98,7 +98,7 @@ CScEngine::~CScEngine() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::cleanup() { +bool CScEngine::cleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; @@ -148,7 +148,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { // add new script CScScript *script = new CScScript(_gameRef, this); - ERRORCODE ret = script->create(filename, compBuffer, compSize, owner); + bool ret = script->create(filename, compBuffer, compSize, owner); if (DID_FAIL(ret)) { _gameRef->LOG(ret, "Error running script '%s'...", filename); delete script; @@ -244,7 +244,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::tick() { +bool CScEngine::tick() { if (_scripts.getSize() == 0) return STATUS_OK; @@ -344,7 +344,7 @@ ERRORCODE CScEngine::tick() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::tickUnbreakable() { +bool CScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_unbreakable) continue; @@ -363,7 +363,7 @@ ERRORCODE CScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::removeFinishedScripts() { +bool CScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { @@ -411,7 +411,7 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::emptyScriptCache() { +bool CScEngine::emptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i]) { delete _cachedScripts[i]; @@ -423,7 +423,7 @@ ERRORCODE CScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::resetObject(CBObject *Object) { +bool CScEngine::resetObject(CBObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { @@ -437,7 +437,7 @@ ERRORCODE CScEngine::resetObject(CBObject *Object) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::resetScript(CScScript *script) { +bool CScEngine::resetScript(CScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { @@ -448,7 +448,7 @@ ERRORCODE CScEngine::resetScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::persist(CBPersistMgr *persistMgr) { +bool CScEngine::persist(CBPersistMgr *persistMgr) { if (!persistMgr->_saving) cleanup(); persistMgr->transfer(TMEMBER(_gameRef)); @@ -473,7 +473,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::pauseAll() { +bool CScEngine::pauseAll() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->pause(); } @@ -483,7 +483,7 @@ ERRORCODE CScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::resumeAll() { +bool CScEngine::resumeAll() { for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->resume(); @@ -500,13 +500,13 @@ bool CScEngine::isValidScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::clearGlobals(bool includingNatives) { +bool CScEngine::clearGlobals(bool includingNatives) { _globals->CleanProps(includingNatives); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) { +bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); @@ -526,7 +526,7 @@ ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { +bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; @@ -553,7 +553,7 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { +bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -578,7 +578,7 @@ ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::refreshScriptBreakpoints() { +bool CScEngine::refreshScriptBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _scripts.getSize(); i++) { @@ -588,7 +588,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { +bool CScEngine::refreshScriptBreakpoints(CScScript *script) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; if (!script || !script->_filename) return STATUS_FAILED; @@ -605,7 +605,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::saveBreakpoints() { +bool CScEngine::saveBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; @@ -628,7 +628,7 @@ ERRORCODE CScEngine::saveBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScEngine::loadBreakpoints() { +bool CScEngine::loadBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; char key[100]; diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h index d439ab8eab..cca1c1aa6b 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ b/engines/wintermute/Base/scriptables/ScEngine.h @@ -83,33 +83,33 @@ public: public: - ERRORCODE dbgSendScripts(IWmeDebugClient *client); + bool dbgSendScripts(IWmeDebugClient *client); CBArray _breakpoints; - ERRORCODE addBreakpoint(const char *scriptFilename, int line); - ERRORCODE removeBreakpoint(const char *scriptFilename, int line); - ERRORCODE refreshScriptBreakpoints(); - ERRORCODE refreshScriptBreakpoints(CScScript *script); - ERRORCODE saveBreakpoints(); - ERRORCODE loadBreakpoints(); - - ERRORCODE clearGlobals(bool includingNatives = false); - ERRORCODE tickUnbreakable(); - ERRORCODE removeFinishedScripts(); + bool addBreakpoint(const char *scriptFilename, int line); + bool removeBreakpoint(const char *scriptFilename, int line); + bool refreshScriptBreakpoints(); + bool refreshScriptBreakpoints(CScScript *script); + bool saveBreakpoints(); + bool loadBreakpoints(); + + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); bool isValidScript(CScScript *script); CScScript *_currentScript; - ERRORCODE resumeAll(); - ERRORCODE pauseAll(); + bool resumeAll(); + bool pauseAll(); void editorCleanup(); - ERRORCODE resetObject(CBObject *Object); - ERRORCODE resetScript(CScScript *script); - ERRORCODE emptyScriptCache(); + bool resetObject(CBObject *Object); + bool resetScript(CScScript *script); + bool emptyScriptCache(); byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); DECLARE_PERSISTENT(CScEngine, CBBase) - ERRORCODE cleanup(); + bool cleanup(); int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - ERRORCODE tick(); + bool tick(); CScValue *_globals; CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); static const bool _compilerAvailable = false; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index e1cf791e31..bddb687934 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -118,7 +118,7 @@ void CScScript::readHeader() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::initScript() { +bool CScScript::initScript() { if (!_scriptStream) { _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); } @@ -165,7 +165,7 @@ ERRORCODE CScScript::initScript() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::initTables() { +bool CScScript::initTables() { uint32 OrigIP = _iP; readHeader(); @@ -240,7 +240,7 @@ ERRORCODE CScScript::initTables() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { +bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { cleanup(); _thread = false; @@ -259,7 +259,7 @@ ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBS _bufferSize = size; - ERRORCODE res = initScript(); + bool res = initScript(); if (DID_FAIL(res)) return res; // establish global variables table @@ -272,7 +272,7 @@ ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBS ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { +bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { cleanup(); _thread = true; @@ -292,7 +292,7 @@ ERRORCODE CScScript::createThread(CScScript *original, uint32 initIP, const char _bufferSize = original->_bufferSize; // initialize - ERRORCODE res = initScript(); + bool res = initScript(); if (DID_FAIL(res)) return res; // copy globals @@ -316,7 +316,7 @@ ERRORCODE CScScript::createThread(CScScript *original, uint32 initIP, const char ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::createMethodThread(CScScript *original, const char *methodName) { +bool CScScript::createMethodThread(CScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); if (ip == 0) return STATUS_FAILED; @@ -339,7 +339,7 @@ ERRORCODE CScScript::createMethodThread(CScScript *original, const char *methodN _bufferSize = original->_bufferSize; // initialize - ERRORCODE res = initScript(); + bool res = initScript(); if (DID_FAIL(res)) return res; // copy globals @@ -470,8 +470,8 @@ char *CScScript::getString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::executeInstruction() { - ERRORCODE ret = STATUS_OK; +bool CScScript::executeInstruction() { + bool ret = STATUS_OK; uint32 dw; const char *str = NULL; @@ -560,7 +560,7 @@ ERRORCODE CScScript::executeInstruction() { CScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - ERRORCODE res = STATUS_FAILED; + bool res = STATUS_FAILED; bool TriedNative = false; // we are already calling this method, try native @@ -1120,7 +1120,7 @@ CScValue *CScScript::getVar(char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::waitFor(CBObject *object) { +bool CScScript::waitFor(CBObject *object) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1133,14 +1133,14 @@ ERRORCODE CScScript::waitFor(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::waitForExclusive(CBObject *object) { +bool CScScript::waitForExclusive(CBObject *object) { _engine->resetObject(object); return waitFor(object); } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::sleep(uint32 duration) { +bool CScScript::sleep(uint32 duration) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1159,7 +1159,7 @@ ERRORCODE CScScript::sleep(uint32 duration) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::finish(bool includingThreads) { +bool CScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); @@ -1171,7 +1171,7 @@ ERRORCODE CScScript::finish(bool includingThreads) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::run() { +bool CScScript::run() { _state = SCRIPT_RUNNING; return STATUS_OK; } @@ -1195,7 +1195,7 @@ void CScScript::runtimeError(const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::persist(CBPersistMgr *persistMgr) { +bool CScScript::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -1265,7 +1265,7 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable CScScript *thread = new CScScript(_gameRef, _engine); if (thread) { - ERRORCODE ret = thread->createThread(this, pos, eventName); + bool ret = thread->createThread(this, pos, eventName); if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); @@ -1302,7 +1302,7 @@ bool CScScript::canHandleMethod(const char *methodName) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::pause() { +bool CScScript::pause() { if (_state == SCRIPT_PAUSED) { _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return STATUS_FAILED; @@ -1318,7 +1318,7 @@ ERRORCODE CScScript::pause() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::resume() { +bool CScScript::resume() { if (_state != SCRIPT_PAUSED) return STATUS_OK; _state = _origState; @@ -1337,7 +1337,7 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { +bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { _gameRef->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); @@ -1347,7 +1347,7 @@ ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScrip ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::copyParameters(CScStack *stack) { +bool CScScript::copyParameters(CScStack *stack) { int i; int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { @@ -1362,7 +1362,7 @@ ERRORCODE CScScript::copyParameters(CScStack *stack) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::finishThreads() { +bool CScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.getSize(); i++) { CScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) @@ -1385,7 +1385,7 @@ const char *CScScript::dbgGetFilename() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::dbgSendScript(IWmeDebugClient *client) { +bool CScScript::dbgSendScript(IWmeDebugClient *client) { if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); else client->onScriptInit(this); @@ -1395,7 +1395,7 @@ ERRORCODE CScScript::dbgSendScript(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScScript::dbgSendVariables(IWmeDebugClient *client) { +bool CScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h index 666edb8309..24d3f87fe5 100644 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ b/engines/wintermute/Base/scriptables/ScScript.h @@ -43,37 +43,37 @@ class CScEngine; class CScStack; class CScScript : public CBBase, public IWmeDebugScript { public: - ERRORCODE dbgSendScript(IWmeDebugClient *client); - ERRORCODE dbgSendVariables(IWmeDebugClient *client); + bool dbgSendScript(IWmeDebugClient *client); + bool dbgSendVariables(IWmeDebugClient *client); CBArray _breakpoints; bool _tracingMode; CScScript *_parentScript; bool _unbreakable; - ERRORCODE finishThreads(); - ERRORCODE copyParameters(CScStack *stack); + bool finishThreads(); + bool copyParameters(CScStack *stack); void afterLoad(); CScValue *_operand; CScValue *_reg1; bool _freezable; - ERRORCODE resume(); - ERRORCODE pause(); + bool resume(); + bool pause(); bool canHandleEvent(const char *eventName); bool canHandleMethod(const char *methodName); - ERRORCODE createThread(CScScript *original, uint32 initIP, const char *eventName); - ERRORCODE createMethodThread(CScScript *original, const char *methodName); + bool createThread(CScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(CScScript *original, const char *methodName); CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(CScScript, CBBase) void runtimeError(const char *fmt, ...); - ERRORCODE run(); - ERRORCODE finish(bool includingThreads = false); - ERRORCODE sleep(uint32 duration); - ERRORCODE waitForExclusive(CBObject *object); - ERRORCODE waitFor(CBObject *object); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(CBObject *object); + bool waitFor(CBObject *object); uint32 _waitTime; bool _waitFrozen; CBObject *_waitObject; @@ -129,12 +129,12 @@ public: CScValue *_globals; CScEngine *_engine; int _currentLine; - ERRORCODE executeInstruction(); + bool executeInstruction(); char *getString(); uint32 getDWORD(); double getFloat(); void cleanup(); - ERRORCODE create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); uint32 _iP; private: void readHeader(); @@ -160,10 +160,10 @@ public: char *_threadEvent; CBScriptHolder *_owner; CScScript::TExternalFunction *getExternal(char *name); - ERRORCODE externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); + bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); private: - ERRORCODE initScript(); - ERRORCODE initTables(); + bool initScript(); + bool initTables(); // IWmeDebugScript interface implementation diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index c889b5ea9e..fd85e9a5d8 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -213,7 +213,7 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScStack::persist(CBPersistMgr *persistMgr) { +bool CScStack::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp index 2c5f388c3d..e75cb133bc 100644 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ b/engines/wintermute/Base/scriptables/ScValue.cpp @@ -188,7 +188,7 @@ CScValue *CScValue::getProp(const char *name) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScValue::deleteProp(const char *name) { +bool CScValue::deleteProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); _valIter = _valObject.find(name); @@ -203,11 +203,11 @@ ERRORCODE CScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { +bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, val); - ERRORCODE ret = STATUS_FAILED; + bool ret = STATUS_FAILED; if (_type == VAL_NATIVE && _valNative) { ret = _valNative->scSetProperty(name, val); } @@ -735,7 +735,7 @@ void CScValue::setValue(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScValue::persist(CBPersistMgr *persistMgr) { +bool CScValue::persist(CBPersistMgr *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_persistent)); @@ -819,7 +819,7 @@ ERRORCODE CScValue::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScValue::saveAsText(CBDynBuffer *buffer, int indent) { +bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { buffer->putTextIndent(indent, "PROPERTY {\n"); @@ -878,7 +878,7 @@ int CScValue::compareStrict(CScValue *val1, CScValue *val2) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { +bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h index 2f946dffc5..3410111d71 100644 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ b/engines/wintermute/Base/scriptables/ScValue.h @@ -43,7 +43,7 @@ class CBScriptable; class CScValue : public CBBase, public IWmeDebugProp { public: - ERRORCODE dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); static int compare(CScValue *val1, CScValue *val2); static int compareStrict(CScValue *val1, CScValue *val2); @@ -52,7 +52,7 @@ public: DECLARE_PERSISTENT(CScValue, CBBase) bool _isConstVar; - ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool saveAsText(CBDynBuffer *buffer, int indent); void setValue(CScValue *val); bool _persistent; bool propExists(const char *name); @@ -65,7 +65,7 @@ public: const char *getString(); void *getMemBuffer(); CBScriptable *getNative(); - ERRORCODE deleteProp(const char *name); + bool deleteProp(const char *name); void deleteProps(); void CleanProps(bool includingNatives); void setBool(bool val); @@ -84,7 +84,7 @@ public: bool isFloat(); bool isInt(); bool isObject(); - ERRORCODE setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); CScValue *getProp(const char *name); CBScriptable *_valNative; CScValue *_valRef; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index 966eb0da09..ba961ed2ae 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -58,7 +58,7 @@ CSXObject::~CSXObject() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSXObject::persist(CBPersistMgr *persistMgr) { +bool CSXObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); return STATUS_OK; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index b829aece35..66f3bed81f 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -167,7 +167,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { +bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { persistMgr->putString(""); persistMgr->putDWORD(_classes.size()); @@ -191,7 +191,7 @@ ERRORCODE CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { +bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { checkHeader("", persistMgr); // reset SavedID of current instances @@ -226,7 +226,7 @@ ERRORCODE CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { +bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { Classes::iterator it; @@ -258,7 +258,7 @@ ERRORCODE CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persis } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { +bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { // get total instances int numInstances = persistMgr->getDWORD(); @@ -294,7 +294,7 @@ ERRORCODE CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persis ////////////////////////////////////////////////////////////////////////// -ERRORCODE CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { +bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return STATUS_FAILED; diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h index 679c92030e..a4a410527d 100644 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ b/engines/wintermute/Sys/SysClassRegistry.h @@ -66,11 +66,11 @@ public: CSysClassRegistry(); virtual ~CSysClassRegistry(); - ERRORCODE enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - ERRORCODE loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - ERRORCODE saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - ERRORCODE loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - ERRORCODE saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + bool loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + bool loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); void *idToPointer(int classID, int instanceID); bool getPointerID(void *pointer, int *classID, int *instanceID); bool registerClass(CSysClass *classObj); diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 5a8b994344..40c5166b45 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -95,14 +95,14 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::loadFile(const char *filename) { +bool CUIButton::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -154,7 +154,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { +bool CUIButton::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -439,7 +439,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "BUTTON\n"); buffer->putTextIndent(indent, "{\n"); @@ -577,7 +577,7 @@ void CUIButton::correctSize() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::display(int offsetX, int offsetY) { +bool CUIButton::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; @@ -666,7 +666,7 @@ void CUIButton::press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// @@ -967,7 +967,7 @@ CScValue *CUIButton::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::scSetProperty(const char *name, CScValue *value) { +bool CUIButton::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -1011,7 +1011,7 @@ const char *CUIButton::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIButton::persist(CBPersistMgr *persistMgr) { +bool CUIButton::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h index a857e8ed2a..5bdc075ebc 100644 --- a/engines/wintermute/UI/UIButton.h +++ b/engines/wintermute/UI/UIButton.h @@ -44,7 +44,7 @@ public: uint32 _oneTimePressTime; DECLARE_PERSISTENT(CUIButton, CUIObject) void press(); - virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); + virtual bool display(int offsetX = 0, int offsetY = 0); bool _press; bool _hover; void correctSize(); @@ -63,14 +63,14 @@ public: CUITiledImage *_backFocus; CUIButton(CBGame *inGame = NULL); virtual ~CUIButton(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index c3cb3ad810..f964ada462 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -91,14 +91,14 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::loadFile(const char *filename) { +bool CUIEdit::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -136,7 +136,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { +bool CUIEdit::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -299,7 +299,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "EDIT\n"); buffer->putTextIndent(indent, "{\n"); @@ -358,7 +358,7 @@ ERRORCODE CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// @@ -454,7 +454,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::scSetProperty(const char *name, CScValue *value) { +bool CUIEdit::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// @@ -540,7 +540,7 @@ void CUIEdit::setCursorChar(const char *character) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::display(int offsetX, int offsetY) { +bool CUIEdit::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; @@ -833,7 +833,7 @@ int CUIEdit::insertChars(int pos, byte *chars, int num) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEdit::persist(CBPersistMgr *persistMgr) { +bool CUIEdit::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h index d47066c8f0..7249301592 100644 --- a/engines/wintermute/UI/UIEdit.h +++ b/engines/wintermute/UI/UIEdit.h @@ -43,7 +43,7 @@ public: int deleteChars(int start, int end); bool _cursorVisible; uint32 _lastBlinkTime; - virtual ERRORCODE display(int offsetX, int offsetY); + virtual bool display(int offsetX, int offsetY); virtual bool handleKeypress(Common::Event *event, bool printable = false); int _scrollOffset; int _frameWidth; @@ -56,14 +56,14 @@ public: CUIEdit(CBGame *inGame); virtual ~CUIEdit(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index 7df6493fd5..a479cd9bd1 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -55,14 +55,14 @@ CUIEntity::~CUIEntity() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::loadFile(const char *filename) { +bool CUIEntity::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -89,7 +89,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { +bool CUIEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -174,7 +174,7 @@ ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); buffer->putTextIndent(indent, "{\n"); @@ -208,7 +208,7 @@ ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::setEntity(const char *filename) { +bool CUIEntity::setEntity(const char *filename) { if (_entity) _gameRef->unregisterObject(_entity); _entity = new CAdEntity(_gameRef); if (!_entity || DID_FAIL(_entity->loadFile(filename))) { @@ -225,7 +225,7 @@ ERRORCODE CUIEntity::setEntity(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::display(int offsetX, int offsetY) { +bool CUIEntity::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; if (_entity) { @@ -251,7 +251,7 @@ ERRORCODE CUIEntity::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// @@ -310,7 +310,7 @@ CScValue *CUIEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::scSetProperty(const char *name, CScValue *value) { +bool CUIEntity::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// @@ -328,7 +328,7 @@ const char *CUIEntity::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIEntity::persist(CBPersistMgr *persistMgr) { +bool CUIEntity::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h index bef73b5e05..b0711838a5 100644 --- a/engines/wintermute/UI/UIEntity.h +++ b/engines/wintermute/UI/UIEntity.h @@ -38,18 +38,18 @@ public: DECLARE_PERSISTENT(CUIEntity, CUIObject) CUIEntity(CBGame *inGame); virtual ~CUIEntity(); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); + virtual bool display(int offsetX = 0, int offsetY = 0); CAdEntity *_entity; - ERRORCODE setEntity(const char *filename); + bool setEntity(const char *filename); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index e7e6fa3b7a..28241c4ae4 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -98,7 +98,7 @@ void CUIObject::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::display(int offsetX, int offsetY) { +bool CUIObject::display(int offsetX, int offsetY) { return STATUS_OK; } @@ -137,7 +137,7 @@ void CUIObject::correctSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// @@ -418,7 +418,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::scSetProperty(const char *name, CScValue *value) { +bool CUIObject::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -500,7 +500,7 @@ bool CUIObject::isFocused() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { +bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { // handle focus change if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { focus(); @@ -510,7 +510,7 @@ ERRORCODE CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::focus() { +bool CUIObject::focus() { CUIObject *obj = this; bool disabled = false; while (obj) { @@ -537,7 +537,7 @@ ERRORCODE CUIObject::focus() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::getTotalOffset(int *offsetX, int *offsetY) { +bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { int offX = 0, offY = 0; CUIObject *obj = _parent; @@ -555,7 +555,7 @@ ERRORCODE CUIObject::getTotalOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::persist(CBPersistMgr *persistMgr) { +bool CUIObject::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); @@ -582,7 +582,7 @@ ERRORCODE CUIObject::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { return STATUS_FAILED; } diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h index 92dc84eeef..a51df9485d 100644 --- a/engines/wintermute/UI/UIObject.h +++ b/engines/wintermute/UI/UIObject.h @@ -40,15 +40,15 @@ class CBFont; class CUIObject : public CBObject { public: - ERRORCODE getTotalOffset(int *offsetX, int *offsetY); + bool getTotalOffset(int *offsetX, int *offsetY); bool _canFocus; - ERRORCODE focus(); - virtual ERRORCODE handleMouse(TMouseEvent event, TMouseButton button); + bool focus(); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); bool _parentNotify; DECLARE_PERSISTENT(CUIObject, CBObject) CUIObject *_parent; - virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); + virtual bool display(int offsetX = 0, int offsetY = 0); virtual void correctSize(); bool _sharedFonts; bool _sharedImages; @@ -69,12 +69,12 @@ public: uint32 _listenerParamDWORD; CBScriptHolder *_listenerObject; CUIObject *_focusedWidget; - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index e219adb262..3ca8e135c1 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -62,7 +62,7 @@ CUIText::~CUIText() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::display(int offsetX, int offsetY) { +bool CUIText::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; @@ -95,14 +95,14 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::loadFile(const char *filename) { +bool CUIText::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -138,7 +138,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { +bool CUIText::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -293,7 +293,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "STATIC\n"); buffer->putTextIndent(indent, "{\n"); @@ -376,7 +376,7 @@ ERRORCODE CUIText::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// @@ -434,7 +434,7 @@ CScValue *CUIText::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::scSetProperty(const char *name, CScValue *value) { +bool CUIText::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -467,7 +467,7 @@ const char *CUIText::scToString() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::persist(CBPersistMgr *persistMgr) { +bool CUIText::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_textAlign)); @@ -478,7 +478,7 @@ ERRORCODE CUIText::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIText::sizeToFit() { +bool CUIText::sizeToFit() { if (_font && _text) { _width = _font->getTextWidth((byte *)_text); _height = _font->getTextHeight((byte *)_text, _width); diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h index 35428fc283..62fbf00b0a 100644 --- a/engines/wintermute/UI/UIText.h +++ b/engines/wintermute/UI/UIText.h @@ -36,22 +36,22 @@ namespace WinterMute { class CUIText : public CUIObject { private: - ERRORCODE sizeToFit(); + bool sizeToFit(); public: - virtual ERRORCODE display(int offsetX, int offsetY); + virtual bool display(int offsetX, int offsetY); DECLARE_PERSISTENT(CUIText, CUIObject) CUIText(CBGame *inGame = NULL); virtual ~CUIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index fc8f43ee2f..12e392a18f 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -64,7 +64,7 @@ CUITiledImage::~CUITiledImage() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { +bool CUITiledImage::display(int x, int y, int width, int height) { if (!_image) return STATUS_FAILED; int tileWidth = _middleMiddle.right - _middleMiddle.left; @@ -119,14 +119,14 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUITiledImage::loadFile(const char *filename) { +bool CUITiledImage::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -158,7 +158,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { +bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -307,7 +307,7 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TILED_IMAGE\n"); buffer->putTextIndent(indent, "{\n"); @@ -350,7 +350,7 @@ void CUITiledImage::correctSize(int *width, int *height) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUITiledImage::persist(CBPersistMgr *persistMgr) { +bool CUITiledImage::persist(CBPersistMgr *persistMgr) { CBObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_downLeft)); diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h index 35083c15a8..379af85e81 100644 --- a/engines/wintermute/UI/UITiledImage.h +++ b/engines/wintermute/UI/UITiledImage.h @@ -39,11 +39,11 @@ class CUITiledImage : public CBObject { public: DECLARE_PERSISTENT(CUITiledImage, CBObject) void correctSize(int *width, int *height); - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); - ERRORCODE display(int x, int y, int width, int height); + bool display(int x, int y, int width, int height); CUITiledImage(CBGame *inGame = NULL); virtual ~CUITiledImage(); CBSubFrame *_image; diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 9126a1ca7b..1541ca3a1d 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -113,7 +113,7 @@ void CUIWindow::cleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::display(int offsetX, int offsetY) { +bool CUIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); @@ -207,14 +207,14 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::loadFile(const char *filename) { +bool CUIWindow::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } - ERRORCODE ret; + bool ret; _filename = new char [strlen(filename) + 1]; strcpy(_filename, filename); @@ -266,7 +266,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { +bool CUIWindow::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -575,7 +575,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { +bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WINDOW\n"); buffer->putTextIndent(indent, "{\n"); @@ -678,7 +678,7 @@ ERRORCODE CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::enableWidget(const char *name, bool Enable) { +bool CUIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; } @@ -687,7 +687,7 @@ ERRORCODE CUIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::showWidget(const char *name, bool Visible) { +bool CUIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; } @@ -698,7 +698,7 @@ ERRORCODE CUIWindow::showWidget(const char *name, bool Visible) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// @@ -1013,7 +1013,7 @@ CScValue *CUIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::scSetProperty(const char *name, CScValue *value) { +bool CUIWindow::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1128,8 +1128,8 @@ bool CUIWindow::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - ERRORCODE res = CUIObject::handleMouse(event, button); +bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + bool res = CUIObject::handleMouse(event, button); // handle window dragging if (!CBPlatform::isRectEmpty(&_dragRect)) { @@ -1158,7 +1158,7 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::persist(CBPersistMgr *persistMgr) { +bool CUIWindow::persist(CBPersistMgr *persistMgr) { CUIObject::persist(persistMgr); @@ -1189,7 +1189,7 @@ ERRORCODE CUIWindow::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::moveFocus(bool forward) { +bool CUIWindow::moveFocus(bool forward) { int i; bool found = false; for (i = 0; i < _widgets.getSize(); i++) { @@ -1230,7 +1230,7 @@ ERRORCODE CUIWindow::moveFocus(bool forward) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::goExclusive() { +bool CUIWindow::goExclusive() { if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; if (_mode == WINDOW_NORMAL) { @@ -1245,7 +1245,7 @@ ERRORCODE CUIWindow::goExclusive() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::goSystemExclusive() { +bool CUIWindow::goSystemExclusive() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; makeFreezable(false); @@ -1262,7 +1262,7 @@ ERRORCODE CUIWindow::goSystemExclusive() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::close() { +bool CUIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { _gameRef->unfreeze(); } @@ -1276,7 +1276,7 @@ ERRORCODE CUIWindow::close() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { +bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { CUIObject *obj = (CUIObject *)param1; switch (obj->_type) { @@ -1302,7 +1302,7 @@ void CUIWindow::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { +bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.getSize(); i++) { CUIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) continue; diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h index e597debaaa..f1d46711ff 100644 --- a/engines/wintermute/UI/UIWindow.h +++ b/engines/wintermute/UI/UIWindow.h @@ -39,7 +39,7 @@ class CUIButton; class CBViewport; class CUIWindow : public CUIObject { public: - ERRORCODE getWindowObjects(CBArray &Objects, bool InteractiveOnly); + bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); bool _pauseMusic; void cleanup(); @@ -53,38 +53,38 @@ public: virtual bool handleMouseWheel(int delta); CUIWindow *_shieldWindow; CUIButton *_shieldButton; - ERRORCODE close(); - ERRORCODE goSystemExclusive(); - ERRORCODE goExclusive(); + bool close(); + bool goSystemExclusive(); + bool goExclusive(); TWindowMode _mode; - ERRORCODE moveFocus(bool forward = true); - virtual ERRORCODE handleMouse(TMouseEvent Event, TMouseButton Button); + bool moveFocus(bool forward = true); + virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); Point32 _dragFrom; bool _dragging; DECLARE_PERSISTENT(CUIWindow, CUIObject) bool _transparent; - ERRORCODE showWidget(const char *name, bool visible = true); - ERRORCODE enableWidget(const char *name, bool enable = true); + bool showWidget(const char *name, bool visible = true); + bool enableWidget(const char *name, bool enable = true); Rect32 _titleRect; Rect32 _dragRect; - virtual ERRORCODE display(int offsetX = 0, int offsetY = 0); + virtual bool display(int offsetX = 0, int offsetY = 0); CUIWindow(CBGame *inGame); virtual ~CUIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false); CBArray _widgets; TTextAlign _titleAlign; - ERRORCODE loadFile(const char *filename); - ERRORCODE loadBuffer(byte *buffer, bool complete = true); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); CUITiledImage *_backInactive; CBFont *_fontInactive; CBSprite *_imageInactive; - virtual ERRORCODE listen(CBScriptHolder *param1, uint32 param2); - virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); // scripting interface virtual CScValue *scGetProperty(const char *name); - virtual ERRORCODE scSetProperty(const char *name, CScValue *value); - virtual ERRORCODE scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 0c71b3ec6e..fc1d0205c8 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -88,7 +88,7 @@ public: // Clean up void freeExtra(); void removeAll(); - ERRORCODE persist(CBPersistMgr *persistMgr); + bool persist(CBPersistMgr *persistMgr); // Accessing elements TYPE getAt(int nIndex) const; @@ -346,7 +346,7 @@ void CBArray::insertAt(int nStartIndex, CBArray *pNewArray) { ///////////////////////////////////////////////////////////////////////////// template -ERRORCODE CBArray::persist(CBPersistMgr *persistMgr) { +bool CBArray::persist(CBPersistMgr *persistMgr) { int i, j; if (persistMgr->_saving) { j = getSize(); diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index efdd651154..af1224c200 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -37,7 +37,7 @@ class CBPersistMgr; // persistence support typedef void *(*PERSISTBUILD)(void); -typedef ERRORCODE(*PERSISTLOAD)(void *, CBPersistMgr *); +typedef bool(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute @@ -50,9 +50,9 @@ namespace WinterMute { static const char _className[];\ static void* persistBuild(void);\ virtual const char* getClassName();\ - static ERRORCODE persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + static bool persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ - virtual ERRORCODE persist(CBPersistMgr* PersistMgr);\ + virtual bool persist(CBPersistMgr* PersistMgr);\ void* operator new (size_t size);\ void operator delete(void* p);\ @@ -63,7 +63,7 @@ namespace WinterMute { return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ }\ \ - ERRORCODE class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ + bool class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ return ((class_name*)Instance)->persist(PersistMgr);\ }\ \ diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index a962608691..93f3196eee 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -45,7 +45,7 @@ CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::SetDefaults() { +bool CVidPlayer::SetDefaults() { _playing = false; /* _aviFile = NULL; @@ -91,7 +91,7 @@ CVidPlayer::~CVidPlayer() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::cleanup() { +bool CVidPlayer::cleanup() { #if 0 if (_sound) _sound->Stop(); if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); @@ -124,7 +124,7 @@ ERRORCODE CVidPlayer::cleanup() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { +bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 cleanup(); @@ -183,7 +183,7 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil // create sound buffer - ERRORCODE res; + bool res; if (_soundAvailable) { _sound = new CBSoundAVI(_gameRef); @@ -204,11 +204,11 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::update() { +bool CVidPlayer::update() { #if 0 if (!m_Playing) return STATUS_OK; - ERRORCODE res; + bool res; if (_soundAvailable && m_Sound) { res = _sound->update(); @@ -274,11 +274,11 @@ ERRORCODE CVidPlayer::update() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::display() { +bool CVidPlayer::display() { #if 0 if (!m_Playing) return STATUS_OK; - ERRORCODE res; + bool res; if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); else res = STATUS_FAILED; @@ -298,7 +298,7 @@ ERRORCODE CVidPlayer::display() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +bool CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { #if 0 if (!_videoStream || !_vidRenderer) return STATUS_FAILED; @@ -359,7 +359,7 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::stop() { +bool CVidPlayer::stop() { #if 0 if (!_playing) return STATUS_OK; @@ -378,7 +378,7 @@ bool CVidPlayer::isPlaying() { ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { +bool CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { #if 0 if (!Filename) return STATUS_OK; diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index 6b729cac20..fd587aa609 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -46,23 +46,23 @@ class CVidPlayer : public CBBase { public: bool _showSubtitle; int _currentSubtitle; - ERRORCODE loadSubtitles(const char *filename, const char *SubtitleFile); + bool loadSubtitles(const char *filename, const char *SubtitleFile); bool _slowRendering; bool isPlaying(); char *_filename; - ERRORCODE stop(); - ERRORCODE play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + bool stop(); + bool play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); uint32 _totalVideoTime; uint32 _startTime; //CVidRenderer *_vidRenderer; //CBSoundAVI *_sound; bool _soundAvailable; - ERRORCODE SetDefaults(); + bool SetDefaults(); bool _playing; - ERRORCODE display(); - ERRORCODE update(); - ERRORCODE initialize(const char *inFilename, const char *SubtitleFile = NULL); - ERRORCODE cleanup(); + bool display(); + bool update(); + bool initialize(const char *inFilename, const char *SubtitleFile = NULL); + bool cleanup(); CVidPlayer(CBGame *inGame); virtual ~CVidPlayer(); diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 6a622449ab..d7e8850177 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -133,7 +133,7 @@ void CVidTheoraPlayer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { +bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { cleanup(); _filename = filename; @@ -294,7 +294,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com vorbis_comment_clear(&m_VorbisComment); } - ERRORCODE Res = STATUS_OK; + bool Res = STATUS_OK; // create sound buffer if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { @@ -334,7 +334,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::resetStream() { +bool CVidTheoraPlayer::resetStream() { warning("VidTheoraPlayer::resetStream - stubbed"); #if 0 if (_sound) _sound->Stop(); @@ -347,7 +347,7 @@ ERRORCODE CVidTheoraPlayer::resetStream() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { +bool CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) @@ -451,7 +451,7 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::stop() { +bool CVidTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { @@ -466,7 +466,7 @@ ERRORCODE CVidTheoraPlayer::stop() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::update() { +bool CVidTheoraPlayer::update() { _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; if (!isPlaying()) return STATUS_OK; @@ -614,7 +614,7 @@ uint32 CVidTheoraPlayer::getMovieFrame() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::WriteVideo() { +bool CVidTheoraPlayer::WriteVideo() { if (!_texture) return STATUS_FAILED; _texture->startPixelOp(); @@ -651,9 +651,9 @@ void CVidTheoraPlayer::writeAlpha() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { +bool CVidTheoraPlayer::display(uint32 alpha) { Rect32 rc; - ERRORCODE res; + bool res; if (_texture && _videoFrameReady) { CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); @@ -667,7 +667,7 @@ ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { +bool CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; @@ -716,7 +716,7 @@ inline int intlog(int num) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::SeekToTime(uint32 time) { +bool CVidTheoraPlayer::SeekToTime(uint32 time) { warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); #if 0 if (!m_TheoraStreams) return STATUS_FAILED; @@ -780,7 +780,7 @@ finish: } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::pause() { +bool CVidTheoraPlayer::pause() { if (_state == THEORA_STATE_PLAYING) { _state = THEORA_STATE_PAUSED; _theoraDecoder->pauseVideo(true); @@ -791,7 +791,7 @@ ERRORCODE CVidTheoraPlayer::pause() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::resume() { +bool CVidTheoraPlayer::resume() { if (_state == THEORA_STATE_PAUSED) { _state = THEORA_STATE_PLAYING; _theoraDecoder->pauseVideo(false); @@ -802,7 +802,7 @@ ERRORCODE CVidTheoraPlayer::resume() { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { +bool CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { //CBBase::persist(persistMgr); if (persistMgr->_saving) { @@ -832,7 +832,7 @@ ERRORCODE CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -ERRORCODE CVidTheoraPlayer::initializeSimple() { +bool CVidTheoraPlayer::initializeSimple() { if (DID_SUCCEED(initialize(_filename))) { if (_alphaFilename != "") setAlphaImage(_alphaFilename); play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 6061ad3199..74fc0ce5b4 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -63,16 +63,16 @@ public: //CVidSubtitler *_subtitler; // control methods - ERRORCODE initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); - ERRORCODE initializeSimple(); - ERRORCODE update(); - ERRORCODE play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); - ERRORCODE stop(); - ERRORCODE display(uint32 alpha = 0xFFFFFFFF); - //ERRORCODE RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + bool initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); + bool initializeSimple(); + bool update(); + bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); + bool stop(); + bool display(uint32 alpha = 0xFFFFFFFF); + //bool RenderFrame(CBSurface *Texture, yuv_buffer *yuv); - ERRORCODE pause(); - ERRORCODE resume(); + bool pause(); + bool resume(); bool isPlaying() { return _state == THEORA_STATE_PLAYING; @@ -99,15 +99,15 @@ public: // alpha related CBImage *_alphaImage; Common::String _alphaFilename; - ERRORCODE setAlphaImage(const Common::String &filename); + bool setAlphaImage(const Common::String &filename); __inline byte getAlphaAt(int x, int y); void writeAlpha(); - ERRORCODE SeekToTime(uint32 Time); + bool SeekToTime(uint32 Time); void cleanup(); - ERRORCODE resetStream(); + bool resetStream(); // video properties TVideoPlayback _playbackType; @@ -137,7 +137,7 @@ private: bool _videoFrameReady; float _videobufTime; - ERRORCODE WriteVideo(); + bool WriteVideo(); bool _playbackStarted; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 60abe21cc6..ce66e197b3 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -205,7 +205,7 @@ int WinterMuteEngine::init() { - ERRORCODE ret; + bool ret; // initialize the renderer ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 678fb6bb6b..04a657c644 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -41,10 +41,8 @@ namespace WinterMute { #define RGBCOLGetR(rgb) ((byte )((rgb)>>16)) #define RGBCOLGetA(rgb) ((byte )((rgb)>>24)) -typedef bool ERRORCODE; - -#define DID_SUCCEED(hr) ((ERRORCODE)(hr)) -#define DID_FAIL(hr) (!((ERRORCODE)(hr))) +#define DID_SUCCEED(hr) ((bool)(hr)) +#define DID_FAIL(hr) (!((bool)(hr))) #define STATUS_OK (true) #define STATUS_FAILED (false) -- cgit v1.2.3 From 018d8a068f0afe108f8332f40b7b5d49d61ed0c3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 18:34:45 +0200 Subject: WINTERMUTE: Rename the variables in BGame::LastClickInfo --- engines/wintermute/Base/BGame.cpp | 14 +++++++------- engines/wintermute/Base/BGame.h | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 02af945d8c..6e70bb6540 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -4435,17 +4435,17 @@ bool CBGame::isDoubleClick(int buttonIndex) { Point32 pos; CBPlatform::getCursorPos(&pos); - int moveX = abs(pos.x - _lastClick[buttonIndex].PosX); - int moveY = abs(pos.y - _lastClick[buttonIndex].PosY); + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - if (_lastClick[buttonIndex].Time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].Time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].Time = CBPlatform::getTime(); - _lastClick[buttonIndex].PosX = pos.x; - _lastClick[buttonIndex].PosY = pos.y; + if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = CBPlatform::getTime(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; return false; } else { - _lastClick[buttonIndex].Time = 0; + _lastClick[buttonIndex].time = 0; return true; } } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index bb8cdce402..09251aedf1 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -358,13 +358,13 @@ private: struct LastClickInfo { LastClickInfo() { - PosX = PosY = 0; - Time = 0; + posX = posY = 0; + time = 0; } - int PosX; - int PosY; - uint32 Time; + int posX; + int posY; + uint32 time; }; LastClickInfo _lastClick[2]; -- cgit v1.2.3 From b42dae6a30db145fd0254e2badbfcd1a445521f6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 18:41:58 +0200 Subject: WINTERMUTE: Remove some useless spaces. --- engines/wintermute/Base/BRenderSDL.h | 2 +- engines/wintermute/Base/BRenderer.cpp | 2 +- engines/wintermute/Base/BRenderer.h | 2 +- engines/wintermute/Base/font/BFontBitmap.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h index 0192849afa..7b5878a496 100644 --- a/engines/wintermute/Base/BRenderSDL.h +++ b/engines/wintermute/Base/BRenderSDL.h @@ -65,7 +65,7 @@ public: bool initRenderer(int width, int height, bool windowed); bool flip(); - bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); bool fade(uint16 alpha); bool fadeToColor(uint32 color, Common::Rect *rect = NULL); diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp index 49eb8db69a..15ec101c1f 100644 --- a/engines/wintermute/Base/BRenderer.cpp +++ b/engines/wintermute/Base/BRenderer.cpp @@ -137,7 +137,7 @@ void CBRenderer::onWindowChange() { ////////////////////////////////////////////////////////////////////// -bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_FAILED; } diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h index ddf2a3a808..4cc7e64fc1 100644 --- a/engines/wintermute/Base/BRenderer.h +++ b/engines/wintermute/Base/BRenderer.h @@ -63,7 +63,7 @@ public: }; virtual bool windowedBlt(); - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); virtual void onWindowChange(); virtual bool initRenderer(int width, int height, bool windowed); virtual bool flip(); diff --git a/engines/wintermute/Base/font/BFontBitmap.h b/engines/wintermute/Base/font/BFontBitmap.h index 94569e4dc7..4806d61291 100644 --- a/engines/wintermute/Base/font/BFontBitmap.h +++ b/engines/wintermute/Base/font/BFontBitmap.h @@ -61,7 +61,7 @@ public: private: int getCharWidth(byte index); - void drawChar(byte c, int x, int y); + void drawChar(byte c, int x, int y); int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); -- cgit v1.2.3 From 28794036edb5a1441ff9ba88a455205859416b43 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 19:25:27 +0200 Subject: WINTERMUTE: Make savegames use targetName as prefix. --- engines/wintermute/Base/BGame.cpp | 5 ++++- engines/wintermute/Base/BGame.h | 4 +++- engines/wintermute/Base/BPersistMgr.cpp | 18 +++++++++++++----- engines/wintermute/Base/BPersistMgr.h | 5 +++-- engines/wintermute/detection.cpp | 9 ++++----- engines/wintermute/wintermute.cpp | 2 ++ engines/wintermute/wintermute.h | 1 + 7 files changed, 30 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6e70bb6540..32242a5313 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3814,7 +3814,10 @@ void CBGame::setWindowTitle() { bool CBGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - sprintf(buffer, "save%03d.%s", slot, _savedGameExt); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + strcpy(buffer, filename.c_str()); warning("Saving %s - we really should prefix these things to avoid collisions.", buffer); return STATUS_OK; } diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 09251aedf1..4bf053dac8 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -233,8 +233,10 @@ private: uint32 _lastTime; uint32 _fpsTime; uint32 _framesRendered; - + Common::String _gameId; public: + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } uint32 _surfaceGCCycleTime; bool _smartCache; bool _videoSubtitles; diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 700b63479a..46c2048ac7 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -51,7 +51,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { +CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { _saving = false; // _buffer = NULL; // _bufferSize = 0; @@ -69,6 +69,13 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { _thumbnailDataSize = 0; _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } } @@ -111,9 +118,9 @@ void CBPersistMgr::cleanup() { _saveStream = NULL; } -Common::String CBPersistMgr::getFilenameForSlot(int slot) { - // TODO: Temporary solution until I have the namespacing sorted out - return Common::String::format("save%03d.DirtySplitSav", slot); +Common::String CBPersistMgr::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); } void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { @@ -149,7 +156,8 @@ void CBPersistMgr::deleteSaveSlot(int slot) { } uint32 CBPersistMgr::getMaxUsedSlot() { - Common::StringArray saves = g_system->getSavefileManager()->listSavefiles("save???.DirtySplitSav"); + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); Common::StringArray::iterator it = saves.begin(); int ret = -1; for (; it != saves.end(); it++) { diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index ee834c005e..656cdf975a 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -52,6 +52,7 @@ public: byte _savedVerBuild; byte _savedExtMajor; byte _savedExtMinor; + Common::String _savePrefix; Common::String _savedName; bool saveFile(const char *filename); uint32 getDWORD(); @@ -93,14 +94,14 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL); + CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); virtual ~CBPersistMgr(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); uint32 _thumbnailDataSize; byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; private: - Common::String getFilenameForSlot(int slot); bool readHeader(const Common::String &filename); TimeDate getTimeDate(); bool putTimeDate(const TimeDate &t); diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index ef28fedd2b..0112bce137 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -304,7 +304,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -316,17 +316,16 @@ public: } int getMaximumSaveSlot() const { - WinterMute::CBPersistMgr pm; - return pm.getMaxUsedSlot() + 1; // TODO: Since we use slot 0, this misses a bit. + return 100; } void removeSaveState(const char *target, int slot) const { - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index ce66e197b3..835aa74e88 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -188,6 +188,8 @@ int WinterMuteEngine::init() { // load general game settings _game->initialize1(); + // set gameId, for savegame-naming: + _game->setGameId(_targetName); if (DID_FAIL(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index bfa4c73125..189f879eea 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -70,6 +70,7 @@ public: virtual ~Console(void) {} }; +// Mainly used for randInt() extern WinterMuteEngine *g_wintermute; } // End of namespace Wintermute -- cgit v1.2.3 From b02711c4cb8e1bc82856b1d75a7752381ae7cfba Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 19:30:24 +0200 Subject: WINTERMUTE: Use saveFileMan for removing saveFiles. --- engines/wintermute/Base/BGame.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 32242a5313..054029ae35 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3871,9 +3871,9 @@ bool CBGame::isSaveSlotUsed(int slot) { bool CBGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - - CBPlatform::deleteFile(filename); - + CBPersistMgr *pm = new CBPersistMgr(this); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; return STATUS_OK; } -- cgit v1.2.3 From c61ffeac7676567d0da147c778a0007202f155dd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 19:38:19 +0200 Subject: WINTERMUTE: Move a few noisy warnings over to debug-channels. --- engines/wintermute/Base/BFileManager.cpp | 5 ++--- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/font/BFontTT.cpp | 6 ++++-- engines/wintermute/wintermute.cpp | 3 ++- engines/wintermute/wintermute.h | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 7dd7d6f0e8..00b44646f4 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -322,7 +322,7 @@ bool CBFileManager::registerPackages() { restoreCurrentDir(); _gameRef->LOG(0, "Scanning packages..."); - warning("Scanning packages"); + debugC(kWinterMuteDebugFileAccess, "Scanning packages"); Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.dcp"); @@ -358,10 +358,9 @@ bool CBFileManager::registerPackages() { } } #endif - warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); - warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize()); return STATUS_OK; } diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 054029ae35..f5b234a013 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3818,7 +3818,7 @@ bool CBGame::getSaveSlotFilename(int slot, char *buffer) { Common::String filename = pm->getFilenameForSlot(slot); delete pm; strcpy(buffer, filename.c_str()); - warning("Saving %s - we really should prefix these things to avoid collisions.", buffer); + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); return STATUS_OK; } diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index e4bd7cc719..4517f580b2 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -39,6 +39,7 @@ #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" #include @@ -195,7 +196,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // not found, create one if (!surface) { - warning("Draw text: %s", text); + debugC(kWinterMuteDebugFont, "Draw text: %s", text); surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); if (surface) { // write surface to cache @@ -257,7 +258,8 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex hasWarned = true; warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); } - warning("%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); + + debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); if (_deletableFont) // We actually have a TTF diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 835aa74e88..528c379aa9 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -58,7 +58,8 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) // Here is the right place to set up the engine specific debug channels DebugMan.addDebugChannel(kWinterMuteDebugLog, "enginelog", "Covers the same output as the log-file in WME"); DebugMan.addDebugChannel(kWinterMuteDebugSaveGame, "savegame", "Savegames"); - + DebugMan.addDebugChannel(kWinterMuteDebugFont, "font", "Text-drawing-related messages"); + DebugMan.addDebugChannel(kWinterMuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 189f879eea..bf716a5a1f 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -36,9 +36,9 @@ class CSysClassRegistry; // our engine debug channels enum { kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine - kWinterMuteDebugSaveGame = 1 << 1 - // next new channel must be 1 << 2 (4) - // the current limitation is 32 debug channels (1 << 31 is the last one) + kWinterMuteDebugSaveGame = 1 << 1, + kWinterMuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) + kWinterMuteDebugFileAccess = 1 << 3 // the current limitation is 32 debug channels (1 << 31 is the last one) }; class WinterMuteEngine : public Engine { -- cgit v1.2.3 From 49bac1ab4acaa3c6c61be32e3999073b50f21d0a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 17:06:45 +0200 Subject: WINTERMUTE: Use correct case for Rect32.h includes. --- engines/wintermute/Ad/AdSentence.h | 2 +- engines/wintermute/Base/BActiveRect.h | 2 +- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BPersistMgr.h | 2 +- engines/wintermute/Base/BSurface.h | 2 +- engines/wintermute/Base/particles/PartParticle.h | 2 +- engines/wintermute/PlatformSDL.h | 2 +- engines/wintermute/utils/utils.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h index 22a6cae39d..71b60c2d0d 100644 --- a/engines/wintermute/Ad/AdSentence.h +++ b/engines/wintermute/Ad/AdSentence.h @@ -32,7 +32,7 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/persistent.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "engines/wintermute/dctypes.h" // Added by ClassView #include "common/rect.h" diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h index abb00c301f..d32b5bc368 100644 --- a/engines/wintermute/Base/BActiveRect.h +++ b/engines/wintermute/Base/BActiveRect.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BACTIVERECT_H #define WINTERMUTE_BACTIVERECT_H -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "engines/wintermute/Base/BBase.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 4bf053dac8..44b820ade7 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -34,7 +34,7 @@ #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "common/events.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index 656cdf975a..3a2aa82c94 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "engines/savestate.h" #include "common/stream.h" #include "common/str.h" diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h index c31ad5643f..ed9ace5322 100644 --- a/engines/wintermute/Base/BSurface.h +++ b/engines/wintermute/Base/BSurface.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BSURFACE_H #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "graphics/surface.h" namespace WinterMute { diff --git a/engines/wintermute/Base/particles/PartParticle.h b/engines/wintermute/Base/particles/PartParticle.h index c8ad1181d7..02913e3d35 100644 --- a/engines/wintermute/Base/particles/PartParticle.h +++ b/engines/wintermute/Base/particles/PartParticle.h @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "engines/wintermute/math/Vector2.h" namespace WinterMute { diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 155c4e0f06..e0314898bf 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -30,7 +30,7 @@ #define WINTERMUTE_PLATFORMSDL_H #include "engines/wintermute/dctypes.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" #include "engines/wintermute/wintypes.h" #include "common/events.h" diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index d75bb8c550..14b8f4aa96 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -30,7 +30,7 @@ #define WINTERMUTE_UTILS_H #include "engines/wintermute/wintypes.h" -#include "engines/wintermute/Math/Rect32.h" +#include "engines/wintermute/math/Rect32.h" namespace WinterMute { -- cgit v1.2.3 From 9c0aff9d8b85e2330fd26db391db15d4f61b01ce Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 17:18:56 +0200 Subject: WINTERMUTE: Remove SXStore from module.mk --- engines/wintermute/module.mk | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index a185f08e13..56c82b6846 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -37,7 +37,6 @@ MODULE_OBJS := \ Base/scriptables/SXMath.o \ Base/scriptables/SxObject.o \ Base/scriptables/SXMemBuffer.o \ - Base/scriptables/SXStore.o \ Base/scriptables/SXString.o \ Base/file/BDiskFile.o \ Base/file/BFile.o \ -- cgit v1.2.3 From 73feff111a98715e87f8e3d72232185650acdc7d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 18:11:23 +0200 Subject: WINTERMUTE: Correct 2 savegame-issues --- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Sys/SysClassRegistry.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 46c2048ac7..c7c3661032 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -404,9 +404,9 @@ Common::String CBPersistMgr::getStringObj() { char *ret = new char[len + 1]; _loadStream->read(ret, len); ret[len] = '\0'; - delete[] ret; Common::String retString = ret; + delete[] ret; if (retString == "(null)") { retString = ""; diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 66f3bed81f..0b173c3afb 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -38,6 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// CSysClassRegistry::CSysClassRegistry() { _count = 0; + _disabled = false; } -- cgit v1.2.3 From def3cd92570ac8138441cd0e7492d0b7bdc61f91 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 18:41:54 +0200 Subject: WINTERMUTE: Replace a few non-persistent CBArrays with Common::Array --- engines/wintermute/Base/BFileManager.cpp | 48 ++++++++++++++--------------- engines/wintermute/Base/BFileManager.h | 9 +++--- engines/wintermute/Base/BSoundMgr.cpp | 18 +++++------ engines/wintermute/Base/BSoundMgr.h | 3 +- engines/wintermute/Base/BSurfaceStorage.cpp | 18 +++++------ engines/wintermute/Base/BSurfaceStorage.h | 5 ++- engines/wintermute/Base/file/BDiskFile.cpp | 2 +- 7 files changed, 51 insertions(+), 52 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp index 00b44646f4..a0ba77482d 100644 --- a/engines/wintermute/Base/BFileManager.cpp +++ b/engines/wintermute/Base/BFileManager.cpp @@ -75,13 +75,13 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::cleanup() { // delete registered paths - for (int i = 0; i < _singlePaths.getSize(); i++) + for (int i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; - _singlePaths.removeAll(); + _singlePaths.clear(); - for (int i = 0; i < _packagePaths.getSize(); i++) + for (int i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; - _packagePaths.removeAll(); + _packagePaths.clear(); // delete file entries @@ -93,16 +93,16 @@ bool CBFileManager::cleanup() { _files.clear(); // close open files - for (int i = 0; i < _openFiles.getSize(); i++) { + for (int i = 0; i < _openFiles.size(); i++) { delete _openFiles[i]; } - _openFiles.removeAll(); + _openFiles.clear(); // delete packages - for (int i = 0; i < _packages.getSize(); i++) + for (int i = 0; i < _packages.size(); i++) delete _packages[i]; - _packages.removeAll(); + _packages.clear(); delete[] _basePath; _basePath = NULL; @@ -225,7 +225,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 ////////////////////////////////////////////////////////////////////////// bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages - for (int i = 0; i < _packages.getSize(); i++) { + for (int i = 0; i < _packages.size(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); } @@ -249,10 +249,10 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { switch (type) { case PATH_SINGLE: - _singlePaths.add(buffer); + _singlePaths.push_back(buffer); break; case PATH_PACKAGE: - _packagePaths.add(buffer); + _packagePaths.push_back(buffer); break; } @@ -262,13 +262,13 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::reloadPaths() { // delete registered paths - for (int i = 0; i < _singlePaths.getSize(); i++) + for (int i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; - _singlePaths.removeAll(); + _singlePaths.clear(); - for (int i = 0; i < _packagePaths.getSize(); i++) + for (int i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; - _packagePaths.removeAll(); + _packagePaths.clear(); return initPaths(); } @@ -358,8 +358,8 @@ bool CBFileManager::registerPackages() { } } #endif - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize()); + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } @@ -424,7 +424,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search pkg->_priority = hdr.Priority; if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.add(pkg); + _packages.push_back(pkg); // read file entries @@ -511,7 +511,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _packagePaths.getSize(); i++) { + for (int i = 0; i < _packagePaths.size(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { @@ -537,7 +537,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { Common::File *ret = NULL; char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _singlePaths.getSize(); i++) { + for (int i = 0; i < _singlePaths.size(); i++) { sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); ret->open(filename); if (ret->isOpen()) @@ -562,7 +562,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) Common::File f; bool found = false; - for (int i = 0; i < _singlePaths.getSize(); i++) { + for (int i = 0; i < _singlePaths.size(); i++) { sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); f.open(fullname); if (f.isOpen()) { @@ -625,17 +625,17 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena #endif*/ Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.add(file); + if (file && keepTrackOf) _openFiles.push_back(file); return file; } ////////////////////////////////////////////////////////////////////////// bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (int i = 0; i < _openFiles.getSize(); i++) { + for (int i = 0; i < _openFiles.size(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; - _openFiles.removeAt(i); + _openFiles.remove_at(i); return STATUS_OK; } } diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h index aebaa6f3fc..53e55402cc 100644 --- a/engines/wintermute/Base/BFileManager.h +++ b/engines/wintermute/Base/BFileManager.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BFileEntry.h" #include "common/archive.h" #include "common/str.h" @@ -68,10 +67,10 @@ public: byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); CBFileManager(CBGame *inGame = NULL); virtual ~CBFileManager(); - CBArray _singlePaths; - CBArray _packagePaths; - CBArray _packages; - CBArray _openFiles; + Common::Array _singlePaths; + Common::Array _packagePaths; + Common::Array _packages; + Common::Array _openFiles; Common::HashMap _files; private: diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp index 98a5e69d7b..d4100df7aa 100644 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ b/engines/wintermute/Base/BSoundMgr.cpp @@ -62,9 +62,9 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.getSize(); i++) + for (int i = 0; i < _sounds.size(); i++) delete _sounds[i]; - _sounds.removeAll(); + _sounds.clear(); #if 0 BASS_Free(); #endif @@ -141,7 +141,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp sound->updateVolume(); // register sound - _sounds.add(sound); + _sounds.push_back(sound); return sound; @@ -157,17 +157,17 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { sound->updateVolume(); // register sound - _sounds.add(sound); + _sounds.push_back(sound); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (int i = 0; i < _sounds.getSize(); i++) { + for (int i = 0; i < _sounds.size(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; - _sounds.removeAt(i); + _sounds.remove_at(i); return STATUS_OK; } } @@ -227,7 +227,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; - for (int i = 0; i < _sounds.getSize(); i++) { + for (int i = 0; i < _sounds.size(); i++) { _sounds[i]->updateVolume(); } return STATUS_OK; @@ -254,7 +254,7 @@ byte CBSoundMgr::getMasterVolume() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::pauseAll(bool includingMusic) { - for (int i = 0; i < _sounds.getSize(); i++) { + for (int i = 0; i < _sounds.size(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; @@ -268,7 +268,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::resumeAll() { - for (int i = 0; i < _sounds.getSize(); i++) { + for (int i = 0; i < _sounds.size(); i++) { if (_sounds[i]->_freezePaused) { _sounds[i]->resume(); _sounds[i]->_freezePaused = false; diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h index 13e3957fce..be5be87b59 100644 --- a/engines/wintermute/Base/BSoundMgr.h +++ b/engines/wintermute/Base/BSoundMgr.h @@ -32,6 +32,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" #include "audio/mixer.h" +#include "common/array.h" namespace WinterMute { class CBSoundBuffer; @@ -59,7 +60,7 @@ public: bool _soundAvailable; CBSoundMgr(CBGame *inGame); virtual ~CBSoundMgr(); - CBArray _sounds; + Common::Array _sounds; void saveSettings(); }; diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 34721c40f6..56b59f714a 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -52,11 +52,11 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::cleanup(bool warn) { - for (int i = 0; i < _surfaces.getSize(); i++) { + for (int i = 0; i < _surfaces.size(); i++) { if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } - _surfaces.removeAll(); + _surfaces.clear(); return STATUS_OK; } @@ -67,7 +67,7 @@ bool CBSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); - for (int i = 0; i < _surfaces.getSize(); i++) { + for (int i = 0; i < _surfaces.size(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { @@ -82,12 +82,12 @@ bool CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.getSize(); i++) { + for (int i = 0; i < _surfaces.size(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; if (_surfaces[i]->_referenceCount <= 0) { delete _surfaces[i]; - _surfaces.removeAt(i); + _surfaces.remove_at(i); } break; } @@ -98,7 +98,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (int i = 0; i < _surfaces.getSize(); i++) { + for (int i = 0; i < _surfaces.size(); i++) { if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; @@ -123,7 +123,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by return NULL; } else { surface->_referenceCount = 1; - _surfaces.add(surface); + _surfaces.push_back(surface); return surface; } } @@ -132,7 +132,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::restoreAll() { bool ret; - for (int i = 0; i < _surfaces.getSize(); i++) { + for (int i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); @@ -161,7 +161,7 @@ bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::sortSurfaces() { - qsort(_surfaces.getData(), _surfaces.getSize(), sizeof(CBSurface *), surfaceSortCB); + qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); return STATUS_OK; } diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h index 1e8074dc99..00ca38a7a1 100644 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ b/engines/wintermute/Base/BSurfaceStorage.h @@ -29,9 +29,8 @@ #ifndef WINTERMUTE_BSURFACESTORAGE_H #define WINTERMUTE_BSURFACESTORAGE_H - -#include "engines/wintermute/coll_templ.h" #include "engines/wintermute/Base/BBase.h" +#include "common/array.h" namespace WinterMute { class CBSurface; @@ -50,7 +49,7 @@ public: CBSurfaceStorage(CBGame *inGame); virtual ~CBSurfaceStorage(); - CBArray _surfaces; + Common::Array _surfaces; }; } // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp index 4287458b8e..2a3386a005 100644 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ b/engines/wintermute/Base/file/BDiskFile.cpp @@ -50,7 +50,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileM uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (int i = 0; i < fileManager->_singlePaths.getSize(); i++) { + for (int i = 0; i < fileManager->_singlePaths.size(); i++) { sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); correctSlashes(fullPath); Common::File *tempFile = new Common::File(); -- cgit v1.2.3 From a3e8ad4c52f2ad484e94fc8b641e7c7b67b44c04 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 19:17:05 +0200 Subject: WINTERMUTE: Move all the gfx-related files to a subfolder, and rename SDL->OSystem --- engines/wintermute/Base/BGame.cpp | 11 +- engines/wintermute/Base/BGame.h | 2 +- engines/wintermute/Base/BImage.cpp | 269 -------- engines/wintermute/Base/BImage.h | 74 --- engines/wintermute/Base/BPersistMgr.cpp | 2 +- engines/wintermute/Base/BRenderSDL.cpp | 701 --------------------- engines/wintermute/Base/BRenderSDL.h | 129 ---- engines/wintermute/Base/BRenderer.cpp | 257 -------- engines/wintermute/Base/BRenderer.h | 128 ---- engines/wintermute/Base/BSaveThumbHelper.cpp | 2 +- engines/wintermute/Base/BSprite.cpp | 2 +- engines/wintermute/Base/BSubFrame.cpp | 2 +- engines/wintermute/Base/BSurface.cpp | 152 ----- engines/wintermute/Base/BSurface.h | 99 --- engines/wintermute/Base/BSurfaceSDL.cpp | 532 ---------------- engines/wintermute/Base/BSurfaceSDL.h | 101 --- engines/wintermute/Base/BSurfaceStorage.cpp | 4 +- engines/wintermute/Base/font/BFontBitmap.cpp | 2 +- engines/wintermute/Base/font/BFontTT.cpp | 6 +- engines/wintermute/Base/font/BFontTT.h | 2 +- engines/wintermute/Base/gfx/base_image.cpp | 269 ++++++++ engines/wintermute/Base/gfx/base_image.h | 74 +++ engines/wintermute/Base/gfx/base_renderer.cpp | 257 ++++++++ engines/wintermute/Base/gfx/base_renderer.h | 128 ++++ engines/wintermute/Base/gfx/base_surface.cpp | 152 +++++ engines/wintermute/Base/gfx/base_surface.h | 99 +++ .../Base/gfx/osystem/base_render_osystem.cpp | 701 +++++++++++++++++++++ .../Base/gfx/osystem/base_render_osystem.h | 129 ++++ .../Base/gfx/osystem/base_surface_osystem.cpp | 532 ++++++++++++++++ .../Base/gfx/osystem/base_surface_osystem.h | 101 +++ engines/wintermute/PlatformSDL.cpp | 8 +- engines/wintermute/UI/UITiledImage.cpp | 2 +- engines/wintermute/module.mk | 10 +- engines/wintermute/video/VidTheoraPlayer.cpp | 5 +- engines/wintermute/video/VidTheoraPlayer.h | 6 +- 35 files changed, 2476 insertions(+), 2474 deletions(-) delete mode 100644 engines/wintermute/Base/BImage.cpp delete mode 100644 engines/wintermute/Base/BImage.h delete mode 100644 engines/wintermute/Base/BRenderSDL.cpp delete mode 100644 engines/wintermute/Base/BRenderSDL.h delete mode 100644 engines/wintermute/Base/BRenderer.cpp delete mode 100644 engines/wintermute/Base/BRenderer.h delete mode 100644 engines/wintermute/Base/BSurface.cpp delete mode 100644 engines/wintermute/Base/BSurface.h delete mode 100644 engines/wintermute/Base/BSurfaceSDL.cpp delete mode 100644 engines/wintermute/Base/BSurfaceSDL.h create mode 100644 engines/wintermute/Base/gfx/base_image.cpp create mode 100644 engines/wintermute/Base/gfx/base_image.h create mode 100644 engines/wintermute/Base/gfx/base_renderer.cpp create mode 100644 engines/wintermute/Base/gfx/base_renderer.h create mode 100644 engines/wintermute/Base/gfx/base_surface.cpp create mode 100644 engines/wintermute/Base/gfx/base_surface.h create mode 100644 engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp create mode 100644 engines/wintermute/Base/gfx/osystem/base_render_osystem.h create mode 100644 engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp create mode 100644 engines/wintermute/Base/gfx/osystem/base_surface_osystem.h (limited to 'engines') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index f5b234a013..d4f97cfdba 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -32,17 +32,18 @@ #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/Base/font/BFont.h" #include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/gfx/base_image.h" +#include "engines/wintermute/Base/gfx/base_surface.h" +#include "engines/wintermute/Base/gfx/base_renderer.h" #include "engines/wintermute/Base/BKeyboardState.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BQuickMsg.h" #include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BRenderer.h" #include "engines/wintermute/Base/BSound.h" #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/Base/BSprite.h" #include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BSurface.h" + #include "engines/wintermute/Base/BTransitionMgr.h" #include "engines/wintermute/Base/BViewport.h" #include "engines/wintermute/Base/BStringTable.h" @@ -484,7 +485,7 @@ bool CBGame::initialize1() { ////////////////////////////////////////////////////////////////////// bool CBGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeSDLRenderer(this); + _renderer = makeOSystemRenderer(this); if (_renderer == NULL) return STATUS_FAILED; return STATUS_OK; @@ -3801,7 +3802,7 @@ void CBGame::setWindowTitle() { title = StringUtil::WideToUtf8(wstr);*/ } #if 0 - CBRenderSDL *renderer = static_cast(_renderer); + CBRenderOSystem *renderer = static_cast(_renderer); // TODO SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 44b820ade7..1a0e4efb09 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BGAME_H #include "engines/wintermute/Base/BDebugger.h" -#include "engines/wintermute/Base/BRenderer.h" +#include "engines/wintermute/Base/gfx/base_renderer.h" #include "engines/wintermute/Base/BObject.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp deleted file mode 100644 index 41a1eff753..0000000000 --- a/engines/wintermute/Base/BImage.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BImage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/jpeg.h" -#include "graphics/decoders/bmp.h" -#include "graphics/surface.h" -#include "engines/wintermute/graphics/tga.h" -#include "common/textconsole.h" -#include "common/stream.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { -#if 0 - _bitmap = bitmap; -#endif - _bitmap = NULL; - _palette = NULL; - _surface = NULL; - _decoder = NULL; - _deletableSurface = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBImage::~CBImage() { - /* delete _bitmap; */ - delete _decoder; - if (_deletableSurface) { - _deletableSurface->free(); - } - delete _deletableSurface; -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); -#endif -} - -bool CBImage::loadFile(const Common::String &filename) { - _filename = filename; - _filename.toLowercase(); - if (StringUtil::startsWith(filename, "savegame:", true)) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".png")) { - _decoder = new Graphics::PNGDecoder(); - } else if (_filename.hasSuffix(".bmp")) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".tga")) { - _decoder = new WinterMute::TGA(); - } else if (_filename.hasSuffix(".jpg")) { - _decoder = new Graphics::JPEGDecoder(); - } else { - error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); - } - _filename = filename; - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); - if (!file) return STATUS_FAILED; - - _decoder->loadStream(*file); - _surface = _decoder->getSurface(); - _palette = _decoder->getPalette(); - _gameRef->_fileManager->closeFile(file); - - return STATUS_OK; -} - -byte CBImage::getAlphaAt(int x, int y) { - if (!_surface) return 0xFF; - uint32 color = *(uint32 *)_surface->getBasePtr(x, y); - byte r, g, b, a; - _surface->format.colorToARGB(color, a, r, g, b); - return a; -} - -void CBImage::copyFrom(Graphics::Surface *surface) { - _surface = _deletableSurface = new Graphics::Surface(); - _deletableSurface->copyFrom(*surface); -} - -////////////////////////////////////////////////////////////////////////// -bool CBImage::saveBMPFile(const char *filename) { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; - else return STATUS_FAILED; -#endif - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::resize(int newWidth, int newHeight) { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); - - - FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); - if (newImg) { - FreeImage_Unload(_bitmap); - _bitmap = newImg; - return STATUS_OK; - } else return STATUS_FAILED; -#endif - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::writeBMPToStream(Common::WriteStream *stream) { - if (!_surface) return false; - - /* The following is just copied over and inverted to write-ops from the BMP-decoder */ - stream->writeByte('B'); - stream->writeByte('M'); - - /* Since we don't care during reads, we don't care during writes: */ - /* uint32 fileSize = */ - stream->writeUint32LE(54 + _surface->h * _surface->pitch); - /* uint16 res1 = */ - stream->writeUint16LE(0); - /* uint16 res2 = */ - stream->writeUint16LE(0); - const uint32 imageOffset = 54; - stream->writeUint32LE(imageOffset); - - const uint32 infoSize = 40; /* Windows v3 BMP */ - stream->writeUint32LE(infoSize); - - uint32 width = _surface->w; - int32 height = _surface->h; - stream->writeUint32LE(width); - stream->writeUint32LE((uint32)height); - - if (width == 0 || height == 0) - return false; - - if (height < 0) { - warning("Right-side up bitmaps not supported"); - return false; - } - - /* uint16 planes = */ stream->writeUint16LE(1); - const uint16 bitsPerPixel = 24; - stream->writeUint16LE(bitsPerPixel); - - const uint32 compression = 0; - stream->writeUint32LE(compression); - - /* uint32 imageSize = */ - stream->writeUint32LE(_surface->h * _surface->pitch); - /* uint32 pixelsPerMeterX = */ - stream->writeUint32LE(0); - /* uint32 pixelsPerMeterY = */ - stream->writeUint32LE(0); - const uint32 paletteColorCount = 0; - stream->writeUint32LE(paletteColorCount); - /* uint32 colorsImportant = */ - stream->writeUint32LE(0); - - // Start us at the beginning of the image (54 bytes in) - Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); - - // BGRA for 24bpp - if (bitsPerPixel == 24) - format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); - - Graphics::Surface *surface = _surface->convertTo(format); - - int srcPitch = width * (bitsPerPixel >> 3); - const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; - - for (int32 i = height - 1; i >= 0; i--) { - for (uint32 j = 0; j < width; j++) { - byte b, g, r; - uint32 color = *(uint32 *)surface->getBasePtr(j, i); - surface->format.colorToRGB(color, r, g, b); - stream->writeByte(b); - stream->writeByte(g); - stream->writeByte(r); - } - - for (int k = 0; k < extraDataLength; k++) { - stream->writeByte(0); - } - } - surface->free(); - delete surface; - return true; - - //*BufferSize = 0; -#if 0 - FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); - uint32 size; - byte *data; - FreeImage_AcquireMemory(fiMem, &data, &size); - - - byte *Buffer = new byte[size]; - memcpy(Buffer, data, size); - - FreeImage_CloseMemory(fiMem); - - if (BufferSize) *BufferSize = size; - - return Buffer; -#endif - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); - - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - - _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); -#endif - TransparentSurface temp(*origImage->_surface, false); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale(newWidth, newHeight); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BImage.h b/engines/wintermute/Base/BImage.h deleted file mode 100644 index 29455d3f7a..0000000000 --- a/engines/wintermute/Base/BImage.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BIMAGE_H -#define WINTERMUTE_BIMAGE_H - -#include "engines/wintermute/Base/BBase.h" -#include "graphics/surface.h" -#include "graphics/pixelformat.h" -#include "graphics/decoders/image_decoder.h" -#include "common/endian.h" -#include "common/str.h" -#include "common/stream.h" - -struct FIBITMAP; - -namespace WinterMute { -class CBSurface; -class CBImage: CBBase { - -public: - CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); - ~CBImage(); - - bool loadFile(const Common::String &filename); - const Graphics::Surface *getSurface() const { - return _surface; - }; - const byte *getPalette() const { - return _palette; - } - byte getAlphaAt(int x, int y); - bool writeBMPToStream(Common::WriteStream *stream); - bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename); - bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(Graphics::Surface *surface); -private: - Common::String _filename; - Graphics::ImageDecoder *_decoder; - FIBITMAP *_bitmap; - const Graphics::Surface *_surface; - Graphics::Surface *_deletableSurface; - const byte *_palette; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index c7c3661032..635097c0ad 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/math/Vector2.h" #include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/gfx/base_image.h" #include "engines/wintermute/Base/BSound.h" #include "graphics/decoders/bmp.h" #include "common/memstream.h" diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp deleted file mode 100644 index 68c04d9d46..0000000000 --- a/engines/wintermute/Base/BRenderSDL.cpp +++ /dev/null @@ -1,701 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BRenderSDL.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BImage.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "common/system.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "common/queue.h" - -namespace WinterMute { - -RenderTicket::RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { - _colorMod = 0; - _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - _mirror |= TransparentSurface::FLIP_H; - if (surf) { - _surface = new Graphics::Surface(); - _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); - assert(_surface->format.bytesPerPixel == 4); - // Get a clipped copy of the surface - for (int i = 0; i < _surface->h; i++) { - memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); - } - // Then scale it if necessary - if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { - TransparentSurface src(*_surface, false); - Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); - _surface->free(); - delete _surface; - _surface = temp; - } - } else { - _surface = NULL; - } -} - -RenderTicket::~RenderTicket() { - if (_surface) { - _surface->free(); - delete _surface; - } -} - -bool RenderTicket::operator==(RenderTicket &t) { - if ((t._srcRect != _srcRect) || - (t._dstRect != _dstRect) || - (t._mirror != _mirror) || - (t._owner != _owner) || - (t._hasAlpha != _hasAlpha) || - (t._colorMod != _colorMod)) { - return false; - } - return true; -} - -CBRenderer *makeSDLRenderer(CBGame *inGame) { - return new CBRenderSDL(inGame); -} - -// TODO: Redo everything here. - -////////////////////////////////////////////////////////////////////////// -CBRenderSDL::CBRenderSDL(CBGame *inGame) : CBRenderer(inGame) { - _renderSurface = new Graphics::Surface(); - _drawNum = 1; - _needsFlip = true; - - _borderLeft = _borderRight = _borderTop = _borderBottom = 0; - _ratioX = _ratioY = 1.0f; - setAlphaMod(255); - setColorMod(255, 255, 255); - _dirtyRect = NULL; - _disableDirtyRects = true; -} - -////////////////////////////////////////////////////////////////////////// -CBRenderSDL::~CBRenderSDL() { - _renderSurface->free(); - delete _renderSurface; -#if 0 - if (_renderer) SDL_DestroyRenderer(_renderer); - if (_win) SDL_DestroyWindow(_win); - SDL_Quit(); -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::initRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; - -#if 0 - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); -#endif - _width = width; - _height = height; - _renderRect.setWidth(_width); - _renderRect.setHeight(_height); - - _realWidth = width; - _realHeight = height; - - - // find suitable resolution -/*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } -#else*/ - _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); - _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); -//#endif - - /* - _realWidth = 480; - _realHeight = 320; - */ - - - float origAspect = (float)_width / (float)_height; - float realAspect = (float)_realWidth / (float)_realHeight; - - float ratio; - if (origAspect < realAspect) { - // normal to wide - ratio = (float)_realHeight / (float)_height; - } else { - // wide to normal - ratio = (float)_realWidth / (float)_width; - } - - _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); - _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); - - _borderTop = (int)((_realHeight - (_height * ratio)) / 2); - _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); - - - - _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; - _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - -#if 0 - Uint32 flags = SDL_WINDOW_SHOWN; -#endif -#ifdef __IPHONEOS__ - //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; -#endif - - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); -// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; - - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - g_system->beginGFXTransaction(); - g_system->initSize(_width, _height, &format); - OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - - if (gfxError != OSystem::kTransactionSuccess) { - warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return STATUS_FAILED; - } -#if 0 - _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); - - if (!_win) return STATUS_FAILED; -#endif - - g_system->showMouse(false); - -#ifdef __IPHONEOS__ - // SDL defaults to OGL ES2, which doesn't work on old devices - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); -#else - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif -#if 0 - _renderer = SDL_CreateRenderer(_win, -1, 0); - - if (!_renderer) return STATUS_FAILED; -#endif - _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _active = true; - - _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); - - return STATUS_OK; -} - -void CBRenderSDL::setAlphaMod(byte alpha) { - byte r = RGBCOLGetR(_colorMod); - byte g = RGBCOLGetB(_colorMod); - byte b = RGBCOLGetB(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -void CBRenderSDL::setColorMod(byte r, byte g, byte b) { - byte alpha = RGBCOLGetA(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::flip() { - if (!_disableDirtyRects) { - drawTickets(); - } - if (_needsFlip || _disableDirtyRects) { - if (_disableDirtyRects) { - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); - } - // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - delete _dirtyRect; - _dirtyRect = NULL; - g_system->updateScreen(); - _needsFlip = false; - } - _drawNum = 1; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::fill(byte r, byte g, byte b, Common::Rect *rect) { - //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); - //SDL_RenderClear(_renderer); - _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) - return STATUS_OK; - if (!rect) { - rect = &_renderRect; - } - _renderSurface->fillRect(*rect, _clearColor); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::fade(uint16 Alpha) { - uint32 dwAlpha = 255 - Alpha; - return fadeToColor(dwAlpha << 24); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBRenderSDL::FadeToColor - Breaks when using dirty rects"); - warning("Implement CBRenderSDL::FadeToColor"); // TODO. - hasWarned = true; - } - - Common::Rect fillRect; - - if (rect) { - fillRect.left = rect->left; - fillRect.top = rect->top; - fillRect.setWidth(rect->width()); - fillRect.setHeight(rect->height()); - } else { - Rect32 rc; - _gameRef->getCurrentViewportRect(&rc); - fillRect.left = (int16)rc.left; - fillRect.top = (int16)rc.top; - fillRect.setWidth((int16)(rc.right - rc.left)); - fillRect.setHeight((int16)(rc.bottom - rc.top)); - } - modTargetRect(&fillRect); - - byte r = RGBCOLGetR(Color); - byte g = RGBCOLGetG(Color); - byte b = RGBCOLGetB(Color); - byte a = RGBCOLGetA(Color); - - //TODO: This is only here until I'm sure about the final pixelformat - uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) - _renderSurface->fillRect(fillRect, col); - else { - setAlphaMod(a); - setColorMod(r, g, b); - Graphics::Surface surf; - surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); - Common::Rect sizeRect(fillRect); - sizeRect.translate(-fillRect.top, -fillRect.left); - surf.fillRect(fillRect, col); - drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); - surf.free(); - _clearColor = col; - } - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - //SDL_RenderFillRect(_renderer, &fillRect); - - return STATUS_OK; -} - -void CBRenderSDL::drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { - if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); - // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); - return; - } - // Skip rects that are completely outside the screen: - if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { - return; - } - - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - drawFromTicket(*it); - return; - } - } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); - ticket->_colorMod = _colorMod; - drawFromTicket(ticket); -} - -void CBRenderSDL::invalidateTicket(RenderTicket *renderTicket) { - addDirtyRect(renderTicket->_dstRect); - renderTicket->_isValid = false; -// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. -} - -void CBRenderSDL::invalidateTicketsFromSurface(CBSurfaceSDL *surf) { - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == surf) { - invalidateTicket(*it); - } - } -} - -void CBRenderSDL::drawFromTicket(RenderTicket *renderTicket) { - renderTicket->_wantsDraw = true; - // A new item always has _drawNum == 0 - if (renderTicket->_drawNum == 0) { - // In-order - if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { - renderTicket->_drawNum = _drawNum++; - _renderQueue.push_back(renderTicket); - addDirtyRect(renderTicket->_dstRect); - } else { - // Before something - Common::List::iterator pos; - for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { - if ((*pos)->_drawNum >= _drawNum) { - break; - } - } - _renderQueue.insert(pos, renderTicket); - Common::List::iterator it; - renderTicket->_drawNum = _drawNum++; - // Increment the following tickets, so they still are in line - for (it = pos; it != _renderQueue.end(); it++) { - (*it)->_drawNum++; - (*it)->_wantsDraw = false; - } - addDirtyRect(renderTicket->_dstRect); - } - } else { - // Was drawn last round, still in the same order - if (_drawNum == renderTicket->_drawNum) { - _drawNum++; - } else { - // Remove the ticket from the list - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it) == renderTicket) { - it = _renderQueue.erase(it); - break; - } else { - it++; - } - } - // Is not in order, so readd it as if it was a new ticket - renderTicket->_drawNum = 0; - drawFromTicket(renderTicket); - } - } -} - -void CBRenderSDL::addDirtyRect(const Common::Rect &rect) { - if (!_dirtyRect) { - _dirtyRect = new Common::Rect(rect); - } else { - _dirtyRect->extend(rect); - } - _dirtyRect->clip(_renderRect); -// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); -} - -void CBRenderSDL::drawTickets() { - RenderQueueIterator it = _renderQueue.begin(); - // Clean out the old tickets - int decrement = 0; - while (it != _renderQueue.end()) { - if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { - RenderTicket* ticket = *it; - addDirtyRect((*it)->_dstRect); - //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); - it = _renderQueue.erase(it); - delete ticket; - decrement++; - } else { - (*it)->_drawNum -= decrement; - it++; - } - } - if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) - return; - // The color-mods are stored in the RenderTickets on add, since we set that state again during - // draw, we need to keep track of what it was prior to draw. - uint32 oldColorMod = _colorMod; -// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); - - // Apply the clear-color to the dirty rect. - _renderSurface->fillRect(*_dirtyRect, _clearColor); - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - RenderTicket *ticket = *it; - if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { - // dstClip is the area we want redrawn. - Common::Rect dstClip(ticket->_dstRect); - // reduce it to the dirty rect - dstClip.clip(*_dirtyRect); - // we need to keep track of the position to redraw the dirty rect - Common::Rect pos(dstClip); - int16 offsetX = ticket->_dstRect.left; - int16 offsetY = ticket->_dstRect.top; - // convert from screen-coords to surface-coords. - dstClip.translate(-offsetX, -offsetY); - - _colorMod = ticket->_colorMod; - drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); - _needsFlip = true; - } - // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) - ticket->_wantsDraw = false; - } - g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - - // Revert the colorMod-state. - _colorMod = oldColorMod; -} - -// Replacement for SDL2's SDL_RenderCopy -void CBRenderSDL::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { - TransparentSurface src(*surf, false); - bool doDelete = false; - if (!clipRect) { - doDelete = true; - clipRect = new Common::Rect(); - clipRect->setWidth(surf->w); - clipRect->setHeight(surf->h); - } - - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) - delete clipRect; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - static bool hasWarned = false; - if (!hasWarned) { - warning("CBRenderSDL::DrawLine - not fully ported yet"); - hasWarned = true; - } - byte r = RGBCOLGetR(color); - byte g = RGBCOLGetG(color); - byte b = RGBCOLGetB(color); - byte a = RGBCOLGetA(color); - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - - Point32 point1, point2; - point1.x = x1; - point1.y = y1; - pointToScreen(&point1); - - point2.x = x2; - point2.y = y2; - pointToScreen(&point2); - - // TODO: This thing is mostly here until I'm sure about the final color-format. - uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); - _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); - //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderSDL::takeScreenshot() { -// TODO: Fix this - warning("CBRenderSDL::TakeScreenshot() - not ported yet"); - CBImage *screenshot = new CBImage(_gameRef); - screenshot->copyFrom(_renderSurface); - return screenshot; -#if 0 - SDL_Rect viewport; - - SDL_RenderGetViewport(_renderer, &viewport); - - SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) return NULL; - - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; - - FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - - int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; - memcpy(bits, src, bytespp * viewport.w); - } - - return new CBImage(_gameRef, dib); -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::switchFullscreen() { - /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); - else SDL_SetWindowFullscreen(_win, SDL_FALSE); - - _windowed = !_windowed; - */ - _gameRef->_registry->writeBool("Video", "Windowed", _windowed); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBRenderSDL::getName() { - if (_name.empty()) { -#if 0 - if (_renderer) { - SDL_RendererInfo info; - SDL_GetRendererInfo(_renderer, &info); - _name = AnsiString(info.name); - } -#endif - } - return _name.c_str(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderSDL::setViewport(int left, int top, int right, int bottom) { - Common::Rect rect; - // TODO: Hopefully this is the same logic that ScummVM uses. - rect.left = (int16)(left + _borderLeft); - rect.top = (int16)(top + _borderTop); - rect.right = (int16)((right - left) * _ratioX); - rect.bottom = (int16)((bottom - top) * _ratioY); - - // TODO fix this once viewports work correctly in SDL/landscape -#ifndef __IPHONEOS__ - //SDL_RenderSetViewport(GetSdlRenderer(), &rect); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::modTargetRect(Common::Rect *rect) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * _ratioX); - rect->h = MathUtil::RoundUp(rect->h * _ratioY); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointFromScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; - point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::pointToScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderSDL::dumpData(const char *filename) { - warning("CBRenderSDL::DumpData(%s) - not reimplemented yet", filename); // TODO -#if 0 - FILE *f = fopen(filename, "wt"); - if (!f) return; - - CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - - int TotalKB = 0; - int TotalLoss = 0; - fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - CBSurfaceSDL *Surf = (CBSurfaceSDL *)Mgr->_surfaces[i]; - if (!Surf->_filename) continue; - if (!Surf->_valid) continue; - - fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); - - int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; - - TotalKB += kb; - fprintf(f, "%d;", kb); - fprintf(f, "\n"); - } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); - - - fclose(f); - _gameRef->LOG(0, "Texture Stats Dump completed."); - _gameRef->QuickMessage("Texture Stats Dump completed."); -#endif -} - -CBSurface *CBRenderSDL::createSurface() { - return new CBSurfaceSDL(_gameRef); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderSDL.h b/engines/wintermute/Base/BRenderSDL.h deleted file mode 100644 index 7b5878a496..0000000000 --- a/engines/wintermute/Base/BRenderSDL.h +++ /dev/null @@ -1,129 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_SDL_H -#define WINTERMUTE_BRENDERER_SDL_H - -#include "engines/wintermute/Base/BRenderer.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "common/list.h" - -namespace WinterMute { -class CBSurfaceSDL; -class RenderTicket { -public: - RenderTicket(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); - RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} - ~RenderTicket(); - Graphics::Surface *_surface; - Common::Rect _srcRect; - Common::Rect _dstRect; - uint32 _mirror; - bool _hasAlpha; - - bool _isValid; - bool _wantsDraw; - uint32 _drawNum; - uint32 _colorMod; - - CBSurfaceSDL *_owner; - bool operator==(RenderTicket &a); -}; - -class CBRenderSDL : public CBRenderer { -public: - CBRenderSDL(CBGame *inGame); - ~CBRenderSDL(); - - const char *getName(); - - bool initRenderer(int width, int height, bool windowed); - bool flip(); - bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - - bool fade(uint16 alpha); - bool fadeToColor(uint32 color, Common::Rect *rect = NULL); - - bool switchFullscreen(); - - bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - - CBImage *takeScreenshot(); - - void setAlphaMod(byte alpha); - void setColorMod(byte r, byte g, byte b); - void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(CBSurfaceSDL *surf); - void drawFromTicket(RenderTicket *renderTicket); - - bool setViewport(int left, int top, int right, int bottom); - - void modTargetRect(Common::Rect *rect); - void pointFromScreen(Point32 *point); - void pointToScreen(Point32 *point); - - void dumpData(const char *filename); - - float getScaleRatioX() const { - return _ratioX; - } - float getScaleRatioY() const { - return _ratioY; - } - - void drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); - CBSurface *createSurface(); -private: - void addDirtyRect(const Common::Rect &rect); - void drawTickets(); - void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); - typedef Common::List::iterator RenderQueueIterator; - Common::Rect *_dirtyRect; - Common::List _renderQueue; - bool _needsFlip; - uint32 _drawNum; - Common::Rect _renderRect; - Graphics::Surface *_renderSurface; - AnsiString _name; - - int _borderLeft; - int _borderTop; - int _borderRight; - int _borderBottom; - - bool _disableDirtyRects; - float _ratioX; - float _ratioY; - uint32 _colorMod; - uint32 _clearColor; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/Base/BRenderer.cpp b/engines/wintermute/Base/BRenderer.cpp deleted file mode 100644 index 15ec101c1f..0000000000 --- a/engines/wintermute/Base/BRenderer.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BRenderer.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - _window = 0; - _clipperWindow = 0; - _active = false; - _ready = false; - _windowed = true; - _forceAlphaColor = 0x00; - - _width = _height = _bPP = 0; - CBPlatform::setRectEmpty(&_monitorRect); - - _realWidth = _realHeight = 0; - _drawOffsetX = _drawOffsetY = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBRenderer::~CBRenderer() { - deleteRectList(); - unclipCursor(); -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::initLoop() { - deleteRectList(); -} - - -////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::getObjectAt(int x, int y) { - Point32 point; - point.x = x; - point.y = y; - - for (int i = _rectList.getSize() - 1; i >= 0; i--) { - if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { - if (_rectList[i]->_precise) { - // frame - if (_rectList[i]->_frame) { - int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); - - if (_rectList[i]->_frame->_mirrorX) { - int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; - xx = width - xx; - } - - if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; - yy = height - yy; - } - - if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; - } - // region - else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; - } - } else return _rectList[i]->_owner; - } - } - - return (CBObject *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderer::deleteRectList() { - for (int i = 0; i < _rectList.getSize(); i++) { - delete _rectList[i]; - } - _rectList.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -bool CBRenderer::switchFullscreen() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::flip() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::initRenderer(int width, int height, bool windowed) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::onWindowChange() { -} - - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::windowedBlt() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setup2D(bool Force) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setupLines() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { - for (int i = 0; i < width; i++) { - drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up - drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down - - drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left - drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fade(uint16 alpha) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(int left, int top, int right, int bottom) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setScreenViewport() { - return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(Rect32 *rect) { - return setViewport(rect->left + _drawOffsetX, - rect->top + _drawOffsetY, - rect->right + _drawOffsetX, - rect->bottom + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::takeScreenshot() { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::clipCursor() { - /* - if (!_windowed) { - Rect32 rc; - GetWindowRect(_window, &rc); - - // if "maintain aspect ratio" is in effect, lock mouse to visible area - rc.left = _drawOffsetX; - rc.top = _drawOffsetY; - rc.right = rc.left + _width; - rc.bottom = rc.top + _height; - - ::ClipCursor(&rc); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::unclipCursor() { - /* - if (!_windowed) ::ClipCursor(NULL); - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Point32 *p) { - if (p->x < _drawOffsetX) return false; - if (p->y < _drawOffsetY) return false; - if (p->x > _drawOffsetX + _width) return false; - if (p->y > _drawOffsetY + _height) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRenderer.h b/engines/wintermute/Base/BRenderer.h deleted file mode 100644 index 4cc7e64fc1..0000000000 --- a/engines/wintermute/Base/BRenderer.h +++ /dev/null @@ -1,128 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_H -#define WINTERMUTE_BRENDERER_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BBase.h" -#include "common/rect.h" - -namespace WinterMute { - -class CBImage; -class CBActiveRect; -class CBObject; -class CBSurface; -class CBRenderer: public CBBase { -public: - int _realWidth; - int _realHeight; - int _drawOffsetX; - int _drawOffsetY; - - virtual void dumpData(const char *filename) {}; - virtual CBImage *takeScreenshot(); - virtual bool setViewport(int left, int top, int right, int bottom); - virtual bool setViewport(Rect32 *Rect); - virtual bool setScreenViewport(); - virtual bool fade(uint16 Alpha); - virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); - CBRenderer(CBGame *inGame = NULL); - virtual ~CBRenderer(); - virtual bool setProjection() { - return STATUS_OK; - }; - - virtual bool windowedBlt(); - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - virtual void onWindowChange(); - virtual bool initRenderer(int width, int height, bool windowed); - virtual bool flip(); - virtual void initLoop(); - virtual bool switchFullscreen(); - virtual bool setup2D(bool force = false); - virtual bool setupLines(); - - virtual const char *getName() { - return ""; - }; - virtual bool displayDebugInfo() { - return STATUS_FAILED; - }; - virtual bool drawShaderQuad() { - return STATUS_FAILED; - } - - virtual float getScaleRatioX() const { - return 1.0f; - } - virtual float getScaleRatioY() const { - return 1.0f; - } - - virtual CBSurface *createSurface() = 0; - - bool clipCursor(); - bool unclipCursor(); - - CBObject *getObjectAt(int x, int y); - void deleteRectList(); - - virtual bool startSpriteBatch() { - return STATUS_OK; - }; - virtual bool endSpriteBatch() { - return STATUS_OK; - }; - bool pointInViewport(Point32 *P); - uint32 _forceAlphaColor; - uint32 _window; - uint32 _clipperWindow; - bool _active; - bool _ready; - bool _windowed; - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; - int _bPP; - int _height; - int _width; - - CBArray _rectList; -}; - -CBRenderer *makeSDLRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp index a1653449ff..74295170ff 100644 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ b/engines/wintermute/Base/BSaveThumbHelper.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BSaveThumbHelper.h" -#include "engines/wintermute/Base/BImage.h" +#include "engines/wintermute/Base/gfx/base_image.h" #include "engines/wintermute/Base/BGame.h" namespace WinterMute { diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp index 1abea36c6b..1af73ca595 100644 --- a/engines/wintermute/Base/BSprite.cpp +++ b/engines/wintermute/Base/BSprite.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFrame.h" #include "engines/wintermute/Base/BSound.h" diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp index fe6695c7c2..7569ecb727 100644 --- a/engines/wintermute/Base/BSubFrame.cpp +++ b/engines/wintermute/Base/BSubFrame.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/BSubFrame.h" #include "engines/wintermute/Base/BActiveRect.h" #include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BSurfaceStorage.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/PlatformSDL.h" diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp deleted file mode 100644 index 3ba2a773a9..0000000000 --- a/engines/wintermute/Base/BSurface.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSurface.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { - _referenceCount = 0; - - _width = _height = 0; - - _filename = ""; - - _pixelOpReady = false; - - _ckDefault = true; - _ckRed = _ckGreen = _ckBlue = 0; - _lifeTime = 0; - _keepLoaded = false; - - _lastUsedTime = 0; - _valid = false; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface::~CBSurface() { - if (_pixelOpReady) endPixelOp(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::restore() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAt(int x, int y) { - return false; -} - -////////////////////////////////////////////////////////////////////// -bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::create(int Width, int Height) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::startPixelOp() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::endPixelOp() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAtLite(int x, int y) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::invalidate() { - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::prepareToDraw() { - _lastUsedTime = _gameRef->_liveTimer; - - if (!_valid) { - //_gameRef->LOG(0, "Reviving: %s", _filename); - return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSurface::setSize(int width, int height) { - _width = width; - _height = height; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurface.h b/engines/wintermute/Base/BSurface.h deleted file mode 100644 index ed9ace5322..0000000000 --- a/engines/wintermute/Base/BSurface.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACE_H -#define WINTERMUTE_BSURFACE_H - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "graphics/surface.h" - -namespace WinterMute { - -class CBSurface: public CBBase { -public: - virtual bool invalidate(); - virtual bool prepareToDraw(); - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - - uint32 _lastUsedTime; - bool _valid; - int _lifeTime; - bool _keepLoaded; - - bool _pixelOpReady; - CBSurface(CBGame *inGame); - virtual ~CBSurface(); - - virtual bool displayHalfTrans(int x, int y, Rect32 rect); - virtual bool isTransparentAt(int x, int y); - virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool restore(); - virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual bool create(int Width, int Height); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { - return STATUS_FAILED; - } - virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); - virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool startPixelOp(); - virtual bool endPixelOp(); - virtual bool isTransparentAtLite(int x, int y); - void setSize(int width, int height); - - int _referenceCount; - - virtual int getWidth() { - return _width; - } - virtual int getHeight() { - return _height; - } - Common::String getFileNameStr() { return _filename; } - const char* getFileName() { return _filename.c_str(); } - //void SetWidth(int Width){ _width = Width; } - //void SetHeight(int Height){ _height = Height; } -protected: - Common::String _filename; - int _height; - int _width; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp deleted file mode 100644 index c8b22511fa..0000000000 --- a/engines/wintermute/Base/BSurfaceSDL.cpp +++ /dev/null @@ -1,532 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" -#include "engines/wintermute/Base/BRenderSDL.h" -#include "engines/wintermute/Base/BImage.h" -#include "engines/wintermute/PlatformSDL.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/bmp.h" -#include "graphics/decoders/jpeg.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/graphics/tga.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "common/stream.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSurfaceSDL::CBSurfaceSDL(CBGame *inGame) : CBSurface(inGame) { - _surface = new Graphics::Surface(); - _alphaMask = NULL; - _hasAlpha = true; - _lockPixels = NULL; - _lockPitch = 0; - _loaded = false; -} - -////////////////////////////////////////////////////////////////////////// -CBSurfaceSDL::~CBSurfaceSDL() { - //TODO - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - - delete[] _alphaMask; - _alphaMask = NULL; - - _gameRef->addMem(-_width * _height * 4); - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); -} - -bool hasTransparency(Graphics::Surface *surf) { - if (surf->format.bytesPerPixel != 4) { - warning("hasTransparency:: non 32 bpp surface passed as argument"); - return false; - } - uint8 r, g, b, a; - for (int i = 0; i < surf->h; i++) { - for (int j = 0; j < surf->w; j++) { - uint32 pix = *(uint32 *)surf->getBasePtr(j, i); - surf->format.colorToARGB(pix, a, r, g, b); - if (a != 255) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* CBRenderSDL *renderer = static_cast(_gameRef->_renderer); */ - _filename = filename; -// const Graphics::Surface *surface = image->getSurface(); - - if (defaultCK) { - ckRed = 255; - ckGreen = 0; - ckBlue = 255; - } - - _ckDefault = defaultCK; - _ckRed = ckRed; - _ckGreen = ckGreen; - _ckBlue = ckBlue; - - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) - _lifeTime = lifeTime; - - _keepLoaded = keepLoaded; - if (_keepLoaded) _lifeTime = -1; - - return STATUS_OK; -} - -void CBSurfaceSDL::finishLoad() { - CBImage *image = new CBImage(_gameRef); - image->loadFile(_filename); - - _width = image->getSurface()->w; - _height = image->getSurface()->h; - - bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); - if (isSaveGameGrayscale) { - warning("grayscaleConversion not yet implemented"); - /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ - } - - // no alpha, set color key - /* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. - delete _surface; - if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); - } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); - } else { - _surface = new Graphics::Surface(); - _surface->copyFrom(*image->getSurface()); - } - - _hasAlpha = hasTransparency(_surface); - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Surface-textures not fully ported yet"); - hasWarned = true; - } - //delete imgDecoder; -#if 0 - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!_texture) { - SDL_FreeSurface(surf); - delete imgDecoder; - return STATUS_FAILED; - } - - GenAlphaMask(surf); - - SDL_FreeSurface(surf); - delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. -#endif - - _valid = true; - - _gameRef->addMem(_width * _height * 4); - - delete image; - - _loaded = true; -} - -////////////////////////////////////////////////////////////////////////// -void CBSurfaceSDL::genAlphaMask(Graphics::Surface *surface) { - warning("CBSurfaceSDL::GenAlphaMask - Not ported yet"); - return; - - delete[] _alphaMask; - _alphaMask = NULL; - if (!surface) return; -#if 0 - SDL_LockSurface(surface); -#endif - bool hasColorKey; - /* uint32 colorKey; */ - uint8 ckRed, ckGreen, ckBlue; - /* if (SDL_GetColorKey(surface, &colorKey) == 0) { - hasColorKey = true; - SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); - } else hasColorKey = false; - */ //TODO - _alphaMask = new byte[surface->w * surface->h]; - - bool hasTransparency = false; - for (int y = 0; y < surface->h; y++) { - for (int x = 0; x < surface->w; x++) { - uint32 pixel = getPixel(surface, x, y); - - uint8 r, g, b, a; - surface->format.colorToARGB(pixel, a, r, g, b); - //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) - a = 0; - - _alphaMask[y * surface->w + x] = a; - if (a < 255) hasTransparency = true; - } - } -#if 0 - SDL_UnlockSurface(surface); -#endif - if (!hasTransparency) { - delete[] _alphaMask; - _alphaMask = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) { - warning("CBSurfaceSDL::GetPixel - Not ported yet"); - int bpp = surface->format.bytesPerPixel; - /* Here p is the address to the pixel we want to retrieve */ - uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; - - switch (bpp) { - case 1: - return *p; - break; - - case 2: - return *(uint16 *)p; - break; - - case 3: -#ifdef SCUMM_BIG_ENDIAN - // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; -#else - //else - return p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - return *(uint32 *)p; - break; - - default: - return 0; /* shouldn't happen, but avoids warnings */ - } - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::create(int width, int height) { - warning("SurfaceSDL::Create not ported yet"); //TODO -#if 0 - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); -#endif - _width = width; - _height = height; - - _gameRef->addMem(_width * _height * 4); - - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) { - warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO -#if 0 - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); -#endif - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - _width = surface->w; - _height = surface->h; -#if 0 - _gameRef->AddMem(_width * _height * 4); -#endif - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::isTransparentAt(int x, int y) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::IsTransparentAt not ported yet"); - hasWarned = true; - } -#if 0 - int access; - int width, height; - //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - - StartPixelOp(); - bool ret = isTransparentAtLite(X, Y); - EndPixelOp(); - - return ret; -#endif - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::isTransparentAtLite(int x, int y) { - //if (!_lockPixels) return false; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::IsTransparentAtLite not ported yet"); - hasWarned = true; - } - if (_surface->format.bytesPerPixel == 4) { - uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); - uint8 r, g, b, a; - _surface->format.colorToARGB(pixel, a, r, g, b); - if (a <= 128) { - return true; - } else { - return false; - } - } -#if 0 - uint32 format; - int access; - int width, height; - - //SDL_QueryTexture(_texture, &format, &access, &width, &height); - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - if (!_alphaMask) return false; - else return _alphaMask[Y * width + X] <= 128; -#endif - return false; - /* - Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); - Uint32 pixel = dst[X]; - - SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); - SDL_FreeFormat(pixelFormat); - - return a <= 128; - */ -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::startPixelOp() { - //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); - // Any pixel-op makes the caching useless: - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::endPixelOp() { - //SDL_UnlockTexture(_texture); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - - if (!_loaded) { - finishLoad(); - } - - if (renderer->_forceAlphaColor != 0) - alpha = renderer->_forceAlphaColor; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceSDL::DrawSprite not fully ported yet"); // TODO. - hasWarned = true; - } - - byte r = RGBCOLGetR(alpha); - byte g = RGBCOLGetG(alpha); - byte b = RGBCOLGetB(alpha); - byte a = RGBCOLGetA(alpha); - - renderer->setAlphaMod(a); - renderer->setColorMod(r, g, b); -#if 0 - SDL_SetTextureColorMod(_texture, r, g, b); - SDL_SetTextureAlphaMod(_texture, a); - - if (AlphaDisable) - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - else - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); -#endif - // TODO: This _might_ miss the intended behaviour by 1 in each direction - // But I think it fits the model used in Wintermute. - Common::Rect srcRect; - srcRect.left = rect->left; - srcRect.top = rect->top; - srcRect.setWidth(rect->right - rect->left); - srcRect.setHeight(rect->bottom - rect->top); - - Common::Rect position; - position.left = x + offsetX; - position.top = y + offsetY; - // TODO: Scaling... - - if (position.left == -1) { - position.left = 0; // TODO: Something is wrong - } - if (position.top == -1) { - position.top = 0; // TODO: Something is wrong - } - - position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); - position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); - - renderer->modTargetRect(&position); - - /* position.left += offsetX; - position.top += offsetY;*/ - - // TODO: This actually requires us to have the SAME source-offsets every time, - // But no checking is in place for that yet. - - bool hasAlpha; - if (_hasAlpha && !alphaDisable) { - hasAlpha = true; - } else { - hasAlpha = false; - } - if (alphaDisable) { - warning("CBSurfaceSDL::drawSprite - AlphaDisable ignored"); - } - - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); -#if 0 - SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); -#endif - - return STATUS_OK; -} - -bool CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlpha) { - _loaded = true; - _surface->copyFrom(surface); - _hasAlpha = hasAlpha; - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceSDL.h b/engines/wintermute/Base/BSurfaceSDL.h deleted file mode 100644 index fa70c97fdf..0000000000 --- a/engines/wintermute/Base/BSurfaceSDL.h +++ /dev/null @@ -1,101 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESDL_H -#define WINTERMUTE_BSURFACESDL_H - -#include "graphics/surface.h" -#include "engines/wintermute/Base/BSurface.h" -#include "common/list.h" - -namespace WinterMute { -struct TransparentSurface; -class CBImage; -class CBSurfaceSDL : public CBSurface { -public: - CBSurfaceSDL(CBGame *inGame); - ~CBSurfaceSDL(); - - bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); - bool create(int width, int height); - - bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - - bool isTransparentAt(int x, int y); - bool isTransparentAtLite(int x, int y); - - bool startPixelOp(); - bool endPixelOp(); - - - bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); - /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); - static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); - static long DLL_CALLCONV TellProc(fi_handle handle);*/ - virtual int getWidth() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->w; - } - return _width; - } - virtual int getHeight() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->h; - } - return _height; - } - -private: - Graphics::Surface *_surface; - bool _loaded; - void finishLoad(); - bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); - void genAlphaMask(Graphics::Surface *surface); - uint32 getPixel(Graphics::Surface *surface, int x, int y); - - bool _hasAlpha; - void *_lockPixels; - int _lockPitch; - byte *_alphaMask; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp index 56b59f714a..64bc3daac6 100644 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ b/engines/wintermute/Base/BSurfaceStorage.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" #include "engines/wintermute/PlatformSDL.h" @@ -114,7 +114,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by } CBSurface *surface; - surface = new CBSurfaceSDL(_gameRef); + surface = _gameRef->_renderer->createSurface(); if (!surface) return NULL; diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp index badf5ac646..15e14958f8 100644 --- a/engines/wintermute/Base/font/BFontBitmap.cpp +++ b/engines/wintermute/Base/font/BFontBitmap.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BSubFrame.h" #include "engines/wintermute/Base/BFrame.h" diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp index 4517f580b2..fd3dcb3567 100644 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ b/engines/wintermute/Base/font/BFontTT.cpp @@ -32,8 +32,8 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/BRenderer.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_renderer.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" @@ -363,7 +363,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex posY += GetLineHeight(); } - CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(_gameRef); + CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { SDL_FreeSurface(surface); return wmeSurface; diff --git a/engines/wintermute/Base/font/BFontTT.h b/engines/wintermute/Base/font/BFontTT.h index 058fc28755..d2b29a89f8 100644 --- a/engines/wintermute/Base/font/BFontTT.h +++ b/engines/wintermute/Base/font/BFontTT.h @@ -31,7 +31,7 @@ #include "engines/wintermute/Base/font/BFontStorage.h" #include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "common/rect.h" #include "graphics/surface.h" #include "graphics/font.h" diff --git a/engines/wintermute/Base/gfx/base_image.cpp b/engines/wintermute/Base/gfx/base_image.cpp new file mode 100644 index 0000000000..e6a6881807 --- /dev/null +++ b/engines/wintermute/Base/gfx/base_image.cpp @@ -0,0 +1,269 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/gfx/base_image.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/bmp.h" +#include "graphics/surface.h" +#include "engines/wintermute/graphics/tga.h" +#include "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +#if 0 + _bitmap = bitmap; +#endif + _bitmap = NULL; + _palette = NULL; + _surface = NULL; + _decoder = NULL; + _deletableSurface = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBImage::~CBImage() { + /* delete _bitmap; */ + delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } + delete _deletableSurface; +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); +#endif +} + +bool CBImage::loadFile(const Common::String &filename) { + _filename = filename; + _filename.toLowercase(); + if (StringUtil::startsWith(filename, "savegame:", true)) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".png")) { + _decoder = new Graphics::PNGDecoder(); + } else if (_filename.hasSuffix(".bmp")) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".tga")) { + _decoder = new WinterMute::TGA(); + } else if (_filename.hasSuffix(".jpg")) { + _decoder = new Graphics::JPEGDecoder(); + } else { + error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + _filename = filename; + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); + if (!file) return STATUS_FAILED; + + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); + _gameRef->_fileManager->closeFile(file); + + return STATUS_OK; +} + +byte CBImage::getAlphaAt(int x, int y) { + if (!_surface) return 0xFF; + uint32 color = *(uint32 *)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} + +void CBImage::copyFrom(Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + +////////////////////////////////////////////////////////////////////////// +bool CBImage::saveBMPFile(const char *filename) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; + else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::resize(int newWidth, int newHeight) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + + + FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + if (newImg) { + FreeImage_Unload(_bitmap); + _bitmap = newImg; + return STATUS_OK; + } else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::writeBMPToStream(Common::WriteStream *stream) { + if (!_surface) return false; + + /* The following is just copied over and inverted to write-ops from the BMP-decoder */ + stream->writeByte('B'); + stream->writeByte('M'); + + /* Since we don't care during reads, we don't care during writes: */ + /* uint32 fileSize = */ + stream->writeUint32LE(54 + _surface->h * _surface->pitch); + /* uint16 res1 = */ + stream->writeUint16LE(0); + /* uint16 res2 = */ + stream->writeUint16LE(0); + const uint32 imageOffset = 54; + stream->writeUint32LE(imageOffset); + + const uint32 infoSize = 40; /* Windows v3 BMP */ + stream->writeUint32LE(infoSize); + + uint32 width = _surface->w; + int32 height = _surface->h; + stream->writeUint32LE(width); + stream->writeUint32LE((uint32)height); + + if (width == 0 || height == 0) + return false; + + if (height < 0) { + warning("Right-side up bitmaps not supported"); + return false; + } + + /* uint16 planes = */ stream->writeUint16LE(1); + const uint16 bitsPerPixel = 24; + stream->writeUint16LE(bitsPerPixel); + + const uint32 compression = 0; + stream->writeUint32LE(compression); + + /* uint32 imageSize = */ + stream->writeUint32LE(_surface->h * _surface->pitch); + /* uint32 pixelsPerMeterX = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ + stream->writeUint32LE(0); + const uint32 paletteColorCount = 0; + stream->writeUint32LE(paletteColorCount); + /* uint32 colorsImportant = */ + stream->writeUint32LE(0); + + // Start us at the beginning of the image (54 bytes in) + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + + // BGRA for 24bpp + if (bitsPerPixel == 24) + format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + + Graphics::Surface *surface = _surface->convertTo(format); + + int srcPitch = width * (bitsPerPixel >> 3); + const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + + for (int32 i = height - 1; i >= 0; i--) { + for (uint32 j = 0; j < width; j++) { + byte b, g, r; + uint32 color = *(uint32 *)surface->getBasePtr(j, i); + surface->format.colorToRGB(color, r, g, b); + stream->writeByte(b); + stream->writeByte(g); + stream->writeByte(r); + } + + for (int k = 0; k < extraDataLength; k++) { + stream->writeByte(0); + } + } + surface->free(); + delete surface; + return true; + + //*BufferSize = 0; +#if 0 + FIMEMORY *fiMem = FreeImage_OpenMemory(); + FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); + uint32 size; + byte *data; + FreeImage_AcquireMemory(fiMem, &data, &size); + + + byte *Buffer = new byte[size]; + memcpy(Buffer, data, size); + + FreeImage_CloseMemory(fiMem); + + if (BufferSize) *BufferSize = size; + + return Buffer; +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + + _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); +#endif + TransparentSurface temp(*origImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale(newWidth, newHeight); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_image.h b/engines/wintermute/Base/gfx/base_image.h new file mode 100644 index 0000000000..29455d3f7a --- /dev/null +++ b/engines/wintermute/Base/gfx/base_image.h @@ -0,0 +1,74 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BIMAGE_H +#define WINTERMUTE_BIMAGE_H + +#include "engines/wintermute/Base/BBase.h" +#include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/decoders/image_decoder.h" +#include "common/endian.h" +#include "common/str.h" +#include "common/stream.h" + +struct FIBITMAP; + +namespace WinterMute { +class CBSurface; +class CBImage: CBBase { + +public: + CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); + ~CBImage(); + + bool loadFile(const Common::String &filename); + const Graphics::Surface *getSurface() const { + return _surface; + }; + const byte *getPalette() const { + return _palette; + } + byte getAlphaAt(int x, int y); + bool writeBMPToStream(Common::WriteStream *stream); + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename); + bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + void copyFrom(Graphics::Surface *surface); +private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; + FIBITMAP *_bitmap; + const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; + const byte *_palette; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/gfx/base_renderer.cpp b/engines/wintermute/Base/gfx/base_renderer.cpp new file mode 100644 index 0000000000..a2ecf16cd4 --- /dev/null +++ b/engines/wintermute/Base/gfx/base_renderer.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/BActiveRect.h" +#include "engines/wintermute/Base/gfx/base_renderer.h" +#include "engines/wintermute/Base/gfx/base_surface.h" +#include "engines/wintermute/Base/BSubFrame.h" +#include "engines/wintermute/Base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { + _window = 0; + _clipperWindow = 0; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _width = _height = _bPP = 0; + CBPlatform::setRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBRenderer::~CBRenderer() { + deleteRectList(); + unclipCursor(); +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::initLoop() { + deleteRectList(); +} + + +////////////////////////////////////////////////////////////////////// +CBObject *CBRenderer::getObjectAt(int x, int y) { + Point32 point; + point.x = x; + point.y = y; + + for (int i = _rectList.getSize() - 1; i >= 0; i--) { + if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + + if (_rectList[i]->_frame->_mirrorX) { + int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + xx = width - xx; + } + + if (_rectList[i]->_frame->_mirrorY) { + int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + yy = height - yy; + } + + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; + } + // region + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + } + } else return _rectList[i]->_owner; + } + } + + return (CBObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderer::deleteRectList() { + for (int i = 0; i < _rectList.getSize(); i++) { + delete _rectList[i]; + } + _rectList.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +bool CBRenderer::switchFullscreen() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::flip() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::onWindowChange() { +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::windowedBlt() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setup2D(bool Force) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setupLines() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { + for (int i = 0; i < width; i++) { + drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up + drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down + + drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left + drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fade(uint16 alpha) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(Rect32 *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderer::takeScreenshot() { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::clipCursor() { + /* + if (!_windowed) { + Rect32 rc; + GetWindowRect(_window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; + + ::ClipCursor(&rc); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::unclipCursor() { + /* + if (!_windowed) ::ClipCursor(NULL); + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::pointInViewport(Point32 *p) { + if (p->x < _drawOffsetX) return false; + if (p->y < _drawOffsetY) return false; + if (p->x > _drawOffsetX + _width) return false; + if (p->y > _drawOffsetY + _height) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_renderer.h b/engines/wintermute/Base/gfx/base_renderer.h new file mode 100644 index 0000000000..b5f654e8ec --- /dev/null +++ b/engines/wintermute/Base/gfx/base_renderer.h @@ -0,0 +1,128 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_H +#define WINTERMUTE_BRENDERER_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/Base/BBase.h" +#include "common/rect.h" + +namespace WinterMute { + +class CBImage; +class CBActiveRect; +class CBObject; +class CBSurface; +class CBRenderer: public CBBase { +public: + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void dumpData(const char *filename) {}; + virtual CBImage *takeScreenshot(); + virtual bool setViewport(int left, int top, int right, int bottom); + virtual bool setViewport(Rect32 *Rect); + virtual bool setScreenViewport(); + virtual bool fade(uint16 Alpha); + virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + CBRenderer(CBGame *inGame = NULL); + virtual ~CBRenderer(); + virtual bool setProjection() { + return STATUS_OK; + }; + + virtual bool windowedBlt(); + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual void onWindowChange(); + virtual bool initRenderer(int width, int height, bool windowed); + virtual bool flip(); + virtual void initLoop(); + virtual bool switchFullscreen(); + virtual bool setup2D(bool force = false); + virtual bool setupLines(); + + virtual const char *getName() { + return ""; + }; + virtual bool displayDebugInfo() { + return STATUS_FAILED; + }; + virtual bool drawShaderQuad() { + return STATUS_FAILED; + } + + virtual float getScaleRatioX() const { + return 1.0f; + } + virtual float getScaleRatioY() const { + return 1.0f; + } + + virtual CBSurface *createSurface() = 0; + + bool clipCursor(); + bool unclipCursor(); + + CBObject *getObjectAt(int x, int y); + void deleteRectList(); + + virtual bool startSpriteBatch() { + return STATUS_OK; + }; + virtual bool endSpriteBatch() { + return STATUS_OK; + }; + bool pointInViewport(Point32 *P); + uint32 _forceAlphaColor; + uint32 _window; + uint32 _clipperWindow; + bool _active; + bool _ready; + bool _windowed; + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; + int _bPP; + int _height; + int _width; + + CBArray _rectList; +}; + +CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/gfx/base_surface.cpp b/engines/wintermute/Base/gfx/base_surface.cpp new file mode 100644 index 0000000000..dac0692d76 --- /dev/null +++ b/engines/wintermute/Base/gfx/base_surface.cpp @@ -0,0 +1,152 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/gfx/base_surface.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = ""; + + _pixelOpReady = false; + + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface::~CBSurface() { + if (_pixelOpReady) endPixelOp(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::restore() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAt(int x, int y) { + return false; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::create(int Width, int Height) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::startPixelOp() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::endPixelOp() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAtLite(int x, int y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::invalidate() { + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::prepareToDraw() { + _lastUsedTime = _gameRef->_liveTimer; + + if (!_valid) { + //_gameRef->LOG(0, "Reviving: %s", _filename); + return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSurface::setSize(int width, int height) { + _width = width; + _height = height; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_surface.h b/engines/wintermute/Base/gfx/base_surface.h new file mode 100644 index 0000000000..ed9ace5322 --- /dev/null +++ b/engines/wintermute/Base/gfx/base_surface.h @@ -0,0 +1,99 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACE_H +#define WINTERMUTE_BSURFACE_H + +#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "graphics/surface.h" + +namespace WinterMute { + +class CBSurface: public CBBase { +public: + virtual bool invalidate(); + virtual bool prepareToDraw(); + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + bool _keepLoaded; + + bool _pixelOpReady; + CBSurface(CBGame *inGame); + virtual ~CBSurface(); + + virtual bool displayHalfTrans(int x, int y, Rect32 rect); + virtual bool isTransparentAt(int x, int y); + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool restore(); + virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(int Width, int Height); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return STATUS_FAILED; + } + virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool startPixelOp(); + virtual bool endPixelOp(); + virtual bool isTransparentAtLite(int x, int y); + void setSize(int width, int height); + + int _referenceCount; + + virtual int getWidth() { + return _width; + } + virtual int getHeight() { + return _height; + } + Common::String getFileNameStr() { return _filename; } + const char* getFileName() { return _filename.c_str(); } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } +protected: + Common::String _filename; + int _height; + int _width; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp new file mode 100644 index 0000000000..923855686d --- /dev/null +++ b/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp @@ -0,0 +1,701 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/Base/BSurfaceStorage.h" +#include "engines/wintermute/Base/gfx/base_image.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BSprite.h" +#include "common/system.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "common/queue.h" + +namespace WinterMute { + +RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { + _colorMod = 0; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; + if (surf) { + _surface = new Graphics::Surface(); + _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); + assert(_surface->format.bytesPerPixel == 4); + // Get a clipped copy of the surface + for (int i = 0; i < _surface->h; i++) { + memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); + } + // Then scale it if necessary + if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + TransparentSurface src(*_surface, false); + Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); + _surface->free(); + delete _surface; + _surface = temp; + } + } else { + _surface = NULL; + } +} + +RenderTicket::~RenderTicket() { + if (_surface) { + _surface->free(); + delete _surface; + } +} + +bool RenderTicket::operator==(RenderTicket &t) { + if ((t._srcRect != _srcRect) || + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } + return true; +} + +CBRenderer *makeOSystemRenderer(CBGame *inGame) { + return new CBRenderOSystem(inGame); +} + +// TODO: Redo everything here. + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { + _renderSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); + _dirtyRect = NULL; + _disableDirtyRects = true; +} + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::~CBRenderOSystem() { + _renderSurface->free(); + delete _renderSurface; +#if 0 + if (_renderer) SDL_DestroyRenderer(_renderer); + if (_win) SDL_DestroyWindow(_win); + SDL_Quit(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; + +#if 0 + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); +#endif + _width = width; + _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); + + _realWidth = width; + _realHeight = height; + + + // find suitable resolution +/*#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } +#else*/ + _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); + _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); +//#endif + + /* + _realWidth = 480; + _realHeight = 320; + */ + + + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)_realHeight / (float)_height; + } else { + // wide to normal + ratio = (float)_realWidth / (float)_width; + } + + _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); + _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); + + _borderTop = (int)((_realHeight - (_height * ratio)) / 2); + _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); + + + + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; + +#if 0 + Uint32 flags = SDL_WINDOW_SHOWN; +#endif +#ifdef __IPHONEOS__ + //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; +#endif + + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); +// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return STATUS_FAILED; + } +#if 0 + _win = SDL_CreateWindow("WME Lite", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + _realWidth, _realHeight, + flags); + + if (!_win) return STATUS_FAILED; +#endif + + g_system->showMouse(false); + +#ifdef __IPHONEOS__ + // SDL defaults to OGL ES2, which doesn't work on old devices + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); +#else + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif +#if 0 + _renderer = SDL_CreateRenderer(_win, -1, 0); + + if (!_renderer) return STATUS_FAILED; +#endif + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _active = true; + + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); + + return STATUS_OK; +} + +void CBRenderOSystem::setAlphaMod(byte alpha) { + byte r = RGBCOLGetR(_colorMod); + byte g = RGBCOLGetB(_colorMod); + byte b = RGBCOLGetB(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { + byte alpha = RGBCOLGetA(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::flip() { + if (!_disableDirtyRects) { + drawTickets(); + } + if (_needsFlip || _disableDirtyRects) { + if (_disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + } + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + delete _dirtyRect; + _dirtyRect = NULL; + g_system->updateScreen(); + _needsFlip = false; + } + _drawNum = 1; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { + //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); + //SDL_RenderClear(_renderer); + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) + return STATUS_OK; + if (!rect) { + rect = &_renderRect; + } + _renderSurface->fillRect(*rect, _clearColor); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fade(uint16 Alpha) { + uint32 dwAlpha = 255 - Alpha; + return fadeToColor(dwAlpha << 24); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); + warning("Implement CBRenderOSystem::FadeToColor"); // TODO. + hasWarned = true; + } + + Common::Rect fillRect; + + if (rect) { + fillRect.left = rect->left; + fillRect.top = rect->top; + fillRect.setWidth(rect->width()); + fillRect.setHeight(rect->height()); + } else { + Rect32 rc; + _gameRef->getCurrentViewportRect(&rc); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); + } + modTargetRect(&fillRect); + + byte r = RGBCOLGetR(Color); + byte g = RGBCOLGetG(Color); + byte b = RGBCOLGetB(Color); + byte a = RGBCOLGetA(Color); + + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + if (_disableDirtyRects) + _renderSurface->fillRect(fillRect, col); + else { + setAlphaMod(a); + setColorMod(r, g, b); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + _clearColor = col; + } + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); + + return STATUS_OK; +} + +void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { + if (_disableDirtyRects) { + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + // HINT: The surface-data contains other info than it should. + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + return; + } + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { + return; + } + + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } + } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + ticket->_colorMod = _colorMod; + drawFromTicket(ticket); +} + +void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} + +void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } + } +} + +void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { + renderTicket->_wantsDraw = true; + // A new item always has _drawNum == 0 + if (renderTicket->_drawNum == 0) { + // In-order + if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { + renderTicket->_drawNum = _drawNum++; + _renderQueue.push_back(renderTicket); + addDirtyRect(renderTicket->_dstRect); + } else { + // Before something + Common::List::iterator pos; + for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { + if ((*pos)->_drawNum >= _drawNum) { + break; + } + } + _renderQueue.insert(pos, renderTicket); + Common::List::iterator it; + renderTicket->_drawNum = _drawNum++; + // Increment the following tickets, so they still are in line + for (it = pos; it != _renderQueue.end(); it++) { + (*it)->_drawNum++; + (*it)->_wantsDraw = false; + } + addDirtyRect(renderTicket->_dstRect); + } + } else { + // Was drawn last round, still in the same order + if (_drawNum == renderTicket->_drawNum) { + _drawNum++; + } else { + // Remove the ticket from the list + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it) == renderTicket) { + it = _renderQueue.erase(it); + break; + } else { + it++; + } + } + // Is not in order, so readd it as if it was a new ticket + renderTicket->_drawNum = 0; + drawFromTicket(renderTicket); + } + } +} + +void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); +} + +void CBRenderOSystem::drawTickets() { + RenderQueueIterator it = _renderQueue.begin(); + // Clean out the old tickets + int decrement = 0; + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { + RenderTicket* ticket = *it; + addDirtyRect((*it)->_dstRect); + //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); + it = _renderQueue.erase(it); + delete ticket; + decrement++; + } else { + (*it)->_drawNum -= decrement; + it++; + } + } + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) + return; + // The color-mods are stored in the RenderTickets on add, since we set that state again during + // draw, we need to keep track of what it was prior to draw. + uint32 oldColorMod = _colorMod; +// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); + + // Apply the clear-color to the dirty rect. + _renderSurface->fillRect(*_dirtyRect, _clearColor); + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + RenderTicket *ticket = *it; + if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { + // dstClip is the area we want redrawn. + Common::Rect dstClip(ticket->_dstRect); + // reduce it to the dirty rect + dstClip.clip(*_dirtyRect); + // we need to keep track of the position to redraw the dirty rect + Common::Rect pos(dstClip); + int16 offsetX = ticket->_dstRect.left; + int16 offsetY = ticket->_dstRect.top; + // convert from screen-coords to surface-coords. + dstClip.translate(-offsetX, -offsetY); + + _colorMod = ticket->_colorMod; + drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + _needsFlip = true; + } + // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) + ticket->_wantsDraw = false; + } + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + + // Revert the colorMod-state. + _colorMod = oldColorMod; +} + +// Replacement for SDL2's SDL_RenderCopy +void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { + TransparentSurface src(*surf, false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(surf->w); + clipRect->setHeight(surf->h); + } + + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) + delete clipRect; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::DrawLine - not fully ported yet"); + hasWarned = true; + } + byte r = RGBCOLGetR(color); + byte g = RGBCOLGetG(color); + byte b = RGBCOLGetB(color); + byte a = RGBCOLGetA(color); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + + Point32 point1, point2; + point1.x = x1; + point1.y = y1; + pointToScreen(&point1); + + point2.x = x2; + point2.y = y2; + pointToScreen(&point2); + + // TODO: This thing is mostly here until I'm sure about the final color-format. + uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderOSystem::takeScreenshot() { +// TODO: Fix this + warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); + CBImage *screenshot = new CBImage(_gameRef); + screenshot->copyFrom(_renderSurface); + return screenshot; +#if 0 + SDL_Rect viewport; + + SDL_RenderGetViewport(_renderer, &viewport); + + SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); + if (!surface) return NULL; + + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + + FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + + int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); + + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + byte *bits = FreeImage_GetScanLine(dib, y); + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + memcpy(bits, src, bytespp * viewport.w); + } + + return new CBImage(_gameRef, dib); +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::switchFullscreen() { + /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); + else SDL_SetWindowFullscreen(_win, SDL_FALSE); + + _windowed = !_windowed; + */ + _gameRef->_registry->writeBool("Video", "Windowed", _windowed); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBRenderOSystem::getName() { + if (_name.empty()) { +#if 0 + if (_renderer) { + SDL_RendererInfo info; + SDL_GetRendererInfo(_renderer, &info); + _name = AnsiString(info.name); + } +#endif + } + return _name.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = (int16)(left + _borderLeft); + rect.top = (int16)(top + _borderTop); + rect.right = (int16)((right - left) * _ratioX); + rect.bottom = (int16)((bottom - top) * _ratioY); + + // TODO fix this once viewports work correctly in SDL/landscape +#ifndef __IPHONEOS__ + //SDL_RenderSetViewport(GetSdlRenderer(), &rect); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::modTargetRect(Common::Rect *rect) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * _ratioX); + rect->h = MathUtil::RoundUp(rect->h * _ratioY); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointFromScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; + point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointToScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::dumpData(const char *filename) { + warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO +#if 0 + FILE *f = fopen(filename, "wt"); + if (!f) return; + + CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; + + int TotalKB = 0; + int TotalLoss = 0; + fprintf(f, "Filename;Usage;Size;KBytes\n"); + for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { + CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; + if (!Surf->_filename) continue; + if (!Surf->_valid) continue; + + fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); + fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); + + int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; + + TotalKB += kb; + fprintf(f, "%d;", kb); + fprintf(f, "\n"); + } + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); + + + fclose(f); + _gameRef->LOG(0, "Texture Stats Dump completed."); + _gameRef->QuickMessage("Texture Stats Dump completed."); +#endif +} + +CBSurface *CBRenderOSystem::createSurface() { + return new CBSurfaceOSystem(_gameRef); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/osystem/base_render_osystem.h b/engines/wintermute/Base/gfx/osystem/base_render_osystem.h new file mode 100644 index 0000000000..44bd1d3906 --- /dev/null +++ b/engines/wintermute/Base/gfx/osystem/base_render_osystem.h @@ -0,0 +1,129 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_SDL_H +#define WINTERMUTE_BRENDERER_SDL_H + +#include "engines/wintermute/Base/gfx/base_renderer.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "common/list.h" + +namespace WinterMute { +class CBSurfaceOSystem; +class RenderTicket { +public: + RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + Graphics::Surface *_surface; + Common::Rect _srcRect; + Common::Rect _dstRect; + uint32 _mirror; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + CBSurfaceOSystem *_owner; + bool operator==(RenderTicket &a); +}; + +class CBRenderOSystem : public CBRenderer { +public: + CBRenderOSystem(CBGame *inGame); + ~CBRenderOSystem(); + + const char *getName(); + + bool initRenderer(int width, int height, bool windowed); + bool flip(); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + + bool fade(uint16 alpha); + bool fadeToColor(uint32 color, Common::Rect *rect = NULL); + + bool switchFullscreen(); + + bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + + CBImage *takeScreenshot(); + + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); + void drawFromTicket(RenderTicket *renderTicket); + + bool setViewport(int left, int top, int right, int bottom); + + void modTargetRect(Common::Rect *rect); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); + + void dumpData(const char *filename); + + float getScaleRatioX() const { + return _ratioX; + } + float getScaleRatioY() const { + return _ratioY; + } + + void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + CBSurface *createSurface(); +private: + void addDirtyRect(const Common::Rect &rect); + void drawTickets(); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); + typedef Common::List::iterator RenderQueueIterator; + Common::Rect *_dirtyRect; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; + Common::Rect _renderRect; + Graphics::Surface *_renderSurface; + AnsiString _name; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + bool _disableDirtyRects; + float _ratioX; + float _ratioY; + uint32 _colorMod; + uint32 _clearColor; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp new file mode 100644 index 0000000000..57b3c61b8a --- /dev/null +++ b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp @@ -0,0 +1,532 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/file/BFile.h" +#include "engines/wintermute/Base/BFileManager.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/Base/gfx/base_image.h" +#include "engines/wintermute/PlatformSDL.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/decoders/jpeg.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/tga.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + _hasAlpha = true; + _lockPixels = NULL; + _lockPitch = 0; + _loaded = false; +} + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::~CBSurfaceOSystem() { + //TODO + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + delete[] _alphaMask; + _alphaMask = NULL; + + _gameRef->addMem(-_width * _height * 4); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); +} + +bool hasTransparency(Graphics::Surface *surf) { + if (surf->format.bytesPerPixel != 4) { + warning("hasTransparency:: non 32 bpp surface passed as argument"); + return false; + } + uint8 r, g, b, a; + for (int i = 0; i < surf->h; i++) { + for (int j = 0; j < surf->w; j++) { + uint32 pix = *(uint32 *)surf->getBasePtr(j, i); + surf->format.colorToARGB(pix, a, r, g, b); + if (a != 255) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ + _filename = filename; +// const Graphics::Surface *surface = image->getSurface(); + + if (defaultCK) { + ckRed = 255; + ckGreen = 0; + ckBlue = 255; + } + + _ckDefault = defaultCK; + _ckRed = ckRed; + _ckGreen = ckGreen; + _ckBlue = ckBlue; + + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + _lifeTime = lifeTime; + + _keepLoaded = keepLoaded; + if (_keepLoaded) _lifeTime = -1; + + return STATUS_OK; +} + +void CBSurfaceOSystem::finishLoad() { + CBImage *image = new CBImage(_gameRef); + image->loadFile(_filename); + + _width = image->getSurface()->w; + _height = image->getSurface()->h; + + bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); + /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ + } + + // no alpha, set color key + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + delete _surface; + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); + } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*image->getSurface()); + } + + _hasAlpha = hasTransparency(_surface); + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO + //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Surface-textures not fully ported yet"); + hasWarned = true; + } + //delete imgDecoder; +#if 0 + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!_texture) { + SDL_FreeSurface(surf); + delete imgDecoder; + return STATUS_FAILED; + } + + GenAlphaMask(surf); + + SDL_FreeSurface(surf); + delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. +#endif + + _valid = true; + + _gameRef->addMem(_width * _height * 4); + + delete image; + + _loaded = true; +} + +////////////////////////////////////////////////////////////////////////// +void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); + return; + + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) return; +#if 0 + SDL_LockSurface(surface); +#endif + bool hasColorKey; + /* uint32 colorKey; */ + uint8 ckRed, ckGreen, ckBlue; + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ //TODO + _alphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + uint32 pixel = getPixel(surface, x, y); + + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + a = 0; + + _alphaMask[y * surface->w + x] = a; + if (a < 255) hasTransparency = true; + } + } +#if 0 + SDL_UnlockSurface(surface); +#endif + if (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { + warning("CBSurfaceOSystem::GetPixel - Not ported yet"); + int bpp = surface->format.bytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(uint16 *)p; + break; + + case 3: +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + //else + return p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + return *(uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(int width, int height) { + warning("CBSurfaceOSystem::Create not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); +#endif + _width = width; + _height = height; + + _gameRef->addMem(_width * _height * 4); + + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); +#endif + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + _width = surface->w; + _height = surface->h; +#if 0 + _gameRef->AddMem(_width * _height * 4); +#endif + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAt(int x, int y) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); + hasWarned = true; + } +#if 0 + int access; + int width, height; + //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + + StartPixelOp(); + bool ret = isTransparentAtLite(X, Y); + EndPixelOp(); + + return ret; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { + //if (!_lockPixels) return false; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); + hasWarned = true; + } + if (_surface->format.bytesPerPixel == 4) { + uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); + uint8 r, g, b, a; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } +#if 0 + uint32 format; + int access; + int width, height; + + //SDL_QueryTexture(_texture, &format, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + if (!_alphaMask) return false; + else return _alphaMask[Y * width + X] <= 128; +#endif + return false; + /* + Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); + Uint32 pixel = dst[X]; + + SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); + SDL_FreeFormat(pixelFormat); + + return a <= 128; + */ +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::startPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::endPixelOp() { + //SDL_UnlockTexture(_texture); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + if (!_loaded) { + finishLoad(); + } + + if (renderer->_forceAlphaColor != 0) + alpha = renderer->_forceAlphaColor; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. + hasWarned = true; + } + + byte r = RGBCOLGetR(alpha); + byte g = RGBCOLGetG(alpha); + byte b = RGBCOLGetB(alpha); + byte a = RGBCOLGetA(alpha); + + renderer->setAlphaMod(a); + renderer->setColorMod(r, g, b); +#if 0 + SDL_SetTextureColorMod(_texture, r, g, b); + SDL_SetTextureAlphaMod(_texture, a); + + if (AlphaDisable) + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); + else + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = rect->left; + srcRect.top = rect->top; + srcRect.setWidth(rect->right - rect->left); + srcRect.setHeight(rect->bottom - rect->top); + + Common::Rect position; + position.left = x + offsetX; + position.top = y + offsetY; + // TODO: Scaling... + + if (position.left == -1) { + position.left = 0; // TODO: Something is wrong + } + if (position.top == -1) { + position.top = 0; // TODO: Something is wrong + } + + position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); + position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); + + renderer->modTargetRect(&position); + + /* position.left += offsetX; + position.top += offsetY;*/ + + // TODO: This actually requires us to have the SAME source-offsets every time, + // But no checking is in place for that yet. + + bool hasAlpha; + if (_hasAlpha && !alphaDisable) { + hasAlpha = true; + } else { + hasAlpha = false; + } + if (alphaDisable) { + warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); + } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); +#if 0 + SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); +#endif + + return STATUS_OK; +} + +bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; + _surface->copyFrom(surface); + _hasAlpha = hasAlpha; + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h new file mode 100644 index 0000000000..a5298706a3 --- /dev/null +++ b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h @@ -0,0 +1,101 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESDL_H +#define WINTERMUTE_BSURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" +#include "common/list.h" + +namespace WinterMute { +struct TransparentSurface; +class CBImage; +class CBSurfaceOSystem : public CBSurface { +public: + CBSurfaceOSystem(CBGame *inGame); + ~CBSurfaceOSystem(); + + bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(int width, int height); + + bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + + bool isTransparentAt(int x, int y); + bool isTransparentAtLite(int x, int y); + + bool startPixelOp(); + bool endPixelOp(); + + + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + virtual int getWidth() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->w; + } + return _width; + } + virtual int getHeight() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->h; + } + return _height; + } + +private: + Graphics::Surface *_surface; + bool _loaded; + void finishLoad(); + bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + void genAlphaMask(Graphics::Surface *surface); + uint32 getPixel(Graphics::Surface *surface, int x, int y); + + bool _hasAlpha; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index df656d13f6..b3834bf465 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRenderSDL.h" +#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/Base/BRegistry.h" @@ -88,7 +88,7 @@ void CBPlatform::handleEvent(Common::Event *event) { break; /*#ifdef __IPHONEOS__ { - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); POINT p; GetCursorPos(&p); _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); @@ -182,7 +182,7 @@ uint32 CBPlatform::getTime() { ////////////////////////////////////////////////////////////////////////// bool CBPlatform::getCursorPos(Point32 *lpPoint) { - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); lpPoint->x = p.x; @@ -195,7 +195,7 @@ bool CBPlatform::getCursorPos(Point32 *lpPoint) { ////////////////////////////////////////////////////////////////////////// bool CBPlatform::setCursorPos(int X, int Y) { - CBRenderSDL *renderer = static_cast(_gameRef->_renderer); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); Point32 p; p.x = X; diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 12e392a18f..31500f7863 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/Base/BSurface.h" +#include "engines/wintermute/Base/gfx/base_surface.h" #include "engines/wintermute/Base/BDynBuffer.h" #include "engines/wintermute/Base/BParser.h" #include "engines/wintermute/Base/BGame.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 56c82b6846..eab99e1eb5 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -46,6 +46,11 @@ MODULE_OBJS := \ Base/font/BFontTT.o \ Base/font/BFont.o \ Base/font/BFontStorage.o \ + Base/gfx/base_image.o \ + Base/gfx/base_renderer.o \ + Base/gfx/base_surface.o \ + Base/gfx/osystem/base_surface_osystem.o \ + Base/gfx/osystem/base_render_osystem.o \ Base/particles/PartParticle.o \ Base/particles/PartEmitter.o \ Base/particles/PartForce.o \ @@ -58,7 +63,6 @@ MODULE_OBJS := \ Base/BFileManager.o \ Base/BGame.o \ Base/BFrame.o \ - Base/BImage.o \ Base/BKeyboardState.o \ Base/BNamedObject.o \ Base/BObject.o \ @@ -69,8 +73,6 @@ MODULE_OBJS := \ Base/BQuickMsg.o \ Base/BRegion.o \ Base/BRegistry.o \ - Base/BRenderer.o \ - Base/BRenderSDL.o \ Base/BResources.o \ Base/BSaveThumbHelper.o \ Base/BScriptable.o \ @@ -81,8 +83,6 @@ MODULE_OBJS := \ Base/BSprite.o \ Base/BStringTable.o \ Base/BSubFrame.o \ - Base/BSurface.o \ - Base/BSurfaceSDL.o \ Base/BSurfaceStorage.o \ Base/BTransitionMgr.o \ Base/BViewport.o \ diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index d7e8850177..3bbd2172f7 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -32,7 +32,8 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/Base/BGame.h" #include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BSurfaceSDL.h" +#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/Base/gfx/base_image.h" #include "engines/wintermute/Base/BSoundMgr.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" @@ -155,7 +156,7 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: // Additional setup. _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); - _texture = new CBSurfaceSDL(_gameRef); + _texture = new CBSurfaceOSystem(_gameRef); _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 74fc0ce5b4..f403a82f64 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -31,14 +31,14 @@ #include "engines/wintermute/Base/BBase.h" #include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BSurface.h" -#include "engines/wintermute/Base/BImage.h" #include "engines/wintermute/persistent.h" #include "video/video_decoder.h" #include "common/stream.h" +#include "graphics/surface.h" namespace WinterMute { - +class CBSurface; +class CBImage; class CVidTheoraPlayer : public CBBase { private: enum { -- cgit v1.2.3 From 113961fd2a2203434b03766d722a0f8c0854bfd0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 19:29:15 +0200 Subject: WINTERMUTE: Change all folder-names to lowercase. --- engines/wintermute/Ad/AdActor.cpp | 1316 ------ engines/wintermute/Ad/AdActor.h | 107 - engines/wintermute/Ad/AdEntity.cpp | 1027 ----- engines/wintermute/Ad/AdEntity.h | 68 - engines/wintermute/Ad/AdGame.cpp | 2061 --------- engines/wintermute/Ad/AdGame.h | 161 - engines/wintermute/Ad/AdInventory.cpp | 119 - engines/wintermute/Ad/AdInventory.h | 52 - engines/wintermute/Ad/AdInventoryBox.cpp | 372 -- engines/wintermute/Ad/AdInventoryBox.h | 64 - engines/wintermute/Ad/AdItem.cpp | 760 ---- engines/wintermute/Ad/AdItem.h | 70 - engines/wintermute/Ad/AdLayer.cpp | 537 --- engines/wintermute/Ad/AdLayer.h | 58 - engines/wintermute/Ad/AdNodeState.cpp | 169 - engines/wintermute/Ad/AdNodeState.h | 58 - engines/wintermute/Ad/AdObject.cpp | 1203 ------ engines/wintermute/Ad/AdObject.h | 123 - engines/wintermute/Ad/AdPath.cpp | 112 - engines/wintermute/Ad/AdPath.h | 56 - engines/wintermute/Ad/AdPathPoint.cpp | 75 - engines/wintermute/Ad/AdPathPoint.h | 50 - engines/wintermute/Ad/AdRegion.cpp | 392 -- engines/wintermute/Ad/AdRegion.h | 58 - engines/wintermute/Ad/AdResponse.cpp | 143 - engines/wintermute/Ad/AdResponse.h | 61 - engines/wintermute/Ad/AdResponseBox.cpp | 647 --- engines/wintermute/Ad/AdResponseBox.h | 87 - engines/wintermute/Ad/AdResponseContext.cpp | 70 - engines/wintermute/Ad/AdResponseContext.h | 50 - engines/wintermute/Ad/AdRotLevel.cpp | 159 - engines/wintermute/Ad/AdRotLevel.h | 49 - engines/wintermute/Ad/AdScaleLevel.cpp | 157 - engines/wintermute/Ad/AdScaleLevel.h | 50 - engines/wintermute/Ad/AdScene.cpp | 2752 ------------ engines/wintermute/Ad/AdScene.h | 181 - engines/wintermute/Ad/AdSceneNode.cpp | 83 - engines/wintermute/Ad/AdSceneNode.h | 54 - engines/wintermute/Ad/AdSceneState.cpp | 88 - engines/wintermute/Ad/AdSceneState.h | 51 - engines/wintermute/Ad/AdSentence.cpp | 317 -- engines/wintermute/Ad/AdSentence.h | 85 - engines/wintermute/Ad/AdSpriteSet.cpp | 312 -- engines/wintermute/Ad/AdSpriteSet.h | 54 - engines/wintermute/Ad/AdTalkDef.cpp | 260 -- engines/wintermute/Ad/AdTalkDef.h | 58 - engines/wintermute/Ad/AdTalkHolder.cpp | 366 -- engines/wintermute/Ad/AdTalkHolder.h | 57 - engines/wintermute/Ad/AdTalkNode.cpp | 266 -- engines/wintermute/Ad/AdTalkNode.h | 63 - engines/wintermute/Ad/AdTypes.h | 107 - engines/wintermute/Ad/AdWaypointGroup.cpp | 261 -- engines/wintermute/Ad/AdWaypointGroup.h | 58 - engines/wintermute/Base/BActiveRect.cpp | 107 - engines/wintermute/Base/BActiveRect.h | 60 - engines/wintermute/Base/BBase.cpp | 178 - engines/wintermute/Base/BBase.h | 64 - engines/wintermute/Base/BDebugger.cpp | 203 - engines/wintermute/Base/BDebugger.h | 95 - engines/wintermute/Base/BDynBuffer.cpp | 192 - engines/wintermute/Base/BDynBuffer.h | 66 - engines/wintermute/Base/BFader.cpp | 176 - engines/wintermute/Base/BFader.h | 62 - engines/wintermute/Base/BFileEntry.cpp | 50 - engines/wintermute/Base/BFileEntry.h | 57 - engines/wintermute/Base/BFileManager.cpp | 737 ---- engines/wintermute/Base/BFileManager.h | 85 - engines/wintermute/Base/BFrame.cpp | 705 --- engines/wintermute/Base/BFrame.h | 73 - engines/wintermute/Base/BGame.cpp | 4478 -------------------- engines/wintermute/Base/BGame.h | 391 -- engines/wintermute/Base/BKeyboardState.cpp | 304 -- engines/wintermute/Base/BKeyboardState.h | 75 - engines/wintermute/Base/BNamedObject.cpp | 65 - engines/wintermute/Base/BNamedObject.h | 50 - engines/wintermute/Base/BObject.cpp | 1128 ----- engines/wintermute/Base/BObject.h | 144 - engines/wintermute/Base/BPackage.cpp | 104 - engines/wintermute/Base/BPackage.h | 61 - engines/wintermute/Base/BParser.cpp | 436 -- engines/wintermute/Base/BParser.h | 89 - engines/wintermute/Base/BPersistMgr.cpp | 778 ---- engines/wintermute/Base/BPersistMgr.h | 114 - engines/wintermute/Base/BPoint.cpp | 64 - engines/wintermute/Base/BPoint.h | 50 - engines/wintermute/Base/BQuickMsg.cpp | 54 - engines/wintermute/Base/BQuickMsg.h | 48 - engines/wintermute/Base/BRegion.cpp | 508 --- engines/wintermute/Base/BRegion.h | 68 - engines/wintermute/Base/BRegistry.cpp | 257 -- engines/wintermute/Base/BRegistry.h | 76 - engines/wintermute/Base/BResources.cpp | 2820 ------------ engines/wintermute/Base/BResources.h | 44 - engines/wintermute/Base/BSaveThumbHelper.cpp | 79 - engines/wintermute/Base/BSaveThumbHelper.h | 50 - engines/wintermute/Base/BScriptHolder.cpp | 473 --- engines/wintermute/Base/BScriptHolder.h | 74 - engines/wintermute/Base/BScriptable.cpp | 188 - engines/wintermute/Base/BScriptable.h | 90 - engines/wintermute/Base/BSound.cpp | 288 -- engines/wintermute/Base/BSound.h | 88 - engines/wintermute/Base/BSoundBuffer.cpp | 383 -- engines/wintermute/Base/BSoundBuffer.h | 100 - engines/wintermute/Base/BSoundMgr.cpp | 292 -- engines/wintermute/Base/BSoundMgr.h | 69 - engines/wintermute/Base/BSprite.cpp | 758 ---- engines/wintermute/Base/BSprite.h | 90 - engines/wintermute/Base/BStringTable.cpp | 229 - engines/wintermute/Base/BStringTable.h | 55 - engines/wintermute/Base/BSubFrame.cpp | 589 --- engines/wintermute/Base/BSubFrame.h | 86 - engines/wintermute/Base/BSurfaceStorage.cpp | 189 - engines/wintermute/Base/BSurfaceStorage.h | 57 - engines/wintermute/Base/BTransitionMgr.cpp | 131 - engines/wintermute/Base/BTransitionMgr.h | 54 - engines/wintermute/Base/BViewport.cpp | 98 - engines/wintermute/Base/BViewport.h | 55 - engines/wintermute/Base/file/BDiskFile.cpp | 131 - engines/wintermute/Base/file/BDiskFile.h | 42 - engines/wintermute/Base/file/BFile.cpp | 69 - engines/wintermute/Base/file/BFile.h | 67 - engines/wintermute/Base/file/BPkgFile.cpp | 105 - engines/wintermute/Base/file/BPkgFile.h | 46 - engines/wintermute/Base/file/BSaveThumbFile.cpp | 146 - engines/wintermute/Base/file/BSaveThumbFile.h | 52 - engines/wintermute/Base/font/BFont.cpp | 206 - engines/wintermute/Base/font/BFont.h | 61 - engines/wintermute/Base/font/BFontBitmap.cpp | 540 --- engines/wintermute/Base/font/BFontBitmap.h | 72 - engines/wintermute/Base/font/BFontStorage.cpp | 135 - engines/wintermute/Base/font/BFontStorage.h | 55 - engines/wintermute/Base/font/BFontTT.cpp | 762 ---- engines/wintermute/Base/font/BFontTT.h | 180 - engines/wintermute/Base/gfx/base_image.cpp | 269 -- engines/wintermute/Base/gfx/base_image.h | 74 - engines/wintermute/Base/gfx/base_renderer.cpp | 257 -- engines/wintermute/Base/gfx/base_renderer.h | 128 - engines/wintermute/Base/gfx/base_surface.cpp | 152 - engines/wintermute/Base/gfx/base_surface.h | 99 - .../Base/gfx/osystem/base_render_osystem.cpp | 701 --- .../Base/gfx/osystem/base_render_osystem.h | 129 - .../Base/gfx/osystem/base_surface_osystem.cpp | 532 --- .../Base/gfx/osystem/base_surface_osystem.h | 101 - engines/wintermute/Base/particles/PartEmitter.cpp | 1199 ------ engines/wintermute/Base/particles/PartEmitter.h | 139 - engines/wintermute/Base/particles/PartForce.cpp | 59 - engines/wintermute/Base/particles/PartForce.h | 57 - engines/wintermute/Base/particles/PartParticle.cpp | 257 -- engines/wintermute/Base/particles/PartParticle.h | 90 - engines/wintermute/Base/scriptables/SXArray.cpp | 238 -- engines/wintermute/Base/scriptables/SXArray.h | 54 - engines/wintermute/Base/scriptables/SXDate.cpp | 297 -- engines/wintermute/Base/scriptables/SXDate.h | 55 - engines/wintermute/Base/scriptables/SXFile.cpp | 779 ---- engines/wintermute/Base/scriptables/SXFile.h | 66 - engines/wintermute/Base/scriptables/SXMath.cpp | 295 -- engines/wintermute/Base/scriptables/SXMath.h | 53 - .../wintermute/Base/scriptables/SXMemBuffer.cpp | 508 --- engines/wintermute/Base/scriptables/SXMemBuffer.h | 59 - engines/wintermute/Base/scriptables/SXString.cpp | 404 -- engines/wintermute/Base/scriptables/SXString.h | 58 - engines/wintermute/Base/scriptables/ScEngine.cpp | 712 ---- engines/wintermute/Base/scriptables/ScEngine.h | 147 - engines/wintermute/Base/scriptables/ScScript.cpp | 1461 ------- engines/wintermute/Base/scriptables/ScScript.h | 183 - engines/wintermute/Base/scriptables/ScStack.cpp | 226 - engines/wintermute/Base/scriptables/ScStack.h | 66 - engines/wintermute/Base/scriptables/ScValue.cpp | 1054 ----- engines/wintermute/Base/scriptables/ScValue.h | 141 - engines/wintermute/Base/scriptables/SxObject.cpp | 67 - engines/wintermute/Base/scriptables/SxObject.h | 47 - engines/wintermute/PlatformSDL.cpp | 10 +- engines/wintermute/Sys/SysClass.cpp | 211 - engines/wintermute/Sys/SysClass.h | 130 - engines/wintermute/Sys/SysClassRegistry.cpp | 314 -- engines/wintermute/Sys/SysClassRegistry.h | 106 - engines/wintermute/Sys/SysInstance.cpp | 49 - engines/wintermute/Sys/SysInstance.h | 68 - engines/wintermute/UI/UIButton.cpp | 1046 ----- engines/wintermute/UI/UIButton.h | 79 - engines/wintermute/UI/UIEdit.cpp | 857 ---- engines/wintermute/UI/UIEdit.h | 72 - engines/wintermute/UI/UIEntity.cpp | 339 -- engines/wintermute/UI/UIEntity.h | 58 - engines/wintermute/UI/UIObject.cpp | 589 --- engines/wintermute/UI/UIObject.h | 83 - engines/wintermute/UI/UIText.cpp | 489 --- engines/wintermute/UI/UIText.h | 60 - engines/wintermute/UI/UITiledImage.cpp | 370 -- engines/wintermute/UI/UITiledImage.h | 63 - engines/wintermute/UI/UIWindow.cpp | 1327 ------ engines/wintermute/UI/UIWindow.h | 93 - engines/wintermute/ad/AdActor.cpp | 1316 ++++++ engines/wintermute/ad/AdActor.h | 107 + engines/wintermute/ad/AdEntity.cpp | 1027 +++++ engines/wintermute/ad/AdEntity.h | 68 + engines/wintermute/ad/AdGame.cpp | 2061 +++++++++ engines/wintermute/ad/AdGame.h | 161 + engines/wintermute/ad/AdInventory.cpp | 119 + engines/wintermute/ad/AdInventory.h | 52 + engines/wintermute/ad/AdInventoryBox.cpp | 372 ++ engines/wintermute/ad/AdInventoryBox.h | 64 + engines/wintermute/ad/AdItem.cpp | 760 ++++ engines/wintermute/ad/AdItem.h | 70 + engines/wintermute/ad/AdLayer.cpp | 537 +++ engines/wintermute/ad/AdLayer.h | 58 + engines/wintermute/ad/AdNodeState.cpp | 169 + engines/wintermute/ad/AdNodeState.h | 58 + engines/wintermute/ad/AdObject.cpp | 1203 ++++++ engines/wintermute/ad/AdObject.h | 123 + engines/wintermute/ad/AdPath.cpp | 112 + engines/wintermute/ad/AdPath.h | 56 + engines/wintermute/ad/AdPathPoint.cpp | 75 + engines/wintermute/ad/AdPathPoint.h | 50 + engines/wintermute/ad/AdRegion.cpp | 392 ++ engines/wintermute/ad/AdRegion.h | 58 + engines/wintermute/ad/AdResponse.cpp | 143 + engines/wintermute/ad/AdResponse.h | 61 + engines/wintermute/ad/AdResponseBox.cpp | 647 +++ engines/wintermute/ad/AdResponseBox.h | 87 + engines/wintermute/ad/AdResponseContext.cpp | 70 + engines/wintermute/ad/AdResponseContext.h | 50 + engines/wintermute/ad/AdRotLevel.cpp | 159 + engines/wintermute/ad/AdRotLevel.h | 49 + engines/wintermute/ad/AdScaleLevel.cpp | 157 + engines/wintermute/ad/AdScaleLevel.h | 50 + engines/wintermute/ad/AdScene.cpp | 2752 ++++++++++++ engines/wintermute/ad/AdScene.h | 181 + engines/wintermute/ad/AdSceneNode.cpp | 83 + engines/wintermute/ad/AdSceneNode.h | 54 + engines/wintermute/ad/AdSceneState.cpp | 88 + engines/wintermute/ad/AdSceneState.h | 51 + engines/wintermute/ad/AdSentence.cpp | 317 ++ engines/wintermute/ad/AdSentence.h | 85 + engines/wintermute/ad/AdSpriteSet.cpp | 312 ++ engines/wintermute/ad/AdSpriteSet.h | 54 + engines/wintermute/ad/AdTalkDef.cpp | 260 ++ engines/wintermute/ad/AdTalkDef.h | 58 + engines/wintermute/ad/AdTalkHolder.cpp | 366 ++ engines/wintermute/ad/AdTalkHolder.h | 57 + engines/wintermute/ad/AdTalkNode.cpp | 266 ++ engines/wintermute/ad/AdTalkNode.h | 63 + engines/wintermute/ad/AdTypes.h | 107 + engines/wintermute/ad/AdWaypointGroup.cpp | 261 ++ engines/wintermute/ad/AdWaypointGroup.h | 58 + engines/wintermute/base/BActiveRect.cpp | 107 + engines/wintermute/base/BActiveRect.h | 60 + engines/wintermute/base/BBase.cpp | 178 + engines/wintermute/base/BBase.h | 64 + engines/wintermute/base/BDebugger.cpp | 203 + engines/wintermute/base/BDebugger.h | 95 + engines/wintermute/base/BDynBuffer.cpp | 192 + engines/wintermute/base/BDynBuffer.h | 66 + engines/wintermute/base/BFader.cpp | 176 + engines/wintermute/base/BFader.h | 62 + engines/wintermute/base/BFileEntry.cpp | 50 + engines/wintermute/base/BFileEntry.h | 57 + engines/wintermute/base/BFileManager.cpp | 737 ++++ engines/wintermute/base/BFileManager.h | 85 + engines/wintermute/base/BFrame.cpp | 705 +++ engines/wintermute/base/BFrame.h | 73 + engines/wintermute/base/BGame.cpp | 4478 ++++++++++++++++++++ engines/wintermute/base/BGame.h | 391 ++ engines/wintermute/base/BKeyboardState.cpp | 304 ++ engines/wintermute/base/BKeyboardState.h | 75 + engines/wintermute/base/BNamedObject.cpp | 65 + engines/wintermute/base/BNamedObject.h | 50 + engines/wintermute/base/BObject.cpp | 1128 +++++ engines/wintermute/base/BObject.h | 144 + engines/wintermute/base/BPackage.cpp | 104 + engines/wintermute/base/BPackage.h | 61 + engines/wintermute/base/BParser.cpp | 436 ++ engines/wintermute/base/BParser.h | 89 + engines/wintermute/base/BPersistMgr.cpp | 778 ++++ engines/wintermute/base/BPersistMgr.h | 114 + engines/wintermute/base/BPoint.cpp | 64 + engines/wintermute/base/BPoint.h | 50 + engines/wintermute/base/BQuickMsg.cpp | 54 + engines/wintermute/base/BQuickMsg.h | 48 + engines/wintermute/base/BRegion.cpp | 508 +++ engines/wintermute/base/BRegion.h | 68 + engines/wintermute/base/BRegistry.cpp | 257 ++ engines/wintermute/base/BRegistry.h | 76 + engines/wintermute/base/BResources.cpp | 2820 ++++++++++++ engines/wintermute/base/BResources.h | 44 + engines/wintermute/base/BSaveThumbHelper.cpp | 79 + engines/wintermute/base/BSaveThumbHelper.h | 50 + engines/wintermute/base/BScriptHolder.cpp | 473 +++ engines/wintermute/base/BScriptHolder.h | 74 + engines/wintermute/base/BScriptable.cpp | 188 + engines/wintermute/base/BScriptable.h | 90 + engines/wintermute/base/BSound.cpp | 288 ++ engines/wintermute/base/BSound.h | 88 + engines/wintermute/base/BSoundBuffer.cpp | 383 ++ engines/wintermute/base/BSoundBuffer.h | 100 + engines/wintermute/base/BSoundMgr.cpp | 292 ++ engines/wintermute/base/BSoundMgr.h | 69 + engines/wintermute/base/BSprite.cpp | 758 ++++ engines/wintermute/base/BSprite.h | 90 + engines/wintermute/base/BStringTable.cpp | 229 + engines/wintermute/base/BStringTable.h | 55 + engines/wintermute/base/BSubFrame.cpp | 589 +++ engines/wintermute/base/BSubFrame.h | 86 + engines/wintermute/base/BSurfaceStorage.cpp | 189 + engines/wintermute/base/BSurfaceStorage.h | 57 + engines/wintermute/base/BTransitionMgr.cpp | 131 + engines/wintermute/base/BTransitionMgr.h | 54 + engines/wintermute/base/BViewport.cpp | 98 + engines/wintermute/base/BViewport.h | 55 + engines/wintermute/base/file/BDiskFile.cpp | 131 + engines/wintermute/base/file/BDiskFile.h | 42 + engines/wintermute/base/file/BFile.cpp | 69 + engines/wintermute/base/file/BFile.h | 67 + engines/wintermute/base/file/BPkgFile.cpp | 105 + engines/wintermute/base/file/BPkgFile.h | 46 + engines/wintermute/base/file/BSaveThumbFile.cpp | 146 + engines/wintermute/base/file/BSaveThumbFile.h | 52 + engines/wintermute/base/font/BFont.cpp | 206 + engines/wintermute/base/font/BFont.h | 61 + engines/wintermute/base/font/BFontBitmap.cpp | 540 +++ engines/wintermute/base/font/BFontBitmap.h | 72 + engines/wintermute/base/font/BFontStorage.cpp | 135 + engines/wintermute/base/font/BFontStorage.h | 55 + engines/wintermute/base/font/BFontTT.cpp | 762 ++++ engines/wintermute/base/font/BFontTT.h | 180 + engines/wintermute/base/gfx/base_image.cpp | 269 ++ engines/wintermute/base/gfx/base_image.h | 74 + engines/wintermute/base/gfx/base_renderer.cpp | 257 ++ engines/wintermute/base/gfx/base_renderer.h | 128 + engines/wintermute/base/gfx/base_surface.cpp | 152 + engines/wintermute/base/gfx/base_surface.h | 99 + .../base/gfx/osystem/base_render_osystem.cpp | 701 +++ .../base/gfx/osystem/base_render_osystem.h | 129 + .../base/gfx/osystem/base_surface_osystem.cpp | 532 +++ .../base/gfx/osystem/base_surface_osystem.h | 101 + engines/wintermute/base/particles/PartEmitter.cpp | 1199 ++++++ engines/wintermute/base/particles/PartEmitter.h | 139 + engines/wintermute/base/particles/PartForce.cpp | 59 + engines/wintermute/base/particles/PartForce.h | 57 + engines/wintermute/base/particles/PartParticle.cpp | 257 ++ engines/wintermute/base/particles/PartParticle.h | 90 + engines/wintermute/base/scriptables/SXArray.cpp | 238 ++ engines/wintermute/base/scriptables/SXArray.h | 54 + engines/wintermute/base/scriptables/SXDate.cpp | 297 ++ engines/wintermute/base/scriptables/SXDate.h | 55 + engines/wintermute/base/scriptables/SXFile.cpp | 779 ++++ engines/wintermute/base/scriptables/SXFile.h | 66 + engines/wintermute/base/scriptables/SXMath.cpp | 295 ++ engines/wintermute/base/scriptables/SXMath.h | 53 + .../wintermute/base/scriptables/SXMemBuffer.cpp | 508 +++ engines/wintermute/base/scriptables/SXMemBuffer.h | 59 + engines/wintermute/base/scriptables/SXString.cpp | 404 ++ engines/wintermute/base/scriptables/SXString.h | 58 + engines/wintermute/base/scriptables/ScEngine.cpp | 712 ++++ engines/wintermute/base/scriptables/ScEngine.h | 147 + engines/wintermute/base/scriptables/ScScript.cpp | 1461 +++++++ engines/wintermute/base/scriptables/ScScript.h | 183 + engines/wintermute/base/scriptables/ScStack.cpp | 226 + engines/wintermute/base/scriptables/ScStack.h | 66 + engines/wintermute/base/scriptables/ScValue.cpp | 1054 +++++ engines/wintermute/base/scriptables/ScValue.h | 141 + engines/wintermute/base/scriptables/SxObject.cpp | 67 + engines/wintermute/base/scriptables/SxObject.h | 47 + engines/wintermute/coll_templ.h | 2 +- engines/wintermute/detection.cpp | 2 +- engines/wintermute/module.mk | 190 +- engines/wintermute/persistent.cpp | 118 +- engines/wintermute/persistent.h | 4 +- engines/wintermute/system/SysClass.cpp | 211 + engines/wintermute/system/SysClass.h | 130 + engines/wintermute/system/SysClassRegistry.cpp | 314 ++ engines/wintermute/system/SysClassRegistry.h | 106 + engines/wintermute/system/SysInstance.cpp | 49 + engines/wintermute/system/SysInstance.h | 68 + engines/wintermute/ui/UIButton.cpp | 1046 +++++ engines/wintermute/ui/UIButton.h | 79 + engines/wintermute/ui/UIEdit.cpp | 857 ++++ engines/wintermute/ui/UIEdit.h | 72 + engines/wintermute/ui/UIEntity.cpp | 339 ++ engines/wintermute/ui/UIEntity.h | 58 + engines/wintermute/ui/UIObject.cpp | 589 +++ engines/wintermute/ui/UIObject.h | 83 + engines/wintermute/ui/UIText.cpp | 489 +++ engines/wintermute/ui/UIText.h | 60 + engines/wintermute/ui/UITiledImage.cpp | 370 ++ engines/wintermute/ui/UITiledImage.h | 63 + engines/wintermute/ui/UIWindow.cpp | 1327 ++++++ engines/wintermute/ui/UIWindow.h | 93 + engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/video/VidPlayer.h | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 12 +- engines/wintermute/video/VidTheoraPlayer.h | 4 +- engines/wintermute/wintermute.cpp | 8 +- 393 files changed, 56157 insertions(+), 56157 deletions(-) delete mode 100644 engines/wintermute/Ad/AdActor.cpp delete mode 100644 engines/wintermute/Ad/AdActor.h delete mode 100644 engines/wintermute/Ad/AdEntity.cpp delete mode 100644 engines/wintermute/Ad/AdEntity.h delete mode 100644 engines/wintermute/Ad/AdGame.cpp delete mode 100644 engines/wintermute/Ad/AdGame.h delete mode 100644 engines/wintermute/Ad/AdInventory.cpp delete mode 100644 engines/wintermute/Ad/AdInventory.h delete mode 100644 engines/wintermute/Ad/AdInventoryBox.cpp delete mode 100644 engines/wintermute/Ad/AdInventoryBox.h delete mode 100644 engines/wintermute/Ad/AdItem.cpp delete mode 100644 engines/wintermute/Ad/AdItem.h delete mode 100644 engines/wintermute/Ad/AdLayer.cpp delete mode 100644 engines/wintermute/Ad/AdLayer.h delete mode 100644 engines/wintermute/Ad/AdNodeState.cpp delete mode 100644 engines/wintermute/Ad/AdNodeState.h delete mode 100644 engines/wintermute/Ad/AdObject.cpp delete mode 100644 engines/wintermute/Ad/AdObject.h delete mode 100644 engines/wintermute/Ad/AdPath.cpp delete mode 100644 engines/wintermute/Ad/AdPath.h delete mode 100644 engines/wintermute/Ad/AdPathPoint.cpp delete mode 100644 engines/wintermute/Ad/AdPathPoint.h delete mode 100644 engines/wintermute/Ad/AdRegion.cpp delete mode 100644 engines/wintermute/Ad/AdRegion.h delete mode 100644 engines/wintermute/Ad/AdResponse.cpp delete mode 100644 engines/wintermute/Ad/AdResponse.h delete mode 100644 engines/wintermute/Ad/AdResponseBox.cpp delete mode 100644 engines/wintermute/Ad/AdResponseBox.h delete mode 100644 engines/wintermute/Ad/AdResponseContext.cpp delete mode 100644 engines/wintermute/Ad/AdResponseContext.h delete mode 100644 engines/wintermute/Ad/AdRotLevel.cpp delete mode 100644 engines/wintermute/Ad/AdRotLevel.h delete mode 100644 engines/wintermute/Ad/AdScaleLevel.cpp delete mode 100644 engines/wintermute/Ad/AdScaleLevel.h delete mode 100644 engines/wintermute/Ad/AdScene.cpp delete mode 100644 engines/wintermute/Ad/AdScene.h delete mode 100644 engines/wintermute/Ad/AdSceneNode.cpp delete mode 100644 engines/wintermute/Ad/AdSceneNode.h delete mode 100644 engines/wintermute/Ad/AdSceneState.cpp delete mode 100644 engines/wintermute/Ad/AdSceneState.h delete mode 100644 engines/wintermute/Ad/AdSentence.cpp delete mode 100644 engines/wintermute/Ad/AdSentence.h delete mode 100644 engines/wintermute/Ad/AdSpriteSet.cpp delete mode 100644 engines/wintermute/Ad/AdSpriteSet.h delete mode 100644 engines/wintermute/Ad/AdTalkDef.cpp delete mode 100644 engines/wintermute/Ad/AdTalkDef.h delete mode 100644 engines/wintermute/Ad/AdTalkHolder.cpp delete mode 100644 engines/wintermute/Ad/AdTalkHolder.h delete mode 100644 engines/wintermute/Ad/AdTalkNode.cpp delete mode 100644 engines/wintermute/Ad/AdTalkNode.h delete mode 100644 engines/wintermute/Ad/AdTypes.h delete mode 100644 engines/wintermute/Ad/AdWaypointGroup.cpp delete mode 100644 engines/wintermute/Ad/AdWaypointGroup.h delete mode 100644 engines/wintermute/Base/BActiveRect.cpp delete mode 100644 engines/wintermute/Base/BActiveRect.h delete mode 100644 engines/wintermute/Base/BBase.cpp delete mode 100644 engines/wintermute/Base/BBase.h delete mode 100644 engines/wintermute/Base/BDebugger.cpp delete mode 100644 engines/wintermute/Base/BDebugger.h delete mode 100644 engines/wintermute/Base/BDynBuffer.cpp delete mode 100644 engines/wintermute/Base/BDynBuffer.h delete mode 100644 engines/wintermute/Base/BFader.cpp delete mode 100644 engines/wintermute/Base/BFader.h delete mode 100644 engines/wintermute/Base/BFileEntry.cpp delete mode 100644 engines/wintermute/Base/BFileEntry.h delete mode 100644 engines/wintermute/Base/BFileManager.cpp delete mode 100644 engines/wintermute/Base/BFileManager.h delete mode 100644 engines/wintermute/Base/BFrame.cpp delete mode 100644 engines/wintermute/Base/BFrame.h delete mode 100644 engines/wintermute/Base/BGame.cpp delete mode 100644 engines/wintermute/Base/BGame.h delete mode 100644 engines/wintermute/Base/BKeyboardState.cpp delete mode 100644 engines/wintermute/Base/BKeyboardState.h delete mode 100644 engines/wintermute/Base/BNamedObject.cpp delete mode 100644 engines/wintermute/Base/BNamedObject.h delete mode 100644 engines/wintermute/Base/BObject.cpp delete mode 100644 engines/wintermute/Base/BObject.h delete mode 100644 engines/wintermute/Base/BPackage.cpp delete mode 100644 engines/wintermute/Base/BPackage.h delete mode 100644 engines/wintermute/Base/BParser.cpp delete mode 100644 engines/wintermute/Base/BParser.h delete mode 100644 engines/wintermute/Base/BPersistMgr.cpp delete mode 100644 engines/wintermute/Base/BPersistMgr.h delete mode 100644 engines/wintermute/Base/BPoint.cpp delete mode 100644 engines/wintermute/Base/BPoint.h delete mode 100644 engines/wintermute/Base/BQuickMsg.cpp delete mode 100644 engines/wintermute/Base/BQuickMsg.h delete mode 100644 engines/wintermute/Base/BRegion.cpp delete mode 100644 engines/wintermute/Base/BRegion.h delete mode 100644 engines/wintermute/Base/BRegistry.cpp delete mode 100644 engines/wintermute/Base/BRegistry.h delete mode 100644 engines/wintermute/Base/BResources.cpp delete mode 100644 engines/wintermute/Base/BResources.h delete mode 100644 engines/wintermute/Base/BSaveThumbHelper.cpp delete mode 100644 engines/wintermute/Base/BSaveThumbHelper.h delete mode 100644 engines/wintermute/Base/BScriptHolder.cpp delete mode 100644 engines/wintermute/Base/BScriptHolder.h delete mode 100644 engines/wintermute/Base/BScriptable.cpp delete mode 100644 engines/wintermute/Base/BScriptable.h delete mode 100644 engines/wintermute/Base/BSound.cpp delete mode 100644 engines/wintermute/Base/BSound.h delete mode 100644 engines/wintermute/Base/BSoundBuffer.cpp delete mode 100644 engines/wintermute/Base/BSoundBuffer.h delete mode 100644 engines/wintermute/Base/BSoundMgr.cpp delete mode 100644 engines/wintermute/Base/BSoundMgr.h delete mode 100644 engines/wintermute/Base/BSprite.cpp delete mode 100644 engines/wintermute/Base/BSprite.h delete mode 100644 engines/wintermute/Base/BStringTable.cpp delete mode 100644 engines/wintermute/Base/BStringTable.h delete mode 100644 engines/wintermute/Base/BSubFrame.cpp delete mode 100644 engines/wintermute/Base/BSubFrame.h delete mode 100644 engines/wintermute/Base/BSurfaceStorage.cpp delete mode 100644 engines/wintermute/Base/BSurfaceStorage.h delete mode 100644 engines/wintermute/Base/BTransitionMgr.cpp delete mode 100644 engines/wintermute/Base/BTransitionMgr.h delete mode 100644 engines/wintermute/Base/BViewport.cpp delete mode 100644 engines/wintermute/Base/BViewport.h delete mode 100644 engines/wintermute/Base/file/BDiskFile.cpp delete mode 100644 engines/wintermute/Base/file/BDiskFile.h delete mode 100644 engines/wintermute/Base/file/BFile.cpp delete mode 100644 engines/wintermute/Base/file/BFile.h delete mode 100644 engines/wintermute/Base/file/BPkgFile.cpp delete mode 100644 engines/wintermute/Base/file/BPkgFile.h delete mode 100644 engines/wintermute/Base/file/BSaveThumbFile.cpp delete mode 100644 engines/wintermute/Base/file/BSaveThumbFile.h delete mode 100644 engines/wintermute/Base/font/BFont.cpp delete mode 100644 engines/wintermute/Base/font/BFont.h delete mode 100644 engines/wintermute/Base/font/BFontBitmap.cpp delete mode 100644 engines/wintermute/Base/font/BFontBitmap.h delete mode 100644 engines/wintermute/Base/font/BFontStorage.cpp delete mode 100644 engines/wintermute/Base/font/BFontStorage.h delete mode 100644 engines/wintermute/Base/font/BFontTT.cpp delete mode 100644 engines/wintermute/Base/font/BFontTT.h delete mode 100644 engines/wintermute/Base/gfx/base_image.cpp delete mode 100644 engines/wintermute/Base/gfx/base_image.h delete mode 100644 engines/wintermute/Base/gfx/base_renderer.cpp delete mode 100644 engines/wintermute/Base/gfx/base_renderer.h delete mode 100644 engines/wintermute/Base/gfx/base_surface.cpp delete mode 100644 engines/wintermute/Base/gfx/base_surface.h delete mode 100644 engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp delete mode 100644 engines/wintermute/Base/gfx/osystem/base_render_osystem.h delete mode 100644 engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp delete mode 100644 engines/wintermute/Base/gfx/osystem/base_surface_osystem.h delete mode 100644 engines/wintermute/Base/particles/PartEmitter.cpp delete mode 100644 engines/wintermute/Base/particles/PartEmitter.h delete mode 100644 engines/wintermute/Base/particles/PartForce.cpp delete mode 100644 engines/wintermute/Base/particles/PartForce.h delete mode 100644 engines/wintermute/Base/particles/PartParticle.cpp delete mode 100644 engines/wintermute/Base/particles/PartParticle.h delete mode 100644 engines/wintermute/Base/scriptables/SXArray.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXArray.h delete mode 100644 engines/wintermute/Base/scriptables/SXDate.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXDate.h delete mode 100644 engines/wintermute/Base/scriptables/SXFile.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXFile.h delete mode 100644 engines/wintermute/Base/scriptables/SXMath.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXMath.h delete mode 100644 engines/wintermute/Base/scriptables/SXMemBuffer.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXMemBuffer.h delete mode 100644 engines/wintermute/Base/scriptables/SXString.cpp delete mode 100644 engines/wintermute/Base/scriptables/SXString.h delete mode 100644 engines/wintermute/Base/scriptables/ScEngine.cpp delete mode 100644 engines/wintermute/Base/scriptables/ScEngine.h delete mode 100644 engines/wintermute/Base/scriptables/ScScript.cpp delete mode 100644 engines/wintermute/Base/scriptables/ScScript.h delete mode 100644 engines/wintermute/Base/scriptables/ScStack.cpp delete mode 100644 engines/wintermute/Base/scriptables/ScStack.h delete mode 100644 engines/wintermute/Base/scriptables/ScValue.cpp delete mode 100644 engines/wintermute/Base/scriptables/ScValue.h delete mode 100644 engines/wintermute/Base/scriptables/SxObject.cpp delete mode 100644 engines/wintermute/Base/scriptables/SxObject.h delete mode 100644 engines/wintermute/Sys/SysClass.cpp delete mode 100644 engines/wintermute/Sys/SysClass.h delete mode 100644 engines/wintermute/Sys/SysClassRegistry.cpp delete mode 100644 engines/wintermute/Sys/SysClassRegistry.h delete mode 100644 engines/wintermute/Sys/SysInstance.cpp delete mode 100644 engines/wintermute/Sys/SysInstance.h delete mode 100644 engines/wintermute/UI/UIButton.cpp delete mode 100644 engines/wintermute/UI/UIButton.h delete mode 100644 engines/wintermute/UI/UIEdit.cpp delete mode 100644 engines/wintermute/UI/UIEdit.h delete mode 100644 engines/wintermute/UI/UIEntity.cpp delete mode 100644 engines/wintermute/UI/UIEntity.h delete mode 100644 engines/wintermute/UI/UIObject.cpp delete mode 100644 engines/wintermute/UI/UIObject.h delete mode 100644 engines/wintermute/UI/UIText.cpp delete mode 100644 engines/wintermute/UI/UIText.h delete mode 100644 engines/wintermute/UI/UITiledImage.cpp delete mode 100644 engines/wintermute/UI/UITiledImage.h delete mode 100644 engines/wintermute/UI/UIWindow.cpp delete mode 100644 engines/wintermute/UI/UIWindow.h create mode 100644 engines/wintermute/ad/AdActor.cpp create mode 100644 engines/wintermute/ad/AdActor.h create mode 100644 engines/wintermute/ad/AdEntity.cpp create mode 100644 engines/wintermute/ad/AdEntity.h create mode 100644 engines/wintermute/ad/AdGame.cpp create mode 100644 engines/wintermute/ad/AdGame.h create mode 100644 engines/wintermute/ad/AdInventory.cpp create mode 100644 engines/wintermute/ad/AdInventory.h create mode 100644 engines/wintermute/ad/AdInventoryBox.cpp create mode 100644 engines/wintermute/ad/AdInventoryBox.h create mode 100644 engines/wintermute/ad/AdItem.cpp create mode 100644 engines/wintermute/ad/AdItem.h create mode 100644 engines/wintermute/ad/AdLayer.cpp create mode 100644 engines/wintermute/ad/AdLayer.h create mode 100644 engines/wintermute/ad/AdNodeState.cpp create mode 100644 engines/wintermute/ad/AdNodeState.h create mode 100644 engines/wintermute/ad/AdObject.cpp create mode 100644 engines/wintermute/ad/AdObject.h create mode 100644 engines/wintermute/ad/AdPath.cpp create mode 100644 engines/wintermute/ad/AdPath.h create mode 100644 engines/wintermute/ad/AdPathPoint.cpp create mode 100644 engines/wintermute/ad/AdPathPoint.h create mode 100644 engines/wintermute/ad/AdRegion.cpp create mode 100644 engines/wintermute/ad/AdRegion.h create mode 100644 engines/wintermute/ad/AdResponse.cpp create mode 100644 engines/wintermute/ad/AdResponse.h create mode 100644 engines/wintermute/ad/AdResponseBox.cpp create mode 100644 engines/wintermute/ad/AdResponseBox.h create mode 100644 engines/wintermute/ad/AdResponseContext.cpp create mode 100644 engines/wintermute/ad/AdResponseContext.h create mode 100644 engines/wintermute/ad/AdRotLevel.cpp create mode 100644 engines/wintermute/ad/AdRotLevel.h create mode 100644 engines/wintermute/ad/AdScaleLevel.cpp create mode 100644 engines/wintermute/ad/AdScaleLevel.h create mode 100644 engines/wintermute/ad/AdScene.cpp create mode 100644 engines/wintermute/ad/AdScene.h create mode 100644 engines/wintermute/ad/AdSceneNode.cpp create mode 100644 engines/wintermute/ad/AdSceneNode.h create mode 100644 engines/wintermute/ad/AdSceneState.cpp create mode 100644 engines/wintermute/ad/AdSceneState.h create mode 100644 engines/wintermute/ad/AdSentence.cpp create mode 100644 engines/wintermute/ad/AdSentence.h create mode 100644 engines/wintermute/ad/AdSpriteSet.cpp create mode 100644 engines/wintermute/ad/AdSpriteSet.h create mode 100644 engines/wintermute/ad/AdTalkDef.cpp create mode 100644 engines/wintermute/ad/AdTalkDef.h create mode 100644 engines/wintermute/ad/AdTalkHolder.cpp create mode 100644 engines/wintermute/ad/AdTalkHolder.h create mode 100644 engines/wintermute/ad/AdTalkNode.cpp create mode 100644 engines/wintermute/ad/AdTalkNode.h create mode 100644 engines/wintermute/ad/AdTypes.h create mode 100644 engines/wintermute/ad/AdWaypointGroup.cpp create mode 100644 engines/wintermute/ad/AdWaypointGroup.h create mode 100644 engines/wintermute/base/BActiveRect.cpp create mode 100644 engines/wintermute/base/BActiveRect.h create mode 100644 engines/wintermute/base/BBase.cpp create mode 100644 engines/wintermute/base/BBase.h create mode 100644 engines/wintermute/base/BDebugger.cpp create mode 100644 engines/wintermute/base/BDebugger.h create mode 100644 engines/wintermute/base/BDynBuffer.cpp create mode 100644 engines/wintermute/base/BDynBuffer.h create mode 100644 engines/wintermute/base/BFader.cpp create mode 100644 engines/wintermute/base/BFader.h create mode 100644 engines/wintermute/base/BFileEntry.cpp create mode 100644 engines/wintermute/base/BFileEntry.h create mode 100644 engines/wintermute/base/BFileManager.cpp create mode 100644 engines/wintermute/base/BFileManager.h create mode 100644 engines/wintermute/base/BFrame.cpp create mode 100644 engines/wintermute/base/BFrame.h create mode 100644 engines/wintermute/base/BGame.cpp create mode 100644 engines/wintermute/base/BGame.h create mode 100644 engines/wintermute/base/BKeyboardState.cpp create mode 100644 engines/wintermute/base/BKeyboardState.h create mode 100644 engines/wintermute/base/BNamedObject.cpp create mode 100644 engines/wintermute/base/BNamedObject.h create mode 100644 engines/wintermute/base/BObject.cpp create mode 100644 engines/wintermute/base/BObject.h create mode 100644 engines/wintermute/base/BPackage.cpp create mode 100644 engines/wintermute/base/BPackage.h create mode 100644 engines/wintermute/base/BParser.cpp create mode 100644 engines/wintermute/base/BParser.h create mode 100644 engines/wintermute/base/BPersistMgr.cpp create mode 100644 engines/wintermute/base/BPersistMgr.h create mode 100644 engines/wintermute/base/BPoint.cpp create mode 100644 engines/wintermute/base/BPoint.h create mode 100644 engines/wintermute/base/BQuickMsg.cpp create mode 100644 engines/wintermute/base/BQuickMsg.h create mode 100644 engines/wintermute/base/BRegion.cpp create mode 100644 engines/wintermute/base/BRegion.h create mode 100644 engines/wintermute/base/BRegistry.cpp create mode 100644 engines/wintermute/base/BRegistry.h create mode 100644 engines/wintermute/base/BResources.cpp create mode 100644 engines/wintermute/base/BResources.h create mode 100644 engines/wintermute/base/BSaveThumbHelper.cpp create mode 100644 engines/wintermute/base/BSaveThumbHelper.h create mode 100644 engines/wintermute/base/BScriptHolder.cpp create mode 100644 engines/wintermute/base/BScriptHolder.h create mode 100644 engines/wintermute/base/BScriptable.cpp create mode 100644 engines/wintermute/base/BScriptable.h create mode 100644 engines/wintermute/base/BSound.cpp create mode 100644 engines/wintermute/base/BSound.h create mode 100644 engines/wintermute/base/BSoundBuffer.cpp create mode 100644 engines/wintermute/base/BSoundBuffer.h create mode 100644 engines/wintermute/base/BSoundMgr.cpp create mode 100644 engines/wintermute/base/BSoundMgr.h create mode 100644 engines/wintermute/base/BSprite.cpp create mode 100644 engines/wintermute/base/BSprite.h create mode 100644 engines/wintermute/base/BStringTable.cpp create mode 100644 engines/wintermute/base/BStringTable.h create mode 100644 engines/wintermute/base/BSubFrame.cpp create mode 100644 engines/wintermute/base/BSubFrame.h create mode 100644 engines/wintermute/base/BSurfaceStorage.cpp create mode 100644 engines/wintermute/base/BSurfaceStorage.h create mode 100644 engines/wintermute/base/BTransitionMgr.cpp create mode 100644 engines/wintermute/base/BTransitionMgr.h create mode 100644 engines/wintermute/base/BViewport.cpp create mode 100644 engines/wintermute/base/BViewport.h create mode 100644 engines/wintermute/base/file/BDiskFile.cpp create mode 100644 engines/wintermute/base/file/BDiskFile.h create mode 100644 engines/wintermute/base/file/BFile.cpp create mode 100644 engines/wintermute/base/file/BFile.h create mode 100644 engines/wintermute/base/file/BPkgFile.cpp create mode 100644 engines/wintermute/base/file/BPkgFile.h create mode 100644 engines/wintermute/base/file/BSaveThumbFile.cpp create mode 100644 engines/wintermute/base/file/BSaveThumbFile.h create mode 100644 engines/wintermute/base/font/BFont.cpp create mode 100644 engines/wintermute/base/font/BFont.h create mode 100644 engines/wintermute/base/font/BFontBitmap.cpp create mode 100644 engines/wintermute/base/font/BFontBitmap.h create mode 100644 engines/wintermute/base/font/BFontStorage.cpp create mode 100644 engines/wintermute/base/font/BFontStorage.h create mode 100644 engines/wintermute/base/font/BFontTT.cpp create mode 100644 engines/wintermute/base/font/BFontTT.h create mode 100644 engines/wintermute/base/gfx/base_image.cpp create mode 100644 engines/wintermute/base/gfx/base_image.h create mode 100644 engines/wintermute/base/gfx/base_renderer.cpp create mode 100644 engines/wintermute/base/gfx/base_renderer.h create mode 100644 engines/wintermute/base/gfx/base_surface.cpp create mode 100644 engines/wintermute/base/gfx/base_surface.h create mode 100644 engines/wintermute/base/gfx/osystem/base_render_osystem.cpp create mode 100644 engines/wintermute/base/gfx/osystem/base_render_osystem.h create mode 100644 engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp create mode 100644 engines/wintermute/base/gfx/osystem/base_surface_osystem.h create mode 100644 engines/wintermute/base/particles/PartEmitter.cpp create mode 100644 engines/wintermute/base/particles/PartEmitter.h create mode 100644 engines/wintermute/base/particles/PartForce.cpp create mode 100644 engines/wintermute/base/particles/PartForce.h create mode 100644 engines/wintermute/base/particles/PartParticle.cpp create mode 100644 engines/wintermute/base/particles/PartParticle.h create mode 100644 engines/wintermute/base/scriptables/SXArray.cpp create mode 100644 engines/wintermute/base/scriptables/SXArray.h create mode 100644 engines/wintermute/base/scriptables/SXDate.cpp create mode 100644 engines/wintermute/base/scriptables/SXDate.h create mode 100644 engines/wintermute/base/scriptables/SXFile.cpp create mode 100644 engines/wintermute/base/scriptables/SXFile.h create mode 100644 engines/wintermute/base/scriptables/SXMath.cpp create mode 100644 engines/wintermute/base/scriptables/SXMath.h create mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.cpp create mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.h create mode 100644 engines/wintermute/base/scriptables/SXString.cpp create mode 100644 engines/wintermute/base/scriptables/SXString.h create mode 100644 engines/wintermute/base/scriptables/ScEngine.cpp create mode 100644 engines/wintermute/base/scriptables/ScEngine.h create mode 100644 engines/wintermute/base/scriptables/ScScript.cpp create mode 100644 engines/wintermute/base/scriptables/ScScript.h create mode 100644 engines/wintermute/base/scriptables/ScStack.cpp create mode 100644 engines/wintermute/base/scriptables/ScStack.h create mode 100644 engines/wintermute/base/scriptables/ScValue.cpp create mode 100644 engines/wintermute/base/scriptables/ScValue.h create mode 100644 engines/wintermute/base/scriptables/SxObject.cpp create mode 100644 engines/wintermute/base/scriptables/SxObject.h create mode 100644 engines/wintermute/system/SysClass.cpp create mode 100644 engines/wintermute/system/SysClass.h create mode 100644 engines/wintermute/system/SysClassRegistry.cpp create mode 100644 engines/wintermute/system/SysClassRegistry.h create mode 100644 engines/wintermute/system/SysInstance.cpp create mode 100644 engines/wintermute/system/SysInstance.h create mode 100644 engines/wintermute/ui/UIButton.cpp create mode 100644 engines/wintermute/ui/UIButton.h create mode 100644 engines/wintermute/ui/UIEdit.cpp create mode 100644 engines/wintermute/ui/UIEdit.h create mode 100644 engines/wintermute/ui/UIEntity.cpp create mode 100644 engines/wintermute/ui/UIEntity.h create mode 100644 engines/wintermute/ui/UIObject.cpp create mode 100644 engines/wintermute/ui/UIObject.h create mode 100644 engines/wintermute/ui/UIText.cpp create mode 100644 engines/wintermute/ui/UIText.h create mode 100644 engines/wintermute/ui/UITiledImage.cpp create mode 100644 engines/wintermute/ui/UITiledImage.h create mode 100644 engines/wintermute/ui/UIWindow.cpp create mode 100644 engines/wintermute/ui/UIWindow.h (limited to 'engines') diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp deleted file mode 100644 index 17bd166796..0000000000 --- a/engines/wintermute/Ad/AdActor.cpp +++ /dev/null @@ -1,1316 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Ad/AdActor.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Ad/AdPath.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintermute.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdActor, false) - - -////////////////////////////////////////////////////////////////////////// -CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - _path = new CAdPath(_gameRef); - - _type = OBJECT_ACTOR; - _dir = DI_LEFT; - - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _targetPoint = new CBPoint; - _afterWalkDir = DI_NONE; - - _animSprite2 = NULL; - - setDefaultAnimNames(); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::setDefaultAnimNames() { - _talkAnimName = "talk"; - _idleAnimName = "idle"; - _walkAnimName = "walk"; - _turnLeftAnimName = "turnleft"; - _turnRightAnimName = "turnright"; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdActor::~CAdActor() { - delete _path; - delete _targetPoint; - _path = NULL; - _targetPoint = NULL; - - delete _walkSprite; - delete _standSprite; - delete _turnLeftSprite; - delete _turnRightSprite; - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _animSprite2 = NULL; // ref only - - for (int i = 0; i < _talkSprites.getSize(); i++) { - delete _talkSprites[i]; - } - _talkSprites.removeAll(); - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - delete _talkSpritesEx[i]; - } - _talkSpritesEx.removeAll(); - - for (int i = 0; i < _anims.getSize(); i++) { - delete _anims[i]; - _anims[i] = NULL; - } - _anims.removeAll(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ACTOR) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(WALK) -TOKEN_DEF(STAND) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(TURN_LEFT) -TOKEN_DEF(TURN_RIGHT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ANIMATION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTOR) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(WALK) - TOKEN_TABLE(STAND) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TURN_LEFT) - TOKEN_TABLE(TURN_RIGHT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { - _gameRef->LOG(0, "'ACTOR' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSpriteSet *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_WALK: - delete _walkSprite; - _walkSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; - else _walkSprite = spr; - break; - - case TOKEN_TALK: - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - break; - - case TOKEN_TALK_SPECIAL: - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - break; - - case TOKEN_STAND: - delete _standSprite; - _standSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; - else _standSprite = spr; - break; - - case TOKEN_TURN_LEFT: - delete _turnLeftSprite; - _turnLeftSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnLeftSprite = spr; - break; - - case TOKEN_TURN_RIGHT: - delete _turnRightSprite; - _turnRightSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnRightSprite = spr; - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); - if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); - if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->mimic(_wptGroup); - } - } - break; - - case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else _anims.add(Anim); - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ACTOR definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - if (spr) delete spr; - _gameRef->LOG(0, "Error loading ACTOR definition"); - return STATUS_FAILED; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - _state = _nextState = STATE_READY; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::turnTo(TDirection dir) { - int delta1, delta2, delta3, delta; - - delta1 = dir - _dir; - delta2 = dir + NUM_DIRECTIONS - _dir; - delta3 = dir - NUM_DIRECTIONS - _dir; - - delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; - delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; - - // already there? - if (abs(delta) < 2) { - _dir = dir; - _state = _nextState; - _nextState = STATE_READY; - return; - } - - _targetDir = dir; - _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; - - _tempSprite2 = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { - _afterWalkDir = afterWalkDir; - if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; - - _path->reset(); - _path->setReady(false); - - _targetPoint->x = x; - _targetPoint->y = y; - - ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); - - _state = STATE_SEARCHING_PATH; - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::display() { - if (_active) updateSounds(); - - uint32 alpha; - if (_alphaColor != 0) alpha = _alphaColor; - else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - - float rotate; - if (_rotatable) { - if (_rotateValid) rotate = _rotate; - else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else rotate = 0.0f; - - if (_active) displaySpriteAttachments(true); - - if (_currentSprite && _active) { - bool reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; - - _currentSprite->display(_posX, - _posY, - reg ? _registerAlias : NULL, - scaleX, - scaleY, - alpha, - rotate, - _blendMode); - - } - - if (_active) displaySpriteAttachments(false); - if (_active && _partEmitter) _partEmitter->display(); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::update() { - _currentSprite = NULL; - - if (_state == STATE_READY) { - if (_animSprite) { - delete _animSprite; - _animSprite = NULL; - } - if (_animSprite2) { - _animSprite2 = NULL; - } - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite; - } - - if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite2; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - } - - bool already_moved = false; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM_SET: - _currentSprite = _animSprite2; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_LEFT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - if (_dir > 0) _dir = (TDirection)(_dir - 1); - else _dir = (TDirection)(NUM_DIRECTIONS - 1); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnLeftSprite) { - _tempSprite2 = _turnLeftSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_RIGHT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - _dir = (TDirection)(_dir + 1); - - if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnRightSprite) { - _tempSprite2 = _turnRightSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_SEARCHING_PATH: - // keep asking scene for the path - if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) - _state = STATE_WAITING_PATH; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_WAITING_PATH: - // wait until the scene finished the path - if (_path->_ready) followPath(); - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_FOLLOWING_PATH: - getNextStep(); - already_moved = true; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(_dir); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite && !_animSprite2) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - } - break; - default: - error("AdActor::Update - Unhandled enum"); - } - - - if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - afterMove(); - } - } - - //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); - - updateBlockRegion(); - _ready = (_state == STATE_READY); - - updatePartEmitter(); - updateSpriteAttachments(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::followPath() { - // skip current position - _path->getFirst(); - while (_path->getCurrent() != NULL) { - if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; - _path->getNext(); - } - - // are there points to follow? - if (_path->getCurrent() != NULL) { - _state = STATE_FOLLOWING_PATH;; - initLine(CBPoint(_posX, _posY), *_path->getCurrent()); - } else { - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else _state = STATE_READY; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::getNextStep() { - if (_walkSprite) { - _currentSprite = _walkSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_walkAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - - if (!_currentSprite) return; - - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (!_currentSprite->_changed) return; - - - int maxStepX, maxStepY; - maxStepX = abs(_currentSprite->_moveX); - maxStepY = abs(_currentSprite->_moveY); - - maxStepX = MAX(maxStepX, maxStepY); - maxStepX = MAX(maxStepX, 1); - - while (_pFCount > 0 && maxStepX >= 0) { - _pFX += _pFStepX; - _pFY += _pFStepY; - - _pFCount--; - maxStepX--; - } - - if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { - if (_pFCount == 0) { - _state = _nextState; - _nextState = STATE_READY; - return; - } - goTo(_targetPoint->x, _targetPoint->y); - return; - } - - - _posX = (int)_pFX; - _posY = (int)_pFY; - - afterMove(); - - - if (_pFCount == 0) { - if (_path->getNext() == NULL) { - _posX = _targetPoint->x; - _posY = _targetPoint->y; - - _path->reset(); - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else { - _state = _nextState; - _nextState = STATE_READY; - } - } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { - _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); - - _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; - _pFStepY = (double)(endPt.y - startPt.y) / _pFCount; - - _pFX = startPt.x; - _pFY = startPt.y; - - int angle = (int)(atan2((double)(endPt.y - startPt.y), (double)(endPt.x - startPt.x)) * (180 / 3.14)); - - _nextState = STATE_FOLLOWING_PATH; - - turnTo(angleToDirection(angle)); -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GoTo / GoToAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { - stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - goTo(X, Y); - if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoToObject / GoToObjectAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - if (!Val->isNative()) { - script->runtimeError("actor.%s method accepts an entity refrence only", name); - stack->pushNULL(); - return STATUS_OK; - } - CAdObject *Obj = (CAdObject *)Val->getNative(); - if (!Obj || Obj->_type != OBJECT_ENTITY) { - script->runtimeError("actor.%s method accepts an entity refrence only", name); - stack->pushNULL(); - return STATUS_OK; - } - CAdEntity *Ent = (CAdEntity *)Obj; - if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); - else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnTo / TurnToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { - stack->correctParams(1); - int dir; - CScValue *val = stack->pop(); - - // turn to object? - if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { - CBObject *obj = (CBObject *)val->getNative(); - int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); - dir = (int)angleToDirection(angle); - } - // otherwise turn to direction - else dir = val->getInt(); - - if (dir >= 0 && dir < NUM_DIRECTIONS) { - turnTo((TDirection)dir); - if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsWalking") == 0) { - stack->correctParams(0); - stack->pushBool(_state == STATE_FOLLOWING_PATH); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MergeAnims - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MergeAnims") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(mergeAnims(stack->pop()->getString()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadAnim") == 0) { - stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); - - bool Found = false; - for (int i = 0; i < _anims.getSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { - // invalidate sprites in use - if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; - if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; - if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; - - delete _anims[i]; - _anims[i] = NULL; - _anims.removeAt(i); - i--; - Found = true; - } - } - stack->pushBool(Found); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasAnim") == 0) { - stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); - stack->pushBool(getAnimByName(AnimName) != NULL); - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Direction") == 0) { - _scValue->setInt(_dir); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Type") == 0) { - _scValue->setString("actor"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkAnimName") == 0) { - _scValue->setString(_talkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkAnimName") == 0) { - _scValue->setString(_walkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IdleAnimName") == 0) { - _scValue->setString(_idleAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnLeftAnimName") == 0) { - _scValue->setString(_turnLeftAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnRightAnimName") == 0) { - _scValue->setString(_turnRightAnimName); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Direction") == 0) { - int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkAnimName") == 0) { - if (value->isNULL()) _talkAnimName = "talk"; - else _talkAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkAnimName") == 0) { - if (value->isNULL()) _walkAnimName = "walk"; - else _walkAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IdleAnimName") == 0) { - if (value->isNULL()) _idleAnimName = "idle"; - else _idleAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnLeftAnimName") == 0) { - if (value->isNULL()) _turnLeftAnimName = "turnleft"; - else _turnLeftAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnRightAnimName") == 0) { - if (value->isNULL()) _turnRightAnimName = "turnright"; - else _turnRightAnimName = value->getString(); - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdActor::scToString() { - return "[actor object]"; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStance(const char *stance) { - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - // old way - if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) - return getTalkStanceOld(stance); - - // new way - CBSprite *ret = NULL; - - // do we have an animation with this name? - CAdSpriteSet *Anim = getAnimByName(stance); - if (Anim) ret = Anim->getSprite(_dir); - - // not - get a random talk - if (!ret) { - CBArray TalkAnims; - for (int i = 0; i < _anims.getSize(); i++) { - if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) - TalkAnims.add(_anims[i]); - } - - if (TalkAnims.getSize() > 0) { - int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); - ret = TalkAnims[rnd]->getSprite(_dir); - } else { - if (_standSprite) ret = _standSprite->getSprite(_dir); - else { - Anim = getAnimByName(_idleAnimName); - if (Anim) ret = Anim->getSprite(_dir); - } - } - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStanceOld(const char *stance) { - CBSprite *ret = NULL; - - if (stance != NULL) { - // search special stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { - ret = _talkSpritesEx[i]->getSprite(_dir); - break; - } - } - if (ret == NULL) { - // search generic stances - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { - ret = _talkSprites[i]->getSprite(_dir); - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); - else { - // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); - ret = _talkSprites[rnd]->getSprite(_dir); - } - } - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER_INT(_dir)); - persistMgr->transfer(TMEMBER(_path)); - persistMgr->transfer(TMEMBER(_pFCount)); - persistMgr->transfer(TMEMBER(_pFStepX)); - persistMgr->transfer(TMEMBER(_pFStepY)); - persistMgr->transfer(TMEMBER(_pFX)); - persistMgr->transfer(TMEMBER(_pFY)); - persistMgr->transfer(TMEMBER(_standSprite)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_targetDir)); - persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); - persistMgr->transfer(TMEMBER(_targetPoint)); - persistMgr->transfer(TMEMBER(_turnLeftSprite)); - persistMgr->transfer(TMEMBER(_turnRightSprite)); - persistMgr->transfer(TMEMBER(_walkSprite)); - - persistMgr->transfer(TMEMBER(_animSprite2)); - persistMgr->transfer(TMEMBER(_talkAnimName)); - persistMgr->transfer(TMEMBER(_idleAnimName)); - persistMgr->transfer(TMEMBER(_walkAnimName)); - persistMgr->transfer(TMEMBER(_turnLeftAnimName)); - persistMgr->transfer(TMEMBER(_turnRightAnimName)); - - _anims.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TDirection CAdActor::angleToDirection(int angle) { - TDirection ret = DI_DOWN;; - - if (angle > -112 && angle <= -67) ret = DI_UP; - else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; - else if (angle > -22 && angle <= 22) ret = DI_RIGHT; - else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; - else if (angle > 67 && angle <= 112) ret = DI_DOWN; - else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; - else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; - else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdActor::getHeight() { - // if no current sprite is set, set some - if (_currentSprite == NULL) { - if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); - else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - // and get height - return CAdTalkHolder::getHeight(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { - for (int i = 0; i < _anims.getSize(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) - return _anims[i]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::mergeAnims(const char *animsFilename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - - byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); - if (fileBuffer == NULL) { - _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); - return STATUS_FAILED; - } - - byte *buffer = fileBuffer; - byte *params; - int cmd; - CBParser parser(_gameRef); - - bool Ret = STATUS_OK; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - Ret = STATUS_FAILED; - } else _anims.add(Anim); - } - break; - } - } - delete [] fileBuffer; - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::playAnim(const char *filename) { - // if we have an anim with this name, use it - CAdSpriteSet *Anim = getAnimByName(filename); - if (Anim) { - _animSprite2 = Anim->getSprite(_dir); - if (_animSprite2) { - _animSprite2->reset(); - _state = STATE_PLAYING_ANIM_SET; - return STATUS_OK; - } - } - // otherwise call the standard handler - return CAdTalkHolder::playAnim(filename); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdActor.h b/engines/wintermute/Ad/AdActor.h deleted file mode 100644 index 114ee04ae8..0000000000 --- a/engines/wintermute/Ad/AdActor.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADACTOR_H -#define WINTERMUTE_ADACTOR_H - - -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/Ad/AdTypes.h" // Added by ClassView -#include "engines/wintermute/Ad/AdTalkHolder.h" -#include "engines/wintermute/Base/BPoint.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "common/str.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -namespace WinterMute { -class CAdSpriteSet; -class CAdPath; -class CAdActor : public CAdTalkHolder { -public: - TDirection angleToDirection(int angle); - DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) - virtual int getHeight(); - CBSprite *getTalkStance(const char *stance); - virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); - CBPoint *_targetPoint; - virtual bool update(); - virtual bool display(); - TDirection _targetDir; - TDirection _afterWalkDir; - virtual void turnTo(TDirection dir); - CAdPath *_path; - CAdSpriteSet *_walkSprite; - CAdSpriteSet *_standSprite; - CAdSpriteSet *_turnLeftSprite; - CAdSpriteSet *_turnRightSprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - TDirection _dir; - CAdActor(CBGame *inGame/*=NULL*/); - virtual ~CAdActor(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - - // new anim system - Common::String _talkAnimName; - Common::String _idleAnimName; - Common::String _walkAnimName; - Common::String _turnLeftAnimName; - Common::String _turnRightAnimName; - CBArray _anims; - virtual bool playAnim(const char *filename); - CAdSpriteSet *getAnimByName(const Common::String &animName); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - bool setDefaultAnimNames(); - CBSprite *getTalkStanceOld(const char *stance); - bool mergeAnims(const char *animsFilename); - CBSprite *_animSprite2; - - void initLine(CBPoint startPt, CBPoint endPt); - void getNextStep(); - void followPath(); - double _pFStepX; - double _pFStepY; - double _pFX; - double _pFY; - int _pFCount; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp deleted file mode 100644 index 20c16e3dd5..0000000000 --- a/engines/wintermute/Ad/AdEntity.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdEntity, false) - -////////////////////////////////////////////////////////////////////////// -CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { - _type = OBJECT_ENTITY; - _subtype = ENTITY_NORMAL; - _region = NULL; - _item = NULL; - - _walkToX = _walkToY = 0; - _walkToDir = DI_NONE; - - _theora = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdEntity::~CAdEntity() { - _gameRef->unregisterObject(_region); - - delete _theora; - _theora = NULL; - - delete[] _item; - _item = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(CURSOR) -TOKEN_DEF(REGION) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_START_TIME) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(SOUND) -TOKEN_DEF(SUBTYPE) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ITEM) -TOKEN_DEF(WALK_TO_X) -TOKEN_DEF(WALK_TO_Y) -TOKEN_DEF(WALK_TO_DIR) -TOKEN_DEF(SAVE_STATE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(REGION) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_START_TIME) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(SUBTYPE) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(WALK_TO_X) - TOKEN_TABLE(WALK_TO_Y) - TOKEN_TABLE(WALK_TO_DIR) - TOKEN_TABLE(SAVE_STATE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { - _gameRef->LOG(0, "'ENTITY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CAdGame *adGame = (CAdGame *)_gameRef; - CBSprite *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SPRITE: { - delete _sprite; - _sprite = NULL; - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - break; - - case TOKEN_TALK: { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - } - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_ITEM: - setItem((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_REGION: { - if (_region) _gameRef->unregisterObject(_region); - _region = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else { - _region = rgn; - _gameRef->registerObject(_region); - } - } - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); - if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); - if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->mimic(_wptGroup); - } - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_SUBTYPE: { - if (scumm_stricmp((char *)params, "sound") == 0) { - delete _sprite; - _sprite = NULL; - if (_gameRef->_editorMode) { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - if (_gameRef->_editorMode) _editorOnly = true; - _zoomable = false; - _rotatable = false; - _registrable = _gameRef->_editorMode; - _shadowable = false; - _subtype = ENTITY_SOUND; - } - } - break; - - case TOKEN_SOUND: - playSFX((char *)params, false, false); - break; - - case TOKEN_SOUND_START_TIME: - parser.scanStr((char *)params, "%d", &_sFXStart); - break; - - case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_SAVE_STATE: - parser.scanStr((char *)params, "%b", &_saveState); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_WALK_TO_X: - parser.scanStr((char *)params, "%d", &_walkToX); - break; - - case TOKEN_WALK_TO_Y: - parser.scanStr((char *)params, "%d", &_walkToY); - break; - - case TOKEN_WALK_TO_DIR: { - int i; - parser.scanStr((char *)params, "%d", &i); - if (i < 0) i = 0; - if (i >= NUM_DIRECTIONS) i = DI_NONE; - _walkToDir = (TDirection)i; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ENTITY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ENTITY definition"); - if (spr) delete spr; - return STATUS_FAILED; - } - - if (_region && _sprite) { - _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); - } - - updatePosition(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - _state = STATE_READY; - - if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::display() { - if (_active) { - updateSounds(); - - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; - - float ScaleX, ScaleY; - getScale(&ScaleX, &ScaleY); - - float Rotate; - if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; - - - bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; - - if (_region && (Reg || _editorAlwaysRegister)) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); - } - - displaySpriteAttachments(true); - if (_theora && (_theora->isPlaying() || _theora->isPaused())) { - _theora->display(Alpha); - } else if (_currentSprite) { - _currentSprite->display(_posX, - _posY, - (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); - } - displaySpriteAttachments(false); - - if (_partEmitter) _partEmitter->display(_region); - - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) - _currentSprite = _sprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - default: // Silence unhandled enum-warning - break; - } - - - if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - } - } - - updateBlockRegion(); - _ready = (_state == STATE_READY); - - if (_theora) { - int OffsetX, OffsetY; - _gameRef->getOffset(&OffsetX, &OffsetY); - _theora->_posX = _posX - OffsetX; - _theora->_posY = _posY - OffsetY; - - _theora->update(); - if (_theora->isFinished()) { - _theora->stop(); - delete _theora; - _theora = NULL; - } - } - - updatePartEmitter(); - updateSpriteAttachments(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX(false))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - stack->correctParams(4); - const char *filename = stack->pop()->getString(); - bool looping = stack->pop()->getBool(false); - CScValue *valAlpha = stack->pop(); - int startTime = stack->pop()->getInt(); - - delete _theora; - _theora = new CVidTheoraPlayer(_gameRef); - if (_theora && DID_SUCCEED(_theora->initialize(filename))) { - if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); - _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); - //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; - stack->pushBool(true); - } else { - script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopTheora") == 0) { - stack->correctParams(0); - if (_theora) { - _theora->stop(); - delete _theora; - _theora = NULL; - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTheoraPlaying") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseTheora") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPlaying()) { - _theora->pause(); - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeTheora") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPaused()) { - _theora->resume(); - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPaused - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTheoraPaused") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPaused()) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // CreateRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateRegion") == 0) { - stack->correctParams(0); - if (!_region) { - _region = new CBRegion(_gameRef); - _gameRef->registerObject(_region); - } - if (_region) stack->pushNative(_region, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteRegion") == 0) { - stack->correctParams(0); - if (_region) { - _gameRef->unregisterObject(_region); - _region = NULL; - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("entity"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Item") == 0) { - if (_item) _scValue->setString(_item); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtype (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtype") == 0) { - if (_subtype == ENTITY_SOUND) - _scValue->setString("sound"); - else - _scValue->setString("normal"); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToX") == 0) { - _scValue->setInt(_walkToX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToY") == 0) { - _scValue->setInt(_walkToY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToDirection") == 0) { - _scValue->setInt((int)_walkToDir); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Region (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Region") == 0) { - if (_region) _scValue->setNative(_region, true); - else _scValue->setNULL(); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Item") == 0) { - setItem(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToX") == 0) { - _walkToX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToY") == 0) { - _walkToY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToDirection") == 0) { - int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdEntity::scToString() { - return "[entity object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - if (_subtype == ENTITY_SOUND) - buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_ignoreItems) - buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); - if (_rotatable) - buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); - - if (!_autoSoundPanning) - buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); - - if (!_saveState) - buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); - - if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); - - buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); - buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); - if (_walkToDir != DI_NONE) - buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); - - if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); - buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); - buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); - } - - - if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); - - if (RGBCOLGetA(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); - - if (_scale >= 0) - buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); - - if (_relativeScale != 0) - buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - CAdTalkHolder::saveAsText(buffer, indent + 2); - - if (_region) _region->saveAsText(buffer, indent + 2); - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - CAdObject::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdEntity::getHeight() { - if (_region && !_sprite) { - return _region->_rect.bottom - _region->_rect.top; - } else { - if (_currentSprite == NULL) _currentSprite = _sprite; - return CAdObject::getHeight(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::updatePosition() { - if (_region && !_sprite) { - _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; - _posY = _region->_rect.bottom; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_item)); - persistMgr->transfer(TMEMBER(_region)); - //persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER_INT(_subtype)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_walkToX)); - persistMgr->transfer(TMEMBER(_walkToY)); - persistMgr->transfer(TMEMBER_INT(_walkToDir)); - - persistMgr->transfer(TMEMBER(_theora)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::setItem(const char *itemName) { - CBUtils::setString(&_item, itemName); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::setSprite(const char *filename) { - bool setCurrent = false; - if (_currentSprite == _sprite) { - _currentSprite = NULL; - setCurrent = true; - } - - delete _sprite; - _sprite = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - delete _sprite; - _sprite = NULL; - return STATUS_FAILED; - } else { - _sprite = spr; - _currentSprite = _sprite; - return STATUS_OK; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdEntity.h b/engines/wintermute/Ad/AdEntity.h deleted file mode 100644 index 43007c645a..0000000000 --- a/engines/wintermute/Ad/AdEntity.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADENTITY_H -#define WINTERMUTE_ADENTITY_H - -#include "engines/wintermute/Ad/AdTalkHolder.h" - -namespace WinterMute { -class CVidTheoraPlayer; -class CAdEntity : public CAdTalkHolder { -public: - CVidTheoraPlayer *_theora; - bool setSprite(const char *filename); - int _walkToX; - int _walkToY; - TDirection _walkToDir; - void setItem(const char *itemName); - char *_item; - DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) - void updatePosition(); - virtual int getHeight(); - CBRegion *_region; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool update(); - virtual bool display(); - CAdEntity(CBGame *inGame); - virtual ~CAdEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - TEntityType _subtype; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp deleted file mode 100644 index af752e3ced..0000000000 --- a/engines/wintermute/Ad/AdGame.cpp +++ /dev/null @@ -1,2061 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdActor.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdInventoryBox.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/Ad/AdResponseBox.h" -#include "engines/wintermute/Ad/AdResponseContext.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BTransitionMgr.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/particles/PartEmitter.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/UI/UIEntity.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/video/VidPlayer.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdGame, true) - -////////////////////////////////////////////////////////////////////////// -CAdGame::CAdGame(): CBGame() { - _responseBox = NULL; - _inventoryBox = NULL; - - _scene = new CAdScene(_gameRef); - _scene->setName(""); - registerObject(_scene); - - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _scheduledFadeIn = false; - - - _stateEx = GAME_NORMAL; - - _selectedItem = NULL; - - - _texItemLifeTime = 10000; - _texWalkLifeTime = 10000; - _texStandLifeTime = 10000; - _texTalkLifeTime = 10000; - - _talkSkipButton = TALK_SKIP_LEFT; - - _sceneViewport = NULL; - - _initialScene = true; - _debugStartupScene = NULL; - _startupScene = NULL; - - _invObject = new CAdObject(this); - _inventoryOwner = _invObject; - - _tempDisableSaveState = false; - _itemsFile = NULL; - - _smartItemCursor = false; - - addSpeechDir("speech"); -} - - -////////////////////////////////////////////////////////////////////////// -CAdGame::~CAdGame() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::cleanup() { - int i; - - for (i = 0; i < _objects.getSize(); i++) { - unregisterObject(_objects[i]); - _objects[i] = NULL; - } - _objects.removeAll(); - - - for (i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.removeAll(); - - for (i = 0; i < _speechDirs.getSize(); i++) { - delete [] _speechDirs[i]; - } - _speechDirs.removeAll(); - - - unregisterObject(_scene); - _scene = NULL; - - // remove items - for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); - _items.removeAll(); - - - // clear remaining inventories - delete _invObject; - _invObject = NULL; - - for (i = 0; i < _inventories.getSize(); i++) { - delete _inventories[i]; - } - _inventories.removeAll(); - - - if (_responseBox) { - _gameRef->unregisterObject(_responseBox); - _responseBox = NULL; - } - - if (_inventoryBox) { - _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = NULL; - } - - delete[] _prevSceneName; - delete[] _prevSceneFilename; - delete[] _scheduledScene; - delete[] _debugStartupScene; - delete[] _itemsFile; - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _debugStartupScene = NULL; - _startupScene = NULL; - _itemsFile = NULL; - - delete _sceneViewport; - _sceneViewport = NULL; - - for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; - _sceneStates.removeAll(); - - for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - - for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; - _responsesGame.removeAll(); - - return CBGame::cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::initLoop() { - if (_scheduledScene && _transMgr->isReady()) { - changeScene(_scheduledScene, _scheduledFadeIn); - delete[] _scheduledScene; - _scheduledScene = NULL; - - _gameRef->_activeObject = NULL; - } - - - bool res; - res = CBGame::initLoop(); - if (DID_FAIL(res)) return res; - - if (_scene) res = _scene->initLoop(); - - _sentences.removeAll(); - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addObject(CAdObject *object) { - _objects.add(object); - return registerObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeObject(CAdObject *object) { - // in case the user called Scene.CreateXXX() and Game.DeleteXXX() - if (_scene) { - bool Res = _scene->removeObject(object); - if (DID_SUCCEED(Res)) return Res; - } - - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] == object) { - _objects.removeAt(i); - break; - } - } - return unregisterObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::changeScene(const char *filename, bool fadeIn) { - if (_scene == NULL) { - _scene = new CAdScene(_gameRef); - registerObject(_scene); - } else { - _scene->applyEvent("SceneShutdown", true); - - setPrevSceneName(_scene->_name); - setPrevSceneFilename(_scene->_filename); - - if (!_tempDisableSaveState) _scene->saveState(); - _tempDisableSaveState = false; - } - - if (_scene) { - // reset objects - for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); - - // reset scene properties - _scene->_sFXVolume = 100; - if (_scene->_scProp) _scene->_scProp->cleanup(); - - bool ret; - if (_initialScene && _debugDebugMode && _debugStartupScene) { - _initialScene = false; - ret = _scene->loadFile(_debugStartupScene); - } else ret = _scene->loadFile(filename); - - if (DID_SUCCEED(ret)) { - // invalidate references to the original scene - for (int i = 0; i < _objects.getSize(); i++) { - _objects[i]->invalidateCurrRegions(); - _objects[i]->_stickRegion = NULL; - } - - _scene->loadState(); - } - if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); - return ret; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::addSentence(CAdSentence *sentence) { - _sentences.add(sentence); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displaySentences(bool frozen) { - for (int i = 0; i < _sentences.getSize(); i++) { - if (frozen && _sentences[i]->_freezable) continue; - else _sentences[i]->display(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::finishSentences() { - for (int i = 0; i < _sentences.getSize(); i++) { - if (_sentences[i]->CanSkip()) { - _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // ChangeScene - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "ChangeScene") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - CScValue *valFadeOut = stack->pop(); - CScValue *valFadeIn = stack->pop(); - - bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); - bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); - - scheduleChangeScene(filename, transIn); - if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); - stack->pushNULL(); - - - //bool ret = ChangeScene(stack->pop()->getString()); - //if(DID_FAIL(ret)) stack->pushBool(false); - //else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadActor") == 0) { - stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); - if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { - addObject(act); - stack->pushNative(act, true); - } else { - delete act; - act = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadEntity") == 0) { - stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); - if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { - addObject(ent); - stack->pushNative(ent, true); - } else { - delete ent; - ent = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); - removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdEntity *ent = new CAdEntity(_gameRef); - addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = new CAdItem(_gameRef); - addItem(item); - if (!val->isNULL()) item->setName(val->getString()); - stack->pushNative(item, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = NULL; - if (val->isNative()) item = (CAdItem *)val->getNative(); - else item = getItemByName(val->getString()); - - if (item) { - deleteItem(item); - } - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QueryItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QueryItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < _items.getSize()) item = _items[index]; - } else { - item = getItemByName(val->getString()); - } - - if (item) stack->pushNative(item, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // AddResponse/AddResponseOnce/AddResponseOnceGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { - stack->correctParams(6); - int id = stack->pop()->getInt(); - const char *text = stack->pop()->getString(); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - CScValue *val4 = stack->pop(); - - if (_responseBox) { - CAdResponse *res = new CAdResponse(_gameRef); - if (res) { - res->_iD = id; - res->setText(text); - _stringTable->expand(&res->_text); - if (!val1->isNULL()) res->setIcon(val1->getString()); - if (!val2->isNULL()) res->setIconHover(val2->getString()); - if (!val3->isNULL()) res->setIconPressed(val3->getString()); - if (!val4->isNULL()) res->setFont(val4->getString()); - - if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; - else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; - - _responseBox->_responses.add(res); - } - } else { - script->runtimeError("Game.AddResponse: response box is not defined"); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResetResponse") == 0) { - stack->correctParams(1); - int ID = stack->pop()->getInt(-1); - resetResponse(ID); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearResponses") == 0) { - stack->correctParams(0); - _responseBox->clearResponses(); - _responseBox->clearButtons(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetResponse") == 0) { - stack->correctParams(1); - bool autoSelectLast = stack->pop()->getBool(); - - if (_responseBox) { - _responseBox->weedResponses(); - - if (_responseBox->_responses.getSize() == 0) { - stack->pushNULL(); - return STATUS_OK; - } - - - if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { - stack->pushInt(_responseBox->_responses[0]->_iD); - _responseBox->handleResponse(_responseBox->_responses[0]); - _responseBox->clearResponses(); - return STATUS_OK; - } - - _responseBox->createButtons(); - _responseBox->_waitingScript = script; - script->waitForExclusive(_responseBox); - _state = GAME_SEMI_FROZEN; - _stateEx = GAME_WAITING_RESPONSE; - } else { - script->runtimeError("Game.GetResponse: response box is not defined"); - stack->pushNULL(); - } - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // GetNumResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNumResponses") == 0) { - stack->correctParams(0); - if (_responseBox) { - _responseBox->weedResponses(); - stack->pushInt(_responseBox->_responses.getSize()); - } else { - script->runtimeError("Game.GetNumResponses: response box is not defined"); - stack->pushNULL(); - } - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // StartDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartDlgBranch") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - Common::String branchName; - if (val->isNULL()) { - branchName.format("line%d", script->_currentLine); - } else branchName = val->getString(); - - startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EndDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EndDlgBranch") == 0) { - stack->correctParams(1); - - const char *branchName = NULL; - CScValue *val = stack->pop(); - if (!val->isNULL()) branchName = val->getString(); - endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCurrentDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCurrentDlgBranch") == 0) { - stack->correctParams(0); - - if (_dlgPendingBranches.getSize() > 0) { - stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TakeItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DropItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // IsItemTaken - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsItemTaken") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (val->getNative() == Inv->_takenItems[j]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { - stack->pushBool(true); - return STATUS_OK; - } - } - } - } else script->runtimeError("Game.IsItemTaken: item name expected"); - - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInventoryWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInventoryWindow") == 0) { - stack->correctParams(0); - if (_inventoryBox && _inventoryBox->_window) - stack->pushNative(_inventoryBox->_window, true); - else - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponsesWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { - stack->correctParams(0); - if (_responseBox && _responseBox->_window) - stack->pushNative(_responseBox->_window, true); - else - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadResponseBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadResponseBox") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _gameRef->unregisterObject(_responseBox); - _responseBox = new CAdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { - registerObject(_responseBox); - stack->pushBool(true); - } else { - delete _responseBox; - _responseBox = NULL; - stack->pushBool(false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadInventoryBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadInventoryBox") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = new CAdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { - registerObject(_inventoryBox); - stack->pushBool(true); - } else { - delete _inventoryBox; - _inventoryBox = NULL; - stack->pushBool(false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadItems") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool merge = stack->pop()->getBool(false); - - bool ret = loadItemsFile(filename, merge); - stack->pushBool(DID_SUCCEED(ret)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSpeechDir") == 0) { - stack->correctParams(1); - const char *dir = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSpeechDir(dir))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSpeechDir") == 0) { - stack->correctParams(1); - const char *dir = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSpeechDir(dir))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSceneViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSceneViewport") == 0) { - stack->correctParams(4); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - int width = stack->pop()->getInt(); - int height = stack->pop()->getInt(); - - if (width <= 0) width = _renderer->_width; - if (height <= 0) height = _renderer->_height; - - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); - - stack->pushBool(true); - - return STATUS_OK; - } - - - else return CBGame::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scene") == 0) { - if (_scene) _scValue->setNative(_scene, true); - else _scValue->setNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelectedItem") == 0) { - //if(_selectedItem) _scValue->setString(_selectedItem->_name); - if (_selectedItem) _scValue->setNative(_selectedItem, true); - else _scValue->setNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { - return _invObject->scGetProperty(name); - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SmartItemCursor") == 0) { - _scValue->setBool(_smartItemCursor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryVisible") == 0) { - _scValue->setBool(_inventoryBox && _inventoryBox->_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); - else _scValue->setInt(0); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ResponsesVisible (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResponsesVisible") == 0) { - _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevScene / PreviousScene (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { - if (!_prevSceneName) _scValue->setString(""); - else _scValue->setString(_prevSceneName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevSceneFilename / PreviousSceneFilename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { - if (!_prevSceneFilename) _scValue->setString(""); - else _scValue->setString(_prevSceneFilename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponse (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponse") == 0) { - if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseText); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponseOrig (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponseOrig") == 0) { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseTextOrig); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner == _invObject) _scValue->setNative(this, true); - else _scValue->setNative(_inventoryOwner, true); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TotalNumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TotalNumItems") == 0) { - _scValue->setInt(_items.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkSkipButton") == 0) { - _scValue->setInt(_talkSkipButton); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ChangingScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ChangingScene") == 0) { - _scValue->setBool(_scheduledScene != NULL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartupScene") == 0) { - if (!_startupScene) _scValue->setNULL(); - else _scValue->setString(_startupScene); - return _scValue; - } - - else return CBGame::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelectedItem") == 0) { - if (value->isNULL()) _selectedItem = NULL; - else { - if (value->isNative()) { - _selectedItem = NULL; - for (int i = 0; i < _items.getSize(); i++) { - if (_items[i] == value->getNative()) { - _selectedItem = (CAdItem *)value->getNative(); - break; - } - } - } else { - // try to get by name - _selectedItem = getItemByName(value->getString()); - } - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SmartItemCursor") == 0) { - _smartItemCursor = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - - if (value->isNULL()) _inventoryOwner = _invObject; - else { - CBObject *Obj = (CBObject *)value->getNative(); - if (Obj == this) _inventoryOwner = _invObject; - else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; - } - - if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkSkipButton") == 0) { - int Val = value->getInt(); - if (Val < 0) Val = 0; - if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; - _talkSkipButton = (TTalkSkipButton)Val; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartupScene") == 0) { - if (value == NULL) { - delete[] _startupScene; - _startupScene = NULL; - } else CBUtils::setString(&_startupScene, value->getString()); - - return STATUS_OK; - } - - else return CBGame::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *this_obj; - - ////////////////////////////////////////////////////////////////////////// - // Actor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Actor") == 0) { - stack->correctParams(0); - this_obj = thisStack->getTop(); - - this_obj->setNative(new CAdActor(_gameRef)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Entity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Entity") == 0) { - stack->correctParams(0); - this_obj = thisStack->getTop(); - - this_obj->setNative(new CAdEntity(_gameRef)); - stack->pushNULL(); - } - - - ////////////////////////////////////////////////////////////////////////// - // call parent - else return CBGame::ExternalCall(script, stack, thisStack, name); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::showCursor() { - if (_cursorHidden) return STATUS_OK; - - if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { - if (_selectedItem->_cursorCombined) { - CBSprite *origLastCursor = _lastCursor; - CBGame::showCursor(); - _lastCursor = origLastCursor; - } - if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) - return drawCursor(_selectedItem->_cursorHover); - else - return drawCursor(_selectedItem->_cursorNormal); - } else return drawCursor(_selectedItem->_cursorNormal); - } else return CBGame::showCursor(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadFile(const char *filename) { - byte *buffer = _fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(AD_GAME) -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(ITEMS) -TOKEN_DEF(ITEM) -TOKEN_DEF(TALK_SKIP_BUTTON) -TOKEN_DEF(SCENE_VIEWPORT) -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(STARTUP_SCENE) -TOKEN_DEF(DEBUG_STARTUP_SCENE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(AD_GAME) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(ITEMS) - TOKEN_TABLE(TALK_SKIP_BUTTON) - TOKEN_TABLE(SCENE_VIEWPORT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(STARTUP_SCENE) - TOKEN_TABLE(DEBUG_STARTUP_SCENE) - TOKEN_TABLE_END - - byte *params; - byte *params2; - int cmd = 1; - CBParser parser(_gameRef); - - bool itemFound = false, itemsFound = false; - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AD_GAME: - while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { - switch (cmd) { - case TOKEN_RESPONSE_BOX: - delete _responseBox; - _responseBox = new CAdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) - registerObject(_responseBox); - else { - delete _responseBox; - _responseBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_INVENTORY_BOX: - delete _inventoryBox; - _inventoryBox = new CAdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) - registerObject(_inventoryBox); - else { - delete _inventoryBox; - _inventoryBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ITEMS: - itemsFound = true; - CBUtils::setString(&_itemsFile, (char *)params2); - if (DID_FAIL(loadItemsFile(_itemsFile))) { - delete[] _itemsFile; - _itemsFile = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; - else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; - else _talkSkipButton = TALK_SKIP_LEFT; - break; - - case TOKEN_SCENE_VIEWPORT: { - Rect32 rc; - parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params2, false); - break; - - case TOKEN_STARTUP_SCENE: - CBUtils::setString(&_startupScene, (char *)params2); - break; - - case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::setString(&_debugStartupScene, (char *)params2); - break; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - if (itemFound && !itemsFound) { - _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file."); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); - CBGame::persist(persistMgr); - - _dlgPendingBranches.persist(persistMgr); - - _inventories.persist(persistMgr); - persistMgr->transfer(TMEMBER(_inventoryBox)); - - _objects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_prevSceneName)); - persistMgr->transfer(TMEMBER(_prevSceneFilename)); - - persistMgr->transfer(TMEMBER(_responseBox)); - _responsesBranch.persist(persistMgr); - _responsesGame.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scene)); - _sceneStates.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scheduledFadeIn)); - persistMgr->transfer(TMEMBER(_scheduledScene)); - persistMgr->transfer(TMEMBER(_selectedItem)); - persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); - - _sentences.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_sceneViewport)); - persistMgr->transfer(TMEMBER_INT(_stateEx)); - persistMgr->transfer(TMEMBER(_initialScene)); - persistMgr->transfer(TMEMBER(_debugStartupScene)); - - persistMgr->transfer(TMEMBER(_invObject)); - persistMgr->transfer(TMEMBER(_inventoryOwner)); - persistMgr->transfer(TMEMBER(_tempDisableSaveState)); - _items.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_itemsFile)); - - _speechDirs.persist(persistMgr); - persistMgr->transfer(TMEMBER(_smartItemCursor)); - - if (!persistMgr->_saving) _initialScene = false; - - persistMgr->transfer(TMEMBER(_startupScene)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadGame(const char *filename) { - bool ret = CBGame::loadGame(filename); - if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::initAfterLoad() { - CBGame::initAfterLoad(); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdGame::afterLoadScene(void *scene, void *data) { - ((CAdScene *)scene)->afterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneName(const char *name) { - delete[] _prevSceneName; - _prevSceneName = NULL; - if (name) { - _prevSceneName = new char[strlen(name) + 1]; - if (_prevSceneName) strcpy(_prevSceneName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneFilename(const char *name) { - delete[] _prevSceneFilename; - _prevSceneFilename = NULL; - if (name) { - _prevSceneFilename = new char[strlen(name) + 1]; - if (_prevSceneFilename) strcpy(_prevSceneFilename, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { - delete[] _scheduledScene; - _scheduledScene = NULL; - - if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); - else { - _scheduledScene = new char [strlen(filename) + 1]; - strcpy(_scheduledScene, filename); - - _scheduledFadeIn = fadeIn; - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - CBGame::getVersion(verMajor, verMinor, NULL, NULL); - - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - //_filename = new char [strlen(filename)+1]; - //strcpy(_filename, filename); - - if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (!merge) { - while (_items.getSize() > 0) deleteItem(_items[0]); - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ITEM: { - CAdItem *item = new CAdItem(_gameRef); - if (item && !DID_FAIL(item->loadBuffer(params, false))) { - // delete item with the same name, if exists - if (merge) { - CAdItem *PrevItem = getItemByName(item->_name); - if (PrevItem) deleteItem(PrevItem); - } - addItem(item); - } else { - delete item; - item = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ITEMS definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ITEMS definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { - char *filenameCor = new char[strlen(filename) + 1]; - strcpy(filenameCor, filename); - for (uint32 i = 0; i < strlen(filenameCor); i++) { - if (filenameCor[i] == '/') filenameCor[i] = '\\'; - } - - for (int i = 0; i < _sceneStates.getSize(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { - delete [] filenameCor; - return _sceneStates[i]; - } - } - - if (saving) { - CAdSceneState *ret = new CAdSceneState(_gameRef); - ret->setFilename(filenameCor); - - _sceneStates.add(ret); - - delete [] filenameCor; - return ret; - } else { - delete [] filenameCor; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE_END - - int cmd = PARSERR_GENERIC; - CBParser parser(_gameRef); - - cmd = parser.getCommand(buffer, commands, params); - switch (cmd) { - case TOKEN_ENTITY_CONTAINER: { - CUIEntity *ent = new CUIEntity(_gameRef); - if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { - delete ent; - ent = NULL; - cmd = PARSERR_GENERIC; - } else { - ent->_parent = win; - win->_widgets.add(ent); - } - } - break; - } - - if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { - return STATUS_FAILED; - } - - return STATUS_OK; - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - if (strcmp(name, "CreateEntityContainer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIEntity *ent = new CUIEntity(_gameRef); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - - ent->_parent = win; - win->_widgets.add(ent); - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; - if (name) { - sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); - _dlgPendingBranches.add(name); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = NULL; - bool deleteName = false; - if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { - name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; - } else { - if (branchName != NULL) { - name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; - if (name) { - sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); - deleteName = true; - } - } - } - - if (name == NULL) return STATUS_OK; - - - int startIndex = -1; - for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { - if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { - startIndex = i; - break; - } - } - if (startIndex >= 0) { - for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { - //ClearBranchResponses(_dlgPendingBranches[i]); - delete [] _dlgPendingBranches[i]; - _dlgPendingBranches[i] = NULL; - } - _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); - } - - // dialogue is over, forget selected responses - if (_dlgPendingBranches.getSize() == 0) { - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - } - - if (deleteName) delete [] name; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::clearBranchResponses(char *name) { - for (int i = 0; i < _responsesBranch.getSize(); i++) { - if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.removeAt(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addBranchResponse(int ID) { - if (branchResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); - r->_iD = ID; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); - _responsesBranch.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::branchResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addGameResponse(int ID) { - if (gameResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); - r->_iD = ID; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); - _responsesGame.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::gameResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesGame.getSize(); i++) { - CAdResponseContext *RespContext = _responsesGame[i]; - if (RespContext->_iD == ID) { - if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetResponse(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - - int i; - - for (i = 0; i < _responsesGame.getSize(); i++) { - if (_responsesGame[i]->_iD == ID) { - if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { - delete _responsesGame[i]; - _responsesGame.removeAt(i); - break; - } - } - } - - for (i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.removeAt(i); - break; - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayContent(bool doUpdate, bool displayAll) { - // init - if (doUpdate) initLoop(); - - // fill black - _renderer->fill(0, 0, 0); - if (!_editorMode) _renderer->setScreenViewport(); - - // playing exclusive video? - if (_videoPlayer->isPlaying()) { - if (doUpdate) _videoPlayer->update(); - _videoPlayer->display(); - } else if (_theoraPlayer) { - if (_theoraPlayer->isPlaying()) { - if (doUpdate) _theoraPlayer->update(); - _theoraPlayer->display(); - } - if (_theoraPlayer->isFinished()) { - delete _theoraPlayer; - _theoraPlayer = NULL; - } - } else { - - // process scripts - if (doUpdate) _scEngine->tick(); - - Point32 p; - getMousePos(&p); - - _scene->update(); - _scene->display(); - - - // display in-game windows - displayWindows(true); - if (_inventoryBox) _inventoryBox->display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); - if (_indicatorDisplay) displayIndicator(); - - - if (doUpdate || displayAll) { - // display normal windows - displayWindows(false); - - setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); - - // textual info - displaySentences(_state == GAME_FROZEN); - - showCursor(); - - if (_fader) _fader->display(); - _transMgr->update(); - } - - } - if (_loadingIcon) { - _loadingIcon->display(_loadingIconX, _loadingIconY); - if (!_loadingIconPersistent) { - delete _loadingIcon; - _loadingIcon = NULL; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::registerInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { - if (_inventories[i] == inv) return STATUS_OK; - } - registerObject(inv); - _inventories.add(inv); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::unregisterInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { - if (_inventories[i] == inv) { - unregisterObject(_inventories[i]); - _inventories.removeAt(i); - return STATUS_OK; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::isItemTaken(char *itemName) { - for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::getItemByName(const char *name) { - for (int i = 0; i < _items.getSize(); i++) { - if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addItem(CAdItem *item) { - _items.add(item); - return _gameRef->registerObject(item); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetContent() { - // clear pending dialogs - for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.removeAll(); - - - // clear inventories - for (int i = 0; i < _inventories.getSize(); i++) { - _inventories[i]->_takenItems.removeAll(); - } - - // clear scene states - for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; - _sceneStates.removeAll(); - - // clear once responses - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - - // clear once game responses - for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; - _responsesGame.removeAll(); - - // reload inventory items - if (_itemsFile) loadItemsFile(_itemsFile); - - _tempDisableSaveState = true; - - return CBGame::resetContent(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::deleteItem(CAdItem *item) { - if (!item) return STATUS_FAILED; - - if (_selectedItem == item) _selectedItem = NULL; - _scene->handleItemAssociations(item->_name, false); - - // remove from all inventories - for (int i = 0; i < _inventories.getSize(); i++) { - _inventories[i]->removeItem(item); - } - - // remove object - for (int i = 0; i < _items.getSize(); i++) { - if (_items[i] == item) { - unregisterObject(_items[i]); - _items.removeAt(i); - break; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; - - char *temp = new char[strlen(dir) + 2]; - strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') - strcat(temp, "\\"); - - for (int i = 0; i < _speechDirs.getSize(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] temp; - return STATUS_OK; - } - } - _speechDirs.add(temp); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; - - char *temp = new char[strlen(dir) + 2]; - strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') - strcat(temp, "\\"); - - bool Found = false; - for (int i = 0; i < _speechDirs.getSize(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] _speechDirs[i]; - _speechDirs.removeAt(i); - Found = true; - break; - } - } - delete [] temp; - - if (Found) return STATUS_OK; - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdGame::findSpeechFile(char *stringID) { - char *ret = new char[MAX_PATH_LENGTH]; - - for (int i = 0; i < _speechDirs.getSize(); i++) { - sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile - if (file) { - _fileManager->closeFile(file); - return ret; - } - - sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - file = _fileManager->openFile(ret); - if (file) { - _fileManager->closeFile(file); - return ret; - } - } - delete [] ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::validMouse() { - Point32 pos; - CBPlatform::getCursorPos(&pos); - - return _renderer->pointInViewport(&pos); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDown() { - if (!validMouse()) return STATUS_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { - finishSentences(); - } - return STATUS_OK; - } - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; - _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDblClick() { - if (!validMouse()) return STATUS_OK; - - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightDown() { - if (!validMouse()) return STATUS_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { - finishSentences(); - } - return STATUS_OK; - } - - if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayDebugInfo() { - char str[100]; - if (_gameRef->_debugDebugMode) { - sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); - _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - - sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); - } - return CBGame::displayDebugInfo(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onScriptShutdown(CScScript *script) { - if (_responseBox && _responseBox->_waitingScript == script) - _responseBox->_waitingScript = NULL; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdGame.h b/engines/wintermute/Ad/AdGame.h deleted file mode 100644 index d677083db0..0000000000 --- a/engines/wintermute/Ad/AdGame.h +++ /dev/null @@ -1,161 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_ADGAME_H -#define WINTERMUTE_ADGAME_H - -#include "engines/wintermute/Ad/AdTypes.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { -class CAdItem; -class CAdInventory; -class CAdSceneState; -class CAdScene; -class CAdItem; -class CAdObject; -class CAdSentence; -class CAdInventoryBox; -class CAdResponseContext; -class CAdResponseBox; -class CAdGame : public CBGame { -public: - virtual bool onScriptShutdown(CScScript *script); - - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - - virtual bool displayDebugInfo(); - - - virtual bool initAfterLoad(); - static void afterLoadScene(void *scene, void *data); - - bool _smartItemCursor; - - CBArray _speechDirs; - bool addSpeechDir(const char *dir); - bool removeSpeechDir(const char *dir); - char *findSpeechFile(char *StringID); - - bool deleteItem(CAdItem *Item); - char *_itemsFile; - bool _tempDisableSaveState; - virtual bool resetContent(); - bool addItem(CAdItem *item); - CAdItem *getItemByName(const char *name); - CBArray _items; - CAdObject *_inventoryOwner; - bool isItemTaken(char *itemName); - bool registerInventory(CAdInventory *inv); - bool unregisterInventory(CAdInventory *inv); - - CAdObject *_invObject; - CBArray _inventories; - virtual bool displayContent(bool update = true, bool displayAll = false); - char *_debugStartupScene; - char *_startupScene; - bool _initialScene; - bool gameResponseUsed(int ID); - bool addGameResponse(int ID); - bool resetResponse(int ID); - - bool branchResponseUsed(int ID); - bool addBranchResponse(int ID); - bool clearBranchResponses(char *name); - bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - - CAdSceneState *getSceneState(const char *filename, bool saving); - CBViewport *_sceneViewport; - int _texItemLifeTime; - int _texWalkLifeTime; - int _texStandLifeTime; - int _texTalkLifeTime; - - TTalkSkipButton _talkSkipButton; - - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - bool scheduleChangeScene(const char *filename, bool fadeIn); - char *_scheduledScene; - bool _scheduledFadeIn; - void setPrevSceneName(const char *name); - void setPrevSceneFilename(const char *name); - char *_prevSceneName; - char *_prevSceneFilename; - virtual bool loadGame(const char *filename); - CAdItem *_selectedItem; - bool cleanup(); - DECLARE_PERSISTENT(CAdGame, CBGame) - - void finishSentences(); - bool showCursor(); - TGameStateEx _stateEx; - CAdResponseBox *_responseBox; - CAdInventoryBox *_inventoryBox; - bool displaySentences(bool frozen); - void addSentence(CAdSentence *sentence); - bool changeScene(const char *filename, bool fadeIn); - bool removeObject(CAdObject *object); - bool addObject(CAdObject *object); - CAdScene *_scene; - bool initLoop(); - CAdGame(); - virtual ~CAdGame(); - CBArray _objects; - CBArray _sentences; - - CBArray _sceneStates; - CBArray _dlgPendingBranches; - - CBArray _responsesBranch; - CBArray _responsesGame; - - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - - bool loadItemsFile(const char *filename, bool merge = false); - bool loadItemsBuffer(byte *buffer, bool merge = false); - - - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - bool validMouse(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp deleted file mode 100644 index 30cb5e5b77..0000000000 --- a/engines/wintermute/Ad/AdInventory.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventory, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { - _scrollOffset = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventory::~CAdInventory() { - _takenItems.removeAll(); // ref only -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) return STATUS_FAILED; - - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); - if (item == NULL) return STATUS_FAILED; - - int insertIndex = -1; - for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - _takenItems.removeAt(i); - i--; - continue; - } - if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; - } - - - if (insertIndex == -1) _takenItems.add(item); - else _takenItems.insertAt(insertIndex, item); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(const char *name) { - if (name == NULL) return STATUS_FAILED; - - for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; - _takenItems.removeAt(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(CAdItem *item) { - if (item == NULL) return STATUS_FAILED; - - for (int i = 0; i < _takenItems.getSize(); i++) { - if (_takenItems[i] == item) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; - _takenItems.removeAt(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - _takenItems.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventory.h b/engines/wintermute/Ad/AdInventory.h deleted file mode 100644 index 14929c8c4b..0000000000 --- a/engines/wintermute/Ad/AdInventory.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORY_H -#define WINTERMUTE_ADINVENTORY_H - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CAdItem; - -class CAdInventory : public CBObject { -public: - DECLARE_PERSISTENT(CAdInventory, CBObject) - bool removeItem(const char *name); - bool removeItem(CAdItem *Item); - bool insertItem(const char *name, const char *insertAfter = NULL); - CAdInventory(CBGame *inGame); - virtual ~CAdInventory(); - CBArray _takenItems; - int _scrollOffset; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp deleted file mode 100644 index 2e767574da..0000000000 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdInventoryBox.h" -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/UI/UIButton.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include "common/rect.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventoryBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - _itemsArea.setEmpty(); - _scrollOffset = 0; - _spacing = 0; - _itemWidth = _itemHeight = 50; - _scrollBy = 1; - - _window = NULL; - _closeButton = NULL; - - _hideSelected = false; - - _visible = false; - _exclusive = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::~CAdInventoryBox() { - _gameRef->unregisterObject(_window); - _window = NULL; - - delete _closeButton; - _closeButton = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) { - _visible = false; - } else if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset -= _scrollBy; - _scrollOffset = MAX(_scrollOffset, 0); - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset += _scrollBy; - } else return CBObject::listen(param1, param2); - break; - default: - error("CAdInventoryBox::Listen - Unhandled enum"); - break; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::display() { - CAdGame *adGame = (CAdGame *)_gameRef; - - if (!_visible) return STATUS_OK; - - int itemsX, itemsY; - itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); - itemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); - - if (_window) { - _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); - } - - - if (_closeButton) { - _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = _gameRef->_renderer->_width; - _closeButton->_height = _gameRef->_renderer->_height; - - _closeButton->display(); - } - - - // display window - Rect32 rect = _itemsArea; - if (_window) { - rect.offsetRect(_window->_posX, _window->_posY); - _window->display(); - } - - // display items - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; - int yyy = rect.top; - for (int j = 0; j < itemsY; j++) { - int xxx = rect.left; - for (int i = 0; i < itemsX; i++) { - int itemIndex = _scrollOffset + j * itemsX + i; - if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { - CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; - if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { - item->update(); - item->display(xxx, yyy); - } - } - - xxx += (_itemWidth + _spacing); - } - yyy += (_itemHeight + _spacing); - } - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(WINDOW) -TOKEN_DEF(EXCLUSIVE) -TOKEN_DEF(ALWAYS_VISIBLE) -TOKEN_DEF(AREA) -TOKEN_DEF(SPACING) -TOKEN_DEF(ITEM_WIDTH) -TOKEN_DEF(ITEM_HEIGHT) -TOKEN_DEF(SCROLL_BY) -TOKEN_DEF(NAME) -TOKEN_DEF(CAPTION) -TOKEN_DEF(HIDE_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(EXCLUSIVE) - TOKEN_TABLE(ALWAYS_VISIBLE) - TOKEN_TABLE(AREA) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(ITEM_WIDTH) - TOKEN_TABLE(ITEM_HEIGHT) - TOKEN_TABLE(SCROLL_BY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(HIDE_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - bool always_visible = false; - - _exclusive = false; - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { - _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(_gameRef); - if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else _gameRef->registerObject(_window); - break; - - case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); - break; - - case TOKEN_EXCLUSIVE: - parser.scanStr((char *)params, "%b", &_exclusive); - break; - - case TOKEN_HIDE_SELECTED: - parser.scanStr((char *)params, "%b", &_hideSelected); - break; - - case TOKEN_ALWAYS_VISIBLE: - parser.scanStr((char *)params, "%b", &always_visible); - break; - - case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_ITEM_WIDTH: - parser.scanStr((char *)params, "%d", &_itemWidth); - break; - - case TOKEN_ITEM_HEIGHT: - parser.scanStr((char *)params, "%d", &_itemHeight); - break; - - case TOKEN_SCROLL_BY: - parser.scanStr((char *)params, "%d", &_scrollBy); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading INVENTORY_BOX definition"); - return STATUS_FAILED; - } - - if (_exclusive) { - delete _closeButton; - _closeButton = new CUIButton(_gameRef); - if (_closeButton) { - _closeButton->setName("close"); - _closeButton->setListener(this, _closeButton, 0); - _closeButton->_parent = _window; - } - } - - _visible = always_visible; - - if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "INVENTORY_BOX\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - - buffer->putTextIndent(indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); - buffer->putTextIndent(indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); - buffer->putTextIndent(indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); - buffer->putTextIndent(indent + 2, "SCROLL_BY=%d\n", _scrollBy); - - buffer->putTextIndent(indent + 2, "\n"); - - // window - if (_window) _window->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_closeButton)); - persistMgr->transfer(TMEMBER(_hideSelected)); - persistMgr->transfer(TMEMBER(_itemHeight)); - persistMgr->transfer(TMEMBER(_itemsArea)); - persistMgr->transfer(TMEMBER(_itemWidth)); - persistMgr->transfer(TMEMBER(_scrollBy)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_window)); - persistMgr->transfer(TMEMBER(_exclusive)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdInventoryBox.h b/engines/wintermute/Ad/AdInventoryBox.h deleted file mode 100644 index f6beae2d46..0000000000 --- a/engines/wintermute/Ad/AdInventoryBox.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORYBOX_H -#define WINTERMUTE_ADINVENTORYBOX_H - -#include "engines/wintermute/Base/BObject.h" -#include "common/rect.h" - -namespace WinterMute { -class CUIButton; -class CUIWindow; - -class CAdInventoryBox : public CBObject { -public: - bool _hideSelected; - DECLARE_PERSISTENT(CAdInventoryBox, CBObject) - bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; - bool _visible; - virtual bool display(); - CUIButton *_closeButton; - int _spacing; - int _scrollOffset; - Rect32 _itemsArea; - bool listen(CBScriptHolder *param1, uint32 param2); - CUIWindow *_window; - CAdInventoryBox(CBGame *inGame); - virtual ~CAdInventoryBox(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp deleted file mode 100644 index be2177456f..0000000000 --- a/engines/wintermute/Ad/AdItem.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdItem, false) - -////////////////////////////////////////////////////////////////////////// -CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { - _spriteHover = NULL; - _cursorNormal = _cursorHover = NULL; - - _cursorCombined = true; - _inInventory = false; - - _displayAmount = false; - _amount = 0; - _amountOffsetX = 0; - _amountOffsetY = 0; - _amountAlign = TAL_RIGHT; - _amountString = NULL; - - _state = STATE_READY; - - _movable = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdItem::~CAdItem() { - delete _spriteHover; - delete _cursorNormal; - delete _cursorHover; - _spriteHover = NULL; - _cursorNormal = NULL; - _cursorHover = NULL; - - delete[] _amountString; - _amountString = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ITEM) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(CURSOR_HOVER) -TOKEN_DEF(CURSOR_COMBINED) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(FONT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(SPRITE_HOVER) -TOKEN_DEF(SPRITE) -TOKEN_DEF(DISPLAY_AMOUNT) -TOKEN_DEF(AMOUNT_OFFSET_X) -TOKEN_DEF(AMOUNT_OFFSET_Y) -TOKEN_DEF(AMOUNT_ALIGN) -TOKEN_DEF(AMOUNT_STRING) -TOKEN_DEF(AMOUNT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(CURSOR_HOVER) - TOKEN_TABLE(CURSOR_COMBINED) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(FONT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(SPRITE_HOVER) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(DISPLAY_AMOUNT) - TOKEN_TABLE(AMOUNT_OFFSET_X) - TOKEN_TABLE(AMOUNT_OFFSET_Y) - TOKEN_TABLE(AMOUNT_ALIGN) - TOKEN_TABLE(AMOUNT_STRING) - TOKEN_TABLE(AMOUNT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { - _gameRef->LOG(0, "'ITEM' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_IMAGE: - case TOKEN_SPRITE: - delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _sprite; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - case TOKEN_SPRITE_HOVER: - delete _spriteHover; - _spriteHover = new CBSprite(_gameRef, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _spriteHover; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_AMOUNT: - parser.scanStr((char *)params, "%d", &_amount); - break; - - case TOKEN_DISPLAY_AMOUNT: - parser.scanStr((char *)params, "%b", &_displayAmount); - break; - - case TOKEN_AMOUNT_OFFSET_X: - parser.scanStr((char *)params, "%d", &_amountOffsetX); - break; - - case TOKEN_AMOUNT_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_amountOffsetY); - break; - - case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; - else _amountAlign = TAL_CENTER; - break; - - case TOKEN_AMOUNT_STRING: - CBUtils::setString(&_amountString, (char *)params); - break; - - case TOKEN_TALK: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - } - break; - - case TOKEN_CURSOR: - delete _cursorNormal; - _cursorNormal = new CBSprite(_gameRef); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _cursorNormal; - _cursorNormal = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_HOVER: - delete _cursorHover; - _cursorHover = new CBSprite(_gameRef); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _cursorHover; - _cursorHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_COMBINED: - parser.scanStr((char *)params, "%b", &_cursorCombined); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ITEM definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ITEM definition"); - return STATUS_FAILED; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) { - if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; - else _currentSprite = _sprite; - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - default: - break; - } - _ready = (_state == STATE_READY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::display(int x, int y) { - int width = 0; - if (_currentSprite) { - Rect32 rc; - _currentSprite->getBoundingRect(&rc, 0, 0); - width = rc.width(); - } - - _posX = x + width / 2; - _posY = y; - - bool ret; - if (_currentSprite) - ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); - else ret = STATUS_OK; - - if (_displayAmount) { - int amountX = x; - int amountY = y + _amountOffsetY; - - if (_amountAlign == TAL_RIGHT) { - width -= _amountOffsetX; - amountX -= _amountOffsetX; - } - amountX += _amountOffsetX; - - CBFont *font = _font ? _font : _gameRef->_systemFont; - if (font) { - if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); - else { - char Str[256]; - sprintf(Str, "%d", _amount); - font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); - } - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetHoverSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetHoverSprite") == 0) { - stack->correctParams(1); - - bool setCurrent = false; - if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; - - const char *filename = stack->pop()->getString(); - - delete _spriteHover; - _spriteHover = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); - } else { - _spriteHover = spr; - if (setCurrent) _currentSprite = _spriteHover; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverSprite") == 0) { - stack->correctParams(0); - - if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); - else stack->pushString(_spriteHover->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverSpriteObject") == 0) { - stack->correctParams(0); - if (!_spriteHover) stack->pushNULL(); - else stack->pushNative(_spriteHover, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetNormalCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetNormalCursor") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - delete _cursorNormal; - _cursorNormal = NULL; - CBSprite *spr = new CBSprite(_gameRef); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); - } else { - _cursorNormal = spr; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNormalCursor") == 0) { - stack->correctParams(0); - - if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); - else stack->pushString(_cursorNormal->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNormalCursorObject") == 0) { - stack->correctParams(0); - - if (!_cursorNormal) stack->pushNULL(); - else stack->pushNative(_cursorNormal, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetHoverCursor") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - delete _cursorHover; - _cursorHover = NULL; - CBSprite *spr = new CBSprite(_gameRef); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); - } else { - _cursorHover = spr; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverCursor") == 0) { - stack->correctParams(0); - - if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); - else stack->pushString(_cursorHover->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverCursorObject") == 0) { - stack->correctParams(0); - - if (!_cursorHover) stack->pushNULL(); - else stack->pushNative(_cursorHover, true); - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("item"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayAmount") == 0) { - _scValue->setBool(_displayAmount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Amount") == 0) { - _scValue->setInt(_amount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetX") == 0) { - _scValue->setInt(_amountOffsetX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetY") == 0) { - _scValue->setInt(_amountOffsetY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountAlign") == 0) { - _scValue->setInt(_amountAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountString") == 0) { - if (!_amountString) _scValue->setNULL(); - else _scValue->setString(_amountString); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { - _scValue->setBool(_cursorCombined); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayAmount") == 0) { - _displayAmount = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Amount") == 0) { - _amount = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetX") == 0) { - _amountOffsetX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetY") == 0) { - _amountOffsetY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountAlign") == 0) { - _amountAlign = (TTextAlign)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountString") == 0) { - if (value->isNULL()) { - delete[] _amountString; - _amountString = NULL; - } else { - CBUtils::setString(&_amountString, value->getString()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { - _cursorCombined = value->getBool(); - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdItem::scToString() { - return "[item]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::persist(CBPersistMgr *persistMgr) { - - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_cursorCombined)); - persistMgr->transfer(TMEMBER(_cursorHover)); - persistMgr->transfer(TMEMBER(_cursorNormal)); - persistMgr->transfer(TMEMBER(_spriteHover)); - persistMgr->transfer(TMEMBER(_inInventory)); - persistMgr->transfer(TMEMBER(_displayAmount)); - persistMgr->transfer(TMEMBER(_amount)); - persistMgr->transfer(TMEMBER(_amountOffsetX)); - persistMgr->transfer(TMEMBER(_amountOffsetY)); - persistMgr->transfer(TMEMBER_INT(_amountAlign)); - persistMgr->transfer(TMEMBER(_amountString)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - else return CAdObject::getExtendedFlag(flagName); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdItem.h b/engines/wintermute/Ad/AdItem.h deleted file mode 100644 index fbbcd608d1..0000000000 --- a/engines/wintermute/Ad/AdItem.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADITEM_H -#define WINTERMUTE_ADITEM_H - - -#include "engines/wintermute/Ad/AdTalkHolder.h" - -namespace WinterMute { - -class CAdItem : public CAdTalkHolder { -public: - bool _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; - TTextAlign _amountAlign; - char *_amountString; - - - bool update(); - DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - bool display(int x, int y); - bool getExtendedFlag(const char *flagName); - bool _inInventory; - bool _cursorCombined; - CBSprite *_spriteHover; - CBSprite *_cursorNormal; - CBSprite *_cursorHover; - CAdItem(CBGame *inGame); - virtual ~CAdItem(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp deleted file mode 100644 index 1dd1efb8a6..0000000000 --- a/engines/wintermute/Ad/AdLayer.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Ad/AdLayer.h" -#include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdLayer, false) - -////////////////////////////////////////////////////////////////////////// -CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { - _main = false; - _width = _height = 0; - _active = true; - _closeUp = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdLayer::~CAdLayer() { - for (int i = 0; i < _nodes.getSize(); i++) - delete _nodes[i]; - _nodes.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(LAYER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(MAIN) -TOKEN_DEF(ENTITY) -TOKEN_DEF(REGION) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(CLOSE_UP) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(MAIN) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(REGION) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(CLOSE_UP) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { - _gameRef->LOG(0, "'LAYER' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_MAIN: - parser.scanStr((char *)params, "%b", &_main); - break; - - case TOKEN_CLOSE_UP: - parser.scanStr((char *)params, "%b", &_closeUp); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_REGION: { - CAdRegion *region = new CAdRegion(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete region; - delete node; - region = NULL; - node = NULL; - } else { - node->setRegion(region); - _nodes.add(node); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (entity) entity->_zoomable = false; // scene entites default to NOT zoom - if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - delete node; - entity = NULL; - node = NULL; - } else { - node->setEntity(entity); - _nodes.add(node); - } - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in LAYER definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - int node = -1; - - if (val->_type == VAL_INT) node = val->getInt(); - else { // get by name - for (int i = 0; i < _nodes.getSize(); i++) { - if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || - (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { - node = i; - break; - } - } - } - - if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); - else { - switch (_nodes[node]->_type) { - case OBJECT_ENTITY: - stack->pushNative(_nodes[node]->_entity, true); - break; - case OBJECT_REGION: - stack->pushNative(_nodes[node]->_region, true); - break; - default: - stack->pushNULL(); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddRegion / AddEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (strcmp(name, "AddRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); - node->setRegion(region); - stack->pushNative(region, true); - } else { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); - node->setEntity(entity); - stack->pushNative(entity, true); - } - _nodes.add(node); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertRegion / InsertEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (strcmp(name, "InsertRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); - node->setRegion(region); - stack->pushNative(region, true); - } else { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); - node->setEntity(entity); - stack->pushNative(entity, true); - } - if (index < 0) index = 0; - if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); - else _nodes.add(node); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdSceneNode *toDelete = NULL; - if (val->isNative()) { - CBScriptable *temp = val->getNative(); - for (int i = 0; i < _nodes.getSize(); i++) { - if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { - toDelete = _nodes[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < _nodes.getSize()) { - toDelete = _nodes[index]; - } - } - if (toDelete == NULL) { - stack->pushBool(false); - return STATUS_OK; - } - - for (int i = 0; i < _nodes.getSize(); i++) { - if (_nodes[i] == toDelete) { - delete _nodes[i]; - _nodes[i] = NULL; - _nodes.removeAt(i); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("layer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumNodes") == 0) { - _scValue->setInt(_nodes.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Main (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Main") == 0) { - _scValue->setBool(_main); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CloseUp") == 0) { - _scValue->setBool(_closeUp); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CloseUp") == 0) { - _closeUp = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - if (_width < 0) _width = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - if (_height < 0) _height = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - bool b = value->getBool(); - if (b == false && _main) { - _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); - } else _active = b; - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdLayer::scToString() { - return "[layer]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "LAYER {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_closeUp) - buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - for (i = 0; i < _nodes.getSize(); i++) { - switch (_nodes[i]->_type) { - case OBJECT_ENTITY: - _nodes[i]->_entity->saveAsText(buffer, indent + 2); - break; - case OBJECT_REGION: - _nodes[i]->_region->saveAsText(buffer, indent + 2); - break; - default: - error("CAdLayer::SaveAsText - Unhandled enum"); - break; - } - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_closeUp)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_main)); - _nodes.persist(persistMgr); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdLayer.h b/engines/wintermute/Ad/AdLayer.h deleted file mode 100644 index 0ccdb13ae7..0000000000 --- a/engines/wintermute/Ad/AdLayer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADLAYER_H -#define WINTERMUTE_ADLAYER_H - -namespace WinterMute { -class CAdSceneNode; -class CAdLayer : public CBObject { -public: - bool _closeUp; - DECLARE_PERSISTENT(CAdLayer, CBObject) - bool _active; - int _height; - int _width; - bool _main; - CAdLayer(CBGame *inGame); - virtual ~CAdLayer(); - CBArray _nodes; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp deleted file mode 100644 index 5037ec0272..0000000000 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Ad/AdNodeState.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdNodeState, false) - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { - _name = NULL; - _active = false; - for (int i = 0; i < 7; i++) _caption[i] = NULL; - _alphaColor = 0; - _filename = NULL; - _cursor = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::~CAdNodeState() { - delete[] _name; - delete[] _filename; - delete[] _cursor; - _name = NULL; - _filename = NULL; - _cursor = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setName(const char *name) { - delete[] _name; - _name = NULL; - CBUtils::setString(&_name, name); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setFilename(const char *filename) { - delete[] _filename; - _filename = NULL; - CBUtils::setString(&_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCursor(const char *filename) { - delete[] _cursor; - _cursor = NULL; - CBUtils::setString(&_cursor, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCaption(const char *caption, int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7) return; - - delete[] _caption[caseVal- 1]; - _caption[caseVal- 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal- 1]) { - strcpy(_caption[caseVal- 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal- 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::getCaption(int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; - else return _caption[caseVal- 1]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { - if (!entity) return STATUS_FAILED; - - // hack! - if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; - - if (saving) { - for (int i = 0; i < 7; i++) { - if (entity->_caption[i]) setCaption(entity->_caption[i], i); - } - if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { - if (includingSprites) setFilename(entity->_sprite->_filename); - else setFilename(""); - } - if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); - _alphaColor = entity->_alphaColor; - _active = entity->_active; - } else { - for (int i = 0; i < 7; i++) { - if (_caption[i]) entity->setCaption(_caption[i], i); - } - if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { - if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) - entity->setSprite(_filename); - } - if (_cursor) { - if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) - entity->setCursor(_cursor); - } - - entity->_active = _active; - entity->_alphaColor = _alphaColor; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdNodeState.h b/engines/wintermute/Ad/AdNodeState.h deleted file mode 100644 index 186f2ebbb2..0000000000 --- a/engines/wintermute/Ad/AdNodeState.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADNODESTATE_H -#define WINTERMUTE_ADNODESTATE_H - -namespace WinterMute { - -class CAdEntity; - -class CAdNodeState : public CBBase { -public: - bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); - void setName(const char *name); - void setFilename(const char *filename); - void setCursor(const char *filename); - DECLARE_PERSISTENT(CAdNodeState, CBBase) - CAdNodeState(CBGame *inGame); - virtual ~CAdNodeState(); - char *_name; - bool _active; - char *_caption[7]; - void setCaption(const char *caption, int caseVal); - char *getCaption(int caseVal); - uint32 _alphaColor; - char *_filename; - char *_cursor; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp deleted file mode 100644 index 451fca7fa6..0000000000 --- a/engines/wintermute/Ad/AdObject.cpp +++ /dev/null @@ -1,1203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/Ad/AdObject.h" -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdLayer.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "common/str.h" -#include "common/util.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdObject, false) - -////////////////////////////////////////////////////////////////////////// -CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _state = _nextState = STATE_NONE; - - _active = true; - _drawn = false; - - _currentSprite = NULL; - _animSprite = NULL; - _tempSprite2 = NULL; - - _font = NULL; - - _sentence = NULL; - - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - - _blockRegion = NULL; - _wptGroup = NULL; - - _currentBlockRegion = NULL; - _currentWptGroup = NULL; - - _ignoreItems = false; - _sceneIndependent = false; - - _stickRegion = NULL; - - _subtitlesModRelative = true; - _subtitlesModX = 0; - _subtitlesModY = 0; - _subtitlesWidth = 0; - _subtitlesModXCenter = true; - - _inventory = NULL; - - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - - _partEmitter = NULL; - _partFollowParent = false; - _partOffsetX = _partOffsetY = 0; - - _registerAlias = this; -} - - -////////////////////////////////////////////////////////////////////////// -CAdObject::~CAdObject() { - _currentSprite = NULL; // reference only, don't delete - delete _animSprite; - _animSprite = NULL; - delete _sentence; - _sentence = NULL; - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - - delete _blockRegion; - _blockRegion = NULL; - delete _wptGroup; - _wptGroup = NULL; - - delete _currentBlockRegion; - _currentBlockRegion = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - - _tempSprite2 = NULL; // reference only - _stickRegion = NULL; - - if (_font) _gameRef->_fontStorage->removeFont(_font); - - if (_inventory) { - ((CAdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; - } - - if (_partEmitter) - _gameRef->unregisterObject(_partEmitter); - - - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - _gameRef->unregisterObject(_attachmentsPre[i]); - } - _attachmentsPre.removeAll(); - - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - _gameRef->unregisterObject(_attachmentsPost[i]); - } - _attachmentsPost.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::playAnim(const char *filename) { - delete _animSprite; - _animSprite = NULL; - _animSprite = new CBSprite(_gameRef, this); - if (!_animSprite) { - _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); - return STATUS_FAILED; - } - bool res = _animSprite->loadFile(filename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); - delete _animSprite; - _animSprite = NULL; - return res; - } - _state = STATE_PLAYING_ANIM; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::display() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::update() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // PlayAnim / PlayAnimAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { - stack->correctParams(1); - if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); - else { - if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTalking") == 0) { - stack->correctParams(0); - stack->pushBool(_state == STATE_TALKING); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTalk / StopTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { - stack->correctParams(0); - if (_sentence) _sentence->finish(); - if (_state == STATE_TALKING) { - _state = _nextState; - _nextState = STATE_READY; - stack->pushBool(true); - } else stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ForceTalkAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ForceTalkAnim") == 0) { - stack->correctParams(1); - const char *animName = stack->pop()->getString(); - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = new char[strlen(animName) + 1]; - strcpy(_forcedTalkAnimName, animName); - _forcedTalkAnimUsed = false; - stack->pushBool(true); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Talk / TalkAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { - stack->correctParams(5); - - const char *text = stack->pop()->getString(); - CScValue *soundVal = stack->pop(); - int duration = stack->pop()->getInt(); - CScValue *valStances = stack->pop(); - - const char *stances = valStances->isNULL() ? NULL : valStances->getString(); - - int align = 0; - CScValue *val = stack->pop(); - if (val->isNULL()) align = TAL_CENTER; - else align = val->getInt(); - - align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); - - const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); - - talk(text, sound, duration, stances, (TTextAlign)align); - if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StickToRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StickToRegion") == 0) { - stack->correctParams(1); - - CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; - bool regFound = false; - - int i; - CScValue *val = stack->pop(); - if (val->isNULL() || !main) { - _stickRegion = NULL; - regFound = true; - } else if (val->isString()) { - const char *regionName = val->getString(); - for (i = 0; i < main->_nodes.getSize(); i++) { - if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { - _stickRegion = main->_nodes[i]->_region; - regFound = true; - break; - } - } - } else if (val->isNative()) { - CBScriptable *obj = val->getNative(); - - for (i = 0; i < main->_nodes.getSize(); i++) { - if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { - _stickRegion = main->_nodes[i]->_region; - regFound = true; - break; - } - } - - } - - if (!regFound) _stickRegion = NULL; - stack->pushBool(regFound); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (val->isNULL()) SetFont(NULL); - else SetFont(val->getString()); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFont") == 0) { - stack->correctParams(0); - if (_font && _font->_filename) stack->pushString(_font->_filename); - else stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TakeItem") == 0) { - stack->correctParams(2); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - const char *itemName = val->getString(); - val = stack->pop(); - const char *insertAfter = val->isNULL() ? NULL : val->getString(); - if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); - else { - // hide associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); - } - - } else script->runtimeError("TakeItem: item name expected"); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DropItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); - else { - // show associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); - } - } else script->runtimeError("DropItem: item name expected"); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); - if (item) stack->pushNative(item, true); - else stack->pushNULL(); - } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) - stack->pushNULL(); - else - stack->pushNative(_inventory->_takenItems[val->getInt()], true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { - if (val->getNative() == _inventory->_takenItems[i]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { - stack->pushBool(true); - return STATUS_OK; - } - } - } else script->runtimeError("HasItem: item name expected"); - - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateParticleEmitter") == 0) { - stack->correctParams(3); - bool followParent = stack->pop()->getBool(); - int offsetX = stack->pop()->getInt(); - int offsetY = stack->pop()->getInt(); - - CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); - if (emitter) stack->pushNative(_partEmitter, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteParticleEmitter") == 0) { - stack->correctParams(0); - if (_partEmitter) { - _gameRef->unregisterObject(_partEmitter); - _partEmitter = NULL; - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddAttachment") == 0) { - stack->correctParams(4); - const char *filename = stack->pop()->getString(); - bool preDisplay = stack->pop()->getBool(true); - int offsetX = stack->pop()->getInt(); - int offsetY = stack->pop()->getInt(); - - bool res; - CAdEntity *ent = new CAdEntity(_gameRef); - if (DID_FAIL(res = ent->loadFile(filename))) { - delete ent; - ent = NULL; - script->runtimeError("AddAttachment() failed loading entity '%s'", filename); - stack->pushBool(false); - } else { - _gameRef->registerObject(ent); - - ent->_posX = offsetX; - ent->_posY = offsetY; - ent->_active = true; - - if (preDisplay) _attachmentsPre.add(ent); - else _attachmentsPost.add(ent); - - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveAttachment") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - bool found = false; - if (val->isNative()) { - CBScriptable *obj = val->getNative(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); - i--; - } - } - } else { - const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - found = true; - _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - found = true; - _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); - i--; - } - } - } - stack->pushBool(found); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAttachment") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - int currIndex = 0; - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPre[i]; - currIndex++; - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPost[i]; - currIndex++; - } - } else { - const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - ret = _attachmentsPre[i]; - break; - } - } - if (!ret) { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - ret = _attachmentsPre[i]; - break; - } - } - } - } - - if (ret != NULL) stack->pushNative(ret, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IgnoreItems") == 0) { - _scValue->setBool(_ignoreItems); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SceneIndependent") == 0) { - _scValue->setBool(_sceneIndependent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesWidth") == 0) { - _scValue->setInt(_subtitlesWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _scValue->setBool(_subtitlesModRelative); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosX") == 0) { - _scValue->setInt(_subtitlesModX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosY") == 0) { - _scValue->setInt(_subtitlesModY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _scValue->setBool(_subtitlesModXCenter); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumItems (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { - _scValue->setInt(getInventory()->_takenItems.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParticleEmitter (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParticleEmitter") == 0) { - if (_partEmitter) _scValue->setNative(_partEmitter, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumAttachments (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumAttachments") == 0) { - _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); - return _scValue; - } - - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IgnoreItems") == 0) { - _ignoreItems = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SceneIndependent") == 0) { - _sceneIndependent = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesWidth") == 0) { - _subtitlesWidth = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _subtitlesModRelative = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosX") == 0) { - _subtitlesModX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosY") == 0) { - _subtitlesModY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _subtitlesModXCenter = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdObject::scToString() { - return "[ad object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::SetFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (filename) { - _font = _gameRef->_fontStorage->addFont(filename); - return _font == NULL ? STATUS_FAILED : STATUS_OK; - } else { - _font = NULL; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CAdObject::getHeight() { - if (!_currentSprite) return 0; - else { - CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; - int ret = 0; - for (int i = 0; i < frame->_subframes.getSize(); i++) { - ret = MAX(ret, frame->_subframes[i]->_hotspotY); - } - - if (_zoomable) { - float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); - ret = (int)(ret * zoom / 100); - } - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { - if (!_sentence) _sentence = new CAdSentence(_gameRef); - if (!_sentence) return; - - if (_forcedTalkAnimName && _forcedTalkAnimUsed) { - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - } - - delete(_sentence->_sound); - _sentence->_sound = NULL; - - _sentence->setText(text); - _gameRef->_stringTable->expand(&_sentence->_text); - _sentence->setStances(stances); - _sentence->_duration = duration; - _sentence->_align = Align; - _sentence->_startTime = _gameRef->_timer; - _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; - _sentence->_freezable = _freezable; - - // try to locate speech file automatically - bool deleteSound = false; - if (!sound) { - char *key = _gameRef->_stringTable->getKey(text); - if (key) { - sound = ((CAdGame *)_gameRef)->findSpeechFile(key); - delete [] key; - - if (sound) deleteSound = true; - } - } - - // load sound and set duration appropriately - if (sound) { - CBSound *snd = new CBSound(_gameRef); - if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { - _sentence->setSound(snd); - if (_sentence->_duration <= 0) { - uint32 Length = snd->getLength(); - if (Length != 0) _sentence->_duration = Length; - } - } else delete snd; - } - - // set duration by text length - if (_sentence->_duration <= 0) {// TODO: Avoid longs. - _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); - } - - - int x, y, width, height; - - x = _posX; - y = _posY; - - if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - - if (_subtitlesWidth > 0) width = _subtitlesWidth; - else { - if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { - width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); - } else width = _gameRef->_renderer->_width / 2; - } - - height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); - - y = y - height - getHeight() - 5; - if (_subtitlesModRelative) { - x += _subtitlesModX; - y += _subtitlesModY; - } else { - x = _subtitlesModX; - y = _subtitlesModY; - } - if (_subtitlesModXCenter) - x = x - width / 2; - - - x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); - y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); - - _sentence->_width = width; - - - _sentence->_pos.x = x; - _sentence->_pos.y = y; - - - if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - _sentence->_fixedPos = !_subtitlesModRelative; - - - _sentence->setupTalkFile(sound); - - _state = STATE_TALKING; - - if (deleteSound) delete [] sound; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::reset() { - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { - delete _animSprite; - _animSprite = NULL; - } else if (_state == STATE_TALKING && _sentence) { - _sentence->finish(); - } - - _state = _nextState = STATE_READY; - - _gameRef->_scEngine->resetObject(this); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blockRegion)); - persistMgr->transfer(TMEMBER(_currentBlockRegion)); - persistMgr->transfer(TMEMBER(_currentWptGroup)); - persistMgr->transfer(TMEMBER(_currentSprite)); - persistMgr->transfer(TMEMBER(_drawn)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_ignoreItems)); - persistMgr->transfer(TMEMBER_INT(_nextState)); - persistMgr->transfer(TMEMBER(_sentence)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_animSprite)); - persistMgr->transfer(TMEMBER(_sceneIndependent)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); - persistMgr->transfer(TMEMBER(_tempSprite2)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_wptGroup)); - persistMgr->transfer(TMEMBER(_stickRegion)); - persistMgr->transfer(TMEMBER(_subtitlesModRelative)); - persistMgr->transfer(TMEMBER(_subtitlesModX)); - persistMgr->transfer(TMEMBER(_subtitlesModY)); - persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); - persistMgr->transfer(TMEMBER(_subtitlesWidth)); - persistMgr->transfer(TMEMBER(_inventory)); - persistMgr->transfer(TMEMBER(_partEmitter)); - - for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); - - _attachmentsPre.persist(persistMgr); - _attachmentsPost.persist(persistMgr); - persistMgr->transfer(TMEMBER(_registerAlias)); - - persistMgr->transfer(TMEMBER(_partFollowParent)); - persistMgr->transfer(TMEMBER(_partOffsetX)); - persistMgr->transfer(TMEMBER(_partOffsetY)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSounds() { - if (_sentence && _sentence->_sound) - updateOneSound(_sentence->_sound); - - return CBObject::updateSounds(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::resetSoundPan() { - if (_sentence && _sentence->_sound) { - _sentence->_sound->setPan(0.0f); - } - return CBObject::resetSoundPan(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - - else return CBObject::getExtendedFlag(flagName); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { - if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); - - CBBase::saveAsText(buffer, indent + 2); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateBlockRegion() { - CAdGame *adGame = (CAdGame *)_gameRef; - if (adGame->_scene) { - if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); - - if (_wptGroup && _currentWptGroup) - _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdInventory *CAdObject::getInventory() { - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - return _inventory; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::afterMove() { - CAdRegion *newRegions[MAX_NUM_REGIONS]; - - ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (!newRegions[i]) break; - bool regFound = false; - for (int j = 0; j < MAX_NUM_REGIONS; j++) { - if (_currentRegions[j] == newRegions[i]) { - _currentRegions[j] = NULL; - regFound = true; - break; - } - } - if (!regFound) newRegions[i]->applyEvent("ActorEntry"); - } - - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) { - _currentRegions[i]->applyEvent("ActorLeave"); - } - _currentRegions[i] = newRegions[i]; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::invalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::getScale(float *scaleX, float *scaleY) { - if (_zoomable) { - if (_scaleX >= 0 || _scaleY >= 0) { - *scaleX = _scaleX < 0 ? 100 : _scaleX; - *scaleY = _scaleY < 0 ? 100 : _scaleY; - } else if (_scale >= 0) *scaleX = *scaleY = _scale; - else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; - } else { - *scaleX = *scaleY = 100; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSpriteAttachments() { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - _attachmentsPre[i]->update(); - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - _attachmentsPost[i]->update(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachments(bool preDisplay) { - if (preDisplay) { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - displaySpriteAttachment(_attachmentsPre[i]); - } - } else { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - displaySpriteAttachment(_attachmentsPost[i]); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { - if (!attachment->_active) return STATUS_OK; - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - int origX = attachment->_posX; - int origY = attachment->_posY; - - // inherit position from owner - attachment->_posX = (int)(this->_posX + attachment->_posX * scaleX / 100.0f); - attachment->_posY = (int)(this->_posY + attachment->_posY * scaleY / 100.0f); - - // inherit other props - attachment->_alphaColor = this->_alphaColor; - attachment->_blendMode = this->_blendMode; - - attachment->_scale = this->_scale; - attachment->_relativeScale = this->_relativeScale; - attachment->_scaleX = this->_scaleX; - attachment->_scaleY = this->_scaleY; - - attachment->_rotate = this->_rotate; - attachment->_relativeRotate = this->_relativeRotate; - attachment->_rotateValid = this->_rotateValid; - - attachment->_registerAlias = this; - attachment->_registrable = this->_registrable; - - bool ret = attachment->display(); - - attachment->_posX = origX; - attachment->_posY = origY; - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { - _partFollowParent = followParent; - _partOffsetX = offsetX; - _partOffsetY = offsetY; - - if (!_partEmitter) { - _partEmitter = new CPartEmitter(_gameRef, this); - if (_partEmitter) { - _gameRef->registerObject(_partEmitter); - } - } - updatePartEmitter(); - return _partEmitter; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updatePartEmitter() { - if (!_partEmitter) return STATUS_FAILED; - - if (_partFollowParent) { - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - _partEmitter->_posX = (int)(_posX + (scaleX / 100.0f) * _partOffsetX); - _partEmitter->_posY = (int)(_posY + (scaleY / 100.0f) * _partOffsetY); - } - return _partEmitter->update(); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdObject.h b/engines/wintermute/Ad/AdObject.h deleted file mode 100644 index 6fb7c02b0f..0000000000 --- a/engines/wintermute/Ad/AdObject.h +++ /dev/null @@ -1,123 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADOBJECT_H -#define WINTERMUTE_ADOBJECT_H - -#include "engines/wintermute/Ad/AdTypes.h" -#include "engines/wintermute/Base/particles/PartEmitter.h" - -namespace WinterMute { - -class CAdWaypointGroup; -class CAdRegion; -class CAdSentence; -class CBFont; -class CBRegion; -class CAdInventory; - -#define MAX_NUM_REGIONS 10 - -class CAdObject : public CBObject { -public: - CPartEmitter *_partEmitter; - virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); - virtual bool updatePartEmitter(); - bool _partFollowParent; - int _partOffsetX; - int _partOffsetY; - - bool invalidateCurrRegions(); - bool _subtitlesModRelative; - bool _subtitlesModXCenter; - int _subtitlesModX; - int _subtitlesModY; - int _subtitlesWidth; - CAdRegion *_stickRegion; - bool _sceneIndependent; - bool _ignoreItems; - bool updateBlockRegion(); - bool _forcedTalkAnimUsed; - char *_forcedTalkAnimName; - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool reset(); - DECLARE_PERSISTENT(CAdObject, CBObject) - virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); - virtual int getHeight(); - CAdSentence *_sentence; - bool SetFont(const char *filename); - virtual bool update(); - virtual bool display(); - bool _drawn; - bool _active; - virtual bool playAnim(const char *filename); - CBSprite *_animSprite; - CBSprite *_currentSprite; - TObjectState _state; - TObjectState _nextState; - TObjectType _type; - CAdObject(CBGame *inGame); - virtual ~CAdObject(); - CBFont *_font; - CBSprite *_tempSprite2; - CBRegion *_blockRegion; - CAdWaypointGroup *_wptGroup; - CBRegion *_currentBlockRegion; - CAdWaypointGroup *_currentWptGroup; - CAdInventory *getInventory(); - - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - virtual bool afterMove(); - CAdRegion *_currentRegions[MAX_NUM_REGIONS]; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - CBArray _attachmentsPre; - CBArray _attachmentsPost; - - bool updateSpriteAttachments(); - bool displaySpriteAttachments(bool preDisplay); - CAdObject *_registerAlias; -private: - bool displaySpriteAttachment(CAdObject *attachment); - CAdInventory *_inventory; - -protected: - bool getScale(float *scaleX, float *scaleY); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp deleted file mode 100644 index 4f0c996157..0000000000 --- a/engines/wintermute/Ad/AdPath.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdPath.h" -#include "engines/wintermute/Base/BPoint.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPath, false) - -////////////////////////////////////////////////////////////////////////// -CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPath::~CAdPath() { - reset(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::reset() { - for (int i = 0; i < _points.getSize(); i++) - delete _points[i]; - - _points.removeAll(); - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getFirst() { - if (_points.getSize() > 0) { - _currIndex = 0; - return _points[_currIndex]; - } else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getNext() { - _currIndex++; - if (_currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::addPoint(CBPoint *point) { - _points.add(point); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPath::setReady(bool ready) { - bool orig = _ready; - _ready = ready; - - return orig; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPath::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_currIndex)); - _points.persist(persistMgr); - persistMgr->transfer(TMEMBER(_ready)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPath.h b/engines/wintermute/Ad/AdPath.h deleted file mode 100644 index 2e150175f3..0000000000 --- a/engines/wintermute/Ad/AdPath.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATH_H -#define WINTERMUTE_ADPATH_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { -class CBPoint; -class CAdPath : public CBBase { -public: - DECLARE_PERSISTENT(CAdPath, CBBase) - CBPoint *getCurrent(); - bool setReady(bool ready = true); - void addPoint(CBPoint *point); - CBPoint *getNext(); - CBPoint *getFirst(); - void reset(); - CAdPath(CBGame *inGame); - virtual ~CAdPath(); - CBArray _points; - int _currIndex; - bool _ready; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdPathPoint.cpp b/engines/wintermute/Ad/AdPathPoint.cpp deleted file mode 100644 index 25e62b80e9..0000000000 --- a/engines/wintermute/Ad/AdPathPoint.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdPathPoint.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPathPoint, false) - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint() { - x = y = 0; - _distance = 0; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { - x = initX; - y = initY; - _distance = initDistance; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::~CAdPathPoint() { - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { - - CBPoint::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_distance)); - persistMgr->transfer(TMEMBER(_marked)); - persistMgr->transfer(TMEMBER(_origin)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdPathPoint.h b/engines/wintermute/Ad/AdPathPoint.h deleted file mode 100644 index cfa08d319b..0000000000 --- a/engines/wintermute/Ad/AdPathPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATHPOINT_H -#define WINTERMUTE_ADPATHPOINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BPoint.h" - -namespace WinterMute { - -class CAdPathPoint : public CBPoint { -public: - DECLARE_PERSISTENT(CAdPathPoint, CBPoint) - CAdPathPoint(int initX, int initY, int initDistance); - CAdPathPoint(); - virtual ~CAdPathPoint(); - CAdPathPoint *_origin; - bool _marked; - int _distance; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp deleted file mode 100644 index 2c481db96d..0000000000 --- a/engines/wintermute/Ad/AdRegion.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdRegion.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRegion, false) - -////////////////////////////////////////////////////////////////////////// -CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { - _blocked = false; - _decoration = false; - _zoom = 0; - _alpha = 0xFFFFFFFF; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRegion::~CAdRegion() { -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(ZOOM) -TOKEN_DEF(SCALE) -TOKEN_DEF(BLOCKED) -TOKEN_DEF(DECORATION) -TOKEN_DEF(POINT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(ZOOM) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(BLOCKED) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(POINT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - int ar = 255, ag = 255, ab = 255, alpha = 255; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_BLOCKED: - parser.scanStr((char *)params, "%b", &_blocked); - break; - - case TOKEN_DECORATION: - parser.scanStr((char *)params, "%b", &_decoration); - break; - - case TOKEN_ZOOM: - case TOKEN_SCALE: { - int j; - parser.scanStr((char *)params, "%d", &j); - _zoom = (float)j; - } - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - /* - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo")==0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - stack->pushNULL(); - - return STATUS_OK; - } - - else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("ad region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Blocked") == 0) { - _scValue->setBool(_blocked); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - _scValue->setFloat(_zoom); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alpha); - return _scValue; - } - - else return CBRegion::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Blocked") == 0) { - _blocked = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - _zoom = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - else return CBRegion::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdRegion::scToString() { - return "[ad region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "REGION {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - int i; - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - for (i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::persist(CBPersistMgr *persistMgr) { - CBRegion::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_blocked)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_zoom)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRegion.h b/engines/wintermute/Ad/AdRegion.h deleted file mode 100644 index a565641de4..0000000000 --- a/engines/wintermute/Ad/AdRegion.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADREGION_H -#define WINTERMUTE_ADREGION_H - -#include "engines/wintermute/Base/BRegion.h" - -namespace WinterMute { - -class CAdRegion : public CBRegion { -public: - DECLARE_PERSISTENT(CAdRegion, CBRegion) - uint32 _alpha; - float _zoom; - bool _blocked; - bool _decoration; - CAdRegion(CBGame *inGame); - virtual ~CAdRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp deleted file mode 100644 index a74d1b960e..0000000000 --- a/engines/wintermute/Ad/AdResponse.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils/utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponse, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { - _text = NULL; - _textOrig = NULL; - _icon = _iconHover = _iconPressed = NULL; - _font = NULL; - _iD = 0; - _responseType = RESPONSE_ALWAYS; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponse::~CAdResponse() { - delete[] _text; - delete[] _textOrig; - delete _icon; - delete _iconHover; - delete _iconPressed; - _text = NULL; - _textOrig = NULL; - _icon = NULL; - _iconHover = NULL; - _iconPressed = NULL; - if (_font) _gameRef->_fontStorage->removeFont(_font); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponse::setText(const char *text) { - CBUtils::setString(&_text, text); - CBUtils::setString(&_textOrig, text); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIcon(const char *filename) { - delete _icon; - _icon = new CBSprite(_gameRef); - if (!_icon || DID_FAIL(_icon->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); - delete _icon; - _icon = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont(filename); - if (!_font) { - _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconHover(const char *filename) { - delete _iconHover; - _iconHover = new CBSprite(_gameRef); - if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); - delete _iconHover; - _iconHover = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconPressed(const char *filename) { - delete _iconPressed; - _iconPressed = new CBSprite(_gameRef); - if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); - delete _iconPressed; - _iconPressed = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_icon)); - persistMgr->transfer(TMEMBER(_iconHover)); - persistMgr->transfer(TMEMBER(_iconPressed)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_textOrig)); - persistMgr->transfer(TMEMBER_INT(_responseType)); - persistMgr->transfer(TMEMBER(_font)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponse.h b/engines/wintermute/Ad/AdResponse.h deleted file mode 100644 index f5ca08639b..0000000000 --- a/engines/wintermute/Ad/AdResponse.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSE_H -#define WINTERMUTE_ADRESPONSE_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Ad/AdTypes.h" - -namespace WinterMute { -class CBFont; -class CAdResponse : public CBObject { -public: - DECLARE_PERSISTENT(CAdResponse, CBObject) - bool setIcon(const char *filename); - bool setFont(const char *filename); - bool setIconHover(const char *filename); - bool setIconPressed(const char *filename); - void setText(const char *text); - int _iD; - CBSprite *_icon; - CBSprite *_iconHover; - CBSprite *_iconPressed; - CBFont *_font; - char *_text; - char *_textOrig; - CAdResponse(CBGame *inGame); - virtual ~CAdResponse(); - TResponseType _responseType; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp deleted file mode 100644 index 4e0bab38c7..0000000000 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdResponseBox.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/UI/UIButton.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { - _font = _fontHover = NULL; - - _window = NULL; - _shieldWindow = new CUIWindow(_gameRef); - - _horizontal = false; - CBPlatform::setRectEmpty(&_responseArea); - _scrollOffset = 0; - _spacing = 0; - - _waitingScript = NULL; - _lastResponseText = NULL; - _lastResponseTextOrig = NULL; - - _verticalAlign = VAL_BOTTOM; - _align = TAL_LEFT; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::~CAdResponseBox() { - - delete _window; - _window = NULL; - delete _shieldWindow; - _shieldWindow = NULL; - delete[] _lastResponseText; - _lastResponseText = NULL; - delete[] _lastResponseTextOrig; - _lastResponseTextOrig = NULL; - - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - - clearResponses(); - clearButtons(); - - _waitingScript = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearResponses() { - for (int i = 0; i < _responses.getSize(); i++) { - delete _responses[i]; - } - _responses.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { - delete _respButtons[i]; - } - _respButtons.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::invalidateButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { - _respButtons[i]->_image = NULL; - _respButtons[i]->_cursor = NULL; - _respButtons[i]->_font = NULL; - _respButtons[i]->_fontHover = NULL; - _respButtons[i]->_fontPress = NULL; - _respButtons[i]->setText(""); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::createButtons() { - clearButtons(); - - _scrollOffset = 0; - for (int i = 0; i < _responses.getSize(); i++) { - CUIButton *btn = new CUIButton(_gameRef); - if (btn) { - btn->_parent = _window; - btn->_sharedFonts = btn->_sharedImages = true; - btn->_sharedCursors = true; - // iconic - if (_responses[i]->_icon) { - btn->_image = _responses[i]->_icon; - if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; - if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; - - btn->setCaption(_responses[i]->_text); - if (_cursor) btn->_cursor = _cursor; - else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; - } - // textual - else { - btn->setText(_responses[i]->_text); - btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; - btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; - btn->_fontPress = btn->_fontHover; - btn->_align = _align; - - if (_gameRef->_touchInterface) - btn->_fontHover = btn->_font; - - - if (_responses[i]->_font) btn->_font = _responses[i]->_font; - - btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; - } - btn->setName("response"); - btn->correctSize(); - - // make the responses touchable - if (_gameRef->_touchInterface) - btn->_height = MAX(btn->_height, 50); - - //btn->SetListener(this, btn, _responses[i]->_iD); - btn->setListener(this, btn, i); - btn->_visible = false; - _respButtons.add(btn); - - if (_responseArea.bottom - _responseArea.top < btn->_height) { - _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); - _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); - } - } - } - _ready = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT) -TOKEN_DEF(AREA) -TOKEN_DEF(HORIZONTAL) -TOKEN_DEF(SPACING) -TOKEN_DEF(WINDOW) -TOKEN_DEF(CURSOR) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT) - TOKEN_TABLE(AREA) - TOKEN_TABLE(HORIZONTAL) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { - _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(_gameRef); - if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else if (_shieldWindow) _shieldWindow->_parent = _window; - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); - break; - - case TOKEN_HORIZONTAL: - parser.scanStr((char *)params, "%b", &_horizontal); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_LEFT; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; - else _verticalAlign = VAL_BOTTOM; - break; - - case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition"); - return STATUS_FAILED; - } - - if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "RESPONSE_BOX\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); - - switch (_align) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CAdResponseBox::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - } - - buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); - - buffer->putTextIndent(indent + 2, "\n"); - - // window - if (_window) _window->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::display() { - Rect32 rect = _responseArea; - if (_window) { - CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); - //_window->display(); - } - - int xxx, yyy, i; - - xxx = rect.left; - yyy = rect.top; - - // shift down if needed - if (!_horizontal) { - int total_height = 0; - for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); - total_height -= _spacing; - - switch (_verticalAlign) { - case VAL_BOTTOM: - if (yyy + total_height < rect.bottom) - yyy = rect.bottom - total_height; - break; - - case VAL_CENTER: - if (yyy + total_height < rect.bottom) - yyy += ((rect.bottom - rect.top) - total_height) / 2; - break; - - case VAL_TOP: - // do nothing - break; - } - } - - // prepare response buttons - bool scrollNeeded = false; - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { - if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) - || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { - - scrollNeeded = true; - _respButtons[i]->_visible = false; - break; - } - - _respButtons[i]->_visible = true; - _respButtons[i]->_posX = xxx; - _respButtons[i]->_posY = yyy; - - if (_horizontal) { - xxx += (_respButtons[i]->_width + _spacing); - } else { - yyy += (_respButtons[i]->_height + _spacing); - } - } - - // show appropriate scroll buttons - if (_window) { - _window->showWidget("prev", _scrollOffset > 0); - _window->showWidget("next", scrollNeeded); - } - - // go exclusive - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - - _shieldWindow->display(); - } - - // display window - if (_window) _window->display(); - - - // display response buttons - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { - _respButtons[i]->display(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset--; - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset++; - } else if (scumm_stricmp(obj->_name, "response") == 0) { - if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); - handleResponse(_responses[param2]); - _waitingScript = NULL; - _gameRef->_state = GAME_RUNNING; - ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; - _ready = true; - invalidateButtons(); - clearResponses(); - } else return CBObject::listen(param1, param2); - break; - default: - error("AdResponseBox::Listen - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_fontHover)); - persistMgr->transfer(TMEMBER(_horizontal)); - persistMgr->transfer(TMEMBER(_lastResponseText)); - persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); - _respButtons.persist(persistMgr); - persistMgr->transfer(TMEMBER(_responseArea)); - _responses.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_waitingScript)); - persistMgr->transfer(TMEMBER(_window)); - - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - persistMgr->transfer(TMEMBER_INT(_align)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::weedResponses() { - CAdGame *adGame = (CAdGame *)_gameRef; - - for (int i = 0; i < _responses.getSize(); i++) { - switch (_responses[i]->_responseType) { - case RESPONSE_ONCE: - if (adGame->branchResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.removeAt(i); - i--; - } - break; - - case RESPONSE_ONCE_GAME: - if (adGame->gameResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.removeAt(i); - i--; - } - break; - default: - warning("CAdResponseBox::WeedResponses - Unhandled enum"); - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { - CBUtils::setString(&_lastResponseText, text); - CBUtils::setString(&_lastResponseTextOrig, textOrig); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::handleResponse(CAdResponse *response) { - setLastResponseText(response->_text, response->_textOrig); - - CAdGame *adGame = (CAdGame *)_gameRef; - - switch (response->_responseType) { - case RESPONSE_ONCE: - adGame->addBranchResponse(response->_iD); - break; - - case RESPONSE_ONCE_GAME: - adGame->addGameResponse(response->_iD); - break; - default: - warning("CAdResponseBox::HandleResponse - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { - CBArray objects; - getObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { - if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { - CBArray objects; - getObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; - } - } - } - return objects[objects.getSize() - 1]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _respButtons.getSize(); i++) { - objects.add(_respButtons[i]); - } - if (_window) _window->getWindowObjects(objects, interactiveOnly); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseBox.h b/engines/wintermute/Ad/AdResponseBox.h deleted file mode 100644 index ba2962a8f7..0000000000 --- a/engines/wintermute/Ad/AdResponseBox.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSEBOX_H -#define WINTERMUTE_ADRESPONSEBOX_H - - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CUIButton; -class CUIWindow; -class CUIObject; -class CAdResponse; -class CAdResponseBox : public CBObject { -public: - CBObject *getNextAccessObject(CBObject *CurrObject); - CBObject *getPrevAccessObject(CBObject *CurrObject); - bool getObjects(CBArray &objects, bool interactiveOnly); - - bool handleResponse(CAdResponse *response); - void setLastResponseText(const char *text, const char *textOrig); - char *_lastResponseText; - char *_lastResponseTextOrig; - DECLARE_PERSISTENT(CAdResponseBox, CBObject) - CScScript *_waitingScript; - virtual bool listen(CBScriptHolder *param1, uint32 param2); - typedef enum { - EVENT_PREV, - EVENT_NEXT, - EVENT_RESPONSE - } TResponseEvent; - - bool weedResponses(); - bool display(); - int _spacing; - int _scrollOffset; - CBFont *_fontHover; - CBFont *_font; - bool createButtons(); - bool invalidateButtons(); - void clearButtons(); - void clearResponses(); - CAdResponseBox(CBGame *inGame); - virtual ~CAdResponseBox(); - CBArray _responses; - CBArray _respButtons; - CUIWindow *_window; - CUIWindow *_shieldWindow; - bool _horizontal; - Rect32 _responseArea; - int _verticalAlign; - TTextAlign _align; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp deleted file mode 100644 index 77a84e651d..0000000000 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdResponseContext.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseContext, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { - _iD = 0; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::~CAdResponseContext() { - delete[] _context; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_context)); - persistMgr->transfer(TMEMBER(_iD)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::setContext(const char *context) { - delete[] _context; - _context = NULL; - if (context) { - _context = new char [strlen(context) + 1]; - if (_context) strcpy(_context, context); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdResponseContext.h b/engines/wintermute/Ad/AdResponseContext.h deleted file mode 100644 index a39e2127d5..0000000000 --- a/engines/wintermute/Ad/AdResponseContext.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSECONTEXT_H -#define WINTERMUTE_ADRESPONSECONTEXT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CAdResponseContext : public CBBase { -public: - void setContext(const char *context); - int _iD; - char *_context; - DECLARE_PERSISTENT(CAdResponseContext, CBBase) - CAdResponseContext(CBGame *inGame); - virtual ~CAdResponseContext(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp deleted file mode 100644 index 956a3efcab..0000000000 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdRotLevel.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRotLevel, false) - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { - _posX = 0; - _rotation = 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::~CAdRotLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(X) -TOKEN_DEF(ROTATION) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(X) - TOKEN_TABLE(ROTATION) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { - _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_ROTATION: { - int i; - parser.scanStr((char *)params, "%d", &i); - _rotation = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_rotation)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdRotLevel.h b/engines/wintermute/Ad/AdRotLevel.h deleted file mode 100644 index 88b0b08aeb..0000000000 --- a/engines/wintermute/Ad/AdRotLevel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADROTLEVEL_H -#define WINTERMUTE_ADROTLEVEL_H - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CAdRotLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdRotLevel, CBObject) - CAdRotLevel(CBGame *inGame); - virtual ~CAdRotLevel(); - float _rotation; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp deleted file mode 100644 index 58e62bd9b4..0000000000 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdScaleLevel.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScaleLevel, false) - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { - _posY = 0; - _scale = 100; -} - - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::~CAdScaleLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(Y) -TOKEN_DEF(SCALE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(Y) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { - _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SCALE: { - int i; - parser.scanStr((char *)params, "%d", &i); - _scale = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scale)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScaleLevel.h b/engines/wintermute/Ad/AdScaleLevel.h deleted file mode 100644 index 5377325ed5..0000000000 --- a/engines/wintermute/Ad/AdScaleLevel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCALELEVEL_H -#define WINTERMUTE_ADSCALELEVEL_H - - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CAdScaleLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdScaleLevel, CBObject) - float _scale; - CAdScaleLevel(CBGame *inGame); - virtual ~CAdScaleLevel(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp deleted file mode 100644 index aad3ffdd1d..0000000000 --- a/engines/wintermute/Ad/AdScene.cpp +++ /dev/null @@ -1,2752 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdActor.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdLayer.h" -#include "engines/wintermute/Ad/AdNodeState.h" -#include "engines/wintermute/Ad/AdObject.h" -#include "engines/wintermute/Ad/AdPath.h" -#include "engines/wintermute/Ad/AdPathPoint.h" -#include "engines/wintermute/Ad/AdRotLevel.h" -#include "engines/wintermute/Ad/AdScaleLevel.h" -#include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BPoint.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BScriptable.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/utils/utils.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScene, false) - -////////////////////////////////////////////////////////////////////////// -CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - _pfTarget = new CBPoint; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdScene::~CAdScene() { - cleanup(); - _gameRef->unregisterObject(_fader); - delete _pfTarget; - _pfTarget = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::setDefaults() { - _initialized = false; - _pfReady = true; - _pfTargetPath = NULL; - _pfRequester = NULL; - _mainLayer = NULL; - - _pfPointsNum = 0; - _persistentState = false; - _persistentStateSprites = true; - - _autoScroll = true; - _offsetLeft = _offsetTop = 0; - _targetOffsetLeft = _targetOffsetTop = 0; - - _lastTimeH = _lastTimeV = 0; - _scrollTimeH = _scrollTimeV = 10; - _scrollPixelsH = _scrollPixelsV = 1; - - _pfMaxTime = 15; - - _paralaxScrolling = true; - - // editor settings - _editorMarginH = _editorMarginV = 100; - - _editorColFrame = 0xE0888888; - _editorColEntity = 0xFF008000; - _editorColRegion = 0xFF0000FF; - _editorColBlocked = 0xFF800080; - _editorColWaypoints = 0xFF0000FF; - _editorColEntitySel = 0xFFFF0000; - _editorColRegionSel = 0xFFFF0000; - _editorColBlockedSel = 0xFFFF0000; - _editorColWaypointsSel = 0xFFFF0000; - _editorColScale = 0xFF00FF00; - _editorColDecor = 0xFF00FFFF; - _editorColDecorSel = 0xFFFF0000; - - _editorShowRegions = true; - _editorShowBlocked = true; - _editorShowDecor = true; - _editorShowEntities = true; - _editorShowScale = true; - - _shieldWindow = NULL; - - _fader = new CBFader(_gameRef); - _gameRef->registerObject(_fader); - - _viewport = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::cleanup() { - CBObject::cleanup(); - - _mainLayer = NULL; // reference only - - int i; - - delete _shieldWindow; - _shieldWindow = NULL; - - _gameRef->unregisterObject(_fader); - _fader = NULL; - - for (i = 0; i < _layers.getSize(); i++) - _gameRef->unregisterObject(_layers[i]); - _layers.removeAll(); - - - for (i = 0; i < _waypointGroups.getSize(); i++) - _gameRef->unregisterObject(_waypointGroups[i]); - _waypointGroups.removeAll(); - - for (i = 0; i < _scaleLevels.getSize(); i++) - _gameRef->unregisterObject(_scaleLevels[i]); - _scaleLevels.removeAll(); - - for (i = 0; i < _rotLevels.getSize(); i++) - _gameRef->unregisterObject(_rotLevels[i]); - _rotLevels.removeAll(); - - - for (i = 0; i < _pfPath.getSize(); i++) - delete _pfPath[i]; - _pfPath.removeAll(); - _pfPointsNum = 0; - - for (i = 0; i < _objects.getSize(); i++) - _gameRef->unregisterObject(_objects[i]); - _objects.removeAll(); - - delete _viewport; - _viewport = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { - if (!_pfReady) return false; - else { - _pfReady = false; - *_pfTarget = target; - _pfTargetPath = path; - _pfRequester = requester; - - _pfTargetPath->reset(); - _pfTargetPath->setReady(false); - - // prepare working path - int i; - pfPointsStart(); - - // first point - //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); - - // if we're one pixel stuck, get unstuck - int startX = source.x; - int startY = source.y; - int bestDistance = 1000; - if (isBlockedAt(startX, startY, true, requester)) { - int tolerance = 2; - for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) { - for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) { - if (isWalkableAt(xxx, yyy, true, requester)) { - int distance = abs(xxx - source.x) + abs(yyy - source.y); - if (distance < bestDistance) { - startX = xxx; - startY = yyy; - - bestDistance = distance; - } - } - } - } - } - - pfPointsAdd(startX, startY, 0); - - //CorrectTargetPoint(&target.x, &target.y); - - // last point - //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); - pfPointsAdd(target.x, target.y, INT_MAX); - - // active waypoints - for (i = 0; i < _waypointGroups.getSize(); i++) { - if (_waypointGroups[i]->_active) { - pfAddWaypointGroup(_waypointGroups[i], requester); - } - } - - - // free waypoints - for (i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { - pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { - pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); - } - } - - return true; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { - if (!wpt->_active) return; - - for (int i = 0; i < wpt->_points.getSize(); i++) { - if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; - - //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); - pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); - } -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getZoomAt(int x, int y) { - float ret = 100; - - bool found = false; - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { - if (node->_region->_zoom != 0) { - ret = node->_region->_zoom; - found = true; - break; - } - } - } - } - if (!found) ret = getScaleAt(y); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { - if (!_gameRef->_debugDebugMode) colorCheck = false; - - uint32 ret; - if (colorCheck) ret = 0xFFFF0000; - else ret = 0xFFFFFFFF; - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { - if (!node->_region->_blocked) ret = node->_region->_alpha; - break; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { - bool ret = true; - - - if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - /* - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) - { - ret = true; - break; - } - */ - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { - ret = true; - break; - } else ret = false; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { - bool ret = false; - - if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { - ret = false; - break; - } else ret = true; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { - double xStep, yStep, x, y; - int xLength, yLength, xCount, yCount; - int x1, y1, x2, y2; - - x1 = p1.x; - y1 = p1.y; - x2 = p2.x; - y2 = p2.y; - - xLength = abs(x2 - x1); - yLength = abs(y2 - y1); - - if (xLength > yLength) { - if (x1 > x2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); - } - - yStep = (double)(y2 - y1) / (double)(x2 - x1); - y = y1; - - for (xCount = x1; xCount < x2; xCount++) { - if (isBlockedAt(xCount, (int)y, true, requester)) return -1; - y += yStep; - } - } else { - if (y1 > y2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); - } - - xStep = (double)(x2 - x1) / (double)(y2 - y1); - x = x1; - - for (yCount = y1; yCount < y2; yCount++) { - if (isBlockedAt((int)x, yCount, true, requester)) return -1; - x += xStep; - } - } - return MAX(xLength, yLength); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pathFinderStep() { - int i; - // get lowest unmarked - int lowestDist = INT_MAX; - CAdPathPoint *lowestPt = NULL; - - for (i = 0; i < _pfPointsNum; i++) - if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { - lowestDist = _pfPath[i]->_distance; - lowestPt = _pfPath[i]; - } - - if (lowestPt == NULL) { // no path -> terminate PathFinder - _pfReady = true; - _pfTargetPath->setReady(true); - return; - } - - lowestPt->_marked = true; - - // target point marked, generate path and terminate - if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { - while (lowestPt != NULL) { - _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); - lowestPt = lowestPt->_origin; - } - - _pfReady = true; - _pfTargetPath->setReady(true); - return; - } - - // otherwise keep on searching - for (i = 0; i < _pfPointsNum; i++) - if (!_pfPath[i]->_marked) { - int j = getPointsDist(*lowestPt, *_pfPath[i], _pfRequester); - if (j != -1 && lowestPt->_distance + j < _pfPath[i]->_distance) { - _pfPath[i]->_distance = lowestPt->_distance + j; - _pfPath[i]->_origin = lowestPt; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::initLoop() { -#ifdef _DEBUGxxxx - int nu_steps = 0; - uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { - PathFinderStep(); - nu_steps++; - } - if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); -#else - uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); -#endif - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCENE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(LAYER) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(CAMERA) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(EDITOR_MARGIN_H) -TOKEN_DEF(EDITOR_MARGIN_V) -TOKEN_DEF(EDITOR_COLOR_FRAME) -TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION_SEL) -TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) -TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION) -TOKEN_DEF(EDITOR_COLOR_DECORATION) -TOKEN_DEF(EDITOR_COLOR_BLOCKED) -TOKEN_DEF(EDITOR_COLOR_ENTITY) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) -TOKEN_DEF(EDITOR_COLOR_SCALE) -TOKEN_DEF(EDITOR_SHOW_REGIONS) -TOKEN_DEF(EDITOR_SHOW_BLOCKED) -TOKEN_DEF(EDITOR_SHOW_DECORATION) -TOKEN_DEF(EDITOR_SHOW_ENTITIES) -TOKEN_DEF(EDITOR_SHOW_SCALE) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(VIEWPORT) -TOKEN_DEF(PERSISTENT_STATE_SPRITES) -TOKEN_DEF(PERSISTENT_STATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCENE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(CAMERA) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(EDITOR_MARGIN_H) - TOKEN_TABLE(EDITOR_MARGIN_V) - TOKEN_TABLE(EDITOR_COLOR_FRAME) - TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) - TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION) - TOKEN_TABLE(EDITOR_COLOR_DECORATION) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED) - TOKEN_TABLE(EDITOR_COLOR_ENTITY) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) - TOKEN_TABLE(EDITOR_COLOR_SCALE) - TOKEN_TABLE(EDITOR_SHOW_REGIONS) - TOKEN_TABLE(EDITOR_SHOW_DECORATION) - TOKEN_TABLE(EDITOR_SHOW_BLOCKED) - TOKEN_TABLE(EDITOR_SHOW_ENTITIES) - TOKEN_TABLE(EDITOR_SHOW_SCALE) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(VIEWPORT) - TOKEN_TABLE(PERSISTENT_STATE_SPRITES) - TOKEN_TABLE(PERSISTENT_STATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - cleanup(); - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { - _gameRef->LOG(0, "'SCENE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int ar, ag, ab, aa; - char camera[MAX_PATH_LENGTH] = ""; - /* float WaypointHeight = -1.0f; */ - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_LAYER: { - CAdLayer *layer = new CAdLayer(_gameRef); - if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete layer; - layer = NULL; - } else { - _gameRef->registerObject(layer); - _layers.add(layer); - if (layer->_main) { - _mainLayer = layer; - _width = layer->_width; - _height = layer->_height; - } - } - } - break; - - case TOKEN_WAYPOINTS: { - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete wpt; - wpt = NULL; - } else { - _gameRef->registerObject(wpt); - _waypointGroups.add(wpt); - } - } - break; - - case TOKEN_SCALE_LEVEL: { - CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); - if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete sl; - sl = NULL; - } else { - _gameRef->registerObject(sl); - _scaleLevels.add(sl); - } - } - break; - - case TOKEN_ROTATION_LEVEL: { - CAdRotLevel *rl = new CAdRotLevel(_gameRef); - if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete rl; - rl = NULL; - } else { - _gameRef->registerObject(rl); - _rotLevels.add(rl); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - entity = NULL; - } else { - addObject(entity); - } - } - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CAMERA: - strcpy(camera, (char *)params); - break; - - case TOKEN_EDITOR_MARGIN_H: - parser.scanStr((char *)params, "%d", &_editorMarginH); - break; - - case TOKEN_EDITOR_MARGIN_V: - parser.scanStr((char *)params, "%d", &_editorMarginV); - break; - - case TOKEN_EDITOR_COLOR_FRAME: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColFrame = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntity = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegion = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecor = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_SCALE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColScale = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_SHOW_REGIONS: - parser.scanStr((char *)params, "%b", &_editorShowRegions); - break; - - case TOKEN_EDITOR_SHOW_BLOCKED: - parser.scanStr((char *)params, "%b", &_editorShowBlocked); - break; - - case TOKEN_EDITOR_SHOW_DECORATION: - parser.scanStr((char *)params, "%b", &_editorShowDecor); - break; - - case TOKEN_EDITOR_SHOW_ENTITIES: - parser.scanStr((char *)params, "%b", &_editorShowEntities); - break; - - case TOKEN_EDITOR_SHOW_SCALE: - parser.scanStr((char *)params, "%b", &_editorShowScale); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_VIEWPORT: { - Rect32 rc; - parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); - } - - case TOKEN_PERSISTENT_STATE: - parser.scanStr((char *)params, "%b", &_persistentState); - break; - - case TOKEN_PERSISTENT_STATE_SPRITES: - parser.scanStr((char *)params, "%b", &_persistentStateSprites); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SCENE definition"); - return STATUS_FAILED; - } - - if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); - - - sortScaleLevels(); - sortRotLevels(); - - _initialized = true; - - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::traverseNodes(bool doUpdate) { - if (!_initialized) return STATUS_OK; - - int j, k; - CAdGame *adGame = (CAdGame *)_gameRef; - - - ////////////////////////////////////////////////////////////////////////// - // prepare viewport - bool PopViewport = false; - if (_viewport && !_gameRef->_editorMode) { - _gameRef->pushViewport(_viewport); - PopViewport = true; - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - _gameRef->pushViewport(adGame->_sceneViewport); - PopViewport = true; - } - - - ////////////////////////////////////////////////////////////////////////// - // *** adjust scroll offset - if (doUpdate) { - /* - if (_autoScroll && _gameRef->_mainObject != NULL) - { - ScrollToObject(_gameRef->_mainObject); - } - */ - - if (_autoScroll) { - // adjust horizontal scroll - if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { - _lastTimeH = _gameRef->_timer; - if (_offsetLeft < _targetOffsetLeft) { - _offsetLeft += _scrollPixelsH; - _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); - } else if (_offsetLeft > _targetOffsetLeft) { - _offsetLeft -= _scrollPixelsH; - _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); - } - } - - // adjust vertical scroll - if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { - _lastTimeV = _gameRef->_timer; - if (_offsetTop < _targetOffsetTop) { - _offsetTop += _scrollPixelsV; - _offsetTop = MIN(_offsetTop, _targetOffsetTop); - } else if (_offsetTop > _targetOffsetTop) { - _offsetTop -= _scrollPixelsV; - _offsetTop = MAX(_offsetTop, _targetOffsetTop); - } - } - - if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; - } else _ready = true; // not scrolling, i.e. always ready - } - - - - - ////////////////////////////////////////////////////////////////////////// - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - int viewportX, viewportY; - getViewportOffset(&viewportX, &viewportY); - - int scrollableX = _width - viewportWidth; - int scrollableY = _height - viewportHeight; - - double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); - double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); - - int origX, origY; - _gameRef->getOffset(&origX, &origY); - - - - ////////////////////////////////////////////////////////////////////////// - // *** display/update everything - _gameRef->_renderer->setup2D(); - - // for each layer - /* int MainOffsetX = 0; */ - /* int MainOffsetY = 0; */ - - for (j = 0; j < _layers.getSize(); j++) { - if (!_layers[j]->_active) continue; - - // make layer exclusive - if (!doUpdate) { - if (_layers[j]->_closeUp && !_gameRef->_editorMode) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - _shieldWindow->display(); - } - } - } - - if (_paralaxScrolling) { - int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); - int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); - _gameRef->setOffset(offsetX, offsetY); - - _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; - - //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX); - } else { - _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); - - _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; - } - - - // for each node - for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { - CAdSceneNode *node = _layers[j]->_nodes[k]; - switch (node->_type) { - case OBJECT_ENTITY: - if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { - _gameRef->_renderer->setup2D(); - - if (doUpdate) node->_entity->update(); - else node->_entity->display(); - } - break; - - case OBJECT_REGION: { - if (node->_region->_blocked) break; - if (node->_region->_decoration) break; - - if (!doUpdate) displayRegionContent(node->_region); - } - break; - default: - error("AdScene::TraverseNodes - Unhandled enum"); - break; - } // switch - } // each node - - // display/update all objects which are off-regions - if (_layers[j]->_main) { - if (doUpdate) { - updateFreeObjects(); - } else { - displayRegionContent(NULL); - } - } - } // each layer - - - // restore state - _gameRef->setOffset(origX, origY); - _gameRef->_renderer->setup2D(); - - // display/update fader - if (_fader) { - if (doUpdate) _fader->update(); - else _fader->display(); - } - - if (PopViewport) _gameRef->popViewport(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::display() { - return traverseNodes(false); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::updateFreeObjects() { - CAdGame *adGame = (CAdGame *)_gameRef; - bool is3DSet; - - // *** update all active objects - is3DSet = false; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (!adGame->_objects[i]->_active) continue; - - adGame->_objects[i]->update(); - adGame->_objects[i]->_drawn = false; - } - - - for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_active) continue; - - _objects[i]->update(); - _objects[i]->_drawn = false; - } - - - if (_autoScroll && _gameRef->_mainObject != NULL) { - scrollToObject(_gameRef->_mainObject); - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CBArray objects; - CAdObject *obj; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - obj = adGame->_objects[i]; - if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); - } - } - - // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); - - // display them - for (int i = 0; i < objects.getSize(); i++) { - obj = objects[i]; - - if (display3DOnly && !obj->_is3D) continue; - - _gameRef->_renderer->setup2D(); - - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); - obj->_drawn = true; - } - - - // display design only objects - if (!display3DOnly) { - if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CAdScene::compareObjs(const void *obj1, const void *obj2) { - CAdObject *object1 = *(CAdObject **)obj1; - CAdObject *object2 = *(CAdObject **)obj2; - - if (object1->_posY < object2->_posY) return -1; - else if (object1->_posY > object2->_posY) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContentOld(CAdRegion *region) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; - - // display all objects in region sorted by _posY - do { - obj = NULL; - int minY = INT_MAX; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { - obj = adGame->_objects[i]; - minY = adGame->_objects[i]->_posY; - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { - obj = _objects[i]; - minY = _objects[i]->_posY; - } - } - - - if (obj != NULL) { - _gameRef->_renderer->setup2D(); - - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); - obj->_drawn = true; - } - } while (obj != NULL); - - - // design only objects - if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::update() { - return traverseNodes(true); -} - -////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - int origOffsetLeft = _targetOffsetLeft; - int origOffsetTop = _targetOffsetTop; - - _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); - _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); - - _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); - _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); - - - if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { - if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; - if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; - //_targetOffsetTop = 0; - } - - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollToObject(CBObject *object) { - if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::skipToObject(CBObject *object) { - if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::skipTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetLeft = MAX(0, offsetX - viewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - - _offsetTop = MAX(0, offsetY - viewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - viewportHeight); - - _targetOffsetLeft = _offsetLeft; - _targetOffsetTop = _offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LoadActor") == 0) { - stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); - if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { - addObject(act); - stack->pushNative(act, true); - } else { - delete act; - act = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadEntity") == 0) { - stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); - if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { - addObject(ent); - stack->pushNative(ent, true); - } else { - delete ent; - ent = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdEntity *ent = new CAdEntity(_gameRef); - addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); - removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - if (val1->isNative()) { - skipToObject((CBObject *)val1->getNative()); - } else { - skipTo(val1->getInt(), val2->getInt()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollTo / ScrollToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { - stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - if (val1->isNative()) { - scrollToObject((CBObject *)val1->getNative()); - } else { - scrollTo(val1->getInt(), val2->getInt()); - } - if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->isInt()) { - int layer = val->getInt(); - if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); - else stack->pushNative(_layers[layer], true); - } else { - const char *LayerName = val->getString(); - bool LayerFound = false; - for (int i = 0; i < _layers.getSize(); i++) { - if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { - stack->pushNative(_layers[i], true); - LayerFound = true; - break; - } - } - if (!LayerFound) stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaypointGroup - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaypointGroup") == 0) { - stack->correctParams(1); - int group = stack->pop()->getInt(); - if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); - else stack->pushNative(_waypointGroups[group], true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNode") == 0) { - stack->correctParams(1); - const char *nodeName = stack->pop()->getString(); - - CBObject *node = getNodeByName(nodeName); - if (node) stack->pushNative((CBScriptable *)node, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFreeNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFreeNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; - } else { - const char *nodeName = val->getString(); - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { - ret = _objects[i]; - break; - } - } - } - if (ret) stack->pushNative(ret, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRegionAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRegionAt") == 0) { - stack->correctParams(3); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - bool includeDecors = false; - if (!val->isNULL()) includeDecors = val->getBool(); - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (node->_region->_decoration && !includeDecors) continue; - - stack->pushNative(node->_region, true); - return STATUS_OK; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsBlockedAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsBlockedAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushBool(isBlockedAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalkableAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsWalkableAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushBool(isWalkableAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetScaleAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetScaleAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushFloat(getZoomAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRotationAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRotationAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushFloat(getRotationAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScrolling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScrolling") == 0) { - stack->correctParams(0); - bool ret = false; - if (_autoScroll) { - if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; - } - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsPointInViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsPointInViewport") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - stack->pushBool(pointInViewport(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetViewport") == 0) { - stack->correctParams(4); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - int width = stack->pop()->getInt(); - int height = stack->pop()->getInt(); - - if (width <= 0) width = _gameRef->_renderer->_width; - if (height <= 0) height = _gameRef->_renderer->_height; - - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) _viewport->setRect(x, y, x + width, y + height); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdLayer *layer = new CAdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); - if (_mainLayer) { - layer->_width = _mainLayer->_width; - layer->_height = _mainLayer->_height; - } - _layers.add(layer); - _gameRef->registerObject(layer); - - stack->pushNative(layer, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertLayer") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - CAdLayer *layer = new CAdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); - if (_mainLayer) { - layer->_width = _mainLayer->_width; - layer->_height = _mainLayer->_height; - } - if (index < 0) index = 0; - if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); - else _layers.add(layer); - - _gameRef->registerObject(layer); - - stack->pushNative(layer, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdLayer *toDelete = NULL; - if (val->isNative()) { - CBScriptable *temp = val->getNative(); - for (int i = 0; i < _layers.getSize(); i++) { - if (_layers[i] == temp) { - toDelete = _layers[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < _layers.getSize()) { - toDelete = _layers[index]; - } - } - if (toDelete == NULL) { - stack->pushBool(false); - return STATUS_OK; - } - - if (toDelete->_main) { - script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); - stack->pushBool(false); - return STATUS_OK; - } - - for (int i = 0; i < _layers.getSize(); i++) { - if (_layers[i] == toDelete) { - _layers.removeAt(i); - _gameRef->unregisterObject(toDelete); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("scene"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumLayers (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLayers") == 0) { - _scValue->setInt(_layers.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWaypointGroups (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->setInt(_waypointGroups.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainLayer (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainLayer") == 0) { - if (_mainLayer) _scValue->setNative(_mainLayer, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFreeNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFreeNodes") == 0) { - _scValue->setInt(_objects.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - int viewportX; - getViewportOffset(&viewportX); - - _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - int viewportY; - getViewportOffset(NULL, &viewportY); - - _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoScroll") == 0) { - _scValue->setBool(_autoScroll); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentState") == 0) { - _scValue->setBool(_persistentState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentStateSprites") == 0) { - _scValue->setBool(_persistentStateSprites); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsX") == 0) { - _scValue->setInt(_scrollPixelsH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsY") == 0) { - _scValue->setInt(_scrollPixelsV); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedX") == 0) { - _scValue->setInt(_scrollTimeH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedY") == 0) { - _scValue->setInt(_scrollTimeV); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetX") == 0) { - _scValue->setInt(_offsetLeft); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetY") == 0) { - _scValue->setInt(_offsetTop); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_width); - else _scValue->setInt(0); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_height); - else _scValue->setInt(0); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoScroll") == 0) { - _autoScroll = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentState") == 0) { - _persistentState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentStateSprites") == 0) { - _persistentStateSprites = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsX") == 0) { - _scrollPixelsH = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsY") == 0) { - _scrollPixelsV = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedX") == 0) { - _scrollTimeH = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedY") == 0) { - _scrollTimeV = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetX") == 0) { - _offsetLeft = value->getInt(); - - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - _targetOffsetLeft = _offsetLeft; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetY") == 0) { - _offsetTop = value->getInt(); - - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - viewportHeight); - _targetOffsetTop = _offsetTop; - - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdScene::scToString() { - return "[scene object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::addObject(CAdObject *object) { - _objects.add(object); - return _gameRef->registerObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::removeObject(CAdObject *object) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] == object) { - _objects.removeAt(i); - return _gameRef->unregisterObject(object); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { - int i; - - buffer->putTextIndent(indent, "SCENE {\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - if (_persistentState) - buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); - - if (!_persistentStateSprites) - buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); - - - // scripts - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // properties - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - // viewport - if (_viewport) { - Rect32 *rc = _viewport->getRect(); - buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); - } - - - - // editor settings - buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); - buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); - buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColFrame), RGBCOLGetG(_editorColFrame), RGBCOLGetB(_editorColFrame), RGBCOLGetA(_editorColFrame)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntitySel), RGBCOLGetG(_editorColEntitySel), RGBCOLGetB(_editorColEntitySel), RGBCOLGetA(_editorColEntitySel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegionSel), RGBCOLGetG(_editorColRegionSel), RGBCOLGetB(_editorColRegionSel), RGBCOLGetA(_editorColRegionSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlockedSel), RGBCOLGetG(_editorColBlockedSel), RGBCOLGetB(_editorColBlockedSel), RGBCOLGetA(_editorColBlockedSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecorSel), RGBCOLGetG(_editorColDecorSel), RGBCOLGetB(_editorColDecorSel), RGBCOLGetA(_editorColDecorSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypointsSel), RGBCOLGetG(_editorColWaypointsSel), RGBCOLGetB(_editorColWaypointsSel), RGBCOLGetA(_editorColWaypointsSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntity), RGBCOLGetG(_editorColEntity), RGBCOLGetB(_editorColEntity), RGBCOLGetA(_editorColEntity)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegion), RGBCOLGetG(_editorColRegion), RGBCOLGetB(_editorColRegion), RGBCOLGetA(_editorColRegion)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecor), RGBCOLGetG(_editorColDecor), RGBCOLGetB(_editorColDecor), RGBCOLGetA(_editorColDecor)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlocked), RGBCOLGetG(_editorColBlocked), RGBCOLGetB(_editorColBlocked), RGBCOLGetA(_editorColBlocked)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypoints), RGBCOLGetG(_editorColWaypoints), RGBCOLGetB(_editorColWaypoints), RGBCOLGetA(_editorColWaypoints)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColScale), RGBCOLGetG(_editorColScale), RGBCOLGetB(_editorColScale), RGBCOLGetA(_editorColScale)); - - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - CBBase::saveAsText(buffer, indent + 2); - - // waypoints - buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // layers - buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); - - // scale levels - buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); - - // rotation levels - buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent + 2, "\n"); - - // free entities - buffer->putTextIndent(indent + 2, "; ----- free entities\n"); - for (i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - _objects[i]->saveAsText(buffer, indent + 2); - - } - } - - - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortScaleLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { - if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { - CAdScaleLevel *sl = _scaleLevels[i]; - _scaleLevels[i] = _scaleLevels[i + 1]; - _scaleLevels[i + 1] = sl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortRotLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _rotLevels.getSize() - 1; i++) { - if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { - CAdRotLevel *rl = _rotLevels[i]; - _rotLevels[i] = _rotLevels[i + 1]; - _rotLevels[i + 1] = rl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getScaleAt(int Y) { - CAdScaleLevel *prev = NULL; - CAdScaleLevel *next = NULL; - - for (int i = 0; i < _scaleLevels.getSize(); i++) { - /* CAdScaleLevel *xxx = _scaleLevels[i];*/ - /* int j = _scaleLevels.getSize(); */ - if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; - else { - next = _scaleLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 100; - - int delta_y = next->_posY - prev->_posY; - float delta_scale = next->_scale - prev->_scale; - Y -= prev->_posY; - - float percent = (float)Y / ((float)delta_y / 100.0f); - return prev->_scale + delta_scale / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_autoScroll)); - persistMgr->transfer(TMEMBER(_editorColBlocked)); - persistMgr->transfer(TMEMBER(_editorColBlockedSel)); - persistMgr->transfer(TMEMBER(_editorColDecor)); - persistMgr->transfer(TMEMBER(_editorColDecorSel)); - persistMgr->transfer(TMEMBER(_editorColEntity)); - persistMgr->transfer(TMEMBER(_editorColEntitySel)); - persistMgr->transfer(TMEMBER(_editorColFrame)); - persistMgr->transfer(TMEMBER(_editorColRegion)); - persistMgr->transfer(TMEMBER(_editorColRegionSel)); - persistMgr->transfer(TMEMBER(_editorColScale)); - persistMgr->transfer(TMEMBER(_editorColWaypoints)); - persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); - persistMgr->transfer(TMEMBER(_editorMarginH)); - persistMgr->transfer(TMEMBER(_editorMarginV)); - persistMgr->transfer(TMEMBER(_editorShowBlocked)); - persistMgr->transfer(TMEMBER(_editorShowDecor)); - persistMgr->transfer(TMEMBER(_editorShowEntities)); - persistMgr->transfer(TMEMBER(_editorShowRegions)); - persistMgr->transfer(TMEMBER(_editorShowScale)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_initialized)); - persistMgr->transfer(TMEMBER(_lastTimeH)); - persistMgr->transfer(TMEMBER(_lastTimeV)); - _layers.persist(persistMgr); - persistMgr->transfer(TMEMBER(_mainLayer)); - _objects.persist(persistMgr); - persistMgr->transfer(TMEMBER(_offsetLeft)); - persistMgr->transfer(TMEMBER(_offsetTop)); - persistMgr->transfer(TMEMBER(_paralaxScrolling)); - persistMgr->transfer(TMEMBER(_persistentState)); - persistMgr->transfer(TMEMBER(_persistentStateSprites)); - persistMgr->transfer(TMEMBER(_pfMaxTime)); - _pfPath.persist(persistMgr); - persistMgr->transfer(TMEMBER(_pfPointsNum)); - persistMgr->transfer(TMEMBER(_pfReady)); - persistMgr->transfer(TMEMBER(_pfRequester)); - persistMgr->transfer(TMEMBER(_pfTarget)); - persistMgr->transfer(TMEMBER(_pfTargetPath)); - _rotLevels.persist(persistMgr); - _scaleLevels.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollPixelsH)); - persistMgr->transfer(TMEMBER(_scrollPixelsV)); - persistMgr->transfer(TMEMBER(_scrollTimeH)); - persistMgr->transfer(TMEMBER(_scrollTimeV)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER(_targetOffsetLeft)); - persistMgr->transfer(TMEMBER(_targetOffsetTop)); - _waypointGroups.persist(persistMgr); - persistMgr->transfer(TMEMBER(_viewport)); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::afterLoad() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { - double xStep, yStep, x, y; - int xLength, yLength, xCount, yCount; - int x1, y1, x2, y2; - - x1 = *targetX; - y1 = *targetY; - x2 = startX; - y2 = startY; - - - xLength = abs(x2 - x1); - yLength = abs(y2 - y1); - - if (xLength > yLength) { - /* - if (X1 > X2) - { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); - y = y1; - - for (xCount = x1; xCount < x2; xCount++) { - if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { - *targetX = xCount; - *targetY = (int)y; - return STATUS_OK; - } - y += yStep; - } - } else { - /* - if (Y1 > Y2) { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); - x = x1; - - for (yCount = y1; yCount < y2; yCount++) { - if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { - *targetX = (int)x; - *targetY = yCount; - return STATUS_OK; - } - x += xStep; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { - int x = *argX; - int y = *argY; - - if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { - return STATUS_OK; - } - - // right - int length_right = 0; - bool found_right = false; - for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { - found_right = true; - break; - } - } - - // left - int length_left = 0; - bool found_left = false; - for (x = *argX, y = *argY; x >= 0; x--, length_left--) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { - found_left = true; - break; - } - } - - // up - int length_up = 0; - bool found_up = false; - for (x = *argX, y = *argY; y >= 0; y--, length_up--) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { - found_up = true; - break; - } - } - - // down - int length_down = 0; - bool found_down = false; - for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { - found_down = true; - break; - } - } - - if (!found_left && !found_right && !found_up && !found_down) { - return STATUS_OK; - } - - int OffsetX = INT_MAX, OffsetY = INT_MAX; - - if (found_left && found_right) { - if (abs(length_left) < abs(length_right)) OffsetX = length_left; - else OffsetX = length_right; - } else if (found_left) OffsetX = length_left; - else if (found_right) OffsetX = length_right; - - if (found_up && found_down) { - if (abs(length_up) < abs(length_down)) OffsetY = length_up; - else OffsetY = length_down; - } else if (found_up) OffsetY = length_up; - else if (found_down) OffsetY = length_down; - - if (abs(OffsetX) < abs(OffsetY)) - *argX = *argX + OffsetX; - else - *argY = *argY + OffsetY; - - if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsStart() { - _pfPointsNum = 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsAdd(int x, int y, int distance) { - if (_pfPointsNum >= _pfPath.getSize()) { - _pfPath.add(new CAdPathPoint(x, y, distance)); - } else { - _pfPath[_pfPointsNum]->x = x; - _pfPath[_pfPointsNum]->y = y; - _pfPath[_pfPointsNum]->_distance = distance; - _pfPath[_pfPointsNum]->_marked = false; - _pfPath[_pfPointsNum]->_origin = NULL; - } - - _pfPointsNum++; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { - CAdGame *adGame = (CAdGame *)_gameRef; - if (_viewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = _viewport->_offsetX; - if (offsetY) *offsetY = _viewport->_offsetY; - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; - if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; - } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportSize(int *width, int *height) { - CAdGame *adGame = (CAdGame *)_gameRef; - if (_viewport && !_gameRef->_editorMode) { - if (width) *width = _viewport->getWidth(); - if (height) *height = _viewport->getHeight(); - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (width) *width = adGame->_sceneViewport->getWidth(); - if (height) *height = adGame->_sceneViewport->getHeight(); - } else { - if (width) *width = _gameRef->_renderer->_width; - if (height) *height = _gameRef->_renderer->_height; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetLeft() { - int viewportX; - getViewportOffset(&viewportX); - - return _offsetLeft - viewportX; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetTop() { - int viewportY; - getViewportOffset(NULL, &viewportY); - - return _offsetTop - viewportY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::pointInViewport(int x, int y) { - int left, top, width, height; - - getViewportOffset(&left, &top); - getViewportSize(&width, &height); - - return x >= left && x <= left + width && y >= top && y <= top + height; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::setOffset(int offsetLeft, int offsetTop) { - _offsetLeft = offsetLeft; - _offsetTop = offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNodeByName(const char *name) { - CBObject *ret = NULL; - - // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || - (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { - switch (node->_type) { - case OBJECT_ENTITY: - ret = node->_entity; - break; - case OBJECT_REGION: - ret = node->_region; - break; - default: - ret = NULL; - } - return ret; - } - } - } - - // free entities - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { - return _objects[i]; - } - } - - // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { - if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { - return _waypointGroups[i]; - } - } - - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveState() { - return persistState(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadState() { - return persistState(false); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::persistState(bool saving) { - if (!_persistentState) return STATUS_OK; - - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSceneState *state = adGame->getSceneState(_filename, saving); - if (!state) return STATUS_OK; - - CAdNodeState *nodeState; - - // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: - if (!node->_entity->_saveState) continue; - nodeState = state->getNodeState(node->_entity->_name, saving); - if (nodeState) { - nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); - //if(Saving) NodeState->_active = node->_entity->_active; - //else node->_entity->_active = NodeState->_active; - } - break; - case OBJECT_REGION: - if (!node->_region->_saveState) continue; - nodeState = state->getNodeState(node->_region->_name, saving); - if (nodeState) { - if (saving) nodeState->_active = node->_region->_active; - else node->_region->_active = nodeState->_active; - } - break; - default: - warning("CAdScene::PersistState - unhandled enum"); - break; - } - } - } - - // free entities - for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_saveState) continue; - if (_objects[i]->_type == OBJECT_ENTITY) { - nodeState = state->getNodeState(_objects[i]->_name, saving); - if (nodeState) { - nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); - //if(Saving) NodeState->_active = _objects[i]->_active; - //else _objects[i]->_active = NodeState->_active; - } - } - } - - // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { - nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); - if (nodeState) { - if (saving) nodeState->_active = _waypointGroups[i]->_active; - else _waypointGroups[i]->_active = nodeState->_active; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getRotationAt(int x, int y) { - CAdRotLevel *prev = NULL; - CAdRotLevel *next = NULL; - - for (int i = 0; i < _rotLevels.getSize(); i++) { - /* CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.getSize();*/ - if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; - else { - next = _rotLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 0; - - int delta_x = next->_posX - prev->_posX; - float delta_rot = next->_rotation - prev->_rotation; - x -= prev->_posX; - - float percent = (float)x / ((float)delta_x / 100.0f); - return prev->_rotation + delta_rot / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::handleItemAssociations(const char *itemName, bool show) { - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - if (layer->_nodes[j]->_type == OBJECT_ENTITY) { - CAdEntity *ent = layer->_nodes[j]->_entity; - - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; - } - } - } - - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - CAdEntity *ent = (CAdEntity *)_objects[i]; - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { - int numUsed = 0; - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (numUsed < numRegions - 1) { - regionList[numUsed] = node->_region; - numUsed++; - } else break; - } - } - } - for (int i = numUsed; i < numRegions; i++) { - regionList[i] = NULL; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::restoreDeviceObjects() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { - CBArray objects; - getSceneObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { - if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { - CBArray objects; - getSceneObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; - } - } - } - return objects[objects.getSize() - 1]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _layers.getSize(); i++) { - // close-up layer -> remove everything below it - if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); - - - for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { - CAdSceneNode *node = _layers[i]->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: { - CAdEntity *ent = node->_entity; - if (ent->_active && (ent->_registrable || !interactiveOnly)) - objects.add(ent); - } - break; - - case OBJECT_REGION: { - CBArray regionObj; - getRegionObjects(node->_region, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { - bool found = false; - for (int old = 0; old < objects.getSize(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) objects.add(regionObj[newIndex]); - } - //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); - } - break; - default: - warning("CAdScene::GetSceneObjects - Unhandled enum"); - break; - } - } - } - - // objects outside any region - CBArray regionObj; - getRegionObjects(NULL, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { - bool found = false; - for (int old = 0; old < objects.getSize(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) objects.add(regionObj[newIndex]); - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - obj = adGame->_objects[i]; - if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; - - objects.add(obj); - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; - - objects.add(obj); - } - } - - // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdScene.h b/engines/wintermute/Ad/AdScene.h deleted file mode 100644 index 72c69e668a..0000000000 --- a/engines/wintermute/Ad/AdScene.h +++ /dev/null @@ -1,181 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENE_H -#define WINTERMUTE_ADSCENE_H - -#include "engines/wintermute/Base/BFader.h" - -namespace WinterMute { - -class CUIWindow; -class CAdObject; -class CAdRegion; -class CBViewport; -class CAdLayer; -class CBPoint; -class CAdWaypointGroup; -class CAdPath; -class CAdScaleLevel; -class CAdRotLevel; -class CAdPathPoint; -class CAdScene : public CBObject { -public: - - CBObject *getNextAccessObject(CBObject *CurrObject); - CBObject *getPrevAccessObject(CBObject *CurrObject); - bool getSceneObjects(CBArray &Objects, bool InteractiveOnly); - bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - - bool afterLoad(); - - bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - bool handleItemAssociations(const char *ItemName, bool Show); - CUIWindow *_shieldWindow; - float getRotationAt(int X, int Y); - bool loadState(); - bool saveState(); - bool _persistentState; - bool _persistentStateSprites; - CBObject *getNodeByName(const char *name); - void setOffset(int OffsetLeft, int OffsetTop); - bool pointInViewport(int X, int Y); - int getOffsetTop(); - int getOffsetLeft(); - bool getViewportSize(int *Width = NULL, int *Height = NULL); - bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - CBViewport *_viewport; - CBFader *_fader; - int _pfPointsNum; - void pfPointsAdd(int X, int Y, int Distance); - void pfPointsStart(); - bool _initialized; - bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); - DECLARE_PERSISTENT(CAdScene, CBObject) - bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - bool displayRegionContentOld(CAdRegion *Region = NULL); - static int compareObjs(const void *Obj1, const void *Obj2); - - bool updateFreeObjects(); - bool traverseNodes(bool Update = false); - float getScaleAt(int Y); - bool sortScaleLevels(); - bool sortRotLevels(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); - bool _paralaxScrolling; - void skipTo(int OffsetX, int OffsetY); - void setDefaults(); - void cleanup(); - void skipToObject(CBObject *Object); - void scrollToObject(CBObject *Object); - void scrollTo(int OffsetX, int OffsetY); - virtual bool update(); - bool _autoScroll; - int _targetOffsetTop; - int _targetOffsetLeft; - - int _scrollPixelsV; - uint32 _scrollTimeV; - uint32 _lastTimeV; - - int _scrollPixelsH; - uint32 _scrollTimeH; - uint32 _lastTimeH; - - virtual bool display(); - uint32 _pfMaxTime; - bool initLoop(); - void pathFinderStep(); - bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - CAdLayer *_mainLayer; - float getZoomAt(int X, int Y); - bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); - CAdScene(CBGame *inGame); - virtual ~CAdScene(); - CBArray _layers; - CBArray _objects; - CBArray _waypointGroups; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - int _width; - int _height; - bool addObject(CAdObject *Object); - bool removeObject(CAdObject *Object); - int _editorMarginH; - int _editorMarginV; - uint32 _editorColFrame; - uint32 _editorColEntity; - uint32 _editorColRegion; - uint32 _editorColBlocked; - uint32 _editorColWaypoints; - uint32 _editorColEntitySel; - uint32 _editorColRegionSel; - uint32 _editorColBlockedSel; - uint32 _editorColWaypointsSel; - uint32 _editorColScale; - uint32 _editorColDecor; - uint32 _editorColDecorSel; - - bool _editorShowRegions; - bool _editorShowBlocked; - bool _editorShowDecor; - bool _editorShowEntities; - bool _editorShowScale; - CBArray _scaleLevels; - CBArray _rotLevels; - - virtual bool restoreDeviceObjects(); - int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - bool persistState(bool Saving = true); - void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); - bool _pfReady; - CBPoint *_pfTarget; - CAdPath *_pfTargetPath; - CBObject *_pfRequester; - CBArray _pfPath; - - int _offsetTop; - int _offsetLeft; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp deleted file mode 100644 index 38de185918..0000000000 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _region = NULL; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::~CAdSceneNode() { - _gameRef->unregisterObject(_region); - _region = NULL; - - _gameRef->unregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setEntity(CAdEntity *entity) { - _type = OBJECT_ENTITY; - _entity = entity; - return _gameRef->registerObject(entity); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setRegion(CAdRegion *region) { - _type = OBJECT_REGION; - _region = region; - return _gameRef->registerObject(region); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - persistMgr->transfer(TMEMBER(_region)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSceneNode.h b/engines/wintermute/Ad/AdSceneNode.h deleted file mode 100644 index 808bfceef4..0000000000 --- a/engines/wintermute/Ad/AdSceneNode.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENENODE_H -#define WINTERMUTE_ADSCENENODE_H - - -#include "engines/wintermute/Ad/AdTypes.h" // Added by ClassView -#include "engines/wintermute/Ad/AdRegion.h" // Added by ClassView -#include "engines/wintermute/Ad/AdEntity.h" - -namespace WinterMute { - -class CAdSceneNode : public CBObject { -public: - DECLARE_PERSISTENT(CAdSceneNode, CBObject) - bool setRegion(CAdRegion *region); - bool setEntity(CAdEntity *entity); - CAdEntity *_entity; - CAdRegion *_region; - TObjectType _type; - CAdSceneNode(CBGame *inGame); - virtual ~CAdSceneNode(); - -}; - -} - -#endif diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp deleted file mode 100644 index e56c5f479a..0000000000 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/Ad/AdNodeState.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneState, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::~CAdSceneState() { - delete[] _filename; - _filename = NULL; - - for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; - _nodeStates.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneState::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_filename)); - _nodeStates.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSceneState::setFilename(const char *filename) { - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { - for (int i = 0; i < _nodeStates.getSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; - } - - if (saving) { - CAdNodeState *ret = new CAdNodeState(_gameRef); - ret->setName(name); - _nodeStates.add(ret); - - return ret; - } else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSceneState.h b/engines/wintermute/Ad/AdSceneState.h deleted file mode 100644 index d81c7b31cb..0000000000 --- a/engines/wintermute/Ad/AdSceneState.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENESTATE_H -#define WINTERMUTE_ADSCENESTATE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { -class CAdNodeState; -class CAdSceneState : public CBBase { -public: - CAdNodeState *getNodeState(char *name, bool saving); - void setFilename(const char *filename); - DECLARE_PERSISTENT(CAdSceneState, CBBase) - CAdSceneState(CBGame *inGame); - virtual ~CAdSceneState(); - char *_filename; - CBArray _nodeStates; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp deleted file mode 100644 index 8c830a15f1..0000000000 --- a/engines/wintermute/Ad/AdSentence.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Ad/AdTalkDef.h" -#include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSentence, false) - -////////////////////////////////////////////////////////////////////////// -CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { - _text = NULL; - _stances = NULL; - _tempStance = NULL; - - _duration = 0; - _startTime = 0; - _currentStance = 0; - - _font = NULL; - - _pos.x = _pos.y = 0; - _width = _gameRef->_renderer->_width; - - _align = (TTextAlign)TAL_CENTER; - - _sound = NULL; - _soundStarted = false; - - _talkDef = NULL; - _currentSprite = NULL; - _currentSkelAnim = NULL; - _fixedPos = false; - _freezable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSentence::~CAdSentence() { - delete _sound; - delete[] _text; - delete[] _stances; - delete[] _tempStance; - delete _talkDef; - _sound = NULL; - _text = NULL; - _stances = NULL; - _tempStance = NULL; - _talkDef = NULL; - - _currentSprite = NULL; // ref only - _currentSkelAnim = NULL; - _font = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setText(const char *text) { - if (_text) delete [] _text; - _text = new char[strlen(text) + 1]; - if (_text) strcpy(_text, text); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setStances(const char *stances) { - if (_stances) delete [] _stances; - if (stances) { - _stances = new char[strlen(stances) + 1]; - if (_stances) strcpy(_stances, stances); - } else _stances = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getCurrentStance() { - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getNextStance() { - _currentStance++; - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getStance(int stance) { - if (_stances == NULL) return NULL; - - if (_tempStance) delete [] _tempStance; - _tempStance = NULL; - - char *start; - char *curr; - int pos; - - if (stance == 0) start = _stances; - else { - pos = 0; - start = NULL; - curr = _stances; - while (pos < stance) { - if (*curr == '\0') break; - if (*curr == ',') pos++; - curr++; - } - if (pos == stance) start = curr; - } - - if (start == NULL) return NULL; - - while (*start == ' ' && *start != ',' && *start != '\0') start++; - - curr = start; - while (*curr != '\0' && *curr != ',') curr++; - - while (curr > start && *(curr - 1) == ' ') curr--; - - _tempStance = new char [curr - start + 1]; - if (_tempStance) { - _tempStance[curr - start] = '\0'; - strncpy(_tempStance, start, curr - start); - } - - return _tempStance; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::display() { - if (!_font || !_text) return STATUS_FAILED; - - if (_sound && !_soundStarted) { - _sound->play(); - _soundStarted = true; - } - - if (_gameRef->_subtitles) { - int x = _pos.x; - int y = _pos.y; - - if (!_fixedPos) { - x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - - x = MAX(x, 0); - x = MIN(x, _gameRef->_renderer->_width - _width); - y = MAX(y, 0); - - _font->drawText((byte *)_text, x, y, _width, _align); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setSound(CBSound *sound) { - if (!sound) return; - delete _sound; - _sound = sound; - _soundStarted = false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::finish() { - if (_sound) _sound->stop(); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER_INT(_align)); - persistMgr->transfer(TMEMBER(_currentStance)); - persistMgr->transfer(TMEMBER(_currentSprite)); - persistMgr->transfer(TMEMBER(_currentSkelAnim)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_sound)); - persistMgr->transfer(TMEMBER(_soundStarted)); - persistMgr->transfer(TMEMBER(_stances)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_talkDef)); - persistMgr->transfer(TMEMBER(_tempStance)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_fixedPos)); - persistMgr->transfer(TMEMBER(_freezable)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::setupTalkFile(const char *soundFilename) { - delete _talkDef; - _talkDef = NULL; - _currentSprite = NULL; - - if (!soundFilename) return STATUS_OK; - - - AnsiString path = PathUtil::getDirectoryName(soundFilename); - AnsiString name = PathUtil::getFileNameWithoutExtension(soundFilename); - - AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); - if (file) { - _gameRef->_fileManager->closeFile(file); - } else return STATUS_OK; // no talk def file found - - - _talkDef = new CAdTalkDef(_gameRef); - if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { - delete _talkDef; - _talkDef = NULL; - return STATUS_FAILED; - } - //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::update(TDirection dir) { - if (!_talkDef) return STATUS_OK; - - uint32 currentTime; - // if sound is available, synchronize with sound, otherwise use timer - - /* - if (_sound) CurrentTime = _sound->GetPositionTime(); - else CurrentTime = _gameRef->_timer - _startTime; - */ - currentTime = _gameRef->_timer - _startTime; - - bool talkNodeFound = false; - for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { - if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { - talkNodeFound = true; - - CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); - if (newSprite != _currentSprite) newSprite->reset(); - _currentSprite = newSprite; - - if (!_talkDef->_nodes[i]->_playToEnd) break; - } - } - - - // no talk node, try to use default sprite instead (if any) - if (!talkNodeFound) { - CBSprite *newSprite = _talkDef->getDefaultSprite(dir); - if (newSprite) { - if (newSprite != _currentSprite) newSprite->reset(); - _currentSprite = newSprite; - } else _currentSprite = NULL; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::CanSkip() { - // prevent accidental sentence skipping (TODO make configurable) - return (_gameRef->_timer - _startTime) > 300; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSentence.h b/engines/wintermute/Ad/AdSentence.h deleted file mode 100644 index 71b60c2d0d..0000000000 --- a/engines/wintermute/Ad/AdSentence.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSENTENCE_H -#define WINTERMUTE_ADSENTENCE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "common/rect.h" - -namespace WinterMute { -class CAdTalkDef; -class CBFont; -class CBSprite; -class CBSound; -class CAdSentence : public CBBase { -public: - bool _freezable; - bool _fixedPos; - CBSprite *_currentSprite; - char *_currentSkelAnim; - bool update(TDirection dir = DI_DOWN); - bool setupTalkFile(const char *soundFilename); - DECLARE_PERSISTENT(CAdSentence, CBBase) - bool finish(); - void setSound(CBSound *Sound); - bool _soundStarted; - CBSound *_sound; - TTextAlign _align; - bool display(); - int _width; - Point32 _pos; - CBFont *_font; - char *getNextStance(); - char *getCurrentStance(); - void setStances(const char *stances); - void setText(const char *text); - int _currentStance; - uint32 _startTime; - char *_stances; - char *_text; - uint32 _duration; - CAdSentence(CBGame *inGame); - virtual ~CAdSentence(); - CAdTalkDef *_talkDef; - - bool CanSkip(); - -private: - char *_tempStance; - char *getStance(int stance); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp deleted file mode 100644 index a5ed4feb0c..0000000000 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSpriteSet, false) - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { - _owner = owner; - - for (int i = 0; i < NUM_DIRECTIONS; i++) - _sprites[i] = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::~CAdSpriteSet() { - for (int i = 0; i < NUM_DIRECTIONS; i++) { - delete _sprites[i]; - _sprites[i] = NULL; - } - - _owner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SPRITESET) -TOKEN_DEF(NAME) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(RIGHT) -TOKEN_DEF(UP) -TOKEN_DEF(DOWN) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(NAME) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(RIGHT) - TOKEN_TABLE(UP) - TOKEN_TABLE(DOWN) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { - _gameRef->LOG(0, "'SPRITESET' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CBSprite *spr = NULL; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_LEFT: - delete _sprites[DI_LEFT]; - _sprites[DI_LEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_LEFT] = spr; - break; - - case TOKEN_RIGHT: - delete _sprites[DI_RIGHT]; - _sprites[DI_RIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_RIGHT] = spr; - break; - - case TOKEN_UP: - delete _sprites[DI_UP]; - _sprites[DI_UP] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UP] = spr; - break; - - case TOKEN_DOWN: - delete _sprites[DI_DOWN]; - _sprites[DI_DOWN] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWN] = spr; - break; - - case TOKEN_UP_LEFT: - delete _sprites[DI_UPLEFT]; - _sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPLEFT] = spr; - break; - - case TOKEN_UP_RIGHT: - delete _sprites[DI_UPRIGHT]; - _sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPRIGHT] = spr; - break; - - case TOKEN_DOWN_LEFT: - delete _sprites[DI_DOWNLEFT]; - _sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNLEFT] = spr; - break; - - case TOKEN_DOWN_RIGHT: - delete _sprites[DI_DOWNRIGHT]; - _sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNRIGHT] = spr; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITESET definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading SPRITESET definition"); - if (spr) delete spr; - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_owner)); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - persistMgr->transfer("", &_sprites[i]); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdSpriteSet::getSprite(TDirection direction) { - int dir = (int)direction; - if (dir < 0) dir = 0; - if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; - - CBSprite *ret = NULL; - - // find nearest set sprite - int numSteps = 0; - for (int i = dir; i >= 0; i--) { - if (_sprites[i] != NULL) { - ret = _sprites[i]; - numSteps = dir - i; - break; - } - } - - for (int i = dir; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] != NULL) { - if (ret == NULL || numSteps > i - dir) return _sprites[i]; - else return ret; - } - } - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITESET {\n"); - if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i]) { - switch (i) { - case DI_UP: - buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPRIGHT: - buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_RIGHT: - buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNRIGHT: - buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWN: - buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNLEFT: - buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_LEFT: - buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPLEFT: - buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - } - } - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::containsSprite(CBSprite *sprite) { - if (!sprite) return false; - - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] == sprite) return true; - } - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdSpriteSet.h b/engines/wintermute/Ad/AdSpriteSet.h deleted file mode 100644 index 1c559fb77b..0000000000 --- a/engines/wintermute/Ad/AdSpriteSet.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSPRITESET_H -#define WINTERMUTE_ADSPRITESET_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BSprite.h" // Added by ClassView - -namespace WinterMute { - -class CAdSpriteSet : public CBObject { -public: - bool containsSprite(CBSprite *sprite); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBSprite *getSprite(TDirection direction); - DECLARE_PERSISTENT(CAdSpriteSet, CBObject) - CBObject *_owner; - CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); - virtual ~CAdSpriteSet(); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - CBSprite *_sprites[NUM_DIRECTIONS]; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp deleted file mode 100644 index 9f31d9f61e..0000000000 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdTalkDef.h" -#include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkDef, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::~CAdTalkDef() { - for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; - _nodes.removeAll(); - - delete[] _defaultSpriteFilename; - delete _defaultSprite; - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - delete[] _defaultSpriteSetFilename; - delete _defaultSpriteSet; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - CBUtils::setString(&_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TALK) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(ACTION) -TOKEN_DEF(DEFAULT_SPRITESET_FILE) -TOKEN_DEF(DEFAULT_SPRITESET) -TOKEN_DEF(DEFAULT_SPRITE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(DEFAULT_SPRITESET_FILE) - TOKEN_TABLE(DEFAULT_SPRITESET) - TOKEN_TABLE(DEFAULT_SPRITE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { - _gameRef->LOG(0, "'TALK' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_ACTION: { - CAdTalkNode *Node = new CAdTalkNode(_gameRef); - if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); - else { - delete Node; - Node = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_DEFAULT_SPRITE: - CBUtils::setString(&_defaultSpriteFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET: { - delete _defaultSpriteSet; - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TALK definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading TALK definition"); - return STATUS_FAILED; - } - - delete _defaultSprite; - delete _defaultSpriteSet; - _defaultSprite = NULL; - _defaultSpriteSet = NULL; - - if (_defaultSpriteFilename) { - _defaultSprite = new CBSprite(_gameRef); - if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; - } - - if (_defaultSpriteSetFilename) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_defaultSprite)); - persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); - persistMgr->transfer(TMEMBER(_defaultSpriteSet)); - persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); - - _nodes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "TALK {\n"); - if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - - if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); - - for (int i = 0; i < _nodes.getSize(); i++) { - _nodes[i]->saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "\n"); - } - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadDefaultSprite() { - if (_defaultSpriteFilename && !_defaultSprite) { - _defaultSprite = new CBSprite(_gameRef); - if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { - delete _defaultSprite; - _defaultSprite = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { - loadDefaultSprite(); - if (_defaultSprite) return _defaultSprite; - else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkDef.h b/engines/wintermute/Ad/AdTalkDef.h deleted file mode 100644 index cece5be4da..0000000000 --- a/engines/wintermute/Ad/AdTalkDef.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKDEF_H -#define WINTERMUTE_ADTALKDEF_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { -class CAdTalkNode; -class CAdSpriteSet; -class CAdTalkDef : public CBObject { -public: - char *_defaultSpriteSetFilename; - CAdSpriteSet *_defaultSpriteSet; - CBSprite *getDefaultSprite(TDirection Dir); - bool loadDefaultSprite(); - DECLARE_PERSISTENT(CAdTalkDef, CBObject) - - CAdTalkDef(CBGame *inGame); - virtual ~CAdTalkDef(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - CBArray _nodes; - char *_defaultSpriteFilename; - CBSprite *_defaultSprite; - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp deleted file mode 100644 index 2626021054..0000000000 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdTalkHolder.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintermute.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkHolder, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::~CAdTalkHolder() { - delete _sprite; - _sprite = NULL; - - for (int i = 0; i < _talkSprites.getSize(); i++) - delete _talkSprites[i]; - _talkSprites.removeAll(); - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) - delete _talkSpritesEx[i]; - _talkSpritesEx.removeAll(); -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { - CBSprite *ret = NULL; - - - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - - if (stance != NULL) { - // search special talk stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { - ret = _talkSpritesEx[i]; - break; - } - } - if (ret == NULL) { - // serach generic talk stances - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { - ret = _talkSprites[i]; - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _sprite; - else { - // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); - ret = _talkSprites[rnd]; - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSprite") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - - bool setCurrent = false; - if (_currentSprite && _currentSprite == _sprite) setCurrent = true; - - delete _sprite; - _sprite = NULL; - - if (val->isNULL()) { - _sprite = NULL; - if (setCurrent) _currentSprite = NULL; - stack->pushBool(true); - } else { - const char *filename = val->getString(); - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - script->runtimeError("SetSprite method failed for file '%s'", filename); - stack->pushBool(false); - } else { - _sprite = spr; - if (setCurrent) _currentSprite = _sprite; - stack->pushBool(true); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSprite") == 0) { - stack->correctParams(0); - - if (!_sprite || !_sprite->_filename) stack->pushNULL(); - else stack->pushString(_sprite->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSpriteObject") == 0) { - stack->correctParams(0); - - if (!_sprite) stack->pushNULL(); - else stack->pushNative(_sprite, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool Ex = stack->pop()->getBool(); - - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("AddTalkSprite method failed for file '%s'", filename); - } else { - if (Ex) _talkSpritesEx.add(spr); - else _talkSprites.add(spr); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool ex = stack->pop()->getBool(); - - bool setCurrent = false; - bool setTemp2 = false; - - if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) - setCurrent = true; - if (_tempSprite2 == _talkSpritesEx[i]) - setTemp2 = true; - delete _talkSpritesEx[i]; - _talkSpritesEx.removeAt(i); - break; - } - } - } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSprites[i]) - setCurrent = true; - if (_tempSprite2 == _talkSprites[i]) - setTemp2 = true; - delete _talkSprites[i]; - _talkSprites.removeAt(i); - break; - } - } - - } - - stack->pushBool(true); - if (setCurrent) - _currentSprite = _sprite; - if (setTemp2) - _tempSprite2 = _sprite; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool ex = stack->pop()->getBool(); - bool setCurrent = false; - bool setTemp2 = false; - - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("SetTalkSprite method failed for file '%s'", filename); - } else { - - // delete current - if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i] == _currentSprite) - setCurrent = true; - if (_talkSpritesEx[i] == _tempSprite2) - setTemp2 = true; - delete _talkSpritesEx[i]; - } - _talkSpritesEx.removeAll(); - } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i] == _currentSprite) setCurrent = true; - if (_talkSprites[i] == _tempSprite2) setTemp2 = true; - delete _talkSprites[i]; - } - _talkSprites.removeAll(); - } - - // set new - if (ex) - _talkSpritesEx.add(spr); - else - _talkSprites.add(spr); - stack->pushBool(true); - - if (setCurrent) - _currentSprite = spr; - if (setTemp2) - _tempSprite2 = spr; - } - return STATUS_OK; - } - - else return CAdObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("talk-holder"); - return _scValue; - } - - else return CAdObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Item")==0){ - SetItem(value->getString()); - return STATUS_OK; - } - - else*/ return CAdObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdTalkHolder::scToString() { - return "[talk-holder object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); - } - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { - CAdObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_sprite)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkHolder.h b/engines/wintermute/Ad/AdTalkHolder.h deleted file mode 100644 index a427c9eb04..0000000000 --- a/engines/wintermute/Ad/AdTalkHolder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKHOLDER_H -#define WINTERMUTE_ADTALKHOLDER_H - -#include "engines/wintermute/Ad/AdObject.h" - -namespace WinterMute { - -class CAdTalkHolder : public CAdObject { -public: - DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *getTalkStance(const char *stance); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - CBSprite *_sprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - CAdTalkHolder(CBGame *inGame); - virtual ~CAdTalkHolder(); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp deleted file mode 100644 index 58644e7ca0..0000000000 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/utils/utils.h" -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { - _sprite = NULL; - _spriteFilename = NULL; - _spriteSet = NULL; - _spriteSetFilename = NULL; - _comment = NULL; - - _startTime = _endTime = 0; - _playToEnd = false; - _preCache = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::~CAdTalkNode() { - delete[] _spriteFilename; - delete _sprite; - delete[] _spriteSetFilename; - delete _spriteSet; - delete _comment; - _spriteFilename = NULL; - _sprite = NULL; - _spriteSetFilename = NULL; - _spriteSet = NULL; - _comment = NULL; -} - - - -TOKEN_DEF_START -TOKEN_DEF(ACTION) -TOKEN_DEF(SPRITESET_FILE) -TOKEN_DEF(SPRITESET) -TOKEN_DEF(SPRITE) -TOKEN_DEF(START_TIME) -TOKEN_DEF(END_TIME) -TOKEN_DEF(COMMENT) -TOKEN_DEF(PRECACHE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(SPRITESET_FILE) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(START_TIME) - TOKEN_TABLE(END_TIME) - TOKEN_TABLE(COMMENT) - TOKEN_TABLE(PRECACHE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { - _gameRef->LOG(0, "'ACTION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - _endTime = 0; - _playToEnd = false; - _preCache = false; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SPRITE: - CBUtils::setString(&_spriteFilename, (char *)params); - break; - - case TOKEN_SPRITESET_FILE: - CBUtils::setString(&_spriteSetFilename, (char *)params); - break; - - case TOKEN_SPRITESET: { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { - delete _spriteSet; - _spriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_START_TIME: - parser.scanStr((char *)params, "%d", &_startTime); - break; - - case TOKEN_END_TIME: - parser.scanStr((char *)params, "%d", &_endTime); - break; - - case TOKEN_PRECACHE: - parser.scanStr((char *)params, "%b", &_preCache); - break; - - case TOKEN_COMMENT: - if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ACTION definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ACTION definition"); - return STATUS_FAILED; - } - - if (_endTime == 0) - _playToEnd = true; - else - _playToEnd = false; - - if (_preCache && _spriteFilename) { - delete _sprite; - _sprite = new CBSprite(_gameRef); - if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) - return STATUS_FAILED; - } - - if (_preCache && _spriteSetFilename) { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) - return STATUS_FAILED; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_comment)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_endTime)); - persistMgr->transfer(TMEMBER(_playToEnd)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_spriteFilename)); - persistMgr->transfer(TMEMBER(_spriteSet)); - persistMgr->transfer(TMEMBER(_spriteSetFilename)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ACTION {\n"); - if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); - buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); - if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadSprite() { - if (_spriteFilename && !_sprite) { - _sprite = new CBSprite(_gameRef); - if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { - delete _sprite; - _sprite = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } - - else if (_spriteSetFilename && !_spriteSet) { - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { - delete _spriteSet; - _spriteSet = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } - - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { - if (time >= _startTime) { - if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; - else return false; - } else return _endTime >= time; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::getSprite(TDirection dir) { - loadSprite(); - if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->getSprite(dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdTalkNode.h b/engines/wintermute/Ad/AdTalkNode.h deleted file mode 100644 index 3718340c0e..0000000000 --- a/engines/wintermute/Ad/AdTalkNode.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKNODE_H -#define WINTERMUTE_ADTALKNODE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { -class CAdSpriteSet; -class CBSprite; -class CAdTalkNode : public CBBase { -public: - char *_spriteSetFilename; - CAdSpriteSet *_spriteSet; - CBSprite *getSprite(TDirection dir); - bool isInTimeInterval(uint32 time, TDirection dir); - bool loadSprite(); - DECLARE_PERSISTENT(CAdTalkNode, CBBase) - - CAdTalkNode(CBGame *inGame); - virtual ~CAdTalkNode(); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - char *_spriteFilename; - CBSprite *_sprite; - uint32 _startTime; - uint32 _endTime; - bool _playToEnd; - bool _preCache; - char *_comment; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Ad/AdTypes.h b/engines/wintermute/Ad/AdTypes.h deleted file mode 100644 index b88d6fe259..0000000000 --- a/engines/wintermute/Ad/AdTypes.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTYPES_H -#define WINTERMUTE_ADTYPES_H - -namespace WinterMute { - -typedef enum { - GAME_NORMAL, - GAME_WAITING_RESPONSE -} TGameStateEx; - -typedef enum { - OBJECT_ENTITY, - OBJECT_REGION, - OBJECT_ACTOR, - OBJECT_NONE -} TObjectType; - -typedef enum { - ENTITY_NORMAL, - ENTITY_SOUND -} TEntityType; - -typedef enum { - STATE_NONE, - STATE_IDLE, - STATE_PLAYING_ANIM, - STATE_READY, - STATE_FOLLOWING_PATH, - STATE_SEARCHING_PATH, - STATE_WAITING_PATH, - STATE_TURNING_LEFT, - STATE_TURNING_RIGHT, - STATE_TURNING, - STATE_TALKING, - STATE_DIRECT_CONTROL, - STATE_PLAYING_ANIM_SET -} TObjectState; - -typedef enum { - DIRECT_WALK_NONE, - DIRECT_WALK_FW, - DIRECT_WALK_BK -} TDirectWalkMode; - -typedef enum { - DIRECT_TURN_NONE, - DIRECT_TURN_CW, - DIRECT_TURN_CCW -} TDirectTurnMode; - -typedef enum { - RESPONSE_TEXT, - RESPONSE_ICON -} TResponseStyle; - -typedef enum { - RESPONSE_ALWAYS, - RESPONSE_ONCE, - RESPONSE_ONCE_GAME -} TResponseType; - - -typedef enum { - TALK_SKIP_LEFT = 0, - TALK_SKIP_RIGHT = 1, - TALK_SKIP_BOTH = 2, - TALK_SKIP_NONE = 3 -} TTalkSkipButton; - -typedef enum { - GEOM_WAYPOINT, - GEOM_WALKPLANE, - GEOM_BLOCKED, - GEOM_GENERIC -} TGeomNodeType; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp deleted file mode 100644 index ec0d66d468..0000000000 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BFileManager.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; -} - - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::~CAdWaypointGroup() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdWaypointGroup::cleanup() { - for (int i = 0; i < _points.getSize(); i++) - delete _points[i]; - _points.removeAll(); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(POINT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(POINT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { - _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in WAYPOINTS definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WAYPOINTS {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - if (_scProp) - _scProp->saveAsText(buffer, indent + 2); - CBBase::saveAsText(buffer, indent + 2); - - for (int i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("waypoint-group"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { - if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; - - cleanup(); - - for (int i = 0; i < wpt->_points.getSize(); i++) { - int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); - int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); - - _points.add(new CBPoint(x + argX, y + argY)); - } - - _lastMimicScale = scale; - _lastMimicX = argX; - _lastMimicY = argY; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Ad/AdWaypointGroup.h b/engines/wintermute/Ad/AdWaypointGroup.h deleted file mode 100644 index 26a3c9a627..0000000000 --- a/engines/wintermute/Ad/AdWaypointGroup.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADWAYPOINTGROUP_H -#define WINTERMUTE_ADWAYPOINTGROUP_H - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { -class CBPoint; -class CAdWaypointGroup : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); - DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool _active; - CAdWaypointGroup(CBGame *inGame); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual ~CAdWaypointGroup(); - CBArray _points; - int _editorSelectedPoint; - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp deleted file mode 100644 index ca0dcddc28..0000000000 --- a/engines/wintermute/Base/BActiveRect.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - clipRect(); -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { - _owner = owner; - _frame = frame; - CBPlatform::setRect(&_rect, x, y, x + width, y + height); - _zoomX = zoomX; - _zoomY = zoomY; - _precise = precise; - _region = NULL; - _offsetX = _offsetY = 0; - clipRect(); -} - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { - _owner = owner; - _region = region; - CBPlatform::copyRect(&_rect, ®ion->_rect); - CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - clipRect(); - _offsetX = offsetX; - _offsetY = offsetY; -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBActiveRect::clipRect() { - Rect32 rc; - bool customViewport; - _gameRef->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = _gameRef->_renderer; - - if (!customViewport) { - rc.left -= Rend->_drawOffsetX; - rc.right -= Rend->_drawOffsetX; - rc.top -= Rend->_drawOffsetY; - rc.bottom -= Rend->_drawOffsetY; - } - - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - - CBPlatform::intersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BActiveRect.h b/engines/wintermute/Base/BActiveRect.h deleted file mode 100644 index d32b5bc368..0000000000 --- a/engines/wintermute/Base/BActiveRect.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H - -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { -public: - void clipRect(); - bool _precise; - float _zoomX; - float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; - int _offsetX; - int _offsetY; - Rect32 _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); - virtual ~CBActiveRect(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp deleted file mode 100644 index 63fddba489..0000000000 --- a/engines/wintermute/Base/BBase.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *gameOwner) { - _gameRef = gameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { - _gameRef = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *propName, const char *initVal) { - _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) - return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return initVal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return STATUS_FAILED; - - if (propValue == NULL) { - _editorProps.erase(propName); - } else { - _editorProps[propName] = propValue; - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBBase::parseEditorProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - - if (!_gameRef->_editorMode) - return STATUS_OK; - - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - - - setEditorProp(propName, propValue); - - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { - _editorPropsIter = _editorProps.begin(); - while (_editorPropsIter != _editorProps.end()) { - buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); - buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - buffer->putTextIndent(indent, "}\n\n"); - - _editorPropsIter++; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h deleted file mode 100644 index e8c87f1f9e..0000000000 --- a/engines/wintermute/Base/BBase.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace WinterMute { - -class CBGame; -class CBDynBuffer; - -class CBBase { -public: - bool _persistable; - bool setEditorProp(const char *propName, const char *propValue); - const char *getEditorProp(const char *propName, const char *initVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; - bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBBase(); - CBGame *_gameRef; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); - - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BDebugger.cpp b/engines/wintermute/Base/BDebugger.cpp deleted file mode 100644 index 4e83579d04..0000000000 --- a/engines/wintermute/Base/BDebugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BDebugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::initialize() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::shutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameInit() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameShutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameTick() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onLog(unsigned int errorCode, const char *text) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptInit(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool CBDebugger::attachClient(IWmeDebugClient *client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::detachClient(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::queryData(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int CBDebugger::getPropInt(const char *propName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double CBDebugger::getPropFloat(const char *propName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::getPropString(const char *propName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::getPropBool(const char *propName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, int propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, double propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, const char *propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, bool propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::continueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDebugger.h b/engines/wintermute/Base/BDebugger.h deleted file mode 100644 index 548519b0a0..0000000000 --- a/engines/wintermute/Base/BDebugger.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/wme_debugger.h" - -// TODO: The entire debugger should possibly be removed - -namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { -public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); - - // initialization - bool _enabled; - bool initialize(); - bool shutdown(); - - // internal interface - bool onGameInit(); - bool onGameShutdown(); - bool onGameTick(); - bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(CScScript *script); - bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - bool onScriptShutdown(CScScript *script); - bool onScriptChangeLine(CScScript *script, int line); - bool onScriptChangeScope(CScScript *script, CScValue *scope); - bool onScriptShutdownScope(CScScript *script, CScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - bool onVariableChangeValue(CScValue *var, CScValue *value); - - bool onScriptHitBreakpoint(CScScript *script); - - // IWmeDebugServer interface - virtual bool attachClient(IWmeDebugClient *client); - virtual bool detachClient(IWmeDebugClient *client); - virtual bool queryData(IWmeDebugClient *client); - - virtual int getPropInt(const char *propName); - virtual double getPropFloat(const char *propName); - virtual const char *getPropString(const char *propName); - virtual bool getPropBool(const char *propName); - - virtual bool setProp(const char *propName, int propValue); - virtual bool setProp(const char *propName, double propValue); - virtual bool setProp(const char *propName, const char *propValue); - virtual bool setProp(const char *propName, bool propValue); - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - - virtual bool addBreakpoint(const char *scriptFilename, int line); - virtual bool removeBreakpoint(const char *scriptFilename, int line); - - virtual bool continueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp deleted file mode 100644 index fec49e3c8f..0000000000 --- a/engines/wintermute/Base/BDynBuffer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = initSize; - _growBy = growBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::cleanup() { - if (_buffer) free(_buffer); - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::init(uint32 initSize) { - cleanup(); - - if (initSize == 0) initSize = _initSize; - - _buffer = (byte *)malloc(initSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); - return STATUS_FAILED; - } - - _realSize = initSize; - _initialized = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - while (_offset + size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return STATUS_FAILED; - } - } - - memcpy(_buffer + _offset, buffer, size); - _offset += size; - _size += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - if (_offset + size > _size) { - _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); - return STATUS_FAILED; - } - - memcpy(buffer, _buffer + _offset, size); - _offset += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putDWORD(uint32 val) { - putBytes((byte *)&val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getDWORD() { - uint32 ret; - getBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putString(const char *val) { - if (!val) putString("(null)"); - else { - putDWORD(strlen(val) + 1); - putBytes((byte *)val, strlen(val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::getString() { - uint32 len = getDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) return NULL; - else return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(const char *fmt, ...) { - va_list va; - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { - va_list va; - - putText("%*s", indent, ""); - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - putBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BDynBuffer.h b/engines/wintermute/Base/BDynBuffer.h deleted file mode 100644 index 6df01903c7..0000000000 --- a/engines/wintermute/Base/BDynBuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBDynBuffer : public CBBase { -public: - bool _initialized; - void putText(const char *fmt, ...); - void putTextIndent(int indent, const char *fmt, ...); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - void putString(const char *val); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 getSize(); - bool init(uint32 initSize = 0); - void cleanup(); - uint32 _size; - byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~CBDynBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void putTextForm(const char *format, va_list argptr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp deleted file mode 100644 index b99244af55..0000000000 --- a/engines/wintermute/Base/BFader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/util.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFader, false) - -////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::update() { - if (!_active) return STATUS_OK; - - int alphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) time = CBPlatform::getTime() - _startTime; - else time = _gameRef->_timer - _startTime; - - if (time >= _duration) _currentAlpha = _targetAlpha; - else { - _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); - } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean - - _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::display() { - if (!_active) return STATUS_OK; - - if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::deactivate() { - _active = false; - _ready = true; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(sourceColor); - _green = RGBCOLGetG(sourceColor); - _blue = RGBCOLGetB(sourceColor); - - _sourceAlpha = RGBCOLGetA(sourceColor); - _targetAlpha = 0; - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(targetColor); - _green = RGBCOLGetG(targetColor); - _blue = RGBCOLGetB(targetColor); - - //_sourceAlpha = 0; - _sourceAlpha = _currentAlpha; - _targetAlpha = RGBCOLGetA(targetColor); - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBFader::getCurrentColor() { - return BYTETORGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blue)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_green)); - persistMgr->transfer(TMEMBER(_red)); - persistMgr->transfer(TMEMBER(_sourceAlpha)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_targetAlpha)); - persistMgr->transfer(TMEMBER(_system)); - - if (_system && !persistMgr->_saving) _startTime = 0; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFader.h b/engines/wintermute/Base/BFader.h deleted file mode 100644 index 8c9d7d0a7c..0000000000 --- a/engines/wintermute/Base/BFader.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H - - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CBFader : public CBObject { -public: - bool _system; - uint32 getCurrentColor(); - bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); - bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - bool deactivate(); - bool display(); - bool update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFileEntry.cpp b/engines/wintermute/Base/BFileEntry.cpp deleted file mode 100644 index aca145dcf1..0000000000 --- a/engines/wintermute/Base/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFileEntry.h b/engines/wintermute/Base/BFileEntry.h deleted file mode 100644 index 660c9cfd1f..0000000000 --- a/engines/wintermute/Base/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp deleted file mode 100644 index a0ba77482d..0000000000 --- a/engines/wintermute/Base/BFileManager.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/Base/file/BDiskFile.h" -#include "engines/wintermute/Base/file/BSaveThumbFile.h" -#include "engines/wintermute/Base/BFileEntry.h" -#include "engines/wintermute/Base/file/BPkgFile.h" -#include "engines/wintermute/Base/BResources.h" -#include "engines/wintermute/Base/BPackage.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/dcpackage.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintermute.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/config-manager.h" -#include "common/system.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/savefile.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { - _basePath = NULL; - - initPaths(); - registerPackages(); -} - - -////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::cleanup() { - // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (int i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - - // close open files - for (int i = 0; i < _openFiles.size(); i++) { - delete _openFiles[i]; - } - _openFiles.clear(); - - - // delete packages - for (int i = 0; i < _packages.size(); i++) - delete _packages[i]; - _packages.clear(); - - delete[] _basePath; - _basePath = NULL; - - return STATUS_OK; -} - - - -#define MAX_FILE_SIZE 10000000 -////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; - - Common::SeekableReadStream *file = openFile(filename); - if (!file) { - if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); - return NULL; - } - - /* - if (File->GetSize() > MAX_FILE_SIZE) { - _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - - buffer = new byte[file->size() + 1]; - if (buffer == NULL) { - _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); - closeFile(file); - return NULL; - } - - if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); - closeFile(file); - delete [] buffer; - return NULL; - }; - - buffer[file->size()] = '\0'; - if (size != NULL) *size = file->size(); - closeFile(file); - - return buffer; -} - -Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::InSaveFile *file = saveMan->openForLoading(filename); - return file; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { - // TODO - warning("Implement SaveFile"); - - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - file->finalize(); - delete file; -#if 0 - RestoreCurrentDir(); - - CBUtils::CreatePath(filename, false); - - FILE *f = fopen(filename, "wb"); - if (!f) { - _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); - return STATUS_FAILED; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { - // unmount all non-local packages - for (int i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->close(); - } - - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; - - bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - - char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return STATUS_FAILED; - - strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); - - switch (type) { - case PATH_SINGLE: - _singlePaths.push_back(buffer); - break; - case PATH_PACKAGE: - _packagePaths.push_back(buffer); - break; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::reloadPaths() { - // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (int i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - return initPaths(); -} - - -#define TEMP_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::initPaths() { - restoreCurrentDir(); - - AnsiString pathList; - int numPaths; - - // single files paths - pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_SINGLE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_SINGLE, ".\\"); - - - // package files paths - addPath(PATH_PACKAGE, "./"); - - pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_PACKAGE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_PACKAGE, "data"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackages() { - restoreCurrentDir(); - - _gameRef->LOG(0, "Scanning packages..."); - debugC(kWinterMuteDebugFileAccess, "Scanning packages"); - - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, "*.dcp"); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - registerPackage((*it)->getName().c_str()); - } -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.getSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } -#endif - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { -// FILE *f = fopen(filename, "rb"); - Common::File *package = new Common::File(); - package->open(filename); - if (!package->isOpen()) { - _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return STATUS_OK; - } - - uint32 absoluteOffset = 0; - bool boundToExe = false; - - if (searchSignature) { - uint32 Offset; - if (!findPackageSignature(package, &Offset)) { - delete package; - return STATUS_OK; - } else { - package->seek(Offset, SEEK_SET); - absoluteOffset = Offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete package; - return STATUS_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = package->readUint32LE(); - dirOffset += absoluteOffset; - package->seek(dirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(_gameRef); - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = package->readByte(); - pkg->_name = new char[nameLength]; - package->read(pkg->_name, nameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.push_back(pkg); - - - // read file entries - uint32 NumFiles = package->readUint32LE(); - - for (uint32 j = 0; j < NumFiles; j++) { - char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; - - nameLength = package->readByte(); - name = new char[nameLength]; - package->read(name, nameLength); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - - CBPlatform::strupr(name); - - offset = package->readUint32LE(); - offset += absoluteOffset; - length = package->readUint32LE(); - compLength = package->readUint32LE(); - flags = package->readUint32LE(); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - timeDate1 = package->readUint32LE(); - timeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(_gameRef); - file->_package = pkg; - file->_offset = offset; - file->_length = length; - file->_compressedLength = compLength; - file->_flags = flags; - - _files[name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = offset; - _filesIter->_value->_length = length; - _filesIter->_value->_compressedLength = compLength; - _filesIter->_value->_flags = flags; - } - } - delete [] name; - } - } - - - delete package; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - - Common::File *ret = new Common::File(); - char filename[MAX_PATH_LENGTH]; - - for (int i = 0; i < _packagePaths.size(); i++) { - sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - } - - sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &name) { - restoreCurrentDir(); - - Common::File *ret = NULL; - char filename[MAX_PATH_LENGTH]; - - for (int i = 0; i < _singlePaths.size(); i++) { - sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { - restoreCurrentDir(); - - Common::File f; - bool found = false; - - for (int i = 0; i < _singlePaths.size(); i++) { - sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(filename.c_str()); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(fullname, filename.c_str()); - } - } - - return found; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { - char *upc_name = new char[strlen(filename.c_str()) + 1]; - strcpy(upc_name, filename.c_str()); - CBPlatform::strupr(upc_name); - - CBFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - delete [] upc_name; - - return ret; -} - -bool CBFileManager::hasFile(const Common::String &filename) { - //TODO: Do this in a much simpler fashion - Common::SeekableReadStream *stream = openFile(filename, true, false); - if (!stream) { - return false; - } - delete stream; - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) return NULL; - //_gameRef->LOG(0, "open file: %s", filename); - /*#ifdef __WIN32__ - if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); - } - } - #endif*/ - - Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.push_back(file); - return file; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (int i = 0; i < _openFiles.size(); i++) { - if (_openFiles[i] == File) { - delete _openFiles[i]; - _openFiles.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { - restoreCurrentDir(); - - Common::SeekableReadStream *ret = NULL; - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); - } - delete SaveThumbFile; - return ret; - } - - - - ret = openDiskFile(filename, this); - if (ret) return ret; - - ret = openPkgFile(filename, this); - if (ret) return ret; - - ret = CBResources::getFile(filename); - if (ret) return ret; - - warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::restoreCurrentDir() { - if (!_basePath) return STATUS_OK; - else { - /*if (!chdir(_basePath)) return STATUS_OK; - else return STATUS_FAILED;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::setBasePath(const Common::String &path) { - cleanup(); - - if (path.c_str()) { - _basePath = new char[path.size() + 1]; - strcpy(_basePath, path.c_str()); - } - - initPaths(); - registerPackages(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h deleted file mode 100644 index 53e55402cc..0000000000 --- a/engines/wintermute/Base/BFileManager.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H - -#include "engines/wintermute/Base/BFileEntry.h" -#include "common/archive.h" -#include "common/str.h" - -namespace Common { -class File; -} - -namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { -public: - bool findPackageSignature(Common::File *f, uint32 *offset); - bool cleanup(); - bool setBasePath(const Common::String &path); - bool restoreCurrentDir(); - char *_basePath; - bool getFullPath(const Common::String &filename, char *fullname); - Common::SeekableReadStream *openFileRaw(const Common::String &filename); - bool closeFile(Common::SeekableReadStream *File); - bool hasFile(const Common::String &filename); - Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openSingleFile(const Common::String &name); - Common::File *openPackage(const Common::String &name); - bool registerPackages(); - bool initPaths(); - bool reloadPaths(); - typedef enum { - PATH_PACKAGE, PATH_SINGLE - } TPathType; - bool addPath(TPathType type, const Common::String &path); - bool requestCD(int cd, char *packageFile, const char *filename); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); - Common::Array _singlePaths; - Common::Array _packagePaths; - Common::Array _packages; - Common::Array _openFiles; - - Common::HashMap _files; -private: - bool registerPackage(const Common::String &filename, bool searchSignature = false); - Common::HashMap::iterator _filesIter; - bool isValidPackage(const AnsiString &fileName) const; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp deleted file mode 100644 index 66a63c6a8f..0000000000 --- a/engines/wintermute/Base/BFrame.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFrame, false) - -////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { - delete _sound; - _sound = NULL; - - for (int i = 0; i < _subframes.getSize(); i++) - delete _subframes[i]; - _subframes.removeAll(); - - for (int i = 0; i < _applyEvent.getSize(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.removeAll(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - bool res; - - for (int i = 0; i < _subframes.getSize(); i++) { - res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) return res; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { - if (_sound && !muted) { - if (owner) owner->updateOneSound(_sound); - _sound->play(); - /* - if (_gameRef->_state == GAME_FROZEN) { - _sound->Pause(true); - } - */ - } - if (owner) { - for (int i = 0; i < _applyEvent.getSize(); i++) { - owner->applyEvent(_applyEvent[i]); - } - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(DELAY) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(MOVE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(SUBFRAME) -TOKEN_DEF(SOUND) -TOKEN_DEF(KEYFRAME) -TOKEN_DEF(DECORATION) -TOKEN_DEF(APPLY_EVENT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_EXPANDED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(KILL_SOUND) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(DELAY) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(MOVE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(SUBFRAME) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(KEYFRAME) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(APPLY_EVENT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_EXPANDED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(KILL_SOUND) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - int hotspotX = 0, hotspotY = 0; - bool custoTrans = false; - bool editorSelected = false; - bool is2DOnly = false; - bool is3DOnly = false; - bool decoration = false; - bool mirrorX = false; - bool mirrorY = false; - CBPlatform::setRectEmpty(&rect); - char *surface_file = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_DELAY: - parser.scanStr(params, "%d", &_delay); - break; - - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); - break; - - case TOKEN_MOVE: - parser.scanStr(params, "%d,%d", &_moveX, &_moveY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &is2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &is3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &mirrorY); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &editorSelected); - break; - - case TOKEN_EDITOR_EXPANDED: - parser.scanStr(params, "%b", &_editorExpanded); - break; - - case TOKEN_KILL_SOUND: - parser.scanStr(params, "%b", &_killSound); - break; - - case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(_gameRef); - if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { - delete subframe; - cmd = PARSERR_GENERIC; - } else _subframes.add(subframe); - } - break; - - case TOKEN_SOUND: { - if (_sound) { - delete _sound; - _sound = NULL; - } - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); - delete _sound; - _sound = NULL; - } - } - break; - - case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.add(Event); - } - break; - - case TOKEN_KEYFRAME: - parser.scanStr(params, "%b", &_keyframe); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &decoration); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FRAME definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading FRAME definition"); - return STATUS_FAILED; - } - - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (surface_file != NULL) { - if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); - - if (!sub->_surface) { - delete sub; - _gameRef->LOG(0, "Error loading SUBFRAME"); - return STATUS_FAILED; - } - - sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); - } - - if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); - else sub->_rect = rect; - - sub->_hotspotX = hotspotX; - sub->_hotspotY = hotspotY; - sub->_2DOnly = is2DOnly; - sub->_3DOnly = is3DOnly; - sub->_decoration = decoration; - sub->_mirrorX = mirrorX; - sub->_mirrorY = mirrorY; - - - sub->_editorSelected = editorSelected; - _subframes.insertAt(0, sub); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - CBPlatform::setRectEmpty(rect); - - Rect32 subRect; - - for (int i = 0; i < _subframes.getSize(); i++) { - _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, rect, &subRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "FRAME {\n"); - buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - - if (_moveX != 0 || _moveY != 0) - buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - - if (_sound && _sound->_soundFilename) - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - - buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - - if (_killSound) - buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - - if (_editorExpanded) - buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - - if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); - - for (int i = 1; i < _subframes.getSize(); i++) { - _subframes[i]->saveAsText(buffer, indent + 2); - } - - for (int i = 0; i < _applyEvent.getSize(); i++) { - buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - CBBase::saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - _applyEvent.persist(persistMgr); - persistMgr->transfer(TMEMBER(_delay)); - persistMgr->transfer(TMEMBER(_editorExpanded)); - persistMgr->transfer(TMEMBER(_keyframe)); - persistMgr->transfer(TMEMBER(_killSound)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_sound)); - _subframes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSound") == 0) { - stack->correctParams(0); - - if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); - else stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSound") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - delete _sound; - _sound = NULL; - - if (!val->isNULL()) { - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { - stack->pushBool(false); - delete _sound; - _sound = NULL; - } else stack->pushBool(true); - } else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSubframe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushNative(_subframes[index], true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); - } - } else { - CBSubFrame *sub = (CBSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.getSize(); i++) { - if (_subframes[i] == sub) { - delete _subframes[i]; - _subframes.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - sub->setDefaultRect(); - } - _subframes.add(sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertSubframe") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - } - - if (index >= _subframes.getSize()) _subframes.add(sub); - else _subframes.insertAt(index, sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.getSize()) { - script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushString(_applyEvent[index]); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - stack->pushNULL(); - return STATUS_OK; - } - } - _applyEvent.add(event); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete [] _applyEvent[i]; - _applyEvent.removeAt(i); - break; - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return CBScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("frame"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { - _scValue->setInt(_delay); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _scValue->setBool(_keyframe); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _scValue->setBool(_killSound); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _scValue->setInt(_moveX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _scValue->setInt(_moveY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumSubframes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return CBScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _keyframe = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _killSound = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _moveX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _moveY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return CBScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBFrame::scToString() { - return "[frame]"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BFrame.h b/engines/wintermute/Base/BFrame.h deleted file mode 100644 index 537471c953..0000000000 --- a/engines/wintermute/Base/BFrame.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H - -#include "engines/wintermute/Base/BScriptable.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { -public: - bool _killSound; - bool _keyframe; - bool oneTimeDisplay(CBObject *owner, bool muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; - bool _editorExpanded; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(CBDynBuffer *buffer, int indent); - int _moveY; - int _moveX; - uint32 _delay; - CBArray _subframes; - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - - CBFrame(CBGame *inGame); - virtual ~CBFrame(); - - CBArray _applyEvent; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp deleted file mode 100644 index d4f97cfdba..0000000000 --- a/engines/wintermute/Base/BGame.cpp +++ /dev/null @@ -1,4478 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/gfx/base_renderer.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BQuickMsg.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BSubFrame.h" - -#include "engines/wintermute/Base/BTransitionMgr.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BSaveThumbHelper.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/SXMath.h" -#include "engines/wintermute/video/VidPlayer.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/wintermute.h" -#include "common/savefile.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/keyboard.h" -#include "common/system.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBGame, true) - - -////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _fileManager = NULL; - _transMgr = NULL; - _debugMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _debugLogFile = NULL; - _debugDebugMode = false; - _debugAbsolutePathWarning = true; - _debugShowFPS = false; - - _systemFont = NULL; - _videoFont = NULL; - - _videoPlayer = NULL; - _theoraPlayer = NULL; - - _mainObject = NULL; - _activeObject = NULL; - - _fader = NULL; - - _offsetX = _offsetY = 0; - _offsetPercentX = _offsetPercentY = 0.0f; - - _subtitles = true; - _videoSubtitles = true; - - _timer = 0; - _timerDelta = 0; - _timerLast = 0; - - _liveTimer = 0; - _liveTimerDelta = 0; - _liveTimerLast = 0; - - _sequence = 0; - - _mousePos.x = _mousePos.y = 0; - _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; - _capturedObject = NULL; - - // FPS counters - _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - - _cursorNoninteractive = NULL; - - _useD3D = false; - - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - _settingsResWidth = 800; - _settingsResHeight = 600; - _settingsRequireAcceleration = false; - _settingsRequireSound = false; - _settingsTLMode = 0; - _settingsAllowWindowed = true; - _settingsGameFile = NULL; - _settingsAllowAdvanced = false; - _settingsAllowAccessTab = true; - _settingsAllowAboutTab = true; - _settingsAllowDesktopRes = false; - - _editorForceScripts = false; - _editorAlwaysRegister = false; - - _focusedWindow = NULL; - - _loadInProgress = false; - - _quitting = false; - _loading = false; - _scheduledLoadSlot = -1; - - _personalizedSave = false; - _compressedSavegames = true; - - _editorMode = false; - _doNotExpandStrings = false; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - _smartCache = false; - _surfaceGCCycleTime = 10000; - - _reportTextureFormat = false; - - _viewportSP = -1; - - _subtitlesSpeed = 70; - - _forceNonStreamedSounds = false; - - _thumbnailWidth = _thumbnailHeight = 0; - - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _richSavedGames = false; - _savedGameExt = NULL; - CBUtils::setString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _localSaveDir = NULL; - CBUtils::setString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - CBPlatform::setRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _autoSaveSlot = 999; - _cursorHidden = false; - -/*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else*/ - _touchInterface = false; - _constrainedMemory = false; -//#endif - -} - - -////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - getDebugMgr()->onGameShutdown(); - - _registry->writeBool("System", "LastRun", true); - - cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _saveLoadImage; - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _videoPlayer; - delete _theoraPlayer; - delete _soundMgr; - delete _debugMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _fileManager; - delete _registry; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _saveLoadImage = NULL; - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _videoPlayer = NULL; - _theoraPlayer = NULL; - _soundMgr = NULL; - _debugMgr = NULL; - - _renderer = NULL; - _fileManager = NULL; - _registry = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - CBPlatform::outputDebugString("--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::cleanup() { - delete _loadingIcon; - _loadingIcon = NULL; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete _music[i]; - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - unregisterObject(_fader); - _fader = NULL; - - for (int i = 0; i < _regObjects.getSize(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.removeAll(); - - _windows.removeAll(); // refs only - _focusedWindow = NULL; // ref only - - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (int i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->finish(); - } - _scripts.removeAll(); - - _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; - _quickMessages.removeAll(); - - _viewportStack.removeAll(); - _viewportSP = -1; - - delete[] _name; - delete[] _filename; - _name = NULL; - _filename = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize1() { - bool loaded = false; // Not really a loop, but a goto-replacement. - while (!loaded) { - _surfaceStorage = new CBSurfaceStorage(this); - if (_surfaceStorage == NULL) - break; - - _fontStorage = new CBFontStorage(this); - if (_fontStorage == NULL) - break; - - _fileManager = new CBFileManager(this); - if (_fileManager == NULL) - break; - - _soundMgr = new CBSoundMgr(this); - if (_soundMgr == NULL) - break; - - _debugMgr = new CBDebugger(this); - if (_debugMgr == NULL) - break; - - _mathClass = new CSXMath(this); - if (_mathClass == NULL) - break; - - _scEngine = new CScEngine(this); - if (_scEngine == NULL) - break; - - _videoPlayer = new CVidPlayer(this); - if (_videoPlayer == NULL) - break; - - _transMgr = new CBTransitionMgr(this); - if (_transMgr == NULL) - break; - - _keyboardState = new CBKeyboardState(this); - if (_keyboardState == NULL) - break; - - _fader = new CBFader(this); - if (_fader == NULL) - break; - registerObject(_fader); - - loaded = true; - } - if (loaded == true) { - return STATUS_OK; - } else { - delete _mathClass; - delete _keyboardState; - delete _transMgr; - delete _debugMgr; - delete _surfaceStorage; - delete _fontStorage; - delete _soundMgr; - delete _fileManager; - delete _scEngine; - delete _videoPlayer; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) return STATUS_FAILED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *filename) { - _debugDebugMode = true; - - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - #ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #endif*/ - int secs = g_system->getMillis() / 1000; - int hours = secs / 3600; - secs = secs % 3600; - int mins = secs / 60; - secs = secs % 60; - -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); -#endif - - LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - - AnsiString platform = CBPlatform::getPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { - if (_debugLogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_debugLogFile); - _debugLogFile = NULL; - } - _debugDebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::LOG(bool res, const char *fmt, ...) { - uint32 secs = g_system->getMillis() / 1000; - uint32 hours = secs / 3600; - secs = secs % 3600; - uint32 mins = secs / 60; - secs = secs % 60; - - char buff[512]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - // redirect to an engine's own callback - if (_engineLogCallback) { - _engineLogCallback(buff, res, _engineLogCallbackData); - } - if (_debugMgr) _debugMgr->onLog(res, buff); - - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - - //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fflush((FILE *)_debugLogFile); - - //QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { - _engineLogCallback = callback; - _engineLogCallbackData = data; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initLoop() { - _viewportSP = -1; - - _currentTime = CBPlatform::getTime(); - - getDebugMgr()->onGameTick(); - _renderer->initLoop(); - _soundMgr->initLoop(); - updateMusicCrossfade(); - - _surfaceStorage->initLoop(); - _fontStorage->initLoop(); - - - //_activeObject = NULL; - - // count FPS - _deltaTime = _currentTime - _lastTime; - _lastTime = _currentTime; - _fpsTime += _deltaTime; - - _liveTimerDelta = _liveTimer - _liveTimerLast; - _liveTimerLast = _liveTimer; - _liveTimer += MIN((uint32)1000, _deltaTime); - - if (_state != GAME_FROZEN) { - _timerDelta = _timer - _timerLast; - _timerLast = _timer; - _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; - - _framesRendered++; - if (_fpsTime > 1000) { - _fps = _framesRendered; - _framesRendered = 0; - _fpsTime = 0; - } - //_gameRef->LOG(0, "%d", _fps); - - getMousePos(&_mousePos); - - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - updateSounds(); - - if (_fader) _fader->update(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initInput() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBGame::getSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setOffset(int offsetX, int offsetY) { - _offsetX = offsetX; - _offsetY = offsetY; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) *offsetX = _offsetX; - if (offsetY != NULL) *offsetY = _offsetY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SYSTEM_FONT) -TOKEN_DEF(VIDEO_FONT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(ACTIVE_CURSOR) -TOKEN_DEF(NONINTERACTIVE_CURSOR) -TOKEN_DEF(STRING_TABLE) -TOKEN_DEF(RESOLUTION) -TOKEN_DEF(SETTINGS) -TOKEN_DEF(REQUIRE_3D_ACCELERATION) -TOKEN_DEF(REQUIRE_SOUND) -TOKEN_DEF(HWTL_MODE) -TOKEN_DEF(ALLOW_WINDOWED_MODE) -TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) -TOKEN_DEF(ALLOW_ABOUT_TAB) -TOKEN_DEF(ALLOW_ADVANCED) -TOKEN_DEF(ALLOW_DESKTOP_RES) -TOKEN_DEF(REGISTRY_PATH) -TOKEN_DEF(PERSONAL_SAVEGAMES) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(SUBTITLES_SPEED) -TOKEN_DEF(SUBTITLES) -TOKEN_DEF(VIDEO_SUBTITLES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(THUMBNAIL_WIDTH) -TOKEN_DEF(THUMBNAIL_HEIGHT) -TOKEN_DEF(INDICATOR_X) -TOKEN_DEF(INDICATOR_Y) -TOKEN_DEF(INDICATOR_WIDTH) -TOKEN_DEF(INDICATOR_HEIGHT) -TOKEN_DEF(INDICATOR_COLOR) -TOKEN_DEF(SAVE_IMAGE_X) -TOKEN_DEF(SAVE_IMAGE_Y) -TOKEN_DEF(SAVE_IMAGE) -TOKEN_DEF(LOAD_IMAGE_X) -TOKEN_DEF(LOAD_IMAGE_Y) -TOKEN_DEF(LOAD_IMAGE) -TOKEN_DEF(LOCAL_SAVE_DIR) -TOKEN_DEF(RICH_SAVED_GAMES) -TOKEN_DEF(SAVED_GAME_EXT) -TOKEN_DEF(GUID) -TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SYSTEM_FONT) - TOKEN_TABLE(VIDEO_FONT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(ACTIVE_CURSOR) - TOKEN_TABLE(NONINTERACTIVE_CURSOR) - TOKEN_TABLE(PERSONAL_SAVEGAMES) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(SUBTITLES_SPEED) - TOKEN_TABLE(SUBTITLES) - TOKEN_TABLE(VIDEO_SUBTITLES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(THUMBNAIL_WIDTH) - TOKEN_TABLE(THUMBNAIL_HEIGHT) - TOKEN_TABLE(INDICATOR_X) - TOKEN_TABLE(INDICATOR_Y) - TOKEN_TABLE(INDICATOR_WIDTH) - TOKEN_TABLE(INDICATOR_HEIGHT) - TOKEN_TABLE(INDICATOR_COLOR) - TOKEN_TABLE(SAVE_IMAGE_X) - TOKEN_TABLE(SAVE_IMAGE_Y) - TOKEN_TABLE(SAVE_IMAGE) - TOKEN_TABLE(LOAD_IMAGE_X) - TOKEN_TABLE(LOAD_IMAGE_Y) - TOKEN_TABLE(LOAD_IMAGE) - TOKEN_TABLE(LOCAL_SAVE_DIR) - TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { - _gameRef->LOG(0, "'GAME' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _systemFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - _videoFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ACTIVE_CURSOR: - delete _activeCursor; - _activeCursor = NULL; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { - delete _activeCursor; - _activeCursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NONINTERACTIVE_CURSOR: - delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PERSONAL_SAVEGAMES: - parser.scanStr((char *)params, "%b", &_personalizedSave); - break; - - case TOKEN_SUBTITLES: - parser.scanStr((char *)params, "%b", &_subtitles); - break; - - case TOKEN_SUBTITLES_SPEED: - parser.scanStr((char *)params, "%d", &_subtitlesSpeed); - break; - - case TOKEN_VIDEO_SUBTITLES: - parser.scanStr((char *)params, "%b", &_videoSubtitles); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_THUMBNAIL_WIDTH: - parser.scanStr((char *)params, "%d", &_thumbnailWidth); - break; - - case TOKEN_THUMBNAIL_HEIGHT: - parser.scanStr((char *)params, "%d", &_thumbnailHeight); - break; - - case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &_indicatorX); - break; - - case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &_indicatorY); - break; - - case TOKEN_INDICATOR_COLOR: { - int r, g, b, a; - parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = BYTETORGBA(r, g, b, a); - } - break; - - case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &_indicatorWidth); - break; - - case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &_indicatorHeight); - break; - - case TOKEN_SAVE_IMAGE: - CBUtils::setString(&_saveImageName, (char *)params); - break; - - case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &_saveImageX); - break; - - case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_saveImageY); - break; - - case TOKEN_LOAD_IMAGE: - CBUtils::setString(&_loadImageName, (char *)params); - break; - - case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &_loadImageX); - break; - - case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_loadImageY); - break; - - case TOKEN_LOCAL_SAVE_DIR: - CBUtils::setString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); - - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - LOG(0, stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - bool res = CBObject::scCallMethod(script, stack, thisStack, name); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // Msg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Msg") == 0) { - stack->correctParams(1); - quickMessage(stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RunScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RunScript") == 0) { - _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadStringTable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadStringTable") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - CScValue *Val = stack->pop(); - - bool ClearOld; - if (Val->isNULL()) ClearOld = true; - else ClearOld = Val->getBool(); - - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ValidObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidObject") == 0) { - stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *) obj)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - resetContent(); - stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->getNative(); - unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadWindow") == 0) { - stack->correctParams(1); - CUIWindow *win = new CUIWindow(_gameRef); - if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { - _windows.add(win); - registerObject(win); - stack->pushNative(win, true); - } else { - delete win; - win = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ExpandString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExpandString") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char *str = new char[strlen(val->getString()) + 1]; - strcpy(str, val->getString()); - _stringTable->expand(&str); - stack->pushString(str); - delete [] str; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayMusic / PlayMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); - else { - stack->correctParams(4); - channel = stack->pop()->getInt(); - } - - const char *filename = stack->pop()->getString(); - CScValue *valLooping = stack->pop(); - bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - - CScValue *valLoopStart = stack->pop(); - uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - - - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopMusic / StopMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic / PauseMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeMusic / ResumeMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusic / GetMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); - else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); - else stack->pushString(_music[channel]->_soundFilename); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicPosition / SetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - uint32 time = stack->pop()->getInt(); - - if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); - else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicPosition / GetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsMusicPlaying / IsMusicChannelPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { - int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else stack->pushBool(_music[channel]->isPlaying()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicVolume / SetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); - else stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicVolume / GetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolumePercent()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicCrossfade - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicCrossfade") == 0) { - stack->correctParams(4); - int channel1 = stack->pop()->getInt(0); - int channel2 = stack->pop()->getInt(0); - uint32 fadeLength = (uint32)stack->pop()->getInt(0); - bool swap = stack->pop()->getBool(true); - - if (_musicCrossfadeRunning) { - script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - stack->pushBool(false); - return STATUS_OK; - } - - _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = channel1; - _musicCrossfadeChannel2 = channel2; - _musicCrossfadeLength = fadeLength; - _musicCrossfadeSwap = swap; - - _musicCrossfadeRunning = true; - - stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundLength") == 0) { - stack->correctParams(1); - - int length = 0; - const char *filename = stack->pop()->getString(); - - CBSound *sound = new CBSound(_gameRef); - if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - length = sound->getLength(); - delete sound; - sound = NULL; - } - stack->pushInt(length); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMousePos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMousePos") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - x = MAX(x, 0); - x = MIN(x, _renderer->_width); - y = MAX(y, 0); - y = MIN(y, _renderer->_height); - Point32 p; - p.x = x + _renderer->_drawOffsetX; - p.y = y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LockMouseRect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LockMouseRect") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - if (right < left) CBUtils::swap(&left, &right); - if (bottom < top) CBUtils::swap(&top, &bottom); - - CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayVideo") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK; - // TODO: ADDVIDEO - */ - - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - - stack->correctParams(6); - const char *filename = stack->pop()->getString(); - warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->pop(); - int Type; - if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) - Type = (int)VID_PLAY_STRETCH; - - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK;*/ - // TODO: ADDVIDEO - - stack->correctParams(7); - const char *filename = stack->pop()->getString(); - CScValue *valType = stack->pop(); - int type; - if (valType->isNULL()) - type = (int)VID_PLAY_STRETCH; - else type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool freezeMusic = stack->pop()->getBool(true); - bool dropFrames = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; - - delete _theoraPlayer; - _theoraPlayer = new CVidTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { - _theoraPlayer->_dontDropFrames = !dropFrames; - if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else { - stack->pushBool(false); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QuitGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QuitGame") == 0) { - stack->correctParams(0); - stack->pushNULL(); - _quitting = true; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int val = stack->pop()->getInt(); - _registry->writeInt("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *val = stack->pop()->getString(); - _registry->writeString("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->readString("PrivateSettings", key, initVal); - stack->pushString(val.c_str()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveGame") == 0) { - stack->correctParams(3); - int slot = stack->pop()->getInt(); - const char *xdesc = stack->pop()->getString(); - bool quick = stack->pop()->getBool(false); - - char *desc = new char[strlen(xdesc) + 1]; - strcpy(desc, xdesc); - stack->pushBool(true); - if (DID_FAIL(SaveGame(slot, desc, quick))) { - stack->pop(); - stack->pushBool(false); - } - delete [] desc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadGame") == 0) { - stack->correctParams(1); - _scheduledLoadSlot = stack->pop()->getInt(); - _loading = true; - stack->pushBool(false); - script->sleep(0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSaveSlotUsed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSaveSlotUsed") == 0) { - stack->correctParams(1); - int Slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(Slot)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSaveSlotDescription - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSaveSlotDescription") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - char desc[512]; - desc[0] = '\0'; - getSaveSlotDescription(slot, desc); - stack->pushString(desc); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - emptySaveSlot(slot); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSFXVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMusicVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMasterVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSFXVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMusicVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMasterVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getMasterVolumePercent()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetActiveCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursor") == 0) { - stack->correctParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); - else stack->pushString(_activeCursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursorObject") == 0) { - stack->correctParams(0); - if (!_activeCursor) stack->pushNULL(); - else stack->pushNative(_activeCursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveActiveCursor") == 0) { - stack->correctParams(0); - delete _activeCursor; - _activeCursor = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasActiveCursor") == 0) { - stack->correctParams(0); - - if (_activeCursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FileExists - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FileExists") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - // TODO: Replace with fileExists - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) stack->pushBool(false); - else { - _fileManager->closeFile(file); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Screenshot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Screenshot") == 0) { - stack->correctParams(1); - char filename[MAX_PATH_LENGTH]; - - CScValue *Val = stack->pop(); - - warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO - int fileNum = 0; - - while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); - if (!Common::File::exists(filename)) - break; - fileNum++; - } - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenshotEx - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenshotEx") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - int sizeX = stack->pop()->getInt(_renderer->_width); - int sizeY = stack->pop()->getInt(_renderer->_height); - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIWindow *win = new CUIWindow(_gameRef); - _windows.add(win); - registerObject(win); - if (!val->isNULL()) win->setName(val->getString()); - stack->pushNative(win, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - CBObject *obj = (CBObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == obj) { - unregisterObject(_windows[i]); - stack->pushBool(true); - return STATUS_OK; - } - } - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenDocument - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenDocument") == 0) { - stack->correctParams(0); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_DumpClassRegistry - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { - stack->correctParams(0); - DEBUG_DumpClassRegistry(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetLoadingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetLoadingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _loadImageX = stack->pop()->getInt(); - _loadImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; - } else { - CBUtils::setString(&_loadImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSavingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _saveImageX = stack->pop()->getInt(); - _saveImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; - } else { - CBUtils::setString(&_saveImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetWaitCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveWaitCursor") == 0) { - stack->correctParams(0); - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursor") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursorObject") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive) stack->pushNULL(); - else stack->pushNative(_cursorNoninteractive, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearScriptCache - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearScriptCache") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayLoadingIcon") == 0) { - stack->correctParams(4); - - const char *filename = stack->pop()->getString(); - _loadingIconX = stack->pop()->getInt(); - _loadingIconY = stack->pop()->getInt(); - _loadingIconPersistent = stack->pop()->getBool(); - - delete _loadingIcon; - _loadingIcon = new CBSprite(this); - if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { - delete _loadingIcon; - _loadingIcon = NULL; - } else { - displayContent(false, true); - _gameRef->_renderer->flip(); - _gameRef->_renderer->initLoop(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideLoadingIcon") == 0) { - stack->correctParams(0); - delete _loadingIcon; - _loadingIcon = NULL; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DumpTextureStats - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DumpTextureStats") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _renderer->dumpData(filename); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccOutputText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccOutputText") == 0) { - stack->correctParams(2); - /* const char *Str = */ - stack->pop()->getString(); - /* int Type = */ - stack->pop()->getInt(); - // do nothing - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StoreSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StoreSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); - if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFileChecksum - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFileChecksum") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool asHex = stack->pop()->getBool(false); - - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (file) { - crc remainder = crc_initialize(); - byte buf[1024]; - int bytesRead = 0; - - while (bytesRead < file->size()) { - int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); - bytesRead += file->read(buf, bufSize); - - for (int i = 0; i < bufSize; i++) { - remainder = crc_process_byte(buf[i], remainder); - } - } - crc checksum = crc_finalize(remainder); - - if (asHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - stack->pushString(Hex); - } else - stack->pushInt(checksum); - - _fileManager->closeFile(file); - file = NULL; - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EnableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EnableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->enableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->disableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ShowStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ShowStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Hwnd (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { - _scValue->setInt((int)_renderer->_window); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { - _scValue->setInt((int)_timer); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowsTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::getTime()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowedMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { - _scValue->setBool(_renderer->_windowed); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _scValue->setInt(_mousePos.x); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _scValue->setInt(_mousePos.y); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - _scValue->setNative(_mainObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ActiveObject (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { - _scValue->setNative(_activeObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenWidth (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { - _scValue->setInt(_renderer->_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenHeight (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { - _scValue->setInt(_renderer->_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - _scValue->setBool(_interactive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DebugMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { - _scValue->setBool(_debugDebugMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundAvailable (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { - _scValue->setBool(_soundMgr->_soundAvailable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getMasterVolumePercent()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyboard (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->setNative(_keyboardState, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _scValue->setBool(_subtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _scValue->setInt(_subtitlesSpeed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _scValue->setBool(_videoSubtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FPS (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { - _scValue->setInt(_fps); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AcceleratedMode / Accelerated (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { - _scValue->setBool(_useD3D); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - _scValue->setInt(_textEncoding); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _scValue->setBool(_textRTL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _scValue->setInt(_soundBufferSizeSec); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _scValue->setBool(_suspendedRendering); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _scValue->setBool(_suppressScriptErrors); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // Frozen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { - _scValue->setBool(_state == GAME_FROZEN); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSTalk - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSCaptions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSKeypress - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardCursorSkip - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardPause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _scValue->setBool(_autorunDisabled); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveDirectory (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = getDataDir(); - _scValue->setString(dataDir.c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _scValue->setBool(_autoSaveOnExit); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _scValue->setInt(_autoSaveSlot); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _scValue->setBool(_cursorHidden); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Platform (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::getPlatformName().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DeviceType (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { - _scValue->setString(getDeviceType().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MostRecentSaveSlot (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Store (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { - _scValue->setNULL(); - error("Request for a SXStore-object, which is not supported by ScummVM"); - - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - bool res = CBObject::scSetProperty(name, value); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->getNative(); - if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - setInteractive(value->getBool()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _subtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->getInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _textRTL = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = value->getInt(); - _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBGame::scToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; - - // update - for (int i = 0; i < _quickMessages.getSize(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.removeAt(i); - i--; - } - } - - int posY = 20; - - // display - for (int i = 0; i < _quickMessages.getSize(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); - posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); - } - return STATUS_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessage(const char *text) { - if (_quickMessages.getSize() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.removeAt(0); - } - _quickMessages.add(new CBQuickMsg(_gameRef, text)); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - quickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::registerObject(CBObject *object) { - _regObjects.add(object); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unregisterObject(CBObject *object) { - if (!object) return STATUS_OK; - - // is it a window? - for (int i = 0; i < _windows.getSize(); i++) { - if ((CBObject *)_windows[i] == object) { - _windows.removeAt(i); - - // get new focused window - if (_focusedWindow == object) _focusedWindow = NULL; - - break; - } - } - - // is it active object? - if (_activeObject == object) _activeObject = NULL; - - // is it main object? - if (_mainObject == object) _mainObject = NULL; - - // destroy object - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) { - _regObjects.removeAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); - delete object; - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::invalidateValues(void *value, void *data) { - CScValue *val = (CScValue *)value; - if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { - ((CBScriptable *)data)->_refCount++; - } - val->setNative(NULL); - val->setNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::validObject(CBObject *object) { - if (!object) return false; - if (object == this) return true; - - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *thisObj; - - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // String - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "String") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXString(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MemBuffer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MemBuffer") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // File - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "File") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXFile(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Date - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Date") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXDate(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Array - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Array") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXArray(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Object - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Object") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXObject(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Sleep - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sleep") == 0) { - stack->correctParams(1); - - script->sleep((uint32)stack->pop()->getInt()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // WaitFor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WaitFor") == 0) { - stack->correctParams(1); - - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Random - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Random") == 0) { - stack->correctParams(2); - - int from = stack->pop()->getInt(); - int to = stack->pop()->getInt(); - - stack->pushInt(CBUtils::randomInt(from, to)); - } - - ////////////////////////////////////////////////////////////////////////// - // SetScriptTimeSlice - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetScriptTimeSlice") == 0) { - stack->correctParams(1); - - script->_timeSlice = (uint32)stack->pop()->getInt(); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeRGBA / MakeRGB / RGB - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { - stack->correctParams(4); - int r = stack->pop()->getInt(); - int g = stack->pop()->getInt(); - int b = stack->pop()->getInt(); - int a; - CScValue *val = stack->pop(); - if (val->isNULL()) a = 255; - else a = val->getInt(); - - stack->pushInt(BYTETORGBA(r, g, b, a)); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeHSL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeHSL") == 0) { - stack->correctParams(3); - int h = stack->pop()->getInt(); - int s = stack->pop()->getInt(); - int l = stack->pop()->getInt(); - - stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetRValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetR(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetGValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetG(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetBValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetB(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetAValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetA(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetHValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(H); - } - - ////////////////////////////////////////////////////////////////////////// - // GetSValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(S); - } - - ////////////////////////////////////////////////////////////////////////// - // GetLValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Debug") == 0) { - stack->correctParams(0); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); - script->sleep(0); - } - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // ToString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToString") == 0) { - stack->correctParams(1); - const char *str = stack->pop()->getString(); - char *str2 = new char[strlen(str) + 1]; - strcpy(str2, str); - stack->pushString(str2); - delete [] str2; - } - - ////////////////////////////////////////////////////////////////////////// - // ToInt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToInt") == 0) { - stack->correctParams(1); - int val = stack->pop()->getInt(); - stack->pushInt(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToFloat") == 0) { - stack->correctParams(1); - double val = stack->pop()->getFloat(); - stack->pushFloat(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - stack->pushBool(val); - } - - ////////////////////////////////////////////////////////////////////////// - // failure - else { - script->runtimeError("Call to undefined function '%s'. Ignored.", name); - stack->correctParams(0); - stack->pushNULL(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::showCursor() { - if (_cursorHidden) return STATUS_OK; - - if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); - } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; - else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); - else if (_cursor) return drawCursor(_cursor); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - LOG(0, "Saving game '%s'...", filename); - - _gameRef->applyEvent("BeforeSave", true); - - bool ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; - - _registry->writeInt("System", "MostRecentSaveSlot", slot); - -save_finish: // TODO: Remove gotos - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - return loadGame(filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(const char *filename) { - LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->onGameShutdown(); - - bool ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - _debugAbsolutePathWarning = false; - if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - - //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; - - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - - getDebugMgr()->onGameInit(); - -load_finish: - _debugAbsolutePathWarning = true; - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::initAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); - - _scEngine->refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->createRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSubFrame(void *subframe, void *data) { - ((CBSubFrame *)subframe)->setSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSound(void *sound, void *data) { - ((CBSound *)sound)->setSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadFont(void *font, void *data) { - ((CBFont *)font)->afterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadScript(void *script, void *data) { - ((CScScript *)script)->afterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayWindows(bool inGame) { - bool res; - - // did we lose focus? focus topmost window - if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { - - res = _windows[i]->display(); - if (DID_FAIL(res)) return res; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - delete _music[channel]; - _music[channel] = NULL; - - _music[channel] = new CBSound(_gameRef); - if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - if (_musicStartTime[channel]) { - _music[channel]->setPositionTime(_musicStartTime[channel]); - _musicStartTime[channel] = 0; - } - if (loopStart) _music[channel]->setLoopStart(loopStart); - return _music[channel]->play(looping); - } else { - delete _music[channel]; - _music[channel] = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - _music[channel]->stop(); - delete _music[channel]; - _music[channel] = NULL; - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pauseMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resumeMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setMusicStartTime(int channel, uint32 time) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadSettings(const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SETTINGS) - TOKEN_TABLE(GAME) - TOKEN_TABLE(STRING_TABLE) - TOKEN_TABLE(RESOLUTION) - TOKEN_TABLE(REQUIRE_3D_ACCELERATION) - TOKEN_TABLE(REQUIRE_SOUND) - TOKEN_TABLE(HWTL_MODE) - TOKEN_TABLE(ALLOW_WINDOWED_MODE) - TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) - TOKEN_TABLE(ALLOW_ABOUT_TAB) - TOKEN_TABLE(ALLOW_ADVANCED) - TOKEN_TABLE(ALLOW_DESKTOP_RES) - TOKEN_TABLE(REGISTRY_PATH) - TOKEN_TABLE(RICH_SAVED_GAMES) - TOKEN_TABLE(SAVED_GAME_EXT) - TOKEN_TABLE(GUID) - TOKEN_TABLE_END - - - byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); - if (origBuffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret = STATUS_OK; - - byte *buffer = origBuffer; - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return STATUS_FAILED; - } - buffer = params; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - delete[] _settingsGameFile; - _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); - break; - - case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_RESOLUTION: - parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); - break; - - case TOKEN_REQUIRE_3D_ACCELERATION: - parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); - break; - - case TOKEN_REQUIRE_SOUND: - parser.scanStr((char *)params, "%b", &_settingsRequireSound); - break; - - case TOKEN_HWTL_MODE: - parser.scanStr((char *)params, "%d", &_settingsTLMode); - break; - - case TOKEN_ALLOW_WINDOWED_MODE: - parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); - break; - - case TOKEN_ALLOW_DESKTOP_RES: - parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); - break; - - case TOKEN_ALLOW_ADVANCED: - parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); - break; - - case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); - break; - - case TOKEN_ALLOW_ABOUT_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); - break; - - case TOKEN_REGISTRY_PATH: - _registry->setBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - CBUtils::setString(&_savedGameExt, (char *)params); - break; - - case TOKEN_GUID: - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); - ret = STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading game settings '%s'", filename); - ret = STATUS_FAILED; - } - - _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; - - delete [] origBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) - cleanup(); - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_activeObject)); - persistMgr->transfer(TMEMBER(_capturedObject)); - persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_doNotExpandStrings)); - persistMgr->transfer(TMEMBER(_editorMode)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_freezeLevel)); - persistMgr->transfer(TMEMBER(_focusedWindow)); - persistMgr->transfer(TMEMBER(_fontStorage)); - persistMgr->transfer(TMEMBER(_interactive)); - persistMgr->transfer(TMEMBER(_keyboardState)); - persistMgr->transfer(TMEMBER(_lastTime)); - persistMgr->transfer(TMEMBER(_mainObject)); - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - persistMgr->transfer(TMEMBER(_music[i])); - persistMgr->transfer(TMEMBER(_musicStartTime[i])); - } - - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_offsetPercentX)); - persistMgr->transfer(TMEMBER(_offsetPercentY)); - - persistMgr->transfer(TMEMBER(_origInteractive)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_personalizedSave)); - persistMgr->transfer(TMEMBER(_quitting)); - - _regObjects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scEngine)); - //persistMgr->transfer(TMEMBER(_soundMgr)); - persistMgr->transfer(TMEMBER_INT(_state)); - //persistMgr->transfer(TMEMBER(_surfaceStorage)); - persistMgr->transfer(TMEMBER(_subtitles)); - persistMgr->transfer(TMEMBER(_subtitlesSpeed)); - persistMgr->transfer(TMEMBER(_systemFont)); - persistMgr->transfer(TMEMBER(_videoFont)); - persistMgr->transfer(TMEMBER(_videoSubtitles)); - - persistMgr->transfer(TMEMBER(_timer)); - persistMgr->transfer(TMEMBER(_timerDelta)); - persistMgr->transfer(TMEMBER(_timerLast)); - - persistMgr->transfer(TMEMBER(_liveTimer)); - persistMgr->transfer(TMEMBER(_liveTimerDelta)); - persistMgr->transfer(TMEMBER(_liveTimerLast)); - - persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); - persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); - persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); - persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); - - persistMgr->transfer(TMEMBER_INT(_textEncoding)); - persistMgr->transfer(TMEMBER(_textRTL)); - - persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); - persistMgr->transfer(TMEMBER(_suspendedRendering)); - - persistMgr->transfer(TMEMBER(_mouseLockRect)); - - _windows.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_suppressScriptErrors)); - persistMgr->transfer(TMEMBER(_autorunDisabled)); - - persistMgr->transfer(TMEMBER(_autoSaveOnExit)); - persistMgr->transfer(TMEMBER(_autoSaveSlot)); - persistMgr->transfer(TMEMBER(_cursorHidden)); - - if (!persistMgr->_saving) - _quitting = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::focusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; - - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == Window) { - if (i < _windows.getSize() - 1) { - _windows.removeAt(i); - _windows.add(Window); - - _gameRef->_focusedWindow = Window; - } - - if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return focusWindow(Prev); - else return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::freeze(bool includingMusic) { - if (_freezeLevel == 0) { - _scEngine->pauseAll(); - _soundMgr->pauseAll(includingMusic); - _origState = _state; - _origInteractive = _interactive; - _interactive = true; - } - _state = GAME_FROZEN; - _freezeLevel++; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unfreeze() { - if (_freezeLevel == 0) return STATUS_OK; - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->resumeAll(); - _soundMgr->resumeAll(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleKeypress(Common::Event *event, bool printable) { - if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) - stopVideo(); - return true; - } - - if (event->type == Common::EVENT_QUIT) { - onWindowClose(); - return true; - } - - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->switchFullscreen(); - return true; - } - - - _keyboardState->handleKeyPress(event); - _keyboardState->readKey(event); -// TODO - - if (_focusedWindow) { - if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { - /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) - _gameRef->_focusedWindow->applyEvent("Keypress"); - else - applyEvent("Keypress"); - /*}*/ - } - return true; - } else { /*if (event->type != SDL_TEXTINPUT)*/ - applyEvent("Keypress"); - return true; - } //else return true; - - return false; -} - -void CBGame::handleKeyRelease(Common::Event *event) { - _keyboardState->handleKeyRelease(event); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleMouseWheel(int Delta) { - bool handled = false; - if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); - - if (!handled) { - if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); - handled = true; - } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); - handled = true; - } - - } - } - - if (!handled) { - if (Delta < 0) { - applyEvent("MouseWheelDown"); - } else { - applyEvent("MouseWheelUp"); - } - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) *verMajor = DCGF_VER_MAJOR; - if (verMinor) *verMinor = DCGF_VER_MINOR; - - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setWindowTitle() { - if (_renderer) { - char title[512]; - strcpy(title, _caption[0]); - if (title[0] != '\0') strcat(title, " - "); - strcat(title, "WME Lite"); - - - Utf8String utf8Title; - if (_textEncoding == TEXT_UTF8) { - utf8Title = Utf8String(title); - } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); - utf8Title = Utf8String(title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } -#if 0 - CBRenderOSystem *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - Common::String filename = pm->getFilenameForSlot(slot); - delete pm; - strcpy(buffer, filename.c_str()); - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDataDir() { - AnsiString userDir = PathUtil::getUserDirectory(); - AnsiString baseDir = _registry->getBasePath(); - return PathUtil::combine(userDir, baseDir); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotDescription(int slot, char *buffer) { - buffer[0] = '\0'; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(filename))) { - _debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - - _debugAbsolutePathWarning = true; - strcpy(buffer, pm->_savedDescription); - delete pm; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!File) return false; - delete File; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::emptySaveSlot(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(this); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); - delete pm; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setActiveObject(CBObject *obj) { - // not-active when game is frozen - if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { - obj = NULL; - } - - if (obj == _activeObject) return STATUS_OK; - - if (_activeObject) _activeObject->applyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); - _activeObject = obj; - if (_activeObject) { - _activeObject->applyEvent("MouseEntry"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pushViewport(CBViewport *viewport) { - _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); - else _viewportStack[_viewportSP] = viewport; - - _renderer->setViewport(viewport->getRect()); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::popViewport() { - _viewportSP--; - if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); - - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) return STATUS_FAILED; - else { - if (_viewportSP >= 0) { - CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) *custom = true; - } else { - CBPlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (custom) *custom = false; - } - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { - if (_viewportSP >= 0) { - if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; - if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; - } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setInteractive(bool state) { - _interactive = state; - if (_transMgr) _transMgr->_origInteractive = state; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::resetMousePos() { - Common::Point p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContent(bool doUpdate, bool displayAll) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContentSimple() { - // fill black - _renderer->fill(0, 0, 0); - if (_indicatorDisplay) displayIndicator(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayIndicator() { - if (_saveLoadImage) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; - _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) - _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - - _renderer->setup2D(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::updateMusicCrossfade() { - /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - - if (!_musicCrossfadeRunning) return STATUS_OK; - if (_state == GAME_FROZEN) return STATUS_OK; - - if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - - if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); - if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); - - uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; - - if (currentTime >= _musicCrossfadeLength) { - _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->setVolumePercent(100); - - _music[_musicCrossfadeChannel1]->stop(); - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent(100); - - - if (_musicCrossfadeSwap) { - // swap channels - CBSound *dummy = _music[_musicCrossfadeChannel1]; - int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; - - _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; - _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - - _music[_musicCrossfadeChannel2] = dummy; - _musicStartTime[_musicCrossfadeChannel2] = dummyInt; - } - } else { - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - - //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resetContent() { - _scEngine->clearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { - warning("DEBUG_DumpClassRegistry - untested"); - Common::DumpFile *f = new Common::DumpFile; - f->open("zz_class_reg_dump.log"); - - CSysClassRegistry::getInstance()->dumpClasses(f); - - f->close(); - delete f; - _gameRef->quickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->invalidateDeviceObjects(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->restoreDeviceObjects(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setWaitCursor(const char *filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) return true; - if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopVideo() { - if (_videoPlayer->isPlaying()) _videoPlayer->stop(); - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - _theoraPlayer->stop(); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::drawCursor(CBSprite *cursor) { - if (!cursor) return STATUS_FAILED; - if (cursor != _lastCursor) { - cursor->reset(); - _lastCursor = cursor; - } - return cursor->draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -bool CBGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return STATUS_OK; - - _renderer->_active = activate; - - if (refreshMouse) { - Point32 p; - getMousePos(&p); - setActiveObject(_renderer->getObjectAt(p.x, p.y)); - } - - if (activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _capturedObject = _activeObject; - _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->initLoop(); - displayContent(false, true); - displayDebugInfo(); - _renderer->windowedBlt(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onWindowClose() { - if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); - return STATUS_OK; - } else return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayDebugInfo() { - char str[100]; - - if (_debugShowFPS) { - sprintf(str, "FPS: %d", _gameRef->_fps); - _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); - } - - if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) - sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else - sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); - - strcat(str, " ("); - strcat(str, _renderer->getName()); - strcat(str, ")"); - _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - - _renderer->displayDebugInfo(); - - int scrTotal, scrRunning, scrWaiting, scrPersistent; - scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); - _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - - - sprintf(str, "Timer: %d", _timer); - _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); - - sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); - - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); - return _debugMgr; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Point32 *pos) { - CBPlatform::getCursorPos(pos); - - pos->x -= _renderer->_drawOffsetX; - pos->y -= _renderer->_drawOffsetY; - - /* - // Windows can squish maximized window if it's larger than desktop - // so we need to modify mouse position appropriately (tnx mRax) - if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { - Common::Rect rc; - ::GetClientRect(_renderer->_window, &rc); - Pos->x *= _gameRef->_renderer->_realWidth; - Pos->x /= (rc.right - rc.left); - Pos->y *= _gameRef->_renderer->_realHeight; - Pos->y /= (rc.bottom - rc.top); - } - */ - - if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { - pos->x = MAX(_mouseLockRect.left, pos->x); - pos->y = MAX(_mouseLockRect.top, pos->y); - - pos->x = MIN(_mouseLockRect.right, pos->x); - pos->y = MIN(_mouseLockRect.bottom, pos->y); - - Point32 newPos = *pos; - - newPos.x += _renderer->_drawOffsetX; - newPos.y += _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(newPos.x, newPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::miniUpdate() { - if (!_miniUpdateEnabled) return STATUS_OK; - - if (CBPlatform::getTime() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::getTime(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isLeftDoubleClick() { - return isDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isRightDoubleClick() { - return isDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - - Point32 pos; - CBPlatform::getCursorPos(&pos); - - int moveX = abs(pos.x - _lastClick[buttonIndex].posX); - int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - - - if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = CBPlatform::getTime(); - _lastClick[buttonIndex].posX = pos.x; - _lastClick[buttonIndex].posY = pos.y; - return false; - } else { - _lastClick[buttonIndex].time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::autoSaveOnExit() { - _soundMgr->saveSettings(); - _registry->saveValues(); - - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; - - SaveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::addMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDeviceType() const { - return "computer"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h deleted file mode 100644 index 1a0e4efb09..0000000000 --- a/engines/wintermute/Base/BGame.h +++ /dev/null @@ -1,391 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H - -#include "engines/wintermute/Base/BDebugger.h" -#include "engines/wintermute/Base/gfx/base_renderer.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/math/Rect32.h" -#include "common/events.h" - -namespace WinterMute { - -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); - -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXMath; -class CBKeyboardState; -class CVidPlayer; -class CVidTheoraPlayer; - -#define NUM_MUSIC_CHANNELS 5 - -class CBGame: public CBObject { -public: - DECLARE_PERSISTENT(CBGame, CBObject) - - virtual bool onScriptShutdown(CScScript *script); - - virtual bool onActivate(bool activate, bool refreshMouse); - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - virtual bool onMouseMiddleDown(); - virtual bool onMouseMiddleUp(); - virtual bool onPaint(); - virtual bool onWindowClose(); - - bool isLeftDoubleClick(); - bool isRightDoubleClick(); - - bool _autorunDisabled; - - uint32 _lastMiniUpdate; - bool _miniUpdateEnabled; - - virtual bool miniUpdate(); - - void getMousePos(Point32 *Pos); - Rect32 _mouseLockRect; - - bool _shuttingDown; - - virtual bool displayDebugInfo(); - bool _debugShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - CBSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - virtual bool resetContent(); - - void DEBUG_DumpClassRegistry(); - bool setWaitCursor(const char *filename); - char *_localSaveDir; - bool _saveDirChecked; - - int _indicatorProgress; -protected: - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - CBSurface *_saveLoadImage; - bool displayIndicator(); - - bool _reportTextureFormat; -public: - int _thumbnailWidth; - int _thumbnailHeight; - - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; - bool _editorMode; - - bool _doNotExpandStrings; - void getOffset(int *offsetX, int *offsetY); - void setOffset(int offsetX, int offsetY); - int getSequence(); - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - CBObject *_mainObject; - - bool initInput(); - bool initLoop(); - uint32 _currentTime; - uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; - bool initialize1(); - bool initialize2(); - bool initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *getDebugMgr(); - - void LOG(bool res, const char *fmt, ...); - - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); - - virtual ~CBGame(); - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *filename = NULL); - bool _debugDebugMode; - bool _debugAbsolutePathWarning; - - void *_debugLogFile; - int _sequence; - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; - - int _viewportSP; - - CBStringTable *_stringTable; - int _settingsResWidth; - int _settingsResHeight; - char *_settingsGameFile; - bool _suppressScriptErrors; - bool _mouseLeftDown; -protected: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - CBFader *_fader; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); -public: - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - // compatibility bits - bool _compatKillMethodThreads; - -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; -public: - const char* getGameId() { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } - uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; - int _scheduledLoadSlot; - bool _loading; - bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); - void setWindowTitle(); - virtual bool handleMouseWheel(int delta); - bool _quitting; - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual void handleKeyRelease(Common::Event *event); -protected: - int _freezeLevel; -public: - bool unfreeze(); - bool freeze(bool includingMusic = true); - bool focusWindow(CUIWindow *window); - CVidPlayer *_videoPlayer; - CVidTheoraPlayer *_theoraPlayer; - bool _loadInProgress; - CUIWindow *_focusedWindow; - bool _editorForceScripts; -protected: - static void afterLoadRegion(void *region, void *data); - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); -public: - static void invalidateValues(void *value, void *data); - - bool loadSettings(const char *filename); - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; - bool displayWindows(bool inGame = false); - CBRegistry *_registry; - bool _useD3D; - virtual bool cleanup(); - virtual bool loadGame(int slot); - virtual bool loadGame(const char *filename); - virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); - virtual bool showCursor(); - - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - CBObject *_capturedObject; - Point32 _mousePos; - bool validObject(CBObject *object); - bool unregisterObject(CBObject *object); - bool registerObject(CBObject *object); - void quickMessage(const char *text); - void quickMessageForm(char *fmt, ...); - bool displayQuickMsg(); - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - - CBArray _regObjects; -public: - virtual bool displayContent(bool update = true, bool displayAll = false); - virtual bool displayContentSimple(); - bool _forceNonStreamedSounds; - void resetMousePos(); - int _subtitlesSpeed; - void setInteractive(bool state); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); - bool popViewport(); - bool pushViewport(CBViewport *Viewport); - bool setActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - bool drawCursor(CBSprite *Cursor); - - virtual bool initAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; - AnsiString getDataDir(); - void addMem(int bytes); - - bool _touchInterface; - bool _constrainedMemory; - AnsiString getDeviceType() const; - -private: - CBDebugger *_debugMgr; - - struct LastClickInfo { - LastClickInfo() { - posX = posY = 0; - time = 0; - } - - int posX; - int posY; - uint32 time; - }; - - LastClickInfo _lastClick[2]; - bool isDoubleClick(int buttonIndex); - uint32 _usedMem; - - - -protected: - // WME Lite specific - bool _autoSaveOnExit; - int _autoSaveSlot; - bool _cursorHidden; - -public: - void autoSaveOnExit(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp deleted file mode 100644 index 83deaa0306..0000000000 --- a/engines/wintermute/Base/BKeyboardState.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "common/system.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { - _currentPrintable = false; - _currentCharCode = 0; - _currentKeyData = 0; - - _currentShift = false; - _currentAlt = false; - _currentControl = false; - - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { - delete[] _keyStates; -} - -void CBKeyboardState::handleKeyPress(Common::Event *event) { - if (event->type == Common::EVENT_KEYDOWN) { - _keyStates[event->kbd.keycode] = true; - } -} - -void CBKeyboardState::handleKeyRelease(Common::Event *event) { - if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "IsKeyDown") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - int vKey; - - if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { - const char *str = val->getString(); - char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); - vKey = (int)temp; - } else vKey = val->getInt(); - - warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); - bool isDown = _keyStates[vKeyToKeyCode(vKey)]; - - stack->pushBool(isDown); - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("keyboard"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Key - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { - if (_currentPrintable) { - char key[2]; - key[0] = (char)_currentCharCode; - key[1] = '\0'; - _scValue->setString(key); - } else _scValue->setString(""); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Printable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { - _scValue->setBool(_currentPrintable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KeyCode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { - _scValue->setInt(_currentCharCode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsShift - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { - _scValue->setBool(_currentShift); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsAlt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { - _scValue->setBool(_currentAlt); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsControl - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { - _scValue->setBool(_currentControl); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - if (_renderer) SetWindowText(_renderer->_window, _name); - return STATUS_OK; - } - - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::scToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::readKey(Common::Event *event) { - //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = keyCodeToVKey(event); - if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { - _currentPrintable = true; - } else { - _currentPrintable = false; - } - //_currentKeyData = KeyData; - - _currentControl = isControlDown(); - _currentAlt = isAltDown(); - _currentShift = isShiftDown(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { - //if(!persistMgr->_saving) cleanup(); - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_currentAlt)); - persistMgr->transfer(TMEMBER(_currentCharCode)); - persistMgr->transfer(TMEMBER(_currentControl)); - persistMgr->transfer(TMEMBER(_currentKeyData)); - persistMgr->transfer(TMEMBER(_currentPrintable)); - persistMgr->transfer(TMEMBER(_currentShift)); - - if (!persistMgr->_saving) { - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; - - switch (event->kbd.keycode) { - case Common::KEYCODE_KP_ENTER: - return Common::KEYCODE_RETURN; - default: - return (uint32)event->kbd.keycode; - } -} - -enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 -}; - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { - // todo - switch (vkey) { - case VK_SPACE: - return Common::KEYCODE_SPACE; - break; - case VK_LEFT: - return Common::KEYCODE_LEFT; - break; - case VK_RIGHT: - return Common::KEYCODE_RIGHT; - break; - case VK_UP: - return Common::KEYCODE_UP; - break; - case VK_DOWN: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; - } - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BKeyboardState.h b/engines/wintermute/Base/BKeyboardState.h deleted file mode 100644 index 84bbab5339..0000000000 --- a/engines/wintermute/Base/BKeyboardState.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BScriptable.h" -#include "common/keyboard.h" -#include "common/events.h" - -namespace WinterMute { - -class CBKeyboardState : public CBScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); - bool readKey(Common::Event *event); - - void handleKeyPress(Common::Event *event); - void handleKeyRelease(Common::Event *event); - static bool isShiftDown(); - static bool isControlDown(); - static bool isAltDown(); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - uint8 *_keyStates; - uint32 keyCodeToVKey(Common::Event *event); - Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BNamedObject.cpp b/engines/wintermute/Base/BNamedObject.cpp deleted file mode 100644 index 855bdb2738..0000000000 --- a/engines/wintermute/Base/BNamedObject.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BNamedObject.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBNamedObject::setName(const char *name) { - delete[] _name; - - _name = new char [strlen(name) + 1]; - if (_name != NULL) strcpy(_name, name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BNamedObject.h b/engines/wintermute/Base/BNamedObject.h deleted file mode 100644 index e2649acbf5..0000000000 --- a/engines/wintermute/Base/BNamedObject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBNamedObject : public CBBase { -public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); - - char *_name; - void setName(const char *name); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp deleted file mode 100644 index 6640602443..0000000000 --- a/engines/wintermute/Base/BObject.cpp +++ /dev/null @@ -1,1128 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBObject, false) - -////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { - _posX = _posY = 0; - _movable = true; - _zoomable = true; - _registrable = true; - _shadowable = true; - _rotatable = false; - _is3D = false; - - _alphaColor = 0; - _scale = -1; - _relativeScale = 0; - - _scaleX = -1; - _scaleY = -1; - - _ready = true; - - _soundEvent = NULL; - - _iD = _gameRef->getSequence(); - - CBPlatform::setRectEmpty(&_rect); - _rectSet = false; - - _cursor = NULL; - _activeCursor = NULL; - _sharedCursors = false; - - _sFX = NULL; - _sFXStart = 0; - _sFXVolume = 100; - _autoSoundPanning = true; - - _editorAlwaysRegister = false; - _editorSelected = false; - - _editorOnly = false; - - _rotate = 0.0f; - _rotateValid = false; - _relativeRotate = 0.0f; - - for (int i = 0; i < 7; i++) - _caption[i] = NULL; - _saveState = true; - - _nonIntMouseEvents = false; - - // sound FX - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - _blendMode = BLEND_NORMAL; -} - - -////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) - _gameRef->_activeObject = NULL; - - CBScriptHolder::cleanup(); - delete[] _soundEvent; - _soundEvent = NULL; - - if (!_sharedCursors) { - delete _cursor; - delete _activeCursor; - _cursor = NULL; - _activeCursor = NULL; - } - delete _sFX; - _sFX = NULL; - - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7) - return; - - delete[] _caption[caseVal - 1]; - _caption[caseVal - 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal - 1]) { - strcpy(_caption[caseVal - 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) - return ""; - else return _caption[caseVal - 1]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - afterMove(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - stack->correctParams(1); - stack->pushString(getCaption(stack->pop()->getInt())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveCursor") == 0) { - stack->correctParams(0); - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } else { - _cursor = NULL; - - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursor") == 0) { - stack->correctParams(0); - if (!_cursor || !_cursor->_filename) stack->pushNULL(); - else stack->pushString(_cursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursorObject") == 0) { - stack->correctParams(0); - if (!_cursor) stack->pushNULL(); - else stack->pushNative(_cursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasCursor") == 0) { - stack->correctParams(0); - - if (_cursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCaption") == 0) { - stack->correctParams(2); - setCaption(stack->pop()->getString(), stack->pop()->getInt()); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadSound") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySound") == 0) { - stack->correctParams(3); - - const char *filename; - bool looping; - uint32 loopStart; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - - if (val1->_type == VAL_BOOL) { - filename = NULL; - looping = val1->getBool(); - loopStart = val2->getInt(); - } else { - if (val1->isNULL()) filename = NULL; - else filename = val1->getString(); - looping = val2->isNULL() ? false : val2->getBool(); - loopStart = val3->getInt(); - } - - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) - stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySoundEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySoundEvent") == 0) { - stack->correctParams(2); - - const char *filename; - const char *eventName; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - - if (val2->isNULL()) { - filename = NULL; - eventName = val1->getString(); - } else { - filename = val1->getString(); - eventName = val2->getString(); - } - - if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(pauseSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(resumeSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSoundPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSoundPlaying") == 0) { - stack->correctParams(0); - - if (_sFX && _sFX->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundPosition") == 0) { - stack->correctParams(1); - - uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundPosition") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(0); - else stack->pushInt(_sFX->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundVolume") == 0) { - stack->correctParams(1); - - int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundVolume") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolumePercent()); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SoundFXNone - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXNone") == 0) { - stack->correctParams(0); - _sFXType = SFX_NONE; - _sFXParam1 = 0; - _sFXParam2 = 0; - _sFXParam3 = 0; - _sFXParam4 = 0; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXEcho - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXEcho") == 0) { - stack->correctParams(4); - _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXReverb - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXReverb") == 0) { - stack->correctParams(4); - _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - _scValue->setString(getCaption(1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(getHeight()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Ready (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { - _scValue->setBool(_ready); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _scValue->setBool(_movable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _scValue->setBool(_registrable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _scValue->setBool(_zoomable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _scValue->setBool(_rotatable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alphaColor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - _scValue->setInt((int)_blendMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _scValue->setFloat((double)_relativeScale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->setNULL(); - else _scValue->setFloat((double)_rotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _scValue->setFloat((double)_relativeRotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _scValue->setBool(_shadowable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _scValue->setBool(_autoSoundPanning); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _scValue->setBool(_saveState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _scValue->setBool(_nonIntMouseEvents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - _scValue->setNULL(); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Caption") == 0) { - setCaption(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _movable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _rotatable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; - _blendMode = (TSpriteBlendMode)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) _scale = -1; - else _scale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) _scaleX = -1; - else _scaleX = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) _scaleY = -1; - else _scaleY = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (value->isNULL()) { - _rotate = 0.0f; - _rotateValid = false; - } else { - _rotate = (float)value->getFloat(); - _rotateValid = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _shadowable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) resetSoundPan(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _saveState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::scToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::showCursor() { - if (_cursor) return _gameRef->drawCursor(_cursor); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - for (int i = 0; i < 7; i++) - persistMgr->transfer(TMEMBER(_caption[i])); - persistMgr->transfer(TMEMBER(_activeCursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - persistMgr->transfer(TMEMBER(_autoSoundPanning)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_sharedCursors)); - persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); - persistMgr->transfer(TMEMBER(_editorOnly)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_is3D)); - persistMgr->transfer(TMEMBER(_movable)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); - persistMgr->transfer(TMEMBER(_relativeScale)); - persistMgr->transfer(TMEMBER(_rotatable)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_sFX)); - persistMgr->transfer(TMEMBER(_sFXStart)); - persistMgr->transfer(TMEMBER(_sFXVolume)); - persistMgr->transfer(TMEMBER(_ready)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_rectSet)); - persistMgr->transfer(TMEMBER(_registrable)); - persistMgr->transfer(TMEMBER(_shadowable)); - persistMgr->transfer(TMEMBER(_soundEvent)); - persistMgr->transfer(TMEMBER(_zoomable)); - - persistMgr->transfer(TMEMBER(_scaleX)); - persistMgr->transfer(TMEMBER(_scaleY)); - - persistMgr->transfer(TMEMBER(_rotate)); - persistMgr->transfer(TMEMBER(_rotateValid)); - persistMgr->transfer(TMEMBER(_relativeRotate)); - - persistMgr->transfer(TMEMBER(_saveState)); - persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); - - persistMgr->transfer(TMEMBER_INT(_sFXType)); - persistMgr->transfer(TMEMBER(_sFXParam1)); - persistMgr->transfer(TMEMBER(_sFXParam2)); - persistMgr->transfer(TMEMBER(_sFXParam3)); - persistMgr->transfer(TMEMBER(_sFXParam4)); - - - persistMgr->transfer(TMEMBER_INT(_blendMode)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setCursor(const char *filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { - delete _cursor; - _cursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setActiveCursor(const char *filename) { - delete _activeCursor; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { - delete _activeCursor; - _activeCursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBObject::getHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleKeypress(Common::Event *event, bool printable) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouseWheel(int delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { - // just play loaded sound - if (filename == NULL && _sFX) { - if (_gameRef->_editorMode || _sFXStart) { - _sFX->setVolumePercent(_sFXVolume); - _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) _sFXStart = 0; - } - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } - - if (filename == NULL) return STATUS_FAILED; - - // create new sound - delete _sFX; - - _sFX = new CBSound(_gameRef); - if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { - _sFX->setVolumePercent(_sFXVolume); - if (_sFXStart) { - _sFX->setPositionTime(_sFXStart); - _sFXStart = 0; - } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } else { - delete _sFX; - _sFX = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::stopSFX(bool deleteSound) { - if (_sFX) { - _sFX->stop(); - if (deleteSound) { - delete _sFX; - _sFX = NULL; - } - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::pauseSFX() { - if (_sFX) return _sFX->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resumeSFX() { - if (_sFX) return _sFX->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXTime(uint32 time) { - _sFXStart = time; - if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXVolume(int volume) { - _sFXVolume = volume; - if (_sFX) return _sFX->setVolumePercent(volume); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->isPlaying()) { - applyEvent(_soundEvent); - setSoundEvent(NULL); - } - } - - if (_sFX) updateOneSound(_sFX); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateOneSound(CBSound *sound) { - bool Ret = STATUS_OK; - - if (sound) { - if (_autoSoundPanning) - Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); - - Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - } - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resetSoundPan() { - if (!_sFX) return STATUS_OK; - else { - return _sFX->setPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::getExtendedFlag(const char *flagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::isReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setSoundEvent(const char *eventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (eventName) { - _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, eventName); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::afterMove() { - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h deleted file mode 100644 index 6e3c632bac..0000000000 --- a/engines/wintermute/Base/BObject.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H - - -#include "engines/wintermute/Base/BScriptHolder.h" -#include "engines/wintermute/persistent.h" -#include "common/events.h" - -namespace WinterMute { - -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(CBSound *sound); - bool _autoSoundPanning; - uint32 _sFXStart; - int _sFXVolume; - bool setSFXTime(uint32 time); - bool setSFXVolume(int volume); - bool resumeSFX(); - bool pauseSFX(); - bool stopSFX(bool deleteSound = true); - bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - CBSound *_sFX; - - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - - virtual bool handleMouseWheel(int delta); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual int getHeight(); - bool setCursor(const char *filename); - bool setActiveCursor(const char *filename); - bool cleanup(); - const char *getCaption(int caseVal = 1); - void setCaption(const char *caption, int caseVal = 1); - bool _editorSelected; - bool _editorAlwaysRegister; - bool _editorOnly; - bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual bool showCursor(); - CBSprite *_cursor; - bool _sharedCursors; - CBSprite *_activeCursor; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; - bool _zoomable; - bool _shadowable; - Rect32 _rect; - bool _rectSet; - int _iD; - bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); - char *_caption[7]; - char *_soundEvent; - int _posY; - int _posX; - bool _saveState; - - // base - virtual bool update() { - return STATUS_FAILED; - }; - virtual bool display() { - return STATUS_FAILED; - }; - virtual bool invalidateDeviceObjects() { - return STATUS_OK; - }; - virtual bool restoreDeviceObjects() { - return STATUS_OK; - }; - bool _nonIntMouseEvents; - - -public: - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp deleted file mode 100644 index 9dcdd38cdc..0000000000 --- a/engines/wintermute/Base/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BPackage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - closeFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { - if (_file) return STATUS_OK; - else { - _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { - delete _file; - _file = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (DID_FAIL(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); - if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPackage.h b/engines/wintermute/Base/BPackage.h deleted file mode 100644 index 117b0c522d..0000000000 --- a/engines/wintermute/Base/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp deleted file mode 100644 index 114c5054ca..0000000000 --- a/engines/wintermute/Base/BParser.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include "common/util.h" - -#define WHITESPACE " \t\n\r" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { - skipCharacters(buf, _whiteSpace); - - // skip comment lines. - while (**buf == ';') { - *buf = strchr(*buf, '\n'); - _parserLine++; - skipCharacters(buf, _whiteSpace); - } - - if (! **buf) // at end of file - return PARSERR_EOF; - - // find the token. - // for now just use brute force. Improve later. - while (tokens->id != 0) { - if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { - // here we could be matching PART of a string - // we could detect this here or the token list - // could just have the longer tokens first in the list - break; - } - ++tokens; - } - if (tokens->id == 0) { - char *p = strchr(*buf, '\n'); - if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); - - return PARSERR_TOKENNOTFOUND; - } - // skip the token - *buf += strlen(tokens->token); - skipCharacters(buf, _whiteSpace); - - // get optional name - *name = getSubText(buf, '\'', '\''); // single quotes - skipCharacters(buf, _whiteSpace); - - // get optional data - if (**buf == '=') // An assignment rather than a command/object. - *data = getAssignmentText(buf); - else - *data = getSubText(buf, '{', '}'); - - return tokens->id; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; - _gameRef->miniUpdate(); - char *name; - return getObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipCharacters(char **buf, const char *toSkip) { - char ch; - while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) - return; - ++*buf; // skip this character - } - // we must be at the end of the buffer if we get here -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) - return 0; - ++*buf; // skip opening delimiter - char *result = *buf; - - // now find the closing delimiter - char theChar; - long skip = 1; - - if (open == close) // we cant nest identical delimiters - open = 0; - while ((theChar = **buf) != 0) { - if (theChar == open) - ++skip; - if (theChar == close) { - if (--skip == 0) { - **buf = 0; // null terminate the result string - ++*buf; // move past the closing delimiter - break; - } - } - ++*buf; // try next character - } - return result; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getAssignmentText(char **buf) { - ++*buf; // skip the '=' - skipCharacters(buf, _whiteSpace); - char *result = *buf; - - - if (*result == '"') { - result = getSubText(buf, '"', '"'); - } else { - // now, we need to find the next whitespace to end the data - char theChar; - - while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars - break; - ++*buf; - } - **buf = 0; // null terminate it - if (theChar) // skip the terminator - ++*buf; - } - - return result; -} - - -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -char *CBParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; - while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; - if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; - } - - if (*b == '\'') { - b++; - while (*b && *b != '\'') { - *t++ = *b++; - } - *t++ = 0; - if (*b == '\'') b++; - } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || - *b == '%' || *b == ':' || *b == '{' || *b == '}') { - *t++ = *b++; - *t++ = 0; - } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { - *t++ = *b++; - *t++ = 0; - } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { - while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { - *t++ = *b++; - } - *t++ = 0; - } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { - while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { - *t++ = *b++; - } - *t++ = 0; - } else if (*b == 0) { - *buf = b; - return NULL; - } else { - // Error. - return NULL; - } - - *buf = b; - return token; -} - - -////////////////////////////////////////////////////////////////////// -float CBParser::getTokenFloat(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { - // Error situation. We handle this by return 0. - return 0.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::getTokenInt(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-')) { - // Error situation. We handle this by return 0. - return 0; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); - if (strcmp(t, tok)) return; // Error -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::scanStr(const char *in, const char *format, ...) { - va_list arg; - va_start(arg, format); - - int num = 0; - in += strspn(in, " \t\n\f"); - - while (*format && *in) { - if (*format == '%') { - format++; - switch (*format) { - case 'd': { - int *a = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - *a = atoi(in); - in += strspn(in, "0123456789+- \t\n\f"); - num++; - break; - } - case 'D': { - int i; - int *list = va_arg(arg, int *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { - list[i++] = atoi(in); - in += strspn(in, "0123456789+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 'b': { - bool *a = va_arg(arg, bool *); - in += strspn(in, " \t\n\f"); - const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - int l = (int)(in2 - in); - - *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || - !scumm_strnicmp(in, "1", l)); - - - in = in2 + strspn(in2, " \t\n\f"); - num++; - break; - } - case 'f': { - float *a = va_arg(arg, float *); - in += strspn(in, " \t\n\f"); - *a = (float)atof(in); - in += strspn(in, "0123456789.eE+- \t\n\f"); - num++; - break; - } - case 'F': { - int i; - float *list = va_arg(arg, float *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { - list[i++] = (float)atof(in); - in += strspn(in, "0123456789.eE+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 's': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\'') { - in++; - const char *in2 = strchr(in, '\''); - if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2; - } - in += strspn(in, " \t\n\f"); - num++; - break; - } - case 'S': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\"') { - in++; - while (*in != '\"') { - if (*in == '\\') { - in++; - switch (*in) { - case '\\': - *a++ = '\\'; - break; - case 'n': - *a++ = '\n'; - break; - case 'r': - *a++ = '\r'; - break; - case 't': - *a++ = '\t'; - break; - case '"': - *a++ = '"'; - break; - default: - *a++ = '\\'; - *a++ = *in; - break; - } //switch - in++; - } else { - *a++ = *in++; - } - } //while in string - in++; - num++; - } //if string started - - //terminate string - *a = '\0'; - break; - } - } - if (*format) format++; - } else if (*format == ' ') { - format++; - in += strspn(in, " \t\n\f"); - } else if (*in == *format) { - in++; - format++; - } else { - num = -1; - break; - } - } - - va_end(arg); - - return num; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BParser.h b/engines/wintermute/Base/BParser.h deleted file mode 100644 index 01d40067cc..0000000000 --- a/engines/wintermute/Base/BParser.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H - - -#define TOKEN_DEF_START \ - enum \ - { \ - TOKEN_NONE = 0, -#define TOKEN_DEF(name) \ - TOKEN_ ## name, -#define TOKEN_DEF_END \ - TOKEN_TOTAL_COUNT \ - }; -#define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ - { -#define TOKEN_TABLE(name) \ - { TOKEN_ ## name, #name }, -#define TOKEN_TABLE_END \ - { 0, 0 } \ - }; - -#define PARSERR_GENERIC -3 -#define PARSERR_EOF -2 -#define PARSERR_TOKENNOTFOUND -1 - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBParser : public CBBase { -public: - struct TokenDesc { - int32 id; - const char *token; - }; - -public: - int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); -private: - char *getLastOffender(); - void skipToken(char **buf, char *tok, char *msg = NULL); - int getTokenInt(char **buf); - float getTokenFloat(char **buf); - char *getToken(char **buf); - char *getAssignmentText(char **buf); - char *getSubText(char **buf, char open, char close); - void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - char *_whiteSpace; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp deleted file mode 100644 index 635097c0ad..0000000000 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BPersistMgr.h" -#include "engines/wintermute/Base/BSaveThumbHelper.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/Base/BSound.h" -#include "graphics/decoders/bmp.h" -#include "common/memstream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/savefile.h" - -namespace WinterMute { - -#define SAVE_BUFFER_INIT_SIZE 100000 -#define SAVE_BUFFER_GROW_BY 50000 - -#define SAVE_MAGIC 0x45564153 -#define SAVE_MAGIC_2 0x32564153 - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { - _saving = false; -// _buffer = NULL; -// _bufferSize = 0; - _offset = 0; - _saveStream = NULL; - _loadStream = NULL; - - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - _thumbnailData = NULL; - if (savePrefix) { - _savePrefix = savePrefix; - } else if (_gameRef) { - _savePrefix = _gameRef->getGameId(); - } else { - _savePrefix = "wmesav"; - } -} - - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::cleanup() { - /* if (_buffer) { - if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0;*/ - _offset = 0; - - delete[] _richBuffer; - _richBuffer = NULL; - _richBufferSize = 0; - - delete[] _savedDescription; - _savedDescription = NULL; // ref to buffer -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - if (_thumbnailData) { - delete [] _thumbnailData; - _thumbnailData = NULL; - } - - delete _loadStream; - delete _saveStream; - _loadStream = NULL; - _saveStream = NULL; -} - -Common::String CBPersistMgr::getFilenameForSlot(int slot) const { - // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) - return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); -} - -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); - return; - } - desc.setSaveSlot(slot); - desc.setDescription(_savedDescription); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - - if (_thumbnailDataSize > 0) { - Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); - Graphics::BitmapDecoder bmpDecoder; - if (bmpDecoder.loadStream(thumbStream)) { - Graphics::Surface *surf = new Graphics::Surface; - surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); - desc.setThumbnail(surf); - } - } - - desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); - desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); - desc.setPlayTime(0); -} - -void CBPersistMgr::deleteSaveSlot(int slot) { - Common::String filename = getFilenameForSlot(slot); - g_system->getSavefileManager()->removeSavefile(filename); -} - -uint32 CBPersistMgr::getMaxUsedSlot() { - Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); - Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); - Common::StringArray::iterator it = saves.begin(); - int ret = -1; - for (; it != saves.end(); it++) { - int num = -1; - sscanf(it->c_str(), "save%d", &num); - ret = MAX(ret, num); - } - return ret; -} - -bool CBPersistMgr::getSaveExists(int slot) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initSave(const char *desc) { - if (!desc) return STATUS_FAILED; - - cleanup(); - _saving = true; - - _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - - if (_saveStream) { - // get thumbnails - if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); - if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - } - } - - uint32 magic = DCGF_MAGIC; - putDWORD(magic); - - magic = SAVE_MAGIC_2; - putDWORD(magic); - - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(VerMajor); - _saveStream->writeByte(VerMinor); - _saveStream->writeByte(ExtMajor); - _saveStream->writeByte(ExtMinor); - - // new in ver 2 - putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->_name); - - // thumbnail data size - bool thumbnailOK = false; - - if (_gameRef->_cachedThumbnail) { - if (_gameRef->_cachedThumbnail->_thumbnail) { - Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); - if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { - _saveStream->writeUint32LE(thumbStream.size()); - _saveStream->write(thumbStream.getData(), thumbStream.size()); - } else { - _saveStream->writeUint32LE(0); - } - - thumbnailOK = true; - } - } - if (!thumbnailOK) putDWORD(0); - - // in any case, destroy the cached thumbnail once used - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - - uint32 dataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(desc) + 1 + // description - sizeof(uint32); // timestamp - - putDWORD(dataOffset); - putString(desc); - - g_system->getTimeAndDate(_savedTimestamp); - putTimeDate(_savedTimestamp); - _savedPlayTime = g_system->getMillis(); - _saveStream->writeUint32LE(_savedPlayTime); - } - return STATUS_OK; -} - -bool CBPersistMgr::readHeader(const Common::String &filename) { - cleanup(); - - _saving = false; - - _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); - if (_loadStream) { - uint32 magic; - magic = getDWORD(); - - if (magic != DCGF_MAGIC) { - cleanup(); - return STATUS_FAILED; - } - - magic = getDWORD(); - - if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { - _savedVerMajor = _loadStream->readByte(); - _savedVerMinor = _loadStream->readByte(); - _savedExtMajor = _loadStream->readByte(); - _savedExtMinor = _loadStream->readByte(); - - if (magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)getDWORD(); - _savedName = getStringObj(); - - // load thumbnail - _thumbnailDataSize = getDWORD(); - if (_thumbnailDataSize > 0) { - _thumbnailData = new byte[_thumbnailDataSize]; - if (_thumbnailData) { - getBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; - } - } else _savedVerBuild = 35; // last build with ver1 savegames - - uint32 dataOffset = getDWORD(); - - _savedDescription = getString(); - _savedTimestamp = getTimeDate(); - _savedPlayTime = _loadStream->readUint32LE(); - - _offset = dataOffset; - - return STATUS_OK; - } - } - - cleanup(); - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initLoad(const char *filename) { - if (DID_FAIL(readHeader(filename))) { - cleanup(); - return STATUS_FAILED; - } - _saving = false; - - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { - _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); - cleanup(); - return STATUS_FAILED; - } - - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - } - - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - - } - - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::saveFile(const char *filename) { - return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { - _saveStream->write(buffer, size); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { - _loadStream->read(buffer, size); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putDWORD(uint32 val) { - _saveStream->writeUint32LE(val); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::getDWORD() { - uint32 ret = _loadStream->readUint32LE(); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putString(const Common::String &val) { - if (!val.size()) putString("(null)"); - else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); - } -} - -Common::String CBPersistMgr::getStringObj() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - Common::String retString = ret; - delete[] ret; - - if (retString == "(null)") { - retString = ""; - } - - return retString; -} - -////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::getString() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - if (!strcmp(ret, "(null)")) { - delete[] ret; - return NULL; - } else return ret; -} - -bool CBPersistMgr::putTimeDate(const TimeDate &t) { - _saveStream->writeSint32LE(t.tm_sec); - _saveStream->writeSint32LE(t.tm_min); - _saveStream->writeSint32LE(t.tm_hour); - _saveStream->writeSint32LE(t.tm_mday); - _saveStream->writeSint32LE(t.tm_mon); - _saveStream->writeSint32LE(t.tm_year); - // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next - - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -TimeDate CBPersistMgr::getTimeDate() { - TimeDate t; - t.tm_sec = _loadStream->readSint32LE(); - t.tm_min = _loadStream->readSint32LE(); - t.tm_hour = _loadStream->readSint32LE(); - t.tm_mday = _loadStream->readSint32LE(); - t.tm_mon = _loadStream->readSint32LE(); - t.tm_year = _loadStream->readSint32LE(); - // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next - return t; -} - -void CBPersistMgr::putFloat(float val) { - Common::String str = Common::String::format("F%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -float CBPersistMgr::getFloat() { - char *str = getString(); - float value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -void CBPersistMgr::putDouble(double val) { - Common::String str = Common::String::format("F%f", val); - str.format("D%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -double CBPersistMgr::getDouble() { - char *str = getString(); - double value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -////////////////////////////////////////////////////////////////////////// -// bool -bool CBPersistMgr::transfer(const char *name, bool *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// int -bool CBPersistMgr::transfer(const char *name, int *val) { - if (_saving) { - _saveStream->writeSint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// DWORD -bool CBPersistMgr::transfer(const char *name, uint32 *val) { - if (_saving) { - _saveStream->writeUint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readUint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// float -bool CBPersistMgr::transfer(const char *name, float *val) { - if (_saving) { - putFloat(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// double -bool CBPersistMgr::transfer(const char *name, double *val) { - if (_saving) { - putDouble(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getDouble(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// char* -bool CBPersistMgr::transfer(const char *name, char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// const char* -bool CBPersistMgr::transfer(const char *name, const char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// Common::String -bool CBPersistMgr::transfer(const char *name, Common::String *val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - *val = str; - delete[] str; - } else { - *val = ""; - } - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { - size_t size; - - if (_saving) { - size = val.size(); - _saveStream->writeUint32LE(size); - - for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { - putString((*it).c_str()); - } - } else { - val.clear(); - size = _loadStream->readUint32LE(); - - for (size_t i = 0; i < size; i++) { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) val.push_back(str); - delete[] str; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// BYTE -bool CBPersistMgr::transfer(const char *name, byte *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// RECT -bool CBPersistMgr::transfer(const char *name, Rect32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->left); - _saveStream->writeSint32LE(val->top); - _saveStream->writeSint32LE(val->right); - _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->left = _loadStream->readSint32LE(); - val->top = _loadStream->readSint32LE(); - val->right = _loadStream->readSint32LE(); - val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// POINT -bool CBPersistMgr::transfer(const char *name, Point32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->x); - _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = _loadStream->readSint32LE(); - val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// Vector2 -bool CBPersistMgr::transfer(const char *name, Vector2 *val) { - if (_saving) { - putFloat(val->x); - putFloat(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = getFloat(); - val->y = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// generic pointer -bool CBPersistMgr::transfer(const char *name, void *val) { - int classID = -1, instanceID = -1; - - if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); - if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - _gameRef->LOG(0, "Warning: invalid instance '%s'", name); - } - - _saveStream->writeUint32LE(classID); - _saveStream->writeUint32LE(instanceID); - } else { - classID = _loadStream->readUint32LE(); - instanceID = _loadStream->readUint32LE(); - - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) return true; - - // it's ok if we are same or newer than the saved game - if (verMajor > _savedVerMajor || - (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || - (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h deleted file mode 100644 index 3a2aa82c94..0000000000 --- a/engines/wintermute/Base/BPersistMgr.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/savestate.h" -#include "common/stream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/rect.h" - -namespace WinterMute { - -class Vector2; - -class CBPersistMgr : public CBBase { -public: - char *_savedDescription; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; - Common::String _savePrefix; - Common::String _savedName; - bool saveFile(const char *filename); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - Common::String getStringObj(); - void putString(const Common::String &val); - float getFloat(); - void putFloat(float val); - double getDouble(); - void putDouble(double val); - void cleanup(); - void getSaveStateDesc(int slot, SaveStateDescriptor &desc); - void deleteSaveSlot(int slot); - uint32 getMaxUsedSlot(); - bool getSaveExists(int slot); - bool initLoad(const char *filename); - bool initSave(const char *desc); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 _offset; - - bool _saving; - - uint32 _richBufferSize; - byte *_richBuffer; - - bool transfer(const char *name, void *val); - bool transfer(const char *name, int *val); - bool transfer(const char *name, uint32 *val); - bool transfer(const char *name, float *val); - bool transfer(const char *name, double *val); - bool transfer(const char *name, bool *val); - bool transfer(const char *name, byte *val); - bool transfer(const char *name, Rect32 *val); - bool transfer(const char *name, Point32 *val); - bool transfer(const char *name, const char **val); - bool transfer(const char *name, char **val); - bool transfer(const char *name, Common::String *val); - bool transfer(const char *name, Vector2 *val); - bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); - virtual ~CBPersistMgr(); - bool checkVersion(byte verMajor, byte verMinor, byte verBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - Common::String getFilenameForSlot(int slot) const; -private: - bool readHeader(const Common::String &filename); - TimeDate getTimeDate(); - bool putTimeDate(const TimeDate &t); - Common::WriteStream *_saveStream; - Common::SeekableReadStream *_loadStream; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BPoint.cpp b/engines/wintermute/Base/BPoint.cpp deleted file mode 100644 index abb170d0b5..0000000000 --- a/engines/wintermute/Base/BPoint.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BPoint.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBPoint, false) - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPoint::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BPoint.h b/engines/wintermute/Base/BPoint.h deleted file mode 100644 index 7b9c561fac..0000000000 --- a/engines/wintermute/Base/BPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBPoint: public CBBase { -public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); - int y; - int x; - virtual ~CBPoint(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BQuickMsg.cpp b/engines/wintermute/Base/BQuickMsg.cpp deleted file mode 100644 index dd87a10dad..0000000000 --- a/engines/wintermute/Base/BQuickMsg.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BQuickMsg.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { - _text = new char [strlen(text) + 1]; - if (_text) strcpy(_text, text); - _startTime = _gameRef->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { - if (_text) delete [] _text; -} - - -////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::getText() { - return _text; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BQuickMsg.h b/engines/wintermute/Base/BQuickMsg.h deleted file mode 100644 index 46f44b291f..0000000000 --- a/engines/wintermute/Base/BQuickMsg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBQuickMsg : public CBBase { -public: - char *getText(); - uint32 _startTime; - char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp deleted file mode 100644 index 3dc14df05f..0000000000 --- a/engines/wintermute/Base/BRegion.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBRegion, false) - -////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - CBPlatform::setRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::createRegion() { - return DID_SUCCEED(getBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) return false; - - Point32 pt; - pt.x = x; - pt.y = y; - - Rect32 rect; - rect.left = x - 1; - rect.right = x + 2; - rect.top = y - 1; - rect.bottom = y + 2; - - if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(POINT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(POINT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int i; - - for (i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // AddPoint - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AddPoint") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - _points.add(new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points[Index]->x = x; - _points[Index]->y = y; - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemovePoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemovePoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - delete _points[index]; - _points[index] = NULL; - - _points.removeAt(index); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - CScValue *val = stack->getPushValue(); - if (val) { - val->setProperty("X", _points[index]->x); - val->setProperty("Y", _points[index]->y); - } - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.getSize()); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBRegion::scToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", nameOverride); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -typedef struct { - double x, y; -} dPoint; - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) return false; - - int counter = 0; - double xinters; - dPoint p, p1, p2; - - p.x = (double)x; - p.y = (double)y; - - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; - - for (int i = 1; i <= _points.getSize(); i++) { - p2.x = (double)_points[i % _points.getSize()]->x; - p2.y = (double)_points[i % _points.getSize()]->y; - - if (p.y > MIN(p1.y, p2.y)) { - if (p.y <= MAX(p1.y, p2.y)) { - if (p.x <= MAX(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) - counter++; - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) - return false; - else - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); - else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - - for (int i = 0; i < _points.getSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); - - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); - } - CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; - - cleanup(); - - for (int i = 0; i < region->_points.getSize(); i++) { - int xVal, yVal; - - xVal = (int)((float)region->_points[i]->x * scale / 100.0f); - yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - - _points.add(new CBPoint(xVal + x, yVal + y)); - } - - _lastMimicScale = scale; - _lastMimicX = x; - _lastMimicY = y; - - return createRegion() ? STATUS_OK : STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegion.h b/engines/wintermute/Base/BRegion.h deleted file mode 100644 index d2f06cbed9..0000000000 --- a/engines/wintermute/Base/BRegion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H - -#include "engines/wintermute/Base/BPoint.h" -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CBRegion : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - bool getBoundingRect(Rect32 *rect); - bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(CBRegion, CBObject) - bool _active; - int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); - bool pointInRegion(int x, int y); - bool createRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - Rect32 _rect; - CBArray _points; - virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp deleted file mode 100644 index c7ec0c2675..0000000000 --- a/engines/wintermute/Base/BRegistry.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/utils.h" -#include "common/config-manager.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { - _iniName = NULL; - - setIniName("./wme.ini"); - loadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { - saveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - - bool found = false; - ret = getValue(_localValues, subKey, key, found); - if (!found) ret = getValue(_values, subKey, key, found); - if (!found) ret = init; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - if (ConfMan.hasKey("master_volume")) { - return ConfMan.getInt("master_volume"); - } else { - return init; - } - } else if (key == "SFXVolume") { - if (ConfMan.hasKey("sfx_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "SpeechVolume") { - if (ConfMan.hasKey("speech_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "MusicVolume") { - if (ConfMan.hasKey("music_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } - } - AnsiString val = readString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - ConfMan.setInt("master_volume", value); - return true; - } else if (key == "SFXVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "SpeechVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "MusicVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } - } - writeString(subKey, key, StringUtil::toString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (readInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return writeInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setIniName(const char *name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { - _iniName = new char [strlen(name) + 3]; - sprintf(_iniName, "./%s", name); - } else { - _iniName = new char [strlen(name) + 1]; - strcpy(_iniName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBRegistry::getIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadValues(bool local) { - if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveValues() { - saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setBasePath(const char *basePath) { - _basePath = PathUtil::getFileNameWithoutExtension(basePath); - - loadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::createPath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - Common::DumpFile stream; - stream.open(fileName.c_str()); - - if (!stream.isOpen()) return; - else { - stream.write(printer.CStr(), printer.Size()); - stream.close(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BRegistry.h b/engines/wintermute/Base/BRegistry.h deleted file mode 100644 index a07f6be8d4..0000000000 --- a/engines/wintermute/Base/BRegistry.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBRegistry : public CBBase { -public: - void setIniName(const char *name); - char *getIniName(); - bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); - int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); - - void setBasePath(const char *basePath); - AnsiString getBasePath() const { - return _basePath; - } - - void loadValues(bool local); - void saveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void loadXml(const AnsiString fileName, PathValueMap &values); - void saveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BResources.cpp b/engines/wintermute/Base/BResources.cpp deleted file mode 100644 index 75b4a5d1ea..0000000000 --- a/engines/wintermute/Base/BResources.cpp +++ /dev/null @@ -1,2820 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BResources.h" -#include "common/str.h" -#include "common/memstream.h" - -namespace WinterMute { - -unsigned char invalid[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} ; - -unsigned char invaliddebug[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, - 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, - 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, - 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, - 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, - 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, - 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, - 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, - 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, - 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, - 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, - 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, - 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, - 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, - 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, - 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, - 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, - 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, - 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, - 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, - 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, - 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, - 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, - 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, - 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, - 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, - 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, - 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, - 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, - 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, - 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, - 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, - 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, - 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, - 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, - 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, - 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, - 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, - 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, - 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, - 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, - 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, - 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, - 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, - 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, - 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, - 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, - 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, - 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, - 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, - 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, - 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, - 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, - 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, - 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, - 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, - 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, - 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 -} ; - -unsigned char systemfont[] = { - 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -} ; - -Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { - if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { - return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { - return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { - return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BResources.h b/engines/wintermute/Base/BResources.h deleted file mode 100644 index 6ec0541b5c..0000000000 --- a/engines/wintermute/Base/BResources.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H - -#include "common/stream.h" -#include "common/str.h" - -namespace WinterMute { - -class CBResources { -public: - static Common::SeekableReadStream *getFile(const Common::String &fileName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp deleted file mode 100644 index 74295170ff..0000000000 --- a/engines/wintermute/Base/BSaveThumbHelper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BSaveThumbHelper.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { - delete _thumbnail; - _thumbnail = NULL; - - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - if (doFlip) { - // when using opengl on windows it seems to be necessary to do this twice - // works normally for direct3d - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - } - - CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) return STATUS_FAILED; - - // normal thumbnail - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new CBImage(_gameRef); - _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); - } - - - delete screenshot; - screenshot = NULL; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSaveThumbHelper.h b/engines/wintermute/Base/BSaveThumbHelper.h deleted file mode 100644 index c7c7e13982..0000000000 --- a/engines/wintermute/Base/BSaveThumbHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBImage; - -class CBSaveThumbHelper : public CBBase { -public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); - bool storeThumbnail(bool doFlip = false); - - CBImage *_thumbnail; - CBImage *_richThumbnail; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp deleted file mode 100644 index 45cbc5d23b..0000000000 --- a/engines/wintermute/Base/BScriptHolder.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Base/BScriptHolder.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { - setName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::cleanup() { - delete[] _filename; - _filename = NULL; - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) delete [] _filename; - - _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) strcpy(_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { - int numHandlers = 0; - - bool ret = STATUS_FAILED; - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); - if (handler) { - //_scripts.add(handler); - numHandlers++; - ret = STATUS_OK; - } - } - } - if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // DEBUG_CrashMe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "DEBUG_CrashMe") == 0) { - stack->correctParams(0); - byte *p = 0; - *p = 10; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ApplyEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ApplyEvent") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - bool ret; - ret = applyEvent(val->getString()); - - if (DID_SUCCEED(ret)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleEvent") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleEvent(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleMethod - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleMethod") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleMethod(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AttachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AttachScript") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DetachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DetachScript") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool killThreads = stack->pop()->getBool(false); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - _scripts[i]->finish(killThreads); - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScriptRunning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScriptRunning") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("script_holder"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::scToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { - return CBBase::saveAsText(buffer, indent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_name)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); - return STATUS_OK; - } - } - } - - CScScript *scr = _gameRef->_scEngine->runScript(filename, this); - if (!scr) { - if (_gameRef->_editorForceScripts) { - // editor hack - scr = new CScScript(_gameRef, _gameRef->_scEngine); - scr->_filename = new char[strlen(filename) + 1]; - strcpy(scr->_filename, filename); - scr->_state = SCRIPT_ERROR; - scr->_owner = this; - _scripts.add(scr); - _gameRef->_scEngine->_scripts.add(scr); - _gameRef->getDebugMgr()->onScriptInit(scr); - - return STATUS_OK; - } - return STATUS_FAILED; - } else { - scr->_freezable = _freezable; - _scripts.add(scr); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::removeScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) { - _scripts.removeAt(i); - break; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; - } - return false; -} - - -TOKEN_DEF_START -TOKEN_DEF(PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - _gameRef->LOG(0, "'PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading PROPERTY definition"); - return STATUS_FAILED; - } - - - CScValue *val = new CScValue(_gameRef); - val->setString(propValue); - scSetProperty(propName, val); - - delete val; - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool freezable) { - _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->_freezable = freezable; - -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.getSize() - 1; i >= 0; i--) { - if (_scripts[i]->canHandleMethod(methodName)) { - - CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); - if (thread) { - bool ret = thread->createMethodThread(_scripts[i], methodName); - if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); - - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); - if (_name && strcmp(_name, "") != 0) { - strcat(buf, " Name: "); - strcat(buf, _name); - } - if (_filename) { - strcat(buf, " File: "); - strcat(buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *eventName) { - return DID_SUCCEED(applyEvent(eventName)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptHolder.h b/engines/wintermute/Base/BScriptHolder.h deleted file mode 100644 index 77f0f386cb..0000000000 --- a/engines/wintermute/Base/BScriptHolder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CBScriptHolder : public CBScriptable { -public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) - - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *methodName); - virtual void makeFreezable(bool freezable); - bool canHandleEvent(const char *eventName); - virtual bool canHandleMethod(const char *eventMethod); - bool cleanup(); - bool removeScript(CScScript *script); - bool addScript(const char *filename); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool applyEvent(const char *eventName, bool unbreakable = false); - void setFilename(const char *filename); - bool parseProperty(byte *buffer, bool complete = true); - char *_filename; - bool _freezable; - bool _ready; - - CBArray _scripts; - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void scDebuggerDesc(char *buf, int bufSize); - // IWmeObject -public: - virtual bool sendEvent(const char *eventName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp deleted file mode 100644 index e9416cfaf3..0000000000 --- a/engines/wintermute/Base/BScriptable.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BScriptable.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptable, false) - -////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { - _refCount = 0; - - if (noValue) _scValue = NULL; - else _scValue = new CScValue(_gameRef); - - _persistable = persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { - //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); - delete _scValue; - delete _scProp; - _scValue = NULL; - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - /* - stack->correctParams(0); - stack->pushNULL(); - script->runtimeError("Call to undefined method '%s'.", name); - - return STATUS_OK; - */ - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->getProp(name); - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->setProp(name, value); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::scToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *CBScriptable::scToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double CBScriptable::scToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetString(const char *val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetInt(int val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetFloat(double val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetBool(bool val) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); - persistMgr->transfer(TMEMBER(_scProp)); - persistMgr->transfer(TMEMBER(_scValue)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *val) { - if (this < val) return -1; - else if (this > val) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::canHandleMethod(const char *eventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::invokeMethodThread(const char *methodName) { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::dbgGetNativeClass() { - return getClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { - return scGetProperty(name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BScriptable.h b/engines/wintermute/Base/BScriptable.h deleted file mode 100644 index e806b83fac..0000000000 --- a/engines/wintermute/Base/BScriptable.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H - - -#include "engines/wintermute/Base/BNamedObject.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CScStack; -class CScScript; - -class CBScriptable : public CBNamedObject, public IWmeDebugObject { -public: - virtual CScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) - - CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); - virtual ~CBScriptable(); - - // high level scripting interface - virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void *scToMemBuffer(); - virtual int scToInt(); - virtual double scToFloat(); - virtual bool scToBool(); - virtual void scSetString(const char *val); - virtual void scSetInt(int val); - virtual void scSetFloat(double val); - virtual void scSetBool(bool val); - virtual int scCompare(CBScriptable *val); - virtual void scDebuggerDesc(char *buf, int bufSize); - int _refCount; - CScValue *_scValue; - CScValue *_scProp; - -public: - // IWmeDebugObject - const char *dbgGetNativeClass(); - IWmeDebugProp *dbgGetProperty(const char *name); - -}; - -// Implemented in their respective .cpp-files -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXMath(CBGame *inGame); -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXStore(CBGame *inGame); -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp deleted file mode 100644 index 315a073301..0000000000 --- a/engines/wintermute/Base/BSound.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BSoundBuffer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSound, false) - -////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { - _sound = NULL; - _soundFilename = NULL; - - _soundType = Audio::Mixer::kSFXSoundType; - _soundStreamed = false; - _soundLooping = false; - _soundPlaying = false; - _soundPaused = false; - _soundFreezePaused = false; - _soundPosition = 0; - _soundPrivateVolume = 0; - _soundLoopStart = 0; - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { - if (_sound) _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - } - delete[] _soundFilename; - _soundFilename = NULL; - - _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); - if (_sound) { - _soundFilename = new char[strlen(filename) + 1]; - strcpy(_soundFilename, filename); - - _soundType = type; - _soundStreamed = streamed; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSoundSimple() { - _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); - if (_sound) { - if (_soundPosition) _sound->setPosition(_soundPosition); - _sound->setLooping(_soundLooping); - _sound->setPrivateVolume(_soundPrivateVolume); - _sound->setLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->resume(); - else return STATUS_OK; - } else return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getLength() { - if (_sound) return _sound->getLength(); - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::play(bool looping) { - if (_sound) { - _soundPaused = false; - return _sound->play(looping, _soundPosition); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::stop() { - if (_sound) { - _soundPaused = false; - return _sound->stop(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::pause(bool freezePaused) { - if (_sound) { - _soundPaused = true; - if (freezePaused) _sound->_freezePaused = true; - return _sound->pause(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->resume(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::persist(CBPersistMgr *persistMgr) { - if (persistMgr->_saving && _sound) { - _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) - _soundPosition = _sound->getPosition(); - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (persistMgr->_saving) { - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - } - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_soundFilename)); - persistMgr->transfer(TMEMBER(_soundLooping)); - persistMgr->transfer(TMEMBER(_soundPaused)); - persistMgr->transfer(TMEMBER(_soundFreezePaused)); - persistMgr->transfer(TMEMBER(_soundPlaying)); - persistMgr->transfer(TMEMBER(_soundPosition)); - persistMgr->transfer(TMEMBER(_soundPrivateVolume)); - persistMgr->transfer(TMEMBER(_soundStreamed)); - persistMgr->transfer(TMEMBER_INT(_soundType)); - persistMgr->transfer(TMEMBER(_soundLoopStart)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPlaying() { - return _sound && _sound->isPlaying(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPaused() { - return _sound && _soundPaused; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPositionTime(uint32 time) { - if (!_sound) return STATUS_FAILED; - _soundPosition = time; - bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) - _soundPosition = 0; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getPositionTime() { - if (!_sound) return 0; - - if (!_sound->isPlaying()) - return 0; - else return _sound->getPosition(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolumePercent(int percent) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(percent * 255 / 100); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(volume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPrivateVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->_privateVolume = volume; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolumePercent() { - if (!_sound) - return 0; - else return _sound->_privateVolume * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolume() { - if (!_sound) - return 0; - else return _sound->_privateVolume; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setLoopStart(uint32 pos) { - if (!_sound) - return STATUS_FAILED; - else { - _sound->setLoopStart(pos); - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPan(float pan) { - if (_sound) - return _sound->setPan(pan); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) - return STATUS_OK; - - if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - bool ret = _sound->applyFX(type, param1, param2, param3, param4); - - _sFXType = type; - _sFXParam1 = param1; - _sFXParam2 = param2; - _sFXParam3 = param3; - _sFXParam4 = param4; - - return ret; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSound.h b/engines/wintermute/Base/BSound.h deleted file mode 100644 index 697c49600d..0000000000 --- a/engines/wintermute/Base/BSound.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "audio/mixer.h" - -namespace WinterMute { - -class CBSoundBuffer; -class CBSound : public CBBase { -public: - bool setPan(float pan); - int _soundPrivateVolume; - int getVolume(); - int getVolumePercent(); - bool setVolumePercent(int percent); - bool setVolume(int volume); - bool setPrivateVolume(int volume); - bool setLoopStart(uint32 pos); - uint32 getPositionTime(); - bool setPositionTime(uint32 time); - bool _soundPaused; - bool _soundFreezePaused; - bool isPlaying(); - bool isPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) - bool resume(); - bool pause(bool freezePaused = false); - bool stop(); - bool play(bool looping = false); - uint32 getLength(); - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - char *_soundFilename; - bool setSoundSimple(); - bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); - - bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); - -private: - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - CBSoundBuffer *_sound; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp deleted file mode 100644 index 0fc9a9158c..0000000000 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BSoundBuffer.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/vorbis.h" -#include "audio/decoders/wave.h" -#include "audio/decoders/raw.h" -#include "common/system.h" -#include "common/substream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { - _stream = NULL; - _handle = NULL; -// _sync = NULL; - - _streamed = false; - _filename = NULL; - _file = NULL; - _privateVolume = 255; - _volume = 255; - - _looping = false; - _loopStart = 0; - - _type = Audio::Mixer::kSFXSoundType; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { - stop(); - - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - delete _stream; - _stream = NULL; - - delete[] _filename; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { - _streamed = Streamed; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif - - // Load a file, but avoid having the File-manager handle the disposal of it. - _file = _gameRef->_fileManager->openFile(filename, true, false); - if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - Common::String strFilename(filename); - if (strFilename.hasSuffix(".ogg")) { - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); - } else if (strFilename.hasSuffix(".wav")) { - int waveSize, waveRate; - byte waveFlags; - uint16 waveType; - - if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { - if (waveType == 1) { - // We need to wrap the file in a substream to make sure the size is right. - _file = new Common::SeekableSubReadStream(_file, 0, waveSize); - _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); - } else { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); - } - } - } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); - } - if (!_stream) { - return STATUS_FAILED; - } - CBUtils::setString(&_filename, filename); - - return STATUS_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return STATUS_FAILED; - } - - CBUtils::setString(&_filename, filename); - - /* - bool res; - bool NewlyCreated = false; - - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = _gameRef->_fileManager->openFile(filename); - if(!_file){ - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if(!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if(DID_FAIL(res)){ - _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); - return res; - } - } - - - - // store filename - if(!_filename){ - _filename = new char[strlen(filename)+1]; - strcpy(_filename, filename); - } - - // close file (if not streaming) - if(!_streamed && _file){ - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - */ - - return STATUS_OK; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::play(bool looping, uint32 startSample) { - if (startSample != 0) { - warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); - } - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - if (_stream) { - _stream->seek(startSample); - _handle = new Audio::SoundHandle; - if (looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); - g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); - } else { - g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); - _looping = looping; -#if 0 - - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::resume() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, false); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::stop() { - if (_stream && _handle) { - g_system->getMixer()->stopHandle(*_handle); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::pause() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, true); - } - return STATUS_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getLength() { - if (_stream) { - uint32 len = _stream->getLength().msecs(); - return len * 1000; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { - _type = type; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::updateVolume() { - setVolume(_privateVolume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setVolume(int volume) { - _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; - if (_stream && _handle) { - byte vol = (byte)(_volume); - g_system->getMixer()->setChannelVolume(*_handle, vol); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPrivateVolume(int volume) { - _privateVolume = volume; - return setVolume(_privateVolume); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::isPlaying() { - if (_stream && _handle) { - return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getPosition() { - if (_stream && _handle) { - uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); - return pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPosition(uint32 pos) { - warning("CBSoundBuffer::SetPosition - not implemented yet"); -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setLoopStart(uint32 pos) { - _loopStart = pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif - return STATUS_OK; -} -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPan(float pan) { - if (_handle) { - g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("CBSoundBuffer::ApplyFX - not implemented yet"); - switch (type) { - case SFX_ECHO: - break; - - case SFX_REVERB: - break; - - default: - break; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundBuffer.h b/engines/wintermute/Base/BSoundBuffer.h deleted file mode 100644 index 632c53008a..0000000000 --- a/engines/wintermute/Base/BSoundBuffer.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H - - -#include "engines/wintermute/Base/BBase.h" -#include "audio/mixer.h" -#include "common/stream.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace WinterMute { - -class CBFile; -class CBSoundBuffer : public CBBase { -public: - - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); - - - bool pause(); - bool play(bool looping = false, uint32 startSample = 0); - bool resume(); - bool stop(); - bool isPlaying(); - - void setLooping(bool looping); - - uint32 getPosition(); - bool setPosition(uint32 pos); - uint32 getLength(); - - bool setLoopStart(uint32 pos); - uint32 getLoopStart() const { - return _loopStart; - } - - bool setPan(float pan); - bool setPrivateVolume(int colume); - bool setVolume(int colume); - void updateVolume(); - - void setType(Audio::Mixer::SoundType Type); - - bool loadFromFile(const char *filename, bool forceReload = false); - void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; - bool _looping; - Common::SeekableReadStream *_file; - char *_filename; - bool _streamed; - - int _privateVolume; -private: - int _volume; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp deleted file mode 100644 index d4100df7aa..0000000000 --- a/engines/wintermute/Base/BSoundMgr.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BSoundBuffer.h" -#include "engines/wintermute/wintermute.h" -#include "common/config-manager.h" -#include "audio/mixer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { - _soundAvailable = false; - _volumeMaster = 255; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.size(); i++) - delete _sounds[i]; - _sounds.clear(); -#if 0 - BASS_Free(); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { - if (_soundAvailable) { - _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initialize() { - _soundAvailable = false; - - if (!g_system->getMixer()->isReady()) { - return STATUS_FAILED; - } - _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); - _soundAvailable = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initLoop() { - if (!_soundAvailable) - return STATUS_OK; -#if 0 - - BASS_Update(500); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) - return NULL; - - CBSoundBuffer *sound; - - // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::compareNoCase(ext, "wav")) { - AnsiString path = PathUtil::getDirectoryName(filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(filename); - - AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (_gameRef->_fileManager->hasFile(newFile)) { - filename = newFile.c_str(); - } - } - - sound = new CBSoundBuffer(_gameRef); - if (!sound) return NULL; - - sound->setStreaming(streamed); - sound->setType(type); - - - bool res = sound->loadFromFile(filename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", filename); - delete sound; - return NULL; - } - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return sound; - - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) - return STATUS_FAILED; - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (int i = 0; i < _sounds.size(); i++) { - if (_sounds[i] == sound) { - delete _sounds[i]; - _sounds.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) - return STATUS_OK; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - ConfMan.setInt("sfx_volume", volume); - break; - case Audio::Mixer::kSpeechSoundType: - ConfMan.setInt("speech_volume", volume); - break; - case Audio::Mixer::kMusicSoundType: - ConfMan.setInt("music_volume", volume); - break; - case Audio::Mixer::kPlainSoundType: - error("Plain sound type shouldn't be used in WME"); - } - g_wintermute->syncSoundSettings(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { - return setVolume(type, percent * 255 / 100); -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { - int volume = 0; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - case Audio::Mixer::kSpeechSoundType: - case Audio::Mixer::kMusicSoundType: - volume = g_system->getMixer()->getVolumeForSoundType(type); - break; - default: - error("Sound-type not set"); - break; - } - - return (byte)(volume * 100 / 255); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolume(byte value) { - _volumeMaster = value; - for (int i = 0; i < _sounds.size(); i++) { - _sounds[i]->updateVolume(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolumePercent(byte percent) { - setMasterVolume(percent * 255 / 100); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { - return getMasterVolume() * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolume() { - return (byte)_volumeMaster; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::pauseAll(bool includingMusic) { - - for (int i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { - _sounds[i]->pause(); - _sounds[i]->_freezePaused = true; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::resumeAll() { - - for (int i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int x, int y) { - float relPos = (float)x / ((float)_gameRef->_renderer->_width); - - float minPan = -0.7f; - float maxPan = 0.7f; - - return minPan + relPos * (maxPan - minPan); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h deleted file mode 100644 index be5be87b59..0000000000 --- a/engines/wintermute/Base/BSoundMgr.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BBase.h" -#include "audio/mixer.h" -#include "common/array.h" - -namespace WinterMute { -class CBSoundBuffer; -class CBSoundMgr : public CBBase { -public: - float posToPan(int x, int y); - bool resumeAll(); - bool pauseAll(bool includingMusic = true); - bool cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); - byte getMasterVolumePercent(); - byte getMasterVolume(); - bool setMasterVolume(byte percent); - bool setMasterVolumePercent(byte percent); - byte getVolumePercent(Audio::Mixer::SoundType type); - bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); - bool setVolume(Audio::Mixer::SoundType type, int volume); - uint32 _volumeOriginal; - int _volumeMaster; - bool removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initLoop(); - bool initialize(); - bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - Common::Array _sounds; - void saveSettings(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp deleted file mode 100644 index 1af73ca595..0000000000 --- a/engines/wintermute/Base/BSprite.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSprite, false) - -////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::setDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - _filename = NULL; - _finished = false; - _changed = false; - _paused = false; - _continuous = false; - _moveX = _moveY = 0; - - _editorMuted = false; - _editorBgFile = NULL; - _editorBgOffsetX = _editorBgOffsetY = 0; - _editorBgAlpha = 0xFF; - _streamed = false; - _streamedKeepLoaded = false; - - setName(""); - - _precise = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::cleanup() { - CBScriptHolder::cleanup(); - - for (int i = 0; i < _frames.getSize(); i++) - delete _frames[i]; - _frames.removeAll(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // move owner if allowed to - if (_changed && _owner && _owner->_movable) { - _owner->_posX += _moveX; - _owner->_posY += _moveY; - _owner->afterMove(); - - x = _owner->_posX; - y = _owner->_posY; - } - - // draw frame - return display(x, y, registerOwner, zoomX, zoomY, alpha); -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); - if (!file) { - _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); - else return loadFile("invalid.bmp", lifeTime, cacheType); - } else { - _gameRef->_fileManager->closeFile(file); - file = NULL; - } - - bool ret; - - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(_gameRef); - CBSubFrame *subframe = new CBSubFrame(_gameRef); - subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); - ret = STATUS_FAILED; - delete frame; - delete subframe; - } else { - CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); - frame->_subframes.add(subframe); - _frames.add(frame); - _currentFrame = 0; - ret = STATUS_OK; - } - } else { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] buffer; - } - } - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - - return ret; -} - - - -TOKEN_DEF_START -TOKEN_DEF(CONTINUOUS) -TOKEN_DEF(SPRITE) -TOKEN_DEF(LOOPING) -TOKEN_DEF(FRAME) -TOKEN_DEF(NAME) -TOKEN_DEF(PRECISE) -TOKEN_DEF(EDITOR_MUTED) -TOKEN_DEF(STREAMED_KEEP_LOADED) -TOKEN_DEF(STREAMED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_BG_FILE) -TOKEN_DEF(EDITOR_BG_OFFSET_X) -TOKEN_DEF(EDITOR_BG_OFFSET_Y) -TOKEN_DEF(EDITOR_BG_ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(CONTINUOUS) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(LOOPING) - TOKEN_TABLE(FRAME) - TOKEN_TABLE(NAME) - TOKEN_TABLE(PRECISE) - TOKEN_TABLE(EDITOR_MUTED) - TOKEN_TABLE(STREAMED_KEEP_LOADED) - TOKEN_TABLE(STREAMED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_BG_FILE) - TOKEN_TABLE(EDITOR_BG_OFFSET_X) - TOKEN_TABLE(EDITOR_BG_OFFSET_Y) - TOKEN_TABLE(EDITOR_BG_ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - cleanup(); - - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - _gameRef->LOG(0, "'SPRITE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int frameCount = 1; - CBFrame *frame; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_CONTINUOUS: - parser.scanStr((char *)params, "%b", &_continuous); - break; - - case TOKEN_EDITOR_MUTED: - parser.scanStr((char *)params, "%b", &_editorMuted); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_LOOPING: - parser.scanStr((char *)params, "%b", &_looping); - break; - - case TOKEN_PRECISE: - parser.scanStr((char *)params, "%b", &_precise); - break; - - case TOKEN_STREAMED: - parser.scanStr((char *)params, "%b", &_streamed); - if (_streamed && lifeTime == -1) { - lifeTime = 500; - cacheType = CACHE_ALL; - } - break; - - case TOKEN_STREAMED_KEEP_LOADED: - parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_EDITOR_BG_FILE: - if (_gameRef->_editorMode) { - delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); - } - break; - - case TOKEN_EDITOR_BG_OFFSET_X: - parser.scanStr((char *)params, "%d", &_editorBgOffsetX); - break; - - case TOKEN_EDITOR_BG_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_editorBgOffsetY); - break; - - case TOKEN_EDITOR_BG_ALPHA: - parser.scanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = MIN(_editorBgAlpha, 255); - _editorBgAlpha = MAX(_editorBgAlpha, 0); - break; - - case TOKEN_FRAME: { - int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - - frame = new CBFrame(_gameRef); - - if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { - delete frame; - _gameRef->LOG(0, "Error parsing frame %d", frameCount); - return STATUS_FAILED; - } - - _frames.add(frame); - frameCount++; - if (_currentFrame == -1) _currentFrame = 0; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITE definition"); - return STATUS_FAILED; - } - _canBreak = !_continuous; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBSprite::reset() { - if (_frames.getSize() > 0) _currentFrame = 0; - else _currentFrame = -1; - - killAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - - if (_currentFrame == -1) return false; - - uint32 timer; - if (_owner && _owner->_freezable) timer = _gameRef->_timer; - else timer = _gameRef->_liveTimer; - - int lastFrame = _currentFrame; - - // get current frame - if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.getSize() - 1) { - _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } - - if (_changed) { - _moveX = _frames[_currentFrame]->_moveX; - _moveY = _frames[_currentFrame]->_moveY; - - if (zoomX != 100 || zoomY != 100) { - _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); - } - } - - return _changed; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // on change... - if (_changed) { - if (_frames[_currentFrame]->_killSound) { - killAllSounds(); - } - applyEvent("FrameChanged"); - _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); - } - - // draw frame - return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); -} - - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::getSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.getSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - CBPlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.getSize(); i++) { - Rect32 frame; - Rect32 temp; - CBPlatform::copyRect(&temp, rect); - _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); - if (_streamed) { - buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - - if (_streamedKeepLoaded) - buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); - } - - if (_editorMuted) - buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - - if (_editorBgFile) { - buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); - } - - CBScriptHolder::saveAsText(buffer, indent + 2); - - int i; - - // scripts - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - - for (i = 0; i < _frames.getSize(); i++) { - _frames[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_canBreak)); - persistMgr->transfer(TMEMBER(_changed)); - persistMgr->transfer(TMEMBER(_paused)); - persistMgr->transfer(TMEMBER(_continuous)); - persistMgr->transfer(TMEMBER(_currentFrame)); - persistMgr->transfer(TMEMBER(_editorAllFrames)); - persistMgr->transfer(TMEMBER(_editorBgAlpha)); - persistMgr->transfer(TMEMBER(_editorBgFile)); - persistMgr->transfer(TMEMBER(_editorBgOffsetX)); - persistMgr->transfer(TMEMBER(_editorBgOffsetY)); - persistMgr->transfer(TMEMBER(_editorMuted)); - persistMgr->transfer(TMEMBER(_finished)); - - _frames.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_lastFrameTime)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_precise)); - persistMgr->transfer(TMEMBER(_streamed)); - persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetFrame") == 0) { - stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - stack->pushNULL(); - } else stack->pushNative(_frames[Index], true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteFrame") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); - } - } else { - CBFrame *Frame = (CBFrame *)Val->getNative(); - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; - delete _frames[i]; - _frames.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddFrame") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) { - sub->setDefaultRect(); - frame->_subframes.add(sub); - } else delete sub; - } - _frames.add(frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertFrame") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) - index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) - filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); - else delete sub; - } - - if (index >= _frames.getSize()) - _frames.add(frame); - else _frames.insertAt(index, frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _paused = true; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Play - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Play") == 0) { - stack->correctParams(0); - _paused = false; - stack->pushNULL(); - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("sprite"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFrames (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { - _scValue->setInt(_currentFrame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_precise); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _scValue->setBool(_looping); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Owner (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->setNULL(); - else _scValue->setNative(_owner, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Finished (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { - _scValue->setBool(_finished); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Paused (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { - _scValue->setBool(_paused); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { - _currentFrame = -1; - } - _lastFrameTime = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _precise = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _looping = value->getBool(); - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSprite::scToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::killAllSounds() { - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i]->_sound) - _frames[i]->_sound->stop(); - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSprite.h b/engines/wintermute/Base/BSprite.h deleted file mode 100644 index 30698b62c1..0000000000 --- a/engines/wintermute/Base/BSprite.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BScriptHolder.h" - -namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { -public: - bool killAllSounds(); - CBSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void cleanup(); - void setDefaults(); - bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) - - bool _editorAllFrames; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - int _moveY; - int _moveX; - bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; - void reset(); - CBObject *_owner; - bool _changed; - bool _paused; - bool _finished; - bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; - bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); - bool _looping; - int _currentFrame; - bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - CBSprite(CBGame *inGame, CBObject *owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp deleted file mode 100644 index f9d4094004..0000000000 --- a/engines/wintermute/Base/BStringTable.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return STATUS_FAILED; - - if (scumm_stricmp(key, "@right-to-left") == 0) { - _gameRef->_textRTL = true; - return STATUS_OK; - } - - Common::String finalKey = key; - finalKey.toLowercase(); - - _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); - - _strings[finalKey] = val; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -char *CBStringTable::getKey(const char *str) { - if (str == NULL || str[0] != '/') return NULL; - - const char *value = strchr(str + 1, '/'); - if (value == NULL) return NULL; - - char *key = new char[value - str]; - strncpy(key, str + 1, value - str - 1); - key[value - str - 1] = '\0'; - CBPlatform::strlwr(key); - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = getKey(new_str); - delete [] new_str; - return Ret; - } else { - delete [] new_str; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBStringTable::expand(char **str, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return; - - if (str == NULL || *str == NULL || *str[0] != '/') return; - - char *value = strchr(*str + 1, '/'); - if (value == NULL) return; - - char *key = new char[value - *str]; - strncpy(key, *str + 1, value - *str - 1); - key[value - *str - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); - } - - delete [] key; - delete [] *str; - *str = new_str; - - if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return string; - - if (string == NULL || string[0] == '\0' || string[0] != '/') return string; - - const char *value = strchr(string + 1, '/'); - if (value == NULL) return string; - - char *key = new char[value - string]; - strncpy(key, string + 1, value - string - 1); - key[value - string - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - const char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); - } else { - new_str = value; - } - - delete [] key; - - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); - else return new_str; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::loadFile(const char *filename, bool clearOld) { - _gameRef->LOG(0, "Loading string table..."); - - if (clearOld) _strings.clear(); - - uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (buffer == NULL) { - _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - uint32 pos = 0; - - if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - pos += 3; - if (_gameRef->_textEncoding != TEXT_UTF8) { - _gameRef->_textEncoding = TEXT_UTF8; - //_gameRef->_textEncoding = TEXT_ANSI; - _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); - } - } else _gameRef->_textEncoding = TEXT_ANSI; - - uint32 lineLength = 0; - while (pos < size) { - lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - - uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); - char *line = new char[realLength + 1]; - strncpy(line, (char *)&buffer[pos], realLength); - line[realLength] = '\0'; - char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); - - if (line[0] != ';') { - if (value != NULL) { - value[0] = '\0'; - value++; - for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; - } - addString(line, value, clearOld); - } else if (line[0] != '\0') addString(line, "", clearOld); - } - - delete [] line; - pos += lineLength + 1; - } - - delete [] buffer; - - _gameRef->LOG(0, " %d strings loaded", _strings.size()); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h deleted file mode 100644 index 4bdbcdc203..0000000000 --- a/engines/wintermute/Base/BStringTable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H - - -#include "common/hashmap.h" -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBStringTable : public CBBase { -public: - const char *expandStatic(const char *string, bool forceExpand = false); - bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str, bool forceExpand = false); - bool addString(const char *key, const char *val, bool reportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); - Common::HashMap _strings; - char *getKey(const char *str); -private: - Common::HashMap::iterator _stringsIter; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp deleted file mode 100644 index 7569ecb727..0000000000 --- a/engines/wintermute/Base/BSubFrame.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - CBPlatform::setRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; -} - - -TOKEN_DEF_START -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(DECORATION) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custoTrans = false; - CBPlatform::setRectEmpty(&rect); - char *surfaceFile = NULL; - - delete _surface; - _surface = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &_2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &_3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &_mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &_mirrorY); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &_decoration); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); - return STATUS_FAILED; - } - - if (surfaceFile != NULL) { - if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); - } - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); - - /* - if(_surface == NULL) - { - _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); - return STATUS_FAILED; - } - */ - if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); - else _rect = rect; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return STATUS_OK; - - if (registerOwner != NULL && !_decoration) { - if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); - } else { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); - } - } - if (_gameRef->_suspendedRendering) return STATUS_OK; - - bool res; - - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) alpha = _alpha; - - if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); - } else { - if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - float ratioX = scaleX / 100.0f; - float ratioY = scaleY / 100.0f; - - CBPlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { - if (complete) - buffer->putTextIndent(indent, "SUBFRAME {\n"); - - if (_surface && _surface->getFileNameStr() != "") - buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); - - if (_transparent != 0xFFFF00FF) - buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - - Rect32 rect; - CBPlatform::setRectEmpty(&rect); - if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::equalRect(&rect, &_rect)) - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); - - if (_hotspotX != 0 || _hotspotY != 0) - buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - - if (_alpha != 0xFFFFFFFF) { - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - } - - if (_mirrorX) - buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - - if (_mirrorY) - buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - - if (_2DOnly) - buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - - if (_3DOnly) - buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - - if (_decoration) - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - - if (_editorSelected) - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - CBBase::saveAsText(buffer, indent + 2); - - - if (complete) - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSubFrame::setDefaultRect() { - if (_surface) { - CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_2DOnly)); - persistMgr->transfer(TMEMBER(_3DOnly)); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_hotspotX)); - persistMgr->transfer(TMEMBER(_hotspotY)); - persistMgr->transfer(TMEMBER(_rect)); - - persistMgr->transfer(TMEMBER(_surfaceFilename)); - persistMgr->transfer(TMEMBER(_cKDefault)); - persistMgr->transfer(TMEMBER(_cKRed)); - persistMgr->transfer(TMEMBER(_cKGreen)); - persistMgr->transfer(TMEMBER(_cKBlue)); - persistMgr->transfer(TMEMBER(_lifeTime)); - - persistMgr->transfer(TMEMBER(_keepLoaded)); - persistMgr->transfer(TMEMBER(_mirrorX)); - persistMgr->transfer(TMEMBER(_mirrorY)); - persistMgr->transfer(TMEMBER(_transparent)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - - if (!_surfaceFilename) stack->pushNULL(); - else stack->pushString(_surfaceFilename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (Val->isNULL()) { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; - stack->pushBool(true); - } else { - const char *filename = Val->getString(); - if (DID_SUCCEED(setSurface(filename))) { - setDefaultRect(); - stack->pushBool(true); - } else stack->pushBool(false); - } - - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("subframe"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - - _scValue->setInt((int)_alpha); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TransparentColor (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { - _scValue->setInt((int)_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _scValue->setBool(_2DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _scValue->setBool(_3DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _scValue->setBool(_mirrorX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _scValue->setBool(_mirrorY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _scValue->setInt(_hotspotX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _scValue->setInt(_hotspotY); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = value->getInt(); - return STATUS_OK; - } - - else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::scToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - _surface = NULL; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - if (_surface) { - _surfaceFilename = new char[strlen(filename) + 1]; - strcpy(_surfaceFilename, filename); - - _cKDefault = defaultCK; - _cKRed = ckRed; - _cKGreen = ckGreen; - _cKBlue = ckBlue; - _lifeTime = lifeTime; - _keepLoaded = keepLoaded; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurfaceSimple() { - if (!_surfaceFilename) { - _surface = NULL; - return STATUS_OK; - } - _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return STATUS_OK; - else return STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSubFrame.h b/engines/wintermute/Base/BSubFrame.h deleted file mode 100644 index 5ff000ea2f..0000000000 --- a/engines/wintermute/Base/BSubFrame.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool setSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) - void setDefaultRect(); - uint32 _transparent; - bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); - bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - - int _hotspotX; - int _hotspotY; - uint32 _alpha; - Rect32 _rect; - - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - CBSurface *_surface; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp deleted file mode 100644 index 64bc3daac6..0000000000 --- a/engines/wintermute/Base/BSurfaceStorage.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { - cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::cleanup(bool warn) { - for (int i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); - delete _surfaces[i]; - } - _surfaces.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::initLoop() { - if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { - _lastCleanupTime = _gameRef->_liveTimer; - sortSurfaces(); - for (int i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; - - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { - //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->invalidate(); - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i] == surface) { - _surfaces[i]->_referenceCount--; - if (_surfaces[i]->_referenceCount <= 0) { - delete _surfaces[i]; - _surfaces.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (int i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_debugDebugMode) - return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - else - return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } - - CBSurface *surface; - surface = _gameRef->_renderer->createSurface(); - - if (!surface) return NULL; - - if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { - delete surface; - return NULL; - } else { - surface->_referenceCount = 1; - _surfaces.push_back(surface); - return surface; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::restoreAll() { - bool ret; - for (int i = 0; i < _surfaces.size(); i++) { - ret = _surfaces[i]->restore(); - if (ret != STATUS_OK) { - _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return STATUS_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) -{ - - if(!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - - //_surfaces.persist(persistMgr); - - return STATUS_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); - - // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; - - - // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; - - // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h deleted file mode 100644 index 00ca38a7a1..0000000000 --- a/engines/wintermute/Base/BSurfaceStorage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H - -#include "engines/wintermute/Base/BBase.h" -#include "common/array.h" - -namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { -public: - uint32 _lastCleanupTime; - bool initLoop(); - bool sortSurfaces(); - static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - - bool restoreAll(); - CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); - - Common::Array _surfaces; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp deleted file mode 100644 index 81d80c40aa..0000000000 --- a/engines/wintermute/Base/BTransitionMgr.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BTransitionMgr.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::isReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return STATUS_OK; - - if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { - _state = TRANS_MGR_READY; - return STATUS_OK; - } - - if (nonInteractive) { - _preserveInteractive = true; - _origInteractive = _gameRef->_interactive; - _gameRef->_interactive = false; - } /*else _preserveInteractive */; - - - _type = type; - _state = TRANS_MGR_RUNNING; - _started = false; - - return STATUS_OK; -} - -#define FADE_DURATION 200 - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::update() { - if (isReady()) return STATUS_OK; - - if (!_started) { - _started = true; - _lastTime = CBPlatform::getTime(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - - case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)((float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (isReady()) { - if (_preserveInteractive) - _gameRef->_interactive = _origInteractive; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BTransitionMgr.h b/engines/wintermute/Base/BTransitionMgr.h deleted file mode 100644 index 8219afeb46..0000000000 --- a/engines/wintermute/Base/BTransitionMgr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { - -class CBTransitionMgr : public CBBase { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - bool update(); - bool start(TTransitionType type, bool nonInteractive = false); - bool isReady(); - TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp deleted file mode 100644 index 8f0680dfb6..0000000000 --- a/engines/wintermute/Base/BViewport.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BViewport.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBViewport, false) - -////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_mainObject)); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_rect)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { - if (!noCheck) { - left = MAX(left, 0); - top = MAX(top, 0); - right = MIN(right, _gameRef->_renderer->_width); - bottom = MIN(bottom, _gameRef->_renderer->_height); - } - - CBPlatform::setRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -Rect32 *CBViewport::getRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/BViewport.h b/engines/wintermute/Base/BViewport.h deleted file mode 100644 index 667d181dcd..0000000000 --- a/engines/wintermute/Base/BViewport.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H - - -#include "engines/wintermute/Base/BBase.h" - -namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { -public: - int getHeight(); - int getWidth(); - Rect32 *getRect(); - bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) - int _offsetY; - int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); -private: - Rect32 _rect; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp deleted file mode 100644 index 2a3386a005..0000000000 --- a/engines/wintermute/Base/file/BDiskFile.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/Base/file/BPkgFile.h" -#include "engines/wintermute/Base/file/BDiskFile.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "common/stream.h" -#include "common/memstream.h" -#include "common/file.h" -#include "common/zlib.h" - -namespace WinterMute { - -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; - } -} - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { - char fullPath[MAX_PATH_LENGTH]; - uint32 prefixSize = 0; - Common::SeekableReadStream *file = NULL; - - for (int i = 0; i < fileManager->_singlePaths.size(); i++) { - sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); - correctSlashes(fullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - // if we didn't find it in search paths, try to open directly - if (!file) { - strcpy(fullPath, filename.c_str()); - correctSlashes(fullPath); - - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - if (file) { - uint32 magic1, magic2; - magic1 = file->readUint32LE(); - magic2 = file->readUint32LE(); - - bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; - - if (compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = file->readUint32LE(); - CompSize = file->readUint32LE(); - UncompSize = file->readUint32LE(); - - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - error("Error allocating memory for compressed file '%s'", filename.c_str()); - delete file; - return NULL; - } - - byte *data = new byte[UncompSize]; - if (!data) { - error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - file->seek(DataOffset + prefixSize, SEEK_SET); - file->read(CompBuffer, CompSize); - - if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { - error("Error uncompressing file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - - delete [] CompBuffer; - - return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); - delete file; - file = NULL; - } else { - file->seek(0, SEEK_SET); - return file; - } - - return file; - - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BDiskFile.h b/engines/wintermute/Base/file/BDiskFile.h deleted file mode 100644 index 23e1a0a315..0000000000 --- a/engines/wintermute/Base/file/BDiskFile.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/file/BFile.cpp b/engines/wintermute/Base/file/BFile.cpp deleted file mode 100644 index 9da60a11ec..0000000000 --- a/engines/wintermute/Base/file/BFile.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/file/BFile.h" -#include "common/memstream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFile::isEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = getPos(); - seek(0); - byte *data = new byte[getSize()]; - read(data, getSize()); - seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BFile.h b/engines/wintermute/Base/file/BFile.h deleted file mode 100644 index cbdd0b1ff1..0000000000 --- a/engines/wintermute/Base/file/BFile.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBFile : public CBBase { -protected: - uint32 _pos; - uint32 _size; -public: - virtual uint32 getSize() { - return _size; - }; - virtual uint32 getPos() { - return _pos; - }; - virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; - virtual bool read(void *buffer, uint32 size) = 0; - virtual bool close() = 0; - virtual bool open(const Common::String &filename) = 0; - virtual bool isEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/file/BPkgFile.cpp b/engines/wintermute/Base/file/BPkgFile.cpp deleted file mode 100644 index fcacfdfd40..0000000000 --- a/engines/wintermute/Base/file/BPkgFile.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BPackage.h" -#include "engines/wintermute/Base/file/BPkgFile.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "common/util.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace WinterMute { - -// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. -class CBPkgFile : public Common::SeekableReadStream { - uint32 _size; - Common::SeekableReadStream *_stream; -public: - CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { - delete _stream; - } - virtual uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } - virtual bool eos() const { - return _stream->eos(); - } - virtual int32 pos() const { - return _stream->pos(); - } - virtual int32 size() const { - return _size; - } - virtual bool seek(int32 offset, int whence = SEEK_SET) { - return _stream->seek(offset, whence); - } -}; - -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { - CBFileEntry *fileEntry; - Common::SeekableReadStream *file = NULL; - char fileName[MAX_PATH_LENGTH]; - strcpy(fileName, filename.c_str()); - - // correct slashes - for (uint32 i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '/') fileName[i] = '\\'; - } - - fileEntry = fileManager->getPackageEntry(fileName); - if (!fileEntry) return NULL; - - file = fileEntry->_package->getFilePointer(); - if (!file) return NULL; - - // TODO: Cleanup - bool compressed = (fileEntry->_compressedLength != 0); - /* _size = fileEntry->_length; */ - - if (compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); - } else { - file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); - } - if (file->size() == 0) { - file = new CBPkgFile(file, fileEntry->_length); - } - - file->seek(0); - - return file; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BPkgFile.h b/engines/wintermute/Base/file/BPkgFile.h deleted file mode 100644 index 0d1916594a..0000000000 --- a/engines/wintermute/Base/file/BPkgFile.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPKGFILE_H -#define WINTERMUTE_BPKGFILE_H - -#include "engines/wintermute/Base/BFileEntry.h" - -namespace Common { -class SeekableReadStream; -class File; -} - -namespace WinterMute { - -class CBFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp deleted file mode 100644 index b61c2a586f..0000000000 --- a/engines/wintermute/Base/file/BSaveThumbFile.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/file/BSaveThumbFile.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { - close(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::open(const Common::String &filename) { - close(); - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; - - char *tempFilename = new char[strlen(filename.c_str()) - 8]; - strcpy(tempFilename, filename.c_str() + 9); - for (uint32 i = 0; i < strlen(tempFilename); i++) { - if (tempFilename[i] < '0' || tempFilename[i] > '9') { - tempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int slot = atoi(tempFilename); - delete [] tempFilename; - - char slotFilename[MAX_PATH_LENGTH + 1]; - _gameRef->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _gameRef->_debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - _gameRef->_debugAbsolutePathWarning = true; - - bool res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = STATUS_OK; - } else res = STATUS_FAILED; - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return STATUS_FAILED; - - memcpy(buffer, (byte *)_data + _pos, size); - _pos += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) return STATUS_FAILED; - - uint32 newPos = 0; - - switch (whence) { - case SEEK_SET: - newPos = pos; - break; - case SEEK_END: - newPos = _size + pos; - break; - case SEEK_CUR: - newPos = _pos + pos; - break; - } - - if (newPos > _size) return STATUS_FAILED; - else _pos = newPos; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/file/BSaveThumbFile.h b/engines/wintermute/Base/file/BSaveThumbFile.h deleted file mode 100644 index 777a4df903..0000000000 --- a/engines/wintermute/Base/file/BSaveThumbFile.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H - - -#include "engines/wintermute/Base/file/BFile.h" - -namespace WinterMute { - -//TODO: Get rid of this -class CBSaveThumbFile : public CBFile { -public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); - virtual bool seek(uint32 pos, int whence = SEEK_SET); - virtual bool read(void *buffer, uint32 size); - virtual bool close(); - virtual bool open(const Common::String &filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/font/BFont.cpp b/engines/wintermute/Base/font/BFont.cpp deleted file mode 100644 index f797d49c5b..0000000000 --- a/engines/wintermute/Base/font/BFont.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/font/BFontBitmap.h" -#include "engines/wintermute/Base/font/BFontTT.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFont, false) - -////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { -} - - -////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - -/* -////////////////////////////////////////////////////////////////////// -bool CBFont::loadFile(const char * Filename) -{ - BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ - _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - CBParser parser(_gameRef); - - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ - -////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFont::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { - if (isTrueType(gameRef, filename)) { - CBFontTT *font = new CBFontTT(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - CBFontBitmap *font = new CBFontBitmap(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; - - byte *WorkBuffer = buffer; - - char *params; - CBParser parser(gameRef); - - bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - ret = true; - - delete [] buffer; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFont.h b/engines/wintermute/Base/font/BFont.h deleted file mode 100644 index 5fa9bf3c1c..0000000000 --- a/engines/wintermute/Base/font/BFont.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H - -#include "engines/wintermute/Base/BObject.h" - -#define NUM_CHARACTERS 256 - -namespace WinterMute { - -class CBFont: public CBObject { -public: - DECLARE_PERSISTENT(CBFont, CBObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - virtual void initLoop() {}; - virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); - - static CBFont *createFromFile(CBGame *game, const char *filename); - -private: - //bool loadBuffer(byte * Buffer); - //bool loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp deleted file mode 100644 index 15e14958f8..0000000000 --- a/engines/wintermute/Base/font/BFontBitmap.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/font/BFontBitmap.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (maxLength >= 0 && str.size() > (uint32)maxLength) - str = Common::String(str.c_str(), (uint32)maxLength); - //str.substr(0, maxLength); // TODO: Remove - - int textWidth = 0; - for (size_t i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; - - if (text == NULL || text[0] == '\0') return _tileHeight; - - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - if (str.empty()) return 0; - - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool new_line = false; - bool long_line = false; - - if (draw) _gameRef->_renderer->startSpriteBatch(); - - while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) _gameRef->_renderer->endSpriteBatch(); - return NumLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { - end = index - 1; - RealLength = LineLength; - } - - if (str[index] == '\n') { - end = index - 1; - RealLength = LineLength; - new_line = true; - } - - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; - } - - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!new_line) { - end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; - } - } else LineLength += getCharWidth(str[index]); - - if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; - int StartX; - switch (align) { - case TAL_CENTER: - StartX = x + (width - RealLength) / 2; - break; - case TAL_RIGHT: - StartX = x + width - RealLength; - break; - case TAL_LEFT: - StartX = x; - break; - default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); - StartX += getCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (long_line) end--; - start = end + 2; - index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; - } - } - - if (draw) _gameRef->_renderer->endSpriteBatch(); - - return NumLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - Rect32 rect; - /* l t r b */ - int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; - - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); - bool handled = false; - if (_sprite) { - _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); - } - handled = true; - } - } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - int widths[300]; - int num = 0, default_width = 8; - int lastWidth = 0; - int i; - int r = 255, g = 255, b = 255; - bool custoTrans = false; - char *surfaceFile = NULL; - char *spriteFile = NULL; - - bool autoWidth = false; - int spaceWidth = 0; - int expandWidth = 0; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = (char *)params; - break; - - case TOKEN_SPRITE: - spriteFile = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_WIDTHS: - parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { - _widths[lastWidth] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); - break; - - case TOKEN_WIDTHS_FRAME: - parser.scanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.scanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.scanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.scanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.scanStr(params, "%b", &autoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.scanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.scanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.scanStr(params, "%d", &spaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.scanStr(params, "%d", &expandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - if (spriteFile != NULL) { - delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(_gameRef); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - _gameRef->LOG(0, "Incomplete font definition"); - return STATUS_FAILED; - } - - if (autoWidth) { - // calculate characters width - getWidths(); - - // do we need to modify widths? - if (expandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; - - _widths[i] = (byte)NewWidth; - } - } - - // handle space character - uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; - - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { - if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { - _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { - - CBFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); - - persistMgr->transfer(TMEMBER(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); - - if (persistMgr->_saving) - persistMgr->putBytes(_widths, sizeof(_widths)); - else - persistMgr->getBytes(_widths, sizeof(_widths)); - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::getWidths() { - CBSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int minCol = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; - if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - minCol = MAX(col, minCol); - break; - } - } - if (minCol == _tileWidth - 1) break; - } - - _widths[i] = minCol + 1; - } - surf->endPixelOp(); - /* - _gameRef->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontBitmap.h b/engines/wintermute/Base/font/BFontBitmap.h deleted file mode 100644 index 4806d61291..0000000000 --- a/engines/wintermute/Base/font/BFontBitmap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H - - -#include "engines/wintermute/Base/font/BFont.h" - -namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { -public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) - bool loadBuffer(byte *Buffer); - bool loadFile(const char *filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); - - - bool getWidths(); - CBSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; - bool _wholeCell; - -private: - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/font/BFontStorage.cpp b/engines/wintermute/Base/font/BFontStorage.cpp deleted file mode 100644 index 0e2e0af84d..0000000000 --- a/engines/wintermute/Base/font/BFontStorage.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); - delete _fonts[i]; - } - _fonts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { - if (!filename) return NULL; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - CBFont* font = new CBFont(_gameRef); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - CBFont *font = CBFont::createFromFile(_gameRef, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::removeFont(CBFont *font) { - if (!font) return STATUS_FAILED; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.removeAt(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::persist(CBPersistMgr *persistMgr) { - - if (!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontStorage.h b/engines/wintermute/Base/font/BFontStorage.h deleted file mode 100644 index 4f360c84c5..0000000000 --- a/engines/wintermute/Base/font/BFontStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBFont; - -class CBFontStorage : public CBBase { -public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) - bool cleanup(bool warn = false); - bool removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; - bool initLoop(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp deleted file mode 100644 index fd3dcb3567..0000000000 --- a/engines/wintermute/Base/font/BFontTT.cpp +++ /dev/null @@ -1,762 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/font/BFontTT.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/gfx/base_renderer.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintermute.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFontTT, false) - -////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - _deletableFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { - clearCache(); - - for (int i = 0; i < _layers.getSize(); i++) { - delete _layers[i]; - } - _layers.removeAll(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (_gameRef->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; - } - } -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - measureText(textStr, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - - int textWidth, textHeight; - measureText(textStr, width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; - - WideString textStr = (char *)text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - CBRenderer *renderer = _gameRef->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - CBSurface *surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - minPriority = 0; - minIndex = i; - } else { - if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { - surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; - minIndex = i; - } - } - } - } - - // not found, create one - if (!surface) { - debugC(kWinterMuteDebugFont, "Draw text: %s", text); - surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); - if (surface) { - // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; - - _cachedTexts[minIndex]->_surface = surface; - _cachedTexts[minIndex]->_align = align; - _cachedTexts[minIndex]->_width = width; - _cachedTexts[minIndex]->_maxHeight = maxHeight; - _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; - _cachedTexts[minIndex]->_text = textStr; - _cachedTexts[minIndex]->_textOffset = textOffset; - _cachedTexts[minIndex]->_marked = true; - } - } - - - // and paint it - if (surface) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { - uint32 color = _layers[i]->_color; - uint32 origForceAlpha = renderer->_forceAlphaColor; - if (renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); - renderer->_forceAlphaColor = 0; - } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - renderer->_forceAlphaColor = origForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO - //WrapText(text, width, maxHeight, lines); - Common::Array lines; - _font->wordWrapText(text, width, lines); - - Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; - if (align == TAL_LEFT) { - alignment = Graphics::kTextAlignLeft; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - alignment = Graphics::kTextAlignRight; - } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); - } - - debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); -// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; - Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - else // We are using a fallback, they can't do 32bpp - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); - uint32 useColor = 0xffffffff; - Common::Array::iterator it; - int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += (int)_lineHeight; - } - - CBSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - _gameRef->LOG(0, "'TTFONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - uint32 BaseColor = 0x00000000; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.scanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.scanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.scanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.scanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.scanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); - } - break; - - case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TTFONT definition"); - return STATUS_FAILED; - } - - // create at least one layer - if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); - } - - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.scanStr(params, "%d", &layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.scanStr(params, "%d", &layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); - - - // persist layers - int numLayers; - if (persistMgr->_saving) { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); - } else { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->_saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; - - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); - if (!file) { - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); - if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; - } - } - - if (file) { -#ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - _gameRef->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } - if (maxWidth >= 0) { - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - Common::Array::iterator it; - textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { - textWidth = MAX(textWidth, _font->getStringWidth(*it)); - } - - //WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * getLineHeight()); - } else { - textWidth = _font->getStringWidth(text); - textHeight = _fontHeight; - } - /* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/font/BFontTT.h b/engines/wintermute/Base/font/BFontTT.h deleted file mode 100644 index d2b29a89f8..0000000000 --- a/engines/wintermute/Base/font/BFontTT.h +++ /dev/null @@ -1,180 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H - -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace WinterMute { - -class CBFontTT : public CBFont { -private: - ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - CBSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - CBCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~CBCachedTTFontText() { - if (_surface) delete _surface; - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { - public: - CBTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - bool persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - -public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); - - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - bool loadBuffer(byte *buffer); - bool loadFile(const char *filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - bool parseLayer(CBTTFontLayer *layer, byte *buffer); - - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - - - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - bool initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _ascender; - float _descender; - float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - CBArray _layers; - void clearCache(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/gfx/base_image.cpp b/engines/wintermute/Base/gfx/base_image.cpp deleted file mode 100644 index e6a6881807..0000000000 --- a/engines/wintermute/Base/gfx/base_image.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/jpeg.h" -#include "graphics/decoders/bmp.h" -#include "graphics/surface.h" -#include "engines/wintermute/graphics/tga.h" -#include "common/textconsole.h" -#include "common/stream.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { -#if 0 - _bitmap = bitmap; -#endif - _bitmap = NULL; - _palette = NULL; - _surface = NULL; - _decoder = NULL; - _deletableSurface = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBImage::~CBImage() { - /* delete _bitmap; */ - delete _decoder; - if (_deletableSurface) { - _deletableSurface->free(); - } - delete _deletableSurface; -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); -#endif -} - -bool CBImage::loadFile(const Common::String &filename) { - _filename = filename; - _filename.toLowercase(); - if (StringUtil::startsWith(filename, "savegame:", true)) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".png")) { - _decoder = new Graphics::PNGDecoder(); - } else if (_filename.hasSuffix(".bmp")) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".tga")) { - _decoder = new WinterMute::TGA(); - } else if (_filename.hasSuffix(".jpg")) { - _decoder = new Graphics::JPEGDecoder(); - } else { - error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); - } - _filename = filename; - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); - if (!file) return STATUS_FAILED; - - _decoder->loadStream(*file); - _surface = _decoder->getSurface(); - _palette = _decoder->getPalette(); - _gameRef->_fileManager->closeFile(file); - - return STATUS_OK; -} - -byte CBImage::getAlphaAt(int x, int y) { - if (!_surface) return 0xFF; - uint32 color = *(uint32 *)_surface->getBasePtr(x, y); - byte r, g, b, a; - _surface->format.colorToARGB(color, a, r, g, b); - return a; -} - -void CBImage::copyFrom(Graphics::Surface *surface) { - _surface = _deletableSurface = new Graphics::Surface(); - _deletableSurface->copyFrom(*surface); -} - -////////////////////////////////////////////////////////////////////////// -bool CBImage::saveBMPFile(const char *filename) { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; - else return STATUS_FAILED; -#endif - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::resize(int newWidth, int newHeight) { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); - - - FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); - if (newImg) { - FreeImage_Unload(_bitmap); - _bitmap = newImg; - return STATUS_OK; - } else return STATUS_FAILED; -#endif - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::writeBMPToStream(Common::WriteStream *stream) { - if (!_surface) return false; - - /* The following is just copied over and inverted to write-ops from the BMP-decoder */ - stream->writeByte('B'); - stream->writeByte('M'); - - /* Since we don't care during reads, we don't care during writes: */ - /* uint32 fileSize = */ - stream->writeUint32LE(54 + _surface->h * _surface->pitch); - /* uint16 res1 = */ - stream->writeUint16LE(0); - /* uint16 res2 = */ - stream->writeUint16LE(0); - const uint32 imageOffset = 54; - stream->writeUint32LE(imageOffset); - - const uint32 infoSize = 40; /* Windows v3 BMP */ - stream->writeUint32LE(infoSize); - - uint32 width = _surface->w; - int32 height = _surface->h; - stream->writeUint32LE(width); - stream->writeUint32LE((uint32)height); - - if (width == 0 || height == 0) - return false; - - if (height < 0) { - warning("Right-side up bitmaps not supported"); - return false; - } - - /* uint16 planes = */ stream->writeUint16LE(1); - const uint16 bitsPerPixel = 24; - stream->writeUint16LE(bitsPerPixel); - - const uint32 compression = 0; - stream->writeUint32LE(compression); - - /* uint32 imageSize = */ - stream->writeUint32LE(_surface->h * _surface->pitch); - /* uint32 pixelsPerMeterX = */ - stream->writeUint32LE(0); - /* uint32 pixelsPerMeterY = */ - stream->writeUint32LE(0); - const uint32 paletteColorCount = 0; - stream->writeUint32LE(paletteColorCount); - /* uint32 colorsImportant = */ - stream->writeUint32LE(0); - - // Start us at the beginning of the image (54 bytes in) - Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); - - // BGRA for 24bpp - if (bitsPerPixel == 24) - format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); - - Graphics::Surface *surface = _surface->convertTo(format); - - int srcPitch = width * (bitsPerPixel >> 3); - const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; - - for (int32 i = height - 1; i >= 0; i--) { - for (uint32 j = 0; j < width; j++) { - byte b, g, r; - uint32 color = *(uint32 *)surface->getBasePtr(j, i); - surface->format.colorToRGB(color, r, g, b); - stream->writeByte(b); - stream->writeByte(g); - stream->writeByte(r); - } - - for (int k = 0; k < extraDataLength; k++) { - stream->writeByte(0); - } - } - surface->free(); - delete surface; - return true; - - //*BufferSize = 0; -#if 0 - FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); - uint32 size; - byte *data; - FreeImage_AcquireMemory(fiMem, &data, &size); - - - byte *Buffer = new byte[size]; - memcpy(Buffer, data, size); - - FreeImage_CloseMemory(fiMem); - - if (BufferSize) *BufferSize = size; - - return Buffer; -#endif - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); - - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - - _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); -#endif - TransparentSurface temp(*origImage->_surface, false); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale(newWidth, newHeight); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_image.h b/engines/wintermute/Base/gfx/base_image.h deleted file mode 100644 index 29455d3f7a..0000000000 --- a/engines/wintermute/Base/gfx/base_image.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BIMAGE_H -#define WINTERMUTE_BIMAGE_H - -#include "engines/wintermute/Base/BBase.h" -#include "graphics/surface.h" -#include "graphics/pixelformat.h" -#include "graphics/decoders/image_decoder.h" -#include "common/endian.h" -#include "common/str.h" -#include "common/stream.h" - -struct FIBITMAP; - -namespace WinterMute { -class CBSurface; -class CBImage: CBBase { - -public: - CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); - ~CBImage(); - - bool loadFile(const Common::String &filename); - const Graphics::Surface *getSurface() const { - return _surface; - }; - const byte *getPalette() const { - return _palette; - } - byte getAlphaAt(int x, int y); - bool writeBMPToStream(Common::WriteStream *stream); - bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename); - bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(Graphics::Surface *surface); -private: - Common::String _filename; - Graphics::ImageDecoder *_decoder; - FIBITMAP *_bitmap; - const Graphics::Surface *_surface; - Graphics::Surface *_deletableSurface; - const byte *_palette; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/gfx/base_renderer.cpp b/engines/wintermute/Base/gfx/base_renderer.cpp deleted file mode 100644 index a2ecf16cd4..0000000000 --- a/engines/wintermute/Base/gfx/base_renderer.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/gfx/base_renderer.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { - _window = 0; - _clipperWindow = 0; - _active = false; - _ready = false; - _windowed = true; - _forceAlphaColor = 0x00; - - _width = _height = _bPP = 0; - CBPlatform::setRectEmpty(&_monitorRect); - - _realWidth = _realHeight = 0; - _drawOffsetX = _drawOffsetY = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBRenderer::~CBRenderer() { - deleteRectList(); - unclipCursor(); -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::initLoop() { - deleteRectList(); -} - - -////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::getObjectAt(int x, int y) { - Point32 point; - point.x = x; - point.y = y; - - for (int i = _rectList.getSize() - 1; i >= 0; i--) { - if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { - if (_rectList[i]->_precise) { - // frame - if (_rectList[i]->_frame) { - int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); - - if (_rectList[i]->_frame->_mirrorX) { - int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; - xx = width - xx; - } - - if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; - yy = height - yy; - } - - if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; - } - // region - else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; - } - } else return _rectList[i]->_owner; - } - } - - return (CBObject *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderer::deleteRectList() { - for (int i = 0; i < _rectList.getSize(); i++) { - delete _rectList[i]; - } - _rectList.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -bool CBRenderer::switchFullscreen() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::flip() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::initRenderer(int width, int height, bool windowed) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -void CBRenderer::onWindowChange() { -} - - -////////////////////////////////////////////////////////////////////// -bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::windowedBlt() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setup2D(bool Force) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setupLines() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { - for (int i = 0; i < width; i++) { - drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up - drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down - - drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left - drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fade(uint16 alpha) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(int left, int top, int right, int bottom) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setScreenViewport() { - return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(Rect32 *rect) { - return setViewport(rect->left + _drawOffsetX, - rect->top + _drawOffsetY, - rect->right + _drawOffsetX, - rect->bottom + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::takeScreenshot() { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::clipCursor() { - /* - if (!_windowed) { - Rect32 rc; - GetWindowRect(_window, &rc); - - // if "maintain aspect ratio" is in effect, lock mouse to visible area - rc.left = _drawOffsetX; - rc.top = _drawOffsetY; - rc.right = rc.left + _width; - rc.bottom = rc.top + _height; - - ::ClipCursor(&rc); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::unclipCursor() { - /* - if (!_windowed) ::ClipCursor(NULL); - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Point32 *p) { - if (p->x < _drawOffsetX) return false; - if (p->y < _drawOffsetY) return false; - if (p->x > _drawOffsetX + _width) return false; - if (p->y > _drawOffsetY + _height) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_renderer.h b/engines/wintermute/Base/gfx/base_renderer.h deleted file mode 100644 index b5f654e8ec..0000000000 --- a/engines/wintermute/Base/gfx/base_renderer.h +++ /dev/null @@ -1,128 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_H -#define WINTERMUTE_BRENDERER_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BBase.h" -#include "common/rect.h" - -namespace WinterMute { - -class CBImage; -class CBActiveRect; -class CBObject; -class CBSurface; -class CBRenderer: public CBBase { -public: - int _realWidth; - int _realHeight; - int _drawOffsetX; - int _drawOffsetY; - - virtual void dumpData(const char *filename) {}; - virtual CBImage *takeScreenshot(); - virtual bool setViewport(int left, int top, int right, int bottom); - virtual bool setViewport(Rect32 *Rect); - virtual bool setScreenViewport(); - virtual bool fade(uint16 Alpha); - virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); - virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); - CBRenderer(CBGame *inGame = NULL); - virtual ~CBRenderer(); - virtual bool setProjection() { - return STATUS_OK; - }; - - virtual bool windowedBlt(); - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - virtual void onWindowChange(); - virtual bool initRenderer(int width, int height, bool windowed); - virtual bool flip(); - virtual void initLoop(); - virtual bool switchFullscreen(); - virtual bool setup2D(bool force = false); - virtual bool setupLines(); - - virtual const char *getName() { - return ""; - }; - virtual bool displayDebugInfo() { - return STATUS_FAILED; - }; - virtual bool drawShaderQuad() { - return STATUS_FAILED; - } - - virtual float getScaleRatioX() const { - return 1.0f; - } - virtual float getScaleRatioY() const { - return 1.0f; - } - - virtual CBSurface *createSurface() = 0; - - bool clipCursor(); - bool unclipCursor(); - - CBObject *getObjectAt(int x, int y); - void deleteRectList(); - - virtual bool startSpriteBatch() { - return STATUS_OK; - }; - virtual bool endSpriteBatch() { - return STATUS_OK; - }; - bool pointInViewport(Point32 *P); - uint32 _forceAlphaColor; - uint32 _window; - uint32 _clipperWindow; - bool _active; - bool _ready; - bool _windowed; - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; - int _bPP; - int _height; - int _width; - - CBArray _rectList; -}; - -CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/gfx/base_surface.cpp b/engines/wintermute/Base/gfx/base_surface.cpp deleted file mode 100644 index dac0692d76..0000000000 --- a/engines/wintermute/Base/gfx/base_surface.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/gfx/base_surface.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { - _referenceCount = 0; - - _width = _height = 0; - - _filename = ""; - - _pixelOpReady = false; - - _ckDefault = true; - _ckRed = _ckGreen = _ckBlue = 0; - _lifeTime = 0; - _keepLoaded = false; - - _lastUsedTime = 0; - _valid = false; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface::~CBSurface() { - if (_pixelOpReady) endPixelOp(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::restore() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAt(int x, int y) { - return false; -} - -////////////////////////////////////////////////////////////////////// -bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::create(int Width, int Height) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::startPixelOp() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::endPixelOp() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAtLite(int x, int y) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::invalidate() { - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBSurface::prepareToDraw() { - _lastUsedTime = _gameRef->_liveTimer; - - if (!_valid) { - //_gameRef->LOG(0, "Reviving: %s", _filename); - return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSurface::setSize(int width, int height) { - _width = width; - _height = height; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/base_surface.h b/engines/wintermute/Base/gfx/base_surface.h deleted file mode 100644 index ed9ace5322..0000000000 --- a/engines/wintermute/Base/gfx/base_surface.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACE_H -#define WINTERMUTE_BSURFACE_H - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "graphics/surface.h" - -namespace WinterMute { - -class CBSurface: public CBBase { -public: - virtual bool invalidate(); - virtual bool prepareToDraw(); - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - - uint32 _lastUsedTime; - bool _valid; - int _lifeTime; - bool _keepLoaded; - - bool _pixelOpReady; - CBSurface(CBGame *inGame); - virtual ~CBSurface(); - - virtual bool displayHalfTrans(int x, int y, Rect32 rect); - virtual bool isTransparentAt(int x, int y); - virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool restore(); - virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual bool create(int Width, int Height); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { - return STATUS_FAILED; - } - virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); - virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool startPixelOp(); - virtual bool endPixelOp(); - virtual bool isTransparentAtLite(int x, int y); - void setSize(int width, int height); - - int _referenceCount; - - virtual int getWidth() { - return _width; - } - virtual int getHeight() { - return _height; - } - Common::String getFileNameStr() { return _filename; } - const char* getFileName() { return _filename.c_str(); } - //void SetWidth(int Width){ _width = Width; } - //void SetHeight(int Height){ _height = Height; } -protected: - Common::String _filename; - int _height; - int _width; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp deleted file mode 100644 index 923855686d..0000000000 --- a/engines/wintermute/Base/gfx/osystem/base_render_osystem.cpp +++ /dev/null @@ -1,701 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/Base/BSurfaceStorage.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "common/system.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "common/queue.h" - -namespace WinterMute { - -RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { - _colorMod = 0; - _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - _mirror |= TransparentSurface::FLIP_H; - if (surf) { - _surface = new Graphics::Surface(); - _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); - assert(_surface->format.bytesPerPixel == 4); - // Get a clipped copy of the surface - for (int i = 0; i < _surface->h; i++) { - memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); - } - // Then scale it if necessary - if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { - TransparentSurface src(*_surface, false); - Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); - _surface->free(); - delete _surface; - _surface = temp; - } - } else { - _surface = NULL; - } -} - -RenderTicket::~RenderTicket() { - if (_surface) { - _surface->free(); - delete _surface; - } -} - -bool RenderTicket::operator==(RenderTicket &t) { - if ((t._srcRect != _srcRect) || - (t._dstRect != _dstRect) || - (t._mirror != _mirror) || - (t._owner != _owner) || - (t._hasAlpha != _hasAlpha) || - (t._colorMod != _colorMod)) { - return false; - } - return true; -} - -CBRenderer *makeOSystemRenderer(CBGame *inGame) { - return new CBRenderOSystem(inGame); -} - -// TODO: Redo everything here. - -////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { - _renderSurface = new Graphics::Surface(); - _drawNum = 1; - _needsFlip = true; - - _borderLeft = _borderRight = _borderTop = _borderBottom = 0; - _ratioX = _ratioY = 1.0f; - setAlphaMod(255); - setColorMod(255, 255, 255); - _dirtyRect = NULL; - _disableDirtyRects = true; -} - -////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::~CBRenderOSystem() { - _renderSurface->free(); - delete _renderSurface; -#if 0 - if (_renderer) SDL_DestroyRenderer(_renderer); - if (_win) SDL_DestroyWindow(_win); - SDL_Quit(); -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; - -#if 0 - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); -#endif - _width = width; - _height = height; - _renderRect.setWidth(_width); - _renderRect.setHeight(_height); - - _realWidth = width; - _realHeight = height; - - - // find suitable resolution -/*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } -#else*/ - _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); - _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); -//#endif - - /* - _realWidth = 480; - _realHeight = 320; - */ - - - float origAspect = (float)_width / (float)_height; - float realAspect = (float)_realWidth / (float)_realHeight; - - float ratio; - if (origAspect < realAspect) { - // normal to wide - ratio = (float)_realHeight / (float)_height; - } else { - // wide to normal - ratio = (float)_realWidth / (float)_width; - } - - _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); - _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); - - _borderTop = (int)((_realHeight - (_height * ratio)) / 2); - _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); - - - - _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; - _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - -#if 0 - Uint32 flags = SDL_WINDOW_SHOWN; -#endif -#ifdef __IPHONEOS__ - //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; -#endif - - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); -// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; - - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); - g_system->beginGFXTransaction(); - g_system->initSize(_width, _height, &format); - OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - - if (gfxError != OSystem::kTransactionSuccess) { - warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return STATUS_FAILED; - } -#if 0 - _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); - - if (!_win) return STATUS_FAILED; -#endif - - g_system->showMouse(false); - -#ifdef __IPHONEOS__ - // SDL defaults to OGL ES2, which doesn't work on old devices - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); -#else - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif -#if 0 - _renderer = SDL_CreateRenderer(_win, -1, 0); - - if (!_renderer) return STATUS_FAILED; -#endif - _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _active = true; - - _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); - - return STATUS_OK; -} - -void CBRenderOSystem::setAlphaMod(byte alpha) { - byte r = RGBCOLGetR(_colorMod); - byte g = RGBCOLGetB(_colorMod); - byte b = RGBCOLGetB(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { - byte alpha = RGBCOLGetA(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::flip() { - if (!_disableDirtyRects) { - drawTickets(); - } - if (_needsFlip || _disableDirtyRects) { - if (_disableDirtyRects) { - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); - } - // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - delete _dirtyRect; - _dirtyRect = NULL; - g_system->updateScreen(); - _needsFlip = false; - } - _drawNum = 1; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { - //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); - //SDL_RenderClear(_renderer); - _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) - return STATUS_OK; - if (!rect) { - rect = &_renderRect; - } - _renderSurface->fillRect(*rect, _clearColor); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fade(uint16 Alpha) { - uint32 dwAlpha = 255 - Alpha; - return fadeToColor(dwAlpha << 24); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); - warning("Implement CBRenderOSystem::FadeToColor"); // TODO. - hasWarned = true; - } - - Common::Rect fillRect; - - if (rect) { - fillRect.left = rect->left; - fillRect.top = rect->top; - fillRect.setWidth(rect->width()); - fillRect.setHeight(rect->height()); - } else { - Rect32 rc; - _gameRef->getCurrentViewportRect(&rc); - fillRect.left = (int16)rc.left; - fillRect.top = (int16)rc.top; - fillRect.setWidth((int16)(rc.right - rc.left)); - fillRect.setHeight((int16)(rc.bottom - rc.top)); - } - modTargetRect(&fillRect); - - byte r = RGBCOLGetR(Color); - byte g = RGBCOLGetG(Color); - byte b = RGBCOLGetB(Color); - byte a = RGBCOLGetA(Color); - - //TODO: This is only here until I'm sure about the final pixelformat - uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) - _renderSurface->fillRect(fillRect, col); - else { - setAlphaMod(a); - setColorMod(r, g, b); - Graphics::Surface surf; - surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); - Common::Rect sizeRect(fillRect); - sizeRect.translate(-fillRect.top, -fillRect.left); - surf.fillRect(fillRect, col); - drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); - surf.free(); - _clearColor = col; - } - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - //SDL_RenderFillRect(_renderer, &fillRect); - - return STATUS_OK; -} - -void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { - if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); - // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); - return; - } - // Skip rects that are completely outside the screen: - if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { - return; - } - - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - drawFromTicket(*it); - return; - } - } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); - ticket->_colorMod = _colorMod; - drawFromTicket(ticket); -} - -void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { - addDirtyRect(renderTicket->_dstRect); - renderTicket->_isValid = false; -// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. -} - -void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == surf) { - invalidateTicket(*it); - } - } -} - -void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { - renderTicket->_wantsDraw = true; - // A new item always has _drawNum == 0 - if (renderTicket->_drawNum == 0) { - // In-order - if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { - renderTicket->_drawNum = _drawNum++; - _renderQueue.push_back(renderTicket); - addDirtyRect(renderTicket->_dstRect); - } else { - // Before something - Common::List::iterator pos; - for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { - if ((*pos)->_drawNum >= _drawNum) { - break; - } - } - _renderQueue.insert(pos, renderTicket); - Common::List::iterator it; - renderTicket->_drawNum = _drawNum++; - // Increment the following tickets, so they still are in line - for (it = pos; it != _renderQueue.end(); it++) { - (*it)->_drawNum++; - (*it)->_wantsDraw = false; - } - addDirtyRect(renderTicket->_dstRect); - } - } else { - // Was drawn last round, still in the same order - if (_drawNum == renderTicket->_drawNum) { - _drawNum++; - } else { - // Remove the ticket from the list - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it) == renderTicket) { - it = _renderQueue.erase(it); - break; - } else { - it++; - } - } - // Is not in order, so readd it as if it was a new ticket - renderTicket->_drawNum = 0; - drawFromTicket(renderTicket); - } - } -} - -void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { - if (!_dirtyRect) { - _dirtyRect = new Common::Rect(rect); - } else { - _dirtyRect->extend(rect); - } - _dirtyRect->clip(_renderRect); -// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); -} - -void CBRenderOSystem::drawTickets() { - RenderQueueIterator it = _renderQueue.begin(); - // Clean out the old tickets - int decrement = 0; - while (it != _renderQueue.end()) { - if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { - RenderTicket* ticket = *it; - addDirtyRect((*it)->_dstRect); - //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); - it = _renderQueue.erase(it); - delete ticket; - decrement++; - } else { - (*it)->_drawNum -= decrement; - it++; - } - } - if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) - return; - // The color-mods are stored in the RenderTickets on add, since we set that state again during - // draw, we need to keep track of what it was prior to draw. - uint32 oldColorMod = _colorMod; -// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); - - // Apply the clear-color to the dirty rect. - _renderSurface->fillRect(*_dirtyRect, _clearColor); - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - RenderTicket *ticket = *it; - if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { - // dstClip is the area we want redrawn. - Common::Rect dstClip(ticket->_dstRect); - // reduce it to the dirty rect - dstClip.clip(*_dirtyRect); - // we need to keep track of the position to redraw the dirty rect - Common::Rect pos(dstClip); - int16 offsetX = ticket->_dstRect.left; - int16 offsetY = ticket->_dstRect.top; - // convert from screen-coords to surface-coords. - dstClip.translate(-offsetX, -offsetY); - - _colorMod = ticket->_colorMod; - drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); - _needsFlip = true; - } - // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) - ticket->_wantsDraw = false; - } - g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - - // Revert the colorMod-state. - _colorMod = oldColorMod; -} - -// Replacement for SDL2's SDL_RenderCopy -void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { - TransparentSurface src(*surf, false); - bool doDelete = false; - if (!clipRect) { - doDelete = true; - clipRect = new Common::Rect(); - clipRect->setWidth(surf->w); - clipRect->setHeight(surf->h); - } - - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) - delete clipRect; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - static bool hasWarned = false; - if (!hasWarned) { - warning("CBRenderOSystem::DrawLine - not fully ported yet"); - hasWarned = true; - } - byte r = RGBCOLGetR(color); - byte g = RGBCOLGetG(color); - byte b = RGBCOLGetB(color); - byte a = RGBCOLGetA(color); - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - - Point32 point1, point2; - point1.x = x1; - point1.y = y1; - pointToScreen(&point1); - - point2.x = x2; - point2.y = y2; - pointToScreen(&point2); - - // TODO: This thing is mostly here until I'm sure about the final color-format. - uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); - _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); - //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderOSystem::takeScreenshot() { -// TODO: Fix this - warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); - CBImage *screenshot = new CBImage(_gameRef); - screenshot->copyFrom(_renderSurface); - return screenshot; -#if 0 - SDL_Rect viewport; - - SDL_RenderGetViewport(_renderer, &viewport); - - SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) return NULL; - - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; - - FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - - int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; - memcpy(bits, src, bytespp * viewport.w); - } - - return new CBImage(_gameRef, dib); -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::switchFullscreen() { - /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); - else SDL_SetWindowFullscreen(_win, SDL_FALSE); - - _windowed = !_windowed; - */ - _gameRef->_registry->writeBool("Video", "Windowed", _windowed); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBRenderOSystem::getName() { - if (_name.empty()) { -#if 0 - if (_renderer) { - SDL_RendererInfo info; - SDL_GetRendererInfo(_renderer, &info); - _name = AnsiString(info.name); - } -#endif - } - return _name.c_str(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { - Common::Rect rect; - // TODO: Hopefully this is the same logic that ScummVM uses. - rect.left = (int16)(left + _borderLeft); - rect.top = (int16)(top + _borderTop); - rect.right = (int16)((right - left) * _ratioX); - rect.bottom = (int16)((bottom - top) * _ratioY); - - // TODO fix this once viewports work correctly in SDL/landscape -#ifndef __IPHONEOS__ - //SDL_RenderSetViewport(GetSdlRenderer(), &rect); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::modTargetRect(Common::Rect *rect) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * _ratioX); - rect->h = MathUtil::RoundUp(rect->h * _ratioY); -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointFromScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; - point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointToScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; -#endif -} - -////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::dumpData(const char *filename) { - warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO -#if 0 - FILE *f = fopen(filename, "wt"); - if (!f) return; - - CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - - int TotalKB = 0; - int TotalLoss = 0; - fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; - if (!Surf->_filename) continue; - if (!Surf->_valid) continue; - - fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); - - int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; - - TotalKB += kb; - fprintf(f, "%d;", kb); - fprintf(f, "\n"); - } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); - - - fclose(f); - _gameRef->LOG(0, "Texture Stats Dump completed."); - _gameRef->QuickMessage("Texture Stats Dump completed."); -#endif -} - -CBSurface *CBRenderOSystem::createSurface() { - return new CBSurfaceOSystem(_gameRef); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/osystem/base_render_osystem.h b/engines/wintermute/Base/gfx/osystem/base_render_osystem.h deleted file mode 100644 index 44bd1d3906..0000000000 --- a/engines/wintermute/Base/gfx/osystem/base_render_osystem.h +++ /dev/null @@ -1,129 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRENDERER_SDL_H -#define WINTERMUTE_BRENDERER_SDL_H - -#include "engines/wintermute/Base/gfx/base_renderer.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "common/list.h" - -namespace WinterMute { -class CBSurfaceOSystem; -class RenderTicket { -public: - RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); - RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} - ~RenderTicket(); - Graphics::Surface *_surface; - Common::Rect _srcRect; - Common::Rect _dstRect; - uint32 _mirror; - bool _hasAlpha; - - bool _isValid; - bool _wantsDraw; - uint32 _drawNum; - uint32 _colorMod; - - CBSurfaceOSystem *_owner; - bool operator==(RenderTicket &a); -}; - -class CBRenderOSystem : public CBRenderer { -public: - CBRenderOSystem(CBGame *inGame); - ~CBRenderOSystem(); - - const char *getName(); - - bool initRenderer(int width, int height, bool windowed); - bool flip(); - bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - - bool fade(uint16 alpha); - bool fadeToColor(uint32 color, Common::Rect *rect = NULL); - - bool switchFullscreen(); - - bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - - CBImage *takeScreenshot(); - - void setAlphaMod(byte alpha); - void setColorMod(byte r, byte g, byte b); - void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); - void drawFromTicket(RenderTicket *renderTicket); - - bool setViewport(int left, int top, int right, int bottom); - - void modTargetRect(Common::Rect *rect); - void pointFromScreen(Point32 *point); - void pointToScreen(Point32 *point); - - void dumpData(const char *filename); - - float getScaleRatioX() const { - return _ratioX; - } - float getScaleRatioY() const { - return _ratioY; - } - - void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); - CBSurface *createSurface(); -private: - void addDirtyRect(const Common::Rect &rect); - void drawTickets(); - void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); - typedef Common::List::iterator RenderQueueIterator; - Common::Rect *_dirtyRect; - Common::List _renderQueue; - bool _needsFlip; - uint32 _drawNum; - Common::Rect _renderRect; - Graphics::Surface *_renderSurface; - AnsiString _name; - - int _borderLeft; - int _borderTop; - int _borderRight; - int _borderBottom; - - bool _disableDirtyRects; - float _ratioX; - float _ratioY; - uint32 _colorMod; - uint32 _clearColor; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp deleted file mode 100644 index 57b3c61b8a..0000000000 --- a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.cpp +++ /dev/null @@ -1,532 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/PlatformSDL.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/bmp.h" -#include "graphics/decoders/jpeg.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/graphics/tga.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "common/stream.h" -#include "common/system.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { - _surface = new Graphics::Surface(); - _alphaMask = NULL; - _hasAlpha = true; - _lockPixels = NULL; - _lockPitch = 0; - _loaded = false; -} - -////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::~CBSurfaceOSystem() { - //TODO - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - - delete[] _alphaMask; - _alphaMask = NULL; - - _gameRef->addMem(-_width * _height * 4); - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); -} - -bool hasTransparency(Graphics::Surface *surf) { - if (surf->format.bytesPerPixel != 4) { - warning("hasTransparency:: non 32 bpp surface passed as argument"); - return false; - } - uint8 r, g, b, a; - for (int i = 0; i < surf->h; i++) { - for (int j = 0; j < surf->w; j++) { - uint32 pix = *(uint32 *)surf->getBasePtr(j, i); - surf->format.colorToARGB(pix, a, r, g, b); - if (a != 255) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ - _filename = filename; -// const Graphics::Surface *surface = image->getSurface(); - - if (defaultCK) { - ckRed = 255; - ckGreen = 0; - ckBlue = 255; - } - - _ckDefault = defaultCK; - _ckRed = ckRed; - _ckGreen = ckGreen; - _ckBlue = ckBlue; - - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) - _lifeTime = lifeTime; - - _keepLoaded = keepLoaded; - if (_keepLoaded) _lifeTime = -1; - - return STATUS_OK; -} - -void CBSurfaceOSystem::finishLoad() { - CBImage *image = new CBImage(_gameRef); - image->loadFile(_filename); - - _width = image->getSurface()->w; - _height = image->getSurface()->h; - - bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); - if (isSaveGameGrayscale) { - warning("grayscaleConversion not yet implemented"); - /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ - } - - // no alpha, set color key - /* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. - delete _surface; - if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); - } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); - } else { - _surface = new Graphics::Surface(); - _surface->copyFrom(*image->getSurface()); - } - - _hasAlpha = hasTransparency(_surface); - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Surface-textures not fully ported yet"); - hasWarned = true; - } - //delete imgDecoder; -#if 0 - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!_texture) { - SDL_FreeSurface(surf); - delete imgDecoder; - return STATUS_FAILED; - } - - GenAlphaMask(surf); - - SDL_FreeSurface(surf); - delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. -#endif - - _valid = true; - - _gameRef->addMem(_width * _height * 4); - - delete image; - - _loaded = true; -} - -////////////////////////////////////////////////////////////////////////// -void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); - return; - - delete[] _alphaMask; - _alphaMask = NULL; - if (!surface) return; -#if 0 - SDL_LockSurface(surface); -#endif - bool hasColorKey; - /* uint32 colorKey; */ - uint8 ckRed, ckGreen, ckBlue; - /* if (SDL_GetColorKey(surface, &colorKey) == 0) { - hasColorKey = true; - SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); - } else hasColorKey = false; - */ //TODO - _alphaMask = new byte[surface->w * surface->h]; - - bool hasTransparency = false; - for (int y = 0; y < surface->h; y++) { - for (int x = 0; x < surface->w; x++) { - uint32 pixel = getPixel(surface, x, y); - - uint8 r, g, b, a; - surface->format.colorToARGB(pixel, a, r, g, b); - //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) - a = 0; - - _alphaMask[y * surface->w + x] = a; - if (a < 255) hasTransparency = true; - } - } -#if 0 - SDL_UnlockSurface(surface); -#endif - if (!hasTransparency) { - delete[] _alphaMask; - _alphaMask = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { - warning("CBSurfaceOSystem::GetPixel - Not ported yet"); - int bpp = surface->format.bytesPerPixel; - /* Here p is the address to the pixel we want to retrieve */ - uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; - - switch (bpp) { - case 1: - return *p; - break; - - case 2: - return *(uint16 *)p; - break; - - case 3: -#ifdef SCUMM_BIG_ENDIAN - // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; -#else - //else - return p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - return *(uint32 *)p; - break; - - default: - return 0; /* shouldn't happen, but avoids warnings */ - } - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(int width, int height) { - warning("CBSurfaceOSystem::Create not ported yet"); //TODO -#if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); -#endif - _width = width; - _height = height; - - _gameRef->addMem(_width * _height * 4); - - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO -#if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); -#endif - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - _width = surface->w; - _height = surface->h; -#if 0 - _gameRef->AddMem(_width * _height * 4); -#endif - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAt(int x, int y) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); - hasWarned = true; - } -#if 0 - int access; - int width, height; - //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - - StartPixelOp(); - bool ret = isTransparentAtLite(X, Y); - EndPixelOp(); - - return ret; -#endif - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { - //if (!_lockPixels) return false; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); - hasWarned = true; - } - if (_surface->format.bytesPerPixel == 4) { - uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); - uint8 r, g, b, a; - _surface->format.colorToARGB(pixel, a, r, g, b); - if (a <= 128) { - return true; - } else { - return false; - } - } -#if 0 - uint32 format; - int access; - int width, height; - - //SDL_QueryTexture(_texture, &format, &access, &width, &height); - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; - - if (!_alphaMask) return false; - else return _alphaMask[Y * width + X] <= 128; -#endif - return false; - /* - Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); - Uint32 pixel = dst[X]; - - SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); - SDL_FreeFormat(pixelFormat); - - return a <= 128; - */ -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::startPixelOp() { - //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); - // Any pixel-op makes the caching useless: - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::endPixelOp() { - //SDL_UnlockTexture(_texture); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - - if (!_loaded) { - finishLoad(); - } - - if (renderer->_forceAlphaColor != 0) - alpha = renderer->_forceAlphaColor; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. - hasWarned = true; - } - - byte r = RGBCOLGetR(alpha); - byte g = RGBCOLGetG(alpha); - byte b = RGBCOLGetB(alpha); - byte a = RGBCOLGetA(alpha); - - renderer->setAlphaMod(a); - renderer->setColorMod(r, g, b); -#if 0 - SDL_SetTextureColorMod(_texture, r, g, b); - SDL_SetTextureAlphaMod(_texture, a); - - if (AlphaDisable) - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - else - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); -#endif - // TODO: This _might_ miss the intended behaviour by 1 in each direction - // But I think it fits the model used in Wintermute. - Common::Rect srcRect; - srcRect.left = rect->left; - srcRect.top = rect->top; - srcRect.setWidth(rect->right - rect->left); - srcRect.setHeight(rect->bottom - rect->top); - - Common::Rect position; - position.left = x + offsetX; - position.top = y + offsetY; - // TODO: Scaling... - - if (position.left == -1) { - position.left = 0; // TODO: Something is wrong - } - if (position.top == -1) { - position.top = 0; // TODO: Something is wrong - } - - position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); - position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); - - renderer->modTargetRect(&position); - - /* position.left += offsetX; - position.top += offsetY;*/ - - // TODO: This actually requires us to have the SAME source-offsets every time, - // But no checking is in place for that yet. - - bool hasAlpha; - if (_hasAlpha && !alphaDisable) { - hasAlpha = true; - } else { - hasAlpha = false; - } - if (alphaDisable) { - warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); - } - - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); -#if 0 - SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); -#endif - - return STATUS_OK; -} - -bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { - _loaded = true; - _surface->copyFrom(surface); - _hasAlpha = hasAlpha; - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h deleted file mode 100644 index a5298706a3..0000000000 --- a/engines/wintermute/Base/gfx/osystem/base_surface_osystem.h +++ /dev/null @@ -1,101 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESDL_H -#define WINTERMUTE_BSURFACESDL_H - -#include "graphics/surface.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "common/list.h" - -namespace WinterMute { -struct TransparentSurface; -class CBImage; -class CBSurfaceOSystem : public CBSurface { -public: - CBSurfaceOSystem(CBGame *inGame); - ~CBSurfaceOSystem(); - - bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); - bool create(int width, int height); - - bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - - bool isTransparentAt(int x, int y); - bool isTransparentAtLite(int x, int y); - - bool startPixelOp(); - bool endPixelOp(); - - - bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); - /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); - static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); - static long DLL_CALLCONV TellProc(fi_handle handle);*/ - virtual int getWidth() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->w; - } - return _width; - } - virtual int getHeight() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->h; - } - return _height; - } - -private: - Graphics::Surface *_surface; - bool _loaded; - void finishLoad(); - bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); - void genAlphaMask(Graphics::Surface *surface); - uint32 getPixel(Graphics::Surface *surface, int x, int y); - - bool _hasAlpha; - void *_lockPixels; - int _lockPitch; - byte *_alphaMask; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/Base/particles/PartEmitter.cpp b/engines/wintermute/Base/particles/PartEmitter.cpp deleted file mode 100644 index e113ab7399..0000000000 --- a/engines/wintermute/Base/particles/PartEmitter.cpp +++ /dev/null @@ -1,1199 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/particles/PartEmitter.h" -#include "engines/wintermute/Base/particles/PartParticle.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include "common/math.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CPartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - _width = _height = 0; - - CBPlatform::setRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = Owner; -} - - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - for (int i = 0; i < _forces.getSize(); i++) { - delete _forces[i]; - } - _forces.removeAll(); - - - for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; - } - _sprites.removeAll(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; - - // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; - } - - // check if file exists - Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); - if (!File) { - _gameRef->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else _gameRef->_fileManager->closeFile(File); - - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; - _sprites.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; - - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); - - float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); - - float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); - - int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); - - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); - - if (!CBPlatform::isRectEmpty(&_border)) { - int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); - int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); - int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); - int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - - particle->_border = _border; - particle->_border.left += thicknessLeft; - particle->_border.right -= thicknessRight; - particle->_border.top += thicknessTop; - particle->_border.bottom -= thicknessBottom; - } - - Vector2 vecPos((float)posX, (float)posY); - Vector2 vecVel(0, velocity); - - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); - particle->_alpha1 = alpha; - particle->_alpha2 = alpha; - } - - particle->_creationTime = currentTime; - particle->_pos = vecPos; - particle->_posZ = posZ; - particle->_velocity = vecVel; - particle->_scale = scale; - particle->_lifeTime = lifeTime; - particle->_rotation = rotation; - particle->_angVelocity = angVelocity; - particle->_growthRate = growthRate; - particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); - particle->fadeIn(currentTime, _fadeInTime); - - - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->update(this, currentTime, timerDelta); - - if (!_particles[i]->_isDead) numLive++; - } - - - // we're understaffed - if (numLive < _maxParticles) { - bool needsSort = false; - if ((int)(currentTime - _lastGenTime) > _genInterval) { - _lastGenTime = currentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return STATUS_OK; - } - - int toGen = MIN(_genAmount, _maxParticles - numLive); - while (toGen > 0) { - int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - CPartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { - particle = new CPartParticle(_gameRef); - _particles.add(particle); - } - initParticle(particle, currentTime, timerDelta); - needsSort = true; - - toGen--; - } - } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - sortParticlesByZ(); - - // we actually generated some particles and we're not in fast-forward mode - if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::display(CBRegion *region) { - if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); - - for (int i = 0; i < _particles.getSize(); i++) { - if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; - } - - _particles[i]->display(this); - } - - if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 delta = 500; - int steps = _overheadTime / delta; - uint32 currentTime = _gameRef->_timer - _overheadTime; - - for (int i = 0; i < steps; i++) { - updateInternal(currentTime, delta); - currentTime += delta; - } - _overheadTime = 0; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::sortParticlesByZ() { - // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; - - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; - - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new CPartForce(_gameRef); - if (force) { - force->setName(name); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeForce(const char *name) { - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - delete _forces[i]; - _forces.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetBorder") == 0) { - stack->correctParams(4); - int borderX = stack->pop()->getInt(); - int borderY = stack->pop()->getInt(); - int borderWidth = stack->pop()->getInt(); - int borderHeight = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBorderThickness") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Start") == 0) { - stack->correctParams(1); - _overheadTime = stack->pop()->getInt(); - stack->pushBool(DID_SUCCEED(start())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Stop") == 0) { - stack->correctParams(0); - - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Resume") == 0) { - stack->correctParams(0); - _running = true; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddGlobalForce") == 0) { - stack->correctParams(3); - const char *forceName = stack->pop()->getString(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddPointForce") == 0) { - stack->correctParams(5); - const char *forceName = stack->pop()->getString(); - int posX = stack->pop()->getInt(); - int posY = stack->pop()->getInt(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveForce") == 0) { - stack->correctParams(1); - const char *forceName = stack->pop()->getString(); - - stack->pushBool(DID_SUCCEED(removeForce(forceName))); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - -////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scValue->setFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scValue->setFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->setBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _scValue->setFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _scValue->setFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->setBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _scValue->setInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _scValue->setInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->setBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _scValue->setInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _scValue->setInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->setFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->setFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _scValue->setFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _scValue->setFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _scValue->setInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _scValue->setInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->setBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _scValue->setInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { - int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; - } - _scValue->setInt(numAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->setInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->setInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _scValue->setInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _scValue->setInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->setInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->setFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->setFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->setBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _scValue->setBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); - - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); - - persistMgr->transfer(TMEMBER(_velocity1)); - persistMgr->transfer(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); - - persistMgr->transfer(TMEMBER(_scale1)); - persistMgr->transfer(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); - - persistMgr->transfer(TMEMBER(_maxParticles)); - - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); - - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); - - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); - - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); - - persistMgr->transfer(TMEMBER(_angVelocity1)); - persistMgr->transfer(TMEMBER(_angVelocity2)); - - persistMgr->transfer(TMEMBER(_rotation1)); - persistMgr->transfer(TMEMBER(_rotation2)); - - persistMgr->transfer(TMEMBER(_growthRate1)); - persistMgr->transfer(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - - persistMgr->transfer(TMEMBER(_useRegion)); - - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - - persistMgr->transfer(TMEMBER(_emitEvent)); - persistMgr->transfer(TMEMBER(_owner)); - - - _sprites.persist(persistMgr); - - int numForces; - if (persistMgr->_saving) { - numForces = _forces.getSize(); - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(_gameRef); - force->persist(persistMgr); - _forces.add(force); - } - } - - int numParticles; - if (persistMgr->_saving) { - numParticles = _particles.getSize(); - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(_gameRef); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartEmitter.h b/engines/wintermute/Base/particles/PartEmitter.h deleted file mode 100644 index 92918927ea..0000000000 --- a/engines/wintermute/Base/particles/PartEmitter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/particles/PartForce.h" - -namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { -public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) - - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); - - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - Rect32 _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - int _fadeOutTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - CBScriptHolder *_owner; - - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(CBRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); - - CBArray _forces; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - CPartForce *addForceByName(const char *name); - int static compareZ(const void *obj1, const void *obj2); - bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - bool updateInternal(uint32 currentTime, uint32 timerDelta); - uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/particles/PartForce.cpp b/engines/wintermute/Base/particles/PartForce.cpp deleted file mode 100644 index 69f3f274d3..0000000000 --- a/engines/wintermute/Base/particles/PartForce.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/particles/PartForce.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartForce::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartForce.h b/engines/wintermute/Base/particles/PartForce.h deleted file mode 100644 index d895e22ee7..0000000000 --- a/engines/wintermute/Base/particles/PartForce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BNamedObject.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartForce : public CBNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - bool persist(CBPersistMgr *PersistMgr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/particles/PartParticle.cpp b/engines/wintermute/Base/particles/PartParticle.cpp deleted file mode 100644 index 37f9796fe7..0000000000 --- a/engines/wintermute/Base/particles/PartParticle.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/particles/PartParticle.h" -#include "engines/wintermute/Base/particles/PartEmitter.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" -#include "common/str.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - CBPlatform::setRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(_gameRef, _gameRef); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { - if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - - return STATUS_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _isDead = true; - return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - - return STATUS_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) - fadeOut(currentTime, emitter->_fadeOutTime); - else - _isDead = true; - } - } - - // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) - fadeOut(currentTime, emitter->_fadeOutTime); - } - if (_state != PARTICLE_NORMAL) return STATUS_OK; - - // update alpha - if (_lifeTime > 0) { - int age = (int)(currentTime - _creationTime); - int alphaDelta = (int)(_alpha2 - _alpha1); - - _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); - } - - // update position - float elapsedTime = (float)timerDelta / 1000.f; - - for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; - switch (force->_type) { - case CPartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case CPartForce::FORCE_POINT: { - Vector2 vecDist = force->_pos - _pos; - float dist = fabs(vecDist.length()); - - dist = 100.0f / dist; - - _velocity += force->_direction * dist * elapsedTime; - } - break; - } - } - _pos += _velocity * elapsedTime; - - // update rotation - _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * elapsedTime; - else - _scale += _growthRate * elapsedTime; - - if (_scale <= 0.0f) - _isDead = true; - - - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::display(CPartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; - - _sprite->GetCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_angVelocity)); - persistMgr->transfer(TMEMBER(_rotation)); - persistMgr->transfer(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - - if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/particles/PartParticle.h b/engines/wintermute/Base/particles/PartParticle.h deleted file mode 100644 index 02913e3d35..0000000000 --- a/engines/wintermute/Base/particles/PartParticle.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTPARTICLE_H -#define WINTERMUTE_PARTPARTICLE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartEmitter; -class CBSprite; -class CBPersistMgr; - -class CPartParticle : public CBBase { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - CBSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(CPartEmitter *emitter); - - bool setSprite(const char *filename); - - bool fadeIn(uint32 currentTime, int fadeTime); - bool fadeOut(uint32 currentTime, int fadeTime); - - bool persist(CBPersistMgr *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp deleted file mode 100644 index e825e5ff97..0000000000 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Sys/SysInstance.h" -#include "engines/wintermute/Base/scriptables/SXArray.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXArray, false) - -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { - return new CSXArray(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); - - int numParams = stack->pop()->getInt(0); - - if (numParams == 1) _length = stack->pop()->getInt(0); - else if (numParams > 1) { - _length = numParams; - char paramName[20]; - for (int i = 0; i < numParams; i++) { - sprintf(paramName, "%d", i); - _values->setProp(paramName, stack->pop()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXArray::scToString() { - static char dummy[32768]; // TODO: Get rid of static. - strcpy(dummy, ""); - char propName[20]; - for (int i = 0; i < _length; i++) { - sprintf(propName, "%d", i); - CScValue *val = _values->getProp(propName); - if (val) { - if (strlen(dummy) + strlen(val->getString()) < 32768) { - strcat(dummy, val->getString()); - } - } - - if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); - } - return dummy; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Push - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Push") == 0) { - int numParams = stack->pop()->getInt(0); - char paramName[20]; - - for (int i = 0; i < numParams; i++) { - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, stack->pop(), true); - } - stack->pushInt(_length); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pop - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Pop") == 0) { - - stack->correctParams(0); - - if (_length > 0) { - char paramName[20]; - sprintf(paramName, "%d", _length - 1); - stack->push(_values->getProp(paramName)); - _values->deleteProp(paramName); - _length--; - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("array"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(_length); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char ParamName[20]; - if (validNumber(name, ParamName)) { - return _values->getProp(ParamName); - } else return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length") == 0) { - int OrigLength = _length; - _length = MAX(value->getInt(0), 0); - - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->deleteProp(PropName); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char paramName[20]; - if (validNumber(name, paramName)) { - int Index = atoi(paramName); - if (Index >= _length) _length = Index + 1; - return _values->setProp(paramName, value); - } else return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_length)); - persistMgr->transfer(TMEMBER(_values)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::validNumber(const char *origStr, char *outStr) { - bool isNumber = true; - for (uint32 i = 0; i < strlen(origStr); i++) { - if (!(origStr[i] >= '0' && origStr[i] <= '9')) { - isNumber = false; - break; - } - } - - if (isNumber) { - int index = atoi(origStr); - sprintf(outStr, "%d", index); - return true; - } else return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::push(CScValue *val) { - char paramName[20]; - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, val, true); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXArray.h b/engines/wintermute/Base/scriptables/SXArray.h deleted file mode 100644 index fcf29f7032..0000000000 --- a/engines/wintermute/Base/scriptables/SXArray.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CSXArray : public CBScriptable { -public: - bool push(CScValue *Val); - bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - int _length; - CScValue *_values; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp deleted file mode 100644 index 214de237fe..0000000000 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/SXDate.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXDate, false) - -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(6); - - memset(&_tm, 0, sizeof(_tm)); - - CScValue *valYear = stack->pop(); - _tm.tm_year = valYear->getInt() - 1900; - _tm.tm_mon = stack->pop()->getInt() - 1; - _tm.tm_mday = stack->pop()->getInt(); - _tm.tm_hour = stack->pop()->getInt(); - _tm.tm_min = stack->pop()->getInt(); - _tm.tm_sec = stack->pop()->getInt(); - - if (valYear->isNULL()) { - g_system->getTimeAndDate(_tm); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { - -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXDate::scToString() { - // TODO: Make this more stringy, and less ISO 8601-like - _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); - return _strRep.c_str(); -#if 0 - return asctime(&_tm); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetYear - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetYear") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_year + 1900); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMonth") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mon + 1); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDate") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mday); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHours") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_hour); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMinutes") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_min); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSeconds") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_sec); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetWeekday - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWeekday") == 0) { - stack->correctParams(0); - warning("GetWeekday returns a wrong value on purpose"); - stack->pushInt(_tm.tm_mday % 7); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetYear - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetYear") == 0) { - stack->correctParams(1); - _tm.tm_year = stack->pop()->getInt() - 1900; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMonth") == 0) { - stack->correctParams(1); - _tm.tm_mon = stack->pop()->getInt() - 1; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDate") == 0) { - stack->correctParams(1); - _tm.tm_mday = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHours") == 0) { - stack->correctParams(1); - _tm.tm_hour = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMinutes") == 0) { - stack->correctParams(1); - _tm.tm_min = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSeconds") == 0) { - stack->correctParams(1); - _tm.tm_sec = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetCurrentTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCurrentTime") == 0) { - stack->correctParams(0); - g_system->getTimeAndDate(_tm); - stack->pushNULL(); - return STATUS_OK; - } - - else - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("date"); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Name")==0){ - setName(value->getString()); - return STATUS_OK; - } - - else*/ return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_tm.tm_year)); - persistMgr->transfer(TMEMBER(_tm.tm_mon)); - persistMgr->transfer(TMEMBER(_tm.tm_mday)); - persistMgr->transfer(TMEMBER(_tm.tm_hour)); - persistMgr->transfer(TMEMBER(_tm.tm_min)); - persistMgr->transfer(TMEMBER(_tm.tm_sec)); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CSXDate::scCompare(CBScriptable *Value) { - TimeDate time1 = _tm; - TimeDate time2 = ((CSXDate *)Value)->_tm; - - if (time1.tm_year < time2.tm_year) { - return -1; - } else if (time1.tm_year == time2.tm_year) { - if (time1.tm_mon < time2.tm_mon) { - return -1; - } else if (time1.tm_mon == time2.tm_mon) { - if (time1.tm_mday < time2.tm_mday) { - return -1; - } else if (time1.tm_mday == time2.tm_mday) { - if (time1.tm_hour < time2.tm_hour) { - return -1; - } else if (time1.tm_hour == time2.tm_hour) { - if (time1.tm_min < time2.tm_min) { - return -1; - } else if (time1.tm_min == time2.tm_min) { - if (time1.tm_sec < time2.tm_sec) { - return -1; - } else if (time1.tm_sec == time2.tm_sec) { - return 0; // Equal - } else { - return 1; // Sec - } - } else { - return 1; // Minute - } - } else { - return 1; // Hour - } - } else { - return 1; // Day - } - } else { - return 1; // Month - } - } else { - return 1; // Year - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXDate.h b/engines/wintermute/Base/scriptables/SXDate.h deleted file mode 100644 index cb1ac4f98f..0000000000 --- a/engines/wintermute/Base/scriptables/SXDate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXDATE_H -#define WINTERMUTE_SXDATE_H - -#include "common/system.h" -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CSXDate : public CBScriptable { -public: - int scCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - char *_string; - TimeDate _tm; -private: - Common::String _strRep; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp deleted file mode 100644 index f6c34545d0..0000000000 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ /dev/null @@ -1,779 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Sys/SysClassRegistry.h" -#include "engines/wintermute/Sys/SysClass.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/file/BFile.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/SXFile.h" - -// Note: This code is completely untested, as I have yet to find a game that uses SXFile. - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXFile, false) - -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { - return new CSXFile(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - _filename = NULL; - if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXFile::cleanup() { - delete[] _filename; - _filename = NULL; - close(); -} - - -////////////////////////////////////////////////////////////////////////// -void CSXFile::close() { - if (_readFile) { - _gameRef->_fileManager->closeFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - _writeFile->finalize(); - delete _writeFile; - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXFile::scToString() { - if (_filename) return _filename; - else return "[file object]"; -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFilename") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - cleanup(); - CBUtils::setString(&_filename, filename); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenAsText / OpenAsBinary - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->correctParams(1); - close(); - _mode = stack->pop()->getInt(1); - if (_mode < 1 || _mode > 3) { - script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); - _mode = 1; - } - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) { - //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } else { - if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = openForWrite(_filename, false); - else _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) _writeFile = openForWrite(_filename, true); - else _writeFile = openForAppend(_filename, true); - } - - if (!_writeFile) { - //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } - - if (_readFile || _writeFile) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - close(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPosition") == 0) { - stack->correctParams(1); - if (_mode == 0) { - script->runtimeError("File.%s: File is not open", name); - stack->pushBool(false); - } else { - int Pos = stack->pop()->getInt(); - stack->pushBool(setPos(Pos)); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Delete - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delete") == 0) { - stack->correctParams(0); - close(); - stack->pushBool(CBPlatform::deleteFile(_filename) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Copy - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Copy") == 0) { - stack->correctParams(2); - const char *Dest = stack->pop()->getString(); - bool Overwrite = stack->pop()->getBool(true); - - close(); - stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadLine") == 0) { - stack->correctParams(0); - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - bool foundNewLine = false; - bool ret = STATUS_FAILED; - do { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == '\n') { - buf[counter] = '\0'; - foundNewLine = true; - break; - } else if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } while (DID_SUCCEED(ret)); - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (!foundNewLine && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadText") == 0) { - stack->correctParams(1); - int textLen = stack->pop()->getInt(); - - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - - bool ret = STATUS_FAILED; - while (counter < (uint32)textLen) { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (textLen > 0 && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteLine / WriteText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->correctParams(1); - const char *line = stack->pop()->getString(); - if (!_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in text mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - Common::String writeLine; - if (strcmp(name, "WriteLine") == 0) { - writeLine = Common::String::format("%s\n", line); - } else { - writeLine = Common::String::format("%s", line); - } - _writeFile->writeString(writeLine); - _writeFile->writeByte(0); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ReadBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadBool") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadByte") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - byte val = _readFile->readByte(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadShort") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int16 val = _readFile->readSint16LE(); - if (!_readFile->err()) { - stack->pushInt(65536 + val); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadInt / ReadLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int32 val = _readFile->readSint32LE(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadFloat") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - float val; - (*(uint32*)&val) = _readFile->readUint32LE(); - if (!_readFile->err()) { - stack->pushFloat(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. - error("SXFile::ReadDouble - Not endian safe yet"); - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadString") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 size = _readFile->readUint32LE(); - if (!_readFile->err()) { - byte *str = new byte[size + 1]; - if (str) { - if (_readFile->read(str, size) == size) { - str[size] = '\0'; - stack->pushString((char *)str); - } - delete [] str; - } else stack->pushNULL(); - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteByte") == 0) { - stack->correctParams(1); - byte val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteShort") == 0) { - stack->correctParams(1); - int16 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint16LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteInt / WriteLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->correctParams(1); - int32 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint32LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteFloat") == 0) { - stack->correctParams(1); - float val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - uint32 *ptr = (uint32*)&val; - _writeFile->writeUint32LE(*ptr); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteDouble") == 0) { - error("SXFile::WriteDouble - Not endian safe yet"); - stack->correctParams(1); - double val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteString") == 0) { - stack->correctParams(1); - const char *val = stack->pop()->getString(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - - uint32 size = strlen(val); - _writeFile->writeUint32LE(size); - _writeFile->writeString(val); - - stack->pushBool(true); - - return STATUS_OK; - } - - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("file"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Position (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { - _scValue->setInt(getPos()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(getLength()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { - _scValue->setBool(_textMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccessMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { - _scValue->setInt(_mode); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getPos() { - if (_mode == 1 && _readFile) - return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - getPos for WriteFile not supported"); - return 0; -// return ftell((FILE *)_writeFile); - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) - return _readFile->seek(pos, whence); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - seeking in WriteFile not supported"); - return false; -// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; - } - else return false; -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getLength() { - if (_mode == 1 && _readFile) - return _readFile->size(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - reading length for WriteFile not supported"); - return 0; -/* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); - - uint32 pos = 0; - if (persistMgr->_saving) { - pos = getPos(); - persistMgr->transfer(TMEMBER(pos)); - } else { - persistMgr->transfer(TMEMBER(pos)); - - // try to re-open file if needed - _writeFile = NULL; - _readFile = NULL; - - if (_mode != 0) { - // open for reading - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) - close(); - } - // open for writing / appending - else { - if (_textMode) { - if (_mode == 2) - _writeFile = openForWrite(_filename, false); - else - _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) - _writeFile = openForWrite(_filename, true); - else - _writeFile = openForAppend(_filename, true); - } - if (_writeFile) - close(); - } - setPos(pos); - } - } - - return STATUS_OK; -} - -// Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { - error("SXFile::openForWrite - WriteFiles not supported"); -} - -// Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h deleted file mode 100644 index f772473dd6..0000000000 --- a/engines/wintermute/Base/scriptables/SXFile.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTES_SXFILE_H -#define WINTERMUTES_SXFILE_H - - -#include "engines/wintermute/Base/BScriptable.h" -#include "common/stream.h" - -namespace WinterMute { - -class CBFile; - -class CSXFile : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); -private: - Common::SeekableReadStream *_readFile; - Common::WriteStream *_writeFile; - int _mode; // 0..none, 1..read, 2..write, 3..append - bool _textMode; - void close(); - void cleanup(); - uint32 getPos(); - uint32 getLength(); - bool setPos(uint32 Pos, int whence = SEEK_SET); - char *_filename; - Common::WriteStream *openForWrite(const Common::String &filename, bool binary); - Common::WriteStream *openForAppend(const Common::String &filename, bool binary); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp deleted file mode 100644 index 40e185d6cc..0000000000 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/scriptables/SXMath.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/persistent.h" -#include "common/math.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -IMPLEMENT_PERSISTENT(CSXMath, true) - -CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); -} - -////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Abs - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Abs") == 0) { - stack->correctParams(1); - stack->pushFloat(fabs(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Acos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Acos") == 0) { - stack->correctParams(1); - stack->pushFloat(acos(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Asin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Asin") == 0) { - stack->correctParams(1); - stack->pushFloat(asin(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan") == 0) { - stack->correctParams(1); - stack->pushFloat(atan(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan2") == 0) { - stack->correctParams(2); - double y = stack->pop()->getFloat(); - double x = stack->pop()->getFloat(); - stack->pushFloat(atan2(y, x)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Ceil - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ceil") == 0) { - stack->correctParams(1); - stack->pushFloat(ceil(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cos") == 0) { - stack->correctParams(1); - stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cosh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cosh") == 0) { - stack->correctParams(1); - stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exp") == 0) { - stack->correctParams(1); - stack->pushFloat(exp(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Floor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Floor") == 0) { - stack->correctParams(1); - stack->pushFloat(floor(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log") == 0) { - stack->correctParams(1); - stack->pushFloat(log(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log10 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log10") == 0) { - stack->correctParams(1); - stack->pushFloat(log10(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pow") == 0) { - stack->correctParams(2); - double x = stack->pop()->getFloat(); - double y = stack->pop()->getFloat(); - - stack->pushFloat(pow(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sin") == 0) { - stack->correctParams(1); - stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sinh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sinh") == 0) { - stack->correctParams(1); - stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tan") == 0) { - stack->correctParams(1); - stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tanh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tanh") == 0) { - stack->correctParams(1); - stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sqrt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sqrt") == 0) { - stack->correctParams(1); - stack->pushFloat(sqrt(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DegToRad - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DegToRad") == 0) { - stack->correctParams(1); - stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RadToDeg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RadToDeg") == 0) { - stack->correctParams(1); - stack->pushFloat(radianToDegree(stack->pop()->getFloat())); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("math"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PI - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { - _scValue->setFloat(M_PI); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::degreeToRadian(double value) { - return value * (M_PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::radianToDegree(double value) { - return value * (180.0f / M_PI); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXMath.h b/engines/wintermute/Base/scriptables/SXMath.h deleted file mode 100644 index eb11b94f34..0000000000 --- a/engines/wintermute/Base/scriptables/SXMath.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMATH_H -#define WINTERMUTE_SXMATH_H - - -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CSXMath : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - -private: - double degreeToRadian(double value); - double radianToDegree(double value); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp deleted file mode 100644 index 296326ebe5..0000000000 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BScriptable.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" -#include "common/file.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) - -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { - return new CSXMemBuffer(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - _buffer = NULL; - _size = 0; - - int NewSize = stack->pop()->getInt(); - resize(MAX(0, NewSize)); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - _size = 0; - _buffer = Buffer; -} - - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::scToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::cleanup() { - if (_size) free(_buffer); - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::resize(int newSize) { - int oldSize = _size; - - if (_size == 0) { - _buffer = malloc(newSize); - if (_buffer) _size = newSize; - } else { - void *newBuf = realloc(_buffer, newSize); - if (!newBuf) { - if (newSize == 0) { - _buffer = newBuf; - _size = newSize; - } else return STATUS_FAILED; - } else { - _buffer = newBuf; - _size = newSize; - } - } - - if (_buffer && _size > oldSize) { - memset((byte *)_buffer + oldSize, 0, _size - oldSize); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { - if (_buffer == NULL) { - script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); - return false; - } - if (_size == 0) - return true; - - if (start < 0 || length == 0 || start + length > _size) { - script->runtimeError("Set/Get method call is out of bounds"); - return false; - } else - return true; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::scToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSize - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSize") == 0) { - stack->correctParams(1); - int newSize = stack->pop()->getInt(); - newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBool") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) - stack->pushNULL(); - else - stack->pushBool(*(bool *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetByte") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) - stack->pushNULL(); - else - stack->pushInt(*(byte *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetShort") == 0) { - stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) - stack->pushNULL(); - else - stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInt / GetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) - stack->pushNULL(); - else - stack->pushInt(*(int *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFloat") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) - stack->pushNULL(); - else - stack->pushFloat(*(float *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDouble") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) - stack->pushNULL(); - else - stack->pushFloat(*(double *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int length = stack->pop()->getInt(); - - // find end of string - if (length == 0 && start >= 0 && start < _size) { - for (int i = start; i < _size; i++) { - if (((char *)_buffer)[i] == '\0') { - length = i - start; - break; - } - } - } - - if (!checkBounds(script, start, length)) - stack->pushNULL(); - else { - char *str = new char[length + 1]; - strncpy(str, (const char *)_buffer + start, length); - str[length] = '\0'; - stack->pushString(str); - delete [] str; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPointer") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) - stack->pushNULL(); - else { - void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); - stack->pushNative(buf, false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBool") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - bool val = stack->pop()->getBool(); - - if (!checkBounds(script, start, sizeof(bool))) - stack->pushBool(false); - else { - *(bool *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetByte") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - byte val = (byte)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(byte))) - stack->pushBool(false); - else { - *(byte *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetShort") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - short val = (short)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(short))) - stack->pushBool(false); - else { - *(short *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInt / SetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int val = stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(int))) - stack->pushBool(false); - else { - *(int *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFloat") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - float val = (float)stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(float))) - stack->pushBool(false); - else { - *(float *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDouble") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - double val = stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(double))) - stack->pushBool(false); - else { - *(double *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - const char *val = stack->pop()->getString(); - - if (!checkBounds(script, start, strlen(val) + 1)) - stack->pushBool(false); - else { - memcpy((byte *)_buffer + start, val, strlen(val) + 1); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPointer") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - /* CScValue *Val = */ stack->pop(); - - if (!checkBounds(script, start, sizeof(void *))) - stack->pushBool(false); - else { - /* - int Pointer = (int)Val->getMemBuffer(); - memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->pushBool(true); - */ - // TODO fix - stack->pushBool(false); - - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_Dump - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->correctParams(0); - if (_buffer && _size) { - warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); - Common::DumpFile f; - f.open("buffer.bin"); - f.write(_buffer, _size); - f.close(); - } - stack->pushNULL(); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("membuffer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Size (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { - _scValue->setInt(_size); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_size)); - - if (persistMgr->_saving) { - if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); - } else { - if (_size > 0) { - _buffer = malloc(_size); - persistMgr->getBytes((byte *)_buffer, _size); - } else _buffer = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *val) { - if (_buffer == val->scToMemBuffer()) return 0; - else return 1; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.h b/engines/wintermute/Base/scriptables/SXMemBuffer.h deleted file mode 100644 index 9a8746288c..0000000000 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CSXMemBuffer : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *stack); - CSXMemBuffer(CBGame *inGame, void *buffer); - virtual ~CSXMemBuffer(); - virtual void *scToMemBuffer(); - int _size; -private: - bool resize(int newSize); - void *_buffer; - void cleanup(); - bool checkBounds(CScScript *script, int start, int length); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp deleted file mode 100644 index ba70551dde..0000000000 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/Base/scriptables/SXString.h" -#include "engines/wintermute/Base/scriptables/SXArray.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/tokenizer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXString, false) - -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { - return new CSXString(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _string = NULL; - _capacity = 0; - - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (val->isInt()) { - _capacity = MAX(0, val->getInt()); - if (_capacity > 0) { - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - } else { - setStringVal(val->getString()); - } - - if (_capacity == 0) setStringVal(""); -} - - -////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { - if (_string) delete [] _string; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::setStringVal(const char *val) { - int len = strlen(val); - if (len >= _capacity) { - _capacity = len + 1; - delete[] _string; - _string = NULL; - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - strcpy(_string, val); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXString::scToString() { - if (_string) return _string; - else return "[null string]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *val) { - setStringVal(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Substring - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Substring") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int end = stack->pop()->getInt(); - - if (end < start) CBUtils::swap(&start, &end); - - //try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); - // } catch (std::exception &) { - // stack->pushNULL(); - // } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Substr - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Substr") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - - CScValue *val = stack->pop(); - int len = val->getInt(); - - if (!val->isNULL() && len <= 0) { - stack->pushString(""); - return STATUS_OK; - } - - if (val->isNULL()) len = strlen(_string) - start; - -// try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - -// WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); -// } catch (std::exception &) { -// stack->pushNULL(); -// } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToUpperCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToUpperCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toUppercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToLowerCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToLowerCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toLowercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IndexOf - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IndexOf") == 0) { - stack->correctParams(2); - - const char *strToFind = stack->pop()->getString(); - int index = stack->pop()->getInt(); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) - toFind = StringUtil::utf8ToWide(strToFind); - else - toFind = StringUtil::ansiToWide(strToFind); - - int indexOf = StringUtil::indexOf(str, toFind, index); - stack->pushInt(indexOf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Split - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Split") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) strcpy(separators, val->getString()); - - CSXArray *array = new CSXArray(_gameRef); - if (!array) { - stack->pushNULL(); - return STATUS_OK; - } - - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) - delims = StringUtil::utf8ToWide(separators); - else - delims = StringUtil::ansiToWide(separators); - - Common::Array parts; - - - - Common::StringTokenizer tokenizer(str, delims); - while (!tokenizer.empty()) { - Common::String str2 = tokenizer.nextToken(); - parts.push_back(str2); - } - // TODO: Clean this up - /*do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - - } while (pos != str.size());*/ - - for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { - WideString &part = (*it); - - if (_gameRef->_textEncoding == TEXT_UTF8) - val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - else - val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); - - array->push(val); - delete val; - val = NULL; - } - - stack->pushNative(array, false); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("string"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(_string); - _scValue->setInt(wstr.size()); - } else - _scValue->setInt(strlen(_string)); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { - _scValue->setInt(_capacity); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Capacity") == 0) { - int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); - else if (newCap != _capacity) { - char *newStr = new char[newCap]; - if (newStr) { - memset(newStr, 0, newCap); - strcpy(newStr, _string); - delete[] _string; - _string = newStr; - _capacity = newCap; - } - } - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_capacity)); - - if (persistMgr->_saving) { - if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); - } else { - if (_capacity > 0) { - _string = new char[_capacity]; - persistMgr->getBytes((byte *)_string, _capacity); - } else _string = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *val) { - return strcmp(_string, ((CSXString *)val)->_string); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SXString.h b/engines/wintermute/Base/scriptables/SXString.h deleted file mode 100644 index 04f9bc80c3..0000000000 --- a/engines/wintermute/Base/scriptables/SXString.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTRING_H -#define WINTERMUTE_SXSTRING_H - - -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -class CSXString : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - void scSetString(const char *val); - const char *scToString(); - void setStringVal(const char *val); - - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp deleted file mode 100644 index 8e57c9a3eb..0000000000 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ /dev/null @@ -1,712 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/SXMath.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BFileManager.h" - - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { - _gameRef->LOG(0, "Initializing scripting engine..."); - - if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); - else _gameRef->LOG(0, " Script compiler is NOT available"); - - _globals = new CScValue(_gameRef); - - - // register 'Game' as global variable - if (!_globals->propExists("Game")) { - CScValue val(_gameRef); - val.setNative(_gameRef, true); - _globals->setProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->propExists("Math")) { - CScValue val(_gameRef); - val.setNative(_gameRef->_mathClass, true); - _globals->setProp("Math", &val); - } - - // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; - - _currentScript = NULL; - - _isProfiling = false; - _profilingStartTime = 0; - - //EnableProfiling(); -} - - -////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { - _gameRef->LOG(0, "Shutting down scripting engine"); - saveBreakpoints(); - - disableProfiling(); - - cleanup(); - - for (int i = 0; i < _breakpoints.getSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::cleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - - _scripts.removeAll(); - - delete _globals; - _globals = NULL; - - emptyScriptCache(); - - _currentScript = NULL; // ref only - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *gameRef = (CBGame *)data; - return gameRef->_fileManager->readWholeFile(filename, size); -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::closeFile(void *data, byte *buffer) { - delete [] buffer; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::parseElement(void *data, int line, int type, void *elementData) { -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { - byte *compBuffer; - uint32 compSize; - - // get script from cache - compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) return NULL; - - // add new script - CScScript *script = new CScScript(_gameRef, this); - bool ret = script->create(filename, compBuffer, compSize, owner); - if (DID_FAIL(ret)) { - _gameRef->LOG(ret, "Error running script '%s'...", filename); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - CScValue val(_gameRef); - if (owner)val.setNative(owner, true); - else val.setNULL(); - - script->_globals->setProp("self", &val); - script->_globals->setProp("this", &val); - - _scripts.add(script); - _gameRef->getDebugMgr()->onScriptInit(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { - // is script in cache? - if (!ignoreCache) { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::getTime(); - *outSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *compBuffer; - uint32 compSize; - - uint32 size; - - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (!buffer) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); - return NULL; - } - - // needs to be compiled? - if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { - compBuffer = buffer; - compSize = size; - } else { - if (!_compilerAvailable) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] buffer; - return NULL; - } - // This code will never be called, since _compilerAvailable is const false. - // It's only here in the event someone would want to reinclude the compiler. - error("Script needs compilation, ScummVM does not contain a WME compiler"); - } - - byte *ret = NULL; - - // add script to cache - CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); - if (cachedScript) { - int index = 0; - uint32 MinTime = CBPlatform::getTime(); - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] == NULL) { - index = i; - break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; - index = i; - } - } - - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; - _cachedScripts[index] = cachedScript; - - ret = cachedScript->_buffer; - *outSize = cachedScript->_size; - } - - - // cleanup - delete [] buffer; - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tick() { - if (_scripts.getSize() == 0) - return STATUS_OK; - - - // resolve waiting scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - switch (_scripts[i]->_state) { - case SCRIPT_WAITING: { - /* - bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.getSize(); j++) - { - if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) - { - if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); - obj_found = true; - break; - } - } - if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists - */ - if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); - } else _scripts[i]->finish(); - break; - } - - case SCRIPT_SLEEPING: { - if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); - } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); - } - break; - } - - case SCRIPT_WAITING_SCRIPT: { - if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { - // fake return value - _scripts[i]->_stack->pushNULL(); - _scripts[i]->_waitScript = NULL; - _scripts[i]->run(); - } else { - if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { - // copy return value - _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); - _scripts[i]->run(); - _scripts[i]->_waitScript->finish(); - _scripts[i]->_waitScript = NULL; - } - } - break; - } - default: - //warning("CScEngine::Tick - Unhandled enum"); - break; - } // switch - } // for each script - - - // execute scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; - - // time sliced script - if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); - } - - // normal script - else { - uint32 startTime = 0; - bool isProfiling = _isProfiling; - if (isProfiling) startTime = CBPlatform::getTime(); - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); - } - _currentScript = NULL; - } - - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tickUnbreakable() { - // execute unbreakable scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - _scripts[i]->finish(); - _currentScript = NULL; - } - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeFinishedScripts() { - // remove finished scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { - int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; - switch (_scripts[i]->_state) { - case SCRIPT_RUNNING: - case SCRIPT_SLEEPING: - case SCRIPT_PAUSED: - numRunning++; - break; - case SCRIPT_WAITING: - numWaiting++; - break; - case SCRIPT_PERSISTENT: - numPersistent++; - break; - default: - warning("CScEngine::GetNumScripts - unhandled enum"); - break; - } - numTotal++; - } - if (running) *running = numRunning; - if (waiting) *waiting = numWaiting; - if (persistent) *persistent = numPersistent; - - return numTotal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::emptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetObject(CBObject *Object) { - // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); - - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetScript(CScScript *script) { - // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { - _scripts[i]->finish(); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_globals)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::editorCleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::pauseAll() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->pause(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->resume(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::isValidScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::clearGlobals(bool includingNatives) { - _globals->CleanProps(includingNatives); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { - // send global variables - _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->dbgSendScript(client); - } - - // and threads later - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->dbgSendScript(client); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - bp = _breakpoints[i]; - break; - } - } - if (bp == NULL) { - bp = new CScBreakpoint(scriptFilename); - _breakpoints.add(bp); - } - - for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) return STATUS_OK; - } - bp->_lines.add(line); - - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.removeAt(j); - if (_breakpoints[i]->_lines.getSize() == 0) { - delete _breakpoints[i]; - _breakpoints.removeAt(i); - } - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; - } - } - break; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _scripts.getSize(); i++) { - refreshScriptBreakpoints(_scripts[i]); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints(CScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - if (!script || !script->_filename) return STATUS_FAILED; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.copy(_breakpoints[i]->_lines); - return STATUS_OK; - } - } - if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - - char text[512]; - char key[100]; - - int count = 0; - for (int i = 0; i < _breakpoints.getSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - count++; - sprintf(key, "Breakpoint%d", count); - sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - _gameRef->_registry->writeString("Debug", key, text); - } - } - _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - char key[100]; - - int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= count; i++) { - /* uint32 BufSize = 512; */ - sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); - - char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); - - if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); - delete[] path; - delete[] line; - path = NULL; - line = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) return; - - AnsiString fileName = filename; - fileName.toLowercase(); - _scriptTimes[fileName] += time; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::enableProfiling() { - if (_isProfiling) return; - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = CBPlatform::getTime(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::disableProfiling() { - if (!_isProfiling) return; - - dumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::dumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; - - typedef std::vector > TimeVector; - TimeVector times; - - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); - - - TimeVector::reverse_iterator tit; - - _gameRef->LOG(0, "***** Script profiling information: *****"); - _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - - for (tit = times.rbegin(); tit != times.rend(); tit++) { - _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScEngine.h b/engines/wintermute/Base/scriptables/ScEngine.h deleted file mode 100644 index cca1c1aa6b..0000000000 --- a/engines/wintermute/Base/scriptables/ScEngine.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCENGINE_H -#define WINTERMUTE_SCENGINE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -#define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { -public: - class CScCachedScript { - public: - CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::getTime(); - _buffer = new byte[size]; - if (_buffer) memcpy(_buffer, buffer, size); - _size = size; - _filename = filename; - }; - - ~CScCachedScript() { - if (_buffer) delete [] _buffer; - }; - - uint32 _timestamp; - byte *_buffer; - uint32 _size; - Common::String _filename; - }; - - class CScBreakpoint { - public: - CScBreakpoint(const char *filename) { - _filename = filename; - } - - ~CScBreakpoint() { - _lines.removeAll(); - } - - Common::String _filename; - CBArray _lines; - }; - - - - -public: - bool dbgSendScripts(IWmeDebugClient *client); - - CBArray _breakpoints; - bool addBreakpoint(const char *scriptFilename, int line); - bool removeBreakpoint(const char *scriptFilename, int line); - bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(CScScript *script); - bool saveBreakpoints(); - bool loadBreakpoints(); - - bool clearGlobals(bool includingNatives = false); - bool tickUnbreakable(); - bool removeFinishedScripts(); - bool isValidScript(CScScript *script); - - CScScript *_currentScript; - bool resumeAll(); - bool pauseAll(); - void editorCleanup(); - bool resetObject(CBObject *Object); - bool resetScript(CScScript *script); - bool emptyScriptCache(); - byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) - bool cleanup(); - int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - bool tick(); - CScValue *_globals; - CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); - static const bool _compilerAvailable = false; - - CScEngine(CBGame *inGame); - virtual ~CScEngine(); - static byte *loadFile(void *data, char *filename, uint32 *size); - static void closeFile(void *data, byte *buffer); - static void parseElement(void *data, int line, int type, void *elementData); - - CBArray _scripts; - - void enableProfiling(); - void disableProfiling(); - bool getIsProfiling() { - return _isProfiling; - } - - void addScriptTime(const char *filename, uint32 Time); - void dumpStats(); - -private: - - CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; - bool _isProfiling; - uint32 _profilingStartTime; - - typedef Common::HashMap ScriptTimes; - ScriptTimes _scriptTimes; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp deleted file mode 100644 index bddb687934..0000000000 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ /dev/null @@ -1,1461 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "common/memstream.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScScript, false) - -////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { - _buffer = NULL; - _bufferSize = _iP = 0; - _scriptStream = NULL; - _filename = NULL; - _currentLine = 0; - - _symbols = NULL; - _numSymbols = 0; - - _engine = Engine; - - _globals = NULL; - - _scopeStack = NULL; - _callStack = NULL; - _thisStack = NULL; - _stack = NULL; - - _operand = NULL; - _reg1 = NULL; - - _functions = NULL; - _numFunctions = 0; - - _methods = NULL; - _numMethods = 0; - - _events = NULL; - _numEvents = 0; - - _externals = NULL; - _numExternals = 0; - - _state = SCRIPT_FINISHED; - _origState = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _timeSlice = 0; - - _thread = false; - _methodThread = false; - _threadEvent = NULL; - - _freezable = true; - _owner = NULL; - - _unbreakable = false; - _parentScript = NULL; - - _tracingMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { - cleanup(); -} - -void CScScript::readHeader() { - uint32 oldPos = _scriptStream->pos(); - _scriptStream->seek(0); - _header.magic = _scriptStream->readUint32LE(); - _header.version = _scriptStream->readUint32LE(); - _header.code_start = _scriptStream->readUint32LE(); - _header.func_table = _scriptStream->readUint32LE(); - _header.symbol_table = _scriptStream->readUint32LE(); - _header.event_table = _scriptStream->readUint32LE(); - _header.externals_table = _scriptStream->readUint32LE(); - _header.method_table = _scriptStream->readUint32LE(); - _scriptStream->seek(oldPos); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initScript() { - if (!_scriptStream) { - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - } - readHeader(); - - if (_header.magic != SCRIPT_MAGIC) { - _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); - cleanup(); - return STATUS_FAILED; - } - - if (_header.version > SCRIPT_VERSION) { - _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - cleanup(); - return STATUS_FAILED; - } - - initTables(); - - // init stacks - _scopeStack = new CScStack(_gameRef); - _callStack = new CScStack(_gameRef); - _thisStack = new CScStack(_gameRef); - _stack = new CScStack(_gameRef); - - _operand = new CScValue(_gameRef); - _reg1 = new CScValue(_gameRef); - - - // skip to the beginning - _iP = _header.code_start; - _scriptStream->seek(_iP); - _currentLine = 0; - - // init breakpoints - _engine->refreshScriptBreakpoints(this); - - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initTables() { - uint32 OrigIP = _iP; - - readHeader(); - // load symbol table - _iP = _header.symbol_table; - - _numSymbols = getDWORD(); - _symbols = new char*[_numSymbols]; - for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = getDWORD(); - _symbols[index] = getString(); - } - - // load functions table - _iP = _header.func_table; - - _numFunctions = getDWORD(); - _functions = new TFunctionPos[_numFunctions]; - for (uint32 i = 0; i < _numFunctions; i++) { - _functions[i].pos = getDWORD(); - _functions[i].name = getString(); - } - - - // load events table - _iP = _header.event_table; - - _numEvents = getDWORD(); - _events = new TEventPos[_numEvents]; - for (uint32 i = 0; i < _numEvents; i++) { - _events[i].pos = getDWORD(); - _events[i].name = getString(); - } - - - // load externals - if (_header.version >= 0x0101) { - _iP = _header.externals_table; - - _numExternals = getDWORD(); - _externals = new TExternalFunction[_numExternals]; - for (uint32 i = 0; i < _numExternals; i++) { - _externals[i].dll_name = getString(); - _externals[i].name = getString(); - _externals[i].call_type = (TCallType)getDWORD(); - _externals[i].returns = (TExternalType)getDWORD(); - _externals[i].nu_params = getDWORD(); - if (_externals[i].nu_params > 0) { - _externals[i].params = new TExternalType[_externals[i].nu_params]; - for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)getDWORD(); - } - } - } - } - - // load method table - _iP = _header.method_table; - - _numMethods = getDWORD(); - _methods = new TMethodPos[_numMethods]; - for (uint32 i = 0; i < _numMethods; i++) { - _methods[i].pos = getDWORD(); - _methods[i].name = getString(); - } - - - _iP = OrigIP; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { - cleanup(); - - _thread = false; - _methodThread = false; - - delete[] _threadEvent; - _threadEvent = NULL; - - _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); - - _buffer = new byte [size]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, buffer, size); - - _bufferSize = size; - - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // establish global variables table - _globals = new CScValue(_gameRef); - - _owner = owner; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { - cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[strlen(eventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, eventName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = initIP; - _scriptStream->seek(_iP); - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createMethodThread(CScScript *original, const char *methodName) { - uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return STATUS_FAILED; - - cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[strlen(methodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, methodName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = ip; - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::cleanup() { - if (_buffer) delete [] _buffer; - _buffer = NULL; - - if (_filename) delete [] _filename; - _filename = NULL; - - if (_symbols) delete [] _symbols; - _symbols = NULL; - _numSymbols = 0; - - if (_globals && !_thread) delete _globals; - _globals = NULL; - - delete _scopeStack; - _scopeStack = NULL; - - delete _callStack; - _callStack = NULL; - - delete _thisStack; - _thisStack = NULL; - - delete _stack; - _stack = NULL; - - if (_functions) delete [] _functions; - _functions = NULL; - _numFunctions = 0; - - if (_methods) delete [] _methods; - _methods = NULL; - _numMethods = 0; - - if (_events) delete [] _events; - _events = NULL; - _numEvents = 0; - - - if (_externals) { - for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; - } - delete [] _externals; - } - _externals = NULL; - _numExternals = 0; - - delete _operand; - delete _reg1; - _operand = NULL; - _reg1 = NULL; - - delete[] _threadEvent; - _threadEvent = NULL; - - _state = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _parentScript = NULL; // ref only - - delete _scriptStream; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getDWORD() { - _scriptStream->seek((int32)_iP); - uint32 ret = _scriptStream->readUint32LE(); - _iP += sizeof(uint32); -// assert(oldRet == ret); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -double CScScript::getFloat() { - _scriptStream->seek((int32)_iP); - byte buffer[8]; - _scriptStream->read(buffer, 8); - -#ifdef SCUMM_BIG_ENDIAN - // TODO: For lack of a READ_LE_UINT64 - SWAP(buffer[0], buffer[7]); - SWAP(buffer[1], buffer[6]); - SWAP(buffer[2], buffer[5]); - SWAP(buffer[3], buffer[4]); -#endif - - double ret = *(double *)(buffer); - _iP += 8; // Hardcode the double-size used originally. - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -char *CScScript::getString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; - _iP++; // string terminator - _scriptStream->seek(_iP); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::executeInstruction() { - bool ret = STATUS_OK; - - uint32 dw; - const char *str = NULL; - - //CScValue* op = new CScValue(_gameRef); - _operand->cleanup(); - - CScValue *op1; - CScValue *op2; - - uint32 inst = getDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->setNULL(); - dw = getDWORD(); - if (_scopeStack->_sP < 0) { - _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); - } else { - _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); - } - - break; - - case II_DEF_GLOB_VAR: - case II_DEF_CONST_VAR: { - dw = getDWORD(); - /* char *Temp = _symbols[dw]; // TODO delete */ - // only create global var if it doesn't exist - if (!_engine->_globals->propExists(_symbols[dw])) { - _operand->setNULL(); - _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); - - _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->getInt(); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } else { - if (_thread) { - _state = SCRIPT_THREAD_FINISHED; - } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; - } - } - - break; - - case II_RET_EVENT: - _state = SCRIPT_FINISHED; - break; - - - case II_CALL: - dw = getDWORD(); - - _operand->setInt(_iP); - _callStack->push(_operand); - - _iP = dw; - - break; - - case II_CALL_BY_EXP: { - // push var - // push string - str = _stack->pop()->getString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); - - CScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - - bool res = STATUS_FAILED; - bool TriedNative = false; - - // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - TriedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - } - - if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { - if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(MethodName); - if (!_waitScript) { - _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", MethodName); - _stack->pushNULL(); - } else { - _state = SCRIPT_WAITING_SCRIPT; - _waitScript->copyParameters(_stack); - } - } else { - // can call methods in unbreakable mode - _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - delete [] MethodName; - break; - } - /* - CScValue* val = var->getProp(MethodName); - if(val){ - dw = GetFuncPos(val->getString()); - if(dw==0){ - TExternalFunction* f = GetExternal(val->getString()); - if(f){ - ExternalCall(_stack, _thisStack, f); - } - else{ - // not an internal nor external, try for native function - _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); - } - } - else{ - _operand->setInt(_iP); - _callStack->Push(_operand); - _iP = dw; - } - } - */ - else { - res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - - if (DID_FAIL(res)) { - _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - } - } - delete [] MethodName; - } - break; - - case II_EXTERNAL_CALL: { - uint32 SymbolIndex = getDWORD(); - - TExternalFunction *f = getExternal(_symbols[SymbolIndex]); - if (f) { - externalCall(_stack, _thisStack, f); - } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); - - break; - } - case II_SCOPE: - _operand->setNULL(); - _scopeStack->push(_operand); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - - break; - - case II_CORRECT_STACK: - dw = getDWORD(); // params expected - _stack->correctParams(dw); - break; - - case II_CREATE_OBJECT: - _operand->setObject(); - _stack->push(_operand); - break; - - case II_POP_EMPTY: - _stack->pop(); - break; - - case II_PUSH_VAR: { - CScValue *var = getVar(_symbols[getDWORD()]); - if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->setReference(var); - _stack->push(_operand); - } else _stack->push(var); - break; - } - - case II_PUSH_VAR_REF: { - CScValue *var = getVar(_symbols[getDWORD()]); - _operand->setReference(var); - _stack->push(_operand); - break; - } - - case II_POP_VAR: { - char *VarName = _symbols[getDWORD()]; - CScValue *var = getVar(VarName); - if (var) { - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else { - if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->setValue(val); - else { - var->copy(val); - } - } - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, val); - } - - break; - } - - case II_PUSH_VAR_THIS: - _stack->push(_thisStack->getTop()); - break; - - case II_PUSH_INT: - _stack->pushInt((int)getDWORD()); - break; - - case II_PUSH_FLOAT: - _stack->pushFloat(getFloat()); - break; - - - case II_PUSH_BOOL: - _stack->pushBool(getDWORD() != 0); - - break; - - case II_PUSH_STRING: - _stack->pushString(getString()); - break; - - case II_PUSH_NULL: - _stack->pushNULL(); - break; - - case II_PUSH_THIS_FROM_STACK: - _operand->setReference(_stack->getTop()); - _thisStack->push(_operand); - break; - - case II_PUSH_THIS: - _operand->setReference(getVar(_symbols[getDWORD()])); - _thisStack->push(_operand); - break; - - case II_POP_THIS: - _thisStack->pop(); - break; - - case II_PUSH_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *val = _stack->pop()->getProp(str); - if (val) _stack->push(val); - else _stack->pushNULL(); - - break; - } - - case II_POP_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *var = _stack->pop(); - CScValue *val = _stack->pop(); - - if (val == NULL) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else var->setProp(str, val); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); - - break; - } - - case II_PUSH_REG1: - _stack->push(_reg1); - break; - - case II_POP_REG1: - _reg1->copy(_stack->pop()); - break; - - case II_JMP: - _iP = getDWORD(); - break; - - case II_JMP_FALSE: { - dw = getDWORD(); - //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - } else { - if (!val->getBool()) _iP = dw; - } - break; - } - - case II_ADD: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; - strcpy(tempStr, op1->getString()); - strcat(tempStr, op2->getString()); - _operand->setString(tempStr); - delete [] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() + op2->getInt()); - else _operand->setFloat(op1->getFloat() + op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_SUB: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() - op2->getInt()); - else _operand->setFloat(op1->getFloat() - op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MUL: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() * op2->getInt()); - else _operand->setFloat(op1->getFloat() * op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_DIV: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getFloat() == 0.0f) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); - else _operand->setFloat(op1->getFloat() / op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MODULO: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getInt() == 0) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) - _operand->setNULL(); - else _operand->setInt(op1->getInt() % op2->getInt()); - - _stack->push(_operand); - - break; - - case II_NOT: - op1 = _stack->pop(); - //if(op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) _operand->setBool(true); - else _operand->setBool(!op1->getBool()); - _stack->push(_operand); - - break; - - case II_AND: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() && op2->getBool()); - } - _stack->push(_operand); - break; - - case II_OR: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() || op2->getBool()); - } - _stack->push(_operand); - break; - - case II_CMP_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() == op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() == op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() == op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) == 0); - _stack->push(_operand); - break; - - case II_CMP_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() != op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() != op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() != op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_CMP_L: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() < op2->getFloat()); - } - else _operand->setBool(op1->getInt() < op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) < 0); - _stack->push(_operand); - break; - - case II_CMP_G: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() > op2->getFloat()); - } - else _operand->setBool(op1->getInt() > op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) > 0); - _stack->push(_operand); - break; - - case II_CMP_LE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() <= op2->getFloat()); - } - else _operand->setBool(op1->getInt() <= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) <= 0); - _stack->push(_operand); - break; - - case II_CMP_GE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() >= op2->getFloat()); - } - else _operand->setBool(op1->getInt() >= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) >= 0); - _stack->push(_operand); - break; - - case II_CMP_STRICT_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) == 0); - _stack->push(_operand); - - break; - - case II_CMP_STRICT_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_DBG_LINE: { - int newLine = getDWORD(); - if (newLine != _currentLine) { - _currentLine = newLine; - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (_breakpoints[i] == _currentLine) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - if (_tracingMode) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - } - break; - - } - default: - _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); - _state = SCRIPT_FINISHED; - ret = STATUS_FAILED; - } // switch(instruction) - - //delete op; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getFuncPos(const char *name) { - for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) - return _functions[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getMethodPos(const char *name) { - for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) - return _methods[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::getVar(char *name) { - CScValue *ret = NULL; - - // scope locals - if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) - ret = _scopeStack->getTop()->getProp(name); - } - - // script globals - if (ret == NULL) { - if (_globals->propExists(name)) - ret = _globals->getProp(name); - } - - // engine globals - if (ret == NULL) { - if (_engine->_globals->propExists(name)) - ret = _engine->_globals->getProp(name); - } - - if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); - _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(_gameRef); - CScValue *scope = _scopeStack->getTop(); - if (scope) { - scope->setProp(name, val); - ret = _scopeStack->getTop()->getProp(name); - } else { - _globals->setProp(name, val); - ret = _globals->getProp(name); - } - delete val; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitFor(CBObject *object) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = object; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitForExclusive(CBObject *object) { - _engine->resetObject(object); - return waitFor(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::sleep(uint32 duration) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_SLEEPING; - if (_gameRef->_state == GAME_FROZEN) { - _waitTime = CBPlatform::getTime() + duration; - _waitFrozen = true; - } else { - _waitTime = _gameRef->_timer + duration; - _waitFrozen = false; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finish(bool includingThreads) { - if (_state != SCRIPT_FINISHED && includingThreads) { - _state = SCRIPT_FINISHED; - finishThreads(); - } else _state = SCRIPT_FINISHED; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::run() { - _state = SCRIPT_RUNNING; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(const char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - _gameRef->LOG(0, " %s", buff); - - if (!_gameRef->_suppressScriptErrors) - _gameRef->quickMessage("Script runtime error. View log for details."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - // buffer - if (persistMgr->_saving) { - if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - persistMgr->transfer(TMEMBER(_bufferSize)); - persistMgr->putBytes(_buffer, _bufferSize); - } else { - // don't save idle/finished scripts - int bufferSize = 0; - persistMgr->transfer(TMEMBER(bufferSize)); - } - } else { - persistMgr->transfer(TMEMBER(_bufferSize)); - if (_bufferSize > 0) { - _buffer = new byte[_bufferSize]; - persistMgr->getBytes(_buffer, _bufferSize); - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - initTables(); - } else { - _buffer = NULL; - _scriptStream = NULL; - } - } - - persistMgr->transfer(TMEMBER(_callStack)); - persistMgr->transfer(TMEMBER(_currentLine)); - persistMgr->transfer(TMEMBER(_engine)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_globals)); - persistMgr->transfer(TMEMBER(_iP)); - persistMgr->transfer(TMEMBER(_scopeStack)); - persistMgr->transfer(TMEMBER(_stack)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_operand)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_reg1)); - persistMgr->transfer(TMEMBER(_thread)); - persistMgr->transfer(TMEMBER(_threadEvent)); - persistMgr->transfer(TMEMBER(_thisStack)); - persistMgr->transfer(TMEMBER(_timeSlice)); - persistMgr->transfer(TMEMBER(_waitObject)); - persistMgr->transfer(TMEMBER(_waitScript)); - persistMgr->transfer(TMEMBER(_waitTime)); - persistMgr->transfer(TMEMBER(_waitFrozen)); - - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_unbreakable)); - persistMgr->transfer(TMEMBER(_parentScript)); - - if (!persistMgr->_saving) _tracingMode = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = getEventPos(eventName); - if (!pos) return NULL; - - CScScript *thread = new CScScript(_gameRef, _engine); - if (thread) { - bool ret = thread->createThread(this, pos, eventName); - if (DID_SUCCEED(ret)) { - thread->_unbreakable = unbreakable; - _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); - return thread; - } else { - delete thread; - return NULL; - } - } else return NULL; - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getEventPos(const char *name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *eventName) { - return getEventPos(eventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *methodName) { - return getMethodPos(methodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::pause() { - if (_state == SCRIPT_PAUSED) { - _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return STATUS_FAILED; - } - - if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; - - _origState = _state; - _state = SCRIPT_PAUSED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::resume() { - if (_state != SCRIPT_PAUSED) return STATUS_OK; - - _state = _origState; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::getExternal(char *name) { - for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) - return &_externals[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { - - _gameRef->LOG(0, "External functions are not supported on this platform."); - stack->correctParams(0); - stack->pushNULL(); - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::copyParameters(CScStack *stack) { - int i; - int NumParams = stack->pop()->getInt(); - for (i = NumParams - 1; i >= 0; i--) { - _stack->push(stack->getAt(i)); - } - _stack->pushInt(NumParams); - - for (i = 0; i < NumParams; i++) stack->pop(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.getSize(); i++) { - CScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) - scr->finish(true); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int CScScript::dbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *CScScript::dbgGetFilename() { - return _filename; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else client->onScriptInit(this); - - return dbgSendVariables(client); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendVariables(IWmeDebugClient *client) { - // send script globals - _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::dbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetNumBreakpoints() { - return _breakpoints.getSize(); -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; - else return -1; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool isTracing) { - _tracingMode = isTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgGetTracingMode() { - return _tracingMode; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::afterLoad() { - if (_buffer == NULL) { - byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); - if (!buffer) { - _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); - _state = SCRIPT_ERROR; - return; - } - - _buffer = new byte [_bufferSize]; - memcpy(_buffer, buffer, _bufferSize); - - delete _scriptStream; - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - - initTables(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScScript.h b/engines/wintermute/Base/scriptables/ScScript.h deleted file mode 100644 index 24d3f87fe5..0000000000 --- a/engines/wintermute/Base/scriptables/ScScript.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -#include "engines/wintermute/wme_debugger.h" - -namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { -public: - bool dbgSendScript(IWmeDebugClient *client); - bool dbgSendVariables(IWmeDebugClient *client); - - CBArray _breakpoints; - bool _tracingMode; - - CScScript *_parentScript; - bool _unbreakable; - bool finishThreads(); - bool copyParameters(CScStack *stack); - - void afterLoad(); - - CScValue *_operand; - CScValue *_reg1; - bool _freezable; - bool resume(); - bool pause(); - bool canHandleEvent(const char *eventName); - bool canHandleMethod(const char *methodName); - bool createThread(CScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(CScScript *original, const char *methodName); - CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); - uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) - void runtimeError(const char *fmt, ...); - bool run(); - bool finish(bool includingThreads = false); - bool sleep(uint32 duration); - bool waitForExclusive(CBObject *object); - bool waitFor(CBObject *object); - uint32 _waitTime; - bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - CScValue *getVar(char *name); - uint32 getFuncPos(const char *name); - uint32 getEventPos(const char *name); - uint32 getMethodPos(const char *name); - typedef struct { - uint32 magic; - uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; - } TScriptHeader; - - TScriptHeader _header; - - typedef struct { - char *name; - uint32 pos; - } TFunctionPos; - - typedef struct { - char *name; - uint32 pos; - } TMethodPos; - - typedef struct { - char *name; - uint32 pos; - } TEventPos; - - typedef struct { - char *name; - char *dll_name; - TCallType call_type; - TExternalType returns; - int nu_params; - TExternalType *params; - } TExternalFunction; - - - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; - int _currentLine; - bool executeInstruction(); - char *getString(); - uint32 getDWORD(); - double getFloat(); - void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); - uint32 _iP; -private: - void readHeader(); - uint32 _bufferSize; - byte *_buffer; -public: - Common::SeekableReadStream *_scriptStream; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); - char *_filename; - char **_symbols; - uint32 _numSymbols; - TFunctionPos *_functions; - TMethodPos *_methods; - TEventPos *_events; - uint32 _numExternals; - TExternalFunction *_externals; - uint32 _numFunctions; - uint32 _numMethods; - uint32 _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *getExternal(char *name); - bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); -private: - bool initScript(); - bool initTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int dbgGetLine(); - virtual const char *dbgGetFilename(); - virtual TScriptState dbgGetState(); - virtual int dbgGetNumBreakpoints(); - virtual int dbgGetBreakpoint(int Index); - - virtual bool dbgSetTracingMode(bool IsTracing); - virtual bool dbgGetTracingMode(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp deleted file mode 100644 index fd85e9a5d8..0000000000 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScStack, false) - -////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { - -#if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); -#endif - - for (int i = 0; i < _values.getSize(); i++) { - delete _values[i]; - } - _values.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::pop() { - if (_sP < 0) { - _gameRef->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::push(CScValue *val) { - _sP++; - - if (_sP < _values.getSize()) { - _values[_sP]->cleanup(); - _values[_sP]->copy(val); - } else { - CScValue *copyVal = new CScValue(_gameRef); - copyVal->copy(val); - _values.add(copyVal); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getPushValue() { - _sP++; - - if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(_gameRef); - _values.add(val); - } - _values[_sP]->cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) return NULL; - else return _values[_sP]; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getAt(int index) { - index = _sP - index; - if (index < 0 || index >= _values.getSize()) return NULL; - else return _values[index]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expectedParams) { - uint32 nuParams = (uint32)pop()->getInt(); - - if (expectedParams < nuParams) { // too many params - while (expectedParams < nuParams) { - //Pop(); - delete _values[_sP - expectedParams]; - _values.removeAt(_sP - expectedParams); - nuParams--; - _sP--; - } - } else if (expectedParams > nuParams) { // need more params - while (expectedParams > nuParams) { - //Push(null_val); - CScValue *nullVal = new CScValue(_gameRef); - nullVal->setNULL(); - _values.insertAt(_sP - nuParams + 1, nullVal); - nuParams++; - _sP++; - - if (_values.getSize() > _sP + 1) { - delete _values[_values.getSize() - 1]; - _values.removeAt(_values.getSize() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNULL() { - /* - CScValue* val = new CScValue(_gameRef); - val->setNULL(); - Push(val); - delete val; - */ - getPushValue()->setNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushInt(int val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setInt(Val); - Push(val); - delete val; - */ - getPushValue()->setInt(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushFloat(double val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setFloat(Val); - Push(val); - delete val; - */ - getPushValue()->setFloat(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushBool(bool val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setBool(Val); - Push(val); - delete val; - */ - getPushValue()->setBool(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushString(const char *val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setString(Val); - Push(val); - delete val; - */ - getPushValue()->setString(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNative(CBScriptable *val, bool persistent) { - /* - CScValue* val = new CScValue(_gameRef); - val->setNative(Val, Persistent); - Push(val); - delete val; - */ - - getPushValue()->setNative(val, persistent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScStack::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_sP)); - _values.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScStack.h b/engines/wintermute/Base/scriptables/ScStack.h deleted file mode 100644 index 739f78424a..0000000000 --- a/engines/wintermute/Base/scriptables/ScStack.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSTACK_H -#define WINTERMUTE_SCSTACK_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CBScriptable; - -class CScStack : public CBBase { -public: - CScValue *getAt(int Index); - CScValue *getPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *val, bool persistent); - void pushString(const char *val); - void pushBool(bool val); - void pushInt(int val); - void pushFloat(double val); - void pushNULL(); - void correctParams(uint32 expectedParams); - CScValue *getTop(); - void push(CScValue *val); - CScValue *pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; - int _sP; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp deleted file mode 100644 index e75cb133bc..0000000000 --- a/engines/wintermute/Base/scriptables/ScValue.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BScriptable.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CScValue, false) - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { - _type = VAL_BOOL; - _valBool = val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { - _type = VAL_INT; - _valInt = val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { - _type = VAL_FLOAT; - _valFloat = val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { - _type = VAL_STRING; - _valString = NULL; - setStringVal(val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool ignoreNatives) { - deleteProps(); - - if (_valString) delete [] _valString; - - if (!ignoreNatives) { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - _valNative = NULL; - } - } - } - - - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); - - if (_type == VAL_STRING && strcmp(name, "Length") == 0) { - _gameRef->_scValue->_type = VAL_INT; - -#if 0 // TODO: Remove FreeType-dependency - if (_gameRef->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif - _gameRef->_scValue->setInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::utf8ToWide(_valString); - _gameRef->_scValue->setInt(wstr.size()); - } - - return _gameRef->_scValue; - } - - CScValue *ret = NULL; - - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); - - if (ret == NULL) { - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) ret = _valIter->_value; - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - delete _valIter->_value; - _valIter->_value = NULL; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) - return _valRef->setProp(name, val); - - bool ret = STATUS_FAILED; - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(name, val); - } - - if (DID_FAIL(ret)) { - CScValue *newVal = NULL; - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - newVal = _valIter->_value; - } - if (!newVal) - newVal = new CScValue(_gameRef); - else newVal->cleanup(); - - newVal->copy(val, copyWhole); - newVal->_isConstVar = setAsConst; - _valObject[name] = newVal; - - if (_type != VAL_NATIVE) _type = VAL_OBJECT; - - /* - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()){ - delete _valIter->_value; - _valIter->_value = NULL; - } - CScValue* val = new CScValue(_gameRef); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) - return _valRef->propExists(name); - _valIter = _valObject.find(name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::deleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool includingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNULL(); - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNative(); - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isString(); - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isFloat(); - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isInt() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isInt(); - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isBool() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isBool(); - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isObject() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isObject(); - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getType(); - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setBool(bool val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setBool(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetBool(val); - return; - } - - _valBool = val; - _type = VAL_BOOL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setInt(int val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setInt(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetInt(val); - return; - } - - _valInt = val; - _type = VAL_INT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setFloat(double val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setFloat(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetFloat(val); - return; - } - - _valFloat = val; - _type = VAL_FLOAT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setString(const char *val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setString(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetString(val); - return; - } - - setStringVal(val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; -} - -void CScValue::setString(const Common::String &val) { - setString(val.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -void CScValue::setStringVal(const char *val) { - if (_valString) { - delete [] _valString; - _valString = NULL; - } - - if (val == NULL) { - _valString = NULL; - return; - } - - _valString = new char [strlen(val) + 1]; - if (_valString) { - strcpy(_valString, val); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNULL() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNULL(); - return; - } - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; - } - _valNative = NULL; - deleteProps(); - - _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *val, bool persistent) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNative(val, persistent); - return; - } - - if (val == NULL) { - setNULL(); - } else { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != val) delete _valNative; - _valNative = NULL; - } - } - - _type = VAL_NATIVE; - _persistent = persistent; - - _valNative = val; - if (_valNative && !_persistent) _valNative->_refCount++; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setObject(); - return; - } - - deleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *val) { - _valRef = val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getBool(); - - switch (_type) { - case VAL_BOOL: - return _valBool; - - case VAL_NATIVE: - return _valNative->scToBool(); - - case VAL_INT: - return (_valInt != 0); - - case VAL_FLOAT: - return (_valFloat != 0.0f); - - case VAL_STRING: - return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1 : 0; - - case VAL_NATIVE: - return _valNative->scToInt(); - - case VAL_INT: - return _valInt; - - case VAL_FLOAT: - return (int)_valFloat; - - case VAL_STRING: - return atoi(_valString); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getFloat(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1.0f : 0.0f; - - case VAL_NATIVE: - return _valNative->scToFloat(); - - case VAL_INT: - return (double)_valInt; - - case VAL_FLOAT: - return _valFloat; - - case VAL_STRING: - return atof(_valString); - - default: - return defaultVal; - } -} - -////////////////////////////////////////////////////////////////////////// -void *CScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getMemBuffer(); - - if (_type == VAL_NATIVE) - return _valNative->scToMemBuffer(); - else return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::getString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getString(); - - switch (_type) { - case VAL_OBJECT: - setStringVal("[object]"); - break; - - case VAL_NULL: - setStringVal("[null]"); - break; - - case VAL_NATIVE: { - const char *strVal = _valNative->scToString(); - setStringVal(strVal); - return strVal; - break; - } - - case VAL_BOOL: - setStringVal(_valBool ? "yes" : "no"); - break; - - case VAL_INT: { - char dummy[50]; - sprintf(dummy, "%d", _valInt); - setStringVal(dummy); - break; - } - - case VAL_FLOAT: { - char dummy[50]; - sprintf(dummy, "%f", _valFloat); - setStringVal(dummy); - break; - } - - case VAL_STRING: - break; - - default: - setStringVal(""); - } - - return _valString; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::getNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getNative(); - - if (_type == VAL_NATIVE) return _valNative; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::copy(CScValue *orig, bool copyWhole) { - _gameRef = orig->_gameRef; - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; - _valNative = NULL; - } - } - - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; - - cleanup(true); - - _type = orig->_type; - _valBool = orig->_valBool; - _valInt = orig->_valInt; - _valFloat = orig->_valFloat; - setStringVal(orig->_valString); - - _valRef = orig->_valRef; - _persistent = orig->_persistent; - - _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; -//!!!! ref->native++ - - // copy properties - if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { - orig->_valIter = orig->_valObject.begin(); - while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(_gameRef); - _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); - orig->_valIter++; - } - } else _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setValue(CScValue *val) { - if (val->_type == VAL_VARIABLE_REF) { - setValue(val->_valRef); - return; - } - - // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { - switch (val->_type) { - case VAL_INT: - _valNative->scSetInt(val->getInt()); - break; - case VAL_FLOAT: - _valNative->scSetFloat(val->getFloat()); - break; - case VAL_BOOL: - _valNative->scSetBool(val->getBool()); - break; - case VAL_STRING: - _valNative->scSetString(val->getString()); - break; - default: - warning("CScValue::setValue - unhandled enum"); - break; - } - } - // otherwise just copy everything - else copy(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_persistent)); - persistMgr->transfer(TMEMBER(_isConstVar)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_valBool)); - persistMgr->transfer(TMEMBER(_valFloat)); - persistMgr->transfer(TMEMBER(_valInt)); - persistMgr->transfer(TMEMBER(_valNative)); - - int size; - const char *str; - if (persistMgr->_saving) { - size = _valObject.size(); - persistMgr->transfer("", &size); - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - str = _valIter->_key.c_str(); - persistMgr->transfer("", &str); - persistMgr->transfer("", &_valIter->_value); - - _valIter++; - } - } else { - CScValue *val; - persistMgr->transfer("", &size); - for (int i = 0; i < size; i++) { - persistMgr->transfer("", &str); - persistMgr->transfer("", &val); - - _valObject[str] = val; - delete [] str; - } - } - - persistMgr->transfer(TMEMBER(_valRef)); - persistMgr->transfer(TMEMBER(_valString)); - - /* - FILE* f = fopen("c:\\val.log", "a+"); - switch(_type) - { - case VAL_STRING: - fprintf(f, "str %s\n", _valString); - break; - - case VAL_INT: - fprintf(f, "int %d\n", _valInt); - break; - - case VAL_BOOL: - fprintf(f, "bool %d\n", _valBool); - break; - - case VAL_NULL: - fprintf(f, "null\n"); - break; - - case VAL_NATIVE: - fprintf(f, "native\n"); - break; - - case VAL_VARIABLE_REF: - fprintf(f, "ref\n"); - break; - - case VAL_OBJECT: - fprintf(f, "obj\n"); - break; - - case VAL_FLOAT: - fprintf(f, "float\n"); - break; - - } - fclose(f); - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - buffer->putTextIndent(indent, "PROPERTY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); - buffer->putTextIndent(indent, "}\n\n"); - - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::compare(CScValue *val1, CScValue *val2) { - // both natives? - if (val1->isNative() && val2->isNative()) { - // same class? - if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { - return val1->getNative()->scCompare(val2->getNative()); - } else return strcmp(val1->getString(), val2->getString()); - } - - // both objects? - if (val1->isObject() && val2->isObject()) return -1; - - - // null states - if (val1->isNULL() && !val2->isNULL()) return -1; - else if (!val1->isNULL() && val2->isNULL()) return 1; - else if (val1->isNULL() && val2->isNULL()) return 0; - - // one of them is string? convert both to string - if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); - - // one of them is float? - if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) return -1; - else if (val1->getFloat() > val2->getFloat()) return 1; - else return 0; - } - - // otherwise compare as int's - if (val1->getInt() < val2->getInt()) return -1; - else if (val1->getInt() > val2->getInt()) return 1; - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::compareStrict(CScValue *val1, CScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return CScValue::compare(val1, val2); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(_gameRef); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::dbgGetType() { - switch (getType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetValInt() { - return getInt(); -} - -////////////////////////////////////////////////////////////////////////// -double CScValue::dbgGetValFloat() { - return getFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetValBool() { - return getBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::dbgGetValString() { - return getString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::dbgGetValNative() { - return getNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(int value) { - setInt(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(double value) { - setFloat(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(bool value) { - setBool(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(const char *value) { - setString(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal() { - setNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetNumProperties(); - else return _valObject.size(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetProperty(index, name, value); - else { - int count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (count == index) { - *name = _valIter->_key.c_str(); - *value = _valIter->_value; - return true; - } - _valIter++; - count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) - return _valRef->dbgGetDescription(buf, bufSize); - - if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(buf, bufSize); - } else { - strncpy(buf, getString(), bufSize); - } - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/ScValue.h b/engines/wintermute/Base/scriptables/ScValue.h deleted file mode 100644 index 3410111d71..0000000000 --- a/engines/wintermute/Base/scriptables/ScValue.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCVALUE_H -#define WINTERMUTE_SCVALUE_H - - -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/wme_debugger.h" -#include "common/str.h" - -namespace WinterMute { - -class CScScript; -class CBScriptable; - -class CScValue : public CBBase, public IWmeDebugProp { -public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); - - static int compare(CScValue *val1, CScValue *val2); - static int compareStrict(CScValue *val1, CScValue *val2); - TValType getTypeTolerant(); - void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) - - bool _isConstVar; - bool saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *val); - bool _persistent; - bool propExists(const char *name); - void copy(CScValue *orig, bool copyWhole = false); - void setStringVal(const char *val); - TValType getType(); - bool getBool(bool defaultVal = false); - int getInt(int defaultVal = 0); - double getFloat(double defaultVal = 0.0f); - const char *getString(); - void *getMemBuffer(); - CBScriptable *getNative(); - bool deleteProp(const char *name); - void deleteProps(); - void CleanProps(bool includingNatives); - void setBool(bool val); - void setInt(int val); - void setFloat(double val); - void setString(const char *val); - void setString(const Common::String &val); - void setNULL(); - void setNative(CBScriptable *val, bool persistent = false); - void setObject(); - void setReference(CScValue *val); - bool isNULL(); - bool isNative(); - bool isString(); - bool isBool(); - bool isFloat(); - bool isInt(); - bool isObject(); - bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); - CScValue *getProp(const char *name); - CBScriptable *_valNative; - CScValue *_valRef; -protected: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; - - bool setProperty(const char *propName, int value); - bool setProperty(const char *propName, const char *value); - bool setProperty(const char *propName, double value); - bool setProperty(const char *propName, bool value); - bool setProperty(const char *propName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType dbgGetType(); - - // getters - virtual int dbgGetValInt(); - virtual double dbgGetValFloat(); - virtual bool dbgGetValBool(); - virtual const char *dbgGetValString(); - virtual IWmeDebugObject *dbgGetValNative(); - - // setters - virtual bool dbgSetVal(int value); - virtual bool dbgSetVal(double value); - virtual bool dbgSetVal(bool value); - virtual bool dbgSetVal(const char *value); - virtual bool dbgSetVal(); - - // properties - virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - - virtual bool dbgGetDescription(char *buf, int bufSize); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp deleted file mode 100644 index ba961ed2ae..0000000000 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SxObject.h" -#include "ScValue.h" -#include "ScStack.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CSXObject, false) - -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { - return new CSXObject(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int numParams = stack->pop()->getInt(0); - for (int i = 0; i < numParams; i++) { - addScript(stack->pop()->getString()); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Base/scriptables/SxObject.h b/engines/wintermute/Base/scriptables/SxObject.h deleted file mode 100644 index 35dab041d1..0000000000 --- a/engines/wintermute/Base/scriptables/SxObject.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/Base/BObject.h" - -namespace WinterMute { - -class CSXObject : public CBObject { -public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index b3834bf465..5bb757eee7 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -27,13 +27,13 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BRegistry.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" #include "common/str.h" #include "common/textconsole.h" #include "common/system.h" diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp deleted file mode 100644 index dee4b7d2d0..0000000000 --- a/engines/wintermute/Sys/SysClass.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "SysInstance.h" -#include "SysClass.h" -#include "SysClassRegistry.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { - _name = name; - - _build = build; - _load = load; - _next = NULL; - _savedID = -1; - _persistent = persistent_class; - _numInst = 0; - - CSysClassRegistry::getInstance()->registerClass(this); -} - - -////////////////////////////////////////////////////////////////////////// -CSysClass::~CSysClass() { - CSysClassRegistry::getInstance()->unregisterClass(this); - removeAllInstances(); -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeAllInstances() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - delete(it->_value); - } - _instances.clear(); - _instanceMap.clear(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { - CSysInstance *inst = new CSysInstance(instance, id, this); - inst->setSavedID(savedId); - _instances[inst] = (inst); - - _instanceMap[instance] = inst; - - CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); - - return inst; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeInstance(void *instance) { - InstanceMap::iterator mapIt = _instanceMap.find(instance); - if (mapIt == _instanceMap.end()) return false; - - Instances::iterator it = _instances.find((mapIt->_value)); - if (it != _instances.end()) { - delete(it->_value); - _instances.erase(it); - } - - _instanceMap.erase(mapIt); - - return false; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::getInstanceID(void *pointer) { - InstanceMap::iterator mapIt = _instanceMap.find(pointer); - if (mapIt == _instanceMap.end()) return -1; - else return (mapIt->_value)->getID(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClass::idToPointer(int savedID) { - //slow - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::getNumInstances() { - return _instances.size(); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::dump(Common::WriteStream *stream) { - Common::String str; - str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); - stream->write(str.c_str(), str.size()); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - persistMgr->putString(_name.c_str()); - persistMgr->putDWORD(_iD); - persistMgr->putDWORD(_instances.size()); - - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - persistMgr->putDWORD((it->_value)->getID()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - _savedID = persistMgr->getDWORD(); - int numInstances = persistMgr->getDWORD(); - - for (int i = 0; i < numInstances; i++) { - int instID = persistMgr->getDWORD(); - if (_persistent) { - - if (i > 0) { - gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); - continue; - } - - Instances::iterator it = _instances.begin(); - if (it != _instances.end()) { - (it->_value)->setSavedID(instID); - CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); - } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); - } - // normal instances, create empty objects - else { - void *emptyObject = _build(); - if (!emptyObject) { - warning("HALT"); - } - - addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); - } - - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - // write instace header - persistMgr->putString(""); - persistMgr->putDWORD(_iD); - persistMgr->putDWORD((it->_value)->getID()); - persistMgr->putString(""); - _load((it->_value)->getInstance(), persistMgr); - persistMgr->putString(""); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { - _load(instance, persistMgr); -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClass::resetSavedIDs() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - (it->_value)->setSavedID(-1); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - lpCallback((it->_value)->getInstance(), lpData); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h deleted file mode 100644 index f807ea677c..0000000000 --- a/engines/wintermute/Sys/SysClass.h +++ /dev/null @@ -1,130 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASS_H -#define WINTERMUTE_SYSCLASS_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dctypes.h" -#include "common/hashmap.h" -#include "common/func.h" -#include "common/stream.h" - -namespace WinterMute { -class CSysInstance; -class CBGame; -class CBPersistMgr; -class CSysClass; - -} - -namespace Common { -template struct Hash; - -template<> struct Hash : public UnaryFunction { - uint operator()(void *val) const { - return (uint)((size_t)val); - } -}; - -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysInstance *val) const { - return (uint)((size_t)val); - } -}; - - -} - -namespace WinterMute { - -class CSysClass { -public: - CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); - ~CSysClass(); - - int getNumInstances(); - bool removeInstance(void *instance); - CSysInstance *addInstance(void *instance, int id, int savedId = -1); - bool removeAllInstances(); - - int getInstanceID(void *pointer); - void *idToPointer(int savedID); - - void setID(int id) { - _iD = id; - } - int getID() const { - return _iD; - } - - int getSavedID() const { - return _savedID; - } - - bool isPersistent() const { - return _persistent; - } - - AnsiString getName() const { - return _name; - } - - void saveTable(CBGame *Game, CBPersistMgr *PersistMgr); - void loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - - void saveInstances(CBGame *Game, CBPersistMgr *PersistMgr); - void loadInstance(void *instance, CBPersistMgr *PersistMgr); - - void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); - - void resetSavedIDs(); - - void dump(Common::WriteStream *stream); - -private: - int _numInst; - bool _persistent; - CSysClass *_next; - int _iD; - int _savedID; - AnsiString _name; - PERSISTBUILD _build; - PERSISTLOAD _load; - - //typedef std::set Instances; - typedef Common::HashMap Instances; - Instances _instances; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp deleted file mode 100644 index 0b173c3afb..0000000000 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/wintermute.h" -#include "SysInstance.h" -#include "SysClassRegistry.h" -#include "common/stream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::CSysClassRegistry() { - _count = 0; - _disabled = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::~CSysClassRegistry() { - unregisterClasses(); -} - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry *CSysClassRegistry::getInstance() { - return g_wintermute->getClassRegistry(); -} - -void CSysClassRegistry::unregisterClasses() { - // CSysClass calls UnregisterClass upon destruction. - while (_classes.size() > 0) { - delete _classes.begin()->_value; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerClass(CSysClass *classObj) { - classObj->setID(_count++); - //_classes.insert(classObj); - _classes[classObj] = classObj; - - _nameMap[classObj->getName()] = classObj; - _idMap[classObj->getID()] = classObj; - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { - - Classes::iterator it = _classes.find(classObj); - if (it == _classes.end()) return false; - - if (classObj->getNumInstances() != 0) { - char str[MAX_PATH_LENGTH]; - sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - CBPlatform::outputDebugString(str); - } - _classes.erase(it); - - NameMap::iterator mapIt = _nameMap.find(classObj->getName()); - if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); - - IdMap::iterator idIt = _idMap.find(classObj->getID()); - if (idIt != _idMap.end()) _idMap.erase(idIt); - - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerInstance(const char *className, void *instance) { - if (_disabled) return true; - - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - - CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); - return (inst != NULL); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { - _instanceMap[pointer] = instance; - - if (instance->getSavedID() >= 0) - _savedInstanceMap[instance->getSavedID()] = instance; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClassRegistry::getNextID() { - return _count++; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - (*mapIt)._value->removeInstance(instance); - - InstanceMap::iterator instIt = _instanceMap.find(instance); - if (instIt != _instanceMap.end()) { - _instanceMap.erase(instIt); - return true; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { - if (pointer == NULL) return true; - - InstanceMap::iterator it = _instanceMap.find(pointer); - if (it == _instanceMap.end()) return false; - - - CSysInstance *inst = (*it)._value; - *instanceID = inst->getID(); - *classID = inst->getClass()->getID(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClassRegistry::idToPointer(int classID, int instanceID) { - SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); - if (it == _savedInstanceMap.end()) return NULL; - else return (*it)._value->getInstance(); -} - -bool checkHeader(const char *tag, CBPersistMgr *pm) { - char *test = pm->getString(); - Common::String verify = test; - delete[] test; - bool retVal = (verify == tag); - if (!retVal) { - error("Expected %s in Save-file not found", tag); - } - return retVal; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { - persistMgr->putString(""); - persistMgr->putDWORD(_classes.size()); - - int counter = 0; - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); - gameRef->displayContent(false); - gameRef->_renderer->flip(); - } - - (it->_value)->saveTable(gameRef, persistMgr); - } - persistMgr->putString(""); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - checkHeader("", persistMgr); - - // reset SavedID of current instances - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - (it->_value)->resetSavedIDs(); - } - - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->isPersistent()) continue; - (it->_value)->removeAllInstances(); - } - - _instanceMap.clear(); - - uint32 numClasses = persistMgr->getDWORD(); - - for (uint32 i = 0; i < numClasses; i++) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); - - Common::String className = persistMgr->getStringObj(); - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); - } - - checkHeader("", persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { - - Classes::iterator it; - - // count total instances - int numInstances = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - numInstances += (it->_value)->getNumInstances(); - } - - persistMgr->putDWORD(numInstances); - - int counter = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - if (counter % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); - gameRef->displayContent(false); - gameRef->_renderer->flip(); - } - } - gameRef->miniUpdate(); - - (it->_value)->saveInstances(gameRef, persistMgr); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { - // get total instances - int numInstances = persistMgr->getDWORD(); - - for (int i = 0; i < numInstances; i++) { - if (i % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); - } - - checkHeader("", persistMgr); - - int classID = persistMgr->getDWORD(); - int instanceID = persistMgr->getDWORD(); - void *instance = idToPointer(classID, instanceID); - - checkHeader("", persistMgr); - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->getSavedID() == classID) { - (it->_value)->loadInstance(instance, persistMgr); - break; - } - } - checkHeader("", persistMgr); - } - - _savedInstanceMap.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return STATUS_FAILED; - - (*mapIt)._value->instanceCallback(lpCallback, lpData); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) - (it->_value)->dump(stream); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h deleted file mode 100644 index a4a410527d..0000000000 --- a/engines/wintermute/Sys/SysClassRegistry.h +++ /dev/null @@ -1,106 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASSREGISTRY_H -#define WINTERMUTE_SYSCLASSREGISTRY_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/func.h" -#include "common/stream.h" - -namespace WinterMute { -class CSysClass; -} - -namespace Common { -template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysClass *val) const { - return (uint)((size_t)val); - } -}; - -} - -namespace WinterMute { - -class CBGame; -class CBPersistMgr; -class CSysInstance; - -class CSysClassRegistry { - void unregisterClasses(); -public: - void registerClasses(); // persistent.cpp - static CSysClassRegistry *getInstance(); - - CSysClassRegistry(); - virtual ~CSysClassRegistry(); - - bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - bool loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - bool saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - bool loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - bool saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - void *idToPointer(int classID, int instanceID); - bool getPointerID(void *pointer, int *classID, int *instanceID); - bool registerClass(CSysClass *classObj); - bool unregisterClass(CSysClass *classObj); - bool registerInstance(const char *className, void *instance); - bool unregisterInstance(const char *className, void *instance); - void dumpClasses(Common::WriteStream *stream); - int getNextID(); - void addInstanceToTable(CSysInstance *instance, void *pointer); - - bool _disabled; - int _count; - - typedef Common::HashMap Classes; - Classes _classes; - - typedef Common::HashMap NameMap; - NameMap _nameMap; - - typedef Common::HashMap IdMap; - IdMap _idMap; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; - - typedef Common::HashMap SavedInstanceMap; - SavedInstanceMap _savedInstanceMap; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/Sys/SysInstance.cpp b/engines/wintermute/Sys/SysInstance.cpp deleted file mode 100644 index b7f6079912..0000000000 --- a/engines/wintermute/Sys/SysInstance.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SysInstance.h" -#include "SysClassRegistry.h" -#include "SysClass.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { - _instance = instance; - _id = id; - _savedID = -1; - _class = sysClass; - - _used = false; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance::~CSysInstance() { -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/Sys/SysInstance.h b/engines/wintermute/Sys/SysInstance.h deleted file mode 100644 index 6becd491af..0000000000 --- a/engines/wintermute/Sys/SysInstance.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSINSTANCE_H -#define WINTERMUTE_SYSINSTANCE_H - -namespace WinterMute { - -class CSysClass; - -class CSysInstance { -public: - CSysInstance(void *Instance, int ID, CSysClass *sysClass); - virtual ~CSysInstance(); - - int getID() const { - return _id; - } - int getSavedID() const { - return _savedID; - } - void *getInstance() const { - return _instance; - } - CSysClass *getClass() const { - return _class; - } - - void setSavedID(int id) { - _savedID = id; - } - -private: - bool _used; - int _id; - int _savedID; - void *_instance; - CSysClass *_class; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp deleted file mode 100644 index 40c5166b45..0000000000 --- a/engines/wintermute/UI/UIButton.cpp +++ /dev/null @@ -1,1046 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/UI/UIButton.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIButton, false) - -////////////////////////////////////////////////////////////////////////// -CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { - _backPress = _backHover = _backDisable = _backFocus = NULL; - - _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; - - _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; - - _align = TAL_CENTER; - - _hover = _press = false; - - _type = UI_BUTTON; - - _canFocus = false; - _stayPressed = false; - - _oneTimePress = false; - _centerImage = false; - - _pixelPerfect = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIButton::~CUIButton() { - delete _backPress; - delete _backHover; - delete _backDisable; - delete _backFocus; - - if (!_sharedFonts) { - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - } - - if (!_sharedImages) { - delete _imageHover; - delete _imagePress; - delete _imageDisable; - delete _imageFocus; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(BUTTON) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(FOCUSABLE) -TOKEN_DEF(BACK_HOVER) -TOKEN_DEF(BACK_PRESS) -TOKEN_DEF(BACK_DISABLE) -TOKEN_DEF(BACK_FOCUS) -TOKEN_DEF(BACK) -TOKEN_DEF(CENTER_IMAGE) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE_PRESS) -TOKEN_DEF(IMAGE_DISABLE) -TOKEN_DEF(IMAGE_FOCUS) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT_PRESS) -TOKEN_DEF(FONT_DISABLE) -TOKEN_DEF(FONT_FOCUS) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(PRESSED) -TOKEN_DEF(PIXEL_PERFECT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(FOCUSABLE) - TOKEN_TABLE(BACK_HOVER) - TOKEN_TABLE(BACK_PRESS) - TOKEN_TABLE(BACK_DISABLE) - TOKEN_TABLE(BACK_FOCUS) - TOKEN_TABLE(BACK) - TOKEN_TABLE(CENTER_IMAGE) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE_PRESS) - TOKEN_TABLE(IMAGE_DISABLE) - TOKEN_TABLE(IMAGE_FOCUS) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT_PRESS) - TOKEN_TABLE(FONT_DISABLE) - TOKEN_TABLE(FONT_FOCUS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(PRESSED) - TOKEN_TABLE(PIXEL_PERFECT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { - _gameRef->LOG(0, "'BUTTON' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_HOVER: - delete _backHover; - _backHover = new CUITiledImage(_gameRef); - if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { - delete _backHover; - _backHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_PRESS: - delete _backPress; - _backPress = new CUITiledImage(_gameRef); - if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { - delete _backPress; - _backPress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_DISABLE: - delete _backDisable; - _backDisable = new CUITiledImage(_gameRef); - if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { - delete _backDisable; - _backDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_FOCUS: - delete _backFocus; - _backFocus = new CUITiledImage(_gameRef); - if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { - delete _backFocus; - _backFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - delete _imageHover; - _imageHover = new CBSprite(_gameRef); - if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { - delete _imageHover; - _imageHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_PRESS: - delete _imagePress; - _imagePress = new CBSprite(_gameRef); - if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { - delete _imagePress; - _imagePress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_DISABLE: - delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); - if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { - delete _imageDisable; - _imageDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_FOCUS: - delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); - if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { - delete _imageFocus; - _imageFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_PRESS: - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - _fontPress = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontPress) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_DISABLE: - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - _fontDisable = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontDisable) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_FOCUS: - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - _fontFocus = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontFocus) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_CENTER; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_FOCUSABLE: - parser.scanStr((char *)params, "%b", &_canFocus); - break; - - case TOKEN_CENTER_IMAGE: - parser.scanStr((char *)params, "%b", &_centerImage); - break; - - case TOKEN_PRESSED: - parser.scanStr((char *)params, "%b", &_stayPressed); - break; - - case TOKEN_PIXEL_PERFECT: - parser.scanStr((char *)params, "%b", &_pixelPerfect); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in BUTTON definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading BUTTON definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "BUTTON\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backHover && _backHover->_filename) - buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); - if (_backPress && _backPress->_filename) - buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); - if (_backDisable && _backDisable->_filename) - buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); - if (_backFocus && _backFocus->_filename) - buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageHover && _imageHover->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); - if (_imagePress && _imagePress->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); - if (_imageDisable && _imageDisable->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); - if (_imageFocus && _imageFocus->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - if (_fontPress && _fontPress->_filename) - buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); - if (_fontDisable && _fontDisable->_filename) - buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); - if (_fontFocus && _fontFocus->_filename) - buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_align) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - warning("CUIButton::SaveAsText - unhandled enum"); - break; - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUIButton::correctSize() { - Rect32 rect; - - CBSprite *img = NULL; - if (_image) img = _image; - else if (_imageDisable) img = _imageDisable; - else if (_imageHover) img = _imageHover; - else if (_imagePress) img = _imagePress; - else if (_imageFocus) img = _imageFocus; - - if (_width <= 0) { - if (img) { - img->getBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (img) { - img->getBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_text) { - int text_height; - if (_font) text_height = _font->getTextHeight((byte *)_text, _width); - else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); - - if (text_height > _height) _height = text_height; - } - - if (_height <= 0) _height = 100; - - if (_back) _back->correctSize(&_width, &_height); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::display(int offsetX, int offsetY) { - if (!_visible) - return STATUS_OK; - - CUITiledImage *back = NULL; - CBSprite *image = NULL; - CBFont *font = 0; - - //RECT rect; - //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); - _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); - - if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); - - - if (_disable) { - if (_backDisable) back = _backDisable; - if (_imageDisable) image = _imageDisable; - if (_text && _fontDisable) font = _fontDisable; - } else if (_press || _oneTimePress || _stayPressed) { - if (_backPress) back = _backPress; - if (_imagePress) image = _imagePress; - if (_text && _fontPress) font = _fontPress; - } else if (_hover) { - if (_backHover) back = _backHover; - if (_imageHover) image = _imageHover; - if (_text && _fontHover) font = _fontHover; - } else if (_canFocus && isFocused()) { - if (_backFocus) back = _backFocus; - if (_imageFocus) image = _imageFocus; - if (_text && _fontFocus) font = _fontFocus; - } - - if (!back && _back) back = _back; - if (!image && _image) image = _image; - if (_text && !font) { - if (_font) font = _font; - else font = _gameRef->_systemFont; - } - - int imageX = offsetX + _posX; - int imageY = offsetY + _posY; - - if (image && _centerImage) { - Rect32 rc; - image->getBoundingRect(&rc, 0, 0); - imageX += (_width - (rc.right - rc.left)) / 2; - imageY += (_height - (rc.bottom - rc.top)) / 2; - } - - if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); - //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); - - if (font && _text) { - int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; - font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); - } - - if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - - // reset unused sprites - if (_image && _image != image) _image->reset(); - if (_imageDisable && _imageDisable != image) _imageDisable->reset(); - if (_imageFocus && _imageFocus != image) _imageFocus->reset(); - if (_imagePress && _imagePress != image) _imagePress->reset(); - if (_imageHover && _imageHover != image) _imageHover->reset(); - - _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIButton::press() { - applyEvent("Press"); - if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->applyEvent(_name); - - _oneTimePress = false; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetDisabledFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetDisabledFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (Val->isNULL()) { - _fontDisable = NULL; - stack->pushBool(true); - } else { - _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_fontDisable != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHoverFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - if (val->isNULL()) { - _fontHover = NULL; - stack->pushBool(true); - } else { - _fontHover = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontHover != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPressedFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (Val->isNULL()) { - _fontPress = NULL; - stack->pushBool(true); - } else { - _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_fontPress != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFocusedFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - if (val->isNULL()) { - _fontFocus = NULL; - stack->pushBool(true); - } else { - _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontFocus != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDisabledImage") == 0) { - stack->correctParams(1); - - delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { - delete _imageDisable; - _imageDisable = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDisabledImage") == 0) { - stack->correctParams(0); - if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); - else stack->pushString(_imageDisable->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDisabledImageObject") == 0) { - stack->correctParams(0); - if (!_imageDisable) stack->pushNULL(); - else stack->pushNative(_imageDisable, true); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHoverImage") == 0) { - stack->correctParams(1); - - delete _imageHover; - _imageHover = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { - delete _imageHover; - _imageHover = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverImage") == 0) { - stack->correctParams(0); - if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); - else stack->pushString(_imageHover->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverImageObject") == 0) { - stack->correctParams(0); - if (!_imageHover) stack->pushNULL(); - else stack->pushNative(_imageHover, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPressedImage") == 0) { - stack->correctParams(1); - - delete _imagePress; - _imagePress = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { - delete _imagePress; - _imagePress = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPressedImage") == 0) { - stack->correctParams(0); - if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); - else stack->pushString(_imagePress->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPressedImageObject") == 0) { - stack->correctParams(0); - if (!_imagePress) stack->pushNULL(); - else stack->pushNative(_imagePress, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFocusedImage") == 0) { - stack->correctParams(1); - - delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { - delete _imageFocus; - _imageFocus = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFocusedImage") == 0) { - stack->correctParams(0); - if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); - else stack->pushString(_imageFocus->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFocusedImageObject") == 0) { - stack->correctParams(0); - if (!_imageFocus) stack->pushNULL(); - else stack->pushNative(_imageFocus, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Press - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Press") == 0) { - stack->correctParams(0); - - if (_visible && !_disable) { - _oneTimePress = true; - _oneTimePressTime = CBPlatform::getTime(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("button"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { - _scValue->setInt(_align); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focusable") == 0) { - _scValue->setBool(_canFocus); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pressed") == 0) { - _scValue->setBool(_stayPressed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_pixelPerfect); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "TextAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _align = (TTextAlign)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focusable") == 0) { - _canFocus = value->getBool(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pressed") == 0) { - _stayPressed = value->getBool(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _pixelPerfect = value->getBool(); - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIButton::scToString() { - return "[button]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER_INT(_align)); - persistMgr->transfer(TMEMBER(_backDisable)); - persistMgr->transfer(TMEMBER(_backFocus)); - persistMgr->transfer(TMEMBER(_backHover)); - persistMgr->transfer(TMEMBER(_backPress)); - persistMgr->transfer(TMEMBER(_centerImage)); - persistMgr->transfer(TMEMBER(_fontDisable)); - persistMgr->transfer(TMEMBER(_fontFocus)); - persistMgr->transfer(TMEMBER(_fontHover)); - persistMgr->transfer(TMEMBER(_fontPress)); - persistMgr->transfer(TMEMBER(_hover)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_imageDisable)); - persistMgr->transfer(TMEMBER(_imageFocus)); - persistMgr->transfer(TMEMBER(_imageHover)); - persistMgr->transfer(TMEMBER(_imagePress)); - persistMgr->transfer(TMEMBER(_pixelPerfect)); - persistMgr->transfer(TMEMBER(_press)); - persistMgr->transfer(TMEMBER(_stayPressed)); - - if (!persistMgr->_saving) { - _oneTimePress = false; - _oneTimePressTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIButton.h b/engines/wintermute/UI/UIButton.h deleted file mode 100644 index 5bdc075ebc..0000000000 --- a/engines/wintermute/UI/UIButton.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIBUTTON_H -#define WINTERMUTE_UIBUTTON_H - - -#include "UIObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUIButton : public CUIObject { -public: - bool _pixelPerfect; - bool _stayPressed; - bool _centerImage; - bool _oneTimePress; - uint32 _oneTimePressTime; - DECLARE_PERSISTENT(CUIButton, CUIObject) - void press(); - virtual bool display(int offsetX = 0, int offsetY = 0); - bool _press; - bool _hover; - void correctSize(); - TTextAlign _align; - CBSprite *_imageHover; - CBSprite *_imagePress; - CBSprite *_imageDisable; - CBSprite *_imageFocus; - CBFont *_fontDisable; - CBFont *_fontPress; - CBFont *_fontHover; - CBFont *_fontFocus; - CUITiledImage *_backPress; - CUITiledImage *_backHover; - CUITiledImage *_backDisable; - CUITiledImage *_backFocus; - CUIButton(CBGame *inGame = NULL); - virtual ~CUIButton(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp deleted file mode 100644 index f964ada462..0000000000 --- a/engines/wintermute/UI/UIEdit.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/UI/UIEdit.h" -#include "engines/wintermute/UI/UIObject.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/utils/utils.h" -#include "common/util.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEdit, false) - -////////////////////////////////////////////////////////////////////////// -CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { - _type = UI_EDIT; - - _fontSelected = NULL; - - _selStart = _selEnd = 10000; - _scrollOffset = 0; - - _cursorChar = NULL; - setCursorChar("|"); - - _cursorBlinkRate = 600; - - _frameWidth = 0; - - setText(""); - - _lastBlinkTime = 0; - _cursorVisible = true; - - _maxLength = -1; - - _canFocus = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEdit::~CUIEdit() { - if (!_sharedFonts) { - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - } - - delete[] _cursorChar; - _cursorChar = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_SELECTED) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR_BLINK_RATE) -TOKEN_DEF(CURSOR) -TOKEN_DEF(FRAME_WIDTH) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MAX_LENGTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF(CAPTION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_SELECTED) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR_BLINK_RATE) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(FRAME_WIDTH) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MAX_LENGTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { - _gameRef->LOG(0, "'EDIT' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_SELECTED: - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - _fontSelected = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontSelected) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_MAX_LENGTH: - parser.scanStr((char *)params, "%d", &_maxLength); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_BLINK_RATE: - parser.scanStr((char *)params, "%d", &_cursorBlinkRate); - break; - - case TOKEN_FRAME_WIDTH: - parser.scanStr((char *)params, "%d", &_frameWidth); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in EDIT definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading EDIT definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "EDIT\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontSelected && _fontSelected->_filename) - buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - buffer->putTextIndent(indent + 2, "MAX_LENGTH=%d\n", _maxLength); - buffer->putTextIndent(indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); - buffer->putTextIndent(indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSelectedFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSelectedFont") == 0) { - stack->correctParams(1); - - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontSelected != NULL); - - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("editor"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelStart") == 0) { - _scValue->setInt(_selStart); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { - _scValue->setInt(_selEnd); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { - _scValue->setInt(_cursorBlinkRate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorChar") == 0) { - _scValue->setString(_cursorChar); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FrameWidth") == 0) { - _scValue->setInt(_frameWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxLength") == 0) { - _scValue->setInt(_maxLength); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::ansiToWide(_text); - _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); - } else { - _scValue->setString(_text); - } - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelStart") == 0) { - _selStart = value->getInt(); - _selStart = MAX(_selStart, 0); - _selStart = MIN((size_t)_selStart, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { - _selEnd = value->getInt(); - _selEnd = MAX(_selEnd, 0); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorChar") == 0) { - setCursorChar(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FrameWidth") == 0) { - _frameWidth = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxLength") == 0) { - _maxLength = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(value->getString()); - setText(StringUtil::wideToAnsi(wstr).c_str()); - } else { - setText(value->getString()); - } - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEdit::scToString() { - return "[edit]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIEdit::setCursorChar(const char *character) { - if (!character) return; - delete[] _cursorChar; - _cursorChar = new char [strlen(character) + 1]; - if (_cursorChar) strcpy(_cursorChar, character); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - - // hack! - TTextEncoding OrigEncoding = _gameRef->_textEncoding; - _gameRef->_textEncoding = TEXT_ANSI; - - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); - - // prepare fonts - CBFont *font; - CBFont *sfont; - - if (_font) font = _font; - else font = _gameRef->_systemFont; - - if (_fontSelected) sfont = _fontSelected; - else sfont = font; - - bool focused = isFocused(); - - _selStart = MAX(_selStart, 0); - _selEnd = MAX(_selEnd, 0); - - _selStart = MIN((size_t)_selStart, strlen(_text)); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - - //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int cursorWidth = font->getTextWidth((byte *)_cursorChar); - - int s1, s2; - bool curFirst; - // modify scroll offset - if (_selStart >= _selEnd) { - while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selEnd; - s2 = _selStart; - curFirst = true; - } else { - while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + - sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - - > _width - cursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selStart; - s2 = _selEnd; - curFirst = false; - } - - - int AlignOffset = 0; - - for (int Count = 0; Count < 2; Count++) { - // draw text - int xxx, yyy, width, height; - - xxx = _posX + _frameWidth + offsetX; - yyy = _posY + _frameWidth + offsetY; - - width = _posX + _width + offsetX - _frameWidth; - height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); - - if (_gameRef->_textRTL) xxx += AlignOffset; - - TTextAlign Align = TAL_LEFT; - - - // unselected 1 - if (s1 > _scrollOffset) { - if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); - xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - } - - // cursor - if (focused && curFirst) { - if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += cursorWidth; - AlignOffset += cursorWidth; - } - - // selected - int s3 = MAX(s1, _scrollOffset); - - if (s2 - s3 > 0) { - if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); - } - - // cursor - if (focused && !curFirst) { - if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += cursorWidth; - AlignOffset += cursorWidth; - } - - // unselected 2 - if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->getTextWidth((byte *)_text + s2); - - AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; - if (AlignOffset < 0) AlignOffset = 0; - } - - - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - - - _gameRef->_textEncoding = OrigEncoding; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { - bool handled = false; - - if (event->type == Common::EVENT_KEYDOWN && !printable) { - switch (event->kbd.keycode) { - case Common::KEYCODE_ESCAPE: - case Common::KEYCODE_TAB: - case Common::KEYCODE_RETURN: - return false; - - // ctrl+A - case Common::KEYCODE_a: - if (CBKeyboardState::isControlDown()) { - _selStart = 0; - _selEnd = strlen(_text); - handled = true; - } - break; - - case Common::KEYCODE_BACKSPACE: - if (_selStart == _selEnd) { - if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); - else deleteChars(_selStart - 1, _selStart); - } else deleteChars(_selStart, _selEnd); - if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); - _selStart = _selEnd; - - handled = true; - break; - - case Common::KEYCODE_LEFT: - case Common::KEYCODE_UP: - _selEnd--; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - handled = true; - break; - - case Common::KEYCODE_RIGHT: - case Common::KEYCODE_DOWN: - _selEnd++; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - handled = true; - break; - - case Common::KEYCODE_HOME: - if (_gameRef->_textRTL) { - _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } else { - _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_END: - if (_gameRef->_textRTL) { - _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } else { - _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_DELETE: - if (_selStart == _selEnd) { - if (_gameRef->_textRTL) { - deleteChars(_selStart - 1, _selStart); - _selEnd--; - if (_selEnd < 0) _selEnd = 0; - } else deleteChars(_selStart, _selStart + 1); - } else deleteChars(_selStart, _selEnd); - if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); - - _selStart = _selEnd; - handled = true; - break; - default: - break; - } - return handled; - } else if (event->type == Common::EVENT_KEYDOWN && printable) { - if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); - - //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); - WideString wstr; - wstr += (char)event->kbd.ascii; - _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); - - if (_gameRef->_textRTL) _selEnd = _selStart; - else _selStart = _selEnd; - - return true; - } - - return false; -} - - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::deleteChars(int start, int end) { - if (start > end) CBUtils::swap(&start, &end); - - start = MAX(start, (int)0); - end = MIN((size_t)end, strlen(_text)); - - char *str = new char[strlen(_text) - (end - start) + 1]; - if (str) { - if (start > 0) memcpy(str, _text, start); - memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->applyEvent(_name); - - return end - start; -} - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::insertChars(int pos, byte *chars, int num) { - if ((int)strlen(_text) + num > _maxLength) { - num -= (strlen(_text) + num - _maxLength); - } - - pos = MAX(pos, (int)0); - pos = MIN((size_t)pos, strlen(_text)); - - char *str = new char[strlen(_text) + num + 1]; - if (str) { - if (pos > 0) memcpy(str, _text, pos); - memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); - - memcpy(str + pos, chars, num); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->applyEvent(_name); - - return num; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_cursorBlinkRate)); - persistMgr->transfer(TMEMBER(_cursorChar)); - persistMgr->transfer(TMEMBER(_fontSelected)); - persistMgr->transfer(TMEMBER(_frameWidth)); - persistMgr->transfer(TMEMBER(_maxLength)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_selEnd)); - persistMgr->transfer(TMEMBER(_selStart)); - - if (!persistMgr->_saving) { - _cursorVisible = false; - _lastBlinkTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h deleted file mode 100644 index 7249301592..0000000000 --- a/engines/wintermute/UI/UIEdit.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIEDIT_H -#define WINTERMUTE_UIEDIT_H - -#include "engines/wintermute/persistent.h" -#include "UIObject.h" -#include "common/events.h" - -namespace WinterMute { -class CBFont; -class CUIEdit : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEdit, CUIObject) - int _maxLength; - int insertChars(int pos, byte *chars, int num); - int deleteChars(int start, int end); - bool _cursorVisible; - uint32 _lastBlinkTime; - virtual bool display(int offsetX, int offsetY); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - int _scrollOffset; - int _frameWidth; - uint32 _cursorBlinkRate; - void setCursorChar(const char *character); - char *_cursorChar; - int _selEnd; - int _selStart; - CBFont *_fontSelected; - CUIEdit(CBGame *inGame); - virtual ~CUIEdit(); - - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp deleted file mode 100644 index a479cd9bd1..0000000000 --- a/engines/wintermute/UI/UIEntity.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/UI/UIEntity.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEntity, false) - -////////////////////////////////////////////////////////////////////////// -CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { - _type = UI_CUSTOM; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEntity::~CUIEntity() { - if (_entity) _gameRef->unregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(NAME) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { - _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_ENTITY: - if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition"); - return STATUS_FAILED; - } - - correctSize(); - - if (_gameRef->_editorMode) { - _width = 50; - _height = 50; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - - if (_entity && _entity->_filename) - buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::setEntity(const char *filename) { - if (_entity) _gameRef->unregisterObject(_entity); - _entity = new CAdEntity(_gameRef); - if (!_entity || DID_FAIL(_entity->loadFile(filename))) { - delete _entity; - _entity = NULL; - return STATUS_FAILED; - } else { - _entity->_nonIntMouseEvents = true; - _entity->_sceneIndependent = true; - _entity->makeFreezable(false); - _gameRef->registerObject(_entity); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - if (_entity) { - _entity->_posX = offsetX + _posX; - _entity->_posY = offsetY + _posY; - if (_entity->_scale < 0) _entity->_zoomable = false; - _entity->_shadowable = false; - - _entity->update(); - - bool origReg = _entity->_registrable; - - if (_entity->_registrable && _disable) _entity->_registrable = false; - - _entity->display(); - _entity->_registrable = origReg; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetEntity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetEntity") == 0) { - stack->correctParams(0); - - if (_entity) stack->pushNative(_entity, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetEntity") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - if (DID_SUCCEED(setEntity(filename))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("entity container"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Freezable") == 0) { - if (_entity) _scValue->setBool(_entity->_freezable); - else _scValue->setBool(false); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Freezable") == 0) { - if (_entity) _entity->makeFreezable(value->getBool()); - return STATUS_OK; - } else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEntity::scToString() { - return "[entity container]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIEntity.h b/engines/wintermute/UI/UIEntity.h deleted file mode 100644 index b0711838a5..0000000000 --- a/engines/wintermute/UI/UIEntity.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIENTITY_H -#define WINTERMUTE_UIENTITY_H - -#include "UIObject.h" - -namespace WinterMute { -class CAdEntity; -class CUIEntity : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEntity, CUIObject) - CUIEntity(CBGame *inGame); - virtual ~CUIEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - virtual bool display(int offsetX = 0, int offsetY = 0); - CAdEntity *_entity; - bool setEntity(const char *filename); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp deleted file mode 100644 index 28241c4ae4..0000000000 --- a/engines/wintermute/UI/UIObject.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/UI/UIObject.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/font/BFontStorage.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIObject, false) - -////////////////////////////////////////////////////////////////////////// -CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { - _back = NULL; - _image = NULL; - _font = NULL; - _text = NULL; - _sharedFonts = _sharedImages = false; - - _width = _height = 0; - - _listenerObject = NULL; - _listenerParamObject = NULL; - _listenerParamDWORD = 0; - - _disable = false; - _visible = true; - - _type = UI_UNKNOWN; - _parent = NULL; - - _parentNotify = false; - - _focusedWidget = NULL; - - _canFocus = false; - _nonIntMouseEvents = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIObject::~CUIObject() { - if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); - - if (_back) delete _back; - if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); - - if (_image && !_sharedImages) delete _image; - - if (_text) delete [] _text; - - _focusedWidget = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::setText(const char *text) { - if (_text) delete [] _text; - _text = new char [strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - for (int i = 0; i < strlen(_text); i++) { - if (_text[i] == '|') _text[i] = '\n'; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::display(int offsetX, int offsetY) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { - _listenerObject = object; - _listenerParamObject = listenerObject; - _listenerParamDWORD = listenerParam; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::correctSize() { - Rect32 rect; - - if (_width <= 0) { - if (_image) { - _image->getBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (_image) { - _image->getBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_back) _back->correctSize(&_width, &_height); -} - - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (Val->isNULL()) { - _font = NULL; - stack->pushBool(true); - } else { - _font = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_font != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - /* const char *filename = */ val->getString(); - - delete _image; - _image = NULL; - if (val->isNULL()) { - stack->pushBool(true); - return STATUS_OK; - } - - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { - delete _image; - _image = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - if (!_image || !_image->_filename) stack->pushNULL(); - else stack->pushString(_image->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetImageObject") == 0) { - stack->correctParams(0); - if (!_image) stack->pushNULL(); - else stack->pushNative(_image, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focus - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focus") == 0) { - stack->correctParams(0); - focus(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveAfter / MoveBefore - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { - stack->correctParams(1); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - - int i; - bool found = false; - CScValue *val = stack->pop(); - // find directly - if (val->isNative()) { - CUIObject *widget = (CUIObject *)val->getNative(); - for (i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == widget) { - found = true; - break; - } - } - } - // find by name - else { - const char *findName = val->getString(); - for (i = 0; i < win->_widgets.getSize(); i++) { - if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { - found = true; - break; - } - } - } - - if (found) { - bool done = false; - for (int j = 0; j < win->_widgets.getSize(); j++) { - if (win->_widgets[j] == this) { - if (strcmp(name, "MoveAfter") == 0) i++; - if (j >= i) j++; - - win->_widgets.insertAt(i, this); - win->_widgets.removeAt(j); - - done = true; - stack->pushBool(true); - break; - } - } - if (!done) stack->pushBool(false); - } else stack->pushBool(false); - - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToBottom - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveToBottom") == 0) { - stack->correctParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); - win->_widgets.insertAt(0, this); - break; - } - } - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToTop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveToTop") == 0) { - stack->correctParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); - win->_widgets.add(this); - break; - } - } - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("ui_object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Parent (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Parent") == 0) { - _scValue->setNative(_parent, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParentNotify") == 0) { - _scValue->setBool(_parentNotify); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Visible") == 0) { - _scValue->setBool(_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Disabled") == 0) { - _scValue->setBool(_disable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - _scValue->setString(_text); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NextSibling (RO) / PrevSibling (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { - _scValue->setNULL(); - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); - } else { - if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); - } - break; - } - } - } - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParentNotify") == 0) { - _parentNotify = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Visible") == 0) { - _visible = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Disabled") == 0) { - _disable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - setText(value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIObject::scToString() { - return "[ui_object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::isFocused() { - if (!_gameRef->_focusedWindow) return false; - if (_gameRef->_focusedWindow == this) return true; - - CUIObject *obj = _gameRef->_focusedWindow; - while (obj) { - if (obj == this) return true; - else obj = obj->_focusedWidget; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { - // handle focus change - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - focus(); - } - return CBObject::handleMouse(event, button); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::focus() { - CUIObject *obj = this; - bool disabled = false; - while (obj) { - if (obj->_disable && obj->_type == UI_WINDOW) { - disabled = true; - break; - } - obj = obj->_parent; - } - if (!disabled) { - obj = this; - while (obj) { - if (obj->_parent) { - if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; - } else { - if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); - } - - obj = obj->_parent; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { - int offX = 0, offY = 0; - - CUIObject *obj = _parent; - while (obj) { - offX += obj->_posX; - offY += obj->_posY; - - obj = obj->_parent; - } - if (offsetX) *offsetX = offX; - if (offsetY) *offsetY = offY; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_back)); - persistMgr->transfer(TMEMBER(_canFocus)); - persistMgr->transfer(TMEMBER(_disable)); - persistMgr->transfer(TMEMBER(_focusedWidget)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_listenerObject)); - persistMgr->transfer(TMEMBER(_listenerParamObject)); - persistMgr->transfer(TMEMBER(_listenerParamDWORD)); - persistMgr->transfer(TMEMBER(_parent)); - persistMgr->transfer(TMEMBER(_parentNotify)); - persistMgr->transfer(TMEMBER(_sharedFonts)); - persistMgr->transfer(TMEMBER(_sharedImages)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { - return STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIObject.h b/engines/wintermute/UI/UIObject.h deleted file mode 100644 index a51df9485d..0000000000 --- a/engines/wintermute/UI/UIObject.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIOBJECT_H -#define WINTERMUTE_UIOBJECT_H - - -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUITiledImage; -class CBFont; -class CUIObject : public CBObject { -public: - - bool getTotalOffset(int *offsetX, int *offsetY); - bool _canFocus; - bool focus(); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - bool isFocused(); - bool _parentNotify; - DECLARE_PERSISTENT(CUIObject, CBObject) - CUIObject *_parent; - virtual bool display(int offsetX = 0, int offsetY = 0); - virtual void correctSize(); - bool _sharedFonts; - bool _sharedImages; - void setText(const char *text); - char *_text; - CBFont *_font; - bool _visible; - CUITiledImage *_back; - bool _disable; - CUIObject(CBGame *inGame = NULL); - virtual ~CUIObject(); - int _width; - int _height; - TUIObjectType _type; - CBSprite *_image; - void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); - CBScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - CBScriptHolder *_listenerObject; - CUIObject *_focusedWidget; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp deleted file mode 100644 index 3ca8e135c1..0000000000 --- a/engines/wintermute/UI/UIText.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/UI/UIText.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIText, false) - -////////////////////////////////////////////////////////////////////////// -CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { - _textAlign = TAL_LEFT; - _verticalAlign = VAL_CENTER; - _type = UI_STATIC; - _canFocus = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIText::~CUIText() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - - CBFont *font = _font; - if (!font) font = _gameRef->_systemFont; - - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); - - if (font && _text) { - int textOffset; - switch (_verticalAlign) { - case VAL_TOP: - textOffset = 0; - break; - case VAL_BOTTOM: - textOffset = _height - font->getTextHeight((byte *)_text, _width); - break; - default: - textOffset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; - } - font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); - } - - //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(STATIC) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIText::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { - _gameRef->LOG(0, "'STATIC' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; - else _textAlign = TAL_CENTER; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; - else _verticalAlign = VAL_CENTER; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in STATIC definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading STATIC definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "STATIC\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_textAlign) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CUIText::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SizeToFit - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SizeToFit") == 0) { - stack->correctParams(0); - sizeToFit(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HeightToFit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HeightToFit") == 0) { - stack->correctParams(0); - if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); - stack->pushNULL(); - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("static"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { - _scValue->setInt(_textAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VerticalAlign") == 0) { - _scValue->setInt(_verticalAlign); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "TextAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _textAlign = (TTextAlign)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VerticalAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; - _verticalAlign = (TVerticalAlign)i; - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIText::scToString() { - return "[static]"; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_textAlign)); - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::sizeToFit() { - if (_font && _text) { - _width = _font->getTextWidth((byte *)_text); - _height = _font->getTextHeight((byte *)_text, _width); - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIText.h b/engines/wintermute/UI/UIText.h deleted file mode 100644 index 62fbf00b0a..0000000000 --- a/engines/wintermute/UI/UIText.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITEXT_H -#define WINTERMUTE_UITEXT_H - - -#include "UIObject.h" - -namespace WinterMute { - -class CUIText : public CUIObject { -private: - bool sizeToFit(); -public: - virtual bool display(int offsetX, int offsetY); - DECLARE_PERSISTENT(CUIText, CUIObject) - CUIText(CBGame *inGame = NULL); - virtual ~CUIText(); - TTextAlign _textAlign; - TVerticalAlign _verticalAlign; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp deleted file mode 100644 index 31500f7863..0000000000 --- a/engines/wintermute/UI/UITiledImage.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/Base/gfx/base_surface.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUITiledImage, false) - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { - _image = NULL; - - CBPlatform::setRectEmpty(&_upLeft); - CBPlatform::setRectEmpty(&_upMiddle); - CBPlatform::setRectEmpty(&_upRight); - CBPlatform::setRectEmpty(&_middleLeft); - CBPlatform::setRectEmpty(&_middleMiddle); - CBPlatform::setRectEmpty(&_middleRight); - CBPlatform::setRectEmpty(&_downLeft); - CBPlatform::setRectEmpty(&_downMiddle); - CBPlatform::setRectEmpty(&_downRight); -} - - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::~CUITiledImage() { - delete _image; - _image = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::display(int x, int y, int width, int height) { - if (!_image) return STATUS_FAILED; - - int tileWidth = _middleMiddle.right - _middleMiddle.left; - int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - - int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; - int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - - int col, row; - - _gameRef->_renderer->startSpriteBatch(); - - // top left/right - _image->_surface->displayTrans(x, y, _upLeft); - _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y, _upRight); - - // bottom left/right - _image->_surface->displayTrans(x, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downLeft); - _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); - - // left/right - int yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { - _image->_surface->displayTrans(x, yyy, _middleLeft); - _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); - yyy += tileWidth; - } - - // top/bottom - int xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, y, _upMiddle); - _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); - xxx += tileWidth; - } - - // tiles - yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { - xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, yyy, _middleMiddle); - xxx += tileWidth; - } - yyy += tileWidth; - } - - _gameRef->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TILED_IMAGE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(UP_MIDDLE) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(DOWN_MIDDLE) -TOKEN_DEF(MIDDLE_LEFT) -TOKEN_DEF(MIDDLE_RIGHT) -TOKEN_DEF(MIDDLE_MIDDLE) -TOKEN_DEF(VERTICAL_TILES) -TOKEN_DEF(HORIZONTAL_TILES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TILED_IMAGE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(UP_MIDDLE) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(DOWN_MIDDLE) - TOKEN_TABLE(MIDDLE_LEFT) - TOKEN_TABLE(MIDDLE_RIGHT) - TOKEN_TABLE(MIDDLE_MIDDLE) - TOKEN_TABLE(VERTICAL_TILES) - TOKEN_TABLE(HORIZONTAL_TILES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - bool hTiles = false, vTiles = false; - int h1 = 0, h2 = 0, h3 = 0; - int v1 = 0, v2 = 0, v3 = 0; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { - _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSubFrame(_gameRef); - if (!_image || DID_FAIL(_image->setSurface((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_UP_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); - break; - - case TOKEN_UP_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); - break; - - case TOKEN_UP_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); - break; - - case TOKEN_DOWN_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); - break; - - case TOKEN_DOWN_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); - break; - - case TOKEN_DOWN_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); - break; - - case TOKEN_MIDDLE_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); - break; - - case TOKEN_MIDDLE_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); - break; - - case TOKEN_MIDDLE_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); - break; - - case TOKEN_HORIZONTAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); - hTiles = true; - break; - - case TOKEN_VERTICAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); - vTiles = true; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading TILED_IMAGE definition"); - return STATUS_FAILED; - } - - if (vTiles && hTiles) { - // up row - CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); - CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); - CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); - - // middle row - CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); - CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); - CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); - - // down row - CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); - CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); - CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); - } - - // default - if (_image && _image->_surface) { - int width = _image->_surface->getWidth() / 3; - int height = _image->_surface->getHeight() / 3; - - if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); - if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); - if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); - - if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); - - if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); - if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); - if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "TILED_IMAGE\n"); - buffer->putTextIndent(indent, "{\n"); - - if (_image && _image->_surfaceFilename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); - - int h1, h2, h3; - int v1, v2, v3; - - h1 = _upLeft.right; - h2 = _upMiddle.right - _upMiddle.left; - h3 = _upRight.right - _upRight.left; - - v1 = _upLeft.bottom; - v2 = _middleLeft.bottom - _middleLeft.top; - v3 = _downLeft.bottom - _downLeft.top; - - - buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", v1, v2, v3); - buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUITiledImage::correctSize(int *width, int *height) { - int tileWidth = _middleMiddle.right - _middleMiddle.left; - int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - - int nuColumns = (*width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; - int nuRows = (*height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - - *width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nuColumns * tileWidth; - *height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nuRows * tileHeight; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_downLeft)); - persistMgr->transfer(TMEMBER(_downMiddle)); - persistMgr->transfer(TMEMBER(_downRight)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_middleLeft)); - persistMgr->transfer(TMEMBER(_middleMiddle)); - persistMgr->transfer(TMEMBER(_middleRight)); - persistMgr->transfer(TMEMBER(_upLeft)); - persistMgr->transfer(TMEMBER(_upMiddle)); - persistMgr->transfer(TMEMBER(_upRight)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UITiledImage.h b/engines/wintermute/UI/UITiledImage.h deleted file mode 100644 index 379af85e81..0000000000 --- a/engines/wintermute/UI/UITiledImage.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITILEDIMAGE_H -#define WINTERMUTE_UITILEDIMAGE_H - - -#include "UIObject.h" -#include "common/rect.h" - -namespace WinterMute { -class CBSubFrame; -class CUITiledImage : public CBObject { -public: - DECLARE_PERSISTENT(CUITiledImage, CBObject) - void correctSize(int *width, int *height); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - bool display(int x, int y, int width, int height); - CUITiledImage(CBGame *inGame = NULL); - virtual ~CUITiledImage(); - CBSubFrame *_image; - Rect32 _upLeft; - Rect32 _upMiddle; - Rect32 _upRight; - Rect32 _middleLeft; - Rect32 _middleMiddle; - Rect32 _middleRight; - Rect32 _downLeft; - Rect32 _downMiddle; - Rect32 _downRight; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp deleted file mode 100644 index 1541ca3a1d..0000000000 --- a/engines/wintermute/UI/UIWindow.cpp +++ /dev/null @@ -1,1327 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/UI/UIWindow.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BParser.h" -#include "engines/wintermute/Base/BActiveRect.h" -#include "engines/wintermute/Base/BDynBuffer.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/UI/UIButton.h" -#include "engines/wintermute/UI/UIEdit.h" -#include "engines/wintermute/UI/UIText.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFont.h" -#include "engines/wintermute/Base/BStringTable.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIWindow, false) - -////////////////////////////////////////////////////////////////////////// -CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::setRectEmpty(&_titleRect); - CBPlatform::setRectEmpty(&_dragRect); - _titleAlign = TAL_LEFT; - _transparent = false; - - _backInactive = NULL; - _fontInactive = NULL; - _imageInactive = NULL; - - _type = UI_WINDOW; - _canFocus = true; - - _dragging = false; - _dragFrom.x = _dragFrom.y = 0; - - _mode = WINDOW_NORMAL; - _shieldWindow = NULL; - _shieldButton = NULL; - - _fadeColor = 0x00000000; - _fadeBackground = false; - - _ready = true; - _isMenu = false; - _inGame = false; - - _clipContents = false; - _viewport = NULL; - - _pauseMusic = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIWindow::~CUIWindow() { - close(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::cleanup() { - delete _shieldWindow; - delete _shieldButton; - delete _viewport; - _shieldWindow = NULL; - _shieldButton = NULL; - _viewport = NULL; - - delete _backInactive; - if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - if (!_sharedImages && _imageInactive) delete _imageInactive; - - for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; - _widgets.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::display(int offsetX, int offsetY) { - // go exclusive - if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - - _shieldWindow->display(); - } - } else if (_isMenu) { - if (!_shieldButton) { - _shieldButton = new CUIButton(_gameRef); - _shieldButton->setName("close"); - _shieldButton->setListener(this, _shieldButton, 0); - _shieldButton->_parent = this; - } - if (_shieldButton) { - _shieldButton->_posX = _shieldButton->_posY = 0; - _shieldButton->_width = _gameRef->_renderer->_width; - _shieldButton->_height = _gameRef->_renderer->_height; - - _shieldButton->display(); - } - } - - if (!_visible) - return STATUS_OK; - - if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); - - if (_dragging) { - _posX += (_gameRef->_mousePos.x - _dragFrom.x); - _posY += (_gameRef->_mousePos.y - _dragFrom.y); - - _dragFrom.x = _gameRef->_mousePos.x; - _dragFrom.y = _gameRef->_mousePos.y; - } - - if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { - moveFocus(); - } - - bool popViewport = false; - if (_clipContents) { - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) { - _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); - _gameRef->pushViewport(_viewport); - popViewport = true; - } - } - - - CUITiledImage *back = _back; - CBSprite *image = _image; - CBFont *font = _font; - - if (!isFocused()) { - if (_backInactive) back = _backInactive; - if (_imageInactive) image = _imageInactive; - if (_fontInactive) font = _fontInactive; - } - - if (_alphaColor != 0) - _gameRef->_renderer->_forceAlphaColor = _alphaColor; - if (back) - back->display(_posX + offsetX, _posY + offsetY, _width, _height); - if (image) - image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); - - if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { - font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); - } - - if (!_transparent && !image) - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); - - for (int i = 0; i < _widgets.getSize(); i++) { - _widgets[i]->display(_posX + offsetX, _posY + offsetY); - } - - if (_alphaColor != 0) - _gameRef->_renderer->_forceAlphaColor = 0; - - if (popViewport) - _gameRef->popViewport(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WINDOW) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK_INACTIVE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE_INACTIVE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_INACTIVE) -TOKEN_DEF(FONT) -TOKEN_DEF(TITLE_ALIGN) -TOKEN_DEF(TITLE_RECT) -TOKEN_DEF(TITLE) -TOKEN_DEF(DRAG_RECT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(FADE_ALPHA) -TOKEN_DEF(FADE_COLOR) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(BUTTON) -TOKEN_DEF(STATIC) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MENU) -TOKEN_DEF(IN_GAME) -TOKEN_DEF(CLIP_CONTENTS) -TOKEN_DEF(PAUSE_MUSIC) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK_INACTIVE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE_INACTIVE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_INACTIVE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TITLE_ALIGN) - TOKEN_TABLE(TITLE_RECT) - TOKEN_TABLE(TITLE) - TOKEN_TABLE(DRAG_RECT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(FADE_ALPHA) - TOKEN_TABLE(FADE_COLOR) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MENU) - TOKEN_TABLE(IN_GAME) - TOKEN_TABLE(CLIP_CONTENTS) - TOKEN_TABLE(PAUSE_MUSIC) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; - int ar = 0, ag = 0, ab = 0, alpha = 0; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { - _gameRef->LOG(0, "'WINDOW' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_INACTIVE: - delete _backInactive; - _backInactive = new CUITiledImage(_gameRef); - if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { - delete _backInactive; - _backInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_INACTIVE: - delete _imageInactive, - _imageInactive = new CBSprite(_gameRef); - if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { - delete _imageInactive; - _imageInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_INACTIVE: - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - _fontInactive = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontInactive) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TITLE: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; - else _titleAlign = TAL_CENTER; - break; - - case TOKEN_TITLE_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); - break; - - case TOKEN_DRAG_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BUTTON: { - CUIButton *btn = new CUIButton(_gameRef); - if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { - delete btn; - btn = NULL; - cmd = PARSERR_GENERIC; - } else { - btn->_parent = this; - _widgets.add(btn); - } - } - break; - - case TOKEN_STATIC: { - CUIText *text = new CUIText(_gameRef); - if (!text || DID_FAIL(text->loadBuffer(params, false))) { - delete text; - text = NULL; - cmd = PARSERR_GENERIC; - } else { - text->_parent = this; - _widgets.add(text); - } - } - break; - - case TOKEN_EDIT: { - CUIEdit *edit = new CUIEdit(_gameRef); - if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { - delete edit; - edit = NULL; - cmd = PARSERR_GENERIC; - } else { - edit->_parent = this; - _widgets.add(edit); - } - } - break; - - case TOKEN_WINDOW: { - CUIWindow *win = new CUIWindow(_gameRef); - if (!win || DID_FAIL(win->loadBuffer(params, false))) { - delete win; - win = NULL; - cmd = PARSERR_GENERIC; - } else { - win->_parent = this; - _widgets.add(win); - } - } - break; - - - case TOKEN_TRANSPARENT: - parser.scanStr((char *)params, "%b", &_transparent); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_PAUSE_MUSIC: - parser.scanStr((char *)params, "%b", &_pauseMusic); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_MENU: - parser.scanStr((char *)params, "%b", &_isMenu); - break; - - case TOKEN_IN_GAME: - parser.scanStr((char *)params, "%b", &_inGame); - break; - - case TOKEN_CLIP_CONTENTS: - parser.scanStr((char *)params, "%b", &_clipContents); - break; - - case TOKEN_FADE_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); - _fadeBackground = true; - break; - - case TOKEN_FADE_ALPHA: - parser.scanStr((char *)params, "%d", &fadeA); - _fadeBackground = true; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - - default: - if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { - cmd = PARSERR_GENERIC; - } - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in WINDOW definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading WINDOW definition"); - return STATUS_FAILED; - } - - correctSize(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - - if (_fadeBackground) - _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); - - _focusedWidget = NULL; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WINDOW\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backInactive && _backInactive->_filename) - buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageInactive && _imageInactive->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontInactive && _fontInactive->_filename) - buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); - - switch (_titleAlign) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); - } - - if (!CBPlatform::isRectEmpty(&_titleRect)) { - buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); - } - - if (!CBPlatform::isRectEmpty(&_dragRect)) { - buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_fadeBackground) { - buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); - buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", RGBCOLGetA(_fadeColor)); - } - - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); - buffer->putTextIndent(indent + 2, "ALPHA=%d\n", RGBCOLGetA(_alphaColor)); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - // controls - for (int i = 0; i < _widgets.getSize(); i++) - _widgets[i]->saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::enableWidget(const char *name, bool Enable) { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::showWidget(const char *name, bool Visible) { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetWidget / GetControl - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->getType() == VAL_INT) { - int widget = val->getInt(); - if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); - else stack->pushNative(_widgets[widget], true); - } else { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { - stack->pushNative(_widgets[i], true); - return STATUS_OK; - } - } - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInactiveFont") == 0) { - stack->correctParams(1); - - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontInactive != NULL); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInactiveImage") == 0) { - stack->correctParams(1); - - delete _imageInactive; - _imageInactive = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { - delete _imageInactive; - _imageInactive = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInactiveImage") == 0) { - stack->correctParams(0); - if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); - else stack->pushString(_imageInactive->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInactiveImageObject") == 0) { - stack->correctParams(0); - if (!_imageInactive) stack->pushNULL(); - else stack->pushNative(_imageInactive, true); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(close())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoExclusive") == 0) { - stack->correctParams(0); - goExclusive(); - script->waitFor(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoSystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoSystemExclusive") == 0) { - stack->correctParams(0); - goSystemExclusive(); - script->waitFor(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Center - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Center") == 0) { - stack->correctParams(0); - _posX = (_gameRef->_renderer->_width - _width) / 2; - _posY = (_gameRef->_renderer->_height - _height) / 2; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadFromFile - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadFromFile") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - cleanup(); - if (!val->isNULL()) { - stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateButton") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIButton *btn = new CUIButton(_gameRef); - if (!val->isNULL()) btn->setName(val->getString()); - stack->pushNative(btn, true); - - btn->_parent = this; - _widgets.add(btn); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateStatic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateStatic") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIText *sta = new CUIText(_gameRef); - if (!val->isNULL()) sta->setName(val->getString()); - stack->pushNative(sta, true); - - sta->_parent = this; - _widgets.add(sta); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEditor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEditor") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIEdit *edi = new CUIEdit(_gameRef); - if (!val->isNULL()) edi->setName(val->getString()); - stack->pushNative(edi, true); - - edi->_parent = this; - _widgets.add(edi); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIWindow *win = new CUIWindow(_gameRef); - if (!val->isNULL()) win->setName(val->getString()); - stack->pushNative(win, true); - - win->_parent = this; - _widgets.add(win); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CUIObject *obj = (CUIObject *)val->getNative(); - - for (int i = 0; i < _widgets.getSize(); i++) { - if (_widgets[i] == obj) { - delete _widgets[i]; - _widgets.removeAt(i); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - } - } - stack->pushNULL(); - return STATUS_OK; - } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("window"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWidgets / NumControls (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { - _scValue->setInt(_widgets.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exclusive") == 0) { - _scValue->setBool(_mode == WINDOW_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SystemExclusive") == 0) { - _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Menu") == 0) { - _scValue->setBool(_isMenu); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InGame") == 0) { - _scValue->setBool(_inGame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0) { - _scValue->setBool(_pauseMusic); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClipContents") == 0) { - _scValue->setBool(_clipContents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Transparent") == 0) { - _scValue->setBool(_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeColor") == 0) { - _scValue->setInt((int)_fadeColor); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Menu") == 0) { - _isMenu = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InGame") == 0) { - _inGame = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0) { - _pauseMusic = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClipContents") == 0) { - _clipContents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Transparent") == 0) { - _transparent = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeColor") == 0) { - _fadeColor = (uint32)value->getInt(); - _fadeBackground = (_fadeColor != 0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exclusive") == 0) { - if (value->getBool()) - goExclusive(); - else { - close(); - _visible = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SystemExclusive") == 0) { - if (value->getBool()) - goSystemExclusive(); - else { - close(); - _visible = true; - } - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIWindow::scToString() { - return "[window]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { -//TODO - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); - } else { - if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); - else return false; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouseWheel(int Delta) { - if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - bool res = CUIObject::handleMouse(event, button); - - // handle window dragging - if (!CBPlatform::isRectEmpty(&_dragRect)) { - // start drag - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - Rect32 dragRect = _dragRect; - int offsetX, offsetY; - getTotalOffset(&offsetX, &offsetY); - CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - - if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { - _dragFrom.x = _gameRef->_mousePos.x; - _dragFrom.y = _gameRef->_mousePos.y; - _dragging = true; - } - } - // end drag - else if (_dragging && event == MOUSE_RELEASE && button == MOUSE_BUTTON_LEFT) { - _dragging = false; - } - } - - return res; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_backInactive)); - persistMgr->transfer(TMEMBER(_clipContents)); - persistMgr->transfer(TMEMBER(_dragFrom)); - persistMgr->transfer(TMEMBER(_dragging)); - persistMgr->transfer(TMEMBER(_dragRect)); - persistMgr->transfer(TMEMBER(_fadeBackground)); - persistMgr->transfer(TMEMBER(_fadeColor)); - persistMgr->transfer(TMEMBER(_fontInactive)); - persistMgr->transfer(TMEMBER(_imageInactive)); - persistMgr->transfer(TMEMBER(_inGame)); - persistMgr->transfer(TMEMBER(_isMenu)); - persistMgr->transfer(TMEMBER_INT(_mode)); - persistMgr->transfer(TMEMBER(_shieldButton)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER_INT(_titleAlign)); - persistMgr->transfer(TMEMBER(_titleRect)); - persistMgr->transfer(TMEMBER(_transparent)); - persistMgr->transfer(TMEMBER(_viewport)); - persistMgr->transfer(TMEMBER(_pauseMusic)); - - _widgets.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::moveFocus(bool forward) { - int i; - bool found = false; - for (i = 0; i < _widgets.getSize(); i++) { - if (_widgets[i] == _focusedWidget) { - found = true; - break; - } - } - if (!found) _focusedWidget = NULL; - - if (!_focusedWidget) { - if (_widgets.getSize() > 0) i = 0; - else return STATUS_OK; - } - - int numTries = 0; - bool done = false; - - while (numTries <= _widgets.getSize()) { - if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { - _focusedWidget = _widgets[i]; - done = true; - break; - } - - if (forward) { - i++; - if (i >= _widgets.getSize()) i = 0; - } else { - i--; - if (i < 0) i = _widgets.getSize() - 1; - } - numTries++; - } - - return done ? STATUS_OK : STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goExclusive() { - if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; - - if (_mode == WINDOW_NORMAL) { - _ready = false; - _mode = WINDOW_EXCLUSIVE; - _visible = true; - _disable = false; - _gameRef->focusWindow(this); - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goSystemExclusive() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; - - makeFreezable(false); - - _mode = WINDOW_SYSTEM_EXCLUSIVE; - _ready = false; - _visible = true; - _disable = false; - _gameRef->focusWindow(this); - - _gameRef->freeze(_pauseMusic); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::close() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - _gameRef->unfreeze(); - } - - _mode = WINDOW_NORMAL; - _visible = false; - _ready = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) close(); - else return CBObject::listen(param1, param2); - break; - default: - return CBObject::listen(param1, param2); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::makeFreezable(bool freezable) { - for (int i = 0; i < _widgets.getSize(); i++) - _widgets[i]->makeFreezable(freezable); - - CBObject::makeFreezable(freezable); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _widgets.getSize(); i++) { - CUIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) continue; - - switch (control->_type) { - case UI_WINDOW: - ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); - break; - - case UI_BUTTON: - case UI_EDIT: - objects.add(control); - break; - - default: - if (!interactiveOnly) objects.add(control); - } - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h deleted file mode 100644 index f1d46711ff..0000000000 --- a/engines/wintermute/UI/UIWindow.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIWINDOW_H -#define WINTERMUTE_UIWINDOW_H - - -#include "UIObject.h" -#include "common/events.h" - -namespace WinterMute { - -class CUIButton; -class CBViewport; -class CUIWindow : public CUIObject { -public: - bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); - - bool _pauseMusic; - void cleanup(); - virtual void makeFreezable(bool freezable); - CBViewport *_viewport; - bool _clipContents; - bool _inGame; - bool _isMenu; - bool _fadeBackground; - uint32 _fadeColor; - virtual bool handleMouseWheel(int delta); - CUIWindow *_shieldWindow; - CUIButton *_shieldButton; - bool close(); - bool goSystemExclusive(); - bool goExclusive(); - TWindowMode _mode; - bool moveFocus(bool forward = true); - virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); - Point32 _dragFrom; - bool _dragging; - DECLARE_PERSISTENT(CUIWindow, CUIObject) - bool _transparent; - bool showWidget(const char *name, bool visible = true); - bool enableWidget(const char *name, bool enable = true); - Rect32 _titleRect; - Rect32 _dragRect; - virtual bool display(int offsetX = 0, int offsetY = 0); - CUIWindow(CBGame *inGame); - virtual ~CUIWindow(); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - CBArray _widgets; - TTextAlign _titleAlign; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - CUITiledImage *_backInactive; - CBFont *_fontInactive; - CBSprite *_imageInactive; - virtual bool listen(CBScriptHolder *param1, uint32 param2); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdActor.cpp b/engines/wintermute/ad/AdActor.cpp new file mode 100644 index 0000000000..480851d21f --- /dev/null +++ b/engines/wintermute/ad/AdActor.cpp @@ -0,0 +1,1316 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/ad/AdActor.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/ad/AdSpriteSet.h" +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/ad/AdPath.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActor, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { + _path = new CAdPath(_gameRef); + + _type = OBJECT_ACTOR; + _dir = DI_LEFT; + + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _targetPoint = new CBPoint; + _afterWalkDir = DI_NONE; + + _animSprite2 = NULL; + + setDefaultAnimNames(); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::setDefaultAnimNames() { + _talkAnimName = "talk"; + _idleAnimName = "idle"; + _walkAnimName = "walk"; + _turnLeftAnimName = "turnleft"; + _turnRightAnimName = "turnright"; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdActor::~CAdActor() { + delete _path; + delete _targetPoint; + _path = NULL; + _targetPoint = NULL; + + delete _walkSprite; + delete _standSprite; + delete _turnLeftSprite; + delete _turnRightSprite; + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _animSprite2 = NULL; // ref only + + for (int i = 0; i < _talkSprites.getSize(); i++) { + delete _talkSprites[i]; + } + _talkSprites.removeAll(); + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + delete _talkSpritesEx[i]; + } + _talkSpritesEx.removeAll(); + + for (int i = 0; i < _anims.getSize(); i++) { + delete _anims[i]; + _anims[i] = NULL; + } + _anims.removeAll(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ACTOR) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(WALK) +TOKEN_DEF(STAND) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(TURN_LEFT) +TOKEN_DEF(TURN_RIGHT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ANIMATION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdActor::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTOR) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(WALK) + TOKEN_TABLE(STAND) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TURN_LEFT) + TOKEN_TABLE(TURN_RIGHT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + _gameRef->LOG(0, "'ACTOR' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CAdGame *adGame = (CAdGame *)_gameRef; + CAdSpriteSet *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.scanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.scanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.scanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.scanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_WALK: + delete _walkSprite; + _walkSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + else _walkSprite = spr; + break; + + case TOKEN_TALK: + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + break; + + case TOKEN_TALK_SPECIAL: + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + break; + + case TOKEN_STAND: + delete _standSprite; + _standSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + else _standSprite = spr; + break; + + case TOKEN_TURN_LEFT: + delete _turnLeftSprite; + _turnLeftSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnLeftSprite = spr; + break; + + case TOKEN_TURN_RIGHT: + delete _turnRightSprite; + _turnRightSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnRightSprite = spr; + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SOUND_VOLUME: + parser.scanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_SOUND_PANNING: + parser.scanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->mimic(_wptGroup); + } + } + break; + + case TOKEN_IGNORE_ITEMS: + parser.scanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + else _anims.add(Anim); + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ACTOR definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + if (spr) delete spr; + _gameRef->LOG(0, "Error loading ACTOR definition"); + return STATUS_FAILED; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + _state = _nextState = STATE_READY; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::turnTo(TDirection dir) { + int delta1, delta2, delta3, delta; + + delta1 = dir - _dir; + delta2 = dir + NUM_DIRECTIONS - _dir; + delta3 = dir - NUM_DIRECTIONS - _dir; + + delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; + delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; + + // already there? + if (abs(delta) < 2) { + _dir = dir; + _state = _nextState; + _nextState = STATE_READY; + return; + } + + _targetDir = dir; + _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; + + _tempSprite2 = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { + _afterWalkDir = afterWalkDir; + if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; + + _path->reset(); + _path->setReady(false); + + _targetPoint->x = x; + _targetPoint->y = y; + + ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + + _state = STATE_SEARCHING_PATH; + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::display() { + if (_active) updateSounds(); + + uint32 alpha; + if (_alphaColor != 0) alpha = _alphaColor; + else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + + float rotate; + if (_rotatable) { + if (_rotateValid) rotate = _rotate; + else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } else rotate = 0.0f; + + if (_active) displaySpriteAttachments(true); + + if (_currentSprite && _active) { + bool reg = _registrable; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; + + _currentSprite->display(_posX, + _posY, + reg ? _registerAlias : NULL, + scaleX, + scaleY, + alpha, + rotate, + _blendMode); + + } + + if (_active) displaySpriteAttachments(false); + if (_active && _partEmitter) _partEmitter->display(); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::update() { + _currentSprite = NULL; + + if (_state == STATE_READY) { + if (_animSprite) { + delete _animSprite; + _animSprite = NULL; + } + if (_animSprite2) { + _animSprite2 = NULL; + } + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite; + } + + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite2; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + } + + bool already_moved = false; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM_SET: + _currentSprite = _animSprite2; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_LEFT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_dir > 0) _dir = (TDirection)(_dir - 1); + else _dir = (TDirection)(NUM_DIRECTIONS - 1); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnLeftSprite) { + _tempSprite2 = _turnLeftSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_RIGHT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + _dir = (TDirection)(_dir + 1); + + if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnRightSprite) { + _tempSprite2 = _turnRightSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_SEARCHING_PATH: + // keep asking scene for the path + if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + _state = STATE_WAITING_PATH; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_WAITING_PATH: + // wait until the scene finished the path + if (_path->_ready) followPath(); + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_FOLLOWING_PATH: + getNextStep(); + already_moved = true; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(_dir); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite && !_animSprite2) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + } + break; + default: + error("AdActor::Update - Unhandled enum"); + } + + + if (_currentSprite && !already_moved) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + afterMove(); + } + } + + //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); + + updateBlockRegion(); + _ready = (_state == STATE_READY); + + updatePartEmitter(); + updateSpriteAttachments(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::followPath() { + // skip current position + _path->getFirst(); + while (_path->getCurrent() != NULL) { + if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; + _path->getNext(); + } + + // are there points to follow? + if (_path->getCurrent() != NULL) { + _state = STATE_FOLLOWING_PATH;; + initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + } else { + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); + else _state = STATE_READY; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::getNextStep() { + if (_walkSprite) { + _currentSprite = _walkSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_walkAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + + if (!_currentSprite) return; + + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (!_currentSprite->_changed) return; + + + int maxStepX, maxStepY; + maxStepX = abs(_currentSprite->_moveX); + maxStepY = abs(_currentSprite->_moveY); + + maxStepX = MAX(maxStepX, maxStepY); + maxStepX = MAX(maxStepX, 1); + + while (_pFCount > 0 && maxStepX >= 0) { + _pFX += _pFStepX; + _pFY += _pFStepY; + + _pFCount--; + maxStepX--; + } + + if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { + if (_pFCount == 0) { + _state = _nextState; + _nextState = STATE_READY; + return; + } + goTo(_targetPoint->x, _targetPoint->y); + return; + } + + + _posX = (int)_pFX; + _posY = (int)_pFY; + + afterMove(); + + + if (_pFCount == 0) { + if (_path->getNext() == NULL) { + _posX = _targetPoint->x; + _posY = _targetPoint->y; + + _path->reset(); + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); + else { + _state = _nextState; + _nextState = STATE_READY; + } + } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { + _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); + + _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; + _pFStepY = (double)(endPt.y - startPt.y) / _pFCount; + + _pFX = startPt.x; + _pFY = startPt.y; + + int angle = (int)(atan2((double)(endPt.y - startPt.y), (double)(endPt.x - startPt.x)) * (180 / 3.14)); + + _nextState = STATE_FOLLOWING_PATH; + + turnTo(angleToDirection(angle)); +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GoTo / GoToAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { + stack->correctParams(2); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + goTo(X, Y); + if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoToObject / GoToObjectAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (!Val->isNative()) { + script->runtimeError("actor.%s method accepts an entity refrence only", name); + stack->pushNULL(); + return STATUS_OK; + } + CAdObject *Obj = (CAdObject *)Val->getNative(); + if (!Obj || Obj->_type != OBJECT_ENTITY) { + script->runtimeError("actor.%s method accepts an entity refrence only", name); + stack->pushNULL(); + return STATUS_OK; + } + CAdEntity *Ent = (CAdEntity *)Obj; + if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); + else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); + if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnTo / TurnToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { + stack->correctParams(1); + int dir; + CScValue *val = stack->pop(); + + // turn to object? + if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { + CBObject *obj = (CBObject *)val->getNative(); + int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); + dir = (int)angleToDirection(angle); + } + // otherwise turn to direction + else dir = val->getInt(); + + if (dir >= 0 && dir < NUM_DIRECTIONS) { + turnTo((TDirection)dir); + if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsWalking") == 0) { + stack->correctParams(0); + stack->pushBool(_state == STATE_FOLLOWING_PATH); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MergeAnims + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MergeAnims") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(mergeAnims(stack->pop()->getString()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadAnim") == 0) { + stack->correctParams(1); + const char *AnimName = stack->pop()->getString(); + + bool Found = false; + for (int i = 0; i < _anims.getSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { + // invalidate sprites in use + if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; + if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; + if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; + + delete _anims[i]; + _anims[i] = NULL; + _anims.removeAt(i); + i--; + Found = true; + } + } + stack->pushBool(Found); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasAnim") == 0) { + stack->correctParams(1); + const char *AnimName = stack->pop()->getString(); + stack->pushBool(getAnimByName(AnimName) != NULL); + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdActor::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Direction") == 0) { + _scValue->setInt(_dir); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Type") == 0) { + _scValue->setString("actor"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkAnimName") == 0) { + _scValue->setString(_talkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkAnimName") == 0) { + _scValue->setString(_walkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IdleAnimName") == 0) { + _scValue->setString(_idleAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnLeftAnimName") == 0) { + _scValue->setString(_turnLeftAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnRightAnimName") == 0) { + _scValue->setString(_turnRightAnimName); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Direction") == 0) { + int dir = value->getInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkAnimName") == 0) { + if (value->isNULL()) _talkAnimName = "talk"; + else _talkAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkAnimName") == 0) { + if (value->isNULL()) _walkAnimName = "walk"; + else _walkAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IdleAnimName") == 0) { + if (value->isNULL()) _idleAnimName = "idle"; + else _idleAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnLeftAnimName") == 0) { + if (value->isNULL()) _turnLeftAnimName = "turnleft"; + else _turnLeftAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnRightAnimName") == 0) { + if (value->isNULL()) _turnRightAnimName = "turnright"; + else _turnRightAnimName = value->getString(); + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdActor::scToString() { + return "[actor object]"; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::getTalkStance(const char *stance) { + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + // old way + if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) + return getTalkStanceOld(stance); + + // new way + CBSprite *ret = NULL; + + // do we have an animation with this name? + CAdSpriteSet *Anim = getAnimByName(stance); + if (Anim) ret = Anim->getSprite(_dir); + + // not - get a random talk + if (!ret) { + CBArray TalkAnims; + for (int i = 0; i < _anims.getSize(); i++) { + if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) + TalkAnims.add(_anims[i]); + } + + if (TalkAnims.getSize() > 0) { + int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); + ret = TalkAnims[rnd]->getSprite(_dir); + } else { + if (_standSprite) ret = _standSprite->getSprite(_dir); + else { + Anim = getAnimByName(_idleAnimName); + if (Anim) ret = Anim->getSprite(_dir); + } + } + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::getTalkStanceOld(const char *stance) { + CBSprite *ret = NULL; + + if (stance != NULL) { + // search special stances + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + ret = _talkSpritesEx[i]->getSprite(_dir); + break; + } + } + if (ret == NULL) { + // search generic stances + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + ret = _talkSprites[i]->getSprite(_dir); + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); + else { + // TODO: remember last + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + ret = _talkSprites[rnd]->getSprite(_dir); + } + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_dir)); + persistMgr->transfer(TMEMBER(_path)); + persistMgr->transfer(TMEMBER(_pFCount)); + persistMgr->transfer(TMEMBER(_pFStepX)); + persistMgr->transfer(TMEMBER(_pFStepY)); + persistMgr->transfer(TMEMBER(_pFX)); + persistMgr->transfer(TMEMBER(_pFY)); + persistMgr->transfer(TMEMBER(_standSprite)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_targetDir)); + persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); + persistMgr->transfer(TMEMBER(_targetPoint)); + persistMgr->transfer(TMEMBER(_turnLeftSprite)); + persistMgr->transfer(TMEMBER(_turnRightSprite)); + persistMgr->transfer(TMEMBER(_walkSprite)); + + persistMgr->transfer(TMEMBER(_animSprite2)); + persistMgr->transfer(TMEMBER(_talkAnimName)); + persistMgr->transfer(TMEMBER(_idleAnimName)); + persistMgr->transfer(TMEMBER(_walkAnimName)); + persistMgr->transfer(TMEMBER(_turnLeftAnimName)); + persistMgr->transfer(TMEMBER(_turnRightAnimName)); + + _anims.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TDirection CAdActor::angleToDirection(int angle) { + TDirection ret = DI_DOWN;; + + if (angle > -112 && angle <= -67) ret = DI_UP; + else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; + else if (angle > -22 && angle <= 22) ret = DI_RIGHT; + else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; + else if (angle > 67 && angle <= 112) ret = DI_DOWN; + else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; + else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; + else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdActor::getHeight() { + // if no current sprite is set, set some + if (_currentSprite == NULL) { + if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); + else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + // and get height + return CAdTalkHolder::getHeight(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { + for (int i = 0; i < _anims.getSize(); i++) { + if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) + return _anims[i]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::mergeAnims(const char *animsFilename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + + byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); + if (fileBuffer == NULL) { + _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); + return STATUS_FAILED; + } + + byte *buffer = fileBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + bool Ret = STATUS_OK; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + Ret = STATUS_FAILED; + } else _anims.add(Anim); + } + break; + } + } + delete [] fileBuffer; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::playAnim(const char *filename) { + // if we have an anim with this name, use it + CAdSpriteSet *Anim = getAnimByName(filename); + if (Anim) { + _animSprite2 = Anim->getSprite(_dir); + if (_animSprite2) { + _animSprite2->reset(); + _state = STATE_PLAYING_ANIM_SET; + return STATUS_OK; + } + } + // otherwise call the standard handler + return CAdTalkHolder::playAnim(filename); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdActor.h b/engines/wintermute/ad/AdActor.h new file mode 100644 index 0000000000..1be8b8131d --- /dev/null +++ b/engines/wintermute/ad/AdActor.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADACTOR_H +#define WINTERMUTE_ADACTOR_H + + +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/ad/AdTypes.h" // Added by ClassView +#include "engines/wintermute/ad/AdTalkHolder.h" +#include "engines/wintermute/base/BPoint.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "common/str.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +namespace WinterMute { +class CAdSpriteSet; +class CAdPath; +class CAdActor : public CAdTalkHolder { +public: + TDirection angleToDirection(int angle); + DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) + virtual int getHeight(); + CBSprite *getTalkStance(const char *stance); + virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); + CBPoint *_targetPoint; + virtual bool update(); + virtual bool display(); + TDirection _targetDir; + TDirection _afterWalkDir; + virtual void turnTo(TDirection dir); + CAdPath *_path; + CAdSpriteSet *_walkSprite; + CAdSpriteSet *_standSprite; + CAdSpriteSet *_turnLeftSprite; + CAdSpriteSet *_turnRightSprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + TDirection _dir; + CAdActor(CBGame *inGame/*=NULL*/); + virtual ~CAdActor(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + + // new anim system + Common::String _talkAnimName; + Common::String _idleAnimName; + Common::String _walkAnimName; + Common::String _turnLeftAnimName; + Common::String _turnRightAnimName; + CBArray _anims; + virtual bool playAnim(const char *filename); + CAdSpriteSet *getAnimByName(const Common::String &animName); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + bool setDefaultAnimNames(); + CBSprite *getTalkStanceOld(const char *stance); + bool mergeAnims(const char *animsFilename); + CBSprite *_animSprite2; + + void initLine(CBPoint startPt, CBPoint endPt); + void getNextStep(); + void followPath(); + double _pFStepX; + double _pFStepY; + double _pFX; + double _pFY; + int _pFCount; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/ad/AdEntity.cpp b/engines/wintermute/ad/AdEntity.cpp new file mode 100644 index 0000000000..c559e99abb --- /dev/null +++ b/engines/wintermute/ad/AdEntity.cpp @@ -0,0 +1,1027 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdEntity, false) + +////////////////////////////////////////////////////////////////////////// +CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { + _type = OBJECT_ENTITY; + _subtype = ENTITY_NORMAL; + _region = NULL; + _item = NULL; + + _walkToX = _walkToY = 0; + _walkToDir = DI_NONE; + + _theora = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdEntity::~CAdEntity() { + _gameRef->unregisterObject(_region); + + delete _theora; + _theora = NULL; + + delete[] _item; + _item = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(CURSOR) +TOKEN_DEF(REGION) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_START_TIME) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(SOUND) +TOKEN_DEF(SUBTYPE) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ITEM) +TOKEN_DEF(WALK_TO_X) +TOKEN_DEF(WALK_TO_Y) +TOKEN_DEF(WALK_TO_DIR) +TOKEN_DEF(SAVE_STATE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(REGION) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_START_TIME) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(SUBTYPE) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(WALK_TO_X) + TOKEN_TABLE(WALK_TO_Y) + TOKEN_TABLE(WALK_TO_DIR) + TOKEN_TABLE(SAVE_STATE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + _gameRef->LOG(0, "'ENTITY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CAdGame *adGame = (CAdGame *)_gameRef; + CBSprite *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SPRITE: { + delete _sprite; + _sprite = NULL; + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + break; + + case TOKEN_TALK: { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + } + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_ITEM: + setItem((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.scanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.scanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.scanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.scanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_REGION: { + if (_region) _gameRef->unregisterObject(_region); + _region = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + else { + _region = rgn; + _gameRef->registerObject(_region); + } + } + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->mimic(_wptGroup); + } + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_SUBTYPE: { + if (scumm_stricmp((char *)params, "sound") == 0) { + delete _sprite; + _sprite = NULL; + if (_gameRef->_editorMode) { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + if (_gameRef->_editorMode) _editorOnly = true; + _zoomable = false; + _rotatable = false; + _registrable = _gameRef->_editorMode; + _shadowable = false; + _subtype = ENTITY_SOUND; + } + } + break; + + case TOKEN_SOUND: + playSFX((char *)params, false, false); + break; + + case TOKEN_SOUND_START_TIME: + parser.scanStr((char *)params, "%d", &_sFXStart); + break; + + case TOKEN_SOUND_VOLUME: + parser.scanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SOUND_PANNING: + parser.scanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_SAVE_STATE: + parser.scanStr((char *)params, "%b", &_saveState); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_IGNORE_ITEMS: + parser.scanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_WALK_TO_X: + parser.scanStr((char *)params, "%d", &_walkToX); + break; + + case TOKEN_WALK_TO_Y: + parser.scanStr((char *)params, "%d", &_walkToY); + break; + + case TOKEN_WALK_TO_DIR: { + int i; + parser.scanStr((char *)params, "%d", &i); + if (i < 0) i = 0; + if (i >= NUM_DIRECTIONS) i = DI_NONE; + _walkToDir = (TDirection)i; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ENTITY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ENTITY definition"); + if (spr) delete spr; + return STATUS_FAILED; + } + + if (_region && _sprite) { + _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); + } + + updatePosition(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + _state = STATE_READY; + + if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::display() { + if (_active) { + updateSounds(); + + uint32 Alpha; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + getScale(&ScaleX, &ScaleY); + + float Rotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } else Rotate = 0.0f; + + + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; + + if (_region && (Reg || _editorAlwaysRegister)) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); + } + + displaySpriteAttachments(true); + if (_theora && (_theora->isPlaying() || _theora->isPaused())) { + _theora->display(Alpha); + } else if (_currentSprite) { + _currentSprite->display(_posX, + _posY, + (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); + } + displaySpriteAttachments(false); + + if (_partEmitter) _partEmitter->display(_region); + + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) + _currentSprite = _sprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + default: // Silence unhandled enum-warning + break; + } + + + if (_currentSprite) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + } + } + + updateBlockRegion(); + _ready = (_state == STATE_READY); + + if (_theora) { + int OffsetX, OffsetY; + _gameRef->getOffset(&OffsetX, &OffsetY); + _theora->_posX = _posX - OffsetX; + _theora->_posY = _posY - OffsetY; + + _theora->update(); + if (_theora->isFinished()) { + _theora->stop(); + delete _theora; + _theora = NULL; + } + } + + updatePartEmitter(); + updateSpriteAttachments(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX(false))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + stack->correctParams(4); + const char *filename = stack->pop()->getString(); + bool looping = stack->pop()->getBool(false); + CScValue *valAlpha = stack->pop(); + int startTime = stack->pop()->getInt(); + + delete _theora; + _theora = new CVidTheoraPlayer(_gameRef); + if (_theora && DID_SUCCEED(_theora->initialize(filename))) { + if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); + _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); + //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; + stack->pushBool(true); + } else { + script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopTheora") == 0) { + stack->correctParams(0); + if (_theora) { + _theora->stop(); + delete _theora; + _theora = NULL; + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTheoraPlaying") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseTheora") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPlaying()) { + _theora->pause(); + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeTheora") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPaused()) { + _theora->resume(); + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPaused + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTheoraPaused") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPaused()) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // CreateRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateRegion") == 0) { + stack->correctParams(0); + if (!_region) { + _region = new CBRegion(_gameRef); + _gameRef->registerObject(_region); + } + if (_region) stack->pushNative(_region, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteRegion") == 0) { + stack->correctParams(0); + if (_region) { + _gameRef->unregisterObject(_region); + _region = NULL; + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdEntity::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("entity"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Item") == 0) { + if (_item) _scValue->setString(_item); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtype (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtype") == 0) { + if (_subtype == ENTITY_SOUND) + _scValue->setString("sound"); + else + _scValue->setString("normal"); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToX") == 0) { + _scValue->setInt(_walkToX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToY") == 0) { + _scValue->setInt(_walkToY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToDirection") == 0) { + _scValue->setInt((int)_walkToDir); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Region (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Region") == 0) { + if (_region) _scValue->setNative(_region, true); + else _scValue->setNULL(); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Item") == 0) { + setItem(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToX") == 0) { + _walkToX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToY") == 0) { + _walkToY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToDirection") == 0) { + int dir = value->getInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdEntity::scToString() { + return "[entity object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + if (_subtype == ENTITY_SOUND) + buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_ignoreItems) + buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + if (_rotatable) + buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + + if (!_autoSoundPanning) + buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + + if (!_saveState) + buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + + if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); + + buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); + buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); + if (_walkToDir != DI_NONE) + buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + + if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); + } + + + if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + + if (RGBCOLGetA(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); + + if (_scale >= 0) + buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); + + if (_relativeScale != 0) + buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + CAdTalkHolder::saveAsText(buffer, indent + 2); + + if (_region) _region->saveAsText(buffer, indent + 2); + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + CAdObject::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdEntity::getHeight() { + if (_region && !_sprite) { + return _region->_rect.bottom - _region->_rect.top; + } else { + if (_currentSprite == NULL) _currentSprite = _sprite; + return CAdObject::getHeight(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::updatePosition() { + if (_region && !_sprite) { + _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; + _posY = _region->_rect.bottom; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_item)); + persistMgr->transfer(TMEMBER(_region)); + //persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER_INT(_subtype)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_walkToX)); + persistMgr->transfer(TMEMBER(_walkToY)); + persistMgr->transfer(TMEMBER_INT(_walkToDir)); + + persistMgr->transfer(TMEMBER(_theora)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::setItem(const char *itemName) { + CBUtils::setString(&_item, itemName); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::setSprite(const char *filename) { + bool setCurrent = false; + if (_currentSprite == _sprite) { + _currentSprite = NULL; + setCurrent = true; + } + + delete _sprite; + _sprite = NULL; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + delete _sprite; + _sprite = NULL; + return STATUS_FAILED; + } else { + _sprite = spr; + _currentSprite = _sprite; + return STATUS_OK; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdEntity.h b/engines/wintermute/ad/AdEntity.h new file mode 100644 index 0000000000..a260ca3329 --- /dev/null +++ b/engines/wintermute/ad/AdEntity.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADENTITY_H +#define WINTERMUTE_ADENTITY_H + +#include "engines/wintermute/ad/AdTalkHolder.h" + +namespace WinterMute { +class CVidTheoraPlayer; +class CAdEntity : public CAdTalkHolder { +public: + CVidTheoraPlayer *_theora; + bool setSprite(const char *filename); + int _walkToX; + int _walkToY; + TDirection _walkToDir; + void setItem(const char *itemName); + char *_item; + DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) + void updatePosition(); + virtual int getHeight(); + CBRegion *_region; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool update(); + virtual bool display(); + CAdEntity(CBGame *inGame); + virtual ~CAdEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + TEntityType _subtype; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdGame.cpp b/engines/wintermute/ad/AdGame.cpp new file mode 100644 index 0000000000..87e3fe14d9 --- /dev/null +++ b/engines/wintermute/ad/AdGame.cpp @@ -0,0 +1,2061 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdActor.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/ad/AdInventory.h" +#include "engines/wintermute/ad/AdInventoryBox.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/ad/AdResponse.h" +#include "engines/wintermute/ad/AdResponseBox.h" +#include "engines/wintermute/ad/AdResponseContext.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/ad/AdSceneState.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/BTransitionMgr.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/particles/PartEmitter.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/ui/UIEntity.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdGame, true) + +////////////////////////////////////////////////////////////////////////// +CAdGame::CAdGame(): CBGame() { + _responseBox = NULL; + _inventoryBox = NULL; + + _scene = new CAdScene(_gameRef); + _scene->setName(""); + registerObject(_scene); + + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _scheduledFadeIn = false; + + + _stateEx = GAME_NORMAL; + + _selectedItem = NULL; + + + _texItemLifeTime = 10000; + _texWalkLifeTime = 10000; + _texStandLifeTime = 10000; + _texTalkLifeTime = 10000; + + _talkSkipButton = TALK_SKIP_LEFT; + + _sceneViewport = NULL; + + _initialScene = true; + _debugStartupScene = NULL; + _startupScene = NULL; + + _invObject = new CAdObject(this); + _inventoryOwner = _invObject; + + _tempDisableSaveState = false; + _itemsFile = NULL; + + _smartItemCursor = false; + + addSpeechDir("speech"); +} + + +////////////////////////////////////////////////////////////////////////// +CAdGame::~CAdGame() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::cleanup() { + int i; + + for (i = 0; i < _objects.getSize(); i++) { + unregisterObject(_objects[i]); + _objects[i] = NULL; + } + _objects.removeAll(); + + + for (i = 0; i < _dlgPendingBranches.getSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.removeAll(); + + for (i = 0; i < _speechDirs.getSize(); i++) { + delete [] _speechDirs[i]; + } + _speechDirs.removeAll(); + + + unregisterObject(_scene); + _scene = NULL; + + // remove items + for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); + _items.removeAll(); + + + // clear remaining inventories + delete _invObject; + _invObject = NULL; + + for (i = 0; i < _inventories.getSize(); i++) { + delete _inventories[i]; + } + _inventories.removeAll(); + + + if (_responseBox) { + _gameRef->unregisterObject(_responseBox); + _responseBox = NULL; + } + + if (_inventoryBox) { + _gameRef->unregisterObject(_inventoryBox); + _inventoryBox = NULL; + } + + delete[] _prevSceneName; + delete[] _prevSceneFilename; + delete[] _scheduledScene; + delete[] _debugStartupScene; + delete[] _itemsFile; + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _debugStartupScene = NULL; + _startupScene = NULL; + _itemsFile = NULL; + + delete _sceneViewport; + _sceneViewport = NULL; + + for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); + + for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + + for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); + + return CBGame::cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::initLoop() { + if (_scheduledScene && _transMgr->isReady()) { + changeScene(_scheduledScene, _scheduledFadeIn); + delete[] _scheduledScene; + _scheduledScene = NULL; + + _gameRef->_activeObject = NULL; + } + + + bool res; + res = CBGame::initLoop(); + if (DID_FAIL(res)) return res; + + if (_scene) res = _scene->initLoop(); + + _sentences.removeAll(); + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addObject(CAdObject *object) { + _objects.add(object); + return registerObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::removeObject(CAdObject *object) { + // in case the user called Scene.CreateXXX() and Game.DeleteXXX() + if (_scene) { + bool Res = _scene->removeObject(object); + if (DID_SUCCEED(Res)) return Res; + } + + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] == object) { + _objects.removeAt(i); + break; + } + } + return unregisterObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::changeScene(const char *filename, bool fadeIn) { + if (_scene == NULL) { + _scene = new CAdScene(_gameRef); + registerObject(_scene); + } else { + _scene->applyEvent("SceneShutdown", true); + + setPrevSceneName(_scene->_name); + setPrevSceneFilename(_scene->_filename); + + if (!_tempDisableSaveState) _scene->saveState(); + _tempDisableSaveState = false; + } + + if (_scene) { + // reset objects + for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); + + // reset scene properties + _scene->_sFXVolume = 100; + if (_scene->_scProp) _scene->_scProp->cleanup(); + + bool ret; + if (_initialScene && _debugDebugMode && _debugStartupScene) { + _initialScene = false; + ret = _scene->loadFile(_debugStartupScene); + } else ret = _scene->loadFile(filename); + + if (DID_SUCCEED(ret)) { + // invalidate references to the original scene + for (int i = 0; i < _objects.getSize(); i++) { + _objects[i]->invalidateCurrRegions(); + _objects[i]->_stickRegion = NULL; + } + + _scene->loadState(); + } + if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); + return ret; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::addSentence(CAdSentence *sentence) { + _sentences.add(sentence); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displaySentences(bool frozen) { + for (int i = 0; i < _sentences.getSize(); i++) { + if (frozen && _sentences[i]->_freezable) continue; + else _sentences[i]->display(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::finishSentences() { + for (int i = 0; i < _sentences.getSize(); i++) { + if (_sentences[i]->CanSkip()) { + _sentences[i]->_duration = 0; + if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // ChangeScene + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "ChangeScene") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + CScValue *valFadeOut = stack->pop(); + CScValue *valFadeIn = stack->pop(); + + bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); + bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); + + scheduleChangeScene(filename, transIn); + if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); + stack->pushNULL(); + + + //bool ret = ChangeScene(stack->pop()->getString()); + //if(DID_FAIL(ret)) stack->pushBool(false); + //else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadActor") == 0) { + stack->correctParams(1); + CAdActor *act = new CAdActor(_gameRef); + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { + addObject(act); + stack->pushNative(act, true); + } else { + delete act; + act = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadEntity") == 0) { + stack->correctParams(1); + CAdEntity *ent = new CAdEntity(_gameRef); + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { + addObject(ent); + stack->pushNative(ent, true); + } else { + delete ent; + ent = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CAdObject *obj = (CAdObject *)val->getNative(); + removeObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdEntity *ent = new CAdEntity(_gameRef); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = new CAdItem(_gameRef); + addItem(item); + if (!val->isNULL()) item->setName(val->getString()); + stack->pushNative(item, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = NULL; + if (val->isNative()) item = (CAdItem *)val->getNative(); + else item = getItemByName(val->getString()); + + if (item) { + deleteItem(item); + } + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QueryItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QueryItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _items.getSize()) item = _items[index]; + } else { + item = getItemByName(val->getString()); + } + + if (item) stack->pushNative(item, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // AddResponse/AddResponseOnce/AddResponseOnceGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { + stack->correctParams(6); + int id = stack->pop()->getInt(); + const char *text = stack->pop()->getString(); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + CScValue *val4 = stack->pop(); + + if (_responseBox) { + CAdResponse *res = new CAdResponse(_gameRef); + if (res) { + res->_iD = id; + res->setText(text); + _stringTable->expand(&res->_text); + if (!val1->isNULL()) res->setIcon(val1->getString()); + if (!val2->isNULL()) res->setIconHover(val2->getString()); + if (!val3->isNULL()) res->setIconPressed(val3->getString()); + if (!val4->isNULL()) res->setFont(val4->getString()); + + if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; + else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; + + _responseBox->_responses.add(res); + } + } else { + script->runtimeError("Game.AddResponse: response box is not defined"); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResetResponse") == 0) { + stack->correctParams(1); + int ID = stack->pop()->getInt(-1); + resetResponse(ID); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearResponses") == 0) { + stack->correctParams(0); + _responseBox->clearResponses(); + _responseBox->clearButtons(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetResponse") == 0) { + stack->correctParams(1); + bool autoSelectLast = stack->pop()->getBool(); + + if (_responseBox) { + _responseBox->weedResponses(); + + if (_responseBox->_responses.getSize() == 0) { + stack->pushNULL(); + return STATUS_OK; + } + + + if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { + stack->pushInt(_responseBox->_responses[0]->_iD); + _responseBox->handleResponse(_responseBox->_responses[0]); + _responseBox->clearResponses(); + return STATUS_OK; + } + + _responseBox->createButtons(); + _responseBox->_waitingScript = script; + script->waitForExclusive(_responseBox); + _state = GAME_SEMI_FROZEN; + _stateEx = GAME_WAITING_RESPONSE; + } else { + script->runtimeError("Game.GetResponse: response box is not defined"); + stack->pushNULL(); + } + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // GetNumResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNumResponses") == 0) { + stack->correctParams(0); + if (_responseBox) { + _responseBox->weedResponses(); + stack->pushInt(_responseBox->_responses.getSize()); + } else { + script->runtimeError("Game.GetNumResponses: response box is not defined"); + stack->pushNULL(); + } + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // StartDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartDlgBranch") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + Common::String branchName; + if (val->isNULL()) { + branchName.format("line%d", script->_currentLine); + } else branchName = val->getString(); + + startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EndDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EndDlgBranch") == 0) { + stack->correctParams(1); + + const char *branchName = NULL; + CScValue *val = stack->pop(); + if (!val->isNULL()) branchName = val->getString(); + endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCurrentDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCurrentDlgBranch") == 0) { + stack->correctParams(0); + + if (_dlgPendingBranches.getSize() > 0) { + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TakeItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DropItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // IsItemTaken + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsItemTaken") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + for (int i = 0; i < _inventories.getSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { + if (val->getNative() == Inv->_takenItems[j]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { + stack->pushBool(true); + return STATUS_OK; + } + } + } + } else script->runtimeError("Game.IsItemTaken: item name expected"); + + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInventoryWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInventoryWindow") == 0) { + stack->correctParams(0); + if (_inventoryBox && _inventoryBox->_window) + stack->pushNative(_inventoryBox->_window, true); + else + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponsesWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { + stack->correctParams(0); + if (_responseBox && _responseBox->_window) + stack->pushNative(_responseBox->_window, true); + else + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadResponseBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadResponseBox") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _gameRef->unregisterObject(_responseBox); + _responseBox = new CAdResponseBox(_gameRef); + if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { + registerObject(_responseBox); + stack->pushBool(true); + } else { + delete _responseBox; + _responseBox = NULL; + stack->pushBool(false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadInventoryBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadInventoryBox") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _gameRef->unregisterObject(_inventoryBox); + _inventoryBox = new CAdInventoryBox(_gameRef); + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { + registerObject(_inventoryBox); + stack->pushBool(true); + } else { + delete _inventoryBox; + _inventoryBox = NULL; + stack->pushBool(false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadItems") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool merge = stack->pop()->getBool(false); + + bool ret = loadItemsFile(filename, merge); + stack->pushBool(DID_SUCCEED(ret)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSpeechDir") == 0) { + stack->correctParams(1); + const char *dir = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSpeechDir(dir))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSpeechDir") == 0) { + stack->correctParams(1); + const char *dir = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSpeechDir(dir))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSceneViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSceneViewport") == 0) { + stack->correctParams(4); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); + + if (width <= 0) width = _renderer->_width; + if (height <= 0) height = _renderer->_height; + + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBGame::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scene") == 0) { + if (_scene) _scValue->setNative(_scene, true); + else _scValue->setNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelectedItem") == 0) { + //if(_selectedItem) _scValue->setString(_selectedItem->_name); + if (_selectedItem) _scValue->setNative(_selectedItem, true); + else _scValue->setNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumItems") == 0) { + return _invObject->scGetProperty(name); + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SmartItemCursor") == 0) { + _scValue->setBool(_smartItemCursor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryVisible") == 0) { + _scValue->setBool(_inventoryBox && _inventoryBox->_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); + else _scValue->setInt(0); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ResponsesVisible (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResponsesVisible") == 0) { + _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevScene / PreviousScene (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { + if (!_prevSceneName) _scValue->setString(""); + else _scValue->setString(_prevSceneName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevSceneFilename / PreviousSceneFilename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { + if (!_prevSceneFilename) _scValue->setString(""); + else _scValue->setString(_prevSceneFilename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponse (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LastResponse") == 0) { + if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseText); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponseOrig (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LastResponseOrig") == 0) { + if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseTextOrig); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryObject") == 0) { + if (_inventoryOwner == _invObject) _scValue->setNative(this, true); + else _scValue->setNative(_inventoryOwner, true); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TotalNumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TotalNumItems") == 0) { + _scValue->setInt(_items.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkSkipButton") == 0) { + _scValue->setInt(_talkSkipButton); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ChangingScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ChangingScene") == 0) { + _scValue->setBool(_scheduledScene != NULL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartupScene") == 0) { + if (!_startupScene) _scValue->setNULL(); + else _scValue->setString(_startupScene); + return _scValue; + } + + else return CBGame::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelectedItem") == 0) { + if (value->isNULL()) _selectedItem = NULL; + else { + if (value->isNative()) { + _selectedItem = NULL; + for (int i = 0; i < _items.getSize(); i++) { + if (_items[i] == value->getNative()) { + _selectedItem = (CAdItem *)value->getNative(); + break; + } + } + } else { + // try to get by name + _selectedItem = getItemByName(value->getString()); + } + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SmartItemCursor") == 0) { + _smartItemCursor = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryVisible") == 0) { + if (_inventoryBox) _inventoryBox->_visible = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryObject") == 0) { + if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + + if (value->isNULL()) _inventoryOwner = _invObject; + else { + CBObject *Obj = (CBObject *)value->getNative(); + if (Obj == this) _inventoryOwner = _invObject; + else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + } + + if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkSkipButton") == 0) { + int Val = value->getInt(); + if (Val < 0) Val = 0; + if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; + _talkSkipButton = (TTalkSkipButton)Val; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartupScene") == 0) { + if (value == NULL) { + delete[] _startupScene; + _startupScene = NULL; + } else CBUtils::setString(&_startupScene, value->getString()); + + return STATUS_OK; + } + + else return CBGame::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // Actor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Actor") == 0) { + stack->correctParams(0); + this_obj = thisStack->getTop(); + + this_obj->setNative(new CAdActor(_gameRef)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Entity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Entity") == 0) { + stack->correctParams(0); + this_obj = thisStack->getTop(); + + this_obj->setNative(new CAdEntity(_gameRef)); + stack->pushNULL(); + } + + + ////////////////////////////////////////////////////////////////////////// + // call parent + else return CBGame::ExternalCall(script, stack, thisStack, name); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem->_cursorCombined) { + CBSprite *origLastCursor = _lastCursor; + CBGame::showCursor(); + _lastCursor = origLastCursor; + } + if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) + return drawCursor(_selectedItem->_cursorHover); + else + return drawCursor(_selectedItem->_cursorNormal); + } else return drawCursor(_selectedItem->_cursorNormal); + } else return CBGame::showCursor(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadFile(const char *filename) { + byte *buffer = _fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(AD_GAME) +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(ITEMS) +TOKEN_DEF(ITEM) +TOKEN_DEF(TALK_SKIP_BUTTON) +TOKEN_DEF(SCENE_VIEWPORT) +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(STARTUP_SCENE) +TOKEN_DEF(DEBUG_STARTUP_SCENE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(AD_GAME) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(ITEMS) + TOKEN_TABLE(TALK_SKIP_BUTTON) + TOKEN_TABLE(SCENE_VIEWPORT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(STARTUP_SCENE) + TOKEN_TABLE(DEBUG_STARTUP_SCENE) + TOKEN_TABLE_END + + byte *params; + byte *params2; + int cmd = 1; + CBParser parser(_gameRef); + + bool itemFound = false, itemsFound = false; + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AD_GAME: + while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + switch (cmd) { + case TOKEN_RESPONSE_BOX: + delete _responseBox; + _responseBox = new CAdResponseBox(_gameRef); + if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) + registerObject(_responseBox); + else { + delete _responseBox; + _responseBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_INVENTORY_BOX: + delete _inventoryBox; + _inventoryBox = new CAdInventoryBox(_gameRef); + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) + registerObject(_inventoryBox); + else { + delete _inventoryBox; + _inventoryBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ITEMS: + itemsFound = true; + CBUtils::setString(&_itemsFile, (char *)params2); + if (DID_FAIL(loadItemsFile(_itemsFile))) { + delete[] _itemsFile; + _itemsFile = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_TALK_SKIP_BUTTON: + if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; + else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; + else _talkSkipButton = TALK_SKIP_LEFT; + break; + + case TOKEN_SCENE_VIEWPORT: { + Rect32 rc; + parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params2, false); + break; + + case TOKEN_STARTUP_SCENE: + CBUtils::setString(&_startupScene, (char *)params2); + break; + + case TOKEN_DEBUG_STARTUP_SCENE: + CBUtils::setString(&_debugStartupScene, (char *)params2); + break; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + if (itemFound && !itemsFound) { + _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file."); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + CBGame::persist(persistMgr); + + _dlgPendingBranches.persist(persistMgr); + + _inventories.persist(persistMgr); + persistMgr->transfer(TMEMBER(_inventoryBox)); + + _objects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_prevSceneName)); + persistMgr->transfer(TMEMBER(_prevSceneFilename)); + + persistMgr->transfer(TMEMBER(_responseBox)); + _responsesBranch.persist(persistMgr); + _responsesGame.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scene)); + _sceneStates.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scheduledFadeIn)); + persistMgr->transfer(TMEMBER(_scheduledScene)); + persistMgr->transfer(TMEMBER(_selectedItem)); + persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); + + _sentences.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_sceneViewport)); + persistMgr->transfer(TMEMBER_INT(_stateEx)); + persistMgr->transfer(TMEMBER(_initialScene)); + persistMgr->transfer(TMEMBER(_debugStartupScene)); + + persistMgr->transfer(TMEMBER(_invObject)); + persistMgr->transfer(TMEMBER(_inventoryOwner)); + persistMgr->transfer(TMEMBER(_tempDisableSaveState)); + _items.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_itemsFile)); + + _speechDirs.persist(persistMgr); + persistMgr->transfer(TMEMBER(_smartItemCursor)); + + if (!persistMgr->_saving) _initialScene = false; + + persistMgr->transfer(TMEMBER(_startupScene)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadGame(const char *filename) { + bool ret = CBGame::loadGame(filename); + if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::initAfterLoad() { + CBGame::initAfterLoad(); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdGame::afterLoadScene(void *scene, void *data) { + ((CAdScene *)scene)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::setPrevSceneName(const char *name) { + delete[] _prevSceneName; + _prevSceneName = NULL; + if (name) { + _prevSceneName = new char[strlen(name) + 1]; + if (_prevSceneName) strcpy(_prevSceneName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::setPrevSceneFilename(const char *name) { + delete[] _prevSceneFilename; + _prevSceneFilename = NULL; + if (name) { + _prevSceneFilename = new char[strlen(name) + 1]; + if (_prevSceneFilename) strcpy(_prevSceneFilename, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { + delete[] _scheduledScene; + _scheduledScene = NULL; + + if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); + else { + _scheduledScene = new char [strlen(filename) + 1]; + strcpy(_scheduledScene, filename); + + _scheduledFadeIn = fadeIn; + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + CBGame::getVersion(verMajor, verMinor, NULL, NULL); + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadItemsFile(const char *filename, bool merge) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + //_filename = new char [strlen(filename)+1]; + //strcpy(_filename, filename); + + if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (!merge) { + while (_items.getSize() > 0) deleteItem(_items[0]); + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ITEM: { + CAdItem *item = new CAdItem(_gameRef); + if (item && !DID_FAIL(item->loadBuffer(params, false))) { + // delete item with the same name, if exists + if (merge) { + CAdItem *PrevItem = getItemByName(item->_name); + if (PrevItem) deleteItem(PrevItem); + } + addItem(item); + } else { + delete item; + item = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ITEMS definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ITEMS definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { + char *filenameCor = new char[strlen(filename) + 1]; + strcpy(filenameCor, filename); + for (uint32 i = 0; i < strlen(filenameCor); i++) { + if (filenameCor[i] == '/') filenameCor[i] = '\\'; + } + + for (int i = 0; i < _sceneStates.getSize(); i++) { + if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { + delete [] filenameCor; + return _sceneStates[i]; + } + } + + if (saving) { + CAdSceneState *ret = new CAdSceneState(_gameRef); + ret->setFilename(filenameCor); + + _sceneStates.add(ret); + + delete [] filenameCor; + return ret; + } else { + delete [] filenameCor; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE_END + + int cmd = PARSERR_GENERIC; + CBParser parser(_gameRef); + + cmd = parser.getCommand(buffer, commands, params); + switch (cmd) { + case TOKEN_ENTITY_CONTAINER: { + CUIEntity *ent = new CUIEntity(_gameRef); + if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { + delete ent; + ent = NULL; + cmd = PARSERR_GENERIC; + } else { + ent->_parent = win; + win->_widgets.add(ent); + } + } + break; + } + + if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { + return STATUS_FAILED; + } + + return STATUS_OK; + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + if (strcmp(name, "CreateEntityContainer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIEntity *ent = new CUIEntity(_gameRef); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + + ent->_parent = win; + win->_widgets.add(ent); + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); + _dlgPendingBranches.add(name); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = NULL; + bool deleteName = false; + if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { + name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; + } else { + if (branchName != NULL) { + name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); + deleteName = true; + } + } + } + + if (name == NULL) return STATUS_OK; + + + int startIndex = -1; + for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { + if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { + startIndex = i; + break; + } + } + if (startIndex >= 0) { + for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { + //ClearBranchResponses(_dlgPendingBranches[i]); + delete [] _dlgPendingBranches[i]; + _dlgPendingBranches[i] = NULL; + } + _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); + } + + // dialogue is over, forget selected responses + if (_dlgPendingBranches.getSize() == 0) { + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + } + + if (deleteName) delete [] name; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::clearBranchResponses(char *name) { + for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addBranchResponse(int ID) { + if (branchResponseUsed(ID)) return STATUS_OK; + CAdResponseContext *r = new CAdResponseContext(_gameRef); + r->_iD = ID; + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesBranch.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::branchResponseUsed(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addGameResponse(int ID) { + if (gameResponseUsed(ID)) return STATUS_OK; + CAdResponseContext *r = new CAdResponseContext(_gameRef); + r->_iD = ID; + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesGame.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::gameResponseUsed(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesGame.getSize(); i++) { + CAdResponseContext *RespContext = _responsesGame[i]; + if (RespContext->_iD == ID) { + if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::resetResponse(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + + int i; + + for (i = 0; i < _responsesGame.getSize(); i++) { + if (_responsesGame[i]->_iD == ID) { + if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { + delete _responsesGame[i]; + _responsesGame.removeAt(i); + break; + } + } + } + + for (i = 0; i < _responsesBranch.getSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.removeAt(i); + break; + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displayContent(bool doUpdate, bool displayAll) { + // init + if (doUpdate) initLoop(); + + // fill black + _renderer->fill(0, 0, 0); + if (!_editorMode) _renderer->setScreenViewport(); + + // playing exclusive video? + if (_videoPlayer->isPlaying()) { + if (doUpdate) _videoPlayer->update(); + _videoPlayer->display(); + } else if (_theoraPlayer) { + if (_theoraPlayer->isPlaying()) { + if (doUpdate) _theoraPlayer->update(); + _theoraPlayer->display(); + } + if (_theoraPlayer->isFinished()) { + delete _theoraPlayer; + _theoraPlayer = NULL; + } + } else { + + // process scripts + if (doUpdate) _scEngine->tick(); + + Point32 p; + getMousePos(&p); + + _scene->update(); + _scene->display(); + + + // display in-game windows + displayWindows(true); + if (_inventoryBox) _inventoryBox->display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); + if (_indicatorDisplay) displayIndicator(); + + + if (doUpdate || displayAll) { + // display normal windows + displayWindows(false); + + setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); + + // textual info + displaySentences(_state == GAME_FROZEN); + + showCursor(); + + if (_fader) _fader->display(); + _transMgr->update(); + } + + } + if (_loadingIcon) { + _loadingIcon->display(_loadingIconX, _loadingIconY); + if (!_loadingIconPersistent) { + delete _loadingIcon; + _loadingIcon = NULL; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::registerInventory(CAdInventory *inv) { + for (int i = 0; i < _inventories.getSize(); i++) { + if (_inventories[i] == inv) return STATUS_OK; + } + registerObject(inv); + _inventories.add(inv); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::unregisterInventory(CAdInventory *inv) { + for (int i = 0; i < _inventories.getSize(); i++) { + if (_inventories[i] == inv) { + unregisterObject(_inventories[i]); + _inventories.removeAt(i); + return STATUS_OK; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::isItemTaken(char *itemName) { + for (int i = 0; i < _inventories.getSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { + if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +CAdItem *CAdGame::getItemByName(const char *name) { + for (int i = 0; i < _items.getSize(); i++) { + if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addItem(CAdItem *item) { + _items.add(item); + return _gameRef->registerObject(item); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::resetContent() { + // clear pending dialogs + for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.removeAll(); + + + // clear inventories + for (int i = 0; i < _inventories.getSize(); i++) { + _inventories[i]->_takenItems.removeAll(); + } + + // clear scene states + for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); + + // clear once responses + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + + // clear once game responses + for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); + + // reload inventory items + if (_itemsFile) loadItemsFile(_itemsFile); + + _tempDisableSaveState = true; + + return CBGame::resetContent(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::deleteItem(CAdItem *item) { + if (!item) return STATUS_FAILED; + + if (_selectedItem == item) _selectedItem = NULL; + _scene->handleItemAssociations(item->_name, false); + + // remove from all inventories + for (int i = 0; i < _inventories.getSize(); i++) { + _inventories[i]->removeItem(item); + } + + // remove object + for (int i = 0; i < _items.getSize(); i++) { + if (_items[i] == item) { + unregisterObject(_items[i]); + _items.removeAt(i); + break; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; + + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); + + for (int i = 0; i < _speechDirs.getSize(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete [] temp; + return STATUS_OK; + } + } + _speechDirs.add(temp); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::removeSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; + + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); + + bool Found = false; + for (int i = 0; i < _speechDirs.getSize(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete [] _speechDirs[i]; + _speechDirs.removeAt(i); + Found = true; + break; + } + } + delete [] temp; + + if (Found) return STATUS_OK; + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdGame::findSpeechFile(char *stringID) { + char *ret = new char[MAX_PATH_LENGTH]; + + for (int i = 0; i < _speechDirs.getSize(); i++) { + sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); + Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile + if (file) { + _fileManager->closeFile(file); + return ret; + } + + sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); + file = _fileManager->openFile(ret); + if (file) { + _fileManager->closeFile(file); + return ret; + } + } + delete [] ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::validMouse() { + Point32 pos; + CBPlatform::getCursorPos(&pos); + + return _renderer->pointInViewport(&pos); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftDown() { + if (!validMouse()) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { + finishSentences(); + } + return STATUS_OK; + } + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftDblClick() { + if (!validMouse()) return STATUS_OK; + + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseRightDown() { + if (!validMouse()) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { + finishSentences(); + } + return STATUS_OK; + } + + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displayDebugInfo() { + char str[100]; + if (_gameRef->_debugDebugMode) { + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); + _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + + sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); + _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + } + return CBGame::displayDebugInfo(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onScriptShutdown(CScScript *script) { + if (_responseBox && _responseBox->_waitingScript == script) + _responseBox->_waitingScript = NULL; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdGame.h b/engines/wintermute/ad/AdGame.h new file mode 100644 index 0000000000..4a89fa97d2 --- /dev/null +++ b/engines/wintermute/ad/AdGame.h @@ -0,0 +1,161 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_ADGAME_H +#define WINTERMUTE_ADGAME_H + +#include "engines/wintermute/ad/AdTypes.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { +class CAdItem; +class CAdInventory; +class CAdSceneState; +class CAdScene; +class CAdItem; +class CAdObject; +class CAdSentence; +class CAdInventoryBox; +class CAdResponseContext; +class CAdResponseBox; +class CAdGame : public CBGame { +public: + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + + virtual bool displayDebugInfo(); + + + virtual bool initAfterLoad(); + static void afterLoadScene(void *scene, void *data); + + bool _smartItemCursor; + + CBArray _speechDirs; + bool addSpeechDir(const char *dir); + bool removeSpeechDir(const char *dir); + char *findSpeechFile(char *StringID); + + bool deleteItem(CAdItem *Item); + char *_itemsFile; + bool _tempDisableSaveState; + virtual bool resetContent(); + bool addItem(CAdItem *item); + CAdItem *getItemByName(const char *name); + CBArray _items; + CAdObject *_inventoryOwner; + bool isItemTaken(char *itemName); + bool registerInventory(CAdInventory *inv); + bool unregisterInventory(CAdInventory *inv); + + CAdObject *_invObject; + CBArray _inventories; + virtual bool displayContent(bool update = true, bool displayAll = false); + char *_debugStartupScene; + char *_startupScene; + bool _initialScene; + bool gameResponseUsed(int ID); + bool addGameResponse(int ID); + bool resetResponse(int ID); + + bool branchResponseUsed(int ID); + bool addBranchResponse(int ID); + bool clearBranchResponses(char *name); + bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + + CAdSceneState *getSceneState(const char *filename, bool saving); + CBViewport *_sceneViewport; + int _texItemLifeTime; + int _texWalkLifeTime; + int _texStandLifeTime; + int _texTalkLifeTime; + + TTalkSkipButton _talkSkipButton; + + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + bool scheduleChangeScene(const char *filename, bool fadeIn); + char *_scheduledScene; + bool _scheduledFadeIn; + void setPrevSceneName(const char *name); + void setPrevSceneFilename(const char *name); + char *_prevSceneName; + char *_prevSceneFilename; + virtual bool loadGame(const char *filename); + CAdItem *_selectedItem; + bool cleanup(); + DECLARE_PERSISTENT(CAdGame, CBGame) + + void finishSentences(); + bool showCursor(); + TGameStateEx _stateEx; + CAdResponseBox *_responseBox; + CAdInventoryBox *_inventoryBox; + bool displaySentences(bool frozen); + void addSentence(CAdSentence *sentence); + bool changeScene(const char *filename, bool fadeIn); + bool removeObject(CAdObject *object); + bool addObject(CAdObject *object); + CAdScene *_scene; + bool initLoop(); + CAdGame(); + virtual ~CAdGame(); + CBArray _objects; + CBArray _sentences; + + CBArray _sceneStates; + CBArray _dlgPendingBranches; + + CBArray _responsesBranch; + CBArray _responsesGame; + + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + + bool loadItemsFile(const char *filename, bool merge = false); + bool loadItemsBuffer(byte *buffer, bool merge = false); + + + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool validMouse(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdInventory.cpp b/engines/wintermute/ad/AdInventory.cpp new file mode 100644 index 0000000000..54195cc68a --- /dev/null +++ b/engines/wintermute/ad/AdInventory.cpp @@ -0,0 +1,119 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/AdInventory.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventory, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { + _scrollOffset = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventory::~CAdInventory() { + _takenItems.removeAll(); // ref only +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::insertItem(const char *name, const char *insertAfter) { + if (name == NULL) return STATUS_FAILED; + + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); + if (item == NULL) return STATUS_FAILED; + + int insertIndex = -1; + for (int i = 0; i < _takenItems.getSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + _takenItems.removeAt(i); + i--; + continue; + } + if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; + } + + + if (insertIndex == -1) _takenItems.add(item); + else _takenItems.insertAt(insertIndex, item); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::removeItem(const char *name) { + if (name == NULL) return STATUS_FAILED; + + for (int i = 0; i < _takenItems.getSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + _takenItems.removeAt(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::removeItem(CAdItem *item) { + if (item == NULL) return STATUS_FAILED; + + for (int i = 0; i < _takenItems.getSize(); i++) { + if (_takenItems[i] == item) { + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + _takenItems.removeAt(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + _takenItems.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdInventory.h b/engines/wintermute/ad/AdInventory.h new file mode 100644 index 0000000000..cec76c03a0 --- /dev/null +++ b/engines/wintermute/ad/AdInventory.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORY_H +#define WINTERMUTE_ADINVENTORY_H + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CAdItem; + +class CAdInventory : public CBObject { +public: + DECLARE_PERSISTENT(CAdInventory, CBObject) + bool removeItem(const char *name); + bool removeItem(CAdItem *Item); + bool insertItem(const char *name, const char *insertAfter = NULL); + CAdInventory(CBGame *inGame); + virtual ~CAdInventory(); + CBArray _takenItems; + int _scrollOffset; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdInventoryBox.cpp b/engines/wintermute/ad/AdInventoryBox.cpp new file mode 100644 index 0000000000..c5c9c3be67 --- /dev/null +++ b/engines/wintermute/ad/AdInventoryBox.cpp @@ -0,0 +1,372 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdInventoryBox.h" +#include "engines/wintermute/ad/AdInventory.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/ui/UIButton.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/rect.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventoryBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { + _itemsArea.setEmpty(); + _scrollOffset = 0; + _spacing = 0; + _itemWidth = _itemHeight = 50; + _scrollBy = 1; + + _window = NULL; + _closeButton = NULL; + + _hideSelected = false; + + _visible = false; + _exclusive = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::~CAdInventoryBox() { + _gameRef->unregisterObject(_window); + _window = NULL; + + delete _closeButton; + _closeButton = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) { + _visible = false; + } else if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset -= _scrollBy; + _scrollOffset = MAX(_scrollOffset, 0); + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset += _scrollBy; + } else return CBObject::listen(param1, param2); + break; + default: + error("CAdInventoryBox::Listen - Unhandled enum"); + break; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::display() { + CAdGame *adGame = (CAdGame *)_gameRef; + + if (!_visible) return STATUS_OK; + + int itemsX, itemsY; + itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + itemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); + + if (_window) { + _window->enableWidget("prev", _scrollOffset > 0); + _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); + } + + + if (_closeButton) { + _closeButton->_posX = _closeButton->_posY = 0; + _closeButton->_width = _gameRef->_renderer->_width; + _closeButton->_height = _gameRef->_renderer->_height; + + _closeButton->display(); + } + + + // display window + Rect32 rect = _itemsArea; + if (_window) { + rect.offsetRect(_window->_posX, _window->_posY); + _window->display(); + } + + // display items + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; + int yyy = rect.top; + for (int j = 0; j < itemsY; j++) { + int xxx = rect.left; + for (int i = 0; i < itemsX; i++) { + int itemIndex = _scrollOffset + j * itemsX + i; + if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { + CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; + if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { + item->update(); + item->display(xxx, yyy); + } + } + + xxx += (_itemWidth + _spacing); + } + yyy += (_itemHeight + _spacing); + } + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(WINDOW) +TOKEN_DEF(EXCLUSIVE) +TOKEN_DEF(ALWAYS_VISIBLE) +TOKEN_DEF(AREA) +TOKEN_DEF(SPACING) +TOKEN_DEF(ITEM_WIDTH) +TOKEN_DEF(ITEM_HEIGHT) +TOKEN_DEF(SCROLL_BY) +TOKEN_DEF(NAME) +TOKEN_DEF(CAPTION) +TOKEN_DEF(HIDE_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(EXCLUSIVE) + TOKEN_TABLE(ALWAYS_VISIBLE) + TOKEN_TABLE(AREA) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(ITEM_WIDTH) + TOKEN_TABLE(ITEM_HEIGHT) + TOKEN_TABLE(SCROLL_BY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(HIDE_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + bool always_visible = false; + + _exclusive = false; + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(_gameRef); + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else _gameRef->registerObject(_window); + break; + + case TOKEN_AREA: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); + break; + + case TOKEN_EXCLUSIVE: + parser.scanStr((char *)params, "%b", &_exclusive); + break; + + case TOKEN_HIDE_SELECTED: + parser.scanStr((char *)params, "%b", &_hideSelected); + break; + + case TOKEN_ALWAYS_VISIBLE: + parser.scanStr((char *)params, "%b", &always_visible); + break; + + case TOKEN_SPACING: + parser.scanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_ITEM_WIDTH: + parser.scanStr((char *)params, "%d", &_itemWidth); + break; + + case TOKEN_ITEM_HEIGHT: + parser.scanStr((char *)params, "%d", &_itemHeight); + break; + + case TOKEN_SCROLL_BY: + parser.scanStr((char *)params, "%d", &_scrollBy); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading INVENTORY_BOX definition"); + return STATUS_FAILED; + } + + if (_exclusive) { + delete _closeButton; + _closeButton = new CUIButton(_gameRef); + if (_closeButton) { + _closeButton->setName("close"); + _closeButton->setListener(this, _closeButton, 0); + _closeButton->_parent = _window; + } + } + + _visible = always_visible; + + if (_window) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "INVENTORY_BOX\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); + + buffer->putTextIndent(indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); + buffer->putTextIndent(indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + buffer->putTextIndent(indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + buffer->putTextIndent(indent + 2, "SCROLL_BY=%d\n", _scrollBy); + + buffer->putTextIndent(indent + 2, "\n"); + + // window + if (_window) _window->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_closeButton)); + persistMgr->transfer(TMEMBER(_hideSelected)); + persistMgr->transfer(TMEMBER(_itemHeight)); + persistMgr->transfer(TMEMBER(_itemsArea)); + persistMgr->transfer(TMEMBER(_itemWidth)); + persistMgr->transfer(TMEMBER(_scrollBy)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_window)); + persistMgr->transfer(TMEMBER(_exclusive)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdInventoryBox.h b/engines/wintermute/ad/AdInventoryBox.h new file mode 100644 index 0000000000..cfd8d74021 --- /dev/null +++ b/engines/wintermute/ad/AdInventoryBox.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORYBOX_H +#define WINTERMUTE_ADINVENTORYBOX_H + +#include "engines/wintermute/base/BObject.h" +#include "common/rect.h" + +namespace WinterMute { +class CUIButton; +class CUIWindow; + +class CAdInventoryBox : public CBObject { +public: + bool _hideSelected; + DECLARE_PERSISTENT(CAdInventoryBox, CBObject) + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; + bool _visible; + virtual bool display(); + CUIButton *_closeButton; + int _spacing; + int _scrollOffset; + Rect32 _itemsArea; + bool listen(CBScriptHolder *param1, uint32 param2); + CUIWindow *_window; + CAdInventoryBox(CBGame *inGame); + virtual ~CAdInventoryBox(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdItem.cpp b/engines/wintermute/ad/AdItem.cpp new file mode 100644 index 0000000000..5678f6cfa6 --- /dev/null +++ b/engines/wintermute/ad/AdItem.cpp @@ -0,0 +1,760 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdItem, false) + +////////////////////////////////////////////////////////////////////////// +CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { + _spriteHover = NULL; + _cursorNormal = _cursorHover = NULL; + + _cursorCombined = true; + _inInventory = false; + + _displayAmount = false; + _amount = 0; + _amountOffsetX = 0; + _amountOffsetY = 0; + _amountAlign = TAL_RIGHT; + _amountString = NULL; + + _state = STATE_READY; + + _movable = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdItem::~CAdItem() { + delete _spriteHover; + delete _cursorNormal; + delete _cursorHover; + _spriteHover = NULL; + _cursorNormal = NULL; + _cursorHover = NULL; + + delete[] _amountString; + _amountString = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ITEM) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(CURSOR_HOVER) +TOKEN_DEF(CURSOR_COMBINED) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(FONT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(SPRITE_HOVER) +TOKEN_DEF(SPRITE) +TOKEN_DEF(DISPLAY_AMOUNT) +TOKEN_DEF(AMOUNT_OFFSET_X) +TOKEN_DEF(AMOUNT_OFFSET_Y) +TOKEN_DEF(AMOUNT_ALIGN) +TOKEN_DEF(AMOUNT_STRING) +TOKEN_DEF(AMOUNT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdItem::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(CURSOR_HOVER) + TOKEN_TABLE(CURSOR_COMBINED) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(FONT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(SPRITE_HOVER) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(DISPLAY_AMOUNT) + TOKEN_TABLE(AMOUNT_OFFSET_X) + TOKEN_TABLE(AMOUNT_OFFSET_Y) + TOKEN_TABLE(AMOUNT_ALIGN) + TOKEN_TABLE(AMOUNT_STRING) + TOKEN_TABLE(AMOUNT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + _gameRef->LOG(0, "'ITEM' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int ar = 0, ag = 0, ab = 0, alpha = 255; + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_IMAGE: + case TOKEN_SPRITE: + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _sprite; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + case TOKEN_SPRITE_HOVER: + delete _spriteHover; + _spriteHover = new CBSprite(_gameRef, this); + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _spriteHover; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_AMOUNT: + parser.scanStr((char *)params, "%d", &_amount); + break; + + case TOKEN_DISPLAY_AMOUNT: + parser.scanStr((char *)params, "%b", &_displayAmount); + break; + + case TOKEN_AMOUNT_OFFSET_X: + parser.scanStr((char *)params, "%d", &_amountOffsetX); + break; + + case TOKEN_AMOUNT_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_amountOffsetY); + break; + + case TOKEN_AMOUNT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; + else _amountAlign = TAL_CENTER; + break; + + case TOKEN_AMOUNT_STRING: + CBUtils::setString(&_amountString, (char *)params); + break; + + case TOKEN_TALK: { + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + } + break; + + case TOKEN_CURSOR: + delete _cursorNormal; + _cursorNormal = new CBSprite(_gameRef); + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _cursorNormal; + _cursorNormal = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_HOVER: + delete _cursorHover; + _cursorHover = new CBSprite(_gameRef); + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _cursorHover; + _cursorHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_COMBINED: + parser.scanStr((char *)params, "%b", &_cursorCombined); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ITEM definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ITEM definition"); + return STATUS_FAILED; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) { + if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; + else _currentSprite = _sprite; + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + default: + break; + } + _ready = (_state == STATE_READY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::display(int x, int y) { + int width = 0; + if (_currentSprite) { + Rect32 rc; + _currentSprite->getBoundingRect(&rc, 0, 0); + width = rc.width(); + } + + _posX = x + width / 2; + _posY = y; + + bool ret; + if (_currentSprite) + ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); + else ret = STATUS_OK; + + if (_displayAmount) { + int amountX = x; + int amountY = y + _amountOffsetY; + + if (_amountAlign == TAL_RIGHT) { + width -= _amountOffsetX; + amountX -= _amountOffsetX; + } + amountX += _amountOffsetX; + + CBFont *font = _font ? _font : _gameRef->_systemFont; + if (font) { + if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); + else { + char Str[256]; + sprintf(Str, "%d", _amount); + font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); + } + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetHoverSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetHoverSprite") == 0) { + stack->correctParams(1); + + bool setCurrent = false; + if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; + + const char *filename = stack->pop()->getString(); + + delete _spriteHover; + _spriteHover = NULL; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); + } else { + _spriteHover = spr; + if (setCurrent) _currentSprite = _spriteHover; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverSprite") == 0) { + stack->correctParams(0); + + if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); + else stack->pushString(_spriteHover->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverSpriteObject") == 0) { + stack->correctParams(0); + if (!_spriteHover) stack->pushNULL(); + else stack->pushNative(_spriteHover, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetNormalCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetNormalCursor") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + delete _cursorNormal; + _cursorNormal = NULL; + CBSprite *spr = new CBSprite(_gameRef); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); + } else { + _cursorNormal = spr; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNormalCursor") == 0) { + stack->correctParams(0); + + if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); + else stack->pushString(_cursorNormal->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNormalCursorObject") == 0) { + stack->correctParams(0); + + if (!_cursorNormal) stack->pushNULL(); + else stack->pushNative(_cursorNormal, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetHoverCursor") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + delete _cursorHover; + _cursorHover = NULL; + CBSprite *spr = new CBSprite(_gameRef); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); + } else { + _cursorHover = spr; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverCursor") == 0) { + stack->correctParams(0); + + if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); + else stack->pushString(_cursorHover->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverCursorObject") == 0) { + stack->correctParams(0); + + if (!_cursorHover) stack->pushNULL(); + else stack->pushNative(_cursorHover, true); + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdItem::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("item"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayAmount") == 0) { + _scValue->setBool(_displayAmount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Amount") == 0) { + _scValue->setInt(_amount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetX") == 0) { + _scValue->setInt(_amountOffsetX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetY") == 0) { + _scValue->setInt(_amountOffsetY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountAlign") == 0) { + _scValue->setInt(_amountAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountString") == 0) { + if (!_amountString) _scValue->setNULL(); + else _scValue->setString(_amountString); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorCombined") == 0) { + _scValue->setBool(_cursorCombined); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayAmount") == 0) { + _displayAmount = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Amount") == 0) { + _amount = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetX") == 0) { + _amountOffsetX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetY") == 0) { + _amountOffsetY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountAlign") == 0) { + _amountAlign = (TTextAlign)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountString") == 0) { + if (value->isNULL()) { + delete[] _amountString; + _amountString = NULL; + } else { + CBUtils::setString(&_amountString, value->getString()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorCombined") == 0) { + _cursorCombined = value->getBool(); + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdItem::scToString() { + return "[item]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::persist(CBPersistMgr *persistMgr) { + + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_cursorCombined)); + persistMgr->transfer(TMEMBER(_cursorHover)); + persistMgr->transfer(TMEMBER(_cursorNormal)); + persistMgr->transfer(TMEMBER(_spriteHover)); + persistMgr->transfer(TMEMBER(_inInventory)); + persistMgr->transfer(TMEMBER(_displayAmount)); + persistMgr->transfer(TMEMBER(_amount)); + persistMgr->transfer(TMEMBER(_amountOffsetX)); + persistMgr->transfer(TMEMBER(_amountOffsetY)); + persistMgr->transfer(TMEMBER_INT(_amountAlign)); + persistMgr->transfer(TMEMBER(_amountString)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; + else return CAdObject::getExtendedFlag(flagName); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdItem.h b/engines/wintermute/ad/AdItem.h new file mode 100644 index 0000000000..d45f9cc614 --- /dev/null +++ b/engines/wintermute/ad/AdItem.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADITEM_H +#define WINTERMUTE_ADITEM_H + + +#include "engines/wintermute/ad/AdTalkHolder.h" + +namespace WinterMute { + +class CAdItem : public CAdTalkHolder { +public: + bool _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; + + + bool update(); + DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) + bool display(int x, int y); + bool getExtendedFlag(const char *flagName); + bool _inInventory; + bool _cursorCombined; + CBSprite *_spriteHover; + CBSprite *_cursorNormal; + CBSprite *_cursorHover; + CAdItem(CBGame *inGame); + virtual ~CAdItem(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdLayer.cpp b/engines/wintermute/ad/AdLayer.cpp new file mode 100644 index 0000000000..d797172338 --- /dev/null +++ b/engines/wintermute/ad/AdLayer.cpp @@ -0,0 +1,537 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/ad/AdLayer.h" +#include "engines/wintermute/ad/AdSceneNode.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdLayer, false) + +////////////////////////////////////////////////////////////////////////// +CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { + _main = false; + _width = _height = 0; + _active = true; + _closeUp = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdLayer::~CAdLayer() { + for (int i = 0; i < _nodes.getSize(); i++) + delete _nodes[i]; + _nodes.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(LAYER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(MAIN) +TOKEN_DEF(ENTITY) +TOKEN_DEF(REGION) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(CLOSE_UP) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(MAIN) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(REGION) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(CLOSE_UP) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + _gameRef->LOG(0, "'LAYER' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_MAIN: + parser.scanStr((char *)params, "%b", &_main); + break; + + case TOKEN_CLOSE_UP: + parser.scanStr((char *)params, "%b", &_closeUp); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_REGION: { + CAdRegion *region = new CAdRegion(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete region; + delete node; + region = NULL; + node = NULL; + } else { + node->setRegion(region); + _nodes.add(node); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (entity) entity->_zoomable = false; // scene entites default to NOT zoom + if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + delete node; + entity = NULL; + node = NULL; + } else { + node->setEntity(entity); + _nodes.add(node); + } + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in LAYER definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int node = -1; + + if (val->_type == VAL_INT) node = val->getInt(); + else { // get by name + for (int i = 0; i < _nodes.getSize(); i++) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { + node = i; + break; + } + } + } + + if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); + else { + switch (_nodes[node]->_type) { + case OBJECT_ENTITY: + stack->pushNative(_nodes[node]->_entity, true); + break; + case OBJECT_REGION: + stack->pushNative(_nodes[node]->_region, true); + break; + default: + stack->pushNULL(); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddRegion / AddEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (strcmp(name, "AddRegion") == 0) { + CAdRegion *region = new CAdRegion(_gameRef); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); + } else { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); + } + _nodes.add(node); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertRegion / InsertEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (strcmp(name, "InsertRegion") == 0) { + CAdRegion *region = new CAdRegion(_gameRef); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); + } else { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); + } + if (index < 0) index = 0; + if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); + else _nodes.add(node); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdSceneNode *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); + for (int i = 0; i < _nodes.getSize(); i++) { + if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { + toDelete = _nodes[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < _nodes.getSize()) { + toDelete = _nodes[index]; + } + } + if (toDelete == NULL) { + stack->pushBool(false); + return STATUS_OK; + } + + for (int i = 0; i < _nodes.getSize(); i++) { + if (_nodes[i] == toDelete) { + delete _nodes[i]; + _nodes[i] = NULL; + _nodes.removeAt(i); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdLayer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("layer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumNodes") == 0) { + _scValue->setInt(_nodes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Main (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Main") == 0) { + _scValue->setBool(_main); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CloseUp") == 0) { + _scValue->setBool(_closeUp); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CloseUp") == 0) { + _closeUp = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + if (_width < 0) _width = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + if (_height < 0) _height = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + bool b = value->getBool(); + if (b == false && _main) { + _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); + } else _active = b; + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdLayer::scToString() { + return "[layer]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "LAYER {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_closeUp) + buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + for (i = 0; i < _nodes.getSize(); i++) { + switch (_nodes[i]->_type) { + case OBJECT_ENTITY: + _nodes[i]->_entity->saveAsText(buffer, indent + 2); + break; + case OBJECT_REGION: + _nodes[i]->_region->saveAsText(buffer, indent + 2); + break; + default: + error("CAdLayer::SaveAsText - Unhandled enum"); + break; + } + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_closeUp)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_main)); + _nodes.persist(persistMgr); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdLayer.h b/engines/wintermute/ad/AdLayer.h new file mode 100644 index 0000000000..0ccdb13ae7 --- /dev/null +++ b/engines/wintermute/ad/AdLayer.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADLAYER_H +#define WINTERMUTE_ADLAYER_H + +namespace WinterMute { +class CAdSceneNode; +class CAdLayer : public CBObject { +public: + bool _closeUp; + DECLARE_PERSISTENT(CAdLayer, CBObject) + bool _active; + int _height; + int _width; + bool _main; + CAdLayer(CBGame *inGame); + virtual ~CAdLayer(); + CBArray _nodes; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdNodeState.cpp b/engines/wintermute/ad/AdNodeState.cpp new file mode 100644 index 0000000000..8e9894b5f5 --- /dev/null +++ b/engines/wintermute/ad/AdNodeState.cpp @@ -0,0 +1,169 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/ad/AdNodeState.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdNodeState, false) + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { + _name = NULL; + _active = false; + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _alphaColor = 0; + _filename = NULL; + _cursor = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::~CAdNodeState() { + delete[] _name; + delete[] _filename; + delete[] _cursor; + _name = NULL; + _filename = NULL; + _cursor = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setName(const char *name) { + delete[] _name; + _name = NULL; + CBUtils::setString(&_name, name); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setFilename(const char *filename) { + delete[] _filename; + _filename = NULL; + CBUtils::setString(&_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setCursor(const char *filename) { + delete[] _cursor; + _cursor = NULL; + CBUtils::setString(&_cursor, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdNodeState::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setCaption(const char *caption, int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7) return; + + delete[] _caption[caseVal- 1]; + _caption[caseVal- 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal- 1]) { + strcpy(_caption[caseVal- 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal- 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdNodeState::getCaption(int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; + else return _caption[caseVal- 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { + if (!entity) return STATUS_FAILED; + + // hack! + if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; + + if (saving) { + for (int i = 0; i < 7; i++) { + if (entity->_caption[i]) setCaption(entity->_caption[i], i); + } + if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { + if (includingSprites) setFilename(entity->_sprite->_filename); + else setFilename(""); + } + if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); + _alphaColor = entity->_alphaColor; + _active = entity->_active; + } else { + for (int i = 0; i < 7; i++) { + if (_caption[i]) entity->setCaption(_caption[i], i); + } + if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { + if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) + entity->setSprite(_filename); + } + if (_cursor) { + if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) + entity->setCursor(_cursor); + } + + entity->_active = _active; + entity->_alphaColor = _alphaColor; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdNodeState.h b/engines/wintermute/ad/AdNodeState.h new file mode 100644 index 0000000000..186f2ebbb2 --- /dev/null +++ b/engines/wintermute/ad/AdNodeState.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADNODESTATE_H +#define WINTERMUTE_ADNODESTATE_H + +namespace WinterMute { + +class CAdEntity; + +class CAdNodeState : public CBBase { +public: + bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); + void setName(const char *name); + void setFilename(const char *filename); + void setCursor(const char *filename); + DECLARE_PERSISTENT(CAdNodeState, CBBase) + CAdNodeState(CBGame *inGame); + virtual ~CAdNodeState(); + char *_name; + bool _active; + char *_caption[7]; + void setCaption(const char *caption, int caseVal); + char *getCaption(int caseVal); + uint32 _alphaColor; + char *_filename; + char *_cursor; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdObject.cpp b/engines/wintermute/ad/AdObject.cpp new file mode 100644 index 0000000000..c74c8cf6b3 --- /dev/null +++ b/engines/wintermute/ad/AdObject.cpp @@ -0,0 +1,1203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/ad/AdObject.h" +#include "engines/wintermute/ad/AdInventory.h" +#include "engines/wintermute/ad/AdLayer.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/ad/AdSceneNode.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "common/str.h" +#include "common/util.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdObject, false) + +////////////////////////////////////////////////////////////////////////// +CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _state = _nextState = STATE_NONE; + + _active = true; + _drawn = false; + + _currentSprite = NULL; + _animSprite = NULL; + _tempSprite2 = NULL; + + _font = NULL; + + _sentence = NULL; + + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + + _blockRegion = NULL; + _wptGroup = NULL; + + _currentBlockRegion = NULL; + _currentWptGroup = NULL; + + _ignoreItems = false; + _sceneIndependent = false; + + _stickRegion = NULL; + + _subtitlesModRelative = true; + _subtitlesModX = 0; + _subtitlesModY = 0; + _subtitlesWidth = 0; + _subtitlesModXCenter = true; + + _inventory = NULL; + + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + + _partEmitter = NULL; + _partFollowParent = false; + _partOffsetX = _partOffsetY = 0; + + _registerAlias = this; +} + + +////////////////////////////////////////////////////////////////////////// +CAdObject::~CAdObject() { + _currentSprite = NULL; // reference only, don't delete + delete _animSprite; + _animSprite = NULL; + delete _sentence; + _sentence = NULL; + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + + delete _blockRegion; + _blockRegion = NULL; + delete _wptGroup; + _wptGroup = NULL; + + delete _currentBlockRegion; + _currentBlockRegion = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + + _tempSprite2 = NULL; // reference only + _stickRegion = NULL; + + if (_font) _gameRef->_fontStorage->removeFont(_font); + + if (_inventory) { + ((CAdGame *)_gameRef)->unregisterInventory(_inventory); + _inventory = NULL; + } + + if (_partEmitter) + _gameRef->unregisterObject(_partEmitter); + + + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + _gameRef->unregisterObject(_attachmentsPre[i]); + } + _attachmentsPre.removeAll(); + + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + _gameRef->unregisterObject(_attachmentsPost[i]); + } + _attachmentsPost.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::playAnim(const char *filename) { + delete _animSprite; + _animSprite = NULL; + _animSprite = new CBSprite(_gameRef, this); + if (!_animSprite) { + _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + return STATUS_FAILED; + } + bool res = _animSprite->loadFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + delete _animSprite; + _animSprite = NULL; + return res; + } + _state = STATE_PLAYING_ANIM; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::display() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::update() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // PlayAnim / PlayAnimAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { + stack->correctParams(1); + if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); + else { + if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTalking") == 0) { + stack->correctParams(0); + stack->pushBool(_state == STATE_TALKING); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTalk / StopTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { + stack->correctParams(0); + if (_sentence) _sentence->finish(); + if (_state == STATE_TALKING) { + _state = _nextState; + _nextState = STATE_READY; + stack->pushBool(true); + } else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ForceTalkAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ForceTalkAnim") == 0) { + stack->correctParams(1); + const char *animName = stack->pop()->getString(); + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = new char[strlen(animName) + 1]; + strcpy(_forcedTalkAnimName, animName); + _forcedTalkAnimUsed = false; + stack->pushBool(true); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Talk / TalkAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { + stack->correctParams(5); + + const char *text = stack->pop()->getString(); + CScValue *soundVal = stack->pop(); + int duration = stack->pop()->getInt(); + CScValue *valStances = stack->pop(); + + const char *stances = valStances->isNULL() ? NULL : valStances->getString(); + + int align = 0; + CScValue *val = stack->pop(); + if (val->isNULL()) align = TAL_CENTER; + else align = val->getInt(); + + align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); + + const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); + + talk(text, sound, duration, stances, (TTextAlign)align); + if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StickToRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StickToRegion") == 0) { + stack->correctParams(1); + + CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; + bool regFound = false; + + int i; + CScValue *val = stack->pop(); + if (val->isNULL() || !main) { + _stickRegion = NULL; + regFound = true; + } else if (val->isString()) { + const char *regionName = val->getString(); + for (i = 0; i < main->_nodes.getSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; + break; + } + } + } else if (val->isNative()) { + CBScriptable *obj = val->getNative(); + + for (i = 0; i < main->_nodes.getSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; + break; + } + } + + } + + if (!regFound) _stickRegion = NULL; + stack->pushBool(regFound); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isNULL()) SetFont(NULL); + else SetFont(val->getString()); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFont") == 0) { + stack->correctParams(0); + if (_font && _font->_filename) stack->pushString(_font->_filename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TakeItem") == 0) { + stack->correctParams(2); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + const char *itemName = val->getString(); + val = stack->pop(); + const char *insertAfter = val->isNULL() ? NULL : val->getString(); + if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); + else { + // hide associated entities + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); + } + + } else script->runtimeError("TakeItem: item name expected"); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DropItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); + else { + // show associated entities + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); + } + } else script->runtimeError("DropItem: item name expected"); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (val->_type == VAL_STRING) { + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); + if (item) stack->pushNative(item, true); + else stack->pushNULL(); + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) + stack->pushNULL(); + else + stack->pushNative(_inventory->_takenItems[val->getInt()], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { + if (val->getNative() == _inventory->_takenItems[i]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { + stack->pushBool(true); + return STATUS_OK; + } + } + } else script->runtimeError("HasItem: item name expected"); + + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateParticleEmitter") == 0) { + stack->correctParams(3); + bool followParent = stack->pop()->getBool(); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); + + CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); + if (emitter) stack->pushNative(_partEmitter, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteParticleEmitter") == 0) { + stack->correctParams(0); + if (_partEmitter) { + _gameRef->unregisterObject(_partEmitter); + _partEmitter = NULL; + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddAttachment") == 0) { + stack->correctParams(4); + const char *filename = stack->pop()->getString(); + bool preDisplay = stack->pop()->getBool(true); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); + + bool res; + CAdEntity *ent = new CAdEntity(_gameRef); + if (DID_FAIL(res = ent->loadFile(filename))) { + delete ent; + ent = NULL; + script->runtimeError("AddAttachment() failed loading entity '%s'", filename); + stack->pushBool(false); + } else { + _gameRef->registerObject(ent); + + ent->_posX = offsetX; + ent->_posY = offsetY; + ent->_active = true; + + if (preDisplay) _attachmentsPre.add(ent); + else _attachmentsPost.add(ent); + + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveAttachment") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool found = false; + if (val->isNative()) { + CBScriptable *obj = val->getNative(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPre[i]); + _attachmentsPre.removeAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPost[i]); + _attachmentsPost.removeAt(i); + i--; + } + } + } else { + const char *attachmentName = val->getString(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + found = true; + _gameRef->unregisterObject(_attachmentsPre[i]); + _attachmentsPre.removeAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + found = true; + _gameRef->unregisterObject(_attachmentsPost[i]); + _attachmentsPost.removeAt(i); + i--; + } + } + } + stack->pushBool(found); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAttachment") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + int currIndex = 0; + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (currIndex == index) ret = _attachmentsPre[i]; + currIndex++; + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (currIndex == index) ret = _attachmentsPost[i]; + currIndex++; + } + } else { + const char *attachmentName = val->getString(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + ret = _attachmentsPre[i]; + break; + } + } + if (!ret) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + ret = _attachmentsPre[i]; + break; + } + } + } + } + + if (ret != NULL) stack->pushNative(ret, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IgnoreItems") == 0) { + _scValue->setBool(_ignoreItems); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SceneIndependent") == 0) { + _scValue->setBool(_sceneIndependent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesWidth") == 0) { + _scValue->setInt(_subtitlesWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosRelative") == 0) { + _scValue->setBool(_subtitlesModRelative); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosX") == 0) { + _scValue->setInt(_subtitlesModX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosY") == 0) { + _scValue->setInt(_subtitlesModY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { + _scValue->setBool(_subtitlesModXCenter); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumItems (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumItems") == 0) { + _scValue->setInt(getInventory()->_takenItems.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParticleEmitter (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParticleEmitter") == 0) { + if (_partEmitter) _scValue->setNative(_partEmitter, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumAttachments (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumAttachments") == 0) { + _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); + return _scValue; + } + + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IgnoreItems") == 0) { + _ignoreItems = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SceneIndependent") == 0) { + _sceneIndependent = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesWidth") == 0) { + _subtitlesWidth = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosRelative") == 0) { + _subtitlesModRelative = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosX") == 0) { + _subtitlesModX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosY") == 0) { + _subtitlesModY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { + _subtitlesModXCenter = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdObject::scToString() { + return "[ad object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::SetFont(const char *filename) { + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (filename) { + _font = _gameRef->_fontStorage->addFont(filename); + return _font == NULL ? STATUS_FAILED : STATUS_OK; + } else { + _font = NULL; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CAdObject::getHeight() { + if (!_currentSprite) return 0; + else { + CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; + int ret = 0; + for (int i = 0; i < frame->_subframes.getSize(); i++) { + ret = MAX(ret, frame->_subframes[i]->_hotspotY); + } + + if (_zoomable) { + float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); + ret = (int)(ret * zoom / 100); + } + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { + if (!_sentence) _sentence = new CAdSentence(_gameRef); + if (!_sentence) return; + + if (_forcedTalkAnimName && _forcedTalkAnimUsed) { + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + } + + delete(_sentence->_sound); + _sentence->_sound = NULL; + + _sentence->setText(text); + _gameRef->_stringTable->expand(&_sentence->_text); + _sentence->setStances(stances); + _sentence->_duration = duration; + _sentence->_align = Align; + _sentence->_startTime = _gameRef->_timer; + _sentence->_currentStance = -1; + _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; + _sentence->_freezable = _freezable; + + // try to locate speech file automatically + bool deleteSound = false; + if (!sound) { + char *key = _gameRef->_stringTable->getKey(text); + if (key) { + sound = ((CAdGame *)_gameRef)->findSpeechFile(key); + delete [] key; + + if (sound) deleteSound = true; + } + } + + // load sound and set duration appropriately + if (sound) { + CBSound *snd = new CBSound(_gameRef); + if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { + _sentence->setSound(snd); + if (_sentence->_duration <= 0) { + uint32 Length = snd->getLength(); + if (Length != 0) _sentence->_duration = Length; + } + } else delete snd; + } + + // set duration by text length + if (_sentence->_duration <= 0) {// TODO: Avoid longs. + _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); + } + + + int x, y, width, height; + + x = _posX; + y = _posY; + + if (!_sceneIndependent && _subtitlesModRelative) { + x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + + if (_subtitlesWidth > 0) width = _subtitlesWidth; + else { + if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { + width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); + } else width = _gameRef->_renderer->_width / 2; + } + + height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); + + y = y - height - getHeight() - 5; + if (_subtitlesModRelative) { + x += _subtitlesModX; + y += _subtitlesModY; + } else { + x = _subtitlesModX; + y = _subtitlesModY; + } + if (_subtitlesModXCenter) + x = x - width / 2; + + + x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); + y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); + + _sentence->_width = width; + + + _sentence->_pos.x = x; + _sentence->_pos.y = y; + + + if (_subtitlesModRelative) { + _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + _sentence->_fixedPos = !_subtitlesModRelative; + + + _sentence->setupTalkFile(sound); + + _state = STATE_TALKING; + + if (deleteSound) delete [] sound; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::reset() { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + delete _animSprite; + _animSprite = NULL; + } else if (_state == STATE_TALKING && _sentence) { + _sentence->finish(); + } + + _state = _nextState = STATE_READY; + + _gameRef->_scEngine->resetObject(this); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blockRegion)); + persistMgr->transfer(TMEMBER(_currentBlockRegion)); + persistMgr->transfer(TMEMBER(_currentWptGroup)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_drawn)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_ignoreItems)); + persistMgr->transfer(TMEMBER_INT(_nextState)); + persistMgr->transfer(TMEMBER(_sentence)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_animSprite)); + persistMgr->transfer(TMEMBER(_sceneIndependent)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); + persistMgr->transfer(TMEMBER(_tempSprite2)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_wptGroup)); + persistMgr->transfer(TMEMBER(_stickRegion)); + persistMgr->transfer(TMEMBER(_subtitlesModRelative)); + persistMgr->transfer(TMEMBER(_subtitlesModX)); + persistMgr->transfer(TMEMBER(_subtitlesModY)); + persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); + persistMgr->transfer(TMEMBER(_subtitlesWidth)); + persistMgr->transfer(TMEMBER(_inventory)); + persistMgr->transfer(TMEMBER(_partEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); + + _attachmentsPre.persist(persistMgr); + _attachmentsPost.persist(persistMgr); + persistMgr->transfer(TMEMBER(_registerAlias)); + + persistMgr->transfer(TMEMBER(_partFollowParent)); + persistMgr->transfer(TMEMBER(_partOffsetX)); + persistMgr->transfer(TMEMBER(_partOffsetY)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateSounds() { + if (_sentence && _sentence->_sound) + updateOneSound(_sentence->_sound); + + return CBObject::updateSounds(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::resetSoundPan() { + if (_sentence && _sentence->_sound) { + _sentence->_sound->setPan(0.0f); + } + return CBObject::resetSoundPan(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; + + else return CBObject::getExtendedFlag(flagName); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { + if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); + + CBBase::saveAsText(buffer, indent + 2); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateBlockRegion() { + CAdGame *adGame = (CAdGame *)_gameRef; + if (adGame->_scene) { + if (_blockRegion && _currentBlockRegion) + _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + + if (_wptGroup && _currentWptGroup) + _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdInventory *CAdObject::getInventory() { + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + return _inventory; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::afterMove() { + CAdRegion *newRegions[MAX_NUM_REGIONS]; + + ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (!newRegions[i]) break; + bool regFound = false; + for (int j = 0; j < MAX_NUM_REGIONS; j++) { + if (_currentRegions[j] == newRegions[i]) { + _currentRegions[j] = NULL; + regFound = true; + break; + } + } + if (!regFound) newRegions[i]->applyEvent("ActorEntry"); + } + + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) { + _currentRegions[i]->applyEvent("ActorLeave"); + } + _currentRegions[i] = newRegions[i]; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::invalidateCurrRegions() { + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::getScale(float *scaleX, float *scaleY) { + if (_zoomable) { + if (_scaleX >= 0 || _scaleY >= 0) { + *scaleX = _scaleX < 0 ? 100 : _scaleX; + *scaleY = _scaleY < 0 ? 100 : _scaleY; + } else if (_scale >= 0) *scaleX = *scaleY = _scale; + else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + } else { + *scaleX = *scaleY = 100; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateSpriteAttachments() { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + _attachmentsPre[i]->update(); + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + _attachmentsPost[i]->update(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::displaySpriteAttachments(bool preDisplay) { + if (preDisplay) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + displaySpriteAttachment(_attachmentsPre[i]); + } + } else { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + displaySpriteAttachment(_attachmentsPost[i]); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { + if (!attachment->_active) return STATUS_OK; + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + int origX = attachment->_posX; + int origY = attachment->_posY; + + // inherit position from owner + attachment->_posX = (int)(this->_posX + attachment->_posX * scaleX / 100.0f); + attachment->_posY = (int)(this->_posY + attachment->_posY * scaleY / 100.0f); + + // inherit other props + attachment->_alphaColor = this->_alphaColor; + attachment->_blendMode = this->_blendMode; + + attachment->_scale = this->_scale; + attachment->_relativeScale = this->_relativeScale; + attachment->_scaleX = this->_scaleX; + attachment->_scaleY = this->_scaleY; + + attachment->_rotate = this->_rotate; + attachment->_relativeRotate = this->_relativeRotate; + attachment->_rotateValid = this->_rotateValid; + + attachment->_registerAlias = this; + attachment->_registrable = this->_registrable; + + bool ret = attachment->display(); + + attachment->_posX = origX; + attachment->_posY = origY; + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { + _partFollowParent = followParent; + _partOffsetX = offsetX; + _partOffsetY = offsetY; + + if (!_partEmitter) { + _partEmitter = new CPartEmitter(_gameRef, this); + if (_partEmitter) { + _gameRef->registerObject(_partEmitter); + } + } + updatePartEmitter(); + return _partEmitter; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updatePartEmitter() { + if (!_partEmitter) return STATUS_FAILED; + + if (_partFollowParent) { + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + _partEmitter->_posX = (int)(_posX + (scaleX / 100.0f) * _partOffsetX); + _partEmitter->_posY = (int)(_posY + (scaleY / 100.0f) * _partOffsetY); + } + return _partEmitter->update(); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdObject.h b/engines/wintermute/ad/AdObject.h new file mode 100644 index 0000000000..d662e84729 --- /dev/null +++ b/engines/wintermute/ad/AdObject.h @@ -0,0 +1,123 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADOBJECT_H +#define WINTERMUTE_ADOBJECT_H + +#include "engines/wintermute/ad/AdTypes.h" +#include "engines/wintermute/base/particles/PartEmitter.h" + +namespace WinterMute { + +class CAdWaypointGroup; +class CAdRegion; +class CAdSentence; +class CBFont; +class CBRegion; +class CAdInventory; + +#define MAX_NUM_REGIONS 10 + +class CAdObject : public CBObject { +public: + CPartEmitter *_partEmitter; + virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); + virtual bool updatePartEmitter(); + bool _partFollowParent; + int _partOffsetX; + int _partOffsetY; + + bool invalidateCurrRegions(); + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int _subtitlesModX; + int _subtitlesModY; + int _subtitlesWidth; + CAdRegion *_stickRegion; + bool _sceneIndependent; + bool _ignoreItems; + bool updateBlockRegion(); + bool _forcedTalkAnimUsed; + char *_forcedTalkAnimName; + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool reset(); + DECLARE_PERSISTENT(CAdObject, CBObject) + virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); + virtual int getHeight(); + CAdSentence *_sentence; + bool SetFont(const char *filename); + virtual bool update(); + virtual bool display(); + bool _drawn; + bool _active; + virtual bool playAnim(const char *filename); + CBSprite *_animSprite; + CBSprite *_currentSprite; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; + CAdObject(CBGame *inGame); + virtual ~CAdObject(); + CBFont *_font; + CBSprite *_tempSprite2; + CBRegion *_blockRegion; + CAdWaypointGroup *_wptGroup; + CBRegion *_currentBlockRegion; + CAdWaypointGroup *_currentWptGroup; + CAdInventory *getInventory(); + + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + virtual bool afterMove(); + CAdRegion *_currentRegions[MAX_NUM_REGIONS]; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + CBArray _attachmentsPre; + CBArray _attachmentsPost; + + bool updateSpriteAttachments(); + bool displaySpriteAttachments(bool preDisplay); + CAdObject *_registerAlias; +private: + bool displaySpriteAttachment(CAdObject *attachment); + CAdInventory *_inventory; + +protected: + bool getScale(float *scaleX, float *scaleY); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdPath.cpp b/engines/wintermute/ad/AdPath.cpp new file mode 100644 index 0000000000..d1b9d87063 --- /dev/null +++ b/engines/wintermute/ad/AdPath.cpp @@ -0,0 +1,112 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdPath.h" +#include "engines/wintermute/base/BPoint.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPath, false) + +////////////////////////////////////////////////////////////////////////// +CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPath::~CAdPath() { + reset(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::reset() { + for (int i = 0; i < _points.getSize(); i++) + delete _points[i]; + + _points.removeAll(); + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getFirst() { + if (_points.getSize() > 0) { + _currIndex = 0; + return _points[_currIndex]; + } else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getNext() { + _currIndex++; + if (_currIndex < _points.getSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getCurrent() { + if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::addPoint(CBPoint *point) { + _points.add(point); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::setReady(bool ready) { + bool orig = _ready; + _ready = ready; + + return orig; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_currIndex)); + _points.persist(persistMgr); + persistMgr->transfer(TMEMBER(_ready)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdPath.h b/engines/wintermute/ad/AdPath.h new file mode 100644 index 0000000000..fdc2980042 --- /dev/null +++ b/engines/wintermute/ad/AdPath.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATH_H +#define WINTERMUTE_ADPATH_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CBPoint; +class CAdPath : public CBBase { +public: + DECLARE_PERSISTENT(CAdPath, CBBase) + CBPoint *getCurrent(); + bool setReady(bool ready = true); + void addPoint(CBPoint *point); + CBPoint *getNext(); + CBPoint *getFirst(); + void reset(); + CAdPath(CBGame *inGame); + virtual ~CAdPath(); + CBArray _points; + int _currIndex; + bool _ready; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdPathPoint.cpp b/engines/wintermute/ad/AdPathPoint.cpp new file mode 100644 index 0000000000..184ad8559a --- /dev/null +++ b/engines/wintermute/ad/AdPathPoint.cpp @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/AdPathPoint.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPathPoint, false) + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint() { + x = y = 0; + _distance = 0; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { + x = initX; + y = initY; + _distance = initDistance; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::~CAdPathPoint() { + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { + + CBPoint::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_distance)); + persistMgr->transfer(TMEMBER(_marked)); + persistMgr->transfer(TMEMBER(_origin)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdPathPoint.h b/engines/wintermute/ad/AdPathPoint.h new file mode 100644 index 0000000000..f58df765b1 --- /dev/null +++ b/engines/wintermute/ad/AdPathPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATHPOINT_H +#define WINTERMUTE_ADPATHPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BPoint.h" + +namespace WinterMute { + +class CAdPathPoint : public CBPoint { +public: + DECLARE_PERSISTENT(CAdPathPoint, CBPoint) + CAdPathPoint(int initX, int initY, int initDistance); + CAdPathPoint(); + virtual ~CAdPathPoint(); + CAdPathPoint *_origin; + bool _marked; + int _distance; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdRegion.cpp b/engines/wintermute/ad/AdRegion.cpp new file mode 100644 index 0000000000..a1864de1ac --- /dev/null +++ b/engines/wintermute/ad/AdRegion.cpp @@ -0,0 +1,392 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdRegion.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRegion, false) + +////////////////////////////////////////////////////////////////////////// +CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { + _blocked = false; + _decoration = false; + _zoom = 0; + _alpha = 0xFFFFFFFF; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRegion::~CAdRegion() { +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(ZOOM) +TOKEN_DEF(SCALE) +TOKEN_DEF(BLOCKED) +TOKEN_DEF(DECORATION) +TOKEN_DEF(POINT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(ZOOM) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(BLOCKED) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(POINT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + int ar = 255, ag = 255, ab = 255, alpha = 255; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_BLOCKED: + parser.scanStr((char *)params, "%b", &_blocked); + break; + + case TOKEN_DECORATION: + parser.scanStr((char *)params, "%b", &_decoration); + break; + + case TOKEN_ZOOM: + case TOKEN_SCALE: { + int j; + parser.scanStr((char *)params, "%d", &j); + _zoom = (float)j; + } + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo")==0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + stack->pushNULL(); + + return STATUS_OK; + } + + else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("ad region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Blocked") == 0) { + _scValue->setBool(_blocked); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + _scValue->setFloat(_zoom); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alpha); + return _scValue; + } + + else return CBRegion::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Blocked") == 0) { + _blocked = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + _zoom = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + else return CBRegion::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdRegion::scToString() { + return "[ad region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "REGION {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + int i; + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::persist(CBPersistMgr *persistMgr) { + CBRegion::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_blocked)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_zoom)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdRegion.h b/engines/wintermute/ad/AdRegion.h new file mode 100644 index 0000000000..c91feb4012 --- /dev/null +++ b/engines/wintermute/ad/AdRegion.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADREGION_H +#define WINTERMUTE_ADREGION_H + +#include "engines/wintermute/base/BRegion.h" + +namespace WinterMute { + +class CAdRegion : public CBRegion { +public: + DECLARE_PERSISTENT(CAdRegion, CBRegion) + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; + CAdRegion(CBGame *inGame); + virtual ~CAdRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdResponse.cpp b/engines/wintermute/ad/AdResponse.cpp new file mode 100644 index 0000000000..20617f9573 --- /dev/null +++ b/engines/wintermute/ad/AdResponse.cpp @@ -0,0 +1,143 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdResponse.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/utils/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponse, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { + _text = NULL; + _textOrig = NULL; + _icon = _iconHover = _iconPressed = NULL; + _font = NULL; + _iD = 0; + _responseType = RESPONSE_ALWAYS; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponse::~CAdResponse() { + delete[] _text; + delete[] _textOrig; + delete _icon; + delete _iconHover; + delete _iconPressed; + _text = NULL; + _textOrig = NULL; + _icon = NULL; + _iconHover = NULL; + _iconPressed = NULL; + if (_font) _gameRef->_fontStorage->removeFont(_font); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponse::setText(const char *text) { + CBUtils::setString(&_text, text); + CBUtils::setString(&_textOrig, text); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIcon(const char *filename) { + delete _icon; + _icon = new CBSprite(_gameRef); + if (!_icon || DID_FAIL(_icon->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); + delete _icon; + _icon = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setFont(const char *filename) { + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont(filename); + if (!_font) { + _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIconHover(const char *filename) { + delete _iconHover; + _iconHover = new CBSprite(_gameRef); + if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); + delete _iconHover; + _iconHover = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIconPressed(const char *filename) { + delete _iconPressed; + _iconPressed = new CBSprite(_gameRef); + if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); + delete _iconPressed; + _iconPressed = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_icon)); + persistMgr->transfer(TMEMBER(_iconHover)); + persistMgr->transfer(TMEMBER(_iconPressed)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_textOrig)); + persistMgr->transfer(TMEMBER_INT(_responseType)); + persistMgr->transfer(TMEMBER(_font)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponse.h b/engines/wintermute/ad/AdResponse.h new file mode 100644 index 0000000000..646d781b89 --- /dev/null +++ b/engines/wintermute/ad/AdResponse.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSE_H +#define WINTERMUTE_ADRESPONSE_H + + +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/ad/AdTypes.h" + +namespace WinterMute { +class CBFont; +class CAdResponse : public CBObject { +public: + DECLARE_PERSISTENT(CAdResponse, CBObject) + bool setIcon(const char *filename); + bool setFont(const char *filename); + bool setIconHover(const char *filename); + bool setIconPressed(const char *filename); + void setText(const char *text); + int _iD; + CBSprite *_icon; + CBSprite *_iconHover; + CBSprite *_iconPressed; + CBFont *_font; + char *_text; + char *_textOrig; + CAdResponse(CBGame *inGame); + virtual ~CAdResponse(); + TResponseType _responseType; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdResponseBox.cpp b/engines/wintermute/ad/AdResponseBox.cpp new file mode 100644 index 0000000000..1a1732edd0 --- /dev/null +++ b/engines/wintermute/ad/AdResponseBox.cpp @@ -0,0 +1,647 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdResponseBox.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/ui/UIButton.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/ad/AdResponse.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { + _font = _fontHover = NULL; + + _window = NULL; + _shieldWindow = new CUIWindow(_gameRef); + + _horizontal = false; + CBPlatform::setRectEmpty(&_responseArea); + _scrollOffset = 0; + _spacing = 0; + + _waitingScript = NULL; + _lastResponseText = NULL; + _lastResponseTextOrig = NULL; + + _verticalAlign = VAL_BOTTOM; + _align = TAL_LEFT; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::~CAdResponseBox() { + + delete _window; + _window = NULL; + delete _shieldWindow; + _shieldWindow = NULL; + delete[] _lastResponseText; + _lastResponseText = NULL; + delete[] _lastResponseTextOrig; + _lastResponseTextOrig = NULL; + + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + + clearResponses(); + clearButtons(); + + _waitingScript = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::clearResponses() { + for (int i = 0; i < _responses.getSize(); i++) { + delete _responses[i]; + } + _responses.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::clearButtons() { + for (int i = 0; i < _respButtons.getSize(); i++) { + delete _respButtons[i]; + } + _respButtons.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::invalidateButtons() { + for (int i = 0; i < _respButtons.getSize(); i++) { + _respButtons[i]->_image = NULL; + _respButtons[i]->_cursor = NULL; + _respButtons[i]->_font = NULL; + _respButtons[i]->_fontHover = NULL; + _respButtons[i]->_fontPress = NULL; + _respButtons[i]->setText(""); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::createButtons() { + clearButtons(); + + _scrollOffset = 0; + for (int i = 0; i < _responses.getSize(); i++) { + CUIButton *btn = new CUIButton(_gameRef); + if (btn) { + btn->_parent = _window; + btn->_sharedFonts = btn->_sharedImages = true; + btn->_sharedCursors = true; + // iconic + if (_responses[i]->_icon) { + btn->_image = _responses[i]->_icon; + if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; + if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; + + btn->setCaption(_responses[i]->_text); + if (_cursor) btn->_cursor = _cursor; + else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; + } + // textual + else { + btn->setText(_responses[i]->_text); + btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; + btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; + btn->_fontPress = btn->_fontHover; + btn->_align = _align; + + if (_gameRef->_touchInterface) + btn->_fontHover = btn->_font; + + + if (_responses[i]->_font) btn->_font = _responses[i]->_font; + + btn->_width = _responseArea.right - _responseArea.left; + if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; + } + btn->setName("response"); + btn->correctSize(); + + // make the responses touchable + if (_gameRef->_touchInterface) + btn->_height = MAX(btn->_height, 50); + + //btn->SetListener(this, btn, _responses[i]->_iD); + btn->setListener(this, btn, i); + btn->_visible = false; + _respButtons.add(btn); + + if (_responseArea.bottom - _responseArea.top < btn->_height) { + _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); + _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); + } + } + } + _ready = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT) +TOKEN_DEF(AREA) +TOKEN_DEF(HORIZONTAL) +TOKEN_DEF(SPACING) +TOKEN_DEF(WINDOW) +TOKEN_DEF(CURSOR) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT) + TOKEN_TABLE(AREA) + TOKEN_TABLE(HORIZONTAL) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(_gameRef); + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else if (_shieldWindow) _shieldWindow->_parent = _window; + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AREA: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); + break; + + case TOKEN_HORIZONTAL: + parser.scanStr((char *)params, "%b", &_horizontal); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_LEFT; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; + else _verticalAlign = VAL_BOTTOM; + break; + + case TOKEN_SPACING: + parser.scanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition"); + return STATUS_FAILED; + } + + if (_window) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "RESPONSE_BOX\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); + + switch (_align) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CAdResponseBox::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + } + + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); + + buffer->putTextIndent(indent + 2, "\n"); + + // window + if (_window) _window->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::display() { + Rect32 rect = _responseArea; + if (_window) { + CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); + //_window->display(); + } + + int xxx, yyy, i; + + xxx = rect.left; + yyy = rect.top; + + // shift down if needed + if (!_horizontal) { + int total_height = 0; + for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + total_height -= _spacing; + + switch (_verticalAlign) { + case VAL_BOTTOM: + if (yyy + total_height < rect.bottom) + yyy = rect.bottom - total_height; + break; + + case VAL_CENTER: + if (yyy + total_height < rect.bottom) + yyy += ((rect.bottom - rect.top) - total_height) / 2; + break; + + case VAL_TOP: + // do nothing + break; + } + } + + // prepare response buttons + bool scrollNeeded = false; + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) + || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { + + scrollNeeded = true; + _respButtons[i]->_visible = false; + break; + } + + _respButtons[i]->_visible = true; + _respButtons[i]->_posX = xxx; + _respButtons[i]->_posY = yyy; + + if (_horizontal) { + xxx += (_respButtons[i]->_width + _spacing); + } else { + yyy += (_respButtons[i]->_height + _spacing); + } + } + + // show appropriate scroll buttons + if (_window) { + _window->showWidget("prev", _scrollOffset > 0); + _window->showWidget("next", scrollNeeded); + } + + // go exclusive + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + + _shieldWindow->display(); + } + + // display window + if (_window) _window->display(); + + + // display response buttons + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + _respButtons[i]->display(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset--; + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset++; + } else if (scumm_stricmp(obj->_name, "response") == 0) { + if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); + handleResponse(_responses[param2]); + _waitingScript = NULL; + _gameRef->_state = GAME_RUNNING; + ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; + _ready = true; + invalidateButtons(); + clearResponses(); + } else return CBObject::listen(param1, param2); + break; + default: + error("AdResponseBox::Listen - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_horizontal)); + persistMgr->transfer(TMEMBER(_lastResponseText)); + persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); + _respButtons.persist(persistMgr); + persistMgr->transfer(TMEMBER(_responseArea)); + _responses.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_waitingScript)); + persistMgr->transfer(TMEMBER(_window)); + + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + persistMgr->transfer(TMEMBER_INT(_align)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::weedResponses() { + CAdGame *adGame = (CAdGame *)_gameRef; + + for (int i = 0; i < _responses.getSize(); i++) { + switch (_responses[i]->_responseType) { + case RESPONSE_ONCE: + if (adGame->branchResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.removeAt(i); + i--; + } + break; + + case RESPONSE_ONCE_GAME: + if (adGame->gameResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.removeAt(i); + i--; + } + break; + default: + warning("CAdResponseBox::WeedResponses - Unhandled enum"); + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { + CBUtils::setString(&_lastResponseText, text); + CBUtils::setString(&_lastResponseTextOrig, textOrig); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::handleResponse(CAdResponse *response) { + setLastResponseText(response->_text, response->_textOrig); + + CAdGame *adGame = (CAdGame *)_gameRef; + + switch (response->_responseType) { + case RESPONSE_ONCE: + adGame->addBranchResponse(response->_iD); + break; + + case RESPONSE_ONCE_GAME: + adGame->addGameResponse(response->_iD); + break; + default: + warning("CAdResponseBox::HandleResponse - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = 0; i < objects.getSize(); i++) { + if (objects[i] == currObject) { + if (i < objects.getSize() - 1) return objects[i + 1]; + else break; + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = objects.getSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; + else break; + } + } + } + return objects[objects.getSize() - 1]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _respButtons.getSize(); i++) { + objects.add(_respButtons[i]); + } + if (_window) _window->getWindowObjects(objects, interactiveOnly); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponseBox.h b/engines/wintermute/ad/AdResponseBox.h new file mode 100644 index 0000000000..93b677bd4a --- /dev/null +++ b/engines/wintermute/ad/AdResponseBox.h @@ -0,0 +1,87 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSEBOX_H +#define WINTERMUTE_ADRESPONSEBOX_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CUIButton; +class CUIWindow; +class CUIObject; +class CAdResponse; +class CAdResponseBox : public CBObject { +public: + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + bool getObjects(CBArray &objects, bool interactiveOnly); + + bool handleResponse(CAdResponse *response); + void setLastResponseText(const char *text, const char *textOrig); + char *_lastResponseText; + char *_lastResponseTextOrig; + DECLARE_PERSISTENT(CAdResponseBox, CBObject) + CScScript *_waitingScript; + virtual bool listen(CBScriptHolder *param1, uint32 param2); + typedef enum { + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE + } TResponseEvent; + + bool weedResponses(); + bool display(); + int _spacing; + int _scrollOffset; + CBFont *_fontHover; + CBFont *_font; + bool createButtons(); + bool invalidateButtons(); + void clearButtons(); + void clearResponses(); + CAdResponseBox(CBGame *inGame); + virtual ~CAdResponseBox(); + CBArray _responses; + CBArray _respButtons; + CUIWindow *_window; + CUIWindow *_shieldWindow; + bool _horizontal; + Rect32 _responseArea; + int _verticalAlign; + TTextAlign _align; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdResponseContext.cpp b/engines/wintermute/ad/AdResponseContext.cpp new file mode 100644 index 0000000000..8573e58b95 --- /dev/null +++ b/engines/wintermute/ad/AdResponseContext.cpp @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdResponseContext.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseContext, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { + _iD = 0; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::~CAdResponseContext() { + delete[] _context; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_context)); + persistMgr->transfer(TMEMBER(_iD)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdResponseContext::setContext(const char *context) { + delete[] _context; + _context = NULL; + if (context) { + _context = new char [strlen(context) + 1]; + if (_context) strcpy(_context, context); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponseContext.h b/engines/wintermute/ad/AdResponseContext.h new file mode 100644 index 0000000000..74506405de --- /dev/null +++ b/engines/wintermute/ad/AdResponseContext.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSECONTEXT_H +#define WINTERMUTE_ADRESPONSECONTEXT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CAdResponseContext : public CBBase { +public: + void setContext(const char *context); + int _iD; + char *_context; + DECLARE_PERSISTENT(CAdResponseContext, CBBase) + CAdResponseContext(CBGame *inGame); + virtual ~CAdResponseContext(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdRotLevel.cpp b/engines/wintermute/ad/AdRotLevel.cpp new file mode 100644 index 0000000000..671d003f35 --- /dev/null +++ b/engines/wintermute/ad/AdRotLevel.cpp @@ -0,0 +1,159 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdRotLevel.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRotLevel, false) + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { + _posX = 0; + _rotation = 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::~CAdRotLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(X) +TOKEN_DEF(ROTATION) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(X) + TOKEN_TABLE(ROTATION) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_ROTATION: { + int i; + parser.scanStr((char *)params, "%d", &i); + _rotation = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_rotation)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdRotLevel.h b/engines/wintermute/ad/AdRotLevel.h new file mode 100644 index 0000000000..9e536a8d8f --- /dev/null +++ b/engines/wintermute/ad/AdRotLevel.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADROTLEVEL_H +#define WINTERMUTE_ADROTLEVEL_H + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CAdRotLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdRotLevel, CBObject) + CAdRotLevel(CBGame *inGame); + virtual ~CAdRotLevel(); + float _rotation; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdScaleLevel.cpp b/engines/wintermute/ad/AdScaleLevel.cpp new file mode 100644 index 0000000000..1ac2f7ba6c --- /dev/null +++ b/engines/wintermute/ad/AdScaleLevel.cpp @@ -0,0 +1,157 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdScaleLevel.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScaleLevel, false) + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { + _posY = 0; + _scale = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::~CAdScaleLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(Y) +TOKEN_DEF(SCALE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(Y) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SCALE: { + int i; + parser.scanStr((char *)params, "%d", &i); + _scale = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scale)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdScaleLevel.h b/engines/wintermute/ad/AdScaleLevel.h new file mode 100644 index 0000000000..c360ec4eff --- /dev/null +++ b/engines/wintermute/ad/AdScaleLevel.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCALELEVEL_H +#define WINTERMUTE_ADSCALELEVEL_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CAdScaleLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdScaleLevel, CBObject) + float _scale; + CAdScaleLevel(CBGame *inGame); + virtual ~CAdScaleLevel(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdScene.cpp b/engines/wintermute/ad/AdScene.cpp new file mode 100644 index 0000000000..022ec4a8a5 --- /dev/null +++ b/engines/wintermute/ad/AdScene.cpp @@ -0,0 +1,2752 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/ad/AdActor.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdLayer.h" +#include "engines/wintermute/ad/AdNodeState.h" +#include "engines/wintermute/ad/AdObject.h" +#include "engines/wintermute/ad/AdPath.h" +#include "engines/wintermute/ad/AdPathPoint.h" +#include "engines/wintermute/ad/AdRotLevel.h" +#include "engines/wintermute/ad/AdScaleLevel.h" +#include "engines/wintermute/ad/AdSceneNode.h" +#include "engines/wintermute/ad/AdSceneState.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/utils/utils.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScene, false) + +////////////////////////////////////////////////////////////////////////// +CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { + _pfTarget = new CBPoint; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdScene::~CAdScene() { + cleanup(); + _gameRef->unregisterObject(_fader); + delete _pfTarget; + _pfTarget = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::setDefaults() { + _initialized = false; + _pfReady = true; + _pfTargetPath = NULL; + _pfRequester = NULL; + _mainLayer = NULL; + + _pfPointsNum = 0; + _persistentState = false; + _persistentStateSprites = true; + + _autoScroll = true; + _offsetLeft = _offsetTop = 0; + _targetOffsetLeft = _targetOffsetTop = 0; + + _lastTimeH = _lastTimeV = 0; + _scrollTimeH = _scrollTimeV = 10; + _scrollPixelsH = _scrollPixelsV = 1; + + _pfMaxTime = 15; + + _paralaxScrolling = true; + + // editor settings + _editorMarginH = _editorMarginV = 100; + + _editorColFrame = 0xE0888888; + _editorColEntity = 0xFF008000; + _editorColRegion = 0xFF0000FF; + _editorColBlocked = 0xFF800080; + _editorColWaypoints = 0xFF0000FF; + _editorColEntitySel = 0xFFFF0000; + _editorColRegionSel = 0xFFFF0000; + _editorColBlockedSel = 0xFFFF0000; + _editorColWaypointsSel = 0xFFFF0000; + _editorColScale = 0xFF00FF00; + _editorColDecor = 0xFF00FFFF; + _editorColDecorSel = 0xFFFF0000; + + _editorShowRegions = true; + _editorShowBlocked = true; + _editorShowDecor = true; + _editorShowEntities = true; + _editorShowScale = true; + + _shieldWindow = NULL; + + _fader = new CBFader(_gameRef); + _gameRef->registerObject(_fader); + + _viewport = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::cleanup() { + CBObject::cleanup(); + + _mainLayer = NULL; // reference only + + int i; + + delete _shieldWindow; + _shieldWindow = NULL; + + _gameRef->unregisterObject(_fader); + _fader = NULL; + + for (i = 0; i < _layers.getSize(); i++) + _gameRef->unregisterObject(_layers[i]); + _layers.removeAll(); + + + for (i = 0; i < _waypointGroups.getSize(); i++) + _gameRef->unregisterObject(_waypointGroups[i]); + _waypointGroups.removeAll(); + + for (i = 0; i < _scaleLevels.getSize(); i++) + _gameRef->unregisterObject(_scaleLevels[i]); + _scaleLevels.removeAll(); + + for (i = 0; i < _rotLevels.getSize(); i++) + _gameRef->unregisterObject(_rotLevels[i]); + _rotLevels.removeAll(); + + + for (i = 0; i < _pfPath.getSize(); i++) + delete _pfPath[i]; + _pfPath.removeAll(); + _pfPointsNum = 0; + + for (i = 0; i < _objects.getSize(); i++) + _gameRef->unregisterObject(_objects[i]); + _objects.removeAll(); + + delete _viewport; + _viewport = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { + if (!_pfReady) return false; + else { + _pfReady = false; + *_pfTarget = target; + _pfTargetPath = path; + _pfRequester = requester; + + _pfTargetPath->reset(); + _pfTargetPath->setReady(false); + + // prepare working path + int i; + pfPointsStart(); + + // first point + //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); + + // if we're one pixel stuck, get unstuck + int startX = source.x; + int startY = source.y; + int bestDistance = 1000; + if (isBlockedAt(startX, startY, true, requester)) { + int tolerance = 2; + for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) { + for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) { + if (isWalkableAt(xxx, yyy, true, requester)) { + int distance = abs(xxx - source.x) + abs(yyy - source.y); + if (distance < bestDistance) { + startX = xxx; + startY = yyy; + + bestDistance = distance; + } + } + } + } + } + + pfPointsAdd(startX, startY, 0); + + //CorrectTargetPoint(&target.x, &target.y); + + // last point + //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); + pfPointsAdd(target.x, target.y, INT_MAX); + + // active waypoints + for (i = 0; i < _waypointGroups.getSize(); i++) { + if (_waypointGroups[i]->_active) { + pfAddWaypointGroup(_waypointGroups[i], requester); + } + } + + + // free waypoints + for (i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { + pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { + pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); + } + } + + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { + if (!wpt->_active) return; + + for (int i = 0; i < wpt->_points.getSize(); i++) { + if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; + + //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); + } +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getZoomAt(int x, int y) { + float ret = 100; + + bool found = false; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { + if (node->_region->_zoom != 0) { + ret = node->_region->_zoom; + found = true; + break; + } + } + } + } + if (!found) ret = getScaleAt(y); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { + if (!_gameRef->_debugDebugMode) colorCheck = false; + + uint32 ret; + if (colorCheck) ret = 0xFFFF0000; + else ret = 0xFFFFFFFF; + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { + if (!node->_region->_blocked) ret = node->_region->_alpha; + break; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { + bool ret = true; + + + if (checkFreeObjects) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + /* + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) + { + ret = true; + break; + } + */ + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { + if (node->_region->_blocked) { + ret = true; + break; + } else ret = false; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { + bool ret = false; + + if (checkFreeObjects) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { + if (node->_region->_blocked) { + ret = false; + break; + } else ret = true; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { + double xStep, yStep, x, y; + int xLength, yLength, xCount, yCount; + int x1, y1, x2, y2; + + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; + + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); + + if (xLength > yLength) { + if (x1 > x2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); + } + + yStep = (double)(y2 - y1) / (double)(x2 - x1); + y = y1; + + for (xCount = x1; xCount < x2; xCount++) { + if (isBlockedAt(xCount, (int)y, true, requester)) return -1; + y += yStep; + } + } else { + if (y1 > y2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); + } + + xStep = (double)(x2 - x1) / (double)(y2 - y1); + x = x1; + + for (yCount = y1; yCount < y2; yCount++) { + if (isBlockedAt((int)x, yCount, true, requester)) return -1; + x += xStep; + } + } + return MAX(xLength, yLength); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pathFinderStep() { + int i; + // get lowest unmarked + int lowestDist = INT_MAX; + CAdPathPoint *lowestPt = NULL; + + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { + lowestDist = _pfPath[i]->_distance; + lowestPt = _pfPath[i]; + } + + if (lowestPt == NULL) { // no path -> terminate PathFinder + _pfReady = true; + _pfTargetPath->setReady(true); + return; + } + + lowestPt->_marked = true; + + // target point marked, generate path and terminate + if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { + while (lowestPt != NULL) { + _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); + lowestPt = lowestPt->_origin; + } + + _pfReady = true; + _pfTargetPath->setReady(true); + return; + } + + // otherwise keep on searching + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked) { + int j = getPointsDist(*lowestPt, *_pfPath[i], _pfRequester); + if (j != -1 && lowestPt->_distance + j < _pfPath[i]->_distance) { + _pfPath[i]->_distance = lowestPt->_distance + j; + _pfPath[i]->_origin = lowestPt; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::initLoop() { +#ifdef _DEBUGxxxx + int nu_steps = 0; + uint32 start = _gameRef->_currentTime; + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { + PathFinderStep(); + nu_steps++; + } + if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); +#else + uint32 start = _gameRef->_currentTime; + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); +#endif + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + delete[] _filename; + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCENE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(LAYER) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(CAMERA) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(EDITOR_MARGIN_H) +TOKEN_DEF(EDITOR_MARGIN_V) +TOKEN_DEF(EDITOR_COLOR_FRAME) +TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION_SEL) +TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) +TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION) +TOKEN_DEF(EDITOR_COLOR_DECORATION) +TOKEN_DEF(EDITOR_COLOR_BLOCKED) +TOKEN_DEF(EDITOR_COLOR_ENTITY) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) +TOKEN_DEF(EDITOR_COLOR_SCALE) +TOKEN_DEF(EDITOR_SHOW_REGIONS) +TOKEN_DEF(EDITOR_SHOW_BLOCKED) +TOKEN_DEF(EDITOR_SHOW_DECORATION) +TOKEN_DEF(EDITOR_SHOW_ENTITIES) +TOKEN_DEF(EDITOR_SHOW_SCALE) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(VIEWPORT) +TOKEN_DEF(PERSISTENT_STATE_SPRITES) +TOKEN_DEF(PERSISTENT_STATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCENE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(CAMERA) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(EDITOR_MARGIN_H) + TOKEN_TABLE(EDITOR_MARGIN_V) + TOKEN_TABLE(EDITOR_COLOR_FRAME) + TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) + TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION) + TOKEN_TABLE(EDITOR_COLOR_DECORATION) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED) + TOKEN_TABLE(EDITOR_COLOR_ENTITY) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) + TOKEN_TABLE(EDITOR_COLOR_SCALE) + TOKEN_TABLE(EDITOR_SHOW_REGIONS) + TOKEN_TABLE(EDITOR_SHOW_DECORATION) + TOKEN_TABLE(EDITOR_SHOW_BLOCKED) + TOKEN_TABLE(EDITOR_SHOW_ENTITIES) + TOKEN_TABLE(EDITOR_SHOW_SCALE) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(VIEWPORT) + TOKEN_TABLE(PERSISTENT_STATE_SPRITES) + TOKEN_TABLE(PERSISTENT_STATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + cleanup(); + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + _gameRef->LOG(0, "'SCENE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int ar, ag, ab, aa; + char camera[MAX_PATH_LENGTH] = ""; + /* float WaypointHeight = -1.0f; */ + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_LAYER: { + CAdLayer *layer = new CAdLayer(_gameRef); + if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete layer; + layer = NULL; + } else { + _gameRef->registerObject(layer); + _layers.add(layer); + if (layer->_main) { + _mainLayer = layer; + _width = layer->_width; + _height = layer->_height; + } + } + } + break; + + case TOKEN_WAYPOINTS: { + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete wpt; + wpt = NULL; + } else { + _gameRef->registerObject(wpt); + _waypointGroups.add(wpt); + } + } + break; + + case TOKEN_SCALE_LEVEL: { + CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); + if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete sl; + sl = NULL; + } else { + _gameRef->registerObject(sl); + _scaleLevels.add(sl); + } + } + break; + + case TOKEN_ROTATION_LEVEL: { + CAdRotLevel *rl = new CAdRotLevel(_gameRef); + if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete rl; + rl = NULL; + } else { + _gameRef->registerObject(rl); + _rotLevels.add(rl); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + entity = NULL; + } else { + addObject(entity); + } + } + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CAMERA: + strcpy(camera, (char *)params); + break; + + case TOKEN_EDITOR_MARGIN_H: + parser.scanStr((char *)params, "%d", &_editorMarginH); + break; + + case TOKEN_EDITOR_MARGIN_V: + parser.scanStr((char *)params, "%d", &_editorMarginV); + break; + + case TOKEN_EDITOR_COLOR_FRAME: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColFrame = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntity = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegion = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecor = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_SCALE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColScale = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_SHOW_REGIONS: + parser.scanStr((char *)params, "%b", &_editorShowRegions); + break; + + case TOKEN_EDITOR_SHOW_BLOCKED: + parser.scanStr((char *)params, "%b", &_editorShowBlocked); + break; + + case TOKEN_EDITOR_SHOW_DECORATION: + parser.scanStr((char *)params, "%b", &_editorShowDecor); + break; + + case TOKEN_EDITOR_SHOW_ENTITIES: + parser.scanStr((char *)params, "%b", &_editorShowEntities); + break; + + case TOKEN_EDITOR_SHOW_SCALE: + parser.scanStr((char *)params, "%b", &_editorShowScale); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_VIEWPORT: { + Rect32 rc; + parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); + } + + case TOKEN_PERSISTENT_STATE: + parser.scanStr((char *)params, "%b", &_persistentState); + break; + + case TOKEN_PERSISTENT_STATE_SPRITES: + parser.scanStr((char *)params, "%b", &_persistentStateSprites); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SCENE definition"); + return STATUS_FAILED; + } + + if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); + + + sortScaleLevels(); + sortRotLevels(); + + _initialized = true; + + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::traverseNodes(bool doUpdate) { + if (!_initialized) return STATUS_OK; + + int j, k; + CAdGame *adGame = (CAdGame *)_gameRef; + + + ////////////////////////////////////////////////////////////////////////// + // prepare viewport + bool PopViewport = false; + if (_viewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(_viewport); + PopViewport = true; + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(adGame->_sceneViewport); + PopViewport = true; + } + + + ////////////////////////////////////////////////////////////////////////// + // *** adjust scroll offset + if (doUpdate) { + /* + if (_autoScroll && _gameRef->_mainObject != NULL) + { + ScrollToObject(_gameRef->_mainObject); + } + */ + + if (_autoScroll) { + // adjust horizontal scroll + if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { + _lastTimeH = _gameRef->_timer; + if (_offsetLeft < _targetOffsetLeft) { + _offsetLeft += _scrollPixelsH; + _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); + } else if (_offsetLeft > _targetOffsetLeft) { + _offsetLeft -= _scrollPixelsH; + _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); + } + } + + // adjust vertical scroll + if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { + _lastTimeV = _gameRef->_timer; + if (_offsetTop < _targetOffsetTop) { + _offsetTop += _scrollPixelsV; + _offsetTop = MIN(_offsetTop, _targetOffsetTop); + } else if (_offsetTop > _targetOffsetTop) { + _offsetTop -= _scrollPixelsV; + _offsetTop = MAX(_offsetTop, _targetOffsetTop); + } + } + + if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; + } else _ready = true; // not scrolling, i.e. always ready + } + + + + + ////////////////////////////////////////////////////////////////////////// + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + int viewportX, viewportY; + getViewportOffset(&viewportX, &viewportY); + + int scrollableX = _width - viewportWidth; + int scrollableY = _height - viewportHeight; + + double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); + double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); + + int origX, origY; + _gameRef->getOffset(&origX, &origY); + + + + ////////////////////////////////////////////////////////////////////////// + // *** display/update everything + _gameRef->_renderer->setup2D(); + + // for each layer + /* int MainOffsetX = 0; */ + /* int MainOffsetY = 0; */ + + for (j = 0; j < _layers.getSize(); j++) { + if (!_layers[j]->_active) continue; + + // make layer exclusive + if (!doUpdate) { + if (_layers[j]->_closeUp && !_gameRef->_editorMode) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + _shieldWindow->display(); + } + } + } + + if (_paralaxScrolling) { + int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); + int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); + _gameRef->setOffset(offsetX, offsetY); + + _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + + //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX); + } else { + _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); + + _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + } + + + // for each node + for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { + CAdSceneNode *node = _layers[j]->_nodes[k]; + switch (node->_type) { + case OBJECT_ENTITY: + if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { + _gameRef->_renderer->setup2D(); + + if (doUpdate) node->_entity->update(); + else node->_entity->display(); + } + break; + + case OBJECT_REGION: { + if (node->_region->_blocked) break; + if (node->_region->_decoration) break; + + if (!doUpdate) displayRegionContent(node->_region); + } + break; + default: + error("AdScene::TraverseNodes - Unhandled enum"); + break; + } // switch + } // each node + + // display/update all objects which are off-regions + if (_layers[j]->_main) { + if (doUpdate) { + updateFreeObjects(); + } else { + displayRegionContent(NULL); + } + } + } // each layer + + + // restore state + _gameRef->setOffset(origX, origY); + _gameRef->_renderer->setup2D(); + + // display/update fader + if (_fader) { + if (doUpdate) _fader->update(); + else _fader->display(); + } + + if (PopViewport) _gameRef->popViewport(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::display() { + return traverseNodes(false); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::updateFreeObjects() { + CAdGame *adGame = (CAdGame *)_gameRef; + bool is3DSet; + + // *** update all active objects + is3DSet = false; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (!adGame->_objects[i]->_active) continue; + + adGame->_objects[i]->update(); + adGame->_objects[i]->_drawn = false; + } + + + for (int i = 0; i < _objects.getSize(); i++) { + if (!_objects[i]->_active) continue; + + _objects[i]->update(); + _objects[i]->_drawn = false; + } + + + if (_autoScroll && _gameRef->_mainObject != NULL) { + scrollToObject(_gameRef->_mainObject); + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { + CAdGame *adGame = (CAdGame *)_gameRef; + CBArray objects; + CAdObject *obj; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.add(obj); + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.add(obj); + } + } + + // sort by _posY + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); + + // display them + for (int i = 0; i < objects.getSize(); i++) { + obj = objects[i]; + + if (display3DOnly && !obj->_is3D) continue; + + _gameRef->_renderer->setup2D(); + + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + obj->_drawn = true; + } + + + // display design only objects + if (!display3DOnly) { + if (_gameRef->_editorMode && region == NULL) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CAdScene::compareObjs(const void *obj1, const void *obj2) { + CAdObject *object1 = *(CAdObject **)obj1; + CAdObject *object2 = *(CAdObject **)obj2; + + if (object1->_posY < object2->_posY) return -1; + else if (object1->_posY > object2->_posY) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::displayRegionContentOld(CAdRegion *region) { + CAdGame *adGame = (CAdGame *)_gameRef; + CAdObject *obj; + + // display all objects in region sorted by _posY + do { + obj = NULL; + int minY = INT_MAX; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + obj = adGame->_objects[i]; + minY = adGame->_objects[i]->_posY; + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + obj = _objects[i]; + minY = _objects[i]->_posY; + } + } + + + if (obj != NULL) { + _gameRef->_renderer->setup2D(); + + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + obj->_drawn = true; + } + } while (obj != NULL); + + + // design only objects + if (_gameRef->_editorMode && region == NULL) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::update() { + return traverseNodes(true); +} + +////////////////////////////////////////////////////////////////////////// +void CAdScene::scrollTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + int origOffsetLeft = _targetOffsetLeft; + int origOffsetTop = _targetOffsetTop; + + _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); + _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); + + _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); + _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); + + + if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { + if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; + if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; + //_targetOffsetTop = 0; + } + + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::scrollToObject(CBObject *object) { + if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::skipToObject(CBObject *object) { + if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::skipTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetLeft = MAX(0, offsetX - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); + + _offsetTop = MAX(0, offsetY - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); + + _targetOffsetLeft = _offsetLeft; + _targetOffsetTop = _offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LoadActor") == 0) { + stack->correctParams(1); + CAdActor *act = new CAdActor(_gameRef); + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { + addObject(act); + stack->pushNative(act, true); + } else { + delete act; + act = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadEntity") == 0) { + stack->correctParams(1); + CAdEntity *ent = new CAdEntity(_gameRef); + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { + addObject(ent); + stack->pushNative(ent, true); + } else { + delete ent; + ent = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdEntity *ent = new CAdEntity(_gameRef); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CAdObject *obj = (CAdObject *)val->getNative(); + removeObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + if (val1->isNative()) { + skipToObject((CBObject *)val1->getNative()); + } else { + skipTo(val1->getInt(), val2->getInt()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollTo / ScrollToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + if (val1->isNative()) { + scrollToObject((CBObject *)val1->getNative()); + } else { + scrollTo(val1->getInt(), val2->getInt()); + } + if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int layer = val->getInt(); + if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); + else stack->pushNative(_layers[layer], true); + } else { + const char *LayerName = val->getString(); + bool LayerFound = false; + for (int i = 0; i < _layers.getSize(); i++) { + if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { + stack->pushNative(_layers[i], true); + LayerFound = true; + break; + } + } + if (!LayerFound) stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaypointGroup + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaypointGroup") == 0) { + stack->correctParams(1); + int group = stack->pop()->getInt(); + if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); + else stack->pushNative(_waypointGroups[group], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNode") == 0) { + stack->correctParams(1); + const char *nodeName = stack->pop()->getString(); + + CBObject *node = getNodeByName(nodeName); + if (node) stack->pushNative((CBScriptable *)node, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFreeNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFreeNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; + } else { + const char *nodeName = val->getString(); + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { + ret = _objects[i]; + break; + } + } + } + if (ret) stack->pushNative(ret, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRegionAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRegionAt") == 0) { + stack->correctParams(3); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + bool includeDecors = false; + if (!val->isNULL()) includeDecors = val->getBool(); + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { + if (node->_region->_decoration && !includeDecors) continue; + + stack->pushNative(node->_region, true); + return STATUS_OK; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsBlockedAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsBlockedAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushBool(isBlockedAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalkableAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsWalkableAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushBool(isWalkableAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetScaleAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetScaleAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushFloat(getZoomAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRotationAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRotationAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushFloat(getRotationAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScrolling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScrolling") == 0) { + stack->correctParams(0); + bool ret = false; + if (_autoScroll) { + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; + } + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); + if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); + if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsPointInViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsPointInViewport") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + stack->pushBool(pointInViewport(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetViewport") == 0) { + stack->correctParams(4); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); + + if (width <= 0) width = _gameRef->_renderer->_width; + if (height <= 0) height = _gameRef->_renderer->_height; + + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) _viewport->setRect(x, y, x + width, y + height); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdLayer *layer = new CAdLayer(_gameRef); + if (!val->isNULL()) layer->setName(val->getString()); + if (_mainLayer) { + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; + } + _layers.add(layer); + _gameRef->registerObject(layer); + + stack->pushNative(layer, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertLayer") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + CAdLayer *layer = new CAdLayer(_gameRef); + if (!val->isNULL()) layer->setName(val->getString()); + if (_mainLayer) { + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; + } + if (index < 0) index = 0; + if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); + else _layers.add(layer); + + _gameRef->registerObject(layer); + + stack->pushNative(layer, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdLayer *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); + for (int i = 0; i < _layers.getSize(); i++) { + if (_layers[i] == temp) { + toDelete = _layers[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < _layers.getSize()) { + toDelete = _layers[index]; + } + } + if (toDelete == NULL) { + stack->pushBool(false); + return STATUS_OK; + } + + if (toDelete->_main) { + script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); + stack->pushBool(false); + return STATUS_OK; + } + + for (int i = 0; i < _layers.getSize(); i++) { + if (_layers[i] == toDelete) { + _layers.removeAt(i); + _gameRef->unregisterObject(toDelete); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdScene::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("scene"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumLayers (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLayers") == 0) { + _scValue->setInt(_layers.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWaypointGroups (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumWaypointGroups") == 0) { + _scValue->setInt(_waypointGroups.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainLayer (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainLayer") == 0) { + if (_mainLayer) _scValue->setNative(_mainLayer, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFreeNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFreeNodes") == 0) { + _scValue->setInt(_objects.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + int viewportX; + getViewportOffset(&viewportX); + + _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + int viewportY; + getViewportOffset(NULL, &viewportY); + + _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoScroll") == 0) { + _scValue->setBool(_autoScroll); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentState") == 0) { + _scValue->setBool(_persistentState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentStateSprites") == 0) { + _scValue->setBool(_persistentStateSprites); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsX") == 0) { + _scValue->setInt(_scrollPixelsH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsY") == 0) { + _scValue->setInt(_scrollPixelsV); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedX") == 0) { + _scValue->setInt(_scrollTimeH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedY") == 0) { + _scValue->setInt(_scrollTimeV); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetX") == 0) { + _scValue->setInt(_offsetLeft); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetY") == 0) { + _scValue->setInt(_offsetTop); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + if (_mainLayer) _scValue->setInt(_mainLayer->_width); + else _scValue->setInt(0); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + if (_mainLayer) _scValue->setInt(_mainLayer->_height); + else _scValue->setInt(0); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoScroll") == 0) { + _autoScroll = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentState") == 0) { + _persistentState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentStateSprites") == 0) { + _persistentStateSprites = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsX") == 0) { + _scrollPixelsH = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsY") == 0) { + _scrollPixelsV = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedX") == 0) { + _scrollTimeH = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedY") == 0) { + _scrollTimeV = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetX") == 0) { + _offsetLeft = value->getInt(); + + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); + _targetOffsetLeft = _offsetLeft; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetY") == 0) { + _offsetTop = value->getInt(); + + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); + _targetOffsetTop = _offsetTop; + + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdScene::scToString() { + return "[scene object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::addObject(CAdObject *object) { + _objects.add(object); + return _gameRef->registerObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::removeObject(CAdObject *object) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] == object) { + _objects.removeAt(i); + return _gameRef->unregisterObject(object); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { + int i; + + buffer->putTextIndent(indent, "SCENE {\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + if (_persistentState) + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + + if (!_persistentStateSprites) + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // properties + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + // viewport + if (_viewport) { + Rect32 *rc = _viewport->getRect(); + buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + } + + + + // editor settings + buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColFrame), RGBCOLGetG(_editorColFrame), RGBCOLGetB(_editorColFrame), RGBCOLGetA(_editorColFrame)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntitySel), RGBCOLGetG(_editorColEntitySel), RGBCOLGetB(_editorColEntitySel), RGBCOLGetA(_editorColEntitySel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegionSel), RGBCOLGetG(_editorColRegionSel), RGBCOLGetB(_editorColRegionSel), RGBCOLGetA(_editorColRegionSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlockedSel), RGBCOLGetG(_editorColBlockedSel), RGBCOLGetB(_editorColBlockedSel), RGBCOLGetA(_editorColBlockedSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecorSel), RGBCOLGetG(_editorColDecorSel), RGBCOLGetB(_editorColDecorSel), RGBCOLGetA(_editorColDecorSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypointsSel), RGBCOLGetG(_editorColWaypointsSel), RGBCOLGetB(_editorColWaypointsSel), RGBCOLGetA(_editorColWaypointsSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntity), RGBCOLGetG(_editorColEntity), RGBCOLGetB(_editorColEntity), RGBCOLGetA(_editorColEntity)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegion), RGBCOLGetG(_editorColRegion), RGBCOLGetB(_editorColRegion), RGBCOLGetA(_editorColRegion)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecor), RGBCOLGetG(_editorColDecor), RGBCOLGetB(_editorColDecor), RGBCOLGetA(_editorColDecor)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlocked), RGBCOLGetG(_editorColBlocked), RGBCOLGetB(_editorColBlocked), RGBCOLGetA(_editorColBlocked)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypoints), RGBCOLGetG(_editorColWaypoints), RGBCOLGetB(_editorColWaypoints), RGBCOLGetA(_editorColWaypoints)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColScale), RGBCOLGetG(_editorColScale), RGBCOLGetB(_editorColScale), RGBCOLGetA(_editorColScale)); + + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + CBBase::saveAsText(buffer, indent + 2); + + // waypoints + buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); + for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // layers + buffer->putTextIndent(indent + 2, "; ----- layers\n"); + for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); + + // scale levels + buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); + for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); + + // rotation levels + buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); + for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent + 2, "\n"); + + // free entities + buffer->putTextIndent(indent + 2, "; ----- free entities\n"); + for (i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + _objects[i]->saveAsText(buffer, indent + 2); + + } + } + + + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::sortScaleLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { + if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { + CAdScaleLevel *sl = _scaleLevels[i]; + _scaleLevels[i] = _scaleLevels[i + 1]; + _scaleLevels[i + 1] = sl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::sortRotLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _rotLevels.getSize() - 1; i++) { + if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { + CAdRotLevel *rl = _rotLevels[i]; + _rotLevels[i] = _rotLevels[i + 1]; + _rotLevels[i + 1] = rl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getScaleAt(int Y) { + CAdScaleLevel *prev = NULL; + CAdScaleLevel *next = NULL; + + for (int i = 0; i < _scaleLevels.getSize(); i++) { + /* CAdScaleLevel *xxx = _scaleLevels[i];*/ + /* int j = _scaleLevels.getSize(); */ + if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; + else { + next = _scaleLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 100; + + int delta_y = next->_posY - prev->_posY; + float delta_scale = next->_scale - prev->_scale; + Y -= prev->_posY; + + float percent = (float)Y / ((float)delta_y / 100.0f); + return prev->_scale + delta_scale / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_autoScroll)); + persistMgr->transfer(TMEMBER(_editorColBlocked)); + persistMgr->transfer(TMEMBER(_editorColBlockedSel)); + persistMgr->transfer(TMEMBER(_editorColDecor)); + persistMgr->transfer(TMEMBER(_editorColDecorSel)); + persistMgr->transfer(TMEMBER(_editorColEntity)); + persistMgr->transfer(TMEMBER(_editorColEntitySel)); + persistMgr->transfer(TMEMBER(_editorColFrame)); + persistMgr->transfer(TMEMBER(_editorColRegion)); + persistMgr->transfer(TMEMBER(_editorColRegionSel)); + persistMgr->transfer(TMEMBER(_editorColScale)); + persistMgr->transfer(TMEMBER(_editorColWaypoints)); + persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); + persistMgr->transfer(TMEMBER(_editorMarginH)); + persistMgr->transfer(TMEMBER(_editorMarginV)); + persistMgr->transfer(TMEMBER(_editorShowBlocked)); + persistMgr->transfer(TMEMBER(_editorShowDecor)); + persistMgr->transfer(TMEMBER(_editorShowEntities)); + persistMgr->transfer(TMEMBER(_editorShowRegions)); + persistMgr->transfer(TMEMBER(_editorShowScale)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_initialized)); + persistMgr->transfer(TMEMBER(_lastTimeH)); + persistMgr->transfer(TMEMBER(_lastTimeV)); + _layers.persist(persistMgr); + persistMgr->transfer(TMEMBER(_mainLayer)); + _objects.persist(persistMgr); + persistMgr->transfer(TMEMBER(_offsetLeft)); + persistMgr->transfer(TMEMBER(_offsetTop)); + persistMgr->transfer(TMEMBER(_paralaxScrolling)); + persistMgr->transfer(TMEMBER(_persistentState)); + persistMgr->transfer(TMEMBER(_persistentStateSprites)); + persistMgr->transfer(TMEMBER(_pfMaxTime)); + _pfPath.persist(persistMgr); + persistMgr->transfer(TMEMBER(_pfPointsNum)); + persistMgr->transfer(TMEMBER(_pfReady)); + persistMgr->transfer(TMEMBER(_pfRequester)); + persistMgr->transfer(TMEMBER(_pfTarget)); + persistMgr->transfer(TMEMBER(_pfTargetPath)); + _rotLevels.persist(persistMgr); + _scaleLevels.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollPixelsH)); + persistMgr->transfer(TMEMBER(_scrollPixelsV)); + persistMgr->transfer(TMEMBER(_scrollTimeH)); + persistMgr->transfer(TMEMBER(_scrollTimeV)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_targetOffsetLeft)); + persistMgr->transfer(TMEMBER(_targetOffsetTop)); + _waypointGroups.persist(persistMgr); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::afterLoad() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { + double xStep, yStep, x, y; + int xLength, yLength, xCount, yCount; + int x1, y1, x2, y2; + + x1 = *targetX; + y1 = *targetY; + x2 = startX; + y2 = startY; + + + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); + + if (xLength > yLength) { + /* + if (X1 > X2) + { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); + y = y1; + + for (xCount = x1; xCount < x2; xCount++) { + if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { + *targetX = xCount; + *targetY = (int)y; + return STATUS_OK; + } + y += yStep; + } + } else { + /* + if (Y1 > Y2) { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); + x = x1; + + for (yCount = y1; yCount < y2; yCount++) { + if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { + *targetX = (int)x; + *targetY = yCount; + return STATUS_OK; + } + x += xStep; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { + int x = *argX; + int y = *argY; + + if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { + return STATUS_OK; + } + + // right + int length_right = 0; + bool found_right = false; + for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { + found_right = true; + break; + } + } + + // left + int length_left = 0; + bool found_left = false; + for (x = *argX, y = *argY; x >= 0; x--, length_left--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { + found_left = true; + break; + } + } + + // up + int length_up = 0; + bool found_up = false; + for (x = *argX, y = *argY; y >= 0; y--, length_up--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { + found_up = true; + break; + } + } + + // down + int length_down = 0; + bool found_down = false; + for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { + found_down = true; + break; + } + } + + if (!found_left && !found_right && !found_up && !found_down) { + return STATUS_OK; + } + + int OffsetX = INT_MAX, OffsetY = INT_MAX; + + if (found_left && found_right) { + if (abs(length_left) < abs(length_right)) OffsetX = length_left; + else OffsetX = length_right; + } else if (found_left) OffsetX = length_left; + else if (found_right) OffsetX = length_right; + + if (found_up && found_down) { + if (abs(length_up) < abs(length_down)) OffsetY = length_up; + else OffsetY = length_down; + } else if (found_up) OffsetY = length_up; + else if (found_down) OffsetY = length_down; + + if (abs(OffsetX) < abs(OffsetY)) + *argX = *argX + OffsetX; + else + *argY = *argY + OffsetY; + + if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfPointsStart() { + _pfPointsNum = 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfPointsAdd(int x, int y, int distance) { + if (_pfPointsNum >= _pfPath.getSize()) { + _pfPath.add(new CAdPathPoint(x, y, distance)); + } else { + _pfPath[_pfPointsNum]->x = x; + _pfPath[_pfPointsNum]->y = y; + _pfPath[_pfPointsNum]->_distance = distance; + _pfPath[_pfPointsNum]->_marked = false; + _pfPath[_pfPointsNum]->_origin = NULL; + } + + _pfPointsNum++; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { + if (offsetX) *offsetX = _viewport->_offsetX; + if (offsetY) *offsetY = _viewport->_offsetY; + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; + if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getViewportSize(int *width, int *height) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { + if (width) *width = _viewport->getWidth(); + if (height) *height = _viewport->getHeight(); + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + if (width) *width = adGame->_sceneViewport->getWidth(); + if (height) *height = adGame->_sceneViewport->getHeight(); + } else { + if (width) *width = _gameRef->_renderer->_width; + if (height) *height = _gameRef->_renderer->_height; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getOffsetLeft() { + int viewportX; + getViewportOffset(&viewportX); + + return _offsetLeft - viewportX; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getOffsetTop() { + int viewportY; + getViewportOffset(NULL, &viewportY); + + return _offsetTop - viewportY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::pointInViewport(int x, int y) { + int left, top, width, height; + + getViewportOffset(&left, &top); + getViewportSize(&width, &height); + + return x >= left && x <= left + width && y >= top && y <= top + height; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::setOffset(int offsetLeft, int offsetTop) { + _offsetLeft = offsetLeft; + _offsetTop = offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getNodeByName(const char *name) { + CBObject *ret = NULL; + + // dependent objects + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || + (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { + switch (node->_type) { + case OBJECT_ENTITY: + ret = node->_entity; + break; + case OBJECT_REGION: + ret = node->_region; + break; + default: + ret = NULL; + } + return ret; + } + } + } + + // free entities + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { + return _objects[i]; + } + } + + // waypoint groups + for (int i = 0; i < _waypointGroups.getSize(); i++) { + if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { + return _waypointGroups[i]; + } + } + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::saveState() { + return persistState(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadState() { + return persistState(false); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::persistState(bool saving) { + if (!_persistentState) return STATUS_OK; + + CAdGame *adGame = (CAdGame *)_gameRef; + CAdSceneState *state = adGame->getSceneState(_filename, saving); + if (!state) return STATUS_OK; + + CAdNodeState *nodeState; + + // dependent objects + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: + if (!node->_entity->_saveState) continue; + nodeState = state->getNodeState(node->_entity->_name, saving); + if (nodeState) { + nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); + //if(Saving) NodeState->_active = node->_entity->_active; + //else node->_entity->_active = NodeState->_active; + } + break; + case OBJECT_REGION: + if (!node->_region->_saveState) continue; + nodeState = state->getNodeState(node->_region->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = node->_region->_active; + else node->_region->_active = nodeState->_active; + } + break; + default: + warning("CAdScene::PersistState - unhandled enum"); + break; + } + } + } + + // free entities + for (int i = 0; i < _objects.getSize(); i++) { + if (!_objects[i]->_saveState) continue; + if (_objects[i]->_type == OBJECT_ENTITY) { + nodeState = state->getNodeState(_objects[i]->_name, saving); + if (nodeState) { + nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); + //if(Saving) NodeState->_active = _objects[i]->_active; + //else _objects[i]->_active = NodeState->_active; + } + } + } + + // waypoint groups + for (int i = 0; i < _waypointGroups.getSize(); i++) { + nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = _waypointGroups[i]->_active; + else _waypointGroups[i]->_active = nodeState->_active; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getRotationAt(int x, int y) { + CAdRotLevel *prev = NULL; + CAdRotLevel *next = NULL; + + for (int i = 0; i < _rotLevels.getSize(); i++) { + /* CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.getSize();*/ + if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; + else { + next = _rotLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 0; + + int delta_x = next->_posX - prev->_posX; + float delta_rot = next->_rotation - prev->_rotation; + x -= prev->_posX; + + float percent = (float)x / ((float)delta_x / 100.0f); + return prev->_rotation + delta_rot / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::handleItemAssociations(const char *itemName, bool show) { + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + if (layer->_nodes[j]->_type == OBJECT_ENTITY) { + CAdEntity *ent = layer->_nodes[j]->_entity; + + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + } + } + } + + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + CAdEntity *ent = (CAdEntity *)_objects[i]; + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { + int numUsed = 0; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { + if (numUsed < numRegions - 1) { + regionList[numUsed] = node->_region; + numUsed++; + } else break; + } + } + } + for (int i = numUsed; i < numRegions; i++) { + regionList[i] = NULL; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::restoreDeviceObjects() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { + CBArray objects; + getSceneObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = 0; i < objects.getSize(); i++) { + if (objects[i] == currObject) { + if (i < objects.getSize() - 1) return objects[i + 1]; + else break; + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getSceneObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = objects.getSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; + else break; + } + } + } + return objects[objects.getSize() - 1]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _layers.getSize(); i++) { + // close-up layer -> remove everything below it + if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); + + + for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { + CAdSceneNode *node = _layers[i]->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: { + CAdEntity *ent = node->_entity; + if (ent->_active && (ent->_registrable || !interactiveOnly)) + objects.add(ent); + } + break; + + case OBJECT_REGION: { + CBArray regionObj; + getRegionObjects(node->_region, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.getSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) objects.add(regionObj[newIndex]); + } + //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); + } + break; + default: + warning("CAdScene::GetSceneObjects - Unhandled enum"); + break; + } + } + } + + // objects outside any region + CBArray regionObj; + getRegionObjects(NULL, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.getSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) objects.add(regionObj[newIndex]); + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { + CAdGame *adGame = (CAdGame *)_gameRef; + CAdObject *obj; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; + + objects.add(obj); + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; + + objects.add(obj); + } + } + + // sort by _posY + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdScene.h b/engines/wintermute/ad/AdScene.h new file mode 100644 index 0000000000..f77c64aa9b --- /dev/null +++ b/engines/wintermute/ad/AdScene.h @@ -0,0 +1,181 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENE_H +#define WINTERMUTE_ADSCENE_H + +#include "engines/wintermute/base/BFader.h" + +namespace WinterMute { + +class CUIWindow; +class CAdObject; +class CAdRegion; +class CBViewport; +class CAdLayer; +class CBPoint; +class CAdWaypointGroup; +class CAdPath; +class CAdScaleLevel; +class CAdRotLevel; +class CAdPathPoint; +class CAdScene : public CBObject { +public: + + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + bool getSceneObjects(CBArray &Objects, bool InteractiveOnly); + bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + + bool afterLoad(); + + bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + bool handleItemAssociations(const char *ItemName, bool Show); + CUIWindow *_shieldWindow; + float getRotationAt(int X, int Y); + bool loadState(); + bool saveState(); + bool _persistentState; + bool _persistentStateSprites; + CBObject *getNodeByName(const char *name); + void setOffset(int OffsetLeft, int OffsetTop); + bool pointInViewport(int X, int Y); + int getOffsetTop(); + int getOffsetLeft(); + bool getViewportSize(int *Width = NULL, int *Height = NULL); + bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + CBViewport *_viewport; + CBFader *_fader; + int _pfPointsNum; + void pfPointsAdd(int X, int Y, int Distance); + void pfPointsStart(); + bool _initialized; + bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + DECLARE_PERSISTENT(CAdScene, CBObject) + bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + bool displayRegionContentOld(CAdRegion *Region = NULL); + static int compareObjs(const void *Obj1, const void *Obj2); + + bool updateFreeObjects(); + bool traverseNodes(bool Update = false); + float getScaleAt(int Y); + bool sortScaleLevels(); + bool sortRotLevels(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); + bool _paralaxScrolling; + void skipTo(int OffsetX, int OffsetY); + void setDefaults(); + void cleanup(); + void skipToObject(CBObject *Object); + void scrollToObject(CBObject *Object); + void scrollTo(int OffsetX, int OffsetY); + virtual bool update(); + bool _autoScroll; + int _targetOffsetTop; + int _targetOffsetLeft; + + int _scrollPixelsV; + uint32 _scrollTimeV; + uint32 _lastTimeV; + + int _scrollPixelsH; + uint32 _scrollTimeH; + uint32 _lastTimeH; + + virtual bool display(); + uint32 _pfMaxTime; + bool initLoop(); + void pathFinderStep(); + bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + CAdLayer *_mainLayer; + float getZoomAt(int X, int Y); + bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); + CAdScene(CBGame *inGame); + virtual ~CAdScene(); + CBArray _layers; + CBArray _objects; + CBArray _waypointGroups; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + int _width; + int _height; + bool addObject(CAdObject *Object); + bool removeObject(CAdObject *Object); + int _editorMarginH; + int _editorMarginV; + uint32 _editorColFrame; + uint32 _editorColEntity; + uint32 _editorColRegion; + uint32 _editorColBlocked; + uint32 _editorColWaypoints; + uint32 _editorColEntitySel; + uint32 _editorColRegionSel; + uint32 _editorColBlockedSel; + uint32 _editorColWaypointsSel; + uint32 _editorColScale; + uint32 _editorColDecor; + uint32 _editorColDecorSel; + + bool _editorShowRegions; + bool _editorShowBlocked; + bool _editorShowDecor; + bool _editorShowEntities; + bool _editorShowScale; + CBArray _scaleLevels; + CBArray _rotLevels; + + virtual bool restoreDeviceObjects(); + int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + bool persistState(bool Saving = true); + void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + bool _pfReady; + CBPoint *_pfTarget; + CAdPath *_pfTargetPath; + CBObject *_pfRequester; + CBArray _pfPath; + + int _offsetTop; + int _offsetLeft; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdSceneNode.cpp b/engines/wintermute/ad/AdSceneNode.cpp new file mode 100644 index 0000000000..5f518e5442 --- /dev/null +++ b/engines/wintermute/ad/AdSceneNode.cpp @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdSceneNode.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _region = NULL; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::~CAdSceneNode() { + _gameRef->unregisterObject(_region); + _region = NULL; + + _gameRef->unregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::setEntity(CAdEntity *entity) { + _type = OBJECT_ENTITY; + _entity = entity; + return _gameRef->registerObject(entity); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::setRegion(CAdRegion *region) { + _type = OBJECT_REGION; + _region = region; + return _gameRef->registerObject(region); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_entity)); + persistMgr->transfer(TMEMBER(_region)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSceneNode.h b/engines/wintermute/ad/AdSceneNode.h new file mode 100644 index 0000000000..d081959934 --- /dev/null +++ b/engines/wintermute/ad/AdSceneNode.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENENODE_H +#define WINTERMUTE_ADSCENENODE_H + + +#include "engines/wintermute/ad/AdTypes.h" // Added by ClassView +#include "engines/wintermute/ad/AdRegion.h" // Added by ClassView +#include "engines/wintermute/ad/AdEntity.h" + +namespace WinterMute { + +class CAdSceneNode : public CBObject { +public: + DECLARE_PERSISTENT(CAdSceneNode, CBObject) + bool setRegion(CAdRegion *region); + bool setEntity(CAdEntity *entity); + CAdEntity *_entity; + CAdRegion *_region; + TObjectType _type; + CAdSceneNode(CBGame *inGame); + virtual ~CAdSceneNode(); + +}; + +} + +#endif diff --git a/engines/wintermute/ad/AdSceneState.cpp b/engines/wintermute/ad/AdSceneState.cpp new file mode 100644 index 0000000000..2192bc13fe --- /dev/null +++ b/engines/wintermute/ad/AdSceneState.cpp @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/ad/AdSceneState.h" +#include "engines/wintermute/ad/AdNodeState.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneState, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::~CAdSceneState() { + delete[] _filename; + _filename = NULL; + + for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; + _nodeStates.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneState::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_filename)); + _nodeStates.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSceneState::setFilename(const char *filename) { + delete[] _filename; + _filename = new char [strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { + for (int i = 0; i < _nodeStates.getSize(); i++) { + if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; + } + + if (saving) { + CAdNodeState *ret = new CAdNodeState(_gameRef); + ret->setName(name); + _nodeStates.add(ret); + + return ret; + } else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSceneState.h b/engines/wintermute/ad/AdSceneState.h new file mode 100644 index 0000000000..82207f383c --- /dev/null +++ b/engines/wintermute/ad/AdSceneState.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENESTATE_H +#define WINTERMUTE_ADSCENESTATE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CAdNodeState; +class CAdSceneState : public CBBase { +public: + CAdNodeState *getNodeState(char *name, bool saving); + void setFilename(const char *filename); + DECLARE_PERSISTENT(CAdSceneState, CBBase) + CAdSceneState(CBGame *inGame); + virtual ~CAdSceneState(); + char *_filename; + CBArray _nodeStates; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdSentence.cpp b/engines/wintermute/ad/AdSentence.cpp new file mode 100644 index 0000000000..98926caac6 --- /dev/null +++ b/engines/wintermute/ad/AdSentence.cpp @@ -0,0 +1,317 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/ad/AdTalkDef.h" +#include "engines/wintermute/ad/AdTalkNode.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSentence, false) + +////////////////////////////////////////////////////////////////////////// +CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { + _text = NULL; + _stances = NULL; + _tempStance = NULL; + + _duration = 0; + _startTime = 0; + _currentStance = 0; + + _font = NULL; + + _pos.x = _pos.y = 0; + _width = _gameRef->_renderer->_width; + + _align = (TTextAlign)TAL_CENTER; + + _sound = NULL; + _soundStarted = false; + + _talkDef = NULL; + _currentSprite = NULL; + _currentSkelAnim = NULL; + _fixedPos = false; + _freezable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSentence::~CAdSentence() { + delete _sound; + delete[] _text; + delete[] _stances; + delete[] _tempStance; + delete _talkDef; + _sound = NULL; + _text = NULL; + _stances = NULL; + _tempStance = NULL; + _talkDef = NULL; + + _currentSprite = NULL; // ref only + _currentSkelAnim = NULL; + _font = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setText(const char *text) { + if (_text) delete [] _text; + _text = new char[strlen(text) + 1]; + if (_text) strcpy(_text, text); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setStances(const char *stances) { + if (_stances) delete [] _stances; + if (stances) { + _stances = new char[strlen(stances) + 1]; + if (_stances) strcpy(_stances, stances); + } else _stances = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getCurrentStance() { + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getNextStance() { + _currentStance++; + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getStance(int stance) { + if (_stances == NULL) return NULL; + + if (_tempStance) delete [] _tempStance; + _tempStance = NULL; + + char *start; + char *curr; + int pos; + + if (stance == 0) start = _stances; + else { + pos = 0; + start = NULL; + curr = _stances; + while (pos < stance) { + if (*curr == '\0') break; + if (*curr == ',') pos++; + curr++; + } + if (pos == stance) start = curr; + } + + if (start == NULL) return NULL; + + while (*start == ' ' && *start != ',' && *start != '\0') start++; + + curr = start; + while (*curr != '\0' && *curr != ',') curr++; + + while (curr > start && *(curr - 1) == ' ') curr--; + + _tempStance = new char [curr - start + 1]; + if (_tempStance) { + _tempStance[curr - start] = '\0'; + strncpy(_tempStance, start, curr - start); + } + + return _tempStance; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::display() { + if (!_font || !_text) return STATUS_FAILED; + + if (_sound && !_soundStarted) { + _sound->play(); + _soundStarted = true; + } + + if (_gameRef->_subtitles) { + int x = _pos.x; + int y = _pos.y; + + if (!_fixedPos) { + x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + + x = MAX(x, 0); + x = MIN(x, _gameRef->_renderer->_width - _width); + y = MAX(y, 0); + + _font->drawText((byte *)_text, x, y, _width, _align); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setSound(CBSound *sound) { + if (!sound) return; + delete _sound; + _sound = sound; + _soundStarted = false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::finish() { + if (_sound) _sound->stop(); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_currentStance)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_currentSkelAnim)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_sound)); + persistMgr->transfer(TMEMBER(_soundStarted)); + persistMgr->transfer(TMEMBER(_stances)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_talkDef)); + persistMgr->transfer(TMEMBER(_tempStance)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_fixedPos)); + persistMgr->transfer(TMEMBER(_freezable)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::setupTalkFile(const char *soundFilename) { + delete _talkDef; + _talkDef = NULL; + _currentSprite = NULL; + + if (!soundFilename) return STATUS_OK; + + + AnsiString path = PathUtil::getDirectoryName(soundFilename); + AnsiString name = PathUtil::getFileNameWithoutExtension(soundFilename); + + AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); + if (file) { + _gameRef->_fileManager->closeFile(file); + } else return STATUS_OK; // no talk def file found + + + _talkDef = new CAdTalkDef(_gameRef); + if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { + delete _talkDef; + _talkDef = NULL; + return STATUS_FAILED; + } + //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::update(TDirection dir) { + if (!_talkDef) return STATUS_OK; + + uint32 currentTime; + // if sound is available, synchronize with sound, otherwise use timer + + /* + if (_sound) CurrentTime = _sound->GetPositionTime(); + else CurrentTime = _gameRef->_timer - _startTime; + */ + currentTime = _gameRef->_timer - _startTime; + + bool talkNodeFound = false; + for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { + if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { + talkNodeFound = true; + + CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); + if (newSprite != _currentSprite) newSprite->reset(); + _currentSprite = newSprite; + + if (!_talkDef->_nodes[i]->_playToEnd) break; + } + } + + + // no talk node, try to use default sprite instead (if any) + if (!talkNodeFound) { + CBSprite *newSprite = _talkDef->getDefaultSprite(dir); + if (newSprite) { + if (newSprite != _currentSprite) newSprite->reset(); + _currentSprite = newSprite; + } else _currentSprite = NULL; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::CanSkip() { + // prevent accidental sentence skipping (TODO make configurable) + return (_gameRef->_timer - _startTime) > 300; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSentence.h b/engines/wintermute/ad/AdSentence.h new file mode 100644 index 0000000000..954568878e --- /dev/null +++ b/engines/wintermute/ad/AdSentence.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSENTENCE_H +#define WINTERMUTE_ADSENTENCE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "common/rect.h" + +namespace WinterMute { +class CAdTalkDef; +class CBFont; +class CBSprite; +class CBSound; +class CAdSentence : public CBBase { +public: + bool _freezable; + bool _fixedPos; + CBSprite *_currentSprite; + char *_currentSkelAnim; + bool update(TDirection dir = DI_DOWN); + bool setupTalkFile(const char *soundFilename); + DECLARE_PERSISTENT(CAdSentence, CBBase) + bool finish(); + void setSound(CBSound *Sound); + bool _soundStarted; + CBSound *_sound; + TTextAlign _align; + bool display(); + int _width; + Point32 _pos; + CBFont *_font; + char *getNextStance(); + char *getCurrentStance(); + void setStances(const char *stances); + void setText(const char *text); + int _currentStance; + uint32 _startTime; + char *_stances; + char *_text; + uint32 _duration; + CAdSentence(CBGame *inGame); + virtual ~CAdSentence(); + CAdTalkDef *_talkDef; + + bool CanSkip(); + +private: + char *_tempStance; + char *getStance(int stance); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdSpriteSet.cpp b/engines/wintermute/ad/AdSpriteSet.cpp new file mode 100644 index 0000000000..127d42d02b --- /dev/null +++ b/engines/wintermute/ad/AdSpriteSet.cpp @@ -0,0 +1,312 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdSpriteSet.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSpriteSet, false) + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { + _owner = owner; + + for (int i = 0; i < NUM_DIRECTIONS; i++) + _sprites[i] = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::~CAdSpriteSet() { + for (int i = 0; i < NUM_DIRECTIONS; i++) { + delete _sprites[i]; + _sprites[i] = NULL; + } + + _owner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SPRITESET) +TOKEN_DEF(NAME) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(RIGHT) +TOKEN_DEF(UP) +TOKEN_DEF(DOWN) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(NAME) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(RIGHT) + TOKEN_TABLE(UP) + TOKEN_TABLE(DOWN) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + _gameRef->LOG(0, "'SPRITESET' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CBSprite *spr = NULL; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_LEFT: + delete _sprites[DI_LEFT]; + _sprites[DI_LEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_LEFT] = spr; + break; + + case TOKEN_RIGHT: + delete _sprites[DI_RIGHT]; + _sprites[DI_RIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_RIGHT] = spr; + break; + + case TOKEN_UP: + delete _sprites[DI_UP]; + _sprites[DI_UP] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UP] = spr; + break; + + case TOKEN_DOWN: + delete _sprites[DI_DOWN]; + _sprites[DI_DOWN] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWN] = spr; + break; + + case TOKEN_UP_LEFT: + delete _sprites[DI_UPLEFT]; + _sprites[DI_UPLEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPLEFT] = spr; + break; + + case TOKEN_UP_RIGHT: + delete _sprites[DI_UPRIGHT]; + _sprites[DI_UPRIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPRIGHT] = spr; + break; + + case TOKEN_DOWN_LEFT: + delete _sprites[DI_DOWNLEFT]; + _sprites[DI_DOWNLEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNLEFT] = spr; + break; + + case TOKEN_DOWN_RIGHT: + delete _sprites[DI_DOWNRIGHT]; + _sprites[DI_DOWNRIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNRIGHT] = spr; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITESET definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading SPRITESET definition"); + if (spr) delete spr; + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_owner)); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + persistMgr->transfer("", &_sprites[i]); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdSpriteSet::getSprite(TDirection direction) { + int dir = (int)direction; + if (dir < 0) dir = 0; + if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; + + CBSprite *ret = NULL; + + // find nearest set sprite + int numSteps = 0; + for (int i = dir; i >= 0; i--) { + if (_sprites[i] != NULL) { + ret = _sprites[i]; + numSteps = dir - i; + break; + } + } + + for (int i = dir; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] != NULL) { + if (ret == NULL || numSteps > i - dir) return _sprites[i]; + else return ret; + } + } + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITESET {\n"); + if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i]) { + switch (i) { + case DI_UP: + buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPRIGHT: + buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_RIGHT: + buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNRIGHT: + buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWN: + buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNLEFT: + buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_LEFT: + buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPLEFT: + buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + } + } + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::containsSprite(CBSprite *sprite) { + if (!sprite) return false; + + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] == sprite) return true; + } + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSpriteSet.h b/engines/wintermute/ad/AdSpriteSet.h new file mode 100644 index 0000000000..ba5c6fb75b --- /dev/null +++ b/engines/wintermute/ad/AdSpriteSet.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSPRITESET_H +#define WINTERMUTE_ADSPRITESET_H + + +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BSprite.h" // Added by ClassView + +namespace WinterMute { + +class CAdSpriteSet : public CBObject { +public: + bool containsSprite(CBSprite *sprite); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBSprite *getSprite(TDirection direction); + DECLARE_PERSISTENT(CAdSpriteSet, CBObject) + CBObject *_owner; + CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); + virtual ~CAdSpriteSet(); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + CBSprite *_sprites[NUM_DIRECTIONS]; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdTalkDef.cpp b/engines/wintermute/ad/AdTalkDef.cpp new file mode 100644 index 0000000000..b598226413 --- /dev/null +++ b/engines/wintermute/ad/AdTalkDef.cpp @@ -0,0 +1,260 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdTalkDef.h" +#include "engines/wintermute/ad/AdTalkNode.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/ad/AdSpriteSet.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkDef, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::~CAdTalkDef() { + for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; + _nodes.removeAll(); + + delete[] _defaultSpriteFilename; + delete _defaultSprite; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + delete[] _defaultSpriteSetFilename; + delete _defaultSpriteSet; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + CBUtils::setString(&_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TALK) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(ACTION) +TOKEN_DEF(DEFAULT_SPRITESET_FILE) +TOKEN_DEF(DEFAULT_SPRITESET) +TOKEN_DEF(DEFAULT_SPRITE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(DEFAULT_SPRITESET_FILE) + TOKEN_TABLE(DEFAULT_SPRITESET) + TOKEN_TABLE(DEFAULT_SPRITE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { + _gameRef->LOG(0, "'TALK' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_ACTION: { + CAdTalkNode *Node = new CAdTalkNode(_gameRef); + if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); + else { + delete Node; + Node = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_DEFAULT_SPRITE: + CBUtils::setString(&_defaultSpriteFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET_FILE: + CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET: { + delete _defaultSpriteSet; + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TALK definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading TALK definition"); + return STATUS_FAILED; + } + + delete _defaultSprite; + delete _defaultSpriteSet; + _defaultSprite = NULL; + _defaultSpriteSet = NULL; + + if (_defaultSpriteFilename) { + _defaultSprite = new CBSprite(_gameRef); + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; + } + + if (_defaultSpriteSetFilename) { + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_defaultSprite)); + persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); + persistMgr->transfer(TMEMBER(_defaultSpriteSet)); + persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); + + _nodes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TALK {\n"); + if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + + if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); + + for (int i = 0; i < _nodes.getSize(); i++) { + _nodes[i]->saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "\n"); + } + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadDefaultSprite() { + if (_defaultSpriteFilename && !_defaultSprite) { + _defaultSprite = new CBSprite(_gameRef); + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { + delete _defaultSprite; + _defaultSprite = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { + loadDefaultSprite(); + if (_defaultSprite) return _defaultSprite; + else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkDef.h b/engines/wintermute/ad/AdTalkDef.h new file mode 100644 index 0000000000..81d6475013 --- /dev/null +++ b/engines/wintermute/ad/AdTalkDef.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKDEF_H +#define WINTERMUTE_ADTALKDEF_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { +class CAdTalkNode; +class CAdSpriteSet; +class CAdTalkDef : public CBObject { +public: + char *_defaultSpriteSetFilename; + CAdSpriteSet *_defaultSpriteSet; + CBSprite *getDefaultSprite(TDirection Dir); + bool loadDefaultSprite(); + DECLARE_PERSISTENT(CAdTalkDef, CBObject) + + CAdTalkDef(CBGame *inGame); + virtual ~CAdTalkDef(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + CBArray _nodes; + char *_defaultSpriteFilename; + CBSprite *_defaultSprite; + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdTalkHolder.cpp b/engines/wintermute/ad/AdTalkHolder.cpp new file mode 100644 index 0000000000..4c627ca9ad --- /dev/null +++ b/engines/wintermute/ad/AdTalkHolder.cpp @@ -0,0 +1,366 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdTalkHolder.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkHolder, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::~CAdTalkHolder() { + delete _sprite; + _sprite = NULL; + + for (int i = 0; i < _talkSprites.getSize(); i++) + delete _talkSprites[i]; + _talkSprites.removeAll(); + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) + delete _talkSpritesEx[i]; + _talkSpritesEx.removeAll(); +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { + CBSprite *ret = NULL; + + + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + + if (stance != NULL) { + // search special talk stances + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + ret = _talkSpritesEx[i]; + break; + } + } + if (ret == NULL) { + // serach generic talk stances + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + ret = _talkSprites[i]; + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.getSize() < 1) ret = _sprite; + else { + // TODO: remember last + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + ret = _talkSprites[rnd]; + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSprite") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + + bool setCurrent = false; + if (_currentSprite && _currentSprite == _sprite) setCurrent = true; + + delete _sprite; + _sprite = NULL; + + if (val->isNULL()) { + _sprite = NULL; + if (setCurrent) _currentSprite = NULL; + stack->pushBool(true); + } else { + const char *filename = val->getString(); + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + script->runtimeError("SetSprite method failed for file '%s'", filename); + stack->pushBool(false); + } else { + _sprite = spr; + if (setCurrent) _currentSprite = _sprite; + stack->pushBool(true); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSprite") == 0) { + stack->correctParams(0); + + if (!_sprite || !_sprite->_filename) stack->pushNULL(); + else stack->pushString(_sprite->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSpriteObject") == 0) { + stack->correctParams(0); + + if (!_sprite) stack->pushNULL(); + else stack->pushNative(_sprite, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool Ex = stack->pop()->getBool(); + + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("AddTalkSprite method failed for file '%s'", filename); + } else { + if (Ex) _talkSpritesEx.add(spr); + else _talkSprites.add(spr); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool ex = stack->pop()->getBool(); + + bool setCurrent = false; + bool setTemp2 = false; + + if (ex) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { + if (_currentSprite == _talkSpritesEx[i]) + setCurrent = true; + if (_tempSprite2 == _talkSpritesEx[i]) + setTemp2 = true; + delete _talkSpritesEx[i]; + _talkSpritesEx.removeAt(i); + break; + } + } + } else { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { + if (_currentSprite == _talkSprites[i]) + setCurrent = true; + if (_tempSprite2 == _talkSprites[i]) + setTemp2 = true; + delete _talkSprites[i]; + _talkSprites.removeAt(i); + break; + } + } + + } + + stack->pushBool(true); + if (setCurrent) + _currentSprite = _sprite; + if (setTemp2) + _tempSprite2 = _sprite; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool ex = stack->pop()->getBool(); + bool setCurrent = false; + bool setTemp2 = false; + + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("SetTalkSprite method failed for file '%s'", filename); + } else { + + // delete current + if (ex) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (_talkSpritesEx[i] == _currentSprite) + setCurrent = true; + if (_talkSpritesEx[i] == _tempSprite2) + setTemp2 = true; + delete _talkSpritesEx[i]; + } + _talkSpritesEx.removeAll(); + } else { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (_talkSprites[i] == _currentSprite) setCurrent = true; + if (_talkSprites[i] == _tempSprite2) setTemp2 = true; + delete _talkSprites[i]; + } + _talkSprites.removeAll(); + } + + // set new + if (ex) + _talkSpritesEx.add(spr); + else + _talkSprites.add(spr); + stack->pushBool(true); + + if (setCurrent) + _currentSprite = spr; + if (setTemp2) + _tempSprite2 = spr; + } + return STATUS_OK; + } + + else return CAdObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdTalkHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("talk-holder"); + return _scValue; + } + + else return CAdObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Item")==0){ + SetItem(value->getString()); + return STATUS_OK; + } + + else*/ return CAdObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdTalkHolder::scToString() { + return "[talk-holder object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (_talkSprites[i]->_filename) + buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + } + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (_talkSpritesEx[i]->_filename) + buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { + CAdObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_sprite)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkHolder.h b/engines/wintermute/ad/AdTalkHolder.h new file mode 100644 index 0000000000..9e6c3bbd63 --- /dev/null +++ b/engines/wintermute/ad/AdTalkHolder.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKHOLDER_H +#define WINTERMUTE_ADTALKHOLDER_H + +#include "engines/wintermute/ad/AdObject.h" + +namespace WinterMute { + +class CAdTalkHolder : public CAdObject { +public: + DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) + virtual CBSprite *getTalkStance(const char *stance); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + CBSprite *_sprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + CAdTalkHolder(CBGame *inGame); + virtual ~CAdTalkHolder(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdTalkNode.cpp b/engines/wintermute/ad/AdTalkNode.cpp new file mode 100644 index 0000000000..da2195be33 --- /dev/null +++ b/engines/wintermute/ad/AdTalkNode.cpp @@ -0,0 +1,266 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdTalkNode.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/ad/AdSpriteSet.h" +#include "engines/wintermute/utils/utils.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { + _sprite = NULL; + _spriteFilename = NULL; + _spriteSet = NULL; + _spriteSetFilename = NULL; + _comment = NULL; + + _startTime = _endTime = 0; + _playToEnd = false; + _preCache = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::~CAdTalkNode() { + delete[] _spriteFilename; + delete _sprite; + delete[] _spriteSetFilename; + delete _spriteSet; + delete _comment; + _spriteFilename = NULL; + _sprite = NULL; + _spriteSetFilename = NULL; + _spriteSet = NULL; + _comment = NULL; +} + + + +TOKEN_DEF_START +TOKEN_DEF(ACTION) +TOKEN_DEF(SPRITESET_FILE) +TOKEN_DEF(SPRITESET) +TOKEN_DEF(SPRITE) +TOKEN_DEF(START_TIME) +TOKEN_DEF(END_TIME) +TOKEN_DEF(COMMENT) +TOKEN_DEF(PRECACHE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(SPRITESET_FILE) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(START_TIME) + TOKEN_TABLE(END_TIME) + TOKEN_TABLE(COMMENT) + TOKEN_TABLE(PRECACHE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + _gameRef->LOG(0, "'ACTION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + _endTime = 0; + _playToEnd = false; + _preCache = false; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SPRITE: + CBUtils::setString(&_spriteFilename, (char *)params); + break; + + case TOKEN_SPRITESET_FILE: + CBUtils::setString(&_spriteSetFilename, (char *)params); + break; + + case TOKEN_SPRITESET: { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { + delete _spriteSet; + _spriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_START_TIME: + parser.scanStr((char *)params, "%d", &_startTime); + break; + + case TOKEN_END_TIME: + parser.scanStr((char *)params, "%d", &_endTime); + break; + + case TOKEN_PRECACHE: + parser.scanStr((char *)params, "%b", &_preCache); + break; + + case TOKEN_COMMENT: + if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ACTION definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ACTION definition"); + return STATUS_FAILED; + } + + if (_endTime == 0) + _playToEnd = true; + else + _playToEnd = false; + + if (_preCache && _spriteFilename) { + delete _sprite; + _sprite = new CBSprite(_gameRef); + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) + return STATUS_FAILED; + } + + if (_preCache && _spriteSetFilename) { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) + return STATUS_FAILED; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_comment)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_endTime)); + persistMgr->transfer(TMEMBER(_playToEnd)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_spriteFilename)); + persistMgr->transfer(TMEMBER(_spriteSet)); + persistMgr->transfer(TMEMBER(_spriteSetFilename)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ACTION {\n"); + if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); + buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); + if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::loadSprite() { + if (_spriteFilename && !_sprite) { + _sprite = new CBSprite(_gameRef); + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { + delete _sprite; + _sprite = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } + + else if (_spriteSetFilename && !_spriteSet) { + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { + delete _spriteSet; + _spriteSet = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } + + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { + if (time >= _startTime) { + if (_playToEnd) { + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; + else return false; + } else return _endTime >= time; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkNode::getSprite(TDirection dir) { + loadSprite(); + if (_sprite) return _sprite; + else if (_spriteSet) return _spriteSet->getSprite(dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkNode.h b/engines/wintermute/ad/AdTalkNode.h new file mode 100644 index 0000000000..11bbb353c1 --- /dev/null +++ b/engines/wintermute/ad/AdTalkNode.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKNODE_H +#define WINTERMUTE_ADTALKNODE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CAdSpriteSet; +class CBSprite; +class CAdTalkNode : public CBBase { +public: + char *_spriteSetFilename; + CAdSpriteSet *_spriteSet; + CBSprite *getSprite(TDirection dir); + bool isInTimeInterval(uint32 time, TDirection dir); + bool loadSprite(); + DECLARE_PERSISTENT(CAdTalkNode, CBBase) + + CAdTalkNode(CBGame *inGame); + virtual ~CAdTalkNode(); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + char *_spriteFilename; + CBSprite *_sprite; + uint32 _startTime; + uint32 _endTime; + bool _playToEnd; + bool _preCache; + char *_comment; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/AdTypes.h b/engines/wintermute/ad/AdTypes.h new file mode 100644 index 0000000000..b88d6fe259 --- /dev/null +++ b/engines/wintermute/ad/AdTypes.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTYPES_H +#define WINTERMUTE_ADTYPES_H + +namespace WinterMute { + +typedef enum { + GAME_NORMAL, + GAME_WAITING_RESPONSE +} TGameStateEx; + +typedef enum { + OBJECT_ENTITY, + OBJECT_REGION, + OBJECT_ACTOR, + OBJECT_NONE +} TObjectType; + +typedef enum { + ENTITY_NORMAL, + ENTITY_SOUND +} TEntityType; + +typedef enum { + STATE_NONE, + STATE_IDLE, + STATE_PLAYING_ANIM, + STATE_READY, + STATE_FOLLOWING_PATH, + STATE_SEARCHING_PATH, + STATE_WAITING_PATH, + STATE_TURNING_LEFT, + STATE_TURNING_RIGHT, + STATE_TURNING, + STATE_TALKING, + STATE_DIRECT_CONTROL, + STATE_PLAYING_ANIM_SET +} TObjectState; + +typedef enum { + DIRECT_WALK_NONE, + DIRECT_WALK_FW, + DIRECT_WALK_BK +} TDirectWalkMode; + +typedef enum { + DIRECT_TURN_NONE, + DIRECT_TURN_CW, + DIRECT_TURN_CCW +} TDirectTurnMode; + +typedef enum { + RESPONSE_TEXT, + RESPONSE_ICON +} TResponseStyle; + +typedef enum { + RESPONSE_ALWAYS, + RESPONSE_ONCE, + RESPONSE_ONCE_GAME +} TResponseType; + + +typedef enum { + TALK_SKIP_LEFT = 0, + TALK_SKIP_RIGHT = 1, + TALK_SKIP_BOTH = 2, + TALK_SKIP_NONE = 3 +} TTalkSkipButton; + +typedef enum { + GEOM_WAYPOINT, + GEOM_WALKPLANE, + GEOM_BLOCKED, + GEOM_GENERIC +} TGeomNodeType; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/ad/AdWaypointGroup.cpp b/engines/wintermute/ad/AdWaypointGroup.cpp new file mode 100644 index 0000000000..3080b34c09 --- /dev/null +++ b/engines/wintermute/ad/AdWaypointGroup.cpp @@ -0,0 +1,261 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BFileManager.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; +} + + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::~CAdWaypointGroup() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdWaypointGroup::cleanup() { + for (int i = 0; i < _points.getSize(); i++) + delete _points[i]; + _points.removeAll(); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(POINT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(POINT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in WAYPOINTS definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WAYPOINTS {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + if (_scProp) + _scProp->saveAsText(buffer, indent + 2); + CBBase::saveAsText(buffer, indent + 2); + + for (int i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdWaypointGroup::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("waypoint-group"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { + if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < wpt->_points.getSize(); i++) { + int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); + int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(x + argX, y + argY)); + } + + _lastMimicScale = scale; + _lastMimicX = argX; + _lastMimicY = argY; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdWaypointGroup.h b/engines/wintermute/ad/AdWaypointGroup.h new file mode 100644 index 0000000000..f7c9e4c361 --- /dev/null +++ b/engines/wintermute/ad/AdWaypointGroup.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADWAYPOINTGROUP_H +#define WINTERMUTE_ADWAYPOINTGROUP_H + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { +class CBPoint; +class CAdWaypointGroup : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); + DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool _active; + CAdWaypointGroup(CBGame *inGame); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual ~CAdWaypointGroup(); + CBArray _points; + int _editorSelectedPoint; + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp new file mode 100644 index 0000000000..382329087a --- /dev/null +++ b/engines/wintermute/base/BActiveRect.cpp @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { + _owner = owner; + _frame = frame; + CBPlatform::setRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { + _owner = owner; + _region = region; + CBPlatform::copyRect(&_rect, ®ion->_rect); + CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + CBRenderer *Rend = _gameRef->_renderer; + + if (!customViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + + CBPlatform::intersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BActiveRect.h b/engines/wintermute/base/BActiveRect.h new file mode 100644 index 0000000000..935b91eaeb --- /dev/null +++ b/engines/wintermute/base/BActiveRect.h @@ -0,0 +1,60 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BBase.cpp b/engines/wintermute/base/BBase.cpp new file mode 100644 index 0000000000..76e1150925 --- /dev/null +++ b/engines/wintermute/base/BBase.cpp @@ -0,0 +1,178 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::getEditorProp(const char *propName, const char *initVal) { + _editorPropsIter = _editorProps.find(propName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean + else return initVal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return STATUS_FAILED; + + if (propValue == NULL) { + _editorProps.erase(propName); + } else { + _editorProps[propName] = propValue; + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBBase::parseEditorProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!_gameRef->_editorMode) + return STATUS_OK; + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + + + setEditorProp(propName, propValue); + + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + buffer->putTextIndent(indent, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BBase.h b/engines/wintermute/base/BBase.h new file mode 100644 index 0000000000..e8c87f1f9e --- /dev/null +++ b/engines/wintermute/base/BBase.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool _persistable; + bool setEditorProp(const char *propName, const char *propValue); + const char *getEditorProp(const char *propName, const char *initVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBBase(); + CBGame *_gameRef; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BDebugger.cpp b/engines/wintermute/base/BDebugger.cpp new file mode 100644 index 0000000000..92f282b6d1 --- /dev/null +++ b/engines/wintermute/base/BDebugger.cpp @@ -0,0 +1,203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BDebugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + _enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::initialize() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::shutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameInit() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameShutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameTick() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onLog(unsigned int errorCode, const char *text) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptInit(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::attachClient(IWmeDebugClient *client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::detachClient(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::queryData(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::getPropInt(const char *propName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::getPropFloat(const char *propName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::getPropString(const char *propName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::getPropBool(const char *propName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, int propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, double propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, const char *propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, bool propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::continueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDebugger.h b/engines/wintermute/base/BDebugger.h new file mode 100644 index 0000000000..cea432f7a8 --- /dev/null +++ b/engines/wintermute/base/BDebugger.h @@ -0,0 +1,95 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/wme_debugger.h" + +// TODO: The entire debugger should possibly be removed + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool _enabled; + bool initialize(); + bool shutdown(); + + // internal interface + bool onGameInit(); + bool onGameShutdown(); + bool onGameTick(); + bool onLog(unsigned int errorCode, const char *text); + bool onScriptInit(CScScript *script); + bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + bool onScriptShutdown(CScScript *script); + bool onScriptChangeLine(CScScript *script, int line); + bool onScriptChangeScope(CScScript *script, CScValue *scope); + bool onScriptShutdownScope(CScScript *script, CScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + bool onVariableChangeValue(CScValue *var, CScValue *value); + + bool onScriptHitBreakpoint(CScScript *script); + + // IWmeDebugServer interface + virtual bool attachClient(IWmeDebugClient *client); + virtual bool detachClient(IWmeDebugClient *client); + virtual bool queryData(IWmeDebugClient *client); + + virtual int getPropInt(const char *propName); + virtual double getPropFloat(const char *propName); + virtual const char *getPropString(const char *propName); + virtual bool getPropBool(const char *propName); + + virtual bool setProp(const char *propName, int propValue); + virtual bool setProp(const char *propName, double propValue); + virtual bool setProp(const char *propName, const char *propValue); + virtual bool setProp(const char *propName, bool propValue); + + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); + + virtual bool addBreakpoint(const char *scriptFilename, int line); + virtual bool removeBreakpoint(const char *scriptFilename, int line); + + virtual bool continueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BDynBuffer.cpp b/engines/wintermute/base/BDynBuffer.cpp new file mode 100644 index 0000000000..9a2e071287 --- /dev/null +++ b/engines/wintermute/base/BDynBuffer.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::cleanup() { + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) initSize = _initSize; + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + if (_offset + size > _size) { + _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putString(const char *val) { + if (!val) putString("(null)"); + else { + putDWORD(strlen(val) + 1); + putBytes((byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + putBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDynBuffer.h b/engines/wintermute/base/BDynBuffer.h new file mode 100644 index 0000000000..66e8182c68 --- /dev/null +++ b/engines/wintermute/base/BDynBuffer.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool _initialized; + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void putTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp new file mode 100644 index 0000000000..7184c6664c --- /dev/null +++ b/engines/wintermute/base/BFader.cpp @@ -0,0 +1,176 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFader.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::update() { + if (!_active) return STATUS_OK; + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) time = CBPlatform::getTime() - _startTime; + else time = _gameRef->_timer - _startTime; + + if (time >= _duration) _currentAlpha = _targetAlpha; + else { + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::display() { + if (!_active) return STATUS_OK; + + if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); + + _sourceAlpha = RGBCOLGetA(sourceColor); + _targetAlpha = 0; + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = RGBCOLGetA(targetColor); + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->_saving) _startTime = 0; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFader.h b/engines/wintermute/base/BFader.h new file mode 100644 index 0000000000..cc90d4603d --- /dev/null +++ b/engines/wintermute/base/BFader.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool _system; + uint32 getCurrentColor(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFileEntry.cpp b/engines/wintermute/base/BFileEntry.cpp new file mode 100644 index 0000000000..39223bfb8e --- /dev/null +++ b/engines/wintermute/base/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileEntry.h b/engines/wintermute/base/BFileEntry.h new file mode 100644 index 0000000000..5fdf2b6308 --- /dev/null +++ b/engines/wintermute/base/BFileEntry.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp new file mode 100644 index 0000000000..1cfb3d47d3 --- /dev/null +++ b/engines/wintermute/base/BFileManager.cpp @@ -0,0 +1,737 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/base/file/BDiskFile.h" +#include "engines/wintermute/base/file/BSaveThumbFile.h" +#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/BResources.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/savefile.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + _basePath = NULL; + + initPaths(); + registerPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::cleanup() { + // delete registered paths + for (int i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (int i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + + // delete file entries + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; + } + _files.clear(); + + // close open files + for (int i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + + // delete packages + for (int i = 0; i < _packages.size(); i++) + delete _packages[i]; + _packages.clear(); + + delete[] _basePath; + _basePath = NULL; + + return STATUS_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + return NULL; + } + + /* + if (File->GetSize() > MAX_FILE_SIZE) { + _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[file->size() + 1]; + if (buffer == NULL) { + _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + closeFile(file); + delete [] buffer; + return NULL; + }; + + buffer[file->size()] = '\0'; + if (size != NULL) *size = file->size(); + closeFile(file); + + return buffer; +} + +Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::InSaveFile *file = saveMan->openForLoading(filename); + return file; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { + // TODO + warning("Implement SaveFile"); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + file->finalize(); + delete file; +#if 0 + RestoreCurrentDir(); + + CBUtils::CreatePath(filename, false); + + FILE *f = fopen(filename, "wb"); + if (!f) { + _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); + return STATUS_FAILED; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { + // unmount all non-local packages + for (int i = 0; i < _packages.size(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->close(); + } + + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; + + bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); + + char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return STATUS_FAILED; + + strcpy(buffer, path.c_str()); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (type) { + case PATH_SINGLE: + _singlePaths.push_back(buffer); + break; + case PATH_PACKAGE: + _packagePaths.push_back(buffer); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::reloadPaths() { + // delete registered paths + for (int i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (int i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + return initPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::initPaths() { + restoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_SINGLE, ".\\"); + + + // package files paths + addPath(PATH_PACKAGE, "./"); + + pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_PACKAGE, "data"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackages() { + restoreCurrentDir(); + + _gameRef->LOG(0, "Scanning packages..."); + debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.dcp"); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + registerPackage((*it)->getName().c_str()); + } +#if 0 + AnsiString extension = AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < _packagePaths.getSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); + + //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } +#endif + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +// FILE *f = fopen(filename, "rb"); + Common::File *package = new Common::File(); + package->open(filename); + if (!package->isOpen()) { + _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + return STATUS_OK; + } + + uint32 absoluteOffset = 0; + bool boundToExe = false; + + if (searchSignature) { + uint32 Offset; + if (!findPackageSignature(package, &Offset)) { + delete package; + return STATUS_OK; + } else { + package->seek(Offset, SEEK_SET); + absoluteOffset = Offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete package; + return STATUS_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = package->readUint32LE(); + dirOffset += absoluteOffset; + package->seek(dirOffset, SEEK_SET); + } + + for (uint32 i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(_gameRef); + if (!pkg) return STATUS_FAILED; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = package->readByte(); + pkg->_name = new char[nameLength]; + package->read(pkg->_name, nameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (uint32 j = 0; j < NumFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = package->readByte(); + name = new char[nameLength]; + package->read(name, nameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + + CBPlatform::strupr(name); + + offset = package->readUint32LE(); + offset += absoluteOffset; + length = package->readUint32LE(); + compLength = package->readUint32LE(); + flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + timeDate1 = package->readUint32LE(); + timeDate2 = package->readUint32LE(); + } + _filesIter = _files.find(name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(_gameRef); + file->_package = pkg; + file->_offset = offset; + file->_length = length; + file->_compressedLength = compLength; + file->_flags = flags; + + _files[name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = offset; + _filesIter->_value->_length = length; + _filesIter->_value->_compressedLength = compLength; + _filesIter->_value->_flags = flags; + } + } + delete [] name; + } + } + + + delete package; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::isValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::startsWith(plainName, "xdevice_", true)) { + return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openPackage(const Common::String &name) { + //TODO: Is it really necessary to do this when we have the ScummVM-system? + + //RestoreCurrentDir(); + + Common::File *ret = new Common::File(); + char filename[MAX_PATH_LENGTH]; + + for (int i = 0; i < _packagePaths.size(); i++) { + sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + } + + sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + delete ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openSingleFile(const Common::String &name) { + restoreCurrentDir(); + + Common::File *ret = NULL; + char filename[MAX_PATH_LENGTH]; + + for (int i = 0; i < _singlePaths.size(); i++) { + sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); + ret->open(filename); + if (ret->isOpen()) + return ret; + } + + // didn't find in search paths, try to open directly + ret->open(name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { + restoreCurrentDir(); + + Common::File f; + bool found = false; + + for (int i = 0; i < _singlePaths.size(); i++) { + sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); + f.open(fullname); + if (f.isOpen()) { + f.close(); + found = true; + break; + } + } + + if (!found) { + f.open(filename.c_str()); + if (f.isOpen()) { + f.close(); + found = true; + strcpy(fullname, filename.c_str()); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { + char *upc_name = new char[strlen(filename.c_str()) + 1]; + strcpy(upc_name, filename.c_str()); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; + + delete [] upc_name; + + return ret; +} + +bool CBFileManager::hasFile(const Common::String &filename) { + //TODO: Do this in a much simpler fashion + Common::SeekableReadStream *stream = openFile(filename, true, false); + if (!stream) { + return false; + } + delete stream; + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) return NULL; + //_gameRef->LOG(0, "open file: %s", filename); + /*#ifdef __WIN32__ + if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); + } + } + #endif*/ + + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) _openFiles.push_back(file); + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::closeFile(Common::SeekableReadStream *File) { + for (int i = 0; i < _openFiles.size(); i++) { + if (_openFiles[i] == File) { + delete _openFiles[i]; + _openFiles.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { + restoreCurrentDir(); + + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + if (DID_SUCCEED(SaveThumbFile->open(filename))) { + ret = SaveThumbFile->getMemStream(); + } + delete SaveThumbFile; + return ret; + } + + + + ret = openDiskFile(filename, this); + if (ret) return ret; + + ret = openPkgFile(filename, this); + if (ret) return ret; + + ret = CBResources::getFile(filename); + if (ret) return ret; + + warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::restoreCurrentDir() { + if (!_basePath) return STATUS_OK; + else { + /*if (!chdir(_basePath)) return STATUS_OK; + else return STATUS_FAILED;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::setBasePath(const Common::String &path) { + cleanup(); + + if (path.c_str()) { + _basePath = new char[path.size() + 1]; + strcpy(_basePath, path.c_str()); + } + + initPaths(); + registerPackages(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h new file mode 100644 index 0000000000..8e7551480d --- /dev/null +++ b/engines/wintermute/base/BFileManager.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + +#include "engines/wintermute/base/BFileEntry.h" +#include "common/archive.h" +#include "common/str.h" + +namespace Common { +class File; +} + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool findPackageSignature(Common::File *f, uint32 *offset); + bool cleanup(); + bool setBasePath(const Common::String &path); + bool restoreCurrentDir(); + char *_basePath; + bool getFullPath(const Common::String &filename, char *fullname); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *getPackageEntry(const Common::String &filename); + Common::File *openSingleFile(const Common::String &name); + Common::File *openPackage(const Common::String &name); + bool registerPackages(); + bool initPaths(); + bool reloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + bool addPath(TPathType type, const Common::String &path); + bool requestCD(int cd, char *packageFile, const char *filename); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + Common::Array _singlePaths; + Common::Array _packagePaths; + Common::Array _packages; + Common::Array _openFiles; + + Common::HashMap _files; +private: + bool registerPackage(const Common::String &filename, bool searchSignature = false); + Common::HashMap::iterator _filesIter; + bool isValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp new file mode 100644 index 0000000000..4af9262701 --- /dev/null +++ b/engines/wintermute/base/BFrame.cpp @@ -0,0 +1,705 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete _sound; + _sound = NULL; + + for (int i = 0; i < _subframes.getSize(); i++) + delete _subframes[i]; + _subframes.removeAll(); + + for (int i = 0; i < _applyEvent.getSize(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.removeAll(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; + + for (int i = 0; i < _subframes.getSize(); i++) { + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); + if (DID_FAIL(res)) return res; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) owner->updateOneSound(_sound); + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (int i = 0; i < _applyEvent.getSize(); i++) { + owner->applyEvent(_applyEvent[i]); + } + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; + CBPlatform::setRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.scanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); + break; + + case TOKEN_MOVE: + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &mirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &editorSelected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.scanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.scanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(_gameRef); + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else _subframes.add(subframe); + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { + if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + _applyEvent.add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.scanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FRAME definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading FRAME definition"); + return STATUS_FAILED; + } + + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (surface_file != NULL) { + if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + + if (!sub->_surface) { + delete sub; + _gameRef->LOG(0, "Error loading SUBFRAME"); + return STATUS_FAILED; + } + + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } + + if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + else sub->_rect = rect; + + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; + + + sub->_editorSelected = editorSelected; + _subframes.insertAt(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + CBPlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (int i = 0; i < _subframes.getSize(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + + if (_sound && _sound->_soundFilename) + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + + if (_editorExpanded) + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + + if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + + for (int i = 1; i < _subframes.getSize(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (int i = 0; i < _applyEvent.getSize(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + CBBase::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + _applyEvent.persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { + stack->pushBool(false); + delete _sound; + _sound = NULL; + } else stack->pushBool(true); + } else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushNative(_subframes[index], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + CBSubFrame *sub = (CBSubFrame *)val->getNative(); + for (int i = 0; i < _subframes.getSize(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + sub->setDefaultRect(); + } + _subframes.add(sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertSubframe") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= _subframes.getSize()) _subframes.add(sub); + else _subframes.insertAt(index, sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _applyEvent.getSize()) { + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushString(_applyEvent[index]); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + stack->pushNULL(); + return STATUS_OK; + } + } + _applyEvent.add(event); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.removeAt(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delay") == 0) { + _scValue->setInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _scValue->setBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _scValue->setBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _scValue->setInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _scValue->setInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumSubframes") == 0) { + _scValue->setInt(_subframes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); + else return CBScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Delay") == 0) { + _delay = MAX(0, value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _keyframe = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _killSound = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _moveX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _moveY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); + else return CBScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBFrame::scToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFrame.h b/engines/wintermute/base/BFrame.h new file mode 100644 index 0000000000..3d487b4ebc --- /dev/null +++ b/engines/wintermute/base/BFrame.h @@ -0,0 +1,73 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool _killSound; + bool _keyframe; + bool oneTimeDisplay(CBObject *owner, bool muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *_sound; + bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool saveAsText(CBDynBuffer *buffer, int indent); + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray _applyEvent; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BGame.cpp b/engines/wintermute/base/BGame.cpp new file mode 100644 index 0000000000..3e577541b7 --- /dev/null +++ b/engines/wintermute/base/BGame.cpp @@ -0,0 +1,4478 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFader.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BQuickMsg.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BSubFrame.h" + +#include "engines/wintermute/base/BTransitionMgr.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _debugAbsolutePathWarning = true; + _debugShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _videoPlayer = NULL; + _theoraPlayer = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + _doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _localSaveDir = NULL; + CBUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + CBPlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + +/*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices +#else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + getDebugMgr()->onGameShutdown(); + + _registry->writeBool("System", "LastRun", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _saveLoadImage; + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _saveLoadImage = NULL; + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::outputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::cleanup() { + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + unregisterObject(_fader); + _fader = NULL; + + for (int i = 0; i < _regObjects.getSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.removeAll(); + + _windows.removeAll(); // refs only + _focusedWindow = NULL; // ref only + + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (int i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.removeAll(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + _quickMessages.removeAll(); + + _viewportStack.removeAll(); + _viewportSP = -1; + + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) + break; + + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) + break; + + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) + break; + + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) + break; + + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) + break; + + _mathClass = new CSXMath(this); + if (_mathClass == NULL) + break; + + _scEngine = new CScEngine(this); + if (_scEngine == NULL) + break; + + _videoPlayer = new CVidPlayer(this); + if (_videoPlayer == NULL) + break; + + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) + break; + + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) + break; + + _fader = new CBFader(this); + if (_fader == NULL) + break; + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _debugMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _fileManager; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) return STATUS_FAILED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + #ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #endif*/ + int secs = g_system->getMillis() / 1000; + int hours = secs / 3600; + secs = secs % 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + if (_debugMgr) _debugMgr->onLog(res, buff); + + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initLoop() { + _viewportSP = -1; + + _currentTime = CBPlatform::getTime(); + + getDebugMgr()->onGameTick(); + _renderer->initLoop(); + _soundMgr->initLoop(); + updateMusicCrossfade(); + + _surfaceStorage->initLoop(); + _fontStorage->initLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //_gameRef->LOG(0, "%d", _fps); + + getMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) _fader->update(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) *offsetX = _offsetX; + if (offsetY != NULL) *offsetY = _offsetY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + _gameRef->LOG(0, "'GAME' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _systemFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + _videoFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.scanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.scanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.scanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.scanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.scanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.scanStr((char *)params, "%d", &_indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.scanStr((char *)params, "%d", &_indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + _indicatorColor = BYTETORGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.scanStr((char *)params, "%d", &_indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.scanStr((char *)params, "%d", &_indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::setString(&_saveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.scanStr((char *)params, "%d", &_saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::setString(&_loadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.scanStr((char *)params, "%d", &_loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + LOG(0, stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + bool res = CBObject::scCallMethod(script, stack, thisStack, name); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Msg") == 0) { + stack->correctParams(1); + quickMessage(stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RunScript") == 0) { + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + stack->correctParams(1); + if (DID_FAIL(addScript(stack->pop()->getString()))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadStringTable") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + CScValue *Val = stack->pop(); + + bool ClearOld; + if (Val->isNULL()) ClearOld = true; + else ClearOld = Val->getBool(); + + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidObject") == 0) { + stack->correctParams(1); + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *) obj)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + resetContent(); + stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CBObject *obj = (CBObject *)val->getNative(); + unregisterObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadWindow") == 0) { + stack->correctParams(1); + CUIWindow *win = new CUIWindow(_gameRef); + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { + _windows.add(win); + registerObject(win); + stack->pushNative(win, true); + } else { + delete win; + win = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExpandString") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); + _stringTable->expand(&str); + stack->pushString(str); + delete [] str; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); + else { + stack->correctParams(4); + channel = stack->pop()->getInt(); + } + + const char *filename = stack->pop()->getString(); + CScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + CScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); + + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); + else { + if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); + else stack->pushString(_music[channel]->_soundFilename); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + uint32 time = stack->pop()->getInt(); + + if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); + else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { + int channel = 0; + if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else stack->pushBool(_music[channel]->isPlaying()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + int volume = stack->pop()->getInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); + else stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getVolumePercent()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->correctParams(4); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); + + if (_musicCrossfadeRunning) { + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->pushBool(false); + return STATUS_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; + + _musicCrossfadeRunning = true; + + stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundLength") == 0) { + stack->correctParams(1); + + int length = 0; + const char *filename = stack->pop()->getString(); + + CBSound *sound = new CBSound(_gameRef); + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; + } + stack->pushInt(length); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMousePos") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + Point32 p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LockMouseRect") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + if (right < left) CBUtils::swap(&left, &right); + if (bottom < top) CBUtils::swap(&top, &bottom); + + CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK; + // TODO: ADDVIDEO + */ + + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + stack->correctParams(6); + const char *filename = stack->pop()->getString(); + warning("PlayVideo: %s - not implemented yet", filename); + CScValue *valType = stack->pop(); + int Type; + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + Type = (int)VID_PLAY_STRETCH; + + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK;*/ + // TODO: ADDVIDEO + + stack->correctParams(7); + const char *filename = stack->pop()->getString(); + CScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) + type = (int)VID_PLAY_STRETCH; + else type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else { + stack->pushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QuitGame") == 0) { + stack->correctParams(0); + stack->pushNULL(); + _quitting = true; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + _registry->writeInt("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + _registry->writeString("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + AnsiString val = _registry->readString("PrivateSettings", key, initVal); + stack->pushString(val.c_str()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveGame") == 0) { + stack->correctParams(3); + int slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); + + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); + stack->pushBool(true); + if (DID_FAIL(SaveGame(slot, desc, quick))) { + stack->pop(); + stack->pushBool(false); + } + delete [] desc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadGame") == 0) { + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->getInt(); + _loading = true; + stack->pushBool(false); + script->sleep(0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->correctParams(1); + int Slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(Slot)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + emptySaveSlot(slot); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); + else stack->pushString(_activeCursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->correctParams(0); + if (!_activeCursor) stack->pushNULL(); + else stack->pushNative(_activeCursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->correctParams(0); + delete _activeCursor; + _activeCursor = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->correctParams(0); + + if (_activeCursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FileExists") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + // TODO: Replace with fileExists + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (!file) stack->pushBool(false); + else { + _fileManager->closeFile(file); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Screenshot") == 0) { + stack->correctParams(1); + char filename[MAX_PATH_LENGTH]; + + CScValue *Val = stack->pop(); + + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO + int fileNum = 0; + + while (true) { + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + if (!Common::File::exists(filename)) + break; + fileNum++; + } + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + _windows.add(win); + registerObject(win); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CBObject *obj = (CBObject *)stack->pop()->getNative(); + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == obj) { + unregisterObject(_windows[i]); + stack->pushBool(true); + return STATUS_OK; + } + } + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenDocument") == 0) { + stack->correctParams(0); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->correctParams(0); + DEBUG_DumpClassRegistry(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _loadImageX = stack->pop()->getInt(); + _loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _loadImageName; + _loadImageName = NULL; + } else { + CBUtils::setString(&_loadImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _saveImageX = stack->pop()->getInt(); + _saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _saveImageName; + _saveImageName = NULL; + } else { + CBUtils::setString(&_saveImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->correctParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive) stack->pushNULL(); + else stack->pushNative(_cursorNoninteractive, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->correctParams(4); + + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + displayContent(false, true); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->correctParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _renderer->dumpData(filename); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccOutputText") == 0) { + stack->correctParams(2); + /* const char *Str = */ + stack->pop()->getString(); + /* int Type = */ + stack->pop()->getInt(); + // do nothing + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool asHex = stack->pop()->getBool(false); + + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (file) { + crc remainder = crc_initialize(); + byte buf[1024]; + int bytesRead = 0; + + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); + + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (asHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + stack->pushString(Hex); + } else + stack->pushInt(checksum); + + _fileManager->closeFile(file); + file = NULL; + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->enableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->disableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Hwnd") == 0) { + _scValue->setInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentTime") == 0) { + _scValue->setInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowsTime") == 0) { + _scValue->setInt((int)CBPlatform::getTime()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowedMode") == 0) { + _scValue->setBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _scValue->setInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _scValue->setInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + _scValue->setNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ActiveObject") == 0) { + _scValue->setNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenWidth") == 0) { + _scValue->setInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenHeight") == 0) { + _scValue->setInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + _scValue->setBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DebugMode") == 0) { + _scValue->setBool(_debugDebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundAvailable") == 0) { + _scValue->setBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyboard") == 0) { + if (_keyboardState) _scValue->setNative(_keyboardState, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _scValue->setBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _scValue->setInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _scValue->setBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FPS") == 0) { + _scValue->setInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + _scValue->setBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + _scValue->setInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _scValue->setBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _scValue->setInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _scValue->setBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _scValue->setBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Frozen") == 0) { + _scValue->setBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSTalk") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSCaptions") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSKeypress") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardPause") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _scValue->setBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveDirectory") == 0) { + AnsiString dataDir = getDataDir(); + _scValue->setString(dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _scValue->setBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _scValue->setInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _scValue->setBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Platform") == 0) { + _scValue->setString(CBPlatform::getPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeviceType") == 0) { + _scValue->setString(getDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MostRecentSaveSlot") == 0) { + _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Store") == 0) { + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); + + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _mousePos.x = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _mousePos.y = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + bool res = CBObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + CBScriptable *obj = value->getNative(); + if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + setInteractive(value->getBool()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _subtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _videoSubtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + int Enc = value->getInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + _textEncoding = (TTextEncoding)Enc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _textRTL = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = value->getInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _suspendedRendering = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _autorunDisabled = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _autoSaveSlot = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _cursorHidden = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayQuickMsg() { + if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + + // update + for (int i = 0; i < _quickMessages.getSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.removeAt(i); + i--; + } + } + + int posY = 20; + + // display + for (int i = 0; i < _quickMessages.getSize(); i++) { + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessage(const char *text) { + if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.removeAt(0); + } + _quickMessages.add(new CBQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::registerObject(CBObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unregisterObject(CBObject *object) { + if (!object) return STATUS_OK; + + // is it a window? + for (int i = 0; i < _windows.getSize(); i++) { + if ((CBObject *)_windows[i] == object) { + _windows.removeAt(i); + + // get new focused window + if (_focusedWindow == object) _focusedWindow = NULL; + + break; + } + } + + // is it active object? + if (_activeObject == object) _activeObject = NULL; + + // is it main object? + if (_mainObject == object) _mainObject = NULL; + + // destroy object + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) { + _regObjects.removeAt(i); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::invalidateValues(void *value, void *data) { + CScValue *val = (CScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { + ((CBScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::validObject(CBObject *object) { + if (!object) return false; + if (object == this) return true; + + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "String") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXString(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MemBuffer") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "File") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXFile(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Date") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXDate(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Array") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXArray(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Object") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXObject(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sleep") == 0) { + stack->correctParams(1); + + script->sleep((uint32)stack->pop()->getInt()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WaitFor") == 0) { + stack->correctParams(1); + + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Random") == 0) { + stack->correctParams(2); + + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); + + stack->pushInt(CBUtils::randomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->correctParams(1); + + script->_timeSlice = (uint32)stack->pop()->getInt(); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->correctParams(4); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); + int a; + CScValue *val = stack->pop(); + if (val->isNULL()) a = 255; + else a = val->getInt(); + + stack->pushInt(BYTETORGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeHSL") == 0) { + stack->correctParams(3); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); + + stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(0); + + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); + script->sleep(0); + } + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToString") == 0) { + stack->correctParams(1); + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete [] str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToInt") == 0) { + stack->correctParams(1); + int val = stack->pop()->getInt(); + stack->pushInt(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToFloat") == 0) { + stack->correctParams(1); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + stack->pushBool(val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + script->runtimeError("Call to undefined function '%s'. Ignored.", name); + stack->correctParams(0); + stack->pushNULL(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (!_interactive && _gameRef->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + } else { + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; + else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); + else if (_cursor) return drawCursor(_cursor); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + LOG(0, "Saving game '%s'...", filename); + + _gameRef->applyEvent("BeforeSave", true); + + bool ret; + + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } + + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + + _registry->writeInt("System", "MostRecentSaveSlot", slot); + +save_finish: // TODO: Remove gotos + delete pm; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + return loadGame(filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(const char *filename) { + LOG(0, "Loading game '%s'...", filename); + getDebugMgr()->onGameShutdown(); + + bool ret; + + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + + + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + _debugAbsolutePathWarning = false; + if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + + //if(DID_FAIL(ret = cleanup())) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + +load_finish: + _debugAbsolutePathWarning = true; + + _indicatorDisplay = false; + delete pm; + _loadInProgress = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::initAfterLoad() { + CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); + + _scEngine->refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadRegion(void *region, void *data) { + ((CBRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSubFrame(void *subframe, void *data) { + ((CBSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSound(void *sound, void *data) { + ((CBSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadFont(void *font, void *data) { + ((CBFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadScript(void *script, void *data) { + ((CScScript *)script)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayWindows(bool inGame) { + bool res; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) return res; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + delete _music[channel]; + _music[channel] = NULL; + + _music[channel] = new CBSound(_gameRef); + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; + } + if (loopStart) _music[channel]->setLoopStart(loopStart); + return _music[channel]->play(looping); + } else { + delete _music[channel]; + _music[channel] = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setMusicStartTime(int channel, uint32 time) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadSettings(const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return STATUS_FAILED; + } + buffer = params; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.scanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.scanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + _registry->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::setString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); + ret = STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading game settings '%s'", filename); + ret = STATUS_FAILED; + } + + _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; + + delete [] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) + cleanup(); + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_doNotExpandStrings)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); + } + + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); + + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); + + _regObjects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); + + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); + + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); + + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); + + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); + + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); + + persistMgr->transfer(TMEMBER(_mouseLockRect)); + + _windows.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); + + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); + + if (!persistMgr->_saving) + _quitting = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::focusWindow(CUIWindow *Window) { + CUIWindow *Prev = _focusedWindow; + + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.getSize() - 1) { + _windows.removeAt(i); + _windows.add(Window); + + _gameRef->_focusedWindow = Window; + } + + if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + return focusWindow(Prev); + else return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::freeze(bool includingMusic) { + if (_freezeLevel == 0) { + _scEngine->pauseAll(); + _soundMgr->pauseAll(includingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unfreeze() { + if (_freezeLevel == 0) return STATUS_OK; + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleKeypress(Common::Event *event, bool printable) { + if (isVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + stopVideo(); + return true; + } + + if (event->type == Common::EVENT_QUIT) { + onWindowClose(); + return true; + } + + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. + _renderer->switchFullscreen(); + return true; + } + + + _keyboardState->handleKeyPress(event); + _keyboardState->readKey(event); +// TODO + + if (_focusedWindow) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + /*if (event->type != SDL_TEXTINPUT) {*/ + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + _gameRef->_focusedWindow->applyEvent("Keypress"); + else + applyEvent("Keypress"); + /*}*/ + } + return true; + } else { /*if (event->type != SDL_TEXTINPUT)*/ + applyEvent("Keypress"); + return true; + } //else return true; + + return false; +} + +void CBGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleMouseWheel(int Delta) { + bool handled = false; + if (_focusedWindow) { + handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + + if (!handled) { + if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); + handled = true; + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); + handled = true; + } + + } + } + + if (!handled) { + if (Delta < 0) { + applyEvent("MouseWheelDown"); + } else { + applyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) *verMajor = DCGF_VER_MAJOR; + if (verMinor) *verMinor = DCGF_VER_MINOR; + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setWindowTitle() { + if (_renderer) { + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') strcat(title, " - "); + strcat(title, "WME Lite"); + + + Utf8String utf8Title; + if (_textEncoding == TEXT_UTF8) { + utf8Title = Utf8String(title); + } else { + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } +#if 0 + CBRenderOSystem *renderer = static_cast(_renderer); + // TODO + + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotFilename(int slot, char *buffer) { + AnsiString dataDir = getDataDir(); + //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + strcpy(buffer, filename.c_str()); + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDataDir() { + AnsiString userDir = PathUtil::getUserDirectory(); + AnsiString baseDir = _registry->getBasePath(); + return PathUtil::combine(userDir, baseDir); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(filename))) { + _debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + + _debugAbsolutePathWarning = true; + strcpy(buffer, pm->_savedDescription); + delete pm; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isSaveSlotUsed(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!File) return false; + delete File; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::emptySaveSlot(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(this); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setActiveObject(CBObject *obj) { + // not-active when game is frozen + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; + } + + if (obj == _activeObject) return STATUS_OK; + + if (_activeObject) _activeObject->applyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + _activeObject = obj; + if (_activeObject) { + _activeObject->applyEvent("MouseEntry"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pushViewport(CBViewport *viewport) { + _viewportSP++; + if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); + else _viewportStack[_viewportSP] = viewport; + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) return STATUS_FAILED; + else { + if (_viewportSP >= 0) { + CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) *custom = true; + } else { + CBPlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) *custom = false; + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { + if (_viewportSP >= 0) { + if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; + if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) _transMgr->_origInteractive = state; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + if (_indicatorDisplay) displayIndicator(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayIndicator() { + if (_saveLoadImage) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + _renderer->setupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + + _renderer->setup2D(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::updateMusicCrossfade() { + /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + + if (!_musicCrossfadeRunning) return STATUS_OK; + if (_state == GAME_FROZEN) return STATUS_OK; + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + + if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); + if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; + + if (currentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); + + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); + + + if (_musicCrossfadeSwap) { + // swap channels + CBSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + CSysClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::invalidateDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::restoreDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) return true; + if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopVideo() { + if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return STATUS_FAILED; + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool CBGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) return STATUS_OK; + + _renderer->_active = activate; + + if (refreshMouse) { + Point32 p; + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); + } + + if (activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + return STATUS_OK; + } else return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayDebugInfo() { + char str[100]; + + if (_debugShowFPS) { + sprintf(str, "FPS: %d", _gameRef->_fps); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (_gameRef->_debugDebugMode) { + if (!_gameRef->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + else + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + + strcat(str, " ("); + strcat(str, _renderer->getName()); + strcat(str, ")"); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->displayDebugInfo(); + + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::getMousePos(Point32 *pos) { + CBPlatform::getCursorPos(pos); + + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { + Common::Rect rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= _gameRef->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= _gameRef->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); + + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); + + Point32 newPos = *pos; + + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::miniUpdate() { + if (!_miniUpdateEnabled) return STATUS_OK; + + if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->initLoop(); + _lastMiniUpdate = CBPlatform::getTime(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 pos; + CBPlatform::getCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); + + + if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = CBPlatform::getTime(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; + return false; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + _registry->saveValues(); + + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; + + SaveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BGame.h b/engines/wintermute/base/BGame.h new file mode 100644 index 0000000000..7441d81b07 --- /dev/null +++ b/engines/wintermute/base/BGame.h @@ -0,0 +1,391 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +#include "engines/wintermute/base/BDebugger.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/Rect32.h" +#include "common/events.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); + +class CBSoundMgr; +class CBFader; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRenderer; +class CBRegistry; +class CBSaveThumbHelper; +class CBSurfaceStorage; +class CSXMath; +class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) + + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); + + bool isLeftDoubleClick(); + bool isRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual bool miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + char *_localSaveDir; + bool _saveDirChecked; + + int _indicatorProgress; +protected: + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + CBSurface *_saveLoadImage; + bool displayIndicator(); + + bool _reportTextureFormat; +public: + int _thumbnailWidth; + int _thumbnailHeight; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; + + bool _doNotExpandStrings; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; + CBDebugger *getDebugMgr(); + + void LOG(bool res, const char *fmt, ...); + + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; + CBGame(); + + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + bool _debugAbsolutePathWarning; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + + CBStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; +protected: + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + CBFader *_fader; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); +public: + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + +private: + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; +public: + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + virtual bool handleMouseWheel(int delta); + bool _quitting; + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual void handleKeyRelease(Common::Event *event); +protected: + int _freezeLevel; +public: + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(CUIWindow *window); + CVidPlayer *_videoPlayer; + CVidTheoraPlayer *_theoraPlayer; + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; +protected: + static void afterLoadRegion(void *region, void *data); + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +public: + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); + CBRegistry *_registry; + bool _useD3D; + virtual bool cleanup(); + virtual bool loadGame(int slot); + virtual bool loadGame(const char *filename); + virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + Point32 _mousePos; + bool validObject(CBObject *object); + bool unregisterObject(CBObject *object); + bool registerObject(CBObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + + CBArray _regObjects; +public: + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); + bool _forceNonStreamedSounds; + void resetMousePos(); + int _subtitlesSpeed; + void setInteractive(bool state); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(CBViewport *Viewport); + bool setActiveObject(CBObject *Obj); + CBSprite *_lastCursor; + bool drawCursor(CBSprite *Cursor); + + virtual bool initAfterLoad(); + CBSaveThumbHelper *_cachedThumbnail; + AnsiString getDataDir(); + void addMem(int bytes); + + bool _touchInterface; + bool _constrainedMemory; + AnsiString getDeviceType() const; + +private: + CBDebugger *_debugMgr; + + struct LastClickInfo { + LastClickInfo() { + posX = posY = 0; + time = 0; + } + + int posX; + int posY; + uint32 time; + }; + + LastClickInfo _lastClick[2]; + bool isDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void autoSaveOnExit(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BKeyboardState.cpp b/engines/wintermute/base/BKeyboardState.cpp new file mode 100644 index 0000000000..85ab15f58e --- /dev/null +++ b/engines/wintermute/base/BKeyboardState.cpp @@ -0,0 +1,304 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + delete[] _keyStates; +} + +void CBKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void CBKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; + } else vKey = val->getInt(); + + warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->setString(key); + } else _scValue->setString(""); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Printable") == 0) { + _scValue->setBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KeyCode") == 0) { + _scValue->setInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsShift") == 0) { + _scValue->setBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsAlt") == 0) { + _scValue->setBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsControl") == 0) { + _scValue->setBool(_currentControl); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::readKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = keyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { + //if(!persistMgr->_saving) cleanup(); + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); + + if (!persistMgr->_saving) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +enum VKeyCodes { + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BKeyboardState.h b/engines/wintermute/base/BKeyboardState.h new file mode 100644 index 0000000000..e3a4a903f7 --- /dev/null +++ b/engines/wintermute/base/BKeyboardState.h @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BScriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + bool readKey(Common::Event *event); + + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + uint8 *_keyStates; + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BNamedObject.cpp b/engines/wintermute/base/BNamedObject.cpp new file mode 100644 index 0000000000..9587da45e8 --- /dev/null +++ b/engines/wintermute/base/BNamedObject.cpp @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BNamedObject.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::setName(const char *name) { + delete[] _name; + + _name = new char [strlen(name) + 1]; + if (_name != NULL) strcpy(_name, name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BNamedObject.h b/engines/wintermute/base/BNamedObject.h new file mode 100644 index 0000000000..4d5fdb0c0e --- /dev/null +++ b/engines/wintermute/base/BNamedObject.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *_name; + void setName(const char *name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp new file mode 100644 index 0000000000..1bb52c0ce6 --- /dev/null +++ b/engines/wintermute/base/BObject.cpp @@ -0,0 +1,1128 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = _gameRef->getSequence(); + + CBPlatform::setRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) + _caption[i] = NULL; + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) + _gameRef->_activeObject = NULL; + + CBScriptHolder::cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) + return; + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::getCaption(int caseVal) { + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else return _caption[caseVal - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + afterMove(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->getInt())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveCursor") == 0) { + stack->correctParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursor") == 0) { + stack->correctParams(0); + if (!_cursor || !_cursor->_filename) stack->pushNULL(); + else stack->pushString(_cursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursorObject") == 0) { + stack->correctParams(0); + if (!_cursor) stack->pushNULL(); + else stack->pushNative(_cursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasCursor") == 0) { + stack->correctParams(0); + + if (_cursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCaption") == 0) { + stack->correctParams(2); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadSound") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + if (DID_SUCCEED(playSFX(filename, false, false))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySound") == 0) { + stack->correctParams(3); + + const char *filename; + bool looping; + uint32 loopStart; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + + if (val1->_type == VAL_BOOL) { + filename = NULL; + looping = val1->getBool(); + loopStart = val2->getInt(); + } else { + if (val1->isNULL()) filename = NULL; + else filename = val1->getString(); + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); + } + + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->correctParams(2); + + const char *filename; + const char *eventName; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + + if (val2->isNULL()) { + filename = NULL; + eventName = val1->getString(); + } else { + filename = val1->getString(); + eventName = val2->getString(); + } + + if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(pauseSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(resumeSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->correctParams(0); + + if (_sFX && _sFX->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->correctParams(1); + + uint32 Time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(0); + else stack->pushInt(_sFX->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->correctParams(1); + + int volume = stack->pop()->getInt(); + if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(_sFXVolume); + else stack->pushInt(_sFX->getVolumePercent()); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXNone") == 0) { + stack->correctParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->correctParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->correctParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + _scValue->setString(getCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(getHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ready") == 0) { + _scValue->setBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _scValue->setBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _scValue->setBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _scValue->setBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _scValue->setBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + _scValue->setInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (_scale < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (_scaleX < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (_scaleY < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _scValue->setFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (!_rotateValid) _scValue->setNULL(); + else _scValue->setFloat((double)_rotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _scValue->setFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _scValue->setBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _scValue->setBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _scValue->setBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _scValue->setBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + _scValue->setNULL(); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Caption") == 0) { + setCaption(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _movable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _registrable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _zoomable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _rotatable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alphaColor = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + int i = value->getInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + _blendMode = (TSpriteBlendMode)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (value->isNULL()) _scale = -1; + else _scale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (value->isNULL()) _scaleX = -1; + else _scaleX = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (value->isNULL()) _scaleY = -1; + else _scaleY = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _relativeScale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (value->isNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)value->getFloat(); + _rotateValid = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _relativeRotate = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _shadowable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _autoSoundPanning = value->getBool(); + if (!_autoSoundPanning) resetSoundPan(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _saveState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::showCursor() { + if (_cursor) return _gameRef->drawCursor(_cursor); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { + // just play loaded sound + if (filename == NULL && _sFX) { + if (_gameRef->_editorMode || _sFXStart) { + _sFX->setVolumePercent(_sFXVolume); + _sFX->setPositionTime(_sFXStart); + if (!_gameRef->_editorMode) _sFXStart = 0; + } + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } + + if (filename == NULL) return STATUS_FAILED; + + // create new sound + delete _sFX; + + _sFX = new CBSound(_gameRef); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); + if (_sFXStart) { + _sFX->setPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } else { + delete _sFX; + _sFX = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::pauseSFX() { + if (_sFX) return _sFX->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resumeSFX() { + if (_sFX) return _sFX->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) return _sFX->setVolumePercent(volume); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) updateOneSound(_sFX); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateOneSound(CBSound *sound) { + bool Ret = STATUS_OK; + + if (sound) { + if (_autoSoundPanning) + Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + + Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resetSoundPan() { + if (!_sFX) return STATUS_OK; + else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, eventName); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BObject.h b/engines/wintermute/base/BObject.h new file mode 100644 index 0000000000..c855c770b7 --- /dev/null +++ b/engines/wintermute/base/BObject.h @@ -0,0 +1,144 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "engines/wintermute/base/BScriptHolder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(CBSound *sound); + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + CBSound *_sFX; + + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + + virtual bool handleMouseWheel(int delta); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); + const char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual bool showCursor(); + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + Rect32 _rect; + bool _rectSet; + int _iD; + bool _movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; + + // base + virtual bool update() { + return STATUS_FAILED; + }; + virtual bool display() { + return STATUS_FAILED; + }; + virtual bool invalidateDeviceObjects() { + return STATUS_OK; + }; + virtual bool restoreDeviceObjects() { + return STATUS_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPackage.cpp b/engines/wintermute/base/BPackage.cpp new file mode 100644 index 0000000000..020b7b902f --- /dev/null +++ b/engines/wintermute/base/BPackage.cpp @@ -0,0 +1,104 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPackage.h b/engines/wintermute/base/BPackage.h new file mode 100644 index 0000000000..8c803fddd9 --- /dev/null +++ b/engines/wintermute/base/BPackage.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/BBase.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp new file mode 100644 index 0000000000..f675d0ca50 --- /dev/null +++ b/engines/wintermute/base/BParser.cpp @@ -0,0 +1,436 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (_whiteSpace != NULL) delete [] _whiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + skipCharacters(buf, _whiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else strcpy(_lastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + skipCharacters(buf, _whiteSpace); + + // get optional name + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = getAssignmentText(buf); + else + *data = getSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + _gameRef->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') _parserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getAssignmentText(char **buf) { + ++*buf; // skip the '=' + skipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = getSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::getToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::getTokenFloat(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::getTokenInt(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { + char *t = getToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::scanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BParser.h b/engines/wintermute/base/BParser.h new file mode 100644 index 0000000000..ae886953a9 --- /dev/null +++ b/engines/wintermute/base/BParser.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, TokenDesc *tokens, char **params); + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + char *getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + char *_whiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp new file mode 100644 index 0000000000..0f2cc6bc8a --- /dev/null +++ b/engines/wintermute/base/BPersistMgr.cpp @@ -0,0 +1,778 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BPersistMgr.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BSound.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + delete[] _savedDescription; + _savedDescription = NULL; // ref to buffer +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; + } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; +} + +Common::String CBPersistMgr::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); +} + +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void CBPersistMgr::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 CBPersistMgr::getMaxUsedSlot() { + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); it++) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool CBPersistMgr::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initSave(const char *desc) { + if (!desc) return STATUS_FAILED; + + cleanup(); + _saving = true; + + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); + + if (_saveStream) { + // get thumbnails + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + } + } + + uint32 magic = DCGF_MAGIC; + putDWORD(magic); + + magic = SAVE_MAGIC_2; + putDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(VerMajor); + _saveStream->writeByte(VerMinor); + _saveStream->writeByte(ExtMajor); + _saveStream->writeByte(ExtMinor); + + // new in ver 2 + putDWORD((uint32)DCGF_VER_BUILD); + putString(_gameRef->_name); + + // thumbnail data size + bool thumbnailOK = false; + + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } + + thumbnailOK = true; + } + } + if (!thumbnailOK) putDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + + uint32 dataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(desc) + 1 + // description + sizeof(uint32); // timestamp + + putDWORD(dataOffset); + putString(desc); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); + } + return STATUS_OK; +} + +bool CBPersistMgr::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + if (_loadStream) { + uint32 magic; + magic = getDWORD(); + + if (magic != DCGF_MAGIC) { + cleanup(); + return STATUS_FAILED; + } + + magic = getDWORD(); + + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); + + if (magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)getDWORD(); + _savedName = getStringObj(); + + // load thumbnail + _thumbnailDataSize = getDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + getBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; + } + } else _savedVerBuild = 35; // last build with ver1 savegames + + uint32 dataOffset = getDWORD(); + + _savedDescription = getString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); + + _offset = dataOffset; + + return STATUS_OK; + } + } + + cleanup(); + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initLoad(const char *filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + cleanup(); + return STATUS_FAILED; + } + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + + } + + /* + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::saveFile(const char *filename) { + return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putString(const Common::String &val) { + if (!val.size()) putString("(null)"); + else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String CBPersistMgr::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + Common::String retString = ret; + delete[] ret; + + if (retString == "(null)") { + retString = ""; + } + + return retString; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::getString() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else return ret; +} + +bool CBPersistMgr::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +TimeDate CBPersistMgr::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + +void CBPersistMgr::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float CBPersistMgr::getFloat() { + char *str = getString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +void CBPersistMgr::putDouble(double val) { + Common::String str = Common::String::format("F%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double CBPersistMgr::getDouble() { + char *str = getString(); + double value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool CBPersistMgr::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// int +bool CBPersistMgr::transfer(const char *name, int *val) { + if (_saving) { + _saveStream->writeSint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +bool CBPersistMgr::transfer(const char *name, uint32 *val) { + if (_saving) { + _saveStream->writeUint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readUint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// float +bool CBPersistMgr::transfer(const char *name, float *val) { + if (_saving) { + putFloat(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// double +bool CBPersistMgr::transfer(const char *name, double *val) { + if (_saving) { + putDouble(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getDouble(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// char* +bool CBPersistMgr::transfer(const char *name, char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// const char* +bool CBPersistMgr::transfer(const char *name, const char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +bool CBPersistMgr::transfer(const char *name, Common::String *val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { + size_t size; + + if (_saving) { + size = val.size(); + _saveStream->writeUint32LE(size); + + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); + } + } else { + val.clear(); + size = _loadStream->readUint32LE(); + + for (size_t i = 0; i < size; i++) { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) val.push_back(str); + delete[] str; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +bool CBPersistMgr::transfer(const char *name, byte *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +bool CBPersistMgr::transfer(const char *name, Rect32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +bool CBPersistMgr::transfer(const char *name, Point32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +bool CBPersistMgr::transfer(const char *name, Vector2 *val) { + if (_saving) { + putFloat(val->x); + putFloat(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = getFloat(); + val->y = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +bool CBPersistMgr::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { + if (_saving) return true; + + // it's ok if we are same or newer than the saved game + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPersistMgr.h b/engines/wintermute/base/BPersistMgr.h new file mode 100644 index 0000000000..2e6ee8058c --- /dev/null +++ b/engines/wintermute/base/BPersistMgr.h @@ -0,0 +1,114 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/savestate.h" +#include "common/stream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/rect.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *_savedDescription; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const char *filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + Common::String getStringObj(); + void putString(const Common::String &val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); + bool initLoad(const char *filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool _saving; + + uint32 _richBufferSize; + byte *_richBuffer; + + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~CBPersistMgr(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + bool putTimeDate(const TimeDate &t); + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPoint.cpp b/engines/wintermute/base/BPoint.cpp new file mode 100644 index 0000000000..4c80e154f2 --- /dev/null +++ b/engines/wintermute/base/BPoint.cpp @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPoint::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPoint.h b/engines/wintermute/base/BPoint.h new file mode 100644 index 0000000000..3e4adb5d13 --- /dev/null +++ b/engines/wintermute/base/BPoint.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BQuickMsg.cpp b/engines/wintermute/base/BQuickMsg.cpp new file mode 100644 index 0000000000..32bd04afe2 --- /dev/null +++ b/engines/wintermute/base/BQuickMsg.cpp @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BQuickMsg.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) strcpy(_text, text); + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (_text) delete [] _text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::getText() { + return _text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BQuickMsg.h b/engines/wintermute/base/BQuickMsg.h new file mode 100644 index 0000000000..c247183714 --- /dev/null +++ b/engines/wintermute/base/BQuickMsg.h @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *getText(); + uint32 _startTime; + char *_text; + CBQuickMsg(CBGame *inGame, const char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp new file mode 100644 index 0000000000..1c38174cb8 --- /dev/null +++ b/engines/wintermute/base/BRegion.cpp @@ -0,0 +1,508 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::cleanup() { + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + CBPlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::pointInRegion(int x, int y) { + if (_points.getSize() < 3) return false; + + Point32 pt; + pt.x = x; + pt.y = y; + + Rect32 rect; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; + + if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int i; + + for (i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AddPoint") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + _points.add(new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points.insertAt(Index, new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points[Index]->x = x; + _points[Index]->y = y; + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemovePoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + delete _points[index]; + _points[index] = NULL; + + _points.removeAt(index); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + CScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); + } + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.getSize()); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", nameOverride); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::ptInPolygon(int x, int y) { + if (_points.getSize() < 3) return false; + + int counter = 0; + double xinters; + dPoint p, p1, p2; + + p.x = (double)x; + p.y = (double)y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (int i = 1; i <= _points.getSize(); i++) { + p2.x = (double)_points[i % _points.getSize()]->x; + p2.y = (double)_points[i % _points.getSize()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < _points.getSize(); i++) { + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); + + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); + } + CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < region->_points.getSize(); i++) { + int xVal, yVal; + + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(xVal + x, yVal + y)); + } + + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; + + return createRegion() ? STATUS_OK : STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegion.h b/engines/wintermute/base/BRegion.h new file mode 100644 index 0000000000..2a92d9daff --- /dev/null +++ b/engines/wintermute/base/BRegion.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); + bool ptInPolygon(int x, int y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool _active; + int _editorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + Rect32 _rect; + CBArray _points; + virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BRegistry.cpp b/engines/wintermute/base/BRegistry.cpp new file mode 100644 index 0000000000..fef09d7479 --- /dev/null +++ b/engines/wintermute/base/BRegistry.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/tinyxml/tinyxml.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/utils.h" +#include "common/config-manager.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + _iniName = NULL; + + setIniName("./wme.ini"); + loadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + saveValues(); + delete[] _iniName; + _iniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + + bool found = false; + ret = getValue(_localValues, subKey, key, found); + if (!found) ret = getValue(_values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + _values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + if (ConfMan.hasKey("master_volume")) { + return ConfMan.getInt("master_volume"); + } else { + return init; + } + } else if (key == "SFXVolume") { + if (ConfMan.hasKey("sfx_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "SpeechVolume") { + if (ConfMan.hasKey("speech_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "MusicVolume") { + if (ConfMan.hasKey("music_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } + } + AnsiString val = readString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + ConfMan.setInt("master_volume", value); + return true; + } else if (key == "SFXVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "SpeechVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "MusicVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } + } + writeString(subKey, key, StringUtil::toString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (readInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return writeInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setIniName(const char *name) { + delete[] _iniName; + _iniName = NULL; + + if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { + _iniName = new char [strlen(name) + 3]; + sprintf(_iniName, "./%s", name); + } else { + _iniName = new char [strlen(name) + 1]; + strcpy(_iniName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::getIniName() { + return _iniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadValues(bool local) { + if (local) loadXml("settings.xml", _localValues); + else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveValues() { + saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setBasePath(const char *basePath) { + _basePath = PathUtil::getFileNameWithoutExtension(basePath); + + loadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it)._value; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt)._value; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName.c_str()); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::createPath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt)._value; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + Common::DumpFile stream; + stream.open(fileName.c_str()); + + if (!stream.isOpen()) return; + else { + stream.write(printer.CStr(), printer.Size()); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegistry.h b/engines/wintermute/base/BRegistry.h new file mode 100644 index 0000000000..123d1d8a2f --- /dev/null +++ b/engines/wintermute/base/BRegistry.h @@ -0,0 +1,76 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void setIniName(const char *name); + char *getIniName(); + bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); + int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void setBasePath(const char *basePath); + AnsiString getBasePath() const { + return _basePath; + } + + void loadValues(bool local); + void saveValues(); + +private: + char *_iniName; + + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; + + PathValueMap _localValues; + PathValueMap _values; + + AnsiString _basePath; + + void loadXml(const AnsiString fileName, PathValueMap &values); + void saveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp new file mode 100644 index 0000000000..b99441b5db --- /dev/null +++ b/engines/wintermute/base/BResources.cpp @@ -0,0 +1,2820 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BResources.h" +#include "common/str.h" +#include "common/memstream.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + +Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { + if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BResources.h b/engines/wintermute/base/BResources.h new file mode 100644 index 0000000000..6ec0541b5c --- /dev/null +++ b/engines/wintermute/base/BResources.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace WinterMute { + +class CBResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &fileName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSaveThumbHelper.cpp b/engines/wintermute/base/BSaveThumbHelper.cpp new file mode 100644 index 0000000000..415d4ed1e4 --- /dev/null +++ b/engines/wintermute/base/BSaveThumbHelper.cpp @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + if (doFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + } + + CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) return STATUS_FAILED; + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new CBImage(_gameRef); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); + } + + + delete screenshot; + screenshot = NULL; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSaveThumbHelper.h b/engines/wintermute/base/BSaveThumbHelper.h new file mode 100644 index 0000000000..30db32cfb2 --- /dev/null +++ b/engines/wintermute/base/BSaveThumbHelper.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + CBImage *_thumbnail; + CBImage *_richThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BScriptHolder.cpp b/engines/wintermute/base/BScriptHolder.cpp new file mode 100644 index 0000000000..65d37b2e5c --- /dev/null +++ b/engines/wintermute/base/BScriptHolder.cpp @@ -0,0 +1,473 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/base/BScriptHolder.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) delete [] _filename; + + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + if (handler) { + //_scripts.add(handler); + numHandlers++; + ret = STATUS_OK; + } + } + } + if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->correctParams(0); + byte *p = 0; + *p = 10; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ApplyEvent") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool ret; + ret = applyEvent(val->getString()); + + if (DID_SUCCEED(ret)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AttachScript") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DetachScript") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool killThreads = stack->pop()->getBool(false); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + _scripts[i]->finish(killThreads); + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { + return CBBase::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_name)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::addScript(const char *filename) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + return STATUS_OK; + } + } + } + + CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.add(scr); + _gameRef->_scEngine->_scripts.add(scr); + _gameRef->getDebugMgr()->onScriptInit(scr); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::removeScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) { + _scripts.removeAt(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleEvent(const char *EventName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleMethod(const char *MethodName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + _gameRef->LOG(0, "'PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading PROPERTY definition"); + return STATUS_FAILED; + } + + + CScValue *val = new CScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->_freezable = freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.getSize() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (_name && strcmp(_name, "") != 0) { + strcat(buf, " Name: "); + strcat(buf, _name); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::sendEvent(const char *eventName) { + return DID_SUCCEED(applyEvent(eventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptHolder.h b/engines/wintermute/base/BScriptHolder.h new file mode 100644 index 0000000000..1e82b8cacf --- /dev/null +++ b/engines/wintermute/base/BScriptHolder.h @@ -0,0 +1,74 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CBScriptHolder : public CBScriptable { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + virtual CScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + bool cleanup(); + bool removeScript(CScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + bool parseProperty(byte *buffer, bool complete = true); + char *_filename; + bool _freezable; + bool _ready; + + CBArray _scripts; + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +public: + virtual bool sendEvent(const char *eventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BScriptable.cpp b/engines/wintermute/base/BScriptable.cpp new file mode 100644 index 0000000000..d1e3556a85 --- /dev/null +++ b/engines/wintermute/base/BScriptable.cpp @@ -0,0 +1,188 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { + _refCount = 0; + + if (noValue) _scValue = NULL; + else _scValue = new CScValue(_gameRef); + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->getProp(name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scSetProperty(const char *name, CScValue *value) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->setProp(name, value); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scCompare(CBScriptable *val) { + if (this < val) return -1; + else if (this > val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::dbgGetNativeClass() { + return getClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { + return scGetProperty(name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptable.h b/engines/wintermute/base/BScriptable.h new file mode 100644 index 0000000000..534bd3bdf1 --- /dev/null +++ b/engines/wintermute/base/BScriptable.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/base/BNamedObject.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool canHandleMethod(const char *eventMethod); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(CBScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + CScValue *_scValue; + CScValue *_scProp; + +public: + // IWmeDebugObject + const char *dbgGetNativeClass(); + IWmeDebugProp *dbgGetProperty(const char *name); + +}; + +// Implemented in their respective .cpp-files +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXMath(CBGame *inGame); +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXStore(CBGame *inGame); +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSound.cpp b/engines/wintermute/base/BSound.cpp new file mode 100644 index 0000000000..2b54b39500 --- /dev/null +++ b/engines/wintermute/base/BSound.cpp @@ -0,0 +1,288 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSoundBuffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + _sound = NULL; + _soundFilename = NULL; + + _soundType = Audio::Mixer::kSFXSoundType; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (_sound) _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + + delete[] _soundFilename; + _soundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + delete[] _soundFilename; + _soundFilename = NULL; + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = new char[strlen(filename) + 1]; + strcpy(_soundFilename, filename); + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSoundSimple() { + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->setPosition(_soundPosition); + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->resume(); + else return STATUS_OK; + } else return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getLength() { + if (_sound) return _sound->getLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) _sound->_freezePaused = true; + return _sound->pause(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::persist(CBPersistMgr *persistMgr) { + if (persistMgr->_saving && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) + _soundPosition = _sound->getPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPaused() { + return _sound && _soundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPositionTime(uint32 time) { + if (!_sound) return STATUS_FAILED; + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) + _soundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getPositionTime() { + if (!_sound) return 0; + + if (!_sound->isPlaying()) + return 0; + else return _sound->getPosition(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolumePercent(int percent) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(percent * 255 / 100); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(volume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPrivateVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->_privateVolume = volume; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolumePercent() { + if (!_sound) + return 0; + else return _sound->_privateVolume * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolume() { + if (!_sound) + return 0; + else return _sound->_privateVolume; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setLoopStart(uint32 pos) { + if (!_sound) + return STATUS_FAILED; + else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPan(float pan) { + if (_sound) + return _sound->setPan(pan); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { + if (!_sound) + return STATUS_OK; + + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + bool ret = _sound->applyFX(type, param1, param2, param3, param4); + + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; + + return ret; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSound.h b/engines/wintermute/base/BSound.h new file mode 100644 index 0000000000..9dc825e4ac --- /dev/null +++ b/engines/wintermute/base/BSound.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "audio/mixer.h" + +namespace WinterMute { + +class CBSoundBuffer; +class CBSound : public CBBase { +public: + bool setPan(float pan); + int _soundPrivateVolume; + int getVolume(); + int getVolumePercent(); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); + uint32 getPositionTime(); + bool setPositionTime(uint32 time); + bool _soundPaused; + bool _soundFreezePaused; + bool isPlaying(); + bool isPaused(); + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + char *_soundFilename; + bool setSoundSimple(); + bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + +private: + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSoundBuffer.cpp b/engines/wintermute/base/BSoundBuffer.cpp new file mode 100644 index 0000000000..4808cc9007 --- /dev/null +++ b/engines/wintermute/base/BSoundBuffer.cpp @@ -0,0 +1,383 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSoundBuffer.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" +#include "common/system.h" +#include "common/substream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; + + delete[] _filename; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + _streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +#if 0 + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } +#endif + + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = _gameRef->_fileManager->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + Common::String strFilename(filename); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); + } else if (strFilename.hasSuffix(".wav")) { + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + } + } + } else { + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + } + if (!_stream) { + return STATUS_FAILED; + } + CBUtils::setString(&_filename, filename); + + return STATUS_OK; +#if 0 + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { + _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); + return STATUS_FAILED; + } + + CBUtils::setString(&_filename, filename); + + /* + bool res; + bool NewlyCreated = false; + + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = _gameRef->_fileManager->openFile(filename); + if(!_file){ + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + // switch to streamed for big files + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!_soundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(_file); + if(DID_FAIL(res)){ + _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); + return res; + } + } + + + + // store filename + if(!_filename){ + _filename = new char[strlen(filename)+1]; + strcpy(_filename, filename); + } + + // close file (if not streaming) + if(!_streamed && _file){ + _gameRef->_fileManager->closeFile(_file); + _file = NULL; + } + */ + + return STATUS_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; + if (looping) { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setLooping(bool looping) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + _looping = looping; +#if 0 + + + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::resume() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setVolume(int volume) { + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; + if (_stream && _handle) { + byte vol = (byte)(_volume); + g_system->getMixer()->setChannelVolume(*_handle, vol); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPosition(uint32 pos) { + warning("CBSoundBuffer::SetPosition - not implemented yet"); +#if 0 + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); + } +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; +#if 0 + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; + } + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return STATUS_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("CBSoundBuffer::ApplyFX - not implemented yet"); + switch (type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundBuffer.h b/engines/wintermute/base/BSoundBuffer.h new file mode 100644 index 0000000000..9384670fbb --- /dev/null +++ b/engines/wintermute/base/BSoundBuffer.h @@ -0,0 +1,100 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "engines/wintermute/base/BBase.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); + bool isPlaying(); + + void setLooping(bool looping); + + uint32 getPosition(); + bool setPosition(uint32 pos); + uint32 getLength(); + + bool setLoopStart(uint32 pos); + uint32 getLoopStart() const { + return _loopStart; + } + + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); + void updateVolume(); + + void setType(Audio::Mixer::SoundType Type); + + bool loadFromFile(const char *filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + Common::SeekableReadStream *_file; + char *_filename; + bool _streamed; + + int _privateVolume; +private: + int _volume; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp new file mode 100644 index 0000000000..8d9b775c68 --- /dev/null +++ b/engines/wintermute/base/BSoundMgr.cpp @@ -0,0 +1,292 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BSoundBuffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::cleanup() { + for (int i = 0; i < _sounds.size(); i++) + delete _sounds[i]; + _sounds.clear(); +#if 0 + BASS_Free(); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::saveSettings() { + if (_soundAvailable) { + _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _soundAvailable = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initLoop() { + if (!_soundAvailable) + return STATUS_OK; +#if 0 + + BASS_Update(500); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (!_soundAvailable) + return NULL; + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (_gameRef->_fileManager->hasFile(newFile)) { + filename = newFile.c_str(); + } + } + + sound = new CBSoundBuffer(_gameRef); + if (!sound) return NULL; + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", filename); + delete sound; + return NULL; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { + if (!sound) + return STATUS_FAILED; + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i] == sound) { + delete _sounds[i]; + _sounds.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { + if (!_soundAvailable) + return STATUS_OK; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); + break; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); + break; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); + break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); + } + g_wintermute->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { + int volume = 0; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); + break; + default: + error("Sound-type not set"); + break; + } + + return (byte)(volume * 100 / 255); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (int i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::pauseAll(bool includingMusic) { + + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + _sounds[i]->pause(); + _sounds[i]->_freezePaused = true; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::resumeAll() { + + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)_gameRef->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundMgr.h b/engines/wintermute/base/BSoundMgr.h new file mode 100644 index 0000000000..a021abadaa --- /dev/null +++ b/engines/wintermute/base/BSoundMgr.h @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace WinterMute { +class CBSoundBuffer; +class CBSoundMgr : public CBBase { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte getMasterVolumePercent(); + byte getMasterVolume(); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); + byte getVolumePercent(Audio::Mixer::SoundType type); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); + uint32 _volumeOriginal; + int _volumeMaster; + bool removeSound(CBSoundBuffer *sound); + CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initLoop(); + bool initialize(); + bool _soundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + Common::Array _sounds; + void saveSettings(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp new file mode 100644 index 0000000000..c93a40ca75 --- /dev/null +++ b/engines/wintermute/base/BSprite.cpp @@ -0,0 +1,758 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + setName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::cleanup() { + CBScriptHolder::cleanup(); + + for (int i = 0; i < _frames.getSize(); i++) + delete _frames[i]; + _frames.removeAll(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + GetCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->afterMove(); + + x = _owner->_posX; + y = _owner->_posY; + } + + // draw frame + return display(x, y, registerOwner, zoomX, zoomY, alpha); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + if (!file) { + _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + else return loadFile("invalid.bmp", lifeTime, cacheType); + } else { + _gameRef->_fileManager->closeFile(file); + file = NULL; + } + + bool ret; + + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + CBFrame *frame = new CBFrame(_gameRef); + CBSubFrame *subframe = new CBSubFrame(_gameRef); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer) { + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + delete [] buffer; + } + } + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + cleanup(); + + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + _gameRef->LOG(0, "'SPRITE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int frameCount = 1; + CBFrame *frame; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.scanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.scanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.scanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.scanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.scanStr((char *)params, "%b", &_streamed); + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (_gameRef->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.scanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(_gameRef); + + if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + delete frame; + _gameRef->LOG(0, "Error parsing frame %d", frameCount); + return STATUS_FAILED; + } + + _frames.add(frame); + frameCount++; + if (_currentFrame == -1) _currentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITE definition"); + return STATUS_FAILED; + } + _canBreak = !_continuous; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::reset() { + if (_frames.getSize() > 0) _currentFrame = 0; + else _currentFrame = -1; + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { + //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) return false; + + uint32 timer; + if (_owner && _owner->_freezable) timer = _gameRef->_timer; + else timer = _gameRef->_liveTimer; + + int lastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.getSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + killAllSounds(); + } + applyEvent("FrameChanged"); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.getSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + CBPlatform::setRectEmpty(rect); + for (int i = 0; i < _frames.getSize(); i++) { + Rect32 frame; + Rect32 temp; + CBPlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (_editorMuted) + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + + if (_editorBgFile) { + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + CBScriptHolder::saveAsText(buffer, indent + 2); + + int i; + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + + for (i = 0; i < _frames.getSize(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int Index = stack->pop()->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + stack->pushNULL(); + } else stack->pushNative(_frames[Index], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteFrame") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (Val->isInt()) { + int Index = Val->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->getNative(); + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddFrame") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.add(sub); + } else delete sub; + } + _frames.add(frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertFrame") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) + index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) + filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); + else delete sub; + } + + if (index >= _frames.getSize()) + _frames.add(frame); + else _frames.insertAt(index, frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _paused = true; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Play") == 0) { + stack->correctParams(0); + _paused = false; + stack->pushNULL(); + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFrames") == 0) { + _scValue->setInt(_frames.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentFrame") == 0) { + _scValue->setInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _scValue->setBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Owner") == 0) { + if (_owner == NULL) _scValue->setNULL(); + else _scValue->setNative(_owner, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Finished") == 0) { + _scValue->setBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Paused") == 0) { + _scValue->setBool(_paused); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _precise = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _looping = value->getBool(); + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::killAllSounds() { + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i]->_sound) + _frames[i]->_sound->stop(); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSprite.h b/engines/wintermute/base/BSprite.h new file mode 100644 index 0000000000..3c67e5f3fe --- /dev/null +++ b/engines/wintermute/base/BSprite.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BScriptHolder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + bool killAllSounds(); + CBSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool _editorAllFrames; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + int _moveY; + int _moveX; + bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void reset(); + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + uint32 _lastFrameTime; + bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + CBSprite(CBGame *inGame, CBObject *owner = NULL); + virtual ~CBSprite(); + CBArray _frames; + bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp new file mode 100644 index 0000000000..44f26ba7e8 --- /dev/null +++ b/engines/wintermute/base/BStringTable.cpp @@ -0,0 +1,229 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return STATUS_FAILED; + + if (scumm_stricmp(key, "@right-to-left") == 0) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + _stringsIter = _strings.find(finalKey); + if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + + _strings[finalKey] = val; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; + + const char *value = strchr(str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = getKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::expand(char **str, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return; + + if (str == NULL || *str == NULL || *str[0] != '/') return; + + char *value = strchr(*str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *str; + *str = new_str; + + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return string; + + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; + + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; + + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) _strings.clear(); + + uint32 size; + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + uint32 pos = 0; + + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else _gameRef->_textEncoding = TEXT_ANSI; + + uint32 lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (uint32 i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); + } + + delete [] line; + pos += lineLength + 1; + } + + delete [] buffer; + + _gameRef->LOG(0, " %d strings loaded", _strings.size()); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BStringTable.h b/engines/wintermute/base/BStringTable.h new file mode 100644 index 0000000000..92d3604b4d --- /dev/null +++ b/engines/wintermute/base/BStringTable.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *expandStatic(const char *string, bool forceExpand = false); + bool loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + bool addString(const char *key, const char *val, bool reportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + Common::HashMap _strings; + char *getKey(const char *str); +private: + Common::HashMap::iterator _stringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp new file mode 100644 index 0000000000..60048ac05a --- /dev/null +++ b/engines/wintermute/base/BSubFrame.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + CBPlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + CBPlatform::setRectEmpty(&rect); + char *surfaceFile = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); + return STATUS_FAILED; + } + + if (surfaceFile != NULL) { + if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + + /* + if(_surface == NULL) + { + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); + return STATUS_FAILED; + } + */ + if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + else _rect = rect; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) return STATUS_OK; + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + } else { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + } + } + if (_gameRef->_suspendedRendering) return STATUS_OK; + + bool res; + + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) alpha = _alpha; + + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; + + CBPlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { + if (complete) + buffer->putTextIndent(indent, "SUBFRAME {\n"); + + if (_surface && _surface->getFileNameStr() != "") + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + + if (_transparent != 0xFFFF00FF) + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + + Rect32 rect; + CBPlatform::setRectEmpty(&rect); + if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!CBPlatform::equalRect(&rect, &_rect)) + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + + if (_hotspotX != 0 || _hotspotY != 0) + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + + if (_alpha != 0xFFFFFFFF) { + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + } + + if (_mirrorX) + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + + if (_mirrorY) + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + + if (_2DOnly) + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + + if (_3DOnly) + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + + if (_decoration) + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + + if (_editorSelected) + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + + if (complete) + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::setDefaultRect() { + if (_surface) { + CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + + if (!_surfaceFilename) stack->pushNULL(); + else stack->pushString(_surfaceFilename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (Val->isNULL()) { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; + stack->pushBool(true); + } else { + const char *filename = Val->getString(); + if (DID_SUCCEED(setSurface(filename))) { + setDefaultRect(); + stack->pushBool(true); + } else stack->pushBool(false); + } + + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + + _scValue->setInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TransparentColor") == 0) { + _scValue->setInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _scValue->setBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _scValue->setBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _scValue->setBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _scValue->setBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _scValue->setInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _scValue->setInt(_hotspotY); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _2DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _3DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _mirrorX = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _mirrorY = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _hotspotX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _hotspotY = value->getInt(); + return STATUS_OK; + } + + else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(filename) + 1]; + strcpy(_surfaceFilename, filename); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return STATUS_OK; + } + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return STATUS_OK; + else return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSubFrame.h b/engines/wintermute/base/BSubFrame.h new file mode 100644 index 0000000000..57ffcae675 --- /dev/null +++ b/engines/wintermute/base/BSubFrame.h @@ -0,0 +1,86 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void setDefaultRect(); + uint32 _transparent; + bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool _editorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + Rect32 _rect; + + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + CBSurface *_surface; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp new file mode 100644 index 0000000000..f50d174898 --- /dev/null +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -0,0 +1,189 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::cleanup(bool warn) { + for (int i = 0; i < _surfaces.size(); i++) { + if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::initLoop() { + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; + sortSurfaces(); + for (int i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::removeSurface(CBSurface *surface) { + for (int i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + for (int i = 0; i < _surfaces.size(); i++) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!_gameRef->_fileManager->hasFile(filename)) { + if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); + if (_gameRef->_debugDebugMode) + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + else + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + + CBSurface *surface; + surface = _gameRef->_renderer->createSurface(); + + if (!surface) return NULL; + + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.push_back(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::restoreAll() { + bool ret; + for (int i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +{ + + if(!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + + + // sort by validity + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSurfaceStorage.h b/engines/wintermute/base/BSurfaceStorage.h new file mode 100644 index 0000000000..c054c2a55b --- /dev/null +++ b/engines/wintermute/base/BSurfaceStorage.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + +#include "engines/wintermute/base/BBase.h" +#include "common/array.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 _lastCleanupTime; + bool initLoop(); + bool sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); + bool cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + bool restoreAll(); + CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + Common::Array _surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp new file mode 100644 index 0000000000..7c9a95368a --- /dev/null +++ b/engines/wintermute/base/BTransitionMgr.cpp @@ -0,0 +1,131 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BTransitionMgr.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) return STATUS_OK; + + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return STATUS_OK; + } + + if (nonInteractive) { + _preserveInteractive = true; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; + } /*else _preserveInteractive */; + + + _type = type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return STATUS_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::update() { + if (isReady()) return STATUS_OK; + + if (!_started) { + _started = true; + _lastTime = CBPlatform::getTime(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (isReady()) { + if (_preserveInteractive) + _gameRef->_interactive = _origInteractive; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BTransitionMgr.h b/engines/wintermute/base/BTransitionMgr.h new file mode 100644 index 0000000000..faedb6fe3e --- /dev/null +++ b/engines/wintermute/base/BTransitionMgr.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp new file mode 100644 index 0000000000..0f2a67d3bf --- /dev/null +++ b/engines/wintermute/base/BViewport.cpp @@ -0,0 +1,98 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BViewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); + } + + CBPlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *CBViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BViewport.h b/engines/wintermute/base/BViewport.h new file mode 100644 index 0000000000..1150b8ebe7 --- /dev/null +++ b/engines/wintermute/base/BViewport.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int getHeight(); + int getWidth(); + Rect32 *getRect(); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int _offsetY; + int _offsetX; + CBObject *_mainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + Rect32 _rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp new file mode 100644 index 0000000000..f2938cebc9 --- /dev/null +++ b/engines/wintermute/base/file/BDiskFile.cpp @@ -0,0 +1,131 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/BDiskFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/file.h" +#include "common/zlib.h" + +namespace WinterMute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { + char fullPath[MAX_PATH_LENGTH]; + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; + + for (int i = 0; i < fileManager->_singlePaths.size(); i++) { + sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); + correctSlashes(fullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + // if we didn't find it in search paths, try to open directly + if (!file) { + strcpy(fullPath, filename.c_str()); + correctSlashes(fullPath); + + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + if (file) { + uint32 magic1, magic2; + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + + if (compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = file->readUint32LE(); + CompSize = file->readUint32LE(); + UncompSize = file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + error("Error allocating memory for compressed file '%s'", filename.c_str()); + delete file; + return NULL; + } + + byte *data = new byte[UncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + file->seek(DataOffset + prefixSize, SEEK_SET); + file->read(CompBuffer, CompSize); + + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + error("Error uncompressing file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + + delete [] CompBuffer; + + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; + } else { + file->seek(0, SEEK_SET); + return file; + } + + return file; + + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BDiskFile.h b/engines/wintermute/base/file/BDiskFile.h new file mode 100644 index 0000000000..23e1a0a315 --- /dev/null +++ b/engines/wintermute/base/file/BDiskFile.h @@ -0,0 +1,42 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BFile.cpp b/engines/wintermute/base/file/BFile.cpp new file mode 100644 index 0000000000..911039e36d --- /dev/null +++ b/engines/wintermute/base/file/BFile.cpp @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = getPos(); + seek(0); + byte *data = new byte[getSize()]; + read(data, getSize()); + seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFile.h b/engines/wintermute/base/file/BFile.h new file mode 100644 index 0000000000..d1737df0ce --- /dev/null +++ b/engines/wintermute/base/file/BFile.h @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/base/BBase.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +protected: + uint32 _pos; + uint32 _size; +public: + virtual uint32 getSize() { + return _size; + }; + virtual uint32 getPos() { + return _pos; + }; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; + virtual bool isEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp new file mode 100644 index 0000000000..7eafe7919e --- /dev/null +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -0,0 +1,105 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/util.h" +#include "common/file.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" + +namespace WinterMute { + +// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. +class CBPkgFile : public Common::SeekableReadStream { + uint32 _size; + Common::SeekableReadStream *_stream; +public: + CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} + virtual ~CBPkgFile() { + delete _stream; + } + virtual uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } + virtual bool eos() const { + return _stream->eos(); + } + virtual int32 pos() const { + return _stream->pos(); + } + virtual int32 size() const { + return _size; + } + virtual bool seek(int32 offset, int whence = SEEK_SET) { + return _stream->seek(offset, whence); + } +}; + +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { + CBFileEntry *fileEntry; + Common::SeekableReadStream *file = NULL; + char fileName[MAX_PATH_LENGTH]; + strcpy(fileName, filename.c_str()); + + // correct slashes + for (uint32 i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '/') fileName[i] = '\\'; + } + + fileEntry = fileManager->getPackageEntry(fileName); + if (!fileEntry) return NULL; + + file = fileEntry->_package->getFilePointer(); + if (!file) return NULL; + + // TODO: Cleanup + bool compressed = (fileEntry->_compressedLength != 0); + /* _size = fileEntry->_length; */ + + if (compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); + } else { + file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); + } + if (file->size() == 0) { + file = new CBPkgFile(file, fileEntry->_length); + } + + file->seek(0); + + return file; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h new file mode 100644 index 0000000000..f8a5831485 --- /dev/null +++ b/engines/wintermute/base/file/BPkgFile.h @@ -0,0 +1,46 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPKGFILE_H +#define WINTERMUTE_BPKGFILE_H + +#include "engines/wintermute/base/BFileEntry.h" + +namespace Common { +class SeekableReadStream; +class File; +} + +namespace WinterMute { + +class CBFileManager; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp new file mode 100644 index 0000000000..b2eebb690b --- /dev/null +++ b/engines/wintermute/base/file/BSaveThumbFile.cpp @@ -0,0 +1,146 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/BSaveThumbFile.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::open(const Common::String &filename) { + close(); + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (uint32 i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int slot = atoi(tempFilename); + delete [] tempFilename; + + char slotFilename[MAX_PATH_LENGTH + 1]; + _gameRef->getSaveSlotFilename(slot, slotFilename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _gameRef->_debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(slotFilename))) { + _gameRef->_debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + _gameRef->_debugAbsolutePathWarning = true; + + bool res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = STATUS_OK; + } else res = STATUS_FAILED; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return STATUS_FAILED; + + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::seek(uint32 pos, int whence) { + if (!_data) return STATUS_FAILED; + + uint32 newPos = 0; + + switch (whence) { + case SEEK_SET: + newPos = pos; + break; + case SEEK_END: + newPos = _size + pos; + break; + case SEEK_CUR: + newPos = _pos + pos; + break; + } + + if (newPos > _size) return STATUS_FAILED; + else _pos = newPos; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BSaveThumbFile.h b/engines/wintermute/base/file/BSaveThumbFile.h new file mode 100644 index 0000000000..5d33ac2220 --- /dev/null +++ b/engines/wintermute/base/file/BSaveThumbFile.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/BFile.h" + +namespace WinterMute { + +//TODO: Get rid of this +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFont.cpp b/engines/wintermute/base/font/BFont.cpp new file mode 100644 index 0000000000..5d0086c581 --- /dev/null +++ b/engines/wintermute/base/font/BFont.cpp @@ -0,0 +1,206 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontBitmap.h" +#include "engines/wintermute/base/font/BFontTT.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +bool CBFont::loadFile(const char * Filename) +{ + BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + if(Buffer==NULL){ + _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); + + if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFont::loadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(_gameRef); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFont::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { + if (isTrueType(gameRef, filename)) { + CBFontTT *font = new CBFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + CBFontBitmap *font = new CBFontBitmap(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; + + byte *WorkBuffer = buffer; + + char *params; + CBParser parser(gameRef); + + bool ret = false; + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + ret = true; + + delete [] buffer; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFont.h b/engines/wintermute/base/font/BFont.h new file mode 100644 index 0000000000..a6ab757b0d --- /dev/null +++ b/engines/wintermute/base/font/BFont.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/base/BObject.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {}; + virtual void afterLoad() {}; + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *createFromFile(CBGame *game, const char *filename); + +private: + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); + static bool isTrueType(CBGame *game, const char *filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp new file mode 100644 index 0000000000..031f075d1b --- /dev/null +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -0,0 +1,540 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFontBitmap.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (size_t i = 0; i < str.size(); i++) { + textWidth += getCharWidth(str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) _gameRef->_renderer->startSpriteBatch(); + + while (!done) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (draw) _gameRef->_renderer->endSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += getCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += getCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) _gameRef->_renderer->endSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; + + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new CBSubFrame(_gameRef); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + _gameRef->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + expandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; + + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; + else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { + + CBFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); + else + persistMgr->getBytes(_widths, sizeof(_widths)); + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::getWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) break; + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + _gameRef->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontBitmap.h b/engines/wintermute/base/font/BFontBitmap.h new file mode 100644 index 0000000000..17bf433f65 --- /dev/null +++ b/engines/wintermute/base/font/BFontBitmap.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/base/font/BFont.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const char *filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + bool getWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp new file mode 100644 index 0000000000..a777ac9db8 --- /dev/null +++ b/engines/wintermute/base/font/BFontStorage.cpp @@ -0,0 +1,135 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.getSize(); i++) { + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::initLoop() { + for (int i = 0; i < _fonts.getSize(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::addFont(const char *filename) { + if (!filename) return NULL; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + CBFont *font = CBFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.removeAt(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::persist(CBPersistMgr *persistMgr) { + + if (!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontStorage.h b/engines/wintermute/base/font/BFontStorage.h new file mode 100644 index 0000000000..9759d5d25e --- /dev/null +++ b/engines/wintermute/base/font/BFontStorage.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + bool cleanup(bool warn = false); + bool removeFont(CBFont *font); + CBFont *addFont(const char *filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + bool initLoop(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp new file mode 100644 index 0000000000..2707dbea31 --- /dev/null +++ b/engines/wintermute/base/font/BFontTT.cpp @@ -0,0 +1,762 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/font/BFontTT.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + clearCache(); + + for (int i = 0; i < _layers.getSize(); i++) { + delete _layers[i]; + } + _layers.removeAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; + +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (_gameRef->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; + + WideString textStr = (char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + debugC(kWinterMuteDebugFont, "Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (int i = 0; i < _layers.getSize(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } + + debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + if (_deletableFont) // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + else // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + uint32 useColor = 0xffffffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + CBSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + _gameRef->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.getSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.add(Layer); + } + + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->_saving) { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + } else { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + if (!file) { + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + } + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + _gameRef->_fileManager->closeFile(file); + return STATUS_FAILED; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return STATUS_FAILED; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontTT.h b/engines/wintermute/base/font/BFontTT.h new file mode 100644 index 0000000000..9b995b293e --- /dev/null +++ b/engines/wintermute/base/font/BFontTT.h @@ -0,0 +1,180 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString getText() const { + return _text; + } + int getWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + bool loadBuffer(byte *buffer); + bool loadFile(const char *filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(CBTTFontLayer *layer, byte *buffer); + + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void clearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp new file mode 100644 index 0000000000..f1e27c9622 --- /dev/null +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -0,0 +1,269 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/bmp.h" +#include "graphics/surface.h" +#include "engines/wintermute/graphics/tga.h" +#include "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +#if 0 + _bitmap = bitmap; +#endif + _bitmap = NULL; + _palette = NULL; + _surface = NULL; + _decoder = NULL; + _deletableSurface = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBImage::~CBImage() { + /* delete _bitmap; */ + delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } + delete _deletableSurface; +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); +#endif +} + +bool CBImage::loadFile(const Common::String &filename) { + _filename = filename; + _filename.toLowercase(); + if (StringUtil::startsWith(filename, "savegame:", true)) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".png")) { + _decoder = new Graphics::PNGDecoder(); + } else if (_filename.hasSuffix(".bmp")) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".tga")) { + _decoder = new WinterMute::TGA(); + } else if (_filename.hasSuffix(".jpg")) { + _decoder = new Graphics::JPEGDecoder(); + } else { + error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + _filename = filename; + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); + if (!file) return STATUS_FAILED; + + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); + _gameRef->_fileManager->closeFile(file); + + return STATUS_OK; +} + +byte CBImage::getAlphaAt(int x, int y) { + if (!_surface) return 0xFF; + uint32 color = *(uint32 *)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} + +void CBImage::copyFrom(Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + +////////////////////////////////////////////////////////////////////////// +bool CBImage::saveBMPFile(const char *filename) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; + else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::resize(int newWidth, int newHeight) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + + + FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + if (newImg) { + FreeImage_Unload(_bitmap); + _bitmap = newImg; + return STATUS_OK; + } else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::writeBMPToStream(Common::WriteStream *stream) { + if (!_surface) return false; + + /* The following is just copied over and inverted to write-ops from the BMP-decoder */ + stream->writeByte('B'); + stream->writeByte('M'); + + /* Since we don't care during reads, we don't care during writes: */ + /* uint32 fileSize = */ + stream->writeUint32LE(54 + _surface->h * _surface->pitch); + /* uint16 res1 = */ + stream->writeUint16LE(0); + /* uint16 res2 = */ + stream->writeUint16LE(0); + const uint32 imageOffset = 54; + stream->writeUint32LE(imageOffset); + + const uint32 infoSize = 40; /* Windows v3 BMP */ + stream->writeUint32LE(infoSize); + + uint32 width = _surface->w; + int32 height = _surface->h; + stream->writeUint32LE(width); + stream->writeUint32LE((uint32)height); + + if (width == 0 || height == 0) + return false; + + if (height < 0) { + warning("Right-side up bitmaps not supported"); + return false; + } + + /* uint16 planes = */ stream->writeUint16LE(1); + const uint16 bitsPerPixel = 24; + stream->writeUint16LE(bitsPerPixel); + + const uint32 compression = 0; + stream->writeUint32LE(compression); + + /* uint32 imageSize = */ + stream->writeUint32LE(_surface->h * _surface->pitch); + /* uint32 pixelsPerMeterX = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ + stream->writeUint32LE(0); + const uint32 paletteColorCount = 0; + stream->writeUint32LE(paletteColorCount); + /* uint32 colorsImportant = */ + stream->writeUint32LE(0); + + // Start us at the beginning of the image (54 bytes in) + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + + // BGRA for 24bpp + if (bitsPerPixel == 24) + format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + + Graphics::Surface *surface = _surface->convertTo(format); + + int srcPitch = width * (bitsPerPixel >> 3); + const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + + for (int32 i = height - 1; i >= 0; i--) { + for (uint32 j = 0; j < width; j++) { + byte b, g, r; + uint32 color = *(uint32 *)surface->getBasePtr(j, i); + surface->format.colorToRGB(color, r, g, b); + stream->writeByte(b); + stream->writeByte(g); + stream->writeByte(r); + } + + for (int k = 0; k < extraDataLength; k++) { + stream->writeByte(0); + } + } + surface->free(); + delete surface; + return true; + + //*BufferSize = 0; +#if 0 + FIMEMORY *fiMem = FreeImage_OpenMemory(); + FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); + uint32 size; + byte *data; + FreeImage_AcquireMemory(fiMem, &data, &size); + + + byte *Buffer = new byte[size]; + memcpy(Buffer, data, size); + + FreeImage_CloseMemory(fiMem); + + if (BufferSize) *BufferSize = size; + + return Buffer; +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + + _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); +#endif + TransparentSurface temp(*origImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale(newWidth, newHeight); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h new file mode 100644 index 0000000000..646a9ddd2d --- /dev/null +++ b/engines/wintermute/base/gfx/base_image.h @@ -0,0 +1,74 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BIMAGE_H +#define WINTERMUTE_BIMAGE_H + +#include "engines/wintermute/base/BBase.h" +#include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/decoders/image_decoder.h" +#include "common/endian.h" +#include "common/str.h" +#include "common/stream.h" + +struct FIBITMAP; + +namespace WinterMute { +class CBSurface; +class CBImage: CBBase { + +public: + CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); + ~CBImage(); + + bool loadFile(const Common::String &filename); + const Graphics::Surface *getSurface() const { + return _surface; + }; + const byte *getPalette() const { + return _palette; + } + byte getAlphaAt(int x, int y); + bool writeBMPToStream(Common::WriteStream *stream); + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename); + bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + void copyFrom(Graphics::Surface *surface); +private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; + FIBITMAP *_bitmap; + const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; + const byte *_palette; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp new file mode 100644 index 0000000000..010aca7141 --- /dev/null +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { + _window = 0; + _clipperWindow = 0; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _width = _height = _bPP = 0; + CBPlatform::setRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBRenderer::~CBRenderer() { + deleteRectList(); + unclipCursor(); +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::initLoop() { + deleteRectList(); +} + + +////////////////////////////////////////////////////////////////////// +CBObject *CBRenderer::getObjectAt(int x, int y) { + Point32 point; + point.x = x; + point.y = y; + + for (int i = _rectList.getSize() - 1; i >= 0; i--) { + if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + + if (_rectList[i]->_frame->_mirrorX) { + int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + xx = width - xx; + } + + if (_rectList[i]->_frame->_mirrorY) { + int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + yy = height - yy; + } + + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; + } + // region + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + } + } else return _rectList[i]->_owner; + } + } + + return (CBObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderer::deleteRectList() { + for (int i = 0; i < _rectList.getSize(); i++) { + delete _rectList[i]; + } + _rectList.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +bool CBRenderer::switchFullscreen() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::flip() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::onWindowChange() { +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::windowedBlt() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setup2D(bool Force) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setupLines() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { + for (int i = 0; i < width; i++) { + drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up + drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down + + drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left + drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fade(uint16 alpha) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(Rect32 *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderer::takeScreenshot() { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::clipCursor() { + /* + if (!_windowed) { + Rect32 rc; + GetWindowRect(_window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; + + ::ClipCursor(&rc); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::unclipCursor() { + /* + if (!_windowed) ::ClipCursor(NULL); + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::pointInViewport(Point32 *p) { + if (p->x < _drawOffsetX) return false; + if (p->y < _drawOffsetY) return false; + if (p->x > _drawOffsetX + _width) return false; + if (p->y > _drawOffsetY + _height) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h new file mode 100644 index 0000000000..81c13f8b39 --- /dev/null +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -0,0 +1,128 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_H +#define WINTERMUTE_BRENDERER_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "common/rect.h" + +namespace WinterMute { + +class CBImage; +class CBActiveRect; +class CBObject; +class CBSurface; +class CBRenderer: public CBBase { +public: + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void dumpData(const char *filename) {}; + virtual CBImage *takeScreenshot(); + virtual bool setViewport(int left, int top, int right, int bottom); + virtual bool setViewport(Rect32 *Rect); + virtual bool setScreenViewport(); + virtual bool fade(uint16 Alpha); + virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + CBRenderer(CBGame *inGame = NULL); + virtual ~CBRenderer(); + virtual bool setProjection() { + return STATUS_OK; + }; + + virtual bool windowedBlt(); + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual void onWindowChange(); + virtual bool initRenderer(int width, int height, bool windowed); + virtual bool flip(); + virtual void initLoop(); + virtual bool switchFullscreen(); + virtual bool setup2D(bool force = false); + virtual bool setupLines(); + + virtual const char *getName() { + return ""; + }; + virtual bool displayDebugInfo() { + return STATUS_FAILED; + }; + virtual bool drawShaderQuad() { + return STATUS_FAILED; + } + + virtual float getScaleRatioX() const { + return 1.0f; + } + virtual float getScaleRatioY() const { + return 1.0f; + } + + virtual CBSurface *createSurface() = 0; + + bool clipCursor(); + bool unclipCursor(); + + CBObject *getObjectAt(int x, int y); + void deleteRectList(); + + virtual bool startSpriteBatch() { + return STATUS_OK; + }; + virtual bool endSpriteBatch() { + return STATUS_OK; + }; + bool pointInViewport(Point32 *P); + uint32 _forceAlphaColor; + uint32 _window; + uint32 _clipperWindow; + bool _active; + bool _ready; + bool _windowed; + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; + int _bPP; + int _height; + int _width; + + CBArray _rectList; +}; + +CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp new file mode 100644 index 0000000000..6c0ca40765 --- /dev/null +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -0,0 +1,152 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/base_surface.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = ""; + + _pixelOpReady = false; + + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface::~CBSurface() { + if (_pixelOpReady) endPixelOp(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::restore() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAt(int x, int y) { + return false; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::create(int Width, int Height) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::startPixelOp() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::endPixelOp() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAtLite(int x, int y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::invalidate() { + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::prepareToDraw() { + _lastUsedTime = _gameRef->_liveTimer; + + if (!_valid) { + //_gameRef->LOG(0, "Reviving: %s", _filename); + return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSurface::setSize(int width, int height) { + _width = width; + _height = height; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h new file mode 100644 index 0000000000..f5fbd495aa --- /dev/null +++ b/engines/wintermute/base/gfx/base_surface.h @@ -0,0 +1,99 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACE_H +#define WINTERMUTE_BSURFACE_H + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "graphics/surface.h" + +namespace WinterMute { + +class CBSurface: public CBBase { +public: + virtual bool invalidate(); + virtual bool prepareToDraw(); + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + bool _keepLoaded; + + bool _pixelOpReady; + CBSurface(CBGame *inGame); + virtual ~CBSurface(); + + virtual bool displayHalfTrans(int x, int y, Rect32 rect); + virtual bool isTransparentAt(int x, int y); + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool restore(); + virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(int Width, int Height); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return STATUS_FAILED; + } + virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool startPixelOp(); + virtual bool endPixelOp(); + virtual bool isTransparentAtLite(int x, int y); + void setSize(int width, int height); + + int _referenceCount; + + virtual int getWidth() { + return _width; + } + virtual int getHeight() { + return _height; + } + Common::String getFileNameStr() { return _filename; } + const char* getFileName() { return _filename.c_str(); } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } +protected: + Common::String _filename; + int _height; + int _width; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp new file mode 100644 index 0000000000..fc971357bf --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -0,0 +1,701 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "common/system.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "common/queue.h" + +namespace WinterMute { + +RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { + _colorMod = 0; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; + if (surf) { + _surface = new Graphics::Surface(); + _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); + assert(_surface->format.bytesPerPixel == 4); + // Get a clipped copy of the surface + for (int i = 0; i < _surface->h; i++) { + memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); + } + // Then scale it if necessary + if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + TransparentSurface src(*_surface, false); + Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); + _surface->free(); + delete _surface; + _surface = temp; + } + } else { + _surface = NULL; + } +} + +RenderTicket::~RenderTicket() { + if (_surface) { + _surface->free(); + delete _surface; + } +} + +bool RenderTicket::operator==(RenderTicket &t) { + if ((t._srcRect != _srcRect) || + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } + return true; +} + +CBRenderer *makeOSystemRenderer(CBGame *inGame) { + return new CBRenderOSystem(inGame); +} + +// TODO: Redo everything here. + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { + _renderSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); + _dirtyRect = NULL; + _disableDirtyRects = true; +} + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::~CBRenderOSystem() { + _renderSurface->free(); + delete _renderSurface; +#if 0 + if (_renderer) SDL_DestroyRenderer(_renderer); + if (_win) SDL_DestroyWindow(_win); + SDL_Quit(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; + +#if 0 + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); +#endif + _width = width; + _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); + + _realWidth = width; + _realHeight = height; + + + // find suitable resolution +/*#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } +#else*/ + _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); + _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); +//#endif + + /* + _realWidth = 480; + _realHeight = 320; + */ + + + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)_realHeight / (float)_height; + } else { + // wide to normal + ratio = (float)_realWidth / (float)_width; + } + + _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); + _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); + + _borderTop = (int)((_realHeight - (_height * ratio)) / 2); + _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); + + + + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; + +#if 0 + Uint32 flags = SDL_WINDOW_SHOWN; +#endif +#ifdef __IPHONEOS__ + //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; +#endif + + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); +// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return STATUS_FAILED; + } +#if 0 + _win = SDL_CreateWindow("WME Lite", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + _realWidth, _realHeight, + flags); + + if (!_win) return STATUS_FAILED; +#endif + + g_system->showMouse(false); + +#ifdef __IPHONEOS__ + // SDL defaults to OGL ES2, which doesn't work on old devices + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); +#else + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif +#if 0 + _renderer = SDL_CreateRenderer(_win, -1, 0); + + if (!_renderer) return STATUS_FAILED; +#endif + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _active = true; + + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); + + return STATUS_OK; +} + +void CBRenderOSystem::setAlphaMod(byte alpha) { + byte r = RGBCOLGetR(_colorMod); + byte g = RGBCOLGetB(_colorMod); + byte b = RGBCOLGetB(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { + byte alpha = RGBCOLGetA(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::flip() { + if (!_disableDirtyRects) { + drawTickets(); + } + if (_needsFlip || _disableDirtyRects) { + if (_disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + } + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + delete _dirtyRect; + _dirtyRect = NULL; + g_system->updateScreen(); + _needsFlip = false; + } + _drawNum = 1; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { + //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); + //SDL_RenderClear(_renderer); + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) + return STATUS_OK; + if (!rect) { + rect = &_renderRect; + } + _renderSurface->fillRect(*rect, _clearColor); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fade(uint16 Alpha) { + uint32 dwAlpha = 255 - Alpha; + return fadeToColor(dwAlpha << 24); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); + warning("Implement CBRenderOSystem::FadeToColor"); // TODO. + hasWarned = true; + } + + Common::Rect fillRect; + + if (rect) { + fillRect.left = rect->left; + fillRect.top = rect->top; + fillRect.setWidth(rect->width()); + fillRect.setHeight(rect->height()); + } else { + Rect32 rc; + _gameRef->getCurrentViewportRect(&rc); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); + } + modTargetRect(&fillRect); + + byte r = RGBCOLGetR(Color); + byte g = RGBCOLGetG(Color); + byte b = RGBCOLGetB(Color); + byte a = RGBCOLGetA(Color); + + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + if (_disableDirtyRects) + _renderSurface->fillRect(fillRect, col); + else { + setAlphaMod(a); + setColorMod(r, g, b); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + _clearColor = col; + } + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); + + return STATUS_OK; +} + +void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { + if (_disableDirtyRects) { + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + // HINT: The surface-data contains other info than it should. + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + return; + } + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { + return; + } + + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } + } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + ticket->_colorMod = _colorMod; + drawFromTicket(ticket); +} + +void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} + +void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } + } +} + +void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { + renderTicket->_wantsDraw = true; + // A new item always has _drawNum == 0 + if (renderTicket->_drawNum == 0) { + // In-order + if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { + renderTicket->_drawNum = _drawNum++; + _renderQueue.push_back(renderTicket); + addDirtyRect(renderTicket->_dstRect); + } else { + // Before something + Common::List::iterator pos; + for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { + if ((*pos)->_drawNum >= _drawNum) { + break; + } + } + _renderQueue.insert(pos, renderTicket); + Common::List::iterator it; + renderTicket->_drawNum = _drawNum++; + // Increment the following tickets, so they still are in line + for (it = pos; it != _renderQueue.end(); it++) { + (*it)->_drawNum++; + (*it)->_wantsDraw = false; + } + addDirtyRect(renderTicket->_dstRect); + } + } else { + // Was drawn last round, still in the same order + if (_drawNum == renderTicket->_drawNum) { + _drawNum++; + } else { + // Remove the ticket from the list + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it) == renderTicket) { + it = _renderQueue.erase(it); + break; + } else { + it++; + } + } + // Is not in order, so readd it as if it was a new ticket + renderTicket->_drawNum = 0; + drawFromTicket(renderTicket); + } + } +} + +void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); +} + +void CBRenderOSystem::drawTickets() { + RenderQueueIterator it = _renderQueue.begin(); + // Clean out the old tickets + int decrement = 0; + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { + RenderTicket* ticket = *it; + addDirtyRect((*it)->_dstRect); + //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); + it = _renderQueue.erase(it); + delete ticket; + decrement++; + } else { + (*it)->_drawNum -= decrement; + it++; + } + } + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) + return; + // The color-mods are stored in the RenderTickets on add, since we set that state again during + // draw, we need to keep track of what it was prior to draw. + uint32 oldColorMod = _colorMod; +// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); + + // Apply the clear-color to the dirty rect. + _renderSurface->fillRect(*_dirtyRect, _clearColor); + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + RenderTicket *ticket = *it; + if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { + // dstClip is the area we want redrawn. + Common::Rect dstClip(ticket->_dstRect); + // reduce it to the dirty rect + dstClip.clip(*_dirtyRect); + // we need to keep track of the position to redraw the dirty rect + Common::Rect pos(dstClip); + int16 offsetX = ticket->_dstRect.left; + int16 offsetY = ticket->_dstRect.top; + // convert from screen-coords to surface-coords. + dstClip.translate(-offsetX, -offsetY); + + _colorMod = ticket->_colorMod; + drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + _needsFlip = true; + } + // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) + ticket->_wantsDraw = false; + } + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + + // Revert the colorMod-state. + _colorMod = oldColorMod; +} + +// Replacement for SDL2's SDL_RenderCopy +void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { + TransparentSurface src(*surf, false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(surf->w); + clipRect->setHeight(surf->h); + } + + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) + delete clipRect; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::DrawLine - not fully ported yet"); + hasWarned = true; + } + byte r = RGBCOLGetR(color); + byte g = RGBCOLGetG(color); + byte b = RGBCOLGetB(color); + byte a = RGBCOLGetA(color); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + + Point32 point1, point2; + point1.x = x1; + point1.y = y1; + pointToScreen(&point1); + + point2.x = x2; + point2.y = y2; + pointToScreen(&point2); + + // TODO: This thing is mostly here until I'm sure about the final color-format. + uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderOSystem::takeScreenshot() { +// TODO: Fix this + warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); + CBImage *screenshot = new CBImage(_gameRef); + screenshot->copyFrom(_renderSurface); + return screenshot; +#if 0 + SDL_Rect viewport; + + SDL_RenderGetViewport(_renderer, &viewport); + + SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); + if (!surface) return NULL; + + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + + FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + + int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); + + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + byte *bits = FreeImage_GetScanLine(dib, y); + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + memcpy(bits, src, bytespp * viewport.w); + } + + return new CBImage(_gameRef, dib); +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::switchFullscreen() { + /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); + else SDL_SetWindowFullscreen(_win, SDL_FALSE); + + _windowed = !_windowed; + */ + _gameRef->_registry->writeBool("Video", "Windowed", _windowed); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBRenderOSystem::getName() { + if (_name.empty()) { +#if 0 + if (_renderer) { + SDL_RendererInfo info; + SDL_GetRendererInfo(_renderer, &info); + _name = AnsiString(info.name); + } +#endif + } + return _name.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = (int16)(left + _borderLeft); + rect.top = (int16)(top + _borderTop); + rect.right = (int16)((right - left) * _ratioX); + rect.bottom = (int16)((bottom - top) * _ratioY); + + // TODO fix this once viewports work correctly in SDL/landscape +#ifndef __IPHONEOS__ + //SDL_RenderSetViewport(GetSdlRenderer(), &rect); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::modTargetRect(Common::Rect *rect) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * _ratioX); + rect->h = MathUtil::RoundUp(rect->h * _ratioY); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointFromScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; + point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointToScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::dumpData(const char *filename) { + warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO +#if 0 + FILE *f = fopen(filename, "wt"); + if (!f) return; + + CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; + + int TotalKB = 0; + int TotalLoss = 0; + fprintf(f, "Filename;Usage;Size;KBytes\n"); + for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { + CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; + if (!Surf->_filename) continue; + if (!Surf->_valid) continue; + + fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); + fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); + + int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; + + TotalKB += kb; + fprintf(f, "%d;", kb); + fprintf(f, "\n"); + } + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); + + + fclose(f); + _gameRef->LOG(0, "Texture Stats Dump completed."); + _gameRef->QuickMessage("Texture Stats Dump completed."); +#endif +} + +CBSurface *CBRenderOSystem::createSurface() { + return new CBSurfaceOSystem(_gameRef); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h new file mode 100644 index 0000000000..d41d14ef35 --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -0,0 +1,129 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_SDL_H +#define WINTERMUTE_BRENDERER_SDL_H + +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "common/list.h" + +namespace WinterMute { +class CBSurfaceOSystem; +class RenderTicket { +public: + RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + Graphics::Surface *_surface; + Common::Rect _srcRect; + Common::Rect _dstRect; + uint32 _mirror; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + CBSurfaceOSystem *_owner; + bool operator==(RenderTicket &a); +}; + +class CBRenderOSystem : public CBRenderer { +public: + CBRenderOSystem(CBGame *inGame); + ~CBRenderOSystem(); + + const char *getName(); + + bool initRenderer(int width, int height, bool windowed); + bool flip(); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + + bool fade(uint16 alpha); + bool fadeToColor(uint32 color, Common::Rect *rect = NULL); + + bool switchFullscreen(); + + bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + + CBImage *takeScreenshot(); + + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); + void drawFromTicket(RenderTicket *renderTicket); + + bool setViewport(int left, int top, int right, int bottom); + + void modTargetRect(Common::Rect *rect); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); + + void dumpData(const char *filename); + + float getScaleRatioX() const { + return _ratioX; + } + float getScaleRatioY() const { + return _ratioY; + } + + void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + CBSurface *createSurface(); +private: + void addDirtyRect(const Common::Rect &rect); + void drawTickets(); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); + typedef Common::List::iterator RenderQueueIterator; + Common::Rect *_dirtyRect; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; + Common::Rect _renderRect; + Graphics::Surface *_renderSurface; + AnsiString _name; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + bool _disableDirtyRects; + float _ratioX; + float _ratioY; + uint32 _colorMod; + uint32 _clearColor; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp new file mode 100644 index 0000000000..1e4ac9a19e --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -0,0 +1,532 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/PlatformSDL.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/decoders/jpeg.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/tga.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + _hasAlpha = true; + _lockPixels = NULL; + _lockPitch = 0; + _loaded = false; +} + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::~CBSurfaceOSystem() { + //TODO + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + delete[] _alphaMask; + _alphaMask = NULL; + + _gameRef->addMem(-_width * _height * 4); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); +} + +bool hasTransparency(Graphics::Surface *surf) { + if (surf->format.bytesPerPixel != 4) { + warning("hasTransparency:: non 32 bpp surface passed as argument"); + return false; + } + uint8 r, g, b, a; + for (int i = 0; i < surf->h; i++) { + for (int j = 0; j < surf->w; j++) { + uint32 pix = *(uint32 *)surf->getBasePtr(j, i); + surf->format.colorToARGB(pix, a, r, g, b); + if (a != 255) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ + _filename = filename; +// const Graphics::Surface *surface = image->getSurface(); + + if (defaultCK) { + ckRed = 255; + ckGreen = 0; + ckBlue = 255; + } + + _ckDefault = defaultCK; + _ckRed = ckRed; + _ckGreen = ckGreen; + _ckBlue = ckBlue; + + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + _lifeTime = lifeTime; + + _keepLoaded = keepLoaded; + if (_keepLoaded) _lifeTime = -1; + + return STATUS_OK; +} + +void CBSurfaceOSystem::finishLoad() { + CBImage *image = new CBImage(_gameRef); + image->loadFile(_filename); + + _width = image->getSurface()->w; + _height = image->getSurface()->h; + + bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); + /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ + } + + // no alpha, set color key + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + delete _surface; + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); + } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*image->getSurface()); + } + + _hasAlpha = hasTransparency(_surface); + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO + //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Surface-textures not fully ported yet"); + hasWarned = true; + } + //delete imgDecoder; +#if 0 + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!_texture) { + SDL_FreeSurface(surf); + delete imgDecoder; + return STATUS_FAILED; + } + + GenAlphaMask(surf); + + SDL_FreeSurface(surf); + delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. +#endif + + _valid = true; + + _gameRef->addMem(_width * _height * 4); + + delete image; + + _loaded = true; +} + +////////////////////////////////////////////////////////////////////////// +void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); + return; + + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) return; +#if 0 + SDL_LockSurface(surface); +#endif + bool hasColorKey; + /* uint32 colorKey; */ + uint8 ckRed, ckGreen, ckBlue; + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ //TODO + _alphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + uint32 pixel = getPixel(surface, x, y); + + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + a = 0; + + _alphaMask[y * surface->w + x] = a; + if (a < 255) hasTransparency = true; + } + } +#if 0 + SDL_UnlockSurface(surface); +#endif + if (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { + warning("CBSurfaceOSystem::GetPixel - Not ported yet"); + int bpp = surface->format.bytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(uint16 *)p; + break; + + case 3: +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + //else + return p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + return *(uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(int width, int height) { + warning("CBSurfaceOSystem::Create not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); +#endif + _width = width; + _height = height; + + _gameRef->addMem(_width * _height * 4); + + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); +#endif + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + _width = surface->w; + _height = surface->h; +#if 0 + _gameRef->AddMem(_width * _height * 4); +#endif + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAt(int x, int y) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); + hasWarned = true; + } +#if 0 + int access; + int width, height; + //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + + StartPixelOp(); + bool ret = isTransparentAtLite(X, Y); + EndPixelOp(); + + return ret; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { + //if (!_lockPixels) return false; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); + hasWarned = true; + } + if (_surface->format.bytesPerPixel == 4) { + uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); + uint8 r, g, b, a; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } +#if 0 + uint32 format; + int access; + int width, height; + + //SDL_QueryTexture(_texture, &format, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + if (!_alphaMask) return false; + else return _alphaMask[Y * width + X] <= 128; +#endif + return false; + /* + Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); + Uint32 pixel = dst[X]; + + SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); + SDL_FreeFormat(pixelFormat); + + return a <= 128; + */ +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::startPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::endPixelOp() { + //SDL_UnlockTexture(_texture); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + if (!_loaded) { + finishLoad(); + } + + if (renderer->_forceAlphaColor != 0) + alpha = renderer->_forceAlphaColor; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. + hasWarned = true; + } + + byte r = RGBCOLGetR(alpha); + byte g = RGBCOLGetG(alpha); + byte b = RGBCOLGetB(alpha); + byte a = RGBCOLGetA(alpha); + + renderer->setAlphaMod(a); + renderer->setColorMod(r, g, b); +#if 0 + SDL_SetTextureColorMod(_texture, r, g, b); + SDL_SetTextureAlphaMod(_texture, a); + + if (AlphaDisable) + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); + else + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = rect->left; + srcRect.top = rect->top; + srcRect.setWidth(rect->right - rect->left); + srcRect.setHeight(rect->bottom - rect->top); + + Common::Rect position; + position.left = x + offsetX; + position.top = y + offsetY; + // TODO: Scaling... + + if (position.left == -1) { + position.left = 0; // TODO: Something is wrong + } + if (position.top == -1) { + position.top = 0; // TODO: Something is wrong + } + + position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); + position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); + + renderer->modTargetRect(&position); + + /* position.left += offsetX; + position.top += offsetY;*/ + + // TODO: This actually requires us to have the SAME source-offsets every time, + // But no checking is in place for that yet. + + bool hasAlpha; + if (_hasAlpha && !alphaDisable) { + hasAlpha = true; + } else { + hasAlpha = false; + } + if (alphaDisable) { + warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); + } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); +#if 0 + SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); +#endif + + return STATUS_OK; +} + +bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; + _surface->copyFrom(surface); + _hasAlpha = hasAlpha; + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h new file mode 100644 index 0000000000..091e8ccba8 --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -0,0 +1,101 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESDL_H +#define WINTERMUTE_BSURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/list.h" + +namespace WinterMute { +struct TransparentSurface; +class CBImage; +class CBSurfaceOSystem : public CBSurface { +public: + CBSurfaceOSystem(CBGame *inGame); + ~CBSurfaceOSystem(); + + bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(int width, int height); + + bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + + bool isTransparentAt(int x, int y); + bool isTransparentAtLite(int x, int y); + + bool startPixelOp(); + bool endPixelOp(); + + + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + virtual int getWidth() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->w; + } + return _width; + } + virtual int getHeight() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->h; + } + return _height; + } + +private: + Graphics::Surface *_surface; + bool _loaded; + void finishLoad(); + bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + void genAlphaMask(Graphics::Surface *surface); + uint32 getPixel(Graphics::Surface *surface, int x, int y); + + bool _hasAlpha; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp new file mode 100644 index 0000000000..81147a5432 --- /dev/null +++ b/engines/wintermute/base/particles/PartEmitter.cpp @@ -0,0 +1,1199 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/PartEmitter.h" +#include "engines/wintermute/base/particles/PartParticle.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/math.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + for (int i = 0; i < _forces.getSize(); i++) { + delete _forces[i]; + } + _forces.removeAll(); + + + for (int i = 0; i < _sprites.getSize(); i++) { + delete [] _sprites[i]; + } + _sprites.removeAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; + + // do we already have the file? + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + } + + // check if file exists + Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else _gameRef->_fileManager->closeFile(File); + + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); + _sprites.add(Str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeSprite(const char *filename) { + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; + + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); + + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::update() { + if (!_running) return STATUS_OK; + else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) numLive++; + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; + else { + particle = new CPartParticle(_gameRef); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + sortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::display(CBRegion *region) { + if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + + for (int i = 0; i < _particles.getSize(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + } + + _particles[i]->display(this); + } + + if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::start() { + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = _gameRef->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::sortParticlesByZ() { + // sort particles by _posY + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; + + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::addForceByName(const char *name) { + CPartForce *force = NULL; + + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new CPartForce(_gameRef); + if (force) { + force->setName(name); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return STATUS_FAILED; + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeForce(const char *name) { + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) numAlive++; + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + int numForces; + if (persistMgr->_saving) { + numForces = _forces.getSize(); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < _forces.getSize(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + int numParticles; + if (persistMgr->_saving) { + numParticles = _particles.getSize(); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(_gameRef); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartEmitter.h b/engines/wintermute/base/particles/PartEmitter.h new file mode 100644 index 0000000000..5156783653 --- /dev/null +++ b/engines/wintermute/base/particles/PartEmitter.h @@ -0,0 +1,139 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/particles/PartForce.h" + +namespace WinterMute { +class CBRegion; +class CPartParticle; +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(CBRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + CBArray _forces; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + CPartForce *addForceByName(const char *name); + int static compareZ(const void *obj1, const void *obj2); + bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/PartForce.cpp b/engines/wintermute/base/particles/PartForce.cpp new file mode 100644 index 0000000000..b864c05292 --- /dev/null +++ b/engines/wintermute/base/particles/PartForce.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/particles/PartForce.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartForce::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartForce.h b/engines/wintermute/base/particles/PartForce.h new file mode 100644 index 0000000000..640c8d7f20 --- /dev/null +++ b/engines/wintermute/base/particles/PartForce.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BNamedObject.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp new file mode 100644 index 0000000000..aa641f0a1c --- /dev/null +++ b/engines/wintermute/base/particles/PartParticle.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/PartParticle.h" +#include "engines/wintermute/base/particles/PartEmitter.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::getInstance()->_disabled = true; + _sprite = new CBSprite(_gameRef, _gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!CBPlatform::ptInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return STATUS_OK; + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (int i = 0; i < emitter->_forces.getSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = CBUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * elapsedTime; + else + _scale += _growthRate * elapsedTime; + + if (_scale <= 0.0f) + _isDead = true; + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; + + _sprite->GetCurrentFrame(); + return _sprite->display(_pos.x, _pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + CSysClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + CSysClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartParticle.h b/engines/wintermute/base/particles/PartParticle.h new file mode 100644 index 0000000000..ab5730d3c5 --- /dev/null +++ b/engines/wintermute/base/particles/PartParticle.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(CPartEmitter *emitter); + + bool setSprite(const char *filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXArray.cpp b/engines/wintermute/base/scriptables/SXArray.cpp new file mode 100644 index 0000000000..425118a3e7 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXArray.cpp @@ -0,0 +1,238 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/system/SysInstance.h" +#include "engines/wintermute/base/scriptables/SXArray.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { + return new CSXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); + + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) _length = stack->pop()->getInt(0); + else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXArray::scToString() { + static char dummy[32768]; // TODO: Get rid of static. + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + CScValue *val = _values->getProp(propName); + if (val) { + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); + } + } + + if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + } + return dummy; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Push") == 0) { + int numParams = stack->pop()->getInt(0); + char paramName[20]; + + for (int i = 0; i < numParams; i++) { + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); + } + stack->pushInt(_length); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Pop") == 0) { + + stack->correctParams(0); + + if (_length > 0) { + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); + _length--; + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (validNumber(name, ParamName)) { + return _values->getProp(ParamName); + } else return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length") == 0) { + int OrigLength = _length; + _length = MAX(value->getInt(0), 0); + + char PropName[20]; + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + _values->deleteProp(PropName); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + int Index = atoi(paramName); + if (Index >= _length) _length = Index + 1; + return _values->setProp(paramName, value); + } else return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::validNumber(const char *origStr, char *outStr) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::push(CScValue *val) { + char paramName[20]; + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXArray.h b/engines/wintermute/base/scriptables/SXArray.h new file mode 100644 index 0000000000..0f46bd546e --- /dev/null +++ b/engines/wintermute/base/scriptables/SXArray.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + bool push(CScValue *Val); + bool validNumber(const char *origStr, char *outStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + int _length; + CScValue *_values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXDate.cpp b/engines/wintermute/base/scriptables/SXDate.cpp new file mode 100644 index 0000000000..cd705cc9d4 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXDate.cpp @@ -0,0 +1,297 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/SXDate.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { + return new CSXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + CScValue *valYear = stack->pop(); + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { + g_system->getTimeAndDate(_tm); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXDate::scToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); +#if 0 + return asctime(&_tm); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetYear") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMonth") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDate") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHours") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMinutes") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_min); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSeconds") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWeekday") == 0) { + stack->correctParams(0); + warning("GetWeekday returns a wrong value on purpose"); + stack->pushInt(_tm.tm_mday % 7); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetYear") == 0) { + stack->correctParams(1); + _tm.tm_year = stack->pop()->getInt() - 1900; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMonth") == 0) { + stack->correctParams(1); + _tm.tm_mon = stack->pop()->getInt() - 1; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDate") == 0) { + stack->correctParams(1); + _tm.tm_mday = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHours") == 0) { + stack->correctParams(1); + _tm.tm_hour = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMinutes") == 0) { + stack->correctParams(1); + _tm.tm_min = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSeconds") == 0) { + stack->correctParams(1); + _tm.tm_sec = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->correctParams(0); + g_system->getTimeAndDate(_tm); + stack->pushNULL(); + return STATUS_OK; + } + + else + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CSXDate::scCompare(CBScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((CSXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXDate.h b/engines/wintermute/base/scriptables/SXDate.h new file mode 100644 index 0000000000..df0641983f --- /dev/null +++ b/engines/wintermute/base/scriptables/SXDate.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + +#include "common/system.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int scCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + char *_string; + TimeDate _tm; +private: + Common::String _strRep; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp new file mode 100644 index 0000000000..b2a6d24677 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXFile.cpp @@ -0,0 +1,779 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/SysClassRegistry.h" +#include "engines/wintermute/system/SysClass.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/SXFile.h" + +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { + return new CSXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + _filename = NULL; + if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::close() { + if (_readFile) { + _gameRef->_fileManager->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXFile::scToString() { + if (_filename) return _filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + CBUtils::setString(&_filename, filename); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->correctParams(1); + close(); + _mode = stack->pop()->getInt(1); + if (_mode < 1 || _mode > 3) { + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); + _mode = 1; + } + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) { + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + if (strcmp(name, "OpenAsText") == 0) { + if (_mode == 2) _writeFile = openForWrite(_filename, false); + else _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) _writeFile = openForWrite(_filename, true); + else _writeFile = openForAppend(_filename, true); + } + + if (!_writeFile) { + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } + + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + close(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPosition") == 0) { + stack->correctParams(1); + if (_mode == 0) { + script->runtimeError("File.%s: File is not open", name); + stack->pushBool(false); + } else { + int Pos = stack->pop()->getInt(); + stack->pushBool(setPos(Pos)); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(0); + close(); + stack->pushBool(CBPlatform::deleteFile(_filename) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Copy") == 0) { + stack->correctParams(2); + const char *Dest = stack->pop()->getString(); + bool Overwrite = stack->pop()->getBool(true); + + close(); + stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadLine") == 0) { + stack->correctParams(0); + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + bool foundNewLine = false; + bool ret = STATUS_FAILED; + do { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + buf[counter] = '\0'; + foundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } while (DID_SUCCEED(ret)); + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (!foundNewLine && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadText") == 0) { + stack->correctParams(1); + int textLen = stack->pop()->getInt(); + + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + + bool ret = STATUS_FAILED; + while (counter < (uint32)textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (textLen > 0 && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->correctParams(1); + const char *line = stack->pop()->getString(); + if (!_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in text mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadBool") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadByte") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadShort") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadFloat") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + float val; + (*(uint32*)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadString") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); + } + delete [] str; + } else stack->pushNULL(); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteByte") == 0) { + stack->correctParams(1); + byte val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteShort") == 0) { + stack->correctParams(1); + int16 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint16LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->correctParams(1); + int32 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint32LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteFloat") == 0) { + stack->correctParams(1); + float val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + uint32 *ptr = (uint32*)&val; + _writeFile->writeUint32LE(*ptr); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); + stack->correctParams(1); + double val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteString") == 0) { + stack->correctParams(1); + const char *val = stack->pop()->getString(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + + uint32 size = strlen(val); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Position") == 0) { + _scValue->setInt(getPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(getLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextMode") == 0) { + _scValue->setBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccessMode") == 0) { + _scValue->setInt(_mode); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getPos() { + if (_mode == 1 && _readFile) + return _readFile->pos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) + return _readFile->seek(pos, whence); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getLength() { + if (_mode == 1 && _readFile) + return _readFile->size(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - reading length for WriteFile not supported"); + return 0; +/* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->_saving) { + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); + } else { + persistMgr->transfer(TMEMBER(pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) + close(); + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) + _writeFile = openForWrite(_filename, false); + else + _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) + _writeFile = openForWrite(_filename, true); + else + _writeFile = openForAppend(_filename, true); + } + if (_writeFile) + close(); + } + setPos(pos); + } + } + + return STATUS_OK; +} + +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXFile.h b/engines/wintermute/base/scriptables/SXFile.h new file mode 100644 index 0000000000..709d1f4378 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXFile.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/base/BScriptable.h" +#include "common/stream.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + Common::SeekableReadStream *_readFile; + Common::WriteStream *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void close(); + void cleanup(); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 Pos, int whence = SEEK_SET); + char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXMath.cpp b/engines/wintermute/base/scriptables/SXMath.cpp new file mode 100644 index 0000000000..fb2838ee94 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMath.cpp @@ -0,0 +1,295 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/persistent.h" +#include "common/math.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +CBScriptable *makeSXMath(CBGame *inGame) { + return new CSXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Abs") == 0) { + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Acos") == 0) { + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Asin") == 0) { + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan") == 0) { + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan2") == 0) { + stack->correctParams(2); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); + stack->pushFloat(atan2(y, x)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ceil") == 0) { + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cos") == 0) { + stack->correctParams(1); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cosh") == 0) { + stack->correctParams(1); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exp") == 0) { + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Floor") == 0) { + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log") == 0) { + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log10") == 0) { + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pow") == 0) { + stack->correctParams(2); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); + + stack->pushFloat(pow(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sin") == 0) { + stack->correctParams(1); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sinh") == 0) { + stack->correctParams(1); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tan") == 0) { + stack->correctParams(1); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tanh") == 0) { + stack->correctParams(1); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sqrt") == 0) { + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DegToRad") == 0) { + stack->correctParams(1); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RadToDeg") == 0) { + stack->correctParams(1); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PI") == 0) { + _scValue->setFloat(M_PI); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMath.h b/engines/wintermute/base/scriptables/SXMath.h new file mode 100644 index 0000000000..4389de611f --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMath.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + +private: + double degreeToRadian(double value); + double radianToDegree(double value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.cpp b/engines/wintermute/base/scriptables/SXMemBuffer.cpp new file mode 100644 index 0000000000..9ac98ab11d --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMemBuffer.cpp @@ -0,0 +1,508 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/SXMemBuffer.h" +#include "common/file.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { + return new CSXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int NewSize = stack->pop()->getInt(); + resize(MAX(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + _size = 0; + _buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::cleanup() { + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::resize(int newSize) { + int oldSize = _size; + + if (_size == 0) { + _buffer = malloc(newSize); + if (_buffer) _size = newSize; + } else { + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; + } else return STATUS_FAILED; + } else { + _buffer = newBuf; + _size = newSize; + } + } + + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { + if (_buffer == NULL) { + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) + return true; + + if (start < 0 || length == 0 || start + length > _size) { + script->runtimeError("Set/Get method call is out of bounds"); + return false; + } else + return true; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSize") == 0) { + stack->correctParams(1); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (DID_SUCCEED(resize(newSize))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBool") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushNULL(); + else + stack->pushBool(*(bool *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetByte") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushNULL(); + else + stack->pushInt(*(byte *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetShort") == 0) { + stack->correctParams(1); + int Start = stack->pop()->getInt(); + if (!checkBounds(script, Start, sizeof(short))) + stack->pushNULL(); + else + stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) + stack->pushNULL(); + else + stack->pushInt(*(int *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFloat") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) + stack->pushNULL(); + else + stack->pushFloat(*(float *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDouble") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) + stack->pushNULL(); + else + stack->pushFloat(*(double *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); + + // find end of string + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + length = i - start; + break; + } + } + } + + if (!checkBounds(script, start, length)) + stack->pushNULL(); + else { + char *str = new char[length + 1]; + strncpy(str, (const char *)_buffer + start, length); + str[length] = '\0'; + stack->pushString(str); + delete [] str; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPointer") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushNULL(); + else { + void *pointer = *(void **)((byte *)_buffer + start); + CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + stack->pushNative(buf, false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBool") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); + + if (!checkBounds(script, start, sizeof(bool))) + stack->pushBool(false); + else { + *(bool *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetByte") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(byte))) + stack->pushBool(false); + else { + *(byte *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetShort") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(short))) + stack->pushBool(false); + else { + *(short *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(int))) + stack->pushBool(false); + else { + *(int *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFloat") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(float))) + stack->pushBool(false); + else { + *(float *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDouble") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(double))) + stack->pushBool(false); + else { + *(double *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); + + if (!checkBounds(script, start, strlen(val) + 1)) + stack->pushBool(false); + else { + memcpy((byte *)_buffer + start, val, strlen(val) + 1); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPointer") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + /* CScValue *Val = */ stack->pop(); + + if (!checkBounds(script, start, sizeof(void *))) + stack->pushBool(false); + else { + /* + int Pointer = (int)Val->getMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + stack->pushBool(true); + */ + // TODO fix + stack->pushBool(false); + + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->correctParams(0); + if (_buffer && _size) { + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); + } + stack->pushNULL(); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Size") == 0) { + _scValue->setInt(_size); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->_saving) { + if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + } else { + if (_size > 0) { + _buffer = malloc(_size); + persistMgr->getBytes((byte *)_buffer, _size); + } else _buffer = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::scCompare(CBScriptable *val) { + if (_buffer == val->scToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.h b/engines/wintermute/base/scriptables/SXMemBuffer.h new file mode 100644 index 0000000000..09831bf464 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMemBuffer.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXMemBuffer(CBGame *inGame, CScStack *stack); + CSXMemBuffer(CBGame *inGame, void *buffer); + virtual ~CSXMemBuffer(); + virtual void *scToMemBuffer(); + int _size; +private: + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(CScScript *script, int start, int length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXString.cpp b/engines/wintermute/base/scriptables/SXString.cpp new file mode 100644 index 0000000000..ed3d243cb0 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXString.cpp @@ -0,0 +1,404 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/SXString.h" +#include "engines/wintermute/base/scriptables/SXArray.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "common/tokenizer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { + return new CSXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + setStringVal(val->getString()); + } + + if (_capacity == 0) setStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXString::scToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Substring") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); + + if (end < start) CBUtils::swap(&start, &end); + + //try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // stack->pushNULL(); + // } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Substr") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + + CScValue *val = stack->pop(); + int len = val->getInt(); + + if (!val->isNULL() && len <= 0) { + stack->pushString(""); + return STATUS_OK; + } + + if (val->isNULL()) len = strlen(_string) - start; + +// try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); +// } catch (std::exception &) { +// stack->pushNULL(); +// } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToUpperCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toUppercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToLowerCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toLowercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IndexOf") == 0) { + stack->correctParams(2); + + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString toFind; + if (_gameRef->_textEncoding == TEXT_UTF8) + toFind = StringUtil::utf8ToWide(strToFind); + else + toFind = StringUtil::ansiToWide(strToFind); + + int indexOf = StringUtil::indexOf(str, toFind, index); + stack->pushInt(indexOf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Split") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) strcpy(separators, val->getString()); + + CSXArray *array = new CSXArray(_gameRef); + if (!array) { + stack->pushNULL(); + return STATUS_OK; + } + + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString delims; + if (_gameRef->_textEncoding == TEXT_UTF8) + delims = StringUtil::utf8ToWide(separators); + else + delims = StringUtil::ansiToWide(separators); + + Common::Array parts; + + + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size());*/ + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (_gameRef->_textEncoding == TEXT_UTF8) + val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + else + val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(_string); + _scValue->setInt(wstr.size()); + } else + _scValue->setInt(strlen(_string)); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Capacity") == 0) { + _scValue->setInt(_capacity); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Capacity") == 0) { + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); + else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); + delete[] _string; + _string = newStr; + _capacity = newCap; + } + } + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->_saving) { + if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + persistMgr->getBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::scCompare(CBScriptable *val) { + return strcmp(_string, ((CSXString *)val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXString.h b/engines/wintermute/base/scriptables/SXString.h new file mode 100644 index 0000000000..348595ad29 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXString.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + void scSetString(const char *val); + const char *scToString(); + void setStringVal(const char *val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScEngine.cpp b/engines/wintermute/base/scriptables/ScEngine.cpp new file mode 100644 index 0000000000..db79a7d0e9 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScEngine.cpp @@ -0,0 +1,712 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BFileManager.h" + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + _gameRef->LOG(0, "Initializing scripting engine..."); + + if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); + else _gameRef->LOG(0, " Script compiler is NOT available"); + + _globals = new CScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + CScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + CScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); + _globals->setProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + + _currentScript = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + saveBreakpoints(); + + disableProfiling(); + + cleanup(); + + for (int i = 0; i < _breakpoints.getSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; + } + _breakpoints.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::cleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + + _scripts.removeAll(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { + CBGame *gameRef = (CBGame *)data; + return gameRef->_fileManager->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::closeFile(void *data, byte *buffer) { + delete [] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(_gameRef, this); + bool ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { + _gameRef->LOG(ret, "Error running script '%s'...", filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(_gameRef); + if (owner)val.setNative(owner, true); + else val.setNULL(); + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + _gameRef->getDebugMgr()->onScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { + // is script in cache? + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + return NULL; + } + + // needs to be compiled? + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; + } else { + if (!_compilerAvailable) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + delete [] buffer; + return NULL; + } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { + int index = 0; + uint32 MinTime = CBPlatform::getTime(); + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete [] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tick() { + if (_scripts.getSize() == 0) + return STATUS_OK; + + + // resolve waiting scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + { + if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + { + if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + */ + if (_gameRef->validObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); + } else _scripts[i]->finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + } else { + if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->pushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); + _scripts[i]->run(); + _scripts[i]->_waitScript->finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + default: + //warning("CScEngine::Tick - Unhandled enum"); + break; + } // switch + } // for each script + + + // execute scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 StartTime = CBPlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + } + + // normal script + else { + uint32 startTime = 0; + bool isProfiling = _isProfiling; + if (isProfiling) startTime = CBPlatform::getTime(); + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + _scripts[i]->finish(); + _currentScript = NULL; + } + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeFinishedScripts() { + // remove finished scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + numRunning++; + break; + case SCRIPT_WAITING: + numWaiting++; + break; + case SCRIPT_PERSISTENT: + numPersistent++; + break; + default: + warning("CScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) *running = numRunning; + if (waiting) *waiting = numWaiting; + if (persistent) *persistent = numPersistent; + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetScript(CScScript *script) { + // terminate all scripts waiting for this script + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::editorCleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::pauseAll() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->pause(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resumeAll() { + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->resume(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::isValidScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { + // send global variables + _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->dbgSendScript(client); + } + + // and threads later + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->dbgSendScript(client); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + CScBreakpoint *bp = NULL; + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + bp = _breakpoints[i]; + break; + } + } + if (bp == NULL) { + bp = new CScBreakpoint(scriptFilename); + _breakpoints.add(bp); + } + + for (int i = 0; i < bp->_lines.getSize(); i++) { + if (bp->_lines[i] == line) return STATUS_OK; + } + bp->_lines.add(line); + + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + if (_breakpoints[i]->_lines[j] == line) { + _breakpoints[i]->_lines.removeAt(j); + if (_breakpoints[i]->_lines.getSize() == 0) { + delete _breakpoints[i]; + _breakpoints.removeAt(i); + } + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; + } + } + break; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _scripts.getSize(); i++) { + refreshScriptBreakpoints(_scripts[i]); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints(CScScript *script) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + if (!script || !script->_filename) return STATUS_FAILED; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { + script->_breakpoints.copy(_breakpoints[i]->_lines); + return STATUS_OK; + } + } + if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::saveBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + + char text[512]; + char key[100]; + + int count = 0; + for (int i = 0; i < _breakpoints.getSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + count++; + sprintf(key, "Breakpoint%d", count); + sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + + _gameRef->_registry->writeString("Debug", key, text); + } + } + _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::loadBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + char key[100]; + + int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= count; i++) { + /* uint32 BufSize = 512; */ + sprintf(key, "Breakpoint%d", i); + AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + + char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + + if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + delete[] path; + delete[] line; + path = NULL; + line = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) return; + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::enableProfiling() { + if (_isProfiling) return; + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = CBPlatform::getTime(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::disableProfiling() { + if (!_isProfiling) return; + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h new file mode 100644 index 0000000000..df327d800c --- /dev/null +++ b/engines/wintermute/base/scriptables/ScEngine.h @@ -0,0 +1,147 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(const char *filename, byte *buffer, uint32 size) { + _timestamp = CBPlatform::getTime(); + _buffer = new byte[size]; + if (_buffer) memcpy(_buffer, buffer, size); + _size = size; + _filename = filename; + }; + + ~CScCachedScript() { + if (_buffer) delete [] _buffer; + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *filename) { + _filename = filename; + } + + ~CScBreakpoint() { + _lines.removeAll(); + } + + Common::String _filename; + CBArray _lines; + }; + + + + +public: + bool dbgSendScripts(IWmeDebugClient *client); + + CBArray _breakpoints; + bool addBreakpoint(const char *scriptFilename, int line); + bool removeBreakpoint(const char *scriptFilename, int line); + bool refreshScriptBreakpoints(); + bool refreshScriptBreakpoints(CScScript *script); + bool saveBreakpoints(); + bool loadBreakpoints(); + + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(CScScript *script); + + CScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(CBObject *Object); + bool resetScript(CScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + CScValue *_globals; + CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); + + CBArray _scripts; + + void enableProfiling(); + void disableProfiling(); + bool getIsProfiling() { + return _isProfiling; + } + + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScScript.cpp b/engines/wintermute/base/scriptables/ScScript.cpp new file mode 100644 index 0000000000..0b5b3c24bf --- /dev/null +++ b/engines/wintermute/base/scriptables/ScScript.cpp @@ -0,0 +1,1461 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/memstream.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _scriptStream = NULL; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = Engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + cleanup(); +} + +void CScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.code_start = _scriptStream->readUint32LE(); + _header.func_table = _scriptStream->readUint32LE(); + _header.symbol_table = _scriptStream->readUint32LE(); + _header.event_table = _scriptStream->readUint32LE(); + _header.externals_table = _scriptStream->readUint32LE(); + _header.method_table = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); + + if (_header.magic != SCRIPT_MAGIC) { + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); + cleanup(); + return STATUS_FAILED; + } + + if (_header.version > SCRIPT_VERSION) { + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + cleanup(); + return STATUS_FAILED; + } + + initTables(); + + // init stacks + _scopeStack = new CScStack(_gameRef); + _callStack = new CScStack(_gameRef); + _thisStack = new CScStack(_gameRef); + _stack = new CScStack(_gameRef); + + _operand = new CScValue(_gameRef); + _reg1 = new CScValue(_gameRef); + + + // skip to the beginning + _iP = _header.code_start; + _scriptStream->seek(_iP); + _currentLine = 0; + + // init breakpoints + _engine->refreshScriptBreakpoints(this); + + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initTables() { + uint32 OrigIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbol_table; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.func_table; + + _numFunctions = getDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (uint32 i = 0; i < _numFunctions; i++) { + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); + } + + + // load events table + _iP = _header.event_table; + + _numEvents = getDWORD(); + _events = new TEventPos[_numEvents]; + for (uint32 i = 0; i < _numEvents; i++) { + _events[i].pos = getDWORD(); + _events[i].name = getString(); + } + + + // load externals + if (_header.version >= 0x0101) { + _iP = _header.externals_table; + + _numExternals = getDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (uint32 i = 0; i < _numExternals; i++) { + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)getDWORD(); + } + } + } + } + + // load method table + _iP = _header.method_table; + + _numMethods = getDWORD(); + _methods = new TMethodPos[_numMethods]; + for (uint32 i = 0; i < _numMethods; i++) { + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); + } + + + _iP = OrigIP; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { + cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); + + _buffer = new byte [size]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, buffer, size); + + _bufferSize = size; + + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // establish global variables table + _globals = new CScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(eventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, eventName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = initIP; + _scriptStream->seek(_iP); + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createMethodThread(CScScript *original, const char *methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) return STATUS_FAILED; + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(methodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, methodName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = ip; + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::cleanup() { + if (_buffer) delete [] _buffer; + _buffer = NULL; + + if (_filename) delete [] _filename; + _filename = NULL; + + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) delete _globals; + _globals = NULL; + + delete _scopeStack; + _scopeStack = NULL; + + delete _callStack; + _callStack = NULL; + + delete _thisStack; + _thisStack = NULL; + + delete _stack; + _stack = NULL; + + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; + + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; + + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (uint32 i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; + } + delete [] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only + + delete _scriptStream; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double CScScript::getFloat() { + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //CScValue* op = new CScValue(_gameRef); + _operand->cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = getDWORD(); + /* char *Temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); + + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = getDWORD(); + + _operand->setInt(_iP); + _callStack->push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->pop()->getString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = _stack->pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + + bool res = STATUS_FAILED; + bool TriedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + TriedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } + + if (DID_FAIL(res)) { + if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (!_unbreakable) { + _waitScript = var->getNative()->invokeMethodThread(MethodName); + if (!_waitScript) { + _stack->correctParams(0); + runtimeError("Error invoking method '%s'.", MethodName); + _stack->pushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->copyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->correctParams(0); + runtimeError("Cannot call method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->getProp(MethodName); + if(val){ + dw = GetFuncPos(val->getString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->getString()); + if(f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); + } + } + else{ + _operand->setInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = STATUS_FAILED; + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + + if (DID_FAIL(res)) { + _stack->correctParams(0); + runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = getDWORD(); + + TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + if (f) { + externalCall(_stack, _thisStack, f); + } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + _operand->setNULL(); + _scopeStack->push(_operand); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + + break; + + case II_CORRECT_STACK: + dw = getDWORD(); // params expected + _stack->correctParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->setObject(); + _stack->push(_operand); + break; + + case II_POP_EMPTY: + _stack->pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = getVar(_symbols[getDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->setReference(var); + _stack->push(_operand); + } else _stack->push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *VarName = _symbols[getDWORD()]; + CScValue *var = getVar(VarName); + if (var) { + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->setValue(val); + else { + var->copy(val); + } + } + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->push(_thisStack->getTop()); + break; + + case II_PUSH_INT: + _stack->pushInt((int)getDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->pushFloat(getFloat()); + break; + + + case II_PUSH_BOOL: + _stack->pushBool(getDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->pushString(getString()); + break; + + case II_PUSH_NULL: + _stack->pushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->setReference(_stack->getTop()); + _thisStack->push(_operand); + break; + + case II_PUSH_THIS: + _operand->setReference(getVar(_symbols[getDWORD()])); + _thisStack->push(_operand); + break; + + case II_POP_THIS: + _thisStack->pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *val = _stack->pop()->getProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); + + if (val == NULL) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else var->setProp(str, val); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + _stack->push(_reg1); + break; + + case II_POP_REG1: + _reg1->copy(_stack->pop()); + break; + + case II_JMP: + _iP = getDWORD(); + break; + + case II_JMP_FALSE: { + dw = getDWORD(); + //if(!_stack->pop()->getBool()) _iP = dw; + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!val->getBool()) _iP = dw; + } + break; + } + + case II_ADD: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); + delete [] tempStr; + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() + op2->getInt()); + else _operand->setFloat(op1->getFloat() + op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_SUB: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() - op2->getInt()); + else _operand->setFloat(op1->getFloat() - op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MUL: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() * op2->getInt()); + else _operand->setFloat(op1->getFloat() * op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_DIV: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getFloat() == 0.0f) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); + else _operand->setFloat(op1->getFloat() / op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MODULO: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getInt() == 0) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + _operand->setNULL(); + else _operand->setInt(op1->getInt() % op2->getInt()); + + _stack->push(_operand); + + break; + + case II_NOT: + op1 = _stack->pop(); + //if(op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) _operand->setBool(true); + else _operand->setBool(!op1->getBool()); + _stack->push(_operand); + + break; + + case II_AND: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() && op2->getBool()); + } + _stack->push(_operand); + break; + + case II_OR: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() || op2->getBool()); + } + _stack->push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() == op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) == 0); + _stack->push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() != op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_CMP_L: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); + } + else _operand->setBool(op1->getInt() < op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) < 0); + _stack->push(_operand); + break; + + case II_CMP_G: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); + } + else _operand->setBool(op1->getInt() > op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) > 0); + _stack->push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); + } + else _operand->setBool(op1->getInt() <= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) <= 0); + _stack->push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); + } + else _operand->setBool(op1->getInt() >= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) >= 0); + _stack->push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _stack->push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (_breakpoints[i] == _currentLine) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + if (_tracingMode) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + } + break; + + } + default: + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = STATUS_FAILED; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getFuncPos(const char *name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (strcmp(name, _functions[i].name) == 0) + return _functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getMethodPos(const char *name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (strcmp(name, _methods[i].name) == 0) + return _methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::getVar(char *name) { + CScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->getTop()->propExists(name)) + ret = _scopeStack->getTop()->getProp(name); + } + + // script globals + if (ret == NULL) { + if (_globals->propExists(name)) + ret = _globals->getProp(name); + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->propExists(name)) + ret = _engine->_globals->getProp(name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + CScValue *val = new CScValue(_gameRef); + CScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); + ret = _scopeStack->getTop()->getProp(name); + } else { + _globals->setProp(name, val); + ret = _globals->getProp(name); + } + delete val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitFor(CBObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitForExclusive(CBObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = CBPlatform::getTime() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else _state = SCRIPT_FINISHED; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::runtimeError(const char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); + + if (!_gameRef->_suppressScriptErrors) + _gameRef->quickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + persistMgr->transfer(TMEMBER(bufferSize)); + } + } else { + persistMgr->transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + initTables(); + } else { + _buffer = NULL; + _scriptStream = NULL; + } + } + + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->_saving) _tracingMode = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { + //if(_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getEventPos(const char *name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleEvent(const char *eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleMethod(const char *methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::pause() { + if (_state == SCRIPT_PAUSED) { + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return STATUS_FAILED; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + + _origState = _state; + _state = SCRIPT_PAUSED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::resume() { + if (_state != SCRIPT_PAUSED) return STATUS_OK; + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) + return &_externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::copyParameters(CScStack *stack) { + int i; + int NumParams = stack->pop()->getInt(); + for (i = NumParams - 1; i >= 0; i--) { + _stack->push(stack->getAt(i)); + } + _stack->pushInt(NumParams); + + for (i = 0; i < NumParams; i++) stack->pop(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finishThreads() { + for (int i = 0; i < _engine->_scripts.getSize(); i++) { + CScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + scr->finish(true); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::dbgGetFilename() { + return _filename; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendScript(IWmeDebugClient *client) { + if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else client->onScriptInit(this); + + return dbgSendVariables(client); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendVariables(IWmeDebugClient *client) { + // send script globals + _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + // CScValue *Scope = _scopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::dbgGetState() { + return _state; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetNumBreakpoints() { + return _breakpoints.getSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetBreakpoint(int index) { + if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSetTracingMode(bool isTracing) { + _tracingMode = isTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgGetTracingMode() { + return _tracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::afterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); + if (!buffer) { + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + + initTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScScript.h b/engines/wintermute/base/scriptables/ScScript.h new file mode 100644 index 0000000000..c031f8186f --- /dev/null +++ b/engines/wintermute/base/scriptables/ScScript.h @@ -0,0 +1,183 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + bool dbgSendScript(IWmeDebugClient *client); + bool dbgSendVariables(IWmeDebugClient *client); + + CBArray _breakpoints; + bool _tracingMode; + + CScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(CScStack *stack); + + void afterLoad(); + + CScValue *_operand; + CScValue *_reg1; + bool _freezable; + bool resume(); + bool pause(); + bool canHandleEvent(const char *eventName); + bool canHandleMethod(const char *methodName); + bool createThread(CScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(CScScript *original, const char *methodName); + CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void runtimeError(const char *fmt, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(CBObject *object); + bool waitFor(CBObject *object); + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + CScValue *getVar(char *name); + uint32 getFuncPos(const char *name); + uint32 getEventPos(const char *name); + uint32 getMethodPos(const char *name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + TScriptHeader _header; + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; + bool executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); + void cleanup(); + bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *_filename; + char **_symbols; + uint32 _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; + CScScript::TExternalFunction *getExternal(char *name); + bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); +private: + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); + virtual TScriptState dbgGetState(); + virtual int dbgGetNumBreakpoints(); + virtual int dbgGetBreakpoint(int Index); + + virtual bool dbgSetTracingMode(bool IsTracing); + virtual bool dbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScStack.cpp b/engines/wintermute/base/scriptables/ScStack.cpp new file mode 100644 index 0000000000..252cd21dda --- /dev/null +++ b/engines/wintermute/base/scriptables/ScStack.cpp @@ -0,0 +1,226 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); +#endif + + for (int i = 0; i < _values.getSize(); i++) { + delete _values[i]; + } + _values.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::push(CScValue *val) { + _sP++; + + if (_sP < _values.getSize()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + CScValue *copyVal = new CScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getPushValue() { + _sP++; + + if (_sP >= _values.getSize()) { + CScValue *val = new CScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getTop() { + if (_sP < 0 || _sP >= _values.getSize()) return NULL; + else return _values[_sP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= _values.getSize()) return NULL; + else return _values[index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.removeAt(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + CScValue *nullVal = new CScValue(_gameRef); + nullVal->setNULL(); + _values.insertAt(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if (_values.getSize() > _sP + 1) { + delete _values[_values.getSize() - 1]; + _values.removeAt(_values.getSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNULL() { + /* + CScValue* val = new CScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushInt(int val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushFloat(double val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushBool(bool val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushString(const char *val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNative(CBScriptable *val, bool persistent) { + /* + CScValue* val = new CScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScStack::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_sP)); + _values.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScStack.h b/engines/wintermute/base/scriptables/ScStack.h new file mode 100644 index 0000000000..22dae63060 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScStack.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *getAt(int Index); + CScValue *getPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void pushNative(CBScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); + void pushNULL(); + void correctParams(uint32 expectedParams); + CScValue *getTop(); + void push(CScValue *val); + CScValue *pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray _values; + int _sP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp new file mode 100644 index 0000000000..e9d5645682 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScValue.cpp @@ -0,0 +1,1054 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::cleanup(bool ignoreNatives) { + deleteProps(); + + if (_valString) delete [] _valString; + + if (!ignoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { + _gameRef->_scValue->_type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (_gameRef->_textEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + CScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + + if (ret == NULL) { + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) ret = _valIter->_value; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) + return _valRef->setProp(name, val); + + bool ret = STATUS_FAILED; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scSetProperty(name, val); + } + + if (DID_FAIL(ret)) { + CScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) + newVal = new CScValue(_gameRef); + else newVal->cleanup(); + + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; + + if (_type != VAL_NATIVE) _type = VAL_OBJECT; + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + CScValue* val = new CScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) + return _valRef->propExists(name); + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNULL(); + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNative(); + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isString(); + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isFloat(); + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isInt() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isInt(); + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isBool() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isBool(); + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isObject() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isObject(); + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getType(); + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setBool(bool val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setBool(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetBool(val); + return; + } + + _valBool = val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setInt(int val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setInt(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetInt(val); + return; + } + + _valInt = val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setFloat(double val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setFloat(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetFloat(val); + return; + } + + _valFloat = val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setString(const char *val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setString(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetString(val); + return; + } + + setStringVal(val); + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; +} + +void CScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void CScValue::setStringVal(const char *val) { + if (_valString) { + delete [] _valString; + _valString = NULL; + } + + if (val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(val) + 1]; + if (_valString) { + strcpy(_valString, val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; + } + _valNative = NULL; + deleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNative(CBScriptable *val, bool persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNative(val, persistent); + return; + } + + if (val == NULL) { + setNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != val) delete _valNative; + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = persistent; + + _valNative = val; + if (_valNative && !_persistent) _valNative->_refCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setReference(CScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getBool(); + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->scToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::getInt(int defaultVal) { + if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->scToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getFloat(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->scToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return defaultVal; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getMemBuffer(); + + if (_type == VAL_NATIVE) + return _valNative->scToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::getString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getString(); + + switch (_type) { + case VAL_OBJECT: + setStringVal("[object]"); + break; + + case VAL_NULL: + setStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; + break; + } + + case VAL_BOOL: + setStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + setStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + setStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + setStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::getNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getNative(); + + if (_type == VAL_NATIVE) return _valNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::copy(CScValue *orig, bool copyWhole) { + _gameRef = orig->_gameRef; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + + cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + setStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setValue(CScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { + case VAL_INT: + _valNative->scSetInt(val->getInt()); + break; + case VAL_FLOAT: + _valNative->scSetFloat(val->getFloat()); + break; + case VAL_BOOL: + _valNative->scSetBool(val->getBool()); + break; + case VAL_STRING: + _valNative->scSetString(val->getString()); + break; + default: + warning("CScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else copy(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (persistMgr->_saving) { + size = _valObject.size(); + persistMgr->transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); + + _valIter++; + } + } else { + CScValue *val; + persistMgr->transfer("", &size); + for (int i = 0; i < size; i++) { + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); + + _valObject[str] = val; + delete [] str; + } + } + + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); + + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::compare(CScValue *val1, CScValue *val2) { + // both natives? + if (val1->isNative() && val2->isNative()) { + // same class? + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else return strcmp(val1->getString(), val2->getString()); + } + + // both objects? + if (val1->isObject() && val2->isObject()) return -1; + + + // null states + if (val1->isNULL() && !val2->isNULL()) return -1; + else if (!val1->isNULL() && val2->isNULL()) return 1; + else if (val1->isNULL() && val2->isNULL()) return 0; + + // one of them is string? convert both to string + if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + + // one of them is float? + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) return -1; + else if (val1->getFloat() > val2->getFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (val1->getInt() < val2->getInt()) return -1; + else if (val1->getInt() > val2->getInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::compareStrict(CScValue *val1, CScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; + else return CScValue::compare(val1, val2); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, int value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, const char *value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, double value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, bool value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName) { + CScValue *val = new CScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::dbgGetType() { + switch (getType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetValInt() { + return getInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::dbgGetValFloat() { + return getFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetValBool() { + return getBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::dbgGetValString() { + return getString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::dbgGetValNative() { + return getNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(int value) { + setInt(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(double value) { + setFloat(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(bool value) { + setBool(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(const char *value) { + setString(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal() { + setNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetNumProperties() { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetNumProperties(); + else return _valObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetProperty(index, name, value); + else { + int count = 0; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (count == index) { + *name = _valIter->_key.c_str(); + *value = _valIter->_value; + return true; + } + _valIter++; + count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) + return _valRef->dbgGetDescription(buf, bufSize); + + if (_type == VAL_NATIVE) { + _valNative->scDebuggerDesc(buf, bufSize); + } else { + strncpy(buf, getString(), bufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScValue.h b/engines/wintermute/base/scriptables/ScValue.h new file mode 100644 index 0000000000..c66a60c22a --- /dev/null +++ b/engines/wintermute/base/scriptables/ScValue.h @@ -0,0 +1,141 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + + static int compare(CScValue *val1, CScValue *val2); + static int compareStrict(CScValue *val1, CScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool _isConstVar; + bool saveAsText(CBDynBuffer *buffer, int indent); + void setValue(CScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(CScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); + const char *getString(); + void *getMemBuffer(); + CBScriptable *getNative(); + bool deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(CBScriptable *val, bool persistent = false); + void setObject(); + void setReference(CScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + CScValue *getProp(const char *name); + CBScriptable *_valNative; + CScValue *_valRef; +protected: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType dbgGetType(); + + // getters + virtual int dbgGetValInt(); + virtual double dbgGetValFloat(); + virtual bool dbgGetValBool(); + virtual const char *dbgGetValString(); + virtual IWmeDebugObject *dbgGetValNative(); + + // setters + virtual bool dbgSetVal(int value); + virtual bool dbgSetVal(double value); + virtual bool dbgSetVal(bool value); + virtual bool dbgSetVal(const char *value); + virtual bool dbgSetVal(); + + // properties + virtual int dbgGetNumProperties(); + virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); + + virtual bool dbgGetDescription(char *buf, int bufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SxObject.cpp b/engines/wintermute/base/scriptables/SxObject.cpp new file mode 100644 index 0000000000..ba961ed2ae --- /dev/null +++ b/engines/wintermute/base/scriptables/SxObject.cpp @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SxObject.h" +#include "ScValue.h" +#include "ScStack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { + return new CSXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { + addScript(stack->pop()->getString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SxObject.h b/engines/wintermute/base/scriptables/SxObject.h new file mode 100644 index 0000000000..b4ec7c6cde --- /dev/null +++ b/engines/wintermute/base/scriptables/SxObject.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index fc1d0205c8..e0d7ad8132 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -31,7 +31,7 @@ #include -#include "engines/wintermute/Base/BPersistMgr.h" +#include "engines/wintermute/base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 0112bce137..437ee76035 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -22,7 +22,7 @@ #include "engines/advancedDetector.h" #include "engines/wintermute/wintermute.h" -#include "engines/wintermute/Base/BPersistMgr.h" +#include "engines/wintermute/base/BPersistMgr.h" #include "common/config-manager.h" #include "common/error.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index eab99e1eb5..0c74193dac 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,91 +1,91 @@ MODULE := engines/wintermute MODULE_OBJS := \ - Ad/AdActor.o \ - Ad/AdEntity.o \ - Ad/AdGame.o \ - Ad/AdInventory.o \ - Ad/AdInventoryBox.o \ - Ad/AdItem.o \ - Ad/AdLayer.o \ - Ad/AdNodeState.o \ - Ad/AdObject.o \ - Ad/AdPath.o \ - Ad/AdPathPoint.o \ - Ad/AdRegion.o \ - Ad/AdResponse.o \ - Ad/AdResponseBox.o \ - Ad/AdResponseContext.o \ - Ad/AdRotLevel.o \ - Ad/AdScaleLevel.o \ - Ad/AdScene.o \ - Ad/AdSceneNode.o \ - Ad/AdSceneState.o \ - Ad/AdSentence.o \ - Ad/AdSpriteSet.o \ - Ad/AdTalkDef.o \ - Ad/AdTalkHolder.o \ - Ad/AdTalkNode.o \ - Ad/AdWaypointGroup.o \ - Base/scriptables/ScEngine.o \ - Base/scriptables/ScScript.o \ - Base/scriptables/ScStack.o \ - Base/scriptables/ScValue.o \ - Base/scriptables/SXArray.o \ - Base/scriptables/SXDate.o \ - Base/scriptables/SXFile.o \ - Base/scriptables/SXMath.o \ - Base/scriptables/SxObject.o \ - Base/scriptables/SXMemBuffer.o \ - Base/scriptables/SXString.o \ - Base/file/BDiskFile.o \ - Base/file/BFile.o \ - Base/file/BSaveThumbFile.o \ - Base/file/BPkgFile.o \ - Base/font/BFontBitmap.o \ - Base/font/BFontTT.o \ - Base/font/BFont.o \ - Base/font/BFontStorage.o \ - Base/gfx/base_image.o \ - Base/gfx/base_renderer.o \ - Base/gfx/base_surface.o \ - Base/gfx/osystem/base_surface_osystem.o \ - Base/gfx/osystem/base_render_osystem.o \ - Base/particles/PartParticle.o \ - Base/particles/PartEmitter.o \ - Base/particles/PartForce.o \ - Base/BActiveRect.o \ - Base/BBase.o \ - Base/BDebugger.o \ - Base/BDynBuffer.o \ - Base/BFader.o \ - Base/BFileEntry.o \ - Base/BFileManager.o \ - Base/BGame.o \ - Base/BFrame.o \ - Base/BKeyboardState.o \ - Base/BNamedObject.o \ - Base/BObject.o \ - Base/BPackage.o \ - Base/BParser.o \ - Base/BPersistMgr.o \ - Base/BPoint.o \ - Base/BQuickMsg.o \ - Base/BRegion.o \ - Base/BRegistry.o \ - Base/BResources.o \ - Base/BSaveThumbHelper.o \ - Base/BScriptable.o \ - Base/BScriptHolder.o \ - Base/BSound.o \ - Base/BSoundBuffer.o \ - Base/BSoundMgr.o \ - Base/BSprite.o \ - Base/BStringTable.o \ - Base/BSubFrame.o \ - Base/BSurfaceStorage.o \ - Base/BTransitionMgr.o \ - Base/BViewport.o \ + ad/AdActor.o \ + ad/AdEntity.o \ + ad/AdGame.o \ + ad/AdInventory.o \ + ad/AdInventoryBox.o \ + ad/AdItem.o \ + ad/AdLayer.o \ + ad/AdNodeState.o \ + ad/AdObject.o \ + ad/AdPath.o \ + ad/AdPathPoint.o \ + ad/AdRegion.o \ + ad/AdResponse.o \ + ad/AdResponseBox.o \ + ad/AdResponseContext.o \ + ad/AdRotLevel.o \ + ad/AdScaleLevel.o \ + ad/AdScene.o \ + ad/AdSceneNode.o \ + ad/AdSceneState.o \ + ad/AdSentence.o \ + ad/AdSpriteSet.o \ + ad/AdTalkDef.o \ + ad/AdTalkHolder.o \ + ad/AdTalkNode.o \ + ad/AdWaypointGroup.o \ + base/scriptables/ScEngine.o \ + base/scriptables/ScScript.o \ + base/scriptables/ScStack.o \ + base/scriptables/ScValue.o \ + base/scriptables/SXArray.o \ + base/scriptables/SXDate.o \ + base/scriptables/SXFile.o \ + base/scriptables/SXMath.o \ + base/scriptables/SxObject.o \ + base/scriptables/SXMemBuffer.o \ + base/scriptables/SXString.o \ + base/file/BDiskFile.o \ + base/file/BFile.o \ + base/file/BSaveThumbFile.o \ + base/file/BPkgFile.o \ + base/font/BFontBitmap.o \ + base/font/BFontTT.o \ + base/font/BFont.o \ + base/font/BFontStorage.o \ + base/gfx/base_image.o \ + base/gfx/base_renderer.o \ + base/gfx/base_surface.o \ + base/gfx/osystem/base_surface_osystem.o \ + base/gfx/osystem/base_render_osystem.o \ + base/particles/PartParticle.o \ + base/particles/PartEmitter.o \ + base/particles/PartForce.o \ + base/BActiveRect.o \ + base/BBase.o \ + base/BDebugger.o \ + base/BDynBuffer.o \ + base/BFader.o \ + base/BFileEntry.o \ + base/BFileManager.o \ + base/BGame.o \ + base/BFrame.o \ + base/BKeyboardState.o \ + base/BNamedObject.o \ + base/BObject.o \ + base/BPackage.o \ + base/BParser.o \ + base/BPersistMgr.o \ + base/BPoint.o \ + base/BQuickMsg.o \ + base/BRegion.o \ + base/BRegistry.o \ + base/BResources.o \ + base/BSaveThumbHelper.o \ + base/BScriptable.o \ + base/BScriptHolder.o \ + base/BSound.o \ + base/BSoundBuffer.o \ + base/BSoundMgr.o \ + base/BSprite.o \ + base/BStringTable.o \ + base/BSubFrame.o \ + base/BSurfaceStorage.o \ + base/BTransitionMgr.o \ + base/BViewport.o \ detection.o \ graphics/transparentSurface.o \ graphics/tga.o \ @@ -93,20 +93,20 @@ MODULE_OBJS := \ math/Matrix4.o \ math/Vector2.o \ PlatformSDL.o \ - Sys/SysClass.o \ - Sys/SysClassRegistry.o \ - Sys/SysInstance.o \ + system/SysClass.o \ + system/SysClassRegistry.o \ + system/SysInstance.o \ tinyxml/tinyxml.o \ tinyxml/tinystr.o \ tinyxml/tinyxmlparser.o \ tinyxml/tinyxmlerror.o \ - UI/UIButton.o \ - UI/UIEdit.o \ - UI/UIEntity.o \ - UI/UIObject.o \ - UI/UIText.o \ - UI/UITiledImage.o \ - UI/UIWindow.o \ + ui/UIButton.o \ + ui/UIEdit.o \ + ui/UIEntity.o \ + ui/UIObject.o \ + ui/UIText.o \ + ui/UITiledImage.o \ + ui/UIWindow.o \ utils/ConvertUTF.o \ utils/crc.o \ utils/PathUtil.o \ diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 5c09022746..fb00419100 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -26,65 +26,65 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/Ad/AdActor.h" -#include "engines/wintermute/Ad/AdEntity.h" -#include "engines/wintermute/Ad/AdGame.h" -#include "engines/wintermute/Ad/AdInventory.h" -#include "engines/wintermute/Ad/AdInventoryBox.h" -#include "engines/wintermute/Ad/AdItem.h" -#include "engines/wintermute/Ad/AdLayer.h" -#include "engines/wintermute/Ad/AdNodeState.h" -#include "engines/wintermute/Ad/AdObject.h" -#include "engines/wintermute/Ad/AdPath.h" -#include "engines/wintermute/Ad/AdPathPoint.h" -#include "engines/wintermute/Ad/AdRegion.h" -#include "engines/wintermute/Ad/AdResponse.h" -#include "engines/wintermute/Ad/AdResponseBox.h" -#include "engines/wintermute/Ad/AdResponseContext.h" -#include "engines/wintermute/Ad/AdRotLevel.h" -#include "engines/wintermute/Ad/AdScaleLevel.h" -#include "engines/wintermute/Ad/AdScene.h" -#include "engines/wintermute/Ad/AdSceneNode.h" -#include "engines/wintermute/Ad/AdSceneState.h" -#include "engines/wintermute/Ad/AdSentence.h" -#include "engines/wintermute/Ad/AdSpriteSet.h" -#include "engines/wintermute/Ad/AdTalkDef.h" -#include "engines/wintermute/Ad/AdTalkHolder.h" -#include "engines/wintermute/Ad/AdTalkNode.h" -#include "engines/wintermute/Ad/AdWaypointGroup.h" -#include "engines/wintermute/Base/BFader.h" -#include "engines/wintermute/Base/font/BFontBitmap.h" -#include "engines/wintermute/Base/font/BFontStorage.h" -#include "engines/wintermute/Base/font/BFontTT.h" -#include "engines/wintermute/Base/BFrame.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BKeyboardState.h" -#include "engines/wintermute/Base/BObject.h" -#include "engines/wintermute/Base/BPoint.h" -#include "engines/wintermute/Base/BRegion.h" -#include "engines/wintermute/Base/BScriptable.h" -#include "engines/wintermute/Base/BScriptHolder.h" -#include "engines/wintermute/Base/BSound.h" -#include "engines/wintermute/Base/BSprite.h" -#include "engines/wintermute/Base/BSubFrame.h" -#include "engines/wintermute/Base/BViewport.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" -#include "engines/wintermute/Base/scriptables/ScScript.h" -#include "engines/wintermute/Base/scriptables/ScStack.h" -#include "engines/wintermute/Base/scriptables/ScValue.h" -#include "engines/wintermute/Base/scriptables/SXArray.h" -#include "engines/wintermute/Base/scriptables/SXDate.h" -#include "engines/wintermute/Base/scriptables/SXFile.h" -#include "engines/wintermute/Base/scriptables/SXMath.h" -#include "engines/wintermute/Base/scriptables/SXMemBuffer.h" -#include "engines/wintermute/Base/scriptables/SxObject.h" -#include "engines/wintermute/Base/scriptables/SXString.h" -#include "engines/wintermute/UI/UIButton.h" -#include "engines/wintermute/UI/UIEdit.h" -#include "engines/wintermute/UI/UIEntity.h" -#include "engines/wintermute/UI/UIText.h" -#include "engines/wintermute/UI/UITiledImage.h" -#include "engines/wintermute/UI/UIWindow.h" +#include "engines/wintermute/ad/AdActor.h" +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/AdInventory.h" +#include "engines/wintermute/ad/AdInventoryBox.h" +#include "engines/wintermute/ad/AdItem.h" +#include "engines/wintermute/ad/AdLayer.h" +#include "engines/wintermute/ad/AdNodeState.h" +#include "engines/wintermute/ad/AdObject.h" +#include "engines/wintermute/ad/AdPath.h" +#include "engines/wintermute/ad/AdPathPoint.h" +#include "engines/wintermute/ad/AdRegion.h" +#include "engines/wintermute/ad/AdResponse.h" +#include "engines/wintermute/ad/AdResponseBox.h" +#include "engines/wintermute/ad/AdResponseContext.h" +#include "engines/wintermute/ad/AdRotLevel.h" +#include "engines/wintermute/ad/AdScaleLevel.h" +#include "engines/wintermute/ad/AdScene.h" +#include "engines/wintermute/ad/AdSceneNode.h" +#include "engines/wintermute/ad/AdSceneState.h" +#include "engines/wintermute/ad/AdSentence.h" +#include "engines/wintermute/ad/AdSpriteSet.h" +#include "engines/wintermute/ad/AdTalkDef.h" +#include "engines/wintermute/ad/AdTalkHolder.h" +#include "engines/wintermute/ad/AdTalkNode.h" +#include "engines/wintermute/ad/AdWaypointGroup.h" +#include "engines/wintermute/base/BFader.h" +#include "engines/wintermute/base/font/BFontBitmap.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFontTT.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/BScriptHolder.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/SXArray.h" +#include "engines/wintermute/base/scriptables/SXDate.h" +#include "engines/wintermute/base/scriptables/SXFile.h" +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/base/scriptables/SXMemBuffer.h" +#include "engines/wintermute/base/scriptables/SxObject.h" +#include "engines/wintermute/base/scriptables/SXString.h" +#include "engines/wintermute/ui/UIButton.h" +#include "engines/wintermute/ui/UIEdit.h" +#include "engines/wintermute/ui/UIEntity.h" +#include "engines/wintermute/ui/UIText.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/ui/UIWindow.h" #include "engines/wintermute/video/VidTheoraPlayer.h" // CSysClass adds these objects to the registry, thus they aren't as leaked as they look diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index af1224c200..556ccbbd4f 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -41,8 +41,8 @@ typedef bool(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute -#include "engines/wintermute/Sys/SysClass.h" -#include "engines/wintermute/Sys/SysClassRegistry.h" +#include "engines/wintermute/system/SysClass.h" +#include "engines/wintermute/system/SysClassRegistry.h" namespace WinterMute { diff --git a/engines/wintermute/system/SysClass.cpp b/engines/wintermute/system/SysClass.cpp new file mode 100644 index 0000000000..dee4b7d2d0 --- /dev/null +++ b/engines/wintermute/system/SysClass.cpp @@ -0,0 +1,211 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "SysInstance.h" +#include "SysClass.h" +#include "SysClassRegistry.h" +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/Base/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { + _name = name; + + _build = build; + _load = load; + _next = NULL; + _savedID = -1; + _persistent = persistent_class; + _numInst = 0; + + CSysClassRegistry::getInstance()->registerClass(this); +} + + +////////////////////////////////////////////////////////////////////////// +CSysClass::~CSysClass() { + CSysClassRegistry::getInstance()->unregisterClass(this); + removeAllInstances(); +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::removeAllInstances() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + delete(it->_value); + } + _instances.clear(); + _instanceMap.clear(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { + CSysInstance *inst = new CSysInstance(instance, id, this); + inst->setSavedID(savedId); + _instances[inst] = (inst); + + _instanceMap[instance] = inst; + + CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); + + return inst; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::removeInstance(void *instance) { + InstanceMap::iterator mapIt = _instanceMap.find(instance); + if (mapIt == _instanceMap.end()) return false; + + Instances::iterator it = _instances.find((mapIt->_value)); + if (it != _instances.end()) { + delete(it->_value); + _instances.erase(it); + } + + _instanceMap.erase(mapIt); + + return false; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::getInstanceID(void *pointer) { + InstanceMap::iterator mapIt = _instanceMap.find(pointer); + if (mapIt == _instanceMap.end()) return -1; + else return (mapIt->_value)->getID(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClass::idToPointer(int savedID) { + //slow + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::getNumInstances() { + return _instances.size(); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::dump(Common::WriteStream *stream) { + Common::String str; + str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); + stream->write(str.c_str(), str.size()); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + persistMgr->putString(_name.c_str()); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD(_instances.size()); + + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + persistMgr->putDWORD((it->_value)->getID()); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + _savedID = persistMgr->getDWORD(); + int numInstances = persistMgr->getDWORD(); + + for (int i = 0; i < numInstances; i++) { + int instID = persistMgr->getDWORD(); + if (_persistent) { + + if (i > 0) { + gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); + continue; + } + + Instances::iterator it = _instances.begin(); + if (it != _instances.end()) { + (it->_value)->setSavedID(instID); + CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); + } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } + // normal instances, create empty objects + else { + void *emptyObject = _build(); + if (!emptyObject) { + warning("HALT"); + } + + addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); + } + + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + // write instace header + persistMgr->putString(""); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD((it->_value)->getID()); + persistMgr->putString(""); + _load((it->_value)->getInstance(), persistMgr); + persistMgr->putString(""); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { + _load(instance, persistMgr); +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClass::resetSavedIDs() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + (it->_value)->setSavedID(-1); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + lpCallback((it->_value)->getInstance(), lpData); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysClass.h b/engines/wintermute/system/SysClass.h new file mode 100644 index 0000000000..f807ea677c --- /dev/null +++ b/engines/wintermute/system/SysClass.h @@ -0,0 +1,130 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASS_H +#define WINTERMUTE_SYSCLASS_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dctypes.h" +#include "common/hashmap.h" +#include "common/func.h" +#include "common/stream.h" + +namespace WinterMute { +class CSysInstance; +class CBGame; +class CBPersistMgr; +class CSysClass; + +} + +namespace Common { +template struct Hash; + +template<> struct Hash : public UnaryFunction { + uint operator()(void *val) const { + return (uint)((size_t)val); + } +}; + +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysInstance *val) const { + return (uint)((size_t)val); + } +}; + + +} + +namespace WinterMute { + +class CSysClass { +public: + CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); + ~CSysClass(); + + int getNumInstances(); + bool removeInstance(void *instance); + CSysInstance *addInstance(void *instance, int id, int savedId = -1); + bool removeAllInstances(); + + int getInstanceID(void *pointer); + void *idToPointer(int savedID); + + void setID(int id) { + _iD = id; + } + int getID() const { + return _iD; + } + + int getSavedID() const { + return _savedID; + } + + bool isPersistent() const { + return _persistent; + } + + AnsiString getName() const { + return _name; + } + + void saveTable(CBGame *Game, CBPersistMgr *PersistMgr); + void loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + + void saveInstances(CBGame *Game, CBPersistMgr *PersistMgr); + void loadInstance(void *instance, CBPersistMgr *PersistMgr); + + void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + + void resetSavedIDs(); + + void dump(Common::WriteStream *stream); + +private: + int _numInst; + bool _persistent; + CSysClass *_next; + int _iD; + int _savedID; + AnsiString _name; + PERSISTBUILD _build; + PERSISTLOAD _load; + + //typedef std::set Instances; + typedef Common::HashMap Instances; + Instances _instances; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/system/SysClassRegistry.cpp b/engines/wintermute/system/SysClassRegistry.cpp new file mode 100644 index 0000000000..0b173c3afb --- /dev/null +++ b/engines/wintermute/system/SysClassRegistry.cpp @@ -0,0 +1,314 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "SysInstance.h" +#include "SysClassRegistry.h" +#include "common/stream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::CSysClassRegistry() { + _count = 0; + _disabled = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::~CSysClassRegistry() { + unregisterClasses(); +} + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry *CSysClassRegistry::getInstance() { + return g_wintermute->getClassRegistry(); +} + +void CSysClassRegistry::unregisterClasses() { + // CSysClass calls UnregisterClass upon destruction. + while (_classes.size() > 0) { + delete _classes.begin()->_value; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::registerClass(CSysClass *classObj) { + classObj->setID(_count++); + //_classes.insert(classObj); + _classes[classObj] = classObj; + + _nameMap[classObj->getName()] = classObj; + _idMap[classObj->getID()] = classObj; + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { + + Classes::iterator it = _classes.find(classObj); + if (it == _classes.end()) return false; + + if (classObj->getNumInstances() != 0) { + char str[MAX_PATH_LENGTH]; + sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); + CBPlatform::outputDebugString(str); + } + _classes.erase(it); + + NameMap::iterator mapIt = _nameMap.find(classObj->getName()); + if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); + + IdMap::iterator idIt = _idMap.find(classObj->getID()); + if (idIt != _idMap.end()) _idMap.erase(idIt); + + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::registerInstance(const char *className, void *instance) { + if (_disabled) return true; + + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + + CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); + return (inst != NULL); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { + _instanceMap[pointer] = instance; + + if (instance->getSavedID() >= 0) + _savedInstanceMap[instance->getSavedID()] = instance; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClassRegistry::getNextID() { + return _count++; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + (*mapIt)._value->removeInstance(instance); + + InstanceMap::iterator instIt = _instanceMap.find(instance); + if (instIt != _instanceMap.end()) { + _instanceMap.erase(instIt); + return true; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { + if (pointer == NULL) return true; + + InstanceMap::iterator it = _instanceMap.find(pointer); + if (it == _instanceMap.end()) return false; + + + CSysInstance *inst = (*it)._value; + *instanceID = inst->getID(); + *classID = inst->getClass()->getID(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClassRegistry::idToPointer(int classID, int instanceID) { + SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); + if (it == _savedInstanceMap.end()) return NULL; + else return (*it)._value->getInstance(); +} + +bool checkHeader(const char *tag, CBPersistMgr *pm) { + char *test = pm->getString(); + Common::String verify = test; + delete[] test; + bool retVal = (verify == tag); + if (!retVal) { + error("Expected %s in Save-file not found", tag); + } + return retVal; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { + persistMgr->putString(""); + persistMgr->putDWORD(_classes.size()); + + int counter = 0; + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); + } + + (it->_value)->saveTable(gameRef, persistMgr); + } + persistMgr->putString(""); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + checkHeader("", persistMgr); + + // reset SavedID of current instances + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + (it->_value)->resetSavedIDs(); + } + + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->isPersistent()) continue; + (it->_value)->removeAllInstances(); + } + + _instanceMap.clear(); + + uint32 numClasses = persistMgr->getDWORD(); + + for (uint32 i = 0; i < numClasses; i++) { + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); + + Common::String className = persistMgr->getStringObj(); + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); + } + + checkHeader("", persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { + + Classes::iterator it; + + // count total instances + int numInstances = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + numInstances += (it->_value)->getNumInstances(); + } + + persistMgr->putDWORD(numInstances); + + int counter = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + if (counter % 20 == 0) { + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); + } + } + gameRef->miniUpdate(); + + (it->_value)->saveInstances(gameRef, persistMgr); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { + // get total instances + int numInstances = persistMgr->getDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (i % 20 == 0) { + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); + } + + checkHeader("", persistMgr); + + int classID = persistMgr->getDWORD(); + int instanceID = persistMgr->getDWORD(); + void *instance = idToPointer(classID, instanceID); + + checkHeader("", persistMgr); + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->getSavedID() == classID) { + (it->_value)->loadInstance(instance, persistMgr); + break; + } + } + checkHeader("", persistMgr); + } + + _savedInstanceMap.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return STATUS_FAILED; + + (*mapIt)._value->instanceCallback(lpCallback, lpData); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) + (it->_value)->dump(stream); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysClassRegistry.h b/engines/wintermute/system/SysClassRegistry.h new file mode 100644 index 0000000000..a4a410527d --- /dev/null +++ b/engines/wintermute/system/SysClassRegistry.h @@ -0,0 +1,106 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASSREGISTRY_H +#define WINTERMUTE_SYSCLASSREGISTRY_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/func.h" +#include "common/stream.h" + +namespace WinterMute { +class CSysClass; +} + +namespace Common { +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysClass *val) const { + return (uint)((size_t)val); + } +}; + +} + +namespace WinterMute { + +class CBGame; +class CBPersistMgr; +class CSysInstance; + +class CSysClassRegistry { + void unregisterClasses(); +public: + void registerClasses(); // persistent.cpp + static CSysClassRegistry *getInstance(); + + CSysClassRegistry(); + virtual ~CSysClassRegistry(); + + bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + bool loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + bool loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + void *idToPointer(int classID, int instanceID); + bool getPointerID(void *pointer, int *classID, int *instanceID); + bool registerClass(CSysClass *classObj); + bool unregisterClass(CSysClass *classObj); + bool registerInstance(const char *className, void *instance); + bool unregisterInstance(const char *className, void *instance); + void dumpClasses(Common::WriteStream *stream); + int getNextID(); + void addInstanceToTable(CSysInstance *instance, void *pointer); + + bool _disabled; + int _count; + + typedef Common::HashMap Classes; + Classes _classes; + + typedef Common::HashMap NameMap; + NameMap _nameMap; + + typedef Common::HashMap IdMap; + IdMap _idMap; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; + + typedef Common::HashMap SavedInstanceMap; + SavedInstanceMap _savedInstanceMap; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/system/SysInstance.cpp b/engines/wintermute/system/SysInstance.cpp new file mode 100644 index 0000000000..b7f6079912 --- /dev/null +++ b/engines/wintermute/system/SysInstance.cpp @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SysInstance.h" +#include "SysClassRegistry.h" +#include "SysClass.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { + _instance = instance; + _id = id; + _savedID = -1; + _class = sysClass; + + _used = false; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance::~CSysInstance() { +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysInstance.h b/engines/wintermute/system/SysInstance.h new file mode 100644 index 0000000000..6becd491af --- /dev/null +++ b/engines/wintermute/system/SysInstance.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSINSTANCE_H +#define WINTERMUTE_SYSINSTANCE_H + +namespace WinterMute { + +class CSysClass; + +class CSysInstance { +public: + CSysInstance(void *Instance, int ID, CSysClass *sysClass); + virtual ~CSysInstance(); + + int getID() const { + return _id; + } + int getSavedID() const { + return _savedID; + } + void *getInstance() const { + return _instance; + } + CSysClass *getClass() const { + return _class; + } + + void setSavedID(int id) { + _savedID = id; + } + +private: + bool _used; + int _id; + int _savedID; + void *_instance; + CSysClass *_class; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIButton.cpp b/engines/wintermute/ui/UIButton.cpp new file mode 100644 index 0000000000..f6c50597bd --- /dev/null +++ b/engines/wintermute/ui/UIButton.cpp @@ -0,0 +1,1046 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/ui/UIButton.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIButton, false) + +////////////////////////////////////////////////////////////////////////// +CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { + _backPress = _backHover = _backDisable = _backFocus = NULL; + + _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; + + _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; + + _align = TAL_CENTER; + + _hover = _press = false; + + _type = UI_BUTTON; + + _canFocus = false; + _stayPressed = false; + + _oneTimePress = false; + _centerImage = false; + + _pixelPerfect = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIButton::~CUIButton() { + delete _backPress; + delete _backHover; + delete _backDisable; + delete _backFocus; + + if (!_sharedFonts) { + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + } + + if (!_sharedImages) { + delete _imageHover; + delete _imagePress; + delete _imageDisable; + delete _imageFocus; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(BUTTON) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(FOCUSABLE) +TOKEN_DEF(BACK_HOVER) +TOKEN_DEF(BACK_PRESS) +TOKEN_DEF(BACK_DISABLE) +TOKEN_DEF(BACK_FOCUS) +TOKEN_DEF(BACK) +TOKEN_DEF(CENTER_IMAGE) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE_PRESS) +TOKEN_DEF(IMAGE_DISABLE) +TOKEN_DEF(IMAGE_FOCUS) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT_PRESS) +TOKEN_DEF(FONT_DISABLE) +TOKEN_DEF(FONT_FOCUS) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(PRESSED) +TOKEN_DEF(PIXEL_PERFECT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIButton::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(FOCUSABLE) + TOKEN_TABLE(BACK_HOVER) + TOKEN_TABLE(BACK_PRESS) + TOKEN_TABLE(BACK_DISABLE) + TOKEN_TABLE(BACK_FOCUS) + TOKEN_TABLE(BACK) + TOKEN_TABLE(CENTER_IMAGE) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE_PRESS) + TOKEN_TABLE(IMAGE_DISABLE) + TOKEN_TABLE(IMAGE_FOCUS) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT_PRESS) + TOKEN_TABLE(FONT_DISABLE) + TOKEN_TABLE(FONT_FOCUS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(PRESSED) + TOKEN_TABLE(PIXEL_PERFECT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + _gameRef->LOG(0, "'BUTTON' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_HOVER: + delete _backHover; + _backHover = new CUITiledImage(_gameRef); + if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { + delete _backHover; + _backHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_PRESS: + delete _backPress; + _backPress = new CUITiledImage(_gameRef); + if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { + delete _backPress; + _backPress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_DISABLE: + delete _backDisable; + _backDisable = new CUITiledImage(_gameRef); + if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { + delete _backDisable; + _backDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_FOCUS: + delete _backFocus; + _backFocus = new CUITiledImage(_gameRef); + if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { + delete _backFocus; + _backFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + delete _imageHover; + _imageHover = new CBSprite(_gameRef); + if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { + delete _imageHover; + _imageHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_PRESS: + delete _imagePress; + _imagePress = new CBSprite(_gameRef); + if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { + delete _imagePress; + _imagePress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_DISABLE: + delete _imageDisable; + _imageDisable = new CBSprite(_gameRef); + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { + delete _imageDisable; + _imageDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_FOCUS: + delete _imageFocus; + _imageFocus = new CBSprite(_gameRef); + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { + delete _imageFocus; + _imageFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_PRESS: + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + _fontPress = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontPress) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_DISABLE: + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + _fontDisable = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontDisable) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_FOCUS: + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + _fontFocus = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontFocus) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_CENTER; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_FOCUSABLE: + parser.scanStr((char *)params, "%b", &_canFocus); + break; + + case TOKEN_CENTER_IMAGE: + parser.scanStr((char *)params, "%b", &_centerImage); + break; + + case TOKEN_PRESSED: + parser.scanStr((char *)params, "%b", &_stayPressed); + break; + + case TOKEN_PIXEL_PERFECT: + parser.scanStr((char *)params, "%b", &_pixelPerfect); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in BUTTON definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading BUTTON definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "BUTTON\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backHover && _backHover->_filename) + buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + if (_backPress && _backPress->_filename) + buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + if (_backDisable && _backDisable->_filename) + buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + if (_backFocus && _backFocus->_filename) + buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageHover && _imageHover->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + if (_imagePress && _imagePress->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + if (_imageDisable && _imageDisable->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + if (_imageFocus && _imageFocus->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + if (_fontPress && _fontPress->_filename) + buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + if (_fontDisable && _fontDisable->_filename) + buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + if (_fontFocus && _fontFocus->_filename) + buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_align) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + warning("CUIButton::SaveAsText - unhandled enum"); + break; + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUIButton::correctSize() { + Rect32 rect; + + CBSprite *img = NULL; + if (_image) img = _image; + else if (_imageDisable) img = _imageDisable; + else if (_imageHover) img = _imageHover; + else if (_imagePress) img = _imagePress; + else if (_imageFocus) img = _imageFocus; + + if (_width <= 0) { + if (img) { + img->getBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (img) { + img->getBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_text) { + int text_height; + if (_font) text_height = _font->getTextHeight((byte *)_text, _width); + else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); + + if (text_height > _height) _height = text_height; + } + + if (_height <= 0) _height = 100; + + if (_back) _back->correctSize(&_width, &_height); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::display(int offsetX, int offsetY) { + if (!_visible) + return STATUS_OK; + + CUITiledImage *back = NULL; + CBSprite *image = NULL; + CBFont *font = 0; + + //RECT rect; + //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); + _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); + + if ((_press && _hover && !_gameRef->_mouseLeftDown) || + (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); + + + if (_disable) { + if (_backDisable) back = _backDisable; + if (_imageDisable) image = _imageDisable; + if (_text && _fontDisable) font = _fontDisable; + } else if (_press || _oneTimePress || _stayPressed) { + if (_backPress) back = _backPress; + if (_imagePress) image = _imagePress; + if (_text && _fontPress) font = _fontPress; + } else if (_hover) { + if (_backHover) back = _backHover; + if (_imageHover) image = _imageHover; + if (_text && _fontHover) font = _fontHover; + } else if (_canFocus && isFocused()) { + if (_backFocus) back = _backFocus; + if (_imageFocus) image = _imageFocus; + if (_text && _fontFocus) font = _fontFocus; + } + + if (!back && _back) back = _back; + if (!image && _image) image = _image; + if (_text && !font) { + if (_font) font = _font; + else font = _gameRef->_systemFont; + } + + int imageX = offsetX + _posX; + int imageY = offsetY + _posY; + + if (image && _centerImage) { + Rect32 rc; + image->getBoundingRect(&rc, 0, 0); + imageX += (_width - (rc.right - rc.left)) / 2; + imageY += (_height - (rc.bottom - rc.top)) / 2; + } + + if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); + //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + + if (font && _text) { + int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + } + + if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + + // reset unused sprites + if (_image && _image != image) _image->reset(); + if (_imageDisable && _imageDisable != image) _imageDisable->reset(); + if (_imageFocus && _imageFocus != image) _imageFocus->reset(); + if (_imagePress && _imagePress != image) _imagePress->reset(); + if (_imageHover && _imageHover != image) _imageHover->reset(); + + _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIButton::press() { + applyEvent("Press"); + if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); + if (_parentNotify && _parent) _parent->applyEvent(_name); + + _oneTimePress = false; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetDisabledFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetDisabledFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (Val->isNULL()) { + _fontDisable = NULL; + stack->pushBool(true); + } else { + _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_fontDisable != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHoverFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (val->isNULL()) { + _fontHover = NULL; + stack->pushBool(true); + } else { + _fontHover = _gameRef->_fontStorage->addFont(val->getString()); + stack->pushBool(_fontHover != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPressedFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (Val->isNULL()) { + _fontPress = NULL; + stack->pushBool(true); + } else { + _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_fontPress != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFocusedFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + if (val->isNULL()) { + _fontFocus = NULL; + stack->pushBool(true); + } else { + _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); + stack->pushBool(_fontFocus != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDisabledImage") == 0) { + stack->correctParams(1); + + delete _imageDisable; + _imageDisable = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { + delete _imageDisable; + _imageDisable = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDisabledImage") == 0) { + stack->correctParams(0); + if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); + else stack->pushString(_imageDisable->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDisabledImageObject") == 0) { + stack->correctParams(0); + if (!_imageDisable) stack->pushNULL(); + else stack->pushNative(_imageDisable, true); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHoverImage") == 0) { + stack->correctParams(1); + + delete _imageHover; + _imageHover = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { + delete _imageHover; + _imageHover = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverImage") == 0) { + stack->correctParams(0); + if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); + else stack->pushString(_imageHover->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverImageObject") == 0) { + stack->correctParams(0); + if (!_imageHover) stack->pushNULL(); + else stack->pushNative(_imageHover, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPressedImage") == 0) { + stack->correctParams(1); + + delete _imagePress; + _imagePress = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { + delete _imagePress; + _imagePress = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPressedImage") == 0) { + stack->correctParams(0); + if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); + else stack->pushString(_imagePress->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPressedImageObject") == 0) { + stack->correctParams(0); + if (!_imagePress) stack->pushNULL(); + else stack->pushNative(_imagePress, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFocusedImage") == 0) { + stack->correctParams(1); + + delete _imageFocus; + _imageFocus = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { + delete _imageFocus; + _imageFocus = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFocusedImage") == 0) { + stack->correctParams(0); + if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); + else stack->pushString(_imageFocus->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFocusedImageObject") == 0) { + stack->correctParams(0); + if (!_imageFocus) stack->pushNULL(); + else stack->pushNative(_imageFocus, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Press + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Press") == 0) { + stack->correctParams(0); + + if (_visible && !_disable) { + _oneTimePress = true; + _oneTimePressTime = CBPlatform::getTime(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIButton::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("button"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextAlign") == 0) { + _scValue->setInt(_align); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focusable") == 0) { + _scValue->setBool(_canFocus); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pressed") == 0) { + _scValue->setBool(_stayPressed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_pixelPerfect); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "TextAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _align = (TTextAlign)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focusable") == 0) { + _canFocus = value->getBool(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pressed") == 0) { + _stayPressed = value->getBool(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _pixelPerfect = value->getBool(); + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIButton::scToString() { + return "[button]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_backDisable)); + persistMgr->transfer(TMEMBER(_backFocus)); + persistMgr->transfer(TMEMBER(_backHover)); + persistMgr->transfer(TMEMBER(_backPress)); + persistMgr->transfer(TMEMBER(_centerImage)); + persistMgr->transfer(TMEMBER(_fontDisable)); + persistMgr->transfer(TMEMBER(_fontFocus)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_fontPress)); + persistMgr->transfer(TMEMBER(_hover)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_imageDisable)); + persistMgr->transfer(TMEMBER(_imageFocus)); + persistMgr->transfer(TMEMBER(_imageHover)); + persistMgr->transfer(TMEMBER(_imagePress)); + persistMgr->transfer(TMEMBER(_pixelPerfect)); + persistMgr->transfer(TMEMBER(_press)); + persistMgr->transfer(TMEMBER(_stayPressed)); + + if (!persistMgr->_saving) { + _oneTimePress = false; + _oneTimePressTime = 0; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIButton.h b/engines/wintermute/ui/UIButton.h new file mode 100644 index 0000000000..5bdc075ebc --- /dev/null +++ b/engines/wintermute/ui/UIButton.h @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIBUTTON_H +#define WINTERMUTE_UIBUTTON_H + + +#include "UIObject.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUIButton : public CUIObject { +public: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + uint32 _oneTimePressTime; + DECLARE_PERSISTENT(CUIButton, CUIObject) + void press(); + virtual bool display(int offsetX = 0, int offsetY = 0); + bool _press; + bool _hover; + void correctSize(); + TTextAlign _align; + CBSprite *_imageHover; + CBSprite *_imagePress; + CBSprite *_imageDisable; + CBSprite *_imageFocus; + CBFont *_fontDisable; + CBFont *_fontPress; + CBFont *_fontHover; + CBFont *_fontFocus; + CUITiledImage *_backPress; + CUITiledImage *_backHover; + CUITiledImage *_backDisable; + CUITiledImage *_backFocus; + CUIButton(CBGame *inGame = NULL); + virtual ~CUIButton(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIEdit.cpp b/engines/wintermute/ui/UIEdit.cpp new file mode 100644 index 0000000000..4825761734 --- /dev/null +++ b/engines/wintermute/ui/UIEdit.cpp @@ -0,0 +1,857 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ui/UIEdit.h" +#include "engines/wintermute/ui/UIObject.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/utils/utils.h" +#include "common/util.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEdit, false) + +////////////////////////////////////////////////////////////////////////// +CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { + _type = UI_EDIT; + + _fontSelected = NULL; + + _selStart = _selEnd = 10000; + _scrollOffset = 0; + + _cursorChar = NULL; + setCursorChar("|"); + + _cursorBlinkRate = 600; + + _frameWidth = 0; + + setText(""); + + _lastBlinkTime = 0; + _cursorVisible = true; + + _maxLength = -1; + + _canFocus = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEdit::~CUIEdit() { + if (!_sharedFonts) { + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + } + + delete[] _cursorChar; + _cursorChar = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_SELECTED) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR_BLINK_RATE) +TOKEN_DEF(CURSOR) +TOKEN_DEF(FRAME_WIDTH) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MAX_LENGTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF(CAPTION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_SELECTED) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR_BLINK_RATE) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(FRAME_WIDTH) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MAX_LENGTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + _gameRef->LOG(0, "'EDIT' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_SELECTED: + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontSelected) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_MAX_LENGTH: + parser.scanStr((char *)params, "%d", &_maxLength); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_BLINK_RATE: + parser.scanStr((char *)params, "%d", &_cursorBlinkRate); + break; + + case TOKEN_FRAME_WIDTH: + parser.scanStr((char *)params, "%d", &_frameWidth); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in EDIT definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading EDIT definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "EDIT\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontSelected && _fontSelected->_filename) + buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "MAX_LENGTH=%d\n", _maxLength); + buffer->putTextIndent(indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + buffer->putTextIndent(indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSelectedFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSelectedFont") == 0) { + stack->correctParams(1); + + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); + stack->pushBool(_fontSelected != NULL); + + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEdit::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("editor"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelStart") == 0) { + _scValue->setInt(_selStart); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelEnd") == 0) { + _scValue->setInt(_selEnd); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorBlinkRate") == 0) { + _scValue->setInt(_cursorBlinkRate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorChar") == 0) { + _scValue->setString(_cursorChar); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FrameWidth") == 0) { + _scValue->setInt(_frameWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxLength") == 0) { + _scValue->setInt(_maxLength); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::ansiToWide(_text); + _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); + } else { + _scValue->setString(_text); + } + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelStart") == 0) { + _selStart = value->getInt(); + _selStart = MAX(_selStart, 0); + _selStart = MIN((size_t)_selStart, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelEnd") == 0) { + _selEnd = value->getInt(); + _selEnd = MAX(_selEnd, 0); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorBlinkRate") == 0) { + _cursorBlinkRate = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorChar") == 0) { + setCursorChar(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FrameWidth") == 0) { + _frameWidth = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxLength") == 0) { + _maxLength = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(value->getString()); + setText(StringUtil::wideToAnsi(wstr).c_str()); + } else { + setText(value->getString()); + } + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEdit::scToString() { + return "[edit]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIEdit::setCursorChar(const char *character) { + if (!character) return; + delete[] _cursorChar; + _cursorChar = new char [strlen(character) + 1]; + if (_cursorChar) strcpy(_cursorChar, character); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + + // hack! + TTextEncoding OrigEncoding = _gameRef->_textEncoding; + _gameRef->_textEncoding = TEXT_ANSI; + + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + + // prepare fonts + CBFont *font; + CBFont *sfont; + + if (_font) font = _font; + else font = _gameRef->_systemFont; + + if (_fontSelected) sfont = _fontSelected; + else sfont = font; + + bool focused = isFocused(); + + _selStart = MAX(_selStart, 0); + _selEnd = MAX(_selEnd, 0); + + _selStart = MIN((size_t)_selStart, strlen(_text)); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + + //int CursorWidth = font->GetCharWidth(_cursorChar[0]); + int cursorWidth = font->getTextWidth((byte *)_cursorChar); + + int s1, s2; + bool curFirst; + // modify scroll offset + if (_selStart >= _selEnd) { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= (int)strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selEnd; + s2 = _selStart; + curFirst = true; + } else { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + + sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + + > _width - cursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= (int)strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selStart; + s2 = _selEnd; + curFirst = false; + } + + + int AlignOffset = 0; + + for (int Count = 0; Count < 2; Count++) { + // draw text + int xxx, yyy, width, height; + + xxx = _posX + _frameWidth + offsetX; + yyy = _posY + _frameWidth + offsetY; + + width = _posX + _width + offsetX - _frameWidth; + height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); + + if (_gameRef->_textRTL) xxx += AlignOffset; + + TTextAlign Align = TAL_LEFT; + + + // unselected 1 + if (s1 > _scrollOffset) { + if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + } + + // cursor + if (focused && curFirst) { + if (Count) { + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += cursorWidth; + AlignOffset += cursorWidth; + } + + // selected + int s3 = MAX(s1, _scrollOffset); + + if (s2 - s3 > 0) { + if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + } + + // cursor + if (focused && !curFirst) { + if (Count) { + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += cursorWidth; + AlignOffset += cursorWidth; + } + + // unselected 2 + if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->getTextWidth((byte *)_text + s2); + + AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; + if (AlignOffset < 0) AlignOffset = 0; + } + + + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + + + _gameRef->_textEncoding = OrigEncoding; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { + bool handled = false; + + if (event->type == Common::EVENT_KEYDOWN && !printable) { + switch (event->kbd.keycode) { + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_TAB: + case Common::KEYCODE_RETURN: + return false; + + // ctrl+A + case Common::KEYCODE_a: + if (CBKeyboardState::isControlDown()) { + _selStart = 0; + _selEnd = strlen(_text); + handled = true; + } + break; + + case Common::KEYCODE_BACKSPACE: + if (_selStart == _selEnd) { + if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); + else deleteChars(_selStart - 1, _selStart); + } else deleteChars(_selStart, _selEnd); + if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); + _selStart = _selEnd; + + handled = true; + break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_UP: + _selEnd--; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + handled = true; + break; + + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_DOWN: + _selEnd++; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + handled = true; + break; + + case Common::KEYCODE_HOME: + if (_gameRef->_textRTL) { + _selEnd = strlen(_text); + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } else { + _selEnd = 0; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_END: + if (_gameRef->_textRTL) { + _selEnd = 0; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } else { + _selEnd = strlen(_text); + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_DELETE: + if (_selStart == _selEnd) { + if (_gameRef->_textRTL) { + deleteChars(_selStart - 1, _selStart); + _selEnd--; + if (_selEnd < 0) _selEnd = 0; + } else deleteChars(_selStart, _selStart + 1); + } else deleteChars(_selStart, _selEnd); + if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); + + _selStart = _selEnd; + handled = true; + break; + default: + break; + } + return handled; + } else if (event->type == Common::EVENT_KEYDOWN && printable) { + if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); + + //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); + WideString wstr; + wstr += (char)event->kbd.ascii; + _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); + + if (_gameRef->_textRTL) _selEnd = _selStart; + else _selStart = _selEnd; + + return true; + } + + return false; +} + + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::deleteChars(int start, int end) { + if (start > end) CBUtils::swap(&start, &end); + + start = MAX(start, (int)0); + end = MIN((size_t)end, strlen(_text)); + + char *str = new char[strlen(_text) - (end - start) + 1]; + if (str) { + if (start > 0) memcpy(str, _text, start); + memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->applyEvent(_name); + + return end - start; +} + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::insertChars(int pos, byte *chars, int num) { + if ((int)strlen(_text) + num > _maxLength) { + num -= (strlen(_text) + num - _maxLength); + } + + pos = MAX(pos, (int)0); + pos = MIN((size_t)pos, strlen(_text)); + + char *str = new char[strlen(_text) + num + 1]; + if (str) { + if (pos > 0) memcpy(str, _text, pos); + memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); + + memcpy(str + pos, chars, num); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->applyEvent(_name); + + return num; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_cursorBlinkRate)); + persistMgr->transfer(TMEMBER(_cursorChar)); + persistMgr->transfer(TMEMBER(_fontSelected)); + persistMgr->transfer(TMEMBER(_frameWidth)); + persistMgr->transfer(TMEMBER(_maxLength)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_selEnd)); + persistMgr->transfer(TMEMBER(_selStart)); + + if (!persistMgr->_saving) { + _cursorVisible = false; + _lastBlinkTime = 0; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIEdit.h b/engines/wintermute/ui/UIEdit.h new file mode 100644 index 0000000000..7249301592 --- /dev/null +++ b/engines/wintermute/ui/UIEdit.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIEDIT_H +#define WINTERMUTE_UIEDIT_H + +#include "engines/wintermute/persistent.h" +#include "UIObject.h" +#include "common/events.h" + +namespace WinterMute { +class CBFont; +class CUIEdit : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEdit, CUIObject) + int _maxLength; + int insertChars(int pos, byte *chars, int num); + int deleteChars(int start, int end); + bool _cursorVisible; + uint32 _lastBlinkTime; + virtual bool display(int offsetX, int offsetY); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + int _scrollOffset; + int _frameWidth; + uint32 _cursorBlinkRate; + void setCursorChar(const char *character); + char *_cursorChar; + int _selEnd; + int _selStart; + CBFont *_fontSelected; + CUIEdit(CBGame *inGame); + virtual ~CUIEdit(); + + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIEntity.cpp b/engines/wintermute/ui/UIEntity.cpp new file mode 100644 index 0000000000..7fbd2d13ff --- /dev/null +++ b/engines/wintermute/ui/UIEntity.cpp @@ -0,0 +1,339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/AdEntity.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/ui/UIEntity.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEntity, false) + +////////////////////////////////////////////////////////////////////////// +CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { + _type = UI_CUSTOM; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEntity::~CUIEntity() { + if (_entity) _gameRef->unregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(NAME) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_ENTITY: + if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition"); + return STATUS_FAILED; + } + + correctSize(); + + if (_gameRef->_editorMode) { + _width = 50; + _height = 50; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + + if (_entity && _entity->_filename) + buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::setEntity(const char *filename) { + if (_entity) _gameRef->unregisterObject(_entity); + _entity = new CAdEntity(_gameRef); + if (!_entity || DID_FAIL(_entity->loadFile(filename))) { + delete _entity; + _entity = NULL; + return STATUS_FAILED; + } else { + _entity->_nonIntMouseEvents = true; + _entity->_sceneIndependent = true; + _entity->makeFreezable(false); + _gameRef->registerObject(_entity); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + if (_entity) { + _entity->_posX = offsetX + _posX; + _entity->_posY = offsetY + _posY; + if (_entity->_scale < 0) _entity->_zoomable = false; + _entity->_shadowable = false; + + _entity->update(); + + bool origReg = _entity->_registrable; + + if (_entity->_registrable && _disable) _entity->_registrable = false; + + _entity->display(); + _entity->_registrable = origReg; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetEntity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetEntity") == 0) { + stack->correctParams(0); + + if (_entity) stack->pushNative(_entity, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetEntity") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + if (DID_SUCCEED(setEntity(filename))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEntity::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("entity container"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Freezable") == 0) { + if (_entity) _scValue->setBool(_entity->_freezable); + else _scValue->setBool(false); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Freezable") == 0) { + if (_entity) _entity->makeFreezable(value->getBool()); + return STATUS_OK; + } else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEntity::scToString() { + return "[entity container]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_entity)); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIEntity.h b/engines/wintermute/ui/UIEntity.h new file mode 100644 index 0000000000..b0711838a5 --- /dev/null +++ b/engines/wintermute/ui/UIEntity.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIENTITY_H +#define WINTERMUTE_UIENTITY_H + +#include "UIObject.h" + +namespace WinterMute { +class CAdEntity; +class CUIEntity : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEntity, CUIObject) + CUIEntity(CBGame *inGame); + virtual ~CUIEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + virtual bool display(int offsetX = 0, int offsetY = 0); + CAdEntity *_entity; + bool setEntity(const char *filename); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIObject.cpp b/engines/wintermute/ui/UIObject.cpp new file mode 100644 index 0000000000..1032faeb2c --- /dev/null +++ b/engines/wintermute/ui/UIObject.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/ui/UIObject.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/font/BFontStorage.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIObject, false) + +////////////////////////////////////////////////////////////////////////// +CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { + _back = NULL; + _image = NULL; + _font = NULL; + _text = NULL; + _sharedFonts = _sharedImages = false; + + _width = _height = 0; + + _listenerObject = NULL; + _listenerParamObject = NULL; + _listenerParamDWORD = 0; + + _disable = false; + _visible = true; + + _type = UI_UNKNOWN; + _parent = NULL; + + _parentNotify = false; + + _focusedWidget = NULL; + + _canFocus = false; + _nonIntMouseEvents = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIObject::~CUIObject() { + if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); + + if (_back) delete _back; + if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); + + if (_image && !_sharedImages) delete _image; + + if (_text) delete [] _text; + + _focusedWidget = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::setText(const char *text) { + if (_text) delete [] _text; + _text = new char [strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + for (int i = 0; i < strlen(_text); i++) { + if (_text[i] == '|') _text[i] = '\n'; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::display(int offsetX, int offsetY) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { + _listenerObject = object; + _listenerParamObject = listenerObject; + _listenerParamDWORD = listenerParam; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::correctSize() { + Rect32 rect; + + if (_width <= 0) { + if (_image) { + _image->getBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (_image) { + _image->getBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_back) _back->correctSize(&_width, &_height); +} + + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (Val->isNULL()) { + _font = NULL; + stack->pushBool(true); + } else { + _font = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_font != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + /* const char *filename = */ val->getString(); + + delete _image; + _image = NULL; + if (val->isNULL()) { + stack->pushBool(true); + return STATUS_OK; + } + + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { + delete _image; + _image = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + if (!_image || !_image->_filename) stack->pushNULL(); + else stack->pushString(_image->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetImageObject") == 0) { + stack->correctParams(0); + if (!_image) stack->pushNULL(); + else stack->pushNative(_image, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focus + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focus") == 0) { + stack->correctParams(0); + focus(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveAfter / MoveBefore + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { + stack->correctParams(1); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + + int i; + bool found = false; + CScValue *val = stack->pop(); + // find directly + if (val->isNative()) { + CUIObject *widget = (CUIObject *)val->getNative(); + for (i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == widget) { + found = true; + break; + } + } + } + // find by name + else { + const char *findName = val->getString(); + for (i = 0; i < win->_widgets.getSize(); i++) { + if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { + found = true; + break; + } + } + } + + if (found) { + bool done = false; + for (int j = 0; j < win->_widgets.getSize(); j++) { + if (win->_widgets[j] == this) { + if (strcmp(name, "MoveAfter") == 0) i++; + if (j >= i) j++; + + win->_widgets.insertAt(i, this); + win->_widgets.removeAt(j); + + done = true; + stack->pushBool(true); + break; + } + } + if (!done) stack->pushBool(false); + } else stack->pushBool(false); + + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToBottom + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveToBottom") == 0) { + stack->correctParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.removeAt(i); + win->_widgets.insertAt(0, this); + break; + } + } + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToTop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveToTop") == 0) { + stack->correctParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.removeAt(i); + win->_widgets.add(this); + break; + } + } + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("ui_object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Parent (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Parent") == 0) { + _scValue->setNative(_parent, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParentNotify") == 0) { + _scValue->setBool(_parentNotify); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Visible") == 0) { + _scValue->setBool(_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Disabled") == 0) { + _scValue->setBool(_disable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + _scValue->setString(_text); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NextSibling (RO) / PrevSibling (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { + _scValue->setNULL(); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + if (strcmp(name, "NextSibling") == 0) { + if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); + } else { + if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); + } + break; + } + } + } + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParentNotify") == 0) { + _parentNotify = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Visible") == 0) { + _visible = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Disabled") == 0) { + _disable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + setText(value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIObject::scToString() { + return "[ui_object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::isFocused() { + if (!_gameRef->_focusedWindow) return false; + if (_gameRef->_focusedWindow == this) return true; + + CUIObject *obj = _gameRef->_focusedWindow; + while (obj) { + if (obj == this) return true; + else obj = obj->_focusedWidget; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { + // handle focus change + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + focus(); + } + return CBObject::handleMouse(event, button); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::focus() { + CUIObject *obj = this; + bool disabled = false; + while (obj) { + if (obj->_disable && obj->_type == UI_WINDOW) { + disabled = true; + break; + } + obj = obj->_parent; + } + if (!disabled) { + obj = this; + while (obj) { + if (obj->_parent) { + if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; + } else { + if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); + } + + obj = obj->_parent; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { + int offX = 0, offY = 0; + + CUIObject *obj = _parent; + while (obj) { + offX += obj->_posX; + offY += obj->_posY; + + obj = obj->_parent; + } + if (offsetX) *offsetX = offX; + if (offsetY) *offsetY = offY; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_back)); + persistMgr->transfer(TMEMBER(_canFocus)); + persistMgr->transfer(TMEMBER(_disable)); + persistMgr->transfer(TMEMBER(_focusedWidget)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_listenerObject)); + persistMgr->transfer(TMEMBER(_listenerParamObject)); + persistMgr->transfer(TMEMBER(_listenerParamDWORD)); + persistMgr->transfer(TMEMBER(_parent)); + persistMgr->transfer(TMEMBER(_parentNotify)); + persistMgr->transfer(TMEMBER(_sharedFonts)); + persistMgr->transfer(TMEMBER(_sharedImages)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIObject.h b/engines/wintermute/ui/UIObject.h new file mode 100644 index 0000000000..26eecefe89 --- /dev/null +++ b/engines/wintermute/ui/UIObject.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIOBJECT_H +#define WINTERMUTE_UIOBJECT_H + + +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUITiledImage; +class CBFont; +class CUIObject : public CBObject { +public: + + bool getTotalOffset(int *offsetX, int *offsetY); + bool _canFocus; + bool focus(); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + bool isFocused(); + bool _parentNotify; + DECLARE_PERSISTENT(CUIObject, CBObject) + CUIObject *_parent; + virtual bool display(int offsetX = 0, int offsetY = 0); + virtual void correctSize(); + bool _sharedFonts; + bool _sharedImages; + void setText(const char *text); + char *_text; + CBFont *_font; + bool _visible; + CUITiledImage *_back; + bool _disable; + CUIObject(CBGame *inGame = NULL); + virtual ~CUIObject(); + int _width; + int _height; + TUIObjectType _type; + CBSprite *_image; + void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); + CBScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + CBScriptHolder *_listenerObject; + CUIObject *_focusedWidget; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIText.cpp b/engines/wintermute/ui/UIText.cpp new file mode 100644 index 0000000000..0b7df9bf19 --- /dev/null +++ b/engines/wintermute/ui/UIText.cpp @@ -0,0 +1,489 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/ui/UIText.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIText, false) + +////////////////////////////////////////////////////////////////////////// +CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { + _textAlign = TAL_LEFT; + _verticalAlign = VAL_CENTER; + _type = UI_STATIC; + _canFocus = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIText::~CUIText() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + + CBFont *font = _font; + if (!font) font = _gameRef->_systemFont; + + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + + if (font && _text) { + int textOffset; + switch (_verticalAlign) { + case VAL_TOP: + textOffset = 0; + break; + case VAL_BOTTOM: + textOffset = _height - font->getTextHeight((byte *)_text, _width); + break; + default: + textOffset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + } + font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); + } + + //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(STATIC) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIText::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + _gameRef->LOG(0, "'STATIC' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; + else _textAlign = TAL_CENTER; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; + else _verticalAlign = VAL_CENTER; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in STATIC definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading STATIC definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "STATIC\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_textAlign) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CUIText::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SizeToFit + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SizeToFit") == 0) { + stack->correctParams(0); + sizeToFit(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HeightToFit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HeightToFit") == 0) { + stack->correctParams(0); + if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); + stack->pushNULL(); + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIText::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("static"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextAlign") == 0) { + _scValue->setInt(_textAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VerticalAlign") == 0) { + _scValue->setInt(_verticalAlign); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "TextAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _textAlign = (TTextAlign)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VerticalAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; + _verticalAlign = (TVerticalAlign)i; + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIText::scToString() { + return "[static]"; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_textAlign)); + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::sizeToFit() { + if (_font && _text) { + _width = _font->getTextWidth((byte *)_text); + _height = _font->getTextHeight((byte *)_text, _width); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIText.h b/engines/wintermute/ui/UIText.h new file mode 100644 index 0000000000..62fbf00b0a --- /dev/null +++ b/engines/wintermute/ui/UIText.h @@ -0,0 +1,60 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITEXT_H +#define WINTERMUTE_UITEXT_H + + +#include "UIObject.h" + +namespace WinterMute { + +class CUIText : public CUIObject { +private: + bool sizeToFit(); +public: + virtual bool display(int offsetX, int offsetY); + DECLARE_PERSISTENT(CUIText, CUIObject) + CUIText(CBGame *inGame = NULL); + virtual ~CUIText(); + TTextAlign _textAlign; + TVerticalAlign _verticalAlign; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UITiledImage.cpp b/engines/wintermute/ui/UITiledImage.cpp new file mode 100644 index 0000000000..b80ae76978 --- /dev/null +++ b/engines/wintermute/ui/UITiledImage.cpp @@ -0,0 +1,370 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUITiledImage, false) + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { + _image = NULL; + + CBPlatform::setRectEmpty(&_upLeft); + CBPlatform::setRectEmpty(&_upMiddle); + CBPlatform::setRectEmpty(&_upRight); + CBPlatform::setRectEmpty(&_middleLeft); + CBPlatform::setRectEmpty(&_middleMiddle); + CBPlatform::setRectEmpty(&_middleRight); + CBPlatform::setRectEmpty(&_downLeft); + CBPlatform::setRectEmpty(&_downMiddle); + CBPlatform::setRectEmpty(&_downRight); +} + + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::~CUITiledImage() { + delete _image; + _image = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::display(int x, int y, int width, int height) { + if (!_image) return STATUS_FAILED; + + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; + + int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; + + int col, row; + + _gameRef->_renderer->startSpriteBatch(); + + // top left/right + _image->_surface->displayTrans(x, y, _upLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y, _upRight); + + // bottom left/right + _image->_surface->displayTrans(x, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); + + // left/right + int yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + _image->_surface->displayTrans(x, yyy, _middleLeft); + _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); + yyy += tileWidth; + } + + // top/bottom + int xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { + _image->_surface->displayTrans(xxx, y, _upMiddle); + _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); + xxx += tileWidth; + } + + // tiles + yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { + _image->_surface->displayTrans(xxx, yyy, _middleMiddle); + xxx += tileWidth; + } + yyy += tileWidth; + } + + _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TILED_IMAGE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(UP_MIDDLE) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(DOWN_MIDDLE) +TOKEN_DEF(MIDDLE_LEFT) +TOKEN_DEF(MIDDLE_RIGHT) +TOKEN_DEF(MIDDLE_MIDDLE) +TOKEN_DEF(VERTICAL_TILES) +TOKEN_DEF(HORIZONTAL_TILES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TILED_IMAGE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(UP_MIDDLE) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(DOWN_MIDDLE) + TOKEN_TABLE(MIDDLE_LEFT) + TOKEN_TABLE(MIDDLE_RIGHT) + TOKEN_TABLE(MIDDLE_MIDDLE) + TOKEN_TABLE(VERTICAL_TILES) + TOKEN_TABLE(HORIZONTAL_TILES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + bool hTiles = false, vTiles = false; + int h1 = 0, h2 = 0, h3 = 0; + int v1 = 0, v2 = 0, v3 = 0; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSubFrame(_gameRef); + if (!_image || DID_FAIL(_image->setSurface((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_UP_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); + break; + + case TOKEN_UP_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); + break; + + case TOKEN_UP_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); + break; + + case TOKEN_DOWN_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); + break; + + case TOKEN_DOWN_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); + break; + + case TOKEN_DOWN_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); + break; + + case TOKEN_MIDDLE_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); + break; + + case TOKEN_MIDDLE_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); + break; + + case TOKEN_MIDDLE_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); + break; + + case TOKEN_HORIZONTAL_TILES: + parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); + hTiles = true; + break; + + case TOKEN_VERTICAL_TILES: + parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); + vTiles = true; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading TILED_IMAGE definition"); + return STATUS_FAILED; + } + + if (vTiles && hTiles) { + // up row + CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); + CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); + CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); + + // middle row + CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); + CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); + CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); + + // down row + CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); + CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); + CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); + } + + // default + if (_image && _image->_surface) { + int width = _image->_surface->getWidth() / 3; + int height = _image->_surface->getHeight() / 3; + + if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); + if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + + if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + + if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TILED_IMAGE\n"); + buffer->putTextIndent(indent, "{\n"); + + if (_image && _image->_surfaceFilename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + + int h1, h2, h3; + int v1, v2, v3; + + h1 = _upLeft.right; + h2 = _upMiddle.right - _upMiddle.left; + h3 = _upRight.right - _upRight.left; + + v1 = _upLeft.bottom; + v2 = _middleLeft.bottom - _middleLeft.top; + v3 = _downLeft.bottom - _downLeft.top; + + + buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", v1, v2, v3); + buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUITiledImage::correctSize(int *width, int *height) { + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; + + int nuColumns = (*width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (*height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; + + *width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nuColumns * tileWidth; + *height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nuRows * tileHeight; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_downLeft)); + persistMgr->transfer(TMEMBER(_downMiddle)); + persistMgr->transfer(TMEMBER(_downRight)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_middleLeft)); + persistMgr->transfer(TMEMBER(_middleMiddle)); + persistMgr->transfer(TMEMBER(_middleRight)); + persistMgr->transfer(TMEMBER(_upLeft)); + persistMgr->transfer(TMEMBER(_upMiddle)); + persistMgr->transfer(TMEMBER(_upRight)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UITiledImage.h b/engines/wintermute/ui/UITiledImage.h new file mode 100644 index 0000000000..379af85e81 --- /dev/null +++ b/engines/wintermute/ui/UITiledImage.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITILEDIMAGE_H +#define WINTERMUTE_UITILEDIMAGE_H + + +#include "UIObject.h" +#include "common/rect.h" + +namespace WinterMute { +class CBSubFrame; +class CUITiledImage : public CBObject { +public: + DECLARE_PERSISTENT(CUITiledImage, CBObject) + void correctSize(int *width, int *height); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + bool display(int x, int y, int width, int height); + CUITiledImage(CBGame *inGame = NULL); + virtual ~CUITiledImage(); + CBSubFrame *_image; + Rect32 _upLeft; + Rect32 _upMiddle; + Rect32 _upRight; + Rect32 _middleLeft; + Rect32 _middleMiddle; + Rect32 _middleRight; + Rect32 _downLeft; + Rect32 _downMiddle; + Rect32 _downRight; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIWindow.cpp b/engines/wintermute/ui/UIWindow.cpp new file mode 100644 index 0000000000..1c6931b4a6 --- /dev/null +++ b/engines/wintermute/ui/UIWindow.cpp @@ -0,0 +1,1327 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/ui/UIButton.h" +#include "engines/wintermute/ui/UIEdit.h" +#include "engines/wintermute/ui/UIText.h" +#include "engines/wintermute/ui/UITiledImage.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIWindow, false) + +////////////////////////////////////////////////////////////////////////// +CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { + CBPlatform::setRectEmpty(&_titleRect); + CBPlatform::setRectEmpty(&_dragRect); + _titleAlign = TAL_LEFT; + _transparent = false; + + _backInactive = NULL; + _fontInactive = NULL; + _imageInactive = NULL; + + _type = UI_WINDOW; + _canFocus = true; + + _dragging = false; + _dragFrom.x = _dragFrom.y = 0; + + _mode = WINDOW_NORMAL; + _shieldWindow = NULL; + _shieldButton = NULL; + + _fadeColor = 0x00000000; + _fadeBackground = false; + + _ready = true; + _isMenu = false; + _inGame = false; + + _clipContents = false; + _viewport = NULL; + + _pauseMusic = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIWindow::~CUIWindow() { + close(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::cleanup() { + delete _shieldWindow; + delete _shieldButton; + delete _viewport; + _shieldWindow = NULL; + _shieldButton = NULL; + _viewport = NULL; + + delete _backInactive; + if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + if (!_sharedImages && _imageInactive) delete _imageInactive; + + for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; + _widgets.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::display(int offsetX, int offsetY) { + // go exclusive + if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + + _shieldWindow->display(); + } + } else if (_isMenu) { + if (!_shieldButton) { + _shieldButton = new CUIButton(_gameRef); + _shieldButton->setName("close"); + _shieldButton->setListener(this, _shieldButton, 0); + _shieldButton->_parent = this; + } + if (_shieldButton) { + _shieldButton->_posX = _shieldButton->_posY = 0; + _shieldButton->_width = _gameRef->_renderer->_width; + _shieldButton->_height = _gameRef->_renderer->_height; + + _shieldButton->display(); + } + } + + if (!_visible) + return STATUS_OK; + + if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); + + if (_dragging) { + _posX += (_gameRef->_mousePos.x - _dragFrom.x); + _posY += (_gameRef->_mousePos.y - _dragFrom.y); + + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; + } + + if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { + moveFocus(); + } + + bool popViewport = false; + if (_clipContents) { + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) { + _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); + _gameRef->pushViewport(_viewport); + popViewport = true; + } + } + + + CUITiledImage *back = _back; + CBSprite *image = _image; + CBFont *font = _font; + + if (!isFocused()) { + if (_backInactive) back = _backInactive; + if (_imageInactive) image = _imageInactive; + if (_fontInactive) font = _fontInactive; + } + + if (_alphaColor != 0) + _gameRef->_renderer->_forceAlphaColor = _alphaColor; + if (back) + back->display(_posX + offsetX, _posY + offsetY, _width, _height); + if (image) + image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); + + if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { + font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + } + + if (!_transparent && !image) + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + + for (int i = 0; i < _widgets.getSize(); i++) { + _widgets[i]->display(_posX + offsetX, _posY + offsetY); + } + + if (_alphaColor != 0) + _gameRef->_renderer->_forceAlphaColor = 0; + + if (popViewport) + _gameRef->popViewport(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WINDOW) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK_INACTIVE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE_INACTIVE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_INACTIVE) +TOKEN_DEF(FONT) +TOKEN_DEF(TITLE_ALIGN) +TOKEN_DEF(TITLE_RECT) +TOKEN_DEF(TITLE) +TOKEN_DEF(DRAG_RECT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(FADE_ALPHA) +TOKEN_DEF(FADE_COLOR) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(BUTTON) +TOKEN_DEF(STATIC) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MENU) +TOKEN_DEF(IN_GAME) +TOKEN_DEF(CLIP_CONTENTS) +TOKEN_DEF(PAUSE_MUSIC) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK_INACTIVE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE_INACTIVE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_INACTIVE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TITLE_ALIGN) + TOKEN_TABLE(TITLE_RECT) + TOKEN_TABLE(TITLE) + TOKEN_TABLE(DRAG_RECT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(FADE_ALPHA) + TOKEN_TABLE(FADE_COLOR) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MENU) + TOKEN_TABLE(IN_GAME) + TOKEN_TABLE(CLIP_CONTENTS) + TOKEN_TABLE(PAUSE_MUSIC) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; + int ar = 0, ag = 0, ab = 0, alpha = 0; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + _gameRef->LOG(0, "'WINDOW' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_INACTIVE: + delete _backInactive; + _backInactive = new CUITiledImage(_gameRef); + if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { + delete _backInactive; + _backInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_INACTIVE: + delete _imageInactive, + _imageInactive = new CBSprite(_gameRef); + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { + delete _imageInactive; + _imageInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_INACTIVE: + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontInactive) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TITLE: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TITLE_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; + else _titleAlign = TAL_CENTER; + break; + + case TOKEN_TITLE_RECT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); + break; + + case TOKEN_DRAG_RECT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BUTTON: { + CUIButton *btn = new CUIButton(_gameRef); + if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { + delete btn; + btn = NULL; + cmd = PARSERR_GENERIC; + } else { + btn->_parent = this; + _widgets.add(btn); + } + } + break; + + case TOKEN_STATIC: { + CUIText *text = new CUIText(_gameRef); + if (!text || DID_FAIL(text->loadBuffer(params, false))) { + delete text; + text = NULL; + cmd = PARSERR_GENERIC; + } else { + text->_parent = this; + _widgets.add(text); + } + } + break; + + case TOKEN_EDIT: { + CUIEdit *edit = new CUIEdit(_gameRef); + if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { + delete edit; + edit = NULL; + cmd = PARSERR_GENERIC; + } else { + edit->_parent = this; + _widgets.add(edit); + } + } + break; + + case TOKEN_WINDOW: { + CUIWindow *win = new CUIWindow(_gameRef); + if (!win || DID_FAIL(win->loadBuffer(params, false))) { + delete win; + win = NULL; + cmd = PARSERR_GENERIC; + } else { + win->_parent = this; + _widgets.add(win); + } + } + break; + + + case TOKEN_TRANSPARENT: + parser.scanStr((char *)params, "%b", &_transparent); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_PAUSE_MUSIC: + parser.scanStr((char *)params, "%b", &_pauseMusic); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_MENU: + parser.scanStr((char *)params, "%b", &_isMenu); + break; + + case TOKEN_IN_GAME: + parser.scanStr((char *)params, "%b", &_inGame); + break; + + case TOKEN_CLIP_CONTENTS: + parser.scanStr((char *)params, "%b", &_clipContents); + break; + + case TOKEN_FADE_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); + _fadeBackground = true; + break; + + case TOKEN_FADE_ALPHA: + parser.scanStr((char *)params, "%d", &fadeA); + _fadeBackground = true; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + + default: + if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { + cmd = PARSERR_GENERIC; + } + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in WINDOW definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading WINDOW definition"); + return STATUS_FAILED; + } + + correctSize(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + + if (_fadeBackground) + _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); + + _focusedWidget = NULL; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WINDOW\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backInactive && _backInactive->_filename) + buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageInactive && _imageInactive->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontInactive && _fontInactive->_filename) + buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); + + switch (_titleAlign) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); + } + + if (!CBPlatform::isRectEmpty(&_titleRect)) { + buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + } + + if (!CBPlatform::isRectEmpty(&_dragRect)) { + buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_fadeBackground) { + buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", RGBCOLGetA(_fadeColor)); + } + + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA=%d\n", RGBCOLGetA(_alphaColor)); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + // controls + for (int i = 0; i < _widgets.getSize(); i++) + _widgets[i]->saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::enableWidget(const char *name, bool Enable) { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::showWidget(const char *name, bool Visible) { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetWidget / GetControl + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->getType() == VAL_INT) { + int widget = val->getInt(); + if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); + else stack->pushNative(_widgets[widget], true); + } else { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { + stack->pushNative(_widgets[i], true); + return STATUS_OK; + } + } + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInactiveFont") == 0) { + stack->correctParams(1); + + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); + stack->pushBool(_fontInactive != NULL); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInactiveImage") == 0) { + stack->correctParams(1); + + delete _imageInactive; + _imageInactive = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { + delete _imageInactive; + _imageInactive = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInactiveImage") == 0) { + stack->correctParams(0); + if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); + else stack->pushString(_imageInactive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInactiveImageObject") == 0) { + stack->correctParams(0); + if (!_imageInactive) stack->pushNULL(); + else stack->pushNative(_imageInactive, true); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(close())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoExclusive") == 0) { + stack->correctParams(0); + goExclusive(); + script->waitFor(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoSystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoSystemExclusive") == 0) { + stack->correctParams(0); + goSystemExclusive(); + script->waitFor(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Center + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Center") == 0) { + stack->correctParams(0); + _posX = (_gameRef->_renderer->_width - _width) / 2; + _posY = (_gameRef->_renderer->_height - _height) / 2; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadFromFile + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadFromFile") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + cleanup(); + if (!val->isNULL()) { + stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateButton") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIButton *btn = new CUIButton(_gameRef); + if (!val->isNULL()) btn->setName(val->getString()); + stack->pushNative(btn, true); + + btn->_parent = this; + _widgets.add(btn); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateStatic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateStatic") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIText *sta = new CUIText(_gameRef); + if (!val->isNULL()) sta->setName(val->getString()); + stack->pushNative(sta, true); + + sta->_parent = this; + _widgets.add(sta); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEditor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEditor") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIEdit *edi = new CUIEdit(_gameRef); + if (!val->isNULL()) edi->setName(val->getString()); + stack->pushNative(edi, true); + + edi->_parent = this; + _widgets.add(edi); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + + win->_parent = this; + _widgets.add(win); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CUIObject *obj = (CUIObject *)val->getNative(); + + for (int i = 0; i < _widgets.getSize(); i++) { + if (_widgets[i] == obj) { + delete _widgets[i]; + _widgets.removeAt(i); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + } + } + stack->pushNULL(); + return STATUS_OK; + } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIWindow::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("window"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWidgets / NumControls (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { + _scValue->setInt(_widgets.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exclusive") == 0) { + _scValue->setBool(_mode == WINDOW_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SystemExclusive") == 0) { + _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Menu") == 0) { + _scValue->setBool(_isMenu); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InGame") == 0) { + _scValue->setBool(_inGame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0) { + _scValue->setBool(_pauseMusic); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClipContents") == 0) { + _scValue->setBool(_clipContents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Transparent") == 0) { + _scValue->setBool(_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeColor") == 0) { + _scValue->setInt((int)_fadeColor); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Menu") == 0) { + _isMenu = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InGame") == 0) { + _inGame = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0) { + _pauseMusic = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClipContents") == 0) { + _clipContents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Transparent") == 0) { + _transparent = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeColor") == 0) { + _fadeColor = (uint32)value->getInt(); + _fadeBackground = (_fadeColor != 0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exclusive") == 0) { + if (value->getBool()) + goExclusive(); + else { + close(); + _visible = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SystemExclusive") == 0) { + if (value->getBool()) + goSystemExclusive(); + else { + close(); + _visible = true; + } + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIWindow::scToString() { + return "[window]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { +//TODO + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { + return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); + } else { + if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); + else return false; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleMouseWheel(int Delta) { + if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + bool res = CUIObject::handleMouse(event, button); + + // handle window dragging + if (!CBPlatform::isRectEmpty(&_dragRect)) { + // start drag + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + Rect32 dragRect = _dragRect; + int offsetX, offsetY; + getTotalOffset(&offsetX, &offsetY); + CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); + + if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; + _dragging = true; + } + } + // end drag + else if (_dragging && event == MOUSE_RELEASE && button == MOUSE_BUTTON_LEFT) { + _dragging = false; + } + } + + return res; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_backInactive)); + persistMgr->transfer(TMEMBER(_clipContents)); + persistMgr->transfer(TMEMBER(_dragFrom)); + persistMgr->transfer(TMEMBER(_dragging)); + persistMgr->transfer(TMEMBER(_dragRect)); + persistMgr->transfer(TMEMBER(_fadeBackground)); + persistMgr->transfer(TMEMBER(_fadeColor)); + persistMgr->transfer(TMEMBER(_fontInactive)); + persistMgr->transfer(TMEMBER(_imageInactive)); + persistMgr->transfer(TMEMBER(_inGame)); + persistMgr->transfer(TMEMBER(_isMenu)); + persistMgr->transfer(TMEMBER_INT(_mode)); + persistMgr->transfer(TMEMBER(_shieldButton)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER_INT(_titleAlign)); + persistMgr->transfer(TMEMBER(_titleRect)); + persistMgr->transfer(TMEMBER(_transparent)); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_pauseMusic)); + + _widgets.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::moveFocus(bool forward) { + int i; + bool found = false; + for (i = 0; i < _widgets.getSize(); i++) { + if (_widgets[i] == _focusedWidget) { + found = true; + break; + } + } + if (!found) _focusedWidget = NULL; + + if (!_focusedWidget) { + if (_widgets.getSize() > 0) i = 0; + else return STATUS_OK; + } + + int numTries = 0; + bool done = false; + + while (numTries <= _widgets.getSize()) { + if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + _focusedWidget = _widgets[i]; + done = true; + break; + } + + if (forward) { + i++; + if (i >= _widgets.getSize()) i = 0; + } else { + i--; + if (i < 0) i = _widgets.getSize() - 1; + } + numTries++; + } + + return done ? STATUS_OK : STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::goExclusive() { + if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; + + if (_mode == WINDOW_NORMAL) { + _ready = false; + _mode = WINDOW_EXCLUSIVE; + _visible = true; + _disable = false; + _gameRef->focusWindow(this); + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::goSystemExclusive() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; + + makeFreezable(false); + + _mode = WINDOW_SYSTEM_EXCLUSIVE; + _ready = false; + _visible = true; + _disable = false; + _gameRef->focusWindow(this); + + _gameRef->freeze(_pauseMusic); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::close() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { + _gameRef->unfreeze(); + } + + _mode = WINDOW_NORMAL; + _visible = false; + _ready = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) close(); + else return CBObject::listen(param1, param2); + break; + default: + return CBObject::listen(param1, param2); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::makeFreezable(bool freezable) { + for (int i = 0; i < _widgets.getSize(); i++) + _widgets[i]->makeFreezable(freezable); + + CBObject::makeFreezable(freezable); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _widgets.getSize(); i++) { + CUIObject *control = _widgets[i]; + if (control->_disable && interactiveOnly) continue; + + switch (control->_type) { + case UI_WINDOW: + ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); + break; + + case UI_BUTTON: + case UI_EDIT: + objects.add(control); + break; + + default: + if (!interactiveOnly) objects.add(control); + } + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIWindow.h b/engines/wintermute/ui/UIWindow.h new file mode 100644 index 0000000000..f1d46711ff --- /dev/null +++ b/engines/wintermute/ui/UIWindow.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIWINDOW_H +#define WINTERMUTE_UIWINDOW_H + + +#include "UIObject.h" +#include "common/events.h" + +namespace WinterMute { + +class CUIButton; +class CBViewport; +class CUIWindow : public CUIObject { +public: + bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); + + bool _pauseMusic; + void cleanup(); + virtual void makeFreezable(bool freezable); + CBViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + uint32 _fadeColor; + virtual bool handleMouseWheel(int delta); + CUIWindow *_shieldWindow; + CUIButton *_shieldButton; + bool close(); + bool goSystemExclusive(); + bool goExclusive(); + TWindowMode _mode; + bool moveFocus(bool forward = true); + virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); + Point32 _dragFrom; + bool _dragging; + DECLARE_PERSISTENT(CUIWindow, CUIObject) + bool _transparent; + bool showWidget(const char *name, bool visible = true); + bool enableWidget(const char *name, bool enable = true); + Rect32 _titleRect; + Rect32 _dragRect; + virtual bool display(int offsetX = 0, int offsetY = 0); + CUIWindow(CBGame *inGame); + virtual ~CUIWindow(); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + CBArray _widgets; + TTextAlign _titleAlign; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + CUITiledImage *_backInactive; + CBFont *_fontInactive; + CBSprite *_imageInactive; + virtual bool listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 9efc7b8935..641b2d20ac 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/wintypes.h" #include "PathUtil.h" -#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/base/BGame.h" #include "common/str.h" #include "common/textconsole.h" #include "engines/wintermute/wintermute.h" diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h index fd587aa609..a44482e4c6 100644 --- a/engines/wintermute/video/VidPlayer.h +++ b/engines/wintermute/video/VidPlayer.h @@ -34,7 +34,7 @@ #pragma once #endif // _MSC_VER > 1000 -#include "engines/wintermute/Base/BBase.h" +#include "engines/wintermute/base/BBase.h" #define MAX_AUDIO_STREAMS 5 #define MAX_VIDEO_STREAMS 5 diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 3bbd2172f7..8727f6f5a6 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -29,12 +29,12 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BFileManager.h" -#include "engines/wintermute/Base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/Base/gfx/base_image.h" -#include "engines/wintermute/Base/BSoundMgr.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BSoundMgr.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/video/decoders/theora_decoder.h" diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index f403a82f64..f624c9a972 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_VIDTHEORAPLAYER_H #define WINTERMUTE_VIDTHEORAPLAYER_H -#include "engines/wintermute/Base/BBase.h" -#include "engines/wintermute/Base/file/BFile.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/file/BFile.h" #include "engines/wintermute/persistent.h" #include "video/video_decoder.h" #include "common/stream.h" diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 528c379aa9..22981dc35f 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,13 +31,13 @@ #include "common/fs.h" #include "engines/util.h" -#include "engines/wintermute/Ad/AdGame.h" +#include "engines/wintermute/ad/AdGame.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/Base/BRegistry.h" +#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/Base/BSoundMgr.h" -#include "engines/wintermute/Base/scriptables/ScEngine.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" namespace WinterMute { -- cgit v1.2.3 From 22923180269f9356e06f8f8517c8128279d820e9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 19:40:18 +0200 Subject: WINTERMUTE: Cleanup some includes in persistency related classes. --- engines/wintermute/persistent.cpp | 1 + engines/wintermute/persistent.h | 3 --- engines/wintermute/system/SysClassRegistry.cpp | 1 + engines/wintermute/system/SysClassRegistry.h | 1 + engines/wintermute/wintypes.h | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index fb00419100..10c2132326 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -86,6 +86,7 @@ #include "engines/wintermute/ui/UITiledImage.h" #include "engines/wintermute/ui/UIWindow.h" #include "engines/wintermute/video/VidTheoraPlayer.h" +#include "engines/wintermute/system/SysClass.h" // CSysClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 556ccbbd4f..a7d028b911 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -29,8 +29,6 @@ #ifndef WINTERMUTE_PERSISTENT_H #define WINTERMUTE_PERSISTENT_H -#include "engines/wintermute/wintypes.h" - namespace WinterMute { class CBPersistMgr; @@ -41,7 +39,6 @@ typedef bool(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute -#include "engines/wintermute/system/SysClass.h" #include "engines/wintermute/system/SysClassRegistry.h" namespace WinterMute { diff --git a/engines/wintermute/system/SysClassRegistry.cpp b/engines/wintermute/system/SysClassRegistry.cpp index 0b173c3afb..4cc0f4508a 100644 --- a/engines/wintermute/system/SysClassRegistry.cpp +++ b/engines/wintermute/system/SysClassRegistry.cpp @@ -31,6 +31,7 @@ #include "engines/wintermute/wintermute.h" #include "SysInstance.h" #include "SysClassRegistry.h" +#include "engines/wintermute/system/SysClass.h" #include "common/stream.h" namespace WinterMute { diff --git a/engines/wintermute/system/SysClassRegistry.h b/engines/wintermute/system/SysClassRegistry.h index a4a410527d..c9c4e8c072 100644 --- a/engines/wintermute/system/SysClassRegistry.h +++ b/engines/wintermute/system/SysClassRegistry.h @@ -32,6 +32,7 @@ #include "engines/wintermute/wintypes.h" #include "engines/wintermute/dctypes.h" #include "engines/wintermute/persistent.h" +#include "engines/wintermute/system/SysClass.h" #include "common/hashmap.h" #include "common/hash-str.h" #include "common/func.h" diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 04a657c644..8db55e2a37 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -30,7 +30,6 @@ #define WINTERMUTE_WINTYPES_H #include "common/scummsys.h" -#include "common/rect.h" namespace WinterMute { -- cgit v1.2.3 From 6a54365483a7d72fd453c2e819b648633d2c4ff4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 19:44:46 +0200 Subject: WINTERMUTE: Add a few missed path-changes (lowercasing folders) --- engines/wintermute/system/SysClass.cpp | 4 ++-- engines/wintermute/system/SysClassRegistry.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/system/SysClass.cpp b/engines/wintermute/system/SysClass.cpp index dee4b7d2d0..2d1066ab5a 100644 --- a/engines/wintermute/system/SysClass.cpp +++ b/engines/wintermute/system/SysClass.cpp @@ -30,8 +30,8 @@ #include "SysInstance.h" #include "SysClass.h" #include "SysClassRegistry.h" -#include "engines/wintermute/Base/BGame.h" -#include "engines/wintermute/Base/BPersistMgr.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BPersistMgr.h" namespace WinterMute { diff --git a/engines/wintermute/system/SysClassRegistry.cpp b/engines/wintermute/system/SysClassRegistry.cpp index 4cc0f4508a..c37f3857e5 100644 --- a/engines/wintermute/system/SysClassRegistry.cpp +++ b/engines/wintermute/system/SysClassRegistry.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/Base/BGame.h" +#include "engines/wintermute/base/BGame.h" #include "engines/wintermute/PlatformSDL.h" #include "engines/wintermute/wintermute.h" #include "SysInstance.h" -- cgit v1.2.3 From 3ad839b32c5e432e93058218db9139dfbe8b8c84 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 00:45:20 +0200 Subject: WINTERMUTE: Rename PlatformSDL->platform_osystem --- engines/wintermute/PlatformSDL.cpp | 380 --------------------- engines/wintermute/PlatformSDL.h | 88 ----- engines/wintermute/ad/AdActor.cpp | 2 +- engines/wintermute/ad/AdEntity.cpp | 2 +- engines/wintermute/ad/AdInventory.cpp | 2 +- engines/wintermute/ad/AdInventoryBox.cpp | 2 +- engines/wintermute/ad/AdItem.cpp | 2 +- engines/wintermute/ad/AdLayer.cpp | 2 +- engines/wintermute/ad/AdNodeState.cpp | 2 +- engines/wintermute/ad/AdResponseBox.cpp | 2 +- engines/wintermute/ad/AdScene.cpp | 2 +- engines/wintermute/ad/AdSceneState.cpp | 2 +- engines/wintermute/ad/AdTalkHolder.cpp | 2 +- engines/wintermute/base/BActiveRect.cpp | 2 +- engines/wintermute/base/BFader.cpp | 2 +- engines/wintermute/base/BFileManager.cpp | 2 +- engines/wintermute/base/BFrame.cpp | 2 +- engines/wintermute/base/BObject.cpp | 2 +- engines/wintermute/base/BParser.cpp | 2 +- engines/wintermute/base/BPersistMgr.cpp | 2 +- engines/wintermute/base/BRegion.cpp | 2 +- engines/wintermute/base/BResources.cpp | 2 +- engines/wintermute/base/BSprite.cpp | 2 +- engines/wintermute/base/BStringTable.cpp | 2 +- engines/wintermute/base/BSubFrame.cpp | 2 +- engines/wintermute/base/BSurfaceStorage.cpp | 2 +- engines/wintermute/base/BTransitionMgr.cpp | 2 +- engines/wintermute/base/BViewport.cpp | 2 +- engines/wintermute/base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/base/font/BFontBitmap.cpp | 2 +- engines/wintermute/base/font/BFontStorage.cpp | 2 +- engines/wintermute/base/font/BFontTT.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/base/particles/PartEmitter.cpp | 2 +- engines/wintermute/base/particles/PartParticle.cpp | 2 +- engines/wintermute/base/scriptables/SXFile.cpp | 2 +- engines/wintermute/base/scriptables/ScEngine.h | 2 +- engines/wintermute/base/scriptables/ScValue.cpp | 2 +- engines/wintermute/module.mk | 2 +- engines/wintermute/platform_osystem.cpp | 380 +++++++++++++++++++++ engines/wintermute/platform_osystem.h | 88 +++++ engines/wintermute/system/SysClassRegistry.cpp | 2 +- engines/wintermute/ui/UIButton.cpp | 2 +- engines/wintermute/ui/UIEdit.cpp | 2 +- engines/wintermute/ui/UIObject.cpp | 2 +- engines/wintermute/ui/UIText.cpp | 2 +- engines/wintermute/ui/UITiledImage.cpp | 2 +- engines/wintermute/ui/UIWindow.cpp | 2 +- engines/wintermute/utils/PathUtil.h | 2 +- engines/wintermute/utils/StringUtil.h | 2 +- engines/wintermute/utils/utils.cpp | 2 +- engines/wintermute/video/VidTheoraPlayer.cpp | 2 +- engines/wintermute/wintermute.cpp | 2 +- 54 files changed, 518 insertions(+), 518 deletions(-) delete mode 100644 engines/wintermute/PlatformSDL.cpp delete mode 100644 engines/wintermute/PlatformSDL.h create mode 100644 engines/wintermute/platform_osystem.cpp create mode 100644 engines/wintermute/platform_osystem.h (limited to 'engines') diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp deleted file mode 100644 index 5bb757eee7..0000000000 --- a/engines/wintermute/PlatformSDL.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/PlatformSDL.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/system.h" - -namespace WinterMute { - -CBGame *CBPlatform::_gameRef = NULL; - -#define CLASS_NAME "GF_FRAME" -int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) { - _gameRef = inGame; - return true; -} - -////////////////////////////////////////////////////////////////////////// -void CBPlatform::handleEvent(Common::Event *event) { - switch (event->type) { - - case Common::EVENT_LBUTTONDOWN: - if (_gameRef) { - if (_gameRef->isLeftDoubleClick()) _gameRef->onMouseLeftDblClick(); - else _gameRef->onMouseLeftDown(); - } - break; - case Common::EVENT_RBUTTONDOWN: - if (_gameRef) { - if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick(); - else _gameRef->onMouseRightDown(); - } - break; - case Common::EVENT_MBUTTONDOWN: - if (_gameRef) _gameRef->onMouseMiddleDown(); - break; - case Common::EVENT_LBUTTONUP: - if (_gameRef) _gameRef->onMouseLeftUp(); - break; - case Common::EVENT_RBUTTONUP: - if (_gameRef) _gameRef->onMouseRightUp(); - break; - case Common::EVENT_MBUTTONUP: - if (_gameRef) _gameRef->onMouseMiddleUp(); - break; - case Common::EVENT_KEYDOWN: - if (_gameRef) _gameRef->handleKeypress(event); - break; - case Common::EVENT_KEYUP: - if (_gameRef) _gameRef->handleKeyRelease(event); - break; - case Common::EVENT_WHEELUP: - case Common::EVENT_WHEELDOWN: - if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); - break; - /*#ifdef __IPHONEOS__ - { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - POINT p; - GetCursorPos(&p); - _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - - if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "CUIButton") == 0) { - CUIButton *btn = static_cast(_gameRef->_activeObject); - if (btn->_visible && !btn->_disable) btn->_press = true; - } - } - #endif*/ - -//TODO - /* case SDL_MOUSEWHEEL: - if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y); - break; - - case SDL_KEYDOWN: - case SDL_TEXTINPUT: - if (_gameRef) _gameRef->handleKeypress(event); - break; - - case SDL_WINDOWEVENT: - switch (event->window.event) { - case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_RESTORED: - if (_gameRef) _gameRef->OnActivate(true, true); - SDL_ShowCursor(SDL_DISABLE); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - case SDL_WINDOWEVENT_MINIMIZED: - #ifndef __IPHONEOS__ - if (_gameRef) _gameRef->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); - #endif - break; - - case SDL_WINDOWEVENT_CLOSE: - break; - - } - break; - */ - case Common::EVENT_QUIT: - case Common::EVENT_RTL: -/*#ifdef __IPHONEOS__ - if (_gameRef) { - _gameRef->AutoSaveOnExit(); - _gameRef->_quitting = true; - } -#else*/ - if (_gameRef) _gameRef->onWindowClose(); -//#endif - - break; - default: - // TODO: Do we care about any other events? - break; - - } -} - -////////////////////////////////////////////////////////////////////////// -int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { - //TODO - /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { - if (_gameRef) _gameRef->AutoSaveOnExit(); - if (_gameRef) _gameRef->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); - } - */ - return 1; -} - - -////////////////////////////////////////////////////////////////////////// -// Win32 API bindings -////////////////////////////////////////////////////////////////////////// -void CBPlatform::outputDebugString(const char *lpOutputString) { -/* -#ifdef __WIN32__ - ::OutputDebugString(lpOutputString); -#endif -*/ -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBPlatform::getTime() { - return g_system->getMillis(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::getCursorPos(Point32 *lpPoint) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - - Common::Point p = g_system->getEventManager()->getMousePos(); - lpPoint->x = p.x; - lpPoint->y = p.y; - - renderer->pointFromScreen(lpPoint); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setCursorPos(int X, int Y) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); - - Point32 p; - p.x = X; - p.y = Y; - renderer->pointToScreen(&p); -// TODO - //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::showWindow(int nCmdShow) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::deleteFile(const char *lpFileName) { - return remove(lpFileName) ? true : false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { -// try { - warning("CBPlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); - return false; -// if (failIfExists && boost::filesystem::exists(to)) return false; -// boost::filesystem::copy_file(from, to); -// return true; -// } catch (...) { -// return false; -// } -} - -////////////////////////////////////////////////////////////////////////// -void CBPlatform::setCapture() { - return; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::releaseCapture() { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setForegroundWindow() { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRectEmpty(Rect32 *lprc) { - lprc->left = lprc->right = lprc->top = lprc->bottom = 0; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::isRectEmpty(const Rect32 *lprc) { - return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ptInRect(Rect32 *lprc, Point32 p) { - return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { - lprc->left = left; - lprc->top = top; - lprc->right = right; - lprc->bottom = bottom; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { - if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || - lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || - lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { - setRectEmpty(lprcDst); - return false; - } - lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); - lprcDst->right = MIN(lprcSrc1->right, lprcSrc2->right); - lprcDst->top = MAX(lprcSrc1->top, lprcSrc2->top); - lprcDst->bottom = MIN(lprcSrc1->bottom, lprcSrc2->bottom); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { - if (isRectEmpty(lprcSrc1)) { - if (isRectEmpty(lprcSrc2)) { - setRectEmpty(lprcDst); - return false; - } else { - *lprcDst = *lprcSrc2; - } - } else { - if (isRectEmpty(lprcSrc2)) { - *lprcDst = *lprcSrc1; - } else { - lprcDst->left = MIN(lprcSrc1->left, lprcSrc2->left); - lprcDst->top = MIN(lprcSrc1->top, lprcSrc2->top); - lprcDst->right = MAX(lprcSrc1->right, lprcSrc2->right); - lprcDst->bottom = MAX(lprcSrc1->bottom, lprcSrc2->bottom); - } - } - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { - if (lprcDst == NULL || lprcSrc == NULL) return false; - - *lprcDst = *lprcSrc; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { - if (lprc == NULL) return false; - - lprc->left += dx; - lprc->top += dy; - lprc->right += dx; - lprc->bottom += dy; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { - return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::getSystemFontPath() { -/*#ifdef __WIN32__ - // we're looking for something like "c:\windows\fonts\"; - char winDir[MAX_PATH_LENGTH + 1]; - winDir[MAX_PATH_LENGTH] = '\0'; - ::GetWindowsDirectory(winDir, MAX_PATH_LENGTH); - return PathUtil::Combine(AnsiString(winDir), "fonts"); -#else*/ - // !PORTME - //return "/Library/Fonts/"; - return ""; -//#endif -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::getPlatformName() { - // TODO: Should conform to the WME-spec. - //return AnsiString(SDL_GetPlatform()); - return AnsiString("ScummVM"); -} - -////////////////////////////////////////////////////////////////////////// -char *CBPlatform::strupr(char *string) { - if (string) { - for (size_t i = 0; i < strlen(string); ++i) { - string[i] = toupper(string[i]); - } - } - return string; -} - -////////////////////////////////////////////////////////////////////////// -char *CBPlatform::strlwr(char *string) { - if (string) { - for (size_t i = 0; i < strlen(string); ++i) { - string[i] = tolower(string[i]); - } - } - return string; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h deleted file mode 100644 index e0314898bf..0000000000 --- a/engines/wintermute/PlatformSDL.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PLATFORMSDL_H -#define WINTERMUTE_PLATFORMSDL_H - -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/wintypes.h" -#include "common/events.h" - -namespace WinterMute { - -class CBGame; - -////////////////////////////////////////////////////////////////////////// -class CBPlatform { -public: - static int initialize(CBGame *inGame, int argc, char *argv[]); - static void handleEvent(Common::Event *event); - - static AnsiString getSystemFontPath(); - static AnsiString getPlatformName(); - - // Win32 API bindings - static void outputDebugString(const char *lpOutputString); - static uint32 getTime(); - static bool getCursorPos(Point32 *lpPoint); - static bool setCursorPos(int X, int Y); - static bool showWindow(int nCmdShow); - static bool deleteFile(const char *lpFileName); - static bool copyFile(const char *from, const char *to, bool failIfExists); - static void setCapture(); - static bool releaseCapture(); - static bool setForegroundWindow(); - - static bool setRectEmpty(Rect32 *lprc); - static bool isRectEmpty(const Rect32 *lprc); - static bool ptInRect(Rect32 *lprc, Point32 p); - static bool setRect(Rect32 *lprc, int left, int top, int right, int bottom); - static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); - static bool unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2); - static bool copyRect(Rect32 *lprcDst, Rect32 *lprcSrc); - static bool offsetRect(Rect32 *lprc, int dx, int dy); - static bool equalRect(Rect32 *rect1, Rect32 *rect2); - - - // string functions -// static int stricmp(const char *str1, const char *str2); -// static int strnicmp(const char *str1, const char *str2, size_t maxCount); - static char *strupr(char *string); - static char *strlwr(char *string); - - // sdl event callback - static int SDLEventWatcher(void *userdata, Common::Event *event); - -private: - static CBGame *_gameRef; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdActor.cpp b/engines/wintermute/ad/AdActor.cpp index 480851d21f..050a419e53 100644 --- a/engines/wintermute/ad/AdActor.cpp +++ b/engines/wintermute/ad/AdActor.cpp @@ -47,7 +47,7 @@ #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdEntity.cpp b/engines/wintermute/ad/AdEntity.cpp index c559e99abb..49c723f66a 100644 --- a/engines/wintermute/ad/AdEntity.cpp +++ b/engines/wintermute/ad/AdEntity.cpp @@ -45,7 +45,7 @@ #include "engines/wintermute/base/BRegion.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" diff --git a/engines/wintermute/ad/AdInventory.cpp b/engines/wintermute/ad/AdInventory.cpp index 54195cc68a..f913108404 100644 --- a/engines/wintermute/ad/AdInventory.cpp +++ b/engines/wintermute/ad/AdInventory.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/ad/AdInventory.h" #include "engines/wintermute/ad/AdGame.h" #include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdInventoryBox.cpp b/engines/wintermute/ad/AdInventoryBox.cpp index c5c9c3be67..9509bf9b10 100644 --- a/engines/wintermute/ad/AdInventoryBox.cpp +++ b/engines/wintermute/ad/AdInventoryBox.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/BDynBuffer.h" #include "engines/wintermute/ui/UIButton.h" #include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/rect.h" diff --git a/engines/wintermute/ad/AdItem.cpp b/engines/wintermute/ad/AdItem.cpp index 5678f6cfa6..0e443d5c3e 100644 --- a/engines/wintermute/ad/AdItem.cpp +++ b/engines/wintermute/ad/AdItem.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BSound.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/scriptables/ScValue.h" diff --git a/engines/wintermute/ad/AdLayer.cpp b/engines/wintermute/ad/AdLayer.cpp index d797172338..4549ba4af7 100644 --- a/engines/wintermute/ad/AdLayer.cpp +++ b/engines/wintermute/ad/AdLayer.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdNodeState.cpp b/engines/wintermute/ad/AdNodeState.cpp index 8e9894b5f5..fd72a356c5 100644 --- a/engines/wintermute/ad/AdNodeState.cpp +++ b/engines/wintermute/ad/AdNodeState.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/BStringTable.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdResponseBox.cpp b/engines/wintermute/ad/AdResponseBox.cpp index 1a1732edd0..829d58f2ee 100644 --- a/engines/wintermute/ad/AdResponseBox.cpp +++ b/engines/wintermute/ad/AdResponseBox.cpp @@ -42,7 +42,7 @@ #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdScene.cpp b/engines/wintermute/ad/AdScene.cpp index 022ec4a8a5..b284543a08 100644 --- a/engines/wintermute/ad/AdScene.cpp +++ b/engines/wintermute/ad/AdScene.cpp @@ -52,7 +52,7 @@ #include "engines/wintermute/base/BScriptable.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" diff --git a/engines/wintermute/ad/AdSceneState.cpp b/engines/wintermute/ad/AdSceneState.cpp index 2192bc13fe..5dfb8c537e 100644 --- a/engines/wintermute/ad/AdSceneState.cpp +++ b/engines/wintermute/ad/AdSceneState.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/ad/AdSceneState.h" #include "engines/wintermute/ad/AdNodeState.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/AdTalkHolder.cpp b/engines/wintermute/ad/AdTalkHolder.cpp index 4c627ca9ad..e1a91792ce 100644 --- a/engines/wintermute/ad/AdTalkHolder.cpp +++ b/engines/wintermute/ad/AdTalkHolder.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp index 382329087a..836a93ad9a 100644 --- a/engines/wintermute/base/BActiveRect.cpp +++ b/engines/wintermute/base/BActiveRect.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/BActiveRect.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp index 7184c6664c..9dec5e1e12 100644 --- a/engines/wintermute/base/BFader.cpp +++ b/engines/wintermute/base/BFader.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BFader.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/util.h" namespace WinterMute { diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 1cfb3d47d3..80b3d7a8df 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -40,7 +40,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/dcpackage.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/textconsole.h" diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp index 4af9262701..d6d8a3aa5c 100644 --- a/engines/wintermute/base/BFrame.cpp +++ b/engines/wintermute/base/BFrame.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/BSoundMgr.h" #include "engines/wintermute/base/BSound.h" #include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp index 1bb52c0ce6..ed5d6fa5b7 100644 --- a/engines/wintermute/base/BObject.cpp +++ b/engines/wintermute/base/BObject.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BStringTable.h" #include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp index f675d0ca50..80d3b58213 100644 --- a/engines/wintermute/base/BParser.cpp +++ b/engines/wintermute/base/BParser.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BParser.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/util.h" diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp index 0f2cc6bc8a..f8faced95f 100644 --- a/engines/wintermute/base/BPersistMgr.cpp +++ b/engines/wintermute/base/BPersistMgr.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BPersistMgr.h" #include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/math/Vector2.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/base/gfx/base_image.h" diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp index 1c38174cb8..c8ec87e04a 100644 --- a/engines/wintermute/base/BRegion.cpp +++ b/engines/wintermute/base/BRegion.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include namespace WinterMute { diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp index b99441b5db..839be570c5 100644 --- a/engines/wintermute/base/BResources.cpp +++ b/engines/wintermute/base/BResources.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BResources.h" #include "common/str.h" #include "common/memstream.h" diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp index c93a40ca75..c4dfaa3f8d 100644 --- a/engines/wintermute/base/BSprite.cpp +++ b/engines/wintermute/base/BSprite.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BSound.h" #include "engines/wintermute/base/BSubFrame.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp index 44f26ba7e8..470ae8549c 100644 --- a/engines/wintermute/base/BStringTable.cpp +++ b/engines/wintermute/base/BStringTable.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BStringTable.h" diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp index 60048ac05a..858f2125c6 100644 --- a/engines/wintermute/base/BSubFrame.cpp +++ b/engines/wintermute/base/BSubFrame.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BSurfaceStorage.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp index f50d174898..887510b675 100644 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp index 7c9a95368a..1cea7285bf 100644 --- a/engines/wintermute/base/BTransitionMgr.cpp +++ b/engines/wintermute/base/BTransitionMgr.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BTransitionMgr.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp index 0f2a67d3bf..2b237a0d38 100644 --- a/engines/wintermute/base/BViewport.cpp +++ b/engines/wintermute/base/BViewport.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BViewport.h" namespace WinterMute { diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp index b2eebb690b..4a75b7d7ce 100644 --- a/engines/wintermute/base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/base/file/BSaveThumbFile.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp index 031f075d1b..341f90d559 100644 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/BFrame.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp index a777ac9db8..b5605cf2bc 100644 --- a/engines/wintermute/base/font/BFontStorage.cpp +++ b/engines/wintermute/base/font/BFontStorage.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/font/BFontStorage.h" #include "engines/wintermute/base/font/BFont.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp index 2707dbea31..5f0c9fec1a 100644 --- a/engines/wintermute/base/font/BFontTT.cpp +++ b/engines/wintermute/base/font/BFontTT.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 010aca7141..5c5ebd91b4 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BSubFrame.h" #include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 1e4ac9a19e..66c6e4a61a 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp index 81147a5432..97de1fe044 100644 --- a/engines/wintermute/base/particles/PartEmitter.cpp +++ b/engines/wintermute/base/particles/PartEmitter.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/BRegion.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/math.h" diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp index aa641f0a1c..1439231993 100644 --- a/engines/wintermute/base/particles/PartParticle.cpp +++ b/engines/wintermute/base/particles/PartParticle.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp index b2a6d24677..1924a42d72 100644 --- a/engines/wintermute/base/scriptables/SXFile.cpp +++ b/engines/wintermute/base/scriptables/SXFile.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/file/BFile.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/SXFile.h" // Note: This code is completely untested, as I have yet to find a game that uses SXFile. diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h index df327d800c..0322319b3d 100644 --- a/engines/wintermute/base/scriptables/ScEngine.h +++ b/engines/wintermute/base/scriptables/ScEngine.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/BBase.h" #include "engines/wintermute/wme_debugger.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp index e9d5645682..f38a12fc7a 100644 --- a/engines/wintermute/base/scriptables/ScValue.cpp +++ b/engines/wintermute/base/scriptables/ScValue.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BDynBuffer.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/scriptables/ScValue.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 0c74193dac..ccda7ffffe 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -92,7 +92,7 @@ MODULE_OBJS := \ math/MathUtil.o \ math/Matrix4.o \ math/Vector2.o \ - PlatformSDL.o \ + platform_osystem.o \ system/SysClass.o \ system/SysClassRegistry.o \ system/SysInstance.o \ diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp new file mode 100644 index 0000000000..82b53da723 --- /dev/null +++ b/engines/wintermute/platform_osystem.cpp @@ -0,0 +1,380 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/system.h" + +namespace WinterMute { + +CBGame *CBPlatform::_gameRef = NULL; + +#define CLASS_NAME "GF_FRAME" +int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) { + _gameRef = inGame; + return true; +} + +////////////////////////////////////////////////////////////////////////// +void CBPlatform::handleEvent(Common::Event *event) { + switch (event->type) { + + case Common::EVENT_LBUTTONDOWN: + if (_gameRef) { + if (_gameRef->isLeftDoubleClick()) _gameRef->onMouseLeftDblClick(); + else _gameRef->onMouseLeftDown(); + } + break; + case Common::EVENT_RBUTTONDOWN: + if (_gameRef) { + if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick(); + else _gameRef->onMouseRightDown(); + } + break; + case Common::EVENT_MBUTTONDOWN: + if (_gameRef) _gameRef->onMouseMiddleDown(); + break; + case Common::EVENT_LBUTTONUP: + if (_gameRef) _gameRef->onMouseLeftUp(); + break; + case Common::EVENT_RBUTTONUP: + if (_gameRef) _gameRef->onMouseRightUp(); + break; + case Common::EVENT_MBUTTONUP: + if (_gameRef) _gameRef->onMouseMiddleUp(); + break; + case Common::EVENT_KEYDOWN: + if (_gameRef) _gameRef->handleKeypress(event); + break; + case Common::EVENT_KEYUP: + if (_gameRef) _gameRef->handleKeyRelease(event); + break; + case Common::EVENT_WHEELUP: + case Common::EVENT_WHEELDOWN: + if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); + break; + /*#ifdef __IPHONEOS__ + { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + POINT p; + GetCursorPos(&p); + _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); + + if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "CUIButton") == 0) { + CUIButton *btn = static_cast(_gameRef->_activeObject); + if (btn->_visible && !btn->_disable) btn->_press = true; + } + } + #endif*/ + +//TODO + /* case SDL_MOUSEWHEEL: + if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y); + break; + + case SDL_KEYDOWN: + case SDL_TEXTINPUT: + if (_gameRef) _gameRef->handleKeypress(event); + break; + + case SDL_WINDOWEVENT: + switch (event->window.event) { + case SDL_WINDOWEVENT_FOCUS_GAINED: + case SDL_WINDOWEVENT_RESTORED: + if (_gameRef) _gameRef->OnActivate(true, true); + SDL_ShowCursor(SDL_DISABLE); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + case SDL_WINDOWEVENT_MINIMIZED: + #ifndef __IPHONEOS__ + if (_gameRef) _gameRef->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); + #endif + break; + + case SDL_WINDOWEVENT_CLOSE: + break; + + } + break; + */ + case Common::EVENT_QUIT: + case Common::EVENT_RTL: +/*#ifdef __IPHONEOS__ + if (_gameRef) { + _gameRef->AutoSaveOnExit(); + _gameRef->_quitting = true; + } +#else*/ + if (_gameRef) _gameRef->onWindowClose(); +//#endif + + break; + default: + // TODO: Do we care about any other events? + break; + + } +} + +////////////////////////////////////////////////////////////////////////// +int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { + //TODO + /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + if (_gameRef) _gameRef->AutoSaveOnExit(); + if (_gameRef) _gameRef->OnActivate(false, false); + SDL_ShowCursor(SDL_ENABLE); + } + */ + return 1; +} + + +////////////////////////////////////////////////////////////////////////// +// Win32 API bindings +////////////////////////////////////////////////////////////////////////// +void CBPlatform::outputDebugString(const char *lpOutputString) { +/* +#ifdef __WIN32__ + ::OutputDebugString(lpOutputString); +#endif +*/ +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPlatform::getTime() { + return g_system->getMillis(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::getCursorPos(Point32 *lpPoint) { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + Common::Point p = g_system->getEventManager()->getMousePos(); + lpPoint->x = p.x; + lpPoint->y = p.y; + + renderer->pointFromScreen(lpPoint); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::setCursorPos(int X, int Y) { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + Point32 p; + p.x = X; + p.y = Y; + renderer->pointToScreen(&p); +// TODO + //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::showWindow(int nCmdShow) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::deleteFile(const char *lpFileName) { + return remove(lpFileName) ? true : false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { +// try { + warning("CBPlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); + return false; +// if (failIfExists && boost::filesystem::exists(to)) return false; +// boost::filesystem::copy_file(from, to); +// return true; +// } catch (...) { +// return false; +// } +} + +////////////////////////////////////////////////////////////////////////// +void CBPlatform::setCapture() { + return; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::releaseCapture() { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::setForegroundWindow() { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::setRectEmpty(Rect32 *lprc) { + lprc->left = lprc->right = lprc->top = lprc->bottom = 0; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::isRectEmpty(const Rect32 *lprc) { + return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::ptInRect(Rect32 *lprc, Point32 p) { + return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { + lprc->left = left; + lprc->top = top; + lprc->right = right; + lprc->bottom = bottom; + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { + if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || + lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || + lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { + setRectEmpty(lprcDst); + return false; + } + lprcDst->left = MAX(lprcSrc1->left, lprcSrc2->left); + lprcDst->right = MIN(lprcSrc1->right, lprcSrc2->right); + lprcDst->top = MAX(lprcSrc1->top, lprcSrc2->top); + lprcDst->bottom = MIN(lprcSrc1->bottom, lprcSrc2->bottom); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { + if (isRectEmpty(lprcSrc1)) { + if (isRectEmpty(lprcSrc2)) { + setRectEmpty(lprcDst); + return false; + } else { + *lprcDst = *lprcSrc2; + } + } else { + if (isRectEmpty(lprcSrc2)) { + *lprcDst = *lprcSrc1; + } else { + lprcDst->left = MIN(lprcSrc1->left, lprcSrc2->left); + lprcDst->top = MIN(lprcSrc1->top, lprcSrc2->top); + lprcDst->right = MAX(lprcSrc1->right, lprcSrc2->right); + lprcDst->bottom = MAX(lprcSrc1->bottom, lprcSrc2->bottom); + } + } + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { + if (lprcDst == NULL || lprcSrc == NULL) return false; + + *lprcDst = *lprcSrc; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { + if (lprc == NULL) return false; + + lprc->left += dx; + lprc->top += dy; + lprc->right += dx; + lprc->bottom += dy; + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { + return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBPlatform::getSystemFontPath() { +/*#ifdef __WIN32__ + // we're looking for something like "c:\windows\fonts\"; + char winDir[MAX_PATH_LENGTH + 1]; + winDir[MAX_PATH_LENGTH] = '\0'; + ::GetWindowsDirectory(winDir, MAX_PATH_LENGTH); + return PathUtil::Combine(AnsiString(winDir), "fonts"); +#else*/ + // !PORTME + //return "/Library/Fonts/"; + return ""; +//#endif +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBPlatform::getPlatformName() { + // TODO: Should conform to the WME-spec. + //return AnsiString(SDL_GetPlatform()); + return AnsiString("ScummVM"); +} + +////////////////////////////////////////////////////////////////////////// +char *CBPlatform::strupr(char *string) { + if (string) { + for (size_t i = 0; i < strlen(string); ++i) { + string[i] = toupper(string[i]); + } + } + return string; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPlatform::strlwr(char *string) { + if (string) { + for (size_t i = 0; i < strlen(string); ++i) { + string[i] = tolower(string[i]); + } + } + return string; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h new file mode 100644 index 0000000000..e0314898bf --- /dev/null +++ b/engines/wintermute/platform_osystem.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PLATFORMSDL_H +#define WINTERMUTE_PLATFORMSDL_H + +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/wintypes.h" +#include "common/events.h" + +namespace WinterMute { + +class CBGame; + +////////////////////////////////////////////////////////////////////////// +class CBPlatform { +public: + static int initialize(CBGame *inGame, int argc, char *argv[]); + static void handleEvent(Common::Event *event); + + static AnsiString getSystemFontPath(); + static AnsiString getPlatformName(); + + // Win32 API bindings + static void outputDebugString(const char *lpOutputString); + static uint32 getTime(); + static bool getCursorPos(Point32 *lpPoint); + static bool setCursorPos(int X, int Y); + static bool showWindow(int nCmdShow); + static bool deleteFile(const char *lpFileName); + static bool copyFile(const char *from, const char *to, bool failIfExists); + static void setCapture(); + static bool releaseCapture(); + static bool setForegroundWindow(); + + static bool setRectEmpty(Rect32 *lprc); + static bool isRectEmpty(const Rect32 *lprc); + static bool ptInRect(Rect32 *lprc, Point32 p); + static bool setRect(Rect32 *lprc, int left, int top, int right, int bottom); + static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); + static bool unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2); + static bool copyRect(Rect32 *lprcDst, Rect32 *lprcSrc); + static bool offsetRect(Rect32 *lprc, int dx, int dy); + static bool equalRect(Rect32 *rect1, Rect32 *rect2); + + + // string functions +// static int stricmp(const char *str1, const char *str2); +// static int strnicmp(const char *str1, const char *str2, size_t maxCount); + static char *strupr(char *string); + static char *strlwr(char *string); + + // sdl event callback + static int SDLEventWatcher(void *userdata, Common::Event *event); + +private: + static CBGame *_gameRef; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/system/SysClassRegistry.cpp b/engines/wintermute/system/SysClassRegistry.cpp index c37f3857e5..3260fd3d5f 100644 --- a/engines/wintermute/system/SysClassRegistry.cpp +++ b/engines/wintermute/system/SysClassRegistry.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "SysInstance.h" #include "SysClassRegistry.h" diff --git a/engines/wintermute/ui/UIButton.cpp b/engines/wintermute/ui/UIButton.cpp index f6c50597bd..273f923376 100644 --- a/engines/wintermute/ui/UIButton.cpp +++ b/engines/wintermute/ui/UIButton.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BStringTable.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/ui/UIEdit.cpp b/engines/wintermute/ui/UIEdit.cpp index 4825761734..610853d8cb 100644 --- a/engines/wintermute/ui/UIEdit.cpp +++ b/engines/wintermute/ui/UIEdit.cpp @@ -40,7 +40,7 @@ #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BStringTable.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/scriptables/ScScript.h" diff --git a/engines/wintermute/ui/UIObject.cpp b/engines/wintermute/ui/UIObject.cpp index 1032faeb2c..8b3dc19537 100644 --- a/engines/wintermute/ui/UIObject.cpp +++ b/engines/wintermute/ui/UIObject.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/ui/UIObject.h" #include "engines/wintermute/ui/UITiledImage.h" #include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/font/BFontStorage.h" diff --git a/engines/wintermute/ui/UIText.cpp b/engines/wintermute/ui/UIText.cpp index 0b7df9bf19..a496483f67 100644 --- a/engines/wintermute/ui/UIText.cpp +++ b/engines/wintermute/ui/UIText.cpp @@ -40,7 +40,7 @@ #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/ui/UITiledImage.cpp b/engines/wintermute/ui/UITiledImage.cpp index b80ae76978..04a2cfca58 100644 --- a/engines/wintermute/ui/UITiledImage.cpp +++ b/engines/wintermute/ui/UITiledImage.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BSubFrame.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/ui/UIWindow.cpp b/engines/wintermute/ui/UIWindow.cpp index 1c6931b4a6..35330e720e 100644 --- a/engines/wintermute/ui/UIWindow.cpp +++ b/engines/wintermute/ui/UIWindow.cpp @@ -46,7 +46,7 @@ #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/utils/PathUtil.h b/engines/wintermute/utils/PathUtil.h index 13e9e46652..139ce89ddd 100644 --- a/engines/wintermute/utils/PathUtil.h +++ b/engines/wintermute/utils/PathUtil.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_PATHUTILS_H #define WINTERMUTE_PATHUTILS_H -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h index 794007276b..bd1b71f405 100644 --- a/engines/wintermute/utils/StringUtil.h +++ b/engines/wintermute/utils/StringUtil.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_STRINGUTIL_H #define WINTERMUTE_STRINGUTIL_H -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 641b2d20ac..1735732185 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintypes.h" #include "PathUtil.h" #include "engines/wintermute/base/BGame.h" diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 8727f6f5a6..ffb24d22dd 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/BSoundMgr.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/video/decoders/theora_decoder.h" #include "common/system.h" //#pragma comment(lib, "libtheora.lib") diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 22981dc35f..220e9f4057 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -33,7 +33,7 @@ #include "engines/util.h" #include "engines/wintermute/ad/AdGame.h" #include "engines/wintermute/wintermute.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BRegistry.h" #include "engines/wintermute/base/BSoundMgr.h" -- cgit v1.2.3 From c648eb2b5ed80f12222556fd6c8a35b9c99dc0fc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 00:53:38 +0200 Subject: WINTERMUTE: Move BFileEntry and BPackage into base/file --- engines/wintermute/base/BFileEntry.cpp | 50 ------------- engines/wintermute/base/BFileEntry.h | 57 --------------- engines/wintermute/base/BFileManager.cpp | 4 +- engines/wintermute/base/BFileManager.h | 2 +- engines/wintermute/base/BPackage.cpp | 104 ---------------------------- engines/wintermute/base/BPackage.h | 61 ---------------- engines/wintermute/base/file/BFileEntry.cpp | 50 +++++++++++++ engines/wintermute/base/file/BFileEntry.h | 57 +++++++++++++++ engines/wintermute/base/file/BPackage.cpp | 104 ++++++++++++++++++++++++++++ engines/wintermute/base/file/BPackage.h | 61 ++++++++++++++++ engines/wintermute/base/file/BPkgFile.cpp | 2 +- engines/wintermute/base/file/BPkgFile.h | 2 +- engines/wintermute/module.mk | 4 +- 13 files changed, 279 insertions(+), 279 deletions(-) delete mode 100644 engines/wintermute/base/BFileEntry.cpp delete mode 100644 engines/wintermute/base/BFileEntry.h delete mode 100644 engines/wintermute/base/BPackage.cpp delete mode 100644 engines/wintermute/base/BPackage.h create mode 100644 engines/wintermute/base/file/BFileEntry.cpp create mode 100644 engines/wintermute/base/file/BFileEntry.h create mode 100644 engines/wintermute/base/file/BPackage.cpp create mode 100644 engines/wintermute/base/file/BPackage.h (limited to 'engines') diff --git a/engines/wintermute/base/BFileEntry.cpp b/engines/wintermute/base/BFileEntry.cpp deleted file mode 100644 index 39223bfb8e..0000000000 --- a/engines/wintermute/base/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileEntry.h b/engines/wintermute/base/BFileEntry.h deleted file mode 100644 index 5fdf2b6308..0000000000 --- a/engines/wintermute/base/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 80b3d7a8df..35dde203c7 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -32,10 +32,10 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/base/file/BDiskFile.h" #include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" +#include "engines/wintermute/base/file/BPackage.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/BResources.h" -#include "engines/wintermute/base/BPackage.h" #include "engines/wintermute/base/BRegistry.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/dcpackage.h" diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h index 8e7551480d..7ea9ff5611 100644 --- a/engines/wintermute/base/BFileManager.h +++ b/engines/wintermute/base/BFileManager.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/BPackage.cpp b/engines/wintermute/base/BPackage.cpp deleted file mode 100644 index 020b7b902f..0000000000 --- a/engines/wintermute/base/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPackage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - closeFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { - if (_file) return STATUS_OK; - else { - _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { - delete _file; - _file = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (DID_FAIL(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); - if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPackage.h b/engines/wintermute/base/BPackage.h deleted file mode 100644 index 8c803fddd9..0000000000 --- a/engines/wintermute/base/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "engines/wintermute/base/BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFileEntry.cpp b/engines/wintermute/base/file/BFileEntry.cpp new file mode 100644 index 0000000000..b00ecb6f9d --- /dev/null +++ b/engines/wintermute/base/file/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFileEntry.h b/engines/wintermute/base/file/BFileEntry.h new file mode 100644 index 0000000000..5fdf2b6308 --- /dev/null +++ b/engines/wintermute/base/file/BFileEntry.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPackage.cpp b/engines/wintermute/base/file/BPackage.cpp new file mode 100644 index 0000000000..bddf1abc1e --- /dev/null +++ b/engines/wintermute/base/file/BPackage.cpp @@ -0,0 +1,104 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BPackage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPackage.h b/engines/wintermute/base/file/BPackage.h new file mode 100644 index 0000000000..8c803fddd9 --- /dev/null +++ b/engines/wintermute/base/file/BPackage.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/BBase.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 7eafe7919e..b787851290 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/file/BPackage.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index f8a5831485..dc8b4b684f 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BPKGFILE_H #define WINTERMUTE_BPKGFILE_H -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" namespace Common { class SeekableReadStream; diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index ccda7ffffe..0063d072b1 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -40,6 +40,8 @@ MODULE_OBJS := \ base/scriptables/SXString.o \ base/file/BDiskFile.o \ base/file/BFile.o \ + base/file/BFileEntry.o \ + base/file/BPackage.o \ base/file/BSaveThumbFile.o \ base/file/BPkgFile.o \ base/font/BFontBitmap.o \ @@ -59,14 +61,12 @@ MODULE_OBJS := \ base/BDebugger.o \ base/BDynBuffer.o \ base/BFader.o \ - base/BFileEntry.o \ base/BFileManager.o \ base/BGame.o \ base/BFrame.o \ base/BKeyboardState.o \ base/BNamedObject.o \ base/BObject.o \ - base/BPackage.o \ base/BParser.o \ base/BPersistMgr.o \ base/BPoint.o \ -- cgit v1.2.3 From df115ce8d4eac608e611acc971181b5b27c49fbe Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 02:26:20 +0200 Subject: WINTERMUTE: Move the detection-entries over to detection_tables.h --- engines/wintermute/detection.cpp | 194 +--------------------------- engines/wintermute/detection_tables.h | 233 ++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+), 193 deletions(-) create mode 100644 engines/wintermute/detection_tables.h (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 437ee76035..e3fbb15d3f 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -30,199 +30,7 @@ #include "engines/metaengine.h" -namespace WinterMute { - -static const PlainGameDescriptor wintermuteGames[] = { - {"5ld", "Five Lethal Demons"}, - {"5ma", "Five Magical Amulets"}, - {"actualdest", "Actual Destination"}, - {"chivalry", "Chivalry is Not Dead"}, - {"deadcity", "Dead City"}, - {"dirtysplit", "Dirty Split"}, - {"eastside", "East Side Story"}, - {"ghostsheet", "Ghost in the Sheet"}, - {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, - {"julia", "J.U.L.I.A."}, - {"mirage", "Mirage"}, - {"pigeons", "Pigeons in the Park"}, - {"reversion", "Reversion"}, - {"rosemary", "Rosemary"}, - {"thebox", "The Box"}, - {"twc", "the white chamber"}, - {"wintermute", "Wintermute engine game"}, - {0, 0} -}; - -static const ADGameDescription gameDescriptions[] = { - { - "5ld", - "", - AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "5ma", - "", - AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "actualdest", - "", - AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "chivalry", - "", - AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "deadcity", - "", - AD_ENTRY1s("data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "eastside", - "Demo", - AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - { - "ghostsheet", - "Demo", - AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - { - "hamlet", - "", - AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "julia", - "", - AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "julia", - "Demo", - AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - { - "mirage", - "", - AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "pigeons", - "", - AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "reversion", - "", - AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "rosemary", - "", - AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "thebox", - "", - AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - { - "twc", - "", - AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - AD_TABLE_END_MARKER -}; - -} +#include "engines/wintermute/detection_tables.h" class WinterMuteMetaEngine : public AdvancedMetaEngine { public: diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h new file mode 100644 index 0000000000..0f15d1043e --- /dev/null +++ b/engines/wintermute/detection_tables.h @@ -0,0 +1,233 @@ +/* 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. + * + */ + +namespace WinterMute { + +static const PlainGameDescriptor wintermuteGames[] = { + {"5ld", "Five Lethal Demons"}, + {"5ma", "Five Magical Amulets"}, + {"actualdest", "Actual Destination"}, + {"chivalry", "Chivalry is Not Dead"}, + {"deadcity", "Dead City"}, + {"dirtysplit", "Dirty Split"}, + {"eastside", "East Side Story"}, + {"ghostsheet", "Ghost in the Sheet"}, + {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, + {"julia", "J.U.L.I.A."}, + {"mirage", "Mirage"}, + {"pigeons", "Pigeons in the Park"}, + {"reversion", "Reversion"}, + {"rosemary", "Rosemary"}, + {"thebox", "The Box"}, + {"twc", "the white chamber"}, + {"wintermute", "Wintermute engine game"}, + {0, 0} +}; + +static const ADGameDescription gameDescriptions[] = { + // Five Lethal Demons + { + "5ld", + "", + AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Five Magical Amulets + { + "5ma", + "", + AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Actual Destination + { + "actualdest", + "", + AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Chivalry is Not Dead + { + "chivalry", + "", + AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Dead City + { + "deadcity", + "", + AD_ENTRY1s("data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Dirty Split (English) + { + "dirtysplit", + "", + AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Dirty Split (German) + { + "dirtysplit", + "", + AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // East Side Story (Demo) + { + "eastside", + "Demo", + AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + // Ghosts in the Sheet + { + "ghostsheet", + "Demo", + AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + // Hamlet or the last game without MMORPS features, shaders and product placement + { + "hamlet", + "", + AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // J.U.L.I.A. (English) + { + "julia", + "", + AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // J.U.L.I.A. (English) (Demo) + { + "julia", + "Demo", + AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + // Mirage + { + "mirage", + "", + AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Pigeons in the Park + { + "pigeons", + "", + AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Reversion + { + "reversion", + "", + AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Rosemary + { + "rosemary", + "", + AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // The Box + { + "thebox", + "", + AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // the white chamber (multi-language) + { + "twc", + "", + AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), + Common::UNK_LANG, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + AD_TABLE_END_MARKER +}; + +} // End of namespace WinterMute -- cgit v1.2.3 From 958cb16f9e9d0995c71a54bd20d4b8464775a9e6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 02:44:15 +0200 Subject: WINTERMUTE: Silence a few signed/unsigned warnings. --- engines/wintermute/base/BFileManager.cpp | 30 +++++++++++----------- engines/wintermute/base/BSoundMgr.cpp | 10 ++++---- engines/wintermute/base/BSurfaceStorage.cpp | 10 ++++---- engines/wintermute/base/file/BDiskFile.cpp | 2 +- engines/wintermute/base/font/BFontBitmap.cpp | 2 +- engines/wintermute/graphics/transparentSurface.cpp | 4 +-- 6 files changed, 29 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 35dde203c7..34638f55e8 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -75,11 +75,11 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::cleanup() { // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) + for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; _singlePaths.clear(); - for (int i = 0; i < _packagePaths.size(); i++) + for (uint32 i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; _packagePaths.clear(); @@ -93,14 +93,14 @@ bool CBFileManager::cleanup() { _files.clear(); // close open files - for (int i = 0; i < _openFiles.size(); i++) { + for (uint32 i = 0; i < _openFiles.size(); i++) { delete _openFiles[i]; } _openFiles.clear(); // delete packages - for (int i = 0; i < _packages.size(); i++) + for (uint32 i = 0; i < _packages.size(); i++) delete _packages[i]; _packages.clear(); @@ -225,7 +225,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 ////////////////////////////////////////////////////////////////////////// bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages - for (int i = 0; i < _packages.size(); i++) { + for (uint32 i = 0; i < _packages.size(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); } @@ -262,11 +262,11 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::reloadPaths() { // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) + for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; _singlePaths.clear(); - for (int i = 0; i < _packagePaths.size(); i++) + for (uint32 i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; _packagePaths.clear(); @@ -378,13 +378,13 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search bool boundToExe = false; if (searchSignature) { - uint32 Offset; - if (!findPackageSignature(package, &Offset)) { + uint32 offset; + if (!findPackageSignature(package, &offset)) { delete package; return STATUS_OK; } else { - package->seek(Offset, SEEK_SET); - absoluteOffset = Offset; + package->seek(offset, SEEK_SET); + absoluteOffset = offset; boundToExe = true; } } @@ -511,7 +511,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _packagePaths.size(); i++) { + for (uint32 i = 0; i < _packagePaths.size(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { @@ -537,7 +537,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { Common::File *ret = NULL; char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _singlePaths.size(); i++) { + for (uint32 i = 0; i < _singlePaths.size(); i++) { sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); ret->open(filename); if (ret->isOpen()) @@ -562,7 +562,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) Common::File f; bool found = false; - for (int i = 0; i < _singlePaths.size(); i++) { + for (uint32 i = 0; i < _singlePaths.size(); i++) { sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); f.open(fullname); if (f.isOpen()) { @@ -632,7 +632,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (int i = 0; i < _openFiles.size(); i++) { + for (uint32 i = 0; i < _openFiles.size(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; _openFiles.remove_at(i); diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp index 8d9b775c68..66baa633e4 100644 --- a/engines/wintermute/base/BSoundMgr.cpp +++ b/engines/wintermute/base/BSoundMgr.cpp @@ -62,7 +62,7 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.size(); i++) + for (uint32 i = 0; i < _sounds.size(); i++) delete _sounds[i]; _sounds.clear(); #if 0 @@ -164,7 +164,7 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; _sounds.remove_at(i); @@ -227,7 +227,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { _sounds[i]->updateVolume(); } return STATUS_OK; @@ -254,7 +254,7 @@ byte CBSoundMgr::getMasterVolume() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::pauseAll(bool includingMusic) { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; @@ -268,7 +268,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::resumeAll() { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->_freezePaused) { _sounds[i]->resume(); _sounds[i]->_freezePaused = false; diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp index 887510b675..406535cf39 100644 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -52,7 +52,7 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::cleanup(bool warn) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } @@ -67,7 +67,7 @@ bool CBSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { @@ -82,7 +82,7 @@ bool CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; if (_surfaces[i]->_referenceCount <= 0) { @@ -98,7 +98,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; @@ -132,7 +132,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::restoreAll() { bool ret; - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp index f2938cebc9..739eafcc73 100644 --- a/engines/wintermute/base/file/BDiskFile.cpp +++ b/engines/wintermute/base/file/BDiskFile.cpp @@ -50,7 +50,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileM uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (int i = 0; i < fileManager->_singlePaths.size(); i++) { + for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); correctSlashes(fullPath); Common::File *tempFile = new Common::File(); diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp index 341f90d559..62576cdfea 100644 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -97,7 +97,7 @@ int CBFontBitmap::getTextWidth(byte *text, int maxLength) { //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; - for (size_t i = 0; i < str.size(); i++) { + for (int i = 0; i < str.size(); i++) { textWidth += getCharWidth(str[i]); } diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index 4c646a6779..cec47ed52f 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -55,10 +55,10 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in const int gShiftTarget = 16;//target.format.gShift; const int rShiftTarget = 24;//target.format.rShift; - for (int i = 0; i < height; i++) { + for (uint32 i = 0; i < height; i++) { out = outo; in = ino; - for (int j = 0; j < width; j++) { + for (uint32 j = 0; j < width; j++) { uint32 pix = *(uint32 *)in; uint32 o_pix = *(uint32 *) out; int b = (pix >> bShift) & 0xff; -- cgit v1.2.3 From b618f7985f33cbb24e36eaf6490ddc59cc148a0a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 03:53:13 +0200 Subject: WINTERMUTE: Decrement tickets when reinserting a ticket that has swapped places. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 12 ++++++++++-- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index fc971357bf..ee971ab6c9 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -352,7 +352,7 @@ void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surfa RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); return; } // Skip rects that are completely outside the screen: @@ -432,6 +432,12 @@ void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { it++; } } + if (it != _renderQueue.end()) { + // Decreement the following tickets. + for (; it != _renderQueue.end(); it++) { + (*it)->_drawNum--; + } + } // Is not in order, so readd it as if it was a new ticket renderTicket->_drawNum = 0; drawFromTicket(renderTicket); @@ -475,8 +481,10 @@ void CBRenderOSystem::drawTickets() { // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); + _drawNum = 1; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { RenderTicket *ticket = *it; + assert(ticket->_drawNum == _drawNum++); if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { // dstClip is the area we want redrawn. Common::Rect dstClip(ticket->_dstRect); @@ -490,7 +498,7 @@ void CBRenderOSystem::drawTickets() { dstClip.translate(-offsetX, -offsetY); _colorMod = ticket->_colorMod; - drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + drawFromSurface(ticket->getSurface(), &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); _needsFlip = true; } // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index d41d14ef35..8a8eb88ede 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -37,11 +37,12 @@ namespace WinterMute { class CBSurfaceOSystem; class RenderTicket { + Graphics::Surface *_surface; public: RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); - Graphics::Surface *_surface; + const Graphics::Surface *getSurface() { return _surface; } Common::Rect _srcRect; Common::Rect _dstRect; uint32 _mirror; -- cgit v1.2.3 From d31b4883a665f962d75e3c96acf47695aa613ed0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 14:24:07 +0200 Subject: WINTERMUTE: Disable ansiToWide for now, as the current implementation was wrong. An odd side-effect was that the script-function SetHoverCursor in AdItem would rename it's filenames from "folder\subfolder\filename.ext" to "folder'subfolder'filename.ext" --- engines/wintermute/utils/StringUtil.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp index c5ad025939..303e7b1131 100644 --- a/engines/wintermute/utils/StringUtil.cpp +++ b/engines/wintermute/utils/StringUtil.cpp @@ -168,11 +168,11 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { hasWarned = true; warning("StringUtil::AnsiToWide - WideString not supported yet"); } - Common::String converted = ""; + /*Common::String converted = ""; uint32 index = 0; while (index != str.size()) { converted += simpleAnsiToWide(str, index); - } + }*/ // using default os locale! /* setlocale(LC_CTYPE, ""); @@ -182,7 +182,7 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { WideString ResultString(wstr); delete [] wstr; return ResultString;*/ - return WideString(converted); + return WideString(str); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 0622b2c5b8260c0f0c01122d6fbc5e10013d1613 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 20:39:21 +0200 Subject: WINTERMUTE: Readd the endian-independence for blitting. --- engines/wintermute/graphics/transparentSurface.cpp | 66 +++++++++++++++------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp index cec47ed52f..a99138ade6 100644 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ b/engines/wintermute/graphics/transparentSurface.cpp @@ -45,16 +45,28 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; - + +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 0; + const int bIndex = 1; + const int gIndex = 2; + const int rIndex = 3; +#else + const int aIndex = 3; + const int bIndex = 2; + const int gIndex = 1; + const int rIndex = 0; +#endif + const int bShift = 8;//img->format.bShift; const int gShift = 16;//img->format.gShift; const int rShift = 24;//img->format.rShift; const int aShift = 0;//img->format.aShift; - + const int bShiftTarget = 8;//target.format.bShift; const int gShiftTarget = 16;//target.format.gShift; const int rShiftTarget = 24;//target.format.rShift; - + for (uint32 i = 0; i < height; i++) { out = outo; in = ino; @@ -67,7 +79,7 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in int a = (pix >> aShift) & 0xff; int o_b, o_g, o_r, o_a; in += inStep; - + /* if (ca != 255) { a = a * ca >> 8; }*/ @@ -82,13 +94,13 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in o_r = r; o_a = a; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[0] = o_a; - out[1] = o_b; - out[2] = o_g; - out[3] = o_r; + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; out += 4; break; - + default: // alpha blending o_a = 255; o_b = (o_pix >> bShiftTarget) & 0xff; @@ -98,10 +110,10 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in o_g += ((g - o_g) * a) >> 8; o_r += ((r - o_r) * a) >> 8; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[0] = o_a; - out[1] = o_b; - out[2] = o_g; - out[3] = o_r; + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; out += 4; } } @@ -213,6 +225,18 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p byte *outo = (byte *)target.getBasePtr(posX, posY); byte *in, *out; +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 0; + const int bIndex = 1; + const int gIndex = 2; + const int rIndex = 3; +#else + const int aIndex = 3; + const int bIndex = 2; + const int gIndex = 1; + const int rIndex = 0; +#endif + const int bShift = 8;//img->format.bShift; const int gShift = 16;//img->format.gShift; const int rShift = 24;//img->format.rShift; @@ -263,10 +287,10 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p o_r = r; o_a = a; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[0] = o_a; - out[1] = o_b; - out[2] = o_g; - out[3] = o_r; + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; out += 4; break; @@ -294,10 +318,10 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p else o_r += ((r - o_r) * a) >> 8; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[0] = o_a; - out[1] = o_b; - out[2] = o_g; - out[3] = o_r; + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; out += 4; } } -- cgit v1.2.3 From 5683f076331d2831eb4720b65bb53e8d01ca33ee Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 18:19:07 +0200 Subject: WINTERMUTE: Rename CamelCased filenames to prefixed_under_score-filenames This is mostly a lead-up to namespacing the Ad/Base folders, and then possibly removing the prefixes from the files, it also has the added benefit of getting rid of the odd case-typos that makes for issues on platforms that don't ignore case. --- engines/wintermute/ad/AdActor.cpp | 1316 ------ engines/wintermute/ad/AdActor.h | 107 - engines/wintermute/ad/AdEntity.cpp | 1027 ----- engines/wintermute/ad/AdEntity.h | 68 - engines/wintermute/ad/AdGame.cpp | 2061 --------- engines/wintermute/ad/AdGame.h | 161 - engines/wintermute/ad/AdInventory.cpp | 119 - engines/wintermute/ad/AdInventory.h | 52 - engines/wintermute/ad/AdInventoryBox.cpp | 372 -- engines/wintermute/ad/AdInventoryBox.h | 64 - engines/wintermute/ad/AdItem.cpp | 760 ---- engines/wintermute/ad/AdItem.h | 70 - engines/wintermute/ad/AdLayer.cpp | 537 --- engines/wintermute/ad/AdLayer.h | 58 - engines/wintermute/ad/AdNodeState.cpp | 169 - engines/wintermute/ad/AdNodeState.h | 58 - engines/wintermute/ad/AdObject.cpp | 1203 ------ engines/wintermute/ad/AdObject.h | 123 - engines/wintermute/ad/AdPath.cpp | 112 - engines/wintermute/ad/AdPath.h | 56 - engines/wintermute/ad/AdPathPoint.cpp | 75 - engines/wintermute/ad/AdPathPoint.h | 50 - engines/wintermute/ad/AdRegion.cpp | 392 -- engines/wintermute/ad/AdRegion.h | 58 - engines/wintermute/ad/AdResponse.cpp | 143 - engines/wintermute/ad/AdResponse.h | 61 - engines/wintermute/ad/AdResponseBox.cpp | 647 --- engines/wintermute/ad/AdResponseBox.h | 87 - engines/wintermute/ad/AdResponseContext.cpp | 70 - engines/wintermute/ad/AdResponseContext.h | 50 - engines/wintermute/ad/AdRotLevel.cpp | 159 - engines/wintermute/ad/AdRotLevel.h | 49 - engines/wintermute/ad/AdScaleLevel.cpp | 157 - engines/wintermute/ad/AdScaleLevel.h | 50 - engines/wintermute/ad/AdScene.cpp | 2752 ------------ engines/wintermute/ad/AdScene.h | 181 - engines/wintermute/ad/AdSceneNode.cpp | 83 - engines/wintermute/ad/AdSceneNode.h | 54 - engines/wintermute/ad/AdSceneState.cpp | 88 - engines/wintermute/ad/AdSceneState.h | 51 - engines/wintermute/ad/AdSentence.cpp | 317 -- engines/wintermute/ad/AdSentence.h | 85 - engines/wintermute/ad/AdSpriteSet.cpp | 312 -- engines/wintermute/ad/AdSpriteSet.h | 54 - engines/wintermute/ad/AdTalkDef.cpp | 260 -- engines/wintermute/ad/AdTalkDef.h | 58 - engines/wintermute/ad/AdTalkHolder.cpp | 366 -- engines/wintermute/ad/AdTalkHolder.h | 57 - engines/wintermute/ad/AdTalkNode.cpp | 266 -- engines/wintermute/ad/AdTalkNode.h | 63 - engines/wintermute/ad/AdTypes.h | 107 - engines/wintermute/ad/AdWaypointGroup.cpp | 261 -- engines/wintermute/ad/AdWaypointGroup.h | 58 - engines/wintermute/ad/ad_actor.cpp | 1316 ++++++ engines/wintermute/ad/ad_actor.h | 107 + engines/wintermute/ad/ad_entity.cpp | 1027 +++++ engines/wintermute/ad/ad_entity.h | 68 + engines/wintermute/ad/ad_game.cpp | 2061 +++++++++ engines/wintermute/ad/ad_game.h | 161 + engines/wintermute/ad/ad_inventory.cpp | 119 + engines/wintermute/ad/ad_inventory.h | 52 + engines/wintermute/ad/ad_inventory_box.cpp | 372 ++ engines/wintermute/ad/ad_inventory_box.h | 64 + engines/wintermute/ad/ad_item.cpp | 760 ++++ engines/wintermute/ad/ad_item.h | 70 + engines/wintermute/ad/ad_layer.cpp | 537 +++ engines/wintermute/ad/ad_layer.h | 58 + engines/wintermute/ad/ad_node_state.cpp | 169 + engines/wintermute/ad/ad_node_state.h | 58 + engines/wintermute/ad/ad_object.cpp | 1203 ++++++ engines/wintermute/ad/ad_object.h | 123 + engines/wintermute/ad/ad_path.cpp | 112 + engines/wintermute/ad/ad_path.h | 56 + engines/wintermute/ad/ad_path_point.cpp | 75 + engines/wintermute/ad/ad_path_point.h | 50 + engines/wintermute/ad/ad_region.cpp | 392 ++ engines/wintermute/ad/ad_region.h | 58 + engines/wintermute/ad/ad_response.cpp | 143 + engines/wintermute/ad/ad_response.h | 61 + engines/wintermute/ad/ad_response_box.cpp | 647 +++ engines/wintermute/ad/ad_response_box.h | 87 + engines/wintermute/ad/ad_response_context.cpp | 70 + engines/wintermute/ad/ad_response_context.h | 50 + engines/wintermute/ad/ad_rot_level.cpp | 159 + engines/wintermute/ad/ad_rot_level.h | 49 + engines/wintermute/ad/ad_scale_level.cpp | 157 + engines/wintermute/ad/ad_scale_level.h | 50 + engines/wintermute/ad/ad_scene.cpp | 2752 ++++++++++++ engines/wintermute/ad/ad_scene.h | 181 + engines/wintermute/ad/ad_scene_node.cpp | 83 + engines/wintermute/ad/ad_scene_node.h | 54 + engines/wintermute/ad/ad_scene_state.cpp | 88 + engines/wintermute/ad/ad_scene_state.h | 51 + engines/wintermute/ad/ad_sentence.cpp | 317 ++ engines/wintermute/ad/ad_sentence.h | 85 + engines/wintermute/ad/ad_sprite_set.cpp | 312 ++ engines/wintermute/ad/ad_sprite_set.h | 54 + engines/wintermute/ad/ad_talk_def.cpp | 260 ++ engines/wintermute/ad/ad_talk_def.h | 58 + engines/wintermute/ad/ad_talk_holder.cpp | 366 ++ engines/wintermute/ad/ad_talk_holder.h | 57 + engines/wintermute/ad/ad_talk_node.cpp | 266 ++ engines/wintermute/ad/ad_talk_node.h | 63 + engines/wintermute/ad/ad_types.h | 107 + engines/wintermute/ad/ad_waypoint_group.cpp | 261 ++ engines/wintermute/ad/ad_waypoint_group.h | 58 + engines/wintermute/base/BActiveRect.cpp | 107 - engines/wintermute/base/BActiveRect.h | 60 - engines/wintermute/base/BBase.cpp | 178 - engines/wintermute/base/BBase.h | 64 - engines/wintermute/base/BDebugger.cpp | 203 - engines/wintermute/base/BDebugger.h | 95 - engines/wintermute/base/BDynBuffer.cpp | 192 - engines/wintermute/base/BDynBuffer.h | 66 - engines/wintermute/base/BFader.cpp | 176 - engines/wintermute/base/BFader.h | 62 - engines/wintermute/base/BFileManager.cpp | 737 ---- engines/wintermute/base/BFileManager.h | 85 - engines/wintermute/base/BFrame.cpp | 705 --- engines/wintermute/base/BFrame.h | 73 - engines/wintermute/base/BGame.cpp | 4478 -------------------- engines/wintermute/base/BGame.h | 391 -- engines/wintermute/base/BKeyboardState.cpp | 304 -- engines/wintermute/base/BKeyboardState.h | 75 - engines/wintermute/base/BNamedObject.cpp | 65 - engines/wintermute/base/BNamedObject.h | 50 - engines/wintermute/base/BObject.cpp | 1128 ----- engines/wintermute/base/BObject.h | 144 - engines/wintermute/base/BParser.cpp | 436 -- engines/wintermute/base/BParser.h | 89 - engines/wintermute/base/BPersistMgr.cpp | 778 ---- engines/wintermute/base/BPersistMgr.h | 114 - engines/wintermute/base/BPoint.cpp | 64 - engines/wintermute/base/BPoint.h | 50 - engines/wintermute/base/BQuickMsg.cpp | 54 - engines/wintermute/base/BQuickMsg.h | 48 - engines/wintermute/base/BRegion.cpp | 508 --- engines/wintermute/base/BRegion.h | 68 - engines/wintermute/base/BRegistry.cpp | 257 -- engines/wintermute/base/BRegistry.h | 76 - engines/wintermute/base/BResources.cpp | 2820 ------------ engines/wintermute/base/BResources.h | 44 - engines/wintermute/base/BSaveThumbHelper.cpp | 79 - engines/wintermute/base/BSaveThumbHelper.h | 50 - engines/wintermute/base/BScriptHolder.cpp | 473 --- engines/wintermute/base/BScriptHolder.h | 74 - engines/wintermute/base/BScriptable.cpp | 188 - engines/wintermute/base/BScriptable.h | 90 - engines/wintermute/base/BSound.cpp | 288 -- engines/wintermute/base/BSound.h | 88 - engines/wintermute/base/BSoundBuffer.cpp | 383 -- engines/wintermute/base/BSoundBuffer.h | 100 - engines/wintermute/base/BSoundMgr.cpp | 292 -- engines/wintermute/base/BSoundMgr.h | 69 - engines/wintermute/base/BSprite.cpp | 758 ---- engines/wintermute/base/BSprite.h | 90 - engines/wintermute/base/BStringTable.cpp | 229 - engines/wintermute/base/BStringTable.h | 55 - engines/wintermute/base/BSubFrame.cpp | 589 --- engines/wintermute/base/BSubFrame.h | 86 - engines/wintermute/base/BSurfaceStorage.cpp | 189 - engines/wintermute/base/BSurfaceStorage.h | 57 - engines/wintermute/base/BTransitionMgr.cpp | 131 - engines/wintermute/base/BTransitionMgr.h | 54 - engines/wintermute/base/BViewport.cpp | 98 - engines/wintermute/base/BViewport.h | 55 - engines/wintermute/base/base.cpp | 178 + engines/wintermute/base/base.h | 64 + engines/wintermute/base/base_active_rect.cpp | 107 + engines/wintermute/base/base_active_rect.h | 60 + engines/wintermute/base/base_debugger.cpp | 203 + engines/wintermute/base/base_debugger.h | 95 + engines/wintermute/base/base_dynamic_buffer.cpp | 192 + engines/wintermute/base/base_dynamic_buffer.h | 66 + engines/wintermute/base/base_fader.cpp | 176 + engines/wintermute/base/base_fader.h | 62 + engines/wintermute/base/base_file_manager.cpp | 737 ++++ engines/wintermute/base/base_file_manager.h | 85 + engines/wintermute/base/base_frame.cpp | 705 +++ engines/wintermute/base/base_frame.h | 73 + engines/wintermute/base/base_game.cpp | 4477 +++++++++++++++++++ engines/wintermute/base/base_game.h | 391 ++ engines/wintermute/base/base_keyboard_state.cpp | 304 ++ engines/wintermute/base/base_keyboard_state.h | 75 + engines/wintermute/base/base_named_object.cpp | 65 + engines/wintermute/base/base_named_object.h | 50 + engines/wintermute/base/base_object.cpp | 1128 +++++ engines/wintermute/base/base_object.h | 144 + engines/wintermute/base/base_parser.cpp | 436 ++ engines/wintermute/base/base_parser.h | 89 + .../wintermute/base/base_persistence_manager.cpp | 778 ++++ engines/wintermute/base/base_persistence_manager.h | 114 + engines/wintermute/base/base_point.cpp | 64 + engines/wintermute/base/base_point.h | 50 + engines/wintermute/base/base_quick_msg.cpp | 54 + engines/wintermute/base/base_quick_msg.h | 48 + engines/wintermute/base/base_region.cpp | 508 +++ engines/wintermute/base/base_region.h | 68 + engines/wintermute/base/base_registry.cpp | 257 ++ engines/wintermute/base/base_registry.h | 76 + engines/wintermute/base/base_save_thumb_helper.cpp | 79 + engines/wintermute/base/base_save_thumb_helper.h | 50 + engines/wintermute/base/base_script_holder.cpp | 473 +++ engines/wintermute/base/base_script_holder.h | 74 + engines/wintermute/base/base_scriptable.cpp | 188 + engines/wintermute/base/base_scriptable.h | 90 + engines/wintermute/base/base_sprite.cpp | 758 ++++ engines/wintermute/base/base_sprite.h | 90 + engines/wintermute/base/base_string_table.cpp | 229 + engines/wintermute/base/base_string_table.h | 55 + engines/wintermute/base/base_sub_frame.cpp | 589 +++ engines/wintermute/base/base_sub_frame.h | 86 + engines/wintermute/base/base_surface_storage.cpp | 189 + engines/wintermute/base/base_surface_storage.h | 57 + .../wintermute/base/base_transition_manager.cpp | 131 + engines/wintermute/base/base_transition_manager.h | 54 + engines/wintermute/base/base_viewport.cpp | 98 + engines/wintermute/base/base_viewport.h | 55 + engines/wintermute/base/file/BDiskFile.cpp | 131 - engines/wintermute/base/file/BDiskFile.h | 42 - engines/wintermute/base/file/BFile.cpp | 69 - engines/wintermute/base/file/BFile.h | 67 - engines/wintermute/base/file/BFileEntry.cpp | 50 - engines/wintermute/base/file/BFileEntry.h | 57 - engines/wintermute/base/file/BPackage.cpp | 104 - engines/wintermute/base/file/BPackage.h | 61 - engines/wintermute/base/file/BPkgFile.cpp | 6 +- engines/wintermute/base/file/BPkgFile.h | 5 +- engines/wintermute/base/file/BSaveThumbFile.cpp | 146 - engines/wintermute/base/file/BSaveThumbFile.h | 52 - engines/wintermute/base/file/base_disk_file.cpp | 131 + engines/wintermute/base/file/base_disk_file.h | 42 + engines/wintermute/base/file/base_file.cpp | 69 + engines/wintermute/base/file/base_file.h | 67 + engines/wintermute/base/file/base_file_entry.cpp | 50 + engines/wintermute/base/file/base_file_entry.h | 57 + engines/wintermute/base/file/base_package.cpp | 104 + engines/wintermute/base/file/base_package.h | 61 + engines/wintermute/base/file/base_resources.cpp | 2820 ++++++++++++ engines/wintermute/base/file/base_resources.h | 44 + .../wintermute/base/file/base_save_thumb_file.cpp | 146 + .../wintermute/base/file/base_save_thumb_file.h | 52 + engines/wintermute/base/font/BFont.cpp | 206 - engines/wintermute/base/font/BFont.h | 61 - engines/wintermute/base/font/BFontBitmap.cpp | 540 --- engines/wintermute/base/font/BFontBitmap.h | 72 - engines/wintermute/base/font/BFontStorage.cpp | 135 - engines/wintermute/base/font/BFontStorage.h | 55 - engines/wintermute/base/font/BFontTT.cpp | 762 ---- engines/wintermute/base/font/BFontTT.h | 180 - engines/wintermute/base/font/base_font.cpp | 206 + engines/wintermute/base/font/base_font.h | 61 + engines/wintermute/base/font/base_font_bitmap.cpp | 540 +++ engines/wintermute/base/font/base_font_bitmap.h | 72 + engines/wintermute/base/font/base_font_storage.cpp | 135 + engines/wintermute/base/font/base_font_storage.h | 55 + .../wintermute/base/font/base_font_truetype.cpp | 762 ++++ engines/wintermute/base/font/base_font_truetype.h | 180 + engines/wintermute/base/gfx/base_image.cpp | 8 +- engines/wintermute/base/gfx/base_image.h | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 6 +- engines/wintermute/base/gfx/base_renderer.h | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/gfx/base_surface.h | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 12 +- .../base/gfx/osystem/base_surface_osystem.cpp | 8 +- engines/wintermute/base/particles/PartEmitter.cpp | 1199 ------ engines/wintermute/base/particles/PartEmitter.h | 139 - engines/wintermute/base/particles/PartForce.cpp | 59 - engines/wintermute/base/particles/PartForce.h | 57 - engines/wintermute/base/particles/PartParticle.cpp | 257 -- engines/wintermute/base/particles/PartParticle.h | 90 - engines/wintermute/base/particles/part_emitter.cpp | 1199 ++++++ engines/wintermute/base/particles/part_emitter.h | 139 + engines/wintermute/base/particles/part_force.cpp | 59 + engines/wintermute/base/particles/part_force.h | 57 + .../wintermute/base/particles/part_particle.cpp | 257 ++ engines/wintermute/base/particles/part_particle.h | 90 + engines/wintermute/base/scriptables/SXArray.cpp | 238 -- engines/wintermute/base/scriptables/SXArray.h | 54 - engines/wintermute/base/scriptables/SXDate.cpp | 297 -- engines/wintermute/base/scriptables/SXDate.h | 55 - engines/wintermute/base/scriptables/SXFile.cpp | 779 ---- engines/wintermute/base/scriptables/SXFile.h | 66 - engines/wintermute/base/scriptables/SXMath.cpp | 295 -- engines/wintermute/base/scriptables/SXMath.h | 53 - .../wintermute/base/scriptables/SXMemBuffer.cpp | 508 --- engines/wintermute/base/scriptables/SXMemBuffer.h | 59 - engines/wintermute/base/scriptables/SXString.cpp | 404 -- engines/wintermute/base/scriptables/SXString.h | 58 - engines/wintermute/base/scriptables/ScEngine.cpp | 712 ---- engines/wintermute/base/scriptables/ScEngine.h | 147 - engines/wintermute/base/scriptables/ScScript.cpp | 1461 ------- engines/wintermute/base/scriptables/ScScript.h | 183 - engines/wintermute/base/scriptables/ScStack.cpp | 226 - engines/wintermute/base/scriptables/ScStack.h | 66 - engines/wintermute/base/scriptables/ScValue.cpp | 1054 ----- engines/wintermute/base/scriptables/ScValue.h | 141 - engines/wintermute/base/scriptables/SxObject.cpp | 67 - engines/wintermute/base/scriptables/SxObject.h | 47 - engines/wintermute/base/scriptables/script.cpp | 1461 +++++++ engines/wintermute/base/scriptables/script.h | 183 + .../wintermute/base/scriptables/script_engine.cpp | 712 ++++ .../wintermute/base/scriptables/script_engine.h | 147 + .../base/scriptables/script_ext_array.cpp | 238 ++ .../wintermute/base/scriptables/script_ext_array.h | 54 + .../base/scriptables/script_ext_date.cpp | 297 ++ .../wintermute/base/scriptables/script_ext_date.h | 55 + .../base/scriptables/script_ext_file.cpp | 779 ++++ .../wintermute/base/scriptables/script_ext_file.h | 66 + .../base/scriptables/script_ext_math.cpp | 295 ++ .../wintermute/base/scriptables/script_ext_math.h | 53 + .../base/scriptables/script_ext_mem_buffer.cpp | 508 +++ .../base/scriptables/script_ext_mem_buffer.h | 59 + .../base/scriptables/script_ext_object.cpp | 67 + .../base/scriptables/script_ext_object.h | 47 + .../base/scriptables/script_ext_string.cpp | 404 ++ .../base/scriptables/script_ext_string.h | 58 + .../wintermute/base/scriptables/script_stack.cpp | 226 + engines/wintermute/base/scriptables/script_stack.h | 66 + .../wintermute/base/scriptables/script_value.cpp | 1054 +++++ engines/wintermute/base/scriptables/script_value.h | 141 + engines/wintermute/base/sound/base_sound.cpp | 288 ++ engines/wintermute/base/sound/base_sound.h | 88 + .../wintermute/base/sound/base_sound_buffer.cpp | 383 ++ engines/wintermute/base/sound/base_sound_buffer.h | 100 + .../wintermute/base/sound/base_sound_manager.cpp | 292 ++ engines/wintermute/base/sound/base_sound_manager.h | 69 + engines/wintermute/coll_templ.h | 4 +- engines/wintermute/detection.cpp | 2 +- engines/wintermute/graphics/transparentSurface.cpp | 427 -- engines/wintermute/graphics/transparentSurface.h | 124 - .../wintermute/graphics/transparent_surface.cpp | 427 ++ engines/wintermute/graphics/transparent_surface.h | 124 + engines/wintermute/math/MathUtil.cpp | 48 - engines/wintermute/math/MathUtil.h | 42 - engines/wintermute/math/Matrix4.cpp | 86 - engines/wintermute/math/Matrix4.h | 59 - engines/wintermute/math/Rect32.h | 86 - engines/wintermute/math/Vector2.cpp | 55 - engines/wintermute/math/Vector2.h | 75 - engines/wintermute/math/math_util.cpp | 48 + engines/wintermute/math/math_util.h | 42 + engines/wintermute/math/matrix4.cpp | 86 + engines/wintermute/math/matrix4.h | 59 + engines/wintermute/math/rect32.h | 86 + engines/wintermute/math/vector2.cpp | 55 + engines/wintermute/math/vector2.h | 75 + engines/wintermute/module.mk | 196 +- engines/wintermute/persistent.cpp | 122 +- engines/wintermute/persistent.h | 2 +- engines/wintermute/platform_osystem.cpp | 10 +- engines/wintermute/platform_osystem.h | 2 +- engines/wintermute/system/SysClass.cpp | 211 - engines/wintermute/system/SysClass.h | 130 - engines/wintermute/system/SysClassRegistry.cpp | 315 -- engines/wintermute/system/SysClassRegistry.h | 107 - engines/wintermute/system/SysInstance.cpp | 49 - engines/wintermute/system/SysInstance.h | 68 - engines/wintermute/system/sys_class.cpp | 211 + engines/wintermute/system/sys_class.h | 130 + engines/wintermute/system/sys_class_registry.cpp | 315 ++ engines/wintermute/system/sys_class_registry.h | 107 + engines/wintermute/system/sys_instance.cpp | 49 + engines/wintermute/system/sys_instance.h | 68 + engines/wintermute/ui/UIButton.cpp | 1046 ----- engines/wintermute/ui/UIButton.h | 79 - engines/wintermute/ui/UIEdit.cpp | 857 ---- engines/wintermute/ui/UIEdit.h | 72 - engines/wintermute/ui/UIEntity.cpp | 339 -- engines/wintermute/ui/UIEntity.h | 58 - engines/wintermute/ui/UIObject.cpp | 589 --- engines/wintermute/ui/UIObject.h | 83 - engines/wintermute/ui/UIText.cpp | 489 --- engines/wintermute/ui/UIText.h | 60 - engines/wintermute/ui/UITiledImage.cpp | 370 -- engines/wintermute/ui/UITiledImage.h | 63 - engines/wintermute/ui/UIWindow.cpp | 1327 ------ engines/wintermute/ui/UIWindow.h | 93 - engines/wintermute/ui/ui_button.cpp | 1046 +++++ engines/wintermute/ui/ui_button.h | 79 + engines/wintermute/ui/ui_edit.cpp | 857 ++++ engines/wintermute/ui/ui_edit.h | 72 + engines/wintermute/ui/ui_entity.cpp | 339 ++ engines/wintermute/ui/ui_entity.h | 58 + engines/wintermute/ui/ui_object.cpp | 589 +++ engines/wintermute/ui/ui_object.h | 83 + engines/wintermute/ui/ui_text.cpp | 489 +++ engines/wintermute/ui/ui_text.h | 60 + engines/wintermute/ui/ui_tiled_image.cpp | 370 ++ engines/wintermute/ui/ui_tiled_image.h | 63 + engines/wintermute/ui/ui_window.cpp | 1327 ++++++ engines/wintermute/ui/ui_window.h | 93 + engines/wintermute/utils/ConvertUTF.cpp | 612 --- engines/wintermute/utils/ConvertUTF.h | 149 - engines/wintermute/utils/PathUtil.cpp | 196 - engines/wintermute/utils/PathUtil.h | 56 - engines/wintermute/utils/StringUtil.cpp | 381 -- engines/wintermute/utils/StringUtil.h | 66 - engines/wintermute/utils/convert_utf.cpp | 612 +++ engines/wintermute/utils/convert_utf.h | 149 + engines/wintermute/utils/crc.cpp | 2 +- engines/wintermute/utils/path_util.cpp | 196 + engines/wintermute/utils/path_util.h | 56 + engines/wintermute/utils/string_util.cpp | 381 ++ engines/wintermute/utils/string_util.h | 66 + engines/wintermute/utils/utils.cpp | 6 +- engines/wintermute/utils/utils.h | 2 +- engines/wintermute/video/VidPlayer.cpp | 470 -- engines/wintermute/video/VidPlayer.h | 93 - engines/wintermute/video/VidTheoraPlayer.cpp | 850 ---- engines/wintermute/video/VidTheoraPlayer.h | 151 - engines/wintermute/video/video_player.cpp | 470 ++ engines/wintermute/video/video_player.h | 93 + engines/wintermute/video/video_theora_player.cpp | 850 ++++ engines/wintermute/video/video_theora_player.h | 151 + engines/wintermute/wintermute.cpp | 8 +- 417 files changed, 57622 insertions(+), 57618 deletions(-) delete mode 100644 engines/wintermute/ad/AdActor.cpp delete mode 100644 engines/wintermute/ad/AdActor.h delete mode 100644 engines/wintermute/ad/AdEntity.cpp delete mode 100644 engines/wintermute/ad/AdEntity.h delete mode 100644 engines/wintermute/ad/AdGame.cpp delete mode 100644 engines/wintermute/ad/AdGame.h delete mode 100644 engines/wintermute/ad/AdInventory.cpp delete mode 100644 engines/wintermute/ad/AdInventory.h delete mode 100644 engines/wintermute/ad/AdInventoryBox.cpp delete mode 100644 engines/wintermute/ad/AdInventoryBox.h delete mode 100644 engines/wintermute/ad/AdItem.cpp delete mode 100644 engines/wintermute/ad/AdItem.h delete mode 100644 engines/wintermute/ad/AdLayer.cpp delete mode 100644 engines/wintermute/ad/AdLayer.h delete mode 100644 engines/wintermute/ad/AdNodeState.cpp delete mode 100644 engines/wintermute/ad/AdNodeState.h delete mode 100644 engines/wintermute/ad/AdObject.cpp delete mode 100644 engines/wintermute/ad/AdObject.h delete mode 100644 engines/wintermute/ad/AdPath.cpp delete mode 100644 engines/wintermute/ad/AdPath.h delete mode 100644 engines/wintermute/ad/AdPathPoint.cpp delete mode 100644 engines/wintermute/ad/AdPathPoint.h delete mode 100644 engines/wintermute/ad/AdRegion.cpp delete mode 100644 engines/wintermute/ad/AdRegion.h delete mode 100644 engines/wintermute/ad/AdResponse.cpp delete mode 100644 engines/wintermute/ad/AdResponse.h delete mode 100644 engines/wintermute/ad/AdResponseBox.cpp delete mode 100644 engines/wintermute/ad/AdResponseBox.h delete mode 100644 engines/wintermute/ad/AdResponseContext.cpp delete mode 100644 engines/wintermute/ad/AdResponseContext.h delete mode 100644 engines/wintermute/ad/AdRotLevel.cpp delete mode 100644 engines/wintermute/ad/AdRotLevel.h delete mode 100644 engines/wintermute/ad/AdScaleLevel.cpp delete mode 100644 engines/wintermute/ad/AdScaleLevel.h delete mode 100644 engines/wintermute/ad/AdScene.cpp delete mode 100644 engines/wintermute/ad/AdScene.h delete mode 100644 engines/wintermute/ad/AdSceneNode.cpp delete mode 100644 engines/wintermute/ad/AdSceneNode.h delete mode 100644 engines/wintermute/ad/AdSceneState.cpp delete mode 100644 engines/wintermute/ad/AdSceneState.h delete mode 100644 engines/wintermute/ad/AdSentence.cpp delete mode 100644 engines/wintermute/ad/AdSentence.h delete mode 100644 engines/wintermute/ad/AdSpriteSet.cpp delete mode 100644 engines/wintermute/ad/AdSpriteSet.h delete mode 100644 engines/wintermute/ad/AdTalkDef.cpp delete mode 100644 engines/wintermute/ad/AdTalkDef.h delete mode 100644 engines/wintermute/ad/AdTalkHolder.cpp delete mode 100644 engines/wintermute/ad/AdTalkHolder.h delete mode 100644 engines/wintermute/ad/AdTalkNode.cpp delete mode 100644 engines/wintermute/ad/AdTalkNode.h delete mode 100644 engines/wintermute/ad/AdTypes.h delete mode 100644 engines/wintermute/ad/AdWaypointGroup.cpp delete mode 100644 engines/wintermute/ad/AdWaypointGroup.h create mode 100644 engines/wintermute/ad/ad_actor.cpp create mode 100644 engines/wintermute/ad/ad_actor.h create mode 100644 engines/wintermute/ad/ad_entity.cpp create mode 100644 engines/wintermute/ad/ad_entity.h create mode 100644 engines/wintermute/ad/ad_game.cpp create mode 100644 engines/wintermute/ad/ad_game.h create mode 100644 engines/wintermute/ad/ad_inventory.cpp create mode 100644 engines/wintermute/ad/ad_inventory.h create mode 100644 engines/wintermute/ad/ad_inventory_box.cpp create mode 100644 engines/wintermute/ad/ad_inventory_box.h create mode 100644 engines/wintermute/ad/ad_item.cpp create mode 100644 engines/wintermute/ad/ad_item.h create mode 100644 engines/wintermute/ad/ad_layer.cpp create mode 100644 engines/wintermute/ad/ad_layer.h create mode 100644 engines/wintermute/ad/ad_node_state.cpp create mode 100644 engines/wintermute/ad/ad_node_state.h create mode 100644 engines/wintermute/ad/ad_object.cpp create mode 100644 engines/wintermute/ad/ad_object.h create mode 100644 engines/wintermute/ad/ad_path.cpp create mode 100644 engines/wintermute/ad/ad_path.h create mode 100644 engines/wintermute/ad/ad_path_point.cpp create mode 100644 engines/wintermute/ad/ad_path_point.h create mode 100644 engines/wintermute/ad/ad_region.cpp create mode 100644 engines/wintermute/ad/ad_region.h create mode 100644 engines/wintermute/ad/ad_response.cpp create mode 100644 engines/wintermute/ad/ad_response.h create mode 100644 engines/wintermute/ad/ad_response_box.cpp create mode 100644 engines/wintermute/ad/ad_response_box.h create mode 100644 engines/wintermute/ad/ad_response_context.cpp create mode 100644 engines/wintermute/ad/ad_response_context.h create mode 100644 engines/wintermute/ad/ad_rot_level.cpp create mode 100644 engines/wintermute/ad/ad_rot_level.h create mode 100644 engines/wintermute/ad/ad_scale_level.cpp create mode 100644 engines/wintermute/ad/ad_scale_level.h create mode 100644 engines/wintermute/ad/ad_scene.cpp create mode 100644 engines/wintermute/ad/ad_scene.h create mode 100644 engines/wintermute/ad/ad_scene_node.cpp create mode 100644 engines/wintermute/ad/ad_scene_node.h create mode 100644 engines/wintermute/ad/ad_scene_state.cpp create mode 100644 engines/wintermute/ad/ad_scene_state.h create mode 100644 engines/wintermute/ad/ad_sentence.cpp create mode 100644 engines/wintermute/ad/ad_sentence.h create mode 100644 engines/wintermute/ad/ad_sprite_set.cpp create mode 100644 engines/wintermute/ad/ad_sprite_set.h create mode 100644 engines/wintermute/ad/ad_talk_def.cpp create mode 100644 engines/wintermute/ad/ad_talk_def.h create mode 100644 engines/wintermute/ad/ad_talk_holder.cpp create mode 100644 engines/wintermute/ad/ad_talk_holder.h create mode 100644 engines/wintermute/ad/ad_talk_node.cpp create mode 100644 engines/wintermute/ad/ad_talk_node.h create mode 100644 engines/wintermute/ad/ad_types.h create mode 100644 engines/wintermute/ad/ad_waypoint_group.cpp create mode 100644 engines/wintermute/ad/ad_waypoint_group.h delete mode 100644 engines/wintermute/base/BActiveRect.cpp delete mode 100644 engines/wintermute/base/BActiveRect.h delete mode 100644 engines/wintermute/base/BBase.cpp delete mode 100644 engines/wintermute/base/BBase.h delete mode 100644 engines/wintermute/base/BDebugger.cpp delete mode 100644 engines/wintermute/base/BDebugger.h delete mode 100644 engines/wintermute/base/BDynBuffer.cpp delete mode 100644 engines/wintermute/base/BDynBuffer.h delete mode 100644 engines/wintermute/base/BFader.cpp delete mode 100644 engines/wintermute/base/BFader.h delete mode 100644 engines/wintermute/base/BFileManager.cpp delete mode 100644 engines/wintermute/base/BFileManager.h delete mode 100644 engines/wintermute/base/BFrame.cpp delete mode 100644 engines/wintermute/base/BFrame.h delete mode 100644 engines/wintermute/base/BGame.cpp delete mode 100644 engines/wintermute/base/BGame.h delete mode 100644 engines/wintermute/base/BKeyboardState.cpp delete mode 100644 engines/wintermute/base/BKeyboardState.h delete mode 100644 engines/wintermute/base/BNamedObject.cpp delete mode 100644 engines/wintermute/base/BNamedObject.h delete mode 100644 engines/wintermute/base/BObject.cpp delete mode 100644 engines/wintermute/base/BObject.h delete mode 100644 engines/wintermute/base/BParser.cpp delete mode 100644 engines/wintermute/base/BParser.h delete mode 100644 engines/wintermute/base/BPersistMgr.cpp delete mode 100644 engines/wintermute/base/BPersistMgr.h delete mode 100644 engines/wintermute/base/BPoint.cpp delete mode 100644 engines/wintermute/base/BPoint.h delete mode 100644 engines/wintermute/base/BQuickMsg.cpp delete mode 100644 engines/wintermute/base/BQuickMsg.h delete mode 100644 engines/wintermute/base/BRegion.cpp delete mode 100644 engines/wintermute/base/BRegion.h delete mode 100644 engines/wintermute/base/BRegistry.cpp delete mode 100644 engines/wintermute/base/BRegistry.h delete mode 100644 engines/wintermute/base/BResources.cpp delete mode 100644 engines/wintermute/base/BResources.h delete mode 100644 engines/wintermute/base/BSaveThumbHelper.cpp delete mode 100644 engines/wintermute/base/BSaveThumbHelper.h delete mode 100644 engines/wintermute/base/BScriptHolder.cpp delete mode 100644 engines/wintermute/base/BScriptHolder.h delete mode 100644 engines/wintermute/base/BScriptable.cpp delete mode 100644 engines/wintermute/base/BScriptable.h delete mode 100644 engines/wintermute/base/BSound.cpp delete mode 100644 engines/wintermute/base/BSound.h delete mode 100644 engines/wintermute/base/BSoundBuffer.cpp delete mode 100644 engines/wintermute/base/BSoundBuffer.h delete mode 100644 engines/wintermute/base/BSoundMgr.cpp delete mode 100644 engines/wintermute/base/BSoundMgr.h delete mode 100644 engines/wintermute/base/BSprite.cpp delete mode 100644 engines/wintermute/base/BSprite.h delete mode 100644 engines/wintermute/base/BStringTable.cpp delete mode 100644 engines/wintermute/base/BStringTable.h delete mode 100644 engines/wintermute/base/BSubFrame.cpp delete mode 100644 engines/wintermute/base/BSubFrame.h delete mode 100644 engines/wintermute/base/BSurfaceStorage.cpp delete mode 100644 engines/wintermute/base/BSurfaceStorage.h delete mode 100644 engines/wintermute/base/BTransitionMgr.cpp delete mode 100644 engines/wintermute/base/BTransitionMgr.h delete mode 100644 engines/wintermute/base/BViewport.cpp delete mode 100644 engines/wintermute/base/BViewport.h create mode 100644 engines/wintermute/base/base.cpp create mode 100644 engines/wintermute/base/base.h create mode 100644 engines/wintermute/base/base_active_rect.cpp create mode 100644 engines/wintermute/base/base_active_rect.h create mode 100644 engines/wintermute/base/base_debugger.cpp create mode 100644 engines/wintermute/base/base_debugger.h create mode 100644 engines/wintermute/base/base_dynamic_buffer.cpp create mode 100644 engines/wintermute/base/base_dynamic_buffer.h create mode 100644 engines/wintermute/base/base_fader.cpp create mode 100644 engines/wintermute/base/base_fader.h create mode 100644 engines/wintermute/base/base_file_manager.cpp create mode 100644 engines/wintermute/base/base_file_manager.h create mode 100644 engines/wintermute/base/base_frame.cpp create mode 100644 engines/wintermute/base/base_frame.h create mode 100644 engines/wintermute/base/base_game.cpp create mode 100644 engines/wintermute/base/base_game.h create mode 100644 engines/wintermute/base/base_keyboard_state.cpp create mode 100644 engines/wintermute/base/base_keyboard_state.h create mode 100644 engines/wintermute/base/base_named_object.cpp create mode 100644 engines/wintermute/base/base_named_object.h create mode 100644 engines/wintermute/base/base_object.cpp create mode 100644 engines/wintermute/base/base_object.h create mode 100644 engines/wintermute/base/base_parser.cpp create mode 100644 engines/wintermute/base/base_parser.h create mode 100644 engines/wintermute/base/base_persistence_manager.cpp create mode 100644 engines/wintermute/base/base_persistence_manager.h create mode 100644 engines/wintermute/base/base_point.cpp create mode 100644 engines/wintermute/base/base_point.h create mode 100644 engines/wintermute/base/base_quick_msg.cpp create mode 100644 engines/wintermute/base/base_quick_msg.h create mode 100644 engines/wintermute/base/base_region.cpp create mode 100644 engines/wintermute/base/base_region.h create mode 100644 engines/wintermute/base/base_registry.cpp create mode 100644 engines/wintermute/base/base_registry.h create mode 100644 engines/wintermute/base/base_save_thumb_helper.cpp create mode 100644 engines/wintermute/base/base_save_thumb_helper.h create mode 100644 engines/wintermute/base/base_script_holder.cpp create mode 100644 engines/wintermute/base/base_script_holder.h create mode 100644 engines/wintermute/base/base_scriptable.cpp create mode 100644 engines/wintermute/base/base_scriptable.h create mode 100644 engines/wintermute/base/base_sprite.cpp create mode 100644 engines/wintermute/base/base_sprite.h create mode 100644 engines/wintermute/base/base_string_table.cpp create mode 100644 engines/wintermute/base/base_string_table.h create mode 100644 engines/wintermute/base/base_sub_frame.cpp create mode 100644 engines/wintermute/base/base_sub_frame.h create mode 100644 engines/wintermute/base/base_surface_storage.cpp create mode 100644 engines/wintermute/base/base_surface_storage.h create mode 100644 engines/wintermute/base/base_transition_manager.cpp create mode 100644 engines/wintermute/base/base_transition_manager.h create mode 100644 engines/wintermute/base/base_viewport.cpp create mode 100644 engines/wintermute/base/base_viewport.h delete mode 100644 engines/wintermute/base/file/BDiskFile.cpp delete mode 100644 engines/wintermute/base/file/BDiskFile.h delete mode 100644 engines/wintermute/base/file/BFile.cpp delete mode 100644 engines/wintermute/base/file/BFile.h delete mode 100644 engines/wintermute/base/file/BFileEntry.cpp delete mode 100644 engines/wintermute/base/file/BFileEntry.h delete mode 100644 engines/wintermute/base/file/BPackage.cpp delete mode 100644 engines/wintermute/base/file/BPackage.h delete mode 100644 engines/wintermute/base/file/BSaveThumbFile.cpp delete mode 100644 engines/wintermute/base/file/BSaveThumbFile.h create mode 100644 engines/wintermute/base/file/base_disk_file.cpp create mode 100644 engines/wintermute/base/file/base_disk_file.h create mode 100644 engines/wintermute/base/file/base_file.cpp create mode 100644 engines/wintermute/base/file/base_file.h create mode 100644 engines/wintermute/base/file/base_file_entry.cpp create mode 100644 engines/wintermute/base/file/base_file_entry.h create mode 100644 engines/wintermute/base/file/base_package.cpp create mode 100644 engines/wintermute/base/file/base_package.h create mode 100644 engines/wintermute/base/file/base_resources.cpp create mode 100644 engines/wintermute/base/file/base_resources.h create mode 100644 engines/wintermute/base/file/base_save_thumb_file.cpp create mode 100644 engines/wintermute/base/file/base_save_thumb_file.h delete mode 100644 engines/wintermute/base/font/BFont.cpp delete mode 100644 engines/wintermute/base/font/BFont.h delete mode 100644 engines/wintermute/base/font/BFontBitmap.cpp delete mode 100644 engines/wintermute/base/font/BFontBitmap.h delete mode 100644 engines/wintermute/base/font/BFontStorage.cpp delete mode 100644 engines/wintermute/base/font/BFontStorage.h delete mode 100644 engines/wintermute/base/font/BFontTT.cpp delete mode 100644 engines/wintermute/base/font/BFontTT.h create mode 100644 engines/wintermute/base/font/base_font.cpp create mode 100644 engines/wintermute/base/font/base_font.h create mode 100644 engines/wintermute/base/font/base_font_bitmap.cpp create mode 100644 engines/wintermute/base/font/base_font_bitmap.h create mode 100644 engines/wintermute/base/font/base_font_storage.cpp create mode 100644 engines/wintermute/base/font/base_font_storage.h create mode 100644 engines/wintermute/base/font/base_font_truetype.cpp create mode 100644 engines/wintermute/base/font/base_font_truetype.h delete mode 100644 engines/wintermute/base/particles/PartEmitter.cpp delete mode 100644 engines/wintermute/base/particles/PartEmitter.h delete mode 100644 engines/wintermute/base/particles/PartForce.cpp delete mode 100644 engines/wintermute/base/particles/PartForce.h delete mode 100644 engines/wintermute/base/particles/PartParticle.cpp delete mode 100644 engines/wintermute/base/particles/PartParticle.h create mode 100644 engines/wintermute/base/particles/part_emitter.cpp create mode 100644 engines/wintermute/base/particles/part_emitter.h create mode 100644 engines/wintermute/base/particles/part_force.cpp create mode 100644 engines/wintermute/base/particles/part_force.h create mode 100644 engines/wintermute/base/particles/part_particle.cpp create mode 100644 engines/wintermute/base/particles/part_particle.h delete mode 100644 engines/wintermute/base/scriptables/SXArray.cpp delete mode 100644 engines/wintermute/base/scriptables/SXArray.h delete mode 100644 engines/wintermute/base/scriptables/SXDate.cpp delete mode 100644 engines/wintermute/base/scriptables/SXDate.h delete mode 100644 engines/wintermute/base/scriptables/SXFile.cpp delete mode 100644 engines/wintermute/base/scriptables/SXFile.h delete mode 100644 engines/wintermute/base/scriptables/SXMath.cpp delete mode 100644 engines/wintermute/base/scriptables/SXMath.h delete mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.cpp delete mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.h delete mode 100644 engines/wintermute/base/scriptables/SXString.cpp delete mode 100644 engines/wintermute/base/scriptables/SXString.h delete mode 100644 engines/wintermute/base/scriptables/ScEngine.cpp delete mode 100644 engines/wintermute/base/scriptables/ScEngine.h delete mode 100644 engines/wintermute/base/scriptables/ScScript.cpp delete mode 100644 engines/wintermute/base/scriptables/ScScript.h delete mode 100644 engines/wintermute/base/scriptables/ScStack.cpp delete mode 100644 engines/wintermute/base/scriptables/ScStack.h delete mode 100644 engines/wintermute/base/scriptables/ScValue.cpp delete mode 100644 engines/wintermute/base/scriptables/ScValue.h delete mode 100644 engines/wintermute/base/scriptables/SxObject.cpp delete mode 100644 engines/wintermute/base/scriptables/SxObject.h create mode 100644 engines/wintermute/base/scriptables/script.cpp create mode 100644 engines/wintermute/base/scriptables/script.h create mode 100644 engines/wintermute/base/scriptables/script_engine.cpp create mode 100644 engines/wintermute/base/scriptables/script_engine.h create mode 100644 engines/wintermute/base/scriptables/script_ext_array.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_array.h create mode 100644 engines/wintermute/base/scriptables/script_ext_date.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_date.h create mode 100644 engines/wintermute/base/scriptables/script_ext_file.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_file.h create mode 100644 engines/wintermute/base/scriptables/script_ext_math.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_math.h create mode 100644 engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_mem_buffer.h create mode 100644 engines/wintermute/base/scriptables/script_ext_object.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_object.h create mode 100644 engines/wintermute/base/scriptables/script_ext_string.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_string.h create mode 100644 engines/wintermute/base/scriptables/script_stack.cpp create mode 100644 engines/wintermute/base/scriptables/script_stack.h create mode 100644 engines/wintermute/base/scriptables/script_value.cpp create mode 100644 engines/wintermute/base/scriptables/script_value.h create mode 100644 engines/wintermute/base/sound/base_sound.cpp create mode 100644 engines/wintermute/base/sound/base_sound.h create mode 100644 engines/wintermute/base/sound/base_sound_buffer.cpp create mode 100644 engines/wintermute/base/sound/base_sound_buffer.h create mode 100644 engines/wintermute/base/sound/base_sound_manager.cpp create mode 100644 engines/wintermute/base/sound/base_sound_manager.h delete mode 100644 engines/wintermute/graphics/transparentSurface.cpp delete mode 100644 engines/wintermute/graphics/transparentSurface.h create mode 100644 engines/wintermute/graphics/transparent_surface.cpp create mode 100644 engines/wintermute/graphics/transparent_surface.h delete mode 100644 engines/wintermute/math/MathUtil.cpp delete mode 100644 engines/wintermute/math/MathUtil.h delete mode 100644 engines/wintermute/math/Matrix4.cpp delete mode 100644 engines/wintermute/math/Matrix4.h delete mode 100644 engines/wintermute/math/Rect32.h delete mode 100644 engines/wintermute/math/Vector2.cpp delete mode 100644 engines/wintermute/math/Vector2.h create mode 100644 engines/wintermute/math/math_util.cpp create mode 100644 engines/wintermute/math/math_util.h create mode 100644 engines/wintermute/math/matrix4.cpp create mode 100644 engines/wintermute/math/matrix4.h create mode 100644 engines/wintermute/math/rect32.h create mode 100644 engines/wintermute/math/vector2.cpp create mode 100644 engines/wintermute/math/vector2.h delete mode 100644 engines/wintermute/system/SysClass.cpp delete mode 100644 engines/wintermute/system/SysClass.h delete mode 100644 engines/wintermute/system/SysClassRegistry.cpp delete mode 100644 engines/wintermute/system/SysClassRegistry.h delete mode 100644 engines/wintermute/system/SysInstance.cpp delete mode 100644 engines/wintermute/system/SysInstance.h create mode 100644 engines/wintermute/system/sys_class.cpp create mode 100644 engines/wintermute/system/sys_class.h create mode 100644 engines/wintermute/system/sys_class_registry.cpp create mode 100644 engines/wintermute/system/sys_class_registry.h create mode 100644 engines/wintermute/system/sys_instance.cpp create mode 100644 engines/wintermute/system/sys_instance.h delete mode 100644 engines/wintermute/ui/UIButton.cpp delete mode 100644 engines/wintermute/ui/UIButton.h delete mode 100644 engines/wintermute/ui/UIEdit.cpp delete mode 100644 engines/wintermute/ui/UIEdit.h delete mode 100644 engines/wintermute/ui/UIEntity.cpp delete mode 100644 engines/wintermute/ui/UIEntity.h delete mode 100644 engines/wintermute/ui/UIObject.cpp delete mode 100644 engines/wintermute/ui/UIObject.h delete mode 100644 engines/wintermute/ui/UIText.cpp delete mode 100644 engines/wintermute/ui/UIText.h delete mode 100644 engines/wintermute/ui/UITiledImage.cpp delete mode 100644 engines/wintermute/ui/UITiledImage.h delete mode 100644 engines/wintermute/ui/UIWindow.cpp delete mode 100644 engines/wintermute/ui/UIWindow.h create mode 100644 engines/wintermute/ui/ui_button.cpp create mode 100644 engines/wintermute/ui/ui_button.h create mode 100644 engines/wintermute/ui/ui_edit.cpp create mode 100644 engines/wintermute/ui/ui_edit.h create mode 100644 engines/wintermute/ui/ui_entity.cpp create mode 100644 engines/wintermute/ui/ui_entity.h create mode 100644 engines/wintermute/ui/ui_object.cpp create mode 100644 engines/wintermute/ui/ui_object.h create mode 100644 engines/wintermute/ui/ui_text.cpp create mode 100644 engines/wintermute/ui/ui_text.h create mode 100644 engines/wintermute/ui/ui_tiled_image.cpp create mode 100644 engines/wintermute/ui/ui_tiled_image.h create mode 100644 engines/wintermute/ui/ui_window.cpp create mode 100644 engines/wintermute/ui/ui_window.h delete mode 100644 engines/wintermute/utils/ConvertUTF.cpp delete mode 100644 engines/wintermute/utils/ConvertUTF.h delete mode 100644 engines/wintermute/utils/PathUtil.cpp delete mode 100644 engines/wintermute/utils/PathUtil.h delete mode 100644 engines/wintermute/utils/StringUtil.cpp delete mode 100644 engines/wintermute/utils/StringUtil.h create mode 100644 engines/wintermute/utils/convert_utf.cpp create mode 100644 engines/wintermute/utils/convert_utf.h create mode 100644 engines/wintermute/utils/path_util.cpp create mode 100644 engines/wintermute/utils/path_util.h create mode 100644 engines/wintermute/utils/string_util.cpp create mode 100644 engines/wintermute/utils/string_util.h delete mode 100644 engines/wintermute/video/VidPlayer.cpp delete mode 100644 engines/wintermute/video/VidPlayer.h delete mode 100644 engines/wintermute/video/VidTheoraPlayer.cpp delete mode 100644 engines/wintermute/video/VidTheoraPlayer.h create mode 100644 engines/wintermute/video/video_player.cpp create mode 100644 engines/wintermute/video/video_player.h create mode 100644 engines/wintermute/video/video_theora_player.cpp create mode 100644 engines/wintermute/video/video_theora_player.h (limited to 'engines') diff --git a/engines/wintermute/ad/AdActor.cpp b/engines/wintermute/ad/AdActor.cpp deleted file mode 100644 index 050a419e53..0000000000 --- a/engines/wintermute/ad/AdActor.cpp +++ /dev/null @@ -1,1316 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/ad/AdActor.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/ad/AdSpriteSet.h" -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/ad/AdPath.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdActor, false) - - -////////////////////////////////////////////////////////////////////////// -CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - _path = new CAdPath(_gameRef); - - _type = OBJECT_ACTOR; - _dir = DI_LEFT; - - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _targetPoint = new CBPoint; - _afterWalkDir = DI_NONE; - - _animSprite2 = NULL; - - setDefaultAnimNames(); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::setDefaultAnimNames() { - _talkAnimName = "talk"; - _idleAnimName = "idle"; - _walkAnimName = "walk"; - _turnLeftAnimName = "turnleft"; - _turnRightAnimName = "turnright"; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdActor::~CAdActor() { - delete _path; - delete _targetPoint; - _path = NULL; - _targetPoint = NULL; - - delete _walkSprite; - delete _standSprite; - delete _turnLeftSprite; - delete _turnRightSprite; - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; - - _animSprite2 = NULL; // ref only - - for (int i = 0; i < _talkSprites.getSize(); i++) { - delete _talkSprites[i]; - } - _talkSprites.removeAll(); - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - delete _talkSpritesEx[i]; - } - _talkSpritesEx.removeAll(); - - for (int i = 0; i < _anims.getSize(); i++) { - delete _anims[i]; - _anims[i] = NULL; - } - _anims.removeAll(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ACTOR) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(WALK) -TOKEN_DEF(STAND) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(TURN_LEFT) -TOKEN_DEF(TURN_RIGHT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ANIMATION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTOR) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(WALK) - TOKEN_TABLE(STAND) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TURN_LEFT) - TOKEN_TABLE(TURN_RIGHT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { - _gameRef->LOG(0, "'ACTOR' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSpriteSet *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_WALK: - delete _walkSprite; - _walkSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; - else _walkSprite = spr; - break; - - case TOKEN_TALK: - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - break; - - case TOKEN_TALK_SPECIAL: - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - break; - - case TOKEN_STAND: - delete _standSprite; - _standSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; - else _standSprite = spr; - break; - - case TOKEN_TURN_LEFT: - delete _turnLeftSprite; - _turnLeftSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnLeftSprite = spr; - break; - - case TOKEN_TURN_RIGHT: - delete _turnRightSprite; - _turnRightSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnRightSprite = spr; - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); - if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { - delete _blockRegion; - delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); - if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { - delete _wptGroup; - delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->mimic(_wptGroup); - } - } - break; - - case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else _anims.add(Anim); - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ACTOR definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - if (spr) delete spr; - _gameRef->LOG(0, "Error loading ACTOR definition"); - return STATUS_FAILED; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - _state = _nextState = STATE_READY; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::turnTo(TDirection dir) { - int delta1, delta2, delta3, delta; - - delta1 = dir - _dir; - delta2 = dir + NUM_DIRECTIONS - _dir; - delta3 = dir - NUM_DIRECTIONS - _dir; - - delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; - delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; - - // already there? - if (abs(delta) < 2) { - _dir = dir; - _state = _nextState; - _nextState = STATE_READY; - return; - } - - _targetDir = dir; - _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; - - _tempSprite2 = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { - _afterWalkDir = afterWalkDir; - if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; - - _path->reset(); - _path->setReady(false); - - _targetPoint->x = x; - _targetPoint->y = y; - - ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); - - _state = STATE_SEARCHING_PATH; - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::display() { - if (_active) updateSounds(); - - uint32 alpha; - if (_alphaColor != 0) alpha = _alphaColor; - else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - - float rotate; - if (_rotatable) { - if (_rotateValid) rotate = _rotate; - else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else rotate = 0.0f; - - if (_active) displaySpriteAttachments(true); - - if (_currentSprite && _active) { - bool reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; - - _currentSprite->display(_posX, - _posY, - reg ? _registerAlias : NULL, - scaleX, - scaleY, - alpha, - rotate, - _blendMode); - - } - - if (_active) displaySpriteAttachments(false); - if (_active && _partEmitter) _partEmitter->display(); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::update() { - _currentSprite = NULL; - - if (_state == STATE_READY) { - if (_animSprite) { - delete _animSprite; - _animSprite = NULL; - } - if (_animSprite2) { - _animSprite2 = NULL; - } - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite; - } - - if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { - _state = _nextState; - _nextState = STATE_READY; - _currentSprite = _animSprite2; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - } - - bool already_moved = false; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM_SET: - _currentSprite = _animSprite2; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_LEFT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - if (_dir > 0) _dir = (TDirection)(_dir - 1); - else _dir = (TDirection)(NUM_DIRECTIONS - 1); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnLeftSprite) { - _tempSprite2 = _turnLeftSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_TURNING_RIGHT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { - _dir = (TDirection)(_dir + 1); - - if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); - - if (_dir == _targetDir) { - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - if (_turnRightSprite) { - _tempSprite2 = _turnRightSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); - } - - if (_tempSprite2) { - _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; - } - _currentSprite = _tempSprite2; - } - } else _currentSprite = _tempSprite2; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_SEARCHING_PATH: - // keep asking scene for the path - if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) - _state = STATE_WAITING_PATH; - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_WAITING_PATH: - // wait until the scene finished the path - if (_path->_ready) followPath(); - break; - - - ////////////////////////////////////////////////////////////////////////// - case STATE_FOLLOWING_PATH: - getNextStep(); - already_moved = true; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(_dir); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = _nextState; - _nextState = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite && !_animSprite2) { - if (_sprite) _currentSprite = _sprite; - else { - if (_standSprite) { - _currentSprite = _standSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - } - break; - default: - error("AdActor::Update - Unhandled enum"); - } - - - if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - afterMove(); - } - } - - //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); - - updateBlockRegion(); - _ready = (_state == STATE_READY); - - updatePartEmitter(); - updateSpriteAttachments(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::followPath() { - // skip current position - _path->getFirst(); - while (_path->getCurrent() != NULL) { - if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; - _path->getNext(); - } - - // are there points to follow? - if (_path->getCurrent() != NULL) { - _state = STATE_FOLLOWING_PATH;; - initLine(CBPoint(_posX, _posY), *_path->getCurrent()); - } else { - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else _state = STATE_READY; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::getNextStep() { - if (_walkSprite) { - _currentSprite = _walkSprite->getSprite(_dir); - } else { - CAdSpriteSet *Anim = getAnimByName(_walkAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - - if (!_currentSprite) return; - - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (!_currentSprite->_changed) return; - - - int maxStepX, maxStepY; - maxStepX = abs(_currentSprite->_moveX); - maxStepY = abs(_currentSprite->_moveY); - - maxStepX = MAX(maxStepX, maxStepY); - maxStepX = MAX(maxStepX, 1); - - while (_pFCount > 0 && maxStepX >= 0) { - _pFX += _pFStepX; - _pFY += _pFStepY; - - _pFCount--; - maxStepX--; - } - - if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { - if (_pFCount == 0) { - _state = _nextState; - _nextState = STATE_READY; - return; - } - goTo(_targetPoint->x, _targetPoint->y); - return; - } - - - _posX = (int)_pFX; - _posY = (int)_pFY; - - afterMove(); - - - if (_pFCount == 0) { - if (_path->getNext() == NULL) { - _posX = _targetPoint->x; - _posY = _targetPoint->y; - - _path->reset(); - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else { - _state = _nextState; - _nextState = STATE_READY; - } - } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { - _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); - - _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; - _pFStepY = (double)(endPt.y - startPt.y) / _pFCount; - - _pFX = startPt.x; - _pFY = startPt.y; - - int angle = (int)(atan2((double)(endPt.y - startPt.y), (double)(endPt.x - startPt.x)) * (180 / 3.14)); - - _nextState = STATE_FOLLOWING_PATH; - - turnTo(angleToDirection(angle)); -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GoTo / GoToAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { - stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - goTo(X, Y); - if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoToObject / GoToObjectAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - if (!Val->isNative()) { - script->runtimeError("actor.%s method accepts an entity refrence only", name); - stack->pushNULL(); - return STATUS_OK; - } - CAdObject *Obj = (CAdObject *)Val->getNative(); - if (!Obj || Obj->_type != OBJECT_ENTITY) { - script->runtimeError("actor.%s method accepts an entity refrence only", name); - stack->pushNULL(); - return STATUS_OK; - } - CAdEntity *Ent = (CAdEntity *)Obj; - if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); - else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnTo / TurnToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { - stack->correctParams(1); - int dir; - CScValue *val = stack->pop(); - - // turn to object? - if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { - CBObject *obj = (CBObject *)val->getNative(); - int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); - dir = (int)angleToDirection(angle); - } - // otherwise turn to direction - else dir = val->getInt(); - - if (dir >= 0 && dir < NUM_DIRECTIONS) { - turnTo((TDirection)dir); - if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsWalking") == 0) { - stack->correctParams(0); - stack->pushBool(_state == STATE_FOLLOWING_PATH); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MergeAnims - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MergeAnims") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(mergeAnims(stack->pop()->getString()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadAnim") == 0) { - stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); - - bool Found = false; - for (int i = 0; i < _anims.getSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { - // invalidate sprites in use - if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; - if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; - if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; - - delete _anims[i]; - _anims[i] = NULL; - _anims.removeAt(i); - i--; - Found = true; - } - } - stack->pushBool(Found); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasAnim") == 0) { - stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); - stack->pushBool(getAnimByName(AnimName) != NULL); - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Direction") == 0) { - _scValue->setInt(_dir); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Type") == 0) { - _scValue->setString("actor"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkAnimName") == 0) { - _scValue->setString(_talkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkAnimName") == 0) { - _scValue->setString(_walkAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IdleAnimName") == 0) { - _scValue->setString(_idleAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnLeftAnimName") == 0) { - _scValue->setString(_turnLeftAnimName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnRightAnimName") == 0) { - _scValue->setString(_turnRightAnimName); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Direction - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Direction") == 0) { - int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkAnimName") == 0) { - if (value->isNULL()) _talkAnimName = "talk"; - else _talkAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkAnimName") == 0) { - if (value->isNULL()) _walkAnimName = "walk"; - else _walkAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IdleAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IdleAnimName") == 0) { - if (value->isNULL()) _idleAnimName = "idle"; - else _idleAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnLeftAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnLeftAnimName") == 0) { - if (value->isNULL()) _turnLeftAnimName = "turnleft"; - else _turnLeftAnimName = value->getString(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TurnRightAnimName - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnRightAnimName") == 0) { - if (value->isNULL()) _turnRightAnimName = "turnright"; - else _turnRightAnimName = value->getString(); - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdActor::scToString() { - return "[actor object]"; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStance(const char *stance) { - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - // old way - if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) - return getTalkStanceOld(stance); - - // new way - CBSprite *ret = NULL; - - // do we have an animation with this name? - CAdSpriteSet *Anim = getAnimByName(stance); - if (Anim) ret = Anim->getSprite(_dir); - - // not - get a random talk - if (!ret) { - CBArray TalkAnims; - for (int i = 0; i < _anims.getSize(); i++) { - if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) - TalkAnims.add(_anims[i]); - } - - if (TalkAnims.getSize() > 0) { - int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); - ret = TalkAnims[rnd]->getSprite(_dir); - } else { - if (_standSprite) ret = _standSprite->getSprite(_dir); - else { - Anim = getAnimByName(_idleAnimName); - if (Anim) ret = Anim->getSprite(_dir); - } - } - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStanceOld(const char *stance) { - CBSprite *ret = NULL; - - if (stance != NULL) { - // search special stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { - ret = _talkSpritesEx[i]->getSprite(_dir); - break; - } - } - if (ret == NULL) { - // search generic stances - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { - ret = _talkSprites[i]->getSprite(_dir); - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); - else { - // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); - ret = _talkSprites[rnd]->getSprite(_dir); - } - } - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER_INT(_dir)); - persistMgr->transfer(TMEMBER(_path)); - persistMgr->transfer(TMEMBER(_pFCount)); - persistMgr->transfer(TMEMBER(_pFStepX)); - persistMgr->transfer(TMEMBER(_pFStepY)); - persistMgr->transfer(TMEMBER(_pFX)); - persistMgr->transfer(TMEMBER(_pFY)); - persistMgr->transfer(TMEMBER(_standSprite)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_targetDir)); - persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); - persistMgr->transfer(TMEMBER(_targetPoint)); - persistMgr->transfer(TMEMBER(_turnLeftSprite)); - persistMgr->transfer(TMEMBER(_turnRightSprite)); - persistMgr->transfer(TMEMBER(_walkSprite)); - - persistMgr->transfer(TMEMBER(_animSprite2)); - persistMgr->transfer(TMEMBER(_talkAnimName)); - persistMgr->transfer(TMEMBER(_idleAnimName)); - persistMgr->transfer(TMEMBER(_walkAnimName)); - persistMgr->transfer(TMEMBER(_turnLeftAnimName)); - persistMgr->transfer(TMEMBER(_turnRightAnimName)); - - _anims.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TDirection CAdActor::angleToDirection(int angle) { - TDirection ret = DI_DOWN;; - - if (angle > -112 && angle <= -67) ret = DI_UP; - else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; - else if (angle > -22 && angle <= 22) ret = DI_RIGHT; - else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; - else if (angle > 67 && angle <= 112) ret = DI_DOWN; - else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; - else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; - else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdActor::getHeight() { - // if no current sprite is set, set some - if (_currentSprite == NULL) { - if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); - else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); - } - } - // and get height - return CAdTalkHolder::getHeight(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { - for (int i = 0; i < _anims.getSize(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) - return _anims[i]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::mergeAnims(const char *animsFilename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ANIMATION) - TOKEN_TABLE_END - - - byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); - if (fileBuffer == NULL) { - _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); - return STATUS_FAILED; - } - - byte *buffer = fileBuffer; - byte *params; - int cmd; - CBParser parser(_gameRef); - - bool Ret = STATUS_OK; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - Ret = STATUS_FAILED; - } else _anims.add(Anim); - } - break; - } - } - delete [] fileBuffer; - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdActor::playAnim(const char *filename) { - // if we have an anim with this name, use it - CAdSpriteSet *Anim = getAnimByName(filename); - if (Anim) { - _animSprite2 = Anim->getSprite(_dir); - if (_animSprite2) { - _animSprite2->reset(); - _state = STATE_PLAYING_ANIM_SET; - return STATUS_OK; - } - } - // otherwise call the standard handler - return CAdTalkHolder::playAnim(filename); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdActor.h b/engines/wintermute/ad/AdActor.h deleted file mode 100644 index 1be8b8131d..0000000000 --- a/engines/wintermute/ad/AdActor.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADACTOR_H -#define WINTERMUTE_ADACTOR_H - - -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/ad/AdTypes.h" // Added by ClassView -#include "engines/wintermute/ad/AdTalkHolder.h" -#include "engines/wintermute/base/BPoint.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "common/str.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -namespace WinterMute { -class CAdSpriteSet; -class CAdPath; -class CAdActor : public CAdTalkHolder { -public: - TDirection angleToDirection(int angle); - DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) - virtual int getHeight(); - CBSprite *getTalkStance(const char *stance); - virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); - CBPoint *_targetPoint; - virtual bool update(); - virtual bool display(); - TDirection _targetDir; - TDirection _afterWalkDir; - virtual void turnTo(TDirection dir); - CAdPath *_path; - CAdSpriteSet *_walkSprite; - CAdSpriteSet *_standSprite; - CAdSpriteSet *_turnLeftSprite; - CAdSpriteSet *_turnRightSprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - TDirection _dir; - CAdActor(CBGame *inGame/*=NULL*/); - virtual ~CAdActor(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - - // new anim system - Common::String _talkAnimName; - Common::String _idleAnimName; - Common::String _walkAnimName; - Common::String _turnLeftAnimName; - Common::String _turnRightAnimName; - CBArray _anims; - virtual bool playAnim(const char *filename); - CAdSpriteSet *getAnimByName(const Common::String &animName); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - bool setDefaultAnimNames(); - CBSprite *getTalkStanceOld(const char *stance); - bool mergeAnims(const char *animsFilename); - CBSprite *_animSprite2; - - void initLine(CBPoint startPt, CBPoint endPt); - void getNextStep(); - void followPath(); - double _pFStepX; - double _pFStepY; - double _pFX; - double _pFY; - int _pFCount; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/ad/AdEntity.cpp b/engines/wintermute/ad/AdEntity.cpp deleted file mode 100644 index 49c723f66a..0000000000 --- a/engines/wintermute/ad/AdEntity.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdEntity, false) - -////////////////////////////////////////////////////////////////////////// -CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { - _type = OBJECT_ENTITY; - _subtype = ENTITY_NORMAL; - _region = NULL; - _item = NULL; - - _walkToX = _walkToY = 0; - _walkToDir = DI_NONE; - - _theora = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdEntity::~CAdEntity() { - _gameRef->unregisterObject(_region); - - delete _theora; - _theora = NULL; - - delete[] _item; - _item = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SCALABLE) -TOKEN_DEF(REGISTRABLE) -TOKEN_DEF(INTERACTIVE) -TOKEN_DEF(SHADOWABLE) -TOKEN_DEF(COLORABLE) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(FONT) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(CURSOR) -TOKEN_DEF(REGION) -TOKEN_DEF(BLOCKED_REGION) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(SOUND_START_TIME) -TOKEN_DEF(SOUND_VOLUME) -TOKEN_DEF(SOUND_PANNING) -TOKEN_DEF(SOUND) -TOKEN_DEF(SUBTYPE) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(IGNORE_ITEMS) -TOKEN_DEF(ROTABLE) -TOKEN_DEF(ROTATABLE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(SCALE) -TOKEN_DEF(RELATIVE_SCALE) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(ITEM) -TOKEN_DEF(WALK_TO_X) -TOKEN_DEF(WALK_TO_Y) -TOKEN_DEF(WALK_TO_DIR) -TOKEN_DEF(SAVE_STATE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCALABLE) - TOKEN_TABLE(REGISTRABLE) - TOKEN_TABLE(INTERACTIVE) - TOKEN_TABLE(SHADOWABLE) - TOKEN_TABLE(COLORABLE) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(REGION) - TOKEN_TABLE(BLOCKED_REGION) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(SOUND_START_TIME) - TOKEN_TABLE(SOUND_VOLUME) - TOKEN_TABLE(SOUND_PANNING) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(SUBTYPE) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(IGNORE_ITEMS) - TOKEN_TABLE(ROTABLE) - TOKEN_TABLE(ROTATABLE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(RELATIVE_SCALE) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(WALK_TO_X) - TOKEN_TABLE(WALK_TO_Y) - TOKEN_TABLE(WALK_TO_DIR) - TOKEN_TABLE(SAVE_STATE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { - _gameRef->LOG(0, "'ENTITY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CAdGame *adGame = (CAdGame *)_gameRef; - CBSprite *spr = NULL; - int ar = 0, ag = 0, ab = 0, alpha = 0; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SPRITE: { - delete _sprite; - _sprite = NULL; - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - break; - - case TOKEN_TALK: { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - } - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_ITEM: - setItem((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_SCALABLE: - parser.scanStr((char *)params, "%b", &_zoomable); - break; - - case TOKEN_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _scale = (float)s; - - } - break; - - case TOKEN_RELATIVE_SCALE: { - int s; - parser.scanStr((char *)params, "%d", &s); - _relativeScale = (float)s; - - } - break; - - case TOKEN_ROTABLE: - case TOKEN_ROTATABLE: - parser.scanStr((char *)params, "%b", &_rotatable); - break; - - case TOKEN_REGISTRABLE: - case TOKEN_INTERACTIVE: - parser.scanStr((char *)params, "%b", &_registrable); - break; - - case TOKEN_SHADOWABLE: - case TOKEN_COLORABLE: - parser.scanStr((char *)params, "%b", &_shadowable); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_REGION: { - if (_region) _gameRef->unregisterObject(_region); - _region = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else { - _region = rgn; - _gameRef->registerObject(_region); - } - } - break; - - case TOKEN_BLOCKED_REGION: { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); - if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { - delete _blockRegion; - _blockRegion = NULL; - delete _currentBlockRegion; - _currentBlockRegion = NULL; - cmd = PARSERR_GENERIC; - } else { - _blockRegion = rgn; - _currentBlockRegion = crgn; - _currentBlockRegion->mimic(_blockRegion); - } - } - break; - - case TOKEN_WAYPOINTS: { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); - if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { - delete _wptGroup; - _wptGroup = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - cmd = PARSERR_GENERIC; - } else { - _wptGroup = wpt; - _currentWptGroup = cwpt; - _currentWptGroup->mimic(_wptGroup); - } - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_SUBTYPE: { - if (scumm_stricmp((char *)params, "sound") == 0) { - delete _sprite; - _sprite = NULL; - if (_gameRef->_editorMode) { - spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; - else _sprite = spr; - } - if (_gameRef->_editorMode) _editorOnly = true; - _zoomable = false; - _rotatable = false; - _registrable = _gameRef->_editorMode; - _shadowable = false; - _subtype = ENTITY_SOUND; - } - } - break; - - case TOKEN_SOUND: - playSFX((char *)params, false, false); - break; - - case TOKEN_SOUND_START_TIME: - parser.scanStr((char *)params, "%d", &_sFXStart); - break; - - case TOKEN_SOUND_VOLUME: - parser.scanStr((char *)params, "%d", &_sFXVolume); - break; - - case TOKEN_SOUND_PANNING: - parser.scanStr((char *)params, "%b", &_autoSoundPanning); - break; - - case TOKEN_SAVE_STATE: - parser.scanStr((char *)params, "%b", &_saveState); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_IGNORE_ITEMS: - parser.scanStr((char *)params, "%b", &_ignoreItems); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_WALK_TO_X: - parser.scanStr((char *)params, "%d", &_walkToX); - break; - - case TOKEN_WALK_TO_Y: - parser.scanStr((char *)params, "%d", &_walkToY); - break; - - case TOKEN_WALK_TO_DIR: { - int i; - parser.scanStr((char *)params, "%d", &i); - if (i < 0) i = 0; - if (i >= NUM_DIRECTIONS) i = DI_NONE; - _walkToDir = (TDirection)i; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ENTITY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ENTITY definition"); - if (spr) delete spr; - return STATUS_FAILED; - } - - if (_region && _sprite) { - _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); - } - - updatePosition(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - _state = STATE_READY; - - if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::display() { - if (_active) { - updateSounds(); - - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; - - float ScaleX, ScaleY; - getScale(&ScaleX, &ScaleY); - - float Rotate; - if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; - - - bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; - - if (_region && (Reg || _editorAlwaysRegister)) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); - } - - displaySpriteAttachments(true); - if (_theora && (_theora->isPlaying() || _theora->isPaused())) { - _theora->display(Alpha); - } else if (_currentSprite) { - _currentSprite->display(_posX, - _posY, - (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, - _blendMode); - } - displaySpriteAttachments(false); - - if (_partEmitter) _partEmitter->display(_region); - - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) - _currentSprite = _sprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - break; - default: // Silence unhandled enum-warning - break; - } - - - if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { - _posX += _currentSprite->_moveX; - _posY += _currentSprite->_moveY; - } - } - - updateBlockRegion(); - _ready = (_state == STATE_READY); - - if (_theora) { - int OffsetX, OffsetY; - _gameRef->getOffset(&OffsetX, &OffsetY); - _theora->_posX = _posX - OffsetX; - _theora->_posY = _posY - OffsetY; - - _theora->update(); - if (_theora->isFinished()) { - _theora->stop(); - delete _theora; - _theora = NULL; - } - } - - updatePartEmitter(); - updateSpriteAttachments(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX(false))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - stack->correctParams(4); - const char *filename = stack->pop()->getString(); - bool looping = stack->pop()->getBool(false); - CScValue *valAlpha = stack->pop(); - int startTime = stack->pop()->getInt(); - - delete _theora; - _theora = new CVidTheoraPlayer(_gameRef); - if (_theora && DID_SUCCEED(_theora->initialize(filename))) { - if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); - _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); - //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; - stack->pushBool(true); - } else { - script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopTheora") == 0) { - stack->correctParams(0); - if (_theora) { - _theora->stop(); - delete _theora; - _theora = NULL; - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTheoraPlaying") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseTheora") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPlaying()) { - _theora->pause(); - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeTheora") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPaused()) { - _theora->resume(); - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTheoraPaused - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTheoraPaused") == 0) { - stack->correctParams(0); - if (_theora && _theora->isPaused()) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // CreateRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateRegion") == 0) { - stack->correctParams(0); - if (!_region) { - _region = new CBRegion(_gameRef); - _gameRef->registerObject(_region); - } - if (_region) stack->pushNative(_region, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteRegion") == 0) { - stack->correctParams(0); - if (_region) { - _gameRef->unregisterObject(_region); - _region = NULL; - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("entity"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Item") == 0) { - if (_item) _scValue->setString(_item); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtype (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtype") == 0) { - if (_subtype == ENTITY_SOUND) - _scValue->setString("sound"); - else - _scValue->setString("normal"); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToX") == 0) { - _scValue->setInt(_walkToX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToY") == 0) { - _scValue->setInt(_walkToY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToDirection") == 0) { - _scValue->setInt((int)_walkToDir); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Region (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Region") == 0) { - if (_region) _scValue->setNative(_region, true); - else _scValue->setNULL(); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Item") == 0) { - setItem(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToX") == 0) { - _walkToX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToY") == 0) { - _walkToY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WalkToDirection - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToDirection") == 0) { - int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdEntity::scToString() { - return "[entity object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - if (_subtype == ENTITY_SOUND) - buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_ignoreItems) - buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); - if (_rotatable) - buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); - - if (!_autoSoundPanning) - buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); - - if (!_saveState) - buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); - - if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); - - buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); - buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); - if (_walkToDir != DI_NONE) - buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); - - if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); - buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); - buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); - } - - - if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); - - if (RGBCOLGetA(_alphaColor) != 0) - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); - - if (_scale >= 0) - buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); - - if (_relativeScale != 0) - buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - CAdTalkHolder::saveAsText(buffer, indent + 2); - - if (_region) _region->saveAsText(buffer, indent + 2); - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - CAdObject::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdEntity::getHeight() { - if (_region && !_sprite) { - return _region->_rect.bottom - _region->_rect.top; - } else { - if (_currentSprite == NULL) _currentSprite = _sprite; - return CAdObject::getHeight(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::updatePosition() { - if (_region && !_sprite) { - _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; - _posY = _region->_rect.bottom; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_item)); - persistMgr->transfer(TMEMBER(_region)); - //persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER_INT(_subtype)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_walkToX)); - persistMgr->transfer(TMEMBER(_walkToY)); - persistMgr->transfer(TMEMBER_INT(_walkToDir)); - - persistMgr->transfer(TMEMBER(_theora)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdEntity::setItem(const char *itemName) { - CBUtils::setString(&_item, itemName); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdEntity::setSprite(const char *filename) { - bool setCurrent = false; - if (_currentSprite == _sprite) { - _currentSprite = NULL; - setCurrent = true; - } - - delete _sprite; - _sprite = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - delete _sprite; - _sprite = NULL; - return STATUS_FAILED; - } else { - _sprite = spr; - _currentSprite = _sprite; - return STATUS_OK; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdEntity.h b/engines/wintermute/ad/AdEntity.h deleted file mode 100644 index a260ca3329..0000000000 --- a/engines/wintermute/ad/AdEntity.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADENTITY_H -#define WINTERMUTE_ADENTITY_H - -#include "engines/wintermute/ad/AdTalkHolder.h" - -namespace WinterMute { -class CVidTheoraPlayer; -class CAdEntity : public CAdTalkHolder { -public: - CVidTheoraPlayer *_theora; - bool setSprite(const char *filename); - int _walkToX; - int _walkToY; - TDirection _walkToDir; - void setItem(const char *itemName); - char *_item; - DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) - void updatePosition(); - virtual int getHeight(); - CBRegion *_region; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool update(); - virtual bool display(); - CAdEntity(CBGame *inGame); - virtual ~CAdEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - TEntityType _subtype; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdGame.cpp b/engines/wintermute/ad/AdGame.cpp deleted file mode 100644 index 87e3fe14d9..0000000000 --- a/engines/wintermute/ad/AdGame.cpp +++ /dev/null @@ -1,2061 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdActor.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/ad/AdInventory.h" -#include "engines/wintermute/ad/AdInventoryBox.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/ad/AdResponse.h" -#include "engines/wintermute/ad/AdResponseBox.h" -#include "engines/wintermute/ad/AdResponseContext.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/ad/AdSceneState.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/BTransitionMgr.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/particles/PartEmitter.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/ui/UIEntity.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/video/VidPlayer.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdGame, true) - -////////////////////////////////////////////////////////////////////////// -CAdGame::CAdGame(): CBGame() { - _responseBox = NULL; - _inventoryBox = NULL; - - _scene = new CAdScene(_gameRef); - _scene->setName(""); - registerObject(_scene); - - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _scheduledFadeIn = false; - - - _stateEx = GAME_NORMAL; - - _selectedItem = NULL; - - - _texItemLifeTime = 10000; - _texWalkLifeTime = 10000; - _texStandLifeTime = 10000; - _texTalkLifeTime = 10000; - - _talkSkipButton = TALK_SKIP_LEFT; - - _sceneViewport = NULL; - - _initialScene = true; - _debugStartupScene = NULL; - _startupScene = NULL; - - _invObject = new CAdObject(this); - _inventoryOwner = _invObject; - - _tempDisableSaveState = false; - _itemsFile = NULL; - - _smartItemCursor = false; - - addSpeechDir("speech"); -} - - -////////////////////////////////////////////////////////////////////////// -CAdGame::~CAdGame() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::cleanup() { - int i; - - for (i = 0; i < _objects.getSize(); i++) { - unregisterObject(_objects[i]); - _objects[i] = NULL; - } - _objects.removeAll(); - - - for (i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.removeAll(); - - for (i = 0; i < _speechDirs.getSize(); i++) { - delete [] _speechDirs[i]; - } - _speechDirs.removeAll(); - - - unregisterObject(_scene); - _scene = NULL; - - // remove items - for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); - _items.removeAll(); - - - // clear remaining inventories - delete _invObject; - _invObject = NULL; - - for (i = 0; i < _inventories.getSize(); i++) { - delete _inventories[i]; - } - _inventories.removeAll(); - - - if (_responseBox) { - _gameRef->unregisterObject(_responseBox); - _responseBox = NULL; - } - - if (_inventoryBox) { - _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = NULL; - } - - delete[] _prevSceneName; - delete[] _prevSceneFilename; - delete[] _scheduledScene; - delete[] _debugStartupScene; - delete[] _itemsFile; - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _debugStartupScene = NULL; - _startupScene = NULL; - _itemsFile = NULL; - - delete _sceneViewport; - _sceneViewport = NULL; - - for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; - _sceneStates.removeAll(); - - for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - - for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; - _responsesGame.removeAll(); - - return CBGame::cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::initLoop() { - if (_scheduledScene && _transMgr->isReady()) { - changeScene(_scheduledScene, _scheduledFadeIn); - delete[] _scheduledScene; - _scheduledScene = NULL; - - _gameRef->_activeObject = NULL; - } - - - bool res; - res = CBGame::initLoop(); - if (DID_FAIL(res)) return res; - - if (_scene) res = _scene->initLoop(); - - _sentences.removeAll(); - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addObject(CAdObject *object) { - _objects.add(object); - return registerObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeObject(CAdObject *object) { - // in case the user called Scene.CreateXXX() and Game.DeleteXXX() - if (_scene) { - bool Res = _scene->removeObject(object); - if (DID_SUCCEED(Res)) return Res; - } - - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] == object) { - _objects.removeAt(i); - break; - } - } - return unregisterObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::changeScene(const char *filename, bool fadeIn) { - if (_scene == NULL) { - _scene = new CAdScene(_gameRef); - registerObject(_scene); - } else { - _scene->applyEvent("SceneShutdown", true); - - setPrevSceneName(_scene->_name); - setPrevSceneFilename(_scene->_filename); - - if (!_tempDisableSaveState) _scene->saveState(); - _tempDisableSaveState = false; - } - - if (_scene) { - // reset objects - for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); - - // reset scene properties - _scene->_sFXVolume = 100; - if (_scene->_scProp) _scene->_scProp->cleanup(); - - bool ret; - if (_initialScene && _debugDebugMode && _debugStartupScene) { - _initialScene = false; - ret = _scene->loadFile(_debugStartupScene); - } else ret = _scene->loadFile(filename); - - if (DID_SUCCEED(ret)) { - // invalidate references to the original scene - for (int i = 0; i < _objects.getSize(); i++) { - _objects[i]->invalidateCurrRegions(); - _objects[i]->_stickRegion = NULL; - } - - _scene->loadState(); - } - if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); - return ret; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::addSentence(CAdSentence *sentence) { - _sentences.add(sentence); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displaySentences(bool frozen) { - for (int i = 0; i < _sentences.getSize(); i++) { - if (frozen && _sentences[i]->_freezable) continue; - else _sentences[i]->display(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::finishSentences() { - for (int i = 0; i < _sentences.getSize(); i++) { - if (_sentences[i]->CanSkip()) { - _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // ChangeScene - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "ChangeScene") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - CScValue *valFadeOut = stack->pop(); - CScValue *valFadeIn = stack->pop(); - - bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); - bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); - - scheduleChangeScene(filename, transIn); - if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); - stack->pushNULL(); - - - //bool ret = ChangeScene(stack->pop()->getString()); - //if(DID_FAIL(ret)) stack->pushBool(false); - //else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadActor") == 0) { - stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); - if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { - addObject(act); - stack->pushNative(act, true); - } else { - delete act; - act = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadEntity") == 0) { - stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); - if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { - addObject(ent); - stack->pushNative(ent, true); - } else { - delete ent; - ent = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); - removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdEntity *ent = new CAdEntity(_gameRef); - addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = new CAdItem(_gameRef); - addItem(item); - if (!val->isNULL()) item->setName(val->getString()); - stack->pushNative(item, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = NULL; - if (val->isNative()) item = (CAdItem *)val->getNative(); - else item = getItemByName(val->getString()); - - if (item) { - deleteItem(item); - } - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QueryItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QueryItem") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdItem *item = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < _items.getSize()) item = _items[index]; - } else { - item = getItemByName(val->getString()); - } - - if (item) stack->pushNative(item, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // AddResponse/AddResponseOnce/AddResponseOnceGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { - stack->correctParams(6); - int id = stack->pop()->getInt(); - const char *text = stack->pop()->getString(); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - CScValue *val4 = stack->pop(); - - if (_responseBox) { - CAdResponse *res = new CAdResponse(_gameRef); - if (res) { - res->_iD = id; - res->setText(text); - _stringTable->expand(&res->_text); - if (!val1->isNULL()) res->setIcon(val1->getString()); - if (!val2->isNULL()) res->setIconHover(val2->getString()); - if (!val3->isNULL()) res->setIconPressed(val3->getString()); - if (!val4->isNULL()) res->setFont(val4->getString()); - - if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; - else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; - - _responseBox->_responses.add(res); - } - } else { - script->runtimeError("Game.AddResponse: response box is not defined"); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResetResponse") == 0) { - stack->correctParams(1); - int ID = stack->pop()->getInt(-1); - resetResponse(ID); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearResponses") == 0) { - stack->correctParams(0); - _responseBox->clearResponses(); - _responseBox->clearButtons(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponse - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetResponse") == 0) { - stack->correctParams(1); - bool autoSelectLast = stack->pop()->getBool(); - - if (_responseBox) { - _responseBox->weedResponses(); - - if (_responseBox->_responses.getSize() == 0) { - stack->pushNULL(); - return STATUS_OK; - } - - - if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { - stack->pushInt(_responseBox->_responses[0]->_iD); - _responseBox->handleResponse(_responseBox->_responses[0]); - _responseBox->clearResponses(); - return STATUS_OK; - } - - _responseBox->createButtons(); - _responseBox->_waitingScript = script; - script->waitForExclusive(_responseBox); - _state = GAME_SEMI_FROZEN; - _stateEx = GAME_WAITING_RESPONSE; - } else { - script->runtimeError("Game.GetResponse: response box is not defined"); - stack->pushNULL(); - } - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // GetNumResponses - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNumResponses") == 0) { - stack->correctParams(0); - if (_responseBox) { - _responseBox->weedResponses(); - stack->pushInt(_responseBox->_responses.getSize()); - } else { - script->runtimeError("Game.GetNumResponses: response box is not defined"); - stack->pushNULL(); - } - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // StartDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartDlgBranch") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - Common::String branchName; - if (val->isNULL()) { - branchName.format("line%d", script->_currentLine); - } else branchName = val->getString(); - - startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EndDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EndDlgBranch") == 0) { - stack->correctParams(1); - - const char *branchName = NULL; - CScValue *val = stack->pop(); - if (!val->isNULL()) branchName = val->getString(); - endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCurrentDlgBranch - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCurrentDlgBranch") == 0) { - stack->correctParams(0); - - if (_dlgPendingBranches.getSize() > 0) { - stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TakeItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DropItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasItem") == 0) { - return _invObject->scCallMethod(script, stack, thisStack, name); - } - - ////////////////////////////////////////////////////////////////////////// - // IsItemTaken - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsItemTaken") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (val->getNative() == Inv->_takenItems[j]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { - stack->pushBool(true); - return STATUS_OK; - } - } - } - } else script->runtimeError("Game.IsItemTaken: item name expected"); - - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInventoryWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInventoryWindow") == 0) { - stack->correctParams(0); - if (_inventoryBox && _inventoryBox->_window) - stack->pushNative(_inventoryBox->_window, true); - else - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetResponsesWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { - stack->correctParams(0); - if (_responseBox && _responseBox->_window) - stack->pushNative(_responseBox->_window, true); - else - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadResponseBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadResponseBox") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _gameRef->unregisterObject(_responseBox); - _responseBox = new CAdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { - registerObject(_responseBox); - stack->pushBool(true); - } else { - delete _responseBox; - _responseBox = NULL; - stack->pushBool(false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadInventoryBox - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadInventoryBox") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = new CAdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { - registerObject(_inventoryBox); - stack->pushBool(true); - } else { - delete _inventoryBox; - _inventoryBox = NULL; - stack->pushBool(false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadItems") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool merge = stack->pop()->getBool(false); - - bool ret = loadItemsFile(filename, merge); - stack->pushBool(DID_SUCCEED(ret)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSpeechDir") == 0) { - stack->correctParams(1); - const char *dir = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSpeechDir(dir))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveSpeechDir - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSpeechDir") == 0) { - stack->correctParams(1); - const char *dir = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSpeechDir(dir))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSceneViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSceneViewport") == 0) { - stack->correctParams(4); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - int width = stack->pop()->getInt(); - int height = stack->pop()->getInt(); - - if (width <= 0) width = _renderer->_width; - if (height <= 0) height = _renderer->_height; - - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); - - stack->pushBool(true); - - return STATUS_OK; - } - - - else return CBGame::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scene") == 0) { - if (_scene) _scValue->setNative(_scene, true); - else _scValue->setNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelectedItem") == 0) { - //if(_selectedItem) _scValue->setString(_selectedItem->_name); - if (_selectedItem) _scValue->setNative(_selectedItem, true); - else _scValue->setNULL(); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { - return _invObject->scGetProperty(name); - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SmartItemCursor") == 0) { - _scValue->setBool(_smartItemCursor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryVisible") == 0) { - _scValue->setBool(_inventoryBox && _inventoryBox->_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); - else _scValue->setInt(0); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ResponsesVisible (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResponsesVisible") == 0) { - _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevScene / PreviousScene (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { - if (!_prevSceneName) _scValue->setString(""); - else _scValue->setString(_prevSceneName); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PrevSceneFilename / PreviousSceneFilename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { - if (!_prevSceneFilename) _scValue->setString(""); - else _scValue->setString(_prevSceneFilename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponse (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponse") == 0) { - if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseText); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LastResponseOrig (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponseOrig") == 0) { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseTextOrig); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner == _invObject) _scValue->setNative(this, true); - else _scValue->setNative(_inventoryOwner, true); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TotalNumItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TotalNumItems") == 0) { - _scValue->setInt(_items.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkSkipButton") == 0) { - _scValue->setInt(_talkSkipButton); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ChangingScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ChangingScene") == 0) { - _scValue->setBool(_scheduledScene != NULL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartupScene") == 0) { - if (!_startupScene) _scValue->setNULL(); - else _scValue->setString(_startupScene); - return _scValue; - } - - else return CBGame::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // SelectedItem - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelectedItem") == 0) { - if (value->isNULL()) _selectedItem = NULL; - else { - if (value->isNative()) { - _selectedItem = NULL; - for (int i = 0; i < _items.getSize(); i++) { - if (_items[i] == value->getNative()) { - _selectedItem = (CAdItem *)value->getNative(); - break; - } - } - } else { - // try to get by name - _selectedItem = getItemByName(value->getString()); - } - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SmartItemCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SmartItemCursor") == 0) { - _smartItemCursor = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryVisible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; - - if (value->isNULL()) _inventoryOwner = _invObject; - else { - CBObject *Obj = (CBObject *)value->getNative(); - if (Obj == this) _inventoryOwner = _invObject; - else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; - } - - if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InventoryScrollOffset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TalkSkipButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkSkipButton") == 0) { - int Val = value->getInt(); - if (Val < 0) Val = 0; - if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; - _talkSkipButton = (TTalkSkipButton)Val; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StartupScene - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartupScene") == 0) { - if (value == NULL) { - delete[] _startupScene; - _startupScene = NULL; - } else CBUtils::setString(&_startupScene, value->getString()); - - return STATUS_OK; - } - - else return CBGame::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *this_obj; - - ////////////////////////////////////////////////////////////////////////// - // Actor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Actor") == 0) { - stack->correctParams(0); - this_obj = thisStack->getTop(); - - this_obj->setNative(new CAdActor(_gameRef)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Entity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Entity") == 0) { - stack->correctParams(0); - this_obj = thisStack->getTop(); - - this_obj->setNative(new CAdEntity(_gameRef)); - stack->pushNULL(); - } - - - ////////////////////////////////////////////////////////////////////////// - // call parent - else return CBGame::ExternalCall(script, stack, thisStack, name); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::showCursor() { - if (_cursorHidden) return STATUS_OK; - - if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { - if (_selectedItem->_cursorCombined) { - CBSprite *origLastCursor = _lastCursor; - CBGame::showCursor(); - _lastCursor = origLastCursor; - } - if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) - return drawCursor(_selectedItem->_cursorHover); - else - return drawCursor(_selectedItem->_cursorNormal); - } else return drawCursor(_selectedItem->_cursorNormal); - } else return CBGame::showCursor(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadFile(const char *filename) { - byte *buffer = _fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(AD_GAME) -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(ITEMS) -TOKEN_DEF(ITEM) -TOKEN_DEF(TALK_SKIP_BUTTON) -TOKEN_DEF(SCENE_VIEWPORT) -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(STARTUP_SCENE) -TOKEN_DEF(DEBUG_STARTUP_SCENE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(AD_GAME) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(ITEMS) - TOKEN_TABLE(TALK_SKIP_BUTTON) - TOKEN_TABLE(SCENE_VIEWPORT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(STARTUP_SCENE) - TOKEN_TABLE(DEBUG_STARTUP_SCENE) - TOKEN_TABLE_END - - byte *params; - byte *params2; - int cmd = 1; - CBParser parser(_gameRef); - - bool itemFound = false, itemsFound = false; - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AD_GAME: - while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { - switch (cmd) { - case TOKEN_RESPONSE_BOX: - delete _responseBox; - _responseBox = new CAdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) - registerObject(_responseBox); - else { - delete _responseBox; - _responseBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_INVENTORY_BOX: - delete _inventoryBox; - _inventoryBox = new CAdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) - registerObject(_inventoryBox); - else { - delete _inventoryBox; - _inventoryBox = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ITEMS: - itemsFound = true; - CBUtils::setString(&_itemsFile, (char *)params2); - if (DID_FAIL(loadItemsFile(_itemsFile))) { - delete[] _itemsFile; - _itemsFile = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; - else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; - else _talkSkipButton = TALK_SKIP_LEFT; - break; - - case TOKEN_SCENE_VIEWPORT: { - Rect32 rc; - parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params2, false); - break; - - case TOKEN_STARTUP_SCENE: - CBUtils::setString(&_startupScene, (char *)params2); - break; - - case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::setString(&_debugStartupScene, (char *)params2); - break; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - if (itemFound && !itemsFound) { - _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file."); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); - CBGame::persist(persistMgr); - - _dlgPendingBranches.persist(persistMgr); - - _inventories.persist(persistMgr); - persistMgr->transfer(TMEMBER(_inventoryBox)); - - _objects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_prevSceneName)); - persistMgr->transfer(TMEMBER(_prevSceneFilename)); - - persistMgr->transfer(TMEMBER(_responseBox)); - _responsesBranch.persist(persistMgr); - _responsesGame.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scene)); - _sceneStates.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scheduledFadeIn)); - persistMgr->transfer(TMEMBER(_scheduledScene)); - persistMgr->transfer(TMEMBER(_selectedItem)); - persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); - - _sentences.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_sceneViewport)); - persistMgr->transfer(TMEMBER_INT(_stateEx)); - persistMgr->transfer(TMEMBER(_initialScene)); - persistMgr->transfer(TMEMBER(_debugStartupScene)); - - persistMgr->transfer(TMEMBER(_invObject)); - persistMgr->transfer(TMEMBER(_inventoryOwner)); - persistMgr->transfer(TMEMBER(_tempDisableSaveState)); - _items.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_itemsFile)); - - _speechDirs.persist(persistMgr); - persistMgr->transfer(TMEMBER(_smartItemCursor)); - - if (!persistMgr->_saving) _initialScene = false; - - persistMgr->transfer(TMEMBER(_startupScene)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadGame(const char *filename) { - bool ret = CBGame::loadGame(filename); - if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::initAfterLoad() { - CBGame::initAfterLoad(); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdGame::afterLoadScene(void *scene, void *data) { - ((CAdScene *)scene)->afterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneName(const char *name) { - delete[] _prevSceneName; - _prevSceneName = NULL; - if (name) { - _prevSceneName = new char[strlen(name) + 1]; - if (_prevSceneName) strcpy(_prevSceneName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneFilename(const char *name) { - delete[] _prevSceneFilename; - _prevSceneFilename = NULL; - if (name) { - _prevSceneFilename = new char[strlen(name) + 1]; - if (_prevSceneFilename) strcpy(_prevSceneFilename, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { - delete[] _scheduledScene; - _scheduledScene = NULL; - - if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); - else { - _scheduledScene = new char [strlen(filename) + 1]; - strcpy(_scheduledScene, filename); - - _scheduledFadeIn = fadeIn; - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - CBGame::getVersion(verMajor, verMinor, NULL, NULL); - - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - //_filename = new char [strlen(filename)+1]; - //strcpy(_filename, filename); - - if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (!merge) { - while (_items.getSize() > 0) deleteItem(_items[0]); - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_ITEM: { - CAdItem *item = new CAdItem(_gameRef); - if (item && !DID_FAIL(item->loadBuffer(params, false))) { - // delete item with the same name, if exists - if (merge) { - CAdItem *PrevItem = getItemByName(item->_name); - if (PrevItem) deleteItem(PrevItem); - } - addItem(item); - } else { - delete item; - item = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ITEMS definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ITEMS definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { - char *filenameCor = new char[strlen(filename) + 1]; - strcpy(filenameCor, filename); - for (uint32 i = 0; i < strlen(filenameCor); i++) { - if (filenameCor[i] == '/') filenameCor[i] = '\\'; - } - - for (int i = 0; i < _sceneStates.getSize(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { - delete [] filenameCor; - return _sceneStates[i]; - } - } - - if (saving) { - CAdSceneState *ret = new CAdSceneState(_gameRef); - ret->setFilename(filenameCor); - - _sceneStates.add(ret); - - delete [] filenameCor; - return ret; - } else { - delete [] filenameCor; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE_END - - int cmd = PARSERR_GENERIC; - CBParser parser(_gameRef); - - cmd = parser.getCommand(buffer, commands, params); - switch (cmd) { - case TOKEN_ENTITY_CONTAINER: { - CUIEntity *ent = new CUIEntity(_gameRef); - if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { - delete ent; - ent = NULL; - cmd = PARSERR_GENERIC; - } else { - ent->_parent = win; - win->_widgets.add(ent); - } - } - break; - } - - if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { - return STATUS_FAILED; - } - - return STATUS_OK; - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - if (strcmp(name, "CreateEntityContainer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIEntity *ent = new CUIEntity(_gameRef); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - - ent->_parent = win; - win->_widgets.add(ent); - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; - if (name) { - sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); - _dlgPendingBranches.add(name); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = NULL; - bool deleteName = false; - if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { - name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; - } else { - if (branchName != NULL) { - name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; - if (name) { - sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); - deleteName = true; - } - } - } - - if (name == NULL) return STATUS_OK; - - - int startIndex = -1; - for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { - if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { - startIndex = i; - break; - } - } - if (startIndex >= 0) { - for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { - //ClearBranchResponses(_dlgPendingBranches[i]); - delete [] _dlgPendingBranches[i]; - _dlgPendingBranches[i] = NULL; - } - _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); - } - - // dialogue is over, forget selected responses - if (_dlgPendingBranches.getSize() == 0) { - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - } - - if (deleteName) delete [] name; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::clearBranchResponses(char *name) { - for (int i = 0; i < _responsesBranch.getSize(); i++) { - if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.removeAt(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addBranchResponse(int ID) { - if (branchResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); - r->_iD = ID; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); - _responsesBranch.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::branchResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addGameResponse(int ID) { - if (gameResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); - r->_iD = ID; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); - _responsesGame.add(r); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::gameResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesGame.getSize(); i++) { - CAdResponseContext *RespContext = _responsesGame[i]; - if (RespContext->_iD == ID) { - if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetResponse(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - - int i; - - for (i = 0; i < _responsesGame.getSize(); i++) { - if (_responsesGame[i]->_iD == ID) { - if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { - delete _responsesGame[i]; - _responsesGame.removeAt(i); - break; - } - } - } - - for (i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { - delete _responsesBranch[i]; - _responsesBranch.removeAt(i); - break; - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayContent(bool doUpdate, bool displayAll) { - // init - if (doUpdate) initLoop(); - - // fill black - _renderer->fill(0, 0, 0); - if (!_editorMode) _renderer->setScreenViewport(); - - // playing exclusive video? - if (_videoPlayer->isPlaying()) { - if (doUpdate) _videoPlayer->update(); - _videoPlayer->display(); - } else if (_theoraPlayer) { - if (_theoraPlayer->isPlaying()) { - if (doUpdate) _theoraPlayer->update(); - _theoraPlayer->display(); - } - if (_theoraPlayer->isFinished()) { - delete _theoraPlayer; - _theoraPlayer = NULL; - } - } else { - - // process scripts - if (doUpdate) _scEngine->tick(); - - Point32 p; - getMousePos(&p); - - _scene->update(); - _scene->display(); - - - // display in-game windows - displayWindows(true); - if (_inventoryBox) _inventoryBox->display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); - if (_indicatorDisplay) displayIndicator(); - - - if (doUpdate || displayAll) { - // display normal windows - displayWindows(false); - - setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); - - // textual info - displaySentences(_state == GAME_FROZEN); - - showCursor(); - - if (_fader) _fader->display(); - _transMgr->update(); - } - - } - if (_loadingIcon) { - _loadingIcon->display(_loadingIconX, _loadingIconY); - if (!_loadingIconPersistent) { - delete _loadingIcon; - _loadingIcon = NULL; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::registerInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { - if (_inventories[i] == inv) return STATUS_OK; - } - registerObject(inv); - _inventories.add(inv); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::unregisterInventory(CAdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { - if (_inventories[i] == inv) { - unregisterObject(_inventories[i]); - _inventories.removeAt(i); - return STATUS_OK; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::isItemTaken(char *itemName) { - for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; - - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::getItemByName(const char *name) { - for (int i = 0; i < _items.getSize(); i++) { - if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addItem(CAdItem *item) { - _items.add(item); - return _gameRef->registerObject(item); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetContent() { - // clear pending dialogs - for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; - } - _dlgPendingBranches.removeAll(); - - - // clear inventories - for (int i = 0; i < _inventories.getSize(); i++) { - _inventories[i]->_takenItems.removeAll(); - } - - // clear scene states - for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; - _sceneStates.removeAll(); - - // clear once responses - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; - _responsesBranch.removeAll(); - - // clear once game responses - for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; - _responsesGame.removeAll(); - - // reload inventory items - if (_itemsFile) loadItemsFile(_itemsFile); - - _tempDisableSaveState = true; - - return CBGame::resetContent(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::deleteItem(CAdItem *item) { - if (!item) return STATUS_FAILED; - - if (_selectedItem == item) _selectedItem = NULL; - _scene->handleItemAssociations(item->_name, false); - - // remove from all inventories - for (int i = 0; i < _inventories.getSize(); i++) { - _inventories[i]->removeItem(item); - } - - // remove object - for (int i = 0; i < _items.getSize(); i++) { - if (_items[i] == item) { - unregisterObject(_items[i]); - _items.removeAt(i); - break; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::addSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; - - char *temp = new char[strlen(dir) + 2]; - strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') - strcat(temp, "\\"); - - for (int i = 0; i < _speechDirs.getSize(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] temp; - return STATUS_OK; - } - } - _speechDirs.add(temp); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; - - char *temp = new char[strlen(dir) + 2]; - strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') - strcat(temp, "\\"); - - bool Found = false; - for (int i = 0; i < _speechDirs.getSize(); i++) { - if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] _speechDirs[i]; - _speechDirs.removeAt(i); - Found = true; - break; - } - } - delete [] temp; - - if (Found) return STATUS_OK; - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdGame::findSpeechFile(char *stringID) { - char *ret = new char[MAX_PATH_LENGTH]; - - for (int i = 0; i < _speechDirs.getSize(); i++) { - sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile - if (file) { - _fileManager->closeFile(file); - return ret; - } - - sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - file = _fileManager->openFile(ret); - if (file) { - _fileManager->closeFile(file); - return ret; - } - } - delete [] ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::validMouse() { - Point32 pos; - CBPlatform::getCursorPos(&pos); - - return _renderer->pointInViewport(&pos); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDown() { - if (!validMouse()) return STATUS_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { - finishSentences(); - } - return STATUS_OK; - } - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; - _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDblClick() { - if (!validMouse()) return STATUS_OK; - - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightDown() { - if (!validMouse()) return STATUS_OK; - if (_state == GAME_RUNNING && !_interactive) { - if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { - finishSentences(); - } - return STATUS_OK; - } - - if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { - _scene->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayDebugInfo() { - char str[100]; - if (_gameRef->_debugDebugMode) { - sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); - _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - - sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); - } - return CBGame::displayDebugInfo(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdGame::onScriptShutdown(CScScript *script) { - if (_responseBox && _responseBox->_waitingScript == script) - _responseBox->_waitingScript = NULL; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdGame.h b/engines/wintermute/ad/AdGame.h deleted file mode 100644 index 4a89fa97d2..0000000000 --- a/engines/wintermute/ad/AdGame.h +++ /dev/null @@ -1,161 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_ADGAME_H -#define WINTERMUTE_ADGAME_H - -#include "engines/wintermute/ad/AdTypes.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { -class CAdItem; -class CAdInventory; -class CAdSceneState; -class CAdScene; -class CAdItem; -class CAdObject; -class CAdSentence; -class CAdInventoryBox; -class CAdResponseContext; -class CAdResponseBox; -class CAdGame : public CBGame { -public: - virtual bool onScriptShutdown(CScScript *script); - - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - - virtual bool displayDebugInfo(); - - - virtual bool initAfterLoad(); - static void afterLoadScene(void *scene, void *data); - - bool _smartItemCursor; - - CBArray _speechDirs; - bool addSpeechDir(const char *dir); - bool removeSpeechDir(const char *dir); - char *findSpeechFile(char *StringID); - - bool deleteItem(CAdItem *Item); - char *_itemsFile; - bool _tempDisableSaveState; - virtual bool resetContent(); - bool addItem(CAdItem *item); - CAdItem *getItemByName(const char *name); - CBArray _items; - CAdObject *_inventoryOwner; - bool isItemTaken(char *itemName); - bool registerInventory(CAdInventory *inv); - bool unregisterInventory(CAdInventory *inv); - - CAdObject *_invObject; - CBArray _inventories; - virtual bool displayContent(bool update = true, bool displayAll = false); - char *_debugStartupScene; - char *_startupScene; - bool _initialScene; - bool gameResponseUsed(int ID); - bool addGameResponse(int ID); - bool resetResponse(int ID); - - bool branchResponseUsed(int ID); - bool addBranchResponse(int ID); - bool clearBranchResponses(char *name); - bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - - CAdSceneState *getSceneState(const char *filename, bool saving); - CBViewport *_sceneViewport; - int _texItemLifeTime; - int _texWalkLifeTime; - int _texStandLifeTime; - int _texTalkLifeTime; - - TTalkSkipButton _talkSkipButton; - - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - bool scheduleChangeScene(const char *filename, bool fadeIn); - char *_scheduledScene; - bool _scheduledFadeIn; - void setPrevSceneName(const char *name); - void setPrevSceneFilename(const char *name); - char *_prevSceneName; - char *_prevSceneFilename; - virtual bool loadGame(const char *filename); - CAdItem *_selectedItem; - bool cleanup(); - DECLARE_PERSISTENT(CAdGame, CBGame) - - void finishSentences(); - bool showCursor(); - TGameStateEx _stateEx; - CAdResponseBox *_responseBox; - CAdInventoryBox *_inventoryBox; - bool displaySentences(bool frozen); - void addSentence(CAdSentence *sentence); - bool changeScene(const char *filename, bool fadeIn); - bool removeObject(CAdObject *object); - bool addObject(CAdObject *object); - CAdScene *_scene; - bool initLoop(); - CAdGame(); - virtual ~CAdGame(); - CBArray _objects; - CBArray _sentences; - - CBArray _sceneStates; - CBArray _dlgPendingBranches; - - CBArray _responsesBranch; - CBArray _responsesGame; - - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - - bool loadItemsFile(const char *filename, bool merge = false); - bool loadItemsBuffer(byte *buffer, bool merge = false); - - - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - bool validMouse(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdInventory.cpp b/engines/wintermute/ad/AdInventory.cpp deleted file mode 100644 index f913108404..0000000000 --- a/engines/wintermute/ad/AdInventory.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/AdInventory.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventory, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { - _scrollOffset = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventory::~CAdInventory() { - _takenItems.removeAll(); // ref only -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) return STATUS_FAILED; - - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); - if (item == NULL) return STATUS_FAILED; - - int insertIndex = -1; - for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - _takenItems.removeAt(i); - i--; - continue; - } - if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; - } - - - if (insertIndex == -1) _takenItems.add(item); - else _takenItems.insertAt(insertIndex, item); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(const char *name) { - if (name == NULL) return STATUS_FAILED; - - for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; - _takenItems.removeAt(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(CAdItem *item) { - if (item == NULL) return STATUS_FAILED; - - for (int i = 0; i < _takenItems.getSize(); i++) { - if (_takenItems[i] == item) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; - _takenItems.removeAt(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdInventory::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - _takenItems.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdInventory.h b/engines/wintermute/ad/AdInventory.h deleted file mode 100644 index cec76c03a0..0000000000 --- a/engines/wintermute/ad/AdInventory.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORY_H -#define WINTERMUTE_ADINVENTORY_H - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CAdItem; - -class CAdInventory : public CBObject { -public: - DECLARE_PERSISTENT(CAdInventory, CBObject) - bool removeItem(const char *name); - bool removeItem(CAdItem *Item); - bool insertItem(const char *name, const char *insertAfter = NULL); - CAdInventory(CBGame *inGame); - virtual ~CAdInventory(); - CBArray _takenItems; - int _scrollOffset; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdInventoryBox.cpp b/engines/wintermute/ad/AdInventoryBox.cpp deleted file mode 100644 index 9509bf9b10..0000000000 --- a/engines/wintermute/ad/AdInventoryBox.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdInventoryBox.h" -#include "engines/wintermute/ad/AdInventory.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/ui/UIButton.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/rect.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdInventoryBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { - _itemsArea.setEmpty(); - _scrollOffset = 0; - _spacing = 0; - _itemWidth = _itemHeight = 50; - _scrollBy = 1; - - _window = NULL; - _closeButton = NULL; - - _hideSelected = false; - - _visible = false; - _exclusive = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::~CAdInventoryBox() { - _gameRef->unregisterObject(_window); - _window = NULL; - - delete _closeButton; - _closeButton = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) { - _visible = false; - } else if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset -= _scrollBy; - _scrollOffset = MAX(_scrollOffset, 0); - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset += _scrollBy; - } else return CBObject::listen(param1, param2); - break; - default: - error("CAdInventoryBox::Listen - Unhandled enum"); - break; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::display() { - CAdGame *adGame = (CAdGame *)_gameRef; - - if (!_visible) return STATUS_OK; - - int itemsX, itemsY; - itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); - itemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); - - if (_window) { - _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); - } - - - if (_closeButton) { - _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = _gameRef->_renderer->_width; - _closeButton->_height = _gameRef->_renderer->_height; - - _closeButton->display(); - } - - - // display window - Rect32 rect = _itemsArea; - if (_window) { - rect.offsetRect(_window->_posX, _window->_posY); - _window->display(); - } - - // display items - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; - int yyy = rect.top; - for (int j = 0; j < itemsY; j++) { - int xxx = rect.left; - for (int i = 0; i < itemsX; i++) { - int itemIndex = _scrollOffset + j * itemsX + i; - if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { - CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; - if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { - item->update(); - item->display(xxx, yyy); - } - } - - xxx += (_itemWidth + _spacing); - } - yyy += (_itemHeight + _spacing); - } - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(INVENTORY_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(WINDOW) -TOKEN_DEF(EXCLUSIVE) -TOKEN_DEF(ALWAYS_VISIBLE) -TOKEN_DEF(AREA) -TOKEN_DEF(SPACING) -TOKEN_DEF(ITEM_WIDTH) -TOKEN_DEF(ITEM_HEIGHT) -TOKEN_DEF(SCROLL_BY) -TOKEN_DEF(NAME) -TOKEN_DEF(CAPTION) -TOKEN_DEF(HIDE_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(INVENTORY_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(EXCLUSIVE) - TOKEN_TABLE(ALWAYS_VISIBLE) - TOKEN_TABLE(AREA) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(ITEM_WIDTH) - TOKEN_TABLE(ITEM_HEIGHT) - TOKEN_TABLE(SCROLL_BY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(HIDE_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - bool always_visible = false; - - _exclusive = false; - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { - _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(_gameRef); - if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else _gameRef->registerObject(_window); - break; - - case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); - break; - - case TOKEN_EXCLUSIVE: - parser.scanStr((char *)params, "%b", &_exclusive); - break; - - case TOKEN_HIDE_SELECTED: - parser.scanStr((char *)params, "%b", &_hideSelected); - break; - - case TOKEN_ALWAYS_VISIBLE: - parser.scanStr((char *)params, "%b", &always_visible); - break; - - case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_ITEM_WIDTH: - parser.scanStr((char *)params, "%d", &_itemWidth); - break; - - case TOKEN_ITEM_HEIGHT: - parser.scanStr((char *)params, "%d", &_itemHeight); - break; - - case TOKEN_SCROLL_BY: - parser.scanStr((char *)params, "%d", &_scrollBy); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading INVENTORY_BOX definition"); - return STATUS_FAILED; - } - - if (_exclusive) { - delete _closeButton; - _closeButton = new CUIButton(_gameRef); - if (_closeButton) { - _closeButton->setName("close"); - _closeButton->setListener(this, _closeButton, 0); - _closeButton->_parent = _window; - } - } - - _visible = always_visible; - - if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "INVENTORY_BOX\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); - - buffer->putTextIndent(indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); - buffer->putTextIndent(indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); - buffer->putTextIndent(indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); - buffer->putTextIndent(indent + 2, "SCROLL_BY=%d\n", _scrollBy); - - buffer->putTextIndent(indent + 2, "\n"); - - // window - if (_window) _window->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_closeButton)); - persistMgr->transfer(TMEMBER(_hideSelected)); - persistMgr->transfer(TMEMBER(_itemHeight)); - persistMgr->transfer(TMEMBER(_itemsArea)); - persistMgr->transfer(TMEMBER(_itemWidth)); - persistMgr->transfer(TMEMBER(_scrollBy)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_window)); - persistMgr->transfer(TMEMBER(_exclusive)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdInventoryBox.h b/engines/wintermute/ad/AdInventoryBox.h deleted file mode 100644 index cfd8d74021..0000000000 --- a/engines/wintermute/ad/AdInventoryBox.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADINVENTORYBOX_H -#define WINTERMUTE_ADINVENTORYBOX_H - -#include "engines/wintermute/base/BObject.h" -#include "common/rect.h" - -namespace WinterMute { -class CUIButton; -class CUIWindow; - -class CAdInventoryBox : public CBObject { -public: - bool _hideSelected; - DECLARE_PERSISTENT(CAdInventoryBox, CBObject) - bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; - bool _visible; - virtual bool display(); - CUIButton *_closeButton; - int _spacing; - int _scrollOffset; - Rect32 _itemsArea; - bool listen(CBScriptHolder *param1, uint32 param2); - CUIWindow *_window; - CAdInventoryBox(CBGame *inGame); - virtual ~CAdInventoryBox(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdItem.cpp b/engines/wintermute/ad/AdItem.cpp deleted file mode 100644 index 0e443d5c3e..0000000000 --- a/engines/wintermute/ad/AdItem.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdItem, false) - -////////////////////////////////////////////////////////////////////////// -CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { - _spriteHover = NULL; - _cursorNormal = _cursorHover = NULL; - - _cursorCombined = true; - _inInventory = false; - - _displayAmount = false; - _amount = 0; - _amountOffsetX = 0; - _amountOffsetY = 0; - _amountAlign = TAL_RIGHT; - _amountString = NULL; - - _state = STATE_READY; - - _movable = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdItem::~CAdItem() { - delete _spriteHover; - delete _cursorNormal; - delete _cursorHover; - _spriteHover = NULL; - _cursorNormal = NULL; - _cursorHover = NULL; - - delete[] _amountString; - _amountString = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ITEM) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(CURSOR_HOVER) -TOKEN_DEF(CURSOR_COMBINED) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(FONT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TALK_SPECIAL) -TOKEN_DEF(TALK) -TOKEN_DEF(SPRITE_HOVER) -TOKEN_DEF(SPRITE) -TOKEN_DEF(DISPLAY_AMOUNT) -TOKEN_DEF(AMOUNT_OFFSET_X) -TOKEN_DEF(AMOUNT_OFFSET_Y) -TOKEN_DEF(AMOUNT_ALIGN) -TOKEN_DEF(AMOUNT_STRING) -TOKEN_DEF(AMOUNT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ITEM) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(CURSOR_HOVER) - TOKEN_TABLE(CURSOR_COMBINED) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(FONT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TALK_SPECIAL) - TOKEN_TABLE(TALK) - TOKEN_TABLE(SPRITE_HOVER) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(DISPLAY_AMOUNT) - TOKEN_TABLE(AMOUNT_OFFSET_X) - TOKEN_TABLE(AMOUNT_OFFSET_Y) - TOKEN_TABLE(AMOUNT_ALIGN) - TOKEN_TABLE(AMOUNT_STRING) - TOKEN_TABLE(AMOUNT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { - _gameRef->LOG(0, "'ITEM' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int ar = 0, ag = 0, ab = 0, alpha = 255; - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_FONT: - SetFont((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_IMAGE: - case TOKEN_SPRITE: - delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _sprite; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - case TOKEN_SPRITE_HOVER: - delete _spriteHover; - _spriteHover = new CBSprite(_gameRef, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _spriteHover; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_AMOUNT: - parser.scanStr((char *)params, "%d", &_amount); - break; - - case TOKEN_DISPLAY_AMOUNT: - parser.scanStr((char *)params, "%b", &_displayAmount); - break; - - case TOKEN_AMOUNT_OFFSET_X: - parser.scanStr((char *)params, "%d", &_amountOffsetX); - break; - - case TOKEN_AMOUNT_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_amountOffsetY); - break; - - case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; - else _amountAlign = TAL_CENTER; - break; - - case TOKEN_AMOUNT_STRING: - CBUtils::setString(&_amountString, (char *)params); - break; - - case TOKEN_TALK: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); - } - break; - - case TOKEN_TALK_SPECIAL: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); - } - break; - - case TOKEN_CURSOR: - delete _cursorNormal; - _cursorNormal = new CBSprite(_gameRef); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _cursorNormal; - _cursorNormal = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_HOVER: - delete _cursorHover; - _cursorHover = new CBSprite(_gameRef); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { - delete _cursorHover; - _cursorHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_COMBINED: - parser.scanStr((char *)params, "%b", &_cursorCombined); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ITEM definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ITEM definition"); - return STATUS_FAILED; - } - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::update() { - _currentSprite = NULL; - - if (_state == STATE_READY && _animSprite) { - delete _animSprite; - _animSprite = NULL; - } - - // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { - _state = STATE_READY; - _currentSprite = _animSprite; - } - - if (_sentence && _state != STATE_TALKING) _sentence->finish(); - - // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; - - switch (_state) { - ////////////////////////////////////////////////////////////////////////// - case STATE_PLAYING_ANIM: - _currentSprite = _animSprite; - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_READY: - if (!_animSprite) { - if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; - else _currentSprite = _sprite; - } - break; - - ////////////////////////////////////////////////////////////////////////// - case STATE_TALKING: { - _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; - - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { - _sentence->finish(); - _tempSprite2 = NULL; - _state = STATE_READY; - } else { - _tempSprite2 = getTalkStance(_sentence->getNextStance()); - if (_tempSprite2) { - _tempSprite2->reset(); - _currentSprite = _tempSprite2; - } - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } else { - _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); - } - } - default: - break; - } - _ready = (_state == STATE_READY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::display(int x, int y) { - int width = 0; - if (_currentSprite) { - Rect32 rc; - _currentSprite->getBoundingRect(&rc, 0, 0); - width = rc.width(); - } - - _posX = x + width / 2; - _posY = y; - - bool ret; - if (_currentSprite) - ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); - else ret = STATUS_OK; - - if (_displayAmount) { - int amountX = x; - int amountY = y + _amountOffsetY; - - if (_amountAlign == TAL_RIGHT) { - width -= _amountOffsetX; - amountX -= _amountOffsetX; - } - amountX += _amountOffsetX; - - CBFont *font = _font ? _font : _gameRef->_systemFont; - if (font) { - if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); - else { - char Str[256]; - sprintf(Str, "%d", _amount); - font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); - } - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetHoverSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetHoverSprite") == 0) { - stack->correctParams(1); - - bool setCurrent = false; - if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; - - const char *filename = stack->pop()->getString(); - - delete _spriteHover; - _spriteHover = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); - } else { - _spriteHover = spr; - if (setCurrent) _currentSprite = _spriteHover; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverSprite") == 0) { - stack->correctParams(0); - - if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); - else stack->pushString(_spriteHover->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverSpriteObject") == 0) { - stack->correctParams(0); - if (!_spriteHover) stack->pushNULL(); - else stack->pushNative(_spriteHover, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetNormalCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetNormalCursor") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - delete _cursorNormal; - _cursorNormal = NULL; - CBSprite *spr = new CBSprite(_gameRef); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); - } else { - _cursorNormal = spr; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNormalCursor") == 0) { - stack->correctParams(0); - - if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); - else stack->pushString(_cursorNormal->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNormalCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNormalCursorObject") == 0) { - stack->correctParams(0); - - if (!_cursorNormal) stack->pushNULL(); - else stack->pushNative(_cursorNormal, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverCursor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetHoverCursor") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - delete _cursorHover; - _cursorHover = NULL; - CBSprite *spr = new CBSprite(_gameRef); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); - } else { - _cursorHover = spr; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverCursor") == 0) { - stack->correctParams(0); - - if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); - else stack->pushString(_cursorHover->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverCursorObject") == 0) { - stack->correctParams(0); - - if (!_cursorHover) stack->pushNULL(); - else stack->pushNative(_cursorHover, true); - return STATUS_OK; - } - - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("item"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayAmount") == 0) { - _scValue->setBool(_displayAmount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Amount") == 0) { - _scValue->setInt(_amount); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetX") == 0) { - _scValue->setInt(_amountOffsetX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetY") == 0) { - _scValue->setInt(_amountOffsetY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountAlign") == 0) { - _scValue->setInt(_amountAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountString") == 0) { - if (!_amountString) _scValue->setNULL(); - else _scValue->setString(_amountString); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { - _scValue->setBool(_cursorCombined); - return _scValue; - } - - else return CAdTalkHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayAmount") == 0) { - _displayAmount = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Amount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Amount") == 0) { - _amount = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetX") == 0) { - _amountOffsetX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountOffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetY") == 0) { - _amountOffsetY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountAlign") == 0) { - _amountAlign = (TTextAlign)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AmountString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountString") == 0) { - if (value->isNULL()) { - delete[] _amountString; - _amountString = NULL; - } else { - CBUtils::setString(&_amountString, value->getString()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorCombined - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { - _cursorCombined = value->getBool(); - return STATUS_OK; - } - - else return CAdTalkHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdItem::scToString() { - return "[item]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::persist(CBPersistMgr *persistMgr) { - - CAdTalkHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_cursorCombined)); - persistMgr->transfer(TMEMBER(_cursorHover)); - persistMgr->transfer(TMEMBER(_cursorNormal)); - persistMgr->transfer(TMEMBER(_spriteHover)); - persistMgr->transfer(TMEMBER(_inInventory)); - persistMgr->transfer(TMEMBER(_displayAmount)); - persistMgr->transfer(TMEMBER(_amount)); - persistMgr->transfer(TMEMBER(_amountOffsetX)); - persistMgr->transfer(TMEMBER(_amountOffsetY)); - persistMgr->transfer(TMEMBER_INT(_amountAlign)); - persistMgr->transfer(TMEMBER(_amountString)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdItem::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - else return CAdObject::getExtendedFlag(flagName); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdItem.h b/engines/wintermute/ad/AdItem.h deleted file mode 100644 index d45f9cc614..0000000000 --- a/engines/wintermute/ad/AdItem.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADITEM_H -#define WINTERMUTE_ADITEM_H - - -#include "engines/wintermute/ad/AdTalkHolder.h" - -namespace WinterMute { - -class CAdItem : public CAdTalkHolder { -public: - bool _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; - TTextAlign _amountAlign; - char *_amountString; - - - bool update(); - DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) - bool display(int x, int y); - bool getExtendedFlag(const char *flagName); - bool _inInventory; - bool _cursorCombined; - CBSprite *_spriteHover; - CBSprite *_cursorNormal; - CBSprite *_cursorHover; - CAdItem(CBGame *inGame); - virtual ~CAdItem(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdLayer.cpp b/engines/wintermute/ad/AdLayer.cpp deleted file mode 100644 index 4549ba4af7..0000000000 --- a/engines/wintermute/ad/AdLayer.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/ad/AdLayer.h" -#include "engines/wintermute/ad/AdSceneNode.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdLayer, false) - -////////////////////////////////////////////////////////////////////////// -CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { - _main = false; - _width = _height = 0; - _active = true; - _closeUp = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdLayer::~CAdLayer() { - for (int i = 0; i < _nodes.getSize(); i++) - delete _nodes[i]; - _nodes.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(LAYER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(MAIN) -TOKEN_DEF(ENTITY) -TOKEN_DEF(REGION) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(CLOSE_UP) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(MAIN) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(REGION) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(CLOSE_UP) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { - _gameRef->LOG(0, "'LAYER' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_MAIN: - parser.scanStr((char *)params, "%b", &_main); - break; - - case TOKEN_CLOSE_UP: - parser.scanStr((char *)params, "%b", &_closeUp); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_REGION: { - CAdRegion *region = new CAdRegion(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete region; - delete node; - region = NULL; - node = NULL; - } else { - node->setRegion(region); - _nodes.add(node); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (entity) entity->_zoomable = false; // scene entites default to NOT zoom - if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - delete node; - entity = NULL; - node = NULL; - } else { - node->setEntity(entity); - _nodes.add(node); - } - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in LAYER definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - int node = -1; - - if (val->_type == VAL_INT) node = val->getInt(); - else { // get by name - for (int i = 0; i < _nodes.getSize(); i++) { - if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || - (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { - node = i; - break; - } - } - } - - if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); - else { - switch (_nodes[node]->_type) { - case OBJECT_ENTITY: - stack->pushNative(_nodes[node]->_entity, true); - break; - case OBJECT_REGION: - stack->pushNative(_nodes[node]->_region, true); - break; - default: - stack->pushNULL(); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddRegion / AddEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (strcmp(name, "AddRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); - node->setRegion(region); - stack->pushNative(region, true); - } else { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); - node->setEntity(entity); - stack->pushNative(entity, true); - } - _nodes.add(node); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertRegion / InsertEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - CAdSceneNode *node = new CAdSceneNode(_gameRef); - if (strcmp(name, "InsertRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); - node->setRegion(region); - stack->pushNative(region, true); - } else { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); - node->setEntity(entity); - stack->pushNative(entity, true); - } - if (index < 0) index = 0; - if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); - else _nodes.add(node); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdSceneNode *toDelete = NULL; - if (val->isNative()) { - CBScriptable *temp = val->getNative(); - for (int i = 0; i < _nodes.getSize(); i++) { - if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { - toDelete = _nodes[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < _nodes.getSize()) { - toDelete = _nodes[index]; - } - } - if (toDelete == NULL) { - stack->pushBool(false); - return STATUS_OK; - } - - for (int i = 0; i < _nodes.getSize(); i++) { - if (_nodes[i] == toDelete) { - delete _nodes[i]; - _nodes[i] = NULL; - _nodes.removeAt(i); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("layer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumNodes") == 0) { - _scValue->setInt(_nodes.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Main (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Main") == 0) { - _scValue->setBool(_main); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CloseUp") == 0) { - _scValue->setBool(_closeUp); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CloseUp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CloseUp") == 0) { - _closeUp = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - if (_width < 0) _width = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - if (_height < 0) _height = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - bool b = value->getBool(); - if (b == false && _main) { - _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); - } else _active = b; - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdLayer::scToString() { - return "[layer]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "LAYER {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_closeUp) - buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - for (i = 0; i < _nodes.getSize(); i++) { - switch (_nodes[i]->_type) { - case OBJECT_ENTITY: - _nodes[i]->_entity->saveAsText(buffer, indent + 2); - break; - case OBJECT_REGION: - _nodes[i]->_region->saveAsText(buffer, indent + 2); - break; - default: - error("CAdLayer::SaveAsText - Unhandled enum"); - break; - } - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdLayer::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_closeUp)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_main)); - _nodes.persist(persistMgr); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdLayer.h b/engines/wintermute/ad/AdLayer.h deleted file mode 100644 index 0ccdb13ae7..0000000000 --- a/engines/wintermute/ad/AdLayer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADLAYER_H -#define WINTERMUTE_ADLAYER_H - -namespace WinterMute { -class CAdSceneNode; -class CAdLayer : public CBObject { -public: - bool _closeUp; - DECLARE_PERSISTENT(CAdLayer, CBObject) - bool _active; - int _height; - int _width; - bool _main; - CAdLayer(CBGame *inGame); - virtual ~CAdLayer(); - CBArray _nodes; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdNodeState.cpp b/engines/wintermute/ad/AdNodeState.cpp deleted file mode 100644 index fd72a356c5..0000000000 --- a/engines/wintermute/ad/AdNodeState.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/ad/AdNodeState.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdNodeState, false) - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { - _name = NULL; - _active = false; - for (int i = 0; i < 7; i++) _caption[i] = NULL; - _alphaColor = 0; - _filename = NULL; - _cursor = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState::~CAdNodeState() { - delete[] _name; - delete[] _filename; - delete[] _cursor; - _name = NULL; - _filename = NULL; - _cursor = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setName(const char *name) { - delete[] _name; - _name = NULL; - CBUtils::setString(&_name, name); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setFilename(const char *filename) { - delete[] _filename; - _filename = NULL; - CBUtils::setString(&_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCursor(const char *filename) { - delete[] _cursor; - _cursor = NULL; - CBUtils::setString(&_cursor, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCaption(const char *caption, int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7) return; - - delete[] _caption[caseVal- 1]; - _caption[caseVal- 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal- 1]) { - strcpy(_caption[caseVal- 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal- 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::getCaption(int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; - else return _caption[caseVal- 1]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { - if (!entity) return STATUS_FAILED; - - // hack! - if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; - - if (saving) { - for (int i = 0; i < 7; i++) { - if (entity->_caption[i]) setCaption(entity->_caption[i], i); - } - if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { - if (includingSprites) setFilename(entity->_sprite->_filename); - else setFilename(""); - } - if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); - _alphaColor = entity->_alphaColor; - _active = entity->_active; - } else { - for (int i = 0; i < 7; i++) { - if (_caption[i]) entity->setCaption(_caption[i], i); - } - if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { - if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) - entity->setSprite(_filename); - } - if (_cursor) { - if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) - entity->setCursor(_cursor); - } - - entity->_active = _active; - entity->_alphaColor = _alphaColor; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdNodeState.h b/engines/wintermute/ad/AdNodeState.h deleted file mode 100644 index 186f2ebbb2..0000000000 --- a/engines/wintermute/ad/AdNodeState.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADNODESTATE_H -#define WINTERMUTE_ADNODESTATE_H - -namespace WinterMute { - -class CAdEntity; - -class CAdNodeState : public CBBase { -public: - bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); - void setName(const char *name); - void setFilename(const char *filename); - void setCursor(const char *filename); - DECLARE_PERSISTENT(CAdNodeState, CBBase) - CAdNodeState(CBGame *inGame); - virtual ~CAdNodeState(); - char *_name; - bool _active; - char *_caption[7]; - void setCaption(const char *caption, int caseVal); - char *getCaption(int caseVal); - uint32 _alphaColor; - char *_filename; - char *_cursor; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdObject.cpp b/engines/wintermute/ad/AdObject.cpp deleted file mode 100644 index c74c8cf6b3..0000000000 --- a/engines/wintermute/ad/AdObject.cpp +++ /dev/null @@ -1,1203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/ad/AdObject.h" -#include "engines/wintermute/ad/AdInventory.h" -#include "engines/wintermute/ad/AdLayer.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/ad/AdSceneNode.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "common/str.h" -#include "common/util.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdObject, false) - -////////////////////////////////////////////////////////////////////////// -CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _state = _nextState = STATE_NONE; - - _active = true; - _drawn = false; - - _currentSprite = NULL; - _animSprite = NULL; - _tempSprite2 = NULL; - - _font = NULL; - - _sentence = NULL; - - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - - _blockRegion = NULL; - _wptGroup = NULL; - - _currentBlockRegion = NULL; - _currentWptGroup = NULL; - - _ignoreItems = false; - _sceneIndependent = false; - - _stickRegion = NULL; - - _subtitlesModRelative = true; - _subtitlesModX = 0; - _subtitlesModY = 0; - _subtitlesWidth = 0; - _subtitlesModXCenter = true; - - _inventory = NULL; - - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - - _partEmitter = NULL; - _partFollowParent = false; - _partOffsetX = _partOffsetY = 0; - - _registerAlias = this; -} - - -////////////////////////////////////////////////////////////////////////// -CAdObject::~CAdObject() { - _currentSprite = NULL; // reference only, don't delete - delete _animSprite; - _animSprite = NULL; - delete _sentence; - _sentence = NULL; - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - - delete _blockRegion; - _blockRegion = NULL; - delete _wptGroup; - _wptGroup = NULL; - - delete _currentBlockRegion; - _currentBlockRegion = NULL; - delete _currentWptGroup; - _currentWptGroup = NULL; - - _tempSprite2 = NULL; // reference only - _stickRegion = NULL; - - if (_font) _gameRef->_fontStorage->removeFont(_font); - - if (_inventory) { - ((CAdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; - } - - if (_partEmitter) - _gameRef->unregisterObject(_partEmitter); - - - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - _gameRef->unregisterObject(_attachmentsPre[i]); - } - _attachmentsPre.removeAll(); - - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - _gameRef->unregisterObject(_attachmentsPost[i]); - } - _attachmentsPost.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::playAnim(const char *filename) { - delete _animSprite; - _animSprite = NULL; - _animSprite = new CBSprite(_gameRef, this); - if (!_animSprite) { - _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); - return STATUS_FAILED; - } - bool res = _animSprite->loadFile(filename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); - delete _animSprite; - _animSprite = NULL; - return res; - } - _state = STATE_PLAYING_ANIM; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::display() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::update() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // PlayAnim / PlayAnimAsync - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { - stack->correctParams(1); - if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); - else { - if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsTalking") == 0) { - stack->correctParams(0); - stack->pushBool(_state == STATE_TALKING); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopTalk / StopTalking - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { - stack->correctParams(0); - if (_sentence) _sentence->finish(); - if (_state == STATE_TALKING) { - _state = _nextState; - _nextState = STATE_READY; - stack->pushBool(true); - } else stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ForceTalkAnim - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ForceTalkAnim") == 0) { - stack->correctParams(1); - const char *animName = stack->pop()->getString(); - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = new char[strlen(animName) + 1]; - strcpy(_forcedTalkAnimName, animName); - _forcedTalkAnimUsed = false; - stack->pushBool(true); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Talk / TalkAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { - stack->correctParams(5); - - const char *text = stack->pop()->getString(); - CScValue *soundVal = stack->pop(); - int duration = stack->pop()->getInt(); - CScValue *valStances = stack->pop(); - - const char *stances = valStances->isNULL() ? NULL : valStances->getString(); - - int align = 0; - CScValue *val = stack->pop(); - if (val->isNULL()) align = TAL_CENTER; - else align = val->getInt(); - - align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); - - const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); - - talk(text, sound, duration, stances, (TTextAlign)align); - if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StickToRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StickToRegion") == 0) { - stack->correctParams(1); - - CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; - bool regFound = false; - - int i; - CScValue *val = stack->pop(); - if (val->isNULL() || !main) { - _stickRegion = NULL; - regFound = true; - } else if (val->isString()) { - const char *regionName = val->getString(); - for (i = 0; i < main->_nodes.getSize(); i++) { - if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { - _stickRegion = main->_nodes[i]->_region; - regFound = true; - break; - } - } - } else if (val->isNative()) { - CBScriptable *obj = val->getNative(); - - for (i = 0; i < main->_nodes.getSize(); i++) { - if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { - _stickRegion = main->_nodes[i]->_region; - regFound = true; - break; - } - } - - } - - if (!regFound) _stickRegion = NULL; - stack->pushBool(regFound); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (val->isNULL()) SetFont(NULL); - else SetFont(val->getString()); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFont") == 0) { - stack->correctParams(0); - if (_font && _font->_filename) stack->pushString(_font->_filename); - else stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TakeItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TakeItem") == 0) { - stack->correctParams(2); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - const char *itemName = val->getString(); - val = stack->pop(); - const char *insertAfter = val->isNULL() ? NULL : val->getString(); - if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); - else { - // hide associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); - } - - } else script->runtimeError("TakeItem: item name expected"); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DropItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DropItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); - else { - // show associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); - } - } else script->runtimeError("DropItem: item name expected"); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); - if (item) stack->pushNative(item, true); - else stack->pushNULL(); - } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) - stack->pushNULL(); - else - stack->pushNative(_inventory->_takenItems[val->getInt()], true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasItem - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasItem") == 0) { - stack->correctParams(1); - - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - - CScValue *val = stack->pop(); - if (!val->isNULL()) { - for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { - if (val->getNative() == _inventory->_takenItems[i]) { - stack->pushBool(true); - return STATUS_OK; - } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { - stack->pushBool(true); - return STATUS_OK; - } - } - } else script->runtimeError("HasItem: item name expected"); - - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateParticleEmitter") == 0) { - stack->correctParams(3); - bool followParent = stack->pop()->getBool(); - int offsetX = stack->pop()->getInt(); - int offsetY = stack->pop()->getInt(); - - CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); - if (emitter) stack->pushNative(_partEmitter, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteParticleEmitter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteParticleEmitter") == 0) { - stack->correctParams(0); - if (_partEmitter) { - _gameRef->unregisterObject(_partEmitter); - _partEmitter = NULL; - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddAttachment") == 0) { - stack->correctParams(4); - const char *filename = stack->pop()->getString(); - bool preDisplay = stack->pop()->getBool(true); - int offsetX = stack->pop()->getInt(); - int offsetY = stack->pop()->getInt(); - - bool res; - CAdEntity *ent = new CAdEntity(_gameRef); - if (DID_FAIL(res = ent->loadFile(filename))) { - delete ent; - ent = NULL; - script->runtimeError("AddAttachment() failed loading entity '%s'", filename); - stack->pushBool(false); - } else { - _gameRef->registerObject(ent); - - ent->_posX = offsetX; - ent->_posY = offsetY; - ent->_active = true; - - if (preDisplay) _attachmentsPre.add(ent); - else _attachmentsPost.add(ent); - - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveAttachment") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - bool found = false; - if (val->isNative()) { - CBScriptable *obj = val->getNative(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i] == obj) { - found = true; - _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); - i--; - } - } - } else { - const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - found = true; - _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); - i--; - } - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - found = true; - _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); - i--; - } - } - } - stack->pushBool(found); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetAttachment - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAttachment") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - int currIndex = 0; - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPre[i]; - currIndex++; - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPost[i]; - currIndex++; - } - } else { - const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { - ret = _attachmentsPre[i]; - break; - } - } - if (!ret) { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { - ret = _attachmentsPre[i]; - break; - } - } - } - } - - if (ret != NULL) stack->pushNative(ret, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IgnoreItems") == 0) { - _scValue->setBool(_ignoreItems); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SceneIndependent") == 0) { - _scValue->setBool(_sceneIndependent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesWidth") == 0) { - _scValue->setInt(_subtitlesWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _scValue->setBool(_subtitlesModRelative); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosX") == 0) { - _scValue->setInt(_subtitlesModX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosY") == 0) { - _scValue->setInt(_subtitlesModY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _scValue->setBool(_subtitlesModXCenter); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumItems (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { - _scValue->setInt(getInventory()->_takenItems.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParticleEmitter (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParticleEmitter") == 0) { - if (_partEmitter) _scValue->setNative(_partEmitter, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumAttachments (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumAttachments") == 0) { - _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); - return _scValue; - } - - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::scSetProperty(const char *name, CScValue *value) { - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IgnoreItems - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IgnoreItems") == 0) { - _ignoreItems = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SceneIndependent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SceneIndependent") == 0) { - _sceneIndependent = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesWidth") == 0) { - _subtitlesWidth = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosRelative - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosRelative") == 0) { - _subtitlesModRelative = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosX") == 0) { - _subtitlesModX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosY") == 0) { - _subtitlesModY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesPosXCenter - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosXCenter") == 0) { - _subtitlesModXCenter = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdObject::scToString() { - return "[ad object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::SetFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (filename) { - _font = _gameRef->_fontStorage->addFont(filename); - return _font == NULL ? STATUS_FAILED : STATUS_OK; - } else { - _font = NULL; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CAdObject::getHeight() { - if (!_currentSprite) return 0; - else { - CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; - int ret = 0; - for (int i = 0; i < frame->_subframes.getSize(); i++) { - ret = MAX(ret, frame->_subframes[i]->_hotspotY); - } - - if (_zoomable) { - float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); - ret = (int)(ret * zoom / 100); - } - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { - if (!_sentence) _sentence = new CAdSentence(_gameRef); - if (!_sentence) return; - - if (_forcedTalkAnimName && _forcedTalkAnimUsed) { - delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; - _forcedTalkAnimUsed = false; - } - - delete(_sentence->_sound); - _sentence->_sound = NULL; - - _sentence->setText(text); - _gameRef->_stringTable->expand(&_sentence->_text); - _sentence->setStances(stances); - _sentence->_duration = duration; - _sentence->_align = Align; - _sentence->_startTime = _gameRef->_timer; - _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; - _sentence->_freezable = _freezable; - - // try to locate speech file automatically - bool deleteSound = false; - if (!sound) { - char *key = _gameRef->_stringTable->getKey(text); - if (key) { - sound = ((CAdGame *)_gameRef)->findSpeechFile(key); - delete [] key; - - if (sound) deleteSound = true; - } - } - - // load sound and set duration appropriately - if (sound) { - CBSound *snd = new CBSound(_gameRef); - if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { - _sentence->setSound(snd); - if (_sentence->_duration <= 0) { - uint32 Length = snd->getLength(); - if (Length != 0) _sentence->_duration = Length; - } - } else delete snd; - } - - // set duration by text length - if (_sentence->_duration <= 0) {// TODO: Avoid longs. - _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); - } - - - int x, y, width, height; - - x = _posX; - y = _posY; - - if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - - if (_subtitlesWidth > 0) width = _subtitlesWidth; - else { - if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { - width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); - } else width = _gameRef->_renderer->_width / 2; - } - - height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); - - y = y - height - getHeight() - 5; - if (_subtitlesModRelative) { - x += _subtitlesModX; - y += _subtitlesModY; - } else { - x = _subtitlesModX; - y = _subtitlesModY; - } - if (_subtitlesModXCenter) - x = x - width / 2; - - - x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); - y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); - - _sentence->_width = width; - - - _sentence->_pos.x = x; - _sentence->_pos.y = y; - - - if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - _sentence->_fixedPos = !_subtitlesModRelative; - - - _sentence->setupTalkFile(sound); - - _state = STATE_TALKING; - - if (deleteSound) delete [] sound; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::reset() { - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { - delete _animSprite; - _animSprite = NULL; - } else if (_state == STATE_TALKING && _sentence) { - _sentence->finish(); - } - - _state = _nextState = STATE_READY; - - _gameRef->_scEngine->resetObject(this); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blockRegion)); - persistMgr->transfer(TMEMBER(_currentBlockRegion)); - persistMgr->transfer(TMEMBER(_currentWptGroup)); - persistMgr->transfer(TMEMBER(_currentSprite)); - persistMgr->transfer(TMEMBER(_drawn)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_ignoreItems)); - persistMgr->transfer(TMEMBER_INT(_nextState)); - persistMgr->transfer(TMEMBER(_sentence)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_animSprite)); - persistMgr->transfer(TMEMBER(_sceneIndependent)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); - persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); - persistMgr->transfer(TMEMBER(_tempSprite2)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_wptGroup)); - persistMgr->transfer(TMEMBER(_stickRegion)); - persistMgr->transfer(TMEMBER(_subtitlesModRelative)); - persistMgr->transfer(TMEMBER(_subtitlesModX)); - persistMgr->transfer(TMEMBER(_subtitlesModY)); - persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); - persistMgr->transfer(TMEMBER(_subtitlesWidth)); - persistMgr->transfer(TMEMBER(_inventory)); - persistMgr->transfer(TMEMBER(_partEmitter)); - - for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); - - _attachmentsPre.persist(persistMgr); - _attachmentsPost.persist(persistMgr); - persistMgr->transfer(TMEMBER(_registerAlias)); - - persistMgr->transfer(TMEMBER(_partFollowParent)); - persistMgr->transfer(TMEMBER(_partOffsetX)); - persistMgr->transfer(TMEMBER(_partOffsetY)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSounds() { - if (_sentence && _sentence->_sound) - updateOneSound(_sentence->_sound); - - return CBObject::updateSounds(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::resetSoundPan() { - if (_sentence && _sentence->_sound) { - _sentence->_sound->setPan(0.0f); - } - return CBObject::resetSoundPan(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - - else return CBObject::getExtendedFlag(flagName); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { - if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); - - CBBase::saveAsText(buffer, indent + 2); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateBlockRegion() { - CAdGame *adGame = (CAdGame *)_gameRef; - if (adGame->_scene) { - if (_blockRegion && _currentBlockRegion) - _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); - - if (_wptGroup && _currentWptGroup) - _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CAdInventory *CAdObject::getInventory() { - if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); - } - return _inventory; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::afterMove() { - CAdRegion *newRegions[MAX_NUM_REGIONS]; - - ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (!newRegions[i]) break; - bool regFound = false; - for (int j = 0; j < MAX_NUM_REGIONS; j++) { - if (_currentRegions[j] == newRegions[i]) { - _currentRegions[j] = NULL; - regFound = true; - break; - } - } - if (!regFound) newRegions[i]->applyEvent("ActorEntry"); - } - - for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) { - _currentRegions[i]->applyEvent("ActorLeave"); - } - _currentRegions[i] = newRegions[i]; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::invalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::getScale(float *scaleX, float *scaleY) { - if (_zoomable) { - if (_scaleX >= 0 || _scaleY >= 0) { - *scaleX = _scaleX < 0 ? 100 : _scaleX; - *scaleY = _scaleY < 0 ? 100 : _scaleY; - } else if (_scale >= 0) *scaleX = *scaleY = _scale; - else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; - } else { - *scaleX = *scaleY = 100; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSpriteAttachments() { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - _attachmentsPre[i]->update(); - } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - _attachmentsPost[i]->update(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachments(bool preDisplay) { - if (preDisplay) { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { - displaySpriteAttachment(_attachmentsPre[i]); - } - } else { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { - displaySpriteAttachment(_attachmentsPost[i]); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { - if (!attachment->_active) return STATUS_OK; - - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - int origX = attachment->_posX; - int origY = attachment->_posY; - - // inherit position from owner - attachment->_posX = (int)(this->_posX + attachment->_posX * scaleX / 100.0f); - attachment->_posY = (int)(this->_posY + attachment->_posY * scaleY / 100.0f); - - // inherit other props - attachment->_alphaColor = this->_alphaColor; - attachment->_blendMode = this->_blendMode; - - attachment->_scale = this->_scale; - attachment->_relativeScale = this->_relativeScale; - attachment->_scaleX = this->_scaleX; - attachment->_scaleY = this->_scaleY; - - attachment->_rotate = this->_rotate; - attachment->_relativeRotate = this->_relativeRotate; - attachment->_rotateValid = this->_rotateValid; - - attachment->_registerAlias = this; - attachment->_registrable = this->_registrable; - - bool ret = attachment->display(); - - attachment->_posX = origX; - attachment->_posY = origY; - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { - _partFollowParent = followParent; - _partOffsetX = offsetX; - _partOffsetY = offsetY; - - if (!_partEmitter) { - _partEmitter = new CPartEmitter(_gameRef, this); - if (_partEmitter) { - _gameRef->registerObject(_partEmitter); - } - } - updatePartEmitter(); - return _partEmitter; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdObject::updatePartEmitter() { - if (!_partEmitter) return STATUS_FAILED; - - if (_partFollowParent) { - float scaleX, scaleY; - getScale(&scaleX, &scaleY); - - _partEmitter->_posX = (int)(_posX + (scaleX / 100.0f) * _partOffsetX); - _partEmitter->_posY = (int)(_posY + (scaleY / 100.0f) * _partOffsetY); - } - return _partEmitter->update(); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdObject.h b/engines/wintermute/ad/AdObject.h deleted file mode 100644 index d662e84729..0000000000 --- a/engines/wintermute/ad/AdObject.h +++ /dev/null @@ -1,123 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADOBJECT_H -#define WINTERMUTE_ADOBJECT_H - -#include "engines/wintermute/ad/AdTypes.h" -#include "engines/wintermute/base/particles/PartEmitter.h" - -namespace WinterMute { - -class CAdWaypointGroup; -class CAdRegion; -class CAdSentence; -class CBFont; -class CBRegion; -class CAdInventory; - -#define MAX_NUM_REGIONS 10 - -class CAdObject : public CBObject { -public: - CPartEmitter *_partEmitter; - virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); - virtual bool updatePartEmitter(); - bool _partFollowParent; - int _partOffsetX; - int _partOffsetY; - - bool invalidateCurrRegions(); - bool _subtitlesModRelative; - bool _subtitlesModXCenter; - int _subtitlesModX; - int _subtitlesModY; - int _subtitlesWidth; - CAdRegion *_stickRegion; - bool _sceneIndependent; - bool _ignoreItems; - bool updateBlockRegion(); - bool _forcedTalkAnimUsed; - char *_forcedTalkAnimName; - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool reset(); - DECLARE_PERSISTENT(CAdObject, CBObject) - virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); - virtual int getHeight(); - CAdSentence *_sentence; - bool SetFont(const char *filename); - virtual bool update(); - virtual bool display(); - bool _drawn; - bool _active; - virtual bool playAnim(const char *filename); - CBSprite *_animSprite; - CBSprite *_currentSprite; - TObjectState _state; - TObjectState _nextState; - TObjectType _type; - CAdObject(CBGame *inGame); - virtual ~CAdObject(); - CBFont *_font; - CBSprite *_tempSprite2; - CBRegion *_blockRegion; - CAdWaypointGroup *_wptGroup; - CBRegion *_currentBlockRegion; - CAdWaypointGroup *_currentWptGroup; - CAdInventory *getInventory(); - - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - virtual bool afterMove(); - CAdRegion *_currentRegions[MAX_NUM_REGIONS]; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - CBArray _attachmentsPre; - CBArray _attachmentsPost; - - bool updateSpriteAttachments(); - bool displaySpriteAttachments(bool preDisplay); - CAdObject *_registerAlias; -private: - bool displaySpriteAttachment(CAdObject *attachment); - CAdInventory *_inventory; - -protected: - bool getScale(float *scaleX, float *scaleY); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdPath.cpp b/engines/wintermute/ad/AdPath.cpp deleted file mode 100644 index d1b9d87063..0000000000 --- a/engines/wintermute/ad/AdPath.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdPath.h" -#include "engines/wintermute/base/BPoint.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPath, false) - -////////////////////////////////////////////////////////////////////////// -CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPath::~CAdPath() { - reset(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::reset() { - for (int i = 0; i < _points.getSize(); i++) - delete _points[i]; - - _points.removeAll(); - _currIndex = -1; - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getFirst() { - if (_points.getSize() > 0) { - _currIndex = 0; - return _points[_currIndex]; - } else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getNext() { - _currIndex++; - if (_currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdPath::addPoint(CBPoint *point) { - _points.add(point); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPath::setReady(bool ready) { - bool orig = _ready; - _ready = ready; - - return orig; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPath::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_currIndex)); - _points.persist(persistMgr); - persistMgr->transfer(TMEMBER(_ready)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdPath.h b/engines/wintermute/ad/AdPath.h deleted file mode 100644 index fdc2980042..0000000000 --- a/engines/wintermute/ad/AdPath.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATH_H -#define WINTERMUTE_ADPATH_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CBPoint; -class CAdPath : public CBBase { -public: - DECLARE_PERSISTENT(CAdPath, CBBase) - CBPoint *getCurrent(); - bool setReady(bool ready = true); - void addPoint(CBPoint *point); - CBPoint *getNext(); - CBPoint *getFirst(); - void reset(); - CAdPath(CBGame *inGame); - virtual ~CAdPath(); - CBArray _points; - int _currIndex; - bool _ready; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdPathPoint.cpp b/engines/wintermute/ad/AdPathPoint.cpp deleted file mode 100644 index 184ad8559a..0000000000 --- a/engines/wintermute/ad/AdPathPoint.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/AdPathPoint.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdPathPoint, false) - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint() { - x = y = 0; - _distance = 0; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { - x = initX; - y = initY; - _distance = initDistance; - - _marked = false; - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdPathPoint::~CAdPathPoint() { - _origin = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { - - CBPoint::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_distance)); - persistMgr->transfer(TMEMBER(_marked)); - persistMgr->transfer(TMEMBER(_origin)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdPathPoint.h b/engines/wintermute/ad/AdPathPoint.h deleted file mode 100644 index f58df765b1..0000000000 --- a/engines/wintermute/ad/AdPathPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADPATHPOINT_H -#define WINTERMUTE_ADPATHPOINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BPoint.h" - -namespace WinterMute { - -class CAdPathPoint : public CBPoint { -public: - DECLARE_PERSISTENT(CAdPathPoint, CBPoint) - CAdPathPoint(int initX, int initY, int initDistance); - CAdPathPoint(); - virtual ~CAdPathPoint(); - CAdPathPoint *_origin; - bool _marked; - int _distance; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdRegion.cpp b/engines/wintermute/ad/AdRegion.cpp deleted file mode 100644 index a1864de1ac..0000000000 --- a/engines/wintermute/ad/AdRegion.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdRegion.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRegion, false) - -////////////////////////////////////////////////////////////////////////// -CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { - _blocked = false; - _decoration = false; - _zoom = 0; - _alpha = 0xFFFFFFFF; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRegion::~CAdRegion() { -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(ZOOM) -TOKEN_DEF(SCALE) -TOKEN_DEF(BLOCKED) -TOKEN_DEF(DECORATION) -TOKEN_DEF(POINT) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(ZOOM) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(BLOCKED) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(POINT) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - int ar = 255, ag = 255, ab = 255, alpha = 255; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_BLOCKED: - parser.scanStr((char *)params, "%b", &_blocked); - break; - - case TOKEN_DECORATION: - parser.scanStr((char *)params, "%b", &_decoration); - break; - - case TOKEN_ZOOM: - case TOKEN_SCALE: { - int j; - parser.scanStr((char *)params, "%d", &j); - _zoom = (float)j; - } - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - /* - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo")==0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - stack->pushNULL(); - - return STATUS_OK; - } - - else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("ad region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Blocked") == 0) { - _scValue->setBool(_blocked); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - _scValue->setFloat(_zoom); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alpha); - return _scValue; - } - - else return CBRegion::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Blocked - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Blocked") == 0) { - _blocked = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - _zoom = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - else return CBRegion::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdRegion::scToString() { - return "[ad region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "REGION {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - int i; - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - for (i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRegion::persist(CBPersistMgr *persistMgr) { - CBRegion::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_blocked)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_zoom)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdRegion.h b/engines/wintermute/ad/AdRegion.h deleted file mode 100644 index c91feb4012..0000000000 --- a/engines/wintermute/ad/AdRegion.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADREGION_H -#define WINTERMUTE_ADREGION_H - -#include "engines/wintermute/base/BRegion.h" - -namespace WinterMute { - -class CAdRegion : public CBRegion { -public: - DECLARE_PERSISTENT(CAdRegion, CBRegion) - uint32 _alpha; - float _zoom; - bool _blocked; - bool _decoration; - CAdRegion(CBGame *inGame); - virtual ~CAdRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdResponse.cpp b/engines/wintermute/ad/AdResponse.cpp deleted file mode 100644 index 20617f9573..0000000000 --- a/engines/wintermute/ad/AdResponse.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdResponse.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/utils/utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponse, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { - _text = NULL; - _textOrig = NULL; - _icon = _iconHover = _iconPressed = NULL; - _font = NULL; - _iD = 0; - _responseType = RESPONSE_ALWAYS; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponse::~CAdResponse() { - delete[] _text; - delete[] _textOrig; - delete _icon; - delete _iconHover; - delete _iconPressed; - _text = NULL; - _textOrig = NULL; - _icon = NULL; - _iconHover = NULL; - _iconPressed = NULL; - if (_font) _gameRef->_fontStorage->removeFont(_font); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponse::setText(const char *text) { - CBUtils::setString(&_text, text); - CBUtils::setString(&_textOrig, text); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIcon(const char *filename) { - delete _icon; - _icon = new CBSprite(_gameRef); - if (!_icon || DID_FAIL(_icon->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); - delete _icon; - _icon = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont(filename); - if (!_font) { - _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconHover(const char *filename) { - delete _iconHover; - _iconHover = new CBSprite(_gameRef); - if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); - delete _iconHover; - _iconHover = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconPressed(const char *filename) { - delete _iconPressed; - _iconPressed = new CBSprite(_gameRef); - if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); - delete _iconPressed; - _iconPressed = NULL; - return STATUS_FAILED; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponse::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_icon)); - persistMgr->transfer(TMEMBER(_iconHover)); - persistMgr->transfer(TMEMBER(_iconPressed)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_textOrig)); - persistMgr->transfer(TMEMBER_INT(_responseType)); - persistMgr->transfer(TMEMBER(_font)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponse.h b/engines/wintermute/ad/AdResponse.h deleted file mode 100644 index 646d781b89..0000000000 --- a/engines/wintermute/ad/AdResponse.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSE_H -#define WINTERMUTE_ADRESPONSE_H - - -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/ad/AdTypes.h" - -namespace WinterMute { -class CBFont; -class CAdResponse : public CBObject { -public: - DECLARE_PERSISTENT(CAdResponse, CBObject) - bool setIcon(const char *filename); - bool setFont(const char *filename); - bool setIconHover(const char *filename); - bool setIconPressed(const char *filename); - void setText(const char *text); - int _iD; - CBSprite *_icon; - CBSprite *_iconHover; - CBSprite *_iconPressed; - CBFont *_font; - char *_text; - char *_textOrig; - CAdResponse(CBGame *inGame); - virtual ~CAdResponse(); - TResponseType _responseType; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdResponseBox.cpp b/engines/wintermute/ad/AdResponseBox.cpp deleted file mode 100644 index 829d58f2ee..0000000000 --- a/engines/wintermute/ad/AdResponseBox.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdResponseBox.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/ui/UIButton.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/ad/AdResponse.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseBox, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { - _font = _fontHover = NULL; - - _window = NULL; - _shieldWindow = new CUIWindow(_gameRef); - - _horizontal = false; - CBPlatform::setRectEmpty(&_responseArea); - _scrollOffset = 0; - _spacing = 0; - - _waitingScript = NULL; - _lastResponseText = NULL; - _lastResponseTextOrig = NULL; - - _verticalAlign = VAL_BOTTOM; - _align = TAL_LEFT; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseBox::~CAdResponseBox() { - - delete _window; - _window = NULL; - delete _shieldWindow; - _shieldWindow = NULL; - delete[] _lastResponseText; - _lastResponseText = NULL; - delete[] _lastResponseTextOrig; - _lastResponseTextOrig = NULL; - - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - - clearResponses(); - clearButtons(); - - _waitingScript = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearResponses() { - for (int i = 0; i < _responses.getSize(); i++) { - delete _responses[i]; - } - _responses.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { - delete _respButtons[i]; - } - _respButtons.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::invalidateButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { - _respButtons[i]->_image = NULL; - _respButtons[i]->_cursor = NULL; - _respButtons[i]->_font = NULL; - _respButtons[i]->_fontHover = NULL; - _respButtons[i]->_fontPress = NULL; - _respButtons[i]->setText(""); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::createButtons() { - clearButtons(); - - _scrollOffset = 0; - for (int i = 0; i < _responses.getSize(); i++) { - CUIButton *btn = new CUIButton(_gameRef); - if (btn) { - btn->_parent = _window; - btn->_sharedFonts = btn->_sharedImages = true; - btn->_sharedCursors = true; - // iconic - if (_responses[i]->_icon) { - btn->_image = _responses[i]->_icon; - if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; - if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; - - btn->setCaption(_responses[i]->_text); - if (_cursor) btn->_cursor = _cursor; - else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; - } - // textual - else { - btn->setText(_responses[i]->_text); - btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; - btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; - btn->_fontPress = btn->_fontHover; - btn->_align = _align; - - if (_gameRef->_touchInterface) - btn->_fontHover = btn->_font; - - - if (_responses[i]->_font) btn->_font = _responses[i]->_font; - - btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; - } - btn->setName("response"); - btn->correctSize(); - - // make the responses touchable - if (_gameRef->_touchInterface) - btn->_height = MAX(btn->_height, 50); - - //btn->SetListener(this, btn, _responses[i]->_iD); - btn->setListener(this, btn, i); - btn->_visible = false; - _respButtons.add(btn); - - if (_responseArea.bottom - _responseArea.top < btn->_height) { - _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); - _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); - } - } - } - _ready = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(RESPONSE_BOX) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT) -TOKEN_DEF(AREA) -TOKEN_DEF(HORIZONTAL) -TOKEN_DEF(SPACING) -TOKEN_DEF(WINDOW) -TOKEN_DEF(CURSOR) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(RESPONSE_BOX) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT) - TOKEN_TABLE(AREA) - TOKEN_TABLE(HORIZONTAL) - TOKEN_TABLE(SPACING) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { - _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_WINDOW: - delete _window; - _window = new CUIWindow(_gameRef); - if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { - delete _window; - _window = NULL; - cmd = PARSERR_GENERIC; - } else if (_shieldWindow) _shieldWindow->_parent = _window; - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_AREA: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); - break; - - case TOKEN_HORIZONTAL: - parser.scanStr((char *)params, "%b", &_horizontal); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_LEFT; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; - else _verticalAlign = VAL_BOTTOM; - break; - - case TOKEN_SPACING: - parser.scanStr((char *)params, "%d", &_spacing); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition"); - return STATUS_FAILED; - } - - if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) - _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "RESPONSE_BOX\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); - - switch (_align) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CAdResponseBox::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - } - - buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); - - buffer->putTextIndent(indent + 2, "\n"); - - // window - if (_window) _window->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::display() { - Rect32 rect = _responseArea; - if (_window) { - CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); - //_window->display(); - } - - int xxx, yyy, i; - - xxx = rect.left; - yyy = rect.top; - - // shift down if needed - if (!_horizontal) { - int total_height = 0; - for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); - total_height -= _spacing; - - switch (_verticalAlign) { - case VAL_BOTTOM: - if (yyy + total_height < rect.bottom) - yyy = rect.bottom - total_height; - break; - - case VAL_CENTER: - if (yyy + total_height < rect.bottom) - yyy += ((rect.bottom - rect.top) - total_height) / 2; - break; - - case VAL_TOP: - // do nothing - break; - } - } - - // prepare response buttons - bool scrollNeeded = false; - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { - if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) - || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { - - scrollNeeded = true; - _respButtons[i]->_visible = false; - break; - } - - _respButtons[i]->_visible = true; - _respButtons[i]->_posX = xxx; - _respButtons[i]->_posY = yyy; - - if (_horizontal) { - xxx += (_respButtons[i]->_width + _spacing); - } else { - yyy += (_respButtons[i]->_height + _spacing); - } - } - - // show appropriate scroll buttons - if (_window) { - _window->showWidget("prev", _scrollOffset > 0); - _window->showWidget("next", scrollNeeded); - } - - // go exclusive - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - - _shieldWindow->display(); - } - - // display window - if (_window) _window->display(); - - - // display response buttons - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { - _respButtons[i]->display(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "prev") == 0) { - _scrollOffset--; - } else if (scumm_stricmp(obj->_name, "next") == 0) { - _scrollOffset++; - } else if (scumm_stricmp(obj->_name, "response") == 0) { - if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); - handleResponse(_responses[param2]); - _waitingScript = NULL; - _gameRef->_state = GAME_RUNNING; - ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; - _ready = true; - invalidateButtons(); - clearResponses(); - } else return CBObject::listen(param1, param2); - break; - default: - error("AdResponseBox::Listen - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_fontHover)); - persistMgr->transfer(TMEMBER(_horizontal)); - persistMgr->transfer(TMEMBER(_lastResponseText)); - persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); - _respButtons.persist(persistMgr); - persistMgr->transfer(TMEMBER(_responseArea)); - _responses.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_waitingScript)); - persistMgr->transfer(TMEMBER(_window)); - - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - persistMgr->transfer(TMEMBER_INT(_align)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::weedResponses() { - CAdGame *adGame = (CAdGame *)_gameRef; - - for (int i = 0; i < _responses.getSize(); i++) { - switch (_responses[i]->_responseType) { - case RESPONSE_ONCE: - if (adGame->branchResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.removeAt(i); - i--; - } - break; - - case RESPONSE_ONCE_GAME: - if (adGame->gameResponseUsed(_responses[i]->_iD)) { - delete _responses[i]; - _responses.removeAt(i); - i--; - } - break; - default: - warning("CAdResponseBox::WeedResponses - Unhandled enum"); - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { - CBUtils::setString(&_lastResponseText, text); - CBUtils::setString(&_lastResponseTextOrig, textOrig); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::handleResponse(CAdResponse *response) { - setLastResponseText(response->_text, response->_textOrig); - - CAdGame *adGame = (CAdGame *)_gameRef; - - switch (response->_responseType) { - case RESPONSE_ONCE: - adGame->addBranchResponse(response->_iD); - break; - - case RESPONSE_ONCE_GAME: - adGame->addGameResponse(response->_iD); - break; - default: - warning("CAdResponseBox::HandleResponse - Unhandled enum"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { - CBArray objects; - getObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { - if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { - CBArray objects; - getObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; - } - } - } - return objects[objects.getSize() - 1]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _respButtons.getSize(); i++) { - objects.add(_respButtons[i]); - } - if (_window) _window->getWindowObjects(objects, interactiveOnly); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponseBox.h b/engines/wintermute/ad/AdResponseBox.h deleted file mode 100644 index 93b677bd4a..0000000000 --- a/engines/wintermute/ad/AdResponseBox.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSEBOX_H -#define WINTERMUTE_ADRESPONSEBOX_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CUIButton; -class CUIWindow; -class CUIObject; -class CAdResponse; -class CAdResponseBox : public CBObject { -public: - CBObject *getNextAccessObject(CBObject *CurrObject); - CBObject *getPrevAccessObject(CBObject *CurrObject); - bool getObjects(CBArray &objects, bool interactiveOnly); - - bool handleResponse(CAdResponse *response); - void setLastResponseText(const char *text, const char *textOrig); - char *_lastResponseText; - char *_lastResponseTextOrig; - DECLARE_PERSISTENT(CAdResponseBox, CBObject) - CScScript *_waitingScript; - virtual bool listen(CBScriptHolder *param1, uint32 param2); - typedef enum { - EVENT_PREV, - EVENT_NEXT, - EVENT_RESPONSE - } TResponseEvent; - - bool weedResponses(); - bool display(); - int _spacing; - int _scrollOffset; - CBFont *_fontHover; - CBFont *_font; - bool createButtons(); - bool invalidateButtons(); - void clearButtons(); - void clearResponses(); - CAdResponseBox(CBGame *inGame); - virtual ~CAdResponseBox(); - CBArray _responses; - CBArray _respButtons; - CUIWindow *_window; - CUIWindow *_shieldWindow; - bool _horizontal; - Rect32 _responseArea; - int _verticalAlign; - TTextAlign _align; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdResponseContext.cpp b/engines/wintermute/ad/AdResponseContext.cpp deleted file mode 100644 index 8573e58b95..0000000000 --- a/engines/wintermute/ad/AdResponseContext.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdResponseContext.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdResponseContext, false) - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { - _iD = 0; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdResponseContext::~CAdResponseContext() { - delete[] _context; - _context = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_context)); - persistMgr->transfer(TMEMBER(_iD)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::setContext(const char *context) { - delete[] _context; - _context = NULL; - if (context) { - _context = new char [strlen(context) + 1]; - if (_context) strcpy(_context, context); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdResponseContext.h b/engines/wintermute/ad/AdResponseContext.h deleted file mode 100644 index 74506405de..0000000000 --- a/engines/wintermute/ad/AdResponseContext.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADRESPONSECONTEXT_H -#define WINTERMUTE_ADRESPONSECONTEXT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CAdResponseContext : public CBBase { -public: - void setContext(const char *context); - int _iD; - char *_context; - DECLARE_PERSISTENT(CAdResponseContext, CBBase) - CAdResponseContext(CBGame *inGame); - virtual ~CAdResponseContext(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdRotLevel.cpp b/engines/wintermute/ad/AdRotLevel.cpp deleted file mode 100644 index 671d003f35..0000000000 --- a/engines/wintermute/ad/AdRotLevel.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdRotLevel.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdRotLevel, false) - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { - _posX = 0; - _rotation = 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -CAdRotLevel::~CAdRotLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(X) -TOKEN_DEF(ROTATION) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(X) - TOKEN_TABLE(ROTATION) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { - _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_ROTATION: { - int i; - parser.scanStr((char *)params, "%d", &i); - _rotation = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_rotation)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdRotLevel.h b/engines/wintermute/ad/AdRotLevel.h deleted file mode 100644 index 9e536a8d8f..0000000000 --- a/engines/wintermute/ad/AdRotLevel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADROTLEVEL_H -#define WINTERMUTE_ADROTLEVEL_H - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CAdRotLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdRotLevel, CBObject) - CAdRotLevel(CBGame *inGame); - virtual ~CAdRotLevel(); - float _rotation; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdScaleLevel.cpp b/engines/wintermute/ad/AdScaleLevel.cpp deleted file mode 100644 index 1ac2f7ba6c..0000000000 --- a/engines/wintermute/ad/AdScaleLevel.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdScaleLevel.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScaleLevel, false) - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { - _posY = 0; - _scale = 100; -} - - -////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::~CAdScaleLevel() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(Y) -TOKEN_DEF(SCALE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(Y) - TOKEN_TABLE(SCALE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { - _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_SCALE: { - int i; - parser.scanStr((char *)params, "%d", &i); - _scale = (float)i; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scale)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdScaleLevel.h b/engines/wintermute/ad/AdScaleLevel.h deleted file mode 100644 index c360ec4eff..0000000000 --- a/engines/wintermute/ad/AdScaleLevel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCALELEVEL_H -#define WINTERMUTE_ADSCALELEVEL_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CAdScaleLevel : public CBObject { -public: - DECLARE_PERSISTENT(CAdScaleLevel, CBObject) - float _scale; - CAdScaleLevel(CBGame *inGame); - virtual ~CAdScaleLevel(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdScene.cpp b/engines/wintermute/ad/AdScene.cpp deleted file mode 100644 index b284543a08..0000000000 --- a/engines/wintermute/ad/AdScene.cpp +++ /dev/null @@ -1,2752 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/ad/AdActor.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdLayer.h" -#include "engines/wintermute/ad/AdNodeState.h" -#include "engines/wintermute/ad/AdObject.h" -#include "engines/wintermute/ad/AdPath.h" -#include "engines/wintermute/ad/AdPathPoint.h" -#include "engines/wintermute/ad/AdRotLevel.h" -#include "engines/wintermute/ad/AdScaleLevel.h" -#include "engines/wintermute/ad/AdSceneNode.h" -#include "engines/wintermute/ad/AdSceneState.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/utils/utils.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdScene, false) - -////////////////////////////////////////////////////////////////////////// -CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - _pfTarget = new CBPoint; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -CAdScene::~CAdScene() { - cleanup(); - _gameRef->unregisterObject(_fader); - delete _pfTarget; - _pfTarget = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::setDefaults() { - _initialized = false; - _pfReady = true; - _pfTargetPath = NULL; - _pfRequester = NULL; - _mainLayer = NULL; - - _pfPointsNum = 0; - _persistentState = false; - _persistentStateSprites = true; - - _autoScroll = true; - _offsetLeft = _offsetTop = 0; - _targetOffsetLeft = _targetOffsetTop = 0; - - _lastTimeH = _lastTimeV = 0; - _scrollTimeH = _scrollTimeV = 10; - _scrollPixelsH = _scrollPixelsV = 1; - - _pfMaxTime = 15; - - _paralaxScrolling = true; - - // editor settings - _editorMarginH = _editorMarginV = 100; - - _editorColFrame = 0xE0888888; - _editorColEntity = 0xFF008000; - _editorColRegion = 0xFF0000FF; - _editorColBlocked = 0xFF800080; - _editorColWaypoints = 0xFF0000FF; - _editorColEntitySel = 0xFFFF0000; - _editorColRegionSel = 0xFFFF0000; - _editorColBlockedSel = 0xFFFF0000; - _editorColWaypointsSel = 0xFFFF0000; - _editorColScale = 0xFF00FF00; - _editorColDecor = 0xFF00FFFF; - _editorColDecorSel = 0xFFFF0000; - - _editorShowRegions = true; - _editorShowBlocked = true; - _editorShowDecor = true; - _editorShowEntities = true; - _editorShowScale = true; - - _shieldWindow = NULL; - - _fader = new CBFader(_gameRef); - _gameRef->registerObject(_fader); - - _viewport = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::cleanup() { - CBObject::cleanup(); - - _mainLayer = NULL; // reference only - - int i; - - delete _shieldWindow; - _shieldWindow = NULL; - - _gameRef->unregisterObject(_fader); - _fader = NULL; - - for (i = 0; i < _layers.getSize(); i++) - _gameRef->unregisterObject(_layers[i]); - _layers.removeAll(); - - - for (i = 0; i < _waypointGroups.getSize(); i++) - _gameRef->unregisterObject(_waypointGroups[i]); - _waypointGroups.removeAll(); - - for (i = 0; i < _scaleLevels.getSize(); i++) - _gameRef->unregisterObject(_scaleLevels[i]); - _scaleLevels.removeAll(); - - for (i = 0; i < _rotLevels.getSize(); i++) - _gameRef->unregisterObject(_rotLevels[i]); - _rotLevels.removeAll(); - - - for (i = 0; i < _pfPath.getSize(); i++) - delete _pfPath[i]; - _pfPath.removeAll(); - _pfPointsNum = 0; - - for (i = 0; i < _objects.getSize(); i++) - _gameRef->unregisterObject(_objects[i]); - _objects.removeAll(); - - delete _viewport; - _viewport = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { - if (!_pfReady) return false; - else { - _pfReady = false; - *_pfTarget = target; - _pfTargetPath = path; - _pfRequester = requester; - - _pfTargetPath->reset(); - _pfTargetPath->setReady(false); - - // prepare working path - int i; - pfPointsStart(); - - // first point - //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); - - // if we're one pixel stuck, get unstuck - int startX = source.x; - int startY = source.y; - int bestDistance = 1000; - if (isBlockedAt(startX, startY, true, requester)) { - int tolerance = 2; - for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) { - for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) { - if (isWalkableAt(xxx, yyy, true, requester)) { - int distance = abs(xxx - source.x) + abs(yyy - source.y); - if (distance < bestDistance) { - startX = xxx; - startY = yyy; - - bestDistance = distance; - } - } - } - } - } - - pfPointsAdd(startX, startY, 0); - - //CorrectTargetPoint(&target.x, &target.y); - - // last point - //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); - pfPointsAdd(target.x, target.y, INT_MAX); - - // active waypoints - for (i = 0; i < _waypointGroups.getSize(); i++) { - if (_waypointGroups[i]->_active) { - pfAddWaypointGroup(_waypointGroups[i], requester); - } - } - - - // free waypoints - for (i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { - pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { - pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); - } - } - - return true; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { - if (!wpt->_active) return; - - for (int i = 0; i < wpt->_points.getSize(); i++) { - if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; - - //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); - pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); - } -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getZoomAt(int x, int y) { - float ret = 100; - - bool found = false; - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { - if (node->_region->_zoom != 0) { - ret = node->_region->_zoom; - found = true; - break; - } - } - } - } - if (!found) ret = getScaleAt(y); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { - if (!_gameRef->_debugDebugMode) colorCheck = false; - - uint32 ret; - if (colorCheck) ret = 0xFFFF0000; - else ret = 0xFFFFFFFF; - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { - if (!node->_region->_blocked) ret = node->_region->_alpha; - break; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { - bool ret = true; - - - if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - /* - if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) - { - ret = true; - break; - } - */ - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { - ret = true; - break; - } else ret = false; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { - bool ret = false; - - if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; - } - } - CAdGame *adGame = (CAdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; - } - } - } - - - if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { - ret = false; - break; - } else ret = true; - } - } - } - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { - double xStep, yStep, x, y; - int xLength, yLength, xCount, yCount; - int x1, y1, x2, y2; - - x1 = p1.x; - y1 = p1.y; - x2 = p2.x; - y2 = p2.y; - - xLength = abs(x2 - x1); - yLength = abs(y2 - y1); - - if (xLength > yLength) { - if (x1 > x2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); - } - - yStep = (double)(y2 - y1) / (double)(x2 - x1); - y = y1; - - for (xCount = x1; xCount < x2; xCount++) { - if (isBlockedAt(xCount, (int)y, true, requester)) return -1; - y += yStep; - } - } else { - if (y1 > y2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); - } - - xStep = (double)(x2 - x1) / (double)(y2 - y1); - x = x1; - - for (yCount = y1; yCount < y2; yCount++) { - if (isBlockedAt((int)x, yCount, true, requester)) return -1; - x += xStep; - } - } - return MAX(xLength, yLength); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pathFinderStep() { - int i; - // get lowest unmarked - int lowestDist = INT_MAX; - CAdPathPoint *lowestPt = NULL; - - for (i = 0; i < _pfPointsNum; i++) - if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { - lowestDist = _pfPath[i]->_distance; - lowestPt = _pfPath[i]; - } - - if (lowestPt == NULL) { // no path -> terminate PathFinder - _pfReady = true; - _pfTargetPath->setReady(true); - return; - } - - lowestPt->_marked = true; - - // target point marked, generate path and terminate - if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { - while (lowestPt != NULL) { - _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); - lowestPt = lowestPt->_origin; - } - - _pfReady = true; - _pfTargetPath->setReady(true); - return; - } - - // otherwise keep on searching - for (i = 0; i < _pfPointsNum; i++) - if (!_pfPath[i]->_marked) { - int j = getPointsDist(*lowestPt, *_pfPath[i], _pfRequester); - if (j != -1 && lowestPt->_distance + j < _pfPath[i]->_distance) { - _pfPath[i]->_distance = lowestPt->_distance + j; - _pfPath[i]->_origin = lowestPt; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::initLoop() { -#ifdef _DEBUGxxxx - int nu_steps = 0; - uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { - PathFinderStep(); - nu_steps++; - } - if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); -#else - uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); -#endif - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SCENE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(LAYER) -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(CAMERA) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCALE_LEVEL) -TOKEN_DEF(ROTATION_LEVEL) -TOKEN_DEF(EDITOR_MARGIN_H) -TOKEN_DEF(EDITOR_MARGIN_V) -TOKEN_DEF(EDITOR_COLOR_FRAME) -TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION_SEL) -TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) -TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) -TOKEN_DEF(EDITOR_COLOR_REGION) -TOKEN_DEF(EDITOR_COLOR_DECORATION) -TOKEN_DEF(EDITOR_COLOR_BLOCKED) -TOKEN_DEF(EDITOR_COLOR_ENTITY) -TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) -TOKEN_DEF(EDITOR_COLOR_SCALE) -TOKEN_DEF(EDITOR_SHOW_REGIONS) -TOKEN_DEF(EDITOR_SHOW_BLOCKED) -TOKEN_DEF(EDITOR_SHOW_DECORATION) -TOKEN_DEF(EDITOR_SHOW_ENTITIES) -TOKEN_DEF(EDITOR_SHOW_SCALE) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(VIEWPORT) -TOKEN_DEF(PERSISTENT_STATE_SPRITES) -TOKEN_DEF(PERSISTENT_STATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SCENE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(LAYER) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(CAMERA) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCALE_LEVEL) - TOKEN_TABLE(ROTATION_LEVEL) - TOKEN_TABLE(EDITOR_MARGIN_H) - TOKEN_TABLE(EDITOR_MARGIN_V) - TOKEN_TABLE(EDITOR_COLOR_FRAME) - TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) - TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) - TOKEN_TABLE(EDITOR_COLOR_REGION) - TOKEN_TABLE(EDITOR_COLOR_DECORATION) - TOKEN_TABLE(EDITOR_COLOR_BLOCKED) - TOKEN_TABLE(EDITOR_COLOR_ENTITY) - TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) - TOKEN_TABLE(EDITOR_COLOR_SCALE) - TOKEN_TABLE(EDITOR_SHOW_REGIONS) - TOKEN_TABLE(EDITOR_SHOW_DECORATION) - TOKEN_TABLE(EDITOR_SHOW_BLOCKED) - TOKEN_TABLE(EDITOR_SHOW_ENTITIES) - TOKEN_TABLE(EDITOR_SHOW_SCALE) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(VIEWPORT) - TOKEN_TABLE(PERSISTENT_STATE_SPRITES) - TOKEN_TABLE(PERSISTENT_STATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - cleanup(); - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { - _gameRef->LOG(0, "'SCENE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int ar, ag, ab, aa; - char camera[MAX_PATH_LENGTH] = ""; - /* float WaypointHeight = -1.0f; */ - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_LAYER: { - CAdLayer *layer = new CAdLayer(_gameRef); - if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete layer; - layer = NULL; - } else { - _gameRef->registerObject(layer); - _layers.add(layer); - if (layer->_main) { - _mainLayer = layer; - _width = layer->_width; - _height = layer->_height; - } - } - } - break; - - case TOKEN_WAYPOINTS: { - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete wpt; - wpt = NULL; - } else { - _gameRef->registerObject(wpt); - _waypointGroups.add(wpt); - } - } - break; - - case TOKEN_SCALE_LEVEL: { - CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); - if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete sl; - sl = NULL; - } else { - _gameRef->registerObject(sl); - _scaleLevels.add(sl); - } - } - break; - - case TOKEN_ROTATION_LEVEL: { - CAdRotLevel *rl = new CAdRotLevel(_gameRef); - if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete rl; - rl = NULL; - } else { - _gameRef->registerObject(rl); - _rotLevels.add(rl); - } - } - break; - - case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); - if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { - cmd = PARSERR_GENERIC; - delete entity; - entity = NULL; - } else { - addObject(entity); - } - } - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CAMERA: - strcpy(camera, (char *)params); - break; - - case TOKEN_EDITOR_MARGIN_H: - parser.scanStr((char *)params, "%d", &_editorMarginH); - break; - - case TOKEN_EDITOR_MARGIN_V: - parser.scanStr((char *)params, "%d", &_editorMarginV); - break; - - case TOKEN_EDITOR_COLOR_FRAME: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColFrame = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntity = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_ENTITY_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_REGION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColRegion = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_DECORATION: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColDecor = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_BLOCKED: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_WAYPOINTS: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_COLOR_SCALE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); - _editorColScale = BYTETORGBA(ar, ag, ab, aa); - break; - - case TOKEN_EDITOR_SHOW_REGIONS: - parser.scanStr((char *)params, "%b", &_editorShowRegions); - break; - - case TOKEN_EDITOR_SHOW_BLOCKED: - parser.scanStr((char *)params, "%b", &_editorShowBlocked); - break; - - case TOKEN_EDITOR_SHOW_DECORATION: - parser.scanStr((char *)params, "%b", &_editorShowDecor); - break; - - case TOKEN_EDITOR_SHOW_ENTITIES: - parser.scanStr((char *)params, "%b", &_editorShowEntities); - break; - - case TOKEN_EDITOR_SHOW_SCALE: - parser.scanStr((char *)params, "%b", &_editorShowScale); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_VIEWPORT: { - Rect32 rc; - parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); - } - - case TOKEN_PERSISTENT_STATE: - parser.scanStr((char *)params, "%b", &_persistentState); - break; - - case TOKEN_PERSISTENT_STATE_SPRITES: - parser.scanStr((char *)params, "%b", &_persistentStateSprites); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SCENE definition"); - return STATUS_FAILED; - } - - if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); - - - sortScaleLevels(); - sortRotLevels(); - - _initialized = true; - - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::traverseNodes(bool doUpdate) { - if (!_initialized) return STATUS_OK; - - int j, k; - CAdGame *adGame = (CAdGame *)_gameRef; - - - ////////////////////////////////////////////////////////////////////////// - // prepare viewport - bool PopViewport = false; - if (_viewport && !_gameRef->_editorMode) { - _gameRef->pushViewport(_viewport); - PopViewport = true; - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - _gameRef->pushViewport(adGame->_sceneViewport); - PopViewport = true; - } - - - ////////////////////////////////////////////////////////////////////////// - // *** adjust scroll offset - if (doUpdate) { - /* - if (_autoScroll && _gameRef->_mainObject != NULL) - { - ScrollToObject(_gameRef->_mainObject); - } - */ - - if (_autoScroll) { - // adjust horizontal scroll - if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { - _lastTimeH = _gameRef->_timer; - if (_offsetLeft < _targetOffsetLeft) { - _offsetLeft += _scrollPixelsH; - _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); - } else if (_offsetLeft > _targetOffsetLeft) { - _offsetLeft -= _scrollPixelsH; - _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); - } - } - - // adjust vertical scroll - if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { - _lastTimeV = _gameRef->_timer; - if (_offsetTop < _targetOffsetTop) { - _offsetTop += _scrollPixelsV; - _offsetTop = MIN(_offsetTop, _targetOffsetTop); - } else if (_offsetTop > _targetOffsetTop) { - _offsetTop -= _scrollPixelsV; - _offsetTop = MAX(_offsetTop, _targetOffsetTop); - } - } - - if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; - } else _ready = true; // not scrolling, i.e. always ready - } - - - - - ////////////////////////////////////////////////////////////////////////// - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - int viewportX, viewportY; - getViewportOffset(&viewportX, &viewportY); - - int scrollableX = _width - viewportWidth; - int scrollableY = _height - viewportHeight; - - double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); - double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); - - int origX, origY; - _gameRef->getOffset(&origX, &origY); - - - - ////////////////////////////////////////////////////////////////////////// - // *** display/update everything - _gameRef->_renderer->setup2D(); - - // for each layer - /* int MainOffsetX = 0; */ - /* int MainOffsetY = 0; */ - - for (j = 0; j < _layers.getSize(); j++) { - if (!_layers[j]->_active) continue; - - // make layer exclusive - if (!doUpdate) { - if (_layers[j]->_closeUp && !_gameRef->_editorMode) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - _shieldWindow->display(); - } - } - } - - if (_paralaxScrolling) { - int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); - int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); - _gameRef->setOffset(offsetX, offsetY); - - _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; - - //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX); - } else { - _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); - - _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; - _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; - } - - - // for each node - for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { - CAdSceneNode *node = _layers[j]->_nodes[k]; - switch (node->_type) { - case OBJECT_ENTITY: - if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { - _gameRef->_renderer->setup2D(); - - if (doUpdate) node->_entity->update(); - else node->_entity->display(); - } - break; - - case OBJECT_REGION: { - if (node->_region->_blocked) break; - if (node->_region->_decoration) break; - - if (!doUpdate) displayRegionContent(node->_region); - } - break; - default: - error("AdScene::TraverseNodes - Unhandled enum"); - break; - } // switch - } // each node - - // display/update all objects which are off-regions - if (_layers[j]->_main) { - if (doUpdate) { - updateFreeObjects(); - } else { - displayRegionContent(NULL); - } - } - } // each layer - - - // restore state - _gameRef->setOffset(origX, origY); - _gameRef->_renderer->setup2D(); - - // display/update fader - if (_fader) { - if (doUpdate) _fader->update(); - else _fader->display(); - } - - if (PopViewport) _gameRef->popViewport(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::display() { - return traverseNodes(false); -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::updateFreeObjects() { - CAdGame *adGame = (CAdGame *)_gameRef; - bool is3DSet; - - // *** update all active objects - is3DSet = false; - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (!adGame->_objects[i]->_active) continue; - - adGame->_objects[i]->update(); - adGame->_objects[i]->_drawn = false; - } - - - for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_active) continue; - - _objects[i]->update(); - _objects[i]->_drawn = false; - } - - - if (_autoScroll && _gameRef->_mainObject != NULL) { - scrollToObject(_gameRef->_mainObject); - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CBArray objects; - CAdObject *obj; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - obj = adGame->_objects[i]; - if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); - } - } - - // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); - - // display them - for (int i = 0; i < objects.getSize(); i++) { - obj = objects[i]; - - if (display3DOnly && !obj->_is3D) continue; - - _gameRef->_renderer->setup2D(); - - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); - obj->_drawn = true; - } - - - // display design only objects - if (!display3DOnly) { - if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CAdScene::compareObjs(const void *obj1, const void *obj2) { - CAdObject *object1 = *(CAdObject **)obj1; - CAdObject *object2 = *(CAdObject **)obj2; - - if (object1->_posY < object2->_posY) return -1; - else if (object1->_posY > object2->_posY) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContentOld(CAdRegion *region) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; - - // display all objects in region sorted by _posY - do { - obj = NULL; - int minY = INT_MAX; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { - obj = adGame->_objects[i]; - minY = adGame->_objects[i]->_posY; - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { - obj = _objects[i]; - minY = _objects[i]->_posY; - } - } - - - if (obj != NULL) { - _gameRef->_renderer->setup2D(); - - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); - obj->_drawn = true; - } - } while (obj != NULL); - - - // design only objects - if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_active && _objects[i]->_editorOnly) { - _objects[i]->display(); - _objects[i]->_drawn = true; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::update() { - return traverseNodes(true); -} - -////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - int origOffsetLeft = _targetOffsetLeft; - int origOffsetTop = _targetOffsetTop; - - _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); - _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); - - _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); - _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); - - - if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { - if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; - if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; - //_targetOffsetTop = 0; - } - - _ready = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollToObject(CBObject *object) { - if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::skipToObject(CBObject *object) { - if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::skipTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetLeft = MAX(0, offsetX - viewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - - _offsetTop = MAX(0, offsetY - viewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - viewportHeight); - - _targetOffsetLeft = _offsetLeft; - _targetOffsetTop = _offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LoadActor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LoadActor") == 0) { - stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); - if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { - addObject(act); - stack->pushNative(act, true); - } else { - delete act; - act = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadEntity") == 0) { - stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); - if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { - addObject(ent); - stack->pushNative(ent, true); - } else { - delete ent; - ent = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdEntity *ent = new CAdEntity(_gameRef); - addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); - stack->pushNative(ent, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); - removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - if (val1->isNative()) { - skipToObject((CBObject *)val1->getNative()); - } else { - skipTo(val1->getInt(), val2->getInt()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollTo / ScrollToAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { - stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - if (val1->isNative()) { - scrollToObject((CBObject *)val1->getNative()); - } else { - scrollTo(val1->getInt(), val2->getInt()); - } - if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->isInt()) { - int layer = val->getInt(); - if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); - else stack->pushNative(_layers[layer], true); - } else { - const char *LayerName = val->getString(); - bool LayerFound = false; - for (int i = 0; i < _layers.getSize(); i++) { - if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { - stack->pushNative(_layers[i], true); - LayerFound = true; - break; - } - } - if (!LayerFound) stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaypointGroup - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaypointGroup") == 0) { - stack->correctParams(1); - int group = stack->pop()->getInt(); - if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); - else stack->pushNative(_waypointGroups[group], true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetNode") == 0) { - stack->correctParams(1); - const char *nodeName = stack->pop()->getString(); - - CBObject *node = getNodeByName(nodeName); - if (node) stack->pushNative((CBScriptable *)node, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFreeNode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFreeNode") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdObject *ret = NULL; - if (val->isInt()) { - int index = val->getInt(); - if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; - } else { - const char *nodeName = val->getString(); - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { - ret = _objects[i]; - break; - } - } - } - if (ret) stack->pushNative(ret, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRegionAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRegionAt") == 0) { - stack->correctParams(3); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - bool includeDecors = false; - if (!val->isNULL()) includeDecors = val->getBool(); - - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (node->_region->_decoration && !includeDecors) continue; - - stack->pushNative(node->_region, true); - return STATUS_OK; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsBlockedAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsBlockedAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushBool(isBlockedAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsWalkableAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsWalkableAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushBool(isWalkableAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetScaleAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetScaleAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushFloat(getZoomAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetRotationAt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRotationAt") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - stack->pushFloat(getRotationAt(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScrolling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScrolling") == 0) { - stack->correctParams(0); - bool ret = false; - if (_autoScroll) { - if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; - } - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsPointInViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsPointInViewport") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - stack->pushBool(pointInViewport(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetViewport - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetViewport") == 0) { - stack->correctParams(4); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - int width = stack->pop()->getInt(); - int height = stack->pop()->getInt(); - - if (width <= 0) width = _gameRef->_renderer->_width; - if (height <= 0) height = _gameRef->_renderer->_height; - - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) _viewport->setRect(x, y, x + width, y + height); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdLayer *layer = new CAdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); - if (_mainLayer) { - layer->_width = _mainLayer->_width; - layer->_height = _mainLayer->_height; - } - _layers.add(layer); - _gameRef->registerObject(layer); - - stack->pushNative(layer, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertLayer") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); - - CAdLayer *layer = new CAdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); - if (_mainLayer) { - layer->_width = _mainLayer->_width; - layer->_height = _mainLayer->_height; - } - if (index < 0) index = 0; - if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); - else _layers.add(layer); - - _gameRef->registerObject(layer); - - stack->pushNative(layer, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteLayer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteLayer") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CAdLayer *toDelete = NULL; - if (val->isNative()) { - CBScriptable *temp = val->getNative(); - for (int i = 0; i < _layers.getSize(); i++) { - if (_layers[i] == temp) { - toDelete = _layers[i]; - break; - } - } - } else { - int index = val->getInt(); - if (index >= 0 && index < _layers.getSize()) { - toDelete = _layers[index]; - } - } - if (toDelete == NULL) { - stack->pushBool(false); - return STATUS_OK; - } - - if (toDelete->_main) { - script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); - stack->pushBool(false); - return STATUS_OK; - } - - for (int i = 0; i < _layers.getSize(); i++) { - if (_layers[i] == toDelete) { - _layers.removeAt(i); - _gameRef->unregisterObject(toDelete); - break; - } - } - stack->pushBool(true); - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("scene"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumLayers (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLayers") == 0) { - _scValue->setInt(_layers.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWaypointGroups (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->setInt(_waypointGroups.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainLayer (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainLayer") == 0) { - if (_mainLayer) _scValue->setNative(_mainLayer, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFreeNodes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFreeNodes") == 0) { - _scValue->setInt(_objects.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - int viewportX; - getViewportOffset(&viewportX); - - _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - int viewportY; - getViewportOffset(NULL, &viewportY); - - _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoScroll") == 0) { - _scValue->setBool(_autoScroll); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentState") == 0) { - _scValue->setBool(_persistentState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentStateSprites") == 0) { - _scValue->setBool(_persistentStateSprites); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsX") == 0) { - _scValue->setInt(_scrollPixelsH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsY") == 0) { - _scValue->setInt(_scrollPixelsV); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedX") == 0) { - _scValue->setInt(_scrollTimeH); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedY") == 0) { - _scValue->setInt(_scrollTimeV); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetX") == 0) { - _scValue->setInt(_offsetLeft); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetY") == 0) { - _scValue->setInt(_offsetTop); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_width); - else _scValue->setInt(0); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_height); - else _scValue->setInt(0); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoScroll - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoScroll") == 0) { - _autoScroll = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentState") == 0) { - _persistentState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PersistentStateSprites - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentStateSprites") == 0) { - _persistentStateSprites = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsX") == 0) { - _scrollPixelsH = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollPixelsY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsY") == 0) { - _scrollPixelsV = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedX") == 0) { - _scrollTimeH = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScrollSpeedY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedY") == 0) { - _scrollTimeV = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetX") == 0) { - _offsetLeft = value->getInt(); - - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); - _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - _targetOffsetLeft = _offsetLeft; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OffsetY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetY") == 0) { - _offsetTop = value->getInt(); - - int viewportWidth, viewportHeight; - getViewportSize(&viewportWidth, &viewportHeight); - - _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); - _offsetTop = MIN(_offsetTop, _height - viewportHeight); - _targetOffsetTop = _offsetTop; - - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdScene::scToString() { - return "[scene object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::addObject(CAdObject *object) { - _objects.add(object); - return _gameRef->registerObject(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::removeObject(CAdObject *object) { - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] == object) { - _objects.removeAt(i); - return _gameRef->unregisterObject(object); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { - int i; - - buffer->putTextIndent(indent, "SCENE {\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - if (_persistentState) - buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); - - if (!_persistentStateSprites) - buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); - - - // scripts - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // properties - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - // viewport - if (_viewport) { - Rect32 *rc = _viewport->getRect(); - buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); - } - - - - // editor settings - buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); - buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); - buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColFrame), RGBCOLGetG(_editorColFrame), RGBCOLGetB(_editorColFrame), RGBCOLGetA(_editorColFrame)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntitySel), RGBCOLGetG(_editorColEntitySel), RGBCOLGetB(_editorColEntitySel), RGBCOLGetA(_editorColEntitySel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegionSel), RGBCOLGetG(_editorColRegionSel), RGBCOLGetB(_editorColRegionSel), RGBCOLGetA(_editorColRegionSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlockedSel), RGBCOLGetG(_editorColBlockedSel), RGBCOLGetB(_editorColBlockedSel), RGBCOLGetA(_editorColBlockedSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecorSel), RGBCOLGetG(_editorColDecorSel), RGBCOLGetB(_editorColDecorSel), RGBCOLGetA(_editorColDecorSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypointsSel), RGBCOLGetG(_editorColWaypointsSel), RGBCOLGetB(_editorColWaypointsSel), RGBCOLGetA(_editorColWaypointsSel)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntity), RGBCOLGetG(_editorColEntity), RGBCOLGetB(_editorColEntity), RGBCOLGetA(_editorColEntity)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegion), RGBCOLGetG(_editorColRegion), RGBCOLGetB(_editorColRegion), RGBCOLGetA(_editorColRegion)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecor), RGBCOLGetG(_editorColDecor), RGBCOLGetB(_editorColDecor), RGBCOLGetA(_editorColDecor)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlocked), RGBCOLGetG(_editorColBlocked), RGBCOLGetB(_editorColBlocked), RGBCOLGetA(_editorColBlocked)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypoints), RGBCOLGetG(_editorColWaypoints), RGBCOLGetB(_editorColWaypoints), RGBCOLGetA(_editorColWaypoints)); - buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColScale), RGBCOLGetG(_editorColScale), RGBCOLGetB(_editorColScale), RGBCOLGetA(_editorColScale)); - - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - CBBase::saveAsText(buffer, indent + 2); - - // waypoints - buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent + 2, "\n"); - - // layers - buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); - - // scale levels - buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); - - // rotation levels - buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent + 2, "\n"); - - // free entities - buffer->putTextIndent(indent + 2, "; ----- free entities\n"); - for (i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - _objects[i]->saveAsText(buffer, indent + 2); - - } - } - - - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortScaleLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { - if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { - CAdScaleLevel *sl = _scaleLevels[i]; - _scaleLevels[i] = _scaleLevels[i + 1]; - _scaleLevels[i + 1] = sl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortRotLevels() { - bool changed; - do { - changed = false; - for (int i = 0; i < _rotLevels.getSize() - 1; i++) { - if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { - CAdRotLevel *rl = _rotLevels[i]; - _rotLevels[i] = _rotLevels[i + 1]; - _rotLevels[i + 1] = rl; - - changed = true; - } - } - - } while (changed); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getScaleAt(int Y) { - CAdScaleLevel *prev = NULL; - CAdScaleLevel *next = NULL; - - for (int i = 0; i < _scaleLevels.getSize(); i++) { - /* CAdScaleLevel *xxx = _scaleLevels[i];*/ - /* int j = _scaleLevels.getSize(); */ - if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; - else { - next = _scaleLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 100; - - int delta_y = next->_posY - prev->_posY; - float delta_scale = next->_scale - prev->_scale; - Y -= prev->_posY; - - float percent = (float)Y / ((float)delta_y / 100.0f); - return prev->_scale + delta_scale / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_autoScroll)); - persistMgr->transfer(TMEMBER(_editorColBlocked)); - persistMgr->transfer(TMEMBER(_editorColBlockedSel)); - persistMgr->transfer(TMEMBER(_editorColDecor)); - persistMgr->transfer(TMEMBER(_editorColDecorSel)); - persistMgr->transfer(TMEMBER(_editorColEntity)); - persistMgr->transfer(TMEMBER(_editorColEntitySel)); - persistMgr->transfer(TMEMBER(_editorColFrame)); - persistMgr->transfer(TMEMBER(_editorColRegion)); - persistMgr->transfer(TMEMBER(_editorColRegionSel)); - persistMgr->transfer(TMEMBER(_editorColScale)); - persistMgr->transfer(TMEMBER(_editorColWaypoints)); - persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); - persistMgr->transfer(TMEMBER(_editorMarginH)); - persistMgr->transfer(TMEMBER(_editorMarginV)); - persistMgr->transfer(TMEMBER(_editorShowBlocked)); - persistMgr->transfer(TMEMBER(_editorShowDecor)); - persistMgr->transfer(TMEMBER(_editorShowEntities)); - persistMgr->transfer(TMEMBER(_editorShowRegions)); - persistMgr->transfer(TMEMBER(_editorShowScale)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_initialized)); - persistMgr->transfer(TMEMBER(_lastTimeH)); - persistMgr->transfer(TMEMBER(_lastTimeV)); - _layers.persist(persistMgr); - persistMgr->transfer(TMEMBER(_mainLayer)); - _objects.persist(persistMgr); - persistMgr->transfer(TMEMBER(_offsetLeft)); - persistMgr->transfer(TMEMBER(_offsetTop)); - persistMgr->transfer(TMEMBER(_paralaxScrolling)); - persistMgr->transfer(TMEMBER(_persistentState)); - persistMgr->transfer(TMEMBER(_persistentStateSprites)); - persistMgr->transfer(TMEMBER(_pfMaxTime)); - _pfPath.persist(persistMgr); - persistMgr->transfer(TMEMBER(_pfPointsNum)); - persistMgr->transfer(TMEMBER(_pfReady)); - persistMgr->transfer(TMEMBER(_pfRequester)); - persistMgr->transfer(TMEMBER(_pfTarget)); - persistMgr->transfer(TMEMBER(_pfTargetPath)); - _rotLevels.persist(persistMgr); - _scaleLevels.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scrollPixelsH)); - persistMgr->transfer(TMEMBER(_scrollPixelsV)); - persistMgr->transfer(TMEMBER(_scrollTimeH)); - persistMgr->transfer(TMEMBER(_scrollTimeV)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER(_targetOffsetLeft)); - persistMgr->transfer(TMEMBER(_targetOffsetTop)); - _waypointGroups.persist(persistMgr); - persistMgr->transfer(TMEMBER(_viewport)); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::afterLoad() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { - double xStep, yStep, x, y; - int xLength, yLength, xCount, yCount; - int x1, y1, x2, y2; - - x1 = *targetX; - y1 = *targetY; - x2 = startX; - y2 = startY; - - - xLength = abs(x2 - x1); - yLength = abs(y2 - y1); - - if (xLength > yLength) { - /* - if (X1 > X2) - { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); - y = y1; - - for (xCount = x1; xCount < x2; xCount++) { - if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { - *targetX = xCount; - *targetY = (int)y; - return STATUS_OK; - } - y += yStep; - } - } else { - /* - if (Y1 > Y2) { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ - - xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); - x = x1; - - for (yCount = y1; yCount < y2; yCount++) { - if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { - *targetX = (int)x; - *targetY = yCount; - return STATUS_OK; - } - x += xStep; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { - int x = *argX; - int y = *argY; - - if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { - return STATUS_OK; - } - - // right - int length_right = 0; - bool found_right = false; - for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { - found_right = true; - break; - } - } - - // left - int length_left = 0; - bool found_left = false; - for (x = *argX, y = *argY; x >= 0; x--, length_left--) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { - found_left = true; - break; - } - } - - // up - int length_up = 0; - bool found_up = false; - for (x = *argX, y = *argY; y >= 0; y--, length_up--) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { - found_up = true; - break; - } - } - - // down - int length_down = 0; - bool found_down = false; - for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { - if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { - found_down = true; - break; - } - } - - if (!found_left && !found_right && !found_up && !found_down) { - return STATUS_OK; - } - - int OffsetX = INT_MAX, OffsetY = INT_MAX; - - if (found_left && found_right) { - if (abs(length_left) < abs(length_right)) OffsetX = length_left; - else OffsetX = length_right; - } else if (found_left) OffsetX = length_left; - else if (found_right) OffsetX = length_right; - - if (found_up && found_down) { - if (abs(length_up) < abs(length_down)) OffsetY = length_up; - else OffsetY = length_down; - } else if (found_up) OffsetY = length_up; - else if (found_down) OffsetY = length_down; - - if (abs(OffsetX) < abs(OffsetY)) - *argX = *argX + OffsetX; - else - *argY = *argY + OffsetY; - - if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsStart() { - _pfPointsNum = 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsAdd(int x, int y, int distance) { - if (_pfPointsNum >= _pfPath.getSize()) { - _pfPath.add(new CAdPathPoint(x, y, distance)); - } else { - _pfPath[_pfPointsNum]->x = x; - _pfPath[_pfPointsNum]->y = y; - _pfPath[_pfPointsNum]->_distance = distance; - _pfPath[_pfPointsNum]->_marked = false; - _pfPath[_pfPointsNum]->_origin = NULL; - } - - _pfPointsNum++; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { - CAdGame *adGame = (CAdGame *)_gameRef; - if (_viewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = _viewport->_offsetX; - if (offsetY) *offsetY = _viewport->_offsetY; - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; - if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; - } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportSize(int *width, int *height) { - CAdGame *adGame = (CAdGame *)_gameRef; - if (_viewport && !_gameRef->_editorMode) { - if (width) *width = _viewport->getWidth(); - if (height) *height = _viewport->getHeight(); - } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (width) *width = adGame->_sceneViewport->getWidth(); - if (height) *height = adGame->_sceneViewport->getHeight(); - } else { - if (width) *width = _gameRef->_renderer->_width; - if (height) *height = _gameRef->_renderer->_height; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetLeft() { - int viewportX; - getViewportOffset(&viewportX); - - return _offsetLeft - viewportX; -} - - -////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetTop() { - int viewportY; - getViewportOffset(NULL, &viewportY); - - return _offsetTop - viewportY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::pointInViewport(int x, int y) { - int left, top, width, height; - - getViewportOffset(&left, &top); - getViewportSize(&width, &height); - - return x >= left && x <= left + width && y >= top && y <= top + height; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdScene::setOffset(int offsetLeft, int offsetTop) { - _offsetLeft = offsetLeft; - _offsetTop = offsetTop; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNodeByName(const char *name) { - CBObject *ret = NULL; - - // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || - (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { - switch (node->_type) { - case OBJECT_ENTITY: - ret = node->_entity; - break; - case OBJECT_REGION: - ret = node->_region; - break; - default: - ret = NULL; - } - return ret; - } - } - } - - // free entities - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { - return _objects[i]; - } - } - - // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { - if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { - return _waypointGroups[i]; - } - } - - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveState() { - return persistState(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadState() { - return persistState(false); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::persistState(bool saving) { - if (!_persistentState) return STATUS_OK; - - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSceneState *state = adGame->getSceneState(_filename, saving); - if (!state) return STATUS_OK; - - CAdNodeState *nodeState; - - // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: - if (!node->_entity->_saveState) continue; - nodeState = state->getNodeState(node->_entity->_name, saving); - if (nodeState) { - nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); - //if(Saving) NodeState->_active = node->_entity->_active; - //else node->_entity->_active = NodeState->_active; - } - break; - case OBJECT_REGION: - if (!node->_region->_saveState) continue; - nodeState = state->getNodeState(node->_region->_name, saving); - if (nodeState) { - if (saving) nodeState->_active = node->_region->_active; - else node->_region->_active = nodeState->_active; - } - break; - default: - warning("CAdScene::PersistState - unhandled enum"); - break; - } - } - } - - // free entities - for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_saveState) continue; - if (_objects[i]->_type == OBJECT_ENTITY) { - nodeState = state->getNodeState(_objects[i]->_name, saving); - if (nodeState) { - nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); - //if(Saving) NodeState->_active = _objects[i]->_active; - //else _objects[i]->_active = NodeState->_active; - } - } - } - - // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { - nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); - if (nodeState) { - if (saving) nodeState->_active = _waypointGroups[i]->_active; - else _waypointGroups[i]->_active = nodeState->_active; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CAdScene::getRotationAt(int x, int y) { - CAdRotLevel *prev = NULL; - CAdRotLevel *next = NULL; - - for (int i = 0; i < _rotLevels.getSize(); i++) { - /* CAdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.getSize();*/ - if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; - else { - next = _rotLevels[i]; - break; - } - } - - if (prev == NULL || next == NULL) return 0; - - int delta_x = next->_posX - prev->_posX; - float delta_rot = next->_rotation - prev->_rotation; - x -= prev->_posX; - - float percent = (float)x / ((float)delta_x / 100.0f); - return prev->_rotation + delta_rot / 100 * percent; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::handleItemAssociations(const char *itemName, bool show) { - for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { - if (layer->_nodes[j]->_type == OBJECT_ENTITY) { - CAdEntity *ent = layer->_nodes[j]->_entity; - - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; - } - } - } - - for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { - CAdEntity *ent = (CAdEntity *)_objects[i]; - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { - int numUsed = 0; - if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (numUsed < numRegions - 1) { - regionList[numUsed] = node->_region; - numUsed++; - } else break; - } - } - } - for (int i = numUsed; i < numRegions; i++) { - regionList[i] = NULL; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::restoreDeviceObjects() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { - CBArray objects; - getSceneObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { - if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; - } - } - } - return objects[0]; - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { - CBArray objects; - getSceneObjects(objects, true); - - if (objects.getSize() == 0) return NULL; - else { - if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { - if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; - } - } - } - return objects[objects.getSize() - 1]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _layers.getSize(); i++) { - // close-up layer -> remove everything below it - if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); - - - for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { - CAdSceneNode *node = _layers[i]->_nodes[j]; - switch (node->_type) { - case OBJECT_ENTITY: { - CAdEntity *ent = node->_entity; - if (ent->_active && (ent->_registrable || !interactiveOnly)) - objects.add(ent); - } - break; - - case OBJECT_REGION: { - CBArray regionObj; - getRegionObjects(node->_region, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { - bool found = false; - for (int old = 0; old < objects.getSize(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) objects.add(regionObj[newIndex]); - } - //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); - } - break; - default: - warning("CAdScene::GetSceneObjects - Unhandled enum"); - break; - } - } - } - - // objects outside any region - CBArray regionObj; - getRegionObjects(NULL, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { - bool found = false; - for (int old = 0; old < objects.getSize(); old++) { - if (objects[old] == regionObj[newIndex]) { - found = true; - break; - } - } - if (!found) objects.add(regionObj[newIndex]); - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; - - // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { - obj = adGame->_objects[i]; - if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; - - objects.add(obj); - } - } - - // scene objects - for (int i = 0; i < _objects.getSize(); i++) { - obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; - - objects.add(obj); - } - } - - // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdScene.h b/engines/wintermute/ad/AdScene.h deleted file mode 100644 index f77c64aa9b..0000000000 --- a/engines/wintermute/ad/AdScene.h +++ /dev/null @@ -1,181 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENE_H -#define WINTERMUTE_ADSCENE_H - -#include "engines/wintermute/base/BFader.h" - -namespace WinterMute { - -class CUIWindow; -class CAdObject; -class CAdRegion; -class CBViewport; -class CAdLayer; -class CBPoint; -class CAdWaypointGroup; -class CAdPath; -class CAdScaleLevel; -class CAdRotLevel; -class CAdPathPoint; -class CAdScene : public CBObject { -public: - - CBObject *getNextAccessObject(CBObject *CurrObject); - CBObject *getPrevAccessObject(CBObject *CurrObject); - bool getSceneObjects(CBArray &Objects, bool InteractiveOnly); - bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); - - bool afterLoad(); - - bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); - bool handleItemAssociations(const char *ItemName, bool Show); - CUIWindow *_shieldWindow; - float getRotationAt(int X, int Y); - bool loadState(); - bool saveState(); - bool _persistentState; - bool _persistentStateSprites; - CBObject *getNodeByName(const char *name); - void setOffset(int OffsetLeft, int OffsetTop); - bool pointInViewport(int X, int Y); - int getOffsetTop(); - int getOffsetLeft(); - bool getViewportSize(int *Width = NULL, int *Height = NULL); - bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - CBViewport *_viewport; - CBFader *_fader; - int _pfPointsNum; - void pfPointsAdd(int X, int Y, int Distance); - void pfPointsStart(); - bool _initialized; - bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); - DECLARE_PERSISTENT(CAdScene, CBObject) - bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - bool displayRegionContentOld(CAdRegion *Region = NULL); - static int compareObjs(const void *Obj1, const void *Obj2); - - bool updateFreeObjects(); - bool traverseNodes(bool Update = false); - float getScaleAt(int Y); - bool sortScaleLevels(); - bool sortRotLevels(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); - bool _paralaxScrolling; - void skipTo(int OffsetX, int OffsetY); - void setDefaults(); - void cleanup(); - void skipToObject(CBObject *Object); - void scrollToObject(CBObject *Object); - void scrollTo(int OffsetX, int OffsetY); - virtual bool update(); - bool _autoScroll; - int _targetOffsetTop; - int _targetOffsetLeft; - - int _scrollPixelsV; - uint32 _scrollTimeV; - uint32 _lastTimeV; - - int _scrollPixelsH; - uint32 _scrollTimeH; - uint32 _lastTimeH; - - virtual bool display(); - uint32 _pfMaxTime; - bool initLoop(); - void pathFinderStep(); - bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - CAdLayer *_mainLayer; - float getZoomAt(int X, int Y); - bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); - CAdScene(CBGame *inGame); - virtual ~CAdScene(); - CBArray _layers; - CBArray _objects; - CBArray _waypointGroups; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - int _width; - int _height; - bool addObject(CAdObject *Object); - bool removeObject(CAdObject *Object); - int _editorMarginH; - int _editorMarginV; - uint32 _editorColFrame; - uint32 _editorColEntity; - uint32 _editorColRegion; - uint32 _editorColBlocked; - uint32 _editorColWaypoints; - uint32 _editorColEntitySel; - uint32 _editorColRegionSel; - uint32 _editorColBlockedSel; - uint32 _editorColWaypointsSel; - uint32 _editorColScale; - uint32 _editorColDecor; - uint32 _editorColDecorSel; - - bool _editorShowRegions; - bool _editorShowBlocked; - bool _editorShowDecor; - bool _editorShowEntities; - bool _editorShowScale; - CBArray _scaleLevels; - CBArray _rotLevels; - - virtual bool restoreDeviceObjects(); - int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - bool persistState(bool Saving = true); - void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); - bool _pfReady; - CBPoint *_pfTarget; - CAdPath *_pfTargetPath; - CBObject *_pfRequester; - CBArray _pfPath; - - int _offsetTop; - int _offsetLeft; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdSceneNode.cpp b/engines/wintermute/ad/AdSceneNode.cpp deleted file mode 100644 index 5f518e5442..0000000000 --- a/engines/wintermute/ad/AdSceneNode.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdSceneNode.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { - _type = OBJECT_NONE; - _region = NULL; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneNode::~CAdSceneNode() { - _gameRef->unregisterObject(_region); - _region = NULL; - - _gameRef->unregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setEntity(CAdEntity *entity) { - _type = OBJECT_ENTITY; - _entity = entity; - return _gameRef->registerObject(entity); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setRegion(CAdRegion *region) { - _type = OBJECT_REGION; - _region = region; - return _gameRef->registerObject(region); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - persistMgr->transfer(TMEMBER(_region)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSceneNode.h b/engines/wintermute/ad/AdSceneNode.h deleted file mode 100644 index d081959934..0000000000 --- a/engines/wintermute/ad/AdSceneNode.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENENODE_H -#define WINTERMUTE_ADSCENENODE_H - - -#include "engines/wintermute/ad/AdTypes.h" // Added by ClassView -#include "engines/wintermute/ad/AdRegion.h" // Added by ClassView -#include "engines/wintermute/ad/AdEntity.h" - -namespace WinterMute { - -class CAdSceneNode : public CBObject { -public: - DECLARE_PERSISTENT(CAdSceneNode, CBObject) - bool setRegion(CAdRegion *region); - bool setEntity(CAdEntity *entity); - CAdEntity *_entity; - CAdRegion *_region; - TObjectType _type; - CAdSceneNode(CBGame *inGame); - virtual ~CAdSceneNode(); - -}; - -} - -#endif diff --git a/engines/wintermute/ad/AdSceneState.cpp b/engines/wintermute/ad/AdSceneState.cpp deleted file mode 100644 index 5dfb8c537e..0000000000 --- a/engines/wintermute/ad/AdSceneState.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/ad/AdSceneState.h" -#include "engines/wintermute/ad/AdNodeState.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSceneState, false) - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSceneState::~CAdSceneState() { - delete[] _filename; - _filename = NULL; - - for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; - _nodeStates.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSceneState::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_filename)); - _nodeStates.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSceneState::setFilename(const char *filename) { - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { - for (int i = 0; i < _nodeStates.getSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; - } - - if (saving) { - CAdNodeState *ret = new CAdNodeState(_gameRef); - ret->setName(name); - _nodeStates.add(ret); - - return ret; - } else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSceneState.h b/engines/wintermute/ad/AdSceneState.h deleted file mode 100644 index 82207f383c..0000000000 --- a/engines/wintermute/ad/AdSceneState.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSCENESTATE_H -#define WINTERMUTE_ADSCENESTATE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { -class CAdNodeState; -class CAdSceneState : public CBBase { -public: - CAdNodeState *getNodeState(char *name, bool saving); - void setFilename(const char *filename); - DECLARE_PERSISTENT(CAdSceneState, CBBase) - CAdSceneState(CBGame *inGame); - virtual ~CAdSceneState(); - char *_filename; - CBArray _nodeStates; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdSentence.cpp b/engines/wintermute/ad/AdSentence.cpp deleted file mode 100644 index 98926caac6..0000000000 --- a/engines/wintermute/ad/AdSentence.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/ad/AdTalkDef.h" -#include "engines/wintermute/ad/AdTalkNode.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSentence, false) - -////////////////////////////////////////////////////////////////////////// -CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { - _text = NULL; - _stances = NULL; - _tempStance = NULL; - - _duration = 0; - _startTime = 0; - _currentStance = 0; - - _font = NULL; - - _pos.x = _pos.y = 0; - _width = _gameRef->_renderer->_width; - - _align = (TTextAlign)TAL_CENTER; - - _sound = NULL; - _soundStarted = false; - - _talkDef = NULL; - _currentSprite = NULL; - _currentSkelAnim = NULL; - _fixedPos = false; - _freezable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSentence::~CAdSentence() { - delete _sound; - delete[] _text; - delete[] _stances; - delete[] _tempStance; - delete _talkDef; - _sound = NULL; - _text = NULL; - _stances = NULL; - _tempStance = NULL; - _talkDef = NULL; - - _currentSprite = NULL; // ref only - _currentSkelAnim = NULL; - _font = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setText(const char *text) { - if (_text) delete [] _text; - _text = new char[strlen(text) + 1]; - if (_text) strcpy(_text, text); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setStances(const char *stances) { - if (_stances) delete [] _stances; - if (stances) { - _stances = new char[strlen(stances) + 1]; - if (_stances) strcpy(_stances, stances); - } else _stances = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getCurrentStance() { - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getNextStance() { - _currentStance++; - return getStance(_currentStance); -} - - -////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getStance(int stance) { - if (_stances == NULL) return NULL; - - if (_tempStance) delete [] _tempStance; - _tempStance = NULL; - - char *start; - char *curr; - int pos; - - if (stance == 0) start = _stances; - else { - pos = 0; - start = NULL; - curr = _stances; - while (pos < stance) { - if (*curr == '\0') break; - if (*curr == ',') pos++; - curr++; - } - if (pos == stance) start = curr; - } - - if (start == NULL) return NULL; - - while (*start == ' ' && *start != ',' && *start != '\0') start++; - - curr = start; - while (*curr != '\0' && *curr != ',') curr++; - - while (curr > start && *(curr - 1) == ' ') curr--; - - _tempStance = new char [curr - start + 1]; - if (_tempStance) { - _tempStance[curr - start] = '\0'; - strncpy(_tempStance, start, curr - start); - } - - return _tempStance; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::display() { - if (!_font || !_text) return STATUS_FAILED; - - if (_sound && !_soundStarted) { - _sound->play(); - _soundStarted = true; - } - - if (_gameRef->_subtitles) { - int x = _pos.x; - int y = _pos.y; - - if (!_fixedPos) { - x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); - } - - - x = MAX(x, 0); - x = MIN(x, _gameRef->_renderer->_width - _width); - y = MAX(y, 0); - - _font->drawText((byte *)_text, x, y, _width, _align); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CAdSentence::setSound(CBSound *sound) { - if (!sound) return; - delete _sound; - _sound = sound; - _soundStarted = false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::finish() { - if (_sound) _sound->stop(); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER_INT(_align)); - persistMgr->transfer(TMEMBER(_currentStance)); - persistMgr->transfer(TMEMBER(_currentSprite)); - persistMgr->transfer(TMEMBER(_currentSkelAnim)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_sound)); - persistMgr->transfer(TMEMBER(_soundStarted)); - persistMgr->transfer(TMEMBER(_stances)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_talkDef)); - persistMgr->transfer(TMEMBER(_tempStance)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_fixedPos)); - persistMgr->transfer(TMEMBER(_freezable)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::setupTalkFile(const char *soundFilename) { - delete _talkDef; - _talkDef = NULL; - _currentSprite = NULL; - - if (!soundFilename) return STATUS_OK; - - - AnsiString path = PathUtil::getDirectoryName(soundFilename); - AnsiString name = PathUtil::getFileNameWithoutExtension(soundFilename); - - AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); - if (file) { - _gameRef->_fileManager->closeFile(file); - } else return STATUS_OK; // no talk def file found - - - _talkDef = new CAdTalkDef(_gameRef); - if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { - delete _talkDef; - _talkDef = NULL; - return STATUS_FAILED; - } - //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::update(TDirection dir) { - if (!_talkDef) return STATUS_OK; - - uint32 currentTime; - // if sound is available, synchronize with sound, otherwise use timer - - /* - if (_sound) CurrentTime = _sound->GetPositionTime(); - else CurrentTime = _gameRef->_timer - _startTime; - */ - currentTime = _gameRef->_timer - _startTime; - - bool talkNodeFound = false; - for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { - if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { - talkNodeFound = true; - - CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); - if (newSprite != _currentSprite) newSprite->reset(); - _currentSprite = newSprite; - - if (!_talkDef->_nodes[i]->_playToEnd) break; - } - } - - - // no talk node, try to use default sprite instead (if any) - if (!talkNodeFound) { - CBSprite *newSprite = _talkDef->getDefaultSprite(dir); - if (newSprite) { - if (newSprite != _currentSprite) newSprite->reset(); - _currentSprite = newSprite; - } else _currentSprite = NULL; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSentence::CanSkip() { - // prevent accidental sentence skipping (TODO make configurable) - return (_gameRef->_timer - _startTime) > 300; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSentence.h b/engines/wintermute/ad/AdSentence.h deleted file mode 100644 index 954568878e..0000000000 --- a/engines/wintermute/ad/AdSentence.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSENTENCE_H -#define WINTERMUTE_ADSENTENCE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "common/rect.h" - -namespace WinterMute { -class CAdTalkDef; -class CBFont; -class CBSprite; -class CBSound; -class CAdSentence : public CBBase { -public: - bool _freezable; - bool _fixedPos; - CBSprite *_currentSprite; - char *_currentSkelAnim; - bool update(TDirection dir = DI_DOWN); - bool setupTalkFile(const char *soundFilename); - DECLARE_PERSISTENT(CAdSentence, CBBase) - bool finish(); - void setSound(CBSound *Sound); - bool _soundStarted; - CBSound *_sound; - TTextAlign _align; - bool display(); - int _width; - Point32 _pos; - CBFont *_font; - char *getNextStance(); - char *getCurrentStance(); - void setStances(const char *stances); - void setText(const char *text); - int _currentStance; - uint32 _startTime; - char *_stances; - char *_text; - uint32 _duration; - CAdSentence(CBGame *inGame); - virtual ~CAdSentence(); - CAdTalkDef *_talkDef; - - bool CanSkip(); - -private: - char *_tempStance; - char *getStance(int stance); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdSpriteSet.cpp b/engines/wintermute/ad/AdSpriteSet.cpp deleted file mode 100644 index 127d42d02b..0000000000 --- a/engines/wintermute/ad/AdSpriteSet.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdSpriteSet.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdSpriteSet, false) - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { - _owner = owner; - - for (int i = 0; i < NUM_DIRECTIONS; i++) - _sprites[i] = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::~CAdSpriteSet() { - for (int i = 0; i < NUM_DIRECTIONS; i++) { - delete _sprites[i]; - _sprites[i] = NULL; - } - - _owner = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(SPRITESET) -TOKEN_DEF(NAME) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(RIGHT) -TOKEN_DEF(UP) -TOKEN_DEF(DOWN) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(NAME) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(RIGHT) - TOKEN_TABLE(UP) - TOKEN_TABLE(DOWN) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { - _gameRef->LOG(0, "'SPRITESET' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - CBSprite *spr = NULL; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_LEFT: - delete _sprites[DI_LEFT]; - _sprites[DI_LEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_LEFT] = spr; - break; - - case TOKEN_RIGHT: - delete _sprites[DI_RIGHT]; - _sprites[DI_RIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_RIGHT] = spr; - break; - - case TOKEN_UP: - delete _sprites[DI_UP]; - _sprites[DI_UP] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UP] = spr; - break; - - case TOKEN_DOWN: - delete _sprites[DI_DOWN]; - _sprites[DI_DOWN] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWN] = spr; - break; - - case TOKEN_UP_LEFT: - delete _sprites[DI_UPLEFT]; - _sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPLEFT] = spr; - break; - - case TOKEN_UP_RIGHT: - delete _sprites[DI_UPRIGHT]; - _sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPRIGHT] = spr; - break; - - case TOKEN_DOWN_LEFT: - delete _sprites[DI_DOWNLEFT]; - _sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNLEFT] = spr; - break; - - case TOKEN_DOWN_RIGHT: - delete _sprites[DI_DOWNRIGHT]; - _sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNRIGHT] = spr; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITESET definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading SPRITESET definition"); - if (spr) delete spr; - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_owner)); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - persistMgr->transfer("", &_sprites[i]); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdSpriteSet::getSprite(TDirection direction) { - int dir = (int)direction; - if (dir < 0) dir = 0; - if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; - - CBSprite *ret = NULL; - - // find nearest set sprite - int numSteps = 0; - for (int i = dir; i >= 0; i--) { - if (_sprites[i] != NULL) { - ret = _sprites[i]; - numSteps = dir - i; - break; - } - } - - for (int i = dir; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] != NULL) { - if (ret == NULL || numSteps > i - dir) return _sprites[i]; - else return ret; - } - } - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITESET {\n"); - if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i]) { - switch (i) { - case DI_UP: - buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPRIGHT: - buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_RIGHT: - buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNRIGHT: - buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWN: - buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_DOWNLEFT: - buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_LEFT: - buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - case DI_UPLEFT: - buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); - break; - } - } - } - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::containsSprite(CBSprite *sprite) { - if (!sprite) return false; - - for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] == sprite) return true; - } - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdSpriteSet.h b/engines/wintermute/ad/AdSpriteSet.h deleted file mode 100644 index ba5c6fb75b..0000000000 --- a/engines/wintermute/ad/AdSpriteSet.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADSPRITESET_H -#define WINTERMUTE_ADSPRITESET_H - - -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BSprite.h" // Added by ClassView - -namespace WinterMute { - -class CAdSpriteSet : public CBObject { -public: - bool containsSprite(CBSprite *sprite); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBSprite *getSprite(TDirection direction); - DECLARE_PERSISTENT(CAdSpriteSet, CBObject) - CBObject *_owner; - CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); - virtual ~CAdSpriteSet(); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - CBSprite *_sprites[NUM_DIRECTIONS]; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdTalkDef.cpp b/engines/wintermute/ad/AdTalkDef.cpp deleted file mode 100644 index b598226413..0000000000 --- a/engines/wintermute/ad/AdTalkDef.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdTalkDef.h" -#include "engines/wintermute/ad/AdTalkNode.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/ad/AdSpriteSet.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkDef, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkDef::~CAdTalkDef() { - for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; - _nodes.removeAll(); - - delete[] _defaultSpriteFilename; - delete _defaultSprite; - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; - - delete[] _defaultSpriteSetFilename; - delete _defaultSpriteSet; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - CBUtils::setString(&_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TALK) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(ACTION) -TOKEN_DEF(DEFAULT_SPRITESET_FILE) -TOKEN_DEF(DEFAULT_SPRITESET) -TOKEN_DEF(DEFAULT_SPRITE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TALK) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(DEFAULT_SPRITESET_FILE) - TOKEN_TABLE(DEFAULT_SPRITESET) - TOKEN_TABLE(DEFAULT_SPRITE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { - _gameRef->LOG(0, "'TALK' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_ACTION: { - CAdTalkNode *Node = new CAdTalkNode(_gameRef); - if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); - else { - delete Node; - Node = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_DEFAULT_SPRITE: - CBUtils::setString(&_defaultSpriteFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); - break; - - case TOKEN_DEFAULT_SPRITESET: { - delete _defaultSpriteSet; - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TALK definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading TALK definition"); - return STATUS_FAILED; - } - - delete _defaultSprite; - delete _defaultSpriteSet; - _defaultSprite = NULL; - _defaultSpriteSet = NULL; - - if (_defaultSpriteFilename) { - _defaultSprite = new CBSprite(_gameRef); - if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; - } - - if (_defaultSpriteSetFilename) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_defaultSprite)); - persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); - persistMgr->transfer(TMEMBER(_defaultSpriteSet)); - persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); - - _nodes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "TALK {\n"); - if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); - - if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); - - for (int i = 0; i < _nodes.getSize(); i++) { - _nodes[i]->saveAsText(buffer, indent + 2); - buffer->putTextIndent(indent, "\n"); - } - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadDefaultSprite() { - if (_defaultSpriteFilename && !_defaultSprite) { - _defaultSprite = new CBSprite(_gameRef); - if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { - delete _defaultSprite; - _defaultSprite = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { - delete _defaultSpriteSet; - _defaultSpriteSet = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { - loadDefaultSprite(); - if (_defaultSprite) return _defaultSprite; - else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkDef.h b/engines/wintermute/ad/AdTalkDef.h deleted file mode 100644 index 81d6475013..0000000000 --- a/engines/wintermute/ad/AdTalkDef.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKDEF_H -#define WINTERMUTE_ADTALKDEF_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { -class CAdTalkNode; -class CAdSpriteSet; -class CAdTalkDef : public CBObject { -public: - char *_defaultSpriteSetFilename; - CAdSpriteSet *_defaultSpriteSet; - CBSprite *getDefaultSprite(TDirection Dir); - bool loadDefaultSprite(); - DECLARE_PERSISTENT(CAdTalkDef, CBObject) - - CAdTalkDef(CBGame *inGame); - virtual ~CAdTalkDef(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - CBArray _nodes; - char *_defaultSpriteFilename; - CBSprite *_defaultSprite; - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdTalkHolder.cpp b/engines/wintermute/ad/AdTalkHolder.cpp deleted file mode 100644 index e1a91792ce..0000000000 --- a/engines/wintermute/ad/AdTalkHolder.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdTalkHolder.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkHolder, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::~CAdTalkHolder() { - delete _sprite; - _sprite = NULL; - - for (int i = 0; i < _talkSprites.getSize(); i++) - delete _talkSprites[i]; - _talkSprites.removeAll(); - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) - delete _talkSpritesEx[i]; - _talkSpritesEx.removeAll(); -} - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { - CBSprite *ret = NULL; - - - // forced stance? - if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { - _forcedTalkAnimUsed = true; - delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); - if (_animSprite) { - bool res = _animSprite->loadFile(_forcedTalkAnimName); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); - delete _animSprite; - _animSprite = NULL; - } else return _animSprite; - } - } - - - if (stance != NULL) { - // search special talk stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { - ret = _talkSpritesEx[i]; - break; - } - } - if (ret == NULL) { - // serach generic talk stances - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { - ret = _talkSprites[i]; - break; - } - } - } - } - - // not a valid stance? get a random one - if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _sprite; - else { - // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); - ret = _talkSprites[rnd]; - } - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSprite - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSprite") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - - bool setCurrent = false; - if (_currentSprite && _currentSprite == _sprite) setCurrent = true; - - delete _sprite; - _sprite = NULL; - - if (val->isNULL()) { - _sprite = NULL; - if (setCurrent) _currentSprite = NULL; - stack->pushBool(true); - } else { - const char *filename = val->getString(); - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - script->runtimeError("SetSprite method failed for file '%s'", filename); - stack->pushBool(false); - } else { - _sprite = spr; - if (setCurrent) _currentSprite = _sprite; - stack->pushBool(true); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSprite") == 0) { - stack->correctParams(0); - - if (!_sprite || !_sprite->_filename) stack->pushNULL(); - else stack->pushString(_sprite->_filename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSpriteObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSpriteObject") == 0) { - stack->correctParams(0); - - if (!_sprite) stack->pushNULL(); - else stack->pushNative(_sprite, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool Ex = stack->pop()->getBool(); - - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("AddTalkSprite method failed for file '%s'", filename); - } else { - if (Ex) _talkSpritesEx.add(spr); - else _talkSprites.add(spr); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool ex = stack->pop()->getBool(); - - bool setCurrent = false; - bool setTemp2 = false; - - if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) - setCurrent = true; - if (_tempSprite2 == _talkSpritesEx[i]) - setTemp2 = true; - delete _talkSpritesEx[i]; - _talkSpritesEx.removeAt(i); - break; - } - } - } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { - if (_currentSprite == _talkSprites[i]) - setCurrent = true; - if (_tempSprite2 == _talkSprites[i]) - setTemp2 = true; - delete _talkSprites[i]; - _talkSprites.removeAt(i); - break; - } - } - - } - - stack->pushBool(true); - if (setCurrent) - _currentSprite = _sprite; - if (setTemp2) - _tempSprite2 = _sprite; - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetTalkSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetTalkSprite") == 0) { - stack->correctParams(2); - - const char *filename = stack->pop()->getString(); - bool ex = stack->pop()->getBool(); - bool setCurrent = false; - bool setTemp2 = false; - - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile(filename))) { - stack->pushBool(false); - script->runtimeError("SetTalkSprite method failed for file '%s'", filename); - } else { - - // delete current - if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i] == _currentSprite) - setCurrent = true; - if (_talkSpritesEx[i] == _tempSprite2) - setTemp2 = true; - delete _talkSpritesEx[i]; - } - _talkSpritesEx.removeAll(); - } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i] == _currentSprite) setCurrent = true; - if (_talkSprites[i] == _tempSprite2) setTemp2 = true; - delete _talkSprites[i]; - } - _talkSprites.removeAll(); - } - - // set new - if (ex) - _talkSpritesEx.add(spr); - else - _talkSprites.add(spr); - stack->pushBool(true); - - if (setCurrent) - _currentSprite = spr; - if (setTemp2) - _tempSprite2 = spr; - } - return STATUS_OK; - } - - else return CAdObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("talk-holder"); - return _scValue; - } - - else return CAdObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Item - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Item")==0){ - SetItem(value->getString()); - return STATUS_OK; - } - - else*/ return CAdObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CAdTalkHolder::scToString() { - return "[talk-holder object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { - for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); - } - - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { - CAdObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_sprite)); - _talkSprites.persist(persistMgr); - _talkSpritesEx.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkHolder.h b/engines/wintermute/ad/AdTalkHolder.h deleted file mode 100644 index 9e6c3bbd63..0000000000 --- a/engines/wintermute/ad/AdTalkHolder.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKHOLDER_H -#define WINTERMUTE_ADTALKHOLDER_H - -#include "engines/wintermute/ad/AdObject.h" - -namespace WinterMute { - -class CAdTalkHolder : public CAdObject { -public: - DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *getTalkStance(const char *stance); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - CBSprite *_sprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - CAdTalkHolder(CBGame *inGame); - virtual ~CAdTalkHolder(); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdTalkNode.cpp b/engines/wintermute/ad/AdTalkNode.cpp deleted file mode 100644 index da2195be33..0000000000 --- a/engines/wintermute/ad/AdTalkNode.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdTalkNode.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/ad/AdSpriteSet.h" -#include "engines/wintermute/utils/utils.h" -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdTalkNode, false) - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { - _sprite = NULL; - _spriteFilename = NULL; - _spriteSet = NULL; - _spriteSetFilename = NULL; - _comment = NULL; - - _startTime = _endTime = 0; - _playToEnd = false; - _preCache = false; -} - - -////////////////////////////////////////////////////////////////////////// -CAdTalkNode::~CAdTalkNode() { - delete[] _spriteFilename; - delete _sprite; - delete[] _spriteSetFilename; - delete _spriteSet; - delete _comment; - _spriteFilename = NULL; - _sprite = NULL; - _spriteSetFilename = NULL; - _spriteSet = NULL; - _comment = NULL; -} - - - -TOKEN_DEF_START -TOKEN_DEF(ACTION) -TOKEN_DEF(SPRITESET_FILE) -TOKEN_DEF(SPRITESET) -TOKEN_DEF(SPRITE) -TOKEN_DEF(START_TIME) -TOKEN_DEF(END_TIME) -TOKEN_DEF(COMMENT) -TOKEN_DEF(PRECACHE) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ACTION) - TOKEN_TABLE(SPRITESET_FILE) - TOKEN_TABLE(SPRITESET) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(START_TIME) - TOKEN_TABLE(END_TIME) - TOKEN_TABLE(COMMENT) - TOKEN_TABLE(PRECACHE) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { - _gameRef->LOG(0, "'ACTION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - _endTime = 0; - _playToEnd = false; - _preCache = false; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SPRITE: - CBUtils::setString(&_spriteFilename, (char *)params); - break; - - case TOKEN_SPRITESET_FILE: - CBUtils::setString(&_spriteSetFilename, (char *)params); - break; - - case TOKEN_SPRITESET: { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { - delete _spriteSet; - _spriteSet = NULL; - cmd = PARSERR_GENERIC; - } - } - break; - - case TOKEN_START_TIME: - parser.scanStr((char *)params, "%d", &_startTime); - break; - - case TOKEN_END_TIME: - parser.scanStr((char *)params, "%d", &_endTime); - break; - - case TOKEN_PRECACHE: - parser.scanStr((char *)params, "%b", &_preCache); - break; - - case TOKEN_COMMENT: - if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ACTION definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ACTION definition"); - return STATUS_FAILED; - } - - if (_endTime == 0) - _playToEnd = true; - else - _playToEnd = false; - - if (_preCache && _spriteFilename) { - delete _sprite; - _sprite = new CBSprite(_gameRef); - if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) - return STATUS_FAILED; - } - - if (_preCache && _spriteSetFilename) { - delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) - return STATUS_FAILED; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_comment)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_endTime)); - persistMgr->transfer(TMEMBER(_playToEnd)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_spriteFilename)); - persistMgr->transfer(TMEMBER(_spriteSet)); - persistMgr->transfer(TMEMBER(_spriteSetFilename)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ACTION {\n"); - if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); - buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); - if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadSprite() { - if (_spriteFilename && !_sprite) { - _sprite = new CBSprite(_gameRef); - if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { - delete _sprite; - _sprite = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } - - else if (_spriteSetFilename && !_spriteSet) { - _spriteSet = new CAdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { - delete _spriteSet; - _spriteSet = NULL; - return STATUS_FAILED; - } else return STATUS_OK; - } - - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { - if (time >= _startTime) { - if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; - else return false; - } else return _endTime >= time; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::getSprite(TDirection dir) { - loadSprite(); - if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->getSprite(dir); - else return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdTalkNode.h b/engines/wintermute/ad/AdTalkNode.h deleted file mode 100644 index 11bbb353c1..0000000000 --- a/engines/wintermute/ad/AdTalkNode.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTALKNODE_H -#define WINTERMUTE_ADTALKNODE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CAdSpriteSet; -class CBSprite; -class CAdTalkNode : public CBBase { -public: - char *_spriteSetFilename; - CAdSpriteSet *_spriteSet; - CBSprite *getSprite(TDirection dir); - bool isInTimeInterval(uint32 time, TDirection dir); - bool loadSprite(); - DECLARE_PERSISTENT(CAdTalkNode, CBBase) - - CAdTalkNode(CBGame *inGame); - virtual ~CAdTalkNode(); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - char *_spriteFilename; - CBSprite *_sprite; - uint32 _startTime; - uint32 _endTime; - bool _playToEnd; - bool _preCache; - char *_comment; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/AdTypes.h b/engines/wintermute/ad/AdTypes.h deleted file mode 100644 index b88d6fe259..0000000000 --- a/engines/wintermute/ad/AdTypes.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADTYPES_H -#define WINTERMUTE_ADTYPES_H - -namespace WinterMute { - -typedef enum { - GAME_NORMAL, - GAME_WAITING_RESPONSE -} TGameStateEx; - -typedef enum { - OBJECT_ENTITY, - OBJECT_REGION, - OBJECT_ACTOR, - OBJECT_NONE -} TObjectType; - -typedef enum { - ENTITY_NORMAL, - ENTITY_SOUND -} TEntityType; - -typedef enum { - STATE_NONE, - STATE_IDLE, - STATE_PLAYING_ANIM, - STATE_READY, - STATE_FOLLOWING_PATH, - STATE_SEARCHING_PATH, - STATE_WAITING_PATH, - STATE_TURNING_LEFT, - STATE_TURNING_RIGHT, - STATE_TURNING, - STATE_TALKING, - STATE_DIRECT_CONTROL, - STATE_PLAYING_ANIM_SET -} TObjectState; - -typedef enum { - DIRECT_WALK_NONE, - DIRECT_WALK_FW, - DIRECT_WALK_BK -} TDirectWalkMode; - -typedef enum { - DIRECT_TURN_NONE, - DIRECT_TURN_CW, - DIRECT_TURN_CCW -} TDirectTurnMode; - -typedef enum { - RESPONSE_TEXT, - RESPONSE_ICON -} TResponseStyle; - -typedef enum { - RESPONSE_ALWAYS, - RESPONSE_ONCE, - RESPONSE_ONCE_GAME -} TResponseType; - - -typedef enum { - TALK_SKIP_LEFT = 0, - TALK_SKIP_RIGHT = 1, - TALK_SKIP_BOTH = 2, - TALK_SKIP_NONE = 3 -} TTalkSkipButton; - -typedef enum { - GEOM_WAYPOINT, - GEOM_WALKPLANE, - GEOM_BLOCKED, - GEOM_GENERIC -} TGeomNodeType; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/ad/AdWaypointGroup.cpp b/engines/wintermute/ad/AdWaypointGroup.cpp deleted file mode 100644 index 3080b34c09..0000000000 --- a/engines/wintermute/ad/AdWaypointGroup.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BFileManager.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; -} - - -////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::~CAdWaypointGroup() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CAdWaypointGroup::cleanup() { - for (int i = 0; i < _points.getSize(); i++) - delete _points[i]; - _points.removeAll(); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WAYPOINTS) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(POINT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WAYPOINTS) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(POINT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { - _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr((char *)params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in WAYPOINTS definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WAYPOINTS {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - if (_scProp) - _scProp->saveAsText(buffer, indent + 2); - CBBase::saveAsText(buffer, indent + 2); - - for (int i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - buffer->putTextIndent(indent, "}\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("waypoint-group"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { - if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; - - cleanup(); - - for (int i = 0; i < wpt->_points.getSize(); i++) { - int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); - int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); - - _points.add(new CBPoint(x + argX, y + argY)); - } - - _lastMimicScale = scale; - _lastMimicX = argX; - _lastMimicY = argY; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ad/AdWaypointGroup.h b/engines/wintermute/ad/AdWaypointGroup.h deleted file mode 100644 index f7c9e4c361..0000000000 --- a/engines/wintermute/ad/AdWaypointGroup.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_ADWAYPOINTGROUP_H -#define WINTERMUTE_ADWAYPOINTGROUP_H - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { -class CBPoint; -class CAdWaypointGroup : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); - DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - bool _active; - CAdWaypointGroup(CBGame *inGame); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual ~CAdWaypointGroup(); - CBArray _points; - int _editorSelectedPoint; - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp new file mode 100644 index 0000000000..36f1aa8286 --- /dev/null +++ b/engines/wintermute/ad/ad_actor.cpp @@ -0,0 +1,1316 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/ad/ad_actor.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/ad/ad_sprite_set.h" +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/ad/ad_path.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdActor, false) + + +////////////////////////////////////////////////////////////////////////// +CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { + _path = new CAdPath(_gameRef); + + _type = OBJECT_ACTOR; + _dir = DI_LEFT; + + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _targetPoint = new CBPoint; + _afterWalkDir = DI_NONE; + + _animSprite2 = NULL; + + setDefaultAnimNames(); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::setDefaultAnimNames() { + _talkAnimName = "talk"; + _idleAnimName = "idle"; + _walkAnimName = "walk"; + _turnLeftAnimName = "turnleft"; + _turnRightAnimName = "turnright"; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdActor::~CAdActor() { + delete _path; + delete _targetPoint; + _path = NULL; + _targetPoint = NULL; + + delete _walkSprite; + delete _standSprite; + delete _turnLeftSprite; + delete _turnRightSprite; + _walkSprite = NULL; + _standSprite = NULL; + _turnLeftSprite = NULL; + _turnRightSprite = NULL; + + _animSprite2 = NULL; // ref only + + for (int i = 0; i < _talkSprites.getSize(); i++) { + delete _talkSprites[i]; + } + _talkSprites.removeAll(); + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + delete _talkSpritesEx[i]; + } + _talkSpritesEx.removeAll(); + + for (int i = 0; i < _anims.getSize(); i++) { + delete _anims[i]; + _anims[i] = NULL; + } + _anims.removeAll(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ACTOR) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(WALK) +TOKEN_DEF(STAND) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(TURN_LEFT) +TOKEN_DEF(TURN_RIGHT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ANIMATION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdActor::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTOR) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(WALK) + TOKEN_TABLE(STAND) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TURN_LEFT) + TOKEN_TABLE(TURN_RIGHT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { + _gameRef->LOG(0, "'ACTOR' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CAdGame *adGame = (CAdGame *)_gameRef; + CAdSpriteSet *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.scanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.scanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.scanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.scanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_WALK: + delete _walkSprite; + _walkSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; + else _walkSprite = spr; + break; + + case TOKEN_TALK: + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + break; + + case TOKEN_TALK_SPECIAL: + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + break; + + case TOKEN_STAND: + delete _standSprite; + _standSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; + else _standSprite = spr; + break; + + case TOKEN_TURN_LEFT: + delete _turnLeftSprite; + _turnLeftSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnLeftSprite = spr; + break; + + case TOKEN_TURN_RIGHT: + delete _turnRightSprite; + _turnRightSprite = NULL; + spr = new CAdSpriteSet(_gameRef, this); + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; + else _turnRightSprite = spr; + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SOUND_VOLUME: + parser.scanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_SOUND_PANNING: + parser.scanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { + delete _blockRegion; + delete _currentBlockRegion; + _blockRegion = NULL; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { + delete _wptGroup; + delete _currentWptGroup; + _wptGroup = NULL; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->mimic(_wptGroup); + } + } + break; + + case TOKEN_IGNORE_ITEMS: + parser.scanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + else _anims.add(Anim); + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ACTOR definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + if (spr) delete spr; + _gameRef->LOG(0, "Error loading ACTOR definition"); + return STATUS_FAILED; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + _state = _nextState = STATE_READY; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::turnTo(TDirection dir) { + int delta1, delta2, delta3, delta; + + delta1 = dir - _dir; + delta2 = dir + NUM_DIRECTIONS - _dir; + delta3 = dir - NUM_DIRECTIONS - _dir; + + delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2; + delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3; + + // already there? + if (abs(delta) < 2) { + _dir = dir; + _state = _nextState; + _nextState = STATE_READY; + return; + } + + _targetDir = dir; + _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; + + _tempSprite2 = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { + _afterWalkDir = afterWalkDir; + if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; + + _path->reset(); + _path->setReady(false); + + _targetPoint->x = x; + _targetPoint->y = y; + + ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + + _state = STATE_SEARCHING_PATH; + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::display() { + if (_active) updateSounds(); + + uint32 alpha; + if (_alphaColor != 0) alpha = _alphaColor; + else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + + float rotate; + if (_rotatable) { + if (_rotateValid) rotate = _rotate; + else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } else rotate = 0.0f; + + if (_active) displaySpriteAttachments(true); + + if (_currentSprite && _active) { + bool reg = _registrable; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; + + _currentSprite->display(_posX, + _posY, + reg ? _registerAlias : NULL, + scaleX, + scaleY, + alpha, + rotate, + _blendMode); + + } + + if (_active) displaySpriteAttachments(false); + if (_active && _partEmitter) _partEmitter->display(); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::update() { + _currentSprite = NULL; + + if (_state == STATE_READY) { + if (_animSprite) { + delete _animSprite; + _animSprite = NULL; + } + if (_animSprite2) { + _animSprite2 = NULL; + } + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite; + } + + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { + _state = _nextState; + _nextState = STATE_READY; + _currentSprite = _animSprite2; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + } + + bool already_moved = false; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM_SET: + _currentSprite = _animSprite2; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_LEFT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_dir > 0) _dir = (TDirection)(_dir - 1); + else _dir = (TDirection)(NUM_DIRECTIONS - 1); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnLeftSprite) { + _tempSprite2 = _turnLeftSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_TURNING_RIGHT: + if (_tempSprite2 == NULL || _tempSprite2->_finished) { + _dir = (TDirection)(_dir + 1); + + if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); + + if (_dir == _targetDir) { + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + if (_turnRightSprite) { + _tempSprite2 = _turnRightSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); + if (Anim) _tempSprite2 = Anim->getSprite(_dir); + } + + if (_tempSprite2) { + _tempSprite2->reset(); + if (_tempSprite2->_looping) _tempSprite2->_looping = false; + } + _currentSprite = _tempSprite2; + } + } else _currentSprite = _tempSprite2; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_SEARCHING_PATH: + // keep asking scene for the path + if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + _state = STATE_WAITING_PATH; + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_WAITING_PATH: + // wait until the scene finished the path + if (_path->_ready) followPath(); + break; + + + ////////////////////////////////////////////////////////////////////////// + case STATE_FOLLOWING_PATH: + getNextStep(); + already_moved = true; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(_dir); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = _nextState; + _nextState = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite && !_animSprite2) { + if (_sprite) _currentSprite = _sprite; + else { + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + } + break; + default: + error("AdActor::Update - Unhandled enum"); + } + + + if (_currentSprite && !already_moved) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + afterMove(); + } + } + + //_gameRef->QuickMessageForm("%s", _currentSprite->_filename); + + updateBlockRegion(); + _ready = (_state == STATE_READY); + + updatePartEmitter(); + updateSpriteAttachments(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::followPath() { + // skip current position + _path->getFirst(); + while (_path->getCurrent() != NULL) { + if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; + _path->getNext(); + } + + // are there points to follow? + if (_path->getCurrent() != NULL) { + _state = STATE_FOLLOWING_PATH;; + initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + } else { + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); + else _state = STATE_READY; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::getNextStep() { + if (_walkSprite) { + _currentSprite = _walkSprite->getSprite(_dir); + } else { + CAdSpriteSet *Anim = getAnimByName(_walkAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + + if (!_currentSprite) return; + + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (!_currentSprite->_changed) return; + + + int maxStepX, maxStepY; + maxStepX = abs(_currentSprite->_moveX); + maxStepY = abs(_currentSprite->_moveY); + + maxStepX = MAX(maxStepX, maxStepY); + maxStepX = MAX(maxStepX, 1); + + while (_pFCount > 0 && maxStepX >= 0) { + _pFX += _pFStepX; + _pFY += _pFStepY; + + _pFCount--; + maxStepX--; + } + + if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { + if (_pFCount == 0) { + _state = _nextState; + _nextState = STATE_READY; + return; + } + goTo(_targetPoint->x, _targetPoint->y); + return; + } + + + _posX = (int)_pFX; + _posY = (int)_pFY; + + afterMove(); + + + if (_pFCount == 0) { + if (_path->getNext() == NULL) { + _posX = _targetPoint->x; + _posY = _targetPoint->y; + + _path->reset(); + if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); + else { + _state = _nextState; + _nextState = STATE_READY; + } + } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { + _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); + + _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; + _pFStepY = (double)(endPt.y - startPt.y) / _pFCount; + + _pFX = startPt.x; + _pFY = startPt.y; + + int angle = (int)(atan2((double)(endPt.y - startPt.y), (double)(endPt.x - startPt.x)) * (180 / 3.14)); + + _nextState = STATE_FOLLOWING_PATH; + + turnTo(angleToDirection(angle)); +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GoTo / GoToAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { + stack->correctParams(2); + int X = stack->pop()->getInt(); + int Y = stack->pop()->getInt(); + goTo(X, Y); + if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoToObject / GoToObjectAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (!Val->isNative()) { + script->runtimeError("actor.%s method accepts an entity refrence only", name); + stack->pushNULL(); + return STATUS_OK; + } + CAdObject *Obj = (CAdObject *)Val->getNative(); + if (!Obj || Obj->_type != OBJECT_ENTITY) { + script->runtimeError("actor.%s method accepts an entity refrence only", name); + stack->pushNULL(); + return STATUS_OK; + } + CAdEntity *Ent = (CAdEntity *)Obj; + if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); + else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); + if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnTo / TurnToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { + stack->correctParams(1); + int dir; + CScValue *val = stack->pop(); + + // turn to object? + if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { + CBObject *obj = (CBObject *)val->getNative(); + int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); + dir = (int)angleToDirection(angle); + } + // otherwise turn to direction + else dir = val->getInt(); + + if (dir >= 0 && dir < NUM_DIRECTIONS) { + turnTo((TDirection)dir); + if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsWalking") == 0) { + stack->correctParams(0); + stack->pushBool(_state == STATE_FOLLOWING_PATH); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MergeAnims + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MergeAnims") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(mergeAnims(stack->pop()->getString()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadAnim") == 0) { + stack->correctParams(1); + const char *AnimName = stack->pop()->getString(); + + bool Found = false; + for (int i = 0; i < _anims.getSize(); i++) { + if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { + // invalidate sprites in use + if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; + if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; + if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; + + delete _anims[i]; + _anims[i] = NULL; + _anims.removeAt(i); + i--; + Found = true; + } + } + stack->pushBool(Found); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasAnim") == 0) { + stack->correctParams(1); + const char *AnimName = stack->pop()->getString(); + stack->pushBool(getAnimByName(AnimName) != NULL); + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdActor::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Direction") == 0) { + _scValue->setInt(_dir); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Type") == 0) { + _scValue->setString("actor"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkAnimName") == 0) { + _scValue->setString(_talkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkAnimName") == 0) { + _scValue->setString(_walkAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IdleAnimName") == 0) { + _scValue->setString(_idleAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnLeftAnimName") == 0) { + _scValue->setString(_turnLeftAnimName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnRightAnimName") == 0) { + _scValue->setString(_turnRightAnimName); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Direction + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Direction") == 0) { + int dir = value->getInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkAnimName") == 0) { + if (value->isNULL()) _talkAnimName = "talk"; + else _talkAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkAnimName") == 0) { + if (value->isNULL()) _walkAnimName = "walk"; + else _walkAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IdleAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IdleAnimName") == 0) { + if (value->isNULL()) _idleAnimName = "idle"; + else _idleAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnLeftAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnLeftAnimName") == 0) { + if (value->isNULL()) _turnLeftAnimName = "turnleft"; + else _turnLeftAnimName = value->getString(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TurnRightAnimName + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TurnRightAnimName") == 0) { + if (value->isNULL()) _turnRightAnimName = "turnright"; + else _turnRightAnimName = value->getString(); + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdActor::scToString() { + return "[actor object]"; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::getTalkStance(const char *stance) { + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + // old way + if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) + return getTalkStanceOld(stance); + + // new way + CBSprite *ret = NULL; + + // do we have an animation with this name? + CAdSpriteSet *Anim = getAnimByName(stance); + if (Anim) ret = Anim->getSprite(_dir); + + // not - get a random talk + if (!ret) { + CBArray TalkAnims; + for (int i = 0; i < _anims.getSize(); i++) { + if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) + TalkAnims.add(_anims[i]); + } + + if (TalkAnims.getSize() > 0) { + int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); + ret = TalkAnims[rnd]->getSprite(_dir); + } else { + if (_standSprite) ret = _standSprite->getSprite(_dir); + else { + Anim = getAnimByName(_idleAnimName); + if (Anim) ret = Anim->getSprite(_dir); + } + } + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdActor::getTalkStanceOld(const char *stance) { + CBSprite *ret = NULL; + + if (stance != NULL) { + // search special stances + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + ret = _talkSpritesEx[i]->getSprite(_dir); + break; + } + } + if (ret == NULL) { + // search generic stances + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + ret = _talkSprites[i]->getSprite(_dir); + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); + else { + // TODO: remember last + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + ret = _talkSprites[rnd]->getSprite(_dir); + } + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_dir)); + persistMgr->transfer(TMEMBER(_path)); + persistMgr->transfer(TMEMBER(_pFCount)); + persistMgr->transfer(TMEMBER(_pFStepX)); + persistMgr->transfer(TMEMBER(_pFStepY)); + persistMgr->transfer(TMEMBER(_pFX)); + persistMgr->transfer(TMEMBER(_pFY)); + persistMgr->transfer(TMEMBER(_standSprite)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_targetDir)); + persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); + persistMgr->transfer(TMEMBER(_targetPoint)); + persistMgr->transfer(TMEMBER(_turnLeftSprite)); + persistMgr->transfer(TMEMBER(_turnRightSprite)); + persistMgr->transfer(TMEMBER(_walkSprite)); + + persistMgr->transfer(TMEMBER(_animSprite2)); + persistMgr->transfer(TMEMBER(_talkAnimName)); + persistMgr->transfer(TMEMBER(_idleAnimName)); + persistMgr->transfer(TMEMBER(_walkAnimName)); + persistMgr->transfer(TMEMBER(_turnLeftAnimName)); + persistMgr->transfer(TMEMBER(_turnRightAnimName)); + + _anims.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TDirection CAdActor::angleToDirection(int angle) { + TDirection ret = DI_DOWN;; + + if (angle > -112 && angle <= -67) ret = DI_UP; + else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; + else if (angle > -22 && angle <= 22) ret = DI_RIGHT; + else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; + else if (angle > 67 && angle <= 112) ret = DI_DOWN; + else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; + else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; + else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdActor::getHeight() { + // if no current sprite is set, set some + if (_currentSprite == NULL) { + if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); + else { + CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + if (Anim) _currentSprite = Anim->getSprite(_dir); + } + } + // and get height + return CAdTalkHolder::getHeight(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { + for (int i = 0; i < _anims.getSize(); i++) { + if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) + return _anims[i]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::mergeAnims(const char *animsFilename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ANIMATION) + TOKEN_TABLE_END + + + byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); + if (fileBuffer == NULL) { + _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); + return STATUS_FAILED; + } + + byte *buffer = fileBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + bool Ret = STATUS_OK; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ANIMATION: { + CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + Ret = STATUS_FAILED; + } else _anims.add(Anim); + } + break; + } + } + delete [] fileBuffer; + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdActor::playAnim(const char *filename) { + // if we have an anim with this name, use it + CAdSpriteSet *Anim = getAnimByName(filename); + if (Anim) { + _animSprite2 = Anim->getSprite(_dir); + if (_animSprite2) { + _animSprite2->reset(); + _state = STATE_PLAYING_ANIM_SET; + return STATUS_OK; + } + } + // otherwise call the standard handler + return CAdTalkHolder::playAnim(filename); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h new file mode 100644 index 0000000000..ca79f638d9 --- /dev/null +++ b/engines/wintermute/ad/ad_actor.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADACTOR_H +#define WINTERMUTE_ADACTOR_H + + +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/ad/ad_types.h" // Added by ClassView +#include "engines/wintermute/ad/ad_talk_holder.h" +#include "engines/wintermute/base/base_point.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "common/str.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +namespace WinterMute { +class CAdSpriteSet; +class CAdPath; +class CAdActor : public CAdTalkHolder { +public: + TDirection angleToDirection(int angle); + DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) + virtual int getHeight(); + CBSprite *getTalkStance(const char *stance); + virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); + CBPoint *_targetPoint; + virtual bool update(); + virtual bool display(); + TDirection _targetDir; + TDirection _afterWalkDir; + virtual void turnTo(TDirection dir); + CAdPath *_path; + CAdSpriteSet *_walkSprite; + CAdSpriteSet *_standSprite; + CAdSpriteSet *_turnLeftSprite; + CAdSpriteSet *_turnRightSprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + TDirection _dir; + CAdActor(CBGame *inGame/*=NULL*/); + virtual ~CAdActor(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + + // new anim system + Common::String _talkAnimName; + Common::String _idleAnimName; + Common::String _walkAnimName; + Common::String _turnLeftAnimName; + Common::String _turnRightAnimName; + CBArray _anims; + virtual bool playAnim(const char *filename); + CAdSpriteSet *getAnimByName(const Common::String &animName); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + bool setDefaultAnimNames(); + CBSprite *getTalkStanceOld(const char *stance); + bool mergeAnims(const char *animsFilename); + CBSprite *_animSprite2; + + void initLine(CBPoint startPt, CBPoint endPt); + void getNextStep(); + void followPath(); + double _pFStepX; + double _pFStepY; + double _pFX; + double _pFY; + int _pFCount; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp new file mode 100644 index 0000000000..5f32017264 --- /dev/null +++ b/engines/wintermute/ad/ad_entity.cpp @@ -0,0 +1,1027 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdEntity, false) + +////////////////////////////////////////////////////////////////////////// +CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { + _type = OBJECT_ENTITY; + _subtype = ENTITY_NORMAL; + _region = NULL; + _item = NULL; + + _walkToX = _walkToY = 0; + _walkToDir = DI_NONE; + + _theora = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdEntity::~CAdEntity() { + _gameRef->unregisterObject(_region); + + delete _theora; + _theora = NULL; + + delete[] _item; + _item = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SCALABLE) +TOKEN_DEF(REGISTRABLE) +TOKEN_DEF(INTERACTIVE) +TOKEN_DEF(SHADOWABLE) +TOKEN_DEF(COLORABLE) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(FONT) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(CURSOR) +TOKEN_DEF(REGION) +TOKEN_DEF(BLOCKED_REGION) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(SOUND_START_TIME) +TOKEN_DEF(SOUND_VOLUME) +TOKEN_DEF(SOUND_PANNING) +TOKEN_DEF(SOUND) +TOKEN_DEF(SUBTYPE) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(IGNORE_ITEMS) +TOKEN_DEF(ROTABLE) +TOKEN_DEF(ROTATABLE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(SCALE) +TOKEN_DEF(RELATIVE_SCALE) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(ITEM) +TOKEN_DEF(WALK_TO_X) +TOKEN_DEF(WALK_TO_Y) +TOKEN_DEF(WALK_TO_DIR) +TOKEN_DEF(SAVE_STATE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCALABLE) + TOKEN_TABLE(REGISTRABLE) + TOKEN_TABLE(INTERACTIVE) + TOKEN_TABLE(SHADOWABLE) + TOKEN_TABLE(COLORABLE) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(REGION) + TOKEN_TABLE(BLOCKED_REGION) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(SOUND_START_TIME) + TOKEN_TABLE(SOUND_VOLUME) + TOKEN_TABLE(SOUND_PANNING) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(SUBTYPE) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(IGNORE_ITEMS) + TOKEN_TABLE(ROTABLE) + TOKEN_TABLE(ROTATABLE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(RELATIVE_SCALE) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(WALK_TO_X) + TOKEN_TABLE(WALK_TO_Y) + TOKEN_TABLE(WALK_TO_DIR) + TOKEN_TABLE(SAVE_STATE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { + _gameRef->LOG(0, "'ENTITY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CAdGame *adGame = (CAdGame *)_gameRef; + CBSprite *spr = NULL; + int ar = 0, ag = 0, ab = 0, alpha = 0; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SPRITE: { + delete _sprite; + _sprite = NULL; + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + break; + + case TOKEN_TALK: { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + } + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_ITEM: + setItem((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_SCALABLE: + parser.scanStr((char *)params, "%b", &_zoomable); + break; + + case TOKEN_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _scale = (float)s; + + } + break; + + case TOKEN_RELATIVE_SCALE: { + int s; + parser.scanStr((char *)params, "%d", &s); + _relativeScale = (float)s; + + } + break; + + case TOKEN_ROTABLE: + case TOKEN_ROTATABLE: + parser.scanStr((char *)params, "%b", &_rotatable); + break; + + case TOKEN_REGISTRABLE: + case TOKEN_INTERACTIVE: + parser.scanStr((char *)params, "%b", &_registrable); + break; + + case TOKEN_SHADOWABLE: + case TOKEN_COLORABLE: + parser.scanStr((char *)params, "%b", &_shadowable); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_REGION: { + if (_region) _gameRef->unregisterObject(_region); + _region = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; + else { + _region = rgn; + _gameRef->registerObject(_region); + } + } + break; + + case TOKEN_BLOCKED_REGION: { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + CBRegion *rgn = new CBRegion(_gameRef); + CBRegion *crgn = new CBRegion(_gameRef); + if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { + delete _blockRegion; + _blockRegion = NULL; + delete _currentBlockRegion; + _currentBlockRegion = NULL; + cmd = PARSERR_GENERIC; + } else { + _blockRegion = rgn; + _currentBlockRegion = crgn; + _currentBlockRegion->mimic(_blockRegion); + } + } + break; + + case TOKEN_WAYPOINTS: { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { + delete _wptGroup; + _wptGroup = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + cmd = PARSERR_GENERIC; + } else { + _wptGroup = wpt; + _currentWptGroup = cwpt; + _currentWptGroup->mimic(_wptGroup); + } + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_SUBTYPE: { + if (scumm_stricmp((char *)params, "sound") == 0) { + delete _sprite; + _sprite = NULL; + if (_gameRef->_editorMode) { + spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; + else _sprite = spr; + } + if (_gameRef->_editorMode) _editorOnly = true; + _zoomable = false; + _rotatable = false; + _registrable = _gameRef->_editorMode; + _shadowable = false; + _subtype = ENTITY_SOUND; + } + } + break; + + case TOKEN_SOUND: + playSFX((char *)params, false, false); + break; + + case TOKEN_SOUND_START_TIME: + parser.scanStr((char *)params, "%d", &_sFXStart); + break; + + case TOKEN_SOUND_VOLUME: + parser.scanStr((char *)params, "%d", &_sFXVolume); + break; + + case TOKEN_SOUND_PANNING: + parser.scanStr((char *)params, "%b", &_autoSoundPanning); + break; + + case TOKEN_SAVE_STATE: + parser.scanStr((char *)params, "%b", &_saveState); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_IGNORE_ITEMS: + parser.scanStr((char *)params, "%b", &_ignoreItems); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_WALK_TO_X: + parser.scanStr((char *)params, "%d", &_walkToX); + break; + + case TOKEN_WALK_TO_Y: + parser.scanStr((char *)params, "%d", &_walkToY); + break; + + case TOKEN_WALK_TO_DIR: { + int i; + parser.scanStr((char *)params, "%d", &i); + if (i < 0) i = 0; + if (i >= NUM_DIRECTIONS) i = DI_NONE; + _walkToDir = (TDirection)i; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ENTITY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ENTITY definition"); + if (spr) delete spr; + return STATUS_FAILED; + } + + if (_region && _sprite) { + _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); + } + + updatePosition(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + _state = STATE_READY; + + if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::display() { + if (_active) { + updateSounds(); + + uint32 Alpha; + if (_alphaColor != 0) Alpha = _alphaColor; + else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + + float ScaleX, ScaleY; + getScale(&ScaleX, &ScaleY); + + float Rotate; + if (_rotatable) { + if (_rotateValid) Rotate = _rotate; + else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } else Rotate = 0.0f; + + + bool Reg = _registrable; + if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; + + if (_region && (Reg || _editorAlwaysRegister)) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); + } + + displaySpriteAttachments(true); + if (_theora && (_theora->isPlaying() || _theora->isPaused())) { + _theora->display(Alpha); + } else if (_currentSprite) { + _currentSprite->display(_posX, + _posY, + (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, + ScaleX, + ScaleY, + Alpha, + Rotate, + _blendMode); + } + displaySpriteAttachments(false); + + if (_partEmitter) _partEmitter->display(_region); + + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) + _currentSprite = _sprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + break; + default: // Silence unhandled enum-warning + break; + } + + + if (_currentSprite) { + _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + if (_currentSprite->_changed) { + _posX += _currentSprite->_moveX; + _posY += _currentSprite->_moveY; + } + } + + updateBlockRegion(); + _ready = (_state == STATE_READY); + + if (_theora) { + int OffsetX, OffsetY; + _gameRef->getOffset(&OffsetX, &OffsetY); + _theora->_posX = _posX - OffsetX; + _theora->_posY = _posY - OffsetY; + + _theora->update(); + if (_theora->isFinished()) { + _theora->stop(); + delete _theora; + _theora = NULL; + } + } + + updatePartEmitter(); + updateSpriteAttachments(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX(false))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + stack->correctParams(4); + const char *filename = stack->pop()->getString(); + bool looping = stack->pop()->getBool(false); + CScValue *valAlpha = stack->pop(); + int startTime = stack->pop()->getInt(); + + delete _theora; + _theora = new CVidTheoraPlayer(_gameRef); + if (_theora && DID_SUCCEED(_theora->initialize(filename))) { + if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); + _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); + //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; + stack->pushBool(true); + } else { + script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopTheora") == 0) { + stack->correctParams(0); + if (_theora) { + _theora->stop(); + delete _theora; + _theora = NULL; + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTheoraPlaying") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseTheora") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPlaying()) { + _theora->pause(); + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeTheora") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPaused()) { + _theora->resume(); + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTheoraPaused + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTheoraPaused") == 0) { + stack->correctParams(0); + if (_theora && _theora->isPaused()) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // CreateRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateRegion") == 0) { + stack->correctParams(0); + if (!_region) { + _region = new CBRegion(_gameRef); + _gameRef->registerObject(_region); + } + if (_region) stack->pushNative(_region, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteRegion") == 0) { + stack->correctParams(0); + if (_region) { + _gameRef->unregisterObject(_region); + _region = NULL; + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdEntity::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("entity"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Item") == 0) { + if (_item) _scValue->setString(_item); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtype (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtype") == 0) { + if (_subtype == ENTITY_SOUND) + _scValue->setString("sound"); + else + _scValue->setString("normal"); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToX") == 0) { + _scValue->setInt(_walkToX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToY") == 0) { + _scValue->setInt(_walkToY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToDirection") == 0) { + _scValue->setInt((int)_walkToDir); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Region (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Region") == 0) { + if (_region) _scValue->setNative(_region, true); + else _scValue->setNULL(); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Item") == 0) { + setItem(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToX") == 0) { + _walkToX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToY") == 0) { + _walkToY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WalkToDirection + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WalkToDirection") == 0) { + int dir = value->getInt(); + if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdEntity::scToString() { + return "[entity object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + if (_subtype == ENTITY_SOUND) + buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALABLE=%s\n", _zoomable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_ignoreItems) + buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); + if (_rotatable) + buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + + if (!_autoSoundPanning) + buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + + if (!_saveState) + buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + + if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); + + buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); + buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); + if (_walkToDir != DI_NONE) + buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + + if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); + buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); + } + + + if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + + if (RGBCOLGetA(_alphaColor) != 0) + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); + + if (_scale >= 0) + buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); + + if (_relativeScale != 0) + buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + CAdTalkHolder::saveAsText(buffer, indent + 2); + + if (_region) _region->saveAsText(buffer, indent + 2); + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + CAdObject::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdEntity::getHeight() { + if (_region && !_sprite) { + return _region->_rect.bottom - _region->_rect.top; + } else { + if (_currentSprite == NULL) _currentSprite = _sprite; + return CAdObject::getHeight(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::updatePosition() { + if (_region && !_sprite) { + _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; + _posY = _region->_rect.bottom; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::persist(CBPersistMgr *persistMgr) { + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_item)); + persistMgr->transfer(TMEMBER(_region)); + //persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER_INT(_subtype)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_walkToX)); + persistMgr->transfer(TMEMBER(_walkToY)); + persistMgr->transfer(TMEMBER_INT(_walkToDir)); + + persistMgr->transfer(TMEMBER(_theora)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdEntity::setItem(const char *itemName) { + CBUtils::setString(&_item, itemName); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdEntity::setSprite(const char *filename) { + bool setCurrent = false; + if (_currentSprite == _sprite) { + _currentSprite = NULL; + setCurrent = true; + } + + delete _sprite; + _sprite = NULL; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + delete _sprite; + _sprite = NULL; + return STATUS_FAILED; + } else { + _sprite = spr; + _currentSprite = _sprite; + return STATUS_OK; + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h new file mode 100644 index 0000000000..8b67d27c1f --- /dev/null +++ b/engines/wintermute/ad/ad_entity.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADENTITY_H +#define WINTERMUTE_ADENTITY_H + +#include "engines/wintermute/ad/ad_talk_holder.h" + +namespace WinterMute { +class CVidTheoraPlayer; +class CAdEntity : public CAdTalkHolder { +public: + CVidTheoraPlayer *_theora; + bool setSprite(const char *filename); + int _walkToX; + int _walkToY; + TDirection _walkToDir; + void setItem(const char *itemName); + char *_item; + DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) + void updatePosition(); + virtual int getHeight(); + CBRegion *_region; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool update(); + virtual bool display(); + CAdEntity(CBGame *inGame); + virtual ~CAdEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + TEntityType _subtype; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp new file mode 100644 index 0000000000..69cda25f29 --- /dev/null +++ b/engines/wintermute/ad/ad_game.cpp @@ -0,0 +1,2061 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_actor.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/ad/ad_inventory.h" +#include "engines/wintermute/ad/ad_inventory_box.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/ad/ad_response.h" +#include "engines/wintermute/ad/ad_response_box.h" +#include "engines/wintermute/ad/ad_response_context.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/ad/ad_scene_state.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/ui/ui_entity.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/video/video_player.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdGame, true) + +////////////////////////////////////////////////////////////////////////// +CAdGame::CAdGame(): CBGame() { + _responseBox = NULL; + _inventoryBox = NULL; + + _scene = new CAdScene(_gameRef); + _scene->setName(""); + registerObject(_scene); + + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _scheduledFadeIn = false; + + + _stateEx = GAME_NORMAL; + + _selectedItem = NULL; + + + _texItemLifeTime = 10000; + _texWalkLifeTime = 10000; + _texStandLifeTime = 10000; + _texTalkLifeTime = 10000; + + _talkSkipButton = TALK_SKIP_LEFT; + + _sceneViewport = NULL; + + _initialScene = true; + _debugStartupScene = NULL; + _startupScene = NULL; + + _invObject = new CAdObject(this); + _inventoryOwner = _invObject; + + _tempDisableSaveState = false; + _itemsFile = NULL; + + _smartItemCursor = false; + + addSpeechDir("speech"); +} + + +////////////////////////////////////////////////////////////////////////// +CAdGame::~CAdGame() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::cleanup() { + int i; + + for (i = 0; i < _objects.getSize(); i++) { + unregisterObject(_objects[i]); + _objects[i] = NULL; + } + _objects.removeAll(); + + + for (i = 0; i < _dlgPendingBranches.getSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.removeAll(); + + for (i = 0; i < _speechDirs.getSize(); i++) { + delete [] _speechDirs[i]; + } + _speechDirs.removeAll(); + + + unregisterObject(_scene); + _scene = NULL; + + // remove items + for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); + _items.removeAll(); + + + // clear remaining inventories + delete _invObject; + _invObject = NULL; + + for (i = 0; i < _inventories.getSize(); i++) { + delete _inventories[i]; + } + _inventories.removeAll(); + + + if (_responseBox) { + _gameRef->unregisterObject(_responseBox); + _responseBox = NULL; + } + + if (_inventoryBox) { + _gameRef->unregisterObject(_inventoryBox); + _inventoryBox = NULL; + } + + delete[] _prevSceneName; + delete[] _prevSceneFilename; + delete[] _scheduledScene; + delete[] _debugStartupScene; + delete[] _itemsFile; + _prevSceneName = NULL; + _prevSceneFilename = NULL; + _scheduledScene = NULL; + _debugStartupScene = NULL; + _startupScene = NULL; + _itemsFile = NULL; + + delete _sceneViewport; + _sceneViewport = NULL; + + for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); + + for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + + for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); + + return CBGame::cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::initLoop() { + if (_scheduledScene && _transMgr->isReady()) { + changeScene(_scheduledScene, _scheduledFadeIn); + delete[] _scheduledScene; + _scheduledScene = NULL; + + _gameRef->_activeObject = NULL; + } + + + bool res; + res = CBGame::initLoop(); + if (DID_FAIL(res)) return res; + + if (_scene) res = _scene->initLoop(); + + _sentences.removeAll(); + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addObject(CAdObject *object) { + _objects.add(object); + return registerObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::removeObject(CAdObject *object) { + // in case the user called Scene.CreateXXX() and Game.DeleteXXX() + if (_scene) { + bool Res = _scene->removeObject(object); + if (DID_SUCCEED(Res)) return Res; + } + + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] == object) { + _objects.removeAt(i); + break; + } + } + return unregisterObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::changeScene(const char *filename, bool fadeIn) { + if (_scene == NULL) { + _scene = new CAdScene(_gameRef); + registerObject(_scene); + } else { + _scene->applyEvent("SceneShutdown", true); + + setPrevSceneName(_scene->_name); + setPrevSceneFilename(_scene->_filename); + + if (!_tempDisableSaveState) _scene->saveState(); + _tempDisableSaveState = false; + } + + if (_scene) { + // reset objects + for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); + + // reset scene properties + _scene->_sFXVolume = 100; + if (_scene->_scProp) _scene->_scProp->cleanup(); + + bool ret; + if (_initialScene && _debugDebugMode && _debugStartupScene) { + _initialScene = false; + ret = _scene->loadFile(_debugStartupScene); + } else ret = _scene->loadFile(filename); + + if (DID_SUCCEED(ret)) { + // invalidate references to the original scene + for (int i = 0; i < _objects.getSize(); i++) { + _objects[i]->invalidateCurrRegions(); + _objects[i]->_stickRegion = NULL; + } + + _scene->loadState(); + } + if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); + return ret; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::addSentence(CAdSentence *sentence) { + _sentences.add(sentence); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displaySentences(bool frozen) { + for (int i = 0; i < _sentences.getSize(); i++) { + if (frozen && _sentences[i]->_freezable) continue; + else _sentences[i]->display(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::finishSentences() { + for (int i = 0; i < _sentences.getSize(); i++) { + if (_sentences[i]->CanSkip()) { + _sentences[i]->_duration = 0; + if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // ChangeScene + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "ChangeScene") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + CScValue *valFadeOut = stack->pop(); + CScValue *valFadeIn = stack->pop(); + + bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); + bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); + + scheduleChangeScene(filename, transIn); + if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); + stack->pushNULL(); + + + //bool ret = ChangeScene(stack->pop()->getString()); + //if(DID_FAIL(ret)) stack->pushBool(false); + //else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadActor") == 0) { + stack->correctParams(1); + CAdActor *act = new CAdActor(_gameRef); + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { + addObject(act); + stack->pushNative(act, true); + } else { + delete act; + act = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadEntity") == 0) { + stack->correctParams(1); + CAdEntity *ent = new CAdEntity(_gameRef); + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { + addObject(ent); + stack->pushNative(ent, true); + } else { + delete ent; + ent = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CAdObject *obj = (CAdObject *)val->getNative(); + removeObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdEntity *ent = new CAdEntity(_gameRef); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = new CAdItem(_gameRef); + addItem(item); + if (!val->isNULL()) item->setName(val->getString()); + stack->pushNative(item, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = NULL; + if (val->isNative()) item = (CAdItem *)val->getNative(); + else item = getItemByName(val->getString()); + + if (item) { + deleteItem(item); + } + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QueryItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QueryItem") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdItem *item = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _items.getSize()) item = _items[index]; + } else { + item = getItemByName(val->getString()); + } + + if (item) stack->pushNative(item, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // AddResponse/AddResponseOnce/AddResponseOnceGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) { + stack->correctParams(6); + int id = stack->pop()->getInt(); + const char *text = stack->pop()->getString(); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + CScValue *val4 = stack->pop(); + + if (_responseBox) { + CAdResponse *res = new CAdResponse(_gameRef); + if (res) { + res->_iD = id; + res->setText(text); + _stringTable->expand(&res->_text); + if (!val1->isNULL()) res->setIcon(val1->getString()); + if (!val2->isNULL()) res->setIconHover(val2->getString()); + if (!val3->isNULL()) res->setIconPressed(val3->getString()); + if (!val4->isNULL()) res->setFont(val4->getString()); + + if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; + else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; + + _responseBox->_responses.add(res); + } + } else { + script->runtimeError("Game.AddResponse: response box is not defined"); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResetResponse") == 0) { + stack->correctParams(1); + int ID = stack->pop()->getInt(-1); + resetResponse(ID); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearResponses") == 0) { + stack->correctParams(0); + _responseBox->clearResponses(); + _responseBox->clearButtons(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponse + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetResponse") == 0) { + stack->correctParams(1); + bool autoSelectLast = stack->pop()->getBool(); + + if (_responseBox) { + _responseBox->weedResponses(); + + if (_responseBox->_responses.getSize() == 0) { + stack->pushNULL(); + return STATUS_OK; + } + + + if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { + stack->pushInt(_responseBox->_responses[0]->_iD); + _responseBox->handleResponse(_responseBox->_responses[0]); + _responseBox->clearResponses(); + return STATUS_OK; + } + + _responseBox->createButtons(); + _responseBox->_waitingScript = script; + script->waitForExclusive(_responseBox); + _state = GAME_SEMI_FROZEN; + _stateEx = GAME_WAITING_RESPONSE; + } else { + script->runtimeError("Game.GetResponse: response box is not defined"); + stack->pushNULL(); + } + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // GetNumResponses + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNumResponses") == 0) { + stack->correctParams(0); + if (_responseBox) { + _responseBox->weedResponses(); + stack->pushInt(_responseBox->_responses.getSize()); + } else { + script->runtimeError("Game.GetNumResponses: response box is not defined"); + stack->pushNULL(); + } + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // StartDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartDlgBranch") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + Common::String branchName; + if (val->isNULL()) { + branchName.format("line%d", script->_currentLine); + } else branchName = val->getString(); + + startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EndDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EndDlgBranch") == 0) { + stack->correctParams(1); + + const char *branchName = NULL; + CScValue *val = stack->pop(); + if (!val->isNULL()) branchName = val->getString(); + endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCurrentDlgBranch + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCurrentDlgBranch") == 0) { + stack->correctParams(0); + + if (_dlgPendingBranches.getSize() > 0) { + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TakeItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DropItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasItem") == 0) { + return _invObject->scCallMethod(script, stack, thisStack, name); + } + + ////////////////////////////////////////////////////////////////////////// + // IsItemTaken + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsItemTaken") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + for (int i = 0; i < _inventories.getSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { + if (val->getNative() == Inv->_takenItems[j]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { + stack->pushBool(true); + return STATUS_OK; + } + } + } + } else script->runtimeError("Game.IsItemTaken: item name expected"); + + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInventoryWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInventoryWindow") == 0) { + stack->correctParams(0); + if (_inventoryBox && _inventoryBox->_window) + stack->pushNative(_inventoryBox->_window, true); + else + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetResponsesWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { + stack->correctParams(0); + if (_responseBox && _responseBox->_window) + stack->pushNative(_responseBox->_window, true); + else + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadResponseBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadResponseBox") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _gameRef->unregisterObject(_responseBox); + _responseBox = new CAdResponseBox(_gameRef); + if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { + registerObject(_responseBox); + stack->pushBool(true); + } else { + delete _responseBox; + _responseBox = NULL; + stack->pushBool(false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadInventoryBox + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadInventoryBox") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _gameRef->unregisterObject(_inventoryBox); + _inventoryBox = new CAdInventoryBox(_gameRef); + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { + registerObject(_inventoryBox); + stack->pushBool(true); + } else { + delete _inventoryBox; + _inventoryBox = NULL; + stack->pushBool(false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadItems") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool merge = stack->pop()->getBool(false); + + bool ret = loadItemsFile(filename, merge); + stack->pushBool(DID_SUCCEED(ret)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSpeechDir") == 0) { + stack->correctParams(1); + const char *dir = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSpeechDir(dir))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveSpeechDir + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSpeechDir") == 0) { + stack->correctParams(1); + const char *dir = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSpeechDir(dir))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSceneViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSceneViewport") == 0) { + stack->correctParams(4); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); + + if (width <= 0) width = _renderer->_width; + if (height <= 0) height = _renderer->_height; + + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBGame::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scene") == 0) { + if (_scene) _scValue->setNative(_scene, true); + else _scValue->setNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelectedItem") == 0) { + //if(_selectedItem) _scValue->setString(_selectedItem->_name); + if (_selectedItem) _scValue->setNative(_selectedItem, true); + else _scValue->setNULL(); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumItems") == 0) { + return _invObject->scGetProperty(name); + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SmartItemCursor") == 0) { + _scValue->setBool(_smartItemCursor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryVisible") == 0) { + _scValue->setBool(_inventoryBox && _inventoryBox->_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); + else _scValue->setInt(0); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ResponsesVisible (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResponsesVisible") == 0) { + _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevScene / PreviousScene (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { + if (!_prevSceneName) _scValue->setString(""); + else _scValue->setString(_prevSceneName); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PrevSceneFilename / PreviousSceneFilename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { + if (!_prevSceneFilename) _scValue->setString(""); + else _scValue->setString(_prevSceneFilename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponse (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LastResponse") == 0) { + if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseText); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LastResponseOrig (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LastResponseOrig") == 0) { + if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); + else _scValue->setString(_responseBox->_lastResponseTextOrig); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryObject") == 0) { + if (_inventoryOwner == _invObject) _scValue->setNative(this, true); + else _scValue->setNative(_inventoryOwner, true); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TotalNumItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TotalNumItems") == 0) { + _scValue->setInt(_items.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkSkipButton") == 0) { + _scValue->setInt(_talkSkipButton); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ChangingScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ChangingScene") == 0) { + _scValue->setBool(_scheduledScene != NULL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartupScene") == 0) { + if (!_startupScene) _scValue->setNULL(); + else _scValue->setString(_startupScene); + return _scValue; + } + + else return CBGame::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // SelectedItem + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelectedItem") == 0) { + if (value->isNULL()) _selectedItem = NULL; + else { + if (value->isNative()) { + _selectedItem = NULL; + for (int i = 0; i < _items.getSize(); i++) { + if (_items[i] == value->getNative()) { + _selectedItem = (CAdItem *)value->getNative(); + break; + } + } + } else { + // try to get by name + _selectedItem = getItemByName(value->getString()); + } + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SmartItemCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SmartItemCursor") == 0) { + _smartItemCursor = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryVisible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryVisible") == 0) { + if (_inventoryBox) _inventoryBox->_visible = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryObject") == 0) { + if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + + if (value->isNULL()) _inventoryOwner = _invObject; + else { + CBObject *Obj = (CBObject *)value->getNative(); + if (Obj == this) _inventoryOwner = _invObject; + else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + } + + if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InventoryScrollOffset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InventoryScrollOffset") == 0) { + if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TalkSkipButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TalkSkipButton") == 0) { + int Val = value->getInt(); + if (Val < 0) Val = 0; + if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; + _talkSkipButton = (TTalkSkipButton)Val; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StartupScene + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StartupScene") == 0) { + if (value == NULL) { + delete[] _startupScene; + _startupScene = NULL; + } else CBUtils::setString(&_startupScene, value->getString()); + + return STATUS_OK; + } + + else return CBGame::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *this_obj; + + ////////////////////////////////////////////////////////////////////////// + // Actor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Actor") == 0) { + stack->correctParams(0); + this_obj = thisStack->getTop(); + + this_obj->setNative(new CAdActor(_gameRef)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Entity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Entity") == 0) { + stack->correctParams(0); + this_obj = thisStack->getTop(); + + this_obj->setNative(new CAdEntity(_gameRef)); + stack->pushNULL(); + } + + + ////////////////////////////////////////////////////////////////////////// + // call parent + else return CBGame::ExternalCall(script, stack, thisStack, name); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { + if (_selectedItem->_cursorCombined) { + CBSprite *origLastCursor = _lastCursor; + CBGame::showCursor(); + _lastCursor = origLastCursor; + } + if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) + return drawCursor(_selectedItem->_cursorHover); + else + return drawCursor(_selectedItem->_cursorNormal); + } else return drawCursor(_selectedItem->_cursorNormal); + } else return CBGame::showCursor(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadFile(const char *filename) { + byte *buffer = _fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(AD_GAME) +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(ITEMS) +TOKEN_DEF(ITEM) +TOKEN_DEF(TALK_SKIP_BUTTON) +TOKEN_DEF(SCENE_VIEWPORT) +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(STARTUP_SCENE) +TOKEN_DEF(DEBUG_STARTUP_SCENE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(AD_GAME) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(ITEMS) + TOKEN_TABLE(TALK_SKIP_BUTTON) + TOKEN_TABLE(SCENE_VIEWPORT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(STARTUP_SCENE) + TOKEN_TABLE(DEBUG_STARTUP_SCENE) + TOKEN_TABLE_END + + byte *params; + byte *params2; + int cmd = 1; + CBParser parser(_gameRef); + + bool itemFound = false, itemsFound = false; + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AD_GAME: + while (cmd > 0 && (cmd = parser.getCommand((char **)¶ms, commands, (char **)¶ms2)) > 0) { + switch (cmd) { + case TOKEN_RESPONSE_BOX: + delete _responseBox; + _responseBox = new CAdResponseBox(_gameRef); + if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) + registerObject(_responseBox); + else { + delete _responseBox; + _responseBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_INVENTORY_BOX: + delete _inventoryBox; + _inventoryBox = new CAdInventoryBox(_gameRef); + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) + registerObject(_inventoryBox); + else { + delete _inventoryBox; + _inventoryBox = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ITEMS: + itemsFound = true; + CBUtils::setString(&_itemsFile, (char *)params2); + if (DID_FAIL(loadItemsFile(_itemsFile))) { + delete[] _itemsFile; + _itemsFile = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_TALK_SKIP_BUTTON: + if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; + else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; + else _talkSkipButton = TALK_SKIP_LEFT; + break; + + case TOKEN_SCENE_VIEWPORT: { + Rect32 rc; + parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params2, false); + break; + + case TOKEN_STARTUP_SCENE: + CBUtils::setString(&_startupScene, (char *)params2); + break; + + case TOKEN_DEBUG_STARTUP_SCENE: + CBUtils::setString(&_debugStartupScene, (char *)params2); + break; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + if (itemFound && !itemsFound) { + _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file."); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + CBGame::persist(persistMgr); + + _dlgPendingBranches.persist(persistMgr); + + _inventories.persist(persistMgr); + persistMgr->transfer(TMEMBER(_inventoryBox)); + + _objects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_prevSceneName)); + persistMgr->transfer(TMEMBER(_prevSceneFilename)); + + persistMgr->transfer(TMEMBER(_responseBox)); + _responsesBranch.persist(persistMgr); + _responsesGame.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scene)); + _sceneStates.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scheduledFadeIn)); + persistMgr->transfer(TMEMBER(_scheduledScene)); + persistMgr->transfer(TMEMBER(_selectedItem)); + persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); + + _sentences.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_sceneViewport)); + persistMgr->transfer(TMEMBER_INT(_stateEx)); + persistMgr->transfer(TMEMBER(_initialScene)); + persistMgr->transfer(TMEMBER(_debugStartupScene)); + + persistMgr->transfer(TMEMBER(_invObject)); + persistMgr->transfer(TMEMBER(_inventoryOwner)); + persistMgr->transfer(TMEMBER(_tempDisableSaveState)); + _items.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_itemsFile)); + + _speechDirs.persist(persistMgr); + persistMgr->transfer(TMEMBER(_smartItemCursor)); + + if (!persistMgr->_saving) _initialScene = false; + + persistMgr->transfer(TMEMBER(_startupScene)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadGame(const char *filename) { + bool ret = CBGame::loadGame(filename); + if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::initAfterLoad() { + CBGame::initAfterLoad(); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdGame::afterLoadScene(void *scene, void *data) { + ((CAdScene *)scene)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::setPrevSceneName(const char *name) { + delete[] _prevSceneName; + _prevSceneName = NULL; + if (name) { + _prevSceneName = new char[strlen(name) + 1]; + if (_prevSceneName) strcpy(_prevSceneName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdGame::setPrevSceneFilename(const char *name) { + delete[] _prevSceneFilename; + _prevSceneFilename = NULL; + if (name) { + _prevSceneFilename = new char[strlen(name) + 1]; + if (_prevSceneFilename) strcpy(_prevSceneFilename, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { + delete[] _scheduledScene; + _scheduledScene = NULL; + + if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); + else { + _scheduledScene = new char [strlen(filename) + 1]; + strcpy(_scheduledScene, filename); + + _scheduledFadeIn = fadeIn; + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + CBGame::getVersion(verMajor, verMinor, NULL, NULL); + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadItemsFile(const char *filename, bool merge) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + //_filename = new char [strlen(filename)+1]; + //strcpy(_filename, filename); + + if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (!merge) { + while (_items.getSize() > 0) deleteItem(_items[0]); + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_ITEM: { + CAdItem *item = new CAdItem(_gameRef); + if (item && !DID_FAIL(item->loadBuffer(params, false))) { + // delete item with the same name, if exists + if (merge) { + CAdItem *PrevItem = getItemByName(item->_name); + if (PrevItem) deleteItem(PrevItem); + } + addItem(item); + } else { + delete item; + item = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ITEMS definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ITEMS definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { + char *filenameCor = new char[strlen(filename) + 1]; + strcpy(filenameCor, filename); + for (uint32 i = 0; i < strlen(filenameCor); i++) { + if (filenameCor[i] == '/') filenameCor[i] = '\\'; + } + + for (int i = 0; i < _sceneStates.getSize(); i++) { + if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { + delete [] filenameCor; + return _sceneStates[i]; + } + } + + if (saving) { + CAdSceneState *ret = new CAdSceneState(_gameRef); + ret->setFilename(filenameCor); + + _sceneStates.add(ret); + + delete [] filenameCor; + return ret; + } else { + delete [] filenameCor; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE_END + + int cmd = PARSERR_GENERIC; + CBParser parser(_gameRef); + + cmd = parser.getCommand(buffer, commands, params); + switch (cmd) { + case TOKEN_ENTITY_CONTAINER: { + CUIEntity *ent = new CUIEntity(_gameRef); + if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { + delete ent; + ent = NULL; + cmd = PARSERR_GENERIC; + } else { + ent->_parent = win; + win->_widgets.add(ent); + } + } + break; + } + + if (cmd == PARSERR_TOKENNOTFOUND || cmd == PARSERR_GENERIC) { + return STATUS_FAILED; + } + + return STATUS_OK; + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + if (strcmp(name, "CreateEntityContainer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIEntity *ent = new CUIEntity(_gameRef); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + + ent->_parent = win; + win->_widgets.add(ent); + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); + _dlgPendingBranches.add(name); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { + char *name = NULL; + bool deleteName = false; + if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { + name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; + } else { + if (branchName != NULL) { + name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; + if (name) { + sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); + deleteName = true; + } + } + } + + if (name == NULL) return STATUS_OK; + + + int startIndex = -1; + for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { + if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { + startIndex = i; + break; + } + } + if (startIndex >= 0) { + for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { + //ClearBranchResponses(_dlgPendingBranches[i]); + delete [] _dlgPendingBranches[i]; + _dlgPendingBranches[i] = NULL; + } + _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); + } + + // dialogue is over, forget selected responses + if (_dlgPendingBranches.getSize() == 0) { + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + } + + if (deleteName) delete [] name; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::clearBranchResponses(char *name) { + for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addBranchResponse(int ID) { + if (branchResponseUsed(ID)) return STATUS_OK; + CAdResponseContext *r = new CAdResponseContext(_gameRef); + r->_iD = ID; + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesBranch.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::branchResponseUsed(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addGameResponse(int ID) { + if (gameResponseUsed(ID)) return STATUS_OK; + CAdResponseContext *r = new CAdResponseContext(_gameRef); + r->_iD = ID; + r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + _responsesGame.add(r); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::gameResponseUsed(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + for (int i = 0; i < _responsesGame.getSize(); i++) { + CAdResponseContext *RespContext = _responsesGame[i]; + if (RespContext->_iD == ID) { + if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::resetResponse(int ID) { + char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + + int i; + + for (i = 0; i < _responsesGame.getSize(); i++) { + if (_responsesGame[i]->_iD == ID) { + if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { + delete _responsesGame[i]; + _responsesGame.removeAt(i); + break; + } + } + } + + for (i = 0; i < _responsesBranch.getSize(); i++) { + if (_responsesBranch[i]->_iD == ID) { + if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { + delete _responsesBranch[i]; + _responsesBranch.removeAt(i); + break; + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displayContent(bool doUpdate, bool displayAll) { + // init + if (doUpdate) initLoop(); + + // fill black + _renderer->fill(0, 0, 0); + if (!_editorMode) _renderer->setScreenViewport(); + + // playing exclusive video? + if (_videoPlayer->isPlaying()) { + if (doUpdate) _videoPlayer->update(); + _videoPlayer->display(); + } else if (_theoraPlayer) { + if (_theoraPlayer->isPlaying()) { + if (doUpdate) _theoraPlayer->update(); + _theoraPlayer->display(); + } + if (_theoraPlayer->isFinished()) { + delete _theoraPlayer; + _theoraPlayer = NULL; + } + } else { + + // process scripts + if (doUpdate) _scEngine->tick(); + + Point32 p; + getMousePos(&p); + + _scene->update(); + _scene->display(); + + + // display in-game windows + displayWindows(true); + if (_inventoryBox) _inventoryBox->display(); + if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); + if (_indicatorDisplay) displayIndicator(); + + + if (doUpdate || displayAll) { + // display normal windows + displayWindows(false); + + setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y)); + + // textual info + displaySentences(_state == GAME_FROZEN); + + showCursor(); + + if (_fader) _fader->display(); + _transMgr->update(); + } + + } + if (_loadingIcon) { + _loadingIcon->display(_loadingIconX, _loadingIconY); + if (!_loadingIconPersistent) { + delete _loadingIcon; + _loadingIcon = NULL; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::registerInventory(CAdInventory *inv) { + for (int i = 0; i < _inventories.getSize(); i++) { + if (_inventories[i] == inv) return STATUS_OK; + } + registerObject(inv); + _inventories.add(inv); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::unregisterInventory(CAdInventory *inv) { + for (int i = 0; i < _inventories.getSize(); i++) { + if (_inventories[i] == inv) { + unregisterObject(_inventories[i]); + _inventories.removeAt(i); + return STATUS_OK; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::isItemTaken(char *itemName) { + for (int i = 0; i < _inventories.getSize(); i++) { + CAdInventory *Inv = _inventories[i]; + + for (int j = 0; j < Inv->_takenItems.getSize(); j++) { + if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +CAdItem *CAdGame::getItemByName(const char *name) { + for (int i = 0; i < _items.getSize(); i++) { + if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addItem(CAdItem *item) { + _items.add(item); + return _gameRef->registerObject(item); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::resetContent() { + // clear pending dialogs + for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { + delete [] _dlgPendingBranches[i]; + } + _dlgPendingBranches.removeAll(); + + + // clear inventories + for (int i = 0; i < _inventories.getSize(); i++) { + _inventories[i]->_takenItems.removeAll(); + } + + // clear scene states + for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + _sceneStates.removeAll(); + + // clear once responses + for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + _responsesBranch.removeAll(); + + // clear once game responses + for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + _responsesGame.removeAll(); + + // reload inventory items + if (_itemsFile) loadItemsFile(_itemsFile); + + _tempDisableSaveState = true; + + return CBGame::resetContent(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::deleteItem(CAdItem *item) { + if (!item) return STATUS_FAILED; + + if (_selectedItem == item) _selectedItem = NULL; + _scene->handleItemAssociations(item->_name, false); + + // remove from all inventories + for (int i = 0; i < _inventories.getSize(); i++) { + _inventories[i]->removeItem(item); + } + + // remove object + for (int i = 0; i < _items.getSize(); i++) { + if (_items[i] == item) { + unregisterObject(_items[i]); + _items.removeAt(i); + break; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::addSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; + + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); + + for (int i = 0; i < _speechDirs.getSize(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete [] temp; + return STATUS_OK; + } + } + _speechDirs.add(temp); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::removeSpeechDir(const char *dir) { + if (!dir || dir[0] == '\0') return STATUS_FAILED; + + char *temp = new char[strlen(dir) + 2]; + strcpy(temp, dir); + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + strcat(temp, "\\"); + + bool Found = false; + for (int i = 0; i < _speechDirs.getSize(); i++) { + if (scumm_stricmp(_speechDirs[i], temp) == 0) { + delete [] _speechDirs[i]; + _speechDirs.removeAt(i); + Found = true; + break; + } + } + delete [] temp; + + if (Found) return STATUS_OK; + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdGame::findSpeechFile(char *stringID) { + char *ret = new char[MAX_PATH_LENGTH]; + + for (int i = 0; i < _speechDirs.getSize(); i++) { + sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); + Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile + if (file) { + _fileManager->closeFile(file); + return ret; + } + + sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); + file = _fileManager->openFile(ret); + if (file) { + _fileManager->closeFile(file); + return ret; + } + } + delete [] ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::validMouse() { + Point32 pos; + CBPlatform::getCursorPos(&pos); + + return _renderer->pointInViewport(&pos); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftDown() { + if (!validMouse()) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { + finishSentences(); + } + return STATUS_OK; + } + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseLeftDblClick() { + if (!validMouse()) return STATUS_OK; + + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseRightDown() { + if (!validMouse()) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { + finishSentences(); + } + return STATUS_OK; + } + + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { + _scene->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::displayDebugInfo() { + char str[100]; + if (_gameRef->_debugDebugMode) { + sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); + _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); + + sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); + _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + } + return CBGame::displayDebugInfo(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdGame::onScriptShutdown(CScScript *script) { + if (_responseBox && _responseBox->_waitingScript == script) + _responseBox->_waitingScript = NULL; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h new file mode 100644 index 0000000000..09b3e09df0 --- /dev/null +++ b/engines/wintermute/ad/ad_game.h @@ -0,0 +1,161 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_ADGAME_H +#define WINTERMUTE_ADGAME_H + +#include "engines/wintermute/ad/ad_types.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { +class CAdItem; +class CAdInventory; +class CAdSceneState; +class CAdScene; +class CAdItem; +class CAdObject; +class CAdSentence; +class CAdInventoryBox; +class CAdResponseContext; +class CAdResponseBox; +class CAdGame : public CBGame { +public: + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + + virtual bool displayDebugInfo(); + + + virtual bool initAfterLoad(); + static void afterLoadScene(void *scene, void *data); + + bool _smartItemCursor; + + CBArray _speechDirs; + bool addSpeechDir(const char *dir); + bool removeSpeechDir(const char *dir); + char *findSpeechFile(char *StringID); + + bool deleteItem(CAdItem *Item); + char *_itemsFile; + bool _tempDisableSaveState; + virtual bool resetContent(); + bool addItem(CAdItem *item); + CAdItem *getItemByName(const char *name); + CBArray _items; + CAdObject *_inventoryOwner; + bool isItemTaken(char *itemName); + bool registerInventory(CAdInventory *inv); + bool unregisterInventory(CAdInventory *inv); + + CAdObject *_invObject; + CBArray _inventories; + virtual bool displayContent(bool update = true, bool displayAll = false); + char *_debugStartupScene; + char *_startupScene; + bool _initialScene; + bool gameResponseUsed(int ID); + bool addGameResponse(int ID); + bool resetResponse(int ID); + + bool branchResponseUsed(int ID); + bool addBranchResponse(int ID); + bool clearBranchResponses(char *name); + bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + + CAdSceneState *getSceneState(const char *filename, bool saving); + CBViewport *_sceneViewport; + int _texItemLifeTime; + int _texWalkLifeTime; + int _texStandLifeTime; + int _texTalkLifeTime; + + TTalkSkipButton _talkSkipButton; + + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + bool scheduleChangeScene(const char *filename, bool fadeIn); + char *_scheduledScene; + bool _scheduledFadeIn; + void setPrevSceneName(const char *name); + void setPrevSceneFilename(const char *name); + char *_prevSceneName; + char *_prevSceneFilename; + virtual bool loadGame(const char *filename); + CAdItem *_selectedItem; + bool cleanup(); + DECLARE_PERSISTENT(CAdGame, CBGame) + + void finishSentences(); + bool showCursor(); + TGameStateEx _stateEx; + CAdResponseBox *_responseBox; + CAdInventoryBox *_inventoryBox; + bool displaySentences(bool frozen); + void addSentence(CAdSentence *sentence); + bool changeScene(const char *filename, bool fadeIn); + bool removeObject(CAdObject *object); + bool addObject(CAdObject *object); + CAdScene *_scene; + bool initLoop(); + CAdGame(); + virtual ~CAdGame(); + CBArray _objects; + CBArray _sentences; + + CBArray _sceneStates; + CBArray _dlgPendingBranches; + + CBArray _responsesBranch; + CBArray _responsesGame; + + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + + bool loadItemsFile(const char *filename, bool merge = false); + bool loadItemsBuffer(byte *buffer, bool merge = false); + + + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + bool validMouse(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp new file mode 100644 index 0000000000..cfbc9e5029 --- /dev/null +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -0,0 +1,119 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_inventory.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventory, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { + _scrollOffset = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventory::~CAdInventory() { + _takenItems.removeAll(); // ref only +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::insertItem(const char *name, const char *insertAfter) { + if (name == NULL) return STATUS_FAILED; + + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); + if (item == NULL) return STATUS_FAILED; + + int insertIndex = -1; + for (int i = 0; i < _takenItems.getSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + _takenItems.removeAt(i); + i--; + continue; + } + if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; + } + + + if (insertIndex == -1) _takenItems.add(item); + else _takenItems.insertAt(insertIndex, item); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::removeItem(const char *name) { + if (name == NULL) return STATUS_FAILED; + + for (int i = 0; i < _takenItems.getSize(); i++) { + if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + _takenItems.removeAt(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::removeItem(CAdItem *item) { + if (item == NULL) return STATUS_FAILED; + + for (int i = 0; i < _takenItems.getSize(); i++) { + if (_takenItems[i] == item) { + if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + _takenItems.removeAt(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdInventory::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + _takenItems.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_inventory.h b/engines/wintermute/ad/ad_inventory.h new file mode 100644 index 0000000000..84d9308d5d --- /dev/null +++ b/engines/wintermute/ad/ad_inventory.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORY_H +#define WINTERMUTE_ADINVENTORY_H + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CAdItem; + +class CAdInventory : public CBObject { +public: + DECLARE_PERSISTENT(CAdInventory, CBObject) + bool removeItem(const char *name); + bool removeItem(CAdItem *Item); + bool insertItem(const char *name, const char *insertAfter = NULL); + CAdInventory(CBGame *inGame); + virtual ~CAdInventory(); + CBArray _takenItems; + int _scrollOffset; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp new file mode 100644 index 0000000000..abe8676376 --- /dev/null +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -0,0 +1,372 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_inventory_box.h" +#include "engines/wintermute/ad/ad_inventory.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/ui/ui_button.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/rect.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdInventoryBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { + _itemsArea.setEmpty(); + _scrollOffset = 0; + _spacing = 0; + _itemWidth = _itemHeight = 50; + _scrollBy = 1; + + _window = NULL; + _closeButton = NULL; + + _hideSelected = false; + + _visible = false; + _exclusive = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdInventoryBox::~CAdInventoryBox() { + _gameRef->unregisterObject(_window); + _window = NULL; + + delete _closeButton; + _closeButton = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) { + _visible = false; + } else if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset -= _scrollBy; + _scrollOffset = MAX(_scrollOffset, 0); + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset += _scrollBy; + } else return CBObject::listen(param1, param2); + break; + default: + error("CAdInventoryBox::Listen - Unhandled enum"); + break; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::display() { + CAdGame *adGame = (CAdGame *)_gameRef; + + if (!_visible) return STATUS_OK; + + int itemsX, itemsY; + itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); + itemsY = (int)floor((float)((_itemsArea.bottom - _itemsArea.top + _spacing) / (_itemHeight + _spacing))); + + if (_window) { + _window->enableWidget("prev", _scrollOffset > 0); + _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); + } + + + if (_closeButton) { + _closeButton->_posX = _closeButton->_posY = 0; + _closeButton->_width = _gameRef->_renderer->_width; + _closeButton->_height = _gameRef->_renderer->_height; + + _closeButton->display(); + } + + + // display window + Rect32 rect = _itemsArea; + if (_window) { + rect.offsetRect(_window->_posX, _window->_posY); + _window->display(); + } + + // display items + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; + int yyy = rect.top; + for (int j = 0; j < itemsY; j++) { + int xxx = rect.left; + for (int i = 0; i < itemsX; i++) { + int itemIndex = _scrollOffset + j * itemsX + i; + if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { + CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; + if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { + item->update(); + item->display(xxx, yyy); + } + } + + xxx += (_itemWidth + _spacing); + } + yyy += (_itemHeight + _spacing); + } + if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(INVENTORY_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(WINDOW) +TOKEN_DEF(EXCLUSIVE) +TOKEN_DEF(ALWAYS_VISIBLE) +TOKEN_DEF(AREA) +TOKEN_DEF(SPACING) +TOKEN_DEF(ITEM_WIDTH) +TOKEN_DEF(ITEM_HEIGHT) +TOKEN_DEF(SCROLL_BY) +TOKEN_DEF(NAME) +TOKEN_DEF(CAPTION) +TOKEN_DEF(HIDE_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(INVENTORY_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(EXCLUSIVE) + TOKEN_TABLE(ALWAYS_VISIBLE) + TOKEN_TABLE(AREA) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(ITEM_WIDTH) + TOKEN_TABLE(ITEM_HEIGHT) + TOKEN_TABLE(SCROLL_BY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(HIDE_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + bool always_visible = false; + + _exclusive = false; + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) { + _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(_gameRef); + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else _gameRef->registerObject(_window); + break; + + case TOKEN_AREA: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom); + break; + + case TOKEN_EXCLUSIVE: + parser.scanStr((char *)params, "%b", &_exclusive); + break; + + case TOKEN_HIDE_SELECTED: + parser.scanStr((char *)params, "%b", &_hideSelected); + break; + + case TOKEN_ALWAYS_VISIBLE: + parser.scanStr((char *)params, "%b", &always_visible); + break; + + case TOKEN_SPACING: + parser.scanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_ITEM_WIDTH: + parser.scanStr((char *)params, "%d", &_itemWidth); + break; + + case TOKEN_ITEM_HEIGHT: + parser.scanStr((char *)params, "%d", &_itemHeight); + break; + + case TOKEN_SCROLL_BY: + parser.scanStr((char *)params, "%d", &_scrollBy); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading INVENTORY_BOX definition"); + return STATUS_FAILED; + } + + if (_exclusive) { + delete _closeButton; + _closeButton = new CUIButton(_gameRef); + if (_closeButton) { + _closeButton->setName("close"); + _closeButton->setListener(this, _closeButton, 0); + _closeButton->_parent = _window; + } + } + + _visible = always_visible; + + if (_window) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "INVENTORY_BOX\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); + + buffer->putTextIndent(indent + 2, "EXCLUSIVE=%s\n", _exclusive ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "HIDE_SELECTED=%s\n", _hideSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ALWAYS_VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); + buffer->putTextIndent(indent + 2, "ITEM_WIDTH=%d\n", _itemWidth); + buffer->putTextIndent(indent + 2, "ITEM_HEIGHT=%d\n", _itemHeight); + buffer->putTextIndent(indent + 2, "SCROLL_BY=%d\n", _scrollBy); + + buffer->putTextIndent(indent + 2, "\n"); + + // window + if (_window) _window->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_closeButton)); + persistMgr->transfer(TMEMBER(_hideSelected)); + persistMgr->transfer(TMEMBER(_itemHeight)); + persistMgr->transfer(TMEMBER(_itemsArea)); + persistMgr->transfer(TMEMBER(_itemWidth)); + persistMgr->transfer(TMEMBER(_scrollBy)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_window)); + persistMgr->transfer(TMEMBER(_exclusive)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h new file mode 100644 index 0000000000..09d3ef409e --- /dev/null +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADINVENTORYBOX_H +#define WINTERMUTE_ADINVENTORYBOX_H + +#include "engines/wintermute/base/base_object.h" +#include "common/rect.h" + +namespace WinterMute { +class CUIButton; +class CUIWindow; + +class CAdInventoryBox : public CBObject { +public: + bool _hideSelected; + DECLARE_PERSISTENT(CAdInventoryBox, CBObject) + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; + bool _visible; + virtual bool display(); + CUIButton *_closeButton; + int _spacing; + int _scrollOffset; + Rect32 _itemsArea; + bool listen(CBScriptHolder *param1, uint32 param2); + CUIWindow *_window; + CAdInventoryBox(CBGame *inGame); + virtual ~CAdInventoryBox(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp new file mode 100644 index 0000000000..9c49a86bcb --- /dev/null +++ b/engines/wintermute/ad/ad_item.cpp @@ -0,0 +1,760 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdItem, false) + +////////////////////////////////////////////////////////////////////////// +CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { + _spriteHover = NULL; + _cursorNormal = _cursorHover = NULL; + + _cursorCombined = true; + _inInventory = false; + + _displayAmount = false; + _amount = 0; + _amountOffsetX = 0; + _amountOffsetY = 0; + _amountAlign = TAL_RIGHT; + _amountString = NULL; + + _state = STATE_READY; + + _movable = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdItem::~CAdItem() { + delete _spriteHover; + delete _cursorNormal; + delete _cursorHover; + _spriteHover = NULL; + _cursorNormal = NULL; + _cursorHover = NULL; + + delete[] _amountString; + _amountString = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ITEM) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(CURSOR_HOVER) +TOKEN_DEF(CURSOR_COMBINED) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(FONT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TALK_SPECIAL) +TOKEN_DEF(TALK) +TOKEN_DEF(SPRITE_HOVER) +TOKEN_DEF(SPRITE) +TOKEN_DEF(DISPLAY_AMOUNT) +TOKEN_DEF(AMOUNT_OFFSET_X) +TOKEN_DEF(AMOUNT_OFFSET_Y) +TOKEN_DEF(AMOUNT_ALIGN) +TOKEN_DEF(AMOUNT_STRING) +TOKEN_DEF(AMOUNT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdItem::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ITEM) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(CURSOR_HOVER) + TOKEN_TABLE(CURSOR_COMBINED) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(FONT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TALK_SPECIAL) + TOKEN_TABLE(TALK) + TOKEN_TABLE(SPRITE_HOVER) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(DISPLAY_AMOUNT) + TOKEN_TABLE(AMOUNT_OFFSET_X) + TOKEN_TABLE(AMOUNT_OFFSET_Y) + TOKEN_TABLE(AMOUNT_ALIGN) + TOKEN_TABLE(AMOUNT_STRING) + TOKEN_TABLE(AMOUNT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { + _gameRef->LOG(0, "'ITEM' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int ar = 0, ag = 0, ab = 0, alpha = 255; + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_FONT: + SetFont((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_IMAGE: + case TOKEN_SPRITE: + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _sprite; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + case TOKEN_SPRITE_HOVER: + delete _spriteHover; + _spriteHover = new CBSprite(_gameRef, this); + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _spriteHover; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_AMOUNT: + parser.scanStr((char *)params, "%d", &_amount); + break; + + case TOKEN_DISPLAY_AMOUNT: + parser.scanStr((char *)params, "%b", &_displayAmount); + break; + + case TOKEN_AMOUNT_OFFSET_X: + parser.scanStr((char *)params, "%d", &_amountOffsetX); + break; + + case TOKEN_AMOUNT_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_amountOffsetY); + break; + + case TOKEN_AMOUNT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; + else _amountAlign = TAL_CENTER; + break; + + case TOKEN_AMOUNT_STRING: + CBUtils::setString(&_amountString, (char *)params); + break; + + case TOKEN_TALK: { + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSprites.add(spr); + } + break; + + case TOKEN_TALK_SPECIAL: { + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + else _talkSpritesEx.add(spr); + } + break; + + case TOKEN_CURSOR: + delete _cursorNormal; + _cursorNormal = new CBSprite(_gameRef); + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _cursorNormal; + _cursorNormal = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_HOVER: + delete _cursorHover; + _cursorHover = new CBSprite(_gameRef); + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + delete _cursorHover; + _cursorHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_COMBINED: + parser.scanStr((char *)params, "%b", &_cursorCombined); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ITEM definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ITEM definition"); + return STATUS_FAILED; + } + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::update() { + _currentSprite = NULL; + + if (_state == STATE_READY && _animSprite) { + delete _animSprite; + _animSprite = NULL; + } + + // finished playing animation? + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + _state = STATE_READY; + _currentSprite = _animSprite; + } + + if (_sentence && _state != STATE_TALKING) _sentence->finish(); + + // default: stand animation + if (!_currentSprite) _currentSprite = _sprite; + + switch (_state) { + ////////////////////////////////////////////////////////////////////////// + case STATE_PLAYING_ANIM: + _currentSprite = _animSprite; + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_READY: + if (!_animSprite) { + if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; + else _currentSprite = _sprite; + } + break; + + ////////////////////////////////////////////////////////////////////////// + case STATE_TALKING: { + _sentence->update(); + if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + + bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { + if (TimeIsUp) { + _sentence->finish(); + _tempSprite2 = NULL; + _state = STATE_READY; + } else { + _tempSprite2 = getTalkStance(_sentence->getNextStance()); + if (_tempSprite2) { + _tempSprite2->reset(); + _currentSprite = _tempSprite2; + } + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } else { + _currentSprite = _tempSprite2; + ((CAdGame *)_gameRef)->addSentence(_sentence); + } + } + default: + break; + } + _ready = (_state == STATE_READY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::display(int x, int y) { + int width = 0; + if (_currentSprite) { + Rect32 rc; + _currentSprite->getBoundingRect(&rc, 0, 0); + width = rc.width(); + } + + _posX = x + width / 2; + _posY = y; + + bool ret; + if (_currentSprite) + ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); + else ret = STATUS_OK; + + if (_displayAmount) { + int amountX = x; + int amountY = y + _amountOffsetY; + + if (_amountAlign == TAL_RIGHT) { + width -= _amountOffsetX; + amountX -= _amountOffsetX; + } + amountX += _amountOffsetX; + + CBFont *font = _font ? _font : _gameRef->_systemFont; + if (font) { + if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); + else { + char Str[256]; + sprintf(Str, "%d", _amount); + font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); + } + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetHoverSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetHoverSprite") == 0) { + stack->correctParams(1); + + bool setCurrent = false; + if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; + + const char *filename = stack->pop()->getString(); + + delete _spriteHover; + _spriteHover = NULL; + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); + } else { + _spriteHover = spr; + if (setCurrent) _currentSprite = _spriteHover; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverSprite") == 0) { + stack->correctParams(0); + + if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); + else stack->pushString(_spriteHover->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverSpriteObject") == 0) { + stack->correctParams(0); + if (!_spriteHover) stack->pushNULL(); + else stack->pushNative(_spriteHover, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetNormalCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetNormalCursor") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + delete _cursorNormal; + _cursorNormal = NULL; + CBSprite *spr = new CBSprite(_gameRef); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); + } else { + _cursorNormal = spr; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNormalCursor") == 0) { + stack->correctParams(0); + + if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); + else stack->pushString(_cursorNormal->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNormalCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNormalCursorObject") == 0) { + stack->correctParams(0); + + if (!_cursorNormal) stack->pushNULL(); + else stack->pushNative(_cursorNormal, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverCursor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetHoverCursor") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + delete _cursorHover; + _cursorHover = NULL; + CBSprite *spr = new CBSprite(_gameRef); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); + } else { + _cursorHover = spr; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverCursor") == 0) { + stack->correctParams(0); + + if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); + else stack->pushString(_cursorHover->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverCursorObject") == 0) { + stack->correctParams(0); + + if (!_cursorHover) stack->pushNULL(); + else stack->pushNative(_cursorHover, true); + return STATUS_OK; + } + + else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdItem::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("item"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayAmount") == 0) { + _scValue->setBool(_displayAmount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Amount") == 0) { + _scValue->setInt(_amount); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetX") == 0) { + _scValue->setInt(_amountOffsetX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetY") == 0) { + _scValue->setInt(_amountOffsetY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountAlign") == 0) { + _scValue->setInt(_amountAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountString") == 0) { + if (!_amountString) _scValue->setNULL(); + else _scValue->setString(_amountString); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorCombined") == 0) { + _scValue->setBool(_cursorCombined); + return _scValue; + } + + else return CAdTalkHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayAmount") == 0) { + _displayAmount = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Amount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Amount") == 0) { + _amount = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetX") == 0) { + _amountOffsetX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountOffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountOffsetY") == 0) { + _amountOffsetY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountAlign") == 0) { + _amountAlign = (TTextAlign)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AmountString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AmountString") == 0) { + if (value->isNULL()) { + delete[] _amountString; + _amountString = NULL; + } else { + CBUtils::setString(&_amountString, value->getString()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorCombined + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorCombined") == 0) { + _cursorCombined = value->getBool(); + return STATUS_OK; + } + + else return CAdTalkHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdItem::scToString() { + return "[item]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::persist(CBPersistMgr *persistMgr) { + + CAdTalkHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_cursorCombined)); + persistMgr->transfer(TMEMBER(_cursorHover)); + persistMgr->transfer(TMEMBER(_cursorNormal)); + persistMgr->transfer(TMEMBER(_spriteHover)); + persistMgr->transfer(TMEMBER(_inInventory)); + persistMgr->transfer(TMEMBER(_displayAmount)); + persistMgr->transfer(TMEMBER(_amount)); + persistMgr->transfer(TMEMBER(_amountOffsetX)); + persistMgr->transfer(TMEMBER(_amountOffsetY)); + persistMgr->transfer(TMEMBER_INT(_amountAlign)); + persistMgr->transfer(TMEMBER(_amountString)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdItem::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; + else return CAdObject::getExtendedFlag(flagName); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h new file mode 100644 index 0000000000..34b19a830f --- /dev/null +++ b/engines/wintermute/ad/ad_item.h @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADITEM_H +#define WINTERMUTE_ADITEM_H + + +#include "engines/wintermute/ad/ad_talk_holder.h" + +namespace WinterMute { + +class CAdItem : public CAdTalkHolder { +public: + bool _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; + + + bool update(); + DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) + bool display(int x, int y); + bool getExtendedFlag(const char *flagName); + bool _inInventory; + bool _cursorCombined; + CBSprite *_spriteHover; + CBSprite *_cursorNormal; + CBSprite *_cursorHover; + CAdItem(CBGame *inGame); + virtual ~CAdItem(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp new file mode 100644 index 0000000000..e23948ed87 --- /dev/null +++ b/engines/wintermute/ad/ad_layer.cpp @@ -0,0 +1,537 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/ad/ad_layer.h" +#include "engines/wintermute/ad/ad_scene_node.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdLayer, false) + +////////////////////////////////////////////////////////////////////////// +CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { + _main = false; + _width = _height = 0; + _active = true; + _closeUp = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdLayer::~CAdLayer() { + for (int i = 0; i < _nodes.getSize(); i++) + delete _nodes[i]; + _nodes.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(LAYER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(MAIN) +TOKEN_DEF(ENTITY) +TOKEN_DEF(REGION) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(CLOSE_UP) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(MAIN) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(REGION) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(CLOSE_UP) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { + _gameRef->LOG(0, "'LAYER' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_MAIN: + parser.scanStr((char *)params, "%b", &_main); + break; + + case TOKEN_CLOSE_UP: + parser.scanStr((char *)params, "%b", &_closeUp); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_REGION: { + CAdRegion *region = new CAdRegion(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete region; + delete node; + region = NULL; + node = NULL; + } else { + node->setRegion(region); + _nodes.add(node); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(_gameRef); + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (entity) entity->_zoomable = false; // scene entites default to NOT zoom + if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + delete node; + entity = NULL; + node = NULL; + } else { + node->setEntity(entity); + _nodes.add(node); + } + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in LAYER definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int node = -1; + + if (val->_type == VAL_INT) node = val->getInt(); + else { // get by name + for (int i = 0; i < _nodes.getSize(); i++) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { + node = i; + break; + } + } + } + + if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); + else { + switch (_nodes[node]->_type) { + case OBJECT_ENTITY: + stack->pushNative(_nodes[node]->_entity, true); + break; + case OBJECT_REGION: + stack->pushNative(_nodes[node]->_region, true); + break; + default: + stack->pushNULL(); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddRegion / AddEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (strcmp(name, "AddRegion") == 0) { + CAdRegion *region = new CAdRegion(_gameRef); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); + } else { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); + } + _nodes.add(node); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertRegion / InsertEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + CAdSceneNode *node = new CAdSceneNode(_gameRef); + if (strcmp(name, "InsertRegion") == 0) { + CAdRegion *region = new CAdRegion(_gameRef); + if (!val->isNULL()) region->setName(val->getString()); + node->setRegion(region); + stack->pushNative(region, true); + } else { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!val->isNULL()) entity->setName(val->getString()); + node->setEntity(entity); + stack->pushNative(entity, true); + } + if (index < 0) index = 0; + if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); + else _nodes.add(node); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdSceneNode *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); + for (int i = 0; i < _nodes.getSize(); i++) { + if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { + toDelete = _nodes[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < _nodes.getSize()) { + toDelete = _nodes[index]; + } + } + if (toDelete == NULL) { + stack->pushBool(false); + return STATUS_OK; + } + + for (int i = 0; i < _nodes.getSize(); i++) { + if (_nodes[i] == toDelete) { + delete _nodes[i]; + _nodes[i] = NULL; + _nodes.removeAt(i); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdLayer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("layer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumNodes") == 0) { + _scValue->setInt(_nodes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Main (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Main") == 0) { + _scValue->setBool(_main); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CloseUp") == 0) { + _scValue->setBool(_closeUp); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CloseUp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CloseUp") == 0) { + _closeUp = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + if (_width < 0) _width = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + if (_height < 0) _height = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + bool b = value->getBool(); + if (b == false && _main) { + _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); + } else _active = b; + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdLayer::scToString() { + return "[layer]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "LAYER {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + if (_closeUp) + buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + for (i = 0; i < _nodes.getSize(); i++) { + switch (_nodes[i]->_type) { + case OBJECT_ENTITY: + _nodes[i]->_entity->saveAsText(buffer, indent + 2); + break; + case OBJECT_REGION: + _nodes[i]->_region->saveAsText(buffer, indent + 2); + break; + default: + error("CAdLayer::SaveAsText - Unhandled enum"); + break; + } + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdLayer::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_closeUp)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_main)); + _nodes.persist(persistMgr); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h new file mode 100644 index 0000000000..0ccdb13ae7 --- /dev/null +++ b/engines/wintermute/ad/ad_layer.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADLAYER_H +#define WINTERMUTE_ADLAYER_H + +namespace WinterMute { +class CAdSceneNode; +class CAdLayer : public CBObject { +public: + bool _closeUp; + DECLARE_PERSISTENT(CAdLayer, CBObject) + bool _active; + int _height; + int _width; + bool _main; + CAdLayer(CBGame *inGame); + virtual ~CAdLayer(); + CBArray _nodes; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp new file mode 100644 index 0000000000..06f9c4cf95 --- /dev/null +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -0,0 +1,169 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/ad/ad_node_state.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdNodeState, false) + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { + _name = NULL; + _active = false; + for (int i = 0; i < 7; i++) _caption[i] = NULL; + _alphaColor = 0; + _filename = NULL; + _cursor = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState::~CAdNodeState() { + delete[] _name; + delete[] _filename; + delete[] _cursor; + _name = NULL; + _filename = NULL; + _cursor = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setName(const char *name) { + delete[] _name; + _name = NULL; + CBUtils::setString(&_name, name); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setFilename(const char *filename) { + delete[] _filename; + _filename = NULL; + CBUtils::setString(&_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setCursor(const char *filename) { + delete[] _cursor; + _cursor = NULL; + CBUtils::setString(&_cursor, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdNodeState::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdNodeState::setCaption(const char *caption, int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7) return; + + delete[] _caption[caseVal- 1]; + _caption[caseVal- 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal- 1]) { + strcpy(_caption[caseVal- 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal- 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdNodeState::getCaption(int caseVal) { + if (caseVal== 0) caseVal= 1; + if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; + else return _caption[caseVal- 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { + if (!entity) return STATUS_FAILED; + + // hack! + if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; + + if (saving) { + for (int i = 0; i < 7; i++) { + if (entity->_caption[i]) setCaption(entity->_caption[i], i); + } + if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { + if (includingSprites) setFilename(entity->_sprite->_filename); + else setFilename(""); + } + if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); + _alphaColor = entity->_alphaColor; + _active = entity->_active; + } else { + for (int i = 0; i < 7; i++) { + if (_caption[i]) entity->setCaption(_caption[i], i); + } + if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { + if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) + entity->setSprite(_filename); + } + if (_cursor) { + if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) + entity->setCursor(_cursor); + } + + entity->_active = _active; + entity->_alphaColor = _alphaColor; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_node_state.h b/engines/wintermute/ad/ad_node_state.h new file mode 100644 index 0000000000..186f2ebbb2 --- /dev/null +++ b/engines/wintermute/ad/ad_node_state.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADNODESTATE_H +#define WINTERMUTE_ADNODESTATE_H + +namespace WinterMute { + +class CAdEntity; + +class CAdNodeState : public CBBase { +public: + bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); + void setName(const char *name); + void setFilename(const char *filename); + void setCursor(const char *filename); + DECLARE_PERSISTENT(CAdNodeState, CBBase) + CAdNodeState(CBGame *inGame); + virtual ~CAdNodeState(); + char *_name; + bool _active; + char *_caption[7]; + void setCaption(const char *caption, int caseVal); + char *getCaption(int caseVal); + uint32 _alphaColor; + char *_filename; + char *_cursor; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp new file mode 100644 index 0000000000..46f2e590fd --- /dev/null +++ b/engines/wintermute/ad/ad_object.cpp @@ -0,0 +1,1203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/ad/ad_object.h" +#include "engines/wintermute/ad/ad_inventory.h" +#include "engines/wintermute/ad/ad_layer.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/ad/ad_scene_node.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "common/str.h" +#include "common/util.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdObject, false) + +////////////////////////////////////////////////////////////////////////// +CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _state = _nextState = STATE_NONE; + + _active = true; + _drawn = false; + + _currentSprite = NULL; + _animSprite = NULL; + _tempSprite2 = NULL; + + _font = NULL; + + _sentence = NULL; + + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + + _blockRegion = NULL; + _wptGroup = NULL; + + _currentBlockRegion = NULL; + _currentWptGroup = NULL; + + _ignoreItems = false; + _sceneIndependent = false; + + _stickRegion = NULL; + + _subtitlesModRelative = true; + _subtitlesModX = 0; + _subtitlesModY = 0; + _subtitlesWidth = 0; + _subtitlesModXCenter = true; + + _inventory = NULL; + + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + + _partEmitter = NULL; + _partFollowParent = false; + _partOffsetX = _partOffsetY = 0; + + _registerAlias = this; +} + + +////////////////////////////////////////////////////////////////////////// +CAdObject::~CAdObject() { + _currentSprite = NULL; // reference only, don't delete + delete _animSprite; + _animSprite = NULL; + delete _sentence; + _sentence = NULL; + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + + delete _blockRegion; + _blockRegion = NULL; + delete _wptGroup; + _wptGroup = NULL; + + delete _currentBlockRegion; + _currentBlockRegion = NULL; + delete _currentWptGroup; + _currentWptGroup = NULL; + + _tempSprite2 = NULL; // reference only + _stickRegion = NULL; + + if (_font) _gameRef->_fontStorage->removeFont(_font); + + if (_inventory) { + ((CAdGame *)_gameRef)->unregisterInventory(_inventory); + _inventory = NULL; + } + + if (_partEmitter) + _gameRef->unregisterObject(_partEmitter); + + + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + _gameRef->unregisterObject(_attachmentsPre[i]); + } + _attachmentsPre.removeAll(); + + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + _gameRef->unregisterObject(_attachmentsPost[i]); + } + _attachmentsPost.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::playAnim(const char *filename) { + delete _animSprite; + _animSprite = NULL; + _animSprite = new CBSprite(_gameRef, this); + if (!_animSprite) { + _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + return STATUS_FAILED; + } + bool res = _animSprite->loadFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + delete _animSprite; + _animSprite = NULL; + return res; + } + _state = STATE_PLAYING_ANIM; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::display() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::update() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // PlayAnim / PlayAnimAsync + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { + stack->correctParams(1); + if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); + else { + if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsTalking") == 0) { + stack->correctParams(0); + stack->pushBool(_state == STATE_TALKING); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopTalk / StopTalking + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { + stack->correctParams(0); + if (_sentence) _sentence->finish(); + if (_state == STATE_TALKING) { + _state = _nextState; + _nextState = STATE_READY; + stack->pushBool(true); + } else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ForceTalkAnim + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ForceTalkAnim") == 0) { + stack->correctParams(1); + const char *animName = stack->pop()->getString(); + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = new char[strlen(animName) + 1]; + strcpy(_forcedTalkAnimName, animName); + _forcedTalkAnimUsed = false; + stack->pushBool(true); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Talk / TalkAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) { + stack->correctParams(5); + + const char *text = stack->pop()->getString(); + CScValue *soundVal = stack->pop(); + int duration = stack->pop()->getInt(); + CScValue *valStances = stack->pop(); + + const char *stances = valStances->isNULL() ? NULL : valStances->getString(); + + int align = 0; + CScValue *val = stack->pop(); + if (val->isNULL()) align = TAL_CENTER; + else align = val->getInt(); + + align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); + + const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); + + talk(text, sound, duration, stances, (TTextAlign)align); + if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StickToRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StickToRegion") == 0) { + stack->correctParams(1); + + CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; + bool regFound = false; + + int i; + CScValue *val = stack->pop(); + if (val->isNULL() || !main) { + _stickRegion = NULL; + regFound = true; + } else if (val->isString()) { + const char *regionName = val->getString(); + for (i = 0; i < main->_nodes.getSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; + break; + } + } + } else if (val->isNative()) { + CBScriptable *obj = val->getNative(); + + for (i = 0; i < main->_nodes.getSize(); i++) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { + _stickRegion = main->_nodes[i]->_region; + regFound = true; + break; + } + } + + } + + if (!regFound) _stickRegion = NULL; + stack->pushBool(regFound); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isNULL()) SetFont(NULL); + else SetFont(val->getString()); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFont") == 0) { + stack->correctParams(0); + if (_font && _font->_filename) stack->pushString(_font->_filename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TakeItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TakeItem") == 0) { + stack->correctParams(2); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + const char *itemName = val->getString(); + val = stack->pop(); + const char *insertAfter = val->isNULL() ? NULL : val->getString(); + if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); + else { + // hide associated entities + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); + } + + } else script->runtimeError("TakeItem: item name expected"); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DropItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DropItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); + else { + // show associated entities + ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); + } + } else script->runtimeError("DropItem: item name expected"); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (val->_type == VAL_STRING) { + CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); + if (item) stack->pushNative(item, true); + else stack->pushNULL(); + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) + stack->pushNULL(); + else + stack->pushNative(_inventory->_takenItems[val->getInt()], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasItem + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasItem") == 0) { + stack->correctParams(1); + + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + + CScValue *val = stack->pop(); + if (!val->isNULL()) { + for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { + if (val->getNative() == _inventory->_takenItems[i]) { + stack->pushBool(true); + return STATUS_OK; + } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { + stack->pushBool(true); + return STATUS_OK; + } + } + } else script->runtimeError("HasItem: item name expected"); + + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateParticleEmitter") == 0) { + stack->correctParams(3); + bool followParent = stack->pop()->getBool(); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); + + CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); + if (emitter) stack->pushNative(_partEmitter, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteParticleEmitter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteParticleEmitter") == 0) { + stack->correctParams(0); + if (_partEmitter) { + _gameRef->unregisterObject(_partEmitter); + _partEmitter = NULL; + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddAttachment") == 0) { + stack->correctParams(4); + const char *filename = stack->pop()->getString(); + bool preDisplay = stack->pop()->getBool(true); + int offsetX = stack->pop()->getInt(); + int offsetY = stack->pop()->getInt(); + + bool res; + CAdEntity *ent = new CAdEntity(_gameRef); + if (DID_FAIL(res = ent->loadFile(filename))) { + delete ent; + ent = NULL; + script->runtimeError("AddAttachment() failed loading entity '%s'", filename); + stack->pushBool(false); + } else { + _gameRef->registerObject(ent); + + ent->_posX = offsetX; + ent->_posY = offsetY; + ent->_active = true; + + if (preDisplay) _attachmentsPre.add(ent); + else _attachmentsPost.add(ent); + + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveAttachment") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool found = false; + if (val->isNative()) { + CBScriptable *obj = val->getNative(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPre[i]); + _attachmentsPre.removeAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i] == obj) { + found = true; + _gameRef->unregisterObject(_attachmentsPost[i]); + _attachmentsPost.removeAt(i); + i--; + } + } + } else { + const char *attachmentName = val->getString(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + found = true; + _gameRef->unregisterObject(_attachmentsPre[i]); + _attachmentsPre.removeAt(i); + i--; + } + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + found = true; + _gameRef->unregisterObject(_attachmentsPost[i]); + _attachmentsPost.removeAt(i); + i--; + } + } + } + stack->pushBool(found); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetAttachment + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAttachment") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + int currIndex = 0; + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (currIndex == index) ret = _attachmentsPre[i]; + currIndex++; + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (currIndex == index) ret = _attachmentsPost[i]; + currIndex++; + } + } else { + const char *attachmentName = val->getString(); + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + ret = _attachmentsPre[i]; + break; + } + } + if (!ret) { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + ret = _attachmentsPre[i]; + break; + } + } + } + } + + if (ret != NULL) stack->pushNative(ret, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IgnoreItems") == 0) { + _scValue->setBool(_ignoreItems); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SceneIndependent") == 0) { + _scValue->setBool(_sceneIndependent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesWidth") == 0) { + _scValue->setInt(_subtitlesWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosRelative") == 0) { + _scValue->setBool(_subtitlesModRelative); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosX") == 0) { + _scValue->setInt(_subtitlesModX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosY") == 0) { + _scValue->setInt(_subtitlesModY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { + _scValue->setBool(_subtitlesModXCenter); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumItems (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumItems") == 0) { + _scValue->setInt(getInventory()->_takenItems.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParticleEmitter (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParticleEmitter") == 0) { + if (_partEmitter) _scValue->setNative(_partEmitter, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumAttachments (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumAttachments") == 0) { + _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); + return _scValue; + } + + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::scSetProperty(const char *name, CScValue *value) { + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IgnoreItems + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IgnoreItems") == 0) { + _ignoreItems = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SceneIndependent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SceneIndependent") == 0) { + _sceneIndependent = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesWidth") == 0) { + _subtitlesWidth = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosRelative + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosRelative") == 0) { + _subtitlesModRelative = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosX") == 0) { + _subtitlesModX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosY") == 0) { + _subtitlesModY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesPosXCenter + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesPosXCenter") == 0) { + _subtitlesModXCenter = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdObject::scToString() { + return "[ad object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::SetFont(const char *filename) { + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (filename) { + _font = _gameRef->_fontStorage->addFont(filename); + return _font == NULL ? STATUS_FAILED : STATUS_OK; + } else { + _font = NULL; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CAdObject::getHeight() { + if (!_currentSprite) return 0; + else { + CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; + int ret = 0; + for (int i = 0; i < frame->_subframes.getSize(); i++) { + ret = MAX(ret, frame->_subframes[i]->_hotspotY); + } + + if (_zoomable) { + float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); + ret = (int)(ret * zoom / 100); + } + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { + if (!_sentence) _sentence = new CAdSentence(_gameRef); + if (!_sentence) return; + + if (_forcedTalkAnimName && _forcedTalkAnimUsed) { + delete[] _forcedTalkAnimName; + _forcedTalkAnimName = NULL; + _forcedTalkAnimUsed = false; + } + + delete(_sentence->_sound); + _sentence->_sound = NULL; + + _sentence->setText(text); + _gameRef->_stringTable->expand(&_sentence->_text); + _sentence->setStances(stances); + _sentence->_duration = duration; + _sentence->_align = Align; + _sentence->_startTime = _gameRef->_timer; + _sentence->_currentStance = -1; + _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; + _sentence->_freezable = _freezable; + + // try to locate speech file automatically + bool deleteSound = false; + if (!sound) { + char *key = _gameRef->_stringTable->getKey(text); + if (key) { + sound = ((CAdGame *)_gameRef)->findSpeechFile(key); + delete [] key; + + if (sound) deleteSound = true; + } + } + + // load sound and set duration appropriately + if (sound) { + CBSound *snd = new CBSound(_gameRef); + if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { + _sentence->setSound(snd); + if (_sentence->_duration <= 0) { + uint32 Length = snd->getLength(); + if (Length != 0) _sentence->_duration = Length; + } + } else delete snd; + } + + // set duration by text length + if (_sentence->_duration <= 0) {// TODO: Avoid longs. + _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); + } + + + int x, y, width, height; + + x = _posX; + y = _posY; + + if (!_sceneIndependent && _subtitlesModRelative) { + x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + + if (_subtitlesWidth > 0) width = _subtitlesWidth; + else { + if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { + width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); + } else width = _gameRef->_renderer->_width / 2; + } + + height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); + + y = y - height - getHeight() - 5; + if (_subtitlesModRelative) { + x += _subtitlesModX; + y += _subtitlesModY; + } else { + x = _subtitlesModX; + y = _subtitlesModY; + } + if (_subtitlesModXCenter) + x = x - width / 2; + + + x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); + y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); + + _sentence->_width = width; + + + _sentence->_pos.x = x; + _sentence->_pos.y = y; + + + if (_subtitlesModRelative) { + _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + _sentence->_fixedPos = !_subtitlesModRelative; + + + _sentence->setupTalkFile(sound); + + _state = STATE_TALKING; + + if (deleteSound) delete [] sound; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::reset() { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + delete _animSprite; + _animSprite = NULL; + } else if (_state == STATE_TALKING && _sentence) { + _sentence->finish(); + } + + _state = _nextState = STATE_READY; + + _gameRef->_scEngine->resetObject(this); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blockRegion)); + persistMgr->transfer(TMEMBER(_currentBlockRegion)); + persistMgr->transfer(TMEMBER(_currentWptGroup)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_drawn)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_ignoreItems)); + persistMgr->transfer(TMEMBER_INT(_nextState)); + persistMgr->transfer(TMEMBER(_sentence)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_animSprite)); + persistMgr->transfer(TMEMBER(_sceneIndependent)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); + persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); + persistMgr->transfer(TMEMBER(_tempSprite2)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_wptGroup)); + persistMgr->transfer(TMEMBER(_stickRegion)); + persistMgr->transfer(TMEMBER(_subtitlesModRelative)); + persistMgr->transfer(TMEMBER(_subtitlesModX)); + persistMgr->transfer(TMEMBER(_subtitlesModY)); + persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); + persistMgr->transfer(TMEMBER(_subtitlesWidth)); + persistMgr->transfer(TMEMBER(_inventory)); + persistMgr->transfer(TMEMBER(_partEmitter)); + + for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); + + _attachmentsPre.persist(persistMgr); + _attachmentsPost.persist(persistMgr); + persistMgr->transfer(TMEMBER(_registerAlias)); + + persistMgr->transfer(TMEMBER(_partFollowParent)); + persistMgr->transfer(TMEMBER(_partOffsetX)); + persistMgr->transfer(TMEMBER(_partOffsetY)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateSounds() { + if (_sentence && _sentence->_sound) + updateOneSound(_sentence->_sound); + + return CBObject::updateSounds(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::resetSoundPan() { + if (_sentence && _sentence->_sound) { + _sentence->_sound->setPan(0.0f); + } + return CBObject::resetSoundPan(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::getExtendedFlag(const char *flagName) { + if (!flagName) return false; + else if (strcmp(flagName, "usable") == 0) return true; + + else return CBObject::getExtendedFlag(flagName); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { + if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); + if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); + + CBBase::saveAsText(buffer, indent + 2); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateBlockRegion() { + CAdGame *adGame = (CAdGame *)_gameRef; + if (adGame->_scene) { + if (_blockRegion && _currentBlockRegion) + _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + + if (_wptGroup && _currentWptGroup) + _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CAdInventory *CAdObject::getInventory() { + if (!_inventory) { + _inventory = new CAdInventory(_gameRef); + ((CAdGame *)_gameRef)->registerInventory(_inventory); + } + return _inventory; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::afterMove() { + CAdRegion *newRegions[MAX_NUM_REGIONS]; + + ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (!newRegions[i]) break; + bool regFound = false; + for (int j = 0; j < MAX_NUM_REGIONS; j++) { + if (_currentRegions[j] == newRegions[i]) { + _currentRegions[j] = NULL; + regFound = true; + break; + } + } + if (!regFound) newRegions[i]->applyEvent("ActorEntry"); + } + + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) { + _currentRegions[i]->applyEvent("ActorLeave"); + } + _currentRegions[i] = newRegions[i]; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::invalidateCurrRegions() { + for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::getScale(float *scaleX, float *scaleY) { + if (_zoomable) { + if (_scaleX >= 0 || _scaleY >= 0) { + *scaleX = _scaleX < 0 ? 100 : _scaleX; + *scaleY = _scaleY < 0 ? 100 : _scaleY; + } else if (_scale >= 0) *scaleX = *scaleY = _scale; + else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + } else { + *scaleX = *scaleY = 100; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updateSpriteAttachments() { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + _attachmentsPre[i]->update(); + } + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + _attachmentsPost[i]->update(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::displaySpriteAttachments(bool preDisplay) { + if (preDisplay) { + for (int i = 0; i < _attachmentsPre.getSize(); i++) { + displaySpriteAttachment(_attachmentsPre[i]); + } + } else { + for (int i = 0; i < _attachmentsPost.getSize(); i++) { + displaySpriteAttachment(_attachmentsPost[i]); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { + if (!attachment->_active) return STATUS_OK; + + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + int origX = attachment->_posX; + int origY = attachment->_posY; + + // inherit position from owner + attachment->_posX = (int)(this->_posX + attachment->_posX * scaleX / 100.0f); + attachment->_posY = (int)(this->_posY + attachment->_posY * scaleY / 100.0f); + + // inherit other props + attachment->_alphaColor = this->_alphaColor; + attachment->_blendMode = this->_blendMode; + + attachment->_scale = this->_scale; + attachment->_relativeScale = this->_relativeScale; + attachment->_scaleX = this->_scaleX; + attachment->_scaleY = this->_scaleY; + + attachment->_rotate = this->_rotate; + attachment->_relativeRotate = this->_relativeRotate; + attachment->_rotateValid = this->_rotateValid; + + attachment->_registerAlias = this; + attachment->_registrable = this->_registrable; + + bool ret = attachment->display(); + + attachment->_posX = origX; + attachment->_posY = origY; + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { + _partFollowParent = followParent; + _partOffsetX = offsetX; + _partOffsetY = offsetY; + + if (!_partEmitter) { + _partEmitter = new CPartEmitter(_gameRef, this); + if (_partEmitter) { + _gameRef->registerObject(_partEmitter); + } + } + updatePartEmitter(); + return _partEmitter; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdObject::updatePartEmitter() { + if (!_partEmitter) return STATUS_FAILED; + + if (_partFollowParent) { + float scaleX, scaleY; + getScale(&scaleX, &scaleY); + + _partEmitter->_posX = (int)(_posX + (scaleX / 100.0f) * _partOffsetX); + _partEmitter->_posY = (int)(_posY + (scaleY / 100.0f) * _partOffsetY); + } + return _partEmitter->update(); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h new file mode 100644 index 0000000000..dd123092a3 --- /dev/null +++ b/engines/wintermute/ad/ad_object.h @@ -0,0 +1,123 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADOBJECT_H +#define WINTERMUTE_ADOBJECT_H + +#include "engines/wintermute/ad/ad_types.h" +#include "engines/wintermute/base/particles/part_emitter.h" + +namespace WinterMute { + +class CAdWaypointGroup; +class CAdRegion; +class CAdSentence; +class CBFont; +class CBRegion; +class CAdInventory; + +#define MAX_NUM_REGIONS 10 + +class CAdObject : public CBObject { +public: + CPartEmitter *_partEmitter; + virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); + virtual bool updatePartEmitter(); + bool _partFollowParent; + int _partOffsetX; + int _partOffsetY; + + bool invalidateCurrRegions(); + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int _subtitlesModX; + int _subtitlesModY; + int _subtitlesWidth; + CAdRegion *_stickRegion; + bool _sceneIndependent; + bool _ignoreItems; + bool updateBlockRegion(); + bool _forcedTalkAnimUsed; + char *_forcedTalkAnimName; + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool reset(); + DECLARE_PERSISTENT(CAdObject, CBObject) + virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); + virtual int getHeight(); + CAdSentence *_sentence; + bool SetFont(const char *filename); + virtual bool update(); + virtual bool display(); + bool _drawn; + bool _active; + virtual bool playAnim(const char *filename); + CBSprite *_animSprite; + CBSprite *_currentSprite; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; + CAdObject(CBGame *inGame); + virtual ~CAdObject(); + CBFont *_font; + CBSprite *_tempSprite2; + CBRegion *_blockRegion; + CAdWaypointGroup *_wptGroup; + CBRegion *_currentBlockRegion; + CAdWaypointGroup *_currentWptGroup; + CAdInventory *getInventory(); + + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + virtual bool afterMove(); + CAdRegion *_currentRegions[MAX_NUM_REGIONS]; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + CBArray _attachmentsPre; + CBArray _attachmentsPost; + + bool updateSpriteAttachments(); + bool displaySpriteAttachments(bool preDisplay); + CAdObject *_registerAlias; +private: + bool displaySpriteAttachment(CAdObject *attachment); + CAdInventory *_inventory; + +protected: + bool getScale(float *scaleX, float *scaleY); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp new file mode 100644 index 0000000000..780912ce08 --- /dev/null +++ b/engines/wintermute/ad/ad_path.cpp @@ -0,0 +1,112 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_path.h" +#include "engines/wintermute/base/base_point.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPath, false) + +////////////////////////////////////////////////////////////////////////// +CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPath::~CAdPath() { + reset(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::reset() { + for (int i = 0; i < _points.getSize(); i++) + delete _points[i]; + + _points.removeAll(); + _currIndex = -1; + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getFirst() { + if (_points.getSize() > 0) { + _currIndex = 0; + return _points[_currIndex]; + } else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getNext() { + _currIndex++; + if (_currIndex < _points.getSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint *CAdPath::getCurrent() { + if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdPath::addPoint(CBPoint *point) { + _points.add(point); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::setReady(bool ready) { + bool orig = _ready; + _ready = ready; + + return orig; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPath::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_currIndex)); + _points.persist(persistMgr); + persistMgr->transfer(TMEMBER(_ready)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h new file mode 100644 index 0000000000..f27362bfd9 --- /dev/null +++ b/engines/wintermute/ad/ad_path.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATH_H +#define WINTERMUTE_ADPATH_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CBPoint; +class CAdPath : public CBBase { +public: + DECLARE_PERSISTENT(CAdPath, CBBase) + CBPoint *getCurrent(); + bool setReady(bool ready = true); + void addPoint(CBPoint *point); + CBPoint *getNext(); + CBPoint *getFirst(); + void reset(); + CAdPath(CBGame *inGame); + virtual ~CAdPath(); + CBArray _points; + int _currIndex; + bool _ready; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp new file mode 100644 index 0000000000..d4b910a30f --- /dev/null +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_path_point.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdPathPoint, false) + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint() { + x = y = 0; + _distance = 0; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { + x = initX; + y = initY; + _distance = initDistance; + + _marked = false; + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdPathPoint::~CAdPathPoint() { + _origin = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { + + CBPoint::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_distance)); + persistMgr->transfer(TMEMBER(_marked)); + persistMgr->transfer(TMEMBER(_origin)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_path_point.h b/engines/wintermute/ad/ad_path_point.h new file mode 100644 index 0000000000..2a58237bb9 --- /dev/null +++ b/engines/wintermute/ad/ad_path_point.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADPATHPOINT_H +#define WINTERMUTE_ADPATHPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_point.h" + +namespace WinterMute { + +class CAdPathPoint : public CBPoint { +public: + DECLARE_PERSISTENT(CAdPathPoint, CBPoint) + CAdPathPoint(int initX, int initY, int initDistance); + CAdPathPoint(); + virtual ~CAdPathPoint(); + CAdPathPoint *_origin; + bool _marked; + int _distance; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp new file mode 100644 index 0000000000..ae65be5013 --- /dev/null +++ b/engines/wintermute/ad/ad_region.cpp @@ -0,0 +1,392 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_region.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRegion, false) + +////////////////////////////////////////////////////////////////////////// +CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { + _blocked = false; + _decoration = false; + _zoom = 0; + _alpha = 0xFFFFFFFF; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRegion::~CAdRegion() { +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(ZOOM) +TOKEN_DEF(SCALE) +TOKEN_DEF(BLOCKED) +TOKEN_DEF(DECORATION) +TOKEN_DEF(POINT) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(ZOOM) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(BLOCKED) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(POINT) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + int ar = 255, ag = 255, ab = 255, alpha = 255; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_BLOCKED: + parser.scanStr((char *)params, "%b", &_blocked); + break; + + case TOKEN_DECORATION: + parser.scanStr((char *)params, "%b", &_decoration); + break; + + case TOKEN_ZOOM: + case TOKEN_SCALE: { + int j; + parser.scanStr((char *)params, "%d", &j); + _zoom = (float)j; + } + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo")==0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + stack->pushNULL(); + + return STATUS_OK; + } + + else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("ad region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Blocked") == 0) { + _scValue->setBool(_blocked); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + _scValue->setFloat(_zoom); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alpha); + return _scValue; + } + + else return CBRegion::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Blocked + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Blocked") == 0) { + _blocked = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + _zoom = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + else return CBRegion::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdRegion::scToString() { + return "[ad region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "REGION {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_zoom); + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + int i; + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRegion::persist(CBPersistMgr *persistMgr) { + CBRegion::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_blocked)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_zoom)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h new file mode 100644 index 0000000000..62c5fd6ba3 --- /dev/null +++ b/engines/wintermute/ad/ad_region.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADREGION_H +#define WINTERMUTE_ADREGION_H + +#include "engines/wintermute/base/base_region.h" + +namespace WinterMute { + +class CAdRegion : public CBRegion { +public: + DECLARE_PERSISTENT(CAdRegion, CBRegion) + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; + CAdRegion(CBGame *inGame); + virtual ~CAdRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp new file mode 100644 index 0000000000..b653fbd36a --- /dev/null +++ b/engines/wintermute/ad/ad_response.cpp @@ -0,0 +1,143 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_response.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponse, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { + _text = NULL; + _textOrig = NULL; + _icon = _iconHover = _iconPressed = NULL; + _font = NULL; + _iD = 0; + _responseType = RESPONSE_ALWAYS; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponse::~CAdResponse() { + delete[] _text; + delete[] _textOrig; + delete _icon; + delete _iconHover; + delete _iconPressed; + _text = NULL; + _textOrig = NULL; + _icon = NULL; + _iconHover = NULL; + _iconPressed = NULL; + if (_font) _gameRef->_fontStorage->removeFont(_font); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponse::setText(const char *text) { + CBUtils::setString(&_text, text); + CBUtils::setString(&_textOrig, text); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIcon(const char *filename) { + delete _icon; + _icon = new CBSprite(_gameRef); + if (!_icon || DID_FAIL(_icon->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); + delete _icon; + _icon = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setFont(const char *filename) { + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont(filename); + if (!_font) { + _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIconHover(const char *filename) { + delete _iconHover; + _iconHover = new CBSprite(_gameRef); + if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); + delete _iconHover; + _iconHover = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::setIconPressed(const char *filename) { + delete _iconPressed; + _iconPressed = new CBSprite(_gameRef); + if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { + _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); + delete _iconPressed; + _iconPressed = NULL; + return STATUS_FAILED; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponse::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_icon)); + persistMgr->transfer(TMEMBER(_iconHover)); + persistMgr->transfer(TMEMBER(_iconPressed)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_textOrig)); + persistMgr->transfer(TMEMBER_INT(_responseType)); + persistMgr->transfer(TMEMBER(_font)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h new file mode 100644 index 0000000000..da450b2229 --- /dev/null +++ b/engines/wintermute/ad/ad_response.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSE_H +#define WINTERMUTE_ADRESPONSE_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/ad/ad_types.h" + +namespace WinterMute { +class CBFont; +class CAdResponse : public CBObject { +public: + DECLARE_PERSISTENT(CAdResponse, CBObject) + bool setIcon(const char *filename); + bool setFont(const char *filename); + bool setIconHover(const char *filename); + bool setIconPressed(const char *filename); + void setText(const char *text); + int _iD; + CBSprite *_icon; + CBSprite *_iconHover; + CBSprite *_iconPressed; + CBFont *_font; + char *_text; + char *_textOrig; + CAdResponse(CBGame *inGame); + virtual ~CAdResponse(); + TResponseType _responseType; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp new file mode 100644 index 0000000000..2499c9a732 --- /dev/null +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -0,0 +1,647 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_response_box.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/ui/ui_button.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/ad/ad_response.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseBox, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { + _font = _fontHover = NULL; + + _window = NULL; + _shieldWindow = new CUIWindow(_gameRef); + + _horizontal = false; + CBPlatform::setRectEmpty(&_responseArea); + _scrollOffset = 0; + _spacing = 0; + + _waitingScript = NULL; + _lastResponseText = NULL; + _lastResponseTextOrig = NULL; + + _verticalAlign = VAL_BOTTOM; + _align = TAL_LEFT; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseBox::~CAdResponseBox() { + + delete _window; + _window = NULL; + delete _shieldWindow; + _shieldWindow = NULL; + delete[] _lastResponseText; + _lastResponseText = NULL; + delete[] _lastResponseTextOrig; + _lastResponseTextOrig = NULL; + + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + + clearResponses(); + clearButtons(); + + _waitingScript = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::clearResponses() { + for (int i = 0; i < _responses.getSize(); i++) { + delete _responses[i]; + } + _responses.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::clearButtons() { + for (int i = 0; i < _respButtons.getSize(); i++) { + delete _respButtons[i]; + } + _respButtons.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::invalidateButtons() { + for (int i = 0; i < _respButtons.getSize(); i++) { + _respButtons[i]->_image = NULL; + _respButtons[i]->_cursor = NULL; + _respButtons[i]->_font = NULL; + _respButtons[i]->_fontHover = NULL; + _respButtons[i]->_fontPress = NULL; + _respButtons[i]->setText(""); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::createButtons() { + clearButtons(); + + _scrollOffset = 0; + for (int i = 0; i < _responses.getSize(); i++) { + CUIButton *btn = new CUIButton(_gameRef); + if (btn) { + btn->_parent = _window; + btn->_sharedFonts = btn->_sharedImages = true; + btn->_sharedCursors = true; + // iconic + if (_responses[i]->_icon) { + btn->_image = _responses[i]->_icon; + if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; + if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; + + btn->setCaption(_responses[i]->_text); + if (_cursor) btn->_cursor = _cursor; + else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; + } + // textual + else { + btn->setText(_responses[i]->_text); + btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; + btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; + btn->_fontPress = btn->_fontHover; + btn->_align = _align; + + if (_gameRef->_touchInterface) + btn->_fontHover = btn->_font; + + + if (_responses[i]->_font) btn->_font = _responses[i]->_font; + + btn->_width = _responseArea.right - _responseArea.left; + if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; + } + btn->setName("response"); + btn->correctSize(); + + // make the responses touchable + if (_gameRef->_touchInterface) + btn->_height = MAX(btn->_height, 50); + + //btn->SetListener(this, btn, _responses[i]->_iD); + btn->setListener(this, btn, i); + btn->_visible = false; + _respButtons.add(btn); + + if (_responseArea.bottom - _responseArea.top < btn->_height) { + _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text); + _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); + } + } + } + _ready = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(RESPONSE_BOX) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT) +TOKEN_DEF(AREA) +TOKEN_DEF(HORIZONTAL) +TOKEN_DEF(SPACING) +TOKEN_DEF(WINDOW) +TOKEN_DEF(CURSOR) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(RESPONSE_BOX) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT) + TOKEN_TABLE(AREA) + TOKEN_TABLE(HORIZONTAL) + TOKEN_TABLE(SPACING) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { + _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_WINDOW: + delete _window; + _window = new CUIWindow(_gameRef); + if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { + delete _window; + _window = NULL; + cmd = PARSERR_GENERIC; + } else if (_shieldWindow) _shieldWindow->_parent = _window; + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_AREA: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom); + break; + + case TOKEN_HORIZONTAL: + parser.scanStr((char *)params, "%b", &_horizontal); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_LEFT; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; + else _verticalAlign = VAL_BOTTOM; + break; + + case TOKEN_SPACING: + parser.scanStr((char *)params, "%d", &_spacing); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition"); + return STATUS_FAILED; + } + + if (_window) { + for (int i = 0; i < _window->_widgets.getSize(); i++) { + if (!_window->_widgets[i]->_listenerObject) + _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "RESPONSE_BOX\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); + + switch (_align) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CAdResponseBox::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + } + + buffer->putTextIndent(indent + 2, "SPACING=%d\n", _spacing); + + buffer->putTextIndent(indent + 2, "\n"); + + // window + if (_window) _window->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::display() { + Rect32 rect = _responseArea; + if (_window) { + CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); + //_window->display(); + } + + int xxx, yyy, i; + + xxx = rect.left; + yyy = rect.top; + + // shift down if needed + if (!_horizontal) { + int total_height = 0; + for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + total_height -= _spacing; + + switch (_verticalAlign) { + case VAL_BOTTOM: + if (yyy + total_height < rect.bottom) + yyy = rect.bottom - total_height; + break; + + case VAL_CENTER: + if (yyy + total_height < rect.bottom) + yyy += ((rect.bottom - rect.top) - total_height) / 2; + break; + + case VAL_TOP: + // do nothing + break; + } + } + + // prepare response buttons + bool scrollNeeded = false; + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) + || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { + + scrollNeeded = true; + _respButtons[i]->_visible = false; + break; + } + + _respButtons[i]->_visible = true; + _respButtons[i]->_posX = xxx; + _respButtons[i]->_posY = yyy; + + if (_horizontal) { + xxx += (_respButtons[i]->_width + _spacing); + } else { + yyy += (_respButtons[i]->_height + _spacing); + } + } + + // show appropriate scroll buttons + if (_window) { + _window->showWidget("prev", _scrollOffset > 0); + _window->showWidget("next", scrollNeeded); + } + + // go exclusive + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + + _shieldWindow->display(); + } + + // display window + if (_window) _window->display(); + + + // display response buttons + for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + _respButtons[i]->display(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "prev") == 0) { + _scrollOffset--; + } else if (scumm_stricmp(obj->_name, "next") == 0) { + _scrollOffset++; + } else if (scumm_stricmp(obj->_name, "response") == 0) { + if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); + handleResponse(_responses[param2]); + _waitingScript = NULL; + _gameRef->_state = GAME_RUNNING; + ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; + _ready = true; + invalidateButtons(); + clearResponses(); + } else return CBObject::listen(param1, param2); + break; + default: + error("AdResponseBox::Listen - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_horizontal)); + persistMgr->transfer(TMEMBER(_lastResponseText)); + persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); + _respButtons.persist(persistMgr); + persistMgr->transfer(TMEMBER(_responseArea)); + _responses.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_spacing)); + persistMgr->transfer(TMEMBER(_waitingScript)); + persistMgr->transfer(TMEMBER(_window)); + + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + persistMgr->transfer(TMEMBER_INT(_align)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::weedResponses() { + CAdGame *adGame = (CAdGame *)_gameRef; + + for (int i = 0; i < _responses.getSize(); i++) { + switch (_responses[i]->_responseType) { + case RESPONSE_ONCE: + if (adGame->branchResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.removeAt(i); + i--; + } + break; + + case RESPONSE_ONCE_GAME: + if (adGame->gameResponseUsed(_responses[i]->_iD)) { + delete _responses[i]; + _responses.removeAt(i); + i--; + } + break; + default: + warning("CAdResponseBox::WeedResponses - Unhandled enum"); + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { + CBUtils::setString(&_lastResponseText, text); + CBUtils::setString(&_lastResponseTextOrig, textOrig); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::handleResponse(CAdResponse *response) { + setLastResponseText(response->_text, response->_textOrig); + + CAdGame *adGame = (CAdGame *)_gameRef; + + switch (response->_responseType) { + case RESPONSE_ONCE: + adGame->addBranchResponse(response->_iD); + break; + + case RESPONSE_ONCE_GAME: + adGame->addGameResponse(response->_iD); + break; + default: + warning("CAdResponseBox::HandleResponse - Unhandled enum"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = 0; i < objects.getSize(); i++) { + if (objects[i] == currObject) { + if (i < objects.getSize() - 1) return objects[i + 1]; + else break; + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = objects.getSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; + else break; + } + } + } + return objects[objects.getSize() - 1]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _respButtons.getSize(); i++) { + objects.add(_respButtons[i]); + } + if (_window) _window->getWindowObjects(objects, interactiveOnly); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h new file mode 100644 index 0000000000..7c611ef2d6 --- /dev/null +++ b/engines/wintermute/ad/ad_response_box.h @@ -0,0 +1,87 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSEBOX_H +#define WINTERMUTE_ADRESPONSEBOX_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CUIButton; +class CUIWindow; +class CUIObject; +class CAdResponse; +class CAdResponseBox : public CBObject { +public: + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + bool getObjects(CBArray &objects, bool interactiveOnly); + + bool handleResponse(CAdResponse *response); + void setLastResponseText(const char *text, const char *textOrig); + char *_lastResponseText; + char *_lastResponseTextOrig; + DECLARE_PERSISTENT(CAdResponseBox, CBObject) + CScScript *_waitingScript; + virtual bool listen(CBScriptHolder *param1, uint32 param2); + typedef enum { + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE + } TResponseEvent; + + bool weedResponses(); + bool display(); + int _spacing; + int _scrollOffset; + CBFont *_fontHover; + CBFont *_font; + bool createButtons(); + bool invalidateButtons(); + void clearButtons(); + void clearResponses(); + CAdResponseBox(CBGame *inGame); + virtual ~CAdResponseBox(); + CBArray _responses; + CBArray _respButtons; + CUIWindow *_window; + CUIWindow *_shieldWindow; + bool _horizontal; + Rect32 _responseArea; + int _verticalAlign; + TTextAlign _align; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp new file mode 100644 index 0000000000..02b819d6de --- /dev/null +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -0,0 +1,70 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_response_context.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdResponseContext, false) + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { + _iD = 0; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdResponseContext::~CAdResponseContext() { + delete[] _context; + _context = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_context)); + persistMgr->transfer(TMEMBER(_iD)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CAdResponseContext::setContext(const char *context) { + delete[] _context; + _context = NULL; + if (context) { + _context = new char [strlen(context) + 1]; + if (_context) strcpy(_context, context); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_response_context.h b/engines/wintermute/ad/ad_response_context.h new file mode 100644 index 0000000000..79eaa27640 --- /dev/null +++ b/engines/wintermute/ad/ad_response_context.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADRESPONSECONTEXT_H +#define WINTERMUTE_ADRESPONSECONTEXT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CAdResponseContext : public CBBase { +public: + void setContext(const char *context); + int _iD; + char *_context; + DECLARE_PERSISTENT(CAdResponseContext, CBBase) + CAdResponseContext(CBGame *inGame); + virtual ~CAdResponseContext(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp new file mode 100644 index 0000000000..0ffbaf6919 --- /dev/null +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -0,0 +1,159 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_rot_level.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdRotLevel, false) + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { + _posX = 0; + _rotation = 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +CAdRotLevel::~CAdRotLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(X) +TOKEN_DEF(ROTATION) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(X) + TOKEN_TABLE(ROTATION) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { + _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_ROTATION: { + int i; + parser.scanStr((char *)params, "%d", &i); + _rotation = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_rotation)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_rot_level.h b/engines/wintermute/ad/ad_rot_level.h new file mode 100644 index 0000000000..2bd9519d65 --- /dev/null +++ b/engines/wintermute/ad/ad_rot_level.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADROTLEVEL_H +#define WINTERMUTE_ADROTLEVEL_H + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CAdRotLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdRotLevel, CBObject) + CAdRotLevel(CBGame *inGame); + virtual ~CAdRotLevel(); + float _rotation; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp new file mode 100644 index 0000000000..220d3c4b39 --- /dev/null +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -0,0 +1,157 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_scale_level.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScaleLevel, false) + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { + _posY = 0; + _scale = 100; +} + + +////////////////////////////////////////////////////////////////////////// +CAdScaleLevel::~CAdScaleLevel() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(Y) +TOKEN_DEF(SCALE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(Y) + TOKEN_TABLE(SCALE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { + _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_SCALE: { + int i; + parser.scanStr((char *)params, "%d", &i); + _scale = (float)i; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); + CBBase::saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scale)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_scale_level.h b/engines/wintermute/ad/ad_scale_level.h new file mode 100644 index 0000000000..4a81c00dda --- /dev/null +++ b/engines/wintermute/ad/ad_scale_level.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCALELEVEL_H +#define WINTERMUTE_ADSCALELEVEL_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CAdScaleLevel : public CBObject { +public: + DECLARE_PERSISTENT(CAdScaleLevel, CBObject) + float _scale; + CAdScaleLevel(CBGame *inGame); + virtual ~CAdScaleLevel(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp new file mode 100644 index 0000000000..11030d6996 --- /dev/null +++ b/engines/wintermute/ad/ad_scene.cpp @@ -0,0 +1,2752 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/ad/ad_actor.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_layer.h" +#include "engines/wintermute/ad/ad_node_state.h" +#include "engines/wintermute/ad/ad_object.h" +#include "engines/wintermute/ad/ad_path.h" +#include "engines/wintermute/ad/ad_path_point.h" +#include "engines/wintermute/ad/ad_rot_level.h" +#include "engines/wintermute/ad/ad_scale_level.h" +#include "engines/wintermute/ad/ad_scene_node.h" +#include "engines/wintermute/ad/ad_scene_state.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_point.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/utils/utils.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdScene, false) + +////////////////////////////////////////////////////////////////////////// +CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { + _pfTarget = new CBPoint; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +CAdScene::~CAdScene() { + cleanup(); + _gameRef->unregisterObject(_fader); + delete _pfTarget; + _pfTarget = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::setDefaults() { + _initialized = false; + _pfReady = true; + _pfTargetPath = NULL; + _pfRequester = NULL; + _mainLayer = NULL; + + _pfPointsNum = 0; + _persistentState = false; + _persistentStateSprites = true; + + _autoScroll = true; + _offsetLeft = _offsetTop = 0; + _targetOffsetLeft = _targetOffsetTop = 0; + + _lastTimeH = _lastTimeV = 0; + _scrollTimeH = _scrollTimeV = 10; + _scrollPixelsH = _scrollPixelsV = 1; + + _pfMaxTime = 15; + + _paralaxScrolling = true; + + // editor settings + _editorMarginH = _editorMarginV = 100; + + _editorColFrame = 0xE0888888; + _editorColEntity = 0xFF008000; + _editorColRegion = 0xFF0000FF; + _editorColBlocked = 0xFF800080; + _editorColWaypoints = 0xFF0000FF; + _editorColEntitySel = 0xFFFF0000; + _editorColRegionSel = 0xFFFF0000; + _editorColBlockedSel = 0xFFFF0000; + _editorColWaypointsSel = 0xFFFF0000; + _editorColScale = 0xFF00FF00; + _editorColDecor = 0xFF00FFFF; + _editorColDecorSel = 0xFFFF0000; + + _editorShowRegions = true; + _editorShowBlocked = true; + _editorShowDecor = true; + _editorShowEntities = true; + _editorShowScale = true; + + _shieldWindow = NULL; + + _fader = new CBFader(_gameRef); + _gameRef->registerObject(_fader); + + _viewport = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::cleanup() { + CBObject::cleanup(); + + _mainLayer = NULL; // reference only + + int i; + + delete _shieldWindow; + _shieldWindow = NULL; + + _gameRef->unregisterObject(_fader); + _fader = NULL; + + for (i = 0; i < _layers.getSize(); i++) + _gameRef->unregisterObject(_layers[i]); + _layers.removeAll(); + + + for (i = 0; i < _waypointGroups.getSize(); i++) + _gameRef->unregisterObject(_waypointGroups[i]); + _waypointGroups.removeAll(); + + for (i = 0; i < _scaleLevels.getSize(); i++) + _gameRef->unregisterObject(_scaleLevels[i]); + _scaleLevels.removeAll(); + + for (i = 0; i < _rotLevels.getSize(); i++) + _gameRef->unregisterObject(_rotLevels[i]); + _rotLevels.removeAll(); + + + for (i = 0; i < _pfPath.getSize(); i++) + delete _pfPath[i]; + _pfPath.removeAll(); + _pfPointsNum = 0; + + for (i = 0; i < _objects.getSize(); i++) + _gameRef->unregisterObject(_objects[i]); + _objects.removeAll(); + + delete _viewport; + _viewport = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { + if (!_pfReady) return false; + else { + _pfReady = false; + *_pfTarget = target; + _pfTargetPath = path; + _pfRequester = requester; + + _pfTargetPath->reset(); + _pfTargetPath->setReady(false); + + // prepare working path + int i; + pfPointsStart(); + + // first point + //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); + + // if we're one pixel stuck, get unstuck + int startX = source.x; + int startY = source.y; + int bestDistance = 1000; + if (isBlockedAt(startX, startY, true, requester)) { + int tolerance = 2; + for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) { + for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) { + if (isWalkableAt(xxx, yyy, true, requester)) { + int distance = abs(xxx - source.x) + abs(yyy - source.y); + if (distance < bestDistance) { + startX = xxx; + startY = yyy; + + bestDistance = distance; + } + } + } + } + } + + pfPointsAdd(startX, startY, 0); + + //CorrectTargetPoint(&target.x, &target.y); + + // last point + //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); + pfPointsAdd(target.x, target.y, INT_MAX); + + // active waypoints + for (i = 0; i < _waypointGroups.getSize(); i++) { + if (_waypointGroups[i]->_active) { + pfAddWaypointGroup(_waypointGroups[i], requester); + } + } + + + // free waypoints + for (i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { + pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { + pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); + } + } + + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { + if (!wpt->_active) return; + + for (int i = 0; i < wpt->_points.getSize(); i++) { + if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; + + //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); + } +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getZoomAt(int x, int y) { + float ret = 100; + + bool found = false; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { + if (node->_region->_zoom != 0) { + ret = node->_region->_zoom; + found = true; + break; + } + } + } + } + if (!found) ret = getScaleAt(y); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { + if (!_gameRef->_debugDebugMode) colorCheck = false; + + uint32 ret; + if (colorCheck) ret = 0xFFFF0000; + else ret = 0xFFFFFFFF; + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { + if (!node->_region->_blocked) ret = node->_region->_alpha; + break; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { + bool ret = true; + + + if (checkFreeObjects) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + /* + if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) + { + ret = true; + break; + } + */ + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { + if (node->_region->_blocked) { + ret = true; + break; + } else ret = false; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { + bool ret = false; + + if (checkFreeObjects) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + } + } + CAdGame *adGame = (CAdGame *)_gameRef; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + } + } + } + + + if (_mainLayer) { + for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { + if (node->_region->_blocked) { + ret = false; + break; + } else ret = true; + } + } + } + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { + double xStep, yStep, x, y; + int xLength, yLength, xCount, yCount; + int x1, y1, x2, y2; + + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; + + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); + + if (xLength > yLength) { + if (x1 > x2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); + } + + yStep = (double)(y2 - y1) / (double)(x2 - x1); + y = y1; + + for (xCount = x1; xCount < x2; xCount++) { + if (isBlockedAt(xCount, (int)y, true, requester)) return -1; + y += yStep; + } + } else { + if (y1 > y2) { + CBUtils::swap(&x1, &x2); + CBUtils::swap(&y1, &y2); + } + + xStep = (double)(x2 - x1) / (double)(y2 - y1); + x = x1; + + for (yCount = y1; yCount < y2; yCount++) { + if (isBlockedAt((int)x, yCount, true, requester)) return -1; + x += xStep; + } + } + return MAX(xLength, yLength); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pathFinderStep() { + int i; + // get lowest unmarked + int lowestDist = INT_MAX; + CAdPathPoint *lowestPt = NULL; + + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { + lowestDist = _pfPath[i]->_distance; + lowestPt = _pfPath[i]; + } + + if (lowestPt == NULL) { // no path -> terminate PathFinder + _pfReady = true; + _pfTargetPath->setReady(true); + return; + } + + lowestPt->_marked = true; + + // target point marked, generate path and terminate + if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { + while (lowestPt != NULL) { + _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); + lowestPt = lowestPt->_origin; + } + + _pfReady = true; + _pfTargetPath->setReady(true); + return; + } + + // otherwise keep on searching + for (i = 0; i < _pfPointsNum; i++) + if (!_pfPath[i]->_marked) { + int j = getPointsDist(*lowestPt, *_pfPath[i], _pfRequester); + if (j != -1 && lowestPt->_distance + j < _pfPath[i]->_distance) { + _pfPath[i]->_distance = lowestPt->_distance + j; + _pfPath[i]->_origin = lowestPt; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::initLoop() { +#ifdef _DEBUGxxxx + int nu_steps = 0; + uint32 start = _gameRef->_currentTime; + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { + PathFinderStep(); + nu_steps++; + } + if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); +#else + uint32 start = _gameRef->_currentTime; + while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); +#endif + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + delete[] _filename; + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SCENE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(LAYER) +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(CAMERA) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCALE_LEVEL) +TOKEN_DEF(ROTATION_LEVEL) +TOKEN_DEF(EDITOR_MARGIN_H) +TOKEN_DEF(EDITOR_MARGIN_V) +TOKEN_DEF(EDITOR_COLOR_FRAME) +TOKEN_DEF(EDITOR_COLOR_ENTITY_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION_SEL) +TOKEN_DEF(EDITOR_COLOR_DECORATION_SEL) +TOKEN_DEF(EDITOR_COLOR_BLOCKED_SEL) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS_SEL) +TOKEN_DEF(EDITOR_COLOR_REGION) +TOKEN_DEF(EDITOR_COLOR_DECORATION) +TOKEN_DEF(EDITOR_COLOR_BLOCKED) +TOKEN_DEF(EDITOR_COLOR_ENTITY) +TOKEN_DEF(EDITOR_COLOR_WAYPOINTS) +TOKEN_DEF(EDITOR_COLOR_SCALE) +TOKEN_DEF(EDITOR_SHOW_REGIONS) +TOKEN_DEF(EDITOR_SHOW_BLOCKED) +TOKEN_DEF(EDITOR_SHOW_DECORATION) +TOKEN_DEF(EDITOR_SHOW_ENTITIES) +TOKEN_DEF(EDITOR_SHOW_SCALE) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(VIEWPORT) +TOKEN_DEF(PERSISTENT_STATE_SPRITES) +TOKEN_DEF(PERSISTENT_STATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SCENE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(LAYER) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(CAMERA) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCALE_LEVEL) + TOKEN_TABLE(ROTATION_LEVEL) + TOKEN_TABLE(EDITOR_MARGIN_H) + TOKEN_TABLE(EDITOR_MARGIN_V) + TOKEN_TABLE(EDITOR_COLOR_FRAME) + TOKEN_TABLE(EDITOR_COLOR_ENTITY_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION_SEL) + TOKEN_TABLE(EDITOR_COLOR_DECORATION_SEL) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED_SEL) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS_SEL) + TOKEN_TABLE(EDITOR_COLOR_REGION) + TOKEN_TABLE(EDITOR_COLOR_DECORATION) + TOKEN_TABLE(EDITOR_COLOR_BLOCKED) + TOKEN_TABLE(EDITOR_COLOR_ENTITY) + TOKEN_TABLE(EDITOR_COLOR_WAYPOINTS) + TOKEN_TABLE(EDITOR_COLOR_SCALE) + TOKEN_TABLE(EDITOR_SHOW_REGIONS) + TOKEN_TABLE(EDITOR_SHOW_DECORATION) + TOKEN_TABLE(EDITOR_SHOW_BLOCKED) + TOKEN_TABLE(EDITOR_SHOW_ENTITIES) + TOKEN_TABLE(EDITOR_SHOW_SCALE) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(VIEWPORT) + TOKEN_TABLE(PERSISTENT_STATE_SPRITES) + TOKEN_TABLE(PERSISTENT_STATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + cleanup(); + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { + _gameRef->LOG(0, "'SCENE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int ar, ag, ab, aa; + char camera[MAX_PATH_LENGTH] = ""; + /* float WaypointHeight = -1.0f; */ + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_LAYER: { + CAdLayer *layer = new CAdLayer(_gameRef); + if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete layer; + layer = NULL; + } else { + _gameRef->registerObject(layer); + _layers.add(layer); + if (layer->_main) { + _mainLayer = layer; + _width = layer->_width; + _height = layer->_height; + } + } + } + break; + + case TOKEN_WAYPOINTS: { + CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete wpt; + wpt = NULL; + } else { + _gameRef->registerObject(wpt); + _waypointGroups.add(wpt); + } + } + break; + + case TOKEN_SCALE_LEVEL: { + CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); + if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete sl; + sl = NULL; + } else { + _gameRef->registerObject(sl); + _scaleLevels.add(sl); + } + } + break; + + case TOKEN_ROTATION_LEVEL: { + CAdRotLevel *rl = new CAdRotLevel(_gameRef); + if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete rl; + rl = NULL; + } else { + _gameRef->registerObject(rl); + _rotLevels.add(rl); + } + } + break; + + case TOKEN_ENTITY: { + CAdEntity *entity = new CAdEntity(_gameRef); + if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + delete entity; + entity = NULL; + } else { + addObject(entity); + } + } + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CAMERA: + strcpy(camera, (char *)params); + break; + + case TOKEN_EDITOR_MARGIN_H: + parser.scanStr((char *)params, "%d", &_editorMarginH); + break; + + case TOKEN_EDITOR_MARGIN_V: + parser.scanStr((char *)params, "%d", &_editorMarginV); + break; + + case TOKEN_EDITOR_COLOR_FRAME: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColFrame = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntity = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_ENTITY_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColEntitySel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegionSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecorSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlockedSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS_SEL: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypointsSel = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_REGION: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColRegion = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_DECORATION: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColDecor = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_BLOCKED: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColBlocked = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_WAYPOINTS: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColWaypoints = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_COLOR_SCALE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &ar, &ag, &ab, &aa); + _editorColScale = BYTETORGBA(ar, ag, ab, aa); + break; + + case TOKEN_EDITOR_SHOW_REGIONS: + parser.scanStr((char *)params, "%b", &_editorShowRegions); + break; + + case TOKEN_EDITOR_SHOW_BLOCKED: + parser.scanStr((char *)params, "%b", &_editorShowBlocked); + break; + + case TOKEN_EDITOR_SHOW_DECORATION: + parser.scanStr((char *)params, "%b", &_editorShowDecor); + break; + + case TOKEN_EDITOR_SHOW_ENTITIES: + parser.scanStr((char *)params, "%b", &_editorShowEntities); + break; + + case TOKEN_EDITOR_SHOW_SCALE: + parser.scanStr((char *)params, "%b", &_editorShowScale); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_VIEWPORT: { + Rect32 rc; + parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); + } + + case TOKEN_PERSISTENT_STATE: + parser.scanStr((char *)params, "%b", &_persistentState); + break; + + case TOKEN_PERSISTENT_STATE_SPRITES: + parser.scanStr((char *)params, "%b", &_persistentStateSprites); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SCENE definition"); + return STATUS_FAILED; + } + + if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); + + + sortScaleLevels(); + sortRotLevels(); + + _initialized = true; + + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::traverseNodes(bool doUpdate) { + if (!_initialized) return STATUS_OK; + + int j, k; + CAdGame *adGame = (CAdGame *)_gameRef; + + + ////////////////////////////////////////////////////////////////////////// + // prepare viewport + bool PopViewport = false; + if (_viewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(_viewport); + PopViewport = true; + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + _gameRef->pushViewport(adGame->_sceneViewport); + PopViewport = true; + } + + + ////////////////////////////////////////////////////////////////////////// + // *** adjust scroll offset + if (doUpdate) { + /* + if (_autoScroll && _gameRef->_mainObject != NULL) + { + ScrollToObject(_gameRef->_mainObject); + } + */ + + if (_autoScroll) { + // adjust horizontal scroll + if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { + _lastTimeH = _gameRef->_timer; + if (_offsetLeft < _targetOffsetLeft) { + _offsetLeft += _scrollPixelsH; + _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); + } else if (_offsetLeft > _targetOffsetLeft) { + _offsetLeft -= _scrollPixelsH; + _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); + } + } + + // adjust vertical scroll + if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { + _lastTimeV = _gameRef->_timer; + if (_offsetTop < _targetOffsetTop) { + _offsetTop += _scrollPixelsV; + _offsetTop = MIN(_offsetTop, _targetOffsetTop); + } else if (_offsetTop > _targetOffsetTop) { + _offsetTop -= _scrollPixelsV; + _offsetTop = MAX(_offsetTop, _targetOffsetTop); + } + } + + if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; + } else _ready = true; // not scrolling, i.e. always ready + } + + + + + ////////////////////////////////////////////////////////////////////////// + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + int viewportX, viewportY; + getViewportOffset(&viewportX, &viewportY); + + int scrollableX = _width - viewportWidth; + int scrollableY = _height - viewportHeight; + + double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); + double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); + + int origX, origY; + _gameRef->getOffset(&origX, &origY); + + + + ////////////////////////////////////////////////////////////////////////// + // *** display/update everything + _gameRef->_renderer->setup2D(); + + // for each layer + /* int MainOffsetX = 0; */ + /* int MainOffsetY = 0; */ + + for (j = 0; j < _layers.getSize(); j++) { + if (!_layers[j]->_active) continue; + + // make layer exclusive + if (!doUpdate) { + if (_layers[j]->_closeUp && !_gameRef->_editorMode) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + _shieldWindow->display(); + } + } + } + + if (_paralaxScrolling) { + int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX); + int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY); + _gameRef->setOffset(offsetX, offsetY); + + _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + + //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX); + } else { + _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY); + + _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f; + _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f; + } + + + // for each node + for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { + CAdSceneNode *node = _layers[j]->_nodes[k]; + switch (node->_type) { + case OBJECT_ENTITY: + if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { + _gameRef->_renderer->setup2D(); + + if (doUpdate) node->_entity->update(); + else node->_entity->display(); + } + break; + + case OBJECT_REGION: { + if (node->_region->_blocked) break; + if (node->_region->_decoration) break; + + if (!doUpdate) displayRegionContent(node->_region); + } + break; + default: + error("AdScene::TraverseNodes - Unhandled enum"); + break; + } // switch + } // each node + + // display/update all objects which are off-regions + if (_layers[j]->_main) { + if (doUpdate) { + updateFreeObjects(); + } else { + displayRegionContent(NULL); + } + } + } // each layer + + + // restore state + _gameRef->setOffset(origX, origY); + _gameRef->_renderer->setup2D(); + + // display/update fader + if (_fader) { + if (doUpdate) _fader->update(); + else _fader->display(); + } + + if (PopViewport) _gameRef->popViewport(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::display() { + return traverseNodes(false); +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::updateFreeObjects() { + CAdGame *adGame = (CAdGame *)_gameRef; + bool is3DSet; + + // *** update all active objects + is3DSet = false; + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (!adGame->_objects[i]->_active) continue; + + adGame->_objects[i]->update(); + adGame->_objects[i]->_drawn = false; + } + + + for (int i = 0; i < _objects.getSize(); i++) { + if (!_objects[i]->_active) continue; + + _objects[i]->update(); + _objects[i]->_drawn = false; + } + + + if (_autoScroll && _gameRef->_mainObject != NULL) { + scrollToObject(_gameRef->_mainObject); + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { + CAdGame *adGame = (CAdGame *)_gameRef; + CBArray objects; + CAdObject *obj; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.add(obj); + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.add(obj); + } + } + + // sort by _posY + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); + + // display them + for (int i = 0; i < objects.getSize(); i++) { + obj = objects[i]; + + if (display3DOnly && !obj->_is3D) continue; + + _gameRef->_renderer->setup2D(); + + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + obj->_drawn = true; + } + + + // display design only objects + if (!display3DOnly) { + if (_gameRef->_editorMode && region == NULL) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CAdScene::compareObjs(const void *obj1, const void *obj2) { + CAdObject *object1 = *(CAdObject **)obj1; + CAdObject *object2 = *(CAdObject **)obj2; + + if (object1->_posY < object2->_posY) return -1; + else if (object1->_posY > object2->_posY) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::displayRegionContentOld(CAdRegion *region) { + CAdGame *adGame = (CAdGame *)_gameRef; + CAdObject *obj; + + // display all objects in region sorted by _posY + do { + obj = NULL; + int minY = INT_MAX; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + obj = adGame->_objects[i]; + minY = adGame->_objects[i]->_posY; + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + obj = _objects[i]; + minY = _objects[i]->_posY; + } + } + + + if (obj != NULL) { + _gameRef->_renderer->setup2D(); + + if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + obj->_drawn = true; + } + } while (obj != NULL); + + + // design only objects + if (_gameRef->_editorMode && region == NULL) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_active && _objects[i]->_editorOnly) { + _objects[i]->display(); + _objects[i]->_drawn = true; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::update() { + return traverseNodes(true); +} + +////////////////////////////////////////////////////////////////////////// +void CAdScene::scrollTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + int origOffsetLeft = _targetOffsetLeft; + int origOffsetTop = _targetOffsetTop; + + _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); + _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); + + _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); + _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); + + + if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { + if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; + if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; + //_targetOffsetTop = 0; + } + + _ready = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::scrollToObject(CBObject *object) { + if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::skipToObject(CBObject *object) { + if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::skipTo(int offsetX, int offsetY) { + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetLeft = MAX(0, offsetX - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); + + _offsetTop = MAX(0, offsetY - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); + + _targetOffsetLeft = _offsetLeft; + _targetOffsetTop = _offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LoadActor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LoadActor") == 0) { + stack->correctParams(1); + CAdActor *act = new CAdActor(_gameRef); + if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { + addObject(act); + stack->pushNative(act, true); + } else { + delete act; + act = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadEntity") == 0) { + stack->correctParams(1); + CAdEntity *ent = new CAdEntity(_gameRef); + if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { + addObject(ent); + stack->pushNative(ent, true); + } else { + delete ent; + ent = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdEntity *ent = new CAdEntity(_gameRef); + addObject(ent); + if (!val->isNULL()) ent->setName(val->getString()); + stack->pushNative(ent, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CAdObject *obj = (CAdObject *)val->getNative(); + removeObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + if (val1->isNative()) { + skipToObject((CBObject *)val1->getNative()); + } else { + skipTo(val1->getInt(), val2->getInt()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollTo / ScrollToAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { + stack->correctParams(2); + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + if (val1->isNative()) { + scrollToObject((CBObject *)val1->getNative()); + } else { + scrollTo(val1->getInt(), val2->getInt()); + } + if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int layer = val->getInt(); + if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); + else stack->pushNative(_layers[layer], true); + } else { + const char *LayerName = val->getString(); + bool LayerFound = false; + for (int i = 0; i < _layers.getSize(); i++) { + if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { + stack->pushNative(_layers[i], true); + LayerFound = true; + break; + } + } + if (!LayerFound) stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaypointGroup + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaypointGroup") == 0) { + stack->correctParams(1); + int group = stack->pop()->getInt(); + if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); + else stack->pushNative(_waypointGroups[group], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetNode") == 0) { + stack->correctParams(1); + const char *nodeName = stack->pop()->getString(); + + CBObject *node = getNodeByName(nodeName); + if (node) stack->pushNative((CBScriptable *)node, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFreeNode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFreeNode") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdObject *ret = NULL; + if (val->isInt()) { + int index = val->getInt(); + if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; + } else { + const char *nodeName = val->getString(); + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { + ret = _objects[i]; + break; + } + } + } + if (ret) stack->pushNative(ret, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRegionAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRegionAt") == 0) { + stack->correctParams(3); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + bool includeDecors = false; + if (!val->isNULL()) includeDecors = val->getBool(); + + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { + if (node->_region->_decoration && !includeDecors) continue; + + stack->pushNative(node->_region, true); + return STATUS_OK; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsBlockedAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsBlockedAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushBool(isBlockedAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsWalkableAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsWalkableAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushBool(isWalkableAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetScaleAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetScaleAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushFloat(getZoomAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetRotationAt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRotationAt") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + stack->pushFloat(getRotationAt(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScrolling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScrolling") == 0) { + stack->correctParams(0); + bool ret = false; + if (_autoScroll) { + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; + } + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); + if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); + if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsPointInViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsPointInViewport") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + stack->pushBool(pointInViewport(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetViewport + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetViewport") == 0) { + stack->correctParams(4); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + int width = stack->pop()->getInt(); + int height = stack->pop()->getInt(); + + if (width <= 0) width = _gameRef->_renderer->_width; + if (height <= 0) height = _gameRef->_renderer->_height; + + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) _viewport->setRect(x, y, x + width, y + height); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdLayer *layer = new CAdLayer(_gameRef); + if (!val->isNULL()) layer->setName(val->getString()); + if (_mainLayer) { + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; + } + _layers.add(layer); + _gameRef->registerObject(layer); + + stack->pushNative(layer, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertLayer") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + CScValue *val = stack->pop(); + + CAdLayer *layer = new CAdLayer(_gameRef); + if (!val->isNULL()) layer->setName(val->getString()); + if (_mainLayer) { + layer->_width = _mainLayer->_width; + layer->_height = _mainLayer->_height; + } + if (index < 0) index = 0; + if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); + else _layers.add(layer); + + _gameRef->registerObject(layer); + + stack->pushNative(layer, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteLayer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteLayer") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CAdLayer *toDelete = NULL; + if (val->isNative()) { + CBScriptable *temp = val->getNative(); + for (int i = 0; i < _layers.getSize(); i++) { + if (_layers[i] == temp) { + toDelete = _layers[i]; + break; + } + } + } else { + int index = val->getInt(); + if (index >= 0 && index < _layers.getSize()) { + toDelete = _layers[index]; + } + } + if (toDelete == NULL) { + stack->pushBool(false); + return STATUS_OK; + } + + if (toDelete->_main) { + script->runtimeError("Scene.DeleteLayer - cannot delete main scene layer"); + stack->pushBool(false); + return STATUS_OK; + } + + for (int i = 0; i < _layers.getSize(); i++) { + if (_layers[i] == toDelete) { + _layers.removeAt(i); + _gameRef->unregisterObject(toDelete); + break; + } + } + stack->pushBool(true); + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdScene::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("scene"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumLayers (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLayers") == 0) { + _scValue->setInt(_layers.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWaypointGroups (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumWaypointGroups") == 0) { + _scValue->setInt(_waypointGroups.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainLayer (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainLayer") == 0) { + if (_mainLayer) _scValue->setNative(_mainLayer, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFreeNodes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFreeNodes") == 0) { + _scValue->setInt(_objects.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + int viewportX; + getViewportOffset(&viewportX); + + _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + int viewportY; + getViewportOffset(NULL, &viewportY); + + _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoScroll") == 0) { + _scValue->setBool(_autoScroll); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentState") == 0) { + _scValue->setBool(_persistentState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentStateSprites") == 0) { + _scValue->setBool(_persistentStateSprites); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsX") == 0) { + _scValue->setInt(_scrollPixelsH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsY") == 0) { + _scValue->setInt(_scrollPixelsV); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedX") == 0) { + _scValue->setInt(_scrollTimeH); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedY") == 0) { + _scValue->setInt(_scrollTimeV); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetX") == 0) { + _scValue->setInt(_offsetLeft); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetY") == 0) { + _scValue->setInt(_offsetTop); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + if (_mainLayer) _scValue->setInt(_mainLayer->_width); + else _scValue->setInt(0); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + if (_mainLayer) _scValue->setInt(_mainLayer->_height); + else _scValue->setInt(0); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoScroll + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoScroll") == 0) { + _autoScroll = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentState") == 0) { + _persistentState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PersistentStateSprites + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PersistentStateSprites") == 0) { + _persistentStateSprites = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsX") == 0) { + _scrollPixelsH = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollPixelsY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollPixelsY") == 0) { + _scrollPixelsV = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedX") == 0) { + _scrollTimeH = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScrollSpeedY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScrollSpeedY") == 0) { + _scrollTimeV = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetX") == 0) { + _offsetLeft = value->getInt(); + + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); + _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); + _targetOffsetLeft = _offsetLeft; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OffsetY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OffsetY") == 0) { + _offsetTop = value->getInt(); + + int viewportWidth, viewportHeight; + getViewportSize(&viewportWidth, &viewportHeight); + + _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); + _offsetTop = MIN(_offsetTop, _height - viewportHeight); + _targetOffsetTop = _offsetTop; + + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdScene::scToString() { + return "[scene object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::addObject(CAdObject *object) { + _objects.add(object); + return _gameRef->registerObject(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::removeObject(CAdObject *object) { + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i] == object) { + _objects.removeAt(i); + return _gameRef->unregisterObject(object); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { + int i; + + buffer->putTextIndent(indent, "SCENE {\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + if (_persistentState) + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + + if (!_persistentStateSprites) + buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // properties + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + // viewport + if (_viewport) { + Rect32 *rc = _viewport->getRect(); + buffer->putTextIndent(indent + 2, "VIEWPORT { %d, %d, %d, %d }\n", rc->left, rc->top, rc->right, rc->bottom); + } + + + + // editor settings + buffer->putTextIndent(indent + 2, "; ----- editor settings\n"); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_H=%d\n", _editorMarginH); + buffer->putTextIndent(indent + 2, "EDITOR_MARGIN_V=%d\n", _editorMarginV); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_FRAME { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColFrame), RGBCOLGetG(_editorColFrame), RGBCOLGetB(_editorColFrame), RGBCOLGetA(_editorColFrame)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntitySel), RGBCOLGetG(_editorColEntitySel), RGBCOLGetB(_editorColEntitySel), RGBCOLGetA(_editorColEntitySel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegionSel), RGBCOLGetG(_editorColRegionSel), RGBCOLGetB(_editorColRegionSel), RGBCOLGetA(_editorColRegionSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlockedSel), RGBCOLGetG(_editorColBlockedSel), RGBCOLGetB(_editorColBlockedSel), RGBCOLGetA(_editorColBlockedSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecorSel), RGBCOLGetG(_editorColDecorSel), RGBCOLGetB(_editorColDecorSel), RGBCOLGetA(_editorColDecorSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS_SEL { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypointsSel), RGBCOLGetG(_editorColWaypointsSel), RGBCOLGetB(_editorColWaypointsSel), RGBCOLGetA(_editorColWaypointsSel)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_ENTITY { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColEntity), RGBCOLGetG(_editorColEntity), RGBCOLGetB(_editorColEntity), RGBCOLGetA(_editorColEntity)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_REGION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColRegion), RGBCOLGetG(_editorColRegion), RGBCOLGetB(_editorColRegion), RGBCOLGetA(_editorColRegion)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_DECORATION { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColDecor), RGBCOLGetG(_editorColDecor), RGBCOLGetB(_editorColDecor), RGBCOLGetA(_editorColDecor)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_BLOCKED { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColBlocked), RGBCOLGetG(_editorColBlocked), RGBCOLGetB(_editorColBlocked), RGBCOLGetA(_editorColBlocked)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_WAYPOINTS { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColWaypoints), RGBCOLGetG(_editorColWaypoints), RGBCOLGetB(_editorColWaypoints), RGBCOLGetA(_editorColWaypoints)); + buffer->putTextIndent(indent + 2, "EDITOR_COLOR_SCALE { %d,%d,%d,%d }\n", RGBCOLGetR(_editorColScale), RGBCOLGetG(_editorColScale), RGBCOLGetB(_editorColScale), RGBCOLGetA(_editorColScale)); + + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_REGIONS=%s\n", _editorShowRegions ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_BLOCKED=%s\n", _editorShowBlocked ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_DECORATION=%s\n", _editorShowDecor ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_ENTITIES=%s\n", _editorShowEntities ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SHOW_SCALE=%s\n", _editorShowScale ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + CBBase::saveAsText(buffer, indent + 2); + + // waypoints + buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); + for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent + 2, "\n"); + + // layers + buffer->putTextIndent(indent + 2, "; ----- layers\n"); + for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); + + // scale levels + buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); + for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); + + // rotation levels + buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); + for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent + 2, "\n"); + + // free entities + buffer->putTextIndent(indent + 2, "; ----- free entities\n"); + for (i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + _objects[i]->saveAsText(buffer, indent + 2); + + } + } + + + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::sortScaleLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { + if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { + CAdScaleLevel *sl = _scaleLevels[i]; + _scaleLevels[i] = _scaleLevels[i + 1]; + _scaleLevels[i + 1] = sl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::sortRotLevels() { + bool changed; + do { + changed = false; + for (int i = 0; i < _rotLevels.getSize() - 1; i++) { + if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { + CAdRotLevel *rl = _rotLevels[i]; + _rotLevels[i] = _rotLevels[i + 1]; + _rotLevels[i + 1] = rl; + + changed = true; + } + } + + } while (changed); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getScaleAt(int Y) { + CAdScaleLevel *prev = NULL; + CAdScaleLevel *next = NULL; + + for (int i = 0; i < _scaleLevels.getSize(); i++) { + /* CAdScaleLevel *xxx = _scaleLevels[i];*/ + /* int j = _scaleLevels.getSize(); */ + if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; + else { + next = _scaleLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 100; + + int delta_y = next->_posY - prev->_posY; + float delta_scale = next->_scale - prev->_scale; + Y -= prev->_posY; + + float percent = (float)Y / ((float)delta_y / 100.0f); + return prev->_scale + delta_scale / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_autoScroll)); + persistMgr->transfer(TMEMBER(_editorColBlocked)); + persistMgr->transfer(TMEMBER(_editorColBlockedSel)); + persistMgr->transfer(TMEMBER(_editorColDecor)); + persistMgr->transfer(TMEMBER(_editorColDecorSel)); + persistMgr->transfer(TMEMBER(_editorColEntity)); + persistMgr->transfer(TMEMBER(_editorColEntitySel)); + persistMgr->transfer(TMEMBER(_editorColFrame)); + persistMgr->transfer(TMEMBER(_editorColRegion)); + persistMgr->transfer(TMEMBER(_editorColRegionSel)); + persistMgr->transfer(TMEMBER(_editorColScale)); + persistMgr->transfer(TMEMBER(_editorColWaypoints)); + persistMgr->transfer(TMEMBER(_editorColWaypointsSel)); + persistMgr->transfer(TMEMBER(_editorMarginH)); + persistMgr->transfer(TMEMBER(_editorMarginV)); + persistMgr->transfer(TMEMBER(_editorShowBlocked)); + persistMgr->transfer(TMEMBER(_editorShowDecor)); + persistMgr->transfer(TMEMBER(_editorShowEntities)); + persistMgr->transfer(TMEMBER(_editorShowRegions)); + persistMgr->transfer(TMEMBER(_editorShowScale)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_initialized)); + persistMgr->transfer(TMEMBER(_lastTimeH)); + persistMgr->transfer(TMEMBER(_lastTimeV)); + _layers.persist(persistMgr); + persistMgr->transfer(TMEMBER(_mainLayer)); + _objects.persist(persistMgr); + persistMgr->transfer(TMEMBER(_offsetLeft)); + persistMgr->transfer(TMEMBER(_offsetTop)); + persistMgr->transfer(TMEMBER(_paralaxScrolling)); + persistMgr->transfer(TMEMBER(_persistentState)); + persistMgr->transfer(TMEMBER(_persistentStateSprites)); + persistMgr->transfer(TMEMBER(_pfMaxTime)); + _pfPath.persist(persistMgr); + persistMgr->transfer(TMEMBER(_pfPointsNum)); + persistMgr->transfer(TMEMBER(_pfReady)); + persistMgr->transfer(TMEMBER(_pfRequester)); + persistMgr->transfer(TMEMBER(_pfTarget)); + persistMgr->transfer(TMEMBER(_pfTargetPath)); + _rotLevels.persist(persistMgr); + _scaleLevels.persist(persistMgr); + persistMgr->transfer(TMEMBER(_scrollPixelsH)); + persistMgr->transfer(TMEMBER(_scrollPixelsV)); + persistMgr->transfer(TMEMBER(_scrollTimeH)); + persistMgr->transfer(TMEMBER(_scrollTimeV)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER(_targetOffsetLeft)); + persistMgr->transfer(TMEMBER(_targetOffsetTop)); + _waypointGroups.persist(persistMgr); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::afterLoad() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { + double xStep, yStep, x, y; + int xLength, yLength, xCount, yCount; + int x1, y1, x2, y2; + + x1 = *targetX; + y1 = *targetY; + x2 = startX; + y2 = startY; + + + xLength = abs(x2 - x1); + yLength = abs(y2 - y1); + + if (xLength > yLength) { + /* + if (X1 > X2) + { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); + y = y1; + + for (xCount = x1; xCount < x2; xCount++) { + if (isWalkableAt(xCount, (int)y, checkFreeObjects, requester)) { + *targetX = xCount; + *targetY = (int)y; + return STATUS_OK; + } + y += yStep; + } + } else { + /* + if (Y1 > Y2) { + Swap(&X1, &X2); + Swap(&Y1, &Y2); + } + */ + + xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); + x = x1; + + for (yCount = y1; yCount < y2; yCount++) { + if (isWalkableAt((int)x, yCount, checkFreeObjects, requester)) { + *targetX = (int)x; + *targetY = yCount; + return STATUS_OK; + } + x += xStep; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { + int x = *argX; + int y = *argY; + + if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { + return STATUS_OK; + } + + // right + int length_right = 0; + bool found_right = false; + for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { + found_right = true; + break; + } + } + + // left + int length_left = 0; + bool found_left = false; + for (x = *argX, y = *argY; x >= 0; x--, length_left--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { + found_left = true; + break; + } + } + + // up + int length_up = 0; + bool found_up = false; + for (x = *argX, y = *argY; y >= 0; y--, length_up--) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { + found_up = true; + break; + } + } + + // down + int length_down = 0; + bool found_down = false; + for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { + if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { + found_down = true; + break; + } + } + + if (!found_left && !found_right && !found_up && !found_down) { + return STATUS_OK; + } + + int OffsetX = INT_MAX, OffsetY = INT_MAX; + + if (found_left && found_right) { + if (abs(length_left) < abs(length_right)) OffsetX = length_left; + else OffsetX = length_right; + } else if (found_left) OffsetX = length_left; + else if (found_right) OffsetX = length_right; + + if (found_up && found_down) { + if (abs(length_up) < abs(length_down)) OffsetY = length_up; + else OffsetY = length_down; + } else if (found_up) OffsetY = length_up; + else if (found_down) OffsetY = length_down; + + if (abs(OffsetX) < abs(OffsetY)) + *argX = *argX + OffsetX; + else + *argY = *argY + OffsetY; + + if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfPointsStart() { + _pfPointsNum = 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::pfPointsAdd(int x, int y, int distance) { + if (_pfPointsNum >= _pfPath.getSize()) { + _pfPath.add(new CAdPathPoint(x, y, distance)); + } else { + _pfPath[_pfPointsNum]->x = x; + _pfPath[_pfPointsNum]->y = y; + _pfPath[_pfPointsNum]->_distance = distance; + _pfPath[_pfPointsNum]->_marked = false; + _pfPath[_pfPointsNum]->_origin = NULL; + } + + _pfPointsNum++; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { + if (offsetX) *offsetX = _viewport->_offsetX; + if (offsetY) *offsetY = _viewport->_offsetY; + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; + if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getViewportSize(int *width, int *height) { + CAdGame *adGame = (CAdGame *)_gameRef; + if (_viewport && !_gameRef->_editorMode) { + if (width) *width = _viewport->getWidth(); + if (height) *height = _viewport->getHeight(); + } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { + if (width) *width = adGame->_sceneViewport->getWidth(); + if (height) *height = adGame->_sceneViewport->getHeight(); + } else { + if (width) *width = _gameRef->_renderer->_width; + if (height) *height = _gameRef->_renderer->_height; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getOffsetLeft() { + int viewportX; + getViewportOffset(&viewportX); + + return _offsetLeft - viewportX; +} + + +////////////////////////////////////////////////////////////////////////// +int CAdScene::getOffsetTop() { + int viewportY; + getViewportOffset(NULL, &viewportY); + + return _offsetTop - viewportY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::pointInViewport(int x, int y) { + int left, top, width, height; + + getViewportOffset(&left, &top); + getViewportSize(&width, &height); + + return x >= left && x <= left + width && y >= top && y <= top + height; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdScene::setOffset(int offsetLeft, int offsetTop) { + _offsetLeft = offsetLeft; + _offsetTop = offsetTop; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getNodeByName(const char *name) { + CBObject *ret = NULL; + + // dependent objects + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || + (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { + switch (node->_type) { + case OBJECT_ENTITY: + ret = node->_entity; + break; + case OBJECT_REGION: + ret = node->_region; + break; + default: + ret = NULL; + } + return ret; + } + } + } + + // free entities + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { + return _objects[i]; + } + } + + // waypoint groups + for (int i = 0; i < _waypointGroups.getSize(); i++) { + if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { + return _waypointGroups[i]; + } + } + + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::saveState() { + return persistState(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::loadState() { + return persistState(false); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::persistState(bool saving) { + if (!_persistentState) return STATUS_OK; + + CAdGame *adGame = (CAdGame *)_gameRef; + CAdSceneState *state = adGame->getSceneState(_filename, saving); + if (!state) return STATUS_OK; + + CAdNodeState *nodeState; + + // dependent objects + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + CAdSceneNode *node = layer->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: + if (!node->_entity->_saveState) continue; + nodeState = state->getNodeState(node->_entity->_name, saving); + if (nodeState) { + nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); + //if(Saving) NodeState->_active = node->_entity->_active; + //else node->_entity->_active = NodeState->_active; + } + break; + case OBJECT_REGION: + if (!node->_region->_saveState) continue; + nodeState = state->getNodeState(node->_region->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = node->_region->_active; + else node->_region->_active = nodeState->_active; + } + break; + default: + warning("CAdScene::PersistState - unhandled enum"); + break; + } + } + } + + // free entities + for (int i = 0; i < _objects.getSize(); i++) { + if (!_objects[i]->_saveState) continue; + if (_objects[i]->_type == OBJECT_ENTITY) { + nodeState = state->getNodeState(_objects[i]->_name, saving); + if (nodeState) { + nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); + //if(Saving) NodeState->_active = _objects[i]->_active; + //else _objects[i]->_active = NodeState->_active; + } + } + } + + // waypoint groups + for (int i = 0; i < _waypointGroups.getSize(); i++) { + nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); + if (nodeState) { + if (saving) nodeState->_active = _waypointGroups[i]->_active; + else _waypointGroups[i]->_active = nodeState->_active; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CAdScene::getRotationAt(int x, int y) { + CAdRotLevel *prev = NULL; + CAdRotLevel *next = NULL; + + for (int i = 0; i < _rotLevels.getSize(); i++) { + /* CAdRotLevel *xxx = _rotLevels[i]; + int j = _rotLevels.getSize();*/ + if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; + else { + next = _rotLevels[i]; + break; + } + } + + if (prev == NULL || next == NULL) return 0; + + int delta_x = next->_posX - prev->_posX; + float delta_rot = next->_rotation - prev->_rotation; + x -= prev->_posX; + + float percent = (float)x / ((float)delta_x / 100.0f); + return prev->_rotation + delta_rot / 100 * percent; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::handleItemAssociations(const char *itemName, bool show) { + for (int i = 0; i < _layers.getSize(); i++) { + CAdLayer *layer = _layers[i]; + for (int j = 0; j < layer->_nodes.getSize(); j++) { + if (layer->_nodes[j]->_type == OBJECT_ENTITY) { + CAdEntity *ent = layer->_nodes[j]->_entity; + + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + } + } + } + + for (int i = 0; i < _objects.getSize(); i++) { + if (_objects[i]->_type == OBJECT_ENTITY) { + CAdEntity *ent = (CAdEntity *)_objects[i]; + if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { + int numUsed = 0; + if (_mainLayer) { + for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + CAdSceneNode *node = _mainLayer->_nodes[i]; + if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { + if (numUsed < numRegions - 1) { + regionList[numUsed] = node->_region; + numUsed++; + } else break; + } + } + } + for (int i = numUsed; i < numRegions; i++) { + regionList[i] = NULL; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::restoreDeviceObjects() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { + CBArray objects; + getSceneObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = 0; i < objects.getSize(); i++) { + if (objects[i] == currObject) { + if (i < objects.getSize() - 1) return objects[i + 1]; + else break; + } + } + } + return objects[0]; + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { + CBArray objects; + getSceneObjects(objects, true); + + if (objects.getSize() == 0) return NULL; + else { + if (currObject != NULL) { + for (int i = objects.getSize() - 1; i >= 0; i--) { + if (objects[i] == currObject) { + if (i > 0) return objects[i - 1]; + else break; + } + } + } + return objects[objects.getSize() - 1]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _layers.getSize(); i++) { + // close-up layer -> remove everything below it + if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); + + + for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { + CAdSceneNode *node = _layers[i]->_nodes[j]; + switch (node->_type) { + case OBJECT_ENTITY: { + CAdEntity *ent = node->_entity; + if (ent->_active && (ent->_registrable || !interactiveOnly)) + objects.add(ent); + } + break; + + case OBJECT_REGION: { + CBArray regionObj; + getRegionObjects(node->_region, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.getSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) objects.add(regionObj[newIndex]); + } + //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); + } + break; + default: + warning("CAdScene::GetSceneObjects - Unhandled enum"); + break; + } + } + } + + // objects outside any region + CBArray regionObj; + getRegionObjects(NULL, regionObj, interactiveOnly); + for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + bool found = false; + for (int old = 0; old < objects.getSize(); old++) { + if (objects[old] == regionObj[newIndex]) { + found = true; + break; + } + } + if (!found) objects.add(regionObj[newIndex]); + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { + CAdGame *adGame = (CAdGame *)_gameRef; + CAdObject *obj; + + // global objects + for (int i = 0; i < adGame->_objects.getSize(); i++) { + obj = adGame->_objects[i]; + if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; + + objects.add(obj); + } + } + + // scene objects + for (int i = 0; i < _objects.getSize(); i++) { + obj = _objects[i]; + if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (interactiveOnly && !obj->_registrable) continue; + + objects.add(obj); + } + } + + // sort by _posY + qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h new file mode 100644 index 0000000000..ab62a4a7fc --- /dev/null +++ b/engines/wintermute/ad/ad_scene.h @@ -0,0 +1,181 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENE_H +#define WINTERMUTE_ADSCENE_H + +#include "engines/wintermute/base/base_fader.h" + +namespace WinterMute { + +class CUIWindow; +class CAdObject; +class CAdRegion; +class CBViewport; +class CAdLayer; +class CBPoint; +class CAdWaypointGroup; +class CAdPath; +class CAdScaleLevel; +class CAdRotLevel; +class CAdPathPoint; +class CAdScene : public CBObject { +public: + + CBObject *getNextAccessObject(CBObject *CurrObject); + CBObject *getPrevAccessObject(CBObject *CurrObject); + bool getSceneObjects(CBArray &Objects, bool InteractiveOnly); + bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + + bool afterLoad(); + + bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + bool handleItemAssociations(const char *ItemName, bool Show); + CUIWindow *_shieldWindow; + float getRotationAt(int X, int Y); + bool loadState(); + bool saveState(); + bool _persistentState; + bool _persistentStateSprites; + CBObject *getNodeByName(const char *name); + void setOffset(int OffsetLeft, int OffsetTop); + bool pointInViewport(int X, int Y); + int getOffsetTop(); + int getOffsetLeft(); + bool getViewportSize(int *Width = NULL, int *Height = NULL); + bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + CBViewport *_viewport; + CBFader *_fader; + int _pfPointsNum; + void pfPointsAdd(int X, int Y, int Distance); + void pfPointsStart(); + bool _initialized; + bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); + DECLARE_PERSISTENT(CAdScene, CBObject) + bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); + bool displayRegionContentOld(CAdRegion *Region = NULL); + static int compareObjs(const void *Obj1, const void *Obj2); + + bool updateFreeObjects(); + bool traverseNodes(bool Update = false); + float getScaleAt(int Y); + bool sortScaleLevels(); + bool sortRotLevels(); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); + bool _paralaxScrolling; + void skipTo(int OffsetX, int OffsetY); + void setDefaults(); + void cleanup(); + void skipToObject(CBObject *Object); + void scrollToObject(CBObject *Object); + void scrollTo(int OffsetX, int OffsetY); + virtual bool update(); + bool _autoScroll; + int _targetOffsetTop; + int _targetOffsetLeft; + + int _scrollPixelsV; + uint32 _scrollTimeV; + uint32 _lastTimeV; + + int _scrollPixelsH; + uint32 _scrollTimeH; + uint32 _lastTimeH; + + virtual bool display(); + uint32 _pfMaxTime; + bool initLoop(); + void pathFinderStep(); + bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); + CAdLayer *_mainLayer; + float getZoomAt(int X, int Y); + bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); + CAdScene(CBGame *inGame); + virtual ~CAdScene(); + CBArray _layers; + CBArray _objects; + CBArray _waypointGroups; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + int _width; + int _height; + bool addObject(CAdObject *Object); + bool removeObject(CAdObject *Object); + int _editorMarginH; + int _editorMarginV; + uint32 _editorColFrame; + uint32 _editorColEntity; + uint32 _editorColRegion; + uint32 _editorColBlocked; + uint32 _editorColWaypoints; + uint32 _editorColEntitySel; + uint32 _editorColRegionSel; + uint32 _editorColBlockedSel; + uint32 _editorColWaypointsSel; + uint32 _editorColScale; + uint32 _editorColDecor; + uint32 _editorColDecorSel; + + bool _editorShowRegions; + bool _editorShowBlocked; + bool _editorShowDecor; + bool _editorShowEntities; + bool _editorShowScale; + CBArray _scaleLevels; + CBArray _rotLevels; + + virtual bool restoreDeviceObjects(); + int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + bool persistState(bool Saving = true); + void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + bool _pfReady; + CBPoint *_pfTarget; + CAdPath *_pfTargetPath; + CBObject *_pfRequester; + CBArray _pfPath; + + int _offsetTop; + int _offsetLeft; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp new file mode 100644 index 0000000000..da7082105f --- /dev/null +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_scene_node.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { + _type = OBJECT_NONE; + _region = NULL; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneNode::~CAdSceneNode() { + _gameRef->unregisterObject(_region); + _region = NULL; + + _gameRef->unregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::setEntity(CAdEntity *entity) { + _type = OBJECT_ENTITY; + _entity = entity; + return _gameRef->registerObject(entity); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::setRegion(CAdRegion *region) { + _type = OBJECT_REGION; + _region = region; + return _gameRef->registerObject(region); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_entity)); + persistMgr->transfer(TMEMBER(_region)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_scene_node.h b/engines/wintermute/ad/ad_scene_node.h new file mode 100644 index 0000000000..1c25f91a2d --- /dev/null +++ b/engines/wintermute/ad/ad_scene_node.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENENODE_H +#define WINTERMUTE_ADSCENENODE_H + + +#include "engines/wintermute/ad/ad_types.h" // Added by ClassView +#include "engines/wintermute/ad/ad_region.h" // Added by ClassView +#include "engines/wintermute/ad/ad_entity.h" + +namespace WinterMute { + +class CAdSceneNode : public CBObject { +public: + DECLARE_PERSISTENT(CAdSceneNode, CBObject) + bool setRegion(CAdRegion *region); + bool setEntity(CAdEntity *entity); + CAdEntity *_entity; + CAdRegion *_region; + TObjectType _type; + CAdSceneNode(CBGame *inGame); + virtual ~CAdSceneNode(); + +}; + +} + +#endif diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp new file mode 100644 index 0000000000..2ac36054a5 --- /dev/null +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/ad/ad_scene_state.h" +#include "engines/wintermute/ad/ad_node_state.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSceneState, false) + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSceneState::~CAdSceneState() { + delete[] _filename; + _filename = NULL; + + for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; + _nodeStates.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSceneState::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_filename)); + _nodeStates.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSceneState::setFilename(const char *filename) { + delete[] _filename; + _filename = new char [strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { + for (int i = 0; i < _nodeStates.getSize(); i++) { + if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; + } + + if (saving) { + CAdNodeState *ret = new CAdNodeState(_gameRef); + ret->setName(name); + _nodeStates.add(ret); + + return ret; + } else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h new file mode 100644 index 0000000000..6df20e0578 --- /dev/null +++ b/engines/wintermute/ad/ad_scene_state.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSCENESTATE_H +#define WINTERMUTE_ADSCENESTATE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CAdNodeState; +class CAdSceneState : public CBBase { +public: + CAdNodeState *getNodeState(char *name, bool saving); + void setFilename(const char *filename); + DECLARE_PERSISTENT(CAdSceneState, CBBase) + CAdSceneState(CBGame *inGame); + virtual ~CAdSceneState(); + char *_filename; + CBArray _nodeStates; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp new file mode 100644 index 0000000000..2607993aa0 --- /dev/null +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -0,0 +1,317 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/ad/ad_talk_def.h" +#include "engines/wintermute/ad/ad_talk_node.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSentence, false) + +////////////////////////////////////////////////////////////////////////// +CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { + _text = NULL; + _stances = NULL; + _tempStance = NULL; + + _duration = 0; + _startTime = 0; + _currentStance = 0; + + _font = NULL; + + _pos.x = _pos.y = 0; + _width = _gameRef->_renderer->_width; + + _align = (TTextAlign)TAL_CENTER; + + _sound = NULL; + _soundStarted = false; + + _talkDef = NULL; + _currentSprite = NULL; + _currentSkelAnim = NULL; + _fixedPos = false; + _freezable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSentence::~CAdSentence() { + delete _sound; + delete[] _text; + delete[] _stances; + delete[] _tempStance; + delete _talkDef; + _sound = NULL; + _text = NULL; + _stances = NULL; + _tempStance = NULL; + _talkDef = NULL; + + _currentSprite = NULL; // ref only + _currentSkelAnim = NULL; + _font = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setText(const char *text) { + if (_text) delete [] _text; + _text = new char[strlen(text) + 1]; + if (_text) strcpy(_text, text); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setStances(const char *stances) { + if (_stances) delete [] _stances; + if (stances) { + _stances = new char[strlen(stances) + 1]; + if (_stances) strcpy(_stances, stances); + } else _stances = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getCurrentStance() { + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getNextStance() { + _currentStance++; + return getStance(_currentStance); +} + + +////////////////////////////////////////////////////////////////////////// +char *CAdSentence::getStance(int stance) { + if (_stances == NULL) return NULL; + + if (_tempStance) delete [] _tempStance; + _tempStance = NULL; + + char *start; + char *curr; + int pos; + + if (stance == 0) start = _stances; + else { + pos = 0; + start = NULL; + curr = _stances; + while (pos < stance) { + if (*curr == '\0') break; + if (*curr == ',') pos++; + curr++; + } + if (pos == stance) start = curr; + } + + if (start == NULL) return NULL; + + while (*start == ' ' && *start != ',' && *start != '\0') start++; + + curr = start; + while (*curr != '\0' && *curr != ',') curr++; + + while (curr > start && *(curr - 1) == ' ') curr--; + + _tempStance = new char [curr - start + 1]; + if (_tempStance) { + _tempStance[curr - start] = '\0'; + strncpy(_tempStance, start, curr - start); + } + + return _tempStance; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::display() { + if (!_font || !_text) return STATUS_FAILED; + + if (_sound && !_soundStarted) { + _sound->play(); + _soundStarted = true; + } + + if (_gameRef->_subtitles) { + int x = _pos.x; + int y = _pos.y; + + if (!_fixedPos) { + x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); + y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + } + + + x = MAX(x, 0); + x = MIN(x, _gameRef->_renderer->_width - _width); + y = MAX(y, 0); + + _font->drawText((byte *)_text, x, y, _width, _align); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CAdSentence::setSound(CBSound *sound) { + if (!sound) return; + delete _sound; + _sound = sound; + _soundStarted = false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::finish() { + if (_sound) _sound->stop(); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_currentStance)); + persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transfer(TMEMBER(_currentSkelAnim)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_sound)); + persistMgr->transfer(TMEMBER(_soundStarted)); + persistMgr->transfer(TMEMBER(_stances)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_talkDef)); + persistMgr->transfer(TMEMBER(_tempStance)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_fixedPos)); + persistMgr->transfer(TMEMBER(_freezable)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::setupTalkFile(const char *soundFilename) { + delete _talkDef; + _talkDef = NULL; + _currentSprite = NULL; + + if (!soundFilename) return STATUS_OK; + + + AnsiString path = PathUtil::getDirectoryName(soundFilename); + AnsiString name = PathUtil::getFileNameWithoutExtension(soundFilename); + + AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); + if (file) { + _gameRef->_fileManager->closeFile(file); + } else return STATUS_OK; // no talk def file found + + + _talkDef = new CAdTalkDef(_gameRef); + if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { + delete _talkDef; + _talkDef = NULL; + return STATUS_FAILED; + } + //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::update(TDirection dir) { + if (!_talkDef) return STATUS_OK; + + uint32 currentTime; + // if sound is available, synchronize with sound, otherwise use timer + + /* + if (_sound) CurrentTime = _sound->GetPositionTime(); + else CurrentTime = _gameRef->_timer - _startTime; + */ + currentTime = _gameRef->_timer - _startTime; + + bool talkNodeFound = false; + for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { + if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { + talkNodeFound = true; + + CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); + if (newSprite != _currentSprite) newSprite->reset(); + _currentSprite = newSprite; + + if (!_talkDef->_nodes[i]->_playToEnd) break; + } + } + + + // no talk node, try to use default sprite instead (if any) + if (!talkNodeFound) { + CBSprite *newSprite = _talkDef->getDefaultSprite(dir); + if (newSprite) { + if (newSprite != _currentSprite) newSprite->reset(); + _currentSprite = newSprite; + } else _currentSprite = NULL; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSentence::CanSkip() { + // prevent accidental sentence skipping (TODO make configurable) + return (_gameRef->_timer - _startTime) > 300; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_sentence.h b/engines/wintermute/ad/ad_sentence.h new file mode 100644 index 0000000000..40f99ea830 --- /dev/null +++ b/engines/wintermute/ad/ad_sentence.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSENTENCE_H +#define WINTERMUTE_ADSENTENCE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "common/rect.h" + +namespace WinterMute { +class CAdTalkDef; +class CBFont; +class CBSprite; +class CBSound; +class CAdSentence : public CBBase { +public: + bool _freezable; + bool _fixedPos; + CBSprite *_currentSprite; + char *_currentSkelAnim; + bool update(TDirection dir = DI_DOWN); + bool setupTalkFile(const char *soundFilename); + DECLARE_PERSISTENT(CAdSentence, CBBase) + bool finish(); + void setSound(CBSound *Sound); + bool _soundStarted; + CBSound *_sound; + TTextAlign _align; + bool display(); + int _width; + Point32 _pos; + CBFont *_font; + char *getNextStance(); + char *getCurrentStance(); + void setStances(const char *stances); + void setText(const char *text); + int _currentStance; + uint32 _startTime; + char *_stances; + char *_text; + uint32 _duration; + CAdSentence(CBGame *inGame); + virtual ~CAdSentence(); + CAdTalkDef *_talkDef; + + bool CanSkip(); + +private: + char *_tempStance; + char *getStance(int stance); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp new file mode 100644 index 0000000000..f0925c6913 --- /dev/null +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -0,0 +1,312 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_sprite_set.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdSpriteSet, false) + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { + _owner = owner; + + for (int i = 0; i < NUM_DIRECTIONS; i++) + _sprites[i] = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdSpriteSet::~CAdSpriteSet() { + for (int i = 0; i < NUM_DIRECTIONS; i++) { + delete _sprites[i]; + _sprites[i] = NULL; + } + + _owner = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(SPRITESET) +TOKEN_DEF(NAME) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(RIGHT) +TOKEN_DEF(UP) +TOKEN_DEF(DOWN) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(NAME) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(RIGHT) + TOKEN_TABLE(UP) + TOKEN_TABLE(DOWN) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { + _gameRef->LOG(0, "'SPRITESET' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + CBSprite *spr = NULL; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_LEFT: + delete _sprites[DI_LEFT]; + _sprites[DI_LEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_LEFT] = spr; + break; + + case TOKEN_RIGHT: + delete _sprites[DI_RIGHT]; + _sprites[DI_RIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_RIGHT] = spr; + break; + + case TOKEN_UP: + delete _sprites[DI_UP]; + _sprites[DI_UP] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UP] = spr; + break; + + case TOKEN_DOWN: + delete _sprites[DI_DOWN]; + _sprites[DI_DOWN] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWN] = spr; + break; + + case TOKEN_UP_LEFT: + delete _sprites[DI_UPLEFT]; + _sprites[DI_UPLEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPLEFT] = spr; + break; + + case TOKEN_UP_RIGHT: + delete _sprites[DI_UPRIGHT]; + _sprites[DI_UPRIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_UPRIGHT] = spr; + break; + + case TOKEN_DOWN_LEFT: + delete _sprites[DI_DOWNLEFT]; + _sprites[DI_DOWNLEFT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNLEFT] = spr; + break; + + case TOKEN_DOWN_RIGHT: + delete _sprites[DI_DOWNRIGHT]; + _sprites[DI_DOWNRIGHT] = NULL; + spr = new CBSprite(_gameRef, _owner); + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + else _sprites[DI_DOWNRIGHT] = spr; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITESET definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading SPRITESET definition"); + if (spr) delete spr; + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_owner)); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + persistMgr->transfer("", &_sprites[i]); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdSpriteSet::getSprite(TDirection direction) { + int dir = (int)direction; + if (dir < 0) dir = 0; + if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; + + CBSprite *ret = NULL; + + // find nearest set sprite + int numSteps = 0; + for (int i = dir; i >= 0; i--) { + if (_sprites[i] != NULL) { + ret = _sprites[i]; + numSteps = dir - i; + break; + } + } + + for (int i = dir; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] != NULL) { + if (ret == NULL || numSteps > i - dir) return _sprites[i]; + else return ret; + } + } + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITESET {\n"); + if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i]) { + switch (i) { + case DI_UP: + buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPRIGHT: + buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_RIGHT: + buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNRIGHT: + buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWN: + buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_DOWNLEFT: + buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_LEFT: + buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + case DI_UPLEFT: + buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + break; + } + } + } + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CAdSpriteSet::containsSprite(CBSprite *sprite) { + if (!sprite) return false; + + for (int i = 0; i < NUM_DIRECTIONS; i++) { + if (_sprites[i] == sprite) return true; + } + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h new file mode 100644 index 0000000000..993832cfa3 --- /dev/null +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADSPRITESET_H +#define WINTERMUTE_ADSPRITESET_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_sprite.h" // Added by ClassView + +namespace WinterMute { + +class CAdSpriteSet : public CBObject { +public: + bool containsSprite(CBSprite *sprite); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBSprite *getSprite(TDirection direction); + DECLARE_PERSISTENT(CAdSpriteSet, CBObject) + CBObject *_owner; + CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); + virtual ~CAdSpriteSet(); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + CBSprite *_sprites[NUM_DIRECTIONS]; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp new file mode 100644 index 0000000000..0cd62df603 --- /dev/null +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -0,0 +1,260 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_talk_def.h" +#include "engines/wintermute/ad/ad_talk_node.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/ad/ad_sprite_set.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkDef, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkDef::~CAdTalkDef() { + for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; + _nodes.removeAll(); + + delete[] _defaultSpriteFilename; + delete _defaultSprite; + _defaultSpriteFilename = NULL; + _defaultSprite = NULL; + + delete[] _defaultSpriteSetFilename; + delete _defaultSpriteSet; + _defaultSpriteSetFilename = NULL; + _defaultSpriteSet = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + CBUtils::setString(&_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TALK) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(ACTION) +TOKEN_DEF(DEFAULT_SPRITESET_FILE) +TOKEN_DEF(DEFAULT_SPRITESET) +TOKEN_DEF(DEFAULT_SPRITE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TALK) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(DEFAULT_SPRITESET_FILE) + TOKEN_TABLE(DEFAULT_SPRITESET) + TOKEN_TABLE(DEFAULT_SPRITE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { + _gameRef->LOG(0, "'TALK' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_ACTION: { + CAdTalkNode *Node = new CAdTalkNode(_gameRef); + if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); + else { + delete Node; + Node = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_DEFAULT_SPRITE: + CBUtils::setString(&_defaultSpriteFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET_FILE: + CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); + break; + + case TOKEN_DEFAULT_SPRITESET: { + delete _defaultSpriteSet; + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TALK definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading TALK definition"); + return STATUS_FAILED; + } + + delete _defaultSprite; + delete _defaultSpriteSet; + _defaultSprite = NULL; + _defaultSpriteSet = NULL; + + if (_defaultSpriteFilename) { + _defaultSprite = new CBSprite(_gameRef); + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; + } + + if (_defaultSpriteSetFilename) { + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_defaultSprite)); + persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); + persistMgr->transfer(TMEMBER(_defaultSpriteSet)); + persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); + + _nodes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TALK {\n"); + if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + + if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); + + for (int i = 0; i < _nodes.getSize(); i++) { + _nodes[i]->saveAsText(buffer, indent + 2); + buffer->putTextIndent(indent, "\n"); + } + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkDef::loadDefaultSprite() { + if (_defaultSpriteFilename && !_defaultSprite) { + _defaultSprite = new CBSprite(_gameRef); + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { + delete _defaultSprite; + _defaultSprite = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { + _defaultSpriteSet = new CAdSpriteSet(_gameRef); + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { + delete _defaultSpriteSet; + _defaultSpriteSet = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { + loadDefaultSprite(); + if (_defaultSprite) return _defaultSprite; + else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h new file mode 100644 index 0000000000..0811f5b8f5 --- /dev/null +++ b/engines/wintermute/ad/ad_talk_def.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKDEF_H +#define WINTERMUTE_ADTALKDEF_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { +class CAdTalkNode; +class CAdSpriteSet; +class CAdTalkDef : public CBObject { +public: + char *_defaultSpriteSetFilename; + CAdSpriteSet *_defaultSpriteSet; + CBSprite *getDefaultSprite(TDirection Dir); + bool loadDefaultSprite(); + DECLARE_PERSISTENT(CAdTalkDef, CBObject) + + CAdTalkDef(CBGame *inGame); + virtual ~CAdTalkDef(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + CBArray _nodes; + char *_defaultSpriteFilename; + CBSprite *_defaultSprite; + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp new file mode 100644 index 0000000000..28e62798c2 --- /dev/null +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -0,0 +1,366 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_talk_holder.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkHolder, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkHolder::~CAdTalkHolder() { + delete _sprite; + _sprite = NULL; + + for (int i = 0; i < _talkSprites.getSize(); i++) + delete _talkSprites[i]; + _talkSprites.removeAll(); + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) + delete _talkSpritesEx[i]; + _talkSpritesEx.removeAll(); +} + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { + CBSprite *ret = NULL; + + + // forced stance? + if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { + _forcedTalkAnimUsed = true; + delete _animSprite; + _animSprite = new CBSprite(_gameRef, this); + if (_animSprite) { + bool res = _animSprite->loadFile(_forcedTalkAnimName); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + delete _animSprite; + _animSprite = NULL; + } else return _animSprite; + } + } + + + if (stance != NULL) { + // search special talk stances + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + ret = _talkSpritesEx[i]; + break; + } + } + if (ret == NULL) { + // serach generic talk stances + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + ret = _talkSprites[i]; + break; + } + } + } + } + + // not a valid stance? get a random one + if (ret == NULL) { + if (_talkSprites.getSize() < 1) ret = _sprite; + else { + // TODO: remember last + int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + ret = _talkSprites[rnd]; + } + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSprite + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSprite") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + + bool setCurrent = false; + if (_currentSprite && _currentSprite == _sprite) setCurrent = true; + + delete _sprite; + _sprite = NULL; + + if (val->isNULL()) { + _sprite = NULL; + if (setCurrent) _currentSprite = NULL; + stack->pushBool(true); + } else { + const char *filename = val->getString(); + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + script->runtimeError("SetSprite method failed for file '%s'", filename); + stack->pushBool(false); + } else { + _sprite = spr; + if (setCurrent) _currentSprite = _sprite; + stack->pushBool(true); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSprite") == 0) { + stack->correctParams(0); + + if (!_sprite || !_sprite->_filename) stack->pushNULL(); + else stack->pushString(_sprite->_filename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSpriteObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSpriteObject") == 0) { + stack->correctParams(0); + + if (!_sprite) stack->pushNULL(); + else stack->pushNative(_sprite, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool Ex = stack->pop()->getBool(); + + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("AddTalkSprite method failed for file '%s'", filename); + } else { + if (Ex) _talkSpritesEx.add(spr); + else _talkSprites.add(spr); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool ex = stack->pop()->getBool(); + + bool setCurrent = false; + bool setTemp2 = false; + + if (ex) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { + if (_currentSprite == _talkSpritesEx[i]) + setCurrent = true; + if (_tempSprite2 == _talkSpritesEx[i]) + setTemp2 = true; + delete _talkSpritesEx[i]; + _talkSpritesEx.removeAt(i); + break; + } + } + } else { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { + if (_currentSprite == _talkSprites[i]) + setCurrent = true; + if (_tempSprite2 == _talkSprites[i]) + setTemp2 = true; + delete _talkSprites[i]; + _talkSprites.removeAt(i); + break; + } + } + + } + + stack->pushBool(true); + if (setCurrent) + _currentSprite = _sprite; + if (setTemp2) + _tempSprite2 = _sprite; + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetTalkSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetTalkSprite") == 0) { + stack->correctParams(2); + + const char *filename = stack->pop()->getString(); + bool ex = stack->pop()->getBool(); + bool setCurrent = false; + bool setTemp2 = false; + + CBSprite *spr = new CBSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile(filename))) { + stack->pushBool(false); + script->runtimeError("SetTalkSprite method failed for file '%s'", filename); + } else { + + // delete current + if (ex) { + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (_talkSpritesEx[i] == _currentSprite) + setCurrent = true; + if (_talkSpritesEx[i] == _tempSprite2) + setTemp2 = true; + delete _talkSpritesEx[i]; + } + _talkSpritesEx.removeAll(); + } else { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (_talkSprites[i] == _currentSprite) setCurrent = true; + if (_talkSprites[i] == _tempSprite2) setTemp2 = true; + delete _talkSprites[i]; + } + _talkSprites.removeAll(); + } + + // set new + if (ex) + _talkSpritesEx.add(spr); + else + _talkSprites.add(spr); + stack->pushBool(true); + + if (setCurrent) + _currentSprite = spr; + if (setTemp2) + _tempSprite2 = spr; + } + return STATUS_OK; + } + + else return CAdObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdTalkHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("talk-holder"); + return _scValue; + } + + else return CAdObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Item + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Item")==0){ + SetItem(value->getString()); + return STATUS_OK; + } + + else*/ return CAdObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CAdTalkHolder::scToString() { + return "[talk-holder object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { + for (int i = 0; i < _talkSprites.getSize(); i++) { + if (_talkSprites[i]->_filename) + buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + } + + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + if (_talkSpritesEx[i]->_filename) + buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { + CAdObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_sprite)); + _talkSprites.persist(persistMgr); + _talkSpritesEx.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h new file mode 100644 index 0000000000..50c2f3504b --- /dev/null +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKHOLDER_H +#define WINTERMUTE_ADTALKHOLDER_H + +#include "engines/wintermute/ad/ad_object.h" + +namespace WinterMute { + +class CAdTalkHolder : public CAdObject { +public: + DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) + virtual CBSprite *getTalkStance(const char *stance); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + CBSprite *_sprite; + CBArray _talkSprites; + CBArray _talkSpritesEx; + CAdTalkHolder(CBGame *inGame); + virtual ~CAdTalkHolder(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp new file mode 100644 index 0000000000..3b82d731c9 --- /dev/null +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -0,0 +1,266 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_talk_node.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/ad/ad_sprite_set.h" +#include "engines/wintermute/utils/utils.h" +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdTalkNode, false) + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { + _sprite = NULL; + _spriteFilename = NULL; + _spriteSet = NULL; + _spriteSetFilename = NULL; + _comment = NULL; + + _startTime = _endTime = 0; + _playToEnd = false; + _preCache = false; +} + + +////////////////////////////////////////////////////////////////////////// +CAdTalkNode::~CAdTalkNode() { + delete[] _spriteFilename; + delete _sprite; + delete[] _spriteSetFilename; + delete _spriteSet; + delete _comment; + _spriteFilename = NULL; + _sprite = NULL; + _spriteSetFilename = NULL; + _spriteSet = NULL; + _comment = NULL; +} + + + +TOKEN_DEF_START +TOKEN_DEF(ACTION) +TOKEN_DEF(SPRITESET_FILE) +TOKEN_DEF(SPRITESET) +TOKEN_DEF(SPRITE) +TOKEN_DEF(START_TIME) +TOKEN_DEF(END_TIME) +TOKEN_DEF(COMMENT) +TOKEN_DEF(PRECACHE) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ACTION) + TOKEN_TABLE(SPRITESET_FILE) + TOKEN_TABLE(SPRITESET) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(START_TIME) + TOKEN_TABLE(END_TIME) + TOKEN_TABLE(COMMENT) + TOKEN_TABLE(PRECACHE) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { + _gameRef->LOG(0, "'ACTION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + _endTime = 0; + _playToEnd = false; + _preCache = false; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SPRITE: + CBUtils::setString(&_spriteFilename, (char *)params); + break; + + case TOKEN_SPRITESET_FILE: + CBUtils::setString(&_spriteSetFilename, (char *)params); + break; + + case TOKEN_SPRITESET: { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { + delete _spriteSet; + _spriteSet = NULL; + cmd = PARSERR_GENERIC; + } + } + break; + + case TOKEN_START_TIME: + parser.scanStr((char *)params, "%d", &_startTime); + break; + + case TOKEN_END_TIME: + parser.scanStr((char *)params, "%d", &_endTime); + break; + + case TOKEN_PRECACHE: + parser.scanStr((char *)params, "%b", &_preCache); + break; + + case TOKEN_COMMENT: + if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ACTION definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ACTION definition"); + return STATUS_FAILED; + } + + if (_endTime == 0) + _playToEnd = true; + else + _playToEnd = false; + + if (_preCache && _spriteFilename) { + delete _sprite; + _sprite = new CBSprite(_gameRef); + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) + return STATUS_FAILED; + } + + if (_preCache && _spriteSetFilename) { + delete _spriteSet; + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) + return STATUS_FAILED; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_comment)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_endTime)); + persistMgr->transfer(TMEMBER(_playToEnd)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_spriteFilename)); + persistMgr->transfer(TMEMBER(_spriteSet)); + persistMgr->transfer(TMEMBER(_spriteSetFilename)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ACTION {\n"); + if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); + buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); + if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); + if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); + if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::loadSprite() { + if (_spriteFilename && !_sprite) { + _sprite = new CBSprite(_gameRef); + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { + delete _sprite; + _sprite = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } + + else if (_spriteSetFilename && !_spriteSet) { + _spriteSet = new CAdSpriteSet(_gameRef); + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { + delete _spriteSet; + _spriteSet = NULL; + return STATUS_FAILED; + } else return STATUS_OK; + } + + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { + if (time >= _startTime) { + if (_playToEnd) { + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; + else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; + else return false; + } else return _endTime >= time; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSprite *CAdTalkNode::getSprite(TDirection dir) { + loadSprite(); + if (_sprite) return _sprite; + else if (_spriteSet) return _spriteSet->getSprite(dir); + else return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_node.h b/engines/wintermute/ad/ad_talk_node.h new file mode 100644 index 0000000000..55adf88e83 --- /dev/null +++ b/engines/wintermute/ad/ad_talk_node.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTALKNODE_H +#define WINTERMUTE_ADTALKNODE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CAdSpriteSet; +class CBSprite; +class CAdTalkNode : public CBBase { +public: + char *_spriteSetFilename; + CAdSpriteSet *_spriteSet; + CBSprite *getSprite(TDirection dir); + bool isInTimeInterval(uint32 time, TDirection dir); + bool loadSprite(); + DECLARE_PERSISTENT(CAdTalkNode, CBBase) + + CAdTalkNode(CBGame *inGame); + virtual ~CAdTalkNode(); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + char *_spriteFilename; + CBSprite *_sprite; + uint32 _startTime; + uint32 _endTime; + bool _playToEnd; + bool _preCache; + char *_comment; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ad/ad_types.h b/engines/wintermute/ad/ad_types.h new file mode 100644 index 0000000000..b88d6fe259 --- /dev/null +++ b/engines/wintermute/ad/ad_types.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADTYPES_H +#define WINTERMUTE_ADTYPES_H + +namespace WinterMute { + +typedef enum { + GAME_NORMAL, + GAME_WAITING_RESPONSE +} TGameStateEx; + +typedef enum { + OBJECT_ENTITY, + OBJECT_REGION, + OBJECT_ACTOR, + OBJECT_NONE +} TObjectType; + +typedef enum { + ENTITY_NORMAL, + ENTITY_SOUND +} TEntityType; + +typedef enum { + STATE_NONE, + STATE_IDLE, + STATE_PLAYING_ANIM, + STATE_READY, + STATE_FOLLOWING_PATH, + STATE_SEARCHING_PATH, + STATE_WAITING_PATH, + STATE_TURNING_LEFT, + STATE_TURNING_RIGHT, + STATE_TURNING, + STATE_TALKING, + STATE_DIRECT_CONTROL, + STATE_PLAYING_ANIM_SET +} TObjectState; + +typedef enum { + DIRECT_WALK_NONE, + DIRECT_WALK_FW, + DIRECT_WALK_BK +} TDirectWalkMode; + +typedef enum { + DIRECT_TURN_NONE, + DIRECT_TURN_CW, + DIRECT_TURN_CCW +} TDirectTurnMode; + +typedef enum { + RESPONSE_TEXT, + RESPONSE_ICON +} TResponseStyle; + +typedef enum { + RESPONSE_ALWAYS, + RESPONSE_ONCE, + RESPONSE_ONCE_GAME +} TResponseType; + + +typedef enum { + TALK_SKIP_LEFT = 0, + TALK_SKIP_RIGHT = 1, + TALK_SKIP_BOTH = 2, + TALK_SKIP_NONE = 3 +} TTalkSkipButton; + +typedef enum { + GEOM_WAYPOINT, + GEOM_WALKPLANE, + GEOM_BLOCKED, + GEOM_GENERIC +} TGeomNodeType; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp new file mode 100644 index 0000000000..4a902266ac --- /dev/null +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -0,0 +1,261 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_file_manager.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; +} + + +////////////////////////////////////////////////////////////////////////// +CAdWaypointGroup::~CAdWaypointGroup() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CAdWaypointGroup::cleanup() { + for (int i = 0; i < _points.getSize(); i++) + delete _points[i]; + _points.removeAll(); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WAYPOINTS) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(POINT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WAYPOINTS) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(POINT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { + _gameRef->LOG(0, "'WAYPOINTS' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr((char *)params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in WAYPOINTS definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WAYPOINTS {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + if (_scProp) + _scProp->saveAsText(buffer, indent + 2); + CBBase::saveAsText(buffer, indent + 2); + + for (int i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + buffer->putTextIndent(indent, "}\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CAdWaypointGroup::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("waypoint-group"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { + if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < wpt->_points.getSize(); i++) { + int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); + int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(x + argX, y + argY)); + } + + _lastMimicScale = scale; + _lastMimicX = argX; + _lastMimicY = argY; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h new file mode 100644 index 0000000000..2cece9e88b --- /dev/null +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_ADWAYPOINTGROUP_H +#define WINTERMUTE_ADWAYPOINTGROUP_H + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { +class CBPoint; +class CAdWaypointGroup : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); + DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool _active; + CAdWaypointGroup(CBGame *inGame); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual ~CAdWaypointGroup(); + CBArray _points; + int _editorSelectedPoint; + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp deleted file mode 100644 index 836a93ad9a..0000000000 --- a/engines/wintermute/base/BActiveRect.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - clipRect(); -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { - _owner = owner; - _frame = frame; - CBPlatform::setRect(&_rect, x, y, x + width, y + height); - _zoomX = zoomX; - _zoomY = zoomY; - _precise = precise; - _region = NULL; - _offsetX = _offsetY = 0; - clipRect(); -} - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { - _owner = owner; - _region = region; - CBPlatform::copyRect(&_rect, ®ion->_rect); - CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - clipRect(); - _offsetX = offsetX; - _offsetY = offsetY; -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBActiveRect::clipRect() { - Rect32 rc; - bool customViewport; - _gameRef->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = _gameRef->_renderer; - - if (!customViewport) { - rc.left -= Rend->_drawOffsetX; - rc.right -= Rend->_drawOffsetX; - rc.top -= Rend->_drawOffsetY; - rc.bottom -= Rend->_drawOffsetY; - } - - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - - CBPlatform::intersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BActiveRect.h b/engines/wintermute/base/BActiveRect.h deleted file mode 100644 index 935b91eaeb..0000000000 --- a/engines/wintermute/base/BActiveRect.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H - -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { -public: - void clipRect(); - bool _precise; - float _zoomX; - float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; - int _offsetX; - int _offsetY; - Rect32 _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); - virtual ~CBActiveRect(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BBase.cpp b/engines/wintermute/base/BBase.cpp deleted file mode 100644 index 76e1150925..0000000000 --- a/engines/wintermute/base/BBase.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *gameOwner) { - _gameRef = gameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { - _gameRef = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *propName, const char *initVal) { - _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) - return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return initVal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return STATUS_FAILED; - - if (propValue == NULL) { - _editorProps.erase(propName); - } else { - _editorProps[propName] = propValue; - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBBase::parseEditorProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - - if (!_gameRef->_editorMode) - return STATUS_OK; - - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - - - setEditorProp(propName, propValue); - - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { - _editorPropsIter = _editorProps.begin(); - while (_editorPropsIter != _editorProps.end()) { - buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); - buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - buffer->putTextIndent(indent, "}\n\n"); - - _editorPropsIter++; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BBase.h b/engines/wintermute/base/BBase.h deleted file mode 100644 index e8c87f1f9e..0000000000 --- a/engines/wintermute/base/BBase.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace WinterMute { - -class CBGame; -class CBDynBuffer; - -class CBBase { -public: - bool _persistable; - bool setEditorProp(const char *propName, const char *propValue); - const char *getEditorProp(const char *propName, const char *initVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; - bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBBase(); - CBGame *_gameRef; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); - - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BDebugger.cpp b/engines/wintermute/base/BDebugger.cpp deleted file mode 100644 index 92f282b6d1..0000000000 --- a/engines/wintermute/base/BDebugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BDebugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::initialize() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::shutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameInit() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameShutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameTick() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onLog(unsigned int errorCode, const char *text) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptInit(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool CBDebugger::attachClient(IWmeDebugClient *client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::detachClient(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::queryData(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int CBDebugger::getPropInt(const char *propName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double CBDebugger::getPropFloat(const char *propName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::getPropString(const char *propName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::getPropBool(const char *propName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, int propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, double propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, const char *propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, bool propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::continueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDebugger.h b/engines/wintermute/base/BDebugger.h deleted file mode 100644 index cea432f7a8..0000000000 --- a/engines/wintermute/base/BDebugger.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/wme_debugger.h" - -// TODO: The entire debugger should possibly be removed - -namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { -public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); - - // initialization - bool _enabled; - bool initialize(); - bool shutdown(); - - // internal interface - bool onGameInit(); - bool onGameShutdown(); - bool onGameTick(); - bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(CScScript *script); - bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - bool onScriptShutdown(CScScript *script); - bool onScriptChangeLine(CScScript *script, int line); - bool onScriptChangeScope(CScScript *script, CScValue *scope); - bool onScriptShutdownScope(CScScript *script, CScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - bool onVariableChangeValue(CScValue *var, CScValue *value); - - bool onScriptHitBreakpoint(CScScript *script); - - // IWmeDebugServer interface - virtual bool attachClient(IWmeDebugClient *client); - virtual bool detachClient(IWmeDebugClient *client); - virtual bool queryData(IWmeDebugClient *client); - - virtual int getPropInt(const char *propName); - virtual double getPropFloat(const char *propName); - virtual const char *getPropString(const char *propName); - virtual bool getPropBool(const char *propName); - - virtual bool setProp(const char *propName, int propValue); - virtual bool setProp(const char *propName, double propValue); - virtual bool setProp(const char *propName, const char *propValue); - virtual bool setProp(const char *propName, bool propValue); - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - - virtual bool addBreakpoint(const char *scriptFilename, int line); - virtual bool removeBreakpoint(const char *scriptFilename, int line); - - virtual bool continueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BDynBuffer.cpp b/engines/wintermute/base/BDynBuffer.cpp deleted file mode 100644 index 9a2e071287..0000000000 --- a/engines/wintermute/base/BDynBuffer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = initSize; - _growBy = growBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::cleanup() { - if (_buffer) free(_buffer); - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::init(uint32 initSize) { - cleanup(); - - if (initSize == 0) initSize = _initSize; - - _buffer = (byte *)malloc(initSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); - return STATUS_FAILED; - } - - _realSize = initSize; - _initialized = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - while (_offset + size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return STATUS_FAILED; - } - } - - memcpy(_buffer + _offset, buffer, size); - _offset += size; - _size += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - if (_offset + size > _size) { - _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); - return STATUS_FAILED; - } - - memcpy(buffer, _buffer + _offset, size); - _offset += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putDWORD(uint32 val) { - putBytes((byte *)&val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getDWORD() { - uint32 ret; - getBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putString(const char *val) { - if (!val) putString("(null)"); - else { - putDWORD(strlen(val) + 1); - putBytes((byte *)val, strlen(val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::getString() { - uint32 len = getDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) return NULL; - else return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(const char *fmt, ...) { - va_list va; - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { - va_list va; - - putText("%*s", indent, ""); - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - putBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDynBuffer.h b/engines/wintermute/base/BDynBuffer.h deleted file mode 100644 index 66e8182c68..0000000000 --- a/engines/wintermute/base/BDynBuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBDynBuffer : public CBBase { -public: - bool _initialized; - void putText(const char *fmt, ...); - void putTextIndent(int indent, const char *fmt, ...); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - void putString(const char *val); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 getSize(); - bool init(uint32 initSize = 0); - void cleanup(); - uint32 _size; - byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~CBDynBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void putTextForm(const char *format, va_list argptr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp deleted file mode 100644 index 9dec5e1e12..0000000000 --- a/engines/wintermute/base/BFader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFader.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/util.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFader, false) - -////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::update() { - if (!_active) return STATUS_OK; - - int alphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) time = CBPlatform::getTime() - _startTime; - else time = _gameRef->_timer - _startTime; - - if (time >= _duration) _currentAlpha = _targetAlpha; - else { - _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); - } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean - - _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::display() { - if (!_active) return STATUS_OK; - - if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::deactivate() { - _active = false; - _ready = true; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(sourceColor); - _green = RGBCOLGetG(sourceColor); - _blue = RGBCOLGetB(sourceColor); - - _sourceAlpha = RGBCOLGetA(sourceColor); - _targetAlpha = 0; - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(targetColor); - _green = RGBCOLGetG(targetColor); - _blue = RGBCOLGetB(targetColor); - - //_sourceAlpha = 0; - _sourceAlpha = _currentAlpha; - _targetAlpha = RGBCOLGetA(targetColor); - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBFader::getCurrentColor() { - return BYTETORGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blue)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_green)); - persistMgr->transfer(TMEMBER(_red)); - persistMgr->transfer(TMEMBER(_sourceAlpha)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_targetAlpha)); - persistMgr->transfer(TMEMBER(_system)); - - if (_system && !persistMgr->_saving) _startTime = 0; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFader.h b/engines/wintermute/base/BFader.h deleted file mode 100644 index cc90d4603d..0000000000 --- a/engines/wintermute/base/BFader.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CBFader : public CBObject { -public: - bool _system; - uint32 getCurrentColor(); - bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); - bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - bool deactivate(); - bool display(); - bool update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp deleted file mode 100644 index 34638f55e8..0000000000 --- a/engines/wintermute/base/BFileManager.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/base/file/BDiskFile.h" -#include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/base/file/BFileEntry.h" -#include "engines/wintermute/base/file/BPackage.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/BResources.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/dcpackage.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/config-manager.h" -#include "common/system.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/savefile.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { - _basePath = NULL; - - initPaths(); - registerPackages(); -} - - -////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::cleanup() { - // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - - // close open files - for (uint32 i = 0; i < _openFiles.size(); i++) { - delete _openFiles[i]; - } - _openFiles.clear(); - - - // delete packages - for (uint32 i = 0; i < _packages.size(); i++) - delete _packages[i]; - _packages.clear(); - - delete[] _basePath; - _basePath = NULL; - - return STATUS_OK; -} - - - -#define MAX_FILE_SIZE 10000000 -////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; - - Common::SeekableReadStream *file = openFile(filename); - if (!file) { - if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); - return NULL; - } - - /* - if (File->GetSize() > MAX_FILE_SIZE) { - _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - - buffer = new byte[file->size() + 1]; - if (buffer == NULL) { - _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); - closeFile(file); - return NULL; - } - - if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); - closeFile(file); - delete [] buffer; - return NULL; - }; - - buffer[file->size()] = '\0'; - if (size != NULL) *size = file->size(); - closeFile(file); - - return buffer; -} - -Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::InSaveFile *file = saveMan->openForLoading(filename); - return file; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { - // TODO - warning("Implement SaveFile"); - - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - file->finalize(); - delete file; -#if 0 - RestoreCurrentDir(); - - CBUtils::CreatePath(filename, false); - - FILE *f = fopen(filename, "wb"); - if (!f) { - _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); - return STATUS_FAILED; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { - // unmount all non-local packages - for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->close(); - } - - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; - - bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - - char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return STATUS_FAILED; - - strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); - - switch (type) { - case PATH_SINGLE: - _singlePaths.push_back(buffer); - break; - case PATH_PACKAGE: - _packagePaths.push_back(buffer); - break; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::reloadPaths() { - // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - return initPaths(); -} - - -#define TEMP_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::initPaths() { - restoreCurrentDir(); - - AnsiString pathList; - int numPaths; - - // single files paths - pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_SINGLE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_SINGLE, ".\\"); - - - // package files paths - addPath(PATH_PACKAGE, "./"); - - pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_PACKAGE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_PACKAGE, "data"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackages() { - restoreCurrentDir(); - - _gameRef->LOG(0, "Scanning packages..."); - debugC(kWinterMuteDebugFileAccess, "Scanning packages"); - - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, "*.dcp"); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - registerPackage((*it)->getName().c_str()); - } -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.getSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } -#endif - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { -// FILE *f = fopen(filename, "rb"); - Common::File *package = new Common::File(); - package->open(filename); - if (!package->isOpen()) { - _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return STATUS_OK; - } - - uint32 absoluteOffset = 0; - bool boundToExe = false; - - if (searchSignature) { - uint32 offset; - if (!findPackageSignature(package, &offset)) { - delete package; - return STATUS_OK; - } else { - package->seek(offset, SEEK_SET); - absoluteOffset = offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete package; - return STATUS_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = package->readUint32LE(); - dirOffset += absoluteOffset; - package->seek(dirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(_gameRef); - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = package->readByte(); - pkg->_name = new char[nameLength]; - package->read(pkg->_name, nameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.push_back(pkg); - - - // read file entries - uint32 NumFiles = package->readUint32LE(); - - for (uint32 j = 0; j < NumFiles; j++) { - char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; - - nameLength = package->readByte(); - name = new char[nameLength]; - package->read(name, nameLength); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - - CBPlatform::strupr(name); - - offset = package->readUint32LE(); - offset += absoluteOffset; - length = package->readUint32LE(); - compLength = package->readUint32LE(); - flags = package->readUint32LE(); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - timeDate1 = package->readUint32LE(); - timeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(_gameRef); - file->_package = pkg; - file->_offset = offset; - file->_length = length; - file->_compressedLength = compLength; - file->_flags = flags; - - _files[name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = offset; - _filesIter->_value->_length = length; - _filesIter->_value->_compressedLength = compLength; - _filesIter->_value->_flags = flags; - } - } - delete [] name; - } - } - - - delete package; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - - Common::File *ret = new Common::File(); - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _packagePaths.size(); i++) { - sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - } - - sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &name) { - restoreCurrentDir(); - - Common::File *ret = NULL; - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { - restoreCurrentDir(); - - Common::File f; - bool found = false; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(filename.c_str()); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(fullname, filename.c_str()); - } - } - - return found; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { - char *upc_name = new char[strlen(filename.c_str()) + 1]; - strcpy(upc_name, filename.c_str()); - CBPlatform::strupr(upc_name); - - CBFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - delete [] upc_name; - - return ret; -} - -bool CBFileManager::hasFile(const Common::String &filename) { - //TODO: Do this in a much simpler fashion - Common::SeekableReadStream *stream = openFile(filename, true, false); - if (!stream) { - return false; - } - delete stream; - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) return NULL; - //_gameRef->LOG(0, "open file: %s", filename); - /*#ifdef __WIN32__ - if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); - } - } - #endif*/ - - Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.push_back(file); - return file; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (uint32 i = 0; i < _openFiles.size(); i++) { - if (_openFiles[i] == File) { - delete _openFiles[i]; - _openFiles.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { - restoreCurrentDir(); - - Common::SeekableReadStream *ret = NULL; - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); - } - delete SaveThumbFile; - return ret; - } - - - - ret = openDiskFile(filename, this); - if (ret) return ret; - - ret = openPkgFile(filename, this); - if (ret) return ret; - - ret = CBResources::getFile(filename); - if (ret) return ret; - - warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::restoreCurrentDir() { - if (!_basePath) return STATUS_OK; - else { - /*if (!chdir(_basePath)) return STATUS_OK; - else return STATUS_FAILED;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::setBasePath(const Common::String &path) { - cleanup(); - - if (path.c_str()) { - _basePath = new char[path.size() + 1]; - strcpy(_basePath, path.c_str()); - } - - initPaths(); - registerPackages(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h deleted file mode 100644 index 7ea9ff5611..0000000000 --- a/engines/wintermute/base/BFileManager.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H - -#include "engines/wintermute/base/file/BFileEntry.h" -#include "common/archive.h" -#include "common/str.h" - -namespace Common { -class File; -} - -namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { -public: - bool findPackageSignature(Common::File *f, uint32 *offset); - bool cleanup(); - bool setBasePath(const Common::String &path); - bool restoreCurrentDir(); - char *_basePath; - bool getFullPath(const Common::String &filename, char *fullname); - Common::SeekableReadStream *openFileRaw(const Common::String &filename); - bool closeFile(Common::SeekableReadStream *File); - bool hasFile(const Common::String &filename); - Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openSingleFile(const Common::String &name); - Common::File *openPackage(const Common::String &name); - bool registerPackages(); - bool initPaths(); - bool reloadPaths(); - typedef enum { - PATH_PACKAGE, PATH_SINGLE - } TPathType; - bool addPath(TPathType type, const Common::String &path); - bool requestCD(int cd, char *packageFile, const char *filename); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); - Common::Array _singlePaths; - Common::Array _packagePaths; - Common::Array _packages; - Common::Array _openFiles; - - Common::HashMap _files; -private: - bool registerPackage(const Common::String &filename, bool searchSignature = false); - Common::HashMap::iterator _filesIter; - bool isValidPackage(const AnsiString &fileName) const; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp deleted file mode 100644 index d6d8a3aa5c..0000000000 --- a/engines/wintermute/base/BFrame.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFrame, false) - -////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { - delete _sound; - _sound = NULL; - - for (int i = 0; i < _subframes.getSize(); i++) - delete _subframes[i]; - _subframes.removeAll(); - - for (int i = 0; i < _applyEvent.getSize(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.removeAll(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - bool res; - - for (int i = 0; i < _subframes.getSize(); i++) { - res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) return res; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { - if (_sound && !muted) { - if (owner) owner->updateOneSound(_sound); - _sound->play(); - /* - if (_gameRef->_state == GAME_FROZEN) { - _sound->Pause(true); - } - */ - } - if (owner) { - for (int i = 0; i < _applyEvent.getSize(); i++) { - owner->applyEvent(_applyEvent[i]); - } - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(DELAY) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(MOVE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(SUBFRAME) -TOKEN_DEF(SOUND) -TOKEN_DEF(KEYFRAME) -TOKEN_DEF(DECORATION) -TOKEN_DEF(APPLY_EVENT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_EXPANDED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(KILL_SOUND) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(DELAY) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(MOVE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(SUBFRAME) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(KEYFRAME) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(APPLY_EVENT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_EXPANDED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(KILL_SOUND) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - int hotspotX = 0, hotspotY = 0; - bool custoTrans = false; - bool editorSelected = false; - bool is2DOnly = false; - bool is3DOnly = false; - bool decoration = false; - bool mirrorX = false; - bool mirrorY = false; - CBPlatform::setRectEmpty(&rect); - char *surface_file = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_DELAY: - parser.scanStr(params, "%d", &_delay); - break; - - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); - break; - - case TOKEN_MOVE: - parser.scanStr(params, "%d,%d", &_moveX, &_moveY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &is2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &is3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &mirrorY); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &editorSelected); - break; - - case TOKEN_EDITOR_EXPANDED: - parser.scanStr(params, "%b", &_editorExpanded); - break; - - case TOKEN_KILL_SOUND: - parser.scanStr(params, "%b", &_killSound); - break; - - case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(_gameRef); - if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { - delete subframe; - cmd = PARSERR_GENERIC; - } else _subframes.add(subframe); - } - break; - - case TOKEN_SOUND: { - if (_sound) { - delete _sound; - _sound = NULL; - } - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); - delete _sound; - _sound = NULL; - } - } - break; - - case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.add(Event); - } - break; - - case TOKEN_KEYFRAME: - parser.scanStr(params, "%b", &_keyframe); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &decoration); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FRAME definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading FRAME definition"); - return STATUS_FAILED; - } - - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (surface_file != NULL) { - if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); - - if (!sub->_surface) { - delete sub; - _gameRef->LOG(0, "Error loading SUBFRAME"); - return STATUS_FAILED; - } - - sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); - } - - if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); - else sub->_rect = rect; - - sub->_hotspotX = hotspotX; - sub->_hotspotY = hotspotY; - sub->_2DOnly = is2DOnly; - sub->_3DOnly = is3DOnly; - sub->_decoration = decoration; - sub->_mirrorX = mirrorX; - sub->_mirrorY = mirrorY; - - - sub->_editorSelected = editorSelected; - _subframes.insertAt(0, sub); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - CBPlatform::setRectEmpty(rect); - - Rect32 subRect; - - for (int i = 0; i < _subframes.getSize(); i++) { - _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, rect, &subRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "FRAME {\n"); - buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - - if (_moveX != 0 || _moveY != 0) - buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - - if (_sound && _sound->_soundFilename) - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - - buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - - if (_killSound) - buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - - if (_editorExpanded) - buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - - if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); - - for (int i = 1; i < _subframes.getSize(); i++) { - _subframes[i]->saveAsText(buffer, indent + 2); - } - - for (int i = 0; i < _applyEvent.getSize(); i++) { - buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - CBBase::saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - _applyEvent.persist(persistMgr); - persistMgr->transfer(TMEMBER(_delay)); - persistMgr->transfer(TMEMBER(_editorExpanded)); - persistMgr->transfer(TMEMBER(_keyframe)); - persistMgr->transfer(TMEMBER(_killSound)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_sound)); - _subframes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSound") == 0) { - stack->correctParams(0); - - if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); - else stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSound") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - delete _sound; - _sound = NULL; - - if (!val->isNULL()) { - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { - stack->pushBool(false); - delete _sound; - _sound = NULL; - } else stack->pushBool(true); - } else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSubframe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushNative(_subframes[index], true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); - } - } else { - CBSubFrame *sub = (CBSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.getSize(); i++) { - if (_subframes[i] == sub) { - delete _subframes[i]; - _subframes.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - sub->setDefaultRect(); - } - _subframes.add(sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertSubframe") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - } - - if (index >= _subframes.getSize()) _subframes.add(sub); - else _subframes.insertAt(index, sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.getSize()) { - script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushString(_applyEvent[index]); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - stack->pushNULL(); - return STATUS_OK; - } - } - _applyEvent.add(event); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete [] _applyEvent[i]; - _applyEvent.removeAt(i); - break; - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return CBScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("frame"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { - _scValue->setInt(_delay); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _scValue->setBool(_keyframe); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _scValue->setBool(_killSound); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _scValue->setInt(_moveX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _scValue->setInt(_moveY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumSubframes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return CBScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _keyframe = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _killSound = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _moveX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _moveY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return CBScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBFrame::scToString() { - return "[frame]"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFrame.h b/engines/wintermute/base/BFrame.h deleted file mode 100644 index 3d487b4ebc..0000000000 --- a/engines/wintermute/base/BFrame.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H - -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { -public: - bool _killSound; - bool _keyframe; - bool oneTimeDisplay(CBObject *owner, bool muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; - bool _editorExpanded; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(CBDynBuffer *buffer, int indent); - int _moveY; - int _moveX; - uint32 _delay; - CBArray _subframes; - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - - CBFrame(CBGame *inGame); - virtual ~CBFrame(); - - CBArray _applyEvent; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BGame.cpp b/engines/wintermute/base/BGame.cpp deleted file mode 100644 index 3e577541b7..0000000000 --- a/engines/wintermute/base/BGame.cpp +++ /dev/null @@ -1,4478 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFader.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BQuickMsg.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BSubFrame.h" - -#include "engines/wintermute/base/BTransitionMgr.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/video/VidPlayer.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/wintermute.h" -#include "common/savefile.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/keyboard.h" -#include "common/system.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBGame, true) - - -////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _fileManager = NULL; - _transMgr = NULL; - _debugMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _debugLogFile = NULL; - _debugDebugMode = false; - _debugAbsolutePathWarning = true; - _debugShowFPS = false; - - _systemFont = NULL; - _videoFont = NULL; - - _videoPlayer = NULL; - _theoraPlayer = NULL; - - _mainObject = NULL; - _activeObject = NULL; - - _fader = NULL; - - _offsetX = _offsetY = 0; - _offsetPercentX = _offsetPercentY = 0.0f; - - _subtitles = true; - _videoSubtitles = true; - - _timer = 0; - _timerDelta = 0; - _timerLast = 0; - - _liveTimer = 0; - _liveTimerDelta = 0; - _liveTimerLast = 0; - - _sequence = 0; - - _mousePos.x = _mousePos.y = 0; - _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; - _capturedObject = NULL; - - // FPS counters - _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - - _cursorNoninteractive = NULL; - - _useD3D = false; - - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - _settingsResWidth = 800; - _settingsResHeight = 600; - _settingsRequireAcceleration = false; - _settingsRequireSound = false; - _settingsTLMode = 0; - _settingsAllowWindowed = true; - _settingsGameFile = NULL; - _settingsAllowAdvanced = false; - _settingsAllowAccessTab = true; - _settingsAllowAboutTab = true; - _settingsAllowDesktopRes = false; - - _editorForceScripts = false; - _editorAlwaysRegister = false; - - _focusedWindow = NULL; - - _loadInProgress = false; - - _quitting = false; - _loading = false; - _scheduledLoadSlot = -1; - - _personalizedSave = false; - _compressedSavegames = true; - - _editorMode = false; - _doNotExpandStrings = false; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - _smartCache = false; - _surfaceGCCycleTime = 10000; - - _reportTextureFormat = false; - - _viewportSP = -1; - - _subtitlesSpeed = 70; - - _forceNonStreamedSounds = false; - - _thumbnailWidth = _thumbnailHeight = 0; - - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _richSavedGames = false; - _savedGameExt = NULL; - CBUtils::setString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _localSaveDir = NULL; - CBUtils::setString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - CBPlatform::setRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _autoSaveSlot = 999; - _cursorHidden = false; - -/*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else*/ - _touchInterface = false; - _constrainedMemory = false; -//#endif - -} - - -////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - getDebugMgr()->onGameShutdown(); - - _registry->writeBool("System", "LastRun", true); - - cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _saveLoadImage; - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _videoPlayer; - delete _theoraPlayer; - delete _soundMgr; - delete _debugMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _fileManager; - delete _registry; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _saveLoadImage = NULL; - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _videoPlayer = NULL; - _theoraPlayer = NULL; - _soundMgr = NULL; - _debugMgr = NULL; - - _renderer = NULL; - _fileManager = NULL; - _registry = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - CBPlatform::outputDebugString("--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::cleanup() { - delete _loadingIcon; - _loadingIcon = NULL; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete _music[i]; - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - unregisterObject(_fader); - _fader = NULL; - - for (int i = 0; i < _regObjects.getSize(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.removeAll(); - - _windows.removeAll(); // refs only - _focusedWindow = NULL; // ref only - - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (int i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->finish(); - } - _scripts.removeAll(); - - _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; - _quickMessages.removeAll(); - - _viewportStack.removeAll(); - _viewportSP = -1; - - delete[] _name; - delete[] _filename; - _name = NULL; - _filename = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize1() { - bool loaded = false; // Not really a loop, but a goto-replacement. - while (!loaded) { - _surfaceStorage = new CBSurfaceStorage(this); - if (_surfaceStorage == NULL) - break; - - _fontStorage = new CBFontStorage(this); - if (_fontStorage == NULL) - break; - - _fileManager = new CBFileManager(this); - if (_fileManager == NULL) - break; - - _soundMgr = new CBSoundMgr(this); - if (_soundMgr == NULL) - break; - - _debugMgr = new CBDebugger(this); - if (_debugMgr == NULL) - break; - - _mathClass = new CSXMath(this); - if (_mathClass == NULL) - break; - - _scEngine = new CScEngine(this); - if (_scEngine == NULL) - break; - - _videoPlayer = new CVidPlayer(this); - if (_videoPlayer == NULL) - break; - - _transMgr = new CBTransitionMgr(this); - if (_transMgr == NULL) - break; - - _keyboardState = new CBKeyboardState(this); - if (_keyboardState == NULL) - break; - - _fader = new CBFader(this); - if (_fader == NULL) - break; - registerObject(_fader); - - loaded = true; - } - if (loaded == true) { - return STATUS_OK; - } else { - delete _mathClass; - delete _keyboardState; - delete _transMgr; - delete _debugMgr; - delete _surfaceStorage; - delete _fontStorage; - delete _soundMgr; - delete _fileManager; - delete _scEngine; - delete _videoPlayer; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) return STATUS_FAILED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *filename) { - _debugDebugMode = true; - - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - #ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #endif*/ - int secs = g_system->getMillis() / 1000; - int hours = secs / 3600; - secs = secs % 3600; - int mins = secs / 60; - secs = secs % 60; - -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); -#endif - - LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - - AnsiString platform = CBPlatform::getPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { - if (_debugLogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_debugLogFile); - _debugLogFile = NULL; - } - _debugDebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::LOG(bool res, const char *fmt, ...) { - uint32 secs = g_system->getMillis() / 1000; - uint32 hours = secs / 3600; - secs = secs % 3600; - uint32 mins = secs / 60; - secs = secs % 60; - - char buff[512]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - // redirect to an engine's own callback - if (_engineLogCallback) { - _engineLogCallback(buff, res, _engineLogCallbackData); - } - if (_debugMgr) _debugMgr->onLog(res, buff); - - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - - //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fflush((FILE *)_debugLogFile); - - //QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { - _engineLogCallback = callback; - _engineLogCallbackData = data; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initLoop() { - _viewportSP = -1; - - _currentTime = CBPlatform::getTime(); - - getDebugMgr()->onGameTick(); - _renderer->initLoop(); - _soundMgr->initLoop(); - updateMusicCrossfade(); - - _surfaceStorage->initLoop(); - _fontStorage->initLoop(); - - - //_activeObject = NULL; - - // count FPS - _deltaTime = _currentTime - _lastTime; - _lastTime = _currentTime; - _fpsTime += _deltaTime; - - _liveTimerDelta = _liveTimer - _liveTimerLast; - _liveTimerLast = _liveTimer; - _liveTimer += MIN((uint32)1000, _deltaTime); - - if (_state != GAME_FROZEN) { - _timerDelta = _timer - _timerLast; - _timerLast = _timer; - _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; - - _framesRendered++; - if (_fpsTime > 1000) { - _fps = _framesRendered; - _framesRendered = 0; - _fpsTime = 0; - } - //_gameRef->LOG(0, "%d", _fps); - - getMousePos(&_mousePos); - - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - updateSounds(); - - if (_fader) _fader->update(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initInput() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBGame::getSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setOffset(int offsetX, int offsetY) { - _offsetX = offsetX; - _offsetY = offsetY; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) *offsetX = _offsetX; - if (offsetY != NULL) *offsetY = _offsetY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SYSTEM_FONT) -TOKEN_DEF(VIDEO_FONT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(ACTIVE_CURSOR) -TOKEN_DEF(NONINTERACTIVE_CURSOR) -TOKEN_DEF(STRING_TABLE) -TOKEN_DEF(RESOLUTION) -TOKEN_DEF(SETTINGS) -TOKEN_DEF(REQUIRE_3D_ACCELERATION) -TOKEN_DEF(REQUIRE_SOUND) -TOKEN_DEF(HWTL_MODE) -TOKEN_DEF(ALLOW_WINDOWED_MODE) -TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) -TOKEN_DEF(ALLOW_ABOUT_TAB) -TOKEN_DEF(ALLOW_ADVANCED) -TOKEN_DEF(ALLOW_DESKTOP_RES) -TOKEN_DEF(REGISTRY_PATH) -TOKEN_DEF(PERSONAL_SAVEGAMES) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(SUBTITLES_SPEED) -TOKEN_DEF(SUBTITLES) -TOKEN_DEF(VIDEO_SUBTITLES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(THUMBNAIL_WIDTH) -TOKEN_DEF(THUMBNAIL_HEIGHT) -TOKEN_DEF(INDICATOR_X) -TOKEN_DEF(INDICATOR_Y) -TOKEN_DEF(INDICATOR_WIDTH) -TOKEN_DEF(INDICATOR_HEIGHT) -TOKEN_DEF(INDICATOR_COLOR) -TOKEN_DEF(SAVE_IMAGE_X) -TOKEN_DEF(SAVE_IMAGE_Y) -TOKEN_DEF(SAVE_IMAGE) -TOKEN_DEF(LOAD_IMAGE_X) -TOKEN_DEF(LOAD_IMAGE_Y) -TOKEN_DEF(LOAD_IMAGE) -TOKEN_DEF(LOCAL_SAVE_DIR) -TOKEN_DEF(RICH_SAVED_GAMES) -TOKEN_DEF(SAVED_GAME_EXT) -TOKEN_DEF(GUID) -TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SYSTEM_FONT) - TOKEN_TABLE(VIDEO_FONT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(ACTIVE_CURSOR) - TOKEN_TABLE(NONINTERACTIVE_CURSOR) - TOKEN_TABLE(PERSONAL_SAVEGAMES) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(SUBTITLES_SPEED) - TOKEN_TABLE(SUBTITLES) - TOKEN_TABLE(VIDEO_SUBTITLES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(THUMBNAIL_WIDTH) - TOKEN_TABLE(THUMBNAIL_HEIGHT) - TOKEN_TABLE(INDICATOR_X) - TOKEN_TABLE(INDICATOR_Y) - TOKEN_TABLE(INDICATOR_WIDTH) - TOKEN_TABLE(INDICATOR_HEIGHT) - TOKEN_TABLE(INDICATOR_COLOR) - TOKEN_TABLE(SAVE_IMAGE_X) - TOKEN_TABLE(SAVE_IMAGE_Y) - TOKEN_TABLE(SAVE_IMAGE) - TOKEN_TABLE(LOAD_IMAGE_X) - TOKEN_TABLE(LOAD_IMAGE_Y) - TOKEN_TABLE(LOAD_IMAGE) - TOKEN_TABLE(LOCAL_SAVE_DIR) - TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { - _gameRef->LOG(0, "'GAME' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _systemFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - _videoFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ACTIVE_CURSOR: - delete _activeCursor; - _activeCursor = NULL; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { - delete _activeCursor; - _activeCursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NONINTERACTIVE_CURSOR: - delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PERSONAL_SAVEGAMES: - parser.scanStr((char *)params, "%b", &_personalizedSave); - break; - - case TOKEN_SUBTITLES: - parser.scanStr((char *)params, "%b", &_subtitles); - break; - - case TOKEN_SUBTITLES_SPEED: - parser.scanStr((char *)params, "%d", &_subtitlesSpeed); - break; - - case TOKEN_VIDEO_SUBTITLES: - parser.scanStr((char *)params, "%b", &_videoSubtitles); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_THUMBNAIL_WIDTH: - parser.scanStr((char *)params, "%d", &_thumbnailWidth); - break; - - case TOKEN_THUMBNAIL_HEIGHT: - parser.scanStr((char *)params, "%d", &_thumbnailHeight); - break; - - case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &_indicatorX); - break; - - case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &_indicatorY); - break; - - case TOKEN_INDICATOR_COLOR: { - int r, g, b, a; - parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = BYTETORGBA(r, g, b, a); - } - break; - - case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &_indicatorWidth); - break; - - case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &_indicatorHeight); - break; - - case TOKEN_SAVE_IMAGE: - CBUtils::setString(&_saveImageName, (char *)params); - break; - - case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &_saveImageX); - break; - - case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_saveImageY); - break; - - case TOKEN_LOAD_IMAGE: - CBUtils::setString(&_loadImageName, (char *)params); - break; - - case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &_loadImageX); - break; - - case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_loadImageY); - break; - - case TOKEN_LOCAL_SAVE_DIR: - CBUtils::setString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); - - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - LOG(0, stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - bool res = CBObject::scCallMethod(script, stack, thisStack, name); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // Msg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Msg") == 0) { - stack->correctParams(1); - quickMessage(stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RunScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RunScript") == 0) { - _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadStringTable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadStringTable") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - CScValue *Val = stack->pop(); - - bool ClearOld; - if (Val->isNULL()) ClearOld = true; - else ClearOld = Val->getBool(); - - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ValidObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidObject") == 0) { - stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *) obj)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - resetContent(); - stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->getNative(); - unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadWindow") == 0) { - stack->correctParams(1); - CUIWindow *win = new CUIWindow(_gameRef); - if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { - _windows.add(win); - registerObject(win); - stack->pushNative(win, true); - } else { - delete win; - win = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ExpandString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExpandString") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char *str = new char[strlen(val->getString()) + 1]; - strcpy(str, val->getString()); - _stringTable->expand(&str); - stack->pushString(str); - delete [] str; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayMusic / PlayMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); - else { - stack->correctParams(4); - channel = stack->pop()->getInt(); - } - - const char *filename = stack->pop()->getString(); - CScValue *valLooping = stack->pop(); - bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - - CScValue *valLoopStart = stack->pop(); - uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - - - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopMusic / StopMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic / PauseMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeMusic / ResumeMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusic / GetMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); - else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); - else stack->pushString(_music[channel]->_soundFilename); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicPosition / SetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - uint32 time = stack->pop()->getInt(); - - if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); - else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicPosition / GetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsMusicPlaying / IsMusicChannelPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { - int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else stack->pushBool(_music[channel]->isPlaying()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicVolume / SetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); - else stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicVolume / GetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolumePercent()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicCrossfade - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicCrossfade") == 0) { - stack->correctParams(4); - int channel1 = stack->pop()->getInt(0); - int channel2 = stack->pop()->getInt(0); - uint32 fadeLength = (uint32)stack->pop()->getInt(0); - bool swap = stack->pop()->getBool(true); - - if (_musicCrossfadeRunning) { - script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - stack->pushBool(false); - return STATUS_OK; - } - - _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = channel1; - _musicCrossfadeChannel2 = channel2; - _musicCrossfadeLength = fadeLength; - _musicCrossfadeSwap = swap; - - _musicCrossfadeRunning = true; - - stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundLength") == 0) { - stack->correctParams(1); - - int length = 0; - const char *filename = stack->pop()->getString(); - - CBSound *sound = new CBSound(_gameRef); - if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - length = sound->getLength(); - delete sound; - sound = NULL; - } - stack->pushInt(length); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMousePos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMousePos") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - x = MAX(x, 0); - x = MIN(x, _renderer->_width); - y = MAX(y, 0); - y = MIN(y, _renderer->_height); - Point32 p; - p.x = x + _renderer->_drawOffsetX; - p.y = y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LockMouseRect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LockMouseRect") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - if (right < left) CBUtils::swap(&left, &right); - if (bottom < top) CBUtils::swap(&top, &bottom); - - CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayVideo") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK; - // TODO: ADDVIDEO - */ - - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - - stack->correctParams(6); - const char *filename = stack->pop()->getString(); - warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->pop(); - int Type; - if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) - Type = (int)VID_PLAY_STRETCH; - - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK;*/ - // TODO: ADDVIDEO - - stack->correctParams(7); - const char *filename = stack->pop()->getString(); - CScValue *valType = stack->pop(); - int type; - if (valType->isNULL()) - type = (int)VID_PLAY_STRETCH; - else type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool freezeMusic = stack->pop()->getBool(true); - bool dropFrames = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; - - delete _theoraPlayer; - _theoraPlayer = new CVidTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { - _theoraPlayer->_dontDropFrames = !dropFrames; - if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else { - stack->pushBool(false); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QuitGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QuitGame") == 0) { - stack->correctParams(0); - stack->pushNULL(); - _quitting = true; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int val = stack->pop()->getInt(); - _registry->writeInt("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *val = stack->pop()->getString(); - _registry->writeString("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->readString("PrivateSettings", key, initVal); - stack->pushString(val.c_str()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveGame") == 0) { - stack->correctParams(3); - int slot = stack->pop()->getInt(); - const char *xdesc = stack->pop()->getString(); - bool quick = stack->pop()->getBool(false); - - char *desc = new char[strlen(xdesc) + 1]; - strcpy(desc, xdesc); - stack->pushBool(true); - if (DID_FAIL(SaveGame(slot, desc, quick))) { - stack->pop(); - stack->pushBool(false); - } - delete [] desc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadGame") == 0) { - stack->correctParams(1); - _scheduledLoadSlot = stack->pop()->getInt(); - _loading = true; - stack->pushBool(false); - script->sleep(0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSaveSlotUsed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSaveSlotUsed") == 0) { - stack->correctParams(1); - int Slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(Slot)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSaveSlotDescription - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSaveSlotDescription") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - char desc[512]; - desc[0] = '\0'; - getSaveSlotDescription(slot, desc); - stack->pushString(desc); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - emptySaveSlot(slot); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSFXVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMusicVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMasterVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSFXVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMusicVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMasterVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getMasterVolumePercent()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetActiveCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursor") == 0) { - stack->correctParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); - else stack->pushString(_activeCursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursorObject") == 0) { - stack->correctParams(0); - if (!_activeCursor) stack->pushNULL(); - else stack->pushNative(_activeCursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveActiveCursor") == 0) { - stack->correctParams(0); - delete _activeCursor; - _activeCursor = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasActiveCursor") == 0) { - stack->correctParams(0); - - if (_activeCursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FileExists - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FileExists") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - // TODO: Replace with fileExists - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) stack->pushBool(false); - else { - _fileManager->closeFile(file); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Screenshot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Screenshot") == 0) { - stack->correctParams(1); - char filename[MAX_PATH_LENGTH]; - - CScValue *Val = stack->pop(); - - warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO - int fileNum = 0; - - while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); - if (!Common::File::exists(filename)) - break; - fileNum++; - } - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenshotEx - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenshotEx") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - int sizeX = stack->pop()->getInt(_renderer->_width); - int sizeY = stack->pop()->getInt(_renderer->_height); - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIWindow *win = new CUIWindow(_gameRef); - _windows.add(win); - registerObject(win); - if (!val->isNULL()) win->setName(val->getString()); - stack->pushNative(win, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - CBObject *obj = (CBObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == obj) { - unregisterObject(_windows[i]); - stack->pushBool(true); - return STATUS_OK; - } - } - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenDocument - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenDocument") == 0) { - stack->correctParams(0); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_DumpClassRegistry - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { - stack->correctParams(0); - DEBUG_DumpClassRegistry(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetLoadingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetLoadingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _loadImageX = stack->pop()->getInt(); - _loadImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; - } else { - CBUtils::setString(&_loadImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSavingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _saveImageX = stack->pop()->getInt(); - _saveImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; - } else { - CBUtils::setString(&_saveImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetWaitCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveWaitCursor") == 0) { - stack->correctParams(0); - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursor") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursorObject") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive) stack->pushNULL(); - else stack->pushNative(_cursorNoninteractive, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearScriptCache - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearScriptCache") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayLoadingIcon") == 0) { - stack->correctParams(4); - - const char *filename = stack->pop()->getString(); - _loadingIconX = stack->pop()->getInt(); - _loadingIconY = stack->pop()->getInt(); - _loadingIconPersistent = stack->pop()->getBool(); - - delete _loadingIcon; - _loadingIcon = new CBSprite(this); - if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { - delete _loadingIcon; - _loadingIcon = NULL; - } else { - displayContent(false, true); - _gameRef->_renderer->flip(); - _gameRef->_renderer->initLoop(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideLoadingIcon") == 0) { - stack->correctParams(0); - delete _loadingIcon; - _loadingIcon = NULL; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DumpTextureStats - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DumpTextureStats") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _renderer->dumpData(filename); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccOutputText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccOutputText") == 0) { - stack->correctParams(2); - /* const char *Str = */ - stack->pop()->getString(); - /* int Type = */ - stack->pop()->getInt(); - // do nothing - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StoreSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StoreSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); - if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFileChecksum - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFileChecksum") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool asHex = stack->pop()->getBool(false); - - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (file) { - crc remainder = crc_initialize(); - byte buf[1024]; - int bytesRead = 0; - - while (bytesRead < file->size()) { - int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); - bytesRead += file->read(buf, bufSize); - - for (int i = 0; i < bufSize; i++) { - remainder = crc_process_byte(buf[i], remainder); - } - } - crc checksum = crc_finalize(remainder); - - if (asHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - stack->pushString(Hex); - } else - stack->pushInt(checksum); - - _fileManager->closeFile(file); - file = NULL; - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EnableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EnableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->enableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->disableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ShowStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ShowStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Hwnd (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { - _scValue->setInt((int)_renderer->_window); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { - _scValue->setInt((int)_timer); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowsTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::getTime()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowedMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { - _scValue->setBool(_renderer->_windowed); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _scValue->setInt(_mousePos.x); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _scValue->setInt(_mousePos.y); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - _scValue->setNative(_mainObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ActiveObject (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { - _scValue->setNative(_activeObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenWidth (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { - _scValue->setInt(_renderer->_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenHeight (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { - _scValue->setInt(_renderer->_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - _scValue->setBool(_interactive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DebugMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { - _scValue->setBool(_debugDebugMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundAvailable (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { - _scValue->setBool(_soundMgr->_soundAvailable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getMasterVolumePercent()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyboard (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->setNative(_keyboardState, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _scValue->setBool(_subtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _scValue->setInt(_subtitlesSpeed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _scValue->setBool(_videoSubtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FPS (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { - _scValue->setInt(_fps); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AcceleratedMode / Accelerated (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { - _scValue->setBool(_useD3D); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - _scValue->setInt(_textEncoding); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _scValue->setBool(_textRTL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _scValue->setInt(_soundBufferSizeSec); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _scValue->setBool(_suspendedRendering); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _scValue->setBool(_suppressScriptErrors); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // Frozen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { - _scValue->setBool(_state == GAME_FROZEN); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSTalk - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSCaptions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSKeypress - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardCursorSkip - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardPause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _scValue->setBool(_autorunDisabled); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveDirectory (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = getDataDir(); - _scValue->setString(dataDir.c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _scValue->setBool(_autoSaveOnExit); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _scValue->setInt(_autoSaveSlot); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _scValue->setBool(_cursorHidden); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Platform (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::getPlatformName().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DeviceType (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { - _scValue->setString(getDeviceType().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MostRecentSaveSlot (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Store (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { - _scValue->setNULL(); - error("Request for a SXStore-object, which is not supported by ScummVM"); - - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - bool res = CBObject::scSetProperty(name, value); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->getNative(); - if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - setInteractive(value->getBool()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _subtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->getInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _textRTL = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = value->getInt(); - _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBGame::scToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; - - // update - for (int i = 0; i < _quickMessages.getSize(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.removeAt(i); - i--; - } - } - - int posY = 20; - - // display - for (int i = 0; i < _quickMessages.getSize(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); - posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); - } - return STATUS_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessage(const char *text) { - if (_quickMessages.getSize() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.removeAt(0); - } - _quickMessages.add(new CBQuickMsg(_gameRef, text)); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - quickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::registerObject(CBObject *object) { - _regObjects.add(object); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unregisterObject(CBObject *object) { - if (!object) return STATUS_OK; - - // is it a window? - for (int i = 0; i < _windows.getSize(); i++) { - if ((CBObject *)_windows[i] == object) { - _windows.removeAt(i); - - // get new focused window - if (_focusedWindow == object) _focusedWindow = NULL; - - break; - } - } - - // is it active object? - if (_activeObject == object) _activeObject = NULL; - - // is it main object? - if (_mainObject == object) _mainObject = NULL; - - // destroy object - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) { - _regObjects.removeAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); - delete object; - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::invalidateValues(void *value, void *data) { - CScValue *val = (CScValue *)value; - if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { - ((CBScriptable *)data)->_refCount++; - } - val->setNative(NULL); - val->setNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::validObject(CBObject *object) { - if (!object) return false; - if (object == this) return true; - - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *thisObj; - - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // String - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "String") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXString(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MemBuffer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MemBuffer") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // File - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "File") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXFile(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Date - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Date") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXDate(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Array - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Array") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXArray(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Object - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Object") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXObject(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Sleep - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sleep") == 0) { - stack->correctParams(1); - - script->sleep((uint32)stack->pop()->getInt()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // WaitFor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WaitFor") == 0) { - stack->correctParams(1); - - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Random - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Random") == 0) { - stack->correctParams(2); - - int from = stack->pop()->getInt(); - int to = stack->pop()->getInt(); - - stack->pushInt(CBUtils::randomInt(from, to)); - } - - ////////////////////////////////////////////////////////////////////////// - // SetScriptTimeSlice - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetScriptTimeSlice") == 0) { - stack->correctParams(1); - - script->_timeSlice = (uint32)stack->pop()->getInt(); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeRGBA / MakeRGB / RGB - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { - stack->correctParams(4); - int r = stack->pop()->getInt(); - int g = stack->pop()->getInt(); - int b = stack->pop()->getInt(); - int a; - CScValue *val = stack->pop(); - if (val->isNULL()) a = 255; - else a = val->getInt(); - - stack->pushInt(BYTETORGBA(r, g, b, a)); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeHSL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeHSL") == 0) { - stack->correctParams(3); - int h = stack->pop()->getInt(); - int s = stack->pop()->getInt(); - int l = stack->pop()->getInt(); - - stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetRValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetR(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetGValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetG(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetBValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetB(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetAValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetA(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetHValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(H); - } - - ////////////////////////////////////////////////////////////////////////// - // GetSValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(S); - } - - ////////////////////////////////////////////////////////////////////////// - // GetLValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Debug") == 0) { - stack->correctParams(0); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); - script->sleep(0); - } - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // ToString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToString") == 0) { - stack->correctParams(1); - const char *str = stack->pop()->getString(); - char *str2 = new char[strlen(str) + 1]; - strcpy(str2, str); - stack->pushString(str2); - delete [] str2; - } - - ////////////////////////////////////////////////////////////////////////// - // ToInt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToInt") == 0) { - stack->correctParams(1); - int val = stack->pop()->getInt(); - stack->pushInt(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToFloat") == 0) { - stack->correctParams(1); - double val = stack->pop()->getFloat(); - stack->pushFloat(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - stack->pushBool(val); - } - - ////////////////////////////////////////////////////////////////////////// - // failure - else { - script->runtimeError("Call to undefined function '%s'. Ignored.", name); - stack->correctParams(0); - stack->pushNULL(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::showCursor() { - if (_cursorHidden) return STATUS_OK; - - if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); - } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; - else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); - else if (_cursor) return drawCursor(_cursor); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - LOG(0, "Saving game '%s'...", filename); - - _gameRef->applyEvent("BeforeSave", true); - - bool ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; - - _registry->writeInt("System", "MostRecentSaveSlot", slot); - -save_finish: // TODO: Remove gotos - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - return loadGame(filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(const char *filename) { - LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->onGameShutdown(); - - bool ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - _debugAbsolutePathWarning = false; - if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - - //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; - - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - - getDebugMgr()->onGameInit(); - -load_finish: - _debugAbsolutePathWarning = true; - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::initAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); - - _scEngine->refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->createRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSubFrame(void *subframe, void *data) { - ((CBSubFrame *)subframe)->setSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSound(void *sound, void *data) { - ((CBSound *)sound)->setSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadFont(void *font, void *data) { - ((CBFont *)font)->afterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadScript(void *script, void *data) { - ((CScScript *)script)->afterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayWindows(bool inGame) { - bool res; - - // did we lose focus? focus topmost window - if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { - - res = _windows[i]->display(); - if (DID_FAIL(res)) return res; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - delete _music[channel]; - _music[channel] = NULL; - - _music[channel] = new CBSound(_gameRef); - if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - if (_musicStartTime[channel]) { - _music[channel]->setPositionTime(_musicStartTime[channel]); - _musicStartTime[channel] = 0; - } - if (loopStart) _music[channel]->setLoopStart(loopStart); - return _music[channel]->play(looping); - } else { - delete _music[channel]; - _music[channel] = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - _music[channel]->stop(); - delete _music[channel]; - _music[channel] = NULL; - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pauseMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resumeMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setMusicStartTime(int channel, uint32 time) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadSettings(const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SETTINGS) - TOKEN_TABLE(GAME) - TOKEN_TABLE(STRING_TABLE) - TOKEN_TABLE(RESOLUTION) - TOKEN_TABLE(REQUIRE_3D_ACCELERATION) - TOKEN_TABLE(REQUIRE_SOUND) - TOKEN_TABLE(HWTL_MODE) - TOKEN_TABLE(ALLOW_WINDOWED_MODE) - TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) - TOKEN_TABLE(ALLOW_ABOUT_TAB) - TOKEN_TABLE(ALLOW_ADVANCED) - TOKEN_TABLE(ALLOW_DESKTOP_RES) - TOKEN_TABLE(REGISTRY_PATH) - TOKEN_TABLE(RICH_SAVED_GAMES) - TOKEN_TABLE(SAVED_GAME_EXT) - TOKEN_TABLE(GUID) - TOKEN_TABLE_END - - - byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); - if (origBuffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret = STATUS_OK; - - byte *buffer = origBuffer; - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return STATUS_FAILED; - } - buffer = params; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - delete[] _settingsGameFile; - _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); - break; - - case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_RESOLUTION: - parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); - break; - - case TOKEN_REQUIRE_3D_ACCELERATION: - parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); - break; - - case TOKEN_REQUIRE_SOUND: - parser.scanStr((char *)params, "%b", &_settingsRequireSound); - break; - - case TOKEN_HWTL_MODE: - parser.scanStr((char *)params, "%d", &_settingsTLMode); - break; - - case TOKEN_ALLOW_WINDOWED_MODE: - parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); - break; - - case TOKEN_ALLOW_DESKTOP_RES: - parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); - break; - - case TOKEN_ALLOW_ADVANCED: - parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); - break; - - case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); - break; - - case TOKEN_ALLOW_ABOUT_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); - break; - - case TOKEN_REGISTRY_PATH: - _registry->setBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - CBUtils::setString(&_savedGameExt, (char *)params); - break; - - case TOKEN_GUID: - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); - ret = STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading game settings '%s'", filename); - ret = STATUS_FAILED; - } - - _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; - - delete [] origBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) - cleanup(); - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_activeObject)); - persistMgr->transfer(TMEMBER(_capturedObject)); - persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_doNotExpandStrings)); - persistMgr->transfer(TMEMBER(_editorMode)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_freezeLevel)); - persistMgr->transfer(TMEMBER(_focusedWindow)); - persistMgr->transfer(TMEMBER(_fontStorage)); - persistMgr->transfer(TMEMBER(_interactive)); - persistMgr->transfer(TMEMBER(_keyboardState)); - persistMgr->transfer(TMEMBER(_lastTime)); - persistMgr->transfer(TMEMBER(_mainObject)); - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - persistMgr->transfer(TMEMBER(_music[i])); - persistMgr->transfer(TMEMBER(_musicStartTime[i])); - } - - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_offsetPercentX)); - persistMgr->transfer(TMEMBER(_offsetPercentY)); - - persistMgr->transfer(TMEMBER(_origInteractive)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_personalizedSave)); - persistMgr->transfer(TMEMBER(_quitting)); - - _regObjects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scEngine)); - //persistMgr->transfer(TMEMBER(_soundMgr)); - persistMgr->transfer(TMEMBER_INT(_state)); - //persistMgr->transfer(TMEMBER(_surfaceStorage)); - persistMgr->transfer(TMEMBER(_subtitles)); - persistMgr->transfer(TMEMBER(_subtitlesSpeed)); - persistMgr->transfer(TMEMBER(_systemFont)); - persistMgr->transfer(TMEMBER(_videoFont)); - persistMgr->transfer(TMEMBER(_videoSubtitles)); - - persistMgr->transfer(TMEMBER(_timer)); - persistMgr->transfer(TMEMBER(_timerDelta)); - persistMgr->transfer(TMEMBER(_timerLast)); - - persistMgr->transfer(TMEMBER(_liveTimer)); - persistMgr->transfer(TMEMBER(_liveTimerDelta)); - persistMgr->transfer(TMEMBER(_liveTimerLast)); - - persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); - persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); - persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); - persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); - - persistMgr->transfer(TMEMBER_INT(_textEncoding)); - persistMgr->transfer(TMEMBER(_textRTL)); - - persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); - persistMgr->transfer(TMEMBER(_suspendedRendering)); - - persistMgr->transfer(TMEMBER(_mouseLockRect)); - - _windows.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_suppressScriptErrors)); - persistMgr->transfer(TMEMBER(_autorunDisabled)); - - persistMgr->transfer(TMEMBER(_autoSaveOnExit)); - persistMgr->transfer(TMEMBER(_autoSaveSlot)); - persistMgr->transfer(TMEMBER(_cursorHidden)); - - if (!persistMgr->_saving) - _quitting = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::focusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; - - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == Window) { - if (i < _windows.getSize() - 1) { - _windows.removeAt(i); - _windows.add(Window); - - _gameRef->_focusedWindow = Window; - } - - if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return focusWindow(Prev); - else return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::freeze(bool includingMusic) { - if (_freezeLevel == 0) { - _scEngine->pauseAll(); - _soundMgr->pauseAll(includingMusic); - _origState = _state; - _origInteractive = _interactive; - _interactive = true; - } - _state = GAME_FROZEN; - _freezeLevel++; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unfreeze() { - if (_freezeLevel == 0) return STATUS_OK; - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->resumeAll(); - _soundMgr->resumeAll(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleKeypress(Common::Event *event, bool printable) { - if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) - stopVideo(); - return true; - } - - if (event->type == Common::EVENT_QUIT) { - onWindowClose(); - return true; - } - - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->switchFullscreen(); - return true; - } - - - _keyboardState->handleKeyPress(event); - _keyboardState->readKey(event); -// TODO - - if (_focusedWindow) { - if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { - /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) - _gameRef->_focusedWindow->applyEvent("Keypress"); - else - applyEvent("Keypress"); - /*}*/ - } - return true; - } else { /*if (event->type != SDL_TEXTINPUT)*/ - applyEvent("Keypress"); - return true; - } //else return true; - - return false; -} - -void CBGame::handleKeyRelease(Common::Event *event) { - _keyboardState->handleKeyRelease(event); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleMouseWheel(int Delta) { - bool handled = false; - if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); - - if (!handled) { - if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); - handled = true; - } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); - handled = true; - } - - } - } - - if (!handled) { - if (Delta < 0) { - applyEvent("MouseWheelDown"); - } else { - applyEvent("MouseWheelUp"); - } - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) *verMajor = DCGF_VER_MAJOR; - if (verMinor) *verMinor = DCGF_VER_MINOR; - - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setWindowTitle() { - if (_renderer) { - char title[512]; - strcpy(title, _caption[0]); - if (title[0] != '\0') strcat(title, " - "); - strcat(title, "WME Lite"); - - - Utf8String utf8Title; - if (_textEncoding == TEXT_UTF8) { - utf8Title = Utf8String(title); - } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); - utf8Title = Utf8String(title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } -#if 0 - CBRenderOSystem *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - Common::String filename = pm->getFilenameForSlot(slot); - delete pm; - strcpy(buffer, filename.c_str()); - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDataDir() { - AnsiString userDir = PathUtil::getUserDirectory(); - AnsiString baseDir = _registry->getBasePath(); - return PathUtil::combine(userDir, baseDir); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotDescription(int slot, char *buffer) { - buffer[0] = '\0'; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(filename))) { - _debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - - _debugAbsolutePathWarning = true; - strcpy(buffer, pm->_savedDescription); - delete pm; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!File) return false; - delete File; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::emptySaveSlot(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(this); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); - delete pm; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setActiveObject(CBObject *obj) { - // not-active when game is frozen - if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { - obj = NULL; - } - - if (obj == _activeObject) return STATUS_OK; - - if (_activeObject) _activeObject->applyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); - _activeObject = obj; - if (_activeObject) { - _activeObject->applyEvent("MouseEntry"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pushViewport(CBViewport *viewport) { - _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); - else _viewportStack[_viewportSP] = viewport; - - _renderer->setViewport(viewport->getRect()); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::popViewport() { - _viewportSP--; - if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); - - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) return STATUS_FAILED; - else { - if (_viewportSP >= 0) { - CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) *custom = true; - } else { - CBPlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (custom) *custom = false; - } - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { - if (_viewportSP >= 0) { - if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; - if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; - } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setInteractive(bool state) { - _interactive = state; - if (_transMgr) _transMgr->_origInteractive = state; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::resetMousePos() { - Common::Point p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContent(bool doUpdate, bool displayAll) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContentSimple() { - // fill black - _renderer->fill(0, 0, 0); - if (_indicatorDisplay) displayIndicator(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayIndicator() { - if (_saveLoadImage) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; - _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) - _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - - _renderer->setup2D(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::updateMusicCrossfade() { - /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - - if (!_musicCrossfadeRunning) return STATUS_OK; - if (_state == GAME_FROZEN) return STATUS_OK; - - if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - - if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); - if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); - - uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; - - if (currentTime >= _musicCrossfadeLength) { - _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->setVolumePercent(100); - - _music[_musicCrossfadeChannel1]->stop(); - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent(100); - - - if (_musicCrossfadeSwap) { - // swap channels - CBSound *dummy = _music[_musicCrossfadeChannel1]; - int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; - - _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; - _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - - _music[_musicCrossfadeChannel2] = dummy; - _musicStartTime[_musicCrossfadeChannel2] = dummyInt; - } - } else { - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - - //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resetContent() { - _scEngine->clearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { - warning("DEBUG_DumpClassRegistry - untested"); - Common::DumpFile *f = new Common::DumpFile; - f->open("zz_class_reg_dump.log"); - - CSysClassRegistry::getInstance()->dumpClasses(f); - - f->close(); - delete f; - _gameRef->quickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->invalidateDeviceObjects(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->restoreDeviceObjects(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setWaitCursor(const char *filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) return true; - if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopVideo() { - if (_videoPlayer->isPlaying()) _videoPlayer->stop(); - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - _theoraPlayer->stop(); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::drawCursor(CBSprite *cursor) { - if (!cursor) return STATUS_FAILED; - if (cursor != _lastCursor) { - cursor->reset(); - _lastCursor = cursor; - } - return cursor->draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -bool CBGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return STATUS_OK; - - _renderer->_active = activate; - - if (refreshMouse) { - Point32 p; - getMousePos(&p); - setActiveObject(_renderer->getObjectAt(p.x, p.y)); - } - - if (activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _capturedObject = _activeObject; - _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->initLoop(); - displayContent(false, true); - displayDebugInfo(); - _renderer->windowedBlt(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onWindowClose() { - if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); - return STATUS_OK; - } else return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayDebugInfo() { - char str[100]; - - if (_debugShowFPS) { - sprintf(str, "FPS: %d", _gameRef->_fps); - _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); - } - - if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) - sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else - sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); - - strcat(str, " ("); - strcat(str, _renderer->getName()); - strcat(str, ")"); - _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - - _renderer->displayDebugInfo(); - - int scrTotal, scrRunning, scrWaiting, scrPersistent; - scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); - _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - - - sprintf(str, "Timer: %d", _timer); - _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); - - sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); - - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); - return _debugMgr; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Point32 *pos) { - CBPlatform::getCursorPos(pos); - - pos->x -= _renderer->_drawOffsetX; - pos->y -= _renderer->_drawOffsetY; - - /* - // Windows can squish maximized window if it's larger than desktop - // so we need to modify mouse position appropriately (tnx mRax) - if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { - Common::Rect rc; - ::GetClientRect(_renderer->_window, &rc); - Pos->x *= _gameRef->_renderer->_realWidth; - Pos->x /= (rc.right - rc.left); - Pos->y *= _gameRef->_renderer->_realHeight; - Pos->y /= (rc.bottom - rc.top); - } - */ - - if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { - pos->x = MAX(_mouseLockRect.left, pos->x); - pos->y = MAX(_mouseLockRect.top, pos->y); - - pos->x = MIN(_mouseLockRect.right, pos->x); - pos->y = MIN(_mouseLockRect.bottom, pos->y); - - Point32 newPos = *pos; - - newPos.x += _renderer->_drawOffsetX; - newPos.y += _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(newPos.x, newPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::miniUpdate() { - if (!_miniUpdateEnabled) return STATUS_OK; - - if (CBPlatform::getTime() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::getTime(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isLeftDoubleClick() { - return isDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isRightDoubleClick() { - return isDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - - Point32 pos; - CBPlatform::getCursorPos(&pos); - - int moveX = abs(pos.x - _lastClick[buttonIndex].posX); - int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - - - if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = CBPlatform::getTime(); - _lastClick[buttonIndex].posX = pos.x; - _lastClick[buttonIndex].posY = pos.y; - return false; - } else { - _lastClick[buttonIndex].time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::autoSaveOnExit() { - _soundMgr->saveSettings(); - _registry->saveValues(); - - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; - - SaveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::addMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDeviceType() const { - return "computer"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BGame.h b/engines/wintermute/base/BGame.h deleted file mode 100644 index 7441d81b07..0000000000 --- a/engines/wintermute/base/BGame.h +++ /dev/null @@ -1,391 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H - -#include "engines/wintermute/base/BDebugger.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/math/Rect32.h" -#include "common/events.h" - -namespace WinterMute { - -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); - -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXMath; -class CBKeyboardState; -class CVidPlayer; -class CVidTheoraPlayer; - -#define NUM_MUSIC_CHANNELS 5 - -class CBGame: public CBObject { -public: - DECLARE_PERSISTENT(CBGame, CBObject) - - virtual bool onScriptShutdown(CScScript *script); - - virtual bool onActivate(bool activate, bool refreshMouse); - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - virtual bool onMouseMiddleDown(); - virtual bool onMouseMiddleUp(); - virtual bool onPaint(); - virtual bool onWindowClose(); - - bool isLeftDoubleClick(); - bool isRightDoubleClick(); - - bool _autorunDisabled; - - uint32 _lastMiniUpdate; - bool _miniUpdateEnabled; - - virtual bool miniUpdate(); - - void getMousePos(Point32 *Pos); - Rect32 _mouseLockRect; - - bool _shuttingDown; - - virtual bool displayDebugInfo(); - bool _debugShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - CBSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - virtual bool resetContent(); - - void DEBUG_DumpClassRegistry(); - bool setWaitCursor(const char *filename); - char *_localSaveDir; - bool _saveDirChecked; - - int _indicatorProgress; -protected: - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - CBSurface *_saveLoadImage; - bool displayIndicator(); - - bool _reportTextureFormat; -public: - int _thumbnailWidth; - int _thumbnailHeight; - - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; - bool _editorMode; - - bool _doNotExpandStrings; - void getOffset(int *offsetX, int *offsetY); - void setOffset(int offsetX, int offsetY); - int getSequence(); - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - CBObject *_mainObject; - - bool initInput(); - bool initLoop(); - uint32 _currentTime; - uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; - bool initialize1(); - bool initialize2(); - bool initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *getDebugMgr(); - - void LOG(bool res, const char *fmt, ...); - - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); - - virtual ~CBGame(); - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *filename = NULL); - bool _debugDebugMode; - bool _debugAbsolutePathWarning; - - void *_debugLogFile; - int _sequence; - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; - - int _viewportSP; - - CBStringTable *_stringTable; - int _settingsResWidth; - int _settingsResHeight; - char *_settingsGameFile; - bool _suppressScriptErrors; - bool _mouseLeftDown; -protected: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - CBFader *_fader; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); -public: - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - // compatibility bits - bool _compatKillMethodThreads; - -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; -public: - const char* getGameId() { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } - uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; - int _scheduledLoadSlot; - bool _loading; - bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); - void setWindowTitle(); - virtual bool handleMouseWheel(int delta); - bool _quitting; - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual void handleKeyRelease(Common::Event *event); -protected: - int _freezeLevel; -public: - bool unfreeze(); - bool freeze(bool includingMusic = true); - bool focusWindow(CUIWindow *window); - CVidPlayer *_videoPlayer; - CVidTheoraPlayer *_theoraPlayer; - bool _loadInProgress; - CUIWindow *_focusedWindow; - bool _editorForceScripts; -protected: - static void afterLoadRegion(void *region, void *data); - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); -public: - static void invalidateValues(void *value, void *data); - - bool loadSettings(const char *filename); - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; - bool displayWindows(bool inGame = false); - CBRegistry *_registry; - bool _useD3D; - virtual bool cleanup(); - virtual bool loadGame(int slot); - virtual bool loadGame(const char *filename); - virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); - virtual bool showCursor(); - - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - CBObject *_capturedObject; - Point32 _mousePos; - bool validObject(CBObject *object); - bool unregisterObject(CBObject *object); - bool registerObject(CBObject *object); - void quickMessage(const char *text); - void quickMessageForm(char *fmt, ...); - bool displayQuickMsg(); - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - - CBArray _regObjects; -public: - virtual bool displayContent(bool update = true, bool displayAll = false); - virtual bool displayContentSimple(); - bool _forceNonStreamedSounds; - void resetMousePos(); - int _subtitlesSpeed; - void setInteractive(bool state); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); - bool popViewport(); - bool pushViewport(CBViewport *Viewport); - bool setActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - bool drawCursor(CBSprite *Cursor); - - virtual bool initAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; - AnsiString getDataDir(); - void addMem(int bytes); - - bool _touchInterface; - bool _constrainedMemory; - AnsiString getDeviceType() const; - -private: - CBDebugger *_debugMgr; - - struct LastClickInfo { - LastClickInfo() { - posX = posY = 0; - time = 0; - } - - int posX; - int posY; - uint32 time; - }; - - LastClickInfo _lastClick[2]; - bool isDoubleClick(int buttonIndex); - uint32 _usedMem; - - - -protected: - // WME Lite specific - bool _autoSaveOnExit; - int _autoSaveSlot; - bool _cursorHidden; - -public: - void autoSaveOnExit(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BKeyboardState.cpp b/engines/wintermute/base/BKeyboardState.cpp deleted file mode 100644 index 85ab15f58e..0000000000 --- a/engines/wintermute/base/BKeyboardState.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/system.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { - _currentPrintable = false; - _currentCharCode = 0; - _currentKeyData = 0; - - _currentShift = false; - _currentAlt = false; - _currentControl = false; - - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { - delete[] _keyStates; -} - -void CBKeyboardState::handleKeyPress(Common::Event *event) { - if (event->type == Common::EVENT_KEYDOWN) { - _keyStates[event->kbd.keycode] = true; - } -} - -void CBKeyboardState::handleKeyRelease(Common::Event *event) { - if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "IsKeyDown") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - int vKey; - - if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { - const char *str = val->getString(); - char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); - vKey = (int)temp; - } else vKey = val->getInt(); - - warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); - bool isDown = _keyStates[vKeyToKeyCode(vKey)]; - - stack->pushBool(isDown); - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("keyboard"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Key - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { - if (_currentPrintable) { - char key[2]; - key[0] = (char)_currentCharCode; - key[1] = '\0'; - _scValue->setString(key); - } else _scValue->setString(""); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Printable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { - _scValue->setBool(_currentPrintable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KeyCode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { - _scValue->setInt(_currentCharCode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsShift - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { - _scValue->setBool(_currentShift); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsAlt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { - _scValue->setBool(_currentAlt); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsControl - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { - _scValue->setBool(_currentControl); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - if (_renderer) SetWindowText(_renderer->_window, _name); - return STATUS_OK; - } - - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::scToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::readKey(Common::Event *event) { - //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = keyCodeToVKey(event); - if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { - _currentPrintable = true; - } else { - _currentPrintable = false; - } - //_currentKeyData = KeyData; - - _currentControl = isControlDown(); - _currentAlt = isAltDown(); - _currentShift = isShiftDown(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { - //if(!persistMgr->_saving) cleanup(); - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_currentAlt)); - persistMgr->transfer(TMEMBER(_currentCharCode)); - persistMgr->transfer(TMEMBER(_currentControl)); - persistMgr->transfer(TMEMBER(_currentKeyData)); - persistMgr->transfer(TMEMBER(_currentPrintable)); - persistMgr->transfer(TMEMBER(_currentShift)); - - if (!persistMgr->_saving) { - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; - - switch (event->kbd.keycode) { - case Common::KEYCODE_KP_ENTER: - return Common::KEYCODE_RETURN; - default: - return (uint32)event->kbd.keycode; - } -} - -enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 -}; - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { - // todo - switch (vkey) { - case VK_SPACE: - return Common::KEYCODE_SPACE; - break; - case VK_LEFT: - return Common::KEYCODE_LEFT; - break; - case VK_RIGHT: - return Common::KEYCODE_RIGHT; - break; - case VK_UP: - return Common::KEYCODE_UP; - break; - case VK_DOWN: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; - } - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BKeyboardState.h b/engines/wintermute/base/BKeyboardState.h deleted file mode 100644 index e3a4a903f7..0000000000 --- a/engines/wintermute/base/BKeyboardState.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BScriptable.h" -#include "common/keyboard.h" -#include "common/events.h" - -namespace WinterMute { - -class CBKeyboardState : public CBScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); - bool readKey(Common::Event *event); - - void handleKeyPress(Common::Event *event); - void handleKeyRelease(Common::Event *event); - static bool isShiftDown(); - static bool isControlDown(); - static bool isAltDown(); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - uint8 *_keyStates; - uint32 keyCodeToVKey(Common::Event *event); - Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BNamedObject.cpp b/engines/wintermute/base/BNamedObject.cpp deleted file mode 100644 index 9587da45e8..0000000000 --- a/engines/wintermute/base/BNamedObject.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BNamedObject.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBNamedObject::setName(const char *name) { - delete[] _name; - - _name = new char [strlen(name) + 1]; - if (_name != NULL) strcpy(_name, name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BNamedObject.h b/engines/wintermute/base/BNamedObject.h deleted file mode 100644 index 4d5fdb0c0e..0000000000 --- a/engines/wintermute/base/BNamedObject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBNamedObject : public CBBase { -public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); - - char *_name; - void setName(const char *name); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp deleted file mode 100644 index ed5d6fa5b7..0000000000 --- a/engines/wintermute/base/BObject.cpp +++ /dev/null @@ -1,1128 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBObject, false) - -////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { - _posX = _posY = 0; - _movable = true; - _zoomable = true; - _registrable = true; - _shadowable = true; - _rotatable = false; - _is3D = false; - - _alphaColor = 0; - _scale = -1; - _relativeScale = 0; - - _scaleX = -1; - _scaleY = -1; - - _ready = true; - - _soundEvent = NULL; - - _iD = _gameRef->getSequence(); - - CBPlatform::setRectEmpty(&_rect); - _rectSet = false; - - _cursor = NULL; - _activeCursor = NULL; - _sharedCursors = false; - - _sFX = NULL; - _sFXStart = 0; - _sFXVolume = 100; - _autoSoundPanning = true; - - _editorAlwaysRegister = false; - _editorSelected = false; - - _editorOnly = false; - - _rotate = 0.0f; - _rotateValid = false; - _relativeRotate = 0.0f; - - for (int i = 0; i < 7; i++) - _caption[i] = NULL; - _saveState = true; - - _nonIntMouseEvents = false; - - // sound FX - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - _blendMode = BLEND_NORMAL; -} - - -////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) - _gameRef->_activeObject = NULL; - - CBScriptHolder::cleanup(); - delete[] _soundEvent; - _soundEvent = NULL; - - if (!_sharedCursors) { - delete _cursor; - delete _activeCursor; - _cursor = NULL; - _activeCursor = NULL; - } - delete _sFX; - _sFX = NULL; - - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7) - return; - - delete[] _caption[caseVal - 1]; - _caption[caseVal - 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal - 1]) { - strcpy(_caption[caseVal - 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) - return ""; - else return _caption[caseVal - 1]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - afterMove(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - stack->correctParams(1); - stack->pushString(getCaption(stack->pop()->getInt())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveCursor") == 0) { - stack->correctParams(0); - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } else { - _cursor = NULL; - - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursor") == 0) { - stack->correctParams(0); - if (!_cursor || !_cursor->_filename) stack->pushNULL(); - else stack->pushString(_cursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursorObject") == 0) { - stack->correctParams(0); - if (!_cursor) stack->pushNULL(); - else stack->pushNative(_cursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasCursor") == 0) { - stack->correctParams(0); - - if (_cursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCaption") == 0) { - stack->correctParams(2); - setCaption(stack->pop()->getString(), stack->pop()->getInt()); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadSound") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySound") == 0) { - stack->correctParams(3); - - const char *filename; - bool looping; - uint32 loopStart; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - - if (val1->_type == VAL_BOOL) { - filename = NULL; - looping = val1->getBool(); - loopStart = val2->getInt(); - } else { - if (val1->isNULL()) filename = NULL; - else filename = val1->getString(); - looping = val2->isNULL() ? false : val2->getBool(); - loopStart = val3->getInt(); - } - - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) - stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySoundEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySoundEvent") == 0) { - stack->correctParams(2); - - const char *filename; - const char *eventName; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - - if (val2->isNULL()) { - filename = NULL; - eventName = val1->getString(); - } else { - filename = val1->getString(); - eventName = val2->getString(); - } - - if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(pauseSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(resumeSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSoundPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSoundPlaying") == 0) { - stack->correctParams(0); - - if (_sFX && _sFX->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundPosition") == 0) { - stack->correctParams(1); - - uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundPosition") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(0); - else stack->pushInt(_sFX->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundVolume") == 0) { - stack->correctParams(1); - - int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundVolume") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolumePercent()); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SoundFXNone - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXNone") == 0) { - stack->correctParams(0); - _sFXType = SFX_NONE; - _sFXParam1 = 0; - _sFXParam2 = 0; - _sFXParam3 = 0; - _sFXParam4 = 0; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXEcho - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXEcho") == 0) { - stack->correctParams(4); - _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXReverb - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXReverb") == 0) { - stack->correctParams(4); - _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - _scValue->setString(getCaption(1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(getHeight()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Ready (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { - _scValue->setBool(_ready); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _scValue->setBool(_movable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _scValue->setBool(_registrable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _scValue->setBool(_zoomable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _scValue->setBool(_rotatable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alphaColor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - _scValue->setInt((int)_blendMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _scValue->setFloat((double)_relativeScale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->setNULL(); - else _scValue->setFloat((double)_rotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _scValue->setFloat((double)_relativeRotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _scValue->setBool(_shadowable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _scValue->setBool(_autoSoundPanning); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _scValue->setBool(_saveState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _scValue->setBool(_nonIntMouseEvents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - _scValue->setNULL(); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Caption") == 0) { - setCaption(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _movable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _rotatable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; - _blendMode = (TSpriteBlendMode)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) _scale = -1; - else _scale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) _scaleX = -1; - else _scaleX = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) _scaleY = -1; - else _scaleY = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (value->isNULL()) { - _rotate = 0.0f; - _rotateValid = false; - } else { - _rotate = (float)value->getFloat(); - _rotateValid = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _shadowable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) resetSoundPan(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _saveState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::scToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::showCursor() { - if (_cursor) return _gameRef->drawCursor(_cursor); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - for (int i = 0; i < 7; i++) - persistMgr->transfer(TMEMBER(_caption[i])); - persistMgr->transfer(TMEMBER(_activeCursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - persistMgr->transfer(TMEMBER(_autoSoundPanning)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_sharedCursors)); - persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); - persistMgr->transfer(TMEMBER(_editorOnly)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_is3D)); - persistMgr->transfer(TMEMBER(_movable)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); - persistMgr->transfer(TMEMBER(_relativeScale)); - persistMgr->transfer(TMEMBER(_rotatable)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_sFX)); - persistMgr->transfer(TMEMBER(_sFXStart)); - persistMgr->transfer(TMEMBER(_sFXVolume)); - persistMgr->transfer(TMEMBER(_ready)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_rectSet)); - persistMgr->transfer(TMEMBER(_registrable)); - persistMgr->transfer(TMEMBER(_shadowable)); - persistMgr->transfer(TMEMBER(_soundEvent)); - persistMgr->transfer(TMEMBER(_zoomable)); - - persistMgr->transfer(TMEMBER(_scaleX)); - persistMgr->transfer(TMEMBER(_scaleY)); - - persistMgr->transfer(TMEMBER(_rotate)); - persistMgr->transfer(TMEMBER(_rotateValid)); - persistMgr->transfer(TMEMBER(_relativeRotate)); - - persistMgr->transfer(TMEMBER(_saveState)); - persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); - - persistMgr->transfer(TMEMBER_INT(_sFXType)); - persistMgr->transfer(TMEMBER(_sFXParam1)); - persistMgr->transfer(TMEMBER(_sFXParam2)); - persistMgr->transfer(TMEMBER(_sFXParam3)); - persistMgr->transfer(TMEMBER(_sFXParam4)); - - - persistMgr->transfer(TMEMBER_INT(_blendMode)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setCursor(const char *filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { - delete _cursor; - _cursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setActiveCursor(const char *filename) { - delete _activeCursor; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { - delete _activeCursor; - _activeCursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBObject::getHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleKeypress(Common::Event *event, bool printable) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouseWheel(int delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { - // just play loaded sound - if (filename == NULL && _sFX) { - if (_gameRef->_editorMode || _sFXStart) { - _sFX->setVolumePercent(_sFXVolume); - _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) _sFXStart = 0; - } - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } - - if (filename == NULL) return STATUS_FAILED; - - // create new sound - delete _sFX; - - _sFX = new CBSound(_gameRef); - if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { - _sFX->setVolumePercent(_sFXVolume); - if (_sFXStart) { - _sFX->setPositionTime(_sFXStart); - _sFXStart = 0; - } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } else { - delete _sFX; - _sFX = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::stopSFX(bool deleteSound) { - if (_sFX) { - _sFX->stop(); - if (deleteSound) { - delete _sFX; - _sFX = NULL; - } - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::pauseSFX() { - if (_sFX) return _sFX->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resumeSFX() { - if (_sFX) return _sFX->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXTime(uint32 time) { - _sFXStart = time; - if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXVolume(int volume) { - _sFXVolume = volume; - if (_sFX) return _sFX->setVolumePercent(volume); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->isPlaying()) { - applyEvent(_soundEvent); - setSoundEvent(NULL); - } - } - - if (_sFX) updateOneSound(_sFX); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateOneSound(CBSound *sound) { - bool Ret = STATUS_OK; - - if (sound) { - if (_autoSoundPanning) - Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); - - Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - } - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resetSoundPan() { - if (!_sFX) return STATUS_OK; - else { - return _sFX->setPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::getExtendedFlag(const char *flagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::isReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setSoundEvent(const char *eventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (eventName) { - _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, eventName); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::afterMove() { - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BObject.h b/engines/wintermute/base/BObject.h deleted file mode 100644 index c855c770b7..0000000000 --- a/engines/wintermute/base/BObject.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H - - -#include "engines/wintermute/base/BScriptHolder.h" -#include "engines/wintermute/persistent.h" -#include "common/events.h" - -namespace WinterMute { - -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(CBSound *sound); - bool _autoSoundPanning; - uint32 _sFXStart; - int _sFXVolume; - bool setSFXTime(uint32 time); - bool setSFXVolume(int volume); - bool resumeSFX(); - bool pauseSFX(); - bool stopSFX(bool deleteSound = true); - bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - CBSound *_sFX; - - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - - virtual bool handleMouseWheel(int delta); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual int getHeight(); - bool setCursor(const char *filename); - bool setActiveCursor(const char *filename); - bool cleanup(); - const char *getCaption(int caseVal = 1); - void setCaption(const char *caption, int caseVal = 1); - bool _editorSelected; - bool _editorAlwaysRegister; - bool _editorOnly; - bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual bool showCursor(); - CBSprite *_cursor; - bool _sharedCursors; - CBSprite *_activeCursor; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; - bool _zoomable; - bool _shadowable; - Rect32 _rect; - bool _rectSet; - int _iD; - bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); - char *_caption[7]; - char *_soundEvent; - int _posY; - int _posX; - bool _saveState; - - // base - virtual bool update() { - return STATUS_FAILED; - }; - virtual bool display() { - return STATUS_FAILED; - }; - virtual bool invalidateDeviceObjects() { - return STATUS_OK; - }; - virtual bool restoreDeviceObjects() { - return STATUS_OK; - }; - bool _nonIntMouseEvents; - - -public: - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp deleted file mode 100644 index 80d3b58213..0000000000 --- a/engines/wintermute/base/BParser.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/util.h" - -#define WHITESPACE " \t\n\r" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { - skipCharacters(buf, _whiteSpace); - - // skip comment lines. - while (**buf == ';') { - *buf = strchr(*buf, '\n'); - _parserLine++; - skipCharacters(buf, _whiteSpace); - } - - if (! **buf) // at end of file - return PARSERR_EOF; - - // find the token. - // for now just use brute force. Improve later. - while (tokens->id != 0) { - if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { - // here we could be matching PART of a string - // we could detect this here or the token list - // could just have the longer tokens first in the list - break; - } - ++tokens; - } - if (tokens->id == 0) { - char *p = strchr(*buf, '\n'); - if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); - - return PARSERR_TOKENNOTFOUND; - } - // skip the token - *buf += strlen(tokens->token); - skipCharacters(buf, _whiteSpace); - - // get optional name - *name = getSubText(buf, '\'', '\''); // single quotes - skipCharacters(buf, _whiteSpace); - - // get optional data - if (**buf == '=') // An assignment rather than a command/object. - *data = getAssignmentText(buf); - else - *data = getSubText(buf, '{', '}'); - - return tokens->id; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; - _gameRef->miniUpdate(); - char *name; - return getObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipCharacters(char **buf, const char *toSkip) { - char ch; - while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) - return; - ++*buf; // skip this character - } - // we must be at the end of the buffer if we get here -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) - return 0; - ++*buf; // skip opening delimiter - char *result = *buf; - - // now find the closing delimiter - char theChar; - long skip = 1; - - if (open == close) // we cant nest identical delimiters - open = 0; - while ((theChar = **buf) != 0) { - if (theChar == open) - ++skip; - if (theChar == close) { - if (--skip == 0) { - **buf = 0; // null terminate the result string - ++*buf; // move past the closing delimiter - break; - } - } - ++*buf; // try next character - } - return result; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getAssignmentText(char **buf) { - ++*buf; // skip the '=' - skipCharacters(buf, _whiteSpace); - char *result = *buf; - - - if (*result == '"') { - result = getSubText(buf, '"', '"'); - } else { - // now, we need to find the next whitespace to end the data - char theChar; - - while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars - break; - ++*buf; - } - **buf = 0; // null terminate it - if (theChar) // skip the terminator - ++*buf; - } - - return result; -} - - -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -char *CBParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; - while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; - if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; - } - - if (*b == '\'') { - b++; - while (*b && *b != '\'') { - *t++ = *b++; - } - *t++ = 0; - if (*b == '\'') b++; - } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || - *b == '%' || *b == ':' || *b == '{' || *b == '}') { - *t++ = *b++; - *t++ = 0; - } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { - *t++ = *b++; - *t++ = 0; - } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { - while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { - *t++ = *b++; - } - *t++ = 0; - } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { - while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { - *t++ = *b++; - } - *t++ = 0; - } else if (*b == 0) { - *buf = b; - return NULL; - } else { - // Error. - return NULL; - } - - *buf = b; - return token; -} - - -////////////////////////////////////////////////////////////////////// -float CBParser::getTokenFloat(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { - // Error situation. We handle this by return 0. - return 0.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::getTokenInt(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-')) { - // Error situation. We handle this by return 0. - return 0; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); - if (strcmp(t, tok)) return; // Error -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::scanStr(const char *in, const char *format, ...) { - va_list arg; - va_start(arg, format); - - int num = 0; - in += strspn(in, " \t\n\f"); - - while (*format && *in) { - if (*format == '%') { - format++; - switch (*format) { - case 'd': { - int *a = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - *a = atoi(in); - in += strspn(in, "0123456789+- \t\n\f"); - num++; - break; - } - case 'D': { - int i; - int *list = va_arg(arg, int *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { - list[i++] = atoi(in); - in += strspn(in, "0123456789+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 'b': { - bool *a = va_arg(arg, bool *); - in += strspn(in, " \t\n\f"); - const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - int l = (int)(in2 - in); - - *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || - !scumm_strnicmp(in, "1", l)); - - - in = in2 + strspn(in2, " \t\n\f"); - num++; - break; - } - case 'f': { - float *a = va_arg(arg, float *); - in += strspn(in, " \t\n\f"); - *a = (float)atof(in); - in += strspn(in, "0123456789.eE+- \t\n\f"); - num++; - break; - } - case 'F': { - int i; - float *list = va_arg(arg, float *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { - list[i++] = (float)atof(in); - in += strspn(in, "0123456789.eE+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 's': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\'') { - in++; - const char *in2 = strchr(in, '\''); - if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2; - } - in += strspn(in, " \t\n\f"); - num++; - break; - } - case 'S': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\"') { - in++; - while (*in != '\"') { - if (*in == '\\') { - in++; - switch (*in) { - case '\\': - *a++ = '\\'; - break; - case 'n': - *a++ = '\n'; - break; - case 'r': - *a++ = '\r'; - break; - case 't': - *a++ = '\t'; - break; - case '"': - *a++ = '"'; - break; - default: - *a++ = '\\'; - *a++ = *in; - break; - } //switch - in++; - } else { - *a++ = *in++; - } - } //while in string - in++; - num++; - } //if string started - - //terminate string - *a = '\0'; - break; - } - } - if (*format) format++; - } else if (*format == ' ') { - format++; - in += strspn(in, " \t\n\f"); - } else if (*in == *format) { - in++; - format++; - } else { - num = -1; - break; - } - } - - va_end(arg); - - return num; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BParser.h b/engines/wintermute/base/BParser.h deleted file mode 100644 index ae886953a9..0000000000 --- a/engines/wintermute/base/BParser.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H - - -#define TOKEN_DEF_START \ - enum \ - { \ - TOKEN_NONE = 0, -#define TOKEN_DEF(name) \ - TOKEN_ ## name, -#define TOKEN_DEF_END \ - TOKEN_TOTAL_COUNT \ - }; -#define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ - { -#define TOKEN_TABLE(name) \ - { TOKEN_ ## name, #name }, -#define TOKEN_TABLE_END \ - { 0, 0 } \ - }; - -#define PARSERR_GENERIC -3 -#define PARSERR_EOF -2 -#define PARSERR_TOKENNOTFOUND -1 - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBParser : public CBBase { -public: - struct TokenDesc { - int32 id; - const char *token; - }; - -public: - int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); -private: - char *getLastOffender(); - void skipToken(char **buf, char *tok, char *msg = NULL); - int getTokenInt(char **buf); - float getTokenFloat(char **buf); - char *getToken(char **buf); - char *getAssignmentText(char **buf); - char *getSubText(char **buf, char open, char close); - void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - char *_whiteSpace; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp deleted file mode 100644 index f8faced95f..0000000000 --- a/engines/wintermute/base/BPersistMgr.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BPersistMgr.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BSound.h" -#include "graphics/decoders/bmp.h" -#include "common/memstream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/savefile.h" - -namespace WinterMute { - -#define SAVE_BUFFER_INIT_SIZE 100000 -#define SAVE_BUFFER_GROW_BY 50000 - -#define SAVE_MAGIC 0x45564153 -#define SAVE_MAGIC_2 0x32564153 - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { - _saving = false; -// _buffer = NULL; -// _bufferSize = 0; - _offset = 0; - _saveStream = NULL; - _loadStream = NULL; - - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - _thumbnailData = NULL; - if (savePrefix) { - _savePrefix = savePrefix; - } else if (_gameRef) { - _savePrefix = _gameRef->getGameId(); - } else { - _savePrefix = "wmesav"; - } -} - - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::cleanup() { - /* if (_buffer) { - if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0;*/ - _offset = 0; - - delete[] _richBuffer; - _richBuffer = NULL; - _richBufferSize = 0; - - delete[] _savedDescription; - _savedDescription = NULL; // ref to buffer -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - if (_thumbnailData) { - delete [] _thumbnailData; - _thumbnailData = NULL; - } - - delete _loadStream; - delete _saveStream; - _loadStream = NULL; - _saveStream = NULL; -} - -Common::String CBPersistMgr::getFilenameForSlot(int slot) const { - // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) - return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); -} - -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); - return; - } - desc.setSaveSlot(slot); - desc.setDescription(_savedDescription); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - - if (_thumbnailDataSize > 0) { - Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); - Graphics::BitmapDecoder bmpDecoder; - if (bmpDecoder.loadStream(thumbStream)) { - Graphics::Surface *surf = new Graphics::Surface; - surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); - desc.setThumbnail(surf); - } - } - - desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); - desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); - desc.setPlayTime(0); -} - -void CBPersistMgr::deleteSaveSlot(int slot) { - Common::String filename = getFilenameForSlot(slot); - g_system->getSavefileManager()->removeSavefile(filename); -} - -uint32 CBPersistMgr::getMaxUsedSlot() { - Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); - Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); - Common::StringArray::iterator it = saves.begin(); - int ret = -1; - for (; it != saves.end(); it++) { - int num = -1; - sscanf(it->c_str(), "save%d", &num); - ret = MAX(ret, num); - } - return ret; -} - -bool CBPersistMgr::getSaveExists(int slot) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initSave(const char *desc) { - if (!desc) return STATUS_FAILED; - - cleanup(); - _saving = true; - - _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - - if (_saveStream) { - // get thumbnails - if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); - if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - } - } - - uint32 magic = DCGF_MAGIC; - putDWORD(magic); - - magic = SAVE_MAGIC_2; - putDWORD(magic); - - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(VerMajor); - _saveStream->writeByte(VerMinor); - _saveStream->writeByte(ExtMajor); - _saveStream->writeByte(ExtMinor); - - // new in ver 2 - putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->_name); - - // thumbnail data size - bool thumbnailOK = false; - - if (_gameRef->_cachedThumbnail) { - if (_gameRef->_cachedThumbnail->_thumbnail) { - Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); - if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { - _saveStream->writeUint32LE(thumbStream.size()); - _saveStream->write(thumbStream.getData(), thumbStream.size()); - } else { - _saveStream->writeUint32LE(0); - } - - thumbnailOK = true; - } - } - if (!thumbnailOK) putDWORD(0); - - // in any case, destroy the cached thumbnail once used - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - - uint32 dataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(desc) + 1 + // description - sizeof(uint32); // timestamp - - putDWORD(dataOffset); - putString(desc); - - g_system->getTimeAndDate(_savedTimestamp); - putTimeDate(_savedTimestamp); - _savedPlayTime = g_system->getMillis(); - _saveStream->writeUint32LE(_savedPlayTime); - } - return STATUS_OK; -} - -bool CBPersistMgr::readHeader(const Common::String &filename) { - cleanup(); - - _saving = false; - - _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); - if (_loadStream) { - uint32 magic; - magic = getDWORD(); - - if (magic != DCGF_MAGIC) { - cleanup(); - return STATUS_FAILED; - } - - magic = getDWORD(); - - if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { - _savedVerMajor = _loadStream->readByte(); - _savedVerMinor = _loadStream->readByte(); - _savedExtMajor = _loadStream->readByte(); - _savedExtMinor = _loadStream->readByte(); - - if (magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)getDWORD(); - _savedName = getStringObj(); - - // load thumbnail - _thumbnailDataSize = getDWORD(); - if (_thumbnailDataSize > 0) { - _thumbnailData = new byte[_thumbnailDataSize]; - if (_thumbnailData) { - getBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; - } - } else _savedVerBuild = 35; // last build with ver1 savegames - - uint32 dataOffset = getDWORD(); - - _savedDescription = getString(); - _savedTimestamp = getTimeDate(); - _savedPlayTime = _loadStream->readUint32LE(); - - _offset = dataOffset; - - return STATUS_OK; - } - } - - cleanup(); - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initLoad(const char *filename) { - if (DID_FAIL(readHeader(filename))) { - cleanup(); - return STATUS_FAILED; - } - _saving = false; - - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { - _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); - cleanup(); - return STATUS_FAILED; - } - - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - } - - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - - } - - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::saveFile(const char *filename) { - return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { - _saveStream->write(buffer, size); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { - _loadStream->read(buffer, size); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putDWORD(uint32 val) { - _saveStream->writeUint32LE(val); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::getDWORD() { - uint32 ret = _loadStream->readUint32LE(); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putString(const Common::String &val) { - if (!val.size()) putString("(null)"); - else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); - } -} - -Common::String CBPersistMgr::getStringObj() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - Common::String retString = ret; - delete[] ret; - - if (retString == "(null)") { - retString = ""; - } - - return retString; -} - -////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::getString() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - if (!strcmp(ret, "(null)")) { - delete[] ret; - return NULL; - } else return ret; -} - -bool CBPersistMgr::putTimeDate(const TimeDate &t) { - _saveStream->writeSint32LE(t.tm_sec); - _saveStream->writeSint32LE(t.tm_min); - _saveStream->writeSint32LE(t.tm_hour); - _saveStream->writeSint32LE(t.tm_mday); - _saveStream->writeSint32LE(t.tm_mon); - _saveStream->writeSint32LE(t.tm_year); - // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next - - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -TimeDate CBPersistMgr::getTimeDate() { - TimeDate t; - t.tm_sec = _loadStream->readSint32LE(); - t.tm_min = _loadStream->readSint32LE(); - t.tm_hour = _loadStream->readSint32LE(); - t.tm_mday = _loadStream->readSint32LE(); - t.tm_mon = _loadStream->readSint32LE(); - t.tm_year = _loadStream->readSint32LE(); - // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next - return t; -} - -void CBPersistMgr::putFloat(float val) { - Common::String str = Common::String::format("F%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -float CBPersistMgr::getFloat() { - char *str = getString(); - float value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -void CBPersistMgr::putDouble(double val) { - Common::String str = Common::String::format("F%f", val); - str.format("D%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -double CBPersistMgr::getDouble() { - char *str = getString(); - double value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -////////////////////////////////////////////////////////////////////////// -// bool -bool CBPersistMgr::transfer(const char *name, bool *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// int -bool CBPersistMgr::transfer(const char *name, int *val) { - if (_saving) { - _saveStream->writeSint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// DWORD -bool CBPersistMgr::transfer(const char *name, uint32 *val) { - if (_saving) { - _saveStream->writeUint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readUint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// float -bool CBPersistMgr::transfer(const char *name, float *val) { - if (_saving) { - putFloat(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// double -bool CBPersistMgr::transfer(const char *name, double *val) { - if (_saving) { - putDouble(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getDouble(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// char* -bool CBPersistMgr::transfer(const char *name, char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// const char* -bool CBPersistMgr::transfer(const char *name, const char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// Common::String -bool CBPersistMgr::transfer(const char *name, Common::String *val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - *val = str; - delete[] str; - } else { - *val = ""; - } - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { - size_t size; - - if (_saving) { - size = val.size(); - _saveStream->writeUint32LE(size); - - for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { - putString((*it).c_str()); - } - } else { - val.clear(); - size = _loadStream->readUint32LE(); - - for (size_t i = 0; i < size; i++) { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) val.push_back(str); - delete[] str; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// BYTE -bool CBPersistMgr::transfer(const char *name, byte *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// RECT -bool CBPersistMgr::transfer(const char *name, Rect32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->left); - _saveStream->writeSint32LE(val->top); - _saveStream->writeSint32LE(val->right); - _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->left = _loadStream->readSint32LE(); - val->top = _loadStream->readSint32LE(); - val->right = _loadStream->readSint32LE(); - val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// POINT -bool CBPersistMgr::transfer(const char *name, Point32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->x); - _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = _loadStream->readSint32LE(); - val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// Vector2 -bool CBPersistMgr::transfer(const char *name, Vector2 *val) { - if (_saving) { - putFloat(val->x); - putFloat(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = getFloat(); - val->y = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// generic pointer -bool CBPersistMgr::transfer(const char *name, void *val) { - int classID = -1, instanceID = -1; - - if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); - if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - _gameRef->LOG(0, "Warning: invalid instance '%s'", name); - } - - _saveStream->writeUint32LE(classID); - _saveStream->writeUint32LE(instanceID); - } else { - classID = _loadStream->readUint32LE(); - instanceID = _loadStream->readUint32LE(); - - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) return true; - - // it's ok if we are same or newer than the saved game - if (verMajor > _savedVerMajor || - (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || - (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPersistMgr.h b/engines/wintermute/base/BPersistMgr.h deleted file mode 100644 index 2e6ee8058c..0000000000 --- a/engines/wintermute/base/BPersistMgr.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/savestate.h" -#include "common/stream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/rect.h" - -namespace WinterMute { - -class Vector2; - -class CBPersistMgr : public CBBase { -public: - char *_savedDescription; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; - Common::String _savePrefix; - Common::String _savedName; - bool saveFile(const char *filename); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - Common::String getStringObj(); - void putString(const Common::String &val); - float getFloat(); - void putFloat(float val); - double getDouble(); - void putDouble(double val); - void cleanup(); - void getSaveStateDesc(int slot, SaveStateDescriptor &desc); - void deleteSaveSlot(int slot); - uint32 getMaxUsedSlot(); - bool getSaveExists(int slot); - bool initLoad(const char *filename); - bool initSave(const char *desc); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 _offset; - - bool _saving; - - uint32 _richBufferSize; - byte *_richBuffer; - - bool transfer(const char *name, void *val); - bool transfer(const char *name, int *val); - bool transfer(const char *name, uint32 *val); - bool transfer(const char *name, float *val); - bool transfer(const char *name, double *val); - bool transfer(const char *name, bool *val); - bool transfer(const char *name, byte *val); - bool transfer(const char *name, Rect32 *val); - bool transfer(const char *name, Point32 *val); - bool transfer(const char *name, const char **val); - bool transfer(const char *name, char **val); - bool transfer(const char *name, Common::String *val); - bool transfer(const char *name, Vector2 *val); - bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); - virtual ~CBPersistMgr(); - bool checkVersion(byte verMajor, byte verMinor, byte verBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - Common::String getFilenameForSlot(int slot) const; -private: - bool readHeader(const Common::String &filename); - TimeDate getTimeDate(); - bool putTimeDate(const TimeDate &t); - Common::WriteStream *_saveStream; - Common::SeekableReadStream *_loadStream; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BPoint.cpp b/engines/wintermute/base/BPoint.cpp deleted file mode 100644 index 4c80e154f2..0000000000 --- a/engines/wintermute/base/BPoint.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBPoint, false) - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPoint::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPoint.h b/engines/wintermute/base/BPoint.h deleted file mode 100644 index 3e4adb5d13..0000000000 --- a/engines/wintermute/base/BPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPoint: public CBBase { -public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); - int y; - int x; - virtual ~CBPoint(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BQuickMsg.cpp b/engines/wintermute/base/BQuickMsg.cpp deleted file mode 100644 index 32bd04afe2..0000000000 --- a/engines/wintermute/base/BQuickMsg.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BQuickMsg.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { - _text = new char [strlen(text) + 1]; - if (_text) strcpy(_text, text); - _startTime = _gameRef->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { - if (_text) delete [] _text; -} - - -////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::getText() { - return _text; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BQuickMsg.h b/engines/wintermute/base/BQuickMsg.h deleted file mode 100644 index c247183714..0000000000 --- a/engines/wintermute/base/BQuickMsg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBQuickMsg : public CBBase { -public: - char *getText(); - uint32 _startTime; - char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp deleted file mode 100644 index c8ec87e04a..0000000000 --- a/engines/wintermute/base/BRegion.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBRegion, false) - -////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - CBPlatform::setRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::createRegion() { - return DID_SUCCEED(getBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) return false; - - Point32 pt; - pt.x = x; - pt.y = y; - - Rect32 rect; - rect.left = x - 1; - rect.right = x + 2; - rect.top = y - 1; - rect.bottom = y + 2; - - if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(POINT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(POINT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int i; - - for (i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // AddPoint - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AddPoint") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - _points.add(new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points[Index]->x = x; - _points[Index]->y = y; - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemovePoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemovePoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - delete _points[index]; - _points[index] = NULL; - - _points.removeAt(index); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - CScValue *val = stack->getPushValue(); - if (val) { - val->setProperty("X", _points[index]->x); - val->setProperty("Y", _points[index]->y); - } - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.getSize()); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBRegion::scToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", nameOverride); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -typedef struct { - double x, y; -} dPoint; - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) return false; - - int counter = 0; - double xinters; - dPoint p, p1, p2; - - p.x = (double)x; - p.y = (double)y; - - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; - - for (int i = 1; i <= _points.getSize(); i++) { - p2.x = (double)_points[i % _points.getSize()]->x; - p2.y = (double)_points[i % _points.getSize()]->y; - - if (p.y > MIN(p1.y, p2.y)) { - if (p.y <= MAX(p1.y, p2.y)) { - if (p.x <= MAX(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) - counter++; - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) - return false; - else - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); - else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - - for (int i = 0; i < _points.getSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); - - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); - } - CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; - - cleanup(); - - for (int i = 0; i < region->_points.getSize(); i++) { - int xVal, yVal; - - xVal = (int)((float)region->_points[i]->x * scale / 100.0f); - yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - - _points.add(new CBPoint(xVal + x, yVal + y)); - } - - _lastMimicScale = scale; - _lastMimicX = x; - _lastMimicY = y; - - return createRegion() ? STATUS_OK : STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegion.h b/engines/wintermute/base/BRegion.h deleted file mode 100644 index 2a92d9daff..0000000000 --- a/engines/wintermute/base/BRegion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H - -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CBRegion : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - bool getBoundingRect(Rect32 *rect); - bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(CBRegion, CBObject) - bool _active; - int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); - bool pointInRegion(int x, int y); - bool createRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - Rect32 _rect; - CBArray _points; - virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BRegistry.cpp b/engines/wintermute/base/BRegistry.cpp deleted file mode 100644 index fef09d7479..0000000000 --- a/engines/wintermute/base/BRegistry.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/utils.h" -#include "common/config-manager.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { - _iniName = NULL; - - setIniName("./wme.ini"); - loadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { - saveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - - bool found = false; - ret = getValue(_localValues, subKey, key, found); - if (!found) ret = getValue(_values, subKey, key, found); - if (!found) ret = init; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - if (ConfMan.hasKey("master_volume")) { - return ConfMan.getInt("master_volume"); - } else { - return init; - } - } else if (key == "SFXVolume") { - if (ConfMan.hasKey("sfx_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "SpeechVolume") { - if (ConfMan.hasKey("speech_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "MusicVolume") { - if (ConfMan.hasKey("music_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } - } - AnsiString val = readString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - ConfMan.setInt("master_volume", value); - return true; - } else if (key == "SFXVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "SpeechVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "MusicVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } - } - writeString(subKey, key, StringUtil::toString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (readInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return writeInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setIniName(const char *name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { - _iniName = new char [strlen(name) + 3]; - sprintf(_iniName, "./%s", name); - } else { - _iniName = new char [strlen(name) + 1]; - strcpy(_iniName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBRegistry::getIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadValues(bool local) { - if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveValues() { - saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setBasePath(const char *basePath) { - _basePath = PathUtil::getFileNameWithoutExtension(basePath); - - loadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::createPath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - Common::DumpFile stream; - stream.open(fileName.c_str()); - - if (!stream.isOpen()) return; - else { - stream.write(printer.CStr(), printer.Size()); - stream.close(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegistry.h b/engines/wintermute/base/BRegistry.h deleted file mode 100644 index 123d1d8a2f..0000000000 --- a/engines/wintermute/base/BRegistry.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBRegistry : public CBBase { -public: - void setIniName(const char *name); - char *getIniName(); - bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); - int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); - - void setBasePath(const char *basePath); - AnsiString getBasePath() const { - return _basePath; - } - - void loadValues(bool local); - void saveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void loadXml(const AnsiString fileName, PathValueMap &values); - void saveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp deleted file mode 100644 index 839be570c5..0000000000 --- a/engines/wintermute/base/BResources.cpp +++ /dev/null @@ -1,2820 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BResources.h" -#include "common/str.h" -#include "common/memstream.h" - -namespace WinterMute { - -unsigned char invalid[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} ; - -unsigned char invaliddebug[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, - 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, - 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, - 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, - 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, - 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, - 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, - 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, - 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, - 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, - 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, - 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, - 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, - 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, - 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, - 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, - 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, - 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, - 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, - 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, - 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, - 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, - 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, - 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, - 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, - 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, - 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, - 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, - 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, - 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, - 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, - 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, - 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, - 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, - 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, - 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, - 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, - 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, - 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, - 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, - 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, - 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, - 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, - 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, - 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, - 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, - 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, - 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, - 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, - 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, - 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, - 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, - 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, - 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, - 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, - 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, - 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, - 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 -} ; - -unsigned char systemfont[] = { - 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -} ; - -Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { - if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { - return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { - return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { - return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BResources.h b/engines/wintermute/base/BResources.h deleted file mode 100644 index 6ec0541b5c..0000000000 --- a/engines/wintermute/base/BResources.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H - -#include "common/stream.h" -#include "common/str.h" - -namespace WinterMute { - -class CBResources { -public: - static Common::SeekableReadStream *getFile(const Common::String &fileName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSaveThumbHelper.cpp b/engines/wintermute/base/BSaveThumbHelper.cpp deleted file mode 100644 index 415d4ed1e4..0000000000 --- a/engines/wintermute/base/BSaveThumbHelper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { - delete _thumbnail; - _thumbnail = NULL; - - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - if (doFlip) { - // when using opengl on windows it seems to be necessary to do this twice - // works normally for direct3d - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - } - - CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) return STATUS_FAILED; - - // normal thumbnail - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new CBImage(_gameRef); - _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); - } - - - delete screenshot; - screenshot = NULL; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSaveThumbHelper.h b/engines/wintermute/base/BSaveThumbHelper.h deleted file mode 100644 index 30db32cfb2..0000000000 --- a/engines/wintermute/base/BSaveThumbHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBImage; - -class CBSaveThumbHelper : public CBBase { -public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); - bool storeThumbnail(bool doFlip = false); - - CBImage *_thumbnail; - CBImage *_richThumbnail; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BScriptHolder.cpp b/engines/wintermute/base/BScriptHolder.cpp deleted file mode 100644 index 65d37b2e5c..0000000000 --- a/engines/wintermute/base/BScriptHolder.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/base/BScriptHolder.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { - setName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::cleanup() { - delete[] _filename; - _filename = NULL; - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) delete [] _filename; - - _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) strcpy(_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { - int numHandlers = 0; - - bool ret = STATUS_FAILED; - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); - if (handler) { - //_scripts.add(handler); - numHandlers++; - ret = STATUS_OK; - } - } - } - if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // DEBUG_CrashMe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "DEBUG_CrashMe") == 0) { - stack->correctParams(0); - byte *p = 0; - *p = 10; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ApplyEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ApplyEvent") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - bool ret; - ret = applyEvent(val->getString()); - - if (DID_SUCCEED(ret)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleEvent") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleEvent(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleMethod - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleMethod") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleMethod(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AttachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AttachScript") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DetachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DetachScript") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool killThreads = stack->pop()->getBool(false); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - _scripts[i]->finish(killThreads); - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScriptRunning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScriptRunning") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("script_holder"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::scToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { - return CBBase::saveAsText(buffer, indent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_name)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); - return STATUS_OK; - } - } - } - - CScScript *scr = _gameRef->_scEngine->runScript(filename, this); - if (!scr) { - if (_gameRef->_editorForceScripts) { - // editor hack - scr = new CScScript(_gameRef, _gameRef->_scEngine); - scr->_filename = new char[strlen(filename) + 1]; - strcpy(scr->_filename, filename); - scr->_state = SCRIPT_ERROR; - scr->_owner = this; - _scripts.add(scr); - _gameRef->_scEngine->_scripts.add(scr); - _gameRef->getDebugMgr()->onScriptInit(scr); - - return STATUS_OK; - } - return STATUS_FAILED; - } else { - scr->_freezable = _freezable; - _scripts.add(scr); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::removeScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) { - _scripts.removeAt(i); - break; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; - } - return false; -} - - -TOKEN_DEF_START -TOKEN_DEF(PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - _gameRef->LOG(0, "'PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading PROPERTY definition"); - return STATUS_FAILED; - } - - - CScValue *val = new CScValue(_gameRef); - val->setString(propValue); - scSetProperty(propName, val); - - delete val; - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool freezable) { - _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->_freezable = freezable; - -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.getSize() - 1; i >= 0; i--) { - if (_scripts[i]->canHandleMethod(methodName)) { - - CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); - if (thread) { - bool ret = thread->createMethodThread(_scripts[i], methodName); - if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); - - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); - if (_name && strcmp(_name, "") != 0) { - strcat(buf, " Name: "); - strcat(buf, _name); - } - if (_filename) { - strcat(buf, " File: "); - strcat(buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *eventName) { - return DID_SUCCEED(applyEvent(eventName)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptHolder.h b/engines/wintermute/base/BScriptHolder.h deleted file mode 100644 index 1e82b8cacf..0000000000 --- a/engines/wintermute/base/BScriptHolder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CBScriptHolder : public CBScriptable { -public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) - - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *methodName); - virtual void makeFreezable(bool freezable); - bool canHandleEvent(const char *eventName); - virtual bool canHandleMethod(const char *eventMethod); - bool cleanup(); - bool removeScript(CScScript *script); - bool addScript(const char *filename); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool applyEvent(const char *eventName, bool unbreakable = false); - void setFilename(const char *filename); - bool parseProperty(byte *buffer, bool complete = true); - char *_filename; - bool _freezable; - bool _ready; - - CBArray _scripts; - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void scDebuggerDesc(char *buf, int bufSize); - // IWmeObject -public: - virtual bool sendEvent(const char *eventName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BScriptable.cpp b/engines/wintermute/base/BScriptable.cpp deleted file mode 100644 index d1e3556a85..0000000000 --- a/engines/wintermute/base/BScriptable.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptable, false) - -////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { - _refCount = 0; - - if (noValue) _scValue = NULL; - else _scValue = new CScValue(_gameRef); - - _persistable = persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { - //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); - delete _scValue; - delete _scProp; - _scValue = NULL; - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - /* - stack->correctParams(0); - stack->pushNULL(); - script->runtimeError("Call to undefined method '%s'.", name); - - return STATUS_OK; - */ - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->getProp(name); - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->setProp(name, value); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::scToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *CBScriptable::scToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double CBScriptable::scToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetString(const char *val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetInt(int val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetFloat(double val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetBool(bool val) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); - persistMgr->transfer(TMEMBER(_scProp)); - persistMgr->transfer(TMEMBER(_scValue)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *val) { - if (this < val) return -1; - else if (this > val) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::canHandleMethod(const char *eventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::invokeMethodThread(const char *methodName) { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::dbgGetNativeClass() { - return getClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { - return scGetProperty(name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptable.h b/engines/wintermute/base/BScriptable.h deleted file mode 100644 index 534bd3bdf1..0000000000 --- a/engines/wintermute/base/BScriptable.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H - - -#include "engines/wintermute/base/BNamedObject.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CScStack; -class CScScript; - -class CBScriptable : public CBNamedObject, public IWmeDebugObject { -public: - virtual CScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) - - CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); - virtual ~CBScriptable(); - - // high level scripting interface - virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void *scToMemBuffer(); - virtual int scToInt(); - virtual double scToFloat(); - virtual bool scToBool(); - virtual void scSetString(const char *val); - virtual void scSetInt(int val); - virtual void scSetFloat(double val); - virtual void scSetBool(bool val); - virtual int scCompare(CBScriptable *val); - virtual void scDebuggerDesc(char *buf, int bufSize); - int _refCount; - CScValue *_scValue; - CScValue *_scProp; - -public: - // IWmeDebugObject - const char *dbgGetNativeClass(); - IWmeDebugProp *dbgGetProperty(const char *name); - -}; - -// Implemented in their respective .cpp-files -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXMath(CBGame *inGame); -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXStore(CBGame *inGame); -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSound.cpp b/engines/wintermute/base/BSound.cpp deleted file mode 100644 index 2b54b39500..0000000000 --- a/engines/wintermute/base/BSound.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSoundBuffer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSound, false) - -////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { - _sound = NULL; - _soundFilename = NULL; - - _soundType = Audio::Mixer::kSFXSoundType; - _soundStreamed = false; - _soundLooping = false; - _soundPlaying = false; - _soundPaused = false; - _soundFreezePaused = false; - _soundPosition = 0; - _soundPrivateVolume = 0; - _soundLoopStart = 0; - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { - if (_sound) _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - } - delete[] _soundFilename; - _soundFilename = NULL; - - _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); - if (_sound) { - _soundFilename = new char[strlen(filename) + 1]; - strcpy(_soundFilename, filename); - - _soundType = type; - _soundStreamed = streamed; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSoundSimple() { - _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); - if (_sound) { - if (_soundPosition) _sound->setPosition(_soundPosition); - _sound->setLooping(_soundLooping); - _sound->setPrivateVolume(_soundPrivateVolume); - _sound->setLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->resume(); - else return STATUS_OK; - } else return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getLength() { - if (_sound) return _sound->getLength(); - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::play(bool looping) { - if (_sound) { - _soundPaused = false; - return _sound->play(looping, _soundPosition); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::stop() { - if (_sound) { - _soundPaused = false; - return _sound->stop(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::pause(bool freezePaused) { - if (_sound) { - _soundPaused = true; - if (freezePaused) _sound->_freezePaused = true; - return _sound->pause(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->resume(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::persist(CBPersistMgr *persistMgr) { - if (persistMgr->_saving && _sound) { - _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) - _soundPosition = _sound->getPosition(); - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (persistMgr->_saving) { - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - } - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_soundFilename)); - persistMgr->transfer(TMEMBER(_soundLooping)); - persistMgr->transfer(TMEMBER(_soundPaused)); - persistMgr->transfer(TMEMBER(_soundFreezePaused)); - persistMgr->transfer(TMEMBER(_soundPlaying)); - persistMgr->transfer(TMEMBER(_soundPosition)); - persistMgr->transfer(TMEMBER(_soundPrivateVolume)); - persistMgr->transfer(TMEMBER(_soundStreamed)); - persistMgr->transfer(TMEMBER_INT(_soundType)); - persistMgr->transfer(TMEMBER(_soundLoopStart)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPlaying() { - return _sound && _sound->isPlaying(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPaused() { - return _sound && _soundPaused; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPositionTime(uint32 time) { - if (!_sound) return STATUS_FAILED; - _soundPosition = time; - bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) - _soundPosition = 0; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getPositionTime() { - if (!_sound) return 0; - - if (!_sound->isPlaying()) - return 0; - else return _sound->getPosition(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolumePercent(int percent) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(percent * 255 / 100); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(volume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPrivateVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->_privateVolume = volume; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolumePercent() { - if (!_sound) - return 0; - else return _sound->_privateVolume * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolume() { - if (!_sound) - return 0; - else return _sound->_privateVolume; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setLoopStart(uint32 pos) { - if (!_sound) - return STATUS_FAILED; - else { - _sound->setLoopStart(pos); - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPan(float pan) { - if (_sound) - return _sound->setPan(pan); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) - return STATUS_OK; - - if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - bool ret = _sound->applyFX(type, param1, param2, param3, param4); - - _sFXType = type; - _sFXParam1 = param1; - _sFXParam2 = param2; - _sFXParam3 = param3; - _sFXParam4 = param4; - - return ret; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSound.h b/engines/wintermute/base/BSound.h deleted file mode 100644 index 9dc825e4ac..0000000000 --- a/engines/wintermute/base/BSound.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "audio/mixer.h" - -namespace WinterMute { - -class CBSoundBuffer; -class CBSound : public CBBase { -public: - bool setPan(float pan); - int _soundPrivateVolume; - int getVolume(); - int getVolumePercent(); - bool setVolumePercent(int percent); - bool setVolume(int volume); - bool setPrivateVolume(int volume); - bool setLoopStart(uint32 pos); - uint32 getPositionTime(); - bool setPositionTime(uint32 time); - bool _soundPaused; - bool _soundFreezePaused; - bool isPlaying(); - bool isPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) - bool resume(); - bool pause(bool freezePaused = false); - bool stop(); - bool play(bool looping = false); - uint32 getLength(); - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - char *_soundFilename; - bool setSoundSimple(); - bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); - - bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); - -private: - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - CBSoundBuffer *_sound; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSoundBuffer.cpp b/engines/wintermute/base/BSoundBuffer.cpp deleted file mode 100644 index 4808cc9007..0000000000 --- a/engines/wintermute/base/BSoundBuffer.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSoundBuffer.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/vorbis.h" -#include "audio/decoders/wave.h" -#include "audio/decoders/raw.h" -#include "common/system.h" -#include "common/substream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { - _stream = NULL; - _handle = NULL; -// _sync = NULL; - - _streamed = false; - _filename = NULL; - _file = NULL; - _privateVolume = 255; - _volume = 255; - - _looping = false; - _loopStart = 0; - - _type = Audio::Mixer::kSFXSoundType; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { - stop(); - - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - delete _stream; - _stream = NULL; - - delete[] _filename; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { - _streamed = Streamed; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif - - // Load a file, but avoid having the File-manager handle the disposal of it. - _file = _gameRef->_fileManager->openFile(filename, true, false); - if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - Common::String strFilename(filename); - if (strFilename.hasSuffix(".ogg")) { - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); - } else if (strFilename.hasSuffix(".wav")) { - int waveSize, waveRate; - byte waveFlags; - uint16 waveType; - - if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { - if (waveType == 1) { - // We need to wrap the file in a substream to make sure the size is right. - _file = new Common::SeekableSubReadStream(_file, 0, waveSize); - _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); - } else { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); - } - } - } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); - } - if (!_stream) { - return STATUS_FAILED; - } - CBUtils::setString(&_filename, filename); - - return STATUS_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return STATUS_FAILED; - } - - CBUtils::setString(&_filename, filename); - - /* - bool res; - bool NewlyCreated = false; - - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = _gameRef->_fileManager->openFile(filename); - if(!_file){ - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if(!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if(DID_FAIL(res)){ - _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); - return res; - } - } - - - - // store filename - if(!_filename){ - _filename = new char[strlen(filename)+1]; - strcpy(_filename, filename); - } - - // close file (if not streaming) - if(!_streamed && _file){ - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - */ - - return STATUS_OK; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::play(bool looping, uint32 startSample) { - if (startSample != 0) { - warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); - } - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - if (_stream) { - _stream->seek(startSample); - _handle = new Audio::SoundHandle; - if (looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); - g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); - } else { - g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); - _looping = looping; -#if 0 - - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::resume() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, false); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::stop() { - if (_stream && _handle) { - g_system->getMixer()->stopHandle(*_handle); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::pause() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, true); - } - return STATUS_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getLength() { - if (_stream) { - uint32 len = _stream->getLength().msecs(); - return len * 1000; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { - _type = type; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::updateVolume() { - setVolume(_privateVolume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setVolume(int volume) { - _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; - if (_stream && _handle) { - byte vol = (byte)(_volume); - g_system->getMixer()->setChannelVolume(*_handle, vol); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPrivateVolume(int volume) { - _privateVolume = volume; - return setVolume(_privateVolume); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::isPlaying() { - if (_stream && _handle) { - return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getPosition() { - if (_stream && _handle) { - uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); - return pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPosition(uint32 pos) { - warning("CBSoundBuffer::SetPosition - not implemented yet"); -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setLoopStart(uint32 pos) { - _loopStart = pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif - return STATUS_OK; -} -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPan(float pan) { - if (_handle) { - g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("CBSoundBuffer::ApplyFX - not implemented yet"); - switch (type) { - case SFX_ECHO: - break; - - case SFX_REVERB: - break; - - default: - break; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundBuffer.h b/engines/wintermute/base/BSoundBuffer.h deleted file mode 100644 index 9384670fbb..0000000000 --- a/engines/wintermute/base/BSoundBuffer.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H - - -#include "engines/wintermute/base/BBase.h" -#include "audio/mixer.h" -#include "common/stream.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace WinterMute { - -class CBFile; -class CBSoundBuffer : public CBBase { -public: - - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); - - - bool pause(); - bool play(bool looping = false, uint32 startSample = 0); - bool resume(); - bool stop(); - bool isPlaying(); - - void setLooping(bool looping); - - uint32 getPosition(); - bool setPosition(uint32 pos); - uint32 getLength(); - - bool setLoopStart(uint32 pos); - uint32 getLoopStart() const { - return _loopStart; - } - - bool setPan(float pan); - bool setPrivateVolume(int colume); - bool setVolume(int colume); - void updateVolume(); - - void setType(Audio::Mixer::SoundType Type); - - bool loadFromFile(const char *filename, bool forceReload = false); - void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; - bool _looping; - Common::SeekableReadStream *_file; - char *_filename; - bool _streamed; - - int _privateVolume; -private: - int _volume; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp deleted file mode 100644 index 66baa633e4..0000000000 --- a/engines/wintermute/base/BSoundMgr.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BSoundBuffer.h" -#include "engines/wintermute/wintermute.h" -#include "common/config-manager.h" -#include "audio/mixer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { - _soundAvailable = false; - _volumeMaster = 255; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) - delete _sounds[i]; - _sounds.clear(); -#if 0 - BASS_Free(); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { - if (_soundAvailable) { - _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initialize() { - _soundAvailable = false; - - if (!g_system->getMixer()->isReady()) { - return STATUS_FAILED; - } - _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); - _soundAvailable = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initLoop() { - if (!_soundAvailable) - return STATUS_OK; -#if 0 - - BASS_Update(500); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) - return NULL; - - CBSoundBuffer *sound; - - // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::compareNoCase(ext, "wav")) { - AnsiString path = PathUtil::getDirectoryName(filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(filename); - - AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (_gameRef->_fileManager->hasFile(newFile)) { - filename = newFile.c_str(); - } - } - - sound = new CBSoundBuffer(_gameRef); - if (!sound) return NULL; - - sound->setStreaming(streamed); - sound->setType(type); - - - bool res = sound->loadFromFile(filename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", filename); - delete sound; - return NULL; - } - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return sound; - - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) - return STATUS_FAILED; - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i] == sound) { - delete _sounds[i]; - _sounds.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) - return STATUS_OK; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - ConfMan.setInt("sfx_volume", volume); - break; - case Audio::Mixer::kSpeechSoundType: - ConfMan.setInt("speech_volume", volume); - break; - case Audio::Mixer::kMusicSoundType: - ConfMan.setInt("music_volume", volume); - break; - case Audio::Mixer::kPlainSoundType: - error("Plain sound type shouldn't be used in WME"); - } - g_wintermute->syncSoundSettings(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { - return setVolume(type, percent * 255 / 100); -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { - int volume = 0; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - case Audio::Mixer::kSpeechSoundType: - case Audio::Mixer::kMusicSoundType: - volume = g_system->getMixer()->getVolumeForSoundType(type); - break; - default: - error("Sound-type not set"); - break; - } - - return (byte)(volume * 100 / 255); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolume(byte value) { - _volumeMaster = value; - for (uint32 i = 0; i < _sounds.size(); i++) { - _sounds[i]->updateVolume(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolumePercent(byte percent) { - setMasterVolume(percent * 255 / 100); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { - return getMasterVolume() * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolume() { - return (byte)_volumeMaster; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::pauseAll(bool includingMusic) { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { - _sounds[i]->pause(); - _sounds[i]->_freezePaused = true; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::resumeAll() { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int x, int y) { - float relPos = (float)x / ((float)_gameRef->_renderer->_width); - - float minPan = -0.7f; - float maxPan = 0.7f; - - return minPan + relPos * (maxPan - minPan); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundMgr.h b/engines/wintermute/base/BSoundMgr.h deleted file mode 100644 index a021abadaa..0000000000 --- a/engines/wintermute/base/BSoundMgr.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" -#include "audio/mixer.h" -#include "common/array.h" - -namespace WinterMute { -class CBSoundBuffer; -class CBSoundMgr : public CBBase { -public: - float posToPan(int x, int y); - bool resumeAll(); - bool pauseAll(bool includingMusic = true); - bool cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); - byte getMasterVolumePercent(); - byte getMasterVolume(); - bool setMasterVolume(byte percent); - bool setMasterVolumePercent(byte percent); - byte getVolumePercent(Audio::Mixer::SoundType type); - bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); - bool setVolume(Audio::Mixer::SoundType type, int volume); - uint32 _volumeOriginal; - int _volumeMaster; - bool removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initLoop(); - bool initialize(); - bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - Common::Array _sounds; - void saveSettings(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp deleted file mode 100644 index c4dfaa3f8d..0000000000 --- a/engines/wintermute/base/BSprite.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSprite, false) - -////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::setDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - _filename = NULL; - _finished = false; - _changed = false; - _paused = false; - _continuous = false; - _moveX = _moveY = 0; - - _editorMuted = false; - _editorBgFile = NULL; - _editorBgOffsetX = _editorBgOffsetY = 0; - _editorBgAlpha = 0xFF; - _streamed = false; - _streamedKeepLoaded = false; - - setName(""); - - _precise = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::cleanup() { - CBScriptHolder::cleanup(); - - for (int i = 0; i < _frames.getSize(); i++) - delete _frames[i]; - _frames.removeAll(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // move owner if allowed to - if (_changed && _owner && _owner->_movable) { - _owner->_posX += _moveX; - _owner->_posY += _moveY; - _owner->afterMove(); - - x = _owner->_posX; - y = _owner->_posY; - } - - // draw frame - return display(x, y, registerOwner, zoomX, zoomY, alpha); -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); - if (!file) { - _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); - else return loadFile("invalid.bmp", lifeTime, cacheType); - } else { - _gameRef->_fileManager->closeFile(file); - file = NULL; - } - - bool ret; - - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(_gameRef); - CBSubFrame *subframe = new CBSubFrame(_gameRef); - subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); - ret = STATUS_FAILED; - delete frame; - delete subframe; - } else { - CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); - frame->_subframes.add(subframe); - _frames.add(frame); - _currentFrame = 0; - ret = STATUS_OK; - } - } else { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] buffer; - } - } - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - - return ret; -} - - - -TOKEN_DEF_START -TOKEN_DEF(CONTINUOUS) -TOKEN_DEF(SPRITE) -TOKEN_DEF(LOOPING) -TOKEN_DEF(FRAME) -TOKEN_DEF(NAME) -TOKEN_DEF(PRECISE) -TOKEN_DEF(EDITOR_MUTED) -TOKEN_DEF(STREAMED_KEEP_LOADED) -TOKEN_DEF(STREAMED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_BG_FILE) -TOKEN_DEF(EDITOR_BG_OFFSET_X) -TOKEN_DEF(EDITOR_BG_OFFSET_Y) -TOKEN_DEF(EDITOR_BG_ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(CONTINUOUS) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(LOOPING) - TOKEN_TABLE(FRAME) - TOKEN_TABLE(NAME) - TOKEN_TABLE(PRECISE) - TOKEN_TABLE(EDITOR_MUTED) - TOKEN_TABLE(STREAMED_KEEP_LOADED) - TOKEN_TABLE(STREAMED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_BG_FILE) - TOKEN_TABLE(EDITOR_BG_OFFSET_X) - TOKEN_TABLE(EDITOR_BG_OFFSET_Y) - TOKEN_TABLE(EDITOR_BG_ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - cleanup(); - - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - _gameRef->LOG(0, "'SPRITE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int frameCount = 1; - CBFrame *frame; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_CONTINUOUS: - parser.scanStr((char *)params, "%b", &_continuous); - break; - - case TOKEN_EDITOR_MUTED: - parser.scanStr((char *)params, "%b", &_editorMuted); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_LOOPING: - parser.scanStr((char *)params, "%b", &_looping); - break; - - case TOKEN_PRECISE: - parser.scanStr((char *)params, "%b", &_precise); - break; - - case TOKEN_STREAMED: - parser.scanStr((char *)params, "%b", &_streamed); - if (_streamed && lifeTime == -1) { - lifeTime = 500; - cacheType = CACHE_ALL; - } - break; - - case TOKEN_STREAMED_KEEP_LOADED: - parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_EDITOR_BG_FILE: - if (_gameRef->_editorMode) { - delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); - } - break; - - case TOKEN_EDITOR_BG_OFFSET_X: - parser.scanStr((char *)params, "%d", &_editorBgOffsetX); - break; - - case TOKEN_EDITOR_BG_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_editorBgOffsetY); - break; - - case TOKEN_EDITOR_BG_ALPHA: - parser.scanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = MIN(_editorBgAlpha, 255); - _editorBgAlpha = MAX(_editorBgAlpha, 0); - break; - - case TOKEN_FRAME: { - int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - - frame = new CBFrame(_gameRef); - - if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { - delete frame; - _gameRef->LOG(0, "Error parsing frame %d", frameCount); - return STATUS_FAILED; - } - - _frames.add(frame); - frameCount++; - if (_currentFrame == -1) _currentFrame = 0; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITE definition"); - return STATUS_FAILED; - } - _canBreak = !_continuous; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBSprite::reset() { - if (_frames.getSize() > 0) _currentFrame = 0; - else _currentFrame = -1; - - killAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - - if (_currentFrame == -1) return false; - - uint32 timer; - if (_owner && _owner->_freezable) timer = _gameRef->_timer; - else timer = _gameRef->_liveTimer; - - int lastFrame = _currentFrame; - - // get current frame - if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.getSize() - 1) { - _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } - - if (_changed) { - _moveX = _frames[_currentFrame]->_moveX; - _moveY = _frames[_currentFrame]->_moveY; - - if (zoomX != 100 || zoomY != 100) { - _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); - } - } - - return _changed; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // on change... - if (_changed) { - if (_frames[_currentFrame]->_killSound) { - killAllSounds(); - } - applyEvent("FrameChanged"); - _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); - } - - // draw frame - return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); -} - - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::getSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.getSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - CBPlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.getSize(); i++) { - Rect32 frame; - Rect32 temp; - CBPlatform::copyRect(&temp, rect); - _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); - if (_streamed) { - buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - - if (_streamedKeepLoaded) - buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); - } - - if (_editorMuted) - buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - - if (_editorBgFile) { - buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); - } - - CBScriptHolder::saveAsText(buffer, indent + 2); - - int i; - - // scripts - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - - for (i = 0; i < _frames.getSize(); i++) { - _frames[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_canBreak)); - persistMgr->transfer(TMEMBER(_changed)); - persistMgr->transfer(TMEMBER(_paused)); - persistMgr->transfer(TMEMBER(_continuous)); - persistMgr->transfer(TMEMBER(_currentFrame)); - persistMgr->transfer(TMEMBER(_editorAllFrames)); - persistMgr->transfer(TMEMBER(_editorBgAlpha)); - persistMgr->transfer(TMEMBER(_editorBgFile)); - persistMgr->transfer(TMEMBER(_editorBgOffsetX)); - persistMgr->transfer(TMEMBER(_editorBgOffsetY)); - persistMgr->transfer(TMEMBER(_editorMuted)); - persistMgr->transfer(TMEMBER(_finished)); - - _frames.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_lastFrameTime)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_precise)); - persistMgr->transfer(TMEMBER(_streamed)); - persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetFrame") == 0) { - stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - stack->pushNULL(); - } else stack->pushNative(_frames[Index], true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteFrame") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); - } - } else { - CBFrame *Frame = (CBFrame *)Val->getNative(); - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; - delete _frames[i]; - _frames.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddFrame") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) { - sub->setDefaultRect(); - frame->_subframes.add(sub); - } else delete sub; - } - _frames.add(frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertFrame") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) - index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) - filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); - else delete sub; - } - - if (index >= _frames.getSize()) - _frames.add(frame); - else _frames.insertAt(index, frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _paused = true; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Play - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Play") == 0) { - stack->correctParams(0); - _paused = false; - stack->pushNULL(); - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("sprite"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFrames (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { - _scValue->setInt(_currentFrame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_precise); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _scValue->setBool(_looping); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Owner (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->setNULL(); - else _scValue->setNative(_owner, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Finished (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { - _scValue->setBool(_finished); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Paused (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { - _scValue->setBool(_paused); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { - _currentFrame = -1; - } - _lastFrameTime = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _precise = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _looping = value->getBool(); - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSprite::scToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::killAllSounds() { - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i]->_sound) - _frames[i]->_sound->stop(); - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSprite.h b/engines/wintermute/base/BSprite.h deleted file mode 100644 index 3c67e5f3fe..0000000000 --- a/engines/wintermute/base/BSprite.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BScriptHolder.h" - -namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { -public: - bool killAllSounds(); - CBSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void cleanup(); - void setDefaults(); - bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) - - bool _editorAllFrames; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - int _moveY; - int _moveX; - bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; - void reset(); - CBObject *_owner; - bool _changed; - bool _paused; - bool _finished; - bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; - bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); - bool _looping; - int _currentFrame; - bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - CBSprite(CBGame *inGame, CBObject *owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp deleted file mode 100644 index 470ae8549c..0000000000 --- a/engines/wintermute/base/BStringTable.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return STATUS_FAILED; - - if (scumm_stricmp(key, "@right-to-left") == 0) { - _gameRef->_textRTL = true; - return STATUS_OK; - } - - Common::String finalKey = key; - finalKey.toLowercase(); - - _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); - - _strings[finalKey] = val; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -char *CBStringTable::getKey(const char *str) { - if (str == NULL || str[0] != '/') return NULL; - - const char *value = strchr(str + 1, '/'); - if (value == NULL) return NULL; - - char *key = new char[value - str]; - strncpy(key, str + 1, value - str - 1); - key[value - str - 1] = '\0'; - CBPlatform::strlwr(key); - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = getKey(new_str); - delete [] new_str; - return Ret; - } else { - delete [] new_str; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBStringTable::expand(char **str, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return; - - if (str == NULL || *str == NULL || *str[0] != '/') return; - - char *value = strchr(*str + 1, '/'); - if (value == NULL) return; - - char *key = new char[value - *str]; - strncpy(key, *str + 1, value - *str - 1); - key[value - *str - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); - } - - delete [] key; - delete [] *str; - *str = new_str; - - if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return string; - - if (string == NULL || string[0] == '\0' || string[0] != '/') return string; - - const char *value = strchr(string + 1, '/'); - if (value == NULL) return string; - - char *key = new char[value - string]; - strncpy(key, string + 1, value - string - 1); - key[value - string - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - const char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); - } else { - new_str = value; - } - - delete [] key; - - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); - else return new_str; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::loadFile(const char *filename, bool clearOld) { - _gameRef->LOG(0, "Loading string table..."); - - if (clearOld) _strings.clear(); - - uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (buffer == NULL) { - _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - uint32 pos = 0; - - if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - pos += 3; - if (_gameRef->_textEncoding != TEXT_UTF8) { - _gameRef->_textEncoding = TEXT_UTF8; - //_gameRef->_textEncoding = TEXT_ANSI; - _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); - } - } else _gameRef->_textEncoding = TEXT_ANSI; - - uint32 lineLength = 0; - while (pos < size) { - lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - - uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); - char *line = new char[realLength + 1]; - strncpy(line, (char *)&buffer[pos], realLength); - line[realLength] = '\0'; - char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); - - if (line[0] != ';') { - if (value != NULL) { - value[0] = '\0'; - value++; - for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; - } - addString(line, value, clearOld); - } else if (line[0] != '\0') addString(line, "", clearOld); - } - - delete [] line; - pos += lineLength + 1; - } - - delete [] buffer; - - _gameRef->LOG(0, " %d strings loaded", _strings.size()); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BStringTable.h b/engines/wintermute/base/BStringTable.h deleted file mode 100644 index 92d3604b4d..0000000000 --- a/engines/wintermute/base/BStringTable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H - - -#include "common/hashmap.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBStringTable : public CBBase { -public: - const char *expandStatic(const char *string, bool forceExpand = false); - bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str, bool forceExpand = false); - bool addString(const char *key, const char *val, bool reportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); - Common::HashMap _strings; - char *getKey(const char *str); -private: - Common::HashMap::iterator _stringsIter; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp deleted file mode 100644 index 858f2125c6..0000000000 --- a/engines/wintermute/base/BSubFrame.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - CBPlatform::setRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; -} - - -TOKEN_DEF_START -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(DECORATION) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custoTrans = false; - CBPlatform::setRectEmpty(&rect); - char *surfaceFile = NULL; - - delete _surface; - _surface = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &_2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &_3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &_mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &_mirrorY); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &_decoration); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); - return STATUS_FAILED; - } - - if (surfaceFile != NULL) { - if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); - } - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); - - /* - if(_surface == NULL) - { - _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); - return STATUS_FAILED; - } - */ - if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); - else _rect = rect; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return STATUS_OK; - - if (registerOwner != NULL && !_decoration) { - if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); - } else { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); - } - } - if (_gameRef->_suspendedRendering) return STATUS_OK; - - bool res; - - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) alpha = _alpha; - - if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); - } else { - if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - float ratioX = scaleX / 100.0f; - float ratioY = scaleY / 100.0f; - - CBPlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { - if (complete) - buffer->putTextIndent(indent, "SUBFRAME {\n"); - - if (_surface && _surface->getFileNameStr() != "") - buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); - - if (_transparent != 0xFFFF00FF) - buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - - Rect32 rect; - CBPlatform::setRectEmpty(&rect); - if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::equalRect(&rect, &_rect)) - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); - - if (_hotspotX != 0 || _hotspotY != 0) - buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - - if (_alpha != 0xFFFFFFFF) { - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - } - - if (_mirrorX) - buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - - if (_mirrorY) - buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - - if (_2DOnly) - buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - - if (_3DOnly) - buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - - if (_decoration) - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - - if (_editorSelected) - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - CBBase::saveAsText(buffer, indent + 2); - - - if (complete) - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSubFrame::setDefaultRect() { - if (_surface) { - CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_2DOnly)); - persistMgr->transfer(TMEMBER(_3DOnly)); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_hotspotX)); - persistMgr->transfer(TMEMBER(_hotspotY)); - persistMgr->transfer(TMEMBER(_rect)); - - persistMgr->transfer(TMEMBER(_surfaceFilename)); - persistMgr->transfer(TMEMBER(_cKDefault)); - persistMgr->transfer(TMEMBER(_cKRed)); - persistMgr->transfer(TMEMBER(_cKGreen)); - persistMgr->transfer(TMEMBER(_cKBlue)); - persistMgr->transfer(TMEMBER(_lifeTime)); - - persistMgr->transfer(TMEMBER(_keepLoaded)); - persistMgr->transfer(TMEMBER(_mirrorX)); - persistMgr->transfer(TMEMBER(_mirrorY)); - persistMgr->transfer(TMEMBER(_transparent)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - - if (!_surfaceFilename) stack->pushNULL(); - else stack->pushString(_surfaceFilename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (Val->isNULL()) { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; - stack->pushBool(true); - } else { - const char *filename = Val->getString(); - if (DID_SUCCEED(setSurface(filename))) { - setDefaultRect(); - stack->pushBool(true); - } else stack->pushBool(false); - } - - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("subframe"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - - _scValue->setInt((int)_alpha); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TransparentColor (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { - _scValue->setInt((int)_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _scValue->setBool(_2DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _scValue->setBool(_3DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _scValue->setBool(_mirrorX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _scValue->setBool(_mirrorY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _scValue->setInt(_hotspotX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _scValue->setInt(_hotspotY); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = value->getInt(); - return STATUS_OK; - } - - else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::scToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - _surface = NULL; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - if (_surface) { - _surfaceFilename = new char[strlen(filename) + 1]; - strcpy(_surfaceFilename, filename); - - _cKDefault = defaultCK; - _cKRed = ckRed; - _cKGreen = ckGreen; - _cKBlue = ckBlue; - _lifeTime = lifeTime; - _keepLoaded = keepLoaded; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurfaceSimple() { - if (!_surfaceFilename) { - _surface = NULL; - return STATUS_OK; - } - _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return STATUS_OK; - else return STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSubFrame.h b/engines/wintermute/base/BSubFrame.h deleted file mode 100644 index 57ffcae675..0000000000 --- a/engines/wintermute/base/BSubFrame.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool setSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) - void setDefaultRect(); - uint32 _transparent; - bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); - bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - - int _hotspotX; - int _hotspotY; - uint32 _alpha; - Rect32 _rect; - - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - CBSurface *_surface; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp deleted file mode 100644 index 406535cf39..0000000000 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { - cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::cleanup(bool warn) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); - delete _surfaces[i]; - } - _surfaces.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::initLoop() { - if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { - _lastCleanupTime = _gameRef->_liveTimer; - sortSurfaces(); - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; - - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { - //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->invalidate(); - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i] == surface) { - _surfaces[i]->_referenceCount--; - if (_surfaces[i]->_referenceCount <= 0) { - delete _surfaces[i]; - _surfaces.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_debugDebugMode) - return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - else - return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } - - CBSurface *surface; - surface = _gameRef->_renderer->createSurface(); - - if (!surface) return NULL; - - if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { - delete surface; - return NULL; - } else { - surface->_referenceCount = 1; - _surfaces.push_back(surface); - return surface; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::restoreAll() { - bool ret; - for (uint32 i = 0; i < _surfaces.size(); i++) { - ret = _surfaces[i]->restore(); - if (ret != STATUS_OK) { - _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return STATUS_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) -{ - - if(!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - - //_surfaces.persist(persistMgr); - - return STATUS_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); - - // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; - - - // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; - - // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSurfaceStorage.h b/engines/wintermute/base/BSurfaceStorage.h deleted file mode 100644 index c054c2a55b..0000000000 --- a/engines/wintermute/base/BSurfaceStorage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H - -#include "engines/wintermute/base/BBase.h" -#include "common/array.h" - -namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { -public: - uint32 _lastCleanupTime; - bool initLoop(); - bool sortSurfaces(); - static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - - bool restoreAll(); - CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); - - Common::Array _surfaces; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp deleted file mode 100644 index 1cea7285bf..0000000000 --- a/engines/wintermute/base/BTransitionMgr.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BTransitionMgr.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::isReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return STATUS_OK; - - if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { - _state = TRANS_MGR_READY; - return STATUS_OK; - } - - if (nonInteractive) { - _preserveInteractive = true; - _origInteractive = _gameRef->_interactive; - _gameRef->_interactive = false; - } /*else _preserveInteractive */; - - - _type = type; - _state = TRANS_MGR_RUNNING; - _started = false; - - return STATUS_OK; -} - -#define FADE_DURATION 200 - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::update() { - if (isReady()) return STATUS_OK; - - if (!_started) { - _started = true; - _lastTime = CBPlatform::getTime(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - - case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)((float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (isReady()) { - if (_preserveInteractive) - _gameRef->_interactive = _origInteractive; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BTransitionMgr.h b/engines/wintermute/base/BTransitionMgr.h deleted file mode 100644 index faedb6fe3e..0000000000 --- a/engines/wintermute/base/BTransitionMgr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBTransitionMgr : public CBBase { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - bool update(); - bool start(TTransitionType type, bool nonInteractive = false); - bool isReady(); - TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp deleted file mode 100644 index 2b237a0d38..0000000000 --- a/engines/wintermute/base/BViewport.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BViewport.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBViewport, false) - -////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_mainObject)); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_rect)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { - if (!noCheck) { - left = MAX(left, 0); - top = MAX(top, 0); - right = MIN(right, _gameRef->_renderer->_width); - bottom = MIN(bottom, _gameRef->_renderer->_height); - } - - CBPlatform::setRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -Rect32 *CBViewport::getRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BViewport.h b/engines/wintermute/base/BViewport.h deleted file mode 100644 index 1150b8ebe7..0000000000 --- a/engines/wintermute/base/BViewport.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { -public: - int getHeight(); - int getWidth(); - Rect32 *getRect(); - bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) - int _offsetY; - int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); -private: - Rect32 _rect; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp new file mode 100644 index 0000000000..5fabe94312 --- /dev/null +++ b/engines/wintermute/base/base.cpp @@ -0,0 +1,178 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::getEditorProp(const char *propName, const char *initVal) { + _editorPropsIter = _editorProps.find(propName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean + else return initVal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return STATUS_FAILED; + + if (propValue == NULL) { + _editorProps.erase(propName); + } else { + _editorProps[propName] = propValue; + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBBase::parseEditorProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!_gameRef->_editorMode) + return STATUS_OK; + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + + + setEditorProp(propName, propValue); + + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + buffer->putTextIndent(indent, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h new file mode 100644 index 0000000000..e8c87f1f9e --- /dev/null +++ b/engines/wintermute/base/base.h @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool _persistable; + bool setEditorProp(const char *propName, const char *propValue); + const char *getEditorProp(const char *propName, const char *initVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBBase(); + CBGame *_gameRef; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp new file mode 100644 index 0000000000..5895b1acd5 --- /dev/null +++ b/engines/wintermute/base/base_active_rect.cpp @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { + _owner = owner; + _frame = frame; + CBPlatform::setRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { + _owner = owner; + _region = region; + CBPlatform::copyRect(&_rect, ®ion->_rect); + CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + CBRenderer *Rend = _gameRef->_renderer; + + if (!customViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + + CBPlatform::intersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h new file mode 100644 index 0000000000..7c9e8d4a39 --- /dev/null +++ b/engines/wintermute/base/base_active_rect.h @@ -0,0 +1,60 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp new file mode 100644 index 0000000000..f56f08dab2 --- /dev/null +++ b/engines/wintermute/base/base_debugger.cpp @@ -0,0 +1,203 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_Debugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + _enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::initialize() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::shutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameInit() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameShutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameTick() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onLog(unsigned int errorCode, const char *text) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptInit(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::attachClient(IWmeDebugClient *client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::detachClient(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::queryData(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::getPropInt(const char *propName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::getPropFloat(const char *propName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::getPropString(const char *propName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::getPropBool(const char *propName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, int propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, double propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, const char *propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, bool propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::continueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h new file mode 100644 index 0000000000..35ea56eafe --- /dev/null +++ b/engines/wintermute/base/base_debugger.h @@ -0,0 +1,95 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/wme_debugger.h" + +// TODO: The entire debugger should possibly be removed + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool _enabled; + bool initialize(); + bool shutdown(); + + // internal interface + bool onGameInit(); + bool onGameShutdown(); + bool onGameTick(); + bool onLog(unsigned int errorCode, const char *text); + bool onScriptInit(CScScript *script); + bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + bool onScriptShutdown(CScScript *script); + bool onScriptChangeLine(CScScript *script, int line); + bool onScriptChangeScope(CScScript *script, CScValue *scope); + bool onScriptShutdownScope(CScScript *script, CScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + bool onVariableChangeValue(CScValue *var, CScValue *value); + + bool onScriptHitBreakpoint(CScScript *script); + + // IWmeDebugServer interface + virtual bool attachClient(IWmeDebugClient *client); + virtual bool detachClient(IWmeDebugClient *client); + virtual bool queryData(IWmeDebugClient *client); + + virtual int getPropInt(const char *propName); + virtual double getPropFloat(const char *propName); + virtual const char *getPropString(const char *propName); + virtual bool getPropBool(const char *propName); + + virtual bool setProp(const char *propName, int propValue); + virtual bool setProp(const char *propName, double propValue); + virtual bool setProp(const char *propName, const char *propValue); + virtual bool setProp(const char *propName, bool propValue); + + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); + + virtual bool addBreakpoint(const char *scriptFilename, int line); + virtual bool removeBreakpoint(const char *scriptFilename, int line); + + virtual bool continueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp new file mode 100644 index 0000000000..7453838219 --- /dev/null +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -0,0 +1,192 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::cleanup() { + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) initSize = _initSize; + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + if (_offset + size > _size) { + _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putString(const char *val) { + if (!val) putString("(null)"); + else { + putDWORD(strlen(val) + 1); + putBytes((byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + putBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h new file mode 100644 index 0000000000..5795fe5bd1 --- /dev/null +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool _initialized; + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void putTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp new file mode 100644 index 0000000000..712f64eb6f --- /dev/null +++ b/engines/wintermute/base/base_fader.cpp @@ -0,0 +1,176 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::update() { + if (!_active) return STATUS_OK; + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) time = CBPlatform::getTime() - _startTime; + else time = _gameRef->_timer - _startTime; + + if (time >= _duration) _currentAlpha = _targetAlpha; + else { + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::display() { + if (!_active) return STATUS_OK; + + if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); + + _sourceAlpha = RGBCOLGetA(sourceColor); + _targetAlpha = 0; + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = RGBCOLGetA(targetColor); + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->_saving) _startTime = 0; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h new file mode 100644 index 0000000000..679f5d0903 --- /dev/null +++ b/engines/wintermute/base/base_fader.h @@ -0,0 +1,62 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool _system; + uint32 getCurrentColor(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp new file mode 100644 index 0000000000..1cb0464a1f --- /dev/null +++ b/engines/wintermute/base/base_file_manager.cpp @@ -0,0 +1,737 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/base_resources.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/savefile.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + _basePath = NULL; + + initPaths(); + registerPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::cleanup() { + // delete registered paths + for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + + // delete file entries + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; + } + _files.clear(); + + // close open files + for (uint32 i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + + // delete packages + for (uint32 i = 0; i < _packages.size(); i++) + delete _packages[i]; + _packages.clear(); + + delete[] _basePath; + _basePath = NULL; + + return STATUS_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + return NULL; + } + + /* + if (File->GetSize() > MAX_FILE_SIZE) { + _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[file->size() + 1]; + if (buffer == NULL) { + _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + closeFile(file); + delete [] buffer; + return NULL; + }; + + buffer[file->size()] = '\0'; + if (size != NULL) *size = file->size(); + closeFile(file); + + return buffer; +} + +Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::InSaveFile *file = saveMan->openForLoading(filename); + return file; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { + // TODO + warning("Implement SaveFile"); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + file->finalize(); + delete file; +#if 0 + RestoreCurrentDir(); + + CBUtils::CreatePath(filename, false); + + FILE *f = fopen(filename, "wb"); + if (!f) { + _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); + return STATUS_FAILED; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { + // unmount all non-local packages + for (uint32 i = 0; i < _packages.size(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->close(); + } + + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; + + bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); + + char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return STATUS_FAILED; + + strcpy(buffer, path.c_str()); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (type) { + case PATH_SINGLE: + _singlePaths.push_back(buffer); + break; + case PATH_PACKAGE: + _packagePaths.push_back(buffer); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::reloadPaths() { + // delete registered paths + for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + return initPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::initPaths() { + restoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_SINGLE, ".\\"); + + + // package files paths + addPath(PATH_PACKAGE, "./"); + + pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_PACKAGE, "data"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackages() { + restoreCurrentDir(); + + _gameRef->LOG(0, "Scanning packages..."); + debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.dcp"); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + registerPackage((*it)->getName().c_str()); + } +#if 0 + AnsiString extension = AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < _packagePaths.getSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); + + //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } +#endif + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +// FILE *f = fopen(filename, "rb"); + Common::File *package = new Common::File(); + package->open(filename); + if (!package->isOpen()) { + _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + return STATUS_OK; + } + + uint32 absoluteOffset = 0; + bool boundToExe = false; + + if (searchSignature) { + uint32 offset; + if (!findPackageSignature(package, &offset)) { + delete package; + return STATUS_OK; + } else { + package->seek(offset, SEEK_SET); + absoluteOffset = offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete package; + return STATUS_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = package->readUint32LE(); + dirOffset += absoluteOffset; + package->seek(dirOffset, SEEK_SET); + } + + for (uint32 i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(_gameRef); + if (!pkg) return STATUS_FAILED; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = package->readByte(); + pkg->_name = new char[nameLength]; + package->read(pkg->_name, nameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (uint32 j = 0; j < NumFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = package->readByte(); + name = new char[nameLength]; + package->read(name, nameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + + CBPlatform::strupr(name); + + offset = package->readUint32LE(); + offset += absoluteOffset; + length = package->readUint32LE(); + compLength = package->readUint32LE(); + flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + timeDate1 = package->readUint32LE(); + timeDate2 = package->readUint32LE(); + } + _filesIter = _files.find(name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(_gameRef); + file->_package = pkg; + file->_offset = offset; + file->_length = length; + file->_compressedLength = compLength; + file->_flags = flags; + + _files[name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = offset; + _filesIter->_value->_length = length; + _filesIter->_value->_compressedLength = compLength; + _filesIter->_value->_flags = flags; + } + } + delete [] name; + } + } + + + delete package; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::isValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::startsWith(plainName, "xdevice_", true)) { + return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openPackage(const Common::String &name) { + //TODO: Is it really necessary to do this when we have the ScummVM-system? + + //RestoreCurrentDir(); + + Common::File *ret = new Common::File(); + char filename[MAX_PATH_LENGTH]; + + for (uint32 i = 0; i < _packagePaths.size(); i++) { + sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + } + + sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + delete ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openSingleFile(const Common::String &name) { + restoreCurrentDir(); + + Common::File *ret = NULL; + char filename[MAX_PATH_LENGTH]; + + for (uint32 i = 0; i < _singlePaths.size(); i++) { + sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); + ret->open(filename); + if (ret->isOpen()) + return ret; + } + + // didn't find in search paths, try to open directly + ret->open(name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { + restoreCurrentDir(); + + Common::File f; + bool found = false; + + for (uint32 i = 0; i < _singlePaths.size(); i++) { + sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); + f.open(fullname); + if (f.isOpen()) { + f.close(); + found = true; + break; + } + } + + if (!found) { + f.open(filename.c_str()); + if (f.isOpen()) { + f.close(); + found = true; + strcpy(fullname, filename.c_str()); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { + char *upc_name = new char[strlen(filename.c_str()) + 1]; + strcpy(upc_name, filename.c_str()); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; + + delete [] upc_name; + + return ret; +} + +bool CBFileManager::hasFile(const Common::String &filename) { + //TODO: Do this in a much simpler fashion + Common::SeekableReadStream *stream = openFile(filename, true, false); + if (!stream) { + return false; + } + delete stream; + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) return NULL; + //_gameRef->LOG(0, "open file: %s", filename); + /*#ifdef __WIN32__ + if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); + } + } + #endif*/ + + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) _openFiles.push_back(file); + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::closeFile(Common::SeekableReadStream *File) { + for (uint32 i = 0; i < _openFiles.size(); i++) { + if (_openFiles[i] == File) { + delete _openFiles[i]; + _openFiles.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { + restoreCurrentDir(); + + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + if (DID_SUCCEED(SaveThumbFile->open(filename))) { + ret = SaveThumbFile->getMemStream(); + } + delete SaveThumbFile; + return ret; + } + + + + ret = openDiskFile(filename, this); + if (ret) return ret; + + ret = openPkgFile(filename, this); + if (ret) return ret; + + ret = CBResources::getFile(filename); + if (ret) return ret; + + warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::restoreCurrentDir() { + if (!_basePath) return STATUS_OK; + else { + /*if (!chdir(_basePath)) return STATUS_OK; + else return STATUS_FAILED;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::setBasePath(const Common::String &path) { + cleanup(); + + if (path.c_str()) { + _basePath = new char[path.size() + 1]; + strcpy(_basePath, path.c_str()); + } + + initPaths(); + registerPackages(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h new file mode 100644 index 0000000000..1bf3156ebe --- /dev/null +++ b/engines/wintermute/base/base_file_manager.h @@ -0,0 +1,85 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + +#include "engines/wintermute/base/file/base_file_entry.h" +#include "common/archive.h" +#include "common/str.h" + +namespace Common { +class File; +} + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool findPackageSignature(Common::File *f, uint32 *offset); + bool cleanup(); + bool setBasePath(const Common::String &path); + bool restoreCurrentDir(); + char *_basePath; + bool getFullPath(const Common::String &filename, char *fullname); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *getPackageEntry(const Common::String &filename); + Common::File *openSingleFile(const Common::String &name); + Common::File *openPackage(const Common::String &name); + bool registerPackages(); + bool initPaths(); + bool reloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + bool addPath(TPathType type, const Common::String &path); + bool requestCD(int cd, char *packageFile, const char *filename); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + Common::Array _singlePaths; + Common::Array _packagePaths; + Common::Array _packages; + Common::Array _openFiles; + + Common::HashMap _files; +private: + bool registerPackage(const Common::String &filename, bool searchSignature = false); + Common::HashMap::iterator _filesIter; + bool isValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp new file mode 100644 index 0000000000..468ad29858 --- /dev/null +++ b/engines/wintermute/base/base_frame.cpp @@ -0,0 +1,705 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete _sound; + _sound = NULL; + + for (int i = 0; i < _subframes.getSize(); i++) + delete _subframes[i]; + _subframes.removeAll(); + + for (int i = 0; i < _applyEvent.getSize(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.removeAll(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; + + for (int i = 0; i < _subframes.getSize(); i++) { + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); + if (DID_FAIL(res)) return res; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) owner->updateOneSound(_sound); + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (int i = 0; i < _applyEvent.getSize(); i++) { + owner->applyEvent(_applyEvent[i]); + } + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; + CBPlatform::setRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.scanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); + break; + + case TOKEN_MOVE: + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &mirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &editorSelected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.scanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.scanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(_gameRef); + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else _subframes.add(subframe); + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { + if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + _applyEvent.add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.scanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FRAME definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading FRAME definition"); + return STATUS_FAILED; + } + + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (surface_file != NULL) { + if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + + if (!sub->_surface) { + delete sub; + _gameRef->LOG(0, "Error loading SUBFRAME"); + return STATUS_FAILED; + } + + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } + + if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + else sub->_rect = rect; + + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; + + + sub->_editorSelected = editorSelected; + _subframes.insertAt(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + CBPlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (int i = 0; i < _subframes.getSize(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + + if (_sound && _sound->_soundFilename) + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + + if (_editorExpanded) + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + + if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + + for (int i = 1; i < _subframes.getSize(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (int i = 0; i < _applyEvent.getSize(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + CBBase::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + _applyEvent.persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { + stack->pushBool(false); + delete _sound; + _sound = NULL; + } else stack->pushBool(true); + } else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushNative(_subframes[index], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + CBSubFrame *sub = (CBSubFrame *)val->getNative(); + for (int i = 0; i < _subframes.getSize(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + sub->setDefaultRect(); + } + _subframes.add(sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertSubframe") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= _subframes.getSize()) _subframes.add(sub); + else _subframes.insertAt(index, sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _applyEvent.getSize()) { + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushString(_applyEvent[index]); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + stack->pushNULL(); + return STATUS_OK; + } + } + _applyEvent.add(event); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.removeAt(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delay") == 0) { + _scValue->setInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _scValue->setBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _scValue->setBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _scValue->setInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _scValue->setInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumSubframes") == 0) { + _scValue->setInt(_subframes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); + else return CBScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Delay") == 0) { + _delay = MAX(0, value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _keyframe = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _killSound = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _moveX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _moveY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); + else return CBScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBFrame::scToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h new file mode 100644 index 0000000000..f3dec4e16f --- /dev/null +++ b/engines/wintermute/base/base_frame.h @@ -0,0 +1,73 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool _killSound; + bool _keyframe; + bool oneTimeDisplay(CBObject *owner, bool muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *_sound; + bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool saveAsText(CBDynBuffer *buffer, int indent); + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray _applyEvent; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp new file mode 100644 index 0000000000..d5e9c99dcf --- /dev/null +++ b/engines/wintermute/base/base_game.cpp @@ -0,0 +1,4477 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/video/video_player.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _debugAbsolutePathWarning = true; + _debugShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _videoPlayer = NULL; + _theoraPlayer = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + _doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _localSaveDir = NULL; + CBUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + CBPlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + +/*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices +#else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + getDebugMgr()->onGameShutdown(); + + _registry->writeBool("System", "LastRun", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _saveLoadImage; + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _saveLoadImage = NULL; + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::outputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::cleanup() { + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + unregisterObject(_fader); + _fader = NULL; + + for (int i = 0; i < _regObjects.getSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.removeAll(); + + _windows.removeAll(); // refs only + _focusedWindow = NULL; // ref only + + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (int i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.removeAll(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + _quickMessages.removeAll(); + + _viewportStack.removeAll(); + _viewportSP = -1; + + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) + break; + + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) + break; + + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) + break; + + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) + break; + + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) + break; + + _mathClass = new CSXMath(this); + if (_mathClass == NULL) + break; + + _scEngine = new CScEngine(this); + if (_scEngine == NULL) + break; + + _videoPlayer = new CVidPlayer(this); + if (_videoPlayer == NULL) + break; + + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) + break; + + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) + break; + + _fader = new CBFader(this); + if (_fader == NULL) + break; + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _debugMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _fileManager; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) return STATUS_FAILED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + #ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #endif*/ + int secs = g_system->getMillis() / 1000; + int hours = secs / 3600; + secs = secs % 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + if (_debugMgr) _debugMgr->onLog(res, buff); + + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initLoop() { + _viewportSP = -1; + + _currentTime = CBPlatform::getTime(); + + getDebugMgr()->onGameTick(); + _renderer->initLoop(); + _soundMgr->initLoop(); + updateMusicCrossfade(); + + _surfaceStorage->initLoop(); + _fontStorage->initLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //_gameRef->LOG(0, "%d", _fps); + + getMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) _fader->update(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) *offsetX = _offsetX; + if (offsetY != NULL) *offsetY = _offsetY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + _gameRef->LOG(0, "'GAME' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _systemFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + _videoFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.scanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.scanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.scanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.scanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.scanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.scanStr((char *)params, "%d", &_indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.scanStr((char *)params, "%d", &_indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + _indicatorColor = BYTETORGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.scanStr((char *)params, "%d", &_indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.scanStr((char *)params, "%d", &_indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::setString(&_saveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.scanStr((char *)params, "%d", &_saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::setString(&_loadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.scanStr((char *)params, "%d", &_loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + LOG(0, stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + bool res = CBObject::scCallMethod(script, stack, thisStack, name); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Msg") == 0) { + stack->correctParams(1); + quickMessage(stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RunScript") == 0) { + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + stack->correctParams(1); + if (DID_FAIL(addScript(stack->pop()->getString()))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadStringTable") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + CScValue *Val = stack->pop(); + + bool ClearOld; + if (Val->isNULL()) ClearOld = true; + else ClearOld = Val->getBool(); + + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidObject") == 0) { + stack->correctParams(1); + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *) obj)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + resetContent(); + stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CBObject *obj = (CBObject *)val->getNative(); + unregisterObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadWindow") == 0) { + stack->correctParams(1); + CUIWindow *win = new CUIWindow(_gameRef); + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { + _windows.add(win); + registerObject(win); + stack->pushNative(win, true); + } else { + delete win; + win = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExpandString") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); + _stringTable->expand(&str); + stack->pushString(str); + delete [] str; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); + else { + stack->correctParams(4); + channel = stack->pop()->getInt(); + } + + const char *filename = stack->pop()->getString(); + CScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + CScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); + + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); + else { + if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); + else stack->pushString(_music[channel]->_soundFilename); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + uint32 time = stack->pop()->getInt(); + + if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); + else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { + int channel = 0; + if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else stack->pushBool(_music[channel]->isPlaying()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + int volume = stack->pop()->getInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); + else stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getVolumePercent()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->correctParams(4); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); + + if (_musicCrossfadeRunning) { + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->pushBool(false); + return STATUS_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; + + _musicCrossfadeRunning = true; + + stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundLength") == 0) { + stack->correctParams(1); + + int length = 0; + const char *filename = stack->pop()->getString(); + + CBSound *sound = new CBSound(_gameRef); + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; + } + stack->pushInt(length); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMousePos") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + Point32 p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LockMouseRect") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + if (right < left) CBUtils::swap(&left, &right); + if (bottom < top) CBUtils::swap(&top, &bottom); + + CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK; + // TODO: ADDVIDEO + */ + + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + stack->correctParams(6); + const char *filename = stack->pop()->getString(); + warning("PlayVideo: %s - not implemented yet", filename); + CScValue *valType = stack->pop(); + int Type; + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + Type = (int)VID_PLAY_STRETCH; + + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK;*/ + // TODO: ADDVIDEO + + stack->correctParams(7); + const char *filename = stack->pop()->getString(); + CScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) + type = (int)VID_PLAY_STRETCH; + else type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else { + stack->pushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QuitGame") == 0) { + stack->correctParams(0); + stack->pushNULL(); + _quitting = true; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + _registry->writeInt("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + _registry->writeString("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + AnsiString val = _registry->readString("PrivateSettings", key, initVal); + stack->pushString(val.c_str()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveGame") == 0) { + stack->correctParams(3); + int slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); + + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); + stack->pushBool(true); + if (DID_FAIL(SaveGame(slot, desc, quick))) { + stack->pop(); + stack->pushBool(false); + } + delete [] desc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadGame") == 0) { + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->getInt(); + _loading = true; + stack->pushBool(false); + script->sleep(0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->correctParams(1); + int Slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(Slot)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + emptySaveSlot(slot); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); + else stack->pushString(_activeCursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->correctParams(0); + if (!_activeCursor) stack->pushNULL(); + else stack->pushNative(_activeCursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->correctParams(0); + delete _activeCursor; + _activeCursor = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->correctParams(0); + + if (_activeCursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FileExists") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + // TODO: Replace with fileExists + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (!file) stack->pushBool(false); + else { + _fileManager->closeFile(file); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Screenshot") == 0) { + stack->correctParams(1); + char filename[MAX_PATH_LENGTH]; + + CScValue *Val = stack->pop(); + + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO + int fileNum = 0; + + while (true) { + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + if (!Common::File::exists(filename)) + break; + fileNum++; + } + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + _windows.add(win); + registerObject(win); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CBObject *obj = (CBObject *)stack->pop()->getNative(); + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == obj) { + unregisterObject(_windows[i]); + stack->pushBool(true); + return STATUS_OK; + } + } + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenDocument") == 0) { + stack->correctParams(0); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->correctParams(0); + DEBUG_DumpClassRegistry(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _loadImageX = stack->pop()->getInt(); + _loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _loadImageName; + _loadImageName = NULL; + } else { + CBUtils::setString(&_loadImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _saveImageX = stack->pop()->getInt(); + _saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _saveImageName; + _saveImageName = NULL; + } else { + CBUtils::setString(&_saveImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->correctParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive) stack->pushNULL(); + else stack->pushNative(_cursorNoninteractive, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->correctParams(4); + + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + displayContent(false, true); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->correctParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _renderer->dumpData(filename); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccOutputText") == 0) { + stack->correctParams(2); + /* const char *Str = */ + stack->pop()->getString(); + /* int Type = */ + stack->pop()->getInt(); + // do nothing + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool asHex = stack->pop()->getBool(false); + + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (file) { + crc remainder = crc_initialize(); + byte buf[1024]; + int bytesRead = 0; + + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); + + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (asHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + stack->pushString(Hex); + } else + stack->pushInt(checksum); + + _fileManager->closeFile(file); + file = NULL; + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->enableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->disableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Hwnd") == 0) { + _scValue->setInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentTime") == 0) { + _scValue->setInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowsTime") == 0) { + _scValue->setInt((int)CBPlatform::getTime()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowedMode") == 0) { + _scValue->setBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _scValue->setInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _scValue->setInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + _scValue->setNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ActiveObject") == 0) { + _scValue->setNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenWidth") == 0) { + _scValue->setInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenHeight") == 0) { + _scValue->setInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + _scValue->setBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DebugMode") == 0) { + _scValue->setBool(_debugDebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundAvailable") == 0) { + _scValue->setBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyboard") == 0) { + if (_keyboardState) _scValue->setNative(_keyboardState, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _scValue->setBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _scValue->setInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _scValue->setBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FPS") == 0) { + _scValue->setInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + _scValue->setBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + _scValue->setInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _scValue->setBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _scValue->setInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _scValue->setBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _scValue->setBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Frozen") == 0) { + _scValue->setBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSTalk") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSCaptions") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSKeypress") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardPause") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _scValue->setBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveDirectory") == 0) { + AnsiString dataDir = getDataDir(); + _scValue->setString(dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _scValue->setBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _scValue->setInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _scValue->setBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Platform") == 0) { + _scValue->setString(CBPlatform::getPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeviceType") == 0) { + _scValue->setString(getDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MostRecentSaveSlot") == 0) { + _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Store") == 0) { + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); + + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _mousePos.x = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _mousePos.y = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + bool res = CBObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + CBScriptable *obj = value->getNative(); + if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + setInteractive(value->getBool()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _subtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _videoSubtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + int Enc = value->getInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + _textEncoding = (TTextEncoding)Enc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _textRTL = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = value->getInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _suspendedRendering = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _autorunDisabled = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _autoSaveSlot = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _cursorHidden = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayQuickMsg() { + if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + + // update + for (int i = 0; i < _quickMessages.getSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.removeAt(i); + i--; + } + } + + int posY = 20; + + // display + for (int i = 0; i < _quickMessages.getSize(); i++) { + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessage(const char *text) { + if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.removeAt(0); + } + _quickMessages.add(new CBQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::registerObject(CBObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unregisterObject(CBObject *object) { + if (!object) return STATUS_OK; + + // is it a window? + for (int i = 0; i < _windows.getSize(); i++) { + if ((CBObject *)_windows[i] == object) { + _windows.removeAt(i); + + // get new focused window + if (_focusedWindow == object) _focusedWindow = NULL; + + break; + } + } + + // is it active object? + if (_activeObject == object) _activeObject = NULL; + + // is it main object? + if (_mainObject == object) _mainObject = NULL; + + // destroy object + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) { + _regObjects.removeAt(i); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::invalidateValues(void *value, void *data) { + CScValue *val = (CScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { + ((CBScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::validObject(CBObject *object) { + if (!object) return false; + if (object == this) return true; + + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "String") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXString(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MemBuffer") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "File") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXFile(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Date") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXDate(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Array") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXArray(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Object") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXObject(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sleep") == 0) { + stack->correctParams(1); + + script->sleep((uint32)stack->pop()->getInt()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WaitFor") == 0) { + stack->correctParams(1); + + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Random") == 0) { + stack->correctParams(2); + + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); + + stack->pushInt(CBUtils::randomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->correctParams(1); + + script->_timeSlice = (uint32)stack->pop()->getInt(); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->correctParams(4); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); + int a; + CScValue *val = stack->pop(); + if (val->isNULL()) a = 255; + else a = val->getInt(); + + stack->pushInt(BYTETORGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeHSL") == 0) { + stack->correctParams(3); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); + + stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(0); + + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); + script->sleep(0); + } + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToString") == 0) { + stack->correctParams(1); + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete [] str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToInt") == 0) { + stack->correctParams(1); + int val = stack->pop()->getInt(); + stack->pushInt(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToFloat") == 0) { + stack->correctParams(1); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + stack->pushBool(val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + script->runtimeError("Call to undefined function '%s'. Ignored.", name); + stack->correctParams(0); + stack->pushNULL(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (!_interactive && _gameRef->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + } else { + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; + else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); + else if (_cursor) return drawCursor(_cursor); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + LOG(0, "Saving game '%s'...", filename); + + _gameRef->applyEvent("BeforeSave", true); + + bool ret; + + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } + + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + + _registry->writeInt("System", "MostRecentSaveSlot", slot); + +save_finish: // TODO: Remove gotos + delete pm; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + return loadGame(filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(const char *filename) { + LOG(0, "Loading game '%s'...", filename); + getDebugMgr()->onGameShutdown(); + + bool ret; + + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + + + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + _debugAbsolutePathWarning = false; + if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + + //if(DID_FAIL(ret = cleanup())) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + +load_finish: + _debugAbsolutePathWarning = true; + + _indicatorDisplay = false; + delete pm; + _loadInProgress = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::initAfterLoad() { + CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); + + _scEngine->refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadRegion(void *region, void *data) { + ((CBRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSubFrame(void *subframe, void *data) { + ((CBSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSound(void *sound, void *data) { + ((CBSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadFont(void *font, void *data) { + ((CBFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadScript(void *script, void *data) { + ((CScScript *)script)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayWindows(bool inGame) { + bool res; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) return res; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + delete _music[channel]; + _music[channel] = NULL; + + _music[channel] = new CBSound(_gameRef); + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; + } + if (loopStart) _music[channel]->setLoopStart(loopStart); + return _music[channel]->play(looping); + } else { + delete _music[channel]; + _music[channel] = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setMusicStartTime(int channel, uint32 time) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadSettings(const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return STATUS_FAILED; + } + buffer = params; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.scanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.scanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + _registry->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::setString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); + ret = STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading game settings '%s'", filename); + ret = STATUS_FAILED; + } + + _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; + + delete [] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) + cleanup(); + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_doNotExpandStrings)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); + } + + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); + + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); + + _regObjects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); + + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); + + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); + + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); + + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); + + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); + + persistMgr->transfer(TMEMBER(_mouseLockRect)); + + _windows.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); + + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); + + if (!persistMgr->_saving) + _quitting = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::focusWindow(CUIWindow *Window) { + CUIWindow *Prev = _focusedWindow; + + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.getSize() - 1) { + _windows.removeAt(i); + _windows.add(Window); + + _gameRef->_focusedWindow = Window; + } + + if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + return focusWindow(Prev); + else return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::freeze(bool includingMusic) { + if (_freezeLevel == 0) { + _scEngine->pauseAll(); + _soundMgr->pauseAll(includingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unfreeze() { + if (_freezeLevel == 0) return STATUS_OK; + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleKeypress(Common::Event *event, bool printable) { + if (isVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + stopVideo(); + return true; + } + + if (event->type == Common::EVENT_QUIT) { + onWindowClose(); + return true; + } + + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. + _renderer->switchFullscreen(); + return true; + } + + + _keyboardState->handleKeyPress(event); + _keyboardState->readKey(event); +// TODO + + if (_focusedWindow) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + /*if (event->type != SDL_TEXTINPUT) {*/ + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + _gameRef->_focusedWindow->applyEvent("Keypress"); + else + applyEvent("Keypress"); + /*}*/ + } + return true; + } else { /*if (event->type != SDL_TEXTINPUT)*/ + applyEvent("Keypress"); + return true; + } //else return true; + + return false; +} + +void CBGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleMouseWheel(int Delta) { + bool handled = false; + if (_focusedWindow) { + handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + + if (!handled) { + if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); + handled = true; + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); + handled = true; + } + + } + } + + if (!handled) { + if (Delta < 0) { + applyEvent("MouseWheelDown"); + } else { + applyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) *verMajor = DCGF_VER_MAJOR; + if (verMinor) *verMinor = DCGF_VER_MINOR; + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setWindowTitle() { + if (_renderer) { + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') strcat(title, " - "); + strcat(title, "WME Lite"); + + + Utf8String utf8Title; + if (_textEncoding == TEXT_UTF8) { + utf8Title = Utf8String(title); + } else { + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } +#if 0 + CBRenderOSystem *renderer = static_cast(_renderer); + // TODO + + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotFilename(int slot, char *buffer) { + AnsiString dataDir = getDataDir(); + //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + strcpy(buffer, filename.c_str()); + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDataDir() { + AnsiString userDir = PathUtil::getUserDirectory(); + AnsiString baseDir = _registry->getBasePath(); + return PathUtil::combine(userDir, baseDir); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(filename))) { + _debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + + _debugAbsolutePathWarning = true; + strcpy(buffer, pm->_savedDescription); + delete pm; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isSaveSlotUsed(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!File) return false; + delete File; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::emptySaveSlot(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(this); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setActiveObject(CBObject *obj) { + // not-active when game is frozen + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; + } + + if (obj == _activeObject) return STATUS_OK; + + if (_activeObject) _activeObject->applyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + _activeObject = obj; + if (_activeObject) { + _activeObject->applyEvent("MouseEntry"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pushViewport(CBViewport *viewport) { + _viewportSP++; + if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); + else _viewportStack[_viewportSP] = viewport; + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) return STATUS_FAILED; + else { + if (_viewportSP >= 0) { + CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) *custom = true; + } else { + CBPlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) *custom = false; + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { + if (_viewportSP >= 0) { + if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; + if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) _transMgr->_origInteractive = state; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + if (_indicatorDisplay) displayIndicator(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayIndicator() { + if (_saveLoadImage) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + _renderer->setupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + + _renderer->setup2D(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::updateMusicCrossfade() { + /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + + if (!_musicCrossfadeRunning) return STATUS_OK; + if (_state == GAME_FROZEN) return STATUS_OK; + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + + if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); + if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; + + if (currentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); + + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); + + + if (_musicCrossfadeSwap) { + // swap channels + CBSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + CSysClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::invalidateDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::restoreDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) return true; + if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopVideo() { + if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return STATUS_FAILED; + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool CBGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) return STATUS_OK; + + _renderer->_active = activate; + + if (refreshMouse) { + Point32 p; + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); + } + + if (activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + return STATUS_OK; + } else return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayDebugInfo() { + char str[100]; + + if (_debugShowFPS) { + sprintf(str, "FPS: %d", _gameRef->_fps); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (_gameRef->_debugDebugMode) { + if (!_gameRef->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + else + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + + strcat(str, " ("); + strcat(str, _renderer->getName()); + strcat(str, ")"); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->displayDebugInfo(); + + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::getMousePos(Point32 *pos) { + CBPlatform::getCursorPos(pos); + + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { + Common::Rect rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= _gameRef->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= _gameRef->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); + + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); + + Point32 newPos = *pos; + + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::miniUpdate() { + if (!_miniUpdateEnabled) return STATUS_OK; + + if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->initLoop(); + _lastMiniUpdate = CBPlatform::getTime(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 pos; + CBPlatform::getCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); + + + if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = CBPlatform::getTime(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; + return false; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + _registry->saveValues(); + + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; + + SaveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h new file mode 100644 index 0000000000..12ab07912b --- /dev/null +++ b/engines/wintermute/base/base_game.h @@ -0,0 +1,391 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/rect32.h" +#include "common/events.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); + +class CBSoundMgr; +class CBFader; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRenderer; +class CBRegistry; +class CBSaveThumbHelper; +class CBSurfaceStorage; +class CSXMath; +class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) + + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); + + bool isLeftDoubleClick(); + bool isRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual bool miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + char *_localSaveDir; + bool _saveDirChecked; + + int _indicatorProgress; +protected: + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + CBSurface *_saveLoadImage; + bool displayIndicator(); + + bool _reportTextureFormat; +public: + int _thumbnailWidth; + int _thumbnailHeight; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; + + bool _doNotExpandStrings; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; + CBDebugger *getDebugMgr(); + + void LOG(bool res, const char *fmt, ...); + + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; + CBGame(); + + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + bool _debugAbsolutePathWarning; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + + CBStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; +protected: + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + CBFader *_fader; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); +public: + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + +private: + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; +public: + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + virtual bool handleMouseWheel(int delta); + bool _quitting; + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual void handleKeyRelease(Common::Event *event); +protected: + int _freezeLevel; +public: + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(CUIWindow *window); + CVidPlayer *_videoPlayer; + CVidTheoraPlayer *_theoraPlayer; + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; +protected: + static void afterLoadRegion(void *region, void *data); + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +public: + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); + CBRegistry *_registry; + bool _useD3D; + virtual bool cleanup(); + virtual bool loadGame(int slot); + virtual bool loadGame(const char *filename); + virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + Point32 _mousePos; + bool validObject(CBObject *object); + bool unregisterObject(CBObject *object); + bool registerObject(CBObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + + CBArray _regObjects; +public: + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); + bool _forceNonStreamedSounds; + void resetMousePos(); + int _subtitlesSpeed; + void setInteractive(bool state); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(CBViewport *Viewport); + bool setActiveObject(CBObject *Obj); + CBSprite *_lastCursor; + bool drawCursor(CBSprite *Cursor); + + virtual bool initAfterLoad(); + CBSaveThumbHelper *_cachedThumbnail; + AnsiString getDataDir(); + void addMem(int bytes); + + bool _touchInterface; + bool _constrainedMemory; + AnsiString getDeviceType() const; + +private: + CBDebugger *_debugMgr; + + struct LastClickInfo { + LastClickInfo() { + posX = posY = 0; + time = 0; + } + + int posX; + int posY; + uint32 time; + }; + + LastClickInfo _lastClick[2]; + bool isDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void autoSaveOnExit(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp new file mode 100644 index 0000000000..240f642b7f --- /dev/null +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -0,0 +1,304 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + delete[] _keyStates; +} + +void CBKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void CBKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; + } else vKey = val->getInt(); + + warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->setString(key); + } else _scValue->setString(""); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Printable") == 0) { + _scValue->setBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KeyCode") == 0) { + _scValue->setInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsShift") == 0) { + _scValue->setBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsAlt") == 0) { + _scValue->setBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsControl") == 0) { + _scValue->setBool(_currentControl); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::readKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = keyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { + //if(!persistMgr->_saving) cleanup(); + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); + + if (!persistMgr->_saving) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +enum VKeyCodes { + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h new file mode 100644 index 0000000000..bdf268c601 --- /dev/null +++ b/engines/wintermute/base/base_keyboard_state.h @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + bool readKey(Common::Event *event); + + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + uint8 *_keyStates; + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp new file mode 100644 index 0000000000..da76fb2047 --- /dev/null +++ b/engines/wintermute/base/base_named_object.cpp @@ -0,0 +1,65 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_named_object.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::setName(const char *name) { + delete[] _name; + + _name = new char [strlen(name) + 1]; + if (_name != NULL) strcpy(_name, name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h new file mode 100644 index 0000000000..c03d1417a3 --- /dev/null +++ b/engines/wintermute/base/base_named_object.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *_name; + void setName(const char *name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp new file mode 100644 index 0000000000..0a4a0638f0 --- /dev/null +++ b/engines/wintermute/base/base_object.cpp @@ -0,0 +1,1128 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = _gameRef->getSequence(); + + CBPlatform::setRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) + _caption[i] = NULL; + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) + _gameRef->_activeObject = NULL; + + CBScriptHolder::cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) + return; + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::getCaption(int caseVal) { + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else return _caption[caseVal - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + afterMove(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->getInt())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveCursor") == 0) { + stack->correctParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursor") == 0) { + stack->correctParams(0); + if (!_cursor || !_cursor->_filename) stack->pushNULL(); + else stack->pushString(_cursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursorObject") == 0) { + stack->correctParams(0); + if (!_cursor) stack->pushNULL(); + else stack->pushNative(_cursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasCursor") == 0) { + stack->correctParams(0); + + if (_cursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCaption") == 0) { + stack->correctParams(2); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadSound") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + if (DID_SUCCEED(playSFX(filename, false, false))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySound") == 0) { + stack->correctParams(3); + + const char *filename; + bool looping; + uint32 loopStart; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + + if (val1->_type == VAL_BOOL) { + filename = NULL; + looping = val1->getBool(); + loopStart = val2->getInt(); + } else { + if (val1->isNULL()) filename = NULL; + else filename = val1->getString(); + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); + } + + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->correctParams(2); + + const char *filename; + const char *eventName; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + + if (val2->isNULL()) { + filename = NULL; + eventName = val1->getString(); + } else { + filename = val1->getString(); + eventName = val2->getString(); + } + + if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(pauseSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(resumeSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->correctParams(0); + + if (_sFX && _sFX->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->correctParams(1); + + uint32 Time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(0); + else stack->pushInt(_sFX->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->correctParams(1); + + int volume = stack->pop()->getInt(); + if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(_sFXVolume); + else stack->pushInt(_sFX->getVolumePercent()); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXNone") == 0) { + stack->correctParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->correctParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->correctParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + _scValue->setString(getCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(getHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ready") == 0) { + _scValue->setBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _scValue->setBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _scValue->setBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _scValue->setBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _scValue->setBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + _scValue->setInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (_scale < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (_scaleX < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (_scaleY < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _scValue->setFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (!_rotateValid) _scValue->setNULL(); + else _scValue->setFloat((double)_rotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _scValue->setFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _scValue->setBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _scValue->setBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _scValue->setBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _scValue->setBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + _scValue->setNULL(); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Caption") == 0) { + setCaption(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _movable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _registrable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _zoomable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _rotatable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alphaColor = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + int i = value->getInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + _blendMode = (TSpriteBlendMode)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (value->isNULL()) _scale = -1; + else _scale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (value->isNULL()) _scaleX = -1; + else _scaleX = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (value->isNULL()) _scaleY = -1; + else _scaleY = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _relativeScale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (value->isNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)value->getFloat(); + _rotateValid = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _relativeRotate = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _shadowable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _autoSoundPanning = value->getBool(); + if (!_autoSoundPanning) resetSoundPan(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _saveState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::showCursor() { + if (_cursor) return _gameRef->drawCursor(_cursor); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { + // just play loaded sound + if (filename == NULL && _sFX) { + if (_gameRef->_editorMode || _sFXStart) { + _sFX->setVolumePercent(_sFXVolume); + _sFX->setPositionTime(_sFXStart); + if (!_gameRef->_editorMode) _sFXStart = 0; + } + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } + + if (filename == NULL) return STATUS_FAILED; + + // create new sound + delete _sFX; + + _sFX = new CBSound(_gameRef); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); + if (_sFXStart) { + _sFX->setPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } else { + delete _sFX; + _sFX = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::pauseSFX() { + if (_sFX) return _sFX->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resumeSFX() { + if (_sFX) return _sFX->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) return _sFX->setVolumePercent(volume); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) updateOneSound(_sFX); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateOneSound(CBSound *sound) { + bool Ret = STATUS_OK; + + if (sound) { + if (_autoSoundPanning) + Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + + Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resetSoundPan() { + if (!_sFX) return STATUS_OK; + else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, eventName); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h new file mode 100644 index 0000000000..70dc69f53d --- /dev/null +++ b/engines/wintermute/base/base_object.h @@ -0,0 +1,144 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(CBSound *sound); + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + CBSound *_sFX; + + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + + virtual bool handleMouseWheel(int delta); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); + const char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual bool showCursor(); + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + Rect32 _rect; + bool _rectSet; + int _iD; + bool _movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; + + // base + virtual bool update() { + return STATUS_FAILED; + }; + virtual bool display() { + return STATUS_FAILED; + }; + virtual bool invalidateDeviceObjects() { + return STATUS_OK; + }; + virtual bool restoreDeviceObjects() { + return STATUS_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp new file mode 100644 index 0000000000..0f185636aa --- /dev/null +++ b/engines/wintermute/base/base_parser.cpp @@ -0,0 +1,436 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (_whiteSpace != NULL) delete [] _whiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + skipCharacters(buf, _whiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else strcpy(_lastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + skipCharacters(buf, _whiteSpace); + + // get optional name + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = getAssignmentText(buf); + else + *data = getSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + _gameRef->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') _parserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getAssignmentText(char **buf) { + ++*buf; // skip the '=' + skipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = getSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::getToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::getTokenFloat(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::getTokenInt(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { + char *t = getToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::scanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h new file mode 100644 index 0000000000..53a02c0f68 --- /dev/null +++ b/engines/wintermute/base/base_parser.h @@ -0,0 +1,89 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, TokenDesc *tokens, char **params); + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + char *getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + char *_whiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp new file mode 100644 index 0000000000..743eaf355b --- /dev/null +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -0,0 +1,778 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + delete[] _savedDescription; + _savedDescription = NULL; // ref to buffer +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; + } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; +} + +Common::String CBPersistMgr::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); +} + +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void CBPersistMgr::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 CBPersistMgr::getMaxUsedSlot() { + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); it++) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool CBPersistMgr::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initSave(const char *desc) { + if (!desc) return STATUS_FAILED; + + cleanup(); + _saving = true; + + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); + + if (_saveStream) { + // get thumbnails + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + } + } + + uint32 magic = DCGF_MAGIC; + putDWORD(magic); + + magic = SAVE_MAGIC_2; + putDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(VerMajor); + _saveStream->writeByte(VerMinor); + _saveStream->writeByte(ExtMajor); + _saveStream->writeByte(ExtMinor); + + // new in ver 2 + putDWORD((uint32)DCGF_VER_BUILD); + putString(_gameRef->_name); + + // thumbnail data size + bool thumbnailOK = false; + + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } + + thumbnailOK = true; + } + } + if (!thumbnailOK) putDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + + uint32 dataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(desc) + 1 + // description + sizeof(uint32); // timestamp + + putDWORD(dataOffset); + putString(desc); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); + } + return STATUS_OK; +} + +bool CBPersistMgr::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + if (_loadStream) { + uint32 magic; + magic = getDWORD(); + + if (magic != DCGF_MAGIC) { + cleanup(); + return STATUS_FAILED; + } + + magic = getDWORD(); + + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); + + if (magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)getDWORD(); + _savedName = getStringObj(); + + // load thumbnail + _thumbnailDataSize = getDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + getBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; + } + } else _savedVerBuild = 35; // last build with ver1 savegames + + uint32 dataOffset = getDWORD(); + + _savedDescription = getString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); + + _offset = dataOffset; + + return STATUS_OK; + } + } + + cleanup(); + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initLoad(const char *filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + cleanup(); + return STATUS_FAILED; + } + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + + } + + /* + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::saveFile(const char *filename) { + return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putString(const Common::String &val) { + if (!val.size()) putString("(null)"); + else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String CBPersistMgr::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + Common::String retString = ret; + delete[] ret; + + if (retString == "(null)") { + retString = ""; + } + + return retString; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::getString() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else return ret; +} + +bool CBPersistMgr::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +TimeDate CBPersistMgr::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + +void CBPersistMgr::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float CBPersistMgr::getFloat() { + char *str = getString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +void CBPersistMgr::putDouble(double val) { + Common::String str = Common::String::format("F%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double CBPersistMgr::getDouble() { + char *str = getString(); + double value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool CBPersistMgr::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// int +bool CBPersistMgr::transfer(const char *name, int *val) { + if (_saving) { + _saveStream->writeSint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +bool CBPersistMgr::transfer(const char *name, uint32 *val) { + if (_saving) { + _saveStream->writeUint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readUint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// float +bool CBPersistMgr::transfer(const char *name, float *val) { + if (_saving) { + putFloat(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// double +bool CBPersistMgr::transfer(const char *name, double *val) { + if (_saving) { + putDouble(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getDouble(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// char* +bool CBPersistMgr::transfer(const char *name, char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// const char* +bool CBPersistMgr::transfer(const char *name, const char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +bool CBPersistMgr::transfer(const char *name, Common::String *val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { + size_t size; + + if (_saving) { + size = val.size(); + _saveStream->writeUint32LE(size); + + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); + } + } else { + val.clear(); + size = _loadStream->readUint32LE(); + + for (size_t i = 0; i < size; i++) { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) val.push_back(str); + delete[] str; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +bool CBPersistMgr::transfer(const char *name, byte *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +bool CBPersistMgr::transfer(const char *name, Rect32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +bool CBPersistMgr::transfer(const char *name, Point32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +bool CBPersistMgr::transfer(const char *name, Vector2 *val) { + if (_saving) { + putFloat(val->x); + putFloat(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = getFloat(); + val->y = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +bool CBPersistMgr::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { + if (_saving) return true; + + // it's ok if we are same or newer than the saved game + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h new file mode 100644 index 0000000000..f2fd42ceca --- /dev/null +++ b/engines/wintermute/base/base_persistence_manager.h @@ -0,0 +1,114 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/savestate.h" +#include "common/stream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/rect.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *_savedDescription; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const char *filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + Common::String getStringObj(); + void putString(const Common::String &val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); + bool initLoad(const char *filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool _saving; + + uint32 _richBufferSize; + byte *_richBuffer; + + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~CBPersistMgr(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + bool putTimeDate(const TimeDate &t); + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp new file mode 100644 index 0000000000..6887349a7a --- /dev/null +++ b/engines/wintermute/base/base_point.cpp @@ -0,0 +1,64 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPoint::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h new file mode 100644 index 0000000000..363ab1f919 --- /dev/null +++ b/engines/wintermute/base/base_point.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp new file mode 100644 index 0000000000..ac1001a2fe --- /dev/null +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) strcpy(_text, text); + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (_text) delete [] _text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::getText() { + return _text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h new file mode 100644 index 0000000000..9a68929932 --- /dev/null +++ b/engines/wintermute/base/base_quick_msg.h @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *getText(); + uint32 _startTime; + char *_text; + CBQuickMsg(CBGame *inGame, const char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp new file mode 100644 index 0000000000..3e513f9fb8 --- /dev/null +++ b/engines/wintermute/base/base_region.cpp @@ -0,0 +1,508 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::cleanup() { + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + CBPlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::pointInRegion(int x, int y) { + if (_points.getSize() < 3) return false; + + Point32 pt; + pt.x = x; + pt.y = y; + + Rect32 rect; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; + + if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int i; + + for (i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AddPoint") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + _points.add(new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points.insertAt(Index, new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points[Index]->x = x; + _points[Index]->y = y; + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemovePoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + delete _points[index]; + _points[index] = NULL; + + _points.removeAt(index); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + CScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); + } + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.getSize()); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", nameOverride); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::ptInPolygon(int x, int y) { + if (_points.getSize() < 3) return false; + + int counter = 0; + double xinters; + dPoint p, p1, p2; + + p.x = (double)x; + p.y = (double)y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (int i = 1; i <= _points.getSize(); i++) { + p2.x = (double)_points[i % _points.getSize()]->x; + p2.y = (double)_points[i % _points.getSize()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < _points.getSize(); i++) { + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); + + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); + } + CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < region->_points.getSize(); i++) { + int xVal, yVal; + + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(xVal + x, yVal + y)); + } + + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; + + return createRegion() ? STATUS_OK : STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h new file mode 100644 index 0000000000..5de1fb9eef --- /dev/null +++ b/engines/wintermute/base/base_region.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); + bool ptInPolygon(int x, int y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool _active; + int _editorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + Rect32 _rect; + CBArray _points; + virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp new file mode 100644 index 0000000000..350a34b61e --- /dev/null +++ b/engines/wintermute/base/base_registry.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/tinyxml/tinyxml.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/utils.h" +#include "common/config-manager.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + _iniName = NULL; + + setIniName("./wme.ini"); + loadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + saveValues(); + delete[] _iniName; + _iniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + + bool found = false; + ret = getValue(_localValues, subKey, key, found); + if (!found) ret = getValue(_values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + _values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + if (ConfMan.hasKey("master_volume")) { + return ConfMan.getInt("master_volume"); + } else { + return init; + } + } else if (key == "SFXVolume") { + if (ConfMan.hasKey("sfx_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "SpeechVolume") { + if (ConfMan.hasKey("speech_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "MusicVolume") { + if (ConfMan.hasKey("music_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } + } + AnsiString val = readString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + ConfMan.setInt("master_volume", value); + return true; + } else if (key == "SFXVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "SpeechVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "MusicVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } + } + writeString(subKey, key, StringUtil::toString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (readInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return writeInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setIniName(const char *name) { + delete[] _iniName; + _iniName = NULL; + + if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { + _iniName = new char [strlen(name) + 3]; + sprintf(_iniName, "./%s", name); + } else { + _iniName = new char [strlen(name) + 1]; + strcpy(_iniName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::getIniName() { + return _iniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadValues(bool local) { + if (local) loadXml("settings.xml", _localValues); + else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveValues() { + saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setBasePath(const char *basePath) { + _basePath = PathUtil::getFileNameWithoutExtension(basePath); + + loadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it)._value; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt)._value; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName.c_str()); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::createPath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt)._value; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + Common::DumpFile stream; + stream.open(fileName.c_str()); + + if (!stream.isOpen()) return; + else { + stream.write(printer.CStr(), printer.Size()); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h new file mode 100644 index 0000000000..06e052cd03 --- /dev/null +++ b/engines/wintermute/base/base_registry.h @@ -0,0 +1,76 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void setIniName(const char *name); + char *getIniName(); + bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); + int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void setBasePath(const char *basePath); + AnsiString getBasePath() const { + return _basePath; + } + + void loadValues(bool local); + void saveValues(); + +private: + char *_iniName; + + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; + + PathValueMap _localValues; + PathValueMap _values; + + AnsiString _basePath; + + void loadXml(const AnsiString fileName, PathValueMap &values); + void saveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp new file mode 100644 index 0000000000..bee63aa307 --- /dev/null +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + if (doFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + } + + CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) return STATUS_FAILED; + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new CBImage(_gameRef); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); + } + + + delete screenshot; + screenshot = NULL; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h new file mode 100644 index 0000000000..e8cdbdc00d --- /dev/null +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + CBImage *_thumbnail; + CBImage *_richThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp new file mode 100644 index 0000000000..5192f76f6e --- /dev/null +++ b/engines/wintermute/base/base_script_holder.cpp @@ -0,0 +1,473 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) delete [] _filename; + + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + if (handler) { + //_scripts.add(handler); + numHandlers++; + ret = STATUS_OK; + } + } + } + if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->correctParams(0); + byte *p = 0; + *p = 10; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ApplyEvent") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool ret; + ret = applyEvent(val->getString()); + + if (DID_SUCCEED(ret)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AttachScript") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DetachScript") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool killThreads = stack->pop()->getBool(false); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + _scripts[i]->finish(killThreads); + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { + return CBBase::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_name)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::addScript(const char *filename) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + return STATUS_OK; + } + } + } + + CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.add(scr); + _gameRef->_scEngine->_scripts.add(scr); + _gameRef->getDebugMgr()->onScriptInit(scr); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::removeScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) { + _scripts.removeAt(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleEvent(const char *EventName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleMethod(const char *MethodName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + _gameRef->LOG(0, "'PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading PROPERTY definition"); + return STATUS_FAILED; + } + + + CScValue *val = new CScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->_freezable = freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.getSize() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (_name && strcmp(_name, "") != 0) { + strcat(buf, " Name: "); + strcat(buf, _name); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::sendEvent(const char *eventName) { + return DID_SUCCEED(applyEvent(eventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h new file mode 100644 index 0000000000..0e5bc1b7ec --- /dev/null +++ b/engines/wintermute/base/base_script_holder.h @@ -0,0 +1,74 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CBScriptHolder : public CBScriptable { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + virtual CScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + bool cleanup(); + bool removeScript(CScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + bool parseProperty(byte *buffer, bool complete = true); + char *_filename; + bool _freezable; + bool _ready; + + CBArray _scripts; + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +public: + virtual bool sendEvent(const char *eventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp new file mode 100644 index 0000000000..e9489fa407 --- /dev/null +++ b/engines/wintermute/base/base_scriptable.cpp @@ -0,0 +1,188 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { + _refCount = 0; + + if (noValue) _scValue = NULL; + else _scValue = new CScValue(_gameRef); + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->getProp(name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scSetProperty(const char *name, CScValue *value) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->setProp(name, value); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scCompare(CBScriptable *val) { + if (this < val) return -1; + else if (this > val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::dbgGetNativeClass() { + return getClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { + return scGetProperty(name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h new file mode 100644 index 0000000000..166f3c0bd1 --- /dev/null +++ b/engines/wintermute/base/base_scriptable.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool canHandleMethod(const char *eventMethod); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(CBScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + CScValue *_scValue; + CScValue *_scProp; + +public: + // IWmeDebugObject + const char *dbgGetNativeClass(); + IWmeDebugProp *dbgGetProperty(const char *name); + +}; + +// Implemented in their respective .cpp-files +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXMath(CBGame *inGame); +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXStore(CBGame *inGame); +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp new file mode 100644 index 0000000000..ba55d1b88b --- /dev/null +++ b/engines/wintermute/base/base_sprite.cpp @@ -0,0 +1,758 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + setName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::cleanup() { + CBScriptHolder::cleanup(); + + for (int i = 0; i < _frames.getSize(); i++) + delete _frames[i]; + _frames.removeAll(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + GetCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->afterMove(); + + x = _owner->_posX; + y = _owner->_posY; + } + + // draw frame + return display(x, y, registerOwner, zoomX, zoomY, alpha); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + if (!file) { + _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + else return loadFile("invalid.bmp", lifeTime, cacheType); + } else { + _gameRef->_fileManager->closeFile(file); + file = NULL; + } + + bool ret; + + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + CBFrame *frame = new CBFrame(_gameRef); + CBSubFrame *subframe = new CBSubFrame(_gameRef); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer) { + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + delete [] buffer; + } + } + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + cleanup(); + + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + _gameRef->LOG(0, "'SPRITE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int frameCount = 1; + CBFrame *frame; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.scanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.scanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.scanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.scanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.scanStr((char *)params, "%b", &_streamed); + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (_gameRef->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.scanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(_gameRef); + + if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + delete frame; + _gameRef->LOG(0, "Error parsing frame %d", frameCount); + return STATUS_FAILED; + } + + _frames.add(frame); + frameCount++; + if (_currentFrame == -1) _currentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITE definition"); + return STATUS_FAILED; + } + _canBreak = !_continuous; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::reset() { + if (_frames.getSize() > 0) _currentFrame = 0; + else _currentFrame = -1; + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { + //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) return false; + + uint32 timer; + if (_owner && _owner->_freezable) timer = _gameRef->_timer; + else timer = _gameRef->_liveTimer; + + int lastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.getSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + killAllSounds(); + } + applyEvent("FrameChanged"); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.getSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + CBPlatform::setRectEmpty(rect); + for (int i = 0; i < _frames.getSize(); i++) { + Rect32 frame; + Rect32 temp; + CBPlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (_editorMuted) + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + + if (_editorBgFile) { + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + CBScriptHolder::saveAsText(buffer, indent + 2); + + int i; + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + + for (i = 0; i < _frames.getSize(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int Index = stack->pop()->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + stack->pushNULL(); + } else stack->pushNative(_frames[Index], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteFrame") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (Val->isInt()) { + int Index = Val->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->getNative(); + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddFrame") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.add(sub); + } else delete sub; + } + _frames.add(frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertFrame") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) + index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) + filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); + else delete sub; + } + + if (index >= _frames.getSize()) + _frames.add(frame); + else _frames.insertAt(index, frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _paused = true; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Play") == 0) { + stack->correctParams(0); + _paused = false; + stack->pushNULL(); + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFrames") == 0) { + _scValue->setInt(_frames.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentFrame") == 0) { + _scValue->setInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _scValue->setBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Owner") == 0) { + if (_owner == NULL) _scValue->setNULL(); + else _scValue->setNative(_owner, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Finished") == 0) { + _scValue->setBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Paused") == 0) { + _scValue->setBool(_paused); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _precise = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _looping = value->getBool(); + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::killAllSounds() { + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i]->_sound) + _frames[i]->_sound->stop(); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h new file mode 100644 index 0000000000..8f3ce84eb4 --- /dev/null +++ b/engines/wintermute/base/base_sprite.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base_script_holder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + bool killAllSounds(); + CBSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool _editorAllFrames; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + int _moveY; + int _moveX; + bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void reset(); + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + uint32 _lastFrameTime; + bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + CBSprite(CBGame *inGame, CBObject *owner = NULL); + virtual ~CBSprite(); + CBArray _frames; + bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp new file mode 100644 index 0000000000..c7789add9d --- /dev/null +++ b/engines/wintermute/base/base_string_table.cpp @@ -0,0 +1,229 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/utils/string_util.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return STATUS_FAILED; + + if (scumm_stricmp(key, "@right-to-left") == 0) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + _stringsIter = _strings.find(finalKey); + if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + + _strings[finalKey] = val; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; + + const char *value = strchr(str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = getKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::expand(char **str, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return; + + if (str == NULL || *str == NULL || *str[0] != '/') return; + + char *value = strchr(*str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *str; + *str = new_str; + + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return string; + + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; + + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; + + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) _strings.clear(); + + uint32 size; + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + uint32 pos = 0; + + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else _gameRef->_textEncoding = TEXT_ANSI; + + uint32 lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (uint32 i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); + } + + delete [] line; + pos += lineLength + 1; + } + + delete [] buffer; + + _gameRef->LOG(0, " %d strings loaded", _strings.size()); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h new file mode 100644 index 0000000000..c612c33a41 --- /dev/null +++ b/engines/wintermute/base/base_string_table.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *expandStatic(const char *string, bool forceExpand = false); + bool loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + bool addString(const char *key, const char *val, bool reportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + Common::HashMap _strings; + char *getKey(const char *str); +private: + Common::HashMap::iterator _stringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp new file mode 100644 index 0000000000..adce6c6b75 --- /dev/null +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + CBPlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + CBPlatform::setRectEmpty(&rect); + char *surfaceFile = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); + return STATUS_FAILED; + } + + if (surfaceFile != NULL) { + if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + + /* + if(_surface == NULL) + { + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); + return STATUS_FAILED; + } + */ + if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + else _rect = rect; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) return STATUS_OK; + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + } else { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + } + } + if (_gameRef->_suspendedRendering) return STATUS_OK; + + bool res; + + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) alpha = _alpha; + + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; + + CBPlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { + if (complete) + buffer->putTextIndent(indent, "SUBFRAME {\n"); + + if (_surface && _surface->getFileNameStr() != "") + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + + if (_transparent != 0xFFFF00FF) + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + + Rect32 rect; + CBPlatform::setRectEmpty(&rect); + if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!CBPlatform::equalRect(&rect, &_rect)) + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + + if (_hotspotX != 0 || _hotspotY != 0) + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + + if (_alpha != 0xFFFFFFFF) { + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + } + + if (_mirrorX) + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + + if (_mirrorY) + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + + if (_2DOnly) + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + + if (_3DOnly) + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + + if (_decoration) + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + + if (_editorSelected) + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + + if (complete) + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::setDefaultRect() { + if (_surface) { + CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + + if (!_surfaceFilename) stack->pushNULL(); + else stack->pushString(_surfaceFilename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (Val->isNULL()) { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; + stack->pushBool(true); + } else { + const char *filename = Val->getString(); + if (DID_SUCCEED(setSurface(filename))) { + setDefaultRect(); + stack->pushBool(true); + } else stack->pushBool(false); + } + + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + + _scValue->setInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TransparentColor") == 0) { + _scValue->setInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _scValue->setBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _scValue->setBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _scValue->setBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _scValue->setBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _scValue->setInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _scValue->setInt(_hotspotY); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _2DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _3DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _mirrorX = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _mirrorY = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _hotspotX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _hotspotY = value->getInt(); + return STATUS_OK; + } + + else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(filename) + 1]; + strcpy(_surfaceFilename, filename); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return STATUS_OK; + } + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return STATUS_OK; + else return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h new file mode 100644 index 0000000000..6fb24c0e4f --- /dev/null +++ b/engines/wintermute/base/base_sub_frame.h @@ -0,0 +1,86 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void setDefaultRect(); + uint32 _transparent; + bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool _editorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + Rect32 _rect; + + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + CBSurface *_surface; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp new file mode 100644 index 0000000000..06c2f1b0cc --- /dev/null +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -0,0 +1,189 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::cleanup(bool warn) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::initLoop() { + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; + sortSurfaces(); + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::removeSurface(CBSurface *surface) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!_gameRef->_fileManager->hasFile(filename)) { + if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); + if (_gameRef->_debugDebugMode) + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + else + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + + CBSurface *surface; + surface = _gameRef->_renderer->createSurface(); + + if (!surface) return NULL; + + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.push_back(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::restoreAll() { + bool ret; + for (uint32 i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +{ + + if(!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + + + // sort by validity + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h new file mode 100644 index 0000000000..58f25e6875 --- /dev/null +++ b/engines/wintermute/base/base_surface_storage.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + +#include "engines/wintermute/base/base.h" +#include "common/array.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 _lastCleanupTime; + bool initLoop(); + bool sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); + bool cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + bool restoreAll(); + CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + Common::Array _surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp new file mode 100644 index 0000000000..30a1a32e6a --- /dev/null +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -0,0 +1,131 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) return STATUS_OK; + + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return STATUS_OK; + } + + if (nonInteractive) { + _preserveInteractive = true; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; + } /*else _preserveInteractive */; + + + _type = type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return STATUS_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::update() { + if (isReady()) return STATUS_OK; + + if (!_started) { + _started = true; + _lastTime = CBPlatform::getTime(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (isReady()) { + if (_preserveInteractive) + _gameRef->_interactive = _origInteractive; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h new file mode 100644 index 0000000000..9b84c653e9 --- /dev/null +++ b/engines/wintermute/base/base_transition_manager.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp new file mode 100644 index 0000000000..83cbc5b0f0 --- /dev/null +++ b/engines/wintermute/base/base_viewport.cpp @@ -0,0 +1,98 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_viewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); + } + + CBPlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *CBViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h new file mode 100644 index 0000000000..795e6f404f --- /dev/null +++ b/engines/wintermute/base/base_viewport.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int getHeight(); + int getWidth(); + Rect32 *getRect(); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int _offsetY; + int _offsetX; + CBObject *_mainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + Rect32 _rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp deleted file mode 100644 index 739eafcc73..0000000000 --- a/engines/wintermute/base/file/BDiskFile.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/file/BDiskFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/stream.h" -#include "common/memstream.h" -#include "common/file.h" -#include "common/zlib.h" - -namespace WinterMute { - -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; - } -} - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { - char fullPath[MAX_PATH_LENGTH]; - uint32 prefixSize = 0; - Common::SeekableReadStream *file = NULL; - - for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { - sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); - correctSlashes(fullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - // if we didn't find it in search paths, try to open directly - if (!file) { - strcpy(fullPath, filename.c_str()); - correctSlashes(fullPath); - - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - if (file) { - uint32 magic1, magic2; - magic1 = file->readUint32LE(); - magic2 = file->readUint32LE(); - - bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; - - if (compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = file->readUint32LE(); - CompSize = file->readUint32LE(); - UncompSize = file->readUint32LE(); - - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - error("Error allocating memory for compressed file '%s'", filename.c_str()); - delete file; - return NULL; - } - - byte *data = new byte[UncompSize]; - if (!data) { - error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - file->seek(DataOffset + prefixSize, SEEK_SET); - file->read(CompBuffer, CompSize); - - if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { - error("Error uncompressing file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - - delete [] CompBuffer; - - return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); - delete file; - file = NULL; - } else { - file->seek(0, SEEK_SET); - return file; - } - - return file; - - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BDiskFile.h b/engines/wintermute/base/file/BDiskFile.h deleted file mode 100644 index 23e1a0a315..0000000000 --- a/engines/wintermute/base/file/BDiskFile.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFile.cpp b/engines/wintermute/base/file/BFile.cpp deleted file mode 100644 index 911039e36d..0000000000 --- a/engines/wintermute/base/file/BFile.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "common/memstream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFile::isEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = getPos(); - seek(0); - byte *data = new byte[getSize()]; - read(data, getSize()); - seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFile.h b/engines/wintermute/base/file/BFile.h deleted file mode 100644 index d1737df0ce..0000000000 --- a/engines/wintermute/base/file/BFile.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H - - -#include "engines/wintermute/base/BBase.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBFile : public CBBase { -protected: - uint32 _pos; - uint32 _size; -public: - virtual uint32 getSize() { - return _size; - }; - virtual uint32 getPos() { - return _pos; - }; - virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; - virtual bool read(void *buffer, uint32 size) = 0; - virtual bool close() = 0; - virtual bool open(const Common::String &filename) = 0; - virtual bool isEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFileEntry.cpp b/engines/wintermute/base/file/BFileEntry.cpp deleted file mode 100644 index b00ecb6f9d..0000000000 --- a/engines/wintermute/base/file/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFileEntry.h b/engines/wintermute/base/file/BFileEntry.h deleted file mode 100644 index 5fdf2b6308..0000000000 --- a/engines/wintermute/base/file/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BPackage.cpp b/engines/wintermute/base/file/BPackage.cpp deleted file mode 100644 index bddf1abc1e..0000000000 --- a/engines/wintermute/base/file/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPackage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - closeFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { - if (_file) return STATUS_OK; - else { - _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { - delete _file; - _file = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (DID_FAIL(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); - if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPackage.h b/engines/wintermute/base/file/BPackage.h deleted file mode 100644 index 8c803fddd9..0000000000 --- a/engines/wintermute/base/file/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "engines/wintermute/base/BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index b787851290..3acde9c1ff 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -27,10 +27,10 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPackage.h" +#include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" #include "common/util.h" #include "common/file.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index dc8b4b684f..4356ae5519 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -29,7 +29,10 @@ #ifndef WINTERMUTE_BPKGFILE_H #define WINTERMUTE_BPKGFILE_H -#include "engines/wintermute/base/file/BFileEntry.h" +#include "engines/wintermute/base/file/base_file_entry.h" + +// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size +// as such it is not renamed to follow the convention of the rest of the files. namespace Common { class SeekableReadStream; diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp deleted file mode 100644 index 4a75b7d7ce..0000000000 --- a/engines/wintermute/base/file/BSaveThumbFile.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { - close(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::open(const Common::String &filename) { - close(); - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; - - char *tempFilename = new char[strlen(filename.c_str()) - 8]; - strcpy(tempFilename, filename.c_str() + 9); - for (uint32 i = 0; i < strlen(tempFilename); i++) { - if (tempFilename[i] < '0' || tempFilename[i] > '9') { - tempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int slot = atoi(tempFilename); - delete [] tempFilename; - - char slotFilename[MAX_PATH_LENGTH + 1]; - _gameRef->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _gameRef->_debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - _gameRef->_debugAbsolutePathWarning = true; - - bool res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = STATUS_OK; - } else res = STATUS_FAILED; - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return STATUS_FAILED; - - memcpy(buffer, (byte *)_data + _pos, size); - _pos += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) return STATUS_FAILED; - - uint32 newPos = 0; - - switch (whence) { - case SEEK_SET: - newPos = pos; - break; - case SEEK_END: - newPos = _size + pos; - break; - case SEEK_CUR: - newPos = _pos + pos; - break; - } - - if (newPos > _size) return STATUS_FAILED; - else _pos = newPos; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BSaveThumbFile.h b/engines/wintermute/base/file/BSaveThumbFile.h deleted file mode 100644 index 5d33ac2220..0000000000 --- a/engines/wintermute/base/file/BSaveThumbFile.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H - - -#include "engines/wintermute/base/file/BFile.h" - -namespace WinterMute { - -//TODO: Get rid of this -class CBSaveThumbFile : public CBFile { -public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); - virtual bool seek(uint32 pos, int whence = SEEK_SET); - virtual bool read(void *buffer, uint32 size); - virtual bool close(); - virtual bool open(const Common::String &filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp new file mode 100644 index 0000000000..99bf9cff3f --- /dev/null +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -0,0 +1,131 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/file.h" +#include "common/zlib.h" + +namespace WinterMute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { + char fullPath[MAX_PATH_LENGTH]; + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; + + for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { + sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); + correctSlashes(fullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + // if we didn't find it in search paths, try to open directly + if (!file) { + strcpy(fullPath, filename.c_str()); + correctSlashes(fullPath); + + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + if (file) { + uint32 magic1, magic2; + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + + if (compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = file->readUint32LE(); + CompSize = file->readUint32LE(); + UncompSize = file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + error("Error allocating memory for compressed file '%s'", filename.c_str()); + delete file; + return NULL; + } + + byte *data = new byte[UncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + file->seek(DataOffset + prefixSize, SEEK_SET); + file->read(CompBuffer, CompSize); + + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + error("Error uncompressing file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + + delete [] CompBuffer; + + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; + } else { + file->seek(0, SEEK_SET); + return file; + } + + return file; + + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h new file mode 100644 index 0000000000..23e1a0a315 --- /dev/null +++ b/engines/wintermute/base/file/base_disk_file.h @@ -0,0 +1,42 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp new file mode 100644 index 0000000000..88a64cb147 --- /dev/null +++ b/engines/wintermute/base/file/base_file.cpp @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = getPos(); + seek(0); + byte *data = new byte[getSize()]; + read(data, getSize()); + seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h new file mode 100644 index 0000000000..b29fc41299 --- /dev/null +++ b/engines/wintermute/base/file/base_file.h @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/base/base.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +protected: + uint32 _pos; + uint32 _size; +public: + virtual uint32 getSize() { + return _size; + }; + virtual uint32 getPos() { + return _pos; + }; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; + virtual bool isEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp new file mode 100644 index 0000000000..3b6f4c7c16 --- /dev/null +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -0,0 +1,50 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file_entry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h new file mode 100644 index 0000000000..ed80821004 --- /dev/null +++ b/engines/wintermute/base/file/base_file_entry.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp new file mode 100644 index 0000000000..fab6409c00 --- /dev/null +++ b/engines/wintermute/base/file/base_package.cpp @@ -0,0 +1,104 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h new file mode 100644 index 0000000000..52fc4f9677 --- /dev/null +++ b/engines/wintermute/base/file/base_package.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/base.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp new file mode 100644 index 0000000000..09cbae88fe --- /dev/null +++ b/engines/wintermute/base/file/base_resources.cpp @@ -0,0 +1,2820 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/file/base_resources.h" +#include "common/str.h" +#include "common/memstream.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + +Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { + if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h new file mode 100644 index 0000000000..6ec0541b5c --- /dev/null +++ b/engines/wintermute/base/file/base_resources.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace WinterMute { + +class CBResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &fileName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp new file mode 100644 index 0000000000..68200d3fc6 --- /dev/null +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -0,0 +1,146 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::open(const Common::String &filename) { + close(); + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (uint32 i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int slot = atoi(tempFilename); + delete [] tempFilename; + + char slotFilename[MAX_PATH_LENGTH + 1]; + _gameRef->getSaveSlotFilename(slot, slotFilename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _gameRef->_debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(slotFilename))) { + _gameRef->_debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + _gameRef->_debugAbsolutePathWarning = true; + + bool res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = STATUS_OK; + } else res = STATUS_FAILED; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return STATUS_FAILED; + + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::seek(uint32 pos, int whence) { + if (!_data) return STATUS_FAILED; + + uint32 newPos = 0; + + switch (whence) { + case SEEK_SET: + newPos = pos; + break; + case SEEK_END: + newPos = _size + pos; + break; + case SEEK_CUR: + newPos = _pos + pos; + break; + } + + if (newPos > _size) return STATUS_FAILED; + else _pos = newPos; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h new file mode 100644 index 0000000000..42566581e2 --- /dev/null +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -0,0 +1,52 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/base_file.h" + +namespace WinterMute { + +//TODO: Get rid of this +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFont.cpp b/engines/wintermute/base/font/BFont.cpp deleted file mode 100644 index 5d0086c581..0000000000 --- a/engines/wintermute/base/font/BFont.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontBitmap.h" -#include "engines/wintermute/base/font/BFontTT.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFont, false) - -////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { -} - - -////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - -/* -////////////////////////////////////////////////////////////////////// -bool CBFont::loadFile(const char * Filename) -{ - BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ - _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - CBParser parser(_gameRef); - - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ - -////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFont::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { - if (isTrueType(gameRef, filename)) { - CBFontTT *font = new CBFontTT(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - CBFontBitmap *font = new CBFontBitmap(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; - - byte *WorkBuffer = buffer; - - char *params; - CBParser parser(gameRef); - - bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - ret = true; - - delete [] buffer; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFont.h b/engines/wintermute/base/font/BFont.h deleted file mode 100644 index a6ab757b0d..0000000000 --- a/engines/wintermute/base/font/BFont.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H - -#include "engines/wintermute/base/BObject.h" - -#define NUM_CHARACTERS 256 - -namespace WinterMute { - -class CBFont: public CBObject { -public: - DECLARE_PERSISTENT(CBFont, CBObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - virtual void initLoop() {}; - virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); - - static CBFont *createFromFile(CBGame *game, const char *filename); - -private: - //bool loadBuffer(byte * Buffer); - //bool loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp deleted file mode 100644 index 62576cdfea..0000000000 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFontBitmap.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (maxLength >= 0 && str.size() > (uint32)maxLength) - str = Common::String(str.c_str(), (uint32)maxLength); - //str.substr(0, maxLength); // TODO: Remove - - int textWidth = 0; - for (int i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; - - if (text == NULL || text[0] == '\0') return _tileHeight; - - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - if (str.empty()) return 0; - - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool new_line = false; - bool long_line = false; - - if (draw) _gameRef->_renderer->startSpriteBatch(); - - while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) _gameRef->_renderer->endSpriteBatch(); - return NumLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { - end = index - 1; - RealLength = LineLength; - } - - if (str[index] == '\n') { - end = index - 1; - RealLength = LineLength; - new_line = true; - } - - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; - } - - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!new_line) { - end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; - } - } else LineLength += getCharWidth(str[index]); - - if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; - int StartX; - switch (align) { - case TAL_CENTER: - StartX = x + (width - RealLength) / 2; - break; - case TAL_RIGHT: - StartX = x + width - RealLength; - break; - case TAL_LEFT: - StartX = x; - break; - default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); - StartX += getCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (long_line) end--; - start = end + 2; - index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; - } - } - - if (draw) _gameRef->_renderer->endSpriteBatch(); - - return NumLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - Rect32 rect; - /* l t r b */ - int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; - - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); - bool handled = false; - if (_sprite) { - _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); - } - handled = true; - } - } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - int widths[300]; - int num = 0, default_width = 8; - int lastWidth = 0; - int i; - int r = 255, g = 255, b = 255; - bool custoTrans = false; - char *surfaceFile = NULL; - char *spriteFile = NULL; - - bool autoWidth = false; - int spaceWidth = 0; - int expandWidth = 0; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = (char *)params; - break; - - case TOKEN_SPRITE: - spriteFile = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_WIDTHS: - parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { - _widths[lastWidth] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); - break; - - case TOKEN_WIDTHS_FRAME: - parser.scanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.scanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.scanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.scanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.scanStr(params, "%b", &autoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.scanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.scanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.scanStr(params, "%d", &spaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.scanStr(params, "%d", &expandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - if (spriteFile != NULL) { - delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(_gameRef); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - _gameRef->LOG(0, "Incomplete font definition"); - return STATUS_FAILED; - } - - if (autoWidth) { - // calculate characters width - getWidths(); - - // do we need to modify widths? - if (expandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; - - _widths[i] = (byte)NewWidth; - } - } - - // handle space character - uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; - - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { - if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { - _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { - - CBFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); - - persistMgr->transfer(TMEMBER(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); - - if (persistMgr->_saving) - persistMgr->putBytes(_widths, sizeof(_widths)); - else - persistMgr->getBytes(_widths, sizeof(_widths)); - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::getWidths() { - CBSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int minCol = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; - if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - minCol = MAX(col, minCol); - break; - } - } - if (minCol == _tileWidth - 1) break; - } - - _widths[i] = minCol + 1; - } - surf->endPixelOp(); - /* - _gameRef->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontBitmap.h b/engines/wintermute/base/font/BFontBitmap.h deleted file mode 100644 index 17bf433f65..0000000000 --- a/engines/wintermute/base/font/BFontBitmap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H - - -#include "engines/wintermute/base/font/BFont.h" - -namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { -public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) - bool loadBuffer(byte *Buffer); - bool loadFile(const char *filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); - - - bool getWidths(); - CBSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; - bool _wholeCell; - -private: - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp deleted file mode 100644 index b5605cf2bc..0000000000 --- a/engines/wintermute/base/font/BFontStorage.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); - delete _fonts[i]; - } - _fonts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { - if (!filename) return NULL; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - CBFont* font = new CBFont(_gameRef); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - CBFont *font = CBFont::createFromFile(_gameRef, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::removeFont(CBFont *font) { - if (!font) return STATUS_FAILED; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.removeAt(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::persist(CBPersistMgr *persistMgr) { - - if (!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontStorage.h b/engines/wintermute/base/font/BFontStorage.h deleted file mode 100644 index 9759d5d25e..0000000000 --- a/engines/wintermute/base/font/BFontStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBFont; - -class CBFontStorage : public CBBase { -public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) - bool cleanup(bool warn = false); - bool removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; - bool initLoop(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp deleted file mode 100644 index 5f0c9fec1a..0000000000 --- a/engines/wintermute/base/font/BFontTT.cpp +++ /dev/null @@ -1,762 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/font/BFontTT.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFontTT, false) - -////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - _deletableFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { - clearCache(); - - for (int i = 0; i < _layers.getSize(); i++) { - delete _layers[i]; - } - _layers.removeAll(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (_gameRef->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; - } - } -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - measureText(textStr, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - - int textWidth, textHeight; - measureText(textStr, width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; - - WideString textStr = (char *)text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - CBRenderer *renderer = _gameRef->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - CBSurface *surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - minPriority = 0; - minIndex = i; - } else { - if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { - surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; - minIndex = i; - } - } - } - } - - // not found, create one - if (!surface) { - debugC(kWinterMuteDebugFont, "Draw text: %s", text); - surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); - if (surface) { - // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; - - _cachedTexts[minIndex]->_surface = surface; - _cachedTexts[minIndex]->_align = align; - _cachedTexts[minIndex]->_width = width; - _cachedTexts[minIndex]->_maxHeight = maxHeight; - _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; - _cachedTexts[minIndex]->_text = textStr; - _cachedTexts[minIndex]->_textOffset = textOffset; - _cachedTexts[minIndex]->_marked = true; - } - } - - - // and paint it - if (surface) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { - uint32 color = _layers[i]->_color; - uint32 origForceAlpha = renderer->_forceAlphaColor; - if (renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); - renderer->_forceAlphaColor = 0; - } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - renderer->_forceAlphaColor = origForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO - //WrapText(text, width, maxHeight, lines); - Common::Array lines; - _font->wordWrapText(text, width, lines); - - Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; - if (align == TAL_LEFT) { - alignment = Graphics::kTextAlignLeft; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - alignment = Graphics::kTextAlignRight; - } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); - } - - debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); -// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; - Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - else // We are using a fallback, they can't do 32bpp - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); - uint32 useColor = 0xffffffff; - Common::Array::iterator it; - int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += (int)_lineHeight; - } - - CBSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - _gameRef->LOG(0, "'TTFONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - uint32 BaseColor = 0x00000000; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.scanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.scanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.scanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.scanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.scanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); - } - break; - - case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TTFONT definition"); - return STATUS_FAILED; - } - - // create at least one layer - if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); - } - - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.scanStr(params, "%d", &layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.scanStr(params, "%d", &layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); - - - // persist layers - int numLayers; - if (persistMgr->_saving) { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); - } else { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->_saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; - - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); - if (!file) { - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); - if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; - } - } - - if (file) { -#ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - _gameRef->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } - if (maxWidth >= 0) { - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - Common::Array::iterator it; - textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { - textWidth = MAX(textWidth, _font->getStringWidth(*it)); - } - - //WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * getLineHeight()); - } else { - textWidth = _font->getStringWidth(text); - textHeight = _fontHeight; - } - /* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontTT.h b/engines/wintermute/base/font/BFontTT.h deleted file mode 100644 index 9b995b293e..0000000000 --- a/engines/wintermute/base/font/BFontTT.h +++ /dev/null @@ -1,180 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H - -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace WinterMute { - -class CBFontTT : public CBFont { -private: - ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - CBSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - CBCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~CBCachedTTFontText() { - if (_surface) delete _surface; - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { - public: - CBTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - bool persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - -public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); - - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - bool loadBuffer(byte *buffer); - bool loadFile(const char *filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - bool parseLayer(CBTTFontLayer *layer, byte *buffer); - - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - - - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - bool initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _ascender; - float _descender; - float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - CBArray _layers; - void clearCache(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp new file mode 100644 index 0000000000..8976cfdabd --- /dev/null +++ b/engines/wintermute/base/font/base_font.cpp @@ -0,0 +1,206 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +bool CBFont::loadFile(const char * Filename) +{ + BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + if(Buffer==NULL){ + _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); + + if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFont::loadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(_gameRef); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFont::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { + if (isTrueType(gameRef, filename)) { + CBFontTT *font = new CBFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + CBFontBitmap *font = new CBFontBitmap(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; + + byte *WorkBuffer = buffer; + + char *params; + CBParser parser(gameRef); + + bool ret = false; + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + ret = true; + + delete [] buffer; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h new file mode 100644 index 0000000000..3df3090bb9 --- /dev/null +++ b/engines/wintermute/base/font/base_font.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/base/base_object.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {}; + virtual void afterLoad() {}; + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *createFromFile(CBGame *game, const char *filename); + +private: + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); + static bool isTrueType(CBGame *game, const char *filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp new file mode 100644 index 0000000000..ef730afb0a --- /dev/null +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -0,0 +1,540 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (int i = 0; i < str.size(); i++) { + textWidth += getCharWidth(str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) _gameRef->_renderer->startSpriteBatch(); + + while (!done) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (draw) _gameRef->_renderer->endSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += getCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += getCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) _gameRef->_renderer->endSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; + + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new CBSubFrame(_gameRef); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + _gameRef->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + expandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; + + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; + else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { + + CBFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); + else + persistMgr->getBytes(_widths, sizeof(_widths)); + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::getWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) break; + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + _gameRef->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h new file mode 100644 index 0000000000..8af530cbc9 --- /dev/null +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/base/font/base_font.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const char *filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + bool getWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp new file mode 100644 index 0000000000..13f779f2cb --- /dev/null +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -0,0 +1,135 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.getSize(); i++) { + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::initLoop() { + for (int i = 0; i < _fonts.getSize(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::addFont(const char *filename) { + if (!filename) return NULL; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + CBFont *font = CBFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.removeAt(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::persist(CBPersistMgr *persistMgr) { + + if (!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h new file mode 100644 index 0000000000..7c88e9a2f4 --- /dev/null +++ b/engines/wintermute/base/font/base_font_storage.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + bool cleanup(bool warn = false); + bool removeFont(CBFont *font); + CBFont *addFont(const char *filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + bool initLoop(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp new file mode 100644 index 0000000000..a52922fb76 --- /dev/null +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -0,0 +1,762 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + clearCache(); + + for (int i = 0; i < _layers.getSize(); i++) { + delete _layers[i]; + } + _layers.removeAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; + +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (_gameRef->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; + + WideString textStr = (char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + debugC(kWinterMuteDebugFont, "Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (int i = 0; i < _layers.getSize(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } + + debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + if (_deletableFont) // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + else // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + uint32 useColor = 0xffffffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + CBSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + _gameRef->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.getSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.add(Layer); + } + + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->_saving) { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + } else { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + if (!file) { + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + } + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + _gameRef->_fileManager->closeFile(file); + return STATUS_FAILED; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return STATUS_FAILED; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h new file mode 100644 index 0000000000..4d8e71a3ff --- /dev/null +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -0,0 +1,180 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString getText() const { + return _text; + } + int getWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + bool loadBuffer(byte *buffer); + bool loadFile(const char *filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(CBTTFontLayer *layer, byte *buffer); + + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void clearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index f1e27c9622..fb6b23db2b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -28,10 +28,10 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#include "engines/wintermute/utils/string_util.h" #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 646a9ddd2d..6cda3e6b46 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BIMAGE_H #define WINTERMUTE_BIMAGE_H -#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/base.h" #include "graphics/surface.h" #include "graphics/pixelformat.h" #include "graphics/decoders/image_decoder.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 5c5ebd91b4..a8c19362f6 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -27,11 +27,11 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 81c13f8b39..d743f19791 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -31,7 +31,7 @@ #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/base.h" #include "common/rect.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 6c0ca40765..73b385d180 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/wintypes.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/base_surface.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index f5fbd495aa..22c1fb83b8 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_BSURFACE_H #define WINTERMUTE_BSURFACE_H -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" #include "graphics/surface.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ee971ab6c9..dbd2511928 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -28,15 +28,15 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" #include "common/system.h" -#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/transparent_surface.h" #include "common/queue.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 66c6e4a61a..87c5731b49 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -26,9 +26,9 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -36,7 +36,7 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" -#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/tga.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp deleted file mode 100644 index 97de1fe044..0000000000 --- a/engines/wintermute/base/particles/PartEmitter.cpp +++ /dev/null @@ -1,1199 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/particles/PartEmitter.h" -#include "engines/wintermute/base/particles/PartParticle.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/math.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CPartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - _width = _height = 0; - - CBPlatform::setRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = Owner; -} - - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - for (int i = 0; i < _forces.getSize(); i++) { - delete _forces[i]; - } - _forces.removeAll(); - - - for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; - } - _sprites.removeAll(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; - - // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; - } - - // check if file exists - Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); - if (!File) { - _gameRef->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else _gameRef->_fileManager->closeFile(File); - - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; - _sprites.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; - - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); - - float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); - - float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); - - int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); - - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); - - if (!CBPlatform::isRectEmpty(&_border)) { - int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); - int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); - int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); - int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - - particle->_border = _border; - particle->_border.left += thicknessLeft; - particle->_border.right -= thicknessRight; - particle->_border.top += thicknessTop; - particle->_border.bottom -= thicknessBottom; - } - - Vector2 vecPos((float)posX, (float)posY); - Vector2 vecVel(0, velocity); - - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); - particle->_alpha1 = alpha; - particle->_alpha2 = alpha; - } - - particle->_creationTime = currentTime; - particle->_pos = vecPos; - particle->_posZ = posZ; - particle->_velocity = vecVel; - particle->_scale = scale; - particle->_lifeTime = lifeTime; - particle->_rotation = rotation; - particle->_angVelocity = angVelocity; - particle->_growthRate = growthRate; - particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); - particle->fadeIn(currentTime, _fadeInTime); - - - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->update(this, currentTime, timerDelta); - - if (!_particles[i]->_isDead) numLive++; - } - - - // we're understaffed - if (numLive < _maxParticles) { - bool needsSort = false; - if ((int)(currentTime - _lastGenTime) > _genInterval) { - _lastGenTime = currentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return STATUS_OK; - } - - int toGen = MIN(_genAmount, _maxParticles - numLive); - while (toGen > 0) { - int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - CPartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { - particle = new CPartParticle(_gameRef); - _particles.add(particle); - } - initParticle(particle, currentTime, timerDelta); - needsSort = true; - - toGen--; - } - } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - sortParticlesByZ(); - - // we actually generated some particles and we're not in fast-forward mode - if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::display(CBRegion *region) { - if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); - - for (int i = 0; i < _particles.getSize(); i++) { - if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; - } - - _particles[i]->display(this); - } - - if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 delta = 500; - int steps = _overheadTime / delta; - uint32 currentTime = _gameRef->_timer - _overheadTime; - - for (int i = 0; i < steps; i++) { - updateInternal(currentTime, delta); - currentTime += delta; - } - _overheadTime = 0; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::sortParticlesByZ() { - // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; - - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; - - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new CPartForce(_gameRef); - if (force) { - force->setName(name); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeForce(const char *name) { - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - delete _forces[i]; - _forces.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetBorder") == 0) { - stack->correctParams(4); - int borderX = stack->pop()->getInt(); - int borderY = stack->pop()->getInt(); - int borderWidth = stack->pop()->getInt(); - int borderHeight = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBorderThickness") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Start") == 0) { - stack->correctParams(1); - _overheadTime = stack->pop()->getInt(); - stack->pushBool(DID_SUCCEED(start())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Stop") == 0) { - stack->correctParams(0); - - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Resume") == 0) { - stack->correctParams(0); - _running = true; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddGlobalForce") == 0) { - stack->correctParams(3); - const char *forceName = stack->pop()->getString(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddPointForce") == 0) { - stack->correctParams(5); - const char *forceName = stack->pop()->getString(); - int posX = stack->pop()->getInt(); - int posY = stack->pop()->getInt(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveForce") == 0) { - stack->correctParams(1); - const char *forceName = stack->pop()->getString(); - - stack->pushBool(DID_SUCCEED(removeForce(forceName))); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - -////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scValue->setFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scValue->setFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->setBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _scValue->setFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _scValue->setFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->setBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _scValue->setInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _scValue->setInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->setBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _scValue->setInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _scValue->setInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->setFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->setFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _scValue->setFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _scValue->setFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _scValue->setInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _scValue->setInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->setBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _scValue->setInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { - int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; - } - _scValue->setInt(numAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->setInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->setInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _scValue->setInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _scValue->setInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->setInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->setFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->setFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->setBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _scValue->setBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); - - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); - - persistMgr->transfer(TMEMBER(_velocity1)); - persistMgr->transfer(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); - - persistMgr->transfer(TMEMBER(_scale1)); - persistMgr->transfer(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); - - persistMgr->transfer(TMEMBER(_maxParticles)); - - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); - - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); - - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); - - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); - - persistMgr->transfer(TMEMBER(_angVelocity1)); - persistMgr->transfer(TMEMBER(_angVelocity2)); - - persistMgr->transfer(TMEMBER(_rotation1)); - persistMgr->transfer(TMEMBER(_rotation2)); - - persistMgr->transfer(TMEMBER(_growthRate1)); - persistMgr->transfer(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - - persistMgr->transfer(TMEMBER(_useRegion)); - - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - - persistMgr->transfer(TMEMBER(_emitEvent)); - persistMgr->transfer(TMEMBER(_owner)); - - - _sprites.persist(persistMgr); - - int numForces; - if (persistMgr->_saving) { - numForces = _forces.getSize(); - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(_gameRef); - force->persist(persistMgr); - _forces.add(force); - } - } - - int numParticles; - if (persistMgr->_saving) { - numParticles = _particles.getSize(); - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(_gameRef); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartEmitter.h b/engines/wintermute/base/particles/PartEmitter.h deleted file mode 100644 index 5156783653..0000000000 --- a/engines/wintermute/base/particles/PartEmitter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/particles/PartForce.h" - -namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { -public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) - - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); - - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - Rect32 _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - int _fadeOutTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - CBScriptHolder *_owner; - - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(CBRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); - - CBArray _forces; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - CPartForce *addForceByName(const char *name); - int static compareZ(const void *obj1, const void *obj2); - bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - bool updateInternal(uint32 currentTime, uint32 timerDelta); - uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/PartForce.cpp b/engines/wintermute/base/particles/PartForce.cpp deleted file mode 100644 index b864c05292..0000000000 --- a/engines/wintermute/base/particles/PartForce.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/particles/PartForce.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartForce::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartForce.h b/engines/wintermute/base/particles/PartForce.h deleted file mode 100644 index 640c8d7f20..0000000000 --- a/engines/wintermute/base/particles/PartForce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BNamedObject.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartForce : public CBNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - bool persist(CBPersistMgr *PersistMgr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp deleted file mode 100644 index 1439231993..0000000000 --- a/engines/wintermute/base/particles/PartParticle.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/particles/PartParticle.h" -#include "engines/wintermute/base/particles/PartEmitter.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - CBPlatform::setRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(_gameRef, _gameRef); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { - if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - - return STATUS_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _isDead = true; - return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - - return STATUS_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) - fadeOut(currentTime, emitter->_fadeOutTime); - else - _isDead = true; - } - } - - // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) - fadeOut(currentTime, emitter->_fadeOutTime); - } - if (_state != PARTICLE_NORMAL) return STATUS_OK; - - // update alpha - if (_lifeTime > 0) { - int age = (int)(currentTime - _creationTime); - int alphaDelta = (int)(_alpha2 - _alpha1); - - _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); - } - - // update position - float elapsedTime = (float)timerDelta / 1000.f; - - for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; - switch (force->_type) { - case CPartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case CPartForce::FORCE_POINT: { - Vector2 vecDist = force->_pos - _pos; - float dist = fabs(vecDist.length()); - - dist = 100.0f / dist; - - _velocity += force->_direction * dist * elapsedTime; - } - break; - } - } - _pos += _velocity * elapsedTime; - - // update rotation - _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * elapsedTime; - else - _scale += _growthRate * elapsedTime; - - if (_scale <= 0.0f) - _isDead = true; - - - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::display(CPartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; - - _sprite->GetCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_angVelocity)); - persistMgr->transfer(TMEMBER(_rotation)); - persistMgr->transfer(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - - if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartParticle.h b/engines/wintermute/base/particles/PartParticle.h deleted file mode 100644 index ab5730d3c5..0000000000 --- a/engines/wintermute/base/particles/PartParticle.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTPARTICLE_H -#define WINTERMUTE_PARTPARTICLE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartEmitter; -class CBSprite; -class CBPersistMgr; - -class CPartParticle : public CBBase { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - CBSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(CPartEmitter *emitter); - - bool setSprite(const char *filename); - - bool fadeIn(uint32 currentTime, int fadeTime); - bool fadeOut(uint32 currentTime, int fadeTime); - - bool persist(CBPersistMgr *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp new file mode 100644 index 0000000000..11ebafd329 --- /dev/null +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -0,0 +1,1199 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/math.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + for (int i = 0; i < _forces.getSize(); i++) { + delete _forces[i]; + } + _forces.removeAll(); + + + for (int i = 0; i < _sprites.getSize(); i++) { + delete [] _sprites[i]; + } + _sprites.removeAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; + + // do we already have the file? + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + } + + // check if file exists + Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else _gameRef->_fileManager->closeFile(File); + + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); + _sprites.add(Str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeSprite(const char *filename) { + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; + + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); + + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::update() { + if (!_running) return STATUS_OK; + else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) numLive++; + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; + else { + particle = new CPartParticle(_gameRef); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + sortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::display(CBRegion *region) { + if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + + for (int i = 0; i < _particles.getSize(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + } + + _particles[i]->display(this); + } + + if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::start() { + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = _gameRef->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::sortParticlesByZ() { + // sort particles by _posY + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; + + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::addForceByName(const char *name) { + CPartForce *force = NULL; + + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new CPartForce(_gameRef); + if (force) { + force->setName(name); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return STATUS_FAILED; + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeForce(const char *name) { + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) numAlive++; + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + int numForces; + if (persistMgr->_saving) { + numForces = _forces.getSize(); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < _forces.getSize(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + int numParticles; + if (persistMgr->_saving) { + numParticles = _particles.getSize(); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(_gameRef); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h new file mode 100644 index 0000000000..cff0a1ec83 --- /dev/null +++ b/engines/wintermute/base/particles/part_emitter.h @@ -0,0 +1,139 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/particles/part_force.h" + +namespace WinterMute { +class CBRegion; +class CPartParticle; +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(CBRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + CBArray _forces; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + CPartForce *addForceByName(const char *name); + int static compareZ(const void *obj1, const void *obj2); + bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp new file mode 100644 index 0000000000..2f330c21b0 --- /dev/null +++ b/engines/wintermute/base/particles/part_force.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/particles/part_force.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartForce::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h new file mode 100644 index 0000000000..f0a6d66c43 --- /dev/null +++ b/engines/wintermute/base/particles/part_force.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/math/vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp new file mode 100644 index 0000000000..931f7558c7 --- /dev/null +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -0,0 +1,257 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::getInstance()->_disabled = true; + _sprite = new CBSprite(_gameRef, _gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!CBPlatform::ptInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return STATUS_OK; + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (int i = 0; i < emitter->_forces.getSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = CBUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * elapsedTime; + else + _scale += _growthRate * elapsedTime; + + if (_scale <= 0.0f) + _isDead = true; + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; + + _sprite->GetCurrentFrame(); + return _sprite->display(_pos.x, _pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + CSysClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + CSysClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h new file mode 100644 index 0000000000..0b256d44ec --- /dev/null +++ b/engines/wintermute/base/particles/part_particle.h @@ -0,0 +1,90 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/math/vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(CPartEmitter *emitter); + + bool setSprite(const char *filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXArray.cpp b/engines/wintermute/base/scriptables/SXArray.cpp deleted file mode 100644 index 425118a3e7..0000000000 --- a/engines/wintermute/base/scriptables/SXArray.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/system/SysInstance.h" -#include "engines/wintermute/base/scriptables/SXArray.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXArray, false) - -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { - return new CSXArray(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); - - int numParams = stack->pop()->getInt(0); - - if (numParams == 1) _length = stack->pop()->getInt(0); - else if (numParams > 1) { - _length = numParams; - char paramName[20]; - for (int i = 0; i < numParams; i++) { - sprintf(paramName, "%d", i); - _values->setProp(paramName, stack->pop()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXArray::scToString() { - static char dummy[32768]; // TODO: Get rid of static. - strcpy(dummy, ""); - char propName[20]; - for (int i = 0; i < _length; i++) { - sprintf(propName, "%d", i); - CScValue *val = _values->getProp(propName); - if (val) { - if (strlen(dummy) + strlen(val->getString()) < 32768) { - strcat(dummy, val->getString()); - } - } - - if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); - } - return dummy; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Push - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Push") == 0) { - int numParams = stack->pop()->getInt(0); - char paramName[20]; - - for (int i = 0; i < numParams; i++) { - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, stack->pop(), true); - } - stack->pushInt(_length); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pop - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Pop") == 0) { - - stack->correctParams(0); - - if (_length > 0) { - char paramName[20]; - sprintf(paramName, "%d", _length - 1); - stack->push(_values->getProp(paramName)); - _values->deleteProp(paramName); - _length--; - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("array"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(_length); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char ParamName[20]; - if (validNumber(name, ParamName)) { - return _values->getProp(ParamName); - } else return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length") == 0) { - int OrigLength = _length; - _length = MAX(value->getInt(0), 0); - - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->deleteProp(PropName); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char paramName[20]; - if (validNumber(name, paramName)) { - int Index = atoi(paramName); - if (Index >= _length) _length = Index + 1; - return _values->setProp(paramName, value); - } else return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_length)); - persistMgr->transfer(TMEMBER(_values)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::validNumber(const char *origStr, char *outStr) { - bool isNumber = true; - for (uint32 i = 0; i < strlen(origStr); i++) { - if (!(origStr[i] >= '0' && origStr[i] <= '9')) { - isNumber = false; - break; - } - } - - if (isNumber) { - int index = atoi(origStr); - sprintf(outStr, "%d", index); - return true; - } else return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::push(CScValue *val) { - char paramName[20]; - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, val, true); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXArray.h b/engines/wintermute/base/scriptables/SXArray.h deleted file mode 100644 index 0f46bd546e..0000000000 --- a/engines/wintermute/base/scriptables/SXArray.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXArray : public CBScriptable { -public: - bool push(CScValue *Val); - bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - int _length; - CScValue *_values; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXDate.cpp b/engines/wintermute/base/scriptables/SXDate.cpp deleted file mode 100644 index cd705cc9d4..0000000000 --- a/engines/wintermute/base/scriptables/SXDate.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/SXDate.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXDate, false) - -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(6); - - memset(&_tm, 0, sizeof(_tm)); - - CScValue *valYear = stack->pop(); - _tm.tm_year = valYear->getInt() - 1900; - _tm.tm_mon = stack->pop()->getInt() - 1; - _tm.tm_mday = stack->pop()->getInt(); - _tm.tm_hour = stack->pop()->getInt(); - _tm.tm_min = stack->pop()->getInt(); - _tm.tm_sec = stack->pop()->getInt(); - - if (valYear->isNULL()) { - g_system->getTimeAndDate(_tm); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { - -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXDate::scToString() { - // TODO: Make this more stringy, and less ISO 8601-like - _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); - return _strRep.c_str(); -#if 0 - return asctime(&_tm); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetYear - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetYear") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_year + 1900); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMonth") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mon + 1); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDate") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mday); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHours") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_hour); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMinutes") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_min); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSeconds") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_sec); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetWeekday - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWeekday") == 0) { - stack->correctParams(0); - warning("GetWeekday returns a wrong value on purpose"); - stack->pushInt(_tm.tm_mday % 7); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetYear - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetYear") == 0) { - stack->correctParams(1); - _tm.tm_year = stack->pop()->getInt() - 1900; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMonth") == 0) { - stack->correctParams(1); - _tm.tm_mon = stack->pop()->getInt() - 1; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDate") == 0) { - stack->correctParams(1); - _tm.tm_mday = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHours") == 0) { - stack->correctParams(1); - _tm.tm_hour = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMinutes") == 0) { - stack->correctParams(1); - _tm.tm_min = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSeconds") == 0) { - stack->correctParams(1); - _tm.tm_sec = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetCurrentTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCurrentTime") == 0) { - stack->correctParams(0); - g_system->getTimeAndDate(_tm); - stack->pushNULL(); - return STATUS_OK; - } - - else - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("date"); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Name")==0){ - setName(value->getString()); - return STATUS_OK; - } - - else*/ return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_tm.tm_year)); - persistMgr->transfer(TMEMBER(_tm.tm_mon)); - persistMgr->transfer(TMEMBER(_tm.tm_mday)); - persistMgr->transfer(TMEMBER(_tm.tm_hour)); - persistMgr->transfer(TMEMBER(_tm.tm_min)); - persistMgr->transfer(TMEMBER(_tm.tm_sec)); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CSXDate::scCompare(CBScriptable *Value) { - TimeDate time1 = _tm; - TimeDate time2 = ((CSXDate *)Value)->_tm; - - if (time1.tm_year < time2.tm_year) { - return -1; - } else if (time1.tm_year == time2.tm_year) { - if (time1.tm_mon < time2.tm_mon) { - return -1; - } else if (time1.tm_mon == time2.tm_mon) { - if (time1.tm_mday < time2.tm_mday) { - return -1; - } else if (time1.tm_mday == time2.tm_mday) { - if (time1.tm_hour < time2.tm_hour) { - return -1; - } else if (time1.tm_hour == time2.tm_hour) { - if (time1.tm_min < time2.tm_min) { - return -1; - } else if (time1.tm_min == time2.tm_min) { - if (time1.tm_sec < time2.tm_sec) { - return -1; - } else if (time1.tm_sec == time2.tm_sec) { - return 0; // Equal - } else { - return 1; // Sec - } - } else { - return 1; // Minute - } - } else { - return 1; // Hour - } - } else { - return 1; // Day - } - } else { - return 1; // Month - } - } else { - return 1; // Year - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXDate.h b/engines/wintermute/base/scriptables/SXDate.h deleted file mode 100644 index df0641983f..0000000000 --- a/engines/wintermute/base/scriptables/SXDate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXDATE_H -#define WINTERMUTE_SXDATE_H - -#include "common/system.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXDate : public CBScriptable { -public: - int scCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - char *_string; - TimeDate _tm; -private: - Common::String _strRep; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp deleted file mode 100644 index 1924a42d72..0000000000 --- a/engines/wintermute/base/scriptables/SXFile.cpp +++ /dev/null @@ -1,779 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/system/SysClassRegistry.h" -#include "engines/wintermute/system/SysClass.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/SXFile.h" - -// Note: This code is completely untested, as I have yet to find a game that uses SXFile. - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXFile, false) - -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { - return new CSXFile(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - _filename = NULL; - if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXFile::cleanup() { - delete[] _filename; - _filename = NULL; - close(); -} - - -////////////////////////////////////////////////////////////////////////// -void CSXFile::close() { - if (_readFile) { - _gameRef->_fileManager->closeFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - _writeFile->finalize(); - delete _writeFile; - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXFile::scToString() { - if (_filename) return _filename; - else return "[file object]"; -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFilename") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - cleanup(); - CBUtils::setString(&_filename, filename); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenAsText / OpenAsBinary - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->correctParams(1); - close(); - _mode = stack->pop()->getInt(1); - if (_mode < 1 || _mode > 3) { - script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); - _mode = 1; - } - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) { - //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } else { - if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = openForWrite(_filename, false); - else _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) _writeFile = openForWrite(_filename, true); - else _writeFile = openForAppend(_filename, true); - } - - if (!_writeFile) { - //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } - - if (_readFile || _writeFile) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - close(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPosition") == 0) { - stack->correctParams(1); - if (_mode == 0) { - script->runtimeError("File.%s: File is not open", name); - stack->pushBool(false); - } else { - int Pos = stack->pop()->getInt(); - stack->pushBool(setPos(Pos)); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Delete - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delete") == 0) { - stack->correctParams(0); - close(); - stack->pushBool(CBPlatform::deleteFile(_filename) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Copy - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Copy") == 0) { - stack->correctParams(2); - const char *Dest = stack->pop()->getString(); - bool Overwrite = stack->pop()->getBool(true); - - close(); - stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadLine") == 0) { - stack->correctParams(0); - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - bool foundNewLine = false; - bool ret = STATUS_FAILED; - do { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == '\n') { - buf[counter] = '\0'; - foundNewLine = true; - break; - } else if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } while (DID_SUCCEED(ret)); - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (!foundNewLine && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadText") == 0) { - stack->correctParams(1); - int textLen = stack->pop()->getInt(); - - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - - bool ret = STATUS_FAILED; - while (counter < (uint32)textLen) { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (textLen > 0 && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteLine / WriteText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->correctParams(1); - const char *line = stack->pop()->getString(); - if (!_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in text mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - Common::String writeLine; - if (strcmp(name, "WriteLine") == 0) { - writeLine = Common::String::format("%s\n", line); - } else { - writeLine = Common::String::format("%s", line); - } - _writeFile->writeString(writeLine); - _writeFile->writeByte(0); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ReadBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadBool") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadByte") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - byte val = _readFile->readByte(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadShort") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int16 val = _readFile->readSint16LE(); - if (!_readFile->err()) { - stack->pushInt(65536 + val); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadInt / ReadLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int32 val = _readFile->readSint32LE(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadFloat") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - float val; - (*(uint32*)&val) = _readFile->readUint32LE(); - if (!_readFile->err()) { - stack->pushFloat(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. - error("SXFile::ReadDouble - Not endian safe yet"); - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadString") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 size = _readFile->readUint32LE(); - if (!_readFile->err()) { - byte *str = new byte[size + 1]; - if (str) { - if (_readFile->read(str, size) == size) { - str[size] = '\0'; - stack->pushString((char *)str); - } - delete [] str; - } else stack->pushNULL(); - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteByte") == 0) { - stack->correctParams(1); - byte val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteShort") == 0) { - stack->correctParams(1); - int16 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint16LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteInt / WriteLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->correctParams(1); - int32 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint32LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteFloat") == 0) { - stack->correctParams(1); - float val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - uint32 *ptr = (uint32*)&val; - _writeFile->writeUint32LE(*ptr); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteDouble") == 0) { - error("SXFile::WriteDouble - Not endian safe yet"); - stack->correctParams(1); - double val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteString") == 0) { - stack->correctParams(1); - const char *val = stack->pop()->getString(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - - uint32 size = strlen(val); - _writeFile->writeUint32LE(size); - _writeFile->writeString(val); - - stack->pushBool(true); - - return STATUS_OK; - } - - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("file"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Position (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { - _scValue->setInt(getPos()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(getLength()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { - _scValue->setBool(_textMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccessMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { - _scValue->setInt(_mode); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getPos() { - if (_mode == 1 && _readFile) - return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - getPos for WriteFile not supported"); - return 0; -// return ftell((FILE *)_writeFile); - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) - return _readFile->seek(pos, whence); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - seeking in WriteFile not supported"); - return false; -// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; - } - else return false; -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getLength() { - if (_mode == 1 && _readFile) - return _readFile->size(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - reading length for WriteFile not supported"); - return 0; -/* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); - - uint32 pos = 0; - if (persistMgr->_saving) { - pos = getPos(); - persistMgr->transfer(TMEMBER(pos)); - } else { - persistMgr->transfer(TMEMBER(pos)); - - // try to re-open file if needed - _writeFile = NULL; - _readFile = NULL; - - if (_mode != 0) { - // open for reading - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) - close(); - } - // open for writing / appending - else { - if (_textMode) { - if (_mode == 2) - _writeFile = openForWrite(_filename, false); - else - _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) - _writeFile = openForWrite(_filename, true); - else - _writeFile = openForAppend(_filename, true); - } - if (_writeFile) - close(); - } - setPos(pos); - } - } - - return STATUS_OK; -} - -// Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { - error("SXFile::openForWrite - WriteFiles not supported"); -} - -// Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXFile.h b/engines/wintermute/base/scriptables/SXFile.h deleted file mode 100644 index 709d1f4378..0000000000 --- a/engines/wintermute/base/scriptables/SXFile.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTES_SXFILE_H -#define WINTERMUTES_SXFILE_H - - -#include "engines/wintermute/base/BScriptable.h" -#include "common/stream.h" - -namespace WinterMute { - -class CBFile; - -class CSXFile : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); -private: - Common::SeekableReadStream *_readFile; - Common::WriteStream *_writeFile; - int _mode; // 0..none, 1..read, 2..write, 3..append - bool _textMode; - void close(); - void cleanup(); - uint32 getPos(); - uint32 getLength(); - bool setPos(uint32 Pos, int whence = SEEK_SET); - char *_filename; - Common::WriteStream *openForWrite(const Common::String &filename, bool binary); - Common::WriteStream *openForAppend(const Common::String &filename, bool binary); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXMath.cpp b/engines/wintermute/base/scriptables/SXMath.cpp deleted file mode 100644 index fb2838ee94..0000000000 --- a/engines/wintermute/base/scriptables/SXMath.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/persistent.h" -#include "common/math.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -IMPLEMENT_PERSISTENT(CSXMath, true) - -CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); -} - -////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Abs - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Abs") == 0) { - stack->correctParams(1); - stack->pushFloat(fabs(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Acos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Acos") == 0) { - stack->correctParams(1); - stack->pushFloat(acos(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Asin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Asin") == 0) { - stack->correctParams(1); - stack->pushFloat(asin(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan") == 0) { - stack->correctParams(1); - stack->pushFloat(atan(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan2") == 0) { - stack->correctParams(2); - double y = stack->pop()->getFloat(); - double x = stack->pop()->getFloat(); - stack->pushFloat(atan2(y, x)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Ceil - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ceil") == 0) { - stack->correctParams(1); - stack->pushFloat(ceil(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cos") == 0) { - stack->correctParams(1); - stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cosh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cosh") == 0) { - stack->correctParams(1); - stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exp") == 0) { - stack->correctParams(1); - stack->pushFloat(exp(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Floor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Floor") == 0) { - stack->correctParams(1); - stack->pushFloat(floor(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log") == 0) { - stack->correctParams(1); - stack->pushFloat(log(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log10 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log10") == 0) { - stack->correctParams(1); - stack->pushFloat(log10(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pow") == 0) { - stack->correctParams(2); - double x = stack->pop()->getFloat(); - double y = stack->pop()->getFloat(); - - stack->pushFloat(pow(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sin") == 0) { - stack->correctParams(1); - stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sinh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sinh") == 0) { - stack->correctParams(1); - stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tan") == 0) { - stack->correctParams(1); - stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tanh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tanh") == 0) { - stack->correctParams(1); - stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sqrt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sqrt") == 0) { - stack->correctParams(1); - stack->pushFloat(sqrt(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DegToRad - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DegToRad") == 0) { - stack->correctParams(1); - stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RadToDeg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RadToDeg") == 0) { - stack->correctParams(1); - stack->pushFloat(radianToDegree(stack->pop()->getFloat())); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("math"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PI - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { - _scValue->setFloat(M_PI); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::degreeToRadian(double value) { - return value * (M_PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::radianToDegree(double value) { - return value * (180.0f / M_PI); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMath.h b/engines/wintermute/base/scriptables/SXMath.h deleted file mode 100644 index 4389de611f..0000000000 --- a/engines/wintermute/base/scriptables/SXMath.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMATH_H -#define WINTERMUTE_SXMATH_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXMath : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - -private: - double degreeToRadian(double value); - double radianToDegree(double value); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.cpp b/engines/wintermute/base/scriptables/SXMemBuffer.cpp deleted file mode 100644 index 9ac98ab11d..0000000000 --- a/engines/wintermute/base/scriptables/SXMemBuffer.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/SXMemBuffer.h" -#include "common/file.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) - -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { - return new CSXMemBuffer(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - _buffer = NULL; - _size = 0; - - int NewSize = stack->pop()->getInt(); - resize(MAX(0, NewSize)); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - _size = 0; - _buffer = Buffer; -} - - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::scToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::cleanup() { - if (_size) free(_buffer); - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::resize(int newSize) { - int oldSize = _size; - - if (_size == 0) { - _buffer = malloc(newSize); - if (_buffer) _size = newSize; - } else { - void *newBuf = realloc(_buffer, newSize); - if (!newBuf) { - if (newSize == 0) { - _buffer = newBuf; - _size = newSize; - } else return STATUS_FAILED; - } else { - _buffer = newBuf; - _size = newSize; - } - } - - if (_buffer && _size > oldSize) { - memset((byte *)_buffer + oldSize, 0, _size - oldSize); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { - if (_buffer == NULL) { - script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); - return false; - } - if (_size == 0) - return true; - - if (start < 0 || length == 0 || start + length > _size) { - script->runtimeError("Set/Get method call is out of bounds"); - return false; - } else - return true; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::scToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSize - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSize") == 0) { - stack->correctParams(1); - int newSize = stack->pop()->getInt(); - newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBool") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) - stack->pushNULL(); - else - stack->pushBool(*(bool *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetByte") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) - stack->pushNULL(); - else - stack->pushInt(*(byte *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetShort") == 0) { - stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) - stack->pushNULL(); - else - stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInt / GetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) - stack->pushNULL(); - else - stack->pushInt(*(int *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFloat") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) - stack->pushNULL(); - else - stack->pushFloat(*(float *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDouble") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) - stack->pushNULL(); - else - stack->pushFloat(*(double *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int length = stack->pop()->getInt(); - - // find end of string - if (length == 0 && start >= 0 && start < _size) { - for (int i = start; i < _size; i++) { - if (((char *)_buffer)[i] == '\0') { - length = i - start; - break; - } - } - } - - if (!checkBounds(script, start, length)) - stack->pushNULL(); - else { - char *str = new char[length + 1]; - strncpy(str, (const char *)_buffer + start, length); - str[length] = '\0'; - stack->pushString(str); - delete [] str; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPointer") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) - stack->pushNULL(); - else { - void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); - stack->pushNative(buf, false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBool") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - bool val = stack->pop()->getBool(); - - if (!checkBounds(script, start, sizeof(bool))) - stack->pushBool(false); - else { - *(bool *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetByte") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - byte val = (byte)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(byte))) - stack->pushBool(false); - else { - *(byte *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetShort") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - short val = (short)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(short))) - stack->pushBool(false); - else { - *(short *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInt / SetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int val = stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(int))) - stack->pushBool(false); - else { - *(int *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFloat") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - float val = (float)stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(float))) - stack->pushBool(false); - else { - *(float *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDouble") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - double val = stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(double))) - stack->pushBool(false); - else { - *(double *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - const char *val = stack->pop()->getString(); - - if (!checkBounds(script, start, strlen(val) + 1)) - stack->pushBool(false); - else { - memcpy((byte *)_buffer + start, val, strlen(val) + 1); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPointer") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - /* CScValue *Val = */ stack->pop(); - - if (!checkBounds(script, start, sizeof(void *))) - stack->pushBool(false); - else { - /* - int Pointer = (int)Val->getMemBuffer(); - memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->pushBool(true); - */ - // TODO fix - stack->pushBool(false); - - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_Dump - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->correctParams(0); - if (_buffer && _size) { - warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); - Common::DumpFile f; - f.open("buffer.bin"); - f.write(_buffer, _size); - f.close(); - } - stack->pushNULL(); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("membuffer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Size (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { - _scValue->setInt(_size); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_size)); - - if (persistMgr->_saving) { - if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); - } else { - if (_size > 0) { - _buffer = malloc(_size); - persistMgr->getBytes((byte *)_buffer, _size); - } else _buffer = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *val) { - if (_buffer == val->scToMemBuffer()) return 0; - else return 1; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.h b/engines/wintermute/base/scriptables/SXMemBuffer.h deleted file mode 100644 index 09831bf464..0000000000 --- a/engines/wintermute/base/scriptables/SXMemBuffer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXMemBuffer : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *stack); - CSXMemBuffer(CBGame *inGame, void *buffer); - virtual ~CSXMemBuffer(); - virtual void *scToMemBuffer(); - int _size; -private: - bool resize(int newSize); - void *_buffer; - void cleanup(); - bool checkBounds(CScScript *script, int start, int length); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXString.cpp b/engines/wintermute/base/scriptables/SXString.cpp deleted file mode 100644 index ed3d243cb0..0000000000 --- a/engines/wintermute/base/scriptables/SXString.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/scriptables/SXString.h" -#include "engines/wintermute/base/scriptables/SXArray.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/tokenizer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXString, false) - -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { - return new CSXString(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _string = NULL; - _capacity = 0; - - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (val->isInt()) { - _capacity = MAX(0, val->getInt()); - if (_capacity > 0) { - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - } else { - setStringVal(val->getString()); - } - - if (_capacity == 0) setStringVal(""); -} - - -////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { - if (_string) delete [] _string; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::setStringVal(const char *val) { - int len = strlen(val); - if (len >= _capacity) { - _capacity = len + 1; - delete[] _string; - _string = NULL; - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - strcpy(_string, val); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXString::scToString() { - if (_string) return _string; - else return "[null string]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *val) { - setStringVal(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Substring - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Substring") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int end = stack->pop()->getInt(); - - if (end < start) CBUtils::swap(&start, &end); - - //try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); - // } catch (std::exception &) { - // stack->pushNULL(); - // } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Substr - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Substr") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - - CScValue *val = stack->pop(); - int len = val->getInt(); - - if (!val->isNULL() && len <= 0) { - stack->pushString(""); - return STATUS_OK; - } - - if (val->isNULL()) len = strlen(_string) - start; - -// try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - -// WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); -// } catch (std::exception &) { -// stack->pushNULL(); -// } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToUpperCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToUpperCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toUppercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToLowerCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToLowerCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toLowercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IndexOf - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IndexOf") == 0) { - stack->correctParams(2); - - const char *strToFind = stack->pop()->getString(); - int index = stack->pop()->getInt(); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) - toFind = StringUtil::utf8ToWide(strToFind); - else - toFind = StringUtil::ansiToWide(strToFind); - - int indexOf = StringUtil::indexOf(str, toFind, index); - stack->pushInt(indexOf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Split - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Split") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) strcpy(separators, val->getString()); - - CSXArray *array = new CSXArray(_gameRef); - if (!array) { - stack->pushNULL(); - return STATUS_OK; - } - - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) - delims = StringUtil::utf8ToWide(separators); - else - delims = StringUtil::ansiToWide(separators); - - Common::Array parts; - - - - Common::StringTokenizer tokenizer(str, delims); - while (!tokenizer.empty()) { - Common::String str2 = tokenizer.nextToken(); - parts.push_back(str2); - } - // TODO: Clean this up - /*do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - - } while (pos != str.size());*/ - - for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { - WideString &part = (*it); - - if (_gameRef->_textEncoding == TEXT_UTF8) - val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - else - val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); - - array->push(val); - delete val; - val = NULL; - } - - stack->pushNative(array, false); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("string"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(_string); - _scValue->setInt(wstr.size()); - } else - _scValue->setInt(strlen(_string)); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { - _scValue->setInt(_capacity); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Capacity") == 0) { - int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); - else if (newCap != _capacity) { - char *newStr = new char[newCap]; - if (newStr) { - memset(newStr, 0, newCap); - strcpy(newStr, _string); - delete[] _string; - _string = newStr; - _capacity = newCap; - } - } - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_capacity)); - - if (persistMgr->_saving) { - if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); - } else { - if (_capacity > 0) { - _string = new char[_capacity]; - persistMgr->getBytes((byte *)_string, _capacity); - } else _string = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *val) { - return strcmp(_string, ((CSXString *)val)->_string); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXString.h b/engines/wintermute/base/scriptables/SXString.h deleted file mode 100644 index 348595ad29..0000000000 --- a/engines/wintermute/base/scriptables/SXString.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTRING_H -#define WINTERMUTE_SXSTRING_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXString : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - void scSetString(const char *val); - const char *scToString(); - void setStringVal(const char *val); - - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScEngine.cpp b/engines/wintermute/base/scriptables/ScEngine.cpp deleted file mode 100644 index db79a7d0e9..0000000000 --- a/engines/wintermute/base/scriptables/ScEngine.cpp +++ /dev/null @@ -1,712 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BFileManager.h" - - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { - _gameRef->LOG(0, "Initializing scripting engine..."); - - if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); - else _gameRef->LOG(0, " Script compiler is NOT available"); - - _globals = new CScValue(_gameRef); - - - // register 'Game' as global variable - if (!_globals->propExists("Game")) { - CScValue val(_gameRef); - val.setNative(_gameRef, true); - _globals->setProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->propExists("Math")) { - CScValue val(_gameRef); - val.setNative(_gameRef->_mathClass, true); - _globals->setProp("Math", &val); - } - - // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; - - _currentScript = NULL; - - _isProfiling = false; - _profilingStartTime = 0; - - //EnableProfiling(); -} - - -////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { - _gameRef->LOG(0, "Shutting down scripting engine"); - saveBreakpoints(); - - disableProfiling(); - - cleanup(); - - for (int i = 0; i < _breakpoints.getSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::cleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - - _scripts.removeAll(); - - delete _globals; - _globals = NULL; - - emptyScriptCache(); - - _currentScript = NULL; // ref only - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *gameRef = (CBGame *)data; - return gameRef->_fileManager->readWholeFile(filename, size); -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::closeFile(void *data, byte *buffer) { - delete [] buffer; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::parseElement(void *data, int line, int type, void *elementData) { -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { - byte *compBuffer; - uint32 compSize; - - // get script from cache - compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) return NULL; - - // add new script - CScScript *script = new CScScript(_gameRef, this); - bool ret = script->create(filename, compBuffer, compSize, owner); - if (DID_FAIL(ret)) { - _gameRef->LOG(ret, "Error running script '%s'...", filename); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - CScValue val(_gameRef); - if (owner)val.setNative(owner, true); - else val.setNULL(); - - script->_globals->setProp("self", &val); - script->_globals->setProp("this", &val); - - _scripts.add(script); - _gameRef->getDebugMgr()->onScriptInit(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { - // is script in cache? - if (!ignoreCache) { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::getTime(); - *outSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *compBuffer; - uint32 compSize; - - uint32 size; - - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (!buffer) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); - return NULL; - } - - // needs to be compiled? - if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { - compBuffer = buffer; - compSize = size; - } else { - if (!_compilerAvailable) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] buffer; - return NULL; - } - // This code will never be called, since _compilerAvailable is const false. - // It's only here in the event someone would want to reinclude the compiler. - error("Script needs compilation, ScummVM does not contain a WME compiler"); - } - - byte *ret = NULL; - - // add script to cache - CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); - if (cachedScript) { - int index = 0; - uint32 MinTime = CBPlatform::getTime(); - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] == NULL) { - index = i; - break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; - index = i; - } - } - - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; - _cachedScripts[index] = cachedScript; - - ret = cachedScript->_buffer; - *outSize = cachedScript->_size; - } - - - // cleanup - delete [] buffer; - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tick() { - if (_scripts.getSize() == 0) - return STATUS_OK; - - - // resolve waiting scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - switch (_scripts[i]->_state) { - case SCRIPT_WAITING: { - /* - bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.getSize(); j++) - { - if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) - { - if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); - obj_found = true; - break; - } - } - if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists - */ - if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); - } else _scripts[i]->finish(); - break; - } - - case SCRIPT_SLEEPING: { - if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); - } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); - } - break; - } - - case SCRIPT_WAITING_SCRIPT: { - if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { - // fake return value - _scripts[i]->_stack->pushNULL(); - _scripts[i]->_waitScript = NULL; - _scripts[i]->run(); - } else { - if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { - // copy return value - _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); - _scripts[i]->run(); - _scripts[i]->_waitScript->finish(); - _scripts[i]->_waitScript = NULL; - } - } - break; - } - default: - //warning("CScEngine::Tick - Unhandled enum"); - break; - } // switch - } // for each script - - - // execute scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; - - // time sliced script - if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); - } - - // normal script - else { - uint32 startTime = 0; - bool isProfiling = _isProfiling; - if (isProfiling) startTime = CBPlatform::getTime(); - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); - } - _currentScript = NULL; - } - - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tickUnbreakable() { - // execute unbreakable scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - _scripts[i]->finish(); - _currentScript = NULL; - } - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeFinishedScripts() { - // remove finished scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { - int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; - switch (_scripts[i]->_state) { - case SCRIPT_RUNNING: - case SCRIPT_SLEEPING: - case SCRIPT_PAUSED: - numRunning++; - break; - case SCRIPT_WAITING: - numWaiting++; - break; - case SCRIPT_PERSISTENT: - numPersistent++; - break; - default: - warning("CScEngine::GetNumScripts - unhandled enum"); - break; - } - numTotal++; - } - if (running) *running = numRunning; - if (waiting) *waiting = numWaiting; - if (persistent) *persistent = numPersistent; - - return numTotal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::emptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetObject(CBObject *Object) { - // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); - - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetScript(CScScript *script) { - // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { - _scripts[i]->finish(); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_globals)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::editorCleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::pauseAll() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->pause(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->resume(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::isValidScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::clearGlobals(bool includingNatives) { - _globals->CleanProps(includingNatives); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { - // send global variables - _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->dbgSendScript(client); - } - - // and threads later - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->dbgSendScript(client); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - bp = _breakpoints[i]; - break; - } - } - if (bp == NULL) { - bp = new CScBreakpoint(scriptFilename); - _breakpoints.add(bp); - } - - for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) return STATUS_OK; - } - bp->_lines.add(line); - - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.removeAt(j); - if (_breakpoints[i]->_lines.getSize() == 0) { - delete _breakpoints[i]; - _breakpoints.removeAt(i); - } - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; - } - } - break; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _scripts.getSize(); i++) { - refreshScriptBreakpoints(_scripts[i]); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints(CScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - if (!script || !script->_filename) return STATUS_FAILED; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.copy(_breakpoints[i]->_lines); - return STATUS_OK; - } - } - if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - - char text[512]; - char key[100]; - - int count = 0; - for (int i = 0; i < _breakpoints.getSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - count++; - sprintf(key, "Breakpoint%d", count); - sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - _gameRef->_registry->writeString("Debug", key, text); - } - } - _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - char key[100]; - - int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= count; i++) { - /* uint32 BufSize = 512; */ - sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); - - char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); - - if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); - delete[] path; - delete[] line; - path = NULL; - line = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) return; - - AnsiString fileName = filename; - fileName.toLowercase(); - _scriptTimes[fileName] += time; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::enableProfiling() { - if (_isProfiling) return; - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = CBPlatform::getTime(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::disableProfiling() { - if (!_isProfiling) return; - - dumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::dumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; - - typedef std::vector > TimeVector; - TimeVector times; - - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); - - - TimeVector::reverse_iterator tit; - - _gameRef->LOG(0, "***** Script profiling information: *****"); - _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - - for (tit = times.rbegin(); tit != times.rend(); tit++) { - _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h deleted file mode 100644 index 0322319b3d..0000000000 --- a/engines/wintermute/base/scriptables/ScEngine.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCENGINE_H -#define WINTERMUTE_SCENGINE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -#define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { -public: - class CScCachedScript { - public: - CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::getTime(); - _buffer = new byte[size]; - if (_buffer) memcpy(_buffer, buffer, size); - _size = size; - _filename = filename; - }; - - ~CScCachedScript() { - if (_buffer) delete [] _buffer; - }; - - uint32 _timestamp; - byte *_buffer; - uint32 _size; - Common::String _filename; - }; - - class CScBreakpoint { - public: - CScBreakpoint(const char *filename) { - _filename = filename; - } - - ~CScBreakpoint() { - _lines.removeAll(); - } - - Common::String _filename; - CBArray _lines; - }; - - - - -public: - bool dbgSendScripts(IWmeDebugClient *client); - - CBArray _breakpoints; - bool addBreakpoint(const char *scriptFilename, int line); - bool removeBreakpoint(const char *scriptFilename, int line); - bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(CScScript *script); - bool saveBreakpoints(); - bool loadBreakpoints(); - - bool clearGlobals(bool includingNatives = false); - bool tickUnbreakable(); - bool removeFinishedScripts(); - bool isValidScript(CScScript *script); - - CScScript *_currentScript; - bool resumeAll(); - bool pauseAll(); - void editorCleanup(); - bool resetObject(CBObject *Object); - bool resetScript(CScScript *script); - bool emptyScriptCache(); - byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) - bool cleanup(); - int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - bool tick(); - CScValue *_globals; - CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); - static const bool _compilerAvailable = false; - - CScEngine(CBGame *inGame); - virtual ~CScEngine(); - static byte *loadFile(void *data, char *filename, uint32 *size); - static void closeFile(void *data, byte *buffer); - static void parseElement(void *data, int line, int type, void *elementData); - - CBArray _scripts; - - void enableProfiling(); - void disableProfiling(); - bool getIsProfiling() { - return _isProfiling; - } - - void addScriptTime(const char *filename, uint32 Time); - void dumpStats(); - -private: - - CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; - bool _isProfiling; - uint32 _profilingStartTime; - - typedef Common::HashMap ScriptTimes; - ScriptTimes _scriptTimes; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScScript.cpp b/engines/wintermute/base/scriptables/ScScript.cpp deleted file mode 100644 index 0b5b3c24bf..0000000000 --- a/engines/wintermute/base/scriptables/ScScript.cpp +++ /dev/null @@ -1,1461 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/memstream.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScScript, false) - -////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { - _buffer = NULL; - _bufferSize = _iP = 0; - _scriptStream = NULL; - _filename = NULL; - _currentLine = 0; - - _symbols = NULL; - _numSymbols = 0; - - _engine = Engine; - - _globals = NULL; - - _scopeStack = NULL; - _callStack = NULL; - _thisStack = NULL; - _stack = NULL; - - _operand = NULL; - _reg1 = NULL; - - _functions = NULL; - _numFunctions = 0; - - _methods = NULL; - _numMethods = 0; - - _events = NULL; - _numEvents = 0; - - _externals = NULL; - _numExternals = 0; - - _state = SCRIPT_FINISHED; - _origState = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _timeSlice = 0; - - _thread = false; - _methodThread = false; - _threadEvent = NULL; - - _freezable = true; - _owner = NULL; - - _unbreakable = false; - _parentScript = NULL; - - _tracingMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { - cleanup(); -} - -void CScScript::readHeader() { - uint32 oldPos = _scriptStream->pos(); - _scriptStream->seek(0); - _header.magic = _scriptStream->readUint32LE(); - _header.version = _scriptStream->readUint32LE(); - _header.code_start = _scriptStream->readUint32LE(); - _header.func_table = _scriptStream->readUint32LE(); - _header.symbol_table = _scriptStream->readUint32LE(); - _header.event_table = _scriptStream->readUint32LE(); - _header.externals_table = _scriptStream->readUint32LE(); - _header.method_table = _scriptStream->readUint32LE(); - _scriptStream->seek(oldPos); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initScript() { - if (!_scriptStream) { - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - } - readHeader(); - - if (_header.magic != SCRIPT_MAGIC) { - _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); - cleanup(); - return STATUS_FAILED; - } - - if (_header.version > SCRIPT_VERSION) { - _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - cleanup(); - return STATUS_FAILED; - } - - initTables(); - - // init stacks - _scopeStack = new CScStack(_gameRef); - _callStack = new CScStack(_gameRef); - _thisStack = new CScStack(_gameRef); - _stack = new CScStack(_gameRef); - - _operand = new CScValue(_gameRef); - _reg1 = new CScValue(_gameRef); - - - // skip to the beginning - _iP = _header.code_start; - _scriptStream->seek(_iP); - _currentLine = 0; - - // init breakpoints - _engine->refreshScriptBreakpoints(this); - - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initTables() { - uint32 OrigIP = _iP; - - readHeader(); - // load symbol table - _iP = _header.symbol_table; - - _numSymbols = getDWORD(); - _symbols = new char*[_numSymbols]; - for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = getDWORD(); - _symbols[index] = getString(); - } - - // load functions table - _iP = _header.func_table; - - _numFunctions = getDWORD(); - _functions = new TFunctionPos[_numFunctions]; - for (uint32 i = 0; i < _numFunctions; i++) { - _functions[i].pos = getDWORD(); - _functions[i].name = getString(); - } - - - // load events table - _iP = _header.event_table; - - _numEvents = getDWORD(); - _events = new TEventPos[_numEvents]; - for (uint32 i = 0; i < _numEvents; i++) { - _events[i].pos = getDWORD(); - _events[i].name = getString(); - } - - - // load externals - if (_header.version >= 0x0101) { - _iP = _header.externals_table; - - _numExternals = getDWORD(); - _externals = new TExternalFunction[_numExternals]; - for (uint32 i = 0; i < _numExternals; i++) { - _externals[i].dll_name = getString(); - _externals[i].name = getString(); - _externals[i].call_type = (TCallType)getDWORD(); - _externals[i].returns = (TExternalType)getDWORD(); - _externals[i].nu_params = getDWORD(); - if (_externals[i].nu_params > 0) { - _externals[i].params = new TExternalType[_externals[i].nu_params]; - for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)getDWORD(); - } - } - } - } - - // load method table - _iP = _header.method_table; - - _numMethods = getDWORD(); - _methods = new TMethodPos[_numMethods]; - for (uint32 i = 0; i < _numMethods; i++) { - _methods[i].pos = getDWORD(); - _methods[i].name = getString(); - } - - - _iP = OrigIP; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { - cleanup(); - - _thread = false; - _methodThread = false; - - delete[] _threadEvent; - _threadEvent = NULL; - - _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); - - _buffer = new byte [size]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, buffer, size); - - _bufferSize = size; - - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // establish global variables table - _globals = new CScValue(_gameRef); - - _owner = owner; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { - cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[strlen(eventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, eventName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = initIP; - _scriptStream->seek(_iP); - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createMethodThread(CScScript *original, const char *methodName) { - uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return STATUS_FAILED; - - cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[strlen(methodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, methodName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = ip; - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::cleanup() { - if (_buffer) delete [] _buffer; - _buffer = NULL; - - if (_filename) delete [] _filename; - _filename = NULL; - - if (_symbols) delete [] _symbols; - _symbols = NULL; - _numSymbols = 0; - - if (_globals && !_thread) delete _globals; - _globals = NULL; - - delete _scopeStack; - _scopeStack = NULL; - - delete _callStack; - _callStack = NULL; - - delete _thisStack; - _thisStack = NULL; - - delete _stack; - _stack = NULL; - - if (_functions) delete [] _functions; - _functions = NULL; - _numFunctions = 0; - - if (_methods) delete [] _methods; - _methods = NULL; - _numMethods = 0; - - if (_events) delete [] _events; - _events = NULL; - _numEvents = 0; - - - if (_externals) { - for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; - } - delete [] _externals; - } - _externals = NULL; - _numExternals = 0; - - delete _operand; - delete _reg1; - _operand = NULL; - _reg1 = NULL; - - delete[] _threadEvent; - _threadEvent = NULL; - - _state = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _parentScript = NULL; // ref only - - delete _scriptStream; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getDWORD() { - _scriptStream->seek((int32)_iP); - uint32 ret = _scriptStream->readUint32LE(); - _iP += sizeof(uint32); -// assert(oldRet == ret); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -double CScScript::getFloat() { - _scriptStream->seek((int32)_iP); - byte buffer[8]; - _scriptStream->read(buffer, 8); - -#ifdef SCUMM_BIG_ENDIAN - // TODO: For lack of a READ_LE_UINT64 - SWAP(buffer[0], buffer[7]); - SWAP(buffer[1], buffer[6]); - SWAP(buffer[2], buffer[5]); - SWAP(buffer[3], buffer[4]); -#endif - - double ret = *(double *)(buffer); - _iP += 8; // Hardcode the double-size used originally. - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -char *CScScript::getString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; - _iP++; // string terminator - _scriptStream->seek(_iP); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::executeInstruction() { - bool ret = STATUS_OK; - - uint32 dw; - const char *str = NULL; - - //CScValue* op = new CScValue(_gameRef); - _operand->cleanup(); - - CScValue *op1; - CScValue *op2; - - uint32 inst = getDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->setNULL(); - dw = getDWORD(); - if (_scopeStack->_sP < 0) { - _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); - } else { - _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); - } - - break; - - case II_DEF_GLOB_VAR: - case II_DEF_CONST_VAR: { - dw = getDWORD(); - /* char *Temp = _symbols[dw]; // TODO delete */ - // only create global var if it doesn't exist - if (!_engine->_globals->propExists(_symbols[dw])) { - _operand->setNULL(); - _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); - - _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->getInt(); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } else { - if (_thread) { - _state = SCRIPT_THREAD_FINISHED; - } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; - } - } - - break; - - case II_RET_EVENT: - _state = SCRIPT_FINISHED; - break; - - - case II_CALL: - dw = getDWORD(); - - _operand->setInt(_iP); - _callStack->push(_operand); - - _iP = dw; - - break; - - case II_CALL_BY_EXP: { - // push var - // push string - str = _stack->pop()->getString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); - - CScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - - bool res = STATUS_FAILED; - bool TriedNative = false; - - // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - TriedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - } - - if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { - if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(MethodName); - if (!_waitScript) { - _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", MethodName); - _stack->pushNULL(); - } else { - _state = SCRIPT_WAITING_SCRIPT; - _waitScript->copyParameters(_stack); - } - } else { - // can call methods in unbreakable mode - _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - delete [] MethodName; - break; - } - /* - CScValue* val = var->getProp(MethodName); - if(val){ - dw = GetFuncPos(val->getString()); - if(dw==0){ - TExternalFunction* f = GetExternal(val->getString()); - if(f){ - ExternalCall(_stack, _thisStack, f); - } - else{ - // not an internal nor external, try for native function - _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); - } - } - else{ - _operand->setInt(_iP); - _callStack->Push(_operand); - _iP = dw; - } - } - */ - else { - res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - - if (DID_FAIL(res)) { - _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - } - } - delete [] MethodName; - } - break; - - case II_EXTERNAL_CALL: { - uint32 SymbolIndex = getDWORD(); - - TExternalFunction *f = getExternal(_symbols[SymbolIndex]); - if (f) { - externalCall(_stack, _thisStack, f); - } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); - - break; - } - case II_SCOPE: - _operand->setNULL(); - _scopeStack->push(_operand); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - - break; - - case II_CORRECT_STACK: - dw = getDWORD(); // params expected - _stack->correctParams(dw); - break; - - case II_CREATE_OBJECT: - _operand->setObject(); - _stack->push(_operand); - break; - - case II_POP_EMPTY: - _stack->pop(); - break; - - case II_PUSH_VAR: { - CScValue *var = getVar(_symbols[getDWORD()]); - if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->setReference(var); - _stack->push(_operand); - } else _stack->push(var); - break; - } - - case II_PUSH_VAR_REF: { - CScValue *var = getVar(_symbols[getDWORD()]); - _operand->setReference(var); - _stack->push(_operand); - break; - } - - case II_POP_VAR: { - char *VarName = _symbols[getDWORD()]; - CScValue *var = getVar(VarName); - if (var) { - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else { - if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->setValue(val); - else { - var->copy(val); - } - } - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, val); - } - - break; - } - - case II_PUSH_VAR_THIS: - _stack->push(_thisStack->getTop()); - break; - - case II_PUSH_INT: - _stack->pushInt((int)getDWORD()); - break; - - case II_PUSH_FLOAT: - _stack->pushFloat(getFloat()); - break; - - - case II_PUSH_BOOL: - _stack->pushBool(getDWORD() != 0); - - break; - - case II_PUSH_STRING: - _stack->pushString(getString()); - break; - - case II_PUSH_NULL: - _stack->pushNULL(); - break; - - case II_PUSH_THIS_FROM_STACK: - _operand->setReference(_stack->getTop()); - _thisStack->push(_operand); - break; - - case II_PUSH_THIS: - _operand->setReference(getVar(_symbols[getDWORD()])); - _thisStack->push(_operand); - break; - - case II_POP_THIS: - _thisStack->pop(); - break; - - case II_PUSH_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *val = _stack->pop()->getProp(str); - if (val) _stack->push(val); - else _stack->pushNULL(); - - break; - } - - case II_POP_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *var = _stack->pop(); - CScValue *val = _stack->pop(); - - if (val == NULL) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else var->setProp(str, val); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); - - break; - } - - case II_PUSH_REG1: - _stack->push(_reg1); - break; - - case II_POP_REG1: - _reg1->copy(_stack->pop()); - break; - - case II_JMP: - _iP = getDWORD(); - break; - - case II_JMP_FALSE: { - dw = getDWORD(); - //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - } else { - if (!val->getBool()) _iP = dw; - } - break; - } - - case II_ADD: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; - strcpy(tempStr, op1->getString()); - strcat(tempStr, op2->getString()); - _operand->setString(tempStr); - delete [] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() + op2->getInt()); - else _operand->setFloat(op1->getFloat() + op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_SUB: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() - op2->getInt()); - else _operand->setFloat(op1->getFloat() - op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MUL: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() * op2->getInt()); - else _operand->setFloat(op1->getFloat() * op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_DIV: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getFloat() == 0.0f) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); - else _operand->setFloat(op1->getFloat() / op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MODULO: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getInt() == 0) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) - _operand->setNULL(); - else _operand->setInt(op1->getInt() % op2->getInt()); - - _stack->push(_operand); - - break; - - case II_NOT: - op1 = _stack->pop(); - //if(op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) _operand->setBool(true); - else _operand->setBool(!op1->getBool()); - _stack->push(_operand); - - break; - - case II_AND: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() && op2->getBool()); - } - _stack->push(_operand); - break; - - case II_OR: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() || op2->getBool()); - } - _stack->push(_operand); - break; - - case II_CMP_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() == op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() == op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() == op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) == 0); - _stack->push(_operand); - break; - - case II_CMP_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() != op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() != op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() != op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_CMP_L: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() < op2->getFloat()); - } - else _operand->setBool(op1->getInt() < op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) < 0); - _stack->push(_operand); - break; - - case II_CMP_G: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() > op2->getFloat()); - } - else _operand->setBool(op1->getInt() > op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) > 0); - _stack->push(_operand); - break; - - case II_CMP_LE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() <= op2->getFloat()); - } - else _operand->setBool(op1->getInt() <= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) <= 0); - _stack->push(_operand); - break; - - case II_CMP_GE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() >= op2->getFloat()); - } - else _operand->setBool(op1->getInt() >= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) >= 0); - _stack->push(_operand); - break; - - case II_CMP_STRICT_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) == 0); - _stack->push(_operand); - - break; - - case II_CMP_STRICT_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_DBG_LINE: { - int newLine = getDWORD(); - if (newLine != _currentLine) { - _currentLine = newLine; - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (_breakpoints[i] == _currentLine) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - if (_tracingMode) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - } - break; - - } - default: - _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); - _state = SCRIPT_FINISHED; - ret = STATUS_FAILED; - } // switch(instruction) - - //delete op; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getFuncPos(const char *name) { - for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) - return _functions[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getMethodPos(const char *name) { - for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) - return _methods[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::getVar(char *name) { - CScValue *ret = NULL; - - // scope locals - if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) - ret = _scopeStack->getTop()->getProp(name); - } - - // script globals - if (ret == NULL) { - if (_globals->propExists(name)) - ret = _globals->getProp(name); - } - - // engine globals - if (ret == NULL) { - if (_engine->_globals->propExists(name)) - ret = _engine->_globals->getProp(name); - } - - if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); - _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(_gameRef); - CScValue *scope = _scopeStack->getTop(); - if (scope) { - scope->setProp(name, val); - ret = _scopeStack->getTop()->getProp(name); - } else { - _globals->setProp(name, val); - ret = _globals->getProp(name); - } - delete val; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitFor(CBObject *object) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = object; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitForExclusive(CBObject *object) { - _engine->resetObject(object); - return waitFor(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::sleep(uint32 duration) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_SLEEPING; - if (_gameRef->_state == GAME_FROZEN) { - _waitTime = CBPlatform::getTime() + duration; - _waitFrozen = true; - } else { - _waitTime = _gameRef->_timer + duration; - _waitFrozen = false; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finish(bool includingThreads) { - if (_state != SCRIPT_FINISHED && includingThreads) { - _state = SCRIPT_FINISHED; - finishThreads(); - } else _state = SCRIPT_FINISHED; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::run() { - _state = SCRIPT_RUNNING; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(const char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - _gameRef->LOG(0, " %s", buff); - - if (!_gameRef->_suppressScriptErrors) - _gameRef->quickMessage("Script runtime error. View log for details."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - // buffer - if (persistMgr->_saving) { - if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - persistMgr->transfer(TMEMBER(_bufferSize)); - persistMgr->putBytes(_buffer, _bufferSize); - } else { - // don't save idle/finished scripts - int bufferSize = 0; - persistMgr->transfer(TMEMBER(bufferSize)); - } - } else { - persistMgr->transfer(TMEMBER(_bufferSize)); - if (_bufferSize > 0) { - _buffer = new byte[_bufferSize]; - persistMgr->getBytes(_buffer, _bufferSize); - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - initTables(); - } else { - _buffer = NULL; - _scriptStream = NULL; - } - } - - persistMgr->transfer(TMEMBER(_callStack)); - persistMgr->transfer(TMEMBER(_currentLine)); - persistMgr->transfer(TMEMBER(_engine)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_globals)); - persistMgr->transfer(TMEMBER(_iP)); - persistMgr->transfer(TMEMBER(_scopeStack)); - persistMgr->transfer(TMEMBER(_stack)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_operand)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_reg1)); - persistMgr->transfer(TMEMBER(_thread)); - persistMgr->transfer(TMEMBER(_threadEvent)); - persistMgr->transfer(TMEMBER(_thisStack)); - persistMgr->transfer(TMEMBER(_timeSlice)); - persistMgr->transfer(TMEMBER(_waitObject)); - persistMgr->transfer(TMEMBER(_waitScript)); - persistMgr->transfer(TMEMBER(_waitTime)); - persistMgr->transfer(TMEMBER(_waitFrozen)); - - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_unbreakable)); - persistMgr->transfer(TMEMBER(_parentScript)); - - if (!persistMgr->_saving) _tracingMode = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = getEventPos(eventName); - if (!pos) return NULL; - - CScScript *thread = new CScScript(_gameRef, _engine); - if (thread) { - bool ret = thread->createThread(this, pos, eventName); - if (DID_SUCCEED(ret)) { - thread->_unbreakable = unbreakable; - _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); - return thread; - } else { - delete thread; - return NULL; - } - } else return NULL; - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getEventPos(const char *name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *eventName) { - return getEventPos(eventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *methodName) { - return getMethodPos(methodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::pause() { - if (_state == SCRIPT_PAUSED) { - _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return STATUS_FAILED; - } - - if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; - - _origState = _state; - _state = SCRIPT_PAUSED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::resume() { - if (_state != SCRIPT_PAUSED) return STATUS_OK; - - _state = _origState; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::getExternal(char *name) { - for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) - return &_externals[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { - - _gameRef->LOG(0, "External functions are not supported on this platform."); - stack->correctParams(0); - stack->pushNULL(); - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::copyParameters(CScStack *stack) { - int i; - int NumParams = stack->pop()->getInt(); - for (i = NumParams - 1; i >= 0; i--) { - _stack->push(stack->getAt(i)); - } - _stack->pushInt(NumParams); - - for (i = 0; i < NumParams; i++) stack->pop(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.getSize(); i++) { - CScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) - scr->finish(true); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int CScScript::dbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *CScScript::dbgGetFilename() { - return _filename; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else client->onScriptInit(this); - - return dbgSendVariables(client); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendVariables(IWmeDebugClient *client) { - // send script globals - _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::dbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetNumBreakpoints() { - return _breakpoints.getSize(); -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; - else return -1; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool isTracing) { - _tracingMode = isTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgGetTracingMode() { - return _tracingMode; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::afterLoad() { - if (_buffer == NULL) { - byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); - if (!buffer) { - _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); - _state = SCRIPT_ERROR; - return; - } - - _buffer = new byte [_bufferSize]; - memcpy(_buffer, buffer, _bufferSize); - - delete _scriptStream; - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - - initTables(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScScript.h b/engines/wintermute/base/scriptables/ScScript.h deleted file mode 100644 index c031f8186f..0000000000 --- a/engines/wintermute/base/scriptables/ScScript.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -#include "engines/wintermute/wme_debugger.h" - -namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { -public: - bool dbgSendScript(IWmeDebugClient *client); - bool dbgSendVariables(IWmeDebugClient *client); - - CBArray _breakpoints; - bool _tracingMode; - - CScScript *_parentScript; - bool _unbreakable; - bool finishThreads(); - bool copyParameters(CScStack *stack); - - void afterLoad(); - - CScValue *_operand; - CScValue *_reg1; - bool _freezable; - bool resume(); - bool pause(); - bool canHandleEvent(const char *eventName); - bool canHandleMethod(const char *methodName); - bool createThread(CScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(CScScript *original, const char *methodName); - CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); - uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) - void runtimeError(const char *fmt, ...); - bool run(); - bool finish(bool includingThreads = false); - bool sleep(uint32 duration); - bool waitForExclusive(CBObject *object); - bool waitFor(CBObject *object); - uint32 _waitTime; - bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - CScValue *getVar(char *name); - uint32 getFuncPos(const char *name); - uint32 getEventPos(const char *name); - uint32 getMethodPos(const char *name); - typedef struct { - uint32 magic; - uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; - } TScriptHeader; - - TScriptHeader _header; - - typedef struct { - char *name; - uint32 pos; - } TFunctionPos; - - typedef struct { - char *name; - uint32 pos; - } TMethodPos; - - typedef struct { - char *name; - uint32 pos; - } TEventPos; - - typedef struct { - char *name; - char *dll_name; - TCallType call_type; - TExternalType returns; - int nu_params; - TExternalType *params; - } TExternalFunction; - - - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; - int _currentLine; - bool executeInstruction(); - char *getString(); - uint32 getDWORD(); - double getFloat(); - void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); - uint32 _iP; -private: - void readHeader(); - uint32 _bufferSize; - byte *_buffer; -public: - Common::SeekableReadStream *_scriptStream; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); - char *_filename; - char **_symbols; - uint32 _numSymbols; - TFunctionPos *_functions; - TMethodPos *_methods; - TEventPos *_events; - uint32 _numExternals; - TExternalFunction *_externals; - uint32 _numFunctions; - uint32 _numMethods; - uint32 _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *getExternal(char *name); - bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); -private: - bool initScript(); - bool initTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int dbgGetLine(); - virtual const char *dbgGetFilename(); - virtual TScriptState dbgGetState(); - virtual int dbgGetNumBreakpoints(); - virtual int dbgGetBreakpoint(int Index); - - virtual bool dbgSetTracingMode(bool IsTracing); - virtual bool dbgGetTracingMode(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScStack.cpp b/engines/wintermute/base/scriptables/ScStack.cpp deleted file mode 100644 index 252cd21dda..0000000000 --- a/engines/wintermute/base/scriptables/ScStack.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScStack, false) - -////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { - -#if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); -#endif - - for (int i = 0; i < _values.getSize(); i++) { - delete _values[i]; - } - _values.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::pop() { - if (_sP < 0) { - _gameRef->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::push(CScValue *val) { - _sP++; - - if (_sP < _values.getSize()) { - _values[_sP]->cleanup(); - _values[_sP]->copy(val); - } else { - CScValue *copyVal = new CScValue(_gameRef); - copyVal->copy(val); - _values.add(copyVal); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getPushValue() { - _sP++; - - if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(_gameRef); - _values.add(val); - } - _values[_sP]->cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) return NULL; - else return _values[_sP]; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getAt(int index) { - index = _sP - index; - if (index < 0 || index >= _values.getSize()) return NULL; - else return _values[index]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expectedParams) { - uint32 nuParams = (uint32)pop()->getInt(); - - if (expectedParams < nuParams) { // too many params - while (expectedParams < nuParams) { - //Pop(); - delete _values[_sP - expectedParams]; - _values.removeAt(_sP - expectedParams); - nuParams--; - _sP--; - } - } else if (expectedParams > nuParams) { // need more params - while (expectedParams > nuParams) { - //Push(null_val); - CScValue *nullVal = new CScValue(_gameRef); - nullVal->setNULL(); - _values.insertAt(_sP - nuParams + 1, nullVal); - nuParams++; - _sP++; - - if (_values.getSize() > _sP + 1) { - delete _values[_values.getSize() - 1]; - _values.removeAt(_values.getSize() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNULL() { - /* - CScValue* val = new CScValue(_gameRef); - val->setNULL(); - Push(val); - delete val; - */ - getPushValue()->setNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushInt(int val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setInt(Val); - Push(val); - delete val; - */ - getPushValue()->setInt(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushFloat(double val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setFloat(Val); - Push(val); - delete val; - */ - getPushValue()->setFloat(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushBool(bool val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setBool(Val); - Push(val); - delete val; - */ - getPushValue()->setBool(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushString(const char *val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setString(Val); - Push(val); - delete val; - */ - getPushValue()->setString(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNative(CBScriptable *val, bool persistent) { - /* - CScValue* val = new CScValue(_gameRef); - val->setNative(Val, Persistent); - Push(val); - delete val; - */ - - getPushValue()->setNative(val, persistent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScStack::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_sP)); - _values.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScStack.h b/engines/wintermute/base/scriptables/ScStack.h deleted file mode 100644 index 22dae63060..0000000000 --- a/engines/wintermute/base/scriptables/ScStack.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSTACK_H -#define WINTERMUTE_SCSTACK_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CBScriptable; - -class CScStack : public CBBase { -public: - CScValue *getAt(int Index); - CScValue *getPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *val, bool persistent); - void pushString(const char *val); - void pushBool(bool val); - void pushInt(int val); - void pushFloat(double val); - void pushNULL(); - void correctParams(uint32 expectedParams); - CScValue *getTop(); - void push(CScValue *val); - CScValue *pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; - int _sP; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp deleted file mode 100644 index f38a12fc7a..0000000000 --- a/engines/wintermute/base/scriptables/ScValue.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CScValue, false) - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { - _type = VAL_BOOL; - _valBool = val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { - _type = VAL_INT; - _valInt = val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { - _type = VAL_FLOAT; - _valFloat = val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { - _type = VAL_STRING; - _valString = NULL; - setStringVal(val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool ignoreNatives) { - deleteProps(); - - if (_valString) delete [] _valString; - - if (!ignoreNatives) { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - _valNative = NULL; - } - } - } - - - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); - - if (_type == VAL_STRING && strcmp(name, "Length") == 0) { - _gameRef->_scValue->_type = VAL_INT; - -#if 0 // TODO: Remove FreeType-dependency - if (_gameRef->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif - _gameRef->_scValue->setInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::utf8ToWide(_valString); - _gameRef->_scValue->setInt(wstr.size()); - } - - return _gameRef->_scValue; - } - - CScValue *ret = NULL; - - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); - - if (ret == NULL) { - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) ret = _valIter->_value; - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - delete _valIter->_value; - _valIter->_value = NULL; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) - return _valRef->setProp(name, val); - - bool ret = STATUS_FAILED; - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(name, val); - } - - if (DID_FAIL(ret)) { - CScValue *newVal = NULL; - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - newVal = _valIter->_value; - } - if (!newVal) - newVal = new CScValue(_gameRef); - else newVal->cleanup(); - - newVal->copy(val, copyWhole); - newVal->_isConstVar = setAsConst; - _valObject[name] = newVal; - - if (_type != VAL_NATIVE) _type = VAL_OBJECT; - - /* - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()){ - delete _valIter->_value; - _valIter->_value = NULL; - } - CScValue* val = new CScValue(_gameRef); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) - return _valRef->propExists(name); - _valIter = _valObject.find(name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::deleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool includingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNULL(); - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNative(); - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isString(); - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isFloat(); - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isInt() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isInt(); - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isBool() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isBool(); - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isObject() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isObject(); - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getType(); - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setBool(bool val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setBool(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetBool(val); - return; - } - - _valBool = val; - _type = VAL_BOOL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setInt(int val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setInt(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetInt(val); - return; - } - - _valInt = val; - _type = VAL_INT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setFloat(double val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setFloat(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetFloat(val); - return; - } - - _valFloat = val; - _type = VAL_FLOAT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setString(const char *val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setString(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetString(val); - return; - } - - setStringVal(val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; -} - -void CScValue::setString(const Common::String &val) { - setString(val.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -void CScValue::setStringVal(const char *val) { - if (_valString) { - delete [] _valString; - _valString = NULL; - } - - if (val == NULL) { - _valString = NULL; - return; - } - - _valString = new char [strlen(val) + 1]; - if (_valString) { - strcpy(_valString, val); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNULL() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNULL(); - return; - } - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; - } - _valNative = NULL; - deleteProps(); - - _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *val, bool persistent) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNative(val, persistent); - return; - } - - if (val == NULL) { - setNULL(); - } else { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != val) delete _valNative; - _valNative = NULL; - } - } - - _type = VAL_NATIVE; - _persistent = persistent; - - _valNative = val; - if (_valNative && !_persistent) _valNative->_refCount++; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setObject(); - return; - } - - deleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *val) { - _valRef = val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getBool(); - - switch (_type) { - case VAL_BOOL: - return _valBool; - - case VAL_NATIVE: - return _valNative->scToBool(); - - case VAL_INT: - return (_valInt != 0); - - case VAL_FLOAT: - return (_valFloat != 0.0f); - - case VAL_STRING: - return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1 : 0; - - case VAL_NATIVE: - return _valNative->scToInt(); - - case VAL_INT: - return _valInt; - - case VAL_FLOAT: - return (int)_valFloat; - - case VAL_STRING: - return atoi(_valString); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getFloat(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1.0f : 0.0f; - - case VAL_NATIVE: - return _valNative->scToFloat(); - - case VAL_INT: - return (double)_valInt; - - case VAL_FLOAT: - return _valFloat; - - case VAL_STRING: - return atof(_valString); - - default: - return defaultVal; - } -} - -////////////////////////////////////////////////////////////////////////// -void *CScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getMemBuffer(); - - if (_type == VAL_NATIVE) - return _valNative->scToMemBuffer(); - else return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::getString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getString(); - - switch (_type) { - case VAL_OBJECT: - setStringVal("[object]"); - break; - - case VAL_NULL: - setStringVal("[null]"); - break; - - case VAL_NATIVE: { - const char *strVal = _valNative->scToString(); - setStringVal(strVal); - return strVal; - break; - } - - case VAL_BOOL: - setStringVal(_valBool ? "yes" : "no"); - break; - - case VAL_INT: { - char dummy[50]; - sprintf(dummy, "%d", _valInt); - setStringVal(dummy); - break; - } - - case VAL_FLOAT: { - char dummy[50]; - sprintf(dummy, "%f", _valFloat); - setStringVal(dummy); - break; - } - - case VAL_STRING: - break; - - default: - setStringVal(""); - } - - return _valString; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::getNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getNative(); - - if (_type == VAL_NATIVE) return _valNative; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::copy(CScValue *orig, bool copyWhole) { - _gameRef = orig->_gameRef; - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; - _valNative = NULL; - } - } - - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; - - cleanup(true); - - _type = orig->_type; - _valBool = orig->_valBool; - _valInt = orig->_valInt; - _valFloat = orig->_valFloat; - setStringVal(orig->_valString); - - _valRef = orig->_valRef; - _persistent = orig->_persistent; - - _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; -//!!!! ref->native++ - - // copy properties - if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { - orig->_valIter = orig->_valObject.begin(); - while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(_gameRef); - _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); - orig->_valIter++; - } - } else _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setValue(CScValue *val) { - if (val->_type == VAL_VARIABLE_REF) { - setValue(val->_valRef); - return; - } - - // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { - switch (val->_type) { - case VAL_INT: - _valNative->scSetInt(val->getInt()); - break; - case VAL_FLOAT: - _valNative->scSetFloat(val->getFloat()); - break; - case VAL_BOOL: - _valNative->scSetBool(val->getBool()); - break; - case VAL_STRING: - _valNative->scSetString(val->getString()); - break; - default: - warning("CScValue::setValue - unhandled enum"); - break; - } - } - // otherwise just copy everything - else copy(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_persistent)); - persistMgr->transfer(TMEMBER(_isConstVar)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_valBool)); - persistMgr->transfer(TMEMBER(_valFloat)); - persistMgr->transfer(TMEMBER(_valInt)); - persistMgr->transfer(TMEMBER(_valNative)); - - int size; - const char *str; - if (persistMgr->_saving) { - size = _valObject.size(); - persistMgr->transfer("", &size); - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - str = _valIter->_key.c_str(); - persistMgr->transfer("", &str); - persistMgr->transfer("", &_valIter->_value); - - _valIter++; - } - } else { - CScValue *val; - persistMgr->transfer("", &size); - for (int i = 0; i < size; i++) { - persistMgr->transfer("", &str); - persistMgr->transfer("", &val); - - _valObject[str] = val; - delete [] str; - } - } - - persistMgr->transfer(TMEMBER(_valRef)); - persistMgr->transfer(TMEMBER(_valString)); - - /* - FILE* f = fopen("c:\\val.log", "a+"); - switch(_type) - { - case VAL_STRING: - fprintf(f, "str %s\n", _valString); - break; - - case VAL_INT: - fprintf(f, "int %d\n", _valInt); - break; - - case VAL_BOOL: - fprintf(f, "bool %d\n", _valBool); - break; - - case VAL_NULL: - fprintf(f, "null\n"); - break; - - case VAL_NATIVE: - fprintf(f, "native\n"); - break; - - case VAL_VARIABLE_REF: - fprintf(f, "ref\n"); - break; - - case VAL_OBJECT: - fprintf(f, "obj\n"); - break; - - case VAL_FLOAT: - fprintf(f, "float\n"); - break; - - } - fclose(f); - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - buffer->putTextIndent(indent, "PROPERTY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); - buffer->putTextIndent(indent, "}\n\n"); - - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::compare(CScValue *val1, CScValue *val2) { - // both natives? - if (val1->isNative() && val2->isNative()) { - // same class? - if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { - return val1->getNative()->scCompare(val2->getNative()); - } else return strcmp(val1->getString(), val2->getString()); - } - - // both objects? - if (val1->isObject() && val2->isObject()) return -1; - - - // null states - if (val1->isNULL() && !val2->isNULL()) return -1; - else if (!val1->isNULL() && val2->isNULL()) return 1; - else if (val1->isNULL() && val2->isNULL()) return 0; - - // one of them is string? convert both to string - if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); - - // one of them is float? - if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) return -1; - else if (val1->getFloat() > val2->getFloat()) return 1; - else return 0; - } - - // otherwise compare as int's - if (val1->getInt() < val2->getInt()) return -1; - else if (val1->getInt() > val2->getInt()) return 1; - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::compareStrict(CScValue *val1, CScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return CScValue::compare(val1, val2); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(_gameRef); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::dbgGetType() { - switch (getType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetValInt() { - return getInt(); -} - -////////////////////////////////////////////////////////////////////////// -double CScValue::dbgGetValFloat() { - return getFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetValBool() { - return getBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::dbgGetValString() { - return getString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::dbgGetValNative() { - return getNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(int value) { - setInt(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(double value) { - setFloat(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(bool value) { - setBool(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(const char *value) { - setString(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal() { - setNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetNumProperties(); - else return _valObject.size(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetProperty(index, name, value); - else { - int count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (count == index) { - *name = _valIter->_key.c_str(); - *value = _valIter->_value; - return true; - } - _valIter++; - count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) - return _valRef->dbgGetDescription(buf, bufSize); - - if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(buf, bufSize); - } else { - strncpy(buf, getString(), bufSize); - } - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScValue.h b/engines/wintermute/base/scriptables/ScValue.h deleted file mode 100644 index c66a60c22a..0000000000 --- a/engines/wintermute/base/scriptables/ScValue.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCVALUE_H -#define WINTERMUTE_SCVALUE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/wme_debugger.h" -#include "common/str.h" - -namespace WinterMute { - -class CScScript; -class CBScriptable; - -class CScValue : public CBBase, public IWmeDebugProp { -public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); - - static int compare(CScValue *val1, CScValue *val2); - static int compareStrict(CScValue *val1, CScValue *val2); - TValType getTypeTolerant(); - void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) - - bool _isConstVar; - bool saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *val); - bool _persistent; - bool propExists(const char *name); - void copy(CScValue *orig, bool copyWhole = false); - void setStringVal(const char *val); - TValType getType(); - bool getBool(bool defaultVal = false); - int getInt(int defaultVal = 0); - double getFloat(double defaultVal = 0.0f); - const char *getString(); - void *getMemBuffer(); - CBScriptable *getNative(); - bool deleteProp(const char *name); - void deleteProps(); - void CleanProps(bool includingNatives); - void setBool(bool val); - void setInt(int val); - void setFloat(double val); - void setString(const char *val); - void setString(const Common::String &val); - void setNULL(); - void setNative(CBScriptable *val, bool persistent = false); - void setObject(); - void setReference(CScValue *val); - bool isNULL(); - bool isNative(); - bool isString(); - bool isBool(); - bool isFloat(); - bool isInt(); - bool isObject(); - bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); - CScValue *getProp(const char *name); - CBScriptable *_valNative; - CScValue *_valRef; -protected: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; - - bool setProperty(const char *propName, int value); - bool setProperty(const char *propName, const char *value); - bool setProperty(const char *propName, double value); - bool setProperty(const char *propName, bool value); - bool setProperty(const char *propName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType dbgGetType(); - - // getters - virtual int dbgGetValInt(); - virtual double dbgGetValFloat(); - virtual bool dbgGetValBool(); - virtual const char *dbgGetValString(); - virtual IWmeDebugObject *dbgGetValNative(); - - // setters - virtual bool dbgSetVal(int value); - virtual bool dbgSetVal(double value); - virtual bool dbgSetVal(bool value); - virtual bool dbgSetVal(const char *value); - virtual bool dbgSetVal(); - - // properties - virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - - virtual bool dbgGetDescription(char *buf, int bufSize); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SxObject.cpp b/engines/wintermute/base/scriptables/SxObject.cpp deleted file mode 100644 index ba961ed2ae..0000000000 --- a/engines/wintermute/base/scriptables/SxObject.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SxObject.h" -#include "ScValue.h" -#include "ScStack.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CSXObject, false) - -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { - return new CSXObject(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int numParams = stack->pop()->getInt(0); - for (int i = 0; i < numParams; i++) { - addScript(stack->pop()->getString()); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SxObject.h b/engines/wintermute/base/scriptables/SxObject.h deleted file mode 100644 index b4ec7c6cde..0000000000 --- a/engines/wintermute/base/scriptables/SxObject.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CSXObject : public CBObject { -public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp new file mode 100644 index 0000000000..a9646e0045 --- /dev/null +++ b/engines/wintermute/base/scriptables/script.cpp @@ -0,0 +1,1461 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/memstream.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _scriptStream = NULL; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = Engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + cleanup(); +} + +void CScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.code_start = _scriptStream->readUint32LE(); + _header.func_table = _scriptStream->readUint32LE(); + _header.symbol_table = _scriptStream->readUint32LE(); + _header.event_table = _scriptStream->readUint32LE(); + _header.externals_table = _scriptStream->readUint32LE(); + _header.method_table = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); + + if (_header.magic != SCRIPT_MAGIC) { + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); + cleanup(); + return STATUS_FAILED; + } + + if (_header.version > SCRIPT_VERSION) { + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + cleanup(); + return STATUS_FAILED; + } + + initTables(); + + // init stacks + _scopeStack = new CScStack(_gameRef); + _callStack = new CScStack(_gameRef); + _thisStack = new CScStack(_gameRef); + _stack = new CScStack(_gameRef); + + _operand = new CScValue(_gameRef); + _reg1 = new CScValue(_gameRef); + + + // skip to the beginning + _iP = _header.code_start; + _scriptStream->seek(_iP); + _currentLine = 0; + + // init breakpoints + _engine->refreshScriptBreakpoints(this); + + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initTables() { + uint32 OrigIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbol_table; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.func_table; + + _numFunctions = getDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (uint32 i = 0; i < _numFunctions; i++) { + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); + } + + + // load events table + _iP = _header.event_table; + + _numEvents = getDWORD(); + _events = new TEventPos[_numEvents]; + for (uint32 i = 0; i < _numEvents; i++) { + _events[i].pos = getDWORD(); + _events[i].name = getString(); + } + + + // load externals + if (_header.version >= 0x0101) { + _iP = _header.externals_table; + + _numExternals = getDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (uint32 i = 0; i < _numExternals; i++) { + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)getDWORD(); + } + } + } + } + + // load method table + _iP = _header.method_table; + + _numMethods = getDWORD(); + _methods = new TMethodPos[_numMethods]; + for (uint32 i = 0; i < _numMethods; i++) { + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); + } + + + _iP = OrigIP; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { + cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); + + _buffer = new byte [size]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, buffer, size); + + _bufferSize = size; + + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // establish global variables table + _globals = new CScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(eventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, eventName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = initIP; + _scriptStream->seek(_iP); + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createMethodThread(CScScript *original, const char *methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) return STATUS_FAILED; + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(methodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, methodName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = ip; + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::cleanup() { + if (_buffer) delete [] _buffer; + _buffer = NULL; + + if (_filename) delete [] _filename; + _filename = NULL; + + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) delete _globals; + _globals = NULL; + + delete _scopeStack; + _scopeStack = NULL; + + delete _callStack; + _callStack = NULL; + + delete _thisStack; + _thisStack = NULL; + + delete _stack; + _stack = NULL; + + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; + + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; + + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (uint32 i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; + } + delete [] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only + + delete _scriptStream; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double CScScript::getFloat() { + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //CScValue* op = new CScValue(_gameRef); + _operand->cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = getDWORD(); + /* char *Temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); + + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = getDWORD(); + + _operand->setInt(_iP); + _callStack->push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->pop()->getString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = _stack->pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + + bool res = STATUS_FAILED; + bool TriedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + TriedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } + + if (DID_FAIL(res)) { + if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (!_unbreakable) { + _waitScript = var->getNative()->invokeMethodThread(MethodName); + if (!_waitScript) { + _stack->correctParams(0); + runtimeError("Error invoking method '%s'.", MethodName); + _stack->pushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->copyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->correctParams(0); + runtimeError("Cannot call method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->getProp(MethodName); + if(val){ + dw = GetFuncPos(val->getString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->getString()); + if(f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); + } + } + else{ + _operand->setInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = STATUS_FAILED; + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + + if (DID_FAIL(res)) { + _stack->correctParams(0); + runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = getDWORD(); + + TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + if (f) { + externalCall(_stack, _thisStack, f); + } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + _operand->setNULL(); + _scopeStack->push(_operand); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + + break; + + case II_CORRECT_STACK: + dw = getDWORD(); // params expected + _stack->correctParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->setObject(); + _stack->push(_operand); + break; + + case II_POP_EMPTY: + _stack->pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = getVar(_symbols[getDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->setReference(var); + _stack->push(_operand); + } else _stack->push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *VarName = _symbols[getDWORD()]; + CScValue *var = getVar(VarName); + if (var) { + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->setValue(val); + else { + var->copy(val); + } + } + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->push(_thisStack->getTop()); + break; + + case II_PUSH_INT: + _stack->pushInt((int)getDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->pushFloat(getFloat()); + break; + + + case II_PUSH_BOOL: + _stack->pushBool(getDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->pushString(getString()); + break; + + case II_PUSH_NULL: + _stack->pushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->setReference(_stack->getTop()); + _thisStack->push(_operand); + break; + + case II_PUSH_THIS: + _operand->setReference(getVar(_symbols[getDWORD()])); + _thisStack->push(_operand); + break; + + case II_POP_THIS: + _thisStack->pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *val = _stack->pop()->getProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); + + if (val == NULL) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else var->setProp(str, val); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + _stack->push(_reg1); + break; + + case II_POP_REG1: + _reg1->copy(_stack->pop()); + break; + + case II_JMP: + _iP = getDWORD(); + break; + + case II_JMP_FALSE: { + dw = getDWORD(); + //if(!_stack->pop()->getBool()) _iP = dw; + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!val->getBool()) _iP = dw; + } + break; + } + + case II_ADD: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); + delete [] tempStr; + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() + op2->getInt()); + else _operand->setFloat(op1->getFloat() + op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_SUB: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() - op2->getInt()); + else _operand->setFloat(op1->getFloat() - op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MUL: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() * op2->getInt()); + else _operand->setFloat(op1->getFloat() * op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_DIV: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getFloat() == 0.0f) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); + else _operand->setFloat(op1->getFloat() / op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MODULO: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getInt() == 0) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + _operand->setNULL(); + else _operand->setInt(op1->getInt() % op2->getInt()); + + _stack->push(_operand); + + break; + + case II_NOT: + op1 = _stack->pop(); + //if(op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) _operand->setBool(true); + else _operand->setBool(!op1->getBool()); + _stack->push(_operand); + + break; + + case II_AND: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() && op2->getBool()); + } + _stack->push(_operand); + break; + + case II_OR: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() || op2->getBool()); + } + _stack->push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() == op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) == 0); + _stack->push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() != op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_CMP_L: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); + } + else _operand->setBool(op1->getInt() < op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) < 0); + _stack->push(_operand); + break; + + case II_CMP_G: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); + } + else _operand->setBool(op1->getInt() > op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) > 0); + _stack->push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); + } + else _operand->setBool(op1->getInt() <= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) <= 0); + _stack->push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); + } + else _operand->setBool(op1->getInt() >= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) >= 0); + _stack->push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _stack->push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (_breakpoints[i] == _currentLine) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + if (_tracingMode) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + } + break; + + } + default: + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = STATUS_FAILED; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getFuncPos(const char *name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (strcmp(name, _functions[i].name) == 0) + return _functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getMethodPos(const char *name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (strcmp(name, _methods[i].name) == 0) + return _methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::getVar(char *name) { + CScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->getTop()->propExists(name)) + ret = _scopeStack->getTop()->getProp(name); + } + + // script globals + if (ret == NULL) { + if (_globals->propExists(name)) + ret = _globals->getProp(name); + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->propExists(name)) + ret = _engine->_globals->getProp(name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + CScValue *val = new CScValue(_gameRef); + CScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); + ret = _scopeStack->getTop()->getProp(name); + } else { + _globals->setProp(name, val); + ret = _globals->getProp(name); + } + delete val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitFor(CBObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitForExclusive(CBObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = CBPlatform::getTime() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else _state = SCRIPT_FINISHED; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::runtimeError(const char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); + + if (!_gameRef->_suppressScriptErrors) + _gameRef->quickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + persistMgr->transfer(TMEMBER(bufferSize)); + } + } else { + persistMgr->transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + initTables(); + } else { + _buffer = NULL; + _scriptStream = NULL; + } + } + + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->_saving) _tracingMode = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { + //if(_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getEventPos(const char *name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleEvent(const char *eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleMethod(const char *methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::pause() { + if (_state == SCRIPT_PAUSED) { + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return STATUS_FAILED; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + + _origState = _state; + _state = SCRIPT_PAUSED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::resume() { + if (_state != SCRIPT_PAUSED) return STATUS_OK; + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) + return &_externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::copyParameters(CScStack *stack) { + int i; + int NumParams = stack->pop()->getInt(); + for (i = NumParams - 1; i >= 0; i--) { + _stack->push(stack->getAt(i)); + } + _stack->pushInt(NumParams); + + for (i = 0; i < NumParams; i++) stack->pop(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finishThreads() { + for (int i = 0; i < _engine->_scripts.getSize(); i++) { + CScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + scr->finish(true); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::dbgGetFilename() { + return _filename; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendScript(IWmeDebugClient *client) { + if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else client->onScriptInit(this); + + return dbgSendVariables(client); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendVariables(IWmeDebugClient *client) { + // send script globals + _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + // CScValue *Scope = _scopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::dbgGetState() { + return _state; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetNumBreakpoints() { + return _breakpoints.getSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetBreakpoint(int index) { + if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSetTracingMode(bool isTracing) { + _tracingMode = isTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgGetTracingMode() { + return _tracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::afterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); + if (!buffer) { + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + + initTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h new file mode 100644 index 0000000000..899e1f3098 --- /dev/null +++ b/engines/wintermute/base/scriptables/script.h @@ -0,0 +1,183 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + bool dbgSendScript(IWmeDebugClient *client); + bool dbgSendVariables(IWmeDebugClient *client); + + CBArray _breakpoints; + bool _tracingMode; + + CScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(CScStack *stack); + + void afterLoad(); + + CScValue *_operand; + CScValue *_reg1; + bool _freezable; + bool resume(); + bool pause(); + bool canHandleEvent(const char *eventName); + bool canHandleMethod(const char *methodName); + bool createThread(CScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(CScScript *original, const char *methodName); + CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void runtimeError(const char *fmt, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(CBObject *object); + bool waitFor(CBObject *object); + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + CScValue *getVar(char *name); + uint32 getFuncPos(const char *name); + uint32 getEventPos(const char *name); + uint32 getMethodPos(const char *name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + TScriptHeader _header; + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; + bool executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); + void cleanup(); + bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *_filename; + char **_symbols; + uint32 _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; + CScScript::TExternalFunction *getExternal(char *name); + bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); +private: + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); + virtual TScriptState dbgGetState(); + virtual int dbgGetNumBreakpoints(); + virtual int dbgGetBreakpoint(int Index); + + virtual bool dbgSetTracingMode(bool IsTracing); + virtual bool dbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp new file mode 100644 index 0000000000..387093ac4a --- /dev/null +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -0,0 +1,712 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_file_manager.h" + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + _gameRef->LOG(0, "Initializing scripting engine..."); + + if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); + else _gameRef->LOG(0, " Script compiler is NOT available"); + + _globals = new CScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + CScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + CScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); + _globals->setProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + + _currentScript = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + saveBreakpoints(); + + disableProfiling(); + + cleanup(); + + for (int i = 0; i < _breakpoints.getSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; + } + _breakpoints.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::cleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + + _scripts.removeAll(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { + CBGame *gameRef = (CBGame *)data; + return gameRef->_fileManager->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::closeFile(void *data, byte *buffer) { + delete [] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(_gameRef, this); + bool ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { + _gameRef->LOG(ret, "Error running script '%s'...", filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(_gameRef); + if (owner)val.setNative(owner, true); + else val.setNULL(); + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + _gameRef->getDebugMgr()->onScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { + // is script in cache? + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + return NULL; + } + + // needs to be compiled? + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; + } else { + if (!_compilerAvailable) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + delete [] buffer; + return NULL; + } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { + int index = 0; + uint32 MinTime = CBPlatform::getTime(); + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete [] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tick() { + if (_scripts.getSize() == 0) + return STATUS_OK; + + + // resolve waiting scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + { + if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + { + if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + */ + if (_gameRef->validObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); + } else _scripts[i]->finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + } else { + if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->pushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); + _scripts[i]->run(); + _scripts[i]->_waitScript->finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + default: + //warning("CScEngine::Tick - Unhandled enum"); + break; + } // switch + } // for each script + + + // execute scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 StartTime = CBPlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + } + + // normal script + else { + uint32 startTime = 0; + bool isProfiling = _isProfiling; + if (isProfiling) startTime = CBPlatform::getTime(); + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + _scripts[i]->finish(); + _currentScript = NULL; + } + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeFinishedScripts() { + // remove finished scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + numRunning++; + break; + case SCRIPT_WAITING: + numWaiting++; + break; + case SCRIPT_PERSISTENT: + numPersistent++; + break; + default: + warning("CScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) *running = numRunning; + if (waiting) *waiting = numWaiting; + if (persistent) *persistent = numPersistent; + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetScript(CScScript *script) { + // terminate all scripts waiting for this script + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::editorCleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::pauseAll() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->pause(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resumeAll() { + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->resume(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::isValidScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { + // send global variables + _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->dbgSendScript(client); + } + + // and threads later + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->dbgSendScript(client); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + CScBreakpoint *bp = NULL; + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + bp = _breakpoints[i]; + break; + } + } + if (bp == NULL) { + bp = new CScBreakpoint(scriptFilename); + _breakpoints.add(bp); + } + + for (int i = 0; i < bp->_lines.getSize(); i++) { + if (bp->_lines[i] == line) return STATUS_OK; + } + bp->_lines.add(line); + + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + if (_breakpoints[i]->_lines[j] == line) { + _breakpoints[i]->_lines.removeAt(j); + if (_breakpoints[i]->_lines.getSize() == 0) { + delete _breakpoints[i]; + _breakpoints.removeAt(i); + } + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; + } + } + break; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _scripts.getSize(); i++) { + refreshScriptBreakpoints(_scripts[i]); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints(CScScript *script) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + if (!script || !script->_filename) return STATUS_FAILED; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { + script->_breakpoints.copy(_breakpoints[i]->_lines); + return STATUS_OK; + } + } + if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::saveBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + + char text[512]; + char key[100]; + + int count = 0; + for (int i = 0; i < _breakpoints.getSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + count++; + sprintf(key, "Breakpoint%d", count); + sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + + _gameRef->_registry->writeString("Debug", key, text); + } + } + _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::loadBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + char key[100]; + + int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= count; i++) { + /* uint32 BufSize = 512; */ + sprintf(key, "Breakpoint%d", i); + AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + + char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + + if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + delete[] path; + delete[] line; + path = NULL; + line = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) return; + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::enableProfiling() { + if (_isProfiling) return; + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = CBPlatform::getTime(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::disableProfiling() { + if (!_isProfiling) return; + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h new file mode 100644 index 0000000000..81dc13a73c --- /dev/null +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -0,0 +1,147 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(const char *filename, byte *buffer, uint32 size) { + _timestamp = CBPlatform::getTime(); + _buffer = new byte[size]; + if (_buffer) memcpy(_buffer, buffer, size); + _size = size; + _filename = filename; + }; + + ~CScCachedScript() { + if (_buffer) delete [] _buffer; + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *filename) { + _filename = filename; + } + + ~CScBreakpoint() { + _lines.removeAll(); + } + + Common::String _filename; + CBArray _lines; + }; + + + + +public: + bool dbgSendScripts(IWmeDebugClient *client); + + CBArray _breakpoints; + bool addBreakpoint(const char *scriptFilename, int line); + bool removeBreakpoint(const char *scriptFilename, int line); + bool refreshScriptBreakpoints(); + bool refreshScriptBreakpoints(CScScript *script); + bool saveBreakpoints(); + bool loadBreakpoints(); + + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(CScScript *script); + + CScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(CBObject *Object); + bool resetScript(CScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + CScValue *_globals; + CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); + + CBArray _scripts; + + void enableProfiling(); + void disableProfiling(); + bool getIsProfiling() { + return _isProfiling; + } + + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp new file mode 100644 index 0000000000..a1b8249cb1 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -0,0 +1,238 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { + return new CSXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); + + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) _length = stack->pop()->getInt(0); + else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXArray::scToString() { + static char dummy[32768]; // TODO: Get rid of static. + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + CScValue *val = _values->getProp(propName); + if (val) { + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); + } + } + + if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + } + return dummy; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Push") == 0) { + int numParams = stack->pop()->getInt(0); + char paramName[20]; + + for (int i = 0; i < numParams; i++) { + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); + } + stack->pushInt(_length); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Pop") == 0) { + + stack->correctParams(0); + + if (_length > 0) { + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); + _length--; + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (validNumber(name, ParamName)) { + return _values->getProp(ParamName); + } else return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length") == 0) { + int OrigLength = _length; + _length = MAX(value->getInt(0), 0); + + char PropName[20]; + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + _values->deleteProp(PropName); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + int Index = atoi(paramName); + if (Index >= _length) _length = Index + 1; + return _values->setProp(paramName, value); + } else return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::validNumber(const char *origStr, char *outStr) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::push(CScValue *val) { + char paramName[20]; + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h new file mode 100644 index 0000000000..b873416572 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + bool push(CScValue *Val); + bool validNumber(const char *origStr, char *outStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + int _length; + CScValue *_values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp new file mode 100644 index 0000000000..211c0d34f0 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -0,0 +1,297 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_date.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { + return new CSXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + CScValue *valYear = stack->pop(); + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { + g_system->getTimeAndDate(_tm); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXDate::scToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); +#if 0 + return asctime(&_tm); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetYear") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMonth") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDate") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHours") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMinutes") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_min); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSeconds") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWeekday") == 0) { + stack->correctParams(0); + warning("GetWeekday returns a wrong value on purpose"); + stack->pushInt(_tm.tm_mday % 7); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetYear") == 0) { + stack->correctParams(1); + _tm.tm_year = stack->pop()->getInt() - 1900; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMonth") == 0) { + stack->correctParams(1); + _tm.tm_mon = stack->pop()->getInt() - 1; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDate") == 0) { + stack->correctParams(1); + _tm.tm_mday = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHours") == 0) { + stack->correctParams(1); + _tm.tm_hour = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMinutes") == 0) { + stack->correctParams(1); + _tm.tm_min = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSeconds") == 0) { + stack->correctParams(1); + _tm.tm_sec = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->correctParams(0); + g_system->getTimeAndDate(_tm); + stack->pushNULL(); + return STATUS_OK; + } + + else + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CSXDate::scCompare(CBScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((CSXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h new file mode 100644 index 0000000000..82f6af1f1d --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + +#include "common/system.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int scCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + char *_string; + TimeDate _tm; +private: + Common::String _strRep; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp new file mode 100644 index 0000000000..58c0416b43 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -0,0 +1,779 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/system/sys_class.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_ext_file.h" + +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { + return new CSXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + _filename = NULL; + if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::close() { + if (_readFile) { + _gameRef->_fileManager->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXFile::scToString() { + if (_filename) return _filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + CBUtils::setString(&_filename, filename); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->correctParams(1); + close(); + _mode = stack->pop()->getInt(1); + if (_mode < 1 || _mode > 3) { + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); + _mode = 1; + } + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) { + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + if (strcmp(name, "OpenAsText") == 0) { + if (_mode == 2) _writeFile = openForWrite(_filename, false); + else _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) _writeFile = openForWrite(_filename, true); + else _writeFile = openForAppend(_filename, true); + } + + if (!_writeFile) { + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } + + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + close(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPosition") == 0) { + stack->correctParams(1); + if (_mode == 0) { + script->runtimeError("File.%s: File is not open", name); + stack->pushBool(false); + } else { + int Pos = stack->pop()->getInt(); + stack->pushBool(setPos(Pos)); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(0); + close(); + stack->pushBool(CBPlatform::deleteFile(_filename) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Copy") == 0) { + stack->correctParams(2); + const char *Dest = stack->pop()->getString(); + bool Overwrite = stack->pop()->getBool(true); + + close(); + stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadLine") == 0) { + stack->correctParams(0); + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + bool foundNewLine = false; + bool ret = STATUS_FAILED; + do { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + buf[counter] = '\0'; + foundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } while (DID_SUCCEED(ret)); + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (!foundNewLine && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadText") == 0) { + stack->correctParams(1); + int textLen = stack->pop()->getInt(); + + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + + bool ret = STATUS_FAILED; + while (counter < (uint32)textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (textLen > 0 && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->correctParams(1); + const char *line = stack->pop()->getString(); + if (!_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in text mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadBool") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadByte") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadShort") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadFloat") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + float val; + (*(uint32*)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadString") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); + } + delete [] str; + } else stack->pushNULL(); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteByte") == 0) { + stack->correctParams(1); + byte val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteShort") == 0) { + stack->correctParams(1); + int16 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint16LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->correctParams(1); + int32 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint32LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteFloat") == 0) { + stack->correctParams(1); + float val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + uint32 *ptr = (uint32*)&val; + _writeFile->writeUint32LE(*ptr); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); + stack->correctParams(1); + double val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteString") == 0) { + stack->correctParams(1); + const char *val = stack->pop()->getString(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + + uint32 size = strlen(val); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Position") == 0) { + _scValue->setInt(getPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(getLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextMode") == 0) { + _scValue->setBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccessMode") == 0) { + _scValue->setInt(_mode); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getPos() { + if (_mode == 1 && _readFile) + return _readFile->pos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) + return _readFile->seek(pos, whence); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getLength() { + if (_mode == 1 && _readFile) + return _readFile->size(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - reading length for WriteFile not supported"); + return 0; +/* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->_saving) { + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); + } else { + persistMgr->transfer(TMEMBER(pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) + close(); + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) + _writeFile = openForWrite(_filename, false); + else + _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) + _writeFile = openForWrite(_filename, true); + else + _writeFile = openForAppend(_filename, true); + } + if (_writeFile) + close(); + } + setPos(pos); + } + } + + return STATUS_OK; +} + +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h new file mode 100644 index 0000000000..5a6811fe57 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/base/base_scriptable.h" +#include "common/stream.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + Common::SeekableReadStream *_readFile; + Common::WriteStream *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void close(); + void cleanup(); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 Pos, int whence = SEEK_SET); + char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp new file mode 100644 index 0000000000..22b08087b7 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -0,0 +1,295 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/persistent.h" +#include "common/math.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +CBScriptable *makeSXMath(CBGame *inGame) { + return new CSXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Abs") == 0) { + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Acos") == 0) { + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Asin") == 0) { + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan") == 0) { + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan2") == 0) { + stack->correctParams(2); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); + stack->pushFloat(atan2(y, x)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ceil") == 0) { + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cos") == 0) { + stack->correctParams(1); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cosh") == 0) { + stack->correctParams(1); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exp") == 0) { + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Floor") == 0) { + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log") == 0) { + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log10") == 0) { + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pow") == 0) { + stack->correctParams(2); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); + + stack->pushFloat(pow(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sin") == 0) { + stack->correctParams(1); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sinh") == 0) { + stack->correctParams(1); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tan") == 0) { + stack->correctParams(1); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tanh") == 0) { + stack->correctParams(1); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sqrt") == 0) { + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DegToRad") == 0) { + stack->correctParams(1); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RadToDeg") == 0) { + stack->correctParams(1); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PI") == 0) { + _scValue->setFloat(M_PI); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h new file mode 100644 index 0000000000..422521233f --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + +private: + double degreeToRadian(double value); + double radianToDegree(double value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp new file mode 100644 index 0000000000..df2bf188ff --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -0,0 +1,508 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" +#include "common/file.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { + return new CSXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int NewSize = stack->pop()->getInt(); + resize(MAX(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + _size = 0; + _buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::cleanup() { + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::resize(int newSize) { + int oldSize = _size; + + if (_size == 0) { + _buffer = malloc(newSize); + if (_buffer) _size = newSize; + } else { + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; + } else return STATUS_FAILED; + } else { + _buffer = newBuf; + _size = newSize; + } + } + + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { + if (_buffer == NULL) { + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) + return true; + + if (start < 0 || length == 0 || start + length > _size) { + script->runtimeError("Set/Get method call is out of bounds"); + return false; + } else + return true; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSize") == 0) { + stack->correctParams(1); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (DID_SUCCEED(resize(newSize))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBool") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushNULL(); + else + stack->pushBool(*(bool *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetByte") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushNULL(); + else + stack->pushInt(*(byte *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetShort") == 0) { + stack->correctParams(1); + int Start = stack->pop()->getInt(); + if (!checkBounds(script, Start, sizeof(short))) + stack->pushNULL(); + else + stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) + stack->pushNULL(); + else + stack->pushInt(*(int *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFloat") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) + stack->pushNULL(); + else + stack->pushFloat(*(float *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDouble") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) + stack->pushNULL(); + else + stack->pushFloat(*(double *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); + + // find end of string + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + length = i - start; + break; + } + } + } + + if (!checkBounds(script, start, length)) + stack->pushNULL(); + else { + char *str = new char[length + 1]; + strncpy(str, (const char *)_buffer + start, length); + str[length] = '\0'; + stack->pushString(str); + delete [] str; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPointer") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushNULL(); + else { + void *pointer = *(void **)((byte *)_buffer + start); + CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + stack->pushNative(buf, false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBool") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); + + if (!checkBounds(script, start, sizeof(bool))) + stack->pushBool(false); + else { + *(bool *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetByte") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(byte))) + stack->pushBool(false); + else { + *(byte *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetShort") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(short))) + stack->pushBool(false); + else { + *(short *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(int))) + stack->pushBool(false); + else { + *(int *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFloat") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(float))) + stack->pushBool(false); + else { + *(float *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDouble") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(double))) + stack->pushBool(false); + else { + *(double *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); + + if (!checkBounds(script, start, strlen(val) + 1)) + stack->pushBool(false); + else { + memcpy((byte *)_buffer + start, val, strlen(val) + 1); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPointer") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + /* CScValue *Val = */ stack->pop(); + + if (!checkBounds(script, start, sizeof(void *))) + stack->pushBool(false); + else { + /* + int Pointer = (int)Val->getMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + stack->pushBool(true); + */ + // TODO fix + stack->pushBool(false); + + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->correctParams(0); + if (_buffer && _size) { + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); + } + stack->pushNULL(); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Size") == 0) { + _scValue->setInt(_size); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->_saving) { + if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + } else { + if (_size > 0) { + _buffer = malloc(_size); + persistMgr->getBytes((byte *)_buffer, _size); + } else _buffer = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::scCompare(CBScriptable *val) { + if (_buffer == val->scToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h new file mode 100644 index 0000000000..a9d78e50e4 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXMemBuffer(CBGame *inGame, CScStack *stack); + CSXMemBuffer(CBGame *inGame, void *buffer); + virtual ~CSXMemBuffer(); + virtual void *scToMemBuffer(); + int _size; +private: + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(CScScript *script, int start, int length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp new file mode 100644 index 0000000000..cb0d32d1a3 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -0,0 +1,67 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_object.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { + return new CSXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { + addScript(stack->pop()->getString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h new file mode 100644 index 0000000000..b4e869d5b3 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp new file mode 100644 index 0000000000..bd7541fadd --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -0,0 +1,404 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/script_ext_string.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" +#include "engines/wintermute/utils/string_util.h" +#include "common/tokenizer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { + return new CSXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + setStringVal(val->getString()); + } + + if (_capacity == 0) setStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXString::scToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Substring") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); + + if (end < start) CBUtils::swap(&start, &end); + + //try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // stack->pushNULL(); + // } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Substr") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + + CScValue *val = stack->pop(); + int len = val->getInt(); + + if (!val->isNULL() && len <= 0) { + stack->pushString(""); + return STATUS_OK; + } + + if (val->isNULL()) len = strlen(_string) - start; + +// try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); +// } catch (std::exception &) { +// stack->pushNULL(); +// } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToUpperCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toUppercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToLowerCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toLowercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IndexOf") == 0) { + stack->correctParams(2); + + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString toFind; + if (_gameRef->_textEncoding == TEXT_UTF8) + toFind = StringUtil::utf8ToWide(strToFind); + else + toFind = StringUtil::ansiToWide(strToFind); + + int indexOf = StringUtil::indexOf(str, toFind, index); + stack->pushInt(indexOf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Split") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) strcpy(separators, val->getString()); + + CSXArray *array = new CSXArray(_gameRef); + if (!array) { + stack->pushNULL(); + return STATUS_OK; + } + + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString delims; + if (_gameRef->_textEncoding == TEXT_UTF8) + delims = StringUtil::utf8ToWide(separators); + else + delims = StringUtil::ansiToWide(separators); + + Common::Array parts; + + + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size());*/ + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (_gameRef->_textEncoding == TEXT_UTF8) + val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + else + val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(_string); + _scValue->setInt(wstr.size()); + } else + _scValue->setInt(strlen(_string)); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Capacity") == 0) { + _scValue->setInt(_capacity); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Capacity") == 0) { + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); + else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); + delete[] _string; + _string = newStr; + _capacity = newCap; + } + } + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->_saving) { + if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + persistMgr->getBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::scCompare(CBScriptable *val) { + return strcmp(_string, ((CSXString *)val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h new file mode 100644 index 0000000000..52a1524dde --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + void scSetString(const char *val); + const char *scToString(); + void setStringVal(const char *val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp new file mode 100644 index 0000000000..188cb2d15c --- /dev/null +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -0,0 +1,226 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); +#endif + + for (int i = 0; i < _values.getSize(); i++) { + delete _values[i]; + } + _values.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::push(CScValue *val) { + _sP++; + + if (_sP < _values.getSize()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + CScValue *copyVal = new CScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getPushValue() { + _sP++; + + if (_sP >= _values.getSize()) { + CScValue *val = new CScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getTop() { + if (_sP < 0 || _sP >= _values.getSize()) return NULL; + else return _values[_sP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= _values.getSize()) return NULL; + else return _values[index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.removeAt(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + CScValue *nullVal = new CScValue(_gameRef); + nullVal->setNULL(); + _values.insertAt(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if (_values.getSize() > _sP + 1) { + delete _values[_values.getSize() - 1]; + _values.removeAt(_values.getSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNULL() { + /* + CScValue* val = new CScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushInt(int val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushFloat(double val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushBool(bool val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushString(const char *val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNative(CBScriptable *val, bool persistent) { + /* + CScValue* val = new CScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScStack::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_sP)); + _values.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h new file mode 100644 index 0000000000..6460f901fe --- /dev/null +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *getAt(int Index); + CScValue *getPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void pushNative(CBScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); + void pushNULL(); + void correctParams(uint32 expectedParams); + CScValue *getTop(); + void push(CScValue *val); + CScValue *pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray _values; + int _sP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp new file mode 100644 index 0000000000..da47ed299f --- /dev/null +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -0,0 +1,1054 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::cleanup(bool ignoreNatives) { + deleteProps(); + + if (_valString) delete [] _valString; + + if (!ignoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { + _gameRef->_scValue->_type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (_gameRef->_textEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + CScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + + if (ret == NULL) { + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) ret = _valIter->_value; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) + return _valRef->setProp(name, val); + + bool ret = STATUS_FAILED; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scSetProperty(name, val); + } + + if (DID_FAIL(ret)) { + CScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) + newVal = new CScValue(_gameRef); + else newVal->cleanup(); + + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; + + if (_type != VAL_NATIVE) _type = VAL_OBJECT; + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + CScValue* val = new CScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) + return _valRef->propExists(name); + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNULL(); + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNative(); + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isString(); + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isFloat(); + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isInt() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isInt(); + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isBool() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isBool(); + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isObject() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isObject(); + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getType(); + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setBool(bool val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setBool(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetBool(val); + return; + } + + _valBool = val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setInt(int val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setInt(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetInt(val); + return; + } + + _valInt = val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setFloat(double val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setFloat(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetFloat(val); + return; + } + + _valFloat = val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setString(const char *val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setString(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetString(val); + return; + } + + setStringVal(val); + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; +} + +void CScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void CScValue::setStringVal(const char *val) { + if (_valString) { + delete [] _valString; + _valString = NULL; + } + + if (val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(val) + 1]; + if (_valString) { + strcpy(_valString, val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; + } + _valNative = NULL; + deleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNative(CBScriptable *val, bool persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNative(val, persistent); + return; + } + + if (val == NULL) { + setNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != val) delete _valNative; + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = persistent; + + _valNative = val; + if (_valNative && !_persistent) _valNative->_refCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setReference(CScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getBool(); + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->scToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::getInt(int defaultVal) { + if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->scToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getFloat(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->scToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return defaultVal; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getMemBuffer(); + + if (_type == VAL_NATIVE) + return _valNative->scToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::getString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getString(); + + switch (_type) { + case VAL_OBJECT: + setStringVal("[object]"); + break; + + case VAL_NULL: + setStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; + break; + } + + case VAL_BOOL: + setStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + setStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + setStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + setStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::getNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getNative(); + + if (_type == VAL_NATIVE) return _valNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::copy(CScValue *orig, bool copyWhole) { + _gameRef = orig->_gameRef; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + + cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + setStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setValue(CScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { + case VAL_INT: + _valNative->scSetInt(val->getInt()); + break; + case VAL_FLOAT: + _valNative->scSetFloat(val->getFloat()); + break; + case VAL_BOOL: + _valNative->scSetBool(val->getBool()); + break; + case VAL_STRING: + _valNative->scSetString(val->getString()); + break; + default: + warning("CScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else copy(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (persistMgr->_saving) { + size = _valObject.size(); + persistMgr->transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); + + _valIter++; + } + } else { + CScValue *val; + persistMgr->transfer("", &size); + for (int i = 0; i < size; i++) { + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); + + _valObject[str] = val; + delete [] str; + } + } + + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); + + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::compare(CScValue *val1, CScValue *val2) { + // both natives? + if (val1->isNative() && val2->isNative()) { + // same class? + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else return strcmp(val1->getString(), val2->getString()); + } + + // both objects? + if (val1->isObject() && val2->isObject()) return -1; + + + // null states + if (val1->isNULL() && !val2->isNULL()) return -1; + else if (!val1->isNULL() && val2->isNULL()) return 1; + else if (val1->isNULL() && val2->isNULL()) return 0; + + // one of them is string? convert both to string + if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + + // one of them is float? + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) return -1; + else if (val1->getFloat() > val2->getFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (val1->getInt() < val2->getInt()) return -1; + else if (val1->getInt() > val2->getInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::compareStrict(CScValue *val1, CScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; + else return CScValue::compare(val1, val2); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, int value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, const char *value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, double value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, bool value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName) { + CScValue *val = new CScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::dbgGetType() { + switch (getType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetValInt() { + return getInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::dbgGetValFloat() { + return getFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetValBool() { + return getBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::dbgGetValString() { + return getString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::dbgGetValNative() { + return getNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(int value) { + setInt(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(double value) { + setFloat(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(bool value) { + setBool(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(const char *value) { + setString(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal() { + setNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetNumProperties() { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetNumProperties(); + else return _valObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetProperty(index, name, value); + else { + int count = 0; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (count == index) { + *name = _valIter->_key.c_str(); + *value = _valIter->_value; + return true; + } + _valIter++; + count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) + return _valRef->dbgGetDescription(buf, bufSize); + + if (_type == VAL_NATIVE) { + _valNative->scDebuggerDesc(buf, bufSize); + } else { + strncpy(buf, getString(), bufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h new file mode 100644 index 0000000000..eaee3ed773 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_value.h @@ -0,0 +1,141 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + + static int compare(CScValue *val1, CScValue *val2); + static int compareStrict(CScValue *val1, CScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool _isConstVar; + bool saveAsText(CBDynBuffer *buffer, int indent); + void setValue(CScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(CScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); + const char *getString(); + void *getMemBuffer(); + CBScriptable *getNative(); + bool deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(CBScriptable *val, bool persistent = false); + void setObject(); + void setReference(CScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + CScValue *getProp(const char *name); + CBScriptable *_valNative; + CScValue *_valRef; +protected: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType dbgGetType(); + + // getters + virtual int dbgGetValInt(); + virtual double dbgGetValFloat(); + virtual bool dbgGetValBool(); + virtual const char *dbgGetValString(); + virtual IWmeDebugObject *dbgGetValNative(); + + // setters + virtual bool dbgSetVal(int value); + virtual bool dbgSetVal(double value); + virtual bool dbgSetVal(bool value); + virtual bool dbgSetVal(const char *value); + virtual bool dbgSetVal(); + + // properties + virtual int dbgGetNumProperties(); + virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); + + virtual bool dbgGetDescription(char *buf, int bufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp new file mode 100644 index 0000000000..e1819e3c65 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -0,0 +1,288 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + _sound = NULL; + _soundFilename = NULL; + + _soundType = Audio::Mixer::kSFXSoundType; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (_sound) _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + + delete[] _soundFilename; + _soundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + delete[] _soundFilename; + _soundFilename = NULL; + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = new char[strlen(filename) + 1]; + strcpy(_soundFilename, filename); + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSoundSimple() { + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->setPosition(_soundPosition); + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->resume(); + else return STATUS_OK; + } else return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getLength() { + if (_sound) return _sound->getLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) _sound->_freezePaused = true; + return _sound->pause(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::persist(CBPersistMgr *persistMgr) { + if (persistMgr->_saving && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) + _soundPosition = _sound->getPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPaused() { + return _sound && _soundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPositionTime(uint32 time) { + if (!_sound) return STATUS_FAILED; + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) + _soundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getPositionTime() { + if (!_sound) return 0; + + if (!_sound->isPlaying()) + return 0; + else return _sound->getPosition(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolumePercent(int percent) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(percent * 255 / 100); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(volume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPrivateVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->_privateVolume = volume; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolumePercent() { + if (!_sound) + return 0; + else return _sound->_privateVolume * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolume() { + if (!_sound) + return 0; + else return _sound->_privateVolume; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setLoopStart(uint32 pos) { + if (!_sound) + return STATUS_FAILED; + else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPan(float pan) { + if (_sound) + return _sound->setPan(pan); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { + if (!_sound) + return STATUS_OK; + + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + bool ret = _sound->applyFX(type, param1, param2, param3, param4); + + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; + + return ret; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h new file mode 100644 index 0000000000..ef52194090 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "audio/mixer.h" + +namespace WinterMute { + +class CBSoundBuffer; +class CBSound : public CBBase { +public: + bool setPan(float pan); + int _soundPrivateVolume; + int getVolume(); + int getVolumePercent(); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); + uint32 getPositionTime(); + bool setPositionTime(uint32 time); + bool _soundPaused; + bool _soundFreezePaused; + bool isPlaying(); + bool isPaused(); + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + char *_soundFilename; + bool setSoundSimple(); + bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + +private: + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp new file mode 100644 index 0000000000..a868f99823 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -0,0 +1,383 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" +#include "common/system.h" +#include "common/substream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; + + delete[] _filename; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + _streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +#if 0 + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } +#endif + + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = _gameRef->_fileManager->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + Common::String strFilename(filename); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); + } else if (strFilename.hasSuffix(".wav")) { + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + } + } + } else { + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + } + if (!_stream) { + return STATUS_FAILED; + } + CBUtils::setString(&_filename, filename); + + return STATUS_OK; +#if 0 + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { + _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); + return STATUS_FAILED; + } + + CBUtils::setString(&_filename, filename); + + /* + bool res; + bool NewlyCreated = false; + + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = _gameRef->_fileManager->openFile(filename); + if(!_file){ + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + // switch to streamed for big files + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!_soundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(_file); + if(DID_FAIL(res)){ + _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); + return res; + } + } + + + + // store filename + if(!_filename){ + _filename = new char[strlen(filename)+1]; + strcpy(_filename, filename); + } + + // close file (if not streaming) + if(!_streamed && _file){ + _gameRef->_fileManager->closeFile(_file); + _file = NULL; + } + */ + + return STATUS_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; + if (looping) { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setLooping(bool looping) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + _looping = looping; +#if 0 + + + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::resume() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setVolume(int volume) { + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; + if (_stream && _handle) { + byte vol = (byte)(_volume); + g_system->getMixer()->setChannelVolume(*_handle, vol); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPosition(uint32 pos) { + warning("CBSoundBuffer::SetPosition - not implemented yet"); +#if 0 + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); + } +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; +#if 0 + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; + } + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return STATUS_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("CBSoundBuffer::ApplyFX - not implemented yet"); + switch (type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h new file mode 100644 index 0000000000..a491bd49ad --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -0,0 +1,100 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); + bool isPlaying(); + + void setLooping(bool looping); + + uint32 getPosition(); + bool setPosition(uint32 pos); + uint32 getLength(); + + bool setLoopStart(uint32 pos); + uint32 getLoopStart() const { + return _loopStart; + } + + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); + void updateVolume(); + + void setType(Audio::Mixer::SoundType Type); + + bool loadFromFile(const char *filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + Common::SeekableReadStream *_file; + char *_filename; + bool _streamed; + + int _privateVolume; +private: + int _volume; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp new file mode 100644 index 0000000000..c2174dea6a --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -0,0 +1,292 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::cleanup() { + for (uint32 i = 0; i < _sounds.size(); i++) + delete _sounds[i]; + _sounds.clear(); +#if 0 + BASS_Free(); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::saveSettings() { + if (_soundAvailable) { + _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _soundAvailable = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initLoop() { + if (!_soundAvailable) + return STATUS_OK; +#if 0 + + BASS_Update(500); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (!_soundAvailable) + return NULL; + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (_gameRef->_fileManager->hasFile(newFile)) { + filename = newFile.c_str(); + } + } + + sound = new CBSoundBuffer(_gameRef); + if (!sound) return NULL; + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", filename); + delete sound; + return NULL; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { + if (!sound) + return STATUS_FAILED; + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i] == sound) { + delete _sounds[i]; + _sounds.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { + if (!_soundAvailable) + return STATUS_OK; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); + break; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); + break; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); + break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); + } + g_wintermute->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { + int volume = 0; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); + break; + default: + error("Sound-type not set"); + break; + } + + return (byte)(volume * 100 / 255); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (uint32 i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::pauseAll(bool includingMusic) { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + _sounds[i]->pause(); + _sounds[i]->_freezePaused = true; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::resumeAll() { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)_gameRef->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h new file mode 100644 index 0000000000..2c05bbfcb8 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -0,0 +1,69 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace WinterMute { +class CBSoundBuffer; +class CBSoundMgr : public CBBase { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte getMasterVolumePercent(); + byte getMasterVolume(); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); + byte getVolumePercent(Audio::Mixer::SoundType type); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); + uint32 _volumeOriginal; + int _volumeMaster; + bool removeSound(CBSoundBuffer *sound); + CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initLoop(); + bool initialize(); + bool _soundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + Common::Array _sounds; + void saveSettings(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index e0d7ad8132..865e60b447 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -31,10 +31,12 @@ #include -#include "engines/wintermute/base/BPersistMgr.h" +#include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { +// Quite the same as Common::Array, but with persistence-support. + ///////////////////////////////////////////////////////////////////////////// template inline void DCConstructElements(TYPE *pElements, int nCount) { diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index e3fbb15d3f..0abe78fa35 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -22,7 +22,7 @@ #include "engines/advancedDetector.h" #include "engines/wintermute/wintermute.h" -#include "engines/wintermute/base/BPersistMgr.h" +#include "engines/wintermute/base/base_persistence_manager.h" #include "common/config-manager.h" #include "common/error.h" diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp deleted file mode 100644 index a99138ade6..0000000000 --- a/engines/wintermute/graphics/transparentSurface.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "common/algorithm.h" -#include "common/endian.h" -#include "common/util.h" -#include "common/rect.h" -#include "common/textconsole.h" -#include "graphics/primitives.h" -#include "engines/wintermute/graphics/transparentSurface.h" - -namespace WinterMute { - -TransparentSurface::TransparentSurface() : Surface() {} - -TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface() { - if (copyData) { - copyFrom(surf); - } else { - w = surf.w; - h = surf.h; - pitch = surf.pitch; - format = surf.format; - pixels = surf.pixels; - } -} - -void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { - byte *in, *out; - -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else - const int aIndex = 3; - const int bIndex = 2; - const int gIndex = 1; - const int rIndex = 0; -#endif - - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; - - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; - - for (uint32 i = 0; i < height; i++) { - out = outo; - in = ino; - for (uint32 j = 0; j < width; j++) { - uint32 pix = *(uint32 *)in; - uint32 o_pix = *(uint32 *) out; - int b = (pix >> bShift) & 0xff; - int g = (pix >> gShift) & 0xff; - int r = (pix >> rShift) & 0xff; - int a = (pix >> aShift) & 0xff; - int o_b, o_g, o_r, o_a; - in += inStep; - - /* if (ca != 255) { - a = a * ca >> 8; - }*/ - - switch (a) { - case 0: // Full transparency - out += 4; - break; - case 255: // Full opacity - o_b = b; - o_g = g; - o_r = r; - o_a = a; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; - out += 4; - break; - - default: // alpha blending - o_a = 255; - o_b = (o_pix >> bShiftTarget) & 0xff; - o_g = (o_pix >> gShiftTarget) & 0xff; - o_r = (o_pix >> rShiftTarget) & 0xff; - o_b += ((b - o_b) * a) >> 8; - o_g += ((g - o_g) * a) >> 8; - o_r += ((r - o_r) * a) >> 8; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; - out += 4; - } - } - outo += pitch; - ino += inoStep; - } -} - - -Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height) { - int ca = (color >> 24) & 0xff; - - Common::Rect retSize; - retSize.top = 0; - retSize.left = 0; - retSize.setWidth(0); - retSize.setHeight(0); - // Check if we need to draw anything at all - if (ca == 0) - return retSize; - - int cr = (color >> 16) & 0xff; - int cg = (color >> 8) & 0xff; - int cb = (color >> 0) & 0xff; - - // Compensate for transparency. Since we're coming - // down to 255 alpha, we just compensate for the colors here - if (ca != 255) { - cr = cr * ca >> 8; - cg = cg * ca >> 8; - cb = cb * ca >> 8; - } - - // Create an encapsulating surface for the data - TransparentSurface srcImage(*this, false); - // TODO: Is the data really in the screen format? - if (format.bytesPerPixel != 4) { - warning("TransparentSurface can only blit 32 bpp images"); - return retSize; - } - - if (pPartRect) { - srcImage.pixels = &((char *)pixels)[pPartRect->top * srcImage.pitch + pPartRect->left * 4]; - srcImage.w = pPartRect->width(); - srcImage.h = pPartRect->height(); - - debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, - pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); - } else { - - debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0, - srcImage.w, srcImage.h, color, width, height); - } - - if (width == -1) - width = srcImage.w; - if (height == -1) - height = srcImage.h; - -#ifdef SCALING_TESTING - // Hardcode scaling to 66% to test scaling - width = width * 2 / 3; - height = height * 2 / 3; -#endif - - Graphics::Surface *img; - Graphics::Surface *imgScaled = NULL; - byte *savedPixels = NULL; - if ((width != srcImage.w) || (height != srcImage.h)) { - // Scale the image - img = imgScaled = srcImage.scale(width, height); - savedPixels = (byte *)img->pixels; - } else { - img = &srcImage; - } - - // Handle off-screen clipping - if (posY < 0) { - img->h = MAX(0, (int)img->h - -posY); - img->pixels = (byte *)img->pixels + img->pitch * -posY; - posY = 0; - } - - if (posX < 0) { - img->w = MAX(0, (int)img->w - -posX); - img->pixels = (byte *)img->pixels + (-posX * 4); - posX = 0; - } - - img->w = CLIP((int)img->w, 0, (int)MAX((int)target.w - posX, 0)); - img->h = CLIP((int)img->h, 0, (int)MAX((int)target.h - posY, 0)); - - if ((img->w > 0) && (img->h > 0)) { - int xp = 0, yp = 0; - - int inStep = 4; - int inoStep = img->pitch; - if (flipping & TransparentSurface::FLIP_V) { - inStep = -inStep; - xp = img->w - 1; - } - - if (flipping & TransparentSurface::FLIP_H) { - inoStep = -inoStep; - yp = img->h - 1; - } - - byte *ino = (byte *)img->getBasePtr(xp, yp); - byte *outo = (byte *)target.getBasePtr(posX, posY); - byte *in, *out; - -#ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else - const int aIndex = 3; - const int bIndex = 2; - const int gIndex = 1; - const int rIndex = 0; -#endif - - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; - - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; - - if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { - doBlit(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); - } else { - for (int i = 0; i < img->h; i++) { - out = outo; - in = ino; - for (int j = 0; j < img->w; j++) { - uint32 pix = *(uint32 *)in; - uint32 o_pix = *(uint32 *) out; - int b = (pix >> bShift) & 0xff; - int g = (pix >> gShift) & 0xff; - int r = (pix >> rShift) & 0xff; - int a = (pix >> aShift) & 0xff; - int o_b, o_g, o_r, o_a; - in += inStep; - - if (ca != 255) { - a = a * ca >> 8; - } - - switch (a) { - case 0: // Full transparency - out += 4; - break; - case 255: // Full opacity - if (cb != 255) - o_b = (b * cb) >> 8; - else - o_b = b; - - if (cg != 255) - o_g = (g * cg) >> 8; - else - o_g = g; - - if (cr != 255) - o_r = (r * cr) >> 8; - else - o_r = r; - o_a = a; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; - out += 4; - break; - - default: // alpha blending - o_a = 255; - o_b = (o_pix >> bShiftTarget) & 0xff; - o_g = (o_pix >> gShiftTarget) & 0xff; - o_r = (o_pix >> rShiftTarget) & 0xff; - if (cb == 0) - o_b = 0; - else if (cb != 255) - o_b += ((b - o_b) * a * cb) >> 16; - else - o_b += ((b - o_b) * a) >> 8; - if (cg == 0) - o_g = 0; - else if (cg != 255) - o_g += ((g - o_g) * a * cg) >> 16; - else - o_g += ((g - o_g) * a) >> 8; - if (cr == 0) - o_r = 0; - else if (cr != 255) - o_r += ((r - o_r) * a * cr) >> 16; - else - o_r += ((r - o_r) * a) >> 8; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; - out += 4; - } - } - outo += target.pitch; - ino += inoStep; - } - } - } - - if (imgScaled) { - imgScaled->pixels = savedPixels; - imgScaled->free(); - delete imgScaled; - } - - retSize.setWidth(img->w); - retSize.setHeight(img->h); - return retSize; -} - -/** - * Scales a passed surface, creating a new surface with the result - * @param srcImage Source image to scale - * @param scaleFactor Scale amount. Must be between 0 and 1.0 (but not zero) - * @remarks Caller is responsible for freeing the returned surface - */ -TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { - TransparentSurface *s = new TransparentSurface(); - s->create(xSize, ySize, this->format); - - int *horizUsage = scaleLine(xSize, this->w); - int *vertUsage = scaleLine(ySize, this->h); - - // Loop to create scaled version - for (int yp = 0; yp < ySize; ++yp) { - const byte *srcP = (const byte *)this->getBasePtr(0, vertUsage[yp]); - byte *destP = (byte *)s->getBasePtr(0, yp); - - for (int xp = 0; xp < xSize; ++xp) { - const byte *tempSrcP = srcP + (horizUsage[xp] * this->format.bytesPerPixel); - for (int byteCtr = 0; byteCtr < this->format.bytesPerPixel; ++byteCtr) { - *destP++ = *tempSrcP++; - } - } - } - - // Delete arrays and return surface - delete[] horizUsage; - delete[] vertUsage; - return s; -} - -/** - * Writes a color key to the alpha channel of the surface - * @param rKey the red component of the color key - * @param gKey the green component of the color key - * @param bKey the blue component of the color key - * @param overwriteAlpha if true, all other alpha will be set fully opaque - */ -void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { - assert(format.bytesPerPixel == 4); - for (int i = 0; i < h; i++) { - for (int j = 0; j < w; j++) { - uint32 pix = ((uint32 *)pixels)[i * w + j]; - uint8 r, g, b, a; - format.colorToARGB(pix, a, r, g, b); - if (r == rKey && g == gKey && b == bKey) { - a = 0; - ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); - } else if (overwriteAlpha) { - a = 255; - ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); - } - } - } -} - -/** - * Returns an array indicating which pixels of a source image horizontally or vertically get - * included in a scaled image - */ -int *TransparentSurface::scaleLine(int size, int srcSize) { - int scale = 100 * size / srcSize; - assert(scale > 0); - int *v = new int[size]; - Common::fill(v, &v[size], 0); - - int distCtr = 0; - int *destP = v; - for (int distIndex = 0; distIndex < srcSize; ++distIndex) { - distCtr += scale; - while (distCtr >= 100) { - assert(destP < &v[size]); - *destP++ = distIndex; - distCtr -= 100; - } - } - - return v; -} - - -} // End of namespace Graphics diff --git a/engines/wintermute/graphics/transparentSurface.h b/engines/wintermute/graphics/transparentSurface.h deleted file mode 100644 index e271bf2488..0000000000 --- a/engines/wintermute/graphics/transparentSurface.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef GRAPHICS_TRANSPARENTSURFACE_H -#define GRAPHICS_TRANSPARENTSURFACE_H - -#include "graphics/surface.h" - -/* - * This code is based on Broken Sword 2.5 engine - * - * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer - * - * Licensed under GNU GPL v2 - * - */ - -// TODO: Find a better solution for this. -#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B)) -#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B)) - -namespace WinterMute { - -/** - * A transparent graphics surface, which implements alpha blitting. - */ -struct TransparentSurface : public Graphics::Surface { - TransparentSurface(); - TransparentSurface(const Graphics::Surface &surf, bool copyData = false); - - void setColorKey(char r, char g, char b); - void disableColorKey(); - - // Enums - /** - @brief The possible flipping parameters for the blit methode. - */ - enum FLIP_FLAGS { - /// The image will not be flipped. - FLIP_NONE = 0, - /// The image will be flipped at the horizontal axis. - FLIP_H = 1, - /// The image will be flipped at the vertical axis. - FLIP_V = 2, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_HV = FLIP_H | FLIP_V, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_VH = FLIP_H | FLIP_V - }; - - /** - @brief renders the surface to another surface - @param pDest a pointer to the target image. In most cases this is the framebuffer. - @param PosX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.
- The default value is 0. - @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.
- The default value is 0. - @param Flipping how the the image should be flipped.
- The default value is BS_Image::FLIP_NONE (no flipping) - @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.
- This referes to the unflipped and unscaled image.
- The default value is NULL. - @param Color an ARGB color value, which determines the parameters for the color modulation und alpha blending.
- The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).
- The color components determines the color for color modulation.
- The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation). - The macros BS_RGB and BS_ARGB can be used for the creation of the color value. - @param Width the output width of the screen section. - The images will be scaled if the output width of the screen section differs from the image section.
- The value -1 determines that the image should not be scaled.
- The default value is -1. - @param Width the output height of the screen section. - The images will be scaled if the output width of the screen section differs from the image section.
- The value -1 determines that the image should not be scaled.
- The default value is -1. - @return returns false if the rendering failed. - */ - - Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0, - int flipping = FLIP_NONE, - Common::Rect *pPartRect = NULL, - uint color = BS_ARGB(255, 255, 255, 255), - int width = -1, int height = -1); - void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); - TransparentSurface *scale(int xSize, int ySize) const; -private: - static int *scaleLine(int size, int srcSize); -}; - -/** - * A deleter for Surface objects which can be used with SharedPtr. - * - * This deleter assures Surface::free is called on deletion. - */ -/*struct SharedPtrTransparentSurfaceDeleter { - void operator()(TransparentSurface *ptr) { - ptr->free(); - delete ptr; - } -};*/ - - -} // End of namespace Graphics - - -#endif diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp new file mode 100644 index 0000000000..6ab9c621d0 --- /dev/null +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -0,0 +1,427 @@ +/* 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. + */ + +#include "common/algorithm.h" +#include "common/endian.h" +#include "common/util.h" +#include "common/rect.h" +#include "common/textconsole.h" +#include "graphics/primitives.h" +#include "engines/wintermute/graphics/transparent_surface.h" + +namespace WinterMute { + +TransparentSurface::TransparentSurface() : Surface() {} + +TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface() { + if (copyData) { + copyFrom(surf); + } else { + w = surf.w; + h = surf.h; + pitch = surf.pitch; + format = surf.format; + pixels = surf.pixels; + } +} + +void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { + byte *in, *out; + +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 0; + const int bIndex = 1; + const int gIndex = 2; + const int rIndex = 3; +#else + const int aIndex = 3; + const int bIndex = 2; + const int gIndex = 1; + const int rIndex = 0; +#endif + + const int bShift = 8;//img->format.bShift; + const int gShift = 16;//img->format.gShift; + const int rShift = 24;//img->format.rShift; + const int aShift = 0;//img->format.aShift; + + const int bShiftTarget = 8;//target.format.bShift; + const int gShiftTarget = 16;//target.format.gShift; + const int rShiftTarget = 24;//target.format.rShift; + + for (uint32 i = 0; i < height; i++) { + out = outo; + in = ino; + for (uint32 j = 0; j < width; j++) { + uint32 pix = *(uint32 *)in; + uint32 o_pix = *(uint32 *) out; + int b = (pix >> bShift) & 0xff; + int g = (pix >> gShift) & 0xff; + int r = (pix >> rShift) & 0xff; + int a = (pix >> aShift) & 0xff; + int o_b, o_g, o_r, o_a; + in += inStep; + + /* if (ca != 255) { + a = a * ca >> 8; + }*/ + + switch (a) { + case 0: // Full transparency + out += 4; + break; + case 255: // Full opacity + o_b = b; + o_g = g; + o_r = r; + o_a = a; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; + out += 4; + break; + + default: // alpha blending + o_a = 255; + o_b = (o_pix >> bShiftTarget) & 0xff; + o_g = (o_pix >> gShiftTarget) & 0xff; + o_r = (o_pix >> rShiftTarget) & 0xff; + o_b += ((b - o_b) * a) >> 8; + o_g += ((g - o_g) * a) >> 8; + o_r += ((r - o_r) * a) >> 8; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; + out += 4; + } + } + outo += pitch; + ino += inoStep; + } +} + + +Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height) { + int ca = (color >> 24) & 0xff; + + Common::Rect retSize; + retSize.top = 0; + retSize.left = 0; + retSize.setWidth(0); + retSize.setHeight(0); + // Check if we need to draw anything at all + if (ca == 0) + return retSize; + + int cr = (color >> 16) & 0xff; + int cg = (color >> 8) & 0xff; + int cb = (color >> 0) & 0xff; + + // Compensate for transparency. Since we're coming + // down to 255 alpha, we just compensate for the colors here + if (ca != 255) { + cr = cr * ca >> 8; + cg = cg * ca >> 8; + cb = cb * ca >> 8; + } + + // Create an encapsulating surface for the data + TransparentSurface srcImage(*this, false); + // TODO: Is the data really in the screen format? + if (format.bytesPerPixel != 4) { + warning("TransparentSurface can only blit 32 bpp images"); + return retSize; + } + + if (pPartRect) { + srcImage.pixels = &((char *)pixels)[pPartRect->top * srcImage.pitch + pPartRect->left * 4]; + srcImage.w = pPartRect->width(); + srcImage.h = pPartRect->height(); + + debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, + pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); + } else { + + debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0, + srcImage.w, srcImage.h, color, width, height); + } + + if (width == -1) + width = srcImage.w; + if (height == -1) + height = srcImage.h; + +#ifdef SCALING_TESTING + // Hardcode scaling to 66% to test scaling + width = width * 2 / 3; + height = height * 2 / 3; +#endif + + Graphics::Surface *img; + Graphics::Surface *imgScaled = NULL; + byte *savedPixels = NULL; + if ((width != srcImage.w) || (height != srcImage.h)) { + // Scale the image + img = imgScaled = srcImage.scale(width, height); + savedPixels = (byte *)img->pixels; + } else { + img = &srcImage; + } + + // Handle off-screen clipping + if (posY < 0) { + img->h = MAX(0, (int)img->h - -posY); + img->pixels = (byte *)img->pixels + img->pitch * -posY; + posY = 0; + } + + if (posX < 0) { + img->w = MAX(0, (int)img->w - -posX); + img->pixels = (byte *)img->pixels + (-posX * 4); + posX = 0; + } + + img->w = CLIP((int)img->w, 0, (int)MAX((int)target.w - posX, 0)); + img->h = CLIP((int)img->h, 0, (int)MAX((int)target.h - posY, 0)); + + if ((img->w > 0) && (img->h > 0)) { + int xp = 0, yp = 0; + + int inStep = 4; + int inoStep = img->pitch; + if (flipping & TransparentSurface::FLIP_V) { + inStep = -inStep; + xp = img->w - 1; + } + + if (flipping & TransparentSurface::FLIP_H) { + inoStep = -inoStep; + yp = img->h - 1; + } + + byte *ino = (byte *)img->getBasePtr(xp, yp); + byte *outo = (byte *)target.getBasePtr(posX, posY); + byte *in, *out; + +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 0; + const int bIndex = 1; + const int gIndex = 2; + const int rIndex = 3; +#else + const int aIndex = 3; + const int bIndex = 2; + const int gIndex = 1; + const int rIndex = 0; +#endif + + const int bShift = 8;//img->format.bShift; + const int gShift = 16;//img->format.gShift; + const int rShift = 24;//img->format.rShift; + const int aShift = 0;//img->format.aShift; + + const int bShiftTarget = 8;//target.format.bShift; + const int gShiftTarget = 16;//target.format.gShift; + const int rShiftTarget = 24;//target.format.rShift; + + if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { + doBlit(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } else { + for (int i = 0; i < img->h; i++) { + out = outo; + in = ino; + for (int j = 0; j < img->w; j++) { + uint32 pix = *(uint32 *)in; + uint32 o_pix = *(uint32 *) out; + int b = (pix >> bShift) & 0xff; + int g = (pix >> gShift) & 0xff; + int r = (pix >> rShift) & 0xff; + int a = (pix >> aShift) & 0xff; + int o_b, o_g, o_r, o_a; + in += inStep; + + if (ca != 255) { + a = a * ca >> 8; + } + + switch (a) { + case 0: // Full transparency + out += 4; + break; + case 255: // Full opacity + if (cb != 255) + o_b = (b * cb) >> 8; + else + o_b = b; + + if (cg != 255) + o_g = (g * cg) >> 8; + else + o_g = g; + + if (cr != 255) + o_r = (r * cr) >> 8; + else + o_r = r; + o_a = a; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; + out += 4; + break; + + default: // alpha blending + o_a = 255; + o_b = (o_pix >> bShiftTarget) & 0xff; + o_g = (o_pix >> gShiftTarget) & 0xff; + o_r = (o_pix >> rShiftTarget) & 0xff; + if (cb == 0) + o_b = 0; + else if (cb != 255) + o_b += ((b - o_b) * a * cb) >> 16; + else + o_b += ((b - o_b) * a) >> 8; + if (cg == 0) + o_g = 0; + else if (cg != 255) + o_g += ((g - o_g) * a * cg) >> 16; + else + o_g += ((g - o_g) * a) >> 8; + if (cr == 0) + o_r = 0; + else if (cr != 255) + o_r += ((r - o_r) * a * cr) >> 16; + else + o_r += ((r - o_r) * a) >> 8; + //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = o_a; + out[bIndex] = o_b; + out[gIndex] = o_g; + out[rIndex] = o_r; + out += 4; + } + } + outo += target.pitch; + ino += inoStep; + } + } + } + + if (imgScaled) { + imgScaled->pixels = savedPixels; + imgScaled->free(); + delete imgScaled; + } + + retSize.setWidth(img->w); + retSize.setHeight(img->h); + return retSize; +} + +/** + * Scales a passed surface, creating a new surface with the result + * @param srcImage Source image to scale + * @param scaleFactor Scale amount. Must be between 0 and 1.0 (but not zero) + * @remarks Caller is responsible for freeing the returned surface + */ +TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { + TransparentSurface *s = new TransparentSurface(); + s->create(xSize, ySize, this->format); + + int *horizUsage = scaleLine(xSize, this->w); + int *vertUsage = scaleLine(ySize, this->h); + + // Loop to create scaled version + for (int yp = 0; yp < ySize; ++yp) { + const byte *srcP = (const byte *)this->getBasePtr(0, vertUsage[yp]); + byte *destP = (byte *)s->getBasePtr(0, yp); + + for (int xp = 0; xp < xSize; ++xp) { + const byte *tempSrcP = srcP + (horizUsage[xp] * this->format.bytesPerPixel); + for (int byteCtr = 0; byteCtr < this->format.bytesPerPixel; ++byteCtr) { + *destP++ = *tempSrcP++; + } + } + } + + // Delete arrays and return surface + delete[] horizUsage; + delete[] vertUsage; + return s; +} + +/** + * Writes a color key to the alpha channel of the surface + * @param rKey the red component of the color key + * @param gKey the green component of the color key + * @param bKey the blue component of the color key + * @param overwriteAlpha if true, all other alpha will be set fully opaque + */ +void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) { + assert(format.bytesPerPixel == 4); + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + uint32 pix = ((uint32 *)pixels)[i * w + j]; + uint8 r, g, b, a; + format.colorToARGB(pix, a, r, g, b); + if (r == rKey && g == gKey && b == bKey) { + a = 0; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } else if (overwriteAlpha) { + a = 255; + ((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b); + } + } + } +} + +/** + * Returns an array indicating which pixels of a source image horizontally or vertically get + * included in a scaled image + */ +int *TransparentSurface::scaleLine(int size, int srcSize) { + int scale = 100 * size / srcSize; + assert(scale > 0); + int *v = new int[size]; + Common::fill(v, &v[size], 0); + + int distCtr = 0; + int *destP = v; + for (int distIndex = 0; distIndex < srcSize; ++distIndex) { + distCtr += scale; + while (distCtr >= 100) { + assert(destP < &v[size]); + *destP++ = distIndex; + distCtr -= 100; + } + } + + return v; +} + + +} // End of namespace Graphics diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h new file mode 100644 index 0000000000..e271bf2488 --- /dev/null +++ b/engines/wintermute/graphics/transparent_surface.h @@ -0,0 +1,124 @@ +/* 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. + */ + +#ifndef GRAPHICS_TRANSPARENTSURFACE_H +#define GRAPHICS_TRANSPARENTSURFACE_H + +#include "graphics/surface.h" + +/* + * This code is based on Broken Sword 2.5 engine + * + * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer + * + * Licensed under GNU GPL v2 + * + */ + +// TODO: Find a better solution for this. +#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B)) +#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B)) + +namespace WinterMute { + +/** + * A transparent graphics surface, which implements alpha blitting. + */ +struct TransparentSurface : public Graphics::Surface { + TransparentSurface(); + TransparentSurface(const Graphics::Surface &surf, bool copyData = false); + + void setColorKey(char r, char g, char b); + void disableColorKey(); + + // Enums + /** + @brief The possible flipping parameters for the blit methode. + */ + enum FLIP_FLAGS { + /// The image will not be flipped. + FLIP_NONE = 0, + /// The image will be flipped at the horizontal axis. + FLIP_H = 1, + /// The image will be flipped at the vertical axis. + FLIP_V = 2, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_HV = FLIP_H | FLIP_V, + /// The image will be flipped at the horizontal and vertical axis. + FLIP_VH = FLIP_H | FLIP_V + }; + + /** + @brief renders the surface to another surface + @param pDest a pointer to the target image. In most cases this is the framebuffer. + @param PosX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.
+ The default value is 0. + @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.
+ The default value is 0. + @param Flipping how the the image should be flipped.
+ The default value is BS_Image::FLIP_NONE (no flipping) + @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.
+ This referes to the unflipped and unscaled image.
+ The default value is NULL. + @param Color an ARGB color value, which determines the parameters for the color modulation und alpha blending.
+ The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).
+ The color components determines the color for color modulation.
+ The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation). + The macros BS_RGB and BS_ARGB can be used for the creation of the color value. + @param Width the output width of the screen section. + The images will be scaled if the output width of the screen section differs from the image section.
+ The value -1 determines that the image should not be scaled.
+ The default value is -1. + @param Width the output height of the screen section. + The images will be scaled if the output width of the screen section differs from the image section.
+ The value -1 determines that the image should not be scaled.
+ The default value is -1. + @return returns false if the rendering failed. + */ + + Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0, + int flipping = FLIP_NONE, + Common::Rect *pPartRect = NULL, + uint color = BS_ARGB(255, 255, 255, 255), + int width = -1, int height = -1); + void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); + TransparentSurface *scale(int xSize, int ySize) const; +private: + static int *scaleLine(int size, int srcSize); +}; + +/** + * A deleter for Surface objects which can be used with SharedPtr. + * + * This deleter assures Surface::free is called on deletion. + */ +/*struct SharedPtrTransparentSurfaceDeleter { + void operator()(TransparentSurface *ptr) { + ptr->free(); + delete ptr; + } +};*/ + + +} // End of namespace Graphics + + +#endif diff --git a/engines/wintermute/math/MathUtil.cpp b/engines/wintermute/math/MathUtil.cpp deleted file mode 100644 index 47b472d9cf..0000000000 --- a/engines/wintermute/math/MathUtil.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "MathUtil.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -float MathUtil::round(float val) { - float result = floor(val); - if (val - result >= 0.5) result += 1.0; - return result; -} - -////////////////////////////////////////////////////////////////////////// -float MathUtil::roundUp(float val) { - float result = floor(val); - if (val - result > 0) result += 1.0; - return result; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/MathUtil.h b/engines/wintermute/math/MathUtil.h deleted file mode 100644 index db814a59ac..0000000000 --- a/engines/wintermute/math/MathUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATHUTIL_H -#define WINTERMUTE_MATHUTIL_H - -namespace WinterMute { - -class MathUtil { -public: - static float round(float val); - static float roundUp(float val); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/Matrix4.cpp b/engines/wintermute/math/Matrix4.cpp deleted file mode 100644 index 557f0d5c9a..0000000000 --- a/engines/wintermute/math/Matrix4.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/math/Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Matrix4::Matrix4() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } -} - -////////////////////////////////////////////////////////////////////////// -Matrix4::~Matrix4() { -} - - -////////////////////////////////////////////////////////////////////////// -void Matrix4::identity() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } - m[0][0] = 1.0f; - m[1][1] = 1.0f; - m[2][2] = 1.0f; - m[3][3] = 1.0f; - -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::rotationZ(float angle) { - identity(); - - m[0][0] = cos(angle); - m[1][1] = cos(angle); - m[0][1] = sin(angle); - m[1][0] = -sin(angle); -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::transformVector2(Vector2 &vec) { - float norm; - - norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; - - float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; - float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; - - vec.x = x; - vec.y = y; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/Matrix4.h b/engines/wintermute/math/Matrix4.h deleted file mode 100644 index 5def8dfe97..0000000000 --- a/engines/wintermute/math/Matrix4.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATRIX4_H -#define WINTERMUTE_MATRIX4_H - -namespace WinterMute { - -class Vector2; - -class Matrix4 { -public: - Matrix4(); - ~Matrix4(); - - void identity(); - void rotationZ(float angle); - void transformVector2(Vector2 &vec); - - /* union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - };*/ - float m[4][4]; - //}; - -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/Rect32.h b/engines/wintermute/math/Rect32.h deleted file mode 100644 index e0babcbbb9..0000000000 --- a/engines/wintermute/math/Rect32.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef WINTERMUTE_RECT32_H -#define WINTERMUTE_RECT32_H - -#include "common/system.h" - -namespace WinterMute { - -struct Point32 { - int32 x; - int32 y; -}; - -struct Rect32 { - int32 top, left; ///< The point at the top left of the rectangle (part of the rect). - int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). - - Rect32() : top(0), left(0), bottom(0), right(0) {} - Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} - Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { - assert(isValidRect()); - } - bool operator==(const Rect32 &rhs) const { return equals(rhs); } - bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } - - int16 width() const { return right - left; } - int16 height() const { return bottom - top; } - - void setWidth(int16 aWidth) { - right = left + aWidth; - } - - void setHeight(int16 aHeight) { - bottom = top + aHeight; - } - - void setEmpty() { - left = right = top = bottom = 0; - } - - void offsetRect(int dx, int dy) { - left += dx; - top += dy; - right += dx; - bottom += dy; - } - /** - * Check if the given rect is equal to this one. - * - * @param r The rectangle to check - * - * @return true if the given rect is equal, false otherwise - */ - bool equals(const Rect32 &r) const { - return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); - } - - bool isValidRect() const { - return (left <= right && top <= bottom); - } -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/math/Vector2.cpp b/engines/wintermute/math/Vector2.cpp deleted file mode 100644 index 8bd10320a8..0000000000 --- a/engines/wintermute/math/Vector2.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2() { - x = y = 0.0f; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2(float xVal, float yVal) { - this->x = xVal; - this->y = yVal; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::~Vector2() { -} - - -////////////////////////////////////////////////////////////////////////// -float Vector2::length() const { - return (float)sqrt(x * x + y * y); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/Vector2.h b/engines/wintermute/math/Vector2.h deleted file mode 100644 index 96d3a3827d..0000000000 --- a/engines/wintermute/math/Vector2.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VECTOR2_H -#define WINTERMUTE_VECTOR2_H - -namespace WinterMute { - -class Vector2 { -public: - Vector2(); - Vector2(float x, float y); - ~Vector2(); - - float length() const; - - inline Vector2 &operator= (const Vector2 &other) { - x = other.x; - y = other.y; - - return *this; - } - - inline Vector2 operator+ (const Vector2 &other) const { - return Vector2(x + other.x, y + other.y); - } - - inline Vector2 operator- (const Vector2 &other) const { - return Vector2(x - other.x, y - other.y); - } - - inline Vector2 operator* (const float scalar) const { - return Vector2(x * scalar, y * scalar); - } - - inline Vector2 &operator+= (const Vector2 &other) { - x += other.x; - y += other.y; - - return *this; - } - - - float x; - float y; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp new file mode 100644 index 0000000000..d9449294fb --- /dev/null +++ b/engines/wintermute/math/math_util.cpp @@ -0,0 +1,48 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/math_util.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +float MathUtil::round(float val) { + float result = floor(val); + if (val - result >= 0.5) result += 1.0; + return result; +} + +////////////////////////////////////////////////////////////////////////// +float MathUtil::roundUp(float val) { + float result = floor(val); + if (val - result > 0) result += 1.0; + return result; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h new file mode 100644 index 0000000000..db814a59ac --- /dev/null +++ b/engines/wintermute/math/math_util.h @@ -0,0 +1,42 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATHUTIL_H +#define WINTERMUTE_MATHUTIL_H + +namespace WinterMute { + +class MathUtil { +public: + static float round(float val); + static float roundUp(float val); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp new file mode 100644 index 0000000000..a716e937f4 --- /dev/null +++ b/engines/wintermute/math/matrix4.cpp @@ -0,0 +1,86 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/matrix4.h" +#include "engines/wintermute/math/vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Matrix4::Matrix4() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } +} + +////////////////////////////////////////////////////////////////////////// +Matrix4::~Matrix4() { +} + + +////////////////////////////////////////////////////////////////////////// +void Matrix4::identity() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } + m[0][0] = 1.0f; + m[1][1] = 1.0f; + m[2][2] = 1.0f; + m[3][3] = 1.0f; + +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::rotationZ(float angle) { + identity(); + + m[0][0] = cos(angle); + m[1][1] = cos(angle); + m[0][1] = sin(angle); + m[1][0] = -sin(angle); +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::transformVector2(Vector2 &vec) { + float norm; + + norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; + + float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; + float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; + + vec.x = x; + vec.y = y; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h new file mode 100644 index 0000000000..5def8dfe97 --- /dev/null +++ b/engines/wintermute/math/matrix4.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATRIX4_H +#define WINTERMUTE_MATRIX4_H + +namespace WinterMute { + +class Vector2; + +class Matrix4 { +public: + Matrix4(); + ~Matrix4(); + + void identity(); + void rotationZ(float angle); + void transformVector2(Vector2 &vec); + + /* union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + };*/ + float m[4][4]; + //}; + +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h new file mode 100644 index 0000000000..e0babcbbb9 --- /dev/null +++ b/engines/wintermute/math/rect32.h @@ -0,0 +1,86 @@ +/* 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. + * + */ + +#ifndef WINTERMUTE_RECT32_H +#define WINTERMUTE_RECT32_H + +#include "common/system.h" + +namespace WinterMute { + +struct Point32 { + int32 x; + int32 y; +}; + +struct Rect32 { + int32 top, left; ///< The point at the top left of the rectangle (part of the rect). + int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). + + Rect32() : top(0), left(0), bottom(0), right(0) {} + Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} + Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { + assert(isValidRect()); + } + bool operator==(const Rect32 &rhs) const { return equals(rhs); } + bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } + + int16 width() const { return right - left; } + int16 height() const { return bottom - top; } + + void setWidth(int16 aWidth) { + right = left + aWidth; + } + + void setHeight(int16 aHeight) { + bottom = top + aHeight; + } + + void setEmpty() { + left = right = top = bottom = 0; + } + + void offsetRect(int dx, int dy) { + left += dx; + top += dy; + right += dx; + bottom += dy; + } + /** + * Check if the given rect is equal to this one. + * + * @param r The rectangle to check + * + * @return true if the given rect is equal, false otherwise + */ + bool equals(const Rect32 &r) const { + return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); + } + + bool isValidRect() const { + return (left <= right && top <= bottom); + } +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp new file mode 100644 index 0000000000..9906a59429 --- /dev/null +++ b/engines/wintermute/math/vector2.cpp @@ -0,0 +1,55 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2() { + x = y = 0.0f; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2(float xVal, float yVal) { + this->x = xVal; + this->y = yVal; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::~Vector2() { +} + + +////////////////////////////////////////////////////////////////////////// +float Vector2::length() const { + return (float)sqrt(x * x + y * y); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h new file mode 100644 index 0000000000..96d3a3827d --- /dev/null +++ b/engines/wintermute/math/vector2.h @@ -0,0 +1,75 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VECTOR2_H +#define WINTERMUTE_VECTOR2_H + +namespace WinterMute { + +class Vector2 { +public: + Vector2(); + Vector2(float x, float y); + ~Vector2(); + + float length() const; + + inline Vector2 &operator= (const Vector2 &other) { + x = other.x; + y = other.y; + + return *this; + } + + inline Vector2 operator+ (const Vector2 &other) const { + return Vector2(x + other.x, y + other.y); + } + + inline Vector2 operator- (const Vector2 &other) const { + return Vector2(x - other.x, y - other.y); + } + + inline Vector2 operator* (const float scalar) const { + return Vector2(x * scalar, y * scalar); + } + + inline Vector2 &operator+= (const Vector2 &other) { + x += other.x; + y += other.y; + + return *this; + } + + + float x; + float y; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 0063d072b1..3ad30cf66b 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -1,119 +1,119 @@ MODULE := engines/wintermute MODULE_OBJS := \ - ad/AdActor.o \ - ad/AdEntity.o \ - ad/AdGame.o \ - ad/AdInventory.o \ - ad/AdInventoryBox.o \ - ad/AdItem.o \ - ad/AdLayer.o \ - ad/AdNodeState.o \ - ad/AdObject.o \ - ad/AdPath.o \ - ad/AdPathPoint.o \ - ad/AdRegion.o \ - ad/AdResponse.o \ - ad/AdResponseBox.o \ - ad/AdResponseContext.o \ - ad/AdRotLevel.o \ - ad/AdScaleLevel.o \ - ad/AdScene.o \ - ad/AdSceneNode.o \ - ad/AdSceneState.o \ - ad/AdSentence.o \ - ad/AdSpriteSet.o \ - ad/AdTalkDef.o \ - ad/AdTalkHolder.o \ - ad/AdTalkNode.o \ - ad/AdWaypointGroup.o \ - base/scriptables/ScEngine.o \ - base/scriptables/ScScript.o \ - base/scriptables/ScStack.o \ - base/scriptables/ScValue.o \ - base/scriptables/SXArray.o \ - base/scriptables/SXDate.o \ - base/scriptables/SXFile.o \ - base/scriptables/SXMath.o \ - base/scriptables/SxObject.o \ - base/scriptables/SXMemBuffer.o \ - base/scriptables/SXString.o \ - base/file/BDiskFile.o \ - base/file/BFile.o \ - base/file/BFileEntry.o \ - base/file/BPackage.o \ - base/file/BSaveThumbFile.o \ + ad/ad_actor.o \ + ad/ad_entity.o \ + ad/ad_game.o \ + ad/ad_inventory.o \ + ad/ad_inventory_box.o \ + ad/ad_item.o \ + ad/ad_layer.o \ + ad/ad_node_state.o \ + ad/ad_object.o \ + ad/ad_path.o \ + ad/ad_path_point.o \ + ad/ad_region.o \ + ad/ad_response.o \ + ad/ad_response_box.o \ + ad/ad_response_context.o \ + ad/ad_rot_level.o \ + ad/ad_scale_level.o \ + ad/ad_scene.o \ + ad/ad_scene_node.o \ + ad/ad_scene_state.o \ + ad/ad_sentence.o \ + ad/ad_sprite_set.o \ + ad/ad_talk_def.o \ + ad/ad_talk_holder.o \ + ad/ad_talk_node.o \ + ad/ad_waypoint_group.o \ + base/scriptables/script.o \ + base/scriptables/script_engine.o \ + base/scriptables/script_stack.o \ + base/scriptables/script_value.o \ + base/scriptables/script_ext_array.o \ + base/scriptables/script_ext_date.o \ + base/scriptables/script_ext_file.o \ + base/scriptables/script_ext_math.o \ + base/scriptables/script_ext_object.o \ + base/scriptables/script_ext_mem_buffer.o \ + base/scriptables/script_ext_string.o \ + base/file/base_disk_file.o \ + base/file/base_file.o \ + base/file/base_file_entry.o \ + base/file/base_package.o \ + base/file/base_resources.o \ + base/file/base_save_thumb_file.o \ base/file/BPkgFile.o \ - base/font/BFontBitmap.o \ - base/font/BFontTT.o \ - base/font/BFont.o \ - base/font/BFontStorage.o \ + base/font/base_font_bitmap.o \ + base/font/base_font_truetype.o \ + base/font/base_font.o \ + base/font/base_font_storage.o \ base/gfx/base_image.o \ base/gfx/base_renderer.o \ base/gfx/base_surface.o \ base/gfx/osystem/base_surface_osystem.o \ base/gfx/osystem/base_render_osystem.o \ - base/particles/PartParticle.o \ - base/particles/PartEmitter.o \ - base/particles/PartForce.o \ - base/BActiveRect.o \ - base/BBase.o \ - base/BDebugger.o \ - base/BDynBuffer.o \ - base/BFader.o \ - base/BFileManager.o \ - base/BGame.o \ - base/BFrame.o \ - base/BKeyboardState.o \ - base/BNamedObject.o \ - base/BObject.o \ - base/BParser.o \ - base/BPersistMgr.o \ - base/BPoint.o \ - base/BQuickMsg.o \ - base/BRegion.o \ - base/BRegistry.o \ - base/BResources.o \ - base/BSaveThumbHelper.o \ - base/BScriptable.o \ - base/BScriptHolder.o \ - base/BSound.o \ - base/BSoundBuffer.o \ - base/BSoundMgr.o \ - base/BSprite.o \ - base/BStringTable.o \ - base/BSubFrame.o \ - base/BSurfaceStorage.o \ - base/BTransitionMgr.o \ - base/BViewport.o \ + base/particles/part_particle.o \ + base/particles/part_emitter.o \ + base/particles/part_force.o \ + base/sound/base_sound.o \ + base/sound/base_sound_buffer.o \ + base/sound/base_sound_manager.o \ + base/base_active_rect.o \ + base/base.o \ + base/base_debugger.o \ + base/base_dynamic_buffer.o \ + base/base_fader.o \ + base/base_file_manager.o \ + base/base_game.o \ + base/base_frame.o \ + base/base_keyboard_state.o \ + base/base_named_object.o \ + base/base_object.o \ + base/base_parser.o \ + base/base_persistence_manager.o \ + base/base_point.o \ + base/base_quick_msg.o \ + base/base_region.o \ + base/base_registry.o \ + base/base_save_thumb_helper.o \ + base/base_scriptable.o \ + base/base_script_holder.o \ + base/base_sprite.o \ + base/base_string_table.o \ + base/base_sub_frame.o \ + base/base_surface_storage.o \ + base/base_transition_manager.o \ + base/base_viewport.o \ detection.o \ - graphics/transparentSurface.o \ + graphics/transparent_surface.o \ graphics/tga.o \ - math/MathUtil.o \ - math/Matrix4.o \ - math/Vector2.o \ + math/math_util.o \ + math/matrix4.o \ + math/vector2.o \ platform_osystem.o \ - system/SysClass.o \ - system/SysClassRegistry.o \ - system/SysInstance.o \ + system/sys_class.o \ + system/sys_class_registry.o \ + system/sys_instance.o \ tinyxml/tinyxml.o \ tinyxml/tinystr.o \ tinyxml/tinyxmlparser.o \ tinyxml/tinyxmlerror.o \ - ui/UIButton.o \ - ui/UIEdit.o \ - ui/UIEntity.o \ - ui/UIObject.o \ - ui/UIText.o \ - ui/UITiledImage.o \ - ui/UIWindow.o \ - utils/ConvertUTF.o \ + ui/ui_button.o \ + ui/ui_edit.o \ + ui/ui_entity.o \ + ui/ui_object.o \ + ui/ui_text.o \ + ui/ui_tiled_image.o \ + ui/ui_window.o \ + utils/convert_utf.o \ utils/crc.o \ - utils/PathUtil.o \ - utils/StringUtil.o \ + utils/path_util.o \ + utils/string_util.o \ utils/utils.o \ - video/VidPlayer.o \ - video/VidTheoraPlayer.o \ + video/video_player.o \ + video/video_theora_player.o \ video/decoders/theora_decoder.o \ wintermute.o \ persistent.o diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 10c2132326..57997405de 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -26,67 +26,67 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/ad/AdActor.h" -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/ad/AdInventory.h" -#include "engines/wintermute/ad/AdInventoryBox.h" -#include "engines/wintermute/ad/AdItem.h" -#include "engines/wintermute/ad/AdLayer.h" -#include "engines/wintermute/ad/AdNodeState.h" -#include "engines/wintermute/ad/AdObject.h" -#include "engines/wintermute/ad/AdPath.h" -#include "engines/wintermute/ad/AdPathPoint.h" -#include "engines/wintermute/ad/AdRegion.h" -#include "engines/wintermute/ad/AdResponse.h" -#include "engines/wintermute/ad/AdResponseBox.h" -#include "engines/wintermute/ad/AdResponseContext.h" -#include "engines/wintermute/ad/AdRotLevel.h" -#include "engines/wintermute/ad/AdScaleLevel.h" -#include "engines/wintermute/ad/AdScene.h" -#include "engines/wintermute/ad/AdSceneNode.h" -#include "engines/wintermute/ad/AdSceneState.h" -#include "engines/wintermute/ad/AdSentence.h" -#include "engines/wintermute/ad/AdSpriteSet.h" -#include "engines/wintermute/ad/AdTalkDef.h" -#include "engines/wintermute/ad/AdTalkHolder.h" -#include "engines/wintermute/ad/AdTalkNode.h" -#include "engines/wintermute/ad/AdWaypointGroup.h" -#include "engines/wintermute/base/BFader.h" -#include "engines/wintermute/base/font/BFontBitmap.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFontTT.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/BScriptHolder.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/SXArray.h" -#include "engines/wintermute/base/scriptables/SXDate.h" -#include "engines/wintermute/base/scriptables/SXFile.h" -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/base/scriptables/SXMemBuffer.h" -#include "engines/wintermute/base/scriptables/SxObject.h" -#include "engines/wintermute/base/scriptables/SXString.h" -#include "engines/wintermute/ui/UIButton.h" -#include "engines/wintermute/ui/UIEdit.h" -#include "engines/wintermute/ui/UIEntity.h" -#include "engines/wintermute/ui/UIText.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/system/SysClass.h" +#include "engines/wintermute/ad/ad_actor.h" +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/ad/ad_inventory.h" +#include "engines/wintermute/ad/ad_inventory_box.h" +#include "engines/wintermute/ad/ad_item.h" +#include "engines/wintermute/ad/ad_layer.h" +#include "engines/wintermute/ad/ad_node_state.h" +#include "engines/wintermute/ad/ad_object.h" +#include "engines/wintermute/ad/ad_path.h" +#include "engines/wintermute/ad/ad_path_point.h" +#include "engines/wintermute/ad/ad_region.h" +#include "engines/wintermute/ad/ad_response.h" +#include "engines/wintermute/ad/ad_response_box.h" +#include "engines/wintermute/ad/ad_response_context.h" +#include "engines/wintermute/ad/ad_rot_level.h" +#include "engines/wintermute/ad/ad_scale_level.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/ad/ad_scene_node.h" +#include "engines/wintermute/ad/ad_scene_state.h" +#include "engines/wintermute/ad/ad_sentence.h" +#include "engines/wintermute/ad/ad_sprite_set.h" +#include "engines/wintermute/ad/ad_talk_def.h" +#include "engines/wintermute/ad/ad_talk_holder.h" +#include "engines/wintermute/ad/ad_talk_node.h" +#include "engines/wintermute/ad/ad_waypoint_group.h" +#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_Keyboard_state.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_point.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" +#include "engines/wintermute/base/scriptables/script_ext_date.h" +#include "engines/wintermute/base/scriptables/script_ext_file.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" +#include "engines/wintermute/base/scriptables/script_ext_object.h" +#include "engines/wintermute/base/scriptables/script_ext_string.h" +#include "engines/wintermute/ui/ui_button.h" +#include "engines/wintermute/ui/ui_edit.h" +#include "engines/wintermute/ui/ui_entity.h" +#include "engines/wintermute/ui/ui_text.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/system/sys_class.h" // CSysClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index a7d028b911..a5dac465b3 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -39,7 +39,7 @@ typedef bool(*PERSISTLOAD)(void *, CBPersistMgr *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute -#include "engines/wintermute/system/SysClassRegistry.h" +#include "engines/wintermute/system/sys_class_registry.h" namespace WinterMute { diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 82b53da723..2be73b7256 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -27,13 +27,13 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/scriptables/script_engine.h" #include "common/str.h" #include "common/textconsole.h" #include "common/system.h" diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index e0314898bf..50b07bccb8 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -30,7 +30,7 @@ #define WINTERMUTE_PLATFORMSDL_H #include "engines/wintermute/dctypes.h" -#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/math/rect32.h" #include "engines/wintermute/wintypes.h" #include "common/events.h" diff --git a/engines/wintermute/system/SysClass.cpp b/engines/wintermute/system/SysClass.cpp deleted file mode 100644 index 2d1066ab5a..0000000000 --- a/engines/wintermute/system/SysClass.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "SysInstance.h" -#include "SysClass.h" -#include "SysClassRegistry.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { - _name = name; - - _build = build; - _load = load; - _next = NULL; - _savedID = -1; - _persistent = persistent_class; - _numInst = 0; - - CSysClassRegistry::getInstance()->registerClass(this); -} - - -////////////////////////////////////////////////////////////////////////// -CSysClass::~CSysClass() { - CSysClassRegistry::getInstance()->unregisterClass(this); - removeAllInstances(); -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeAllInstances() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - delete(it->_value); - } - _instances.clear(); - _instanceMap.clear(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { - CSysInstance *inst = new CSysInstance(instance, id, this); - inst->setSavedID(savedId); - _instances[inst] = (inst); - - _instanceMap[instance] = inst; - - CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); - - return inst; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeInstance(void *instance) { - InstanceMap::iterator mapIt = _instanceMap.find(instance); - if (mapIt == _instanceMap.end()) return false; - - Instances::iterator it = _instances.find((mapIt->_value)); - if (it != _instances.end()) { - delete(it->_value); - _instances.erase(it); - } - - _instanceMap.erase(mapIt); - - return false; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::getInstanceID(void *pointer) { - InstanceMap::iterator mapIt = _instanceMap.find(pointer); - if (mapIt == _instanceMap.end()) return -1; - else return (mapIt->_value)->getID(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClass::idToPointer(int savedID) { - //slow - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); - } - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClass::getNumInstances() { - return _instances.size(); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::dump(Common::WriteStream *stream) { - Common::String str; - str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); - stream->write(str.c_str(), str.size()); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - persistMgr->putString(_name.c_str()); - persistMgr->putDWORD(_iD); - persistMgr->putDWORD(_instances.size()); - - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - persistMgr->putDWORD((it->_value)->getID()); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - _savedID = persistMgr->getDWORD(); - int numInstances = persistMgr->getDWORD(); - - for (int i = 0; i < numInstances; i++) { - int instID = persistMgr->getDWORD(); - if (_persistent) { - - if (i > 0) { - gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); - continue; - } - - Instances::iterator it = _instances.begin(); - if (it != _instances.end()) { - (it->_value)->setSavedID(instID); - CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); - } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); - } - // normal instances, create empty objects - else { - void *emptyObject = _build(); - if (!emptyObject) { - warning("HALT"); - } - - addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); - } - - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - // write instace header - persistMgr->putString(""); - persistMgr->putDWORD(_iD); - persistMgr->putDWORD((it->_value)->getID()); - persistMgr->putString(""); - _load((it->_value)->getInstance(), persistMgr); - persistMgr->putString(""); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { - _load(instance, persistMgr); -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClass::resetSavedIDs() { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - (it->_value)->setSavedID(-1); - } -} - -////////////////////////////////////////////////////////////////////////// -void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { - Instances::iterator it; - for (it = _instances.begin(); it != _instances.end(); ++it) { - lpCallback((it->_value)->getInstance(), lpData); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysClass.h b/engines/wintermute/system/SysClass.h deleted file mode 100644 index f807ea677c..0000000000 --- a/engines/wintermute/system/SysClass.h +++ /dev/null @@ -1,130 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASS_H -#define WINTERMUTE_SYSCLASS_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dctypes.h" -#include "common/hashmap.h" -#include "common/func.h" -#include "common/stream.h" - -namespace WinterMute { -class CSysInstance; -class CBGame; -class CBPersistMgr; -class CSysClass; - -} - -namespace Common { -template struct Hash; - -template<> struct Hash : public UnaryFunction { - uint operator()(void *val) const { - return (uint)((size_t)val); - } -}; - -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysInstance *val) const { - return (uint)((size_t)val); - } -}; - - -} - -namespace WinterMute { - -class CSysClass { -public: - CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); - ~CSysClass(); - - int getNumInstances(); - bool removeInstance(void *instance); - CSysInstance *addInstance(void *instance, int id, int savedId = -1); - bool removeAllInstances(); - - int getInstanceID(void *pointer); - void *idToPointer(int savedID); - - void setID(int id) { - _iD = id; - } - int getID() const { - return _iD; - } - - int getSavedID() const { - return _savedID; - } - - bool isPersistent() const { - return _persistent; - } - - AnsiString getName() const { - return _name; - } - - void saveTable(CBGame *Game, CBPersistMgr *PersistMgr); - void loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - - void saveInstances(CBGame *Game, CBPersistMgr *PersistMgr); - void loadInstance(void *instance, CBPersistMgr *PersistMgr); - - void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); - - void resetSavedIDs(); - - void dump(Common::WriteStream *stream); - -private: - int _numInst; - bool _persistent; - CSysClass *_next; - int _iD; - int _savedID; - AnsiString _name; - PERSISTBUILD _build; - PERSISTLOAD _load; - - //typedef std::set Instances; - typedef Common::HashMap Instances; - Instances _instances; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/system/SysClassRegistry.cpp b/engines/wintermute/system/SysClassRegistry.cpp deleted file mode 100644 index 3260fd3d5f..0000000000 --- a/engines/wintermute/system/SysClassRegistry.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "SysInstance.h" -#include "SysClassRegistry.h" -#include "engines/wintermute/system/SysClass.h" -#include "common/stream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::CSysClassRegistry() { - _count = 0; - _disabled = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::~CSysClassRegistry() { - unregisterClasses(); -} - -////////////////////////////////////////////////////////////////////////// -CSysClassRegistry *CSysClassRegistry::getInstance() { - return g_wintermute->getClassRegistry(); -} - -void CSysClassRegistry::unregisterClasses() { - // CSysClass calls UnregisterClass upon destruction. - while (_classes.size() > 0) { - delete _classes.begin()->_value; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerClass(CSysClass *classObj) { - classObj->setID(_count++); - //_classes.insert(classObj); - _classes[classObj] = classObj; - - _nameMap[classObj->getName()] = classObj; - _idMap[classObj->getID()] = classObj; - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { - - Classes::iterator it = _classes.find(classObj); - if (it == _classes.end()) return false; - - if (classObj->getNumInstances() != 0) { - char str[MAX_PATH_LENGTH]; - sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - CBPlatform::outputDebugString(str); - } - _classes.erase(it); - - NameMap::iterator mapIt = _nameMap.find(classObj->getName()); - if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); - - IdMap::iterator idIt = _idMap.find(classObj->getID()); - if (idIt != _idMap.end()) _idMap.erase(idIt); - - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerInstance(const char *className, void *instance) { - if (_disabled) return true; - - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - - CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); - return (inst != NULL); -} - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { - _instanceMap[pointer] = instance; - - if (instance->getSavedID() >= 0) - _savedInstanceMap[instance->getSavedID()] = instance; -} - -////////////////////////////////////////////////////////////////////////// -int CSysClassRegistry::getNextID() { - return _count++; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; - (*mapIt)._value->removeInstance(instance); - - InstanceMap::iterator instIt = _instanceMap.find(instance); - if (instIt != _instanceMap.end()) { - _instanceMap.erase(instIt); - return true; - } else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { - if (pointer == NULL) return true; - - InstanceMap::iterator it = _instanceMap.find(pointer); - if (it == _instanceMap.end()) return false; - - - CSysInstance *inst = (*it)._value; - *instanceID = inst->getID(); - *classID = inst->getClass()->getID(); - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void *CSysClassRegistry::idToPointer(int classID, int instanceID) { - SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); - if (it == _savedInstanceMap.end()) return NULL; - else return (*it)._value->getInstance(); -} - -bool checkHeader(const char *tag, CBPersistMgr *pm) { - char *test = pm->getString(); - Common::String verify = test; - delete[] test; - bool retVal = (verify == tag); - if (!retVal) { - error("Expected %s in Save-file not found", tag); - } - return retVal; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { - persistMgr->putString(""); - persistMgr->putDWORD(_classes.size()); - - int counter = 0; - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); - gameRef->displayContent(false); - gameRef->_renderer->flip(); - } - - (it->_value)->saveTable(gameRef, persistMgr); - } - persistMgr->putString(""); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { - checkHeader("", persistMgr); - - // reset SavedID of current instances - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - (it->_value)->resetSavedIDs(); - } - - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->isPersistent()) continue; - (it->_value)->removeAllInstances(); - } - - _instanceMap.clear(); - - uint32 numClasses = persistMgr->getDWORD(); - - for (uint32 i = 0; i < numClasses; i++) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); - - Common::String className = persistMgr->getStringObj(); - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); - } - - checkHeader("", persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { - - Classes::iterator it; - - // count total instances - int numInstances = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - numInstances += (it->_value)->getNumInstances(); - } - - persistMgr->putDWORD(numInstances); - - int counter = 0; - for (it = _classes.begin(); it != _classes.end(); ++it) { - counter++; - - if (!quickSave) { - if (counter % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); - gameRef->displayContent(false); - gameRef->_renderer->flip(); - } - } - gameRef->miniUpdate(); - - (it->_value)->saveInstances(gameRef, persistMgr); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { - // get total instances - int numInstances = persistMgr->getDWORD(); - - for (int i = 0; i < numInstances; i++) { - if (i % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); - } - - checkHeader("", persistMgr); - - int classID = persistMgr->getDWORD(); - int instanceID = persistMgr->getDWORD(); - void *instance = idToPointer(classID, instanceID); - - checkHeader("", persistMgr); - - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->getSavedID() == classID) { - (it->_value)->loadInstance(instance, persistMgr); - break; - } - } - checkHeader("", persistMgr); - } - - _savedInstanceMap.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { - NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return STATUS_FAILED; - - (*mapIt)._value->instanceCallback(lpCallback, lpData); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { - Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) - (it->_value)->dump(stream); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysClassRegistry.h b/engines/wintermute/system/SysClassRegistry.h deleted file mode 100644 index c9c4e8c072..0000000000 --- a/engines/wintermute/system/SysClassRegistry.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSCLASSREGISTRY_H -#define WINTERMUTE_SYSCLASSREGISTRY_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/system/SysClass.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/func.h" -#include "common/stream.h" - -namespace WinterMute { -class CSysClass; -} - -namespace Common { -template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysClass *val) const { - return (uint)((size_t)val); - } -}; - -} - -namespace WinterMute { - -class CBGame; -class CBPersistMgr; -class CSysInstance; - -class CSysClassRegistry { - void unregisterClasses(); -public: - void registerClasses(); // persistent.cpp - static CSysClassRegistry *getInstance(); - - CSysClassRegistry(); - virtual ~CSysClassRegistry(); - - bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); - bool loadTable(CBGame *Game, CBPersistMgr *PersistMgr); - bool saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - bool loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); - bool saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); - void *idToPointer(int classID, int instanceID); - bool getPointerID(void *pointer, int *classID, int *instanceID); - bool registerClass(CSysClass *classObj); - bool unregisterClass(CSysClass *classObj); - bool registerInstance(const char *className, void *instance); - bool unregisterInstance(const char *className, void *instance); - void dumpClasses(Common::WriteStream *stream); - int getNextID(); - void addInstanceToTable(CSysInstance *instance, void *pointer); - - bool _disabled; - int _count; - - typedef Common::HashMap Classes; - Classes _classes; - - typedef Common::HashMap NameMap; - NameMap _nameMap; - - typedef Common::HashMap IdMap; - IdMap _idMap; - - typedef Common::HashMap InstanceMap; - InstanceMap _instanceMap; - - typedef Common::HashMap SavedInstanceMap; - SavedInstanceMap _savedInstanceMap; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/system/SysInstance.cpp b/engines/wintermute/system/SysInstance.cpp deleted file mode 100644 index b7f6079912..0000000000 --- a/engines/wintermute/system/SysInstance.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SysInstance.h" -#include "SysClassRegistry.h" -#include "SysClass.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { - _instance = instance; - _id = id; - _savedID = -1; - _class = sysClass; - - _used = false; -} - -////////////////////////////////////////////////////////////////////////// -CSysInstance::~CSysInstance() { -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/system/SysInstance.h b/engines/wintermute/system/SysInstance.h deleted file mode 100644 index 6becd491af..0000000000 --- a/engines/wintermute/system/SysInstance.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SYSINSTANCE_H -#define WINTERMUTE_SYSINSTANCE_H - -namespace WinterMute { - -class CSysClass; - -class CSysInstance { -public: - CSysInstance(void *Instance, int ID, CSysClass *sysClass); - virtual ~CSysInstance(); - - int getID() const { - return _id; - } - int getSavedID() const { - return _savedID; - } - void *getInstance() const { - return _instance; - } - CSysClass *getClass() const { - return _class; - } - - void setSavedID(int id) { - _savedID = id; - } - -private: - bool _used; - int _id; - int _savedID; - void *_instance; - CSysClass *_class; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp new file mode 100644 index 0000000000..be70f8b8bd --- /dev/null +++ b/engines/wintermute/system/sys_class.cpp @@ -0,0 +1,211 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/system/sys_class.h" +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { + _name = name; + + _build = build; + _load = load; + _next = NULL; + _savedID = -1; + _persistent = persistent_class; + _numInst = 0; + + CSysClassRegistry::getInstance()->registerClass(this); +} + + +////////////////////////////////////////////////////////////////////////// +CSysClass::~CSysClass() { + CSysClassRegistry::getInstance()->unregisterClass(this); + removeAllInstances(); +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::removeAllInstances() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + delete(it->_value); + } + _instances.clear(); + _instanceMap.clear(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { + CSysInstance *inst = new CSysInstance(instance, id, this); + inst->setSavedID(savedId); + _instances[inst] = (inst); + + _instanceMap[instance] = inst; + + CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); + + return inst; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClass::removeInstance(void *instance) { + InstanceMap::iterator mapIt = _instanceMap.find(instance); + if (mapIt == _instanceMap.end()) return false; + + Instances::iterator it = _instances.find((mapIt->_value)); + if (it != _instances.end()) { + delete(it->_value); + _instances.erase(it); + } + + _instanceMap.erase(mapIt); + + return false; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::getInstanceID(void *pointer) { + InstanceMap::iterator mapIt = _instanceMap.find(pointer); + if (mapIt == _instanceMap.end()) return -1; + else return (mapIt->_value)->getID(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClass::idToPointer(int savedID) { + //slow + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClass::getNumInstances() { + return _instances.size(); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::dump(Common::WriteStream *stream) { + Common::String str; + str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); + stream->write(str.c_str(), str.size()); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + persistMgr->putString(_name.c_str()); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD(_instances.size()); + + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + persistMgr->putDWORD((it->_value)->getID()); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + _savedID = persistMgr->getDWORD(); + int numInstances = persistMgr->getDWORD(); + + for (int i = 0; i < numInstances; i++) { + int instID = persistMgr->getDWORD(); + if (_persistent) { + + if (i > 0) { + gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances); + continue; + } + + Instances::iterator it = _instances.begin(); + if (it != _instances.end()) { + (it->_value)->setSavedID(instID); + CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); + } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } + // normal instances, create empty objects + else { + void *emptyObject = _build(); + if (!emptyObject) { + warning("HALT"); + } + + addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); + } + + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + // write instace header + persistMgr->putString(""); + persistMgr->putDWORD(_iD); + persistMgr->putDWORD((it->_value)->getID()); + persistMgr->putString(""); + _load((it->_value)->getInstance(), persistMgr); + persistMgr->putString(""); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { + _load(instance, persistMgr); +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClass::resetSavedIDs() { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + (it->_value)->setSavedID(-1); + } +} + +////////////////////////////////////////////////////////////////////////// +void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { + Instances::iterator it; + for (it = _instances.begin(); it != _instances.end(); ++it) { + lpCallback((it->_value)->getInstance(), lpData); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/sys_class.h b/engines/wintermute/system/sys_class.h new file mode 100644 index 0000000000..f807ea677c --- /dev/null +++ b/engines/wintermute/system/sys_class.h @@ -0,0 +1,130 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASS_H +#define WINTERMUTE_SYSCLASS_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dctypes.h" +#include "common/hashmap.h" +#include "common/func.h" +#include "common/stream.h" + +namespace WinterMute { +class CSysInstance; +class CBGame; +class CBPersistMgr; +class CSysClass; + +} + +namespace Common { +template struct Hash; + +template<> struct Hash : public UnaryFunction { + uint operator()(void *val) const { + return (uint)((size_t)val); + } +}; + +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysInstance *val) const { + return (uint)((size_t)val); + } +}; + + +} + +namespace WinterMute { + +class CSysClass { +public: + CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); + ~CSysClass(); + + int getNumInstances(); + bool removeInstance(void *instance); + CSysInstance *addInstance(void *instance, int id, int savedId = -1); + bool removeAllInstances(); + + int getInstanceID(void *pointer); + void *idToPointer(int savedID); + + void setID(int id) { + _iD = id; + } + int getID() const { + return _iD; + } + + int getSavedID() const { + return _savedID; + } + + bool isPersistent() const { + return _persistent; + } + + AnsiString getName() const { + return _name; + } + + void saveTable(CBGame *Game, CBPersistMgr *PersistMgr); + void loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + + void saveInstances(CBGame *Game, CBPersistMgr *PersistMgr); + void loadInstance(void *instance, CBPersistMgr *PersistMgr); + + void instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData); + + void resetSavedIDs(); + + void dump(Common::WriteStream *stream); + +private: + int _numInst; + bool _persistent; + CSysClass *_next; + int _iD; + int _savedID; + AnsiString _name; + PERSISTBUILD _build; + PERSISTLOAD _load; + + //typedef std::set Instances; + typedef Common::HashMap Instances; + Instances _instances; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp new file mode 100644 index 0000000000..ce14b01385 --- /dev/null +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -0,0 +1,315 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/system/sys_class.h" +#include "common/stream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::CSysClassRegistry() { + _count = 0; + _disabled = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry::~CSysClassRegistry() { + unregisterClasses(); +} + +////////////////////////////////////////////////////////////////////////// +CSysClassRegistry *CSysClassRegistry::getInstance() { + return g_wintermute->getClassRegistry(); +} + +void CSysClassRegistry::unregisterClasses() { + // CSysClass calls UnregisterClass upon destruction. + while (_classes.size() > 0) { + delete _classes.begin()->_value; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::registerClass(CSysClass *classObj) { + classObj->setID(_count++); + //_classes.insert(classObj); + _classes[classObj] = classObj; + + _nameMap[classObj->getName()] = classObj; + _idMap[classObj->getID()] = classObj; + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { + + Classes::iterator it = _classes.find(classObj); + if (it == _classes.end()) return false; + + if (classObj->getNumInstances() != 0) { + char str[MAX_PATH_LENGTH]; + sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); + CBPlatform::outputDebugString(str); + } + _classes.erase(it); + + NameMap::iterator mapIt = _nameMap.find(classObj->getName()); + if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); + + IdMap::iterator idIt = _idMap.find(classObj->getID()); + if (idIt != _idMap.end()) _idMap.erase(idIt); + + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::registerInstance(const char *className, void *instance) { + if (_disabled) return true; + + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + + CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); + return (inst != NULL); +} + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { + _instanceMap[pointer] = instance; + + if (instance->getSavedID() >= 0) + _savedInstanceMap[instance->getSavedID()] = instance; +} + +////////////////////////////////////////////////////////////////////////// +int CSysClassRegistry::getNextID() { + return _count++; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return false; + (*mapIt)._value->removeInstance(instance); + + InstanceMap::iterator instIt = _instanceMap.find(instance); + if (instIt != _instanceMap.end()) { + _instanceMap.erase(instIt); + return true; + } else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { + if (pointer == NULL) return true; + + InstanceMap::iterator it = _instanceMap.find(pointer); + if (it == _instanceMap.end()) return false; + + + CSysInstance *inst = (*it)._value; + *instanceID = inst->getID(); + *classID = inst->getClass()->getID(); + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void *CSysClassRegistry::idToPointer(int classID, int instanceID) { + SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); + if (it == _savedInstanceMap.end()) return NULL; + else return (*it)._value->getInstance(); +} + +bool checkHeader(const char *tag, CBPersistMgr *pm) { + char *test = pm->getString(); + Common::String verify = test; + delete[] test; + bool retVal = (verify == tag); + if (!retVal) { + error("Expected %s in Save-file not found", tag); + } + return retVal; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { + persistMgr->putString(""); + persistMgr->putDWORD(_classes.size()); + + int counter = 0; + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); + } + + (it->_value)->saveTable(gameRef, persistMgr); + } + persistMgr->putString(""); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { + checkHeader("", persistMgr); + + // reset SavedID of current instances + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + (it->_value)->resetSavedIDs(); + } + + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->isPersistent()) continue; + (it->_value)->removeAllInstances(); + } + + _instanceMap.clear(); + + uint32 numClasses = persistMgr->getDWORD(); + + for (uint32 i = 0; i < numClasses; i++) { + gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); + + Common::String className = persistMgr->getStringObj(); + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); + } + + checkHeader("", persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { + + Classes::iterator it; + + // count total instances + int numInstances = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + numInstances += (it->_value)->getNumInstances(); + } + + persistMgr->putDWORD(numInstances); + + int counter = 0; + for (it = _classes.begin(); it != _classes.end(); ++it) { + counter++; + + if (!quickSave) { + if (counter % 20 == 0) { + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->displayContent(false); + gameRef->_renderer->flip(); + } + } + gameRef->miniUpdate(); + + (it->_value)->saveInstances(gameRef, persistMgr); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { + // get total instances + int numInstances = persistMgr->getDWORD(); + + for (int i = 0; i < numInstances; i++) { + if (i % 20 == 0) { + gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); + gameRef->displayContentSimple(); + gameRef->_renderer->flip(); + } + + checkHeader("", persistMgr); + + int classID = persistMgr->getDWORD(); + int instanceID = persistMgr->getDWORD(); + void *instance = idToPointer(classID, instanceID); + + checkHeader("", persistMgr); + + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) { + if ((it->_value)->getSavedID() == classID) { + (it->_value)->loadInstance(instance, persistMgr); + break; + } + } + checkHeader("", persistMgr); + } + + _savedInstanceMap.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { + NameMap::iterator mapIt = _nameMap.find(className); + if (mapIt == _nameMap.end()) return STATUS_FAILED; + + (*mapIt)._value->instanceCallback(lpCallback, lpData); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { + Classes::iterator it; + for (it = _classes.begin(); it != _classes.end(); ++it) + (it->_value)->dump(stream); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/sys_class_registry.h b/engines/wintermute/system/sys_class_registry.h new file mode 100644 index 0000000000..e17ae9bf78 --- /dev/null +++ b/engines/wintermute/system/sys_class_registry.h @@ -0,0 +1,107 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSCLASSREGISTRY_H +#define WINTERMUTE_SYSCLASSREGISTRY_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/system/sys_class.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/func.h" +#include "common/stream.h" + +namespace WinterMute { +class CSysClass; +} + +namespace Common { +template struct Hash; +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::CSysClass *val) const { + return (uint)((size_t)val); + } +}; + +} + +namespace WinterMute { + +class CBGame; +class CBPersistMgr; +class CSysInstance; + +class CSysClassRegistry { + void unregisterClasses(); +public: + void registerClasses(); // persistent.cpp + static CSysClassRegistry *getInstance(); + + CSysClassRegistry(); + virtual ~CSysClassRegistry(); + + bool enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData); + bool loadTable(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveTable(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + bool loadInstances(CBGame *Game, CBPersistMgr *PersistMgr); + bool saveInstances(CBGame *Game, CBPersistMgr *PersistMgr, bool quickSave); + void *idToPointer(int classID, int instanceID); + bool getPointerID(void *pointer, int *classID, int *instanceID); + bool registerClass(CSysClass *classObj); + bool unregisterClass(CSysClass *classObj); + bool registerInstance(const char *className, void *instance); + bool unregisterInstance(const char *className, void *instance); + void dumpClasses(Common::WriteStream *stream); + int getNextID(); + void addInstanceToTable(CSysInstance *instance, void *pointer); + + bool _disabled; + int _count; + + typedef Common::HashMap Classes; + Classes _classes; + + typedef Common::HashMap NameMap; + NameMap _nameMap; + + typedef Common::HashMap IdMap; + IdMap _idMap; + + typedef Common::HashMap InstanceMap; + InstanceMap _instanceMap; + + typedef Common::HashMap SavedInstanceMap; + SavedInstanceMap _savedInstanceMap; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/system/sys_instance.cpp b/engines/wintermute/system/sys_instance.cpp new file mode 100644 index 0000000000..c34c3cc64a --- /dev/null +++ b/engines/wintermute/system/sys_instance.cpp @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/system/sys_class.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { + _instance = instance; + _id = id; + _savedID = -1; + _class = sysClass; + + _used = false; +} + +////////////////////////////////////////////////////////////////////////// +CSysInstance::~CSysInstance() { +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/system/sys_instance.h b/engines/wintermute/system/sys_instance.h new file mode 100644 index 0000000000..6becd491af --- /dev/null +++ b/engines/wintermute/system/sys_instance.h @@ -0,0 +1,68 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SYSINSTANCE_H +#define WINTERMUTE_SYSINSTANCE_H + +namespace WinterMute { + +class CSysClass; + +class CSysInstance { +public: + CSysInstance(void *Instance, int ID, CSysClass *sysClass); + virtual ~CSysInstance(); + + int getID() const { + return _id; + } + int getSavedID() const { + return _savedID; + } + void *getInstance() const { + return _instance; + } + CSysClass *getClass() const { + return _class; + } + + void setSavedID(int id) { + _savedID = id; + } + +private: + bool _used; + int _id; + int _savedID; + void *_instance; + CSysClass *_class; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/UIButton.cpp b/engines/wintermute/ui/UIButton.cpp deleted file mode 100644 index 273f923376..0000000000 --- a/engines/wintermute/ui/UIButton.cpp +++ /dev/null @@ -1,1046 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/ui/UIButton.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIButton, false) - -////////////////////////////////////////////////////////////////////////// -CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { - _backPress = _backHover = _backDisable = _backFocus = NULL; - - _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; - - _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; - - _align = TAL_CENTER; - - _hover = _press = false; - - _type = UI_BUTTON; - - _canFocus = false; - _stayPressed = false; - - _oneTimePress = false; - _centerImage = false; - - _pixelPerfect = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIButton::~CUIButton() { - delete _backPress; - delete _backHover; - delete _backDisable; - delete _backFocus; - - if (!_sharedFonts) { - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - } - - if (!_sharedImages) { - delete _imageHover; - delete _imagePress; - delete _imageDisable; - delete _imageFocus; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(BUTTON) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(FOCUSABLE) -TOKEN_DEF(BACK_HOVER) -TOKEN_DEF(BACK_PRESS) -TOKEN_DEF(BACK_DISABLE) -TOKEN_DEF(BACK_FOCUS) -TOKEN_DEF(BACK) -TOKEN_DEF(CENTER_IMAGE) -TOKEN_DEF(IMAGE_HOVER) -TOKEN_DEF(IMAGE_PRESS) -TOKEN_DEF(IMAGE_DISABLE) -TOKEN_DEF(IMAGE_FOCUS) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_HOVER) -TOKEN_DEF(FONT_PRESS) -TOKEN_DEF(FONT_DISABLE) -TOKEN_DEF(FONT_FOCUS) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(EVENTS) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(PRESSED) -TOKEN_DEF(PIXEL_PERFECT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(FOCUSABLE) - TOKEN_TABLE(BACK_HOVER) - TOKEN_TABLE(BACK_PRESS) - TOKEN_TABLE(BACK_DISABLE) - TOKEN_TABLE(BACK_FOCUS) - TOKEN_TABLE(BACK) - TOKEN_TABLE(CENTER_IMAGE) - TOKEN_TABLE(IMAGE_HOVER) - TOKEN_TABLE(IMAGE_PRESS) - TOKEN_TABLE(IMAGE_DISABLE) - TOKEN_TABLE(IMAGE_FOCUS) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_HOVER) - TOKEN_TABLE(FONT_PRESS) - TOKEN_TABLE(FONT_DISABLE) - TOKEN_TABLE(FONT_FOCUS) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(PRESSED) - TOKEN_TABLE(PIXEL_PERFECT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { - _gameRef->LOG(0, "'BUTTON' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_HOVER: - delete _backHover; - _backHover = new CUITiledImage(_gameRef); - if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { - delete _backHover; - _backHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_PRESS: - delete _backPress; - _backPress = new CUITiledImage(_gameRef); - if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { - delete _backPress; - _backPress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_DISABLE: - delete _backDisable; - _backDisable = new CUITiledImage(_gameRef); - if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { - delete _backDisable; - _backDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_FOCUS: - delete _backFocus; - _backFocus = new CUITiledImage(_gameRef); - if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { - delete _backFocus; - _backFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_HOVER: - delete _imageHover; - _imageHover = new CBSprite(_gameRef); - if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { - delete _imageHover; - _imageHover = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_PRESS: - delete _imagePress; - _imagePress = new CBSprite(_gameRef); - if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { - delete _imagePress; - _imagePress = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_DISABLE: - delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); - if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { - delete _imageDisable; - _imageDisable = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_FOCUS: - delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); - if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { - delete _imageFocus; - _imageFocus = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_PRESS: - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - _fontPress = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontPress) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_DISABLE: - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - _fontDisable = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontDisable) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_FOCUS: - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - _fontFocus = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontFocus) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_CENTER; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_FOCUSABLE: - parser.scanStr((char *)params, "%b", &_canFocus); - break; - - case TOKEN_CENTER_IMAGE: - parser.scanStr((char *)params, "%b", &_centerImage); - break; - - case TOKEN_PRESSED: - parser.scanStr((char *)params, "%b", &_stayPressed); - break; - - case TOKEN_PIXEL_PERFECT: - parser.scanStr((char *)params, "%b", &_pixelPerfect); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in BUTTON definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading BUTTON definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "BUTTON\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backHover && _backHover->_filename) - buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); - if (_backPress && _backPress->_filename) - buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); - if (_backDisable && _backDisable->_filename) - buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); - if (_backFocus && _backFocus->_filename) - buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageHover && _imageHover->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); - if (_imagePress && _imagePress->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); - if (_imageDisable && _imageDisable->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); - if (_imageFocus && _imageFocus->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - if (_fontPress && _fontPress->_filename) - buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); - if (_fontDisable && _fontDisable->_filename) - buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); - if (_fontFocus && _fontFocus->_filename) - buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_align) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - warning("CUIButton::SaveAsText - unhandled enum"); - break; - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUIButton::correctSize() { - Rect32 rect; - - CBSprite *img = NULL; - if (_image) img = _image; - else if (_imageDisable) img = _imageDisable; - else if (_imageHover) img = _imageHover; - else if (_imagePress) img = _imagePress; - else if (_imageFocus) img = _imageFocus; - - if (_width <= 0) { - if (img) { - img->getBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (img) { - img->getBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_text) { - int text_height; - if (_font) text_height = _font->getTextHeight((byte *)_text, _width); - else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); - - if (text_height > _height) _height = text_height; - } - - if (_height <= 0) _height = 100; - - if (_back) _back->correctSize(&_width, &_height); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::display(int offsetX, int offsetY) { - if (!_visible) - return STATUS_OK; - - CUITiledImage *back = NULL; - CBSprite *image = NULL; - CBFont *font = 0; - - //RECT rect; - //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); - _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); - - if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); - - - if (_disable) { - if (_backDisable) back = _backDisable; - if (_imageDisable) image = _imageDisable; - if (_text && _fontDisable) font = _fontDisable; - } else if (_press || _oneTimePress || _stayPressed) { - if (_backPress) back = _backPress; - if (_imagePress) image = _imagePress; - if (_text && _fontPress) font = _fontPress; - } else if (_hover) { - if (_backHover) back = _backHover; - if (_imageHover) image = _imageHover; - if (_text && _fontHover) font = _fontHover; - } else if (_canFocus && isFocused()) { - if (_backFocus) back = _backFocus; - if (_imageFocus) image = _imageFocus; - if (_text && _fontFocus) font = _fontFocus; - } - - if (!back && _back) back = _back; - if (!image && _image) image = _image; - if (_text && !font) { - if (_font) font = _font; - else font = _gameRef->_systemFont; - } - - int imageX = offsetX + _posX; - int imageY = offsetY + _posY; - - if (image && _centerImage) { - Rect32 rc; - image->getBoundingRect(&rc, 0, 0); - imageX += (_width - (rc.right - rc.left)) / 2; - imageY += (_height - (rc.bottom - rc.top)) / 2; - } - - if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); - //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); - - if (font && _text) { - int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; - font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); - } - - if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - - // reset unused sprites - if (_image && _image != image) _image->reset(); - if (_imageDisable && _imageDisable != image) _imageDisable->reset(); - if (_imageFocus && _imageFocus != image) _imageFocus->reset(); - if (_imagePress && _imagePress != image) _imagePress->reset(); - if (_imageHover && _imageHover != image) _imageHover->reset(); - - _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIButton::press() { - applyEvent("Press"); - if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->applyEvent(_name); - - _oneTimePress = false; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetDisabledFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetDisabledFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (Val->isNULL()) { - _fontDisable = NULL; - stack->pushBool(true); - } else { - _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_fontDisable != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetHoverFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHoverFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - if (val->isNULL()) { - _fontHover = NULL; - stack->pushBool(true); - } else { - _fontHover = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontHover != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPressedFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (Val->isNULL()) { - _fontPress = NULL; - stack->pushBool(true); - } else { - _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_fontPress != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFocusedFont") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); - if (val->isNULL()) { - _fontFocus = NULL; - stack->pushBool(true); - } else { - _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); - stack->pushBool(_fontFocus != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDisabledImage") == 0) { - stack->correctParams(1); - - delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { - delete _imageDisable; - _imageDisable = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDisabledImage") == 0) { - stack->correctParams(0); - if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); - else stack->pushString(_imageDisable->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDisabledImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDisabledImageObject") == 0) { - stack->correctParams(0); - if (!_imageDisable) stack->pushNULL(); - else stack->pushNative(_imageDisable, true); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHoverImage") == 0) { - stack->correctParams(1); - - delete _imageHover; - _imageHover = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { - delete _imageHover; - _imageHover = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverImage") == 0) { - stack->correctParams(0); - if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); - else stack->pushString(_imageHover->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetHoverImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHoverImageObject") == 0) { - stack->correctParams(0); - if (!_imageHover) stack->pushNULL(); - else stack->pushNative(_imageHover, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPressedImage") == 0) { - stack->correctParams(1); - - delete _imagePress; - _imagePress = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { - delete _imagePress; - _imagePress = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPressedImage") == 0) { - stack->correctParams(0); - if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); - else stack->pushString(_imagePress->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPressedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPressedImageObject") == 0) { - stack->correctParams(0); - if (!_imagePress) stack->pushNULL(); - else stack->pushNative(_imagePress, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFocusedImage") == 0) { - stack->correctParams(1); - - delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { - delete _imageFocus; - _imageFocus = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFocusedImage") == 0) { - stack->correctParams(0); - if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); - else stack->pushString(_imageFocus->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFocusedImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFocusedImageObject") == 0) { - stack->correctParams(0); - if (!_imageFocus) stack->pushNULL(); - else stack->pushNative(_imageFocus, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Press - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Press") == 0) { - stack->correctParams(0); - - if (_visible && !_disable) { - _oneTimePress = true; - _oneTimePressTime = CBPlatform::getTime(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("button"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { - _scValue->setInt(_align); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focusable") == 0) { - _scValue->setBool(_canFocus); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pressed") == 0) { - _scValue->setBool(_stayPressed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_pixelPerfect); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "TextAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _align = (TTextAlign)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focusable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focusable") == 0) { - _canFocus = value->getBool(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Pressed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pressed") == 0) { - _stayPressed = value->getBool(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _pixelPerfect = value->getBool(); - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIButton::scToString() { - return "[button]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIButton::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER_INT(_align)); - persistMgr->transfer(TMEMBER(_backDisable)); - persistMgr->transfer(TMEMBER(_backFocus)); - persistMgr->transfer(TMEMBER(_backHover)); - persistMgr->transfer(TMEMBER(_backPress)); - persistMgr->transfer(TMEMBER(_centerImage)); - persistMgr->transfer(TMEMBER(_fontDisable)); - persistMgr->transfer(TMEMBER(_fontFocus)); - persistMgr->transfer(TMEMBER(_fontHover)); - persistMgr->transfer(TMEMBER(_fontPress)); - persistMgr->transfer(TMEMBER(_hover)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_imageDisable)); - persistMgr->transfer(TMEMBER(_imageFocus)); - persistMgr->transfer(TMEMBER(_imageHover)); - persistMgr->transfer(TMEMBER(_imagePress)); - persistMgr->transfer(TMEMBER(_pixelPerfect)); - persistMgr->transfer(TMEMBER(_press)); - persistMgr->transfer(TMEMBER(_stayPressed)); - - if (!persistMgr->_saving) { - _oneTimePress = false; - _oneTimePressTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIButton.h b/engines/wintermute/ui/UIButton.h deleted file mode 100644 index 5bdc075ebc..0000000000 --- a/engines/wintermute/ui/UIButton.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIBUTTON_H -#define WINTERMUTE_UIBUTTON_H - - -#include "UIObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUIButton : public CUIObject { -public: - bool _pixelPerfect; - bool _stayPressed; - bool _centerImage; - bool _oneTimePress; - uint32 _oneTimePressTime; - DECLARE_PERSISTENT(CUIButton, CUIObject) - void press(); - virtual bool display(int offsetX = 0, int offsetY = 0); - bool _press; - bool _hover; - void correctSize(); - TTextAlign _align; - CBSprite *_imageHover; - CBSprite *_imagePress; - CBSprite *_imageDisable; - CBSprite *_imageFocus; - CBFont *_fontDisable; - CBFont *_fontPress; - CBFont *_fontHover; - CBFont *_fontFocus; - CUITiledImage *_backPress; - CUITiledImage *_backHover; - CUITiledImage *_backDisable; - CUITiledImage *_backFocus; - CUIButton(CBGame *inGame = NULL); - virtual ~CUIButton(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UIEdit.cpp b/engines/wintermute/ui/UIEdit.cpp deleted file mode 100644 index 610853d8cb..0000000000 --- a/engines/wintermute/ui/UIEdit.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ui/UIEdit.h" -#include "engines/wintermute/ui/UIObject.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/utils/utils.h" -#include "common/util.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEdit, false) - -////////////////////////////////////////////////////////////////////////// -CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { - _type = UI_EDIT; - - _fontSelected = NULL; - - _selStart = _selEnd = 10000; - _scrollOffset = 0; - - _cursorChar = NULL; - setCursorChar("|"); - - _cursorBlinkRate = 600; - - _frameWidth = 0; - - setText(""); - - _lastBlinkTime = 0; - _cursorVisible = true; - - _maxLength = -1; - - _canFocus = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEdit::~CUIEdit() { - if (!_sharedFonts) { - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - } - - delete[] _cursorChar; - _cursorChar = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_SELECTED) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR_BLINK_RATE) -TOKEN_DEF(CURSOR) -TOKEN_DEF(FRAME_WIDTH) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MAX_LENGTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF(CAPTION) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_SELECTED) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR_BLINK_RATE) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(FRAME_WIDTH) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MAX_LENGTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { - _gameRef->LOG(0, "'EDIT' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_SELECTED: - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - _fontSelected = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontSelected) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_MAX_LENGTH: - parser.scanStr((char *)params, "%d", &_maxLength); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_CURSOR_BLINK_RATE: - parser.scanStr((char *)params, "%d", &_cursorBlinkRate); - break; - - case TOKEN_FRAME_WIDTH: - parser.scanStr((char *)params, "%d", &_frameWidth); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in EDIT definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading EDIT definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "EDIT\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontSelected && _fontSelected->_filename) - buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - buffer->putTextIndent(indent + 2, "MAX_LENGTH=%d\n", _maxLength); - buffer->putTextIndent(indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); - buffer->putTextIndent(indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSelectedFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSelectedFont") == 0) { - stack->correctParams(1); - - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); - _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontSelected != NULL); - - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("editor"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelStart") == 0) { - _scValue->setInt(_selStart); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { - _scValue->setInt(_selEnd); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { - _scValue->setInt(_cursorBlinkRate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorChar") == 0) { - _scValue->setString(_cursorChar); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FrameWidth") == 0) { - _scValue->setInt(_frameWidth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxLength") == 0) { - _scValue->setInt(_maxLength); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::ansiToWide(_text); - _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); - } else { - _scValue->setString(_text); - } - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // SelStart - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SelStart") == 0) { - _selStart = value->getInt(); - _selStart = MAX(_selStart, 0); - _selStart = MIN((size_t)_selStart, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SelEnd - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { - _selEnd = value->getInt(); - _selEnd = MAX(_selEnd, 0); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorBlinkRate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorChar - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorChar") == 0) { - setCursorChar(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FrameWidth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FrameWidth") == 0) { - _frameWidth = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxLength") == 0) { - _maxLength = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(value->getString()); - setText(StringUtil::wideToAnsi(wstr).c_str()); - } else { - setText(value->getString()); - } - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEdit::scToString() { - return "[edit]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIEdit::setCursorChar(const char *character) { - if (!character) return; - delete[] _cursorChar; - _cursorChar = new char [strlen(character) + 1]; - if (_cursorChar) strcpy(_cursorChar, character); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - - // hack! - TTextEncoding OrigEncoding = _gameRef->_textEncoding; - _gameRef->_textEncoding = TEXT_ANSI; - - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); - - // prepare fonts - CBFont *font; - CBFont *sfont; - - if (_font) font = _font; - else font = _gameRef->_systemFont; - - if (_fontSelected) sfont = _fontSelected; - else sfont = font; - - bool focused = isFocused(); - - _selStart = MAX(_selStart, 0); - _selEnd = MAX(_selEnd, 0); - - _selStart = MIN((size_t)_selStart, strlen(_text)); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); - - //int CursorWidth = font->GetCharWidth(_cursorChar[0]); - int cursorWidth = font->getTextWidth((byte *)_cursorChar); - - int s1, s2; - bool curFirst; - // modify scroll offset - if (_selStart >= _selEnd) { - while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selEnd; - s2 = _selStart; - curFirst = true; - } else { - while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + - sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) - - > _width - cursorWidth - 2 * _frameWidth) { - _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; - } - - _scrollOffset = MIN(_scrollOffset, _selEnd); - - s1 = _selStart; - s2 = _selEnd; - curFirst = false; - } - - - int AlignOffset = 0; - - for (int Count = 0; Count < 2; Count++) { - // draw text - int xxx, yyy, width, height; - - xxx = _posX + _frameWidth + offsetX; - yyy = _posY + _frameWidth + offsetY; - - width = _posX + _width + offsetX - _frameWidth; - height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); - - if (_gameRef->_textRTL) xxx += AlignOffset; - - TTextAlign Align = TAL_LEFT; - - - // unselected 1 - if (s1 > _scrollOffset) { - if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); - xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - } - - // cursor - if (focused && curFirst) { - if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += cursorWidth; - AlignOffset += cursorWidth; - } - - // selected - int s3 = MAX(s1, _scrollOffset); - - if (s2 - s3 > 0) { - if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); - xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); - } - - // cursor - if (focused && !curFirst) { - if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); - _cursorVisible = !_cursorVisible; - } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); - } - xxx += cursorWidth; - AlignOffset += cursorWidth; - } - - // unselected 2 - if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->getTextWidth((byte *)_text + s2); - - AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; - if (AlignOffset < 0) AlignOffset = 0; - } - - - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); - - - _gameRef->_textEncoding = OrigEncoding; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { - bool handled = false; - - if (event->type == Common::EVENT_KEYDOWN && !printable) { - switch (event->kbd.keycode) { - case Common::KEYCODE_ESCAPE: - case Common::KEYCODE_TAB: - case Common::KEYCODE_RETURN: - return false; - - // ctrl+A - case Common::KEYCODE_a: - if (CBKeyboardState::isControlDown()) { - _selStart = 0; - _selEnd = strlen(_text); - handled = true; - } - break; - - case Common::KEYCODE_BACKSPACE: - if (_selStart == _selEnd) { - if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); - else deleteChars(_selStart - 1, _selStart); - } else deleteChars(_selStart, _selEnd); - if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); - _selStart = _selEnd; - - handled = true; - break; - - case Common::KEYCODE_LEFT: - case Common::KEYCODE_UP: - _selEnd--; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - handled = true; - break; - - case Common::KEYCODE_RIGHT: - case Common::KEYCODE_DOWN: - _selEnd++; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - handled = true; - break; - - case Common::KEYCODE_HOME: - if (_gameRef->_textRTL) { - _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } else { - _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_END: - if (_gameRef->_textRTL) { - _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } else { - _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; - } - handled = true; - break; - - case Common::KEYCODE_DELETE: - if (_selStart == _selEnd) { - if (_gameRef->_textRTL) { - deleteChars(_selStart - 1, _selStart); - _selEnd--; - if (_selEnd < 0) _selEnd = 0; - } else deleteChars(_selStart, _selStart + 1); - } else deleteChars(_selStart, _selEnd); - if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); - - _selStart = _selEnd; - handled = true; - break; - default: - break; - } - return handled; - } else if (event->type == Common::EVENT_KEYDOWN && printable) { - if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); - - //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); - WideString wstr; - wstr += (char)event->kbd.ascii; - _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); - - if (_gameRef->_textRTL) _selEnd = _selStart; - else _selStart = _selEnd; - - return true; - } - - return false; -} - - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::deleteChars(int start, int end) { - if (start > end) CBUtils::swap(&start, &end); - - start = MAX(start, (int)0); - end = MIN((size_t)end, strlen(_text)); - - char *str = new char[strlen(_text) - (end - start) + 1]; - if (str) { - if (start > 0) memcpy(str, _text, start); - memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->applyEvent(_name); - - return end - start; -} - - -////////////////////////////////////////////////////////////////////////// -int CUIEdit::insertChars(int pos, byte *chars, int num) { - if ((int)strlen(_text) + num > _maxLength) { - num -= (strlen(_text) + num - _maxLength); - } - - pos = MAX(pos, (int)0); - pos = MIN((size_t)pos, strlen(_text)); - - char *str = new char[strlen(_text) + num + 1]; - if (str) { - if (pos > 0) memcpy(str, _text, pos); - memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); - - memcpy(str + pos, chars, num); - - delete[] _text; - _text = str; - } - if (_parentNotify && _parent) _parent->applyEvent(_name); - - return num; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIEdit::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_cursorBlinkRate)); - persistMgr->transfer(TMEMBER(_cursorChar)); - persistMgr->transfer(TMEMBER(_fontSelected)); - persistMgr->transfer(TMEMBER(_frameWidth)); - persistMgr->transfer(TMEMBER(_maxLength)); - persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_selEnd)); - persistMgr->transfer(TMEMBER(_selStart)); - - if (!persistMgr->_saving) { - _cursorVisible = false; - _lastBlinkTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIEdit.h b/engines/wintermute/ui/UIEdit.h deleted file mode 100644 index 7249301592..0000000000 --- a/engines/wintermute/ui/UIEdit.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIEDIT_H -#define WINTERMUTE_UIEDIT_H - -#include "engines/wintermute/persistent.h" -#include "UIObject.h" -#include "common/events.h" - -namespace WinterMute { -class CBFont; -class CUIEdit : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEdit, CUIObject) - int _maxLength; - int insertChars(int pos, byte *chars, int num); - int deleteChars(int start, int end); - bool _cursorVisible; - uint32 _lastBlinkTime; - virtual bool display(int offsetX, int offsetY); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - int _scrollOffset; - int _frameWidth; - uint32 _cursorBlinkRate; - void setCursorChar(const char *character); - char *_cursorChar; - int _selEnd; - int _selStart; - CBFont *_fontSelected; - CUIEdit(CBGame *inGame); - virtual ~CUIEdit(); - - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UIEntity.cpp b/engines/wintermute/ui/UIEntity.cpp deleted file mode 100644 index 7fbd2d13ff..0000000000 --- a/engines/wintermute/ui/UIEntity.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/AdEntity.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/ui/UIEntity.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIEntity, false) - -////////////////////////////////////////////////////////////////////////// -CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { - _type = UI_CUSTOM; - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CUIEntity::~CUIEntity() { - if (_entity) _gameRef->unregisterObject(_entity); - _entity = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(ENTITY_CONTAINER) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(NAME) -TOKEN_DEF(ENTITY) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(ENTITY_CONTAINER) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ENTITY) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { - _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_ENTITY: - if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition"); - return STATUS_FAILED; - } - - correctSize(); - - if (_gameRef->_editorMode) { - _width = 50; - _height = 50; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - - if (_entity && _entity->_filename) - buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::setEntity(const char *filename) { - if (_entity) _gameRef->unregisterObject(_entity); - _entity = new CAdEntity(_gameRef); - if (!_entity || DID_FAIL(_entity->loadFile(filename))) { - delete _entity; - _entity = NULL; - return STATUS_FAILED; - } else { - _entity->_nonIntMouseEvents = true; - _entity->_sceneIndependent = true; - _entity->makeFreezable(false); - _gameRef->registerObject(_entity); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - if (_entity) { - _entity->_posX = offsetX + _posX; - _entity->_posY = offsetY + _posY; - if (_entity->_scale < 0) _entity->_zoomable = false; - _entity->_shadowable = false; - - _entity->update(); - - bool origReg = _entity->_registrable; - - if (_entity->_registrable && _disable) _entity->_registrable = false; - - _entity->display(); - _entity->_registrable = origReg; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetEntity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetEntity") == 0) { - stack->correctParams(0); - - if (_entity) stack->pushNative(_entity, true); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetEntity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetEntity") == 0) { - stack->correctParams(1); - - const char *filename = stack->pop()->getString(); - - if (DID_SUCCEED(setEntity(filename))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("entity container"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Freezable") == 0) { - if (_entity) _scValue->setBool(_entity->_freezable); - else _scValue->setBool(false); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Freezable - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Freezable") == 0) { - if (_entity) _entity->makeFreezable(value->getBool()); - return STATUS_OK; - } else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIEntity::scToString() { - return "[entity container]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIEntity::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_entity)); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIEntity.h b/engines/wintermute/ui/UIEntity.h deleted file mode 100644 index b0711838a5..0000000000 --- a/engines/wintermute/ui/UIEntity.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIENTITY_H -#define WINTERMUTE_UIENTITY_H - -#include "UIObject.h" - -namespace WinterMute { -class CAdEntity; -class CUIEntity : public CUIObject { -public: - DECLARE_PERSISTENT(CUIEntity, CUIObject) - CUIEntity(CBGame *inGame); - virtual ~CUIEntity(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - virtual bool display(int offsetX = 0, int offsetY = 0); - CAdEntity *_entity; - bool setEntity(const char *filename); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UIObject.cpp b/engines/wintermute/ui/UIObject.cpp deleted file mode 100644 index 8b3dc19537..0000000000 --- a/engines/wintermute/ui/UIObject.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/ui/UIObject.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/font/BFontStorage.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIObject, false) - -////////////////////////////////////////////////////////////////////////// -CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { - _back = NULL; - _image = NULL; - _font = NULL; - _text = NULL; - _sharedFonts = _sharedImages = false; - - _width = _height = 0; - - _listenerObject = NULL; - _listenerParamObject = NULL; - _listenerParamDWORD = 0; - - _disable = false; - _visible = true; - - _type = UI_UNKNOWN; - _parent = NULL; - - _parentNotify = false; - - _focusedWidget = NULL; - - _canFocus = false; - _nonIntMouseEvents = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIObject::~CUIObject() { - if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); - - if (_back) delete _back; - if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); - - if (_image && !_sharedImages) delete _image; - - if (_text) delete [] _text; - - _focusedWidget = NULL; // ref only -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::setText(const char *text) { - if (_text) delete [] _text; - _text = new char [strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - for (int i = 0; i < strlen(_text); i++) { - if (_text[i] == '|') _text[i] = '\n'; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::display(int offsetX, int offsetY) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { - _listenerObject = object; - _listenerParamObject = listenerObject; - _listenerParamDWORD = listenerParam; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIObject::correctSize() { - Rect32 rect; - - if (_width <= 0) { - if (_image) { - _image->getBoundingRect(&rect, 0, 0); - _width = rect.right - rect.left; - } else _width = 100; - } - - if (_height <= 0) { - if (_image) { - _image->getBoundingRect(&rect, 0, 0); - _height = rect.bottom - rect.top; - } - } - - if (_back) _back->correctSize(&_width, &_height); -} - - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFont - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFont") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (Val->isNULL()) { - _font = NULL; - stack->pushBool(true); - } else { - _font = _gameRef->_fontStorage->addFont(Val->getString()); - stack->pushBool(_font != NULL); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - /* const char *filename = */ val->getString(); - - delete _image; - _image = NULL; - if (val->isNULL()) { - stack->pushBool(true); - return STATUS_OK; - } - - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { - delete _image; - _image = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - if (!_image || !_image->_filename) stack->pushNULL(); - else stack->pushString(_image->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetImageObject") == 0) { - stack->correctParams(0); - if (!_image) stack->pushNULL(); - else stack->pushNative(_image, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Focus - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focus") == 0) { - stack->correctParams(0); - focus(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveAfter / MoveBefore - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { - stack->correctParams(1); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - - int i; - bool found = false; - CScValue *val = stack->pop(); - // find directly - if (val->isNative()) { - CUIObject *widget = (CUIObject *)val->getNative(); - for (i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == widget) { - found = true; - break; - } - } - } - // find by name - else { - const char *findName = val->getString(); - for (i = 0; i < win->_widgets.getSize(); i++) { - if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { - found = true; - break; - } - } - } - - if (found) { - bool done = false; - for (int j = 0; j < win->_widgets.getSize(); j++) { - if (win->_widgets[j] == this) { - if (strcmp(name, "MoveAfter") == 0) i++; - if (j >= i) j++; - - win->_widgets.insertAt(i, this); - win->_widgets.removeAt(j); - - done = true; - stack->pushBool(true); - break; - } - } - if (!done) stack->pushBool(false); - } else stack->pushBool(false); - - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToBottom - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveToBottom") == 0) { - stack->correctParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); - win->_widgets.insertAt(0, this); - break; - } - } - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveToTop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveToTop") == 0) { - stack->correctParams(0); - - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); - win->_widgets.add(this); - break; - } - } - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("ui_object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Parent (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Parent") == 0) { - _scValue->setNative(_parent, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParentNotify") == 0) { - _scValue->setBool(_parentNotify); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Visible") == 0) { - _scValue->setBool(_visible); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Disabled") == 0) { - _scValue->setBool(_disable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - _scValue->setString(_text); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NextSibling (RO) / PrevSibling (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { - _scValue->setNULL(); - if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { - if (win->_widgets[i] == this) { - if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); - } else { - if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); - } - break; - } - } - } - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ParentNotify - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParentNotify") == 0) { - _parentNotify = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Visible - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Visible") == 0) { - _visible = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Disabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Disabled") == 0) { - _disable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Text - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { - setText(value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIObject::scToString() { - return "[ui_object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::isFocused() { - if (!_gameRef->_focusedWindow) return false; - if (_gameRef->_focusedWindow == this) return true; - - CUIObject *obj = _gameRef->_focusedWindow; - while (obj) { - if (obj == this) return true; - else obj = obj->_focusedWidget; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { - // handle focus change - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - focus(); - } - return CBObject::handleMouse(event, button); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::focus() { - CUIObject *obj = this; - bool disabled = false; - while (obj) { - if (obj->_disable && obj->_type == UI_WINDOW) { - disabled = true; - break; - } - obj = obj->_parent; - } - if (!disabled) { - obj = this; - while (obj) { - if (obj->_parent) { - if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; - } else { - if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); - } - - obj = obj->_parent; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { - int offX = 0, offY = 0; - - CUIObject *obj = _parent; - while (obj) { - offX += obj->_posX; - offY += obj->_posY; - - obj = obj->_parent; - } - if (offsetX) *offsetX = offX; - if (offsetY) *offsetY = offY; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_back)); - persistMgr->transfer(TMEMBER(_canFocus)); - persistMgr->transfer(TMEMBER(_disable)); - persistMgr->transfer(TMEMBER(_focusedWidget)); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_height)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_listenerObject)); - persistMgr->transfer(TMEMBER(_listenerParamObject)); - persistMgr->transfer(TMEMBER(_listenerParamDWORD)); - persistMgr->transfer(TMEMBER(_parent)); - persistMgr->transfer(TMEMBER(_parentNotify)); - persistMgr->transfer(TMEMBER(_sharedFonts)); - persistMgr->transfer(TMEMBER(_sharedImages)); - persistMgr->transfer(TMEMBER(_text)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_width)); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { - return STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIObject.h b/engines/wintermute/ui/UIObject.h deleted file mode 100644 index 26eecefe89..0000000000 --- a/engines/wintermute/ui/UIObject.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIOBJECT_H -#define WINTERMUTE_UIOBJECT_H - - -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView - -namespace WinterMute { - -class CUITiledImage; -class CBFont; -class CUIObject : public CBObject { -public: - - bool getTotalOffset(int *offsetX, int *offsetY); - bool _canFocus; - bool focus(); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - bool isFocused(); - bool _parentNotify; - DECLARE_PERSISTENT(CUIObject, CBObject) - CUIObject *_parent; - virtual bool display(int offsetX = 0, int offsetY = 0); - virtual void correctSize(); - bool _sharedFonts; - bool _sharedImages; - void setText(const char *text); - char *_text; - CBFont *_font; - bool _visible; - CUITiledImage *_back; - bool _disable; - CUIObject(CBGame *inGame = NULL); - virtual ~CUIObject(); - int _width; - int _height; - TUIObjectType _type; - CBSprite *_image; - void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); - CBScriptHolder *_listenerParamObject; - uint32 _listenerParamDWORD; - CBScriptHolder *_listenerObject; - CUIObject *_focusedWidget; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UIText.cpp b/engines/wintermute/ui/UIText.cpp deleted file mode 100644 index a496483f67..0000000000 --- a/engines/wintermute/ui/UIText.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/ui/UIText.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIText, false) - -////////////////////////////////////////////////////////////////////////// -CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { - _textAlign = TAL_LEFT; - _verticalAlign = VAL_CENTER; - _type = UI_STATIC; - _canFocus = false; -} - - -////////////////////////////////////////////////////////////////////////// -CUIText::~CUIText() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; - - - CBFont *font = _font; - if (!font) font = _gameRef->_systemFont; - - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); - - if (font && _text) { - int textOffset; - switch (_verticalAlign) { - case VAL_TOP: - textOffset = 0; - break; - case VAL_BOTTOM: - textOffset = _height - font->getTextHeight((byte *)_text, _width); - break; - default: - textOffset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; - } - font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); - } - - //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(STATIC) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT) -TOKEN_DEF(TEXT_ALIGN) -TOKEN_DEF(VERTICAL_ALIGN) -TOKEN_DEF(TEXT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIText::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TEXT_ALIGN) - TOKEN_TABLE(VERTICAL_ALIGN) - TOKEN_TABLE(TEXT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { - _gameRef->LOG(0, "'STATIC' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TEXT: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; - else _textAlign = TAL_CENTER; - break; - - case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; - else _verticalAlign = VAL_CENTER; - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in STATIC definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading STATIC definition"); - return STATUS_FAILED; - } - - correctSize(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "STATIC\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - if (_text) - buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); - - switch (_textAlign) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); - break; - default: - error("CUIText::SaveAsText - Unhandled enum"); - break; - } - - switch (_verticalAlign) { - case VAL_TOP: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); - break; - case VAL_BOTTOM: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); - break; - case VAL_CENTER: - buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SizeToFit - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SizeToFit") == 0) { - stack->correctParams(0); - sizeToFit(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HeightToFit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HeightToFit") == 0) { - stack->correctParams(0); - if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); - stack->pushNULL(); - return STATUS_OK; - } - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("static"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { - _scValue->setInt(_textAlign); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VerticalAlign") == 0) { - _scValue->setInt(_verticalAlign); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // TextAlign - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "TextAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; - _textAlign = (TTextAlign)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VerticalAlign - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VerticalAlign") == 0) { - int i = value->getInt(); - if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; - _verticalAlign = (TVerticalAlign)i; - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIText::scToString() { - return "[static]"; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - persistMgr->transfer(TMEMBER_INT(_textAlign)); - persistMgr->transfer(TMEMBER_INT(_verticalAlign)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIText::sizeToFit() { - if (_font && _text) { - _width = _font->getTextWidth((byte *)_text); - _height = _font->getTextHeight((byte *)_text, _width); - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIText.h b/engines/wintermute/ui/UIText.h deleted file mode 100644 index 62fbf00b0a..0000000000 --- a/engines/wintermute/ui/UIText.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITEXT_H -#define WINTERMUTE_UITEXT_H - - -#include "UIObject.h" - -namespace WinterMute { - -class CUIText : public CUIObject { -private: - bool sizeToFit(); -public: - virtual bool display(int offsetX, int offsetY); - DECLARE_PERSISTENT(CUIText, CUIObject) - CUIText(CBGame *inGame = NULL); - virtual ~CUIText(); - TTextAlign _textAlign; - TVerticalAlign _verticalAlign; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UITiledImage.cpp b/engines/wintermute/ui/UITiledImage.cpp deleted file mode 100644 index 04a2cfca58..0000000000 --- a/engines/wintermute/ui/UITiledImage.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUITiledImage, false) - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { - _image = NULL; - - CBPlatform::setRectEmpty(&_upLeft); - CBPlatform::setRectEmpty(&_upMiddle); - CBPlatform::setRectEmpty(&_upRight); - CBPlatform::setRectEmpty(&_middleLeft); - CBPlatform::setRectEmpty(&_middleMiddle); - CBPlatform::setRectEmpty(&_middleRight); - CBPlatform::setRectEmpty(&_downLeft); - CBPlatform::setRectEmpty(&_downMiddle); - CBPlatform::setRectEmpty(&_downRight); -} - - -////////////////////////////////////////////////////////////////////////// -CUITiledImage::~CUITiledImage() { - delete _image; - _image = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::display(int x, int y, int width, int height) { - if (!_image) return STATUS_FAILED; - - int tileWidth = _middleMiddle.right - _middleMiddle.left; - int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - - int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; - int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - - int col, row; - - _gameRef->_renderer->startSpriteBatch(); - - // top left/right - _image->_surface->displayTrans(x, y, _upLeft); - _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y, _upRight); - - // bottom left/right - _image->_surface->displayTrans(x, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downLeft); - _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); - - // left/right - int yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { - _image->_surface->displayTrans(x, yyy, _middleLeft); - _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); - yyy += tileWidth; - } - - // top/bottom - int xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, y, _upMiddle); - _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); - xxx += tileWidth; - } - - // tiles - yyy = y + (_upMiddle.bottom - _upMiddle.top); - for (row = 0; row < nuRows; row++) { - xxx = x + (_upLeft.right - _upLeft.left); - for (col = 0; col < nuColumns; col++) { - _image->_surface->displayTrans(xxx, yyy, _middleMiddle); - xxx += tileWidth; - } - yyy += tileWidth; - } - - _gameRef->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TILED_IMAGE) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(UP_LEFT) -TOKEN_DEF(UP_RIGHT) -TOKEN_DEF(UP_MIDDLE) -TOKEN_DEF(DOWN_LEFT) -TOKEN_DEF(DOWN_RIGHT) -TOKEN_DEF(DOWN_MIDDLE) -TOKEN_DEF(MIDDLE_LEFT) -TOKEN_DEF(MIDDLE_RIGHT) -TOKEN_DEF(MIDDLE_MIDDLE) -TOKEN_DEF(VERTICAL_TILES) -TOKEN_DEF(HORIZONTAL_TILES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TILED_IMAGE) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(UP_LEFT) - TOKEN_TABLE(UP_RIGHT) - TOKEN_TABLE(UP_MIDDLE) - TOKEN_TABLE(DOWN_LEFT) - TOKEN_TABLE(DOWN_RIGHT) - TOKEN_TABLE(DOWN_MIDDLE) - TOKEN_TABLE(MIDDLE_LEFT) - TOKEN_TABLE(MIDDLE_RIGHT) - TOKEN_TABLE(MIDDLE_MIDDLE) - TOKEN_TABLE(VERTICAL_TILES) - TOKEN_TABLE(HORIZONTAL_TILES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - bool hTiles = false, vTiles = false; - int h1 = 0, h2 = 0, h3 = 0; - int v1 = 0, v2 = 0, v3 = 0; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { - _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSubFrame(_gameRef); - if (!_image || DID_FAIL(_image->setSurface((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_UP_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); - break; - - case TOKEN_UP_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); - break; - - case TOKEN_UP_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); - break; - - case TOKEN_DOWN_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); - break; - - case TOKEN_DOWN_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); - break; - - case TOKEN_DOWN_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); - break; - - case TOKEN_MIDDLE_LEFT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); - break; - - case TOKEN_MIDDLE_RIGHT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); - break; - - case TOKEN_MIDDLE_MIDDLE: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); - break; - - case TOKEN_HORIZONTAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); - hTiles = true; - break; - - case TOKEN_VERTICAL_TILES: - parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); - vTiles = true; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading TILED_IMAGE definition"); - return STATUS_FAILED; - } - - if (vTiles && hTiles) { - // up row - CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); - CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); - CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); - - // middle row - CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); - CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); - CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); - - // down row - CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); - CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); - CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); - } - - // default - if (_image && _image->_surface) { - int width = _image->_surface->getWidth() / 3; - int height = _image->_surface->getHeight() / 3; - - if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); - if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); - if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); - - if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); - - if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); - if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); - if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "TILED_IMAGE\n"); - buffer->putTextIndent(indent, "{\n"); - - if (_image && _image->_surfaceFilename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); - - int h1, h2, h3; - int v1, v2, v3; - - h1 = _upLeft.right; - h2 = _upMiddle.right - _upMiddle.left; - h3 = _upRight.right - _upRight.left; - - v1 = _upLeft.bottom; - v2 = _middleLeft.bottom - _middleLeft.top; - v3 = _downLeft.bottom - _downLeft.top; - - - buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", v1, v2, v3); - buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CUITiledImage::correctSize(int *width, int *height) { - int tileWidth = _middleMiddle.right - _middleMiddle.left; - int tileHeight = _middleMiddle.bottom - _middleMiddle.top; - - int nuColumns = (*width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; - int nuRows = (*height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; - - *width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nuColumns * tileWidth; - *height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nuRows * tileHeight; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_downLeft)); - persistMgr->transfer(TMEMBER(_downMiddle)); - persistMgr->transfer(TMEMBER(_downRight)); - persistMgr->transfer(TMEMBER(_image)); - persistMgr->transfer(TMEMBER(_middleLeft)); - persistMgr->transfer(TMEMBER(_middleMiddle)); - persistMgr->transfer(TMEMBER(_middleRight)); - persistMgr->transfer(TMEMBER(_upLeft)); - persistMgr->transfer(TMEMBER(_upMiddle)); - persistMgr->transfer(TMEMBER(_upRight)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UITiledImage.h b/engines/wintermute/ui/UITiledImage.h deleted file mode 100644 index 379af85e81..0000000000 --- a/engines/wintermute/ui/UITiledImage.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UITILEDIMAGE_H -#define WINTERMUTE_UITILEDIMAGE_H - - -#include "UIObject.h" -#include "common/rect.h" - -namespace WinterMute { -class CBSubFrame; -class CUITiledImage : public CBObject { -public: - DECLARE_PERSISTENT(CUITiledImage, CBObject) - void correctSize(int *width, int *height); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - bool display(int x, int y, int width, int height); - CUITiledImage(CBGame *inGame = NULL); - virtual ~CUITiledImage(); - CBSubFrame *_image; - Rect32 _upLeft; - Rect32 _upMiddle; - Rect32 _upRight; - Rect32 _middleLeft; - Rect32 _middleMiddle; - Rect32 _middleRight; - Rect32 _downLeft; - Rect32 _downMiddle; - Rect32 _downRight; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/UIWindow.cpp b/engines/wintermute/ui/UIWindow.cpp deleted file mode 100644 index 35330e720e..0000000000 --- a/engines/wintermute/ui/UIWindow.cpp +++ /dev/null @@ -1,1327 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/ui/UIButton.h" -#include "engines/wintermute/ui/UIEdit.h" -#include "engines/wintermute/ui/UIText.h" -#include "engines/wintermute/ui/UITiledImage.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CUIWindow, false) - -////////////////////////////////////////////////////////////////////////// -CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::setRectEmpty(&_titleRect); - CBPlatform::setRectEmpty(&_dragRect); - _titleAlign = TAL_LEFT; - _transparent = false; - - _backInactive = NULL; - _fontInactive = NULL; - _imageInactive = NULL; - - _type = UI_WINDOW; - _canFocus = true; - - _dragging = false; - _dragFrom.x = _dragFrom.y = 0; - - _mode = WINDOW_NORMAL; - _shieldWindow = NULL; - _shieldButton = NULL; - - _fadeColor = 0x00000000; - _fadeBackground = false; - - _ready = true; - _isMenu = false; - _inGame = false; - - _clipContents = false; - _viewport = NULL; - - _pauseMusic = true; -} - - -////////////////////////////////////////////////////////////////////////// -CUIWindow::~CUIWindow() { - close(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::cleanup() { - delete _shieldWindow; - delete _shieldButton; - delete _viewport; - _shieldWindow = NULL; - _shieldButton = NULL; - _viewport = NULL; - - delete _backInactive; - if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - if (!_sharedImages && _imageInactive) delete _imageInactive; - - for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; - _widgets.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::display(int offsetX, int offsetY) { - // go exclusive - if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); - if (_shieldWindow) { - _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; - - _shieldWindow->display(); - } - } else if (_isMenu) { - if (!_shieldButton) { - _shieldButton = new CUIButton(_gameRef); - _shieldButton->setName("close"); - _shieldButton->setListener(this, _shieldButton, 0); - _shieldButton->_parent = this; - } - if (_shieldButton) { - _shieldButton->_posX = _shieldButton->_posY = 0; - _shieldButton->_width = _gameRef->_renderer->_width; - _shieldButton->_height = _gameRef->_renderer->_height; - - _shieldButton->display(); - } - } - - if (!_visible) - return STATUS_OK; - - if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); - - if (_dragging) { - _posX += (_gameRef->_mousePos.x - _dragFrom.x); - _posY += (_gameRef->_mousePos.y - _dragFrom.y); - - _dragFrom.x = _gameRef->_mousePos.x; - _dragFrom.y = _gameRef->_mousePos.y; - } - - if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { - moveFocus(); - } - - bool popViewport = false; - if (_clipContents) { - if (!_viewport) _viewport = new CBViewport(_gameRef); - if (_viewport) { - _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); - _gameRef->pushViewport(_viewport); - popViewport = true; - } - } - - - CUITiledImage *back = _back; - CBSprite *image = _image; - CBFont *font = _font; - - if (!isFocused()) { - if (_backInactive) back = _backInactive; - if (_imageInactive) image = _imageInactive; - if (_fontInactive) font = _fontInactive; - } - - if (_alphaColor != 0) - _gameRef->_renderer->_forceAlphaColor = _alphaColor; - if (back) - back->display(_posX + offsetX, _posY + offsetY, _width, _height); - if (image) - image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); - - if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { - font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); - } - - if (!_transparent && !image) - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); - - for (int i = 0; i < _widgets.getSize(); i++) { - _widgets[i]->display(_posX + offsetX, _posY + offsetY); - } - - if (_alphaColor != 0) - _gameRef->_renderer->_forceAlphaColor = 0; - - if (popViewport) - _gameRef->popViewport(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(WINDOW) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(DISABLED) -TOKEN_DEF(VISIBLE) -TOKEN_DEF(BACK_INACTIVE) -TOKEN_DEF(BACK) -TOKEN_DEF(IMAGE_INACTIVE) -TOKEN_DEF(IMAGE) -TOKEN_DEF(FONT_INACTIVE) -TOKEN_DEF(FONT) -TOKEN_DEF(TITLE_ALIGN) -TOKEN_DEF(TITLE_RECT) -TOKEN_DEF(TITLE) -TOKEN_DEF(DRAG_RECT) -TOKEN_DEF(X) -TOKEN_DEF(Y) -TOKEN_DEF(WIDTH) -TOKEN_DEF(HEIGHT) -TOKEN_DEF(FADE_ALPHA) -TOKEN_DEF(FADE_COLOR) -TOKEN_DEF(CURSOR) -TOKEN_DEF(NAME) -TOKEN_DEF(BUTTON) -TOKEN_DEF(STATIC) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PARENT_NOTIFY) -TOKEN_DEF(MENU) -TOKEN_DEF(IN_GAME) -TOKEN_DEF(CLIP_CONTENTS) -TOKEN_DEF(PAUSE_MUSIC) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(EDIT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(WINDOW) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(DISABLED) - TOKEN_TABLE(VISIBLE) - TOKEN_TABLE(BACK_INACTIVE) - TOKEN_TABLE(BACK) - TOKEN_TABLE(IMAGE_INACTIVE) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(FONT_INACTIVE) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TITLE_ALIGN) - TOKEN_TABLE(TITLE_RECT) - TOKEN_TABLE(TITLE) - TOKEN_TABLE(DRAG_RECT) - TOKEN_TABLE(X) - TOKEN_TABLE(Y) - TOKEN_TABLE(WIDTH) - TOKEN_TABLE(HEIGHT) - TOKEN_TABLE(FADE_ALPHA) - TOKEN_TABLE(FADE_COLOR) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(NAME) - TOKEN_TABLE(BUTTON) - TOKEN_TABLE(STATIC) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PARENT_NOTIFY) - TOKEN_TABLE(MENU) - TOKEN_TABLE(IN_GAME) - TOKEN_TABLE(CLIP_CONTENTS) - TOKEN_TABLE(PAUSE_MUSIC) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(EDIT) - TOKEN_TABLE_END - - byte *params; - int cmd = 2; - CBParser parser(_gameRef); - - int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; - int ar = 0, ag = 0, ab = 0, alpha = 0; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { - _gameRef->LOG(0, "'WINDOW' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_BACK: - delete _back; - _back = new CUITiledImage(_gameRef); - if (!_back || DID_FAIL(_back->loadFile((char *)params))) { - delete _back; - _back = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BACK_INACTIVE: - delete _backInactive; - _backInactive = new CUITiledImage(_gameRef); - if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { - delete _backInactive; - _backInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE: - delete _image; - _image = new CBSprite(_gameRef); - if (!_image || DID_FAIL(_image->loadFile((char *)params))) { - delete _image; - _image = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_IMAGE_INACTIVE: - delete _imageInactive, - _imageInactive = new CBSprite(_gameRef); - if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { - delete _imageInactive; - _imageInactive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); - _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; - break; - - case TOKEN_FONT_INACTIVE: - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - _fontInactive = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontInactive) cmd = PARSERR_GENERIC; - break; - - case TOKEN_TITLE: - setText((char *)params); - _gameRef->_stringTable->expand(&_text); - break; - - case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; - else _titleAlign = TAL_CENTER; - break; - - case TOKEN_TITLE_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); - break; - - case TOKEN_DRAG_RECT: - parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); - break; - - case TOKEN_X: - parser.scanStr((char *)params, "%d", &_posX); - break; - - case TOKEN_Y: - parser.scanStr((char *)params, "%d", &_posY); - break; - - case TOKEN_WIDTH: - parser.scanStr((char *)params, "%d", &_width); - break; - - case TOKEN_HEIGHT: - parser.scanStr((char *)params, "%d", &_height); - break; - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_BUTTON: { - CUIButton *btn = new CUIButton(_gameRef); - if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { - delete btn; - btn = NULL; - cmd = PARSERR_GENERIC; - } else { - btn->_parent = this; - _widgets.add(btn); - } - } - break; - - case TOKEN_STATIC: { - CUIText *text = new CUIText(_gameRef); - if (!text || DID_FAIL(text->loadBuffer(params, false))) { - delete text; - text = NULL; - cmd = PARSERR_GENERIC; - } else { - text->_parent = this; - _widgets.add(text); - } - } - break; - - case TOKEN_EDIT: { - CUIEdit *edit = new CUIEdit(_gameRef); - if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { - delete edit; - edit = NULL; - cmd = PARSERR_GENERIC; - } else { - edit->_parent = this; - _widgets.add(edit); - } - } - break; - - case TOKEN_WINDOW: { - CUIWindow *win = new CUIWindow(_gameRef); - if (!win || DID_FAIL(win->loadBuffer(params, false))) { - delete win; - win = NULL; - cmd = PARSERR_GENERIC; - } else { - win->_parent = this; - _widgets.add(win); - } - } - break; - - - case TOKEN_TRANSPARENT: - parser.scanStr((char *)params, "%b", &_transparent); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PARENT_NOTIFY: - parser.scanStr((char *)params, "%b", &_parentNotify); - break; - - case TOKEN_PAUSE_MUSIC: - parser.scanStr((char *)params, "%b", &_pauseMusic); - break; - - case TOKEN_DISABLED: - parser.scanStr((char *)params, "%b", &_disable); - break; - - case TOKEN_VISIBLE: - parser.scanStr((char *)params, "%b", &_visible); - break; - - case TOKEN_MENU: - parser.scanStr((char *)params, "%b", &_isMenu); - break; - - case TOKEN_IN_GAME: - parser.scanStr((char *)params, "%b", &_inGame); - break; - - case TOKEN_CLIP_CONTENTS: - parser.scanStr((char *)params, "%b", &_clipContents); - break; - - case TOKEN_FADE_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); - _fadeBackground = true; - break; - - case TOKEN_FADE_ALPHA: - parser.scanStr((char *)params, "%d", &fadeA); - _fadeBackground = true; - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr((char *)params, "%d", &alpha); - break; - - - default: - if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { - cmd = PARSERR_GENERIC; - } - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in WINDOW definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading WINDOW definition"); - return STATUS_FAILED; - } - - correctSize(); - - if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { - ar = ag = ab = 255; - } - _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - - if (_fadeBackground) - _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); - - _focusedWidget = NULL; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "WINDOW\n"); - buffer->putTextIndent(indent, "{\n"); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backInactive && _backInactive->_filename) - buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageInactive && _imageInactive->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontInactive && _fontInactive->_filename) - buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_text) - buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); - - switch (_titleAlign) { - case TAL_LEFT: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); - break; - case TAL_RIGHT: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); - break; - case TAL_CENTER: - buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); - break; - default: - error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); - } - - if (!CBPlatform::isRectEmpty(&_titleRect)) { - buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); - } - - if (!CBPlatform::isRectEmpty(&_dragRect)) { - buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); - } - - buffer->putTextIndent(indent + 2, "\n"); - - buffer->putTextIndent(indent + 2, "X=%d\n", _posX); - buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); - buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); - buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); - - buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); - - buffer->putTextIndent(indent + 2, "\n"); - - if (_fadeBackground) { - buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); - buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", RGBCOLGetA(_fadeColor)); - } - - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); - buffer->putTextIndent(indent + 2, "ALPHA=%d\n", RGBCOLGetA(_alphaColor)); - - buffer->putTextIndent(indent + 2, "\n"); - - // scripts - for (int i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - buffer->putTextIndent(indent + 2, "\n"); - - // editor properties - CBBase::saveAsText(buffer, indent + 2); - - // controls - for (int i = 0; i < _widgets.getSize(); i++) - _widgets[i]->saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n"); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::enableWidget(const char *name, bool Enable) { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::showWidget(const char *name, bool Visible) { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetWidget / GetControl - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->getType() == VAL_INT) { - int widget = val->getInt(); - if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); - else stack->pushNative(_widgets[widget], true); - } else { - for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { - stack->pushNative(_widgets[i], true); - return STATUS_OK; - } - } - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveFont - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInactiveFont") == 0) { - stack->correctParams(1); - - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); - stack->pushBool(_fontInactive != NULL); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInactiveImage") == 0) { - stack->correctParams(1); - - delete _imageInactive; - _imageInactive = new CBSprite(_gameRef); - const char *filename = stack->pop()->getString(); - if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { - delete _imageInactive; - _imageInactive = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInactiveImage") == 0) { - stack->correctParams(0); - if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); - else stack->pushString(_imageInactive->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInactiveImageObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInactiveImageObject") == 0) { - stack->correctParams(0); - if (!_imageInactive) stack->pushNULL(); - else stack->pushNative(_imageInactive, true); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(close())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoExclusive") == 0) { - stack->correctParams(0); - goExclusive(); - script->waitFor(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GoSystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GoSystemExclusive") == 0) { - stack->correctParams(0); - goSystemExclusive(); - script->waitFor(this); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Center - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Center") == 0) { - stack->correctParams(0); - _posX = (_gameRef->_renderer->_width - _width) / 2; - _posY = (_gameRef->_renderer->_height - _height) / 2; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadFromFile - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadFromFile") == 0) { - stack->correctParams(1); - - CScValue *val = stack->pop(); - cleanup(); - if (!val->isNULL()) { - stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateButton - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateButton") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIButton *btn = new CUIButton(_gameRef); - if (!val->isNULL()) btn->setName(val->getString()); - stack->pushNative(btn, true); - - btn->_parent = this; - _widgets.add(btn); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateStatic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateStatic") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIText *sta = new CUIText(_gameRef); - if (!val->isNULL()) sta->setName(val->getString()); - stack->pushNative(sta, true); - - sta->_parent = this; - _widgets.add(sta); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateEditor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateEditor") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIEdit *edi = new CUIEdit(_gameRef); - if (!val->isNULL()) edi->setName(val->getString()); - stack->pushNative(edi, true); - - edi->_parent = this; - _widgets.add(edi); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIWindow *win = new CUIWindow(_gameRef); - if (!val->isNULL()) win->setName(val->getString()); - stack->pushNative(win, true); - - win->_parent = this; - _widgets.add(win); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CUIObject *obj = (CUIObject *)val->getNative(); - - for (int i = 0; i < _widgets.getSize(); i++) { - if (_widgets[i] == obj) { - delete _widgets[i]; - _widgets.removeAt(i); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - } - } - stack->pushNULL(); - return STATUS_OK; - } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; - - else return CUIObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("window"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumWidgets / NumControls (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { - _scValue->setInt(_widgets.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exclusive") == 0) { - _scValue->setBool(_mode == WINDOW_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SystemExclusive") == 0) { - _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Menu") == 0) { - _scValue->setBool(_isMenu); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InGame") == 0) { - _scValue->setBool(_inGame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0) { - _scValue->setBool(_pauseMusic); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClipContents") == 0) { - _scValue->setBool(_clipContents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Transparent") == 0) { - _scValue->setBool(_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeColor") == 0) { - _scValue->setInt((int)_fadeColor); - return _scValue; - } - - else return CUIObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Menu - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Menu") == 0) { - _isMenu = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InGame") == 0) { - _inGame = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0) { - _pauseMusic = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClipContents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClipContents") == 0) { - _clipContents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Transparent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Transparent") == 0) { - _transparent = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeColor") == 0) { - _fadeColor = (uint32)value->getInt(); - _fadeBackground = (_fadeColor != 0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exclusive") == 0) { - if (value->getBool()) - goExclusive(); - else { - close(); - _visible = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SystemExclusive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SystemExclusive") == 0) { - if (value->getBool()) - goSystemExclusive(); - else { - close(); - _visible = true; - } - return STATUS_OK; - } - - else return CUIObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CUIWindow::scToString() { - return "[window]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { -//TODO - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); - } else { - if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); - else return false; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouseWheel(int Delta) { - if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - bool res = CUIObject::handleMouse(event, button); - - // handle window dragging - if (!CBPlatform::isRectEmpty(&_dragRect)) { - // start drag - if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { - Rect32 dragRect = _dragRect; - int offsetX, offsetY; - getTotalOffset(&offsetX, &offsetY); - CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - - if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { - _dragFrom.x = _gameRef->_mousePos.x; - _dragFrom.y = _gameRef->_mousePos.y; - _dragging = true; - } - } - // end drag - else if (_dragging && event == MOUSE_RELEASE && button == MOUSE_BUTTON_LEFT) { - _dragging = false; - } - } - - return res; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::persist(CBPersistMgr *persistMgr) { - - CUIObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_backInactive)); - persistMgr->transfer(TMEMBER(_clipContents)); - persistMgr->transfer(TMEMBER(_dragFrom)); - persistMgr->transfer(TMEMBER(_dragging)); - persistMgr->transfer(TMEMBER(_dragRect)); - persistMgr->transfer(TMEMBER(_fadeBackground)); - persistMgr->transfer(TMEMBER(_fadeColor)); - persistMgr->transfer(TMEMBER(_fontInactive)); - persistMgr->transfer(TMEMBER(_imageInactive)); - persistMgr->transfer(TMEMBER(_inGame)); - persistMgr->transfer(TMEMBER(_isMenu)); - persistMgr->transfer(TMEMBER_INT(_mode)); - persistMgr->transfer(TMEMBER(_shieldButton)); - persistMgr->transfer(TMEMBER(_shieldWindow)); - persistMgr->transfer(TMEMBER_INT(_titleAlign)); - persistMgr->transfer(TMEMBER(_titleRect)); - persistMgr->transfer(TMEMBER(_transparent)); - persistMgr->transfer(TMEMBER(_viewport)); - persistMgr->transfer(TMEMBER(_pauseMusic)); - - _widgets.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::moveFocus(bool forward) { - int i; - bool found = false; - for (i = 0; i < _widgets.getSize(); i++) { - if (_widgets[i] == _focusedWidget) { - found = true; - break; - } - } - if (!found) _focusedWidget = NULL; - - if (!_focusedWidget) { - if (_widgets.getSize() > 0) i = 0; - else return STATUS_OK; - } - - int numTries = 0; - bool done = false; - - while (numTries <= _widgets.getSize()) { - if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { - _focusedWidget = _widgets[i]; - done = true; - break; - } - - if (forward) { - i++; - if (i >= _widgets.getSize()) i = 0; - } else { - i--; - if (i < 0) i = _widgets.getSize() - 1; - } - numTries++; - } - - return done ? STATUS_OK : STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goExclusive() { - if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; - - if (_mode == WINDOW_NORMAL) { - _ready = false; - _mode = WINDOW_EXCLUSIVE; - _visible = true; - _disable = false; - _gameRef->focusWindow(this); - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goSystemExclusive() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; - - makeFreezable(false); - - _mode = WINDOW_SYSTEM_EXCLUSIVE; - _ready = false; - _visible = true; - _disable = false; - _gameRef->focusWindow(this); - - _gameRef->freeze(_pauseMusic); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::close() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { - _gameRef->unfreeze(); - } - - _mode = WINDOW_NORMAL; - _visible = false; - _ready = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; - - switch (obj->_type) { - case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) close(); - else return CBObject::listen(param1, param2); - break; - default: - return CBObject::listen(param1, param2); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CUIWindow::makeFreezable(bool freezable) { - for (int i = 0; i < _widgets.getSize(); i++) - _widgets[i]->makeFreezable(freezable); - - CBObject::makeFreezable(freezable); -} - - -////////////////////////////////////////////////////////////////////////// -bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { - for (int i = 0; i < _widgets.getSize(); i++) { - CUIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) continue; - - switch (control->_type) { - case UI_WINDOW: - ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); - break; - - case UI_BUTTON: - case UI_EDIT: - objects.add(control); - break; - - default: - if (!interactiveOnly) objects.add(control); - } - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/ui/UIWindow.h b/engines/wintermute/ui/UIWindow.h deleted file mode 100644 index f1d46711ff..0000000000 --- a/engines/wintermute/ui/UIWindow.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_UIWINDOW_H -#define WINTERMUTE_UIWINDOW_H - - -#include "UIObject.h" -#include "common/events.h" - -namespace WinterMute { - -class CUIButton; -class CBViewport; -class CUIWindow : public CUIObject { -public: - bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); - - bool _pauseMusic; - void cleanup(); - virtual void makeFreezable(bool freezable); - CBViewport *_viewport; - bool _clipContents; - bool _inGame; - bool _isMenu; - bool _fadeBackground; - uint32 _fadeColor; - virtual bool handleMouseWheel(int delta); - CUIWindow *_shieldWindow; - CUIButton *_shieldButton; - bool close(); - bool goSystemExclusive(); - bool goExclusive(); - TWindowMode _mode; - bool moveFocus(bool forward = true); - virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); - Point32 _dragFrom; - bool _dragging; - DECLARE_PERSISTENT(CUIWindow, CUIObject) - bool _transparent; - bool showWidget(const char *name, bool visible = true); - bool enableWidget(const char *name, bool enable = true); - Rect32 _titleRect; - Rect32 _dragRect; - virtual bool display(int offsetX = 0, int offsetY = 0); - CUIWindow(CBGame *inGame); - virtual ~CUIWindow(); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - CBArray _widgets; - TTextAlign _titleAlign; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - CUITiledImage *_backInactive; - CBFont *_fontInactive; - CBSprite *_imageInactive; - virtual bool listen(CBScriptHolder *param1, uint32 param2); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp new file mode 100644 index 0000000000..5b1867b652 --- /dev/null +++ b/engines/wintermute/ui/ui_button.cpp @@ -0,0 +1,1046 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/ui/ui_button.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIButton, false) + +////////////////////////////////////////////////////////////////////////// +CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { + _backPress = _backHover = _backDisable = _backFocus = NULL; + + _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; + + _imageDisable = _imagePress = _imageHover = _imageFocus = NULL; + + _align = TAL_CENTER; + + _hover = _press = false; + + _type = UI_BUTTON; + + _canFocus = false; + _stayPressed = false; + + _oneTimePress = false; + _centerImage = false; + + _pixelPerfect = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIButton::~CUIButton() { + delete _backPress; + delete _backHover; + delete _backDisable; + delete _backFocus; + + if (!_sharedFonts) { + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + } + + if (!_sharedImages) { + delete _imageHover; + delete _imagePress; + delete _imageDisable; + delete _imageFocus; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(BUTTON) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(FOCUSABLE) +TOKEN_DEF(BACK_HOVER) +TOKEN_DEF(BACK_PRESS) +TOKEN_DEF(BACK_DISABLE) +TOKEN_DEF(BACK_FOCUS) +TOKEN_DEF(BACK) +TOKEN_DEF(CENTER_IMAGE) +TOKEN_DEF(IMAGE_HOVER) +TOKEN_DEF(IMAGE_PRESS) +TOKEN_DEF(IMAGE_DISABLE) +TOKEN_DEF(IMAGE_FOCUS) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_HOVER) +TOKEN_DEF(FONT_PRESS) +TOKEN_DEF(FONT_DISABLE) +TOKEN_DEF(FONT_FOCUS) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(EVENTS) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(PRESSED) +TOKEN_DEF(PIXEL_PERFECT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIButton::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(FOCUSABLE) + TOKEN_TABLE(BACK_HOVER) + TOKEN_TABLE(BACK_PRESS) + TOKEN_TABLE(BACK_DISABLE) + TOKEN_TABLE(BACK_FOCUS) + TOKEN_TABLE(BACK) + TOKEN_TABLE(CENTER_IMAGE) + TOKEN_TABLE(IMAGE_HOVER) + TOKEN_TABLE(IMAGE_PRESS) + TOKEN_TABLE(IMAGE_DISABLE) + TOKEN_TABLE(IMAGE_FOCUS) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_HOVER) + TOKEN_TABLE(FONT_PRESS) + TOKEN_TABLE(FONT_DISABLE) + TOKEN_TABLE(FONT_FOCUS) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(PRESSED) + TOKEN_TABLE(PIXEL_PERFECT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { + _gameRef->LOG(0, "'BUTTON' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_HOVER: + delete _backHover; + _backHover = new CUITiledImage(_gameRef); + if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { + delete _backHover; + _backHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_PRESS: + delete _backPress; + _backPress = new CUITiledImage(_gameRef); + if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { + delete _backPress; + _backPress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_DISABLE: + delete _backDisable; + _backDisable = new CUITiledImage(_gameRef); + if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { + delete _backDisable; + _backDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_FOCUS: + delete _backFocus; + _backFocus = new CUITiledImage(_gameRef); + if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { + delete _backFocus; + _backFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_HOVER: + delete _imageHover; + _imageHover = new CBSprite(_gameRef); + if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { + delete _imageHover; + _imageHover = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_PRESS: + delete _imagePress; + _imagePress = new CBSprite(_gameRef); + if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { + delete _imagePress; + _imagePress = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_DISABLE: + delete _imageDisable; + _imageDisable = new CBSprite(_gameRef); + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { + delete _imageDisable; + _imageDisable = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_FOCUS: + delete _imageFocus; + _imageFocus = new CBSprite(_gameRef); + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { + delete _imageFocus; + _imageFocus = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_HOVER: + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + _fontHover = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontHover) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_PRESS: + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + _fontPress = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontPress) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_DISABLE: + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + _fontDisable = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontDisable) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_FOCUS: + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + _fontFocus = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontFocus) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; + else _align = TAL_CENTER; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_FOCUSABLE: + parser.scanStr((char *)params, "%b", &_canFocus); + break; + + case TOKEN_CENTER_IMAGE: + parser.scanStr((char *)params, "%b", &_centerImage); + break; + + case TOKEN_PRESSED: + parser.scanStr((char *)params, "%b", &_stayPressed); + break; + + case TOKEN_PIXEL_PERFECT: + parser.scanStr((char *)params, "%b", &_pixelPerfect); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in BUTTON definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading BUTTON definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "BUTTON\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backHover && _backHover->_filename) + buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); + if (_backPress && _backPress->_filename) + buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); + if (_backDisable && _backDisable->_filename) + buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); + if (_backFocus && _backFocus->_filename) + buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageHover && _imageHover->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); + if (_imagePress && _imagePress->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); + if (_imageDisable && _imageDisable->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); + if (_imageFocus && _imageFocus->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontHover && _fontHover->_filename) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + if (_fontPress && _fontPress->_filename) + buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); + if (_fontDisable && _fontDisable->_filename) + buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); + if (_fontFocus && _fontFocus->_filename) + buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_align) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + warning("CUIButton::SaveAsText - unhandled enum"); + break; + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "FOCUSABLE=%s\n", _canFocus ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CENTER_IMAGE=%s\n", _centerImage ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRESSED=%s\n", _stayPressed ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PIXEL_PERFECT=%s\n", _pixelPerfect ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUIButton::correctSize() { + Rect32 rect; + + CBSprite *img = NULL; + if (_image) img = _image; + else if (_imageDisable) img = _imageDisable; + else if (_imageHover) img = _imageHover; + else if (_imagePress) img = _imagePress; + else if (_imageFocus) img = _imageFocus; + + if (_width <= 0) { + if (img) { + img->getBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (img) { + img->getBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_text) { + int text_height; + if (_font) text_height = _font->getTextHeight((byte *)_text, _width); + else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); + + if (text_height > _height) _height = text_height; + } + + if (_height <= 0) _height = 100; + + if (_back) _back->correctSize(&_width, &_height); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::display(int offsetX, int offsetY) { + if (!_visible) + return STATUS_OK; + + CUITiledImage *back = NULL; + CBSprite *image = NULL; + CBFont *font = 0; + + //RECT rect; + //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); + _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); + + if ((_press && _hover && !_gameRef->_mouseLeftDown) || + (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); + + + if (_disable) { + if (_backDisable) back = _backDisable; + if (_imageDisable) image = _imageDisable; + if (_text && _fontDisable) font = _fontDisable; + } else if (_press || _oneTimePress || _stayPressed) { + if (_backPress) back = _backPress; + if (_imagePress) image = _imagePress; + if (_text && _fontPress) font = _fontPress; + } else if (_hover) { + if (_backHover) back = _backHover; + if (_imageHover) image = _imageHover; + if (_text && _fontHover) font = _fontHover; + } else if (_canFocus && isFocused()) { + if (_backFocus) back = _backFocus; + if (_imageFocus) image = _imageFocus; + if (_text && _fontFocus) font = _fontFocus; + } + + if (!back && _back) back = _back; + if (!image && _image) image = _image; + if (_text && !font) { + if (_font) font = _font; + else font = _gameRef->_systemFont; + } + + int imageX = offsetX + _posX; + int imageY = offsetY + _posY; + + if (image && _centerImage) { + Rect32 rc; + image->getBoundingRect(&rc, 0, 0); + imageX += (_width - (rc.right - rc.left)) / 2; + imageY += (_height - (rc.bottom - rc.top)) / 2; + } + + if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); + //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + + if (font && _text) { + int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); + } + + if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + + // reset unused sprites + if (_image && _image != image) _image->reset(); + if (_imageDisable && _imageDisable != image) _imageDisable->reset(); + if (_imageFocus && _imageFocus != image) _imageFocus->reset(); + if (_imagePress && _imagePress != image) _imagePress->reset(); + if (_imageHover && _imageHover != image) _imageHover->reset(); + + _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIButton::press() { + applyEvent("Press"); + if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); + if (_parentNotify && _parent) _parent->applyEvent(_name); + + _oneTimePress = false; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetDisabledFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetDisabledFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (Val->isNULL()) { + _fontDisable = NULL; + stack->pushBool(true); + } else { + _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_fontDisable != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetHoverFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHoverFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (val->isNULL()) { + _fontHover = NULL; + stack->pushBool(true); + } else { + _fontHover = _gameRef->_fontStorage->addFont(val->getString()); + stack->pushBool(_fontHover != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPressedFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (Val->isNULL()) { + _fontPress = NULL; + stack->pushBool(true); + } else { + _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_fontPress != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFocusedFont") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + if (val->isNULL()) { + _fontFocus = NULL; + stack->pushBool(true); + } else { + _fontFocus = _gameRef->_fontStorage->addFont(val->getString()); + stack->pushBool(_fontFocus != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDisabledImage") == 0) { + stack->correctParams(1); + + delete _imageDisable; + _imageDisable = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { + delete _imageDisable; + _imageDisable = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDisabledImage") == 0) { + stack->correctParams(0); + if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); + else stack->pushString(_imageDisable->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDisabledImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDisabledImageObject") == 0) { + stack->correctParams(0); + if (!_imageDisable) stack->pushNULL(); + else stack->pushNative(_imageDisable, true); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHoverImage") == 0) { + stack->correctParams(1); + + delete _imageHover; + _imageHover = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { + delete _imageHover; + _imageHover = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverImage") == 0) { + stack->correctParams(0); + if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); + else stack->pushString(_imageHover->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetHoverImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHoverImageObject") == 0) { + stack->correctParams(0); + if (!_imageHover) stack->pushNULL(); + else stack->pushNative(_imageHover, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPressedImage") == 0) { + stack->correctParams(1); + + delete _imagePress; + _imagePress = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { + delete _imagePress; + _imagePress = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPressedImage") == 0) { + stack->correctParams(0); + if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); + else stack->pushString(_imagePress->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPressedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPressedImageObject") == 0) { + stack->correctParams(0); + if (!_imagePress) stack->pushNULL(); + else stack->pushNative(_imagePress, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFocusedImage") == 0) { + stack->correctParams(1); + + delete _imageFocus; + _imageFocus = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { + delete _imageFocus; + _imageFocus = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFocusedImage") == 0) { + stack->correctParams(0); + if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); + else stack->pushString(_imageFocus->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFocusedImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFocusedImageObject") == 0) { + stack->correctParams(0); + if (!_imageFocus) stack->pushNULL(); + else stack->pushNative(_imageFocus, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Press + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Press") == 0) { + stack->correctParams(0); + + if (_visible && !_disable) { + _oneTimePress = true; + _oneTimePressTime = CBPlatform::getTime(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIButton::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("button"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextAlign") == 0) { + _scValue->setInt(_align); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focusable") == 0) { + _scValue->setBool(_canFocus); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pressed") == 0) { + _scValue->setBool(_stayPressed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_pixelPerfect); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "TextAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _align = (TTextAlign)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focusable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focusable") == 0) { + _canFocus = value->getBool(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Pressed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pressed") == 0) { + _stayPressed = value->getBool(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _pixelPerfect = value->getBool(); + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIButton::scToString() { + return "[button]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIButton::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_align)); + persistMgr->transfer(TMEMBER(_backDisable)); + persistMgr->transfer(TMEMBER(_backFocus)); + persistMgr->transfer(TMEMBER(_backHover)); + persistMgr->transfer(TMEMBER(_backPress)); + persistMgr->transfer(TMEMBER(_centerImage)); + persistMgr->transfer(TMEMBER(_fontDisable)); + persistMgr->transfer(TMEMBER(_fontFocus)); + persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transfer(TMEMBER(_fontPress)); + persistMgr->transfer(TMEMBER(_hover)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_imageDisable)); + persistMgr->transfer(TMEMBER(_imageFocus)); + persistMgr->transfer(TMEMBER(_imageHover)); + persistMgr->transfer(TMEMBER(_imagePress)); + persistMgr->transfer(TMEMBER(_pixelPerfect)); + persistMgr->transfer(TMEMBER(_press)); + persistMgr->transfer(TMEMBER(_stayPressed)); + + if (!persistMgr->_saving) { + _oneTimePress = false; + _oneTimePressTime = 0; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h new file mode 100644 index 0000000000..c6538f4423 --- /dev/null +++ b/engines/wintermute/ui/ui_button.h @@ -0,0 +1,79 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIBUTTON_H +#define WINTERMUTE_UIBUTTON_H + + +#include "engines/wintermute/ui/ui_object.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUIButton : public CUIObject { +public: + bool _pixelPerfect; + bool _stayPressed; + bool _centerImage; + bool _oneTimePress; + uint32 _oneTimePressTime; + DECLARE_PERSISTENT(CUIButton, CUIObject) + void press(); + virtual bool display(int offsetX = 0, int offsetY = 0); + bool _press; + bool _hover; + void correctSize(); + TTextAlign _align; + CBSprite *_imageHover; + CBSprite *_imagePress; + CBSprite *_imageDisable; + CBSprite *_imageFocus; + CBFont *_fontDisable; + CBFont *_fontPress; + CBFont *_fontHover; + CBFont *_fontFocus; + CUITiledImage *_backPress; + CUITiledImage *_backHover; + CUITiledImage *_backDisable; + CUITiledImage *_backFocus; + CUIButton(CBGame *inGame = NULL); + virtual ~CUIButton(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp new file mode 100644 index 0000000000..237b944332 --- /dev/null +++ b/engines/wintermute/ui/ui_edit.cpp @@ -0,0 +1,857 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ui/ui_edit.h" +#include "engines/wintermute/ui/ui_object.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/utils.h" +#include "common/util.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEdit, false) + +////////////////////////////////////////////////////////////////////////// +CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { + _type = UI_EDIT; + + _fontSelected = NULL; + + _selStart = _selEnd = 10000; + _scrollOffset = 0; + + _cursorChar = NULL; + setCursorChar("|"); + + _cursorBlinkRate = 600; + + _frameWidth = 0; + + setText(""); + + _lastBlinkTime = 0; + _cursorVisible = true; + + _maxLength = -1; + + _canFocus = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEdit::~CUIEdit() { + if (!_sharedFonts) { + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + } + + delete[] _cursorChar; + _cursorChar = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_SELECTED) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR_BLINK_RATE) +TOKEN_DEF(CURSOR) +TOKEN_DEF(FRAME_WIDTH) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MAX_LENGTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF(CAPTION) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_SELECTED) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR_BLINK_RATE) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(FRAME_WIDTH) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MAX_LENGTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { + _gameRef->LOG(0, "'EDIT' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_SELECTED: + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontSelected) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_MAX_LENGTH: + parser.scanStr((char *)params, "%d", &_maxLength); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_CURSOR_BLINK_RATE: + parser.scanStr((char *)params, "%d", &_cursorBlinkRate); + break; + + case TOKEN_FRAME_WIDTH: + parser.scanStr((char *)params, "%d", &_frameWidth); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in EDIT definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading EDIT definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "EDIT\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontSelected && _fontSelected->_filename) + buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + buffer->putTextIndent(indent + 2, "MAX_LENGTH=%d\n", _maxLength); + buffer->putTextIndent(indent + 2, "CURSOR_BLINK_RATE=%d\n", _cursorBlinkRate); + buffer->putTextIndent(indent + 2, "FRAME_WIDTH=%d\n", _frameWidth); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSelectedFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSelectedFont") == 0) { + stack->correctParams(1); + + if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); + stack->pushBool(_fontSelected != NULL); + + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEdit::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("editor"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelStart") == 0) { + _scValue->setInt(_selStart); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelEnd") == 0) { + _scValue->setInt(_selEnd); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorBlinkRate") == 0) { + _scValue->setInt(_cursorBlinkRate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorChar") == 0) { + _scValue->setString(_cursorChar); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FrameWidth") == 0) { + _scValue->setInt(_frameWidth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxLength") == 0) { + _scValue->setInt(_maxLength); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::ansiToWide(_text); + _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); + } else { + _scValue->setString(_text); + } + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // SelStart + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SelStart") == 0) { + _selStart = value->getInt(); + _selStart = MAX(_selStart, 0); + _selStart = MIN((size_t)_selStart, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SelEnd + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SelEnd") == 0) { + _selEnd = value->getInt(); + _selEnd = MAX(_selEnd, 0); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorBlinkRate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorBlinkRate") == 0) { + _cursorBlinkRate = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorChar + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorChar") == 0) { + setCursorChar(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FrameWidth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FrameWidth") == 0) { + _frameWidth = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxLength") == 0) { + _maxLength = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(value->getString()); + setText(StringUtil::wideToAnsi(wstr).c_str()); + } else { + setText(value->getString()); + } + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEdit::scToString() { + return "[edit]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIEdit::setCursorChar(const char *character) { + if (!character) return; + delete[] _cursorChar; + _cursorChar = new char [strlen(character) + 1]; + if (_cursorChar) strcpy(_cursorChar, character); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + + // hack! + TTextEncoding OrigEncoding = _gameRef->_textEncoding; + _gameRef->_textEncoding = TEXT_ANSI; + + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + + // prepare fonts + CBFont *font; + CBFont *sfont; + + if (_font) font = _font; + else font = _gameRef->_systemFont; + + if (_fontSelected) sfont = _fontSelected; + else sfont = font; + + bool focused = isFocused(); + + _selStart = MAX(_selStart, 0); + _selEnd = MAX(_selEnd, 0); + + _selStart = MIN((size_t)_selStart, strlen(_text)); + _selEnd = MIN((size_t)_selEnd, strlen(_text)); + + //int CursorWidth = font->GetCharWidth(_cursorChar[0]); + int cursorWidth = font->getTextWidth((byte *)_cursorChar); + + int s1, s2; + bool curFirst; + // modify scroll offset + if (_selStart >= _selEnd) { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= (int)strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selEnd; + s2 = _selStart; + curFirst = true; + } else { + while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selStart - _scrollOffset)) + + sfont->getTextWidth((byte *)(_text + MAX(_scrollOffset, _selStart)), _selEnd - MAX(_scrollOffset, _selStart)) + + > _width - cursorWidth - 2 * _frameWidth) { + _scrollOffset++; + if (_scrollOffset >= (int)strlen(_text)) break; + } + + _scrollOffset = MIN(_scrollOffset, _selEnd); + + s1 = _selStart; + s2 = _selEnd; + curFirst = false; + } + + + int AlignOffset = 0; + + for (int Count = 0; Count < 2; Count++) { + // draw text + int xxx, yyy, width, height; + + xxx = _posX + _frameWidth + offsetX; + yyy = _posY + _frameWidth + offsetY; + + width = _posX + _width + offsetX - _frameWidth; + height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); + + if (_gameRef->_textRTL) xxx += AlignOffset; + + TTextAlign Align = TAL_LEFT; + + + // unselected 1 + if (s1 > _scrollOffset) { + if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + } + + // cursor + if (focused && curFirst) { + if (Count) { + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += cursorWidth; + AlignOffset += cursorWidth; + } + + // selected + int s3 = MAX(s1, _scrollOffset); + + if (s2 - s3 > 0) { + if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + } + + // cursor + if (focused && !curFirst) { + if (Count) { + if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = CBPlatform::getTime(); + _cursorVisible = !_cursorVisible; + } + if (_cursorVisible) + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + } + xxx += cursorWidth; + AlignOffset += cursorWidth; + } + + // unselected 2 + if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); + AlignOffset += font->getTextWidth((byte *)_text + s2); + + AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; + if (AlignOffset < 0) AlignOffset = 0; + } + + + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + + + _gameRef->_textEncoding = OrigEncoding; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { + bool handled = false; + + if (event->type == Common::EVENT_KEYDOWN && !printable) { + switch (event->kbd.keycode) { + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_TAB: + case Common::KEYCODE_RETURN: + return false; + + // ctrl+A + case Common::KEYCODE_a: + if (CBKeyboardState::isControlDown()) { + _selStart = 0; + _selEnd = strlen(_text); + handled = true; + } + break; + + case Common::KEYCODE_BACKSPACE: + if (_selStart == _selEnd) { + if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); + else deleteChars(_selStart - 1, _selStart); + } else deleteChars(_selStart, _selEnd); + if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); + _selStart = _selEnd; + + handled = true; + break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_UP: + _selEnd--; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + handled = true; + break; + + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_DOWN: + _selEnd++; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + handled = true; + break; + + case Common::KEYCODE_HOME: + if (_gameRef->_textRTL) { + _selEnd = strlen(_text); + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } else { + _selEnd = 0; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_END: + if (_gameRef->_textRTL) { + _selEnd = 0; + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } else { + _selEnd = strlen(_text); + if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + } + handled = true; + break; + + case Common::KEYCODE_DELETE: + if (_selStart == _selEnd) { + if (_gameRef->_textRTL) { + deleteChars(_selStart - 1, _selStart); + _selEnd--; + if (_selEnd < 0) _selEnd = 0; + } else deleteChars(_selStart, _selStart + 1); + } else deleteChars(_selStart, _selEnd); + if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); + + _selStart = _selEnd; + handled = true; + break; + default: + break; + } + return handled; + } else if (event->type == Common::EVENT_KEYDOWN && printable) { + if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); + + //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); + WideString wstr; + wstr += (char)event->kbd.ascii; + _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); + + if (_gameRef->_textRTL) _selEnd = _selStart; + else _selStart = _selEnd; + + return true; + } + + return false; +} + + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::deleteChars(int start, int end) { + if (start > end) CBUtils::swap(&start, &end); + + start = MAX(start, (int)0); + end = MIN((size_t)end, strlen(_text)); + + char *str = new char[strlen(_text) - (end - start) + 1]; + if (str) { + if (start > 0) memcpy(str, _text, start); + memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->applyEvent(_name); + + return end - start; +} + + +////////////////////////////////////////////////////////////////////////// +int CUIEdit::insertChars(int pos, byte *chars, int num) { + if ((int)strlen(_text) + num > _maxLength) { + num -= (strlen(_text) + num - _maxLength); + } + + pos = MAX(pos, (int)0); + pos = MIN((size_t)pos, strlen(_text)); + + char *str = new char[strlen(_text) + num + 1]; + if (str) { + if (pos > 0) memcpy(str, _text, pos); + memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); + + memcpy(str + pos, chars, num); + + delete[] _text; + _text = str; + } + if (_parentNotify && _parent) _parent->applyEvent(_name); + + return num; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIEdit::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_cursorBlinkRate)); + persistMgr->transfer(TMEMBER(_cursorChar)); + persistMgr->transfer(TMEMBER(_fontSelected)); + persistMgr->transfer(TMEMBER(_frameWidth)); + persistMgr->transfer(TMEMBER(_maxLength)); + persistMgr->transfer(TMEMBER(_scrollOffset)); + persistMgr->transfer(TMEMBER(_selEnd)); + persistMgr->transfer(TMEMBER(_selStart)); + + if (!persistMgr->_saving) { + _cursorVisible = false; + _lastBlinkTime = 0; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h new file mode 100644 index 0000000000..400cd7b578 --- /dev/null +++ b/engines/wintermute/ui/ui_edit.h @@ -0,0 +1,72 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIEDIT_H +#define WINTERMUTE_UIEDIT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/ui/ui_object.h" +#include "common/events.h" + +namespace WinterMute { +class CBFont; +class CUIEdit : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEdit, CUIObject) + int _maxLength; + int insertChars(int pos, byte *chars, int num); + int deleteChars(int start, int end); + bool _cursorVisible; + uint32 _lastBlinkTime; + virtual bool display(int offsetX, int offsetY); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + int _scrollOffset; + int _frameWidth; + uint32 _cursorBlinkRate; + void setCursorChar(const char *character); + char *_cursorChar; + int _selEnd; + int _selStart; + CBFont *_fontSelected; + CUIEdit(CBGame *inGame); + virtual ~CUIEdit(); + + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp new file mode 100644 index 0000000000..012ff0390f --- /dev/null +++ b/engines/wintermute/ui/ui_entity.cpp @@ -0,0 +1,339 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_entity.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/ui/ui_entity.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIEntity, false) + +////////////////////////////////////////////////////////////////////////// +CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { + _type = UI_CUSTOM; + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CUIEntity::~CUIEntity() { + if (_entity) _gameRef->unregisterObject(_entity); + _entity = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(ENTITY_CONTAINER) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(NAME) +TOKEN_DEF(ENTITY) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(ENTITY_CONTAINER) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ENTITY) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { + _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_ENTITY: + if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition"); + return STATUS_FAILED; + } + + correctSize(); + + if (_gameRef->_editorMode) { + _width = 50; + _height = 50; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + + if (_entity && _entity->_filename) + buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::setEntity(const char *filename) { + if (_entity) _gameRef->unregisterObject(_entity); + _entity = new CAdEntity(_gameRef); + if (!_entity || DID_FAIL(_entity->loadFile(filename))) { + delete _entity; + _entity = NULL; + return STATUS_FAILED; + } else { + _entity->_nonIntMouseEvents = true; + _entity->_sceneIndependent = true; + _entity->makeFreezable(false); + _gameRef->registerObject(_entity); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + if (_entity) { + _entity->_posX = offsetX + _posX; + _entity->_posY = offsetY + _posY; + if (_entity->_scale < 0) _entity->_zoomable = false; + _entity->_shadowable = false; + + _entity->update(); + + bool origReg = _entity->_registrable; + + if (_entity->_registrable && _disable) _entity->_registrable = false; + + _entity->display(); + _entity->_registrable = origReg; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetEntity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetEntity") == 0) { + stack->correctParams(0); + + if (_entity) stack->pushNative(_entity, true); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetEntity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetEntity") == 0) { + stack->correctParams(1); + + const char *filename = stack->pop()->getString(); + + if (DID_SUCCEED(setEntity(filename))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIEntity::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("entity container"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Freezable") == 0) { + if (_entity) _scValue->setBool(_entity->_freezable); + else _scValue->setBool(false); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Freezable + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Freezable") == 0) { + if (_entity) _entity->makeFreezable(value->getBool()); + return STATUS_OK; + } else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIEntity::scToString() { + return "[entity container]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIEntity::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_entity)); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h new file mode 100644 index 0000000000..6873000681 --- /dev/null +++ b/engines/wintermute/ui/ui_entity.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIENTITY_H +#define WINTERMUTE_UIENTITY_H + +#include "engines/wintermute/ui/ui_object.h" + +namespace WinterMute { +class CAdEntity; +class CUIEntity : public CUIObject { +public: + DECLARE_PERSISTENT(CUIEntity, CUIObject) + CUIEntity(CBGame *inGame); + virtual ~CUIEntity(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + virtual bool display(int offsetX = 0, int offsetY = 0); + CAdEntity *_entity; + bool setEntity(const char *filename); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp new file mode 100644 index 0000000000..605b5b74b1 --- /dev/null +++ b/engines/wintermute/ui/ui_object.cpp @@ -0,0 +1,589 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/ui/ui_object.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/font/base_font_storage.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIObject, false) + +////////////////////////////////////////////////////////////////////////// +CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { + _back = NULL; + _image = NULL; + _font = NULL; + _text = NULL; + _sharedFonts = _sharedImages = false; + + _width = _height = 0; + + _listenerObject = NULL; + _listenerParamObject = NULL; + _listenerParamDWORD = 0; + + _disable = false; + _visible = true; + + _type = UI_UNKNOWN; + _parent = NULL; + + _parentNotify = false; + + _focusedWidget = NULL; + + _canFocus = false; + _nonIntMouseEvents = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIObject::~CUIObject() { + if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); + + if (_back) delete _back; + if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); + + if (_image && !_sharedImages) delete _image; + + if (_text) delete [] _text; + + _focusedWidget = NULL; // ref only +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::setText(const char *text) { + if (_text) delete [] _text; + _text = new char [strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + for (int i = 0; i < strlen(_text); i++) { + if (_text[i] == '|') _text[i] = '\n'; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::display(int offsetX, int offsetY) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { + _listenerObject = object; + _listenerParamObject = listenerObject; + _listenerParamDWORD = listenerParam; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIObject::correctSize() { + Rect32 rect; + + if (_width <= 0) { + if (_image) { + _image->getBoundingRect(&rect, 0, 0); + _width = rect.right - rect.left; + } else _width = 100; + } + + if (_height <= 0) { + if (_image) { + _image->getBoundingRect(&rect, 0, 0); + _height = rect.bottom - rect.top; + } + } + + if (_back) _back->correctSize(&_width, &_height); +} + + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFont + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFont") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (_font) _gameRef->_fontStorage->removeFont(_font); + if (Val->isNULL()) { + _font = NULL; + stack->pushBool(true); + } else { + _font = _gameRef->_fontStorage->addFont(Val->getString()); + stack->pushBool(_font != NULL); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + /* const char *filename = */ val->getString(); + + delete _image; + _image = NULL; + if (val->isNULL()) { + stack->pushBool(true); + return STATUS_OK; + } + + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { + delete _image; + _image = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + if (!_image || !_image->_filename) stack->pushNULL(); + else stack->pushString(_image->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetImageObject") == 0) { + stack->correctParams(0); + if (!_image) stack->pushNULL(); + else stack->pushNative(_image, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Focus + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Focus") == 0) { + stack->correctParams(0); + focus(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveAfter / MoveBefore + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) { + stack->correctParams(1); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + + int i; + bool found = false; + CScValue *val = stack->pop(); + // find directly + if (val->isNative()) { + CUIObject *widget = (CUIObject *)val->getNative(); + for (i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == widget) { + found = true; + break; + } + } + } + // find by name + else { + const char *findName = val->getString(); + for (i = 0; i < win->_widgets.getSize(); i++) { + if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { + found = true; + break; + } + } + } + + if (found) { + bool done = false; + for (int j = 0; j < win->_widgets.getSize(); j++) { + if (win->_widgets[j] == this) { + if (strcmp(name, "MoveAfter") == 0) i++; + if (j >= i) j++; + + win->_widgets.insertAt(i, this); + win->_widgets.removeAt(j); + + done = true; + stack->pushBool(true); + break; + } + } + if (!done) stack->pushBool(false); + } else stack->pushBool(false); + + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToBottom + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveToBottom") == 0) { + stack->correctParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.removeAt(i); + win->_widgets.insertAt(0, this); + break; + } + } + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveToTop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveToTop") == 0) { + stack->correctParams(0); + + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + win->_widgets.removeAt(i); + win->_widgets.add(this); + break; + } + } + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("ui_object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Parent (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Parent") == 0) { + _scValue->setNative(_parent, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParentNotify") == 0) { + _scValue->setBool(_parentNotify); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Visible") == 0) { + _scValue->setBool(_visible); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Disabled") == 0) { + _scValue->setBool(_disable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + _scValue->setString(_text); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NextSibling (RO) / PrevSibling (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { + _scValue->setNULL(); + if (_parent && _parent->_type == UI_WINDOW) { + CUIWindow *win = (CUIWindow *)_parent; + for (int i = 0; i < win->_widgets.getSize(); i++) { + if (win->_widgets[i] == this) { + if (strcmp(name, "NextSibling") == 0) { + if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); + } else { + if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); + } + break; + } + } + } + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ParentNotify + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ParentNotify") == 0) { + _parentNotify = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Visible + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Visible") == 0) { + _visible = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Disabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Disabled") == 0) { + _disable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Text + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Text") == 0) { + setText(value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIObject::scToString() { + return "[ui_object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::isFocused() { + if (!_gameRef->_focusedWindow) return false; + if (_gameRef->_focusedWindow == this) return true; + + CUIObject *obj = _gameRef->_focusedWindow; + while (obj) { + if (obj == this) return true; + else obj = obj->_focusedWidget; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { + // handle focus change + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + focus(); + } + return CBObject::handleMouse(event, button); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::focus() { + CUIObject *obj = this; + bool disabled = false; + while (obj) { + if (obj->_disable && obj->_type == UI_WINDOW) { + disabled = true; + break; + } + obj = obj->_parent; + } + if (!disabled) { + obj = this; + while (obj) { + if (obj->_parent) { + if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; + } else { + if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); + } + + obj = obj->_parent; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { + int offX = 0, offY = 0; + + CUIObject *obj = _parent; + while (obj) { + offX += obj->_posX; + offY += obj->_posY; + + obj = obj->_parent; + } + if (offsetX) *offsetX = offX; + if (offsetY) *offsetY = offY; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_back)); + persistMgr->transfer(TMEMBER(_canFocus)); + persistMgr->transfer(TMEMBER(_disable)); + persistMgr->transfer(TMEMBER(_focusedWidget)); + persistMgr->transfer(TMEMBER(_font)); + persistMgr->transfer(TMEMBER(_height)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_listenerObject)); + persistMgr->transfer(TMEMBER(_listenerParamObject)); + persistMgr->transfer(TMEMBER(_listenerParamDWORD)); + persistMgr->transfer(TMEMBER(_parent)); + persistMgr->transfer(TMEMBER(_parentNotify)); + persistMgr->transfer(TMEMBER(_sharedFonts)); + persistMgr->transfer(TMEMBER(_sharedImages)); + persistMgr->transfer(TMEMBER(_text)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_visible)); + persistMgr->transfer(TMEMBER(_width)); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h new file mode 100644 index 0000000000..35bd092592 --- /dev/null +++ b/engines/wintermute/ui/ui_object.h @@ -0,0 +1,83 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIOBJECT_H +#define WINTERMUTE_UIOBJECT_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView + +namespace WinterMute { + +class CUITiledImage; +class CBFont; +class CUIObject : public CBObject { +public: + + bool getTotalOffset(int *offsetX, int *offsetY); + bool _canFocus; + bool focus(); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + bool isFocused(); + bool _parentNotify; + DECLARE_PERSISTENT(CUIObject, CBObject) + CUIObject *_parent; + virtual bool display(int offsetX = 0, int offsetY = 0); + virtual void correctSize(); + bool _sharedFonts; + bool _sharedImages; + void setText(const char *text); + char *_text; + CBFont *_font; + bool _visible; + CUITiledImage *_back; + bool _disable; + CUIObject(CBGame *inGame = NULL); + virtual ~CUIObject(); + int _width; + int _height; + TUIObjectType _type; + CBSprite *_image; + void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); + CBScriptHolder *_listenerParamObject; + uint32 _listenerParamDWORD; + CBScriptHolder *_listenerObject; + CUIObject *_focusedWidget; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp new file mode 100644 index 0000000000..6309d05a1e --- /dev/null +++ b/engines/wintermute/ui/ui_text.cpp @@ -0,0 +1,489 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/ui/ui_text.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIText, false) + +////////////////////////////////////////////////////////////////////////// +CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { + _textAlign = TAL_LEFT; + _verticalAlign = VAL_CENTER; + _type = UI_STATIC; + _canFocus = false; +} + + +////////////////////////////////////////////////////////////////////////// +CUIText::~CUIText() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::display(int offsetX, int offsetY) { + if (!_visible) return STATUS_OK; + + + CBFont *font = _font; + if (!font) font = _gameRef->_systemFont; + + if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + + if (font && _text) { + int textOffset; + switch (_verticalAlign) { + case VAL_TOP: + textOffset = 0; + break; + case VAL_BOTTOM: + textOffset = _height - font->getTextHeight((byte *)_text, _width); + break; + default: + textOffset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; + } + font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); + } + + //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(STATIC) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT) +TOKEN_DEF(TEXT_ALIGN) +TOKEN_DEF(VERTICAL_ALIGN) +TOKEN_DEF(TEXT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIText::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TEXT_ALIGN) + TOKEN_TABLE(VERTICAL_ALIGN) + TOKEN_TABLE(TEXT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { + _gameRef->LOG(0, "'STATIC' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TEXT: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TEXT_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; + else _textAlign = TAL_CENTER; + break; + + case TOKEN_VERTICAL_ALIGN: + if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; + else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; + else _verticalAlign = VAL_CENTER; + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in STATIC definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading STATIC definition"); + return STATUS_FAILED; + } + + correctSize(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "STATIC\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + if (_text) + buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + + switch (_textAlign) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); + break; + default: + error("CUIText::SaveAsText - Unhandled enum"); + break; + } + + switch (_verticalAlign) { + case VAL_TOP: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "top"); + break; + case VAL_BOTTOM: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "bottom"); + break; + case VAL_CENTER: + buffer->putTextIndent(indent + 2, "VERTICAL_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIText::SaveAsText - Unhandled enum value: NUM_VERTICAL_ALIGN"); + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SizeToFit + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SizeToFit") == 0) { + stack->correctParams(0); + sizeToFit(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HeightToFit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HeightToFit") == 0) { + stack->correctParams(0); + if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); + stack->pushNULL(); + return STATUS_OK; + } + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIText::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("static"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextAlign") == 0) { + _scValue->setInt(_textAlign); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VerticalAlign") == 0) { + _scValue->setInt(_verticalAlign); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // TextAlign + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "TextAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + _textAlign = (TTextAlign)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VerticalAlign + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VerticalAlign") == 0) { + int i = value->getInt(); + if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; + _verticalAlign = (TVerticalAlign)i; + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIText::scToString() { + return "[static]"; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + persistMgr->transfer(TMEMBER_INT(_textAlign)); + persistMgr->transfer(TMEMBER_INT(_verticalAlign)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIText::sizeToFit() { + if (_font && _text) { + _width = _font->getTextWidth((byte *)_text); + _height = _font->getTextHeight((byte *)_text, _width); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h new file mode 100644 index 0000000000..dc633dc042 --- /dev/null +++ b/engines/wintermute/ui/ui_text.h @@ -0,0 +1,60 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITEXT_H +#define WINTERMUTE_UITEXT_H + + +#include "engines/wintermute/ui/ui_object.h" + +namespace WinterMute { + +class CUIText : public CUIObject { +private: + bool sizeToFit(); +public: + virtual bool display(int offsetX, int offsetY); + DECLARE_PERSISTENT(CUIText, CUIObject) + CUIText(CBGame *inGame = NULL); + virtual ~CUIText(); + TTextAlign _textAlign; + TVerticalAlign _verticalAlign; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp new file mode 100644 index 0000000000..39b39b556d --- /dev/null +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -0,0 +1,370 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUITiledImage, false) + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { + _image = NULL; + + CBPlatform::setRectEmpty(&_upLeft); + CBPlatform::setRectEmpty(&_upMiddle); + CBPlatform::setRectEmpty(&_upRight); + CBPlatform::setRectEmpty(&_middleLeft); + CBPlatform::setRectEmpty(&_middleMiddle); + CBPlatform::setRectEmpty(&_middleRight); + CBPlatform::setRectEmpty(&_downLeft); + CBPlatform::setRectEmpty(&_downMiddle); + CBPlatform::setRectEmpty(&_downRight); +} + + +////////////////////////////////////////////////////////////////////////// +CUITiledImage::~CUITiledImage() { + delete _image; + _image = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::display(int x, int y, int width, int height) { + if (!_image) return STATUS_FAILED; + + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; + + int nuColumns = (width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; + + int col, row; + + _gameRef->_renderer->startSpriteBatch(); + + // top left/right + _image->_surface->displayTrans(x, y, _upLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y, _upRight); + + // bottom left/right + _image->_surface->displayTrans(x, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downLeft); + _image->_surface->displayTrans(x + (_upLeft.right - _upLeft.left) + nuColumns * tileWidth, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downRight); + + // left/right + int yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + _image->_surface->displayTrans(x, yyy, _middleLeft); + _image->_surface->displayTrans(x + (_middleLeft.right - _middleLeft.left) + nuColumns * tileWidth, yyy, _middleRight); + yyy += tileWidth; + } + + // top/bottom + int xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { + _image->_surface->displayTrans(xxx, y, _upMiddle); + _image->_surface->displayTrans(xxx, y + (_upMiddle.bottom - _upMiddle.top) + nuRows * tileHeight, _downMiddle); + xxx += tileWidth; + } + + // tiles + yyy = y + (_upMiddle.bottom - _upMiddle.top); + for (row = 0; row < nuRows; row++) { + xxx = x + (_upLeft.right - _upLeft.left); + for (col = 0; col < nuColumns; col++) { + _image->_surface->displayTrans(xxx, yyy, _middleMiddle); + xxx += tileWidth; + } + yyy += tileWidth; + } + + _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TILED_IMAGE) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(UP_LEFT) +TOKEN_DEF(UP_RIGHT) +TOKEN_DEF(UP_MIDDLE) +TOKEN_DEF(DOWN_LEFT) +TOKEN_DEF(DOWN_RIGHT) +TOKEN_DEF(DOWN_MIDDLE) +TOKEN_DEF(MIDDLE_LEFT) +TOKEN_DEF(MIDDLE_RIGHT) +TOKEN_DEF(MIDDLE_MIDDLE) +TOKEN_DEF(VERTICAL_TILES) +TOKEN_DEF(HORIZONTAL_TILES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TILED_IMAGE) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(UP_LEFT) + TOKEN_TABLE(UP_RIGHT) + TOKEN_TABLE(UP_MIDDLE) + TOKEN_TABLE(DOWN_LEFT) + TOKEN_TABLE(DOWN_RIGHT) + TOKEN_TABLE(DOWN_MIDDLE) + TOKEN_TABLE(MIDDLE_LEFT) + TOKEN_TABLE(MIDDLE_RIGHT) + TOKEN_TABLE(MIDDLE_MIDDLE) + TOKEN_TABLE(VERTICAL_TILES) + TOKEN_TABLE(HORIZONTAL_TILES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + bool hTiles = false, vTiles = false; + int h1 = 0, h2 = 0, h3 = 0; + int v1 = 0, v2 = 0, v3 = 0; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) { + _gameRef->LOG(0, "'TILED_IMAGE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSubFrame(_gameRef); + if (!_image || DID_FAIL(_image->setSurface((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_UP_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upLeft.left, &_upLeft.top, &_upLeft.right, &_upLeft.bottom); + break; + + case TOKEN_UP_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upRight.left, &_upRight.top, &_upRight.right, &_upRight.bottom); + break; + + case TOKEN_UP_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_upMiddle.left, &_upMiddle.top, &_upMiddle.right, &_upMiddle.bottom); + break; + + case TOKEN_DOWN_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downLeft.left, &_downLeft.top, &_downLeft.right, &_downLeft.bottom); + break; + + case TOKEN_DOWN_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downRight.left, &_downRight.top, &_downRight.right, &_downRight.bottom); + break; + + case TOKEN_DOWN_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_downMiddle.left, &_downMiddle.top, &_downMiddle.right, &_downMiddle.bottom); + break; + + case TOKEN_MIDDLE_LEFT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleLeft.left, &_middleLeft.top, &_middleLeft.right, &_middleLeft.bottom); + break; + + case TOKEN_MIDDLE_RIGHT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleRight.left, &_middleRight.top, &_middleRight.right, &_middleRight.bottom); + break; + + case TOKEN_MIDDLE_MIDDLE: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_middleMiddle.left, &_middleMiddle.top, &_middleMiddle.right, &_middleMiddle.bottom); + break; + + case TOKEN_HORIZONTAL_TILES: + parser.scanStr((char *)params, "%d,%d,%d", &h1, &h2, &h3); + hTiles = true; + break; + + case TOKEN_VERTICAL_TILES: + parser.scanStr((char *)params, "%d,%d,%d", &v1, &v2, &v3); + vTiles = true; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading TILED_IMAGE definition"); + return STATUS_FAILED; + } + + if (vTiles && hTiles) { + // up row + CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); + CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); + CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); + + // middle row + CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); + CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); + CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); + + // down row + CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); + CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); + CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); + } + + // default + if (_image && _image->_surface) { + int width = _image->_surface->getWidth() / 3; + int height = _image->_surface->getHeight() / 3; + + if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); + if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + + if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + + if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "TILED_IMAGE\n"); + buffer->putTextIndent(indent, "{\n"); + + if (_image && _image->_surfaceFilename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + + int h1, h2, h3; + int v1, v2, v3; + + h1 = _upLeft.right; + h2 = _upMiddle.right - _upMiddle.left; + h3 = _upRight.right - _upRight.left; + + v1 = _upLeft.bottom; + v2 = _middleLeft.bottom - _middleLeft.top; + v3 = _downLeft.bottom - _downLeft.top; + + + buffer->putTextIndent(indent + 2, "VERTICAL_TILES { %d, %d, %d }\n", v1, v2, v3); + buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CUITiledImage::correctSize(int *width, int *height) { + int tileWidth = _middleMiddle.right - _middleMiddle.left; + int tileHeight = _middleMiddle.bottom - _middleMiddle.top; + + int nuColumns = (*width - (_middleLeft.right - _middleLeft.left) - (_middleRight.right - _middleRight.left)) / tileWidth; + int nuRows = (*height - (_upMiddle.bottom - _upMiddle.top) - (_downMiddle.bottom - _downMiddle.top)) / tileHeight; + + *width = (_middleLeft.right - _middleLeft.left) + (_middleRight.right - _middleRight.left) + nuColumns * tileWidth; + *height = (_upMiddle.bottom - _upMiddle.top) + (_downMiddle.bottom - _downMiddle.top) + nuRows * tileHeight; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUITiledImage::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_downLeft)); + persistMgr->transfer(TMEMBER(_downMiddle)); + persistMgr->transfer(TMEMBER(_downRight)); + persistMgr->transfer(TMEMBER(_image)); + persistMgr->transfer(TMEMBER(_middleLeft)); + persistMgr->transfer(TMEMBER(_middleMiddle)); + persistMgr->transfer(TMEMBER(_middleRight)); + persistMgr->transfer(TMEMBER(_upLeft)); + persistMgr->transfer(TMEMBER(_upMiddle)); + persistMgr->transfer(TMEMBER(_upRight)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_tiled_image.h b/engines/wintermute/ui/ui_tiled_image.h new file mode 100644 index 0000000000..79adf7caac --- /dev/null +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -0,0 +1,63 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UITILEDIMAGE_H +#define WINTERMUTE_UITILEDIMAGE_H + + +#include "engines/wintermute/ui/ui_object.h" +#include "common/rect.h" + +namespace WinterMute { +class CBSubFrame; +class CUITiledImage : public CBObject { +public: + DECLARE_PERSISTENT(CUITiledImage, CBObject) + void correctSize(int *width, int *height); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + bool display(int x, int y, int width, int height); + CUITiledImage(CBGame *inGame = NULL); + virtual ~CUITiledImage(); + CBSubFrame *_image; + Rect32 _upLeft; + Rect32 _upMiddle; + Rect32 _upRight; + Rect32 _middleLeft; + Rect32 _middleMiddle; + Rect32 _middleRight; + Rect32 _downLeft; + Rect32 _downMiddle; + Rect32 _downRight; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp new file mode 100644 index 0000000000..269744a3c2 --- /dev/null +++ b/engines/wintermute/ui/ui_window.cpp @@ -0,0 +1,1327 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/ui/ui_button.h" +#include "engines/wintermute/ui/ui_edit.h" +#include "engines/wintermute/ui/ui_text.h" +#include "engines/wintermute/ui/ui_tiled_image.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CUIWindow, false) + +////////////////////////////////////////////////////////////////////////// +CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { + CBPlatform::setRectEmpty(&_titleRect); + CBPlatform::setRectEmpty(&_dragRect); + _titleAlign = TAL_LEFT; + _transparent = false; + + _backInactive = NULL; + _fontInactive = NULL; + _imageInactive = NULL; + + _type = UI_WINDOW; + _canFocus = true; + + _dragging = false; + _dragFrom.x = _dragFrom.y = 0; + + _mode = WINDOW_NORMAL; + _shieldWindow = NULL; + _shieldButton = NULL; + + _fadeColor = 0x00000000; + _fadeBackground = false; + + _ready = true; + _isMenu = false; + _inGame = false; + + _clipContents = false; + _viewport = NULL; + + _pauseMusic = true; +} + + +////////////////////////////////////////////////////////////////////////// +CUIWindow::~CUIWindow() { + close(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::cleanup() { + delete _shieldWindow; + delete _shieldButton; + delete _viewport; + _shieldWindow = NULL; + _shieldButton = NULL; + _viewport = NULL; + + delete _backInactive; + if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + if (!_sharedImages && _imageInactive) delete _imageInactive; + + for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; + _widgets.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::display(int offsetX, int offsetY) { + // go exclusive + if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { + if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (_shieldWindow) { + _shieldWindow->_posX = _shieldWindow->_posY = 0; + _shieldWindow->_width = _gameRef->_renderer->_width; + _shieldWindow->_height = _gameRef->_renderer->_height; + + _shieldWindow->display(); + } + } else if (_isMenu) { + if (!_shieldButton) { + _shieldButton = new CUIButton(_gameRef); + _shieldButton->setName("close"); + _shieldButton->setListener(this, _shieldButton, 0); + _shieldButton->_parent = this; + } + if (_shieldButton) { + _shieldButton->_posX = _shieldButton->_posY = 0; + _shieldButton->_width = _gameRef->_renderer->_width; + _shieldButton->_height = _gameRef->_renderer->_height; + + _shieldButton->display(); + } + } + + if (!_visible) + return STATUS_OK; + + if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); + + if (_dragging) { + _posX += (_gameRef->_mousePos.x - _dragFrom.x); + _posY += (_gameRef->_mousePos.y - _dragFrom.y); + + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; + } + + if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) { + moveFocus(); + } + + bool popViewport = false; + if (_clipContents) { + if (!_viewport) _viewport = new CBViewport(_gameRef); + if (_viewport) { + _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); + _gameRef->pushViewport(_viewport); + popViewport = true; + } + } + + + CUITiledImage *back = _back; + CBSprite *image = _image; + CBFont *font = _font; + + if (!isFocused()) { + if (_backInactive) back = _backInactive; + if (_imageInactive) image = _imageInactive; + if (_fontInactive) font = _fontInactive; + } + + if (_alphaColor != 0) + _gameRef->_renderer->_forceAlphaColor = _alphaColor; + if (back) + back->display(_posX + offsetX, _posY + offsetY, _width, _height); + if (image) + image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); + + if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { + font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); + } + + if (!_transparent && !image) + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + + for (int i = 0; i < _widgets.getSize(); i++) { + _widgets[i]->display(_posX + offsetX, _posY + offsetY); + } + + if (_alphaColor != 0) + _gameRef->_renderer->_forceAlphaColor = 0; + + if (popViewport) + _gameRef->popViewport(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(WINDOW) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(DISABLED) +TOKEN_DEF(VISIBLE) +TOKEN_DEF(BACK_INACTIVE) +TOKEN_DEF(BACK) +TOKEN_DEF(IMAGE_INACTIVE) +TOKEN_DEF(IMAGE) +TOKEN_DEF(FONT_INACTIVE) +TOKEN_DEF(FONT) +TOKEN_DEF(TITLE_ALIGN) +TOKEN_DEF(TITLE_RECT) +TOKEN_DEF(TITLE) +TOKEN_DEF(DRAG_RECT) +TOKEN_DEF(X) +TOKEN_DEF(Y) +TOKEN_DEF(WIDTH) +TOKEN_DEF(HEIGHT) +TOKEN_DEF(FADE_ALPHA) +TOKEN_DEF(FADE_COLOR) +TOKEN_DEF(CURSOR) +TOKEN_DEF(NAME) +TOKEN_DEF(BUTTON) +TOKEN_DEF(STATIC) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PARENT_NOTIFY) +TOKEN_DEF(MENU) +TOKEN_DEF(IN_GAME) +TOKEN_DEF(CLIP_CONTENTS) +TOKEN_DEF(PAUSE_MUSIC) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(EDIT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(WINDOW) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(DISABLED) + TOKEN_TABLE(VISIBLE) + TOKEN_TABLE(BACK_INACTIVE) + TOKEN_TABLE(BACK) + TOKEN_TABLE(IMAGE_INACTIVE) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(FONT_INACTIVE) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TITLE_ALIGN) + TOKEN_TABLE(TITLE_RECT) + TOKEN_TABLE(TITLE) + TOKEN_TABLE(DRAG_RECT) + TOKEN_TABLE(X) + TOKEN_TABLE(Y) + TOKEN_TABLE(WIDTH) + TOKEN_TABLE(HEIGHT) + TOKEN_TABLE(FADE_ALPHA) + TOKEN_TABLE(FADE_COLOR) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(NAME) + TOKEN_TABLE(BUTTON) + TOKEN_TABLE(STATIC) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PARENT_NOTIFY) + TOKEN_TABLE(MENU) + TOKEN_TABLE(IN_GAME) + TOKEN_TABLE(CLIP_CONTENTS) + TOKEN_TABLE(PAUSE_MUSIC) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(EDIT) + TOKEN_TABLE_END + + byte *params; + int cmd = 2; + CBParser parser(_gameRef); + + int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; + int ar = 0, ag = 0, ab = 0, alpha = 0; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) { + _gameRef->LOG(0, "'WINDOW' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_BACK: + delete _back; + _back = new CUITiledImage(_gameRef); + if (!_back || DID_FAIL(_back->loadFile((char *)params))) { + delete _back; + _back = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BACK_INACTIVE: + delete _backInactive; + _backInactive = new CUITiledImage(_gameRef); + if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { + delete _backInactive; + _backInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE: + delete _image; + _image = new CBSprite(_gameRef); + if (!_image || DID_FAIL(_image->loadFile((char *)params))) { + delete _image; + _image = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_IMAGE_INACTIVE: + delete _imageInactive, + _imageInactive = new CBSprite(_gameRef); + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { + delete _imageInactive; + _imageInactive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_FONT: + if (_font) _gameRef->_fontStorage->removeFont(_font); + _font = _gameRef->_fontStorage->addFont((char *)params); + if (!_font) cmd = PARSERR_GENERIC; + break; + + case TOKEN_FONT_INACTIVE: + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont((char *)params); + if (!_fontInactive) cmd = PARSERR_GENERIC; + break; + + case TOKEN_TITLE: + setText((char *)params); + _gameRef->_stringTable->expand(&_text); + break; + + case TOKEN_TITLE_ALIGN: + if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; + else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; + else _titleAlign = TAL_CENTER; + break; + + case TOKEN_TITLE_RECT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_titleRect.left, &_titleRect.top, &_titleRect.right, &_titleRect.bottom); + break; + + case TOKEN_DRAG_RECT: + parser.scanStr((char *)params, "%d,%d,%d,%d", &_dragRect.left, &_dragRect.top, &_dragRect.right, &_dragRect.bottom); + break; + + case TOKEN_X: + parser.scanStr((char *)params, "%d", &_posX); + break; + + case TOKEN_Y: + parser.scanStr((char *)params, "%d", &_posY); + break; + + case TOKEN_WIDTH: + parser.scanStr((char *)params, "%d", &_width); + break; + + case TOKEN_HEIGHT: + parser.scanStr((char *)params, "%d", &_height); + break; + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_BUTTON: { + CUIButton *btn = new CUIButton(_gameRef); + if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { + delete btn; + btn = NULL; + cmd = PARSERR_GENERIC; + } else { + btn->_parent = this; + _widgets.add(btn); + } + } + break; + + case TOKEN_STATIC: { + CUIText *text = new CUIText(_gameRef); + if (!text || DID_FAIL(text->loadBuffer(params, false))) { + delete text; + text = NULL; + cmd = PARSERR_GENERIC; + } else { + text->_parent = this; + _widgets.add(text); + } + } + break; + + case TOKEN_EDIT: { + CUIEdit *edit = new CUIEdit(_gameRef); + if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { + delete edit; + edit = NULL; + cmd = PARSERR_GENERIC; + } else { + edit->_parent = this; + _widgets.add(edit); + } + } + break; + + case TOKEN_WINDOW: { + CUIWindow *win = new CUIWindow(_gameRef); + if (!win || DID_FAIL(win->loadBuffer(params, false))) { + delete win; + win = NULL; + cmd = PARSERR_GENERIC; + } else { + win->_parent = this; + _widgets.add(win); + } + } + break; + + + case TOKEN_TRANSPARENT: + parser.scanStr((char *)params, "%b", &_transparent); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PARENT_NOTIFY: + parser.scanStr((char *)params, "%b", &_parentNotify); + break; + + case TOKEN_PAUSE_MUSIC: + parser.scanStr((char *)params, "%b", &_pauseMusic); + break; + + case TOKEN_DISABLED: + parser.scanStr((char *)params, "%b", &_disable); + break; + + case TOKEN_VISIBLE: + parser.scanStr((char *)params, "%b", &_visible); + break; + + case TOKEN_MENU: + parser.scanStr((char *)params, "%b", &_isMenu); + break; + + case TOKEN_IN_GAME: + parser.scanStr((char *)params, "%b", &_inGame); + break; + + case TOKEN_CLIP_CONTENTS: + parser.scanStr((char *)params, "%b", &_clipContents); + break; + + case TOKEN_FADE_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &fadeR, &fadeG, &fadeB); + _fadeBackground = true; + break; + + case TOKEN_FADE_ALPHA: + parser.scanStr((char *)params, "%d", &fadeA); + _fadeBackground = true; + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr((char *)params, "%d", &alpha); + break; + + + default: + if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) { + cmd = PARSERR_GENERIC; + } + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in WINDOW definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading WINDOW definition"); + return STATUS_FAILED; + } + + correctSize(); + + if (alpha != 0 && ar == 0 && ag == 0 && ab == 0) { + ar = ag = ab = 255; + } + _alphaColor = BYTETORGBA(ar, ag, ab, alpha); + + if (_fadeBackground) + _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); + + _focusedWidget = NULL; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "WINDOW\n"); + buffer->putTextIndent(indent, "{\n"); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_back && _back->_filename) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_backInactive && _backInactive->_filename) + buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + + if (_image && _image->_filename) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_imageInactive && _imageInactive->_filename) + buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + + if (_font && _font->_filename) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_fontInactive && _fontInactive->_filename) + buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + + if (_cursor && _cursor->_filename) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_text) + buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); + + switch (_titleAlign) { + case TAL_LEFT: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "left"); + break; + case TAL_RIGHT: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "right"); + break; + case TAL_CENTER: + buffer->putTextIndent(indent + 2, "TITLE_ALIGN=\"%s\"\n", "center"); + break; + default: + error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); + } + + if (!CBPlatform::isRectEmpty(&_titleRect)) { + buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); + } + + if (!CBPlatform::isRectEmpty(&_dragRect)) { + buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); + } + + buffer->putTextIndent(indent + 2, "\n"); + + buffer->putTextIndent(indent + 2, "X=%d\n", _posX); + buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); + buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); + buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); + + buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "TRANSPARENT=%s\n", _transparent ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PAUSE_MUSIC=%s\n", _pauseMusic ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "MENU=%s\n", _isMenu ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "IN_GAME=%s\n", _inGame ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CLIP_CONTENTS=%s\n", _clipContents ? "TRUE" : "FALSE"); + + buffer->putTextIndent(indent + 2, "\n"); + + if (_fadeBackground) { + buffer->putTextIndent(indent + 2, "FADE_COLOR { %d, %d, %d }\n", RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); + buffer->putTextIndent(indent + 2, "FADE_ALPHA=%d\n", RGBCOLGetA(_fadeColor)); + } + + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d, %d, %d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + buffer->putTextIndent(indent + 2, "ALPHA=%d\n", RGBCOLGetA(_alphaColor)); + + buffer->putTextIndent(indent + 2, "\n"); + + // scripts + for (int i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + buffer->putTextIndent(indent + 2, "\n"); + + // editor properties + CBBase::saveAsText(buffer, indent + 2); + + // controls + for (int i = 0; i < _widgets.getSize(); i++) + _widgets[i]->saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n"); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::enableWidget(const char *name, bool Enable) { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::showWidget(const char *name, bool Visible) { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetWidget / GetControl + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->getType() == VAL_INT) { + int widget = val->getInt(); + if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); + else stack->pushNative(_widgets[widget], true); + } else { + for (int i = 0; i < _widgets.getSize(); i++) { + if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { + stack->pushNative(_widgets[i], true); + return STATUS_OK; + } + } + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveFont + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInactiveFont") == 0) { + stack->correctParams(1); + + if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); + stack->pushBool(_fontInactive != NULL); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInactiveImage") == 0) { + stack->correctParams(1); + + delete _imageInactive; + _imageInactive = new CBSprite(_gameRef); + const char *filename = stack->pop()->getString(); + if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { + delete _imageInactive; + _imageInactive = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInactiveImage") == 0) { + stack->correctParams(0); + if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); + else stack->pushString(_imageInactive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInactiveImageObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInactiveImageObject") == 0) { + stack->correctParams(0); + if (!_imageInactive) stack->pushNULL(); + else stack->pushNative(_imageInactive, true); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(close())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoExclusive") == 0) { + stack->correctParams(0); + goExclusive(); + script->waitFor(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GoSystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GoSystemExclusive") == 0) { + stack->correctParams(0); + goSystemExclusive(); + script->waitFor(this); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Center + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Center") == 0) { + stack->correctParams(0); + _posX = (_gameRef->_renderer->_width - _width) / 2; + _posY = (_gameRef->_renderer->_height - _height) / 2; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadFromFile + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadFromFile") == 0) { + stack->correctParams(1); + + CScValue *val = stack->pop(); + cleanup(); + if (!val->isNULL()) { + stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateButton + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateButton") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIButton *btn = new CUIButton(_gameRef); + if (!val->isNULL()) btn->setName(val->getString()); + stack->pushNative(btn, true); + + btn->_parent = this; + _widgets.add(btn); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateStatic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateStatic") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIText *sta = new CUIText(_gameRef); + if (!val->isNULL()) sta->setName(val->getString()); + stack->pushNative(sta, true); + + sta->_parent = this; + _widgets.add(sta); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateEditor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateEditor") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIEdit *edi = new CUIEdit(_gameRef); + if (!val->isNULL()) edi->setName(val->getString()); + stack->pushNative(edi, true); + + edi->_parent = this; + _widgets.add(edi); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + + win->_parent = this; + _widgets.add(win); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CUIObject *obj = (CUIObject *)val->getNative(); + + for (int i = 0; i < _widgets.getSize(); i++) { + if (_widgets[i] == obj) { + delete _widgets[i]; + _widgets.removeAt(i); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + } + } + stack->pushNULL(); + return STATUS_OK; + } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; + + else return CUIObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CUIWindow::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("window"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumWidgets / NumControls (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { + _scValue->setInt(_widgets.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exclusive") == 0) { + _scValue->setBool(_mode == WINDOW_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SystemExclusive") == 0) { + _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Menu") == 0) { + _scValue->setBool(_isMenu); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InGame") == 0) { + _scValue->setBool(_inGame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0) { + _scValue->setBool(_pauseMusic); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClipContents") == 0) { + _scValue->setBool(_clipContents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Transparent") == 0) { + _scValue->setBool(_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeColor") == 0) { + _scValue->setInt((int)_fadeColor); + return _scValue; + } + + else return CUIObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Menu + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Menu") == 0) { + _isMenu = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InGame") == 0) { + _inGame = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0) { + _pauseMusic = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClipContents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClipContents") == 0) { + _clipContents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Transparent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Transparent") == 0) { + _transparent = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeColor") == 0) { + _fadeColor = (uint32)value->getInt(); + _fadeBackground = (_fadeColor != 0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exclusive") == 0) { + if (value->getBool()) + goExclusive(); + else { + close(); + _visible = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SystemExclusive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SystemExclusive") == 0) { + if (value->getBool()) + goSystemExclusive(); + else { + close(); + _visible = true; + } + return STATUS_OK; + } + + else return CUIObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CUIWindow::scToString() { + return "[window]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { +//TODO + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { + return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); + } else { + if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); + else return false; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleMouseWheel(int Delta) { + if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + bool res = CUIObject::handleMouse(event, button); + + // handle window dragging + if (!CBPlatform::isRectEmpty(&_dragRect)) { + // start drag + if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { + Rect32 dragRect = _dragRect; + int offsetX, offsetY; + getTotalOffset(&offsetX, &offsetY); + CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); + + if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { + _dragFrom.x = _gameRef->_mousePos.x; + _dragFrom.y = _gameRef->_mousePos.y; + _dragging = true; + } + } + // end drag + else if (_dragging && event == MOUSE_RELEASE && button == MOUSE_BUTTON_LEFT) { + _dragging = false; + } + } + + return res; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::persist(CBPersistMgr *persistMgr) { + + CUIObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_backInactive)); + persistMgr->transfer(TMEMBER(_clipContents)); + persistMgr->transfer(TMEMBER(_dragFrom)); + persistMgr->transfer(TMEMBER(_dragging)); + persistMgr->transfer(TMEMBER(_dragRect)); + persistMgr->transfer(TMEMBER(_fadeBackground)); + persistMgr->transfer(TMEMBER(_fadeColor)); + persistMgr->transfer(TMEMBER(_fontInactive)); + persistMgr->transfer(TMEMBER(_imageInactive)); + persistMgr->transfer(TMEMBER(_inGame)); + persistMgr->transfer(TMEMBER(_isMenu)); + persistMgr->transfer(TMEMBER_INT(_mode)); + persistMgr->transfer(TMEMBER(_shieldButton)); + persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transfer(TMEMBER_INT(_titleAlign)); + persistMgr->transfer(TMEMBER(_titleRect)); + persistMgr->transfer(TMEMBER(_transparent)); + persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transfer(TMEMBER(_pauseMusic)); + + _widgets.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::moveFocus(bool forward) { + int i; + bool found = false; + for (i = 0; i < _widgets.getSize(); i++) { + if (_widgets[i] == _focusedWidget) { + found = true; + break; + } + } + if (!found) _focusedWidget = NULL; + + if (!_focusedWidget) { + if (_widgets.getSize() > 0) i = 0; + else return STATUS_OK; + } + + int numTries = 0; + bool done = false; + + while (numTries <= _widgets.getSize()) { + if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { + _focusedWidget = _widgets[i]; + done = true; + break; + } + + if (forward) { + i++; + if (i >= _widgets.getSize()) i = 0; + } else { + i--; + if (i < 0) i = _widgets.getSize() - 1; + } + numTries++; + } + + return done ? STATUS_OK : STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::goExclusive() { + if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; + + if (_mode == WINDOW_NORMAL) { + _ready = false; + _mode = WINDOW_EXCLUSIVE; + _visible = true; + _disable = false; + _gameRef->focusWindow(this); + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::goSystemExclusive() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; + + makeFreezable(false); + + _mode = WINDOW_SYSTEM_EXCLUSIVE; + _ready = false; + _visible = true; + _disable = false; + _gameRef->focusWindow(this); + + _gameRef->freeze(_pauseMusic); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::close() { + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { + _gameRef->unfreeze(); + } + + _mode = WINDOW_NORMAL; + _visible = false; + _ready = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { + CUIObject *obj = (CUIObject *)param1; + + switch (obj->_type) { + case UI_BUTTON: + if (scumm_stricmp(obj->_name, "close") == 0) close(); + else return CBObject::listen(param1, param2); + break; + default: + return CBObject::listen(param1, param2); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CUIWindow::makeFreezable(bool freezable) { + for (int i = 0; i < _widgets.getSize(); i++) + _widgets[i]->makeFreezable(freezable); + + CBObject::makeFreezable(freezable); +} + + +////////////////////////////////////////////////////////////////////////// +bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { + for (int i = 0; i < _widgets.getSize(); i++) { + CUIObject *control = _widgets[i]; + if (control->_disable && interactiveOnly) continue; + + switch (control->_type) { + case UI_WINDOW: + ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); + break; + + case UI_BUTTON: + case UI_EDIT: + objects.add(control); + break; + + default: + if (!interactiveOnly) objects.add(control); + } + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h new file mode 100644 index 0000000000..6fe24c6a2c --- /dev/null +++ b/engines/wintermute/ui/ui_window.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_UIWINDOW_H +#define WINTERMUTE_UIWINDOW_H + + +#include "engines/wintermute/ui/ui_object.h" +#include "common/events.h" + +namespace WinterMute { + +class CUIButton; +class CBViewport; +class CUIWindow : public CUIObject { +public: + bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); + + bool _pauseMusic; + void cleanup(); + virtual void makeFreezable(bool freezable); + CBViewport *_viewport; + bool _clipContents; + bool _inGame; + bool _isMenu; + bool _fadeBackground; + uint32 _fadeColor; + virtual bool handleMouseWheel(int delta); + CUIWindow *_shieldWindow; + CUIButton *_shieldButton; + bool close(); + bool goSystemExclusive(); + bool goExclusive(); + TWindowMode _mode; + bool moveFocus(bool forward = true); + virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); + Point32 _dragFrom; + bool _dragging; + DECLARE_PERSISTENT(CUIWindow, CUIObject) + bool _transparent; + bool showWidget(const char *name, bool visible = true); + bool enableWidget(const char *name, bool enable = true); + Rect32 _titleRect; + Rect32 _dragRect; + virtual bool display(int offsetX = 0, int offsetY = 0); + CUIWindow(CBGame *inGame); + virtual ~CUIWindow(); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + CBArray _widgets; + TTextAlign _titleAlign; + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + CUITiledImage *_backInactive; + CBFont *_fontInactive; + CBSprite *_imageInactive; + virtual bool listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/utils/ConvertUTF.cpp b/engines/wintermute/utils/ConvertUTF.cpp deleted file mode 100644 index 8f7d6d2124..0000000000 --- a/engines/wintermute/utils/ConvertUTF.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Source code file. - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Sept 2001: fixed const & error conditions per - mods suggested by S. Parent & A. Lillich. - June 2002: Tim Dodd added detection and handling of incomplete - source sequences, enhanced error detection, added casts - to eliminate compiler warnings. - July 2003: slight mods to back out aggressive FFFE detection. - Jan 2004: updated switches in from-UTF8 conversions. - Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. - - See the header file "ConvertUTF.h" for complete documentation. - ------------------------------------------------------------------------- */ - - -#include "ConvertUTF.h" -#ifdef CVTUTF_DEBUG -#include -#endif - -static const int halfShift = 10; /* used for shifting by 10 bits */ - -static const UTF32 halfBase = 0x0010000UL; -static const UTF32 halfMask = 0x3FFUL; - -#define UNI_SUR_HIGH_START (UTF32)0xD800 -#define UNI_SUR_HIGH_END (UTF32)0xDBFF -#define UNI_SUR_LOW_START (UTF32)0xDC00 -#define UNI_SUR_LOW_END (UTF32)0xDFFF -#define false 0 -#define true 1 - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - if (target >= targetEnd) { - result = targetExhausted; - break; - } - ch = *source++; - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_LEGAL_UTF32) { - if (flags == strictConversion) { - result = sourceIllegal; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - --source; /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF32 *target = *targetStart; - UTF32 ch, ch2; - while (source < sourceEnd) { - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - if (target >= targetEnd) { - source = oldSource; /* Back up source pointer! */ - result = targetExhausted; - break; - } - *target++ = ch; - } - *sourceStart = source; - *targetStart = target; -#ifdef CVTUTF_DEBUG - if (result == sourceIllegal) { - fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); - fflush(stderr); - } -#endif - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Index into the table below with the first byte of a UTF-8 sequence to - * get the number of trailing bytes that are supposed to follow it. - * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is - * left as-is for anyone who may want to do such conversion, which was - * allowed in earlier algorithms. - */ -static const char trailingBytesForUTF8[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 -}; - -/* - * Magic values subtracted from a buffer value during UTF8 conversion. - * This table contains as many values as there might be trailing bytes - * in a UTF-8 sequence. - */ -static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL - }; - -/* - * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed - * into the first byte, depending on how many bytes follow. There are - * as many entries in this table as there are UTF-8 sequence types. - * (I.e., one byte sequence, two byte... etc.). Remember that sequencs - * for *legal* UTF-8 will be 4 or fewer bytes total. - */ -static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -/* --------------------------------------------------------------------- */ - -/* The interface converts a whole buffer to avoid function-call overhead. - * Constants have been gathered. Loops & conditionals have been removed as - * much as possible for efficiency, in favor of drop-through switches. - * (See "Note A" at the bottom of the file for equivalent code.) - * If your compiler supports it, the "isLegalUTF8" call can be turned - * into an inline function. - */ - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - UTF32 ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* Figure out how many bytes the result will require */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch < (UTF32)0x110000) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - } - - target += bytesToWrite; - if (target > targetEnd) { - source = oldSource; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -/* - * Utility routine to tell whether a sequence of bytes is legal UTF-8. - * This must be called with the length pre-determined by the first byte. - * If not calling this from ConvertUTF8to*, then the length can be set by: - * length = trailingBytesForUTF8[*source]+1; - * and the sequence is illegal right away if there aren't that many bytes - * available. - * If presented with a length > 4, this returns false. The Unicode - * definition of UTF-8 goes up to 4-byte sequences. - */ - -static Boolean isLegalUTF8(const UTF8 *source, int length) { - UTF8 a; - const UTF8 *srcptr = source + length; - switch (length) { - default: - return false; - /* Everything else falls through when "true"... */ - case 4: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: - if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: - if ((a = (*--srcptr)) > 0xBF) return false; - - switch (*source) { - /* no fall-through in this inner switch */ - case 0xE0: - if (a < 0xA0) return false; - break; - case 0xED: - if (a > 0x9F) return false; - break; - case 0xF0: - if (a < 0x90) return false; - break; - case 0xF4: - if (a > 0x8F) return false; - break; - default: - if (a < 0x80) return false; - } - - case 1: - if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; -} - -/* --------------------------------------------------------------------- */ - -/* - * Exported function to return whether a UTF-8 sequence is legal or not. - * This is not used here; it's just exported. - */ -Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { - int length = trailingBytesForUTF8[*source] + 1; - if (source + length > sourceEnd) { - return false; - } - return isLegalUTF8(source, length); -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF16 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 4: - ch += *source++; - ch <<= 6; /* remember, illegal UTF-8 */ - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_UTF16) { - if (flags == strictConversion) { - result = sourceIllegal; - source -= (extraBytesToRead + 1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up source pointer! */ - result = targetExhausted; - break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF32 *source = *sourceStart; - UTF8 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - ch = *source++; - if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* - * Figure out how many bytes the result will require. Turn any - * illegally large UTF32 things (> Plane 17) into replacement chars. - */ - if (ch < (UTF32)0x80) { - bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { - bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { - bytesToWrite = 3; - } else if (ch <= UNI_MAX_LEGAL_UTF32) { - bytesToWrite = 4; - } else { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - result = sourceIllegal; - } - - target += bytesToWrite; - if (target > targetEnd) { - --source; /* Back up source pointer! */ - target -= bytesToWrite; - result = targetExhausted; - break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 3: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 2: - *--target = (UTF8)((ch | byteMark) & byteMask); - ch >>= 6; - case 1: - *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); - } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- */ - -ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8 *source = *sourceStart; - UTF32 *target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; - break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead + 1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: - ch += *source++; - ch <<= 6; - case 4: - ch += *source++; - ch <<= 6; - case 3: - ch += *source++; - ch <<= 6; - case 2: - ch += *source++; - ch <<= 6; - case 1: - ch += *source++; - ch <<= 6; - case 0: - ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (target >= targetEnd) { - source -= (extraBytesToRead + 1); /* Back up the source pointer! */ - result = targetExhausted; - break; - } - if (ch <= UNI_MAX_LEGAL_UTF32) { - /* - * UTF-16 surrogate values are illegal in UTF-32, and anything - * over Plane 17 (> 0x10FFFF) is illegal. - */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead + 1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - *target++ = ch; - } - } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ - result = sourceIllegal; - *target++ = UNI_REPLACEMENT_CHAR; - } - } - *sourceStart = source; - *targetStart = target; - return result; -} - -/* --------------------------------------------------------------------- - - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - In UTF-8 writing code, the switches on "bytesToWrite" are - similarly unrolled loops. - - --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/ConvertUTF.h b/engines/wintermute/utils/ConvertUTF.h deleted file mode 100644 index 03a8bb2bae..0000000000 --- a/engines/wintermute/utils/ConvertUTF.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Header file. - - Several funtions are included here, forming a complete set of - conversions between the three formats. UTF-7 is not included - here, but is handled in a separate source file. - - Each of these routines takes pointers to input buffers and output - buffers. The input buffers are const. - - Each routine converts the text between *sourceStart and sourceEnd, - putting the result into the buffer between *targetStart and - targetEnd. Note: the end pointers are *after* the last item: e.g. - *(sourceEnd - 1) is the last item. - - The return result indicates whether the conversion was successful, - and if not, whether the problem was in the source or target buffers. - (Only the first encountered problem is indicated.) - - After the conversion, *sourceStart and *targetStart are both - updated to point to the end of last text successfully converted in - the respective buffers. - - Input parameters: - sourceStart - pointer to a pointer to the source buffer. - The contents of this are modified on return so that - it points at the next thing to be converted. - targetStart - similarly, pointer to pointer to the target buffer. - sourceEnd, targetEnd - respectively pointers to the ends of the - two buffers, for overflow checking only. - - These conversion functions take a ConversionFlags argument. When this - flag is set to strict, both irregular sequences and isolated surrogates - will cause an error. When the flag is set to lenient, both irregular - sequences and isolated surrogates are converted. - - Whether the flag is strict or lenient, all illegal sequences will cause - an error return. This includes sequences such as: , , - or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code - must check for illegal sequences. - - When the flag is set to lenient, characters over 0x10FFFF are converted - to the replacement character; otherwise (when the flag is set to strict) - they constitute an error. - - Output parameters: - The value "sourceIllegal" is returned from some routines if the input - sequence is malformed. When "sourceIllegal" is returned, the source - value will point to the illegal value that caused the problem. E.g., - in UTF-8 when a sequence is malformed, it points to the start of the - malformed sequence. - - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Fixes & updates, Sept 2001. - ------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------- - The following 4 definitions are compiler-specific. - The C standard does not guarantee that wchar_t has at least - 16 bits, so wchar_t is no less portable than unsigned short! - All should be unsigned values to avoid sign extension during - bit mask & shift operations. ------------------------------------------------------------------------- */ - -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ - -/* Some fundamental constants */ -#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD -#define UNI_MAX_BMP (UTF32)0x0000FFFF -#define UNI_MAX_UTF16 (UTF32)0x0010FFFF -#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF -#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF - -typedef enum { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ -} ConversionResult; - -typedef enum { - strictConversion = 0, - lenientConversion -} ConversionFlags; - -/* This is for C++ and does no harm in C */ -#ifdef __cplusplus -extern "C" { -#endif - - ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - - ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - - Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); - -#ifdef __cplusplus -} -#endif - -/* --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp deleted file mode 100644 index 7fa06cf682..0000000000 --- a/engines/wintermute/utils/PathUtil.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "common/file.h" -#include "PathUtil.h" -#include "StringUtil.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::unifySeparators(const AnsiString &path) { - AnsiString newPath = path; - - AnsiString::iterator it; - for (it = newPath.begin(); it != newPath.end(); it++) { - if (*it == '\\') *it = '/'; - } - return newPath; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::normalizeFileName(const AnsiString &path) { - AnsiString newPath = unifySeparators(path); - newPath.toLowercase(); - return newPath; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { - AnsiString newPath1 = unifySeparators(path1); - AnsiString newPath2 = unifySeparators(path2); - - if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) - newPath1 += "/"; - - return newPath1 + newPath2; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getDirectoryName(const AnsiString &path) { - AnsiString newPath = unifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); - Common::String filename = getFileName(path); - return Common::String(path.c_str(), path.size() - filename.size()); - //if (pos == AnsiString::npos) return ""; - //else return newPath.substr(0, pos + 1); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getFileName(const AnsiString &path) { - AnsiString newPath = unifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. - Common::String lastPart = Common::lastPathComponent(path, '/'); - if (lastPart[lastPart.size() - 1 ] != '/') - return lastPart; - else - return path; - //if (pos == AnsiString::npos) return path; - //else return newPath.substr(pos + 1); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { - AnsiString fileName = getFileName(path); - - //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! - // TODO: Prettify this. - Common::String extension = Common::lastPathComponent(path, '.'); - Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); - return filename; - //if (pos == AnsiString::npos) return fileName; - //else return fileName.substr(0, pos); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getExtension(const AnsiString &path) { - AnsiString fileName = getFileName(path); - - //size_t pos = fileName.find_last_of('.'); - return Common::lastPathComponent(path, '.'); - //if (pos == AnsiString::npos) return ""; - //else return fileName.substr(pos); -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getSafeLogFileName() { - AnsiString logFileName = getUserDirectory(); - -/*#ifdef __WIN32__ - char moduleName[MAX_PATH_LENGTH]; - ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); - - AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; - fileName = Combine("/Wintermute Engine/Logs/", fileName); - logFileName = Combine(logFileName, fileName); - -#else*/ - // !PORTME - logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); -//#endif - - createDirectory(getDirectoryName(logFileName)); - return logFileName; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::createDirectory(const AnsiString &path) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::matchesMask(const AnsiString &fileName, const AnsiString &mask) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::fileExists(const AnsiString &fileName) { - warning("PathUtil::FileExists(%s)", fileName.c_str()); - - Common::File stream; - - stream.open(fileName.c_str()); - bool ret = stream.isOpen(); - stream.close(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getUserDirectory() { - warning("PathUtil::GetUserDirectory - stubbed"); - AnsiString userDir = "./"; -#if 0 -#ifdef __WIN32__ - char buffer[MAX_PATH_LENGTH]; - buffer[0] = '\0'; - LPITEMIDLIST pidl = NULL; - LPMALLOC pMalloc; - if (DID_SUCCEED(SHGetMalloc(&pMalloc))) { - SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - if (pidl) { - SHGetPathFromIDList(pidl, buffer); - } - pMalloc->Free(pidl); - userDir = AnsiString(buffer); - } -#elif __MACOSX__ - FSRef fileRef; - OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); - if (error == noErr) { - char buffer[MAX_PATH_LENGTH]; - error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); - if (error == noErr) - userDir = buffer; - - } -#elif __IPHONEOS__ - char path[MAX_PATH_LENGTH]; - IOS_GetDataDir(path); - userDir = AnsiString(path); -#endif -#endif // 0 - return userDir; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/utils/PathUtil.h b/engines/wintermute/utils/PathUtil.h deleted file mode 100644 index 139ce89ddd..0000000000 --- a/engines/wintermute/utils/PathUtil.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PATHUTILS_H -#define WINTERMUTE_PATHUTILS_H - -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -class PathUtil { -public: - static AnsiString unifySeparators(const AnsiString &path); - static AnsiString normalizeFileName(const AnsiString &path); - static AnsiString combine(const AnsiString &path1, const AnsiString &path2); - static AnsiString getDirectoryName(const AnsiString &path); - static AnsiString getFileName(const AnsiString &path); - static AnsiString getFileNameWithoutExtension(const AnsiString &path); - static AnsiString getExtension(const AnsiString &path); - static bool createDirectory(const AnsiString &path); - static bool matchesMask(const AnsiString &fileName, const AnsiString &mask); - - static bool fileExists(const AnsiString &fileName); - - static AnsiString getSafeLogFileName(); - static AnsiString getUserDirectory(); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp deleted file mode 100644 index 303e7b1131..0000000000 --- a/engines/wintermute/utils/StringUtil.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "common/tokenizer.h" -#include "StringUtil.h" -#include "ConvertUTF.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { - return (str1.compareToIgnoreCase(str2) == 0); -} - -////////////////////////////////////////////////////////////////////////// -/*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { - WideString str1lc = str1; - WideString str2lc = str2; - - ToLowerCase(str1lc); - ToLowerCase(str2lc); - - return (str1lc == str2lc); -}*/ - -////////////////////////////////////////////////////////////////////////// -WideString StringUtil::utf8ToWide(const Utf8String &Utf8Str) { - error("StringUtil::Utf8ToWide - WideString not supported yet"); - /* size_t WideSize = Utf8Str.size(); - - if (sizeof(wchar_t) == 2) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF16 *TargetStart = reinterpret_cast(WideStringNative); - UTF16 *TargetEnd = TargetStart + WideSize + 1; - - ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else if (sizeof(wchar_t) == 4) { - wchar_t *WideStringNative = new wchar_t[WideSize + 1]; - - const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); - const UTF8 *SourceEnd = SourceStart + WideSize; - - UTF32 *TargetStart = reinterpret_cast(WideStringNative); - UTF32 *TargetEnd = TargetStart + WideSize; - - ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] WideStringNative; - return L""; - } - *TargetStart = 0; - WideString ResultString(WideStringNative); - delete [] WideStringNative; - - return ResultString; - } else { - return L""; - }*/ - return ""; -} - -////////////////////////////////////////////////////////////////////////// -Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { - error("StringUtil::wideToUtf8 - Widestring not supported yet"); - /* size_t WideSize = WideStr.length(); - - if (sizeof(wchar_t) == 2) { - size_t Utf8Size = 3 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF16 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else if (sizeof(wchar_t) == 4) { - size_t Utf8Size = 4 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; - - const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); - const UTF32 *SourceEnd = SourceStart + WideSize; - - UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); - UTF8 *TargetEnd = TargetStart + Utf8Size; - - ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); - if (res != conversionOK) { - delete [] Utf8StringNative; - return (Utf8String)""; - } - *TargetStart = 0; - Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; - return ResultString; - } else { - return (Utf8String)""; - }*/ - return ""; -} - -// Currently this only does Ansi->ISO 8859, and only for carets. -char simpleAnsiToWide(const AnsiString &str, uint32 &offset) { - char c = str[offset]; - - if (c == 92) { - offset++; - return '\''; - } else { - offset++; - return c; - } -} - -////////////////////////////////////////////////////////////////////////// -WideString StringUtil::ansiToWide(const AnsiString &str) { - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("StringUtil::AnsiToWide - WideString not supported yet"); - } - /*Common::String converted = ""; - uint32 index = 0; - while (index != str.size()) { - converted += simpleAnsiToWide(str, index); - }*/ - // using default os locale! - - /* setlocale(LC_CTYPE, ""); - size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; - wchar_t *wstr = new wchar_t[WideSize]; - mbstowcs(wstr, str.c_str(), WideSize); - WideString ResultString(wstr); - delete [] wstr; - return ResultString;*/ - return WideString(str); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::wideToAnsi(const WideString &wstr) { - // using default os locale! - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("StringUtil::WideToAnsi - WideString not supported yet"); - } - /* setlocale(LC_CTYPE, ""); - size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; - char *str = new char[WideSize]; - wcstombs(str, wstr.c_str(), WideSize); - AnsiString ResultString(str); - delete [] str; - return ResultString;*/ - return AnsiString(wstr); -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString startPart = str.substr(0, patternLength); - - if (ignoreCase) return CompareNoCase(startPart, pattern); - else return (startPart == pattern);*/ - if (!ignoreCase) - return str.hasPrefix(pattern); - else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString startPart(str.c_str(), patternLength); - uint32 likeness = startPart.compareToIgnoreCase(pattern.c_str()); - return (likeness == 0); - } -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); // TODO: Remove - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString endPart = str.substr(strLength - patternLength, patternLength); - - if (ignoreCase) return CompareNoCase(endPart, pattern); - else return (endPart == pattern);*/ - if (!ignoreCase) { - return str.hasSuffix(pattern); - } else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); - uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); - return (likeness != 0); - } -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { - if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; - else return false; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { - if (from.empty() || from == to) return str; - - AnsiString result = str; - /*size_t pos = 0;*/ - - while (result.contains(from)) { - const char *startPtr = strstr(result.c_str(), from.c_str()); - uint32 index = startPtr - result.c_str(); - - Common::String tail(result.c_str() + index + to.size()); - result = Common::String(result.c_str(), index); - result += to; - result += tail; - - /* pos = result.find(from, pos); - if (pos == result.npos) break; - - result.replace(pos, from.size(), to); - pos += to.size();*/ - } - - return result; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { - AnsiString trimmedStr = str; - - if (fromRight) { - //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO - warning("fromRight-trim not implemented yet, %s", chars.c_str()); - } - if (fromLeft) { - uint32 lastOf = lastIndexOf(str, chars, 0); - trimmedStr = Common::String(trimmedStr.c_str() + lastOf); - //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); - } - return trimmedStr; -} - -////////////////////////////////////////////////////////////////////////// -int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.find(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ - const char *index = strstr(str.c_str(), toFind.c_str()); - if (index == NULL) - return -1; - else - return index - str.c_str(); -} - -////////////////////////////////////////////////////////////////////////// -int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.rfind(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ - int32 lastIndex = -1; - bool found = false; - for (size_t i = startFrom; i < str.size(); i++) { - found = false; - for (size_t j = 0; j < toFind.size(); j++) { - if (str[i + j] != toFind[j]) { - found = false; - break; - } else { - found = true; - } - } - if (found) - lastIndex = i; - } - return lastIndex; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(size_t val) { - return Common::String::format("%u", (uint32)val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(int val) { - return Common::String::format("%d", val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(float val) { - return Common::String::format("%f", val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(double val) { - return Common::String::format("%f", val); -} - - -////////////////////////////////////////////////////////////////////////// -void StringUtil::split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { - result.clear(); -//TODO: Verify this, wrt keepEmptyItems. - Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); - //typedef boost::char_separator separator_t; - //typedef boost::tokenizer tokenizer_t; - - //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); - //tokenizer_t tokens(list, del); - while (!tokenizer.empty()) { - Common::String copy(tokenizer.nextToken().c_str()); - result.push_back(copy); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h deleted file mode 100644 index bd1b71f405..0000000000 --- a/engines/wintermute/utils/StringUtil.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_STRINGUTIL_H -#define WINTERMUTE_STRINGUTIL_H - -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -class StringUtil { -public: - static bool compareNoCase(const AnsiString &str1, const AnsiString &str2); - //static bool compareNoCase(const WideString &str1, const WideString &str2); - static WideString utf8ToWide(const Utf8String &Utf8Str); - static Utf8String wideToUtf8(const WideString &WideStr); - static WideString ansiToWide(const AnsiString &str); - static AnsiString wideToAnsi(const WideString &str); - - static bool startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - - static bool isUtf8BOM(const byte *buffer, uint32 bufferSize); - - static AnsiString replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); - static AnsiString trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); - - static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static int lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - - static AnsiString toString(size_t val); - static AnsiString toString(int val); - static AnsiString toString(float val); - static AnsiString toString(double val); - - static void split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/utils/convert_utf.cpp b/engines/wintermute/utils/convert_utf.cpp new file mode 100644 index 0000000000..db0c0fa9f9 --- /dev/null +++ b/engines/wintermute/utils/convert_utf.cpp @@ -0,0 +1,612 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "engines/wintermute/utils/convert_utf.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; + break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF32 *target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; + break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG + if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); + } +#endif + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16 *oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source + length; + switch (length) { + default: + return false; + /* Everything else falls through when "true"... */ + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) return false; + break; + case 0xED: + if (a > 0x9F) return false; + break; + case 0xF0: + if (a < 0x90) return false; + break; + case 0xF4: + if (a > 0x8F) return false; + break; + default: + if (a < 0x80) return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source] + 1; + if (source + length > sourceEnd) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF16 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 4: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32 *source = *sourceStart; + UTF8 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8 *source = *sourceStart; + UTF32 *target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; + case 4: + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up the source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_LEGAL_UTF32) { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = ch; + } + } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/convert_utf.h b/engines/wintermute/utils/convert_utf.h new file mode 100644 index 0000000000..03a8bb2bae --- /dev/null +++ b/engines/wintermute/utils/convert_utf.h @@ -0,0 +1,149 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that wchar_t has at least + 16 bits, so wchar_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + + ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); + + ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); + + Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp index 0bce1c4c51..933857e066 100644 --- a/engines/wintermute/utils/crc.cpp +++ b/engines/wintermute/utils/crc.cpp @@ -15,7 +15,7 @@ * expressed or implied by its publication or distribution. **********************************************************************/ -#include "crc.h" +#include "engines/wintermute/utils/crc.h" /* diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp new file mode 100644 index 0000000000..6b6b2d6b96 --- /dev/null +++ b/engines/wintermute/utils/path_util.cpp @@ -0,0 +1,196 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "common/file.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::unifySeparators(const AnsiString &path) { + AnsiString newPath = path; + + AnsiString::iterator it; + for (it = newPath.begin(); it != newPath.end(); it++) { + if (*it == '\\') *it = '/'; + } + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::normalizeFileName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + newPath.toLowercase(); + return newPath; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { + AnsiString newPath1 = unifySeparators(path1); + AnsiString newPath2 = unifySeparators(path2); + + if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) + newPath1 += "/"; + + return newPath1 + newPath2; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getDirectoryName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + + //size_t pos = newPath.find_last_of(L'/'); + Common::String filename = getFileName(path); + return Common::String(path.c_str(), path.size() - filename.size()); + //if (pos == AnsiString::npos) return ""; + //else return newPath.substr(0, pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getFileName(const AnsiString &path) { + AnsiString newPath = unifySeparators(path); + + //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. + Common::String lastPart = Common::lastPathComponent(path, '/'); + if (lastPart[lastPart.size() - 1 ] != '/') + return lastPart; + else + return path; + //if (pos == AnsiString::npos) return path; + //else return newPath.substr(pos + 1); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); + + //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! + // TODO: Prettify this. + Common::String extension = Common::lastPathComponent(path, '.'); + Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); + return filename; + //if (pos == AnsiString::npos) return fileName; + //else return fileName.substr(0, pos); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getExtension(const AnsiString &path) { + AnsiString fileName = getFileName(path); + + //size_t pos = fileName.find_last_of('.'); + return Common::lastPathComponent(path, '.'); + //if (pos == AnsiString::npos) return ""; + //else return fileName.substr(pos); +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getSafeLogFileName() { + AnsiString logFileName = getUserDirectory(); + +/*#ifdef __WIN32__ + char moduleName[MAX_PATH_LENGTH]; + ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); + + AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; + fileName = Combine("/Wintermute Engine/Logs/", fileName); + logFileName = Combine(logFileName, fileName); + +#else*/ + // !PORTME + logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); +//#endif + + createDirectory(getDirectoryName(logFileName)); + return logFileName; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::createDirectory(const AnsiString &path) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::matchesMask(const AnsiString &fileName, const AnsiString &mask) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool PathUtil::fileExists(const AnsiString &fileName) { + warning("PathUtil::FileExists(%s)", fileName.c_str()); + + Common::File stream; + + stream.open(fileName.c_str()); + bool ret = stream.isOpen(); + stream.close(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +AnsiString PathUtil::getUserDirectory() { + warning("PathUtil::GetUserDirectory - stubbed"); + AnsiString userDir = "./"; +#if 0 +#ifdef __WIN32__ + char buffer[MAX_PATH_LENGTH]; + buffer[0] = '\0'; + LPITEMIDLIST pidl = NULL; + LPMALLOC pMalloc; + if (DID_SUCCEED(SHGetMalloc(&pMalloc))) { + SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); + if (pidl) { + SHGetPathFromIDList(pidl, buffer); + } + pMalloc->Free(pidl); + userDir = AnsiString(buffer); + } +#elif __MACOSX__ + FSRef fileRef; + OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); + if (error == noErr) { + char buffer[MAX_PATH_LENGTH]; + error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); + if (error == noErr) + userDir = buffer; + + } +#elif __IPHONEOS__ + char path[MAX_PATH_LENGTH]; + IOS_GetDataDir(path); + userDir = AnsiString(path); +#endif +#endif // 0 + return userDir; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h new file mode 100644 index 0000000000..139ce89ddd --- /dev/null +++ b/engines/wintermute/utils/path_util.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PATHUTILS_H +#define WINTERMUTE_PATHUTILS_H + +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +class PathUtil { +public: + static AnsiString unifySeparators(const AnsiString &path); + static AnsiString normalizeFileName(const AnsiString &path); + static AnsiString combine(const AnsiString &path1, const AnsiString &path2); + static AnsiString getDirectoryName(const AnsiString &path); + static AnsiString getFileName(const AnsiString &path); + static AnsiString getFileNameWithoutExtension(const AnsiString &path); + static AnsiString getExtension(const AnsiString &path); + static bool createDirectory(const AnsiString &path); + static bool matchesMask(const AnsiString &fileName, const AnsiString &mask); + + static bool fileExists(const AnsiString &fileName); + + static AnsiString getSafeLogFileName(); + static AnsiString getUserDirectory(); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp new file mode 100644 index 0000000000..c3fcb09f1d --- /dev/null +++ b/engines/wintermute/utils/string_util.cpp @@ -0,0 +1,381 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "common/tokenizer.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/convert_utf.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { + return (str1.compareToIgnoreCase(str2) == 0); +} + +////////////////////////////////////////////////////////////////////////// +/*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { + WideString str1lc = str1; + WideString str2lc = str2; + + ToLowerCase(str1lc); + ToLowerCase(str2lc); + + return (str1lc == str2lc); +}*/ + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::utf8ToWide(const Utf8String &Utf8Str) { + error("StringUtil::Utf8ToWide - WideString not supported yet"); + /* size_t WideSize = Utf8Str.size(); + + if (sizeof(wchar_t) == 2) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF16 *TargetStart = reinterpret_cast(WideStringNative); + UTF16 *TargetEnd = TargetStart + WideSize + 1; + + ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else if (sizeof(wchar_t) == 4) { + wchar_t *WideStringNative = new wchar_t[WideSize + 1]; + + const UTF8 *SourceStart = reinterpret_cast(Utf8Str.c_str()); + const UTF8 *SourceEnd = SourceStart + WideSize; + + UTF32 *TargetStart = reinterpret_cast(WideStringNative); + UTF32 *TargetEnd = TargetStart + WideSize; + + ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] WideStringNative; + return L""; + } + *TargetStart = 0; + WideString ResultString(WideStringNative); + delete [] WideStringNative; + + return ResultString; + } else { + return L""; + }*/ + return ""; +} + +////////////////////////////////////////////////////////////////////////// +Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { + error("StringUtil::wideToUtf8 - Widestring not supported yet"); + /* size_t WideSize = WideStr.length(); + + if (sizeof(wchar_t) == 2) { + size_t Utf8Size = 3 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF16 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else if (sizeof(wchar_t) == 4) { + size_t Utf8Size = 4 * WideSize + 1; + char *Utf8StringNative = new char[Utf8Size]; + + const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); + const UTF32 *SourceEnd = SourceStart + WideSize; + + UTF8 *TargetStart = reinterpret_cast(Utf8StringNative); + UTF8 *TargetEnd = TargetStart + Utf8Size; + + ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); + if (res != conversionOK) { + delete [] Utf8StringNative; + return (Utf8String)""; + } + *TargetStart = 0; + Utf8String ResultString(Utf8StringNative); + delete [] Utf8StringNative; + return ResultString; + } else { + return (Utf8String)""; + }*/ + return ""; +} + +// Currently this only does Ansi->ISO 8859, and only for carets. +char simpleAnsiToWide(const AnsiString &str, uint32 &offset) { + char c = str[offset]; + + if (c == 92) { + offset++; + return '\''; + } else { + offset++; + return c; + } +} + +////////////////////////////////////////////////////////////////////////// +WideString StringUtil::ansiToWide(const AnsiString &str) { + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("StringUtil::AnsiToWide - WideString not supported yet"); + } + /*Common::String converted = ""; + uint32 index = 0; + while (index != str.size()) { + converted += simpleAnsiToWide(str, index); + }*/ + // using default os locale! + + /* setlocale(LC_CTYPE, ""); + size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; + wchar_t *wstr = new wchar_t[WideSize]; + mbstowcs(wstr, str.c_str(), WideSize); + WideString ResultString(wstr); + delete [] wstr; + return ResultString;*/ + return WideString(str); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::wideToAnsi(const WideString &wstr) { + // using default os locale! + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("StringUtil::WideToAnsi - WideString not supported yet"); + } + /* setlocale(LC_CTYPE, ""); + size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; + char *str = new char[WideSize]; + wcstombs(str, wstr.c_str(), WideSize); + AnsiString ResultString(str); + delete [] str; + return ResultString;*/ + return AnsiString(wstr); +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + /* size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart = str.substr(0, patternLength); + + if (ignoreCase) return CompareNoCase(startPart, pattern); + else return (startPart == pattern);*/ + if (!ignoreCase) + return str.hasPrefix(pattern); + else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString startPart(str.c_str(), patternLength); + uint32 likeness = startPart.compareToIgnoreCase(pattern.c_str()); + return (likeness == 0); + } +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { + /* size_t strLength = str.size(); // TODO: Remove + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + AnsiString endPart = str.substr(strLength - patternLength, patternLength); + + if (ignoreCase) return CompareNoCase(endPart, pattern); + else return (endPart == pattern);*/ + if (!ignoreCase) { + return str.hasSuffix(pattern); + } else { + size_t strLength = str.size(); + size_t patternLength = pattern.size(); + + if (strLength < patternLength || patternLength == 0) + return false; + + Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); + uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); + return (likeness != 0); + } +} + +////////////////////////////////////////////////////////////////////////// +bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { + if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; + else return false; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { + if (from.empty() || from == to) return str; + + AnsiString result = str; + /*size_t pos = 0;*/ + + while (result.contains(from)) { + const char *startPtr = strstr(result.c_str(), from.c_str()); + uint32 index = startPtr - result.c_str(); + + Common::String tail(result.c_str() + index + to.size()); + result = Common::String(result.c_str(), index); + result += to; + result += tail; + + /* pos = result.find(from, pos); + if (pos == result.npos) break; + + result.replace(pos, from.size(), to); + pos += to.size();*/ + } + + return result; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { + AnsiString trimmedStr = str; + + if (fromRight) { + //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO + warning("fromRight-trim not implemented yet, %s", chars.c_str()); + } + if (fromLeft) { + uint32 lastOf = lastIndexOf(str, chars, 0); + trimmedStr = Common::String(trimmedStr.c_str() + lastOf); + //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); + } + return trimmedStr; +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + /*size_t pos = str.find(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos;*/ + const char *index = strstr(str.c_str(), toFind.c_str()); + if (index == NULL) + return -1; + else + return index - str.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { + /*size_t pos = str.rfind(toFind, startFrom); + if (pos == str.npos) return -1; + else return pos;*/ + int32 lastIndex = -1; + bool found = false; + for (size_t i = startFrom; i < str.size(); i++) { + found = false; + for (size_t j = 0; j < toFind.size(); j++) { + if (str[i + j] != toFind[j]) { + found = false; + break; + } else { + found = true; + } + } + if (found) + lastIndex = i; + } + return lastIndex; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::toString(size_t val) { + return Common::String::format("%u", (uint32)val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::toString(int val) { + return Common::String::format("%d", val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::toString(float val) { + return Common::String::format("%f", val); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString StringUtil::toString(double val) { + return Common::String::format("%f", val); +} + + +////////////////////////////////////////////////////////////////////////// +void StringUtil::split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { + result.clear(); +//TODO: Verify this, wrt keepEmptyItems. + Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); + //typedef boost::char_separator separator_t; + //typedef boost::tokenizer tokenizer_t; + + //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); + //tokenizer_t tokens(list, del); + while (!tokenizer.empty()) { + Common::String copy(tokenizer.nextToken().c_str()); + result.push_back(copy); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h new file mode 100644 index 0000000000..bd1b71f405 --- /dev/null +++ b/engines/wintermute/utils/string_util.h @@ -0,0 +1,66 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_STRINGUTIL_H +#define WINTERMUTE_STRINGUTIL_H + +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +class StringUtil { +public: + static bool compareNoCase(const AnsiString &str1, const AnsiString &str2); + //static bool compareNoCase(const WideString &str1, const WideString &str2); + static WideString utf8ToWide(const Utf8String &Utf8Str); + static Utf8String wideToUtf8(const WideString &WideStr); + static WideString ansiToWide(const AnsiString &str); + static AnsiString wideToAnsi(const WideString &str); + + static bool startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + static bool endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); + + static bool isUtf8BOM(const byte *buffer, uint32 bufferSize); + + static AnsiString replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); + static AnsiString trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); + + static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); + static int lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); + + static AnsiString toString(size_t val); + static AnsiString toString(int val); + static AnsiString toString(float val); + static AnsiString toString(double val); + + static void split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 1735732185..e77f35a0e8 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -27,11 +27,11 @@ */ #include "engines/wintermute/dcgf.h" -#include "utils.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintypes.h" -#include "PathUtil.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/base_game.h" #include "common/str.h" #include "common/textconsole.h" #include "engines/wintermute/wintermute.h" diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 14b8f4aa96..c8ca2e121c 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -30,7 +30,7 @@ #define WINTERMUTE_UTILS_H #include "engines/wintermute/wintypes.h" -#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/math/rect32.h" namespace WinterMute { diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp deleted file mode 100644 index 93f3196eee..0000000000 --- a/engines/wintermute/video/VidPlayer.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - -#include "engines/wintermute/dcgf.h" -#include "VidPlayer.h" - -//#pragma comment(lib, "vfw32.lib") - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { - SetDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::SetDefaults() { - _playing = false; - - /* _aviFile = NULL; - - _audioStream = NULL; - _audioFormat = NULL; - - _videoStream = NULL; - _videoFormat = NULL; - _videoPGF = NULL;*/ - _videoEndTime = 0; - - //_sound = NULL; - _soundAvailable = false; - - //_vidRenderer = NULL; - - _startTime = 0; - _totalVideoTime = 0; - - //_lastSample = -1; - - //_targetFormat = NULL; - - _playPosX = _playPosY = 0; - _playZoom = 0.0f; - - _filename = NULL; - - _slowRendering = false; - - _currentSubtitle = 0; - _showSubtitle = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CVidPlayer::~CVidPlayer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::cleanup() { -#if 0 - if (_sound) _sound->Stop(); - if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); - _videoPGF = NULL; - - _playing = false; - - - if (_aviFile) AVIFileRelease(m_AviFile); - - if (_audioStream) AVIStreamRelease(m_AudioStream); - if (_videoStream) AVIStreamRelease(m_VideoStream); - - if (_audioFormat) delete [](byte *)m_AudioFormat; - if (_videoFormat) delete [](byte *)m_VideoFormat; - if (_targetFormat) delete [](byte *)m_TargetFormat; - - SAFE_DELETE(_sound); - SAFE_DELETE(_vidRenderer); - - SAFE_DELETE_ARRAY(_filename); - - for (int i = 0; i < _subtitles.getSize(); i++) delete _subtitles[i]; - _subtitles.removeAll(); - - return SetDefaults(); -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { -#if 0 - cleanup(); - - char Filename[MAX_PATH_LENGTH]; - _gameRef->_fileManager->GetFullPath(inFilename, filename); - - // open file - if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - _gameRef->LOG(0, "Error opening AVI file '%s'", filename); - return STATUS_FAILED; - } - - // get video stream - if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - _gameRef->LOG(0, "Error finding video stream in AVI file '%s'", filename); - return STATUS_FAILED; - } - _totalVideoTime = AVIStreamEndTime(_videoStream); - - // get audio stream - if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) - _soundAvailable = true; - else - _soundAvailable = false; - - - LONG Size; - - // get video format - if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - _gameRef->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); - return STATUS_FAILED; - } - _videoFormat = (LPBITMAPINFO)new BYTE[Size]; - AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); - - // initialize optimal target format - m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; - memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); - memcpy(m_TargetFormat, m_VideoFormat, Size); - m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); - - m_TargetFormat->bV4BitCount = 24; - m_TargetFormat->bV4V4Compression = BI_RGB; - - if (_gameRef->m_UseD3D) - m_VidRenderer = new CVidRendererD3D(_gameRef); - else - m_VidRenderer = new CVidRendererDD(_gameRef); - - if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); - SAFE_DELETE(m_VidRenderer); - return STATUS_FAILED; - } - - - // create sound buffer - bool res; - - if (_soundAvailable) { - _sound = new CBSoundAVI(_gameRef); - if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { - SAFE_DELETE(_sound); - _soundAvailable = false; - _gameRef->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); - } - } - - if (_gameRef->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); - - _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::update() { -#if 0 - if (!m_Playing) return STATUS_OK; - - bool res; - - if (_soundAvailable && m_Sound) { - res = _sound->update(); - if (DID_FAIL(res)) return res; - } - - - DWORD CurrentTime; // current playing time (in ms) - /* - if(m_SoundAvailable && m_Sound){ - CurrentTime = m_Sound->GetPosition(); // in samples - CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); - - if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; - } - else - CurrentTime = timeGetTime() - m_StartTime; - */ - CurrentTime = timeGetTime() - _startTime; - - if (CurrentTime >= _totalVideoTime) { - Stop(); - return STATUS_OK; - } - - - // get and render frame - DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); - if (sample != _lastSample) { - _lastSample = sample; - - // process subtitles - _showSubtitle = false; - while (_currentSubtitle < _subtitles.getSize()) { - int End = _subtitles[_currentSubtitle]->m_EndFrame; - - bool NextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); - - if (sample > End) { - if (NextFrameOK) { - _currentSubtitle++; - } else { - _showSubtitle = (End == 0); - break; - } - } else { - _showSubtitle = true; - break; - } - } - - - // render frame - LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); - if (FrameData) { - if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); - else return _vidRenderer->ProcessFrame(FrameData); - } else return STATUS_FAILED; - } else return STATUS_OK; -#endif - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::display() { -#if 0 - if (!m_Playing) return STATUS_OK; - - bool res; - if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); - else res = STATUS_FAILED; - - // display subtitle - if (m_ShowSubtitle) { - CBFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); - font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); - } - - return res; -#endif - return 0; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { -#if 0 - if (!_videoStream || !_vidRenderer) return STATUS_FAILED; - - switch (Type) { - case VID_PLAY_POS: - _playZoom = 100.0f; - _playPosX = X; - _playPosY = Y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float ZoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); - _playZoom = min(ZoomX, ZoomY); - _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; - _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - _playZoom = 100.0f; - _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; - _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; - break; - } - - _targetFormat->bV4BitCount = 24; - _targetFormat->bV4V4Compression = BI_RGB; - - - _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); - if (!_videoPGF) { - _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); - if (!_videoPGF) { - _gameRef->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); - cleanup(); - return STATUS_FAILED; - } else { - _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); - _slowRendering = true; - } - } else _slowRendering = false; - - // HACK!!! - _slowRendering = true; - - - _currentSubtitle = 0; - - _gameRef->Freeze(FreezeMusic); - - _playing = true; - if (_sound) _sound->Play(); - _startTime = timeGetTime(); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::stop() { -#if 0 - if (!_playing) return STATUS_OK; - - cleanup(); - - _gameRef->Unfreeze(); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::isPlaying() { - return _playing; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { -#if 0 - if (!Filename) return STATUS_OK; - - char NewFile[MAX_PATH_LENGTH]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - - if (SubtitleFile) { - strcpy(NewFile, SubtitleFile); - } else { - _splitpath(filename, drive, dir, fname, NULL); - _makepath(NewFile, drive, dir, fname, ".SUB"); - } - - DWORD Size; - BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); - if (Buffer == NULL) return STATUS_OK; // no subtitles - - - LONG Start, End; - bool InToken; - char *TokenStart; - int TokenLength; - int TokenPos; - int TextLength; - - int Pos = 0; - int LineLength = 0; - while (Pos < Size) { - Start = End = -1; - InToken = false; - TokenPos = -1; - TextLength = 0; - - LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; - - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *Text = new char[RealLength + 1]; - char *line = (char *)&Buffer[Pos]; - - for (int i = 0; i < RealLength; i++) { - if (line[i] == '{') { - if (!InToken) { - InToken = true; - TokenStart = line + i + 1; - TokenLength = 0; - TokenPos++; - } else TokenLength++; - } else if (line[i] == '}') { - if (InToken) { - InToken = false; - char *Token = new char[TokenLength + 1]; - strncpy(Token, TokenStart, TokenLength); - Token[TokenLength] = '\0'; - if (TokenPos == 0) Start = atoi(Token); - else if (TokenPos == 1) End = atoi(Token); - - delete [] Token; - } else { - Text[TextLength] = line[i]; - TextLength++; - } - } else { - if (InToken) { - TokenLength++; - } else { - Text[TextLength] = line[i]; - if (Text[TextLength] == '|') Text[TextLength] = '\n'; - TextLength++; - } - } - } - Text[TextLength] = '\0'; - - if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); - - delete [] Text; - - Pos += LineLength + 1; - } - - delete [] Buffer; -#endif - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/video/VidPlayer.h b/engines/wintermute/video/VidPlayer.h deleted file mode 100644 index a44482e4c6..0000000000 --- a/engines/wintermute/video/VidPlayer.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VIDPLAYER_H -#define WINTERMUTE_VIDPLAYER_H - -#include "engines/wintermute/dctypes.h" // Added by ClassView -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "engines/wintermute/base/BBase.h" - -#define MAX_AUDIO_STREAMS 5 -#define MAX_VIDEO_STREAMS 5 - - -namespace WinterMute { - -class CVidPlayer : public CBBase { -public: - bool _showSubtitle; - int _currentSubtitle; - bool loadSubtitles(const char *filename, const char *SubtitleFile); - bool _slowRendering; - bool isPlaying(); - char *_filename; - bool stop(); - bool play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); - uint32 _totalVideoTime; - uint32 _startTime; - //CVidRenderer *_vidRenderer; - //CBSoundAVI *_sound; - bool _soundAvailable; - bool SetDefaults(); - bool _playing; - bool display(); - bool update(); - bool initialize(const char *inFilename, const char *SubtitleFile = NULL); - bool cleanup(); - CVidPlayer(CBGame *inGame); - virtual ~CVidPlayer(); - - /*PAVIFILE _aviFile; - - LONG _lastSample; - - PAVISTREAM _audioStream; - PAVISTREAM _videoStream; - - LPWAVEFORMAT _audioFormat; - - LPBITMAPINFO _videoFormat; - PGETFRAME _videoPGF;*/ - uint32 _videoEndTime; - - int _playPosX; - int _playPosY; - float _playZoom; - - /* LPBITMAPV4HEADER _targetFormat; - - CBArray _subtitles;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp deleted file mode 100644 index ffb24d22dd..0000000000 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ /dev/null @@ -1,850 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/video/decoders/theora_decoder.h" -#include "common/system.h" -//#pragma comment(lib, "libtheora.lib") - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false) - -////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { - SetDefaults(); -} - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::SetDefaults() { - - _file = NULL; - _filename = ""; - _startTime = 0; - _looping = false; - - _freezeGame = false; - _currentTime = 0; - - _state = THEORA_STATE_NONE; - - _videoFrameReady = false; - _audioFrameReady = false; - _videobufTime = 0; - - _playbackStarted = false; - _dontDropFrames = false; - - _texture = NULL; - _alphaImage = NULL; - _alphaFilename = ""; - - _frameRendered = false; - - _seekingKeyframe = false; - _timeOffset = 0.0f; - - _posX = _posY = 0; - _playbackType = VID_PLAY_CENTER; - _playZoom = 0.0f; - - _savedState = THEORA_STATE_NONE; - _savedPos = 0; - _volume = 100; - _theoraDecoder = NULL; -#if 0 - _vorbisStreams = _theoraStreams = 0; - - GenLookupTables(); - - _subtitler = NULL; -#endif -} - -////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::~CVidTheoraPlayer(void) { - cleanup(); - - /* SAFE_DELETE_ARRAY(_filename); - SAFE_DELETE_ARRAY(_alphaFilename); - SAFE_DELETE(_texture); - SAFE_DELETE(_alphaImage);*/ -// SAFE_DELETE(_subtitler); -} - -////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::cleanup() { - if (_file) { - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - - _surface.free(); - delete _theoraDecoder; - _theoraDecoder = NULL; - delete _alphaImage; - _alphaImage = NULL; - delete _texture; - _texture = NULL; -#if 0 - if (m_Sound) { - _gameRef->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - } - - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufFill = 0; - m_AudioBufSize = 0; -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { - cleanup(); - - _filename = filename; - _file = _gameRef->_fileManager->openFile(filename, true, false); - if (!_file) return STATUS_FAILED; - - //if (Filename != _filename) CBUtils::setString(&_filename, filename); -#if defined (USE_THEORADEC) - _theoraDecoder = new TheoraDecoder(); -#else - return STATUS_FAILED; -#endif - _theoraDecoder->loadStream(_file); - - if (!_theoraDecoder->isVideoLoaded()) - return STATUS_FAILED; - - _state = THEORA_STATE_PAUSED; - - // Additional setup. - _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); - _texture = new CBSurfaceOSystem(_gameRef); - _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); - _state = THEORA_STATE_PLAYING; - _playZoom = 100; - - return STATUS_OK; -#if 0 - cleanup(); - - _file = _gameRef->_fileManager->openFile(filename); - if (!_file) return STATUS_FAILED; - - if (Filename != _filename) CBUtils::setString(&_filename, filename); - - // start up Ogg stream synchronization layer - ogg_sync_init(&m_OggSyncState); - - // init supporting Vorbis structures needed in header parsing - vorbis_comment_init(&m_VorbisComment); - vorbis_info_init(&m_VorbisInfo); - - // init supporting Theora structures needed in header parsing - theora_comment_init(&m_TheoraComment); - theora_info_init(&m_TheoraInfo); - - - - // Ogg file open; parse the headers - // Only interested in Vorbis/Theora streams - ogg_packet TempOggPacket; - bool IsDone = false; - while (!IsDone) { - int BytesRead = BufferData(&m_OggSyncState); - if (BytesRead == 0) break; - - while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - ogg_stream_state OggStateTest; - - // is this a mandated initial header? If not, stop parsing - if (!ogg_page_bos(&m_OggPage)) { - // don't leak the page; get it into the appropriate stream - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - - IsDone = true; - break; - } - - ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); - ogg_stream_pagein(&OggStateTest, &m_OggPage); - ogg_stream_packetout(&OggStateTest, &TempOggPacket); - - // identify the codec: try theora - if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { - // it is theora - memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); - m_TheoraStreams = 1; - } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { - // it is vorbis - memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); - m_VorbisStreams = 1; - } else { - // whatever it is, we don't care about it - ogg_stream_clear(&OggStateTest); - } - } - } - - // we're expecting more header packets - while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { - int Ret; - - // look for further theora headers - while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { - if (Ret < 0) { - _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return STATUS_FAILED; - } - if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { - _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return STATUS_FAILED; - } - m_TheoraStreams++; - if (m_TheoraStreams == 3) break; - } - - /* look for more vorbis header packets */ - while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { - if (Ret < 0) { - _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return STATUS_FAILED; - } - if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { - _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return STATUS_FAILED; - } - m_VorbisStreams++; - if (m_VorbisStreams == 3) break; - } - - // The header pages/packets will arrive before anything else we - // care about, or the stream is not obeying spec - if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - } else { - int Ret = BufferData(&m_OggSyncState); // someone needs more data - if (Ret == 0) { - _gameRef->LOG(0, "End of file while searching for codec headers"); - return STATUS_FAILED; - } - } - } - - - - // and now we have it all. initialize decoders - if (m_TheoraStreams) { - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - } else { - // tear down the partial theora setup - theora_info_clear(&m_TheoraInfo); - theora_comment_clear(&m_TheoraComment); - } - - if (m_VorbisStreams) { - vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); - vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); - - } else { - // tear down the partial vorbis setup - vorbis_info_clear(&m_VorbisInfo); - vorbis_comment_clear(&m_VorbisComment); - } - - bool Res = STATUS_OK; - - // create sound buffer - if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { - m_Sound = new CBSoundTheora(_gameRef); - _gameRef->m_SoundMgr->AddSound(m_Sound); - if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { - _gameRef->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - _gameRef->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); - } else { - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufSize = m_Sound->m_StreamBlockSize; - m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; - } - } - - // create texture - if (m_TheoraStreams && !m_Texture) { - if (_gameRef->m_UseD3D) - m_Texture = new CBSurfaceD3D(_gameRef); - else - m_Texture = new CBSurfaceDD(_gameRef); - - if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { - SAFE_DELETE(m_Texture); - } - } - - - if (!m_Subtitler) m_Subtitler = new CVidSubtitler(_gameRef); - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); - - return Res; -#endif - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::resetStream() { - warning("VidTheoraPlayer::resetStream - stubbed"); -#if 0 - if (_sound) _sound->Stop(); - - m_TimeOffset = 0.0f; - Initialize(m_Filename); - Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { - if (forceZoom < 0.0f) - forceZoom = 100.0f; - if (volume < 0) - _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); - else _volume = volume; - - _freezeGame = freezeGame; - - if (!_playbackStarted && _freezeGame) - _gameRef->freeze(freezeMusic); - - _playbackStarted = false; - float width, height; - if (_theoraDecoder) { - _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); - _state = THEORA_STATE_PLAYING; - _looping = looping; - _playbackType = type; - - _startTime = startTime; - _volume = volume; - _posX = x; - _posY = y; - _playZoom = forceZoom; - - width = (float)_theoraDecoder->getWidth(); - height = (float)_theoraDecoder->getHeight(); - } else { - width = (float)_gameRef->_renderer->_width; - height = (float)_gameRef->_renderer->_height; - } - - switch (type) { - case VID_PLAY_POS: - _playZoom = forceZoom; - _posX = x; - _posY = y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->_renderer->_width / width * 100); - float ZoomY = (float)((float)_gameRef->_renderer->_height / height * 100); - _playZoom = MIN(ZoomX, ZoomY); - _posX = (int)((_gameRef->_renderer->_width - width * (_playZoom / 100)) / 2); - _posY = (int)((_gameRef->_renderer->_height - height * (_playZoom / 100)) / 2); - } - break; - - case VID_PLAY_CENTER: - _playZoom = 100.0f; - _posX = (int)((_gameRef->_renderer->_width - width) / 2); - _posY = (int)((_gameRef->_renderer->_height - height) / 2); - break; - } - return STATUS_OK; -#if 0 - - m_State = THEORA_STATE_PLAYING; - - m_Looping = Looping; - m_PlaybackType = Type; - - float Width, Height; - if (m_TheoraStreams) { - Width = (float)m_TheoraInfo.width; - Height = (float)m_TheoraInfo.height; - } else { - Width = (float)_gameRef->m_Renderer->m_Width; - Height = (float)_gameRef->m_Renderer->m_Height; - } - - switch (Type) { - case VID_PLAY_POS: - m_PlayZoom = ForceZoom; - m_PosX = X; - m_PosY = Y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->m_Renderer->m_Width / Width * 100); - float ZoomY = (float)((float)_gameRef->m_Renderer->m_Height / Height * 100); - m_PlayZoom = min(ZoomX, ZoomY); - m_PosX = (_gameRef->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; - m_PosY = (_gameRef->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - m_PlayZoom = 100.0f; - m_PosX = (_gameRef->m_Renderer->m_Width - Width) / 2; - m_PosY = (_gameRef->m_Renderer->m_Height - Height) / 2; - break; - } - - - if (StartTime) SeekToTime(StartTime); - - Update(); -#endif - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::stop() { - _theoraDecoder->close(); - _state = THEORA_STATE_FINISHED; - if (_freezeGame) { - _gameRef->unfreeze(); - } -#if 0 - if (m_Sound) m_Sound->Stop(); - m_State = THEORA_STATE_FINISHED; - if (m_FreezeGame) _gameRef->Unfreeze(); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::update() { - _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; - - if (!isPlaying()) return STATUS_OK; - - if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; - - if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) return STATUS_OK; - - if (_theoraDecoder) { - if (_theoraDecoder->endOfVideo() && _looping) { - warning("Should loop movie"); - _theoraDecoder->rewind(); - } else if (_theoraDecoder->endOfVideo() && !_looping) { - warning("Finished movie"); - _state = THEORA_STATE_FINISHED; - _playbackStarted = false; - if (_freezeGame) _gameRef->unfreeze(); - } - if (_state == THEORA_STATE_PLAYING) { - if (_theoraDecoder->getTimeToNextFrame() == 0) { - _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); - if (_texture) { - WriteVideo(); - } - } - return STATUS_OK; - } - } - // Skip the busy-loop? - if ((!_texture || !_videoFrameReady) && !_theoraDecoder->endOfVideo()) { - // end playback - if (!_looping) { - _state = THEORA_STATE_FINISHED; - if (_freezeGame) _gameRef->unfreeze(); - return STATUS_OK; - } else { - resetStream(); - return STATUS_OK; - } - } - -#if 0 - m_CurrentTime = m_FreezeGame ? _gameRef->m_LiveTimer : _gameRef->m_Timer; - - if (!IsPlaying()) return STATUS_OK; - - if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; - - if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; - - int Counter = 0; - while (true) { - if (m_Sound) DecodeVorbis(); - else m_AudioFrameReady = true; - - if (m_Texture) DecodeTheora(); - else m_VideoFrameReady = true; - - if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { - // end playback - if (!m_Looping) { - m_State = THEORA_STATE_FINISHED; - if (m_Sound) m_Sound->Stop(); - if (m_FreezeGame) _gameRef->Unfreeze(); - break; - } else { - ResetStream(); - return STATUS_OK; - } - } - - - if (!m_VideoFrameReady || !m_AudioFrameReady) { - Counter++; - if (StreamInData() == 0) break; - } else break; - } - - - // If playback has begun, top audio buffer off immediately. - //if(m_Sound) WriteAudio(); - - // are we at or past time for this video frame? - if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { - //_gameRef->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); - if (m_Texture) WriteVideo(); - m_VideoFrameReady = false; - - if (m_SavedState == THEORA_STATE_PAUSED) { - Pause(); - m_SavedState = THEORA_STATE_NONE; - } - } - - // if our buffers either don't exist or are ready to go, - // we can begin playback - bool StartNow = false; - if ((!m_TheoraStreams || m_VideoFrameReady) && - (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; - // same if we've run out of input - if (m_File->IsEOF()) StartNow = true; - - - if (m_Sound) WriteAudio(); - - - if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { - //m_StartTime = timeGetTime(); - m_StartTime = m_CurrentTime; - if (m_Sound) { - m_Sound->SetPrivateVolume(m_Volume); - m_Sound->Play(); - } - m_PlaybackStarted = true; - } - - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -uint32 CVidTheoraPlayer::getMovieTime() { - if (!_playbackStarted) { - return 0; - } else { - return _theoraDecoder->getTime(); - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CVidTheoraPlayer::getMovieFrame() { -#if 0 - if (!m_TheoraStreams) return 0; - float Time = GetMovieTime(); - - return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); -#endif - if (_theoraDecoder) { - return _theoraDecoder->getTime(); - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::WriteVideo() { - if (!_texture) return STATUS_FAILED; - - _texture->startPixelOp(); - - writeAlpha(); - if (_alphaImage) { - _texture->putSurface(_surface, true); - } else { - _texture->putSurface(_surface, false); - } - - //RenderFrame(_texture, &yuv); - - _texture->endPixelOp(); - _videoFrameReady = true; - return STATUS_OK; -} - -void CVidTheoraPlayer::writeAlpha() { - if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { - assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); - assert(_surface.format.bytesPerPixel == 4); - const byte *alphaData = (byte *)_alphaImage->getSurface()->getBasePtr(0, 0); - int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); - alphaData += alphaPlace; - byte *imgData = (byte *)_surface.getBasePtr(0, 0); - imgData += (_surface.format.aShift / 8); - for (int i = 0; i < _surface.w * _surface.h; i++) { - *imgData = *alphaData; - alphaData += 4; - imgData += 4; - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::display(uint32 alpha) { - Rect32 rc; - bool res; - - if (_texture && _videoFrameReady) { - CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); - if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); - else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); - } else res = STATUS_FAILED; -#if 0 - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->display(); -#endif - return res; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { - warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); - - delete _alphaImage; - _alphaImage = new CBImage(_gameRef); - if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { - delete _alphaImage; - _alphaImage = NULL; - _alphaFilename = ""; - return STATUS_FAILED; - } - - if (_alphaFilename != filename) { - _alphaFilename = filename; - } - //TODO: Conversion. -#if 0 - SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new CBImage(_gameRef); - if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { - SAFE_DELETE(m_AlphaImage); - SAFE_DELETE_ARRAY(m_AlphaFilename); - return STATUS_FAILED; - } - if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, filename); - m_AlphaImage->Convert(IMG_TRUECOLOR); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -byte CVidTheoraPlayer::getAlphaAt(int x, int y) { - if (_alphaImage) return _alphaImage->getAlphaAt(x, y); - else return 0xFF; -} - - -////////////////////////////////////////////////////////////////////////// -inline int intlog(int num) { - int r = 0; - while (num > 0) { - num = num / 2; - r = r + 1; - } - - return r; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::SeekToTime(uint32 time) { - warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); -#if 0 - if (!m_TheoraStreams) return STATUS_FAILED; - - - float TargetTime = Time / 1000.0f; - - - ogg_page page; - int read = 1; - ogg_int64_t gran; - float movieLength = 0; - DWORD LastPos = 0; - - int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); - - while (!m_File->IsEOF() && read != 0) { - read = BufferData(&m_OggSyncState); - - while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { - int serno = ogg_page_serialno(&page); - //This is theora stream we were searching for - if (m_TheoraStreamState.serialno == serno) { - //Calculate a rough time estimate - gran = ogg_page_granulepos(&page); - if (gran >= 0) { - ogg_int64_t iframe = gran >> keyframe_granule_shift; - ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); - movieLength = (iframe + pframe) * - ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); - - if (movieLength >= TargetTime) { - m_TimeOffset = movieLength; - //m_TimeOffset = TargetTime; - //m_File->Seek(LastPos); - - goto finish; - } - LastPos = m_File->GetPos(); - } - } - } - } - -finish: - ogg_sync_reset(&m_OggSyncState); - - ogg_stream_reset(&m_TheoraStreamState); - ogg_stream_reset(&m_VorbisStreamState); - - theora_clear(&m_TheoraState); - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - vorbis_synthesis_restart(&m_VorbisDSPState); - - m_SeekingKeyframe = true; - - //theora_packet_iskeyframe - -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::pause() { - if (_state == THEORA_STATE_PLAYING) { - _state = THEORA_STATE_PAUSED; - _theoraDecoder->pauseVideo(true); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::resume() { - if (_state == THEORA_STATE_PAUSED) { - _state = THEORA_STATE_PLAYING; - _theoraDecoder->pauseVideo(false); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { - //CBBase::persist(persistMgr); - - if (persistMgr->_saving) { - _savedPos = getMovieTime() * 1000; - _savedState = _state; - } else { - SetDefaults(); - } - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_savedPos)); - persistMgr->transfer(TMEMBER(_savedState)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_alphaFilename)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); - persistMgr->transfer(TMEMBER(_playZoom)); - persistMgr->transfer(TMEMBER_INT(_playbackType)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_volume)); - - if (!persistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { - initializeSimple(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::initializeSimple() { - if (DID_SUCCEED(initialize(_filename))) { - if (_alphaFilename != "") setAlphaImage(_alphaFilename); - play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); - } else _state = THEORA_STATE_FINISHED; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CVidTheoraPlayer::getTexture() { - return _texture; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h deleted file mode 100644 index f624c9a972..0000000000 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ /dev/null @@ -1,151 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VIDTHEORAPLAYER_H -#define WINTERMUTE_VIDTHEORAPLAYER_H - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/persistent.h" -#include "video/video_decoder.h" -#include "common/stream.h" -#include "graphics/surface.h" - -namespace WinterMute { -class CBSurface; -class CBImage; -class CVidTheoraPlayer : public CBBase { -private: - enum { - THEORA_STATE_NONE = 0, - THEORA_STATE_PLAYING = 1, - THEORA_STATE_PAUSED = 2, - THEORA_STATE_FINISHED = 3 - }; - Video::RewindableVideoDecoder *_theoraDecoder; - Graphics::Surface _surface; -public: - DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase) - - CVidTheoraPlayer(CBGame *inGame); - virtual ~CVidTheoraPlayer(void); - - // external objects - Common::SeekableReadStream *_file; - Common::String _filename; - - CBSurface *_texture; - //CVidSubtitler *_subtitler; - - // control methods - bool initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); - bool initializeSimple(); - bool update(); - bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); - bool stop(); - bool display(uint32 alpha = 0xFFFFFFFF); - //bool RenderFrame(CBSurface *Texture, yuv_buffer *yuv); - - bool pause(); - bool resume(); - - bool isPlaying() { - return _state == THEORA_STATE_PLAYING; - }; - bool isFinished() { - return _state == THEORA_STATE_FINISHED; - }; - bool isPaused() { - return _state == THEORA_STATE_PAUSED; - }; - - uint32 getMovieTime(); - uint32 getMovieFrame(); - - CBSurface *getTexture(); - - int _state; - uint32 _startTime; - - int _savedState; - uint32 _savedPos; - - - // alpha related - CBImage *_alphaImage; - Common::String _alphaFilename; - bool setAlphaImage(const Common::String &filename); - __inline byte getAlphaAt(int x, int y); - void writeAlpha(); - - bool SeekToTime(uint32 Time); - - - void cleanup(); - bool resetStream(); - - // video properties - TVideoPlayback _playbackType; - int _posX; - int _posY; - float _playZoom; - int _volume; - - bool _looping; - bool _dontDropFrames; - bool _freezeGame; - uint32 _currentTime; - - -private: - // seeking support - bool _seekingKeyframe; - float _timeOffset; - - bool _frameRendered; - - bool getIsFrameReady() { - return _videoFrameReady; - } -private: - bool _audioFrameReady; - bool _videoFrameReady; - float _videobufTime; - - bool WriteVideo(); - - bool _playbackStarted; - - // helpers - void SetDefaults(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp new file mode 100644 index 0000000000..49d1c6c50f --- /dev/null +++ b/engines/wintermute/video/video_player.cpp @@ -0,0 +1,470 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/video/video_player.h" + +//#pragma comment(lib, "vfw32.lib") + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::SetDefaults() { + _playing = false; + + /* _aviFile = NULL; + + _audioStream = NULL; + _audioFormat = NULL; + + _videoStream = NULL; + _videoFormat = NULL; + _videoPGF = NULL;*/ + _videoEndTime = 0; + + //_sound = NULL; + _soundAvailable = false; + + //_vidRenderer = NULL; + + _startTime = 0; + _totalVideoTime = 0; + + //_lastSample = -1; + + //_targetFormat = NULL; + + _playPosX = _playPosY = 0; + _playZoom = 0.0f; + + _filename = NULL; + + _slowRendering = false; + + _currentSubtitle = 0; + _showSubtitle = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CVidPlayer::~CVidPlayer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::cleanup() { +#if 0 + if (_sound) _sound->Stop(); + if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); + _videoPGF = NULL; + + _playing = false; + + + if (_aviFile) AVIFileRelease(m_AviFile); + + if (_audioStream) AVIStreamRelease(m_AudioStream); + if (_videoStream) AVIStreamRelease(m_VideoStream); + + if (_audioFormat) delete [](byte *)m_AudioFormat; + if (_videoFormat) delete [](byte *)m_VideoFormat; + if (_targetFormat) delete [](byte *)m_TargetFormat; + + SAFE_DELETE(_sound); + SAFE_DELETE(_vidRenderer); + + SAFE_DELETE_ARRAY(_filename); + + for (int i = 0; i < _subtitles.getSize(); i++) delete _subtitles[i]; + _subtitles.removeAll(); + + return SetDefaults(); +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { +#if 0 + cleanup(); + + char Filename[MAX_PATH_LENGTH]; + _gameRef->_fileManager->GetFullPath(inFilename, filename); + + // open file + if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { + _gameRef->LOG(0, "Error opening AVI file '%s'", filename); + return STATUS_FAILED; + } + + // get video stream + if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { + _gameRef->LOG(0, "Error finding video stream in AVI file '%s'", filename); + return STATUS_FAILED; + } + _totalVideoTime = AVIStreamEndTime(_videoStream); + + // get audio stream + if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + _soundAvailable = true; + else + _soundAvailable = false; + + + LONG Size; + + // get video format + if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { + _gameRef->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); + return STATUS_FAILED; + } + _videoFormat = (LPBITMAPINFO)new BYTE[Size]; + AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); + + // initialize optimal target format + m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; + memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); + memcpy(m_TargetFormat, m_VideoFormat, Size); + m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); + + m_TargetFormat->bV4BitCount = 24; + m_TargetFormat->bV4V4Compression = BI_RGB; + + if (_gameRef->m_UseD3D) + m_VidRenderer = new CVidRendererD3D(_gameRef); + else + m_VidRenderer = new CVidRendererDD(_gameRef); + + if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { + _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); + SAFE_DELETE(m_VidRenderer); + return STATUS_FAILED; + } + + + // create sound buffer + bool res; + + if (_soundAvailable) { + _sound = new CBSoundAVI(_gameRef); + if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { + SAFE_DELETE(_sound); + _soundAvailable = false; + _gameRef->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); + } + } + + if (_gameRef->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::update() { +#if 0 + if (!m_Playing) return STATUS_OK; + + bool res; + + if (_soundAvailable && m_Sound) { + res = _sound->update(); + if (DID_FAIL(res)) return res; + } + + + DWORD CurrentTime; // current playing time (in ms) + /* + if(m_SoundAvailable && m_Sound){ + CurrentTime = m_Sound->GetPosition(); // in samples + CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); + + if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; + } + else + CurrentTime = timeGetTime() - m_StartTime; + */ + CurrentTime = timeGetTime() - _startTime; + + if (CurrentTime >= _totalVideoTime) { + Stop(); + return STATUS_OK; + } + + + // get and render frame + DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); + if (sample != _lastSample) { + _lastSample = sample; + + // process subtitles + _showSubtitle = false; + while (_currentSubtitle < _subtitles.getSize()) { + int End = _subtitles[_currentSubtitle]->m_EndFrame; + + bool NextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); + + if (sample > End) { + if (NextFrameOK) { + _currentSubtitle++; + } else { + _showSubtitle = (End == 0); + break; + } + } else { + _showSubtitle = true; + break; + } + } + + + // render frame + LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); + if (FrameData) { + if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); + else return _vidRenderer->ProcessFrame(FrameData); + } else return STATUS_FAILED; + } else return STATUS_OK; +#endif + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::display() { +#if 0 + if (!m_Playing) return STATUS_OK; + + bool res; + if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); + else res = STATUS_FAILED; + + // display subtitle + if (m_ShowSubtitle) { + CBFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); + font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); + } + + return res; +#endif + return 0; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +#if 0 + if (!_videoStream || !_vidRenderer) return STATUS_FAILED; + + switch (Type) { + case VID_PLAY_POS: + _playZoom = 100.0f; + _playPosX = X; + _playPosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float ZoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + _playZoom = min(ZoomX, ZoomY); + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; + break; + } + + _targetFormat->bV4BitCount = 24; + _targetFormat->bV4V4Compression = BI_RGB; + + + _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); + if (!_videoPGF) { + _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); + if (!_videoPGF) { + _gameRef->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); + cleanup(); + return STATUS_FAILED; + } else { + _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); + _slowRendering = true; + } + } else _slowRendering = false; + + // HACK!!! + _slowRendering = true; + + + _currentSubtitle = 0; + + _gameRef->Freeze(FreezeMusic); + + _playing = true; + if (_sound) _sound->Play(); + _startTime = timeGetTime(); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::stop() { +#if 0 + if (!_playing) return STATUS_OK; + + cleanup(); + + _gameRef->Unfreeze(); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::isPlaying() { + return _playing; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { +#if 0 + if (!Filename) return STATUS_OK; + + char NewFile[MAX_PATH_LENGTH]; + char drive[_MAX_DRIVE]; + char dir[_MAX_DIR]; + char fname[_MAX_FNAME]; + + if (SubtitleFile) { + strcpy(NewFile, SubtitleFile); + } else { + _splitpath(filename, drive, dir, fname, NULL); + _makepath(NewFile, drive, dir, fname, ".SUB"); + } + + DWORD Size; + BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); + if (Buffer == NULL) return STATUS_OK; // no subtitles + + + LONG Start, End; + bool InToken; + char *TokenStart; + int TokenLength; + int TokenPos; + int TextLength; + + int Pos = 0; + int LineLength = 0; + while (Pos < Size) { + Start = End = -1; + InToken = false; + TokenPos = -1; + TextLength = 0; + + LineLength = 0; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *Text = new char[RealLength + 1]; + char *line = (char *)&Buffer[Pos]; + + for (int i = 0; i < RealLength; i++) { + if (line[i] == '{') { + if (!InToken) { + InToken = true; + TokenStart = line + i + 1; + TokenLength = 0; + TokenPos++; + } else TokenLength++; + } else if (line[i] == '}') { + if (InToken) { + InToken = false; + char *Token = new char[TokenLength + 1]; + strncpy(Token, TokenStart, TokenLength); + Token[TokenLength] = '\0'; + if (TokenPos == 0) Start = atoi(Token); + else if (TokenPos == 1) End = atoi(Token); + + delete [] Token; + } else { + Text[TextLength] = line[i]; + TextLength++; + } + } else { + if (InToken) { + TokenLength++; + } else { + Text[TextLength] = line[i]; + if (Text[TextLength] == '|') Text[TextLength] = '\n'; + TextLength++; + } + } + } + Text[TextLength] = '\0'; + + if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); + + delete [] Text; + + Pos += LineLength + 1; + } + + delete [] Buffer; +#endif + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h new file mode 100644 index 0000000000..ca6c7fdec5 --- /dev/null +++ b/engines/wintermute/video/video_player.h @@ -0,0 +1,93 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDPLAYER_H +#define WINTERMUTE_VIDPLAYER_H + +#include "engines/wintermute/dctypes.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "engines/wintermute/base/base.h" + +#define MAX_AUDIO_STREAMS 5 +#define MAX_VIDEO_STREAMS 5 + + +namespace WinterMute { + +class CVidPlayer : public CBBase { +public: + bool _showSubtitle; + int _currentSubtitle; + bool loadSubtitles(const char *filename, const char *SubtitleFile); + bool _slowRendering; + bool isPlaying(); + char *_filename; + bool stop(); + bool play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + uint32 _totalVideoTime; + uint32 _startTime; + //CVidRenderer *_vidRenderer; + //CBSoundAVI *_sound; + bool _soundAvailable; + bool SetDefaults(); + bool _playing; + bool display(); + bool update(); + bool initialize(const char *inFilename, const char *SubtitleFile = NULL); + bool cleanup(); + CVidPlayer(CBGame *inGame); + virtual ~CVidPlayer(); + + /*PAVIFILE _aviFile; + + LONG _lastSample; + + PAVISTREAM _audioStream; + PAVISTREAM _videoStream; + + LPWAVEFORMAT _audioFormat; + + LPBITMAPINFO _videoFormat; + PGETFRAME _videoPGF;*/ + uint32 _videoEndTime; + + int _playPosX; + int _playPosY; + float _playZoom; + + /* LPBITMAPV4HEADER _targetFormat; + + CBArray _subtitles;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp new file mode 100644 index 0000000000..e3c120ff86 --- /dev/null +++ b/engines/wintermute/video/video_theora_player.cpp @@ -0,0 +1,850 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/video/decoders/theora_decoder.h" +#include "common/system.h" +//#pragma comment(lib, "libtheora.lib") + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false) + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { + SetDefaults(); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::SetDefaults() { + + _file = NULL; + _filename = ""; + _startTime = 0; + _looping = false; + + _freezeGame = false; + _currentTime = 0; + + _state = THEORA_STATE_NONE; + + _videoFrameReady = false; + _audioFrameReady = false; + _videobufTime = 0; + + _playbackStarted = false; + _dontDropFrames = false; + + _texture = NULL; + _alphaImage = NULL; + _alphaFilename = ""; + + _frameRendered = false; + + _seekingKeyframe = false; + _timeOffset = 0.0f; + + _posX = _posY = 0; + _playbackType = VID_PLAY_CENTER; + _playZoom = 0.0f; + + _savedState = THEORA_STATE_NONE; + _savedPos = 0; + _volume = 100; + _theoraDecoder = NULL; +#if 0 + _vorbisStreams = _theoraStreams = 0; + + GenLookupTables(); + + _subtitler = NULL; +#endif +} + +////////////////////////////////////////////////////////////////////////// +CVidTheoraPlayer::~CVidTheoraPlayer(void) { + cleanup(); + + /* SAFE_DELETE_ARRAY(_filename); + SAFE_DELETE_ARRAY(_alphaFilename); + SAFE_DELETE(_texture); + SAFE_DELETE(_alphaImage);*/ +// SAFE_DELETE(_subtitler); +} + +////////////////////////////////////////////////////////////////////////// +void CVidTheoraPlayer::cleanup() { + if (_file) { + _gameRef->_fileManager->closeFile(_file); + _file = NULL; + } + + _surface.free(); + delete _theoraDecoder; + _theoraDecoder = NULL; + delete _alphaImage; + _alphaImage = NULL; + delete _texture; + _texture = NULL; +#if 0 + if (m_Sound) { + _gameRef->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + } + + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufFill = 0; + m_AudioBufSize = 0; +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { + cleanup(); + + _filename = filename; + _file = _gameRef->_fileManager->openFile(filename, true, false); + if (!_file) return STATUS_FAILED; + + //if (Filename != _filename) CBUtils::setString(&_filename, filename); +#if defined (USE_THEORADEC) + _theoraDecoder = new TheoraDecoder(); +#else + return STATUS_FAILED; +#endif + _theoraDecoder->loadStream(_file); + + if (!_theoraDecoder->isVideoLoaded()) + return STATUS_FAILED; + + _state = THEORA_STATE_PAUSED; + + // Additional setup. + _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); + _texture = new CBSurfaceOSystem(_gameRef); + _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); + _state = THEORA_STATE_PLAYING; + _playZoom = 100; + + return STATUS_OK; +#if 0 + cleanup(); + + _file = _gameRef->_fileManager->openFile(filename); + if (!_file) return STATUS_FAILED; + + if (Filename != _filename) CBUtils::setString(&_filename, filename); + + // start up Ogg stream synchronization layer + ogg_sync_init(&m_OggSyncState); + + // init supporting Vorbis structures needed in header parsing + vorbis_comment_init(&m_VorbisComment); + vorbis_info_init(&m_VorbisInfo); + + // init supporting Theora structures needed in header parsing + theora_comment_init(&m_TheoraComment); + theora_info_init(&m_TheoraInfo); + + + + // Ogg file open; parse the headers + // Only interested in Vorbis/Theora streams + ogg_packet TempOggPacket; + bool IsDone = false; + while (!IsDone) { + int BytesRead = BufferData(&m_OggSyncState); + if (BytesRead == 0) break; + + while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + ogg_stream_state OggStateTest; + + // is this a mandated initial header? If not, stop parsing + if (!ogg_page_bos(&m_OggPage)) { + // don't leak the page; get it into the appropriate stream + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + + IsDone = true; + break; + } + + ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); + ogg_stream_pagein(&OggStateTest, &m_OggPage); + ogg_stream_packetout(&OggStateTest, &TempOggPacket); + + // identify the codec: try theora + if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { + // it is theora + memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); + m_TheoraStreams = 1; + } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { + // it is vorbis + memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); + m_VorbisStreams = 1; + } else { + // whatever it is, we don't care about it + ogg_stream_clear(&OggStateTest); + } + } + } + + // we're expecting more header packets + while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { + int Ret; + + // look for further theora headers + while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { + if (Ret < 0) { + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return STATUS_FAILED; + } + if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + return STATUS_FAILED; + } + m_TheoraStreams++; + if (m_TheoraStreams == 3) break; + } + + /* look for more vorbis header packets */ + while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { + if (Ret < 0) { + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return STATUS_FAILED; + } + if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + return STATUS_FAILED; + } + m_VorbisStreams++; + if (m_VorbisStreams == 3) break; + } + + // The header pages/packets will arrive before anything else we + // care about, or the stream is not obeying spec + if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { + if (m_TheoraStreams) + ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); + if (m_VorbisStreams) + ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); + } else { + int Ret = BufferData(&m_OggSyncState); // someone needs more data + if (Ret == 0) { + _gameRef->LOG(0, "End of file while searching for codec headers"); + return STATUS_FAILED; + } + } + } + + + + // and now we have it all. initialize decoders + if (m_TheoraStreams) { + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + } else { + // tear down the partial theora setup + theora_info_clear(&m_TheoraInfo); + theora_comment_clear(&m_TheoraComment); + } + + if (m_VorbisStreams) { + vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); + vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); + + } else { + // tear down the partial vorbis setup + vorbis_info_clear(&m_VorbisInfo); + vorbis_comment_clear(&m_VorbisComment); + } + + bool Res = STATUS_OK; + + // create sound buffer + if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { + m_Sound = new CBSoundTheora(_gameRef); + _gameRef->m_SoundMgr->AddSound(m_Sound); + if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { + _gameRef->m_SoundMgr->RemoveSound(m_Sound); + m_Sound = NULL; + _gameRef->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); + } else { + SAFE_DELETE_ARRAY(m_AudioBuf); + m_AudioBufSize = m_Sound->m_StreamBlockSize; + m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; + } + } + + // create texture + if (m_TheoraStreams && !m_Texture) { + if (_gameRef->m_UseD3D) + m_Texture = new CBSurfaceD3D(_gameRef); + else + m_Texture = new CBSurfaceDD(_gameRef); + + if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { + SAFE_DELETE(m_Texture); + } + } + + + if (!m_Subtitler) m_Subtitler = new CVidSubtitler(_gameRef); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); + + return Res; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::resetStream() { + warning("VidTheoraPlayer::resetStream - stubbed"); +#if 0 + if (_sound) _sound->Stop(); + + m_TimeOffset = 0.0f; + Initialize(m_Filename); + Play(m_PlaybackType, m_PosX, m_PosY, false, false, m_Looping, 0, m_PlayZoom); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { + if (forceZoom < 0.0f) + forceZoom = 100.0f; + if (volume < 0) + _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); + else _volume = volume; + + _freezeGame = freezeGame; + + if (!_playbackStarted && _freezeGame) + _gameRef->freeze(freezeMusic); + + _playbackStarted = false; + float width, height; + if (_theoraDecoder) { + _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); + _state = THEORA_STATE_PLAYING; + _looping = looping; + _playbackType = type; + + _startTime = startTime; + _volume = volume; + _posX = x; + _posY = y; + _playZoom = forceZoom; + + width = (float)_theoraDecoder->getWidth(); + height = (float)_theoraDecoder->getHeight(); + } else { + width = (float)_gameRef->_renderer->_width; + height = (float)_gameRef->_renderer->_height; + } + + switch (type) { + case VID_PLAY_POS: + _playZoom = forceZoom; + _posX = x; + _posY = y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)_gameRef->_renderer->_width / width * 100); + float ZoomY = (float)((float)_gameRef->_renderer->_height / height * 100); + _playZoom = MIN(ZoomX, ZoomY); + _posX = (int)((_gameRef->_renderer->_width - width * (_playZoom / 100)) / 2); + _posY = (int)((_gameRef->_renderer->_height - height * (_playZoom / 100)) / 2); + } + break; + + case VID_PLAY_CENTER: + _playZoom = 100.0f; + _posX = (int)((_gameRef->_renderer->_width - width) / 2); + _posY = (int)((_gameRef->_renderer->_height - height) / 2); + break; + } + return STATUS_OK; +#if 0 + + m_State = THEORA_STATE_PLAYING; + + m_Looping = Looping; + m_PlaybackType = Type; + + float Width, Height; + if (m_TheoraStreams) { + Width = (float)m_TheoraInfo.width; + Height = (float)m_TheoraInfo.height; + } else { + Width = (float)_gameRef->m_Renderer->m_Width; + Height = (float)_gameRef->m_Renderer->m_Height; + } + + switch (Type) { + case VID_PLAY_POS: + m_PlayZoom = ForceZoom; + m_PosX = X; + m_PosY = Y; + break; + + case VID_PLAY_STRETCH: { + float ZoomX = (float)((float)_gameRef->m_Renderer->m_Width / Width * 100); + float ZoomY = (float)((float)_gameRef->m_Renderer->m_Height / Height * 100); + m_PlayZoom = min(ZoomX, ZoomY); + m_PosX = (_gameRef->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; + } + break; + + case VID_PLAY_CENTER: + m_PlayZoom = 100.0f; + m_PosX = (_gameRef->m_Renderer->m_Width - Width) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height) / 2; + break; + } + + + if (StartTime) SeekToTime(StartTime); + + Update(); +#endif + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::stop() { + _theoraDecoder->close(); + _state = THEORA_STATE_FINISHED; + if (_freezeGame) { + _gameRef->unfreeze(); + } +#if 0 + if (m_Sound) m_Sound->Stop(); + m_State = THEORA_STATE_FINISHED; + if (m_FreezeGame) _gameRef->Unfreeze(); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::update() { + _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; + + if (!isPlaying()) return STATUS_OK; + + if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; + + if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) return STATUS_OK; + + if (_theoraDecoder) { + if (_theoraDecoder->endOfVideo() && _looping) { + warning("Should loop movie"); + _theoraDecoder->rewind(); + } else if (_theoraDecoder->endOfVideo() && !_looping) { + warning("Finished movie"); + _state = THEORA_STATE_FINISHED; + _playbackStarted = false; + if (_freezeGame) _gameRef->unfreeze(); + } + if (_state == THEORA_STATE_PLAYING) { + if (_theoraDecoder->getTimeToNextFrame() == 0) { + _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); + if (_texture) { + WriteVideo(); + } + } + return STATUS_OK; + } + } + // Skip the busy-loop? + if ((!_texture || !_videoFrameReady) && !_theoraDecoder->endOfVideo()) { + // end playback + if (!_looping) { + _state = THEORA_STATE_FINISHED; + if (_freezeGame) _gameRef->unfreeze(); + return STATUS_OK; + } else { + resetStream(); + return STATUS_OK; + } + } + +#if 0 + m_CurrentTime = m_FreezeGame ? _gameRef->m_LiveTimer : _gameRef->m_Timer; + + if (!IsPlaying()) return STATUS_OK; + + if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; + + if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; + + int Counter = 0; + while (true) { + if (m_Sound) DecodeVorbis(); + else m_AudioFrameReady = true; + + if (m_Texture) DecodeTheora(); + else m_VideoFrameReady = true; + + if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { + // end playback + if (!m_Looping) { + m_State = THEORA_STATE_FINISHED; + if (m_Sound) m_Sound->Stop(); + if (m_FreezeGame) _gameRef->Unfreeze(); + break; + } else { + ResetStream(); + return STATUS_OK; + } + } + + + if (!m_VideoFrameReady || !m_AudioFrameReady) { + Counter++; + if (StreamInData() == 0) break; + } else break; + } + + + // If playback has begun, top audio buffer off immediately. + //if(m_Sound) WriteAudio(); + + // are we at or past time for this video frame? + if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { + //_gameRef->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); + if (m_Texture) WriteVideo(); + m_VideoFrameReady = false; + + if (m_SavedState == THEORA_STATE_PAUSED) { + Pause(); + m_SavedState = THEORA_STATE_NONE; + } + } + + // if our buffers either don't exist or are ready to go, + // we can begin playback + bool StartNow = false; + if ((!m_TheoraStreams || m_VideoFrameReady) && + (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; + // same if we've run out of input + if (m_File->IsEOF()) StartNow = true; + + + if (m_Sound) WriteAudio(); + + + if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { + //m_StartTime = timeGetTime(); + m_StartTime = m_CurrentTime; + if (m_Sound) { + m_Sound->SetPrivateVolume(m_Volume); + m_Sound->Play(); + } + m_PlaybackStarted = true; + } + + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CVidTheoraPlayer::getMovieTime() { + if (!_playbackStarted) { + return 0; + } else { + return _theoraDecoder->getTime(); + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CVidTheoraPlayer::getMovieFrame() { +#if 0 + if (!m_TheoraStreams) return 0; + float Time = GetMovieTime(); + + return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); +#endif + if (_theoraDecoder) { + return _theoraDecoder->getTime(); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::WriteVideo() { + if (!_texture) return STATUS_FAILED; + + _texture->startPixelOp(); + + writeAlpha(); + if (_alphaImage) { + _texture->putSurface(_surface, true); + } else { + _texture->putSurface(_surface, false); + } + + //RenderFrame(_texture, &yuv); + + _texture->endPixelOp(); + _videoFrameReady = true; + return STATUS_OK; +} + +void CVidTheoraPlayer::writeAlpha() { + if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { + assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); + assert(_surface.format.bytesPerPixel == 4); + const byte *alphaData = (byte *)_alphaImage->getSurface()->getBasePtr(0, 0); + int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); + alphaData += alphaPlace; + byte *imgData = (byte *)_surface.getBasePtr(0, 0); + imgData += (_surface.format.aShift / 8); + for (int i = 0; i < _surface.w * _surface.h; i++) { + *imgData = *alphaData; + alphaData += 4; + imgData += 4; + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::display(uint32 alpha) { + Rect32 rc; + bool res; + + if (_texture && _videoFrameReady) { + CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); + if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); + else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); + } else res = STATUS_FAILED; +#if 0 + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->display(); +#endif + return res; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { + warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); + + delete _alphaImage; + _alphaImage = new CBImage(_gameRef); + if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { + delete _alphaImage; + _alphaImage = NULL; + _alphaFilename = ""; + return STATUS_FAILED; + } + + if (_alphaFilename != filename) { + _alphaFilename = filename; + } + //TODO: Conversion. +#if 0 + SAFE_DELETE(m_AlphaImage); + m_AlphaImage = new CBImage(_gameRef); + if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { + SAFE_DELETE(m_AlphaImage); + SAFE_DELETE_ARRAY(m_AlphaFilename); + return STATUS_FAILED; + } + if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, filename); + m_AlphaImage->Convert(IMG_TRUECOLOR); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +byte CVidTheoraPlayer::getAlphaAt(int x, int y) { + if (_alphaImage) return _alphaImage->getAlphaAt(x, y); + else return 0xFF; +} + + +////////////////////////////////////////////////////////////////////////// +inline int intlog(int num) { + int r = 0; + while (num > 0) { + num = num / 2; + r = r + 1; + } + + return r; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::SeekToTime(uint32 time) { + warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); +#if 0 + if (!m_TheoraStreams) return STATUS_FAILED; + + + float TargetTime = Time / 1000.0f; + + + ogg_page page; + int read = 1; + ogg_int64_t gran; + float movieLength = 0; + DWORD LastPos = 0; + + int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); + + while (!m_File->IsEOF() && read != 0) { + read = BufferData(&m_OggSyncState); + + while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { + int serno = ogg_page_serialno(&page); + //This is theora stream we were searching for + if (m_TheoraStreamState.serialno == serno) { + //Calculate a rough time estimate + gran = ogg_page_granulepos(&page); + if (gran >= 0) { + ogg_int64_t iframe = gran >> keyframe_granule_shift; + ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); + movieLength = (iframe + pframe) * + ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); + + if (movieLength >= TargetTime) { + m_TimeOffset = movieLength; + //m_TimeOffset = TargetTime; + //m_File->Seek(LastPos); + + goto finish; + } + LastPos = m_File->GetPos(); + } + } + } + } + +finish: + ogg_sync_reset(&m_OggSyncState); + + ogg_stream_reset(&m_TheoraStreamState); + ogg_stream_reset(&m_VorbisStreamState); + + theora_clear(&m_TheoraState); + theora_decode_init(&m_TheoraState, &m_TheoraInfo); + vorbis_synthesis_restart(&m_VorbisDSPState); + + m_SeekingKeyframe = true; + + //theora_packet_iskeyframe + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::pause() { + if (_state == THEORA_STATE_PLAYING) { + _state = THEORA_STATE_PAUSED; + _theoraDecoder->pauseVideo(true); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::resume() { + if (_state == THEORA_STATE_PAUSED) { + _state = THEORA_STATE_PLAYING; + _theoraDecoder->pauseVideo(false); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { + //CBBase::persist(persistMgr); + + if (persistMgr->_saving) { + _savedPos = getMovieTime() * 1000; + _savedState = _state; + } else { + SetDefaults(); + } + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_savedPos)); + persistMgr->transfer(TMEMBER(_savedState)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_alphaFilename)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_playZoom)); + persistMgr->transfer(TMEMBER_INT(_playbackType)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_volume)); + + if (!persistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { + initializeSimple(); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidTheoraPlayer::initializeSimple() { + if (DID_SUCCEED(initialize(_filename))) { + if (_alphaFilename != "") setAlphaImage(_alphaFilename); + play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); + } else _state = THEORA_STATE_FINISHED; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CVidTheoraPlayer::getTexture() { + return _texture; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h new file mode 100644 index 0000000000..5bf8e165c7 --- /dev/null +++ b/engines/wintermute/video/video_theora_player.h @@ -0,0 +1,151 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDTHEORAPLAYER_H +#define WINTERMUTE_VIDTHEORAPLAYER_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/persistent.h" +#include "video/video_decoder.h" +#include "common/stream.h" +#include "graphics/surface.h" + +namespace WinterMute { +class CBSurface; +class CBImage; +class CVidTheoraPlayer : public CBBase { +private: + enum { + THEORA_STATE_NONE = 0, + THEORA_STATE_PLAYING = 1, + THEORA_STATE_PAUSED = 2, + THEORA_STATE_FINISHED = 3 + }; + Video::RewindableVideoDecoder *_theoraDecoder; + Graphics::Surface _surface; +public: + DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase) + + CVidTheoraPlayer(CBGame *inGame); + virtual ~CVidTheoraPlayer(void); + + // external objects + Common::SeekableReadStream *_file; + Common::String _filename; + + CBSurface *_texture; + //CVidSubtitler *_subtitler; + + // control methods + bool initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); + bool initializeSimple(); + bool update(); + bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); + bool stop(); + bool display(uint32 alpha = 0xFFFFFFFF); + //bool RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + + bool pause(); + bool resume(); + + bool isPlaying() { + return _state == THEORA_STATE_PLAYING; + }; + bool isFinished() { + return _state == THEORA_STATE_FINISHED; + }; + bool isPaused() { + return _state == THEORA_STATE_PAUSED; + }; + + uint32 getMovieTime(); + uint32 getMovieFrame(); + + CBSurface *getTexture(); + + int _state; + uint32 _startTime; + + int _savedState; + uint32 _savedPos; + + + // alpha related + CBImage *_alphaImage; + Common::String _alphaFilename; + bool setAlphaImage(const Common::String &filename); + __inline byte getAlphaAt(int x, int y); + void writeAlpha(); + + bool SeekToTime(uint32 Time); + + + void cleanup(); + bool resetStream(); + + // video properties + TVideoPlayback _playbackType; + int _posX; + int _posY; + float _playZoom; + int _volume; + + bool _looping; + bool _dontDropFrames; + bool _freezeGame; + uint32 _currentTime; + + +private: + // seeking support + bool _seekingKeyframe; + float _timeOffset; + + bool _frameRendered; + + bool getIsFrameReady() { + return _videoFrameReady; + } +private: + bool _audioFrameReady; + bool _videoFrameReady; + float _videobufTime; + + bool WriteVideo(); + + bool _playbackStarted; + + // helpers + void SetDefaults(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 220e9f4057..2a651baabf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -31,13 +31,13 @@ #include "common/fs.h" #include "engines/util.h" -#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/scriptables/script_engine.h" namespace WinterMute { -- cgit v1.2.3 From 6e780b04dccdff3f09a760d4bc492a896418f486 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 19:37:05 +0200 Subject: WINTERMUTE: Fix a few Upper_case filenames that got missed in the last commit. --- engines/wintermute/base/base_debugger.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/base_point.cpp | 2 +- engines/wintermute/base/base_region.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 2 +- engines/wintermute/persistent.cpp | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp index f56f08dab2..8adeea2b1f 100644 --- a/engines/wintermute/base/base_debugger.cpp +++ b/engines/wintermute/base/base_debugger.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/base_debugger.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 712f64eb6f..b34e89e41a 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" #include "common/util.h" diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index d5e9c99dcf..00c852e02d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/font/base_font_storage.h" diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 12ab07912b..711eebfc98 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/base_debugger.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 6887349a7a..e878f34387 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 5de1fb9eef..0c35d99bd9 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BREGION_H #define WINTERMUTE_BREGION_H -#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" namespace WinterMute { diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 11ebafd329..b3b05b6e65 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/math/matrix4.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 57997405de..205b448880 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -52,13 +52,13 @@ #include "engines/wintermute/ad/ad_talk_holder.h" #include "engines/wintermute/ad/ad_talk_node.h" #include "engines/wintermute/ad/ad_waypoint_group.h" -#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/font/base_font_bitmap.h" #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_Keyboard_state.h" +#include "engines/wintermute/base/base_keyboard_state.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_region.h" -- cgit v1.2.3 From 2e82471240804df65acdf51c43ea044cbb81ae68 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 19:50:08 +0200 Subject: WINTERMUTE: Get rid of #pragma once. --- engines/wintermute/ad/ad_actor.h | 5 +---- engines/wintermute/video/video_player.h | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index ca79f638d9..67e0630f83 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -37,11 +37,8 @@ #include "engines/wintermute/persistent.h" #include "common/str.h" -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - namespace WinterMute { + class CAdSpriteSet; class CAdPath; class CAdActor : public CAdTalkHolder { diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h index ca6c7fdec5..8dda93b43e 100644 --- a/engines/wintermute/video/video_player.h +++ b/engines/wintermute/video/video_player.h @@ -30,10 +30,6 @@ #define WINTERMUTE_VIDPLAYER_H #include "engines/wintermute/dctypes.h" // Added by ClassView -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - #include "engines/wintermute/base/base.h" #define MAX_AUDIO_STREAMS 5 -- cgit v1.2.3 From b5a07fef8ebf29f7f44b15d9b34799c7e115fdad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 21:01:47 +0200 Subject: WINTERMUTE: Get rid of the C-prefix for class-definitions. --- engines/wintermute/ad/ad_actor.cpp | 166 ++++---- engines/wintermute/ad/ad_actor.h | 46 +- engines/wintermute/ad/ad_entity.cpp | 102 ++--- engines/wintermute/ad/ad_entity.h | 22 +- engines/wintermute/ad/ad_game.cpp | 276 ++++++------ engines/wintermute/ad/ad_game.h | 92 ++-- engines/wintermute/ad/ad_inventory.cpp | 22 +- engines/wintermute/ad/ad_inventory.h | 14 +- engines/wintermute/ad/ad_inventory_box.cpp | 42 +- engines/wintermute/ad/ad_inventory_box.h | 20 +- engines/wintermute/ad/ad_item.cpp | 80 ++-- engines/wintermute/ad/ad_item.h | 20 +- engines/wintermute/ad/ad_layer.cpp | 70 +-- engines/wintermute/ad/ad_layer.h | 20 +- engines/wintermute/ad/ad_node_state.cpp | 26 +- engines/wintermute/ad/ad_node_state.h | 12 +- engines/wintermute/ad/ad_object.cpp | 170 ++++---- engines/wintermute/ad/ad_object.h | 68 +-- engines/wintermute/ad/ad_path.cpp | 20 +- engines/wintermute/ad/ad_path.h | 20 +- engines/wintermute/ad/ad_path_point.cpp | 12 +- engines/wintermute/ad/ad_path_point.h | 12 +- engines/wintermute/ad/ad_region.cpp | 38 +- engines/wintermute/ad/ad_region.h | 16 +- engines/wintermute/ad/ad_response.cpp | 38 +- engines/wintermute/ad/ad_response.h | 18 +- engines/wintermute/ad/ad_response_box.cpp | 82 ++-- engines/wintermute/ad/ad_response_box.h | 42 +- engines/wintermute/ad/ad_response_context.cpp | 10 +- engines/wintermute/ad/ad_response_context.h | 8 +- engines/wintermute/ad/ad_rot_level.cpp | 22 +- engines/wintermute/ad/ad_rot_level.h | 10 +- engines/wintermute/ad/ad_scale_level.cpp | 22 +- engines/wintermute/ad/ad_scale_level.h | 10 +- engines/wintermute/ad/ad_scene.cpp | 340 +++++++-------- engines/wintermute/ad/ad_scene.h | 102 ++--- engines/wintermute/ad/ad_scene_node.cpp | 14 +- engines/wintermute/ad/ad_scene_node.h | 16 +- engines/wintermute/ad/ad_scene_state.cpp | 14 +- engines/wintermute/ad/ad_scene_state.h | 14 +- engines/wintermute/ad/ad_sentence.cpp | 40 +- engines/wintermute/ad/ad_sentence.h | 26 +- engines/wintermute/ad/ad_sprite_set.cpp | 46 +- engines/wintermute/ad/ad_sprite_set.h | 18 +- engines/wintermute/ad/ad_talk_def.cpp | 44 +- engines/wintermute/ad/ad_talk_def.h | 22 +- engines/wintermute/ad/ad_talk_holder.cpp | 42 +- engines/wintermute/ad/ad_talk_holder.h | 24 +- engines/wintermute/ad/ad_talk_node.cpp | 38 +- engines/wintermute/ad/ad_talk_node.h | 20 +- engines/wintermute/ad/ad_waypoint_group.cpp | 38 +- engines/wintermute/ad/ad_waypoint_group.h | 20 +- engines/wintermute/base/base.cpp | 16 +- engines/wintermute/base/base.h | 18 +- engines/wintermute/base/base_active_rect.cpp | 22 +- engines/wintermute/base/base_active_rect.h | 22 +- engines/wintermute/base/base_debugger.cpp | 66 +-- engines/wintermute/base/base_debugger.h | 34 +- engines/wintermute/base/base_dynamic_buffer.cpp | 34 +- engines/wintermute/base/base_dynamic_buffer.h | 6 +- engines/wintermute/base/base_fader.cpp | 28 +- engines/wintermute/base/base_fader.h | 8 +- engines/wintermute/base/base_file_manager.cpp | 78 ++-- engines/wintermute/base/base_file_manager.h | 16 +- engines/wintermute/base/base_frame.cpp | 70 +-- engines/wintermute/base/base_frame.h | 36 +- engines/wintermute/base/base_game.cpp | 468 ++++++++++----------- engines/wintermute/base/base_game.h | 138 +++--- engines/wintermute/base/base_keyboard_state.cpp | 42 +- engines/wintermute/base/base_keyboard_state.h | 14 +- engines/wintermute/base/base_named_object.cpp | 10 +- engines/wintermute/base/base_named_object.h | 10 +- engines/wintermute/base/base_object.cpp | 94 ++--- engines/wintermute/base/base_object.h | 40 +- engines/wintermute/base/base_parser.cpp | 26 +- engines/wintermute/base/base_parser.h | 8 +- .../wintermute/base/base_persistence_manager.cpp | 86 ++-- engines/wintermute/base/base_persistence_manager.h | 6 +- engines/wintermute/base/base_point.cpp | 10 +- engines/wintermute/base/base_point.h | 10 +- engines/wintermute/base/base_quick_msg.cpp | 6 +- engines/wintermute/base/base_quick_msg.h | 6 +- engines/wintermute/base/base_region.cpp | 66 +-- engines/wintermute/base/base_region.h | 20 +- engines/wintermute/base/base_registry.cpp | 34 +- engines/wintermute/base/base_registry.h | 6 +- engines/wintermute/base/base_save_thumb_helper.cpp | 10 +- engines/wintermute/base/base_save_thumb_helper.h | 12 +- engines/wintermute/base/base_script_holder.cpp | 70 +-- engines/wintermute/base/base_script_holder.h | 24 +- engines/wintermute/base/base_scriptable.cpp | 50 +-- engines/wintermute/base/base_scriptable.h | 44 +- engines/wintermute/base/base_sprite.cpp | 92 ++-- engines/wintermute/base/base_sprite.h | 32 +- engines/wintermute/base/base_string_table.cpp | 22 +- engines/wintermute/base/base_string_table.h | 6 +- engines/wintermute/base/base_sub_frame.cpp | 68 +-- engines/wintermute/base/base_sub_frame.h | 26 +- engines/wintermute/base/base_surface_storage.cpp | 34 +- engines/wintermute/base/base_surface_storage.h | 16 +- .../wintermute/base/base_transition_manager.cpp | 18 +- engines/wintermute/base/base_transition_manager.h | 6 +- engines/wintermute/base/base_viewport.cpp | 20 +- engines/wintermute/base/base_viewport.h | 12 +- engines/wintermute/base/file/BPkgFile.cpp | 7 +- engines/wintermute/base/file/BPkgFile.h | 4 +- engines/wintermute/base/file/base_disk_file.cpp | 2 +- engines/wintermute/base/file/base_disk_file.h | 2 +- engines/wintermute/base/file/base_file.cpp | 8 +- engines/wintermute/base/file/base_file.h | 6 +- engines/wintermute/base/file/base_file_entry.cpp | 4 +- engines/wintermute/base/file/base_file_entry.h | 10 +- engines/wintermute/base/file/base_package.cpp | 14 +- engines/wintermute/base/file/base_package.h | 6 +- engines/wintermute/base/file/base_resources.cpp | 2 +- engines/wintermute/base/file/base_resources.h | 2 +- .../wintermute/base/file/base_save_thumb_file.cpp | 14 +- .../wintermute/base/file/base_save_thumb_file.h | 6 +- engines/wintermute/base/font/base_font.cpp | 36 +- engines/wintermute/base/font/base_font.h | 12 +- engines/wintermute/base/font/base_font_bitmap.cpp | 44 +- engines/wintermute/base/font/base_font_bitmap.h | 14 +- engines/wintermute/base/font/base_font_storage.cpp | 20 +- engines/wintermute/base/font/base_font_storage.h | 16 +- .../wintermute/base/font/base_font_truetype.cpp | 78 ++-- engines/wintermute/base/font/base_font_truetype.h | 30 +- engines/wintermute/base/gfx/base_image.cpp | 20 +- engines/wintermute/base/gfx/base_image.h | 10 +- engines/wintermute/base/gfx/base_renderer.cpp | 54 +-- engines/wintermute/base/gfx/base_renderer.h | 24 +- engines/wintermute/base/gfx/base_surface.cpp | 34 +- engines/wintermute/base/gfx/base_surface.h | 6 +- .../base/gfx/osystem/base_render_osystem.cpp | 78 ++-- .../base/gfx/osystem/base_render_osystem.h | 20 +- .../base/gfx/osystem/base_surface_osystem.cpp | 72 ++-- .../base/gfx/osystem/base_surface_osystem.h | 8 +- engines/wintermute/base/particles/part_emitter.cpp | 112 ++--- engines/wintermute/base/particles/part_emitter.h | 34 +- engines/wintermute/base/particles/part_force.cpp | 6 +- engines/wintermute/base/particles/part_force.h | 8 +- .../wintermute/base/particles/part_particle.cpp | 42 +- engines/wintermute/base/particles/part_particle.h | 20 +- engines/wintermute/base/scriptables/script.cpp | 158 +++---- engines/wintermute/base/scriptables/script.h | 62 +-- .../wintermute/base/scriptables/script_engine.cpp | 110 ++--- .../wintermute/base/scriptables/script_engine.h | 38 +- .../base/scriptables/script_ext_array.cpp | 34 +- .../wintermute/base/scriptables/script_ext_array.h | 20 +- .../base/scriptables/script_ext_date.cpp | 28 +- .../wintermute/base/scriptables/script_ext_date.h | 16 +- .../base/scriptables/script_ext_file.cpp | 56 +-- .../wintermute/base/scriptables/script_ext_file.h | 16 +- .../base/scriptables/script_ext_math.cpp | 22 +- .../wintermute/base/scriptables/script_ext_math.h | 12 +- .../base/scriptables/script_ext_mem_buffer.cpp | 42 +- .../base/scriptables/script_ext_mem_buffer.h | 20 +- .../base/scriptables/script_ext_object.cpp | 14 +- .../base/scriptables/script_ext_object.h | 8 +- .../base/scriptables/script_ext_string.cpp | 44 +- .../base/scriptables/script_ext_string.h | 16 +- .../wintermute/base/scriptables/script_stack.cpp | 50 +-- engines/wintermute/base/scriptables/script_stack.h | 26 +- .../wintermute/base/scriptables/script_value.cpp | 158 +++---- engines/wintermute/base/scriptables/script_value.h | 50 +-- engines/wintermute/base/sound/base_sound.cpp | 46 +- engines/wintermute/base/sound/base_sound.h | 12 +- .../wintermute/base/sound/base_sound_buffer.cpp | 62 +-- engines/wintermute/base/sound/base_sound_buffer.h | 8 +- .../wintermute/base/sound/base_sound_manager.cpp | 44 +- engines/wintermute/base/sound/base_sound_manager.h | 18 +- engines/wintermute/coll_templ.h | 66 +-- engines/wintermute/detection.cpp | 6 +- engines/wintermute/persistent.cpp | 134 +++--- engines/wintermute/persistent.h | 16 +- engines/wintermute/platform_osystem.cpp | 66 +-- engines/wintermute/platform_osystem.h | 8 +- engines/wintermute/system/sys_class.cpp | 42 +- engines/wintermute/system/sys_class.h | 36 +- engines/wintermute/system/sys_class_registry.cpp | 46 +- engines/wintermute/system/sys_class_registry.h | 44 +- engines/wintermute/system/sys_instance.cpp | 4 +- engines/wintermute/system/sys_instance.h | 12 +- engines/wintermute/ui/ui_button.cpp | 100 ++--- engines/wintermute/ui/ui_button.h | 40 +- engines/wintermute/ui/ui_edit.cpp | 82 ++-- engines/wintermute/ui/ui_edit.h | 20 +- engines/wintermute/ui/ui_entity.cpp | 42 +- engines/wintermute/ui/ui_entity.h | 20 +- engines/wintermute/ui/ui_object.cpp | 72 ++-- engines/wintermute/ui/ui_object.h | 36 +- engines/wintermute/ui/ui_text.cpp | 52 +-- engines/wintermute/ui/ui_text.h | 16 +- engines/wintermute/ui/ui_tiled_image.cpp | 82 ++-- engines/wintermute/ui/ui_tiled_image.h | 14 +- engines/wintermute/ui/ui_window.cpp | 154 +++---- engines/wintermute/ui/ui_window.h | 38 +- engines/wintermute/utils/utils.cpp | 44 +- engines/wintermute/utils/utils.h | 4 +- engines/wintermute/video/video_player.cpp | 26 +- engines/wintermute/video/video_player.h | 10 +- engines/wintermute/video/video_theora_player.cpp | 72 ++-- engines/wintermute/video/video_theora_player.h | 20 +- engines/wintermute/wintermute.cpp | 16 +- engines/wintermute/wintermute.h | 10 +- 204 files changed, 4085 insertions(+), 4082 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 36f1aa8286..1da28cd93d 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -52,12 +52,12 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdActor, false) +IMPLEMENT_PERSISTENT(AdActor, false) ////////////////////////////////////////////////////////////////////////// -CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { - _path = new CAdPath(_gameRef); +AdActor::AdActor(BaseGame *inGame): AdTalkHolder(inGame) { + _path = new AdPath(_gameRef); _type = OBJECT_ACTOR; _dir = DI_LEFT; @@ -67,7 +67,7 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { _turnLeftSprite = NULL; _turnRightSprite = NULL; - _targetPoint = new CBPoint; + _targetPoint = new BasePoint; _afterWalkDir = DI_NONE; _animSprite2 = NULL; @@ -76,7 +76,7 @@ CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) { } ////////////////////////////////////////////////////////////////////////// -bool CAdActor::setDefaultAnimNames() { +bool AdActor::setDefaultAnimNames() { _talkAnimName = "talk"; _idleAnimName = "idle"; _walkAnimName = "walk"; @@ -86,7 +86,7 @@ bool CAdActor::setDefaultAnimNames() { } ////////////////////////////////////////////////////////////////////////// -CAdActor::~CAdActor() { +AdActor::~AdActor() { delete _path; delete _targetPoint; _path = NULL; @@ -123,10 +123,10 @@ CAdActor::~CAdActor() { ////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadFile(const char *filename) { +bool AdActor::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -183,7 +183,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(ANIMATION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdActor::loadBuffer(byte *buffer, bool complete) { +bool AdActor::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTOR) TOKEN_TABLE(X) @@ -225,7 +225,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { @@ -235,8 +235,8 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { buffer = params; } - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSpriteSet *spr = NULL; + AdGame *adGame = (AdGame *)_gameRef; + AdSpriteSet *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -290,19 +290,19 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_WALK: delete _walkSprite; _walkSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; else _walkSprite = spr; break; case TOKEN_TALK: - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); break; case TOKEN_TALK_SPECIAL: - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); break; @@ -310,7 +310,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_STAND: delete _standSprite; _standSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; else _standSprite = spr; break; @@ -318,7 +318,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_LEFT: delete _turnLeftSprite; _turnLeftSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnLeftSprite = spr; break; @@ -326,7 +326,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_RIGHT: delete _turnRightSprite; _turnRightSprite = NULL; - spr = new CAdSpriteSet(_gameRef, this); + spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; else _turnRightSprite = spr; break; @@ -337,7 +337,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -378,8 +378,8 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentBlockRegion; _blockRegion = NULL; _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); + BaseRegion *rgn = new BaseRegion(_gameRef); + BaseRegion *crgn = new BaseRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; delete _currentBlockRegion; @@ -399,8 +399,8 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentWptGroup; _wptGroup = NULL; _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); + AdWaypointGroup *cwpt = new AdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; delete _currentWptGroup; @@ -432,7 +432,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + AdSpriteSet *Anim = new AdSpriteSet(_gameRef, this); if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else _anims.add(Anim); } @@ -460,7 +460,7 @@ bool CAdActor::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -void CAdActor::turnTo(TDirection dir) { +void AdActor::turnTo(TDirection dir) { int delta1, delta2, delta3, delta; delta1 = dir - _dir; @@ -486,7 +486,7 @@ void CAdActor::turnTo(TDirection dir) { ////////////////////////////////////////////////////////////////////////// -void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { +void AdActor::goTo(int x, int y, TDirection afterWalkDir) { _afterWalkDir = afterWalkDir; if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; @@ -496,7 +496,7 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { _targetPoint->x = x; _targetPoint->y = y; - ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); + ((AdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this); _state = STATE_SEARCHING_PATH; @@ -504,12 +504,12 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { ////////////////////////////////////////////////////////////////////////// -bool CAdActor::display() { +bool AdActor::display() { if (_active) updateSounds(); uint32 alpha; if (_alphaColor != 0) alpha = _alphaColor; - else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + else alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; float scaleX, scaleY; getScale(&scaleX, &scaleY); @@ -518,14 +518,14 @@ bool CAdActor::display() { float rotate; if (_rotatable) { if (_rotateValid) rotate = _rotate; - else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + else rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else rotate = 0.0f; if (_active) displaySpriteAttachments(true); if (_currentSprite && _active) { bool reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false; + if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) reg = false; _currentSprite->display(_posX, _posY, @@ -547,7 +547,7 @@ bool CAdActor::display() { ////////////////////////////////////////////////////////////////////////// -bool CAdActor::update() { +bool AdActor::update() { _currentSprite = NULL; if (_state == STATE_READY) { @@ -582,7 +582,7 @@ bool CAdActor::update() { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + AdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } @@ -615,7 +615,7 @@ bool CAdActor::update() { if (_turnLeftSprite) { _tempSprite2 = _turnLeftSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); + AdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); if (Anim) _tempSprite2 = Anim->getSprite(_dir); } @@ -644,7 +644,7 @@ bool CAdActor::update() { if (_turnRightSprite) { _tempSprite2 = _turnRightSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = getAnimByName(_turnRightAnimName); + AdSpriteSet *Anim = getAnimByName(_turnRightAnimName); if (Anim) _tempSprite2 = Anim->getSprite(_dir); } @@ -661,7 +661,7 @@ bool CAdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_SEARCHING_PATH: // keep asking scene for the path - if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this)) + if (((AdGame *)_gameRef)->_scene->getPath(BasePoint(_posX, _posY), *_targetPoint, _path, this)) _state = STATE_WAITING_PATH; break; @@ -696,12 +696,12 @@ bool CAdActor::update() { if (_tempSprite2) { _tempSprite2->reset(); _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } } else { _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } break; @@ -714,7 +714,7 @@ bool CAdActor::update() { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + AdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } @@ -726,7 +726,7 @@ bool CAdActor::update() { if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -747,7 +747,7 @@ bool CAdActor::update() { ////////////////////////////////////////////////////////////////////////// -void CAdActor::followPath() { +void AdActor::followPath() { // skip current position _path->getFirst(); while (_path->getCurrent() != NULL) { @@ -758,7 +758,7 @@ void CAdActor::followPath() { // are there points to follow? if (_path->getCurrent() != NULL) { _state = STATE_FOLLOWING_PATH;; - initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + initLine(BasePoint(_posX, _posY), *_path->getCurrent()); } else { if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); else _state = STATE_READY; @@ -767,17 +767,17 @@ void CAdActor::followPath() { ////////////////////////////////////////////////////////////////////////// -void CAdActor::getNextStep() { +void AdActor::getNextStep() { if (_walkSprite) { _currentSprite = _walkSprite->getSprite(_dir); } else { - CAdSpriteSet *Anim = getAnimByName(_walkAnimName); + AdSpriteSet *Anim = getAnimByName(_walkAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } if (!_currentSprite) return; - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (!_currentSprite->_changed) return; @@ -796,7 +796,7 @@ void CAdActor::getNextStep() { maxStepX--; } - if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { + if (((AdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { if (_pFCount == 0) { _state = _nextState; _nextState = STATE_READY; @@ -824,13 +824,13 @@ void CAdActor::getNextStep() { _state = _nextState; _nextState = STATE_READY; } - } else initLine(CBPoint(_posX, _posY), *_path->getCurrent()); + } else initLine(BasePoint(_posX, _posY), *_path->getCurrent()); } } ////////////////////////////////////////////////////////////////////////// -void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { +void AdActor::initLine(BasePoint startPt, BasePoint endPt) { _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; @@ -850,7 +850,7 @@ void CAdActor::initLine(CBPoint startPt, CBPoint endPt) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GoTo / GoToAsync ////////////////////////////////////////////////////////////////////////// @@ -869,19 +869,19 @@ bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (!Val->isNative()) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return STATUS_OK; } - CAdObject *Obj = (CAdObject *)Val->getNative(); + AdObject *Obj = (AdObject *)Val->getNative(); if (!Obj || Obj->_type != OBJECT_ENTITY) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return STATUS_OK; } - CAdEntity *Ent = (CAdEntity *)Obj; + AdEntity *Ent = (AdEntity *)Obj; if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); @@ -895,11 +895,11 @@ bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) { stack->correctParams(1); int dir; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); // turn to object? - if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) { - CBObject *obj = (CBObject *)val->getNative(); + if (val->isNative() && _gameRef->validObject((BaseObject *)val->getNative())) { + BaseObject *obj = (BaseObject *)val->getNative(); int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14)); dir = (int)angleToDirection(angle); } @@ -968,12 +968,12 @@ bool CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); + else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdActor::scGetProperty(const char *name) { +ScValue *AdActor::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1030,12 +1030,12 @@ CScValue *CAdActor::scGetProperty(const char *name) { return _scValue; } - else return CAdTalkHolder::scGetProperty(name); + else return AdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdActor::scSetProperty(const char *name, CScValue *value) { +bool AdActor::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// @@ -1090,27 +1090,27 @@ bool CAdActor::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CAdTalkHolder::scSetProperty(name, value); + else return AdTalkHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdActor::scToString() { +const char *AdActor::scToString() { return "[actor object]"; } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStance(const char *stance) { +BaseSprite *AdActor::getTalkStance(const char *stance) { // forced stance? if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); + _animSprite = new BaseSprite(_gameRef, this); if (_animSprite) { bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -1122,15 +1122,15 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { return getTalkStanceOld(stance); // new way - CBSprite *ret = NULL; + BaseSprite *ret = NULL; // do we have an animation with this name? - CAdSpriteSet *Anim = getAnimByName(stance); + AdSpriteSet *Anim = getAnimByName(stance); if (Anim) ret = Anim->getSprite(_dir); // not - get a random talk if (!ret) { - CBArray TalkAnims; + BaseArray TalkAnims; for (int i = 0; i < _anims.getSize(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) TalkAnims.add(_anims[i]); @@ -1151,8 +1151,8 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdActor::getTalkStanceOld(const char *stance) { - CBSprite *ret = NULL; +BaseSprite *AdActor::getTalkStanceOld(const char *stance) { + BaseSprite *ret = NULL; if (stance != NULL) { // search special stances @@ -1187,8 +1187,8 @@ CBSprite *CAdActor::getTalkStanceOld(const char *stance) { } ////////////////////////////////////////////////////////////////////////// -bool CAdActor::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); +bool AdActor::persist(BasePersistenceManager *persistMgr) { + AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_dir)); persistMgr->transfer(TMEMBER(_path)); @@ -1221,7 +1221,7 @@ bool CAdActor::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -TDirection CAdActor::angleToDirection(int angle) { +TDirection AdActor::angleToDirection(int angle) { TDirection ret = DI_DOWN;; if (angle > -112 && angle <= -67) ret = DI_UP; @@ -1238,22 +1238,22 @@ TDirection CAdActor::angleToDirection(int angle) { ////////////////////////////////////////////////////////////////////////// -int CAdActor::getHeight() { +int AdActor::getHeight() { // if no current sprite is set, set some if (_currentSprite == NULL) { if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); else { - CAdSpriteSet *Anim = getAnimByName(_idleAnimName); + AdSpriteSet *Anim = getAnimByName(_idleAnimName); if (Anim) _currentSprite = Anim->getSprite(_dir); } } // and get height - return CAdTalkHolder::getHeight(); + return AdTalkHolder::getHeight(); } ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { +AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.getSize(); i++) { if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) return _anims[i]; @@ -1262,7 +1262,7 @@ CAdSpriteSet *CAdActor::getAnimByName(const Common::String &animName) { } ////////////////////////////////////////////////////////////////////////// -bool CAdActor::mergeAnims(const char *animsFilename) { +bool AdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ANIMATION) TOKEN_TABLE_END @@ -1270,21 +1270,21 @@ bool CAdActor::mergeAnims(const char *animsFilename) { byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); if (fileBuffer == NULL) { - _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename); + _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); return STATUS_FAILED; } byte *buffer = fileBuffer; byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); bool Ret = STATUS_OK; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { - CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this); + AdSpriteSet *Anim = new AdSpriteSet(_gameRef, this); if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = STATUS_FAILED; @@ -1298,9 +1298,9 @@ bool CAdActor::mergeAnims(const char *animsFilename) { } ////////////////////////////////////////////////////////////////////////// -bool CAdActor::playAnim(const char *filename) { +bool AdActor::playAnim(const char *filename) { // if we have an anim with this name, use it - CAdSpriteSet *Anim = getAnimByName(filename); + AdSpriteSet *Anim = getAnimByName(filename); if (Anim) { _animSprite2 = Anim->getSprite(_dir); if (_animSprite2) { @@ -1310,7 +1310,7 @@ bool CAdActor::playAnim(const char *filename) { } } // otherwise call the standard handler - return CAdTalkHolder::playAnim(filename); + return AdTalkHolder::playAnim(filename); } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 67e0630f83..3cce827b17 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -39,31 +39,31 @@ namespace WinterMute { -class CAdSpriteSet; -class CAdPath; -class CAdActor : public CAdTalkHolder { +class AdSpriteSet; +class AdPath; +class AdActor : public AdTalkHolder { public: TDirection angleToDirection(int angle); - DECLARE_PERSISTENT(CAdActor, CAdTalkHolder) + DECLARE_PERSISTENT(AdActor, AdTalkHolder) virtual int getHeight(); - CBSprite *getTalkStance(const char *stance); + BaseSprite *getTalkStance(const char *stance); virtual void goTo(int x, int y, TDirection afterWalkDir = DI_NONE); - CBPoint *_targetPoint; + BasePoint *_targetPoint; virtual bool update(); virtual bool display(); TDirection _targetDir; TDirection _afterWalkDir; virtual void turnTo(TDirection dir); - CAdPath *_path; - CAdSpriteSet *_walkSprite; - CAdSpriteSet *_standSprite; - CAdSpriteSet *_turnLeftSprite; - CAdSpriteSet *_turnRightSprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; + AdPath *_path; + AdSpriteSet *_walkSprite; + AdSpriteSet *_standSprite; + AdSpriteSet *_turnLeftSprite; + AdSpriteSet *_turnRightSprite; + BaseArray _talkSprites; + BaseArray _talkSpritesEx; TDirection _dir; - CAdActor(CBGame *inGame/*=NULL*/); - virtual ~CAdActor(); + AdActor(BaseGame *inGame/*=NULL*/); + virtual ~AdActor(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); @@ -73,23 +73,23 @@ public: Common::String _walkAnimName; Common::String _turnLeftAnimName; Common::String _turnRightAnimName; - CBArray _anims; + BaseArray _anims; virtual bool playAnim(const char *filename); - CAdSpriteSet *getAnimByName(const Common::String &animName); + AdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: bool setDefaultAnimNames(); - CBSprite *getTalkStanceOld(const char *stance); + BaseSprite *getTalkStanceOld(const char *stance); bool mergeAnims(const char *animsFilename); - CBSprite *_animSprite2; + BaseSprite *_animSprite2; - void initLine(CBPoint startPt, CBPoint endPt); + void initLine(BasePoint startPt, BasePoint endPt); void getNextStep(); void followPath(); double _pFStepX; diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 5f32017264..06a551b252 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -55,10 +55,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdEntity, false) +IMPLEMENT_PERSISTENT(AdEntity, false) ////////////////////////////////////////////////////////////////////////// -CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { +AdEntity::AdEntity(BaseGame *inGame): AdTalkHolder(inGame) { _type = OBJECT_ENTITY; _subtype = ENTITY_NORMAL; _region = NULL; @@ -72,7 +72,7 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdEntity::~CAdEntity() { +AdEntity::~AdEntity() { _gameRef->unregisterObject(_region); delete _theora; @@ -84,10 +84,10 @@ CAdEntity::~CAdEntity() { ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadFile(const char *filename) { +bool AdEntity::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -150,7 +150,7 @@ TOKEN_DEF(WALK_TO_DIR) TOKEN_DEF(SAVE_STATE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::loadBuffer(byte *buffer, bool complete) { +bool AdEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SPRITE) @@ -198,7 +198,7 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { @@ -208,8 +208,8 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { buffer = params; } - CAdGame *adGame = (CAdGame *)_gameRef; - CBSprite *spr = NULL; + AdGame *adGame = (AdGame *)_gameRef; + BaseSprite *spr = NULL; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -228,21 +228,21 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE: { delete _sprite; _sprite = NULL; - spr = new CBSprite(_gameRef, this); + spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; else _sprite = spr; } break; case TOKEN_TALK: { - spr = new CBSprite(_gameRef, this); + spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { - spr = new CBSprite(_gameRef, this); + spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); } @@ -305,7 +305,7 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -320,7 +320,7 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_REGION: { if (_region) _gameRef->unregisterObject(_region); _region = NULL; - CBRegion *rgn = new CBRegion(_gameRef); + BaseRegion *rgn = new BaseRegion(_gameRef); if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; else { _region = rgn; @@ -334,8 +334,8 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { _blockRegion = NULL; delete _currentBlockRegion; _currentBlockRegion = NULL; - CBRegion *rgn = new CBRegion(_gameRef); - CBRegion *crgn = new CBRegion(_gameRef); + BaseRegion *rgn = new BaseRegion(_gameRef); + BaseRegion *crgn = new BaseRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; _blockRegion = NULL; @@ -355,8 +355,8 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { _wptGroup = NULL; delete _currentWptGroup; _currentWptGroup = NULL; - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); - CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef); + AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); + AdWaypointGroup *cwpt = new AdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; _wptGroup = NULL; @@ -380,7 +380,7 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { delete _sprite; _sprite = NULL; if (_gameRef->_editorMode) { - spr = new CBSprite(_gameRef, this); + spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; else _sprite = spr; } @@ -474,20 +474,20 @@ bool CAdEntity::loadBuffer(byte *buffer, bool complete) { _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = STATE_READY; - if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false; + if (_item && ((AdGame *)_gameRef)->isItemTaken(_item)) _active = false; return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::display() { +bool AdEntity::display() { if (_active) { updateSounds(); uint32 Alpha; if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + else Alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; float ScaleX, ScaleY; getScale(&ScaleX, &ScaleY); @@ -495,15 +495,15 @@ bool CAdEntity::display() { float Rotate; if (_rotatable) { if (_rotateValid) Rotate = _rotate; - else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + else Rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; } else Rotate = 0.0f; bool Reg = _registrable; - if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false; + if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) Reg = false; if (_region && (Reg || _editorAlwaysRegister)) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); } displaySpriteAttachments(true); @@ -529,7 +529,7 @@ bool CAdEntity::display() { ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::update() { +bool AdEntity::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -577,11 +577,11 @@ bool CAdEntity::update() { _tempSprite2->reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } break; @@ -591,7 +591,7 @@ bool CAdEntity::update() { if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -625,7 +625,7 @@ bool CAdEntity::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // StopSound ////////////////////////////////////////////////////////////////////////// @@ -644,11 +644,11 @@ bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(4); const char *filename = stack->pop()->getString(); bool looping = stack->pop()->getBool(false); - CScValue *valAlpha = stack->pop(); + ScValue *valAlpha = stack->pop(); int startTime = stack->pop()->getInt(); delete _theora; - _theora = new CVidTheoraPlayer(_gameRef); + _theora = new VideoTheoraPlayer(_gameRef); if (_theora && DID_SUCCEED(_theora->initialize(filename))) { if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); @@ -732,7 +732,7 @@ bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "CreateRegion") == 0) { stack->correctParams(0); if (!_region) { - _region = new CBRegion(_gameRef); + _region = new BaseRegion(_gameRef); _gameRef->registerObject(_region); } if (_region) stack->pushNative(_region, true); @@ -755,12 +755,12 @@ bool CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); + else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdEntity::scGetProperty(const char *name) { +ScValue *AdEntity::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -826,12 +826,12 @@ CScValue *CAdEntity::scGetProperty(const char *name) { return _scValue; } - else return CAdTalkHolder::scGetProperty(name); + else return AdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::scSetProperty(const char *name, CScValue *value) { +bool AdEntity::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item @@ -866,18 +866,18 @@ bool CAdEntity::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CAdTalkHolder::scSetProperty(name, value); + else return AdTalkHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdEntity::scToString() { +const char *AdEntity::scToString() { return "[entity object]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); if (_subtype == ENTITY_SOUND) @@ -942,13 +942,13 @@ bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { if (_cursor && _cursor->_filename) buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); - CAdTalkHolder::saveAsText(buffer, indent + 2); + AdTalkHolder::saveAsText(buffer, indent + 2); if (_region) _region->saveAsText(buffer, indent + 2); if (_scProp) _scProp->saveAsText(buffer, indent + 2); - CAdObject::saveAsText(buffer, indent + 2); + AdObject::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n\n"); @@ -957,18 +957,18 @@ bool CAdEntity::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -int CAdEntity::getHeight() { +int AdEntity::getHeight() { if (_region && !_sprite) { return _region->_rect.bottom - _region->_rect.top; } else { if (_currentSprite == NULL) _currentSprite = _sprite; - return CAdObject::getHeight(); + return AdObject::getHeight(); } } ////////////////////////////////////////////////////////////////////////// -void CAdEntity::updatePosition() { +void AdEntity::updatePosition() { if (_region && !_sprite) { _posX = _region->_rect.left + (_region->_rect.right - _region->_rect.left) / 2; _posY = _region->_rect.bottom; @@ -977,8 +977,8 @@ void CAdEntity::updatePosition() { ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::persist(CBPersistMgr *persistMgr) { - CAdTalkHolder::persist(persistMgr); +bool AdEntity::persist(BasePersistenceManager *persistMgr) { + AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_item)); persistMgr->transfer(TMEMBER(_region)); @@ -998,12 +998,12 @@ bool CAdEntity::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdEntity::setItem(const char *itemName) { - CBUtils::setString(&_item, itemName); +void AdEntity::setItem(const char *itemName) { + BaseUtils::setString(&_item, itemName); } ////////////////////////////////////////////////////////////////////////// -bool CAdEntity::setSprite(const char *filename) { +bool AdEntity::setSprite(const char *filename) { bool setCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; @@ -1012,7 +1012,7 @@ bool CAdEntity::setSprite(const char *filename) { delete _sprite; _sprite = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); + BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { delete _sprite; _sprite = NULL; diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h index 8b67d27c1f..9931327916 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -32,33 +32,33 @@ #include "engines/wintermute/ad/ad_talk_holder.h" namespace WinterMute { -class CVidTheoraPlayer; -class CAdEntity : public CAdTalkHolder { +class VideoTheoraPlayer; +class AdEntity : public AdTalkHolder { public: - CVidTheoraPlayer *_theora; + VideoTheoraPlayer *_theora; bool setSprite(const char *filename); int _walkToX; int _walkToY; TDirection _walkToDir; void setItem(const char *itemName); char *_item; - DECLARE_PERSISTENT(CAdEntity, CAdTalkHolder) + DECLARE_PERSISTENT(AdEntity, AdTalkHolder) void updatePosition(); virtual int getHeight(); - CBRegion *_region; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + BaseRegion *_region; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); virtual bool update(); virtual bool display(); - CAdEntity(CBGame *inGame); - virtual ~CAdEntity(); + AdEntity(BaseGame *inGame); + virtual ~AdEntity(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); TEntityType _subtype; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 69cda25f29..e10ec1bf6d 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -63,14 +63,14 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdGame, true) +IMPLEMENT_PERSISTENT(AdGame, true) ////////////////////////////////////////////////////////////////////////// -CAdGame::CAdGame(): CBGame() { +AdGame::AdGame(): BaseGame() { _responseBox = NULL; _inventoryBox = NULL; - _scene = new CAdScene(_gameRef); + _scene = new AdScene(_gameRef); _scene->setName(""); registerObject(_scene); @@ -98,7 +98,7 @@ CAdGame::CAdGame(): CBGame() { _debugStartupScene = NULL; _startupScene = NULL; - _invObject = new CAdObject(this); + _invObject = new AdObject(this); _inventoryOwner = _invObject; _tempDisableSaveState = false; @@ -111,13 +111,13 @@ CAdGame::CAdGame(): CBGame() { ////////////////////////////////////////////////////////////////////////// -CAdGame::~CAdGame() { +AdGame::~AdGame() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::cleanup() { +bool AdGame::cleanup() { int i; for (i = 0; i < _objects.getSize(); i++) { @@ -190,12 +190,12 @@ bool CAdGame::cleanup() { for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; _responsesGame.removeAll(); - return CBGame::cleanup(); + return BaseGame::cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::initLoop() { +bool AdGame::initLoop() { if (_scheduledScene && _transMgr->isReady()) { changeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; @@ -206,7 +206,7 @@ bool CAdGame::initLoop() { bool res; - res = CBGame::initLoop(); + res = BaseGame::initLoop(); if (DID_FAIL(res)) return res; if (_scene) res = _scene->initLoop(); @@ -218,14 +218,14 @@ bool CAdGame::initLoop() { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::addObject(CAdObject *object) { +bool AdGame::addObject(AdObject *object) { _objects.add(object); return registerObject(object); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeObject(CAdObject *object) { +bool AdGame::removeObject(AdObject *object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { bool Res = _scene->removeObject(object); @@ -243,9 +243,9 @@ bool CAdGame::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::changeScene(const char *filename, bool fadeIn) { +bool AdGame::changeScene(const char *filename, bool fadeIn) { if (_scene == NULL) { - _scene = new CAdScene(_gameRef); + _scene = new AdScene(_gameRef); registerObject(_scene); } else { _scene->applyEvent("SceneShutdown", true); @@ -287,13 +287,13 @@ bool CAdGame::changeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::addSentence(CAdSentence *sentence) { +void AdGame::addSentence(AdSentence *sentence) { _sentences.add(sentence); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::displaySentences(bool frozen) { +bool AdGame::displaySentences(bool frozen) { for (int i = 0; i < _sentences.getSize(); i++) { if (frozen && _sentences[i]->_freezable) continue; else _sentences[i]->display(); @@ -303,7 +303,7 @@ bool CAdGame::displaySentences(bool frozen) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::finishSentences() { +void AdGame::finishSentences() { for (int i = 0; i < _sentences.getSize(); i++) { if (_sentences[i]->CanSkip()) { _sentences[i]->_duration = 0; @@ -316,15 +316,15 @@ void CAdGame::finishSentences() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // ChangeScene ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "ChangeScene") == 0) { stack->correctParams(3); const char *filename = stack->pop()->getString(); - CScValue *valFadeOut = stack->pop(); - CScValue *valFadeIn = stack->pop(); + ScValue *valFadeOut = stack->pop(); + ScValue *valFadeIn = stack->pop(); bool transOut = valFadeOut->isNULL() ? true : valFadeOut->getBool(); bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); @@ -346,7 +346,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); + AdActor *act = new AdActor(_gameRef); if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); @@ -363,7 +363,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); + AdEntity *ent = new AdEntity(_gameRef); if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); @@ -380,8 +380,8 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); + ScValue *val = stack->pop(); + AdObject *obj = (AdObject *)val->getNative(); removeObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); @@ -394,9 +394,9 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdEntity *ent = new CAdEntity(_gameRef); + AdEntity *ent = new AdEntity(_gameRef); addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -408,9 +408,9 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateItem") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdItem *item = new CAdItem(_gameRef); + AdItem *item = new AdItem(_gameRef); addItem(item); if (!val->isNULL()) item->setName(val->getString()); stack->pushNative(item, true); @@ -422,10 +422,10 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteItem") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdItem *item = NULL; - if (val->isNative()) item = (CAdItem *)val->getNative(); + AdItem *item = NULL; + if (val->isNative()) item = (AdItem *)val->getNative(); else item = getItemByName(val->getString()); if (item) { @@ -441,9 +441,9 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "QueryItem") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdItem *item = NULL; + AdItem *item = NULL; if (val->isInt()) { int index = val->getInt(); if (index >= 0 && index < _items.getSize()) item = _items[index]; @@ -465,13 +465,13 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(6); int id = stack->pop()->getInt(); const char *text = stack->pop()->getString(); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - CScValue *val4 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *val3 = stack->pop(); + ScValue *val4 = stack->pop(); if (_responseBox) { - CAdResponse *res = new CAdResponse(_gameRef); + AdResponse *res = new AdResponse(_gameRef); if (res) { res->_iD = id; res->setText(text); @@ -573,7 +573,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartDlgBranch") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); Common::String branchName; if (val->isNULL()) { branchName.format("line%d", script->_currentLine); @@ -592,7 +592,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(1); const char *branchName = NULL; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (!val->isNULL()) branchName = val->getString(); endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); @@ -648,10 +648,10 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta else if (strcmp(name, "IsItemTaken") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (!val->isNULL()) { for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; + AdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.getSize(); j++) { if (val->getNative() == Inv->_takenItems[j]) { @@ -703,7 +703,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta const char *filename = stack->pop()->getString(); _gameRef->unregisterObject(_responseBox); - _responseBox = new CAdResponseBox(_gameRef); + _responseBox = new AdResponseBox(_gameRef); if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) { registerObject(_responseBox); stack->pushBool(true); @@ -723,7 +723,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta const char *filename = stack->pop()->getString(); _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = new CAdInventoryBox(_gameRef); + _inventoryBox = new AdInventoryBox(_gameRef); if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) { registerObject(_inventoryBox); stack->pushBool(true); @@ -784,7 +784,7 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta if (width <= 0) width = _renderer->_width; if (height <= 0) height = _renderer->_height; - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (!_sceneViewport) _sceneViewport = new BaseViewport(_gameRef); if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -793,12 +793,12 @@ bool CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta } - else return CBGame::scCallMethod(script, stack, thisStack, name); + else return BaseGame::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdGame::scGetProperty(const char *name) { +ScValue *AdGame::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -947,12 +947,12 @@ CScValue *CAdGame::scGetProperty(const char *name) { return _scValue; } - else return CBGame::scGetProperty(name); + else return BaseGame::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::scSetProperty(const char *name, CScValue *value) { +bool AdGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelectedItem @@ -964,7 +964,7 @@ bool CAdGame::scSetProperty(const char *name, CScValue *value) { _selectedItem = NULL; for (int i = 0; i < _items.getSize(); i++) { if (_items[i] == value->getNative()) { - _selectedItem = (CAdItem *)value->getNative(); + _selectedItem = (AdItem *)value->getNative(); break; } } @@ -1001,9 +1001,9 @@ bool CAdGame::scSetProperty(const char *name, CScValue *value) { if (value->isNULL()) _inventoryOwner = _invObject; else { - CBObject *Obj = (CBObject *)value->getNative(); + BaseObject *Obj = (BaseObject *)value->getNative(); if (Obj == this) _inventoryOwner = _invObject; - else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj; + else if (_gameRef->validObject(Obj)) _inventoryOwner = (AdObject *)Obj; } if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; @@ -1037,18 +1037,18 @@ bool CAdGame::scSetProperty(const char *name, CScValue *value) { if (value == NULL) { delete[] _startupScene; _startupScene = NULL; - } else CBUtils::setString(&_startupScene, value->getString()); + } else BaseUtils::setString(&_startupScene, value->getString()); return STATUS_OK; } - else return CBGame::scSetProperty(name, value); + else return BaseGame::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *this_obj; +bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *this_obj; ////////////////////////////////////////////////////////////////////////// // Actor @@ -1057,7 +1057,7 @@ bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->setNative(new CAdActor(_gameRef)); + this_obj->setNative(new AdActor(_gameRef)); stack->pushNULL(); } @@ -1068,14 +1068,14 @@ bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(0); this_obj = thisStack->getTop(); - this_obj->setNative(new CAdEntity(_gameRef)); + this_obj->setNative(new AdEntity(_gameRef)); stack->pushNULL(); } ////////////////////////////////////////////////////////////////////////// // call parent - else return CBGame::ExternalCall(script, stack, thisStack, name); + else return BaseGame::ExternalCall(script, stack, thisStack, name); return STATUS_OK; @@ -1083,13 +1083,13 @@ bool CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// -bool CAdGame::showCursor() { +bool AdGame::showCursor() { if (_cursorHidden) return STATUS_OK; if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { - CBSprite *origLastCursor = _lastCursor; - CBGame::showCursor(); + BaseSprite *origLastCursor = _lastCursor; + BaseGame::showCursor(); _lastCursor = origLastCursor; } if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { @@ -1098,15 +1098,15 @@ bool CAdGame::showCursor() { else return drawCursor(_selectedItem->_cursorNormal); } else return drawCursor(_selectedItem->_cursorNormal); - } else return CBGame::showCursor(); + } else return BaseGame::showCursor(); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadFile(const char *filename) { +bool AdGame::loadFile(const char *filename) { byte *buffer = _fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1139,7 +1139,7 @@ TOKEN_DEF(STARTUP_SCENE) TOKEN_DEF(DEBUG_STARTUP_SCENE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadBuffer(byte *buffer, bool complete) { +bool AdGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(AD_GAME) @@ -1156,14 +1156,14 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { byte *params; byte *params2; int cmd = 1; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); bool itemFound = false, itemsFound = false; while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - if (DID_FAIL(CBGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (DID_FAIL(BaseGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; break; case TOKEN_AD_GAME: @@ -1171,7 +1171,7 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { switch (cmd) { case TOKEN_RESPONSE_BOX: delete _responseBox; - _responseBox = new CAdResponseBox(_gameRef); + _responseBox = new AdResponseBox(_gameRef); if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) registerObject(_responseBox); else { @@ -1183,7 +1183,7 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; - _inventoryBox = new CAdInventoryBox(_gameRef); + _inventoryBox = new AdInventoryBox(_gameRef); if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) registerObject(_inventoryBox); else { @@ -1195,7 +1195,7 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ITEMS: itemsFound = true; - CBUtils::setString(&_itemsFile, (char *)params2); + BaseUtils::setString(&_itemsFile, (char *)params2); if (DID_FAIL(loadItemsFile(_itemsFile))) { delete[] _itemsFile; _itemsFile = NULL; @@ -1212,7 +1212,7 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCENE_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef); + if (!_sceneViewport) _sceneViewport = new BaseViewport(_gameRef); if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); } break; @@ -1222,11 +1222,11 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_STARTUP_SCENE: - CBUtils::setString(&_startupScene, (char *)params2); + BaseUtils::setString(&_startupScene, (char *)params2); break; case TOKEN_DEBUG_STARTUP_SCENE: - CBUtils::setString(&_debugStartupScene, (char *)params2); + BaseUtils::setString(&_debugStartupScene, (char *)params2); break; } } @@ -1252,9 +1252,9 @@ bool CAdGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::persist(CBPersistMgr *persistMgr) { +bool AdGame::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(); - CBGame::persist(persistMgr); + BaseGame::persist(persistMgr); _dlgPendingBranches.persist(persistMgr); @@ -1303,27 +1303,27 @@ bool CAdGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadGame(const char *filename) { - bool ret = CBGame::loadGame(filename); - if (DID_SUCCEED(ret)) CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CAdRegion", NULL); +bool AdGame::loadGame(const char *filename) { + bool ret = BaseGame::loadGame(filename); + if (DID_SUCCEED(ret)) SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "AdRegion", NULL); return ret; } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::initAfterLoad() { - CBGame::initAfterLoad(); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScene, "CAdScene", NULL); +bool AdGame::initAfterLoad() { + BaseGame::initAfterLoad(); + SystemClassRegistry::getInstance()->enumInstances(afterLoadScene, "AdScene", NULL); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -void CAdGame::afterLoadScene(void *scene, void *data) { - ((CAdScene *)scene)->afterLoad(); +void AdGame::afterLoadScene(void *scene, void *data) { + ((AdScene *)scene)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneName(const char *name) { +void AdGame::setPrevSceneName(const char *name) { delete[] _prevSceneName; _prevSceneName = NULL; if (name) { @@ -1334,7 +1334,7 @@ void CAdGame::setPrevSceneName(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CAdGame::setPrevSceneFilename(const char *name) { +void AdGame::setPrevSceneFilename(const char *name) { delete[] _prevSceneFilename; _prevSceneFilename = NULL; if (name) { @@ -1345,7 +1345,7 @@ void CAdGame::setPrevSceneFilename(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { +bool AdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; @@ -1362,8 +1362,8 @@ bool CAdGame::scheduleChangeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - CBGame::getVersion(verMajor, verMinor, NULL, NULL); +bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + BaseGame::getVersion(verMajor, verMinor, NULL, NULL); if (extMajor) *extMajor = 0; if (extMinor) *extMinor = 0; @@ -1373,10 +1373,10 @@ bool CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *e ////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsFile(const char *filename, bool merge) { +bool AdGame::loadItemsFile(const char *filename, bool merge) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1395,14 +1395,14 @@ bool CAdGame::loadItemsFile(const char *filename, bool merge) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { +bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE_END byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (!merge) { while (_items.getSize() > 0) deleteItem(_items[0]); @@ -1411,11 +1411,11 @@ bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ITEM: { - CAdItem *item = new CAdItem(_gameRef); + AdItem *item = new AdItem(_gameRef); if (item && !DID_FAIL(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (merge) { - CAdItem *PrevItem = getItemByName(item->_name); + AdItem *PrevItem = getItemByName(item->_name); if (PrevItem) deleteItem(PrevItem); } addItem(item); @@ -1443,7 +1443,7 @@ bool CAdGame::loadItemsBuffer(byte *buffer, bool merge) { ////////////////////////////////////////////////////////////////////////// -CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { +AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { char *filenameCor = new char[strlen(filename) + 1]; strcpy(filenameCor, filename); for (uint32 i = 0; i < strlen(filenameCor); i++) { @@ -1458,7 +1458,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { } if (saving) { - CAdSceneState *ret = new CAdSceneState(_gameRef); + AdSceneState *ret = new AdSceneState(_gameRef); ret->setFilename(filenameCor); _sceneStates.add(ret); @@ -1473,18 +1473,18 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { +bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE_END int cmd = PARSERR_GENERIC; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); cmd = parser.getCommand(buffer, commands, params); switch (cmd) { case TOKEN_ENTITY_CONTAINER: { - CUIEntity *ent = new CUIEntity(_gameRef); + UIEntity *ent = new UIEntity(_gameRef); if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { delete ent; ent = NULL; @@ -1507,12 +1507,12 @@ bool CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +bool AdGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { if (strcmp(name, "CreateEntityContainer") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIEntity *ent = new CUIEntity(_gameRef); + UIEntity *ent = new UIEntity(_gameRef); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -1525,7 +1525,7 @@ bool CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack ////////////////////////////////////////////////////////////////////////// -bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +bool AdGame::startDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); @@ -1536,7 +1536,7 @@ bool CAdGame::startDlgBranch(const char *branchName, const char *scriptName, con ////////////////////////////////////////////////////////////////////////// -bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { +bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; bool deleteName = false; if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { @@ -1583,7 +1583,7 @@ bool CAdGame::endDlgBranch(const char *branchName, const char *scriptName, const ////////////////////////////////////////////////////////////////////////// -bool CAdGame::clearBranchResponses(char *name) { +bool AdGame::clearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.getSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; @@ -1596,9 +1596,9 @@ bool CAdGame::clearBranchResponses(char *name) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::addBranchResponse(int ID) { +bool AdGame::addBranchResponse(int ID) { if (branchResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); + AdResponseContext *r = new AdResponseContext(_gameRef); r->_iD = ID; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesBranch.add(r); @@ -1607,7 +1607,7 @@ bool CAdGame::addBranchResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::branchResponseUsed(int ID) { +bool AdGame::branchResponseUsed(int ID) { char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; for (int i = 0; i < _responsesBranch.getSize(); i++) { if (_responsesBranch[i]->_iD == ID) { @@ -1619,9 +1619,9 @@ bool CAdGame::branchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::addGameResponse(int ID) { +bool AdGame::addGameResponse(int ID) { if (gameResponseUsed(ID)) return STATUS_OK; - CAdResponseContext *r = new CAdResponseContext(_gameRef); + AdResponseContext *r = new AdResponseContext(_gameRef); r->_iD = ID; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesGame.add(r); @@ -1630,10 +1630,10 @@ bool CAdGame::addGameResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::gameResponseUsed(int ID) { +bool AdGame::gameResponseUsed(int ID) { char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; for (int i = 0; i < _responsesGame.getSize(); i++) { - CAdResponseContext *RespContext = _responsesGame[i]; + AdResponseContext *RespContext = _responsesGame[i]; if (RespContext->_iD == ID) { if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; } @@ -1643,7 +1643,7 @@ bool CAdGame::gameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetResponse(int ID) { +bool AdGame::resetResponse(int ID) { char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; int i; @@ -1672,7 +1672,7 @@ bool CAdGame::resetResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayContent(bool doUpdate, bool displayAll) { +bool AdGame::displayContent(bool doUpdate, bool displayAll) { // init if (doUpdate) initLoop(); @@ -1740,7 +1740,7 @@ bool CAdGame::displayContent(bool doUpdate, bool displayAll) { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::registerInventory(CAdInventory *inv) { +bool AdGame::registerInventory(AdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) return STATUS_OK; } @@ -1751,7 +1751,7 @@ bool CAdGame::registerInventory(CAdInventory *inv) { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::unregisterInventory(CAdInventory *inv) { +bool AdGame::unregisterInventory(AdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); @@ -1763,9 +1763,9 @@ bool CAdGame::unregisterInventory(CAdInventory *inv) { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::isItemTaken(char *itemName) { +bool AdGame::isItemTaken(char *itemName) { for (int i = 0; i < _inventories.getSize(); i++) { - CAdInventory *Inv = _inventories[i]; + AdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.getSize(); j++) { if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { @@ -1777,7 +1777,7 @@ bool CAdGame::isItemTaken(char *itemName) { } ////////////////////////////////////////////////////////////////////////// -CAdItem *CAdGame::getItemByName(const char *name) { +AdItem *AdGame::getItemByName(const char *name) { for (int i = 0; i < _items.getSize(); i++) { if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; } @@ -1786,14 +1786,14 @@ CAdItem *CAdGame::getItemByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::addItem(CAdItem *item) { +bool AdGame::addItem(AdItem *item) { _items.add(item); return _gameRef->registerObject(item); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::resetContent() { +bool AdGame::resetContent() { // clear pending dialogs for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { delete [] _dlgPendingBranches[i]; @@ -1823,12 +1823,12 @@ bool CAdGame::resetContent() { _tempDisableSaveState = true; - return CBGame::resetContent(); + return BaseGame::resetContent(); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::deleteItem(CAdItem *item) { +bool AdGame::deleteItem(AdItem *item) { if (!item) return STATUS_FAILED; if (_selectedItem == item) _selectedItem = NULL; @@ -1853,7 +1853,7 @@ bool CAdGame::deleteItem(CAdItem *item) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::addSpeechDir(const char *dir) { +bool AdGame::addSpeechDir(const char *dir) { if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; @@ -1874,7 +1874,7 @@ bool CAdGame::addSpeechDir(const char *dir) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::removeSpeechDir(const char *dir) { +bool AdGame::removeSpeechDir(const char *dir) { if (!dir || dir[0] == '\0') return STATUS_FAILED; char *temp = new char[strlen(dir) + 2]; @@ -1899,7 +1899,7 @@ bool CAdGame::removeSpeechDir(const char *dir) { ////////////////////////////////////////////////////////////////////////// -char *CAdGame::findSpeechFile(char *stringID) { +char *AdGame::findSpeechFile(char *stringID) { char *ret = new char[MAX_PATH_LENGTH]; for (int i = 0; i < _speechDirs.getSize(); i++) { @@ -1923,15 +1923,15 @@ char *CAdGame::findSpeechFile(char *stringID) { ////////////////////////////////////////////////////////////////////////// -bool CAdGame::validMouse() { +bool AdGame::validMouse() { Point32 pos; - CBPlatform::getCursorPos(&pos); + BasePlatform::getCursorPos(&pos); return _renderer->pointInViewport(&pos); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDown() { +bool AdGame::onMouseLeftDown() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { @@ -1953,16 +1953,16 @@ bool CAdGame::onMouseLeftDown() { if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); + BasePlatform::setCapture(/*_renderer->_window*/); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftUp() { +bool AdGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - CBPlatform::releaseCapture(); + BasePlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; @@ -1978,7 +1978,7 @@ bool CAdGame::onMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseLeftDblClick() { +bool AdGame::onMouseLeftDblClick() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; @@ -1997,7 +1997,7 @@ bool CAdGame::onMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightDown() { +bool AdGame::onMouseRightDown() { if (!validMouse()) return STATUS_OK; if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { @@ -2022,7 +2022,7 @@ bool CAdGame::onMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onMouseRightUp() { +bool AdGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); @@ -2037,7 +2037,7 @@ bool CAdGame::onMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::displayDebugInfo() { +bool AdGame::displayDebugInfo() { char str[100]; if (_gameRef->_debugDebugMode) { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); @@ -2046,12 +2046,12 @@ bool CAdGame::displayDebugInfo() { sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } - return CBGame::displayDebugInfo(); + return BaseGame::displayDebugInfo(); } ////////////////////////////////////////////////////////////////////////// -bool CAdGame::onScriptShutdown(CScScript *script) { +bool AdGame::onScriptShutdown(ScScript *script) { if (_responseBox && _responseBox->_waitingScript == script) _responseBox->_waitingScript = NULL; diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 09b3e09df0..b52fd2832f 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -32,19 +32,19 @@ #include "engines/wintermute/base/base_game.h" namespace WinterMute { -class CAdItem; -class CAdInventory; -class CAdSceneState; -class CAdScene; -class CAdItem; -class CAdObject; -class CAdSentence; -class CAdInventoryBox; -class CAdResponseContext; -class CAdResponseBox; -class CAdGame : public CBGame { +class AdItem; +class AdInventory; +class AdSceneState; +class AdScene; +class AdItem; +class AdObject; +class AdSentence; +class AdInventoryBox; +class AdResponseContext; +class AdResponseBox; +class AdGame : public BaseGame { public: - virtual bool onScriptShutdown(CScScript *script); + virtual bool onScriptShutdown(ScScript *script); virtual bool onMouseLeftDown(); virtual bool onMouseLeftUp(); @@ -60,25 +60,25 @@ public: bool _smartItemCursor; - CBArray _speechDirs; + BaseArray _speechDirs; bool addSpeechDir(const char *dir); bool removeSpeechDir(const char *dir); char *findSpeechFile(char *StringID); - bool deleteItem(CAdItem *Item); + bool deleteItem(AdItem *Item); char *_itemsFile; bool _tempDisableSaveState; virtual bool resetContent(); - bool addItem(CAdItem *item); - CAdItem *getItemByName(const char *name); - CBArray _items; - CAdObject *_inventoryOwner; + bool addItem(AdItem *item); + AdItem *getItemByName(const char *name); + BaseArray _items; + AdObject *_inventoryOwner; bool isItemTaken(char *itemName); - bool registerInventory(CAdInventory *inv); - bool unregisterInventory(CAdInventory *inv); + bool registerInventory(AdInventory *inv); + bool unregisterInventory(AdInventory *inv); - CAdObject *_invObject; - CBArray _inventories; + AdObject *_invObject; + BaseArray _inventories; virtual bool displayContent(bool update = true, bool displayAll = false); char *_debugStartupScene; char *_startupScene; @@ -92,11 +92,11 @@ public: bool clearBranchResponses(char *name); bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); - CAdSceneState *getSceneState(const char *filename, bool saving); - CBViewport *_sceneViewport; + AdSceneState *getSceneState(const char *filename, bool saving); + BaseViewport *_sceneViewport; int _texItemLifeTime; int _texWalkLifeTime; int _texStandLifeTime; @@ -113,32 +113,32 @@ public: char *_prevSceneName; char *_prevSceneFilename; virtual bool loadGame(const char *filename); - CAdItem *_selectedItem; + AdItem *_selectedItem; bool cleanup(); - DECLARE_PERSISTENT(CAdGame, CBGame) + DECLARE_PERSISTENT(AdGame, BaseGame) void finishSentences(); bool showCursor(); TGameStateEx _stateEx; - CAdResponseBox *_responseBox; - CAdInventoryBox *_inventoryBox; + AdResponseBox *_responseBox; + AdInventoryBox *_inventoryBox; bool displaySentences(bool frozen); - void addSentence(CAdSentence *sentence); + void addSentence(AdSentence *sentence); bool changeScene(const char *filename, bool fadeIn); - bool removeObject(CAdObject *object); - bool addObject(CAdObject *object); - CAdScene *_scene; + bool removeObject(AdObject *object); + bool addObject(AdObject *object); + AdScene *_scene; bool initLoop(); - CAdGame(); - virtual ~CAdGame(); - CBArray _objects; - CBArray _sentences; + AdGame(); + virtual ~AdGame(); + BaseArray _objects; + BaseArray _sentences; - CBArray _sceneStates; - CBArray _dlgPendingBranches; + BaseArray _sceneStates; + BaseArray _dlgPendingBranches; - CBArray _responsesBranch; - CBArray _responsesGame; + BaseArray _responsesBranch; + BaseArray _responsesGame; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); @@ -147,12 +147,12 @@ public: bool loadItemsBuffer(byte *buffer, bool merge = false); - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); bool validMouse(); }; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index cfbc9e5029..fd56eef419 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -34,25 +34,25 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdInventory, false) +IMPLEMENT_PERSISTENT(AdInventory, false) ////////////////////////////////////////////////////////////////////////// -CAdInventory::CAdInventory(CBGame *inGame): CBObject(inGame) { +AdInventory::AdInventory(BaseGame *inGame): BaseObject(inGame) { _scrollOffset = 0; } ////////////////////////////////////////////////////////////////////////// -CAdInventory::~CAdInventory() { +AdInventory::~AdInventory() { _takenItems.removeAll(); // ref only } ////////////////////////////////////////////////////////////////////////// -bool CAdInventory::insertItem(const char *name, const char *insertAfter) { +bool AdInventory::insertItem(const char *name, const char *insertAfter) { if (name == NULL) return STATUS_FAILED; - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name); + AdItem *item = ((AdGame *)_gameRef)->getItemByName(name); if (item == NULL) return STATUS_FAILED; int insertIndex = -1; @@ -74,12 +74,12 @@ bool CAdInventory::insertItem(const char *name, const char *insertAfter) { ////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(const char *name) { +bool AdInventory::removeItem(const char *name) { if (name == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL; _takenItems.removeAt(i); return STATUS_OK; } @@ -91,12 +91,12 @@ bool CAdInventory::removeItem(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CAdInventory::removeItem(CAdItem *item) { +bool AdInventory::removeItem(AdItem *item) { if (item == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.getSize(); i++) { if (_takenItems[i] == item) { - if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL; + if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL; _takenItems.removeAt(i); return STATUS_OK; } @@ -106,9 +106,9 @@ bool CAdInventory::removeItem(CAdItem *item) { } ////////////////////////////////////////////////////////////////////////// -bool CAdInventory::persist(CBPersistMgr *persistMgr) { +bool AdInventory::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); _takenItems.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollOffset)); diff --git a/engines/wintermute/ad/ad_inventory.h b/engines/wintermute/ad/ad_inventory.h index 84d9308d5d..6f7537633d 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -33,17 +33,17 @@ namespace WinterMute { -class CAdItem; +class AdItem; -class CAdInventory : public CBObject { +class AdInventory : public BaseObject { public: - DECLARE_PERSISTENT(CAdInventory, CBObject) + DECLARE_PERSISTENT(AdInventory, BaseObject) bool removeItem(const char *name); - bool removeItem(CAdItem *Item); + bool removeItem(AdItem *Item); bool insertItem(const char *name, const char *insertAfter = NULL); - CAdInventory(CBGame *inGame); - virtual ~CAdInventory(); - CBArray _takenItems; + AdInventory(BaseGame *inGame); + virtual ~AdInventory(); + BaseArray _takenItems; int _scrollOffset; }; diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index abe8676376..f835dd22d4 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -43,10 +43,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdInventoryBox, false) +IMPLEMENT_PERSISTENT(AdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { +AdInventoryBox::AdInventoryBox(BaseGame *inGame): BaseObject(inGame) { _itemsArea.setEmpty(); _scrollOffset = 0; _spacing = 0; @@ -64,7 +64,7 @@ CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdInventoryBox::~CAdInventoryBox() { +AdInventoryBox::~AdInventoryBox() { _gameRef->unregisterObject(_window); _window = NULL; @@ -74,8 +74,8 @@ CAdInventoryBox::~CAdInventoryBox() { ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; +bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; switch (obj->_type) { case UI_BUTTON: @@ -86,10 +86,10 @@ bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { _scrollOffset = MAX(_scrollOffset, 0); } else if (scumm_stricmp(obj->_name, "next") == 0) { _scrollOffset += _scrollBy; - } else return CBObject::listen(param1, param2); + } else return BaseObject::listen(param1, param2); break; default: - error("CAdInventoryBox::Listen - Unhandled enum"); + error("AdInventoryBox::Listen - Unhandled enum"); break; } @@ -98,8 +98,8 @@ bool CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::display() { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdInventoryBox::display() { + AdGame *adGame = (AdGame *)_gameRef; if (!_visible) return STATUS_OK; @@ -137,8 +137,8 @@ bool CAdInventoryBox::display() { for (int i = 0; i < itemsX; i++) { int itemIndex = _scrollOffset + j * itemsX + i; if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { - CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; - if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) { + AdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; + if (item != ((AdGame *)_gameRef)->_selectedItem || !_hideSelected) { item->update(); item->display(xxx, yyy); } @@ -155,10 +155,10 @@ bool CAdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadFile(const char *filename) { +bool AdInventoryBox::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -193,7 +193,7 @@ TOKEN_DEF(HIDE_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { +bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(INVENTORY_BOX) TOKEN_TABLE(TEMPLATE) @@ -213,7 +213,7 @@ bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); bool always_visible = false; _exclusive = false; @@ -241,7 +241,7 @@ bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: delete _window; - _window = new CUIWindow(_gameRef); + _window = new UIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; @@ -297,7 +297,7 @@ bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { if (_exclusive) { delete _closeButton; - _closeButton = new CUIButton(_gameRef); + _closeButton = new UIButton(_gameRef); if (_closeButton) { _closeButton->setName("close"); _closeButton->setListener(this, _closeButton, 0); @@ -318,7 +318,7 @@ bool CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "INVENTORY_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -343,7 +343,7 @@ bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -351,8 +351,8 @@ bool CAdInventoryBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdInventoryBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_closeButton)); persistMgr->transfer(TMEMBER(_hideSelected)); diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h index 09d3ef409e..dfbf62be9a 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -33,30 +33,30 @@ #include "common/rect.h" namespace WinterMute { -class CUIButton; -class CUIWindow; +class UIButton; +class UIWindow; -class CAdInventoryBox : public CBObject { +class AdInventoryBox : public BaseObject { public: bool _hideSelected; - DECLARE_PERSISTENT(CAdInventoryBox, CBObject) + DECLARE_PERSISTENT(AdInventoryBox, BaseObject) bool _exclusive; int _scrollBy; int _itemHeight; int _itemWidth; bool _visible; virtual bool display(); - CUIButton *_closeButton; + UIButton *_closeButton; int _spacing; int _scrollOffset; Rect32 _itemsArea; - bool listen(CBScriptHolder *param1, uint32 param2); - CUIWindow *_window; - CAdInventoryBox(CBGame *inGame); - virtual ~CAdInventoryBox(); + bool listen(BaseScriptHolder *param1, uint32 param2); + UIWindow *_window; + AdInventoryBox(BaseGame *inGame); + virtual ~AdInventoryBox(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 9c49a86bcb..781b924513 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -46,10 +46,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdItem, false) +IMPLEMENT_PERSISTENT(AdItem, false) ////////////////////////////////////////////////////////////////////////// -CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { +AdItem::AdItem(BaseGame *inGame): AdTalkHolder(inGame) { _spriteHover = NULL; _cursorNormal = _cursorHover = NULL; @@ -70,7 +70,7 @@ CAdItem::CAdItem(CBGame *inGame): CAdTalkHolder(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdItem::~CAdItem() { +AdItem::~AdItem() { delete _spriteHover; delete _cursorNormal; delete _cursorHover; @@ -84,10 +84,10 @@ CAdItem::~CAdItem() { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadFile(const char *filename) { +bool AdItem::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -134,7 +134,7 @@ TOKEN_DEF(AMOUNT_STRING) TOKEN_DEF(AMOUNT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdItem::loadBuffer(byte *buffer, bool complete) { +bool AdItem::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ITEM) TOKEN_TABLE(TEMPLATE) @@ -166,7 +166,7 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { @@ -198,8 +198,8 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: case TOKEN_SPRITE: delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + _sprite = new BaseSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _sprite; cmd = PARSERR_GENERIC; } @@ -208,8 +208,8 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: case TOKEN_SPRITE_HOVER: delete _spriteHover; - _spriteHover = new CBSprite(_gameRef, this); - if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + _spriteHover = new BaseSprite(_gameRef, this); + if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _spriteHover; cmd = PARSERR_GENERIC; } @@ -238,27 +238,27 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AMOUNT_STRING: - CBUtils::setString(&_amountString, (char *)params); + BaseUtils::setString(&_amountString, (char *)params); break; case TOKEN_TALK: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + BaseSprite *spr = new BaseSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSprites.add(spr); } break; case TOKEN_TALK_SPECIAL: { - CBSprite *spr = new CBSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; + BaseSprite *spr = new BaseSprite(_gameRef, this); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; else _talkSpritesEx.add(spr); } break; case TOKEN_CURSOR: delete _cursorNormal; - _cursorNormal = new CBSprite(_gameRef); - if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + _cursorNormal = new BaseSprite(_gameRef); + if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorNormal; _cursorNormal = NULL; cmd = PARSERR_GENERIC; @@ -267,8 +267,8 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR_HOVER: delete _cursorHover; - _cursorHover = new CBSprite(_gameRef); - if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) { + _cursorHover = new BaseSprite(_gameRef); + if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorHover; _cursorHover = NULL; cmd = PARSERR_GENERIC; @@ -319,7 +319,7 @@ bool CAdItem::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::update() { +bool AdItem::update() { _currentSprite = NULL; if (_state == STATE_READY && _animSprite) { @@ -369,11 +369,11 @@ bool CAdItem::update() { _tempSprite2->reset(); _currentSprite = _tempSprite2; } - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } else { _currentSprite = _tempSprite2; - ((CAdGame *)_gameRef)->addSentence(_sentence); + ((AdGame *)_gameRef)->addSentence(_sentence); } } default: @@ -386,7 +386,7 @@ bool CAdItem::update() { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::display(int x, int y) { +bool AdItem::display(int x, int y) { int width = 0; if (_currentSprite) { Rect32 rc; @@ -412,7 +412,7 @@ bool CAdItem::display(int x, int y) { } amountX += _amountOffsetX; - CBFont *font = _font ? _font : _gameRef->_systemFont; + BaseFont *font = _font ? _font : _gameRef->_systemFont; if (font) { if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); else { @@ -430,7 +430,7 @@ bool CAdItem::display(int x, int y) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetHoverSprite ////////////////////////////////////////////////////////////////////////// @@ -444,7 +444,7 @@ bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta delete _spriteHover; _spriteHover = NULL; - CBSprite *spr = new CBSprite(_gameRef, this); + BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); @@ -487,7 +487,7 @@ bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta delete _cursorNormal; _cursorNormal = NULL; - CBSprite *spr = new CBSprite(_gameRef); + BaseSprite *spr = new BaseSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename); @@ -530,7 +530,7 @@ bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta delete _cursorHover; _cursorHover = NULL; - CBSprite *spr = new CBSprite(_gameRef); + BaseSprite *spr = new BaseSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename); @@ -563,12 +563,12 @@ bool CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta return STATUS_OK; } - else return CAdTalkHolder::scCallMethod(script, stack, thisStack, name); + else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdItem::scGetProperty(const char *name) { +ScValue *AdItem::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -644,12 +644,12 @@ CScValue *CAdItem::scGetProperty(const char *name) { return _scValue; } - else return CAdTalkHolder::scGetProperty(name); + else return AdTalkHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdItem::scSetProperty(const char *name, CScValue *value) { +bool AdItem::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -706,7 +706,7 @@ bool CAdItem::scSetProperty(const char *name, CScValue *value) { delete[] _amountString; _amountString = NULL; } else { - CBUtils::setString(&_amountString, value->getString()); + BaseUtils::setString(&_amountString, value->getString()); } return STATUS_OK; } @@ -719,20 +719,20 @@ bool CAdItem::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CAdTalkHolder::scSetProperty(name, value); + else return AdTalkHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdItem::scToString() { +const char *AdItem::scToString() { return "[item]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdItem::persist(CBPersistMgr *persistMgr) { +bool AdItem::persist(BasePersistenceManager *persistMgr) { - CAdTalkHolder::persist(persistMgr); + AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_cursorCombined)); persistMgr->transfer(TMEMBER(_cursorHover)); @@ -751,10 +751,10 @@ bool CAdItem::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdItem::getExtendedFlag(const char *flagName) { +bool AdItem::getExtendedFlag(const char *flagName) { if (!flagName) return false; else if (strcmp(flagName, "usable") == 0) return true; - else return CAdObject::getExtendedFlag(flagName); + else return AdObject::getExtendedFlag(flagName); } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index 34b19a830f..11010c2a35 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CAdItem : public CAdTalkHolder { +class AdItem : public AdTalkHolder { public: bool _displayAmount; int _amount; @@ -45,23 +45,23 @@ public: bool update(); - DECLARE_PERSISTENT(CAdItem, CAdTalkHolder) + DECLARE_PERSISTENT(AdItem, AdTalkHolder) bool display(int x, int y); bool getExtendedFlag(const char *flagName); bool _inInventory; bool _cursorCombined; - CBSprite *_spriteHover; - CBSprite *_cursorNormal; - CBSprite *_cursorHover; - CAdItem(CBGame *inGame); - virtual ~CAdItem(); + BaseSprite *_spriteHover; + BaseSprite *_cursorNormal; + BaseSprite *_cursorHover; + AdItem(BaseGame *inGame); + virtual ~AdItem(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index e23948ed87..2cd7ac26ce 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -41,10 +41,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdLayer, false) +IMPLEMENT_PERSISTENT(AdLayer, false) ////////////////////////////////////////////////////////////////////////// -CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { +AdLayer::AdLayer(BaseGame *inGame): BaseObject(inGame) { _main = false; _width = _height = 0; _active = true; @@ -53,7 +53,7 @@ CAdLayer::CAdLayer(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdLayer::~CAdLayer() { +AdLayer::~AdLayer() { for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; _nodes.removeAll(); @@ -61,10 +61,10 @@ CAdLayer::~CAdLayer() { ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadFile(const char *filename) { +bool AdLayer::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -99,7 +99,7 @@ TOKEN_DEF(CLOSE_UP) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::loadBuffer(byte *buffer, bool complete) { +bool AdLayer::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(LAYER) TOKEN_TABLE(TEMPLATE) @@ -120,7 +120,7 @@ bool CAdLayer::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { @@ -165,8 +165,8 @@ bool CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_REGION: { - CAdRegion *region = new CAdRegion(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); + AdRegion *region = new AdRegion(_gameRef); + AdSceneNode *node = new AdSceneNode(_gameRef); if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete region; @@ -181,8 +181,8 @@ bool CAdLayer::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); - CAdSceneNode *node = new CAdSceneNode(_gameRef); + AdEntity *entity = new AdEntity(_gameRef); + AdSceneNode *node = new AdSceneNode(_gameRef); if (entity) entity->_zoomable = false; // scene entites default to NOT zoom if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; @@ -226,13 +226,13 @@ bool CAdLayer::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetNode ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetNode") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); int node = -1; if (val->_type == VAL_INT) node = val->getInt(); @@ -267,16 +267,16 @@ bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdSceneNode *node = new CAdSceneNode(_gameRef); + AdSceneNode *node = new AdSceneNode(_gameRef); if (strcmp(name, "AddRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); + AdRegion *region = new AdRegion(_gameRef); if (!val->isNULL()) region->setName(val->getString()); node->setRegion(region); stack->pushNative(region, true); } else { - CAdEntity *entity = new CAdEntity(_gameRef); + AdEntity *entity = new AdEntity(_gameRef); if (!val->isNULL()) entity->setName(val->getString()); node->setEntity(entity); stack->pushNative(entity, true); @@ -291,16 +291,16 @@ bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdSceneNode *node = new CAdSceneNode(_gameRef); + AdSceneNode *node = new AdSceneNode(_gameRef); if (strcmp(name, "InsertRegion") == 0) { - CAdRegion *region = new CAdRegion(_gameRef); + AdRegion *region = new AdRegion(_gameRef); if (!val->isNULL()) region->setName(val->getString()); node->setRegion(region); stack->pushNative(region, true); } else { - CAdEntity *entity = new CAdEntity(_gameRef); + AdEntity *entity = new AdEntity(_gameRef); if (!val->isNULL()) entity->setName(val->getString()); node->setEntity(entity); stack->pushNative(entity, true); @@ -317,11 +317,11 @@ bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteNode") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdSceneNode *toDelete = NULL; + AdSceneNode *toDelete = NULL; if (val->isNative()) { - CBScriptable *temp = val->getNative(); + BaseScriptable *temp = val->getNative(); for (int i = 0; i < _nodes.getSize(); i++) { if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { toDelete = _nodes[i]; @@ -351,12 +351,12 @@ bool CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdLayer::scGetProperty(const char *name) { +ScValue *AdLayer::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -415,12 +415,12 @@ CScValue *CAdLayer::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::scSetProperty(const char *name, CScValue *value) { +bool AdLayer::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -466,18 +466,18 @@ bool CAdLayer::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdLayer::scToString() { +const char *AdLayer::scToString() { return "[layer]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "LAYER {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -506,12 +506,12 @@ bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { _nodes[i]->_region->saveAsText(buffer, indent + 2); break; default: - error("CAdLayer::SaveAsText - Unhandled enum"); + error("AdLayer::SaveAsText - Unhandled enum"); break; } } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n\n"); @@ -520,9 +520,9 @@ bool CAdLayer::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdLayer::persist(CBPersistMgr *persistMgr) { +bool AdLayer::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_closeUp)); diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index 0ccdb13ae7..b76cbf1d99 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -30,26 +30,26 @@ #define WINTERMUTE_ADLAYER_H namespace WinterMute { -class CAdSceneNode; -class CAdLayer : public CBObject { +class AdSceneNode; +class AdLayer : public BaseObject { public: bool _closeUp; - DECLARE_PERSISTENT(CAdLayer, CBObject) + DECLARE_PERSISTENT(AdLayer, BaseObject) bool _active; int _height; int _width; bool _main; - CAdLayer(CBGame *inGame); - virtual ~CAdLayer(); - CBArray _nodes; + AdLayer(BaseGame *inGame); + virtual ~AdLayer(); + BaseArray _nodes; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 06f9c4cf95..12bd275614 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -38,11 +38,11 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdNodeState, false) +IMPLEMENT_PERSISTENT(AdNodeState, false) ////////////////////////////////////////////////////////////////////////// -CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { +AdNodeState::AdNodeState(BaseGame *inGame): BaseClass(inGame) { _name = NULL; _active = false; for (int i = 0; i < 7; i++) _caption[i] = NULL; @@ -53,7 +53,7 @@ CAdNodeState::CAdNodeState(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdNodeState::~CAdNodeState() { +AdNodeState::~AdNodeState() { delete[] _name; delete[] _filename; delete[] _cursor; @@ -68,31 +68,31 @@ CAdNodeState::~CAdNodeState() { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setName(const char *name) { +void AdNodeState::setName(const char *name) { delete[] _name; _name = NULL; - CBUtils::setString(&_name, name); + BaseUtils::setString(&_name, name); } ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setFilename(const char *filename) { +void AdNodeState::setFilename(const char *filename) { delete[] _filename; _filename = NULL; - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); } ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCursor(const char *filename) { +void AdNodeState::setCursor(const char *filename) { delete[] _cursor; _cursor = NULL; - CBUtils::setString(&_cursor, filename); + BaseUtils::setString(&_cursor, filename); } ////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::persist(CBPersistMgr *persistMgr) { +bool AdNodeState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_active)); @@ -107,7 +107,7 @@ bool CAdNodeState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdNodeState::setCaption(const char *caption, int caseVal) { +void AdNodeState::setCaption(const char *caption, int caseVal) { if (caseVal== 0) caseVal= 1; if (caseVal< 1 || caseVal> 7) return; @@ -121,7 +121,7 @@ void CAdNodeState::setCaption(const char *caption, int caseVal) { ////////////////////////////////////////////////////////////////////////// -char *CAdNodeState::getCaption(int caseVal) { +char *AdNodeState::getCaption(int caseVal) { if (caseVal== 0) caseVal= 1; if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; else return _caption[caseVal- 1]; @@ -129,7 +129,7 @@ char *CAdNodeState::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -bool CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, bool saving) { +bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool saving) { if (!entity) return STATUS_FAILED; // hack! diff --git a/engines/wintermute/ad/ad_node_state.h b/engines/wintermute/ad/ad_node_state.h index 186f2ebbb2..fc7692a1bf 100644 --- a/engines/wintermute/ad/ad_node_state.h +++ b/engines/wintermute/ad/ad_node_state.h @@ -31,17 +31,17 @@ namespace WinterMute { -class CAdEntity; +class AdEntity; -class CAdNodeState : public CBBase { +class AdNodeState : public BaseClass { public: - bool transferEntity(CAdEntity *entity, bool includingSprites, bool saving); + bool transferEntity(AdEntity *entity, bool includingSprites, bool saving); void setName(const char *name); void setFilename(const char *filename); void setCursor(const char *filename); - DECLARE_PERSISTENT(CAdNodeState, CBBase) - CAdNodeState(CBGame *inGame); - virtual ~CAdNodeState(); + DECLARE_PERSISTENT(AdNodeState, BaseClass) + AdNodeState(BaseGame *inGame); + virtual ~AdNodeState(); char *_name; bool _active; char *_caption[7]; diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 46f2e590fd..39593c482c 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -54,10 +54,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdObject, false) +IMPLEMENT_PERSISTENT(AdObject, false) ////////////////////////////////////////////////////////////////////////// -CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { +AdObject::AdObject(BaseGame *inGame): BaseObject(inGame) { _type = OBJECT_NONE; _state = _nextState = STATE_NONE; @@ -105,7 +105,7 @@ CAdObject::CAdObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdObject::~CAdObject() { +AdObject::~AdObject() { _currentSprite = NULL; // reference only, don't delete delete _animSprite; _animSprite = NULL; @@ -130,7 +130,7 @@ CAdObject::~CAdObject() { if (_font) _gameRef->_fontStorage->removeFont(_font); if (_inventory) { - ((CAdGame *)_gameRef)->unregisterInventory(_inventory); + ((AdGame *)_gameRef)->unregisterInventory(_inventory); _inventory = NULL; } @@ -151,17 +151,17 @@ CAdObject::~CAdObject() { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::playAnim(const char *filename) { +bool AdObject::playAnim(const char *filename) { delete _animSprite; _animSprite = NULL; - _animSprite = new CBSprite(_gameRef, this); + _animSprite = new BaseSprite(_gameRef, this); if (!_animSprite) { - _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); return STATUS_FAILED; } bool res = _animSprite->loadFile(filename); if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); delete _animSprite; _animSprite = NULL; return res; @@ -173,13 +173,13 @@ bool CAdObject::playAnim(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::display() { +bool AdObject::display() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::update() { +bool AdObject::update() { return STATUS_OK; } @@ -187,7 +187,7 @@ bool CAdObject::update() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // PlayAnim / PlayAnimAsync @@ -257,14 +257,14 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(5); const char *text = stack->pop()->getString(); - CScValue *soundVal = stack->pop(); + ScValue *soundVal = stack->pop(); int duration = stack->pop()->getInt(); - CScValue *valStances = stack->pop(); + ScValue *valStances = stack->pop(); const char *stances = valStances->isNULL() ? NULL : valStances->getString(); int align = 0; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isNULL()) align = TAL_CENTER; else align = val->getInt(); @@ -285,11 +285,11 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "StickToRegion") == 0) { stack->correctParams(1); - CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer; + AdLayer *main = ((AdGame *)_gameRef)->_scene->_mainLayer; bool regFound = false; int i; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isNULL() || !main) { _stickRegion = NULL; regFound = true; @@ -303,7 +303,7 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } } } else if (val->isNative()) { - CBScriptable *obj = val->getNative(); + BaseScriptable *obj = val->getNative(); for (i = 0; i < main->_nodes.getSize(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { @@ -325,7 +325,7 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFont") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isNULL()) SetFont(NULL); else SetFont(val->getString()); @@ -351,11 +351,11 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); } - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (!val->isNULL()) { const char *itemName = val->getString(); val = stack->pop(); @@ -363,7 +363,7 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); else { // hide associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); + ((AdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); } } else script->runtimeError("TakeItem: item name expected"); @@ -379,16 +379,16 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); } - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (!val->isNULL()) { if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); else { // show associated entities - ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); + ((AdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); } } else script->runtimeError("DropItem: item name expected"); @@ -403,13 +403,13 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); } - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->_type == VAL_STRING) { - CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString()); + AdItem *item = ((AdGame *)_gameRef)->getItemByName(val->getString()); if (item) stack->pushNative(item, true); else stack->pushNULL(); } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) @@ -427,11 +427,11 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); } - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (!val->isNULL()) { for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { if (val->getNative() == _inventory->_takenItems[i]) { @@ -457,7 +457,7 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int offsetX = stack->pop()->getInt(); int offsetY = stack->pop()->getInt(); - CPartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); + PartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); if (emitter) stack->pushNative(_partEmitter, true); else stack->pushNULL(); @@ -489,7 +489,7 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int offsetY = stack->pop()->getInt(); bool res; - CAdEntity *ent = new CAdEntity(_gameRef); + AdEntity *ent = new AdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; ent = NULL; @@ -516,10 +516,10 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RemoveAttachment") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); bool found = false; if (val->isNative()) { - CBScriptable *obj = val->getNative(); + BaseScriptable *obj = val->getNative(); for (int i = 0; i < _attachmentsPre.getSize(); i++) { if (_attachmentsPre[i] == obj) { found = true; @@ -565,9 +565,9 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetAttachment") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdObject *ret = NULL; + AdObject *ret = NULL; if (val->isInt()) { int index = val->getInt(); int currIndex = 0; @@ -603,12 +603,12 @@ bool CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdObject::scGetProperty(const char *name) { +ScValue *AdObject::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -710,12 +710,12 @@ CScValue *CAdObject::scGetProperty(const char *name) { } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::scSetProperty(const char *name, CScValue *value) { +bool AdObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active @@ -781,18 +781,18 @@ bool CAdObject::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdObject::scToString() { +const char *AdObject::scToString() { return "[ad object]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::SetFont(const char *filename) { +bool AdObject::SetFont(const char *filename) { if (_font) _gameRef->_fontStorage->removeFont(_font); if (filename) { _font = _gameRef->_fontStorage->addFont(filename); @@ -805,17 +805,17 @@ bool CAdObject::SetFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -int CAdObject::getHeight() { +int AdObject::getHeight() { if (!_currentSprite) return 0; else { - CBFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; + BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; int ret = 0; for (int i = 0; i < frame->_subframes.getSize(); i++) { ret = MAX(ret, frame->_subframes[i]->_hotspotY); } if (_zoomable) { - float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); + float zoom = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); ret = (int)(ret * zoom / 100); } return ret; @@ -824,8 +824,8 @@ int CAdObject::getHeight() { ////////////////////////////////////////////////////////////////////////// -void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { - if (!_sentence) _sentence = new CAdSentence(_gameRef); +void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { + if (!_sentence) _sentence = new AdSentence(_gameRef); if (!_sentence) return; if (_forcedTalkAnimName && _forcedTalkAnimUsed) { @@ -852,7 +852,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const if (!sound) { char *key = _gameRef->_stringTable->getKey(text); if (key) { - sound = ((CAdGame *)_gameRef)->findSpeechFile(key); + sound = ((AdGame *)_gameRef)->findSpeechFile(key); delete [] key; if (sound) deleteSound = true; @@ -861,7 +861,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // load sound and set duration appropriately if (sound) { - CBSound *snd = new CBSound(_gameRef); + BaseSound *snd = new BaseSound(_gameRef); if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { @@ -883,8 +883,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const y = _posY; if (!_sceneIndependent && _subtitlesModRelative) { - x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + x -= ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + y -= ((AdGame *)_gameRef)->_scene->getOffsetTop(); } @@ -920,8 +920,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const if (_subtitlesModRelative) { - _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + _sentence->_pos.x += ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + _sentence->_pos.y += ((AdGame *)_gameRef)->_scene->getOffsetTop(); } _sentence->_fixedPos = !_subtitlesModRelative; @@ -936,7 +936,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const ////////////////////////////////////////////////////////////////////////// -bool CAdObject::reset() { +bool AdObject::reset() { if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { delete _animSprite; _animSprite = NULL; @@ -953,8 +953,8 @@ bool CAdObject::reset() { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool AdObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_blockRegion)); @@ -998,46 +998,46 @@ bool CAdObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSounds() { +bool AdObject::updateSounds() { if (_sentence && _sentence->_sound) updateOneSound(_sentence->_sound); - return CBObject::updateSounds(); + return BaseObject::updateSounds(); } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::resetSoundPan() { +bool AdObject::resetSoundPan() { if (_sentence && _sentence->_sound) { _sentence->_sound->setPan(0.0f); } - return CBObject::resetSoundPan(); + return BaseObject::resetSoundPan(); } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::getExtendedFlag(const char *flagName) { +bool AdObject::getExtendedFlag(const char *flagName) { if (!flagName) return false; else if (strcmp(flagName, "usable") == 0) return true; - else return CBObject::getExtendedFlag(flagName); + else return BaseObject::getExtendedFlag(flagName); } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateBlockRegion() { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdObject::updateBlockRegion() { + AdGame *adGame = (AdGame *)_gameRef; if (adGame->_scene) { if (_blockRegion && _currentBlockRegion) _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); @@ -1049,20 +1049,20 @@ bool CAdObject::updateBlockRegion() { } ////////////////////////////////////////////////////////////////////////// -CAdInventory *CAdObject::getInventory() { +AdInventory *AdObject::getInventory() { if (!_inventory) { - _inventory = new CAdInventory(_gameRef); - ((CAdGame *)_gameRef)->registerInventory(_inventory); + _inventory = new AdInventory(_gameRef); + ((AdGame *)_gameRef)->registerInventory(_inventory); } return _inventory; } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::afterMove() { - CAdRegion *newRegions[MAX_NUM_REGIONS]; +bool AdObject::afterMove() { + AdRegion *newRegions[MAX_NUM_REGIONS]; - ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); + ((AdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { if (!newRegions[i]) break; bool regFound = false; @@ -1087,20 +1087,20 @@ bool CAdObject::afterMove() { } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::invalidateCurrRegions() { +bool AdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::getScale(float *scaleX, float *scaleY) { +bool AdObject::getScale(float *scaleX, float *scaleY) { if (_zoomable) { if (_scaleX >= 0 || _scaleY >= 0) { *scaleX = _scaleX < 0 ? 100 : _scaleX; *scaleY = _scaleY < 0 ? 100 : _scaleY; } else if (_scale >= 0) *scaleX = *scaleY = _scale; - else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + else *scaleX = *scaleY = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; } else { *scaleX = *scaleY = 100; } @@ -1108,7 +1108,7 @@ bool CAdObject::getScale(float *scaleX, float *scaleY) { } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::updateSpriteAttachments() { +bool AdObject::updateSpriteAttachments() { for (int i = 0; i < _attachmentsPre.getSize(); i++) { _attachmentsPre[i]->update(); } @@ -1119,7 +1119,7 @@ bool CAdObject::updateSpriteAttachments() { } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachments(bool preDisplay) { +bool AdObject::displaySpriteAttachments(bool preDisplay) { if (preDisplay) { for (int i = 0; i < _attachmentsPre.getSize(); i++) { displaySpriteAttachment(_attachmentsPre[i]); @@ -1133,7 +1133,7 @@ bool CAdObject::displaySpriteAttachments(bool preDisplay) { } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { +bool AdObject::displaySpriteAttachment(AdObject *attachment) { if (!attachment->_active) return STATUS_OK; float scaleX, scaleY; @@ -1171,13 +1171,13 @@ bool CAdObject::displaySpriteAttachment(CAdObject *attachment) { } ////////////////////////////////////////////////////////////////////////// -CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { +PartEmitter *AdObject::createParticleEmitter(bool followParent, int offsetX, int offsetY) { _partFollowParent = followParent; _partOffsetX = offsetX; _partOffsetY = offsetY; if (!_partEmitter) { - _partEmitter = new CPartEmitter(_gameRef, this); + _partEmitter = new PartEmitter(_gameRef, this); if (_partEmitter) { _gameRef->registerObject(_partEmitter); } @@ -1187,7 +1187,7 @@ CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, i } ////////////////////////////////////////////////////////////////////////// -bool CAdObject::updatePartEmitter() { +bool AdObject::updatePartEmitter() { if (!_partEmitter) return STATUS_FAILED; if (_partFollowParent) { diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index dd123092a3..a8da8bd820 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -34,19 +34,19 @@ namespace WinterMute { -class CAdWaypointGroup; -class CAdRegion; -class CAdSentence; -class CBFont; -class CBRegion; -class CAdInventory; +class AdWaypointGroup; +class AdRegion; +class AdSentence; +class BaseFont; +class BaseRegion; +class AdInventory; #define MAX_NUM_REGIONS 10 -class CAdObject : public CBObject { +class AdObject : public BaseObject { public: - CPartEmitter *_partEmitter; - virtual CPartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); + PartEmitter *_partEmitter; + virtual PartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); virtual bool updatePartEmitter(); bool _partFollowParent; int _partOffsetX; @@ -58,7 +58,7 @@ public: int _subtitlesModX; int _subtitlesModY; int _subtitlesWidth; - CAdRegion *_stickRegion; + AdRegion *_stickRegion; bool _sceneIndependent; bool _ignoreItems; bool updateBlockRegion(); @@ -68,51 +68,51 @@ public: virtual bool resetSoundPan(); virtual bool updateSounds(); bool reset(); - DECLARE_PERSISTENT(CAdObject, CBObject) + DECLARE_PERSISTENT(AdObject, BaseObject) virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); virtual int getHeight(); - CAdSentence *_sentence; + AdSentence *_sentence; bool SetFont(const char *filename); virtual bool update(); virtual bool display(); bool _drawn; bool _active; virtual bool playAnim(const char *filename); - CBSprite *_animSprite; - CBSprite *_currentSprite; + BaseSprite *_animSprite; + BaseSprite *_currentSprite; TObjectState _state; TObjectState _nextState; TObjectType _type; - CAdObject(CBGame *inGame); - virtual ~CAdObject(); - CBFont *_font; - CBSprite *_tempSprite2; - CBRegion *_blockRegion; - CAdWaypointGroup *_wptGroup; - CBRegion *_currentBlockRegion; - CAdWaypointGroup *_currentWptGroup; - CAdInventory *getInventory(); - - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + AdObject(BaseGame *inGame); + virtual ~AdObject(); + BaseFont *_font; + BaseSprite *_tempSprite2; + BaseRegion *_blockRegion; + AdWaypointGroup *_wptGroup; + BaseRegion *_currentBlockRegion; + AdWaypointGroup *_currentWptGroup; + AdInventory *getInventory(); + + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); virtual bool afterMove(); - CAdRegion *_currentRegions[MAX_NUM_REGIONS]; + AdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); - CBArray _attachmentsPre; - CBArray _attachmentsPost; + BaseArray _attachmentsPre; + BaseArray _attachmentsPost; bool updateSpriteAttachments(); bool displaySpriteAttachments(bool preDisplay); - CAdObject *_registerAlias; + AdObject *_registerAlias; private: - bool displaySpriteAttachment(CAdObject *attachment); - CAdInventory *_inventory; + bool displaySpriteAttachment(AdObject *attachment); + AdInventory *_inventory; protected: bool getScale(float *scaleX, float *scaleY); diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 780912ce08..cecfaa37d6 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -32,23 +32,23 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdPath, false) +IMPLEMENT_PERSISTENT(AdPath, false) ////////////////////////////////////////////////////////////////////////// -CAdPath::CAdPath(CBGame *inGame): CBBase(inGame) { +AdPath::AdPath(BaseGame *inGame): BaseClass(inGame) { _currIndex = -1; _ready = false; } ////////////////////////////////////////////////////////////////////////// -CAdPath::~CAdPath() { +AdPath::~AdPath() { reset(); } ////////////////////////////////////////////////////////////////////////// -void CAdPath::reset() { +void AdPath::reset() { for (int i = 0; i < _points.getSize(); i++) delete _points[i]; @@ -59,7 +59,7 @@ void CAdPath::reset() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getFirst() { +BasePoint *AdPath::getFirst() { if (_points.getSize() > 0) { _currIndex = 0; return _points[_currIndex]; @@ -68,7 +68,7 @@ CBPoint *CAdPath::getFirst() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getNext() { +BasePoint *AdPath::getNext() { _currIndex++; if (_currIndex < _points.getSize()) return _points[_currIndex]; else return NULL; @@ -76,20 +76,20 @@ CBPoint *CAdPath::getNext() { ////////////////////////////////////////////////////////////////////////// -CBPoint *CAdPath::getCurrent() { +BasePoint *AdPath::getCurrent() { if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; else return NULL; } ////////////////////////////////////////////////////////////////////////// -void CAdPath::addPoint(CBPoint *point) { +void AdPath::addPoint(BasePoint *point) { _points.add(point); } ////////////////////////////////////////////////////////////////////////// -bool CAdPath::setReady(bool ready) { +bool AdPath::setReady(bool ready) { bool orig = _ready; _ready = ready; @@ -98,7 +98,7 @@ bool CAdPath::setReady(bool ready) { ////////////////////////////////////////////////////////////////////////// -bool CAdPath::persist(CBPersistMgr *persistMgr) { +bool AdPath::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h index f27362bfd9..958f52af03 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -34,19 +34,19 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CBPoint; -class CAdPath : public CBBase { +class BasePoint; +class AdPath : public BaseClass { public: - DECLARE_PERSISTENT(CAdPath, CBBase) - CBPoint *getCurrent(); + DECLARE_PERSISTENT(AdPath, BaseClass) + BasePoint *getCurrent(); bool setReady(bool ready = true); - void addPoint(CBPoint *point); - CBPoint *getNext(); - CBPoint *getFirst(); + void addPoint(BasePoint *point); + BasePoint *getNext(); + BasePoint *getFirst(); void reset(); - CAdPath(CBGame *inGame); - virtual ~CAdPath(); - CBArray _points; + AdPath(BaseGame *inGame); + virtual ~AdPath(); + BaseArray _points; int _currIndex; bool _ready; }; diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp index d4b910a30f..d5d447eb9a 100644 --- a/engines/wintermute/ad/ad_path_point.cpp +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -31,10 +31,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdPathPoint, false) +IMPLEMENT_PERSISTENT(AdPathPoint, false) ////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint() { +AdPathPoint::AdPathPoint() { x = y = 0; _distance = 0; @@ -44,7 +44,7 @@ CAdPathPoint::CAdPathPoint() { ////////////////////////////////////////////////////////////////////////// -CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { +AdPathPoint::AdPathPoint(int initX, int initY, int initDistance) { x = initX; y = initY; _distance = initDistance; @@ -55,15 +55,15 @@ CAdPathPoint::CAdPathPoint(int initX, int initY, int initDistance) { ////////////////////////////////////////////////////////////////////////// -CAdPathPoint::~CAdPathPoint() { +AdPathPoint::~AdPathPoint() { _origin = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CAdPathPoint::persist(CBPersistMgr *persistMgr) { +bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { - CBPoint::persist(persistMgr); + BasePoint::persist(persistMgr); persistMgr->transfer(TMEMBER(_distance)); persistMgr->transfer(TMEMBER(_marked)); diff --git a/engines/wintermute/ad/ad_path_point.h b/engines/wintermute/ad/ad_path_point.h index 2a58237bb9..ea0a5795d0 100644 --- a/engines/wintermute/ad/ad_path_point.h +++ b/engines/wintermute/ad/ad_path_point.h @@ -34,13 +34,13 @@ namespace WinterMute { -class CAdPathPoint : public CBPoint { +class AdPathPoint : public BasePoint { public: - DECLARE_PERSISTENT(CAdPathPoint, CBPoint) - CAdPathPoint(int initX, int initY, int initDistance); - CAdPathPoint(); - virtual ~CAdPathPoint(); - CAdPathPoint *_origin; + DECLARE_PERSISTENT(AdPathPoint, BasePoint) + AdPathPoint(int initX, int initY, int initDistance); + AdPathPoint(); + virtual ~AdPathPoint(); + AdPathPoint *_origin; bool _marked; int _distance; }; diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index ae65be5013..1bd6051bda 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -37,10 +37,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdRegion, false) +IMPLEMENT_PERSISTENT(AdRegion, false) ////////////////////////////////////////////////////////////////////////// -CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { +AdRegion::AdRegion(BaseGame *inGame): BaseRegion(inGame) { _blocked = false; _decoration = false; _zoom = 0; @@ -49,15 +49,15 @@ CAdRegion::CAdRegion(CBGame *inGame): CBRegion(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdRegion::~CAdRegion() { +AdRegion::~AdRegion() { } ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadFile(const char *filename) { +bool AdRegion::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -95,7 +95,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::loadBuffer(byte *buffer, bool complete) { +bool AdRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -118,7 +118,7 @@ bool CAdRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { @@ -170,7 +170,7 @@ bool CAdRegion::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); } break; @@ -219,7 +219,7 @@ bool CAdRegion::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { /* ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -233,12 +233,12 @@ bool CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - else*/ return CBRegion::scCallMethod(script, stack, thisStack, name); + else*/ return BaseRegion::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdRegion::scGetProperty(const char *name) { +ScValue *AdRegion::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -289,12 +289,12 @@ CScValue *CAdRegion::scGetProperty(const char *name) { return _scValue; } - else return CBRegion::scGetProperty(name); + else return BaseRegion::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::scSetProperty(const char *name, CScValue *value) { +bool AdRegion::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -335,18 +335,18 @@ bool CAdRegion::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBRegion::scSetProperty(name, value); + else return BaseRegion::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdRegion::scToString() { +const char *AdRegion::scToString() { return "[ad region]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "REGION {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -369,7 +369,7 @@ bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n\n"); @@ -378,8 +378,8 @@ bool CAdRegion::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdRegion::persist(CBPersistMgr *persistMgr) { - CBRegion::persist(persistMgr); +bool AdRegion::persist(BasePersistenceManager *persistMgr) { + BaseRegion::persist(persistMgr); persistMgr->transfer(TMEMBER(_alpha)); persistMgr->transfer(TMEMBER(_blocked)); diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h index 62c5fd6ba3..7ee36dc970 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -33,23 +33,23 @@ namespace WinterMute { -class CAdRegion : public CBRegion { +class AdRegion : public BaseRegion { public: - DECLARE_PERSISTENT(CAdRegion, CBRegion) + DECLARE_PERSISTENT(AdRegion, BaseRegion) uint32 _alpha; float _zoom; bool _blocked; bool _decoration; - CAdRegion(CBGame *inGame); - virtual ~CAdRegion(); + AdRegion(BaseGame *inGame); + virtual ~AdRegion(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index b653fbd36a..29398f547c 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -35,10 +35,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdResponse, false) +IMPLEMENT_PERSISTENT(AdResponse, false) ////////////////////////////////////////////////////////////////////////// -CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { +AdResponse::AdResponse(BaseGame *inGame): BaseObject(inGame) { _text = NULL; _textOrig = NULL; _icon = _iconHover = _iconPressed = NULL; @@ -49,7 +49,7 @@ CAdResponse::CAdResponse(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdResponse::~CAdResponse() { +AdResponse::~AdResponse() { delete[] _text; delete[] _textOrig; delete _icon; @@ -65,18 +65,18 @@ CAdResponse::~CAdResponse() { ////////////////////////////////////////////////////////////////////////// -void CAdResponse::setText(const char *text) { - CBUtils::setString(&_text, text); - CBUtils::setString(&_textOrig, text); +void AdResponse::setText(const char *text) { + BaseUtils::setString(&_text, text); + BaseUtils::setString(&_textOrig, text); } ////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIcon(const char *filename) { +bool AdResponse::setIcon(const char *filename) { delete _icon; - _icon = new CBSprite(_gameRef); + _icon = new BaseSprite(_gameRef); if (!_icon || DID_FAIL(_icon->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename); + _gameRef->LOG(0, "AdResponse::setIcon failed for file '%s'", filename); delete _icon; _icon = NULL; return STATUS_FAILED; @@ -85,22 +85,22 @@ bool CAdResponse::setIcon(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setFont(const char *filename) { +bool AdResponse::setFont(const char *filename) { if (_font) _gameRef->_fontStorage->removeFont(_font); _font = _gameRef->_fontStorage->addFont(filename); if (!_font) { - _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename); + _gameRef->LOG(0, "AdResponse::setFont failed for file '%s'", filename); return STATUS_FAILED; } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconHover(const char *filename) { +bool AdResponse::setIconHover(const char *filename) { delete _iconHover; - _iconHover = new CBSprite(_gameRef); + _iconHover = new BaseSprite(_gameRef); if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename); + _gameRef->LOG(0, "AdResponse::setIconHover failed for file '%s'", filename); delete _iconHover; _iconHover = NULL; return STATUS_FAILED; @@ -110,11 +110,11 @@ bool CAdResponse::setIconHover(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CAdResponse::setIconPressed(const char *filename) { +bool AdResponse::setIconPressed(const char *filename) { delete _iconPressed; - _iconPressed = new CBSprite(_gameRef); + _iconPressed = new BaseSprite(_gameRef); if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { - _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename); + _gameRef->LOG(0, "AdResponse::setIconPressed failed for file '%s'", filename); delete _iconPressed; _iconPressed = NULL; return STATUS_FAILED; @@ -124,9 +124,9 @@ bool CAdResponse::setIconPressed(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CAdResponse::persist(CBPersistMgr *persistMgr) { +bool AdResponse::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_icon)); persistMgr->transfer(TMEMBER(_iconHover)); diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h index da450b2229..0cb8f6628b 100644 --- a/engines/wintermute/ad/ad_response.h +++ b/engines/wintermute/ad/ad_response.h @@ -34,24 +34,24 @@ #include "engines/wintermute/ad/ad_types.h" namespace WinterMute { -class CBFont; -class CAdResponse : public CBObject { +class BaseFont; +class AdResponse : public BaseObject { public: - DECLARE_PERSISTENT(CAdResponse, CBObject) + DECLARE_PERSISTENT(AdResponse, BaseObject) bool setIcon(const char *filename); bool setFont(const char *filename); bool setIconHover(const char *filename); bool setIconPressed(const char *filename); void setText(const char *text); int _iD; - CBSprite *_icon; - CBSprite *_iconHover; - CBSprite *_iconPressed; - CBFont *_font; + BaseSprite *_icon; + BaseSprite *_iconHover; + BaseSprite *_iconPressed; + BaseFont *_font; char *_text; char *_textOrig; - CAdResponse(CBGame *inGame); - virtual ~CAdResponse(); + AdResponse(BaseGame *inGame); + virtual ~AdResponse(); TResponseType _responseType; }; diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 2499c9a732..5b7e441abc 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -47,17 +47,17 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdResponseBox, false) +IMPLEMENT_PERSISTENT(AdResponseBox, false) ////////////////////////////////////////////////////////////////////////// -CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { +AdResponseBox::AdResponseBox(BaseGame *inGame): BaseObject(inGame) { _font = _fontHover = NULL; _window = NULL; - _shieldWindow = new CUIWindow(_gameRef); + _shieldWindow = new UIWindow(_gameRef); _horizontal = false; - CBPlatform::setRectEmpty(&_responseArea); + BasePlatform::setRectEmpty(&_responseArea); _scrollOffset = 0; _spacing = 0; @@ -71,7 +71,7 @@ CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdResponseBox::~CAdResponseBox() { +AdResponseBox::~AdResponseBox() { delete _window; _window = NULL; @@ -93,7 +93,7 @@ CAdResponseBox::~CAdResponseBox() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearResponses() { +void AdResponseBox::clearResponses() { for (int i = 0; i < _responses.getSize(); i++) { delete _responses[i]; } @@ -102,7 +102,7 @@ void CAdResponseBox::clearResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::clearButtons() { +void AdResponseBox::clearButtons() { for (int i = 0; i < _respButtons.getSize(); i++) { delete _respButtons[i]; } @@ -111,7 +111,7 @@ void CAdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::invalidateButtons() { +bool AdResponseBox::invalidateButtons() { for (int i = 0; i < _respButtons.getSize(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; @@ -125,12 +125,12 @@ bool CAdResponseBox::invalidateButtons() { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::createButtons() { +bool AdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; for (int i = 0; i < _responses.getSize(); i++) { - CUIButton *btn = new CUIButton(_gameRef); + UIButton *btn = new UIButton(_gameRef); if (btn) { btn->_parent = _window; btn->_sharedFonts = btn->_sharedImages = true; @@ -187,10 +187,10 @@ bool CAdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadFile(const char *filename) { +bool AdResponseBox::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -223,7 +223,7 @@ TOKEN_DEF(VERTICAL_ALIGN) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { +bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(RESPONSE_BOX) TOKEN_TABLE(TEMPLATE) @@ -242,7 +242,7 @@ bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { @@ -260,7 +260,7 @@ bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW: delete _window; - _window = new CUIWindow(_gameRef); + _window = new UIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; _window = NULL; @@ -310,7 +310,7 @@ bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -335,7 +335,7 @@ bool CAdResponseBox::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdResponseBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "RESPONSE_BOX\n"); buffer->putTextIndent(indent, "{\n"); @@ -362,7 +362,7 @@ bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: - error("CAdResponseBox::SaveAsText - Unhandled enum"); + error("AdResponseBox::SaveAsText - Unhandled enum"); break; } @@ -388,7 +388,7 @@ bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -396,10 +396,10 @@ bool CAdResponseBox::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::display() { +bool AdResponseBox::display() { Rect32 rect = _responseArea; if (_window) { - CBPlatform::offsetRect(&rect, _window->_posX, _window->_posY); + BasePlatform::offsetRect(&rect, _window->_posX, _window->_posY); //_window->display(); } @@ -482,8 +482,8 @@ bool CAdResponseBox::display() { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; +bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; switch (obj->_type) { case UI_BUTTON: @@ -496,11 +496,11 @@ bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { handleResponse(_responses[param2]); _waitingScript = NULL; _gameRef->_state = GAME_RUNNING; - ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL; + ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL; _ready = true; invalidateButtons(); clearResponses(); - } else return CBObject::listen(param1, param2); + } else return BaseObject::listen(param1, param2); break; default: error("AdResponseBox::Listen - Unhandled enum"); @@ -511,8 +511,8 @@ bool CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_font)); persistMgr->transfer(TMEMBER(_fontHover)); @@ -536,8 +536,8 @@ bool CAdResponseBox::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::weedResponses() { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdResponseBox::weedResponses() { + AdGame *adGame = (AdGame *)_gameRef; for (int i = 0; i < _responses.getSize(); i++) { switch (_responses[i]->_responseType) { @@ -557,7 +557,7 @@ bool CAdResponseBox::weedResponses() { } break; default: - warning("CAdResponseBox::WeedResponses - Unhandled enum"); + warning("AdResponseBox::WeedResponses - Unhandled enum"); break; } } @@ -566,17 +566,17 @@ bool CAdResponseBox::weedResponses() { ////////////////////////////////////////////////////////////////////////// -void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) { - CBUtils::setString(&_lastResponseText, text); - CBUtils::setString(&_lastResponseTextOrig, textOrig); +void AdResponseBox::setLastResponseText(const char *text, const char *textOrig) { + BaseUtils::setString(&_lastResponseText, text); + BaseUtils::setString(&_lastResponseTextOrig, textOrig); } ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::handleResponse(CAdResponse *response) { +bool AdResponseBox::handleResponse(AdResponse *response) { setLastResponseText(response->_text, response->_textOrig); - CAdGame *adGame = (CAdGame *)_gameRef; + AdGame *adGame = (AdGame *)_gameRef; switch (response->_responseType) { case RESPONSE_ONCE: @@ -587,7 +587,7 @@ bool CAdResponseBox::handleResponse(CAdResponse *response) { adGame->addGameResponse(response->_iD); break; default: - warning("CAdResponseBox::HandleResponse - Unhandled enum"); + warning("AdResponseBox::HandleResponse - Unhandled enum"); } return STATUS_OK; @@ -595,8 +595,8 @@ bool CAdResponseBox::handleResponse(CAdResponse *response) { ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { - CBArray objects; +BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { + BaseArray objects; getObjects(objects, true); if (objects.getSize() == 0) return NULL; @@ -615,8 +615,8 @@ CBObject *CAdResponseBox::getNextAccessObject(CBObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { - CBArray objects; +BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { + BaseArray objects; getObjects(objects, true); if (objects.getSize() == 0) return NULL; @@ -635,7 +635,7 @@ CBObject *CAdResponseBox::getPrevAccessObject(CBObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -bool CAdResponseBox::getObjects(CBArray &objects, bool interactiveOnly) { +bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _respButtons.getSize(); i++) { objects.add(_respButtons[i]); } diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index 7c611ef2d6..f77ff3360c 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -34,23 +34,23 @@ namespace WinterMute { -class CUIButton; -class CUIWindow; -class CUIObject; -class CAdResponse; -class CAdResponseBox : public CBObject { +class UIButton; +class UIWindow; +class UIObject; +class AdResponse; +class AdResponseBox : public BaseObject { public: - CBObject *getNextAccessObject(CBObject *CurrObject); - CBObject *getPrevAccessObject(CBObject *CurrObject); - bool getObjects(CBArray &objects, bool interactiveOnly); + BaseObject *getNextAccessObject(BaseObject *CurrObject); + BaseObject *getPrevAccessObject(BaseObject *CurrObject); + bool getObjects(BaseArray &objects, bool interactiveOnly); - bool handleResponse(CAdResponse *response); + bool handleResponse(AdResponse *response); void setLastResponseText(const char *text, const char *textOrig); char *_lastResponseText; char *_lastResponseTextOrig; - DECLARE_PERSISTENT(CAdResponseBox, CBObject) - CScScript *_waitingScript; - virtual bool listen(CBScriptHolder *param1, uint32 param2); + DECLARE_PERSISTENT(AdResponseBox, BaseObject) + ScScript *_waitingScript; + virtual bool listen(BaseScriptHolder *param1, uint32 param2); typedef enum { EVENT_PREV, EVENT_NEXT, @@ -61,25 +61,25 @@ public: bool display(); int _spacing; int _scrollOffset; - CBFont *_fontHover; - CBFont *_font; + BaseFont *_fontHover; + BaseFont *_font; bool createButtons(); bool invalidateButtons(); void clearButtons(); void clearResponses(); - CAdResponseBox(CBGame *inGame); - virtual ~CAdResponseBox(); - CBArray _responses; - CBArray _respButtons; - CUIWindow *_window; - CUIWindow *_shieldWindow; + AdResponseBox(BaseGame *inGame); + virtual ~AdResponseBox(); + BaseArray _responses; + BaseArray _respButtons; + UIWindow *_window; + UIWindow *_shieldWindow; bool _horizontal; Rect32 _responseArea; int _verticalAlign; TTextAlign _align; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 02b819d6de..32d9415fe9 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -32,24 +32,24 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdResponseContext, false) +IMPLEMENT_PERSISTENT(AdResponseContext, false) ////////////////////////////////////////////////////////////////////////// -CAdResponseContext::CAdResponseContext(CBGame *inGame): CBBase(inGame) { +AdResponseContext::AdResponseContext(BaseGame *inGame): BaseClass(inGame) { _iD = 0; _context = NULL; } ////////////////////////////////////////////////////////////////////////// -CAdResponseContext::~CAdResponseContext() { +AdResponseContext::~AdResponseContext() { delete[] _context; _context = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { +bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_iD)); @@ -58,7 +58,7 @@ bool CAdResponseContext::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CAdResponseContext::setContext(const char *context) { +void AdResponseContext::setContext(const char *context) { delete[] _context; _context = NULL; if (context) { diff --git a/engines/wintermute/ad/ad_response_context.h b/engines/wintermute/ad/ad_response_context.h index 79eaa27640..d0dc1546b7 100644 --- a/engines/wintermute/ad/ad_response_context.h +++ b/engines/wintermute/ad/ad_response_context.h @@ -34,14 +34,14 @@ namespace WinterMute { -class CAdResponseContext : public CBBase { +class AdResponseContext : public BaseClass { public: void setContext(const char *context); int _iD; char *_context; - DECLARE_PERSISTENT(CAdResponseContext, CBBase) - CAdResponseContext(CBGame *inGame); - virtual ~CAdResponseContext(); + DECLARE_PERSISTENT(AdResponseContext, BaseClass) + AdResponseContext(BaseGame *inGame); + virtual ~AdResponseContext(); }; diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 0ffbaf6919..e758eaa1f6 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -36,27 +36,27 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdRotLevel, false) +IMPLEMENT_PERSISTENT(AdRotLevel, false) ////////////////////////////////////////////////////////////////////////// -CAdRotLevel::CAdRotLevel(CBGame *inGame): CBObject(inGame) { +AdRotLevel::AdRotLevel(BaseGame *inGame): BaseObject(inGame) { _posX = 0; _rotation = 0.0f; } ////////////////////////////////////////////////////////////////////////// -CAdRotLevel::~CAdRotLevel() { +AdRotLevel::~AdRotLevel() { } ////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadFile(const char *filename) { +bool AdRotLevel::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -82,7 +82,7 @@ TOKEN_DEF(ROTATION) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { +bool AdRotLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ROTATION_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -93,7 +93,7 @@ bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { @@ -135,11 +135,11 @@ bool CAdRotLevel::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdRotLevel::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ROTATION_LEVEL {\n"); buffer->putTextIndent(indent + 2, "X=%d\n", _posX); buffer->putTextIndent(indent + 2, "ROTATION=%d\n", (int)_rotation); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -147,9 +147,9 @@ bool CAdRotLevel::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdRotLevel::persist(CBPersistMgr *persistMgr) { +bool AdRotLevel::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_rotation)); diff --git a/engines/wintermute/ad/ad_rot_level.h b/engines/wintermute/ad/ad_rot_level.h index 2bd9519d65..4339a379a5 100644 --- a/engines/wintermute/ad/ad_rot_level.h +++ b/engines/wintermute/ad/ad_rot_level.h @@ -33,13 +33,13 @@ namespace WinterMute { -class CAdRotLevel : public CBObject { +class AdRotLevel : public BaseObject { public: - DECLARE_PERSISTENT(CAdRotLevel, CBObject) - CAdRotLevel(CBGame *inGame); - virtual ~CAdRotLevel(); + DECLARE_PERSISTENT(AdRotLevel, BaseObject) + AdRotLevel(BaseGame *inGame); + virtual ~AdRotLevel(); float _rotation; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); }; diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 220d3c4b39..65e0cc4663 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -35,26 +35,26 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdScaleLevel, false) +IMPLEMENT_PERSISTENT(AdScaleLevel, false) ////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::CAdScaleLevel(CBGame *inGame): CBObject(inGame) { +AdScaleLevel::AdScaleLevel(BaseGame *inGame): BaseObject(inGame) { _posY = 0; _scale = 100; } ////////////////////////////////////////////////////////////////////////// -CAdScaleLevel::~CAdScaleLevel() { +AdScaleLevel::~AdScaleLevel() { } ////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadFile(const char *filename) { +bool AdScaleLevel::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -80,7 +80,7 @@ TOKEN_DEF(SCALE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { +bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCALE_LEVEL) TOKEN_TABLE(TEMPLATE) @@ -91,7 +91,7 @@ bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { @@ -133,11 +133,11 @@ bool CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdScaleLevel::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SCALE_LEVEL {\n"); buffer->putTextIndent(indent + 2, "Y=%d\n", _posY); buffer->putTextIndent(indent + 2, "SCALE=%d\n", (int)_scale); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -145,9 +145,9 @@ bool CAdScaleLevel::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdScaleLevel::persist(CBPersistMgr *persistMgr) { +bool AdScaleLevel::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_scale)); diff --git a/engines/wintermute/ad/ad_scale_level.h b/engines/wintermute/ad/ad_scale_level.h index 4a81c00dda..5e84f8c9ce 100644 --- a/engines/wintermute/ad/ad_scale_level.h +++ b/engines/wintermute/ad/ad_scale_level.h @@ -34,13 +34,13 @@ namespace WinterMute { -class CAdScaleLevel : public CBObject { +class AdScaleLevel : public BaseObject { public: - DECLARE_PERSISTENT(CAdScaleLevel, CBObject) + DECLARE_PERSISTENT(AdScaleLevel, BaseObject) float _scale; - CAdScaleLevel(CBGame *inGame); - virtual ~CAdScaleLevel(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + AdScaleLevel(BaseGame *inGame); + virtual ~AdScaleLevel(); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); }; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 11030d6996..104fe6dd4d 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -62,17 +62,17 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdScene, false) +IMPLEMENT_PERSISTENT(AdScene, false) ////////////////////////////////////////////////////////////////////////// -CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { - _pfTarget = new CBPoint; +AdScene::AdScene(BaseGame *inGame): BaseObject(inGame) { + _pfTarget = new BasePoint; setDefaults(); } ////////////////////////////////////////////////////////////////////////// -CAdScene::~CAdScene() { +AdScene::~AdScene() { cleanup(); _gameRef->unregisterObject(_fader); delete _pfTarget; @@ -81,7 +81,7 @@ CAdScene::~CAdScene() { ////////////////////////////////////////////////////////////////////////// -void CAdScene::setDefaults() { +void AdScene::setDefaults() { _initialized = false; _pfReady = true; _pfTargetPath = NULL; @@ -128,7 +128,7 @@ void CAdScene::setDefaults() { _shieldWindow = NULL; - _fader = new CBFader(_gameRef); + _fader = new BaseFader(_gameRef); _gameRef->registerObject(_fader); _viewport = NULL; @@ -136,8 +136,8 @@ void CAdScene::setDefaults() { ////////////////////////////////////////////////////////////////////////// -void CAdScene::cleanup() { - CBObject::cleanup(); +void AdScene::cleanup() { + BaseObject::cleanup(); _mainLayer = NULL; // reference only @@ -184,7 +184,7 @@ void CAdScene::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester) { +bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester) { if (!_pfReady) return false; else { _pfReady = false; @@ -200,7 +200,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfPointsStart(); // first point - //_pfPath.add(new CAdPathPoint(source.x, source.y, 0)); + //_pfPath.add(new AdPathPoint(source.x, source.y, 0)); // if we're one pixel stuck, get unstuck int startX = source.x; @@ -228,7 +228,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * //CorrectTargetPoint(&target.x, &target.y); // last point - //_pfPath.add(new CAdPathPoint(target.x, target.y, INT_MAX)); + //_pfPath.add(new AdPathPoint(target.x, target.y, INT_MAX)); pfPointsAdd(target.x, target.y, INT_MAX); // active waypoints @@ -245,7 +245,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } - CAdGame *adGame = (CAdGame *)_gameRef; + AdGame *adGame = (AdGame *)_gameRef; for (i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); @@ -258,26 +258,26 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * ////////////////////////////////////////////////////////////////////////// -void CAdScene::pfAddWaypointGroup(CAdWaypointGroup *wpt, CBObject *requester) { +void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { if (!wpt->_active) return; for (int i = 0; i < wpt->_points.getSize(); i++) { if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; - //_pfPath.add(new CAdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); + //_pfPath.add(new AdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); } } ////////////////////////////////////////////////////////////////////////// -float CAdScene::getZoomAt(int x, int y) { +float AdScene::getZoomAt(int x, int y) { float ret = 100; bool found = false; if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { if (node->_region->_zoom != 0) { ret = node->_region->_zoom; @@ -294,7 +294,7 @@ float CAdScene::getZoomAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// -uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { +uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) { if (!_gameRef->_debugDebugMode) colorCheck = false; uint32 ret; @@ -303,7 +303,7 @@ uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { if (!node->_region->_blocked) ret = node->_region->_alpha; break; @@ -315,7 +315,7 @@ uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *requester) { +bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { bool ret = true; @@ -325,7 +325,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; } } - CAdGame *adGame = (CAdGame *)_gameRef; + AdGame *adGame = (AdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; @@ -336,7 +336,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (_mainLayer) { for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; /* if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) { @@ -357,7 +357,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques ////////////////////////////////////////////////////////////////////////// -bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *requester) { +bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { bool ret = false; if (checkFreeObjects) { @@ -366,7 +366,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; } } - CAdGame *adGame = (CAdGame *)_gameRef; + AdGame *adGame = (AdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; @@ -377,7 +377,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_mainLayer) { for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { if (node->_region->_blocked) { ret = false; @@ -391,7 +391,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque ////////////////////////////////////////////////////////////////////////// -int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { +int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester) { double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; int x1, y1, x2, y2; @@ -406,8 +406,8 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { if (xLength > yLength) { if (x1 > x2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); + BaseUtils::swap(&x1, &x2); + BaseUtils::swap(&y1, &y2); } yStep = (double)(y2 - y1) / (double)(x2 - x1); @@ -419,8 +419,8 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { } } else { if (y1 > y2) { - CBUtils::swap(&x1, &x2); - CBUtils::swap(&y1, &y2); + BaseUtils::swap(&x1, &x2); + BaseUtils::swap(&y1, &y2); } xStep = (double)(x2 - x1) / (double)(y2 - y1); @@ -436,11 +436,11 @@ int CAdScene::getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::pathFinderStep() { +void AdScene::pathFinderStep() { int i; // get lowest unmarked int lowestDist = INT_MAX; - CAdPathPoint *lowestPt = NULL; + AdPathPoint *lowestPt = NULL; for (i = 0; i < _pfPointsNum; i++) if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { @@ -459,7 +459,7 @@ void CAdScene::pathFinderStep() { // target point marked, generate path and terminate if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { while (lowestPt != NULL) { - _pfTargetPath->_points.insertAt(0, new CBPoint(lowestPt->x, lowestPt->y)); + _pfTargetPath->_points.insertAt(0, new BasePoint(lowestPt->x, lowestPt->y)); lowestPt = lowestPt->_origin; } @@ -481,18 +481,18 @@ void CAdScene::pathFinderStep() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::initLoop() { +bool AdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) { + while (!_pfReady && BasePlatform::getTime() - start <= _pfMaxTime) { PathFinderStep(); nu_steps++; } if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); #else uint32 start = _gameRef->_currentTime; - while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); + while (!_pfReady && BasePlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); #endif return STATUS_OK; @@ -500,10 +500,10 @@ bool CAdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadFile(const char *filename) { +bool AdScene::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -565,7 +565,7 @@ TOKEN_DEF(PERSISTENT_STATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadBuffer(byte *buffer, bool complete) { +bool AdScene::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SCENE) TOKEN_TABLE(TEMPLATE) @@ -610,7 +610,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { @@ -639,7 +639,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LAYER: { - CAdLayer *layer = new CAdLayer(_gameRef); + AdLayer *layer = new AdLayer(_gameRef); if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete layer; @@ -657,7 +657,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WAYPOINTS: { - CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef); + AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete wpt; @@ -670,7 +670,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SCALE_LEVEL: { - CAdScaleLevel *sl = new CAdScaleLevel(_gameRef); + AdScaleLevel *sl = new AdScaleLevel(_gameRef); if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete sl; @@ -683,7 +683,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ROTATION_LEVEL: { - CAdRotLevel *rl = new CAdRotLevel(_gameRef); + AdRotLevel *rl = new AdRotLevel(_gameRef); if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete rl; @@ -696,7 +696,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ENTITY: { - CAdEntity *entity = new CAdEntity(_gameRef); + AdEntity *entity = new AdEntity(_gameRef); if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; @@ -709,7 +709,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -820,7 +820,7 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new CBViewport(_gameRef); + if (!_viewport) _viewport = new BaseViewport(_gameRef); if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); } @@ -856,11 +856,11 @@ bool CAdScene::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::traverseNodes(bool doUpdate) { +bool AdScene::traverseNodes(bool doUpdate) { if (!_initialized) return STATUS_OK; int j, k; - CAdGame *adGame = (CAdGame *)_gameRef; + AdGame *adGame = (AdGame *)_gameRef; ////////////////////////////////////////////////////////////////////////// @@ -949,7 +949,7 @@ bool CAdScene::traverseNodes(bool doUpdate) { // make layer exclusive if (!doUpdate) { if (_layers[j]->_closeUp && !_gameRef->_editorMode) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (!_shieldWindow) _shieldWindow = new UIWindow(_gameRef); if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; _shieldWindow->_width = _gameRef->_renderer->_width; @@ -978,7 +978,7 @@ bool CAdScene::traverseNodes(bool doUpdate) { // for each node for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { - CAdSceneNode *node = _layers[j]->_nodes[k]; + AdSceneNode *node = _layers[j]->_nodes[k]; switch (node->_type) { case OBJECT_ENTITY: if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { @@ -1030,13 +1030,13 @@ bool CAdScene::traverseNodes(bool doUpdate) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::display() { +bool AdScene::display() { return traverseNodes(false); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::updateFreeObjects() { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdScene::updateFreeObjects() { + AdGame *adGame = (AdGame *)_gameRef; bool is3DSet; // *** update all active objects @@ -1067,10 +1067,10 @@ bool CAdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CBArray objects; - CAdObject *obj; +bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { + AdGame *adGame = (AdGame *)_gameRef; + BaseArray objects; + AdObject *obj; // global objects for (int i = 0; i < adGame->_objects.getSize(); i++) { @@ -1089,7 +1089,7 @@ bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { } // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(CAdObject *), CAdScene::compareObjs); + qsort(objects.getData(), objects.getSize(), sizeof(AdObject *), AdScene::compareObjs); // display them for (int i = 0; i < objects.getSize(); i++) { @@ -1120,9 +1120,9 @@ bool CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) { } ////////////////////////////////////////////////////////////////////////// -int CAdScene::compareObjs(const void *obj1, const void *obj2) { - CAdObject *object1 = *(CAdObject **)obj1; - CAdObject *object2 = *(CAdObject **)obj2; +int AdScene::compareObjs(const void *obj1, const void *obj2) { + AdObject *object1 = *(AdObject **)obj1; + AdObject *object2 = *(AdObject **)obj2; if (object1->_posY < object2->_posY) return -1; else if (object1->_posY > object2->_posY) return 1; @@ -1130,9 +1130,9 @@ int CAdScene::compareObjs(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::displayRegionContentOld(CAdRegion *region) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; +bool AdScene::displayRegionContentOld(AdRegion *region) { + AdGame *adGame = (AdGame *)_gameRef; + AdObject *obj; // display all objects in region sorted by _posY do { @@ -1180,12 +1180,12 @@ bool CAdScene::displayRegionContentOld(CAdRegion *region) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::update() { +bool AdScene::update() { return traverseNodes(true); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollTo(int offsetX, int offsetY) { +void AdScene::scrollTo(int offsetX, int offsetY) { int viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); @@ -1210,19 +1210,19 @@ void CAdScene::scrollTo(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::scrollToObject(CBObject *object) { +void AdScene::scrollToObject(BaseObject *object) { if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::skipToObject(CBObject *object) { +void AdScene::skipToObject(BaseObject *object) { if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); } ////////////////////////////////////////////////////////////////////////// -void CAdScene::skipTo(int offsetX, int offsetY) { +void AdScene::skipTo(int offsetX, int offsetY) { int viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); @@ -1240,13 +1240,13 @@ void CAdScene::skipTo(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LoadActor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "LoadActor") == 0) { stack->correctParams(1); - CAdActor *act = new CAdActor(_gameRef); + AdActor *act = new AdActor(_gameRef); if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) { addObject(act); stack->pushNative(act, true); @@ -1263,7 +1263,7 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadEntity") == 0) { stack->correctParams(1); - CAdEntity *ent = new CAdEntity(_gameRef); + AdEntity *ent = new AdEntity(_gameRef); if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) { addObject(ent); stack->pushNative(ent, true); @@ -1280,9 +1280,9 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEntity") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdEntity *ent = new CAdEntity(_gameRef); + AdEntity *ent = new AdEntity(_gameRef); addObject(ent); if (!val->isNULL()) ent->setName(val->getString()); stack->pushNative(ent, true); @@ -1294,8 +1294,8 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); - CAdObject *obj = (CAdObject *)val->getNative(); + ScValue *val = stack->pop(); + AdObject *obj = (AdObject *)val->getNative(); removeObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); @@ -1308,10 +1308,10 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SkipTo") == 0) { stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); if (val1->isNative()) { - skipToObject((CBObject *)val1->getNative()); + skipToObject((BaseObject *)val1->getNative()); } else { skipTo(val1->getInt(), val2->getInt()); } @@ -1324,10 +1324,10 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) { stack->correctParams(2); - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); if (val1->isNative()) { - scrollToObject((CBObject *)val1->getNative()); + scrollToObject((BaseObject *)val1->getNative()); } else { scrollTo(val1->getInt(), val2->getInt()); } @@ -1341,7 +1341,7 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetLayer") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isInt()) { int layer = val->getInt(); if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); @@ -1379,8 +1379,8 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt stack->correctParams(1); const char *nodeName = stack->pop()->getString(); - CBObject *node = getNodeByName(nodeName); - if (node) stack->pushNative((CBScriptable *)node, true); + BaseObject *node = getNodeByName(nodeName); + if (node) stack->pushNative((BaseScriptable *)node, true); else stack->pushNULL(); return STATUS_OK; @@ -1391,9 +1391,9 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFreeNode") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdObject *ret = NULL; + AdObject *ret = NULL; if (val->isInt()) { int index = val->getInt(); if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; @@ -1419,14 +1419,14 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt stack->correctParams(3); int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); bool includeDecors = false; if (!val->isNULL()) includeDecors = val->getBool(); if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (node->_region->_decoration && !includeDecors) continue; @@ -1570,7 +1570,7 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt if (width <= 0) width = _gameRef->_renderer->_width; if (height <= 0) height = _gameRef->_renderer->_height; - if (!_viewport) _viewport = new CBViewport(_gameRef); + if (!_viewport) _viewport = new BaseViewport(_gameRef); if (_viewport) _viewport->setRect(x, y, x + width, y + height); stack->pushBool(true); @@ -1583,9 +1583,9 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddLayer") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdLayer *layer = new CAdLayer(_gameRef); + AdLayer *layer = new AdLayer(_gameRef); if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { layer->_width = _mainLayer->_width; @@ -1604,9 +1604,9 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt else if (strcmp(name, "InsertLayer") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdLayer *layer = new CAdLayer(_gameRef); + AdLayer *layer = new AdLayer(_gameRef); if (!val->isNULL()) layer->setName(val->getString()); if (_mainLayer) { layer->_width = _mainLayer->_width; @@ -1627,11 +1627,11 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteLayer") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CAdLayer *toDelete = NULL; + AdLayer *toDelete = NULL; if (val->isNative()) { - CBScriptable *temp = val->getNative(); + BaseScriptable *temp = val->getNative(); for (int i = 0; i < _layers.getSize(); i++) { if (_layers[i] == temp) { toDelete = _layers[i]; @@ -1666,12 +1666,12 @@ bool CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdScene::scGetProperty(const char *name) { +ScValue *AdScene::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1829,12 +1829,12 @@ CScValue *CAdScene::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::scSetProperty(const char *name, CScValue *value) { +bool AdScene::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1931,25 +1931,25 @@ bool CAdScene::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdScene::scToString() { +const char *AdScene::scToString() { return "[scene object]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::addObject(CAdObject *object) { +bool AdScene::addObject(AdObject *object) { _objects.add(object); return _gameRef->registerObject(object); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::removeObject(CAdObject *object) { +bool AdScene::removeObject(AdObject *object) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { _objects.removeAt(i); @@ -1961,7 +1961,7 @@ bool CAdScene::removeObject(CAdObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { int i; buffer->putTextIndent(indent, "SCENE {\n"); @@ -2019,7 +2019,7 @@ bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); // waypoints buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); @@ -2059,13 +2059,13 @@ bool CAdScene::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortScaleLevels() { +bool AdScene::sortScaleLevels() { bool changed; do { changed = false; for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { - CAdScaleLevel *sl = _scaleLevels[i]; + AdScaleLevel *sl = _scaleLevels[i]; _scaleLevels[i] = _scaleLevels[i + 1]; _scaleLevels[i + 1] = sl; @@ -2080,13 +2080,13 @@ bool CAdScene::sortScaleLevels() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::sortRotLevels() { +bool AdScene::sortRotLevels() { bool changed; do { changed = false; for (int i = 0; i < _rotLevels.getSize() - 1; i++) { if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { - CAdRotLevel *rl = _rotLevels[i]; + AdRotLevel *rl = _rotLevels[i]; _rotLevels[i] = _rotLevels[i + 1]; _rotLevels[i + 1] = rl; @@ -2101,12 +2101,12 @@ bool CAdScene::sortRotLevels() { ////////////////////////////////////////////////////////////////////////// -float CAdScene::getScaleAt(int Y) { - CAdScaleLevel *prev = NULL; - CAdScaleLevel *next = NULL; +float AdScene::getScaleAt(int Y) { + AdScaleLevel *prev = NULL; + AdScaleLevel *next = NULL; for (int i = 0; i < _scaleLevels.getSize(); i++) { - /* CAdScaleLevel *xxx = _scaleLevels[i];*/ + /* AdScaleLevel *xxx = _scaleLevels[i];*/ /* int j = _scaleLevels.getSize(); */ if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; else { @@ -2127,8 +2127,8 @@ float CAdScene::getScaleAt(int Y) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool AdScene::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_autoScroll)); persistMgr->transfer(TMEMBER(_editorColBlocked)); @@ -2187,12 +2187,12 @@ bool CAdScene::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::afterLoad() { +bool AdScene::afterLoad() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, CBObject *requester) { +bool AdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, BaseObject *requester) { double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; int x1, y1, x2, y2; @@ -2251,7 +2251,7 @@ bool CAdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *ta } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, CBObject *requester) { +bool AdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, BaseObject *requester) { int x = *argX; int y = *argY; @@ -2328,15 +2328,15 @@ bool CAdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, ////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsStart() { +void AdScene::pfPointsStart() { _pfPointsNum = 0; } ////////////////////////////////////////////////////////////////////////// -void CAdScene::pfPointsAdd(int x, int y, int distance) { +void AdScene::pfPointsAdd(int x, int y, int distance) { if (_pfPointsNum >= _pfPath.getSize()) { - _pfPath.add(new CAdPathPoint(x, y, distance)); + _pfPath.add(new AdPathPoint(x, y, distance)); } else { _pfPath[_pfPointsNum]->x = x; _pfPath[_pfPointsNum]->y = y; @@ -2350,8 +2350,8 @@ void CAdScene::pfPointsAdd(int x, int y, int distance) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdScene::getViewportOffset(int *offsetX, int *offsetY) { + AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (offsetX) *offsetX = _viewport->_offsetX; if (offsetY) *offsetY = _viewport->_offsetY; @@ -2367,8 +2367,8 @@ bool CAdScene::getViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getViewportSize(int *width, int *height) { - CAdGame *adGame = (CAdGame *)_gameRef; +bool AdScene::getViewportSize(int *width, int *height) { + AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (width) *width = _viewport->getWidth(); if (height) *height = _viewport->getHeight(); @@ -2384,7 +2384,7 @@ bool CAdScene::getViewportSize(int *width, int *height) { ////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetLeft() { +int AdScene::getOffsetLeft() { int viewportX; getViewportOffset(&viewportX); @@ -2393,7 +2393,7 @@ int CAdScene::getOffsetLeft() { ////////////////////////////////////////////////////////////////////////// -int CAdScene::getOffsetTop() { +int AdScene::getOffsetTop() { int viewportY; getViewportOffset(NULL, &viewportY); @@ -2402,7 +2402,7 @@ int CAdScene::getOffsetTop() { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::pointInViewport(int x, int y) { +bool AdScene::pointInViewport(int x, int y) { int left, top, width, height; getViewportOffset(&left, &top); @@ -2413,21 +2413,21 @@ bool CAdScene::pointInViewport(int x, int y) { ////////////////////////////////////////////////////////////////////////// -void CAdScene::setOffset(int offsetLeft, int offsetTop) { +void AdScene::setOffset(int offsetLeft, int offsetTop) { _offsetLeft = offsetLeft; _offsetTop = offsetTop; } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNodeByName(const char *name) { - CBObject *ret = NULL; +BaseObject *AdScene::getNodeByName(const char *name) { + BaseObject *ret = NULL; // dependent objects for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; + AdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; + AdSceneNode *node = layer->_nodes[j]; if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { switch (node->_type) { @@ -2464,32 +2464,32 @@ CBObject *CAdScene::getNodeByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::saveState() { +bool AdScene::saveState() { return persistState(true); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::loadState() { +bool AdScene::loadState() { return persistState(false); } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::persistState(bool saving) { +bool AdScene::persistState(bool saving) { if (!_persistentState) return STATUS_OK; - CAdGame *adGame = (CAdGame *)_gameRef; - CAdSceneState *state = adGame->getSceneState(_filename, saving); + AdGame *adGame = (AdGame *)_gameRef; + AdSceneState *state = adGame->getSceneState(_filename, saving); if (!state) return STATUS_OK; - CAdNodeState *nodeState; + AdNodeState *nodeState; // dependent objects for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; + AdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.getSize(); j++) { - CAdSceneNode *node = layer->_nodes[j]; + AdSceneNode *node = layer->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: if (!node->_entity->_saveState) continue; @@ -2509,7 +2509,7 @@ bool CAdScene::persistState(bool saving) { } break; default: - warning("CAdScene::PersistState - unhandled enum"); + warning("AdScene::PersistState - unhandled enum"); break; } } @@ -2521,7 +2521,7 @@ bool CAdScene::persistState(bool saving) { if (_objects[i]->_type == OBJECT_ENTITY) { nodeState = state->getNodeState(_objects[i]->_name, saving); if (nodeState) { - nodeState->transferEntity((CAdEntity *)_objects[i], _persistentStateSprites, saving); + nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); //if(Saving) NodeState->_active = _objects[i]->_active; //else _objects[i]->_active = NodeState->_active; } @@ -2542,12 +2542,12 @@ bool CAdScene::persistState(bool saving) { ////////////////////////////////////////////////////////////////////////// -float CAdScene::getRotationAt(int x, int y) { - CAdRotLevel *prev = NULL; - CAdRotLevel *next = NULL; +float AdScene::getRotationAt(int x, int y) { + AdRotLevel *prev = NULL; + AdRotLevel *next = NULL; for (int i = 0; i < _rotLevels.getSize(); i++) { - /* CAdRotLevel *xxx = _rotLevels[i]; + /* AdRotLevel *xxx = _rotLevels[i]; int j = _rotLevels.getSize();*/ if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; else { @@ -2568,12 +2568,12 @@ float CAdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::handleItemAssociations(const char *itemName, bool show) { +bool AdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _layers.getSize(); i++) { - CAdLayer *layer = _layers[i]; + AdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.getSize(); j++) { if (layer->_nodes[j]->_type == OBJECT_ENTITY) { - CAdEntity *ent = layer->_nodes[j]->_entity; + AdEntity *ent = layer->_nodes[j]->_entity; if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; } @@ -2582,7 +2582,7 @@ bool CAdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { - CAdEntity *ent = (CAdEntity *)_objects[i]; + AdEntity *ent = (AdEntity *)_objects[i]; if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; } } @@ -2592,11 +2592,11 @@ bool CAdScene::handleItemAssociations(const char *itemName, bool show) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions) { +bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) { int numUsed = 0; if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { - CAdSceneNode *node = _mainLayer->_nodes[i]; + AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (numUsed < numRegions - 1) { regionList[numUsed] = node->_region; @@ -2613,14 +2613,14 @@ bool CAdScene::getRegionsAt(int x, int y, CAdRegion **regionList, int numRegions } ////////////////////////////////////////////////////////////////////////// -bool CAdScene::restoreDeviceObjects() { +bool AdScene::restoreDeviceObjects() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { - CBArray objects; +BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { + BaseArray objects; getSceneObjects(objects, true); if (objects.getSize() == 0) return NULL; @@ -2639,8 +2639,8 @@ CBObject *CAdScene::getNextAccessObject(CBObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { - CBArray objects; +BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { + BaseArray objects; getSceneObjects(objects, true); if (objects.getSize() == 0) return NULL; @@ -2660,24 +2660,24 @@ CBObject *CAdScene::getPrevAccessObject(CBObject *currObject) { ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getSceneObjects(CBArray &objects, bool interactiveOnly) { +bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.getSize(); i++) { // close-up layer -> remove everything below it if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { - CAdSceneNode *node = _layers[i]->_nodes[j]; + AdSceneNode *node = _layers[i]->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: { - CAdEntity *ent = node->_entity; + AdEntity *ent = node->_entity; if (ent->_active && (ent->_registrable || !interactiveOnly)) objects.add(ent); } break; case OBJECT_REGION: { - CBArray regionObj; + BaseArray regionObj; getRegionObjects(node->_region, regionObj, interactiveOnly); for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; @@ -2693,14 +2693,14 @@ bool CAdScene::getSceneObjects(CBArray &objects, bool } break; default: - warning("CAdScene::GetSceneObjects - Unhandled enum"); + warning("AdScene::GetSceneObjects - Unhandled enum"); break; } } } // objects outside any region - CBArray regionObj; + BaseArray regionObj; getRegionObjects(NULL, regionObj, interactiveOnly); for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; @@ -2719,9 +2719,9 @@ bool CAdScene::getSceneObjects(CBArray &objects, bool ////////////////////////////////////////////////////////////////////////// -bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &objects, bool interactiveOnly) { - CAdGame *adGame = (CAdGame *)_gameRef; - CAdObject *obj; +bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly) { + AdGame *adGame = (AdGame *)_gameRef; + AdObject *obj; // global objects for (int i = 0; i < adGame->_objects.getSize(); i++) { @@ -2744,7 +2744,7 @@ bool CAdScene::getRegionObjects(CAdRegion *region, CBArray &Objects, bool InteractiveOnly); - bool getRegionObjects(CAdRegion *Region, CBArray &Objects, bool InteractiveOnly); + BaseObject *getNextAccessObject(BaseObject *CurrObject); + BaseObject *getPrevAccessObject(BaseObject *CurrObject); + bool getSceneObjects(BaseArray &Objects, bool InteractiveOnly); + bool getRegionObjects(AdRegion *Region, BaseArray &Objects, bool InteractiveOnly); bool afterLoad(); - bool getRegionsAt(int X, int Y, CAdRegion **RegionList, int NumRegions); + bool getRegionsAt(int X, int Y, AdRegion **RegionList, int NumRegions); bool handleItemAssociations(const char *ItemName, bool Show); - CUIWindow *_shieldWindow; + UIWindow *_shieldWindow; float getRotationAt(int X, int Y); bool loadState(); bool saveState(); bool _persistentState; bool _persistentStateSprites; - CBObject *getNodeByName(const char *name); + BaseObject *getNodeByName(const char *name); void setOffset(int OffsetLeft, int OffsetTop); bool pointInViewport(int X, int Y); int getOffsetTop(); int getOffsetLeft(); bool getViewportSize(int *Width = NULL, int *Height = NULL); bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); - CBViewport *_viewport; - CBFader *_fader; + BaseViewport *_viewport; + BaseFader *_fader; int _pfPointsNum; void pfPointsAdd(int X, int Y, int Distance); void pfPointsStart(); bool _initialized; - bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, CBObject *Requester); - DECLARE_PERSISTENT(CAdScene, CBObject) - bool displayRegionContent(CAdRegion *Region = NULL, bool Display3DOnly = false); - bool displayRegionContentOld(CAdRegion *Region = NULL); + bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); + bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, BaseObject *Requester); + DECLARE_PERSISTENT(AdScene, BaseObject) + bool displayRegionContent(AdRegion *Region = NULL, bool Display3DOnly = false); + bool displayRegionContentOld(AdRegion *Region = NULL); static int compareObjs(const void *Obj1, const void *Obj2); bool updateFreeObjects(); @@ -87,14 +87,14 @@ public: float getScaleAt(int Y); bool sortScaleLevels(); bool sortRotLevels(); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); bool _paralaxScrolling; void skipTo(int OffsetX, int OffsetY); void setDefaults(); void cleanup(); - void skipToObject(CBObject *Object); - void scrollToObject(CBObject *Object); + void skipToObject(BaseObject *Object); + void scrollToObject(BaseObject *Object); void scrollTo(int OffsetX, int OffsetY); virtual bool update(); bool _autoScroll; @@ -113,22 +113,22 @@ public: uint32 _pfMaxTime; bool initLoop(); void pathFinderStep(); - bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, CBObject *Requester = NULL); - CAdLayer *_mainLayer; + bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); + bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); + AdLayer *_mainLayer; float getZoomAt(int X, int Y); - bool getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject *requester = NULL); - CAdScene(CBGame *inGame); - virtual ~CAdScene(); - CBArray _layers; - CBArray _objects; - CBArray _waypointGroups; + bool getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = NULL); + AdScene(BaseGame *inGame); + virtual ~AdScene(); + BaseArray _layers; + BaseArray _objects; + BaseArray _waypointGroups; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); int _width; int _height; - bool addObject(CAdObject *Object); - bool removeObject(CAdObject *Object); + bool addObject(AdObject *Object); + bool removeObject(AdObject *Object); int _editorMarginH; int _editorMarginV; uint32 _editorColFrame; @@ -149,27 +149,27 @@ public: bool _editorShowDecor; bool _editorShowEntities; bool _editorShowScale; - CBArray _scaleLevels; - CBArray _rotLevels; + BaseArray _scaleLevels; + BaseArray _rotLevels; virtual bool restoreDeviceObjects(); - int getPointsDist(CBPoint p1, CBPoint p2, CBObject *requester = NULL); + int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: bool persistState(bool Saving = true); - void pfAddWaypointGroup(CAdWaypointGroup *Wpt, CBObject *Requester = NULL); + void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *Requester = NULL); bool _pfReady; - CBPoint *_pfTarget; - CAdPath *_pfTargetPath; - CBObject *_pfRequester; - CBArray _pfPath; + BasePoint *_pfTarget; + AdPath *_pfTargetPath; + BaseObject *_pfRequester; + BaseArray _pfPath; int _offsetTop; int _offsetLeft; diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index da7082105f..dbf68ff0ca 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -32,10 +32,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdSceneNode, false) +IMPLEMENT_PERSISTENT(AdSceneNode, false) ////////////////////////////////////////////////////////////////////////// -CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { +AdSceneNode::AdSceneNode(BaseGame *inGame): BaseObject(inGame) { _type = OBJECT_NONE; _region = NULL; _entity = NULL; @@ -43,7 +43,7 @@ CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdSceneNode::~CAdSceneNode() { +AdSceneNode::~AdSceneNode() { _gameRef->unregisterObject(_region); _region = NULL; @@ -53,7 +53,7 @@ CAdSceneNode::~CAdSceneNode() { ////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setEntity(CAdEntity *entity) { +bool AdSceneNode::setEntity(AdEntity *entity) { _type = OBJECT_ENTITY; _entity = entity; return _gameRef->registerObject(entity); @@ -61,7 +61,7 @@ bool CAdSceneNode::setEntity(CAdEntity *entity) { ////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::setRegion(CAdRegion *region) { +bool AdSceneNode::setRegion(AdRegion *region) { _type = OBJECT_REGION; _region = region; return _gameRef->registerObject(region); @@ -69,9 +69,9 @@ bool CAdSceneNode::setRegion(CAdRegion *region) { ////////////////////////////////////////////////////////////////////////// -bool CAdSceneNode::persist(CBPersistMgr *persistMgr) { +bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_entity)); persistMgr->transfer(TMEMBER(_region)); diff --git a/engines/wintermute/ad/ad_scene_node.h b/engines/wintermute/ad/ad_scene_node.h index 1c25f91a2d..b56c351bc8 100644 --- a/engines/wintermute/ad/ad_scene_node.h +++ b/engines/wintermute/ad/ad_scene_node.h @@ -36,16 +36,16 @@ namespace WinterMute { -class CAdSceneNode : public CBObject { +class AdSceneNode : public BaseObject { public: - DECLARE_PERSISTENT(CAdSceneNode, CBObject) - bool setRegion(CAdRegion *region); - bool setEntity(CAdEntity *entity); - CAdEntity *_entity; - CAdRegion *_region; + DECLARE_PERSISTENT(AdSceneNode, BaseObject) + bool setRegion(AdRegion *region); + bool setEntity(AdEntity *entity); + AdEntity *_entity; + AdRegion *_region; TObjectType _type; - CAdSceneNode(CBGame *inGame); - virtual ~CAdSceneNode(); + AdSceneNode(BaseGame *inGame); + virtual ~AdSceneNode(); }; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 2ac36054a5..da7b417470 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -35,16 +35,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdSceneState, false) +IMPLEMENT_PERSISTENT(AdSceneState, false) ////////////////////////////////////////////////////////////////////////// -CAdSceneState::CAdSceneState(CBGame *inGame): CBBase(inGame) { +AdSceneState::AdSceneState(BaseGame *inGame): BaseClass(inGame) { _filename = NULL; } ////////////////////////////////////////////////////////////////////////// -CAdSceneState::~CAdSceneState() { +AdSceneState::~AdSceneState() { delete[] _filename; _filename = NULL; @@ -54,7 +54,7 @@ CAdSceneState::~CAdSceneState() { ////////////////////////////////////////////////////////////////////////// -bool CAdSceneState::persist(CBPersistMgr *persistMgr) { +bool AdSceneState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); _nodeStates.persist(persistMgr); @@ -63,7 +63,7 @@ bool CAdSceneState::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CAdSceneState::setFilename(const char *filename) { +void AdSceneState::setFilename(const char *filename) { delete[] _filename; _filename = new char [strlen(filename) + 1]; if (_filename) strcpy(_filename, filename); @@ -71,13 +71,13 @@ void CAdSceneState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { +AdNodeState *AdSceneState::getNodeState(char *name, bool saving) { for (int i = 0; i < _nodeStates.getSize(); i++) { if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; } if (saving) { - CAdNodeState *ret = new CAdNodeState(_gameRef); + AdNodeState *ret = new AdNodeState(_gameRef); ret->setName(name); _nodeStates.add(ret); diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h index 6df20e0578..7231ba52db 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -34,16 +34,16 @@ #include "engines/wintermute/coll_templ.h" namespace WinterMute { -class CAdNodeState; -class CAdSceneState : public CBBase { +class AdNodeState; +class AdSceneState : public BaseClass { public: - CAdNodeState *getNodeState(char *name, bool saving); + AdNodeState *getNodeState(char *name, bool saving); void setFilename(const char *filename); - DECLARE_PERSISTENT(CAdSceneState, CBBase) - CAdSceneState(CBGame *inGame); - virtual ~CAdSceneState(); + DECLARE_PERSISTENT(AdSceneState, BaseClass) + AdSceneState(BaseGame *inGame); + virtual ~AdSceneState(); char *_filename; - CBArray _nodeStates; + BaseArray _nodeStates; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 2607993aa0..ba59f57451 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -41,10 +41,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdSentence, false) +IMPLEMENT_PERSISTENT(AdSentence, false) ////////////////////////////////////////////////////////////////////////// -CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { +AdSentence::AdSentence(BaseGame *inGame): BaseClass(inGame) { _text = NULL; _stances = NULL; _tempStance = NULL; @@ -72,7 +72,7 @@ CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdSentence::~CAdSentence() { +AdSentence::~AdSentence() { delete _sound; delete[] _text; delete[] _stances; @@ -91,7 +91,7 @@ CAdSentence::~CAdSentence() { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::setText(const char *text) { +void AdSentence::setText(const char *text) { if (_text) delete [] _text; _text = new char[strlen(text) + 1]; if (_text) strcpy(_text, text); @@ -99,7 +99,7 @@ void CAdSentence::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::setStances(const char *stances) { +void AdSentence::setStances(const char *stances) { if (_stances) delete [] _stances; if (stances) { _stances = new char[strlen(stances) + 1]; @@ -109,20 +109,20 @@ void CAdSentence::setStances(const char *stances) { ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getCurrentStance() { +char *AdSentence::getCurrentStance() { return getStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getNextStance() { +char *AdSentence::getNextStance() { _currentStance++; return getStance(_currentStance); } ////////////////////////////////////////////////////////////////////////// -char *CAdSentence::getStance(int stance) { +char *AdSentence::getStance(int stance) { if (_stances == NULL) return NULL; if (_tempStance) delete [] _tempStance; @@ -165,7 +165,7 @@ char *CAdSentence::getStance(int stance) { ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::display() { +bool AdSentence::display() { if (!_font || !_text) return STATUS_FAILED; if (_sound && !_soundStarted) { @@ -178,8 +178,8 @@ bool CAdSentence::display() { int y = _pos.y; if (!_fixedPos) { - x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft(); - y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop(); + x = x - ((AdGame *)_gameRef)->_scene->getOffsetLeft(); + y = y - ((AdGame *)_gameRef)->_scene->getOffsetTop(); } @@ -195,7 +195,7 @@ bool CAdSentence::display() { ////////////////////////////////////////////////////////////////////////// -void CAdSentence::setSound(CBSound *sound) { +void AdSentence::setSound(BaseSound *sound) { if (!sound) return; delete _sound; _sound = sound; @@ -204,14 +204,14 @@ void CAdSentence::setSound(CBSound *sound) { ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::finish() { +bool AdSentence::finish() { if (_sound) _sound->stop(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::persist(CBPersistMgr *persistMgr) { +bool AdSentence::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -238,7 +238,7 @@ bool CAdSentence::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::setupTalkFile(const char *soundFilename) { +bool AdSentence::setupTalkFile(const char *soundFilename) { delete _talkDef; _talkDef = NULL; _currentSprite = NULL; @@ -257,7 +257,7 @@ bool CAdSentence::setupTalkFile(const char *soundFilename) { } else return STATUS_OK; // no talk def file found - _talkDef = new CAdTalkDef(_gameRef); + _talkDef = new AdTalkDef(_gameRef); if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { delete _talkDef; _talkDef = NULL; @@ -270,7 +270,7 @@ bool CAdSentence::setupTalkFile(const char *soundFilename) { ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::update(TDirection dir) { +bool AdSentence::update(TDirection dir) { if (!_talkDef) return STATUS_OK; uint32 currentTime; @@ -287,7 +287,7 @@ bool CAdSentence::update(TDirection dir) { if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { talkNodeFound = true; - CBSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); + BaseSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); if (newSprite != _currentSprite) newSprite->reset(); _currentSprite = newSprite; @@ -298,7 +298,7 @@ bool CAdSentence::update(TDirection dir) { // no talk node, try to use default sprite instead (if any) if (!talkNodeFound) { - CBSprite *newSprite = _talkDef->getDefaultSprite(dir); + BaseSprite *newSprite = _talkDef->getDefaultSprite(dir); if (newSprite) { if (newSprite != _currentSprite) newSprite->reset(); _currentSprite = newSprite; @@ -309,7 +309,7 @@ bool CAdSentence::update(TDirection dir) { } ////////////////////////////////////////////////////////////////////////// -bool CAdSentence::CanSkip() { +bool AdSentence::CanSkip() { // prevent accidental sentence skipping (TODO make configurable) return (_gameRef->_timer - _startTime) > 300; } diff --git a/engines/wintermute/ad/ad_sentence.h b/engines/wintermute/ad/ad_sentence.h index 40f99ea830..6883bd8893 100644 --- a/engines/wintermute/ad/ad_sentence.h +++ b/engines/wintermute/ad/ad_sentence.h @@ -37,28 +37,28 @@ #include "common/rect.h" namespace WinterMute { -class CAdTalkDef; -class CBFont; -class CBSprite; -class CBSound; -class CAdSentence : public CBBase { +class AdTalkDef; +class BaseFont; +class BaseSprite; +class BaseSound; +class AdSentence : public BaseClass { public: bool _freezable; bool _fixedPos; - CBSprite *_currentSprite; + BaseSprite *_currentSprite; char *_currentSkelAnim; bool update(TDirection dir = DI_DOWN); bool setupTalkFile(const char *soundFilename); - DECLARE_PERSISTENT(CAdSentence, CBBase) + DECLARE_PERSISTENT(AdSentence, BaseClass) bool finish(); - void setSound(CBSound *Sound); + void setSound(BaseSound *Sound); bool _soundStarted; - CBSound *_sound; + BaseSound *_sound; TTextAlign _align; bool display(); int _width; Point32 _pos; - CBFont *_font; + BaseFont *_font; char *getNextStance(); char *getCurrentStance(); void setStances(const char *stances); @@ -68,9 +68,9 @@ public: char *_stances; char *_text; uint32 _duration; - CAdSentence(CBGame *inGame); - virtual ~CAdSentence(); - CAdTalkDef *_talkDef; + AdSentence(BaseGame *inGame); + virtual ~AdSentence(); + AdTalkDef *_talkDef; bool CanSkip(); diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index f0925c6913..b594bd0467 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -35,10 +35,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdSpriteSet, false) +IMPLEMENT_PERSISTENT(AdSpriteSet, false) ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { +AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner): BaseObject(inGame) { _owner = owner; for (int i = 0; i < NUM_DIRECTIONS; i++) @@ -47,7 +47,7 @@ CAdSpriteSet::CAdSpriteSet(CBGame *inGame, CBObject *owner): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdSpriteSet::~CAdSpriteSet() { +AdSpriteSet::~AdSpriteSet() { for (int i = 0; i < NUM_DIRECTIONS; i++) { delete _sprites[i]; _sprites[i] = NULL; @@ -58,10 +58,10 @@ CAdSpriteSet::~CAdSpriteSet() { ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -90,7 +90,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { +bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -108,7 +108,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { @@ -118,7 +118,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite buffer = params; } - CBSprite *spr = NULL; + BaseSprite *spr = NULL; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: @@ -132,7 +132,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_LEFT: delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_LEFT] = spr; break; @@ -140,7 +140,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_RIGHT: delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_RIGHT] = spr; break; @@ -148,7 +148,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_UP: delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UP] = spr; break; @@ -156,7 +156,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_DOWN: delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWN] = spr; break; @@ -164,7 +164,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_UP_LEFT: delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPLEFT] = spr; break; @@ -172,7 +172,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_UP_RIGHT: delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_UPRIGHT] = spr; break; @@ -180,7 +180,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_DOWN_LEFT: delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNLEFT] = spr; break; @@ -188,7 +188,7 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite case TOKEN_DOWN_RIGHT: delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; - spr = new CBSprite(_gameRef, _owner); + spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; else _sprites[DI_DOWNRIGHT] = spr; break; @@ -214,9 +214,9 @@ bool CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprite ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { +bool AdSpriteSet::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_owner)); for (int i = 0; i < NUM_DIRECTIONS; i++) { @@ -228,12 +228,12 @@ bool CAdSpriteSet::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdSpriteSet::getSprite(TDirection direction) { +BaseSprite *AdSpriteSet::getSprite(TDirection direction) { int dir = (int)direction; if (dir < 0) dir = 0; if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; - CBSprite *ret = NULL; + BaseSprite *ret = NULL; // find nearest set sprite int numSteps = 0; @@ -258,7 +258,7 @@ CBSprite *CAdSpriteSet::getSprite(TDirection direction) { ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITESET {\n"); if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); for (int i = 0; i < NUM_DIRECTIONS; i++) { @@ -292,7 +292,7 @@ bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { } } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); @@ -300,7 +300,7 @@ bool CAdSpriteSet::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -bool CAdSpriteSet::containsSprite(CBSprite *sprite) { +bool AdSpriteSet::containsSprite(BaseSprite *sprite) { if (!sprite) return false; for (int i = 0; i < NUM_DIRECTIONS; i++) { diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h index 993832cfa3..196d8a8e3a 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -35,18 +35,18 @@ namespace WinterMute { -class CAdSpriteSet : public CBObject { +class AdSpriteSet : public BaseObject { public: - bool containsSprite(CBSprite *sprite); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBSprite *getSprite(TDirection direction); - DECLARE_PERSISTENT(CAdSpriteSet, CBObject) - CBObject *_owner; - CAdSpriteSet(CBGame *inGame, CBObject *owner = NULL); - virtual ~CAdSpriteSet(); + bool containsSprite(BaseSprite *sprite); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + BaseSprite *getSprite(TDirection direction); + DECLARE_PERSISTENT(AdSpriteSet, BaseObject) + BaseObject *_owner; + AdSpriteSet(BaseGame *inGame, BaseObject *owner = NULL); + virtual ~AdSpriteSet(); bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - CBSprite *_sprites[NUM_DIRECTIONS]; + BaseSprite *_sprites[NUM_DIRECTIONS]; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 0cd62df603..979e8b2698 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -39,10 +39,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdTalkDef, false) +IMPLEMENT_PERSISTENT(AdTalkDef, false) ////////////////////////////////////////////////////////////////////////// -CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { +AdTalkDef::AdTalkDef(BaseGame *inGame): BaseObject(inGame) { _defaultSpriteFilename = NULL; _defaultSprite = NULL; @@ -52,7 +52,7 @@ CAdTalkDef::CAdTalkDef(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdTalkDef::~CAdTalkDef() { +AdTalkDef::~AdTalkDef() { for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; _nodes.removeAll(); @@ -69,16 +69,16 @@ CAdTalkDef::~CAdTalkDef() { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadFile(const char *filename) { +bool AdTalkDef::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } bool ret; - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); @@ -98,7 +98,7 @@ TOKEN_DEF(DEFAULT_SPRITE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { +bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TALK) TOKEN_TABLE(TEMPLATE) @@ -111,7 +111,7 @@ bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { @@ -128,7 +128,7 @@ bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ACTION: { - CAdTalkNode *Node = new CAdTalkNode(_gameRef); + AdTalkNode *Node = new AdTalkNode(_gameRef); if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); else { delete Node; @@ -139,16 +139,16 @@ bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_DEFAULT_SPRITE: - CBUtils::setString(&_defaultSpriteFilename, (char *)params); + BaseUtils::setString(&_defaultSpriteFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET_FILE: - CBUtils::setString(&_defaultSpriteSetFilename, (char *)params); + BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params); break; case TOKEN_DEFAULT_SPRITESET: { delete _defaultSpriteSet; - _defaultSpriteSet = new CAdSpriteSet(_gameRef); + _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; @@ -179,12 +179,12 @@ bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { _defaultSpriteSet = NULL; if (_defaultSpriteFilename) { - _defaultSprite = new CBSprite(_gameRef); + _defaultSprite = new BaseSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; } if (_defaultSpriteSetFilename) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); + _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; } @@ -194,9 +194,9 @@ bool CAdTalkDef::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { +bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_defaultSprite)); persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); @@ -210,7 +210,7 @@ bool CAdTalkDef::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdTalkDef::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TALK {\n"); if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); @@ -221,7 +221,7 @@ bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { _nodes[i]->saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "\n"); } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); @@ -230,16 +230,16 @@ bool CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkDef::loadDefaultSprite() { +bool AdTalkDef::loadDefaultSprite() { if (_defaultSpriteFilename && !_defaultSprite) { - _defaultSprite = new CBSprite(_gameRef); + _defaultSprite = new BaseSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { delete _defaultSprite; _defaultSprite = NULL; return STATUS_FAILED; } else return STATUS_OK; } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { - _defaultSpriteSet = new CAdSpriteSet(_gameRef); + _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; @@ -250,7 +250,7 @@ bool CAdTalkDef::loadDefaultSprite() { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkDef::getDefaultSprite(TDirection dir) { +BaseSprite *AdTalkDef::getDefaultSprite(TDirection dir) { loadDefaultSprite(); if (_defaultSprite) return _defaultSprite; else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index 0811f5b8f5..fa32a81041 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -33,24 +33,24 @@ #include "engines/wintermute/base/base_object.h" namespace WinterMute { -class CAdTalkNode; -class CAdSpriteSet; -class CAdTalkDef : public CBObject { +class AdTalkNode; +class AdSpriteSet; +class AdTalkDef : public BaseObject { public: char *_defaultSpriteSetFilename; - CAdSpriteSet *_defaultSpriteSet; - CBSprite *getDefaultSprite(TDirection Dir); + AdSpriteSet *_defaultSpriteSet; + BaseSprite *getDefaultSprite(TDirection Dir); bool loadDefaultSprite(); - DECLARE_PERSISTENT(CAdTalkDef, CBObject) + DECLARE_PERSISTENT(AdTalkDef, BaseObject) - CAdTalkDef(CBGame *inGame); - virtual ~CAdTalkDef(); + AdTalkDef(BaseGame *inGame); + virtual ~AdTalkDef(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - CBArray _nodes; + BaseArray _nodes; char *_defaultSpriteFilename; - CBSprite *_defaultSprite; - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + BaseSprite *_defaultSprite; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 28e62798c2..bd48ac601c 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -40,16 +40,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdTalkHolder, false) +IMPLEMENT_PERSISTENT(AdTalkHolder, false) ////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::CAdTalkHolder(CBGame *inGame): CAdObject(inGame) { +AdTalkHolder::AdTalkHolder(BaseGame *inGame): AdObject(inGame) { _sprite = NULL; } ////////////////////////////////////////////////////////////////////////// -CAdTalkHolder::~CAdTalkHolder() { +AdTalkHolder::~AdTalkHolder() { delete _sprite; _sprite = NULL; @@ -63,19 +63,19 @@ CAdTalkHolder::~CAdTalkHolder() { } ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { - CBSprite *ret = NULL; +BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { + BaseSprite *ret = NULL; // forced stance? if (_forcedTalkAnimName && !_forcedTalkAnimUsed) { _forcedTalkAnimUsed = true; delete _animSprite; - _animSprite = new CBSprite(_gameRef, this); + _animSprite = new BaseSprite(_gameRef, this); if (_animSprite) { bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -119,14 +119,14 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSprite ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSprite") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); bool setCurrent = false; if (_currentSprite && _currentSprite == _sprite) setCurrent = true; @@ -140,7 +140,7 @@ bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->pushBool(true); } else { const char *filename = val->getString(); - CBSprite *spr = new CBSprite(_gameRef, this); + BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { script->runtimeError("SetSprite method failed for file '%s'", filename); stack->pushBool(false); @@ -184,7 +184,7 @@ bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *t const char *filename = stack->pop()->getString(); bool Ex = stack->pop()->getBool(); - CBSprite *spr = new CBSprite(_gameRef, this); + BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("AddTalkSprite method failed for file '%s'", filename); @@ -255,7 +255,7 @@ bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *t bool setCurrent = false; bool setTemp2 = false; - CBSprite *spr = new CBSprite(_gameRef, this); + BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("SetTalkSprite method failed for file '%s'", filename); @@ -295,12 +295,12 @@ bool CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *t return STATUS_OK; } - else return CAdObject::scCallMethod(script, stack, thisStack, name); + else return AdObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CAdTalkHolder::scGetProperty(const char *name) { +ScValue *AdTalkHolder::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -311,12 +311,12 @@ CScValue *CAdTalkHolder::scGetProperty(const char *name) { return _scValue; } - else return CAdObject::scGetProperty(name); + else return AdObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { +bool AdTalkHolder::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Item @@ -326,18 +326,18 @@ bool CAdTalkHolder::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else*/ return CAdObject::scSetProperty(name, value); + else*/ return AdObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CAdTalkHolder::scToString() { +const char *AdTalkHolder::scToString() { return "[talk-holder object]"; } ////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { for (int i = 0; i < _talkSprites.getSize(); i++) { if (_talkSprites[i]->_filename) buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); @@ -353,8 +353,8 @@ bool CAdTalkHolder::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkHolder::persist(CBPersistMgr *persistMgr) { - CAdObject::persist(persistMgr); +bool AdTalkHolder::persist(BasePersistenceManager *persistMgr) { + AdObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_sprite)); _talkSprites.persist(persistMgr); diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h index 50c2f3504b..8ad8ae1e52 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -33,21 +33,21 @@ namespace WinterMute { -class CAdTalkHolder : public CAdObject { +class AdTalkHolder : public AdObject { public: - DECLARE_PERSISTENT(CAdTalkHolder, CAdObject) - virtual CBSprite *getTalkStance(const char *stance); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - CBSprite *_sprite; - CBArray _talkSprites; - CBArray _talkSpritesEx; - CAdTalkHolder(CBGame *inGame); - virtual ~CAdTalkHolder(); + DECLARE_PERSISTENT(AdTalkHolder, AdObject) + virtual BaseSprite *getTalkStance(const char *stance); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + BaseSprite *_sprite; + BaseArray _talkSprites; + BaseArray _talkSpritesEx; + AdTalkHolder(BaseGame *inGame); + virtual ~AdTalkHolder(); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index 3b82d731c9..5325b1aeff 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -36,10 +36,10 @@ #include "engines/wintermute/utils/utils.h" namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdTalkNode, false) +IMPLEMENT_PERSISTENT(AdTalkNode, false) ////////////////////////////////////////////////////////////////////////// -CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { +AdTalkNode::AdTalkNode(BaseGame *inGame): BaseClass(inGame) { _sprite = NULL; _spriteFilename = NULL; _spriteSet = NULL; @@ -53,7 +53,7 @@ CAdTalkNode::CAdTalkNode(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdTalkNode::~CAdTalkNode() { +AdTalkNode::~AdTalkNode() { delete[] _spriteFilename; delete _sprite; delete[] _spriteSetFilename; @@ -80,7 +80,7 @@ TOKEN_DEF(PRECACHE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { +bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ACTION) TOKEN_TABLE(SPRITESET_FILE) @@ -95,7 +95,7 @@ bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { @@ -112,16 +112,16 @@ bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_SPRITE: - CBUtils::setString(&_spriteFilename, (char *)params); + BaseUtils::setString(&_spriteFilename, (char *)params); break; case TOKEN_SPRITESET_FILE: - CBUtils::setString(&_spriteSetFilename, (char *)params); + BaseUtils::setString(&_spriteSetFilename, (char *)params); break; case TOKEN_SPRITESET: { delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); + _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { delete _spriteSet; _spriteSet = NULL; @@ -143,7 +143,7 @@ bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_COMMENT: - if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params); + if (_gameRef->_editorMode) BaseUtils::setString(&_comment, (char *)params); break; case TOKEN_EDITOR_PROPERTY: @@ -168,14 +168,14 @@ bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { if (_preCache && _spriteFilename) { delete _sprite; - _sprite = new CBSprite(_gameRef); + _sprite = new BaseSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) return STATUS_FAILED; } if (_preCache && _spriteSetFilename) { delete _spriteSet; - _spriteSet = new CAdSpriteSet(_gameRef); + _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) return STATUS_FAILED; } @@ -186,7 +186,7 @@ bool CAdTalkNode::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { +bool AdTalkNode::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_comment)); persistMgr->transfer(TMEMBER(_startTime)); persistMgr->transfer(TMEMBER(_endTime)); @@ -201,7 +201,7 @@ bool CAdTalkNode::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdTalkNode::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ACTION {\n"); if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); @@ -211,7 +211,7 @@ bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); @@ -220,9 +220,9 @@ bool CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::loadSprite() { +bool AdTalkNode::loadSprite() { if (_spriteFilename && !_sprite) { - _sprite = new CBSprite(_gameRef); + _sprite = new BaseSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { delete _sprite; _sprite = NULL; @@ -231,7 +231,7 @@ bool CAdTalkNode::loadSprite() { } else if (_spriteSetFilename && !_spriteSet) { - _spriteSet = new CAdSpriteSet(_gameRef); + _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; _spriteSet = NULL; @@ -244,7 +244,7 @@ bool CAdTalkNode::loadSprite() { ////////////////////////////////////////////////////////////////////////// -bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { +bool AdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { if (time >= _startTime) { if (_playToEnd) { if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; @@ -256,7 +256,7 @@ bool CAdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { ////////////////////////////////////////////////////////////////////////// -CBSprite *CAdTalkNode::getSprite(TDirection dir) { +BaseSprite *AdTalkNode::getSprite(TDirection dir) { loadSprite(); if (_sprite) return _sprite; else if (_spriteSet) return _spriteSet->getSprite(dir); diff --git a/engines/wintermute/ad/ad_talk_node.h b/engines/wintermute/ad/ad_talk_node.h index 55adf88e83..9e599b6af2 100644 --- a/engines/wintermute/ad/ad_talk_node.h +++ b/engines/wintermute/ad/ad_talk_node.h @@ -33,23 +33,23 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CAdSpriteSet; -class CBSprite; -class CAdTalkNode : public CBBase { +class AdSpriteSet; +class BaseSprite; +class AdTalkNode : public BaseClass { public: char *_spriteSetFilename; - CAdSpriteSet *_spriteSet; - CBSprite *getSprite(TDirection dir); + AdSpriteSet *_spriteSet; + BaseSprite *getSprite(TDirection dir); bool isInTimeInterval(uint32 time, TDirection dir); bool loadSprite(); - DECLARE_PERSISTENT(CAdTalkNode, CBBase) + DECLARE_PERSISTENT(AdTalkNode, BaseClass) - CAdTalkNode(CBGame *inGame); - virtual ~CAdTalkNode(); + AdTalkNode(BaseGame *inGame); + virtual ~AdTalkNode(); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); char *_spriteFilename; - CBSprite *_sprite; + BaseSprite *_sprite; uint32 _startTime; uint32 _endTime; bool _playToEnd; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 4a902266ac..25e5345ee7 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -37,10 +37,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CAdWaypointGroup, false) +IMPLEMENT_PERSISTENT(AdWaypointGroup, false) ////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { +AdWaypointGroup::AdWaypointGroup(BaseGame *inGame): BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; @@ -49,13 +49,13 @@ CAdWaypointGroup::CAdWaypointGroup(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CAdWaypointGroup::~CAdWaypointGroup() { +AdWaypointGroup::~AdWaypointGroup() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CAdWaypointGroup::cleanup() { +void AdWaypointGroup::cleanup() { for (int i = 0; i < _points.getSize(); i++) delete _points[i]; _points.removeAll(); @@ -64,10 +64,10 @@ void CAdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadFile(const char *filename) { +bool AdWaypointGroup::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -96,7 +96,7 @@ TOKEN_DEF(PROPERTY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { +bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WAYPOINTS) TOKEN_TABLE(TEMPLATE) @@ -110,7 +110,7 @@ bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { @@ -133,7 +133,7 @@ bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); } break; @@ -164,7 +164,7 @@ bool CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { +bool AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WAYPOINTS {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); @@ -172,7 +172,7 @@ bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { if (_scProp) _scProp->saveAsText(buffer, indent + 2); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); for (int i = 0; i < _points.getSize(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); @@ -185,9 +185,9 @@ bool CAdWaypointGroup::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { +bool AdWaypointGroup::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_editorSelectedPoint)); @@ -201,7 +201,7 @@ bool CAdWaypointGroup::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScValue *CAdWaypointGroup::scGetProperty(const char *name) { +ScValue *AdWaypointGroup::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -220,12 +220,12 @@ CScValue *CAdWaypointGroup::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { +bool AdWaypointGroup::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// @@ -234,12 +234,12 @@ bool CAdWaypointGroup::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int argY) { +bool AdWaypointGroup::mimic(AdWaypointGroup *wpt, float scale, int argX, int argY) { if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; cleanup(); @@ -248,7 +248,7 @@ bool CAdWaypointGroup::mimic(CAdWaypointGroup *wpt, float scale, int argX, int a int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); - _points.add(new CBPoint(x + argX, y + argY)); + _points.add(new BasePoint(x + argX, y + argY)); } _lastMimicScale = scale; diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index 2cece9e88b..f23f7be859 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -32,25 +32,25 @@ #include "engines/wintermute/base/base_object.h" namespace WinterMute { -class CBPoint; -class CAdWaypointGroup : public CBObject { +class BasePoint; +class AdWaypointGroup : public BaseObject { public: float _lastMimicScale; int _lastMimicX; int _lastMimicY; void cleanup(); - bool mimic(CAdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); - DECLARE_PERSISTENT(CAdWaypointGroup, CBObject) - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + bool mimic(AdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); + DECLARE_PERSISTENT(AdWaypointGroup, BaseObject) + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); bool _active; - CAdWaypointGroup(CBGame *inGame); + AdWaypointGroup(BaseGame *inGame); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual ~CAdWaypointGroup(); - CBArray _points; + virtual ~AdWaypointGroup(); + BaseArray _points; int _editorSelectedPoint; - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 5fabe94312..4b62a7553a 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -35,27 +35,27 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *gameOwner) { +BaseClass::BaseClass(BaseGame *gameOwner) { _gameRef = gameOwner; _persistable = true; } ////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { +BaseClass::BaseClass() { _gameRef = NULL; _persistable = true; } ////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { +BaseClass::~BaseClass() { _editorProps.clear(); } ////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *propName, const char *initVal) { +const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { _editorPropsIter = _editorProps.find(propName); if (_editorPropsIter != _editorProps.end()) return _editorPropsIter->_value.c_str(); @@ -65,7 +65,7 @@ const char *CBBase::getEditorProp(const char *propName, const char *initVal) { ////////////////////////////////////////////////////////////////////////// -bool CBBase::setEditorProp(const char *propName, const char *propValue) { +bool BaseClass::setEditorProp(const char *propName, const char *propValue) { if (propName == NULL) return STATUS_FAILED; if (propValue == NULL) { @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBBase::parseEditorProperty(byte *buffer, bool complete) { +bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -98,7 +98,7 @@ bool CBBase::parseEditorProperty(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { @@ -159,7 +159,7 @@ bool CBBase::parseEditorProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index e8c87f1f9e..0265ce97d5 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -37,21 +37,21 @@ namespace WinterMute { -class CBGame; -class CBDynBuffer; +class BaseGame; +class BaseDynamicBuffer; -class CBBase { +class BaseClass { public: bool _persistable; bool setEditorProp(const char *propName, const char *propValue); const char *getEditorProp(const char *propName, const char *initVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; + BaseClass(TDynamicConstructor, TDynamicConstructor) {}; bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBBase(); - CBGame *_gameRef; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + BaseClass(); + BaseGame *_gameRef; + BaseClass(BaseGame *GameOwner); + virtual ~BaseClass(); Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 5895b1acd5..493b35bf12 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -35,8 +35,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); +BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); _owner = NULL; _frame = NULL; _region = NULL; @@ -48,10 +48,10 @@ CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): BaseClass(inGame) { _owner = owner; _frame = frame; - CBPlatform::setRect(&_rect, x, y, x + width, y + height); + BasePlatform::setRect(&_rect, x, y, x + width, y + height); _zoomX = zoomX; _zoomY = zoomY; _precise = precise; @@ -61,11 +61,11 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, i } ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY): BaseClass(inGame) { _owner = owner; _region = region; - CBPlatform::copyRect(&_rect, ®ion->_rect); - CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + BasePlatform::copyRect(&_rect, ®ion->_rect); + BasePlatform::offsetRect(&_rect, -offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; @@ -77,7 +77,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, in ////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { +BaseActiveRect::~BaseActiveRect() { _owner = NULL; _frame = NULL; _region = NULL; @@ -85,11 +85,11 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// -void CBActiveRect::clipRect() { +void BaseActiveRect::clipRect() { Rect32 rc; bool customViewport; _gameRef->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = _gameRef->_renderer; + BaseRenderer *Rend = _gameRef->_renderer; if (!customViewport) { rc.left -= Rend->_drawOffsetX; @@ -101,7 +101,7 @@ void CBActiveRect::clipRect() { if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - CBPlatform::intersectRect(&_rect, &_rect, &rc); + BasePlatform::intersectRect(&_rect, &_rect, &rc); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 7c9e8d4a39..0885b0e13e 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -33,25 +33,25 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { +class BaseRegion; +class BaseSubFrame; +class BaseObject; +class BaseActiveRect: BaseClass { public: void clipRect(); bool _precise; float _zoomX; float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; + BaseSubFrame *_frame; + BaseObject *_owner; + BaseRegion *_region; int _offsetX; int _offsetY; Rect32 _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); - virtual ~CBActiveRect(); + BaseActiveRect(BaseGame *inGameOwner = NULL); + BaseActiveRect(BaseGame *inGameOwner, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY); + virtual ~BaseActiveRect(); }; diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp index 8adeea2b1f..ef4f1ce686 100644 --- a/engines/wintermute/base/base_debugger.cpp +++ b/engines/wintermute/base/base_debugger.cpp @@ -31,172 +31,172 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { +BaseDebugger::BaseDebugger(BaseGame *inGame) : BaseClass(inGame) { _enabled = false; } ////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { +BaseDebugger::~BaseDebugger(void) { } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::initialize() { +bool BaseDebugger::initialize() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::shutdown() { +bool BaseDebugger::shutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameInit() { +bool BaseDebugger::onGameInit() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameShutdown() { +bool BaseDebugger::onGameShutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameTick() { +bool BaseDebugger::onGameTick() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onLog(unsigned int errorCode, const char *text) { +bool BaseDebugger::onLog(unsigned int errorCode, const char *text) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptInit(CScScript *script) { +bool BaseDebugger::onScriptInit(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool BaseDebugger::onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool BaseDebugger::onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdown(CScScript *script) { +bool BaseDebugger::onScriptShutdown(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { +bool BaseDebugger::onScriptChangeLine(ScScript *script, int Line) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { +bool BaseDebugger::onScriptChangeScope(ScScript *script, ScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { +bool BaseDebugger::onScriptShutdownScope(ScScript *script, ScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { +bool BaseDebugger::onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { +bool BaseDebugger::onVariableChangeValue(ScValue *var, ScValue *value) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { +bool BaseDebugger::onScriptHitBreakpoint(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // IWmeDebugServer interface implementation -bool CBDebugger::attachClient(IWmeDebugClient *client) { +bool BaseDebugger::attachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::detachClient(IWmeDebugClient *client) { +bool BaseDebugger::detachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::queryData(IWmeDebugClient *client) { +bool BaseDebugger::queryData(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -int CBDebugger::getPropInt(const char *propName) { +int BaseDebugger::getPropInt(const char *propName) { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBDebugger::getPropFloat(const char *propName) { +double BaseDebugger::getPropFloat(const char *propName) { return 0.0; } ////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::getPropString(const char *propName) { +const char *BaseDebugger::getPropString(const char *propName) { return ""; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::getPropBool(const char *propName) { +bool BaseDebugger::getPropBool(const char *propName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, int propValue) { +bool BaseDebugger::setProp(const char *propName, int propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, double propValue) { +bool BaseDebugger::setProp(const char *propName, double propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, const char *propValue) { +bool BaseDebugger::setProp(const char *propName, const char *propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, bool propValue) { +bool BaseDebugger::setProp(const char *propName, bool propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { +bool BaseDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { +bool BaseDebugger::addBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { +bool BaseDebugger::removeBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::continueExecution() { +bool BaseDebugger::continueExecution() { return false; } diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h index 35ea56eafe..7266e073d8 100644 --- a/engines/wintermute/base/base_debugger.h +++ b/engines/wintermute/base/base_debugger.h @@ -36,12 +36,12 @@ // TODO: The entire debugger should possibly be removed namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { +class ScScript; +class ScValue; +class BaseDebugger : public BaseClass, public IWmeDebugServer { public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); + BaseDebugger(BaseGame *inGame); + virtual ~BaseDebugger(void); // initialization bool _enabled; @@ -53,18 +53,18 @@ public: bool onGameShutdown(); bool onGameTick(); bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(CScScript *script); - bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - bool onScriptShutdown(CScScript *script); - bool onScriptChangeLine(CScScript *script, int line); - bool onScriptChangeScope(CScScript *script, CScValue *scope); - bool onScriptShutdownScope(CScScript *script, CScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - bool onVariableChangeValue(CScValue *var, CScValue *value); - - bool onScriptHitBreakpoint(CScScript *script); + bool onScriptInit(ScScript *script); + bool onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name); + + bool onScriptShutdown(ScScript *script); + bool onScriptChangeLine(ScScript *script, int line); + bool onScriptChangeScope(ScScript *script, ScValue *scope); + bool onScriptShutdownScope(ScScript *script, ScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName); + bool onVariableChangeValue(ScValue *var, ScValue *value); + + bool onScriptHitBreakpoint(ScScript *script); // IWmeDebugServer interface virtual bool attachClient(IWmeDebugClient *client); diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 7453838219..8d6f88c9fe 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy): BaseClass(inGame) { _buffer = NULL; _size = 0; _realSize = 0; @@ -46,13 +46,13 @@ CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase ////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { +BaseDynamicBuffer::~BaseDynamicBuffer() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::cleanup() { +void BaseDynamicBuffer::cleanup() { if (_buffer) free(_buffer); _buffer = NULL; _size = 0; @@ -63,20 +63,20 @@ void CBDynBuffer::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getSize() { +uint32 BaseDynamicBuffer::getSize() { return _size; } ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::init(uint32 initSize) { +bool BaseDynamicBuffer::init(uint32 initSize) { cleanup(); if (initSize == 0) initSize = _initSize; _buffer = (byte *)malloc(initSize); if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + _gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); return STATUS_FAILED; } @@ -88,14 +88,14 @@ bool CBDynBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { if (!_initialized) init(); while (_offset + size > _realSize) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + _gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return STATUS_FAILED; } } @@ -109,11 +109,11 @@ bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { if (!_initialized) init(); if (_offset + size > _size) { - _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); return STATUS_FAILED; } @@ -125,13 +125,13 @@ bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putDWORD(uint32 val) { +void BaseDynamicBuffer::putDWORD(uint32 val) { putBytes((byte *)&val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getDWORD() { +uint32 BaseDynamicBuffer::getDWORD() { uint32 ret; getBytes((byte *)&ret, sizeof(uint32)); return ret; @@ -139,7 +139,7 @@ uint32 CBDynBuffer::getDWORD() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putString(const char *val) { +void BaseDynamicBuffer::putString(const char *val) { if (!val) putString("(null)"); else { putDWORD(strlen(val) + 1); @@ -149,7 +149,7 @@ void CBDynBuffer::putString(const char *val) { ////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::getString() { +char *BaseDynamicBuffer::getString() { uint32 len = getDWORD(); char *ret = (char *)(_buffer + _offset); _offset += len; @@ -160,7 +160,7 @@ char *CBDynBuffer::getString() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(const char *fmt, ...) { +void BaseDynamicBuffer::putText(const char *fmt, ...) { va_list va; va_start(va, fmt); @@ -171,7 +171,7 @@ void CBDynBuffer::putText(const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { +void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { va_list va; putText("%*s", indent, ""); @@ -183,7 +183,7 @@ void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextForm(const char *format, va_list argptr) { +void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { char buff[32768]; vsprintf(buff, format, argptr); putBytes((byte *)buff, strlen(buff)); diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 5795fe5bd1..0567f874df 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBDynBuffer : public CBBase { +class BaseDynamicBuffer : public BaseClass { public: bool _initialized; void putText(const char *fmt, ...); @@ -50,8 +50,8 @@ public: void cleanup(); uint32 _size; byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~CBDynBuffer(); + BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~BaseDynamicBuffer(); private: uint32 _realSize; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index b34e89e41a..4dcdf82347 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -38,10 +38,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFader, false) +IMPLEMENT_PERSISTENT(BaseFader, false) ////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { +BaseFader::BaseFader(BaseGame *inGame): BaseObject(inGame) { _active = false; _red = _green = _blue = 0; _currentAlpha = 0x00; @@ -54,20 +54,20 @@ CBFader::CBFader(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { +BaseFader::~BaseFader() { } ////////////////////////////////////////////////////////////////////////// -bool CBFader::update() { +bool BaseFader::update() { if (!_active) return STATUS_OK; int alphaDelta = _targetAlpha - _sourceAlpha; uint32 time; - if (_system) time = CBPlatform::getTime() - _startTime; + if (_system) time = BasePlatform::getTime() - _startTime; else time = _gameRef->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; @@ -84,7 +84,7 @@ bool CBFader::update() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::display() { +bool BaseFader::display() { if (!_active) return STATUS_OK; if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); @@ -93,7 +93,7 @@ bool CBFader::display() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::deactivate() { +bool BaseFader::deactivate() { _active = false; _ready = true; return STATUS_OK; @@ -101,7 +101,7 @@ bool CBFader::deactivate() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { +bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -115,7 +115,7 @@ bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::getTime(); + if (_system) _startTime = BasePlatform::getTime(); else _startTime = _gameRef->_timer; return STATUS_OK; @@ -123,7 +123,7 @@ bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { ////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { +bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -138,7 +138,7 @@ bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::getTime(); + if (_system) _startTime = BasePlatform::getTime(); else _startTime = _gameRef->_timer; @@ -147,15 +147,15 @@ bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { ////////////////////////////////////////////////////////////////////////// -uint32 CBFader::getCurrentColor() { +uint32 BaseFader::getCurrentColor() { return BYTETORGBA(_red, _green, _blue, _currentAlpha); } ////////////////////////////////////////////////////////////////////////// -bool CBFader::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool BaseFader::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_blue)); diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 679f5d0903..36dd8a1d53 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBFader : public CBObject { +class BaseFader : public BaseObject { public: bool _system; uint32 getCurrentColor(); @@ -43,9 +43,9 @@ public: bool deactivate(); bool display(); bool update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); + DECLARE_PERSISTENT(BaseFader, BaseObject) + BaseFader(BaseGame *inGame); + virtual ~BaseFader(); bool _active; byte _red; byte _green; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1cb0464a1f..a2c81b8a8c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -58,7 +58,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { +BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { _basePath = NULL; initPaths(); @@ -67,13 +67,13 @@ CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { +BaseFileManager::~BaseFileManager() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::cleanup() { +bool BaseFileManager::cleanup() { // delete registered paths for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; @@ -114,7 +114,7 @@ bool CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { +byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; Common::SeekableReadStream *file = openFile(filename); @@ -153,14 +153,14 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, return buffer; } -Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { +Common::SeekableReadStream *BaseFileManager::loadSaveGame(const Common::String &filename) { Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); Common::InSaveFile *file = saveMan->openForLoading(filename); return file; } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { +bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { // TODO warning("Implement SaveFile"); @@ -173,7 +173,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 #if 0 RestoreCurrentDir(); - CBUtils::CreatePath(filename, false); + BaseUtils::CreatePath(filename, false); FILE *f = fopen(filename, "wb"); if (!f) { @@ -223,7 +223,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { +bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (uint32 i = 0; i < _packages.size(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); @@ -235,7 +235,7 @@ bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::addPath(TPathType type, const Common::String &path) { +bool BaseFileManager::addPath(TPathType type, const Common::String &path) { if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); @@ -245,7 +245,7 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { strcpy(buffer, path.c_str()); if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); + //BasePlatform::strlwr(buffer); switch (type) { case PATH_SINGLE: @@ -260,7 +260,7 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::reloadPaths() { +bool BaseFileManager::reloadPaths() { // delete registered paths for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; @@ -276,7 +276,7 @@ bool CBFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::initPaths() { +bool BaseFileManager::initPaths() { restoreCurrentDir(); AnsiString pathList; @@ -284,10 +284,10 @@ bool CBFileManager::initPaths() { // single files paths pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_SINGLE, path); } @@ -301,10 +301,10 @@ bool CBFileManager::initPaths() { addPath(PATH_PACKAGE, "./"); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_PACKAGE, path); } @@ -318,7 +318,7 @@ bool CBFileManager::initPaths() { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackages() { +bool BaseFileManager::registerPackages() { restoreCurrentDir(); _gameRef->LOG(0, "Scanning packages..."); @@ -365,7 +365,7 @@ bool CBFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { // FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); @@ -411,7 +411,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(_gameRef); + BasePackage *pkg = new BasePackage(_gameRef); if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; @@ -450,7 +450,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search name[nameLength - 1] = '\0'; - CBPlatform::strupr(name); + BasePlatform::strupr(name); offset = package->readUint32LE(); offset += absoluteOffset; @@ -464,7 +464,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } _filesIter = _files.find(name); if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(_gameRef); + BaseFileEntry *file = new BaseFileEntry(_gameRef); file->_package = pkg; file->_offset = offset; file->_length = length; @@ -492,7 +492,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::isValidPackage(const AnsiString &fileName) const { +bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); // check for device-type specific packages @@ -503,7 +503,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &name) { +Common::File *BaseFileManager::openPackage(const Common::String &name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -524,14 +524,14 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { if (ret->isOpen()) { return ret; } - warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &name) { +Common::File *BaseFileManager::openSingleFile(const Common::String &name) { restoreCurrentDir(); Common::File *ret = NULL; @@ -556,7 +556,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { +bool BaseFileManager::getFullPath(const Common::String &filename, char *fullname) { restoreCurrentDir(); Common::File f; @@ -586,12 +586,12 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) ////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { +BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { char *upc_name = new char[strlen(filename.c_str()) + 1]; strcpy(upc_name, filename.c_str()); - CBPlatform::strupr(upc_name); + BasePlatform::strupr(upc_name); - CBFileEntry *ret = NULL; + BaseFileEntry *ret = NULL; _filesIter = _files.find(upc_name); if (_filesIter != _files.end()) ret = _filesIter->_value; @@ -600,7 +600,7 @@ CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { return ret; } -bool CBFileManager::hasFile(const Common::String &filename) { +bool BaseFileManager::hasFile(const Common::String &filename) { //TODO: Do this in a much simpler fashion Common::SeekableReadStream *stream = openFile(filename, true, false); if (!stream) { @@ -611,7 +611,7 @@ bool CBFileManager::hasFile(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { +Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; //_gameRef->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ @@ -631,7 +631,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::closeFile(Common::SeekableReadStream *File) { +bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { for (uint32 i = 0; i < _openFiles.size(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; @@ -644,13 +644,13 @@ bool CBFileManager::closeFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { +Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { restoreCurrentDir(); Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); } @@ -666,7 +666,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ret = openPkgFile(filename, this); if (ret) return ret; - ret = CBResources::getFile(filename); + ret = BaseResources::getFile(filename); if (ret) return ret; warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); @@ -675,19 +675,19 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::restoreCurrentDir() { +bool BaseFileManager::restoreCurrentDir() { if (!_basePath) return STATUS_OK; else { /*if (!chdir(_basePath)) return STATUS_OK; else return STATUS_FAILED;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); + warning("BaseFileManager::RestoreCurrentDir - ignored"); return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::setBasePath(const Common::String &path) { +bool BaseFileManager::setBasePath(const Common::String &path) { cleanup(); if (path.c_str()) { @@ -703,7 +703,7 @@ bool CBFileManager::setBasePath(const Common::String &path) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { +bool BaseFileManager::findPackageSignature(Common::File *f, uint32 *offset) { byte buf[32768]; byte signature[8]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 1bf3156ebe..469108bee8 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -38,8 +38,8 @@ class File; } namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { +class BaseFile; +class BaseFileManager: BaseClass { public: bool findPackageSignature(Common::File *f, uint32 *offset); bool cleanup(); @@ -51,7 +51,7 @@ public: bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *getPackageEntry(const Common::String &filename); + BaseFileEntry *getPackageEntry(const Common::String &filename); Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); bool registerPackages(); @@ -65,17 +65,17 @@ public: Common::SeekableReadStream *loadSaveGame(const Common::String &filename); bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); + BaseFileManager(BaseGame *inGame = NULL); + virtual ~BaseFileManager(); Common::Array _singlePaths; Common::Array _packagePaths; - Common::Array _packages; + Common::Array _packages; Common::Array _openFiles; - Common::HashMap _files; + Common::HashMap _files; private: bool registerPackage(const Common::String &filename, bool searchSignature = false); - Common::HashMap::iterator _filesIter; + Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; }; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 468ad29858..2a729a882a 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -42,10 +42,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBFrame, false) +IMPLEMENT_PERSISTENT(BaseFrame, false) ////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { +BaseFrame::BaseFrame(BaseGame *inGame): BaseScriptable(inGame, true) { _delay = 0; _moveX = _moveY = 0; @@ -58,7 +58,7 @@ CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { +BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; @@ -75,7 +75,7 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { +bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { bool res; for (int i = 0; i < _subframes.getSize(); i++) { @@ -87,7 +87,7 @@ bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoo ////////////////////////////////////////////////////////////////////////// -bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { +bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { if (_sound && !muted) { if (owner) owner->updateOneSound(_sound); _sound->play(); @@ -131,7 +131,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -158,7 +158,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -170,7 +170,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { bool decoration = false; bool mirrorX = false; bool mirrorY = false; - CBPlatform::setRectEmpty(&rect); + BasePlatform::setRectEmpty(&rect); char *surface_file = NULL; while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { @@ -237,7 +237,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(_gameRef); + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; @@ -250,7 +250,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { delete _sound; _sound = NULL; } - _sound = new CBSound(_gameRef); + _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); delete _sound; @@ -290,7 +290,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (surface_file != NULL) { if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); @@ -305,7 +305,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); } - if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + if (BasePlatform::isRectEmpty(&rect)) sub->setDefaultRect(); else sub->_rect = rect; sub->_hotspotX = hotspotX; @@ -325,15 +325,15 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::setRectEmpty(rect); + BasePlatform::setRectEmpty(rect); Rect32 subRect; for (int i = 0; i < _subframes.getSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, rect, &subRect); + BasePlatform::unionRect(rect, rect, &subRect); } return true; } @@ -341,7 +341,7 @@ bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float sc ////////////////////////////////////////////////////////////////////////// -bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); @@ -369,7 +369,7 @@ bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n\n"); @@ -379,8 +379,8 @@ bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool BaseFrame::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); _applyEvent.persist(persistMgr); persistMgr->transfer(TMEMBER(_delay)); @@ -399,7 +399,7 @@ bool CBFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -417,12 +417,12 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSound") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); delete _sound; _sound = NULL; if (!val->isNULL()) { - _sound = new CBSound(_gameRef); + _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { stack->pushBool(false); delete _sound; @@ -451,14 +451,14 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteSubframe") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { - CBSubFrame *sub = (CBSubFrame *)val->getNative(); + BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); for (int i = 0; i < _subframes.getSize(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; @@ -476,11 +476,11 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSubframe") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); sub->setDefaultRect(); @@ -499,11 +499,11 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta int index = stack->pop()->getInt(); if (index < 0) index = 0; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); } @@ -565,14 +565,14 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } } ////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); +ScValue *BaseFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new ScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -642,13 +642,13 @@ CScValue *CBFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } } ////////////////////////////////////////////////////////////////////////// -bool CBFrame::scSetProperty(const char *name, CScValue *value) { +bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// @@ -692,13 +692,13 @@ bool CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return CBScriptable::scSetProperty(name, value); + else return BaseScriptable::scSetProperty(name, value); } } ////////////////////////////////////////////////////////////////////////// -const char *CBFrame::scToString() { +const char *BaseFrame::scToString() { return "[frame]"; } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index f3dec4e16f..dcbf74bc47 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -33,37 +33,37 @@ #include "engines/wintermute/coll_templ.h" namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { +class BaseSound; +class BaseSubFrame; +class BaseObject; +class ScScript; +class ScStack; +class BaseFrame: public BaseScriptable { public: bool _killSound; bool _keyframe; - bool oneTimeDisplay(CBObject *owner, bool muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; + bool oneTimeDisplay(BaseObject *owner, bool muted = false); + DECLARE_PERSISTENT(BaseFrame, BaseScriptable) + BaseSound *_sound; bool _editorExpanded; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(CBDynBuffer *buffer, int indent); + bool saveAsText(BaseDynamicBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; - CBArray _subframes; - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + BaseArray _subframes; + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - CBFrame(CBGame *inGame); - virtual ~CBFrame(); + BaseFrame(BaseGame *inGame); + virtual ~BaseFrame(); - CBArray _applyEvent; + BaseArray _applyEvent; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 00c852e02d..0adc938895 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -74,11 +74,11 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBGame, true) +IMPLEMENT_PERSISTENT(BaseGame, true) ////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { +BaseGame::BaseGame(): BaseObject(this) { _shuttingDown = false; _state = GAME_RUNNING; @@ -143,8 +143,8 @@ CBGame::CBGame(): CBObject(this) { _useD3D = false; - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); + _registry = new BaseRegistry(this); + _stringTable = new BaseStringTable(this); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { _music[i] = NULL; @@ -205,7 +205,7 @@ CBGame::CBGame(): CBObject(this) { _indicatorHeight = 8; _richSavedGames = false; _savedGameExt = NULL; - CBUtils::setString(&_savedGameExt, "dsv"); + BaseUtils::setString(&_savedGameExt, "dsv"); _musicCrossfadeRunning = false; _musicCrossfadeStartTime = 0; @@ -222,7 +222,7 @@ CBGame::CBGame(): CBObject(this) { _loadImageX = _loadImageY = 0; _localSaveDir = NULL; - CBUtils::setString(&_localSaveDir, "saves"); + BaseUtils::setString(&_localSaveDir, "saves"); _saveDirChecked = false; _loadingIcon = NULL; @@ -238,7 +238,7 @@ CBGame::CBGame(): CBObject(this) { _lastCursor = NULL; - CBPlatform::setRectEmpty(&_mouseLockRect); + BasePlatform::setRectEmpty(&_mouseLockRect); _suppressScriptErrors = false; _lastMiniUpdate = 0; @@ -270,7 +270,7 @@ CBGame::CBGame(): CBObject(this) { ////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { +BaseGame::~BaseGame() { _shuttingDown = true; LOG(0, ""); @@ -330,12 +330,12 @@ CBGame::~CBGame() { _stringTable = NULL; DEBUG_DebugDisable(); - CBPlatform::outputDebugString("--- shutting down normally ---\n"); + BasePlatform::outputDebugString("--- shutting down normally ---\n"); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::cleanup() { +bool BaseGame::cleanup() { delete _loadingIcon; _loadingIcon = NULL; @@ -414,50 +414,50 @@ bool CBGame::cleanup() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize1() { +bool BaseGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { - _surfaceStorage = new CBSurfaceStorage(this); + _surfaceStorage = new BaseSurfaceStorage(this); if (_surfaceStorage == NULL) break; - _fontStorage = new CBFontStorage(this); + _fontStorage = new BaseFontStorage(this); if (_fontStorage == NULL) break; - _fileManager = new CBFileManager(this); + _fileManager = new BaseFileManager(this); if (_fileManager == NULL) break; - _soundMgr = new CBSoundMgr(this); + _soundMgr = new BaseSoundMgr(this); if (_soundMgr == NULL) break; - _debugMgr = new CBDebugger(this); + _debugMgr = new BaseDebugger(this); if (_debugMgr == NULL) break; - _mathClass = new CSXMath(this); + _mathClass = new SXMath(this); if (_mathClass == NULL) break; - _scEngine = new CScEngine(this); + _scEngine = new ScEngine(this); if (_scEngine == NULL) break; - _videoPlayer = new CVidPlayer(this); + _videoPlayer = new VideoPlayer(this); if (_videoPlayer == NULL) break; - _transMgr = new CBTransitionMgr(this); + _transMgr = new BaseTransitionMgr(this); if (_transMgr == NULL) break; - _keyboardState = new CBKeyboardState(this); + _keyboardState = new BaseKeyboardState(this); if (_keyboardState == NULL) break; - _fader = new CBFader(this); + _fader = new BaseFader(this); if (_fader == NULL) break; registerObject(_fader); @@ -483,7 +483,7 @@ bool CBGame::initialize1() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize2() { // we know whether we are going to be accelerated +bool BaseGame::initialize2() { // we know whether we are going to be accelerated _renderer = makeOSystemRenderer(this); if (_renderer == NULL) return STATUS_FAILED; @@ -492,7 +492,7 @@ bool CBGame::initialize2() { // we know whether we are going to be accelerated ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize3() { // renderer is initialized +bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; @@ -505,7 +505,7 @@ bool CBGame::initialize3() { // renderer is initialized ////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *filename) { +void BaseGame::DEBUG_DebugEnable(const char *filename) { _debugDebugMode = true; /* time_t timeNow; @@ -532,14 +532,14 @@ void CBGame::DEBUG_DebugEnable(const char *filename) { LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - AnsiString platform = CBPlatform::getPlatformName(); + AnsiString platform = BasePlatform::getPlatformName(); LOG(0, "Platform: %s", platform.c_str()); LOG(0, ""); } ////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { +void BaseGame::DEBUG_DebugDisable() { if (_debugLogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); //fclose((FILE *)_debugLogFile); @@ -550,7 +550,7 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// -void CBGame::LOG(bool res, const char *fmt, ...) { +void BaseGame::LOG(bool res, const char *fmt, ...) { uint32 secs = g_system->getMillis() / 1000; uint32 hours = secs / 3600; secs = secs % 3600; @@ -580,17 +580,17 @@ void CBGame::LOG(bool res, const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { +void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { _engineLogCallback = callback; _engineLogCallbackData = data; } ////////////////////////////////////////////////////////////////////// -bool CBGame::initLoop() { +bool BaseGame::initLoop() { _viewportSP = -1; - _currentTime = CBPlatform::getTime(); + _currentTime = BasePlatform::getTime(); getDebugMgr()->onGameTick(); _renderer->initLoop(); @@ -645,35 +645,35 @@ bool CBGame::initLoop() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initInput() { +bool BaseGame::initInput() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CBGame::getSequence() { +int BaseGame::getSequence() { return ++_sequence; } ////////////////////////////////////////////////////////////////////////// -void CBGame::setOffset(int offsetX, int offsetY) { +void BaseGame::setOffset(int offsetX, int offsetY) { _offsetX = offsetX; _offsetY = offsetY; } ////////////////////////////////////////////////////////////////////////// -void CBGame::getOffset(int *offsetX, int *offsetY) { +void BaseGame::getOffset(int *offsetX, int *offsetY) { if (offsetX != NULL) *offsetX = _offsetX; if (offsetY != NULL) *offsetY = _offsetY; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadFile(const char *filename) { +bool BaseGame::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -740,7 +740,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadBuffer(byte *buffer, bool complete) { +bool BaseGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -778,7 +778,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { @@ -819,7 +819,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -830,7 +830,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ACTIVE_CURSOR: delete _activeCursor; _activeCursor = NULL; - _activeCursor = new CBSprite(_gameRef); + _activeCursor = new BaseSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { delete _activeCursor; _activeCursor = NULL; @@ -840,7 +840,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(_gameRef); + _cursorNoninteractive = new BaseSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -908,7 +908,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SAVE_IMAGE: - CBUtils::setString(&_saveImageName, (char *)params); + BaseUtils::setString(&_saveImageName, (char *)params); break; case TOKEN_SAVE_IMAGE_X: @@ -920,7 +920,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOAD_IMAGE: - CBUtils::setString(&_loadImageName, (char *)params); + BaseUtils::setString(&_loadImageName, (char *)params); break; case TOKEN_LOAD_IMAGE_X: @@ -932,7 +932,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOCAL_SAVE_DIR: - CBUtils::setString(&_localSaveDir, (char *)params); + BaseUtils::setString(&_localSaveDir, (char *)params); break; case TOKEN_COMPAT_KILL_METHOD_THREADS: @@ -960,7 +960,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -975,7 +975,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - bool res = CBObject::scCallMethod(script, stack, thisStack, name); + bool res = BaseObject::scCallMethod(script, stack, thisStack, name); setWindowTitle(); return res; } @@ -1010,7 +1010,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "LoadStringTable") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); bool ClearOld; if (Val->isNULL()) ClearOld = true; @@ -1029,8 +1029,8 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *) obj)) stack->pushBool(true); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *) obj)) stack->pushBool(true); else stack->pushBool(false); return STATUS_OK; @@ -1053,8 +1053,8 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->getNative(); + ScValue *val = stack->pop(); + BaseObject *obj = (BaseObject *)val->getNative(); unregisterObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); @@ -1067,7 +1067,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadWindow") == 0) { stack->correctParams(1); - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { _windows.add(win); registerObject(win); @@ -1085,7 +1085,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExpandString") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); char *str = new char[strlen(val->getString()) + 1]; strcpy(str, val->getString()); _stringTable->expand(&str); @@ -1106,10 +1106,10 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac } const char *filename = stack->pop()->getString(); - CScValue *valLooping = stack->pop(); + ScValue *valLooping = stack->pop(); bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - CScValue *valLoopStart = stack->pop(); + ScValue *valLoopStart = stack->pop(); uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); @@ -1311,7 +1311,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int length = 0; const char *filename = stack->pop()->getString(); - CBSound *sound = new CBSound(_gameRef); + BaseSound *sound = new BaseSound(_gameRef); if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { length = sound->getLength(); delete sound; @@ -1336,7 +1336,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; - CBPlatform::setCursorPos(p.x, p.y); + BasePlatform::setCursorPos(p.x, p.y); stack->pushNULL(); return STATUS_OK; @@ -1352,10 +1352,10 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int right = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - if (right < left) CBUtils::swap(&left, &right); - if (bottom < top) CBUtils::swap(&top, &bottom); + if (right < left) BaseUtils::swap(&left, &right); + if (bottom < top) BaseUtils::swap(&top, &bottom); - CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); stack->pushNULL(); return STATUS_OK; @@ -1377,7 +1377,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(6); const char *filename = stack->pop()->getString(); warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->pop(); + ScValue *valType = stack->pop(); int Type; if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->getInt(); @@ -1386,7 +1386,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int yVal = stack->pop()->getInt(); bool FreezeMusic = stack->pop()->getBool(true); - CScValue *valSub = stack->pop(); + ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) @@ -1414,7 +1414,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(7); const char *filename = stack->pop()->getString(); - CScValue *valType = stack->pop(); + ScValue *valType = stack->pop(); int type; if (valType->isNULL()) type = (int)VID_PLAY_STRETCH; @@ -1425,13 +1425,13 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac bool freezeMusic = stack->pop()->getBool(true); bool dropFrames = stack->pop()->getBool(true); - CScValue *valSub = stack->pop(); + ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; delete _theoraPlayer; - _theoraPlayer = new CVidTheoraPlayer(this); + _theoraPlayer = new VideoTheoraPlayer(this); if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !dropFrames; if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { @@ -1776,7 +1776,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(1); char filename[MAX_PATH_LENGTH]; - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int fileNum = 0; @@ -1789,7 +1789,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac } bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); + BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; @@ -1809,7 +1809,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int sizeY = stack->pop()->getInt(_renderer->_height); bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); + BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->resize(sizeX, sizeY)); if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); @@ -1825,9 +1825,9 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); _windows.add(win); registerObject(win); if (!val->isNULL()) win->setName(val->getString()); @@ -1840,7 +1840,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); - CBObject *obj = (CBObject *)stack->pop()->getNative(); + BaseObject *obj = (BaseObject *)stack->pop()->getNative(); for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == obj) { unregisterObject(_windows[i]); @@ -1876,7 +1876,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); _loadImageX = stack->pop()->getInt(); _loadImageY = stack->pop()->getInt(); @@ -1884,7 +1884,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::setString(&_loadImageName, val->getString()); + BaseUtils::setString(&_loadImageName, val->getString()); } stack->pushNULL(); return STATUS_OK; @@ -1895,7 +1895,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); _saveImageX = stack->pop()->getInt(); _saveImageY = stack->pop()->getInt(); @@ -1903,7 +1903,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac delete[] _saveImageName; _saveImageName = NULL; } else { - CBUtils::setString(&_saveImageName, val->getString()); + BaseUtils::setString(&_saveImageName, val->getString()); } stack->pushNULL(); return STATUS_OK; @@ -1976,7 +1976,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac _loadingIconPersistent = stack->pop()->getBool(); delete _loadingIcon; - _loadingIcon = new CBSprite(this); + _loadingIcon = new BaseSprite(this); if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { delete _loadingIcon; _loadingIcon = NULL; @@ -2035,7 +2035,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "StoreSaveThumbnail") == 0) { stack->correctParams(0); delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); + _cachedThumbnail = new BaseSaveThumbHelper(this); if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; @@ -2143,12 +2143,12 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *name) { +ScValue *BaseGame::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -2185,7 +2185,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::getTime()); + _scValue->setInt((int)BasePlatform::getTime()); return _scValue; } @@ -2504,7 +2504,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Platform (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::getPlatformName().c_str()); + _scValue->setString(BasePlatform::getPlatformName().c_str()); return _scValue; } @@ -2534,12 +2534,12 @@ CScValue *CBGame::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::scSetProperty(const char *name, CScValue *value) { +bool BaseGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -2571,7 +2571,7 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - bool res = CBObject::scSetProperty(name, value); + bool res = BaseObject::scSetProperty(name, value); setWindowTitle(); return res; } @@ -2580,8 +2580,8 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->getNative(); - if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + BaseScriptable *obj = value->getNative(); + if (obj == NULL || validObject((BaseObject *)obj)) _mainObject = (BaseObject *)obj; return STATUS_OK; } @@ -2729,12 +2729,12 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBGame::scToString() { +const char *BaseGame::scToString() { return "[game object]"; } @@ -2742,7 +2742,7 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayQuickMsg() { +bool BaseGame::displayQuickMsg() { if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; // update @@ -2767,17 +2767,17 @@ bool CBGame::displayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessage(const char *text) { +void BaseGame::quickMessage(const char *text) { if (_quickMessages.getSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.removeAt(0); } - _quickMessages.add(new CBQuickMsg(_gameRef, text)); + _quickMessages.add(new BaseQuickMsg(_gameRef, text)); } ////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(char *fmt, ...) { +void BaseGame::quickMessageForm(char *fmt, ...) { char buff[256]; va_list va; @@ -2790,19 +2790,19 @@ void CBGame::quickMessageForm(char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::registerObject(CBObject *object) { +bool BaseGame::registerObject(BaseObject *object) { _regObjects.add(object); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::unregisterObject(CBObject *object) { +bool BaseGame::unregisterObject(BaseObject *object) { if (!object) return STATUS_OK; // is it a window? for (int i = 0; i < _windows.getSize(); i++) { - if ((CBObject *)_windows[i] == object) { + if ((BaseObject *)_windows[i] == object) { _windows.removeAt(i); // get new focused window @@ -2822,7 +2822,7 @@ bool CBGame::unregisterObject(CBObject *object) { for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { _regObjects.removeAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + if (!_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); delete object; return STATUS_OK; } @@ -2833,11 +2833,11 @@ bool CBGame::unregisterObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -void CBGame::invalidateValues(void *value, void *data) { - CScValue *val = (CScValue *)value; +void BaseGame::invalidateValues(void *value, void *data) { + ScValue *val = (ScValue *)value; if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { - ((CBScriptable *)data)->_refCount++; + if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { + ((BaseScriptable *)data)->_refCount++; } val->setNative(NULL); val->setNULL(); @@ -2847,7 +2847,7 @@ void CBGame::invalidateValues(void *value, void *data) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::validObject(CBObject *object) { +bool BaseGame::validObject(BaseObject *object) { if (!object) return false; if (object == this) return true; @@ -2859,8 +2859,8 @@ bool CBGame::validObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *thisObj; +bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// // LOG @@ -2947,8 +2947,8 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "WaitFor") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *)obj)) script->waitForExclusive((BaseObject *)obj); stack->pushNULL(); } @@ -2961,7 +2961,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int from = stack->pop()->getInt(); int to = stack->pop()->getInt(); - stack->pushInt(CBUtils::randomInt(from, to)); + stack->pushInt(BaseUtils::randomInt(from, to)); } ////////////////////////////////////////////////////////////////////////// @@ -2983,7 +2983,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int g = stack->pop()->getInt(); int b = stack->pop()->getInt(); int a; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isNULL()) a = 255; else a = val->getInt(); @@ -2999,7 +2999,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int s = stack->pop()->getInt(); int l = stack->pop()->getInt(); - stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + stack->pushInt(BaseUtils::HSLtoRGB(h, s, l)); } ////////////////////////////////////////////////////////////////////////// @@ -3050,7 +3050,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(H); } @@ -3062,7 +3062,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(S); } @@ -3074,7 +3074,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(L); } @@ -3143,7 +3143,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// -bool CBGame::showCursor() { +bool BaseGame::showCursor() { if (_cursorHidden) return STATUS_OK; if (!_interactive && _gameRef->_state == GAME_RUNNING) { @@ -3160,7 +3160,7 @@ bool CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { +bool BaseGame::SaveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -3172,7 +3172,7 @@ bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; if (!quickSave) { @@ -3188,8 +3188,8 @@ bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { } } - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3206,8 +3206,8 @@ save_finish: // TODO: Remove gotos ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); +bool BaseGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); _loading = false; _scheduledLoadSlot = -1; @@ -3220,7 +3220,7 @@ bool CBGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(const char *filename) { +bool BaseGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); getDebugMgr()->onGameShutdown(); @@ -3241,13 +3241,13 @@ bool CBGame::loadGame(const char *filename) { _loadInProgress = true; _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); _debugAbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; // data initialization after load initAfterLoad(); @@ -3269,19 +3269,19 @@ load_finish: delete _saveLoadImage; _saveLoadImage = NULL; - //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); return ret; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::initAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); +bool BaseGame::initAfterLoad() { + SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); _scEngine->refreshScriptBreakpoints(); @@ -3289,35 +3289,35 @@ bool CBGame::initAfterLoad() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->createRegion(); +void BaseGame::afterLoadRegion(void *region, void *data) { + ((BaseRegion *)region)->createRegion(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSubFrame(void *subframe, void *data) { - ((CBSubFrame *)subframe)->setSurfaceSimple(); +void BaseGame::afterLoadSubFrame(void *subframe, void *data) { + ((BaseSubFrame *)subframe)->setSurfaceSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSound(void *sound, void *data) { - ((CBSound *)sound)->setSoundSimple(); +void BaseGame::afterLoadSound(void *sound, void *data) { + ((BaseSound *)sound)->setSoundSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadFont(void *font, void *data) { - ((CBFont *)font)->afterLoad(); +void BaseGame::afterLoadFont(void *font, void *data) { + ((BaseFont *)font)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadScript(void *script, void *data) { - ((CScScript *)script)->afterLoad(); +void BaseGame::afterLoadScript(void *script, void *data) { + ((ScScript *)script)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayWindows(bool inGame) { +bool BaseGame::displayWindows(bool inGame) { bool res; // did we lose focus? focus topmost window @@ -3345,7 +3345,7 @@ bool CBGame::displayWindows(bool inGame) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { +bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3354,7 +3354,7 @@ bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 l delete _music[channel]; _music[channel] = NULL; - _music[channel] = new CBSound(_gameRef); + _music[channel] = new BaseSound(_gameRef); if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { if (_musicStartTime[channel]) { _music[channel]->setPositionTime(_musicStartTime[channel]); @@ -3371,7 +3371,7 @@ bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 l ////////////////////////////////////////////////////////////////////////// -bool CBGame::stopMusic(int channel) { +bool BaseGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3387,7 +3387,7 @@ bool CBGame::stopMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::pauseMusic(int channel) { +bool BaseGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3399,7 +3399,7 @@ bool CBGame::pauseMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::resumeMusic(int channel) { +bool BaseGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3411,7 +3411,7 @@ bool CBGame::resumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::setMusicStartTime(int channel, uint32 time) { +bool BaseGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3424,7 +3424,7 @@ bool CBGame::setMusicStartTime(int channel, uint32 time) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadSettings(const char *filename) { +bool BaseGame::loadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3447,7 +3447,7 @@ bool CBGame::loadSettings(const char *filename) { byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); if (origBuffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; } @@ -3456,7 +3456,7 @@ bool CBGame::loadSettings(const char *filename) { byte *buffer = origBuffer; byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); @@ -3520,7 +3520,7 @@ bool CBGame::loadSettings(const char *filename) { break; case TOKEN_SAVED_GAME_EXT: - CBUtils::setString(&_savedGameExt, (char *)params); + BaseUtils::setString(&_savedGameExt, (char *)params); break; case TOKEN_GUID: @@ -3547,11 +3547,11 @@ bool CBGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::persist(CBPersistMgr *persistMgr) { +bool BaseGame::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(); - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_activeObject)); persistMgr->transfer(TMEMBER(_capturedObject)); @@ -3640,8 +3640,8 @@ bool CBGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::focusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; +bool BaseGame::focusWindow(UIWindow *Window) { + UIWindow *Prev = _focusedWindow; for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == Window) { @@ -3662,7 +3662,7 @@ bool CBGame::focusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::freeze(bool includingMusic) { +bool BaseGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { _scEngine->pauseAll(); _soundMgr->pauseAll(includingMusic); @@ -3678,7 +3678,7 @@ bool CBGame::freeze(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::unfreeze() { +bool BaseGame::unfreeze() { if (_freezeLevel == 0) return STATUS_OK; _freezeLevel--; @@ -3694,7 +3694,7 @@ bool CBGame::unfreeze() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::handleKeypress(Common::Event *event, bool printable) { +bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (isVideoPlaying()) { if (event->kbd.keycode == Common::KEYCODE_ESCAPE) stopVideo(); @@ -3735,13 +3735,13 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { return false; } -void CBGame::handleKeyRelease(Common::Event *event) { +void BaseGame::handleKeyRelease(Common::Event *event) { _keyboardState->handleKeyRelease(event); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::handleMouseWheel(int Delta) { +bool BaseGame::handleMouseWheel(int Delta) { bool handled = false; if (_focusedWindow) { handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); @@ -3771,7 +3771,7 @@ bool CBGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { if (verMajor) *verMajor = DCGF_VER_MAJOR; if (verMinor) *verMinor = DCGF_VER_MINOR; @@ -3783,7 +3783,7 @@ bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex ////////////////////////////////////////////////////////////////////////// -void CBGame::setWindowTitle() { +void BaseGame::setWindowTitle() { if (_renderer) { char title[512]; strcpy(title, _caption[0]); @@ -3795,13 +3795,13 @@ void CBGame::setWindowTitle() { if (_textEncoding == TEXT_UTF8) { utf8Title = Utf8String(title); } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); + warning("BaseGame::SetWindowTitle -Ignoring textencoding"); utf8Title = Utf8String(title); /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } #if 0 - CBRenderOSystem *renderer = static_cast(_renderer); + BaseRenderOSystem *renderer = static_cast(_renderer); // TODO SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); @@ -3811,10 +3811,10 @@ void CBGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotFilename(int slot, char *buffer) { +bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String filename = pm->getFilenameForSlot(slot); delete pm; strcpy(buffer, filename.c_str()); @@ -3823,7 +3823,7 @@ bool CBGame::getSaveSlotFilename(int slot, char *buffer) { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDataDir() { +AnsiString BaseGame::getDataDir() { AnsiString userDir = PathUtil::getUserDirectory(); AnsiString baseDir = _registry->getBasePath(); return PathUtil::combine(userDir, baseDir); @@ -3831,12 +3831,12 @@ AnsiString CBGame::getDataDir() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotDescription(int slot, char *buffer) { +bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; _debugAbsolutePathWarning = false; @@ -3855,11 +3855,11 @@ bool CBGame::getSaveSlotDescription(int slot, char *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::isSaveSlotUsed(int slot) { +bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); if (!File) return false; delete File; @@ -3868,10 +3868,10 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::emptySaveSlot(int slot) { +bool BaseGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(this); + BasePersistenceManager *pm = new BasePersistenceManager(this); g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return STATUS_OK; @@ -3879,7 +3879,7 @@ bool CBGame::emptySaveSlot(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::setActiveObject(CBObject *obj) { +bool BaseGame::setActiveObject(BaseObject *obj) { // not-active when game is frozen if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { obj = NULL; @@ -3899,7 +3899,7 @@ bool CBGame::setActiveObject(CBObject *obj) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::pushViewport(CBViewport *viewport) { +bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); else _viewportStack[_viewportSP] = viewport; @@ -3911,7 +3911,7 @@ bool CBGame::pushViewport(CBViewport *viewport) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::popViewport() { +bool BaseGame::popViewport() { _viewportSP--; if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); @@ -3926,14 +3926,14 @@ bool CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { +bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { - CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); if (custom) *custom = true; } else { - CBPlatform::setRect(rect, _renderer->_drawOffsetX, + BasePlatform::setRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); @@ -3946,7 +3946,7 @@ bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { +bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; @@ -3960,42 +3960,42 @@ bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { +bool BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -void CBGame::setInteractive(bool state) { +void BaseGame::setInteractive(bool state) { _interactive = state; if (_transMgr) _transMgr->_origInteractive = state; } ////////////////////////////////////////////////////////////////////////// -void CBGame::resetMousePos() { +void BaseGame::resetMousePos() { Common::Point p; p.x = _mousePos.x + _renderer->_drawOffsetX; p.y = _mousePos.y + _renderer->_drawOffsetY; - CBPlatform::setCursorPos(p.x, p.y); + BasePlatform::setCursorPos(p.x, p.y); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContent(bool doUpdate, bool displayAll) { +bool BaseGame::displayContent(bool doUpdate, bool displayAll) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContentSimple() { +bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); if (_indicatorDisplay) displayIndicator(); @@ -4005,10 +4005,10 @@ bool CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayIndicator() { +bool BaseGame::displayIndicator() { if (_saveLoadImage) { Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } @@ -4023,7 +4023,7 @@ bool CBGame::displayIndicator() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::updateMusicCrossfade() { +bool BaseGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) return STATUS_OK; @@ -4055,7 +4055,7 @@ bool CBGame::updateMusicCrossfade() { if (_musicCrossfadeSwap) { // swap channels - CBSound *dummy = _music[_musicCrossfadeChannel1]; + BaseSound *dummy = _music[_musicCrossfadeChannel1]; int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; @@ -4078,7 +4078,7 @@ bool CBGame::updateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::resetContent() { +bool BaseGame::resetContent() { _scEngine->clearGlobals(); //_timer = 0; //_liveTimer = 0; @@ -4087,12 +4087,12 @@ bool CBGame::resetContent() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { +void BaseGame::DEBUG_DumpClassRegistry() { warning("DEBUG_DumpClassRegistry - untested"); Common::DumpFile *f = new Common::DumpFile; f->open("zz_class_reg_dump.log"); - CSysClassRegistry::getInstance()->dumpClasses(f); + SystemClassRegistry::getInstance()->dumpClasses(f); f->close(); delete f; @@ -4101,7 +4101,7 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::invalidateDeviceObjects() { +bool BaseGame::invalidateDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->invalidateDeviceObjects(); } @@ -4110,7 +4110,7 @@ bool CBGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::restoreDeviceObjects() { +bool BaseGame::restoreDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->restoreDeviceObjects(); } @@ -4118,11 +4118,11 @@ bool CBGame::restoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::setWaitCursor(const char *filename) { +bool BaseGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; - _cursorNoninteractive = new CBSprite(_gameRef); + _cursorNoninteractive = new BaseSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -4131,14 +4131,14 @@ bool CBGame::setWaitCursor(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isVideoPlaying() { +bool BaseGame::isVideoPlaying() { if (_videoPlayer->isPlaying()) return true; if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; return false; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::stopVideo() { +bool BaseGame::stopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); @@ -4150,7 +4150,7 @@ bool CBGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::drawCursor(CBSprite *cursor) { +bool BaseGame::drawCursor(BaseSprite *cursor) { if (!cursor) return STATUS_FAILED; if (cursor != _lastCursor) { cursor->reset(); @@ -4162,7 +4162,7 @@ bool CBGame::drawCursor(CBSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -bool CBGame::onActivate(bool activate, bool refreshMouse) { +bool BaseGame::onActivate(bool activate, bool refreshMouse) { if (_shuttingDown || !_renderer) return STATUS_OK; _renderer->_active = activate; @@ -4180,7 +4180,7 @@ bool CBGame::onActivate(bool activate, bool refreshMouse) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDown() { +bool BaseGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); @@ -4192,16 +4192,16 @@ bool CBGame::onMouseLeftDown() { if (_activeObject != NULL) _capturedObject = _activeObject; _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); + BasePlatform::setCapture(/*_renderer->_window*/); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftUp() { +bool BaseGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - CBPlatform::releaseCapture(); + BasePlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; @@ -4215,7 +4215,7 @@ bool CBGame::onMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDblClick() { +bool BaseGame::onMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); @@ -4230,7 +4230,7 @@ bool CBGame::onMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDblClick() { +bool BaseGame::onMouseRightDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); @@ -4245,7 +4245,7 @@ bool CBGame::onMouseRightDblClick() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDown() { +bool BaseGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); @@ -4258,7 +4258,7 @@ bool CBGame::onMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightUp() { +bool BaseGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); @@ -4271,7 +4271,7 @@ bool CBGame::onMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleDown() { +bool BaseGame::onMouseMiddleDown() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); @@ -4286,7 +4286,7 @@ bool CBGame::onMouseMiddleDown() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleUp() { +bool BaseGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); @@ -4299,7 +4299,7 @@ bool CBGame::onMouseMiddleUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onPaint() { +bool BaseGame::onPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { _renderer->initLoop(); displayContent(false, true); @@ -4310,7 +4310,7 @@ bool CBGame::onPaint() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onWindowClose() { +bool BaseGame::onWindowClose() { if (canHandleEvent("QuitGame")) { if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); return STATUS_OK; @@ -4318,7 +4318,7 @@ bool CBGame::onWindowClose() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayDebugInfo() { +bool BaseGame::displayDebugInfo() { char str[100]; if (_debugShowFPS) { @@ -4359,15 +4359,15 @@ bool CBGame::displayDebugInfo() { } ////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); +BaseDebugger *BaseGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new BaseDebugger(this); return _debugMgr; } ////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Point32 *pos) { - CBPlatform::getCursorPos(pos); +void BaseGame::getMousePos(Point32 *pos) { + BasePlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; pos->y -= _renderer->_drawOffsetY; @@ -4386,7 +4386,7 @@ void CBGame::getMousePos(Point32 *pos) { */ if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + if (!BasePlatform::ptInRect(&_mouseLockRect, *pos)) { pos->x = MAX(_mouseLockRect.left, pos->x); pos->y = MAX(_mouseLockRect.top, pos->y); @@ -4398,52 +4398,52 @@ void CBGame::getMousePos(Point32 *pos) { newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; - CBPlatform::setCursorPos(newPos.x, newPos.y); + BasePlatform::setCursorPos(newPos.x, newPos.y); } } } ////////////////////////////////////////////////////////////////////////// -bool CBGame::miniUpdate() { +bool BaseGame::miniUpdate() { if (!_miniUpdateEnabled) return STATUS_OK; - if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (BasePlatform::getTime() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::getTime(); + _lastMiniUpdate = BasePlatform::getTime(); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onScriptShutdown(CScScript *script) { +bool BaseGame::onScriptShutdown(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isLeftDoubleClick() { +bool BaseGame::isLeftDoubleClick() { return isDoubleClick(0); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isRightDoubleClick() { +bool BaseGame::isRightDoubleClick() { return isDoubleClick(1); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isDoubleClick(int buttonIndex) { +bool BaseGame::isDoubleClick(int buttonIndex) { uint32 maxDoubleCLickTime = 500; int maxMoveX = 4; int maxMoveY = 4; Point32 pos; - CBPlatform::getCursorPos(&pos); + BasePlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].posX); int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = CBPlatform::getTime(); + if (_lastClick[buttonIndex].time == 0 || BasePlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = BasePlatform::getTime(); _lastClick[buttonIndex].posX = pos.x; _lastClick[buttonIndex].posY = pos.y; return false; @@ -4454,7 +4454,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { } ////////////////////////////////////////////////////////////////////////// -void CBGame::autoSaveOnExit() { +void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); _registry->saveValues(); @@ -4465,12 +4465,12 @@ void CBGame::autoSaveOnExit() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::addMem(int bytes) { +void BaseGame::addMem(int bytes) { _usedMem += bytes; } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDeviceType() const { +AnsiString BaseGame::getDeviceType() const { return "computer"; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 711eebfc98..77fa6b3a8b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -41,33 +41,33 @@ namespace WinterMute { typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXMath; -class CBKeyboardState; -class CVidPlayer; -class CVidTheoraPlayer; +class BaseSoundMgr; +class BaseFader; +class BaseFont; +class BaseFileManager; +class BaseTransitionMgr; +class ScEngine; +class BaseFontStorage; +class BaseStringTable; +class BaseQuickMsg; +class UIWindow; +class BaseViewport; +class BaseRenderer; +class BaseRegistry; +class BaseSaveThumbHelper; +class BaseSurfaceStorage; +class SXMath; +class BaseKeyboardState; +class VideoPlayer; +class VideoTheoraPlayer; #define NUM_MUSIC_CHANNELS 5 -class CBGame: public CBObject { +class BaseGame: public BaseObject { public: - DECLARE_PERSISTENT(CBGame, CBObject) + DECLARE_PERSISTENT(BaseGame, BaseObject) - virtual bool onScriptShutdown(CScScript *script); + virtual bool onScriptShutdown(ScScript *script); virtual bool onActivate(bool activate, bool refreshMouse); virtual bool onMouseLeftDown(); @@ -105,7 +105,7 @@ public: TTextEncoding _textEncoding; bool _textRTL; - CBSprite *_loadingIcon; + BaseSprite *_loadingIcon; int _loadingIconX; int _loadingIconY; int _loadingIconPersistent; @@ -136,7 +136,7 @@ protected: int _loadImageX; int _loadImageY; - CBSurface *_saveLoadImage; + BaseSurface *_saveLoadImage; bool displayIndicator(); bool _reportTextureFormat; @@ -157,32 +157,32 @@ public: int _offsetX; float _offsetPercentX; float _offsetPercentY; - CBObject *_mainObject; + BaseObject *_mainObject; bool initInput(); bool initLoop(); uint32 _currentTime; uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; + BaseFont *_systemFont; + BaseFont *_videoFont; bool initialize1(); bool initialize2(); bool initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *getDebugMgr(); + BaseFileManager *_fileManager; + BaseTransitionMgr *_transMgr; + BaseDebugger *getDebugMgr(); void LOG(bool res, const char *fmt, ...); - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); + BaseRenderer *_renderer; + BaseSoundMgr *_soundMgr; + ScEngine *_scEngine; + SXMath *_mathClass; + BaseSurfaceStorage *_surfaceStorage; + BaseFontStorage *_fontStorage; + BaseGame(); - virtual ~CBGame(); + virtual ~BaseGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *filename = NULL); bool _debugDebugMode; @@ -192,13 +192,13 @@ public: int _sequence; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; int _viewportSP; - CBStringTable *_stringTable; + BaseStringTable *_stringTable; int _settingsResWidth; int _settingsResHeight; char *_settingsGameFile; @@ -215,15 +215,15 @@ protected: bool _settingsRequireSound; bool _settingsAllowDesktopRes; int _settingsTLMode; - CBFader *_fader; + BaseFader *_fader; virtual bool invalidateDeviceObjects(); virtual bool restoreDeviceObjects(); public: - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; @@ -262,11 +262,11 @@ protected: public: bool unfreeze(); bool freeze(bool includingMusic = true); - bool focusWindow(CUIWindow *window); - CVidPlayer *_videoPlayer; - CVidTheoraPlayer *_theoraPlayer; + bool focusWindow(UIWindow *window); + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; bool _loadInProgress; - CUIWindow *_focusedWindow; + UIWindow *_focusedWindow; bool _editorForceScripts; protected: static void afterLoadRegion(void *region, void *data); @@ -283,7 +283,7 @@ public: bool pauseMusic(int channel); bool stopMusic(int channel); bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; + BaseSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; uint32 _musicCrossfadeStartTime; @@ -291,7 +291,7 @@ public: int _musicCrossfadeChannel1; int _musicCrossfadeChannel2; bool displayWindows(bool inGame = false); - CBRegistry *_registry; + BaseRegistry *_registry; bool _useD3D; virtual bool cleanup(); virtual bool loadGame(int slot); @@ -299,9 +299,9 @@ public: virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; + BaseSprite *_cursorNoninteractive; + BaseObject *_activeObject; + BaseKeyboardState *_keyboardState; bool _interactive; TGameState _state; TGameState _origState; @@ -314,11 +314,11 @@ public: uint32 _liveTimerDelta; uint32 _liveTimerLast; - CBObject *_capturedObject; + BaseObject *_capturedObject; Point32 _mousePos; - bool validObject(CBObject *object); - bool unregisterObject(CBObject *object); - bool registerObject(CBObject *object); + bool validObject(BaseObject *object); + bool unregisterObject(BaseObject *object); + bool registerObject(BaseObject *object); void quickMessage(const char *text); void quickMessageForm(char *fmt, ...); bool displayQuickMsg(); @@ -328,7 +328,7 @@ public: bool isVideoPlaying(); bool stopVideo(); - CBArray _regObjects; + BaseArray _regObjects; public: virtual bool displayContent(bool update = true, bool displayAll = false); virtual bool displayContentSimple(); @@ -336,18 +336,18 @@ public: void resetMousePos(); int _subtitlesSpeed; void setInteractive(bool state); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); bool popViewport(); - bool pushViewport(CBViewport *Viewport); - bool setActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - bool drawCursor(CBSprite *Cursor); + bool pushViewport(BaseViewport *Viewport); + bool setActiveObject(BaseObject *Obj); + BaseSprite *_lastCursor; + bool drawCursor(BaseSprite *Cursor); virtual bool initAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; + BaseSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); @@ -356,7 +356,7 @@ public: AnsiString getDeviceType() const; private: - CBDebugger *_debugMgr; + BaseDebugger *_debugMgr; struct LastClickInfo { LastClickInfo() { diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 240f642b7f..ad014762d4 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -35,10 +35,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBKeyboardState, false) +IMPLEMENT_PERSISTENT(BaseKeyboardState, false) ////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame): BaseScriptable(inGame) { _currentPrintable = false; _currentCharCode = 0; _currentKeyData = 0; @@ -54,17 +54,17 @@ CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { +BaseKeyboardState::~BaseKeyboardState() { delete[] _keyStates; } -void CBKeyboardState::handleKeyPress(Common::Event *event) { +void BaseKeyboardState::handleKeyPress(Common::Event *event) { if (event->type == Common::EVENT_KEYDOWN) { _keyStates[event->kbd.keycode] = true; } } -void CBKeyboardState::handleKeyRelease(Common::Event *event) { +void BaseKeyboardState::handleKeyRelease(Common::Event *event) { if (event->type == Common::EVENT_KEYUP) { _keyStates[event->kbd.keycode] = false; } @@ -73,13 +73,13 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "IsKeyDown") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); int vKey; if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { @@ -98,12 +98,12 @@ bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack return STATUS_OK; } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *name) { +ScValue *BaseKeyboardState::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -168,12 +168,12 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { +bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -184,18 +184,18 @@ bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::scToString() { +const char *BaseKeyboardState::scToString() { return "[keyboard state]"; } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::readKey(Common::Event *event) { +bool BaseKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || @@ -215,9 +215,9 @@ bool CBKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { +bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { //if(!persistMgr->_saving) cleanup(); - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); persistMgr->transfer(TMEMBER(_currentCharCode)); @@ -237,25 +237,25 @@ bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isShiftDown() { +bool BaseKeyboardState::isShiftDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_SHIFT); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isControlDown() { +bool BaseKeyboardState::isControlDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_CTRL); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isAltDown() { +bool BaseKeyboardState::isAltDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_ALT); } ////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { +uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { if (event->type != Common::EVENT_KEYDOWN) return 0; switch (event->kbd.keycode) { @@ -275,7 +275,7 @@ enum VKeyCodes { }; ////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { +Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { case VK_SPACE: diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index bdf268c601..8c4b1afb59 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -37,7 +37,7 @@ namespace WinterMute { -class CBKeyboardState : public CBScriptable { +class BaseKeyboardState : public BaseScriptable { public: uint32 _currentKeyData; uint32 _currentCharCode; @@ -47,9 +47,9 @@ public: bool _currentAlt; bool _currentControl; - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); + DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) + BaseKeyboardState(BaseGame *inGame); + virtual ~BaseKeyboardState(); bool readKey(Common::Event *event); void handleKeyPress(Common::Event *event); @@ -59,9 +59,9 @@ public: static bool isAltDown(); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index da76fb2047..97b9f53353 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -32,30 +32,30 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { +BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { +BaseNamedObject::BaseNamedObject() : BaseClass() { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { +BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { +BaseNamedObject::~BaseNamedObject(void) { delete[] _name; _name = NULL; } ////////////////////////////////////////////////////////////////////// -void CBNamedObject::setName(const char *name) { +void BaseNamedObject::setName(const char *name) { delete[] _name; _name = new char [strlen(name) + 1]; diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index c03d1417a3..f7b496ead8 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -34,12 +34,12 @@ namespace WinterMute { -class CBNamedObject : public CBBase { +class BaseNamedObject : public BaseClass { public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); + BaseNamedObject(BaseGame *inGame); + BaseNamedObject(); + virtual ~BaseNamedObject(void); + BaseNamedObject(TDynamicConstructor, TDynamicConstructor); char *_name; void setName(const char *name); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 0a4a0638f0..4ab121ded9 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -40,10 +40,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBObject, false) +IMPLEMENT_PERSISTENT(BaseObject, false) ////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { +BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { _posX = _posY = 0; _movable = true; _zoomable = true; @@ -65,7 +65,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _iD = _gameRef->getSequence(); - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _rectSet = false; _cursor = NULL; @@ -101,17 +101,17 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { +BaseObject::~BaseObject() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBObject::cleanup() { +bool BaseObject::cleanup() { if (_gameRef && _gameRef->_activeObject == this) _gameRef->_activeObject = NULL; - CBScriptHolder::cleanup(); + BaseScriptHolder::cleanup(); delete[] _soundEvent; _soundEvent = NULL; @@ -137,7 +137,7 @@ bool CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull +void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull if (caseVal == 0) caseVal = 1; if (caseVal < 1 || caseVal > 7) return; @@ -152,7 +152,7 @@ void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Ca ////////////////////////////////////////////////////////////////////////// -const char *CBObject::getCaption(int caseVal) { +const char *BaseObject::getCaption(int caseVal) { if (caseVal == 0) caseVal = 1; if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) return ""; @@ -161,7 +161,7 @@ const char *CBObject::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { +bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -169,7 +169,7 @@ bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -291,9 +291,9 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt bool looping; uint32 loopStart; - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *val3 = stack->pop(); if (val1->_type == VAL_BOOL) { filename = NULL; @@ -321,8 +321,8 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt const char *filename; const char *eventName; - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); if (val2->isNULL()) { filename = NULL; @@ -473,12 +473,12 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); + else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *name) { +ScValue *BaseObject::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -666,12 +666,12 @@ CScValue *CBObject::scGetProperty(const char *name) { return _scValue; } - else return CBScriptHolder::scGetProperty(name); + else return BaseScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBObject::scSetProperty(const char *name, CScValue *value) { +bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// @@ -845,32 +845,32 @@ bool CBObject::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptHolder::scSetProperty(name, value); + else return BaseScriptHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBObject::scToString() { +const char *BaseObject::scToString() { return "[object]"; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::showCursor() { +bool BaseObject::showCursor() { if (_cursor) return _gameRef->drawCursor(_cursor); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); +bool BaseObject::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); @@ -925,14 +925,14 @@ bool CBObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setCursor(const char *filename) { +bool BaseObject::setCursor(const char *filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; } _sharedCursors = false; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { delete _cursor; _cursor = NULL; @@ -942,9 +942,9 @@ bool CBObject::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setActiveCursor(const char *filename) { +bool BaseObject::setActiveCursor(const char *filename) { delete _activeCursor; - _activeCursor = new CBSprite(_gameRef); + _activeCursor = new BaseSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { delete _activeCursor; _activeCursor = NULL; @@ -954,31 +954,31 @@ bool CBObject::setActiveCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -int CBObject::getHeight() { +int BaseObject::getHeight() { return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { +bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleKeypress(Common::Event *event, bool printable) { +bool BaseObject::handleKeypress(Common::Event *event, bool printable) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouseWheel(int delta) { +bool BaseObject::handleMouseWheel(int delta) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { +bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound if (filename == NULL && _sFX) { if (_gameRef->_editorMode || _sFXStart) { @@ -998,7 +998,7 @@ bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const c // create new sound delete _sFX; - _sFX = new CBSound(_gameRef); + _sFX = new BaseSound(_gameRef); if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { _sFX->setVolumePercent(_sFXVolume); if (_sFXStart) { @@ -1020,7 +1020,7 @@ bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const c ////////////////////////////////////////////////////////////////////////// -bool CBObject::stopSFX(bool deleteSound) { +bool BaseObject::stopSFX(bool deleteSound) { if (_sFX) { _sFX->stop(); if (deleteSound) { @@ -1033,21 +1033,21 @@ bool CBObject::stopSFX(bool deleteSound) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::pauseSFX() { +bool BaseObject::pauseSFX() { if (_sFX) return _sFX->pause(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::resumeSFX() { +bool BaseObject::resumeSFX() { if (_sFX) return _sFX->resume(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXTime(uint32 time) { +bool BaseObject::setSFXTime(uint32 time) { _sFXStart = time; if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); else return STATUS_OK; @@ -1055,7 +1055,7 @@ bool CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXVolume(int volume) { +bool BaseObject::setSFXVolume(int volume) { _sFXVolume = volume; if (_sFX) return _sFX->setVolumePercent(volume); else return STATUS_OK; @@ -1063,7 +1063,7 @@ bool CBObject::setSFXVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::updateSounds() { +bool BaseObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); @@ -1077,7 +1077,7 @@ bool CBObject::updateSounds() { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::updateOneSound(CBSound *sound) { +bool BaseObject::updateOneSound(BaseSound *sound) { bool Ret = STATUS_OK; if (sound) { @@ -1090,7 +1090,7 @@ bool CBObject::updateOneSound(CBSound *sound) { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::resetSoundPan() { +bool BaseObject::resetSoundPan() { if (!_sFX) return STATUS_OK; else { return _sFX->setPan(0.0f); @@ -1099,19 +1099,19 @@ bool CBObject::resetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CBObject::getExtendedFlag(const char *flagName) { +bool BaseObject::getExtendedFlag(const char *flagName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::isReady() { +bool BaseObject::isReady() { return _ready; } ////////////////////////////////////////////////////////////////////////// -void CBObject::setSoundEvent(const char *eventName) { +void BaseObject::setSoundEvent(const char *eventName) { delete[] _soundEvent; _soundEvent = NULL; if (eventName) { @@ -1121,7 +1121,7 @@ void CBObject::setSoundEvent(const char *eventName) { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::afterMove() { +bool BaseObject::afterMove() { return STATUS_OK; } diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 70dc69f53d..c05501b145 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -36,14 +36,14 @@ namespace WinterMute { -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { +class BaseSprite; +class BaseSound; +class BaseSurface; +class BaseScriptHolder; +class ScValue; +class ScStack; +class ScScript; +class BaseObject : public BaseScriptHolder { public: TSpriteBlendMode _blendMode; virtual bool afterMove(); @@ -61,7 +61,7 @@ public: virtual bool getExtendedFlag(const char *flagName); virtual bool resetSoundPan(); virtual bool updateSounds(); - bool updateOneSound(CBSound *sound); + bool updateOneSound(BaseSound *sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; @@ -71,7 +71,7 @@ public: bool pauseSFX(); bool stopSFX(bool deleteSound = true); bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - CBSound *_sFX; + BaseSound *_sFX; TSFXType _sFXType; float _sFXParam1; @@ -92,13 +92,13 @@ public: bool _editorAlwaysRegister; bool _editorOnly; bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) virtual bool showCursor(); - CBSprite *_cursor; + BaseSprite *_cursor; bool _sharedCursors; - CBSprite *_activeCursor; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); + BaseSprite *_activeCursor; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; bool _zoomable; @@ -107,8 +107,8 @@ public: bool _rectSet; int _iD; bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); char *_caption[7]; char *_soundEvent; int _posY; @@ -133,9 +133,9 @@ public: public: // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 0f185636aa..b07d98eca8 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -43,26 +43,26 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { +BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } ////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { +BaseParser::~BaseParser() { if (_whiteSpace != NULL) delete [] _whiteSpace; } ////////////////////////////////////////////////////////////////////// -char *CBParser::getLastOffender() { +char *BaseParser::getLastOffender() { return _lastOffender; } ////////////////////////////////////////////////////////////////////// -int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -113,7 +113,7 @@ int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **dat ////////////////////////////////////////////////////////////////////// -int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; _gameRef->miniUpdate(); char *name; @@ -122,7 +122,7 @@ int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { ////////////////////////////////////////////////////////////////////// -void CBParser::skipCharacters(char **buf, const char *toSkip) { +void BaseParser::skipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { if (ch == '\n') _parserLine++; @@ -135,7 +135,7 @@ void CBParser::skipCharacters(char **buf, const char *toSkip) { ////////////////////////////////////////////////////////////////////// -char *CBParser::getSubText(char **buf, char open, char close) { +char *BaseParser::getSubText(char **buf, char open, char close) { if (**buf == 0 || **buf != open) return 0; ++*buf; // skip opening delimiter @@ -164,7 +164,7 @@ char *CBParser::getSubText(char **buf, char open, char close) { ////////////////////////////////////////////////////////////////////// -char *CBParser::getAssignmentText(char **buf) { +char *BaseParser::getAssignmentText(char **buf) { ++*buf; // skip the '=' skipCharacters(buf, _whiteSpace); char *result = *buf; @@ -192,7 +192,7 @@ char *CBParser::getAssignmentText(char **buf) { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *CBParser::getToken(char **buf) { +char *BaseParser::getToken(char **buf) { static char token[100]; char *b = *buf, * t = token; while (true) { @@ -240,7 +240,7 @@ char *CBParser::getToken(char **buf) { ////////////////////////////////////////////////////////////////////// -float CBParser::getTokenFloat(char **buf) { +float BaseParser::getTokenFloat(char **buf) { char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. @@ -252,7 +252,7 @@ float CBParser::getTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// -int CBParser::getTokenInt(char **buf) { +int BaseParser::getTokenInt(char **buf) { char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. @@ -264,14 +264,14 @@ int CBParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// -void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { +void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { char *t = getToken(buf); if (strcmp(t, tok)) return; // Error } ////////////////////////////////////////////////////////////////////// -int CBParser::scanStr(const char *in, const char *format, ...) { +int BaseParser::scanStr(const char *in, const char *format, ...) { va_list arg; va_start(arg, format); diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 53a02c0f68..a5c55ceb41 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -40,7 +40,7 @@ TOKEN_TOTAL_COUNT \ }; #define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ + static BaseParser::TokenDesc name [] = \ { #define TOKEN_TABLE(name) \ { TOKEN_ ## name, #name }, @@ -57,7 +57,7 @@ namespace WinterMute { -class CBParser : public CBBase { +class BaseParser : public BaseClass { public: struct TokenDesc { int32 id; @@ -67,8 +67,8 @@ public: public: int scanStr(const char *in, const char *format, ...); int32 getCommand(char **buf, TokenDesc *tokens, char **params); - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); + BaseParser(BaseGame *inGame = NULL); + virtual ~BaseParser(); private: char *getLastOffender(); void skipToken(char **buf, char *tok, char *msg = NULL); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 743eaf355b..18dc8ed11c 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -51,7 +51,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { +BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix): BaseClass(inGame) { _saving = false; // _buffer = NULL; // _bufferSize = 0; @@ -80,13 +80,13 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGam ////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { +BasePersistenceManager::~BasePersistenceManager() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::cleanup() { +void BasePersistenceManager::cleanup() { /* if (_buffer) { if (_saving) free(_buffer); else delete [] _buffer; // allocated by file manager @@ -118,12 +118,12 @@ void CBPersistMgr::cleanup() { _saveStream = NULL; } -Common::String CBPersistMgr::getFilenameForSlot(int slot) const { +Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); } -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { +void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { @@ -150,12 +150,12 @@ void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { desc.setPlayTime(0); } -void CBPersistMgr::deleteSaveSlot(int slot) { +void BasePersistenceManager::deleteSaveSlot(int slot) { Common::String filename = getFilenameForSlot(slot); g_system->getSavefileManager()->removeSavefile(filename); } -uint32 CBPersistMgr::getMaxUsedSlot() { +uint32 BasePersistenceManager::getMaxUsedSlot() { Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); Common::StringArray::iterator it = saves.begin(); @@ -168,7 +168,7 @@ uint32 CBPersistMgr::getMaxUsedSlot() { return ret; } -bool CBPersistMgr::getSaveExists(int slot) { +bool BasePersistenceManager::getSaveExists(int slot) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { @@ -178,7 +178,7 @@ bool CBPersistMgr::getSaveExists(int slot) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initSave(const char *desc) { +bool BasePersistenceManager::initSave(const char *desc) { if (!desc) return STATUS_FAILED; cleanup(); @@ -189,7 +189,7 @@ bool CBPersistMgr::initSave(const char *desc) { if (_saveStream) { // get thumbnails if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + _gameRef->_cachedThumbnail = new BaseSaveThumbHelper(_gameRef); if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { delete _gameRef->_cachedThumbnail; _gameRef->_cachedThumbnail = NULL; @@ -252,7 +252,7 @@ bool CBPersistMgr::initSave(const char *desc) { return STATUS_OK; } -bool CBPersistMgr::readHeader(const Common::String &filename) { +bool BasePersistenceManager::readHeader(const Common::String &filename) { cleanup(); _saving = false; @@ -307,7 +307,7 @@ bool CBPersistMgr::readHeader(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initLoad(const char *filename) { +bool BasePersistenceManager::initLoad(const char *filename) { if (DID_FAIL(readHeader(filename))) { cleanup(); return STATUS_FAILED; @@ -356,13 +356,13 @@ bool CBPersistMgr::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::saveFile(const char *filename) { +bool BasePersistenceManager::saveFile(const char *filename) { return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { +bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); if (_saveStream->err()) return STATUS_FAILED; @@ -370,7 +370,7 @@ bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { +bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); if (_loadStream->err()) return STATUS_FAILED; @@ -378,20 +378,20 @@ bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putDWORD(uint32 val) { +void BasePersistenceManager::putDWORD(uint32 val) { _saveStream->writeUint32LE(val); } ////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::getDWORD() { +uint32 BasePersistenceManager::getDWORD() { uint32 ret = _loadStream->readUint32LE(); return ret; } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putString(const Common::String &val) { +void BasePersistenceManager::putString(const Common::String &val) { if (!val.size()) putString("(null)"); else { _saveStream->writeUint32LE(val.size()); @@ -399,7 +399,7 @@ void CBPersistMgr::putString(const Common::String &val) { } } -Common::String CBPersistMgr::getStringObj() { +Common::String BasePersistenceManager::getStringObj() { uint32 len = _loadStream->readUint32LE(); char *ret = new char[len + 1]; _loadStream->read(ret, len); @@ -416,7 +416,7 @@ Common::String CBPersistMgr::getStringObj() { } ////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::getString() { +char *BasePersistenceManager::getString() { uint32 len = _loadStream->readUint32LE(); char *ret = new char[len + 1]; _loadStream->read(ret, len); @@ -428,7 +428,7 @@ char *CBPersistMgr::getString() { } else return ret; } -bool CBPersistMgr::putTimeDate(const TimeDate &t) { +bool BasePersistenceManager::putTimeDate(const TimeDate &t) { _saveStream->writeSint32LE(t.tm_sec); _saveStream->writeSint32LE(t.tm_min); _saveStream->writeSint32LE(t.tm_hour); @@ -443,7 +443,7 @@ bool CBPersistMgr::putTimeDate(const TimeDate &t) { return STATUS_OK; } -TimeDate CBPersistMgr::getTimeDate() { +TimeDate BasePersistenceManager::getTimeDate() { TimeDate t; t.tm_sec = _loadStream->readSint32LE(); t.tm_min = _loadStream->readSint32LE(); @@ -455,13 +455,13 @@ TimeDate CBPersistMgr::getTimeDate() { return t; } -void CBPersistMgr::putFloat(float val) { +void BasePersistenceManager::putFloat(float val) { Common::String str = Common::String::format("F%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); } -float CBPersistMgr::getFloat() { +float BasePersistenceManager::getFloat() { char *str = getString(); float value = 0.0f; int ret = sscanf(str, "F%f", &value); @@ -472,14 +472,14 @@ float CBPersistMgr::getFloat() { return value; } -void CBPersistMgr::putDouble(double val) { +void BasePersistenceManager::putDouble(double val) { Common::String str = Common::String::format("F%f", val); str.format("D%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); } -double CBPersistMgr::getDouble() { +double BasePersistenceManager::getDouble() { char *str = getString(); double value = 0.0f; int ret = sscanf(str, "F%f", &value); @@ -492,7 +492,7 @@ double CBPersistMgr::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -bool CBPersistMgr::transfer(const char *name, bool *val) { +bool BasePersistenceManager::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -509,7 +509,7 @@ bool CBPersistMgr::transfer(const char *name, bool *val) { ////////////////////////////////////////////////////////////////////////// // int -bool CBPersistMgr::transfer(const char *name, int *val) { +bool BasePersistenceManager::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); if (_saveStream->err()) @@ -526,7 +526,7 @@ bool CBPersistMgr::transfer(const char *name, int *val) { ////////////////////////////////////////////////////////////////////////// // DWORD -bool CBPersistMgr::transfer(const char *name, uint32 *val) { +bool BasePersistenceManager::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); if (_saveStream->err()) @@ -543,7 +543,7 @@ bool CBPersistMgr::transfer(const char *name, uint32 *val) { ////////////////////////////////////////////////////////////////////////// // float -bool CBPersistMgr::transfer(const char *name, float *val) { +bool BasePersistenceManager::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); if (_saveStream->err()) @@ -560,7 +560,7 @@ bool CBPersistMgr::transfer(const char *name, float *val) { ////////////////////////////////////////////////////////////////////////// // double -bool CBPersistMgr::transfer(const char *name, double *val) { +bool BasePersistenceManager::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) @@ -577,7 +577,7 @@ bool CBPersistMgr::transfer(const char *name, double *val) { ////////////////////////////////////////////////////////////////////////// // char* -bool CBPersistMgr::transfer(const char *name, char **val) { +bool BasePersistenceManager::transfer(const char *name, char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -594,7 +594,7 @@ bool CBPersistMgr::transfer(const char *name, char **val) { ////////////////////////////////////////////////////////////////////////// // const char* -bool CBPersistMgr::transfer(const char *name, const char **val) { +bool BasePersistenceManager::transfer(const char *name, const char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -611,7 +611,7 @@ bool CBPersistMgr::transfer(const char *name, const char **val) { ////////////////////////////////////////////////////////////////////////// // Common::String -bool CBPersistMgr::transfer(const char *name, Common::String *val) { +bool BasePersistenceManager::transfer(const char *name, Common::String *val) { if (_saving) { putString(*val); return STATUS_OK; @@ -632,7 +632,7 @@ bool CBPersistMgr::transfer(const char *name, Common::String *val) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { +bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { size_t size; if (_saving) { @@ -662,7 +662,7 @@ bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { ////////////////////////////////////////////////////////////////////////// // BYTE -bool CBPersistMgr::transfer(const char *name, byte *val) { +bool BasePersistenceManager::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -679,7 +679,7 @@ bool CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -bool CBPersistMgr::transfer(const char *name, Rect32 *val) { +bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -702,7 +702,7 @@ bool CBPersistMgr::transfer(const char *name, Rect32 *val) { ////////////////////////////////////////////////////////////////////////// // POINT -bool CBPersistMgr::transfer(const char *name, Point32 *val) { +bool BasePersistenceManager::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); @@ -721,7 +721,7 @@ bool CBPersistMgr::transfer(const char *name, Point32 *val) { ////////////////////////////////////////////////////////////////////////// // Vector2 -bool CBPersistMgr::transfer(const char *name, Vector2 *val) { +bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); @@ -740,11 +740,11 @@ bool CBPersistMgr::transfer(const char *name, Vector2 *val) { ////////////////////////////////////////////////////////////////////////// // generic pointer -bool CBPersistMgr::transfer(const char *name, void *val) { +bool BasePersistenceManager::transfer(const char *name, void *val) { int classID = -1, instanceID = -1; if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { _gameRef->LOG(0, "Warning: invalid instance '%s'", name); } @@ -755,7 +755,7 @@ bool CBPersistMgr::transfer(const char *name, void *val) { classID = _loadStream->readUint32LE(); instanceID = _loadStream->readUint32LE(); - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); } return STATUS_OK; @@ -763,7 +763,7 @@ bool CBPersistMgr::transfer(const char *name, void *val) { ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { +bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { if (_saving) return true; // it's ok if we are same or newer than the saved game diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index f2fd42ceca..a400c612dc 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -42,7 +42,7 @@ namespace WinterMute { class Vector2; -class CBPersistMgr : public CBBase { +class BasePersistenceManager : public BaseClass { public: char *_savedDescription; TimeDate _savedTimestamp; @@ -94,8 +94,8 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); - virtual ~CBPersistMgr(); + BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); uint32 _thumbnailDataSize; diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index e878f34387..76d8d85c70 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -32,28 +32,28 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBPoint, false) +IMPLEMENT_PERSISTENT(BasePoint, false) ////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { +BasePoint::BasePoint() { x = y = 0; } ////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { +BasePoint::~BasePoint() { } ////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { +BasePoint::BasePoint(int initX, int initY) { x = initX; y = initY; } ////////////////////////////////////////////////////////////////////////// -bool CBPoint::persist(CBPersistMgr *persistMgr) { +bool BasePoint::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(x)); persistMgr->transfer(TMEMBER(y)); diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 363ab1f919..35d310b8d9 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -34,14 +34,14 @@ namespace WinterMute { -class CBPoint: public CBBase { +class BasePoint: public BaseClass { public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); + DECLARE_PERSISTENT(BasePoint, BaseClass) + BasePoint(); + BasePoint(int initX, int initY); int y; int x; - virtual ~CBPoint(); + virtual ~BasePoint(); }; diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index ac1001a2fe..856a214f80 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { _text = new char [strlen(text) + 1]; if (_text) strcpy(_text, text); _startTime = _gameRef->_currentTime; @@ -41,13 +41,13 @@ CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { +BaseQuickMsg::~BaseQuickMsg() { if (_text) delete [] _text; } ////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::getText() { +char *BaseQuickMsg::getText() { return _text; } diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index 9a68929932..f2f9144bc0 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -33,13 +33,13 @@ namespace WinterMute { -class CBQuickMsg : public CBBase { +class BaseQuickMsg : public BaseClass { public: char *getText(); uint32 _startTime; char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); + BaseQuickMsg(BaseGame *inGame, const char *Text); + virtual ~BaseQuickMsg(); }; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 3e513f9fb8..e336b92789 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -40,43 +40,43 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBRegion, false) +IMPLEMENT_PERSISTENT(BaseRegion, false) ////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { +BaseRegion::BaseRegion(BaseGame *inGame): BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; _lastMimicX = _lastMimicY = INT_MIN; - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); } ////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { +BaseRegion::~BaseRegion() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBRegion::cleanup() { +void BaseRegion::cleanup() { for (int i = 0; i < _points.getSize(); i++) delete _points[i]; _points.removeAll(); - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::createRegion() { +bool BaseRegion::createRegion() { return DID_SUCCEED(getBoundingRect(&_rect)); } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::pointInRegion(int x, int y) { +bool BaseRegion::pointInRegion(int x, int y) { if (_points.getSize() < 3) return false; Point32 pt; @@ -89,16 +89,16 @@ bool CBRegion::pointInRegion(int x, int y) { rect.top = y - 1; rect.bottom = y + 2; - if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + if (BasePlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); else return false; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadFile(const char *filename) { +bool BaseRegion::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadBuffer(byte *buffer, bool complete) { +bool BaseRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -143,7 +143,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { @@ -179,7 +179,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); } break; @@ -210,7 +210,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -220,7 +220,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -238,7 +238,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new CBPoint(x, y)); + _points.insertAt(Index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -295,7 +295,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int index = stack->pop()->getInt(); if (index >= 0 && index < _points.getSize()) { - CScValue *val = stack->getPushValue(); + ScValue *val = stack->getPushValue(); if (val) { val->setProperty("X", _points[index]->x); val->setProperty("Y", _points[index]->y); @@ -305,12 +305,12 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *name) { +ScValue *BaseRegion::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -345,12 +345,12 @@ CScValue *CBRegion::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::scSetProperty(const char *name, CScValue *value) { +bool BaseRegion::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -367,18 +367,18 @@ bool CBRegion::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBRegion::scToString() { +const char *BaseRegion::scToString() { return "[region]"; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { +bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); @@ -406,9 +406,9 @@ bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverr ////////////////////////////////////////////////////////////////////////// -bool CBRegion::persist(CBPersistMgr *persistMgr) { +bool BaseRegion::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_editorSelectedPoint)); @@ -426,7 +426,7 @@ typedef struct { } dPoint; ////////////////////////////////////////////////////////////////////////// -bool CBRegion::ptInPolygon(int x, int y) { +bool BaseRegion::ptInPolygon(int x, int y) { if (_points.getSize() < 3) return false; int counter = 0; @@ -465,8 +465,8 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -bool CBRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); +bool BaseRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) BasePlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -477,14 +477,14 @@ bool CBRegion::getBoundingRect(Rect32 *rect) { MaxX = MAX(MaxX, _points[i]->x); MaxY = MAX(MaxY, _points[i]->y); } - CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + BasePlatform::setRect(rect, MinX, MinY, MaxX, MaxY); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { +bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; cleanup(); @@ -495,7 +495,7 @@ bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { xVal = (int)((float)region->_points[i]->x * scale / 100.0f); yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - _points.add(new CBPoint(xVal + x, yVal + y)); + _points.add(new BasePoint(xVal + x, yVal + y)); } _lastMimicScale = scale; diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 0c35d99bd9..a15e0cca2a 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -34,32 +34,32 @@ namespace WinterMute { -class CBRegion : public CBObject { +class BaseRegion : public BaseObject { public: float _lastMimicScale; int _lastMimicX; int _lastMimicY; void cleanup(); - bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); bool getBoundingRect(Rect32 *rect); bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(CBRegion, CBObject) + DECLARE_PERSISTENT(BaseRegion, BaseObject) bool _active; int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); + BaseRegion(BaseGame *inGame); + virtual ~BaseRegion(); bool pointInRegion(int x, int y); bool createRegion(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; - CBArray _points; - virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + BaseArray _points; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 350a34b61e..dfab1b5076 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { +BaseRegistry::BaseRegistry(BaseGame *inGame): BaseClass(inGame) { _iniName = NULL; setIniName("./wme.ini"); @@ -47,7 +47,7 @@ CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { +BaseRegistry::~BaseRegistry() { saveValues(); delete[] _iniName; _iniName = NULL; @@ -56,7 +56,7 @@ CBRegistry::~CBRegistry() { ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { +AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { AnsiString ret = ""; bool found = false; @@ -69,14 +69,14 @@ AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &ke ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { +bool BaseRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { _values[subKey][key] = value; return true; } ////////////////////////////////////////////////////////////////////////// -int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { +int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { if (subKey == "Audio") { if (key == "MasterVolume") { if (ConfMan.hasKey("master_volume")) { @@ -111,7 +111,7 @@ int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int ini ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { +bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { if (subKey == "Audio") { if (key == "MasterVolume") { ConfMan.setInt("master_volume", value); @@ -133,19 +133,19 @@ bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int v ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { +bool BaseRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { return (readInt(subKey, key, (int)init) != 0); } ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { +bool BaseRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { return writeInt(subKey, key, (int)value); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::setIniName(const char *name) { +void BaseRegistry::setIniName(const char *name) { delete[] _iniName; _iniName = NULL; @@ -160,30 +160,30 @@ void CBRegistry::setIniName(const char *name) { ////////////////////////////////////////////////////////////////////////// -char *CBRegistry::getIniName() { +char *BaseRegistry::getIniName() { return _iniName; } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadValues(bool local) { +void BaseRegistry::loadValues(bool local) { if (local) loadXml("settings.xml", _localValues); else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveValues() { +void BaseRegistry::saveValues() { saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::setBasePath(const char *basePath) { +void BaseRegistry::setBasePath(const char *basePath) { _basePath = PathUtil::getFileNameWithoutExtension(basePath); loadValues(false); } ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { +AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { found = false; PathValueMap::iterator it = values.find(path); if (it == values.end()) return ""; @@ -198,7 +198,7 @@ AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, con } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { +void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { TiXmlDocument doc(fileName.c_str()); if (!doc.LoadFile()) return; @@ -215,8 +215,8 @@ void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { ////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::createPath(fileName.c_str()); +void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + BaseUtils::createPath(fileName.c_str()); TiXmlDocument doc; doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h index 06e052cd03..1d67c18e85 100644 --- a/engines/wintermute/base/base_registry.h +++ b/engines/wintermute/base/base_registry.h @@ -33,7 +33,7 @@ namespace WinterMute { -class CBRegistry : public CBBase { +class BaseRegistry : public BaseClass { public: void setIniName(const char *name); char *getIniName(); @@ -43,8 +43,8 @@ public: int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); + BaseRegistry(BaseGame *inGame); + virtual ~BaseRegistry(); void setBasePath(const char *basePath); AnsiString getBasePath() const { diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index bee63aa307..68cfb8a7ea 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -34,18 +34,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame): BaseClass(inGame) { _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { +BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { delete _thumbnail; _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { +bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; @@ -60,12 +60,12 @@ bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { _gameRef->_renderer->flip(); } - CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); if (!screenshot) return STATUS_FAILED; // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new CBImage(_gameRef); + _thumbnail = new BaseImage(_gameRef); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index e8cdbdc00d..ef2615a668 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -33,16 +33,16 @@ namespace WinterMute { -class CBImage; +class BaseImage; -class CBSaveThumbHelper : public CBBase { +class BaseSaveThumbHelper : public BaseClass { public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); + BaseSaveThumbHelper(BaseGame *inGame); + virtual ~BaseSaveThumbHelper(void); bool storeThumbnail(bool doFlip = false); - CBImage *_thumbnail; - CBImage *_richThumbnail; + BaseImage *_thumbnail; + BaseImage *_richThumbnail; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 5192f76f6e..f803a9191f 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -37,10 +37,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBScriptHolder, false) +IMPLEMENT_PERSISTENT(BaseScriptHolder, false) ////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame): BaseScriptable(inGame) { setName(""); _freezable = true; @@ -49,13 +49,13 @@ CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { +BaseScriptHolder::~BaseScriptHolder() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::cleanup() { +bool BaseScriptHolder::cleanup() { delete[] _filename; _filename = NULL; @@ -71,7 +71,7 @@ bool CBScriptHolder::cleanup() { } ////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *filename) { +void BaseScriptHolder::setFilename(const char *filename) { if (_filename != NULL) delete [] _filename; _filename = new char [strlen(filename) + 1]; @@ -80,13 +80,13 @@ void CBScriptHolder::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { +bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; bool ret = STATUS_FAILED; for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { //_scripts.add(handler); numHandlers++; @@ -101,7 +101,7 @@ bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { +bool BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -109,7 +109,7 @@ bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -127,7 +127,7 @@ bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack * ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ApplyEvent") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); bool ret; ret = applyEvent(val->getString()); @@ -203,12 +203,12 @@ bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushBool(ret); return STATUS_OK; - } else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *name) { +ScValue *BaseScriptHolder::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -235,36 +235,36 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { +bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); return STATUS_OK; - } else return CBScriptable::scSetProperty(name, value); + } else return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::scToString() { +const char *BaseScriptHolder::scToString() { return "[script_holder]"; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { - return CBBase::saveAsText(buffer, indent); +bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return BaseClass::saveAsText(buffer, indent); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); @@ -276,21 +276,21 @@ bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::addScript(const char *filename) { +bool BaseScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); return STATUS_OK; } } } - CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + ScScript *scr = _gameRef->_scEngine->runScript(filename, this); if (!scr) { if (_gameRef->_editorForceScripts) { // editor hack - scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr = new ScScript(_gameRef, _gameRef->_scEngine); scr->_filename = new char[strlen(filename) + 1]; strcpy(scr->_filename, filename); scr->_state = SCRIPT_ERROR; @@ -311,7 +311,7 @@ bool CBScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::removeScript(CScScript *script) { +bool BaseScriptHolder::removeScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { _scripts.removeAt(i); @@ -322,7 +322,7 @@ bool CBScriptHolder::removeScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleEvent(const char *EventName) { +bool BaseScriptHolder::canHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; } @@ -331,7 +331,7 @@ bool CBScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleMethod(const char *MethodName) { +bool BaseScriptHolder::canHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; } @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { +bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -354,7 +354,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { @@ -403,7 +403,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { } - CScValue *val = new CScValue(_gameRef); + ScValue *val = new ScValue(_gameRef); val->setString(propValue); scSetProperty(propName, val); @@ -418,7 +418,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool freezable) { +void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->_freezable = freezable; @@ -427,11 +427,11 @@ void CBScriptHolder::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { +ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { for (int i = _scripts.getSize() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { - CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); if (thread) { bool ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { @@ -450,7 +450,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { +void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); if (_name && strcmp(_name, "") != 0) { strcat(buf, " Name: "); @@ -466,7 +466,7 @@ void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { ////////////////////////////////////////////////////////////////////////// // IWmeObject ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *eventName) { +bool BaseScriptHolder::sendEvent(const char *eventName) { return DID_SUCCEED(applyEvent(eventName)); } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 0e5bc1b7ec..52711572c1 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -35,21 +35,21 @@ namespace WinterMute { -class CBScriptHolder : public CBScriptable { +class BaseScriptHolder : public BaseScriptable { public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *methodName); + BaseScriptHolder(BaseGame *inGame); + virtual ~BaseScriptHolder(); + virtual ScScript *invokeMethodThread(const char *methodName); virtual void makeFreezable(bool freezable); bool canHandleEvent(const char *eventName); virtual bool canHandleMethod(const char *eventMethod); bool cleanup(); - bool removeScript(CScScript *script); + bool removeScript(ScScript *script); bool addScript(const char *filename); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); bool parseProperty(byte *buffer, bool complete = true); @@ -57,11 +57,11 @@ public: bool _freezable; bool _ready; - CBArray _scripts; + BaseArray _scripts; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index e9489fa407..6da67db3fb 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -33,14 +33,14 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBScriptable, false) +IMPLEMENT_PERSISTENT(BaseScriptable, false) ////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { +BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { _refCount = 0; if (noValue) _scValue = NULL; - else _scValue = new CScValue(_gameRef); + else _scValue = new ScValue(_gameRef); _persistable = persistable; @@ -49,7 +49,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa ////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { +BaseScriptable::~BaseScriptable() { //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); delete _scValue; delete _scProp; @@ -61,7 +61,7 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { /* stack->correctParams(0); stack->pushNULL(); @@ -74,72 +74,72 @@ bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(_gameRef); +ScValue *BaseScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new ScValue(_gameRef); if (_scProp) return _scProp->getProp(name); else return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(_gameRef); +bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { + if (!_scProp) _scProp = new ScValue(_gameRef); if (_scProp) return _scProp->setProp(name, value); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::scToString() { +const char *BaseScriptable::scToString() { return "[native object]"; } ////////////////////////////////////////////////////////////////////////// -void *CBScriptable::scToMemBuffer() { +void *BaseScriptable::scToMemBuffer() { return (void *)NULL; } ////////////////////////////////////////////////////////////////////////// -int CBScriptable::scToInt() { +int BaseScriptable::scToInt() { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBScriptable::scToFloat() { +double BaseScriptable::scToFloat() { return 0.0f; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scToBool() { +bool BaseScriptable::scToBool() { return false; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetString(const char *val) { +void BaseScriptable::scSetString(const char *val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetInt(int val) { +void BaseScriptable::scSetInt(int val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetFloat(double val) { +void BaseScriptable::scSetFloat(double val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetBool(bool val) { +void BaseScriptable::scSetBool(bool val) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::persist(CBPersistMgr *persistMgr) { +bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); @@ -150,25 +150,25 @@ bool CBScriptable::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *val) { +int BaseScriptable::scCompare(BaseScriptable *val) { if (this < val) return -1; else if (this > val) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { +void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::canHandleMethod(const char *eventMethod) { +bool BaseScriptable::canHandleMethod(const char *eventMethod) { return false; } ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::invokeMethodThread(const char *methodName) { +ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } @@ -176,12 +176,12 @@ CScScript *CBScriptable::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugObject ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::dbgGetNativeClass() { +const char *BaseScriptable::dbgGetNativeClass() { return getClassName(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { +IWmeDebugProp *BaseScriptable::dbgGetProperty(const char *name) { return scGetProperty(name); } diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 166f3c0bd1..b9283ed349 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -36,23 +36,23 @@ namespace WinterMute { -class CScValue; -class CScStack; -class CScScript; +class ScValue; +class ScStack; +class ScScript; -class CBScriptable : public CBNamedObject, public IWmeDebugObject { +class BaseScriptable : public BaseNamedObject, public IWmeDebugObject { public: - virtual CScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + virtual ScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) - CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); - virtual ~CBScriptable(); + BaseScriptable(BaseGame *inGame, bool noValue = false, bool persistable = true); + virtual ~BaseScriptable(); // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); virtual int scToInt(); @@ -62,11 +62,11 @@ public: virtual void scSetInt(int val); virtual void scSetFloat(double val); virtual void scSetBool(bool val); - virtual int scCompare(CBScriptable *val); + virtual int scCompare(BaseScriptable *val); virtual void scDebuggerDesc(char *buf, int bufSize); int _refCount; - CScValue *_scValue; - CScValue *_scProp; + ScValue *_scValue; + ScValue *_scProp; public: // IWmeDebugObject @@ -76,14 +76,14 @@ public: }; // Implemented in their respective .cpp-files -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXMath(CBGame *inGame); -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXStore(CBGame *inGame); -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXMath(BaseGame *inGame); +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXStore(BaseGame *inGame); +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index ba55d1b88b..046a40bacf 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -45,10 +45,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSprite, false) +IMPLEMENT_PERSISTENT(BaseSprite, false) ////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner): BaseScriptHolder(inGame) { _editorAllFrames = false; _owner = Owner; setDefaults(); @@ -56,13 +56,13 @@ CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { +BaseSprite::~BaseSprite() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBSprite::setDefaults() { +void BaseSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; @@ -87,8 +87,8 @@ void CBSprite::setDefaults() { ////////////////////////////////////////////////////////////////////////// -void CBSprite::cleanup() { - CBScriptHolder::cleanup(); +void BaseSprite::cleanup() { + BaseScriptHolder::cleanup(); for (int i = 0; i < _frames.getSize(); i++) delete _frames[i]; @@ -102,7 +102,7 @@ void CBSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { +bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; @@ -122,10 +122,10 @@ bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zo ////////////////////////////////////////////////////////////////////// -bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { - _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); else return loadFile("invalid.bmp", lifeTime, cacheType); } else { @@ -137,8 +137,8 @@ bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cac AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(_gameRef); - CBSubFrame *subframe = new CBSubFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); @@ -146,7 +146,7 @@ bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cac delete frame; delete subframe; } else { - CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + BasePlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); frame->_subframes.add(subframe); _frames.add(frame); _currentFrame = 0; @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -208,7 +208,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); cleanup(); @@ -222,7 +222,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach } int frameCount = 1; - CBFrame *frame; + BaseFrame *frame; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: @@ -287,7 +287,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach int FrameLifeTime = lifeTime; if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - frame = new CBFrame(_gameRef); + frame = new BaseFrame(_gameRef); if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; @@ -318,7 +318,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach ////////////////////////////////////////////////////////////////////// -void CBSprite::reset() { +void BaseSprite::reset() { if (_frames.getSize() > 0) _currentFrame = 0; else _currentFrame = -1; @@ -331,7 +331,7 @@ void CBSprite::reset() { ////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { +bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; @@ -383,7 +383,7 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; // on change... @@ -401,34 +401,34 @@ bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::getSurface() { +BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; + BaseFrame *Frame = _frames[_currentFrame]; if (Frame && Frame->_subframes.getSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; + BaseSubFrame *Subframe = Frame->_subframes[0]; if (Subframe) return Subframe->_surface; else return NULL; } else return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::setRectEmpty(rect); + BasePlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { Rect32 frame; Rect32 temp; - CBPlatform::copyRect(&temp, rect); + BasePlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, &temp, &frame); + BasePlatform::unionRect(rect, &temp, &frame); } return true; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); @@ -451,7 +451,7 @@ bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } - CBScriptHolder::saveAsText(buffer, indent + 2); + BaseScriptHolder::saveAsText(buffer, indent + 2); int i; @@ -472,8 +472,8 @@ bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CBSprite::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); +bool BaseSprite::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_canBreak)); persistMgr->transfer(TMEMBER(_changed)); @@ -507,7 +507,7 @@ bool CBSprite::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -526,14 +526,14 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteFrame") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (Val->isInt()) { int Index = Val->getInt(-1); if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { - CBFrame *Frame = (CBFrame *)Val->getNative(); + BaseFrame *Frame = (BaseFrame *)Val->getNative(); for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i] == Frame) { if (i == _currentFrame) _lastFrameTime = 0; @@ -562,13 +562,13 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddFrame") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.add(sub); @@ -589,14 +589,14 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt if (index < 0) index = 0; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); else delete sub; } @@ -629,12 +629,12 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); + else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *name) { +ScValue *BaseSprite::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -702,12 +702,12 @@ CScValue *CBSprite::scGetProperty(const char *name) { return _scValue; } - else return CBScriptHolder::scGetProperty(name); + else return BaseScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::scSetProperty(const char *name, CScValue *value) { +bool BaseSprite::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// @@ -736,18 +736,18 @@ bool CBSprite::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptHolder::scSetProperty(name, value); + else return BaseScriptHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSprite::scToString() { +const char *BaseSprite::scToString() { return "[sprite]"; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::killAllSounds() { +bool BaseSprite::killAllSounds() { for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i]->_sound) _frames[i]->_sound->stop(); diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 8f3ce84eb4..6ddec287d6 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -34,13 +34,13 @@ #include "engines/wintermute/base/base_script_holder.h" namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { +class BaseFrame; +class BaseSurface; +class BaseObject; +class BaseSprite: public BaseScriptHolder { public: bool killAllSounds(); - CBSurface *getSurface(); + BaseSurface *getSurface(); char *_editorBgFile; int _editorBgOffsetX; int _editorBgOffsetY; @@ -50,38 +50,38 @@ public: void cleanup(); void setDefaults(); bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) bool _editorAllFrames; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; - bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; bool _continuous; void reset(); - CBObject *_owner; + BaseObject *_owner; bool _changed; bool _paused; bool _finished; bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; - bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - CBSprite(CBGame *inGame, CBObject *owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - bool saveAsText(CBDynBuffer *buffer, int indent); + BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); + virtual ~BaseSprite(); + BaseArray _frames; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index c7789add9d..7ac79d4745 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -36,13 +36,13 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { +BaseStringTable::BaseStringTable(BaseGame *inGame): BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { +BaseStringTable::~BaseStringTable() { // delete strings _strings.clear(); @@ -50,7 +50,7 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { +bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { if (key == NULL || val == NULL) return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { @@ -70,7 +70,7 @@ bool CBStringTable::addString(const char *key, const char *val, bool reportDupli } ////////////////////////////////////////////////////////////////////////// -char *CBStringTable::getKey(const char *str) { +char *BaseStringTable::getKey(const char *str) { if (str == NULL || str[0] != '/') return NULL; const char *value = strchr(str + 1, '/'); @@ -79,7 +79,7 @@ char *CBStringTable::getKey(const char *str) { char *key = new char[value - str]; strncpy(key, str + 1, value - str - 1); key[value - str - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); char *new_str; @@ -102,7 +102,7 @@ char *CBStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void CBStringTable::expand(char **str, bool forceExpand) { +void BaseStringTable::expand(char **str, bool forceExpand) { if (_gameRef->_doNotExpandStrings && !forceExpand) return; if (str == NULL || *str == NULL || *str[0] != '/') return; @@ -113,7 +113,7 @@ void CBStringTable::expand(char **str, bool forceExpand) { char *key = new char[value - *str]; strncpy(key, *str + 1, value - *str - 1); key[value - *str - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); value++; @@ -137,7 +137,7 @@ void CBStringTable::expand(char **str, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { +const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) { if (_gameRef->_doNotExpandStrings && !forceExpand) return string; if (string == NULL || string[0] == '\0' || string[0] != '/') return string; @@ -148,7 +148,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { char *key = new char[value - string]; strncpy(key, string + 1, value - string - 1); key[value - string - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); value++; @@ -169,7 +169,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -bool CBStringTable::loadFile(const char *filename, bool clearOld) { +bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); if (clearOld) _strings.clear(); @@ -177,7 +177,7 @@ bool CBStringTable::loadFile(const char *filename, bool clearOld) { uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { - _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index c612c33a41..ac46aaee43 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -35,14 +35,14 @@ namespace WinterMute { -class CBStringTable : public CBBase { +class BaseStringTable : public BaseClass { public: const char *expandStatic(const char *string, bool forceExpand = false); bool loadFile(const char *filename, bool deleteAll = true); void expand(char **str, bool forceExpand = false); bool addString(const char *key, const char *val, bool reportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); + BaseStringTable(BaseGame *inGame); + virtual ~BaseStringTable(); Common::HashMap _strings; char *getKey(const char *str); private: diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index adce6c6b75..d6a8c2490f 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -40,16 +40,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSubFrame, false) +IMPLEMENT_PERSISTENT(BaseSubFrame, false) ////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { +BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { _surface = NULL; _hotspotX = _hotspotY = 0; _alpha = 0xFFFFFFFF; _transparent = 0xFFFF00FF; - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _editorSelected = false; @@ -67,7 +67,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { +BaseSubFrame::~BaseSubFrame() { if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -109,12 +109,12 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; - CBPlatform::setRectEmpty(&rect); + BasePlatform::setRectEmpty(&rect); char *surfaceFile = NULL; delete _surface; @@ -196,7 +196,7 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } */ - if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + if (BasePlatform::isRectEmpty(&rect)) setDefaultRect(); else _rect = rect; return STATUS_OK; @@ -204,14 +204,14 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////// -bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { +bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (!_surface) return STATUS_OK; if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) return STATUS_OK; @@ -233,13 +233,13 @@ bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; - CBPlatform::setRect(rect, + BasePlatform::setRect(rect, (int)(x - _hotspotX * ratioX), (int)(y - _hotspotY * ratioY), (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), @@ -249,7 +249,7 @@ bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { +bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); @@ -260,9 +260,9 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); Rect32 rect; - CBPlatform::setRectEmpty(&rect); - if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::equalRect(&rect, &_rect)) + BasePlatform::setRectEmpty(&rect); + if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!BasePlatform::equalRect(&rect, &_rect)) buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) @@ -291,7 +291,7 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { if (_editorSelected) buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); if (complete) @@ -302,17 +302,17 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { ////////////////////////////////////////////////////////////////////////// -void CBSubFrame::setDefaultRect() { +void BaseSubFrame::setDefaultRect() { if (_surface) { - CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else BasePlatform::setRectEmpty(&_rect); } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::persist(CBPersistMgr *persistMgr) { +bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); @@ -342,7 +342,7 @@ bool CBSubFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -360,7 +360,7 @@ bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (Val->isNULL()) { if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); @@ -378,13 +378,13 @@ bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this return STATUS_OK; } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); +ScValue *BaseSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new ScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -468,12 +468,12 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { +bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// @@ -538,18 +538,18 @@ bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptable::scSetProperty(name, value); + else return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::scToString() { +const char *BaseSubFrame::scToString() { return "[subframe]"; } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -576,7 +576,7 @@ bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, by ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurfaceSimple() { +bool BaseSubFrame::setSurfaceSimple() { if (!_surfaceFilename) { _surface = NULL; return STATUS_OK; diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 6fb24c0e4f..52b1d76c01 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -34,25 +34,25 @@ #include "engines/wintermute/base/base_scriptable.h" namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { +class BaseObject; +class BaseSurface; +class BaseSubFrame : public BaseScriptable { public: bool _mirrorX; bool _mirrorY; bool _decoration; bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool setSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) void setDefaultRect(); uint32 _transparent; - bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); + BaseSubFrame(BaseGame *inGame); + virtual ~BaseSubFrame(); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; @@ -71,12 +71,12 @@ public: bool _2DOnly; bool _3DOnly; - CBSurface *_surface; + BaseSurface *_surface; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 06c2f1b0cc..7067c2a607 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -36,24 +36,24 @@ namespace WinterMute { -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); +//IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); ////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame): BaseClass(inGame) { _lastCleanupTime = 0; } ////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { +BaseSurfaceStorage::~BaseSurfaceStorage() { cleanup(true); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::cleanup(bool warn) { +bool BaseSurfaceStorage::cleanup(bool warn) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + if (warn) _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.clear(); @@ -63,7 +63,7 @@ bool CBSurfaceStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::initLoop() { +bool BaseSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); @@ -81,7 +81,7 @@ bool CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::removeSurface(CBSurface *surface) { +bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; @@ -97,7 +97,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (uint32 i = 0; i < _surfaces.size(); i++) { if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; @@ -113,7 +113,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); } - CBSurface *surface; + BaseSurface *surface; surface = _gameRef->_renderer->createSurface(); if (!surface) return NULL; @@ -130,12 +130,12 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::restoreAll() { +bool BaseSurfaceStorage::restoreAll() { bool ret; for (uint32 i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { - _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); return ret; } } @@ -145,7 +145,7 @@ bool CBSurfaceStorage::restoreAll() { /* ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { if(!persistMgr->_saving) cleanup(false); @@ -160,16 +160,16 @@ bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); +bool BaseSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(BaseSurface *), surfaceSortCB); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); +int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + BaseSurface *s1 = *((BaseSurface **)arg1); + BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 58f25e6875..350210b95e 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -33,23 +33,23 @@ #include "common/array.h" namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { +class BaseSurface; +class BaseSurfaceStorage : public BaseClass { public: uint32 _lastCleanupTime; bool initLoop(); bool sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); bool cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); - CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); + BaseSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(BaseSurface *surface); + BaseSurfaceStorage(BaseGame *inGame); + virtual ~BaseSurfaceStorage(); - Common::Array _surfaces; + Common::Array _surfaces; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 30a1a32e6a..b524636af7 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame): BaseClass(inGame) { _state = TRANS_MGR_READY; _type = TRANSITION_NONE; _origInteractive = false; @@ -46,19 +46,19 @@ CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { +BaseTransitionMgr::~BaseTransitionMgr() { } ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::isReady() { +bool BaseTransitionMgr::isReady() { return (_state == TRANS_MGR_READY); } ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { +bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { if (_state != TRANS_MGR_READY) return STATUS_OK; if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { @@ -83,12 +83,12 @@ bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { #define FADE_DURATION 200 ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::update() { +bool BaseTransitionMgr::update() { if (isReady()) return STATUS_OK; if (!_started) { _started = true; - _lastTime = CBPlatform::getTime(); + _lastTime = BasePlatform::getTime(); } switch (_type) { @@ -97,7 +97,7 @@ bool CBTransitionMgr::update() { break; case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::getTime() - _lastTime; + uint32 time = BasePlatform::getTime() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -108,7 +108,7 @@ bool CBTransitionMgr::update() { break; case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::getTime() - _lastTime; + uint32 time = BasePlatform::getTime() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -118,7 +118,7 @@ bool CBTransitionMgr::update() { } break; default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + error("BaseTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); } if (isReady()) { diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 9b84c653e9..104f327fb8 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -33,7 +33,7 @@ namespace WinterMute { -class CBTransitionMgr : public CBBase { +class BaseTransitionMgr : public BaseClass { public: bool _started; uint32 _lastTime; @@ -43,8 +43,8 @@ public: bool start(TTransitionType type, bool nonInteractive = false); bool isReady(); TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); + BaseTransitionMgr(BaseGame *inGame); + virtual ~BaseTransitionMgr(); TTransitionType _type; }; diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index 83cbc5b0f0..ad875ec00d 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -32,24 +32,24 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBViewport, false) +IMPLEMENT_PERSISTENT(BaseViewport, false) ////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); +BaseViewport::BaseViewport(BaseGame *inGame): BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); _mainObject = NULL; _offsetX = _offsetY = 0; } ////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { +BaseViewport::~BaseViewport() { } ////////////////////////////////////////////////////////////////////////// -bool CBViewport::persist(CBPersistMgr *persistMgr) { +bool BaseViewport::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -63,7 +63,7 @@ bool CBViewport::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { +bool BaseViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); @@ -71,7 +71,7 @@ bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) bottom = MIN(bottom, _gameRef->_renderer->_height); } - CBPlatform::setRect(&_rect, left, top, right, bottom); + BasePlatform::setRect(&_rect, left, top, right, bottom); _offsetX = left; _offsetY = top; return STATUS_OK; @@ -79,19 +79,19 @@ bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) ////////////////////////////////////////////////////////////////////////// -Rect32 *CBViewport::getRect() { +Rect32 *BaseViewport::getRect() { return &_rect; } ////////////////////////////////////////////////////////////////////////// -int CBViewport::getWidth() { +int BaseViewport::getWidth() { return _rect.right - _rect.left; } ////////////////////////////////////////////////////////////////////////// -int CBViewport::getHeight() { +int BaseViewport::getHeight() { return _rect.bottom - _rect.top; } diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 795e6f404f..33e9448082 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -33,19 +33,19 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { +class BaseObject; +class BaseViewport : public BaseClass { public: int getHeight(); int getWidth(); Rect32 *getRect(); bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) + DECLARE_PERSISTENT(BaseViewport, BaseClass) int _offsetY; int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); + BaseObject *_mainObject; + BaseViewport(BaseGame *inGame = NULL); + virtual ~BaseViewport(); private: Rect32 _rect; }; diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 3acde9c1ff..5e1ebc5922 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -39,6 +39,9 @@ namespace WinterMute { +// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size +// as such it is not renamed to follow the convention of the rest of the files. + // HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. class CBPkgFile : public Common::SeekableReadStream { uint32 _size; @@ -65,8 +68,8 @@ public: } }; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { - CBFileEntry *fileEntry; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager) { + BaseFileEntry *fileEntry; Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH_LENGTH]; strcpy(fileName, filename.c_str()); diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index 4356ae5519..ca1b1f837d 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -41,8 +41,8 @@ class File; namespace WinterMute { -class CBFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); +class BaseFileManager; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 99bf9cff3f..6c89fc22f1 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -45,7 +45,7 @@ void correctSlashes(char *fileName) { } } -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { +Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 23e1a0a315..e688a12b50 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -35,7 +35,7 @@ class SeekableReadStream; namespace WinterMute { -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); +Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 88a64cb147..d4109bb259 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -38,24 +38,24 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { +BaseFile::BaseFile(BaseGame *inGame): BaseClass(inGame) { _pos = 0; _size = 0; } ////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { +BaseFile::~BaseFile() { } ////////////////////////////////////////////////////////////////////////// -bool CBFile::isEOF() { +bool BaseFile::isEOF() { return _pos == _size; } -Common::SeekableReadStream *CBFile::getMemStream() { +Common::SeekableReadStream *BaseFile::getMemStream() { uint32 oldPos = getPos(); seek(0); byte *data = new byte[getSize()]; diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index b29fc41299..1a144414fc 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -40,7 +40,7 @@ class SeekableReadStream; namespace WinterMute { -class CBFile : public CBBase { +class BaseFile : public BaseClass { protected: uint32 _pos; uint32 _size; @@ -56,8 +56,8 @@ public: virtual bool close() = 0; virtual bool open(const Common::String &filename) = 0; virtual bool isEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); + BaseFile(BaseGame *inGame); + virtual ~BaseFile(); // Temporary solution to allow usage in ScummVM-code: virtual Common::SeekableReadStream *getMemStream(); }; diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 3b6f4c7c16..d3e0fee7b0 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -31,7 +31,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { +BaseFileEntry::BaseFileEntry(BaseGame *inGame): BaseClass(inGame) { _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; @@ -43,7 +43,7 @@ CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { +BaseFileEntry::~BaseFileEntry() { _package = NULL; // ref only } diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index ed80821004..0e0375e42d 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -34,9 +34,9 @@ namespace WinterMute { -class CBPackage; +class BasePackage; -class CBFileEntry : public CBBase { +class BaseFileEntry : public BaseClass { public: uint32 _timeDate2; uint32 _timeDate1; @@ -46,9 +46,9 @@ public: uint32 _compressedLength; uint32 _length; uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); + BasePackage *_package; + BaseFileEntry(BaseGame *inGame); + virtual ~BaseFileEntry(); }; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index fab6409c00..03a80f3d8d 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { +BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { _file = NULL; _name = NULL; _cD = 0; @@ -50,14 +50,14 @@ CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { +BasePackage::~BasePackage() { if (_name) delete [] _name; closeFilePointer(_file); } ////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { +bool BasePackage::open() { if (_file) return STATUS_OK; else { _file = getFilePointer(); @@ -67,7 +67,7 @@ bool CBPackage::open() { ////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { +bool BasePackage::close() { delete _file; _file = NULL; return STATUS_OK; @@ -75,7 +75,7 @@ bool CBPackage::close() { ////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { +bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { bool ret; if (DID_FAIL(ret = open())) return ret; else { @@ -86,7 +86,7 @@ bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buff } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { +Common::SeekableReadStream *BasePackage::getFilePointer() { Common::File *file = _gameRef->_fileManager->openPackage(_name); if (!file) { _gameRef->_fileManager->requestCD(_cD, _name, ""); @@ -96,7 +96,7 @@ Common::SeekableReadStream *CBPackage::getFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { +void BasePackage::closeFilePointer(Common::SeekableReadStream *&file) { delete file; file = NULL; } diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 52fc4f9677..bf45087f91 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -38,7 +38,7 @@ class SeekableReadStream; namespace WinterMute { -class CBPackage : public CBBase { +class BasePackage : public BaseClass { public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); @@ -51,8 +51,8 @@ public: char *_name; int _cD; Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); + BasePackage(BaseGame *inGame); + virtual ~BasePackage(); }; diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 09cbae88fe..9b1c9fee04 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2806,7 +2806,7 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; -Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { +Common::SeekableReadStream *BaseResources::getFile(const Common::String &fileName) { if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 6ec0541b5c..6316cecd15 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBResources { +class BaseResources { public: static Common::SeekableReadStream *getFile(const Common::String &fileName); }; diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 68200d3fc6..a2295b70a5 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -39,19 +39,19 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame): BaseFile(inGame) { _data = NULL; } ////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { +BaseSaveThumbFile::~BaseSaveThumbFile() { close(); } ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::open(const Common::String &filename) { +bool BaseSaveThumbFile::open(const Common::String &filename) { close(); if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; @@ -71,7 +71,7 @@ bool CBSaveThumbFile::open(const Common::String &filename) { char slotFilename[MAX_PATH_LENGTH + 1]; _gameRef->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; _gameRef->_debugAbsolutePathWarning = false; @@ -97,7 +97,7 @@ bool CBSaveThumbFile::open(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::close() { +bool BaseSaveThumbFile::close() { delete[] _data; _data = NULL; @@ -109,7 +109,7 @@ bool CBSaveThumbFile::close() { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::read(void *buffer, uint32 size) { +bool BaseSaveThumbFile::read(void *buffer, uint32 size) { if (!_data || _pos + size > _size) return STATUS_FAILED; memcpy(buffer, (byte *)_data + _pos, size); @@ -120,7 +120,7 @@ bool CBSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::seek(uint32 pos, int whence) { +bool BaseSaveThumbFile::seek(uint32 pos, int whence) { if (!_data) return STATUS_FAILED; uint32 newPos = 0; diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 42566581e2..6065f10f81 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -35,10 +35,10 @@ namespace WinterMute { //TODO: Get rid of this -class CBSaveThumbFile : public CBFile { +class BaseSaveThumbFile : public BaseFile { public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); + BaseSaveThumbFile(BaseGame *Game); + virtual ~BaseSaveThumbFile(); virtual bool seek(uint32 pos, int whence = SEEK_SET); virtual bool read(void *buffer, uint32 size); virtual bool close(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 8976cfdabd..0c86517fc7 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -40,42 +40,42 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFont, false) +IMPLEMENT_PERSISTENT(BaseFont, false) ////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { +BaseFont::BaseFont(BaseGame *inGame): BaseObject(inGame) { } ////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { +BaseFont::~BaseFont() { } ////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { +int BaseFont::getTextHeight(byte *text, int width) { return 0; } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { +int BaseFont::getTextWidth(byte *text, int maxLength) { return 0; } /* ////////////////////////////////////////////////////////////////////// -bool CBFont::loadFile(const char * Filename) +bool BaseFont::loadFile(const char * Filename) { BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); if(Buffer==NULL){ - _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFont::loadBuffer(byte * Buffer) +bool BaseFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -104,7 +104,7 @@ bool CBFont::loadBuffer(byte * Buffer) char* params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); @@ -138,23 +138,23 @@ bool CBFont::loadBuffer(byte * Buffer) */ ////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { +int BaseFont::getLetterHeight() { return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBFont::persist(CBPersistMgr *persistMgr) { +bool BaseFont::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const char *filename) { if (isTrueType(gameRef, filename)) { - CBFontTT *font = new CBFontTT(gameRef); + BaseFontTT *font = new BaseFontTT(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -163,7 +163,7 @@ CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { } return font; } else { - CBFontBitmap *font = new CBFontBitmap(gameRef); + BaseFontBitmap *font = new BaseFontBitmap(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -180,7 +180,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { +bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) @@ -193,7 +193,7 @@ bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { byte *WorkBuffer = buffer; char *params; - CBParser parser(gameRef); + BaseParser parser(gameRef); bool ret = false; if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 3df3090bb9..695bce2af3 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -35,9 +35,9 @@ namespace WinterMute { -class CBFont: public CBObject { +class BaseFont: public BaseObject { public: - DECLARE_PERSISTENT(CBFont, CBObject) + DECLARE_PERSISTENT(BaseFont, BaseObject) virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); @@ -45,15 +45,15 @@ public: virtual void initLoop() {}; virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); + BaseFont(BaseGame *inGame); + virtual ~BaseFont(); - static CBFont *createFromFile(CBGame *game, const char *filename); + static BaseFont *createFromFile(BaseGame *game, const char *filename); private: //bool loadBuffer(byte * Buffer); //bool loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); + static bool isTrueType(BaseGame *game, const char *filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ef730afb0a..a913cc52ba 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -45,10 +45,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFontBitmap, false) +IMPLEMENT_PERSISTENT(BaseFontBitmap, false) ////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame): BaseFont(inGame) { _subframe = NULL; _sprite = NULL; _widthsFrame = 0; @@ -61,7 +61,7 @@ CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { ////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { +BaseFontBitmap::~BaseFontBitmap() { delete _subframe; delete _sprite; _subframe = NULL; @@ -70,19 +70,19 @@ CBFontBitmap::~CBFontBitmap() { ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { textHeightDraw(text, x, y, width, align, true, max_height, maxLength); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { +int BaseFontBitmap::getTextHeight(byte *text, int width) { return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { +int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { AnsiString str; if (_gameRef->_textEncoding == TEXT_UTF8) { @@ -106,7 +106,7 @@ int CBFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { +int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { if (maxLength == 0) return 0; if (text == NULL || text[0] == '\0') return _tileHeight; @@ -187,7 +187,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign StartX = x; break; default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); break; } for (i = start; i < end + 1; i++) { @@ -213,7 +213,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { +void BaseFontBitmap::drawChar(byte c, int x, int y) { if (_fontextFix) c--; int row, col; @@ -227,7 +227,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { if (_wholeCell) tileWidth = _tileWidth; else tileWidth = _widths[c]; - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; if (_sprite) { _sprite->GetCurrentFrame(); @@ -243,10 +243,10 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadFile(const char *filename) { +bool BaseFontBitmap::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -282,7 +282,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadBuffer(byte *buffer) { +bool BaseFontBitmap::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -304,7 +304,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { _gameRef->LOG(0, "'FONT' keyword expected."); @@ -401,7 +401,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { if (spriteFile != NULL) { delete _sprite; - _sprite = new CBSprite(_gameRef, this); + _sprite = new BaseSprite(_gameRef, this); if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { delete _sprite; _sprite = NULL; @@ -409,7 +409,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { } if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(_gameRef); + _subframe = new BaseSubFrame(_gameRef); if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); else _subframe->setSurface(surfaceFile); } @@ -454,9 +454,9 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { +bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { - CBFont::persist(persistMgr); + BaseFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_numColumns)); persistMgr->transfer(TMEMBER(_subframe)); @@ -480,15 +480,15 @@ bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { +int BaseFontBitmap::getCharWidth(byte index) { if (_fontextFix) index--; return _widths[index]; } ////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::getWidths() { - CBSurface *surf = NULL; +bool BaseFontBitmap::getWidths() { + BaseSurface *surf = NULL; if (_sprite) { if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { @@ -533,7 +533,7 @@ bool CBFontBitmap::getWidths() { } ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { +int BaseFontBitmap::getLetterHeight() { return _tileHeight; } diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 8af530cbc9..8a4f5af570 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -33,10 +33,10 @@ #include "engines/wintermute/base/font/base_font.h" namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { +class BaseSubFrame; +class BaseFontBitmap : public BaseFont { public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) + DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) bool loadBuffer(byte *Buffer); bool loadFile(const char *filename); virtual int getTextWidth(byte *text, int maxLength = -1); @@ -44,19 +44,19 @@ public: virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); + BaseFontBitmap(BaseGame *inGame); + virtual ~BaseFontBitmap(); bool getWidths(); - CBSprite *_sprite; + BaseSprite *_sprite; int _widthsFrame; bool _fontextFix; int _numColumns; int _tileHeight; int _tileWidth; byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; + BaseSubFrame *_subframe; bool _wholeCell; private: diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 13f779f2cb..220a16e14f 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -39,19 +39,19 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFontStorage, true) +IMPLEMENT_PERSISTENT(BaseFontStorage, true) ////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +BaseFontStorage::BaseFontStorage(BaseGame *inGame): BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { +BaseFontStorage::~BaseFontStorage() { cleanup(true); } ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::cleanup(bool warn) { +bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; @@ -62,7 +62,7 @@ bool CBFontStorage::cleanup(bool warn) { } ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::initLoop() { +bool BaseFontStorage::initLoop() { for (int i = 0; i < _fonts.getSize(); i++) { _fonts[i]->initLoop(); } @@ -70,7 +70,7 @@ bool CBFontStorage::initLoop() { } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { +BaseFont *BaseFontStorage::addFont(const char *filename) { if (!filename) return NULL; for (int i = 0; i < _fonts.getSize(); i++) { @@ -81,7 +81,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { } /* - CBFont* font = new CBFont(_gameRef); + BaseFont* font = new BaseFont(_gameRef); if (!font) return NULL; if (DID_FAIL(font->loadFile(filename))) { @@ -94,7 +94,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { return font; } */ - CBFont *font = CBFont::createFromFile(_gameRef, filename); + BaseFont *font = BaseFont::createFromFile(_gameRef, filename); if (font) { font->_refCount = 1; _fonts.add(font); @@ -104,7 +104,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::removeFont(CBFont *font) { +bool BaseFontStorage::removeFont(BaseFont *font) { if (!font) return STATUS_FAILED; for (int i = 0; i < _fonts.getSize(); i++) { @@ -122,7 +122,7 @@ bool CBFontStorage::removeFont(CBFont *font) { ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::persist(CBPersistMgr *persistMgr) { +bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(false); diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 7c88e9a2f4..2c9c6817c3 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -36,17 +36,17 @@ namespace WinterMute { -class CBFont; +class BaseFont; -class CBFontStorage : public CBBase { +class BaseFontStorage : public BaseClass { public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) + DECLARE_PERSISTENT(BaseFontStorage, BaseClass) bool cleanup(bool warn = false); - bool removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; + bool removeFont(BaseFont *font); + BaseFont *addFont(const char *filename); + BaseFontStorage(BaseGame *inGame); + virtual ~BaseFontStorage(); + BaseArray _fonts; bool initLoop(); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index a52922fb76..bcf8621a40 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -46,10 +46,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBFontTT, false) +IMPLEMENT_PERSISTENT(BaseFontTT, false) ////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { +BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _fontHeight = 12; _isBold = _isItalic = _isUnderline = _isStriked = false; @@ -71,7 +71,7 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { +BaseFontTT::~BaseFontTT(void) { clearCache(); for (int i = 0; i < _layers.getSize(); i++) { @@ -97,7 +97,7 @@ CBFontTT::~CBFontTT(void) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { +void BaseFontTT::clearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i]) delete _cachedTexts[i]; _cachedTexts[i] = NULL; @@ -105,7 +105,7 @@ void CBFontTT::clearCache() { } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { +void BaseFontTT::initLoop() { // we need more aggressive cache management on iOS not to waste too much memory on fonts if (_gameRef->_constrainedMemory) { // purge all cached images not used in the last frame @@ -121,7 +121,7 @@ void CBFontTT::initLoop() { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { +int BaseFontTT::getTextWidth(byte *text, int maxLength) { WideString textStr; if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); @@ -138,7 +138,7 @@ int CBFontTT::getTextWidth(byte *text, int maxLength) { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { +int BaseFontTT::getTextHeight(byte *text, int width) { WideString textStr; if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); @@ -153,7 +153,7 @@ int CBFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { if (text == NULL || strcmp((char *)text, "") == 0) return; WideString textStr = (char *)text; @@ -166,12 +166,12 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove - CBRenderer *renderer = _gameRef->_renderer; + BaseRenderer *renderer = _gameRef->_renderer; // find cached surface, if exists int minPriority = INT_MAX; int minIndex = -1; - CBSurface *surface = NULL; + BaseSurface *surface = NULL; int textOffset = 0; for (int i = 0; i < NUM_CACHED_TEXTS; i++) { @@ -201,7 +201,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i if (surface) { // write surface to cache if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; + _cachedTexts[minIndex] = new BaseCachedTTFontText; _cachedTexts[minIndex]->_surface = surface; _cachedTexts[minIndex]->_align = align; @@ -219,7 +219,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = renderer->_forceAlphaColor; @@ -237,7 +237,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i } ////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { +BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { //TextLineList lines; // TODO //WrapText(text, width, maxHeight, lines); @@ -256,7 +256,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex static bool hasWarned = false; if (!hasWarned) { hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + warning("BaseFontTT::RenderTextToTexture - Not fully ported yet"); } debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); @@ -274,7 +274,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex heightOffset += (int)_lineHeight; } - CBSurface *retSurface = _gameRef->_renderer->createSurface(); + BaseSurface *retSurface = _gameRef->_renderer->createSurface(); Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); @@ -363,7 +363,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex posY += GetLineHeight(); } - CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + BaseSurfaceOSystem *wmeSurface = new BaseSurfaceOSystem(_gameRef); if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { SDL_FreeSurface(surface); return wmeSurface; @@ -377,9 +377,9 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { +void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); + warning("BaseFontTT::BlitSurface - not ported yet"); #if 0 for (int y = 0; y < src->h; y++) { if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; @@ -401,16 +401,16 @@ void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Co } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { +int BaseFontTT::getLetterHeight() { return (int)getLineHeight(); } ////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadFile(const char *filename) { +bool BaseFontTT::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -444,7 +444,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadBuffer(byte *buffer) { +bool BaseFontTT::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -462,7 +462,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { _gameRef->LOG(0, "'TTFONT' keyword expected."); @@ -483,7 +483,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { break; case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); + BaseUtils::setString(&_fontFile, params); break; case TOKEN_BOLD: @@ -521,7 +521,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { break; case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; + BaseTTFontLayer *Layer = new BaseTTFontLayer; if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); else { delete Layer; @@ -540,19 +540,19 @@ bool CBFontTT::loadBuffer(byte *buffer) { // create at least one layer if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; + BaseTTFontLayer *Layer = new BaseTTFontLayer; Layer->_color = BaseColor; _layers.add(Layer); } - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + if (!_fontFile) BaseUtils::setString(&_fontFile, "arial.ttf"); return initFont(); } ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { +bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -562,7 +562,7 @@ bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -595,8 +595,8 @@ bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); +bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { + BaseFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_isBold)); persistMgr->transfer(TMEMBER(_isItalic)); @@ -616,7 +616,7 @@ bool CBFontTT::persist(CBPersistMgr *persistMgr) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; + BaseTTFontLayer *layer = new BaseTTFontLayer; layer->persist(persistMgr); _layers.add(layer); } @@ -632,18 +632,18 @@ bool CBFontTT::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { +void BaseFontTT::afterLoad() { initFont(); } ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::initFont() { +bool BaseFontTT::initFont() { if (!_fontFile) return STATUS_FAILED; Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); @@ -659,7 +659,7 @@ bool CBFontTT::initFont() { } if (!_font) { _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + warning("BaseFontTT::InitFont - Couldn't load %s", _fontFile); } _lineHeight = _font->getFontHeight(); return STATUS_OK; @@ -673,8 +673,8 @@ bool CBFontTT::initFont() { _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; memset(_fTStream, 0, sizeof(*_fTStream)); - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->read = BaseFontTT::FTReadSeekProc; + _fTStream->close = BaseFontTT::FTCloseProc; _fTStream->descriptor.pointer = file; _fTStream->size = file->GetSize(); @@ -725,7 +725,7 @@ bool CBFontTT::initFont() { } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { +void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; // TODO: This function gets called a lot, so warnings like these drown out the usefull information static bool hasWarned = false; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 4d8e71a3ff..8a8459b070 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -40,22 +40,22 @@ namespace WinterMute { -class CBFontTT : public CBFont { +class BaseFontTT : public BaseFont { private: ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { + class BaseCachedTTFontText { public: WideString _text; int _width; TTextAlign _align; int _maxHeight; int _maxLength; - CBSurface *_surface; + BaseSurface *_surface; int _priority; int _textOffset; bool _marked; - CBCachedTTFontText() { + BaseCachedTTFontText() { //_text = L""; _text = ""; _width = _maxHeight = _maxLength = -1; @@ -66,21 +66,21 @@ private: _marked = false; } - virtual ~CBCachedTTFontText() { + virtual ~BaseCachedTTFontText() { if (_surface) delete _surface; } }; public: ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { + class BaseTTFontLayer { public: - CBTTFontLayer() { + BaseTTFontLayer() { _offsetX = _offsetY = 0; _color = 0x00000000; } - bool persist(CBPersistMgr *persistMgr) { + bool persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_offsetX)); persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_color)); @@ -114,9 +114,9 @@ public: public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); + DECLARE_PERSISTENT(BaseFontTT, BaseFont) + BaseFontTT(BaseGame *inGame); + virtual ~BaseFontTT(void); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); @@ -134,16 +134,16 @@ public: void initLoop(); private: - bool parseLayer(CBTTFontLayer *layer, byte *buffer); + bool parseLayer(BaseTTFontLayer *layer, byte *buffer); void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; bool initFont(); @@ -170,7 +170,7 @@ public: int _fontHeight; char *_fontFile; - CBArray _layers; + BaseArray _layers; void clearCache(); }; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index fb6b23db2b..533c3a866e 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -44,7 +44,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +BaseImage::BaseImage(BaseGame *inGame, FIBITMAP *bitmap): BaseClass(inGame) { #if 0 _bitmap = bitmap; #endif @@ -57,7 +57,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBImage::~CBImage() { +BaseImage::~BaseImage() { /* delete _bitmap; */ delete _decoder; if (_deletableSurface) { @@ -69,7 +69,7 @@ CBImage::~CBImage() { #endif } -bool CBImage::loadFile(const Common::String &filename) { +bool BaseImage::loadFile(const Common::String &filename) { _filename = filename; _filename.toLowercase(); if (StringUtil::startsWith(filename, "savegame:", true)) { @@ -83,7 +83,7 @@ bool CBImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { - error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); } _filename = filename; Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); @@ -97,7 +97,7 @@ bool CBImage::loadFile(const Common::String &filename) { return STATUS_OK; } -byte CBImage::getAlphaAt(int x, int y) { +byte BaseImage::getAlphaAt(int x, int y) { if (!_surface) return 0xFF; uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; @@ -105,13 +105,13 @@ byte CBImage::getAlphaAt(int x, int y) { return a; } -void CBImage::copyFrom(Graphics::Surface *surface) { +void BaseImage::copyFrom(Graphics::Surface *surface) { _surface = _deletableSurface = new Graphics::Surface(); _deletableSurface->copyFrom(*surface); } ////////////////////////////////////////////////////////////////////////// -bool CBImage::saveBMPFile(const char *filename) { +bool BaseImage::saveBMPFile(const char *filename) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -123,7 +123,7 @@ bool CBImage::saveBMPFile(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::resize(int newWidth, int newHeight) { +bool BaseImage::resize(int newWidth, int newHeight) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -143,7 +143,7 @@ bool CBImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::writeBMPToStream(Common::WriteStream *stream) { +bool BaseImage::writeBMPToStream(Common::WriteStream *stream) { if (!_surface) return false; /* The following is just copied over and inverted to write-ops from the BMP-decoder */ @@ -247,7 +247,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { #if 0 if (_bitmap) FreeImage_Unload(_bitmap); diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 6cda3e6b46..4b43e36a6d 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -40,12 +40,12 @@ struct FIBITMAP; namespace WinterMute { -class CBSurface; -class CBImage: CBBase { +class BaseSurface; +class BaseImage: BaseClass { public: - CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); - ~CBImage(); + BaseImage(BaseGame *inGame, FIBITMAP *bitmap = NULL); + ~BaseImage(); bool loadFile(const Common::String &filename); const Graphics::Surface *getSurface() const { @@ -58,7 +58,7 @@ public: bool writeBMPToStream(Common::WriteStream *stream); bool resize(int newWidth, int newHeight); bool saveBMPFile(const char *filename); - bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); void copyFrom(Graphics::Surface *surface); private: Common::String _filename; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index a8c19362f6..c46115d70a 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { +BaseRenderer::BaseRenderer(BaseGame *inGame): BaseClass(inGame) { _window = 0; _clipperWindow = 0; _active = false; @@ -46,7 +46,7 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { _forceAlphaColor = 0x00; _width = _height = _bPP = 0; - CBPlatform::setRectEmpty(&_monitorRect); + BasePlatform::setRectEmpty(&_monitorRect); _realWidth = _realHeight = 0; _drawOffsetX = _drawOffsetY = 0; @@ -54,26 +54,26 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBRenderer::~CBRenderer() { +BaseRenderer::~BaseRenderer() { deleteRectList(); unclipCursor(); } ////////////////////////////////////////////////////////////////////// -void CBRenderer::initLoop() { +void BaseRenderer::initLoop() { deleteRectList(); } ////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::getObjectAt(int x, int y) { +BaseObject *BaseRenderer::getObjectAt(int x, int y) { Point32 point; point.x = x; point.y = y; for (int i = _rectList.getSize() - 1; i >= 0; i--) { - if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { @@ -100,12 +100,12 @@ CBObject *CBRenderer::getObjectAt(int x, int y) { } } - return (CBObject *)NULL; + return (BaseObject *)NULL; } ////////////////////////////////////////////////////////////////////////// -void CBRenderer::deleteRectList() { +void BaseRenderer::deleteRectList() { for (int i = 0; i < _rectList.getSize(); i++) { delete _rectList[i]; } @@ -115,58 +115,58 @@ void CBRenderer::deleteRectList() { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -bool CBRenderer::switchFullscreen() { +bool BaseRenderer::switchFullscreen() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::flip() { +bool BaseRenderer::flip() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::initRenderer(int width, int height, bool windowed) { +bool BaseRenderer::initRenderer(int width, int height, bool windowed) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -void CBRenderer::onWindowChange() { +void BaseRenderer::onWindowChange() { } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool BaseRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::windowedBlt() { +bool BaseRenderer::windowedBlt() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setup2D(bool Force) { +bool BaseRenderer::setup2D(bool Force) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setupLines() { +bool BaseRenderer::setupLines() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { +bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { for (int i = 0; i < width; i++) { drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down @@ -179,31 +179,31 @@ bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int widt ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fade(uint16 alpha) { +bool BaseRenderer::fade(uint16 alpha) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { +bool BaseRenderer::fadeToColor(uint32 color, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(int left, int top, int right, int bottom) { +bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setScreenViewport() { +bool BaseRenderer::setScreenViewport() { return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(Rect32 *rect) { +bool BaseRenderer::setViewport(Rect32 *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -212,13 +212,13 @@ bool CBRenderer::setViewport(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::takeScreenshot() { +BaseImage *BaseRenderer::takeScreenshot() { return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::clipCursor() { +bool BaseRenderer::clipCursor() { /* if (!_windowed) { Rect32 rc; @@ -237,7 +237,7 @@ bool CBRenderer::clipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::unclipCursor() { +bool BaseRenderer::unclipCursor() { /* if (!_windowed) ::ClipCursor(NULL); */ @@ -245,7 +245,7 @@ bool CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Point32 *p) { +bool BaseRenderer::pointInViewport(Point32 *p) { if (p->x < _drawOffsetX) return false; if (p->y < _drawOffsetY) return false; if (p->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index d743f19791..118cda0ec6 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -36,11 +36,11 @@ namespace WinterMute { -class CBImage; -class CBActiveRect; -class CBObject; -class CBSurface; -class CBRenderer: public CBBase { +class BaseImage; +class BaseActiveRect; +class BaseObject; +class BaseSurface; +class BaseRenderer: public BaseClass { public: int _realWidth; int _realHeight; @@ -48,7 +48,7 @@ public: int _drawOffsetY; virtual void dumpData(const char *filename) {}; - virtual CBImage *takeScreenshot(); + virtual BaseImage *takeScreenshot(); virtual bool setViewport(int left, int top, int right, int bottom); virtual bool setViewport(Rect32 *Rect); virtual bool setScreenViewport(); @@ -56,8 +56,8 @@ public: virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); - CBRenderer(CBGame *inGame = NULL); - virtual ~CBRenderer(); + BaseRenderer(BaseGame *inGame = NULL); + virtual ~BaseRenderer(); virtual bool setProjection() { return STATUS_OK; }; @@ -89,12 +89,12 @@ public: return 1.0f; } - virtual CBSurface *createSurface() = 0; + virtual BaseSurface *createSurface() = 0; bool clipCursor(); bool unclipCursor(); - CBObject *getObjectAt(int x, int y); + BaseObject *getObjectAt(int x, int y); void deleteRectList(); virtual bool startSpriteBatch() { @@ -118,10 +118,10 @@ public: int _height; int _width; - CBArray _rectList; + BaseArray _rectList; }; -CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp +BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 73b385d180..684236ac7f 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { +BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { _referenceCount = 0; _width = _height = 0; @@ -53,87 +53,87 @@ CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBSurface::~CBSurface() { +BaseSurface::~BaseSurface() { if (_pixelOpReady) endPixelOp(); } ////////////////////////////////////////////////////////////////////// -bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::restore() { +bool BaseSurface::restore() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAt(int x, int y) { +bool BaseSurface::isTransparentAt(int x, int y) { return false; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { +bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::create(int Width, int Height) { +bool BaseSurface::create(int Width, int Height) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::startPixelOp() { +bool BaseSurface::startPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::endPixelOp() { +bool BaseSurface::endPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { +bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { +bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { +bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { return false; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAtLite(int x, int y) { +bool BaseSurface::isTransparentAtLite(int x, int y) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::invalidate() { +bool BaseSurface::invalidate() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::prepareToDraw() { +bool BaseSurface::prepareToDraw() { _lastUsedTime = _gameRef->_liveTimer; if (!_valid) { @@ -144,7 +144,7 @@ bool CBSurface::prepareToDraw() { ////////////////////////////////////////////////////////////////////////// -void CBSurface::setSize(int width, int height) { +void BaseSurface::setSize(int width, int height) { _width = width; _height = height; } diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 22c1fb83b8..9a72cbb236 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -35,7 +35,7 @@ namespace WinterMute { -class CBSurface: public CBBase { +class BaseSurface: public BaseClass { public: virtual bool invalidate(); virtual bool prepareToDraw(); @@ -50,8 +50,8 @@ public: bool _keepLoaded; bool _pixelOpReady; - CBSurface(CBGame *inGame); - virtual ~CBSurface(); + BaseSurface(BaseGame *inGame); + virtual ~BaseSurface(); virtual bool displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index dbd2511928..ec69a80095 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -41,7 +41,7 @@ namespace WinterMute { -RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; @@ -89,14 +89,14 @@ bool RenderTicket::operator==(RenderTicket &t) { return true; } -CBRenderer *makeOSystemRenderer(CBGame *inGame) { - return new CBRenderOSystem(inGame); +BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { + return new BaseRenderOSystem(inGame); } // TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { +BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); _drawNum = 1; _needsFlip = true; @@ -110,7 +110,7 @@ CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::~CBRenderOSystem() { +BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; #if 0 @@ -121,7 +121,7 @@ CBRenderOSystem::~CBRenderOSystem() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { +bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; #if 0 @@ -237,20 +237,20 @@ bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { return STATUS_OK; } -void CBRenderOSystem::setAlphaMod(byte alpha) { +void BaseRenderOSystem::setAlphaMod(byte alpha) { byte r = RGBCOLGetR(_colorMod); byte g = RGBCOLGetB(_colorMod); byte b = RGBCOLGetB(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } -void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { +void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { byte alpha = RGBCOLGetA(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::flip() { +bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); } @@ -270,7 +270,7 @@ bool CBRenderOSystem::flip() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); @@ -285,20 +285,20 @@ bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fade(uint16 Alpha) { +bool BaseRenderOSystem::fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; return fadeToColor(dwAlpha << 24); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { +bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); - warning("Implement CBRenderOSystem::FadeToColor"); // TODO. + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + warning("Implement BaseRenderOSystem::FadeToColor"); // TODO. hasWarned = true; } @@ -347,7 +347,7 @@ bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { return STATUS_OK; } -void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { if (_disableDirtyRects) { RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. @@ -375,13 +375,13 @@ void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surfa drawFromTicket(ticket); } -void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { +void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); renderTicket->_isValid = false; // renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. } -void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { +void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { if ((*it)->_owner == surf) { @@ -390,7 +390,7 @@ void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { } } -void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { +void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { renderTicket->_wantsDraw = true; // A new item always has _drawNum == 0 if (renderTicket->_drawNum == 0) { @@ -445,7 +445,7 @@ void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { } } -void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { +void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { if (!_dirtyRect) { _dirtyRect = new Common::Rect(rect); } else { @@ -455,7 +455,7 @@ void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { // warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); } -void CBRenderOSystem::drawTickets() { +void BaseRenderOSystem::drawTickets() { RenderQueueIterator it = _renderQueue.begin(); // Clean out the old tickets int decrement = 0; @@ -511,7 +511,7 @@ void CBRenderOSystem::drawTickets() { } // Replacement for SDL2's SDL_RenderCopy -void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { +void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { TransparentSurface src(*surf, false); bool doDelete = false; if (!clipRect) { @@ -527,10 +527,10 @@ void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rec } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { - warning("CBRenderOSystem::DrawLine - not fully ported yet"); + warning("BaseRenderOSystem::DrawLine - not fully ported yet"); hasWarned = true; } byte r = RGBCOLGetR(color); @@ -558,10 +558,10 @@ bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { } ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderOSystem::takeScreenshot() { +BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Fix this - warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); - CBImage *screenshot = new CBImage(_gameRef); + warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); + BaseImage *screenshot = new BaseImage(_gameRef); screenshot->copyFrom(_renderSurface); return screenshot; #if 0 @@ -584,13 +584,13 @@ CBImage *CBRenderOSystem::takeScreenshot() { memcpy(bits, src, bytespp * viewport.w); } - return new CBImage(_gameRef, dib); + return new BaseImage(_gameRef, dib); #endif return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::switchFullscreen() { +bool BaseRenderOSystem::switchFullscreen() { /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); else SDL_SetWindowFullscreen(_win, SDL_FALSE); @@ -602,7 +602,7 @@ bool CBRenderOSystem::switchFullscreen() { } ////////////////////////////////////////////////////////////////////////// -const char *CBRenderOSystem::getName() { +const char *BaseRenderOSystem::getName() { if (_name.empty()) { #if 0 if (_renderer) { @@ -616,7 +616,7 @@ const char *CBRenderOSystem::getName() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { +bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. rect.left = (int16)(left + _borderLeft); @@ -632,7 +632,7 @@ bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::modTargetRect(Common::Rect *rect) { +void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -645,7 +645,7 @@ void CBRenderOSystem::modTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointFromScreen(Point32 *point) { +void BaseRenderOSystem::pointFromScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -657,7 +657,7 @@ void CBRenderOSystem::pointFromScreen(Point32 *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointToScreen(Point32 *point) { +void BaseRenderOSystem::pointToScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -668,19 +668,19 @@ void CBRenderOSystem::pointToScreen(Point32 *point) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::dumpData(const char *filename) { - warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO +void BaseRenderOSystem::dumpData(const char *filename) { + warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO #if 0 FILE *f = fopen(filename, "wt"); if (!f) return; - CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; + BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; int TotalKB = 0; int TotalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; + BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; if (!Surf->_filename) continue; if (!Surf->_valid) continue; @@ -702,8 +702,8 @@ void CBRenderOSystem::dumpData(const char *filename) { #endif } -CBSurface *CBRenderOSystem::createSurface() { - return new CBSurfaceOSystem(_gameRef); +BaseSurface *BaseRenderOSystem::createSurface() { + return new BaseSurfaceOSystem(_gameRef); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 8a8eb88ede..75c745ecf7 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -35,11 +35,11 @@ #include "common/list.h" namespace WinterMute { -class CBSurfaceOSystem; +class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; public: - RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); const Graphics::Surface *getSurface() { return _surface; } @@ -53,14 +53,14 @@ public: uint32 _drawNum; uint32 _colorMod; - CBSurfaceOSystem *_owner; + BaseSurfaceOSystem *_owner; bool operator==(RenderTicket &a); }; -class CBRenderOSystem : public CBRenderer { +class BaseRenderOSystem : public BaseRenderer { public: - CBRenderOSystem(CBGame *inGame); - ~CBRenderOSystem(); + BaseRenderOSystem(BaseGame *inGame); + ~BaseRenderOSystem(); const char *getName(); @@ -75,12 +75,12 @@ public: bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - CBImage *takeScreenshot(); + BaseImage *takeScreenshot(); void setAlphaMod(byte alpha); void setColorMod(byte r, byte g, byte b); void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); + void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); @@ -98,8 +98,8 @@ public: return _ratioY; } - void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); - CBSurface *createSurface(); + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + BaseSurface *createSurface(); private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 87c5731b49..0de31349fd 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -46,7 +46,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { +BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { _surface = new Graphics::Surface(); _alphaMask = NULL; _hasAlpha = true; @@ -56,7 +56,7 @@ CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::~CBSurfaceOSystem() { +BaseSurfaceOSystem::~BaseSurfaceOSystem() { //TODO if (_surface) { _surface->free(); @@ -68,7 +68,7 @@ CBSurfaceOSystem::~CBSurfaceOSystem() { _alphaMask = NULL; _gameRef->addMem(-_width * _height * 4); - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); } @@ -91,8 +91,8 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ +bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); @@ -116,8 +116,8 @@ bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, return STATUS_OK; } -void CBSurfaceOSystem::finishLoad() { - CBImage *image = new CBImage(_gameRef); +void BaseSurfaceOSystem::finishLoad() { + BaseImage *image = new BaseImage(_gameRef); image->loadFile(_filename); _width = image->getSurface()->w; @@ -191,8 +191,8 @@ void CBSurfaceOSystem::finishLoad() { } ////////////////////////////////////////////////////////////////////////// -void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); +void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); return; delete[] _alphaMask; @@ -237,8 +237,8 @@ void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { - warning("CBSurfaceOSystem::GetPixel - Not ported yet"); +uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { + warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; @@ -273,10 +273,10 @@ uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(int width, int height) { - warning("CBSurfaceOSystem::Create not ported yet"); //TODO +bool BaseSurfaceOSystem::create(int width, int height) { + warning("BaseSurfaceOSystem::Create not ported yet"); //TODO #if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); #endif _width = width; @@ -290,10 +290,10 @@ bool CBSurfaceOSystem::create(int width, int height) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO +bool BaseSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO #if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); #endif if (_surface) { @@ -314,12 +314,12 @@ bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAt(int x, int y) { +bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); + warning("BaseSurfaceOSystem::IsTransparentAt not ported yet"); hasWarned = true; } #if 0 @@ -340,14 +340,14 @@ bool CBSurfaceOSystem::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { +bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { //if (!_lockPixels) return false; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); + warning("BaseSurfaceOSystem::IsTransparentAtLite not ported yet"); hasWarned = true; } if (_surface->format.bytesPerPixel == 4) { @@ -387,57 +387,57 @@ bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::startPixelOp() { +bool BaseSurfaceOSystem::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::endPixelOp() { +bool BaseSurfaceOSystem::endPixelOp() { //SDL_UnlockTexture(_texture); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); +bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); if (!_loaded) { finishLoad(); @@ -450,7 +450,7 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. + warning("BaseSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } @@ -508,7 +508,7 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float hasAlpha = false; } if (alphaDisable) { - warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); + warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); @@ -519,11 +519,11 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float return STATUS_OK; } -bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { +bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->copyFrom(surface); _hasAlpha = hasAlpha; - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 091e8ccba8..bece031fe7 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -35,11 +35,11 @@ namespace WinterMute { struct TransparentSurface; -class CBImage; -class CBSurfaceOSystem : public CBSurface { +class BaseImage; +class BaseSurfaceOSystem : public BaseSurface { public: - CBSurfaceOSystem(CBGame *inGame); - ~CBSurfaceOSystem(); + BaseSurfaceOSystem(BaseGame *inGame); + ~BaseSurfaceOSystem(); bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index b3b05b6e65..212f11d2f6 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -43,13 +43,13 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CPartEmitter, false) +IMPLEMENT_PERSISTENT(PartEmitter, false) ////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject(inGame) { _width = _height = 0; - CBPlatform::setRectEmpty(&_border); + BasePlatform::setRectEmpty(&_border); _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; _angle1 = _angle2 = 0; @@ -94,7 +94,7 @@ CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inG ////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { +PartEmitter::~PartEmitter(void) { for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } @@ -116,7 +116,7 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addSprite(const char *filename) { +bool PartEmitter::addSprite(const char *filename) { if (!filename) return STATUS_FAILED; // do we already have the file? @@ -139,7 +139,7 @@ bool CPartEmitter::addSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeSprite(const char *filename) { +bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; @@ -151,34 +151,34 @@ bool CPartEmitter::removeSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { +bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { if (!particle) return STATUS_FAILED; if (_sprites.getSize() == 0) return STATUS_FAILED; - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); + int posX = BaseUtils::randomInt(_posX, _posX + _width); + int posY = BaseUtils::randomInt(_posY, _posY + _height); + float posZ = BaseUtils::randomFloat(0.0f, 100.0f); float velocity; if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + else velocity = BaseUtils::randomFloat(_velocity1, _velocity2); float scale; if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); + else scale = BaseUtils::randomFloat(_scale1, _scale2); int lifeTime; if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + float angle = BaseUtils::randomAngle(_angle1, _angle2); + int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); - if (!CBPlatform::isRectEmpty(&_border)) { + if (!BasePlatform::isRectEmpty(&_border)) { int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); @@ -195,14 +195,14 @@ bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uin Vector2 vecVel(0, velocity); Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); matRot.transformVector2(vecVel); if (_alphaTimeBased) { particle->_alpha1 = _alpha1; particle->_alpha2 = _alpha2; } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); + int alpha = BaseUtils::randomInt(_alpha1, _alpha2); particle->_alpha1 = alpha; particle->_alpha2 = alpha; } @@ -226,13 +226,13 @@ bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uin } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::update() { +bool PartEmitter::update() { if (!_running) return STATUS_OK; else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { +bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; for (int i = 0; i < _particles.getSize(); i++) { @@ -263,10 +263,10 @@ bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } } - CPartParticle *particle; + PartParticle *particle; if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; else { - particle = new CPartParticle(_gameRef); + particle = new PartParticle(_gameRef); _particles.add(particle); } initParticle(particle, currentTime, timerDelta); @@ -288,7 +288,7 @@ bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::display(CBRegion *region) { +bool PartEmitter::display(BaseRegion *region) { if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.getSize(); i++) { @@ -305,7 +305,7 @@ bool CPartEmitter::display(CBRegion *region) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::start() { +bool PartEmitter::start() { for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->_isDead = true; } @@ -329,16 +329,16 @@ bool CPartEmitter::start() { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::sortParticlesByZ() { +bool PartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + qsort(_particles.getData(), _particles.getSize(), sizeof(PartParticle *), PartEmitter::compareZ); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; +int PartEmitter::compareZ(const void *obj1, const void *obj2) { + PartParticle *p1 = *(PartParticle **)obj1; + PartParticle *p2 = *(PartParticle **)obj2; if (p1->_posZ < p2->_posZ) return -1; else if (p1->_posZ > p2->_posZ) return 1; @@ -346,14 +346,14 @@ int CPartEmitter::compareZ(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); +bool PartEmitter::setBorder(int x, int y, int width, int height) { + BasePlatform::setRect(&_border, x, y, x + width, y + height); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { +bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { _borderThicknessLeft = thicknessLeft; _borderThicknessRight = thicknessRight; _borderThicknessTop = thicknessTop; @@ -363,8 +363,8 @@ bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int } ////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; +PartForce *PartEmitter::addForceByName(const char *name) { + PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { @@ -373,7 +373,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { } } if (!force) { - force = new CPartForce(_gameRef); + force = new PartForce(_gameRef); if (force) { force->setName(name); _forces.add(force); @@ -384,8 +384,8 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); +bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { + PartForce *force = addForceByName(name); if (!force) return STATUS_FAILED; force->_type = type; @@ -393,14 +393,14 @@ bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int p force->_direction = Vector2(0, strength); Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); matRot.transformVector2(force->_direction); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeForce(const char *name) { +bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; @@ -415,7 +415,7 @@ bool CPartEmitter::removeForce(const char *name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -524,7 +524,7 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, 0, 0, angle, strength))); return STATUS_OK; } @@ -540,7 +540,7 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, posX, posY, angle, strength))); return STATUS_OK; } @@ -557,11 +557,11 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { +ScValue *PartEmitter::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -828,12 +828,12 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { +bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// @@ -1081,16 +1081,16 @@ bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + if (!value->isNULL()) BaseUtils::setString(&_emitEvent, value->getString()); return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { +const char *PartEmitter::scToString() { return "[particle emitter]"; } @@ -1098,8 +1098,8 @@ const char *CPartEmitter::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool PartEmitter::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); persistMgr->transfer(TMEMBER(_height)); @@ -1171,7 +1171,7 @@ bool CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(_gameRef); + PartForce *force = new PartForce(_gameRef); force->persist(persistMgr); _forces.add(force); } @@ -1187,7 +1187,7 @@ bool CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(_gameRef); + PartParticle *particle = new PartParticle(_gameRef); particle->persist(persistMgr); _particles.add(particle); } diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index cff0a1ec83..6575544db0 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -34,14 +34,14 @@ #include "engines/wintermute/base/particles/part_force.h" namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { +class BaseRegion; +class PartParticle; +class PartEmitter : public BaseObject { public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) + DECLARE_PERSISTENT(PartEmitter, BaseObject) - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); + PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); + virtual ~PartEmitter(void); int _width; int _height; @@ -98,13 +98,13 @@ public: bool _useRegion; char *_emitEvent; - CBScriptHolder *_owner; + BaseScriptHolder *_owner; bool start(); bool update(); bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(CBRegion *region); + bool display(BaseRegion *region); bool sortParticlesByZ(); bool addSprite(const char *filename); @@ -112,26 +112,26 @@ public: bool setBorder(int x, int y, int width, int height); bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); bool removeForce(const char *name); - CBArray _forces; + BaseArray _forces; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: - CPartForce *addForceByName(const char *name); + PartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); - bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; + BaseArray _particles; + BaseArray _sprites; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 2f330c21b0..ba60e8b41c 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { +PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { _pos = Vector2(0.0f, 0.0f); _direction = Vector2(0.0f, 0.0f); _type = FORCE_POINT; @@ -42,12 +42,12 @@ CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { +PartForce::~PartForce(void) { } ////////////////////////////////////////////////////////////////////////// -bool CPartForce::persist(CBPersistMgr *persistMgr) { +bool PartForce::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h index f0a6d66c43..ec79ab7238 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -36,20 +36,20 @@ namespace WinterMute { -class CPartForce : public CBNamedObject { +class PartForce : public BaseNamedObject { public: enum TForceType { FORCE_POINT, FORCE_GLOBAL }; - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); + PartForce(BaseGame *inGame); + virtual ~PartForce(void); Vector2 _pos; Vector2 _direction; TForceType _type; - bool persist(CBPersistMgr *PersistMgr); + bool persist(BasePersistenceManager *PersistMgr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 931f7558c7..93b9f3659d 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -39,7 +39,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { +PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { _pos = Vector2(0.0f, 0.0f); _posZ = 0.0f; _velocity = Vector2(0.0f, 0.0f); @@ -48,7 +48,7 @@ CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { _creationTime = 0; _lifeTime = 0; _isDead = true; - CBPlatform::setRectEmpty(&_border); + BasePlatform::setRectEmpty(&_border); _state = PARTICLE_NORMAL; _fadeStart = 0; @@ -66,13 +66,13 @@ CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { +PartParticle::~PartParticle(void) { delete _sprite; _sprite = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::setSprite(const char *filename) { +bool PartParticle::setSprite(const char *filename) { if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { _sprite->reset(); return STATUS_OK; @@ -81,22 +81,22 @@ bool CPartParticle::setSprite(const char *filename) { delete _sprite; _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(_gameRef, _gameRef); + SystemClassRegistry::getInstance()->_disabled = true; + _sprite = new BaseSprite(_gameRef, _gameRef); if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; return STATUS_OK; } else { delete _sprite; _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { +bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; @@ -123,11 +123,11 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim } // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + if (!_isDead && !BasePlatform::isRectEmpty(&_border)) { Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) + if (!BasePlatform::ptInRect(&_border, p)) fadeOut(currentTime, emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return STATUS_OK; @@ -144,13 +144,13 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim float elapsedTime = (float)timerDelta / 1000.f; for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; + PartForce *force = emitter->_forces[i]; switch (force->_type) { - case CPartForce::FORCE_GLOBAL: + case PartForce::FORCE_GLOBAL: _velocity += force->_direction * elapsedTime; break; - case CPartForce::FORCE_POINT: { + case PartForce::FORCE_POINT: { Vector2 vecDist = force->_pos - _pos; float dist = fabs(vecDist.length()); @@ -165,7 +165,7 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim // update rotation _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); + _rotation = BaseUtils::normalizeAngle(_rotation); // update scale if (_exponentialGrowth) @@ -182,7 +182,7 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::display(CPartEmitter *emitter) { +bool PartParticle::display(PartEmitter *emitter) { if (!_sprite) return STATUS_FAILED; if (_isDead) return STATUS_OK; @@ -197,7 +197,7 @@ bool CPartParticle::display(CPartEmitter *emitter) { ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { +bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { _currentAlpha = 0; _fadeStart = currentTime; _fadeTime = fadeTime; @@ -207,7 +207,7 @@ bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { +bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; _fadeStart = currentTime; @@ -218,7 +218,7 @@ bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::persist(CBPersistMgr *persistMgr) { +bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_alpha1)); persistMgr->transfer(TMEMBER(_alpha2)); persistMgr->transfer(TMEMBER(_border)); @@ -244,9 +244,9 @@ bool CPartParticle::persist(CBPersistMgr *persistMgr) { } else { char *filename; persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; + SystemClassRegistry::getInstance()->_disabled = true; setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; delete[] filename; filename = NULL; } diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 0b256d44ec..8b0c6eea36 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -36,18 +36,18 @@ namespace WinterMute { -class CPartEmitter; -class CBSprite; -class CBPersistMgr; +class PartEmitter; +class BaseSprite; +class BasePersistenceManager; -class CPartParticle : public CBBase { +class PartParticle : public BaseClass { public: enum TParticleState { PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT }; - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); + PartParticle(BaseGame *inGame); + virtual ~PartParticle(void); float _growthRate; bool _exponentialGrowth; @@ -63,21 +63,21 @@ public: float _posZ; Vector2 _velocity; float _scale; - CBSprite *_sprite; + BaseSprite *_sprite; uint32 _creationTime; int _lifeTime; bool _isDead; TParticleState _state; - bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(CPartEmitter *emitter); + bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(PartEmitter *emitter); bool setSprite(const char *filename); bool fadeIn(uint32 currentTime, int fadeTime); bool fadeOut(uint32 currentTime, int fadeTime); - bool persist(CBPersistMgr *PersistMgr); + bool persist(BasePersistenceManager *PersistMgr); private: uint32 _fadeStart; int _fadeTime; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index a9646e0045..45544831e3 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -36,10 +36,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScScript, false) +IMPLEMENT_PERSISTENT(ScScript, false) ////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { +ScScript::ScScript(BaseGame *inGame, ScEngine *Engine): BaseClass(inGame) { _buffer = NULL; _bufferSize = _iP = 0; _scriptStream = NULL; @@ -98,11 +98,11 @@ CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { +ScScript::~ScScript() { cleanup(); } -void CScScript::readHeader() { +void ScScript::readHeader() { uint32 oldPos = _scriptStream->pos(); _scriptStream->seek(0); _header.magic = _scriptStream->readUint32LE(); @@ -118,7 +118,7 @@ void CScScript::readHeader() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::initScript() { +bool ScScript::initScript() { if (!_scriptStream) { _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); } @@ -139,13 +139,13 @@ bool CScScript::initScript() { initTables(); // init stacks - _scopeStack = new CScStack(_gameRef); - _callStack = new CScStack(_gameRef); - _thisStack = new CScStack(_gameRef); - _stack = new CScStack(_gameRef); + _scopeStack = new ScStack(_gameRef); + _callStack = new ScStack(_gameRef); + _thisStack = new ScStack(_gameRef); + _stack = new ScStack(_gameRef); - _operand = new CScValue(_gameRef); - _reg1 = new CScValue(_gameRef); + _operand = new ScValue(_gameRef); + _reg1 = new ScValue(_gameRef); // skip to the beginning @@ -165,7 +165,7 @@ bool CScScript::initScript() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::initTables() { +bool ScScript::initTables() { uint32 OrigIP = _iP; readHeader(); @@ -240,7 +240,7 @@ bool CScScript::initTables() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { +bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner) { cleanup(); _thread = false; @@ -263,7 +263,7 @@ bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScript if (DID_FAIL(res)) return res; // establish global variables table - _globals = new CScValue(_gameRef); + _globals = new ScValue(_gameRef); _owner = owner; @@ -272,7 +272,7 @@ bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScript ////////////////////////////////////////////////////////////////////////// -bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { +bool ScScript::createThread(ScScript *original, uint32 initIP, const char *eventName) { cleanup(); _thread = true; @@ -316,7 +316,7 @@ bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eve ////////////////////////////////////////////////////////////////////////// -bool CScScript::createMethodThread(CScScript *original, const char *methodName) { +bool ScScript::createMethodThread(ScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); if (ip == 0) return STATUS_FAILED; @@ -360,7 +360,7 @@ bool CScScript::createMethodThread(CScScript *original, const char *methodName) ////////////////////////////////////////////////////////////////////////// -void CScScript::cleanup() { +void ScScript::cleanup() { if (_buffer) delete [] _buffer; _buffer = NULL; @@ -430,7 +430,7 @@ void CScScript::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getDWORD() { +uint32 ScScript::getDWORD() { _scriptStream->seek((int32)_iP); uint32 ret = _scriptStream->readUint32LE(); _iP += sizeof(uint32); @@ -439,7 +439,7 @@ uint32 CScScript::getDWORD() { } ////////////////////////////////////////////////////////////////////////// -double CScScript::getFloat() { +double ScScript::getFloat() { _scriptStream->seek((int32)_iP); byte buffer[8]; _scriptStream->read(buffer, 8); @@ -459,7 +459,7 @@ double CScScript::getFloat() { ////////////////////////////////////////////////////////////////////////// -char *CScScript::getString() { +char *ScScript::getString() { char *ret = (char *)(_buffer + _iP); while (*(char *)(_buffer + _iP) != '\0') _iP++; _iP++; // string terminator @@ -470,17 +470,17 @@ char *CScScript::getString() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::executeInstruction() { +bool ScScript::executeInstruction() { bool ret = STATUS_OK; uint32 dw; const char *str = NULL; - //CScValue* op = new CScValue(_gameRef); + //ScValue* op = new ScValue(_gameRef); _operand->cleanup(); - CScValue *op1; - CScValue *op2; + ScValue *op1; + ScValue *op2; uint32 inst = getDWORD(); switch (inst) { @@ -557,7 +557,7 @@ bool CScScript::executeInstruction() { char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); - CScValue *var = _stack->pop(); + ScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; bool res = STATUS_FAILED; @@ -591,7 +591,7 @@ bool CScScript::executeInstruction() { break; } /* - CScValue* val = var->getProp(MethodName); + ScValue* val = var->getProp(MethodName); if(val){ dw = GetFuncPos(val->getString()); if(dw==0){ @@ -660,7 +660,7 @@ bool CScScript::executeInstruction() { break; case II_PUSH_VAR: { - CScValue *var = getVar(_symbols[getDWORD()]); + ScValue *var = getVar(_symbols[getDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->setReference(var); _stack->push(_operand); @@ -669,7 +669,7 @@ bool CScScript::executeInstruction() { } case II_PUSH_VAR_REF: { - CScValue *var = getVar(_symbols[getDWORD()]); + ScValue *var = getVar(_symbols[getDWORD()]); _operand->setReference(var); _stack->push(_operand); break; @@ -677,9 +677,9 @@ bool CScScript::executeInstruction() { case II_POP_VAR: { char *VarName = _symbols[getDWORD()]; - CScValue *var = getVar(VarName); + ScValue *var = getVar(VarName); if (var) { - CScValue *val = _stack->pop(); + ScValue *val = _stack->pop(); if (!val) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); @@ -740,7 +740,7 @@ bool CScScript::executeInstruction() { case II_PUSH_BY_EXP: { str = _stack->pop()->getString(); - CScValue *val = _stack->pop()->getProp(str); + ScValue *val = _stack->pop()->getProp(str); if (val) _stack->push(val); else _stack->pushNULL(); @@ -749,8 +749,8 @@ bool CScScript::executeInstruction() { case II_POP_BY_EXP: { str = _stack->pop()->getString(); - CScValue *var = _stack->pop(); - CScValue *val = _stack->pop(); + ScValue *var = _stack->pop(); + ScValue *val = _stack->pop(); if (val == NULL) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); @@ -778,7 +778,7 @@ bool CScScript::executeInstruction() { case II_JMP_FALSE: { dw = getDWORD(); //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *val = _stack->pop(); + ScValue *val = _stack->pop(); if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { @@ -916,7 +916,7 @@ bool CScScript::executeInstruction() { } */ - _operand->setBool(CScValue::compare(op1, op2) == 0); + _operand->setBool(ScValue::compare(op1, op2) == 0); _stack->push(_operand); break; @@ -940,7 +940,7 @@ bool CScScript::executeInstruction() { } */ - _operand->setBool(CScValue::compare(op1, op2) != 0); + _operand->setBool(ScValue::compare(op1, op2) != 0); _stack->push(_operand); break; @@ -955,7 +955,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() < op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) < 0); + _operand->setBool(ScValue::compare(op1, op2) < 0); _stack->push(_operand); break; @@ -970,7 +970,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() > op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) > 0); + _operand->setBool(ScValue::compare(op1, op2) > 0); _stack->push(_operand); break; @@ -985,7 +985,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() <= op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) <= 0); + _operand->setBool(ScValue::compare(op1, op2) <= 0); _stack->push(_operand); break; @@ -1000,7 +1000,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() >= op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) >= 0); + _operand->setBool(ScValue::compare(op1, op2) >= 0); _stack->push(_operand); break; @@ -1009,7 +1009,7 @@ bool CScScript::executeInstruction() { op1 = _stack->pop(); //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _operand->setBool(ScValue::compareStrict(op1, op2) == 0); _stack->push(_operand); break; @@ -1019,7 +1019,7 @@ bool CScScript::executeInstruction() { op1 = _stack->pop(); //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _operand->setBool(ScValue::compareStrict(op1, op2) != 0); _stack->push(_operand); break; @@ -1059,7 +1059,7 @@ bool CScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getFuncPos(const char *name) { +uint32 ScScript::getFuncPos(const char *name) { for (uint32 i = 0; i < _numFunctions; i++) { if (strcmp(name, _functions[i].name) == 0) return _functions[i].pos; @@ -1069,7 +1069,7 @@ uint32 CScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getMethodPos(const char *name) { +uint32 ScScript::getMethodPos(const char *name) { for (uint32 i = 0; i < _numMethods; i++) { if (strcmp(name, _methods[i].name) == 0) return _methods[i].pos; @@ -1079,8 +1079,8 @@ uint32 CScScript::getMethodPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::getVar(char *name) { - CScValue *ret = NULL; +ScValue *ScScript::getVar(char *name) { + ScValue *ret = NULL; // scope locals if (_scopeStack->_sP >= 0) { @@ -1103,8 +1103,8 @@ CScValue *CScScript::getVar(char *name) { if (ret == NULL) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(_gameRef); - CScValue *scope = _scopeStack->getTop(); + ScValue *val = new ScValue(_gameRef); + ScValue *scope = _scopeStack->getTop(); if (scope) { scope->setProp(name, val); ret = _scopeStack->getTop()->getProp(name); @@ -1120,7 +1120,7 @@ CScValue *CScScript::getVar(char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::waitFor(CBObject *object) { +bool ScScript::waitFor(BaseObject *object) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1133,14 +1133,14 @@ bool CScScript::waitFor(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::waitForExclusive(CBObject *object) { +bool ScScript::waitForExclusive(BaseObject *object) { _engine->resetObject(object); return waitFor(object); } ////////////////////////////////////////////////////////////////////////// -bool CScScript::sleep(uint32 duration) { +bool ScScript::sleep(uint32 duration) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1148,7 +1148,7 @@ bool CScScript::sleep(uint32 duration) { _state = SCRIPT_SLEEPING; if (_gameRef->_state == GAME_FROZEN) { - _waitTime = CBPlatform::getTime() + duration; + _waitTime = BasePlatform::getTime() + duration; _waitFrozen = true; } else { _waitTime = _gameRef->_timer + duration; @@ -1159,7 +1159,7 @@ bool CScScript::sleep(uint32 duration) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::finish(bool includingThreads) { +bool ScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); @@ -1171,14 +1171,14 @@ bool CScScript::finish(bool includingThreads) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::run() { +bool ScScript::run() { _state = SCRIPT_RUNNING; return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(const char *fmt, ...) { +void ScScript::runtimeError(const char *fmt, ...) { char buff[256]; va_list va; @@ -1195,7 +1195,7 @@ void CScScript::runtimeError(const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::persist(CBPersistMgr *persistMgr) { +bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -1257,13 +1257,13 @@ bool CScScript::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { +ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { //if(_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); if (!pos) return NULL; - CScScript *thread = new CScScript(_gameRef, _engine); + ScScript *thread = new ScScript(_gameRef, _engine); if (thread) { bool ret = thread->createThread(this, pos, eventName); if (DID_SUCCEED(ret)) { @@ -1281,7 +1281,7 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getEventPos(const char *name) { +uint32 ScScript::getEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; } @@ -1290,19 +1290,19 @@ uint32 CScScript::getEventPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *eventName) { +bool ScScript::canHandleEvent(const char *eventName) { return getEventPos(eventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *methodName) { +bool ScScript::canHandleMethod(const char *methodName) { return getMethodPos(methodName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::pause() { +bool ScScript::pause() { if (_state == SCRIPT_PAUSED) { _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return STATUS_FAILED; @@ -1318,7 +1318,7 @@ bool CScScript::pause() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::resume() { +bool ScScript::resume() { if (_state != SCRIPT_PAUSED) return STATUS_OK; _state = _origState; @@ -1327,7 +1327,7 @@ bool CScScript::resume() { ////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::getExternal(char *name) { +ScScript::TExternalFunction *ScScript::getExternal(char *name) { for (uint32 i = 0; i < _numExternals; i++) { if (strcmp(name, _externals[i].name) == 0) return &_externals[i]; @@ -1337,7 +1337,7 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { +bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { _gameRef->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); @@ -1347,7 +1347,7 @@ bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TE ////////////////////////////////////////////////////////////////////////// -bool CScScript::copyParameters(CScStack *stack) { +bool ScScript::copyParameters(ScStack *stack) { int i; int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { @@ -1362,9 +1362,9 @@ bool CScScript::copyParameters(CScStack *stack) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::finishThreads() { +bool ScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.getSize(); i++) { - CScScript *scr = _engine->_scripts[i]; + ScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) scr->finish(true); } @@ -1374,18 +1374,18 @@ bool CScScript::finishThreads() { ////////////////////////////////////////////////////////////////////////// // IWmeDebugScript interface implementation -int CScScript::dbgGetLine() { +int ScScript::dbgGetLine() { return _currentLine; } ////////////////////////////////////////////////////////////////////////// -const char *CScScript::dbgGetFilename() { +const char *ScScript::dbgGetFilename() { return _filename; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendScript(IWmeDebugClient *client) { +bool ScScript::dbgSendScript(IWmeDebugClient *client) { if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); else client->onScriptInit(this); @@ -1395,14 +1395,14 @@ bool CScScript::dbgSendScript(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendVariables(IWmeDebugClient *client) { +bool ScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); // send scope variables if (_scopeStack->_sP >= 0) { for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); + // ScValue *Scope = _scopeStack->GetAt(i); //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } @@ -1411,35 +1411,35 @@ bool CScScript::dbgSendVariables(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::dbgGetState() { +TScriptState ScScript::dbgGetState() { return _state; } ////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetNumBreakpoints() { +int ScScript::dbgGetNumBreakpoints() { return _breakpoints.getSize(); } ////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int index) { +int ScScript::dbgGetBreakpoint(int index) { if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; else return -1; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool isTracing) { +bool ScScript::dbgSetTracingMode(bool isTracing) { _tracingMode = isTracing; return true; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgGetTracingMode() { +bool ScScript::dbgGetTracingMode() { return _tracingMode; } ////////////////////////////////////////////////////////////////////////// -void CScScript::afterLoad() { +void ScScript::afterLoad() { if (_buffer == NULL) { byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); if (!buffer) { diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 899e1f3098..3bb4bc48a7 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -37,50 +37,50 @@ #include "engines/wintermute/wme_debugger.h" namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { +class BaseScriptHolder; +class BaseObject; +class ScEngine; +class ScStack; +class ScScript : public BaseClass, public IWmeDebugScript { public: bool dbgSendScript(IWmeDebugClient *client); bool dbgSendVariables(IWmeDebugClient *client); - CBArray _breakpoints; + BaseArray _breakpoints; bool _tracingMode; - CScScript *_parentScript; + ScScript *_parentScript; bool _unbreakable; bool finishThreads(); - bool copyParameters(CScStack *stack); + bool copyParameters(ScStack *stack); void afterLoad(); - CScValue *_operand; - CScValue *_reg1; + ScValue *_operand; + ScValue *_reg1; bool _freezable; bool resume(); bool pause(); bool canHandleEvent(const char *eventName); bool canHandleMethod(const char *methodName); - bool createThread(CScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(CScScript *original, const char *methodName); - CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + bool createThread(ScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(ScScript *original, const char *methodName); + ScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) + DECLARE_PERSISTENT(ScScript, BaseClass) void runtimeError(const char *fmt, ...); bool run(); bool finish(bool includingThreads = false); bool sleep(uint32 duration); - bool waitForExclusive(CBObject *object); - bool waitFor(CBObject *object); + bool waitForExclusive(BaseObject *object); + bool waitFor(BaseObject *object); uint32 _waitTime; bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; + BaseObject *_waitObject; + ScScript *_waitScript; TScriptState _state; TScriptState _origState; - CScValue *getVar(char *name); + ScValue *getVar(char *name); uint32 getFuncPos(const char *name); uint32 getEventPos(const char *name); uint32 getMethodPos(const char *name); @@ -122,19 +122,19 @@ public: } TExternalFunction; - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; + ScStack *_callStack; + ScStack *_thisStack; + ScStack *_scopeStack; + ScStack *_stack; + ScValue *_globals; + ScEngine *_engine; int _currentLine; bool executeInstruction(); char *getString(); uint32 getDWORD(); double getFloat(); void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + bool create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner); uint32 _iP; private: void readHeader(); @@ -142,8 +142,8 @@ private: byte *_buffer; public: Common::SeekableReadStream *_scriptStream; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); + ScScript(BaseGame *inGame, ScEngine *Engine); + virtual ~ScScript(); char *_filename; char **_symbols; uint32 _numSymbols; @@ -158,9 +158,9 @@ public: bool _thread; bool _methodThread; char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *getExternal(char *name); - bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); + BaseScriptHolder *_owner; + ScScript::TExternalFunction *getExternal(char *name); + bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); private: bool initScript(); bool initTables(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 387093ac4a..44add054c5 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -41,29 +41,29 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScEngine, true) +IMPLEMENT_PERSISTENT(ScEngine, true) #define COMPILER_DLL "dcscomp.dll" ////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { +ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); else _gameRef->LOG(0, " Script compiler is NOT available"); - _globals = new CScValue(_gameRef); + _globals = new ScValue(_gameRef); // register 'Game' as global variable if (!_globals->propExists("Game")) { - CScValue val(_gameRef); + ScValue val(_gameRef); val.setNative(_gameRef, true); _globals->setProp("Game", &val); } // register 'Math' as global variable if (!_globals->propExists("Math")) { - CScValue val(_gameRef); + ScValue val(_gameRef); val.setNative(_gameRef->_mathClass, true); _globals->setProp("Math", &val); } @@ -81,7 +81,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { +ScEngine::~ScEngine() { _gameRef->LOG(0, "Shutting down scripting engine"); saveBreakpoints(); @@ -98,7 +98,7 @@ CScEngine::~CScEngine() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::cleanup() { +bool ScEngine::cleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; @@ -120,25 +120,25 @@ bool CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *gameRef = (CBGame *)data; +byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { + BaseGame *gameRef = (BaseGame *)data; return gameRef->_fileManager->readWholeFile(filename, size); } ////////////////////////////////////////////////////////////////////////// -void CScEngine::closeFile(void *data, byte *buffer) { +void ScEngine::closeFile(void *data, byte *buffer) { delete [] buffer; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +void ScEngine::parseElement(void *data, int line, int type, void *elementData) { } ////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { +ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { byte *compBuffer; uint32 compSize; @@ -147,7 +147,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { if (!compBuffer) return NULL; // add new script - CScScript *script = new CScScript(_gameRef, this); + ScScript *script = new ScScript(_gameRef, this); bool ret = script->create(filename, compBuffer, compSize, owner); if (DID_FAIL(ret)) { _gameRef->LOG(ret, "Error running script '%s'...", filename); @@ -155,7 +155,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { return NULL; } else { // publish the "self" pseudo-variable - CScValue val(_gameRef); + ScValue val(_gameRef); if (owner)val.setNative(owner, true); else val.setNULL(); @@ -171,12 +171,12 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { +byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { // is script in cache? if (!ignoreCache) { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + _cachedScripts[i]->_timestamp = BasePlatform::getTime(); *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } @@ -191,7 +191,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (!buffer) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; } @@ -201,7 +201,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i compSize = size; } else { if (!_compilerAvailable) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); delete [] buffer; return NULL; } @@ -216,7 +216,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = CBPlatform::getTime(); + uint32 MinTime = BasePlatform::getTime(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; @@ -244,7 +244,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// -bool CScEngine::tick() { +bool ScEngine::tick() { if (_scripts.getSize() == 0) return STATUS_OK; @@ -275,7 +275,7 @@ bool CScEngine::tick() { case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= BasePlatform::getTime()) _scripts[i]->run(); } else { if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); } @@ -300,7 +300,7 @@ bool CScEngine::tick() { break; } default: - //warning("CScEngine::Tick - Unhandled enum"); + //warning("ScEngine::Tick - Unhandled enum"); break; } // switch } // for each script @@ -314,25 +314,25 @@ bool CScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + uint32 StartTime = BasePlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && BasePlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - StartTime); } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = CBPlatform::getTime(); + if (isProfiling) startTime = BasePlatform::getTime(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - startTime); } _currentScript = NULL; } @@ -344,7 +344,7 @@ bool CScEngine::tick() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::tickUnbreakable() { +bool ScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_unbreakable) continue; @@ -363,7 +363,7 @@ bool CScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeFinishedScripts() { +bool ScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { @@ -379,7 +379,7 @@ bool CScEngine::removeFinishedScripts() { ////////////////////////////////////////////////////////////////////////// -int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { +int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; for (int i = 0; i < _scripts.getSize(); i++) { @@ -397,7 +397,7 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { numPersistent++; break; default: - warning("CScEngine::GetNumScripts - unhandled enum"); + warning("ScEngine::GetNumScripts - unhandled enum"); break; } numTotal++; @@ -411,7 +411,7 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::emptyScriptCache() { +bool ScEngine::emptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i]) { delete _cachedScripts[i]; @@ -423,7 +423,7 @@ bool CScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetObject(CBObject *Object) { +bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { @@ -437,7 +437,7 @@ bool CScEngine::resetObject(CBObject *Object) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetScript(CScScript *script) { +bool ScEngine::resetScript(ScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { @@ -448,7 +448,7 @@ bool CScEngine::resetScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::persist(CBPersistMgr *persistMgr) { +bool ScEngine::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(); persistMgr->transfer(TMEMBER(_gameRef)); @@ -461,7 +461,7 @@ bool CScEngine::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::editorCleanup() { +void ScEngine::editorCleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; @@ -473,7 +473,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::pauseAll() { +bool ScEngine::pauseAll() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->pause(); } @@ -483,7 +483,7 @@ bool CScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resumeAll() { +bool ScEngine::resumeAll() { for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->resume(); @@ -492,7 +492,7 @@ bool CScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::isValidScript(CScScript *script) { +bool ScEngine::isValidScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) return true; } @@ -500,13 +500,13 @@ bool CScEngine::isValidScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::clearGlobals(bool includingNatives) { +bool ScEngine::clearGlobals(bool includingNatives) { _globals->CleanProps(includingNatives); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { +bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); @@ -526,7 +526,7 @@ bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { +bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; @@ -553,7 +553,7 @@ bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { +bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -578,7 +578,7 @@ bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints() { +bool ScEngine::refreshScriptBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _scripts.getSize(); i++) { @@ -588,7 +588,7 @@ bool CScEngine::refreshScriptBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints(CScScript *script) { +bool ScEngine::refreshScriptBreakpoints(ScScript *script) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; if (!script || !script->_filename) return STATUS_FAILED; @@ -605,7 +605,7 @@ bool CScEngine::refreshScriptBreakpoints(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::saveBreakpoints() { +bool ScEngine::saveBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; @@ -628,7 +628,7 @@ bool CScEngine::saveBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::loadBreakpoints() { +bool ScEngine::loadBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; char key[100]; @@ -639,8 +639,8 @@ bool CScEngine::loadBreakpoints() { sprintf(key, "Breakpoint%d", i); AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); - char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); delete[] path; @@ -654,7 +654,7 @@ bool CScEngine::loadBreakpoints() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::addScriptTime(const char *filename, uint32 time) { +void ScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) return; AnsiString fileName = filename; @@ -664,19 +664,19 @@ void CScEngine::addScriptTime(const char *filename, uint32 time) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::enableProfiling() { +void ScEngine::enableProfiling() { if (_isProfiling) return; // destroy old data, if any _scriptTimes.clear(); - _profilingStartTime = CBPlatform::getTime(); + _profilingStartTime = BasePlatform::getTime(); _isProfiling = true; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::disableProfiling() { +void ScEngine::disableProfiling() { if (!_isProfiling) return; dumpStats(); @@ -685,9 +685,9 @@ void CScEngine::disableProfiling() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::dumpStats() { +void ScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + /* uint32 totalTime = BasePlatform::getTime() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 81dc13a73c..06d61b4156 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -39,16 +39,16 @@ namespace WinterMute { #define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { +class ScScript; +class ScValue; +class BaseObject; +class BaseScriptHolder; +class ScEngine : public BaseClass { public: class CScCachedScript { public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::getTime(); + _timestamp = BasePlatform::getTime(); _buffer = new byte[size]; if (_buffer) memcpy(_buffer, buffer, size); _size = size; @@ -76,7 +76,7 @@ public: } Common::String _filename; - CBArray _lines; + BaseArray _lines; }; @@ -85,42 +85,42 @@ public: public: bool dbgSendScripts(IWmeDebugClient *client); - CBArray _breakpoints; + BaseArray _breakpoints; bool addBreakpoint(const char *scriptFilename, int line); bool removeBreakpoint(const char *scriptFilename, int line); bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(CScScript *script); + bool refreshScriptBreakpoints(ScScript *script); bool saveBreakpoints(); bool loadBreakpoints(); bool clearGlobals(bool includingNatives = false); bool tickUnbreakable(); bool removeFinishedScripts(); - bool isValidScript(CScScript *script); + bool isValidScript(ScScript *script); - CScScript *_currentScript; + ScScript *_currentScript; bool resumeAll(); bool pauseAll(); void editorCleanup(); - bool resetObject(CBObject *Object); - bool resetScript(CScScript *script); + bool resetObject(BaseObject *Object); + bool resetScript(ScScript *script); bool emptyScriptCache(); byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) + DECLARE_PERSISTENT(ScEngine, BaseClass) bool cleanup(); int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); bool tick(); - CScValue *_globals; - CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + ScValue *_globals; + ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); static const bool _compilerAvailable = false; - CScEngine(CBGame *inGame); - virtual ~CScEngine(); + ScEngine(BaseGame *inGame); + virtual ~ScEngine(); static byte *loadFile(void *data, char *filename, uint32 *size); static void closeFile(void *data, byte *buffer); static void parseElement(void *data, int line, int type, void *elementData); - CBArray _scripts; + BaseArray _scripts; void enableProfiling(); void disableProfiling(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index a1b8249cb1..41059b2d80 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -34,16 +34,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXArray, false) +IMPLEMENT_PERSISTENT(SXArray, false) -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { - return new CSXArray(inGame, stack); +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { + return new SXArray(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { _length = 0; - _values = new CScValue(_gameRef); + _values = new ScValue(_gameRef); int numParams = stack->pop()->getInt(0); @@ -59,27 +59,27 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame): BaseScriptable(inGame) { _length = 0; - _values = new CScValue(_gameRef); + _values = new ScValue(_gameRef); } ////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { +SXArray::~SXArray() { delete _values; _values = NULL; } ////////////////////////////////////////////////////////////////////////// -const char *CSXArray::scToString() { +const char *SXArray::scToString() { static char dummy[32768]; // TODO: Get rid of static. strcpy(dummy, ""); char propName[20]; for (int i = 0; i < _length; i++) { sprintf(propName, "%d", i); - CScValue *val = _values->getProp(propName); + ScValue *val = _values->getProp(propName); if (val) { if (strlen(dummy) + strlen(val->getString()) < 32768) { strcat(dummy, val->getString()); @@ -93,7 +93,7 @@ const char *CSXArray::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *name) { +ScValue *SXArray::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::scSetProperty(const char *name, CScValue *value) { +bool SXArray::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// @@ -199,8 +199,8 @@ bool CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool SXArray::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_length)); persistMgr->transfer(TMEMBER(_values)); @@ -210,7 +210,7 @@ bool CSXArray::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::validNumber(const char *origStr, char *outStr) { +bool SXArray::validNumber(const char *origStr, char *outStr) { bool isNumber = true; for (uint32 i = 0; i < strlen(origStr); i++) { if (!(origStr[i] >= '0' && origStr[i] <= '9')) { @@ -227,7 +227,7 @@ bool CSXArray::validNumber(const char *origStr, char *outStr) { } ////////////////////////////////////////////////////////////////////////// -bool CSXArray::push(CScValue *val) { +bool SXArray::push(ScValue *val) { char paramName[20]; _length++; sprintf(paramName, "%d", _length - 1); diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index b873416572..3f8d703f85 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -33,20 +33,20 @@ namespace WinterMute { -class CSXArray : public CBScriptable { +class SXArray : public BaseScriptable { public: - bool push(CScValue *Val); + bool push(ScValue *Val); bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXArray, BaseScriptable) + SXArray(BaseGame *inGame, ScStack *stack); + SXArray(BaseGame *inGame); + virtual ~SXArray(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); int _length; - CScValue *_values; + ScValue *_values; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 211c0d34f0..322fb9bc5b 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -32,19 +32,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXDate, false) +IMPLEMENT_PERSISTENT(SXDate, false) -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { + return new SXDate(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXDate::SXDate(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); - CScValue *valYear = stack->pop(); + ScValue *valYear = stack->pop(); _tm.tm_year = valYear->getInt() - 1900; _tm.tm_mon = stack->pop()->getInt() - 1; _tm.tm_mday = stack->pop()->getInt(); @@ -59,12 +59,12 @@ CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { +SXDate::~SXDate() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXDate::scToString() { +const char *SXDate::scToString() { // TODO: Make this more stringy, and less ISO 8601-like _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); return _strRep.c_str(); @@ -75,7 +75,7 @@ const char *CSXDate::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *name) { +ScValue *SXDate::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ CScValue *CSXDate::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::scSetProperty(const char *name, CScValue *value) { +bool SXDate::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -238,9 +238,9 @@ bool CSXDate::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::persist(CBPersistMgr *persistMgr) { +bool SXDate::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_tm.tm_year)); persistMgr->transfer(TMEMBER(_tm.tm_mon)); persistMgr->transfer(TMEMBER(_tm.tm_mday)); @@ -251,9 +251,9 @@ bool CSXDate::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -int CSXDate::scCompare(CBScriptable *Value) { +int SXDate::scCompare(BaseScriptable *Value) { TimeDate time1 = _tm; - TimeDate time2 = ((CSXDate *)Value)->_tm; + TimeDate time2 = ((SXDate *)Value)->_tm; if (time1.tm_year < time2.tm_year) { return -1; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 82f6af1f1d..b2df4abe94 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -34,15 +34,15 @@ namespace WinterMute { -class CSXDate : public CBScriptable { +class SXDate : public BaseScriptable { public: - int scCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + int scCompare(BaseScriptable *Value); + DECLARE_PERSISTENT(SXDate, BaseScriptable) + SXDate(BaseGame *inGame, ScStack *Stack); + virtual ~SXDate(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); char *_string; TimeDate _tm; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 58c0416b43..ffa362a938 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -42,19 +42,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXFile, false) +IMPLEMENT_PERSISTENT(SXFile, false) -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { - return new CSXFile(inGame, stack); +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { + return new SXFile(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); _filename = NULL; - if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString()); _readFile = NULL; _writeFile = NULL; @@ -65,12 +65,12 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { +SXFile::~SXFile() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CSXFile::cleanup() { +void SXFile::cleanup() { delete[] _filename; _filename = NULL; close(); @@ -78,7 +78,7 @@ void CSXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CSXFile::close() { +void SXFile::close() { if (_readFile) { _gameRef->_fileManager->closeFile(_readFile); _readFile = NULL; @@ -93,14 +93,14 @@ void CSXFile::close() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXFile::scToString() { +const char *SXFile::scToString() { if (_filename) return _filename; else return "[file object]"; } #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(1); const char *filename = stack->pop()->getString(); cleanup(); - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); stack->pushNULL(); return STATUS_OK; } @@ -182,7 +182,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); close(); - stack->pushBool(CBPlatform::deleteFile(_filename) != false); + stack->pushBool(BasePlatform::deleteFile(_filename) != false); return STATUS_OK; } @@ -195,7 +195,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta bool Overwrite = stack->pop()->getBool(true); close(); - stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); return STATUS_OK; } @@ -593,12 +593,12 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *name) { +ScValue *SXFile::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -649,12 +649,12 @@ CScValue *CSXFile::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::scSetProperty(const char *name, CScValue *value) { +bool SXFile::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -672,11 +672,11 @@ bool CSXFile::scSetProperty(const char *name, CScValue *value) { } return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getPos() { +uint32 SXFile::getPos() { if (_mode == 1 && _readFile) return _readFile->pos(); else if ((_mode == 2 || _mode == 3) && _writeFile) { @@ -689,11 +689,11 @@ uint32 CSXFile::getPos() { } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, int whence) { +bool SXFile::setPos(uint32 pos, int whence) { if (_mode == 1 && _readFile) return _readFile->seek(pos, whence); else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - seeking in WriteFile not supported"); + error("SXFile - seeking in WriteFile not supported"); return false; // return fseek((FILE *)_writeFile, pos, (int)origin) == 0; } @@ -701,11 +701,11 @@ bool CSXFile::setPos(uint32 pos, int whence) { } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getLength() { +uint32 SXFile::getLength() { if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - reading length for WriteFile not supported"); + error("SXFile - reading length for WriteFile not supported"); return 0; /* uint32 currentPos = ftell((FILE *)_writeFile); @@ -717,9 +717,9 @@ uint32 CSXFile::getLength() { } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::persist(CBPersistMgr *persistMgr) { +bool SXFile::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_mode)); @@ -767,12 +767,12 @@ bool CSXFile::persist(CBPersistMgr *persistMgr) { } // Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { +Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool binary) { error("SXFile::openForWrite - WriteFiles not supported"); } // Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { +Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { error("SXFile::openForAppend - WriteFiles not supported"); } diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index 5a6811fe57..4d78feb044 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -35,17 +35,17 @@ namespace WinterMute { -class CBFile; +class BaseFile; -class CSXFile : public CBScriptable { +class SXFile : public BaseScriptable { public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXFile, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); + SXFile(BaseGame *inGame, ScStack *Stack); + virtual ~SXFile(); private: Common::SeekableReadStream *_readFile; Common::WriteStream *_writeFile; diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 22b08087b7..1c37a15aa9 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -40,26 +40,26 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CSXMath, true) +IMPLEMENT_PERSISTENT(SXMath, true) -CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); +BaseScriptable *makeSXMath(BaseGame *inGame) { + return new SXMath(inGame); } ////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { +SXMath::SXMath(BaseGame *inGame): BaseScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { +SXMath::~SXMath() { } ////////////////////////////////////////////////////////////////////////// -bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// @@ -250,7 +250,7 @@ bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *name) { +ScValue *SXMath::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -274,21 +274,21 @@ CScValue *CSXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -double CSXMath::degreeToRadian(double value) { +double SXMath::degreeToRadian(double value) { return value * (M_PI / 180.0f); } ////////////////////////////////////////////////////////////////////////// -double CSXMath::radianToDegree(double value) { +double SXMath::radianToDegree(double value) { return value * (180.0f / M_PI); } ////////////////////////////////////////////////////////////////////////// -bool CSXMath::persist(CBPersistMgr *persistMgr) { +bool SXMath::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index 422521233f..393342e5ca 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -34,13 +34,13 @@ namespace WinterMute { -class CSXMath : public CBScriptable { +class SXMath : public BaseScriptable { public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXMath, BaseScriptable) + SXMath(BaseGame *inGame); + virtual ~SXMath(); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); private: double degreeToRadian(double value); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index df2bf188ff..79ba978002 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -35,14 +35,14 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) +IMPLEMENT_PERSISTENT(SXMemBuffer, false) -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { - return new CSXMemBuffer(inGame, stack); +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { + return new SXMemBuffer(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); _buffer = NULL; _size = 0; @@ -52,31 +52,31 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *Buffer): BaseScriptable(inGame) { _size = 0; _buffer = Buffer; } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { +SXMemBuffer::~SXMemBuffer() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::scToMemBuffer() { +void *SXMemBuffer::scToMemBuffer() { return _buffer; } ////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::cleanup() { +void SXMemBuffer::cleanup() { if (_size) free(_buffer); _buffer = NULL; _size = 0; } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::resize(int newSize) { +bool SXMemBuffer::resize(int newSize) { int oldSize = _size; if (_size == 0) { @@ -102,7 +102,7 @@ bool CSXMemBuffer::resize(int newSize) { } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { +bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { if (_buffer == NULL) { script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; @@ -118,13 +118,13 @@ bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { } ////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::scToString() { +const char *SXMemBuffer::scToString() { return "[membuffer object]"; } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -264,7 +264,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); else { void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); stack->pushNative(buf, false); } return STATUS_OK; @@ -395,7 +395,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); int start = stack->pop()->getInt(); - /* CScValue *Val = */ stack->pop(); + /* ScValue *Val = */ stack->pop(); if (!checkBounds(script, start, sizeof(void *))) stack->pushBool(false); @@ -433,7 +433,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *name) { +ScValue *SXMemBuffer::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -452,12 +452,12 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { +bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -475,14 +475,14 @@ bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { } return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { +bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_size)); @@ -500,7 +500,7 @@ bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *val) { +int SXMemBuffer::scCompare(BaseScriptable *val) { if (_buffer == val->scToMemBuffer()) return 0; else return 1; } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index a9d78e50e4..c325181e3f 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -34,24 +34,24 @@ namespace WinterMute { -class CSXMemBuffer : public CBScriptable { +class SXMemBuffer : public BaseScriptable { public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *stack); - CSXMemBuffer(CBGame *inGame, void *buffer); - virtual ~CSXMemBuffer(); + SXMemBuffer(BaseGame *inGame, ScStack *stack); + SXMemBuffer(BaseGame *inGame, void *buffer); + virtual ~SXMemBuffer(); virtual void *scToMemBuffer(); int _size; private: bool resize(int newSize); void *_buffer; void cleanup(); - bool checkBounds(CScScript *script, int start, int length); + bool checkBounds(ScScript *script, int start, int length); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index cb0d32d1a3..b72e3e4b97 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -36,14 +36,14 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CSXObject, false) +IMPLEMENT_PERSISTENT(SXObject, false) -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { - return new CSXObject(inGame, stack); +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { + return new SXObject(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { +SXObject::SXObject(BaseGame *inGame, ScStack *stack): BaseObject(inGame) { int numParams = stack->pop()->getInt(0); for (int i = 0; i < numParams; i++) { addScript(stack->pop()->getString()); @@ -52,14 +52,14 @@ CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { +SXObject::~SXObject() { } ////////////////////////////////////////////////////////////////////////// -bool CSXObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool SXObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index b4e869d5b3..d744c58042 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -34,11 +34,11 @@ namespace WinterMute { -class CSXObject : public CBObject { +class SXObject : public BaseObject { public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); + DECLARE_PERSISTENT(SXObject, BaseObject) + SXObject(BaseGame *inGame, ScStack *Stack); + virtual ~SXObject(); }; diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index bd7541fadd..e645772b6f 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -37,19 +37,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXString, false) +IMPLEMENT_PERSISTENT(SXString, false) -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { - return new CSXString(inGame, stack); +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { + return new SXString(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { _string = NULL; _capacity = 0; stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isInt()) { _capacity = MAX(0, val->getInt()); @@ -66,13 +66,13 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { +SXString::~SXString() { if (_string) delete [] _string; } ////////////////////////////////////////////////////////////////////////// -void CSXString::setStringVal(const char *val) { +void SXString::setStringVal(const char *val) { int len = strlen(val); if (len >= _capacity) { _capacity = len + 1; @@ -86,20 +86,20 @@ void CSXString::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// -const char *CSXString::scToString() { +const char *SXString::scToString() { if (_string) return _string; else return "[null string]"; } ////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *val) { +void SXString::scSetString(const char *val) { setStringVal(val); } ////////////////////////////////////////////////////////////////////////// -bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int start = stack->pop()->getInt(); int end = stack->pop()->getInt(); - if (end < start) CBUtils::swap(&start, &end); + if (end < start) BaseUtils::swap(&start, &end); //try { WideString str; @@ -138,7 +138,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); int start = stack->pop()->getInt(); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); int len = val->getInt(); if (!val->isNULL() && len <= 0) { @@ -245,11 +245,11 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Split") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); char separators[MAX_PATH_LENGTH] = ","; if (!val->isNULL()) strcpy(separators, val->getString()); - CSXArray *array = new CSXArray(_gameRef); + SXArray *array = new SXArray(_gameRef); if (!array) { stack->pushNULL(); return STATUS_OK; @@ -299,9 +299,9 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS WideString &part = (*it); if (_gameRef->_textEncoding == TEXT_UTF8) - val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); else - val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); array->push(val); delete val; @@ -317,7 +317,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *name) { +ScValue *SXString::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,7 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXString::scSetProperty(const char *name, CScValue *value) { +bool SXString::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// @@ -377,9 +377,9 @@ bool CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXString::persist(CBPersistMgr *persistMgr) { +bool SXString::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_capacity)); @@ -397,8 +397,8 @@ bool CSXString::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *val) { - return strcmp(_string, ((CSXString *)val)->_string); +int SXString::scCompare(BaseScriptable *val) { + return strcmp(_string, ((SXString *)val)->_string); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 52a1524dde..9a3bbfc80b 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -34,19 +34,19 @@ namespace WinterMute { -class CSXString : public CBScriptable { +class SXString : public BaseScriptable { public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXString, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); void scSetString(const char *val); const char *scToString(); void setStringVal(const char *val); - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); + SXString(BaseGame *inGame, ScStack *Stack); + virtual ~SXString(); private: char *_string; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 188cb2d15c..74cc7a57ee 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -32,16 +32,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScStack, false) +IMPLEMENT_PERSISTENT(ScStack, false) ////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { +ScStack::ScStack(BaseGame *inGame): BaseClass(inGame) { _sP = -1; } ////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { +ScStack::~ScStack() { #if _DEBUG //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); @@ -55,7 +55,7 @@ CScStack::~CScStack() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::pop() { +ScValue *ScStack::pop() { if (_sP < 0) { _gameRef->LOG(0, "Fatal: Stack underflow"); return NULL; @@ -66,14 +66,14 @@ CScValue *CScStack::pop() { ////////////////////////////////////////////////////////////////////////// -void CScStack::push(CScValue *val) { +void ScStack::push(ScValue *val) { _sP++; if (_sP < _values.getSize()) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { - CScValue *copyVal = new CScValue(_gameRef); + ScValue *copyVal = new ScValue(_gameRef); copyVal->copy(val); _values.add(copyVal); } @@ -81,11 +81,11 @@ void CScStack::push(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getPushValue() { +ScValue *ScStack::getPushValue() { _sP++; if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(_gameRef); + ScValue *val = new ScValue(_gameRef); _values.add(val); } _values[_sP]->cleanup(); @@ -95,14 +95,14 @@ CScValue *CScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getTop() { +ScValue *ScStack::getTop() { if (_sP < 0 || _sP >= _values.getSize()) return NULL; else return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getAt(int index) { +ScValue *ScStack::getAt(int index) { index = _sP - index; if (index < 0 || index >= _values.getSize()) return NULL; else return _values[index]; @@ -110,7 +110,7 @@ CScValue *CScStack::getAt(int index) { ////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expectedParams) { +void ScStack::correctParams(uint32 expectedParams) { uint32 nuParams = (uint32)pop()->getInt(); if (expectedParams < nuParams) { // too many params @@ -124,7 +124,7 @@ void CScStack::correctParams(uint32 expectedParams) { } else if (expectedParams > nuParams) { // need more params while (expectedParams > nuParams) { //Push(null_val); - CScValue *nullVal = new CScValue(_gameRef); + ScValue *nullVal = new ScValue(_gameRef); nullVal->setNULL(); _values.insertAt(_sP - nuParams + 1, nullVal); nuParams++; @@ -140,9 +140,9 @@ void CScStack::correctParams(uint32 expectedParams) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushNULL() { +void ScStack::pushNULL() { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setNULL(); Push(val); delete val; @@ -152,9 +152,9 @@ void CScStack::pushNULL() { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushInt(int val) { +void ScStack::pushInt(int val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setInt(Val); Push(val); delete val; @@ -164,9 +164,9 @@ void CScStack::pushInt(int val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushFloat(double val) { +void ScStack::pushFloat(double val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setFloat(Val); Push(val); delete val; @@ -176,9 +176,9 @@ void CScStack::pushFloat(double val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushBool(bool val) { +void ScStack::pushBool(bool val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setBool(Val); Push(val); delete val; @@ -188,9 +188,9 @@ void CScStack::pushBool(bool val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushString(const char *val) { +void ScStack::pushString(const char *val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setString(Val); Push(val); delete val; @@ -200,9 +200,9 @@ void CScStack::pushString(const char *val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushNative(CBScriptable *val, bool persistent) { +void ScStack::pushNative(BaseScriptable *val, bool persistent) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setNative(Val, Persistent); Push(val); delete val; @@ -213,7 +213,7 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -bool CScStack::persist(CBPersistMgr *persistMgr) { +bool ScStack::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 6460f901fe..3aacad0765 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -36,27 +36,27 @@ namespace WinterMute { -class CScValue; -class CBScriptable; +class ScValue; +class BaseScriptable; -class CScStack : public CBBase { +class ScStack : public BaseClass { public: - CScValue *getAt(int Index); - CScValue *getPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *val, bool persistent); + ScValue *getAt(int Index); + ScValue *getPushValue(); + DECLARE_PERSISTENT(ScStack, BaseClass) + void pushNative(BaseScriptable *val, bool persistent); void pushString(const char *val); void pushBool(bool val); void pushInt(int val); void pushFloat(double val); void pushNULL(); void correctParams(uint32 expectedParams); - CScValue *getTop(); - void push(CScValue *val); - CScValue *pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; + ScValue *getTop(); + void push(ScValue *val); + ScValue *pop(); + ScStack(BaseGame *inGame); + virtual ~ScStack(); + BaseArray _values; int _sP; }; diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index da47ed299f..0d8c34e719 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -40,10 +40,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CScValue, false) +IMPLEMENT_PERSISTENT(ScValue, false) ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { _type = VAL_NULL; _valBool = false; @@ -58,7 +58,7 @@ CScValue::CScValue(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { _type = VAL_BOOL; _valBool = val; @@ -73,7 +73,7 @@ CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { _type = VAL_INT; _valInt = val; @@ -88,7 +88,7 @@ CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { _type = VAL_FLOAT; _valFloat = val; @@ -103,7 +103,7 @@ CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { _type = VAL_STRING; _valString = NULL; setStringVal(val); @@ -119,7 +119,7 @@ CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool ignoreNatives) { +void ScValue::cleanup(bool ignoreNatives) { deleteProps(); if (_valString) delete [] _valString; @@ -150,13 +150,13 @@ void CScValue::cleanup(bool ignoreNatives) { ////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { +ScValue::~ScValue() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::getProp(const char *name) { +ScValue *ScValue::getProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); if (_type == VAL_STRING && strcmp(name, "Length") == 0) { @@ -176,7 +176,7 @@ CScValue *CScValue::getProp(const char *name) { return _gameRef->_scValue; } - CScValue *ret = NULL; + ScValue *ret = NULL; if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); @@ -188,7 +188,7 @@ CScValue *CScValue::getProp(const char *name) { } ////////////////////////////////////////////////////////////////////////// -bool CScValue::deleteProp(const char *name) { +bool ScValue::deleteProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); _valIter = _valObject.find(name); @@ -203,7 +203,7 @@ bool CScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { +bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, val); @@ -213,14 +213,14 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set } if (DID_FAIL(ret)) { - CScValue *newVal = NULL; + ScValue *newVal = NULL; _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { newVal = _valIter->_value; } if (!newVal) - newVal = new CScValue(_gameRef); + newVal = new ScValue(_gameRef); else newVal->cleanup(); newVal->copy(val, copyWhole); @@ -235,7 +235,7 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set delete _valIter->_value; _valIter->_value = NULL; } - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->Copy(Val, CopyWhole); val->_isConstVar = SetAsConst; _valObject[Name] = val; @@ -249,7 +249,7 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set ////////////////////////////////////////////////////////////////////////// -bool CScValue::propExists(const char *name) { +bool ScValue::propExists(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->propExists(name); _valIter = _valObject.find(name); @@ -259,10 +259,10 @@ bool CScValue::propExists(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CScValue::deleteProps() { +void ScValue::deleteProps() { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; + delete(ScValue *)_valIter->_value; _valIter++; } _valObject.clear(); @@ -270,7 +270,7 @@ void CScValue::deleteProps() { ////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool includingNatives) { +void ScValue::CleanProps(bool includingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); @@ -279,7 +279,7 @@ void CScValue::CleanProps(bool includingNatives) { } ////////////////////////////////////////////////////////////////////////// -bool CScValue::isNULL() { +bool ScValue::isNULL() { if (_type == VAL_VARIABLE_REF) return _valRef->isNULL(); @@ -288,7 +288,7 @@ bool CScValue::isNULL() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isNative() { +bool ScValue::isNative() { if (_type == VAL_VARIABLE_REF) return _valRef->isNative(); @@ -297,7 +297,7 @@ bool CScValue::isNative() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isString() { +bool ScValue::isString() { if (_type == VAL_VARIABLE_REF) return _valRef->isString(); @@ -306,7 +306,7 @@ bool CScValue::isString() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isFloat() { +bool ScValue::isFloat() { if (_type == VAL_VARIABLE_REF) return _valRef->isFloat(); @@ -315,7 +315,7 @@ bool CScValue::isFloat() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isInt() { +bool ScValue::isInt() { if (_type == VAL_VARIABLE_REF) return _valRef->isInt(); @@ -324,7 +324,7 @@ bool CScValue::isInt() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isBool() { +bool ScValue::isBool() { if (_type == VAL_VARIABLE_REF) return _valRef->isBool(); @@ -333,7 +333,7 @@ bool CScValue::isBool() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isObject() { +bool ScValue::isObject() { if (_type == VAL_VARIABLE_REF) return _valRef->isObject(); @@ -342,7 +342,7 @@ bool CScValue::isObject() { ////////////////////////////////////////////////////////////////////////// -TValType CScValue::getTypeTolerant() { +TValType ScValue::getTypeTolerant() { if (_type == VAL_VARIABLE_REF) return _valRef->getType(); @@ -351,7 +351,7 @@ TValType CScValue::getTypeTolerant() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setBool(bool val) { +void ScValue::setBool(bool val) { if (_type == VAL_VARIABLE_REF) { _valRef->setBool(val); return; @@ -368,7 +368,7 @@ void CScValue::setBool(bool val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setInt(int val) { +void ScValue::setInt(int val) { if (_type == VAL_VARIABLE_REF) { _valRef->setInt(val); return; @@ -385,7 +385,7 @@ void CScValue::setInt(int val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setFloat(double val) { +void ScValue::setFloat(double val) { if (_type == VAL_VARIABLE_REF) { _valRef->setFloat(val); return; @@ -402,7 +402,7 @@ void CScValue::setFloat(double val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setString(const char *val) { +void ScValue::setString(const char *val) { if (_type == VAL_VARIABLE_REF) { _valRef->setString(val); return; @@ -418,12 +418,12 @@ void CScValue::setString(const char *val) { else _type = VAL_NULL; } -void CScValue::setString(const Common::String &val) { +void ScValue::setString(const Common::String &val) { setString(val.c_str()); } ////////////////////////////////////////////////////////////////////////// -void CScValue::setStringVal(const char *val) { +void ScValue::setStringVal(const char *val) { if (_valString) { delete [] _valString; _valString = NULL; @@ -442,7 +442,7 @@ void CScValue::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setNULL() { +void ScValue::setNULL() { if (_type == VAL_VARIABLE_REF) { _valRef->setNULL(); return; @@ -460,7 +460,7 @@ void CScValue::setNULL() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *val, bool persistent) { +void ScValue::setNative(BaseScriptable *val, bool persistent) { if (_type == VAL_VARIABLE_REF) { _valRef->setNative(val, persistent); return; @@ -487,7 +487,7 @@ void CScValue::setNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setObject() { +void ScValue::setObject() { if (_type == VAL_VARIABLE_REF) { _valRef->setObject(); return; @@ -499,14 +499,14 @@ void CScValue::setObject() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *val) { +void ScValue::setReference(ScValue *val) { _valRef = val; _type = VAL_VARIABLE_REF; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool defaultVal) { +bool ScValue::getBool(bool defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getBool(); @@ -533,7 +533,7 @@ bool CScValue::getBool(bool defaultVal) { ////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int defaultVal) { +int ScValue::getInt(int defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); switch (_type) { @@ -559,7 +559,7 @@ int CScValue::getInt(int defaultVal) { ////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double defaultVal) { +double ScValue::getFloat(double defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getFloat(); @@ -585,7 +585,7 @@ double CScValue::getFloat(double defaultVal) { } ////////////////////////////////////////////////////////////////////////// -void *CScValue::getMemBuffer() { +void *ScValue::getMemBuffer() { if (_type == VAL_VARIABLE_REF) return _valRef->getMemBuffer(); @@ -596,7 +596,7 @@ void *CScValue::getMemBuffer() { ////////////////////////////////////////////////////////////////////////// -const char *CScValue::getString() { +const char *ScValue::getString() { if (_type == VAL_VARIABLE_REF) return _valRef->getString(); @@ -646,7 +646,7 @@ const char *CScValue::getString() { ////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::getNative() { +BaseScriptable *ScValue::getNative() { if (_type == VAL_VARIABLE_REF) return _valRef->getNative(); @@ -656,13 +656,13 @@ CBScriptable *CScValue::getNative() { ////////////////////////////////////////////////////////////////////////// -TValType CScValue::getType() { +TValType ScValue::getType() { return _type; } ////////////////////////////////////////////////////////////////////////// -void CScValue::copy(CScValue *orig, bool copyWhole) { +void ScValue::copy(ScValue *orig, bool copyWhole) { _gameRef = orig->_gameRef; if (_valNative && !_persistent) { @@ -694,7 +694,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) { if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { orig->_valIter = orig->_valObject.begin(); while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key] = new ScValue(_gameRef); _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } @@ -703,7 +703,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setValue(CScValue *val) { +void ScValue::setValue(ScValue *val) { if (val->_type == VAL_VARIABLE_REF) { setValue(val->_valRef); return; @@ -725,7 +725,7 @@ void CScValue::setValue(CScValue *val) { _valNative->scSetString(val->getString()); break; default: - warning("CScValue::setValue - unhandled enum"); + warning("ScValue::setValue - unhandled enum"); break; } } @@ -735,7 +735,7 @@ void CScValue::setValue(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::persist(CBPersistMgr *persistMgr) { +bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_persistent)); @@ -760,7 +760,7 @@ bool CScValue::persist(CBPersistMgr *persistMgr) { _valIter++; } } else { - CScValue *val; + ScValue *val; persistMgr->transfer("", &size); for (int i = 0; i < size; i++) { persistMgr->transfer("", &str); @@ -819,7 +819,7 @@ bool CScValue::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { +bool ScValue::saveAsText(BaseDynamicBuffer *buffer, int indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { buffer->putTextIndent(indent, "PROPERTY {\n"); @@ -835,7 +835,7 @@ bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::compare(CScValue *val1, CScValue *val2) { +int ScValue::compare(ScValue *val1, ScValue *val2) { // both natives? if (val1->isNative() && val2->isNative()) { // same class? @@ -871,14 +871,14 @@ int CScValue::compare(CScValue *val1, CScValue *val2) { ////////////////////////////////////////////////////////////////////////// -int CScValue::compareStrict(CScValue *val1, CScValue *val2) { +int ScValue::compareStrict(ScValue *val1, ScValue *val2) { if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return CScValue::compare(val1, val2); + else return ScValue::compare(val1, val2); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { +bool ScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); @@ -889,24 +889,24 @@ bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableTyp ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, int value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, const char *value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, double value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -914,8 +914,8 @@ bool CScValue::setProperty(const char *propName, double value) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, bool value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -923,8 +923,8 @@ bool CScValue::setProperty(const char *propName, bool value) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(_gameRef); +bool ScValue::setProperty(const char *propName) { + ScValue *val = new ScValue(_gameRef); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -934,7 +934,7 @@ bool CScValue::setProperty(const char *propName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugProp ////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::dbgGetType() { +EWmeDebuggerPropType ScValue::dbgGetType() { switch (getType()) { case VAL_NULL: return WME_DBGPROP_NULL; @@ -956,70 +956,70 @@ EWmeDebuggerPropType CScValue::dbgGetType() { } ////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetValInt() { +int ScValue::dbgGetValInt() { return getInt(); } ////////////////////////////////////////////////////////////////////////// -double CScValue::dbgGetValFloat() { +double ScValue::dbgGetValFloat() { return getFloat(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetValBool() { +bool ScValue::dbgGetValBool() { return getBool(); } ////////////////////////////////////////////////////////////////////////// -const char *CScValue::dbgGetValString() { +const char *ScValue::dbgGetValString() { return getString(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::dbgGetValNative() { +IWmeDebugObject *ScValue::dbgGetValNative() { return getNative(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(int value) { +bool ScValue::dbgSetVal(int value) { setInt(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(double value) { +bool ScValue::dbgSetVal(double value) { setFloat(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(bool value) { +bool ScValue::dbgSetVal(bool value) { setBool(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(const char *value) { +bool ScValue::dbgSetVal(const char *value) { setString(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal() { +bool ScValue::dbgSetVal() { setNULL(); return true; } ////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetNumProperties() { +int ScValue::dbgGetNumProperties() { if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetNumProperties(); else return _valObject.size(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { +bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetProperty(index, name, value); else { @@ -1039,7 +1039,7 @@ bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **valu } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetDescription(char *buf, int bufSize) { +bool ScValue::dbgGetDescription(char *buf, int bufSize) { if (_type == VAL_VARIABLE_REF) return _valRef->dbgGetDescription(buf, bufSize); diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index eaee3ed773..7a684d2334 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -38,25 +38,25 @@ namespace WinterMute { -class CScScript; -class CBScriptable; +class ScScript; +class BaseScriptable; -class CScValue : public CBBase, public IWmeDebugProp { +class ScValue : public BaseClass, public IWmeDebugProp { public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID); - static int compare(CScValue *val1, CScValue *val2); - static int compareStrict(CScValue *val1, CScValue *val2); + static int compare(ScValue *val1, ScValue *val2); + static int compareStrict(ScValue *val1, ScValue *val2); TValType getTypeTolerant(); void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) + DECLARE_PERSISTENT(ScValue, BaseClass) bool _isConstVar; - bool saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *val); + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + void setValue(ScValue *val); bool _persistent; bool propExists(const char *name); - void copy(CScValue *orig, bool copyWhole = false); + void copy(ScValue *orig, bool copyWhole = false); void setStringVal(const char *val); TValType getType(); bool getBool(bool defaultVal = false); @@ -64,7 +64,7 @@ public: double getFloat(double defaultVal = 0.0f); const char *getString(); void *getMemBuffer(); - CBScriptable *getNative(); + BaseScriptable *getNative(); bool deleteProp(const char *name); void deleteProps(); void CleanProps(bool includingNatives); @@ -74,9 +74,9 @@ public: void setString(const char *val); void setString(const Common::String &val); void setNULL(); - void setNative(CBScriptable *val, bool persistent = false); + void setNative(BaseScriptable *val, bool persistent = false); void setObject(); - void setReference(CScValue *val); + void setReference(ScValue *val); bool isNULL(); bool isNative(); bool isString(); @@ -84,10 +84,10 @@ public: bool isFloat(); bool isInt(); bool isObject(); - bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); - CScValue *getProp(const char *name); - CBScriptable *_valNative; - CScValue *_valRef; + bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); + ScValue *getProp(const char *name); + BaseScriptable *_valNative; + ScValue *_valRef; protected: bool _valBool; int _valInt; @@ -95,14 +95,14 @@ protected: char *_valString; public: TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; + ScValue(BaseGame *inGame); + ScValue(BaseGame *inGame, bool Val); + ScValue(BaseGame *inGame, int Val); + ScValue(BaseGame *inGame, double Val); + ScValue(BaseGame *inGame, const char *Val); + virtual ~ScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; bool setProperty(const char *propName, int value); bool setProperty(const char *propName, const char *value); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index e1819e3c65..06421e8632 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -33,10 +33,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSound, false) +IMPLEMENT_PERSISTENT(BaseSound, false) ////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { +BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { _sound = NULL; _soundFilename = NULL; @@ -56,7 +56,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { +BaseSound::~BaseSound() { if (_sound) _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; @@ -66,7 +66,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; @@ -88,7 +88,7 @@ bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool ////////////////////////////////////////////////////////////////////////// -bool CBSound::setSoundSimple() { +bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->setPosition(_soundPosition); @@ -104,14 +104,14 @@ bool CBSound::setSoundSimple() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getLength() { +uint32 BaseSound::getLength() { if (_sound) return _sound->getLength(); else return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::play(bool looping) { +bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); @@ -120,7 +120,7 @@ bool CBSound::play(bool looping) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::stop() { +bool BaseSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); @@ -129,7 +129,7 @@ bool CBSound::stop() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::pause(bool freezePaused) { +bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; if (freezePaused) _sound->_freezePaused = true; @@ -139,7 +139,7 @@ bool CBSound::pause(bool freezePaused) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::resume() { +bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); @@ -148,7 +148,7 @@ bool CBSound::resume() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::persist(CBPersistMgr *persistMgr) { +bool BaseSound::persist(BasePersistenceManager *persistMgr) { if (persistMgr->_saving && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; @@ -182,19 +182,19 @@ bool CBSound::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::isPlaying() { +bool BaseSound::isPlaying() { return _sound && _sound->isPlaying(); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::isPaused() { +bool BaseSound::isPaused() { return _sound && _soundPaused; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPositionTime(uint32 time) { +bool BaseSound::setPositionTime(uint32 time) { if (!_sound) return STATUS_FAILED; _soundPosition = time; bool ret = _sound->setPosition(_soundPosition); @@ -205,7 +205,7 @@ bool CBSound::setPositionTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getPositionTime() { +uint32 BaseSound::getPositionTime() { if (!_sound) return 0; if (!_sound->isPlaying()) @@ -214,42 +214,42 @@ uint32 CBSound::getPositionTime() { } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolumePercent(int percent) { +bool BaseSound::setVolumePercent(int percent) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolume(int volume) { +bool BaseSound::setVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPrivateVolume(int volume) { +bool BaseSound::setPrivateVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->_privateVolume = volume; } ////////////////////////////////////////////////////////////////////////// -int CBSound::getVolumePercent() { +int BaseSound::getVolumePercent() { if (!_sound) return 0; else return _sound->_privateVolume * 100 / 255; } ////////////////////////////////////////////////////////////////////////// -int CBSound::getVolume() { +int BaseSound::getVolume() { if (!_sound) return 0; else return _sound->_privateVolume; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setLoopStart(uint32 pos) { +bool BaseSound::setLoopStart(uint32 pos) { if (!_sound) return STATUS_FAILED; else { @@ -259,7 +259,7 @@ bool CBSound::setLoopStart(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPan(float pan) { +bool BaseSound::setPan(float pan) { if (_sound) return _sound->setPan(pan); else return STATUS_FAILED; @@ -267,7 +267,7 @@ bool CBSound::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { +bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) return STATUS_OK; diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index ef52194090..0b033de47d 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -36,8 +36,8 @@ namespace WinterMute { -class CBSoundBuffer; -class CBSound : public CBBase { +class BaseSoundBuffer; +class BaseSound : public BaseClass { public: bool setPan(float pan); int _soundPrivateVolume; @@ -57,7 +57,7 @@ public: bool _soundLooping; uint32 _soundLoopStart; uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) + DECLARE_PERSISTENT(BaseSound, BaseClass) bool resume(); bool pause(bool freezePaused = false); bool stop(); @@ -68,8 +68,8 @@ public: char *_soundFilename; bool setSoundSimple(); bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); + BaseSound(BaseGame *inGame); + virtual ~BaseSound(); bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); @@ -79,7 +79,7 @@ private: float _sFXParam2; float _sFXParam3; float _sFXParam4; - CBSoundBuffer *_sound; + BaseSoundBuffer *_sound; }; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index a868f99823..b8c19c2985 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -50,7 +50,7 @@ namespace WinterMute { #define MAX_NONSTREAMED_FILE_SIZE 1024*1024 ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { _stream = NULL; _handle = NULL; // _sync = NULL; @@ -71,7 +71,7 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { +BaseSoundBuffer::~BaseSoundBuffer() { stop(); if (_handle) { @@ -88,13 +88,13 @@ CBSoundBuffer::~CBSoundBuffer() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { +void BaseSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { _streamed = Streamed; } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { +bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); #if 0 if (_stream) { @@ -132,15 +132,15 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { if (!_stream) { return STATUS_FAILED; } - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); return STATUS_OK; #if 0 BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; + fileProc.close = BaseSoundBuffer::FileCloseProc; + fileProc.read = BaseSoundBuffer::FileReadProc; + fileProc.seek = BaseSoundBuffer::FileSeekProc; + fileProc.length = BaseSoundBuffer::FileLenProc; _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); if (!_stream) { @@ -148,7 +148,7 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { return STATUS_FAILED; } - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); /* bool res; @@ -196,7 +196,7 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::play(bool looping, uint32 startSample) { +bool BaseSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } @@ -220,7 +220,7 @@ bool CBSoundBuffer::play(bool looping, uint32 startSample) { } ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setLooping(bool looping) { +void BaseSoundBuffer::setLooping(bool looping) { warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); _looping = looping; #if 0 @@ -233,7 +233,7 @@ void CBSoundBuffer::setLooping(bool looping) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::resume() { +bool BaseSoundBuffer::resume() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); } @@ -242,7 +242,7 @@ bool CBSoundBuffer::resume() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::stop() { +bool BaseSoundBuffer::stop() { if (_stream && _handle) { g_system->getMixer()->stopHandle(*_handle); } @@ -251,7 +251,7 @@ bool CBSoundBuffer::stop() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::pause() { +bool BaseSoundBuffer::pause() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, true); } @@ -260,7 +260,7 @@ bool CBSoundBuffer::pause() { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getLength() { +uint32 BaseSoundBuffer::getLength() { if (_stream) { uint32 len = _stream->getLength().msecs(); return len * 1000; @@ -270,17 +270,17 @@ uint32 CBSoundBuffer::getLength() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { +void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { _type = type; } ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::updateVolume() { +void BaseSoundBuffer::updateVolume() { setVolume(_privateVolume); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setVolume(int volume) { +bool BaseSoundBuffer::setVolume(int volume) { _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; if (_stream && _handle) { byte vol = (byte)(_volume); @@ -291,14 +291,14 @@ bool CBSoundBuffer::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPrivateVolume(int volume) { +bool BaseSoundBuffer::setPrivateVolume(int volume) { _privateVolume = volume; return setVolume(_privateVolume); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::isPlaying() { +bool BaseSoundBuffer::isPlaying() { if (_stream && _handle) { return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); } else { @@ -308,7 +308,7 @@ bool CBSoundBuffer::isPlaying() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getPosition() { +uint32 BaseSoundBuffer::getPosition() { if (_stream && _handle) { uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); return pos; @@ -318,8 +318,8 @@ uint32 CBSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPosition(uint32 pos) { - warning("CBSoundBuffer::SetPosition - not implemented yet"); +bool BaseSoundBuffer::setPosition(uint32 pos) { + warning("BaseSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); @@ -330,7 +330,7 @@ bool CBSoundBuffer::setPosition(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setLoopStart(uint32 pos) { +bool BaseSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; #if 0 if (_stream) { @@ -340,7 +340,7 @@ bool CBSoundBuffer::setLoopStart(uint32 pos) { } if (_loopStart > 0) { QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, BaseSoundBuffer::LoopSyncProc, (void *)this); } } #endif @@ -348,8 +348,8 @@ bool CBSoundBuffer::setLoopStart(uint32 pos) { } #if 0 ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); +void BaseSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + BaseSoundBuffer *soundBuf = static_cast(user); QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) @@ -357,7 +357,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPan(float pan) { +bool BaseSoundBuffer::setPan(float pan) { if (_handle) { g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } @@ -365,8 +365,8 @@ bool CBSoundBuffer::setPan(float pan) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("CBSoundBuffer::ApplyFX - not implemented yet"); +bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("BaseSoundBuffer::ApplyFX - not implemented yet"); switch (type) { case SFX_ECHO: break; diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index a491bd49ad..9c85a02b39 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -41,12 +41,12 @@ class SoundHandle; namespace WinterMute { -class CBFile; -class CBSoundBuffer : public CBBase { +class BaseFile; +class BaseSoundBuffer : public BaseClass { public: - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); + BaseSoundBuffer(BaseGame *inGame); + virtual ~BaseSoundBuffer(); bool pause(); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index c2174dea6a..22b22a5db6 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -44,24 +44,24 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); +//IMPLEMENT_PERSISTENT(BaseSoundMgr, true); ////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame): BaseClass(inGame) { _soundAvailable = false; _volumeMaster = 255; } ////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { +BaseSoundMgr::~BaseSoundMgr() { saveSettings(); cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::cleanup() { +bool BaseSoundMgr::cleanup() { for (uint32 i = 0; i < _sounds.size(); i++) delete _sounds[i]; _sounds.clear(); @@ -72,14 +72,14 @@ bool CBSoundMgr::cleanup() { } ////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { +void BaseSoundMgr::saveSettings() { if (_soundAvailable) { _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); } } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initialize() { +bool BaseSoundMgr::initialize() { _soundAvailable = false; if (!g_system->getMixer()->isReady()) { @@ -93,7 +93,7 @@ bool CBSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initLoop() { +bool BaseSoundMgr::initLoop() { if (!_soundAvailable) return STATUS_OK; #if 0 @@ -105,11 +105,11 @@ bool CBSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) return NULL; - CBSoundBuffer *sound; + BaseSoundBuffer *sound; // try to switch WAV to OGG file (if available) AnsiString ext = PathUtil::getExtension(filename); @@ -123,7 +123,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp } } - sound = new CBSoundBuffer(_gameRef); + sound = new BaseSoundBuffer(_gameRef); if (!sound) return NULL; sound->setStreaming(streamed); @@ -149,7 +149,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { +bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { if (!sound) return STATUS_FAILED; @@ -163,7 +163,7 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { +bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; @@ -177,7 +177,7 @@ bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { +bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { if (!_soundAvailable) return STATUS_OK; @@ -200,13 +200,13 @@ bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { +bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { return setVolume(type, percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { +byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { int volume = 0; switch (type) { @@ -225,7 +225,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolume(byte value) { +bool BaseSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; for (uint32 i = 0; i < _sounds.size(); i++) { _sounds[i]->updateVolume(); @@ -234,25 +234,25 @@ bool CBSoundMgr::setMasterVolume(byte value) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolumePercent(byte percent) { +bool BaseSoundMgr::setMasterVolumePercent(byte percent) { setMasterVolume(percent * 255 / 100); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { +byte BaseSoundMgr::getMasterVolumePercent() { return getMasterVolume() * 100 / 255; } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolume() { +byte BaseSoundMgr::getMasterVolume() { return (byte)_volumeMaster; } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::pauseAll(bool includingMusic) { +bool BaseSoundMgr::pauseAll(bool includingMusic) { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { @@ -266,7 +266,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::resumeAll() { +bool BaseSoundMgr::resumeAll() { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->_freezePaused) { @@ -280,7 +280,7 @@ bool CBSoundMgr::resumeAll() { ////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int x, int y) { +float BaseSoundMgr::posToPan(int x, int y) { float relPos = (float)x / ((float)_gameRef->_renderer->_width); float minPan = -0.7f; diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 2c05bbfcb8..53caffbe61 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -35,14 +35,14 @@ #include "common/array.h" namespace WinterMute { -class CBSoundBuffer; -class CBSoundMgr : public CBBase { +class BaseSoundBuffer; +class BaseSoundMgr : public BaseClass { public: float posToPan(int x, int y); bool resumeAll(); bool pauseAll(bool includingMusic = true); bool cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); byte getMasterVolumePercent(); byte getMasterVolume(); bool setMasterVolume(byte percent); @@ -52,15 +52,15 @@ public: bool setVolume(Audio::Mixer::SoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; - bool removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool removeSound(BaseSoundBuffer *sound); + BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); bool initLoop(); bool initialize(); bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - Common::Array _sounds; + BaseSoundMgr(BaseGame *inGame); + virtual ~BaseSoundMgr(); + Common::Array _sounds; void saveSettings(); }; diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 865e60b447..252531e4d2 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -70,16 +70,16 @@ bool DCCompareElements(const TYPE *pElement1, const ARG_TYPE *pElement2) { return *pElement1 == *pElement2; } -//class CBPersistMgr; +//class BasePersistenceManager; ///////////////////////////////////////////////////////////////////////////// -// CBArray +// BaseArray ///////////////////////////////////////////////////////////////////////////// template -class CBArray { +class BaseArray { public: // Construction - CBArray(); + BaseArray(); // Attributes int getSize() const; @@ -90,7 +90,7 @@ public: // Clean up void freeExtra(); void removeAll(); - bool persist(CBPersistMgr *persistMgr); + bool persist(BasePersistenceManager *persistMgr); // Accessing elements TYPE getAt(int nIndex) const; @@ -104,8 +104,8 @@ public: // Potentially growing the array void setAtGrow(int nIndex, ARG_TYPE newElement); int add(ARG_TYPE newElement); - int append(const CBArray &src); - void copy(const CBArray &src); + int append(const BaseArray &src); + void copy(const BaseArray &src); // overloaded operator helpers TYPE operator[](int nIndex) const; @@ -114,7 +114,7 @@ public: // Operations that move elements around void insertAt(int nIndex, ARG_TYPE newElement, int nCount = 1); void removeAt(int nIndex, int nCount = 1); - void insertAt(int nStartIndex, CBArray *pNewArray); + void insertAt(int nStartIndex, BaseArray *pNewArray); // Implementation protected: @@ -124,71 +124,71 @@ protected: int _nGrowBy; // grow amount public: - ~CBArray(); + ~BaseArray(); }; ///////////////////////////////////////////////////////////////////////////// -// CBArray inline functions +// BaseArray inline functions ///////////////////////////////////////////////////////////////////////////// template -inline int CBArray::getSize() const { +inline int BaseArray::getSize() const { return _nSize; } template -inline int CBArray::getUpperBound() const { +inline int BaseArray::getUpperBound() const { return _nSize - 1; } template -inline void CBArray::removeAll() { +inline void BaseArray::removeAll() { setSize(0, -1); } template -inline TYPE CBArray::getAt(int nIndex) const { +inline TYPE BaseArray::getAt(int nIndex) const { return _pData[nIndex]; } template -inline void CBArray::setAt(int nIndex, ARG_TYPE newElement) { +inline void BaseArray::setAt(int nIndex, ARG_TYPE newElement) { _pData[nIndex] = newElement; } template -inline TYPE &CBArray::elementAt(int nIndex) { +inline TYPE &BaseArray::elementAt(int nIndex) { return _pData[nIndex]; } template -inline const TYPE *CBArray::getData() const { +inline const TYPE *BaseArray::getData() const { return (const TYPE *)_pData; } template -inline TYPE *CBArray::getData() { +inline TYPE *BaseArray::getData() { return (TYPE *)_pData; } template -inline int CBArray::add(ARG_TYPE newElement) { +inline int BaseArray::add(ARG_TYPE newElement) { int nIndex = _nSize; setAtGrow(nIndex, newElement); return nIndex; } template -inline TYPE CBArray::operator[](int nIndex) const { +inline TYPE BaseArray::operator[](int nIndex) const { return getAt(nIndex); } template -inline TYPE &CBArray::operator[](int nIndex) { +inline TYPE &BaseArray::operator[](int nIndex) { return elementAt(nIndex); } ///////////////////////////////////////////////////////////////////////////// -// CBArray out-of-line functions +// BaseArray out-of-line functions ///////////////////////////////////////////////////////////////////////////// template -CBArray::CBArray() { +BaseArray::BaseArray() { _pData = NULL; _nSize = _nMaxSize = _nGrowBy = 0; } ///////////////////////////////////////////////////////////////////////////// template -CBArray::~CBArray() { +BaseArray::~BaseArray() { if (_pData != NULL) { DCDestructElements(_pData, _nSize); delete[](byte *)_pData; @@ -197,7 +197,7 @@ CBArray::~CBArray() { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::setSize(int nNewSize, int nGrowBy) { +void BaseArray::setSize(int nNewSize, int nGrowBy) { if (nGrowBy != -1) _nGrowBy = nGrowBy; // set new size @@ -257,7 +257,7 @@ void CBArray::setSize(int nNewSize, int nGrowBy) { ///////////////////////////////////////////////////////////////////////////// template -int CBArray::append(const CBArray &src) { +int BaseArray::append(const BaseArray &src) { int nOldSize = _nSize; setSize(_nSize + src._nSize); DCCopyElements(_pData + nOldSize, src._pData, src._nSize); @@ -266,14 +266,14 @@ int CBArray::append(const CBArray &src) { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::copy(const CBArray &src) { +void BaseArray::copy(const BaseArray &src) { setSize(src._nSize); DCCopyElements(_pData, src._pData, src._nSize); } ///////////////////////////////////////////////////////////////////////////// template -void CBArray::freeExtra() { +void BaseArray::freeExtra() { if (_nSize != _nMaxSize) { // shrink to desired size TYPE *pNewData = NULL; @@ -292,7 +292,7 @@ void CBArray::freeExtra() { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::setAtGrow(int nIndex, ARG_TYPE newElement) { +void BaseArray::setAtGrow(int nIndex, ARG_TYPE newElement) { if (nIndex >= _nSize) setSize(nIndex + 1, -1); _pData[nIndex] = newElement; @@ -300,7 +300,7 @@ void CBArray::setAtGrow(int nIndex, ARG_TYPE newElement) { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::insertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { +void BaseArray::insertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { if (nIndex >= _nSize) { // adding after the end of the array setSize(nIndex + nCount, -1); // grow so nIndex is valid @@ -325,7 +325,7 @@ void CBArray::insertAt(int nIndex, ARG_TYPE newElement, int nCou ///////////////////////////////////////////////////////////////////////////// template -void CBArray::removeAt(int nIndex, int nCount) { +void BaseArray::removeAt(int nIndex, int nCount) { // just remove a range int nMoveCount = _nSize - (nIndex + nCount); DCDestructElements(&_pData[nIndex], nCount); @@ -337,7 +337,7 @@ void CBArray::removeAt(int nIndex, int nCount) { ///////////////////////////////////////////////////////////////////////////// template -void CBArray::insertAt(int nStartIndex, CBArray *pNewArray) { +void BaseArray::insertAt(int nStartIndex, BaseArray *pNewArray) { if (pNewArray->GetSize() > 0) { InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize()); for (int i = 0; i < pNewArray->GetSize(); i++) @@ -348,7 +348,7 @@ void CBArray::insertAt(int nStartIndex, CBArray *pNewArray) { ///////////////////////////////////////////////////////////////////////////// template -bool CBArray::persist(CBPersistMgr *persistMgr) { +bool BaseArray::persist(BasePersistenceManager *persistMgr) { int i, j; if (persistMgr->_saving) { j = getSize(); diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 0abe78fa35..285c3ffaeb 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -112,7 +112,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::CBPersistMgr pm(NULL, target); + WinterMute::BasePersistenceManager pm(NULL, target); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -128,12 +128,12 @@ public: } void removeSaveState(const char *target, int slot) const { - WinterMute::CBPersistMgr pm(NULL, target); + WinterMute::BasePersistenceManager pm(NULL, target); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::CBPersistMgr pm(NULL, target); + WinterMute::BasePersistenceManager pm(NULL, target); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 205b448880..6473b52bee 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -88,80 +88,80 @@ #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/system/sys_class.h" -// CSysClass adds these objects to the registry, thus they aren't as leaked as they look +// SystemClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ - new WinterMute::CSysClass(class_name::_className, class_name::persistBuild, class_name::persistLoad, persistent_class); + new WinterMute::SystemClass(class_name::_className, class_name::persistBuild, class_name::persistLoad, persistent_class); namespace WinterMute { -// This is done in a separate file, to avoid including the kitchensink in CSysClassRegistry. -void CSysClassRegistry::registerClasses() { - REGISTER_CLASS(CAdActor, false) - REGISTER_CLASS(CAdEntity, false) - REGISTER_CLASS(CAdGame, true) - REGISTER_CLASS(CAdInventory, false) - REGISTER_CLASS(CAdInventoryBox, false) - REGISTER_CLASS(CAdItem, false) - REGISTER_CLASS(CAdLayer, false) - REGISTER_CLASS(CAdNodeState, false) - REGISTER_CLASS(CAdObject, false) - REGISTER_CLASS(CAdPath, false) - REGISTER_CLASS(CAdPathPoint, false) - REGISTER_CLASS(CAdRegion, false) - REGISTER_CLASS(CAdResponse, false) - REGISTER_CLASS(CAdResponseBox, false) - REGISTER_CLASS(CAdResponseContext, false) - REGISTER_CLASS(CAdRotLevel, false) - REGISTER_CLASS(CAdScaleLevel, false) - REGISTER_CLASS(CAdScene, false) - REGISTER_CLASS(CAdSceneNode, false) - REGISTER_CLASS(CAdSceneState, false) - REGISTER_CLASS(CAdSentence, false) - REGISTER_CLASS(CAdSpriteSet, false) - REGISTER_CLASS(CAdTalkDef, false) - REGISTER_CLASS(CAdTalkHolder, false) - REGISTER_CLASS(CAdTalkNode, false) - REGISTER_CLASS(CAdWaypointGroup, false) +// This is done in a separate file, to avoid including the kitchensink in SystemClassRegistry. +void SystemClassRegistry::registerClasses() { + REGISTER_CLASS(AdActor, false) + REGISTER_CLASS(AdEntity, false) + REGISTER_CLASS(AdGame, true) + REGISTER_CLASS(AdInventory, false) + REGISTER_CLASS(AdInventoryBox, false) + REGISTER_CLASS(AdItem, false) + REGISTER_CLASS(AdLayer, false) + REGISTER_CLASS(AdNodeState, false) + REGISTER_CLASS(AdObject, false) + REGISTER_CLASS(AdPath, false) + REGISTER_CLASS(AdPathPoint, false) + REGISTER_CLASS(AdRegion, false) + REGISTER_CLASS(AdResponse, false) + REGISTER_CLASS(AdResponseBox, false) + REGISTER_CLASS(AdResponseContext, false) + REGISTER_CLASS(AdRotLevel, false) + REGISTER_CLASS(AdScaleLevel, false) + REGISTER_CLASS(AdScene, false) + REGISTER_CLASS(AdSceneNode, false) + REGISTER_CLASS(AdSceneState, false) + REGISTER_CLASS(AdSentence, false) + REGISTER_CLASS(AdSpriteSet, false) + REGISTER_CLASS(AdTalkDef, false) + REGISTER_CLASS(AdTalkHolder, false) + REGISTER_CLASS(AdTalkNode, false) + REGISTER_CLASS(AdWaypointGroup, false) - REGISTER_CLASS(CBFader, false) - REGISTER_CLASS(CBFont, false) - REGISTER_CLASS(CBFontBitmap, false) - REGISTER_CLASS(CBFontStorage, true) - REGISTER_CLASS(CBFontTT, false) - REGISTER_CLASS(CBFrame, false) - REGISTER_CLASS(CBGame, true) - REGISTER_CLASS(CBKeyboardState, false) - REGISTER_CLASS(CBObject, false) - REGISTER_CLASS(CBPoint, false) - REGISTER_CLASS(CBRegion, false) - REGISTER_CLASS(CBScriptable, false) - REGISTER_CLASS(CBScriptHolder, false) - REGISTER_CLASS(CBSound, false) - REGISTER_CLASS(CBSprite, false) - REGISTER_CLASS(CBSubFrame, false) + REGISTER_CLASS(BaseFader, false) + REGISTER_CLASS(BaseFont, false) + REGISTER_CLASS(BaseFontBitmap, false) + REGISTER_CLASS(BaseFontStorage, true) + REGISTER_CLASS(BaseFontTT, false) + REGISTER_CLASS(BaseFrame, false) + REGISTER_CLASS(BaseGame, true) + REGISTER_CLASS(BaseKeyboardState, false) + REGISTER_CLASS(BaseObject, false) + REGISTER_CLASS(BasePoint, false) + REGISTER_CLASS(BaseRegion, false) + REGISTER_CLASS(BaseScriptable, false) + REGISTER_CLASS(BaseScriptHolder, false) + REGISTER_CLASS(BaseSound, false) + REGISTER_CLASS(BaseSprite, false) + REGISTER_CLASS(BaseSubFrame, false) - REGISTER_CLASS(CBViewport, false) - REGISTER_CLASS(CPartEmitter, false) - REGISTER_CLASS(CScEngine, true) - REGISTER_CLASS(CScScript, false) - REGISTER_CLASS(CScStack, false) - REGISTER_CLASS(CScValue, false) - REGISTER_CLASS(CSXArray, false) - REGISTER_CLASS(CSXDate, false) - REGISTER_CLASS(CSXFile, false) - REGISTER_CLASS(CSXMath, true) - REGISTER_CLASS(CSXMemBuffer, false) - REGISTER_CLASS(CSXObject, false) - REGISTER_CLASS(CSXString, false) + REGISTER_CLASS(BaseViewport, false) + REGISTER_CLASS(PartEmitter, false) + REGISTER_CLASS(ScEngine, true) + REGISTER_CLASS(ScScript, false) + REGISTER_CLASS(ScStack, false) + REGISTER_CLASS(ScValue, false) + REGISTER_CLASS(SXArray, false) + REGISTER_CLASS(SXDate, false) + REGISTER_CLASS(SXFile, false) + REGISTER_CLASS(SXMath, true) + REGISTER_CLASS(SXMemBuffer, false) + REGISTER_CLASS(SXObject, false) + REGISTER_CLASS(SXString, false) - REGISTER_CLASS(CUIButton, false) - REGISTER_CLASS(CUIEdit, false) - REGISTER_CLASS(CUIEntity, false) - REGISTER_CLASS(CUIObject, false) - REGISTER_CLASS(CUIText, false) - REGISTER_CLASS(CUITiledImage, false) - REGISTER_CLASS(CUIWindow, false) - REGISTER_CLASS(CVidTheoraPlayer, false) + REGISTER_CLASS(UIButton, false) + REGISTER_CLASS(UIEdit, false) + REGISTER_CLASS(UIEntity, false) + REGISTER_CLASS(UIObject, false) + REGISTER_CLASS(UIText, false) + REGISTER_CLASS(UITiledImage, false) + REGISTER_CLASS(UIWindow, false) + REGISTER_CLASS(VideoTheoraPlayer, false) warning("TODO: Clean this up at some proper time"); } diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index a5dac465b3..4d7d08735c 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -31,11 +31,11 @@ namespace WinterMute { -class CBPersistMgr; +class BasePersistenceManager; // persistence support typedef void *(*PERSISTBUILD)(void); -typedef bool(*PERSISTLOAD)(void *, CBPersistMgr *); +typedef bool(*PERSISTLOAD)(void *, BasePersistenceManager *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); } // end of namespace WinterMute @@ -47,9 +47,9 @@ namespace WinterMute { static const char _className[];\ static void* persistBuild(void);\ virtual const char* getClassName();\ - static bool persistLoad(void* Instance, CBPersistMgr* PersistMgr);\ + static bool persistLoad(void* Instance, BasePersistenceManager* PersistMgr);\ class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ - virtual bool persist(CBPersistMgr* PersistMgr);\ + virtual bool persist(BasePersistenceManager* PersistMgr);\ void* operator new (size_t size);\ void operator delete(void* p);\ @@ -60,7 +60,7 @@ namespace WinterMute { return ::new class_name(DYNAMIC_CONSTRUCTOR, DYNAMIC_CONSTRUCTOR);\ }\ \ - bool class_name::persistLoad(void* Instance, CBPersistMgr* PersistMgr){\ + bool class_name::persistLoad(void* Instance, BasePersistenceManager* PersistMgr){\ return ((class_name*)Instance)->persist(PersistMgr);\ }\ \ @@ -68,16 +68,16 @@ namespace WinterMute { return #class_name;\ }\ \ - /*CSysClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);*/\ + /*SystemClass Register##class_name(class_name::_className, class_name::PersistBuild, class_name::PersistLoad, persistent_class);*/\ \ void* class_name::operator new (size_t size){\ void* ret = ::operator new(size);\ - CSysClassRegistry::getInstance()->registerInstance(#class_name, ret);\ + SystemClassRegistry::getInstance()->registerInstance(#class_name, ret);\ return ret;\ }\ \ void class_name::operator delete (void* p){\ - CSysClassRegistry::getInstance()->unregisterInstance(#class_name, p);\ + SystemClassRegistry::getInstance()->unregisterInstance(#class_name, p);\ ::operator delete(p);\ }\ diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 2be73b7256..028a85ada1 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -40,16 +40,16 @@ namespace WinterMute { -CBGame *CBPlatform::_gameRef = NULL; +BaseGame *BasePlatform::_gameRef = NULL; #define CLASS_NAME "GF_FRAME" -int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) { +int BasePlatform::initialize(BaseGame *inGame, int argc, char *argv[]) { _gameRef = inGame; return true; } ////////////////////////////////////////////////////////////////////////// -void CBPlatform::handleEvent(Common::Event *event) { +void BasePlatform::handleEvent(Common::Event *event) { switch (event->type) { case Common::EVENT_LBUTTONDOWN: @@ -88,13 +88,13 @@ void CBPlatform::handleEvent(Common::Event *event) { break; /*#ifdef __IPHONEOS__ { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); POINT p; GetCursorPos(&p); _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "CUIButton") == 0) { - CUIButton *btn = static_cast(_gameRef->_activeObject); + if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "UIButton") == 0) { + UIButton *btn = static_cast(_gameRef->_activeObject); if (btn->_visible && !btn->_disable) btn->_press = true; } } @@ -151,7 +151,7 @@ void CBPlatform::handleEvent(Common::Event *event) { } ////////////////////////////////////////////////////////////////////////// -int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { +int BasePlatform::SDLEventWatcher(void *userdata, Common::Event *event) { //TODO /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { if (_gameRef) _gameRef->AutoSaveOnExit(); @@ -166,7 +166,7 @@ int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // Win32 API bindings ////////////////////////////////////////////////////////////////////////// -void CBPlatform::outputDebugString(const char *lpOutputString) { +void BasePlatform::outputDebugString(const char *lpOutputString) { /* #ifdef __WIN32__ ::OutputDebugString(lpOutputString); @@ -176,13 +176,13 @@ void CBPlatform::outputDebugString(const char *lpOutputString) { ////////////////////////////////////////////////////////////////////////// -uint32 CBPlatform::getTime() { +uint32 BasePlatform::getTime() { return g_system->getMillis(); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::getCursorPos(Point32 *lpPoint) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); +bool BasePlatform::getCursorPos(Point32 *lpPoint) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); Common::Point p = g_system->getEventManager()->getMousePos(); lpPoint->x = p.x; @@ -194,8 +194,8 @@ bool CBPlatform::getCursorPos(Point32 *lpPoint) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setCursorPos(int X, int Y) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); +bool BasePlatform::setCursorPos(int X, int Y) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); Point32 p; p.x = X; @@ -207,19 +207,19 @@ bool CBPlatform::setCursorPos(int X, int Y) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::showWindow(int nCmdShow) { +bool BasePlatform::showWindow(int nCmdShow) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::deleteFile(const char *lpFileName) { +bool BasePlatform::deleteFile(const char *lpFileName) { return remove(lpFileName) ? true : false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { +bool BasePlatform::copyFile(const char *from, const char *to, bool failIfExists) { // try { - warning("CBPlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); + warning("BasePlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); return false; // if (failIfExists && boost::filesystem::exists(to)) return false; // boost::filesystem::copy_file(from, to); @@ -230,38 +230,38 @@ bool CBPlatform::copyFile(const char *from, const char *to, bool failIfExists) { } ////////////////////////////////////////////////////////////////////////// -void CBPlatform::setCapture() { +void BasePlatform::setCapture() { return; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::releaseCapture() { +bool BasePlatform::releaseCapture() { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setForegroundWindow() { +bool BasePlatform::setForegroundWindow() { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRectEmpty(Rect32 *lprc) { +bool BasePlatform::setRectEmpty(Rect32 *lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; return true; } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::isRectEmpty(const Rect32 *lprc) { +bool BasePlatform::isRectEmpty(const Rect32 *lprc) { return (lprc->left >= lprc->right) || (lprc->top >= lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::ptInRect(Rect32 *lprc, Point32 p) { +bool BasePlatform::ptInRect(Rect32 *lprc, Point32 p) { return (p.x >= lprc->left) && (p.x < lprc->right) && (p.y >= lprc->top) && (p.y < lprc->bottom); } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { +bool BasePlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) { lprc->left = left; lprc->top = top; lprc->right = right; @@ -271,7 +271,7 @@ bool CBPlatform::setRect(Rect32 *lprc, int left, int top, int right, int bottom) } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { +bool BasePlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1) || isRectEmpty(lprcSrc2) || lprcSrc1->left >= lprcSrc2->right || lprcSrc2->left >= lprcSrc1->right || lprcSrc1->top >= lprcSrc2->bottom || lprcSrc2->top >= lprcSrc1->bottom) { @@ -287,7 +287,7 @@ bool CBPlatform::intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Re } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { +bool BasePlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) { if (isRectEmpty(lprcSrc1)) { if (isRectEmpty(lprcSrc2)) { setRectEmpty(lprcDst); @@ -310,7 +310,7 @@ bool CBPlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2) } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { +bool BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { if (lprcDst == NULL || lprcSrc == NULL) return false; *lprcDst = *lprcSrc; @@ -318,7 +318,7 @@ bool CBPlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { +bool BasePlatform::offsetRect(Rect32 *lprc, int dx, int dy) { if (lprc == NULL) return false; lprc->left += dx; @@ -330,13 +330,13 @@ bool CBPlatform::offsetRect(Rect32 *lprc, int dx, int dy) { } ////////////////////////////////////////////////////////////////////////// -bool CBPlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { +bool BasePlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; } ////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::getSystemFontPath() { +AnsiString BasePlatform::getSystemFontPath() { /*#ifdef __WIN32__ // we're looking for something like "c:\windows\fonts\"; char winDir[MAX_PATH_LENGTH + 1]; @@ -351,14 +351,14 @@ AnsiString CBPlatform::getSystemFontPath() { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBPlatform::getPlatformName() { +AnsiString BasePlatform::getPlatformName() { // TODO: Should conform to the WME-spec. //return AnsiString(SDL_GetPlatform()); return AnsiString("ScummVM"); } ////////////////////////////////////////////////////////////////////////// -char *CBPlatform::strupr(char *string) { +char *BasePlatform::strupr(char *string) { if (string) { for (size_t i = 0; i < strlen(string); ++i) { string[i] = toupper(string[i]); @@ -368,7 +368,7 @@ char *CBPlatform::strupr(char *string) { } ////////////////////////////////////////////////////////////////////////// -char *CBPlatform::strlwr(char *string) { +char *BasePlatform::strlwr(char *string) { if (string) { for (size_t i = 0; i < strlen(string); ++i) { string[i] = tolower(string[i]); diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 50b07bccb8..601f47b29d 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -36,12 +36,12 @@ namespace WinterMute { -class CBGame; +class BaseGame; ////////////////////////////////////////////////////////////////////////// -class CBPlatform { +class BasePlatform { public: - static int initialize(CBGame *inGame, int argc, char *argv[]); + static int initialize(BaseGame *inGame, int argc, char *argv[]); static void handleEvent(Common::Event *event); static AnsiString getSystemFontPath(); @@ -80,7 +80,7 @@ public: static int SDLEventWatcher(void *userdata, Common::Event *event); private: - static CBGame *_gameRef; + static BaseGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp index be70f8b8bd..32704e0a0e 100644 --- a/engines/wintermute/system/sys_class.cpp +++ b/engines/wintermute/system/sys_class.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { +SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { _name = name; _build = build; @@ -46,18 +46,18 @@ CSysClass::CSysClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD loa _persistent = persistent_class; _numInst = 0; - CSysClassRegistry::getInstance()->registerClass(this); + SystemClassRegistry::getInstance()->registerClass(this); } ////////////////////////////////////////////////////////////////////////// -CSysClass::~CSysClass() { - CSysClassRegistry::getInstance()->unregisterClass(this); +SystemClass::~SystemClass() { + SystemClassRegistry::getInstance()->unregisterClass(this); removeAllInstances(); } ////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeAllInstances() { +bool SystemClass::removeAllInstances() { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { delete(it->_value); @@ -69,21 +69,21 @@ bool CSysClass::removeAllInstances() { } ////////////////////////////////////////////////////////////////////////// -CSysInstance *CSysClass::addInstance(void *instance, int id, int savedId) { - CSysInstance *inst = new CSysInstance(instance, id, this); +SystemInstance *SystemClass::addInstance(void *instance, int id, int savedId) { + SystemInstance *inst = new SystemInstance(instance, id, this); inst->setSavedID(savedId); _instances[inst] = (inst); _instanceMap[instance] = inst; - CSysClassRegistry::getInstance()->addInstanceToTable(inst, instance); + SystemClassRegistry::getInstance()->addInstanceToTable(inst, instance); return inst; } ////////////////////////////////////////////////////////////////////////// -bool CSysClass::removeInstance(void *instance) { +bool SystemClass::removeInstance(void *instance) { InstanceMap::iterator mapIt = _instanceMap.find(instance); if (mapIt == _instanceMap.end()) return false; @@ -99,14 +99,14 @@ bool CSysClass::removeInstance(void *instance) { } ////////////////////////////////////////////////////////////////////////// -int CSysClass::getInstanceID(void *pointer) { +int SystemClass::getInstanceID(void *pointer) { InstanceMap::iterator mapIt = _instanceMap.find(pointer); if (mapIt == _instanceMap.end()) return -1; else return (mapIt->_value)->getID(); } ////////////////////////////////////////////////////////////////////////// -void *CSysClass::idToPointer(int savedID) { +void *SystemClass::idToPointer(int savedID) { //slow Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { @@ -116,19 +116,19 @@ void *CSysClass::idToPointer(int savedID) { } ////////////////////////////////////////////////////////////////////////// -int CSysClass::getNumInstances() { +int SystemClass::getNumInstances() { return _instances.size(); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::dump(Common::WriteStream *stream) { +void SystemClass::dump(Common::WriteStream *stream) { Common::String str; str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), getNumInstances()); stream->write(str.c_str(), str.size()); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { +void SystemClass::saveTable(BaseGame *gameRef, BasePersistenceManager *persistMgr) { persistMgr->putString(_name.c_str()); persistMgr->putDWORD(_iD); persistMgr->putDWORD(_instances.size()); @@ -140,7 +140,7 @@ void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { +void SystemClass::loadTable(BaseGame *gameRef, BasePersistenceManager *persistMgr) { _savedID = persistMgr->getDWORD(); int numInstances = persistMgr->getDWORD(); @@ -156,7 +156,7 @@ void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { Instances::iterator it = _instances.begin(); if (it != _instances.end()) { (it->_value)->setSavedID(instID); - CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); + SystemClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); } // normal instances, create empty objects @@ -166,14 +166,14 @@ void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { warning("HALT"); } - addInstance(emptyObject, CSysClassRegistry::getInstance()->getNextID(), instID); + addInstance(emptyObject, SystemClassRegistry::getInstance()->getNextID(), instID); } } } ////////////////////////////////////////////////////////////////////////// -void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { +void SystemClass::saveInstances(BaseGame *Game, BasePersistenceManager *persistMgr) { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { // write instace header @@ -187,13 +187,13 @@ void CSysClass::saveInstances(CBGame *Game, CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::loadInstance(void *instance, CBPersistMgr *persistMgr) { +void SystemClass::loadInstance(void *instance, BasePersistenceManager *persistMgr) { _load(instance, persistMgr); } ////////////////////////////////////////////////////////////////////////// -void CSysClass::resetSavedIDs() { +void SystemClass::resetSavedIDs() { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { (it->_value)->setSavedID(-1); @@ -201,7 +201,7 @@ void CSysClass::resetSavedIDs() { } ////////////////////////////////////////////////////////////////////////// -void CSysClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { +void SystemClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpData) { Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { lpCallback((it->_value)->getInstance(), lpData); diff --git a/engines/wintermute/system/sys_class.h b/engines/wintermute/system/sys_class.h index f807ea677c..bd534f8bb0 100644 --- a/engines/wintermute/system/sys_class.h +++ b/engines/wintermute/system/sys_class.h @@ -36,10 +36,10 @@ #include "common/stream.h" namespace WinterMute { -class CSysInstance; -class CBGame; -class CBPersistMgr; -class CSysClass; +class SystemInstance; +class BaseGame; +class BasePersistenceManager; +class SystemClass; } @@ -52,8 +52,8 @@ template<> struct Hash : public UnaryFunction { } }; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysInstance *val) const { +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::SystemInstance *val) const { return (uint)((size_t)val); } }; @@ -63,14 +63,14 @@ template<> struct Hash : public UnaryFunction Instances; - typedef Common::HashMap Instances; + //typedef std::set Instances; + typedef Common::HashMap Instances; Instances _instances; - typedef Common::HashMap InstanceMap; + typedef Common::HashMap InstanceMap; InstanceMap _instanceMap; }; diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index ce14b01385..7f7814f75c 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -37,31 +37,31 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::CSysClassRegistry() { +SystemClassRegistry::SystemClassRegistry() { _count = 0; _disabled = false; } ////////////////////////////////////////////////////////////////////////// -CSysClassRegistry::~CSysClassRegistry() { +SystemClassRegistry::~SystemClassRegistry() { unregisterClasses(); } ////////////////////////////////////////////////////////////////////////// -CSysClassRegistry *CSysClassRegistry::getInstance() { +SystemClassRegistry *SystemClassRegistry::getInstance() { return g_wintermute->getClassRegistry(); } -void CSysClassRegistry::unregisterClasses() { - // CSysClass calls UnregisterClass upon destruction. +void SystemClassRegistry::unregisterClasses() { + // SystemClass calls UnregisterClass upon destruction. while (_classes.size() > 0) { delete _classes.begin()->_value; } } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerClass(CSysClass *classObj) { +bool SystemClassRegistry::registerClass(SystemClass *classObj) { classObj->setID(_count++); //_classes.insert(classObj); _classes[classObj] = classObj; @@ -74,7 +74,7 @@ bool CSysClassRegistry::registerClass(CSysClass *classObj) { ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { +bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { Classes::iterator it = _classes.find(classObj); if (it == _classes.end()) return false; @@ -82,7 +82,7 @@ bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { if (classObj->getNumInstances() != 0) { char str[MAX_PATH_LENGTH]; sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - CBPlatform::outputDebugString(str); + BasePlatform::outputDebugString(str); } _classes.erase(it); @@ -98,18 +98,18 @@ bool CSysClassRegistry::unregisterClass(CSysClass *classObj) { ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::registerInstance(const char *className, void *instance) { +bool SystemClassRegistry::registerInstance(const char *className, void *instance) { if (_disabled) return true; NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return false; - CSysInstance *inst = (*mapIt)._value->addInstance(instance, _count++); + SystemInstance *inst = (*mapIt)._value->addInstance(instance, _count++); return (inst != NULL); } ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer) { +void SystemClassRegistry::addInstanceToTable(SystemInstance *instance, void *pointer) { _instanceMap[pointer] = instance; if (instance->getSavedID() >= 0) @@ -117,12 +117,12 @@ void CSysClassRegistry::addInstanceToTable(CSysInstance *instance, void *pointer } ////////////////////////////////////////////////////////////////////////// -int CSysClassRegistry::getNextID() { +int SystemClassRegistry::getNextID() { return _count++; } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::unregisterInstance(const char *className, void *instance) { +bool SystemClassRegistry::unregisterInstance(const char *className, void *instance) { NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return false; (*mapIt)._value->removeInstance(instance); @@ -136,14 +136,14 @@ bool CSysClassRegistry::unregisterInstance(const char *className, void *instance ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { +bool SystemClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { if (pointer == NULL) return true; InstanceMap::iterator it = _instanceMap.find(pointer); if (it == _instanceMap.end()) return false; - CSysInstance *inst = (*it)._value; + SystemInstance *inst = (*it)._value; *instanceID = inst->getID(); *classID = inst->getClass()->getID(); @@ -151,13 +151,13 @@ bool CSysClassRegistry::getPointerID(void *pointer, int *classID, int *instanceI } ////////////////////////////////////////////////////////////////////////// -void *CSysClassRegistry::idToPointer(int classID, int instanceID) { +void *SystemClassRegistry::idToPointer(int classID, int instanceID) { SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); if (it == _savedInstanceMap.end()) return NULL; else return (*it)._value->getInstance(); } -bool checkHeader(const char *tag, CBPersistMgr *pm) { +bool checkHeader(const char *tag, BasePersistenceManager *pm) { char *test = pm->getString(); Common::String verify = test; delete[] test; @@ -169,7 +169,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { +bool SystemClassRegistry::saveTable(BaseGame *gameRef, BasePersistenceManager *persistMgr, bool quickSave) { persistMgr->putString(""); persistMgr->putDWORD(_classes.size()); @@ -193,7 +193,7 @@ bool CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, boo ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { +bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *persistMgr) { checkHeader("", persistMgr); // reset SavedID of current instances @@ -228,7 +228,7 @@ bool CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) { +bool SystemClassRegistry::saveInstances(BaseGame *gameRef, BasePersistenceManager *persistMgr, bool quickSave) { Classes::iterator it; @@ -260,7 +260,7 @@ bool CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, } ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) { +bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManager *persistMgr) { // get total instances int numInstances = persistMgr->getDWORD(); @@ -296,7 +296,7 @@ bool CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { +bool SystemClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { NameMap::iterator mapIt = _nameMap.find(className); if (mapIt == _nameMap.end()) return STATUS_FAILED; @@ -306,7 +306,7 @@ bool CSysClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const ch ////////////////////////////////////////////////////////////////////////// -void CSysClassRegistry::dumpClasses(Common::WriteStream *stream) { +void SystemClassRegistry::dumpClasses(Common::WriteStream *stream) { Classes::iterator it; for (it = _classes.begin(); it != _classes.end(); ++it) (it->_value)->dump(stream); diff --git a/engines/wintermute/system/sys_class_registry.h b/engines/wintermute/system/sys_class_registry.h index e17ae9bf78..d668c57803 100644 --- a/engines/wintermute/system/sys_class_registry.h +++ b/engines/wintermute/system/sys_class_registry.h @@ -39,13 +39,13 @@ #include "common/stream.h" namespace WinterMute { -class CSysClass; +class SystemClass; } namespace Common { template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::CSysClass *val) const { +template<> struct Hash : public UnaryFunction { + uint operator()(WinterMute::SystemClass *val) const { return (uint)((size_t)val); } }; @@ -54,50 +54,50 @@ template<> struct Hash : public UnaryFunction Classes; + typedef Common::HashMap Classes; Classes _classes; - typedef Common::HashMap NameMap; + typedef Common::HashMap NameMap; NameMap _nameMap; - typedef Common::HashMap IdMap; + typedef Common::HashMap IdMap; IdMap _idMap; - typedef Common::HashMap InstanceMap; + typedef Common::HashMap InstanceMap; InstanceMap _instanceMap; - typedef Common::HashMap SavedInstanceMap; + typedef Common::HashMap SavedInstanceMap; SavedInstanceMap _savedInstanceMap; }; diff --git a/engines/wintermute/system/sys_instance.cpp b/engines/wintermute/system/sys_instance.cpp index c34c3cc64a..a5ef69647c 100644 --- a/engines/wintermute/system/sys_instance.cpp +++ b/engines/wintermute/system/sys_instance.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { +SystemInstance::SystemInstance(void *instance, int id, SystemClass *sysClass) { _instance = instance; _id = id; _savedID = -1; @@ -43,7 +43,7 @@ CSysInstance::CSysInstance(void *instance, int id, CSysClass *sysClass) { } ////////////////////////////////////////////////////////////////////////// -CSysInstance::~CSysInstance() { +SystemInstance::~SystemInstance() { } } // end of namespace WinterMute diff --git a/engines/wintermute/system/sys_instance.h b/engines/wintermute/system/sys_instance.h index 6becd491af..493055a8fd 100644 --- a/engines/wintermute/system/sys_instance.h +++ b/engines/wintermute/system/sys_instance.h @@ -31,12 +31,12 @@ namespace WinterMute { -class CSysClass; +class SystemClass; -class CSysInstance { +class SystemInstance { public: - CSysInstance(void *Instance, int ID, CSysClass *sysClass); - virtual ~CSysInstance(); + SystemInstance(void *Instance, int ID, SystemClass *sysClass); + virtual ~SystemInstance(); int getID() const { return _id; @@ -47,7 +47,7 @@ public: void *getInstance() const { return _instance; } - CSysClass *getClass() const { + SystemClass *getClass() const { return _class; } @@ -60,7 +60,7 @@ private: int _id; int _savedID; void *_instance; - CSysClass *_class; + SystemClass *_class; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 5b1867b652..af7e3262db 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -45,10 +45,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIButton, false) +IMPLEMENT_PERSISTENT(UIButton, false) ////////////////////////////////////////////////////////////////////////// -CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { +UIButton::UIButton(BaseGame *inGame): UIObject(inGame) { _backPress = _backHover = _backDisable = _backFocus = NULL; _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; @@ -72,7 +72,7 @@ CUIButton::CUIButton(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CUIButton::~CUIButton() { +UIButton::~UIButton() { delete _backPress; delete _backHover; delete _backDisable; @@ -95,10 +95,10 @@ CUIButton::~CUIButton() { ////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadFile(const char *filename) { +bool UIButton::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -154,7 +154,7 @@ TOKEN_DEF(PIXEL_PERFECT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUIButton::loadBuffer(byte *buffer, bool complete) { +bool UIButton::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(BUTTON) TOKEN_TABLE(TEMPLATE) @@ -196,7 +196,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { @@ -222,7 +222,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(_gameRef); + _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -232,7 +232,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_HOVER: delete _backHover; - _backHover = new CUITiledImage(_gameRef); + _backHover = new UITiledImage(_gameRef); if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) { delete _backHover; _backHover = NULL; @@ -242,7 +242,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_PRESS: delete _backPress; - _backPress = new CUITiledImage(_gameRef); + _backPress = new UITiledImage(_gameRef); if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) { delete _backPress; _backPress = NULL; @@ -252,7 +252,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_DISABLE: delete _backDisable; - _backDisable = new CUITiledImage(_gameRef); + _backDisable = new UITiledImage(_gameRef); if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) { delete _backDisable; _backDisable = NULL; @@ -262,7 +262,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_FOCUS: delete _backFocus; - _backFocus = new CUITiledImage(_gameRef); + _backFocus = new UITiledImage(_gameRef); if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) { delete _backFocus; _backFocus = NULL; @@ -272,7 +272,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(_gameRef); + _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -282,7 +282,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER: delete _imageHover; - _imageHover = new CBSprite(_gameRef); + _imageHover = new BaseSprite(_gameRef); if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) { delete _imageHover; _imageHover = NULL; @@ -292,7 +292,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_PRESS: delete _imagePress; - _imagePress = new CBSprite(_gameRef); + _imagePress = new BaseSprite(_gameRef); if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) { delete _imagePress; _imagePress = NULL; @@ -302,7 +302,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_DISABLE: delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); + _imageDisable = new BaseSprite(_gameRef); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) { delete _imageDisable; _imageDisable = NULL; @@ -312,7 +312,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_FOCUS: delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); + _imageFocus = new BaseSprite(_gameRef); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) { delete _imageFocus; _imageFocus = NULL; @@ -379,7 +379,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -439,7 +439,7 @@ bool CUIButton::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "BUTTON\n"); buffer->putTextIndent(indent, "{\n"); @@ -501,7 +501,7 @@ bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: - warning("CUIButton::SaveAsText - unhandled enum"); + warning("UIButton::SaveAsText - unhandled enum"); break; } @@ -531,17 +531,17 @@ bool CUIButton::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -void CUIButton::correctSize() { +void UIButton::correctSize() { Rect32 rect; - CBSprite *img = NULL; + BaseSprite *img = NULL; if (_image) img = _image; else if (_imageDisable) img = _imageDisable; else if (_imageHover) img = _imageHover; @@ -577,21 +577,21 @@ void CUIButton::correctSize() { ////////////////////////////////////////////////////////////////////////// -bool CUIButton::display(int offsetX, int offsetY) { +bool UIButton::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; - CUITiledImage *back = NULL; - CBSprite *image = NULL; - CBFont *font = 0; + UITiledImage *back = NULL; + BaseSprite *image = NULL; + BaseFont *font = 0; //RECT rect; - //CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); - //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); + //BasePlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height); + //_hover = (!_disable && BasePlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE); _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press(); + (_oneTimePress && BasePlatform::getTime() - _oneTimePressTime >= 100)) press(); if (_disable) { @@ -638,7 +638,7 @@ bool CUIButton::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites if (_image && _image != image) _image->reset(); @@ -654,7 +654,7 @@ bool CUIButton::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -void CUIButton::press() { +void UIButton::press() { applyEvent("Press"); if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); if (_parentNotify && _parent) _parent->applyEvent(_name); @@ -666,13 +666,13 @@ void CUIButton::press() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetDisabledFont ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetDisabledFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); if (Val->isNULL()) { @@ -690,7 +690,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHoverFont") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); if (val->isNULL()) { @@ -708,7 +708,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPressedFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); if (Val->isNULL()) { @@ -726,7 +726,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFocusedFont") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); if (val->isNULL()) { @@ -746,7 +746,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); delete _imageDisable; - _imageDisable = new CBSprite(_gameRef); + _imageDisable = new BaseSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) { delete _imageDisable; @@ -787,7 +787,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); delete _imageHover; - _imageHover = new CBSprite(_gameRef); + _imageHover = new BaseSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) { delete _imageHover; @@ -827,7 +827,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); delete _imagePress; - _imagePress = new CBSprite(_gameRef); + _imagePress = new BaseSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) { delete _imagePress; @@ -867,7 +867,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); delete _imageFocus; - _imageFocus = new CBSprite(_gameRef); + _imageFocus = new BaseSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) { delete _imageFocus; @@ -908,7 +908,7 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS if (_visible && !_disable) { _oneTimePress = true; - _oneTimePressTime = CBPlatform::getTime(); + _oneTimePressTime = BasePlatform::getTime(); } stack->pushNULL(); @@ -916,12 +916,12 @@ bool CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS } - else return CUIObject::scCallMethod(script, stack, thisStack, name); + else return UIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIButton::scGetProperty(const char *name) { +ScValue *UIButton::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -962,12 +962,12 @@ CScValue *CUIButton::scGetProperty(const char *name) { return _scValue; } - else return CUIObject::scGetProperty(name); + else return UIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIButton::scSetProperty(const char *name, CScValue *value) { +bool UIButton::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -1000,20 +1000,20 @@ bool CUIButton::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CUIObject::scSetProperty(name, value); + else return UIObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIButton::scToString() { +const char *UIButton::scToString() { return "[button]"; } ////////////////////////////////////////////////////////////////////////// -bool CUIButton::persist(CBPersistMgr *persistMgr) { +bool UIButton::persist(BasePersistenceManager *persistMgr) { - CUIObject::persist(persistMgr); + UIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_align)); persistMgr->transfer(TMEMBER(_backDisable)); diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index c6538f4423..5c034d6113 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -35,42 +35,42 @@ namespace WinterMute { -class CUIButton : public CUIObject { +class UIButton : public UIObject { public: bool _pixelPerfect; bool _stayPressed; bool _centerImage; bool _oneTimePress; uint32 _oneTimePressTime; - DECLARE_PERSISTENT(CUIButton, CUIObject) + DECLARE_PERSISTENT(UIButton, UIObject) void press(); virtual bool display(int offsetX = 0, int offsetY = 0); bool _press; bool _hover; void correctSize(); TTextAlign _align; - CBSprite *_imageHover; - CBSprite *_imagePress; - CBSprite *_imageDisable; - CBSprite *_imageFocus; - CBFont *_fontDisable; - CBFont *_fontPress; - CBFont *_fontHover; - CBFont *_fontFocus; - CUITiledImage *_backPress; - CUITiledImage *_backHover; - CUITiledImage *_backDisable; - CUITiledImage *_backFocus; - CUIButton(CBGame *inGame = NULL); - virtual ~CUIButton(); + BaseSprite *_imageHover; + BaseSprite *_imagePress; + BaseSprite *_imageDisable; + BaseSprite *_imageFocus; + BaseFont *_fontDisable; + BaseFont *_fontPress; + BaseFont *_fontHover; + BaseFont *_fontFocus; + UITiledImage *_backPress; + UITiledImage *_backHover; + UITiledImage *_backDisable; + UITiledImage *_backFocus; + UIButton(BaseGame *inGame = NULL); + virtual ~UIButton(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 237b944332..d9c6c6586a 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -50,10 +50,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIEdit, false) +IMPLEMENT_PERSISTENT(UIEdit, false) ////////////////////////////////////////////////////////////////////////// -CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { +UIEdit::UIEdit(BaseGame *inGame): UIObject(inGame) { _type = UI_EDIT; _fontSelected = NULL; @@ -80,7 +80,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CUIEdit::~CUIEdit() { +UIEdit::~UIEdit() { if (!_sharedFonts) { if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); } @@ -91,10 +91,10 @@ CUIEdit::~CUIEdit() { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadFile(const char *filename) { +bool UIEdit::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -136,7 +136,7 @@ TOKEN_DEF(EDIT) TOKEN_DEF(CAPTION) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::loadBuffer(byte *buffer, bool complete) { +bool UIEdit::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) @@ -164,7 +164,7 @@ bool CUIEdit::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { @@ -186,7 +186,7 @@ bool CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(_gameRef); + _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -196,7 +196,7 @@ bool CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(_gameRef); + _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -247,7 +247,7 @@ bool CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -299,7 +299,7 @@ bool CUIEdit::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "EDIT\n"); buffer->putTextIndent(indent, "{\n"); @@ -349,7 +349,7 @@ bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -358,7 +358,7 @@ bool CUIEdit::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSelectedFont ////////////////////////////////////////////////////////////////////////// @@ -372,12 +372,12 @@ bool CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta return STATUS_OK; } - else return CUIObject::scCallMethod(script, stack, thisStack, name); + else return UIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEdit::scGetProperty(const char *name) { +ScValue *UIEdit::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -449,12 +449,12 @@ CScValue *CUIEdit::scGetProperty(const char *name) { return _scValue; } - else return CUIObject::scGetProperty(name); + else return UIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::scSetProperty(const char *name, CScValue *value) { +bool UIEdit::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// @@ -520,18 +520,18 @@ bool CUIEdit::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CUIObject::scSetProperty(name, value); + else return UIObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIEdit::scToString() { +const char *UIEdit::scToString() { return "[edit]"; } ////////////////////////////////////////////////////////////////////////// -void CUIEdit::setCursorChar(const char *character) { +void UIEdit::setCursorChar(const char *character) { if (!character) return; delete[] _cursorChar; _cursorChar = new char [strlen(character) + 1]; @@ -540,7 +540,7 @@ void CUIEdit::setCursorChar(const char *character) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::display(int offsetX, int offsetY) { +bool UIEdit::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; @@ -552,8 +552,8 @@ bool CUIEdit::display(int offsetX, int offsetY) { if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); // prepare fonts - CBFont *font; - CBFont *sfont; + BaseFont *font; + BaseFont *sfont; if (_font) font = _font; else font = _gameRef->_systemFont; @@ -630,8 +630,8 @@ bool CUIEdit::display(int offsetX, int offsetY) { // cursor if (focused && curFirst) { if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); + if (BasePlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = BasePlatform::getTime(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) @@ -653,8 +653,8 @@ bool CUIEdit::display(int offsetX, int offsetY) { // cursor if (focused && !curFirst) { if (Count) { - if (CBPlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = CBPlatform::getTime(); + if (BasePlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = BasePlatform::getTime(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) @@ -673,7 +673,7 @@ bool CUIEdit::display(int offsetX, int offsetY) { } - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); _gameRef->_textEncoding = OrigEncoding; @@ -683,7 +683,7 @@ bool CUIEdit::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { +bool UIEdit::handleKeypress(Common::Event *event, bool printable) { bool handled = false; if (event->type == Common::EVENT_KEYDOWN && !printable) { @@ -695,7 +695,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { // ctrl+A case Common::KEYCODE_a: - if (CBKeyboardState::isControlDown()) { + if (BaseKeyboardState::isControlDown()) { _selStart = 0; _selEnd = strlen(_text); handled = true; @@ -716,24 +716,24 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_LEFT: case Common::KEYCODE_UP: _selEnd--; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; handled = true; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_DOWN: _selEnd++; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; handled = true; break; case Common::KEYCODE_HOME: if (_gameRef->_textRTL) { _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; } else { _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; } handled = true; break; @@ -741,10 +741,10 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_END: if (_gameRef->_textRTL) { _selEnd = 0; - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; } else { _selEnd = strlen(_text); - if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; } handled = true; break; @@ -786,8 +786,8 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// -int CUIEdit::deleteChars(int start, int end) { - if (start > end) CBUtils::swap(&start, &end); +int UIEdit::deleteChars(int start, int end) { + if (start > end) BaseUtils::swap(&start, &end); start = MAX(start, (int)0); end = MIN((size_t)end, strlen(_text)); @@ -807,7 +807,7 @@ int CUIEdit::deleteChars(int start, int end) { ////////////////////////////////////////////////////////////////////////// -int CUIEdit::insertChars(int pos, byte *chars, int num) { +int UIEdit::insertChars(int pos, byte *chars, int num) { if ((int)strlen(_text) + num > _maxLength) { num -= (strlen(_text) + num - _maxLength); } @@ -833,9 +833,9 @@ int CUIEdit::insertChars(int pos, byte *chars, int num) { ////////////////////////////////////////////////////////////////////////// -bool CUIEdit::persist(CBPersistMgr *persistMgr) { +bool UIEdit::persist(BasePersistenceManager *persistMgr) { - CUIObject::persist(persistMgr); + UIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_cursorBlinkRate)); persistMgr->transfer(TMEMBER(_cursorChar)); diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index 400cd7b578..221b8aa151 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -34,10 +34,10 @@ #include "common/events.h" namespace WinterMute { -class CBFont; -class CUIEdit : public CUIObject { +class BaseFont; +class UIEdit : public UIObject { public: - DECLARE_PERSISTENT(CUIEdit, CUIObject) + DECLARE_PERSISTENT(UIEdit, UIObject) int _maxLength; int insertChars(int pos, byte *chars, int num); int deleteChars(int start, int end); @@ -52,18 +52,18 @@ public: char *_cursorChar; int _selEnd; int _selStart; - CBFont *_fontSelected; - CUIEdit(CBGame *inGame); - virtual ~CUIEdit(); + BaseFont *_fontSelected; + UIEdit(BaseGame *inGame); + virtual ~UIEdit(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 012ff0390f..acbcd2430f 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -38,27 +38,27 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIEntity, false) +IMPLEMENT_PERSISTENT(UIEntity, false) ////////////////////////////////////////////////////////////////////////// -CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { +UIEntity::UIEntity(BaseGame *inGame): UIObject(inGame) { _type = UI_CUSTOM; _entity = NULL; } ////////////////////////////////////////////////////////////////////////// -CUIEntity::~CUIEntity() { +UIEntity::~UIEntity() { if (_entity) _gameRef->unregisterObject(_entity); _entity = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadFile(const char *filename) { +bool UIEntity::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -89,7 +89,7 @@ TOKEN_DEF(SCRIPT) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::loadBuffer(byte *buffer, bool complete) { +bool UIEntity::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) @@ -105,7 +105,7 @@ bool CUIEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { @@ -174,7 +174,7 @@ bool CUIEntity::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); buffer->putTextIndent(indent, "{\n"); @@ -201,16 +201,16 @@ bool CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::setEntity(const char *filename) { +bool UIEntity::setEntity(const char *filename) { if (_entity) _gameRef->unregisterObject(_entity); - _entity = new CAdEntity(_gameRef); + _entity = new AdEntity(_gameRef); if (!_entity || DID_FAIL(_entity->loadFile(filename))) { delete _entity; _entity = NULL; @@ -225,7 +225,7 @@ bool CUIEntity::setEntity(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::display(int offsetX, int offsetY) { +bool UIEntity::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; if (_entity) { @@ -251,7 +251,7 @@ bool CUIEntity::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// @@ -280,12 +280,12 @@ bool CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - else return CUIObject::scCallMethod(script, stack, thisStack, name); + else return UIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIEntity::scGetProperty(const char *name) { +ScValue *UIEntity::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -305,32 +305,32 @@ CScValue *CUIEntity::scGetProperty(const char *name) { return _scValue; } - else return CUIObject::scGetProperty(name); + else return UIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::scSetProperty(const char *name, CScValue *value) { +bool UIEntity::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Freezable") == 0) { if (_entity) _entity->makeFreezable(value->getBool()); return STATUS_OK; - } else return CUIObject::scSetProperty(name, value); + } else return UIObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIEntity::scToString() { +const char *UIEntity::scToString() { return "[entity container]"; } ////////////////////////////////////////////////////////////////////////// -bool CUIEntity::persist(CBPersistMgr *persistMgr) { +bool UIEntity::persist(BasePersistenceManager *persistMgr) { - CUIObject::persist(persistMgr); + UIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_entity)); return STATUS_OK; diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index 6873000681..9c9bffdc4a 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -32,24 +32,24 @@ #include "engines/wintermute/ui/ui_object.h" namespace WinterMute { -class CAdEntity; -class CUIEntity : public CUIObject { +class AdEntity; +class UIEntity : public UIObject { public: - DECLARE_PERSISTENT(CUIEntity, CUIObject) - CUIEntity(CBGame *inGame); - virtual ~CUIEntity(); + DECLARE_PERSISTENT(UIEntity, UIObject) + UIEntity(BaseGame *inGame); + virtual ~UIEntity(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); virtual bool display(int offsetX = 0, int offsetY = 0); - CAdEntity *_entity; + AdEntity *_entity; bool setEntity(const char *filename); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 605b5b74b1..20fd6c363f 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -38,10 +38,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIObject, false) +IMPLEMENT_PERSISTENT(UIObject, false) ////////////////////////////////////////////////////////////////////////// -CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { +UIObject::UIObject(BaseGame *inGame): BaseObject(inGame) { _back = NULL; _image = NULL; _font = NULL; @@ -70,8 +70,8 @@ CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CUIObject::~CUIObject() { - if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this); +UIObject::~UIObject() { + if (!_gameRef->_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(BaseGame::invalidateValues, "ScValue", (void *)this); if (_back) delete _back; if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); @@ -85,7 +85,7 @@ CUIObject::~CUIObject() { ////////////////////////////////////////////////////////////////////////// -void CUIObject::setText(const char *text) { +void UIObject::setText(const char *text) { if (_text) delete [] _text; _text = new char [strlen(text) + 1]; if (_text) { @@ -98,13 +98,13 @@ void CUIObject::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// -bool CUIObject::display(int offsetX, int offsetY) { +bool UIObject::display(int offsetX, int offsetY) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam) { +void UIObject::setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam) { _listenerObject = object; _listenerParamObject = listenerObject; _listenerParamDWORD = listenerParam; @@ -112,7 +112,7 @@ void CUIObject::setListener(CBScriptHolder *object, CBScriptHolder *listenerObje ////////////////////////////////////////////////////////////////////////// -void CUIObject::correctSize() { +void UIObject::correctSize() { Rect32 rect; if (_width <= 0) { @@ -137,13 +137,13 @@ void CUIObject::correctSize() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFont ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFont") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (_font) _gameRef->_fontStorage->removeFont(_font); if (Val->isNULL()) { @@ -161,7 +161,7 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); /* const char *filename = */ val->getString(); @@ -172,7 +172,7 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - _image = new CBSprite(_gameRef); + _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile(val->getString()))) { delete _image; _image = NULL; @@ -221,14 +221,14 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; + UIWindow *win = (UIWindow *)_parent; int i; bool found = false; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); // find directly if (val->isNative()) { - CUIObject *widget = (CUIObject *)val->getNative(); + UIObject *widget = (UIObject *)val->getNative(); for (i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == widget) { found = true; @@ -277,7 +277,7 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; + UIWindow *win = (UIWindow *)_parent; for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { win->_widgets.removeAt(i); @@ -298,7 +298,7 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(0); if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; + UIWindow *win = (UIWindow *)_parent; for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { win->_widgets.removeAt(i); @@ -312,12 +312,12 @@ bool CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIObject::scGetProperty(const char *name) { +ScValue *UIObject::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -398,7 +398,7 @@ CScValue *CUIObject::scGetProperty(const char *name) { else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { _scValue->setNULL(); if (_parent && _parent->_type == UI_WINDOW) { - CUIWindow *win = (CUIWindow *)_parent; + UIWindow *win = (UIWindow *)_parent; for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { if (strcmp(name, "NextSibling") == 0) { @@ -413,12 +413,12 @@ CScValue *CUIObject::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIObject::scSetProperty(const char *name, CScValue *value) { +bool UIObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -475,22 +475,22 @@ bool CUIObject::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIObject::scToString() { +const char *UIObject::scToString() { return "[ui_object]"; } ////////////////////////////////////////////////////////////////////////// -bool CUIObject::isFocused() { +bool UIObject::isFocused() { if (!_gameRef->_focusedWindow) return false; if (_gameRef->_focusedWindow == this) return true; - CUIObject *obj = _gameRef->_focusedWindow; + UIObject *obj = _gameRef->_focusedWindow; while (obj) { if (obj == this) return true; else obj = obj->_focusedWidget; @@ -500,18 +500,18 @@ bool CUIObject::isFocused() { ////////////////////////////////////////////////////////////////////////// -bool CUIObject::handleMouse(TMouseEvent event, TMouseButton button) { +bool UIObject::handleMouse(TMouseEvent event, TMouseButton button) { // handle focus change if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { focus(); } - return CBObject::handleMouse(event, button); + return BaseObject::handleMouse(event, button); } ////////////////////////////////////////////////////////////////////////// -bool CUIObject::focus() { - CUIObject *obj = this; +bool UIObject::focus() { + UIObject *obj = this; bool disabled = false; while (obj) { if (obj->_disable && obj->_type == UI_WINDOW) { @@ -526,7 +526,7 @@ bool CUIObject::focus() { if (obj->_parent) { if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; } else { - if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj); + if (obj->_type == UI_WINDOW) _gameRef->focusWindow((UIWindow *)obj); } obj = obj->_parent; @@ -537,10 +537,10 @@ bool CUIObject::focus() { ////////////////////////////////////////////////////////////////////////// -bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { +bool UIObject::getTotalOffset(int *offsetX, int *offsetY) { int offX = 0, offY = 0; - CUIObject *obj = _parent; + UIObject *obj = _parent; while (obj) { offX += obj->_posX; offY += obj->_posY; @@ -555,9 +555,9 @@ bool CUIObject::getTotalOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIObject::persist(CBPersistMgr *persistMgr) { +bool UIObject::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_back)); persistMgr->transfer(TMEMBER(_canFocus)); @@ -582,7 +582,7 @@ bool CUIObject::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CUIObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_FAILED; } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 35bd092592..64cd711dcc 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -35,9 +35,9 @@ namespace WinterMute { -class CUITiledImage; -class CBFont; -class CUIObject : public CBObject { +class UITiledImage; +class BaseFont; +class UIObject : public BaseObject { public: bool getTotalOffset(int *offsetX, int *offsetY); @@ -46,35 +46,35 @@ public: virtual bool handleMouse(TMouseEvent event, TMouseButton button); bool isFocused(); bool _parentNotify; - DECLARE_PERSISTENT(CUIObject, CBObject) - CUIObject *_parent; + DECLARE_PERSISTENT(UIObject, BaseObject) + UIObject *_parent; virtual bool display(int offsetX = 0, int offsetY = 0); virtual void correctSize(); bool _sharedFonts; bool _sharedImages; void setText(const char *text); char *_text; - CBFont *_font; + BaseFont *_font; bool _visible; - CUITiledImage *_back; + UITiledImage *_back; bool _disable; - CUIObject(CBGame *inGame = NULL); - virtual ~CUIObject(); + UIObject(BaseGame *inGame = NULL); + virtual ~UIObject(); int _width; int _height; TUIObjectType _type; - CBSprite *_image; - void setListener(CBScriptHolder *object, CBScriptHolder *listenerObject, uint32 listenerParam); - CBScriptHolder *_listenerParamObject; + BaseSprite *_image; + void setListener(BaseScriptHolder *object, BaseScriptHolder *listenerObject, uint32 listenerParam); + BaseScriptHolder *_listenerParamObject; uint32 _listenerParamDWORD; - CBScriptHolder *_listenerObject; - CUIObject *_focusedWidget; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + BaseScriptHolder *_listenerObject; + UIObject *_focusedWidget; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 6309d05a1e..fdf7f6287f 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -44,10 +44,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIText, false) +IMPLEMENT_PERSISTENT(UIText, false) ////////////////////////////////////////////////////////////////////////// -CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { +UIText::UIText(BaseGame *inGame): UIObject(inGame) { _textAlign = TAL_LEFT; _verticalAlign = VAL_CENTER; _type = UI_STATIC; @@ -56,17 +56,17 @@ CUIText::CUIText(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CUIText::~CUIText() { +UIText::~UIText() { } ////////////////////////////////////////////////////////////////////////// -bool CUIText::display(int offsetX, int offsetY) { +bool UIText::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; - CBFont *font = _font; + BaseFont *font = _font; if (!font) font = _gameRef->_systemFont; if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); @@ -87,7 +87,7 @@ bool CUIText::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height); } - //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); + //_gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false)); return STATUS_OK; } @@ -95,10 +95,10 @@ bool CUIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIText::loadFile(const char *filename) { +bool UIText::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -138,7 +138,7 @@ TOKEN_DEF(PARENT_NOTIFY) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUIText::loadBuffer(byte *buffer, bool complete) { +bool UIText::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(STATIC) TOKEN_TABLE(TEMPLATE) @@ -164,7 +164,7 @@ bool CUIText::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { @@ -190,7 +190,7 @@ bool CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(_gameRef); + _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -200,7 +200,7 @@ bool CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(_gameRef); + _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -249,7 +249,7 @@ bool CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -293,7 +293,7 @@ bool CUIText::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "STATIC\n"); buffer->putTextIndent(indent, "{\n"); @@ -328,7 +328,7 @@ bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "TEXT_ALIGN=\"%s\"\n", "center"); break; default: - error("CUIText::SaveAsText - Unhandled enum"); + error("UIText::SaveAsText - Unhandled enum"); break; } @@ -367,7 +367,7 @@ bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; @@ -376,7 +376,7 @@ bool CUIText::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIText::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SizeToFit ////////////////////////////////////////////////////////////////////////// @@ -397,12 +397,12 @@ bool CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta return STATUS_OK; } - else return CUIObject::scCallMethod(script, stack, thisStack, name); + else return UIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIText::scGetProperty(const char *name) { +ScValue *UIText::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -429,12 +429,12 @@ CScValue *CUIText::scGetProperty(const char *name) { return _scValue; } - else return CUIObject::scGetProperty(name); + else return UIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIText::scSetProperty(const char *name, CScValue *value) { +bool UIText::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// @@ -455,21 +455,21 @@ bool CUIText::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CUIObject::scSetProperty(name, value); + else return UIObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIText::scToString() { +const char *UIText::scToString() { return "[static]"; } ////////////////////////////////////////////////////////////////////////// -bool CUIText::persist(CBPersistMgr *persistMgr) { +bool UIText::persist(BasePersistenceManager *persistMgr) { - CUIObject::persist(persistMgr); + UIObject::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_textAlign)); persistMgr->transfer(TMEMBER_INT(_verticalAlign)); @@ -478,7 +478,7 @@ bool CUIText::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CUIText::sizeToFit() { +bool UIText::sizeToFit() { if (_font && _text) { _width = _font->getTextWidth((byte *)_text); _height = _font->getTextHeight((byte *)_text, _width); diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index dc633dc042..ee2e63c448 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -34,24 +34,24 @@ namespace WinterMute { -class CUIText : public CUIObject { +class UIText : public UIObject { private: bool sizeToFit(); public: virtual bool display(int offsetX, int offsetY); - DECLARE_PERSISTENT(CUIText, CUIObject) - CUIText(CBGame *inGame = NULL); - virtual ~CUIText(); + DECLARE_PERSISTENT(UIText, UIObject) + UIText(BaseGame *inGame = NULL); + virtual ~UIText(); TTextAlign _textAlign; TVerticalAlign _verticalAlign; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 39b39b556d..fec30f46e9 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -38,33 +38,33 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUITiledImage, false) +IMPLEMENT_PERSISTENT(UITiledImage, false) ////////////////////////////////////////////////////////////////////////// -CUITiledImage::CUITiledImage(CBGame *inGame): CBObject(inGame) { +UITiledImage::UITiledImage(BaseGame *inGame): BaseObject(inGame) { _image = NULL; - CBPlatform::setRectEmpty(&_upLeft); - CBPlatform::setRectEmpty(&_upMiddle); - CBPlatform::setRectEmpty(&_upRight); - CBPlatform::setRectEmpty(&_middleLeft); - CBPlatform::setRectEmpty(&_middleMiddle); - CBPlatform::setRectEmpty(&_middleRight); - CBPlatform::setRectEmpty(&_downLeft); - CBPlatform::setRectEmpty(&_downMiddle); - CBPlatform::setRectEmpty(&_downRight); + BasePlatform::setRectEmpty(&_upLeft); + BasePlatform::setRectEmpty(&_upMiddle); + BasePlatform::setRectEmpty(&_upRight); + BasePlatform::setRectEmpty(&_middleLeft); + BasePlatform::setRectEmpty(&_middleMiddle); + BasePlatform::setRectEmpty(&_middleRight); + BasePlatform::setRectEmpty(&_downLeft); + BasePlatform::setRectEmpty(&_downMiddle); + BasePlatform::setRectEmpty(&_downRight); } ////////////////////////////////////////////////////////////////////////// -CUITiledImage::~CUITiledImage() { +UITiledImage::~UITiledImage() { delete _image; _image = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::display(int x, int y, int width, int height) { +bool UITiledImage::display(int x, int y, int width, int height) { if (!_image) return STATUS_FAILED; int tileWidth = _middleMiddle.right - _middleMiddle.left; @@ -119,10 +119,10 @@ bool CUITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadFile(const char *filename) { +bool UITiledImage::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -158,7 +158,7 @@ TOKEN_DEF(HORIZONTAL_TILES) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { +bool UITiledImage::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TILED_IMAGE) TOKEN_TABLE(TEMPLATE) @@ -179,7 +179,7 @@ bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); bool hTiles = false, vTiles = false; int h1 = 0, h2 = 0, h3 = 0; int v1 = 0, v2 = 0, v3 = 0; @@ -200,7 +200,7 @@ bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSubFrame(_gameRef); + _image = new BaseSubFrame(_gameRef); if (!_image || DID_FAIL(_image->setSurface((char *)params))) { delete _image; _image = NULL; @@ -270,19 +270,19 @@ bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { if (vTiles && hTiles) { // up row - CBPlatform::setRect(&_upLeft, 0, 0, h1, v1); - CBPlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); - CBPlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); + BasePlatform::setRect(&_upLeft, 0, 0, h1, v1); + BasePlatform::setRect(&_upMiddle, h1, 0, h1 + h2, v1); + BasePlatform::setRect(&_upRight, h1 + h2, 0, h1 + h2 + h3, v1); // middle row - CBPlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); - CBPlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); - CBPlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); + BasePlatform::setRect(&_middleLeft, 0, v1, h1, v1 + v2); + BasePlatform::setRect(&_middleMiddle, h1, v1, h1 + h2, v1 + v2); + BasePlatform::setRect(&_middleRight, h1 + h2, v1, h1 + h2 + h3, v1 + v2); // down row - CBPlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); - CBPlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); - CBPlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); + BasePlatform::setRect(&_downLeft, 0, v1 + v2, h1, v1 + v2 + v3); + BasePlatform::setRect(&_downMiddle, h1, v1 + v2, h1 + h2, v1 + v2 + v3); + BasePlatform::setRect(&_downRight, h1 + h2, v1 + v2, h1 + h2 + h3, v1 + v2 + v3); } // default @@ -290,24 +290,24 @@ bool CUITiledImage::loadBuffer(byte *buffer, bool complete) { int width = _image->_surface->getWidth() / 3; int height = _image->_surface->getHeight() / 3; - if (CBPlatform::isRectEmpty(&_upLeft)) CBPlatform::setRect(&_upLeft, 0, 0, width, height); - if (CBPlatform::isRectEmpty(&_upMiddle)) CBPlatform::setRect(&_upMiddle, width, 0, 2 * width, height); - if (CBPlatform::isRectEmpty(&_upRight)) CBPlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + if (BasePlatform::isRectEmpty(&_upLeft)) BasePlatform::setRect(&_upLeft, 0, 0, width, height); + if (BasePlatform::isRectEmpty(&_upMiddle)) BasePlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + if (BasePlatform::isRectEmpty(&_upRight)) BasePlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); - if (CBPlatform::isRectEmpty(&_middleLeft)) CBPlatform::setRect(&_middleLeft, 0, height, width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleMiddle)) CBPlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); - if (CBPlatform::isRectEmpty(&_middleRight)) CBPlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + if (BasePlatform::isRectEmpty(&_middleLeft)) BasePlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + if (BasePlatform::isRectEmpty(&_middleMiddle)) BasePlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + if (BasePlatform::isRectEmpty(&_middleRight)) BasePlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); - if (CBPlatform::isRectEmpty(&_downLeft)) CBPlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); - if (CBPlatform::isRectEmpty(&_downMiddle)) CBPlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); - if (CBPlatform::isRectEmpty(&_downRight)) CBPlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + if (BasePlatform::isRectEmpty(&_downLeft)) BasePlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + if (BasePlatform::isRectEmpty(&_downMiddle)) BasePlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + if (BasePlatform::isRectEmpty(&_downRight)) BasePlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { +bool UITiledImage::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TILED_IMAGE\n"); buffer->putTextIndent(indent, "{\n"); @@ -330,14 +330,14 @@ bool CUITiledImage::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "HORIZONTAL_TILES { %d, %d, %d }\n", h1, h2, h3); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n"); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -void CUITiledImage::correctSize(int *width, int *height) { +void UITiledImage::correctSize(int *width, int *height) { int tileWidth = _middleMiddle.right - _middleMiddle.left; int tileHeight = _middleMiddle.bottom - _middleMiddle.top; @@ -350,8 +350,8 @@ void CUITiledImage::correctSize(int *width, int *height) { ////////////////////////////////////////////////////////////////////////// -bool CUITiledImage::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool UITiledImage::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_downLeft)); persistMgr->transfer(TMEMBER(_downMiddle)); diff --git a/engines/wintermute/ui/ui_tiled_image.h b/engines/wintermute/ui/ui_tiled_image.h index 79adf7caac..2d7068e7cd 100644 --- a/engines/wintermute/ui/ui_tiled_image.h +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -34,19 +34,19 @@ #include "common/rect.h" namespace WinterMute { -class CBSubFrame; -class CUITiledImage : public CBObject { +class BaseSubFrame; +class UITiledImage : public BaseObject { public: - DECLARE_PERSISTENT(CUITiledImage, CBObject) + DECLARE_PERSISTENT(UITiledImage, BaseObject) void correctSize(int *width, int *height); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); bool display(int x, int y, int width, int height); - CUITiledImage(CBGame *inGame = NULL); - virtual ~CUITiledImage(); - CBSubFrame *_image; + UITiledImage(BaseGame *inGame = NULL); + virtual ~UITiledImage(); + BaseSubFrame *_image; Rect32 _upLeft; Rect32 _upMiddle; Rect32 _upRight; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 269744a3c2..0fedfdc87a 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -50,12 +50,12 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CUIWindow, false) +IMPLEMENT_PERSISTENT(UIWindow, false) ////////////////////////////////////////////////////////////////////////// -CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { - CBPlatform::setRectEmpty(&_titleRect); - CBPlatform::setRectEmpty(&_dragRect); +UIWindow::UIWindow(BaseGame *inGame): UIObject(inGame) { + BasePlatform::setRectEmpty(&_titleRect); + BasePlatform::setRectEmpty(&_dragRect); _titleAlign = TAL_LEFT; _transparent = false; @@ -88,14 +88,14 @@ CUIWindow::CUIWindow(CBGame *inGame): CUIObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CUIWindow::~CUIWindow() { +UIWindow::~UIWindow() { close(); cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CUIWindow::cleanup() { +void UIWindow::cleanup() { delete _shieldWindow; delete _shieldButton; delete _viewport; @@ -113,10 +113,10 @@ void CUIWindow::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::display(int offsetX, int offsetY) { +bool UIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef); + if (!_shieldWindow) _shieldWindow = new UIWindow(_gameRef); if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; _shieldWindow->_width = _gameRef->_renderer->_width; @@ -126,7 +126,7 @@ bool CUIWindow::display(int offsetX, int offsetY) { } } else if (_isMenu) { if (!_shieldButton) { - _shieldButton = new CUIButton(_gameRef); + _shieldButton = new UIButton(_gameRef); _shieldButton->setName("close"); _shieldButton->setListener(this, _shieldButton, 0); _shieldButton->_parent = this; @@ -159,7 +159,7 @@ bool CUIWindow::display(int offsetX, int offsetY) { bool popViewport = false; if (_clipContents) { - if (!_viewport) _viewport = new CBViewport(_gameRef); + if (!_viewport) _viewport = new BaseViewport(_gameRef); if (_viewport) { _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); _gameRef->pushViewport(_viewport); @@ -168,9 +168,9 @@ bool CUIWindow::display(int offsetX, int offsetY) { } - CUITiledImage *back = _back; - CBSprite *image = _image; - CBFont *font = _font; + UITiledImage *back = _back; + BaseSprite *image = _image; + BaseFont *font = _font; if (!isFocused()) { if (_backInactive) back = _backInactive; @@ -185,12 +185,12 @@ bool CUIWindow::display(int offsetX, int offsetY) { if (image) image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); - if (!CBPlatform::isRectEmpty(&_titleRect) && font && _text) { + if (!BasePlatform::isRectEmpty(&_titleRect) && font && _text) { font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } if (!_transparent && !image) - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); @@ -207,10 +207,10 @@ bool CUIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadFile(const char *filename) { +bool UIWindow::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -266,7 +266,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(EDIT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::loadBuffer(byte *buffer, bool complete) { +bool UIWindow::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(WINDOW) TOKEN_TABLE(ALPHA_COLOR) @@ -308,7 +308,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; int ar = 0, ag = 0, ab = 0, alpha = 0; @@ -337,7 +337,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK: delete _back; - _back = new CUITiledImage(_gameRef); + _back = new UITiledImage(_gameRef); if (!_back || DID_FAIL(_back->loadFile((char *)params))) { delete _back; _back = NULL; @@ -347,7 +347,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_INACTIVE: delete _backInactive; - _backInactive = new CUITiledImage(_gameRef); + _backInactive = new UITiledImage(_gameRef); if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) { delete _backInactive; _backInactive = NULL; @@ -357,7 +357,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE: delete _image; - _image = new CBSprite(_gameRef); + _image = new BaseSprite(_gameRef); if (!_image || DID_FAIL(_image->loadFile((char *)params))) { delete _image; _image = NULL; @@ -367,7 +367,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_INACTIVE: delete _imageInactive, - _imageInactive = new CBSprite(_gameRef); + _imageInactive = new BaseSprite(_gameRef); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) { delete _imageInactive; _imageInactive = NULL; @@ -424,7 +424,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -433,7 +433,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_BUTTON: { - CUIButton *btn = new CUIButton(_gameRef); + UIButton *btn = new UIButton(_gameRef); if (!btn || DID_FAIL(btn->loadBuffer(params, false))) { delete btn; btn = NULL; @@ -446,7 +446,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_STATIC: { - CUIText *text = new CUIText(_gameRef); + UIText *text = new UIText(_gameRef); if (!text || DID_FAIL(text->loadBuffer(params, false))) { delete text; text = NULL; @@ -459,7 +459,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_EDIT: { - CUIEdit *edit = new CUIEdit(_gameRef); + UIEdit *edit = new UIEdit(_gameRef); if (!edit || DID_FAIL(edit->loadBuffer(params, false))) { delete edit; edit = NULL; @@ -472,7 +472,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_WINDOW: { - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); if (!win || DID_FAIL(win->loadBuffer(params, false))) { delete win; win = NULL; @@ -575,7 +575,7 @@ bool CUIWindow::loadBuffer(byte *buffer, bool complete) { } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { +bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WINDOW\n"); buffer->putTextIndent(indent, "{\n"); @@ -621,11 +621,11 @@ bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { error("UIWindow::SaveAsText - Unhandled enum-value NUM_TEXT_ALIGN"); } - if (!CBPlatform::isRectEmpty(&_titleRect)) { + if (!BasePlatform::isRectEmpty(&_titleRect)) { buffer->putTextIndent(indent + 2, "TITLE_RECT { %d, %d, %d, %d }\n", _titleRect.left, _titleRect.top, _titleRect.right, _titleRect.bottom); } - if (!CBPlatform::isRectEmpty(&_dragRect)) { + if (!BasePlatform::isRectEmpty(&_dragRect)) { buffer->putTextIndent(indent + 2, "DRAG_RECT { %d, %d, %d, %d }\n", _dragRect.left, _dragRect.top, _dragRect.right, _dragRect.bottom); } @@ -666,7 +666,7 @@ bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // editor properties - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); // controls for (int i = 0; i < _widgets.getSize(); i++) @@ -678,7 +678,7 @@ bool CUIWindow::saveAsText(CBDynBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::enableWidget(const char *name, bool Enable) { +bool UIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; } @@ -687,7 +687,7 @@ bool CUIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::showWidget(const char *name, bool Visible) { +bool UIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; } @@ -698,13 +698,13 @@ bool CUIWindow::showWidget(const char *name, bool Visible) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetWidget / GetControl ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->getType() == VAL_INT) { int widget = val->getInt(); if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); @@ -742,7 +742,7 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(1); delete _imageInactive; - _imageInactive = new CBSprite(_gameRef); + _imageInactive = new BaseSprite(_gameRef); const char *filename = stack->pop()->getString(); if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) { delete _imageInactive; @@ -824,7 +824,7 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS else if (strcmp(name, "LoadFromFile") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); cleanup(); if (!val->isNULL()) { stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); @@ -838,9 +838,9 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateButton") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIButton *btn = new CUIButton(_gameRef); + UIButton *btn = new UIButton(_gameRef); if (!val->isNULL()) btn->setName(val->getString()); stack->pushNative(btn, true); @@ -855,9 +855,9 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateStatic") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIText *sta = new CUIText(_gameRef); + UIText *sta = new UIText(_gameRef); if (!val->isNULL()) sta->setName(val->getString()); stack->pushNative(sta, true); @@ -872,9 +872,9 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateEditor") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIEdit *edi = new CUIEdit(_gameRef); + UIEdit *edi = new UIEdit(_gameRef); if (!val->isNULL()) edi->setName(val->getString()); stack->pushNative(edi, true); @@ -889,9 +889,9 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); if (!val->isNULL()) win->setName(val->getString()); stack->pushNative(win, true); @@ -906,8 +906,8 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); - CUIObject *obj = (CUIObject *)val->getNative(); + ScValue *val = stack->pop(); + UIObject *obj = (UIObject *)val->getNative(); for (int i = 0; i < _widgets.getSize(); i++) { if (_widgets[i] == obj) { @@ -920,12 +920,12 @@ bool CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS return STATUS_OK; } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; - else return CUIObject::scCallMethod(script, stack, thisStack, name); + else return UIObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CUIWindow::scGetProperty(const char *name) { +ScValue *UIWindow::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -1008,12 +1008,12 @@ CScValue *CUIWindow::scGetProperty(const char *name) { return _scValue; } - else return CUIObject::scGetProperty(name); + else return UIObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::scSetProperty(const char *name, CScValue *value) { +bool UIWindow::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -1097,21 +1097,21 @@ bool CUIWindow::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CUIObject::scSetProperty(name, value); + else return UIObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CUIWindow::scToString() { +const char *UIWindow::scToString() { return "[window]"; } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { +bool UIWindow::handleKeypress(Common::Event *event, bool printable) { //TODO if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { - return DID_SUCCEED(moveFocus(!CBKeyboardState::isShiftDown())); + return DID_SUCCEED(moveFocus(!BaseKeyboardState::isShiftDown())); } else { if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); else return false; @@ -1121,26 +1121,26 @@ bool CUIWindow::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouseWheel(int Delta) { +bool UIWindow::handleMouseWheel(int Delta) { if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); else return false; } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { - bool res = CUIObject::handleMouse(event, button); +bool UIWindow::handleMouse(TMouseEvent event, TMouseButton button) { + bool res = UIObject::handleMouse(event, button); // handle window dragging - if (!CBPlatform::isRectEmpty(&_dragRect)) { + if (!BasePlatform::isRectEmpty(&_dragRect)) { // start drag if (event == MOUSE_CLICK && button == MOUSE_BUTTON_LEFT) { Rect32 dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); - CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); + BasePlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); - if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { + if (BasePlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { _dragFrom.x = _gameRef->_mousePos.x; _dragFrom.y = _gameRef->_mousePos.y; _dragging = true; @@ -1158,9 +1158,9 @@ bool CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::persist(CBPersistMgr *persistMgr) { +bool UIWindow::persist(BasePersistenceManager *persistMgr) { - CUIObject::persist(persistMgr); + UIObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_backInactive)); persistMgr->transfer(TMEMBER(_clipContents)); @@ -1189,7 +1189,7 @@ bool CUIWindow::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::moveFocus(bool forward) { +bool UIWindow::moveFocus(bool forward) { int i; bool found = false; for (i = 0; i < _widgets.getSize(); i++) { @@ -1230,7 +1230,7 @@ bool CUIWindow::moveFocus(bool forward) { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goExclusive() { +bool UIWindow::goExclusive() { if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; if (_mode == WINDOW_NORMAL) { @@ -1245,7 +1245,7 @@ bool CUIWindow::goExclusive() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::goSystemExclusive() { +bool UIWindow::goSystemExclusive() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; makeFreezable(false); @@ -1262,7 +1262,7 @@ bool CUIWindow::goSystemExclusive() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::close() { +bool UIWindow::close() { if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { _gameRef->unfreeze(); } @@ -1276,16 +1276,16 @@ bool CUIWindow::close() { ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { - CUIObject *obj = (CUIObject *)param1; +bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { + UIObject *obj = (UIObject *)param1; switch (obj->_type) { case UI_BUTTON: if (scumm_stricmp(obj->_name, "close") == 0) close(); - else return CBObject::listen(param1, param2); + else return BaseObject::listen(param1, param2); break; default: - return CBObject::listen(param1, param2); + return BaseObject::listen(param1, param2); } return STATUS_OK; @@ -1293,23 +1293,23 @@ bool CUIWindow::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// -void CUIWindow::makeFreezable(bool freezable) { +void UIWindow::makeFreezable(bool freezable) { for (int i = 0; i < _widgets.getSize(); i++) _widgets[i]->makeFreezable(freezable); - CBObject::makeFreezable(freezable); + BaseObject::makeFreezable(freezable); } ////////////////////////////////////////////////////////////////////////// -bool CUIWindow::getWindowObjects(CBArray &objects, bool interactiveOnly) { +bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.getSize(); i++) { - CUIObject *control = _widgets[i]; + UIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) continue; switch (control->_type) { case UI_WINDOW: - ((CUIWindow *)control)->getWindowObjects(objects, interactiveOnly); + ((UIWindow *)control)->getWindowObjects(objects, interactiveOnly); break; case UI_BUTTON: diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 6fe24c6a2c..9e8862471c 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -35,24 +35,24 @@ namespace WinterMute { -class CUIButton; -class CBViewport; -class CUIWindow : public CUIObject { +class UIButton; +class BaseViewport; +class UIWindow : public UIObject { public: - bool getWindowObjects(CBArray &Objects, bool InteractiveOnly); + bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); bool _pauseMusic; void cleanup(); virtual void makeFreezable(bool freezable); - CBViewport *_viewport; + BaseViewport *_viewport; bool _clipContents; bool _inGame; bool _isMenu; bool _fadeBackground; uint32 _fadeColor; virtual bool handleMouseWheel(int delta); - CUIWindow *_shieldWindow; - CUIButton *_shieldButton; + UIWindow *_shieldWindow; + UIButton *_shieldButton; bool close(); bool goSystemExclusive(); bool goExclusive(); @@ -61,30 +61,30 @@ public: virtual bool handleMouse(TMouseEvent Event, TMouseButton Button); Point32 _dragFrom; bool _dragging; - DECLARE_PERSISTENT(CUIWindow, CUIObject) + DECLARE_PERSISTENT(UIWindow, UIObject) bool _transparent; bool showWidget(const char *name, bool visible = true); bool enableWidget(const char *name, bool enable = true); Rect32 _titleRect; Rect32 _dragRect; virtual bool display(int offsetX = 0, int offsetY = 0); - CUIWindow(CBGame *inGame); - virtual ~CUIWindow(); + UIWindow(BaseGame *inGame); + virtual ~UIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false); - CBArray _widgets; + BaseArray _widgets; TTextAlign _titleAlign; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - CUITiledImage *_backInactive; - CBFont *_fontInactive; - CBSprite *_imageInactive; - virtual bool listen(CBScriptHolder *param1, uint32 param2); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); + UITiledImage *_backInactive; + BaseFont *_fontInactive; + BaseSprite *_imageInactive; + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index e77f35a0e8..038095c8ae 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -45,7 +45,7 @@ static inline unsigned Sqr(int x) { ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { +void BaseUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { // If it's partly off the right side of the screen if (*destX + (srcRect->right - srcRect->left) > destRect->right) srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; @@ -76,20 +76,20 @@ void CBUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { ////////////////////////////////////////////////////////////////////////////////// // Swap - swaps two integers ////////////////////////////////////////////////////////////////////////////////// -void CBUtils::swap(int *a, int *b) { +void BaseUtils::swap(int *a, int *b) { int Temp = *a; *a = *b; *b = Temp; } ////////////////////////////////////////////////////////////////////////// -bool CBUtils::strBeginsI(const char *string, const char *fragment) { +bool BaseUtils::strBeginsI(const char *string, const char *fragment) { return (scumm_strnicmp(string, fragment, strlen(fragment)) == 0); } ////////////////////////////////////////////////////////////////////////// -float CBUtils::normalizeAngle(float angle) { +float BaseUtils::normalizeAngle(float angle) { while (angle > 360) angle -= 360; while (angle < 0) angle += 360; @@ -98,14 +98,14 @@ float CBUtils::normalizeAngle(float angle) { //////////////////////////////////////////////////////////////////////////////// -void CBUtils::createPath(const char *path, bool pathOnly) { +void BaseUtils::createPath(const char *path, bool pathOnly) { AnsiString pathStr; if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); else pathStr = path; // try { - warning("CBUtils::CreatePath - not implemented: %s", path); + warning("BaseUtils::CreatePath - not implemented: %s", path); // boost::filesystem::create_directories(path); // } catch (...) { return; @@ -114,13 +114,13 @@ void CBUtils::createPath(const char *path, bool pathOnly) { ////////////////////////////////////////////////////////////////////////// -void CBUtils::debugMessage(const char *text) { +void BaseUtils::debugMessage(const char *text) { //MessageBox(hWnd, Text, "WME", MB_OK|MB_ICONINFORMATION); } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::setString(char **string, const char *value) { +char *BaseUtils::setString(char **string, const char *value) { delete[] *string; *string = new char[strlen(value) + 1]; if (*string) strcpy(*string, value); @@ -128,7 +128,7 @@ char *CBUtils::setString(char **string, const char *value) { } ////////////////////////////////////////////////////////////////////////// -int CBUtils::strNumEntries(const char *str, const char delim) { +int BaseUtils::strNumEntries(const char *str, const char delim) { int numEntries = 1; for (uint32 i = 0; i < strlen(str); i++) { if (str[i] == delim) numEntries++; @@ -138,7 +138,7 @@ int CBUtils::strNumEntries(const char *str, const char delim) { ////////////////////////////////////////////////////////////////////////// -char *CBUtils::strEntry(int entry, const char *str, const char delim) { +char *BaseUtils::strEntry(int entry, const char *str, const char delim) { int numEntries = 0; const char *start = NULL; @@ -163,7 +163,7 @@ char *CBUtils::strEntry(int entry, const char *str, const char delim) { } ////////////////////////////////////////////////////////////////////////// -int CBUtils::randomInt(int from, int to) { +int BaseUtils::randomInt(int from, int to) { if (to < from) { int i = to; to = from; @@ -174,14 +174,14 @@ int CBUtils::randomInt(int from, int to) { } ////////////////////////////////////////////////////////////////////////// -float CBUtils::randomFloat(float from, float to) { +float BaseUtils::randomFloat(float from, float to) { const uint32 randMax = RAND_MAX; float randNum = (float)g_wintermute->randInt(0, randMax) / (float)randMax; return from + (to - from) * randNum; } ////////////////////////////////////////////////////////////////////////// -float CBUtils::randomAngle(float From, float To) { +float BaseUtils::randomAngle(float From, float To) { while (To < From) { To += 360; } @@ -189,7 +189,7 @@ float CBUtils::randomAngle(float From, float To) { } ////////////////////////////////////////////////////////////////////////// -bool CBUtils::matchesPattern(const char *pattern, const char *string) { +bool BaseUtils::matchesPattern(const char *pattern, const char *string) { char stringc, patternc; for (;; ++string) { @@ -220,14 +220,14 @@ bool CBUtils::matchesPattern(const char *pattern, const char *string) { } while (*string) - if (CBUtils::matchesPattern(pattern, string++)) + if (BaseUtils::matchesPattern(pattern, string++)) return true; return false; default: if (patternc != stringc) if (patternc == '.' && stringc == 0) - return(CBUtils::matchesPattern(pattern, string)); + return(BaseUtils::matchesPattern(pattern, string)); else return false; break; @@ -236,10 +236,10 @@ bool CBUtils::matchesPattern(const char *pattern, const char *string) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::getPath(const char *filename) { +char *BaseUtils::getPath(const char *filename) { AnsiString path = PathUtil::getDirectoryName(filename); //path = boost::filesystem::syste_complete(path).string(); - warning("CBUtils::GetPath: (%s), not implemented", filename); + warning("BaseUtils::GetPath: (%s), not implemented", filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); @@ -247,7 +247,7 @@ char *CBUtils::getPath(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -char *CBUtils::getFilename(const char *filename) { +char *BaseUtils::getFilename(const char *filename) { AnsiString path = PathUtil::getFileName(filename); char *ret = new char[path.size() + 1]; strcpy(ret, path.c_str()); @@ -255,7 +255,7 @@ char *CBUtils::getFilename(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -void CBUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { +void BaseUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { float varR = (RGBCOLGetR(RGBColor) / 255.0f); float varG = (RGBCOLGetG(RGBColor) / 255.0f); float varB = (RGBCOLGetB(RGBColor) / 255.0f); @@ -304,7 +304,7 @@ void CBUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { ////////////////////////////////////////////////////////////////////////// -uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { +uint32 BaseUtils::HSLtoRGB(byte InH, byte InS, byte InL) { float H = InH / 255.0f; float S = InS / 255.0f; float L = InL / 255.0f; @@ -333,7 +333,7 @@ uint32 CBUtils::HSLtoRGB(byte InH, byte InS, byte InL) { ////////////////////////////////////////////////////////////////////////// -float CBUtils::Hue2RGB(float v1, float v2, float vH) { +float BaseUtils::Hue2RGB(float v1, float v2, float vH) { if (vH < 0.0f) vH += 1.0f; if (vH > 1.0f) vH -= 1.0f; if ((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH); diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index c8ca2e121c..3baafaa606 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -34,9 +34,9 @@ namespace WinterMute { -class CBGame; +class BaseGame; -class CBUtils { +class BaseUtils { public: static void clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect); static void swap(int *a, int *b); diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index 49d1c6c50f..2806dbe516 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -39,13 +39,13 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -CVidPlayer::CVidPlayer(CBGame *inGame): CBBase(inGame) { +VideoPlayer::VideoPlayer(BaseGame *inGame): BaseClass(inGame) { SetDefaults(); } ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::SetDefaults() { +bool VideoPlayer::SetDefaults() { _playing = false; /* _aviFile = NULL; @@ -85,13 +85,13 @@ bool CVidPlayer::SetDefaults() { ////////////////////////////////////////////////////////////////////////// -CVidPlayer::~CVidPlayer() { +VideoPlayer::~VideoPlayer() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::cleanup() { +bool VideoPlayer::cleanup() { #if 0 if (_sound) _sound->Stop(); if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); @@ -124,7 +124,7 @@ bool CVidPlayer::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { +bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 cleanup(); @@ -186,7 +186,7 @@ bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { bool res; if (_soundAvailable) { - _sound = new CBSoundAVI(_gameRef); + _sound = new BaseSoundAVI(_gameRef); if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { SAFE_DELETE(_sound); _soundAvailable = false; @@ -204,7 +204,7 @@ bool CVidPlayer::initialize(const char *inFilename, const char *SubtitleFile) { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::update() { +bool VideoPlayer::update() { #if 0 if (!m_Playing) return STATUS_OK; @@ -274,7 +274,7 @@ bool CVidPlayer::update() { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::display() { +bool VideoPlayer::display() { #if 0 if (!m_Playing) return STATUS_OK; @@ -284,7 +284,7 @@ bool CVidPlayer::display() { // display subtitle if (m_ShowSubtitle) { - CBFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; + BaseFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); } @@ -298,7 +298,7 @@ bool CVidPlayer::display() { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { #if 0 if (!_videoStream || !_vidRenderer) return STATUS_FAILED; @@ -359,7 +359,7 @@ bool CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::stop() { +bool VideoPlayer::stop() { #if 0 if (!_playing) return STATUS_OK; @@ -372,13 +372,13 @@ bool CVidPlayer::stop() { ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::isPlaying() { +bool VideoPlayer::isPlaying() { return _playing; } ////////////////////////////////////////////////////////////////////////// -bool CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { +bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { #if 0 if (!Filename) return STATUS_OK; diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h index 8dda93b43e..8e82a44076 100644 --- a/engines/wintermute/video/video_player.h +++ b/engines/wintermute/video/video_player.h @@ -38,7 +38,7 @@ namespace WinterMute { -class CVidPlayer : public CBBase { +class VideoPlayer : public BaseClass { public: bool _showSubtitle; int _currentSubtitle; @@ -51,7 +51,7 @@ public: uint32 _totalVideoTime; uint32 _startTime; //CVidRenderer *_vidRenderer; - //CBSoundAVI *_sound; + //BaseSoundAVI *_sound; bool _soundAvailable; bool SetDefaults(); bool _playing; @@ -59,8 +59,8 @@ public: bool update(); bool initialize(const char *inFilename, const char *SubtitleFile = NULL); bool cleanup(); - CVidPlayer(CBGame *inGame); - virtual ~CVidPlayer(); + VideoPlayer(BaseGame *inGame); + virtual ~VideoPlayer(); /*PAVIFILE _aviFile; @@ -81,7 +81,7 @@ public: /* LPBITMAPV4HEADER _targetFormat; - CBArray _subtitles;*/ + BaseArray _subtitles;*/ }; } // end of namespace WinterMute diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index e3c120ff86..91161cbd3b 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -43,15 +43,15 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CVidTheoraPlayer, false) +IMPLEMENT_PERSISTENT(VideoTheoraPlayer, false) ////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::CVidTheoraPlayer(CBGame *inGame): CBBase(inGame) { +VideoTheoraPlayer::VideoTheoraPlayer(BaseGame *inGame): BaseClass(inGame) { SetDefaults(); } ////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::SetDefaults() { +void VideoTheoraPlayer::SetDefaults() { _file = NULL; _filename = ""; @@ -97,7 +97,7 @@ void CVidTheoraPlayer::SetDefaults() { } ////////////////////////////////////////////////////////////////////////// -CVidTheoraPlayer::~CVidTheoraPlayer(void) { +VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); /* SAFE_DELETE_ARRAY(_filename); @@ -108,7 +108,7 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { } ////////////////////////////////////////////////////////////////////////// -void CVidTheoraPlayer::cleanup() { +void VideoTheoraPlayer::cleanup() { if (_file) { _gameRef->_fileManager->closeFile(_file); _file = NULL; @@ -134,14 +134,14 @@ void CVidTheoraPlayer::cleanup() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { +bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common::String &subtitleFile) { cleanup(); _filename = filename; _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) return STATUS_FAILED; - //if (Filename != _filename) CBUtils::setString(&_filename, filename); + //if (Filename != _filename) BaseUtils::setString(&_filename, filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else @@ -156,7 +156,7 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: // Additional setup. _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); - _texture = new CBSurfaceOSystem(_gameRef); + _texture = new BaseSurfaceOSystem(_gameRef); _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; @@ -168,7 +168,7 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: _file = _gameRef->_fileManager->openFile(filename); if (!_file) return STATUS_FAILED; - if (Filename != _filename) CBUtils::setString(&_filename, filename); + if (Filename != _filename) BaseUtils::setString(&_filename, filename); // start up Ogg stream synchronization layer ogg_sync_init(&m_OggSyncState); @@ -299,7 +299,7 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: // create sound buffer if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { - m_Sound = new CBSoundTheora(_gameRef); + m_Sound = new BaseSoundTheora(_gameRef); _gameRef->m_SoundMgr->AddSound(m_Sound); if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { _gameRef->m_SoundMgr->RemoveSound(m_Sound); @@ -315,9 +315,9 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: // create texture if (m_TheoraStreams && !m_Texture) { if (_gameRef->m_UseD3D) - m_Texture = new CBSurfaceD3D(_gameRef); + m_Texture = new BaseSurfaceD3D(_gameRef); else - m_Texture = new CBSurfaceDD(_gameRef); + m_Texture = new BaseSurfaceDD(_gameRef); if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { SAFE_DELETE(m_Texture); @@ -335,7 +335,7 @@ bool CVidTheoraPlayer::initialize(const Common::String &filename, const Common:: ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::resetStream() { +bool VideoTheoraPlayer::resetStream() { warning("VidTheoraPlayer::resetStream - stubbed"); #if 0 if (_sound) _sound->Stop(); @@ -348,7 +348,7 @@ bool CVidTheoraPlayer::resetStream() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { +bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) @@ -452,7 +452,7 @@ bool CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::stop() { +bool VideoTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { @@ -467,7 +467,7 @@ bool CVidTheoraPlayer::stop() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::update() { +bool VideoTheoraPlayer::update() { _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; if (!isPlaying()) return STATUS_OK; @@ -590,7 +590,7 @@ bool CVidTheoraPlayer::update() { } ////////////////////////////////////////////////////////////////////////// -uint32 CVidTheoraPlayer::getMovieTime() { +uint32 VideoTheoraPlayer::getMovieTime() { if (!_playbackStarted) { return 0; } else { @@ -600,7 +600,7 @@ uint32 CVidTheoraPlayer::getMovieTime() { ////////////////////////////////////////////////////////////////////////// -uint32 CVidTheoraPlayer::getMovieFrame() { +uint32 VideoTheoraPlayer::getMovieFrame() { #if 0 if (!m_TheoraStreams) return 0; float Time = GetMovieTime(); @@ -615,7 +615,7 @@ uint32 CVidTheoraPlayer::getMovieFrame() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::WriteVideo() { +bool VideoTheoraPlayer::WriteVideo() { if (!_texture) return STATUS_FAILED; _texture->startPixelOp(); @@ -634,7 +634,7 @@ bool CVidTheoraPlayer::WriteVideo() { return STATUS_OK; } -void CVidTheoraPlayer::writeAlpha() { +void VideoTheoraPlayer::writeAlpha() { if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); @@ -652,12 +652,12 @@ void CVidTheoraPlayer::writeAlpha() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::display(uint32 alpha) { +bool VideoTheoraPlayer::display(uint32 alpha) { Rect32 rc; bool res; if (_texture && _videoFrameReady) { - CBPlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); + BasePlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); } else res = STATUS_FAILED; @@ -668,11 +668,11 @@ bool CVidTheoraPlayer::display(uint32 alpha) { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { - warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); +bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { + warning("VideoTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; - _alphaImage = new CBImage(_gameRef); + _alphaImage = new BaseImage(_gameRef); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; @@ -686,20 +686,20 @@ bool CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { //TODO: Conversion. #if 0 SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new CBImage(_gameRef); + m_AlphaImage = new BaseImage(_gameRef); if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); return STATUS_FAILED; } - if (m_AlphaFilename != Filename) CBUtils::setString(&m_AlphaFilename, filename); + if (m_AlphaFilename != Filename) BaseUtils::setString(&m_AlphaFilename, filename); m_AlphaImage->Convert(IMG_TRUECOLOR); #endif return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -byte CVidTheoraPlayer::getAlphaAt(int x, int y) { +byte VideoTheoraPlayer::getAlphaAt(int x, int y) { if (_alphaImage) return _alphaImage->getAlphaAt(x, y); else return 0xFF; } @@ -717,8 +717,8 @@ inline int intlog(int num) { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::SeekToTime(uint32 time) { - warning("CVidTheoraPlayer::SeekToTime(%d) - not supported", time); +bool VideoTheoraPlayer::SeekToTime(uint32 time) { + warning("VideoTheoraPlayer::SeekToTime(%d) - not supported", time); #if 0 if (!m_TheoraStreams) return STATUS_FAILED; @@ -781,7 +781,7 @@ finish: } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::pause() { +bool VideoTheoraPlayer::pause() { if (_state == THEORA_STATE_PLAYING) { _state = THEORA_STATE_PAUSED; _theoraDecoder->pauseVideo(true); @@ -792,7 +792,7 @@ bool CVidTheoraPlayer::pause() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::resume() { +bool VideoTheoraPlayer::resume() { if (_state == THEORA_STATE_PAUSED) { _state = THEORA_STATE_PLAYING; _theoraDecoder->pauseVideo(false); @@ -803,8 +803,8 @@ bool CVidTheoraPlayer::resume() { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { - //CBBase::persist(persistMgr); +bool VideoTheoraPlayer::persist(BasePersistenceManager *persistMgr) { + //BaseClass::persist(persistMgr); if (persistMgr->_saving) { _savedPos = getMovieTime() * 1000; @@ -833,7 +833,7 @@ bool CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CVidTheoraPlayer::initializeSimple() { +bool VideoTheoraPlayer::initializeSimple() { if (DID_SUCCEED(initialize(_filename))) { if (_alphaFilename != "") setAlphaImage(_alphaFilename); play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); @@ -843,7 +843,7 @@ bool CVidTheoraPlayer::initializeSimple() { } ////////////////////////////////////////////////////////////////////////// -CBSurface *CVidTheoraPlayer::getTexture() { +BaseSurface *VideoTheoraPlayer::getTexture() { return _texture; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 5bf8e165c7..6e0e4b3152 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -37,9 +37,9 @@ #include "graphics/surface.h" namespace WinterMute { -class CBSurface; -class CBImage; -class CVidTheoraPlayer : public CBBase { +class BaseSurface; +class BaseImage; +class VideoTheoraPlayer : public BaseClass { private: enum { THEORA_STATE_NONE = 0, @@ -50,16 +50,16 @@ private: Video::RewindableVideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: - DECLARE_PERSISTENT(CVidTheoraPlayer, CBBase) + DECLARE_PERSISTENT(VideoTheoraPlayer, BaseClass) - CVidTheoraPlayer(CBGame *inGame); - virtual ~CVidTheoraPlayer(void); + VideoTheoraPlayer(BaseGame *inGame); + virtual ~VideoTheoraPlayer(void); // external objects Common::SeekableReadStream *_file; Common::String _filename; - CBSurface *_texture; + BaseSurface *_texture; //CVidSubtitler *_subtitler; // control methods @@ -69,7 +69,7 @@ public: bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); bool stop(); bool display(uint32 alpha = 0xFFFFFFFF); - //bool RenderFrame(CBSurface *Texture, yuv_buffer *yuv); + //bool RenderFrame(BaseSurface *Texture, yuv_buffer *yuv); bool pause(); bool resume(); @@ -87,7 +87,7 @@ public: uint32 getMovieTime(); uint32 getMovieFrame(); - CBSurface *getTexture(); + BaseSurface *getTexture(); int _state; uint32 _startTime; @@ -97,7 +97,7 @@ public: // alpha related - CBImage *_alphaImage; + BaseImage *_alphaImage; Common::String _alphaFilename; bool setAlphaImage(const Common::String &filename); __inline byte getAlphaAt(int x, int y); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 2a651baabf..69c5df5bc5 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -138,12 +138,12 @@ Common::Error WinterMuteEngine::run() { } int WinterMuteEngine::init() { - _classReg = new CSysClassRegistry(); + _classReg = new SystemClassRegistry(); _classReg->registerClasses(); - _game = new CAdGame; + _game = new AdGame; if (!_game) return 1; - CBPlatform::initialize(_game, 0, NULL); + BasePlatform::initialize(_game, 0, NULL); bool windowedMode = !ConfMan.getBool("fullscreen"); @@ -157,8 +157,8 @@ int WinterMuteEngine::init() { else param[0] = '\0'; if (strcmp(param, "") != 0) { - char *IniDir = CBUtils::GetPath(param); - char *IniName = CBUtils::GetFilename(param); + char *IniDir = BaseUtils::GetPath(param); + char *IniName = BaseUtils::GetFilename(param); // switch to ini's dir warning("TODO: Place ini-files somewhere"); @@ -230,7 +230,7 @@ int WinterMuteEngine::init() { // load game - uint32 DataInitStart = CBPlatform::getTime(); + uint32 DataInitStart = BasePlatform::getTime(); if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); @@ -242,7 +242,7 @@ int WinterMuteEngine::init() { _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; - _game->LOG(0, "Engine initialized in %d ms", CBPlatform::getTime() - DataInitStart); + _game->LOG(0, "Engine initialized in %d ms", BasePlatform::getTime() - DataInitStart); _game->LOG(0, ""); if (ConfMan.hasKey("save_slot")) { @@ -272,7 +272,7 @@ int WinterMuteEngine::messageLoop() { while (!done) { Common::Event event; while (_system->getEventManager()->pollEvent(event)) { - CBPlatform::handleEvent(&event); + BasePlatform::handleEvent(&event); } if (_game && _game->_renderer->_active && _game->_renderer->_ready) { diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index bf716a5a1f..b37f495b5e 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -31,8 +31,8 @@ namespace WinterMute { class Console; -class CBGame; -class CSysClassRegistry; +class BaseGame; +class SystemClassRegistry; // our engine debug channels enum { kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine @@ -49,15 +49,15 @@ public: virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } - CSysClassRegistry *getClassRegistry(){ return _classReg; } + SystemClassRegistry *getClassRegistry(){ return _classReg; } uint32 randInt(int from, int to); private: int init(); void deinit(); int messageLoop(); Console *_console; - CBGame *_game; - CSysClassRegistry *_classReg; + BaseGame *_game; + SystemClassRegistry *_classReg; // We need random numbers Common::RandomSource *_rnd; const ADGameDescription *_gameDescription; -- cgit v1.2.3 From f54f262bb56d251d131109a81cad7811e240ff4f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 21:17:08 +0200 Subject: WINTERMUTE: Fix a few signed/unsigned and float->int warnings. --- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index a913cc52ba..cb3468c4f3 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -97,8 +97,8 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; - for (int i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); + for (int i = 0; (uint32)i < str.size(); i++) { + textWidth += getCharWidth((byte)str[i]); } return textWidth; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 212f11d2f6..54e612ff42 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -168,7 +168,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 else scale = BaseUtils::randomFloat(_scale1, _scale2); int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + if (_lifeTimeZBased) lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); float angle = BaseUtils::randomAngle(_angle1, _angle2); -- cgit v1.2.3 From 742521c20db68e965761ba9309bb0a3dea379217 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 07:24:48 +0200 Subject: WINTERMUTE: Redo base_file_manager, to use FSLists for registering/opening packages. This is helpfull for consistency between registering and lookup, and allows for explicit removal/adding of sub_paths for the engine. But most importantly it keeps the loading consistent and non-duplicated for detection. --- engines/wintermute/base/base_file_manager.cpp | 171 +++++++++++------------- engines/wintermute/base/base_file_manager.h | 14 +- engines/wintermute/base/file/base_disk_file.cpp | 57 +++----- engines/wintermute/base/file/base_package.cpp | 4 +- engines/wintermute/base/file/base_package.h | 2 +- engines/wintermute/dcpackage.h | 40 +++--- 6 files changed, 128 insertions(+), 160 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index a2c81b8a8c..4dcc1c6948 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -50,6 +50,7 @@ #include "common/fs.h" #include "common/file.h" #include "common/savefile.h" +#include "common/fs.h" namespace WinterMute { @@ -75,15 +76,8 @@ BaseFileManager::~BaseFileManager() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::cleanup() { // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; _packagePaths.clear(); - // delete file entries _filesIter = _files.begin(); while (_filesIter != _files.end()) { @@ -226,7 +220,7 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->close(); + if (_packages[i]->_cd > 0) _packages[i]->close(); } @@ -235,24 +229,25 @@ bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; +bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { + if (path.getName().c_str() == NULL || strlen(path.getName().c_str()) < 1) return STATUS_FAILED; - bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); +// bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; +/* char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; if (buffer == NULL) return STATUS_FAILED; strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\"); + if (!slashed) strcat(buffer, "\\");*/ //BasePlatform::strlwr(buffer); switch (type) { case PATH_SINGLE: - _singlePaths.push_back(buffer); + // _singlePaths.push_back(path); + error("TODO: Allow adding single-paths"); break; case PATH_PACKAGE: - _packagePaths.push_back(buffer); + _packagePaths.push_back(path); break; } @@ -262,12 +257,12 @@ bool BaseFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::reloadPaths() { // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); +/* for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i];*/ + //_singlePaths.clear(); - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; +/* for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i];*/ _packagePaths.clear(); return initPaths(); @@ -289,16 +284,17 @@ bool BaseFileManager::initPaths() { for (int i = 0; i < numPaths; i++) { char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - addPath(PATH_SINGLE, path); + error("BaseFileManager::initPaths - Game wants to add customPath: %s", path); // TODO +// addPath(PATH_SINGLE, path); } delete[] path; path = NULL; } - addPath(PATH_SINGLE, ".\\"); - +// addPath(PATH_SINGLE, ".\\"); // package files paths - addPath(PATH_PACKAGE, "./"); + const Common::FSNode gameData(ConfMan.get("path")); + addPath(PATH_PACKAGE, gameData); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); @@ -306,16 +302,32 @@ bool BaseFileManager::initPaths() { for (int i = 0; i < numPaths; i++) { char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - addPath(PATH_PACKAGE, path); + error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path); // TODO +// addPath(PATH_PACKAGE, path); } delete[] path; path = NULL; } - addPath(PATH_PACKAGE, "data"); + + Common::FSNode dataSubFolder = gameData.getChild("data"); + if (dataSubFolder.exists()) { + addPath(PATH_PACKAGE, dataSubFolder); + } return STATUS_OK; } +bool BaseFileManager::registerPackages(const Common::FSList &fslist) { + for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { + warning("Adding %s", (*it).getName().c_str()); + if ((*it).getName().contains(".dcp")) { + if (registerPackage((*it).createReadStream())) { + addPath(PATH_PACKAGE, (*it)); + } + } + } + warning(" Registered %d files in %d package(s)", _files.size(), _packages.size()); +} ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { @@ -324,11 +336,24 @@ bool BaseFileManager::registerPackages() { _gameRef->LOG(0, "Scanning packages..."); debugC(kWinterMuteDebugFileAccess, "Scanning packages"); - Common::ArchiveMemberList files; +/* Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.dcp"); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { registerPackage((*it)->getName().c_str()); + }*/ + // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail + // and that has to be like that to support the detection-scheme. + Common::FSList files; + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + (*it).getChildren(files, Common::FSNode::kListFilesOnly); + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { + if (!fileIt->getName().contains(".dcp")) + continue; + warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + registerPackage((*fileIt).createReadStream()); + } } #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); @@ -373,7 +398,10 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); return STATUS_OK; } + return registerPackage(package, filename); +} +bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; @@ -392,25 +420,25 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear TPackageHeader hdr; hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return STATUS_OK; } - if (hdr.PackageVersion != PACKAGE_VERSION) { + if (hdr._packageVersion != PACKAGE_VERSION) { _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { uint32 dirOffset; dirOffset = package->readUint32LE(); dirOffset += absoluteOffset; package->seek(dirOffset, SEEK_SET); } - for (uint32 i = 0; i < hdr.NumDirs; i++) { + for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(_gameRef); if (!pkg) return STATUS_FAILED; @@ -420,10 +448,10 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear byte nameLength = package->readByte(); pkg->_name = new char[nameLength]; package->read(pkg->_name, nameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; + pkg->_cd = package->readByte(); + pkg->_priority = hdr._priority; - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk _packages.push_back(pkg); @@ -439,7 +467,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear package->read(name, nameLength); // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { for (int k = 0; k < nameLength; k++) { ((byte *)name)[k] ^= 'D'; } @@ -458,7 +486,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear compLength = package->readUint32LE(); flags = package->readUint32LE(); - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { timeDate1 = package->readUint32LE(); timeDate2 = package->readUint32LE(); } @@ -474,7 +502,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear _files[name] = file; } else { // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { _filesIter->_value->_package = pkg; _filesIter->_value->_offset = offset; _filesIter->_value->_length = length; @@ -511,13 +539,21 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (uint32 i = 0; i < _packagePaths.size(); i++) { + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + Common::String packageName = (*it).getName(); + if (packageName == (name + ".dcp")) + ret->open((*it)); + if (ret->isOpen()) { + return ret; + } + } +/* for (uint32 i = 0; i < _packagePaths.size(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; } - } + }*/ sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); @@ -530,61 +566,6 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { } -////////////////////////////////////////////////////////////////////////// -Common::File *BaseFileManager::openSingleFile(const Common::String &name) { - restoreCurrentDir(); - - Common::File *ret = NULL; - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::getFullPath(const Common::String &filename, char *fullname) { - restoreCurrentDir(); - - Common::File f; - bool found = false; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(filename.c_str()); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(fullname, filename.c_str()); - } - } - - return found; -} - - ////////////////////////////////////////////////////////////////////////// BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { char *upc_name = new char[strlen(filename.c_str()) + 1]; @@ -703,7 +684,7 @@ bool BaseFileManager::setBasePath(const Common::String &path) { ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::findPackageSignature(Common::File *f, uint32 *offset) { +bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; byte signature[8]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 469108bee8..78e6cb737f 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -32,6 +32,7 @@ #include "engines/wintermute/base/file/base_file_entry.h" #include "common/archive.h" #include "common/str.h" +#include "common/fs.h" namespace Common { class File; @@ -41,39 +42,38 @@ namespace WinterMute { class BaseFile; class BaseFileManager: BaseClass { public: - bool findPackageSignature(Common::File *f, uint32 *offset); + bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool cleanup(); bool setBasePath(const Common::String &path); bool restoreCurrentDir(); char *_basePath; - bool getFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *openFileRaw(const Common::String &filename); bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); BaseFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); + bool registerPackages(const Common::FSList &fslist); bool registerPackages(); bool initPaths(); bool reloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - bool addPath(TPathType type, const Common::String &path); + bool addPath(TPathType type, const Common::FSNode &path); bool requestCD(int cd, char *packageFile, const char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); BaseFileManager(BaseGame *inGame = NULL); virtual ~BaseFileManager(); - Common::Array _singlePaths; - Common::Array _packagePaths; +// Common::FSList _singlePaths; + Common::FSList _packagePaths; Common::Array _packages; Common::Array _openFiles; - Common::HashMap _files; private: + bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 6c89fc22f1..b4653c2c80 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -36,6 +36,7 @@ #include "common/memstream.h" #include "common/file.h" #include "common/zlib.h" +#include "common/archive.h" namespace WinterMute { @@ -50,27 +51,13 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { - sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); - correctSlashes(fullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - // if we didn't find it in search paths, try to open directly - if (!file) { - strcpy(fullPath, filename.c_str()); - correctSlashes(fullPath); - - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + file = (*it)->createReadStream(); + break; } } @@ -83,38 +70,38 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; if (compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = file->readUint32LE(); - CompSize = file->readUint32LE(); - UncompSize = file->readUint32LE(); + uint32 dataOffset, compSize, uncompSize; + dataOffset = file->readUint32LE(); + compSize = file->readUint32LE(); + uncompSize = file->readUint32LE(); - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { + byte *compBuffer = new byte[compSize]; + if (!compBuffer) { error("Error allocating memory for compressed file '%s'", filename.c_str()); delete file; return NULL; } - byte *data = new byte[UncompSize]; + byte *data = new byte[uncompSize]; if (!data) { error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] CompBuffer; + delete [] compBuffer; delete file; return NULL; } - file->seek(DataOffset + prefixSize, SEEK_SET); - file->read(CompBuffer, CompSize); + file->seek(dataOffset + prefixSize, SEEK_SET); + file->read(compBuffer, compSize); - if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); - delete [] CompBuffer; + delete [] compBuffer; delete file; return NULL; } - delete [] CompBuffer; + delete [] compBuffer; - return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); delete file; file = NULL; } else { diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 03a80f3d8d..24f7c23422 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -43,7 +43,7 @@ namespace WinterMute { BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { _file = NULL; _name = NULL; - _cD = 0; + _cd = 0; _priority = 0; _boundToExe = false; } @@ -89,7 +89,7 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu Common::SeekableReadStream *BasePackage::getFilePointer() { Common::File *file = _gameRef->_fileManager->openPackage(_name); if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); + _gameRef->_fileManager->requestCD(_cd, _name, ""); file = _gameRef->_fileManager->openPackage(_name); } return file; diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index bf45087f91..2f305ea049 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -49,7 +49,7 @@ public: bool close(); bool open(); char *_name; - int _cD; + int _cd; Common::SeekableReadStream *_file; BasePackage(BaseGame *inGame); virtual ~BasePackage(); diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h index 0b7bdf9b44..5e47edba56 100644 --- a/engines/wintermute/dcpackage.h +++ b/engines/wintermute/dcpackage.h @@ -40,33 +40,33 @@ namespace WinterMute { struct TPackageHeader { - uint32 Magic1; - uint32 Magic2; - uint32 PackageVersion; - uint32 GameVersion; - byte Priority; - byte CD; - bool MasterIndex; - uint32 CreationTime; - char Desc[100]; - uint32 NumDirs; + uint32 _magic1; + uint32 _magic2; + uint32 _packageVersion; + uint32 _gameVersion; + byte _priority; + byte _cd; + bool _masterIndex; + uint32 _creationTime; + char _desc[100]; + uint32 _numDirs; // TODO: Move this out of the header. void readFromStream(Common::ReadStream *stream) { - Magic1 = stream->readUint32LE(); - Magic2 = stream->readUint32LE(); - PackageVersion = stream->readUint32LE(); + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); - GameVersion = stream->readUint32LE(); + _gameVersion = stream->readUint32LE(); - Priority = stream->readByte(); - CD = stream->readByte(); - MasterIndex = stream->readByte(); + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); stream->readByte(); // To align the next byte... - CreationTime = stream->readUint32LE(); + _creationTime = stream->readUint32LE(); - stream->read(Desc, 100); - NumDirs = stream->readUint32LE(); + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); } }; -- cgit v1.2.3 From c8b1c747242df4d8c596873ee320d64583380be0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 07:28:17 +0200 Subject: WINTERMUTE: Add in a fallback-detector for unknown games. (flagged as "fangame" for now) This does a minimal engine-startup to open any dcp's and get the proper "startup.settings"-file, and then get the name/caption fields from that file. There are currently no handling of localized strings used there (base_string_table would be the culprit). And, there is also no secondary checks for language (but for that matter, there is no support for chosing language if multiple exist at this point either). --- engines/wintermute/detection.cpp | 62 +++++++++++++++++++++++++++++++++++++-- engines/wintermute/wintermute.cpp | 62 +++++++++++++++++++++++++++++++++++++++ engines/wintermute/wintermute.h | 3 ++ 3 files changed, 125 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 285c3ffaeb..5e259f717d 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -32,6 +32,24 @@ #include "engines/wintermute/detection_tables.h" +namespace WinterMute { + +/** + * The fallback game descriptor used by the WinterMute engine's fallbackDetector. + * Contents of this struct are overwritten by the fallbackDetector. (logic copied partially + * from the SCI-engine). + */ +static ADGameDescription s_fallbackDesc = { + "", + "", + AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor + Common::UNK_LANG, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() +}; +static char s_fallbackGameIdBuf[256]; + class WinterMuteMetaEngine : public AdvancedMetaEngine { public: WinterMuteMetaEngine() : AdvancedMetaEngine(WinterMute::gameDescriptions, sizeof(ADGameDescription), WinterMute::wintermuteGames) { @@ -83,6 +101,44 @@ public: } return detectedGames; }*/ + + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + // Set some defaults + s_fallbackDesc.extra = ""; + s_fallbackDesc.language = Common::UNK_LANG; + s_fallbackDesc.flags = ADGF_UNSTABLE; + s_fallbackDesc.platform = Common::kPlatformWindows; // default to Windows + s_fallbackDesc.gameid = "wintermute"; + s_fallbackDesc.guioptions = GUIO0(); + + if (allFiles.contains("data.dcp")) { + Common::String name, caption; + if (WinterMuteEngine::getGameInfo(fslist, name, caption)) { + for (int32 i = 0; i < name.size(); i++) { + // Replace spaces with underscores + if (name[i] == ' ') { + name.setChar('_', (uint32)i); + } + } + // Prefix to avoid collisions with actually known games + name = "wmefan-" + name; + strncpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); + s_fallbackDesc.gameid = s_fallbackGameIdBuf; + if (caption != name) { + caption += " (fangame) "; + char *offset = s_fallbackGameIdBuf + name.size() + 1; + uint32 remainingLength = (sizeof(s_fallbackGameIdBuf) - 1) - (name.size() + 1); + strncpy(offset, caption.c_str(), remainingLength); + s_fallbackDesc.extra = offset; + s_fallbackDesc.flags |= ADGF_USEEXTRAASTITLE; + } + return &s_fallbackDesc; + } // Fall through to return 0; + } + return 0; + } + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { assert(syst); assert(engine); @@ -141,8 +197,10 @@ public: } }; +} // end of namespace WinterMute + #if PLUGIN_ENABLED_DYNAMIC(WINTERMUTE) -REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); +REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMute::WinterMuteMetaEngine); #else -REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMuteMetaEngine); +REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMute::WinterMuteMetaEngine); #endif diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 69c5df5bc5..9040de66e6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -29,6 +29,7 @@ #include "common/EventRecorder.h" #include "common/file.h" #include "common/fs.h" +#include "common/tokenizer.h" #include "engines/util.h" #include "engines/wintermute/ad/ad_game.h" @@ -37,12 +38,24 @@ #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/scriptables/script_engine.h" namespace WinterMute { WinterMuteEngine *g_wintermute; +// Simple constructor for detection - we need to setup the persistence to avoid special-casing in-engine +// This might not be the prettiest solution +WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { + g_wintermute = this; + _classReg = new SystemClassRegistry(); + _classReg->registerClasses(); + + _game = new AdGame(); + _rnd = NULL; +} + WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) { // Put your engine in a sane state, but do nothing big yet; @@ -74,7 +87,10 @@ WinterMuteEngine::~WinterMuteEngine() { debug("WinterMuteEngine::~WinterMuteEngine"); // Dispose your resources here + delete _classReg; delete _rnd; + delete _game; + g_wintermute = NULL; // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); @@ -320,6 +336,52 @@ int WinterMuteEngine::messageLoop() { void WinterMuteEngine::deinit() { delete _classReg; + _classReg = NULL; +} + +bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { + bool retVal = false; + caption = name = "(invalid)"; + + // Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it + WinterMuteEngine *engine = new WinterMuteEngine(); + + engine->_game->initialize1(); + engine->_game->_fileManager->registerPackages(fslist); + if (engine->_game->loadSettings("startup.settings")) { + // We do some manual parsing here, as the engine needs gfx to be initalized to do that. + Common::SeekableReadStream *stream = engine->_game->_fileManager->openFile((engine->_game->_settingsGameFile ? engine->_game->_settingsGameFile : "default.game"), false, false); + while (!stream->eos() && !stream->err()) { + Common::String line = stream->readLine(); + line.trim(); // Get rid of indentation + // Expect "GAME {" or comment, or empty line + if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) + continue; + else { + Common::StringTokenizer token(line, "="); + Common::String key = token.nextToken(); + Common::String value = token.nextToken(); + if (value.size() == 0) + continue; + if (value[0] == '\"') + value.deleteChar(0); + else + continue; // not a string + if (value.lastChar() == '\"') + value.deleteLastChar(); + if (key == "NAME") { + retVal = true; + name = value; + } else if (key == "CAPTION") { + retVal = true; + caption = value; + } + } + } + delete stream; + } + delete engine; + return retVal; } uint32 WinterMuteEngine::randInt(int from, int to) { diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index b37f495b5e..e850a72196 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -44,6 +44,7 @@ enum { class WinterMuteEngine : public Engine { public: WinterMuteEngine(OSystem *syst, const ADGameDescription *desc); + WinterMuteEngine(); ~WinterMuteEngine(); virtual Common::Error run(); @@ -51,6 +52,8 @@ public: Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } SystemClassRegistry *getClassRegistry(){ return _classReg; } uint32 randInt(int from, int to); + // For detection-purposes: + static bool getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption); private: int init(); void deinit(); -- cgit v1.2.3 From a549977cffae9a5f1be41d9b07d42908648e8f6d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 21:02:25 +0200 Subject: WINTERMUTE: Use FSNodes to parse relative paths used by the games. --- engines/wintermute/base/file/base_disk_file.cpp | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index b4653c2c80..d1a8f02fa5 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -37,6 +37,8 @@ #include "common/file.h" #include "common/zlib.h" #include "common/archive.h" +#include "common/tokenizer.h" +#include "common/config-manager.h" namespace WinterMute { @@ -50,7 +52,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - + // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); @@ -60,7 +62,29 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil break; } } - + // The filename can be an explicit path, thus we need to chop it up, expecting the path the game + // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + if (!file) { + if (filename.contains(':')) + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + if (filename.contains('\\')) { + Common::StringTokenizer path(filename, "\\"); + + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSNode curNode = gameDataDir; + while (!path.empty()) { + Common::String pathPart = path.nextToken(); + Common::FSNode nextNode(curNode.getChild(pathPart)); + if (nextNode.exists() && nextNode.isReadable()) { + curNode = nextNode; + } + if (!curNode.isDirectory()) { + file = curNode.createReadStream(); + break; + } + } + } + } if (file) { uint32 magic1, magic2; magic1 = file->readUint32LE(); -- cgit v1.2.3 From 6fb641111f28d02714064ae193e39e4f1e60ce35 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 21:02:57 +0200 Subject: WINTERMUTE: Use only alphanumerics in fallback-gameids. --- engines/wintermute/detection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 5e259f717d..85b8dcf429 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -27,6 +27,7 @@ #include "common/config-manager.h" #include "common/error.h" #include "common/fs.h" +#include "common/util.h" #include "engines/metaengine.h" @@ -116,8 +117,8 @@ public: Common::String name, caption; if (WinterMuteEngine::getGameInfo(fslist, name, caption)) { for (int32 i = 0; i < name.size(); i++) { - // Replace spaces with underscores - if (name[i] == ' ') { + // Replace spaces (and other non-alphanumerics) with underscores + if (!Common::isAlnum(name[i])) { name.setChar('_', (uint32)i); } } -- cgit v1.2.3 From 3bcbd1881c9a22a594707726154c568d187e313b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:27:07 +0200 Subject: WINTERMUTE: Avoid opening files when checking hasFile() --- engines/wintermute/ad/ad_game.cpp | 10 ++----- engines/wintermute/ad/ad_sentence.cpp | 7 ++--- engines/wintermute/base/base_file_manager.cpp | 13 +++++---- engines/wintermute/base/file/base_disk_file.cpp | 37 +++++++++++++++++++++++++ engines/wintermute/base/file/base_disk_file.h | 1 + engines/wintermute/base/file/base_resources.cpp | 19 ++++++++++--- engines/wintermute/base/file/base_resources.h | 3 +- 7 files changed, 66 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index e10ec1bf6d..aa350b0e4c 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -1904,18 +1904,12 @@ char *AdGame::findSpeechFile(char *stringID) { for (int i = 0; i < _speechDirs.getSize(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - Common::SeekableReadStream *file = _fileManager->openFile(ret); // TODO: Replace with hasFile - if (file) { - _fileManager->closeFile(file); + if (_fileManager->hasFile(ret)) return ret; - } sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - file = _fileManager->openFile(ret); - if (file) { - _fileManager->closeFile(file); + if (_fileManager->hasFile(ret)) return ret; - } } delete [] ret; return NULL; diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index ba59f57451..ad3a291e16 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -251,11 +251,8 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str()); - if (file) { - _gameRef->_fileManager->closeFile(file); - } else return STATUS_OK; // no talk def file found - + if (!_gameRef->_fileManager->hasFile(talkDefFileName)) + return STATUS_OK; // no talk def file found _talkDef = new AdTalkDef(_gameRef); if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 4dcc1c6948..f651835fe4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -582,12 +582,13 @@ BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) } bool BaseFileManager::hasFile(const Common::String &filename) { - //TODO: Do this in a much simpler fashion - Common::SeekableReadStream *stream = openFile(filename, true, false); - if (!stream) { - return false; - } - delete stream; + if (diskFileExists(filename)) + return true; + if (getPackageEntry(filename)) + return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. + if (BaseResources::hasFile(filename)) + return true; + return false; return true; } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index d1a8f02fa5..c20fd9f342 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -48,6 +48,43 @@ void correctSlashes(char *fileName) { } } +bool diskFileExists(const Common::String& filename) { + Common::SeekableReadStream *file = NULL; + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + return true; + } + } + // The filename can be an explicit path, thus we need to chop it up, expecting the path the game + // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + if (filename.contains(':')) + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + if (filename.contains('\\')) { + Common::StringTokenizer path(filename, "\\"); + + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSNode curNode = gameDataDir; + while (!path.empty()) { + Common::String pathPart = path.nextToken(); + Common::FSNode nextNode(curNode.getChild(pathPart)); + if (nextNode.exists() && nextNode.isReadable()) { + curNode = nextNode; + } + if (!curNode.isDirectory()) { + if (curNode.exists() && curNode.isReadable()) + return true; + else + return false; + } + } + } + return false; +} + Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index e688a12b50..b0ba32cb84 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -36,6 +36,7 @@ class SeekableReadStream; namespace WinterMute { Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); +bool diskFileExists(const Common::String& filename); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 9b1c9fee04..f7aaf6393a 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2806,15 +2806,26 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; -Common::SeekableReadStream *BaseResources::getFile(const Common::String &fileName) { - if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { +Common::SeekableReadStream *BaseResources::getFile(const Common::String &filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); } return NULL; } +bool BaseResources::hasFile(const Common::String& filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { + return true; + } + return false; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 6316cecd15..2959f9882f 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -36,7 +36,8 @@ namespace WinterMute { class BaseResources { public: - static Common::SeekableReadStream *getFile(const Common::String &fileName); + static Common::SeekableReadStream *getFile(const Common::String &filename); + static bool hasFile(const Common::String& filename); }; } // end of namespace WinterMute -- cgit v1.2.3 From 4c3421288d2d74396579f35b25a7b78e14afa7f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:29:07 +0200 Subject: WINTERMUTE: Add an audio-debug-channel and reduce the use of warning() --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/sound/base_sound_buffer.cpp | 13 ++++--------- engines/wintermute/wintermute.cpp | 1 + engines/wintermute/wintermute.h | 3 ++- 4 files changed, 8 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f651835fe4..0a59a3b134 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -472,7 +472,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const ((byte *)name)[k] ^= 'D'; } } - + debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory name[nameLength - 1] = '\0'; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index b8c19c2985..e1dba2120d 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/base/sound/base_sound_buffer.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" #include "audio/audiostream.h" #include "audio/mixer.h" #include "audio/decoders/vorbis.h" @@ -95,13 +96,7 @@ void BaseSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 Block ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif + debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = _gameRef->_fileManager->openFile(filename, true, false); @@ -123,11 +118,11 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _file = new Common::SeekableSubReadStream(_file, 0, waveSize); _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); } else { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); } } } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); } if (!_stream) { return STATUS_FAILED; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 9040de66e6..520889fd11 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -73,6 +73,7 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) DebugMan.addDebugChannel(kWinterMuteDebugSaveGame, "savegame", "Savegames"); DebugMan.addDebugChannel(kWinterMuteDebugFont, "font", "Text-drawing-related messages"); DebugMan.addDebugChannel(kWinterMuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); + DebugMan.addDebugChannel(kWinterMuteDebugAudio, "audio", "audio-playback-related issues"); // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index e850a72196..5d5edb66de 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -38,7 +38,8 @@ enum { kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine kWinterMuteDebugSaveGame = 1 << 1, kWinterMuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) - kWinterMuteDebugFileAccess = 1 << 3 // the current limitation is 32 debug channels (1 << 31 is the last one) + kWinterMuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) + kWinterMuteDebugAudio = 1 << 4 }; class WinterMuteEngine : public Engine { -- cgit v1.2.3 From 803c4215534bdbdc545c8aa32418444e27d607f5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:30:24 +0200 Subject: WINTERMUTE: Fix a few issues in PathUtil, mainly getFileNameWithoutExtension was off by one --- engines/wintermute/utils/path_util.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 6b6b2d6b96..6812d824df 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -37,10 +37,11 @@ namespace WinterMute { AnsiString PathUtil::unifySeparators(const AnsiString &path) { AnsiString newPath = path; - AnsiString::iterator it; - for (it = newPath.begin(); it != newPath.end(); it++) { - if (*it == '\\') *it = '/'; + for (uint32 i = 0; i < newPath.size(); i++) { + if (newPath[i] == '\\') + newPath.setChar('/', i); } + return newPath; } @@ -78,7 +79,7 @@ AnsiString PathUtil::getFileName(const AnsiString &path) { AnsiString newPath = unifySeparators(path); //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. - Common::String lastPart = Common::lastPathComponent(path, '/'); + Common::String lastPart = Common::lastPathComponent(newPath, '/'); if (lastPart[lastPart.size() - 1 ] != '/') return lastPart; else @@ -93,9 +94,12 @@ AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! // TODO: Prettify this. - Common::String extension = Common::lastPathComponent(path, '.'); - Common::String filename = Common::String(path.c_str(), path.size() - extension.size()); - return filename; + AnsiString extension = Common::lastPathComponent(fileName, '.'); + for (int i = 0; i < extension.size() + 1; i++) { + fileName.deleteLastChar(); + } +// Common::String filename = Common::String(fileName.c_str(), fileName.size() - extension.size() + 1); + return fileName; //if (pos == AnsiString::npos) return fileName; //else return fileName.substr(0, pos); } -- cgit v1.2.3 From 30ada3c13f63ef35ccdd21ca76fb45aa9fb1dc3c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:31:02 +0200 Subject: WINTERMUTE: Check for failure when decoding images. --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 8 ++++++-- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 0de31349fd..772f7c35ba 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -116,9 +116,11 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed return STATUS_OK; } -void BaseSurfaceOSystem::finishLoad() { +bool BaseSurfaceOSystem::finishLoad() { BaseImage *image = new BaseImage(_gameRef); - image->loadFile(_filename); + if (!image->loadFile(_filename)) { + return false; + } _width = image->getSurface()->w; _height = image->getSurface()->h; @@ -188,6 +190,8 @@ void BaseSurfaceOSystem::finishLoad() { delete image; _loaded = true; + + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index bece031fe7..3a8d64703f 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -85,7 +85,7 @@ public: private: Graphics::Surface *_surface; bool _loaded; - void finishLoad(); + bool finishLoad(); bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); -- cgit v1.2.3 From f6a5a2a0d57d2e0829aa93ac0b30d3c0e1bf8838 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:55:54 +0200 Subject: WINTERMUTE: Wrap away base_script_holder's _filename field in getters/setters, avoiding direct writes. --- engines/wintermute/ad/ad_actor.cpp | 3 +- engines/wintermute/ad/ad_entity.cpp | 15 ++-- engines/wintermute/ad/ad_game.cpp | 5 +- engines/wintermute/ad/ad_inventory_box.cpp | 3 +- engines/wintermute/ad/ad_item.cpp | 15 ++-- engines/wintermute/ad/ad_layer.cpp | 3 +- engines/wintermute/ad/ad_node_state.cpp | 10 +-- engines/wintermute/ad/ad_object.cpp | 2 +- engines/wintermute/ad/ad_region.cpp | 3 +- engines/wintermute/ad/ad_response_box.cpp | 15 ++-- engines/wintermute/ad/ad_rot_level.cpp | 3 +- engines/wintermute/ad/ad_scale_level.cpp | 3 +- engines/wintermute/ad/ad_scene.cpp | 12 +-- engines/wintermute/ad/ad_sprite_set.cpp | 16 ++-- engines/wintermute/ad/ad_talk_def.cpp | 2 +- engines/wintermute/ad/ad_talk_holder.cpp | 16 ++-- engines/wintermute/ad/ad_waypoint_group.cpp | 3 +- engines/wintermute/base/base_game.cpp | 14 ++-- engines/wintermute/base/base_object.cpp | 4 +- engines/wintermute/base/base_region.cpp | 3 +- engines/wintermute/base/base_script_holder.cpp | 8 +- engines/wintermute/base/base_script_holder.h | 4 +- engines/wintermute/base/base_sprite.cpp | 6 +- engines/wintermute/base/font/base_font_bitmap.cpp | 3 +- engines/wintermute/base/font/base_font_storage.cpp | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 3 +- .../wintermute/base/particles/part_particle.cpp | 5 +- engines/wintermute/ui/ui_button.cpp | 89 +++++++++++----------- engines/wintermute/ui/ui_edit.cpp | 23 +++--- engines/wintermute/ui/ui_entity.cpp | 7 +- engines/wintermute/ui/ui_object.cpp | 4 +- engines/wintermute/ui/ui_text.cpp | 19 +++-- engines/wintermute/ui/ui_tiled_image.cpp | 3 +- engines/wintermute/ui/ui_window.cpp | 35 +++++---- 34 files changed, 171 insertions(+), 192 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 1da28cd93d..c6a9b59420 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -132,8 +132,7 @@ bool AdActor::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 06a551b252..df469b4321 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -93,8 +93,7 @@ bool AdEntity::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); @@ -914,8 +913,8 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->_filename) - buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->_filename); + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->getFilename()) + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename()); if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); @@ -936,11 +935,11 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { if (_relativeScale != 0) buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); AdTalkHolder::saveAsText(buffer, indent + 2); diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index aa350b0e4c..8010a37864 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -251,7 +251,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { _scene->applyEvent("SceneShutdown", true); setPrevSceneName(_scene->_name); - setPrevSceneFilename(_scene->_filename); + setPrevSceneFilename(_scene->getFilename()); if (!_tempDisableSaveState) _scene->saveState(); _tempDisableSaveState = false; @@ -1112,8 +1112,7 @@ bool AdGame::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index f835dd22d4..d2bdcdde34 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -164,8 +164,7 @@ bool AdInventoryBox::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 781b924513..0b85fdb9b3 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -93,8 +93,7 @@ bool AdItem::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); @@ -462,8 +461,8 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetHoverSprite") == 0) { stack->correctParams(0); - if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL(); - else stack->pushString(_spriteHover->_filename); + if (!_spriteHover || !_spriteHover->getFilename()) stack->pushNULL(); + else stack->pushString(_spriteHover->getFilename()); return STATUS_OK; } @@ -504,8 +503,8 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetNormalCursor") == 0) { stack->correctParams(0); - if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL(); - else stack->pushString(_cursorNormal->_filename); + if (!_cursorNormal || !_cursorNormal->getFilename()) stack->pushNULL(); + else stack->pushString(_cursorNormal->getFilename()); return STATUS_OK; } @@ -547,8 +546,8 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetHoverCursor") == 0) { stack->correctParams(0); - if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL(); - else stack->pushString(_cursorHover->_filename); + if (!_cursorHover || !_cursorHover->getFilename()) stack->pushNULL(); + else stack->pushString(_cursorHover->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 2cd7ac26ce..e59b5cde18 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -70,8 +70,7 @@ bool AdLayer::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 12bd275614..fca2600884 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -139,11 +139,11 @@ bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool s for (int i = 0; i < 7; i++) { if (entity->_caption[i]) setCaption(entity->_caption[i], i); } - if (!entity->_region && entity->_sprite && entity->_sprite->_filename) { - if (includingSprites) setFilename(entity->_sprite->_filename); + if (!entity->_region && entity->_sprite && entity->_sprite->getFilename()) { + if (includingSprites) setFilename(entity->_sprite->getFilename()); else setFilename(""); } - if (entity->_cursor && entity->_cursor->_filename) setCursor(entity->_cursor->_filename); + if (entity->_cursor && entity->_cursor->getFilename()) setCursor(entity->_cursor->getFilename()); _alphaColor = entity->_alphaColor; _active = entity->_active; } else { @@ -151,11 +151,11 @@ bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool s if (_caption[i]) entity->setCaption(_caption[i], i); } if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { - if (!entity->_sprite || !entity->_sprite->_filename || scumm_stricmp(entity->_sprite->_filename, _filename) != 0) + if (!entity->_sprite || !entity->_sprite->getFilename() || scumm_stricmp(entity->_sprite->getFilename(), _filename) != 0) entity->setSprite(_filename); } if (_cursor) { - if (!entity->_cursor || !entity->_cursor->_filename || scumm_stricmp(entity->_cursor->_filename, _cursor) != 0) + if (!entity->_cursor || !entity->_cursor->getFilename() || scumm_stricmp(entity->_cursor->getFilename(), _cursor) != 0) entity->setCursor(_cursor); } diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 39593c482c..bac39f5ea6 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -339,7 +339,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFont") == 0) { stack->correctParams(0); - if (_font && _font->_filename) stack->pushString(_font->_filename); + if (_font && _font->getFilename()) stack->pushString(_font->getFilename()); else stack->pushNULL(); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 1bd6051bda..bac02f5dd6 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -63,8 +63,7 @@ bool AdRegion::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 5b7e441abc..212802ef3a 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -196,8 +196,7 @@ bool AdResponseBox::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); @@ -341,13 +340,13 @@ bool AdResponseBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + if (_fontHover && _fontHover->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->getFilename()); - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index e758eaa1f6..b9949d9f9b 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -62,8 +62,7 @@ bool AdRotLevel::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 65e0cc4663..539e9a8bb7 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -60,8 +60,7 @@ bool AdScaleLevel::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 104fe6dd4d..958bf64ae5 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -509,15 +509,11 @@ bool AdScene::loadFile(const char *filename) { bool ret; - delete[] _filename; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - + setFilename(filename); delete [] buffer; @@ -843,7 +839,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { return STATUS_FAILED; } - if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename); + if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", getFilename()); sortScaleLevels(); @@ -2480,7 +2476,7 @@ bool AdScene::persistState(bool saving) { if (!_persistentState) return STATUS_OK; AdGame *adGame = (AdGame *)_gameRef; - AdSceneState *state = adGame->getSceneState(_filename, saving); + AdSceneState *state = adGame->getSceneState(getFilename(), saving); if (!state) return STATUS_OK; AdNodeState *nodeState; diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index b594bd0467..34ea53481d 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -265,28 +265,28 @@ bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { if (_sprites[i]) { switch (i) { case DI_UP: - buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_UPRIGHT: - buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_RIGHT: - buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "RIGHT=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_DOWNRIGHT: - buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN_RIGHT=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_DOWN: - buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_DOWNLEFT: - buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "DOWN_LEFT=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_LEFT: - buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "LEFT=\"%s\"\n", _sprites[i]->getFilename()); break; case DI_UPLEFT: - buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->_filename); + buffer->putTextIndent(indent + 2, "UP_LEFT=\"%s\"\n", _sprites[i]->getFilename()); break; } } diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 979e8b2698..2756b69467 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -78,7 +78,7 @@ bool AdTalkDef::loadFile(const char *filename) { bool ret; - BaseUtils::setString(&_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index bd48ac601c..17f7171cc3 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -159,8 +159,8 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS else if (strcmp(name, "GetSprite") == 0) { stack->correctParams(0); - if (!_sprite || !_sprite->_filename) stack->pushNULL(); - else stack->pushString(_sprite->_filename); + if (!_sprite || !_sprite->getFilename()) stack->pushNULL(); + else stack->pushString(_sprite->getFilename()); return STATUS_OK; } @@ -210,7 +210,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS if (ex) { for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_filename, filename) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->getFilename(), filename) == 0) { if (_currentSprite == _talkSpritesEx[i]) setCurrent = true; if (_tempSprite2 == _talkSpritesEx[i]) @@ -222,7 +222,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } } else { for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_filename, filename) == 0) { + if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { if (_currentSprite == _talkSprites[i]) setCurrent = true; if (_tempSprite2 == _talkSprites[i]) @@ -339,13 +339,13 @@ const char *AdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->_filename); + if (_talkSprites[i]->getFilename()) + buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->getFilename()); } for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i]->_filename) - buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->_filename); + if (_talkSpritesEx[i]->getFilename()) + buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->getFilename()); } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 25e5345ee7..4a8ab966e8 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -73,8 +73,7 @@ bool AdWaypointGroup::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 0adc938895..da2c01a17f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -396,9 +396,8 @@ bool BaseGame::cleanup() { _viewportSP = -1; delete[] _name; - delete[] _filename; _name = NULL; - _filename = NULL; + setFilename(NULL); for (int i = 0; i < 7; i++) { delete[] _caption[i]; _caption[i] = NULL; @@ -679,8 +678,7 @@ bool BaseGame::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); @@ -1662,8 +1660,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursor") == 0) { stack->correctParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); - else stack->pushString(_activeCursor->_filename); + if (!_activeCursor || !_activeCursor->getFilename()) stack->pushNULL(); + else stack->pushString(_activeCursor->getFilename()); return STATUS_OK; } @@ -1938,8 +1936,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursor") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->_filename); + if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 4ab121ded9..2002f01dc8 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -227,8 +227,8 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { stack->correctParams(0); - if (!_cursor || !_cursor->_filename) stack->pushNULL(); - else stack->pushString(_cursor->_filename); + if (!_cursor || !_cursor->getFilename()) stack->pushNULL(); + else stack->pushString(_cursor->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index e336b92789..95fa163550 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -104,8 +104,7 @@ bool BaseRegion::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index f803a9191f..4235353c1e 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -72,8 +72,12 @@ bool BaseScriptHolder::cleanup() { ////////////////////////////////////////////////////////////////////// void BaseScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) delete [] _filename; - + if (_filename != NULL) { + delete [] _filename; + _filename = NULL; + } + if (filename == NULL) + return; _filename = new char [strlen(filename) + 1]; if (_filename != NULL) strcpy(_filename, filename); } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 52711572c1..ef1c389dcb 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -52,8 +52,8 @@ public: virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); + const char *getFilename() { return _filename; } bool parseProperty(byte *buffer, bool complete = true); - char *_filename; bool _freezable; bool _ready; @@ -65,6 +65,8 @@ public: virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject +private: + char *_filename; public: virtual bool sendEvent(const char *eventName); }; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 046a40bacf..f44e3d4024 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -66,7 +66,7 @@ void BaseSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; - _filename = NULL; + setFilename(NULL); _finished = false; _changed = false; _paused = false; @@ -160,9 +160,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c } } - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - + setFilename(filename); return ret; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index cb3468c4f3..9a3caf2669 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -252,8 +252,7 @@ bool BaseFontBitmap::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 220a16e14f..9adc62c829 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -53,7 +53,7 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); delete _fonts[i]; } _fonts.removeAll(); @@ -74,7 +74,7 @@ BaseFont *BaseFontStorage::addFont(const char *filename) { if (!filename) return NULL; for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { _fonts[i]->_refCount++; return _fonts[i]; } diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index bcf8621a40..9782d1d7db 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -416,8 +416,7 @@ bool BaseFontTT::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 93b9f3659d..e36cec6f47 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -73,7 +73,7 @@ PartParticle::~PartParticle(void) { ////////////////////////////////////////////////////////////////////////// bool PartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename, _sprite->getFilename()) == 0) { _sprite->reset(); return STATUS_OK; } @@ -240,7 +240,8 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_fadeStartAlpha)); if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); + const char *filename = _sprite->getFilename(); + persistMgr->transfer(TMEMBER(filename)); } else { char *filename; persistMgr->transfer(TMEMBER(filename)); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index af7e3262db..bb7d4d530d 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -104,8 +104,7 @@ bool UIButton::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); @@ -448,41 +447,41 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backHover && _backHover->_filename) - buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->_filename); - if (_backPress && _backPress->_filename) - buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->_filename); - if (_backDisable && _backDisable->_filename) - buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->_filename); - if (_backFocus && _backFocus->_filename) - buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->_filename); - - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageHover && _imageHover->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->_filename); - if (_imagePress && _imagePress->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->_filename); - if (_imageDisable && _imageDisable->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->_filename); - if (_imageFocus && _imageFocus->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->_filename); - - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontHover && _fontHover->_filename) - buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->_filename); - if (_fontPress && _fontPress->_filename) - buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->_filename); - if (_fontDisable && _fontDisable->_filename) - buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->_filename); - if (_fontFocus && _fontFocus->_filename) - buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->_filename); - - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_back && _back->getFilename()) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + if (_backHover && _backHover->getFilename()) + buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->getFilename()); + if (_backPress && _backPress->getFilename()) + buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->getFilename()); + if (_backDisable && _backDisable->getFilename()) + buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->getFilename()); + if (_backFocus && _backFocus->getFilename()) + buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->getFilename()); + + if (_image && _image->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + if (_imageHover && _imageHover->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->getFilename()); + if (_imagePress && _imagePress->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->getFilename()); + if (_imageDisable && _imageDisable->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->getFilename()); + if (_imageFocus && _imageFocus->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->getFilename()); + + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + if (_fontHover && _fontHover->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->getFilename()); + if (_fontPress && _fontPress->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->getFilename()); + if (_fontDisable && _fontDisable->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->getFilename()); + if (_fontFocus && _fontFocus->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->getFilename()); + + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); buffer->putTextIndent(indent + 2, "\n"); @@ -762,8 +761,8 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDisabledImage") == 0) { stack->correctParams(0); - if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL(); - else stack->pushString(_imageDisable->_filename); + if (!_imageDisable || !_imageDisable->getFilename()) stack->pushNULL(); + else stack->pushString(_imageDisable->getFilename()); return STATUS_OK; } @@ -803,8 +802,8 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverImage") == 0) { stack->correctParams(0); - if (!_imageHover || !_imageHover->_filename) stack->pushNULL(); - else stack->pushString(_imageHover->_filename); + if (!_imageHover || !_imageHover->getFilename()) stack->pushNULL(); + else stack->pushString(_imageHover->getFilename()); return STATUS_OK; } @@ -843,8 +842,8 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPressedImage") == 0) { stack->correctParams(0); - if (!_imagePress || !_imagePress->_filename) stack->pushNULL(); - else stack->pushString(_imagePress->_filename); + if (!_imagePress || !_imagePress->getFilename()) stack->pushNULL(); + else stack->pushString(_imagePress->getFilename()); return STATUS_OK; } @@ -883,8 +882,8 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFocusedImage") == 0) { stack->correctParams(0); - if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL(); - else stack->pushString(_imageFocus->_filename); + if (!_imageFocus || !_imageFocus->getFilename()) stack->pushNULL(); + else stack->pushString(_imageFocus->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index d9c6c6586a..b2e7b29284 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -100,8 +100,7 @@ bool UIEdit::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); @@ -308,19 +307,19 @@ bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_back && _back->getFilename()) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_image && _image->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontSelected && _fontSelected->_filename) - buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->_filename); + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + if (_fontSelected && _fontSelected->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->getFilename()); - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); buffer->putTextIndent(indent + 2, "\n"); diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index acbcd2430f..a67ba6b29f 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -64,8 +64,7 @@ bool UIEntity::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); @@ -188,8 +187,8 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - if (_entity && _entity->_filename) - buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->_filename); + if (_entity && _entity->getFilename()) + buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->getFilename()); buffer->putTextIndent(indent + 2, "\n"); diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 20fd6c363f..416ad1e114 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -187,8 +187,8 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetImage") == 0) { stack->correctParams(0); - if (!_image || !_image->_filename) stack->pushNULL(); - else stack->pushString(_image->_filename); + if (!_image || !_image->getFilename()) stack->pushNULL(); + else stack->pushString(_image->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index fdf7f6287f..62ef968552 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -104,8 +104,7 @@ bool UIText::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); @@ -302,17 +301,17 @@ bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); + if (_back && _back->getFilename()) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); + if (_image && _image->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); if (_text) buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index fec30f46e9..6ee27bb411 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -128,8 +128,7 @@ bool UITiledImage::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 0fedfdc87a..5a1caa9fd4 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -216,8 +216,7 @@ bool UIWindow::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); @@ -584,23 +583,23 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->_filename) - buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->_filename); - if (_backInactive && _backInactive->_filename) - buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->_filename); + if (_back && _back->getFilename()) + buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + if (_backInactive && _backInactive->getFilename()) + buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->getFilename()); - if (_image && _image->_filename) - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_filename); - if (_imageInactive && _imageInactive->_filename) - buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->_filename); + if (_image && _image->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + if (_imageInactive && _imageInactive->getFilename()) + buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->getFilename()); - if (_font && _font->_filename) - buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->_filename); - if (_fontInactive && _fontInactive->_filename) - buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->_filename); + if (_font && _font->getFilename()) + buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + if (_fontInactive && _fontInactive->getFilename()) + buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->getFilename()); - if (_cursor && _cursor->_filename) - buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->_filename); + if (_cursor && _cursor->getFilename()) + buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); buffer->putTextIndent(indent + 2, "\n"); @@ -758,8 +757,8 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInactiveImage") == 0) { stack->correctParams(0); - if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL(); - else stack->pushString(_imageInactive->_filename); + if (!_imageInactive || !_imageInactive->getFilename()) stack->pushNULL(); + else stack->pushString(_imageInactive->getFilename()); return STATUS_OK; } -- cgit v1.2.3 From 8c378f794e0398e646eb3598c9e27c09b4d68dfc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:17:32 +0200 Subject: WINTERMUTE: Wrap _name in base_named_object in getters/setters. --- engines/wintermute/ad/ad_actor.cpp | 12 ++++++------ engines/wintermute/ad/ad_entity.cpp | 4 ++-- engines/wintermute/ad/ad_game.cpp | 16 ++++++++-------- engines/wintermute/ad/ad_inventory.cpp | 6 +++--- engines/wintermute/ad/ad_inventory_box.cpp | 8 ++++---- engines/wintermute/ad/ad_item.cpp | 2 +- engines/wintermute/ad/ad_layer.cpp | 6 +++--- engines/wintermute/ad/ad_object.cpp | 16 ++++++++-------- engines/wintermute/ad/ad_region.cpp | 4 ++-- engines/wintermute/ad/ad_response_box.cpp | 6 +++--- engines/wintermute/ad/ad_scene.cpp | 22 +++++++++++----------- engines/wintermute/ad/ad_scene_state.cpp | 2 +- engines/wintermute/ad/ad_scene_state.h | 2 +- engines/wintermute/ad/ad_sprite_set.cpp | 2 +- engines/wintermute/ad/ad_talk_holder.cpp | 6 +++--- engines/wintermute/ad/ad_waypoint_group.cpp | 2 +- engines/wintermute/base/base_game.cpp | 9 ++++----- engines/wintermute/base/base_named_object.cpp | 4 ++++ engines/wintermute/base/base_named_object.h | 3 ++- .../wintermute/base/base_persistence_manager.cpp | 4 ++-- engines/wintermute/base/base_region.cpp | 4 ++-- engines/wintermute/base/base_script_holder.cpp | 17 ++++++++++++----- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/particles/part_force.cpp | 9 ++++++++- engines/wintermute/ui/ui_button.cpp | 4 ++-- engines/wintermute/ui/ui_edit.cpp | 6 +++--- engines/wintermute/ui/ui_entity.cpp | 2 +- engines/wintermute/ui/ui_object.cpp | 4 ++-- engines/wintermute/ui/ui_text.cpp | 2 +- engines/wintermute/ui/ui_window.cpp | 10 +++++----- 31 files changed, 109 insertions(+), 91 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index c6a9b59420..68059072d7 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -940,7 +940,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool Found = false; for (int i = 0; i < _anims.getSize(); i++) { - if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) { + if (scumm_stricmp(_anims[i]->getName(), AnimName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; @@ -1109,7 +1109,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { if (_animSprite) { bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -1131,7 +1131,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { if (!ret) { BaseArray TalkAnims; for (int i = 0; i < _anims.getSize(); i++) { - if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0) + if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) TalkAnims.add(_anims[i]); } @@ -1156,7 +1156,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { if (stance != NULL) { // search special stances for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { ret = _talkSpritesEx[i]->getSprite(_dir); break; } @@ -1164,7 +1164,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { if (ret == NULL) { // search generic stances for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { ret = _talkSprites[i]->getSprite(_dir); break; } @@ -1254,7 +1254,7 @@ int AdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.getSize(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->_name) == 0) + if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) return _anims[i]; } return NULL; diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index df469b4321..2a281d0fcb 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -462,7 +462,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { } if (_region && _sprite) { - _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name); + _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", getName()); } updatePosition(); @@ -878,7 +878,7 @@ const char *AdEntity::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); if (_subtype == ENTITY_SOUND) buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 8010a37864..42a453d533 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -250,7 +250,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { } else { _scene->applyEvent("SceneShutdown", true); - setPrevSceneName(_scene->_name); + setPrevSceneName(_scene->getName()); setPrevSceneFilename(_scene->getFilename()); if (!_tempDisableSaveState) _scene->saveState(); @@ -657,7 +657,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (val->getNative() == Inv->_takenItems[j]) { stack->pushBool(true); return STATUS_OK; - } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) { + } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->getName()) == 0) { stack->pushBool(true); return STATUS_OK; } @@ -1093,7 +1093,7 @@ bool AdGame::showCursor() { _lastCursor = origLastCursor; } if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name)) + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName())) return drawCursor(_selectedItem->_cursorHover); else return drawCursor(_selectedItem->_cursorNormal); @@ -1414,7 +1414,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { if (item && !DID_FAIL(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (merge) { - AdItem *PrevItem = getItemByName(item->_name); + AdItem *PrevItem = getItemByName(item->getName()); if (PrevItem) deleteItem(PrevItem); } addItem(item); @@ -1767,7 +1767,7 @@ bool AdGame::isItemTaken(char *itemName) { AdInventory *Inv = _inventories[i]; for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) { + if (scumm_stricmp(itemName, Inv->_takenItems[j]->getName()) == 0) { return true; } } @@ -1778,7 +1778,7 @@ bool AdGame::isItemTaken(char *itemName) { ////////////////////////////////////////////////////////////////////////// AdItem *AdGame::getItemByName(const char *name) { for (int i = 0; i < _items.getSize(); i++) { - if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i]; + if (scumm_stricmp(_items[i]->getName(), name) == 0) return _items[i]; } return NULL; } @@ -1831,7 +1831,7 @@ bool AdGame::deleteItem(AdItem *item) { if (!item) return STATUS_FAILED; if (_selectedItem == item) _selectedItem = NULL; - _scene->handleItemAssociations(item->_name, false); + _scene->handleItemAssociations(item->getName(), false); // remove from all inventories for (int i = 0; i < _inventories.getSize(); i++) { @@ -2036,7 +2036,7 @@ bool AdGame::displayDebugInfo() { sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop()); _systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT); - sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???"); + sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->getName()) ? _scene->getName() : "???", _prevSceneName ? _prevSceneName : "???"); _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); } return BaseGame::displayDebugInfo(); diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index fd56eef419..d79d171d02 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -57,12 +57,12 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { int insertIndex = -1; for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { _takenItems.removeAt(i); i--; continue; } - if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1; + if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) insertIndex = i + 1; } @@ -78,7 +78,7 @@ bool AdInventory::removeItem(const char *name) { if (name == NULL) return STATUS_FAILED; for (int i = 0; i < _takenItems.getSize(); i++) { - if (scumm_stricmp(_takenItems[i]->_name, name) == 0) { + if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL; _takenItems.removeAt(i); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index d2bdcdde34..488cee77c8 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -79,12 +79,12 @@ bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) { + if (scumm_stricmp(obj->getName(), "close") == 0) { _visible = false; - } else if (scumm_stricmp(obj->_name, "prev") == 0) { + } else if (scumm_stricmp(obj->getName(), "prev") == 0) { _scrollOffset -= _scrollBy; _scrollOffset = MAX(_scrollOffset, 0); - } else if (scumm_stricmp(obj->_name, "next") == 0) { + } else if (scumm_stricmp(obj->getName(), "next") == 0) { _scrollOffset += _scrollBy; } else return BaseObject::listen(param1, param2); break; @@ -321,7 +321,7 @@ bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "INVENTORY_BOX\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom); diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 0b85fdb9b3..ba116b6569 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -582,7 +582,7 @@ ScValue *AdItem::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index e59b5cde18..80fbc683ef 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -237,8 +237,8 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (val->_type == VAL_INT) node = val->getInt(); else { // get by name for (int i = 0; i < _nodes.getSize(); i++) { - if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) || - (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) { + if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->getName(), val->getString()) == 0) || + (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->getName(), val->getString()) == 0)) { node = i; break; } @@ -478,7 +478,7 @@ const char *AdLayer::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "LAYER {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width); diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index bac39f5ea6..acca57393c 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -156,12 +156,12 @@ bool AdObject::playAnim(const char *filename) { _animSprite = NULL; _animSprite = new BaseSprite(_gameRef, this); if (!_animSprite) { - _gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); return STATUS_FAILED; } bool res = _animSprite->loadFile(filename); if (DID_FAIL(res)) { - _gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename); + _gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); delete _animSprite; _animSprite = NULL; return res; @@ -296,7 +296,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } else if (val->isString()) { const char *regionName = val->getString(); for (i = 0; i < main->_nodes.getSize(); i++) { - if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) { + if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->getName() && scumm_stricmp(main->_nodes[i]->_region->getName(), regionName) == 0) { _stickRegion = main->_nodes[i]->_region; regFound = true; break; @@ -437,7 +437,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); return STATUS_OK; - } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) { + } else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->getName()) == 0) { stack->pushBool(true); return STATUS_OK; } @@ -539,7 +539,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } else { const char *attachmentName = val->getString(); for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); _attachmentsPre.removeAt(i); @@ -547,7 +547,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); _attachmentsPost.removeAt(i); @@ -582,14 +582,14 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } else { const char *attachmentName = val->getString(); for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) { + if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; } } if (!ret) { for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) { + if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; } diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index bac02f5dd6..965f14d8a3 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -252,7 +252,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } @@ -347,7 +347,7 @@ const char *AdRegion::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "REGION {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 212802ef3a..38fbd6f95d 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -486,11 +486,11 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->_name, "prev") == 0) { + if (scumm_stricmp(obj->getName(), "prev") == 0) { _scrollOffset--; - } else if (scumm_stricmp(obj->_name, "next") == 0) { + } else if (scumm_stricmp(obj->getName(), "next") == 0) { _scrollOffset++; - } else if (scumm_stricmp(obj->_name, "response") == 0) { + } else if (scumm_stricmp(obj->getName(), "response") == 0) { if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); handleResponse(_responses[param2]); _waitingScript = NULL; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 958bf64ae5..e76e61af79 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1346,7 +1346,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *LayerName = val->getString(); bool LayerFound = false; for (int i = 0; i < _layers.getSize(); i++) { - if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) { + if (scumm_stricmp(LayerName, _layers[i]->getName()) == 0) { stack->pushNative(_layers[i], true); LayerFound = true; break; @@ -1396,7 +1396,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } else { const char *nodeName = val->getString(); for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) { + if (_objects[i] && _objects[i]->getName() && scumm_stricmp(_objects[i]->getName(), nodeName) == 0) { ret = _objects[i]; break; } @@ -1962,7 +1962,7 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SCENE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); if (_persistentState) @@ -2424,8 +2424,8 @@ BaseObject *AdScene::getNodeByName(const char *name) { AdLayer *layer = _layers[i]; for (int j = 0; j < layer->_nodes.getSize(); j++) { AdSceneNode *node = layer->_nodes[j]; - if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) || - (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) { + if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->getName())) || + (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->getName()))) { switch (node->_type) { case OBJECT_ENTITY: ret = node->_entity; @@ -2443,14 +2443,14 @@ BaseObject *AdScene::getNodeByName(const char *name) { // free entities for (int i = 0; i < _objects.getSize(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) { + if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->getName())) { return _objects[i]; } } // waypoint groups for (int i = 0; i < _waypointGroups.getSize(); i++) { - if (!scumm_stricmp(name, _waypointGroups[i]->_name)) { + if (!scumm_stricmp(name, _waypointGroups[i]->getName())) { return _waypointGroups[i]; } } @@ -2489,7 +2489,7 @@ bool AdScene::persistState(bool saving) { switch (node->_type) { case OBJECT_ENTITY: if (!node->_entity->_saveState) continue; - nodeState = state->getNodeState(node->_entity->_name, saving); + nodeState = state->getNodeState(node->_entity->getName(), saving); if (nodeState) { nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); //if(Saving) NodeState->_active = node->_entity->_active; @@ -2498,7 +2498,7 @@ bool AdScene::persistState(bool saving) { break; case OBJECT_REGION: if (!node->_region->_saveState) continue; - nodeState = state->getNodeState(node->_region->_name, saving); + nodeState = state->getNodeState(node->_region->getName(), saving); if (nodeState) { if (saving) nodeState->_active = node->_region->_active; else node->_region->_active = nodeState->_active; @@ -2515,7 +2515,7 @@ bool AdScene::persistState(bool saving) { for (int i = 0; i < _objects.getSize(); i++) { if (!_objects[i]->_saveState) continue; if (_objects[i]->_type == OBJECT_ENTITY) { - nodeState = state->getNodeState(_objects[i]->_name, saving); + nodeState = state->getNodeState(_objects[i]->getName(), saving); if (nodeState) { nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); //if(Saving) NodeState->_active = _objects[i]->_active; @@ -2526,7 +2526,7 @@ bool AdScene::persistState(bool saving) { // waypoint groups for (int i = 0; i < _waypointGroups.getSize(); i++) { - nodeState = state->getNodeState(_waypointGroups[i]->_name, saving); + nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving); if (nodeState) { if (saving) nodeState->_active = _waypointGroups[i]->_active; else _waypointGroups[i]->_active = nodeState->_active; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index da7b417470..173c1ef57b 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -71,7 +71,7 @@ void AdSceneState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -AdNodeState *AdSceneState::getNodeState(char *name, bool saving) { +AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { for (int i = 0; i < _nodeStates.getSize(); i++) { if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; } diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h index 7231ba52db..469f985639 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -37,7 +37,7 @@ namespace WinterMute { class AdNodeState; class AdSceneState : public BaseClass { public: - AdNodeState *getNodeState(char *name, bool saving); + AdNodeState *getNodeState(const char *name, bool saving); void setFilename(const char *filename); DECLARE_PERSISTENT(AdSceneState, BaseClass) AdSceneState(BaseGame *inGame); diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 34ea53481d..4840951ab2 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -260,7 +260,7 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) { ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITESET {\n"); - if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + if (getName()) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); for (int i = 0; i < NUM_DIRECTIONS; i++) { if (_sprites[i]) { switch (i) { diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 17f7171cc3..de19004584 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -75,7 +75,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { if (_animSprite) { bool res = _animSprite->loadFile(_forcedTalkAnimName); if (DID_FAIL(res)) { - _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName); + _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; } else return _animSprite; @@ -86,7 +86,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { if (stance != NULL) { // search special talk stances for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) { + if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { ret = _talkSpritesEx[i]; break; } @@ -94,7 +94,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { if (ret == NULL) { // serach generic talk stances for (int i = 0; i < _talkSprites.getSize(); i++) { - if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) { + if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { ret = _talkSprites[i]; break; } diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 4a8ab966e8..28ce2967dd 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -165,7 +165,7 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WAYPOINTS {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index da2c01a17f..8ef45e4106 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -395,8 +395,7 @@ bool BaseGame::cleanup() { _viewportStack.removeAll(); _viewportSP = -1; - delete[] _name; - _name = NULL; + setName(NULL); setFilename(NULL); for (int i = 0; i < 7; i++) { delete[] _caption[i]; @@ -1780,7 +1779,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int fileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum); if (!Common::File::exists(filename)) break; fileNum++; @@ -2160,7 +2159,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -4346,7 +4345,7 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Timer: %d", _timer); _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 97b9f53353..ad95d83211 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -57,6 +57,10 @@ BaseNamedObject::~BaseNamedObject(void) { ////////////////////////////////////////////////////////////////////// void BaseNamedObject::setName(const char *name) { delete[] _name; + _name = NULL; + + if (name == NULL) + return; _name = new char [strlen(name) + 1]; if (_name != NULL) strcpy(_name, name); diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index f7b496ead8..32e4d561d7 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -35,13 +35,14 @@ namespace WinterMute { class BaseNamedObject : public BaseClass { + char *_name; public: BaseNamedObject(BaseGame *inGame); BaseNamedObject(); virtual ~BaseNamedObject(void); BaseNamedObject(TDynamicConstructor, TDynamicConstructor); - char *_name; + const char *getName() { return _name; } void setName(const char *name); }; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 18dc8ed11c..610229644c 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -212,7 +212,7 @@ bool BasePersistenceManager::initSave(const char *desc) { // new in ver 2 putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->_name); + putString(_gameRef->getName()); // thumbnail data size bool thumbnailOK = false; @@ -314,7 +314,7 @@ bool BasePersistenceManager::initLoad(const char *filename) { } _saving = false; - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 95fa163550..d654f69b9c 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -324,7 +324,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } @@ -381,7 +381,7 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 4235353c1e..c4d8b9b5c2 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -227,7 +227,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } @@ -272,7 +272,14 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_name)); + if (persistMgr->_saving) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + const char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + } _scripts.persist(persistMgr); return STATUS_OK; @@ -284,7 +291,7 @@ bool BaseScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); return STATUS_OK; } } @@ -456,9 +463,9 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); - if (_name && strcmp(_name, "") != 0) { + if (getName() && strcmp(getName(), "") != 0) { strcat(buf, " Name: "); - strcat(buf, _name); + strcat(buf, getName()); } if (_filename) { strcat(buf, " File: "); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index f44e3d4024..7b3e104d84 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -428,7 +428,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 54e612ff42..76fe3c79de 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -367,7 +367,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->getName()) == 0) { force = _forces[i]; break; } @@ -402,7 +402,7 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->getName()) == 0) { delete _forces[i]; _forces.removeAt(i); return STATUS_OK; diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index ba60e8b41c..7311ea21f6 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -48,7 +48,14 @@ PartForce::~PartForce(void) { ////////////////////////////////////////////////////////////////////////// bool PartForce::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); + if (persistMgr->_saving) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + const char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + } persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); persistMgr->transfer(TMEMBER_INT(_type)); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index bb7d4d530d..2c4f6d5e4e 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -442,7 +442,7 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "BUTTON\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "\n"); @@ -656,7 +656,7 @@ bool UIButton::display(int offsetX, int offsetY) { void UIButton::press() { applyEvent("Press"); if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->applyEvent(_name); + if (_parentNotify && _parent) _parent->applyEvent(getName()); _oneTimePress = false; } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index b2e7b29284..8c277e7c87 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -302,7 +302,7 @@ bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "EDIT\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "\n"); @@ -799,7 +799,7 @@ int UIEdit::deleteChars(int start, int end) { delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->applyEvent(_name); + if (_parentNotify && _parent) _parent->applyEvent(getName()); return end - start; } @@ -824,7 +824,7 @@ int UIEdit::insertChars(int pos, byte *chars, int num) { delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->applyEvent(_name); + if (_parentNotify && _parent) _parent->applyEvent(getName()); return num; } diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index a67ba6b29f..0244b104a7 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -177,7 +177,7 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY_CONTAINER\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "\n"); diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 416ad1e114..2b05fea22b 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -240,7 +240,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else { const char *findName = val->getString(); for (i = 0; i < win->_widgets.getSize(); i++) { - if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) { + if (scumm_stricmp(win->_widgets[i]->getName(), findName) == 0) { found = true; break; } @@ -332,7 +332,7 @@ ScValue *UIObject::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 62ef968552..c3548b60ac 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -296,7 +296,7 @@ bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "STATIC\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "\n"); diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 5a1caa9fd4..7e6986508b 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -578,7 +578,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "WINDOW\n"); buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "\n"); @@ -679,7 +679,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable; + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_disable = !Enable; } return STATUS_OK; } @@ -688,7 +688,7 @@ bool UIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible; + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_visible = Visible; } return STATUS_OK; } @@ -710,7 +710,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else stack->pushNative(_widgets[widget], true); } else { for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) { + if (scumm_stricmp(_widgets[i]->getName(), val->getString()) == 0) { stack->pushNative(_widgets[i], true); return STATUS_OK; } @@ -1280,7 +1280,7 @@ bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->_name, "close") == 0) close(); + if (scumm_stricmp(obj->getName(), "close") == 0) close(); else return BaseObject::listen(param1, param2); break; default: -- cgit v1.2.3 From a249b096c03d1cc3437f4e16abe92758f584947d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:26:18 +0200 Subject: WINTERMUTE: Remove Base as superclass for base_package. --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/file/base_package.cpp | 9 +++++---- engines/wintermute/base/file/base_package.h | 13 ++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 0a59a3b134..2fd5521e37 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -439,7 +439,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const } for (uint32 i = 0; i < hdr._numDirs; i++) { - BasePackage *pkg = new BasePackage(_gameRef); + BasePackage *pkg = new BasePackage(this); if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 24f7c23422..a95be25a81 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -40,12 +40,13 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { +BasePackage::BasePackage(BaseFileManager *fileMan)/*: BaseClass(inGame) */{ _file = NULL; _name = NULL; _cd = 0; _priority = 0; _boundToExe = false; + _fileManager = fileMan; } @@ -87,10 +88,10 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); + Common::File *file = _fileManager->openPackage(_name); if (!file) { - _gameRef->_fileManager->requestCD(_cd, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); + _fileManager->requestCD(_cd, _name, ""); + file = _fileManager->openPackage(_name); } return file; } diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 2f305ea049..af180ac7bf 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -29,16 +29,16 @@ #ifndef WINTERMUTE_BPACKAGE_H #define WINTERMUTE_BPACKAGE_H - -#include "engines/wintermute/base/base.h" +#include "common/stream.h" namespace Common { class SeekableReadStream; } namespace WinterMute { - -class BasePackage : public BaseClass { +class BaseFileManager; +class BasePackage { + BaseFileManager *_fileManager; public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); @@ -51,9 +51,8 @@ public: char *_name; int _cd; Common::SeekableReadStream *_file; - BasePackage(BaseGame *inGame); - virtual ~BasePackage(); - + BasePackage(BaseFileManager *fileMan); + ~BasePackage(); }; } // end of namespace WinterMute -- cgit v1.2.3 From 4f1b03eac1be560bbaaa3f379ddd4084693df64f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:36:13 +0200 Subject: WINTERMUTE: Remove Base as superclass for base_file_entry --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/base_file_manager.h | 1 + engines/wintermute/base/file/base_disk_file.cpp | 4 ---- engines/wintermute/base/file/base_disk_file.h | 4 +--- engines/wintermute/base/file/base_file_entry.cpp | 4 ++-- engines/wintermute/base/file/base_file_entry.h | 7 +++---- engines/wintermute/base/file/base_package.cpp | 1 - engines/wintermute/base/file/base_resources.cpp | 1 - 8 files changed, 8 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 2fd5521e37..70818bcb61 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -492,7 +492,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const } _filesIter = _files.find(name); if (_filesIter == _files.end()) { - BaseFileEntry *file = new BaseFileEntry(_gameRef); + BaseFileEntry *file = new BaseFileEntry(); file->_package = pkg; file->_offset = offset; file->_length = length; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 78e6cb737f..7799f5193a 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BFILEMANAGER_H #include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/base.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index c20fd9f342..21f7c7c189 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/wintypes.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/base_file_manager.h" @@ -49,7 +47,6 @@ void correctSlashes(char *fileName) { } bool diskFileExists(const Common::String& filename) { - Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); @@ -86,7 +83,6 @@ bool diskFileExists(const Common::String& filename) { } Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { - char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index b0ba32cb84..13d5c3e03c 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -29,9 +29,7 @@ #ifndef WINTERMUTE_BDISKFILE_H #define WINTERMUTE_BDISKFILE_H -namespace Common { -class SeekableReadStream; -} +#include "common/stream.h" namespace WinterMute { diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index d3e0fee7b0..43527f9fc0 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -25,13 +25,13 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" + #include "engines/wintermute/base/file/base_file_entry.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry(BaseGame *inGame): BaseClass(inGame) { +BaseFileEntry::BaseFileEntry(){ _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 0e0375e42d..086a70e7ed 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -29,14 +29,13 @@ #ifndef WINTERMUTE_BFILEENTRY_H #define WINTERMUTE_BFILEENTRY_H - -#include "engines/wintermute/base/base.h" +#include "common/str.h" namespace WinterMute { class BasePackage; -class BaseFileEntry : public BaseClass { +class BaseFileEntry { public: uint32 _timeDate2; uint32 _timeDate1; @@ -47,7 +46,7 @@ public: uint32 _length; uint32 _offset; BasePackage *_package; - BaseFileEntry(BaseGame *inGame); + BaseFileEntry(); virtual ~BaseFileEntry(); }; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a95be25a81..303d6eea17 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/file.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index f7aaf6393a..73c06271d7 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/file/base_resources.h" #include "common/str.h" #include "common/memstream.h" -- cgit v1.2.3 From 8b6e4fc7527eb5c56755c068d8c5b75951298fe5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 00:14:34 +0200 Subject: WINTERMUTE: Privatize/remove unused/internal functions in BaseFileManager --- engines/wintermute/base/base_file_manager.cpp | 188 +++----------------------- engines/wintermute/base/base_file_manager.h | 49 +++---- 2 files changed, 44 insertions(+), 193 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 70818bcb61..da49f188c1 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -60,8 +60,6 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { - _basePath = NULL; - initPaths(); registerPackages(); } @@ -98,9 +96,6 @@ bool BaseFileManager::cleanup() { delete _packages[i]; _packages.clear(); - delete[] _basePath; - _basePath = NULL; - return STATUS_OK; } @@ -164,54 +159,7 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin file->write(buffer, bufferSize); file->finalize(); delete file; -#if 0 - RestoreCurrentDir(); - - BaseUtils::CreatePath(filename, false); - - FILE *f = fopen(filename, "wb"); - if (!f) { - _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); - return STATUS_FAILED; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif return STATUS_OK; } @@ -230,16 +178,8 @@ bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (path.getName().c_str() == NULL || strlen(path.getName().c_str()) < 1) return STATUS_FAILED; - -// bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - -/* char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return STATUS_FAILED; - - strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\");*/ - //BasePlatform::strlwr(buffer); + if (!path.exists()) + return STATUS_FAILED; switch (type) { case PATH_SINGLE: @@ -257,12 +197,7 @@ bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::reloadPaths() { // delete registered paths -/* for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i];*/ //_singlePaths.clear(); - -/* for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i];*/ _packagePaths.clear(); return initPaths(); @@ -272,8 +207,6 @@ bool BaseFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - restoreCurrentDir(); - AnsiString pathList; int numPaths; @@ -319,29 +252,22 @@ bool BaseFileManager::initPaths() { bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { - warning("Adding %s", (*it).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it).createReadStream())) { addPath(PATH_PACKAGE, (*it)); } } } - warning(" Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + return true; } ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - restoreCurrentDir(); - _gameRef->LOG(0, "Scanning packages..."); debugC(kWinterMuteDebugFileAccess, "Scanning packages"); -/* Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, "*.dcp"); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - registerPackage((*it)->getName().c_str()); - }*/ // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; @@ -355,34 +281,7 @@ bool BaseFileManager::registerPackages() { registerPackage((*fileIt).createReadStream()); } } -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.getSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } -#endif debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); @@ -391,7 +290,6 @@ bool BaseFileManager::registerPackages() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { -// FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { @@ -419,7 +317,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const TPackageHeader hdr; hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; @@ -456,9 +353,9 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const // read file entries - uint32 NumFiles = package->readUint32LE(); + uint32 numFiles = package->readUint32LE(); - for (uint32 j = 0; j < NumFiles; j++) { + for (uint32 j = 0; j < numFiles; j++) { char *name; uint32 offset, length, compLength, flags, timeDate1, timeDate2; @@ -533,12 +430,7 @@ bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { ////////////////////////////////////////////////////////////////////////// Common::File *BaseFileManager::openPackage(const Common::String &name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - Common::File *ret = new Common::File(); - char filename[MAX_PATH_LENGTH]; - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { Common::String packageName = (*it).getName(); if (packageName == (name + ".dcp")) @@ -547,19 +439,12 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { return ret; } } -/* for (uint32 i = 0; i < _packagePaths.size(); i++) { - sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - }*/ - sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); +/* sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; - } + }*/ warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; @@ -594,17 +479,9 @@ bool BaseFileManager::hasFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) return NULL; - //_gameRef->LOG(0, "open file: %s", filename); - /*#ifdef __WIN32__ - if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); - } - } - #endif*/ + if (strcmp(filename.c_str(), "") == 0) + return NULL; + debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); if (file && keepTrackOf) _openFiles.push_back(file); @@ -627,8 +504,6 @@ bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { - restoreCurrentDir(); - Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { @@ -640,50 +515,23 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - - ret = openDiskFile(filename, this); - if (ret) return ret; + if (ret) + return ret; ret = openPkgFile(filename, this); - if (ret) return ret; + if (ret) + return ret; ret = BaseResources::getFile(filename); - if (ret) return ret; + if (ret) + return ret; warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::restoreCurrentDir() { - if (!_basePath) return STATUS_OK; - else { - /*if (!chdir(_basePath)) return STATUS_OK; - else return STATUS_FAILED;*/ - warning("BaseFileManager::RestoreCurrentDir - ignored"); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::setBasePath(const Common::String &path) { - cleanup(); - - if (path.c_str()) { - _basePath = new char[path.size() + 1]; - strcpy(_basePath, path.c_str()); - } - - initPaths(); - registerPackages(); - - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 7799f5193a..b91609bc45 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/file/base_package.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" @@ -41,44 +41,47 @@ class File; namespace WinterMute { class BaseFile; +class BaseFileEntry; class BaseFileManager: BaseClass { public: - bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool cleanup(); - bool setBasePath(const Common::String &path); - bool restoreCurrentDir(); - char *_basePath; - Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + + BaseFileManager(BaseGame *inGame = NULL); + virtual ~BaseFileManager(); + // Used only by BasePersistenceManager + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + // Used only for detection + bool registerPackages(const Common::FSList &fslist); + // Used by BasePackage only BaseFileEntry *getPackageEntry(const Common::String &filename); Common::File *openPackage(const Common::String &name); - bool registerPackages(const Common::FSList &fslist); - bool registerPackages(); - bool initPaths(); - bool reloadPaths(); + bool requestCD(int cd, char *packageFile, const char *filename); +private: typedef enum { - PATH_PACKAGE, PATH_SINGLE + PATH_PACKAGE, + PATH_SINGLE } TPathType; + bool reloadPaths(); + bool initPaths(); bool addPath(TPathType type, const Common::FSNode &path); - bool requestCD(int cd, char *packageFile, const char *filename); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(BaseGame *inGame = NULL); - virtual ~BaseFileManager(); -// Common::FSList _singlePaths; + bool registerPackages(); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); Common::FSList _packagePaths; +// Common::FSList _singlePaths; + bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); + bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); + bool registerPackage(const Common::String &filename, bool searchSignature = false); + bool isValidPackage(const AnsiString &fileName) const; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; -private: - bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); - bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; - bool isValidPackage(const AnsiString &fileName) const; - }; } // end of namespace WinterMute -- cgit v1.2.3 From 61e011ada98f780d28bbea53f3c702f2bb3ed2bd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 00:40:38 +0200 Subject: WINTERMUTE: Reenable direct package-loading for now --- engines/wintermute/base/base_file_manager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index da49f188c1..772af11c13 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -439,12 +439,11 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { return ret; } } - -/* sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + Common::String filename = Common::String::format("%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; - }*/ + } warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; -- cgit v1.2.3 From 93864d4e39f6335684bee9d8dc291ce9af32ca7b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:08:57 +0200 Subject: WINTERMUTE: Remove Base as superclass for BaseImage --- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/gfx/base_image.cpp | 13 ++++--------- engines/wintermute/base/gfx/base_image.h | 10 ++++------ engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 2 +- .../wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/video/video_theora_player.cpp | 2 +- 6 files changed, 12 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 68cfb8a7ea..9f87f392e5 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -65,7 +65,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(_gameRef); + _thumbnail = new BaseImage(_gameRef->_fileManager); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 533c3a866e..bdc7cb76e2 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -26,9 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/utils/string_util.h" @@ -44,11 +42,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage(BaseGame *inGame, FIBITMAP *bitmap): BaseClass(inGame) { -#if 0 - _bitmap = bitmap; -#endif - _bitmap = NULL; +BaseImage::BaseImage(BaseFileManager *fileManager) { + _fileManager = fileManager; _palette = NULL; _surface = NULL; _decoder = NULL; @@ -86,13 +81,13 @@ bool BaseImage::loadFile(const Common::String &filename) { error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); } _filename = filename; - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); + Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); if (!file) return STATUS_FAILED; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); - _gameRef->_fileManager->closeFile(file); + _fileManager->closeFile(file); return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 4b43e36a6d..7f344b5c1c 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BIMAGE_H #define WINTERMUTE_BIMAGE_H -#include "engines/wintermute/base/base.h" #include "graphics/surface.h" #include "graphics/pixelformat.h" #include "graphics/decoders/image_decoder.h" @@ -37,14 +36,13 @@ #include "common/str.h" #include "common/stream.h" -struct FIBITMAP; - namespace WinterMute { class BaseSurface; -class BaseImage: BaseClass { +class BaseFileManager; +class BaseImage { public: - BaseImage(BaseGame *inGame, FIBITMAP *bitmap = NULL); + BaseImage(BaseFileManager *fileManager); ~BaseImage(); bool loadFile(const Common::String &filename); @@ -63,10 +61,10 @@ public: private: Common::String _filename; Graphics::ImageDecoder *_decoder; - FIBITMAP *_bitmap; const Graphics::Surface *_surface; Graphics::Surface *_deletableSurface; const byte *_palette; + BaseFileManager *_fileManager; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ec69a80095..24e3ddb0ae 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -561,7 +561,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Fix this warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); - BaseImage *screenshot = new BaseImage(_gameRef); + BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); screenshot->copyFrom(_renderSurface); return screenshot; #if 0 diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 772f7c35ba..c8cbe99f73 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -117,7 +117,7 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed } bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(_gameRef); + BaseImage *image = new BaseImage(_gameRef->_fileManager); if (!image->loadFile(_filename)) { return false; } diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 91161cbd3b..f20d4470ac 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -672,7 +672,7 @@ bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("VideoTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; - _alphaImage = new BaseImage(_gameRef); + _alphaImage = new BaseImage(_gameRef->_fileManager); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; -- cgit v1.2.3 From d1f7730ec25b409f3651167640dd48b7dd8046be Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:28:42 +0200 Subject: WINTERMUTE: Encapsulate BaseRenderer::_rectList and replace it by Common::Array --- engines/wintermute/ad/ad_entity.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 4 ++-- engines/wintermute/base/gfx/base_renderer.cpp | 10 +++++++--- engines/wintermute/base/gfx/base_renderer.h | 10 ++++++---- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 2 +- engines/wintermute/ui/ui_window.cpp | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 2a281d0fcb..91ba066d6a 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -502,7 +502,7 @@ bool AdEntity::display() { if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) Reg = false; if (_region && (Reg || _editorAlwaysRegister)) { - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); } displaySpriteAttachments(true); diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index d6a8c2490f..05b7d21dfe 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -209,9 +209,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) return STATUS_OK; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index c46115d70a..63c23169b7 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -72,7 +72,7 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { point.x = x; point.y = y; - for (int i = _rectList.getSize() - 1; i >= 0; i--) { + for (int i = _rectList.size() - 1; i >= 0; i--) { if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame @@ -106,10 +106,10 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// void BaseRenderer::deleteRectList() { - for (int i = 0; i < _rectList.getSize(); i++) { + for (int i = 0; i < _rectList.size(); i++) { delete _rectList[i]; } - _rectList.removeAll(); + _rectList.clear(); } @@ -254,4 +254,8 @@ bool BaseRenderer::pointInViewport(Point32 *p) { return true; } +void BaseRenderer::addRectToList(BaseActiveRect *rect) { + _rectList.push_back(rect); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 118cda0ec6..32dced0878 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -29,10 +29,10 @@ #ifndef WINTERMUTE_BRENDERER_H #define WINTERMUTE_BRENDERER_H - -#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" #include "common/rect.h" +#include "common/array.h" namespace WinterMute { @@ -117,8 +117,10 @@ public: int _bPP; int _height; int _width; - - BaseArray _rectList; + + void addRectToList(BaseActiveRect *rect); +private: + Common::Array _rectList; }; BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 2c4f6d5e4e..21a60ef922 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -637,7 +637,7 @@ bool UIButton::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); // reset unused sprites if (_image && _image != image) _image->reset(); diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 8c277e7c87..df3bd85bb8 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -672,7 +672,7 @@ bool UIEdit::display(int offsetX, int offsetY) { } - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); _gameRef->_textEncoding = OrigEncoding; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 7e6986508b..1f7dc0bee9 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -190,7 +190,7 @@ bool UIWindow::display(int offsetX, int offsetY) { } if (!_transparent && !image) - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); -- cgit v1.2.3 From 4b0ede4685bd1f02e86572f110ab906be265930a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:40:49 +0200 Subject: Rename BaseGame::SaveGame -> saveGame --- engines/wintermute/base/base_game.cpp | 6 +++--- engines/wintermute/base/base_game.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8ef45e4106..6897a37776 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1513,7 +1513,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack char *desc = new char[strlen(xdesc) + 1]; strcpy(desc, xdesc); stack->pushBool(true); - if (DID_FAIL(SaveGame(slot, desc, quick))) { + if (DID_FAIL(saveGame(slot, desc, quick))) { stack->pop(); stack->pushBool(false); } @@ -3157,7 +3157,7 @@ bool BaseGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::SaveGame(int slot, const char *desc, bool quickSave) { +bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -4458,7 +4458,7 @@ void BaseGame::autoSaveOnExit() { if (!_autoSaveOnExit) return; if (_state == GAME_FROZEN) return; - SaveGame(_autoSaveSlot, "autosave", true); + saveGame(_autoSaveSlot, "autosave", true); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 77fa6b3a8b..4a5adb4e39 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -296,7 +296,7 @@ public: virtual bool cleanup(); virtual bool loadGame(int slot); virtual bool loadGame(const char *filename); - virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); BaseSprite *_cursorNoninteractive; -- cgit v1.2.3 From aac94209b306466b49b0938e5f7aab5e280a6c78 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:54:47 +0200 Subject: WINTERMUTE: Clean up a few includes. --- engines/wintermute/ad/ad_actor.cpp | 9 ++------- engines/wintermute/ad/ad_actor.h | 2 ++ engines/wintermute/ad/ad_entity.cpp | 1 + engines/wintermute/ad/ad_object.cpp | 2 +- engines/wintermute/ad/ad_object.h | 3 ++- engines/wintermute/ad/ad_sprite_set.cpp | 1 + engines/wintermute/ad/ad_sprite_set.h | 3 +-- engines/wintermute/persistent.cpp | 1 + 8 files changed, 11 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 68059072d7..bfc21c6ccc 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -26,10 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/base_object.h" #include "engines/wintermute/ad/ad_actor.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_scene.h" @@ -38,16 +34,15 @@ #include "engines/wintermute/ad/ad_waypoint_group.h" #include "engines/wintermute/ad/ad_path.h" #include "engines/wintermute/ad/ad_sentence.h" -#include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/wintermute.h" namespace WinterMute { diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 3cce827b17..870b3e8418 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -33,6 +33,7 @@ #include "engines/wintermute/dctypes.h" // Added by ClassView #include "engines/wintermute/ad/ad_types.h" // Added by ClassView #include "engines/wintermute/ad/ad_talk_holder.h" +#include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base_point.h" // Added by ClassView #include "engines/wintermute/persistent.h" #include "common/str.h" @@ -41,6 +42,7 @@ namespace WinterMute { class AdSpriteSet; class AdPath; +class BaseSprite; class AdActor : public AdTalkHolder { public: TDirection angleToDirection(int angle); diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 91ba066d6a..1ea2512df6 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -51,6 +51,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/base/particles/part_emitter.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index acca57393c..84f13dc989 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_item.h" #include "engines/wintermute/ad/ad_object.h" @@ -49,6 +48,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/particles/part_emitter.h" #include "common/str.h" #include "common/util.h" diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index a8da8bd820..f26a29c8b2 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -30,7 +30,7 @@ #define WINTERMUTE_ADOBJECT_H #include "engines/wintermute/ad/ad_types.h" -#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/base_object.h" namespace WinterMute { @@ -40,6 +40,7 @@ class AdSentence; class BaseFont; class BaseRegion; class AdInventory; +class PartEmitter; #define MAX_NUM_REGIONS 10 diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 4840951ab2..b2238b63ba 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/base/base_dynamic_buffer.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_sprite.h" namespace WinterMute { diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h index 196d8a8e3a..555ab914cf 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -31,10 +31,9 @@ #include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/base/base_sprite.h" // Added by ClassView namespace WinterMute { - +class BaseSprite; class AdSpriteSet : public BaseObject { public: bool containsSprite(BaseSprite *sprite); diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 6473b52bee..76d73911b2 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -68,6 +68,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -- cgit v1.2.3 From 927eb9a9e8f8dab6995c83367739bbf280886c2d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 02:05:37 +0200 Subject: WINTERMUTE: Some more BaseFileManager-cleanup --- engines/wintermute/base/base_file_manager.cpp | 29 +++++++++------------------ engines/wintermute/base/base_file_manager.h | 1 - 2 files changed, 9 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 772af11c13..57f59a144c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -108,7 +108,8 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { - if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + if (mustExist) + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); return NULL; } @@ -123,13 +124,13 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz buffer = new byte[file->size() + 1]; if (buffer == NULL) { - _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); closeFile(file); return NULL; } if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); delete [] buffer; return NULL; @@ -265,8 +266,7 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - _gameRef->LOG(0, "Scanning packages..."); - debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Scanning packages"); // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. @@ -282,8 +282,7 @@ bool BaseFileManager::registerPackages() { } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } @@ -293,7 +292,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { - _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Error opening package file '%s'. Ignoring.", filename.c_str()); return STATUS_OK; } return registerPackage(package, filename); @@ -318,13 +317,13 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const TPackageHeader hdr; hdr.readFromStream(package); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return STATUS_OK; } if (hdr._packageVersion != PACKAGE_VERSION) { - _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 @@ -416,16 +415,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); - } - return true; -} ////////////////////////////////////////////////////////////////////////// Common::File *BaseFileManager::openPackage(const Common::String &name) { diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index b91609bc45..8dfde06f74 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -77,7 +77,6 @@ private: bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); bool registerPackage(const Common::String &filename, bool searchSignature = false); - bool isValidPackage(const AnsiString &fileName) const; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; -- cgit v1.2.3 From 7a818009b4c20df1811c0b158b0f8acfe0e3d208 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 02:23:14 +0200 Subject: WINTERMUTE: Clean out unused utils. --- engines/wintermute/base/base_game.cpp | 1 + .../wintermute/base/scriptables/script_engine.cpp | 2 +- .../wintermute/base/scriptables/script_engine.h | 1 - engines/wintermute/utils/path_util.h | 2 +- engines/wintermute/utils/string_util.cpp | 96 ---------------------- engines/wintermute/utils/string_util.h | 12 +-- engines/wintermute/utils/utils.cpp | 64 +-------------- engines/wintermute/utils/utils.h | 5 -- 8 files changed, 6 insertions(+), 177 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 6897a37776..d3da177a92 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -60,6 +60,7 @@ #include "engines/wintermute/base/scriptables/script_ext_math.h" #include "engines/wintermute/video/video_player.h" #include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "common/savefile.h" #include "common/textconsole.h" diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 44add054c5..e8544d8cd6 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_file_manager.h" - +#include "engines/wintermute/utils/utils.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 06d61b4156..6d2ed92e4f 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,6 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index 139ce89ddd..a52b4baaf9 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_PATHUTILS_H #define WINTERMUTE_PATHUTILS_H -#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/dctypes.h" namespace WinterMute { diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index c3fcb09f1d..fcf5620cd7 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "common/tokenizer.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/convert_utf.h" @@ -264,48 +263,6 @@ bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { else return false; } -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::replace(const AnsiString &str, const AnsiString &from, const AnsiString &to) { - if (from.empty() || from == to) return str; - - AnsiString result = str; - /*size_t pos = 0;*/ - - while (result.contains(from)) { - const char *startPtr = strstr(result.c_str(), from.c_str()); - uint32 index = startPtr - result.c_str(); - - Common::String tail(result.c_str() + index + to.size()); - result = Common::String(result.c_str(), index); - result += to; - result += tail; - - /* pos = result.find(from, pos); - if (pos == result.npos) break; - - result.replace(pos, from.size(), to); - pos += to.size();*/ - } - - return result; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::trim(const AnsiString &str, bool fromLeft, bool fromRight, const AnsiString &chars) { - AnsiString trimmedStr = str; - - if (fromRight) { - //trimmedStr.erase(trimmedStr.find_last_not_of(chars) + 1); // TODO - warning("fromRight-trim not implemented yet, %s", chars.c_str()); - } - if (fromLeft) { - uint32 lastOf = lastIndexOf(str, chars, 0); - trimmedStr = Common::String(trimmedStr.c_str() + lastOf); - //trimmedStr.erase(0, trimmedStr.find_first_not_of(chars)); - } - return trimmedStr; -} - ////////////////////////////////////////////////////////////////////////// int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { /*size_t pos = str.find(toFind, startFrom); @@ -318,64 +275,11 @@ int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t return index - str.c_str(); } -////////////////////////////////////////////////////////////////////////// -int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.rfind(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ - int32 lastIndex = -1; - bool found = false; - for (size_t i = startFrom; i < str.size(); i++) { - found = false; - for (size_t j = 0; j < toFind.size(); j++) { - if (str[i + j] != toFind[j]) { - found = false; - break; - } else { - found = true; - } - } - if (found) - lastIndex = i; - } - return lastIndex; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(size_t val) { - return Common::String::format("%u", (uint32)val); -} ////////////////////////////////////////////////////////////////////////// AnsiString StringUtil::toString(int val) { return Common::String::format("%d", val); } -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(float val) { - return Common::String::format("%f", val); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString StringUtil::toString(double val) { - return Common::String::format("%f", val); -} - - -////////////////////////////////////////////////////////////////////////// -void StringUtil::split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems) { - result.clear(); -//TODO: Verify this, wrt keepEmptyItems. - Common::StringTokenizer tokenizer(list.c_str(), delimiters.c_str()); - //typedef boost::char_separator separator_t; - //typedef boost::tokenizer tokenizer_t; - - //separator_t del(delimiters.c_str(), "", keepEmptyItems ? boost::keep_empty_tokens : boost::drop_empty_tokens); - //tokenizer_t tokens(list, del); - while (!tokenizer.empty()) { - Common::String copy(tokenizer.nextToken().c_str()); - result.push_back(copy); - } -} } // end of namespace WinterMute diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h index bd1b71f405..80b4ab5911 100644 --- a/engines/wintermute/utils/string_util.h +++ b/engines/wintermute/utils/string_util.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_STRINGUTIL_H #define WINTERMUTE_STRINGUTIL_H -#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/dctypes.h" namespace WinterMute { @@ -46,19 +46,9 @@ public: static bool endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); static bool isUtf8BOM(const byte *buffer, uint32 bufferSize); - - static AnsiString replace(const AnsiString &str, const AnsiString &from, const AnsiString &to); - static AnsiString trim(const AnsiString &str, bool fromLeft = true, bool fromRight = true, const AnsiString &chars = " \n\r\t"); - static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static int lastIndexOf(const WideString &str, const WideString &toFind, size_t startFrom); - static AnsiString toString(size_t val); static AnsiString toString(int val); - static AnsiString toString(float val); - static AnsiString toString(double val); - - static void split(const AnsiString &list, const AnsiString &delimiters, AnsiStringArray &result, bool keepEmptyItems = false); }; } // end of namespace WinterMute diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 038095c8ae..ee723cf80a 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -26,14 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/base/base_game.h" -#include "common/str.h" -#include "common/textconsole.h" #include "engines/wintermute/wintermute.h" namespace WinterMute { @@ -43,36 +36,6 @@ static inline unsigned Sqr(int x) { return (x * x); } - -////////////////////////////////////////////////////////////////////////////////// -void BaseUtils::clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect) { - // If it's partly off the right side of the screen - if (*destX + (srcRect->right - srcRect->left) > destRect->right) - srcRect->right -= *destX + (srcRect->right - srcRect->left) - destRect->right; - - if (srcRect->right < 0) srcRect->right = 0; - - // Partly off the left side of the screen - if (*destX < destRect->left) { - srcRect->left += destRect->left - *destX; - *destX = destRect->left; - } - - // Partly off the top of the screen - if (*destY < destRect->top) { - srcRect->top += destRect->top - *destY; - *destY = destRect->top; - } - - // If it's partly off the bottom side of the screen - if (*destY + (srcRect->bottom - srcRect->top) > destRect->bottom) - srcRect->bottom -= ((srcRect->bottom - srcRect->top) + *destY) - destRect->bottom; - - if (srcRect->bottom < 0) srcRect->bottom = 0; - - return; -} - ////////////////////////////////////////////////////////////////////////////////// // Swap - swaps two integers ////////////////////////////////////////////////////////////////////////////////// @@ -82,11 +45,6 @@ void BaseUtils::swap(int *a, int *b) { *b = Temp; } -////////////////////////////////////////////////////////////////////////// -bool BaseUtils::strBeginsI(const char *string, const char *fragment) { - return (scumm_strnicmp(string, fragment, strlen(fragment)) == 0); -} - ////////////////////////////////////////////////////////////////////////// float BaseUtils::normalizeAngle(float angle) { @@ -99,11 +57,11 @@ float BaseUtils::normalizeAngle(float angle) { //////////////////////////////////////////////////////////////////////////////// void BaseUtils::createPath(const char *path, bool pathOnly) { - AnsiString pathStr; +/* AnsiString pathStr; if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); else pathStr = path; - +*/ // try { warning("BaseUtils::CreatePath - not implemented: %s", path); // boost::filesystem::create_directories(path); @@ -235,24 +193,6 @@ bool BaseUtils::matchesPattern(const char *pattern, const char *string) { } } -////////////////////////////////////////////////////////////////////////// -char *BaseUtils::getPath(const char *filename) { - AnsiString path = PathUtil::getDirectoryName(filename); - //path = boost::filesystem::syste_complete(path).string(); - warning("BaseUtils::GetPath: (%s), not implemented", filename); - char *ret = new char[path.size() + 1]; - strcpy(ret, path.c_str()); - - return ret; -} - -////////////////////////////////////////////////////////////////////////// -char *BaseUtils::getFilename(const char *filename) { - AnsiString path = PathUtil::getFileName(filename); - char *ret = new char[path.size() + 1]; - strcpy(ret, path.c_str()); - return ret; -} ////////////////////////////////////////////////////////////////////////// void BaseUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 3baafaa606..3cb01c57b8 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -38,9 +38,7 @@ class BaseGame; class BaseUtils { public: - static void clip(int *destX, int *destY, Rect32 *srcRect, Rect32 *destRect); static void swap(int *a, int *b); - static bool strBeginsI(const char *string, const char *fragment); static float normalizeAngle(float angle); static void createPath(const char *path, bool pathOnly = false); @@ -57,9 +55,6 @@ public: static bool matchesPattern(const char *pattern, const char *string); - static char *getPath(const char *filename); - static char *getFilename(const char *filename); - static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); static uint32 HSLtoRGB(byte H, byte S, byte L); -- cgit v1.2.3 From dd6d093cf33f3ab3cf49f848ba6298733bad5831 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 02:36:57 +0200 Subject: WINTERMUTE: Remove 2 more unecessary includes. --- engines/wintermute/system/sys_class_registry.h | 1 - engines/wintermute/video/video_theora_player.h | 1 - 2 files changed, 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/system/sys_class_registry.h b/engines/wintermute/system/sys_class_registry.h index d668c57803..65d4fe1f02 100644 --- a/engines/wintermute/system/sys_class_registry.h +++ b/engines/wintermute/system/sys_class_registry.h @@ -31,7 +31,6 @@ #include "engines/wintermute/wintypes.h" #include "engines/wintermute/dctypes.h" -#include "engines/wintermute/persistent.h" #include "engines/wintermute/system/sys_class.h" #include "common/hashmap.h" #include "common/hash-str.h" diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 6e0e4b3152..3d17aed31e 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -30,7 +30,6 @@ #define WINTERMUTE_VIDTHEORAPLAYER_H #include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/persistent.h" #include "video/video_decoder.h" #include "common/stream.h" -- cgit v1.2.3 From 448911930d8d6bf43a67769d50ee4048f296b7f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:01:05 +0200 Subject: WINTERMUTE: Remove unused code from platform_osystem.h --- engines/wintermute/ad/ad_game.cpp | 1 + engines/wintermute/ad/ad_response_box.cpp | 2 +- engines/wintermute/ad/ad_scene.cpp | 5 +- engines/wintermute/base/base_active_rect.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 7 +- engines/wintermute/base/base_file_manager.cpp | 22 +++--- engines/wintermute/base/base_game.cpp | 13 ++-- engines/wintermute/base/base_sub_frame.cpp | 2 +- .../wintermute/base/base_transition_manager.cpp | 7 +- .../wintermute/base/font/base_font_truetype.cpp | 4 +- engines/wintermute/base/scriptables/script.cpp | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 20 ++--- .../wintermute/base/scriptables/script_engine.h | 3 +- .../base/scriptables/script_ext_file.cpp | 12 ++- engines/wintermute/platform_osystem.cpp | 88 ---------------------- engines/wintermute/platform_osystem.h | 18 +---- engines/wintermute/ui/ui_button.cpp | 5 +- engines/wintermute/ui/ui_edit.cpp | 9 +-- engines/wintermute/ui/ui_window.cpp | 2 +- engines/wintermute/wintermute.cpp | 4 +- 20 files changed, 63 insertions(+), 165 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 42a453d533..977115ad76 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -59,6 +59,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/video/video_player.h" #include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 38fbd6f95d..a800ae71b2 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -398,7 +398,7 @@ bool AdResponseBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool AdResponseBox::display() { Rect32 rect = _responseArea; if (_window) { - BasePlatform::offsetRect(&rect, _window->_posX, _window->_posY); + rect.offsetRect(_window->_posX, _window->_posY); //_window->display(); } diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index e76e61af79..a802039550 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -52,7 +52,6 @@ #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_viewport.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" @@ -485,14 +484,14 @@ bool AdScene::initLoop() { #ifdef _DEBUGxxxx int nu_steps = 0; uint32 start = _gameRef->_currentTime; - while (!_pfReady && BasePlatform::getTime() - start <= _pfMaxTime) { + while (!_pfReady && g_system->getMillis() - start <= _pfMaxTime) { PathFinderStep(); nu_steps++; } if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); #else uint32 start = _gameRef->_currentTime; - while (!_pfReady && BasePlatform::getTime() - start <= _pfMaxTime) pathFinderStep(); + while (!_pfReady && g_system->getMillis() - start <= _pfMaxTime) pathFinderStep(); #endif return STATUS_OK; diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 493b35bf12..598324e10b 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -65,7 +65,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion * _owner = owner; _region = region; BasePlatform::copyRect(&_rect, ®ion->_rect); - BasePlatform::offsetRect(&_rect, -offsetX, -offsetY); + _rect.offsetRect(-offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4dcdf82347..c5f170bb43 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" #include "common/util.h" namespace WinterMute { @@ -67,7 +66,7 @@ bool BaseFader::update() { uint32 time; - if (_system) time = BasePlatform::getTime() - _startTime; + if (_system) time = g_system->getMillis() - _startTime; else time = _gameRef->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; @@ -115,7 +114,7 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = BasePlatform::getTime(); + if (_system) _startTime = g_system->getMillis(); else _startTime = _gameRef->_timer; return STATUS_OK; @@ -138,7 +137,7 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = BasePlatform::getTime(); + if (_system) _startTime = g_system->getMillis(); else _startTime = _gameRef->_timer; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 57f59a144c..1eb27ad0c4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -372,9 +372,11 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory name[nameLength - 1] = '\0'; - - - BasePlatform::strupr(name); + + Common::String upcName = name; + upcName.toUppercase(); + delete[] name; + name = NULL; offset = package->readUint32LE(); offset += absoluteOffset; @@ -386,7 +388,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const timeDate1 = package->readUint32LE(); timeDate2 = package->readUint32LE(); } - _filesIter = _files.find(name); + _filesIter = _files.find(upcName.c_str()); if (_filesIter == _files.end()) { BaseFileEntry *file = new BaseFileEntry(); file->_package = pkg; @@ -395,7 +397,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const file->_compressedLength = compLength; file->_flags = flags; - _files[name] = file; + _files[upcName.c_str()] = file; } else { // current package has lower CD number or higher priority, than the registered if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { @@ -406,7 +408,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const _filesIter->_value->_flags = flags; } } - delete [] name; } } @@ -441,16 +442,13 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { - char *upc_name = new char[strlen(filename.c_str()) + 1]; - strcpy(upc_name, filename.c_str()); - BasePlatform::strupr(upc_name); + Common::String upc_name = filename; + upc_name.toUppercase(); BaseFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); + _filesIter = _files.find(upc_name.c_str()); if (_filesIter != _files.end()) ret = _filesIter->_value; - delete [] upc_name; - return ret; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index d3da177a92..e72deb4be2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -62,6 +62,7 @@ #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/platform_osystem.h" #include "common/savefile.h" #include "common/textconsole.h" #include "common/util.h" @@ -589,7 +590,7 @@ void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { bool BaseGame::initLoop() { _viewportSP = -1; - _currentTime = BasePlatform::getTime(); + _currentTime = g_system->getMillis(); getDebugMgr()->onGameTick(); _renderer->initLoop(); @@ -2183,7 +2184,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)BasePlatform::getTime()); + _scValue->setInt((int)g_system->getMillis()); return _scValue; } @@ -4405,9 +4406,9 @@ void BaseGame::getMousePos(Point32 *pos) { bool BaseGame::miniUpdate() { if (!_miniUpdateEnabled) return STATUS_OK; - if (BasePlatform::getTime() - _lastMiniUpdate > 200) { + if (g_system->getMillis() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = BasePlatform::getTime(); + _lastMiniUpdate = g_system->getMillis(); } return STATUS_OK; } @@ -4440,8 +4441,8 @@ bool BaseGame::isDoubleClick(int buttonIndex) { int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - if (_lastClick[buttonIndex].time == 0 || BasePlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = BasePlatform::getTime(); + if (_lastClick[buttonIndex].time == 0 || g_system->getMillis() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = g_system->getMillis(); _lastClick[buttonIndex].posX = pos.x; _lastClick[buttonIndex].posY = pos.y; return false; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 05b7d21dfe..d30d38ef70 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -262,7 +262,7 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple Rect32 rect; BasePlatform::setRectEmpty(&rect); if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!BasePlatform::equalRect(&rect, &_rect)) + if (!(rect == _rect)) buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index b524636af7..e4665756e2 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" namespace WinterMute { @@ -88,7 +87,7 @@ bool BaseTransitionMgr::update() { if (!_started) { _started = true; - _lastTime = BasePlatform::getTime(); + _lastTime = g_system->getMillis(); } switch (_type) { @@ -97,7 +96,7 @@ bool BaseTransitionMgr::update() { break; case TRANSITION_FADE_OUT: { - uint32 time = BasePlatform::getTime() - _lastTime; + uint32 time = g_system->getMillis() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -108,7 +107,7 @@ bool BaseTransitionMgr::update() { break; case TRANSITION_FADE_IN: { - uint32 time = BasePlatform::getTime() - _lastTime; + uint32 time = g_system->getMillis() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 9782d1d7db..88eec8469f 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -641,13 +641,15 @@ bool BaseFontTT::initFont() { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { + //TODO: Try to fallback from Arial to FreeSans + /* // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return STATUS_FAILED; - } + }*/ } if (file) { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 45544831e3..11fe6ff0cc 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1148,7 +1148,7 @@ bool ScScript::sleep(uint32 duration) { _state = SCRIPT_SLEEPING; if (_gameRef->_state == GAME_FROZEN) { - _waitTime = BasePlatform::getTime() + duration; + _waitTime = g_system->getMillis() + duration; _waitFrozen = true; } else { _waitTime = _gameRef->_timer + duration; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e8544d8cd6..472e9d9fec 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -176,7 +176,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig if (!ignoreCache) { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = BasePlatform::getTime(); + _cachedScripts[i]->_timestamp = g_system->getMillis(); *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } @@ -216,7 +216,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = BasePlatform::getTime(); + uint32 MinTime = g_system->getMillis(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; @@ -275,7 +275,7 @@ bool ScEngine::tick() { case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= BasePlatform::getTime()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run(); } else { if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); } @@ -314,25 +314,25 @@ bool ScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = BasePlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && BasePlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + uint32 StartTime = g_system->getMillis(); + while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = BasePlatform::getTime(); + if (isProfiling) startTime = g_system->getMillis(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - startTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); } _currentScript = NULL; } @@ -670,7 +670,7 @@ void ScEngine::enableProfiling() { // destroy old data, if any _scriptTimes.clear(); - _profilingStartTime = BasePlatform::getTime(); + _profilingStartTime = g_system->getMillis(); _isProfiling = true; } @@ -687,7 +687,7 @@ void ScEngine::disableProfiling() { ////////////////////////////////////////////////////////////////////////// void ScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = BasePlatform::getTime() - _profilingStartTime; + /* uint32 totalTime = g_system->getMillis() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 6d2ed92e4f..3d85192aa6 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,6 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/platform_osystem.h" namespace WinterMute { @@ -47,7 +46,7 @@ public: class CScCachedScript { public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = BasePlatform::getTime(); + _timestamp = g_system->getMillis(); _buffer = new byte[size]; if (_buffer) memcpy(_buffer, buffer, size); _size = size; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index ffa362a938..383b956555 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -182,7 +182,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); close(); - stack->pushBool(BasePlatform::deleteFile(_filename) != false); + error("SXFile-Method: \"Delete\" not supported"); + //stack->pushBool(BasePlatform::deleteFile(_filename) != false); + stack->pushBool(false); return STATUS_OK; } @@ -191,11 +193,13 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { stack->correctParams(2); - const char *Dest = stack->pop()->getString(); - bool Overwrite = stack->pop()->getBool(true); + const char *dest = stack->pop()->getString(); + bool overwrite = stack->pop()->getBool(true); close(); - stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + error("SXFile-Method: Copy not supported"); + //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(false); return STATUS_OK; } diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 028a85ada1..a76cc100ce 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -26,14 +26,9 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/scriptables/script_engine.h" #include "common/str.h" #include "common/textconsole.h" #include "common/system.h" @@ -150,18 +145,6 @@ void BasePlatform::handleEvent(Common::Event *event) { } } -////////////////////////////////////////////////////////////////////////// -int BasePlatform::SDLEventWatcher(void *userdata, Common::Event *event) { - //TODO - /* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) { - if (_gameRef) _gameRef->AutoSaveOnExit(); - if (_gameRef) _gameRef->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); - } - */ - return 1; -} - ////////////////////////////////////////////////////////////////////////// // Win32 API bindings @@ -175,11 +158,6 @@ void BasePlatform::outputDebugString(const char *lpOutputString) { } -////////////////////////////////////////////////////////////////////////// -uint32 BasePlatform::getTime() { - return g_system->getMillis(); -} - ////////////////////////////////////////////////////////////////////////// bool BasePlatform::getCursorPos(Point32 *lpPoint) { BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); @@ -211,24 +189,6 @@ bool BasePlatform::showWindow(int nCmdShow) { return false; } -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::deleteFile(const char *lpFileName) { - return remove(lpFileName) ? true : false; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::copyFile(const char *from, const char *to, bool failIfExists) { -// try { - warning("BasePlatform::copyFile(%s, %s, %d) - not implemented", from, to, failIfExists); - return false; -// if (failIfExists && boost::filesystem::exists(to)) return false; -// boost::filesystem::copy_file(from, to); -// return true; -// } catch (...) { -// return false; -// } -} - ////////////////////////////////////////////////////////////////////////// void BasePlatform::setCapture() { return; @@ -239,11 +199,6 @@ bool BasePlatform::releaseCapture() { return false; } -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::setForegroundWindow() { - return false; -} - ////////////////////////////////////////////////////////////////////////// bool BasePlatform::setRectEmpty(Rect32 *lprc) { lprc->left = lprc->right = lprc->top = lprc->bottom = 0; @@ -317,39 +272,6 @@ bool BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { return true; } -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::offsetRect(Rect32 *lprc, int dx, int dy) { - if (lprc == NULL) return false; - - lprc->left += dx; - lprc->top += dy; - lprc->right += dx; - lprc->bottom += dy; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePlatform::equalRect(Rect32 *rect1, Rect32 *rect2) { - return rect1->left == rect2->left && rect1->right == rect2->right && rect1->top == rect2->top && rect1->bottom == rect2->bottom; -} - - -////////////////////////////////////////////////////////////////////////// -AnsiString BasePlatform::getSystemFontPath() { -/*#ifdef __WIN32__ - // we're looking for something like "c:\windows\fonts\"; - char winDir[MAX_PATH_LENGTH + 1]; - winDir[MAX_PATH_LENGTH] = '\0'; - ::GetWindowsDirectory(winDir, MAX_PATH_LENGTH); - return PathUtil::Combine(AnsiString(winDir), "fonts"); -#else*/ - // !PORTME - //return "/Library/Fonts/"; - return ""; -//#endif -} - ////////////////////////////////////////////////////////////////////////// AnsiString BasePlatform::getPlatformName() { // TODO: Should conform to the WME-spec. @@ -357,16 +279,6 @@ AnsiString BasePlatform::getPlatformName() { return AnsiString("ScummVM"); } -////////////////////////////////////////////////////////////////////////// -char *BasePlatform::strupr(char *string) { - if (string) { - for (size_t i = 0; i < strlen(string); ++i) { - string[i] = toupper(string[i]); - } - } - return string; -} - ////////////////////////////////////////////////////////////////////////// char *BasePlatform::strlwr(char *string) { if (string) { diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 601f47b29d..77a690c207 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -31,7 +31,6 @@ #include "engines/wintermute/dctypes.h" #include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/wintypes.h" #include "common/events.h" namespace WinterMute { @@ -43,21 +42,17 @@ class BasePlatform { public: static int initialize(BaseGame *inGame, int argc, char *argv[]); static void handleEvent(Common::Event *event); - - static AnsiString getSystemFontPath(); static AnsiString getPlatformName(); // Win32 API bindings static void outputDebugString(const char *lpOutputString); - static uint32 getTime(); + //static uint32 getTime(); static bool getCursorPos(Point32 *lpPoint); static bool setCursorPos(int X, int Y); static bool showWindow(int nCmdShow); - static bool deleteFile(const char *lpFileName); - static bool copyFile(const char *from, const char *to, bool failIfExists); + static void setCapture(); static bool releaseCapture(); - static bool setForegroundWindow(); static bool setRectEmpty(Rect32 *lprc); static bool isRectEmpty(const Rect32 *lprc); @@ -66,19 +61,10 @@ public: static bool intersectRect(Rect32 *lprcDst, const Rect32 *lprcSrc1, const Rect32 *lprcSrc2); static bool unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2); static bool copyRect(Rect32 *lprcDst, Rect32 *lprcSrc); - static bool offsetRect(Rect32 *lprc, int dx, int dy); - static bool equalRect(Rect32 *rect1, Rect32 *rect2); - // string functions -// static int stricmp(const char *str1, const char *str2); -// static int strnicmp(const char *str1, const char *str2, size_t maxCount); - static char *strupr(char *string); static char *strlwr(char *string); - // sdl event callback - static int SDLEventWatcher(void *userdata, Common::Event *event); - private: static BaseGame *_gameRef; }; diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 21a60ef922..235a73e8a6 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -38,7 +38,6 @@ #include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" @@ -590,7 +589,7 @@ bool UIButton::display(int offsetX, int offsetY) { _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && BasePlatform::getTime() - _oneTimePressTime >= 100)) press(); + (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) press(); if (_disable) { @@ -907,7 +906,7 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_visible && !_disable) { _oneTimePress = true; - _oneTimePressTime = BasePlatform::getTime(); + _oneTimePressTime = g_system->getMillis(); } stack->pushNULL(); diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index df3bd85bb8..3d847408b5 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -40,7 +40,6 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script.h" @@ -629,8 +628,8 @@ bool UIEdit::display(int offsetX, int offsetY) { // cursor if (focused && curFirst) { if (Count) { - if (BasePlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = BasePlatform::getTime(); + if (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = g_system->getMillis(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) @@ -652,8 +651,8 @@ bool UIEdit::display(int offsetX, int offsetY) { // cursor if (focused && !curFirst) { if (Count) { - if (BasePlatform::getTime() - _lastBlinkTime >= _cursorBlinkRate) { - _lastBlinkTime = BasePlatform::getTime(); + if (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { + _lastBlinkTime = g_system->getMillis(); _cursorVisible = !_cursorVisible; } if (_cursorVisible) diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 1f7dc0bee9..2c3d7b78ea 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -1137,7 +1137,7 @@ bool UIWindow::handleMouse(TMouseEvent event, TMouseButton button) { Rect32 dragRect = _dragRect; int offsetX, offsetY; getTotalOffset(&offsetX, &offsetY); - BasePlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY); + dragRect.offsetRect(_posX + offsetX, _posY + offsetY); if (BasePlatform::ptInRect(&dragRect, _gameRef->_mousePos)) { _dragFrom.x = _gameRef->_mousePos.x; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 520889fd11..5695e5e8df 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -247,7 +247,7 @@ int WinterMuteEngine::init() { // load game - uint32 DataInitStart = BasePlatform::getTime(); + uint32 DataInitStart = g_system->getMillis(); if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); @@ -259,7 +259,7 @@ int WinterMuteEngine::init() { _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; - _game->LOG(0, "Engine initialized in %d ms", BasePlatform::getTime() - DataInitStart); + _game->LOG(0, "Engine initialized in %d ms", g_system->getMillis() - DataInitStart); _game->LOG(0, ""); if (ConfMan.hasKey("save_slot")) { -- cgit v1.2.3 From aedb0aea505e764c4c7bab1f90520b380be4d688 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:22:49 +0200 Subject: WINTERMUTE: Remove dcgf.h from almost all includes. --- engines/wintermute/ad/ad_entity.cpp | 2 -- engines/wintermute/ad/ad_game.cpp | 1 - engines/wintermute/ad/ad_inventory_box.cpp | 2 +- engines/wintermute/ad/ad_item.cpp | 1 - engines/wintermute/ad/ad_layer.cpp | 1 - engines/wintermute/ad/ad_node_state.cpp | 1 - engines/wintermute/ad/ad_path.cpp | 1 - engines/wintermute/ad/ad_region.cpp | 1 - engines/wintermute/ad/ad_response.cpp | 1 - engines/wintermute/ad/ad_response_box.cpp | 1 - engines/wintermute/ad/ad_response_context.cpp | 1 - engines/wintermute/ad/ad_rot_level.cpp | 1 - engines/wintermute/ad/ad_scale_level.cpp | 1 - engines/wintermute/ad/ad_scene_node.cpp | 1 - engines/wintermute/ad/ad_scene_state.cpp | 1 - engines/wintermute/ad/ad_sentence.cpp | 1 - engines/wintermute/ad/ad_sprite_set.cpp | 1 - engines/wintermute/ad/ad_talk_def.cpp | 1 - engines/wintermute/ad/ad_talk_holder.cpp | 1 - engines/wintermute/ad/ad_talk_node.cpp | 1 - engines/wintermute/base/base.cpp | 1 - engines/wintermute/base/base_active_rect.cpp | 1 - engines/wintermute/base/base_fader.cpp | 1 - engines/wintermute/base/base_file_manager.cpp | 1 - engines/wintermute/base/base_frame.cpp | 1 - engines/wintermute/base/base_keyboard_state.cpp | 1 - engines/wintermute/base/base_named_object.cpp | 1 - engines/wintermute/base/base_object.cpp | 1 - engines/wintermute/base/base_parser.cpp | 1 - engines/wintermute/base/base_point.cpp | 1 - engines/wintermute/base/base_quick_msg.cpp | 1 - engines/wintermute/base/base_region.cpp | 1 - engines/wintermute/base/base_save_thumb_helper.cpp | 1 - engines/wintermute/base/base_script_holder.cpp | 1 - engines/wintermute/base/base_scriptable.cpp | 1 - engines/wintermute/base/base_sprite.cpp | 1 - engines/wintermute/base/base_sub_frame.cpp | 1 - engines/wintermute/base/base_surface_storage.cpp | 1 - engines/wintermute/base/base_transition_manager.cpp | 1 - engines/wintermute/base/file/BPkgFile.cpp | 1 - engines/wintermute/base/file/base_file.cpp | 1 - engines/wintermute/base/file/base_package.cpp | 1 - engines/wintermute/base/file/base_save_thumb_file.cpp | 1 - engines/wintermute/base/font/base_font.cpp | 1 - engines/wintermute/base/font/base_font_bitmap.cpp | 1 - engines/wintermute/base/font/base_font_storage.cpp | 1 - engines/wintermute/base/font/base_font_truetype.cpp | 1 - engines/wintermute/base/gfx/base_renderer.cpp | 1 - engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 - engines/wintermute/base/particles/part_emitter.cpp | 1 - engines/wintermute/base/particles/part_force.cpp | 1 - engines/wintermute/base/particles/part_particle.cpp | 2 -- engines/wintermute/base/scriptables/script.cpp | 1 - engines/wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 - engines/wintermute/base/sound/base_sound_manager.cpp | 1 - engines/wintermute/ui/ui_button.cpp | 1 - engines/wintermute/ui/ui_text.cpp | 1 - engines/wintermute/ui/ui_tiled_image.cpp | 1 - engines/wintermute/ui/ui_window.cpp | 1 - engines/wintermute/utils/path_util.cpp | 1 - engines/wintermute/video/video_player.cpp | 1 - engines/wintermute/video/video_theora_player.cpp | 1 - 63 files changed, 1 insertion(+), 65 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 1ea2512df6..80c52de71a 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -27,8 +27,6 @@ */ - -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_entity.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 977115ad76..ef5461bb5e 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_actor.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_entity.h" diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 488cee77c8..38e06535d9 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" + #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_inventory_box.h" #include "engines/wintermute/ad/ad_inventory.h" diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index ba116b6569..ec9fa3c14c 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_item.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_sentence.h" diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 80fbc683ef..38894a0e88 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/ad/ad_layer.h" #include "engines/wintermute/ad/ad_scene_node.h" diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index fca2600884..f8196e96b7 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/ad/ad_node_state.h" #include "engines/wintermute/ad/ad_entity.h" diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index cecfaa37d6..f7832d621d 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_path.h" #include "engines/wintermute/base/base_point.h" diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 965f14d8a3..a23c000137 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_region.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index 29398f547c..fbfe828330 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_response.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/font/base_font_storage.h" diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index a800ae71b2..90582ce811 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/ad/ad_response_box.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 32d9415fe9..8d966e7a3e 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_response_context.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index b9949d9f9b..6f3ffdaeb5 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_rot_level.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 539e9a8bb7..1adf4266b2 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_scale_level.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index dbf68ff0ca..658e85340d 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_scene_node.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 173c1ef57b..617f247241 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/ad/ad_scene_state.h" #include "engines/wintermute/ad/ad_node_state.h" diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index ad3a291e16..452c2587d4 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_sentence.h" #include "engines/wintermute/ad/ad_talk_def.h" #include "engines/wintermute/ad/ad_talk_node.h" diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index b2238b63ba..e158b6115a 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_sprite_set.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 2756b69467..cfbefd39d4 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_talk_def.h" #include "engines/wintermute/ad/ad_talk_node.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index de19004584..db13e0a549 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_talk_holder.h" #include "engines/wintermute/base/base_dynamic_buffer.h" #include "engines/wintermute/base/scriptables/script_value.h" diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index 5325b1aeff..306825c439 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_talk_node.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 4b62a7553a..b81261cdaf 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 598324e10b..0283ee274e 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_region.h" diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index c5f170bb43..8ed2fb3f0b 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" #include "common/util.h" diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1eb27ad0c4..5d399c33a1 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 2a729a882a..8278c48299 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index ad014762d4..a12f70f3ba 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_keyboard_state.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index ad95d83211..0821c9325b 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_named_object.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 2002f01dc8..44823acf1a 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/scriptables/script_value.h" diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index b07d98eca8..b7a221daf5 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 76d8d85c70..99e8c609df 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index 856a214f80..6e435b3ee0 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_quick_msg.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index d654f69b9c..22b5a99937 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 9f87f392e5..b63f280f05 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index c4d8b9b5c2..20eb2d13e1 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/base/base_script_holder.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 6da67db3fb..40aa2871b5 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 7b3e104d84..86dbefdd70 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index d30d38ef70..2ac011917c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_active_rect.h" diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 7067c2a607..8e6931f54b 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index e4665756e2..53dd99aac2 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 5e1ebc5922..be37571901 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index d4109bb259..b2c0b31db9 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "common/memstream.h" diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 303d6eea17..a0f56ddf83 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/file.h" diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a2295b70a5..a6d56f281e 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 0c86517fc7..e9d245782a 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/font/base_font_bitmap.h" #include "engines/wintermute/base/font/base_font_truetype.h" diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9a3caf2669..8fd13a6835 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font_bitmap.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 9adc62c829..338273f338 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 88eec8469f..18966c662c 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 63c23169b7..a40b3204a5 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/gfx/base_surface.h" diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 24e3ddb0ae..70d1268e5a 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 76fe3c79de..bfe050cbe0 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/math/vector2.h" diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 7311ea21f6..6a8f328349 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/particles/part_force.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index e36cec6f47..37f374a3e5 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/base_sprite.h" @@ -34,7 +33,6 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -#include namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 11fe6ff0cc..bdd11ca06a 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 472e9d9fec..c275ebf5af 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/scriptables/script_value.h" diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index e1dba2120d..0b7fc840bf 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound_manager.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 22b22a5db6..a73b20e404 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 235a73e8a6..93e45fb1ff 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_dynamic_buffer.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/ui/ui_button.h" diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index c3548b60ac..3535da0ca5 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_dynamic_buffer.h" #include "engines/wintermute/ui/ui_text.h" #include "engines/wintermute/ui/ui_tiled_image.h" diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 6ee27bb411..5e1d9675c0 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ui/ui_tiled_image.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 2c3d7b78ea..e9308e052b 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_active_rect.h" diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 6812d824df..d97b9bedab 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "common/file.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index 2806dbe516..be3bb3ec94 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -27,7 +27,6 @@ */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/video/video_player.h" //#pragma comment(lib, "vfw32.lib") diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index f20d4470ac..81e6769cfd 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -27,7 +27,6 @@ */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_game.h" -- cgit v1.2.3 From c7eda9abc80d1912148cae4292b94620c67a9c19 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:42:27 +0200 Subject: WINTERMUTE: Encapsulate and distance BasePersistenceManager from Base. --- engines/wintermute/ad/ad_game.cpp | 4 ++-- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_game.cpp | 4 ++-- engines/wintermute/base/base_keyboard_state.cpp | 4 ++-- .../wintermute/base/base_persistence_manager.cpp | 16 ++++++++------ engines/wintermute/base/base_persistence_manager.h | 25 ++++++++++++---------- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/particles/part_force.cpp | 2 +- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 4 ++-- .../wintermute/base/scriptables/script_engine.cpp | 2 +- .../base/scriptables/script_ext_file.cpp | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 2 +- .../base/scriptables/script_ext_string.cpp | 2 +- .../wintermute/base/scriptables/script_value.cpp | 2 +- engines/wintermute/base/sound/base_sound.cpp | 4 ++-- engines/wintermute/coll_templ.h | 4 ++-- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 2 +- engines/wintermute/video/video_theora_player.cpp | 4 ++-- 25 files changed, 55 insertions(+), 50 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index ef5461bb5e..d75f41e38e 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -1252,7 +1252,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) cleanup(); + if (!persistMgr->getIsSaving()) cleanup(); BaseGame::persist(persistMgr); _dlgPendingBranches.persist(persistMgr); @@ -1292,7 +1292,7 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { _speechDirs.persist(persistMgr); persistMgr->transfer(TMEMBER(_smartItemCursor)); - if (!persistMgr->_saving) _initialScene = false; + if (!persistMgr->getIsSaving()) _initialScene = false; persistMgr->transfer(TMEMBER(_startupScene)); diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 8ed2fb3f0b..4e7c608482 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -166,7 +166,7 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_targetAlpha)); persistMgr->transfer(TMEMBER(_system)); - if (_system && !persistMgr->_saving) _startTime = 0; + if (_system && !persistMgr->getIsSaving()) _startTime = 0; return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index e72deb4be2..301f79691d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3547,7 +3547,7 @@ bool BaseGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) + if (!persistMgr->getIsSaving()) cleanup(); BaseObject::persist(persistMgr); @@ -3631,7 +3631,7 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot)); persistMgr->transfer(TMEMBER(_cursorHidden)); - if (!persistMgr->_saving) + if (!persistMgr->getIsSaving()) _quitting = false; return STATUS_OK; diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index a12f70f3ba..db0f1db94d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -215,7 +215,7 @@ bool BaseKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if(!persistMgr->_saving) cleanup(); + //if(!persistMgr->getIsSaving()) cleanup(); BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); @@ -225,7 +225,7 @@ bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_currentPrintable)); persistMgr->transfer(TMEMBER(_currentShift)); - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum for (int i = 0; i < 323; i++) { _keyStates[i] = false; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 610229644c..da38806888 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/wintermute.h" #include "graphics/decoders/bmp.h" #include "common/memstream.h" #include "common/str.h" @@ -51,7 +52,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix): BaseClass(inGame) { +BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) { _saving = false; // _buffer = NULL; // _bufferSize = 0; @@ -315,7 +316,7 @@ bool BasePersistenceManager::initLoad(const char *filename) { _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; } @@ -325,8 +326,9 @@ bool BasePersistenceManager::initLoad(const char *filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { - _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; } @@ -336,8 +338,8 @@ bool BasePersistenceManager::initLoad(const char *filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { - _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; @@ -746,7 +748,7 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { if (_saving) { SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + debugC(kWinterMuteDebugSaveGame, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(classID); diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index a400c612dc..a59f797668 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BPERSISTMGR_H -#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" #include "engines/wintermute/math/rect32.h" #include "engines/savestate.h" #include "common/stream.h" @@ -41,17 +41,10 @@ namespace WinterMute { class Vector2; - -class BasePersistenceManager : public BaseClass { +class BaseGame; +class BasePersistenceManager { public: char *_savedDescription; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; Common::String _savePrefix; Common::String _savedName; bool saveFile(const char *filename); @@ -75,7 +68,7 @@ public: bool putBytes(byte *buffer, uint32 size); uint32 _offset; - bool _saving; + bool getIsSaving() { return _saving; } uint32 _richBufferSize; byte *_richBuffer; @@ -107,6 +100,16 @@ private: bool putTimeDate(const TimeDate &t); Common::WriteStream *_saveStream; Common::SeekableReadStream *_loadStream; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + bool _saving; + // Separate from Base, as this class can do SOME operations without a _gameRef. + BaseGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 20eb2d13e1..62ed4f67f2 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -271,7 +271,7 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 8e6931f54b..0dd10f6bdc 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -147,7 +147,7 @@ bool BaseSurfaceStorage::restoreAll() { bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { - if(!persistMgr->_saving) cleanup(false); + if(!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 8fd13a6835..2e752d4f2e 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -463,7 +463,7 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER(_widthsFrame)); - if (persistMgr->_saving) + if (persistMgr->getIsSaving()) persistMgr->putBytes(_widths, sizeof(_widths)); else persistMgr->getBytes(_widths, sizeof(_widths)); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 338273f338..84c80c73cb 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -123,7 +123,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) cleanup(false); + if (!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); _fonts.persist(persistMgr); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 18966c662c..c371177bac 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -606,7 +606,7 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { // persist layers int numLayers; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); @@ -620,7 +620,7 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { } } - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; _fallbackFont = _font = _deletableFont = NULL; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index bfe050cbe0..6bfff0799e 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -1161,7 +1161,7 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { _sprites.persist(persistMgr); int numForces; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numForces = _forces.getSize(); persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < _forces.getSize(); i++) { @@ -1177,7 +1177,7 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { } int numParticles; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numParticles = _particles.getSize(); persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < _particles.getSize(); i++) { diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 6a8f328349..7b2f117b4f 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -47,7 +47,7 @@ PartForce::~PartForce(void) { ////////////////////////////////////////////////////////////////////////// bool PartForce::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 37f374a3e5..b63a82f926 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -237,7 +237,7 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_exponentialGrowth)); persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *filename = _sprite->getFilename(); persistMgr->transfer(TMEMBER(filename)); } else { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index bdd11ca06a..52490c0710 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1199,7 +1199,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); // buffer - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { persistMgr->transfer(TMEMBER(_bufferSize)); persistMgr->putBytes(_buffer, _bufferSize); @@ -1249,7 +1249,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_unbreakable)); persistMgr->transfer(TMEMBER(_parentScript)); - if (!persistMgr->_saving) _tracingMode = false; + if (!persistMgr->getIsSaving()) _tracingMode = false; return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index c275ebf5af..59ec113d1f 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -448,7 +448,7 @@ bool ScEngine::resetScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) cleanup(); + if (!persistMgr->getIsSaving()) cleanup(); persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currentScript)); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 383b956555..92943f7485 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -730,7 +730,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_textMode)); uint32 pos = 0; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { pos = getPos(); persistMgr->transfer(TMEMBER(pos)); } else { diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 79ba978002..b625fad400 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -486,7 +486,7 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_size)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); } else { if (_size > 0) { diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index e645772b6f..5e01e5e29c 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -383,7 +383,7 @@ bool SXString::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_capacity)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); } else { if (_capacity > 0) { diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 0d8c34e719..6d12c34914 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -748,7 +748,7 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { int size; const char *str; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { size = _valObject.size(); persistMgr->transfer("", &size); _valIter = _valObject.begin(); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 06421e8632..1853d7abfd 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -149,7 +149,7 @@ bool BaseSound::resume() { ////////////////////////////////////////////////////////////////////////// bool BaseSound::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->_saving && _sound) { + if (persistMgr->getIsSaving() && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; @@ -159,7 +159,7 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { _soundFreezePaused = _sound->_freezePaused; } - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { _sFXType = SFX_NONE; _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 252531e4d2..d7e1ae1748 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -350,7 +350,7 @@ void BaseArray::insertAt(int nStartIndex, BaseArray *pNewArray) template bool BaseArray::persist(BasePersistenceManager *persistMgr) { int i, j; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { j = getSize(); persistMgr->transfer("ArraySize", &j); for (i = 0; i < j; i++) { @@ -366,7 +366,7 @@ bool BaseArray::persist(BasePersistenceManager *persistMgr) { add(obj); } } - return STATUS_OK; + return true; } } // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 93e45fb1ff..a6adfca374 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1032,7 +1032,7 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_press)); persistMgr->transfer(TMEMBER(_stayPressed)); - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { _oneTimePress = false; _oneTimePressTime = 0; } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 3d847408b5..e687075a9a 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -844,7 +844,7 @@ bool UIEdit::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_selEnd)); persistMgr->transfer(TMEMBER(_selStart)); - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { _cursorVisible = false; _lastBlinkTime = 0; } diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 81e6769cfd..97fba01201 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -805,7 +805,7 @@ bool VideoTheoraPlayer::resume() { bool VideoTheoraPlayer::persist(BasePersistenceManager *persistMgr) { //BaseClass::persist(persistMgr); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { _savedPos = getMovieTime() * 1000; _savedState = _state; } else { @@ -824,7 +824,7 @@ bool VideoTheoraPlayer::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_looping)); persistMgr->transfer(TMEMBER(_volume)); - if (!persistMgr->_saving && (_savedState != THEORA_STATE_NONE)) { + if (!persistMgr->getIsSaving() && (_savedState != THEORA_STATE_NONE)) { initializeSimple(); } -- cgit v1.2.3 From 5bcc47646451c8c1cfe358ff69f5e7f77336fc91 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 04:37:25 +0200 Subject: WINTERMUTE: Initialize the BaseGame reference in BasePersistenceManager --- engines/wintermute/base/base_persistence_manager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index da38806888..bcdb93a93e 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -59,6 +59,7 @@ BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *sav _offset = 0; _saveStream = NULL; _loadStream = NULL; + _gameRef = inGame; _richBuffer = NULL; _richBufferSize = 0; -- cgit v1.2.3 From 88fe4e3106e4eb7f3c179dfdb3b5a2f4fd3c7e2c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 04:40:31 +0200 Subject: WINTERMUTE: Handle the "language/" subdirectory separately for choice of language. Since we don't have the same launcher the games have, we'll have to avoid including ALL the datafiles, as the localization-dcps are usually intended to work alone. For now, it's hardcoded to only load english. --- engines/wintermute/base/base_file_manager.cpp | 28 ++++++++++++++++++++------- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/file/base_package.cpp | 7 ++++--- engines/wintermute/base/file/base_package.h | 2 ++ 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 5d399c33a1..1ff82d5e18 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -246,7 +246,10 @@ bool BaseFileManager::initPaths() { if (dataSubFolder.exists()) { addPath(PATH_PACKAGE, dataSubFolder); } - + Common::FSNode languageSubFolder = gameData.getChild("language"); + if (languageSubFolder.exists()) { + addPath(PATH_PACKAGE, languageSubFolder); + } return STATUS_OK; } @@ -254,7 +257,7 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { - if (registerPackage((*it).createReadStream())) { + if (registerPackage((*it))) { addPath(PATH_PACKAGE, (*it)); } } @@ -276,8 +279,16 @@ bool BaseFileManager::registerPackages() { for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().contains(".dcp")) continue; + // Avoid registering all the language files + // TODO: Select based on the gameDesc. + if (fileIt->getParent().getName() == "language") { + Common::String parentName = fileIt->getParent().getName(); + Common::String dcpName = fileIt->getName(); + if (fileIt->getName() != "english.dcp") + continue; + } warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); - registerPackage((*fileIt).createReadStream()); + registerPackage((*fileIt)); } } @@ -287,7 +298,7 @@ bool BaseFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +/*bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { @@ -295,12 +306,14 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear return STATUS_OK; } return registerPackage(package, filename); -} +}*/ -bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const Common::String &filename, bool searchSignature) { +bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; - + Common::SeekableReadStream * package = file.createReadStream(); + if (!package) + return STATUS_FAILED; if (searchSignature) { uint32 offset; if (!findPackageSignature(package, &offset)) { @@ -335,6 +348,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(this); + pkg->_fsnode = file; if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 8dfde06f74..f859e39b00 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -75,8 +75,8 @@ private: Common::FSList _packagePaths; // Common::FSList _singlePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); - bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); - bool registerPackage(const Common::String &filename, bool searchSignature = false); + bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); +// bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a0f56ddf83..427f2f46f8 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -86,12 +86,13 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::File *file = _fileManager->openPackage(_name); + Common::SeekableReadStream *stream = _fsnode.createReadStream(); +/* Common::File *file = _fileManager->openPackage(_name); if (!file) { _fileManager->requestCD(_cd, _name, ""); file = _fileManager->openPackage(_name); - } - return file; + }*/ + return stream; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index af180ac7bf..673655a710 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BPACKAGE_H #include "common/stream.h" +#include "common/fs.h" namespace Common { class SeekableReadStream; @@ -43,6 +44,7 @@ public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); + Common::FSNode _fsnode; bool _boundToExe; byte _priority; bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); -- cgit v1.2.3 From 579810d296a355f003b5bfc00aeed00ff7247ec6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:14:38 +0200 Subject: WINTERMUTE: Use hasSuffix instead of contains to verify file-extensions. --- engines/wintermute/base/base_file_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1ff82d5e18..1e3e94c4f4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -277,7 +277,7 @@ bool BaseFileManager::registerPackages() { warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { - if (!fileIt->getName().contains(".dcp")) + if (!fileIt->getName().hasSuffix(".dcp")) continue; // Avoid registering all the language files // TODO: Select based on the gameDesc. -- cgit v1.2.3 From ec7362d13e8edc4ccf64ee004592cb10db8bc6f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:30:22 +0200 Subject: WINTERMUTE: Clean up and comment base_disk_file. --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 76 +++++++++++++------------ engines/wintermute/base/file/base_disk_file.h | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1e3e94c4f4..addce1dea4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -514,7 +514,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - ret = openDiskFile(filename, this); + ret = openDiskFile(filename); if (ret) return ret; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 21f7c7c189..09a83f5768 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -46,43 +46,63 @@ void correctSlashes(char *fileName) { } } -bool diskFileExists(const Common::String& filename) { - // Try directly from SearchMan first - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, filename); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - if ((*it)->getName() == filename) { - return true; - } - } +// Parse a relative path in the game-folder, and if it exists, return a FSNode to it. +static Common::FSNode getNodeForRelativePath(const Common::String& filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + + // Absolute path: TODO: Add specific fallbacks here. if (filename.contains(':')) error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + + // Relative path: if (filename.contains('\\')) { Common::StringTokenizer path(filename, "\\"); - + + // Start traversing relative to the game-data-dir const Common::FSNode gameDataDir(ConfMan.get("path")); Common::FSNode curNode = gameDataDir; + + // Parse all path-elements while (!path.empty()) { + // Get the next path-component by slicing on '\\' Common::String pathPart = path.nextToken(); + // Get the next FSNode in the chain, if it exists as a child from the previous. Common::FSNode nextNode(curNode.getChild(pathPart)); if (nextNode.exists() && nextNode.isReadable()) { curNode = nextNode; } + // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { - if (curNode.exists() && curNode.isReadable()) - return true; - else - return false; + assert(path.empty()); + return curNode; + break; } } } + // Return an invalid FSNode to mark that we didn't find the requested file. + return Common::FSNode(); +} + +bool diskFileExists(const Common::String& filename) { + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + return true; + } + } + // File wasn't found in SearchMan, try to parse the path as a relative path. + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + return true; + } return false; } -Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { +Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first @@ -95,27 +115,11 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil break; } } - // The filename can be an explicit path, thus we need to chop it up, expecting the path the game - // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + // File wasn't found in SearchMan, try to parse the path as a relative path. if (!file) { - if (filename.contains(':')) - error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); - if (filename.contains('\\')) { - Common::StringTokenizer path(filename, "\\"); - - const Common::FSNode gameDataDir(ConfMan.get("path")); - Common::FSNode curNode = gameDataDir; - while (!path.empty()) { - Common::String pathPart = path.nextToken(); - Common::FSNode nextNode(curNode.getChild(pathPart)); - if (nextNode.exists() && nextNode.isReadable()) { - curNode = nextNode; - } - if (!curNode.isDirectory()) { - file = curNode.createReadStream(); - break; - } - } + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + file = searchNode.createReadStream(); } } if (file) { diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 13d5c3e03c..0653b2e854 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -33,7 +33,7 @@ namespace WinterMute { -Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); +Common::SeekableReadStream *openDiskFile(const Common::String &filename); bool diskFileExists(const Common::String& filename); } // end of namespace WinterMute -- cgit v1.2.3 From c59965ad4faca67be0dad554bc291a97f2691dff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:49:01 +0200 Subject: WINTERMUTE: Make sure we don't skip path-components. --- engines/wintermute/base/file/base_disk_file.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 09a83f5768..c03a9b61e7 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -69,14 +69,19 @@ static Common::FSNode getNodeForRelativePath(const Common::String& filename) { Common::String pathPart = path.nextToken(); // Get the next FSNode in the chain, if it exists as a child from the previous. Common::FSNode nextNode(curNode.getChild(pathPart)); + if (!nextNode.exists()) { + // Return an invalid FSNode. + return Common::FSNode(); + } if (nextNode.exists() && nextNode.isReadable()) { curNode = nextNode; } // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { - assert(path.empty()); + if (!path.empty()) { + error("Relative path %s reached a file before the end of the path", filename.c_str()); + } return curNode; - break; } } } -- cgit v1.2.3 From 8be1e095fd6ab78f8f90633d254643f5bb45ffd4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 00:08:39 +0200 Subject: WINTERMUTE: Avoid starting up the engine to perform detection. --- engines/wintermute/base/base_file_manager.cpp | 13 ++-- engines/wintermute/base/base_file_manager.h | 12 ++-- engines/wintermute/base/file/base_package.cpp | 14 ++-- engines/wintermute/base/file/dcpackage.h | 96 +++++++++++++++++++++++++++ engines/wintermute/base/gfx/base_image.cpp | 10 +-- engines/wintermute/dcpackage.h | 96 --------------------------- engines/wintermute/wintermute.cpp | 52 ++++++++++++--- 7 files changed, 164 insertions(+), 129 deletions(-) create mode 100644 engines/wintermute/base/file/dcpackage.h delete mode 100644 engines/wintermute/dcpackage.h (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index addce1dea4..d54fe96854 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_file_entry.h" @@ -37,9 +35,8 @@ #include "engines/wintermute/base/file/base_resources.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/base/file/dcpackage.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/textconsole.h" @@ -58,12 +55,11 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { +BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) { initPaths(); registerPackages(); } - ////////////////////////////////////////////////////////////////////// BaseFileManager::~BaseFileManager() { cleanup(); @@ -207,6 +203,9 @@ bool BaseFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { + if (!_gameRef) // This function only works when the game-registry is loaded + return STATUS_FAILED; + AnsiString pathList; int numPaths; @@ -506,6 +505,8 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + if (!_gameRef) + error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index f859e39b00..cacdb8bf2d 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -29,20 +29,17 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/file/base_package.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" - -namespace Common { -class File; -} +#include "common/file.h" namespace WinterMute { class BaseFile; class BaseFileEntry; -class BaseFileManager: BaseClass { +class BaseGame; +class BasePackage; +class BaseFileManager { public: bool cleanup(); @@ -77,6 +74,7 @@ private: bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); // bool registerPackage(const Common::String &filename, bool searchSignature = false); + BaseGame *_gameRef; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 427f2f46f8..1706a7a50b 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -57,10 +57,10 @@ BasePackage::~BasePackage() { ////////////////////////////////////////////////////////////////////////// bool BasePackage::open() { - if (_file) return STATUS_OK; + if (_file) return true; else { _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; + return _file ? true : false; } } @@ -69,18 +69,18 @@ bool BasePackage::open() { bool BasePackage::close() { delete _file; _file = NULL; - return STATUS_OK; + return true; } ////////////////////////////////////////////////////////////////////////// bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { bool ret; - if (DID_FAIL(ret = open())) return ret; + if (!(ret = open())) return ret; else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; + if (file->seek(offset, SEEK_SET)) return false; + if (file->read(buffer, size) != 1) return false; + else return true; } } diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h new file mode 100644 index 0000000000..5e47edba56 --- /dev/null +++ b/engines/wintermute/base/file/dcpackage.h @@ -0,0 +1,96 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef _DCPACKAGE_H_ +#define _DCPACKAGE_H_ + + +#define PACKAGE_MAGIC_1 0xDEC0ADDE +#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" +#define PACKAGE_VERSION 0x00000200 +#define PACKAGE_EXTENSION "dcp" + +#include "common/stream.h" + +namespace WinterMute { + +struct TPackageHeader { + uint32 _magic1; + uint32 _magic2; + uint32 _packageVersion; + uint32 _gameVersion; + byte _priority; + byte _cd; + bool _masterIndex; + uint32 _creationTime; + char _desc[100]; + uint32 _numDirs; + // TODO: Move this out of the header. + void readFromStream(Common::ReadStream *stream) { + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); + + _gameVersion = stream->readUint32LE(); + + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + _creationTime = stream->readUint32LE(); + + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); + } +}; + +/* +v2: uint32 DirOffset + + +Dir: byte NameLength + char Name [NameLength] + byte CD; + uint32 NumEntries + + +Entry: byte NameLength + char Name [NameLength] + uint32 Offset + uint32 Length + uint32 CompLength + uint32 Flags +v2: uint32 TimeDate1 + uint32 TimeDate2 // not used + +*/ + +} // end of namespace WinterMute + +#endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index bdc7cb76e2..2c18b64110 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -82,14 +82,14 @@ bool BaseImage::loadFile(const Common::String &filename) { } _filename = filename; Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) return STATUS_FAILED; + if (!file) return false; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); _fileManager->closeFile(file); - return STATUS_OK; + return true; } byte BaseImage::getAlphaAt(int x, int y) { @@ -113,7 +113,7 @@ bool BaseImage::saveBMPFile(const char *filename) { if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; else return STATUS_FAILED; #endif - return STATUS_FAILED; + return false; } @@ -133,7 +133,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { return STATUS_OK; } else return STATUS_FAILED; #endif - return STATUS_FAILED; + return false; } @@ -258,7 +258,7 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { _deletableSurface = NULL; } _surface = _deletableSurface = temp.scale(newWidth, newHeight); - return STATUS_OK; + return true; } } // end of namespace WinterMute diff --git a/engines/wintermute/dcpackage.h b/engines/wintermute/dcpackage.h deleted file mode 100644 index 5e47edba56..0000000000 --- a/engines/wintermute/dcpackage.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef _DCPACKAGE_H_ -#define _DCPACKAGE_H_ - - -#define PACKAGE_MAGIC_1 0xDEC0ADDE -#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" -#define PACKAGE_VERSION 0x00000200 -#define PACKAGE_EXTENSION "dcp" - -#include "common/stream.h" - -namespace WinterMute { - -struct TPackageHeader { - uint32 _magic1; - uint32 _magic2; - uint32 _packageVersion; - uint32 _gameVersion; - byte _priority; - byte _cd; - bool _masterIndex; - uint32 _creationTime; - char _desc[100]; - uint32 _numDirs; - // TODO: Move this out of the header. - void readFromStream(Common::ReadStream *stream) { - _magic1 = stream->readUint32LE(); - _magic2 = stream->readUint32LE(); - _packageVersion = stream->readUint32LE(); - - _gameVersion = stream->readUint32LE(); - - _priority = stream->readByte(); - _cd = stream->readByte(); - _masterIndex = stream->readByte(); - stream->readByte(); // To align the next byte... - - _creationTime = stream->readUint32LE(); - - stream->read(_desc, 100); - _numDirs = stream->readUint32LE(); - } -}; - -/* -v2: uint32 DirOffset - - -Dir: byte NameLength - char Name [NameLength] - byte CD; - uint32 NumEntries - - -Entry: byte NameLength - char Name [NameLength] - uint32 Offset - uint32 Length - uint32 CompLength - uint32 Flags -v2: uint32 TimeDate1 - uint32 TimeDate2 // not used - -*/ - -} // end of namespace WinterMute - -#endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 5695e5e8df..7089b57216 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -343,15 +343,51 @@ void WinterMuteEngine::deinit() { bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { bool retVal = false; caption = name = "(invalid)"; - + Common::SeekableReadStream *stream = NULL; // Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it - WinterMuteEngine *engine = new WinterMuteEngine(); - - engine->_game->initialize1(); - engine->_game->_fileManager->registerPackages(fslist); - if (engine->_game->loadSettings("startup.settings")) { + BaseFileManager *fileMan = new BaseFileManager(); + fileMan->registerPackages(fslist); + stream = fileMan->openFile("startup.settings", false, false); + + // The process is as follows: Check the "GAME=" tag in startup.settings, to decide where the + // game-settings are (usually "default.game"), then look into the game-settings to find + // the NAME = and CAPTION = tags, to use them to generate a gameid and extras-field + + Common::String settingsGameFile = "default.game"; + // If the stream-open failed, lets at least attempt to open the default game file afterwards + // so, we don't call it a failure yet. + if (stream) { + while (!stream->eos() && !stream->err()) { + Common::String line = stream->readLine(); + line.trim(); // Get rid of indentation + // Expect "SETTINGS {" or comment, or empty line + if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) + continue; + else { + // We are looking for "GAME =" + Common::StringTokenizer token(line, "="); + Common::String key = token.nextToken(); + Common::String value = token.nextToken(); + if (value.size() == 0) + continue; + if (value[0] == '\"') + value.deleteChar(0); + else + continue; + if (value.lastChar() == '\"') + value.deleteLastChar(); + if (key == "GAME") { + settingsGameFile = value; + break; + } + } + } + } + + delete stream; + stream = fileMan->openFile(settingsGameFile, false, false); + if (stream) { // We do some manual parsing here, as the engine needs gfx to be initalized to do that. - Common::SeekableReadStream *stream = engine->_game->_fileManager->openFile((engine->_game->_settingsGameFile ? engine->_game->_settingsGameFile : "default.game"), false, false); while (!stream->eos() && !stream->err()) { Common::String line = stream->readLine(); line.trim(); // Get rid of indentation @@ -381,7 +417,7 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String } delete stream; } - delete engine; + delete fileMan; return retVal; } -- cgit v1.2.3 From 7521d0f26545381a740307d3a1d2f52e53462bfa Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 00:31:12 +0200 Subject: WINTERMUTE: Cleanup in BaseFileManager --- engines/wintermute/base/base_file_manager.cpp | 62 ++++++++------------------- engines/wintermute/base/base_file_manager.h | 6 +-- 2 files changed, 22 insertions(+), 46 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index d54fe96854..3317b01c6f 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -31,14 +31,14 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_resources.h" +#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/file/dcpackage.h" -#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" +#include "common/tokenizer.h" #include "common/textconsole.h" #include "common/util.h" #include "common/config-manager.h" @@ -96,7 +96,6 @@ bool BaseFileManager::cleanup() { -#define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; @@ -108,15 +107,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz return NULL; } - /* - if (File->GetSize() > MAX_FILE_SIZE) { - _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - buffer = new byte[file->size() + 1]; if (buffer == NULL) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); @@ -207,39 +197,36 @@ bool BaseFileManager::initPaths() { return STATUS_FAILED; AnsiString pathList; - int numPaths; // single files paths pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - error("BaseFileManager::initPaths - Game wants to add customPath: %s", path); // TODO -// addPath(PATH_SINGLE, path); + Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); +// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); + while (!entries->empty()) { + Common::String path = entries->nextToken(); + if (path.size() > 0) { + error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO + // addPath(PATH_SINGLE, path); } - delete[] path; - path = NULL; } -// addPath(PATH_SINGLE, ".\\"); + delete entries; + entries = NULL; // package files paths const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path); // TODO -// addPath(PATH_PACKAGE, path); + entries = new Common::StringTokenizer(pathList, ";"); + while (!entries->empty()) { + Common::String path = entries->nextToken(); + if (path.size() > 0) { + error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO + // addPath(PATH_SINGLE, path); } - delete[] path; - path = NULL; } + delete entries; + entries = NULL; Common::FSNode dataSubFolder = gameData.getChild("data"); if (dataSubFolder.exists()) { @@ -296,17 +283,6 @@ bool BaseFileManager::registerPackages() { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -/*bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { - Common::File *package = new Common::File(); - package->open(filename); - if (!package->isOpen()) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return STATUS_OK; - } - return registerPackage(package, filename); -}*/ - bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index cacdb8bf2d..776fc32df1 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -70,15 +70,15 @@ private: bool registerPackages(); Common::SeekableReadStream *openFileRaw(const Common::String &filename); Common::FSList _packagePaths; -// Common::FSList _singlePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); -// bool registerPackage(const Common::String &filename, bool searchSignature = false); - BaseGame *_gameRef; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; Common::HashMap::iterator _filesIter; + // This class is intentionally not a subclass of Base, as it needs to be used by + // the detector too, without launching the entire engine: + BaseGame *_gameRef; }; } // end of namespace WinterMute -- cgit v1.2.3 From ab8d13ee5806f7d9cf6e352482934ad371a55e11 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:20:17 +0200 Subject: WINTERMUTE: Change the DCP-file access to work as an Common::Archive. --- engines/wintermute/base/base_file_manager.cpp | 236 ++-------------------- engines/wintermute/base/base_file_manager.h | 12 +- engines/wintermute/base/file/BPkgFile.cpp | 107 ---------- engines/wintermute/base/file/BPkgFile.h | 49 ----- engines/wintermute/base/file/base_file_entry.cpp | 53 +++++ engines/wintermute/base/file/base_file_entry.h | 6 +- engines/wintermute/base/file/base_package.cpp | 245 ++++++++++++++++++----- engines/wintermute/base/file/base_package.h | 58 ++++-- engines/wintermute/module.mk | 1 - 9 files changed, 320 insertions(+), 447 deletions(-) delete mode 100644 engines/wintermute/base/file/BPkgFile.cpp delete mode 100644 engines/wintermute/base/file/BPkgFile.h (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 3317b01c6f..2661081528 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -29,13 +29,10 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" -#include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/file/dcpackage.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/tokenizer.h" @@ -71,31 +68,18 @@ bool BaseFileManager::cleanup() { // delete registered paths _packagePaths.clear(); - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - // close open files for (uint32 i = 0; i < _openFiles.size(); i++) { delete _openFiles[i]; } _openFiles.clear(); - // delete packages - for (uint32 i = 0; i < _packages.size(); i++) - delete _packages[i]; _packages.clear(); return STATUS_OK; } - - ////////////////////////////////////////////////////////////////////// byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; @@ -149,19 +133,6 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { - // unmount all non-local packages - for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cd > 0) _packages[i]->close(); - } - - - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { if (!path.exists()) @@ -189,8 +160,6 @@ bool BaseFileManager::reloadPaths() { return initPaths(); } - -#define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { if (!_gameRef) // This function only works when the game-registry is loaded @@ -248,7 +217,6 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { } } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return true; } @@ -278,177 +246,44 @@ bool BaseFileManager::registerPackages() { } } - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); +// debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { - uint32 absoluteOffset = 0; - bool boundToExe = false; - Common::SeekableReadStream * package = file.createReadStream(); - if (!package) - return STATUS_FAILED; - if (searchSignature) { - uint32 offset; - if (!findPackageSignature(package, &offset)) { - delete package; - return STATUS_OK; - } else { - package->seek(offset, SEEK_SET); - absoluteOffset = offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); - if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete package; - return STATUS_OK; - } - - if (hdr._packageVersion != PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); - } - - // new in v2 - if (hdr._packageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = package->readUint32LE(); - dirOffset += absoluteOffset; - package->seek(dirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr._numDirs; i++) { - BasePackage *pkg = new BasePackage(this); - pkg->_fsnode = file; - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = package->readByte(); - pkg->_name = new char[nameLength]; - package->read(pkg->_name, nameLength); - pkg->_cd = package->readByte(); - pkg->_priority = hdr._priority; - - if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk - _packages.push_back(pkg); - - - // read file entries - uint32 numFiles = package->readUint32LE(); - - for (uint32 j = 0; j < numFiles; j++) { - char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; + PackageSet *pack = new PackageSet(file, filename, searchSignature); + _packages.add(file.getName(), pack, pack->getPriority() , true); - nameLength = package->readByte(); - name = new char[nameLength]; - package->read(name, nameLength); - - // v2 - xor name - if (hdr._packageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - Common::String upcName = name; - upcName.toUppercase(); - delete[] name; - name = NULL; - - offset = package->readUint32LE(); - offset += absoluteOffset; - length = package->readUint32LE(); - compLength = package->readUint32LE(); - flags = package->readUint32LE(); - - if (hdr._packageVersion == PACKAGE_VERSION) { - timeDate1 = package->readUint32LE(); - timeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(upcName.c_str()); - if (_filesIter == _files.end()) { - BaseFileEntry *file = new BaseFileEntry(); - file->_package = pkg; - file->_offset = offset; - file->_length = length; - file->_compressedLength = compLength; - file->_flags = flags; - - _files[upcName.c_str()] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = offset; - _filesIter->_value->_length = length; - _filesIter->_value->_compressedLength = compLength; - _filesIter->_value->_flags = flags; - } - } - } - } - - - delete package; return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// -Common::File *BaseFileManager::openPackage(const Common::String &name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - Common::File *ret = new Common::File(); - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - Common::String packageName = (*it).getName(); - if (packageName == (name + ".dcp")) - ret->open((*it)); - if (ret->isOpen()) { - return ret; - } - } - Common::String filename = Common::String::format("%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; +Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &filename) { + Common::String upcName = filename; + upcName.toUppercase(); + Common::SeekableReadStream *file = NULL; + char fileName[MAX_PATH_LENGTH]; + strcpy(fileName, upcName.c_str()); + + // correct slashes + for (int32 i = 0; i < upcName.size(); i++) { + if (upcName[i] == '/') + upcName.setChar('\\', (uint32)i); } - warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { - Common::String upc_name = filename; - upc_name.toUppercase(); - - BaseFileEntry *ret = NULL; - _filesIter = _files.find(upc_name.c_str()); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - return ret; + Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + file = entry->createReadStream(); + return file; } bool BaseFileManager::hasFile(const Common::String &filename) { if (diskFileExists(filename)) return true; - if (getPackageEntry(filename)) + if (_packages.hasFile(filename)) return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. if (BaseResources::hasFile(filename)) return true; return false; - return true; } ////////////////////////////////////////////////////////////////////////// @@ -495,7 +330,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f if (ret) return ret; - ret = openPkgFile(filename, this); + ret = openPkgFile(filename); if (ret) return ret; @@ -507,37 +342,4 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return NULL; } - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 776fc32df1..89d1e5b46b 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -35,10 +35,7 @@ #include "common/file.h" namespace WinterMute { -class BaseFile; -class BaseFileEntry; class BaseGame; -class BasePackage; class BaseFileManager { public: bool cleanup(); @@ -55,10 +52,6 @@ public: bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); // Used only for detection bool registerPackages(const Common::FSList &fslist); - // Used by BasePackage only - BaseFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openPackage(const Common::String &name); - bool requestCD(int cd, char *packageFile, const char *filename); private: typedef enum { PATH_PACKAGE, @@ -69,13 +62,12 @@ private: bool addPath(TPathType type, const Common::FSNode &path); bool registerPackages(); Common::SeekableReadStream *openFileRaw(const Common::String &filename); + Common::SeekableReadStream *openPkgFile(const Common::String &filename); Common::FSList _packagePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); - Common::Array _packages; + Common::SearchSet _packages; Common::Array _openFiles; - Common::HashMap _files; - Common::HashMap::iterator _filesIter; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: BaseGame *_gameRef; diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp deleted file mode 100644 index be37571901..0000000000 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "common/util.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace WinterMute { - -// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size -// as such it is not renamed to follow the convention of the rest of the files. - -// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. -class CBPkgFile : public Common::SeekableReadStream { - uint32 _size; - Common::SeekableReadStream *_stream; -public: - CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { - delete _stream; - } - virtual uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } - virtual bool eos() const { - return _stream->eos(); - } - virtual int32 pos() const { - return _stream->pos(); - } - virtual int32 size() const { - return _size; - } - virtual bool seek(int32 offset, int whence = SEEK_SET) { - return _stream->seek(offset, whence); - } -}; - -Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager) { - BaseFileEntry *fileEntry; - Common::SeekableReadStream *file = NULL; - char fileName[MAX_PATH_LENGTH]; - strcpy(fileName, filename.c_str()); - - // correct slashes - for (uint32 i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '/') fileName[i] = '\\'; - } - - fileEntry = fileManager->getPackageEntry(fileName); - if (!fileEntry) return NULL; - - file = fileEntry->_package->getFilePointer(); - if (!file) return NULL; - - // TODO: Cleanup - bool compressed = (fileEntry->_compressedLength != 0); - /* _size = fileEntry->_length; */ - - if (compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); - } else { - file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); - } - if (file->size() == 0) { - file = new CBPkgFile(file, fileEntry->_length); - } - - file->seek(0); - - return file; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h deleted file mode 100644 index ca1b1f837d..0000000000 --- a/engines/wintermute/base/file/BPkgFile.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPKGFILE_H -#define WINTERMUTE_BPKGFILE_H - -#include "engines/wintermute/base/file/base_file_entry.h" - -// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size -// as such it is not renamed to follow the convention of the rest of the files. - -namespace Common { -class SeekableReadStream; -class File; -} - -namespace WinterMute { - -class BaseFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 43527f9fc0..5032650704 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -27,8 +27,61 @@ */ #include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/base_package.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" namespace WinterMute { +// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. +class CBPkgFile : public Common::SeekableReadStream { + uint32 _size; + Common::SeekableReadStream *_stream; +public: + CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} + virtual ~CBPkgFile() { + delete _stream; + } + virtual uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } + virtual bool eos() const { + return _stream->eos(); + } + virtual int32 pos() const { + return _stream->pos(); + } + virtual int32 size() const { + return _size; + } + virtual bool seek(int32 offset, int whence = SEEK_SET) { + return _stream->seek(offset, whence); + } +}; + +Common::SeekableReadStream *BaseFileEntry::createReadStream() const { + Common::SeekableReadStream *file = _package->getFilePointer(); + if (!file) return NULL; + + // TODO: Cleanup + bool compressed = (_compressedLength != 0); + /* _size = fileEntry->_length; */ + + if (compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); + } else { + file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); + } + if (file->size() == 0) { + file = new CBPkgFile(file, _length); + } + + file->seek(0); + + return file; +} ////////////////////////////////////////////////////////////////////////// BaseFileEntry::BaseFileEntry(){ diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 086a70e7ed..b94a6cd9fc 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -29,14 +29,18 @@ #ifndef WINTERMUTE_BFILEENTRY_H #define WINTERMUTE_BFILEENTRY_H +#include "common/archive.h" #include "common/str.h" +#include "common/stream.h" namespace WinterMute { class BasePackage; -class BaseFileEntry { +class BaseFileEntry : public Common::ArchiveMember { public: + virtual Common::SeekableReadStream *createReadStream() const; + virtual Common::String getName() const { return _filename; } uint32 _timeDate2; uint32 _timeDate1; uint32 _flags; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 1706a7a50b..6987cad3e6 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -27,78 +27,229 @@ */ #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/dcpackage.h" +#include "engines/wintermute/wintermute.h" #include "common/file.h" #include "common/stream.h" +#include "common/debug.h" namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -BasePackage::BasePackage(BaseFileManager *fileMan)/*: BaseClass(inGame) */{ - _file = NULL; - _name = NULL; +BasePackage::BasePackage() { + _name = ""; _cd = 0; _priority = 0; _boundToExe = false; - _fileManager = fileMan; } +Common::SeekableReadStream *BasePackage::getFilePointer() { + Common::SeekableReadStream *stream = _fsnode.createReadStream(); -////////////////////////////////////////////////////////////////////////// -BasePackage::~BasePackage() { - if (_name) delete [] _name; - closeFilePointer(_file); + return stream; } - -////////////////////////////////////////////////////////////////////////// -bool BasePackage::open() { - if (_file) return true; - else { - _file = getFilePointer(); - return _file ? true : false; +static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + } + return false; + } +PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { + uint32 absoluteOffset = 0; + _priority = 0; + bool boundToExe = false; + Common::SeekableReadStream *stream = file.createReadStream(); + if (!stream) + return; + if (searchSignature) { + uint32 offset; + if (!findPackageSignature(stream, &offset)) { + delete stream; + return; + } else { + stream->seek(offset, SEEK_SET); + absoluteOffset = offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(stream); + if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete stream; + return; + } + + if (hdr._packageVersion != PACKAGE_VERSION) { + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); + } + _priority = hdr._priority; + // new in v2 + if (hdr._packageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = stream->readUint32LE(); + dirOffset += absoluteOffset; + stream->seek(dirOffset, SEEK_SET); + } + assert(hdr._numDirs == 1); + for (uint32 i = 0; i < hdr._numDirs; i++) { + BasePackage *pkg = new BasePackage(); + if (!pkg) return; + pkg->_fsnode = file; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = stream->readByte(); + char *pkgName = new char[nameLength]; + stream->read(pkgName, nameLength); + pkg->_name = pkgName; + pkg->_cd = stream->readByte(); + pkg->_priority = hdr._priority; + delete[] pkgName; + pkgName = NULL; + + if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 numFiles = stream->readUint32LE(); + + for (uint32 j = 0; j < numFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = stream->readByte(); + name = new char[nameLength]; + stream->read(name, nameLength); + + // v2 - xor name + if (hdr._packageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); + warning( "Package contains %s", name); + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + Common::String upcName = name; + upcName.toUppercase(); + delete[] name; + name = NULL; + + offset = stream->readUint32LE(); + offset += absoluteOffset; + length = stream->readUint32LE(); + compLength = stream->readUint32LE(); + flags = stream->readUint32LE(); + + if (hdr._packageVersion == PACKAGE_VERSION) { + timeDate1 = stream->readUint32LE(); + timeDate2 = stream->readUint32LE(); + } + _filesIter = _files.find(upcName.c_str()); + if (_filesIter == _files.end()) { + BaseFileEntry *fileEntry = new BaseFileEntry(); + fileEntry->_package = pkg; + fileEntry->_offset = offset; + fileEntry->_length = length; + fileEntry->_compressedLength = compLength; + fileEntry->_flags = flags; + + _files[upcName.c_str()] = Common::ArchiveMemberPtr(fileEntry); + } else { + // current package has higher priority than the registered + // TODO: This cast might be a bit ugly. + BaseFileEntry *filePtr = (BaseFileEntry*) &*(_filesIter->_value); + if (pkg->_priority > filePtr->_package->_priority) { + filePtr->_package = pkg; + filePtr->_offset = offset; + filePtr->_length = length; + filePtr->_compressedLength = compLength; + filePtr->_flags = flags; + } + } + } + } + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + delete stream; +} -////////////////////////////////////////////////////////////////////////// -bool BasePackage::close() { - delete _file; - _file = NULL; - return true; +PackageSet::~PackageSet() { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + delete *it; + } + _packages.clear(); } +bool PackageSet::hasFile(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return (it != _files.end()); +} -////////////////////////////////////////////////////////////////////////// -bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (!(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return false; - if (file->read(buffer, size) != 1) return false; - else return true; +int PackageSet::listMembers(Common::ArchiveMemberList &list) const { + Common::HashMap::const_iterator it = _files.begin(); + Common::HashMap::const_iterator end = _files.end(); + int count = 0; + for (; it != end; ++it) { + const Common::ArchiveMemberPtr ptr(it->_value); + list.push_back(ptr); + count++; } + return count; } -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::SeekableReadStream *stream = _fsnode.createReadStream(); -/* Common::File *file = _fileManager->openPackage(_name); - if (!file) { - _fileManager->requestCD(_cd, _name, ""); - file = _fileManager->openPackage(_name); - }*/ - return stream; +const Common::ArchiveMemberPtr PackageSet::getMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return Common::ArchiveMemberPtr(it->_value); } -////////////////////////////////////////////////////////////////////////// -void BasePackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; +Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + if (it != _files.end()) + return it->_value->createReadStream(); + return NULL; } } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 673655a710..b9a7bc5934 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -29,32 +29,60 @@ #ifndef WINTERMUTE_BPACKAGE_H #define WINTERMUTE_BPACKAGE_H +#include "common/archive.h" #include "common/stream.h" #include "common/fs.h" -namespace Common { -class SeekableReadStream; -} - namespace WinterMute { -class BaseFileManager; class BasePackage { - BaseFileManager *_fileManager; public: Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - Common::FSNode _fsnode; bool _boundToExe; byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; + Common::String _name; int _cd; - Common::SeekableReadStream *_file; - BasePackage(BaseFileManager *fileMan); - ~BasePackage(); + BasePackage(); +}; + +class PackageSet : public Common::Archive { +public: + virtual ~PackageSet(); + + PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); + /** + * Check if a member with the given name is present in the Archive. + * Patterns are not allowed, as this is meant to be a quick File::exists() + * replacement. + */ + virtual bool hasFile(const Common::String &name) const; + + /** + * Add all members of the Archive to list. + * Must only append to list, and not remove elements from it. + * + * @return the number of names added to list + */ + virtual int listMembers(Common::ArchiveMemberList &list) const; + + /** + * Returns a ArchiveMember representation of the given file. + */ + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; + + /** + * Create a stream bound to a member with the specified name in the + * archive. If no member with this name exists, 0 is returned. + * @return the newly created input stream + */ + virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + + int getPriority() const { return _priority; } +private: + byte _priority; + Common::Array _packages; + Common::HashMap _files; + Common::HashMap::iterator _filesIter; }; } // end of namespace WinterMute diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 3ad30cf66b..02ba08f255 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -44,7 +44,6 @@ MODULE_OBJS := \ base/file/base_package.o \ base/file/base_resources.o \ base/file/base_save_thumb_file.o \ - base/file/BPkgFile.o \ base/font/base_font_bitmap.o \ base/font/base_font_truetype.o \ base/font/base_font.o \ -- cgit v1.2.3 From b05b6210b73d47461de9392c4936a5cb4dde57e1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:32:54 +0200 Subject: WINTERMUTE: Forgot to add this change to last commit (SQUASHME) --- engines/wintermute/base/file/base_disk_file.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index c03a9b61e7..35546b0001 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/stream.h" -- cgit v1.2.3 From 28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:33:24 +0200 Subject: WINTERMUTE: Move SaveGame-file-saving handling over to BasePersistenceManager --- engines/wintermute/base/base_file_manager.cpp | 21 --------------------- engines/wintermute/base/base_file_manager.h | 3 --- .../wintermute/base/base_persistence_manager.cpp | 16 ++++++++++++++-- engines/wintermute/base/base_persistence_manager.h | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 2661081528..156aff61fe 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -112,27 +112,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz return buffer; } -Common::SeekableReadStream *BaseFileManager::loadSaveGame(const Common::String &filename) { - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::InSaveFile *file = saveMan->openForLoading(filename); - return file; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { - // TODO - warning("Implement SaveFile"); - - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - file->finalize(); - delete file; - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { if (!path.exists()) diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 89d1e5b46b..e3c20378bb 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -43,13 +43,10 @@ public: bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); BaseFileManager(BaseGame *inGame = NULL); virtual ~BaseFileManager(); - // Used only by BasePersistenceManager - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); // Used only for detection bool registerPackages(const Common::FSList &fslist); private: diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bcdb93a93e..5f8a2114c1 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -359,8 +359,20 @@ bool BasePersistenceManager::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::saveFile(const char *filename) { - return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +bool BasePersistenceManager::saveFile(const Common::String &filename) { + byte *prefixBuffer = _richBuffer; + uint32 prefixSize = _richBufferSize; + byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); + uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + bool retVal = !file->err(); + file->finalize(); + delete file; + return retVal; } diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index a59f797668..78d3230c47 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -47,7 +47,7 @@ public: char *_savedDescription; Common::String _savePrefix; Common::String _savedName; - bool saveFile(const char *filename); + bool saveFile(const Common::String &filename); uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); -- cgit v1.2.3 From 45c5eb5cab069ea9ca4302a637f4621d460c790d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 05:08:13 +0200 Subject: WINTERMUTE: Privatize/Protect variables that don't need to be public. --- engines/wintermute/ad/ad_game.h | 60 +++--- engines/wintermute/ad/ad_node_state.cpp | 2 +- engines/wintermute/base/base.h | 4 +- engines/wintermute/base/base_fader.h | 1 + engines/wintermute/base/base_game.cpp | 9 +- engines/wintermute/base/base_game.h | 227 +++++++++++---------- engines/wintermute/base/base_object.h | 67 +++--- .../wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/base_persistence_manager.h | 2 +- engines/wintermute/base/base_save_thumb_helper.h | 1 + engines/wintermute/base/base_string_table.cpp | 12 +- engines/wintermute/base/base_string_table.h | 4 +- .../wintermute/base/file/base_save_thumb_file.cpp | 6 +- engines/wintermute/base/font/base_font_bitmap.h | 3 +- engines/wintermute/base/gfx/base_renderer.h | 18 +- engines/wintermute/base/gfx/base_surface.h | 12 +- engines/wintermute/base/particles/part_emitter.h | 85 ++++---- engines/wintermute/base/scriptables/script.h | 18 +- .../wintermute/base/scriptables/script_ext_array.h | 1 + .../wintermute/base/scriptables/script_ext_date.h | 2 +- .../base/scriptables/script_ext_mem_buffer.h | 3 +- .../base/scriptables/script_ext_object.h | 1 - engines/wintermute/base/scriptables/script_value.h | 2 +- engines/wintermute/base/sound/base_sound_buffer.h | 7 +- engines/wintermute/wintermute.cpp | 2 +- 25 files changed, 279 insertions(+), 272 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index b52fd2832f..5136ed09d3 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -54,13 +54,9 @@ public: virtual bool displayDebugInfo(); - virtual bool initAfterLoad(); static void afterLoadScene(void *scene, void *data); - bool _smartItemCursor; - - BaseArray _speechDirs; bool addSpeechDir(const char *dir); bool removeSpeechDir(const char *dir); char *findSpeechFile(char *StringID); @@ -71,18 +67,13 @@ public: virtual bool resetContent(); bool addItem(AdItem *item); AdItem *getItemByName(const char *name); - BaseArray _items; + AdObject *_inventoryOwner; bool isItemTaken(char *itemName); bool registerInventory(AdInventory *inv); bool unregisterInventory(AdInventory *inv); - - AdObject *_invObject; - BaseArray _inventories; virtual bool displayContent(bool update = true, bool displayAll = false); - char *_debugStartupScene; - char *_startupScene; - bool _initialScene; + bool gameResponseUsed(int ID); bool addGameResponse(int ID); bool resetResponse(int ID); @@ -97,6 +88,7 @@ public: AdSceneState *getSceneState(const char *filename, bool saving); BaseViewport *_sceneViewport; + int _texItemLifeTime; int _texWalkLifeTime; int _texStandLifeTime; @@ -106,12 +98,9 @@ public: virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); bool scheduleChangeScene(const char *filename, bool fadeIn); - char *_scheduledScene; - bool _scheduledFadeIn; void setPrevSceneName(const char *name); void setPrevSceneFilename(const char *name); - char *_prevSceneName; - char *_prevSceneFilename; + virtual bool loadGame(const char *filename); AdItem *_selectedItem; bool cleanup(); @@ -119,9 +108,9 @@ public: void finishSentences(); bool showCursor(); + TGameStateEx _stateEx; - AdResponseBox *_responseBox; - AdInventoryBox *_inventoryBox; + bool displaySentences(bool frozen); void addSentence(AdSentence *sentence); bool changeScene(const char *filename, bool fadeIn); @@ -131,14 +120,8 @@ public: bool initLoop(); AdGame(); virtual ~AdGame(); - BaseArray _objects; - BaseArray _sentences; - BaseArray _sceneStates; - BaseArray _dlgPendingBranches; - - BaseArray _responsesBranch; - BaseArray _responsesGame; + BaseArray _objects; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); @@ -146,14 +129,37 @@ public: bool loadItemsFile(const char *filename, bool merge = false); bool loadItemsBuffer(byte *buffer, bool merge = false); - - virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); - // scripting interface virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); bool validMouse(); +private: + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + + AdObject *_invObject; + BaseArray _inventories; + char *_scheduledScene; + bool _scheduledFadeIn; + char *_prevSceneName; + char *_prevSceneFilename; + char *_debugStartupScene; + char *_startupScene; + bool _initialScene; + bool _smartItemCursor; + BaseArray _speechDirs; + BaseArray _items; + + BaseArray _sentences; + + BaseArray _sceneStates; + BaseArray _dlgPendingBranches; + + BaseArray _responsesBranch; + BaseArray _responsesGame; + + AdResponseBox *_responseBox; + AdInventoryBox *_inventoryBox; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index f8196e96b7..6212274d03 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -131,7 +131,7 @@ char *AdNodeState::getCaption(int caseVal) { bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool saving) { if (!entity) return STATUS_FAILED; - // hack! + // HACK! if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; if (saving) { diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index 0265ce97d5..8c6aad12e6 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -49,10 +49,10 @@ public: bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); BaseClass(); - BaseGame *_gameRef; BaseClass(BaseGame *GameOwner); virtual ~BaseClass(); - + BaseGame *_gameRef; +protected: Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; /* std::map _editorProps; diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 36dd8a1d53..4401bd0ebd 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -46,6 +46,7 @@ public: DECLARE_PERSISTENT(BaseFader, BaseObject) BaseFader(BaseGame *inGame); virtual ~BaseFader(); +private: bool _active; byte _red; byte _green; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 301f79691d..fcf45f18f2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -104,7 +104,6 @@ BaseGame::BaseGame(): BaseObject(this) { _debugLogFile = NULL; _debugDebugMode = false; - _debugAbsolutePathWarning = true; _debugShowFPS = false; _systemFont = NULL; @@ -180,7 +179,7 @@ BaseGame::BaseGame(): BaseObject(this) { _compressedSavegames = true; _editorMode = false; - _doNotExpandStrings = false; + //_doNotExpandStrings = false; _engineLogCallback = NULL; _engineLogCallbackData = NULL; @@ -3241,7 +3240,6 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - _debugAbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; @@ -3259,7 +3257,6 @@ bool BaseGame::loadGame(const char *filename) { getDebugMgr()->onGameInit(); load_finish: - _debugAbsolutePathWarning = true; _indicatorDisplay = false; delete pm; @@ -3555,7 +3552,6 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_activeObject)); persistMgr->transfer(TMEMBER(_capturedObject)); persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_doNotExpandStrings)); persistMgr->transfer(TMEMBER(_editorMode)); persistMgr->transfer(TMEMBER(_fader)); persistMgr->transfer(TMEMBER(_freezeLevel)); @@ -3838,14 +3834,11 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; - _debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(filename))) { - _debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _debugAbsolutePathWarning = true; strcpy(buffer, pm->_savedDescription); delete pm; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 4a5adb4e39..34dec89d20 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -105,54 +105,21 @@ public: TTextEncoding _textEncoding; bool _textRTL; - BaseSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - virtual bool resetContent(); void DEBUG_DumpClassRegistry(); bool setWaitCursor(const char *filename); - char *_localSaveDir; - bool _saveDirChecked; - int _indicatorProgress; -protected: - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - BaseSurface *_saveLoadImage; - bool displayIndicator(); + int _indicatorProgress; // TODO: Hide - bool _reportTextureFormat; -public: int _thumbnailWidth; int _thumbnailHeight; - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; bool _editorMode; - - bool _doNotExpandStrings; void getOffset(int *offsetX, int *offsetY); void setOffset(int offsetX, int offsetY); int getSequence(); + int _offsetY; int _offsetX; float _offsetPercentX; @@ -181,20 +148,16 @@ public: BaseSurfaceStorage *_surfaceStorage; BaseFontStorage *_fontStorage; BaseGame(); - virtual ~BaseGame(); + void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *filename = NULL); bool _debugDebugMode; - bool _debugAbsolutePathWarning; void *_debugLogFile; int _sequence; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; int _viewportSP; @@ -203,22 +166,8 @@ public: int _settingsResHeight; char *_settingsGameFile; bool _suppressScriptErrors; - bool _mouseLeftDown; -protected: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - BaseFader *_fader; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); -public: + bool _mouseLeftDown; // TODO: Hide + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface virtual ScValue *scGetProperty(const char *name); @@ -228,68 +177,33 @@ public: // compatibility bits bool _compatKillMethodThreads; -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; -public: const char* getGameId() { return _gameId.c_str(); } void setGameId(const Common::String& gameId) { _gameId = gameId; } uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; + bool _smartCache; // RO + bool _subtitles; // RO + int _scheduledLoadSlot; bool _loading; - bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); - void setWindowTitle(); + virtual bool handleMouseWheel(int delta); bool _quitting; virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); -protected: - int _freezeLevel; -public: + bool unfreeze(); bool freeze(bool includingMusic = true); bool focusWindow(UIWindow *window); - VideoPlayer *_videoPlayer; - VideoTheoraPlayer *_theoraPlayer; bool _loadInProgress; UIWindow *_focusedWindow; bool _editorForceScripts; -protected: - static void afterLoadRegion(void *region, void *data); - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); -public: + static void invalidateValues(void *value, void *data); bool loadSettings(const char *filename); - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - BaseSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); BaseRegistry *_registry; bool _useD3D; @@ -298,10 +212,9 @@ public: virtual bool loadGame(const char *filename); virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - - BaseSprite *_cursorNoninteractive; + BaseObject *_activeObject; - BaseKeyboardState *_keyboardState; + bool _interactive; TGameState _state; TGameState _origState; @@ -322,14 +235,7 @@ public: void quickMessage(const char *text); void quickMessageForm(char *fmt, ...); bool displayQuickMsg(); - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - BaseArray _regObjects; -public: virtual bool displayContent(bool update = true, bool displayAll = false); virtual bool displayContentSimple(); bool _forceNonStreamedSounds; @@ -350,13 +256,114 @@ public: BaseSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); - bool _touchInterface; bool _constrainedMemory; - AnsiString getDeviceType() const; +protected: + BaseSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + BaseFader *_fader; + + bool _indicatorDisplay; + bool displayIndicator(); + + int _freezeLevel; + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; + static void afterLoadRegion(void *region, void *data); private: + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); + + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + char *_localSaveDir; + bool _saveDirChecked; + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + BaseSurface *_saveLoadImage; + + bool _reportTextureFormat; + + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + + bool _videoSubtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + + bool _personalizedSave; + + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + BaseSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + + BaseSprite *_cursorNoninteractive; + BaseKeyboardState *_keyboardState; + + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + BaseDebugger *_debugMgr; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; + + AnsiString getDeviceType() const; struct LastClickInfo { LastClickInfo() { diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index c05501b145..c1e3172a77 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -44,27 +44,9 @@ class ScValue; class ScStack; class ScScript; class BaseObject : public BaseScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(BaseSound *sound); +protected: bool _autoSoundPanning; uint32 _sFXStart; - int _sFXVolume; bool setSFXTime(uint32 time); bool setSFXVolume(int volume); bool resumeSFX(); @@ -72,12 +54,37 @@ public: bool stopSFX(bool deleteSound = true); bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); BaseSound *_sFX; - TSFXType _sFXType; float _sFXParam1; float _sFXParam2; float _sFXParam3; float _sFXParam4; + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + float _scaleX; + float _scaleY; + float _relativeScale; + bool _editorSelected; + bool _editorAlwaysRegister; + bool _ready; + Rect32 _rect; + bool _rectSet; + int _iD; + char *_soundEvent; +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _scale; + uint32 _alphaColor; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(BaseSound *sound); + int _sFXVolume; virtual bool handleMouseWheel(int delta); virtual bool handleMouse(TMouseEvent event, TMouseButton button); @@ -88,10 +95,10 @@ public: bool cleanup(); const char *getCaption(int caseVal = 1); void setCaption(const char *caption, int caseVal = 1); - bool _editorSelected; - bool _editorAlwaysRegister; + bool _editorOnly; bool _is3D; + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) virtual bool showCursor(); BaseSprite *_cursor; @@ -99,22 +106,18 @@ public: BaseSprite *_activeCursor; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); virtual bool listen(BaseScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; + + bool _movable; bool _zoomable; bool _shadowable; - Rect32 _rect; - bool _rectSet; - int _iD; - bool _movable; - BaseObject(BaseGame *inGame); - virtual ~BaseObject(); - char *_caption[7]; - char *_soundEvent; int _posY; int _posX; + bool _registrable; + char *_caption[7]; bool _saveState; + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); // base virtual bool update() { return STATUS_FAILED; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 5f8a2114c1..44d2fc00ba 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -309,7 +309,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::initLoad(const char *filename) { +bool BasePersistenceManager::initLoad(const Common::String &filename) { if (DID_FAIL(readHeader(filename))) { cleanup(); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 78d3230c47..cdb29fde6b 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -62,7 +62,7 @@ public: void deleteSaveSlot(int slot); uint32 getMaxUsedSlot(); bool getSaveExists(int slot); - bool initLoad(const char *filename); + bool initLoad(const Common::String &filename); bool initSave(const char *desc); bool getBytes(byte *buffer, uint32 size); bool putBytes(byte *buffer, uint32 size); diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index ef2615a668..d0d0757fbf 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -42,6 +42,7 @@ public: bool storeThumbnail(bool doFlip = false); BaseImage *_thumbnail; +private: BaseImage *_richThumbnail; }; diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 7ac79d4745..e528244438 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -102,9 +102,7 @@ char *BaseStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return; - +void BaseStringTable::expand(char **str) { if (str == NULL || *str == NULL || *str[0] != '/') return; char *value = strchr(*str + 1, '/'); @@ -132,14 +130,12 @@ void BaseStringTable::expand(char **str, bool forceExpand) { delete [] *str; *str = new_str; - if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); + if (strlen(*str) > 0 && *str[0] == '/') expand(str); } ////////////////////////////////////////////////////////////////////////// -const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return string; - +const char *BaseStringTable::expandStatic(const char *string) { if (string == NULL || string[0] == '\0' || string[0] != '/') return string; const char *value = strchr(string + 1, '/'); @@ -163,7 +159,7 @@ const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) delete [] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str); else return new_str; } diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index ac46aaee43..e8dee0c42d 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -37,9 +37,9 @@ namespace WinterMute { class BaseStringTable : public BaseClass { public: - const char *expandStatic(const char *string, bool forceExpand = false); + const char *expandStatic(const char *string); bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str, bool forceExpand = false); + void expand(char **str); bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); virtual ~BaseStringTable(); diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a6d56f281e..899265a2fb 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -68,18 +68,14 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename); delete [] tempFilename; - char slotFilename[MAX_PATH_LENGTH + 1]; - _gameRef->getSaveSlotFilename(slot, slotFilename); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + Common::String slotFilename = pm->getFilenameForSlot(slot); if (!pm) return STATUS_FAILED; - _gameRef->_debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _gameRef->_debugAbsolutePathWarning = true; bool res; diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 8a4f5af570..79806be95f 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -47,7 +47,7 @@ public: BaseFontBitmap(BaseGame *inGame); virtual ~BaseFontBitmap(); - +private: bool getWidths(); BaseSprite *_sprite; int _widthsFrame; @@ -59,7 +59,6 @@ public: BaseSubFrame *_subframe; bool _wholeCell; -private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 32dced0878..84da8bd7f8 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -104,21 +104,23 @@ public: return STATUS_OK; }; bool pointInViewport(Point32 *P); - uint32 _forceAlphaColor; - uint32 _window; - uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; int _bPP; int _height; int _width; - + uint32 _window; + uint32 _forceAlphaColor; + void addRectToList(BaseActiveRect *rect); +protected: + uint32 _clipperWindow; + + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; private: Common::Array _rectList; }; diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 9a72cbb236..cb98bde722 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -39,15 +39,9 @@ class BaseSurface: public BaseClass { public: virtual bool invalidate(); virtual bool prepareToDraw(); - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - uint32 _lastUsedTime; bool _valid; int _lifeTime; - bool _keepLoaded; bool _pixelOpReady; BaseSurface(BaseGame *inGame); @@ -88,6 +82,12 @@ public: //void SetWidth(int Width){ _width = Width; } //void SetHeight(int Height){ _height = Height; } protected: + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + bool _keepLoaded; Common::String _filename; int _height; int _width; diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 6575544db0..198e415cc4 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -43,88 +43,89 @@ public: PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); virtual ~PartEmitter(void); + int _fadeOutTime; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(BaseRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + BaseArray _forces; + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: int _width; int _height; - + int _angle1; int _angle2; - + float _rotation1; float _rotation2; - + float _angVelocity1; float _angVelocity2; - + float _growthRate1; float _growthRate2; bool _exponentialGrowth; - + float _velocity1; float _velocity2; bool _velocityZBased; - + float _scale1; float _scale2; bool _scaleZBased; - + int _maxParticles; - + int _lifeTime1; int _lifeTime2; bool _lifeTimeZBased; - + int _genInterval; int _genAmount; - + bool _running; int _overheadTime; - + int _maxBatches; int _batchesGenerated; - + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; int _borderThicknessBottom; - + int _fadeInTime; - int _fadeOutTime; - + int _alpha1; int _alpha2; bool _alphaTimeBased; - + bool _useRegion; - + char *_emitEvent; BaseScriptHolder *_owner; - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(BaseRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); - - BaseArray _forces; - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: PartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 3bb4bc48a7..ba73e1015f 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -55,9 +55,10 @@ public: bool copyParameters(ScStack *stack); void afterLoad(); - +private: ScValue *_operand; ScValue *_reg1; +public: bool _freezable; bool resume(); bool pause(); @@ -145,6 +146,13 @@ public: ScScript(BaseGame *inGame, ScEngine *Engine); virtual ~ScScript(); char *_filename; + bool _thread; + bool _methodThread; + char *_threadEvent; + BaseScriptHolder *_owner; + ScScript::TExternalFunction *getExternal(char *name); + bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); +private: char **_symbols; uint32 _numSymbols; TFunctionPos *_functions; @@ -155,13 +163,7 @@ public: uint32 _numFunctions; uint32 _numMethods; uint32 _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - BaseScriptHolder *_owner; - ScScript::TExternalFunction *getExternal(char *name); - bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); -private: + bool initScript(); bool initTables(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 3f8d703f85..8eb86c4e69 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -45,6 +45,7 @@ public: bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); +private: int _length; ScValue *_values; }; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index b2df4abe94..69fe1f1ae5 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -44,9 +44,9 @@ public: bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); +private: char *_string; TimeDate _tm; -private: Common::String _strRep; }; diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index c325181e3f..b5428b4bd9 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -46,8 +46,9 @@ public: SXMemBuffer(BaseGame *inGame, void *buffer); virtual ~SXMemBuffer(); virtual void *scToMemBuffer(); - int _size; private: + int _size; + bool resize(int newSize); void *_buffer; void cleanup(); diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index d744c58042..f7d3a7bc0f 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -39,7 +39,6 @@ public: DECLARE_PERSISTENT(SXObject, BaseObject) SXObject(BaseGame *inGame, ScStack *Stack); virtual ~SXObject(); - }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 7a684d2334..069c36bd47 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -88,7 +88,7 @@ public: ScValue *getProp(const char *name); BaseScriptable *_valNative; ScValue *_valRef; -protected: +private: bool _valBool; int _valInt; double _valFloat; diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 9c85a02b39..c32f83eb1e 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -48,7 +48,6 @@ public: BaseSoundBuffer(BaseGame *inGame); virtual ~BaseSoundBuffer(); - bool pause(); bool play(bool looping = false, uint32 startSample = 0); bool resume(); @@ -86,12 +85,12 @@ public: uint32 _loopStart; Audio::Mixer::SoundType _type; bool _looping; - Common::SeekableReadStream *_file; - char *_filename; - bool _streamed; int _privateVolume; private: + char *_filename; + bool _streamed; + Common::SeekableReadStream *_file; int _volume; }; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 7089b57216..31c4ee2fb8 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -255,7 +255,7 @@ int WinterMuteEngine::init() { _game = NULL; return false; } - _game->setWindowTitle(); + //_game->setWindowTitle(); _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; -- cgit v1.2.3 From 46968e20f944810cb3b9bce1fdf5f61a7f1de0bb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 18:38:13 +0200 Subject: WINTERMUTE: Cleanup in BasePackage. --- engines/wintermute/base/file/base_package.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 6987cad3e6..90bb027042 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -138,8 +138,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk _packages.push_back(pkg); - - + // read file entries uint32 numFiles = stream->readUint32LE(); @@ -158,10 +157,6 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - warning( "Package contains %s", name); - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; Common::String upcName = name; upcName.toUppercase(); @@ -178,7 +173,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool timeDate1 = stream->readUint32LE(); timeDate2 = stream->readUint32LE(); } - _filesIter = _files.find(upcName.c_str()); + _filesIter = _files.find(upcName); if (_filesIter == _files.end()) { BaseFileEntry *fileEntry = new BaseFileEntry(); fileEntry->_package = pkg; @@ -187,7 +182,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool fileEntry->_compressedLength = compLength; fileEntry->_flags = flags; - _files[upcName.c_str()] = Common::ArchiveMemberPtr(fileEntry); + _files[upcName] = Common::ArchiveMemberPtr(fileEntry); } else { // current package has higher priority than the registered // TODO: This cast might be a bit ugly. -- cgit v1.2.3 From 6331bea4231b5db86d01a8f21b5ff84e4b96d8f6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 18:59:26 +0200 Subject: WINTERMUTE: Remove in-engine fullscreen-switching, let ScummVM handle that. --- engines/wintermute/base/base_game.cpp | 7 ------- engines/wintermute/base/gfx/base_renderer.cpp | 7 ------- engines/wintermute/base/gfx/base_renderer.h | 1 - engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 12 ------------ engines/wintermute/base/gfx/osystem/base_render_osystem.h | 2 -- 5 files changed, 29 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index fcf45f18f2..622c23595b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3701,13 +3701,6 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { return true; } - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->switchFullscreen(); - return true; - } - - _keyboardState->handleKeyPress(event); _keyboardState->readKey(event); // TODO diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index a40b3204a5..ac475b3c5e 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,13 +111,6 @@ void BaseRenderer::deleteRectList() { _rectList.clear(); } - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::switchFullscreen() { - return STATUS_FAILED; -} - ////////////////////////////////////////////////////////////////////// bool BaseRenderer::flip() { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 84da8bd7f8..b67f221e83 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -68,7 +68,6 @@ public: virtual bool initRenderer(int width, int height, bool windowed); virtual bool flip(); virtual void initLoop(); - virtual bool switchFullscreen(); virtual bool setup2D(bool force = false); virtual bool setupLines(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 70d1268e5a..2d2e62076c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -588,18 +588,6 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { return NULL; } -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::switchFullscreen() { - /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); - else SDL_SetWindowFullscreen(_win, SDL_FALSE); - - _windowed = !_windowed; - */ - _gameRef->_registry->writeBool("Video", "Windowed", _windowed); - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// const char *BaseRenderOSystem::getName() { if (_name.empty()) { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 75c745ecf7..3f4185dce2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -71,8 +71,6 @@ public: bool fade(uint16 alpha); bool fadeToColor(uint32 color, Common::Rect *rect = NULL); - bool switchFullscreen(); - bool drawLine(int x1, int y1, int x2, int y2, uint32 color); BaseImage *takeScreenshot(); -- cgit v1.2.3 From 6e55e32a381d1219dfbe8d3c1532d55b28291192 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 20:00:58 +0200 Subject: WINTERMUTE: Cleanup and comment BaseRenderer a bit --- engines/wintermute/base/base_fader.cpp | 5 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/gfx/base_image.cpp | 9 +-- engines/wintermute/base/gfx/base_image.h | 8 +-- engines/wintermute/base/gfx/base_renderer.cpp | 30 ---------- engines/wintermute/base/gfx/base_renderer.h | 70 +++++++++++++++++++--- .../base/gfx/osystem/base_render_osystem.cpp | 34 +++-------- .../base/gfx/osystem/base_render_osystem.h | 9 ++- engines/wintermute/ui/ui_window.cpp | 10 +++- engines/wintermute/ui/ui_window.h | 3 +- 10 files changed, 98 insertions(+), 82 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4e7c608482..10818abfb9 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -85,8 +85,9 @@ bool BaseFader::update() { bool BaseFader::display() { if (!_active) return STATUS_OK; - if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); - else return STATUS_OK; + if (_currentAlpha > 0x00) + _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 622c23595b..756a28ad7b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4318,7 +4318,7 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); strcat(str, " ("); - strcat(str, _renderer->getName()); + strcat(str, _renderer->getName().c_str()); strcat(str, ")"); _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 2c18b64110..09a78a748b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -92,7 +92,7 @@ bool BaseImage::loadFile(const Common::String &filename) { return true; } -byte BaseImage::getAlphaAt(int x, int y) { +byte BaseImage::getAlphaAt(int x, int y) const { if (!_surface) return 0xFF; uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; @@ -100,19 +100,20 @@ byte BaseImage::getAlphaAt(int x, int y) { return a; } -void BaseImage::copyFrom(Graphics::Surface *surface) { +void BaseImage::copyFrom(const Graphics::Surface *surface) { _surface = _deletableSurface = new Graphics::Surface(); _deletableSurface->copyFrom(*surface); } ////////////////////////////////////////////////////////////////////////// -bool BaseImage::saveBMPFile(const char *filename) { +bool BaseImage::saveBMPFile(const char *filename) const { #if 0 if (!_bitmap) return STATUS_FAILED; if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; else return STATUS_FAILED; #endif + warning("BaseImage::saveBMPFile - stubbed"); // TODO return false; } @@ -138,7 +139,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// -bool BaseImage::writeBMPToStream(Common::WriteStream *stream) { +bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { if (!_surface) return false; /* The following is just copied over and inverted to write-ops from the BMP-decoder */ diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 7f344b5c1c..ed0142ea95 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -52,12 +52,12 @@ public: const byte *getPalette() const { return _palette; } - byte getAlphaAt(int x, int y); - bool writeBMPToStream(Common::WriteStream *stream); + byte getAlphaAt(int x, int y) const; + bool writeBMPToStream(Common::WriteStream *stream) const; bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename); + bool saveBMPFile(const char *filename) const; bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(Graphics::Surface *surface); + void copyFrom(const Graphics::Surface *surface); private: Common::String _filename; Graphics::ImageDecoder *_decoder; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index ac475b3c5e..66b7f513bf 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,12 +111,6 @@ void BaseRenderer::deleteRectList() { _rectList.clear(); } -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::flip() { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////// bool BaseRenderer::initRenderer(int width, int height, bool windowed) { return STATUS_FAILED; @@ -128,12 +122,6 @@ void BaseRenderer::onWindowChange() { } -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::windowedBlt() { return STATUS_FAILED; @@ -170,18 +158,6 @@ bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int wi } -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fade(uint16 alpha) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fadeToColor(uint32 color, Common::Rect *rect) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { return STATUS_FAILED; @@ -203,12 +179,6 @@ bool BaseRenderer::setViewport(Rect32 *rect) { } -////////////////////////////////////////////////////////////////////////// -BaseImage *BaseRenderer::takeScreenshot() { - return NULL; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::clipCursor() { /* diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index b67f221e83..90a1e378ca 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -40,6 +40,12 @@ class BaseImage; class BaseActiveRect; class BaseObject; class BaseSurface; + +/** + * @class BaseRenderer a common interface for the rendering portion of WME + * this interface is mainly intended to wrap away any differencies between + * software-rendering/hardware-rendering. + */ class BaseRenderer: public BaseClass { public: int _realWidth; @@ -48,12 +54,34 @@ public: int _drawOffsetY; virtual void dumpData(const char *filename) {}; - virtual BaseImage *takeScreenshot(); + /** + * Take a screenshot of the current screenstate + * + * @return a BaseImage containing the current screen-buffer. + */ + virtual BaseImage *takeScreenshot() = 0; virtual bool setViewport(int left, int top, int right, int bottom); - virtual bool setViewport(Rect32 *Rect); + virtual bool setViewport(Rect32 *rect); virtual bool setScreenViewport(); - virtual bool fade(uint16 Alpha); - virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + + virtual Graphics::PixelFormat getPixelFormat() const = 0; + /** + * Fade the screen to black + * + * @param alpha amount to fade by (alpha value of black) + * @return + */ + virtual void fade(uint16 alpha) = 0; + /** + * Fade a portion of the screen to a specific color + * + * @param r the red component to fade too. + * @param g the green component to fade too. + * @param b the blue component to fade too. + * @param a the alpha component to fade too. + * @param rect the portion of the screen to fade (if NULL, the entire screen will be faded). + */ + virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL) = 0; virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); BaseRenderer(BaseGame *inGame = NULL); @@ -63,17 +91,33 @@ public: }; virtual bool windowedBlt(); - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + /** + * Fill a portion of the screen with a specified color + * + * @param r the red component to fill with. + * @param g the green component to fill with. + * @param b the blue component to fill with. + */ + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL) = 0; virtual void onWindowChange(); virtual bool initRenderer(int width, int height, bool windowed); - virtual bool flip(); + /** + * Flip the backbuffer onto the screen-buffer + * The screen will NOT be updated before calling this function. + * + * @return true if successfull, false on error. + */ + virtual bool flip() = 0; virtual void initLoop(); virtual bool setup2D(bool force = false); virtual bool setupLines(); - virtual const char *getName() { - return ""; - }; + /** + * Get the name of the current renderer + * + * @return the name of the renderer. + */ + virtual Common::String getName() const = 0; virtual bool displayDebugInfo() { return STATUS_FAILED; }; @@ -88,6 +132,14 @@ public: return 1.0f; } + /** + * Create a Surface fit for use with the renderer. + * As diverse implementations of BaseRenderer might have different solutions for storing surfaces + * this allows for a common interface for creating surface-handles. (Mostly usefull to ease future + * implementation of hw-accelerated rendering, or readding 3D-support at some point). + * + * @return a surface that can be used with this renderer + */ virtual BaseSurface *createSurface() = 0; bool clipCursor(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 2d2e62076c..09ee62c3b8 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -284,14 +284,14 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::fade(uint16 Alpha) { - uint32 dwAlpha = 255 - Alpha; - return fadeToColor(dwAlpha << 24); +void BaseRenderOSystem::fade(uint16 alpha) { + byte dwAlpha = (byte)(255 - alpha); + return fadeToColor(0, 0, 0, dwAlpha); } ////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { +void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -318,11 +318,6 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { } modTargetRect(&fillRect); - byte r = RGBCOLGetR(Color); - byte g = RGBCOLGetG(Color); - byte b = RGBCOLGetB(Color); - byte a = RGBCOLGetA(Color); - //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); if (_disableDirtyRects) @@ -342,8 +337,10 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); +} - return STATUS_OK; +Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { + return _renderSurface->format; } void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { @@ -589,17 +586,8 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { } ////////////////////////////////////////////////////////////////////////// -const char *BaseRenderOSystem::getName() { - if (_name.empty()) { -#if 0 - if (_renderer) { - SDL_RendererInfo info; - SDL_GetRendererInfo(_renderer, &info); - _name = AnsiString(info.name); - } -#endif - } - return _name.c_str(); +Common::String BaseRenderOSystem::getName() const { + return "ScummVM-OSystem-renderer"; } ////////////////////////////////////////////////////////////////////////// @@ -611,10 +599,6 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { rect.right = (int16)((right - left) * _ratioX); rect.bottom = (int16)((bottom - top) * _ratioY); - // TODO fix this once viewports work correctly in SDL/landscape -#ifndef __IPHONEOS__ - //SDL_RenderSetViewport(GetSdlRenderer(), &rect); -#endif return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 3f4185dce2..b7507098da 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -62,14 +62,14 @@ public: BaseRenderOSystem(BaseGame *inGame); ~BaseRenderOSystem(); - const char *getName(); + Common::String getName() const; bool initRenderer(int width, int height, bool windowed); bool flip(); bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - - bool fade(uint16 alpha); - bool fadeToColor(uint32 color, Common::Rect *rect = NULL); + Graphics::PixelFormat getPixelFormat() const; + void fade(uint16 alpha); + void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL); bool drawLine(int x1, int y1, int x2, int y2, uint32 color); @@ -109,7 +109,6 @@ private: uint32 _drawNum; Common::Rect _renderRect; Graphics::Surface *_renderSurface; - AnsiString _name; int _borderLeft; int _borderTop; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index e9308e052b..4c1068d366 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -142,7 +142,15 @@ bool UIWindow::display(int offsetX, int offsetY) { if (!_visible) return STATUS_OK; - if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor); + if (_fadeBackground) { + Graphics::PixelFormat format = _gameRef->_renderer->getPixelFormat(); + byte fadeR, fadeG, fadeB, fadeA; + // First convert from the internal format to the screen-format + uint32 fadeColor = format.ARGBToColor(RGBCOLGetA(_fadeColor), RGBCOLGetR(_fadeColor), RGBCOLGetG(_fadeColor), RGBCOLGetB(_fadeColor)); + // Then get components + format.colorToARGB(fadeColor, fadeA, fadeR, fadeG, fadeB); + _gameRef->_renderer->fadeToColor(fadeR, fadeG, fadeB, fadeA); + } if (_dragging) { _posX += (_gameRef->_mousePos.x - _dragFrom.x); diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 9e8862471c..c2baeb1ea1 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -38,6 +38,7 @@ namespace WinterMute { class UIButton; class BaseViewport; class UIWindow : public UIObject { + uint32 _fadeColor; public: bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); @@ -49,7 +50,7 @@ public: bool _inGame; bool _isMenu; bool _fadeBackground; - uint32 _fadeColor; + virtual bool handleMouseWheel(int delta); UIWindow *_shieldWindow; UIButton *_shieldButton; -- cgit v1.2.3 From f2379252f46187cfc4030765282374e5f086675f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:00:57 +0200 Subject: WINTERMUTE: Reformat and constify BaseStringTable --- engines/wintermute/base/base_string_table.cpp | 128 ++++++++++++++------------ engines/wintermute/base/base_string_table.h | 10 +- 2 files changed, 76 insertions(+), 62 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index e528244438..58cf046436 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -51,7 +51,8 @@ BaseStringTable::~BaseStringTable() { ////////////////////////////////////////////////////////////////////////// bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return STATUS_FAILED; + if (key == NULL || val == NULL) + return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { _gameRef->_textRTL = true; @@ -61,8 +62,9 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup Common::String finalKey = key; finalKey.toLowercase(); - _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + StringsIter it = _strings.find(finalKey); + if (it != _strings.end() && reportDuplicities) + _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); _strings[finalKey] = val; @@ -70,30 +72,32 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup } ////////////////////////////////////////////////////////////////////////// -char *BaseStringTable::getKey(const char *str) { - if (str == NULL || str[0] != '/') return NULL; +char *BaseStringTable::getKey(const char *str) const { + if (str == NULL || str[0] != '/') + return NULL; const char *value = strchr(str + 1, '/'); - if (value == NULL) return NULL; + if (value == NULL) + return NULL; char *key = new char[value - str]; - strncpy(key, str + 1, value - str - 1); - key[value - str - 1] = '\0'; + Common::strlcpy(key, str + 1, (size_t)(value - str)); + BasePlatform::strlwr(key); - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = getKey(new_str); - delete [] new_str; - return Ret; + char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); + if (strlen(newStr) > 0 && newStr[0] == '/' && strchr(newStr + 1, '/')) { + delete[] key; + char *ret = getKey(newStr); + delete[] newStr; + return ret; } else { - delete [] new_str; + delete[] newStr; return key; } } else { @@ -102,65 +106,71 @@ char *BaseStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str) { - if (str == NULL || *str == NULL || *str[0] != '/') return; +void BaseStringTable::expand(char **str) const { + if (str == NULL || *str == NULL || *str[0] != '/') + return; char *value = strchr(*str + 1, '/'); - if (value == NULL) return; + if (value == NULL) + return; char *key = new char[value - *str]; - strncpy(key, *str + 1, value - *str - 1); - key[value - *str - 1] = '\0'; + Common::strlcpy(key, *str + 1, (size_t)(value - *str)); + BasePlatform::strlwr(key); value++; - char *new_str; + char *newStr; - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); + newStr = new char[strlen(value) + 1]; + strcpy(newStr, value); } - delete [] key; - delete [] *str; - *str = new_str; + delete[] key; + delete[] *str; + *str = newStr; - if (strlen(*str) > 0 && *str[0] == '/') expand(str); + if (strlen(*str) > 0 && *str[0] == '/') + expand(str); } ////////////////////////////////////////////////////////////////////////// -const char *BaseStringTable::expandStatic(const char *string) { - if (string == NULL || string[0] == '\0' || string[0] != '/') return string; +const char *BaseStringTable::expandStatic(const char *string) const { + if (string == NULL || string[0] == '\0' || string[0] != '/') + return string; const char *value = strchr(string + 1, '/'); - if (value == NULL) return string; + if (value == NULL) + return string; char *key = new char[value - string]; - strncpy(key, string + 1, value - string - 1); - key[value - string - 1] = '\0'; + Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); BasePlatform::strlwr(key); value++; - const char *new_str; + const char *newStr; - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = it->_value.c_str(); } else { - new_str = value; + newStr = value; } - delete [] key; + delete[] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str); - else return new_str; + if (strlen(newStr) > 0 && newStr[0] == '/') + return expandStatic(newStr); + else + return newStr; } @@ -168,7 +178,8 @@ const char *BaseStringTable::expandStatic(const char *string) { bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); - if (clearOld) _strings.clear(); + if (clearOld) + _strings.clear(); uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); @@ -191,12 +202,12 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { uint32 lineLength = 0; while (pos < size) { lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') + lineLength++; uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); char *line = new char[realLength + 1]; - strncpy(line, (char *)&buffer[pos], realLength); - line[realLength] = '\0'; + Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); char *value = strchr(line, '\t'); if (value == NULL) value = strchr(line, ' '); @@ -205,17 +216,20 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { value[0] = '\0'; value++; for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; + if (value[i] == '|') + value[i] = '\n'; } addString(line, value, clearOld); - } else if (line[0] != '\0') addString(line, "", clearOld); + } else if (line[0] != '\0') { + addString(line, "", clearOld); + } } - delete [] line; + delete[] line; pos += lineLength + 1; } - delete [] buffer; + delete[] buffer; _gameRef->LOG(0, " %d strings loaded", _strings.size()); diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index e8dee0c42d..1bc9047f7f 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -37,16 +37,16 @@ namespace WinterMute { class BaseStringTable : public BaseClass { public: - const char *expandStatic(const char *string); bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str); + void expand(char **str) const; + const char *expandStatic(const char *string) const; bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); virtual ~BaseStringTable(); - Common::HashMap _strings; - char *getKey(const char *str); + char *getKey(const char *str) const; private: - Common::HashMap::iterator _stringsIter; + Common::HashMap _strings; + typedef Common::HashMap::const_iterator StringsIter; }; -- cgit v1.2.3 From fa96c9ea187cdb26e9f1ce048c9132f723e25df1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:05:03 +0200 Subject: WINTERMUTE: "delete []" -> "delete[]" --- engines/wintermute/ad/ad_actor.cpp | 4 ++-- engines/wintermute/ad/ad_entity.cpp | 2 +- engines/wintermute/ad/ad_game.cpp | 28 +++++++++++----------- engines/wintermute/ad/ad_inventory_box.cpp | 2 +- engines/wintermute/ad/ad_item.cpp | 2 +- engines/wintermute/ad/ad_layer.cpp | 2 +- engines/wintermute/ad/ad_object.cpp | 4 ++-- engines/wintermute/ad/ad_region.cpp | 2 +- engines/wintermute/ad/ad_response_box.cpp | 2 +- engines/wintermute/ad/ad_rot_level.cpp | 2 +- engines/wintermute/ad/ad_scale_level.cpp | 2 +- engines/wintermute/ad/ad_scene.cpp | 2 +- engines/wintermute/ad/ad_sentence.cpp | 6 ++--- engines/wintermute/ad/ad_sprite_set.cpp | 2 +- engines/wintermute/ad/ad_talk_def.cpp | 2 +- engines/wintermute/ad/ad_waypoint_group.cpp | 2 +- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 10 ++++---- engines/wintermute/base/base_parser.cpp | 2 +- .../wintermute/base/base_persistence_manager.cpp | 4 ++-- engines/wintermute/base/base_quick_msg.cpp | 2 +- engines/wintermute/base/base_region.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 6 ++--- .../wintermute/base/file/base_save_thumb_file.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/scriptables/script.cpp | 22 ++++++++--------- .../wintermute/base/scriptables/script_engine.cpp | 6 ++--- .../wintermute/base/scriptables/script_engine.h | 2 +- .../base/scriptables/script_ext_file.cpp | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 2 +- .../base/scriptables/script_ext_string.cpp | 2 +- .../wintermute/base/scriptables/script_value.cpp | 6 ++--- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 2 +- engines/wintermute/ui/ui_entity.cpp | 2 +- engines/wintermute/ui/ui_object.cpp | 4 ++-- engines/wintermute/ui/ui_text.cpp | 2 +- engines/wintermute/ui/ui_tiled_image.cpp | 2 +- engines/wintermute/ui/ui_window.cpp | 2 +- engines/wintermute/utils/string_util.cpp | 20 ++++++++-------- engines/wintermute/video/video_player.cpp | 12 +++++----- engines/wintermute/wintermute.cpp | 6 ++--- 48 files changed, 105 insertions(+), 105 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index bfc21c6ccc..fc28293ac8 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -132,7 +132,7 @@ bool AdActor::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } @@ -1287,7 +1287,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { break; } } - delete [] fileBuffer; + delete[] fileBuffer; return Ret; } diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 80c52de71a..a4b94d062f 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -97,7 +97,7 @@ bool AdEntity::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index d75f41e38e..1df34e74bd 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -128,12 +128,12 @@ bool AdGame::cleanup() { for (i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; + delete[] _dlgPendingBranches[i]; } _dlgPendingBranches.removeAll(); for (i = 0; i < _speechDirs.getSize(); i++) { - delete [] _speechDirs[i]; + delete[] _speechDirs[i]; } _speechDirs.removeAll(); @@ -1117,7 +1117,7 @@ bool AdGame::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } @@ -1387,7 +1387,7 @@ bool AdGame::loadItemsFile(const char *filename, bool merge) { if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } @@ -1451,7 +1451,7 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { for (int i = 0; i < _sceneStates.getSize(); i++) { if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { - delete [] filenameCor; + delete[] filenameCor; return _sceneStates[i]; } } @@ -1462,10 +1462,10 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { _sceneStates.add(ret); - delete [] filenameCor; + delete[] filenameCor; return ret; } else { - delete [] filenameCor; + delete[] filenameCor; return NULL; } } @@ -1563,7 +1563,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const if (startIndex >= 0) { for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); - delete [] _dlgPendingBranches[i]; + delete[] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; } _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); @@ -1575,7 +1575,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const _responsesBranch.removeAll(); } - if (deleteName) delete [] name; + if (deleteName) delete[] name; return STATUS_OK; } @@ -1795,7 +1795,7 @@ bool AdGame::addItem(AdItem *item) { bool AdGame::resetContent() { // clear pending dialogs for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { - delete [] _dlgPendingBranches[i]; + delete[] _dlgPendingBranches[i]; } _dlgPendingBranches.removeAll(); @@ -1862,7 +1862,7 @@ bool AdGame::addSpeechDir(const char *dir) { for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] temp; + delete[] temp; return STATUS_OK; } } @@ -1884,13 +1884,13 @@ bool AdGame::removeSpeechDir(const char *dir) { bool Found = false; for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { - delete [] _speechDirs[i]; + delete[] _speechDirs[i]; _speechDirs.removeAt(i); Found = true; break; } } - delete [] temp; + delete[] temp; if (Found) return STATUS_OK; else return STATUS_FAILED; @@ -1910,7 +1910,7 @@ char *AdGame::findSpeechFile(char *stringID) { if (_fileManager->hasFile(ret)) return ret; } - delete [] ret; + delete[] ret; return NULL; } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 38e06535d9..60607c71c6 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -169,7 +169,7 @@ bool AdInventoryBox::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index ec9fa3c14c..e9a1bb4353 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -97,7 +97,7 @@ bool AdItem::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 38894a0e88..0a93edfb35 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -73,7 +73,7 @@ bool AdLayer::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 84f13dc989..fdbc987158 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -853,7 +853,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *key = _gameRef->_stringTable->getKey(text); if (key) { sound = ((AdGame *)_gameRef)->findSpeechFile(key); - delete [] key; + delete[] key; if (sound) deleteSound = true; } @@ -931,7 +931,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const _state = STATE_TALKING; - if (deleteSound) delete [] sound; + if (deleteSound) delete[] sound; } diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index a23c000137..eec25b2aaa 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -67,7 +67,7 @@ bool AdRegion::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 90582ce811..22b40f3ea4 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -200,7 +200,7 @@ bool AdResponseBox::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 6f3ffdaeb5..72fcaeff28 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -66,7 +66,7 @@ bool AdRotLevel::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 1adf4266b2..c390c6dc08 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -64,7 +64,7 @@ bool AdScaleLevel::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index a802039550..dd69db3d68 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -514,7 +514,7 @@ bool AdScene::loadFile(const char *filename) { setFilename(filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 452c2587d4..a011db3f02 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -91,7 +91,7 @@ AdSentence::~AdSentence() { ////////////////////////////////////////////////////////////////////////// void AdSentence::setText(const char *text) { - if (_text) delete [] _text; + if (_text) delete[] _text; _text = new char[strlen(text) + 1]; if (_text) strcpy(_text, text); } @@ -99,7 +99,7 @@ void AdSentence::setText(const char *text) { ////////////////////////////////////////////////////////////////////////// void AdSentence::setStances(const char *stances) { - if (_stances) delete [] _stances; + if (_stances) delete[] _stances; if (stances) { _stances = new char[strlen(stances) + 1]; if (_stances) strcpy(_stances, stances); @@ -124,7 +124,7 @@ char *AdSentence::getNextStance() { char *AdSentence::getStance(int stance) { if (_stances == NULL) return NULL; - if (_tempStance) delete [] _tempStance; + if (_tempStance) delete[] _tempStance; _tempStance = NULL; char *start; diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index e158b6115a..fcbf9af4eb 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -69,7 +69,7 @@ bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index cfbefd39d4..2b0c6c6c1b 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -81,7 +81,7 @@ bool AdTalkDef::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 28ce2967dd..7e5d8d29c6 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -78,7 +78,7 @@ bool AdWaypointGroup::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 156aff61fe..b25bbf024d 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -101,7 +101,7 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); - delete [] buffer; + delete[] buffer; return NULL; }; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 8278c48299..77e959f11b 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -552,7 +552,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac const char *event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete [] _applyEvent[i]; + delete[] _applyEvent[i]; _applyEvent.removeAt(i); break; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 756a28ad7b..b11915afc7 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -682,7 +682,7 @@ bool BaseGame::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } @@ -1088,7 +1088,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack strcpy(str, val->getString()); _stringTable->expand(&str); stack->pushString(str); - delete [] str; + delete[] str; return STATUS_OK; } @@ -1518,7 +1518,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pop(); stack->pushBool(false); } - delete [] desc; + delete[] desc; return STATUS_OK; } @@ -3098,7 +3098,7 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack char *str2 = new char[strlen(str) + 1]; strcpy(str2, str); stack->pushString(str2); - delete [] str2; + delete[] str2; } ////////////////////////////////////////////////////////////////////////// @@ -3536,7 +3536,7 @@ bool BaseGame::loadSettings(const char *filename) { _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; - delete [] origBuffer; + delete[] origBuffer; return ret; } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index b7a221daf5..588d210134 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -50,7 +50,7 @@ BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseParser::~BaseParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; + if (_whiteSpace != NULL) delete[] _whiteSpace; } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 44d2fc00ba..3f9e8de855 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -91,7 +91,7 @@ BasePersistenceManager::~BasePersistenceManager() { void BasePersistenceManager::cleanup() { /* if (_buffer) { if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager + else delete[] _buffer; // allocated by file manager } _buffer = NULL; @@ -110,7 +110,7 @@ void BasePersistenceManager::cleanup() { _thumbnailDataSize = 0; if (_thumbnailData) { - delete [] _thumbnailData; + delete[] _thumbnailData; _thumbnailData = NULL; } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index 6e435b3ee0..d672e39c6b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -41,7 +41,7 @@ BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::~BaseQuickMsg() { - if (_text) delete [] _text; + if (_text) delete[] _text; } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 22b5a99937..f88de2ab91 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -108,7 +108,7 @@ bool BaseRegion::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 62ed4f67f2..d274f9df73 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -72,7 +72,7 @@ bool BaseScriptHolder::cleanup() { ////////////////////////////////////////////////////////////////////// void BaseScriptHolder::setFilename(const char *filename) { if (_filename != NULL) { - delete [] _filename; + delete[] _filename; _filename = NULL; } if (filename == NULL) diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 86dbefdd70..3514504824 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -155,7 +155,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] buffer; + delete[] buffer; } } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 35546b0001..1598101036 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -150,7 +150,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { byte *data = new byte[uncompSize]; if (!data) { error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] compBuffer; + delete[] compBuffer; delete file; return NULL; } @@ -159,12 +159,12 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); - delete [] compBuffer; + delete[] compBuffer; delete file; return NULL; } - delete [] compBuffer; + delete[] compBuffer; return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); delete file; diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 899265a2fb..0a0d0cac09 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -66,7 +66,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { // get slot number from name int slot = atoi(tempFilename); - delete [] tempFilename; + delete[] tempFilename; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String slotFilename = pm->getFilenameForSlot(slot); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index e9d245782a..7bffbc35c8 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -85,7 +85,7 @@ bool BaseFont::loadFile(const char * Filename) if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - delete [] Buffer; + delete[] Buffer; return ret; } @@ -198,7 +198,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) ret = true; - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 2e752d4f2e..dd6c6da327 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -255,7 +255,7 @@ bool BaseFontBitmap::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index c371177bac..dd5d006556 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -419,7 +419,7 @@ bool BaseFontTT::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 6bfff0799e..1ddefec610 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -106,7 +106,7 @@ PartEmitter::~PartEmitter(void) { for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; + delete[] _sprites[i]; } _sprites.removeAll(); @@ -141,7 +141,7 @@ bool PartEmitter::addSprite(const char *filename) { bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; + delete[] _sprites[i]; _sprites.removeAt(i); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 52490c0710..57e08135ed 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -360,13 +360,13 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { ////////////////////////////////////////////////////////////////////////// void ScScript::cleanup() { - if (_buffer) delete [] _buffer; + if (_buffer) delete[] _buffer; _buffer = NULL; - if (_filename) delete [] _filename; + if (_filename) delete[] _filename; _filename = NULL; - if (_symbols) delete [] _symbols; + if (_symbols) delete[] _symbols; _symbols = NULL; _numSymbols = 0; @@ -385,24 +385,24 @@ void ScScript::cleanup() { delete _stack; _stack = NULL; - if (_functions) delete [] _functions; + if (_functions) delete[] _functions; _functions = NULL; _numFunctions = 0; - if (_methods) delete [] _methods; + if (_methods) delete[] _methods; _methods = NULL; _numMethods = 0; - if (_events) delete [] _events; + if (_events) delete[] _events; _events = NULL; _numEvents = 0; if (_externals) { for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; + if (_externals[i].nu_params > 0) delete[] _externals[i].params; } - delete [] _externals; + delete[] _externals; } _externals = NULL; _numExternals = 0; @@ -586,7 +586,7 @@ bool ScScript::executeInstruction() { runtimeError("Cannot call method '%s'. Ignored.", MethodName); _stack->pushNULL(); } - delete [] MethodName; + delete[] MethodName; break; } /* @@ -621,7 +621,7 @@ bool ScScript::executeInstruction() { } } } - delete [] MethodName; + delete[] MethodName; } break; @@ -797,7 +797,7 @@ bool ScScript::executeInstruction() { strcpy(tempStr, op1->getString()); strcat(tempStr, op2->getString()); _operand->setString(tempStr); - delete [] tempStr; + delete[] tempStr; } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) _operand->setInt(op1->getInt() + op2->getInt()); else _operand->setFloat(op1->getFloat() + op2->getFloat()); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 59ec113d1f..c33d844aa1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -127,7 +127,7 @@ byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { ////////////////////////////////////////////////////////////////////////// void ScEngine::closeFile(void *data, byte *buffer) { - delete [] buffer; + delete[] buffer; } @@ -201,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig } else { if (!_compilerAvailable) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] buffer; + delete[] buffer; return NULL; } // This code will never be called, since _compilerAvailable is const false. @@ -235,7 +235,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig // cleanup - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 3d85192aa6..e443ec5832 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -54,7 +54,7 @@ public: }; ~CScCachedScript() { - if (_buffer) delete [] _buffer; + if (_buffer) delete[] _buffer; }; uint32 _timestamp; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 92943f7485..01179bb3ad 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -457,7 +457,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, str[size] = '\0'; stack->pushString((char *)str); } - delete [] str; + delete[] str; } else stack->pushNULL(); } else stack->pushNULL(); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index b625fad400..6b791871ad 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -249,7 +249,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt strncpy(str, (const char *)_buffer + start, length); str[length] = '\0'; stack->pushString(str); - delete [] str; + delete[] str; } return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 5e01e5e29c..385d7ca746 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -67,7 +67,7 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// SXString::~SXString() { - if (_string) delete [] _string; + if (_string) delete[] _string; } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 6d12c34914..59e0965f5e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -122,7 +122,7 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { void ScValue::cleanup(bool ignoreNatives) { deleteProps(); - if (_valString) delete [] _valString; + if (_valString) delete[] _valString; if (!ignoreNatives) { if (_valNative && !_persistent) { @@ -425,7 +425,7 @@ void ScValue::setString(const Common::String &val) { ////////////////////////////////////////////////////////////////////////// void ScValue::setStringVal(const char *val) { if (_valString) { - delete [] _valString; + delete[] _valString; _valString = NULL; } @@ -767,7 +767,7 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer("", &val); _valObject[str] = val; - delete [] str; + delete[] str; } } diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index a6adfca374..fab724eb06 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -106,7 +106,7 @@ bool UIButton::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index e687075a9a..988f56ae17 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -103,7 +103,7 @@ bool UIEdit::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 0244b104a7..21fa3120ba 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -69,7 +69,7 @@ bool UIEntity::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 2b05fea22b..ed58079ad2 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -78,7 +78,7 @@ UIObject::~UIObject() { if (_image && !_sharedImages) delete _image; - if (_text) delete [] _text; + if (_text) delete[] _text; _focusedWidget = NULL; // ref only } @@ -86,7 +86,7 @@ UIObject::~UIObject() { ////////////////////////////////////////////////////////////////////////// void UIObject::setText(const char *text) { - if (_text) delete [] _text; + if (_text) delete[] _text; _text = new char [strlen(text) + 1]; if (_text) { strcpy(_text, text); diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 3535da0ca5..6d838b8d37 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -107,7 +107,7 @@ bool UIText::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 5e1d9675c0..e0b2a75ee4 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -132,7 +132,7 @@ bool UITiledImage::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 4c1068d366..b14c832397 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -227,7 +227,7 @@ bool UIWindow::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index fcf5620cd7..be6207c3b8 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -64,12 +64,12 @@ WideString StringUtil::utf8ToWide(const Utf8String &Utf8Str) { ConversionResult res = ConvertUTF8toUTF16(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); if (res != conversionOK) { - delete [] WideStringNative; + delete[] WideStringNative; return L""; } *TargetStart = 0; WideString ResultString(WideStringNative); - delete [] WideStringNative; + delete[] WideStringNative; return ResultString; } else if (sizeof(wchar_t) == 4) { @@ -83,12 +83,12 @@ WideString StringUtil::utf8ToWide(const Utf8String &Utf8Str) { ConversionResult res = ConvertUTF8toUTF32(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); if (res != conversionOK) { - delete [] WideStringNative; + delete[] WideStringNative; return L""; } *TargetStart = 0; WideString ResultString(WideStringNative); - delete [] WideStringNative; + delete[] WideStringNative; return ResultString; } else { @@ -114,12 +114,12 @@ Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { ConversionResult res = ConvertUTF16toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); if (res != conversionOK) { - delete [] Utf8StringNative; + delete[] Utf8StringNative; return (Utf8String)""; } *TargetStart = 0; Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; + delete[] Utf8StringNative; return ResultString; } else if (sizeof(wchar_t) == 4) { size_t Utf8Size = 4 * WideSize + 1; @@ -133,12 +133,12 @@ Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { ConversionResult res = ConvertUTF32toUTF8(&SourceStart, SourceEnd, &TargetStart, TargetEnd, strictConversion); if (res != conversionOK) { - delete [] Utf8StringNative; + delete[] Utf8StringNative; return (Utf8String)""; } *TargetStart = 0; Utf8String ResultString(Utf8StringNative); - delete [] Utf8StringNative; + delete[] Utf8StringNative; return ResultString; } else { return (Utf8String)""; @@ -179,7 +179,7 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { wchar_t *wstr = new wchar_t[WideSize]; mbstowcs(wstr, str.c_str(), WideSize); WideString ResultString(wstr); - delete [] wstr; + delete[] wstr; return ResultString;*/ return WideString(str); } @@ -198,7 +198,7 @@ AnsiString StringUtil::wideToAnsi(const WideString &wstr) { char *str = new char[WideSize]; wcstombs(str, wstr.c_str(), WideSize); AnsiString ResultString(str); - delete [] str; + delete[] str; return ResultString;*/ return AnsiString(wstr); } diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index be3bb3ec94..ac16104268 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -104,9 +104,9 @@ bool VideoPlayer::cleanup() { if (_audioStream) AVIStreamRelease(m_AudioStream); if (_videoStream) AVIStreamRelease(m_VideoStream); - if (_audioFormat) delete [](byte *)m_AudioFormat; - if (_videoFormat) delete [](byte *)m_VideoFormat; - if (_targetFormat) delete [](byte *)m_TargetFormat; + if (_audioFormat) delete[](byte *)m_AudioFormat; + if (_videoFormat) delete[](byte *)m_VideoFormat; + if (_targetFormat) delete[](byte *)m_TargetFormat; SAFE_DELETE(_sound); SAFE_DELETE(_vidRenderer); @@ -437,7 +437,7 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) if (TokenPos == 0) Start = atoi(Token); else if (TokenPos == 1) End = atoi(Token); - delete [] Token; + delete[] Token; } else { Text[TextLength] = line[i]; TextLength++; @@ -456,12 +456,12 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); - delete [] Text; + delete[] Text; Pos += LineLength + 1; } - delete [] Buffer; + delete[] Buffer; #endif return STATUS_OK; } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 31c4ee2fb8..d797972e40 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -185,8 +185,8 @@ int WinterMuteEngine::init() { sprintf(param, "./%s", IniName); _game->_registry->SetIniName(param); - delete [] IniDir; - delete [] IniName; + delete[] IniDir; + delete[] IniName; } } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; }*/ @@ -270,7 +270,7 @@ int WinterMuteEngine::init() { if (SaveGame) { _game->loadGame(SaveGame); - delete [] SaveGame; + delete[] SaveGame; } // all set, ready to go -- cgit v1.2.3 From 1ad859a468415cc7fd93adaa84beba02aae29ad8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:21:55 +0200 Subject: WINTERMUTE: "if(" -> "if (" --- engines/wintermute/ad/ad_entity.cpp | 2 +- engines/wintermute/ad/ad_game.cpp | 4 +-- engines/wintermute/ad/ad_scene.cpp | 6 ++-- engines/wintermute/ad/ad_talk_holder.cpp | 2 +- engines/wintermute/base/base_game.cpp | 4 +-- engines/wintermute/base/base_keyboard_state.cpp | 2 +- engines/wintermute/base/base_scriptable.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 4 +-- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 6 ++-- engines/wintermute/base/scriptables/script.cpp | 36 +++++++++++----------- .../wintermute/base/scriptables/script_engine.cpp | 6 ++-- .../base/scriptables/script_ext_date.cpp | 2 +- .../base/scriptables/script_ext_file.cpp | 4 +-- .../base/scriptables/script_ext_mem_buffer.cpp | 4 +-- .../wintermute/base/scriptables/script_value.cpp | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 16 +++++----- engines/wintermute/dcgf.h | 7 ----- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/video/video_player.cpp | 4 +-- engines/wintermute/video/video_theora_player.cpp | 2 +- engines/wintermute/wintermute.cpp | 12 ++++---- 23 files changed, 63 insertions(+), 70 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index a4b94d062f..98fb296bf5 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -650,7 +650,7 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_theora && DID_SUCCEED(_theora->initialize(filename))) { if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); - //if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale; + //if (_scale>=0) _theora->_playZoom = _scale; stack->pushBool(true); } else { script->runtimeError("Entity.PlayTheora - error playing video '%s'", filename); diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 1df34e74bd..259fc175ae 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -335,7 +335,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, //bool ret = ChangeScene(stack->pop()->getString()); - //if(DID_FAIL(ret)) stack->pushBool(false); + //if (DID_FAIL(ret)) stack->pushBool(false); //else stack->pushBool(true); return STATUS_OK; @@ -821,7 +821,7 @@ ScValue *AdGame::scGetProperty(const char *name) { // SelectedItem ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelectedItem") == 0) { - //if(_selectedItem) _scValue->setString(_selectedItem->_name); + //if (_selectedItem) _scValue->setString(_selectedItem->_name); if (_selectedItem) _scValue->setNative(_selectedItem, true); else _scValue->setNULL(); diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index dd69db3d68..85c2341268 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -2491,7 +2491,7 @@ bool AdScene::persistState(bool saving) { nodeState = state->getNodeState(node->_entity->getName(), saving); if (nodeState) { nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); - //if(Saving) NodeState->_active = node->_entity->_active; + //if (Saving) NodeState->_active = node->_entity->_active; //else node->_entity->_active = NodeState->_active; } break; @@ -2517,7 +2517,7 @@ bool AdScene::persistState(bool saving) { nodeState = state->getNodeState(_objects[i]->getName(), saving); if (nodeState) { nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); - //if(Saving) NodeState->_active = _objects[i]->_active; + //if (Saving) NodeState->_active = _objects[i]->_active; //else _objects[i]->_active = NodeState->_active; } } @@ -2684,7 +2684,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i } if (!found) objects.add(regionObj[newIndex]); } - //if(RegionObj.getSize() > 0) Objects.Append(RegionObj); + //if (RegionObj.getSize() > 0) Objects.Append(RegionObj); } break; default: diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index db13e0a549..359215ee8f 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -320,7 +320,7 @@ bool AdTalkHolder::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Item")==0){ + if (strcmp(name, "Item")==0){ SetItem(value->getString()); return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b11915afc7..63040f2db2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3242,7 +3242,7 @@ bool BaseGame::loadGame(const char *filename) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - //if(DID_FAIL(ret = cleanup())) goto load_finish; + //if (DID_FAIL(ret = cleanup())) goto load_finish; if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; @@ -3873,7 +3873,7 @@ bool BaseGame::setActiveObject(BaseObject *obj) { if (obj == _activeObject) return STATUS_OK; if (_activeObject) _activeObject->applyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); _activeObject = obj; if (_activeObject) { _activeObject->applyEvent("MouseEntry"); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index db0f1db94d..a85ec3e972 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -215,7 +215,7 @@ bool BaseKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if(!persistMgr->getIsSaving()) cleanup(); + //if (!persistMgr->getIsSaving()) cleanup(); BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 40aa2871b5..4059abde3d 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -49,7 +49,7 @@ BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) ////////////////////////////////////////////////////////////////////////// BaseScriptable::~BaseScriptable() { - //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + //if (_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); delete _scValue; delete _scProp; _scValue = NULL; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 3514504824..03b0ef3615 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -329,7 +329,7 @@ void BaseSprite::reset() { ////////////////////////////////////////////////////////////////////// bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 2ac011917c..0b87dd2b7a 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -189,7 +189,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); /* - if(_surface == NULL) + if (_surface == NULL) { _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); return STATUS_FAILED; @@ -217,7 +217,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl bool res; - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) if (_alpha != 0xFFFFFFFF) alpha = _alpha; if (rotate != 0.0f) { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0dd10f6bdc..d8ba0cbbce 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -147,7 +147,7 @@ bool BaseSurfaceStorage::restoreAll() { bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { - if(!persistMgr->getIsSaving()) cleanup(false); + if (!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 7bffbc35c8..d576b834a2 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -73,7 +73,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { bool BaseFont::loadFile(const char * Filename) { BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ + if (Buffer==NULL){ _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -83,7 +83,7 @@ bool BaseFont::loadFile(const char * Filename) _filename = new char [strlen(filename)+1]; strcpy(_filename, filename); - if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); delete[] Buffer; @@ -105,7 +105,7 @@ bool BaseFont::loadBuffer(byte * Buffer) int cmd; BaseParser parser(_gameRef); - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); return STATUS_FAILED; } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 57e08135ed..a519da5832 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -591,11 +591,11 @@ bool ScScript::executeInstruction() { } /* ScValue* val = var->getProp(MethodName); - if(val){ + if (val){ dw = GetFuncPos(val->getString()); - if(dw==0){ + if (dw==0){ TExternalFunction* f = GetExternal(val->getString()); - if(f){ + if (f){ ExternalCall(_stack, _thisStack, f); } else{ @@ -776,7 +776,7 @@ bool ScScript::executeInstruction() { case II_JMP_FALSE: { dw = getDWORD(); - //if(!_stack->pop()->getBool()) _iP = dw; + //if (!_stack->pop()->getBool()) _iP = dw; ScValue *val = _stack->pop(); if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); @@ -864,7 +864,7 @@ bool ScScript::executeInstruction() { case II_NOT: op1 = _stack->pop(); - //if(op1->isNULL()) _operand->setNULL(); + //if (op1->isNULL()) _operand->setNULL(); if (op1->isNULL()) _operand->setBool(true); else _operand->setBool(!op1->getBool()); _stack->push(_operand); @@ -900,14 +900,14 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if(op1->isNative() && op2->isNative()){ + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if (op1->isNative() && op2->isNative()){ _operand->setBool(op1->getNative() == op2->getNative()); } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() == op2->getFloat()); } else{ @@ -924,14 +924,14 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if(op1->isNative() && op2->isNative()){ + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if (op1->isNative() && op2->isNative()){ _operand->setBool(op1->getNative() != op2->getNative()); } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() != op2->getFloat()); } else{ @@ -948,7 +948,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() < op2->getFloat()); } else _operand->setBool(op1->getInt() < op2->getInt()); @@ -963,7 +963,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() > op2->getFloat()); } else _operand->setBool(op1->getInt() > op2->getInt()); @@ -978,7 +978,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() <= op2->getFloat()); } else _operand->setBool(op1->getInt() <= op2->getInt()); @@ -993,7 +993,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() >= op2->getFloat()); } else _operand->setBool(op1->getInt() >= op2->getInt()); @@ -1257,7 +1257,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; + //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); if (!pos) return NULL; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index c33d844aa1..792dfd4589 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -257,14 +257,14 @@ bool ScEngine::tick() { bool obj_found=false; for(int j=0; j<_gameRef->_regObjects.getSize(); j++) { - if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) { - if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + if (_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); obj_found = true; break; } } - if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (_gameRef->validObject(_scripts[i]->_waitObject)) { if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 322fb9bc5b..d2fd3663c7 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -228,7 +228,7 @@ bool SXDate::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Name")==0){ + if (strcmp(name, "Name")==0){ setName(value->getString()); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 01179bb3ad..7da1601bdc 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -663,12 +663,12 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ + if (strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(value->getInt(0), 0); char PropName[20]; - if(_length < OrigLength){ + if (_length < OrigLength){ for(int i=_length; iDeleteProp(PropName); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 6b791871ad..3d3f0b218b 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -462,12 +462,12 @@ bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ + if (strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(value->getInt(0), 0); char PropName[20]; - if(_length < OrigLength){ + if (_length < OrigLength){ for(int i=_length; iDeleteProp(PropName); diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 59e0965f5e..5e824cd10c 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -240,7 +240,7 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs val->_isConstVar = SetAsConst; _valObject[Name] = val; - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + if (_type!=VAL_NATIVE) _type = VAL_OBJECT; */ } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 0b7fc840bf..27276f4fa7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -148,22 +148,22 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { bool res; bool NewlyCreated = false; - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = _gameRef->_fileManager->openFile(filename); - if(!_file){ + if (!_soundBuffer || ForceReload || _streamed){ + if (!_file) _file = _gameRef->_fileManager->openFile(filename); + if (!_file){ _gameRef->LOG(0, "Error opening sound file '%s'", filename); return STATUS_FAILED; } // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + if (!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); } // create buffer - if(!_soundBuffer){ + if (!_soundBuffer){ NewlyCreated = true; res = InitializeBuffer(_file); - if(DID_FAIL(res)){ + if (DID_FAIL(res)){ _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); return res; } @@ -172,13 +172,13 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { // store filename - if(!_filename){ + if (!_filename){ _filename = new char[strlen(filename)+1]; strcpy(_filename, filename); } // close file (if not streaming) - if(!_streamed && _file){ + if (!_streamed && _file){ _gameRef->_fileManager->closeFile(_file); _file = NULL; } diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index 8e222cfce3..f8213570e4 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -48,11 +48,4 @@ #define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP -#ifdef GetClassName -#undef GetClassName -#endif - -// macros -#define RELEASE(obj) if(obj) { obj->Release(); obj = NULL; } else 0 - #endif // _DCGF_H_ diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index fab724eb06..2c4cecdc85 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -627,7 +627,7 @@ bool UIButton::display(int offsetX, int offsetY) { } if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); - //if(image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); + //if (image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); if (font && _text) { diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index ac16104268..464cbec7ff 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -217,11 +217,11 @@ bool VideoPlayer::update() { DWORD CurrentTime; // current playing time (in ms) /* - if(m_SoundAvailable && m_Sound){ + if (m_SoundAvailable && m_Sound){ CurrentTime = m_Sound->GetPosition(); // in samples CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); - if(!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; + if (!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; } else CurrentTime = timeGetTime() - m_StartTime; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 97fba01201..91703e40b7 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -547,7 +547,7 @@ bool VideoTheoraPlayer::update() { // If playback has begun, top audio buffer off immediately. - //if(m_Sound) WriteAudio(); + //if (m_Sound) WriteAudio(); // are we at or past time for this video frame? if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index d797972e40..55204bcc74 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -165,7 +165,7 @@ int WinterMuteEngine::init() { bool windowedMode = !ConfMan.getBool("fullscreen"); // parse command line - char *SaveGame = NULL; + char *saveGame = NULL; /* for (int i = 0; i < argc; i++) { strcpy(param, argv[i]); @@ -268,9 +268,9 @@ int WinterMuteEngine::init() { _game->loadGame(str.c_str()); } - if (SaveGame) { - _game->loadGame(SaveGame); - delete[] SaveGame; + if (saveGame) { + _game->loadGame(saveGame); + delete[] saveGame; } // all set, ready to go @@ -314,9 +314,9 @@ int WinterMuteEngine::messageLoop() { if (_game) { // remember previous window position /* - if(_game->_renderer && _game->_renderer->_windowed) + if (_game->_renderer && _game->_renderer->_windowed) { - if(!::IsIconic(_game->_renderer->_window)) + if (!::IsIconic(_game->_renderer->_window)) { int PosX = _game->_renderer->_windowRect.left; int PosY = _game->_renderer->_windowRect.top; -- cgit v1.2.3 From 38507fa9895620639d8733dbb4e085dfb2282a33 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 04:12:58 +0200 Subject: WINTERMUTE: AStyle-formatting. --- engines/wintermute/ad/ad_actor.cpp | 2 +- engines/wintermute/ad/ad_game.h | 4 +- engines/wintermute/ad/ad_item.cpp | 2 +- engines/wintermute/ad/ad_node_state.cpp | 35 +++--- engines/wintermute/ad/ad_response_box.h | 6 +- engines/wintermute/ad/ad_talk_holder.cpp | 4 +- engines/wintermute/ad/ad_types.h | 36 +++--- engines/wintermute/base/base_file_manager.cpp | 10 +- engines/wintermute/base/base_file_manager.h | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 28 ++--- engines/wintermute/base/base_game.h | 14 +-- engines/wintermute/base/base_keyboard_state.cpp | 48 ++++---- engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/base_parser.h | 2 +- .../wintermute/base/base_persistence_manager.cpp | 4 +- engines/wintermute/base/base_registry.cpp | 4 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 8 +- .../wintermute/base/base_transition_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 8 +- engines/wintermute/base/file/base_disk_file.h | 2 +- engines/wintermute/base/file/base_file_entry.cpp | 10 +- engines/wintermute/base/file/base_package.cpp | 40 +++---- engines/wintermute/base/file/base_package.h | 6 +- engines/wintermute/base/file/base_resources.cpp | 2 +- engines/wintermute/base/file/base_resources.h | 2 +- engines/wintermute/base/file/dcpackage.h | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 4 +- engines/wintermute/base/gfx/base_renderer.h | 4 +- engines/wintermute/base/gfx/base_surface.h | 2 +- .../base/gfx/osystem/base_render_osystem.cpp | 74 ++++++------ .../base/gfx/osystem/base_render_osystem.h | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- engines/wintermute/base/particles/part_emitter.h | 32 +++--- engines/wintermute/base/sound/base_sound.cpp | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 4 +- .../wintermute/base/sound/base_sound_manager.cpp | 2 +- engines/wintermute/dcscript.h | 16 +-- engines/wintermute/dctypes.h | 118 +++++++++---------- engines/wintermute/detection.cpp | 116 +++++++++---------- engines/wintermute/math/math_util.cpp | 4 +- engines/wintermute/math/math_util.h | 4 +- engines/wintermute/math/matrix4.cpp | 4 +- engines/wintermute/math/matrix4.h | 4 +- engines/wintermute/math/rect32.h | 36 +++--- engines/wintermute/math/vector2.cpp | 4 +- engines/wintermute/math/vector2.h | 4 +- engines/wintermute/utils/path_util.cpp | 14 +-- engines/wintermute/utils/string_util.cpp | 2 +- engines/wintermute/utils/utils.cpp | 8 +- engines/wintermute/wintermute.cpp | 126 ++++++++++----------- engines/wintermute/wintermute.h | 4 +- engines/wintermute/wintypes.h | 4 +- 54 files changed, 452 insertions(+), 439 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index fc28293ac8..fe1948d3a8 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -790,7 +790,7 @@ void AdActor::getNextStep() { maxStepX--; } - if (((AdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) { + if (((AdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX, (int) _pFY, true, this)) { if (_pFCount == 0) { _state = _nextState; _nextState = STATE_READY; diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 5136ed09d3..49c48de0bb 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -151,10 +151,10 @@ private: BaseArray _items; BaseArray _sentences; - + BaseArray _sceneStates; BaseArray _dlgPendingBranches; - + BaseArray _responsesBranch; BaseArray _responsesGame; diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index e9a1bb4353..cae974e152 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -375,7 +375,7 @@ bool AdItem::update() { } } default: - break; + break; } _ready = (_state == STATE_READY); diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 6212274d03..444373ea75 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -44,7 +44,8 @@ IMPLEMENT_PERSISTENT(AdNodeState, false) AdNodeState::AdNodeState(BaseGame *inGame): BaseClass(inGame) { _name = NULL; _active = false; - for (int i = 0; i < 7; i++) _caption[i] = NULL; + for (int i = 0; i < 7; i++) + _caption[i] = NULL; _alphaColor = 0; _filename = NULL; _cursor = NULL; @@ -99,7 +100,8 @@ bool AdNodeState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_cursor)); persistMgr->transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); return STATUS_OK; } @@ -107,23 +109,27 @@ bool AdNodeState::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setCaption(const char *caption, int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7) return; - - delete[] _caption[caseVal- 1]; - _caption[caseVal- 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal- 1]) { - strcpy(_caption[caseVal- 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal- 1]); + if (caseVal == 0) + caseVal = 1; + if (caseVal < 1 || caseVal > 7) + return; + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); } } ////////////////////////////////////////////////////////////////////////// char *AdNodeState::getCaption(int caseVal) { - if (caseVal== 0) caseVal= 1; - if (caseVal< 1 || caseVal> 7 || _caption[caseVal- 1] == NULL) return ""; - else return _caption[caseVal- 1]; + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else + return _caption[caseVal - 1]; } @@ -132,7 +138,8 @@ bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool s if (!entity) return STATUS_FAILED; // HACK! - if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef; + if (this->_gameRef != entity->_gameRef) + this->_gameRef = entity->_gameRef; if (saving) { for (int i = 0; i < 7; i++) { diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index f77ff3360c..5dc22cbebe 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -52,9 +52,9 @@ public: ScScript *_waitingScript; virtual bool listen(BaseScriptHolder *param1, uint32 param2); typedef enum { - EVENT_PREV, - EVENT_NEXT, - EVENT_RESPONSE + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE } TResponseEvent; bool weedResponses(); diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 359215ee8f..d47cbb446e 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -222,7 +222,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } else { for (int i = 0; i < _talkSprites.getSize(); i++) { if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { - if (_currentSprite == _talkSprites[i]) + if (_currentSprite == _talkSprites[i]) setCurrent = true; if (_tempSprite2 == _talkSprites[i]) setTemp2 = true; @@ -282,7 +282,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS // set new if (ex) _talkSpritesEx.add(spr); - else + else _talkSprites.add(spr); stack->pushBool(true); diff --git a/engines/wintermute/ad/ad_types.h b/engines/wintermute/ad/ad_types.h index b88d6fe259..18892919c6 100644 --- a/engines/wintermute/ad/ad_types.h +++ b/engines/wintermute/ad/ad_types.h @@ -33,19 +33,19 @@ namespace WinterMute { typedef enum { GAME_NORMAL, - GAME_WAITING_RESPONSE + GAME_WAITING_RESPONSE } TGameStateEx; typedef enum { OBJECT_ENTITY, - OBJECT_REGION, - OBJECT_ACTOR, - OBJECT_NONE + OBJECT_REGION, + OBJECT_ACTOR, + OBJECT_NONE } TObjectType; typedef enum { ENTITY_NORMAL, - ENTITY_SOUND + ENTITY_SOUND } TEntityType; typedef enum { @@ -66,40 +66,40 @@ typedef enum { typedef enum { DIRECT_WALK_NONE, - DIRECT_WALK_FW, - DIRECT_WALK_BK + DIRECT_WALK_FW, + DIRECT_WALK_BK } TDirectWalkMode; typedef enum { DIRECT_TURN_NONE, - DIRECT_TURN_CW, - DIRECT_TURN_CCW + DIRECT_TURN_CW, + DIRECT_TURN_CCW } TDirectTurnMode; typedef enum { RESPONSE_TEXT, - RESPONSE_ICON + RESPONSE_ICON } TResponseStyle; typedef enum { RESPONSE_ALWAYS, - RESPONSE_ONCE, - RESPONSE_ONCE_GAME + RESPONSE_ONCE, + RESPONSE_ONCE_GAME } TResponseType; typedef enum { TALK_SKIP_LEFT = 0, - TALK_SKIP_RIGHT = 1, - TALK_SKIP_BOTH = 2, - TALK_SKIP_NONE = 3 + TALK_SKIP_RIGHT = 1, + TALK_SKIP_BOTH = 2, + TALK_SKIP_NONE = 3 } TTalkSkipButton; typedef enum { GEOM_WAYPOINT, - GEOM_WALKPLANE, - GEOM_BLOCKED, - GEOM_GENERIC + GEOM_WALKPLANE, + GEOM_BLOCKED, + GEOM_GENERIC } TGeomNodeType; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index b25bbf024d..c296f88699 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -119,7 +119,7 @@ bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { switch (type) { case PATH_SINGLE: - // _singlePaths.push_back(path); + // _singlePaths.push_back(path); error("TODO: Allow adding single-paths"); break; case PATH_PACKAGE: @@ -154,7 +154,7 @@ bool BaseFileManager::initPaths() { Common::String path = entries->nextToken(); if (path.size() > 0) { error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); + // addPath(PATH_SINGLE, path); } } delete entries; @@ -170,7 +170,7 @@ bool BaseFileManager::initPaths() { Common::String path = entries->nextToken(); if (path.size() > 0) { error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); + // addPath(PATH_SINGLE, path); } } delete entries; @@ -244,7 +244,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH_LENGTH]; strcpy(fileName, upcName.c_str()); - + // correct slashes for (int32 i = 0; i < upcName.size(); i++) { if (upcName[i] == '/') @@ -300,7 +300,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); - } + } delete SaveThumbFile; return ret; } diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index e3c20378bb..c49bbe3815 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -52,7 +52,7 @@ public: private: typedef enum { PATH_PACKAGE, - PATH_SINGLE + PATH_SINGLE } TPathType; bool reloadPaths(); bool initPaths(); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 77e959f11b..67edccd041 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,7 +61,7 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) + for (int i = 0; i < _subframes.getSize(); i++) delete _subframes[i]; _subframes.removeAll(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 63040f2db2..b2b92d6de4 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -259,10 +259,10 @@ BaseGame::BaseGame(): BaseObject(this) { _autoSaveSlot = 999; _cursorHidden = false; -/*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else*/ + /*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices + #else*/ _touchInterface = false; _constrainedMemory = false; //#endif @@ -460,7 +460,7 @@ bool BaseGame::initialize1() { if (_fader == NULL) break; registerObject(_fader); - + loaded = true; } if (loaded == true) { @@ -2120,9 +2120,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif*/ + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); + #endif*/ stack->pushNULL(); return STATUS_OK; @@ -2133,9 +2133,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif*/ + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); + #endif*/ stack->pushNULL(); return STATUS_OK; @@ -3919,9 +3919,9 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (custom) *custom = true; } else { BasePlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); if (custom) *custom = false; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 34dec89d20..8da62af40a 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -212,7 +212,7 @@ public: virtual bool loadGame(const char *filename); virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - + BaseObject *_activeObject; bool _interactive; @@ -296,21 +296,21 @@ private: int _indicatorY; int _indicatorWidth; int _indicatorHeight; - + char *_localSaveDir; bool _saveDirChecked; bool _richSavedGames; char *_savedGameExt; - + char *_loadImageName; char *_saveImageName; int _saveImageX; int _saveImageY; int _loadImageX; int _loadImageY; - + BaseSurface *_saveLoadImage; - + bool _reportTextureFormat; // FPS stuff @@ -328,7 +328,7 @@ private: bool _compressedSavegames; bool _personalizedSave; - + bool emptySaveSlot(int slot); bool isSaveSlotUsed(int slot); bool getSaveSlotDescription(int slot, char *buffer); @@ -353,7 +353,7 @@ private: uint32 _fps; bool updateMusicCrossfade(); - + bool isVideoPlaying(); bool stopVideo(); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index a85ec3e972..03f9929eee 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -266,36 +266,36 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { } enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 }; ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { - case VK_SPACE: - return Common::KEYCODE_SPACE; - break; - case VK_LEFT: - return Common::KEYCODE_LEFT; - break; - case VK_RIGHT: - return Common::KEYCODE_RIGHT; - break; - case VK_UP: - return Common::KEYCODE_UP; - break; - case VK_DOWN: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; } } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 588d210134..12ed67ba2a 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -180,7 +180,7 @@ char *BaseParser::getAssignmentText(char **buf) { break; ++*buf; } - **buf = 0; // null terminate it + **buf = 0; // null terminate it if (theChar) // skip the terminator ++*buf; } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index a5c55ceb41..03ca71b48d 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -60,7 +60,7 @@ namespace WinterMute { class BaseParser : public BaseClass { public: struct TokenDesc { - int32 id; + int32 id; const char *token; }; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 3f9e8de855..cf7deb2970 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -420,12 +420,12 @@ Common::String BasePersistenceManager::getStringObj() { _loadStream->read(ret, len); ret[len] = '\0'; - Common::String retString = ret; + Common::String retString = ret; delete[] ret; if (retString == "(null)") { retString = ""; - } + } return retString; } diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index dfab1b5076..7eb2685746 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -103,7 +103,7 @@ int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int i return init; } } - } + } AnsiString val = readString(subKey, key, ""); if (val.empty()) return init; else return atoi(val.c_str()); @@ -126,7 +126,7 @@ bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int error("This key shouldn't be read by the scripts"); return true; } - } + } writeString(subKey, key, StringUtil::toString(value)); return true; } diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 03b0ef3615..c2e57f9fd6 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -583,7 +583,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) + if (index < 0) index = 0; ScValue *val = stack->pop(); diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 0b87dd2b7a..523bbed866 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -239,10 +239,10 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo float ratioY = scaleY / 100.0f; BasePlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); return true; } diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 53dd99aac2..eeaacd2063 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -69,7 +69,7 @@ bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { _origInteractive = _gameRef->_interactive; _gameRef->_interactive = false; } /*else _preserveInteractive */; - + _type = type; _state = TRANS_MGR_RUNNING; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 1598101036..bb8504d2f4 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -46,7 +46,7 @@ void correctSlashes(char *fileName) { } // Parse a relative path in the game-folder, and if it exists, return a FSNode to it. -static Common::FSNode getNodeForRelativePath(const Common::String& filename) { +static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) @@ -88,11 +88,11 @@ static Common::FSNode getNodeForRelativePath(const Common::String& filename) { return Common::FSNode(); } -bool diskFileExists(const Common::String& filename) { +bool diskFileExists(const Common::String &filename) { // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { return true; @@ -112,7 +112,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { file = (*it)->createReadStream(); diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 0653b2e854..99a9e8b9a3 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -34,7 +34,7 @@ namespace WinterMute { Common::SeekableReadStream *openDiskFile(const Common::String &filename); -bool diskFileExists(const Common::String& filename); +bool diskFileExists(const Common::String &filename); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 5032650704..8282079c86 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -62,11 +62,11 @@ public: Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); if (!file) return NULL; - + // TODO: Cleanup bool compressed = (_compressedLength != 0); /* _size = fileEntry->_length; */ - + if (compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. @@ -77,14 +77,14 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { if (file->size() == 0) { file = new CBPkgFile(file, _length); } - + file->seek(0); - + return file; } ////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry(){ +BaseFileEntry::BaseFileEntry() { _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 90bb027042..f2d2378c6a 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -51,33 +51,33 @@ Common::SeekableReadStream *BasePackage::getFilePointer() { static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; - + byte signature[8]; ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - + uint32 fileSize = (uint32)f->size(); uint32 startPos = 1024 * 1024; uint32 bytesRead = startPos; - + while (bytesRead < fileSize - 16) { uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); f->seek((int32)startPos, SEEK_SET); uint32 actuallyRead = f->read(buf, toRead); if (actuallyRead != toRead) return false; - + for (uint32 i = 0; i < toRead - 8; i++) if (!memcmp(buf + i, signature, 8)) { *offset = startPos + i; return true; } - + bytesRead = bytesRead + toRead - 16; startPos = startPos + toRead - 16; - + } return false; - + } PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { @@ -98,7 +98,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool boundToExe = true; } } - + TPackageHeader hdr; hdr.readFromStream(stream); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { @@ -106,7 +106,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool delete stream; return; } - + if (hdr._packageVersion != PACKAGE_VERSION) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } @@ -125,7 +125,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool pkg->_fsnode = file; pkg->_boundToExe = boundToExe; - + // read package info byte nameLength = stream->readByte(); char *pkgName = new char[nameLength]; @@ -141,15 +141,15 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool // read file entries uint32 numFiles = stream->readUint32LE(); - + for (uint32 j = 0; j < numFiles; j++) { char *name; uint32 offset, length, compLength, flags, timeDate1, timeDate2; - + nameLength = stream->readByte(); name = new char[nameLength]; stream->read(name, nameLength); - + // v2 - xor name if (hdr._packageVersion == PACKAGE_VERSION) { for (int k = 0; k < nameLength; k++) { @@ -157,18 +157,18 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - + Common::String upcName = name; upcName.toUppercase(); delete[] name; name = NULL; - + offset = stream->readUint32LE(); offset += absoluteOffset; length = stream->readUint32LE(); compLength = stream->readUint32LE(); flags = stream->readUint32LE(); - + if (hdr._packageVersion == PACKAGE_VERSION) { timeDate1 = stream->readUint32LE(); timeDate2 = stream->readUint32LE(); @@ -181,12 +181,12 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool fileEntry->_length = length; fileEntry->_compressedLength = compLength; fileEntry->_flags = flags; - + _files[upcName] = Common::ArchiveMemberPtr(fileEntry); } else { // current package has higher priority than the registered // TODO: This cast might be a bit ugly. - BaseFileEntry *filePtr = (BaseFileEntry*) &*(_filesIter->_value); + BaseFileEntry *filePtr = (BaseFileEntry *) &*(_filesIter->_value); if (pkg->_priority > filePtr->_package->_priority) { filePtr->_package = pkg; filePtr->_offset = offset; @@ -198,12 +198,12 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - + delete stream; } PackageSet::~PackageSet() { - for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { delete *it; } _packages.clear(); diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index b9a7bc5934..a562229f65 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -48,7 +48,7 @@ public: class PackageSet : public Common::Archive { public: virtual ~PackageSet(); - + PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); /** * Check if a member with the given name is present in the Archive. @@ -64,12 +64,12 @@ public: * @return the number of names added to list */ virtual int listMembers(Common::ArchiveMemberList &list) const; - + /** * Returns a ArchiveMember representation of the given file. */ virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - + /** * Create a stream bound to a member with the specified name in the * archive. If no member with this name exists, 0 is returned. diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 73c06271d7..aac5436071 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2816,7 +2816,7 @@ Common::SeekableReadStream *BaseResources::getFile(const Common::String &filenam return NULL; } -bool BaseResources::hasFile(const Common::String& filename) { +bool BaseResources::hasFile(const Common::String &filename) { if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { return true; } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 2959f9882f..2ccab6996f 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -37,7 +37,7 @@ namespace WinterMute { class BaseResources { public: static Common::SeekableReadStream *getFile(const Common::String &filename); - static bool hasFile(const Common::String& filename); + static bool hasFile(const Common::String &filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 5e47edba56..4a51683260 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index dd5d006556..0a97370cb7 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -646,8 +646,8 @@ bool BaseFontTT::initFont() { AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; }*/ } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 90a1e378ca..83b5ad0e16 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -74,7 +74,7 @@ public: virtual void fade(uint16 alpha) = 0; /** * Fade a portion of the screen to a specific color - * + * * @param r the red component to fade too. * @param g the green component to fade too. * @param b the blue component to fade too. @@ -93,7 +93,7 @@ public: virtual bool windowedBlt(); /** * Fill a portion of the screen with a specified color - * + * * @param r the red component to fill with. * @param g the green component to fill with. * @param b the blue component to fill with. diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index cb98bde722..66a3460d48 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -86,7 +86,7 @@ protected: byte _ckRed; byte _ckGreen; byte _ckBlue; - + bool _keepLoaded; Common::String _filename; int _height; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 09ee62c3b8..43cf66d053 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -43,11 +43,11 @@ namespace WinterMute { RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; - _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - _mirror |= TransparentSurface::FLIP_H; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -78,13 +78,13 @@ RenderTicket::~RenderTicket() { bool RenderTicket::operator==(RenderTicket &t) { if ((t._srcRect != _srcRect) || - (t._dstRect != _dstRect) || - (t._mirror != _mirror) || - (t._owner != _owner) || - (t._hasAlpha != _hasAlpha) || - (t._colorMod != _colorMod)) { - return false; - } + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } return true; } @@ -137,22 +137,22 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { // find suitable resolution -/*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } -#else*/ + /*#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } + #else*/ _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); //#endif @@ -257,7 +257,7 @@ bool BaseRenderOSystem::flip() { if (_disableDirtyRects) { g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); } - // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); delete _dirtyRect; _dirtyRect = NULL; g_system->updateScreen(); @@ -347,7 +347,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (_disableDirtyRects) { RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); return; } @@ -355,8 +355,8 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; } - - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); compare._colorMod = _colorMod; RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { @@ -397,14 +397,14 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); } else { // Before something - Common::List::iterator pos; + Common::List::iterator pos; for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { if ((*pos)->_drawNum >= _drawNum) { break; } } _renderQueue.insert(pos, renderTicket); - Common::List::iterator it; + Common::List::iterator it; renderTicket->_drawNum = _drawNum++; // Increment the following tickets, so they still are in line for (it = pos; it != _renderQueue.end(); it++) { @@ -432,7 +432,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { // Decreement the following tickets. for (; it != _renderQueue.end(); it++) { (*it)->_drawNum--; - } + } } // Is not in order, so readd it as if it was a new ticket renderTicket->_drawNum = 0; @@ -457,7 +457,7 @@ void BaseRenderOSystem::drawTickets() { int decrement = 0; while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { - RenderTicket* ticket = *it; + RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); @@ -474,7 +474,7 @@ void BaseRenderOSystem::drawTickets() { // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; // warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); - + // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); _drawNum = 1; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index b7507098da..0d00b1b427 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -102,9 +102,9 @@ private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); - typedef Common::List::iterator RenderQueueIterator; + typedef Common::List::iterator RenderQueueIterator; Common::Rect *_dirtyRect; - Common::List _renderQueue; + Common::List _renderQueue; bool _needsFlip; uint32 _drawNum; Common::Rect _renderRect; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index c8cbe99f73..36213dfde1 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -190,7 +190,7 @@ bool BaseSurfaceOSystem::finishLoad() { delete image; _loaded = true; - + return true; } @@ -529,7 +529,7 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl _hasAlpha = hasAlpha; BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); - + return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 198e415cc4..fc557a9512 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -72,57 +72,57 @@ public: private: int _width; int _height; - + int _angle1; int _angle2; - + float _rotation1; float _rotation2; - + float _angVelocity1; float _angVelocity2; - + float _growthRate1; float _growthRate2; bool _exponentialGrowth; - + float _velocity1; float _velocity2; bool _velocityZBased; - + float _scale1; float _scale2; bool _scaleZBased; - + int _maxParticles; - + int _lifeTime1; int _lifeTime2; bool _lifeTimeZBased; - + int _genInterval; int _genAmount; - + bool _running; int _overheadTime; - + int _maxBatches; int _batchesGenerated; - + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; int _borderThicknessBottom; - + int _fadeInTime; - + int _alpha1; int _alpha2; bool _alphaTimeBased; - + bool _useRegion; - + char *_emitEvent; BaseScriptHolder *_owner; diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 1853d7abfd..8cc8c21948 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -229,7 +229,7 @@ bool BaseSound::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) + if (!_sound) return STATUS_FAILED; else return _sound->_privateVolume = volume; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 27276f4fa7..f2db0a18fb 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -110,7 +110,7 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { int waveSize, waveRate; byte waveFlags; uint16 waveType; - + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { if (waveType == 1) { // We need to wrap the file in a substream to make sure the size is right. @@ -208,7 +208,7 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { } else { g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); } - } + } return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index a73b20e404..cebc3a3765 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -80,7 +80,7 @@ void BaseSoundMgr::saveSettings() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::initialize() { _soundAvailable = false; - + if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h index 36d84b45d9..9610ebf94c 100644 --- a/engines/wintermute/dcscript.h +++ b/engines/wintermute/dcscript.h @@ -50,14 +50,14 @@ typedef enum { // script states typedef enum { SCRIPT_RUNNING, - SCRIPT_WAITING, - SCRIPT_SLEEPING, - SCRIPT_FINISHED, - SCRIPT_PERSISTENT, - SCRIPT_ERROR, - SCRIPT_PAUSED, - SCRIPT_WAITING_SCRIPT, - SCRIPT_THREAD_FINISHED + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED } TScriptState; // opcodes diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index 4d56ac1459..edca18a6ed 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -52,44 +52,44 @@ typedef Common::Array AnsiStringArray; enum TGameState { GAME_RUNNING, - GAME_FROZEN, - GAME_SEMI_FROZEN + GAME_FROZEN, + GAME_SEMI_FROZEN }; -enum TImageType { - IMG_PALETTED8, - IMG_TRUECOLOR +enum TImageType { + IMG_PALETTED8, + IMG_TRUECOLOR }; enum TTextAlign { TAL_LEFT = 0, - TAL_RIGHT, - TAL_CENTER, - NUM_TEXT_ALIGN + TAL_RIGHT, + TAL_CENTER, + NUM_TEXT_ALIGN }; enum TVerticalAlign { VAL_TOP = 0, - VAL_CENTER, - VAL_BOTTOM, - NUM_VERTICAL_ALIGN + VAL_CENTER, + VAL_BOTTOM, + NUM_VERTICAL_ALIGN }; enum TDirection { - DI_UP = 0, - DI_UPRIGHT = 1, - DI_RIGHT = 2, - DI_DOWNRIGHT = 3, - DI_DOWN = 4, - DI_DOWNLEFT = 5, - DI_LEFT = 6, - DI_UPLEFT = 7, - NUM_DIRECTIONS = 8, - DI_NONE = 9 + DI_UP = 0, + DI_UPRIGHT = 1, + DI_RIGHT = 2, + DI_DOWNRIGHT = 3, + DI_DOWN = 4, + DI_DOWNLEFT = 5, + DI_LEFT = 6, + DI_UPLEFT = 7, + NUM_DIRECTIONS = 8, + DI_NONE = 9 }; @@ -113,20 +113,20 @@ enum TEventType { enum TUIObjectType { UI_UNKNOWN, - UI_BUTTON, - UI_WINDOW, - UI_STATIC, - UI_EDIT, - UI_HTML, - UI_CUSTOM + UI_BUTTON, + UI_WINDOW, + UI_STATIC, + UI_EDIT, + UI_HTML, + UI_CUSTOM }; enum TRendererState { RSTATE_3D, - RSTATE_2D, - RSTATE_LINES, - RSTATE_NONE + RSTATE_2D, + RSTATE_LINES, + RSTATE_NONE }; @@ -137,29 +137,29 @@ enum TDynamicConstructor { enum TVideoMode { VIDEO_WINDOW, - VIDEO_FULLSCREEN, - VIDEO_ANY + VIDEO_FULLSCREEN, + VIDEO_ANY }; enum TVideoPlayback { - VID_PLAY_POS = 0, - VID_PLAY_STRETCH = 1, - VID_PLAY_CENTER = 2 + VID_PLAY_POS = 0, + VID_PLAY_STRETCH = 1, + VID_PLAY_CENTER = 2 }; enum TMouseEvent { MOUSE_CLICK, - MOUSE_RELEASE, - MOUSE_DBLCLICK + MOUSE_RELEASE, + MOUSE_DBLCLICK }; enum TMouseButton { MOUSE_BUTTON_LEFT, - MOUSE_BUTTON_RIGHT, - MOUSE_BUTTON_MIDDLE + MOUSE_BUTTON_RIGHT, + MOUSE_BUTTON_MIDDLE }; @@ -169,56 +169,56 @@ enum TTransMgrState { enum TTransitionType { - TRANSITION_NONE = 0, + TRANSITION_NONE = 0, TRANSITION_FADE_OUT = 1, - TRANSITION_FADE_IN = 2, + TRANSITION_FADE_IN = 2, NUM_TRANSITION_TYPES }; enum TWindowMode { WINDOW_NORMAL, - WINDOW_EXCLUSIVE, - WINDOW_SYSTEM_EXCLUSIVE + WINDOW_EXCLUSIVE, + WINDOW_SYSTEM_EXCLUSIVE }; enum TSFXType { SFX_NONE, - SFX_ECHO, - SFX_REVERB + SFX_ECHO, + SFX_REVERB }; enum TSpriteCacheType { CACHE_ALL, - CACHE_HALF + CACHE_HALF }; enum TTextEncoding { TEXT_ANSI = 0, - TEXT_UTF8 = 1, - NUM_TEXT_ENCODINGS + TEXT_UTF8 = 1, + NUM_TEXT_ENCODINGS }; enum TSpriteBlendMode { - BLEND_UNKNOWN = -1, - BLEND_NORMAL = 0, - BLEND_ADDITIVE = 1, - BLEND_SUBTRACTIVE = 2, - NUM_BLEND_MODES + BLEND_UNKNOWN = -1, + BLEND_NORMAL = 0, + BLEND_ADDITIVE = 1, + BLEND_SUBTRACTIVE = 2, + NUM_BLEND_MODES }; enum TTTSType { TTS_CAPTION = 0, - TTS_TALK, - TTS_KEYPRESS + TTS_TALK, + TTS_KEYPRESS }; enum TShadowType { - SHADOW_NONE = 0, - SHADOW_SIMPLE = 1, - SHADOW_FLAT = 2, - SHADOW_STENCIL = 3 + SHADOW_NONE = 0, + SHADOW_SIMPLE = 1, + SHADOW_FLAT = 2, + SHADOW_STENCIL = 3 }; } // end of namespace WinterMute diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 85b8dcf429..92ffcf3154 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -64,55 +64,55 @@ public: return "Copyright (c) 2011 Jan Nedoma"; } -/* virtual GameList getSupportedGames() const { - GameList games; - const PlainGameDescriptor *g = wintermuteGames; - while (g->gameid) { - games.push_back(*g); - g++; - } - - return games; - } + /* virtual GameList getSupportedGames() const { + GameList games; + const PlainGameDescriptor *g = wintermuteGames; + while (g->gameid) { + games.push_back(*g); + g++; + } + + return games; + } + + virtual GameDescriptor findGame(const char *gameid) const { + const PlainGameDescriptor *g = wintermuteGames; + while (g->gameid) { + if (0 == scumm_stricmp(gameid, g->gameid)) + break; + g++; + } + return GameDescriptor(g->gameid, g->description); + }*/ + + /* virtual GameList detectGames(const Common::FSList &fslist) const { + GameList detectedGames; + + // Iterate over all files in the given directory + for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { + if (!file->isDirectory()) { + const char *gameName = file->getName().c_str(); + + if (0 == scumm_stricmp("data.dcp", gameName)) { + // You could check the contents of the file now if you need to. + detectedGames.push_back(WinterMute_setting[0]); + break; + } + } + } + return detectedGames; + }*/ - virtual GameDescriptor findGame(const char *gameid) const { - const PlainGameDescriptor *g = wintermuteGames; - while (g->gameid) { - if (0 == scumm_stricmp(gameid, g->gameid)) - break; - g++; - } - return GameDescriptor(g->gameid, g->description); - }*/ -/* virtual GameList detectGames(const Common::FSList &fslist) const { - GameList detectedGames; - - // Iterate over all files in the given directory - for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - if (!file->isDirectory()) { - const char *gameName = file->getName().c_str(); - - if (0 == scumm_stricmp("data.dcp", gameName)) { - // You could check the contents of the file now if you need to. - detectedGames.push_back(WinterMute_setting[0]); - break; - } - } - } - return detectedGames; - }*/ - - virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { // Set some defaults s_fallbackDesc.extra = ""; s_fallbackDesc.language = Common::UNK_LANG; s_fallbackDesc.flags = ADGF_UNSTABLE; - s_fallbackDesc.platform = Common::kPlatformWindows; // default to Windows + s_fallbackDesc.platform = Common::kPlatformWindows; // default to Windows s_fallbackDesc.gameid = "wintermute"; s_fallbackDesc.guioptions = GUIO0(); - + if (allFiles.contains("data.dcp")) { Common::String name, caption; if (WinterMuteEngine::getGameInfo(fslist, name, caption)) { @@ -139,7 +139,7 @@ public: } return 0; } - + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { assert(syst); assert(engine); @@ -150,20 +150,20 @@ public: bool hasFeature(MetaEngineFeature f) const { switch (f) { - case MetaEngine::kSupportsListSaves: - return true; - case MetaEngine::kSupportsLoadingDuringStartup: - return true; - case MetaEngine::kSupportsDeleteSave: - return true; - case MetaEngine::kSavesSupportCreationDate: - return true; - case MetaEngine::kSavesSupportMetaInfo: - return true; - case MetaEngine::kSavesSupportThumbnail: - return true; - default: - return false; + case MetaEngine::kSupportsListSaves: + return true; + case MetaEngine::kSupportsLoadingDuringStartup: + return true; + case MetaEngine::kSupportsDeleteSave: + return true; + case MetaEngine::kSavesSupportCreationDate: + return true; + case MetaEngine::kSavesSupportMetaInfo: + return true; + case MetaEngine::kSavesSupportThumbnail: + return true; + default: + return false; } } @@ -179,16 +179,16 @@ public: } return saves; } - + int getMaximumSaveSlot() const { return 100; } - + void removeSaveState(const char *target, int slot) const { WinterMute::BasePersistenceManager pm(NULL, target); pm.deleteSaveSlot(slot); } - + virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { WinterMute::BasePersistenceManager pm(NULL, target); SaveStateDescriptor retVal; diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index d9449294fb..fe7325baa4 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h index db814a59ac..258d9bd67b 100644 --- a/engines/wintermute/math/math_util.h +++ b/engines/wintermute/math/math_util.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp index a716e937f4..379c219ec3 100644 --- a/engines/wintermute/math/matrix4.cpp +++ b/engines/wintermute/math/matrix4.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h index 5def8dfe97..4f65fe5779 100644 --- a/engines/wintermute/math/matrix4.h +++ b/engines/wintermute/math/matrix4.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index e0babcbbb9..428d49290c 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -8,18 +8,18 @@ * 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. * */ - + #ifndef WINTERMUTE_RECT32_H #define WINTERMUTE_RECT32_H @@ -33,24 +33,32 @@ struct Point32 { }; struct Rect32 { - int32 top, left; ///< The point at the top left of the rectangle (part of the rect). - int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). - + int32 top, left; ///< The point at the top left of the rectangle (part of the rect). + int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). + Rect32() : top(0), left(0), bottom(0), right(0) {} Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { assert(isValidRect()); } - bool operator==(const Rect32 &rhs) const { return equals(rhs); } - bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } - - int16 width() const { return right - left; } - int16 height() const { return bottom - top; } - + bool operator==(const Rect32 &rhs) const { + return equals(rhs); + } + bool operator!=(const Rect32 &rhs) const { + return !equals(rhs); + } + + int16 width() const { + return right - left; + } + int16 height() const { + return bottom - top; + } + void setWidth(int16 aWidth) { right = left + aWidth; } - + void setHeight(int16 aHeight) { bottom = top + aHeight; } @@ -75,7 +83,7 @@ struct Rect32 { bool equals(const Rect32 &r) const { return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); } - + bool isValidRect() const { return (left <= right && top <= bottom); } diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp index 9906a59429..ecf2f1e8e4 100644 --- a/engines/wintermute/math/vector2.cpp +++ b/engines/wintermute/math/vector2.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h index 96d3a3827d..ca4f499794 100644 --- a/engines/wintermute/math/vector2.h +++ b/engines/wintermute/math/vector2.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index d97b9bedab..27b2b0b727 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -118,15 +118,15 @@ AnsiString PathUtil::getExtension(const AnsiString &path) { AnsiString PathUtil::getSafeLogFileName() { AnsiString logFileName = getUserDirectory(); -/*#ifdef __WIN32__ - char moduleName[MAX_PATH_LENGTH]; - ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); + /*#ifdef __WIN32__ + char moduleName[MAX_PATH_LENGTH]; + ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); - AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; - fileName = Combine("/Wintermute Engine/Logs/", fileName); - logFileName = Combine(logFileName, fileName); + AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; + fileName = Combine("/Wintermute Engine/Logs/", fileName); + logFileName = Combine(logFileName, fileName); -#else*/ + #else*/ // !PORTME logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); //#endif diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index be6207c3b8..748016d9c4 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -170,7 +170,7 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { /*Common::String converted = ""; uint32 index = 0; while (index != str.size()) { - converted += simpleAnsiToWide(str, index); + converted += simpleAnsiToWide(str, index); }*/ // using default os locale! diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index ee723cf80a..a4751ef11b 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -57,11 +57,11 @@ float BaseUtils::normalizeAngle(float angle) { //////////////////////////////////////////////////////////////////////////////// void BaseUtils::createPath(const char *path, bool pathOnly) { -/* AnsiString pathStr; + /* AnsiString pathStr; - if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); - else pathStr = path; -*/ + if (!pathOnly) pathStr = PathUtil::getDirectoryName(path); + else pathStr = path; + */ // try { warning("BaseUtils::CreatePath - not implemented: %s", path); // boost::filesystem::create_directories(path); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 55204bcc74..ac9c3b7fbf 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -51,7 +51,7 @@ WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { g_wintermute = this; _classReg = new SystemClassRegistry(); _classReg->registerClasses(); - + _game = new AdGame(); _rnd = NULL; } @@ -79,7 +79,7 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) debug("WinterMuteEngine::WinterMuteEngine"); _game = NULL; - + g_wintermute = this; _classReg = NULL; } @@ -97,12 +97,12 @@ WinterMuteEngine::~WinterMuteEngine() { DebugMan.clearAllDebugChannels(); } -bool WinterMuteEngine::hasFeature(EngineFeature f) const { +bool WinterMuteEngine::hasFeature(EngineFeature f) const { switch (f) { - case kSupportsRTL: - return true; - default: - return false; + case kSupportsRTL: + return true; + default: + return false; } return false; } @@ -144,7 +144,7 @@ Common::Error WinterMuteEngine::run() { debugC(2, kWinterMuteDebugSaveGame , "Savegame debugging-enabled"); int ret = 1; - + ret = init(); if (ret == 0) { @@ -163,92 +163,90 @@ int WinterMuteEngine::init() { BasePlatform::initialize(_game, 0, NULL); bool windowedMode = !ConfMan.getBool("fullscreen"); - + // parse command line char *saveGame = NULL; -/* for (int i = 0; i < argc; i++) { - strcpy(param, argv[i]); - - if (scumm_stricmp(param, "-project") == 0) { - if (argc > i) strcpy(param, argv[i + 1]); - else param[0] = '\0'; - - if (strcmp(param, "") != 0) { - char *IniDir = BaseUtils::GetPath(param); - char *IniName = BaseUtils::GetFilename(param); - - // switch to ini's dir - warning("TODO: Place ini-files somewhere"); - // chdir(IniDir); - - // set ini name - sprintf(param, "./%s", IniName); - _game->_registry->SetIniName(param); - - delete[] IniDir; - delete[] IniName; - } - } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; - }*/ - - + /* for (int i = 0; i < argc; i++) { + strcpy(param, argv[i]); + + if (scumm_stricmp(param, "-project") == 0) { + if (argc > i) strcpy(param, argv[i + 1]); + else param[0] = '\0'; + + if (strcmp(param, "") != 0) { + char *IniDir = BaseUtils::GetPath(param); + char *IniName = BaseUtils::GetFilename(param); + + // switch to ini's dir + warning("TODO: Place ini-files somewhere"); + // chdir(IniDir); + + // set ini name + sprintf(param, "./%s", IniName); + _game->_registry->SetIniName(param); + + delete[] IniDir; + delete[] IniName; + } + } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; + }*/ + + if (_game->_registry->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); - + _game->_debugShowFPS = _game->_registry->readBool("Debug", "ShowFPS"); - + if (_game->_registry->readBool("Debug", "DisableSmartCache")) { _game->LOG(0, "Smart cache is DISABLED"); _game->_smartCache = false; } - - /* bool AllowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ - + + /* bool AllowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ + // load general game settings _game->initialize1(); - + // set gameId, for savegame-naming: _game->setGameId(_targetName); - + if (DID_FAIL(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); delete _game; _game = NULL; - + warning("Some of the essential files are missing. Please reinstall."); return 2; } - + _game->initialize2(); - + _game->getDebugMgr()->onGameInit(); _game->_scEngine->loadBreakpoints(); - - - + bool ret; - + // initialize the renderer ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode); if (DID_FAIL(ret)) { _game->LOG(ret, "Error initializing renderer. Exiting."); - + delete _game; _game = NULL; return 3; } - + _game->initialize3(); - + // initialize sound manager (non-fatal if we fail) ret = _game->_soundMgr->initialize(); if (DID_FAIL(ret)) { _game->LOG(ret, "Sound is NOT available."); } - - + + // load game uint32 DataInitStart = g_system->getMillis(); - + if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); delete _game; @@ -258,21 +256,21 @@ int WinterMuteEngine::init() { //_game->setWindowTitle(); _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; - + _game->LOG(0, "Engine initialized in %d ms", g_system->getMillis() - DataInitStart); _game->LOG(0, ""); - + if (ConfMan.hasKey("save_slot")) { int slot = ConfMan.getInt("save_slot"); Common::String str = Common::String::format("save00%d.DirtySplitSav", slot); _game->loadGame(str.c_str()); } - + if (saveGame) { _game->loadGame(saveGame); delete[] saveGame; } - + // all set, ready to go return 0; } @@ -285,13 +283,13 @@ int WinterMuteEngine::messageLoop() { uint32 diff = 0; const uint32 maxFPS = 60; - const uint32 frameTime = (uint32)((1.0/maxFPS) * 1000); + const uint32 frameTime = (uint32)((1.0 / maxFPS) * 1000); while (!done) { Common::Event event; while (_system->getEventManager()->pollEvent(event)) { BasePlatform::handleEvent(&event); } - + if (_game && _game->_renderer->_active && _game->_renderer->_ready) { _game->displayContent(); _game->displayQuickMsg(); @@ -310,7 +308,7 @@ int WinterMuteEngine::messageLoop() { } if (_game->_quitting) break; } - + if (_game) { // remember previous window position /* @@ -322,13 +320,13 @@ int WinterMuteEngine::messageLoop() { int PosY = _game->_renderer->_windowRect.top; PosX -= _game->_renderer->_monitorRect.left; PosY -= _game->_renderer->_monitorRect.top; - + _game->_registry->writeInt("Video", "WindowPosX", PosX); _game->_registry->writeInt("Video", "WindowPosY", PosY); } } */ - + delete _game; _game = NULL; } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 5d5edb66de..14c2ba2ab5 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -38,8 +38,8 @@ enum { kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine kWinterMuteDebugSaveGame = 1 << 1, kWinterMuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) - kWinterMuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) - kWinterMuteDebugAudio = 1 << 4 + kWinterMuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) + kWinterMuteDebugAudio = 1 << 4 }; class WinterMuteEngine : public Engine { diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 8db55e2a37..4b2fc5bada 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -43,8 +43,8 @@ namespace WinterMute { #define DID_SUCCEED(hr) ((bool)(hr)) #define DID_FAIL(hr) (!((bool)(hr))) -#define STATUS_OK (true) -#define STATUS_FAILED (false) +#define STATUS_OK (true) +#define STATUS_FAILED (false) #define MAX_PATH_LENGTH 512 -- cgit v1.2.3 From ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 15:59:26 +0200 Subject: WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code. --- engines/wintermute/ad/ad_actor.cpp | 408 ++++++---- engines/wintermute/ad/ad_entity.cpp | 270 +++++-- engines/wintermute/ad/ad_game.cpp | 614 ++++++++++----- engines/wintermute/ad/ad_inventory.cpp | 35 +- engines/wintermute/ad/ad_inventory_box.cpp | 35 +- engines/wintermute/ad/ad_item.cpp | 143 ++-- engines/wintermute/ad/ad_layer.cpp | 83 +- engines/wintermute/ad/ad_node_state.cpp | 53 +- engines/wintermute/ad/ad_object.cpp | 248 ++++-- engines/wintermute/ad/ad_object.h | 2 +- engines/wintermute/ad/ad_path.cpp | 21 +- engines/wintermute/ad/ad_region.cpp | 24 +- engines/wintermute/ad/ad_response.cpp | 8 +- engines/wintermute/ad/ad_response_box.cpp | 151 ++-- engines/wintermute/ad/ad_response_context.cpp | 8 +- engines/wintermute/ad/ad_response_context.h | 2 +- engines/wintermute/ad/ad_rot_level.cpp | 8 +- engines/wintermute/ad/ad_scale_level.cpp | 8 +- engines/wintermute/ad/ad_scene.cpp | 625 ++++++++++----- engines/wintermute/ad/ad_scene_state.cpp | 16 +- engines/wintermute/ad/ad_sentence.cpp | 102 ++- engines/wintermute/ad/ad_sprite_set.cpp | 100 ++- engines/wintermute/ad/ad_talk_def.cpp | 64 +- engines/wintermute/ad/ad_talk_holder.cpp | 107 ++- engines/wintermute/ad/ad_talk_node.cpp | 82 +- engines/wintermute/ad/ad_waypoint_group.cpp | 26 +- engines/wintermute/base/base.cpp | 28 +- engines/wintermute/base/base_active_rect.cpp | 8 +- engines/wintermute/base/base_dynamic_buffer.cpp | 28 +- engines/wintermute/base/base_fader.cpp | 45 +- engines/wintermute/base/base_file_manager.cpp | 52 +- engines/wintermute/base/base_frame.cpp | 124 ++- engines/wintermute/base/base_game.cpp | 859 ++++++++++++++------- engines/wintermute/base/base_keyboard_state.cpp | 24 +- engines/wintermute/base/base_named_object.cpp | 7 +- engines/wintermute/base/base_object.cpp | 291 ++++--- engines/wintermute/base/base_parser.cpp | 76 +- .../wintermute/base/base_persistence_manager.cpp | 97 ++- engines/wintermute/base/base_quick_msg.cpp | 8 +- engines/wintermute/base/base_region.cpp | 87 ++- engines/wintermute/base/base_registry.cpp | 43 +- engines/wintermute/base/base_save_thumb_helper.cpp | 4 +- engines/wintermute/base/base_script_holder.cpp | 55 +- engines/wintermute/base/base_scriptable.cpp | 39 +- engines/wintermute/base/base_sprite.cpp | 162 ++-- engines/wintermute/base/base_string_table.cpp | 49 +- engines/wintermute/base/base_sub_frame.cpp | 137 ++-- engines/wintermute/base/base_surface_storage.cpp | 45 +- .../wintermute/base/base_transition_manager.cpp | 17 +- engines/wintermute/base/file/base_disk_file.cpp | 11 +- engines/wintermute/base/file/base_file_entry.cpp | 4 +- engines/wintermute/base/file/base_package.cpp | 18 +- .../wintermute/base/file/base_save_thumb_file.cpp | 27 +- engines/wintermute/base/font/base_font.cpp | 7 +- engines/wintermute/base/font/base_font_bitmap.cpp | 115 ++- engines/wintermute/base/font/base_font_storage.cpp | 16 +- .../wintermute/base/font/base_font_truetype.cpp | 119 ++- engines/wintermute/base/font/base_font_truetype.h | 4 +- engines/wintermute/base/gfx/base_image.cpp | 76 +- engines/wintermute/base/gfx/base_renderer.cpp | 28 +- engines/wintermute/base/gfx/base_surface.cpp | 8 +- .../base/gfx/osystem/base_render_osystem.cpp | 55 +- .../base/gfx/osystem/base_surface_osystem.cpp | 41 +- engines/wintermute/base/particles/part_emitter.cpp | 140 +++- .../wintermute/base/particles/part_particle.cpp | 36 +- engines/wintermute/base/scriptables/script.cpp | 292 +++++-- .../wintermute/base/scriptables/script_engine.cpp | 167 ++-- .../wintermute/base/scriptables/script_engine.h | 8 +- .../base/scriptables/script_ext_array.cpp | 35 +- .../wintermute/base/scriptables/script_ext_array.h | 2 +- .../base/scriptables/script_ext_date.cpp | 9 +- .../base/scriptables/script_ext_file.cpp | 166 ++-- .../base/scriptables/script_ext_math.cpp | 8 +- .../base/scriptables/script_ext_mem_buffer.cpp | 118 +-- .../base/scriptables/script_ext_string.cpp | 120 +-- .../wintermute/base/scriptables/script_stack.cpp | 14 +- .../wintermute/base/scriptables/script_value.cpp | 197 +++-- engines/wintermute/base/sound/base_sound.cpp | 113 ++- .../wintermute/base/sound/base_sound_manager.cpp | 19 +- engines/wintermute/math/math_util.cpp | 8 +- engines/wintermute/system/sys_class.cpp | 19 +- engines/wintermute/system/sys_class_registry.cpp | 61 +- engines/wintermute/ui/ui_button.cpp | 391 +++++++--- engines/wintermute/ui/ui_edit.cpp | 252 ++++-- engines/wintermute/ui/ui_entity.cpp | 70 +- engines/wintermute/ui/ui_object.cpp | 143 +++- engines/wintermute/ui/ui_text.cpp | 91 ++- engines/wintermute/ui/ui_tiled_image.cpp | 51 +- engines/wintermute/ui/ui_window.cpp | 265 +++++-- engines/wintermute/utils/path_util.cpp | 14 +- engines/wintermute/utils/string_util.cpp | 22 +- engines/wintermute/utils/utils.cpp | 102 ++- engines/wintermute/video/video_player.cpp | 135 +++- engines/wintermute/video/video_theora_player.cpp | 96 ++- 94 files changed, 6430 insertions(+), 2791 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index fe1948d3a8..d1e03eac3a 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -129,7 +129,9 @@ bool AdActor::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename); + } delete[] buffer; @@ -235,7 +237,9 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_X: @@ -255,7 +259,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - SetFont((char *)params); + setFont((char *)params); break; case TOKEN_SCALABLE: @@ -285,44 +289,62 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { delete _walkSprite; _walkSprite = NULL; spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC; - else _walkSprite = spr; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) { + cmd = PARSERR_GENERIC; + } else { + _walkSprite = spr; + } break; case TOKEN_TALK: spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSprites.add(spr); + } break; case TOKEN_TALK_SPECIAL: spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSpritesEx.add(spr); + } break; case TOKEN_STAND: delete _standSprite; _standSprite = NULL; spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC; - else _standSprite = spr; + if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _standSprite = spr; + } break; case TOKEN_TURN_LEFT: delete _turnLeftSprite; _turnLeftSprite = NULL; spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnLeftSprite = spr; + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) { + cmd = PARSERR_GENERIC; + } else { + _turnLeftSprite = spr; + } break; case TOKEN_TURN_RIGHT: delete _turnRightSprite; _turnRightSprite = NULL; spr = new AdSpriteSet(_gameRef, this); - if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC; - else _turnRightSprite = spr; + if (!spr || DID_FAIL(spr->loadBuffer(params, true))) { + cmd = PARSERR_GENERIC; + } else { + _turnRightSprite = spr; + } break; case TOKEN_SCRIPT: @@ -426,9 +448,12 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ANIMATION: { - AdSpriteSet *Anim = new AdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else _anims.add(Anim); + AdSpriteSet *anim = new AdSpriteSet(_gameRef, this); + if (!anim || DID_FAIL(anim->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + } else { + _anims.add(anim); + } } break; } @@ -438,7 +463,9 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { return STATUS_FAILED; } if (cmd == PARSERR_GENERIC) { - if (spr) delete spr; + if (spr) { + delete spr; + } _gameRef->LOG(0, "Error loading ACTOR definition"); return STATUS_FAILED; } @@ -482,7 +509,9 @@ void AdActor::turnTo(TDirection dir) { ////////////////////////////////////////////////////////////////////////// void AdActor::goTo(int x, int y, TDirection afterWalkDir) { _afterWalkDir = afterWalkDir; - if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) return; + if (x == _targetPoint->x && y == _targetPoint->y && _state == STATE_FOLLOWING_PATH) { + return; + } _path->reset(); _path->setReady(false); @@ -499,11 +528,16 @@ void AdActor::goTo(int x, int y, TDirection afterWalkDir) { ////////////////////////////////////////////////////////////////////////// bool AdActor::display() { - if (_active) updateSounds(); + if (_active) { + updateSounds(); + } uint32 alpha; - if (_alphaColor != 0) alpha = _alphaColor; - else alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + if (_alphaColor != 0) { + alpha = _alphaColor; + } else { + alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF; + } float scaleX, scaleY; getScale(&scaleX, &scaleY); @@ -511,15 +545,24 @@ bool AdActor::display() { float rotate; if (_rotatable) { - if (_rotateValid) rotate = _rotate; - else rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else rotate = 0.0f; + if (_rotateValid) { + rotate = _rotate; + } else { + rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } + } else { + rotate = 0.0f; + } - if (_active) displaySpriteAttachments(true); + if (_active) { + displaySpriteAttachments(true); + } if (_currentSprite && _active) { bool reg = _registrable; - if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) reg = false; + if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) { + reg = false; + } _currentSprite->display(_posX, _posY, @@ -532,8 +575,12 @@ bool AdActor::display() { } - if (_active) displaySpriteAttachments(false); - if (_active && _partEmitter) _partEmitter->display(); + if (_active) { + displaySpriteAttachments(false); + } + if (_active && _partEmitter) { + _partEmitter->display(); + } return STATUS_OK; @@ -567,17 +614,22 @@ bool AdActor::update() { _currentSprite = _animSprite2; } - if (_sentence && _state != STATE_TALKING) _sentence->finish(); + if (_sentence && _state != STATE_TALKING) { + _sentence->finish(); + } // default: stand animation if (!_currentSprite) { - if (_sprite) _currentSprite = _sprite; - else { + if (_sprite) { + _currentSprite = _sprite; + } else { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - AdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(_idleAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } } } } @@ -598,8 +650,11 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_LEFT: if (_tempSprite2 == NULL || _tempSprite2->_finished) { - if (_dir > 0) _dir = (TDirection)(_dir - 1); - else _dir = (TDirection)(NUM_DIRECTIONS - 1); + if (_dir > 0) { + _dir = (TDirection)(_dir - 1); + } else { + _dir = (TDirection)(NUM_DIRECTIONS - 1); + } if (_dir == _targetDir) { _tempSprite2 = NULL; @@ -609,17 +664,23 @@ bool AdActor::update() { if (_turnLeftSprite) { _tempSprite2 = _turnLeftSprite->getSprite(_dir); } else { - AdSpriteSet *Anim = getAnimByName(_turnLeftAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(_turnLeftAnimName); + if (anim) { + _tempSprite2 = anim->getSprite(_dir); + } } if (_tempSprite2) { _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; + if (_tempSprite2->_looping) { + _tempSprite2->_looping = false; + } } _currentSprite = _tempSprite2; } - } else _currentSprite = _tempSprite2; + } else { + _currentSprite = _tempSprite2; + } break; @@ -628,7 +689,9 @@ bool AdActor::update() { if (_tempSprite2 == NULL || _tempSprite2->_finished) { _dir = (TDirection)(_dir + 1); - if ((int)_dir >= (int)NUM_DIRECTIONS) _dir = (TDirection)(0); + if ((int)_dir >= (int)NUM_DIRECTIONS) { + _dir = (TDirection)(0); + } if (_dir == _targetDir) { _tempSprite2 = NULL; @@ -638,32 +701,41 @@ bool AdActor::update() { if (_turnRightSprite) { _tempSprite2 = _turnRightSprite->getSprite(_dir); } else { - AdSpriteSet *Anim = getAnimByName(_turnRightAnimName); - if (Anim) _tempSprite2 = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(_turnRightAnimName); + if (anim) { + _tempSprite2 = anim->getSprite(_dir); + } } if (_tempSprite2) { _tempSprite2->reset(); - if (_tempSprite2->_looping) _tempSprite2->_looping = false; + if (_tempSprite2->_looping) { + _tempSprite2->_looping = false; + } } _currentSprite = _tempSprite2; } - } else _currentSprite = _tempSprite2; + } else { + _currentSprite = _tempSprite2; + } break; ////////////////////////////////////////////////////////////////////////// case STATE_SEARCHING_PATH: // keep asking scene for the path - if (((AdGame *)_gameRef)->_scene->getPath(BasePoint(_posX, _posY), *_targetPoint, _path, this)) + if (((AdGame *)_gameRef)->_scene->getPath(BasePoint(_posX, _posY), *_targetPoint, _path, this)) { _state = STATE_WAITING_PATH; + } break; ////////////////////////////////////////////////////////////////////////// case STATE_WAITING_PATH: // wait until the scene finished the path - if (_path->_ready) followPath(); + if (_path->_ready) { + followPath(); + } break; @@ -676,7 +748,9 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { _sentence->update(_dir); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + if (_sentence->_currentSprite) { + _tempSprite2 = _sentence->_currentSprite; + } bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { @@ -703,13 +777,16 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_READY: if (!_animSprite && !_animSprite2) { - if (_sprite) _currentSprite = _sprite; - else { + if (_sprite) { + _currentSprite = _sprite; + } else { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { - AdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(_idleAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } } } } @@ -745,7 +822,9 @@ void AdActor::followPath() { // skip current position _path->getFirst(); while (_path->getCurrent() != NULL) { - if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) break; + if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) { + break; + } _path->getNext(); } @@ -754,8 +833,11 @@ void AdActor::followPath() { _state = STATE_FOLLOWING_PATH;; initLine(BasePoint(_posX, _posY), *_path->getCurrent()); } else { - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else _state = STATE_READY; + if (_afterWalkDir != DI_NONE) { + turnTo(_afterWalkDir); + } else { + _state = STATE_READY; + } } } @@ -765,14 +847,20 @@ void AdActor::getNextStep() { if (_walkSprite) { _currentSprite = _walkSprite->getSprite(_dir); } else { - AdSpriteSet *Anim = getAnimByName(_walkAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(_walkAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } } - if (!_currentSprite) return; + if (!_currentSprite) { + return; + } _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (!_currentSprite->_changed) return; + if (!_currentSprite->_changed) { + return; + } int maxStepX, maxStepY; @@ -813,12 +901,15 @@ void AdActor::getNextStep() { _posY = _targetPoint->y; _path->reset(); - if (_afterWalkDir != DI_NONE) turnTo(_afterWalkDir); - else { + if (_afterWalkDir != DI_NONE) { + turnTo(_afterWalkDir); + } else { _state = _nextState; _nextState = STATE_READY; } - } else initLine(BasePoint(_posX, _posY), *_path->getCurrent()); + } else { + initLine(BasePoint(_posX, _posY), *_path->getCurrent()); + } } } @@ -853,7 +944,9 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, int X = stack->pop()->getInt(); int Y = stack->pop()->getInt(); goTo(X, Y); - if (strcmp(name, "GoToAsync") != 0) script->waitForExclusive(this); + if (strcmp(name, "GoToAsync") != 0) { + script->waitForExclusive(this); + } stack->pushNULL(); return STATUS_OK; } @@ -863,22 +956,27 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); - if (!Val->isNative()) { + ScValue *val = stack->pop(); + if (!val->isNative()) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return STATUS_OK; } - AdObject *Obj = (AdObject *)Val->getNative(); - if (!Obj || Obj->_type != OBJECT_ENTITY) { + AdObject *obj = (AdObject *)val->getNative(); + if (!obj || obj->_type != OBJECT_ENTITY) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return STATUS_OK; } - AdEntity *Ent = (AdEntity *)Obj; - if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY); - else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir); - if (strcmp(name, "GoToObjectAsync") != 0) script->waitForExclusive(this); + AdEntity *ent = (AdEntity *)obj; + if (ent->_walkToX == 0 && ent->_walkToY == 0) { + goTo(ent->_posX, ent->_posY); + } else { + goTo(ent->_walkToX, ent->_walkToY, ent->_walkToDir); + } + if (strcmp(name, "GoToObjectAsync") != 0) { + script->waitForExclusive(this); + } stack->pushNULL(); return STATUS_OK; } @@ -898,11 +996,15 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, dir = (int)angleToDirection(angle); } // otherwise turn to direction - else dir = val->getInt(); + else { + dir = val->getInt(); + } if (dir >= 0 && dir < NUM_DIRECTIONS) { turnTo((TDirection)dir); - if (strcmp(name, "TurnToAsync") != 0) script->waitForExclusive(this); + if (strcmp(name, "TurnToAsync") != 0) { + script->waitForExclusive(this); + } } stack->pushNULL(); return STATUS_OK; @@ -937,9 +1039,15 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, for (int i = 0; i < _anims.getSize(); i++) { if (scumm_stricmp(_anims[i]->getName(), AnimName) == 0) { // invalidate sprites in use - if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL; - if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL; - if (_anims[i]->containsSprite(_animSprite2)) _animSprite2 = NULL; + if (_anims[i]->containsSprite(_tempSprite2)) { + _tempSprite2 = NULL; + } + if (_anims[i]->containsSprite(_currentSprite)) { + _currentSprite = NULL; + } + if (_anims[i]->containsSprite(_animSprite2)) { + _animSprite2 = NULL; + } delete _anims[i]; _anims[i] = NULL; @@ -960,9 +1068,9 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *AnimName = stack->pop()->getString(); stack->pushBool(getAnimByName(AnimName) != NULL); return STATUS_OK; + } else { + return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } - - else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } @@ -1022,9 +1130,9 @@ ScValue *AdActor::scGetProperty(const char *name) { else if (strcmp(name, "TurnRightAnimName") == 0) { _scValue->setString(_turnRightAnimName); return _scValue; + } else { + return AdTalkHolder::scGetProperty(name); } - - else return AdTalkHolder::scGetProperty(name); } @@ -1035,7 +1143,9 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Direction") == 0) { int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _dir = (TDirection)dir; + if (dir >= 0 && dir < NUM_DIRECTIONS) { + _dir = (TDirection)dir; + } return STATUS_OK; } @@ -1043,8 +1153,11 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { // TalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkAnimName") == 0) { - if (value->isNULL()) _talkAnimName = "talk"; - else _talkAnimName = value->getString(); + if (value->isNULL()) { + _talkAnimName = "talk"; + } else { + _talkAnimName = value->getString(); + } return STATUS_OK; } @@ -1052,8 +1165,11 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { // WalkAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkAnimName") == 0) { - if (value->isNULL()) _walkAnimName = "walk"; - else _walkAnimName = value->getString(); + if (value->isNULL()) { + _walkAnimName = "walk"; + } else { + _walkAnimName = value->getString(); + } return STATUS_OK; } @@ -1061,8 +1177,11 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { // IdleAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IdleAnimName") == 0) { - if (value->isNULL()) _idleAnimName = "idle"; - else _idleAnimName = value->getString(); + if (value->isNULL()) { + _idleAnimName = "idle"; + } else { + _idleAnimName = value->getString(); + } return STATUS_OK; } @@ -1070,8 +1189,11 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnLeftAnimName") == 0) { - if (value->isNULL()) _turnLeftAnimName = "turnleft"; - else _turnLeftAnimName = value->getString(); + if (value->isNULL()) { + _turnLeftAnimName = "turnleft"; + } else { + _turnLeftAnimName = value->getString(); + } return STATUS_OK; } @@ -1079,12 +1201,15 @@ bool AdActor::scSetProperty(const char *name, ScValue *value) { // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TurnRightAnimName") == 0) { - if (value->isNULL()) _turnRightAnimName = "turnright"; - else _turnRightAnimName = value->getString(); + if (value->isNULL()) { + _turnRightAnimName = "turnright"; + } else { + _turnRightAnimName = value->getString(); + } return STATUS_OK; + } else { + return AdTalkHolder::scSetProperty(name, value); } - - else return AdTalkHolder::scSetProperty(name, value); } @@ -1107,37 +1232,46 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; - } else return _animSprite; + } else { + return _animSprite; + } } } // old way - if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) + if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) { return getTalkStanceOld(stance); + } // new way BaseSprite *ret = NULL; // do we have an animation with this name? - AdSpriteSet *Anim = getAnimByName(stance); - if (Anim) ret = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(stance); + if (anim) { + ret = anim->getSprite(_dir); + } // not - get a random talk if (!ret) { - BaseArray TalkAnims; + BaseArray talkAnims; for (int i = 0; i < _anims.getSize(); i++) { - if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) - TalkAnims.add(_anims[i]); + if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { + talkAnims.add(_anims[i]); + } } - if (TalkAnims.getSize() > 0) { - int rnd = g_wintermute->randInt(0, TalkAnims.getSize() - 1); - ret = TalkAnims[rnd]->getSprite(_dir); + if (talkAnims.getSize() > 0) { + int rnd = g_wintermute->randInt(0, talkAnims.getSize() - 1); + ret = talkAnims[rnd]->getSprite(_dir); } else { - if (_standSprite) ret = _standSprite->getSprite(_dir); - else { - Anim = getAnimByName(_idleAnimName); - if (Anim) ret = Anim->getSprite(_dir); + if (_standSprite) { + ret = _standSprite->getSprite(_dir); + } else { + anim = getAnimByName(_idleAnimName); + if (anim) { + ret = anim->getSprite(_dir); + } } } } @@ -1169,8 +1303,9 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _standSprite->getSprite(_dir); - else { + if (_talkSprites.getSize() < 1) { + ret = _standSprite->getSprite(_dir); + } else { // TODO: remember last int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]->getSprite(_dir); @@ -1218,14 +1353,23 @@ bool AdActor::persist(BasePersistenceManager *persistMgr) { TDirection AdActor::angleToDirection(int angle) { TDirection ret = DI_DOWN;; - if (angle > -112 && angle <= -67) ret = DI_UP; - else if (angle > -67 && angle <= -22) ret = DI_UPRIGHT; - else if (angle > -22 && angle <= 22) ret = DI_RIGHT; - else if (angle > 22 && angle <= 67) ret = DI_DOWNRIGHT; - else if (angle > 67 && angle <= 112) ret = DI_DOWN; - else if (angle > 112 && angle <= 157) ret = DI_DOWNLEFT; - else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) ret = DI_LEFT; - else if (angle > -157 && angle <= -112) ret = DI_UPLEFT; + if (angle > -112 && angle <= -67) { + ret = DI_UP; + } else if (angle > -67 && angle <= -22) { + ret = DI_UPRIGHT; + } else if (angle > -22 && angle <= 22) { + ret = DI_RIGHT; + } else if (angle > 22 && angle <= 67) { + ret = DI_DOWNRIGHT; + } else if (angle > 67 && angle <= 112) { + ret = DI_DOWN; + } else if (angle > 112 && angle <= 157) { + ret = DI_DOWNLEFT; + } else if ((angle > 157 && angle <= 180) || (angle >= -180 && angle <= -157)) { + ret = DI_LEFT; + } else if (angle > -157 && angle <= -112) { + ret = DI_UPLEFT; + } return ret; } @@ -1235,10 +1379,13 @@ TDirection AdActor::angleToDirection(int angle) { int AdActor::getHeight() { // if no current sprite is set, set some if (_currentSprite == NULL) { - if (_standSprite) _currentSprite = _standSprite->getSprite(_dir); - else { - AdSpriteSet *Anim = getAnimByName(_idleAnimName); - if (Anim) _currentSprite = Anim->getSprite(_dir); + if (_standSprite) { + _currentSprite = _standSprite->getSprite(_dir); + } else { + AdSpriteSet *anim = getAnimByName(_idleAnimName); + if (anim) { + _currentSprite = anim->getSprite(_dir); + } } } // and get height @@ -1249,8 +1396,9 @@ int AdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { for (int i = 0; i < _anims.getSize(); i++) { - if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) + if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) { return _anims[i]; + } } return NULL; } @@ -1278,11 +1426,13 @@ bool AdActor::mergeAnims(const char *animsFilename) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_ANIMATION: { - AdSpriteSet *Anim = new AdSpriteSet(_gameRef, this); - if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) { + AdSpriteSet *anim = new AdSpriteSet(_gameRef, this); + if (!anim || DID_FAIL(anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; Ret = STATUS_FAILED; - } else _anims.add(Anim); + } else { + _anims.add(anim); + } } break; } @@ -1294,9 +1444,9 @@ bool AdActor::mergeAnims(const char *animsFilename) { ////////////////////////////////////////////////////////////////////////// bool AdActor::playAnim(const char *filename) { // if we have an anim with this name, use it - AdSpriteSet *Anim = getAnimByName(filename); - if (Anim) { - _animSprite2 = Anim->getSprite(_dir); + AdSpriteSet *anim = getAnimByName(filename); + if (anim) { + _animSprite2 = anim->getSprite(_dir); if (_animSprite2) { _animSprite2->reset(); _state = STATE_PLAYING_ANIM_SET; diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 98fb296bf5..aa30a0096c 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -94,7 +94,9 @@ bool AdEntity::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename); + } delete[] buffer; @@ -212,7 +214,9 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_X: @@ -227,22 +231,31 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { delete _sprite; _sprite = NULL; spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC; - else _sprite = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } else { + _sprite = spr; + } } break; case TOKEN_TALK: { spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSprites.add(spr); + } } break; case TOKEN_TALK_SPECIAL: { spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); + if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSpritesEx.add(spr); + } } break; @@ -259,7 +272,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - SetFont((char *)params); + setFont((char *)params); break; case TOKEN_SCALABLE: @@ -316,11 +329,14 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_REGION: { - if (_region) _gameRef->unregisterObject(_region); + if (_region) { + _gameRef->unregisterObject(_region); + } _region = NULL; BaseRegion *rgn = new BaseRegion(_gameRef); - if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC; - else { + if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + } else { _region = rgn; _gameRef->registerObject(_region); } @@ -379,10 +395,15 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { _sprite = NULL; if (_gameRef->_editorMode) { spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC; - else _sprite = spr; + if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) { + cmd = PARSERR_GENERIC; + } else { + _sprite = spr; + } + } + if (_gameRef->_editorMode) { + _editorOnly = true; } - if (_gameRef->_editorMode) _editorOnly = true; _zoomable = false; _rotatable = false; _registrable = _gameRef->_editorMode; @@ -443,8 +464,12 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_WALK_TO_DIR: { int i; parser.scanStr((char *)params, "%d", &i); - if (i < 0) i = 0; - if (i >= NUM_DIRECTIONS) i = DI_NONE; + if (i < 0) { + i = 0; + } + if (i >= NUM_DIRECTIONS) { + i = DI_NONE; + } _walkToDir = (TDirection)i; } break; @@ -456,7 +481,9 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { } if (cmd == PARSERR_GENERIC) { _gameRef->LOG(0, "Error loading ENTITY definition"); - if (spr) delete spr; + if (spr) { + delete spr; + } return STATUS_FAILED; } @@ -472,7 +499,9 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { _alphaColor = BYTETORGBA(ar, ag, ab, alpha); _state = STATE_READY; - if (_item && ((AdGame *)_gameRef)->isItemTaken(_item)) _active = false; + if (_item && ((AdGame *)_gameRef)->isItemTaken(_item)) { + _active = false; + } return STATUS_OK; } @@ -483,43 +512,55 @@ bool AdEntity::display() { if (_active) { updateSounds(); - uint32 Alpha; - if (_alphaColor != 0) Alpha = _alphaColor; - else Alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + uint32 alpha; + if (_alphaColor != 0) { + alpha = _alphaColor; + } else { + alpha = _shadowable ? ((AdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF; + } - float ScaleX, ScaleY; - getScale(&ScaleX, &ScaleY); + float scaleX, scaleY; + getScale(&scaleX, &scaleY); - float Rotate; + float rotate; if (_rotatable) { - if (_rotateValid) Rotate = _rotate; - else Rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; - } else Rotate = 0.0f; + if (_rotateValid) { + rotate = _rotate; + } else { + rotate = ((AdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate; + } + } else { + rotate = 0.0f; + } - bool Reg = _registrable; - if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) Reg = false; + bool reg = _registrable; + if (_ignoreItems && ((AdGame *)_gameRef)->_selectedItem) { + reg = false; + } - if (_region && (Reg || _editorAlwaysRegister)) { + if (_region && (reg || _editorAlwaysRegister)) { _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY)); } displaySpriteAttachments(true); if (_theora && (_theora->isPlaying() || _theora->isPaused())) { - _theora->display(Alpha); + _theora->display(alpha); } else if (_currentSprite) { _currentSprite->display(_posX, _posY, - (Reg || _editorAlwaysRegister) ? _registerAlias : NULL, - ScaleX, - ScaleY, - Alpha, - Rotate, + (reg || _editorAlwaysRegister) ? _registerAlias : NULL, + scaleX, + scaleY, + alpha, + rotate, _blendMode); } displaySpriteAttachments(false); - if (_partEmitter) _partEmitter->display(_region); + if (_partEmitter) { + _partEmitter->display(_region); + } } return STATUS_OK; @@ -541,10 +582,14 @@ bool AdEntity::update() { _currentSprite = _animSprite; } - if (_sentence && _state != STATE_TALKING) _sentence->finish(); + if (_sentence && _state != STATE_TALKING) { + _sentence->finish(); + } // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; + if (!_currentSprite) { + _currentSprite = _sprite; + } switch (_state) { ////////////////////////////////////////////////////////////////////////// @@ -554,14 +599,17 @@ bool AdEntity::update() { ////////////////////////////////////////////////////////////////////////// case STATE_READY: - if (!_animSprite) + if (!_animSprite) { _currentSprite = _sprite; + } break; ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + if (_sentence->_currentSprite) { + _tempSprite2 = _sentence->_currentSprite; + } bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { @@ -630,8 +678,11 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) { stack->correctParams(0); - if (DID_FAIL(stopSFX(false))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(stopSFX(false))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -648,7 +699,9 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _theora; _theora = new VideoTheoraPlayer(_gameRef); if (_theora && DID_SUCCEED(_theora->initialize(filename))) { - if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString()); + if (!valAlpha->isNULL()) { + _theora->setAlphaImage(valAlpha->getString()); + } _theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume); //if (_scale>=0) _theora->_playZoom = _scale; stack->pushBool(true); @@ -670,7 +723,9 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _theora; _theora = NULL; stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -680,8 +735,11 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTheoraPlaying") == 0) { stack->correctParams(0); - if (_theora && _theora->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); + if (_theora && _theora->isPlaying()) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -694,7 +752,9 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_theora && _theora->isPlaying()) { _theora->pause(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -707,7 +767,9 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_theora && _theora->isPaused()) { _theora->resume(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -717,8 +779,11 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsTheoraPaused") == 0) { stack->correctParams(0); - if (_theora && _theora->isPaused()) stack->pushBool(true); - else stack->pushBool(false); + if (_theora && _theora->isPaused()) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -733,8 +798,11 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _region = new BaseRegion(_gameRef); _gameRef->registerObject(_region); } - if (_region) stack->pushNative(_region, true); - else stack->pushNULL(); + if (_region) { + stack->pushNative(_region, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -748,12 +816,14 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack _gameRef->unregisterObject(_region); _region = NULL; stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; + } else { + return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } - - else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } @@ -773,8 +843,11 @@ ScValue *AdEntity::scGetProperty(const char *name) { // Item ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Item") == 0) { - if (_item) _scValue->setString(_item); - else _scValue->setNULL(); + if (_item) { + _scValue->setString(_item); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -783,10 +856,11 @@ ScValue *AdEntity::scGetProperty(const char *name) { // Subtype (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Subtype") == 0) { - if (_subtype == ENTITY_SOUND) + if (_subtype == ENTITY_SOUND) { _scValue->setString("sound"); - else + } else { _scValue->setString("normal"); + } return _scValue; } @@ -819,12 +893,15 @@ ScValue *AdEntity::scGetProperty(const char *name) { // Region (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Region") == 0) { - if (_region) _scValue->setNative(_region, true); - else _scValue->setNULL(); + if (_region) { + _scValue->setNative(_region, true); + } else { + _scValue->setNULL(); + } return _scValue; + } else { + return AdTalkHolder::scGetProperty(name); } - - else return AdTalkHolder::scGetProperty(name); } @@ -860,11 +937,13 @@ bool AdEntity::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WalkToDirection") == 0) { int dir = value->getInt(); - if (dir >= 0 && dir < NUM_DIRECTIONS) _walkToDir = (TDirection)dir; + if (dir >= 0 && dir < NUM_DIRECTIONS) { + _walkToDir = (TDirection)dir; + } return STATUS_OK; + } else { + return AdTalkHolder::scSetProperty(name, value); } - - else return AdTalkHolder::scSetProperty(name, value); } @@ -878,8 +957,9 @@ const char *AdEntity::scToString() { bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ENTITY {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - if (_subtype == ENTITY_SOUND) + if (_subtype == ENTITY_SOUND) { buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n"); + } buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "X=%d\n", _posX); @@ -888,23 +968,30 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "INTERACTIVE=%s\n", _registrable ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "COLORABLE=%s\n", _shadowable ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_ignoreItems) + if (_ignoreItems) { buffer->putTextIndent(indent + 2, "IGNORE_ITEMS=%s\n", _ignoreItems ? "TRUE" : "FALSE"); - if (_rotatable) + } + if (_rotatable) { buffer->putTextIndent(indent + 2, "ROTATABLE=%s\n", _rotatable ? "TRUE" : "FALSE"); + } - if (!_autoSoundPanning) + if (!_autoSoundPanning) { buffer->putTextIndent(indent + 2, "SOUND_PANNING=%s\n", _autoSoundPanning ? "TRUE" : "FALSE"); + } - if (!_saveState) + if (!_saveState) { buffer->putTextIndent(indent + 2, "SAVE_STATE=%s\n", _saveState ? "TRUE" : "FALSE"); + } - if (_item && _item[0] != '\0') buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); + if (_item && _item[0] != '\0') { + buffer->putTextIndent(indent + 2, "ITEM=\"%s\"\n", _item); + } buffer->putTextIndent(indent + 2, "WALK_TO_X=%d\n", _walkToX); buffer->putTextIndent(indent + 2, "WALK_TO_Y=%d\n", _walkToY); - if (_walkToDir != DI_NONE) + if (_walkToDir != DI_NONE) { buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); + } int i; @@ -912,8 +999,9 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_subtype == ENTITY_NORMAL && _sprite && _sprite->getFilename()) + if (_subtype == ENTITY_NORMAL && _sprite && _sprite->getFilename()) { buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename()); + } if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); @@ -922,29 +1010,39 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { } - if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) + if (RGBCOLGetR(_alphaColor) != 0 || RGBCOLGetG(_alphaColor) != 0 || RGBCOLGetB(_alphaColor) != 0) { buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alphaColor), RGBCOLGetG(_alphaColor), RGBCOLGetB(_alphaColor)); + } - if (RGBCOLGetA(_alphaColor) != 0) + if (RGBCOLGetA(_alphaColor) != 0) { buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alphaColor)); + } - if (_scale >= 0) + if (_scale >= 0) { buffer->putTextIndent(indent + 2, "SCALE = %d\n", (int)_scale); + } - if (_relativeScale != 0) + if (_relativeScale != 0) { buffer->putTextIndent(indent + 2, "RELATIVE_SCALE = %d\n", (int)_relativeScale); + } - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } AdTalkHolder::saveAsText(buffer, indent + 2); - if (_region) _region->saveAsText(buffer, indent + 2); + if (_region) { + _region->saveAsText(buffer, indent + 2); + } - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } AdObject::saveAsText(buffer, indent + 2); @@ -959,7 +1057,9 @@ int AdEntity::getHeight() { if (_region && !_sprite) { return _region->_rect.bottom - _region->_rect.top; } else { - if (_currentSprite == NULL) _currentSprite = _sprite; + if (_currentSprite == NULL) { + _currentSprite = _sprite; + } return AdObject::getHeight(); } } diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 259fc175ae..a6452e8837 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -142,7 +142,9 @@ bool AdGame::cleanup() { _scene = NULL; // remove items - for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]); + for (i = 0; i < _items.getSize(); i++) { + _gameRef->unregisterObject(_items[i]); + } _items.removeAll(); @@ -181,13 +183,19 @@ bool AdGame::cleanup() { delete _sceneViewport; _sceneViewport = NULL; - for (i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + for (i = 0; i < _sceneStates.getSize(); i++) { + delete _sceneStates[i]; + } _sceneStates.removeAll(); - for (i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + for (i = 0; i < _responsesBranch.getSize(); i++) { + delete _responsesBranch[i]; + } _responsesBranch.removeAll(); - for (i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + for (i = 0; i < _responsesGame.getSize(); i++) { + delete _responsesGame[i]; + } _responsesGame.removeAll(); return BaseGame::cleanup(); @@ -207,9 +215,13 @@ bool AdGame::initLoop() { bool res; res = BaseGame::initLoop(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } - if (_scene) res = _scene->initLoop(); + if (_scene) { + res = _scene->initLoop(); + } _sentences.removeAll(); @@ -228,8 +240,10 @@ bool AdGame::addObject(AdObject *object) { bool AdGame::removeObject(AdObject *object) { // in case the user called Scene.CreateXXX() and Game.DeleteXXX() if (_scene) { - bool Res = _scene->removeObject(object); - if (DID_SUCCEED(Res)) return Res; + bool res = _scene->removeObject(object); + if (DID_SUCCEED(res)) { + return res; + } } for (int i = 0; i < _objects.getSize(); i++) { @@ -253,23 +267,31 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { setPrevSceneName(_scene->getName()); setPrevSceneFilename(_scene->getFilename()); - if (!_tempDisableSaveState) _scene->saveState(); + if (!_tempDisableSaveState) { + _scene->saveState(); + } _tempDisableSaveState = false; } if (_scene) { // reset objects - for (int i = 0; i < _objects.getSize(); i++) _objects[i]->reset(); + for (int i = 0; i < _objects.getSize(); i++) { + _objects[i]->reset(); + } // reset scene properties _scene->_sFXVolume = 100; - if (_scene->_scProp) _scene->_scProp->cleanup(); + if (_scene->_scProp) { + _scene->_scProp->cleanup(); + } bool ret; if (_initialScene && _debugDebugMode && _debugStartupScene) { _initialScene = false; ret = _scene->loadFile(_debugStartupScene); - } else ret = _scene->loadFile(filename); + } else { + ret = _scene->loadFile(filename); + } if (DID_SUCCEED(ret)) { // invalidate references to the original scene @@ -280,9 +302,13 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { _scene->loadState(); } - if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN); + if (fadeIn) { + _gameRef->_transMgr->start(TRANSITION_FADE_IN); + } return ret; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -295,8 +321,11 @@ void AdGame::addSentence(AdSentence *sentence) { ////////////////////////////////////////////////////////////////////////// bool AdGame::displaySentences(bool frozen) { for (int i = 0; i < _sentences.getSize(); i++) { - if (frozen && _sentences[i]->_freezable) continue; - else _sentences[i]->display(); + if (frozen && _sentences[i]->_freezable) { + continue; + } else { + _sentences[i]->display(); + } } return STATUS_OK; } @@ -307,7 +336,9 @@ void AdGame::finishSentences() { for (int i = 0; i < _sentences.getSize(); i++) { if (_sentences[i]->CanSkip()) { _sentences[i]->_duration = 0; - if (_sentences[i]->_sound) _sentences[i]->_sound->stop(); + if (_sentences[i]->_sound) { + _sentences[i]->_sound->stop(); + } } } } @@ -330,7 +361,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool transIn = valFadeIn->isNULL() ? true : valFadeIn->getBool(); scheduleChangeScene(filename, transIn); - if (transOut) _transMgr->start(TRANSITION_FADE_OUT, true); + if (transOut) { + _transMgr->start(TRANSITION_FADE_OUT, true); + } stack->pushNULL(); @@ -383,7 +416,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); AdObject *obj = (AdObject *)val->getNative(); removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } stack->pushNULL(); return STATUS_OK; @@ -398,7 +433,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdEntity *ent = new AdEntity(_gameRef); addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); + if (!val->isNULL()) { + ent->setName(val->getString()); + } stack->pushNative(ent, true); return STATUS_OK; } @@ -412,7 +449,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdItem *item = new AdItem(_gameRef); addItem(item); - if (!val->isNULL()) item->setName(val->getString()); + if (!val->isNULL()) { + item->setName(val->getString()); + } stack->pushNative(item, true); return STATUS_OK; } @@ -425,8 +464,11 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); AdItem *item = NULL; - if (val->isNative()) item = (AdItem *)val->getNative(); - else item = getItemByName(val->getString()); + if (val->isNative()) { + item = (AdItem *)val->getNative(); + } else { + item = getItemByName(val->getString()); + } if (item) { deleteItem(item); @@ -446,13 +488,18 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdItem *item = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _items.getSize()) item = _items[index]; + if (index >= 0 && index < _items.getSize()) { + item = _items[index]; + } } else { item = getItemByName(val->getString()); } - if (item) stack->pushNative(item, true); - else stack->pushNULL(); + if (item) { + stack->pushNative(item, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -476,13 +523,24 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, res->_iD = id; res->setText(text); _stringTable->expand(&res->_text); - if (!val1->isNULL()) res->setIcon(val1->getString()); - if (!val2->isNULL()) res->setIconHover(val2->getString()); - if (!val3->isNULL()) res->setIconPressed(val3->getString()); - if (!val4->isNULL()) res->setFont(val4->getString()); + if (!val1->isNULL()) { + res->setIcon(val1->getString()); + } + if (!val2->isNULL()) { + res->setIconHover(val2->getString()); + } + if (!val3->isNULL()) { + res->setIconPressed(val3->getString()); + } + if (!val4->isNULL()) { + res->setFont(val4->getString()); + } - if (strcmp(name, "AddResponseOnce") == 0) res->_responseType = RESPONSE_ONCE; - else if (strcmp(name, "AddResponseOnceGame") == 0) res->_responseType = RESPONSE_ONCE_GAME; + if (strcmp(name, "AddResponseOnce") == 0) { + res->_responseType = RESPONSE_ONCE; + } else if (strcmp(name, "AddResponseOnceGame") == 0) { + res->_responseType = RESPONSE_ONCE_GAME; + } _responseBox->_responses.add(res); } @@ -577,7 +635,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, Common::String branchName; if (val->isNULL()) { branchName.format("line%d", script->_currentLine); - } else branchName = val->getString(); + } else { + branchName = val->getString(); + } startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); @@ -593,7 +653,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *branchName = NULL; ScValue *val = stack->pop(); - if (!val->isNULL()) branchName = val->getString(); + if (!val->isNULL()) { + branchName = val->getString(); + } endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); stack->pushNULL(); @@ -609,7 +671,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (_dlgPendingBranches.getSize() > 0) { stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -663,7 +727,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } } - } else script->runtimeError("Game.IsItemTaken: item name expected"); + } else { + script->runtimeError("Game.IsItemTaken: item name expected"); + } stack->pushBool(false); return STATUS_OK; @@ -674,10 +740,11 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInventoryWindow") == 0) { stack->correctParams(0); - if (_inventoryBox && _inventoryBox->_window) + if (_inventoryBox && _inventoryBox->_window) { stack->pushNative(_inventoryBox->_window, true); - else + } else { stack->pushNULL(); + } return STATUS_OK; } @@ -687,10 +754,11 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { stack->correctParams(0); - if (_responseBox && _responseBox->_window) + if (_responseBox && _responseBox->_window) { stack->pushNative(_responseBox->_window, true); - else + } else { stack->pushNULL(); + } return STATUS_OK; } @@ -781,11 +849,19 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, int width = stack->pop()->getInt(); int height = stack->pop()->getInt(); - if (width <= 0) width = _renderer->_width; - if (height <= 0) height = _renderer->_height; + if (width <= 0) { + width = _renderer->_width; + } + if (height <= 0) { + height = _renderer->_height; + } - if (!_sceneViewport) _sceneViewport = new BaseViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height); + if (!_sceneViewport) { + _sceneViewport = new BaseViewport(_gameRef); + } + if (_sceneViewport) { + _sceneViewport->setRect(x, y, x + width, y + height); + } stack->pushBool(true); @@ -793,7 +869,9 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } - else return BaseGame::scCallMethod(script, stack, thisStack, name); + else { + return BaseGame::scCallMethod(script, stack, thisStack, name); + } } @@ -812,8 +890,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // Scene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scene") == 0) { - if (_scene) _scValue->setNative(_scene, true); - else _scValue->setNULL(); + if (_scene) { + _scValue->setNative(_scene, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -822,8 +903,11 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SelectedItem") == 0) { //if (_selectedItem) _scValue->setString(_selectedItem->_name); - if (_selectedItem) _scValue->setNative(_selectedItem, true); - else _scValue->setNULL(); + if (_selectedItem) { + _scValue->setNative(_selectedItem, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -854,8 +938,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _scValue->setInt(_inventoryBox->_scrollOffset); - else _scValue->setInt(0); + if (_inventoryBox) { + _scValue->setInt(_inventoryBox->_scrollOffset); + } else { + _scValue->setInt(0); + } return _scValue; } @@ -872,8 +959,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // PrevScene / PreviousScene (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { - if (!_prevSceneName) _scValue->setString(""); - else _scValue->setString(_prevSceneName); + if (!_prevSceneName) { + _scValue->setString(""); + } else { + _scValue->setString(_prevSceneName); + } return _scValue; } @@ -881,8 +971,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // PrevSceneFilename / PreviousSceneFilename (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { - if (!_prevSceneFilename) _scValue->setString(""); - else _scValue->setString(_prevSceneFilename); + if (!_prevSceneFilename) { + _scValue->setString(""); + } else { + _scValue->setString(_prevSceneFilename); + } return _scValue; } @@ -890,8 +983,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LastResponse") == 0) { - if (!_responseBox || !_responseBox->_lastResponseText) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseText); + if (!_responseBox || !_responseBox->_lastResponseText) { + _scValue->setString(""); + } else { + _scValue->setString(_responseBox->_lastResponseText); + } return _scValue; } @@ -899,8 +995,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LastResponseOrig") == 0) { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) _scValue->setString(""); - else _scValue->setString(_responseBox->_lastResponseTextOrig); + if (!_responseBox || !_responseBox->_lastResponseTextOrig) { + _scValue->setString(""); + } else { + _scValue->setString(_responseBox->_lastResponseTextOrig); + } return _scValue; } @@ -908,8 +1007,11 @@ ScValue *AdGame::scGetProperty(const char *name) { // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner == _invObject) _scValue->setNative(this, true); - else _scValue->setNative(_inventoryOwner, true); + if (_inventoryOwner == _invObject) { + _scValue->setNative(this, true); + } else { + _scValue->setNative(_inventoryOwner, true); + } return _scValue; } @@ -942,12 +1044,17 @@ ScValue *AdGame::scGetProperty(const char *name) { // StartupScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartupScene") == 0) { - if (!_startupScene) _scValue->setNULL(); - else _scValue->setString(_startupScene); + if (!_startupScene) { + _scValue->setNULL(); + } else { + _scValue->setString(_startupScene); + } return _scValue; } - else return BaseGame::scGetProperty(name); + else { + return BaseGame::scGetProperty(name); + } } @@ -958,8 +1065,9 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // SelectedItem ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelectedItem") == 0) { - if (value->isNULL()) _selectedItem = NULL; - else { + if (value->isNULL()) { + _selectedItem = NULL; + } else { if (value->isNative()) { _selectedItem = NULL; for (int i = 0; i < _items.getSize(); i++) { @@ -989,7 +1097,9 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // InventoryVisible ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryVisible") == 0) { - if (_inventoryBox) _inventoryBox->_visible = value->getBool(); + if (_inventoryBox) { + _inventoryBox->_visible = value->getBool(); + } return STATUS_OK; } @@ -997,16 +1107,24 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // InventoryObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryObject") == 0) { - if (_inventoryOwner && _inventoryBox) _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + if (_inventoryOwner && _inventoryBox) { + _inventoryOwner->getInventory()->_scrollOffset = _inventoryBox->_scrollOffset; + } - if (value->isNULL()) _inventoryOwner = _invObject; - else { - BaseObject *Obj = (BaseObject *)value->getNative(); - if (Obj == this) _inventoryOwner = _invObject; - else if (_gameRef->validObject(Obj)) _inventoryOwner = (AdObject *)Obj; + if (value->isNULL()) { + _inventoryOwner = _invObject; + } else { + BaseObject *obj = (BaseObject *)value->getNative(); + if (obj == this) { + _inventoryOwner = _invObject; + } else if (_gameRef->validObject(obj)) { + _inventoryOwner = (AdObject *)obj; + } } - if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; + if (_inventoryOwner && _inventoryBox) { + _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset; + } return STATUS_OK; } @@ -1015,7 +1133,9 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InventoryScrollOffset") == 0) { - if (_inventoryBox) _inventoryBox->_scrollOffset = value->getInt(); + if (_inventoryBox) { + _inventoryBox->_scrollOffset = value->getInt(); + } return STATUS_OK; } @@ -1023,10 +1143,14 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // TalkSkipButton ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TalkSkipButton") == 0) { - int Val = value->getInt(); - if (Val < 0) Val = 0; - if (Val > TALK_SKIP_NONE) Val = TALK_SKIP_NONE; - _talkSkipButton = (TTalkSkipButton)Val; + int val = value->getInt(); + if (val < 0) { + val = 0; + } + if (val > TALK_SKIP_NONE) { + val = TALK_SKIP_NONE; + } + _talkSkipButton = (TTalkSkipButton)val; return STATUS_OK; } @@ -1037,12 +1161,16 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { if (value == NULL) { delete[] _startupScene; _startupScene = NULL; - } else BaseUtils::setString(&_startupScene, value->getString()); + } else { + BaseUtils::setString(&_startupScene, value->getString()); + } return STATUS_OK; } - else return BaseGame::scSetProperty(name, value); + else { + return BaseGame::scSetProperty(name, value); + } } @@ -1075,7 +1203,9 @@ bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// // call parent - else return BaseGame::ExternalCall(script, stack, thisStack, name); + else { + return BaseGame::ExternalCall(script, stack, thisStack, name); + } return STATUS_OK; @@ -1084,7 +1214,9 @@ bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// bool AdGame::showCursor() { - if (_cursorHidden) return STATUS_OK; + if (_cursorHidden) { + return STATUS_OK; + } if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) { if (_selectedItem->_cursorCombined) { @@ -1093,12 +1225,17 @@ bool AdGame::showCursor() { _lastCursor = origLastCursor; } if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) { - if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName())) + if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName())) { return drawCursor(_selectedItem->_cursorHover); - else + } else { return drawCursor(_selectedItem->_cursorNormal); - } else return drawCursor(_selectedItem->_cursorNormal); - } else return BaseGame::showCursor(); + } + } else { + return drawCursor(_selectedItem->_cursorNormal); + } + } else { + return BaseGame::showCursor(); + } } @@ -1114,7 +1251,9 @@ bool AdGame::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + } delete[] buffer; @@ -1162,7 +1301,9 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_GAME: - if (DID_FAIL(BaseGame::loadBuffer(params, false))) cmd = PARSERR_GENERIC; + if (DID_FAIL(BaseGame::loadBuffer(params, false))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_AD_GAME: @@ -1171,9 +1312,9 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_RESPONSE_BOX: delete _responseBox; _responseBox = new AdResponseBox(_gameRef); - if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) + if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2))) { registerObject(_responseBox); - else { + } else { delete _responseBox; _responseBox = NULL; cmd = PARSERR_GENERIC; @@ -1183,9 +1324,9 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX: delete _inventoryBox; _inventoryBox = new AdInventoryBox(_gameRef); - if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) + if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2))) { registerObject(_inventoryBox); - else { + } else { delete _inventoryBox; _inventoryBox = NULL; cmd = PARSERR_GENERIC; @@ -1203,16 +1344,24 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TALK_SKIP_BUTTON: - if (scumm_stricmp((char *)params2, "right") == 0) _talkSkipButton = TALK_SKIP_RIGHT; - else if (scumm_stricmp((char *)params2, "both") == 0) _talkSkipButton = TALK_SKIP_BOTH; - else _talkSkipButton = TALK_SKIP_LEFT; + if (scumm_stricmp((char *)params2, "right") == 0) { + _talkSkipButton = TALK_SKIP_RIGHT; + } else if (scumm_stricmp((char *)params2, "both") == 0) { + _talkSkipButton = TALK_SKIP_BOTH; + } else { + _talkSkipButton = TALK_SKIP_LEFT; + } break; case TOKEN_SCENE_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_sceneViewport) _sceneViewport = new BaseViewport(_gameRef); - if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); + if (!_sceneViewport) { + _sceneViewport = new BaseViewport(_gameRef); + } + if (_sceneViewport) { + _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom); + } } break; @@ -1252,7 +1401,9 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(); + if (!persistMgr->getIsSaving()) { + cleanup(); + } BaseGame::persist(persistMgr); _dlgPendingBranches.persist(persistMgr); @@ -1292,7 +1443,9 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { _speechDirs.persist(persistMgr); persistMgr->transfer(TMEMBER(_smartItemCursor)); - if (!persistMgr->getIsSaving()) _initialScene = false; + if (!persistMgr->getIsSaving()) { + _initialScene = false; + } persistMgr->transfer(TMEMBER(_startupScene)); @@ -1304,7 +1457,9 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdGame::loadGame(const char *filename) { bool ret = BaseGame::loadGame(filename); - if (DID_SUCCEED(ret)) SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "AdRegion", NULL); + if (DID_SUCCEED(ret)) { + SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "AdRegion", NULL); + } return ret; } @@ -1327,7 +1482,9 @@ void AdGame::setPrevSceneName(const char *name) { _prevSceneName = NULL; if (name) { _prevSceneName = new char[strlen(name) + 1]; - if (_prevSceneName) strcpy(_prevSceneName, name); + if (_prevSceneName) { + strcpy(_prevSceneName, name); + } } } @@ -1338,7 +1495,9 @@ void AdGame::setPrevSceneFilename(const char *name) { _prevSceneFilename = NULL; if (name) { _prevSceneFilename = new char[strlen(name) + 1]; - if (_prevSceneFilename) strcpy(_prevSceneFilename, name); + if (_prevSceneFilename) { + strcpy(_prevSceneFilename, name); + } } } @@ -1348,8 +1507,9 @@ bool AdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; _scheduledScene = NULL; - if (_scene && !_scene->_initialized) return changeScene(filename, fadeIn); - else { + if (_scene && !_scene->_initialized) { + return changeScene(filename, fadeIn); + } else { _scheduledScene = new char [strlen(filename) + 1]; strcpy(_scheduledScene, filename); @@ -1364,8 +1524,12 @@ bool AdGame::scheduleChangeScene(const char *filename, bool fadeIn) { bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { BaseGame::getVersion(verMajor, verMinor, NULL, NULL); - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; + if (extMajor) { + *extMajor = 0; + } + if (extMinor) { + *extMinor = 0; + } return STATUS_OK; } @@ -1384,7 +1548,9 @@ bool AdGame::loadItemsFile(const char *filename, bool merge) { //_filename = new char [strlen(filename)+1]; //strcpy(_filename, filename); - if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); + if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) { + _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename); + } delete[] buffer; @@ -1404,7 +1570,9 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { BaseParser parser(_gameRef); if (!merge) { - while (_items.getSize() > 0) deleteItem(_items[0]); + while (_items.getSize() > 0) { + deleteItem(_items[0]); + } } while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { @@ -1414,8 +1582,10 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { if (item && !DID_FAIL(item->loadBuffer(params, false))) { // delete item with the same name, if exists if (merge) { - AdItem *PrevItem = getItemByName(item->getName()); - if (PrevItem) deleteItem(PrevItem); + AdItem *prevItem = getItemByName(item->getName()); + if (prevItem) { + deleteItem(prevItem); + } } addItem(item); } else { @@ -1446,7 +1616,9 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { char *filenameCor = new char[strlen(filename) + 1]; strcpy(filenameCor, filename); for (uint32 i = 0; i < strlen(filenameCor); i++) { - if (filenameCor[i] == '/') filenameCor[i] = '\\'; + if (filenameCor[i] == '/') { + filenameCor[i] = '\\'; + } } for (int i = 0; i < _sceneStates.getSize(); i++) { @@ -1512,14 +1684,18 @@ bool AdGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *st ScValue *val = stack->pop(); UIEntity *ent = new UIEntity(_gameRef); - if (!val->isNULL()) ent->setName(val->getString()); + if (!val->isNULL()) { + ent->setName(val->getString()); + } stack->pushNative(ent, true); ent->_parent = win; win->_widgets.add(ent); return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -1550,7 +1726,9 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const } } - if (name == NULL) return STATUS_OK; + if (name == NULL) { + return STATUS_OK; + } int startIndex = -1; @@ -1571,11 +1749,15 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const // dialogue is over, forget selected responses if (_dlgPendingBranches.getSize() == 0) { - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + for (int i = 0; i < _responsesBranch.getSize(); i++) { + delete _responsesBranch[i]; + } _responsesBranch.removeAll(); } - if (deleteName) delete[] name; + if (deleteName) { + delete[] name; + } return STATUS_OK; } @@ -1595,10 +1777,12 @@ bool AdGame::clearBranchResponses(char *name) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::addBranchResponse(int ID) { - if (branchResponseUsed(ID)) return STATUS_OK; +bool AdGame::addBranchResponse(int id) { + if (branchResponseUsed(id)) { + return STATUS_OK; + } AdResponseContext *r = new AdResponseContext(_gameRef); - r->_iD = ID; + r->_id = id; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesBranch.add(r); return STATUS_OK; @@ -1606,11 +1790,13 @@ bool AdGame::addBranchResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::branchResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; +bool AdGame::branchResponseUsed(int id) { + char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; for (int i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) return true; + if (_responsesBranch[i]->_id == id) { + if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { + return true; + } } } return false; @@ -1618,10 +1804,12 @@ bool AdGame::branchResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::addGameResponse(int ID) { - if (gameResponseUsed(ID)) return STATUS_OK; +bool AdGame::addGameResponse(int id) { + if (gameResponseUsed(id)) { + return STATUS_OK; + } AdResponseContext *r = new AdResponseContext(_gameRef); - r->_iD = ID; + r->_id = id; r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); _responsesGame.add(r); return STATUS_OK; @@ -1629,12 +1817,14 @@ bool AdGame::addGameResponse(int ID) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::gameResponseUsed(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; +bool AdGame::gameResponseUsed(int id) { + char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; for (int i = 0; i < _responsesGame.getSize(); i++) { - AdResponseContext *RespContext = _responsesGame[i]; - if (RespContext->_iD == ID) { - if ((Context == NULL && RespContext->_context == NULL) || ((Context != NULL && RespContext->_context != NULL) && scumm_stricmp(Context, RespContext->_context) == 0)) return true; + AdResponseContext *respContext = _responsesGame[i]; + if (respContext->_id == id) { + if ((context == NULL && respContext->_context == NULL) || ((context != NULL && respContext->_context != NULL) && scumm_stricmp(context, respContext->_context) == 0)) { + return true; + } } } return false; @@ -1642,14 +1832,12 @@ bool AdGame::gameResponseUsed(int ID) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::resetResponse(int ID) { - char *Context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - - int i; +bool AdGame::resetResponse(int id) { + char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (i = 0; i < _responsesGame.getSize(); i++) { - if (_responsesGame[i]->_iD == ID) { - if ((Context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(Context, _responsesGame[i]->_context) == 0) { + for (int i = 0; i < _responsesGame.getSize(); i++) { + if (_responsesGame[i]->_id == id) { + if ((context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(context, _responsesGame[i]->_context) == 0) { delete _responsesGame[i]; _responsesGame.removeAt(i); break; @@ -1657,9 +1845,9 @@ bool AdGame::resetResponse(int ID) { } } - for (i = 0; i < _responsesBranch.getSize(); i++) { - if (_responsesBranch[i]->_iD == ID) { - if ((Context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(Context, _responsesBranch[i]->_context) == 0) { + for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (_responsesBranch[i]->_id == id) { + if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; _responsesBranch.removeAt(i); break; @@ -1673,19 +1861,27 @@ bool AdGame::resetResponse(int ID) { ////////////////////////////////////////////////////////////////////////// bool AdGame::displayContent(bool doUpdate, bool displayAll) { // init - if (doUpdate) initLoop(); + if (doUpdate) { + initLoop(); + } // fill black _renderer->fill(0, 0, 0); - if (!_editorMode) _renderer->setScreenViewport(); + if (!_editorMode) { + _renderer->setScreenViewport(); + } // playing exclusive video? if (_videoPlayer->isPlaying()) { - if (doUpdate) _videoPlayer->update(); + if (doUpdate) { + _videoPlayer->update(); + } _videoPlayer->display(); } else if (_theoraPlayer) { if (_theoraPlayer->isPlaying()) { - if (doUpdate) _theoraPlayer->update(); + if (doUpdate) { + _theoraPlayer->update(); + } _theoraPlayer->display(); } if (_theoraPlayer->isFinished()) { @@ -1695,7 +1891,9 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { } else { // process scripts - if (doUpdate) _scEngine->tick(); + if (doUpdate) { + _scEngine->tick(); + } Point32 p; getMousePos(&p); @@ -1706,9 +1904,15 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { // display in-game windows displayWindows(true); - if (_inventoryBox) _inventoryBox->display(); - if (_stateEx == GAME_WAITING_RESPONSE) _responseBox->display(); - if (_indicatorDisplay) displayIndicator(); + if (_inventoryBox) { + _inventoryBox->display(); + } + if (_stateEx == GAME_WAITING_RESPONSE) { + _responseBox->display(); + } + if (_indicatorDisplay) { + displayIndicator(); + } if (doUpdate || displayAll) { @@ -1722,7 +1926,9 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { showCursor(); - if (_fader) _fader->display(); + if (_fader) { + _fader->display(); + } _transMgr->update(); } @@ -1741,7 +1947,9 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { ////////////////////////////////////////////////////////////////////////// bool AdGame::registerInventory(AdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { - if (_inventories[i] == inv) return STATUS_OK; + if (_inventories[i] == inv) { + return STATUS_OK; + } } registerObject(inv); _inventories.add(inv); @@ -1778,7 +1986,9 @@ bool AdGame::isItemTaken(char *itemName) { ////////////////////////////////////////////////////////////////////////// AdItem *AdGame::getItemByName(const char *name) { for (int i = 0; i < _items.getSize(); i++) { - if (scumm_stricmp(_items[i]->getName(), name) == 0) return _items[i]; + if (scumm_stricmp(_items[i]->getName(), name) == 0) { + return _items[i]; + } } return NULL; } @@ -1806,19 +2016,27 @@ bool AdGame::resetContent() { } // clear scene states - for (int i = 0; i < _sceneStates.getSize(); i++) delete _sceneStates[i]; + for (int i = 0; i < _sceneStates.getSize(); i++) { + delete _sceneStates[i]; + } _sceneStates.removeAll(); // clear once responses - for (int i = 0; i < _responsesBranch.getSize(); i++) delete _responsesBranch[i]; + for (int i = 0; i < _responsesBranch.getSize(); i++) { + delete _responsesBranch[i]; + } _responsesBranch.removeAll(); // clear once game responses - for (int i = 0; i < _responsesGame.getSize(); i++) delete _responsesGame[i]; + for (int i = 0; i < _responsesGame.getSize(); i++) { + delete _responsesGame[i]; + } _responsesGame.removeAll(); // reload inventory items - if (_itemsFile) loadItemsFile(_itemsFile); + if (_itemsFile) { + loadItemsFile(_itemsFile); + } _tempDisableSaveState = true; @@ -1828,9 +2046,13 @@ bool AdGame::resetContent() { ////////////////////////////////////////////////////////////////////////// bool AdGame::deleteItem(AdItem *item) { - if (!item) return STATUS_FAILED; + if (!item) { + return STATUS_FAILED; + } - if (_selectedItem == item) _selectedItem = NULL; + if (_selectedItem == item) { + _selectedItem = NULL; + } _scene->handleItemAssociations(item->getName(), false); // remove from all inventories @@ -1853,12 +2075,15 @@ bool AdGame::deleteItem(AdItem *item) { ////////////////////////////////////////////////////////////////////////// bool AdGame::addSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; + if (!dir || dir[0] == '\0') { + return STATUS_FAILED; + } char *temp = new char[strlen(dir) + 2]; strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') { strcat(temp, "\\"); + } for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { @@ -1874,26 +2099,28 @@ bool AdGame::addSpeechDir(const char *dir) { ////////////////////////////////////////////////////////////////////////// bool AdGame::removeSpeechDir(const char *dir) { - if (!dir || dir[0] == '\0') return STATUS_FAILED; + if (!dir || dir[0] == '\0') { + return STATUS_FAILED; + } char *temp = new char[strlen(dir) + 2]; strcpy(temp, dir); - if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') + if (temp[strlen(temp) - 1] != '\\' && temp[strlen(temp) - 1] != '/') { strcat(temp, "\\"); + } - bool Found = false; + bool found = false; for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete[] _speechDirs[i]; _speechDirs.removeAt(i); - Found = true; + found = true; break; } } delete[] temp; - if (Found) return STATUS_OK; - else return STATUS_FAILED; + return found; } @@ -1903,12 +2130,14 @@ char *AdGame::findSpeechFile(char *stringID) { for (int i = 0; i < _speechDirs.getSize(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - if (_fileManager->hasFile(ret)) + if (_fileManager->hasFile(ret)) { return ret; + } sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - if (_fileManager->hasFile(ret)) + if (_fileManager->hasFile(ret)) { return ret; + } } delete[] ret; return NULL; @@ -1925,7 +2154,9 @@ bool AdGame::validMouse() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onMouseLeftDown() { - if (!validMouse()) return STATUS_OK; + if (!validMouse()) { + return STATUS_OK; + } if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_LEFT || _talkSkipButton == TALK_SKIP_BOTH) { finishSentences(); @@ -1933,7 +2164,9 @@ bool AdGame::onMouseLeftDown() { return STATUS_OK; } - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { @@ -1944,7 +2177,9 @@ bool AdGame::onMouseLeftDown() { } } - if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject; + if (_activeObject != NULL) { + _gameRef->_capturedObject = _gameRef->_activeObject; + } _mouseLeftDown = true; BasePlatform::setCapture(/*_renderer->_window*/); @@ -1953,7 +2188,9 @@ bool AdGame::onMouseLeftDown() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } BasePlatform::releaseCapture(); _capturedObject = NULL; @@ -1972,11 +2209,17 @@ bool AdGame::onMouseLeftUp() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onMouseLeftDblClick() { - if (!validMouse()) return STATUS_OK; + if (!validMouse()) { + return STATUS_OK; + } - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { @@ -1991,7 +2234,9 @@ bool AdGame::onMouseLeftDblClick() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onMouseRightDown() { - if (!validMouse()) return STATUS_OK; + if (!validMouse()) { + return STATUS_OK; + } if (_state == GAME_RUNNING && !_interactive) { if (_talkSkipButton == TALK_SKIP_RIGHT || _talkSkipButton == TALK_SKIP_BOTH) { finishSentences(); @@ -1999,9 +2244,13 @@ bool AdGame::onMouseRightDown() { return STATUS_OK; } - if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) return STATUS_OK; + if ((_state == GAME_RUNNING && !_interactive) || _stateEx == GAME_WAITING_RESPONSE) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { @@ -2016,7 +2265,9 @@ bool AdGame::onMouseRightDown() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { @@ -2045,8 +2296,9 @@ bool AdGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onScriptShutdown(ScScript *script) { - if (_responseBox && _responseBox->_waitingScript == script) + if (_responseBox && _responseBox->_waitingScript == script) { _responseBox->_waitingScript = NULL; + } return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index d79d171d02..aa6e0b6f0b 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -50,10 +50,14 @@ AdInventory::~AdInventory() { ////////////////////////////////////////////////////////////////////////// bool AdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) return STATUS_FAILED; + if (name == NULL) { + return STATUS_FAILED; + } AdItem *item = ((AdGame *)_gameRef)->getItemByName(name); - if (item == NULL) return STATUS_FAILED; + if (item == NULL) { + return STATUS_FAILED; + } int insertIndex = -1; for (int i = 0; i < _takenItems.getSize(); i++) { @@ -62,12 +66,17 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { i--; continue; } - if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) insertIndex = i + 1; + if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) { + insertIndex = i + 1; + } } - if (insertIndex == -1) _takenItems.add(item); - else _takenItems.insertAt(insertIndex, item); + if (insertIndex == -1) { + _takenItems.add(item); + } else { + _takenItems.insertAt(insertIndex, item); + } return STATUS_OK; } @@ -75,11 +84,15 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { ////////////////////////////////////////////////////////////////////////// bool AdInventory::removeItem(const char *name) { - if (name == NULL) return STATUS_FAILED; + if (name == NULL) { + return STATUS_FAILED; + } for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { - if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL; + if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { + ((AdGame *)_gameRef)->_selectedItem = NULL; + } _takenItems.removeAt(i); return STATUS_OK; } @@ -92,11 +105,15 @@ bool AdInventory::removeItem(const char *name) { ////////////////////////////////////////////////////////////////////////// bool AdInventory::removeItem(AdItem *item) { - if (item == NULL) return STATUS_FAILED; + if (item == NULL) { + return STATUS_FAILED; + } for (int i = 0; i < _takenItems.getSize(); i++) { if (_takenItems[i] == item) { - if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL; + if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { + ((AdGame *)_gameRef)->_selectedItem = NULL; + } _takenItems.removeAt(i); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 60607c71c6..b8a3f1da22 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -86,7 +86,9 @@ bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { _scrollOffset = MAX(_scrollOffset, 0); } else if (scumm_stricmp(obj->getName(), "next") == 0) { _scrollOffset += _scrollBy; - } else return BaseObject::listen(param1, param2); + } else { + return BaseObject::listen(param1, param2); + } break; default: error("AdInventoryBox::Listen - Unhandled enum"); @@ -101,7 +103,9 @@ bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { bool AdInventoryBox::display() { AdGame *adGame = (AdGame *)_gameRef; - if (!_visible) return STATUS_OK; + if (!_visible) { + return STATUS_OK; + } int itemsX, itemsY; itemsX = (int)floor((float)((_itemsArea.right - _itemsArea.left + _spacing) / (_itemWidth + _spacing))); @@ -130,7 +134,9 @@ bool AdInventoryBox::display() { } // display items - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; + if (_window && _window->_alphaColor != 0) { + _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor; + } int yyy = rect.top; for (int j = 0; j < itemsY; j++) { int xxx = rect.left; @@ -148,7 +154,9 @@ bool AdInventoryBox::display() { } yyy += (_itemHeight + _spacing); } - if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0; + if (_window && _window->_alphaColor != 0) { + _gameRef->_renderer->_forceAlphaColor = 0; + } return STATUS_OK; } @@ -166,7 +174,9 @@ bool AdInventoryBox::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename); + } delete[] buffer; @@ -227,7 +237,9 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -245,7 +257,9 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; - } else _gameRef->registerObject(_window); + } else { + _gameRef->registerObject(_window); + } break; case TOKEN_AREA: @@ -308,8 +322,9 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { if (_window) { for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) + if (!_window->_widgets[i]->_listenerObject) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } } } @@ -337,7 +352,9 @@ bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // window - if (_window) _window->saveAsText(buffer, indent + 2); + if (_window) { + _window->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent + 2, "\n"); diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index cae974e152..c9e0d56b24 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -94,7 +94,9 @@ bool AdItem::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename); + } delete[] buffer; @@ -178,7 +180,9 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -186,7 +190,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - SetFont((char *)params); + setFont((char *)params); break; case TOKEN_CAPTION: @@ -230,9 +234,13 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_AMOUNT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _amountAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _amountAlign = TAL_RIGHT; - else _amountAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) { + _amountAlign = TAL_LEFT; + } else if (scumm_stricmp((char *)params, "right") == 0) { + _amountAlign = TAL_RIGHT; + } else { + _amountAlign = TAL_CENTER; + } break; case TOKEN_AMOUNT_STRING: @@ -241,15 +249,21 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_TALK: { BaseSprite *spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSprites.add(spr); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSprites.add(spr); + } } break; case TOKEN_TALK_SPECIAL: { BaseSprite *spr = new BaseSprite(_gameRef, this); - if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC; - else _talkSpritesEx.add(spr); + if (!spr || DID_FAIL(spr->loadFile((char *)params, ((AdGame *)_gameRef)->_texTalkLifeTime))) { + cmd = PARSERR_GENERIC; + } else { + _talkSpritesEx.add(spr); + } } break; @@ -331,10 +345,14 @@ bool AdItem::update() { _currentSprite = _animSprite; } - if (_sentence && _state != STATE_TALKING) _sentence->finish(); + if (_sentence && _state != STATE_TALKING) { + _sentence->finish(); + } // default: stand animation - if (!_currentSprite) _currentSprite = _sprite; + if (!_currentSprite) { + _currentSprite = _sprite; + } switch (_state) { ////////////////////////////////////////////////////////////////////////// @@ -345,15 +363,20 @@ bool AdItem::update() { ////////////////////////////////////////////////////////////////////////// case STATE_READY: if (!_animSprite) { - if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover; - else _currentSprite = _sprite; + if (_gameRef->_activeObject == this && _spriteHover) { + _currentSprite = _spriteHover; + } else { + _currentSprite = _sprite; + } } break; ////////////////////////////////////////////////////////////////////////// case STATE_TALKING: { _sentence->update(); - if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite; + if (_sentence->_currentSprite) { + _tempSprite2 = _sentence->_currentSprite; + } bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { @@ -396,9 +419,11 @@ bool AdItem::display(int x, int y) { _posY = y; bool ret; - if (_currentSprite) + if (_currentSprite) { ret = _currentSprite->draw(x, y, this, 100, 100, _alphaColor); - else ret = STATUS_OK; + } else { + ret = STATUS_OK; + } if (_displayAmount) { int amountX = x; @@ -412,8 +437,9 @@ bool AdItem::display(int x, int y) { BaseFont *font = _font ? _font : _gameRef->_systemFont; if (font) { - if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); - else { + if (_amountString) { + font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); + } else { char Str[256]; sprintf(Str, "%d", _amount); font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); @@ -436,7 +462,9 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); bool setCurrent = false; - if (_currentSprite && _currentSprite == _spriteHover) setCurrent = true; + if (_currentSprite && _currentSprite == _spriteHover) { + setCurrent = true; + } const char *filename = stack->pop()->getString(); @@ -448,7 +476,9 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename); } else { _spriteHover = spr; - if (setCurrent) _currentSprite = _spriteHover; + if (setCurrent) { + _currentSprite = _spriteHover; + } stack->pushBool(true); } return STATUS_OK; @@ -460,8 +490,11 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetHoverSprite") == 0) { stack->correctParams(0); - if (!_spriteHover || !_spriteHover->getFilename()) stack->pushNULL(); - else stack->pushString(_spriteHover->getFilename()); + if (!_spriteHover || !_spriteHover->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_spriteHover->getFilename()); + } return STATUS_OK; } @@ -470,8 +503,11 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverSpriteObject") == 0) { stack->correctParams(0); - if (!_spriteHover) stack->pushNULL(); - else stack->pushNative(_spriteHover, true); + if (!_spriteHover) { + stack->pushNULL(); + } else { + stack->pushNative(_spriteHover, true); + } return STATUS_OK; } @@ -502,8 +538,11 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetNormalCursor") == 0) { stack->correctParams(0); - if (!_cursorNormal || !_cursorNormal->getFilename()) stack->pushNULL(); - else stack->pushString(_cursorNormal->getFilename()); + if (!_cursorNormal || !_cursorNormal->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNormal->getFilename()); + } return STATUS_OK; } @@ -513,8 +552,11 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetNormalCursorObject") == 0) { stack->correctParams(0); - if (!_cursorNormal) stack->pushNULL(); - else stack->pushNative(_cursorNormal, true); + if (!_cursorNormal) { + stack->pushNULL(); + } else { + stack->pushNative(_cursorNormal, true); + } return STATUS_OK; } @@ -545,8 +587,11 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetHoverCursor") == 0) { stack->correctParams(0); - if (!_cursorHover || !_cursorHover->getFilename()) stack->pushNULL(); - else stack->pushString(_cursorHover->getFilename()); + if (!_cursorHover || !_cursorHover->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorHover->getFilename()); + } return STATUS_OK; } @@ -556,12 +601,15 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetHoverCursorObject") == 0) { stack->correctParams(0); - if (!_cursorHover) stack->pushNULL(); - else stack->pushNative(_cursorHover, true); + if (!_cursorHover) { + stack->pushNULL(); + } else { + stack->pushNative(_cursorHover, true); + } return STATUS_OK; + } else { + return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } - - else return AdTalkHolder::scCallMethod(script, stack, thisStack, name); } @@ -629,8 +677,11 @@ ScValue *AdItem::scGetProperty(const char *name) { // AmountString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AmountString") == 0) { - if (!_amountString) _scValue->setNULL(); - else _scValue->setString(_amountString); + if (!_amountString) { + _scValue->setNULL(); + } else { + _scValue->setString(_amountString); + } return _scValue; } @@ -640,9 +691,9 @@ ScValue *AdItem::scGetProperty(const char *name) { else if (strcmp(name, "CursorCombined") == 0) { _scValue->setBool(_cursorCombined); return _scValue; + } else { + return AdTalkHolder::scGetProperty(name); } - - else return AdTalkHolder::scGetProperty(name); } @@ -715,9 +766,9 @@ bool AdItem::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "CursorCombined") == 0) { _cursorCombined = value->getBool(); return STATUS_OK; + } else { + return AdTalkHolder::scSetProperty(name, value); } - - else return AdTalkHolder::scSetProperty(name, value); } @@ -750,9 +801,13 @@ bool AdItem::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdItem::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - else return AdObject::getExtendedFlag(flagName); + if (!flagName) { + return false; + } else if (strcmp(flagName, "usable") == 0) { + return true; + } else { + return AdObject::getExtendedFlag(flagName); + } } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 0a93edfb35..6c9e6381b2 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -53,8 +53,9 @@ AdLayer::AdLayer(BaseGame *inGame): BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdLayer::~AdLayer() { - for (int i = 0; i < _nodes.getSize(); i++) + for (int i = 0; i < _nodes.getSize(); i++) { delete _nodes[i]; + } _nodes.removeAll(); } @@ -71,7 +72,9 @@ bool AdLayer::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename); + } delete[] buffer; @@ -131,7 +134,9 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -181,7 +186,9 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { case TOKEN_ENTITY: { AdEntity *entity = new AdEntity(_gameRef); AdSceneNode *node = new AdSceneNode(_gameRef); - if (entity) entity->_zoomable = false; // scene entites default to NOT zoom + if (entity) { + entity->_zoomable = false; // scene entites default to NOT zoom + } if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; @@ -233,8 +240,9 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); int node = -1; - if (val->_type == VAL_INT) node = val->getInt(); - else { // get by name + if (val->_type == VAL_INT) { + node = val->getInt(); + } else { // get by name for (int i = 0; i < _nodes.getSize(); i++) { if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->getName(), val->getString()) == 0) || (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->getName(), val->getString()) == 0)) { @@ -244,8 +252,9 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } - if (node < 0 || node >= _nodes.getSize()) stack->pushNULL(); - else { + if (node < 0 || node >= _nodes.getSize()) { + stack->pushNULL(); + } else { switch (_nodes[node]->_type) { case OBJECT_ENTITY: stack->pushNative(_nodes[node]->_entity, true); @@ -270,12 +279,16 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdSceneNode *node = new AdSceneNode(_gameRef); if (strcmp(name, "AddRegion") == 0) { AdRegion *region = new AdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); + if (!val->isNULL()) { + region->setName(val->getString()); + } node->setRegion(region); stack->pushNative(region, true); } else { AdEntity *entity = new AdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); + if (!val->isNULL()) { + entity->setName(val->getString()); + } node->setEntity(entity); stack->pushNative(entity, true); } @@ -294,18 +307,27 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdSceneNode *node = new AdSceneNode(_gameRef); if (strcmp(name, "InsertRegion") == 0) { AdRegion *region = new AdRegion(_gameRef); - if (!val->isNULL()) region->setName(val->getString()); + if (!val->isNULL()) { + region->setName(val->getString()); + } node->setRegion(region); stack->pushNative(region, true); } else { AdEntity *entity = new AdEntity(_gameRef); - if (!val->isNULL()) entity->setName(val->getString()); + if (!val->isNULL()) { + entity->setName(val->getString()); + } node->setEntity(entity); stack->pushNative(entity, true); } - if (index < 0) index = 0; - if (index <= _nodes.getSize() - 1) _nodes.insertAt(index, node); - else _nodes.add(node); + if (index < 0) { + index = 0; + } + if (index <= _nodes.getSize() - 1) { + _nodes.insertAt(index, node); + } else { + _nodes.add(node); + } return STATUS_OK; } @@ -347,9 +369,9 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } stack->pushBool(true); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -411,9 +433,9 @@ ScValue *AdLayer::scGetProperty(const char *name) { else if (strcmp(name, "Active") == 0) { _scValue->setBool(_active); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -440,7 +462,9 @@ bool AdLayer::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { _width = value->getInt(); - if (_width < 0) _width = 0; + if (_width < 0) { + _width = 0; + } return STATUS_OK; } @@ -449,7 +473,9 @@ bool AdLayer::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { _height = value->getInt(); - if (_height < 0) _height = 0; + if (_height < 0) { + _height = 0; + } return STATUS_OK; } @@ -460,11 +486,13 @@ bool AdLayer::scSetProperty(const char *name, ScValue *value) { bool b = value->getBool(); if (b == false && _main) { _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer"); - } else _active = b; + } else { + _active = b; + } return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -484,8 +512,9 @@ bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "HEIGHT=%d\n", _height); buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - if (_closeUp) + if (_closeUp) { buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); + } int i; @@ -493,7 +522,9 @@ bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } for (i = 0; i < _nodes.getSize(); i++) { switch (_nodes[i]->_type) { diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 444373ea75..5a58dba5b1 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -44,8 +44,9 @@ IMPLEMENT_PERSISTENT(AdNodeState, false) AdNodeState::AdNodeState(BaseGame *inGame): BaseClass(inGame) { _name = NULL; _active = false; - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { _caption[i] = NULL; + } _alphaColor = 0; _filename = NULL; _cursor = NULL; @@ -100,8 +101,9 @@ bool AdNodeState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_cursor)); persistMgr->transfer(TMEMBER(_alphaColor)); - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { persistMgr->transfer(TMEMBER(_caption[i])); + } return STATUS_OK; } @@ -109,10 +111,12 @@ bool AdNodeState::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setCaption(const char *caption, int caseVal) { - if (caseVal == 0) + if (caseVal == 0) { caseVal = 1; - if (caseVal < 1 || caseVal > 7) + } + if (caseVal < 1 || caseVal > 7) { return; + } delete[] _caption[caseVal - 1]; _caption[caseVal - 1] = new char[strlen(caption) + 1]; @@ -125,44 +129,61 @@ void AdNodeState::setCaption(const char *caption, int caseVal) { ////////////////////////////////////////////////////////////////////////// char *AdNodeState::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { return ""; - else + } else { return _caption[caseVal - 1]; + } } ////////////////////////////////////////////////////////////////////////// bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool saving) { - if (!entity) return STATUS_FAILED; + if (!entity) { + return STATUS_FAILED; + } // HACK! - if (this->_gameRef != entity->_gameRef) + if (this->_gameRef != entity->_gameRef) { this->_gameRef = entity->_gameRef; + } if (saving) { for (int i = 0; i < 7; i++) { - if (entity->_caption[i]) setCaption(entity->_caption[i], i); + if (entity->_caption[i]) { + setCaption(entity->_caption[i], i); + } } if (!entity->_region && entity->_sprite && entity->_sprite->getFilename()) { - if (includingSprites) setFilename(entity->_sprite->getFilename()); - else setFilename(""); + if (includingSprites) { + setFilename(entity->_sprite->getFilename()); + } else { + setFilename(""); + } + } + if (entity->_cursor && entity->_cursor->getFilename()) { + setCursor(entity->_cursor->getFilename()); } - if (entity->_cursor && entity->_cursor->getFilename()) setCursor(entity->_cursor->getFilename()); _alphaColor = entity->_alphaColor; _active = entity->_active; } else { for (int i = 0; i < 7; i++) { - if (_caption[i]) entity->setCaption(_caption[i], i); + if (_caption[i]) { + entity->setCaption(_caption[i], i); + } } if (_filename && !entity->_region && includingSprites && strcmp(_filename, "") != 0) { - if (!entity->_sprite || !entity->_sprite->getFilename() || scumm_stricmp(entity->_sprite->getFilename(), _filename) != 0) + if (!entity->_sprite || !entity->_sprite->getFilename() || scumm_stricmp(entity->_sprite->getFilename(), _filename) != 0) { entity->setSprite(_filename); + } } if (_cursor) { - if (!entity->_cursor || !entity->_cursor->getFilename() || scumm_stricmp(entity->_cursor->getFilename(), _cursor) != 0) + if (!entity->_cursor || !entity->_cursor->getFilename() || scumm_stricmp(entity->_cursor->getFilename(), _cursor) != 0) { entity->setCursor(_cursor); + } } entity->_active = _active; diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index fdbc987158..c6f0306cbb 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -94,7 +94,9 @@ AdObject::AdObject(BaseGame *inGame): BaseObject(inGame) { _inventory = NULL; - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + _currentRegions[i] = NULL; + } _partEmitter = NULL; _partFollowParent = false; @@ -127,15 +129,18 @@ AdObject::~AdObject() { _tempSprite2 = NULL; // reference only _stickRegion = NULL; - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } if (_inventory) { ((AdGame *)_gameRef)->unregisterInventory(_inventory); _inventory = NULL; } - if (_partEmitter) + if (_partEmitter) { _gameRef->unregisterObject(_partEmitter); + } for (int i = 0; i < _attachmentsPre.getSize(); i++) { @@ -194,9 +199,12 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) { stack->correctParams(1); - if (DID_FAIL(playAnim(stack->pop()->getString()))) stack->pushBool(false); - else { - if (strcmp(name, "PlayAnimAsync") != 0) script->waitFor(this); + if (DID_FAIL(playAnim(stack->pop()->getString()))) { + stack->pushBool(false); + } else { + if (strcmp(name, "PlayAnimAsync") != 0) { + script->waitFor(this); + } stack->pushBool(true); } return STATUS_OK; @@ -226,12 +234,16 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) { stack->correctParams(0); - if (_sentence) _sentence->finish(); + if (_sentence) { + _sentence->finish(); + } if (_state == STATE_TALKING) { _state = _nextState; _nextState = STATE_READY; stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -265,15 +277,20 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int align = 0; ScValue *val = stack->pop(); - if (val->isNULL()) align = TAL_CENTER; - else align = val->getInt(); + if (val->isNULL()) { + align = TAL_CENTER; + } else { + align = val->getInt(); + } align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); talk(text, sound, duration, stances, (TTextAlign)align); - if (strcmp(name, "TalkAsync") != 0) script->waitForExclusive(this); + if (strcmp(name, "TalkAsync") != 0) { + script->waitForExclusive(this); + } stack->pushNULL(); return STATUS_OK; @@ -315,7 +332,9 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } - if (!regFound) _stickRegion = NULL; + if (!regFound) { + _stickRegion = NULL; + } stack->pushBool(regFound); return STATUS_OK; } @@ -327,8 +346,11 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); - if (val->isNULL()) SetFont(NULL); - else SetFont(val->getString()); + if (val->isNULL()) { + setFont(NULL); + } else { + setFont(val->getString()); + } stack->pushNULL(); return STATUS_OK; @@ -339,8 +361,11 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFont") == 0) { stack->correctParams(0); - if (_font && _font->getFilename()) stack->pushString(_font->getFilename()); - else stack->pushNULL(); + if (_font && _font->getFilename()) { + stack->pushString(_font->getFilename()); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -360,13 +385,16 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *itemName = val->getString(); val = stack->pop(); const char *insertAfter = val->isNULL() ? NULL : val->getString(); - if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName); - else { + if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) { + script->runtimeError("Cannot add item '%s' to inventory", itemName); + } else { // hide associated entities ((AdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false); } - } else script->runtimeError("TakeItem: item name expected"); + } else { + script->runtimeError("TakeItem: item name expected"); + } stack->pushNULL(); return STATUS_OK; @@ -385,12 +413,15 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (!val->isNULL()) { - if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); - else { + if (DID_FAIL(_inventory->removeItem(val->getString()))) { + script->runtimeError("Cannot remove item '%s' from inventory", val->getString()); + } else { // show associated entities ((AdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true); } - } else script->runtimeError("DropItem: item name expected"); + } else { + script->runtimeError("DropItem: item name expected"); + } stack->pushNULL(); return STATUS_OK; @@ -410,12 +441,16 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (val->_type == VAL_STRING) { AdItem *item = ((AdGame *)_gameRef)->getItemByName(val->getString()); - if (item) stack->pushNative(item, true); - else stack->pushNULL(); - } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) + if (item) { + stack->pushNative(item, true); + } else { + stack->pushNULL(); + } + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) { stack->pushNULL(); - else + } else { stack->pushNative(_inventory->_takenItems[val->getInt()], true); + } return STATUS_OK; } @@ -442,7 +477,9 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack return STATUS_OK; } } - } else script->runtimeError("HasItem: item name expected"); + } else { + script->runtimeError("HasItem: item name expected"); + } stack->pushBool(false); return STATUS_OK; @@ -458,8 +495,11 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int offsetY = stack->pop()->getInt(); PartEmitter *emitter = createParticleEmitter(followParent, offsetX, offsetY); - if (emitter) stack->pushNative(_partEmitter, true); - else stack->pushNULL(); + if (emitter) { + stack->pushNative(_partEmitter, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -502,8 +542,11 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ent->_posY = offsetY; ent->_active = true; - if (preDisplay) _attachmentsPre.add(ent); - else _attachmentsPost.add(ent); + if (preDisplay) { + _attachmentsPre.add(ent); + } else { + _attachmentsPost.add(ent); + } stack->pushBool(true); } @@ -572,11 +615,15 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int index = val->getInt(); int currIndex = 0; for (int i = 0; i < _attachmentsPre.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPre[i]; + if (currIndex == index) { + ret = _attachmentsPre[i]; + } currIndex++; } for (int i = 0; i < _attachmentsPost.getSize(); i++) { - if (currIndex == index) ret = _attachmentsPost[i]; + if (currIndex == index) { + ret = _attachmentsPost[i]; + } currIndex++; } } else { @@ -597,13 +644,16 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } - if (ret != NULL) stack->pushNative(ret, true); - else stack->pushNULL(); + if (ret != NULL) { + stack->pushNative(ret, true); + } else { + stack->pushNULL(); + } return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -695,8 +745,11 @@ ScValue *AdObject::scGetProperty(const char *name) { // ParticleEmitter (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ParticleEmitter") == 0) { - if (_partEmitter) _scValue->setNative(_partEmitter, true); - else _scValue->setNULL(); + if (_partEmitter) { + _scValue->setNative(_partEmitter, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -707,10 +760,9 @@ ScValue *AdObject::scGetProperty(const char *name) { else if (strcmp(name, "NumAttachments") == 0) { _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - - else return BaseObject::scGetProperty(name); } @@ -779,9 +831,9 @@ bool AdObject::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "SubtitlesPosXCenter") == 0) { _subtitlesModXCenter = value->getBool(); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -792,8 +844,10 @@ const char *AdObject::scToString() { ////////////////////////////////////////////////////////////////////////// -bool AdObject::SetFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); +bool AdObject::setFont(const char *filename) { + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } if (filename) { _font = _gameRef->_fontStorage->addFont(filename); return _font == NULL ? STATUS_FAILED : STATUS_OK; @@ -806,8 +860,9 @@ bool AdObject::SetFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// int AdObject::getHeight() { - if (!_currentSprite) return 0; - else { + if (!_currentSprite) { + return 0; + } else { BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; int ret = 0; for (int i = 0; i < frame->_subframes.getSize(); i++) { @@ -825,8 +880,12 @@ int AdObject::getHeight() { ////////////////////////////////////////////////////////////////////////// void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { - if (!_sentence) _sentence = new AdSentence(_gameRef); - if (!_sentence) return; + if (!_sentence) { + _sentence = new AdSentence(_gameRef); + } + if (!_sentence) { + return; + } if (_forcedTalkAnimName && _forcedTalkAnimUsed) { delete[] _forcedTalkAnimName; @@ -855,7 +914,9 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const sound = ((AdGame *)_gameRef)->findSpeechFile(key); delete[] key; - if (sound) deleteSound = true; + if (sound) { + deleteSound = true; + } } } @@ -865,10 +926,14 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) { _sentence->setSound(snd); if (_sentence->_duration <= 0) { - uint32 Length = snd->getLength(); - if (Length != 0) _sentence->_duration = Length; + uint32 length = snd->getLength(); + if (length != 0) { + _sentence->_duration = length; + } } - } else delete snd; + } else { + delete snd; + } } // set duration by text length @@ -888,11 +953,14 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const } - if (_subtitlesWidth > 0) width = _subtitlesWidth; - else { + if (_subtitlesWidth > 0) { + width = _subtitlesWidth; + } else { if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) { width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2)); - } else width = _gameRef->_renderer->_width / 2; + } else { + width = _gameRef->_renderer->_width / 2; + } } height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width); @@ -905,8 +973,9 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const x = _subtitlesModX; y = _subtitlesModY; } - if (_subtitlesModXCenter) + if (_subtitlesModXCenter) { x = x - width / 2; + } x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); @@ -931,7 +1000,9 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const _state = STATE_TALKING; - if (deleteSound) delete[] sound; + if (deleteSound) { + delete[] sound; + } } @@ -983,7 +1054,9 @@ bool AdObject::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_inventory)); persistMgr->transfer(TMEMBER(_partEmitter)); - for (int i = 0; i < MAX_NUM_REGIONS; i++) persistMgr->transfer(TMEMBER(_currentRegions[i])); + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + persistMgr->transfer(TMEMBER(_currentRegions[i])); + } _attachmentsPre.persist(persistMgr); _attachmentsPost.persist(persistMgr); @@ -999,8 +1072,9 @@ bool AdObject::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdObject::updateSounds() { - if (_sentence && _sentence->_sound) + if (_sentence && _sentence->_sound) { updateOneSound(_sentence->_sound); + } return BaseObject::updateSounds(); } @@ -1017,17 +1091,24 @@ bool AdObject::resetSoundPan() { ////////////////////////////////////////////////////////////////////////// bool AdObject::getExtendedFlag(const char *flagName) { - if (!flagName) return false; - else if (strcmp(flagName, "usable") == 0) return true; - - else return BaseObject::getExtendedFlag(flagName); + if (!flagName) { + return false; + } else if (strcmp(flagName, "usable") == 0) { + return true; + } else { + return BaseObject::getExtendedFlag(flagName); + } } ////////////////////////////////////////////////////////////////////////// bool AdObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { - if (_blockRegion) _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); - if (_wptGroup) _wptGroup->saveAsText(buffer, indent + 2); + if (_blockRegion) { + _blockRegion->saveAsText(buffer, indent + 2, "BLOCKED_REGION"); + } + if (_wptGroup) { + _wptGroup->saveAsText(buffer, indent + 2); + } BaseClass::saveAsText(buffer, indent + 2); @@ -1039,11 +1120,13 @@ bool AdObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool AdObject::updateBlockRegion() { AdGame *adGame = (AdGame *)_gameRef; if (adGame->_scene) { - if (_blockRegion && _currentBlockRegion) + if (_blockRegion && _currentBlockRegion) { _currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + } - if (_wptGroup && _currentWptGroup) + if (_wptGroup && _currentWptGroup) { _currentWptGroup->mimic(_wptGroup, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY); + } } return STATUS_OK; } @@ -1064,7 +1147,9 @@ bool AdObject::afterMove() { ((AdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS); for (int i = 0; i < MAX_NUM_REGIONS; i++) { - if (!newRegions[i]) break; + if (!newRegions[i]) { + break; + } bool regFound = false; for (int j = 0; j < MAX_NUM_REGIONS; j++) { if (_currentRegions[j] == newRegions[i]) { @@ -1073,7 +1158,9 @@ bool AdObject::afterMove() { break; } } - if (!regFound) newRegions[i]->applyEvent("ActorEntry"); + if (!regFound) { + newRegions[i]->applyEvent("ActorEntry"); + } } for (int i = 0; i < MAX_NUM_REGIONS; i++) { @@ -1088,7 +1175,9 @@ bool AdObject::afterMove() { ////////////////////////////////////////////////////////////////////////// bool AdObject::invalidateCurrRegions() { - for (int i = 0; i < MAX_NUM_REGIONS; i++) _currentRegions[i] = NULL; + for (int i = 0; i < MAX_NUM_REGIONS; i++) { + _currentRegions[i] = NULL; + } return STATUS_OK; } @@ -1099,8 +1188,11 @@ bool AdObject::getScale(float *scaleX, float *scaleY) { if (_scaleX >= 0 || _scaleY >= 0) { *scaleX = _scaleX < 0 ? 100 : _scaleX; *scaleY = _scaleY < 0 ? 100 : _scaleY; - } else if (_scale >= 0) *scaleX = *scaleY = _scale; - else *scaleX = *scaleY = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + } else if (_scale >= 0) { + *scaleX = *scaleY = _scale; + } else { + *scaleX = *scaleY = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale; + } } else { *scaleX = *scaleY = 100; } @@ -1134,7 +1226,9 @@ bool AdObject::displaySpriteAttachments(bool preDisplay) { ////////////////////////////////////////////////////////////////////////// bool AdObject::displaySpriteAttachment(AdObject *attachment) { - if (!attachment->_active) return STATUS_OK; + if (!attachment->_active) { + return STATUS_OK; + } float scaleX, scaleY; getScale(&scaleX, &scaleY); @@ -1188,7 +1282,9 @@ PartEmitter *AdObject::createParticleEmitter(bool followParent, int offsetX, int ////////////////////////////////////////////////////////////////////////// bool AdObject::updatePartEmitter() { - if (!_partEmitter) return STATUS_FAILED; + if (!_partEmitter) { + return STATUS_FAILED; + } if (_partFollowParent) { float scaleX, scaleY; diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index f26a29c8b2..58cb15fde3 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -73,7 +73,7 @@ public: virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); virtual int getHeight(); AdSentence *_sentence; - bool SetFont(const char *filename); + bool setFont(const char *filename); virtual bool update(); virtual bool display(); bool _drawn; diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index f7832d621d..89be10f0fb 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -48,8 +48,9 @@ AdPath::~AdPath() { ////////////////////////////////////////////////////////////////////////// void AdPath::reset() { - for (int i = 0; i < _points.getSize(); i++) + for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; + } _points.removeAll(); _currIndex = -1; @@ -62,22 +63,30 @@ BasePoint *AdPath::getFirst() { if (_points.getSize() > 0) { _currIndex = 0; return _points[_currIndex]; - } else return NULL; + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// BasePoint *AdPath::getNext() { _currIndex++; - if (_currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; + if (_currIndex < _points.getSize()) { + return _points[_currIndex]; + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// BasePoint *AdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < _points.getSize()) return _points[_currIndex]; - else return NULL; + if (_currIndex >= 0 && _currIndex < _points.getSize()) { + return _points[_currIndex]; + } else { + return NULL; + } } diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index eec25b2aaa..6b104d51ad 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -64,7 +64,9 @@ bool AdRegion::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + } delete[] buffer; @@ -126,7 +128,9 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { buffer = params; } - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + for (int i = 0; i < _points.getSize(); i++) { + delete _points[i]; + } _points.removeAll(); int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -134,7 +138,9 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -285,9 +291,9 @@ ScValue *AdRegion::scGetProperty(const char *name) { else if (strcmp(name, "AlphaColor") == 0) { _scValue->setInt((int)_alpha); return _scValue; + } else { + return BaseRegion::scGetProperty(name); } - - else return BaseRegion::scGetProperty(name); } @@ -331,9 +337,9 @@ bool AdRegion::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "AlphaColor") == 0) { _alpha = (uint32)value->getInt(); return STATUS_OK; + } else { + return BaseRegion::scSetProperty(name, value); } - - else return BaseRegion::scSetProperty(name, value); } @@ -361,7 +367,9 @@ bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } for (i = 0; i < _points.getSize(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index fbfe828330..e954b0d44d 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -59,7 +59,9 @@ AdResponse::~AdResponse() { _icon = NULL; _iconHover = NULL; _iconPressed = NULL; - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } } @@ -85,7 +87,9 @@ bool AdResponse::setIcon(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool AdResponse::setFont(const char *filename) { - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont(filename); if (!_font) { _gameRef->LOG(0, "AdResponse::setFont failed for file '%s'", filename); diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 22b40f3ea4..fe37002abb 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -81,8 +81,12 @@ AdResponseBox::~AdResponseBox() { delete[] _lastResponseTextOrig; _lastResponseTextOrig = NULL; - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } + if (_fontHover) { + _gameRef->_fontStorage->removeFont(_fontHover); + } clearResponses(); clearButtons(); @@ -137,12 +141,19 @@ bool AdResponseBox::createButtons() { // iconic if (_responses[i]->_icon) { btn->_image = _responses[i]->_icon; - if (_responses[i]->_iconHover) btn->_imageHover = _responses[i]->_iconHover; - if (_responses[i]->_iconPressed) btn->_imagePress = _responses[i]->_iconPressed; + if (_responses[i]->_iconHover) { + btn->_imageHover = _responses[i]->_iconHover; + } + if (_responses[i]->_iconPressed) { + btn->_imagePress = _responses[i]->_iconPressed; + } btn->setCaption(_responses[i]->_text); - if (_cursor) btn->_cursor = _cursor; - else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor; + if (_cursor) { + btn->_cursor = _cursor; + } else if (_gameRef->_activeCursor) { + btn->_cursor = _gameRef->_activeCursor; + } } // textual else { @@ -152,21 +163,27 @@ bool AdResponseBox::createButtons() { btn->_fontPress = btn->_fontHover; btn->_align = _align; - if (_gameRef->_touchInterface) + if (_gameRef->_touchInterface) { btn->_fontHover = btn->_font; + } - if (_responses[i]->_font) btn->_font = _responses[i]->_font; + if (_responses[i]->_font) { + btn->_font = _responses[i]->_font; + } btn->_width = _responseArea.right - _responseArea.left; - if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width; + if (btn->_width <= 0) { + btn->_width = _gameRef->_renderer->_width; + } } btn->setName("response"); btn->correctSize(); // make the responses touchable - if (_gameRef->_touchInterface) + if (_gameRef->_touchInterface) { btn->_height = MAX(btn->_height, 50); + } //btn->SetListener(this, btn, _responses[i]->_iD); btn->setListener(this, btn, i); @@ -197,7 +214,9 @@ bool AdResponseBox::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename); + } delete[] buffer; @@ -253,7 +272,9 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_WINDOW: @@ -263,19 +284,29 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { delete _window; _window = NULL; cmd = PARSERR_GENERIC; - } else if (_shieldWindow) _shieldWindow->_parent = _window; + } else if (_shieldWindow) { + _shieldWindow->_parent = _window; + } break; case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; + if (!_font) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontHover) { + _gameRef->_fontStorage->removeFont(_fontHover); + } _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; + if (!_fontHover) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_AREA: @@ -287,15 +318,23 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "center") == 0) _align = TAL_CENTER; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_LEFT; + if (scumm_stricmp((char *)params, "center") == 0) { + _align = TAL_CENTER; + } else if (scumm_stricmp((char *)params, "right") == 0) { + _align = TAL_RIGHT; + } else { + _align = TAL_LEFT; + } break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "center") == 0) _verticalAlign = VAL_CENTER; - else _verticalAlign = VAL_BOTTOM; + if (scumm_stricmp((char *)params, "top") == 0) { + _verticalAlign = VAL_TOP; + } else if (scumm_stricmp((char *)params, "center") == 0) { + _verticalAlign = VAL_CENTER; + } else { + _verticalAlign = VAL_BOTTOM; + } break; case TOKEN_SPACING: @@ -324,8 +363,9 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { if (_window) { for (int i = 0; i < _window->_widgets.getSize(); i++) { - if (!_window->_widgets[i]->_listenerObject) + if (!_window->_widgets[i]->_listenerObject) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); + } } } @@ -339,13 +379,16 @@ bool AdResponseBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _responseArea.left, _responseArea.top, _responseArea.right, _responseArea.bottom); - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_fontHover && _fontHover->getFilename()) + } + if (_fontHover && _fontHover->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } buffer->putTextIndent(indent + 2, "HORIZONTAL=%s\n", _horizontal ? "TRUE" : "FALSE"); @@ -381,7 +424,9 @@ bool AdResponseBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // window - if (_window) _window->saveAsText(buffer, indent + 2); + if (_window) { + _window->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent + 2, "\n"); @@ -409,18 +454,22 @@ bool AdResponseBox::display() { // shift down if needed if (!_horizontal) { int total_height = 0; - for (i = 0; i < _respButtons.getSize(); i++) total_height += (_respButtons[i]->_height + _spacing); + for (i = 0; i < _respButtons.getSize(); i++) { + total_height += (_respButtons[i]->_height + _spacing); + } total_height -= _spacing; switch (_verticalAlign) { case VAL_BOTTOM: - if (yyy + total_height < rect.bottom) + if (yyy + total_height < rect.bottom) { yyy = rect.bottom - total_height; + } break; case VAL_CENTER: - if (yyy + total_height < rect.bottom) + if (yyy + total_height < rect.bottom) { yyy += ((rect.bottom - rect.top) - total_height) / 2; + } break; case VAL_TOP: @@ -467,7 +516,9 @@ bool AdResponseBox::display() { } // display window - if (_window) _window->display(); + if (_window) { + _window->display(); + } // display response buttons @@ -490,7 +541,9 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { } else if (scumm_stricmp(obj->getName(), "next") == 0) { _scrollOffset++; } else if (scumm_stricmp(obj->getName(), "response") == 0) { - if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD); + if (_waitingScript) { + _waitingScript->_stack->pushInt(_responses[param2]->_iD); + } handleResponse(_responses[param2]); _waitingScript = NULL; _gameRef->_state = GAME_RUNNING; @@ -498,7 +551,9 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { _ready = true; invalidateButtons(); clearResponses(); - } else return BaseObject::listen(param1, param2); + } else { + return BaseObject::listen(param1, param2); + } break; default: error("AdResponseBox::Listen - Unhandled enum"); @@ -597,13 +652,17 @@ BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { BaseArray objects; getObjects(objects, true); - if (objects.getSize() == 0) return NULL; - else { + if (objects.getSize() == 0) { + return NULL; + } else { if (currObject != NULL) { for (int i = 0; i < objects.getSize(); i++) { if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; + if (i < objects.getSize() - 1) { + return objects[i + 1]; + } else { + break; + } } } } @@ -617,13 +676,17 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { BaseArray objects; getObjects(objects, true); - if (objects.getSize() == 0) return NULL; - else { + if (objects.getSize() == 0) { + return NULL; + } else { if (currObject != NULL) { for (int i = objects.getSize() - 1; i >= 0; i--) { if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; + if (i > 0) { + return objects[i - 1]; + } else { + break; + } } } } @@ -637,7 +700,9 @@ bool AdResponseBox::getObjects(BaseArray &objects, bool for (int i = 0; i < _respButtons.getSize(); i++) { objects.add(_respButtons[i]); } - if (_window) _window->getWindowObjects(objects, interactiveOnly); + if (_window) { + _window->getWindowObjects(objects, interactiveOnly); + } return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 8d966e7a3e..41359fc0f0 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -35,7 +35,7 @@ IMPLEMENT_PERSISTENT(AdResponseContext, false) ////////////////////////////////////////////////////////////////////////// AdResponseContext::AdResponseContext(BaseGame *inGame): BaseClass(inGame) { - _iD = 0; + _id = 0; _context = NULL; } @@ -51,7 +51,7 @@ AdResponseContext::~AdResponseContext() { bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_context)); - persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_id)); return STATUS_OK; } @@ -62,7 +62,9 @@ void AdResponseContext::setContext(const char *context) { _context = NULL; if (context) { _context = new char [strlen(context) + 1]; - if (_context) strcpy(_context, context); + if (_context) { + strcpy(_context, context); + } } } diff --git a/engines/wintermute/ad/ad_response_context.h b/engines/wintermute/ad/ad_response_context.h index d0dc1546b7..d5c8bb3fa3 100644 --- a/engines/wintermute/ad/ad_response_context.h +++ b/engines/wintermute/ad/ad_response_context.h @@ -37,7 +37,7 @@ namespace WinterMute { class AdResponseContext : public BaseClass { public: void setContext(const char *context); - int _iD; + int _id; char *_context; DECLARE_PERSISTENT(AdResponseContext, BaseClass) AdResponseContext(BaseGame *inGame); diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 72fcaeff28..f04d379e6b 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -63,7 +63,9 @@ bool AdRotLevel::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename); + } delete[] buffer; @@ -104,7 +106,9 @@ bool AdRotLevel::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_X: diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index c390c6dc08..f9da6bba4a 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -61,7 +61,9 @@ bool AdScaleLevel::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename); + } delete[] buffer; @@ -102,7 +104,9 @@ bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_Y: diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 85c2341268..21f28b6247 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -148,31 +148,37 @@ void AdScene::cleanup() { _gameRef->unregisterObject(_fader); _fader = NULL; - for (i = 0; i < _layers.getSize(); i++) + for (i = 0; i < _layers.getSize(); i++) { _gameRef->unregisterObject(_layers[i]); + } _layers.removeAll(); - for (i = 0; i < _waypointGroups.getSize(); i++) + for (i = 0; i < _waypointGroups.getSize(); i++) { _gameRef->unregisterObject(_waypointGroups[i]); + } _waypointGroups.removeAll(); - for (i = 0; i < _scaleLevels.getSize(); i++) + for (i = 0; i < _scaleLevels.getSize(); i++) { _gameRef->unregisterObject(_scaleLevels[i]); + } _scaleLevels.removeAll(); - for (i = 0; i < _rotLevels.getSize(); i++) + for (i = 0; i < _rotLevels.getSize(); i++) { _gameRef->unregisterObject(_rotLevels[i]); + } _rotLevels.removeAll(); - for (i = 0; i < _pfPath.getSize(); i++) + for (i = 0; i < _pfPath.getSize(); i++) { delete _pfPath[i]; + } _pfPath.removeAll(); _pfPointsNum = 0; - for (i = 0; i < _objects.getSize(); i++) + for (i = 0; i < _objects.getSize(); i++) { _gameRef->unregisterObject(_objects[i]); + } _objects.removeAll(); delete _viewport; @@ -184,8 +190,9 @@ void AdScene::cleanup() { ////////////////////////////////////////////////////////////////////////// bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester) { - if (!_pfReady) return false; - else { + if (!_pfReady) { + return false; + } else { _pfReady = false; *_pfTarget = target; _pfTargetPath = path; @@ -258,10 +265,14 @@ bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObje ////////////////////////////////////////////////////////////////////////// void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { - if (!wpt->_active) return; + if (!wpt->_active) { + return; + } for (int i = 0; i < wpt->_points.getSize(); i++) { - if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) continue; + if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) { + continue; + } //_pfPath.add(new AdPathPoint(Wpt->_points[i]->x, Wpt->_points[i]->y, INT_MAX)); pfPointsAdd(wpt->_points[i]->x, wpt->_points[i]->y, INT_MAX); @@ -286,7 +297,9 @@ float AdScene::getZoomAt(int x, int y) { } } } - if (!found) ret = getScaleAt(y); + if (!found) { + ret = getScaleAt(y); + } return ret; } @@ -294,17 +307,24 @@ float AdScene::getZoomAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) { - if (!_gameRef->_debugDebugMode) colorCheck = false; + if (!_gameRef->_debugDebugMode) { + colorCheck = false; + } uint32 ret; - if (colorCheck) ret = 0xFFFF0000; - else ret = 0xFFFFFFFF; + if (colorCheck) { + ret = 0xFFFF0000; + } else { + ret = 0xFFFFFFFF; + } if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { - if (!node->_region->_blocked) ret = node->_region->_alpha; + if (!node->_region->_blocked) { + ret = node->_region->_alpha; + } break; } } @@ -321,13 +341,17 @@ bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *reque if (checkFreeObjects) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { + return true; + } } } AdGame *adGame = (AdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true; + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { + return true; + } } } } @@ -347,7 +371,9 @@ bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *reque if (node->_region->_blocked) { ret = true; break; - } else ret = false; + } else { + ret = false; + } } } } @@ -362,13 +388,17 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ if (checkFreeObjects) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { - if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { + return false; + } } } AdGame *adGame = (AdGame *)_gameRef; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { - if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false; + if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { + return false; + } } } } @@ -381,7 +411,9 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ if (node->_region->_blocked) { ret = false; break; - } else ret = true; + } else { + ret = true; + } } } } @@ -413,7 +445,9 @@ int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester) { y = y1; for (xCount = x1; xCount < x2; xCount++) { - if (isBlockedAt(xCount, (int)y, true, requester)) return -1; + if (isBlockedAt(xCount, (int)y, true, requester)) { + return -1; + } y += yStep; } } else { @@ -426,7 +460,9 @@ int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester) { x = x1; for (yCount = y1; yCount < y2; yCount++) { - if (isBlockedAt((int)x, yCount, true, requester)) return -1; + if (isBlockedAt((int)x, yCount, true, requester)) { + return -1; + } x += xStep; } } @@ -488,10 +524,14 @@ bool AdScene::initLoop() { PathFinderStep(); nu_steps++; } - if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); + if (nu_steps > 0) { + _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime); + } #else uint32 start = _gameRef->_currentTime; - while (!_pfReady && g_system->getMillis() - start <= _pfMaxTime) pathFinderStep(); + while (!_pfReady && g_system->getMillis() - start <= _pfMaxTime) { + pathFinderStep(); + } #endif return STATUS_OK; @@ -510,7 +550,9 @@ bool AdScene::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename); + } setFilename(filename); @@ -622,7 +664,9 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -815,8 +859,12 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: { Rect32 rc; parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom); - if (!_viewport) _viewport = new BaseViewport(_gameRef); - if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); + if (!_viewport) { + _viewport = new BaseViewport(_gameRef); + } + if (_viewport) { + _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true); + } } case TOKEN_PERSISTENT_STATE: @@ -838,7 +886,9 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { return STATUS_FAILED; } - if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", getFilename()); + if (_mainLayer == NULL) { + _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", getFilename()); + } sortScaleLevels(); @@ -852,7 +902,9 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdScene::traverseNodes(bool doUpdate) { - if (!_initialized) return STATUS_OK; + if (!_initialized) { + return STATUS_OK; + } int j, k; AdGame *adGame = (AdGame *)_gameRef; @@ -860,13 +912,13 @@ bool AdScene::traverseNodes(bool doUpdate) { ////////////////////////////////////////////////////////////////////////// // prepare viewport - bool PopViewport = false; + bool popViewport = false; if (_viewport && !_gameRef->_editorMode) { _gameRef->pushViewport(_viewport); - PopViewport = true; + popViewport = true; } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { _gameRef->pushViewport(adGame->_sceneViewport); - PopViewport = true; + popViewport = true; } @@ -905,8 +957,12 @@ bool AdScene::traverseNodes(bool doUpdate) { } } - if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) _ready = true; - } else _ready = true; // not scrolling, i.e. always ready + if (_offsetTop == _targetOffsetTop && _offsetLeft == _targetOffsetLeft) { + _ready = true; + } + } else { + _ready = true; // not scrolling, i.e. always ready + } } @@ -939,12 +995,16 @@ bool AdScene::traverseNodes(bool doUpdate) { /* int MainOffsetY = 0; */ for (j = 0; j < _layers.getSize(); j++) { - if (!_layers[j]->_active) continue; + if (!_layers[j]->_active) { + continue; + } // make layer exclusive if (!doUpdate) { if (_layers[j]->_closeUp && !_gameRef->_editorMode) { - if (!_shieldWindow) _shieldWindow = new UIWindow(_gameRef); + if (!_shieldWindow) { + _shieldWindow = new UIWindow(_gameRef); + } if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; _shieldWindow->_width = _gameRef->_renderer->_width; @@ -979,16 +1039,25 @@ bool AdScene::traverseNodes(bool doUpdate) { if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) { _gameRef->_renderer->setup2D(); - if (doUpdate) node->_entity->update(); - else node->_entity->display(); + if (doUpdate) { + node->_entity->update(); + } else { + node->_entity->display(); + } } break; case OBJECT_REGION: { - if (node->_region->_blocked) break; - if (node->_region->_decoration) break; + if (node->_region->_blocked) { + break; + } + if (node->_region->_decoration) { + break; + } - if (!doUpdate) displayRegionContent(node->_region); + if (!doUpdate) { + displayRegionContent(node->_region); + } } break; default: @@ -1014,11 +1083,16 @@ bool AdScene::traverseNodes(bool doUpdate) { // display/update fader if (_fader) { - if (doUpdate) _fader->update(); - else _fader->display(); + if (doUpdate) { + _fader->update(); + } else { + _fader->display(); + } } - if (PopViewport) _gameRef->popViewport(); + if (popViewport) { + _gameRef->popViewport(); + } return STATUS_OK; } @@ -1037,7 +1111,9 @@ bool AdScene::updateFreeObjects() { // *** update all active objects is3DSet = false; for (int i = 0; i < adGame->_objects.getSize(); i++) { - if (!adGame->_objects[i]->_active) continue; + if (!adGame->_objects[i]->_active) { + continue; + } adGame->_objects[i]->update(); adGame->_objects[i]->_drawn = false; @@ -1045,7 +1121,9 @@ bool AdScene::updateFreeObjects() { for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_active) continue; + if (!_objects[i]->_active) { + continue; + } _objects[i]->update(); _objects[i]->_drawn = false; @@ -1090,11 +1168,15 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { for (int i = 0; i < objects.getSize(); i++) { obj = objects[i]; - if (display3DOnly && !obj->_is3D) continue; + if (display3DOnly && !obj->_is3D) { + continue; + } _gameRef->_renderer->setup2D(); - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + if (_gameRef->_editorMode || !obj->_editorOnly) { + obj->display(); + } obj->_drawn = true; } @@ -1119,9 +1201,13 @@ int AdScene::compareObjs(const void *obj1, const void *obj2) { AdObject *object1 = *(AdObject **)obj1; AdObject *object2 = *(AdObject **)obj2; - if (object1->_posY < object2->_posY) return -1; - else if (object1->_posY > object2->_posY) return 1; - else return 0; + if (object1->_posY < object2->_posY) { + return -1; + } else if (object1->_posY > object2->_posY) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -1154,7 +1240,9 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { if (obj != NULL) { _gameRef->_renderer->setup2D(); - if (_gameRef->_editorMode || !obj->_editorOnly) obj->display(); + if (_gameRef->_editorMode || !obj->_editorOnly) { + obj->display(); + } obj->_drawn = true; } } while (obj != NULL); @@ -1195,8 +1283,12 @@ void AdScene::scrollTo(int offsetX, int offsetY) { if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { - if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft; - if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop; + if (abs(origOffsetLeft - _targetOffsetLeft) < 5) { + _targetOffsetLeft = origOffsetLeft; + } + if (abs(origOffsetTop - _targetOffsetTop) < 5) { + _targetOffsetTop = origOffsetTop; + } //_targetOffsetTop = 0; } @@ -1206,13 +1298,17 @@ void AdScene::scrollTo(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// void AdScene::scrollToObject(BaseObject *object) { - if (object) scrollTo(object->_posX, object->_posY - object->getHeight() / 2); + if (object) { + scrollTo(object->_posX, object->_posY - object->getHeight() / 2); + } } ////////////////////////////////////////////////////////////////////////// void AdScene::skipToObject(BaseObject *object) { - if (object) skipTo(object->_posX, object->_posY - object->getHeight() / 2); + if (object) { + skipTo(object->_posX, object->_posY - object->getHeight() / 2); + } } @@ -1279,7 +1375,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdEntity *ent = new AdEntity(_gameRef); addObject(ent); - if (!val->isNULL()) ent->setName(val->getString()); + if (!val->isNULL()) { + ent->setName(val->getString()); + } stack->pushNative(ent, true); return STATUS_OK; } @@ -1292,7 +1390,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); AdObject *obj = (AdObject *)val->getNative(); removeObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } stack->pushNULL(); return STATUS_OK; @@ -1326,7 +1426,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } else { scrollTo(val1->getInt(), val2->getInt()); } - if (strcmp(name, "ScrollTo") == 0) script->waitForExclusive(this); + if (strcmp(name, "ScrollTo") == 0) { + script->waitForExclusive(this); + } stack->pushNULL(); return STATUS_OK; } @@ -1339,19 +1441,24 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); if (val->isInt()) { int layer = val->getInt(); - if (layer < 0 || layer >= _layers.getSize()) stack->pushNULL(); - else stack->pushNative(_layers[layer], true); + if (layer < 0 || layer >= _layers.getSize()) { + stack->pushNULL(); + } else { + stack->pushNative(_layers[layer], true); + } } else { - const char *LayerName = val->getString(); - bool LayerFound = false; + const char *layerName = val->getString(); + bool layerFound = false; for (int i = 0; i < _layers.getSize(); i++) { - if (scumm_stricmp(LayerName, _layers[i]->getName()) == 0) { + if (scumm_stricmp(layerName, _layers[i]->getName()) == 0) { stack->pushNative(_layers[i], true); - LayerFound = true; + layerFound = true; break; } } - if (!LayerFound) stack->pushNULL(); + if (!layerFound) { + stack->pushNULL(); + } } return STATUS_OK; } @@ -1362,8 +1469,11 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetWaypointGroup") == 0) { stack->correctParams(1); int group = stack->pop()->getInt(); - if (group < 0 || group >= _waypointGroups.getSize()) stack->pushNULL(); - else stack->pushNative(_waypointGroups[group], true); + if (group < 0 || group >= _waypointGroups.getSize()) { + stack->pushNULL(); + } else { + stack->pushNative(_waypointGroups[group], true); + } return STATUS_OK; } @@ -1375,8 +1485,11 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *nodeName = stack->pop()->getString(); BaseObject *node = getNodeByName(nodeName); - if (node) stack->pushNative((BaseScriptable *)node, true); - else stack->pushNULL(); + if (node) { + stack->pushNative((BaseScriptable *)node, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -1391,7 +1504,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdObject *ret = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _objects.getSize()) ret = _objects[index]; + if (index >= 0 && index < _objects.getSize()) { + ret = _objects[index]; + } } else { const char *nodeName = val->getString(); for (int i = 0; i < _objects.getSize(); i++) { @@ -1401,8 +1516,11 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } } - if (ret) stack->pushNative(ret, true); - else stack->pushNULL(); + if (ret) { + stack->pushNative(ret, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -1417,13 +1535,17 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); bool includeDecors = false; - if (!val->isNULL()) includeDecors = val->getBool(); + if (!val->isNULL()) { + includeDecors = val->getBool(); + } if (_mainLayer) { for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (node->_region->_decoration && !includeDecors) continue; + if (node->_region->_decoration && !includeDecors) { + continue; + } stack->pushNative(node->_region, true); return STATUS_OK; @@ -1489,7 +1611,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(0); bool ret = false; if (_autoScroll) { - if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) ret = true; + if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) { + ret = true; + } } stack->pushBool(ret); @@ -1508,7 +1632,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, byte alpha = stack->pop()->getInt(0xFF); _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeOutAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1526,7 +1652,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, byte alpha = stack->pop()->getInt(0xFF); _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration); - if (strcmp(name, "FadeInAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1562,11 +1690,19 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, int width = stack->pop()->getInt(); int height = stack->pop()->getInt(); - if (width <= 0) width = _gameRef->_renderer->_width; - if (height <= 0) height = _gameRef->_renderer->_height; + if (width <= 0) { + width = _gameRef->_renderer->_width; + } + if (height <= 0) { + height = _gameRef->_renderer->_height; + } - if (!_viewport) _viewport = new BaseViewport(_gameRef); - if (_viewport) _viewport->setRect(x, y, x + width, y + height); + if (!_viewport) { + _viewport = new BaseViewport(_gameRef); + } + if (_viewport) { + _viewport->setRect(x, y, x + width, y + height); + } stack->pushBool(true); @@ -1581,7 +1717,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); AdLayer *layer = new AdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); + if (!val->isNULL()) { + layer->setName(val->getString()); + } if (_mainLayer) { layer->_width = _mainLayer->_width; layer->_height = _mainLayer->_height; @@ -1602,14 +1740,21 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); AdLayer *layer = new AdLayer(_gameRef); - if (!val->isNULL()) layer->setName(val->getString()); + if (!val->isNULL()) { + layer->setName(val->getString()); + } if (_mainLayer) { layer->_width = _mainLayer->_width; layer->_height = _mainLayer->_height; } - if (index < 0) index = 0; - if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer); - else _layers.add(layer); + if (index < 0) { + index = 0; + } + if (index <= _layers.getSize() - 1) { + _layers.insertAt(index, layer); + } else { + _layers.add(layer); + } _gameRef->registerObject(layer); @@ -1659,9 +1804,9 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } stack->pushBool(true); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -1697,8 +1842,11 @@ ScValue *AdScene::scGetProperty(const char *name) { // MainLayer (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainLayer") == 0) { - if (_mainLayer) _scValue->setNative(_mainLayer, true); - else _scValue->setNULL(); + if (_mainLayer) { + _scValue->setNative(_mainLayer, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -1810,8 +1958,11 @@ ScValue *AdScene::scGetProperty(const char *name) { // Width (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Width") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_width); - else _scValue->setInt(0); + if (_mainLayer) { + _scValue->setInt(_mainLayer->_width); + } else { + _scValue->setInt(0); + } return _scValue; } @@ -1819,12 +1970,15 @@ ScValue *AdScene::scGetProperty(const char *name) { // Height (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Height") == 0) { - if (_mainLayer) _scValue->setInt(_mainLayer->_height); - else _scValue->setInt(0); + if (_mainLayer) { + _scValue->setInt(_mainLayer->_height); + } else { + _scValue->setInt(0); + } return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -1924,9 +2078,9 @@ bool AdScene::scSetProperty(const char *name, ScValue *value) { _targetOffsetTop = _offsetTop; return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -1964,11 +2118,13 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - if (_persistentState) + if (_persistentState) { buffer->putTextIndent(indent + 2, "PERSISTENT_STATE=%s\n", _persistentState ? "TRUE" : "FALSE"); + } - if (!_persistentStateSprites) + if (!_persistentStateSprites) { buffer->putTextIndent(indent + 2, "PERSISTENT_STATE_SPRITES=%s\n", _persistentStateSprites ? "TRUE" : "FALSE"); + } // scripts @@ -1979,7 +2135,9 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // properties - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } // viewport if (_viewport) { @@ -2018,21 +2176,29 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // waypoints buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.getSize(); i++) _waypointGroups[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _waypointGroups.getSize(); i++) { + _waypointGroups[i]->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent + 2, "\n"); // layers buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.getSize(); i++) _layers[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _layers.getSize(); i++) { + _layers[i]->saveAsText(buffer, indent + 2); + } // scale levels buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.getSize(); i++) _scaleLevels[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _scaleLevels.getSize(); i++) { + _scaleLevels[i]->saveAsText(buffer, indent + 2); + } // rotation levels buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.getSize(); i++) _rotLevels[i]->saveAsText(buffer, indent + 2); + for (i = 0; i < _rotLevels.getSize(); i++) { + _rotLevels[i]->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent + 2, "\n"); @@ -2103,14 +2269,17 @@ float AdScene::getScaleAt(int Y) { for (int i = 0; i < _scaleLevels.getSize(); i++) { /* AdScaleLevel *xxx = _scaleLevels[i];*/ /* int j = _scaleLevels.getSize(); */ - if (_scaleLevels[i]->_posY < Y) prev = _scaleLevels[i]; - else { + if (_scaleLevels[i]->_posY < Y) { + prev = _scaleLevels[i]; + } else { next = _scaleLevels[i]; break; } } - if (prev == NULL || next == NULL) return 100; + if (prev == NULL || next == NULL) { + return 100; + } int delta_y = next->_posY - prev->_posY; float delta_scale = next->_scale - prev->_scale; @@ -2255,70 +2424,86 @@ bool AdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, b } // right - int length_right = 0; - bool found_right = false; - for (x = *argX, y = *argY; x < _mainLayer->_width; x++, length_right++) { + int lengthRight = 0; + bool foundRight = false; + for (x = *argX, y = *argY; x < _mainLayer->_width; x++, lengthRight++) { if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x - 5, y, checkFreeObjects, requester)) { - found_right = true; + foundRight = true; break; } } // left - int length_left = 0; - bool found_left = false; - for (x = *argX, y = *argY; x >= 0; x--, length_left--) { + int lengthLeft = 0; + bool foundLeft = false; + for (x = *argX, y = *argY; x >= 0; x--, lengthLeft--) { if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x + 5, y, checkFreeObjects, requester)) { - found_left = true; + foundLeft = true; break; } } // up - int length_up = 0; - bool found_up = false; - for (x = *argX, y = *argY; y >= 0; y--, length_up--) { + int lengthUp = 0; + bool foundUp = false; + for (x = *argX, y = *argY; y >= 0; y--, lengthUp--) { if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y + 5, checkFreeObjects, requester)) { - found_up = true; + foundUp = true; break; } } // down - int length_down = 0; - bool found_down = false; - for (x = *argX, y = *argY; y < _mainLayer->_height; y++, length_down++) { + int lengthDown = 0; + bool foundDown = false; + for (x = *argX, y = *argY; y < _mainLayer->_height; y++, lengthDown++) { if (isWalkableAt(x, y, checkFreeObjects, requester) && isWalkableAt(x, y - 5, checkFreeObjects, requester)) { - found_down = true; + foundDown = true; break; } } - if (!found_left && !found_right && !found_up && !found_down) { + if (!foundLeft && !foundRight && !foundUp && !foundDown) { return STATUS_OK; } - int OffsetX = INT_MAX, OffsetY = INT_MAX; + int offsetX = INT_MAX, offsetY = INT_MAX; - if (found_left && found_right) { - if (abs(length_left) < abs(length_right)) OffsetX = length_left; - else OffsetX = length_right; - } else if (found_left) OffsetX = length_left; - else if (found_right) OffsetX = length_right; + if (foundLeft && foundRight) { + if (abs(lengthLeft) < abs(lengthRight)) { + offsetX = lengthLeft; + } else { + offsetX = lengthRight; + } + } else if (foundLeft) { + offsetX = lengthLeft; + } else if (foundRight) { + offsetX = lengthRight; + } - if (found_up && found_down) { - if (abs(length_up) < abs(length_down)) OffsetY = length_up; - else OffsetY = length_down; - } else if (found_up) OffsetY = length_up; - else if (found_down) OffsetY = length_down; + if (foundUp && foundDown) { + if (abs(lengthUp) < abs(lengthDown)) { + offsetY = lengthUp; + } else { + offsetY = lengthDown; + } + } else if (foundUp) { + offsetY = lengthUp; + } else if (foundDown) { + offsetY = lengthDown; + } - if (abs(OffsetX) < abs(OffsetY)) - *argX = *argX + OffsetX; - else - *argY = *argY + OffsetY; + if (abs(offsetX) < abs(offsetY)) { + *argX = *argX + offsetX; + } else { + *argY = *argY + offsetY; + } - if (!isWalkableAt(*argX, *argY)) return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); - else return STATUS_OK; + if (!isWalkableAt(*argX, *argY)) { + return correctTargetPoint2(startX, startY, argX, argY, checkFreeObjects, requester); + } else { + return STATUS_OK; + } } @@ -2348,14 +2533,26 @@ void AdScene::pfPointsAdd(int x, int y, int distance) { bool AdScene::getViewportOffset(int *offsetX, int *offsetY) { AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = _viewport->_offsetX; - if (offsetY) *offsetY = _viewport->_offsetY; + if (offsetX) { + *offsetX = _viewport->_offsetX; + } + if (offsetY) { + *offsetY = _viewport->_offsetY; + } } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX; - if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY; + if (offsetX) { + *offsetX = adGame->_sceneViewport->_offsetX; + } + if (offsetY) { + *offsetY = adGame->_sceneViewport->_offsetY; + } } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; + if (offsetX) { + *offsetX = 0; + } + if (offsetY) { + *offsetY = 0; + } } return STATUS_OK; } @@ -2365,14 +2562,26 @@ bool AdScene::getViewportOffset(int *offsetX, int *offsetY) { bool AdScene::getViewportSize(int *width, int *height) { AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { - if (width) *width = _viewport->getWidth(); - if (height) *height = _viewport->getHeight(); + if (width) { + *width = _viewport->getWidth(); + } + if (height) { + *height = _viewport->getHeight(); + } } else if (adGame->_sceneViewport && !_gameRef->_editorMode) { - if (width) *width = adGame->_sceneViewport->getWidth(); - if (height) *height = adGame->_sceneViewport->getHeight(); + if (width) { + *width = adGame->_sceneViewport->getWidth(); + } + if (height) { + *height = adGame->_sceneViewport->getHeight(); + } } else { - if (width) *width = _gameRef->_renderer->_width; - if (height) *height = _gameRef->_renderer->_height; + if (width) { + *width = _gameRef->_renderer->_width; + } + if (height) { + *height = _gameRef->_renderer->_height; + } } return STATUS_OK; } @@ -2472,11 +2681,15 @@ bool AdScene::loadState() { ////////////////////////////////////////////////////////////////////////// bool AdScene::persistState(bool saving) { - if (!_persistentState) return STATUS_OK; + if (!_persistentState) { + return STATUS_OK; + } AdGame *adGame = (AdGame *)_gameRef; AdSceneState *state = adGame->getSceneState(getFilename(), saving); - if (!state) return STATUS_OK; + if (!state) { + return STATUS_OK; + } AdNodeState *nodeState; @@ -2487,7 +2700,9 @@ bool AdScene::persistState(bool saving) { AdSceneNode *node = layer->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: - if (!node->_entity->_saveState) continue; + if (!node->_entity->_saveState) { + continue; + } nodeState = state->getNodeState(node->_entity->getName(), saving); if (nodeState) { nodeState->transferEntity(node->_entity, _persistentStateSprites, saving); @@ -2496,11 +2711,16 @@ bool AdScene::persistState(bool saving) { } break; case OBJECT_REGION: - if (!node->_region->_saveState) continue; + if (!node->_region->_saveState) { + continue; + } nodeState = state->getNodeState(node->_region->getName(), saving); if (nodeState) { - if (saving) nodeState->_active = node->_region->_active; - else node->_region->_active = nodeState->_active; + if (saving) { + nodeState->_active = node->_region->_active; + } else { + node->_region->_active = nodeState->_active; + } } break; default: @@ -2512,7 +2732,9 @@ bool AdScene::persistState(bool saving) { // free entities for (int i = 0; i < _objects.getSize(); i++) { - if (!_objects[i]->_saveState) continue; + if (!_objects[i]->_saveState) { + continue; + } if (_objects[i]->_type == OBJECT_ENTITY) { nodeState = state->getNodeState(_objects[i]->getName(), saving); if (nodeState) { @@ -2527,8 +2749,11 @@ bool AdScene::persistState(bool saving) { for (int i = 0; i < _waypointGroups.getSize(); i++) { nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving); if (nodeState) { - if (saving) nodeState->_active = _waypointGroups[i]->_active; - else _waypointGroups[i]->_active = nodeState->_active; + if (saving) { + nodeState->_active = _waypointGroups[i]->_active; + } else { + _waypointGroups[i]->_active = nodeState->_active; + } } } @@ -2544,14 +2769,17 @@ float AdScene::getRotationAt(int x, int y) { for (int i = 0; i < _rotLevels.getSize(); i++) { /* AdRotLevel *xxx = _rotLevels[i]; int j = _rotLevels.getSize();*/ - if (_rotLevels[i]->_posX < x) prev = _rotLevels[i]; - else { + if (_rotLevels[i]->_posX < x) { + prev = _rotLevels[i]; + } else { next = _rotLevels[i]; break; } } - if (prev == NULL || next == NULL) return 0; + if (prev == NULL || next == NULL) { + return 0; + } int delta_x = next->_posX - prev->_posX; float delta_rot = next->_rotation - prev->_rotation; @@ -2570,7 +2798,9 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { if (layer->_nodes[j]->_type == OBJECT_ENTITY) { AdEntity *ent = layer->_nodes[j]->_entity; - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + if (ent->_item && strcmp(ent->_item, itemName) == 0) { + ent->_active = show; + } } } } @@ -2578,7 +2808,9 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { AdEntity *ent = (AdEntity *)_objects[i]; - if (ent->_item && strcmp(ent->_item, itemName) == 0) ent->_active = show; + if (ent->_item && strcmp(ent->_item, itemName) == 0) { + ent->_active = show; + } } } @@ -2596,7 +2828,9 @@ bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) if (numUsed < numRegions - 1) { regionList[numUsed] = node->_region; numUsed++; - } else break; + } else { + break; + } } } } @@ -2618,13 +2852,17 @@ BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { BaseArray objects; getSceneObjects(objects, true); - if (objects.getSize() == 0) return NULL; - else { + if (objects.getSize() == 0) { + return NULL; + } else { if (currObject != NULL) { for (int i = 0; i < objects.getSize(); i++) { if (objects[i] == currObject) { - if (i < objects.getSize() - 1) return objects[i + 1]; - else break; + if (i < objects.getSize() - 1) { + return objects[i + 1]; + } else { + break; + } } } } @@ -2638,13 +2876,17 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { BaseArray objects; getSceneObjects(objects, true); - if (objects.getSize() == 0) return NULL; - else { + if (objects.getSize() == 0) { + return NULL; + } else { if (currObject != NULL) { for (int i = objects.getSize() - 1; i >= 0; i--) { if (objects[i] == currObject) { - if (i > 0) return objects[i - 1]; - else break; + if (i > 0) { + return objects[i - 1]; + } else { + break; + } } } } @@ -2658,7 +2900,9 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.getSize(); i++) { // close-up layer -> remove everything below it - if (interactiveOnly && _layers[i]->_closeUp) objects.removeAll(); + if (interactiveOnly && _layers[i]->_closeUp) { + objects.removeAll(); + } for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { @@ -2666,8 +2910,9 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i switch (node->_type) { case OBJECT_ENTITY: { AdEntity *ent = node->_entity; - if (ent->_active && (ent->_registrable || !interactiveOnly)) + if (ent->_active && (ent->_registrable || !interactiveOnly)) { objects.add(ent); + } } break; @@ -2682,7 +2927,9 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i break; } } - if (!found) objects.add(regionObj[newIndex]); + if (!found) { + objects.add(regionObj[newIndex]); + } } //if (RegionObj.getSize() > 0) Objects.Append(RegionObj); } @@ -2705,7 +2952,9 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i break; } } - if (!found) objects.add(regionObj[newIndex]); + if (!found) { + objects.add(regionObj[newIndex]); + } } @@ -2722,7 +2971,9 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray_objects.getSize(); i++) { obj = adGame->_objects[i]; if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; + if (interactiveOnly && !obj->_registrable) { + continue; + } objects.add(obj); } @@ -2732,7 +2983,9 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - if (interactiveOnly && !obj->_registrable) continue; + if (interactiveOnly && !obj->_registrable) { + continue; + } objects.add(obj); } diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 617f247241..8a223150f2 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -47,7 +47,9 @@ AdSceneState::~AdSceneState() { delete[] _filename; _filename = NULL; - for (int i = 0; i < _nodeStates.getSize(); i++) delete _nodeStates[i]; + for (int i = 0; i < _nodeStates.getSize(); i++) { + delete _nodeStates[i]; + } _nodeStates.removeAll(); } @@ -65,14 +67,18 @@ bool AdSceneState::persist(BasePersistenceManager *persistMgr) { void AdSceneState::setFilename(const char *filename) { delete[] _filename; _filename = new char [strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); + if (_filename) { + strcpy(_filename, filename); + } } ////////////////////////////////////////////////////////////////////////// AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { for (int i = 0; i < _nodeStates.getSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i]; + if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) { + return _nodeStates[i]; + } } if (saving) { @@ -81,7 +87,9 @@ AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { _nodeStates.add(ret); return ret; - } else return NULL; + } else { + return NULL; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index a011db3f02..d429c1fedf 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -91,19 +91,29 @@ AdSentence::~AdSentence() { ////////////////////////////////////////////////////////////////////////// void AdSentence::setText(const char *text) { - if (_text) delete[] _text; + if (_text) { + delete[] _text; + } _text = new char[strlen(text) + 1]; - if (_text) strcpy(_text, text); + if (_text) { + strcpy(_text, text); + } } ////////////////////////////////////////////////////////////////////////// void AdSentence::setStances(const char *stances) { - if (_stances) delete[] _stances; + if (_stances) { + delete[] _stances; + } if (stances) { _stances = new char[strlen(stances) + 1]; - if (_stances) strcpy(_stances, stances); - } else _stances = NULL; + if (_stances) { + strcpy(_stances, stances); + } + } else { + _stances = NULL; + } } @@ -122,36 +132,55 @@ char *AdSentence::getNextStance() { ////////////////////////////////////////////////////////////////////////// char *AdSentence::getStance(int stance) { - if (_stances == NULL) return NULL; + if (_stances == NULL) { + return NULL; + } - if (_tempStance) delete[] _tempStance; + if (_tempStance) { + delete[] _tempStance; + } _tempStance = NULL; char *start; char *curr; int pos; - if (stance == 0) start = _stances; - else { + if (stance == 0) { + start = _stances; + } else { pos = 0; start = NULL; curr = _stances; while (pos < stance) { - if (*curr == '\0') break; - if (*curr == ',') pos++; + if (*curr == '\0') { + break; + } + if (*curr == ',') { + pos++; + } curr++; } - if (pos == stance) start = curr; + if (pos == stance) { + start = curr; + } } - if (start == NULL) return NULL; + if (start == NULL) { + return NULL; + } - while (*start == ' ' && *start != ',' && *start != '\0') start++; + while (*start == ' ' && *start != ',' && *start != '\0') { + start++; + } curr = start; - while (*curr != '\0' && *curr != ',') curr++; + while (*curr != '\0' && *curr != ',') { + curr++; + } - while (curr > start && *(curr - 1) == ' ') curr--; + while (curr > start && *(curr - 1) == ' ') { + curr--; + } _tempStance = new char [curr - start + 1]; if (_tempStance) { @@ -165,7 +194,9 @@ char *AdSentence::getStance(int stance) { ////////////////////////////////////////////////////////////////////////// bool AdSentence::display() { - if (!_font || !_text) return STATUS_FAILED; + if (!_font || !_text) { + return STATUS_FAILED; + } if (_sound && !_soundStarted) { _sound->play(); @@ -195,7 +226,9 @@ bool AdSentence::display() { ////////////////////////////////////////////////////////////////////////// void AdSentence::setSound(BaseSound *sound) { - if (!sound) return; + if (!sound) { + return; + } delete _sound; _sound = sound; _soundStarted = false; @@ -204,7 +237,9 @@ void AdSentence::setSound(BaseSound *sound) { ////////////////////////////////////////////////////////////////////////// bool AdSentence::finish() { - if (_sound) _sound->stop(); + if (_sound) { + _sound->stop(); + } return STATUS_OK; } @@ -242,7 +277,9 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { _talkDef = NULL; _currentSprite = NULL; - if (!soundFilename) return STATUS_OK; + if (!soundFilename) { + return STATUS_OK; + } AnsiString path = PathUtil::getDirectoryName(soundFilename); @@ -250,8 +287,9 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - if (!_gameRef->_fileManager->hasFile(talkDefFileName)) - return STATUS_OK; // no talk def file found + if (!_gameRef->_fileManager->hasFile(talkDefFileName)) { + return STATUS_OK; // no talk def file found + } _talkDef = new AdTalkDef(_gameRef); if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { @@ -267,7 +305,9 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { ////////////////////////////////////////////////////////////////////////// bool AdSentence::update(TDirection dir) { - if (!_talkDef) return STATUS_OK; + if (!_talkDef) { + return STATUS_OK; + } uint32 currentTime; // if sound is available, synchronize with sound, otherwise use timer @@ -284,10 +324,14 @@ bool AdSentence::update(TDirection dir) { talkNodeFound = true; BaseSprite *newSprite = _talkDef->_nodes[i]->getSprite(dir); - if (newSprite != _currentSprite) newSprite->reset(); + if (newSprite != _currentSprite) { + newSprite->reset(); + } _currentSprite = newSprite; - if (!_talkDef->_nodes[i]->_playToEnd) break; + if (!_talkDef->_nodes[i]->_playToEnd) { + break; + } } } @@ -296,9 +340,13 @@ bool AdSentence::update(TDirection dir) { if (!talkNodeFound) { BaseSprite *newSprite = _talkDef->getDefaultSprite(dir); if (newSprite) { - if (newSprite != _currentSprite) newSprite->reset(); + if (newSprite != _currentSprite) { + newSprite->reset(); + } _currentSprite = newSprite; - } else _currentSprite = NULL; + } else { + _currentSprite = NULL; + } } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index fcbf9af4eb..42409988a5 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -41,8 +41,9 @@ IMPLEMENT_PERSISTENT(AdSpriteSet, false) AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner): BaseObject(inGame) { _owner = owner; - for (int i = 0; i < NUM_DIRECTIONS; i++) + for (int i = 0; i < NUM_DIRECTIONS; i++) { _sprites[i] = NULL; + } } @@ -67,7 +68,9 @@ bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType bool ret; - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename); + } delete[] buffer; @@ -90,7 +93,7 @@ TOKEN_DEF(TEMPLATE) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType CacheType) { +bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SPRITESET) TOKEN_TABLE(NAME) @@ -122,7 +125,9 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -133,64 +138,88 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC delete _sprites[DI_LEFT]; _sprites[DI_LEFT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_LEFT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_LEFT] = spr; + } break; case TOKEN_RIGHT: delete _sprites[DI_RIGHT]; _sprites[DI_RIGHT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_RIGHT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_RIGHT] = spr; + } break; case TOKEN_UP: delete _sprites[DI_UP]; _sprites[DI_UP] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UP] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_UP] = spr; + } break; case TOKEN_DOWN: delete _sprites[DI_DOWN]; _sprites[DI_DOWN] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWN] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_DOWN] = spr; + } break; case TOKEN_UP_LEFT: delete _sprites[DI_UPLEFT]; _sprites[DI_UPLEFT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPLEFT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_UPLEFT] = spr; + } break; case TOKEN_UP_RIGHT: delete _sprites[DI_UPRIGHT]; _sprites[DI_UPRIGHT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_UPRIGHT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_UPRIGHT] = spr; + } break; case TOKEN_DOWN_LEFT: delete _sprites[DI_DOWNLEFT]; _sprites[DI_DOWNLEFT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNLEFT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_DOWNLEFT] = spr; + } break; case TOKEN_DOWN_RIGHT: delete _sprites[DI_DOWNRIGHT]; _sprites[DI_DOWNRIGHT] = NULL; spr = new BaseSprite(_gameRef, _owner); - if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC; - else _sprites[DI_DOWNRIGHT] = spr; + if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { + cmd = PARSERR_GENERIC; + } else { + _sprites[DI_DOWNRIGHT] = spr; + } break; case TOKEN_EDITOR_PROPERTY: @@ -205,7 +234,9 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC if (cmd == PARSERR_GENERIC) { _gameRef->LOG(0, "Error loading SPRITESET definition"); - if (spr) delete spr; + if (spr) { + delete spr; + } return STATUS_FAILED; } @@ -230,8 +261,12 @@ bool AdSpriteSet::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// BaseSprite *AdSpriteSet::getSprite(TDirection direction) { int dir = (int)direction; - if (dir < 0) dir = 0; - if (dir >= NUM_DIRECTIONS) dir = NUM_DIRECTIONS - 1; + if (dir < 0) { + dir = 0; + } + if (dir >= NUM_DIRECTIONS) { + dir = NUM_DIRECTIONS - 1; + } BaseSprite *ret = NULL; @@ -247,8 +282,11 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) { for (int i = dir; i < NUM_DIRECTIONS; i++) { if (_sprites[i] != NULL) { - if (ret == NULL || numSteps > i - dir) return _sprites[i]; - else return ret; + if (ret == NULL || numSteps > i - dir) { + return _sprites[i]; + } else { + return ret; + } } } @@ -260,7 +298,9 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) { ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITESET {\n"); - if (getName()) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + if (getName()) { + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + } for (int i = 0; i < NUM_DIRECTIONS; i++) { if (_sprites[i]) { switch (i) { @@ -301,10 +341,14 @@ bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::containsSprite(BaseSprite *sprite) { - if (!sprite) return false; + if (!sprite) { + return false; + } for (int i = 0; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] == sprite) return true; + if (_sprites[i] == sprite) { + return true; + } } return false; } diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 2b0c6c6c1b..fc057ba183 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -52,7 +52,9 @@ AdTalkDef::AdTalkDef(BaseGame *inGame): BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdTalkDef::~AdTalkDef() { - for (int i = 0; i < _nodes.getSize(); i++) delete _nodes[i]; + for (int i = 0; i < _nodes.getSize(); i++) { + delete _nodes[i]; + } _nodes.removeAll(); delete[] _defaultSpriteFilename; @@ -79,7 +81,9 @@ bool AdTalkDef::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing TALK file '%s'", filename); + } delete[] buffer; @@ -123,15 +127,18 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_ACTION: { - AdTalkNode *Node = new AdTalkNode(_gameRef); - if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node); - else { - delete Node; - Node = NULL; + AdTalkNode *node = new AdTalkNode(_gameRef); + if (node && DID_SUCCEED(node->loadBuffer(params, false))) { + _nodes.add(node); + } else { + delete node; + node = NULL; cmd = PARSERR_GENERIC; } } @@ -179,12 +186,16 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { if (_defaultSpriteFilename) { _defaultSprite = new BaseSprite(_gameRef); - if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED; + if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { + return STATUS_FAILED; + } } if (_defaultSpriteSetFilename) { _defaultSpriteSet = new AdSpriteSet(_gameRef); - if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED; + if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { + return STATUS_FAILED; + } } @@ -211,10 +222,15 @@ bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdTalkDef::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TALK {\n"); - if (_defaultSpriteFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + if (_defaultSpriteFilename) { + buffer->putTextIndent(indent + 2, "DEFAULT_SPRITE=\"%s\"\n", _defaultSpriteFilename); + } - if (_defaultSpriteSetFilename) buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); - else if (_defaultSpriteSet) _defaultSpriteSet->saveAsText(buffer, indent + 2); + if (_defaultSpriteSetFilename) { + buffer->putTextIndent(indent + 2, "DEFAULT_SPRITESET_FILE=\"%s\"\n", _defaultSpriteSetFilename); + } else if (_defaultSpriteSet) { + _defaultSpriteSet->saveAsText(buffer, indent + 2); + } for (int i = 0; i < _nodes.getSize(); i++) { _nodes[i]->saveAsText(buffer, indent + 2); @@ -236,24 +252,34 @@ bool AdTalkDef::loadDefaultSprite() { delete _defaultSprite; _defaultSprite = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } else if (_defaultSpriteSetFilename && !_defaultSpriteSet) { _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; _defaultSpriteSet = NULL; return STATUS_FAILED; - } else return STATUS_OK; - } else return STATUS_OK; + } else { + return STATUS_OK; + } + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// BaseSprite *AdTalkDef::getDefaultSprite(TDirection dir) { loadDefaultSprite(); - if (_defaultSprite) return _defaultSprite; - else if (_defaultSpriteSet) return _defaultSpriteSet->getSprite(dir); - else return NULL; + if (_defaultSprite) { + return _defaultSprite; + } else if (_defaultSpriteSet) { + return _defaultSpriteSet->getSprite(dir); + } else { + return NULL; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index d47cbb446e..90435d7977 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -52,12 +52,14 @@ AdTalkHolder::~AdTalkHolder() { delete _sprite; _sprite = NULL; - for (int i = 0; i < _talkSprites.getSize(); i++) + for (int i = 0; i < _talkSprites.getSize(); i++) { delete _talkSprites[i]; + } _talkSprites.removeAll(); - for (int i = 0; i < _talkSpritesEx.getSize(); i++) + for (int i = 0; i < _talkSpritesEx.getSize(); i++) { delete _talkSpritesEx[i]; + } _talkSpritesEx.removeAll(); } @@ -77,7 +79,9 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; _animSprite = NULL; - } else return _animSprite; + } else { + return _animSprite; + } } } @@ -103,8 +107,9 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.getSize() < 1) ret = _sprite; - else { + if (_talkSprites.getSize() < 1) { + ret = _sprite; + } else { // TODO: remember last int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]; @@ -128,14 +133,18 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ScValue *val = stack->pop(); bool setCurrent = false; - if (_currentSprite && _currentSprite == _sprite) setCurrent = true; + if (_currentSprite && _currentSprite == _sprite) { + setCurrent = true; + } delete _sprite; _sprite = NULL; if (val->isNULL()) { _sprite = NULL; - if (setCurrent) _currentSprite = NULL; + if (setCurrent) { + _currentSprite = NULL; + } stack->pushBool(true); } else { const char *filename = val->getString(); @@ -145,7 +154,9 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS stack->pushBool(false); } else { _sprite = spr; - if (setCurrent) _currentSprite = _sprite; + if (setCurrent) { + _currentSprite = _sprite; + } stack->pushBool(true); } } @@ -158,8 +169,11 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS else if (strcmp(name, "GetSprite") == 0) { stack->correctParams(0); - if (!_sprite || !_sprite->getFilename()) stack->pushNULL(); - else stack->pushString(_sprite->getFilename()); + if (!_sprite || !_sprite->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_sprite->getFilename()); + } return STATUS_OK; } @@ -169,8 +183,11 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS else if (strcmp(name, "GetSpriteObject") == 0) { stack->correctParams(0); - if (!_sprite) stack->pushNULL(); - else stack->pushNative(_sprite, true); + if (!_sprite) { + stack->pushNULL(); + } else { + stack->pushNative(_sprite, true); + } return STATUS_OK; } @@ -181,15 +198,18 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS stack->correctParams(2); const char *filename = stack->pop()->getString(); - bool Ex = stack->pop()->getBool(); + bool ex = stack->pop()->getBool(); BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); script->runtimeError("AddTalkSprite method failed for file '%s'", filename); } else { - if (Ex) _talkSpritesEx.add(spr); - else _talkSprites.add(spr); + if (ex) { + _talkSpritesEx.add(spr); + } else { + _talkSprites.add(spr); + } stack->pushBool(true); } return STATUS_OK; @@ -210,10 +230,12 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS if (ex) { for (int i = 0; i < _talkSpritesEx.getSize(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getFilename(), filename) == 0) { - if (_currentSprite == _talkSpritesEx[i]) + if (_currentSprite == _talkSpritesEx[i]) { setCurrent = true; - if (_tempSprite2 == _talkSpritesEx[i]) + } + if (_tempSprite2 == _talkSpritesEx[i]) { setTemp2 = true; + } delete _talkSpritesEx[i]; _talkSpritesEx.removeAt(i); break; @@ -222,10 +244,12 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } else { for (int i = 0; i < _talkSprites.getSize(); i++) { if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { - if (_currentSprite == _talkSprites[i]) + if (_currentSprite == _talkSprites[i]) { setCurrent = true; - if (_tempSprite2 == _talkSprites[i]) + } + if (_tempSprite2 == _talkSprites[i]) { setTemp2 = true; + } delete _talkSprites[i]; _talkSprites.removeAt(i); break; @@ -235,10 +259,12 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } stack->pushBool(true); - if (setCurrent) + if (setCurrent) { _currentSprite = _sprite; - if (setTemp2) + } + if (setTemp2) { _tempSprite2 = _sprite; + } return STATUS_OK; } @@ -263,38 +289,47 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS // delete current if (ex) { for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i] == _currentSprite) + if (_talkSpritesEx[i] == _currentSprite) { setCurrent = true; - if (_talkSpritesEx[i] == _tempSprite2) + } + if (_talkSpritesEx[i] == _tempSprite2) { setTemp2 = true; + } delete _talkSpritesEx[i]; } _talkSpritesEx.removeAll(); } else { for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i] == _currentSprite) setCurrent = true; - if (_talkSprites[i] == _tempSprite2) setTemp2 = true; + if (_talkSprites[i] == _currentSprite) { + setCurrent = true; + } + if (_talkSprites[i] == _tempSprite2) { + setTemp2 = true; + } delete _talkSprites[i]; } _talkSprites.removeAll(); } // set new - if (ex) + if (ex) { _talkSpritesEx.add(spr); - else + } else { _talkSprites.add(spr); + } stack->pushBool(true); - if (setCurrent) + if (setCurrent) { _currentSprite = spr; - if (setTemp2) + } + if (setTemp2) { _tempSprite2 = spr; + } } return STATUS_OK; + } else { + return AdObject::scCallMethod(script, stack, thisStack, name); } - - else return AdObject::scCallMethod(script, stack, thisStack, name); } @@ -308,9 +343,9 @@ ScValue *AdTalkHolder::scGetProperty(const char *name) { if (strcmp(name, "Type") == 0) { _scValue->setString("talk-holder"); return _scValue; + } else { + return AdObject::scGetProperty(name); } - - else return AdObject::scGetProperty(name); } @@ -338,13 +373,15 @@ const char *AdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { for (int i = 0; i < _talkSprites.getSize(); i++) { - if (_talkSprites[i]->getFilename()) + if (_talkSprites[i]->getFilename()) { buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->getFilename()); + } } for (int i = 0; i < _talkSpritesEx.getSize(); i++) { - if (_talkSpritesEx[i]->getFilename()) + if (_talkSpritesEx[i]->getFilename()) { buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->getFilename()); + } } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index 306825c439..ef30290b8c 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -142,7 +142,9 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_COMMENT: - if (_gameRef->_editorMode) BaseUtils::setString(&_comment, (char *)params); + if (_gameRef->_editorMode) { + BaseUtils::setString(&_comment, (char *)params); + } break; case TOKEN_EDITOR_PROPERTY: @@ -160,23 +162,26 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { return STATUS_FAILED; } - if (_endTime == 0) + if (_endTime == 0) { _playToEnd = true; - else + } else { _playToEnd = false; + } if (_preCache && _spriteFilename) { delete _sprite; _sprite = new BaseSprite(_gameRef); - if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) + if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { return STATUS_FAILED; + } } if (_preCache && _spriteSetFilename) { delete _spriteSet; _spriteSet = new AdSpriteSet(_gameRef); - if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) + if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { return STATUS_FAILED; + } } return STATUS_OK; @@ -202,13 +207,24 @@ bool AdTalkNode::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdTalkNode::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "ACTION {\n"); - if (_comment) buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); + if (_comment) { + buffer->putTextIndent(indent + 2, "COMMENT=\"%s\"\n", _comment); + } buffer->putTextIndent(indent + 2, "START_TIME=%d\n", _startTime); - if (!_playToEnd) buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); - if (_spriteFilename) buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); - if (_spriteSetFilename) buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); - else if (_spriteSet) _spriteSet->saveAsText(buffer, indent + 2); - if (_preCache) buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + if (!_playToEnd) { + buffer->putTextIndent(indent + 2, "END_TIME=%d\n", _endTime); + } + if (_spriteFilename) { + buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _spriteFilename); + } + if (_spriteSetFilename) { + buffer->putTextIndent(indent + 2, "SPRITESET_FILE=\"%s\"\n", _spriteSetFilename); + } else if (_spriteSet) { + _spriteSet->saveAsText(buffer, indent + 2); + } + if (_preCache) { + buffer->putTextIndent(indent + 2, "PRECACHE=\"%s\"\n", _preCache ? "TRUE" : "FALSE"); + } BaseClass::saveAsText(buffer, indent + 2); @@ -226,19 +242,21 @@ bool AdTalkNode::loadSprite() { delete _sprite; _sprite = NULL; return STATUS_FAILED; - } else return STATUS_OK; - } - - else if (_spriteSetFilename && !_spriteSet) { + } else { + return STATUS_OK; + } + } else if (_spriteSetFilename && !_spriteSet) { _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; _spriteSet = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } + } else { + return STATUS_OK; } - - else return STATUS_OK; } @@ -246,20 +264,32 @@ bool AdTalkNode::loadSprite() { bool AdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { if (time >= _startTime) { if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) return true; - else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) return true; - else return false; - } else return _endTime >= time; - } else return false; + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) { + return true; + } else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) { + return true; + } else { + return false; + } + } else { + return _endTime >= time; + } + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// BaseSprite *AdTalkNode::getSprite(TDirection dir) { loadSprite(); - if (_sprite) return _sprite; - else if (_spriteSet) return _spriteSet->getSprite(dir); - else return NULL; + if (_sprite) { + return _sprite; + } else if (_spriteSet) { + return _spriteSet->getSprite(dir); + } else { + return NULL; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 7e5d8d29c6..bb1e9275f5 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -56,8 +56,9 @@ AdWaypointGroup::~AdWaypointGroup() { ////////////////////////////////////////////////////////////////////////// void AdWaypointGroup::cleanup() { - for (int i = 0; i < _points.getSize(); i++) + for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; + } _points.removeAll(); _editorSelectedPoint = -1; } @@ -75,7 +76,9 @@ bool AdWaypointGroup::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename); + } delete[] buffer; @@ -122,7 +125,9 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -169,8 +174,9 @@ bool AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - if (_scProp) + if (_scProp) { _scProp->saveAsText(buffer, indent + 2); + } BaseClass::saveAsText(buffer, indent + 2); for (int i = 0; i < _points.getSize(); i++) { @@ -217,9 +223,9 @@ ScValue *AdWaypointGroup::scGetProperty(const char *name) { else if (strcmp(name, "Active") == 0) { _scValue->setBool(_active); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -233,13 +239,17 @@ bool AdWaypointGroup::scSetProperty(const char *name, ScValue *value) { return STATUS_OK; } - else return BaseObject::scSetProperty(name, value); + else { + return BaseObject::scSetProperty(name, value); + } } ////////////////////////////////////////////////////////////////////////// bool AdWaypointGroup::mimic(AdWaypointGroup *wpt, float scale, int argX, int argY) { - if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) return STATUS_OK; + if (scale == _lastMimicScale && argX == _lastMimicX && argY == _lastMimicY) { + return STATUS_OK; + } cleanup(); diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index b81261cdaf..687d2d52e6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -56,16 +56,19 @@ BaseClass::~BaseClass() { ////////////////////////////////////////////////////////////////////////// const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) + if (_editorPropsIter != _editorProps.end()) { return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return initVal; + } else { + return initVal; + } } ////////////////////////////////////////////////////////////////////////// bool BaseClass::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return STATUS_FAILED; + if (propName == NULL) { + return STATUS_FAILED; + } if (propValue == NULL) { _editorProps.erase(propName); @@ -91,8 +94,9 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_END - if (!_gameRef->_editorMode) + if (!_gameRef->_editorMode) { return STATUS_OK; + } byte *params; @@ -115,15 +119,21 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { case TOKEN_NAME: delete[] propName; propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; case TOKEN_VALUE: delete[] propValue; propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; } diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 0283ee274e..0756d10698 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -97,8 +97,12 @@ void BaseActiveRect::clipRect() { rc.bottom -= Rend->_drawOffsetY; } - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + if (rc.left > _rect.left) { + _offsetX = rc.left - _rect.left; + } + if (rc.top > _rect.top) { + _offsetY = rc.top - _rect.top; + } BasePlatform::intersectRect(&_rect, &_rect, &rc); } diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 8d6f88c9fe..a61227b0dc 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -53,7 +53,9 @@ BaseDynamicBuffer::~BaseDynamicBuffer() { ////////////////////////////////////////////////////////////////////////// void BaseDynamicBuffer::cleanup() { - if (_buffer) free(_buffer); + if (_buffer) { + free(_buffer); + } _buffer = NULL; _size = 0; _realSize = 0; @@ -72,7 +74,9 @@ uint32 BaseDynamicBuffer::getSize() { bool BaseDynamicBuffer::init(uint32 initSize) { cleanup(); - if (initSize == 0) initSize = _initSize; + if (initSize == 0) { + initSize = _initSize; + } _buffer = (byte *)malloc(initSize); if (!_buffer) { @@ -89,7 +93,9 @@ bool BaseDynamicBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); + if (!_initialized) { + init(); + } while (_offset + size > _realSize) { _realSize += _growBy; @@ -110,7 +116,9 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); + if (!_initialized) { + init(); + } if (_offset + size > _size) { _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); @@ -140,8 +148,9 @@ uint32 BaseDynamicBuffer::getDWORD() { ////////////////////////////////////////////////////////////////////////// void BaseDynamicBuffer::putString(const char *val) { - if (!val) putString("(null)"); - else { + if (!val) { + putString("(null)"); + } else { putDWORD(strlen(val) + 1); putBytes((byte *)val, strlen(val) + 1); } @@ -154,8 +163,11 @@ char *BaseDynamicBuffer::getString() { char *ret = (char *)(_buffer + _offset); _offset += len; - if (!strcmp(ret, "(null)")) return NULL; - else return ret; + if (!strcmp(ret, "(null)")) { + return NULL; + } else { + return ret; + } } diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 10818abfb9..04fde5457c 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -59,23 +59,31 @@ BaseFader::~BaseFader() { ////////////////////////////////////////////////////////////////////////// bool BaseFader::update() { - if (!_active) return STATUS_OK; + if (!_active) { + return STATUS_OK; + } int alphaDelta = _targetAlpha - _sourceAlpha; uint32 time; - if (_system) time = g_system->getMillis() - _startTime; - else time = _gameRef->_timer - _startTime; + if (_system) { + time = g_system->getMillis() - _startTime; + } else { + time = _gameRef->_timer - _startTime; + } - if (time >= _duration) _currentAlpha = _targetAlpha; - else { + if (time >= _duration) { + _currentAlpha = _targetAlpha; + } else { _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); } _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; + if (_ready && _currentAlpha == 0x00) { + _active = false; + } return STATUS_OK; } @@ -83,10 +91,13 @@ bool BaseFader::update() { ////////////////////////////////////////////////////////////////////////// bool BaseFader::display() { - if (!_active) return STATUS_OK; + if (!_active) { + return STATUS_OK; + } - if (_currentAlpha > 0x00) + if (_currentAlpha > 0x00) { _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + } return STATUS_OK; } @@ -114,8 +125,11 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = g_system->getMillis(); - else _startTime = _gameRef->_timer; + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } return STATUS_OK; } @@ -137,8 +151,11 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = g_system->getMillis(); - else _startTime = _gameRef->_timer; + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } return STATUS_OK; @@ -167,7 +184,9 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_targetAlpha)); persistMgr->transfer(TMEMBER(_system)); - if (_system && !persistMgr->getIsSaving()) _startTime = 0; + if (_system && !persistMgr->getIsSaving()) { + _startTime = 0; + } return STATUS_OK; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index c296f88699..ff693e055c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -86,8 +86,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { - if (mustExist) + if (mustExist) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); + } return NULL; } @@ -106,7 +107,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz }; buffer[file->size()] = '\0'; - if (size != NULL) *size = file->size(); + if (size != NULL) { + *size = file->size(); + } closeFile(file); return buffer; @@ -114,8 +117,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (!path.exists()) + if (!path.exists()) { return STATUS_FAILED; + } switch (type) { case PATH_SINGLE: @@ -141,8 +145,9 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!_gameRef) // This function only works when the game-registry is loaded + if (!_gameRef) { // This function only works when the game-registry is loaded return STATUS_FAILED; + } AnsiString pathList; @@ -210,15 +215,17 @@ bool BaseFileManager::registerPackages() { warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { - if (!fileIt->getName().hasSuffix(".dcp")) + if (!fileIt->getName().hasSuffix(".dcp")) { continue; + } // Avoid registering all the language files // TODO: Select based on the gameDesc. if (fileIt->getParent().getName() == "language") { Common::String parentName = fileIt->getParent().getName(); Common::String dcpName = fileIt->getName(); - if (fileIt->getName() != "english.dcp") + if (fileIt->getName() != "english.dcp") { continue; + } } warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); @@ -247,8 +254,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f // correct slashes for (int32 i = 0; i < upcName.size(); i++) { - if (upcName[i] == '/') + if (upcName[i] == '/') { upcName.setChar('\\', (uint32)i); + } } Common::ArchiveMemberPtr entry = _packages.getMember(upcName); file = entry->createReadStream(); @@ -256,23 +264,29 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } bool BaseFileManager::hasFile(const Common::String &filename) { - if (diskFileExists(filename)) + if (diskFileExists(filename)) { return true; - if (_packages.hasFile(filename)) - return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. - if (BaseResources::hasFile(filename)) + } + if (_packages.hasFile(filename)) { + return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. + } + if (BaseResources::hasFile(filename)) { return true; + } return false; } ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) + if (strcmp(filename.c_str(), "") == 0) { return NULL; + } debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.push_back(file); + if (file && keepTrackOf) { + _openFiles.push_back(file); + } return file; } @@ -295,8 +309,9 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!_gameRef) + if (!_gameRef) { error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); + } BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); @@ -306,16 +321,19 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f } ret = openDiskFile(filename); - if (ret) + if (ret) { return ret; + } ret = openPkgFile(filename); - if (ret) + if (ret) { return ret; + } ret = BaseResources::getFile(filename); - if (ret) + if (ret) { return ret; + } warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 67edccd041..68b866bbf5 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,8 +61,9 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) + for (int i = 0; i < _subframes.getSize(); i++) { delete _subframes[i]; + } _subframes.removeAll(); for (int i = 0; i < _applyEvent.getSize(); i++) { @@ -79,7 +80,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float for (int i = 0; i < _subframes.getSize(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } } return STATUS_OK; } @@ -88,7 +91,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float ////////////////////////////////////////////////////////////////////////// bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { if (_sound && !muted) { - if (owner) owner->updateOneSound(_sound); + if (owner) { + owner->updateOneSound(_sound); + } _sound->play(); /* if (_gameRef->_state == GAME_FROZEN) { @@ -240,7 +245,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; - } else _subframes.add(subframe); + } else { + _subframes.add(subframe); + } } break; @@ -251,7 +258,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + if (_gameRef->_soundMgr->_soundAvailable) { + _gameRef->LOG(0, "Error loading sound '%s'.", params); + } delete _sound; _sound = NULL; } @@ -291,8 +300,11 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (surface_file != NULL) { - if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + if (custoTrans) { + sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + } else { + sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + } if (!sub->_surface) { delete sub; @@ -301,11 +313,16 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + if (custoTrans) { + sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } } - if (BasePlatform::isRectEmpty(&rect)) sub->setDefaultRect(); - else sub->_rect = rect; + if (BasePlatform::isRectEmpty(&rect)) { + sub->setDefaultRect(); + } else { + sub->_rect = rect; + } sub->_hotspotX = hotspotX; sub->_hotspotY = hotspotY; @@ -325,7 +342,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } BasePlatform::setRectEmpty(rect); Rect32 subRect; @@ -344,21 +363,27 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - if (_moveX != 0 || _moveY != 0) + if (_moveX != 0 || _moveY != 0) { buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + } - if (_sound && _sound->_soundFilename) + if (_sound && _sound->_soundFilename) { buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + } buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - if (_killSound) + if (_killSound) { buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + } - if (_editorExpanded) + if (_editorExpanded) { buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + } - if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + if (_subframes.getSize() > 0) { + _subframes[0]->saveAsText(buffer, indent, false); + } for (int i = 1; i < _subframes.getSize(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); @@ -406,8 +431,11 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSound") == 0) { stack->correctParams(0); - if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); - else stack->pushNULL(); + if (_sound && _sound->_soundFilename) { + stack->pushString(_sound->_soundFilename); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -426,8 +454,12 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac stack->pushBool(false); delete _sound; _sound = NULL; - } else stack->pushBool(true); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -440,7 +472,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); - } else stack->pushNative(_subframes[index], true); + } else { + stack->pushNative(_subframes[index], true); + } return STATUS_OK; } @@ -477,7 +511,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac stack->correctParams(1); ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { @@ -496,19 +532,26 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "InsertSubframe") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) index = 0; + if (index < 0) { + index = 0; + } ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); } - if (index >= _subframes.getSize()) _subframes.add(sub); - else _subframes.insertAt(index, sub); + if (index >= _subframes.getSize()) { + _subframes.add(sub); + } else { + _subframes.insertAt(index, sub); + } stack->pushNative(sub, true); return STATUS_OK; @@ -523,7 +566,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index < 0 || index >= _applyEvent.getSize()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); - } else stack->pushString(_applyEvent[index]); + } else { + stack->pushString(_applyEvent[index]); + } return STATUS_OK; } @@ -563,15 +608,20 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); + if (_subframes.getSize() == 1) { + return _subframes[0]->scCallMethod(script, stack, thisStack, name); + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } } } ////////////////////////////////////////////////////////////////////////// ScValue *BaseFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new ScValue(_gameRef); + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -640,8 +690,11 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return BaseScriptable::scGetProperty(name); + if (_subframes.getSize() == 1) { + return _subframes[0]->scGetProperty(name); + } else { + return BaseScriptable::scGetProperty(name); + } } } @@ -690,8 +743,11 @@ bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return BaseScriptable::scSetProperty(name, value); + if (_subframes.getSize() == 1) { + return _subframes[0]->scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } } } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b2b92d6de4..9de183660e 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -390,7 +390,9 @@ bool BaseGame::cleanup() { _fontStorage->removeFont(_videoFont); _videoFont = NULL; - for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + for (int i = 0; i < _quickMessages.getSize(); i++) { + delete _quickMessages[i]; + } _quickMessages.removeAll(); _viewportStack.removeAll(); @@ -417,48 +419,59 @@ bool BaseGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { _surfaceStorage = new BaseSurfaceStorage(this); - if (_surfaceStorage == NULL) + if (_surfaceStorage == NULL) { break; + } _fontStorage = new BaseFontStorage(this); - if (_fontStorage == NULL) + if (_fontStorage == NULL) { break; + } _fileManager = new BaseFileManager(this); - if (_fileManager == NULL) + if (_fileManager == NULL) { break; + } _soundMgr = new BaseSoundMgr(this); - if (_soundMgr == NULL) + if (_soundMgr == NULL) { break; + } _debugMgr = new BaseDebugger(this); - if (_debugMgr == NULL) + if (_debugMgr == NULL) { break; + } _mathClass = new SXMath(this); - if (_mathClass == NULL) + if (_mathClass == NULL) { break; + } _scEngine = new ScEngine(this); - if (_scEngine == NULL) + if (_scEngine == NULL) { break; + } _videoPlayer = new VideoPlayer(this); - if (_videoPlayer == NULL) + if (_videoPlayer == NULL) { break; + } _transMgr = new BaseTransitionMgr(this); - if (_transMgr == NULL) + if (_transMgr == NULL) { break; + } _keyboardState = new BaseKeyboardState(this); - if (_keyboardState == NULL) + if (_keyboardState == NULL) { break; + } _fader = new BaseFader(this); - if (_fader == NULL) + if (_fader == NULL) { break; + } registerObject(_fader); loaded = true; @@ -484,7 +497,9 @@ bool BaseGame::initialize1() { ////////////////////////////////////////////////////////////////////// bool BaseGame::initialize2() { // we know whether we are going to be accelerated _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) return STATUS_FAILED; + if (_renderer == NULL) { + return STATUS_FAILED; + } return STATUS_OK; } @@ -495,9 +510,15 @@ bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + if (_indicatorY == -1) { + _indicatorY = _renderer->_height - _indicatorHeight; + } + if (_indicatorX == -1) { + _indicatorX = 0; + } + if (_indicatorWidth == -1) { + _indicatorWidth = _renderer->_width; + } return STATUS_OK; } @@ -567,7 +588,9 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } - if (_debugMgr) _debugMgr->onLog(res, buff); + if (_debugMgr) { + _debugMgr->onLog(res, buff); + } debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); @@ -615,7 +638,9 @@ bool BaseGame::initLoop() { _timerDelta = _timer - _timerLast; _timerLast = _timer; _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; + } else { + _timerDelta = 0; + } _framesRendered++; if (_fpsTime > 1000) { @@ -637,7 +662,9 @@ bool BaseGame::initLoop() { updateSounds(); - if (_fader) _fader->update(); + if (_fader) { + _fader->update(); + } return STATUS_OK; } @@ -663,8 +690,12 @@ void BaseGame::setOffset(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// void BaseGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) *offsetX = _offsetX; - if (offsetY != NULL) *offsetY = _offsetY; + if (offsetX != NULL) { + *offsetX = _offsetX; + } + if (offsetY != NULL) { + *offsetY = _offsetY; + } } @@ -680,7 +711,9 @@ bool BaseGame::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + } delete[] buffer; @@ -789,7 +822,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -801,14 +836,18 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->removeFont(_systemFont); + if (_systemFont) { + _fontStorage->removeFont(_systemFont); + } _systemFont = NULL; _systemFont = _gameRef->_fontStorage->addFont((char *)params); break; case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->removeFont(_videoFont); + if (_videoFont) { + _fontStorage->removeFont(_videoFont); + } _videoFont = NULL; _videoFont = _gameRef->_fontStorage->addFont((char *)params); @@ -939,7 +978,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } } - if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + if (!_systemFont) { + _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + } if (cmd == PARSERR_TOKENNOTFOUND) { @@ -994,10 +1035,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "RunScript") == 0) { _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) + if (DID_FAIL(addScript(stack->pop()->getString()))) { stack->pushBool(false); - else + } else { stack->pushBool(true); + } return STATUS_OK; } @@ -1008,16 +1050,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "LoadStringTable") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); bool ClearOld; - if (Val->isNULL()) ClearOld = true; - else ClearOld = Val->getBool(); + if (val->isNULL()) { + ClearOld = true; + } else { + ClearOld = val->getBool(); + } - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) { stack->pushBool(false); - else + } else { stack->pushBool(true); + } return STATUS_OK; } @@ -1028,8 +1074,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *) obj)) stack->pushBool(true); - else stack->pushBool(false); + if (validObject((BaseObject *) obj)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1054,7 +1103,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); BaseObject *obj = (BaseObject *)val->getNative(); unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } stack->pushNULL(); return STATUS_OK; @@ -1097,8 +1148,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); - else { + if (strcmp(name, "PlayMusic") == 0) { + stack->correctParams(3); + } else { stack->correctParams(4); channel = stack->pop()->getInt(); } @@ -1111,8 +1163,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1122,14 +1177,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "StopMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(stopMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1139,14 +1198,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "PauseMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(pauseMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1155,14 +1218,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "ResumeMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(resumeMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1171,15 +1238,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); - else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); - else stack->pushString(_music[channel]->_soundFilename); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { + stack->pushNULL(); + } else { + if (!_music[channel] || !_music[channel]->_soundFilename) { + stack->pushNULL(); + } else { + stack->pushString(_music[channel]->_soundFilename); + } } return STATUS_OK; } @@ -1189,16 +1261,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); - else { + if (strcmp(name, "SetMusicPosition") == 0) { + stack->correctParams(1); + } else { stack->correctParams(2); channel = stack->pop()->getInt(); } uint32 time = stack->pop()->getInt(); - if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setMusicStartTime(channel, time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1208,14 +1284,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusicPosition") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getPositionTime()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getPositionTime()); + } return STATUS_OK; } @@ -1224,14 +1304,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); - else { + if (strcmp(name, "IsMusicPlaying") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else stack->pushBool(_music[channel]->isPlaying()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + stack->pushBool(_music[channel]->isPlaying()); + } return STATUS_OK; } @@ -1240,17 +1324,22 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); - else { + if (strcmp(name, "SetMusicVolume") == 0) { + stack->correctParams(1); + } else { stack->correctParams(2); channel = stack->pop()->getInt(); } int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); - else stack->pushBool(true); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } } return STATUS_OK; } @@ -1260,14 +1349,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusicVolume") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolumePercent()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getVolumePercent()); + } return STATUS_OK; } @@ -1350,8 +1443,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int right = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - if (right < left) BaseUtils::swap(&left, &right); - if (bottom < top) BaseUtils::swap(&top, &bottom); + if (right < left) { + BaseUtils::swap(&left, &right); + } + if (bottom < top) { + BaseUtils::swap(&top, &bottom); + } BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); @@ -1376,26 +1473,34 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); warning("PlayVideo: %s - not implemented yet", filename); ScValue *valType = stack->pop(); - int Type; - if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); + int type; + if (valType->isNULL()) { + type = (int)VID_PLAY_STRETCH; + } else { + type = valType->getInt(); + } int xVal = stack->pop()->getInt(); int yVal = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); + bool freezeMusic = stack->pop()->getBool(true); ScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) - Type = (int)VID_PLAY_STRETCH; + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, subtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)type, xVal, yVal, freezeMusic))) { stack->pushBool(true); script->sleep(0); - } else stack->pushBool(false); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1414,9 +1519,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); ScValue *valType = stack->pop(); int type; - if (valType->isNULL()) + if (valType->isNULL()) { type = (int)VID_PLAY_STRETCH; - else type = valType->getInt(); + } else { + type = valType->getInt(); + } int xVal = stack->pop()->getInt(); int yVal = stack->pop()->getInt(); @@ -1426,7 +1533,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } delete _theoraPlayer; _theoraPlayer = new VideoTheoraPlayer(this); @@ -1435,7 +1544,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); script->sleep(0); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } } else { stack->pushBool(false); delete _theoraPlayer; @@ -1649,8 +1760,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetActiveCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1660,8 +1774,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursor") == 0) { stack->correctParams(0); - if (!_activeCursor || !_activeCursor->getFilename()) stack->pushNULL(); - else stack->pushString(_activeCursor->getFilename()); + if (!_activeCursor || !_activeCursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_activeCursor->getFilename()); + } return STATUS_OK; } @@ -1671,8 +1788,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursorObject") == 0) { stack->correctParams(0); - if (!_activeCursor) stack->pushNULL(); - else stack->pushNative(_activeCursor, true); + if (!_activeCursor) { + stack->pushNULL(); + } else { + stack->pushNative(_activeCursor, true); + } return STATUS_OK; } @@ -1695,8 +1815,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "HasActiveCursor") == 0) { stack->correctParams(0); - if (_activeCursor) stack->pushBool(true); - else stack->pushBool(false); + if (_activeCursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1710,8 +1833,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // TODO: Replace with fileExists Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) stack->pushBool(false); - else { + if (!file) { + stack->pushBool(false); + } else { _fileManager->closeFile(file); stack->pushBool(true); } @@ -1732,7 +1856,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1752,7 +1878,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1774,15 +1902,16 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); char filename[MAX_PATH_LENGTH]; - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int fileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum); - if (!Common::File::exists(filename)) + sprintf(filename, "%s%03d.bmp", val->isNULL() ? getName() : val->getString(), fileNum); + if (!Common::File::exists(filename)) { break; + } fileNum++; } @@ -1791,7 +1920,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (image) { ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; - } else ret = false; + } else { + ret = false; + } stack->pushBool(ret); return STATUS_OK; @@ -1810,9 +1941,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + if (ret) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + } delete image; - } else ret = false; + } else { + ret = false; + } stack->pushBool(ret); return STATUS_OK; @@ -1828,7 +1963,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack UIWindow *win = new UIWindow(_gameRef); _windows.add(win); registerObject(win); - if (!val->isNULL()) win->setName(val->getString()); + if (!val->isNULL()) { + win->setName(val->getString()); + } stack->pushNative(win, true); return STATUS_OK; } @@ -1912,8 +2049,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1936,8 +2076,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursor") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->getFilename()); + if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNoninteractive->getFilename()); + } return STATUS_OK; } @@ -1947,8 +2090,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursorObject") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive) stack->pushNULL(); - else stack->pushNative(_cursorNoninteractive, true); + if (!_cursorNoninteractive) { + stack->pushNULL(); + } else { + stack->pushNative(_cursorNoninteractive, true); + } return STATUS_OK; } @@ -2017,10 +2163,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccOutputText") == 0) { stack->correctParams(2); - /* const char *Str = */ - stack->pop()->getString(); - /* int Type = */ - stack->pop()->getInt(); + /* const char *Str = */ stack->pop()->getString(); + /* int type = */ stack->pop()->getInt(); // do nothing stack->pushNULL(); @@ -2038,7 +2182,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _cachedThumbnail; _cachedThumbnail = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -2083,12 +2229,15 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack char Hex[100]; sprintf(Hex, "%x", checksum); stack->pushString(Hex); - } else + } else { stack->pushInt(checksum); + } _fileManager->closeFile(file); file = NULL; - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -2139,9 +2288,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushNULL(); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -2307,8 +2456,11 @@ ScValue *BaseGame::scGetProperty(const char *name) { // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->setNative(_keyboardState, true); - else _scValue->setNULL(); + if (_keyboardState) { + _scValue->setNative(_keyboardState, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -2530,9 +2682,9 @@ ScValue *BaseGame::scGetProperty(const char *name) { error("Request for a SXStore-object, which is not supported by ScummVM"); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -2579,7 +2731,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { BaseScriptable *obj = value->getNative(); - if (obj == NULL || validObject((BaseObject *)obj)) _mainObject = (BaseObject *)obj; + if (obj == NULL || validObject((BaseObject *)obj)) { + _mainObject = (BaseObject *)obj; + } return STATUS_OK; } @@ -2655,10 +2809,14 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->getInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; + int enc = value->getInt(); + if (enc < 0) { + enc = 0; + } + if (enc >= NUM_TEXT_ENCODINGS) { + enc = NUM_TEXT_ENCODINGS - 1; + } + _textEncoding = (TTextEncoding)enc; return STATUS_OK; } @@ -2725,9 +2883,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "CursorHidden") == 0) { _cursorHidden = value->getBool(); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -2741,7 +2899,9 @@ const char *BaseGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + if (_quickMessages.getSize() == 0 || !_systemFont) { + return STATUS_OK; + } // update for (int i = 0; i < _quickMessages.getSize(); i++) { @@ -2796,7 +2956,9 @@ bool BaseGame::registerObject(BaseObject *object) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::unregisterObject(BaseObject *object) { - if (!object) return STATUS_OK; + if (!object) { + return STATUS_OK; + } // is it a window? for (int i = 0; i < _windows.getSize(); i++) { @@ -2804,23 +2966,31 @@ bool BaseGame::unregisterObject(BaseObject *object) { _windows.removeAt(i); // get new focused window - if (_focusedWindow == object) _focusedWindow = NULL; + if (_focusedWindow == object) { + _focusedWindow = NULL; + } break; } } // is it active object? - if (_activeObject == object) _activeObject = NULL; + if (_activeObject == object) { + _activeObject = NULL; + } // is it main object? - if (_mainObject == object) _mainObject = NULL; + if (_mainObject == object) { + _mainObject = NULL; + } // destroy object for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { _regObjects.removeAt(i); - if (!_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + if (!_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + } delete object; return STATUS_OK; } @@ -2846,11 +3016,17 @@ void BaseGame::invalidateValues(void *value, void *data) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::validObject(BaseObject *object) { - if (!object) return false; - if (object == this) return true; + if (!object) { + return false; + } + if (object == this) { + return true; + } for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) return true; + if (_regObjects[i] == object) { + return true; + } } return false; } @@ -2946,7 +3122,9 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *)obj)) script->waitForExclusive((BaseObject *)obj); + if (validObject((BaseObject *)obj)) { + script->waitForExclusive((BaseObject *)obj); + } stack->pushNULL(); } @@ -2982,8 +3160,11 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack int b = stack->pop()->getInt(); int a; ScValue *val = stack->pop(); - if (val->isNULL()) a = 255; - else a = val->getInt(); + if (val->isNULL()) { + a = 255; + } else { + a = val->getInt(); + } stack->pushInt(BYTETORGBA(r, g, b, a)); } @@ -3142,15 +3323,23 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// bool BaseGame::showCursor() { - if (_cursorHidden) return STATUS_OK; + if (_cursorHidden) { + return STATUS_OK; + } if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + if (_cursorNoninteractive) { + return drawCursor(_cursorNoninteractive); + } } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; - else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); - else if (_cursor) return drawCursor(_cursor); + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) { + return STATUS_OK; + } else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) { + return drawCursor(_activeCursor); + } else if (_cursor) { + return drawCursor(_cursor); + } } } return STATUS_FAILED; @@ -3171,7 +3360,9 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + if (DID_FAIL(ret = pm->initSave(desc))) { + goto save_finish; + } if (!quickSave) { delete _saveLoadImage; @@ -3186,9 +3377,15 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { } } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { + goto save_finish; + } + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { + goto save_finish; + } + if (DID_FAIL(ret = pm->saveFile(filename))) { + goto save_finish; + } _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3240,11 +3437,17 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + if (DID_FAIL(ret = pm->initLoad(filename))) { + goto load_finish; + } //if (DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { + goto load_finish; + } + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { + goto load_finish; + } // data initialization after load initAfterLoad(); @@ -3332,7 +3535,9 @@ bool BaseGame::displayWindows(bool inGame) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } } } @@ -3356,7 +3561,9 @@ bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 _music[channel]->setPositionTime(_musicStartTime[channel]); _musicStartTime[channel] = 0; } - if (loopStart) _music[channel]->setLoopStart(loopStart); + if (loopStart) { + _music[channel]->setLoopStart(loopStart); + } return _music[channel]->play(looping); } else { delete _music[channel]; @@ -3378,7 +3585,9 @@ bool BaseGame::stopMusic(int channel) { delete _music[channel]; _music[channel] = NULL; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -3389,8 +3598,11 @@ bool BaseGame::pauseMusic(int channel) { return STATUS_FAILED; } - if (_music[channel]) return _music[channel]->pause(); - else return STATUS_FAILED; + if (_music[channel]) { + return _music[channel]->pause(); + } else { + return STATUS_FAILED; + } } @@ -3401,8 +3613,11 @@ bool BaseGame::resumeMusic(int channel) { return STATUS_FAILED; } - if (_music[channel]) return _music[channel]->resume(); - else return STATUS_FAILED; + if (_music[channel]) { + return _music[channel]->resume(); + } else { + return STATUS_FAILED; + } } @@ -3414,8 +3629,11 @@ bool BaseGame::setMusicStartTime(int channel, uint32 time) { } _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return STATUS_OK; + if (_music[channel] && _music[channel]->isPlaying()) { + return _music[channel]->setPositionTime(time); + } else { + return STATUS_OK; + } } @@ -3464,11 +3682,15 @@ bool BaseGame::loadSettings(const char *filename) { case TOKEN_GAME: delete[] _settingsGameFile; _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + if (_settingsGameFile) { + strcpy(_settingsGameFile, (char *)params); + } break; case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(_stringTable->loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_RESOLUTION: @@ -3544,8 +3766,9 @@ bool BaseGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) + if (!persistMgr->getIsSaving()) { cleanup(); + } BaseObject::persist(persistMgr); @@ -3627,29 +3850,32 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot)); persistMgr->transfer(TMEMBER(_cursorHidden)); - if (!persistMgr->getIsSaving()) + if (!persistMgr->getIsSaving()) { _quitting = false; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool BaseGame::focusWindow(UIWindow *Window) { - UIWindow *Prev = _focusedWindow; +bool BaseGame::focusWindow(UIWindow *window) { + UIWindow *prev = _focusedWindow; for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == Window) { + if (_windows[i] == window) { if (i < _windows.getSize() - 1) { _windows.removeAt(i); - _windows.add(Window); + _windows.add(window); - _gameRef->_focusedWindow = Window; + _gameRef->_focusedWindow = window; } - if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return focusWindow(Prev); - else return STATUS_OK; + if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) { + return focusWindow(prev); + } else { + return STATUS_OK; + } } } return STATUS_FAILED; @@ -3674,7 +3900,9 @@ bool BaseGame::freeze(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::unfreeze() { - if (_freezeLevel == 0) return STATUS_OK; + if (_freezeLevel == 0) { + return STATUS_OK; + } _freezeLevel--; if (_freezeLevel == 0) { @@ -3691,8 +3919,9 @@ bool BaseGame::unfreeze() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) { stopVideo(); + } return true; } @@ -3708,10 +3937,11 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (_focusedWindow) { if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) { _gameRef->_focusedWindow->applyEvent("Keypress"); - else + } else { applyEvent("Keypress"); + } /*}*/ } return true; @@ -3760,11 +3990,19 @@ bool BaseGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) *verMajor = DCGF_VER_MAJOR; - if (verMinor) *verMinor = DCGF_VER_MINOR; + if (verMajor) { + *verMajor = DCGF_VER_MAJOR; + } + if (verMinor) { + *verMinor = DCGF_VER_MINOR; + } - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; + if (extMajor) { + *extMajor = 0; + } + if (extMinor) { + *extMinor = 0; + } return STATUS_OK; } @@ -3775,7 +4013,9 @@ void BaseGame::setWindowTitle() { if (_renderer) { char title[512]; strcpy(title, _caption[0]); - if (title[0] != '\0') strcat(title, " - "); + if (title[0] != '\0') { + strcat(title, " - "); + } strcat(title, "WME Lite"); @@ -3825,7 +4065,9 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (!pm) return STATUS_FAILED; + if (!pm) { + return STATUS_FAILED; + } if (DID_FAIL(pm->initLoad(filename))) { delete pm; @@ -3845,9 +4087,11 @@ bool BaseGame::isSaveSlotUsed(int slot) { getSaveSlotFilename(slot, filename); warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!File) return false; - delete File; + Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!file) { + return false; + } + delete file; return true; } @@ -3870,9 +4114,13 @@ bool BaseGame::setActiveObject(BaseObject *obj) { obj = NULL; } - if (obj == _activeObject) return STATUS_OK; + if (obj == _activeObject) { + return STATUS_OK; + } - if (_activeObject) _activeObject->applyEvent("MouseLeave"); + if (_activeObject) { + _activeObject->applyEvent("MouseLeave"); + } //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); _activeObject = obj; if (_activeObject) { @@ -3886,8 +4134,11 @@ bool BaseGame::setActiveObject(BaseObject *obj) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); - else _viewportStack[_viewportSP] = viewport; + if (_viewportSP >= _viewportStack.getSize()) { + _viewportStack.add(viewport); + } else { + _viewportStack[_viewportSP] = viewport; + } _renderer->setViewport(viewport->getRect()); @@ -3898,13 +4149,16 @@ bool BaseGame::pushViewport(BaseViewport *viewport) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::popViewport() { _viewportSP--; - if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + if (_viewportSP < -1) { + _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + } - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) { + _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + } else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); return STATUS_OK; } @@ -3912,17 +4166,22 @@ bool BaseGame::popViewport() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) return STATUS_FAILED; - else { + if (rect == NULL) { + return STATUS_FAILED; + } else { if (_viewportSP >= 0) { BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) *custom = true; + if (custom) { + *custom = true; + } } else { BasePlatform::setRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); - if (custom) *custom = false; + if (custom) { + *custom = false; + } } return STATUS_OK; @@ -3933,11 +4192,19 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { - if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; - if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + if (offsetX) { + *offsetX = _viewportStack[_viewportSP]->_offsetX; + } + if (offsetY) { + *offsetY = _viewportStack[_viewportSP]->_offsetY; + } } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; + if (offsetX) { + *offsetX = 0; + } + if (offsetY) { + *offsetY = 0; + } } return STATUS_OK; @@ -3959,7 +4226,9 @@ bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack * ////////////////////////////////////////////////////////////////////////// void BaseGame::setInteractive(bool state) { _interactive = state; - if (_transMgr) _transMgr->_origInteractive = state; + if (_transMgr) { + _transMgr->_origInteractive = state; + } } @@ -3983,7 +4252,9 @@ bool BaseGame::displayContent(bool doUpdate, bool displayAll) { bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); - if (_indicatorDisplay) displayIndicator(); + if (_indicatorDisplay) { + displayIndicator(); + } return STATUS_OK; } @@ -3994,14 +4265,20 @@ bool BaseGame::displayIndicator() { if (_saveLoadImage) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } } - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + return STATUS_OK; + } _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) + for (int i = 0; i < _indicatorHeight; i++) { _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + } _renderer->setup2D(); return STATUS_OK; @@ -4011,8 +4288,12 @@ bool BaseGame::displayIndicator() { bool BaseGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - if (!_musicCrossfadeRunning) return STATUS_OK; - if (_state == GAME_FROZEN) return STATUS_OK; + if (!_musicCrossfadeRunning) { + return STATUS_OK; + } + if (_state == GAME_FROZEN) { + return STATUS_OK; + } if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { _musicCrossfadeRunning = false; @@ -4023,8 +4304,12 @@ bool BaseGame::updateMusicCrossfade() { return STATUS_OK; } - if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); - if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + if (!_music[_musicCrossfadeChannel1]->isPlaying()) { + _music[_musicCrossfadeChannel1]->play(); + } + if (!_music[_musicCrossfadeChannel2]->isPlaying()) { + _music[_musicCrossfadeChannel2]->play(); + } uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; @@ -4112,19 +4397,27 @@ bool BaseGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool BaseGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) return true; - if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + if (_videoPlayer->isPlaying()) { + return true; + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + return true; + } return false; } ////////////////////////////////////////////////////////////////////////// bool BaseGame::stopVideo() { - if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_videoPlayer->isPlaying()) { + _videoPlayer->stop(); + } if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); delete _theoraPlayer; @@ -4136,7 +4429,9 @@ bool BaseGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::drawCursor(BaseSprite *cursor) { - if (!cursor) return STATUS_FAILED; + if (!cursor) { + return STATUS_FAILED; + } if (cursor != _lastCursor) { cursor->reset(); _lastCursor = cursor; @@ -4148,7 +4443,9 @@ bool BaseGame::drawCursor(BaseSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// bool BaseGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return STATUS_OK; + if (_shuttingDown || !_renderer) { + return STATUS_OK; + } _renderer->_active = activate; @@ -4158,15 +4455,20 @@ bool BaseGame::onActivate(bool activate, bool refreshMouse) { setActiveObject(_renderer->getObjectAt(p.x, p.y)); } - if (activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); + if (activate) { + _soundMgr->resumeAll(); + } else { + _soundMgr->pauseAll(); + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { @@ -4175,7 +4477,9 @@ bool BaseGame::onMouseLeftDown() { } } - if (_activeObject != NULL) _capturedObject = _activeObject; + if (_activeObject != NULL) { + _capturedObject = _activeObject; + } _mouseLeftDown = true; BasePlatform::setCapture(/*_renderer->_window*/); @@ -4184,7 +4488,9 @@ bool BaseGame::onMouseLeftDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } BasePlatform::releaseCapture(); _capturedObject = NULL; @@ -4201,9 +4507,13 @@ bool BaseGame::onMouseLeftUp() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { @@ -4216,9 +4526,13 @@ bool BaseGame::onMouseLeftDblClick() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); if (!handled) { @@ -4231,7 +4545,9 @@ bool BaseGame::onMouseRightDblClick() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { @@ -4244,7 +4560,9 @@ bool BaseGame::onMouseRightDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { @@ -4257,9 +4575,13 @@ bool BaseGame::onMouseRightUp() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); if (!handled) { @@ -4272,7 +4594,9 @@ bool BaseGame::onMouseMiddleDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseMiddleUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); if (!handled) { @@ -4297,9 +4621,13 @@ bool BaseGame::onPaint() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onWindowClose() { if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + if (_state != GAME_FROZEN) { + _gameRef->applyEvent("QuitGame"); + } return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// @@ -4312,10 +4640,11 @@ bool BaseGame::displayDebugInfo() { } if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) + if (!_gameRef->_renderer->_windowed) { sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else + } else { sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + } strcat(str, " ("); strcat(str, _renderer->getName().c_str()); @@ -4333,7 +4662,9 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Timer: %d", _timer); _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) { + _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + } sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); @@ -4345,7 +4676,9 @@ bool BaseGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// BaseDebugger *BaseGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new BaseDebugger(this); + if (!_debugMgr) { + _debugMgr = new BaseDebugger(this); + } return _debugMgr; } @@ -4390,10 +4723,14 @@ void BaseGame::getMousePos(Point32 *pos) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::miniUpdate() { - if (!_miniUpdateEnabled) return STATUS_OK; + if (!_miniUpdateEnabled) { + return STATUS_OK; + } if (g_system->getMillis() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); + if (_soundMgr) { + _soundMgr->initLoop(); + } _lastMiniUpdate = g_system->getMillis(); } return STATUS_OK; @@ -4443,8 +4780,12 @@ void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); _registry->saveValues(); - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; + if (!_autoSaveOnExit) { + return; + } + if (_state == GAME_FROZEN) { + return; + } saveGame(_autoSaveSlot, "autosave", true); } diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 03f9929eee..3bad8f6012 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -84,9 +84,13 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { const char *str = val->getString(); char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + if (temp >= 'A' && temp <= 'Z') { + temp += ('a' - 'A'); + } vKey = (int)temp; - } else vKey = val->getInt(); + } else { + vKey = val->getInt(); + } warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; // Uint8 *state = SDL_GetKeyboardState(NULL); @@ -95,9 +99,9 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * stack->pushBool(isDown); return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } @@ -122,7 +126,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { key[0] = (char)_currentCharCode; key[1] = '\0'; _scValue->setString(key); - } else _scValue->setString(""); + } else { + _scValue->setString(""); + } return _scValue; } @@ -165,9 +171,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { else if (strcmp(name, "IsControl") == 0) { _scValue->setBool(_currentControl); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -255,7 +261,9 @@ bool BaseKeyboardState::isAltDown() { ////////////////////////////////////////////////////////////////////////// uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; + if (event->type != Common::EVENT_KEYDOWN) { + return 0; + } switch (event->kbd.keycode) { case Common::KEYCODE_KP_ENTER: diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 0821c9325b..0873f090d0 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -58,11 +58,14 @@ void BaseNamedObject::setName(const char *name) { delete[] _name; _name = NULL; - if (name == NULL) + if (name == NULL) { return; + } _name = new char [strlen(name) + 1]; - if (_name != NULL) strcpy(_name, name); + if (_name != NULL) { + strcpy(_name, name); + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 44823acf1a..18619616fe 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -85,8 +85,9 @@ BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { _rotateValid = false; _relativeRotate = 0.0f; - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { _caption[i] = NULL; + } _saveState = true; _nonIntMouseEvents = false; @@ -107,8 +108,9 @@ BaseObject::~BaseObject() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) + if (_gameRef && _gameRef->_activeObject == this) { _gameRef->_activeObject = NULL; + } BaseScriptHolder::cleanup(); delete[] _soundEvent; @@ -137,9 +139,12 @@ bool BaseObject::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7) + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7) { return; + } delete[] _caption[caseVal - 1]; _caption[caseVal - 1] = new char[strlen(caption) + 1]; @@ -152,10 +157,14 @@ void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename ////////////////////////////////////////////////////////////////////////// const char *BaseObject::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { return ""; - else return _caption[caseVal - 1]; + } else { + return _caption[caseVal - 1]; + } } @@ -198,8 +207,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -226,8 +238,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { stack->correctParams(0); - if (!_cursor || !_cursor->getFilename()) stack->pushNULL(); - else stack->pushString(_cursor->getFilename()); + if (!_cursor || !_cursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursor->getFilename()); + } return STATUS_OK; } @@ -237,8 +252,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursorObject") == 0) { stack->correctParams(0); - if (!_cursor) stack->pushNULL(); - else stack->pushNative(_cursor, true); + if (!_cursor) { + stack->pushNULL(); + } else { + stack->pushNative(_cursor, true); + } return STATUS_OK; } @@ -249,8 +267,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "HasCursor") == 0) { stack->correctParams(0); - if (_cursor) stack->pushBool(true); - else stack->pushBool(false); + if (_cursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -272,10 +293,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) + if (DID_SUCCEED(playSFX(filename, false, false))) { stack->pushBool(true); - else + } else { stack->pushBool(false); + } return STATUS_OK; } @@ -299,15 +321,20 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta looping = val1->getBool(); loopStart = val2->getInt(); } else { - if (val1->isNULL()) filename = NULL; - else filename = val1->getString(); + if (val1->isNULL()) { + filename = NULL; + } else { + filename = val1->getString(); + } looping = val2->isNULL() ? false : val2->getBool(); loopStart = val3->getInt(); } - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) { stack->pushBool(false); - else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -331,8 +358,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta eventName = val2->getString(); } - if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(playSFX(filename, false, true, eventName))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -342,8 +372,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "StopSound") == 0) { stack->correctParams(0); - if (DID_FAIL(stopSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(stopSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -353,8 +386,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "PauseSound") == 0) { stack->correctParams(0); - if (DID_FAIL(pauseSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(pauseSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -364,8 +400,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "ResumeSound") == 0) { stack->correctParams(0); - if (DID_FAIL(resumeSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(resumeSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -375,8 +414,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "IsSoundPlaying") == 0) { stack->correctParams(0); - if (_sFX && _sFX->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); + if (_sFX && _sFX->isPlaying()) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -387,8 +429,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setSFXTime(Time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -398,8 +443,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "GetSoundPosition") == 0) { stack->correctParams(0); - if (!_sFX) stack->pushInt(0); - else stack->pushInt(_sFX->getPositionTime()); + if (!_sFX) { + stack->pushInt(0); + } else { + stack->pushInt(_sFX->getPositionTime()); + } return STATUS_OK; } @@ -410,8 +458,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setSFXVolume(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -421,8 +472,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "GetSoundVolume") == 0) { stack->correctParams(0); - if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolumePercent()); + if (!_sFX) { + stack->pushInt(_sFXVolume); + } else { + stack->pushInt(_sFX->getVolumePercent()); + } return STATUS_OK; } @@ -470,9 +524,9 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->pushNULL(); return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } @@ -578,8 +632,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scale); + if (_scale < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scale); + } return _scValue; } @@ -587,8 +644,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleX); + if (_scaleX < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleX); + } return _scValue; } @@ -596,8 +656,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleY); + if (_scaleY < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleY); + } return _scValue; } @@ -613,8 +676,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->setNULL(); - else _scValue->setFloat((double)_rotate); + if (!_rotateValid) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_rotate); + } return _scValue; } @@ -663,9 +729,9 @@ ScValue *BaseObject::scGetProperty(const char *name) { else if (strcmp(name, "AccCaption") == 0) { _scValue->setNULL(); return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); } - - else return BaseScriptHolder::scGetProperty(name); } @@ -742,7 +808,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) { + i = BLEND_NORMAL; + } _blendMode = (TSpriteBlendMode)i; return STATUS_OK; } @@ -751,8 +819,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) _scale = -1; - else _scale = (float)value->getFloat(); + if (value->isNULL()) { + _scale = -1; + } else { + _scale = (float)value->getFloat(); + } return STATUS_OK; } @@ -760,8 +831,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) _scaleX = -1; - else _scaleX = (float)value->getFloat(); + if (value->isNULL()) { + _scaleX = -1; + } else { + _scaleX = (float)value->getFloat(); + } return STATUS_OK; } @@ -769,8 +843,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) _scaleY = -1; - else _scaleY = (float)value->getFloat(); + if (value->isNULL()) { + _scaleY = -1; + } else { + _scaleY = (float)value->getFloat(); + } return STATUS_OK; } @@ -817,7 +894,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundPanning") == 0) { _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) resetSoundPan(); + if (!_autoSoundPanning) { + resetSoundPan(); + } return STATUS_OK; } @@ -842,9 +921,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccCaption") == 0) { return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); } - - else return BaseScriptHolder::scSetProperty(name, value); } @@ -856,8 +935,11 @@ const char *BaseObject::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::showCursor() { - if (_cursor) return _gameRef->drawCursor(_cursor); - else return STATUS_FAILED; + if (_cursor) { + return _gameRef->drawCursor(_cursor); + } else { + return STATUS_FAILED; + } } @@ -871,8 +953,9 @@ bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool BaseObject::persist(BasePersistenceManager *persistMgr) { BaseScriptHolder::persist(persistMgr); - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { persistMgr->transfer(TMEMBER(_caption[i])); + } persistMgr->transfer(TMEMBER(_activeCursor)); persistMgr->transfer(TMEMBER(_alphaColor)); persistMgr->transfer(TMEMBER(_autoSoundPanning)); @@ -936,7 +1019,9 @@ bool BaseObject::setCursor(const char *filename) { delete _cursor; _cursor = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } @@ -948,7 +1033,9 @@ bool BaseObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } @@ -983,16 +1070,24 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const if (_gameRef->_editorMode || _sFXStart) { _sFX->setVolumePercent(_sFXVolume); _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) _sFXStart = 0; + if (!_gameRef->_editorMode) { + _sFXStart = 0; + } } if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } return _sFX->play(looping); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } - if (filename == NULL) return STATUS_FAILED; + if (filename == NULL) { + return STATUS_FAILED; + } // create new sound delete _sFX; @@ -1007,9 +1102,13 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } return _sFX->play(looping); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } else { delete _sFX; _sFX = NULL; @@ -1027,37 +1126,51 @@ bool BaseObject::stopSFX(bool deleteSound) { _sFX = NULL; } return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::pauseSFX() { - if (_sFX) return _sFX->pause(); - else return STATUS_FAILED; + if (_sFX) { + return _sFX->pause(); + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::resumeSFX() { - if (_sFX) return _sFX->resume(); - else return STATUS_FAILED; + if (_sFX) { + return _sFX->resume(); + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::setSFXTime(uint32 time) { _sFXStart = time; - if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return STATUS_OK; + if (_sFX && _sFX->isPlaying()) { + return _sFX->setPositionTime(time); + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::setSFXVolume(int volume) { _sFXVolume = volume; - if (_sFX) return _sFX->setVolumePercent(volume); - else return STATUS_OK; + if (_sFX) { + return _sFX->setVolumePercent(volume); + } else { + return STATUS_OK; + } } @@ -1070,7 +1183,9 @@ bool BaseObject::updateSounds() { } } - if (_sFX) updateOneSound(_sFX); + if (_sFX) { + updateOneSound(_sFX); + } return STATUS_OK; } @@ -1080,8 +1195,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) { bool Ret = STATUS_OK; if (sound) { - if (_autoSoundPanning) + if (_autoSoundPanning) { Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + } Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } @@ -1090,8 +1206,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) { ////////////////////////////////////////////////////////////////////////// bool BaseObject::resetSoundPan() { - if (!_sFX) return STATUS_OK; - else { + if (!_sFX) { + return STATUS_OK; + } else { return _sFX->setPan(0.0f); } } @@ -1115,7 +1232,9 @@ void BaseObject::setSoundEvent(const char *eventName) { _soundEvent = NULL; if (eventName) { _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, eventName); + if (_soundEvent) { + strcpy(_soundEvent, eventName); + } } } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 12ed67ba2a..98d77f4ed5 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -50,7 +50,9 @@ BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseParser::~BaseParser() { - if (_whiteSpace != NULL) delete[] _whiteSpace; + if (_whiteSpace != NULL) { + delete[] _whiteSpace; + } } @@ -71,8 +73,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d skipCharacters(buf, _whiteSpace); } - if (! **buf) // at end of file + if (! **buf) { // at end of file return PARSERR_EOF; + } // find the token. // for now just use brute force. Improve later. @@ -89,7 +92,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d char *p = strchr(*buf, '\n'); if (p && p > *buf) { strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); + } else { + strcpy(_lastOffender, ""); + } return PARSERR_TOKENNOTFOUND; } @@ -102,10 +107,11 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d skipCharacters(buf, _whiteSpace); // get optional data - if (**buf == '=') // An assignment rather than a command/object. + if (**buf == '=') { // An assignment rather than a command/object. *data = getAssignmentText(buf); - else + } else { *data = getSubText(buf, '{', '}'); + } return tokens->id; } @@ -113,7 +119,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d ////////////////////////////////////////////////////////////////////// int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; + if (!*buf) { + return PARSERR_TOKENNOTFOUND; + } _gameRef->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); @@ -124,9 +132,12 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { void BaseParser::skipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) + if (ch == '\n') { + _parserLine++; + } + if (strchr(toSkip, ch) == NULL) { return; + } ++*buf; // skip this character } // we must be at the end of the buffer if we get here @@ -135,8 +146,9 @@ void BaseParser::skipCharacters(char **buf, const char *toSkip) { ////////////////////////////////////////////////////////////////////// char *BaseParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) + if (**buf == 0 || **buf != open) { return 0; + } ++*buf; // skip opening delimiter char *result = *buf; @@ -144,11 +156,13 @@ char *BaseParser::getSubText(char **buf, char open, char close) { char theChar; long skip = 1; - if (open == close) // we cant nest identical delimiters + if (open == close) { // we cant nest identical delimiters open = 0; + } while ((theChar = **buf) != 0) { - if (theChar == open) + if (theChar == open) { ++skip; + } if (theChar == close) { if (--skip == 0) { **buf = 0; // null terminate the result string @@ -176,13 +190,15 @@ char *BaseParser::getAssignmentText(char **buf) { char theChar; while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars + if (theChar <= 0x20) { // space and control chars break; + } ++*buf; } - **buf = 0; // null terminate it - if (theChar) // skip the terminator + **buf = 0; // null terminate it + if (theChar) { // skip the terminator ++*buf; + } } return result; @@ -195,10 +211,16 @@ char *BaseParser::getToken(char **buf) { static char token[100]; char *b = *buf, * t = token; while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { + b++; + } if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; + while (*b && *b != '\n' && *b != 13 && *b != 10) { + b++; + } + else { + break; + } } if (*b == '\'') { @@ -207,7 +229,9 @@ char *BaseParser::getToken(char **buf) { *t++ = *b++; } *t++ = 0; - if (*b == '\'') b++; + if (*b == '\'') { + b++; + } } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || *b == '%' || *b == ':' || *b == '{' || *b == '}') { *t++ = *b++; @@ -265,7 +289,9 @@ int BaseParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { char *t = getToken(buf); - if (strcmp(t, tok)) return; // Error + if (strcmp(t, tok)) { + return; // Error + } } @@ -299,7 +325,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { list[i++] = atoi(in); in += strspn(in, "0123456789+-"); in += strspn(in, " \t\n\f"); - if (*in != ',') break; + if (*in != ',') { + break; + } in++; in += strspn(in, " \t\n\f"); } @@ -339,7 +367,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { list[i++] = (float)atof(in); in += strspn(in, "0123456789.eE+-"); in += strspn(in, " \t\n\f"); - if (*in != ',') break; + if (*in != ',') { + break; + } in++; in += strspn(in, " \t\n\f"); } @@ -414,7 +444,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { break; } } - if (*format) format++; + if (*format) { + format++; + } } else if (*format == ' ') { format++; in += strspn(in, " \t\n\f"); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index cf7deb2970..d8f928b683 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -181,7 +181,9 @@ bool BasePersistenceManager::getSaveExists(int slot) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::initSave(const char *desc) { - if (!desc) return STATUS_FAILED; + if (!desc) { + return STATUS_FAILED; + } cleanup(); _saving = true; @@ -232,7 +234,9 @@ bool BasePersistenceManager::initSave(const char *desc) { thumbnailOK = true; } } - if (!thumbnailOK) putDWORD(0); + if (!thumbnailOK) { + putDWORD(0); + } // in any case, destroy the cached thumbnail once used delete _gameRef->_cachedThumbnail; @@ -288,9 +292,13 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { _thumbnailData = new byte[_thumbnailDataSize]; if (_thumbnailData) { getBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; + } else { + _thumbnailDataSize = 0; + } } - } else _savedVerBuild = 35; // last build with ver1 savegames + } else { + _savedVerBuild = 35; // last build with ver1 savegames + } uint32 dataOffset = getDWORD(); @@ -379,16 +387,18 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } @@ -407,8 +417,9 @@ uint32 BasePersistenceManager::getDWORD() { ////////////////////////////////////////////////////////////////////////// void BasePersistenceManager::putString(const Common::String &val) { - if (!val.size()) putString("(null)"); - else { + if (!val.size()) { + putString("(null)"); + } else { _saveStream->writeUint32LE(val.size()); _saveStream->writeString(val); } @@ -440,7 +451,9 @@ char *BasePersistenceManager::getString() { if (!strcmp(ret, "(null)")) { delete[] ret; return NULL; - } else return ret; + } else { + return ret; + } } bool BasePersistenceManager::putTimeDate(const TimeDate &t) { @@ -510,13 +523,15 @@ double BasePersistenceManager::getDouble() { bool BasePersistenceManager::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readByte(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -527,13 +542,15 @@ bool BasePersistenceManager::transfer(const char *name, bool *val) { bool BasePersistenceManager::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -544,13 +561,15 @@ bool BasePersistenceManager::transfer(const char *name, int *val) { bool BasePersistenceManager::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readUint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -561,13 +580,15 @@ bool BasePersistenceManager::transfer(const char *name, uint32 *val) { bool BasePersistenceManager::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = getFloat(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -578,13 +599,15 @@ bool BasePersistenceManager::transfer(const char *name, float *val) { bool BasePersistenceManager::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = getDouble(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -667,7 +690,9 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { delete[] str; return STATUS_FAILED; } - if (str) val.push_back(str); + if (str) { + val.push_back(str); + } delete[] str; } } @@ -680,13 +705,15 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { bool BasePersistenceManager::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readByte(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -700,16 +727,18 @@ bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { _saveStream->writeSint32LE(val->top); _saveStream->writeSint32LE(val->right); _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->left = _loadStream->readSint32LE(); val->top = _loadStream->readSint32LE(); val->right = _loadStream->readSint32LE(); val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -721,14 +750,16 @@ bool BasePersistenceManager::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->x = _loadStream->readSint32LE(); val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -740,14 +771,16 @@ bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->x = getFloat(); val->y = getFloat(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -779,13 +812,17 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) return true; + if (_saving) { + return true; + } // it's ok if we are same or newer than the saved game if (verMajor > _savedVerMajor || (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) return false; + ) { + return false; + } return true; } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index d672e39c6b..bf38adb578 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -34,14 +34,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { _text = new char [strlen(text) + 1]; - if (_text) strcpy(_text, text); + if (_text) { + strcpy(_text, text); + } _startTime = _gameRef->_currentTime; } ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::~BaseQuickMsg() { - if (_text) delete[] _text; + if (_text) { + delete[] _text; + } } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index f88de2ab91..67cda44ece 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -60,7 +60,9 @@ BaseRegion::~BaseRegion() { ////////////////////////////////////////////////////////////////////////// void BaseRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + for (int i = 0; i < _points.getSize(); i++) { + delete _points[i]; + } _points.removeAll(); BasePlatform::setRectEmpty(&_rect); @@ -76,7 +78,9 @@ bool BaseRegion::createRegion() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) return false; + if (_points.getSize() < 3) { + return false; + } Point32 pt; pt.x = x; @@ -88,8 +92,11 @@ bool BaseRegion::pointInRegion(int x, int y) { rect.top = y - 1; rect.bottom = y + 2; - if (BasePlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); - else return false; + if (BasePlatform::ptInRect(&_rect, pt)) { + return ptInPolygon(x, y); + } else { + return false; + } } @@ -105,7 +112,9 @@ bool BaseRegion::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + } delete[] buffer; @@ -153,13 +162,17 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { int i; - for (i = 0; i < _points.getSize(); i++) delete _points[i]; + for (i = 0; i < _points.getSize(); i++) { + delete _points[i]; + } _points.removeAll(); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -240,7 +253,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -260,7 +275,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -280,7 +297,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -298,12 +317,14 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta val->setProperty("X", _points[index]->x); val->setProperty("Y", _points[index]->y); } - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -341,9 +362,9 @@ ScValue *BaseRegion::scGetProperty(const char *name) { else if (strcmp(name, "NumPoints") == 0) { _scValue->setInt(_points.getSize()); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -363,9 +384,9 @@ bool BaseRegion::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "Active") == 0) { _active = value->getBool(); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -377,8 +398,11 @@ const char *BaseRegion::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", nameOverride); + if (!nameOverride) { + buffer->putTextIndent(indent, "REGION {\n"); + } else { + buffer->putTextIndent(indent, "%s {\n", nameOverride); + } buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -395,7 +419,9 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent, "}\n\n"); @@ -425,7 +451,9 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) return false; + if (_points.getSize() < 3) { + return false; + } int counter = 0; double xinters; @@ -446,8 +474,9 @@ bool BaseRegion::ptInPolygon(int x, int y) { if (p.x <= MAX(p1.x, p2.x)) { if (p1.y != p2.y) { xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) + if (p1.x == p2.x || p.x <= xinters) { counter++; + } } } } @@ -455,17 +484,19 @@ bool BaseRegion::ptInPolygon(int x, int y) { p1 = p2; } - if (counter % 2 == 0) + if (counter % 2 == 0) { return false; - else + } else { return true; + } } ////////////////////////////////////////////////////////////////////////// bool BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) BasePlatform::setRectEmpty(rect); - else { + if (_points.getSize() == 0) { + BasePlatform::setRectEmpty(rect); + } else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; for (int i = 0; i < _points.getSize(); i++) { @@ -483,7 +514,9 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { + return STATUS_OK; + } cleanup(); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 7eb2685746..441d00c05b 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -61,8 +61,12 @@ AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString & bool found = false; ret = getValue(_localValues, subKey, key, found); - if (!found) ret = getValue(_values, subKey, key, found); - if (!found) ret = init; + if (!found) { + ret = getValue(_values, subKey, key, found); + } + if (!found) { + ret = init; + } return ret; } @@ -105,8 +109,11 @@ int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int i } } AnsiString val = readString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); + if (val.empty()) { + return init; + } else { + return atoi(val.c_str()); + } } @@ -166,8 +173,11 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + if (local) { + loadXml("settings.xml", _localValues); + } else { + loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + } } ////////////////////////////////////////////////////////////////////////// @@ -186,12 +196,15 @@ void BaseRegistry::setBasePath(const char *basePath) { AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { found = false; PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; + if (it == values.end()) { + return ""; + } KeyValuePair pairs = (*it)._value; KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { + if (keyIt == pairs.end()) { + return ""; + } else { found = true; return (*keyIt)._value; } @@ -200,11 +213,14 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; + if (!doc.LoadFile()) { + return; + } TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) return; + } for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { @@ -247,8 +263,9 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { Common::DumpFile stream; stream.open(fileName.c_str()); - if (!stream.isOpen()) return; - else { + if (!stream.isOpen()) { + return; + } else { stream.write(printer.CStr(), printer.Size()); stream.close(); } diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index b63f280f05..5007b65422 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -60,7 +60,9 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { } BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) return STATUS_FAILED; + if (!screenshot) { + return STATUS_FAILED; + } // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d274f9df73..b90b4dc60a 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -75,10 +75,13 @@ void BaseScriptHolder::setFilename(const char *filename) { delete[] _filename; _filename = NULL; } - if (filename == NULL) + if (filename == NULL) { return; + } _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) strcpy(_filename, filename); + if (_filename != NULL) { + strcpy(_filename, filename); + } } @@ -97,7 +100,9 @@ bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { } } } - if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + if (numHandlers > 0 && unbreakable) { + _gameRef->_scEngine->tickUnbreakable(); + } return ret; } @@ -134,8 +139,11 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t bool ret; ret = applyEvent(val->getString()); - if (DID_SUCCEED(ret)) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(ret)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -206,7 +214,9 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t stack->pushBool(ret); return STATUS_OK; - } else return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } } @@ -236,9 +246,9 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { else if (strcmp(name, "Filename") == 0) { _scValue->setString(_filename); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -250,7 +260,9 @@ bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { if (strcmp(name, "Name") == 0) { setName(value->getString()); return STATUS_OK; - } else return BaseScriptable::scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } } @@ -334,7 +346,9 @@ bool BaseScriptHolder::removeScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { + return true; + } } return false; } @@ -343,7 +357,9 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { + return true; + } } return false; } @@ -382,15 +398,21 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { case TOKEN_NAME: delete[] propName; propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; case TOKEN_VALUE: delete[] propValue; propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; } @@ -430,8 +452,9 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) { _scripts[i]->_freezable = freezable; + } } diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 4059abde3d..ad89b63d65 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -38,8 +38,11 @@ IMPLEMENT_PERSISTENT(BaseScriptable, false) BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { _refCount = 0; - if (noValue) _scValue = NULL; - else _scValue = new ScValue(_gameRef); + if (noValue) { + _scValue = NULL; + } else { + _scValue = new ScValue(_gameRef); + } _persistable = persistable; @@ -74,17 +77,27 @@ bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi ////////////////////////////////////////////////////////////////////////// ScValue *BaseScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new ScValue(_gameRef); - if (_scProp) return _scProp->getProp(name); - else return NULL; + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->getProp(name); + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { - if (!_scProp) _scProp = new ScValue(_gameRef); - if (_scProp) return _scProp->setProp(name, value); - else return STATUS_FAILED; + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->setProp(name, value); + } else { + return STATUS_FAILED; + } } @@ -150,9 +163,13 @@ bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int BaseScriptable::scCompare(BaseScriptable *val) { - if (this < val) return -1; - else if (this > val) return 1; - else return 0; + if (this < val) { + return -1; + } else if (this > val) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index c2e57f9fd6..2fda638665 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -89,8 +89,9 @@ void BaseSprite::setDefaults() { void BaseSprite::cleanup() { BaseScriptHolder::cleanup(); - for (int i = 0; i < _frames.getSize(); i++) + for (int i = 0; i < _frames.getSize(); i++) { delete _frames[i]; + } _frames.removeAll(); delete[] _editorBgFile; @@ -103,7 +104,9 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return STATUS_OK; + } // move owner if allowed to if (_changed && _owner && _owner->_movable) { @@ -125,8 +128,11 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); - else return loadFile("invalid.bmp", lifeTime, cacheType); + if (_gameRef->_debugDebugMode) { + return loadFile("invalid_debug.bmp", lifeTime, cacheType); + } else { + return loadFile("invalid.bmp", lifeTime, cacheType); + } } else { _gameRef->_fileManager->closeFile(file); file = NULL; @@ -154,7 +160,9 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c } else { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { + _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + } delete[] buffer; } } @@ -262,7 +270,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa if (_gameRef->_editorMode) { delete[] _editorBgFile; _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + if (_editorBgFile) { + strcpy(_editorBgFile, (char *)params); + } } break; @@ -282,7 +292,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa case TOKEN_FRAME: { int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) { + FrameLifeTime = -1; + } frame = new BaseFrame(_gameRef); @@ -294,7 +306,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa _frames.add(frame); frameCount++; - if (_currentFrame == -1) _currentFrame = 0; + if (_currentFrame == -1) { + _currentFrame = 0; + } } break; @@ -316,8 +330,11 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa ////////////////////////////////////////////////////////////////////// void BaseSprite::reset() { - if (_frames.getSize() > 0) _currentFrame = 0; - else _currentFrame = -1; + if (_frames.getSize() > 0) { + _currentFrame = 0; + } else { + _currentFrame = -1; + } killAllSounds(); @@ -331,11 +348,16 @@ void BaseSprite::reset() { bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - if (_currentFrame == -1) return false; + if (_currentFrame == -1) { + return false; + } uint32 timer; - if (_owner && _owner->_freezable) timer = _gameRef->_timer; - else timer = _gameRef->_liveTimer; + if (_owner && _owner->_freezable) { + timer = _gameRef->_timer; + } else { + timer = _gameRef->_liveTimer; + } int lastFrame = _currentFrame; @@ -343,7 +365,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { if (_currentFrame < _frames.getSize() - 1) { _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + if (_continuous) { + _canBreak = (_currentFrame == _frames.getSize() - 1); + } } else { if (_looping) { _currentFrame = 0; @@ -362,7 +386,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { if (_lastFrameTime == 0) { _lastFrameTime = timer; _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + if (_continuous) { + _canBreak = (_currentFrame == _frames.getSize() - 1); + } } if (_changed) { @@ -381,7 +407,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return STATUS_OK; + } // on change... if (_changed) { @@ -400,18 +428,27 @@ bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - BaseFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.getSize() > 0) { - BaseSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return NULL; + } + BaseFrame *frame = _frames[_currentFrame]; + if (frame && frame->_subframes.getSize() > 0) { + BaseSubFrame *subframe = frame->_subframes[0]; + if (subframe) { + return subframe->_surface; + } else { + return NULL; + } + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } BasePlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { @@ -434,12 +471,14 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { if (_streamed) { buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - if (_streamedKeepLoaded) + if (_streamedKeepLoaded) { buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } } - if (_editorMuted) + if (_editorMuted) { buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + } if (_editorBgFile) { buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); @@ -514,7 +553,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); - } else stack->pushNative(_frames[Index], true); + } else { + stack->pushNative(_frames[Index], true); + } return STATUS_OK; } @@ -523,17 +564,19 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteFrame") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); } } else { - BaseFrame *Frame = (BaseFrame *)Val->getNative(); + BaseFrame *frame = (BaseFrame *)val->getNative(); for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; + if (_frames[i] == frame) { + if (i == _currentFrame) { + _lastFrameTime = 0; + } delete _frames[i]; _frames.removeAt(i); break; @@ -561,7 +604,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { @@ -569,7 +614,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.add(sub); - } else delete sub; + } else { + delete sub; + } } _frames.add(frame); @@ -583,24 +630,31 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) + if (index < 0) { index = 0; + } ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) + if (!val->isNULL()) { filename = val->getString(); + } BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); - else delete sub; + if (DID_SUCCEED(sub->setSurface(filename))) { + frame->_subframes.add(sub); + } else { + delete sub; + } } - if (index >= _frames.getSize()) + if (index >= _frames.getSize()) { _frames.add(frame); - else _frames.insertAt(index, frame); + } else { + _frames.insertAt(index, frame); + } stack->pushNative(frame, true); return STATUS_OK; @@ -624,9 +678,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta _paused = false; stack->pushNULL(); return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } @@ -678,8 +732,11 @@ ScValue *BaseSprite::scGetProperty(const char *name) { // Owner (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->setNULL(); - else _scValue->setNative(_owner, true); + if (_owner == NULL) { + _scValue->setNULL(); + } else { + _scValue->setNative(_owner, true); + } return _scValue; } @@ -697,9 +754,9 @@ ScValue *BaseSprite::scGetProperty(const char *name) { else if (strcmp(name, "Paused") == 0) { _scValue->setBool(_paused); return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); } - - else return BaseScriptHolder::scGetProperty(name); } @@ -731,9 +788,9 @@ bool BaseSprite::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "Looping") == 0) { _looping = value->getBool(); return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); } - - else return BaseScriptHolder::scSetProperty(name, value); } @@ -746,8 +803,9 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i]->_sound) + if (_frames[i]->_sound) { _frames[i]->_sound->stop(); + } } return STATUS_OK; } diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 58cf046436..18a18fe0ba 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -51,8 +51,9 @@ BaseStringTable::~BaseStringTable() { ////////////////////////////////////////////////////////////////////////// bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) + if (key == NULL || val == NULL) { return STATUS_FAILED; + } if (scumm_stricmp(key, "@right-to-left") == 0) { _gameRef->_textRTL = true; @@ -63,8 +64,9 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup finalKey.toLowercase(); StringsIter it = _strings.find(finalKey); - if (it != _strings.end() && reportDuplicities) + if (it != _strings.end() && reportDuplicities) { _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + } _strings[finalKey] = val; @@ -73,12 +75,14 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup ////////////////////////////////////////////////////////////////////////// char *BaseStringTable::getKey(const char *str) const { - if (str == NULL || str[0] != '/') + if (str == NULL || str[0] != '/') { return NULL; + } const char *value = strchr(str + 1, '/'); - if (value == NULL) + if (value == NULL) { return NULL; + } char *key = new char[value - str]; Common::strlcpy(key, str + 1, (size_t)(value - str)); @@ -107,12 +111,14 @@ char *BaseStringTable::getKey(const char *str) const { ////////////////////////////////////////////////////////////////////////// void BaseStringTable::expand(char **str) const { - if (str == NULL || *str == NULL || *str[0] != '/') + if (str == NULL || *str == NULL || *str[0] != '/') { return; + } char *value = strchr(*str + 1, '/'); - if (value == NULL) + if (value == NULL) { return; + } char *key = new char[value - *str]; Common::strlcpy(key, *str + 1, (size_t)(value - *str)); @@ -136,19 +142,22 @@ void BaseStringTable::expand(char **str) const { delete[] *str; *str = newStr; - if (strlen(*str) > 0 && *str[0] == '/') + if (strlen(*str) > 0 && *str[0] == '/') { expand(str); + } } ////////////////////////////////////////////////////////////////////////// const char *BaseStringTable::expandStatic(const char *string) const { - if (string == NULL || string[0] == '\0' || string[0] != '/') + if (string == NULL || string[0] == '\0' || string[0] != '/') { return string; + } const char *value = strchr(string + 1, '/'); - if (value == NULL) + if (value == NULL) { return string; + } char *key = new char[value - string]; Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); @@ -167,10 +176,11 @@ const char *BaseStringTable::expandStatic(const char *string) const { delete[] key; - if (strlen(newStr) > 0 && newStr[0] == '/') + if (strlen(newStr) > 0 && newStr[0] == '/') { return expandStatic(newStr); - else + } else { return newStr; + } } @@ -178,8 +188,9 @@ const char *BaseStringTable::expandStatic(const char *string) const { bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); - if (clearOld) + if (clearOld) { _strings.clear(); + } uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); @@ -197,27 +208,33 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { //_gameRef->_textEncoding = TEXT_ANSI; _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); } - } else _gameRef->_textEncoding = TEXT_ANSI; + } else { + _gameRef->_textEncoding = TEXT_ANSI; + } uint32 lineLength = 0; while (pos < size) { lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') { lineLength++; + } uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); char *line = new char[realLength + 1]; Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); + if (value == NULL) { + value = strchr(line, ' '); + } if (line[0] != ';') { if (value != NULL) { value[0] = '\0'; value++; for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') + if (value[i] == '|') { value[i] = '\n'; + } } addString(line, value, clearOld); } else if (line[0] != '\0') { diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 523bbed866..e8290ee659 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -67,7 +67,9 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// BaseSubFrame::~BaseSubFrame() { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } delete[] _surfaceFilename; _surfaceFilename = NULL; } @@ -181,12 +183,17 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } if (surfaceFile != NULL) { - if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + if (custoTrans) { + setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + } else { + setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } } _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + if (custoTrans) { + _transparent = BYTETORGBA(r, g, b, 0xFF); + } /* if (_surface == NULL) @@ -195,8 +202,11 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } */ - if (BasePlatform::isRectEmpty(&rect)) setDefaultRect(); - else _rect = rect; + if (BasePlatform::isRectEmpty(&rect)) { + setDefaultRect(); + } else { + _rect = rect; + } return STATUS_OK; } @@ -204,7 +214,9 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return STATUS_OK; + if (!_surface) { + return STATUS_OK; + } if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { @@ -213,18 +225,25 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } - if (_gameRef->_suspendedRendering) return STATUS_OK; + if (_gameRef->_suspendedRendering) { + return STATUS_OK; + } bool res; //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) alpha = _alpha; + if (_alpha != 0xFFFFFFFF) { + alpha = _alpha; + } if (rotate != 0.0f) { res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); } else { - if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + if (zoomX == 100 && zoomY == 100) { + res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + } else { + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } } return res; @@ -233,7 +252,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl ////////////////////////////////////////////////////////////////////////// bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; @@ -249,52 +270,66 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo ////////////////////////////////////////////////////////////////////////// bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { - if (complete) + if (complete) { buffer->putTextIndent(indent, "SUBFRAME {\n"); + } - if (_surface && _surface->getFileNameStr() != "") + if (_surface && _surface->getFileNameStr() != "") { buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + } - if (_transparent != 0xFFFF00FF) + if (_transparent != 0xFFFF00FF) { buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + } Rect32 rect; BasePlatform::setRectEmpty(&rect); - if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!(rect == _rect)) + if (_surface) { + BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } + if (!(rect == _rect)) { buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + } - if (_hotspotX != 0 || _hotspotY != 0) + if (_hotspotX != 0 || _hotspotY != 0) { buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + } if (_alpha != 0xFFFFFFFF) { buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); } - if (_mirrorX) + if (_mirrorX) { buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + } - if (_mirrorY) + if (_mirrorY) { buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + } - if (_2DOnly) + if (_2DOnly) { buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + } - if (_3DOnly) + if (_3DOnly) { buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + } - if (_decoration) + if (_decoration) { buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + } - if (_editorSelected) + if (_editorSelected) { buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + } BaseClass::saveAsText(buffer, indent + 2); - if (complete) + if (complete) { buffer->putTextIndent(indent, "}\n\n"); + } return STATUS_OK; } @@ -304,7 +339,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple void BaseSubFrame::setDefaultRect() { if (_surface) { BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else BasePlatform::setRectEmpty(&_rect); + } else { + BasePlatform::setRectEmpty(&_rect); + } } @@ -349,8 +386,11 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS if (strcmp(name, "GetImage") == 0) { stack->correctParams(0); - if (!_surfaceFilename) stack->pushNULL(); - else stack->pushString(_surfaceFilename); + if (!_surfaceFilename) { + stack->pushNULL(); + } else { + stack->pushString(_surfaceFilename); + } return STATUS_OK; } @@ -359,31 +399,37 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); - if (Val->isNULL()) { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + if (val->isNULL()) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } delete[] _surfaceFilename; _surfaceFilename = NULL; stack->pushBool(true); } else { - const char *filename = Val->getString(); + const char *filename = val->getString(); if (DID_SUCCEED(setSurface(filename))) { setDefaultRect(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } } return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// ScValue *BaseSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new ScValue(_gameRef); + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -465,9 +511,9 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { else if (strcmp(name, "HotspotY") == 0) { _scValue->setInt(_hotspotY); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -535,9 +581,9 @@ bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "HotspotY") == 0) { _hotspotY = value->getInt(); return STATUS_OK; + } else { + return BaseScriptable::scSetProperty(name, value); } - - else return BaseScriptable::scSetProperty(name, value); } @@ -570,7 +616,9 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, _keepLoaded = keepLoaded; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -581,8 +629,11 @@ bool BaseSubFrame::setSurfaceSimple() { return STATUS_OK; } _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return STATUS_OK; - else return STATUS_FAILED; + if (_surface) { + return STATUS_OK; + } else { + return STATUS_FAILED; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index d8ba0cbbce..3d878b1346 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -52,7 +52,9 @@ BaseSurfaceStorage::~BaseSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceStorage::cleanup(bool warn) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + if (warn) { + _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + } delete _surfaces[i]; } _surfaces.clear(); @@ -67,7 +69,9 @@ bool BaseSurfaceStorage::initLoop() { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; + if (_surfaces[i]->_lifeTime <= 0) { + break; + } if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); @@ -105,17 +109,22 @@ BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK } if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_debugDebugMode) + if (filename) { + _gameRef->LOG(0, "Missing image: '%s'", filename); + } + if (_gameRef->_debugDebugMode) { return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - else + } else { return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } } BaseSurface *surface; surface = _gameRef->_renderer->createSurface(); - if (!surface) return NULL; + if (!surface) { + return NULL; + } if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { delete surface; @@ -171,18 +180,28 @@ int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { + return 1; + } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) { + return -1; + } // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; + if (s1->_valid && !s2->_valid) { + return -1; + } else if (!s1->_valid && s2->_valid) { + return 1; + } // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; + else if (s1->_lastUsedTime > s2->_lastUsedTime) { + return 1; + } else if (s1->_lastUsedTime < s2->_lastUsedTime) { + return -1; + } else { + return 0; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index eeaacd2063..7a78865552 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -57,7 +57,9 @@ bool BaseTransitionMgr::isReady() { ////////////////////////////////////////////////////////////////////////// bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return STATUS_OK; + if (_state != TRANS_MGR_READY) { + return STATUS_OK; + } if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { _state = TRANS_MGR_READY; @@ -82,7 +84,9 @@ bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { ////////////////////////////////////////////////////////////////////////// bool BaseTransitionMgr::update() { - if (isReady()) return STATUS_OK; + if (isReady()) { + return STATUS_OK; + } if (!_started) { _started = true; @@ -100,8 +104,9 @@ bool BaseTransitionMgr::update() { alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) + if (time > FADE_DURATION) { _state = TRANS_MGR_READY; + } } break; @@ -111,8 +116,9 @@ bool BaseTransitionMgr::update() { alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) + if (time > FADE_DURATION) { _state = TRANS_MGR_READY; + } } break; default: @@ -120,8 +126,9 @@ bool BaseTransitionMgr::update() { } if (isReady()) { - if (_preserveInteractive) + if (_preserveInteractive) { _gameRef->_interactive = _origInteractive; + } } return STATUS_OK; } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index bb8504d2f4..7d805aedb5 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -41,7 +41,9 @@ namespace WinterMute { void correctSlashes(char *fileName) { for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; + if (fileName[i] == '\\') { + fileName[i] = '/'; + } } } @@ -51,8 +53,9 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) // Absolute path: TODO: Add specific fallbacks here. - if (filename.contains(':')) + if (filename.contains(':')) { error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + } // Relative path: if (filename.contains('\\')) { @@ -132,7 +135,9 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { magic2 = file->readUint32LE(); bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) { + compressed = true; + } if (compressed) { uint32 dataOffset, compSize, uncompSize; diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 8282079c86..7bf635b858 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -61,7 +61,9 @@ public: Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); - if (!file) return NULL; + if (!file) { + return NULL; + } // TODO: Cleanup bool compressed = (_compressedLength != 0); diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index f2d2378c6a..b41ae3c1bd 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -64,7 +64,9 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); f->seek((int32)startPos, SEEK_SET); uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; + if (actuallyRead != toRead) { + return false; + } for (uint32 i = 0; i < toRead - 8; i++) if (!memcmp(buf + i, signature, 8)) { @@ -85,8 +87,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool _priority = 0; bool boundToExe = false; Common::SeekableReadStream *stream = file.createReadStream(); - if (!stream) + if (!stream) { return; + } if (searchSignature) { uint32 offset; if (!findPackageSignature(stream, &offset)) { @@ -121,7 +124,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool assert(hdr._numDirs == 1); for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(); - if (!pkg) return; + if (!pkg) { + return; + } pkg->_fsnode = file; pkg->_boundToExe = boundToExe; @@ -136,7 +141,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool delete[] pkgName; pkgName = NULL; - if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk + if (!hdr._masterIndex) { + pkg->_cd = 0; // override CD to fixed disk + } _packages.push_back(pkg); // read file entries @@ -242,8 +249,9 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common:: upcName.toUppercase(); Common::HashMap::const_iterator it; it = _files.find(upcName.c_str()); - if (it != _files.end()) + if (it != _files.end()) { return it->_value->createReadStream(); + } return NULL; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 0a0d0cac09..e067241589 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -53,7 +53,9 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { bool BaseSaveThumbFile::open(const Common::String &filename) { close(); - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { + return STATUS_FAILED; + } char *tempFilename = new char[strlen(filename.c_str()) - 8]; strcpy(tempFilename, filename.c_str() + 9); @@ -70,7 +72,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String slotFilename = pm->getFilenameForSlot(slot); - if (!pm) return STATUS_FAILED; + if (!pm) { + return STATUS_FAILED; + } if (DID_FAIL(pm->initLoad(slotFilename))) { delete pm; @@ -84,7 +88,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); _size = pm->_thumbnailDataSize; res = STATUS_OK; - } else res = STATUS_FAILED; + } else { + res = STATUS_FAILED; + } delete pm; return res; @@ -105,7 +111,9 @@ bool BaseSaveThumbFile::close() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return STATUS_FAILED; + if (!_data || _pos + size > _size) { + return STATUS_FAILED; + } memcpy(buffer, (byte *)_data + _pos, size); _pos += size; @@ -116,7 +124,9 @@ bool BaseSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) return STATUS_FAILED; + if (!_data) { + return STATUS_FAILED; + } uint32 newPos = 0; @@ -132,8 +142,11 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) { break; } - if (newPos > _size) return STATUS_FAILED; - else _pos = newPos; + if (newPos > _size) { + return STATUS_FAILED; + } else { + _pos = newPos; + } return STATUS_OK; } diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index d576b834a2..937557f4d7 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -187,7 +187,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { byte *buffer = gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; + if (buffer == NULL) { + return false; + } byte *WorkBuffer = buffer; @@ -195,8 +197,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { BaseParser parser(gameRef); bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { ret = true; + } delete[] buffer; return ret; diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index dd6c6da327..9cce8ca9ee 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -91,8 +91,9 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { str = AnsiString((char *)text); } - if (maxLength >= 0 && str.size() > (uint32)maxLength) + if (maxLength >= 0 && str.size() > (uint32)maxLength) { str = Common::String(str.c_str(), (uint32)maxLength); + } //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; @@ -106,9 +107,13 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; + if (maxLength == 0) { + return 0; + } - if (text == NULL || text[0] == '\0') return _tileHeight; + if (text == NULL || text[0] == '\0') { + return _tileHeight; + } AnsiString str; @@ -118,7 +123,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } else { str = AnsiString((char *)text); } - if (str.empty()) return 0; + if (str.empty()) { + return 0; + } int LineLength = 0; int RealLength = 0; @@ -135,11 +142,15 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli bool new_line = false; bool long_line = false; - if (draw) _gameRef->_renderer->startSpriteBatch(); + if (draw) { + _gameRef->_renderer->startSpriteBatch(); + } while (!done) { if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) _gameRef->_renderer->endSpriteBatch(); + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } return NumLines * _tileHeight; } @@ -170,10 +181,14 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli LineLength += getCharWidth(str[index]); RealLength = LineLength; } - } else LineLength += getCharWidth(str[index]); + } else { + LineLength += getCharWidth(str[index]); + } if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; + if (end < 0) { + done = true; + } int StartX; switch (align) { case TAL_CENTER: @@ -190,12 +205,16 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli break; } for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); + if (draw) { + drawChar(str[i], StartX, y); + } StartX += getCharWidth(str[i]); } y += _tileHeight; last_end = end; - if (long_line) end--; + if (long_line) { + end--; + } start = end + 2; index = end + 1; LineLength = 0; @@ -205,7 +224,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } } - if (draw) _gameRef->_renderer->endSpriteBatch(); + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } return NumLines * _tileHeight; } @@ -213,7 +234,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli ////////////////////////////////////////////////////////////////////// void BaseFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; + if (_fontextFix) { + c--; + } int row, col; @@ -223,8 +246,11 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { Rect32 rect; /* l t r b */ int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; + if (_wholeCell) { + tileWidth = _tileWidth; + } else { + tileWidth = _widths[c]; + } BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; @@ -237,7 +263,9 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { handled = true; } } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); + if (!handled && _subframe) { + _subframe->_surface->displayTrans(x, y, rect); + } } @@ -253,7 +281,9 @@ bool BaseFontBitmap::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + } delete[] buffer; @@ -408,8 +438,11 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { if (surfaceFile != NULL && !_sprite) { _subframe = new BaseSubFrame(_gameRef); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); + if (custoTrans) { + _subframe->setSurface(surfaceFile, false, r, g, b); + } else { + _subframe->setSurface(surfaceFile); + } } @@ -425,25 +458,32 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { // do we need to modify widths? if (expandWidth != 0) { for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; + int newWidth = (int)_widths[i] + expandWidth; + if (newWidth < 0) { + newWidth = 0; + } - _widths[i] = (byte)NewWidth; + _widths[i] = (byte)newWidth; } } // handle space character uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; + if (_fontextFix) { + spaceChar--; + } - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { + if (spaceWidth != 0) { + _widths[spaceChar] = spaceWidth; + } else { if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; } } } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + for (i = lastWidth; i < NUM_CHARACTERS; i++) { + _widths[i] = default_width; + } } @@ -463,10 +503,11 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER(_widthsFrame)); - if (persistMgr->getIsSaving()) + if (persistMgr->getIsSaving()) { persistMgr->putBytes(_widths, sizeof(_widths)); - else + } else { persistMgr->getBytes(_widths, sizeof(_widths)); + } persistMgr->transfer(TMEMBER(_fontextFix)); @@ -479,7 +520,9 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int BaseFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; + if (_fontextFix) { + index--; + } return _widths[index]; } @@ -495,8 +538,12 @@ bool BaseFontBitmap::getWidths() { } } } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + if (surf == NULL && _subframe) { + surf = _subframe->_surface; + } + if (!surf || DID_FAIL(surf->startPixelOp())) { + return STATUS_FAILED; + } for (int i = 0; i < NUM_CHARACTERS; i++) { @@ -507,14 +554,18 @@ bool BaseFontBitmap::getWidths() { int minCol = -1; for (int row = 0; row < _tileHeight; row++) { for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) { + continue; + } if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; minCol = MAX(col, minCol); break; } } - if (minCol == _tileWidth - 1) break; + if (minCol == _tileWidth - 1) { + break; + } } _widths[i] = minCol + 1; diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 84c80c73cb..8b4fa74181 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -52,7 +52,9 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + if (warn) { + _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + } delete _fonts[i]; } _fonts.removeAll(); @@ -70,7 +72,9 @@ bool BaseFontStorage::initLoop() { ////////////////////////////////////////////////////////////////////////// BaseFont *BaseFontStorage::addFont(const char *filename) { - if (!filename) return NULL; + if (!filename) { + return NULL; + } for (int i = 0; i < _fonts.getSize(); i++) { if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { @@ -104,7 +108,9 @@ BaseFont *BaseFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::removeFont(BaseFont *font) { - if (!font) return STATUS_FAILED; + if (!font) { + return STATUS_FAILED; + } for (int i = 0; i < _fonts.getSize(); i++) { if (_fonts[i] == font) { @@ -123,7 +129,9 @@ bool BaseFontStorage::removeFont(BaseFont *font) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(false); + if (!persistMgr->getIsSaving()) { + cleanup(false); + } persistMgr->transfer(TMEMBER(_gameRef)); _fonts.persist(persistMgr); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 0a97370cb7..420df58b74 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -57,7 +57,9 @@ BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _fallbackFont = NULL; _deletableFont = NULL; - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } #if 0 _fTFace = NULL; @@ -98,7 +100,9 @@ BaseFontTT::~BaseFontTT(void) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::clearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; + if (_cachedTexts[i]) { + delete _cachedTexts[i]; + } _cachedTexts[i] = NULL; } } @@ -109,12 +113,16 @@ void BaseFontTT::initLoop() { if (_gameRef->_constrainedMemory) { // purge all cached images not used in the last frame for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; + if (_cachedTexts[i] == NULL) { + continue; + } if (!_cachedTexts[i]->_marked) { delete _cachedTexts[i]; _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; + } else { + _cachedTexts[i]->_marked = false; + } } } } @@ -123,11 +131,15 @@ void BaseFontTT::initLoop() { int BaseFontTT::getTextWidth(byte *text, int maxLength) { WideString textStr; - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; @@ -140,8 +152,11 @@ int BaseFontTT::getTextWidth(byte *text, int maxLength) { int BaseFontTT::getTextHeight(byte *text, int width) { WideString textStr; - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } int textWidth, textHeight; @@ -153,7 +168,9 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; + if (text == NULL || strcmp((char *)text, "") == 0) { + return; + } WideString textStr = (char *)text; @@ -161,8 +178,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } //text = text.substr(0, MaxLength); // TODO: Remove BaseRenderer *renderer = _gameRef->_renderer; @@ -199,7 +217,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); if (surface) { // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + if (_cachedTexts[minIndex] != NULL) { + delete _cachedTexts[minIndex]; + } _cachedTexts[minIndex] = new BaseCachedTTFontText; _cachedTexts[minIndex]->_surface = surface; @@ -261,10 +281,11 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) // We actually have a TTF + if (_deletableFont) { // We actually have a TTF surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - else // We are using a fallback, they can't do 32bpp + } else { // We are using a fallback, they can't do 32bpp surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + } uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; @@ -309,7 +330,9 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; + if (!glyph) { + continue; + } textOffset = MAX(textOffset, glyph->GetBearingY()); } @@ -322,10 +345,14 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; + if (!glyph) { + continue; + } float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + if (prevChar != L'\0') { + kerning = GetKerning(prevChar, ch); + } posX += (int)kerning; @@ -381,7 +408,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, warning("BaseFontTT::BlitSurface - not ported yet"); #if 0 for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) { + continue; + } uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; @@ -391,7 +420,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, uint32 *tgtBuf32 = (uint32 *)tgtBuf; for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) { + continue; + } tgtBuf32[x + targetRect->x] = srcBuf32[x]; } @@ -417,7 +448,9 @@ bool BaseFontTT::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + } delete[] buffer; @@ -468,7 +501,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { } buffer = (byte *)params; - uint32 BaseColor = 0x00000000; + uint32 baseColor = 0x00000000; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -507,23 +540,24 @@ bool BaseFontTT::loadBuffer(byte *buffer) { case TOKEN_COLOR: { int r, g, b; parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + baseColor = BYTETORGBA(r, g, b, RGBCOLGetA(baseColor)); } break; case TOKEN_ALPHA: { int a; parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + baseColor = BYTETORGBA(RGBCOLGetR(baseColor), RGBCOLGetG(baseColor), RGBCOLGetB(baseColor), a); } break; case TOKEN_LAYER: { - BaseTTFontLayer *Layer = new BaseTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; + BaseTTFontLayer *layer = new BaseTTFontLayer; + if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) { + _layers.add(layer); + } else { + delete layer; + layer = NULL; cmd = PARSERR_TOKENNOTFOUND; } } @@ -538,12 +572,14 @@ bool BaseFontTT::loadBuffer(byte *buffer) { // create at least one layer if (_layers.getSize() == 0) { - BaseTTFontLayer *Layer = new BaseTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->_color = baseColor; + _layers.add(layer); } - if (!_fontFile) BaseUtils::setString(&_fontFile, "arial.ttf"); + if (!_fontFile) { + BaseUtils::setString(&_fontFile, "arial.ttf"); + } return initFont(); } @@ -587,8 +623,11 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { break; } } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; + if (cmd != PARSERR_EOF) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } } @@ -609,7 +648,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving()) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + for (int i = 0; i < numLayers; i++) { + _layers[i]->persist(persistMgr); + } } else { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); @@ -621,7 +662,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { } if (!persistMgr->getIsSaving()) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } _fallbackFont = _font = _deletableFont = NULL; } @@ -636,7 +679,9 @@ void BaseFontTT::afterLoad() { ////////////////////////////////////////////////////////////////////////// bool BaseFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; + if (!_fontFile) { + return STATUS_FAILED; + } Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 8a8459b070..f8c5eee74d 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -67,7 +67,9 @@ private: } virtual ~BaseCachedTTFontText() { - if (_surface) delete _surface; + if (_surface) { + delete _surface; + } } }; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 09a78a748b..571deed793 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -53,15 +53,11 @@ BaseImage::BaseImage(BaseFileManager *fileManager) { ////////////////////////////////////////////////////////////////////// BaseImage::~BaseImage() { - /* delete _bitmap; */ delete _decoder; if (_deletableSurface) { _deletableSurface->free(); } delete _deletableSurface; -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); -#endif } bool BaseImage::loadFile(const Common::String &filename) { @@ -82,7 +78,9 @@ bool BaseImage::loadFile(const Common::String &filename) { } _filename = filename; Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) return false; + if (!file) { + return false; + } _decoder->loadStream(*file); _surface = _decoder->getSurface(); @@ -93,7 +91,9 @@ bool BaseImage::loadFile(const Common::String &filename) { } byte BaseImage::getAlphaAt(int x, int y) const { - if (!_surface) return 0xFF; + if (!_surface) { + return 0xFF; + } uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; _surface->format.colorToARGB(color, a, r, g, b); @@ -107,12 +107,6 @@ void BaseImage::copyFrom(const Graphics::Surface *surface) { ////////////////////////////////////////////////////////////////////////// bool BaseImage::saveBMPFile(const char *filename) const { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; - else return STATUS_FAILED; -#endif warning("BaseImage::saveBMPFile - stubbed"); // TODO return false; } @@ -121,10 +115,16 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { #if 0 - if (!_bitmap) return STATUS_FAILED; + if (!_bitmap) { + return STATUS_FAILED; + } - if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + if (newWidth == 0) { + NewWidth = FreeImage_GetWidth(_bitmap); + } + if (newHeight == 0) { + NewHeight = FreeImage_GetHeight(_bitmap); + } FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); @@ -132,7 +132,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { FreeImage_Unload(_bitmap); _bitmap = newImg; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } #endif return false; } @@ -140,7 +142,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { - if (!_surface) return false; + if (!_surface) { + return false; + } /* The following is just copied over and inverted to write-ops from the BMP-decoder */ stream->writeByte('B'); @@ -164,8 +168,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { stream->writeUint32LE(width); stream->writeUint32LE((uint32)height); - if (width == 0 || height == 0) + if (width == 0 || height == 0) { return false; + } if (height < 0) { warning("Right-side up bitmaps not supported"); @@ -194,8 +199,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); // BGRA for 24bpp - if (bitsPerPixel == 24) + if (bitsPerPixel == 24) { format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + } Graphics::Surface *surface = _surface->convertTo(format); @@ -219,36 +225,22 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { surface->free(); delete surface; return true; - - //*BufferSize = 0; -#if 0 - FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); - uint32 size; - byte *data; - FreeImage_AcquireMemory(fiMem, &data, &size); - - - byte *Buffer = new byte[size]; - memcpy(Buffer, data, size); - - FreeImage_CloseMemory(fiMem); - - if (BufferSize) *BufferSize = size; - - return Buffer; -#endif - return false; } ////////////////////////////////////////////////////////////////////////// bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { #if 0 - if (_bitmap) FreeImage_Unload(_bitmap); + if (_bitmap) { + FreeImage_Unload(_bitmap); + } - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + if (NewWidth == 0) { + NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + } + if (NewHeight == 0) { + NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + } _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); #endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 66b7f513bf..168aa75d91 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -89,13 +89,19 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { yy = height - yy; } - if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) { + return _rectList[i]->_owner; + } } // region else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) { + return _rectList[i]->_owner; + } } - } else return _rectList[i]->_owner; + } else { + return _rectList[i]->_owner; + } } } @@ -208,10 +214,18 @@ bool BaseRenderer::unclipCursor() { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::pointInViewport(Point32 *p) { - if (p->x < _drawOffsetX) return false; - if (p->y < _drawOffsetY) return false; - if (p->x > _drawOffsetX + _width) return false; - if (p->y > _drawOffsetY + _height) return false; + if (p->x < _drawOffsetX) { + return false; + } + if (p->y < _drawOffsetY) { + return false; + } + if (p->x > _drawOffsetX + _width) { + return false; + } + if (p->y > _drawOffsetY + _height) { + return false; + } return true; } diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 684236ac7f..68e3e3d26c 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -54,7 +54,9 @@ BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseSurface::~BaseSurface() { - if (_pixelOpReady) endPixelOp(); + if (_pixelOpReady) { + endPixelOp(); + } } @@ -139,7 +141,9 @@ bool BaseSurface::prepareToDraw() { if (!_valid) { //_gameRef->LOG(0, "Reviving: %s", _filename); return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 43cf66d053..e465194e58 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -44,10 +44,12 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) + if (mirrorX) { _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) + } + if (mirrorY) { _mirror |= TransparentSurface::FLIP_H; + } if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -113,8 +115,12 @@ BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; #if 0 - if (_renderer) SDL_DestroyRenderer(_renderer); - if (_win) SDL_DestroyWindow(_win); + if (_renderer) { + SDL_DestroyRenderer(_renderer); + } + if (_win) { + SDL_DestroyWindow(_win); + } SDL_Quit(); #endif } @@ -212,7 +218,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _realWidth, _realHeight, flags); - if (!_win) return STATUS_FAILED; + if (!_win) { + return STATUS_FAILED; + } #endif g_system->showMouse(false); @@ -226,7 +234,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { #if 0 _renderer = SDL_CreateRenderer(_win, -1, 0); - if (!_renderer) return STATUS_FAILED; + if (!_renderer) { + return STATUS_FAILED; + } #endif _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; @@ -273,8 +283,9 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) + if (!_disableDirtyRects) { return STATUS_OK; + } if (!rect) { rect = &_renderRect; } @@ -320,9 +331,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) + if (_disableDirtyRects) { _renderSurface->fillRect(fillRect, col); - else { + } else { setAlphaMod(a); setColorMod(r, g, b); Graphics::Surface surf; @@ -468,8 +479,9 @@ void BaseRenderOSystem::drawTickets() { it++; } } - if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { return; + } // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; @@ -518,8 +530,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R } src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) + if (doDelete) { delete clipRect; + } } ////////////////////////////////////////////////////////////////////////// @@ -566,9 +579,13 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { SDL_RenderGetViewport(_renderer, &viewport); SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) return NULL; + if (!surface) { + return NULL; + } - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { + return NULL; + } FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -643,7 +660,9 @@ void BaseRenderOSystem::dumpData(const char *filename) { warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO #if 0 FILE *f = fopen(filename, "wt"); - if (!f) return; + if (!f) { + return; + } BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; @@ -652,8 +671,12 @@ void BaseRenderOSystem::dumpData(const char *filename) { fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; - if (!Surf->_filename) continue; - if (!Surf->_valid) continue; + if (!Surf->_filename) { + continue; + } + if (!Surf->_valid) { + continue; + } fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 36213dfde1..4b680e2793 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -107,11 +107,14 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed _ckGreen = ckGreen; _ckBlue = ckBlue; - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) { _lifeTime = lifeTime; + } _keepLoaded = keepLoaded; - if (_keepLoaded) _lifeTime = -1; + if (_keepLoaded) { + _lifeTime = -1; + } return STATUS_OK; } @@ -201,7 +204,9 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { delete[] _alphaMask; _alphaMask = NULL; - if (!surface) return; + if (!surface) { + return; + } #if 0 SDL_LockSurface(surface); #endif @@ -224,11 +229,14 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { surface->format.colorToARGB(pixel, a, r, g, b); //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) { a = 0; + } _alphaMask[y * surface->w + x] = a; - if (a < 255) hasTransparency = true; + if (a < 255) { + hasTransparency = true; + } } } #if 0 @@ -331,7 +339,9 @@ bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { int width, height; //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + if (X < 0 || X >= width || Y < 0 || Y >= height) { + return true; + } StartPixelOp(); @@ -371,10 +381,15 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { //SDL_QueryTexture(_texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + if (X < 0 || X >= width || Y < 0 || Y >= height) { + return true; + } - if (!_alphaMask) return false; - else return _alphaMask[Y * width + X] <= 128; + if (!_alphaMask) { + return false; + } else { + return _alphaMask[Y * width + X] <= 128; + } #endif return false; /* @@ -447,8 +462,9 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo finishLoad(); } - if (renderer->_forceAlphaColor != 0) + if (renderer->_forceAlphaColor != 0) { alpha = renderer->_forceAlphaColor; + } // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. @@ -469,10 +485,11 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); - if (AlphaDisable) + if (alphaDisable) { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - else + } else { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); + } #endif // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 1ddefec610..b16fb83abf 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -116,11 +116,15 @@ PartEmitter::~PartEmitter(void) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; + if (!filename) { + return STATUS_FAILED; + } // do we already have the file? for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + if (scumm_stricmp(filename, _sprites[i]) == 0) { + return STATUS_OK; + } } // check if file exists @@ -128,7 +132,9 @@ bool PartEmitter::addSprite(const char *filename) { if (!File) { _gameRef->LOG(0, "Sprite '%s' not found", filename); return STATUS_FAILED; - } else _gameRef->_fileManager->closeFile(File); + } else { + _gameRef->_fileManager->closeFile(File); + } char *Str = new char[strlen(filename) + 1]; strcpy(Str, filename); @@ -151,24 +157,37 @@ bool PartEmitter::removeSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; + if (!particle) { + return STATUS_FAILED; + } + if (_sprites.getSize() == 0) { + return STATUS_FAILED; + } int posX = BaseUtils::randomInt(_posX, _posX + _width); int posY = BaseUtils::randomInt(_posY, _posY + _height); float posZ = BaseUtils::randomFloat(0.0f, 100.0f); float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = BaseUtils::randomFloat(_velocity1, _velocity2); + if (_velocityZBased) { + velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + } else { + velocity = BaseUtils::randomFloat(_velocity1, _velocity2); + } float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = BaseUtils::randomFloat(_scale1, _scale2); + if (_scaleZBased) { + scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + } else { + scale = BaseUtils::randomFloat(_scale1, _scale2); + } int lifeTime; - if (_lifeTimeZBased) lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); - else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); + if (_lifeTimeZBased) { + lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); + } else { + lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); + } float angle = BaseUtils::randomAngle(_angle1, _angle2); int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); @@ -220,14 +239,20 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 particle->fadeIn(currentTime, _fadeInTime); - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; + if (particle->_isDead) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool PartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + if (!_running) { + return STATUS_OK; + } else { + return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + } } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +262,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->update(this, currentTime, timerDelta); - if (!_particles[i]->_isDead) numLive++; + if (!_particles[i]->_isDead) { + numLive++; + } } @@ -263,8 +290,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } PartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { + if (firstDeadIndex >= 0) { + particle = _particles[firstDeadIndex]; + } else { particle = new PartParticle(_gameRef); _particles.add(particle); } @@ -274,12 +302,15 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { toGen--; } } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) { sortParticlesByZ(); + } // we actually generated some particles and we're not in fast-forward mode if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + if (_owner && _emitEvent) { + _owner->applyEvent(_emitEvent); + } } } @@ -288,17 +319,23 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::display(BaseRegion *region) { - if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + if (_sprites.getSize() <= 1) { + _gameRef->_renderer->startSpriteBatch(); + } for (int i = 0; i < _particles.getSize(); i++) { if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { + continue; + } } _particles[i]->display(this); } - if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + if (_sprites.getSize() <= 1) { + _gameRef->_renderer->endSpriteBatch(); + } return STATUS_OK; } @@ -339,9 +376,13 @@ int PartEmitter::compareZ(const void *obj1, const void *obj2) { PartParticle *p1 = *(PartParticle **)obj1; PartParticle *p2 = *(PartParticle **)obj2; - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; + if (p1->_posZ < p2->_posZ) { + return -1; + } else if (p1->_posZ > p2->_posZ) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -385,7 +426,9 @@ PartForce *PartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { PartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; + if (!force) { + return STATUS_FAILED; + } force->_type = type; force->_pos = Vector2(posX, posY); @@ -554,9 +597,9 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushBool(DID_SUCCEED(removeForce(forceName))); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// @@ -745,7 +788,9 @@ ScValue *PartEmitter::scGetProperty(const char *name) { else if (strcmp(name, "NumLiveParticles") == 0) { int numAlive = 0; for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; + if (_particles[i] && !_particles[i]->_isDead) { + numAlive++; + } } _scValue->setInt(numAlive); return _scValue; @@ -822,12 +867,15 @@ ScValue *PartEmitter::scGetProperty(const char *name) { // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); + if (!_emitEvent) { + _scValue->setNULL(); + } else { + _scValue->setString(_emitEvent); + } return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -978,8 +1026,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha1") == 0) { _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; + if (_alpha1 < 0) { + _alpha1 = 0; + } + if (_alpha1 > 255) { + _alpha1 = 255; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -987,8 +1039,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha2") == 0) { _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; + if (_alpha2 < 0) { + _alpha2 = 0; + } + if (_alpha2 > 255) { + _alpha2 = 255; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1080,11 +1136,13 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->isNULL()) BaseUtils::setString(&_emitEvent, value->getString()); + if (!value->isNULL()) { + BaseUtils::setString(&_emitEvent, value->getString()); + } return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index b63a82f926..4a5239edfe 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -99,24 +99,29 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + } else { + _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + } return STATUS_OK; } else if (_state == PARTICLE_FADEOUT) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _isDead = true; return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + } else { + _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + } return STATUS_OK; } else { // time is up if (_lifeTime > 0) { if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) + if (emitter->_fadeOutTime > 0) { fadeOut(currentTime, emitter->_fadeOutTime); - else + } else { _isDead = true; + } } } @@ -125,10 +130,13 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!BasePlatform::ptInRect(&_border, p)) + if (!BasePlatform::ptInRect(&_border, p)) { fadeOut(currentTime, emitter->_fadeOutTime); + } + } + if (_state != PARTICLE_NORMAL) { + return STATUS_OK; } - if (_state != PARTICLE_NORMAL) return STATUS_OK; // update alpha if (_lifeTime > 0) { @@ -166,13 +174,15 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer _rotation = BaseUtils::normalizeAngle(_rotation); // update scale - if (_exponentialGrowth) + if (_exponentialGrowth) { _scale += _scale / 100.0f * _growthRate * elapsedTime; - else + } else { _scale += _growthRate * elapsedTime; + } - if (_scale <= 0.0f) + if (_scale <= 0.0f) { _isDead = true; + } return STATUS_OK; @@ -181,8 +191,12 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer ////////////////////////////////////////////////////////////////////////// bool PartParticle::display(PartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; + if (!_sprite) { + return STATUS_FAILED; + } + if (_isDead) { + return STATUS_OK; + } _sprite->GetCurrentFrame(); return _sprite->display(_pos.x, _pos.y, diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index a519da5832..4deeb0bf39 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -249,17 +249,23 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip _threadEvent = NULL; _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); + if (_filename) { + strcpy(_filename, filename); + } _buffer = new byte [size]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, buffer, size); _bufferSize = size; bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // establish global variables table _globals = new ScValue(_gameRef); @@ -277,22 +283,30 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event _thread = true; _methodThread = false; _threadEvent = new char[strlen(eventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, eventName); + if (_threadEvent) { + strcpy(_threadEvent, eventName); + } // copy filename _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); + if (_filename) { + strcpy(_filename, original->_filename); + } // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // copy globals _globals = original->_globals; @@ -317,29 +331,39 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event ////////////////////////////////////////////////////////////////////////// bool ScScript::createMethodThread(ScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return STATUS_FAILED; + if (ip == 0) { + return STATUS_FAILED; + } cleanup(); _thread = true; _methodThread = true; _threadEvent = new char[strlen(methodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, methodName); + if (_threadEvent) { + strcpy(_threadEvent, methodName); + } // copy filename _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); + if (_filename) { + strcpy(_filename, original->_filename); + } // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // copy globals _globals = original->_globals; @@ -360,17 +384,25 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { ////////////////////////////////////////////////////////////////////////// void ScScript::cleanup() { - if (_buffer) delete[] _buffer; + if (_buffer) { + delete[] _buffer; + } _buffer = NULL; - if (_filename) delete[] _filename; + if (_filename) { + delete[] _filename; + } _filename = NULL; - if (_symbols) delete[] _symbols; + if (_symbols) { + delete[] _symbols; + } _symbols = NULL; _numSymbols = 0; - if (_globals && !_thread) delete _globals; + if (_globals && !_thread) { + delete _globals; + } _globals = NULL; delete _scopeStack; @@ -385,22 +417,30 @@ void ScScript::cleanup() { delete _stack; _stack = NULL; - if (_functions) delete[] _functions; + if (_functions) { + delete[] _functions; + } _functions = NULL; _numFunctions = 0; - if (_methods) delete[] _methods; + if (_methods) { + delete[] _methods; + } _methods = NULL; _numMethods = 0; - if (_events) delete[] _events; + if (_events) { + delete[] _events; + } _events = NULL; _numEvents = 0; if (_externals) { for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete[] _externals[i].params; + if (_externals[i].nu_params > 0) { + delete[] _externals[i].params; + } } delete[] _externals; } @@ -423,7 +463,7 @@ void ScScript::cleanup() { _waitScript = NULL; _parentScript = NULL; // ref only - + delete _scriptStream; } @@ -460,7 +500,9 @@ double ScScript::getFloat() { ////////////////////////////////////////////////////////////////////////// char *ScScript::getString() { char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; + while (*(char *)(_buffer + _iP) != '\0') { + _iP++; + } _iP++; // string terminator _scriptStream->seek(_iP); @@ -489,12 +531,14 @@ bool ScScript::executeInstruction() { dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } } break; @@ -508,8 +552,9 @@ bool ScScript::executeInstruction() { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } } break; } @@ -521,14 +566,20 @@ bool ScScript::executeInstruction() { _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) { + _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + } else { + _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; + if (_numEvents == 0 && _numMethods == 0) { + _state = SCRIPT_FINISHED; + } else { + _state = SCRIPT_PERSISTENT; + } } } @@ -557,7 +608,9 @@ bool ScScript::executeInstruction() { strcpy(MethodName, str); ScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + if (var->_type == VAL_VARIABLE_REF) { + var = var->_valRef; + } bool res = STATUS_FAILED; bool TriedNative = false; @@ -612,7 +665,9 @@ bool ScScript::executeInstruction() { */ else { res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (var->_type == VAL_NATIVE && !TriedNative) { + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } if (DID_FAIL(res)) { _stack->correctParams(0); @@ -631,7 +686,9 @@ bool ScScript::executeInstruction() { TExternalFunction *f = getExternal(_symbols[SymbolIndex]); if (f) { externalCall(_stack, _thisStack, f); - } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + } else { + _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + } break; } @@ -639,8 +696,11 @@ bool ScScript::executeInstruction() { _operand->setNULL(); _scopeStack->push(_operand); - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) { + _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + } else { + _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } break; @@ -663,7 +723,9 @@ bool ScScript::executeInstruction() { if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->setReference(var); _stack->push(_operand); - } else _stack->push(var); + } else { + _stack->push(var); + } break; } @@ -683,15 +745,19 @@ bool ScScript::executeInstruction() { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); } else { - if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->setValue(val); - else { + if (val->getType() == VAL_VARIABLE_REF) { + val = val->_valRef; + } + if (val->_type == VAL_NATIVE) { + var->setValue(val); + } else { var->copy(val); } } - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } } break; @@ -740,8 +806,11 @@ bool ScScript::executeInstruction() { case II_PUSH_BY_EXP: { str = _stack->pop()->getString(); ScValue *val = _stack->pop()->getProp(str); - if (val) _stack->push(val); - else _stack->pushNULL(); + if (val) { + _stack->push(val); + } else { + _stack->pushNULL(); + } break; } @@ -754,10 +823,13 @@ bool ScScript::executeInstruction() { if (val == NULL) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); - } else var->setProp(str, val); + } else { + var->setProp(str, val); + } - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + } break; } @@ -781,7 +853,9 @@ bool ScScript::executeInstruction() { if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { - if (!val->getBool()) _iP = dw; + if (!val->getBool()) { + _iP = dw; + } } break; } @@ -790,17 +864,19 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) + if (op1->isNULL() || op2->isNULL()) { _operand->setNULL(); - else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; strcpy(tempStr, op1->getString()); strcat(tempStr, op2->getString()); _operand->setString(tempStr); delete[] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() + op2->getInt()); - else _operand->setFloat(op1->getFloat() + op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() + op2->getFloat()); + } _stack->push(_operand); @@ -810,11 +886,13 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) + if (op1->isNULL() || op2->isNULL()) { _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() - op2->getInt()); - else _operand->setFloat(op1->getFloat() - op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() - op2->getFloat()); + } _stack->push(_operand); @@ -824,10 +902,13 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + if (op1->isNULL() || op2->isNULL()) { + _operand->setNULL(); + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() * op2->getInt()); - else _operand->setFloat(op1->getFloat() * op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() * op2->getFloat()); + } _stack->push(_operand); @@ -837,11 +918,15 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getFloat() == 0.0f) + if (op2->getFloat() == 0.0f) { runtimeError("Division by zero."); + } - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); - else _operand->setFloat(op1->getFloat() / op2->getFloat()); + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) { + _operand->setNULL(); + } else { + _operand->setFloat(op1->getFloat() / op2->getFloat()); + } _stack->push(_operand); @@ -851,12 +936,15 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getInt() == 0) + if (op2->getInt() == 0) { runtimeError("Division by zero."); + } - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) { _operand->setNULL(); - else _operand->setInt(op1->getInt() % op2->getInt()); + } else { + _operand->setInt(op1->getInt() % op2->getInt()); + } _stack->push(_operand); @@ -865,8 +953,11 @@ bool ScScript::executeInstruction() { case II_NOT: op1 = _stack->pop(); //if (op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) _operand->setBool(true); - else _operand->setBool(!op1->getBool()); + if (op1->isNULL()) { + _operand->setBool(true); + } else { + _operand->setBool(!op1->getBool()); + } _stack->push(_operand); break; @@ -1060,8 +1151,9 @@ bool ScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getFuncPos(const char *name) { for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) + if (strcmp(name, _functions[i].name) == 0) { return _functions[i].pos; + } } return 0; } @@ -1070,8 +1162,9 @@ uint32 ScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getMethodPos(const char *name) { for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) + if (strcmp(name, _methods[i].name) == 0) { return _methods[i].pos; + } } return 0; } @@ -1083,20 +1176,23 @@ ScValue *ScScript::getVar(char *name) { // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) + if (_scopeStack->getTop()->propExists(name)) { ret = _scopeStack->getTop()->getProp(name); + } } // script globals if (ret == NULL) { - if (_globals->propExists(name)) + if (_globals->propExists(name)) { ret = _globals->getProp(name); + } } // engine globals if (ret == NULL) { - if (_engine->_globals->propExists(name)) + if (_engine->_globals->propExists(name)) { ret = _engine->_globals->getProp(name); + } } if (ret == NULL) { @@ -1162,7 +1258,9 @@ bool ScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); - } else _state = SCRIPT_FINISHED; + } else { + _state = SCRIPT_FINISHED; + } return STATUS_OK; @@ -1188,8 +1286,9 @@ void ScScript::runtimeError(const char *fmt, ...) { _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); _gameRef->LOG(0, " %s", buff); - if (!_gameRef->_suppressScriptErrors) + if (!_gameRef->_suppressScriptErrors) { _gameRef->quickMessage("Script runtime error. View log for details."); + } } @@ -1217,8 +1316,8 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { initTables(); } else { _buffer = NULL; - _scriptStream = NULL; - } + _scriptStream = NULL; + } } persistMgr->transfer(TMEMBER(_callStack)); @@ -1249,7 +1348,9 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_unbreakable)); persistMgr->transfer(TMEMBER(_parentScript)); - if (!persistMgr->getIsSaving()) _tracingMode = false; + if (!persistMgr->getIsSaving()) { + _tracingMode = false; + } return STATUS_OK; } @@ -1260,7 +1361,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); - if (!pos) return NULL; + if (!pos) { + return NULL; + } ScScript *thread = new ScScript(_gameRef, _engine); if (thread) { @@ -1274,7 +1377,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) delete thread; return NULL; } - } else return NULL; + } else { + return NULL; + } } @@ -1282,7 +1387,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + if (scumm_stricmp(name, _events[i].name) == 0) { + return _events[i].pos; + } } return 0; } @@ -1307,7 +1414,9 @@ bool ScScript::pause() { return STATUS_FAILED; } - if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + if (!_freezable || _state == SCRIPT_PERSISTENT) { + return STATUS_OK; + } _origState = _state; _state = SCRIPT_PAUSED; @@ -1318,7 +1427,9 @@ bool ScScript::pause() { ////////////////////////////////////////////////////////////////////////// bool ScScript::resume() { - if (_state != SCRIPT_PAUSED) return STATUS_OK; + if (_state != SCRIPT_PAUSED) { + return STATUS_OK; + } _state = _origState; return STATUS_OK; @@ -1328,8 +1439,9 @@ bool ScScript::resume() { ////////////////////////////////////////////////////////////////////////// ScScript::TExternalFunction *ScScript::getExternal(char *name) { for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) + if (strcmp(name, _externals[i].name) == 0) { return &_externals[i]; + } } return NULL; } @@ -1354,7 +1466,9 @@ bool ScScript::copyParameters(ScStack *stack) { } _stack->pushInt(NumParams); - for (i = 0; i < NumParams; i++) stack->pop(); + for (i = 0; i < NumParams; i++) { + stack->pop(); + } return STATUS_OK; } @@ -1364,8 +1478,9 @@ bool ScScript::copyParameters(ScStack *stack) { bool ScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.getSize(); i++) { ScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { scr->finish(true); + } } return STATUS_OK; } @@ -1385,9 +1500,13 @@ const char *ScScript::dbgGetFilename() { ////////////////////////////////////////////////////////////////////////// bool ScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else client->onScriptInit(this); + if (_methodThread) { + client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + } else if (_thread) { + client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + } else { + client->onScriptInit(this); + } return dbgSendVariables(client); return STATUS_OK; @@ -1421,8 +1540,11 @@ int ScScript::dbgGetNumBreakpoints() { ////////////////////////////////////////////////////////////////////////// int ScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; - else return -1; + if (index >= 0 && index < _breakpoints.getSize()) { + return _breakpoints[index]; + } else { + return -1; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 792dfd4589..356617094d 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -47,8 +47,11 @@ IMPLEMENT_PERSISTENT(ScEngine, true) ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); - if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); - else _gameRef->LOG(0, " Script compiler is NOT available"); + if (_compilerAvailable) { + _gameRef->LOG(0, " Script compiler bound successfuly"); + } else { + _gameRef->LOG(0, " Script compiler is NOT available"); + } _globals = new ScValue(_gameRef); @@ -68,7 +71,9 @@ ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { } // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + _cachedScripts[i] = NULL; + } _currentScript = NULL; @@ -99,7 +104,9 @@ ScEngine::~ScEngine() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::cleanup() { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } delete _scripts[i]; _scripts.removeAt(i); i--; @@ -143,7 +150,9 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { // get script from cache compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) return NULL; + if (!compBuffer) { + return NULL; + } // add new script ScScript *script = new ScScript(_gameRef, this); @@ -155,8 +164,11 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { } else { // publish the "self" pseudo-variable ScValue val(_gameRef); - if (owner)val.setNative(owner, true); - else val.setNULL(); + if (owner) { + val.setNative(owner, true); + } else { + val.setNULL(); + } script->_globals->setProp("self", &val); script->_globals->setProp("this", &val); @@ -226,7 +238,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig } } - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + if (_cachedScripts[index] != NULL) { + delete _cachedScripts[index]; + } _cachedScripts[index] = cachedScript; ret = cachedScript->_buffer; @@ -244,8 +258,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig ////////////////////////////////////////////////////////////////////////// bool ScEngine::tick() { - if (_scripts.getSize() == 0) + if (_scripts.getSize() == 0) { return STATUS_OK; + } // resolve waiting scripts @@ -267,16 +282,24 @@ bool ScEngine::tick() { if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); - } else _scripts[i]->finish(); + if (_scripts[i]->_waitObject->isReady()) { + _scripts[i]->run(); + } + } else { + _scripts[i]->finish(); + } break; } case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= g_system->getMillis()) { + _scripts[i]->run(); + } } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= _gameRef->_timer) { + _scripts[i]->run(); + } } break; } @@ -309,7 +332,9 @@ bool ScEngine::tick() { for (int i = 0; i < _scripts.getSize(); i++) { // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + if (_scripts[i]->_state == SCRIPT_PAUSED) { + continue; + } // time sliced script if (_scripts[i]->_timeSlice > 0) { @@ -318,20 +343,26 @@ bool ScEngine::tick() { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + if (_isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + } } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = g_system->getMillis(); + if (isProfiling) { + startTime = g_system->getMillis(); + } while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + if (isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + } } _currentScript = NULL; } @@ -346,7 +377,9 @@ bool ScEngine::tick() { bool ScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; + if (!_scripts[i]->_unbreakable) { + continue; + } while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; @@ -366,7 +399,9 @@ bool ScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.removeAt(i); @@ -382,7 +417,9 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + if (_scripts[i]->_state == SCRIPT_FINISHED) { + continue; + } switch (_scripts[i]->_state) { case SCRIPT_RUNNING: case SCRIPT_SLEEPING: @@ -401,9 +438,15 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { } numTotal++; } - if (running) *running = numRunning; - if (waiting) *waiting = numWaiting; - if (persistent) *persistent = numPersistent; + if (running) { + *running = numRunning; + } + if (waiting) { + *waiting = numWaiting; + } + if (persistent) { + *persistent = numPersistent; + } return numTotal; } @@ -426,7 +469,9 @@ bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + if (!_gameRef->_compatKillMethodThreads) { + resetScript(_scripts[i]); + } bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well @@ -448,7 +493,9 @@ bool ScEngine::resetScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(); + if (!persistMgr->getIsSaving()) { + cleanup(); + } persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currentScript)); @@ -474,7 +521,9 @@ void ScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::pauseAll() { for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->pause(); + if (_scripts[i] != _currentScript) { + _scripts[i]->pause(); + } } return STATUS_OK; @@ -483,8 +532,9 @@ bool ScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) { _scripts[i]->resume(); + } return STATUS_OK; } @@ -493,7 +543,9 @@ bool ScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::isValidScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) return true; + if (_scripts[i] == script) { + return true; + } } return false; } @@ -511,14 +563,17 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { // process normal scripts first for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + if (_scripts[i]->_thread || _scripts[i]->_methodThread) { + continue; + } _scripts[i]->dbgSendScript(client); } // and threads later for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) + if (_scripts[i]->_thread || _scripts[i]->_methodThread) { _scripts[i]->dbgSendScript(client); + } } return STATUS_OK; @@ -526,7 +581,9 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } CScBreakpoint *bp = NULL; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -541,7 +598,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { } for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) return STATUS_OK; + if (bp->_lines[i] == line) { + return STATUS_OK; + } } bp->_lines.add(line); @@ -553,7 +612,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { @@ -578,7 +639,9 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } for (int i = 0; i < _scripts.getSize(); i++) { refreshScriptBreakpoints(_scripts[i]); @@ -588,9 +651,13 @@ bool ScEngine::refreshScriptBreakpoints() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::refreshScriptBreakpoints(ScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } - if (!script || !script->_filename) return STATUS_FAILED; + if (!script || !script->_filename) { + return STATUS_FAILED; + } for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { @@ -598,14 +665,18 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) { return STATUS_OK; } } - if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + if (script->_breakpoints.getSize() > 0) { + script->_breakpoints.removeAll(); + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool ScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } char text[512]; @@ -628,7 +699,9 @@ bool ScEngine::saveBreakpoints() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } char key[100]; @@ -641,7 +714,9 @@ bool ScEngine::loadBreakpoints() { char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); - if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + if (path != NULL && line != NULL) { + addBreakpoint(path, atoi(line)); + } delete[] path; delete[] line; path = NULL; @@ -654,7 +729,9 @@ bool ScEngine::loadBreakpoints() { ////////////////////////////////////////////////////////////////////////// void ScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) return; + if (!_isProfiling) { + return; + } AnsiString fileName = filename; fileName.toLowercase(); @@ -664,7 +741,9 @@ void ScEngine::addScriptTime(const char *filename, uint32 time) { ////////////////////////////////////////////////////////////////////////// void ScEngine::enableProfiling() { - if (_isProfiling) return; + if (_isProfiling) { + return; + } // destroy old data, if any _scriptTimes.clear(); @@ -676,7 +755,9 @@ void ScEngine::enableProfiling() { ////////////////////////////////////////////////////////////////////////// void ScEngine::disableProfiling() { - if (!_isProfiling) return; + if (!_isProfiling) { + return; + } dumpStats(); _isProfiling = false; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index e443ec5832..fc441347df 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -48,13 +48,17 @@ public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { _timestamp = g_system->getMillis(); _buffer = new byte[size]; - if (_buffer) memcpy(_buffer, buffer, size); + if (_buffer) { + memcpy(_buffer, buffer, size); + } _size = size; _filename = filename; }; ~CScCachedScript() { - if (_buffer) delete[] _buffer; + if (_buffer) { + delete[] _buffer; + } }; uint32 _timestamp; diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 41059b2d80..0380103cd4 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -47,8 +47,9 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { int numParams = stack->pop()->getInt(0); - if (numParams == 1) _length = stack->pop()->getInt(0); - else if (numParams > 1) { + if (numParams == 1) { + _length = stack->pop()->getInt(0); + } else if (numParams > 1) { _length = numParams; char paramName[20]; for (int i = 0; i < numParams; i++) { @@ -86,7 +87,9 @@ const char *SXArray::scToString() { } } - if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + if (i < _length - 1 && strlen(dummy) + 1 < 32768) { + strcat(dummy, ","); + } } return dummy; } @@ -124,12 +127,14 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->push(_values->getProp(paramName)); _values->deleteProp(paramName); _length--; - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -160,7 +165,9 @@ ScValue *SXArray::scGetProperty(const char *name) { char ParamName[20]; if (validNumber(name, ParamName)) { return _values->getProp(ParamName); - } else return _scValue; + } else { + return _scValue; + } } } @@ -190,10 +197,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) { else { char paramName[20]; if (validNumber(name, paramName)) { - int Index = atoi(paramName); - if (Index >= _length) _length = Index + 1; + int index = atoi(paramName); + if (index >= _length) { + _length = index + 1; + } return _values->setProp(paramName, value); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } } @@ -223,7 +234,9 @@ bool SXArray::validNumber(const char *origStr, char *outStr) { int index = atoi(origStr); sprintf(outStr, "%d", index); return true; - } else return false; + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 8eb86c4e69..67a1104b46 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -35,7 +35,7 @@ namespace WinterMute { class SXArray : public BaseScriptable { public: - bool push(ScValue *Val); + bool push(ScValue *val); bool validNumber(const char *origStr, char *outStr); DECLARE_PERSISTENT(SXArray, BaseScriptable) SXArray(BaseGame *inGame, ScStack *stack); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index d2fd3663c7..a3bb7e2183 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -199,10 +199,9 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, g_system->getTimeAndDate(_tm); stack->pushNULL(); return STATUS_OK; - } - - else + } else { return STATUS_FAILED; + } } @@ -216,9 +215,9 @@ ScValue *SXDate::scGetProperty(const char *name) { if (strcmp(name, "Type") == 0) { _scValue->setString("date"); return _scValue; + } else { + return _scValue; } - - else return _scValue; } diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 7da1601bdc..437fbb64a2 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -51,10 +51,12 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { ////////////////////////////////////////////////////////////////////////// SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); _filename = NULL; - if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString()); + if (!val->isNULL()) { + BaseUtils::setString(&_filename, val->getString()); + } _readFile = NULL; _writeFile = NULL; @@ -94,8 +96,11 @@ void SXFile::close() { ////////////////////////////////////////////////////////////////////////// const char *SXFile::scToString() { - if (_filename) return _filename; - else return "[file object]"; + if (_filename) { + return _filename; + } else { + return "[file object]"; + } } #define FILE_BUFFER_SIZE 32768 @@ -129,24 +134,37 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } } else { if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = openForWrite(_filename, false); - else _writeFile = openForAppend(_filename, false); + if (_mode == 2) { + _writeFile = openForWrite(_filename, false); + } else { + _writeFile = openForAppend(_filename, false); + } } else { - if (_mode == 2) _writeFile = openForWrite(_filename, true); - else _writeFile = openForAppend(_filename, true); + if (_mode == 2) { + _writeFile = openForWrite(_filename, true); + } else { + _writeFile = openForAppend(_filename, true); + } } if (!_writeFile) { //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } } - if (_readFile || _writeFile) stack->pushBool(true); - else stack->pushBool(false); + if (_readFile || _writeFile) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -221,7 +239,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool ret = STATUS_FAILED; do { ret = _readFile->read(&b, 1); - if (ret != 1) break; + if (ret != 1) { + break; + } if (counter > bufSize) { buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); @@ -231,8 +251,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, buf[counter] = '\0'; foundNewLine = true; break; - } else if (b == 0x0D) continue; - else { + } else if (b == 0x0D) { + continue; + } else { buf[counter] = b; counter++; } @@ -244,8 +265,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } buf[counter] = '\0'; - if (!foundNewLine && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); + if (!foundNewLine && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } free(buf); @@ -272,14 +296,17 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool ret = STATUS_FAILED; while (counter < (uint32)textLen) { ret = _readFile->read(&b, 1); - if (ret != 1) break; + if (ret != 1) { + break; + } if (counter > bufSize) { buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); bufSize += FILE_BUFFER_SIZE; } - if (b == 0x0D) continue; - else { + if (b == 0x0D) { + continue; + } else { buf[counter] = b; counter++; } @@ -291,8 +318,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } buf[counter] = '\0'; - if (textLen > 0 && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); + if (textLen > 0 && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } free(buf); @@ -335,8 +365,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); - else stack->pushNULL(); + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) { + stack->pushBool(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -355,8 +388,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile->err()) { stack->pushInt(val); } else { - stack->pushNULL(); - } + stack->pushNULL(); + } return STATUS_OK; } @@ -375,7 +408,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile->err()) { stack->pushInt(65536 + val); } else { - stack->pushNULL(); + stack->pushNULL(); } return STATUS_OK; } @@ -411,7 +444,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } float val; - (*(uint32*)&val) = _readFile->readUint32LE(); + (*(uint32 *)&val) = _readFile->readUint32LE(); if (!_readFile->err()) { stack->pushFloat(val); } else { @@ -433,8 +466,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); - else stack->pushNULL(); + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -458,8 +494,12 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushString((char *)str); } delete[] str; - } else stack->pushNULL(); - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -548,7 +588,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(false); return STATUS_OK; } - uint32 *ptr = (uint32*)&val; + uint32 *ptr = (uint32 *)&val; _writeFile->writeUint32LE(*ptr); stack->pushBool(true); @@ -594,10 +634,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(true); return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } @@ -651,9 +690,9 @@ ScValue *SXFile::scGetProperty(const char *name) { else if (strcmp(name, "AccessMode") == 0) { _scValue->setInt(_mode); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -681,43 +720,46 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// uint32 SXFile::getPos() { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - getPos for WriteFile not supported"); return 0; // return ftell((FILE *)_writeFile); - } else { + } else { return 0; } } ////////////////////////////////////////////////////////////////////////// bool SXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->seek(pos, whence); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - seeking in WriteFile not supported"); return false; // return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } else { + return false; } - else return false; } ////////////////////////////////////////////////////////////////////////// uint32 SXFile::getLength() { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->size(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - reading length for WriteFile not supported"); return 0; -/* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else return 0; + /* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -744,24 +786,28 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { // open for reading if (_mode == 1) { _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) + if (!_readFile) { close(); + } } // open for writing / appending else { if (_textMode) { - if (_mode == 2) + if (_mode == 2) { _writeFile = openForWrite(_filename, false); - else + } else { _writeFile = openForAppend(_filename, false); + } } else { - if (_mode == 2) + if (_mode == 2) { _writeFile = openForWrite(_filename, true); - else + } else { _writeFile = openForAppend(_filename, true); + } } - if (_writeFile) + if (_writeFile) { close(); + } } setPos(pos); } @@ -777,7 +823,7 @@ Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool b // Should replace fopen(..., "ab+") and fopen(..., "a+") Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); + error("SXFile::openForAppend - WriteFiles not supported"); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 1c37a15aa9..525b43434f 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -243,9 +243,9 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); stack->pushFloat(radianToDegree(stack->pop()->getFloat())); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -267,9 +267,9 @@ ScValue *SXMath::scGetProperty(const char *name) { else if (strcmp(name, "PI") == 0) { _scValue->setFloat(M_PI); return _scValue; + } else { + return _scValue; } - - else return _scValue; } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 3d3f0b218b..e15af3446e 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -70,7 +70,9 @@ void *SXMemBuffer::scToMemBuffer() { ////////////////////////////////////////////////////////////////////////// void SXMemBuffer::cleanup() { - if (_size) free(_buffer); + if (_size) { + free(_buffer); + } _buffer = NULL; _size = 0; } @@ -81,14 +83,18 @@ bool SXMemBuffer::resize(int newSize) { if (_size == 0) { _buffer = malloc(newSize); - if (_buffer) _size = newSize; + if (_buffer) { + _size = newSize; + } } else { void *newBuf = realloc(_buffer, newSize); if (!newBuf) { if (newSize == 0) { _buffer = newBuf; _size = newSize; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } else { _buffer = newBuf; _size = newSize; @@ -107,14 +113,16 @@ bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } - if (_size == 0) + if (_size == 0) { return true; + } if (start < 0 || length == 0 || start + length > _size) { script->runtimeError("Set/Get method call is out of bounds"); return false; - } else + } else { return true; + } } ////////////////////////////////////////////////////////////////////////// @@ -132,10 +140,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->correctParams(1); int newSize = stack->pop()->getInt(); newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) + if (DID_SUCCEED(resize(newSize))) { stack->pushBool(true); - else + } else { stack->pushBool(false); + } return STATUS_OK; } @@ -146,10 +155,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetBool") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) + if (!checkBounds(script, start, sizeof(bool))) { stack->pushNULL(); - else + } else { stack->pushBool(*(bool *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -160,10 +170,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetByte") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) + if (!checkBounds(script, start, sizeof(byte))) { stack->pushNULL(); - else + } else { stack->pushInt(*(byte *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -174,10 +185,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) + if (!checkBounds(script, Start, sizeof(short))) { stack->pushNULL(); - else + } else { stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + } return STATUS_OK; } @@ -188,10 +200,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) + if (!checkBounds(script, start, sizeof(int))) { stack->pushNULL(); - else + } else { stack->pushInt(*(int *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -202,10 +215,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetFloat") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) + if (!checkBounds(script, start, sizeof(float))) { stack->pushNULL(); - else + } else { stack->pushFloat(*(float *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -216,10 +230,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetDouble") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) + if (!checkBounds(script, start, sizeof(double))) { stack->pushNULL(); - else + } else { stack->pushFloat(*(double *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -242,9 +257,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } } - if (!checkBounds(script, start, length)) + if (!checkBounds(script, start, length)) { stack->pushNULL(); - else { + } else { char *str = new char[length + 1]; strncpy(str, (const char *)_buffer + start, length); str[length] = '\0'; @@ -260,9 +275,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetPointer") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) + if (!checkBounds(script, start, sizeof(void *))) { stack->pushNULL(); - else { + } else { void *pointer = *(void **)((byte *)_buffer + start); SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); stack->pushNative(buf, false); @@ -278,9 +293,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); bool val = stack->pop()->getBool(); - if (!checkBounds(script, start, sizeof(bool))) + if (!checkBounds(script, start, sizeof(bool))) { stack->pushBool(false); - else { + } else { *(bool *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -295,9 +310,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); byte val = (byte)stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) + if (!checkBounds(script, start, sizeof(byte))) { stack->pushBool(false); - else { + } else { *(byte *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -312,9 +327,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); short val = (short)stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(short))) + if (!checkBounds(script, start, sizeof(short))) { stack->pushBool(false); - else { + } else { *(short *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -329,9 +344,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); int val = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) + if (!checkBounds(script, start, sizeof(int))) { stack->pushBool(false); - else { + } else { *(int *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -346,9 +361,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); float val = (float)stack->pop()->getFloat(); - if (!checkBounds(script, start, sizeof(float))) + if (!checkBounds(script, start, sizeof(float))) { stack->pushBool(false); - else { + } else { *(float *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -363,9 +378,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); double val = stack->pop()->getFloat(); - if (!checkBounds(script, start, sizeof(double))) + if (!checkBounds(script, start, sizeof(double))) { stack->pushBool(false); - else { + } else { *(double *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -380,9 +395,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); const char *val = stack->pop()->getString(); - if (!checkBounds(script, start, strlen(val) + 1)) + if (!checkBounds(script, start, strlen(val) + 1)) { stack->pushBool(false); - else { + } else { memcpy((byte *)_buffer + start, val, strlen(val) + 1); stack->pushBool(true); } @@ -395,11 +410,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); int start = stack->pop()->getInt(); - /* ScValue *Val = */ stack->pop(); + /* ScValue *val = */ stack->pop(); - if (!checkBounds(script, start, sizeof(void *))) + if (!checkBounds(script, start, sizeof(void *))) { stack->pushBool(false); - else { + } else { /* int Pointer = (int)Val->getMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); @@ -426,9 +441,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } stack->pushNULL(); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -450,9 +465,9 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) { if (strcmp(name, "Size") == 0) { _scValue->setInt(_size); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -487,12 +502,16 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_size)); if (persistMgr->getIsSaving()) { - if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + if (_size > 0) { + persistMgr->putBytes((byte *)_buffer, _size); + } } else { if (_size > 0) { _buffer = malloc(_size); persistMgr->getBytes((byte *)_buffer, _size); - } else _buffer = NULL; + } else { + _buffer = NULL; + } } return STATUS_OK; @@ -501,8 +520,11 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int SXMemBuffer::scCompare(BaseScriptable *val) { - if (_buffer == val->scToMemBuffer()) return 0; - else return 1; + if (_buffer == val->scToMemBuffer()) { + return 0; + } else { + return 1; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 385d7ca746..1c7349bd8d 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -61,13 +61,17 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { setStringVal(val->getString()); } - if (_capacity == 0) setStringVal(""); + if (_capacity == 0) { + setStringVal(""); + } } ////////////////////////////////////////////////////////////////////////// SXString::~SXString() { - if (_string) delete[] _string; + if (_string) { + delete[] _string; + } } @@ -87,8 +91,11 @@ void SXString::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// const char *SXString::scToString() { - if (_string) return _string; - else return "[null string]"; + if (_string) { + return _string; + } else { + return "[null string]"; + } } @@ -108,22 +115,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int start = stack->pop()->getInt(); int end = stack->pop()->getInt(); - if (end < start) BaseUtils::swap(&start, &end); + if (end < start) { + BaseUtils::swap(&start, &end); + } //try { WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } //WideString subStr = str.substr(start, end - start + 1); WideString subStr(str.c_str() + start, end - start + 1); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } // } catch (std::exception &) { // stack->pushNULL(); // } @@ -146,22 +157,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack return STATUS_OK; } - if (val->isNULL()) len = strlen(_string) - start; + if (val->isNULL()) { + len = strlen(_string) - start; + } // try { WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } // WideString subStr = str.substr(start, len); WideString subStr(str.c_str() + start, len); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } // } catch (std::exception &) { // stack->pushNULL(); // } @@ -176,17 +191,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } str.toUppercase(); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } return STATUS_OK; } @@ -198,17 +215,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } str.toLowercase(); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } return STATUS_OK; } @@ -223,16 +242,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int index = stack->pop()->getInt(); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { toFind = StringUtil::utf8ToWide(strToFind); - else + } else { toFind = StringUtil::ansiToWide(strToFind); + } int indexOf = StringUtil::indexOf(str, toFind, index); stack->pushInt(indexOf); @@ -247,7 +268,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) strcpy(separators, val->getString()); + if (!val->isNULL()) { + strcpy(separators, val->getString()); + } SXArray *array = new SXArray(_gameRef); if (!array) { @@ -257,16 +280,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { delims = StringUtil::utf8ToWide(separators); - else + } else { delims = StringUtil::ansiToWide(separators); + } Common::Array parts; @@ -298,10 +323,11 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - else + } else { val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + } array->push(val); delete val; @@ -310,9 +336,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushNative(array, false); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -334,8 +360,9 @@ ScValue *SXString::scGetProperty(const char *name) { if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); - } else + } else { _scValue->setInt(strlen(_string)); + } return _scValue; } @@ -345,9 +372,9 @@ ScValue *SXString::scGetProperty(const char *name) { else if (strcmp(name, "Capacity") == 0) { _scValue->setInt(_capacity); return _scValue; + } else { + return _scValue; } - - else return _scValue; } @@ -358,8 +385,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); - else if (newCap != _capacity) { + if (newCap < (int32)(strlen(_string) + 1)) { + _gameRef->LOG(0, "Warning: cannot lower string capacity"); + } else if (newCap != _capacity) { char *newStr = new char[newCap]; if (newStr) { memset(newStr, 0, newCap); @@ -370,9 +398,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) { } } return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -384,12 +412,16 @@ bool SXString::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_capacity)); if (persistMgr->getIsSaving()) { - if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + if (_capacity > 0) { + persistMgr->putBytes((byte *)_string, _capacity); + } } else { if (_capacity > 0) { _string = new char[_capacity]; persistMgr->getBytes((byte *)_string, _capacity); - } else _string = NULL; + } else { + _string = NULL; + } } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 74cc7a57ee..0d4ea54b8c 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -96,16 +96,22 @@ ScValue *ScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) return NULL; - else return _values[_sP]; + if (_sP < 0 || _sP >= _values.getSize()) { + return NULL; + } else { + return _values[_sP]; + } } ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getAt(int index) { index = _sP - index; - if (index < 0 || index >= _values.getSize()) return NULL; - else return _values[index]; + if (index < 0 || index >= _values.getSize()) { + return NULL; + } else { + return _values[index]; + } } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 5e824cd10c..01cb4044ff 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -122,7 +122,9 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { void ScValue::cleanup(bool ignoreNatives) { deleteProps(); - if (_valString) delete[] _valString; + if (_valString) { + delete[] _valString; + } if (!ignoreNatives) { if (_valNative && !_persistent) { @@ -157,7 +159,9 @@ ScValue::~ScValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + if (_type == VAL_VARIABLE_REF) { + return _valRef->getProp(name); + } if (_type == VAL_STRING && strcmp(name, "Length") == 0) { _gameRef->_scValue->_type = VAL_INT; @@ -178,18 +182,24 @@ ScValue *ScValue::getProp(const char *name) { ScValue *ret = NULL; - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scGetProperty(name); + } if (ret == NULL) { _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) ret = _valIter->_value; + if (_valIter != _valObject.end()) { + ret = _valIter->_value; + } } return ret; } ////////////////////////////////////////////////////////////////////////// bool ScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + if (_type == VAL_VARIABLE_REF) { + return _valRef->deleteProp(name); + } _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { @@ -204,8 +214,9 @@ bool ScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->setProp(name, val); + } bool ret = STATUS_FAILED; if (_type == VAL_NATIVE && _valNative) { @@ -219,15 +230,19 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs if (_valIter != _valObject.end()) { newVal = _valIter->_value; } - if (!newVal) + if (!newVal) { newVal = new ScValue(_gameRef); - else newVal->cleanup(); + } else { + newVal->cleanup(); + } newVal->copy(val, copyWhole); newVal->_isConstVar = setAsConst; _valObject[name] = newVal; - if (_type != VAL_NATIVE) _type = VAL_OBJECT; + if (_type != VAL_NATIVE) { + _type = VAL_OBJECT; + } /* _valIter = _valObject.find(Name); @@ -250,8 +265,9 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs ////////////////////////////////////////////////////////////////////////// bool ScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->propExists(name); + } _valIter = _valObject.find(name); return (_valIter != _valObject.end()); @@ -273,15 +289,18 @@ void ScValue::deleteProps() { void ScValue::CleanProps(bool includingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { + _valIter->_value->setNULL(); + } _valIter++; } } ////////////////////////////////////////////////////////////////////////// bool ScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isNULL(); + } return (_type == VAL_NULL); } @@ -289,8 +308,9 @@ bool ScValue::isNULL() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isNative() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isNative(); + } return (_type == VAL_NATIVE); } @@ -298,8 +318,9 @@ bool ScValue::isNative() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isString() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isString(); + } return (_type == VAL_STRING); } @@ -307,8 +328,9 @@ bool ScValue::isString() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isFloat(); + } return (_type == VAL_FLOAT); } @@ -316,8 +338,9 @@ bool ScValue::isFloat() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isInt() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isInt(); + } return (_type == VAL_INT); } @@ -325,8 +348,9 @@ bool ScValue::isInt() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isBool() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isBool(); + } return (_type == VAL_BOOL); } @@ -334,8 +358,9 @@ bool ScValue::isBool() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isObject() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isObject(); + } return (_type == VAL_OBJECT); } @@ -343,8 +368,9 @@ bool ScValue::isObject() { ////////////////////////////////////////////////////////////////////////// TValType ScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getType(); + } return _type; } @@ -414,8 +440,11 @@ void ScValue::setString(const char *val) { } setStringVal(val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; + if (_valString) { + _type = VAL_STRING; + } else { + _type = VAL_NULL; + } } void ScValue::setString(const Common::String &val) { @@ -450,7 +479,9 @@ void ScValue::setNULL() { if (_valNative && !_persistent) { _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; + if (_valNative->_refCount <= 0) { + delete _valNative; + } } _valNative = NULL; deleteProps(); @@ -472,7 +503,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { - if (_valNative != val) delete _valNative; + if (_valNative != val) { + delete _valNative; + } _valNative = NULL; } } @@ -481,7 +514,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) { _persistent = persistent; _valNative = val; - if (_valNative && !_persistent) _valNative->_refCount++; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } } } @@ -507,8 +542,9 @@ void ScValue::setReference(ScValue *val) { ////////////////////////////////////////////////////////////////////////// bool ScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getBool(); + } switch (_type) { case VAL_BOOL: @@ -534,7 +570,9 @@ bool ScValue::getBool(bool defaultVal) { ////////////////////////////////////////////////////////////////////////// int ScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + if (_type == VAL_VARIABLE_REF) { + return _valRef->getInt(); + } switch (_type) { case VAL_BOOL: @@ -560,8 +598,9 @@ int ScValue::getInt(int defaultVal) { ////////////////////////////////////////////////////////////////////////// double ScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getFloat(); + } switch (_type) { case VAL_BOOL: @@ -586,19 +625,23 @@ double ScValue::getFloat(double defaultVal) { ////////////////////////////////////////////////////////////////////////// void *ScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getMemBuffer(); + } - if (_type == VAL_NATIVE) + if (_type == VAL_NATIVE) { return _valNative->scToMemBuffer(); - else return (void *)NULL; + } else { + return (void *)NULL; + } } ////////////////////////////////////////////////////////////////////////// const char *ScValue::getString() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getString(); + } switch (_type) { case VAL_OBJECT: @@ -647,11 +690,15 @@ const char *ScValue::getString() { ////////////////////////////////////////////////////////////////////////// BaseScriptable *ScValue::getNative() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getNative(); + } - if (_type == VAL_NATIVE) return _valNative; - else return NULL; + if (_type == VAL_NATIVE) { + return _valNative; + } else { + return NULL; + } } @@ -668,12 +715,16 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; + if (_valNative != orig->_valNative) { + delete _valNative; + } _valNative = NULL; } } - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) { + orig = orig->_valRef; + } cleanup(true); @@ -687,7 +738,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { _persistent = orig->_persistent; _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } //!!!! ref->native++ // copy properties @@ -698,7 +751,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } - } else _valObject.clear(); + } else { + _valObject.clear(); + } } @@ -730,7 +785,9 @@ void ScValue::setValue(ScValue *val) { } } // otherwise just copy everything - else copy(val); + else { + copy(val); + } } @@ -841,39 +898,60 @@ int ScValue::compare(ScValue *val1, ScValue *val2) { // same class? if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { return val1->getNative()->scCompare(val2->getNative()); - } else return strcmp(val1->getString(), val2->getString()); + } else { + return strcmp(val1->getString(), val2->getString()); + } } // both objects? - if (val1->isObject() && val2->isObject()) return -1; + if (val1->isObject() && val2->isObject()) { + return -1; + } // null states - if (val1->isNULL() && !val2->isNULL()) return -1; - else if (!val1->isNULL() && val2->isNULL()) return 1; - else if (val1->isNULL() && val2->isNULL()) return 0; + if (val1->isNULL() && !val2->isNULL()) { + return -1; + } else if (!val1->isNULL() && val2->isNULL()) { + return 1; + } else if (val1->isNULL() && val2->isNULL()) { + return 0; + } // one of them is string? convert both to string - if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + if (val1->isString() || val2->isString()) { + return strcmp(val1->getString(), val2->getString()); + } // one of them is float? if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) return -1; - else if (val1->getFloat() > val2->getFloat()) return 1; - else return 0; + if (val1->getFloat() < val2->getFloat()) { + return -1; + } else if (val1->getFloat() > val2->getFloat()) { + return 1; + } else { + return 0; + } } // otherwise compare as int's - if (val1->getInt() < val2->getInt()) return -1; - else if (val1->getInt() > val2->getInt()) return 1; - else return 0; + if (val1->getInt() < val2->getInt()) { + return -1; + } else if (val1->getInt() > val2->getInt()) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// int ScValue::compareStrict(ScValue *val1, ScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return ScValue::compare(val1, val2); + if (val1->getTypeTolerant() != val2->getTypeTolerant()) { + return -1; + } else { + return ScValue::compare(val1, val2); + } } @@ -1013,16 +1091,18 @@ bool ScValue::dbgSetVal() { ////////////////////////////////////////////////////////////////////////// int ScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) + if (_valNative && _valNative->_scProp) { return _valNative->_scProp->dbgGetNumProperties(); - else return _valObject.size(); + } else { + return _valObject.size(); + } } ////////////////////////////////////////////////////////////////////////// bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) + if (_valNative && _valNative->_scProp) { return _valNative->_scProp->dbgGetProperty(index, name, value); - else { + } else { int count = 0; _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { @@ -1040,8 +1120,9 @@ bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value ////////////////////////////////////////////////////////////////////////// bool ScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->dbgGetDescription(buf, bufSize); + } if (_type == VAL_NATIVE) { _valNative->scDebuggerDesc(buf, bufSize); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 8cc8c21948..9cd9e4cc75 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -57,7 +57,9 @@ BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// BaseSound::~BaseSound() { - if (_sound) _gameRef->_soundMgr->removeSound(_sound); + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + } _sound = NULL; delete[] _soundFilename; @@ -83,7 +85,9 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo _soundStreamed = streamed; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -91,22 +95,32 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { - if (_soundPosition) _sound->setPosition(_soundPosition); + if (_soundPosition) { + _sound->setPosition(_soundPosition); + } _sound->setLooping(_soundLooping); _sound->setPrivateVolume(_soundPrivateVolume); _sound->setLoopStart(_soundLoopStart); _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->resume(); - else return STATUS_OK; - } else return STATUS_FAILED; + if (_soundPlaying) { + return _sound->resume(); + } else { + return STATUS_OK; + } + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getLength() { - if (_sound) return _sound->getLength(); - else return 0; + if (_sound) { + return _sound->getLength(); + } else { + return 0; + } } @@ -115,7 +129,9 @@ bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -124,7 +140,9 @@ bool BaseSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -132,9 +150,13 @@ bool BaseSound::stop() { bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; - if (freezePaused) _sound->_freezePaused = true; + if (freezePaused) { + _sound->_freezePaused = true; + } return _sound->pause(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -143,7 +165,9 @@ bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -153,8 +177,9 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) + if (_soundPlaying) { _soundPosition = _sound->getPosition(); + } _soundLoopStart = _sound->_loopStart; _soundFreezePaused = _sound->_freezePaused; } @@ -195,64 +220,81 @@ bool BaseSound::isPaused() { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPositionTime(uint32 time) { - if (!_sound) return STATUS_FAILED; + if (!_sound) { + return STATUS_FAILED; + } _soundPosition = time; bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) + if (_sound->isPlaying()) { _soundPosition = 0; + } return ret; } ////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getPositionTime() { - if (!_sound) return 0; + if (!_sound) { + return 0; + } - if (!_sound->isPlaying()) + if (!_sound->isPlaying()) { return 0; - else return _sound->getPosition(); + } else { + return _sound->getPosition(); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolumePercent(int percent) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->setPrivateVolume(percent * 255 / 100); + } else { + return _sound->setPrivateVolume(percent * 255 / 100); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolume(int volume) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->setPrivateVolume(volume); + } else { + return _sound->setPrivateVolume(volume); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->_privateVolume = volume; + } else { + return _sound->_privateVolume = volume; + } } ////////////////////////////////////////////////////////////////////////// int BaseSound::getVolumePercent() { - if (!_sound) + if (!_sound) { return 0; - else return _sound->_privateVolume * 100 / 255; + } else { + return _sound->_privateVolume * 100 / 255; + } } ////////////////////////////////////////////////////////////////////////// int BaseSound::getVolume() { - if (!_sound) + if (!_sound) { return 0; - else return _sound->_privateVolume; + } else { + return _sound->_privateVolume; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setLoopStart(uint32 pos) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else { + } else { _sound->setLoopStart(pos); return STATUS_OK; } @@ -260,16 +302,19 @@ bool BaseSound::setLoopStart(uint32 pos) { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPan(float pan) { - if (_sound) + if (_sound) { return _sound->setPan(pan); - else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) + if (!_sound) { return STATUS_OK; + } if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { bool ret = _sound->applyFX(type, param1, param2, param3, param4); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index cebc3a3765..74aae59e3d 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -61,8 +61,9 @@ BaseSoundMgr::~BaseSoundMgr() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) + for (uint32 i = 0; i < _sounds.size(); i++) { delete _sounds[i]; + } _sounds.clear(); #if 0 BASS_Free(); @@ -93,8 +94,9 @@ bool BaseSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::initLoop() { - if (!_soundAvailable) + if (!_soundAvailable) { return STATUS_OK; + } #if 0 BASS_Update(500); @@ -105,8 +107,9 @@ bool BaseSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) + if (!_soundAvailable) { return NULL; + } BaseSoundBuffer *sound; @@ -123,7 +126,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun } sound = new BaseSoundBuffer(_gameRef); - if (!sound) return NULL; + if (!sound) { + return NULL; + } sound->setStreaming(streamed); sound->setType(type); @@ -149,8 +154,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) + if (!sound) { return STATUS_FAILED; + } // Make sure the master-volume is applied to the sound. sound->updateVolume(); @@ -177,8 +183,9 @@ bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) + if (!_soundAvailable) { return STATUS_OK; + } switch (type) { case Audio::Mixer::kSFXSoundType: diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index fe7325baa4..ef5b676662 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -34,14 +34,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// float MathUtil::round(float val) { float result = floor(val); - if (val - result >= 0.5) result += 1.0; + if (val - result >= 0.5) { + result += 1.0; + } return result; } ////////////////////////////////////////////////////////////////////////// float MathUtil::roundUp(float val) { float result = floor(val); - if (val - result > 0) result += 1.0; + if (val - result > 0) { + result += 1.0; + } return result; } diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp index 32704e0a0e..21578320c7 100644 --- a/engines/wintermute/system/sys_class.cpp +++ b/engines/wintermute/system/sys_class.cpp @@ -85,7 +85,9 @@ SystemInstance *SystemClass::addInstance(void *instance, int id, int savedId) { ////////////////////////////////////////////////////////////////////////// bool SystemClass::removeInstance(void *instance) { InstanceMap::iterator mapIt = _instanceMap.find(instance); - if (mapIt == _instanceMap.end()) return false; + if (mapIt == _instanceMap.end()) { + return false; + } Instances::iterator it = _instances.find((mapIt->_value)); if (it != _instances.end()) { @@ -101,8 +103,11 @@ bool SystemClass::removeInstance(void *instance) { ////////////////////////////////////////////////////////////////////////// int SystemClass::getInstanceID(void *pointer) { InstanceMap::iterator mapIt = _instanceMap.find(pointer); - if (mapIt == _instanceMap.end()) return -1; - else return (mapIt->_value)->getID(); + if (mapIt == _instanceMap.end()) { + return -1; + } else { + return (mapIt->_value)->getID(); + } } ////////////////////////////////////////////////////////////////////////// @@ -110,7 +115,9 @@ void *SystemClass::idToPointer(int savedID) { //slow Instances::iterator it; for (it = _instances.begin(); it != _instances.end(); ++it) { - if ((it->_value)->getSavedID() == savedID) return (it->_value)->getInstance(); + if ((it->_value)->getSavedID() == savedID) { + return (it->_value)->getInstance(); + } } return NULL; } @@ -157,7 +164,9 @@ void SystemClass::loadTable(BaseGame *gameRef, BasePersistenceManager *persistMg if (it != _instances.end()) { (it->_value)->setSavedID(instID); SystemClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance()); - } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } else { + gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str()); + } } // normal instances, create empty objects else { diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index 7f7814f75c..47910af4e8 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -77,7 +77,9 @@ bool SystemClassRegistry::registerClass(SystemClass *classObj) { bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { Classes::iterator it = _classes.find(classObj); - if (it == _classes.end()) return false; + if (it == _classes.end()) { + return false; + } if (classObj->getNumInstances() != 0) { char str[MAX_PATH_LENGTH]; @@ -87,10 +89,14 @@ bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { _classes.erase(it); NameMap::iterator mapIt = _nameMap.find(classObj->getName()); - if (mapIt != _nameMap.end()) _nameMap.erase(mapIt); + if (mapIt != _nameMap.end()) { + _nameMap.erase(mapIt); + } IdMap::iterator idIt = _idMap.find(classObj->getID()); - if (idIt != _idMap.end()) _idMap.erase(idIt); + if (idIt != _idMap.end()) { + _idMap.erase(idIt); + } return true; @@ -99,10 +105,14 @@ bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { ////////////////////////////////////////////////////////////////////////// bool SystemClassRegistry::registerInstance(const char *className, void *instance) { - if (_disabled) return true; + if (_disabled) { + return true; + } NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; + if (mapIt == _nameMap.end()) { + return false; + } SystemInstance *inst = (*mapIt)._value->addInstance(instance, _count++); return (inst != NULL); @@ -112,8 +122,9 @@ bool SystemClassRegistry::registerInstance(const char *className, void *instance void SystemClassRegistry::addInstanceToTable(SystemInstance *instance, void *pointer) { _instanceMap[pointer] = instance; - if (instance->getSavedID() >= 0) + if (instance->getSavedID() >= 0) { _savedInstanceMap[instance->getSavedID()] = instance; + } } ////////////////////////////////////////////////////////////////////////// @@ -124,23 +135,31 @@ int SystemClassRegistry::getNextID() { ////////////////////////////////////////////////////////////////////////// bool SystemClassRegistry::unregisterInstance(const char *className, void *instance) { NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return false; + if (mapIt == _nameMap.end()) { + return false; + } (*mapIt)._value->removeInstance(instance); InstanceMap::iterator instIt = _instanceMap.find(instance); if (instIt != _instanceMap.end()) { _instanceMap.erase(instIt); return true; - } else return false; + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// bool SystemClassRegistry::getPointerID(void *pointer, int *classID, int *instanceID) { - if (pointer == NULL) return true; + if (pointer == NULL) { + return true; + } InstanceMap::iterator it = _instanceMap.find(pointer); - if (it == _instanceMap.end()) return false; + if (it == _instanceMap.end()) { + return false; + } SystemInstance *inst = (*it)._value; @@ -153,8 +172,11 @@ bool SystemClassRegistry::getPointerID(void *pointer, int *classID, int *instanc ////////////////////////////////////////////////////////////////////////// void *SystemClassRegistry::idToPointer(int classID, int instanceID) { SavedInstanceMap::iterator it = _savedInstanceMap.find(instanceID); - if (it == _savedInstanceMap.end()) return NULL; - else return (*it)._value->getInstance(); + if (it == _savedInstanceMap.end()) { + return NULL; + } else { + return (*it)._value->getInstance(); + } } bool checkHeader(const char *tag, BasePersistenceManager *pm) { @@ -203,7 +225,9 @@ bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *p } for (it = _classes.begin(); it != _classes.end(); ++it) { - if ((it->_value)->isPersistent()) continue; + if ((it->_value)->isPersistent()) { + continue; + } (it->_value)->removeAllInstances(); } @@ -218,7 +242,9 @@ bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *p Common::String className = persistMgr->getStringObj(); NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr); + if (mapIt != _nameMap.end()) { + (*mapIt)._value->loadTable(gameRef, persistMgr); + } } checkHeader("", persistMgr); @@ -298,7 +324,9 @@ bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManage ////////////////////////////////////////////////////////////////////////// bool SystemClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const char *className, void *lpData) { NameMap::iterator mapIt = _nameMap.find(className); - if (mapIt == _nameMap.end()) return STATUS_FAILED; + if (mapIt == _nameMap.end()) { + return STATUS_FAILED; + } (*mapIt)._value->instanceCallback(lpCallback, lpData); return STATUS_OK; @@ -308,8 +336,9 @@ bool SystemClassRegistry::enumInstances(SYS_INSTANCE_CALLBACK lpCallback, const ////////////////////////////////////////////////////////////////////////// void SystemClassRegistry::dumpClasses(Common::WriteStream *stream) { Classes::iterator it; - for (it = _classes.begin(); it != _classes.end(); ++it) + for (it = _classes.begin(); it != _classes.end(); ++it) { (it->_value)->dump(stream); + } } } // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 2c4cecdc85..706b0d3c00 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -77,10 +77,18 @@ UIButton::~UIButton() { delete _backFocus; if (!_sharedFonts) { - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + if (_fontHover) { + _gameRef->_fontStorage->removeFont(_fontHover); + } + if (_fontPress) { + _gameRef->_fontStorage->removeFont(_fontPress); + } + if (_fontDisable) { + _gameRef->_fontStorage->removeFont(_fontDisable); + } + if (_fontFocus) { + _gameRef->_fontStorage->removeFont(_fontFocus); + } } if (!_sharedImages) { @@ -104,7 +112,9 @@ bool UIButton::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename); + } delete[] buffer; @@ -206,7 +216,9 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -318,33 +330,53 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; + if (!_font) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_HOVER: - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontHover) { + _gameRef->_fontStorage->removeFont(_fontHover); + } _fontHover = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontHover) cmd = PARSERR_GENERIC; + if (!_fontHover) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_PRESS: - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); + if (_fontPress) { + _gameRef->_fontStorage->removeFont(_fontPress); + } _fontPress = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontPress) cmd = PARSERR_GENERIC; + if (!_fontPress) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_DISABLE: - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); + if (_fontDisable) { + _gameRef->_fontStorage->removeFont(_fontDisable); + } _fontDisable = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontDisable) cmd = PARSERR_GENERIC; + if (!_fontDisable) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_FOCUS: - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + if (_fontFocus) { + _gameRef->_fontStorage->removeFont(_fontFocus); + } _fontFocus = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontFocus) cmd = PARSERR_GENERIC; + if (!_fontFocus) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_TEXT: @@ -353,9 +385,13 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _align = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _align = TAL_RIGHT; - else _align = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) { + _align = TAL_LEFT; + } else if (scumm_stricmp((char *)params, "right") == 0) { + _align = TAL_RIGHT; + } else { + _align = TAL_CENTER; + } break; case TOKEN_X: @@ -445,47 +481,64 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->getFilename()) + if (_back && _back->getFilename()) { buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - if (_backHover && _backHover->getFilename()) + } + if (_backHover && _backHover->getFilename()) { buffer->putTextIndent(indent + 2, "BACK_HOVER=\"%s\"\n", _backHover->getFilename()); - if (_backPress && _backPress->getFilename()) + } + if (_backPress && _backPress->getFilename()) { buffer->putTextIndent(indent + 2, "BACK_PRESS=\"%s\"\n", _backPress->getFilename()); - if (_backDisable && _backDisable->getFilename()) + } + if (_backDisable && _backDisable->getFilename()) { buffer->putTextIndent(indent + 2, "BACK_DISABLE=\"%s\"\n", _backDisable->getFilename()); - if (_backFocus && _backFocus->getFilename()) + } + if (_backFocus && _backFocus->getFilename()) { buffer->putTextIndent(indent + 2, "BACK_FOCUS=\"%s\"\n", _backFocus->getFilename()); + } - if (_image && _image->getFilename()) + if (_image && _image->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - if (_imageHover && _imageHover->getFilename()) + } + if (_imageHover && _imageHover->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE_HOVER=\"%s\"\n", _imageHover->getFilename()); - if (_imagePress && _imagePress->getFilename()) + } + if (_imagePress && _imagePress->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE_PRESS=\"%s\"\n", _imagePress->getFilename()); - if (_imageDisable && _imageDisable->getFilename()) + } + if (_imageDisable && _imageDisable->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE_DISABLE=\"%s\"\n", _imageDisable->getFilename()); - if (_imageFocus && _imageFocus->getFilename()) + } + if (_imageFocus && _imageFocus->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE_FOCUS=\"%s\"\n", _imageFocus->getFilename()); + } - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_fontHover && _fontHover->getFilename()) + } + if (_fontHover && _fontHover->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_HOVER=\"%s\"\n", _fontHover->getFilename()); - if (_fontPress && _fontPress->getFilename()) + } + if (_fontPress && _fontPress->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_PRESS=\"%s\"\n", _fontPress->getFilename()); - if (_fontDisable && _fontDisable->getFilename()) + } + if (_fontDisable && _fontDisable->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_DISABLE=\"%s\"\n", _fontDisable->getFilename()); - if (_fontFocus && _fontFocus->getFilename()) + } + if (_fontFocus && _fontFocus->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_FOCUS=\"%s\"\n", _fontFocus->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } buffer->putTextIndent(indent + 2, "\n"); - if (_text) + if (_text) { buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + } switch (_align) { case TAL_LEFT: @@ -539,17 +592,25 @@ void UIButton::correctSize() { Rect32 rect; BaseSprite *img = NULL; - if (_image) img = _image; - else if (_imageDisable) img = _imageDisable; - else if (_imageHover) img = _imageHover; - else if (_imagePress) img = _imagePress; - else if (_imageFocus) img = _imageFocus; + if (_image) { + img = _image; + } else if (_imageDisable) { + img = _imageDisable; + } else if (_imageHover) { + img = _imageHover; + } else if (_imagePress) { + img = _imagePress; + } else if (_imageFocus) { + img = _imageFocus; + } if (_width <= 0) { if (img) { img->getBoundingRect(&rect, 0, 0); _width = rect.right - rect.left; - } else _width = 100; + } else { + _width = 100; + } } if (_height <= 0) { @@ -561,22 +622,32 @@ void UIButton::correctSize() { if (_text) { int text_height; - if (_font) text_height = _font->getTextHeight((byte *)_text, _width); - else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); + if (_font) { + text_height = _font->getTextHeight((byte *)_text, _width); + } else { + text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width); + } - if (text_height > _height) _height = text_height; + if (text_height > _height) { + _height = text_height; + } } - if (_height <= 0) _height = 100; + if (_height <= 0) { + _height = 100; + } - if (_back) _back->correctSize(&_width, &_height); + if (_back) { + _back->correctSize(&_width, &_height); + } } ////////////////////////////////////////////////////////////////////////// bool UIButton::display(int offsetX, int offsetY) { - if (!_visible) + if (!_visible) { return STATUS_OK; + } UITiledImage *back = NULL; BaseSprite *image = NULL; @@ -588,32 +659,65 @@ bool UIButton::display(int offsetX, int offsetY) { _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN)); if ((_press && _hover && !_gameRef->_mouseLeftDown) || - (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) press(); + (_oneTimePress && g_system->getMillis() - _oneTimePressTime >= 100)) { + press(); + } if (_disable) { - if (_backDisable) back = _backDisable; - if (_imageDisable) image = _imageDisable; - if (_text && _fontDisable) font = _fontDisable; + if (_backDisable) { + back = _backDisable; + } + if (_imageDisable) { + image = _imageDisable; + } + if (_text && _fontDisable) { + font = _fontDisable; + } } else if (_press || _oneTimePress || _stayPressed) { - if (_backPress) back = _backPress; - if (_imagePress) image = _imagePress; - if (_text && _fontPress) font = _fontPress; + if (_backPress) { + back = _backPress; + } + if (_imagePress) { + image = _imagePress; + } + if (_text && _fontPress) { + font = _fontPress; + } } else if (_hover) { - if (_backHover) back = _backHover; - if (_imageHover) image = _imageHover; - if (_text && _fontHover) font = _fontHover; + if (_backHover) { + back = _backHover; + } + if (_imageHover) { + image = _imageHover; + } + if (_text && _fontHover) { + font = _fontHover; + } } else if (_canFocus && isFocused()) { - if (_backFocus) back = _backFocus; - if (_imageFocus) image = _imageFocus; - if (_text && _fontFocus) font = _fontFocus; + if (_backFocus) { + back = _backFocus; + } + if (_imageFocus) { + image = _imageFocus; + } + if (_text && _fontFocus) { + font = _fontFocus; + } } - if (!back && _back) back = _back; - if (!image && _image) image = _image; + if (!back && _back) { + back = _back; + } + if (!image && _image) { + image = _image; + } if (_text && !font) { - if (_font) font = _font; - else font = _gameRef->_systemFont; + if (_font) { + font = _font; + } else { + font = _gameRef->_systemFont; + } } int imageX = offsetX + _posX; @@ -626,23 +730,39 @@ bool UIButton::display(int offsetX, int offsetY) { imageY += (_height - (rc.bottom - rc.top)) / 2; } - if (back) back->display(offsetX + _posX, offsetY + _posY, _width, _height); + if (back) { + back->display(offsetX + _posX, offsetY + _posY, _width, _height); + } //if (image) image->Draw(ImageX +((_press||_oneTimePress)&&back?1:0), ImageY +((_press||_oneTimePress)&&back?1:0), NULL); - if (image) image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + if (image) { + image->draw(imageX + ((_press || _oneTimePress) && back ? 1 : 0), imageY + ((_press || _oneTimePress) && back ? 1 : 0), _pixelPerfect ? this : NULL); + } if (font && _text) { int text_offset = (_height - font->getTextHeight((byte *)_text, _width)) / 2; font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align); } - if (!_pixelPerfect || !_image) _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + if (!_pixelPerfect || !_image) { + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false)); + } // reset unused sprites - if (_image && _image != image) _image->reset(); - if (_imageDisable && _imageDisable != image) _imageDisable->reset(); - if (_imageFocus && _imageFocus != image) _imageFocus->reset(); - if (_imagePress && _imagePress != image) _imagePress->reset(); - if (_imageHover && _imageHover != image) _imageHover->reset(); + if (_image && _image != image) { + _image->reset(); + } + if (_imageDisable && _imageDisable != image) { + _imageDisable->reset(); + } + if (_imageFocus && _imageFocus != image) { + _imageFocus->reset(); + } + if (_imagePress && _imagePress != image) { + _imagePress->reset(); + } + if (_imageHover && _imageHover != image) { + _imageHover->reset(); + } _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this; @@ -653,8 +773,12 @@ bool UIButton::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// void UIButton::press() { applyEvent("Press"); - if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); - if (_parentNotify && _parent) _parent->applyEvent(getName()); + if (_listenerObject) { + _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); + } + if (_parentNotify && _parent) { + _parent->applyEvent(getName()); + } _oneTimePress = false; } @@ -669,14 +793,16 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetDisabledFont") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); - if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable); - if (Val->isNULL()) { + if (_fontDisable) { + _gameRef->_fontStorage->removeFont(_fontDisable); + } + if (val->isNULL()) { _fontDisable = NULL; stack->pushBool(true); } else { - _fontDisable = _gameRef->_fontStorage->addFont(Val->getString()); + _fontDisable = _gameRef->_fontStorage->addFont(val->getString()); stack->pushBool(_fontDisable != NULL); } return STATUS_OK; @@ -689,7 +815,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); - if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover); + if (_fontHover) { + _gameRef->_fontStorage->removeFont(_fontHover); + } if (val->isNULL()) { _fontHover = NULL; stack->pushBool(true); @@ -705,14 +833,16 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPressedFont") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); - if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress); - if (Val->isNULL()) { + if (_fontPress) { + _gameRef->_fontStorage->removeFont(_fontPress); + } + if (val->isNULL()) { _fontPress = NULL; stack->pushBool(true); } else { - _fontPress = _gameRef->_fontStorage->addFont(Val->getString()); + _fontPress = _gameRef->_fontStorage->addFont(val->getString()); stack->pushBool(_fontPress != NULL); } return STATUS_OK; @@ -725,7 +855,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); - if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus); + if (_fontFocus) { + _gameRef->_fontStorage->removeFont(_fontFocus); + } if (val->isNULL()) { _fontFocus = NULL; stack->pushBool(true); @@ -749,7 +881,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _imageDisable; _imageDisable = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -759,8 +893,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDisabledImage") == 0) { stack->correctParams(0); - if (!_imageDisable || !_imageDisable->getFilename()) stack->pushNULL(); - else stack->pushString(_imageDisable->getFilename()); + if (!_imageDisable || !_imageDisable->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageDisable->getFilename()); + } return STATUS_OK; } @@ -770,8 +907,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDisabledImageObject") == 0) { stack->correctParams(0); - if (!_imageDisable) stack->pushNULL(); - else stack->pushNative(_imageDisable, true); + if (!_imageDisable) { + stack->pushNULL(); + } else { + stack->pushNative(_imageDisable, true); + } return STATUS_OK; } @@ -790,7 +930,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _imageHover; _imageHover = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -800,8 +942,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverImage") == 0) { stack->correctParams(0); - if (!_imageHover || !_imageHover->getFilename()) stack->pushNULL(); - else stack->pushString(_imageHover->getFilename()); + if (!_imageHover || !_imageHover->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageHover->getFilename()); + } return STATUS_OK; } @@ -811,8 +956,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHoverImageObject") == 0) { stack->correctParams(0); - if (!_imageHover) stack->pushNULL(); - else stack->pushNative(_imageHover, true); + if (!_imageHover) { + stack->pushNULL(); + } else { + stack->pushNative(_imageHover, true); + } return STATUS_OK; } @@ -830,7 +978,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _imagePress; _imagePress = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -840,8 +990,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPressedImage") == 0) { stack->correctParams(0); - if (!_imagePress || !_imagePress->getFilename()) stack->pushNULL(); - else stack->pushString(_imagePress->getFilename()); + if (!_imagePress || !_imagePress->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imagePress->getFilename()); + } return STATUS_OK; } @@ -851,8 +1004,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPressedImageObject") == 0) { stack->correctParams(0); - if (!_imagePress) stack->pushNULL(); - else stack->pushNative(_imagePress, true); + if (!_imagePress) { + stack->pushNULL(); + } else { + stack->pushNative(_imagePress, true); + } return STATUS_OK; } @@ -870,7 +1026,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _imageFocus; _imageFocus = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -880,8 +1038,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFocusedImage") == 0) { stack->correctParams(0); - if (!_imageFocus || !_imageFocus->getFilename()) stack->pushNULL(); - else stack->pushString(_imageFocus->getFilename()); + if (!_imageFocus || !_imageFocus->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageFocus->getFilename()); + } return STATUS_OK; } @@ -891,8 +1052,11 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFocusedImageObject") == 0) { stack->correctParams(0); - if (!_imageFocus) stack->pushNULL(); - else stack->pushNative(_imageFocus, true); + if (!_imageFocus) { + stack->pushNULL(); + } else { + stack->pushNative(_imageFocus, true); + } return STATUS_OK; } @@ -910,10 +1074,9 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushNULL(); return STATUS_OK; + } else { + return UIObject::scCallMethod(script, stack, thisStack, name); } - - - else return UIObject::scCallMethod(script, stack, thisStack, name); } @@ -957,9 +1120,9 @@ ScValue *UIButton::scGetProperty(const char *name) { else if (strcmp(name, "PixelPerfect") == 0) { _scValue->setBool(_pixelPerfect); return _scValue; + } else { + return UIObject::scGetProperty(name); } - - else return UIObject::scGetProperty(name); } @@ -970,7 +1133,9 @@ bool UIButton::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + if (i < 0 || i >= NUM_TEXT_ALIGN) { + i = 0; + } _align = (TTextAlign)i; return STATUS_OK; } @@ -995,9 +1160,9 @@ bool UIButton::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "PixelPerfect") == 0) { _pixelPerfect = value->getBool(); return STATUS_OK; + } else { + return UIObject::scSetProperty(name, value); } - - else return UIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 988f56ae17..22d477bc31 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -81,7 +81,9 @@ UIEdit::UIEdit(BaseGame *inGame): UIObject(inGame) { ////////////////////////////////////////////////////////////////////////// UIEdit::~UIEdit() { if (!_sharedFonts) { - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + if (_fontSelected) { + _gameRef->_fontStorage->removeFont(_fontSelected); + } } delete[] _cursorChar; @@ -101,7 +103,9 @@ bool UIEdit::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename); + } delete[] buffer; @@ -175,7 +179,9 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -203,15 +209,23 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; + if (!_font) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_SELECTED: - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + if (_fontSelected) { + _gameRef->_fontStorage->removeFont(_fontSelected); + } _fontSelected = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontSelected) cmd = PARSERR_GENERIC; + if (!_fontSelected) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_TEXT: @@ -306,24 +320,30 @@ bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->getFilename()) + if (_back && _back->getFilename()) { buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + } - if (_image && _image->getFilename()) + if (_image && _image->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + } - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_fontSelected && _fontSelected->getFilename()) + } + if (_fontSelected && _fontSelected->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_SELECTED=\"%s\"\n", _fontSelected->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } buffer->putTextIndent(indent + 2, "\n"); - if (_text) + if (_text) { buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + } buffer->putTextIndent(indent + 2, "\n"); @@ -363,14 +383,16 @@ bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (strcmp(name, "SetSelectedFont") == 0) { stack->correctParams(1); - if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected); + if (_fontSelected) { + _gameRef->_fontStorage->removeFont(_fontSelected); + } _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontSelected != NULL); return STATUS_OK; + } else { + return UIObject::scCallMethod(script, stack, thisStack, name); } - - else return UIObject::scCallMethod(script, stack, thisStack, name); } @@ -445,9 +467,9 @@ ScValue *UIEdit::scGetProperty(const char *name) { _scValue->setString(_text); } return _scValue; + } else { + return UIObject::scGetProperty(name); } - - else return UIObject::scGetProperty(name); } @@ -459,7 +481,7 @@ bool UIEdit::scSetProperty(const char *name, ScValue *value) { if (strcmp(name, "SelStart") == 0) { _selStart = value->getInt(); _selStart = MAX(_selStart, 0); - _selStart = MIN((size_t)_selStart, strlen(_text)); + _selStart = (int)MIN((size_t)_selStart, strlen(_text)); return STATUS_OK; } @@ -469,7 +491,7 @@ bool UIEdit::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "SelEnd") == 0) { _selEnd = value->getInt(); _selEnd = MAX(_selEnd, 0); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); + _selEnd = (int)MIN((size_t)_selEnd, strlen(_text)); return STATUS_OK; } @@ -477,7 +499,7 @@ bool UIEdit::scSetProperty(const char *name, ScValue *value) { // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CursorBlinkRate") == 0) { - _cursorBlinkRate = value->getInt(); + _cursorBlinkRate = (uint32)value->getInt(); return STATUS_OK; } @@ -516,9 +538,9 @@ bool UIEdit::scSetProperty(const char *name, ScValue *value) { setText(value->getString()); } return STATUS_OK; + } else { + return UIObject::scSetProperty(name, value); } - - else return UIObject::scSetProperty(name, value); } @@ -530,42 +552,58 @@ const char *UIEdit::scToString() { ////////////////////////////////////////////////////////////////////////// void UIEdit::setCursorChar(const char *character) { - if (!character) return; + if (!character) { + return; + } delete[] _cursorChar; _cursorChar = new char [strlen(character) + 1]; - if (_cursorChar) strcpy(_cursorChar, character); + if (_cursorChar) { + strcpy(_cursorChar, character); + } } ////////////////////////////////////////////////////////////////////////// bool UIEdit::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; + if (!_visible) { + return STATUS_OK; + } // hack! TTextEncoding OrigEncoding = _gameRef->_textEncoding; _gameRef->_textEncoding = TEXT_ANSI; - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + if (_back) { + _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + } + if (_image) { + _image->draw(offsetX + _posX, offsetY + _posY, NULL); + } // prepare fonts BaseFont *font; BaseFont *sfont; - if (_font) font = _font; - else font = _gameRef->_systemFont; + if (_font) { + font = _font; + } else { + font = _gameRef->_systemFont; + } - if (_fontSelected) sfont = _fontSelected; - else sfont = font; + if (_fontSelected) { + sfont = _fontSelected; + } else { + sfont = font; + } bool focused = isFocused(); _selStart = MAX(_selStart, 0); _selEnd = MAX(_selEnd, 0); - _selStart = MIN((size_t)_selStart, strlen(_text)); - _selEnd = MIN((size_t)_selEnd, strlen(_text)); + _selStart = (int)MIN((size_t)_selStart, strlen(_text)); + _selEnd = (int)MIN((size_t)_selEnd, strlen(_text)); //int CursorWidth = font->GetCharWidth(_cursorChar[0]); int cursorWidth = font->getTextWidth((byte *)_cursorChar); @@ -576,7 +614,9 @@ bool UIEdit::display(int offsetX, int offsetY) { if (_selStart >= _selEnd) { while (font->getTextWidth((byte *)_text + _scrollOffset, MAX(0, _selEnd - _scrollOffset)) > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; + if (_scrollOffset >= (int)strlen(_text)) { + break; + } } _scrollOffset = MIN(_scrollOffset, _selEnd); @@ -590,7 +630,9 @@ bool UIEdit::display(int offsetX, int offsetY) { > _width - cursorWidth - 2 * _frameWidth) { _scrollOffset++; - if (_scrollOffset >= (int)strlen(_text)) break; + if (_scrollOffset >= (int)strlen(_text)) { + break; + } } _scrollOffset = MIN(_scrollOffset, _selEnd); @@ -601,9 +643,9 @@ bool UIEdit::display(int offsetX, int offsetY) { } - int AlignOffset = 0; + int alignOffset = 0; - for (int Count = 0; Count < 2; Count++) { + for (int count = 0; count < 2; count++) { // draw text int xxx, yyy, width, height; @@ -613,61 +655,73 @@ bool UIEdit::display(int offsetX, int offsetY) { width = _posX + _width + offsetX - _frameWidth; height = MAX(font->getLetterHeight(), sfont->getLetterHeight()); - if (_gameRef->_textRTL) xxx += AlignOffset; + if (_gameRef->_textRTL) { + xxx += alignOffset; + } - TTextAlign Align = TAL_LEFT; + TTextAlign align = TAL_LEFT; // unselected 1 if (s1 > _scrollOffset) { - if (Count) font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, Align, height, s1 - _scrollOffset); + if (count) { + font->drawText((byte *)_text + _scrollOffset, xxx, yyy, width - xxx, align, height, s1 - _scrollOffset); + } xxx += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); - AlignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); + alignOffset += font->getTextWidth((byte *)_text + _scrollOffset, s1 - _scrollOffset); } // cursor if (focused && curFirst) { - if (Count) { + if (count) { if (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { _lastBlinkTime = g_system->getMillis(); _cursorVisible = !_cursorVisible; } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + if (_cursorVisible) { + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, align, height, 1); + } } xxx += cursorWidth; - AlignOffset += cursorWidth; + alignOffset += cursorWidth; } // selected int s3 = MAX(s1, _scrollOffset); if (s2 - s3 > 0) { - if (Count) sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, Align, height, s2 - s3); + if (count) { + sfont->drawText((byte *)_text + s3, xxx, yyy, width - xxx, align, height, s2 - s3); + } xxx += sfont->getTextWidth((byte *)_text + s3, s2 - s3); - AlignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); + alignOffset += sfont->getTextWidth((byte *)_text + s3, s2 - s3); } // cursor if (focused && !curFirst) { - if (Count) { + if (count) { if (g_system->getMillis() - _lastBlinkTime >= _cursorBlinkRate) { _lastBlinkTime = g_system->getMillis(); _cursorVisible = !_cursorVisible; } - if (_cursorVisible) - font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, Align, height, 1); + if (_cursorVisible) { + font->drawText((byte *)_cursorChar, xxx, yyy, width - xxx, align, height, 1); + } } xxx += cursorWidth; - AlignOffset += cursorWidth; + alignOffset += cursorWidth; } // unselected 2 - if (Count) font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, Align, height); - AlignOffset += font->getTextWidth((byte *)_text + s2); + if (count) { + font->drawText((byte *)_text + s2, xxx, yyy, width - xxx, align, height); + } + alignOffset += font->getTextWidth((byte *)_text + s2); - AlignOffset = (_width - 2 * _frameWidth) - AlignOffset; - if (AlignOffset < 0) AlignOffset = 0; + alignOffset = (_width - 2 * _frameWidth) - alignOffset; + if (alignOffset < 0) { + alignOffset = 0; + } } @@ -702,10 +756,17 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_BACKSPACE: if (_selStart == _selEnd) { - if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1); - else deleteChars(_selStart - 1, _selStart); - } else deleteChars(_selStart, _selEnd); - if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart); + if (_gameRef->_textRTL) { + deleteChars(_selStart, _selStart + 1); + } else { + deleteChars(_selStart - 1, _selStart); + } + } else { + deleteChars(_selStart, _selEnd); + } + if (_selEnd >= _selStart) { + _selEnd -= MAX(1, _selEnd - _selStart); + } _selStart = _selEnd; handled = true; @@ -714,24 +775,32 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_LEFT: case Common::KEYCODE_UP: _selEnd--; - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } handled = true; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_DOWN: _selEnd++; - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } handled = true; break; case Common::KEYCODE_HOME: if (_gameRef->_textRTL) { _selEnd = strlen(_text); - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } } else { _selEnd = 0; - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } } handled = true; break; @@ -739,10 +808,14 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_END: if (_gameRef->_textRTL) { _selEnd = 0; - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } } else { _selEnd = strlen(_text); - if (!BaseKeyboardState::isShiftDown()) _selStart = _selEnd; + if (!BaseKeyboardState::isShiftDown()) { + _selStart = _selEnd; + } } handled = true; break; @@ -752,10 +825,18 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { if (_gameRef->_textRTL) { deleteChars(_selStart - 1, _selStart); _selEnd--; - if (_selEnd < 0) _selEnd = 0; - } else deleteChars(_selStart, _selStart + 1); - } else deleteChars(_selStart, _selEnd); - if (_selEnd > _selStart) _selEnd -= (_selEnd - _selStart); + if (_selEnd < 0) { + _selEnd = 0; + } + } else { + deleteChars(_selStart, _selStart + 1); + } + } else { + deleteChars(_selStart, _selEnd); + } + if (_selEnd > _selStart) { + _selEnd -= (_selEnd - _selStart); + } _selStart = _selEnd; handled = true; @@ -765,15 +846,20 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { } return handled; } else if (event->type == Common::EVENT_KEYDOWN && printable) { - if (_selStart != _selEnd) deleteChars(_selStart, _selEnd); + if (_selStart != _selEnd) { + deleteChars(_selStart, _selEnd); + } //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); WideString wstr; wstr += (char)event->kbd.ascii; _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); - if (_gameRef->_textRTL) _selEnd = _selStart; - else _selStart = _selEnd; + if (_gameRef->_textRTL) { + _selEnd = _selStart; + } else { + _selStart = _selEnd; + } return true; } @@ -785,20 +871,26 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// int UIEdit::deleteChars(int start, int end) { - if (start > end) BaseUtils::swap(&start, &end); + if (start > end) { + BaseUtils::swap(&start, &end); + } start = MAX(start, (int)0); end = MIN((size_t)end, strlen(_text)); char *str = new char[strlen(_text) - (end - start) + 1]; if (str) { - if (start > 0) memcpy(str, _text, start); + if (start > 0) { + memcpy(str, _text, start); + } memcpy(str + MAX(0, start), _text + end, strlen(_text) - end + 1); delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->applyEvent(getName()); + if (_parentNotify && _parent) { + _parent->applyEvent(getName()); + } return end - start; } @@ -815,7 +907,9 @@ int UIEdit::insertChars(int pos, byte *chars, int num) { char *str = new char[strlen(_text) + num + 1]; if (str) { - if (pos > 0) memcpy(str, _text, pos); + if (pos > 0) { + memcpy(str, _text, pos); + } memcpy(str + pos + num, _text + pos, strlen(_text) - pos + 1); memcpy(str + pos, chars, num); @@ -823,7 +917,9 @@ int UIEdit::insertChars(int pos, byte *chars, int num) { delete[] _text; _text = str; } - if (_parentNotify && _parent) _parent->applyEvent(getName()); + if (_parentNotify && _parent) { + _parent->applyEvent(getName()); + } return num; } diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 21fa3120ba..c2438b0fc6 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -49,7 +49,9 @@ UIEntity::UIEntity(BaseGame *inGame): UIObject(inGame) { ////////////////////////////////////////////////////////////////////////// UIEntity::~UIEntity() { - if (_entity) _gameRef->unregisterObject(_entity); + if (_entity) { + _gameRef->unregisterObject(_entity); + } _entity = NULL; } @@ -66,7 +68,9 @@ bool UIEntity::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename); + } delete[] buffer; @@ -117,7 +121,9 @@ bool UIEntity::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -141,7 +147,9 @@ bool UIEntity::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ENTITY: - if (DID_FAIL(setEntity((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(setEntity((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_SCRIPT: @@ -187,8 +195,9 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "DISABLED=%s\n", _disable ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "VISIBLE=%s\n", _visible ? "TRUE" : "FALSE"); - if (_entity && _entity->getFilename()) + if (_entity && _entity->getFilename()) { buffer->putTextIndent(indent + 2, "ENTITY=\"%s\"\n", _entity->getFilename()); + } buffer->putTextIndent(indent + 2, "\n"); @@ -208,7 +217,9 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool UIEntity::setEntity(const char *filename) { - if (_entity) _gameRef->unregisterObject(_entity); + if (_entity) { + _gameRef->unregisterObject(_entity); + } _entity = new AdEntity(_gameRef); if (!_entity || DID_FAIL(_entity->loadFile(filename))) { delete _entity; @@ -225,19 +236,25 @@ bool UIEntity::setEntity(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool UIEntity::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; + if (!_visible) { + return STATUS_OK; + } if (_entity) { _entity->_posX = offsetX + _posX; _entity->_posY = offsetY + _posY; - if (_entity->_scale < 0) _entity->_zoomable = false; + if (_entity->_scale < 0) { + _entity->_zoomable = false; + } _entity->_shadowable = false; _entity->update(); bool origReg = _entity->_registrable; - if (_entity->_registrable && _disable) _entity->_registrable = false; + if (_entity->_registrable && _disable) { + _entity->_registrable = false; + } _entity->display(); _entity->_registrable = origReg; @@ -257,8 +274,11 @@ bool UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (strcmp(name, "GetEntity") == 0) { stack->correctParams(0); - if (_entity) stack->pushNative(_entity, true); - else stack->pushNULL(); + if (_entity) { + stack->pushNative(_entity, true); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -271,15 +291,16 @@ bool UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(setEntity(filename))) + if (DID_SUCCEED(setEntity(filename))) { stack->pushBool(true); - else + } else { stack->pushBool(false); + } return STATUS_OK; + } else { + return UIObject::scCallMethod(script, stack, thisStack, name); } - - else return UIObject::scCallMethod(script, stack, thisStack, name); } @@ -299,12 +320,15 @@ ScValue *UIEntity::scGetProperty(const char *name) { // Freezable ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Freezable") == 0) { - if (_entity) _scValue->setBool(_entity->_freezable); - else _scValue->setBool(false); + if (_entity) { + _scValue->setBool(_entity->_freezable); + } else { + _scValue->setBool(false); + } return _scValue; + } else { + return UIObject::scGetProperty(name); } - - else return UIObject::scGetProperty(name); } @@ -314,9 +338,13 @@ bool UIEntity::scSetProperty(const char *name, ScValue *value) { // Freezable ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Freezable") == 0) { - if (_entity) _entity->makeFreezable(value->getBool()); + if (_entity) { + _entity->makeFreezable(value->getBool()); + } return STATUS_OK; - } else return UIObject::scSetProperty(name, value); + } else { + return UIObject::scSetProperty(name, value); + } } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index ed58079ad2..e44bb0f741 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -71,14 +71,24 @@ UIObject::UIObject(BaseGame *inGame): BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// UIObject::~UIObject() { - if (!_gameRef->_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(BaseGame::invalidateValues, "ScValue", (void *)this); + if (!_gameRef->_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(BaseGame::invalidateValues, "ScValue", (void *)this); + } - if (_back) delete _back; - if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font); + if (_back) { + delete _back; + } + if (_font && !_sharedFonts) { + _gameRef->_fontStorage->removeFont(_font); + } - if (_image && !_sharedImages) delete _image; + if (_image && !_sharedImages) { + delete _image; + } - if (_text) delete[] _text; + if (_text) { + delete[] _text; + } _focusedWidget = NULL; // ref only } @@ -86,12 +96,16 @@ UIObject::~UIObject() { ////////////////////////////////////////////////////////////////////////// void UIObject::setText(const char *text) { - if (_text) delete[] _text; + if (_text) { + delete[] _text; + } _text = new char [strlen(text) + 1]; if (_text) { strcpy(_text, text); for (int i = 0; i < strlen(_text); i++) { - if (_text[i] == '|') _text[i] = '\n'; + if (_text[i] == '|') { + _text[i] = '\n'; + } } } } @@ -119,7 +133,9 @@ void UIObject::correctSize() { if (_image) { _image->getBoundingRect(&rect, 0, 0); _width = rect.right - rect.left; - } else _width = 100; + } else { + _width = 100; + } } if (_height <= 0) { @@ -129,7 +145,9 @@ void UIObject::correctSize() { } } - if (_back) _back->correctSize(&_width, &_height); + if (_back) { + _back->correctSize(&_width, &_height); + } } @@ -143,14 +161,16 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFont") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); - if (_font) _gameRef->_fontStorage->removeFont(_font); - if (Val->isNULL()) { + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } + if (val->isNULL()) { _font = NULL; stack->pushBool(true); } else { - _font = _gameRef->_fontStorage->addFont(Val->getString()); + _font = _gameRef->_fontStorage->addFont(val->getString()); stack->pushBool(_font != NULL); } return STATUS_OK; @@ -177,7 +197,9 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _image; _image = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -187,8 +209,11 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetImage") == 0) { stack->correctParams(0); - if (!_image || !_image->getFilename()) stack->pushNULL(); - else stack->pushString(_image->getFilename()); + if (!_image || !_image->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_image->getFilename()); + } return STATUS_OK; } @@ -198,8 +223,11 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetImageObject") == 0) { stack->correctParams(0); - if (!_image) stack->pushNULL(); - else stack->pushNative(_image, true); + if (!_image) { + stack->pushNULL(); + } else { + stack->pushNative(_image, true); + } return STATUS_OK; } @@ -251,8 +279,12 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool done = false; for (int j = 0; j < win->_widgets.getSize(); j++) { if (win->_widgets[j] == this) { - if (strcmp(name, "MoveAfter") == 0) i++; - if (j >= i) j++; + if (strcmp(name, "MoveAfter") == 0) { + i++; + } + if (j >= i) { + j++; + } win->_widgets.insertAt(i, this); win->_widgets.removeAt(j); @@ -262,10 +294,16 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack break; } } - if (!done) stack->pushBool(false); - } else stack->pushBool(false); + if (!done) { + stack->pushBool(false); + } + } else { + stack->pushBool(false); + } - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -286,7 +324,9 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -307,12 +347,14 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -402,18 +444,22 @@ ScValue *UIObject::scGetProperty(const char *name) { for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.getSize() - 1) _scValue->setNative(win->_widgets[i + 1], true); + if (i < win->_widgets.getSize() - 1) { + _scValue->setNative(win->_widgets[i + 1], true); + } } else { - if (i > 0) _scValue->setNative(win->_widgets[i - 1], true); + if (i > 0) { + _scValue->setNative(win->_widgets[i - 1], true); + } } break; } } } return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -473,9 +519,9 @@ bool UIObject::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "Text") == 0) { setText(value->getString()); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -487,13 +533,20 @@ const char *UIObject::scToString() { ////////////////////////////////////////////////////////////////////////// bool UIObject::isFocused() { - if (!_gameRef->_focusedWindow) return false; - if (_gameRef->_focusedWindow == this) return true; + if (!_gameRef->_focusedWindow) { + return false; + } + if (_gameRef->_focusedWindow == this) { + return true; + } UIObject *obj = _gameRef->_focusedWindow; while (obj) { - if (obj == this) return true; - else obj = obj->_focusedWidget; + if (obj == this) { + return true; + } else { + obj = obj->_focusedWidget; + } } return false; } @@ -524,9 +577,13 @@ bool UIObject::focus() { obj = this; while (obj) { if (obj->_parent) { - if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj; + if (!obj->_disable && obj->_canFocus) { + obj->_parent->_focusedWidget = obj; + } } else { - if (obj->_type == UI_WINDOW) _gameRef->focusWindow((UIWindow *)obj); + if (obj->_type == UI_WINDOW) { + _gameRef->focusWindow((UIWindow *)obj); + } } obj = obj->_parent; @@ -547,8 +604,12 @@ bool UIObject::getTotalOffset(int *offsetX, int *offsetY) { obj = obj->_parent; } - if (offsetX) *offsetX = offX; - if (offsetY) *offsetY = offY; + if (offsetX) { + *offsetX = offX; + } + if (offsetY) { + *offsetY = offY; + } return STATUS_OK; } diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 6d838b8d37..25fef4fd93 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -62,14 +62,22 @@ UIText::~UIText() { ////////////////////////////////////////////////////////////////////////// bool UIText::display(int offsetX, int offsetY) { - if (!_visible) return STATUS_OK; + if (!_visible) { + return STATUS_OK; + } BaseFont *font = _font; - if (!font) font = _gameRef->_systemFont; + if (!font) { + font = _gameRef->_systemFont; + } - if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height); - if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL); + if (_back) { + _back->display(offsetX + _posX, offsetY + _posY, _width, _height); + } + if (_image) { + _image->draw(offsetX + _posX, offsetY + _posY, NULL); + } if (font && _text) { int textOffset; @@ -105,7 +113,9 @@ bool UIText::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename); + } delete[] buffer; @@ -175,7 +185,9 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -207,9 +219,13 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; + if (!_font) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_TEXT: @@ -218,15 +234,23 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TEXT_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _textAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _textAlign = TAL_RIGHT; - else _textAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) { + _textAlign = TAL_LEFT; + } else if (scumm_stricmp((char *)params, "right") == 0) { + _textAlign = TAL_RIGHT; + } else { + _textAlign = TAL_CENTER; + } break; case TOKEN_VERTICAL_ALIGN: - if (scumm_stricmp((char *)params, "top") == 0) _verticalAlign = VAL_TOP; - else if (scumm_stricmp((char *)params, "bottom") == 0) _verticalAlign = VAL_BOTTOM; - else _verticalAlign = VAL_CENTER; + if (scumm_stricmp((char *)params, "top") == 0) { + _verticalAlign = VAL_TOP; + } else if (scumm_stricmp((char *)params, "bottom") == 0) { + _verticalAlign = VAL_BOTTOM; + } else { + _verticalAlign = VAL_CENTER; + } break; case TOKEN_X: @@ -300,20 +324,25 @@ bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->getFilename()) + if (_back && _back->getFilename()) { buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); + } - if (_image && _image->getFilename()) + if (_image && _image->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); + } - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } - if (_text) + if (_text) { buffer->putTextIndent(indent + 2, "TEXT=\"%s\"\n", _text); + } switch (_textAlign) { case TAL_LEFT: @@ -390,12 +419,14 @@ bool UIText::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HeightToFit") == 0) { stack->correctParams(0); - if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width); + if (_font && _text) { + _height = _font->getTextHeight((byte *)_text, _width); + } stack->pushNULL(); return STATUS_OK; + } else { + return UIObject::scCallMethod(script, stack, thisStack, name); } - - else return UIObject::scCallMethod(script, stack, thisStack, name); } @@ -425,9 +456,9 @@ ScValue *UIText::scGetProperty(const char *name) { else if (strcmp(name, "VerticalAlign") == 0) { _scValue->setInt(_verticalAlign); return _scValue; + } else { + return UIObject::scGetProperty(name); } - - else return UIObject::scGetProperty(name); } @@ -438,7 +469,9 @@ bool UIText::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "TextAlign") == 0) { int i = value->getInt(); - if (i < 0 || i >= NUM_TEXT_ALIGN) i = 0; + if (i < 0 || i >= NUM_TEXT_ALIGN) { + i = 0; + } _textAlign = (TTextAlign)i; return STATUS_OK; } @@ -448,12 +481,14 @@ bool UIText::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "VerticalAlign") == 0) { int i = value->getInt(); - if (i < 0 || i >= NUM_VERTICAL_ALIGN) i = 0; + if (i < 0 || i >= NUM_VERTICAL_ALIGN) { + i = 0; + } _verticalAlign = (TVerticalAlign)i; return STATUS_OK; + } else { + return UIObject::scSetProperty(name, value); } - - else return UIObject::scSetProperty(name, value); } diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index e0b2a75ee4..c11361de8d 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -64,7 +64,9 @@ UITiledImage::~UITiledImage() { ////////////////////////////////////////////////////////////////////////// bool UITiledImage::display(int x, int y, int width, int height) { - if (!_image) return STATUS_FAILED; + if (!_image) { + return STATUS_FAILED; + } int tileWidth = _middleMiddle.right - _middleMiddle.left; int tileHeight = _middleMiddle.bottom - _middleMiddle.top; @@ -129,7 +131,9 @@ bool UITiledImage::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename); + } delete[] buffer; @@ -193,7 +197,9 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_IMAGE: @@ -288,17 +294,35 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { int width = _image->_surface->getWidth() / 3; int height = _image->_surface->getHeight() / 3; - if (BasePlatform::isRectEmpty(&_upLeft)) BasePlatform::setRect(&_upLeft, 0, 0, width, height); - if (BasePlatform::isRectEmpty(&_upMiddle)) BasePlatform::setRect(&_upMiddle, width, 0, 2 * width, height); - if (BasePlatform::isRectEmpty(&_upRight)) BasePlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + if (BasePlatform::isRectEmpty(&_upLeft)) { + BasePlatform::setRect(&_upLeft, 0, 0, width, height); + } + if (BasePlatform::isRectEmpty(&_upMiddle)) { + BasePlatform::setRect(&_upMiddle, width, 0, 2 * width, height); + } + if (BasePlatform::isRectEmpty(&_upRight)) { + BasePlatform::setRect(&_upRight, 2 * width, 0, 3 * width, height); + } - if (BasePlatform::isRectEmpty(&_middleLeft)) BasePlatform::setRect(&_middleLeft, 0, height, width, 2 * height); - if (BasePlatform::isRectEmpty(&_middleMiddle)) BasePlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); - if (BasePlatform::isRectEmpty(&_middleRight)) BasePlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + if (BasePlatform::isRectEmpty(&_middleLeft)) { + BasePlatform::setRect(&_middleLeft, 0, height, width, 2 * height); + } + if (BasePlatform::isRectEmpty(&_middleMiddle)) { + BasePlatform::setRect(&_middleMiddle, width, height, 2 * width, 2 * height); + } + if (BasePlatform::isRectEmpty(&_middleRight)) { + BasePlatform::setRect(&_middleRight, 2 * width, height, 3 * width, 2 * height); + } - if (BasePlatform::isRectEmpty(&_downLeft)) BasePlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); - if (BasePlatform::isRectEmpty(&_downMiddle)) BasePlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); - if (BasePlatform::isRectEmpty(&_downRight)) BasePlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + if (BasePlatform::isRectEmpty(&_downLeft)) { + BasePlatform::setRect(&_downLeft, 0, 2 * height, width, 3 * height); + } + if (BasePlatform::isRectEmpty(&_downMiddle)) { + BasePlatform::setRect(&_downMiddle, width, 2 * height, 2 * width, 3 * height); + } + if (BasePlatform::isRectEmpty(&_downRight)) { + BasePlatform::setRect(&_downRight, 2 * width, 2 * height, 3 * width, 3 * height); + } } return STATUS_OK; @@ -309,8 +333,9 @@ bool UITiledImage::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TILED_IMAGE\n"); buffer->putTextIndent(indent, "{\n"); - if (_image && _image->_surfaceFilename) + if (_image && _image->_surfaceFilename) { buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + } int h1, h2, h3; int v1, v2, v3; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index b14c832397..f221405f15 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -103,10 +103,16 @@ void UIWindow::cleanup() { _viewport = NULL; delete _backInactive; - if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); - if (!_sharedImages && _imageInactive) delete _imageInactive; + if (!_sharedFonts && _fontInactive) { + _gameRef->_fontStorage->removeFont(_fontInactive); + } + if (!_sharedImages && _imageInactive) { + delete _imageInactive; + } - for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i]; + for (int i = 0; i < _widgets.getSize(); i++) { + delete _widgets[i]; + } _widgets.removeAll(); } @@ -115,7 +121,9 @@ void UIWindow::cleanup() { bool UIWindow::display(int offsetX, int offsetY) { // go exclusive if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) { - if (!_shieldWindow) _shieldWindow = new UIWindow(_gameRef); + if (!_shieldWindow) { + _shieldWindow = new UIWindow(_gameRef); + } if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; _shieldWindow->_width = _gameRef->_renderer->_width; @@ -139,8 +147,9 @@ bool UIWindow::display(int offsetX, int offsetY) { } } - if (!_visible) + if (!_visible) { return STATUS_OK; + } if (_fadeBackground) { Graphics::PixelFormat format = _gameRef->_renderer->getPixelFormat(); @@ -166,7 +175,9 @@ bool UIWindow::display(int offsetX, int offsetY) { bool popViewport = false; if (_clipContents) { - if (!_viewport) _viewport = new BaseViewport(_gameRef); + if (!_viewport) { + _viewport = new BaseViewport(_gameRef); + } if (_viewport) { _viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY); _gameRef->pushViewport(_viewport); @@ -180,34 +191,46 @@ bool UIWindow::display(int offsetX, int offsetY) { BaseFont *font = _font; if (!isFocused()) { - if (_backInactive) back = _backInactive; - if (_imageInactive) image = _imageInactive; - if (_fontInactive) font = _fontInactive; + if (_backInactive) { + back = _backInactive; + } + if (_imageInactive) { + image = _imageInactive; + } + if (_fontInactive) { + font = _fontInactive; + } } - if (_alphaColor != 0) + if (_alphaColor != 0) { _gameRef->_renderer->_forceAlphaColor = _alphaColor; - if (back) + } + if (back) { back->display(_posX + offsetX, _posY + offsetY, _width, _height); - if (image) + } + if (image) { image->draw(_posX + offsetX, _posY + offsetY, _transparent ? NULL : this); + } if (!BasePlatform::isRectEmpty(&_titleRect) && font && _text) { font->drawText((byte *)_text, _posX + offsetX + _titleRect.left, _posY + offsetY + _titleRect.top, _titleRect.right - _titleRect.left, _titleAlign, _titleRect.bottom - _titleRect.top); } - if (!_transparent && !image) + if (!_transparent && !image) { _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); + } for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); } - if (_alphaColor != 0) + if (_alphaColor != 0) { _gameRef->_renderer->_forceAlphaColor = 0; + } - if (popViewport) + if (popViewport) { _gameRef->popViewport(); + } return STATUS_OK; } @@ -225,7 +248,9 @@ bool UIWindow::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename); + } delete[] buffer; @@ -330,7 +355,9 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { while (cmd >= PARSERR_TOKENNOTFOUND && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) >= PARSERR_TOKENNOTFOUND) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -382,15 +409,23 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_FONT: - if (_font) _gameRef->_fontStorage->removeFont(_font); + if (_font) { + _gameRef->_fontStorage->removeFont(_font); + } _font = _gameRef->_fontStorage->addFont((char *)params); - if (!_font) cmd = PARSERR_GENERIC; + if (!_font) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_FONT_INACTIVE: - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + if (_fontInactive) { + _gameRef->_fontStorage->removeFont(_fontInactive); + } _fontInactive = _gameRef->_fontStorage->addFont((char *)params); - if (!_fontInactive) cmd = PARSERR_GENERIC; + if (!_fontInactive) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_TITLE: @@ -399,9 +434,13 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_TITLE_ALIGN: - if (scumm_stricmp((char *)params, "left") == 0) _titleAlign = TAL_LEFT; - else if (scumm_stricmp((char *)params, "right") == 0) _titleAlign = TAL_RIGHT; - else _titleAlign = TAL_CENTER; + if (scumm_stricmp((char *)params, "left") == 0) { + _titleAlign = TAL_LEFT; + } else if (scumm_stricmp((char *)params, "right") == 0) { + _titleAlign = TAL_RIGHT; + } else { + _titleAlign = TAL_CENTER; + } break; case TOKEN_TITLE_RECT: @@ -572,8 +611,9 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { } _alphaColor = BYTETORGBA(ar, ag, ab, alpha); - if (_fadeBackground) + if (_fadeBackground) { _fadeColor = BYTETORGBA(fadeR, fadeG, fadeB, fadeA); + } _focusedWidget = NULL; @@ -590,28 +630,36 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); - if (_back && _back->getFilename()) + if (_back && _back->getFilename()) { buffer->putTextIndent(indent + 2, "BACK=\"%s\"\n", _back->getFilename()); - if (_backInactive && _backInactive->getFilename()) + } + if (_backInactive && _backInactive->getFilename()) { buffer->putTextIndent(indent + 2, "BACK_INACTIVE=\"%s\"\n", _backInactive->getFilename()); + } - if (_image && _image->getFilename()) + if (_image && _image->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getFilename()); - if (_imageInactive && _imageInactive->getFilename()) + } + if (_imageInactive && _imageInactive->getFilename()) { buffer->putTextIndent(indent + 2, "IMAGE_INACTIVE=\"%s\"\n", _imageInactive->getFilename()); + } - if (_font && _font->getFilename()) + if (_font && _font->getFilename()) { buffer->putTextIndent(indent + 2, "FONT=\"%s\"\n", _font->getFilename()); - if (_fontInactive && _fontInactive->getFilename()) + } + if (_fontInactive && _fontInactive->getFilename()) { buffer->putTextIndent(indent + 2, "FONT_INACTIVE=\"%s\"\n", _fontInactive->getFilename()); + } - if (_cursor && _cursor->getFilename()) + if (_cursor && _cursor->getFilename()) { buffer->putTextIndent(indent + 2, "CURSOR=\"%s\"\n", _cursor->getFilename()); + } buffer->putTextIndent(indent + 2, "\n"); - if (_text) + if (_text) { buffer->putTextIndent(indent + 2, "TITLE=\"%s\"\n", _text); + } switch (_titleAlign) { case TAL_LEFT: @@ -675,8 +723,9 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { BaseClass::saveAsText(buffer, indent + 2); // controls - for (int i = 0; i < _widgets.getSize(); i++) + for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent, "}\n"); @@ -686,7 +735,9 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::enableWidget(const char *name, bool Enable) { for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_disable = !Enable; + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { + _widgets[i]->_disable = !Enable; + } } return STATUS_OK; } @@ -695,7 +746,9 @@ bool UIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::showWidget(const char *name, bool Visible) { for (int i = 0; i < _widgets.getSize(); i++) { - if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_visible = Visible; + if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { + _widgets[i]->_visible = Visible; + } } return STATUS_OK; } @@ -713,8 +766,11 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (val->getType() == VAL_INT) { int widget = val->getInt(); - if (widget < 0 || widget >= _widgets.getSize()) stack->pushNULL(); - else stack->pushNative(_widgets[widget], true); + if (widget < 0 || widget >= _widgets.getSize()) { + stack->pushNULL(); + } else { + stack->pushNative(_widgets[widget], true); + } } else { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->getName(), val->getString()) == 0) { @@ -734,7 +790,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "SetInactiveFont") == 0) { stack->correctParams(1); - if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive); + if (_fontInactive) { + _gameRef->_fontStorage->removeFont(_fontInactive); + } _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString()); stack->pushBool(_fontInactive != NULL); @@ -754,7 +812,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _imageInactive; _imageInactive = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -764,8 +824,11 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInactiveImage") == 0) { stack->correctParams(0); - if (!_imageInactive || !_imageInactive->getFilename()) stack->pushNULL(); - else stack->pushString(_imageInactive->getFilename()); + if (!_imageInactive || !_imageInactive->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_imageInactive->getFilename()); + } return STATUS_OK; } @@ -775,8 +838,11 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInactiveImageObject") == 0) { stack->correctParams(0); - if (!_imageInactive) stack->pushNULL(); - else stack->pushNative(_imageInactive, true); + if (!_imageInactive) { + stack->pushNULL(); + } else { + stack->pushNative(_imageInactive, true); + } return STATUS_OK; } @@ -834,7 +900,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack cleanup(); if (!val->isNULL()) { stack->pushBool(DID_SUCCEED(loadFile(val->getString()))); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -847,7 +915,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); UIButton *btn = new UIButton(_gameRef); - if (!val->isNULL()) btn->setName(val->getString()); + if (!val->isNULL()) { + btn->setName(val->getString()); + } stack->pushNative(btn, true); btn->_parent = this; @@ -864,7 +934,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); UIText *sta = new UIText(_gameRef); - if (!val->isNULL()) sta->setName(val->getString()); + if (!val->isNULL()) { + sta->setName(val->getString()); + } stack->pushNative(sta, true); sta->_parent = this; @@ -881,7 +953,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); UIEdit *edi = new UIEdit(_gameRef); - if (!val->isNULL()) edi->setName(val->getString()); + if (!val->isNULL()) { + edi->setName(val->getString()); + } stack->pushNative(edi, true); edi->_parent = this; @@ -898,7 +972,9 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); UIWindow *win = new UIWindow(_gameRef); - if (!val->isNULL()) win->setName(val->getString()); + if (!val->isNULL()) { + win->setName(val->getString()); + } stack->pushNative(win, true); win->_parent = this; @@ -919,14 +995,20 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_widgets[i] == obj) { delete _widgets[i]; _widgets.removeAt(i); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } } } stack->pushNULL(); return STATUS_OK; - } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK; + } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) { + return STATUS_OK; + } - else return UIObject::scCallMethod(script, stack, thisStack, name); + else { + return UIObject::scCallMethod(script, stack, thisStack, name); + } } @@ -1012,9 +1094,9 @@ ScValue *UIWindow::scGetProperty(const char *name) { else if (strcmp(name, "FadeColor") == 0) { _scValue->setInt((int)_fadeColor); return _scValue; + } else { + return UIObject::scGetProperty(name); } - - else return UIObject::scGetProperty(name); } @@ -1081,9 +1163,9 @@ bool UIWindow::scSetProperty(const char *name, ScValue *value) { // Exclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exclusive") == 0) { - if (value->getBool()) + if (value->getBool()) { goExclusive(); - else { + } else { close(); _visible = true; } @@ -1094,16 +1176,16 @@ bool UIWindow::scSetProperty(const char *name, ScValue *value) { // SystemExclusive ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SystemExclusive") == 0) { - if (value->getBool()) + if (value->getBool()) { goSystemExclusive(); - else { + } else { close(); _visible = true; } return STATUS_OK; + } else { + return UIObject::scSetProperty(name, value); } - - else return UIObject::scSetProperty(name, value); } @@ -1119,8 +1201,11 @@ bool UIWindow::handleKeypress(Common::Event *event, bool printable) { if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) { return DID_SUCCEED(moveFocus(!BaseKeyboardState::isShiftDown())); } else { - if (_focusedWidget) return _focusedWidget->handleKeypress(event, printable); - else return false; + if (_focusedWidget) { + return _focusedWidget->handleKeypress(event, printable); + } else { + return false; + } } return false; } @@ -1128,8 +1213,11 @@ bool UIWindow::handleKeypress(Common::Event *event, bool printable) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::handleMouseWheel(int Delta) { - if (_focusedWidget) return _focusedWidget->handleMouseWheel(Delta); - else return false; + if (_focusedWidget) { + return _focusedWidget->handleMouseWheel(Delta); + } else { + return false; + } } @@ -1204,11 +1292,16 @@ bool UIWindow::moveFocus(bool forward) { break; } } - if (!found) _focusedWidget = NULL; + if (!found) { + _focusedWidget = NULL; + } if (!_focusedWidget) { - if (_widgets.getSize() > 0) i = 0; - else return STATUS_OK; + if (_widgets.getSize() > 0) { + i = 0; + } else { + return STATUS_OK; + } } int numTries = 0; @@ -1223,10 +1316,14 @@ bool UIWindow::moveFocus(bool forward) { if (forward) { i++; - if (i >= _widgets.getSize()) i = 0; + if (i >= _widgets.getSize()) { + i = 0; + } } else { i--; - if (i < 0) i = _widgets.getSize() - 1; + if (i < 0) { + i = _widgets.getSize() - 1; + } } numTries++; } @@ -1237,7 +1334,9 @@ bool UIWindow::moveFocus(bool forward) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::goExclusive() { - if (_mode == WINDOW_EXCLUSIVE) return STATUS_OK; + if (_mode == WINDOW_EXCLUSIVE) { + return STATUS_OK; + } if (_mode == WINDOW_NORMAL) { _ready = false; @@ -1246,13 +1345,17 @@ bool UIWindow::goExclusive() { _disable = false; _gameRef->focusWindow(this); return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool UIWindow::goSystemExclusive() { - if (_mode == WINDOW_SYSTEM_EXCLUSIVE) return STATUS_OK; + if (_mode == WINDOW_SYSTEM_EXCLUSIVE) { + return STATUS_OK; + } makeFreezable(false); @@ -1287,8 +1390,11 @@ bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { switch (obj->_type) { case UI_BUTTON: - if (scumm_stricmp(obj->getName(), "close") == 0) close(); - else return BaseObject::listen(param1, param2); + if (scumm_stricmp(obj->getName(), "close") == 0) { + close(); + } else { + return BaseObject::listen(param1, param2); + } break; default: return BaseObject::listen(param1, param2); @@ -1300,8 +1406,9 @@ bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// void UIWindow::makeFreezable(bool freezable) { - for (int i = 0; i < _widgets.getSize(); i++) + for (int i = 0; i < _widgets.getSize(); i++) { _widgets[i]->makeFreezable(freezable); + } BaseObject::makeFreezable(freezable); } @@ -1311,7 +1418,9 @@ void UIWindow::makeFreezable(bool freezable) { bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.getSize(); i++) { UIObject *control = _widgets[i]; - if (control->_disable && interactiveOnly) continue; + if (control->_disable && interactiveOnly) { + continue; + } switch (control->_type) { case UI_WINDOW: @@ -1324,7 +1433,9 @@ bool UIWindow::getWindowObjects(BaseArray &objects, bool break; default: - if (!interactiveOnly) objects.add(control); + if (!interactiveOnly) { + objects.add(control); + } } } return STATUS_OK; diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 27b2b0b727..51f0f5817e 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -37,8 +37,9 @@ AnsiString PathUtil::unifySeparators(const AnsiString &path) { AnsiString newPath = path; for (uint32 i = 0; i < newPath.size(); i++) { - if (newPath[i] == '\\') + if (newPath[i] == '\\') { newPath.setChar('/', i); + } } return newPath; @@ -56,8 +57,9 @@ AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { AnsiString newPath1 = unifySeparators(path1); AnsiString newPath2 = unifySeparators(path2); - if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) + if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) { newPath1 += "/"; + } return newPath1 + newPath2; } @@ -79,10 +81,11 @@ AnsiString PathUtil::getFileName(const AnsiString &path) { //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. Common::String lastPart = Common::lastPathComponent(newPath, '/'); - if (lastPart[lastPart.size() - 1 ] != '/') + if (lastPart[lastPart.size() - 1 ] != '/') { return lastPart; - else + } else { return path; + } //if (pos == AnsiString::npos) return path; //else return newPath.substr(pos + 1); } @@ -183,8 +186,9 @@ AnsiString PathUtil::getUserDirectory() { if (error == noErr) { char buffer[MAX_PATH_LENGTH]; error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); - if (error == noErr) + if (error == noErr) { userDir = buffer; + } } #elif __IPHONEOS__ diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index 748016d9c4..f864a8480a 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -215,14 +215,15 @@ bool StringUtil::startsWith(const AnsiString &str, const AnsiString &pattern, bo if (ignoreCase) return CompareNoCase(startPart, pattern); else return (startPart == pattern);*/ - if (!ignoreCase) + if (!ignoreCase) { return str.hasPrefix(pattern); - else { + } else { size_t strLength = str.size(); size_t patternLength = pattern.size(); - if (strLength < patternLength || patternLength == 0) + if (strLength < patternLength || patternLength == 0) { return false; + } AnsiString startPart(str.c_str(), patternLength); uint32 likeness = startPart.compareToIgnoreCase(pattern.c_str()); @@ -248,8 +249,9 @@ bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool size_t strLength = str.size(); size_t patternLength = pattern.size(); - if (strLength < patternLength || patternLength == 0) + if (strLength < patternLength || patternLength == 0) { return false; + } Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); @@ -259,8 +261,11 @@ bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool ////////////////////////////////////////////////////////////////////////// bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { - if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) return true; - else return false; + if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { + return true; + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// @@ -269,10 +274,11 @@ int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t if (pos == str.npos) return -1; else return pos;*/ const char *index = strstr(str.c_str(), toFind.c_str()); - if (index == NULL) + if (index == NULL) { return -1; - else + } else { return index - str.c_str(); + } } diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index a4751ef11b..39bb1d7137 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -48,8 +48,12 @@ void BaseUtils::swap(int *a, int *b) { ////////////////////////////////////////////////////////////////////////// float BaseUtils::normalizeAngle(float angle) { - while (angle > 360) angle -= 360; - while (angle < 0) angle += 360; + while (angle > 360) { + angle -= 360; + } + while (angle < 0) { + angle += 360; + } return angle; } @@ -81,7 +85,9 @@ void BaseUtils::debugMessage(const char *text) { char *BaseUtils::setString(char **string, const char *value) { delete[] *string; *string = new char[strlen(value) + 1]; - if (*string) strcpy(*string, value); + if (*string) { + strcpy(*string, value); + } return *string; } @@ -89,7 +95,9 @@ char *BaseUtils::setString(char **string, const char *value) { int BaseUtils::strNumEntries(const char *str, const char delim) { int numEntries = 1; for (uint32 i = 0; i < strlen(str); i++) { - if (str[i] == delim) numEntries++; + if (str[i] == delim) { + numEntries++; + } } return numEntries; } @@ -104,8 +112,11 @@ char *BaseUtils::strEntry(int entry, const char *str, const char delim) { for (uint32 i = 0; i <= strlen(str); i++) { if (numEntries == entry) { - if (!start) start = str + i; - else len++; + if (!start) { + start = str + i; + } else { + len++; + } } if (str[i] == delim || str[i] == '\0') { numEntries++; @@ -159,35 +170,46 @@ bool BaseUtils::matchesPattern(const char *pattern, const char *string) { return (stringc == 0); case '?': - if (stringc == 0) return false; + if (stringc == 0) { + return false; + } break; case '*': - if (!*pattern) return true; + if (!*pattern) { + return true; + } if (*pattern == '.') { char *dot; - if (pattern[1] == '*' && pattern[2] == 0) return true; + if (pattern[1] == '*' && pattern[2] == 0) { + return true; + } dot = (char *)strchr(string, '.'); - if (pattern[1] == 0) return (dot == NULL || dot[1] == 0); + if (pattern[1] == 0) { + return (dot == NULL || dot[1] == 0); + } if (dot != NULL) { string = dot; - if (strpbrk(pattern, "*?[") == NULL && strchr(string + 1, '.') == NULL) + if (strpbrk(pattern, "*?[") == NULL && strchr(string + 1, '.') == NULL) { return(scumm_stricmp(pattern + 1, string + 1) == 0); + } } } while (*string) - if (BaseUtils::matchesPattern(pattern, string++)) + if (BaseUtils::matchesPattern(pattern, string++)) { return true; + } return false; default: if (patternc != stringc) - if (patternc == '.' && stringc == 0) + if (patternc == '.' && stringc == 0) { return(BaseUtils::matchesPattern(pattern, string)); - else + } else { return false; + } break; } } @@ -222,19 +244,30 @@ void BaseUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { } //Chromatic data... else { - if (L < 0.5f) S = delMax / (varMax + varMin); - else S = delMax / (2.0f - varMax - varMin); + if (L < 0.5f) { + S = delMax / (varMax + varMin); + } else { + S = delMax / (2.0f - varMax - varMin); + } float delR = (((varMax - varR) / 6.0f) + (delMax / 2.0f)) / delMax; float delG = (((varMax - varG) / 6.0f) + (delMax / 2.0f)) / delMax; float delB = (((varMax - varB) / 6.0f) + (delMax / 2.0f)) / delMax; - if (varR == varMax) H = delB - delG; - else if (varG == varMax) H = (1.0f / 3.0f) + delR - delB; - else if (varB == varMax) H = (2.0f / 3.0f) + delG - delR; + if (varR == varMax) { + H = delB - delG; + } else if (varG == varMax) { + H = (1.0f / 3.0f) + delR - delB; + } else if (varB == varMax) { + H = (2.0f / 3.0f) + delG - delR; + } - if (H < 0) H += 1; - if (H > 1) H -= 1; + if (H < 0) { + H += 1; + } + if (H > 1) { + H -= 1; + } } *outH = (byte)(H * 255); @@ -259,8 +292,11 @@ uint32 BaseUtils::HSLtoRGB(byte InH, byte InS, byte InL) { } else { float var_1, var_2; - if (L < 0.5) var_2 = L * (1.0 + S); - else var_2 = (L + S) - (S * L); + if (L < 0.5) { + var_2 = L * (1.0 + S); + } else { + var_2 = (L + S) - (S * L); + } var_1 = 2.0f * L - var_2; @@ -274,11 +310,21 @@ uint32 BaseUtils::HSLtoRGB(byte InH, byte InS, byte InL) { ////////////////////////////////////////////////////////////////////////// float BaseUtils::Hue2RGB(float v1, float v2, float vH) { - if (vH < 0.0f) vH += 1.0f; - if (vH > 1.0f) vH -= 1.0f; - if ((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH); - if ((2.0f * vH) < 1.0f) return (v2); - if ((3.0f * vH) < 2.0f) return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f); + if (vH < 0.0f) { + vH += 1.0f; + } + if (vH > 1.0f) { + vH -= 1.0f; + } + if ((6.0f * vH) < 1.0f) { + return (v1 + (v2 - v1) * 6.0f * vH); + } + if ((2.0f * vH) < 1.0f) { + return (v2); + } + if ((3.0f * vH) < 2.0f) { + return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f); + } return (v1); } diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index 464cbec7ff..7affd91013 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -92,28 +92,46 @@ VideoPlayer::~VideoPlayer() { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::cleanup() { #if 0 - if (_sound) _sound->Stop(); - if (_videoPGF) AVIStreamGetFrameClose(_videoPGF); + if (_sound) { + _sound->Stop(); + } + if (_videoPGF) { + AVIStreamGetFrameClose(_videoPGF); + } _videoPGF = NULL; _playing = false; - if (_aviFile) AVIFileRelease(m_AviFile); + if (_aviFile) { + AVIFileRelease(m_AviFile); + } - if (_audioStream) AVIStreamRelease(m_AudioStream); - if (_videoStream) AVIStreamRelease(m_VideoStream); + if (_audioStream) { + AVIStreamRelease(m_AudioStream); + } + if (_videoStream) { + AVIStreamRelease(m_VideoStream); + } - if (_audioFormat) delete[](byte *)m_AudioFormat; - if (_videoFormat) delete[](byte *)m_VideoFormat; - if (_targetFormat) delete[](byte *)m_TargetFormat; + if (_audioFormat) { + delete[](byte *)m_AudioFormat; + } + if (_videoFormat) { + delete[](byte *)m_VideoFormat; + } + if (_targetFormat) { + delete[](byte *)m_TargetFormat; + } SAFE_DELETE(_sound); SAFE_DELETE(_vidRenderer); SAFE_DELETE_ARRAY(_filename); - for (int i = 0; i < _subtitles.getSize(); i++) delete _subtitles[i]; + for (int i = 0; i < _subtitles.getSize(); i++) { + delete _subtitles[i]; + } _subtitles.removeAll(); return SetDefaults(); @@ -144,10 +162,11 @@ bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { _totalVideoTime = AVIStreamEndTime(_videoStream); // get audio stream - if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) { _soundAvailable = true; - else + } else { _soundAvailable = false; + } LONG Size; @@ -169,10 +188,11 @@ bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { m_TargetFormat->bV4BitCount = 24; m_TargetFormat->bV4V4Compression = BI_RGB; - if (_gameRef->m_UseD3D) + if (_gameRef->m_UseD3D) { m_VidRenderer = new CVidRendererD3D(_gameRef); - else + } else { m_VidRenderer = new CVidRendererDD(_gameRef); + } if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); @@ -193,10 +213,14 @@ bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { } } - if (_gameRef->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + if (_gameRef->_videoSubtitles) { + LoadSubtitles(inFilename, SubtitleFile); + } _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); + if (_filename) { + strcpy(_filename, filename); + } #endif return STATUS_OK; } @@ -205,13 +229,17 @@ bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::update() { #if 0 - if (!m_Playing) return STATUS_OK; + if (!m_Playing) { + return STATUS_OK; + } bool res; if (_soundAvailable && m_Sound) { res = _sound->update(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } } @@ -263,10 +291,17 @@ bool VideoPlayer::update() { // render frame LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); if (FrameData) { - if (_slowRendering) return _vidRenderer->ProcessFrameSlow(FrameData); - else return _vidRenderer->ProcessFrame(FrameData); - } else return STATUS_FAILED; - } else return STATUS_OK; + if (_slowRendering) { + return _vidRenderer->ProcessFrameSlow(FrameData); + } else { + return _vidRenderer->ProcessFrame(FrameData); + } + } else { + return STATUS_FAILED; + } + } else { + return STATUS_OK; + } #endif return 0; } @@ -275,11 +310,16 @@ bool VideoPlayer::update() { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::display() { #if 0 - if (!m_Playing) return STATUS_OK; + if (!m_Playing) { + return STATUS_OK; + } bool res; - if (_vidRenderer) res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); - else res = STATUS_FAILED; + if (_vidRenderer) { + res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); + } else { + res = STATUS_FAILED; + } // display subtitle if (m_ShowSubtitle) { @@ -299,7 +339,9 @@ bool VideoPlayer::display() { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { #if 0 - if (!_videoStream || !_vidRenderer) return STATUS_FAILED; + if (!_videoStream || !_vidRenderer) { + return STATUS_FAILED; + } switch (Type) { case VID_PLAY_POS: @@ -339,7 +381,9 @@ bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); _slowRendering = true; } - } else _slowRendering = false; + } else { + _slowRendering = false; + } // HACK!!! _slowRendering = true; @@ -350,7 +394,9 @@ bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { _gameRef->Freeze(FreezeMusic); _playing = true; - if (_sound) _sound->Play(); + if (_sound) { + _sound->Play(); + } _startTime = timeGetTime(); #endif return STATUS_OK; @@ -360,7 +406,9 @@ bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::stop() { #if 0 - if (!_playing) return STATUS_OK; + if (!_playing) { + return STATUS_OK; + } cleanup(); @@ -379,7 +427,9 @@ bool VideoPlayer::isPlaying() { ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { #if 0 - if (!Filename) return STATUS_OK; + if (!Filename) { + return STATUS_OK; + } char NewFile[MAX_PATH_LENGTH]; char drive[_MAX_DRIVE]; @@ -395,7 +445,9 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) DWORD Size; BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); - if (Buffer == NULL) return STATUS_OK; // no subtitles + if (Buffer == NULL) { + return STATUS_OK; // no subtitles + } LONG Start, End; @@ -414,7 +466,9 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) TextLength = 0; LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { + LineLength++; + } int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); char *Text = new char[RealLength + 1]; @@ -427,15 +481,20 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) TokenStart = line + i + 1; TokenLength = 0; TokenPos++; - } else TokenLength++; + } else { + TokenLength++; + } } else if (line[i] == '}') { if (InToken) { InToken = false; char *Token = new char[TokenLength + 1]; strncpy(Token, TokenStart, TokenLength); Token[TokenLength] = '\0'; - if (TokenPos == 0) Start = atoi(Token); - else if (TokenPos == 1) End = atoi(Token); + if (TokenPos == 0) { + Start = atoi(Token); + } else if (TokenPos == 1) { + End = atoi(Token); + } delete[] Token; } else { @@ -447,14 +506,18 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) TokenLength++; } else { Text[TextLength] = line[i]; - if (Text[TextLength] == '|') Text[TextLength] = '\n'; + if (Text[TextLength] == '|') { + Text[TextLength] = '\n'; + } TextLength++; } } } Text[TextLength] = '\0'; - if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); + if (Start != -1 && TextLength > 0) { + _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); + } delete[] Text; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 91703e40b7..07e2fc022d 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -138,7 +138,9 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: _filename = filename; _file = _gameRef->_fileManager->openFile(filename, true, false); - if (!_file) return STATUS_FAILED; + if (!_file) { + return STATUS_FAILED; + } //if (Filename != _filename) BaseUtils::setString(&_filename, filename); #if defined (USE_THEORADEC) @@ -148,8 +150,9 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif _theoraDecoder->loadStream(_file); - if (!_theoraDecoder->isVideoLoaded()) + if (!_theoraDecoder->isVideoLoaded()) { return STATUS_FAILED; + } _state = THEORA_STATE_PAUSED; @@ -165,9 +168,13 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: cleanup(); _file = _gameRef->_fileManager->openFile(filename); - if (!_file) return STATUS_FAILED; + if (!_file) { + return STATUS_FAILED; + } - if (Filename != _filename) BaseUtils::setString(&_filename, filename); + if (filename != _filename) { + BaseUtils::setString(&_filename, filename); + } // start up Ogg stream synchronization layer ogg_sync_init(&m_OggSyncState); @@ -187,8 +194,10 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: ogg_packet TempOggPacket; bool IsDone = false; while (!IsDone) { - int BytesRead = BufferData(&m_OggSyncState); - if (BytesRead == 0) break; + int bytesRead = BufferData(&m_OggSyncState); + if (bytesRead == 0) { + break; + } while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { ogg_stream_state OggStateTest; @@ -313,10 +322,11 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: // create texture if (m_TheoraStreams && !m_Texture) { - if (_gameRef->m_UseD3D) + if (_gameRef->m_UseD3D) { m_Texture = new BaseSurfaceD3D(_gameRef); - else + } else { m_Texture = new BaseSurfaceDD(_gameRef); + } if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { SAFE_DELETE(m_Texture); @@ -337,7 +347,9 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: bool VideoTheoraPlayer::resetStream() { warning("VidTheoraPlayer::resetStream - stubbed"); #if 0 - if (_sound) _sound->Stop(); + if (_sound) { + _sound->Stop(); + } m_TimeOffset = 0.0f; Initialize(m_Filename); @@ -348,16 +360,20 @@ bool VideoTheoraPlayer::resetStream() { ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) { - if (forceZoom < 0.0f) + if (forceZoom < 0.0f) { forceZoom = 100.0f; - if (volume < 0) + } + if (volume < 0) { _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); - else _volume = volume; + } else { + _volume = volume; + } _freezeGame = freezeGame; - if (!_playbackStarted && _freezeGame) + if (!_playbackStarted && _freezeGame) { _gameRef->freeze(freezeMusic); + } _playbackStarted = false; float width, height; @@ -469,11 +485,17 @@ bool VideoTheoraPlayer::stop() { bool VideoTheoraPlayer::update() { _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; - if (!isPlaying()) return STATUS_OK; + if (!isPlaying()) { + return STATUS_OK; + } - if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; + if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) { + return STATUS_OK; + } - if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) return STATUS_OK; + if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) { + return STATUS_OK; + } if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { @@ -483,7 +505,9 @@ bool VideoTheoraPlayer::update() { warning("Finished movie"); _state = THEORA_STATE_FINISHED; _playbackStarted = false; - if (_freezeGame) _gameRef->unfreeze(); + if (_freezeGame) { + _gameRef->unfreeze(); + } } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { @@ -500,7 +524,9 @@ bool VideoTheoraPlayer::update() { // end playback if (!_looping) { _state = THEORA_STATE_FINISHED; - if (_freezeGame) _gameRef->unfreeze(); + if (_freezeGame) { + _gameRef->unfreeze(); + } return STATUS_OK; } else { resetStream(); @@ -615,7 +641,9 @@ uint32 VideoTheoraPlayer::getMovieFrame() { ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::WriteVideo() { - if (!_texture) return STATUS_FAILED; + if (!_texture) { + return STATUS_FAILED; + } _texture->startPixelOp(); @@ -657,11 +685,18 @@ bool VideoTheoraPlayer::display(uint32 alpha) { if (_texture && _videoFrameReady) { BasePlatform::setRect(&rc, 0, 0, _texture->getWidth(), _texture->getHeight()); - if (_playZoom == 100.0f) res = _texture->displayTrans(_posX, _posY, rc, alpha); - else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); - } else res = STATUS_FAILED; + if (_playZoom == 100.0f) { + res = _texture->displayTrans(_posX, _posY, rc, alpha); + } else { + res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); + } + } else { + res = STATUS_FAILED; + } #if 0 - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->display(); + if (m_Subtitler && _gameRef->m_VideoSubtitles) { + m_Subtitler->display(); + } #endif return res; } @@ -699,8 +734,11 @@ bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// byte VideoTheoraPlayer::getAlphaAt(int x, int y) { - if (_alphaImage) return _alphaImage->getAlphaAt(x, y); - else return 0xFF; + if (_alphaImage) { + return _alphaImage->getAlphaAt(x, y); + } else { + return 0xFF; + } } @@ -834,9 +872,13 @@ bool VideoTheoraPlayer::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::initializeSimple() { if (DID_SUCCEED(initialize(_filename))) { - if (_alphaFilename != "") setAlphaImage(_alphaFilename); + if (_alphaFilename != "") { + setAlphaImage(_alphaFilename); + } play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); - } else _state = THEORA_STATE_FINISHED; + } else { + _state = THEORA_STATE_FINISHED; + } return STATUS_OK; } -- cgit v1.2.3 From f5cbee18f86de7c5c423fc855c8466e6ce01c714 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 17:45:32 +0200 Subject: WINTERMUTE: Remove unused code in BaseFontTTF --- .../wintermute/base/font/base_font_truetype.cpp | 46 +--------------------- engines/wintermute/base/font/base_font_truetype.h | 30 -------------- 2 files changed, 2 insertions(+), 74 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 420df58b74..e14d79cb42 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -61,13 +61,7 @@ BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _cachedTexts[i] = NULL; } -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; + _lineHeight = 0; _maxCharWidth = _maxCharHeight = 0; } @@ -85,15 +79,6 @@ BaseFontTT::~BaseFontTT(void) { delete _deletableFont; _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif } @@ -258,7 +243,7 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { //TextLineList lines; - // TODO + // TODO: Use WideString-conversion here. //WrapText(text, width, maxHeight, lines); Common::Array lines; _font->wordWrapText(text, width, lines); @@ -402,33 +387,6 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, return NULL; } -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("BaseFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) { - continue; - } - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) { - continue; - } - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} ////////////////////////////////////////////////////////////////////////// int BaseFontTT::getLetterHeight() { diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index f8c5eee74d..434fa7100c 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -94,27 +94,6 @@ public: uint32 _color; }; - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - public: DECLARE_PERSISTENT(BaseFontTT, BaseFont) BaseFontTT(BaseGame *inGame); @@ -138,12 +117,9 @@ public: private: bool parseLayer(BaseTTFontLayer *layer, byte *buffer); - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; @@ -153,13 +129,7 @@ private: const Graphics::Font *_font; const Graphics::Font *_fallbackFont; - float _ascender; - float _descender; float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; size_t _maxCharWidth; size_t _maxCharHeight; -- cgit v1.2.3 From e9a847fb352dd0e59fe45fd27c41a93d40f2bd1f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 18:20:58 +0200 Subject: WINTERMUTE: Remove #if 0 - commented out code. --- engines/wintermute/base/base_game.cpp | 18 +- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/gfx/base_image.cpp | 8 +- .../base/gfx/osystem/base_render_osystem.cpp | 49 +--- .../base/gfx/osystem/base_surface_osystem.cpp | 134 +---------- .../base/gfx/osystem/base_surface_osystem.h | 2 - .../wintermute/base/sound/base_sound_buffer.cpp | 93 +------- .../wintermute/base/sound/base_sound_manager.cpp | 17 -- engines/wintermute/base/sound/base_sound_manager.h | 1 - engines/wintermute/video/video_theora_player.cpp | 264 +-------------------- engines/wintermute/video/video_theora_player.h | 1 - 11 files changed, 16 insertions(+), 573 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 9de183660e..41ea01dffd 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -616,7 +616,6 @@ bool BaseGame::initLoop() { getDebugMgr()->onGameTick(); _renderer->initLoop(); - _soundMgr->initLoop(); updateMusicCrossfade(); _surfaceStorage->initLoop(); @@ -4023,17 +4022,12 @@ void BaseGame::setWindowTitle() { if (_textEncoding == TEXT_UTF8) { utf8Title = Utf8String(title); } else { - warning("BaseGame::SetWindowTitle -Ignoring textencoding"); + warning("BaseGame::SetWindowTitle - Ignoring textencoding"); utf8Title = Utf8String(title); /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } -#if 0 - BaseRenderOSystem *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif + warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); } } @@ -4722,18 +4716,14 @@ void BaseGame::getMousePos(Point32 *pos) { } ////////////////////////////////////////////////////////////////////////// -bool BaseGame::miniUpdate() { +void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. if (!_miniUpdateEnabled) { - return STATUS_OK; + return; } if (g_system->getMillis() - _lastMiniUpdate > 200) { - if (_soundMgr) { - _soundMgr->initLoop(); - } _lastMiniUpdate = g_system->getMillis(); } - return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8da62af40a..08d1869452 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -89,7 +89,7 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - virtual bool miniUpdate(); + virtual void miniUpdate(); void getMousePos(Point32 *Pos); Rect32 _mouseLockRect; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 571deed793..628bffff55 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -114,6 +114,7 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { + warning("BaseImage::resize(%d, %d), stubbed", newWidth, newHeight); #if 0 if (!_bitmap) { return STATUS_FAILED; @@ -128,13 +129,6 @@ bool BaseImage::resize(int newWidth, int newHeight) { FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); - if (newImg) { - FreeImage_Unload(_bitmap); - _bitmap = newImg; - return STATUS_OK; - } else { - return STATUS_FAILED; - } #endif return false; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index e465194e58..6913b3434c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -114,25 +114,10 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; -#if 0 - if (_renderer) { - SDL_DestroyRenderer(_renderer); - } - if (_win) { - SDL_DestroyWindow(_win); - } - SDL_Quit(); -#endif } ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; - -#if 0 - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); -#endif _width = width; _height = height; _renderRect.setWidth(_width); @@ -192,15 +177,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; -#if 0 - Uint32 flags = SDL_WINDOW_SHOWN; -#endif -#ifdef __IPHONEOS__ - //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; -#endif - - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); -// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); @@ -211,33 +188,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); return STATUS_FAILED; } -#if 0 - _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); - - if (!_win) { - return STATUS_FAILED; - } -#endif g_system->showMouse(false); -#ifdef __IPHONEOS__ - // SDL defaults to OGL ES2, which doesn't work on old devices - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); -#else - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif -#if 0 - _renderer = SDL_CreateRenderer(_win, -1, 0); - - if (!_renderer) { - return STATUS_FAILED; - } -#endif _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 4b680e2793..b77abf6a79 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -131,11 +131,7 @@ bool BaseSurfaceOSystem::finishLoad() { bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); - /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ + // FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO } // no alpha, set color key @@ -161,31 +157,6 @@ bool BaseSurfaceOSystem::finishLoad() { } _hasAlpha = hasTransparency(_surface); - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Surface-textures not fully ported yet"); - hasWarned = true; - } - //delete imgDecoder; -#if 0 - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!_texture) { - SDL_FreeSurface(surf); - delete imgDecoder; - return STATUS_FAILED; - } - - GenAlphaMask(surf); - - SDL_FreeSurface(surf); - delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. -#endif - _valid = true; _gameRef->addMem(_width * _height * 4); @@ -207,9 +178,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { if (!surface) { return; } -#if 0 - SDL_LockSurface(surface); -#endif + bool hasColorKey; /* uint32 colorKey; */ uint8 ckRed, ckGreen, ckBlue; @@ -239,9 +208,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } } } -#if 0 - SDL_UnlockSurface(surface); -#endif + if (!hasTransparency) { delete[] _alphaMask; _alphaMask = NULL; @@ -286,11 +253,6 @@ uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::create(int width, int height) { - warning("BaseSurfaceOSystem::Create not ported yet"); //TODO -#if 0 - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); -#endif _width = width; _height = height; @@ -301,69 +263,17 @@ bool BaseSurfaceOSystem::create(int width, int height) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { - warning("BaseSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO -#if 0 - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); -#endif - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - _width = surface->w; - _height = surface->h; -#if 0 - _gameRef->AddMem(_width * _height * 4); -#endif - _valid = true; - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::IsTransparentAt not ported yet"); - hasWarned = true; - } -#if 0 - int access; - int width, height; - //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) { - return true; - } - - - StartPixelOp(); - bool ret = isTransparentAtLite(X, Y); - EndPixelOp(); - - return ret; -#endif - return 0; + return isTransparentAtLite(x, y); } ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { - //if (!_lockPixels) return false; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::IsTransparentAtLite not ported yet"); - hasWarned = true; + if (x < 0 || x >= _surface->w || y < 0 || y >= _surface->h) { + return true; } + if (_surface->format.bytesPerPixel == 4) { uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); uint8 r, g, b, a; @@ -374,35 +284,8 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { return false; } } -#if 0 - uint32 format; - int access; - int width, height; - - //SDL_QueryTexture(_texture, &format, &access, &width, &height); - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) { - return true; - } - if (!_alphaMask) { - return false; - } else { - return _alphaMask[Y * width + X] <= 128; - } -#endif return false; - /* - Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); - Uint32 pixel = dst[X]; - - SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); - SDL_FreeFormat(pixelFormat); - - return a <= 128; - */ } ////////////////////////////////////////////////////////////////////////// @@ -533,9 +416,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo } renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); -#if 0 - SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); -#endif return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 3a8d64703f..9ed80cec50 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -44,8 +44,6 @@ public: bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); - bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - bool isTransparentAt(int x, int y); bool isTransparentAtLite(int x, int y); diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index f2db0a18fb..d94f8c61b6 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -129,63 +129,6 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { BaseUtils::setString(&_filename, filename); return STATUS_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = BaseSoundBuffer::FileCloseProc; - fileProc.read = BaseSoundBuffer::FileReadProc; - fileProc.seek = BaseSoundBuffer::FileSeekProc; - fileProc.length = BaseSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return STATUS_FAILED; - } - - BaseUtils::setString(&_filename, filename); - - /* - bool res; - bool NewlyCreated = false; - - if (!_soundBuffer || ForceReload || _streamed){ - if (!_file) _file = _gameRef->_fileManager->openFile(filename); - if (!_file){ - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - // switch to streamed for big files - if (!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if (!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if (DID_FAIL(res)){ - _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); - return res; - } - } - - - - // store filename - if (!_filename){ - _filename = new char[strlen(filename)+1]; - strcpy(_filename, filename); - } - - // close file (if not streaming) - if (!_streamed && _file){ - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - */ - - return STATUS_OK; -#endif } @@ -215,15 +158,8 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO _looping = looping; -#if 0 - - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif } ////////////////////////////////////////////////////////////////////////// @@ -314,42 +250,15 @@ uint32 BaseSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPosition(uint32 pos) { warning("BaseSoundBuffer::SetPosition - not implemented yet"); -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, BaseSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif return STATUS_OK; } -#if 0 -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - BaseSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPan(float pan) { if (_handle) { diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 74aae59e3d..d2e640e3f3 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -65,9 +65,6 @@ bool BaseSoundMgr::cleanup() { delete _sounds[i]; } _sounds.clear(); -#if 0 - BASS_Free(); -#endif return STATUS_OK; } @@ -91,20 +88,6 @@ bool BaseSoundMgr::initialize() { return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::initLoop() { - if (!_soundAvailable) { - return STATUS_OK; - } -#if 0 - - BASS_Update(500); -#endif - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) { diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 53caffbe61..464330c733 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -55,7 +55,6 @@ public: bool removeSound(BaseSoundBuffer *sound); BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initLoop(); bool initialize(); bool _soundAvailable; BaseSoundMgr(BaseGame *inGame); diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 07e2fc022d..59c83c3a52 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/video/video_theora_player.h" -#include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" @@ -38,7 +37,6 @@ #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/video/decoders/theora_decoder.h" #include "common/system.h" -//#pragma comment(lib, "libtheora.lib") namespace WinterMute { @@ -87,10 +85,6 @@ void VideoTheoraPlayer::SetDefaults() { _volume = 100; _theoraDecoder = NULL; #if 0 - _vorbisStreams = _theoraStreams = 0; - - GenLookupTables(); - _subtitler = NULL; #endif } @@ -120,16 +114,6 @@ void VideoTheoraPlayer::cleanup() { _alphaImage = NULL; delete _texture; _texture = NULL; -#if 0 - if (m_Sound) { - _gameRef->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - } - - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufFill = 0; - m_AudioBufSize = 0; -#endif } ////////////////////////////////////////////////////////////////////////// @@ -164,182 +148,6 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: _playZoom = 100; return STATUS_OK; -#if 0 - cleanup(); - - _file = _gameRef->_fileManager->openFile(filename); - if (!_file) { - return STATUS_FAILED; - } - - if (filename != _filename) { - BaseUtils::setString(&_filename, filename); - } - - // start up Ogg stream synchronization layer - ogg_sync_init(&m_OggSyncState); - - // init supporting Vorbis structures needed in header parsing - vorbis_comment_init(&m_VorbisComment); - vorbis_info_init(&m_VorbisInfo); - - // init supporting Theora structures needed in header parsing - theora_comment_init(&m_TheoraComment); - theora_info_init(&m_TheoraInfo); - - - - // Ogg file open; parse the headers - // Only interested in Vorbis/Theora streams - ogg_packet TempOggPacket; - bool IsDone = false; - while (!IsDone) { - int bytesRead = BufferData(&m_OggSyncState); - if (bytesRead == 0) { - break; - } - - while (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - ogg_stream_state OggStateTest; - - // is this a mandated initial header? If not, stop parsing - if (!ogg_page_bos(&m_OggPage)) { - // don't leak the page; get it into the appropriate stream - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - - IsDone = true; - break; - } - - ogg_stream_init(&OggStateTest, ogg_page_serialno(&m_OggPage)); - ogg_stream_pagein(&OggStateTest, &m_OggPage); - ogg_stream_packetout(&OggStateTest, &TempOggPacket); - - // identify the codec: try theora - if (!m_TheoraStreams && theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket) >= 0) { - // it is theora - memcpy(&m_TheoraStreamState, &OggStateTest, sizeof(OggStateTest)); - m_TheoraStreams = 1; - } else if (!m_VorbisStreams && vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket) >= 0) { - // it is vorbis - memcpy(&m_VorbisStreamState, &OggStateTest, sizeof(OggStateTest)); - m_VorbisStreams = 1; - } else { - // whatever it is, we don't care about it - ogg_stream_clear(&OggStateTest); - } - } - } - - // we're expecting more header packets - while ((m_TheoraStreams && m_TheoraStreams < 3) || (m_VorbisStreams && m_VorbisStreams < 3)) { - int Ret; - - // look for further theora headers - while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { - if (Ret < 0) { - _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return STATUS_FAILED; - } - if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { - _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); - return STATUS_FAILED; - } - m_TheoraStreams++; - if (m_TheoraStreams == 3) break; - } - - /* look for more vorbis header packets */ - while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { - if (Ret < 0) { - _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return STATUS_FAILED; - } - if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { - _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); - return STATUS_FAILED; - } - m_VorbisStreams++; - if (m_VorbisStreams == 3) break; - } - - // The header pages/packets will arrive before anything else we - // care about, or the stream is not obeying spec - if (ogg_sync_pageout(&m_OggSyncState, &m_OggPage) > 0) { - if (m_TheoraStreams) - ogg_stream_pagein(&m_TheoraStreamState, &m_OggPage); - if (m_VorbisStreams) - ogg_stream_pagein(&m_VorbisStreamState, &m_OggPage); - } else { - int Ret = BufferData(&m_OggSyncState); // someone needs more data - if (Ret == 0) { - _gameRef->LOG(0, "End of file while searching for codec headers"); - return STATUS_FAILED; - } - } - } - - - - // and now we have it all. initialize decoders - if (m_TheoraStreams) { - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - } else { - // tear down the partial theora setup - theora_info_clear(&m_TheoraInfo); - theora_comment_clear(&m_TheoraComment); - } - - if (m_VorbisStreams) { - vorbis_synthesis_init(&m_VorbisDSPState, &m_VorbisInfo); - vorbis_block_init(&m_VorbisDSPState, &m_VorbisBlock); - - } else { - // tear down the partial vorbis setup - vorbis_info_clear(&m_VorbisInfo); - vorbis_comment_clear(&m_VorbisComment); - } - - bool Res = STATUS_OK; - - // create sound buffer - if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { - m_Sound = new BaseSoundTheora(_gameRef); - _gameRef->m_SoundMgr->AddSound(m_Sound); - if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { - _gameRef->m_SoundMgr->RemoveSound(m_Sound); - m_Sound = NULL; - _gameRef->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); - } else { - SAFE_DELETE_ARRAY(m_AudioBuf); - m_AudioBufSize = m_Sound->m_StreamBlockSize; - m_AudioBuf = new ogg_int16_t[m_AudioBufSize]; - } - } - - // create texture - if (m_TheoraStreams && !m_Texture) { - if (_gameRef->m_UseD3D) { - m_Texture = new BaseSurfaceD3D(_gameRef); - } else { - m_Texture = new BaseSurfaceDD(_gameRef); - } - - if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { - SAFE_DELETE(m_Texture); - } - } - - - if (!m_Subtitler) m_Subtitler = new CVidSubtitler(_gameRef); - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); - - return Res; -#endif - return STATUS_FAILED; } @@ -420,45 +228,6 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, } return STATUS_OK; #if 0 - - m_State = THEORA_STATE_PLAYING; - - m_Looping = Looping; - m_PlaybackType = Type; - - float Width, Height; - if (m_TheoraStreams) { - Width = (float)m_TheoraInfo.width; - Height = (float)m_TheoraInfo.height; - } else { - Width = (float)_gameRef->m_Renderer->m_Width; - Height = (float)_gameRef->m_Renderer->m_Height; - } - - switch (Type) { - case VID_PLAY_POS: - m_PlayZoom = ForceZoom; - m_PosX = X; - m_PosY = Y; - break; - - case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->m_Renderer->m_Width / Width * 100); - float ZoomY = (float)((float)_gameRef->m_Renderer->m_Height / Height * 100); - m_PlayZoom = min(ZoomX, ZoomY); - m_PosX = (_gameRef->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; - m_PosY = (_gameRef->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - m_PlayZoom = 100.0f; - m_PosX = (_gameRef->m_Renderer->m_Width - Width) / 2; - m_PosY = (_gameRef->m_Renderer->m_Height - Height) / 2; - break; - } - - if (StartTime) SeekToTime(StartTime); Update(); @@ -473,11 +242,7 @@ bool VideoTheoraPlayer::stop() { if (_freezeGame) { _gameRef->unfreeze(); } -#if 0 - if (m_Sound) m_Sound->Stop(); - m_State = THEORA_STATE_FINISHED; - if (m_FreezeGame) _gameRef->Unfreeze(); -#endif + return STATUS_OK; } @@ -623,22 +388,6 @@ uint32 VideoTheoraPlayer::getMovieTime() { } } - -////////////////////////////////////////////////////////////////////////// -uint32 VideoTheoraPlayer::getMovieFrame() { -#if 0 - if (!m_TheoraStreams) return 0; - float Time = GetMovieTime(); - - return Time / ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); -#endif - if (_theoraDecoder) { - return _theoraDecoder->getTime(); - } else { - return 0; - } -} - ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::WriteVideo() { if (!_texture) { @@ -718,17 +467,6 @@ bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { _alphaFilename = filename; } //TODO: Conversion. -#if 0 - SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new BaseImage(_gameRef); - if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { - SAFE_DELETE(m_AlphaImage); - SAFE_DELETE_ARRAY(m_AlphaFilename); - return STATUS_FAILED; - } - if (m_AlphaFilename != Filename) BaseUtils::setString(&m_AlphaFilename, filename); - m_AlphaImage->Convert(IMG_TRUECOLOR); -#endif return STATUS_OK; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 3d17aed31e..58fe700d75 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -84,7 +84,6 @@ public: }; uint32 getMovieTime(); - uint32 getMovieFrame(); BaseSurface *getTexture(); -- cgit v1.2.3 From 5e325a5b285e03f9099fa6b81c2f6a85fabe4b06 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 18:47:31 +0200 Subject: WINTERMUTE: Privatize most fields in AdActor --- engines/wintermute/ad/ad_actor.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 870b3e8418..5da014bcda 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -53,9 +53,17 @@ public: BasePoint *_targetPoint; virtual bool update(); virtual bool display(); + virtual void turnTo(TDirection dir); + AdActor(BaseGame *inGame/*=NULL*/); + virtual ~AdActor(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + + +private: TDirection _targetDir; TDirection _afterWalkDir; - virtual void turnTo(TDirection dir); + AdPath *_path; AdSpriteSet *_walkSprite; AdSpriteSet *_standSprite; @@ -64,11 +72,6 @@ public: BaseArray _talkSprites; BaseArray _talkSpritesEx; TDirection _dir; - AdActor(BaseGame *inGame/*=NULL*/); - virtual ~AdActor(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - // new anim system Common::String _talkAnimName; Common::String _idleAnimName; @@ -85,7 +88,6 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); -private: bool setDefaultAnimNames(); BaseSprite *getTalkStanceOld(const char *stance); bool mergeAnims(const char *animsFilename); -- cgit v1.2.3 From 91edc76b3e98a3b94ca67c17bdc740f272572759 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:24:04 +0200 Subject: WINTERMUTE: Avoid crashing when a file doesn't exist in a DCP. --- engines/wintermute/base/base_file_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index ff693e055c..94f561997e 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -259,6 +259,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } } Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + if (!entry) { + return NULL; + } file = entry->createReadStream(); return file; } -- cgit v1.2.3 From eb22e36d5e12b64442ce23c656227483dd9cf61e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:31:08 +0200 Subject: WINTERMUTE: Disable SaveGame thumbs for now --- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index e067241589..b29935d943 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -52,6 +52,8 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::open(const Common::String &filename) { close(); + warning("SaveGame-thumbs disabled for now"); + return STATUS_FAILED; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { return STATUS_FAILED; -- cgit v1.2.3 From 4eda234611bd77f053defe9e61d592b308270eaa Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:41:18 +0200 Subject: WINTERMUTE: Replace BaseArray with a templated subclass of Common::Array. This needs additional cleanup, but compiles and runs at this point. --- engines/wintermute/ad/ad_actor.cpp | 10 +- engines/wintermute/ad/ad_actor.h | 6 +- engines/wintermute/ad/ad_game.cpp | 46 +-- engines/wintermute/ad/ad_game.h | 18 +- engines/wintermute/ad/ad_inventory.cpp | 10 +- engines/wintermute/ad/ad_inventory.h | 2 +- engines/wintermute/ad/ad_layer.cpp | 6 +- engines/wintermute/ad/ad_layer.h | 2 +- engines/wintermute/ad/ad_object.cpp | 12 +- engines/wintermute/ad/ad_object.h | 4 +- engines/wintermute/ad/ad_path.cpp | 2 +- engines/wintermute/ad/ad_path.h | 2 +- engines/wintermute/ad/ad_region.cpp | 2 +- engines/wintermute/ad/ad_response_box.cpp | 14 +- engines/wintermute/ad/ad_response_box.h | 6 +- engines/wintermute/ad/ad_scene.cpp | 36 +- engines/wintermute/ad/ad_scene.h | 16 +- engines/wintermute/ad/ad_scene_state.cpp | 2 +- engines/wintermute/ad/ad_scene_state.h | 2 +- engines/wintermute/ad/ad_talk_def.cpp | 2 +- engines/wintermute/ad/ad_talk_def.h | 2 +- engines/wintermute/ad/ad_talk_holder.cpp | 12 +- engines/wintermute/ad/ad_talk_holder.h | 4 +- engines/wintermute/ad/ad_waypoint_group.cpp | 2 +- engines/wintermute/ad/ad_waypoint_group.h | 2 +- engines/wintermute/base/base_frame.cpp | 12 +- engines/wintermute/base/base_frame.h | 4 +- engines/wintermute/base/base_game.cpp | 20 +- engines/wintermute/base/base_game.h | 8 +- engines/wintermute/base/base_region.cpp | 8 +- engines/wintermute/base/base_region.h | 2 +- engines/wintermute/base/base_script_holder.cpp | 4 +- engines/wintermute/base/base_script_holder.h | 2 +- engines/wintermute/base/base_sprite.cpp | 6 +- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 4 +- engines/wintermute/base/font/base_font_storage.h | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 12 +- engines/wintermute/base/particles/part_emitter.h | 6 +- engines/wintermute/base/scriptables/script.h | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 16 +- .../wintermute/base/scriptables/script_engine.h | 8 +- .../wintermute/base/scriptables/script_stack.cpp | 8 +- engines/wintermute/base/scriptables/script_stack.h | 2 +- engines/wintermute/coll_templ.h | 373 +++------------------ engines/wintermute/ui/ui_object.cpp | 10 +- engines/wintermute/ui/ui_window.cpp | 6 +- engines/wintermute/ui/ui_window.h | 4 +- engines/wintermute/video/video_player.cpp | 2 +- 51 files changed, 234 insertions(+), 515 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index d1e03eac3a..fb46cef9cf 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -101,18 +101,18 @@ AdActor::~AdActor() { for (int i = 0; i < _talkSprites.getSize(); i++) { delete _talkSprites[i]; } - _talkSprites.removeAll(); + _talkSprites.clear(); for (int i = 0; i < _talkSpritesEx.getSize(); i++) { delete _talkSpritesEx[i]; } - _talkSpritesEx.removeAll(); + _talkSpritesEx.clear(); for (int i = 0; i < _anims.getSize(); i++) { delete _anims[i]; _anims[i] = NULL; } - _anims.removeAll(); + _anims.clear(); } @@ -1051,7 +1051,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, delete _anims[i]; _anims[i] = NULL; - _anims.removeAt(i); + _anims.remove_at(i); i--; Found = true; } @@ -1254,7 +1254,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { // not - get a random talk if (!ret) { - BaseArray talkAnims; + BaseArray talkAnims; for (int i = 0; i < _anims.getSize(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { talkAnims.add(_anims[i]); diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 5da014bcda..0c6334ac9d 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -69,8 +69,8 @@ private: AdSpriteSet *_standSprite; AdSpriteSet *_turnLeftSprite; AdSpriteSet *_turnRightSprite; - BaseArray _talkSprites; - BaseArray _talkSpritesEx; + BaseArray _talkSprites; + BaseArray _talkSpritesEx; TDirection _dir; // new anim system Common::String _talkAnimName; @@ -78,7 +78,7 @@ private: Common::String _walkAnimName; Common::String _turnLeftAnimName; Common::String _turnRightAnimName; - BaseArray _anims; + BaseArray _anims; virtual bool playAnim(const char *filename); AdSpriteSet *getAnimByName(const Common::String &animName); diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index a6452e8837..4533496199 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -124,18 +124,18 @@ bool AdGame::cleanup() { unregisterObject(_objects[i]); _objects[i] = NULL; } - _objects.removeAll(); + _objects.clear(); for (i = 0; i < _dlgPendingBranches.getSize(); i++) { delete[] _dlgPendingBranches[i]; } - _dlgPendingBranches.removeAll(); + _dlgPendingBranches.clear(); for (i = 0; i < _speechDirs.getSize(); i++) { delete[] _speechDirs[i]; } - _speechDirs.removeAll(); + _speechDirs.clear(); unregisterObject(_scene); @@ -145,7 +145,7 @@ bool AdGame::cleanup() { for (i = 0; i < _items.getSize(); i++) { _gameRef->unregisterObject(_items[i]); } - _items.removeAll(); + _items.clear(); // clear remaining inventories @@ -155,7 +155,7 @@ bool AdGame::cleanup() { for (i = 0; i < _inventories.getSize(); i++) { delete _inventories[i]; } - _inventories.removeAll(); + _inventories.clear(); if (_responseBox) { @@ -186,17 +186,17 @@ bool AdGame::cleanup() { for (i = 0; i < _sceneStates.getSize(); i++) { delete _sceneStates[i]; } - _sceneStates.removeAll(); + _sceneStates.clear(); for (i = 0; i < _responsesBranch.getSize(); i++) { delete _responsesBranch[i]; } - _responsesBranch.removeAll(); + _responsesBranch.clear(); for (i = 0; i < _responsesGame.getSize(); i++) { delete _responsesGame[i]; } - _responsesGame.removeAll(); + _responsesGame.clear(); return BaseGame::cleanup(); } @@ -223,7 +223,7 @@ bool AdGame::initLoop() { res = _scene->initLoop(); } - _sentences.removeAll(); + _sentences.clear(); return res; } @@ -248,7 +248,7 @@ bool AdGame::removeObject(AdObject *object) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { - _objects.removeAt(i); + _objects.remove_at(i); break; } } @@ -1744,7 +1744,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const delete[] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; } - _dlgPendingBranches.removeAt(startIndex, _dlgPendingBranches.getSize() - startIndex); + _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.getSize() - startIndex); } // dialogue is over, forget selected responses @@ -1752,7 +1752,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const for (int i = 0; i < _responsesBranch.getSize(); i++) { delete _responsesBranch[i]; } - _responsesBranch.removeAll(); + _responsesBranch.clear(); } if (deleteName) { @@ -1768,7 +1768,7 @@ bool AdGame::clearBranchResponses(char *name) { for (int i = 0; i < _responsesBranch.getSize(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; - _responsesBranch.removeAt(i); + _responsesBranch.remove_at(i); i--; } } @@ -1839,7 +1839,7 @@ bool AdGame::resetResponse(int id) { if (_responsesGame[i]->_id == id) { if ((context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(context, _responsesGame[i]->_context) == 0) { delete _responsesGame[i]; - _responsesGame.removeAt(i); + _responsesGame.remove_at(i); break; } } @@ -1849,7 +1849,7 @@ bool AdGame::resetResponse(int id) { if (_responsesBranch[i]->_id == id) { if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; - _responsesBranch.removeAt(i); + _responsesBranch.remove_at(i); break; } } @@ -1962,7 +1962,7 @@ bool AdGame::unregisterInventory(AdInventory *inv) { for (int i = 0; i < _inventories.getSize(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); - _inventories.removeAt(i); + _inventories.remove_at(i); return STATUS_OK; } } @@ -2007,31 +2007,31 @@ bool AdGame::resetContent() { for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { delete[] _dlgPendingBranches[i]; } - _dlgPendingBranches.removeAll(); + _dlgPendingBranches.clear(); // clear inventories for (int i = 0; i < _inventories.getSize(); i++) { - _inventories[i]->_takenItems.removeAll(); + _inventories[i]->_takenItems.clear(); } // clear scene states for (int i = 0; i < _sceneStates.getSize(); i++) { delete _sceneStates[i]; } - _sceneStates.removeAll(); + _sceneStates.clear(); // clear once responses for (int i = 0; i < _responsesBranch.getSize(); i++) { delete _responsesBranch[i]; } - _responsesBranch.removeAll(); + _responsesBranch.clear(); // clear once game responses for (int i = 0; i < _responsesGame.getSize(); i++) { delete _responsesGame[i]; } - _responsesGame.removeAll(); + _responsesGame.clear(); // reload inventory items if (_itemsFile) { @@ -2064,7 +2064,7 @@ bool AdGame::deleteItem(AdItem *item) { for (int i = 0; i < _items.getSize(); i++) { if (_items[i] == item) { unregisterObject(_items[i]); - _items.removeAt(i); + _items.remove_at(i); break; } } @@ -2113,7 +2113,7 @@ bool AdGame::removeSpeechDir(const char *dir) { for (int i = 0; i < _speechDirs.getSize(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete[] _speechDirs[i]; - _speechDirs.removeAt(i); + _speechDirs.remove_at(i); found = true; break; } diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 49c48de0bb..e0179d3e94 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -121,7 +121,7 @@ public: AdGame(); virtual ~AdGame(); - BaseArray _objects; + BaseArray _objects; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); @@ -138,7 +138,7 @@ private: virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); AdObject *_invObject; - BaseArray _inventories; + BaseArray _inventories; char *_scheduledScene; bool _scheduledFadeIn; char *_prevSceneName; @@ -147,16 +147,16 @@ private: char *_startupScene; bool _initialScene; bool _smartItemCursor; - BaseArray _speechDirs; - BaseArray _items; + BaseArray _speechDirs; + BaseArray _items; - BaseArray _sentences; + BaseArray _sentences; - BaseArray _sceneStates; - BaseArray _dlgPendingBranches; + BaseArray _sceneStates; + BaseArray _dlgPendingBranches; - BaseArray _responsesBranch; - BaseArray _responsesGame; + BaseArray _responsesBranch; + BaseArray _responsesGame; AdResponseBox *_responseBox; AdInventoryBox *_inventoryBox; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index aa6e0b6f0b..6cc5ed879e 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -44,7 +44,7 @@ AdInventory::AdInventory(BaseGame *inGame): BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdInventory::~AdInventory() { - _takenItems.removeAll(); // ref only + _takenItems.clear(); // ref only } @@ -62,7 +62,7 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { int insertIndex = -1; for (int i = 0; i < _takenItems.getSize(); i++) { if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { - _takenItems.removeAt(i); + _takenItems.remove_at(i); i--; continue; } @@ -75,7 +75,7 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { if (insertIndex == -1) { _takenItems.add(item); } else { - _takenItems.insertAt(insertIndex, item); + _takenItems.insert_at(insertIndex, item); } return STATUS_OK; @@ -93,7 +93,7 @@ bool AdInventory::removeItem(const char *name) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { ((AdGame *)_gameRef)->_selectedItem = NULL; } - _takenItems.removeAt(i); + _takenItems.remove_at(i); return STATUS_OK; } } @@ -114,7 +114,7 @@ bool AdInventory::removeItem(AdItem *item) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { ((AdGame *)_gameRef)->_selectedItem = NULL; } - _takenItems.removeAt(i); + _takenItems.remove_at(i); return STATUS_OK; } } diff --git a/engines/wintermute/ad/ad_inventory.h b/engines/wintermute/ad/ad_inventory.h index 6f7537633d..9eff30454c 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -43,7 +43,7 @@ public: bool insertItem(const char *name, const char *insertAfter = NULL); AdInventory(BaseGame *inGame); virtual ~AdInventory(); - BaseArray _takenItems; + BaseArray _takenItems; int _scrollOffset; }; diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 6c9e6381b2..a60cd76209 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -56,7 +56,7 @@ AdLayer::~AdLayer() { for (int i = 0; i < _nodes.getSize(); i++) { delete _nodes[i]; } - _nodes.removeAll(); + _nodes.clear(); } @@ -324,7 +324,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, index = 0; } if (index <= _nodes.getSize() - 1) { - _nodes.insertAt(index, node); + _nodes.insert_at(index, node); } else { _nodes.add(node); } @@ -363,7 +363,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (_nodes[i] == toDelete) { delete _nodes[i]; _nodes[i] = NULL; - _nodes.removeAt(i); + _nodes.remove_at(i); break; } } diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index b76cbf1d99..6d1686e1a6 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -41,7 +41,7 @@ public: bool _main; AdLayer(BaseGame *inGame); virtual ~AdLayer(); - BaseArray _nodes; + BaseArray _nodes; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index c6f0306cbb..cf60bedf2c 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -146,12 +146,12 @@ AdObject::~AdObject() { for (int i = 0; i < _attachmentsPre.getSize(); i++) { _gameRef->unregisterObject(_attachmentsPre[i]); } - _attachmentsPre.removeAll(); + _attachmentsPre.clear(); for (int i = 0; i < _attachmentsPost.getSize(); i++) { _gameRef->unregisterObject(_attachmentsPost[i]); } - _attachmentsPost.removeAll(); + _attachmentsPost.clear(); } @@ -567,7 +567,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_attachmentsPre[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); + _attachmentsPre.remove_at(i); i--; } } @@ -575,7 +575,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_attachmentsPost[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); + _attachmentsPost.remove_at(i); i--; } } @@ -585,7 +585,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); - _attachmentsPre.removeAt(i); + _attachmentsPre.remove_at(i); i--; } } @@ -593,7 +593,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); - _attachmentsPost.removeAt(i); + _attachmentsPost.remove_at(i); i--; } } diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index 58cb15fde3..8e4cb80742 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -105,8 +105,8 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); - BaseArray _attachmentsPre; - BaseArray _attachmentsPost; + BaseArray _attachmentsPre; + BaseArray _attachmentsPost; bool updateSpriteAttachments(); bool displaySpriteAttachments(bool preDisplay); diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 89be10f0fb..7734b4d9ba 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -52,7 +52,7 @@ void AdPath::reset() { delete _points[i]; } - _points.removeAll(); + _points.clear(); _currIndex = -1; _ready = false; } diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h index 958f52af03..8622e6757c 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -46,7 +46,7 @@ public: void reset(); AdPath(BaseGame *inGame); virtual ~AdPath(); - BaseArray _points; + BaseArray _points; int _currIndex; bool _ready; }; diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 6b104d51ad..18b5731830 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -131,7 +131,7 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); int ar = 255, ag = 255, ab = 255, alpha = 255; diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index fe37002abb..c566120405 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -100,7 +100,7 @@ void AdResponseBox::clearResponses() { for (int i = 0; i < _responses.getSize(); i++) { delete _responses[i]; } - _responses.removeAll(); + _responses.clear(); } @@ -109,7 +109,7 @@ void AdResponseBox::clearButtons() { for (int i = 0; i < _respButtons.getSize(); i++) { delete _respButtons[i]; } - _respButtons.removeAll(); + _respButtons.clear(); } @@ -597,7 +597,7 @@ bool AdResponseBox::weedResponses() { case RESPONSE_ONCE: if (adGame->branchResponseUsed(_responses[i]->_iD)) { delete _responses[i]; - _responses.removeAt(i); + _responses.remove_at(i); i--; } break; @@ -605,7 +605,7 @@ bool AdResponseBox::weedResponses() { case RESPONSE_ONCE_GAME: if (adGame->gameResponseUsed(_responses[i]->_iD)) { delete _responses[i]; - _responses.removeAt(i); + _responses.remove_at(i); i--; } break; @@ -649,7 +649,7 @@ bool AdResponseBox::handleResponse(AdResponse *response) { ////////////////////////////////////////////////////////////////////////// BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { - BaseArray objects; + BaseArray objects; getObjects(objects, true); if (objects.getSize() == 0) { @@ -673,7 +673,7 @@ BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { ////////////////////////////////////////////////////////////////////////// BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { - BaseArray objects; + BaseArray objects; getObjects(objects, true); if (objects.getSize() == 0) { @@ -696,7 +696,7 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { } ////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { +bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _respButtons.getSize(); i++) { objects.add(_respButtons[i]); } diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index 5dc22cbebe..c1f60ba6ae 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -42,7 +42,7 @@ class AdResponseBox : public BaseObject { public: BaseObject *getNextAccessObject(BaseObject *CurrObject); BaseObject *getPrevAccessObject(BaseObject *CurrObject); - bool getObjects(BaseArray &objects, bool interactiveOnly); + bool getObjects(BaseArray &objects, bool interactiveOnly); bool handleResponse(AdResponse *response); void setLastResponseText(const char *text, const char *textOrig); @@ -69,8 +69,8 @@ public: void clearResponses(); AdResponseBox(BaseGame *inGame); virtual ~AdResponseBox(); - BaseArray _responses; - BaseArray _respButtons; + BaseArray _responses; + BaseArray _respButtons; UIWindow *_window; UIWindow *_shieldWindow; bool _horizontal; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 21f28b6247..d863d21140 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -151,35 +151,35 @@ void AdScene::cleanup() { for (i = 0; i < _layers.getSize(); i++) { _gameRef->unregisterObject(_layers[i]); } - _layers.removeAll(); + _layers.clear(); for (i = 0; i < _waypointGroups.getSize(); i++) { _gameRef->unregisterObject(_waypointGroups[i]); } - _waypointGroups.removeAll(); + _waypointGroups.clear(); for (i = 0; i < _scaleLevels.getSize(); i++) { _gameRef->unregisterObject(_scaleLevels[i]); } - _scaleLevels.removeAll(); + _scaleLevels.clear(); for (i = 0; i < _rotLevels.getSize(); i++) { _gameRef->unregisterObject(_rotLevels[i]); } - _rotLevels.removeAll(); + _rotLevels.clear(); for (i = 0; i < _pfPath.getSize(); i++) { delete _pfPath[i]; } - _pfPath.removeAll(); + _pfPath.clear(); _pfPointsNum = 0; for (i = 0; i < _objects.getSize(); i++) { _gameRef->unregisterObject(_objects[i]); } - _objects.removeAll(); + _objects.clear(); delete _viewport; _viewport = NULL; @@ -494,7 +494,7 @@ void AdScene::pathFinderStep() { // target point marked, generate path and terminate if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { while (lowestPt != NULL) { - _pfTargetPath->_points.insertAt(0, new BasePoint(lowestPt->x, lowestPt->y)); + _pfTargetPath->_points.insert_at(0, new BasePoint(lowestPt->x, lowestPt->y)); lowestPt = lowestPt->_origin; } @@ -1142,7 +1142,7 @@ bool AdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { AdGame *adGame = (AdGame *)_gameRef; - BaseArray objects; + BaseArray objects; AdObject *obj; // global objects @@ -1751,7 +1751,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, index = 0; } if (index <= _layers.getSize() - 1) { - _layers.insertAt(index, layer); + _layers.insert_at(index, layer); } else { _layers.add(layer); } @@ -1797,7 +1797,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, for (int i = 0; i < _layers.getSize(); i++) { if (_layers[i] == toDelete) { - _layers.removeAt(i); + _layers.remove_at(i); _gameRef->unregisterObject(toDelete); break; } @@ -2101,7 +2101,7 @@ bool AdScene::addObject(AdObject *object) { bool AdScene::removeObject(AdObject *object) { for (int i = 0; i < _objects.getSize(); i++) { if (_objects[i] == object) { - _objects.removeAt(i); + _objects.remove_at(i); return _gameRef->unregisterObject(object); } } @@ -2849,7 +2849,7 @@ bool AdScene::restoreDeviceObjects() { ////////////////////////////////////////////////////////////////////////// BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { - BaseArray objects; + BaseArray objects; getSceneObjects(objects, true); if (objects.getSize() == 0) { @@ -2873,7 +2873,7 @@ BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { ////////////////////////////////////////////////////////////////////////// BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { - BaseArray objects; + BaseArray objects; getSceneObjects(objects, true); if (objects.getSize() == 0) { @@ -2897,11 +2897,11 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { ////////////////////////////////////////////////////////////////////////// -bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { +bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _layers.getSize(); i++) { // close-up layer -> remove everything below it if (interactiveOnly && _layers[i]->_closeUp) { - objects.removeAll(); + objects.clear(); } @@ -2917,7 +2917,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i break; case OBJECT_REGION: { - BaseArray regionObj; + BaseArray regionObj; getRegionObjects(node->_region, regionObj, interactiveOnly); for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; @@ -2942,7 +2942,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i } // objects outside any region - BaseArray regionObj; + BaseArray regionObj; getRegionObjects(NULL, regionObj, interactiveOnly); for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { bool found = false; @@ -2963,7 +2963,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool i ////////////////////////////////////////////////////////////////////////// -bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly) { +bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly) { AdGame *adGame = (AdGame *)_gameRef; AdObject *obj; diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index b1420cc5c2..a4bf666aea 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -49,8 +49,8 @@ public: BaseObject *getNextAccessObject(BaseObject *CurrObject); BaseObject *getPrevAccessObject(BaseObject *CurrObject); - bool getSceneObjects(BaseArray &Objects, bool InteractiveOnly); - bool getRegionObjects(AdRegion *Region, BaseArray &Objects, bool InteractiveOnly); + bool getSceneObjects(BaseArray &Objects, bool InteractiveOnly); + bool getRegionObjects(AdRegion *Region, BaseArray &Objects, bool InteractiveOnly); bool afterLoad(); @@ -120,9 +120,9 @@ public: bool getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = NULL); AdScene(BaseGame *inGame); virtual ~AdScene(); - BaseArray _layers; - BaseArray _objects; - BaseArray _waypointGroups; + BaseArray _layers; + BaseArray _objects; + BaseArray _waypointGroups; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); int _width; @@ -149,8 +149,8 @@ public: bool _editorShowDecor; bool _editorShowEntities; bool _editorShowScale; - BaseArray _scaleLevels; - BaseArray _rotLevels; + BaseArray _scaleLevels; + BaseArray _rotLevels; virtual bool restoreDeviceObjects(); int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); @@ -169,7 +169,7 @@ private: BasePoint *_pfTarget; AdPath *_pfTargetPath; BaseObject *_pfRequester; - BaseArray _pfPath; + BaseArray _pfPath; int _offsetTop; int _offsetLeft; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 8a223150f2..673fb965e9 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -50,7 +50,7 @@ AdSceneState::~AdSceneState() { for (int i = 0; i < _nodeStates.getSize(); i++) { delete _nodeStates[i]; } - _nodeStates.removeAll(); + _nodeStates.clear(); } diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h index 469f985639..8f1bdb8fd2 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -43,7 +43,7 @@ public: AdSceneState(BaseGame *inGame); virtual ~AdSceneState(); char *_filename; - BaseArray _nodeStates; + BaseArray _nodeStates; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index fc057ba183..5b88887e0c 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -55,7 +55,7 @@ AdTalkDef::~AdTalkDef() { for (int i = 0; i < _nodes.getSize(); i++) { delete _nodes[i]; } - _nodes.removeAll(); + _nodes.clear(); delete[] _defaultSpriteFilename; delete _defaultSprite; diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index fa32a81041..4d28881e97 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -47,7 +47,7 @@ public: virtual ~AdTalkDef(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - BaseArray _nodes; + BaseArray _nodes; char *_defaultSpriteFilename; BaseSprite *_defaultSprite; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 90435d7977..6aca8e01a8 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -55,12 +55,12 @@ AdTalkHolder::~AdTalkHolder() { for (int i = 0; i < _talkSprites.getSize(); i++) { delete _talkSprites[i]; } - _talkSprites.removeAll(); + _talkSprites.clear(); for (int i = 0; i < _talkSpritesEx.getSize(); i++) { delete _talkSpritesEx[i]; } - _talkSpritesEx.removeAll(); + _talkSpritesEx.clear(); } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +237,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS setTemp2 = true; } delete _talkSpritesEx[i]; - _talkSpritesEx.removeAt(i); + _talkSpritesEx.remove_at(i); break; } } @@ -251,7 +251,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS setTemp2 = true; } delete _talkSprites[i]; - _talkSprites.removeAt(i); + _talkSprites.remove_at(i); break; } } @@ -297,7 +297,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } delete _talkSpritesEx[i]; } - _talkSpritesEx.removeAll(); + _talkSpritesEx.clear(); } else { for (int i = 0; i < _talkSprites.getSize(); i++) { if (_talkSprites[i] == _currentSprite) { @@ -308,7 +308,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } delete _talkSprites[i]; } - _talkSprites.removeAll(); + _talkSprites.clear(); } // set new diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h index 8ad8ae1e52..2607fdd9da 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -39,8 +39,8 @@ public: virtual BaseSprite *getTalkStance(const char *stance); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); BaseSprite *_sprite; - BaseArray _talkSprites; - BaseArray _talkSpritesEx; + BaseArray _talkSprites; + BaseArray _talkSpritesEx; AdTalkHolder(BaseGame *inGame); virtual ~AdTalkHolder(); diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index bb1e9275f5..fac3bbe630 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -59,7 +59,7 @@ void AdWaypointGroup::cleanup() { for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); _editorSelectedPoint = -1; } diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index f23f7be859..7d69ab8237 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -47,7 +47,7 @@ public: bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); virtual ~AdWaypointGroup(); - BaseArray _points; + BaseArray _points; int _editorSelectedPoint; virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 68b866bbf5..208d6037d9 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -64,13 +64,13 @@ BaseFrame::~BaseFrame() { for (int i = 0; i < _subframes.getSize(); i++) { delete _subframes[i]; } - _subframes.removeAll(); + _subframes.clear(); for (int i = 0; i < _applyEvent.getSize(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } - _applyEvent.removeAll(); + _applyEvent.clear(); } @@ -334,7 +334,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { sub->_editorSelected = editorSelected; - _subframes.insertAt(0, sub); + _subframes.insert_at(0, sub); return STATUS_OK; } @@ -495,7 +495,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac for (int i = 0; i < _subframes.getSize(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; - _subframes.removeAt(i); + _subframes.remove_at(i); break; } } @@ -550,7 +550,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index >= _subframes.getSize()) { _subframes.add(sub); } else { - _subframes.insertAt(index, sub); + _subframes.insert_at(index, sub); } stack->pushNative(sub, true); @@ -598,7 +598,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { delete[] _applyEvent[i]; - _applyEvent.removeAt(i); + _applyEvent.remove_at(i); break; } } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index dcbf74bc47..c8e9cbb400 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -51,14 +51,14 @@ public: int _moveY; int _moveX; uint32 _delay; - BaseArray _subframes; + BaseArray _subframes; bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); virtual ~BaseFrame(); - BaseArray _applyEvent; + BaseArray _applyEvent; // scripting interface virtual ScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 41ea01dffd..00f5731787 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -356,9 +356,9 @@ bool BaseGame::cleanup() { delete _regObjects[i]; _regObjects[i] = NULL; } - _regObjects.removeAll(); + _regObjects.clear(); - _windows.removeAll(); // refs only + _windows.clear(); // refs only _focusedWindow = NULL; // ref only delete[] _saveImageName; @@ -382,7 +382,7 @@ bool BaseGame::cleanup() { _scripts[i]->_owner = NULL; _scripts[i]->finish(); } - _scripts.removeAll(); + _scripts.clear(); _fontStorage->removeFont(_systemFont); _systemFont = NULL; @@ -393,9 +393,9 @@ bool BaseGame::cleanup() { for (int i = 0; i < _quickMessages.getSize(); i++) { delete _quickMessages[i]; } - _quickMessages.removeAll(); + _quickMessages.clear(); - _viewportStack.removeAll(); + _viewportStack.clear(); _viewportSP = -1; setName(NULL); @@ -2906,7 +2906,7 @@ bool BaseGame::displayQuickMsg() { for (int i = 0; i < _quickMessages.getSize(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; - _quickMessages.removeAt(i); + _quickMessages.remove_at(i); i--; } } @@ -2927,7 +2927,7 @@ bool BaseGame::displayQuickMsg() { void BaseGame::quickMessage(const char *text) { if (_quickMessages.getSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; - _quickMessages.removeAt(0); + _quickMessages.remove_at(0); } _quickMessages.add(new BaseQuickMsg(_gameRef, text)); } @@ -2962,7 +2962,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { // is it a window? for (int i = 0; i < _windows.getSize(); i++) { if ((BaseObject *)_windows[i] == object) { - _windows.removeAt(i); + _windows.remove_at(i); // get new focused window if (_focusedWindow == object) { @@ -2986,7 +2986,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { // destroy object for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { - _regObjects.removeAt(i); + _regObjects.remove_at(i); if (!_loadInProgress) { SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); } @@ -3864,7 +3864,7 @@ bool BaseGame::focusWindow(UIWindow *window) { for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == window) { if (i < _windows.getSize() - 1) { - _windows.removeAt(i); + _windows.remove_at(i); _windows.add(window); _gameRef->_focusedWindow = window; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 08d1869452..ecb698b70a 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -358,10 +358,10 @@ private: bool stopVideo(); BaseDebugger *_debugMgr; - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; - BaseArray _regObjects; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; AnsiString getDeviceType() const; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 67cda44ece..13815a5958 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -63,7 +63,7 @@ void BaseRegion::cleanup() { for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); BasePlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; @@ -165,7 +165,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { for (i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -249,7 +249,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new BasePoint(x, y)); + _points.insert_at(Index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -293,7 +293,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta delete _points[index]; _points[index] = NULL; - _points.removeAt(index); + _points.remove_at(index); createRegion(); stack->pushBool(true); diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index a15e0cca2a..3b4b28030d 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -53,7 +53,7 @@ public: bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; - BaseArray _points; + BaseArray _points; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index b90b4dc60a..131acf326f 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -64,7 +64,7 @@ bool BaseScriptHolder::cleanup() { _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } - _scripts.removeAll(); + _scripts.clear(); return STATUS_OK; } @@ -336,7 +336,7 @@ bool BaseScriptHolder::addScript(const char *filename) { bool BaseScriptHolder::removeScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { - _scripts.removeAt(i); + _scripts.remove_at(i); break; } } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index ef1c389dcb..4162936ded 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -57,7 +57,7 @@ public: bool _freezable; bool _ready; - BaseArray _scripts; + BaseArray _scripts; // scripting interface virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 2fda638665..274c792263 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -92,7 +92,7 @@ void BaseSprite::cleanup() { for (int i = 0; i < _frames.getSize(); i++) { delete _frames[i]; } - _frames.removeAll(); + _frames.clear(); delete[] _editorBgFile; _editorBgFile = NULL; @@ -578,7 +578,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta _lastFrameTime = 0; } delete _frames[i]; - _frames.removeAt(i); + _frames.remove_at(i); break; } } @@ -653,7 +653,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (index >= _frames.getSize()) { _frames.add(frame); } else { - _frames.insertAt(index, frame); + _frames.insert_at(index, frame); } stack->pushNative(frame, true); diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 6ddec287d6..477ab70878 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -75,7 +75,7 @@ public: bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); virtual ~BaseSprite(); - BaseArray _frames; + BaseArray _frames; bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 8b4fa74181..95f1ae601c 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -57,7 +57,7 @@ bool BaseFontStorage::cleanup(bool warn) { } delete _fonts[i]; } - _fonts.removeAll(); + _fonts.clear(); return STATUS_OK; } @@ -117,7 +117,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { delete _fonts[i]; - _fonts.removeAt(i); + _fonts.remove_at(i); } break; } diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 2c9c6817c3..3af9244ffe 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -46,7 +46,7 @@ public: BaseFont *addFont(const char *filename); BaseFontStorage(BaseGame *inGame); virtual ~BaseFontStorage(); - BaseArray _fonts; + BaseArray _fonts; bool initLoop(); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index e14d79cb42..ac6430d4c9 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -72,7 +72,7 @@ BaseFontTT::~BaseFontTT(void) { for (int i = 0; i < _layers.getSize(); i++) { delete _layers[i]; } - _layers.removeAll(); + _layers.clear(); delete[] _fontFile; _fontFile = NULL; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 434fa7100c..20ef531a46 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -142,7 +142,7 @@ public: int _fontHeight; char *_fontFile; - BaseArray _layers; + BaseArray _layers; void clearCache(); }; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index b16fb83abf..8b86365196 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -97,18 +97,18 @@ PartEmitter::~PartEmitter(void) { for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.removeAll(); + _particles.clear(); for (int i = 0; i < _forces.getSize(); i++) { delete _forces[i]; } - _forces.removeAll(); + _forces.clear(); for (int i = 0; i < _sprites.getSize(); i++) { delete[] _sprites[i]; } - _sprites.removeAll(); + _sprites.clear(); delete[] _emitEvent; _emitEvent = NULL; @@ -148,7 +148,7 @@ bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete[] _sprites[i]; - _sprites.removeAt(i); + _sprites.remove_at(i); return STATUS_OK; } } @@ -446,7 +446,7 @@ bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->getName()) == 0) { delete _forces[i]; - _forces.removeAt(i); + _forces.remove_at(i); return STATUS_OK; } } @@ -527,7 +527,7 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.removeAll(); + _particles.clear(); _running = false; stack->pushBool(true); diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index fc557a9512..4e3b837a11 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -60,7 +60,7 @@ public: bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); bool removeForce(const char *name); - BaseArray _forces; + BaseArray _forces; // scripting interface virtual ScValue *scGetProperty(const char *name); @@ -131,8 +131,8 @@ private: bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; - BaseArray _particles; - BaseArray _sprites; + BaseArray _particles; + BaseArray _sprites; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index ba73e1015f..c343ad24ad 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -46,7 +46,7 @@ public: bool dbgSendScript(IWmeDebugClient *client); bool dbgSendVariables(IWmeDebugClient *client); - BaseArray _breakpoints; + BaseArray _breakpoints; bool _tracingMode; ScScript *_parentScript; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 356617094d..e1aed7ed82 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -97,7 +97,7 @@ ScEngine::~ScEngine() { delete _breakpoints[i]; _breakpoints[i] = NULL; } - _breakpoints.removeAll(); + _breakpoints.clear(); } @@ -108,11 +108,11 @@ bool ScEngine::cleanup() { _scripts[i]->_owner->removeScript(_scripts[i]); } delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } - _scripts.removeAll(); + _scripts.clear(); delete _globals; _globals = NULL; @@ -404,7 +404,7 @@ bool ScEngine::removeFinishedScripts() { } _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } } @@ -511,7 +511,7 @@ void ScEngine::editorCleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } } @@ -620,10 +620,10 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.removeAt(j); + _breakpoints[i]->_lines.remove_at(j); if (_breakpoints[i]->_lines.getSize() == 0) { delete _breakpoints[i]; - _breakpoints.removeAt(i); + _breakpoints.remove_at(i); } // refresh changes refreshScriptBreakpoints(); @@ -666,7 +666,7 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) { } } if (script->_breakpoints.getSize() > 0) { - script->_breakpoints.removeAll(); + script->_breakpoints.clear(); } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index fc441347df..fcfaa51971 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -74,11 +74,11 @@ public: } ~CScBreakpoint() { - _lines.removeAll(); + _lines.clear(); } Common::String _filename; - BaseArray _lines; + BaseArray _lines; }; @@ -87,7 +87,7 @@ public: public: bool dbgSendScripts(IWmeDebugClient *client); - BaseArray _breakpoints; + BaseArray _breakpoints; bool addBreakpoint(const char *scriptFilename, int line); bool removeBreakpoint(const char *scriptFilename, int line); bool refreshScriptBreakpoints(); @@ -122,7 +122,7 @@ public: static void closeFile(void *data, byte *buffer); static void parseElement(void *data, int line, int type, void *elementData); - BaseArray _scripts; + BaseArray _scripts; void enableProfiling(); void disableProfiling(); diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 0d4ea54b8c..8840a2c0f1 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -50,7 +50,7 @@ ScStack::~ScStack() { for (int i = 0; i < _values.getSize(); i++) { delete _values[i]; } - _values.removeAll(); + _values.clear(); } @@ -123,7 +123,7 @@ void ScStack::correctParams(uint32 expectedParams) { while (expectedParams < nuParams) { //Pop(); delete _values[_sP - expectedParams]; - _values.removeAt(_sP - expectedParams); + _values.remove_at(_sP - expectedParams); nuParams--; _sP--; } @@ -132,13 +132,13 @@ void ScStack::correctParams(uint32 expectedParams) { //Push(null_val); ScValue *nullVal = new ScValue(_gameRef); nullVal->setNULL(); - _values.insertAt(_sP - nuParams + 1, nullVal); + _values.insert_at(_sP - nuParams + 1, nullVal); nuParams++; _sP++; if (_values.getSize() > _sP + 1) { delete _values[_values.getSize() - 1]; - _values.removeAt(_values.getSize() - 1); + _values.remove_at(_values.getSize() - 1); } } } diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 3aacad0765..95839cc680 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -56,7 +56,7 @@ public: ScValue *pop(); ScStack(BaseGame *inGame); virtual ~ScStack(); - BaseArray _values; + BaseArray _values; int _sP; }; diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index d7e1ae1748..51a4120c15 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -29,345 +29,64 @@ #ifndef WINTERMUTE_COLL_TEMPL_H #define WINTERMUTE_COLL_TEMPL_H - -#include +#include "common/array.h" #include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { -// Quite the same as Common::Array, but with persistence-support. - -///////////////////////////////////////////////////////////////////////////// -template -inline void DCConstructElements(TYPE *pElements, int nCount) { - // first do bit-wise zero initialization - memset((void *)pElements, 0, nCount * sizeof(TYPE)); - - // then call the constructor(s) - for (; nCount--; pElements++) - ::new((void *)pElements) TYPE; -} - -///////////////////////////////////////////////////////////////////////////// -template -inline void DCDestructElements(TYPE *pElements, int nCount) { - // call the destructor(s) - for (; nCount--; pElements++) - pElements->~TYPE(); -} - -///////////////////////////////////////////////////////////////////////////// -template -inline void DCCopyElements(TYPE *pDest, const TYPE *pSrc, int nCount) { - // default is element-copy using assignment - while (nCount--) - *pDest++ = *pSrc++; -} - -///////////////////////////////////////////////////////////////////////////// -template -bool DCCompareElements(const TYPE *pElement1, const ARG_TYPE *pElement2) { - return *pElement1 == *pElement2; -} - -//class BasePersistenceManager; - -///////////////////////////////////////////////////////////////////////////// -// BaseArray -///////////////////////////////////////////////////////////////////////////// -template -class BaseArray { -public: -// Construction - BaseArray(); - -// Attributes - int getSize() const; - int getUpperBound() const; - void setSize(int nNewSize, int nGrowBy = -1); - -// Operations - // Clean up - void freeExtra(); - void removeAll(); - bool persist(BasePersistenceManager *persistMgr); - - // Accessing elements - TYPE getAt(int nIndex) const; - void setAt(int nIndex, ARG_TYPE newElement); - TYPE &elementAt(int nIndex); - - // Direct Access to the element data (may return NULL) - const TYPE *getData() const; - TYPE *getData(); - - // Potentially growing the array - void setAtGrow(int nIndex, ARG_TYPE newElement); - int add(ARG_TYPE newElement); - int append(const BaseArray &src); - void copy(const BaseArray &src); - - // overloaded operator helpers - TYPE operator[](int nIndex) const; - TYPE &operator[](int nIndex); - - // Operations that move elements around - void insertAt(int nIndex, ARG_TYPE newElement, int nCount = 1); - void removeAt(int nIndex, int nCount = 1); - void insertAt(int nStartIndex, BaseArray *pNewArray); - -// Implementation -protected: - TYPE *_pData; // the actual array of data - int _nSize; // # of elements (upperBound - 1) - int _nMaxSize; // max allocated - int _nGrowBy; // grow amount - +// Basically Common::Array with peristence-support. +template +class BaseArray : public Common::Array { public: - ~BaseArray(); -}; - -///////////////////////////////////////////////////////////////////////////// -// BaseArray inline functions -///////////////////////////////////////////////////////////////////////////// -template -inline int BaseArray::getSize() const { - return _nSize; -} -template -inline int BaseArray::getUpperBound() const { - return _nSize - 1; -} -template -inline void BaseArray::removeAll() { - setSize(0, -1); -} -template -inline TYPE BaseArray::getAt(int nIndex) const { - return _pData[nIndex]; -} -template -inline void BaseArray::setAt(int nIndex, ARG_TYPE newElement) { - _pData[nIndex] = newElement; -} -template -inline TYPE &BaseArray::elementAt(int nIndex) { - return _pData[nIndex]; -} -template -inline const TYPE *BaseArray::getData() const { - return (const TYPE *)_pData; -} -template -inline TYPE *BaseArray::getData() { - return (TYPE *)_pData; -} -template -inline int BaseArray::add(ARG_TYPE newElement) { - int nIndex = _nSize; - setAtGrow(nIndex, newElement); - return nIndex; -} -template -inline TYPE BaseArray::operator[](int nIndex) const { - return getAt(nIndex); -} -template -inline TYPE &BaseArray::operator[](int nIndex) { - return elementAt(nIndex); -} - -///////////////////////////////////////////////////////////////////////////// -// BaseArray out-of-line functions -///////////////////////////////////////////////////////////////////////////// -template -BaseArray::BaseArray() { - _pData = NULL; - _nSize = _nMaxSize = _nGrowBy = 0; -} - -///////////////////////////////////////////////////////////////////////////// -template -BaseArray::~BaseArray() { - if (_pData != NULL) { - DCDestructElements(_pData, _nSize); - delete[](byte *)_pData; - } -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::setSize(int nNewSize, int nGrowBy) { - if (nGrowBy != -1) - _nGrowBy = nGrowBy; // set new size - - if (nNewSize == 0) { - // shrink to nothing - if (_pData != NULL) { - DCDestructElements(_pData, _nSize); - delete[](byte *)_pData; - _pData = NULL; - } - _nSize = _nMaxSize = 0; - } else if (_pData == NULL) { - // create one with exact size - _pData = (TYPE *) new byte[nNewSize * sizeof(TYPE)]; - DCConstructElements(_pData, nNewSize); - _nSize = _nMaxSize = nNewSize; - } else if (nNewSize <= _nMaxSize) { - // it fits - if (nNewSize > _nSize) { - // initialize the new elements - DCConstructElements(&_pData[_nSize], nNewSize - _nSize); - } else if (_nSize > nNewSize) { - // destroy the old elements - DCDestructElements(&_pData[nNewSize], _nSize - nNewSize); - } - _nSize = nNewSize; - } else { - // otherwise, grow array - nGrowBy = _nGrowBy; - if (nGrowBy == 0) { - // heuristically determine growth when nGrowBy == 0 - // (this avoids heap fragmentation in many situations) - nGrowBy = _nSize / 8; - nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy); +// TODO: Might want to make sure that destructors are called when replacing/deleting/getting destructed + bool persist(BasePersistenceManager *persistMgr) { + int j; + if (persistMgr->getIsSaving()) { + j = Common::Array::size(); + persistMgr->transfer("ArraySize", &j); + typename Common::Array::const_iterator it = Common::Array::begin(); + for (; it != Common::Array::end(); it++) { + TYPE obj = *it; + persistMgr->transfer("", &obj); + } + } else { + Common::Array::clear(); + persistMgr->transfer("ArraySize", &j); + for (int i = 0; i < j; i++) { + TYPE obj; + persistMgr->transfer("", &obj); + add(obj); + } } - int nNewMax; - if (nNewSize < _nMaxSize + nGrowBy) - nNewMax = _nMaxSize + nGrowBy; // granularity - else - nNewMax = nNewSize; // no slush - - TYPE *pNewData = (TYPE *) new byte[nNewMax * sizeof(TYPE)]; - - // copy new data from old - memcpy(pNewData, _pData, _nSize * sizeof(TYPE)); - - // construct remaining elements - DCConstructElements(&pNewData[_nSize], nNewSize - _nSize); - - // get rid of old stuff (note: no destructors called) - delete[](byte *)_pData; - _pData = pNewData; - _nSize = nNewSize; - _nMaxSize = nNewMax; + return true; } -} - -///////////////////////////////////////////////////////////////////////////// -template -int BaseArray::append(const BaseArray &src) { - int nOldSize = _nSize; - setSize(_nSize + src._nSize); - DCCopyElements(_pData + nOldSize, src._pData, src._nSize); - return nOldSize; -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::copy(const BaseArray &src) { - setSize(src._nSize); - DCCopyElements(_pData, src._pData, src._nSize); -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::freeExtra() { - if (_nSize != _nMaxSize) { - // shrink to desired size - TYPE *pNewData = NULL; - if (_nSize != 0) { - pNewData = (TYPE *) new byte[_nSize * sizeof(TYPE)]; - // copy new data from old - memcpy(pNewData, _pData, _nSize * sizeof(TYPE)); - } - - // get rid of old stuff (note: no destructors called) - delete[](byte *)_pData; - _pData = pNewData; - _nMaxSize = _nSize; + // TODO: Just here for convenience while verifying that this works. + int getSize() const { + return Common::Array::size(); } -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::setAtGrow(int nIndex, ARG_TYPE newElement) { - if (nIndex >= _nSize) - setSize(nIndex + 1, -1); - _pData[nIndex] = newElement; -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::insertAt(int nIndex, ARG_TYPE newElement, int nCount /*=1*/) { - if (nIndex >= _nSize) { - // adding after the end of the array - setSize(nIndex + nCount, -1); // grow so nIndex is valid - } else { - // inserting in the middle of the array - int nOldSize = _nSize; - setSize(_nSize + nCount, -1); // grow it to new size - // destroy intial data before copying over it - DCDestructElements(&_pData[nOldSize], nCount); - // shift old data up to fill gap - memmove(&_pData[nIndex + nCount], &_pData[nIndex], - (nOldSize - nIndex) * sizeof(TYPE)); - - // re-init slots we copied from - DCConstructElements(&_pData[nIndex], nCount); + int add(TYPE newElement) { + Common::Array::push_back(newElement); + return getSize() - 1; } - - // insert new value in the gap - while (nCount--) - _pData[nIndex++] = newElement; -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::removeAt(int nIndex, int nCount) { - // just remove a range - int nMoveCount = _nSize - (nIndex + nCount); - DCDestructElements(&_pData[nIndex], nCount); - if (nMoveCount) - memcpy(&_pData[nIndex], &_pData[nIndex + nCount], - nMoveCount * sizeof(TYPE)); - _nSize -= nCount; -} - -///////////////////////////////////////////////////////////////////////////// -template -void BaseArray::insertAt(int nStartIndex, BaseArray *pNewArray) { - if (pNewArray->GetSize() > 0) { - InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize()); - for (int i = 0; i < pNewArray->GetSize(); i++) - setAt(nStartIndex + i, pNewArray->GetAt(i)); + void remove_at(uint32 idx) { + Common::Array::remove_at(idx); } -} - - -///////////////////////////////////////////////////////////////////////////// -template -bool BaseArray::persist(BasePersistenceManager *persistMgr) { - int i, j; - if (persistMgr->getIsSaving()) { - j = getSize(); - persistMgr->transfer("ArraySize", &j); - for (i = 0; i < j; i++) { - ARG_TYPE obj = getAt(i); - persistMgr->transfer("", &obj); - } - } else { - setSize(0, -1); - persistMgr->transfer("ArraySize", &j); - for (i = 0; i < j; i++) { - ARG_TYPE obj; - persistMgr->transfer("", &obj); - add(obj); + void remove_at(uint32 idx, uint32 num) { + while (num) { + if (idx >= Common::Array::size()) { + break; + } + Common::Array::remove_at(idx); } } - return true; -} + template + void copy(const BaseArray &src) { + Common::Array::insert_at(0, src); + } + void *getData() { // Ugly, should perhaps add a sort-function instead. + return Common::Array::_storage; + } +}; } // end of namespace WinterMute diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index e44bb0f741..9fe9cd18e4 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -286,8 +286,8 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack j++; } - win->_widgets.insertAt(i, this); - win->_widgets.removeAt(j); + win->_widgets.insert_at(i, this); + win->_widgets.remove_at(j); done = true; stack->pushBool(true); @@ -318,8 +318,8 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack UIWindow *win = (UIWindow *)_parent; for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); - win->_widgets.insertAt(0, this); + win->_widgets.remove_at(i); + win->_widgets.insert_at(0, this); break; } } @@ -341,7 +341,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack UIWindow *win = (UIWindow *)_parent; for (int i = 0; i < win->_widgets.getSize(); i++) { if (win->_widgets[i] == this) { - win->_widgets.removeAt(i); + win->_widgets.remove_at(i); win->_widgets.add(this); break; } diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index f221405f15..b9e2ad056f 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -113,7 +113,7 @@ void UIWindow::cleanup() { for (int i = 0; i < _widgets.getSize(); i++) { delete _widgets[i]; } - _widgets.removeAll(); + _widgets.clear(); } @@ -994,7 +994,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack for (int i = 0; i < _widgets.getSize(); i++) { if (_widgets[i] == obj) { delete _widgets[i]; - _widgets.removeAt(i); + _widgets.remove_at(i); if (val->getType() == VAL_VARIABLE_REF) { val->setNULL(); } @@ -1415,7 +1415,7 @@ void UIWindow::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// -bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { +bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { for (int i = 0; i < _widgets.getSize(); i++) { UIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) { diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index c2baeb1ea1..556850f6fa 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -40,7 +40,7 @@ class BaseViewport; class UIWindow : public UIObject { uint32 _fadeColor; public: - bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); + bool getWindowObjects(BaseArray &Objects, bool InteractiveOnly); bool _pauseMusic; void cleanup(); @@ -72,7 +72,7 @@ public: UIWindow(BaseGame *inGame); virtual ~UIWindow(); virtual bool handleKeypress(Common::Event *event, bool printable = false); - BaseArray _widgets; + BaseArray _widgets; TTextAlign _titleAlign; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index 7affd91013..66ec926582 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -132,7 +132,7 @@ bool VideoPlayer::cleanup() { for (int i = 0; i < _subtitles.getSize(); i++) { delete _subtitles[i]; } - _subtitles.removeAll(); + _subtitles.clear(); return SetDefaults(); #endif -- cgit v1.2.3 From 2c530bc6edc9ffd95fa86488a663e67d2735041f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 20:49:59 +0200 Subject: WINTERMUTE: var_name -> varName --- engines/wintermute/ad/ad_game.cpp | 18 ++-- engines/wintermute/ad/ad_inventory_box.cpp | 6 +- engines/wintermute/ad/ad_response_box.cpp | 14 +-- engines/wintermute/base/font/base_font_bitmap.cpp | 6 +- engines/wintermute/base/scriptables/script.cpp | 24 ++--- engines/wintermute/base/scriptables/script.h | 12 +-- .../wintermute/graphics/transparent_surface.cpp | 100 ++++++++++----------- engines/wintermute/system/sys_class.cpp | 4 +- engines/wintermute/system/sys_class.h | 2 +- engines/wintermute/utils/utils.cpp | 14 +-- 10 files changed, 100 insertions(+), 100 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 4533496199..e7bc4483e6 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -715,13 +715,13 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); if (!val->isNULL()) { for (int i = 0; i < _inventories.getSize(); i++) { - AdInventory *Inv = _inventories[i]; + AdInventory *inv = _inventories[i]; - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (val->getNative() == Inv->_takenItems[j]) { + for (int j = 0; j < inv->_takenItems.getSize(); j++) { + if (val->getNative() == inv->_takenItems[j]) { stack->pushBool(true); return STATUS_OK; - } else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->getName()) == 0) { + } else if (scumm_stricmp(val->getString(), inv->_takenItems[j]->getName()) == 0) { stack->pushBool(true); return STATUS_OK; } @@ -1176,16 +1176,16 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { - ScValue *this_obj; + ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// // Actor ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Actor") == 0) { stack->correctParams(0); - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(new AdActor(_gameRef)); + thisObj->setNative(new AdActor(_gameRef)); stack->pushNULL(); } @@ -1194,9 +1194,9 @@ bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Entity") == 0) { stack->correctParams(0); - this_obj = thisStack->getTop(); + thisObj = thisStack->getTop(); - this_obj->setNative(new AdEntity(_gameRef)); + thisObj->setNative(new AdEntity(_gameRef)); stack->pushNULL(); } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index b8a3f1da22..80929bcb7b 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -223,7 +223,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; BaseParser parser(_gameRef); - bool always_visible = false; + bool alwaysVisible = false; _exclusive = false; if (complete) { @@ -275,7 +275,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_ALWAYS_VISIBLE: - parser.scanStr((char *)params, "%b", &always_visible); + parser.scanStr((char *)params, "%b", &alwaysVisible); break; case TOKEN_SPACING: @@ -318,7 +318,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { } } - _visible = always_visible; + _visible = alwaysVisible; if (_window) { for (int i = 0; i < _window->_widgets.getSize(); i++) { diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index c566120405..07df0a88ee 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -453,22 +453,22 @@ bool AdResponseBox::display() { // shift down if needed if (!_horizontal) { - int total_height = 0; + int totalHeight = 0; for (i = 0; i < _respButtons.getSize(); i++) { - total_height += (_respButtons[i]->_height + _spacing); + totalHeight += (_respButtons[i]->_height + _spacing); } - total_height -= _spacing; + totalHeight -= _spacing; switch (_verticalAlign) { case VAL_BOTTOM: - if (yyy + total_height < rect.bottom) { - yyy = rect.bottom - total_height; + if (yyy + totalHeight < rect.bottom) { + yyy = rect.bottom - totalHeight; } break; case VAL_CENTER: - if (yyy + total_height < rect.bottom) { - yyy += ((rect.bottom - rect.top) - total_height) / 2; + if (yyy + totalHeight < rect.bottom) { + yyy += ((rect.bottom - rect.top) - totalHeight) / 2; } break; diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9cce8ca9ee..ee876f2503 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -341,7 +341,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { buffer = (byte *)params; int widths[300]; - int num = 0, default_width = 8; + int num = 0, defaultWidth = 8; int lastWidth = 0; int i; int r = 255, g = 255, b = 255; @@ -377,7 +377,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); + parser.scanStr(params, "%d", &defaultWidth); break; case TOKEN_WIDTHS_FRAME: @@ -482,7 +482,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { } } else { for (i = lastWidth; i < NUM_CHARACTERS; i++) { - _widths[i] = default_width; + _widths[i] = defaultWidth; } } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 4deeb0bf39..54a04c454f 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -106,12 +106,12 @@ void ScScript::readHeader() { _scriptStream->seek(0); _header.magic = _scriptStream->readUint32LE(); _header.version = _scriptStream->readUint32LE(); - _header.code_start = _scriptStream->readUint32LE(); - _header.func_table = _scriptStream->readUint32LE(); - _header.symbol_table = _scriptStream->readUint32LE(); - _header.event_table = _scriptStream->readUint32LE(); - _header.externals_table = _scriptStream->readUint32LE(); - _header.method_table = _scriptStream->readUint32LE(); + _header.codeStart = _scriptStream->readUint32LE(); + _header.funcTable = _scriptStream->readUint32LE(); + _header.symbolTable = _scriptStream->readUint32LE(); + _header.eventTable = _scriptStream->readUint32LE(); + _header.externalsTable = _scriptStream->readUint32LE(); + _header.methodTable = _scriptStream->readUint32LE(); _scriptStream->seek(oldPos); } @@ -148,7 +148,7 @@ bool ScScript::initScript() { // skip to the beginning - _iP = _header.code_start; + _iP = _header.codeStart; _scriptStream->seek(_iP); _currentLine = 0; @@ -169,7 +169,7 @@ bool ScScript::initTables() { readHeader(); // load symbol table - _iP = _header.symbol_table; + _iP = _header.symbolTable; _numSymbols = getDWORD(); _symbols = new char*[_numSymbols]; @@ -179,7 +179,7 @@ bool ScScript::initTables() { } // load functions table - _iP = _header.func_table; + _iP = _header.funcTable; _numFunctions = getDWORD(); _functions = new TFunctionPos[_numFunctions]; @@ -190,7 +190,7 @@ bool ScScript::initTables() { // load events table - _iP = _header.event_table; + _iP = _header.eventTable; _numEvents = getDWORD(); _events = new TEventPos[_numEvents]; @@ -202,7 +202,7 @@ bool ScScript::initTables() { // load externals if (_header.version >= 0x0101) { - _iP = _header.externals_table; + _iP = _header.externalsTable; _numExternals = getDWORD(); _externals = new TExternalFunction[_numExternals]; @@ -222,7 +222,7 @@ bool ScScript::initTables() { } // load method table - _iP = _header.method_table; + _iP = _header.methodTable; _numMethods = getDWORD(); _methods = new TMethodPos[_numMethods]; diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index c343ad24ad..2ee1319acb 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -88,12 +88,12 @@ public: typedef struct { uint32 magic; uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; + uint32 codeStart; + uint32 funcTable; + uint32 symbolTable; + uint32 eventTable; + uint32 externalsTable; + uint32 methodTable; } TScriptHeader; TScriptHeader _header; diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 6ab9c621d0..65bdbcf5a1 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -72,12 +72,12 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in in = ino; for (uint32 j = 0; j < width; j++) { uint32 pix = *(uint32 *)in; - uint32 o_pix = *(uint32 *) out; + uint32 oPix = *(uint32 *) out; int b = (pix >> bShift) & 0xff; int g = (pix >> gShift) & 0xff; int r = (pix >> rShift) & 0xff; int a = (pix >> aShift) & 0xff; - int o_b, o_g, o_r, o_a; + int outb, outg, outr, outa; in += inStep; /* if (ca != 255) { @@ -89,31 +89,31 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in out += 4; break; case 255: // Full opacity - o_b = b; - o_g = g; - o_r = r; - o_a = a; + outb = b; + outg = g; + outr = r; + outa = a; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; + out[aIndex] = outa; + out[bIndex] = outb; + out[gIndex] = outg; + out[rIndex] = outr; out += 4; break; default: // alpha blending - o_a = 255; - o_b = (o_pix >> bShiftTarget) & 0xff; - o_g = (o_pix >> gShiftTarget) & 0xff; - o_r = (o_pix >> rShiftTarget) & 0xff; - o_b += ((b - o_b) * a) >> 8; - o_g += ((g - o_g) * a) >> 8; - o_r += ((r - o_r) * a) >> 8; + outa = 255; + outb = (oPix >> bShiftTarget) & 0xff; + outg = (oPix >> gShiftTarget) & 0xff; + outr = (oPix >> rShiftTarget) & 0xff; + outb += ((b - outb) * a) >> 8; + outg += ((g - outg) * a) >> 8; + outr += ((r - outr) * a) >> 8; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; + out[aIndex] = outa; + out[bIndex] = outb; + out[gIndex] = outg; + out[rIndex] = outr; out += 4; } } @@ -259,7 +259,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p int g = (pix >> gShift) & 0xff; int r = (pix >> rShift) & 0xff; int a = (pix >> aShift) & 0xff; - int o_b, o_g, o_r, o_a; + int outb, outg, outr, outa; in += inStep; if (ca != 255) { @@ -272,56 +272,56 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p break; case 255: // Full opacity if (cb != 255) - o_b = (b * cb) >> 8; + outb = (b * cb) >> 8; else - o_b = b; + outb = b; if (cg != 255) - o_g = (g * cg) >> 8; + outg = (g * cg) >> 8; else - o_g = g; + outg = g; if (cr != 255) - o_r = (r * cr) >> 8; + outr = (r * cr) >> 8; else - o_r = r; - o_a = a; + outr = r; + outa = a; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; + out[aIndex] = outa; + out[bIndex] = outb; + out[gIndex] = outg; + out[rIndex] = outr; out += 4; break; default: // alpha blending - o_a = 255; - o_b = (o_pix >> bShiftTarget) & 0xff; - o_g = (o_pix >> gShiftTarget) & 0xff; - o_r = (o_pix >> rShiftTarget) & 0xff; + outa = 255; + outb = (o_pix >> bShiftTarget) & 0xff; + outg = (o_pix >> gShiftTarget) & 0xff; + outr = (o_pix >> rShiftTarget) & 0xff; if (cb == 0) - o_b = 0; + outb = 0; else if (cb != 255) - o_b += ((b - o_b) * a * cb) >> 16; + outb += ((b - outb) * a * cb) >> 16; else - o_b += ((b - o_b) * a) >> 8; + outb += ((b - outb) * a) >> 8; if (cg == 0) - o_g = 0; + outg = 0; else if (cg != 255) - o_g += ((g - o_g) * a * cg) >> 16; + outg += ((g - outg) * a * cg) >> 16; else - o_g += ((g - o_g) * a) >> 8; + outg += ((g - outg) * a) >> 8; if (cr == 0) - o_r = 0; + outr = 0; else if (cr != 255) - o_r += ((r - o_r) * a * cr) >> 16; + outr += ((r - outr) * a * cr) >> 16; else - o_r += ((r - o_r) * a) >> 8; + outr += ((r - outr) * a) >> 8; //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); - out[aIndex] = o_a; - out[bIndex] = o_b; - out[gIndex] = o_g; - out[rIndex] = o_r; + out[aIndex] = outa; + out[bIndex] = outb; + out[gIndex] = outg; + out[rIndex] = outr; out += 4; } } diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp index 21578320c7..ce06e8980e 100644 --- a/engines/wintermute/system/sys_class.cpp +++ b/engines/wintermute/system/sys_class.cpp @@ -36,14 +36,14 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class) { +SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass) { _name = name; _build = build; _load = load; _next = NULL; _savedID = -1; - _persistent = persistent_class; + _persistent = persistentClass; _numInst = 0; SystemClassRegistry::getInstance()->registerClass(this); diff --git a/engines/wintermute/system/sys_class.h b/engines/wintermute/system/sys_class.h index bd534f8bb0..36968e1cc2 100644 --- a/engines/wintermute/system/sys_class.h +++ b/engines/wintermute/system/sys_class.h @@ -65,7 +65,7 @@ namespace WinterMute { class SystemClass { public: - SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistent_class); + SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass); ~SystemClass(); int getNumInstances(); diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 39bb1d7137..3336cf63e2 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -290,19 +290,19 @@ uint32 BaseUtils::HSLtoRGB(byte InH, byte InS, byte InL) { G = (byte)(L * 255); B = (byte)(L * 255); } else { - float var_1, var_2; + float var1, var2; if (L < 0.5) { - var_2 = L * (1.0 + S); + var2 = L * (1.0 + S); } else { - var_2 = (L + S) - (S * L); + var2 = (L + S) - (S * L); } - var_1 = 2.0f * L - var_2; + var1 = 2.0f * L - var2; - R = (byte)(255 * Hue2RGB(var_1, var_2, H + (1.0f / 3.0f))); - G = (byte)(255 * Hue2RGB(var_1, var_2, H)); - B = (byte)(255 * Hue2RGB(var_1, var_2, H - (1.0f / 3.0f))); + R = (byte)(255 * Hue2RGB(var1, var2, H + (1.0f / 3.0f))); + G = (byte)(255 * Hue2RGB(var1, var2, H)); + B = (byte)(255 * Hue2RGB(var1, var2, H - (1.0f / 3.0f))); } return BYTETORGBA(255, R, G, B); } -- cgit v1.2.3 From 496a3938c451683845e73fa9b2cba20dadddfe21 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 21:01:00 +0200 Subject: WINTERMUTE: Remove gotos. --- engines/wintermute/base/base_game.cpp | 78 +++++++++------------- .../wintermute/base/base_persistence_manager.cpp | 8 --- 2 files changed, 32 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 00f5731787..402b7294aa 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3359,36 +3359,29 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) { - goto save_finish; - } - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); + if (DID_SUCCEED(ret = pm->initSave(desc))) { + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } } } - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { - goto save_finish; - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { - goto save_finish; - } - if (DID_FAIL(ret = pm->saveFile(filename))) { - goto save_finish; + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = pm->saveFile(filename))) { + _registry->writeInt("System", "MostRecentSaveSlot", slot); + } + } + } } - _registry->writeInt("System", "MostRecentSaveSlot", slot); - -save_finish: // TODO: Remove gotos delete pm; _indicatorDisplay = false; @@ -3436,30 +3429,23 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initLoad(filename))) { - goto load_finish; - } - - //if (DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { - goto load_finish; - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { - goto load_finish; + if (DID_SUCCEED(ret = pm->initLoad(filename))) { + //if (DID_SUCCEED(ret = cleanup())) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + } + } } - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - - getDebugMgr()->onGameInit(); - -load_finish: - _indicatorDisplay = false; delete pm; _loadInProgress = false; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index d8f928b683..9f07da57ac 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -354,14 +354,6 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { } - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - return STATUS_OK; } -- cgit v1.2.3 From 3a49f2bad407787ef65d04c5f9ae423485629b41 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 22:20:55 +0200 Subject: WINTERMUTE: More variable/function renaming VarName->varName --- engines/wintermute/ad/ad_actor.cpp | 36 ++++++------ engines/wintermute/ad/ad_entity.cpp | 16 +++--- engines/wintermute/ad/ad_game.cpp | 10 ++-- engines/wintermute/ad/ad_game.h | 2 +- engines/wintermute/ad/ad_inventory_box.h | 9 +-- engines/wintermute/ad/ad_item.cpp | 12 ++-- engines/wintermute/ad/ad_item.h | 15 +++-- engines/wintermute/ad/ad_node_state.h | 4 +- engines/wintermute/ad/ad_scene.cpp | 6 +- engines/wintermute/ad/ad_scene.h | 58 ++++++++++---------- engines/wintermute/ad/ad_scene_state.cpp | 2 +- engines/wintermute/ad/ad_sentence.cpp | 2 +- engines/wintermute/ad/ad_sentence.h | 2 +- engines/wintermute/base/base_frame.cpp | 6 +- engines/wintermute/base/base_frame.h | 2 +- engines/wintermute/base/base_game.cpp | 28 +++++----- engines/wintermute/base/base_game.h | 4 +- engines/wintermute/base/base_object.cpp | 14 ++--- .../wintermute/base/base_persistence_manager.cpp | 14 ++--- engines/wintermute/base/base_region.cpp | 26 ++++----- engines/wintermute/base/base_sprite.cpp | 22 ++++---- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/base_surface_storage.h | 2 +- engines/wintermute/base/font/base_font.cpp | 4 +- engines/wintermute/base/font/base_font_bitmap.cpp | 64 +++++++++++----------- engines/wintermute/base/font/base_font_bitmap.h | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/gfx/base_surface.h | 6 +- .../base/gfx/osystem/base_render_osystem.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 10 ++-- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 54 +++++++++--------- .../wintermute/base/scriptables/script_engine.cpp | 18 +++--- .../base/scriptables/script_ext_array.cpp | 18 +++--- .../base/scriptables/script_ext_file.cpp | 8 +-- .../wintermute/base/scriptables/script_ext_file.h | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 20 +++---- engines/wintermute/base/sound/base_sound.cpp | 2 +- engines/wintermute/base/sound/base_sound.h | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 4 +- engines/wintermute/platform_osystem.cpp | 6 +- engines/wintermute/platform_osystem.h | 2 +- engines/wintermute/system/sys_instance.h | 2 +- engines/wintermute/ui/ui_window.cpp | 8 +-- engines/wintermute/utils/string_util.cpp | 16 +++--- engines/wintermute/utils/utils.cpp | 20 +++---- engines/wintermute/utils/utils.h | 2 +- engines/wintermute/video/video_player.cpp | 58 ++++++++++---------- engines/wintermute/video/video_player.h | 8 +-- engines/wintermute/video/video_theora_player.cpp | 18 +++--- engines/wintermute/video/video_theora_player.h | 8 +-- engines/wintermute/wintermute.cpp | 14 ++--- 55 files changed, 344 insertions(+), 342 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index fb46cef9cf..540b6b62c2 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -752,9 +752,9 @@ bool AdActor::update() { _tempSprite2 = _sentence->_currentSprite; } - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; _state = _nextState; @@ -797,7 +797,7 @@ bool AdActor::update() { if (_currentSprite && !already_moved) { - _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -857,7 +857,7 @@ void AdActor::getNextStep() { return; } - _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (!_currentSprite->_changed) { return; } @@ -941,9 +941,9 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) { stack->correctParams(2); - int X = stack->pop()->getInt(); - int Y = stack->pop()->getInt(); - goTo(X, Y); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + goTo(x, y); if (strcmp(name, "GoToAsync") != 0) { script->waitForExclusive(this); } @@ -1033,11 +1033,11 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); + const char *animName = stack->pop()->getString(); - bool Found = false; + bool found = false; for (int i = 0; i < _anims.getSize(); i++) { - if (scumm_stricmp(_anims[i]->getName(), AnimName) == 0) { + if (scumm_stricmp(_anims[i]->getName(), animName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) { _tempSprite2 = NULL; @@ -1053,10 +1053,10 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, _anims[i] = NULL; _anims.remove_at(i); i--; - Found = true; + found = true; } } - stack->pushBool(Found); + stack->pushBool(found); return STATUS_OK; } @@ -1065,8 +1065,8 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HasAnim") == 0) { stack->correctParams(1); - const char *AnimName = stack->pop()->getString(); - stack->pushBool(getAnimByName(AnimName) != NULL); + const char *animName = stack->pop()->getString(); + stack->pushBool(getAnimByName(animName) != NULL); return STATUS_OK; } else { return AdTalkHolder::scCallMethod(script, stack, thisStack, name); @@ -1421,7 +1421,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { int cmd; BaseParser parser(_gameRef); - bool Ret = STATUS_OK; + bool ret = STATUS_OK; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -1429,7 +1429,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { AdSpriteSet *anim = new AdSpriteSet(_gameRef, this); if (!anim || DID_FAIL(anim->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; - Ret = STATUS_FAILED; + ret = STATUS_FAILED; } else { _anims.add(anim); } @@ -1438,7 +1438,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { } } delete[] fileBuffer; - return Ret; + return ret; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index aa30a0096c..daa064f328 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -611,9 +611,9 @@ bool AdEntity::update() { _tempSprite2 = _sentence->_currentSprite; } - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; _state = STATE_READY; @@ -637,7 +637,7 @@ bool AdEntity::update() { if (_currentSprite) { - _currentSprite->GetCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); + _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); if (_currentSprite->_changed) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; @@ -648,10 +648,10 @@ bool AdEntity::update() { _ready = (_state == STATE_READY); if (_theora) { - int OffsetX, OffsetY; - _gameRef->getOffset(&OffsetX, &OffsetY); - _theora->_posX = _posX - OffsetX; - _theora->_posY = _posY - OffsetY; + int offsetX, offsetY; + _gameRef->getOffset(&offsetX, &offsetY); + _theora->_posX = _posX - offsetX; + _theora->_posY = _posY - offsetY; _theora->update(); if (_theora->isFinished()) { diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index e7bc4483e6..66ec582f21 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -334,7 +334,7 @@ bool AdGame::displaySentences(bool frozen) { ////////////////////////////////////////////////////////////////////////// void AdGame::finishSentences() { for (int i = 0; i < _sentences.getSize(); i++) { - if (_sentences[i]->CanSkip()) { + if (_sentences[i]->canSkip()) { _sentences[i]->_duration = 0; if (_sentences[i]->_sound) { _sentences[i]->_sound->stop(); @@ -557,8 +557,8 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResetResponse") == 0) { stack->correctParams(1); - int ID = stack->pop()->getInt(-1); - resetResponse(ID); + int id = stack->pop()->getInt(-1); + resetResponse(id); stack->pushNULL(); return STATUS_OK; } @@ -1175,7 +1175,7 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { +bool AdGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// @@ -1204,7 +1204,7 @@ bool AdGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// // call parent else { - return BaseGame::ExternalCall(script, stack, thisStack, name); + return BaseGame::externalCall(script, stack, thisStack, name); } diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index e0179d3e94..ef671b0a64 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -135,7 +135,7 @@ public: virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); bool validMouse(); private: - virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); AdObject *_invObject; BaseArray _inventories; diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h index dfbf62be9a..1857cd8f19 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -40,10 +40,6 @@ class AdInventoryBox : public BaseObject { public: bool _hideSelected; DECLARE_PERSISTENT(AdInventoryBox, BaseObject) - bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; bool _visible; virtual bool display(); UIButton *_closeButton; @@ -57,6 +53,11 @@ public: bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); +private: + bool _exclusive; + int _scrollBy; + int _itemHeight; + int _itemWidth; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index c9e0d56b24..70b8bba2a4 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -378,9 +378,9 @@ bool AdItem::update() { _tempSprite2 = _sentence->_currentSprite; } - bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) { - if (TimeIsUp) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); + if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; _state = STATE_READY; @@ -440,9 +440,9 @@ bool AdItem::display(int x, int y) { if (_amountString) { font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); } else { - char Str[256]; - sprintf(Str, "%d", _amount); - font->drawText((byte *)Str, amountX, amountY, width, _amountAlign); + char str[256]; + sprintf(str, "%d", _amount); + font->drawText((byte *)str, amountX, amountY, width, _amountAlign); } } } diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index 11010c2a35..eaa6844fcd 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -36,14 +36,6 @@ namespace WinterMute { class AdItem : public AdTalkHolder { public: - bool _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; - TTextAlign _amountAlign; - char *_amountString; - - bool update(); DECLARE_PERSISTENT(AdItem, AdTalkHolder) bool display(int x, int y); @@ -63,6 +55,13 @@ public: virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); +private: + bool _displayAmount; + int _amount; + int _amountOffsetX; + int _amountOffsetY; + TTextAlign _amountAlign; + char *_amountString; }; } // end of namespace WinterMute diff --git a/engines/wintermute/ad/ad_node_state.h b/engines/wintermute/ad/ad_node_state.h index fc7692a1bf..64ecab6849 100644 --- a/engines/wintermute/ad/ad_node_state.h +++ b/engines/wintermute/ad/ad_node_state.h @@ -35,6 +35,7 @@ class AdEntity; class AdNodeState : public BaseClass { public: + bool _active; bool transferEntity(AdEntity *entity, bool includingSprites, bool saving); void setName(const char *name); void setFilename(const char *filename); @@ -42,8 +43,9 @@ public: DECLARE_PERSISTENT(AdNodeState, BaseClass) AdNodeState(BaseGame *inGame); virtual ~AdNodeState(); + const char *getName() const { return _name; } +private: char *_name; - bool _active; char *_caption[7]; void setCaption(const char *caption, int caseVal); char *getCaption(int caseVal); diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index d863d21140..e047373918 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -659,7 +659,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { int ar, ag, ab, aa; char camera[MAX_PATH_LENGTH] = ""; - /* float WaypointHeight = -1.0f; */ + /* float waypointHeight = -1.0f; */ while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -991,8 +991,8 @@ bool AdScene::traverseNodes(bool doUpdate) { _gameRef->_renderer->setup2D(); // for each layer - /* int MainOffsetX = 0; */ - /* int MainOffsetY = 0; */ + /* int mainOffsetX = 0; */ + /* int mainOffsetY = 0; */ for (j = 0; j < _layers.getSize(); j++) { if (!_layers[j]->_active) { diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index a4bf666aea..5c2f505001 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -47,55 +47,55 @@ class AdPathPoint; class AdScene : public BaseObject { public: - BaseObject *getNextAccessObject(BaseObject *CurrObject); - BaseObject *getPrevAccessObject(BaseObject *CurrObject); - bool getSceneObjects(BaseArray &Objects, bool InteractiveOnly); - bool getRegionObjects(AdRegion *Region, BaseArray &Objects, bool InteractiveOnly); + BaseObject *getNextAccessObject(BaseObject *currObject); + BaseObject *getPrevAccessObject(BaseObject *currObject); + bool getSceneObjects(BaseArray &objects, bool interactiveOnly); + bool getRegionObjects(AdRegion *region, BaseArray &objects, bool interactiveOnly); bool afterLoad(); - bool getRegionsAt(int X, int Y, AdRegion **RegionList, int NumRegions); - bool handleItemAssociations(const char *ItemName, bool Show); + bool getRegionsAt(int x, int y, AdRegion **regionList, int numRegions); + bool handleItemAssociations(const char *itemName, bool show); UIWindow *_shieldWindow; - float getRotationAt(int X, int Y); + float getRotationAt(int x, int y); bool loadState(); bool saveState(); bool _persistentState; bool _persistentStateSprites; BaseObject *getNodeByName(const char *name); - void setOffset(int OffsetLeft, int OffsetTop); - bool pointInViewport(int X, int Y); + void setOffset(int offsetLeft, int offsetTop); + bool pointInViewport(int x, int y); int getOffsetTop(); int getOffsetLeft(); - bool getViewportSize(int *Width = NULL, int *Height = NULL); - bool getViewportOffset(int *OffsetX = NULL, int *OffsetY = NULL); + bool getViewportSize(int *width = NULL, int *height = NULL); + bool getViewportOffset(int *offsetX = NULL, int *offsetY = NULL); BaseViewport *_viewport; BaseFader *_fader; int _pfPointsNum; - void pfPointsAdd(int X, int Y, int Distance); + void pfPointsAdd(int x, int y, int distance); void pfPointsStart(); bool _initialized; - bool correctTargetPoint(int StartX, int StartY, int *X, int *Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); - bool correctTargetPoint2(int StartX, int StartY, int *TargetX, int *TargetY, bool CheckFreeObjects, BaseObject *Requester); + bool correctTargetPoint(int startX, int startY, int *x, int *y, bool checkFreeObjects = false, BaseObject *requester = NULL); + bool correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, BaseObject *requester); DECLARE_PERSISTENT(AdScene, BaseObject) - bool displayRegionContent(AdRegion *Region = NULL, bool Display3DOnly = false); - bool displayRegionContentOld(AdRegion *Region = NULL); - static int compareObjs(const void *Obj1, const void *Obj2); + bool displayRegionContent(AdRegion *region = NULL, bool display3DOnly = false); + bool displayRegionContentOld(AdRegion *region = NULL); + static int compareObjs(const void *obj1, const void *obj2); bool updateFreeObjects(); - bool traverseNodes(bool Update = false); - float getScaleAt(int Y); + bool traverseNodes(bool update = false); + float getScaleAt(int y); bool sortScaleLevels(); bool sortRotLevels(); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - uint32 getAlphaAt(int X, int Y, bool ColorCheck = false); + uint32 getAlphaAt(int x, int y, bool colorCheck = false); bool _paralaxScrolling; - void skipTo(int OffsetX, int OffsetY); + void skipTo(int offsetX, int offsetY); void setDefaults(); void cleanup(); - void skipToObject(BaseObject *Object); - void scrollToObject(BaseObject *Object); - void scrollTo(int OffsetX, int OffsetY); + void skipToObject(BaseObject *object); + void scrollToObject(BaseObject *object); + void scrollTo(int offsetX, int offsetY); virtual bool update(); bool _autoScroll; int _targetOffsetTop; @@ -113,10 +113,10 @@ public: uint32 _pfMaxTime; bool initLoop(); void pathFinderStep(); - bool isBlockedAt(int X, int Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); - bool isWalkableAt(int X, int Y, bool CheckFreeObjects = false, BaseObject *Requester = NULL); + bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = NULL); + bool isWalkableAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = NULL); AdLayer *_mainLayer; - float getZoomAt(int X, int Y); + float getZoomAt(int x, int y); bool getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = NULL); AdScene(BaseGame *inGame); virtual ~AdScene(); @@ -163,8 +163,8 @@ public: private: - bool persistState(bool Saving = true); - void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *Requester = NULL); + bool persistState(bool saving = true); + void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *requester = NULL); bool _pfReady; BasePoint *_pfTarget; AdPath *_pfTargetPath; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 673fb965e9..bbacf57707 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -76,7 +76,7 @@ void AdSceneState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { for (int i = 0; i < _nodeStates.getSize(); i++) { - if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) { + if (scumm_stricmp(_nodeStates[i]->getName(), name) == 0) { return _nodeStates[i]; } } diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index d429c1fedf..6bbcd590a8 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -353,7 +353,7 @@ bool AdSentence::update(TDirection dir) { } ////////////////////////////////////////////////////////////////////////// -bool AdSentence::CanSkip() { +bool AdSentence::canSkip() { // prevent accidental sentence skipping (TODO make configurable) return (_gameRef->_timer - _startTime) > 300; } diff --git a/engines/wintermute/ad/ad_sentence.h b/engines/wintermute/ad/ad_sentence.h index 6883bd8893..ae4ee793d5 100644 --- a/engines/wintermute/ad/ad_sentence.h +++ b/engines/wintermute/ad/ad_sentence.h @@ -72,7 +72,7 @@ public: virtual ~AdSentence(); AdTalkDef *_talkDef; - bool CanSkip(); + bool canSkip(); private: char *_tempStance; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 208d6037d9..44e39823e6 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -268,9 +268,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.add(Event); + char *event = new char[strlen(params) + 1]; + strcpy(event, params); + _applyEvent.add(event); } break; diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index c8e9cbb400..b019ebf7b6 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -52,7 +52,7 @@ public: int _moveX; uint32 _delay; BaseArray _subframes; - bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 402b7294aa..20ed358ec2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1051,14 +1051,14 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); ScValue *val = stack->pop(); - bool ClearOld; + bool clearOld; if (val->isNULL()) { - ClearOld = true; + clearOld = true; } else { - ClearOld = val->getBool(); + clearOld = val->getBool(); } - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) { + if (DID_FAIL(_stringTable->loadFile(filename, clearOld))) { stack->pushBool(false); } else { stack->pushBool(true); @@ -1530,7 +1530,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool dropFrames = stack->pop()->getBool(true); ScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { type = (int)VID_PLAY_STRETCH; @@ -1538,7 +1538,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _theoraPlayer; _theoraPlayer = new VideoTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, subtitleFile))) { _theoraPlayer->_dontDropFrames = !dropFrames; if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); @@ -1649,8 +1649,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); - int Slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(Slot)); + int slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(slot)); return STATUS_OK; } @@ -2162,7 +2162,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccOutputText") == 0) { stack->correctParams(2); - /* const char *Str = */ stack->pop()->getString(); + /* const char *str = */ stack->pop()->getString(); /* int type = */ stack->pop()->getInt(); // do nothing stack->pushNULL(); @@ -2225,9 +2225,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack crc checksum = crc_finalize(remainder); if (asHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - stack->pushString(Hex); + char hex[100]; + sprintf(hex, "%x", checksum); + stack->pushString(hex); } else { stack->pushInt(checksum); } @@ -3032,7 +3032,7 @@ bool BaseGame::validObject(BaseObject *object) { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { +bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// @@ -4266,7 +4266,7 @@ bool BaseGame::displayIndicator() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::updateMusicCrossfade() { - /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + /* byte globMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) { return STATUS_OK; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index ecb698b70a..d4a4c0e682 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -39,7 +39,7 @@ namespace WinterMute { -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); +typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); class BaseSoundMgr; class BaseFader; @@ -168,7 +168,7 @@ public: bool _suppressScriptErrors; bool _mouseLeftDown; // TODO: Hide - virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 18619616fe..76047ef4b4 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -428,8 +428,8 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "SetSoundPosition") == 0) { stack->correctParams(1); - uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) { + uint32 time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(time))) { stack->pushBool(false); } else { stack->pushBool(true); @@ -1099,7 +1099,7 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const _sFX->setPositionTime(_sFXStart); _sFXStart = 0; } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + _sFX->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (playNow) { setSoundEvent(eventName); if (loopStart) { @@ -1192,16 +1192,16 @@ bool BaseObject::updateSounds() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::updateOneSound(BaseSound *sound) { - bool Ret = STATUS_OK; + bool ret = STATUS_OK; if (sound) { if (_autoSoundPanning) { - Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); } - Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + ret = sound->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } - return Ret; + return ret; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 9f07da57ac..bc751e6aed 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -206,13 +206,13 @@ bool BasePersistenceManager::initSave(const char *desc) { magic = SAVE_MAGIC_2; putDWORD(magic); - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(VerMajor); - _saveStream->writeByte(VerMinor); - _saveStream->writeByte(ExtMajor); - _saveStream->writeByte(ExtMinor); + byte verMajor, verMinor, extMajor, extMinor; + _gameRef->getVersion(&verMajor, &verMinor, &extMajor, &extMinor); + //uint32 version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(verMajor); + _saveStream->writeByte(verMinor); + _saveStream->writeByte(extMajor); + _saveStream->writeByte(extMinor); // new in ver 2 putDWORD((uint32)DCGF_VER_BUILD); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 13815a5958..79ea5396fc 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -244,12 +244,12 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.getSize()) { - _points.insert_at(Index, new BasePoint(x, y)); + if (index >= 0 && index < _points.getSize()) { + _points.insert_at(index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -265,13 +265,13 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.getSize()) { - _points[Index]->x = x; - _points[Index]->y = y; + if (index >= 0 && index < _points.getSize()) { + _points[index]->x = x; + _points[index]->y = y; createRegion(); stack->pushBool(true); @@ -497,16 +497,16 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) { if (_points.getSize() == 0) { BasePlatform::setRectEmpty(rect); } else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; for (int i = 0; i < _points.getSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); + minX = MIN(minX, _points[i]->x); + minY = MIN(minY, _points[i]->y); - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); + maxX = MAX(maxX, _points[i]->x); + maxY = MAX(maxY, _points[i]->y); } - BasePlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + BasePlatform::setRect(rect, minX, minY, maxX, maxY); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 274c792263..fb1b5a82cf 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -103,7 +103,7 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - GetCurrentFrame(zoomX, zoomY); + getCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { return STATUS_OK; } @@ -291,14 +291,14 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa break; case TOKEN_FRAME: { - int FrameLifeTime = lifeTime; + int frameLifeTime = lifeTime; if (cacheType == CACHE_HALF && frameCount % 2 != 1) { - FrameLifeTime = -1; + frameLifeTime = -1; } frame = new BaseFrame(_gameRef); - if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + if (DID_FAIL(frame->loadBuffer(params, frameLifeTime, _streamedKeepLoaded))) { delete frame; _gameRef->LOG(0, "Error parsing frame %d", frameCount); return STATUS_FAILED; @@ -345,7 +345,7 @@ void BaseSprite::reset() { ////////////////////////////////////////////////////////////////////// -bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { +bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) { @@ -406,7 +406,7 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { return STATUS_OK; } @@ -421,7 +421,7 @@ bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float } // draw frame - return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); + return _frames[_currentFrame]->draw(x - _gameRef->_offsetX, y - _gameRef->_offsetY, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); } @@ -549,12 +549,12 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); stack->pushNULL(); } else { - stack->pushNative(_frames[Index], true); + stack->pushNative(_frames[index], true); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 477ab70878..084d7b2d70 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -57,7 +57,7 @@ public: int _moveY; int _moveX; bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool getCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; bool _continuous; diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 350210b95e..13c4deb3db 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -40,7 +40,7 @@ public: bool initLoop(); bool sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool Warn = false); + bool cleanup(bool warn = false); //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 937557f4d7..34ff717ae5 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -191,13 +191,13 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { return false; } - byte *WorkBuffer = buffer; + byte *workBuffer = buffer; char *params; BaseParser parser(gameRef); bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { + if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { ret = true; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ee876f2503..9431c730bd 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -127,9 +127,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli return 0; } - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; + int lineLength = 0; + int realLength = 0; + int numLines = 0; int i; @@ -139,66 +139,66 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli int last_end = 0; bool done = false; - bool new_line = false; - bool long_line = false; + bool newLine = false; + bool longLine = false; if (draw) { _gameRef->_renderer->startSpriteBatch(); } while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (maxHeight > 0 && (numLines + 1)*_tileHeight > maxHeight) { if (draw) { _gameRef->_renderer->endSpriteBatch(); } - return NumLines * _tileHeight; + return numLines * _tileHeight; } index++; if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { end = index - 1; - RealLength = LineLength; + realLength = lineLength; } if (str[index] == '\n') { end = index - 1; - RealLength = LineLength; - new_line = true; + realLength = lineLength; + newLine = true; } - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + if (lineLength + getCharWidth(str[index]) > width && last_end == end) { end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; + realLength = lineLength; + newLine = true; + longLine = true; } if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { done = true; - if (!new_line) { + if (!newLine) { end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; + lineLength += getCharWidth(str[index]); + realLength = lineLength; } } else { - LineLength += getCharWidth(str[index]); + lineLength += getCharWidth(str[index]); } - if ((LineLength > width) || done || new_line) { + if ((lineLength > width) || done || newLine) { if (end < 0) { done = true; } - int StartX; + int startX; switch (align) { case TAL_CENTER: - StartX = x + (width - RealLength) / 2; + startX = x + (width - realLength) / 2; break; case TAL_RIGHT: - StartX = x + width - RealLength; + startX = x + width - realLength; break; case TAL_LEFT: - StartX = x; + startX = x; break; default: error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); @@ -206,21 +206,21 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } for (i = start; i < end + 1; i++) { if (draw) { - drawChar(str[i], StartX, y); + drawChar(str[i], startX, y); } - StartX += getCharWidth(str[i]); + startX += getCharWidth(str[i]); } y += _tileHeight; last_end = end; - if (long_line) { + if (longLine) { end--; } start = end + 2; index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; + lineLength = 0; + newLine = false; + longLine = false; + numLines++; } } @@ -228,7 +228,7 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli _gameRef->_renderer->endSpriteBatch(); } - return NumLines * _tileHeight; + return numLines * _tileHeight; } @@ -255,7 +255,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; if (_sprite) { - _sprite->GetCurrentFrame(); + _sprite->getCurrentFrame(); if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 79806be95f..abf2d39aa0 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -62,7 +62,7 @@ private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index ac6430d4c9..c643a5e1b1 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -701,7 +701,7 @@ bool BaseFontTT::initFont() { // http://en.wikipedia.org/wiki/E_(typography) float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float emsPerUnit = 1.0f / _fTFace->units_per_EM; float pixelsPerUnit = pixelsPerEm * EmsPerUnit; // bounding box in pixels diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 68e3e3d26c..635d48058f 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -87,7 +87,7 @@ bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect } ////////////////////////////////////////////////////////////////////////// -bool BaseSurface::create(int Width, int Height) { +bool BaseSurface::create(int width, int height) { return STATUS_FAILED; } diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 66a3460d48..4f67f871dd 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -52,12 +52,12 @@ public: virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool restore(); virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual bool create(int Width, int Height); + virtual bool create(int width, int height); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return STATUS_FAILED; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 6913b3434c..7e43b0b7f4 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -619,8 +619,8 @@ void BaseRenderOSystem::dumpData(const char *filename) { BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - int TotalKB = 0; - int TotalLoss = 0; + int totalKB = 0; + int totalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index b77abf6a79..aa9cc8474a 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -327,8 +327,8 @@ bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !transparent, blendMode, mirrorX, mirrorY); } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 9ed80cec50..8e4370892b 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -55,7 +55,7 @@ public: bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 8b86365196..f8c0c1a5cf 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -45,7 +45,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(PartEmitter, false) ////////////////////////////////////////////////////////////////////////// -PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject(inGame) { +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { _width = _height = 0; BasePlatform::setRectEmpty(&_border); @@ -88,7 +88,7 @@ PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject _useRegion = false; _emitEvent = NULL; - _owner = Owner; + _owner = owner; } @@ -136,9 +136,9 @@ bool PartEmitter::addSprite(const char *filename) { _gameRef->_fileManager->closeFile(File); } - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); + char *str = new char[strlen(filename) + 1]; + strcpy(str, filename); + _sprites.add(str); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 4a5239edfe..27dbe9999c 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -198,7 +198,7 @@ bool PartParticle::display(PartEmitter *emitter) { return STATUS_OK; } - _sprite->GetCurrentFrame(); + _sprite->getCurrentFrame(); return _sprite->display(_pos.x, _pos.y, NULL, _scale, _scale, diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 54a04c454f..75c4d38574 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -165,7 +165,7 @@ bool ScScript::initScript() { ////////////////////////////////////////////////////////////////////////// bool ScScript::initTables() { - uint32 OrigIP = _iP; + uint32 origIP = _iP; readHeader(); // load symbol table @@ -232,7 +232,7 @@ bool ScScript::initTables() { } - _iP = OrigIP; + _iP = origIP; return STATUS_OK; } @@ -546,7 +546,7 @@ bool ScScript::executeInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { dw = getDWORD(); - /* char *Temp = _symbols[dw]; // TODO delete */ + /* char *temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist if (!_engine->_globals->propExists(_symbols[dw])) { _operand->setNULL(); @@ -604,8 +604,8 @@ bool ScScript::executeInstruction() { // push var // push string str = _stack->pop()->getString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); + char *methodName = new char[strlen(str) + 1]; + strcpy(methodName, str); ScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) { @@ -613,21 +613,21 @@ bool ScScript::executeInstruction() { } bool res = STATUS_FAILED; - bool TriedNative = false; + bool triedNative = false; // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - TriedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (_thread && _methodThread && strcmp(methodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + triedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); } if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (var->isNative() && var->getNative()->canHandleMethod(methodName)) { if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(MethodName); + _waitScript = var->getNative()->invokeMethodThread(methodName); if (!_waitScript) { _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", MethodName); + runtimeError("Error invoking method '%s'.", methodName); _stack->pushNULL(); } else { _state = SCRIPT_WAITING_SCRIPT; @@ -636,10 +636,10 @@ bool ScScript::executeInstruction() { } else { // can call methods in unbreakable mode _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", MethodName); + runtimeError("Cannot call method '%s'. Ignored.", methodName); _stack->pushNULL(); } - delete[] MethodName; + delete[] methodName; break; } /* @@ -665,29 +665,29 @@ bool ScScript::executeInstruction() { */ else { res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) { - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (var->_type == VAL_NATIVE && !triedNative) { + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); } if (DID_FAIL(res)) { _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + runtimeError("Call to undefined method '%s'. Ignored.", methodName); _stack->pushNULL(); } } } - delete[] MethodName; + delete[] methodName; } break; case II_EXTERNAL_CALL: { - uint32 SymbolIndex = getDWORD(); + uint32 symbolIndex = getDWORD(); - TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + TExternalFunction *f = getExternal(_symbols[symbolIndex]); if (f) { externalCall(_stack, _thisStack, f); } else { - _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + _gameRef->externalCall(this, _stack, _thisStack, _symbols[symbolIndex]); } break; @@ -737,8 +737,8 @@ bool ScScript::executeInstruction() { } case II_POP_VAR: { - char *VarName = _symbols[getDWORD()]; - ScValue *var = getVar(VarName); + char *varName = _symbols[getDWORD()]; + ScValue *var = getVar(varName); if (var) { ScValue *val = _stack->pop(); if (!val) { @@ -1460,13 +1460,13 @@ bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExter ////////////////////////////////////////////////////////////////////////// bool ScScript::copyParameters(ScStack *stack) { int i; - int NumParams = stack->pop()->getInt(); - for (i = NumParams - 1; i >= 0; i--) { + int numParams = stack->pop()->getInt(); + for (i = numParams - 1; i >= 0; i--) { _stack->push(stack->getAt(i)); } - _stack->pushInt(NumParams); + _stack->pushInt(numParams); - for (i = 0; i < NumParams; i++) { + for (i = 0; i < numParams; i++) { stack->pop(); } diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e1aed7ed82..bc8d54ef58 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -227,13 +227,13 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = g_system->getMillis(); + uint32 minTime = g_system->getMillis(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; + } else if (_cachedScripts[i]->_timestamp <= minTime) { + minTime = _cachedScripts[i]->_timestamp; index = i; } } @@ -338,13 +338,13 @@ bool ScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = g_system->getMillis(); - while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - StartTime < _scripts[i]->_timeSlice) { + uint32 startTime = g_system->getMillis(); + while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - startTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } if (_isProfiling && _scripts[i]->_filename) { - addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); } } @@ -473,8 +473,8 @@ bool ScEngine::resetObject(BaseObject *Object) { resetScript(_scripts[i]); } - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + bool isThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!isThread); // 1.9b1 - top-level script kills its threads as well } } return STATUS_OK; @@ -707,7 +707,7 @@ bool ScEngine::loadBreakpoints() { int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { - /* uint32 BufSize = 512; */ + /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 0380103cd4..cc3bec89c0 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -162,9 +162,9 @@ ScValue *SXArray::scGetProperty(const char *name) { // [number] ////////////////////////////////////////////////////////////////////////// else { - char ParamName[20]; - if (validNumber(name, ParamName)) { - return _values->getProp(ParamName); + char paramName[20]; + if (validNumber(name, paramName)) { + return _values->getProp(paramName); } else { return _scValue; } @@ -178,14 +178,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length") == 0) { - int OrigLength = _length; + int origLength = _length; _length = MAX(value->getInt(0), 0); - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->deleteProp(PropName); + char propName[20]; + if (_length < origLength) { + for (int i = _length; i < origLength; i++) { + sprintf(propName, "%d", i); + _values->deleteProp(propName); } } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 437fbb64a2..4eeabca04d 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -188,8 +188,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, script->runtimeError("File.%s: File is not open", name); stack->pushBool(false); } else { - int Pos = stack->pop()->getInt(); - stack->pushBool(setPos(Pos)); + int pos = stack->pop()->getInt(); + stack->pushBool(setPos(pos)); } return STATUS_OK; } @@ -703,10 +703,10 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length")==0){ - int OrigLength = _length; + int origLength = _length; _length = max(value->getInt(0), 0); - char PropName[20]; + char propName[20]; if (_length < OrigLength){ for(int i=_length; ipop()->getInt(); - resize(MAX(0, NewSize)); + int newSize = stack->pop()->getInt(); + resize(MAX(0, newSize)); } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *Buffer): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer): BaseScriptable(inGame) { _size = 0; - _buffer = Buffer; + _buffer = buffer; } @@ -184,11 +184,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) { + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(short))) { stack->pushNULL(); } else { - stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + stack->pushInt(65536 + * (short *)((byte *)_buffer + start)); } return STATUS_OK; @@ -416,7 +416,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushBool(false); } else { /* - int Pointer = (int)Val->getMemBuffer(); + int pointer = (int)Val->getMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); stack->pushBool(true); */ @@ -478,10 +478,10 @@ bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length")==0){ - int OrigLength = _length; + int origLength = _length; _length = max(value->getInt(0), 0); - char PropName[20]; + char propName[20]; if (_length < OrigLength){ for(int i=_length; i(_gameRef->_renderer); Point32 p; - p.x = X; - p.y = Y; + p.x = x; + p.y = y; renderer->pointToScreen(&p); // TODO //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 77a690c207..14b8c959a8 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -48,7 +48,7 @@ public: static void outputDebugString(const char *lpOutputString); //static uint32 getTime(); static bool getCursorPos(Point32 *lpPoint); - static bool setCursorPos(int X, int Y); + static bool setCursorPos(int x, int y); static bool showWindow(int nCmdShow); static void setCapture(); diff --git a/engines/wintermute/system/sys_instance.h b/engines/wintermute/system/sys_instance.h index 493055a8fd..90336742f8 100644 --- a/engines/wintermute/system/sys_instance.h +++ b/engines/wintermute/system/sys_instance.h @@ -35,7 +35,7 @@ class SystemClass; class SystemInstance { public: - SystemInstance(void *Instance, int ID, SystemClass *sysClass); + SystemInstance(void *instance, int id, SystemClass *sysClass); virtual ~SystemInstance(); int getID() const { diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index b9e2ad056f..6aba91b791 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -733,10 +733,10 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { } ////////////////////////////////////////////////////////////////////////// -bool UIWindow::enableWidget(const char *name, bool Enable) { +bool UIWindow::enableWidget(const char *name, bool enable) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_disable = !Enable; + _widgets[i]->_disable = !enable; } } return STATUS_OK; @@ -744,10 +744,10 @@ bool UIWindow::enableWidget(const char *name, bool Enable) { ////////////////////////////////////////////////////////////////////////// -bool UIWindow::showWidget(const char *name, bool Visible) { +bool UIWindow::showWidget(const char *name, bool visible) { for (int i = 0; i < _widgets.getSize(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { - _widgets[i]->_visible = Visible; + _widgets[i]->_visible = visible; } } return STATUS_OK; diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index f864a8480a..92f6fb202b 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -103,8 +103,8 @@ Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { /* size_t WideSize = WideStr.length(); if (sizeof(wchar_t) == 2) { - size_t Utf8Size = 3 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; + size_t utf8Size = 3 * WideSize + 1; + char *utf8StringNative = new char[Utf8Size]; const UTF16 *SourceStart = reinterpret_cast(WideStr.c_str()); const UTF16 *SourceEnd = SourceStart + WideSize; @@ -122,8 +122,8 @@ Utf8String StringUtil::wideToUtf8(const WideString &WideStr) { delete[] Utf8StringNative; return ResultString; } else if (sizeof(wchar_t) == 4) { - size_t Utf8Size = 4 * WideSize + 1; - char *Utf8StringNative = new char[Utf8Size]; + size_t utf8Size = 4 * WideSize + 1; + char *utf8StringNative = new char[Utf8Size]; const UTF32 *SourceStart = reinterpret_cast(WideStr.c_str()); const UTF32 *SourceEnd = SourceStart + WideSize; @@ -175,7 +175,7 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { // using default os locale! /* setlocale(LC_CTYPE, ""); - size_t WideSize = mbstowcs(NULL, str.c_str(), 0) + 1; + size_t wideSize = mbstowcs(NULL, str.c_str(), 0) + 1; wchar_t *wstr = new wchar_t[WideSize]; mbstowcs(wstr, str.c_str(), WideSize); WideString ResultString(wstr); @@ -194,7 +194,7 @@ AnsiString StringUtil::wideToAnsi(const WideString &wstr) { warning("StringUtil::WideToAnsi - WideString not supported yet"); } /* setlocale(LC_CTYPE, ""); - size_t WideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; + size_t wideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; wcstombs(str, wstr.c_str(), WideSize); AnsiString ResultString(str); @@ -260,8 +260,8 @@ bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool } ////////////////////////////////////////////////////////////////////////// -bool StringUtil::isUtf8BOM(const byte *Buffer, uint32 BufferSize) { - if (BufferSize > 3 && Buffer[0] == 0xEF && Buffer[1] == 0xBB && Buffer[2] == 0xBF) { +bool StringUtil::isUtf8BOM(const byte *buffer, uint32 bufferSize) { + if (bufferSize > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { return true; } else { return false; diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 3336cf63e2..3050a36263 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -40,9 +40,9 @@ static inline unsigned Sqr(int x) { // Swap - swaps two integers ////////////////////////////////////////////////////////////////////////////////// void BaseUtils::swap(int *a, int *b) { - int Temp = *a; + int temp = *a; *a = *b; - *b = Temp; + *b = temp; } @@ -150,11 +150,11 @@ float BaseUtils::randomFloat(float from, float to) { } ////////////////////////////////////////////////////////////////////////// -float BaseUtils::randomAngle(float From, float To) { - while (To < From) { - To += 360; +float BaseUtils::randomAngle(float from, float to) { + while (to < from) { + to += 360; } - return normalizeAngle(randomFloat(From, To)); + return normalizeAngle(randomFloat(from, to)); } ////////////////////////////////////////////////////////////////////////// @@ -217,10 +217,10 @@ bool BaseUtils::matchesPattern(const char *pattern, const char *string) { ////////////////////////////////////////////////////////////////////////// -void BaseUtils::RGBtoHSL(uint32 RGBColor, byte *outH, byte *outS, byte *outL) { - float varR = (RGBCOLGetR(RGBColor) / 255.0f); - float varG = (RGBCOLGetG(RGBColor) / 255.0f); - float varB = (RGBCOLGetB(RGBColor) / 255.0f); +void BaseUtils::RGBtoHSL(uint32 rgbColor, byte *outH, byte *outS, byte *outL) { + float varR = (RGBCOLGetR(rgbColor) / 255.0f); + float varG = (RGBCOLGetG(rgbColor) / 255.0f); + float varB = (RGBCOLGetB(rgbColor) / 255.0f); //Min. value of RGB float varMin = MIN(varR, varG); diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 3cb01c57b8..5b3ce65470 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -55,7 +55,7 @@ public: static bool matchesPattern(const char *pattern, const char *string); - static void RGBtoHSL(uint32 RGBColor, byte *OutH, byte *OutS, byte *OutL); + static void RGBtoHSL(uint32 rgbColor, byte *outH, byte *outS, byte *outL); static uint32 HSLtoRGB(byte H, byte S, byte L); private: diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index 66ec926582..a4c81d12b5 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -39,12 +39,12 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// VideoPlayer::VideoPlayer(BaseGame *inGame): BaseClass(inGame) { - SetDefaults(); + setDefaults(); } ////////////////////////////////////////////////////////////////////////// -bool VideoPlayer::SetDefaults() { +bool VideoPlayer::setDefaults() { _playing = false; /* _aviFile = NULL; @@ -145,7 +145,7 @@ bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { #if 0 cleanup(); - char Filename[MAX_PATH_LENGTH]; + char filename[MAX_PATH_LENGTH]; _gameRef->_fileManager->GetFullPath(inFilename, filename); // open file @@ -270,9 +270,9 @@ bool VideoPlayer::update() { // process subtitles _showSubtitle = false; while (_currentSubtitle < _subtitles.getSize()) { - int End = _subtitles[_currentSubtitle]->m_EndFrame; + int end = _subtitles[_currentSubtitle]->m_EndFrame; - bool NextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); + bool nextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); if (sample > End) { if (NextFrameOK) { @@ -324,7 +324,7 @@ bool VideoPlayer::display() { // display subtitle if (m_ShowSubtitle) { BaseFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); + int height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); } @@ -337,7 +337,7 @@ bool VideoPlayer::display() { ////////////////////////////////////////////////////////////////////////// -bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { +bool VideoPlayer::play(TVideoPlayback type, int x, int y, bool FreezeMusic) { #if 0 if (!_videoStream || !_vidRenderer) { return STATUS_FAILED; @@ -351,8 +351,8 @@ bool VideoPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) { break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float ZoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + float zoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float zoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); _playZoom = min(ZoomX, ZoomY); _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; @@ -431,7 +431,7 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) return STATUS_OK; } - char NewFile[MAX_PATH_LENGTH]; + char newFile[MAX_PATH_LENGTH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; @@ -443,35 +443,35 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) _makepath(NewFile, drive, dir, fname, ".SUB"); } - DWORD Size; - BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); + DWORD size; + BYTE *buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); if (Buffer == NULL) { return STATUS_OK; // no subtitles } LONG Start, End; - bool InToken; - char *TokenStart; - int TokenLength; - int TokenPos; - int TextLength; - - int Pos = 0; - int LineLength = 0; + bool inToken; + char *tokenStart; + int tokenLength; + int tokenPos; + int textLength; + + int pos = 0; + int lineLength = 0; while (Pos < Size) { - Start = End = -1; - InToken = false; - TokenPos = -1; - TextLength = 0; + start = End = -1; + inToken = false; + tokenPos = -1; + textLength = 0; - LineLength = 0; + lineLength = 0; while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { - LineLength++; + lineLength++; } - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *Text = new char[RealLength + 1]; + int realLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *text = new char[RealLength + 1]; char *line = (char *)&Buffer[Pos]; for (int i = 0; i < RealLength; i++) { @@ -487,7 +487,7 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) } else if (line[i] == '}') { if (InToken) { InToken = false; - char *Token = new char[TokenLength + 1]; + char *token = new char[TokenLength + 1]; strncpy(Token, TokenStart, TokenLength); Token[TokenLength] = '\0'; if (TokenPos == 0) { diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h index 8e82a44076..4c02506094 100644 --- a/engines/wintermute/video/video_player.h +++ b/engines/wintermute/video/video_player.h @@ -42,22 +42,22 @@ class VideoPlayer : public BaseClass { public: bool _showSubtitle; int _currentSubtitle; - bool loadSubtitles(const char *filename, const char *SubtitleFile); + bool loadSubtitles(const char *filename, const char *subtitleFile); bool _slowRendering; bool isPlaying(); char *_filename; bool stop(); - bool play(TVideoPlayback Type = VID_PLAY_CENTER, int X = 0, int Y = 0, bool FreezeMusic = true); + bool play(TVideoPlayback Type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeMusic = true); uint32 _totalVideoTime; uint32 _startTime; //CVidRenderer *_vidRenderer; //BaseSoundAVI *_sound; bool _soundAvailable; - bool SetDefaults(); + bool setDefaults(); bool _playing; bool display(); bool update(); - bool initialize(const char *inFilename, const char *SubtitleFile = NULL); + bool initialize(const char *inFilename, const char *subtitleFile = NULL); bool cleanup(); VideoPlayer(BaseGame *inGame); virtual ~VideoPlayer(); diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 59c83c3a52..6468f02524 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -212,9 +212,9 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)_gameRef->_renderer->_width / width * 100); - float ZoomY = (float)((float)_gameRef->_renderer->_height / height * 100); - _playZoom = MIN(ZoomX, ZoomY); + float zoomX = (float)((float)_gameRef->_renderer->_width / width * 100); + float zoomY = (float)((float)_gameRef->_renderer->_height / height * 100); + _playZoom = MIN(zoomX, zoomY); _posX = (int)((_gameRef->_renderer->_width - width * (_playZoom / 100)) / 2); _posY = (int)((_gameRef->_renderer->_height - height * (_playZoom / 100)) / 2); } @@ -278,7 +278,7 @@ bool VideoTheoraPlayer::update() { if (_theoraDecoder->getTimeToNextFrame() == 0) { _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); if (_texture) { - WriteVideo(); + writeVideo(); } } return STATUS_OK; @@ -308,7 +308,7 @@ bool VideoTheoraPlayer::update() { if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; - int Counter = 0; + int counter = 0; while (true) { if (m_Sound) DecodeVorbis(); else m_AudioFrameReady = true; @@ -354,7 +354,7 @@ bool VideoTheoraPlayer::update() { // if our buffers either don't exist or are ready to go, // we can begin playback - bool StartNow = false; + bool startNow = false; if ((!m_TheoraStreams || m_VideoFrameReady) && (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; // same if we've run out of input @@ -389,7 +389,7 @@ uint32 VideoTheoraPlayer::getMovieTime() { } ////////////////////////////////////////////////////////////////////////// -bool VideoTheoraPlayer::WriteVideo() { +bool VideoTheoraPlayer::writeVideo() { if (!_texture) { return STATUS_FAILED; } @@ -492,13 +492,13 @@ inline int intlog(int num) { } ////////////////////////////////////////////////////////////////////////// -bool VideoTheoraPlayer::SeekToTime(uint32 time) { +bool VideoTheoraPlayer::seekToTime(uint32 time) { warning("VideoTheoraPlayer::SeekToTime(%d) - not supported", time); #if 0 if (!m_TheoraStreams) return STATUS_FAILED; - float TargetTime = Time / 1000.0f; + float targetTime = Time / 1000.0f; ogg_page page; diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 58fe700d75..fe71ae0f35 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -65,10 +65,10 @@ public: bool initialize(const Common::String &filename, const Common::String &subtitleFile = NULL); bool initializeSimple(); bool update(); - bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool Looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); + bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); bool stop(); bool display(uint32 alpha = 0xFFFFFFFF); - //bool RenderFrame(BaseSurface *Texture, yuv_buffer *yuv); + //bool renderFrame(BaseSurface *texture, yuv_buffer *yuv); bool pause(); bool resume(); @@ -101,7 +101,7 @@ public: __inline byte getAlphaAt(int x, int y); void writeAlpha(); - bool SeekToTime(uint32 Time); + bool seekToTime(uint32 Time); void cleanup(); @@ -135,7 +135,7 @@ private: bool _videoFrameReady; float _videobufTime; - bool WriteVideo(); + bool writeVideo(); bool _playbackStarted; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index ac9c3b7fbf..21ee65b832 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -174,8 +174,8 @@ int WinterMuteEngine::init() { else param[0] = '\0'; if (strcmp(param, "") != 0) { - char *IniDir = BaseUtils::GetPath(param); - char *IniName = BaseUtils::GetFilename(param); + char *iniDir = BaseUtils::GetPath(param); + char *iniName = BaseUtils::GetFilename(param); // switch to ini's dir warning("TODO: Place ini-files somewhere"); @@ -201,7 +201,7 @@ int WinterMuteEngine::init() { _game->_smartCache = false; } - /* bool AllowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ + /* bool allowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ // load general game settings _game->initialize1(); @@ -245,7 +245,7 @@ int WinterMuteEngine::init() { // load game - uint32 DataInitStart = g_system->getMillis(); + uint32 dataInitStart = g_system->getMillis(); if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { _game->LOG(ret, "Error loading game file. Exiting."); @@ -257,7 +257,7 @@ int WinterMuteEngine::init() { _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; - _game->LOG(0, "Engine initialized in %d ms", g_system->getMillis() - DataInitStart); + _game->LOG(0, "Engine initialized in %d ms", g_system->getMillis() - dataInitStart); _game->LOG(0, ""); if (ConfMan.hasKey("save_slot")) { @@ -316,8 +316,8 @@ int WinterMuteEngine::messageLoop() { { if (!::IsIconic(_game->_renderer->_window)) { - int PosX = _game->_renderer->_windowRect.left; - int PosY = _game->_renderer->_windowRect.top; + int posX = _game->_renderer->_windowRect.left; + int posY = _game->_renderer->_windowRect.top; PosX -= _game->_renderer->_monitorRect.left; PosY -= _game->_renderer->_monitorRect.top; -- cgit v1.2.3 From 90e174eeb28a956e67b3e3e2d2b38489ded958c8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 23:49:50 +0200 Subject: WINTERMUTE: Implement Screen-fading --- .../base/gfx/osystem/base_render_osystem.cpp | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 7e43b0b7f4..917a76be85 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -284,20 +284,17 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) { - _renderSurface->fillRect(fillRect, col); - } else { - setAlphaMod(a); - setColorMod(r, g, b); - Graphics::Surface surf; - surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); - Common::Rect sizeRect(fillRect); - sizeRect.translate(-fillRect.top, -fillRect.left); - surf.fillRect(fillRect, col); - drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); - surf.free(); - _clearColor = col; - } + + setAlphaMod(255); + setColorMod(255, 255, 255); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); @@ -320,14 +317,16 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S return; } - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - drawFromTicket(*it); - return; + if (owner) { // Fade-tickets are owner-less + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } } } RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); -- cgit v1.2.3 From bb131aaa072d1d75e7d1c0a5f6f0ef3614fc8eb7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 00:05:15 +0200 Subject: WINTERMUTE: Clean up some TODOs. --- engines/wintermute/base/base.cpp | 2 -- engines/wintermute/base/base_game.cpp | 25 +++------------------- engines/wintermute/base/base_object.cpp | 2 +- engines/wintermute/base/file/base_file_entry.cpp | 8 +++---- engines/wintermute/base/file/base_package.cpp | 18 ++++++++++++++++ engines/wintermute/base/file/dcpackage.h | 20 ++--------------- .../base/gfx/osystem/base_render_osystem.cpp | 2 -- .../base/gfx/osystem/base_surface_osystem.cpp | 3 +-- engines/wintermute/detection.cpp | 2 +- engines/wintermute/video/video_theora_player.cpp | 2 +- 10 files changed, 30 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 687d2d52e6..d5163fa7a6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -175,8 +175,6 @@ bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "{\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove buffer->putTextIndent(indent, "}\n\n"); _editorPropsIter++; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 20ed358ec2..cb53d37c2d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1459,13 +1459,6 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // PlayVideo ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayVideo") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK; - // TODO: ADDVIDEO - */ - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); stack->correctParams(6); @@ -1508,12 +1501,6 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK;*/ - // TODO: ADDVIDEO - stack->correctParams(7); const char *filename = stack->pop()->getString(); ScValue *valType = stack->pop(); @@ -1830,14 +1817,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); const char *filename = stack->pop()->getString(); - // TODO: Replace with fileExists - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) { - stack->pushBool(false); - } else { - _fileManager->closeFile(file); - stack->pushBool(true); - } + bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false + stack->pushBool(exists); return STATUS_OK; } @@ -3933,7 +3914,7 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { } else { /*if (event->type != SDL_TEXTINPUT)*/ applyEvent("Keypress"); return true; - } //else return true; + } return false; } diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 76047ef4b4..5fbfc31924 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -138,7 +138,7 @@ bool BaseObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull +void BaseObject::setCaption(const char *caption, int caseVal) { if (caseVal == 0) { caseVal = 1; } diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 7bf635b858..da1bfa7ac8 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -65,18 +65,16 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { return NULL; } - // TODO: Cleanup + bool compressed = (_compressedLength != 0); - /* _size = fileEntry->_length; */ if (compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); + // file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // TODO: Uncomment on merge } else { file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); } - if (file->size() == 0) { + if (file->size() == 0) { // TODO: Cleanup on next merge (CBPkgFile is just a placeholder for the commented out wrap above. file = new CBPkgFile(file, _length); } diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index b41ae3c1bd..80d3b4a515 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -82,6 +82,24 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) } +void TPackageHeader::readFromStream(Common::ReadStream *stream) { + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); + + _gameVersion = stream->readUint32LE(); + + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + _creationTime = stream->readUint32LE(); + + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); +} + PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; _priority = 0; diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 4a51683260..ccebc5909c 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -50,24 +50,8 @@ struct TPackageHeader { uint32 _creationTime; char _desc[100]; uint32 _numDirs; - // TODO: Move this out of the header. - void readFromStream(Common::ReadStream *stream) { - _magic1 = stream->readUint32LE(); - _magic2 = stream->readUint32LE(); - _packageVersion = stream->readUint32LE(); - - _gameVersion = stream->readUint32LE(); - - _priority = stream->readByte(); - _cd = stream->readByte(); - _masterIndex = stream->readByte(); - stream->readByte(); // To align the next byte... - - _creationTime = stream->readUint32LE(); - - stream->read(_desc, 100); - _numDirs = stream->readUint32LE(); - } + // base_package.cpp: + void readFromStream(Common::ReadStream *stream); }; /* diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 917a76be85..b41df5f1e2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -94,8 +94,6 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { return new BaseRenderOSystem(inGame); } -// TODO: Redo everything here. - ////////////////////////////////////////////////////////////////////////// BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index aa9cc8474a..5e6347fdef 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -57,7 +57,6 @@ BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { ////////////////////////////////////////////////////////////////////////// BaseSurfaceOSystem::~BaseSurfaceOSystem() { - //TODO if (_surface) { _surface->free(); delete _surface; @@ -385,8 +384,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo Common::Rect position; position.left = x + offsetX; position.top = y + offsetY; - // TODO: Scaling... + // Crop off-by-ones: if (position.left == -1) { position.left = 0; // TODO: Something is wrong } diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 92ffcf3154..011b64aff3 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -124,7 +124,7 @@ public: } // Prefix to avoid collisions with actually known games name = "wmefan-" + name; - strncpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); + strncpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); s_fallbackDesc.gameid = s_fallbackGameIdBuf; if (caption != name) { caption += " (fangame) "; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 6468f02524..ada645c972 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -410,7 +410,7 @@ bool VideoTheoraPlayer::writeVideo() { return STATUS_OK; } -void VideoTheoraPlayer::writeAlpha() { +void VideoTheoraPlayer::writeAlpha() { // TODO: Endian-fix. if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); -- cgit v1.2.3 From efee8c01ceded526406a3ad6ffc2dc1c078c2ce2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 03:11:26 +0200 Subject: WINTERMUTE: Fix loading from launcher. --- engines/wintermute/wintermute.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 21ee65b832..8bf83cc0f6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -262,8 +262,7 @@ int WinterMuteEngine::init() { if (ConfMan.hasKey("save_slot")) { int slot = ConfMan.getInt("save_slot"); - Common::String str = Common::String::format("save00%d.DirtySplitSav", slot); - _game->loadGame(str.c_str()); + _game->loadGame(slot); } if (saveGame) { -- cgit v1.2.3 From b3b86c440cb2a13a43ce6dd3102bf85f4211795b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 15:55:06 +0200 Subject: WINTERMUTE: Clear out a few warning()s --- engines/wintermute/base/base_file_manager.cpp | 4 ++-- engines/wintermute/base/base_persistence_manager.cpp | 3 +-- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 9 ++++++--- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 12 +----------- engines/wintermute/base/sound/base_sound.h | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 7 +++---- engines/wintermute/persistent.cpp | 1 - 7 files changed, 13 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 94f561997e..1c58da2be9 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -212,7 +212,7 @@ bool BaseFileManager::registerPackages() { // and that has to be like that to support the detection-scheme. Common::FSList files; for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().hasSuffix(".dcp")) { @@ -227,7 +227,7 @@ bool BaseFileManager::registerPackages() { continue; } } - warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); } } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bc751e6aed..995b996b33 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -127,7 +127,7 @@ Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + debugC(kWinterMuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); return; @@ -172,7 +172,6 @@ uint32 BasePersistenceManager::getMaxUsedSlot() { bool BasePersistenceManager::getSaveExists(int slot) { Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { return false; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index b41df5f1e2..00ef2ec95c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -258,8 +258,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - warning("Implement BaseRenderOSystem::FadeToColor"); // TODO. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + } hasWarned = true; } @@ -489,7 +490,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { - warning("BaseRenderOSystem::DrawLine - not fully ported yet"); + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); + } hasWarned = true; } byte r = RGBCOLGetR(color); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5e6347fdef..5102d182f9 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -348,14 +348,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo alpha = renderer->_forceAlphaColor; } - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. - hasWarned = true; - } - byte r = RGBCOLGetR(alpha); byte g = RGBCOLGetG(alpha); byte b = RGBCOLGetB(alpha); @@ -363,10 +355,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); -#if 0 - SDL_SetTextureColorMod(_texture, r, g, b); - SDL_SetTextureAlphaMod(_texture, a); +#if 0 // These are kept for reference if BlendMode is reimplemented at some point. if (alphaDisable) { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); } else { diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index bb37e55388..7ea9f38f6c 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -80,7 +80,6 @@ private: float _sFXParam3; float _sFXParam4; BaseSoundBuffer *_sound; - }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 34aee36f1b..aa03609177 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -134,9 +134,6 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::play(bool looping, uint32 startSample) { - if (startSample != 0) { - warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); - } if (_handle) { g_system->getMixer()->stopHandle(*_handle); delete _handle; @@ -269,12 +266,14 @@ bool BaseSoundBuffer::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("BaseSoundBuffer::ApplyFX - not implemented yet"); + // This function was already stubbed out in WME Lite, and thus isn't reimplemented here either. switch (type) { case SFX_ECHO: + //warning("BaseSoundBuffer::ApplyFX(SFX_ECHO, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); break; case SFX_REVERB: + //warning("BaseSoundBuffer::ApplyFX(SFX_REVERB, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); break; default: diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index 76d73911b2..fc1531ab9b 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -163,7 +163,6 @@ void SystemClassRegistry::registerClasses() { REGISTER_CLASS(UITiledImage, false) REGISTER_CLASS(UIWindow, false) REGISTER_CLASS(VideoTheoraPlayer, false) - warning("TODO: Clean this up at some proper time"); } } -- cgit v1.2.3 From df5943ae59350b37e6f811ec2e9a968d0660fcab Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 15:59:58 +0200 Subject: WINTERMUTE: Start sounds again after loading a save. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 15 +++++++++++++-- engines/wintermute/base/sound/base_sound_buffer.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index aa03609177..25be117db2 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -63,6 +63,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { _looping = false; _loopStart = 0; + _startPos = 0; _type = Audio::Mixer::kSFXSoundType; @@ -155,14 +156,21 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO + if (isPlaying()) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO + } _looping = looping; } ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::resume() { + // If the sound was paused while active: if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); + } else if (_stream) { // Otherwise we come from a savegame, and thus have no handle + play(_looping, _startPos); + } else { + warning("BaseSoundBuffer::resume - Called without a handle or a stream"); } return STATUS_OK; } @@ -246,7 +254,10 @@ uint32 BaseSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPosition(uint32 pos) { - warning("BaseSoundBuffer::SetPosition - not implemented yet"); + if (isPlaying()) { + warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); + } + _startPos = pos; return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index c32f83eb1e..107ceb87d7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -88,6 +88,7 @@ public: int _privateVolume; private: + uint32 _startPos; char *_filename; bool _streamed; Common::SeekableReadStream *_file; -- cgit v1.2.3 From 3ff2e2cc936dce22b74699c30a160389c4f50447 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:01:03 +0200 Subject: WINTERMUTE: Support the SPACE-key as a printable character. --- engines/wintermute/base/base_keyboard_state.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 3bad8f6012..2b77cb23ca 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -204,7 +204,8 @@ bool BaseKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0) || + (_currentCharCode == Common::KEYCODE_SPACE)) { _currentPrintable = true; } else { _currentPrintable = false; -- cgit v1.2.3 From 996e79b3d5e5d336080017a800e50be6a9a33d15 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:04:37 +0200 Subject: WINTERMUTE: Fix SaveGame-thumb loading/saving. --- engines/wintermute/base/base_file_manager.cpp | 15 +++++++++++---- engines/wintermute/base/base_game.cpp | 14 ++++---------- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1c58da2be9..f1320b814b 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -267,6 +267,13 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } bool BaseFileManager::hasFile(const Common::String &filename) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + BasePersistenceManager pm(_gameRef); + if (filename.size() < 9) + return false; + int slot = atoi(filename.c_str() + 9); + return pm.getSaveExists(slot); + } if (diskFileExists(filename)) { return true; } @@ -315,11 +322,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f if (!_gameRef) { error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); } - BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef); + if (DID_SUCCEED(saveThumbFile->open(filename))) { + ret = saveThumbFile->getMemStream(); } - delete SaveThumbFile; + delete saveThumbFile; return ret; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index cb53d37c2d..8fd2b193b1 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4001,8 +4001,6 @@ void BaseGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String filename = pm->getFilenameForSlot(slot); delete pm; @@ -4046,14 +4044,10 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - - warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!file) { - return false; - } - delete file; - return true; + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + bool ret = pm->getSaveExists(slot); + delete pm; + return ret; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index b29935d943..e067241589 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -52,8 +52,6 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::open(const Common::String &filename) { close(); - warning("SaveGame-thumbs disabled for now"); - return STATUS_FAILED; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { return STATUS_FAILED; -- cgit v1.2.3 From a190bb8fdc5959bb2b529baab0d45bc31d2f467a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:07:50 +0200 Subject: WINTERMUTE: Add a stubbed fallback for the absolute path used in East Side Story C:\\windows\\fonts\\framd.ttf --- engines/wintermute/base/file/base_disk_file.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 7d805aedb5..93533b4057 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -52,9 +52,10 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) - // Absolute path: TODO: Add specific fallbacks here. + // Absolute path: These should have been handled in openDiskFile. if (filename.contains(':')) { - error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + // So just return an invalid node. + return Common::FSNode(); } // Relative path: @@ -112,9 +113,19 @@ bool diskFileExists(const Common::String &filename) { Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; + Common::String fixedFilename = filename; + + // Absolute path: TODO: Add specific fallbacks here. + if (filename.contains(':')) { + if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" + fixedFilename = filename.c_str() + 17; + } else { + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + } + } // Try directly from SearchMan first Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, filename); + SearchMan.listMatchingMembers(files, fixedFilename); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { -- cgit v1.2.3 From a9e9ed7d3b5411e5eaf44ac87f1a10ce53e962d9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:08:46 +0200 Subject: WINTERMUTE: Formatting "var_name"->"varName" --- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 34ff717ae5..1f938dfac2 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -53,7 +53,7 @@ BaseFont::~BaseFont() { ////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9431c730bd..152e08273d 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -69,8 +69,8 @@ BaseFontBitmap::~BaseFontBitmap() { ////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); } -- cgit v1.2.3 From 6262a2ac8751b1bfff7becc8cf181ab9dd16bf87 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 17:43:17 +0200 Subject: WINTERMUTE: Use an arbitrary size nearest neighbour scaler for save thumbnails. Thanks to clone2727 --- engines/wintermute/base/gfx/base_image.cpp | 16 ++--------- .../wintermute/graphics/transparent_surface.cpp | 33 ++++++++++++++++++++-- engines/wintermute/graphics/transparent_surface.h | 3 ++ 3 files changed, 36 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 628bffff55..3aa21d0f7f 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -224,27 +224,15 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { -#if 0 - if (_bitmap) { - FreeImage_Unload(_bitmap); - } - - if (NewWidth == 0) { - NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - } - if (NewHeight == 0) { - NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - } + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); -#endif TransparentSurface temp(*origImage->_surface, false); if (_deletableSurface) { _deletableSurface->free(); delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scale(newWidth, newHeight); + _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); return true; } diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 65bdbcf5a1..59010d5ed3 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -342,10 +342,39 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } +TransparentSurface *TransparentSurface::scaleSafe(uint16 newWidth, uint16 newHeight) const { + Common::Rect srcRect(0, 0, (int16)w, (int16)h); + Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight); + return scaleSafe(srcRect, dstRect); +} + +// Copied from clone2727's https://github.com/clone2727/scummvm/blob/pegasus/engines/pegasus/surface.cpp#L247 +TransparentSurface *TransparentSurface::scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const { + // I'm doing simple linear scaling here + // dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH); + TransparentSurface *target = new TransparentSurface(); + + int srcW = srcRect.width(); + int srcH = srcRect.height(); + int dstW = dstRect.width(); + int dstH = dstRect.height(); + + target->create((uint16)dstW, (uint16)dstH, this->format); + + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + uint32 color = READ_UINT32((byte *)getBasePtr(x * srcW / dstW + srcRect.left, + y * srcH / dstH + srcRect.top)); + WRITE_UINT32((byte *)target->getBasePtr(x + dstRect.left, y + dstRect.top), color); + } + } + return target; + +} /** * Scales a passed surface, creating a new surface with the result - * @param srcImage Source image to scale - * @param scaleFactor Scale amount. Must be between 0 and 1.0 (but not zero) + * @param xSize target width. + * @param ySize target height. * @remarks Caller is responsible for freeing the returned surface */ TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index e271bf2488..79637037db 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -101,6 +101,9 @@ struct TransparentSurface : public Graphics::Surface { int width = -1, int height = -1); void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); TransparentSurface *scale(int xSize, int ySize) const; + // The following scale-code supports arbitrary scaling (i.e. no repeats of column 0 at the end of lines) + TransparentSurface *scaleSafe(uint16 newWidth, uint16 newHeight) const; + TransparentSurface *scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const; private: static int *scaleLine(int size, int srcSize); }; -- cgit v1.2.3 From f6ac34ab9a48b702e3c3678cfd208ebeb2517dc4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 18:13:42 +0200 Subject: WINTERMUTE: Get rid of almost all LLVM GCC 4.2 warnings. --- engines/wintermute/ad/ad_node_state.cpp | 2 +- engines/wintermute/ad/ad_node_state.h | 2 +- engines/wintermute/base/base_file_manager.cpp | 4 ++-- engines/wintermute/base/base_persistence_manager.cpp | 8 ++++---- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- engines/wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_file.cpp | 6 +++--- engines/wintermute/base/sound/base_sound.cpp | 3 ++- engines/wintermute/detection.cpp | 4 ++-- engines/wintermute/ui/ui_object.cpp | 2 +- engines/wintermute/utils/crc.cpp | 3 +++ engines/wintermute/utils/crc.h | 12 ++++++++---- engines/wintermute/utils/path_util.cpp | 2 +- 15 files changed, 32 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 5a58dba5b1..270a114277 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -128,7 +128,7 @@ void AdNodeState::setCaption(const char *caption, int caseVal) { ////////////////////////////////////////////////////////////////////////// -char *AdNodeState::getCaption(int caseVal) { +const char *AdNodeState::getCaption(int caseVal) { if (caseVal == 0) { caseVal = 1; } diff --git a/engines/wintermute/ad/ad_node_state.h b/engines/wintermute/ad/ad_node_state.h index 64ecab6849..ce15bc893f 100644 --- a/engines/wintermute/ad/ad_node_state.h +++ b/engines/wintermute/ad/ad_node_state.h @@ -48,7 +48,7 @@ private: char *_name; char *_caption[7]; void setCaption(const char *caption, int caseVal); - char *getCaption(int caseVal); + const char *getCaption(int caseVal); uint32 _alphaColor; char *_filename; char *_cursor; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f1320b814b..5bad96d65e 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -253,8 +253,8 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f strcpy(fileName, upcName.c_str()); // correct slashes - for (int32 i = 0; i < upcName.size(); i++) { - if (upcName[i] == '/') { + for (uint32 i = 0; i < upcName.size(); i++) { + if (upcName[(int32)i] == '/') { upcName.setChar('\\', (uint32)i); } } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 995b996b33..ce7c66b7dd 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -492,7 +492,7 @@ float BasePersistenceManager::getFloat() { } void BasePersistenceManager::putDouble(double val) { - Common::String str = Common::String::format("F%f", val); + Common::String str = Common::String::format("D%f", val); str.format("D%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); @@ -500,10 +500,10 @@ void BasePersistenceManager::putDouble(double val) { double BasePersistenceManager::getDouble() { char *str = getString(); - double value = 0.0f; - int ret = sscanf(str, "F%f", &value); + float value = 0.0f; // TODO: Do we ever really need to carry a full double-precision number? + int ret = sscanf(str, "D%f", &value); if (ret != 1) { - warning("%s not parsed as float", str); + warning("%s not parsed as double", str); } delete[] str; return value; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 3d878b1346..689066eb6e 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -73,7 +73,7 @@ bool BaseSurfaceStorage::initLoop() { break; } - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + if (_surfaces[i]->_lifeTime > 0 && (int)(_surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 152e08273d..ed7c13a54d 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -174,7 +174,7 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli longLine = true; } - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { done = true; if (!newLine) { end = index; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 168aa75d91..3a29bf542d 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,7 +111,7 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// void BaseRenderer::deleteRectList() { - for (int i = 0; i < _rectList.size(); i++) { + for (uint32 i = 0; i < _rectList.size(); i++) { delete _rectList[i]; } _rectList.clear(); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 27dbe9999c..0c0ec08ba9 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -199,7 +199,7 @@ bool PartParticle::display(PartEmitter *emitter) { } _sprite->getCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, + return _sprite->display((int)_pos.x, (int)_pos.y, NULL, _scale, _scale, BYTETORGBA(255, 255, 255, _currentAlpha), diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 4eeabca04d..9736ae3ee2 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -211,8 +211,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { stack->correctParams(2); - const char *dest = stack->pop()->getString(); - bool overwrite = stack->pop()->getBool(true); + /* const char *dest = */ stack->pop()->getString(); + /* bool overwrite = */ stack->pop()->getBool(true); close(); error("SXFile-Method: Copy not supported"); @@ -601,7 +601,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "WriteDouble") == 0) { error("SXFile::WriteDouble - Not endian safe yet"); stack->correctParams(1); - double val = stack->pop()->getFloat(); + /* double val = */ stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 9bea6be770..8a139ead4f 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -268,7 +268,8 @@ bool BaseSound::setPrivateVolume(int volume) { if (!_sound) { return STATUS_FAILED; } else { - return _sound->_privateVolume = volume; + _sound->_privateVolume = volume; + return STATUS_OK; } } diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 011b64aff3..58b6c5df90 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -116,9 +116,9 @@ public: if (allFiles.contains("data.dcp")) { Common::String name, caption; if (WinterMuteEngine::getGameInfo(fslist, name, caption)) { - for (int32 i = 0; i < name.size(); i++) { + for (uint32 i = 0; i < name.size(); i++) { // Replace spaces (and other non-alphanumerics) with underscores - if (!Common::isAlnum(name[i])) { + if (!Common::isAlnum(name[(int32)i])) { name.setChar('_', (uint32)i); } } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 9fe9cd18e4..d1a13200c8 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -102,7 +102,7 @@ void UIObject::setText(const char *text) { _text = new char [strlen(text) + 1]; if (_text) { strcpy(_text, text); - for (int i = 0; i < strlen(_text); i++) { + for (uint32 i = 0; i < strlen(_text); i++) { if (_text[i] == '|') { _text[i] = '\n'; } diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp index 933857e066..c127d08417 100644 --- a/engines/wintermute/utils/crc.cpp +++ b/engines/wintermute/utils/crc.cpp @@ -17,6 +17,7 @@ #include "engines/wintermute/utils/crc.h" +namespace WinterMute { /* * Derive parameters from the standard-specific parameters in crc.h. @@ -232,3 +233,5 @@ crc crc_process_byte(unsigned char byteVal, crc remainder) { crc crc_finalize(crc remainder) { return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); } + +} // end of namespace WinterMute diff --git a/engines/wintermute/utils/crc.h b/engines/wintermute/utils/crc.h index cf7ea1a00c..363340531d 100644 --- a/engines/wintermute/utils/crc.h +++ b/engines/wintermute/utils/crc.h @@ -16,6 +16,10 @@ #ifndef _crc_h #define _crc_h +#include "common/system.h" // For types. + +namespace WinterMute { + #ifndef TRUE #define FALSE 0 #define TRUE !FALSE @@ -26,10 +30,9 @@ */ #define CRC32 - #if defined(CRC_CCITT) -typedef unsigned short crc; +typedef uint16 crc; #define CRC_NAME "CRC-CCITT" #define POLYNOMIAL 0x1021 @@ -41,7 +44,7 @@ typedef unsigned short crc; #elif defined(CRC16) -typedef unsigned short crc; +typedef uint16 crc; #define CRC_NAME "CRC-16" #define POLYNOMIAL 0x8005 @@ -53,7 +56,7 @@ typedef unsigned short crc; #elif defined(CRC32) -typedef unsigned long crc; +typedef uint32 crc; #define CRC_NAME "CRC-32" #define POLYNOMIAL 0x04C11DB7 @@ -77,5 +80,6 @@ extern "C" crc crc_initialize(void); extern "C" crc crc_process_byte(unsigned char byteVal, crc remainder); extern "C" crc crc_finalize(crc remainder); +} // End of namespace WinterMute #endif /* _crc_h */ diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 51f0f5817e..2fbe785a38 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -97,7 +97,7 @@ AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! // TODO: Prettify this. AnsiString extension = Common::lastPathComponent(fileName, '.'); - for (int i = 0; i < extension.size() + 1; i++) { + for (uint32 i = 0; i < extension.size() + 1; i++) { fileName.deleteLastChar(); } // Common::String filename = Common::String(fileName.c_str(), fileName.size() - extension.size() + 1); -- cgit v1.2.3 From fbc19f3f0b4345d5e2db3416ed3de79593bcef36 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 18:24:00 +0200 Subject: WINTERMUTE: Fix a Clang-warning --- engines/wintermute/utils/utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 3050a36263..05aa34f95f 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -204,12 +204,13 @@ bool BaseUtils::matchesPattern(const char *pattern, const char *string) { return false; default: - if (patternc != stringc) + if (patternc != stringc) { if (patternc == '.' && stringc == 0) { return(BaseUtils::matchesPattern(pattern, string)); } else { return false; } + } break; } } -- cgit v1.2.3 From a4e2fb4504f0a7ba42521f7cd4c95c997adf96f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 18:24:22 +0200 Subject: WINTERMUTE: Move TinyXML into the WinterMute-namespace. --- engines/wintermute/tinyxml/tinystr.cpp | 4 ++++ engines/wintermute/tinyxml/tinystr.h | 4 ++++ engines/wintermute/tinyxml/tinyxml.cpp | 4 ++++ engines/wintermute/tinyxml/tinyxml.h | 6 ++++++ engines/wintermute/tinyxml/tinyxmlerror.cpp | 6 ++++++ engines/wintermute/tinyxml/tinyxmlparser.cpp | 5 +++++ 6 files changed, 29 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/tinyxml/tinystr.cpp b/engines/wintermute/tinyxml/tinystr.cpp index 0665768205..81152d9017 100644 --- a/engines/wintermute/tinyxml/tinystr.cpp +++ b/engines/wintermute/tinyxml/tinystr.cpp @@ -21,11 +21,14 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for use in ScummVM (namespace added) #ifndef TIXML_USE_STL #include "tinystr.h" +namespace WinterMute { + // Error value for find primitive const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); @@ -107,5 +110,6 @@ TiXmlString operator + (const char* a, const TiXmlString & b) return tmp; } +} // end of namespace WinterMute #endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinystr.h b/engines/wintermute/tinyxml/tinystr.h index 89cca33415..7f35f52864 100644 --- a/engines/wintermute/tinyxml/tinystr.h +++ b/engines/wintermute/tinyxml/tinystr.h @@ -21,6 +21,7 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for use in ScummVM (namespace added) #ifndef TIXML_USE_STL @@ -44,6 +45,7 @@ distribution. #define TIXML_EXPLICIT #endif +namespace WinterMute { /* TiXmlString is an emulation of a subset of the std::string template. @@ -301,5 +303,7 @@ public : } ; +} // end of namespace WinterMute + #endif // TIXML_STRING_INCLUDED #endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinyxml.cpp b/engines/wintermute/tinyxml/tinyxml.cpp index e4a0c2780f..2ab6880a56 100644 --- a/engines/wintermute/tinyxml/tinyxml.cpp +++ b/engines/wintermute/tinyxml/tinyxml.cpp @@ -22,6 +22,8 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for use in ScummVM (namespace added) + #include #ifdef TIXML_USE_STL @@ -31,6 +33,7 @@ distribution. #include "engines/wintermute/tinyxml/tinyxml.h" +namespace WinterMute { bool TiXmlBase::condenseWhiteSpace = true; @@ -1886,3 +1889,4 @@ bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) return true; } +} // end of namespace WinterMute diff --git a/engines/wintermute/tinyxml/tinyxml.h b/engines/wintermute/tinyxml/tinyxml.h index afb07cfbed..a32e145587 100644 --- a/engines/wintermute/tinyxml/tinyxml.h +++ b/engines/wintermute/tinyxml/tinyxml.h @@ -22,6 +22,8 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for ScummVM (namespace added) + #undef TIXML_USE_STL #ifndef TINYXML_INCLUDED @@ -83,6 +85,8 @@ distribution. #endif #endif +namespace WinterMute { + class TiXmlDocument; class TiXmlElement; class TiXmlComment; @@ -1799,5 +1803,7 @@ private: #pragma warning( pop ) #endif +} // end of namespace WinterMute + #endif diff --git a/engines/wintermute/tinyxml/tinyxmlerror.cpp b/engines/wintermute/tinyxml/tinyxmlerror.cpp index d24f63b2e5..ccfe4a039e 100644 --- a/engines/wintermute/tinyxml/tinyxmlerror.cpp +++ b/engines/wintermute/tinyxml/tinyxmlerror.cpp @@ -22,6 +22,8 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for use in ScummVM (namespace added) + #include "tinyxml.h" // The goal of the seperate error file is to make the first @@ -31,6 +33,8 @@ distribution. // It also cleans up the code a bit. // +namespace WinterMute { + const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = { "No error", @@ -51,3 +55,5 @@ const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = "Error parsing CDATA.", "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", }; + +} // end of namespace WinterMute diff --git a/engines/wintermute/tinyxml/tinyxmlparser.cpp b/engines/wintermute/tinyxml/tinyxmlparser.cpp index 14fd7c8c79..709dee0320 100644 --- a/engines/wintermute/tinyxml/tinyxmlparser.cpp +++ b/engines/wintermute/tinyxml/tinyxmlparser.cpp @@ -22,6 +22,8 @@ must not be misrepresented as being the original software. distribution. */ +// Modified for use in ScummVM (namespace added) + #include #include @@ -37,6 +39,8 @@ distribution. # endif #endif +namespace WinterMute { + // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries // or order will break putstring. @@ -1636,3 +1640,4 @@ bool TiXmlText::Blank() const return true; } +} // end of namespace WinterMute -- cgit v1.2.3 From 99d4c55e88712a0b0dc0d97e4c9c52946a5f48f2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:07:00 +0200 Subject: WINTERMUTE: Remove all unneccessary #if 0 blocks --- .../wintermute/base/font/base_font_truetype.cpp | 164 +------- engines/wintermute/base/gfx/base_image.cpp | 25 +- engines/wintermute/base/gfx/base_renderer.h | 1 + .../base/gfx/osystem/base_render_osystem.cpp | 114 +----- .../base/gfx/osystem/base_render_osystem.h | 2 +- .../base/scriptables/script_ext_date.cpp | 4 +- .../wintermute/base/scriptables/script_value.cpp | 4 - engines/wintermute/platform_osystem.cpp | 4 +- engines/wintermute/utils/path_util.cpp | 33 +- engines/wintermute/video/video_player.cpp | 431 +-------------------- engines/wintermute/video/video_player.h | 1 + engines/wintermute/video/video_theora_player.cpp | 153 +------- 12 files changed, 51 insertions(+), 885 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index c643a5e1b1..638b939ec1 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -256,12 +256,6 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, } else if (align == TAL_RIGHT) { alignment = Graphics::kTextAlignRight; } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("BaseFontTT::RenderTextToTexture - Not fully ported yet"); - } debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; @@ -287,104 +281,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, delete surface; delete convertedSurface; return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) { - continue; - } - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) { - continue; - } - - float kerning = 0; - if (prevChar != L'\0') { - kerning = GetKerning(prevChar, ch); - } - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - BaseSurfaceOSystem *wmeSurface = new BaseSurfaceOSystem(_gameRef); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; + // TODO: _isUnderline, _isBold, _isItalic, _isStriked } @@ -666,65 +563,6 @@ bool BaseFontTT::initFont() { } _lineHeight = _font->getFontHeight(); return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = BaseFontTT::FTReadSeekProc; - _fTStream->close = BaseFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - _gameRef->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float emsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 3aa21d0f7f..1fff59d85b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -114,23 +114,16 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { - warning("BaseImage::resize(%d, %d), stubbed", newWidth, newHeight); -#if 0 - if (!_bitmap) { - return STATUS_FAILED; - } - - if (newWidth == 0) { - NewWidth = FreeImage_GetWidth(_bitmap); - } - if (newHeight == 0) { - NewHeight = FreeImage_GetHeight(_bitmap); + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + TransparentSurface temp(*_surface, true); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; } - - - FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); -#endif - return false; + _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + temp.free(); + return true; } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 83b5ad0e16..008db69713 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -62,6 +62,7 @@ public: virtual BaseImage *takeScreenshot() = 0; virtual bool setViewport(int left, int top, int right, int bottom); virtual bool setViewport(Rect32 *rect); + virtual Rect32 getViewPort() = 0; virtual bool setScreenViewport(); virtual Graphics::PixelFormat getPixelFormat() const = 0; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 00ef2ec95c..90dda1af72 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -231,8 +231,6 @@ bool BaseRenderOSystem::flip() { ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { - //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); - //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); if (!_disableDirtyRects) { return STATUS_OK; @@ -240,6 +238,7 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { if (!rect) { rect = &_renderRect; } + // TODO: This doesn't work with dirty rects _renderSurface->fillRect(*rect, _clearColor); return STATUS_OK; @@ -410,7 +409,6 @@ void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { _dirtyRect->extend(rect); } _dirtyRect->clip(_renderRect); -// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); } void BaseRenderOSystem::drawTickets() { @@ -421,7 +419,6 @@ void BaseRenderOSystem::drawTickets() { if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); - //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); delete ticket; decrement++; @@ -436,7 +433,6 @@ void BaseRenderOSystem::drawTickets() { // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; -// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); @@ -521,38 +517,11 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { ////////////////////////////////////////////////////////////////////////// BaseImage *BaseRenderOSystem::takeScreenshot() { -// TODO: Fix this +// TODO: Clip by viewport. warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); screenshot->copyFrom(_renderSurface); return screenshot; -#if 0 - SDL_Rect viewport; - - SDL_RenderGetViewport(_renderer, &viewport); - - SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) { - return NULL; - } - - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { - return NULL; - } - - FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - - int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; - memcpy(bits, src, bytespp * viewport.w); - } - - return new BaseImage(_gameRef, dib); -#endif - return NULL; } ////////////////////////////////////////////////////////////////////////// @@ -569,84 +538,43 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { rect.right = (int16)((right - left) * _ratioX); rect.bottom = (int16)((bottom - top) * _ratioY); + _renderRect = rect; return STATUS_OK; } +Rect32 BaseRenderOSystem::getViewPort() { + Rect32 ret; + ret.top = _renderRect.top; + ret.bottom = _renderRect.bottom; + ret.left = _renderRect.left; + ret.right = _renderRect.right; + return ret; +} + ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * _ratioX); - rect->h = MathUtil::RoundUp(rect->h * _ratioY); -#endif + rect->left = MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); + rect->top = MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); + rect->setWidth(MathUtil::roundUp(rect->width() * _ratioX)); + rect->setHeight(MathUtil::roundUp(rect->height() * _ratioY)); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointFromScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; - point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; -#endif + point->x = point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left; + point->y = point->y / _ratioY - _borderTop / _ratioY + _renderRect.top; } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointToScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; -#endif + point->x = MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::dumpData(const char *filename) { - warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO -#if 0 - FILE *f = fopen(filename, "wt"); - if (!f) { - return; - } - - BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - - int totalKB = 0; - int totalLoss = 0; - fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; - if (!Surf->_filename) { - continue; - } - if (!Surf->_valid) { - continue; - } - - fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); - - int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; - - TotalKB += kb; - fprintf(f, "%d;", kb); - fprintf(f, "\n"); - } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); - - - fclose(f); - _gameRef->LOG(0, "Texture Stats Dump completed."); - _gameRef->QuickMessage("Texture Stats Dump completed."); -#endif + warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO } BaseSurface *BaseRenderOSystem::createSurface() { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 0d00b1b427..dfffc68c17 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -82,7 +82,7 @@ public: void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); - + Rect32 getViewPort(); void modTargetRect(Common::Rect *rect); void pointFromScreen(Point32 *point); void pointToScreen(Point32 *point); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index a3bb7e2183..181be8ddd0 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -68,9 +68,7 @@ const char *SXDate::scToString() { // TODO: Make this more stringy, and less ISO 8601-like _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); return _strRep.c_str(); -#if 0 - return asctime(&_tm); -#endif + //return asctime(&_tm); } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 01cb4044ff..9b83daf42f 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -166,11 +166,7 @@ ScValue *ScValue::getProp(const char *name) { if (_type == VAL_STRING && strcmp(name, "Length") == 0) { _gameRef->_scValue->_type = VAL_INT; -#if 0 // TODO: Remove FreeType-dependency if (_gameRef->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif _gameRef->_scValue->setInt(strlen(_valString)); } else { WideString wstr = StringUtil::utf8ToWide(_valString); diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index c7d0c6cfed..32d53e3a50 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -179,8 +179,8 @@ bool BasePlatform::setCursorPos(int x, int y) { p.x = x; p.y = y; renderer->pointToScreen(&p); -// TODO - //SDL_WarpMouseInWindow(renderer->GetSdlWindow(), p.x, p.y); + + g_system->warpMouse(x, y); return true; } diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 2fbe785a38..4e36c3e316 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -163,40 +163,9 @@ bool PathUtil::fileExists(const AnsiString &fileName) { ////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getUserDirectory() { +AnsiString PathUtil::getUserDirectory() { // TODO: Get rid of warning("PathUtil::GetUserDirectory - stubbed"); AnsiString userDir = "./"; -#if 0 -#ifdef __WIN32__ - char buffer[MAX_PATH_LENGTH]; - buffer[0] = '\0'; - LPITEMIDLIST pidl = NULL; - LPMALLOC pMalloc; - if (DID_SUCCEED(SHGetMalloc(&pMalloc))) { - SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - if (pidl) { - SHGetPathFromIDList(pidl, buffer); - } - pMalloc->Free(pidl); - userDir = AnsiString(buffer); - } -#elif __MACOSX__ - FSRef fileRef; - OSStatus error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); - if (error == noErr) { - char buffer[MAX_PATH_LENGTH]; - error = FSRefMakePath(&fileRef, (UInt8 *)buffer, sizeof(buffer)); - if (error == noErr) { - userDir = buffer; - } - - } -#elif __IPHONEOS__ - char path[MAX_PATH_LENGTH]; - IOS_GetDataDir(path); - userDir = AnsiString(path); -#endif -#endif // 0 return userDir; } diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index a4c81d12b5..d0b4019621 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -29,8 +29,6 @@ #include "engines/wintermute/video/video_player.h" -//#pragma comment(lib, "vfw32.lib") - namespace WinterMute { ////////////////////////////////////////////////////////////////////// @@ -42,33 +40,13 @@ VideoPlayer::VideoPlayer(BaseGame *inGame): BaseClass(inGame) { setDefaults(); } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::setDefaults() { _playing = false; - - /* _aviFile = NULL; - - _audioStream = NULL; - _audioFormat = NULL; - - _videoStream = NULL; - _videoFormat = NULL; - _videoPGF = NULL;*/ _videoEndTime = 0; - - //_sound = NULL; _soundAvailable = false; - - //_vidRenderer = NULL; - _startTime = 0; _totalVideoTime = 0; - - //_lastSample = -1; - - //_targetFormat = NULL; - _playPosX = _playPosY = 0; _playZoom = 0.0f; @@ -82,450 +60,49 @@ bool VideoPlayer::setDefaults() { return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// VideoPlayer::~VideoPlayer() { cleanup(); } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::cleanup() { -#if 0 - if (_sound) { - _sound->Stop(); - } - if (_videoPGF) { - AVIStreamGetFrameClose(_videoPGF); - } - _videoPGF = NULL; - - _playing = false; - - - if (_aviFile) { - AVIFileRelease(m_AviFile); - } - - if (_audioStream) { - AVIStreamRelease(m_AudioStream); - } - if (_videoStream) { - AVIStreamRelease(m_VideoStream); - } - - if (_audioFormat) { - delete[](byte *)m_AudioFormat; - } - if (_videoFormat) { - delete[](byte *)m_VideoFormat; - } - if (_targetFormat) { - delete[](byte *)m_TargetFormat; - } - - SAFE_DELETE(_sound); - SAFE_DELETE(_vidRenderer); - - SAFE_DELETE_ARRAY(_filename); - - for (int i = 0; i < _subtitles.getSize(); i++) { - delete _subtitles[i]; - } - _subtitles.clear(); - - return SetDefaults(); -#endif return 0; } - ////////////////////////////////////////////////////////////////////////// -bool VideoPlayer::initialize(const char *inFilename, const char *SubtitleFile) { -#if 0 - cleanup(); - - char filename[MAX_PATH_LENGTH]; - _gameRef->_fileManager->GetFullPath(inFilename, filename); - - // open file - if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - _gameRef->LOG(0, "Error opening AVI file '%s'", filename); - return STATUS_FAILED; - } - - // get video stream - if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - _gameRef->LOG(0, "Error finding video stream in AVI file '%s'", filename); - return STATUS_FAILED; - } - _totalVideoTime = AVIStreamEndTime(_videoStream); - - // get audio stream - if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) { - _soundAvailable = true; - } else { - _soundAvailable = false; - } - - - LONG Size; - - // get video format - if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - _gameRef->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); - return STATUS_FAILED; - } - _videoFormat = (LPBITMAPINFO)new BYTE[Size]; - AVIStreamReadFormat(m_VideoStream, 0, m_VideoFormat, &Size); - - // initialize optimal target format - m_TargetFormat = (LPBITMAPV4HEADER)new BYTE[max(Size, sizeof(BITMAPV4HEADER))]; - memset(m_TargetFormat, 0, sizeof(BITMAPV4HEADER)); - memcpy(m_TargetFormat, m_VideoFormat, Size); - m_TargetFormat->bV4Size = max(Size, sizeof(BITMAPV4HEADER)); - - m_TargetFormat->bV4BitCount = 24; - m_TargetFormat->bV4V4Compression = BI_RGB; - - if (_gameRef->m_UseD3D) { - m_VidRenderer = new CVidRendererD3D(_gameRef); - } else { - m_VidRenderer = new CVidRendererDD(_gameRef); - } - - if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); - SAFE_DELETE(m_VidRenderer); - return STATUS_FAILED; - } - - - // create sound buffer - bool res; - - if (_soundAvailable) { - _sound = new BaseSoundAVI(_gameRef); - if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { - SAFE_DELETE(_sound); - _soundAvailable = false; - _gameRef->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); - } - } - - if (_gameRef->_videoSubtitles) { - LoadSubtitles(inFilename, SubtitleFile); - } - - _filename = new char[strlen(filename) + 1]; - if (_filename) { - strcpy(_filename, filename); - } -#endif +bool VideoPlayer::initialize(const char *inFilename, const char *subtitleFile) { + warning("VideoPlayer: %s %s - Not implemented yet", inFilename, subtitleFile); return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::update() { -#if 0 - if (!m_Playing) { - return STATUS_OK; - } - - bool res; - - if (_soundAvailable && m_Sound) { - res = _sound->update(); - if (DID_FAIL(res)) { - return res; - } - } - - - DWORD CurrentTime; // current playing time (in ms) - /* - if (m_SoundAvailable && m_Sound){ - CurrentTime = m_Sound->GetPosition(); // in samples - CurrentTime /= (m_Sound->m_Format.wf.nSamplesPerSec / 1000); - - if (!m_Sound->IsPlaying()) CurrentTime = m_TotalVideoTime; - } - else - CurrentTime = timeGetTime() - m_StartTime; - */ - CurrentTime = timeGetTime() - _startTime; - - if (CurrentTime >= _totalVideoTime) { - Stop(); - return STATUS_OK; - } - - - // get and render frame - DWORD sample = AVIStreamTimeToSample(_videoStream, CurrentTime); - if (sample != _lastSample) { - _lastSample = sample; - - // process subtitles - _showSubtitle = false; - while (_currentSubtitle < _subtitles.getSize()) { - int end = _subtitles[_currentSubtitle]->m_EndFrame; - - bool nextFrameOK = (_currentSubtitle < _subtitles.getSize() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= sample); - - if (sample > End) { - if (NextFrameOK) { - _currentSubtitle++; - } else { - _showSubtitle = (End == 0); - break; - } - } else { - _showSubtitle = true; - break; - } - } - - - // render frame - LPBITMAPINFOHEADER FrameData = (LPBITMAPINFOHEADER)AVIStreamGetFrame(m_VideoPGF, sample); - if (FrameData) { - if (_slowRendering) { - return _vidRenderer->ProcessFrameSlow(FrameData); - } else { - return _vidRenderer->ProcessFrame(FrameData); - } - } else { - return STATUS_FAILED; - } - } else { - return STATUS_OK; - } -#endif return 0; } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::display() { -#if 0 - if (!m_Playing) { - return STATUS_OK; - } - - bool res; - if (_vidRenderer) { - res = _vidRenderer->display(m_PlayPosX, m_PlayPosY, m_PlayZoom); - } else { - res = STATUS_FAILED; - } - - // display subtitle - if (m_ShowSubtitle) { - BaseFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; - int height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); - font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); - } - - return res; -#endif return 0; } - - - ////////////////////////////////////////////////////////////////////////// -bool VideoPlayer::play(TVideoPlayback type, int x, int y, bool FreezeMusic) { -#if 0 - if (!_videoStream || !_vidRenderer) { - return STATUS_FAILED; - } - - switch (Type) { - case VID_PLAY_POS: - _playZoom = 100.0f; - _playPosX = X; - _playPosY = Y; - break; - - case VID_PLAY_STRETCH: { - float zoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float zoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); - _playZoom = min(ZoomX, ZoomY); - _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; - _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; - } - break; - - case VID_PLAY_CENTER: - _playZoom = 100.0f; - _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; - _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; - break; - } - - _targetFormat->bV4BitCount = 24; - _targetFormat->bV4V4Compression = BI_RGB; - - - _videoPGF = AVIStreamGetFrameOpen(_videoStream, (LPBITMAPINFOHEADER)m_TargetFormat); - if (!_videoPGF) { - _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); - if (!_videoPGF) { - _gameRef->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); - cleanup(); - return STATUS_FAILED; - } else { - _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); - _slowRendering = true; - } - } else { - _slowRendering = false; - } - - // HACK!!! - _slowRendering = true; - - - _currentSubtitle = 0; - - _gameRef->Freeze(FreezeMusic); - - _playing = true; - if (_sound) { - _sound->Play(); - } - _startTime = timeGetTime(); -#endif +bool VideoPlayer::play(TVideoPlayback type, int x, int y, bool freezeMusic) { return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::stop() { -#if 0 - if (!_playing) { - return STATUS_OK; - } - - cleanup(); - - _gameRef->Unfreeze(); -#endif return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// bool VideoPlayer::isPlaying() { return _playing; } - ////////////////////////////////////////////////////////////////////////// -bool VideoPlayer::loadSubtitles(const char *filename, const char *SubtitleFile) { -#if 0 - if (!Filename) { - return STATUS_OK; - } - - char newFile[MAX_PATH_LENGTH]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - - if (SubtitleFile) { - strcpy(NewFile, SubtitleFile); - } else { - _splitpath(filename, drive, dir, fname, NULL); - _makepath(NewFile, drive, dir, fname, ".SUB"); - } - - DWORD size; - BYTE *buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); - if (Buffer == NULL) { - return STATUS_OK; // no subtitles - } - - - LONG Start, End; - bool inToken; - char *tokenStart; - int tokenLength; - int tokenPos; - int textLength; - - int pos = 0; - int lineLength = 0; - while (Pos < Size) { - start = End = -1; - inToken = false; - tokenPos = -1; - textLength = 0; - - lineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { - lineLength++; - } - - int realLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *text = new char[RealLength + 1]; - char *line = (char *)&Buffer[Pos]; - - for (int i = 0; i < RealLength; i++) { - if (line[i] == '{') { - if (!InToken) { - InToken = true; - TokenStart = line + i + 1; - TokenLength = 0; - TokenPos++; - } else { - TokenLength++; - } - } else if (line[i] == '}') { - if (InToken) { - InToken = false; - char *token = new char[TokenLength + 1]; - strncpy(Token, TokenStart, TokenLength); - Token[TokenLength] = '\0'; - if (TokenPos == 0) { - Start = atoi(Token); - } else if (TokenPos == 1) { - End = atoi(Token); - } - - delete[] Token; - } else { - Text[TextLength] = line[i]; - TextLength++; - } - } else { - if (InToken) { - TokenLength++; - } else { - Text[TextLength] = line[i]; - if (Text[TextLength] == '|') { - Text[TextLength] = '\n'; - } - TextLength++; - } - } - } - Text[TextLength] = '\0'; - - if (Start != -1 && TextLength > 0) { - _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); - } - - delete[] Text; - - Pos += LineLength + 1; - } - - delete[] Buffer; -#endif +bool VideoPlayer::loadSubtitles(const char *filename, const char *subtitleFile) { return STATUS_OK; } diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h index 4c02506094..190223c6d1 100644 --- a/engines/wintermute/video/video_player.h +++ b/engines/wintermute/video/video_player.h @@ -38,6 +38,7 @@ namespace WinterMute { +// AVI-Video-player, currently fully stubbed class VideoPlayer : public BaseClass { public: bool _showSubtitle; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index ada645c972..c0a86ecd7e 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -84,9 +84,9 @@ void VideoTheoraPlayer::SetDefaults() { _savedPos = 0; _volume = 100; _theoraDecoder = NULL; -#if 0 - _subtitler = NULL; -#endif + + // TODO: Add subtitles-support + //_subtitler = NULL; } ////////////////////////////////////////////////////////////////////////// @@ -154,7 +154,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::resetStream() { warning("VidTheoraPlayer::resetStream - stubbed"); -#if 0 +#if 0 // Stubbed for now, as theora isn't seekable if (_sound) { _sound->Stop(); } @@ -227,7 +227,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, break; } return STATUS_OK; -#if 0 +#if 0 // Stubbed for now as theora isn't seekable if (StartTime) SeekToTime(StartTime); Update(); @@ -299,83 +299,6 @@ bool VideoTheoraPlayer::update() { } } -#if 0 - m_CurrentTime = m_FreezeGame ? _gameRef->m_LiveTimer : _gameRef->m_Timer; - - if (!IsPlaying()) return STATUS_OK; - - if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; - - if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; - - int counter = 0; - while (true) { - if (m_Sound) DecodeVorbis(); - else m_AudioFrameReady = true; - - if (m_Texture) DecodeTheora(); - else m_VideoFrameReady = true; - - if ((!m_Sound || !m_AudioFrameReady) && (!m_Texture || !m_VideoFrameReady) && m_File->IsEOF()) { - // end playback - if (!m_Looping) { - m_State = THEORA_STATE_FINISHED; - if (m_Sound) m_Sound->Stop(); - if (m_FreezeGame) _gameRef->Unfreeze(); - break; - } else { - ResetStream(); - return STATUS_OK; - } - } - - - if (!m_VideoFrameReady || !m_AudioFrameReady) { - Counter++; - if (StreamInData() == 0) break; - } else break; - } - - - // If playback has begun, top audio buffer off immediately. - //if (m_Sound) WriteAudio(); - - // are we at or past time for this video frame? - if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { - //_gameRef->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); - if (m_Texture) WriteVideo(); - m_VideoFrameReady = false; - - if (m_SavedState == THEORA_STATE_PAUSED) { - Pause(); - m_SavedState = THEORA_STATE_NONE; - } - } - - // if our buffers either don't exist or are ready to go, - // we can begin playback - bool startNow = false; - if ((!m_TheoraStreams || m_VideoFrameReady) && - (!m_VorbisStreams || m_AudioFrameReady)) StartNow = true; - // same if we've run out of input - if (m_File->IsEOF()) StartNow = true; - - - if (m_Sound) WriteAudio(); - - - if (!m_PlaybackStarted && StartNow && !m_SeekingKeyframe) { - //m_StartTime = timeGetTime(); - m_StartTime = m_CurrentTime; - if (m_Sound) { - m_Sound->SetPrivateVolume(m_Volume); - m_Sound->Play(); - } - m_PlaybackStarted = true; - } - - if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); -#endif return STATUS_OK; } @@ -442,11 +365,11 @@ bool VideoTheoraPlayer::display(uint32 alpha) { } else { res = STATUS_FAILED; } -#if 0 - if (m_Subtitler && _gameRef->m_VideoSubtitles) { + // TODO: Add subtitles-support +/* if (m_Subtitler && _gameRef->m_VideoSubtitles) { m_Subtitler->display(); - } -#endif + }*/ + return res; } @@ -494,64 +417,6 @@ inline int intlog(int num) { ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::seekToTime(uint32 time) { warning("VideoTheoraPlayer::SeekToTime(%d) - not supported", time); -#if 0 - if (!m_TheoraStreams) return STATUS_FAILED; - - - float targetTime = Time / 1000.0f; - - - ogg_page page; - int read = 1; - ogg_int64_t gran; - float movieLength = 0; - DWORD LastPos = 0; - - int keyframe_granule_shift = intlog(m_TheoraInfo.keyframe_frequency_force - 1); - - while (!m_File->IsEOF() && read != 0) { - read = BufferData(&m_OggSyncState); - - while (ogg_sync_pageout(&m_OggSyncState, &page) > 0) { - int serno = ogg_page_serialno(&page); - //This is theora stream we were searching for - if (m_TheoraStreamState.serialno == serno) { - //Calculate a rough time estimate - gran = ogg_page_granulepos(&page); - if (gran >= 0) { - ogg_int64_t iframe = gran >> keyframe_granule_shift; - ogg_int64_t pframe = gran - (iframe << keyframe_granule_shift); - movieLength = (iframe + pframe) * - ((double)m_TheoraInfo.fps_denominator / m_TheoraInfo.fps_numerator); - - if (movieLength >= TargetTime) { - m_TimeOffset = movieLength; - //m_TimeOffset = TargetTime; - //m_File->Seek(LastPos); - - goto finish; - } - LastPos = m_File->GetPos(); - } - } - } - } - -finish: - ogg_sync_reset(&m_OggSyncState); - - ogg_stream_reset(&m_TheoraStreamState); - ogg_stream_reset(&m_VorbisStreamState); - - theora_clear(&m_TheoraState); - theora_decode_init(&m_TheoraState, &m_TheoraInfo); - vorbis_synthesis_restart(&m_VorbisDSPState); - - m_SeekingKeyframe = true; - - //theora_packet_iskeyframe - -#endif return STATUS_OK; } -- cgit v1.2.3 From c7fa8e7d1024e4447a7396b5099870d01b775746 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:35:20 +0200 Subject: WINTERMUTE: Move settings-files to save-dir (gzipped xml now) --- engines/wintermute/ad/ad_game.cpp | 2 +- engines/wintermute/ad/ad_game.h | 2 +- engines/wintermute/base/base_game.cpp | 7 ++- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/base_registry.cpp | 31 ++++++----- .../base/gfx/osystem/base_render_osystem.cpp | 25 +-------- engines/wintermute/platform_osystem.cpp | 42 +++------------ engines/wintermute/platform_osystem.h | 2 - engines/wintermute/system/sys_class_registry.cpp | 4 +- engines/wintermute/utils/path_util.cpp | 63 ---------------------- engines/wintermute/utils/path_util.h | 5 -- engines/wintermute/wintermute.cpp | 4 +- 12 files changed, 38 insertions(+), 151 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 66ec582f21..b922123e38 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -66,7 +66,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdGame, true) ////////////////////////////////////////////////////////////////////////// -AdGame::AdGame(): BaseGame() { +AdGame::AdGame(const Common::String &gameId): BaseGame(gameId) { _responseBox = NULL; _inventoryBox = NULL; diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index ef671b0a64..7f76b959d4 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -118,7 +118,7 @@ public: bool addObject(AdObject *object); AdScene *_scene; bool initLoop(); - AdGame(); + AdGame(const Common::String &gameId); virtual ~AdGame(); BaseArray _objects; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8fd2b193b1..3e6cb6e043 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -80,7 +80,7 @@ IMPLEMENT_PERSISTENT(BaseGame, true) ////////////////////////////////////////////////////////////////////// -BaseGame::BaseGame(): BaseObject(this) { +BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { _shuttingDown = false; _state = GAME_RUNNING; @@ -259,6 +259,7 @@ BaseGame::BaseGame(): BaseObject(this) { _autoSaveSlot = 999; _cursorHidden = false; + // Block kept as a reminder that the engine CAN run in constrained/touch-mode /*#ifdef __IPHONEOS__ _touchInterface = true; _constrainedMemory = true; // TODO differentiate old and new iOS devices @@ -331,7 +332,7 @@ BaseGame::~BaseGame() { _stringTable = NULL; DEBUG_DebugDisable(); - BasePlatform::outputDebugString("--- shutting down normally ---\n"); + debugC(kWinterMuteDebugLog, "--- shutting down normally ---\n"); } @@ -2249,6 +2250,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { stack->correctParams(0); + // Block kept to show intention of opcode. /*#ifdef __IPHONEOS__ IOS_ShowStatusLine(TRUE); #endif*/ @@ -2262,6 +2264,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { stack->correctParams(0); + // Block kept to show intention of opcode. /*#ifdef __IPHONEOS__ IOS_ShowStatusLine(FALSE); #endif*/ diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index d4a4c0e682..76881eefd7 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -147,7 +147,7 @@ public: SXMath *_mathClass; BaseSurfaceStorage *_surfaceStorage; BaseFontStorage *_fontStorage; - BaseGame(); + BaseGame(const Common::String &gameId); virtual ~BaseGame(); void DEBUG_DebugDisable(); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 441d00c05b..02f1da7322 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -32,6 +32,8 @@ #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" #include "common/config-manager.h" #include "common/file.h" @@ -173,16 +175,14 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - if (local) { - loadXml("settings.xml", _localValues); - } else { - loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); - } + Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + saveXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// @@ -212,10 +212,15 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) { + Common::SeekableReadStream *stream = g_wintermute->getSaveFileMan()->openForLoading(fileName); + if (!stream) { return; } + char *data = new char[stream->size()]; + stream->read(data, stream->size()); + TiXmlDocument doc; + doc.Parse(data); + delete data; TiXmlElement *rootElem = doc.RootElement(); if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) @@ -260,14 +265,14 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { TiXmlPrinter printer; doc.Accept(&printer); - Common::DumpFile stream; - stream.open(fileName.c_str()); + Common::WriteStream *stream = g_wintermute->getSaveFileMan()->openForSaving(fileName); - if (!stream.isOpen()) { + if (!stream) { return; } else { - stream.write(printer.CStr(), printer.Size()); - stream.close(); + stream->write(printer.CStr(), printer.Size()); + stream->finalize(); + delete stream; } } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 90dda1af72..58839d5ffe 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -124,33 +124,10 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _realWidth = width; _realHeight = height; + //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - // find suitable resolution - /*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } - #else*/ _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); -//#endif - - /* - _realWidth = 480; - _realHeight = 320; - */ - float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index 32d53e3a50..b2a0b976d4 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -81,21 +81,7 @@ void BasePlatform::handleEvent(Common::Event *event) { case Common::EVENT_WHEELDOWN: if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); break; - /*#ifdef __IPHONEOS__ - { - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - POINT p; - GetCursorPos(&p); - _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y)); - - if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "UIButton") == 0) { - UIButton *btn = static_cast(_gameRef->_activeObject); - if (btn->_visible && !btn->_disable) btn->_press = true; - } - } - #endif*/ - -//TODO +//TODO: Handle MouseWheel /* case SDL_MOUSEWHEEL: if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y); break; @@ -114,10 +100,8 @@ void BasePlatform::handleEvent(Common::Event *event) { break; case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_MINIMIZED: - #ifndef __IPHONEOS__ if (_gameRef) _gameRef->OnActivate(false, false); SDL_ShowCursor(SDL_ENABLE); - #endif break; case SDL_WINDOWEVENT_CLOSE: @@ -128,15 +112,15 @@ void BasePlatform::handleEvent(Common::Event *event) { */ case Common::EVENT_QUIT: case Common::EVENT_RTL: -/*#ifdef __IPHONEOS__ - if (_gameRef) { - _gameRef->AutoSaveOnExit(); - _gameRef->_quitting = true; - } -#else*/ +// Block kept in case we want to support autoSaveOnExit. +//#ifdef __IPHONEOS__ +// if (_gameRef) { +// _gameRef->AutoSaveOnExit(); +// _gameRef->_quitting = true; +// } +//#else*/ if (_gameRef) _gameRef->onWindowClose(); //#endif - break; default: // TODO: Do we care about any other events? @@ -148,16 +132,6 @@ void BasePlatform::handleEvent(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // Win32 API bindings -////////////////////////////////////////////////////////////////////////// -void BasePlatform::outputDebugString(const char *lpOutputString) { -/* -#ifdef __WIN32__ - ::OutputDebugString(lpOutputString); -#endif -*/ -} - - ////////////////////////////////////////////////////////////////////////// bool BasePlatform::getCursorPos(Point32 *lpPoint) { BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 14b8c959a8..53462724bd 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -45,8 +45,6 @@ public: static AnsiString getPlatformName(); // Win32 API bindings - static void outputDebugString(const char *lpOutputString); - //static uint32 getTime(); static bool getCursorPos(Point32 *lpPoint); static bool setCursorPos(int x, int y); static bool showWindow(int nCmdShow); diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index 47910af4e8..09e43529e3 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -82,9 +82,7 @@ bool SystemClassRegistry::unregisterClass(SystemClass *classObj) { } if (classObj->getNumInstances() != 0) { - char str[MAX_PATH_LENGTH]; - sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); - BasePlatform::outputDebugString(str); + debugC(WinterMute::kWinterMuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); } _classes.erase(it); diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 4e36c3e316..db1b479dab 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -67,101 +67,38 @@ AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::getDirectoryName(const AnsiString &path) { AnsiString newPath = unifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); Common::String filename = getFileName(path); return Common::String(path.c_str(), path.size() - filename.size()); - //if (pos == AnsiString::npos) return ""; - //else return newPath.substr(0, pos + 1); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::getFileName(const AnsiString &path) { AnsiString newPath = unifySeparators(path); - - //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE. Common::String lastPart = Common::lastPathComponent(newPath, '/'); if (lastPart[lastPart.size() - 1 ] != '/') { return lastPart; } else { return path; } - //if (pos == AnsiString::npos) return path; - //else return newPath.substr(pos + 1); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) { AnsiString fileName = getFileName(path); - - //size_t pos = fileName.find_last_of('.'); //TODO REMOVE! // TODO: Prettify this. AnsiString extension = Common::lastPathComponent(fileName, '.'); for (uint32 i = 0; i < extension.size() + 1; i++) { fileName.deleteLastChar(); } -// Common::String filename = Common::String(fileName.c_str(), fileName.size() - extension.size() + 1); return fileName; - //if (pos == AnsiString::npos) return fileName; - //else return fileName.substr(0, pos); } ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::getExtension(const AnsiString &path) { AnsiString fileName = getFileName(path); - - //size_t pos = fileName.find_last_of('.'); return Common::lastPathComponent(path, '.'); - //if (pos == AnsiString::npos) return ""; - //else return fileName.substr(pos); } - -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getSafeLogFileName() { - AnsiString logFileName = getUserDirectory(); - - /*#ifdef __WIN32__ - char moduleName[MAX_PATH_LENGTH]; - ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH); - - AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log"; - fileName = Combine("/Wintermute Engine/Logs/", fileName); - logFileName = Combine(logFileName, fileName); - - #else*/ - // !PORTME - logFileName = combine(logFileName, "/Wintermute Engine/wme.log"); -//#endif - - createDirectory(getDirectoryName(logFileName)); - return logFileName; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::createDirectory(const AnsiString &path) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::matchesMask(const AnsiString &fileName, const AnsiString &mask) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool PathUtil::fileExists(const AnsiString &fileName) { - warning("PathUtil::FileExists(%s)", fileName.c_str()); - - Common::File stream; - - stream.open(fileName.c_str()); - bool ret = stream.isOpen(); - stream.close(); - - return ret; -} - - ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::getUserDirectory() { // TODO: Get rid of warning("PathUtil::GetUserDirectory - stubbed"); diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index a52b4baaf9..9b3e988805 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -42,12 +42,7 @@ public: static AnsiString getFileName(const AnsiString &path); static AnsiString getFileNameWithoutExtension(const AnsiString &path); static AnsiString getExtension(const AnsiString &path); - static bool createDirectory(const AnsiString &path); - static bool matchesMask(const AnsiString &fileName, const AnsiString &mask); - static bool fileExists(const AnsiString &fileName); - - static AnsiString getSafeLogFileName(); static AnsiString getUserDirectory(); }; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 8bf83cc0f6..8e782a2444 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -52,7 +52,7 @@ WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { _classReg = new SystemClassRegistry(); _classReg->registerClasses(); - _game = new AdGame(); + _game = new AdGame(""); _rnd = NULL; } @@ -158,7 +158,7 @@ int WinterMuteEngine::init() { _classReg = new SystemClassRegistry(); _classReg->registerClasses(); - _game = new AdGame; + _game = new AdGame(_targetName); if (!_game) return 1; BasePlatform::initialize(_game, 0, NULL); -- cgit v1.2.3 From 8ed71a99f6aaee27a3187cb47fe0c3b30acf88a0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:37:00 +0200 Subject: WINTERMUTE: Constructor(args): SuperClass(args) -> Constructor(args) : SuperClass(args) --- engines/wintermute/ad/ad_actor.cpp | 2 +- engines/wintermute/ad/ad_entity.cpp | 2 +- engines/wintermute/ad/ad_game.cpp | 2 +- engines/wintermute/ad/ad_inventory.cpp | 2 +- engines/wintermute/ad/ad_inventory_box.cpp | 2 +- engines/wintermute/ad/ad_item.cpp | 2 +- engines/wintermute/ad/ad_layer.cpp | 2 +- engines/wintermute/ad/ad_node_state.cpp | 2 +- engines/wintermute/ad/ad_object.cpp | 2 +- engines/wintermute/ad/ad_path.cpp | 2 +- engines/wintermute/ad/ad_region.cpp | 2 +- engines/wintermute/ad/ad_response.cpp | 2 +- engines/wintermute/ad/ad_response_box.cpp | 2 +- engines/wintermute/ad/ad_response_context.cpp | 2 +- engines/wintermute/ad/ad_rot_level.cpp | 2 +- engines/wintermute/ad/ad_scale_level.cpp | 2 +- engines/wintermute/ad/ad_scene.cpp | 2 +- engines/wintermute/ad/ad_scene_node.cpp | 2 +- engines/wintermute/ad/ad_scene_state.cpp | 2 +- engines/wintermute/ad/ad_sentence.cpp | 2 +- engines/wintermute/ad/ad_sprite_set.cpp | 2 +- engines/wintermute/ad/ad_talk_def.cpp | 2 +- engines/wintermute/ad/ad_talk_holder.cpp | 2 +- engines/wintermute/ad/ad_talk_node.cpp | 2 +- engines/wintermute/ad/ad_waypoint_group.cpp | 2 +- engines/wintermute/base/base_active_rect.cpp | 6 +++--- engines/wintermute/base/base_dynamic_buffer.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_keyboard_state.cpp | 2 +- engines/wintermute/base/base_object.cpp | 2 +- engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/base_quick_msg.cpp | 2 +- engines/wintermute/base/base_region.cpp | 2 +- engines/wintermute/base/base_registry.cpp | 2 +- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_scriptable.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_string_table.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/base_transition_manager.cpp | 2 +- engines/wintermute/base/base_viewport.cpp | 2 +- engines/wintermute/base/file/base_file.cpp | 2 +- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 2 +- engines/wintermute/base/scriptables/script_engine.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_array.cpp | 4 ++-- engines/wintermute/base/scriptables/script_ext_date.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_file.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_math.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp | 4 ++-- engines/wintermute/base/scriptables/script_ext_object.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_string.cpp | 2 +- engines/wintermute/base/scriptables/script_stack.cpp | 2 +- engines/wintermute/base/scriptables/script_value.cpp | 10 +++++----- engines/wintermute/base/sound/base_sound.cpp | 2 +- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 +- engines/wintermute/base/sound/base_sound_manager.cpp | 2 +- engines/wintermute/persistent.h | 2 +- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 2 +- engines/wintermute/ui/ui_entity.cpp | 2 +- engines/wintermute/ui/ui_object.cpp | 2 +- engines/wintermute/ui/ui_text.cpp | 2 +- engines/wintermute/ui/ui_tiled_image.cpp | 2 +- engines/wintermute/ui/ui_window.cpp | 2 +- engines/wintermute/video/video_player.cpp | 2 +- engines/wintermute/video/video_theora_player.cpp | 2 +- 76 files changed, 84 insertions(+), 84 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 540b6b62c2..caadab18aa 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -51,7 +51,7 @@ IMPLEMENT_PERSISTENT(AdActor, false) ////////////////////////////////////////////////////////////////////////// -AdActor::AdActor(BaseGame *inGame): AdTalkHolder(inGame) { +AdActor::AdActor(BaseGame *inGame) : AdTalkHolder(inGame) { _path = new AdPath(_gameRef); _type = OBJECT_ACTOR; diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index daa064f328..b6da77f971 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -57,7 +57,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdEntity, false) ////////////////////////////////////////////////////////////////////////// -AdEntity::AdEntity(BaseGame *inGame): AdTalkHolder(inGame) { +AdEntity::AdEntity(BaseGame *inGame) : AdTalkHolder(inGame) { _type = OBJECT_ENTITY; _subtype = ENTITY_NORMAL; _region = NULL; diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index b922123e38..260a3fc378 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -66,7 +66,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdGame, true) ////////////////////////////////////////////////////////////////////////// -AdGame::AdGame(const Common::String &gameId): BaseGame(gameId) { +AdGame::AdGame(const Common::String &gameId) : BaseGame(gameId) { _responseBox = NULL; _inventoryBox = NULL; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 6cc5ed879e..203a18ae32 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdInventory, false) ////////////////////////////////////////////////////////////////////////// -AdInventory::AdInventory(BaseGame *inGame): BaseObject(inGame) { +AdInventory::AdInventory(BaseGame *inGame) : BaseObject(inGame) { _scrollOffset = 0; } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 80929bcb7b..bc773cbdaf 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -46,7 +46,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdInventoryBox, false) ////////////////////////////////////////////////////////////////////////// -AdInventoryBox::AdInventoryBox(BaseGame *inGame): BaseObject(inGame) { +AdInventoryBox::AdInventoryBox(BaseGame *inGame) : BaseObject(inGame) { _itemsArea.setEmpty(); _scrollOffset = 0; _spacing = 0; diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 70b8bba2a4..8e93ef77d4 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -48,7 +48,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdItem, false) ////////////////////////////////////////////////////////////////////////// -AdItem::AdItem(BaseGame *inGame): AdTalkHolder(inGame) { +AdItem::AdItem(BaseGame *inGame) : AdTalkHolder(inGame) { _spriteHover = NULL; _cursorNormal = _cursorHover = NULL; diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index a60cd76209..c4be6c8dfc 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -43,7 +43,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdLayer, false) ////////////////////////////////////////////////////////////////////////// -AdLayer::AdLayer(BaseGame *inGame): BaseObject(inGame) { +AdLayer::AdLayer(BaseGame *inGame) : BaseObject(inGame) { _main = false; _width = _height = 0; _active = true; diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 270a114277..4784d6d331 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -41,7 +41,7 @@ IMPLEMENT_PERSISTENT(AdNodeState, false) ////////////////////////////////////////////////////////////////////////// -AdNodeState::AdNodeState(BaseGame *inGame): BaseClass(inGame) { +AdNodeState::AdNodeState(BaseGame *inGame) : BaseClass(inGame) { _name = NULL; _active = false; for (int i = 0; i < 7; i++) { diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index cf60bedf2c..aaf4c6db4a 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -57,7 +57,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdObject, false) ////////////////////////////////////////////////////////////////////////// -AdObject::AdObject(BaseGame *inGame): BaseObject(inGame) { +AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { _type = OBJECT_NONE; _state = _nextState = STATE_NONE; diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 7734b4d9ba..89eb3f29fa 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -34,7 +34,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdPath, false) ////////////////////////////////////////////////////////////////////////// -AdPath::AdPath(BaseGame *inGame): BaseClass(inGame) { +AdPath::AdPath(BaseGame *inGame) : BaseClass(inGame) { _currIndex = -1; _ready = false; } diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 18b5731830..7d51cfce37 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -39,7 +39,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdRegion, false) ////////////////////////////////////////////////////////////////////////// -AdRegion::AdRegion(BaseGame *inGame): BaseRegion(inGame) { +AdRegion::AdRegion(BaseGame *inGame) : BaseRegion(inGame) { _blocked = false; _decoration = false; _zoom = 0; diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index e954b0d44d..9cfa181b1c 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdResponse, false) ////////////////////////////////////////////////////////////////////////// -AdResponse::AdResponse(BaseGame *inGame): BaseObject(inGame) { +AdResponse::AdResponse(BaseGame *inGame) : BaseObject(inGame) { _text = NULL; _textOrig = NULL; _icon = _iconHover = _iconPressed = NULL; diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 07df0a88ee..7f2fdc9b3e 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -49,7 +49,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdResponseBox, false) ////////////////////////////////////////////////////////////////////////// -AdResponseBox::AdResponseBox(BaseGame *inGame): BaseObject(inGame) { +AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { _font = _fontHover = NULL; _window = NULL; diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 41359fc0f0..175a7f8491 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -34,7 +34,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdResponseContext, false) ////////////////////////////////////////////////////////////////////////// -AdResponseContext::AdResponseContext(BaseGame *inGame): BaseClass(inGame) { +AdResponseContext::AdResponseContext(BaseGame *inGame) : BaseClass(inGame) { _id = 0; _context = NULL; } diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index f04d379e6b..753dd38190 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -39,7 +39,7 @@ IMPLEMENT_PERSISTENT(AdRotLevel, false) ////////////////////////////////////////////////////////////////////////// -AdRotLevel::AdRotLevel(BaseGame *inGame): BaseObject(inGame) { +AdRotLevel::AdRotLevel(BaseGame *inGame) : BaseObject(inGame) { _posX = 0; _rotation = 0.0f; } diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index f9da6bba4a..465e82cbde 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdScaleLevel, false) ////////////////////////////////////////////////////////////////////////// -AdScaleLevel::AdScaleLevel(BaseGame *inGame): BaseObject(inGame) { +AdScaleLevel::AdScaleLevel(BaseGame *inGame) : BaseObject(inGame) { _posY = 0; _scale = 100; } diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index e047373918..859effd5c7 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -64,7 +64,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdScene, false) ////////////////////////////////////////////////////////////////////////// -AdScene::AdScene(BaseGame *inGame): BaseObject(inGame) { +AdScene::AdScene(BaseGame *inGame) : BaseObject(inGame) { _pfTarget = new BasePoint; setDefaults(); } diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index 658e85340d..87b2c25406 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -34,7 +34,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdSceneNode, false) ////////////////////////////////////////////////////////////////////////// -AdSceneNode::AdSceneNode(BaseGame *inGame): BaseObject(inGame) { +AdSceneNode::AdSceneNode(BaseGame *inGame) : BaseObject(inGame) { _type = OBJECT_NONE; _region = NULL; _entity = NULL; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index bbacf57707..eafb1f96b6 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdSceneState, false) ////////////////////////////////////////////////////////////////////////// -AdSceneState::AdSceneState(BaseGame *inGame): BaseClass(inGame) { +AdSceneState::AdSceneState(BaseGame *inGame) : BaseClass(inGame) { _filename = NULL; } diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 6bbcd590a8..5126a51c80 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -43,7 +43,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdSentence, false) ////////////////////////////////////////////////////////////////////////// -AdSentence::AdSentence(BaseGame *inGame): BaseClass(inGame) { +AdSentence::AdSentence(BaseGame *inGame) : BaseClass(inGame) { _text = NULL; _stances = NULL; _tempStance = NULL; diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 42409988a5..0a5949b2c0 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -38,7 +38,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdSpriteSet, false) ////////////////////////////////////////////////////////////////////////// -AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner): BaseObject(inGame) { +AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner) : BaseObject(inGame) { _owner = owner; for (int i = 0; i < NUM_DIRECTIONS; i++) { diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 5b88887e0c..b12a6af357 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -41,7 +41,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdTalkDef, false) ////////////////////////////////////////////////////////////////////////// -AdTalkDef::AdTalkDef(BaseGame *inGame): BaseObject(inGame) { +AdTalkDef::AdTalkDef(BaseGame *inGame) : BaseObject(inGame) { _defaultSpriteFilename = NULL; _defaultSprite = NULL; diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 6aca8e01a8..5a2b3df31b 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdTalkHolder, false) ////////////////////////////////////////////////////////////////////////// -AdTalkHolder::AdTalkHolder(BaseGame *inGame): AdObject(inGame) { +AdTalkHolder::AdTalkHolder(BaseGame *inGame) : AdObject(inGame) { _sprite = NULL; } diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index ef30290b8c..ecaf098a40 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -38,7 +38,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdTalkNode, false) ////////////////////////////////////////////////////////////////////////// -AdTalkNode::AdTalkNode(BaseGame *inGame): BaseClass(inGame) { +AdTalkNode::AdTalkNode(BaseGame *inGame) : BaseClass(inGame) { _sprite = NULL; _spriteFilename = NULL; _spriteSet = NULL; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index fac3bbe630..1188ec2fb1 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -40,7 +40,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(AdWaypointGroup, false) ////////////////////////////////////////////////////////////////////////// -AdWaypointGroup::AdWaypointGroup(BaseGame *inGame): BaseObject(inGame) { +AdWaypointGroup::AdWaypointGroup(BaseGame *inGame) : BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 0756d10698..a895735725 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { BasePlatform::setRectEmpty(&_rect); _owner = NULL; _frame = NULL; @@ -47,7 +47,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise) : BaseClass(inGame) { _owner = owner; _frame = frame; BasePlatform::setRect(&_rect, x, y, x + width, y + height); @@ -60,7 +60,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame } ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { _owner = owner; _region = region; BasePlatform::copyRect(&_rect, ®ion->_rect); diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index a61227b0dc..949548b68b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy): BaseClass(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) { _buffer = NULL; _size = 0; _realSize = 0; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 04fde5457c..4bc166f841 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -39,7 +39,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFader, false) ////////////////////////////////////////////////////////////////////////// -BaseFader::BaseFader(BaseGame *inGame): BaseObject(inGame) { +BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { _active = false; _red = _green = _blue = 0; _currentAlpha = 0x00; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 44e39823e6..edbfe3447f 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -44,7 +44,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFrame, false) ////////////////////////////////////////////////////////////////////// -BaseFrame::BaseFrame(BaseGame *inGame): BaseScriptable(inGame, true) { +BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _delay = 0; _moveX = _moveY = 0; diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 2b77cb23ca..01b5cea36d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseKeyboardState, false) ////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::BaseKeyboardState(BaseGame *inGame): BaseScriptable(inGame) { +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(inGame) { _currentPrintable = false; _currentCharCode = 0; _currentKeyData = 0; diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 5fbfc31924..7d186c7f0a 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseObject, false) ////////////////////////////////////////////////////////////////////// -BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { +BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { _posX = _posY = 0; _movable = true; _zoomable = true; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 98d77f4ed5..3bd4f0441f 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -42,7 +42,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { +BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index bf38adb578..e9f3e430af 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { _text = new char [strlen(text) + 1]; if (_text) { strcpy(_text, text); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 79ea5396fc..7335d904c7 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseRegion, false) ////////////////////////////////////////////////////////////////////////// -BaseRegion::BaseRegion(BaseGame *inGame): BaseObject(inGame) { +BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 02f1da7322..2b6127bd09 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry(BaseGame *inGame): BaseClass(inGame) { +BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) { _iniName = NULL; setIniName("./wme.ini"); diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 5007b65422..8b71c73818 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame): BaseClass(inGame) { +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { _thumbnail = NULL; } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 131acf326f..51d1b32814 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -39,7 +39,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseScriptHolder, false) ////////////////////////////////////////////////////////////////////// -BaseScriptHolder::BaseScriptHolder(BaseGame *inGame): BaseScriptable(inGame) { +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { setName(""); _freezable = true; diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index ad89b63d65..743805cad7 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseScriptable, false) ////////////////////////////////////////////////////////////////////////// -BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { +BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) : BaseNamedObject(inGame) { _refCount = 0; if (noValue) { diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index fb1b5a82cf..00af5bd960 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -47,7 +47,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSprite, false) ////////////////////////////////////////////////////////////////////// -BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner): BaseScriptHolder(inGame) { +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { _editorAllFrames = false; _owner = Owner; setDefaults(); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 18a18fe0ba..8dc9e25e4b 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseStringTable::BaseStringTable(BaseGame *inGame): BaseClass(inGame) { +BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { } diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index e8290ee659..17b5196f2a 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSubFrame, false) ////////////////////////////////////////////////////////////////////////// -BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { +BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _surface = NULL; _hotspotX = _hotspotY = 0; _alpha = 0xFFFFFFFF; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 689066eb6e..63e14aa543 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -38,7 +38,7 @@ namespace WinterMute { //IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); ////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame): BaseClass(inGame) { +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { _lastCleanupTime = 0; } diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 7a78865552..63a13309fb 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame): BaseClass(inGame) { +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { _state = TRANS_MGR_READY; _type = TRANSITION_NONE; _origInteractive = false; diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index ad875ec00d..a6c7eea96e 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseViewport, false) ////////////////////////////////////////////////////////////////////////// -BaseViewport::BaseViewport(BaseGame *inGame): BaseClass(inGame) { +BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { BasePlatform::setRectEmpty(&_rect); _mainObject = NULL; _offsetX = _offsetY = 0; diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index b2c0b31db9..11d095e70b 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile(BaseGame *inGame): BaseClass(inGame) { +BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) { _pos = 0; _size = 0; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index e067241589..a285a93923 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame): BaseFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) { _data = NULL; } diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 1f938dfac2..5087f1752d 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFont, false) ////////////////////////////////////////////////////////////////////// -BaseFont::BaseFont(BaseGame *inGame): BaseObject(inGame) { +BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ed7c13a54d..046ab77333 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -47,7 +47,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontBitmap, false) ////////////////////////////////////////////////////////////////////// -BaseFontBitmap::BaseFontBitmap(BaseGame *inGame): BaseFont(inGame) { +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { _subframe = NULL; _sprite = NULL; _widthsFrame = 0; diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 95f1ae601c..bc4152131f 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -41,7 +41,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontStorage, true) ////////////////////////////////////////////////////////////////////////// -BaseFontStorage::BaseFontStorage(BaseGame *inGame): BaseClass(inGame) { +BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 638b939ec1..2dd436dc37 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -48,7 +48,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontTT, false) ////////////////////////////////////////////////////////////////////////// -BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { +BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { _fontHeight = 12; _isBold = _isItalic = _isUnderline = _isStriked = false; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 3a29bf542d..ab5111332e 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseRenderer::BaseRenderer(BaseGame *inGame): BaseClass(inGame) { +BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _window = 0; _clipperWindow = 0; _active = false; diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 635d48058f..62ddece47c 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { +BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { _referenceCount = 0; _width = _height = 0; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 75c4d38574..d8d4bc66da 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -38,7 +38,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScScript, false) ////////////////////////////////////////////////////////////////////////// -ScScript::ScScript(BaseGame *inGame, ScEngine *Engine): BaseClass(inGame) { +ScScript::ScScript(BaseGame *inGame, ScEngine *Engine) : BaseClass(inGame) { _buffer = NULL; _bufferSize = _iP = 0; _scriptStream = NULL; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index bc8d54ef58..01f647c110 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -44,7 +44,7 @@ IMPLEMENT_PERSISTENT(ScEngine, true) #define COMPILER_DLL "dcscomp.dll" ////////////////////////////////////////////////////////////////////////// -ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { +ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); if (_compilerAvailable) { diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index cc3bec89c0..79303723e0 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -41,7 +41,7 @@ BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { _length = 0; _values = new ScValue(_gameRef); @@ -60,7 +60,7 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame): BaseScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { _length = 0; _values = new ScValue(_gameRef); } diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 181be8ddd0..72f41c83cc 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -39,7 +39,7 @@ BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXDate::SXDate(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 9736ae3ee2..5743722d6f 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -49,7 +49,7 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(1); ScValue *val = stack->pop(); diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 525b43434f..6b80da6389 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -47,7 +47,7 @@ BaseScriptable *makeSXMath(BaseGame *inGame) { } ////////////////////////////////////////////////////////////////////////// -SXMath::SXMath(BaseGame *inGame): BaseScriptable(inGame) { +SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 9bde5d45e7..afe5e65467 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -42,7 +42,7 @@ BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(1); _buffer = NULL; _size = 0; @@ -52,7 +52,7 @@ SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGam } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { _size = 0; _buffer = buffer; } diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index b72e3e4b97..ab7296b1ce 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -43,7 +43,7 @@ BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXObject::SXObject(BaseGame *inGame, ScStack *stack): BaseObject(inGame) { +SXObject::SXObject(BaseGame *inGame, ScStack *stack) : BaseObject(inGame) { int numParams = stack->pop()->getInt(0); for (int i = 0; i < numParams; i++) { addScript(stack->pop()->getString()); diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 1c7349bd8d..adbf16611c 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -44,7 +44,7 @@ BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { _string = NULL; _capacity = 0; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 8840a2c0f1..9b3a0201ac 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScStack, false) ////////////////////////////////////////////////////////////////////////// -ScStack::ScStack(BaseGame *inGame): BaseClass(inGame) { +ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { _sP = -1; } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 9b83daf42f..456f93507e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -43,7 +43,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScValue, false) ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { _type = VAL_NULL; _valBool = false; @@ -58,7 +58,7 @@ ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { _type = VAL_BOOL; _valBool = val; @@ -73,7 +73,7 @@ ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { _type = VAL_INT; _valInt = val; @@ -88,7 +88,7 @@ ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { _type = VAL_FLOAT; _valFloat = val; @@ -103,7 +103,7 @@ ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { _type = VAL_STRING; _valString = NULL; setStringVal(val); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 8a139ead4f..6151128624 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -36,7 +36,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSound, false) ////////////////////////////////////////////////////////////////////////// -BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { +BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sound = NULL; _soundFilename = NULL; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 25be117db2..ed667592e9 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -50,7 +50,7 @@ namespace WinterMute { #define MAX_NONSTREAMED_FILE_SIZE 1024*1024 ////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { _stream = NULL; _handle = NULL; // _sync = NULL; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index d2e640e3f3..4659c35ff7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -46,7 +46,7 @@ namespace WinterMute { //IMPLEMENT_PERSISTENT(BaseSoundMgr, true); ////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::BaseSoundMgr(BaseGame *inGame): BaseClass(inGame) { +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { _soundAvailable = false; _volumeMaster = 255; } diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 4d7d08735c..0df2f8420b 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -48,7 +48,7 @@ namespace WinterMute { static void* persistBuild(void);\ virtual const char* getClassName();\ static bool persistLoad(void* Instance, BasePersistenceManager* PersistMgr);\ - class_name(TDynamicConstructor p1, TDynamicConstructor p2):parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ + class_name(TDynamicConstructor p1, TDynamicConstructor p2) :parent_class(p1, p2){ /*memset(this, 0, sizeof(class_name));*/ };\ virtual bool persist(BasePersistenceManager* PersistMgr);\ void* operator new (size_t size);\ void operator delete(void* p);\ diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 706b0d3c00..3352f9355d 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -46,7 +46,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIButton, false) ////////////////////////////////////////////////////////////////////////// -UIButton::UIButton(BaseGame *inGame): UIObject(inGame) { +UIButton::UIButton(BaseGame *inGame) : UIObject(inGame) { _backPress = _backHover = _backDisable = _backFocus = NULL; _fontHover = _fontPress = _fontDisable = _fontFocus = NULL; diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 22d477bc31..1483c46475 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -52,7 +52,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIEdit, false) ////////////////////////////////////////////////////////////////////////// -UIEdit::UIEdit(BaseGame *inGame): UIObject(inGame) { +UIEdit::UIEdit(BaseGame *inGame) : UIObject(inGame) { _type = UI_EDIT; _fontSelected = NULL; diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index c2438b0fc6..71b573fc92 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -41,7 +41,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIEntity, false) ////////////////////////////////////////////////////////////////////////// -UIEntity::UIEntity(BaseGame *inGame): UIObject(inGame) { +UIEntity::UIEntity(BaseGame *inGame) : UIObject(inGame) { _type = UI_CUSTOM; _entity = NULL; } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index d1a13200c8..8f1356020e 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -41,7 +41,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIObject, false) ////////////////////////////////////////////////////////////////////////// -UIObject::UIObject(BaseGame *inGame): BaseObject(inGame) { +UIObject::UIObject(BaseGame *inGame) : BaseObject(inGame) { _back = NULL; _image = NULL; _font = NULL; diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 25fef4fd93..5ead4ad6f3 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -46,7 +46,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIText, false) ////////////////////////////////////////////////////////////////////////// -UIText::UIText(BaseGame *inGame): UIObject(inGame) { +UIText::UIText(BaseGame *inGame) : UIObject(inGame) { _textAlign = TAL_LEFT; _verticalAlign = VAL_CENTER; _type = UI_STATIC; diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index c11361de8d..f54ba7843e 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -40,7 +40,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UITiledImage, false) ////////////////////////////////////////////////////////////////////////// -UITiledImage::UITiledImage(BaseGame *inGame): BaseObject(inGame) { +UITiledImage::UITiledImage(BaseGame *inGame) : BaseObject(inGame) { _image = NULL; BasePlatform::setRectEmpty(&_upLeft); diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 6aba91b791..0a2ec6b389 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -52,7 +52,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(UIWindow, false) ////////////////////////////////////////////////////////////////////////// -UIWindow::UIWindow(BaseGame *inGame): UIObject(inGame) { +UIWindow::UIWindow(BaseGame *inGame) : UIObject(inGame) { BasePlatform::setRectEmpty(&_titleRect); BasePlatform::setRectEmpty(&_dragRect); _titleAlign = TAL_LEFT; diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index d0b4019621..a3eedaa293 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -VideoPlayer::VideoPlayer(BaseGame *inGame): BaseClass(inGame) { +VideoPlayer::VideoPlayer(BaseGame *inGame) : BaseClass(inGame) { setDefaults(); } diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index c0a86ecd7e..dad456f431 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -43,7 +43,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(VideoTheoraPlayer, false) ////////////////////////////////////////////////////////////////////////// -VideoTheoraPlayer::VideoTheoraPlayer(BaseGame *inGame): BaseClass(inGame) { +VideoTheoraPlayer::VideoTheoraPlayer(BaseGame *inGame) : BaseClass(inGame) { SetDefaults(); } -- cgit v1.2.3 From e08a0d84a2dd4ebb312fc72b9757c303e351dbb1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:42:37 +0200 Subject: WINTERMUTE: Hardcode the Game.SaveDirectory return value in-engine for now. --- engines/wintermute/base/base_game.cpp | 10 +--------- engines/wintermute/base/base_game.h | 1 - engines/wintermute/utils/path_util.cpp | 7 ------- engines/wintermute/utils/path_util.h | 2 -- 4 files changed, 1 insertion(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 3e6cb6e043..a7ea7fe95f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -2604,7 +2604,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = getDataDir(); + AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. _scValue->setString(dataDir.c_str()); return _scValue; } @@ -4012,14 +4012,6 @@ bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -AnsiString BaseGame::getDataDir() { - AnsiString userDir = PathUtil::getUserDirectory(); - AnsiString baseDir = _registry->getBasePath(); - return PathUtil::combine(userDir, baseDir); -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 76881eefd7..9adca0743c 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -254,7 +254,6 @@ public: virtual bool initAfterLoad(); BaseSaveThumbHelper *_cachedThumbnail; - AnsiString getDataDir(); void addMem(int bytes); bool _touchInterface; bool _constrainedMemory; diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index db1b479dab..065e0aada9 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -99,11 +99,4 @@ AnsiString PathUtil::getExtension(const AnsiString &path) { return Common::lastPathComponent(path, '.'); } -////////////////////////////////////////////////////////////////////////// -AnsiString PathUtil::getUserDirectory() { // TODO: Get rid of - warning("PathUtil::GetUserDirectory - stubbed"); - AnsiString userDir = "./"; - return userDir; -} - } // end of namespace WinterMute diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index 9b3e988805..f63c15dcd1 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -42,8 +42,6 @@ public: static AnsiString getFileName(const AnsiString &path); static AnsiString getFileNameWithoutExtension(const AnsiString &path); static AnsiString getExtension(const AnsiString &path); - - static AnsiString getUserDirectory(); }; } // end of namespace WinterMute -- cgit v1.2.3 From e841bf16d6b955f779e5e30535848bd650d22352 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 28 Jul 2012 23:10:33 +0200 Subject: WINTERMUTE: Fix a few warnings pointed out by fuzzie. --- engines/wintermute/ad/ad_entity.cpp | 2 -- engines/wintermute/ad/ad_scene.cpp | 7 ++++--- engines/wintermute/base/base_file_manager.cpp | 3 ++- engines/wintermute/base/base_region.h | 3 ++- engines/wintermute/base/base_registry.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/file/base_package.cpp | 6 +++--- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 5 +++-- engines/wintermute/ui/ui_object.h | 1 + 10 files changed, 18 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index b6da77f971..6fea297018 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -1102,10 +1102,8 @@ void AdEntity::setItem(const char *itemName) { ////////////////////////////////////////////////////////////////////////// bool AdEntity::setSprite(const char *filename) { - bool setCurrent = false; if (_currentSprite == _sprite) { _currentSprite = NULL; - setCurrent = true; } delete _sprite; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 859effd5c7..9a808bbb5f 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1106,15 +1106,16 @@ bool AdScene::display() { ////////////////////////////////////////////////////////////////////////// bool AdScene::updateFreeObjects() { AdGame *adGame = (AdGame *)_gameRef; - bool is3DSet; + // 3D-code removed + // bool is3DSet; // *** update all active objects - is3DSet = false; + // is3DSet = false; for (int i = 0; i < adGame->_objects.getSize(); i++) { if (!adGame->_objects[i]->_active) { continue; } - + // 3D-code removed adGame->_objects[i]->update(); adGame->_objects[i]->_drawn = false; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 5bad96d65e..7fe7b3ab98 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -269,8 +269,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { BasePersistenceManager pm(_gameRef); - if (filename.size() < 9) + if (filename.size() <= 9) { return false; + } int slot = atoi(filename.c_str() + 9); return pm.getSaveExists(slot); } diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 3b4b28030d..7770d345f7 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -54,7 +54,8 @@ public: bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; BaseArray _points; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, NULL); } + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); // scripting interface virtual ScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 2b6127bd09..afaa01f06d 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -220,7 +220,7 @@ void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { stream->read(data, stream->size()); TiXmlDocument doc; doc.Parse(data); - delete data; + delete[] data; TiXmlElement *rootElem = doc.RootElement(); if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 63e14aa543..c01c86c009 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -73,7 +73,7 @@ bool BaseSurfaceStorage::initLoop() { break; } - if (_surfaces[i]->_lifeTime > 0 && (int)(_surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 80d3b4a515..ab74810d1d 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -169,7 +169,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool for (uint32 j = 0; j < numFiles; j++) { char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; + uint32 offset, length, compLength, flags;/*, timeDate1, timeDate2;*/ nameLength = stream->readByte(); name = new char[nameLength]; @@ -195,8 +195,8 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool flags = stream->readUint32LE(); if (hdr._packageVersion == PACKAGE_VERSION) { - timeDate1 = stream->readUint32LE(); - timeDate2 = stream->readUint32LE(); + /* timeDate1 = */ stream->readUint32LE(); + /* timeDate2 = */ stream->readUint32LE(); } _filesIter = _files.find(upcName); if (_filesIter == _files.end()) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 046ab77333..e2c5fa881c 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -371,7 +371,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { case TOKEN_WIDTHS: parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + for (i = 0; lastWidth < NUM_CHARACTERS && num > 0; lastWidth++, num--, i++) { _widths[lastWidth] = (byte)widths[i]; } break; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5102d182f9..d3209cb1c0 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -394,12 +394,13 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. - bool hasAlpha; + // TODO: Optimize by not doing alpha-blits if we lack or disable alpha +/* bool hasAlpha; if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; - } + }*/ if (alphaDisable) { warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 64cd711dcc..50d0a08873 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -48,6 +48,7 @@ public: bool _parentNotify; DECLARE_PERSISTENT(UIObject, BaseObject) UIObject *_parent; + virtual bool display() { return display(0, 0); } virtual bool display(int offsetX = 0, int offsetY = 0); virtual void correctSize(); bool _sharedFonts; -- cgit v1.2.3 From 6dc1e09da93c0ba0507fd0ceadbbb504469deccc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 00:27:50 +0200 Subject: WINTERMUTE: Replace const char* with const Common::String & in fonts, gfx, particles, sound and files. --- engines/wintermute/ad/ad_entity.cpp | 4 +- engines/wintermute/base/base.cpp | 8 ++-- engines/wintermute/base/base.h | 4 +- engines/wintermute/base/base_frame.cpp | 8 ++-- engines/wintermute/base/base_game.cpp | 4 +- engines/wintermute/base/base_sprite.cpp | 10 ++--- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/base_sub_frame.cpp | 6 +-- engines/wintermute/base/base_sub_frame.h | 2 +- engines/wintermute/base/base_surface_storage.cpp | 8 ++-- engines/wintermute/base/base_surface_storage.h | 2 +- engines/wintermute/base/font/base_font.cpp | 4 +- engines/wintermute/base/font/base_font.h | 4 +- engines/wintermute/base/font/base_font_bitmap.cpp | 8 ++-- engines/wintermute/base/font/base_font_bitmap.h | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 6 +-- engines/wintermute/base/font/base_font_storage.h | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 8 ++-- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 7 --- engines/wintermute/base/gfx/base_surface.h | 2 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- .../base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 12 +++--- engines/wintermute/base/particles/part_emitter.h | 6 +-- .../wintermute/base/particles/part_particle.cpp | 4 +- engines/wintermute/base/particles/part_particle.h | 2 +- engines/wintermute/base/scriptables/script.cpp | 32 +++++++------- engines/wintermute/base/scriptables/script.h | 16 +++---- engines/wintermute/base/sound/base_sound.cpp | 50 ++-------------------- engines/wintermute/base/sound/base_sound.h | 24 +++++------ .../wintermute/base/sound/base_sound_buffer.cpp | 17 +++----- engines/wintermute/base/sound/base_sound_buffer.h | 4 +- .../wintermute/base/sound/base_sound_manager.cpp | 9 ++-- engines/wintermute/base/sound/base_sound_manager.h | 2 +- 35 files changed, 117 insertions(+), 168 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 6fea297018..4d1641036a 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -1003,8 +1003,8 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename()); } - if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename); + if (_subtype == ENTITY_SOUND && _sFX && _sFX->getFilename()) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->getFilename()); buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart); buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume); } diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index d5163fa7a6..074bd0db68 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -54,7 +54,7 @@ BaseClass::~BaseClass() { ////////////////////////////////////////////////////////////////////////// -const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { +Common::String BaseClass::getEditorProp(const Common::String &propName, const Common::String &initVal) { _editorPropsIter = _editorProps.find(propName); if (_editorPropsIter != _editorProps.end()) { return _editorPropsIter->_value.c_str(); @@ -65,12 +65,12 @@ const char *BaseClass::getEditorProp(const char *propName, const char *initVal) ////////////////////////////////////////////////////////////////////////// -bool BaseClass::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) { +bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { + if (propName.size() == 0) { return STATUS_FAILED; } - if (propValue == NULL) { + if (propValue.size() == 0) { _editorProps.erase(propName); } else { _editorProps[propName] = propValue; diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index 8c6aad12e6..dcd186be42 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -43,8 +43,8 @@ class BaseDynamicBuffer; class BaseClass { public: bool _persistable; - bool setEditorProp(const char *propName, const char *propValue); - const char *getEditorProp(const char *propName, const char *initVal = NULL); + bool setEditorProp(const Common::String &propName, const Common::String &propValue); + Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); BaseClass(TDynamicConstructor, TDynamicConstructor) {}; bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index edbfe3447f..27e07790bb 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -367,8 +367,8 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); } - if (_sound && _sound->_soundFilename) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + if (_sound && _sound->getFilename()) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); } buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); @@ -431,8 +431,8 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSound") == 0) { stack->correctParams(0); - if (_sound && _sound->_soundFilename) { - stack->pushString(_sound->_soundFilename); + if (_sound && _sound->getFilename()) { + stack->pushString(_sound->getFilename()); } else { stack->pushNULL(); } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index a7ea7fe95f..fdf638f94f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1247,10 +1247,10 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { stack->pushNULL(); } else { - if (!_music[channel] || !_music[channel]->_soundFilename) { + if (!_music[channel] || !_music[channel]->getFilename()) { stack->pushNULL(); } else { - stack->pushString(_music[channel]->_soundFilename); + stack->pushString(_music[channel]->getFilename()); } } return STATUS_OK; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 00af5bd960..6ab8e60a17 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -124,10 +124,10 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa ////////////////////////////////////////////////////////////////////// -bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { - _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); if (_gameRef->_debugDebugMode) { return loadFile("invalid_debug.bmp", lifeTime, cacheType); } else { @@ -146,7 +146,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); ret = STATUS_FAILED; delete frame; delete subframe; @@ -161,13 +161,13 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { - _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); } delete[] buffer; } } - setFilename(filename); + setFilename(filename.c_str()); return ret; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 084d7b2d70..952bff0017 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -67,7 +67,7 @@ public: bool _paused; bool _finished; bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 17b5196f2a..6ce8c78b3b 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -594,7 +594,7 @@ const char *BaseSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::setSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -605,8 +605,8 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); if (_surface) { - _surfaceFilename = new char[strlen(filename) + 1]; - strcpy(_surfaceFilename, filename); + _surfaceFilename = new char[filename.size() + 1]; + strcpy(_surfaceFilename, filename.c_str()); _cKDefault = defaultCK; _cKRed = ckRed; diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 52b1d76c01..023e306706 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -41,7 +41,7 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool setSurfaceSimple(); DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) void setDefaultRect(); diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index c01c86c009..7d6f499012 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -100,17 +100,17 @@ bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { ////////////////////////////////////////////////////////////////////// -BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; } } if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) { - _gameRef->LOG(0, "Missing image: '%s'", filename); + if (filename.size()) { + _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); } if (_gameRef->_debugDebugMode) { return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 13c4deb3db..c09b0a30ab 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -44,7 +44,7 @@ public: //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); - BaseSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + BaseSurface *addSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool removeSurface(BaseSurface *surface); BaseSurfaceStorage(BaseGame *inGame); virtual ~BaseSurfaceStorage(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 5087f1752d..4a5cd31002 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -151,7 +151,7 @@ bool BaseFont::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const char *filename) { +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { if (isTrueType(gameRef, filename)) { BaseFontTT *font = new BaseFontTT(gameRef); if (font) { @@ -179,7 +179,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { +bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 695bce2af3..f1dc962565 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -48,12 +48,12 @@ public: BaseFont(BaseGame *inGame); virtual ~BaseFont(); - static BaseFont *createFromFile(BaseGame *game, const char *filename); + static BaseFont *createFromFile(BaseGame *game, const Common::String &filename); private: //bool loadBuffer(byte * Buffer); //bool loadFile(const char* Filename); - static bool isTrueType(BaseGame *game, const char *filename); + static bool isTrueType(BaseGame *game, const Common::String &filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index e2c5fa881c..e7bf362b32 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -270,19 +270,19 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadFile(const char *filename) { +bool BaseFontBitmap::loadFile(const Common::String &filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; } bool ret; - setFilename(filename); + setFilename(filename.c_str()); if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); } delete[] buffer; diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index abf2d39aa0..fb992d2e9a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -38,7 +38,7 @@ class BaseFontBitmap : public BaseFont { public: DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) bool loadBuffer(byte *Buffer); - bool loadFile(const char *filename); + bool loadFile(const Common::String &filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index bc4152131f..0c34a8822a 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -71,13 +71,13 @@ bool BaseFontStorage::initLoop() { } ////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFontStorage::addFont(const char *filename) { - if (!filename) { +BaseFont *BaseFontStorage::addFont(const Common::String &filename) { + if (!filename.size()) { return NULL; } for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { _fonts[i]->_refCount++; return _fonts[i]; } diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 3af9244ffe..3a39617c32 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -43,7 +43,7 @@ public: DECLARE_PERSISTENT(BaseFontStorage, BaseClass) bool cleanup(bool warn = false); bool removeFont(BaseFont *font); - BaseFont *addFont(const char *filename); + BaseFont *addFont(const Common::String &filename); BaseFontStorage(BaseGame *inGame); virtual ~BaseFontStorage(); BaseArray _fonts; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 2dd436dc37..793c044839 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -292,19 +292,19 @@ int BaseFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadFile(const char *filename) { +bool BaseFontTT::loadFile(const Common::String &filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; } bool ret; - setFilename(filename); + setFilename(filename.c_str()); if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); } delete[] buffer; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 20ef531a46..a893e70ec0 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -105,7 +105,7 @@ public: virtual int getLetterHeight(); bool loadBuffer(byte *buffer); - bool loadFile(const char *filename); + bool loadFile(const Common::String &filename); float getLineHeight() const { return _lineHeight; diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 62ddece47c..28ac4e6973 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -59,13 +59,6 @@ BaseSurface::~BaseSurface() { } } - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////// bool BaseSurface::restore() { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 4f67f871dd..57a51ce3aa 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -56,7 +56,7 @@ public: virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool restore(); - virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual bool create(int width, int height); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index d3209cb1c0..642f2179e6 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -90,7 +90,7 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 8e4370892b..fe1d055026 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -41,7 +41,7 @@ public: BaseSurfaceOSystem(BaseGame *inGame); ~BaseSurfaceOSystem(); - bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); bool isTransparentAt(int x, int y); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index f8c0c1a5cf..7389885f5a 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -403,11 +403,11 @@ bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int } ////////////////////////////////////////////////////////////////////////// -PartForce *PartEmitter::addForceByName(const char *name) { +PartForce *PartEmitter::addForceByName(const Common::String &name) { PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->getName()) == 0) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { force = _forces[i]; break; } @@ -415,7 +415,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { if (!force) { force = new PartForce(_gameRef); if (force) { - force->setName(name); + force->setName(name.c_str()); _forces.add(force); } } @@ -424,7 +424,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { +bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { PartForce *force = addForceByName(name); if (!force) { return STATUS_FAILED; @@ -442,9 +442,9 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos } ////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeForce(const char *name) { +bool PartEmitter::removeForce(const Common::String &name) { for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->getName()) == 0) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { delete _forces[i]; _forces.remove_at(i); return STATUS_OK; diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 4e3b837a11..438dfff521 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -57,8 +57,8 @@ public: bool setBorder(int x, int y, int width, int height); bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); + bool addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const Common::String &name); BaseArray _forces; @@ -126,7 +126,7 @@ private: char *_emitEvent; BaseScriptHolder *_owner; - PartForce *addForceByName(const char *name); + PartForce *addForceByName(const Common::String &name); int static compareZ(const void *obj1, const void *obj2); bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 0c0ec08ba9..2b05edd61f 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -70,8 +70,8 @@ PartParticle::~PartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -bool PartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->getFilename() && scumm_stricmp(filename, _sprite->getFilename()) == 0) { +bool PartParticle::setSprite(const Common::String &filename) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { _sprite->reset(); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 8b0c6eea36..44da85a559 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -72,7 +72,7 @@ public: bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); bool display(PartEmitter *emitter); - bool setSprite(const char *filename); + bool setSprite(const Common::String &filename); bool fadeIn(uint32 currentTime, int fadeTime); bool fadeOut(uint32 currentTime, int fadeTime); diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index d8d4bc66da..29185edce6 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -277,14 +277,14 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip ////////////////////////////////////////////////////////////////////////// -bool ScScript::createThread(ScScript *original, uint32 initIP, const char *eventName) { +bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { cleanup(); _thread = true; _methodThread = false; - _threadEvent = new char[strlen(eventName) + 1]; + _threadEvent = new char[eventName.size() + 1]; if (_threadEvent) { - strcpy(_threadEvent, eventName); + strcpy(_threadEvent, eventName.c_str()); } // copy filename @@ -329,7 +329,7 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event ////////////////////////////////////////////////////////////////////////// -bool ScScript::createMethodThread(ScScript *original, const char *methodName) { +bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { uint32 ip = original->getMethodPos(methodName); if (ip == 0) { return STATUS_FAILED; @@ -339,9 +339,9 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { _thread = true; _methodThread = true; - _threadEvent = new char[strlen(methodName) + 1]; + _threadEvent = new char[methodName.size() + 1]; if (_threadEvent) { - strcpy(_threadEvent, methodName); + strcpy(_threadEvent, methodName.c_str()); } // copy filename @@ -1149,9 +1149,9 @@ bool ScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getFuncPos(const char *name) { +uint32 ScScript::getFuncPos(const Common::String &name) { for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) { + if (name == _functions[i].name) { return _functions[i].pos; } } @@ -1160,9 +1160,9 @@ uint32 ScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getMethodPos(const char *name) { +uint32 ScScript::getMethodPos(const Common::String &name) { for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) { + if (name == _methods[i].name) { return _methods[i].pos; } } @@ -1357,7 +1357,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { +ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); @@ -1371,7 +1371,7 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str()); return thread; } else { delete thread; @@ -1385,9 +1385,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getEventPos(const char *name) { +uint32 ScScript::getEventPos(const Common::String &name) { for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) { + if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { return _events[i].pos; } } @@ -1396,13 +1396,13 @@ uint32 ScScript::getEventPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleEvent(const char *eventName) { +bool ScScript::canHandleEvent(const Common::String &eventName) { return getEventPos(eventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleMethod(const char *methodName) { +bool ScScript::canHandleMethod(const Common::String &methodName) { return getMethodPos(methodName) != 0; } diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 2ee1319acb..6b5fa1733b 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -62,11 +62,11 @@ public: bool _freezable; bool resume(); bool pause(); - bool canHandleEvent(const char *eventName); - bool canHandleMethod(const char *methodName); - bool createThread(ScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(ScScript *original, const char *methodName); - ScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + bool canHandleEvent(const Common::String &eventName); + bool canHandleMethod(const Common::String &methodName); + bool createThread(ScScript *original, uint32 initIP, const Common::String &eventName); + bool createMethodThread(ScScript *original, const Common::String &methodName); + ScScript *invokeEventHandler(const Common::String &eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(ScScript, BaseClass) void runtimeError(const char *fmt, ...); @@ -82,9 +82,9 @@ public: TScriptState _state; TScriptState _origState; ScValue *getVar(char *name); - uint32 getFuncPos(const char *name); - uint32 getEventPos(const char *name); - uint32 getMethodPos(const char *name); + uint32 getFuncPos(const Common::String &name); + uint32 getEventPos(const Common::String &name); + uint32 getMethodPos(const Common::String &name); typedef struct { uint32 magic; uint32 version; diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 6151128624..7e32552d08 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -35,10 +35,9 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSound, false) -////////////////////////////////////////////////////////////////////////// BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sound = NULL; - _soundFilename = NULL; + _soundFilename = ""; _soundType = Audio::Mixer::kSFXSoundType; _soundStreamed = false; @@ -54,32 +53,23 @@ BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } - -////////////////////////////////////////////////////////////////////////// BaseSound::~BaseSound() { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); } _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; } - -////////////////////////////////////////////////////////////////////////// -bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; } - delete[] _soundFilename; - _soundFilename = NULL; + _soundFilename = Common::String(); // Set empty _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); if (_sound) { - _soundFilename = new char[strlen(filename) + 1]; - strcpy(_soundFilename, filename); + _soundFilename = filename; _soundType = type; _soundStreamed = streamed; @@ -90,8 +80,6 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { @@ -112,9 +100,6 @@ bool BaseSound::setSoundSimple() { } } - - -////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getLength() { if (_sound) { return _sound->getLength(); @@ -123,8 +108,6 @@ uint32 BaseSound::getLength() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; @@ -134,8 +117,6 @@ bool BaseSound::play(bool looping) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::stop() { if (_sound) { _soundPaused = false; @@ -145,8 +126,6 @@ bool BaseSound::stop() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; @@ -159,8 +138,6 @@ bool BaseSound::pause(bool freezePaused) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; @@ -170,8 +147,6 @@ bool BaseSound::resume() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving() && _sound) { _soundPlaying = _sound->isPlaying(); @@ -205,20 +180,14 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::isPlaying() { return _sound && _sound->isPlaying(); } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::isPaused() { return _sound && _soundPaused; } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPositionTime(uint32 time) { if (!_sound) { return STATUS_FAILED; @@ -231,8 +200,6 @@ bool BaseSound::setPositionTime(uint32 time) { return ret; } - -////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getPositionTime() { if (!_sound) { return 0; @@ -245,7 +212,6 @@ uint32 BaseSound::getPositionTime() { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolumePercent(int percent) { if (!_sound) { return STATUS_FAILED; @@ -254,7 +220,6 @@ bool BaseSound::setVolumePercent(int percent) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolume(int volume) { if (!_sound) { return STATUS_FAILED; @@ -263,7 +228,6 @@ bool BaseSound::setVolume(int volume) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { if (!_sound) { return STATUS_FAILED; @@ -273,7 +237,6 @@ bool BaseSound::setPrivateVolume(int volume) { } } -////////////////////////////////////////////////////////////////////////// int BaseSound::getVolumePercent() { if (!_sound) { return 0; @@ -282,7 +245,6 @@ int BaseSound::getVolumePercent() { } } -////////////////////////////////////////////////////////////////////////// int BaseSound::getVolume() { if (!_sound) { return 0; @@ -291,7 +253,6 @@ int BaseSound::getVolume() { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setLoopStart(uint32 pos) { if (!_sound) { return STATUS_FAILED; @@ -301,7 +262,6 @@ bool BaseSound::setLoopStart(uint32 pos) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPan(float pan) { if (_sound) { return _sound->setPan(pan); @@ -310,8 +270,6 @@ bool BaseSound::setPan(float pan) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) { return STATUS_OK; diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index 7ea9f38f6c..cadba77bc8 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -40,7 +40,6 @@ class BaseSoundBuffer; class BaseSound : public BaseClass { public: bool setPan(float pan); - int _soundPrivateVolume; int getVolume(); int getVolumePercent(); bool setVolumePercent(int percent); @@ -49,31 +48,32 @@ public: bool setLoopStart(uint32 pos); uint32 getPositionTime(); bool setPositionTime(uint32 time); - bool _soundPaused; - bool _soundFreezePaused; bool isPlaying(); bool isPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; DECLARE_PERSISTENT(BaseSound, BaseClass) bool resume(); bool pause(bool freezePaused = false); bool stop(); bool play(bool looping = false); uint32 getLength(); - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - char *_soundFilename; + const char *getFilename() { return _soundFilename.c_str(); } bool setSoundSimple(); - bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); BaseSound(BaseGame *inGame); virtual ~BaseSound(); bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); - private: + Common::String _soundFilename; + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + int _soundPrivateVolume; + uint32 _soundLoopStart; + uint32 _soundPosition; + bool _soundPlaying; + bool _soundLooping; + bool _soundPaused; + bool _soundFreezePaused; TSFXType _sFXType; float _sFXParam1; float _sFXParam2; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index ed667592e9..5f36eb96d4 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -56,7 +56,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { // _sync = NULL; _streamed = false; - _filename = NULL; + _filename = ""; _file = NULL; _privateVolume = 255; _volume = 255; @@ -82,9 +82,6 @@ BaseSoundBuffer::~BaseSoundBuffer() { } delete _stream; _stream = NULL; - - delete[] _filename; - _filename = NULL; } @@ -95,13 +92,13 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block ////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { + debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename); + _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); return STATUS_FAILED; } Common::String strFilename(filename); @@ -118,16 +115,16 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _file = new Common::SeekableSubReadStream(_file, 0, waveSize); _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); } else { - error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType); } } } else { - error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str()); } if (!_stream) { return STATUS_FAILED; } - BaseUtils::setString(&_filename, filename); + _filename = filename; return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 107ceb87d7..7aec144283 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -72,7 +72,7 @@ public: void setType(Audio::Mixer::SoundType Type); - bool loadFromFile(const char *filename, bool forceReload = false); + bool loadFromFile(const Common::String &filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); @@ -89,7 +89,7 @@ public: int _privateVolume; private: uint32 _startPos; - char *_filename; + Common::String _filename; bool _streamed; Common::SeekableReadStream *_file; int _volume; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 4659c35ff7..8df9f299ef 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -89,13 +89,14 @@ bool BaseSoundMgr::initialize() { } ////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) { return NULL; } BaseSoundBuffer *sound; + Common::String useFilename = filename; // try to switch WAV to OGG file (if available) AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::compareNoCase(ext, "wav")) { @@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun AnsiString newFile = PathUtil::combine(path, name + "ogg"); if (_gameRef->_fileManager->hasFile(newFile)) { - filename = newFile.c_str(); + useFilename = newFile; } } @@ -117,9 +118,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun sound->setType(type); - bool res = sound->loadFromFile(filename); + bool res = sound->loadFromFile(useFilename); if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", filename); + _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); delete sound; return NULL; } diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 464330c733..a2b8f2c9e9 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -53,7 +53,7 @@ public: uint32 _volumeOriginal; int _volumeMaster; bool removeSound(BaseSoundBuffer *sound); - BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); bool initialize(); bool _soundAvailable; -- cgit v1.2.3 From b214041539559e65b89b3270439970fd7173dcbe Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 00:58:15 +0200 Subject: WINTERMUTE: Remove static function variable from SXArray --- engines/wintermute/base/scriptables/script_ext_array.cpp | 5 +++-- engines/wintermute/base/scriptables/script_ext_array.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 79303723e0..a422d6d8a5 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -75,7 +75,7 @@ SXArray::~SXArray() { ////////////////////////////////////////////////////////////////////////// const char *SXArray::scToString() { - static char dummy[32768]; // TODO: Get rid of static. + char dummy[32768]; strcpy(dummy, ""); char propName[20]; for (int i = 0; i < _length; i++) { @@ -91,7 +91,8 @@ const char *SXArray::scToString() { strcat(dummy, ","); } } - return dummy; + _strRep = dummy; + return _strRep.c_str(); } diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 67a1104b46..f2718f4ea2 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -48,6 +48,7 @@ public: private: int _length; ScValue *_values; + Common::String _strRep; }; } // end of namespace WinterMute -- cgit v1.2.3 From 9b5cf8f1bafd5aa0dba9194a8f04e58724652891 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 02:30:26 +0200 Subject: WINTERMUTE: Introduce a Singleton-class for holding registry/filemanager. --- engines/wintermute/ad/ad_actor.cpp | 8 +- engines/wintermute/ad/ad_entity.cpp | 4 +- engines/wintermute/ad/ad_game.cpp | 14 +-- engines/wintermute/ad/ad_inventory_box.cpp | 4 +- engines/wintermute/ad/ad_item.cpp | 4 +- engines/wintermute/ad/ad_layer.cpp | 4 +- engines/wintermute/ad/ad_region.cpp | 4 +- engines/wintermute/ad/ad_response_box.cpp | 4 +- engines/wintermute/ad/ad_rot_level.cpp | 4 +- engines/wintermute/ad/ad_scale_level.cpp | 4 +- engines/wintermute/ad/ad_scene.cpp | 4 +- engines/wintermute/ad/ad_sentence.cpp | 2 +- engines/wintermute/ad/ad_sprite_set.cpp | 4 +- engines/wintermute/ad/ad_talk_def.cpp | 4 +- engines/wintermute/ad/ad_talk_node.cpp | 2 +- engines/wintermute/ad/ad_waypoint_group.cpp | 4 +- engines/wintermute/base/base.cpp | 2 +- engines/wintermute/base/base_dynamic_buffer.cpp | 10 +- engines/wintermute/base/base_dynamic_buffer.h | 2 +- engines/wintermute/base/base_engine.cpp | 108 +++++++++++++++++++++ engines/wintermute/base/base_engine.h | 59 +++++++++++ engines/wintermute/base/base_file_manager.cpp | 28 ++++-- engines/wintermute/base/base_file_manager.h | 5 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 61 +++++------- engines/wintermute/base/base_game.h | 2 - engines/wintermute/base/base_parser.cpp | 5 +- engines/wintermute/base/base_parser.h | 5 +- .../wintermute/base/base_persistence_manager.cpp | 11 ++- engines/wintermute/base/base_persistence_manager.h | 2 +- engines/wintermute/base/base_region.cpp | 4 +- engines/wintermute/base/base_registry.cpp | 8 +- engines/wintermute/base/base_registry.h | 9 +- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 8 +- engines/wintermute/base/base_string_table.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/file/base_file.cpp | 2 +- engines/wintermute/base/file/base_file.h | 4 +- .../wintermute/base/file/base_save_thumb_file.cpp | 6 +- .../wintermute/base/file/base_save_thumb_file.h | 2 +- engines/wintermute/base/font/base_font.cpp | 9 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 10 +- engines/wintermute/base/gfx/base_image.cpp | 4 +- engines/wintermute/base/gfx/base_image.h | 2 +- .../base/gfx/osystem/base_render_osystem.cpp | 9 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 +- .../wintermute/base/particles/part_particle.cpp | 3 +- .../wintermute/base/scriptables/script_engine.cpp | 13 +-- .../base/scriptables/script_ext_file.cpp | 6 +- .../wintermute/base/sound/base_sound_buffer.cpp | 2 +- .../wintermute/base/sound/base_sound_manager.cpp | 7 +- engines/wintermute/detection.cpp | 6 +- engines/wintermute/module.mk | 3 +- engines/wintermute/ui/ui_button.cpp | 4 +- engines/wintermute/ui/ui_edit.cpp | 4 +- engines/wintermute/ui/ui_entity.cpp | 4 +- engines/wintermute/ui/ui_text.cpp | 4 +- engines/wintermute/ui/ui_tiled_image.cpp | 4 +- engines/wintermute/ui/ui_window.cpp | 4 +- engines/wintermute/video/video_theora_player.cpp | 6 +- engines/wintermute/wintermute.cpp | 13 ++- 66 files changed, 366 insertions(+), 190 deletions(-) create mode 100644 engines/wintermute/base/base_engine.cpp create mode 100644 engines/wintermute/base/base_engine.h (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index caadab18aa..b4e9d80a02 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -119,7 +119,7 @@ AdActor::~AdActor() { ////////////////////////////////////////////////////////////////////////// bool AdActor::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -221,7 +221,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) { @@ -1410,7 +1410,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_END - byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename); + byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); if (fileBuffer == NULL) { _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); return STATUS_FAILED; @@ -1419,7 +1419,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { byte *buffer = fileBuffer; byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; bool ret = STATUS_OK; diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 4d1641036a..e6fde43697 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -84,7 +84,7 @@ AdEntity::~AdEntity() { ////////////////////////////////////////////////////////////////////////// bool AdEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -198,7 +198,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) { diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 260a3fc378..e399ba5fcf 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -1241,7 +1241,7 @@ bool AdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// bool AdGame::loadFile(const char *filename) { - byte *buffer = _fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -1294,7 +1294,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { byte *params; byte *params2; int cmd = 1; - BaseParser parser(_gameRef); + BaseParser parser; bool itemFound = false, itemsFound = false; @@ -1537,7 +1537,7 @@ bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex ////////////////////////////////////////////////////////////////////////// bool AdGame::loadItemsFile(const char *filename, bool merge) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; @@ -1567,7 +1567,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (!merge) { while (_items.getSize() > 0) { @@ -1650,7 +1650,7 @@ bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { TOKEN_TABLE_END int cmd = PARSERR_GENERIC; - BaseParser parser(_gameRef); + BaseParser parser; cmd = parser.getCommand(buffer, commands, params); switch (cmd) { @@ -2130,12 +2130,12 @@ char *AdGame::findSpeechFile(char *stringID) { for (int i = 0; i < _speechDirs.getSize(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); - if (_fileManager->hasFile(ret)) { + if (BaseFileManager::getEngineInstance()->hasFile(ret)) { return ret; } sprintf(ret, "%s%s.wav", _speechDirs[i], stringID); - if (_fileManager->hasFile(ret)) { + if (BaseFileManager::getEngineInstance()->hasFile(ret)) { return ret; } } diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index bc773cbdaf..555fa8e5c2 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -164,7 +164,7 @@ bool AdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// bool AdInventoryBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -222,7 +222,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; bool alwaysVisible = false; _exclusive = false; diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 8e93ef77d4..cacafa826b 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -84,7 +84,7 @@ AdItem::~AdItem() { ////////////////////////////////////////////////////////////////////////// bool AdItem::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -166,7 +166,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) { diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index c4be6c8dfc..5742c9fc85 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -62,7 +62,7 @@ AdLayer::~AdLayer() { ////////////////////////////////////////////////////////////////////////// bool AdLayer::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -121,7 +121,7 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) { diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 7d51cfce37..5ecb24c5b7 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -54,7 +54,7 @@ AdRegion::~AdRegion() { ////////////////////////////////////////////////////////////////////////// bool AdRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -118,7 +118,7 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 7f2fdc9b3e..e321f1cd93 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -204,7 +204,7 @@ bool AdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -259,7 +259,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) { diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 753dd38190..28c37b5b81 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -53,7 +53,7 @@ AdRotLevel::~AdRotLevel() { ////////////////////////////////////////////////////////////////////////// bool AdRotLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -93,7 +93,7 @@ bool AdRotLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) { diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 465e82cbde..430be3559d 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -51,7 +51,7 @@ AdScaleLevel::~AdScaleLevel() { ////////////////////////////////////////////////////////////////////////// bool AdScaleLevel::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -91,7 +91,7 @@ bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) { diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 9a808bbb5f..b84c4c2dca 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -540,7 +540,7 @@ bool AdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// bool AdScene::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -647,7 +647,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) { diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 5126a51c80..d243aaf8e6 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -287,7 +287,7 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk"); - if (!_gameRef->_fileManager->hasFile(talkDefFileName)) { + if (!BaseFileManager::getEngineInstance()->hasFile(talkDefFileName)) { return STATUS_OK; // no talk def file found } diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 0a5949b2c0..df10418d95 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -60,7 +60,7 @@ AdSpriteSet::~AdSpriteSet() { ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -111,7 +111,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) { diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index b12a6af357..71d8d6b1c3 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -71,7 +71,7 @@ AdTalkDef::~AdTalkDef() { ////////////////////////////////////////////////////////////////////////// bool AdTalkDef::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -114,7 +114,7 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) { diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index ecaf098a40..14c1c3f459 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -94,7 +94,7 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) { diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 1188ec2fb1..0f83c2c50b 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -66,7 +66,7 @@ void AdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// bool AdWaypointGroup::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -112,7 +112,7 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) { diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 074bd0db68..8fa26f04a6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -101,7 +101,7 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 949548b68b..d953483be8 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -26,13 +26,13 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_dynamic_buffer.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { _buffer = NULL; _size = 0; _realSize = 0; @@ -80,7 +80,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) { _buffer = (byte *)malloc(initSize); if (!_buffer) { - _gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); + BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); return STATUS_FAILED; } @@ -101,7 +101,7 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { - _gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return STATUS_FAILED; } } @@ -121,7 +121,7 @@ bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { } if (_offset + size > _size) { - _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); + BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); return STATUS_FAILED; } diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 0567f874df..ff3897e71b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -34,7 +34,7 @@ namespace WinterMute { -class BaseDynamicBuffer : public BaseClass { +class BaseDynamicBuffer { public: bool _initialized; void putText(const char *fmt, ...); diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp new file mode 100644 index 0000000000..cd6e9c9e3b --- /dev/null +++ b/engines/wintermute/base/base_engine.cpp @@ -0,0 +1,108 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/wintermute.h" +#include "common/system.h" + +namespace WinterMute { + +BaseEngine *BaseEngine::_instance = 0; + /* +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; +public: + ~BaseEngine(); + BaseEngine *getInstance(); + BaseFileManager *getFileMan() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } +};*/ +BaseEngine::BaseEngine() { + +} + +void BaseEngine::init() { + _registry = new BaseRegistry(); + // File-manager depends on registry. + _fileManager = new BaseFileManager(); +} + +BaseEngine::~BaseEngine() { + delete _fileManager; + delete _registry; +} + +BaseEngine *BaseEngine::getInstance() { + if (!_instance) + assert(0); + return _instance; +} + +void BaseEngine::createInstance(const Common::String &gameid) { + if (_instance) { + delete _instance; + _instance = NULL; + } + _instance = new BaseEngine(); + _instance->_gameId = gameid; + _instance->init(); +} + +void BaseEngine::destroyInstance() { + delete _instance; + _instance = NULL; +} + +void BaseEngine::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + if (_instance && _instance->_gameRef) { + _instance->_gameRef->LOG("%s", buff); + } else { + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + } +} + +} // end of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h new file mode 100644 index 0000000000..5782c012d8 --- /dev/null +++ b/engines/wintermute/base/base_engine.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + #include "common/str.h" + +namespace WinterMute { + +class BaseFileManager; +class BaseRegistry; +class BaseGame; +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + void init(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; + Common::String _gameId; + BaseGame *_gameRef; +public: + ~BaseEngine(); + static void createInstance(const Common::String &gameid); + static BaseEngine *getInstance(); + static void destroyInstance(); + + void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } + + BaseGame *getGameRef() { return _gameRef; } + BaseFileManager *getFileManager() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } + static void LOG(bool res, const char *fmt, ...); + const char *getGameId() { return _gameId.c_str(); } +}; + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 7fe7b3ab98..83047ca75c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -27,13 +27,15 @@ */ #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" #include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" +#include "common/debug.h" #include "common/str.h" #include "common/tokenizer.h" #include "common/textconsole.h" @@ -52,7 +54,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) { +BaseFileManager::BaseFileManager() { initPaths(); registerPackages(); } @@ -145,14 +147,15 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!_gameRef) { // This function only works when the game-registry is loaded + BaseEngine *enginePtr = BaseEngine::getInstance(); + if (!enginePtr) { // This function only works when the game-registry is loaded return STATUS_FAILED; } AnsiString pathList; // single files paths - pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", ""); Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); // numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); while (!entries->empty()) { @@ -169,7 +172,7 @@ bool BaseFileManager::initPaths() { const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", ""); entries = new Common::StringTokenizer(pathList, ";"); while (!entries->empty()) { Common::String path = entries->nextToken(); @@ -268,7 +271,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(_gameRef); + BasePersistenceManager pm(BaseEngine::getInstance()->getGameId()); if (filename.size() <= 9) { return false; } @@ -320,10 +323,10 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!_gameRef) { - error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); + if (!BaseEngine::getInstance()) { + error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); } - BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef); + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); if (DID_SUCCEED(saveThumbFile->open(filename))) { ret = saveThumbFile->getMemStream(); } @@ -350,4 +353,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return NULL; } +BaseFileManager *BaseFileManager::getEngineInstance() { + if (BaseEngine::getInstance()) { + return BaseEngine::getInstance()->getFileManager(); + } + return NULL; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index c49bbe3815..23032ca65a 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -35,7 +35,6 @@ #include "common/file.h" namespace WinterMute { -class BaseGame; class BaseFileManager { public: bool cleanup(); @@ -45,10 +44,11 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(BaseGame *inGame = NULL); + BaseFileManager(); virtual ~BaseFileManager(); // Used only for detection bool registerPackages(const Common::FSList &fslist); + static BaseFileManager *getEngineInstance(); private: typedef enum { PATH_PACKAGE, @@ -67,7 +67,6 @@ private: Common::Array _openFiles; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: - BaseGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 27e07790bb..87213b1421 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -162,7 +162,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index fdf638f94f..687e394920 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -27,6 +27,7 @@ */ #include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_file_manager.h" @@ -94,7 +95,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _fontStorage = NULL; _renderer = NULL; _soundMgr = NULL; - _fileManager = NULL; _transMgr = NULL; _debugMgr = NULL; _scEngine = NULL; @@ -144,7 +144,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _useD3D = false; - _registry = new BaseRegistry(this); _stringTable = new BaseStringTable(this); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { @@ -280,7 +279,7 @@ BaseGame::~BaseGame() { getDebugMgr()->onGameShutdown(); - _registry->writeBool("System", "LastRun", true); + BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -304,8 +303,6 @@ BaseGame::~BaseGame() { //SAFE_DELETE(_keyboardState); delete _renderer; - delete _fileManager; - delete _registry; delete _stringTable; _localSaveDir = NULL; @@ -327,8 +324,6 @@ BaseGame::~BaseGame() { _debugMgr = NULL; _renderer = NULL; - _fileManager = NULL; - _registry = NULL; _stringTable = NULL; DEBUG_DebugDisable(); @@ -429,11 +424,6 @@ bool BaseGame::initialize1() { break; } - _fileManager = new BaseFileManager(this); - if (_fileManager == NULL) { - break; - } - _soundMgr = new BaseSoundMgr(this); if (_soundMgr == NULL) { break; @@ -487,7 +477,6 @@ bool BaseGame::initialize1() { delete _surfaceStorage; delete _fontStorage; delete _soundMgr; - delete _fileManager; delete _scEngine; delete _videoPlayer; return STATUS_FAILED; @@ -701,7 +690,7 @@ void BaseGame::getOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -809,7 +798,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { @@ -1560,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - _registry->writeInt("PrivateSettings", key, val); + BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1572,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal)); return STATUS_OK; } @@ -1583,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - _registry->writeString("PrivateSettings", key, val); + BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1595,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->readString("PrivateSettings", key, initVal); + AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return STATUS_OK; } @@ -1818,7 +1807,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); const char *filename = stack->pop()->getString(); - bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false + bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false stack->pushBool(exists); return STATUS_OK; } @@ -2190,7 +2179,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); bool asHex = stack->pop()->getBool(false); - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false); if (file) { crc remainder = crc_initialize(); byte buf[1024]; @@ -2214,7 +2203,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushInt(checksum); } - _fileManager->closeFile(file); + BaseFileManager::getEngineInstance()->closeFile(file); file = NULL; } else { stack->pushNULL(); @@ -2653,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -3342,7 +3331,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initSave(desc))) { if (!quickSave) { delete _saveLoadImage; @@ -3360,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - _registry->writeInt("System", "MostRecentSaveSlot", slot); + BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); } } } @@ -3412,7 +3401,7 @@ bool BaseGame::loadGame(const char *filename) { _loadInProgress = true; _indicatorDisplay = true; _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initLoad(filename))) { //if (DID_SUCCEED(ret = cleanup())) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { @@ -3628,7 +3617,7 @@ bool BaseGame::loadSettings(const char *filename) { TOKEN_TABLE_END - byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (origBuffer == NULL) { _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; @@ -3639,7 +3628,7 @@ bool BaseGame::loadSettings(const char *filename) { byte *buffer = origBuffer; byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); @@ -3699,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - _registry->setBasePath((char *)params); + BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3723,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + _settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; delete[] origBuffer; @@ -4004,7 +3993,7 @@ void BaseGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); Common::String filename = pm->getFilenameForSlot(slot); delete pm; strcpy(buffer, filename.c_str()); @@ -4018,7 +4007,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (!pm) { return STATUS_FAILED; } @@ -4039,7 +4028,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); bool ret = pm->getSaveExists(slot); delete pm; return ret; @@ -4050,7 +4039,7 @@ bool BaseGame::isSaveSlotUsed(int slot) { bool BaseGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(this); + BasePersistenceManager *pm = new BasePersistenceManager(); g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return STATUS_OK; @@ -4724,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - _registry->saveValues(); + BaseEngine::getInstance()->getRegistry()->saveValues(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 9adca0743c..40c9e254c4 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -135,7 +135,6 @@ public: bool initialize1(); bool initialize2(); bool initialize3(); - BaseFileManager *_fileManager; BaseTransitionMgr *_transMgr; BaseDebugger *getDebugMgr(); @@ -205,7 +204,6 @@ public: bool loadSettings(const char *filename); bool displayWindows(bool inGame = false); - BaseRegistry *_registry; bool _useD3D; virtual bool cleanup(); virtual bool loadGame(int slot); diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 3bd4f0441f..5dba8f9317 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/util.h" @@ -42,7 +43,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) { +BaseParser::BaseParser() { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } @@ -122,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } - _gameRef->miniUpdate(); + BaseEngine::getInstance()->getGameRef()->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 03ca71b48d..3b1979efa1 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -52,12 +52,11 @@ #define PARSERR_EOF -2 #define PARSERR_TOKENNOTFOUND -1 -#include "engines/wintermute/base/base.h" #include "engines/wintermute/coll_templ.h" namespace WinterMute { -class BaseParser : public BaseClass { +class BaseParser { public: struct TokenDesc { int32 id; @@ -67,7 +66,7 @@ public: public: int scanStr(const char *in, const char *format, ...); int32 getCommand(char **buf, TokenDesc *tokens, char **params); - BaseParser(BaseGame *inGame = NULL); + BaseParser(); virtual ~BaseParser(); private: char *getLastOffender(); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index ce7c66b7dd..2d30395928 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/platform_osystem.h" @@ -52,14 +53,18 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) { +BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { _saving = false; // _buffer = NULL; // _bufferSize = 0; _offset = 0; _saveStream = NULL; _loadStream = NULL; - _gameRef = inGame; + if (BaseEngine::getInstance()) { + _gameRef = BaseEngine::getInstance()->getGameRef(); + } else { + _gameRef = NULL; + } _richBuffer = NULL; _richBufferSize = 0; @@ -263,7 +268,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { _saving = false; _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + //_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize); if (_loadStream) { uint32 magic; magic = getDWORD(); diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index cdb29fde6b..30fac6e191 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -87,7 +87,7 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL); + BasePersistenceManager(const char *savePrefix = NULL); virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 7335d904c7..82dc359eb0 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -102,7 +102,7 @@ bool BaseRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -150,7 +150,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index afaa01f06d..495f68b486 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) { +BaseRegistry::BaseRegistry() { _iniName = NULL; setIniName("./wme.ini"); @@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; saveXml(filename, _values); } diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h index 1d67c18e85..5e235c2a68 100644 --- a/engines/wintermute/base/base_registry.h +++ b/engines/wintermute/base/base_registry.h @@ -29,11 +29,14 @@ #ifndef WINTERMUTE_BREGISTRY_H #define WINTERMUTE_BREGISTRY_H -#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/str.h" namespace WinterMute { -class BaseRegistry : public BaseClass { +class BaseRegistry { public: void setIniName(const char *name); char *getIniName(); @@ -43,7 +46,7 @@ public: int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - BaseRegistry(BaseGame *inGame); + BaseRegistry(); virtual ~BaseRegistry(); void setBasePath(const char *basePath); diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 8b71c73818..0d580e8db3 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -66,7 +66,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(_gameRef->_fileManager); + _thumbnail = new BaseImage(); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 51d1b32814..614ee7c7b8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -380,7 +380,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6ab8e60a17..bc2167c618 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -125,7 +125,7 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa ////////////////////////////////////////////////////////////////////// bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); if (!file) { _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); if (_gameRef->_debugDebugMode) { @@ -134,7 +134,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC return loadFile("invalid.bmp", lifeTime, cacheType); } } else { - _gameRef->_fileManager->closeFile(file); + BaseFileManager::getEngineInstance()->closeFile(file); file = NULL; } @@ -158,7 +158,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC ret = STATUS_OK; } } else { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); @@ -213,7 +213,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; cleanup(); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8dc9e25e4b..8fa69e5288 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -193,7 +193,7 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { } uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); if (buffer == NULL) { _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 6ce8c78b3b..333e2f4f9c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -110,7 +110,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 7d6f499012..e3c3692892 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -108,7 +108,7 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool } } - if (!_gameRef->_fileManager->hasFile(filename)) { + if (!BaseFileManager::getEngineInstance()->hasFile(filename)) { if (filename.size()) { _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); } diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 11d095e70b..185a21ad57 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) { +BaseFile::BaseFile() { _pos = 0; _size = 0; } diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 1a144414fc..0c1ab2a045 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -40,7 +40,7 @@ class SeekableReadStream; namespace WinterMute { -class BaseFile : public BaseClass { +class BaseFile { protected: uint32 _pos; uint32 _size; @@ -56,7 +56,7 @@ public: virtual bool close() = 0; virtual bool open(const Common::String &filename) = 0; virtual bool isEOF(); - BaseFile(BaseGame *inGame); + BaseFile(); virtual ~BaseFile(); // Temporary solution to allow usage in ScummVM-code: virtual Common::SeekableReadStream *getMemStream(); diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a285a93923..1f7288a6ff 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile() { _data = NULL; } @@ -70,7 +70,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename); delete[] tempFilename; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); Common::String slotFilename = pm->getFilenameForSlot(slot); if (!pm) { return STATUS_FAILED; diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 6065f10f81..d95958d95f 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -37,7 +37,7 @@ namespace WinterMute { //TODO: Get rid of this class BaseSaveThumbFile : public BaseFile { public: - BaseSaveThumbFile(BaseGame *Game); + BaseSaveThumbFile(); virtual ~BaseSaveThumbFile(); virtual bool seek(uint32 pos, int whence = SEEK_SET); virtual bool read(void *buffer, uint32 size); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 4a5cd31002..fa9242366e 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -31,7 +31,6 @@ #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_game.h" namespace WinterMute { @@ -72,7 +71,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// bool BaseFont::loadFile(const char * Filename) { - BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (Buffer==NULL){ _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -103,7 +102,7 @@ bool BaseFont::loadBuffer(byte * Buffer) char* params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); @@ -186,7 +185,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_END - byte *buffer = gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { return false; } @@ -194,7 +193,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { byte *workBuffer = buffer; char *params; - BaseParser parser(gameRef); + BaseParser parser; bool ret = false; if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index e7bf362b32..6585d7cb0a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -271,7 +271,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// bool BaseFontBitmap::loadFile(const Common::String &filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -332,7 +332,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { _gameRef->LOG(0, "'FONT' keyword expected."); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 793c044839..a141c68db7 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -293,7 +293,7 @@ int BaseFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// bool BaseFontTT::loadFile(const Common::String &filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -348,7 +348,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { _gameRef->LOG(0, "'TTFONT' keyword expected."); @@ -451,7 +451,7 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -538,13 +538,13 @@ bool BaseFontTT::initFont() { return STATUS_FAILED; } - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile); if (!file) { //TODO: Try to fallback from Arial to FreeSans /* // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 1fff59d85b..2167503dc8 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -42,8 +42,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage(BaseFileManager *fileManager) { - _fileManager = fileManager; +BaseImage::BaseImage() { + _fileManager = BaseFileManager::getEngineInstance(); _palette = NULL; _surface = NULL; _decoder = NULL; diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index ed0142ea95..76a389977d 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -42,7 +42,7 @@ class BaseFileManager; class BaseImage { public: - BaseImage(BaseFileManager *fileManager); + BaseImage(); ~BaseImage(); bool loadFile(const Common::String &filename); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 58839d5ffe..51b0c2dd36 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -126,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); - _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); + _realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width); + _realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; @@ -152,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO + //_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); @@ -496,7 +497,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Clip by viewport. warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); - BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); + BaseImage *screenshot = new BaseImage(); screenshot->copyFrom(_renderSurface); return screenshot; } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 642f2179e6..c449f6471c 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -119,7 +119,7 @@ bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, } bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(_gameRef->_fileManager); + BaseImage *image = new BaseImage(); if (!image->loadFile(_filename)) { return false; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 7389885f5a..ced01b7fd9 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -128,12 +128,12 @@ bool PartEmitter::addSprite(const char *filename) { } // check if file exists - Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); if (!File) { _gameRef->LOG(0, "Sprite '%s' not found", filename); return STATUS_FAILED; } else { - _gameRef->_fileManager->closeFile(File); + BaseFileManager::getEngineInstance()->closeFile(File); } char *str = new char[strlen(filename) + 1]; diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 2b05edd61f..1a449a50a5 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" @@ -80,7 +79,7 @@ bool PartParticle::setSprite(const Common::String &filename) { _sprite = NULL; SystemClassRegistry::getInstance()->_disabled = true; - _sprite = new BaseSprite(_gameRef, _gameRef); + _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { SystemClassRegistry::getInstance()->_disabled = false; return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 01f647c110..9e11a7c5b4 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_ext_math.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_file_manager.h" @@ -128,7 +129,7 @@ bool ScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { BaseGame *gameRef = (BaseGame *)data; - return gameRef->_fileManager->readWholeFile(filename, size); + return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); } @@ -200,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size); if (!buffer) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; @@ -689,10 +690,10 @@ bool ScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - _gameRef->_registry->writeString("Debug", key, text); + BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text); } } - _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count); return STATUS_OK; } @@ -705,11 +706,11 @@ bool ScEngine::loadBreakpoints() { char key[100]; - int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, ""); char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 5743722d6f..50d89921e1 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -82,7 +82,7 @@ void SXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// void SXFile::close() { if (_readFile) { - _gameRef->_fileManager->closeFile(_readFile); + BaseFileManager::getEngineInstance()->closeFile(_readFile); _readFile = NULL; } if (_writeFile) { @@ -130,7 +130,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, _mode = 1; } if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); close(); @@ -785,7 +785,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { if (_mode != 0) { // open for reading if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); if (!_readFile) { close(); } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 5f36eb96d4..ac329704bc 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -96,7 +96,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. - _file = _gameRef->_fileManager->openFile(filename, true, false); + _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); if (!_file) { _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); return STATUS_FAILED; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 8df9f299ef..61c7376c79 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_game.h" @@ -71,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); } } @@ -82,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; return STATUS_OK; @@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M AnsiString name = PathUtil::getFileNameWithoutExtension(filename); AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (_gameRef->_fileManager->hasFile(newFile)) { + if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { useFilename = newFile; } } diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 58b6c5df90..269ab28601 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -169,7 +169,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::BasePersistenceManager pm(NULL, target); + WinterMute::BasePersistenceManager pm(target); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -185,12 +185,12 @@ public: } void removeSaveState(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(NULL, target); + WinterMute::BasePersistenceManager pm(target); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(NULL, target); + WinterMute::BasePersistenceManager pm(target); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 02ba08f255..87f08242d5 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -63,10 +63,11 @@ MODULE_OBJS := \ base/base.o \ base/base_debugger.o \ base/base_dynamic_buffer.o \ + base/base_engine.o \ base/base_fader.o \ base/base_file_manager.o \ - base/base_game.o \ base/base_frame.o \ + base/base_game.o \ base/base_keyboard_state.o \ base/base_named_object.o \ base/base_object.o \ diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 3352f9355d..fb125ef94c 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -102,7 +102,7 @@ UIButton::~UIButton() { ////////////////////////////////////////////////////////////////////////// bool UIButton::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -203,7 +203,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) { diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 1483c46475..88c68a3314 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -93,7 +93,7 @@ UIEdit::~UIEdit() { ////////////////////////////////////////////////////////////////////////// bool UIEdit::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -166,7 +166,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) { diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 71b573fc92..8008e96050 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -58,7 +58,7 @@ UIEntity::~UIEntity() { ////////////////////////////////////////////////////////////////////////// bool UIEntity::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -108,7 +108,7 @@ bool UIEntity::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 5ead4ad6f3..56fea4edf9 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -103,7 +103,7 @@ bool UIText::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIText::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -172,7 +172,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) { diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index f54ba7843e..62c07bf1d7 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -121,7 +121,7 @@ bool UITiledImage::display(int x, int y, int width, int height) { ////////////////////////////////////////////////////////////////////////// bool UITiledImage::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -181,7 +181,7 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; bool hTiles = false, vTiles = false; int h1 = 0, h2 = 0, h3 = 0; int v1 = 0, v2 = 0, v3 = 0; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 0a2ec6b389..4f3ee9ff43 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -238,7 +238,7 @@ bool UIWindow::display(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -339,7 +339,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd = 2; - BaseParser parser(_gameRef); + BaseParser parser; int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0; int ar = 0, ag = 0, ab = 0, alpha = 0; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index dad456f431..ad99e24534 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -103,7 +103,7 @@ VideoTheoraPlayer::~VideoTheoraPlayer(void) { ////////////////////////////////////////////////////////////////////////// void VideoTheoraPlayer::cleanup() { if (_file) { - _gameRef->_fileManager->closeFile(_file); + BaseFileManager::getEngineInstance()->closeFile(_file); _file = NULL; } @@ -121,7 +121,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: cleanup(); _filename = filename; - _file = _gameRef->_fileManager->openFile(filename, true, false); + _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); if (!_file) { return STATUS_FAILED; } @@ -378,7 +378,7 @@ bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("VideoTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; - _alphaImage = new BaseImage(_gameRef->_fileManager); + _alphaImage = new BaseImage(); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 8e782a2444..f2e811b45e 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -35,6 +35,7 @@ #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/sound/base_sound_manager.h" @@ -88,7 +89,7 @@ WinterMuteEngine::~WinterMuteEngine() { debug("WinterMuteEngine::~WinterMuteEngine"); // Dispose your resources here - delete _classReg; + deinit(); delete _rnd; delete _game; g_wintermute = NULL; @@ -157,9 +158,10 @@ Common::Error WinterMuteEngine::run() { int WinterMuteEngine::init() { _classReg = new SystemClassRegistry(); _classReg->registerClasses(); - + BaseEngine::createInstance(_targetName); _game = new AdGame(_targetName); if (!_game) return 1; + BaseEngine::getInstance()->setGameRef(_game); BasePlatform::initialize(_game, 0, NULL); bool windowedMode = !ConfMan.getBool("fullscreen"); @@ -192,11 +194,11 @@ int WinterMuteEngine::init() { }*/ - if (_game->_registry->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); + if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); - _game->_debugShowFPS = _game->_registry->readBool("Debug", "ShowFPS"); + _game->_debugShowFPS = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "ShowFPS"); - if (_game->_registry->readBool("Debug", "DisableSmartCache")) { + if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DisableSmartCache")) { _game->LOG(0, "Smart cache is DISABLED"); _game->_smartCache = false; } @@ -335,6 +337,7 @@ int WinterMuteEngine::messageLoop() { void WinterMuteEngine::deinit() { delete _classReg; _classReg = NULL; + BaseEngine::destroyInstance(); } bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { -- cgit v1.2.3 From 482a5fb467e6694fb54c75f718563992657edf97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 02:59:14 +0200 Subject: WINTERMUTE: Make the BaseEngine-singleton use Common::Singleton as super-class --- engines/wintermute/base/base_engine.cpp | 47 ++++++---------------- engines/wintermute/base/base_engine.h | 9 ++--- engines/wintermute/base/base_file_manager.cpp | 15 ++++--- engines/wintermute/base/base_game.cpp | 22 +++++----- engines/wintermute/base/base_parser.cpp | 2 +- .../wintermute/base/base_persistence_manager.cpp | 9 +++-- engines/wintermute/base/base_persistence_manager.h | 3 +- engines/wintermute/base/base_registry.cpp | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 6 +-- .../wintermute/base/scriptables/script_engine.cpp | 11 +++-- .../wintermute/base/sound/base_sound_manager.cpp | 4 +- engines/wintermute/detection.cpp | 6 +-- engines/wintermute/wintermute.cpp | 11 ++--- 13 files changed, 63 insertions(+), 86 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index cd6e9c9e3b..0185d973fa 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -32,24 +32,17 @@ #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" +namespace Common { +DECLARE_SINGLETON(WinterMute::BaseEngine); +} namespace WinterMute { -BaseEngine *BaseEngine::_instance = 0; - /* -class BaseEngine { - static BaseEngine *_instance; - BaseEngine(); - BaseFileManager *_fileManager; - BaseRegistry *_registry; -public: - ~BaseEngine(); - BaseEngine *getInstance(); - BaseFileManager *getFileMan() { return _fileManager; } - BaseRegistry *getRegistry() { return _registry; } -};*/ BaseEngine::BaseEngine() { - + _fileManager = NULL; + _registry = NULL; + _gameRef = NULL; + _gameId = ""; } void BaseEngine::init() { @@ -63,25 +56,9 @@ BaseEngine::~BaseEngine() { delete _registry; } -BaseEngine *BaseEngine::getInstance() { - if (!_instance) - assert(0); - return _instance; -} - void BaseEngine::createInstance(const Common::String &gameid) { - if (_instance) { - delete _instance; - _instance = NULL; - } - _instance = new BaseEngine(); - _instance->_gameId = gameid; - _instance->init(); -} - -void BaseEngine::destroyInstance() { - delete _instance; - _instance = NULL; + instance()._gameId = gameid; + instance().init(); } void BaseEngine::LOG(bool res, const char *fmt, ...) { @@ -98,11 +75,11 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { vsprintf(buff, fmt, va); va_end(va); - if (_instance && _instance->_gameRef) { - _instance->_gameRef->LOG("%s", buff); + if (instance()._gameRef) { + instance()._gameRef->LOG("%s", buff); } else { debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); } } -} // end of namespace WinterMute \ No newline at end of file +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 5782c012d8..d45d979f25 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -27,26 +27,23 @@ */ #include "common/str.h" + #include "common/singleton.h" namespace WinterMute { class BaseFileManager; class BaseRegistry; class BaseGame; -class BaseEngine { - static BaseEngine *_instance; - BaseEngine(); +class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; BaseRegistry *_registry; Common::String _gameId; BaseGame *_gameRef; public: + BaseEngine(); ~BaseEngine(); static void createInstance(const Common::String &gameid); - static BaseEngine *getInstance(); - static void destroyInstance(); - void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } BaseGame *getGameRef() { return _gameRef; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 83047ca75c..801729c5e8 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -147,15 +147,14 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - BaseEngine *enginePtr = BaseEngine::getInstance(); - if (!enginePtr) { // This function only works when the game-registry is loaded + if (!BaseEngine::instance().getRegistry()) { // This function only works when the game-registry is loaded return STATUS_FAILED; } AnsiString pathList; // single files paths - pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", ""); + pathList = BaseEngine::instance().getRegistry()->readString("Resource", "CustomPaths", ""); Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); // numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); while (!entries->empty()) { @@ -172,7 +171,7 @@ bool BaseFileManager::initPaths() { const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", ""); + pathList = BaseEngine::instance().getRegistry()->readString("Resource", "PackagePaths", ""); entries = new Common::StringTokenizer(pathList, ";"); while (!entries->empty()) { Common::String path = entries->nextToken(); @@ -271,7 +270,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(BaseEngine::getInstance()->getGameId()); + BasePersistenceManager pm(BaseEngine::instance().getGameId()); if (filename.size() <= 9) { return false; } @@ -323,7 +322,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!BaseEngine::getInstance()) { + if (!BaseEngine::instance().getGameRef()) { error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); } BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); @@ -354,8 +353,8 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f } BaseFileManager *BaseFileManager::getEngineInstance() { - if (BaseEngine::getInstance()) { - return BaseEngine::getInstance()->getFileManager(); + if (BaseEngine::instance().getFileManager()) { + return BaseEngine::instance().getFileManager(); } return NULL; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 687e394920..6fea190e01 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -279,7 +279,7 @@ BaseGame::~BaseGame() { getDebugMgr()->onGameShutdown(); - BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true); + BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -1549,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val); + BaseEngine::instance().getRegistry()->writeInt("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1561,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal)); + stack->pushInt(BaseEngine::instance().getRegistry()->readInt("PrivateSettings", key, initVal)); return STATUS_OK; } @@ -1572,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val); + BaseEngine::instance().getRegistry()->writeString("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1584,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal); + AnsiString val = BaseEngine::instance().getRegistry()->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return STATUS_OK; } @@ -2642,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(BaseEngine::instance().getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -3349,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); + BaseEngine::instance().getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); } } } @@ -3688,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params); + BaseEngine::instance().getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3712,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); + _settingsAllowWindowed = BaseEngine::instance().getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = BaseEngine::instance().getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; delete[] origBuffer; @@ -4713,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - BaseEngine::getInstance()->getRegistry()->saveValues(); + BaseEngine::instance().getRegistry()->saveValues(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 5dba8f9317..5d5a2d534d 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -123,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } - BaseEngine::getInstance()->getGameRef()->miniUpdate(); + BaseEngine::instance().getGameRef()->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 2d30395928..ddc5e15d92 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -53,15 +53,16 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { +BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { _saving = false; // _buffer = NULL; // _bufferSize = 0; _offset = 0; _saveStream = NULL; _loadStream = NULL; - if (BaseEngine::getInstance()) { - _gameRef = BaseEngine::getInstance()->getGameRef(); + _deleteSingleton = deleteSingleton; + if (BaseEngine::instance().getGameRef()) { + _gameRef = BaseEngine::instance().getGameRef(); } else { _gameRef = NULL; } @@ -89,6 +90,8 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { ////////////////////////////////////////////////////////////////////////// BasePersistenceManager::~BasePersistenceManager() { cleanup(); + if (_deleteSingleton) + BaseEngine::destroy(); } diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 30fac6e191..87892b42f3 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -87,7 +87,7 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - BasePersistenceManager(const char *savePrefix = NULL); + BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); @@ -95,6 +95,7 @@ public: byte *_thumbnailData; Common::String getFilenameForSlot(int slot) const; private: + bool _deleteSingleton; bool readHeader(const Common::String &filename); TimeDate getTimeDate(); bool putTimeDate(const TimeDate &t); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 495f68b486..d03691ea42 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; saveXml(filename, _values); } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 51b0c2dd36..6e18aaba29 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -127,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width); - _realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height); + _realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); + _realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; @@ -153,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO + //_windowed = BaseEngine::instance().getRegistry()->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 9e11a7c5b4..96250dbb90 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -128,7 +128,6 @@ bool ScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { - BaseGame *gameRef = (BaseGame *)data; return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); } @@ -201,7 +200,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig uint32 size; - byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size); + byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); if (!buffer) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; @@ -690,10 +689,10 @@ bool ScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text); + BaseEngine::instance().getRegistry()->writeString("Debug", key, text); } } - BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count); + BaseEngine::instance().getRegistry()->writeInt("Debug", "NumBreakpoints", count); return STATUS_OK; } @@ -706,11 +705,11 @@ bool ScEngine::loadBreakpoints() { char key[100]; - int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0); + int count = BaseEngine::instance().getRegistry()->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, ""); + AnsiString breakpoint = BaseEngine::instance().getRegistry()->readString("Debug", key, ""); char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 61c7376c79..03f6fffb58 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -72,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); + BaseEngine::instance().getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); } } @@ -83,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255); + _volumeMaster = BaseEngine::instance().getRegistry()->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; return STATUS_OK; diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 269ab28601..af2560fcf2 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -169,7 +169,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::BasePersistenceManager pm(target); + WinterMute::BasePersistenceManager pm(target, true); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -185,12 +185,12 @@ public: } void removeSaveState(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(target); + WinterMute::BasePersistenceManager pm(target, true); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(target); + WinterMute::BasePersistenceManager pm(target, true); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index f2e811b45e..8e07569bf7 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -161,7 +161,7 @@ int WinterMuteEngine::init() { BaseEngine::createInstance(_targetName); _game = new AdGame(_targetName); if (!_game) return 1; - BaseEngine::getInstance()->setGameRef(_game); + BaseEngine::instance().setGameRef(_game); BasePlatform::initialize(_game, 0, NULL); bool windowedMode = !ConfMan.getBool("fullscreen"); @@ -194,11 +194,11 @@ int WinterMuteEngine::init() { }*/ - if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); + if (BaseEngine::instance().getRegistry()->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); - _game->_debugShowFPS = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "ShowFPS"); + _game->_debugShowFPS = BaseEngine::instance().getRegistry()->readBool("Debug", "ShowFPS"); - if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DisableSmartCache")) { + if (BaseEngine::instance().getRegistry()->readBool("Debug", "DisableSmartCache")) { _game->LOG(0, "Smart cache is DISABLED"); _game->_smartCache = false; } @@ -337,7 +337,7 @@ int WinterMuteEngine::messageLoop() { void WinterMuteEngine::deinit() { delete _classReg; _classReg = NULL; - BaseEngine::destroyInstance(); + BaseEngine::destroy(); } bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { @@ -418,6 +418,7 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String delete stream; } delete fileMan; + BaseEngine::destroy(); return retVal; } -- cgit v1.2.3 From 3a218180017e97e4b9dceca3bf25a232f271c6b9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 03:41:45 +0200 Subject: WINTERMUTE: Make BaseSubFrame load lazily. --- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 43 ++++++++++++++++++++------- engines/wintermute/base/base_sub_frame.h | 8 ++++- engines/wintermute/base/gfx/base_renderer.cpp | 8 ++--- 5 files changed, 45 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 87213b1421..5473419f22 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -321,7 +321,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (BasePlatform::isRectEmpty(&rect)) { sub->setDefaultRect(); } else { - sub->_rect = rect; + sub->setRect(rect); } sub->_hotspotX = hotspotX; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index bc2167c618..bc42f81dd4 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -151,7 +151,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC delete frame; delete subframe; } else { - BasePlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + subframe->setDefaultRect(); frame->_subframes.add(subframe); _frames.add(frame); _currentFrame = 0; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 333e2f4f9c..006f15fa2c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -48,6 +48,7 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _alpha = 0xFFFFFFFF; _transparent = 0xFFFF00FF; + _wantsDefaultRect = false; BasePlatform::setRectEmpty(&_rect); _editorSelected = false; @@ -205,12 +206,25 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (BasePlatform::isRectEmpty(&rect)) { setDefaultRect(); } else { - _rect = rect; + setRect(rect); } return STATUS_OK; } +Rect32 BaseSubFrame::getRect() { + if (_wantsDefaultRect && _surface) { + BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _wantsDefaultRect = false; + } + return _rect; +} + +void BaseSubFrame::setRect(Rect32 rect) { + _wantsDefaultRect = false; + _rect = rect; +} + ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { @@ -220,9 +234,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) { @@ -237,12 +251,12 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl } if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); } else { if (zoomX == 100 && zoomY == 100) { - res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY); } else { - res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); } } @@ -262,8 +276,8 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo BasePlatform::setRect(rect, (int)(x - _hotspotX * ratioX), (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), + (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); return true; } @@ -287,8 +301,8 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple if (_surface) { BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); } - if (!(rect == _rect)) { - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + if (!(rect == getRect())) { + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", getRect().left, getRect().top, getRect().right, getRect().bottom); } if (_hotspotX != 0 || _hotspotY != 0) { @@ -338,8 +352,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple ////////////////////////////////////////////////////////////////////////// void BaseSubFrame::setDefaultRect() { if (_surface) { - BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _wantsDefaultRect = true; } else { + _wantsDefaultRect = false; BasePlatform::setRectEmpty(&_rect); } } @@ -350,6 +365,12 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); + if (persistMgr->getIsSaving()) { + getRect(); // To make sure it gets updated if it was never loaded. + } else { + _wantsDefaultRect = false; + } + persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); persistMgr->transfer(TMEMBER(_alpha)); diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 023e306706..d8027d3ce9 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -58,8 +58,14 @@ public: int _hotspotX; int _hotspotY; uint32 _alpha; + // These two setters and getters are rather usefull, as they allow _rect to be lazily defined + // Thus we don't need to load the actual graphics before the rect is actually needed. + Rect32 getRect(); + void setRect(Rect32 rect); +private: + bool _wantsDefaultRect; Rect32 _rect; - +public: bool _cKDefault; byte _cKRed; byte _cKGreen; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index ab5111332e..cc6167a749 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -76,16 +76,16 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { - int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + int xx = (int)((_rectList[i]->_frame->getRect().left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->getRect().top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); if (_rectList[i]->_frame->_mirrorX) { - int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + int width = _rectList[i]->_frame->getRect().right - _rectList[i]->_frame->getRect().left; xx = width - xx; } if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().top; yy = height - yy; } -- cgit v1.2.3 From da0ba41903bf50c3a6cb2923ca943386cd984f8c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 14:56:39 +0200 Subject: WINTERMUTE: Remove more unused utils. --- engines/wintermute/utils/utils.cpp | 72 -------------------------------------- engines/wintermute/utils/utils.h | 3 -- 2 files changed, 75 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 05aa34f95f..6571147a80 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -91,18 +91,6 @@ char *BaseUtils::setString(char **string, const char *value) { return *string; } -////////////////////////////////////////////////////////////////////////// -int BaseUtils::strNumEntries(const char *str, const char delim) { - int numEntries = 1; - for (uint32 i = 0; i < strlen(str); i++) { - if (str[i] == delim) { - numEntries++; - } - } - return numEntries; -} - - ////////////////////////////////////////////////////////////////////////// char *BaseUtils::strEntry(int entry, const char *str, const char delim) { int numEntries = 0; @@ -157,66 +145,6 @@ float BaseUtils::randomAngle(float from, float to) { return normalizeAngle(randomFloat(from, to)); } -////////////////////////////////////////////////////////////////////////// -bool BaseUtils::matchesPattern(const char *pattern, const char *string) { - char stringc, patternc; - - for (;; ++string) { - stringc = toupper(*string); - patternc = toupper(*pattern++); - - switch (patternc) { - case 0: - return (stringc == 0); - - case '?': - if (stringc == 0) { - return false; - } - break; - - case '*': - if (!*pattern) { - return true; - } - - if (*pattern == '.') { - char *dot; - if (pattern[1] == '*' && pattern[2] == 0) { - return true; - } - dot = (char *)strchr(string, '.'); - if (pattern[1] == 0) { - return (dot == NULL || dot[1] == 0); - } - if (dot != NULL) { - string = dot; - if (strpbrk(pattern, "*?[") == NULL && strchr(string + 1, '.') == NULL) { - return(scumm_stricmp(pattern + 1, string + 1) == 0); - } - } - } - - while (*string) - if (BaseUtils::matchesPattern(pattern, string++)) { - return true; - } - return false; - - default: - if (patternc != stringc) { - if (patternc == '.' && stringc == 0) { - return(BaseUtils::matchesPattern(pattern, string)); - } else { - return false; - } - } - break; - } - } -} - - ////////////////////////////////////////////////////////////////////////// void BaseUtils::RGBtoHSL(uint32 rgbColor, byte *outH, byte *outS, byte *outL) { float varR = (RGBCOLGetR(rgbColor) / 255.0f); diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 5b3ce65470..36a7398869 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -46,15 +46,12 @@ public: static void debugMessage(const char *text); static char *setString(char **string, const char *value); - static int strNumEntries(const char *str, const char delim = ','); static char *strEntry(int entry, const char *str, const char delim = ','); static int randomInt(int from, int to); static float randomFloat(float from, float to); static float randomAngle(float from, float to); - static bool matchesPattern(const char *pattern, const char *string); - static void RGBtoHSL(uint32 rgbColor, byte *outH, byte *outS, byte *outL); static uint32 HSLtoRGB(byte H, byte S, byte L); -- cgit v1.2.3 From 1f5288d8c17bb65d623e96ab66833ba548c26e70 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 15:03:54 +0200 Subject: WINTERMUTE: Use ConfMan instead of registry. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 3 ++- engines/wintermute/base/sound/base_sound_manager.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 6e18aaba29..8e6c6bb83c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -38,6 +38,7 @@ #include "common/system.h" #include "engines/wintermute/graphics/transparent_surface.h" #include "common/queue.h" +#include "common/config-manager.h" namespace WinterMute { @@ -153,7 +154,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = BaseEngine::instance().getRegistry()->readBool("Video", "Windowed", true); TODO + _windowed = !ConfMan.getBool("fullscreen"); Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 03f6fffb58..43109443a7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -72,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - BaseEngine::instance().getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); + ConfMan.setInt("master_volume", _volumeMaster); } } @@ -83,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = BaseEngine::instance().getRegistry()->readInt("Audio", "MasterVolume", 255); + _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); _soundAvailable = true; return STATUS_OK; -- cgit v1.2.3 From aa3467ddaa4b1df72398a1545c9d8b1c89dad6ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 15:30:44 +0200 Subject: WINTERMUTE: Remove the debugger. --- engines/wintermute/base/base_debugger.cpp | 203 --------------------- engines/wintermute/base/base_debugger.h | 95 ---------- engines/wintermute/base/base_game.cpp | 34 ---- engines/wintermute/base/base_game.h | 3 - engines/wintermute/base/base_script_holder.cpp | 3 - engines/wintermute/base/base_scriptable.cpp | 13 -- engines/wintermute/base/base_scriptable.h | 9 +- engines/wintermute/base/scriptables/script.cpp | 115 ------------ engines/wintermute/base/scriptables/script.h | 13 +- .../wintermute/base/scriptables/script_engine.cpp | 181 +----------------- .../wintermute/base/scriptables/script_engine.h | 14 -- .../wintermute/base/scriptables/script_value.cpp | 136 -------------- engines/wintermute/base/scriptables/script_value.h | 30 +-- engines/wintermute/module.mk | 1 - engines/wintermute/wintermute.cpp | 3 - engines/wintermute/wme_debugger.h | 172 ----------------- 16 files changed, 4 insertions(+), 1021 deletions(-) delete mode 100644 engines/wintermute/base/base_debugger.cpp delete mode 100644 engines/wintermute/base/base_debugger.h delete mode 100644 engines/wintermute/wme_debugger.h (limited to 'engines') diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp deleted file mode 100644 index ef4f1ce686..0000000000 --- a/engines/wintermute/base/base_debugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_debugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -BaseDebugger::BaseDebugger(BaseGame *inGame) : BaseClass(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -BaseDebugger::~BaseDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::initialize() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::shutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameInit() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameShutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameTick() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onLog(unsigned int errorCode, const char *text) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptInit(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptShutdown(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptChangeLine(ScScript *script, int Line) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptChangeScope(ScScript *script, ScValue *scope) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptShutdownScope(ScScript *script, ScValue *scope) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onVariableChangeValue(ScValue *var, ScValue *value) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptHitBreakpoint(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool BaseDebugger::attachClient(IWmeDebugClient *client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::detachClient(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::queryData(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseDebugger::getPropInt(const char *propName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double BaseDebugger::getPropFloat(const char *propName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *BaseDebugger::getPropString(const char *propName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::getPropBool(const char *propName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, int propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, double propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, const char *propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, bool propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::addBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::removeBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::continueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h deleted file mode 100644 index 7266e073d8..0000000000 --- a/engines/wintermute/base/base_debugger.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/wme_debugger.h" - -// TODO: The entire debugger should possibly be removed - -namespace WinterMute { -class ScScript; -class ScValue; -class BaseDebugger : public BaseClass, public IWmeDebugServer { -public: - BaseDebugger(BaseGame *inGame); - virtual ~BaseDebugger(void); - - // initialization - bool _enabled; - bool initialize(); - bool shutdown(); - - // internal interface - bool onGameInit(); - bool onGameShutdown(); - bool onGameTick(); - bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(ScScript *script); - bool onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name); - - bool onScriptShutdown(ScScript *script); - bool onScriptChangeLine(ScScript *script, int line); - bool onScriptChangeScope(ScScript *script, ScValue *scope); - bool onScriptShutdownScope(ScScript *script, ScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName); - bool onVariableChangeValue(ScValue *var, ScValue *value); - - bool onScriptHitBreakpoint(ScScript *script); - - // IWmeDebugServer interface - virtual bool attachClient(IWmeDebugClient *client); - virtual bool detachClient(IWmeDebugClient *client); - virtual bool queryData(IWmeDebugClient *client); - - virtual int getPropInt(const char *propName); - virtual double getPropFloat(const char *propName); - virtual const char *getPropString(const char *propName); - virtual bool getPropBool(const char *propName); - - virtual bool setProp(const char *propName, int propValue); - virtual bool setProp(const char *propName, double propValue); - virtual bool setProp(const char *propName, const char *propValue); - virtual bool setProp(const char *propName, bool propValue); - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - - virtual bool addBreakpoint(const char *scriptFilename, int line); - virtual bool removeBreakpoint(const char *scriptFilename, int line); - - virtual bool continueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 6fea190e01..062f92ccae 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -96,7 +96,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _renderer = NULL; _soundMgr = NULL; _transMgr = NULL; - _debugMgr = NULL; _scEngine = NULL; _keyboardState = NULL; @@ -277,8 +276,6 @@ BaseGame::~BaseGame() { LOG(0, ""); LOG(0, "Shutting down..."); - getDebugMgr()->onGameShutdown(); - BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -299,7 +296,6 @@ BaseGame::~BaseGame() { delete _videoPlayer; delete _theoraPlayer; delete _soundMgr; - delete _debugMgr; //SAFE_DELETE(_keyboardState); delete _renderer; @@ -321,7 +317,6 @@ BaseGame::~BaseGame() { _videoPlayer = NULL; _theoraPlayer = NULL; _soundMgr = NULL; - _debugMgr = NULL; _renderer = NULL; _stringTable = NULL; @@ -429,11 +424,6 @@ bool BaseGame::initialize1() { break; } - _debugMgr = new BaseDebugger(this); - if (_debugMgr == NULL) { - break; - } - _mathClass = new SXMath(this); if (_mathClass == NULL) { break; @@ -473,7 +463,6 @@ bool BaseGame::initialize1() { delete _mathClass; delete _keyboardState; delete _transMgr; - delete _debugMgr; delete _surfaceStorage; delete _fontStorage; delete _soundMgr; @@ -578,9 +567,6 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } - if (_debugMgr) { - _debugMgr->onLog(res, buff); - } debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); @@ -604,7 +590,6 @@ bool BaseGame::initLoop() { _currentTime = g_system->getMillis(); - getDebugMgr()->onGameTick(); _renderer->initLoop(); updateMusicCrossfade(); @@ -3234,11 +3219,6 @@ bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Debug") == 0) { stack->correctParams(0); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); - script->sleep(0); - } stack->pushNULL(); } @@ -3382,7 +3362,6 @@ bool BaseGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->onGameShutdown(); bool ret; @@ -3413,8 +3392,6 @@ bool BaseGame::loadGame(const char *filename) { displayContent(true, false); //_renderer->flip(); - - getDebugMgr()->onGameInit(); } } } @@ -3440,8 +3417,6 @@ bool BaseGame::initAfterLoad() { SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); - _scEngine->refreshScriptBreakpoints(); - return STATUS_OK; } @@ -4613,15 +4588,6 @@ bool BaseGame::displayDebugInfo() { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -BaseDebugger *BaseGame::getDebugMgr() { - if (!_debugMgr) { - _debugMgr = new BaseDebugger(this); - } - return _debugMgr; -} - - ////////////////////////////////////////////////////////////////////////// void BaseGame::getMousePos(Point32 *pos) { BasePlatform::getCursorPos(pos); diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 40c9e254c4..fd20608a42 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -#include "engines/wintermute/base/base_debugger.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/persistent.h" @@ -136,7 +135,6 @@ public: bool initialize2(); bool initialize3(); BaseTransitionMgr *_transMgr; - BaseDebugger *getDebugMgr(); void LOG(bool res, const char *fmt, ...); @@ -354,7 +352,6 @@ private: bool isVideoPlaying(); bool stopVideo(); - BaseDebugger *_debugMgr; BaseArray _quickMessages; BaseArray _windows; BaseArray _viewportStack; diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 614ee7c7b8..19bd82f2b0 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -319,7 +319,6 @@ bool BaseScriptHolder::addScript(const char *filename) { scr->_owner = this; _scripts.add(scr); _gameRef->_scEngine->_scripts.add(scr); - _gameRef->getDebugMgr()->onScriptInit(scr); return STATUS_OK; } @@ -469,8 +468,6 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { bool ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { _scripts[i]->_engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); - return thread; } else { delete thread; diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 743805cad7..11092427be 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -188,17 +188,4 @@ ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptable::dbgGetNativeClass() { - return getClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *BaseScriptable::dbgGetProperty(const char *name) { - return scGetProperty(name); -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index b9283ed349..6227b84649 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -31,7 +31,6 @@ #include "engines/wintermute/base/base_named_object.h" -#include "engines/wintermute/wme_debugger.h" #include "engines/wintermute/persistent.h" namespace WinterMute { @@ -40,7 +39,7 @@ class ScValue; class ScStack; class ScScript; -class BaseScriptable : public BaseNamedObject, public IWmeDebugObject { +class BaseScriptable : public BaseNamedObject { public: virtual ScScript *invokeMethodThread(const char *methodName); DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) @@ -67,12 +66,6 @@ public: int _refCount; ScValue *_scValue; ScValue *_scProp; - -public: - // IWmeDebugObject - const char *dbgGetNativeClass(); - IWmeDebugProp *dbgGetProperty(const char *name); - }; // Implemented in their respective .cpp-files diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 29185edce6..fb77225700 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -152,10 +152,6 @@ bool ScScript::initScript() { _scriptStream->seek(_iP); _currentLine = 0; - // init breakpoints - _engine->refreshScriptBreakpoints(this); - - // ready to rumble... _state = SCRIPT_RUNNING; @@ -531,14 +527,8 @@ bool ScScript::executeInstruction() { dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); - } } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); - } } break; @@ -551,26 +541,14 @@ bool ScScript::executeInstruction() { if (!_engine->_globals->propExists(_symbols[dw])) { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); - } } break; } case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); - _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - - if (_scopeStack->_sP < 0) { - _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - } else { - _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -695,13 +673,6 @@ bool ScScript::executeInstruction() { case II_SCOPE: _operand->setNULL(); _scopeStack->push(_operand); - - if (_scopeStack->_sP < 0) { - _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - } else { - _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } - break; case II_CORRECT_STACK: @@ -754,10 +725,6 @@ bool ScScript::executeInstruction() { var->copy(val); } } - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableChangeValue(var, val); - } } break; @@ -827,10 +794,6 @@ bool ScScript::executeInstruction() { var->setProp(str, val); } - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); - } - break; } @@ -1117,21 +1080,6 @@ bool ScScript::executeInstruction() { int newLine = getDWORD(); if (newLine != _currentLine) { _currentLine = newLine; - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (_breakpoints[i] == _currentLine) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - if (_tracingMode) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } } break; @@ -1371,7 +1319,6 @@ ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unb if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str()); return thread; } else { delete thread; @@ -1497,68 +1444,6 @@ const char *ScScript::dbgGetFilename() { return _filename; } - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) { - client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - } else if (_thread) { - client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - } else { - client->onScriptInit(this); - } - - return dbgSendVariables(client); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSendVariables(IWmeDebugClient *client) { - // send script globals - _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // ScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState ScScript::dbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int ScScript::dbgGetNumBreakpoints() { - return _breakpoints.getSize(); -} - -////////////////////////////////////////////////////////////////////////// -int ScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) { - return _breakpoints[index]; - } else { - return -1; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSetTracingMode(bool isTracing) { - _tracingMode = isTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgGetTracingMode() { - return _tracingMode; -} - - ////////////////////////////////////////////////////////////////////////// void ScScript::afterLoad() { if (_buffer == NULL) { diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 6b5fa1733b..1cd5c2dc1e 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -34,18 +34,13 @@ #include "engines/wintermute/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/wme_debugger.h" - namespace WinterMute { class BaseScriptHolder; class BaseObject; class ScEngine; class ScStack; -class ScScript : public BaseClass, public IWmeDebugScript { +class ScScript : public BaseClass { public: - bool dbgSendScript(IWmeDebugClient *client); - bool dbgSendVariables(IWmeDebugClient *client); - BaseArray _breakpoints; bool _tracingMode; @@ -172,12 +167,6 @@ private: public: virtual int dbgGetLine(); virtual const char *dbgGetFilename(); - virtual TScriptState dbgGetState(); - virtual int dbgGetNumBreakpoints(); - virtual int dbgGetBreakpoint(int Index); - - virtual bool dbgSetTracingMode(bool IsTracing); - virtual bool dbgGetTracingMode(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 96250dbb90..06f584c9bb 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -88,17 +88,10 @@ ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// ScEngine::~ScEngine() { _gameRef->LOG(0, "Shutting down scripting engine"); - saveBreakpoints(); disableProfiling(); cleanup(); - - for (int i = 0; i < _breakpoints.getSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.clear(); } @@ -174,7 +167,6 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { script->_globals->setProp("this", &val); _scripts.add(script); - _gameRef->getDebugMgr()->onScriptInit(script); return script; } @@ -402,7 +394,7 @@ bool ScEngine::removeFinishedScripts() { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); } - _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; _scripts.remove_at(i); i--; @@ -556,177 +548,6 @@ bool ScEngine::clearGlobals(bool includingNatives) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { - // send global variables - _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) { - continue; - } - _scripts[i]->dbgSendScript(client); - } - - // and threads later - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) { - _scripts[i]->dbgSendScript(client); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - bp = _breakpoints[i]; - break; - } - } - if (bp == NULL) { - bp = new CScBreakpoint(scriptFilename); - _breakpoints.add(bp); - } - - for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) { - return STATUS_OK; - } - } - bp->_lines.add(line); - - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.remove_at(j); - if (_breakpoints[i]->_lines.getSize() == 0) { - delete _breakpoints[i]; - _breakpoints.remove_at(i); - } - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; - } - } - break; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - for (int i = 0; i < _scripts.getSize(); i++) { - refreshScriptBreakpoints(_scripts[i]); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::refreshScriptBreakpoints(ScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - if (!script || !script->_filename) { - return STATUS_FAILED; - } - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.copy(_breakpoints[i]->_lines); - return STATUS_OK; - } - } - if (script->_breakpoints.getSize() > 0) { - script->_breakpoints.clear(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - - char text[512]; - char key[100]; - - int count = 0; - for (int i = 0; i < _breakpoints.getSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - count++; - sprintf(key, "Breakpoint%d", count); - sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - BaseEngine::instance().getRegistry()->writeString("Debug", key, text); - } - } - BaseEngine::instance().getRegistry()->writeInt("Debug", "NumBreakpoints", count); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - char key[100]; - - int count = BaseEngine::instance().getRegistry()->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= count; i++) { - /* uint32 bufSize = 512; */ - sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = BaseEngine::instance().getRegistry()->readString("Debug", key, ""); - - char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); - - if (path != NULL && line != NULL) { - addBreakpoint(path, atoi(line)); - } - delete[] path; - delete[] line; - path = NULL; - line = NULL; - } - - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// void ScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) { diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index fcfaa51971..9aae8be85b 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -32,7 +32,6 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -#include "engines/wintermute/wme_debugger.h" namespace WinterMute { @@ -81,20 +80,7 @@ public: BaseArray _lines; }; - - - public: - bool dbgSendScripts(IWmeDebugClient *client); - - BaseArray _breakpoints; - bool addBreakpoint(const char *scriptFilename, int line); - bool removeBreakpoint(const char *scriptFilename, int line); - bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(ScScript *script); - bool saveBreakpoints(); - bool loadBreakpoints(); - bool clearGlobals(bool includingNatives = false); bool tickUnbreakable(); bool removeFinishedScripts(); diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 456f93507e..d35f85f9a1 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -950,18 +950,6 @@ int ScValue::compareStrict(ScValue *val1, ScValue *val2) { } } - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool ScValue::setProperty(const char *propName, int value) { ScValue *val = new ScValue(_gameRef, value); @@ -1004,128 +992,4 @@ bool ScValue::setProperty(const char *propName) { return ret; } - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType ScValue::dbgGetType() { - switch (getType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int ScValue::dbgGetValInt() { - return getInt(); -} - -////////////////////////////////////////////////////////////////////////// -double ScValue::dbgGetValFloat() { - return getFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetValBool() { - return getBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *ScValue::dbgGetValString() { - return getString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *ScValue::dbgGetValNative() { - return getNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(int value) { - setInt(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(double value) { - setFloat(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(bool value) { - setBool(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(const char *value) { - setString(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal() { - setNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int ScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) { - return _valNative->_scProp->dbgGetNumProperties(); - } else { - return _valObject.size(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) { - return _valNative->_scProp->dbgGetProperty(index, name, value); - } else { - int count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (count == index) { - *name = _valIter->_key.c_str(); - *value = _valIter->_value; - return true; - } - _valIter++; - count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->dbgGetDescription(buf, bufSize); - } - - if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(buf, bufSize); - } else { - strncpy(buf, getString(), bufSize); - } - return true; -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 069c36bd47..8fced06972 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -33,7 +33,6 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/wme_debugger.h" #include "common/str.h" namespace WinterMute { @@ -41,10 +40,8 @@ namespace WinterMute { class ScScript; class BaseScriptable; -class ScValue : public BaseClass, public IWmeDebugProp { +class ScValue : public BaseClass { public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID); - static int compare(ScValue *val1, ScValue *val2); static int compareStrict(ScValue *val1, ScValue *val2); TValType getTypeTolerant(); @@ -109,31 +106,6 @@ public: bool setProperty(const char *propName, double value); bool setProperty(const char *propName, bool value); bool setProperty(const char *propName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType dbgGetType(); - - // getters - virtual int dbgGetValInt(); - virtual double dbgGetValFloat(); - virtual bool dbgGetValBool(); - virtual const char *dbgGetValString(); - virtual IWmeDebugObject *dbgGetValNative(); - - // setters - virtual bool dbgSetVal(int value); - virtual bool dbgSetVal(double value); - virtual bool dbgSetVal(bool value); - virtual bool dbgSetVal(const char *value); - virtual bool dbgSetVal(); - - // properties - virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - - virtual bool dbgGetDescription(char *buf, int bufSize); }; } // end of namespace WinterMute diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 87f08242d5..ae84b38028 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -61,7 +61,6 @@ MODULE_OBJS := \ base/sound/base_sound_manager.o \ base/base_active_rect.o \ base/base.o \ - base/base_debugger.o \ base/base_dynamic_buffer.o \ base/base_engine.o \ base/base_fader.o \ diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 8e07569bf7..7bfe1ece01 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -222,9 +222,6 @@ int WinterMuteEngine::init() { _game->initialize2(); - _game->getDebugMgr()->onGameInit(); - _game->_scEngine->loadBreakpoints(); - bool ret; // initialize the renderer diff --git a/engines/wintermute/wme_debugger.h b/engines/wintermute/wme_debugger.h deleted file mode 100644 index 75f57339db..0000000000 --- a/engines/wintermute/wme_debugger.h +++ /dev/null @@ -1,172 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WME_DEBUGGER_H -#define WME_DEBUGGER_H - -#ifdef SetProp -#undef SetProp -#endif - -#include "engines/wintermute/dcscript.h" - -namespace WinterMute { - -class IWmeDebugClient; -class IWmeDebugObject; - -////////////////////////////////////////////////////////////////////////// -typedef enum { - WME_DBGPROP_NULL = 0, - WME_DBGPROP_INT = 1, - WME_DBGPROP_FLOAT = 2, - WME_DBGPROP_BOOL = 3, - WME_DBGPROP_STRING = 4, - WME_DBGPROP_OBJECT = 5, - WME_DBGPROP_NATIVE = 6, - WME_DBGPROP_UNKNOWN = 7 -} -EWmeDebuggerPropType; - -////////////////////////////////////////////////////////////////////////// -typedef enum { - WME_DBGVAR_GLOBAL = 0, - WME_DBGVAR_SCRIPT = 1, - WME_DBGVAR_SCOPE = 2 -} -EWmeDebuggerVariableType; - -////////////////////////////////////////////////////////////////////////// -class IWmeDebugScript { -public: - virtual ~IWmeDebugScript() {} - virtual int dbgGetLine() = 0; - virtual const char *dbgGetFilename() = 0; - virtual TScriptState dbgGetState() = 0; - - virtual int dbgGetNumBreakpoints() = 0; - virtual int dbgGetBreakpoint(int index) = 0; - - virtual bool dbgSetTracingMode(bool isTracing) = 0; - virtual bool dbgGetTracingMode() = 0; -}; - -////////////////////////////////////////////////////////////////////////// -class IWmeDebugProp { -public: - virtual EWmeDebuggerPropType dbgGetType() = 0; - - virtual ~IWmeDebugProp() {} - // getters - virtual int dbgGetValInt() = 0; - virtual double dbgGetValFloat() = 0; - virtual bool dbgGetValBool() = 0; - virtual const char *dbgGetValString() = 0; - virtual IWmeDebugObject *dbgGetValNative() = 0; - - // setters - virtual bool dbgSetVal(int value) = 0; - virtual bool dbgSetVal(double value) = 0; - virtual bool dbgSetVal(bool value) = 0; - virtual bool dbgSetVal(const char *value) = 0; - virtual bool dbgSetVal() = 0; - - // properties - virtual int dbgGetNumProperties() = 0; - virtual bool dbgGetProperty(int index, const char **name, IWmeDebugProp **value) = 0; - - virtual bool dbgGetDescription(char *buf, int bufSize) = 0; -}; - -////////////////////////////////////////////////////////////////////////// -class IWmeDebugObject { -public: - virtual ~IWmeDebugObject() {} - virtual const char *dbgGetNativeClass() = 0; - virtual IWmeDebugProp *dbgGetProperty(const char *name) = 0; -}; - -////////////////////////////////////////////////////////////////////////// -class IWmeDebugClient { -public: - virtual ~IWmeDebugClient() {} - virtual bool onGameInit() = 0; - virtual bool onGameShutdown() = 0; - - virtual bool onGameTick() = 0; - - virtual bool onLog(unsigned int errorCode, const char *text) = 0; - - virtual bool onScriptInit(IWmeDebugScript *script) = 0; - virtual bool onScriptEventThreadInit(IWmeDebugScript *script, IWmeDebugScript *ParentScript, const char *EventName) = 0; - virtual bool onScriptMethodThreadInit(IWmeDebugScript *script, IWmeDebugScript *ParentScript, const char *MethodName) = 0; - virtual bool onScriptShutdown(IWmeDebugScript *script) = 0; - virtual bool onScriptChangeLine(IWmeDebugScript *script, int Line) = 0; - virtual bool onScriptChangeScope(IWmeDebugScript *script, unsigned int scopeID) = 0; - virtual bool onScriptShutdownScope(IWmeDebugScript *script, unsigned int scopeID) = 0; - - virtual bool onVariableInit(EWmeDebuggerVariableType Type, IWmeDebugScript *script, unsigned int scopeID, IWmeDebugProp *variable, const char *variableName) = 0; - virtual bool onVariableChangeValue(IWmeDebugProp *variable, IWmeDebugProp *value) = 0; - - virtual bool onScriptHitBreakpoint(IWmeDebugScript *script, int line) = 0; -}; - -////////////////////////////////////////////////////////////////////////// -class IWmeDebugServer { -public: - virtual ~IWmeDebugServer() {} - virtual bool attachClient(IWmeDebugClient *client) = 0; - virtual bool detachClient(IWmeDebugClient *client) = 0; - - virtual bool queryData(IWmeDebugClient *client) = 0; - - virtual int getPropInt(const char *propName) = 0; - virtual double getPropFloat(const char *propName) = 0; - virtual const char *getPropString(const char *propName) = 0; - virtual bool getPropBool(const char *propName) = 0; - - virtual bool setProp(const char *propName, int propValue) = 0; - virtual bool setProp(const char *propName, double propValue) = 0; - virtual bool setProp(const char *propName, const char *propValue) = 0; - virtual bool setProp(const char *propName, bool propValue) = 0; - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) = 0; - - virtual bool addBreakpoint(const char *scriptFilename, int line) = 0; - virtual bool removeBreakpoint(const char *scriptFilename, int line) = 0; - - virtual bool continueExecution() = 0; -}; - - -typedef bool (*WMEDBG_INITIALIZE)(IWmeDebugServer *Server); -typedef bool (*WMEDBG_SHUTDOWN)(IWmeDebugServer *Server); - -} // end of namespace WinterMute - -#endif // WME_DEBUGGER_H -- cgit v1.2.3 From 2e7d21fc525a5b0451274d3844e3d6a1de1f6cb2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 17:53:44 +0200 Subject: WINTERMUTE: Replace BaseRegistry with ConfMan --- engines/wintermute/base/base_engine.cpp | 5 - engines/wintermute/base/base_engine.h | 2 - engines/wintermute/base/base_file_manager.cpp | 33 +- engines/wintermute/base/base_game.cpp | 43 +- engines/wintermute/base/base_registry.cpp | 279 --- engines/wintermute/base/base_registry.h | 79 - .../base/gfx/osystem/base_render_osystem.cpp | 6 +- .../wintermute/base/scriptables/script_engine.cpp | 1 - .../wintermute/base/sound/base_sound_manager.cpp | 1 - engines/wintermute/module.mk | 5 - engines/wintermute/tinyxml/tinystr.cpp | 115 -- engines/wintermute/tinyxml/tinystr.h | 309 ---- engines/wintermute/tinyxml/tinyxml.cpp | 1892 -------------------- engines/wintermute/tinyxml/tinyxml.h | 1809 ------------------- engines/wintermute/tinyxml/tinyxmlerror.cpp | 59 - engines/wintermute/tinyxml/tinyxmlparser.cpp | 1643 ----------------- engines/wintermute/utils/string_util.cpp | 10 + engines/wintermute/utils/string_util.h | 3 + engines/wintermute/wintermute.cpp | 23 +- 19 files changed, 61 insertions(+), 6256 deletions(-) delete mode 100644 engines/wintermute/base/base_registry.cpp delete mode 100644 engines/wintermute/base/base_registry.h delete mode 100644 engines/wintermute/tinyxml/tinystr.cpp delete mode 100644 engines/wintermute/tinyxml/tinystr.h delete mode 100644 engines/wintermute/tinyxml/tinyxml.cpp delete mode 100644 engines/wintermute/tinyxml/tinyxml.h delete mode 100644 engines/wintermute/tinyxml/tinyxmlerror.cpp delete mode 100644 engines/wintermute/tinyxml/tinyxmlparser.cpp (limited to 'engines') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 0185d973fa..8e3e6cf0e0 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" @@ -40,20 +39,16 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; - _registry = NULL; _gameRef = NULL; _gameId = ""; } void BaseEngine::init() { - _registry = new BaseRegistry(); - // File-manager depends on registry. _fileManager = new BaseFileManager(); } BaseEngine::~BaseEngine() { delete _fileManager; - delete _registry; } void BaseEngine::createInstance(const Common::String &gameid) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index d45d979f25..30f241ecc6 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -37,7 +37,6 @@ class BaseGame; class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; - BaseRegistry *_registry; Common::String _gameId; BaseGame *_gameRef; public: @@ -48,7 +47,6 @@ public: BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } - BaseRegistry *getRegistry() { return _registry; } static void LOG(bool res, const char *fmt, ...); const char *getGameId() { return _gameId.c_str(); } }; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 801729c5e8..d5071ccf48 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -32,7 +32,6 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/debug.h" @@ -147,42 +146,12 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!BaseEngine::instance().getRegistry()) { // This function only works when the game-registry is loaded - return STATUS_FAILED; - } - - AnsiString pathList; - - // single files paths - pathList = BaseEngine::instance().getRegistry()->readString("Resource", "CustomPaths", ""); - Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); -// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - while (!entries->empty()) { - Common::String path = entries->nextToken(); - if (path.size() > 0) { - error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); - } - } - delete entries; - entries = NULL; + // Removed: Config-based file-path choice. // package files paths const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = BaseEngine::instance().getRegistry()->readString("Resource", "PackagePaths", ""); - entries = new Common::StringTokenizer(pathList, ";"); - while (!entries->empty()) { - Common::String path = entries->nextToken(); - if (path.size() > 0) { - error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); - } - } - delete entries; - entries = NULL; - Common::FSNode dataSubFolder = gameData.getChild("data"); if (dataSubFolder.exists()) { addPath(PATH_PACKAGE, dataSubFolder); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 062f92ccae..0453222e24 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -39,7 +39,6 @@ #include "engines/wintermute/base/base_keyboard_state.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_quick_msg.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_sprite.h" @@ -64,6 +63,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" +#include "common/config-manager.h" #include "common/savefile.h" #include "common/textconsole.h" #include "common/util.h" @@ -276,7 +276,7 @@ BaseGame::~BaseGame() { LOG(0, ""); LOG(0, "Shutting down..."); - BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); + ConfMan.setBool("last_run", true); cleanup(); @@ -1534,7 +1534,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - BaseEngine::instance().getRegistry()->writeInt("PrivateSettings", key, val); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + ConfMan.setInt(privKey, val); stack->pushNULL(); return STATUS_OK; } @@ -1546,7 +1547,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(BaseEngine::instance().getRegistry()->readInt("PrivateSettings", key, initVal)); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + int result = initVal; + if (ConfMan.hasKey(privKey)) { + result = ConfMan.getInt(privKey); + } + stack->pushInt(result); return STATUS_OK; } @@ -1557,7 +1563,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - BaseEngine::instance().getRegistry()->writeString("PrivateSettings", key, val); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String privVal = StringUtil::encodeSetting(val); + ConfMan.set(privKey, privVal); stack->pushNULL(); return STATUS_OK; } @@ -1569,8 +1577,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = BaseEngine::instance().getRegistry()->readString("PrivateSettings", key, initVal); - stack->pushString(val.c_str()); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String result = initVal; + if (ConfMan.hasKey(privKey)) { + result = StringUtil::decodeSetting(ConfMan.get(key)); + } + stack->pushString(result.c_str()); return STATUS_OK; } @@ -2627,7 +2639,11 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(BaseEngine::instance().getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); + if (!ConfMan.hasKey("most_recent_saveslot")) { + _scValue->setInt(-1); + } else { + _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); + } return _scValue; } @@ -3329,7 +3345,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - BaseEngine::instance().getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); + ConfMan.setInt("most_recent_saveslot", slot); } } } @@ -3663,7 +3679,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - BaseEngine::instance().getRegistry()->setBasePath((char *)params); + //BaseEngine::instance().getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3687,9 +3703,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = BaseEngine::instance().getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = BaseEngine::instance().getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; + _settingsAllowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. + _compressedSavegames = true; delete[] origBuffer; @@ -4679,7 +4694,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - BaseEngine::instance().getRegistry()->saveValues(); + ConfMan.flushToDisk(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp deleted file mode 100644 index d03691ea42..0000000000 --- a/engines/wintermute/base/base_registry.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/wintermute.h" -#include "common/savefile.h" -#include "common/config-manager.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry() { - _iniName = NULL; - - setIniName("./wme.ini"); - loadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -BaseRegistry::~BaseRegistry() { - saveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - - bool found = false; - ret = getValue(_localValues, subKey, key, found); - if (!found) { - ret = getValue(_values, subKey, key, found); - } - if (!found) { - ret = init; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - if (ConfMan.hasKey("master_volume")) { - return ConfMan.getInt("master_volume"); - } else { - return init; - } - } else if (key == "SFXVolume") { - if (ConfMan.hasKey("sfx_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "SpeechVolume") { - if (ConfMan.hasKey("speech_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "MusicVolume") { - if (ConfMan.hasKey("music_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } - } - AnsiString val = readString(subKey, key, ""); - if (val.empty()) { - return init; - } else { - return atoi(val.c_str()); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - ConfMan.setInt("master_volume", value); - return true; - } else if (key == "SFXVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "SpeechVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "MusicVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } - } - writeString(subKey, key, StringUtil::toString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (readInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return writeInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::setIniName(const char *name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { - _iniName = new char [strlen(name) + 3]; - sprintf(_iniName, "./%s", name); - } else { - _iniName = new char [strlen(name) + 1]; - strcpy(_iniName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseRegistry::getIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; - loadXml(filename, _values); -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::saveValues() { - Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; - saveXml(filename, _values); -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::setBasePath(const char *basePath) { - _basePath = PathUtil::getFileNameWithoutExtension(basePath); - - loadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) { - return ""; - } - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) { - return ""; - } else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - Common::SeekableReadStream *stream = g_wintermute->getSaveFileMan()->openForLoading(fileName); - if (!stream) { - return; - } - char *data = new char[stream->size()]; - stream->read(data, stream->size()); - TiXmlDocument doc; - doc.Parse(data); - delete[] data; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - } - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - BaseUtils::createPath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - Common::WriteStream *stream = g_wintermute->getSaveFileMan()->openForSaving(fileName); - - if (!stream) { - return; - } else { - stream->write(printer.CStr(), printer.Size()); - stream->finalize(); - delete stream; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h deleted file mode 100644 index 5e235c2a68..0000000000 --- a/engines/wintermute/base/base_registry.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "engines/wintermute/dctypes.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/str.h" - -namespace WinterMute { - -class BaseRegistry { -public: - void setIniName(const char *name); - char *getIniName(); - bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); - int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - BaseRegistry(); - virtual ~BaseRegistry(); - - void setBasePath(const char *basePath); - AnsiString getBasePath() const { - return _basePath; - } - - void loadValues(bool local); - void saveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void loadXml(const AnsiString fileName, PathValueMap &values); - void saveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 8e6c6bb83c..f407a871b0 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -128,8 +126,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); - _realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); + //_realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); + //_realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 06f584c9bb..e5d965a4b1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -32,7 +32,6 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_ext_math.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 43109443a7..ed475ec31c 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index ae84b38028..2d253bca84 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -75,7 +75,6 @@ MODULE_OBJS := \ base/base_point.o \ base/base_quick_msg.o \ base/base_region.o \ - base/base_registry.o \ base/base_save_thumb_helper.o \ base/base_scriptable.o \ base/base_script_holder.o \ @@ -95,10 +94,6 @@ MODULE_OBJS := \ system/sys_class.o \ system/sys_class_registry.o \ system/sys_instance.o \ - tinyxml/tinyxml.o \ - tinyxml/tinystr.o \ - tinyxml/tinyxmlparser.o \ - tinyxml/tinyxmlerror.o \ ui/ui_button.o \ ui/ui_edit.o \ ui/ui_entity.o \ diff --git a/engines/wintermute/tinyxml/tinystr.cpp b/engines/wintermute/tinyxml/tinystr.cpp deleted file mode 100644 index 81152d9017..0000000000 --- a/engines/wintermute/tinyxml/tinystr.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -// Modified for use in ScummVM (namespace added) - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -namespace WinterMute { - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - -} // end of namespace WinterMute - -#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinystr.h b/engines/wintermute/tinyxml/tinystr.h deleted file mode 100644 index 7f35f52864..0000000000 --- a/engines/wintermute/tinyxml/tinystr.h +++ /dev/null @@ -1,309 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -// Modified for use in ScummVM (namespace added) - -#ifndef TIXML_USE_STL - -#ifndef TIXML_STRING_INCLUDED -#define TIXML_STRING_INCLUDED - -#include -#include - -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: -*/ -#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit -#elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit -#else - #define TIXML_EXPLICIT -#endif - -namespace WinterMute { - -/* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. -*/ -class TiXmlString -{ - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; - -} ; - - -inline bool operator == (const TiXmlString & a, const TiXmlString & b) -{ - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare -} -inline bool operator < (const TiXmlString & a, const TiXmlString & b) -{ - return strcmp(a.c_str(), b.c_str()) < 0; -} - -inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } -inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } -inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } -inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } - -inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } -inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } -inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } -inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); -TiXmlString operator + (const TiXmlString & a, const char* b); -TiXmlString operator + (const char* a, const TiXmlString & b); - - -/* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. -*/ -class TiXmlOutStream : public TiXmlString -{ -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } - -} ; - -} // end of namespace WinterMute - -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL diff --git a/engines/wintermute/tinyxml/tinyxml.cpp b/engines/wintermute/tinyxml/tinyxml.cpp deleted file mode 100644 index 2ab6880a56..0000000000 --- a/engines/wintermute/tinyxml/tinyxml.cpp +++ /dev/null @@ -1,1892 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -// Modified for use in ScummVM (namespace added) - -#include - -#ifdef TIXML_USE_STL -#include -#include -#endif - -#include "engines/wintermute/tinyxml/tinyxml.h" - -namespace WinterMute { - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( replaceThis->parent != this ) - return 0; - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return &node->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const char* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s ); - } - else { - *i = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const std::string* s = Attribute( name ); - if ( i ) - { - if ( s ) { - *i = atoi( s->c_str() ); - } - else { - *i = 0; - } - } - return s; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const char* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s ); - } - else { - *d = 0; - } - } - return s; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const std::string* s = Attribute( name ); - if ( d ) - { - if ( s ) { - *d = atof( s->c_str() ); - } - else { - *d = 0; - } - } - return s; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - return node->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); - #else - sprintf( buf, "%d", val ); - #endif - SetAttribute( name, buf ); -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - std::ostringstream oss; - oss << val; - SetAttribute( name, oss.str() ); -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); - #else - sprintf( buf, "%f", val ); - #endif - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING _name( cname ); - TIXML_STRING _value( cvalue ); - #else - const char* _name = cname; - const char* _value = cvalue; - #endif - - TiXmlAttribute* node = attributeSet.Find( _name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - // See STL_STRING_BUG below. - //StringToBuffer buf( value ); - - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - // See STL_STRING_BUG below. -// StringToBuffer buf( value ); -// -// if ( buf.buffer && SaveFile( buf.buffer ) ) -// return true; -// -// return false; - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - // There was a really terrifying little bug here. The code: - // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same - // address as it's c_str() method, and so bad things happen. Looks - // like a bug in the Microsoft STL implementation. - // Add an extra string to avoid the crash. - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // - // - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - const char* lastPos = buf; - const char* p = buf; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - if ( *p == 0xa ) { - // Newline character. No special rules for this. Append all the characters - // since the last string, and include the newline. - data.append( lastPos, (p-lastPos+1) ); // append, include the newline - ++p; // move past the newline - lastPos = p; // and point to the new buffer (may be 0) - assert( p <= (buf+length) ); - } - else if ( *p == 0xd ) { - // Carriage return. Append what we have so far, then - // handle moving forward in the buffer. - if ( (p-lastPos) > 0 ) { - data.append( lastPos, p-lastPos ); // do not add the CR - } - data += (char)0xa; // a proper newline - - if ( *(p+1) == 0xa ) { - // Carriage return - new line sequence - p += 2; - lastPos = p; - assert( p <= (buf+length) ); - } - else { - // it was followed by something else...that is presumably characters again. - ++p; - lastPos = p; - assert( p <= (buf+length) ); - } - } - else { - ++p; - } - } - // Handle any left over characters. - if ( p-lastPos ) { - data.append( lastPos, p-lastPos ); - } - delete [] buf; - buf = 0; - - Parse( data.c_str(), 0, encoding ); - - if ( Error() ) - return false; - else - return true; -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); - #else - sprintf (buf, "%lf", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::DECLARATION ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} -*/ -#endif - - -const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - -/* -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} -*/ - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && iNextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && iNextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && iNextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && iNextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += ""; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += ""; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += ""; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/tinyxml/tinyxml.h b/engines/wintermute/tinyxml/tinyxml.h deleted file mode 100644 index a32e145587..0000000000 --- a/engines/wintermute/tinyxml/tinyxml.h +++ /dev/null @@ -1,1809 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -// Modified for ScummVM (namespace added) - -#undef TIXML_USE_STL - -#ifndef TINYXML_INCLUDED -#define TINYXML_INCLUDED - -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4530 ) -#pragma warning( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include - -// Help out windows: -#if defined( _DEBUG ) && !defined( DEBUG ) -#define DEBUG -#endif - -#ifdef TIXML_USE_STL - #include - #include - #include - #define TIXML_STRING std::string -#else - #include "tinystr.h" - #define TIXML_STRING TiXmlString -#endif - -// Deprecated library function hell. Compilers want to use the -// new safe versions. This probably doesn't fully address the problem, -// but it gets closer. There are too many compilers for me to fully -// test. If you get compilation troubles, undefine TIXML_SAFE -#define TIXML_SAFE - -#ifdef TIXML_SAFE - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s - #define TIXML_SNSCANF _snscanf_s - #define TIXML_SSCANF sscanf_s - #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - //#pragma message( "Using _sn* functions." ) - #define TIXML_SNPRINTF _snprintf - #define TIXML_SNSCANF _snscanf - #define TIXML_SSCANF sscanf - #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_SNSCANF snscanf - #define TIXML_SSCANF sscanf - #else - #define TIXML_SSCANF sscanf - #endif -#endif - -namespace WinterMute { - -class TiXmlDocument; -class TiXmlElement; -class TiXmlComment; -class TiXmlUnknown; -class TiXmlAttribute; -class TiXmlText; -class TiXmlDeclaration; -class TiXmlParsingData; - -const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 5; -const int TIXML_PATCH_VERSION = 3; - -/* Internal structure for tracking location of items - in the XML file. -*/ -struct TiXmlCursor -{ - TiXmlCursor() { Clear(); } - void Clear() { row = col = -1; } - - int row; // 0 based. - int col; // 0 based. -}; - - -/** - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simple called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its sibilings will be Visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - - You should never change the document from a callback. - - @sa TiXmlNode::Accept() -*/ -class TiXmlVisitor -{ -public: - virtual ~TiXmlVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } - /// Visit a document. - virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } - - /// Visit an element. - virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } - /// Visit an element. - virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } - - /// Visit a declaration - virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } - /// Visit a text node - virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } - /// Visit a comment node - virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknow node - virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } -}; - -// Only used by Attribute::Query functions -enum -{ - TIXML_SUCCESS, - TIXML_NO_ATTRIBUTE, - TIXML_WRONG_TYPE -}; - - -// Used by the parsing routines. -enum TiXmlEncoding -{ - TIXML_ENCODING_UNKNOWN, - TIXML_ENCODING_UTF8, - TIXML_ENCODING_LEGACY -}; - -const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; - -/** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - @endverbatim -*/ -class TiXmlBase -{ - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; - -public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} - - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert - tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } - - /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. - - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. - - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. - - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - - @sa TiXmlDocument::SetTabSize() - */ - int Row() const { return location.row + 1; } - int Column() const { return location.col + 1; } ///< See Row() - - void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. - void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. - const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. - - // Table that returs, for a given lead byte, the total number of bytes - // in the UTF-8 sequence. - static const int utf8ByteTable[256]; - - virtual const char* Parse( const char* p, - TiXmlParsingData* data, - TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, - or they will be transformed into entities! - */ - static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_OUT_OF_MEMORY, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - TIXML_ERROR_PARSING_CDATA, - TIXML_ERROR_DOCUMENT_TOP_ONLY, - - TIXML_ERROR_STRING_COUNT - }; - -protected: - - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); - } - inline static bool IsWhiteSpace( int c ) - { - if ( c < 256 ) - return IsWhiteSpace( (char) c ); - return false; // Again, only truly correct for English/Latin...but usually works. - } - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); - static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding ); // the current encoding - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); - - // Get a character, while interpreting entities. - // The length can be from 0 to 4 bytes. - inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) - { - assert( p ); - if ( encoding == TIXML_ENCODING_UTF8 ) - { - *length = utf8ByteTable[ *((const unsigned char*)p) ]; - assert( *length >= 0 && *length < 5 ); - } - else - { - *length = 1; - } - - if ( *length == 1 ) - { - if ( *p == '&' ) - return GetEntity( p, _value, length, encoding ); - *_value = *p; - return p+1; - } - else if ( *length ) - { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), - // and the null terminator isn't needed - for( int i=0; p[i] && i<*length; ++i ) { - _value[i] = p[i]; - } - return p + (*length); - } - else - { - // Not valid text. - return 0; - } - } - - // Return true if the next characters in the stream are any of the endTag sequences. - // Ignore case only works for english, and should only be relied on when comparing - // to English words: StringEqual( p, "version", true ) is fine. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase, - TiXmlEncoding encoding ); - - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; - - TiXmlCursor location; - - /// Field containing a generic user pointer - void* userData; - - // None of these methods are reliable for any language except English. - // Good for approximation, not great for accuracy. - static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); - static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); - inline static int ToLower( int v, TiXmlEncoding encoding ) - { - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( v < 128 ) return tolower( v ); - return v; - } - else - { - return tolower( v ); - } - } - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - -private: - TiXmlBase( const TiXmlBase& ); // not implemented. - void operator=( const TiXmlBase& base ); // not allowed. - - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; -}; - - -/** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. -*/ -class TiXmlNode : public TiXmlBase -{ - friend class TiXmlDocument; - friend class TiXmlElement; - -public: - #ifdef TIXML_USE_STL - - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); - - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - DOCUMENT, - ELEMENT, - COMMENT, - UNKNOWN, - TEXT, - DECLARATION, - TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ - const char *Value() const { return value.c_str (); } - - #ifdef TIXML_USE_STL - /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ - const std::string& ValueStr() const { return value; } - #endif - - const TIXML_STRING& ValueTStr() const { return value; } - - /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - void SetValue(const char * _value) { value = _value;} - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); - - /// One step up the DOM. - TiXmlNode* Parent() { return parent; } - const TiXmlNode* Parent() const { return parent; } - - const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - /// The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* FirstChild( const char * _value ) { - // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) - // call the method, cast the return back to non-const. - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); - } - const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild() { return lastChild; } - - const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. - TiXmlNode* LastChild( const char * _value ) { - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); - } - - /// This flavor of IterateChildren searches for children with a particular 'value' - const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - #endif - - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - - /** Add a new node related to this. Adds a child past the LastChild. - - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. - - @sa InsertEndChild - */ - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling() const { return prev; } - TiXmlNode* PreviousSibling() { return prev; } - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling( const char * ) const; - TiXmlNode* PreviousSibling( const char *_prev ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - const TiXmlNode* NextSibling() const { return next; } - TiXmlNode* NextSibling() { return next; } - - /// Navigate to a sibling node with the given 'value'. - const TiXmlNode* NextSibling( const char * ) const; - TiXmlNode* NextSibling( const char* _next ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement() const; - TiXmlElement* NextSiblingElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement( const char * ) const; - TiXmlElement* NextSiblingElement( const char *_next ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement() const; - TiXmlElement* FirstChildElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); - } - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement( const char * _value ) const; - TiXmlElement* FirstChildElement( const char * _value ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. - */ - int Type() const { return type; } - - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - const TiXmlDocument* GetDocument() const; - TiXmlDocument* GetDocument() { - return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); - } - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ - virtual TiXmlNode* Clone() const = 0; - - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. - - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( TiXmlVisitor* visitor ) const = 0; - -protected: - TiXmlNode( NodeType _type ); - - // Copy to the allocated object. Shared functionality between Clone, Copy constructor, - // and the assignment operator. - void CopyTo( TiXmlNode* target ) const; - - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; - #endif - - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - - TiXmlNode* parent; - NodeType type; - - TiXmlNode* firstChild; - TiXmlNode* lastChild; - - TIXML_STRING value; - - TiXmlNode* prev; - TiXmlNode* next; - -private: - TiXmlNode( const TiXmlNode& ); // not implemented. - void operator=( const TiXmlNode& base ); // not allowed. -}; - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. -*/ -class TiXmlAttribute : public TiXmlBase -{ - friend class TiXmlAttributeSet; - -public: - /// Construct an empty attribute. - TiXmlAttribute() : TiXmlBase() - { - document = 0; - prev = next = 0; - } - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - - const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. - #ifdef TIXML_USE_STL - const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. - #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - - // Get the tinyxml string representation - const TIXML_STRING& NameTStr() const { return name; } - - /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ - int QueryIntValue( int* _value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* _value ) const; - - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. - - void SetIntValue( int _value ); ///< Set the value from an integer. - void SetDoubleValue( double _value ); ///< Set the value from a double. - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - const TiXmlAttribute* Next() const; - TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); - } - - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - const TiXmlAttribute* Previous() const; - TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); - } - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } - -private: - TiXmlAttribute( const TiXmlAttribute& ); // not implemented. - void operator=( const TiXmlAttribute& base ); // not allowed. - - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; -}; - - -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. -*/ -class TiXmlAttributeSet -{ -public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); - - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); - - const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - - const TiXmlAttribute* Find( const char* _name ) const; - TiXmlAttribute* Find( const char* _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - #ifdef TIXML_USE_STL - const TiXmlAttribute* Find( const std::string& _name ) const; - TiXmlAttribute* Find( const std::string& _name ) { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); - } - - #endif - -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed - void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) - - TiXmlAttribute sentinel; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TiXmlElement : public TiXmlNode -{ -public: - /// Construct an element. - TiXmlElement (const char * in_value); - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ); - #endif - - TiXmlElement( const TiXmlElement& ); - - void operator=( const TiXmlElement& base ); - - virtual ~TiXmlElement(); - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ - const char* Attribute( const char* name, double* d ) const; - - /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ - int QueryIntAttribute( const char* name, int* _value ) const; - /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* _value ) const; - /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { - double d; - int result = QueryDoubleAttribute( name, &d ); - if ( result == TIXML_SUCCESS ) { - *_value = (float)d; - } - return result; - } - - #ifdef TIXML_USE_STL - /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. - - NOTE: This method doesn't work correctly for 'string' types. - - @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ - template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - std::stringstream sstream( node->ValueStr() ); - sstream >> *outValue; - if ( !sstream.fail() ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; - } - /* - This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" - but template specialization is hard to get working cross-compiler. Leaving the bug for now. - - // The above will fail for std::string because the space character is used as a seperator. - // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string - template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - *outValue = node->ValueStr(); - return TIXML_SUCCESS; - } - */ - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * _value ); - - #ifdef TIXML_USE_STL - const std::string* Attribute( const std::string& name ) const; - const std::string* Attribute( const std::string& name, int* i ) const; - const std::string* Attribute( const std::string& name, double* d ) const; - int QueryIntAttribute( const std::string& name, int* _value ) const; - int QueryDoubleAttribute( const std::string& name, double* _value ) const; - - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ); - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ); - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetDoubleAttribute( const char * name, double value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); - #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif - - const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } - const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ - const char* GetText() const; - - /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; - // Print the Element to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - - void CopyTo( TiXmlElement* target ) const; - void ClearThis(); // like clear, but initializes 'this' object as well - - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - -private: - - TiXmlAttributeSet attributeSet; -}; - - -/** An XML comment. -*/ -class TiXmlComment : public TiXmlNode -{ -public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} - /// Construct a comment from text. - TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { - SetValue( _value ); - } - TiXmlComment( const TiXmlComment& ); - void operator=( const TiXmlComment& base ); - - virtual ~TiXmlComment() {} - - /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; - // Write this Comment to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlComment* target ) const; - - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; - -private: - -}; - - -/** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). -*/ -class TiXmlText : public TiXmlNode -{ - friend class TiXmlElement; -public: - /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) - { - SetValue( initValue ); - cdata = false; - } - #endif - - TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } - void operator=( const TiXmlText& base ) { base.CopyTo( this ); } - - // Write this text object to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /// Queries whether this represents text using a CDATA section. - bool CDATA() const { return cdata; } - /// Turns on or off a CDATA representation of text. - void SetCDATA( bool _cdata ) { cdata = _cdata; } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - void CopyTo( TiXmlText* target ) const; - - bool Blank() const; // returns true if all white space and new lines - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - bool cdata; // true if this should be input and output as a CDATA style text element -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. -*/ -class TiXmlDeclaration : public TiXmlNode -{ -public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} - -#ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ); -#endif - - /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); - - TiXmlDeclaration( const TiXmlDeclaration& copy ); - void operator=( const TiXmlDeclaration& copy ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return an empty string if none was found. - const char *Version() const { return version.c_str (); } - /// Encoding. Will return an empty string if none was found. - const char *Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char *Standalone() const { return standalone.c_str (); } - - /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; - // Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlDeclaration* target ) const; - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; -}; - - -/** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into TiXmlUnknowns. -*/ -class TiXmlUnknown : public TiXmlNode -{ -public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} - virtual ~TiXmlUnknown() {} - - TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } - void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } - - /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; - // Print this Unknown to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected: - void CopyTo( TiXmlUnknown* target ) const; - - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - -}; - - -/** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. -*/ -class TiXmlDocument : public TiXmlNode -{ -public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ); - #endif - - TiXmlDocument( const TiXmlDocument& copy ); - void operator=( const TiXmlDocument& copy ); - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ - bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given FILE*. Returns true if successful. - bool SaveFile( FILE* ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && LoadFile( f.buffer, encoding )); - return LoadFile( filename.c_str(), encoding ); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { -// StringToBuffer f( filename ); -// return ( f.buffer && SaveFile( f.buffer )); - return SaveFile( filename.c_str() ); - } - #endif - - /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - const TiXmlElement* RootElement() const { return FirstChildElement(); } - TiXmlElement* RootElement() { return FirstChildElement(); } - - /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - int ErrorId() const { return errorId; } - - /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) - - @sa SetTabSize, Row, Column - */ - int ErrorRow() const { return errorLocation.row+1; } - int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - - /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. - - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. - - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. - - Note that row and column tracking is not supported when using operator>>. - - The tab size needs to be enabled before the parse or load. Correct usage: - @verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - @endverbatim - - @sa Row, Column - */ - void SetTabSize( int _tabsize ) { tabsize = _tabsize; } - - int TabSize() const { return tabsize; } - - /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; - } - - /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { Print( stdout, 0 ); } - - /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ - //char* PrintToMemory() const; - - /// Print this Document to a FILE stream. - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - - virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - void CopyTo( TiXmlDocument* target ) const; - - bool error; - int errorId; - TIXML_STRING errorDesc; - int tabsize; - TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. -}; - - -/** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - TiXmlHandle handleCopy = handle; - @endverbatim - - What they should not be used for is iteration: - - @verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - @endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - @endverbatim -*/ -class TiXmlHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } - /// Copy constructor - TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } - - /// Return a handle to the first child node. - TiXmlHandle FirstChild() const; - /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; - /// Return a handle to the first child element. - TiXmlHandle FirstChildElement() const; - /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; - - /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( int index ) const; - - #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } - - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } - #endif - - /** Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* ToNode() const { return node; } - /** Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /** Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /** Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - - /** @deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* Node() const { return ToNode(); } - /** @deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* Element() const { return ToElement(); } - /** @deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* Text() const { return ToText(); } - /** @deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* Unknown() const { return ToUnknown(); } - -private: - TiXmlNode* node; -}; - - -/** Print to memory functionality. The TiXmlPrinter is useful when you need to: - - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) - - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. - - TiXmlPrinter uses the Visitor API. - @verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); - - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - @endverbatim -*/ -class TiXmlPrinter : public TiXmlVisitor -{ -public: - TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), - buffer(), indent( " " ), lineBreak( "\n" ) {} - - virtual bool VisitEnter( const TiXmlDocument& doc ); - virtual bool VisitExit( const TiXmlDocument& doc ); - - virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); - virtual bool VisitExit( const TiXmlElement& element ); - - virtual bool Visit( const TiXmlDeclaration& declaration ); - virtual bool Visit( const TiXmlText& text ); - virtual bool Visit( const TiXmlComment& comment ); - virtual bool Visit( const TiXmlUnknown& unknown ); - - /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ - void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } - /// Query the indention string. - const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ - void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } - /// Query the current line breaking string. - const char* LineBreak() { return lineBreak.c_str(); } - - /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ - void SetStreamPrinting() { indent = ""; - lineBreak = ""; - } - /// Return the result. - const char* CStr() { return buffer.c_str(); } - /// Return the length of the result string. - size_t Size() { return buffer.size(); } - - #ifdef TIXML_USE_STL - /// Return the result. - const std::string& Str() { return buffer; } - #endif - -private: - void DoIndent() { - for( int i=0; i -#include - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -namespace WinterMute { - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; iappend( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p ) - p += strlen( endTag ); - return p; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); -} - -#endif - -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) -{ - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; -} - -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } -} - - -TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) -{ - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - TiXmlDocument* doc = GetDocument(); - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // [ 1475201 ] TinyXML parses entities in comments - // Oops - ReadText doesn't work, because we don't want to parse the entities. - // p = ReadText( p, &value, false, endTag, false, encoding ); - // - // from the XML spec: - /* - [Definition: Comments may appear anywhere in a document outside other markup; in addition, - they may appear within the document type declaration at places allowed by the grammar. - They are not part of the document's character data; an XML processor MAY, but need not, - make it possible for an application to retrieve the text of comments. For compatibility, - the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity - references MUST NOT be recognized within comments. - - An example of a comment: - - - */ - - value = ""; - // Keep all the white space. - while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) - { - value.append( p, 1 ); - ++p; - } - if ( p ) - p += strlen( endTag ); - - return p; -} - - -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - -// int tabsize = 4; -// if ( document ) -// tabsize = document->TabSize(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; -} - -#ifdef TIXML_USE_STL -void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } -} -#endif - -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = ""; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; - } -} - -#ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } -} -#endif - -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) -{ - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; -} - -bool TiXmlText::Blank() const -{ - for ( unsigned i=0; iDEBUG_DebugEnable("./wme.log"); + } + } - if (BaseEngine::instance().getRegistry()->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log"); + if (ConfMan.hasKey("show_fps")) { + _game->_debugShowFPS = ConfMan.getBool("show_fps"); + } else { + _game->_debugShowFPS = false; + } - _game->_debugShowFPS = BaseEngine::instance().getRegistry()->readBool("Debug", "ShowFPS"); + if (ConfMan.hasKey("disable_smartcache")) { + _game->_smartCache = ConfMan.getBool("disable_smartcache"); + } else { + _game->_smartCache = true; + } - if (BaseEngine::instance().getRegistry()->readBool("Debug", "DisableSmartCache")) { + if (!_game->_smartCache) { _game->LOG(0, "Smart cache is DISABLED"); - _game->_smartCache = false; } - /* bool allowDirectDraw = _game->_registry->readBool("Debug", "AllowDirectDraw", false);*/ - // load general game settings _game->initialize1(); -- cgit v1.2.3 From 20e2ec4ff4d869ba54edf5b930d84340245292b6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 18:00:15 +0200 Subject: WINTERMUTE: Remove unused functions from StringUtil:: --- .../wintermute/base/base_persistence_manager.cpp | 1 - engines/wintermute/base/base_sprite.cpp | 6 ++- engines/wintermute/base/base_string_table.cpp | 1 - engines/wintermute/base/gfx/base_image.cpp | 3 +- .../wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/utils/path_util.cpp | 3 +- engines/wintermute/utils/string_util.cpp | 59 ---------------------- engines/wintermute/utils/string_util.h | 3 -- 8 files changed, 6 insertions(+), 71 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index ddc5e15d92..b6cd59328d 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -34,7 +34,6 @@ #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/wintermute.h" diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index bc42f81dd4..6c66b808b7 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" @@ -140,8 +139,11 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC bool ret; + AnsiString filePrefix = filename; AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + ext.toLowercase(); + filePrefix.toLowercase(); + if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) { BaseFrame *frame = new BaseFrame(_gameRef); BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8fa69e5288..2e8774020d 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -30,7 +30,6 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_string_table.h" -#include "engines/wintermute/utils/string_util.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 2167503dc8..9203b62734 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/graphics/transparent_surface.h" -#include "engines/wintermute/utils/string_util.h" #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" @@ -63,7 +62,7 @@ BaseImage::~BaseImage() { bool BaseImage::loadFile(const Common::String &filename) { _filename = filename; _filename.toLowercase(); - if (StringUtil::startsWith(filename, "savegame:", true)) { + if (filename.hasPrefix("savegame:")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".png")) { _decoder = new Graphics::PNGDecoder(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e5d965a4b1..a1f246c4bc 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index 065e0aada9..dcf35be776 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -28,7 +28,6 @@ #include "common/file.h" #include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" namespace WinterMute { @@ -57,7 +56,7 @@ AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) { AnsiString newPath1 = unifySeparators(path1); AnsiString newPath2 = unifySeparators(path2); - if (!StringUtil::endsWith(newPath1, "/", true) && !StringUtil::startsWith(newPath2, "/", true)) { + if (!newPath1.hasSuffix("/") && !newPath2.hasPrefix("/")) { newPath1 += "/"; } diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index 3e71a939d2..b51d094784 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -203,62 +203,6 @@ AnsiString StringUtil::wideToAnsi(const WideString &wstr) { return AnsiString(wstr); } -////////////////////////////////////////////////////////////////////////// -bool StringUtil::startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString startPart = str.substr(0, patternLength); - - if (ignoreCase) return CompareNoCase(startPart, pattern); - else return (startPart == pattern);*/ - if (!ignoreCase) { - return str.hasPrefix(pattern); - } else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) { - return false; - } - - AnsiString startPart(str.c_str(), patternLength); - uint32 likeness = startPart.compareToIgnoreCase(pattern.c_str()); - return (likeness == 0); - } -} - -////////////////////////////////////////////////////////////////////////// -bool StringUtil::endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase) { - /* size_t strLength = str.size(); // TODO: Remove - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) - return false; - - AnsiString endPart = str.substr(strLength - patternLength, patternLength); - - if (ignoreCase) return CompareNoCase(endPart, pattern); - else return (endPart == pattern);*/ - if (!ignoreCase) { - return str.hasSuffix(pattern); - } else { - size_t strLength = str.size(); - size_t patternLength = pattern.size(); - - if (strLength < patternLength || patternLength == 0) { - return false; - } - - Common::String endPart(str.c_str() + (strLength - patternLength), patternLength); - uint32 likeness = str.compareToIgnoreCase(pattern.c_str()); - return (likeness != 0); - } -} - ////////////////////////////////////////////////////////////////////////// bool StringUtil::isUtf8BOM(const byte *buffer, uint32 bufferSize) { if (bufferSize > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { @@ -270,9 +214,6 @@ bool StringUtil::isUtf8BOM(const byte *buffer, uint32 bufferSize) { ////////////////////////////////////////////////////////////////////////// int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) { - /*size_t pos = str.find(toFind, startFrom); - if (pos == str.npos) return -1; - else return pos;*/ const char *index = strstr(str.c_str(), toFind.c_str()); if (index == NULL) { return -1; diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h index 6a10b63ac4..582007917d 100644 --- a/engines/wintermute/utils/string_util.h +++ b/engines/wintermute/utils/string_util.h @@ -42,9 +42,6 @@ public: static WideString ansiToWide(const AnsiString &str); static AnsiString wideToAnsi(const WideString &str); - static bool startsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool endsWith(const AnsiString &str, const AnsiString &pattern, bool ignoreCase = false); - static bool isUtf8BOM(const byte *buffer, uint32 bufferSize); static int indexOf(const WideString &str, const WideString &toFind, size_t startFrom); -- cgit v1.2.3 From 6b07218eb24e91865eee277758112e5bb4fecd97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 18:22:10 +0200 Subject: WINTERMUTE: Remove statics and silence spam in debug console. --- engines/wintermute/base/base_parser.cpp | 21 ++++++++------- engines/wintermute/base/base_parser.h | 8 +++--- .../wintermute/base/font/base_font_truetype.cpp | 7 +---- .../base/gfx/osystem/base_render_osystem.cpp | 21 ++++++--------- .../base/gfx/osystem/base_render_osystem.h | 2 +- engines/wintermute/platform_osystem.h | 1 + engines/wintermute/utils/string_util.cpp | 10 ------- engines/wintermute/video/video_theora_player.cpp | 5 ++-- engines/wintermute/wintermute.cpp | 31 ++++------------------ 9 files changed, 34 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 5d5a2d534d..1b39b55768 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -64,7 +64,7 @@ char *BaseParser::getLastOffender() { ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -119,7 +119,7 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } @@ -205,12 +205,10 @@ char *BaseParser::getAssignmentText(char **buf) { return result; } - -////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *BaseParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; +Common::String BaseParser::getToken(char **buf) { + char token[100]; // TODO: Remove static + char *b = *buf, *t = token; while (true) { while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { b++; @@ -265,7 +263,8 @@ char *BaseParser::getToken(char **buf) { ////////////////////////////////////////////////////////////////////// float BaseParser::getTokenFloat(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. return 0.; @@ -277,7 +276,8 @@ float BaseParser::getTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// int BaseParser::getTokenInt(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. return 0; @@ -289,7 +289,8 @@ int BaseParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (strcmp(t, tok)) { return; // Error } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 3b1979efa1..34266bd5bd 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -40,7 +40,7 @@ TOKEN_TOTAL_COUNT \ }; #define TOKEN_TABLE_START(name) \ - static BaseParser::TokenDesc name [] = \ + static const BaseParser::TokenDesc name [] = \ { #define TOKEN_TABLE(name) \ { TOKEN_ ## name, #name }, @@ -65,7 +65,7 @@ public: public: int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); + int32 getCommand(char **buf, const TokenDesc *tokens, char **params); BaseParser(); virtual ~BaseParser(); private: @@ -73,11 +73,11 @@ private: void skipToken(char **buf, char *tok, char *msg = NULL); int getTokenInt(char **buf); float getTokenFloat(char **buf); - char *getToken(char **buf); + Common::String getToken(char **buf); char *getAssignmentText(char **buf); char *getSubText(char **buf, char open, char close); void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data); int _parserLine; char _lastOffender[255]; char *_whiteSpace; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index a141c68db7..b80bbdc41d 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -568,12 +568,7 @@ bool BaseFontTT::initFont() { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } + if (maxWidth >= 0) { Common::Array lines; _font->wordWrapText(text, maxWidth, lines); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index f407a871b0..fa0663dc65 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -105,7 +105,6 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { setAlphaMod(255); setColorMod(255, 255, 255); _dirtyRect = NULL; - _disableDirtyRects = true; } ////////////////////////////////////////////////////////////////////////// @@ -232,12 +231,10 @@ void BaseRenderOSystem::fade(uint16 alpha) { void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - } - hasWarned = true; + + // TODO: Add fading with dirty rects. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); } Common::Rect fillRect; @@ -461,13 +458,11 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); - } - hasWarned = true; + + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); } + byte r = RGBCOLGetR(color); byte g = RGBCOLGetG(color); byte b = RGBCOLGetB(color); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index dfffc68c17..2b6b5943c2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -115,7 +115,7 @@ private: int _borderRight; int _borderBottom; - bool _disableDirtyRects; + static const bool _disableDirtyRects = true; float _ratioX; float _ratioY; uint32 _colorMod; diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index 53462724bd..ffc9933635 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -64,6 +64,7 @@ public: static char *strlwr(char *string); private: + // Set by initialize on game-startup, the object referred to is also deleted by deinit in WinterMuteEngine static BaseGame *_gameRef; }; diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index b51d094784..ed1d2094d2 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -162,11 +162,6 @@ char simpleAnsiToWide(const AnsiString &str, uint32 &offset) { ////////////////////////////////////////////////////////////////////////// WideString StringUtil::ansiToWide(const AnsiString &str) { // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("StringUtil::AnsiToWide - WideString not supported yet"); - } /*Common::String converted = ""; uint32 index = 0; while (index != str.size()) { @@ -188,11 +183,6 @@ WideString StringUtil::ansiToWide(const AnsiString &str) { AnsiString StringUtil::wideToAnsi(const WideString &wstr) { // using default os locale! // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("StringUtil::WideToAnsi - WideString not supported yet"); - } /* setlocale(LC_CTYPE, ""); size_t wideSize = wcstombs(NULL, wstr.c_str(), 0) + 1; char *str = new char[WideSize]; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index ad99e24534..49ce333b63 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/video/decoders/theora_decoder.h" +#include "engines/wintermute/wintermute.h" #include "common/system.h" namespace WinterMute { @@ -264,10 +265,10 @@ bool VideoTheoraPlayer::update() { if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { - warning("Should loop movie"); + warning("Should loop movie %s", _filename.c_str()); _theoraDecoder->rewind(); } else if (_theoraDecoder->endOfVideo() && !_looping) { - warning("Finished movie"); + debugC(kWinterMuteDebugLog, "Finished movie %s", _filename.c_str()); _state = THEORA_STATE_FINISHED; _playbackStarted = false; if (_freezeGame) { diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 2782ecd2c3..68a9dd6e13 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -77,7 +77,6 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); - debug("WinterMuteEngine::WinterMuteEngine"); _game = NULL; g_wintermute = this; @@ -85,8 +84,6 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) } WinterMuteEngine::~WinterMuteEngine() { - debug("WinterMuteEngine::~WinterMuteEngine"); - // Dispose your resources here deinit(); delete _rnd; @@ -114,39 +111,21 @@ Common::Error WinterMuteEngine::run() { if (g_system->getScreenFormat() != format) { error("Wintermute currently REQUIRES 32bpp"); } - // You could use backend transactions directly as an alternative, - // but it isn't recommended, until you want to handle the error values - // from OSystem::endGFXTransaction yourself. - // This is just an example template: - //_system->beginGFXTransaction(); - // // This setup the graphics mode according to users seetings - // initCommonGFX(false); - // - // // Specify dimensions of game graphics window. - // // In this example: 320x200 - // _system->initSize(320, 200); - //FIXME: You really want to handle - //OSystem::kTransactionSizeChangeFailed here - //_system->endGFXTransaction(); // Create debugger console. It requires GFX to be initialized _console = new Console(this); - // Additional setup. - debug("WinterMuteEngine::init"); - - // Your main even loop should be (invoked from) here. - debug("WinterMuteEngine::go: Hello, World!"); - - DebugMan.enableDebugChannel("enginelog"); - // This test will show up if -d1 and --debugflags=example are specified on the commandline +// DebugMan.enableDebugChannel("enginelog"); debugC(1, kWinterMuteDebugLog, "Engine Debug-LOG enabled"); debugC(2, kWinterMuteDebugSaveGame , "Savegame debugging-enabled"); int ret = 1; + // Additional setup. + debugC(kWinterMuteDebugLog, "WinterMuteEngine::init"); ret = init(); - + + debugC(kWinterMuteDebugLog, "WinterMuteEngine::messageLoop"); if (ret == 0) { ret = messageLoop(); } -- cgit v1.2.3 From 80a67a70cdaad254185ffd9b2042a710e4a6e338 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 19:09:37 +0200 Subject: WINTERMUTE: Add header-guards to BaseEngine --- engines/wintermute/base/base_engine.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 30f241ecc6..b9dcfcb845 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -26,6 +26,9 @@ * Copyright (c) 2011 Jan Nedoma */ +#ifndef WINTERMUTE_BASE_ENGINE_H +#define WINTERMUTE_BASE_ENGINE_H + #include "common/str.h" #include "common/singleton.h" @@ -52,3 +55,5 @@ public: }; } // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 85ce9340bcb425a6c5e8dbcacff5a7fa2fb4c817 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 21:35:11 +0200 Subject: WINTERMUTE: Separate out SaveGame-code from BaseGame --- engines/wintermute/ad/ad_game.cpp | 28 +- engines/wintermute/ad/ad_game.h | 4 - engines/wintermute/base/base_game.cpp | 342 ++++------------------- engines/wintermute/base/base_game.h | 36 +-- engines/wintermute/base/gfx/base_renderer.cpp | 129 +++++++++ engines/wintermute/base/gfx/base_renderer.h | 30 ++ engines/wintermute/base/saveload.cpp | 198 +++++++++++++ engines/wintermute/base/saveload.h | 57 ++++ engines/wintermute/module.mk | 1 + engines/wintermute/system/sys_class_registry.cpp | 8 +- engines/wintermute/wintermute.cpp | 34 +-- 11 files changed, 483 insertions(+), 384 deletions(-) create mode 100644 engines/wintermute/base/saveload.cpp create mode 100644 engines/wintermute/base/saveload.h (limited to 'engines') diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index e399ba5fcf..3bda534a04 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -49,6 +49,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_viewport.h" #include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/saveload.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" @@ -1453,29 +1454,6 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// -bool AdGame::loadGame(const char *filename) { - bool ret = BaseGame::loadGame(filename); - if (DID_SUCCEED(ret)) { - SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "AdRegion", NULL); - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool AdGame::initAfterLoad() { - BaseGame::initAfterLoad(); - SystemClassRegistry::getInstance()->enumInstances(afterLoadScene, "AdScene", NULL); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void AdGame::afterLoadScene(void *scene, void *data) { - ((AdScene *)scene)->afterLoad(); -} - - ////////////////////////////////////////////////////////////////////////// void AdGame::setPrevSceneName(const char *name) { delete[] _prevSceneName; @@ -1910,9 +1888,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { if (_stateEx == GAME_WAITING_RESPONSE) { _responseBox->display(); } - if (_indicatorDisplay) { - displayIndicator(); - } + _renderer->displayIndicator(); if (doUpdate || displayAll) { diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 7f76b959d4..080aea40aa 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -54,9 +54,6 @@ public: virtual bool displayDebugInfo(); - virtual bool initAfterLoad(); - static void afterLoadScene(void *scene, void *data); - bool addSpeechDir(const char *dir); bool removeSpeechDir(const char *dir); char *findSpeechFile(char *StringID); @@ -101,7 +98,6 @@ public: void setPrevSceneName(const char *name); void setPrevSceneFilename(const char *name); - virtual bool loadGame(const char *filename); AdItem *_selectedItem; bool cleanup(); DECLARE_PERSISTENT(AdGame, BaseGame) diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 0453222e24..b92da4c11b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -49,10 +49,7 @@ #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/saveload.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/base/scriptables/script_stack.h" @@ -61,6 +58,10 @@ #include "engines/wintermute/video/video_player.h" #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/ui/ui_window.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" #include "common/config-manager.h" @@ -195,13 +196,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _thumbnailWidth = _thumbnailHeight = 0; - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; _richSavedGames = false; _savedGameExt = NULL; BaseUtils::setString(&_savedGameExt, "dsv"); @@ -213,13 +207,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _musicCrossfadeChannel2 = -1; _musicCrossfadeSwap = false; - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - _localSaveDir = NULL; BaseUtils::setString(&_localSaveDir, "saves"); _saveDirChecked = false; @@ -286,7 +273,6 @@ BaseGame::~BaseGame() { delete _cachedThumbnail; - delete _saveLoadImage; delete _mathClass; delete _transMgr; @@ -307,7 +293,6 @@ BaseGame::~BaseGame() { _cachedThumbnail = NULL; - _saveLoadImage = NULL; _mathClass = NULL; _transMgr = NULL; @@ -352,11 +337,6 @@ bool BaseGame::cleanup() { _windows.clear(); // refs only _focusedWindow = NULL; // ref only - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - delete _cursorNoninteractive; delete _cursor; delete _activeCursor; @@ -488,17 +468,7 @@ bool BaseGame::initialize2() { // we know whether we are going to be accelerated bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; - - if (_indicatorY == -1) { - _indicatorY = _renderer->_height - _indicatorHeight; - } - if (_indicatorX == -1) { - _indicatorX = 0; - } - if (_indicatorWidth == -1) { - _indicatorWidth = _renderer->_width; - } - + _renderer->initIndicator(); return STATUS_OK; } @@ -780,6 +750,20 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(LOCAL_SAVE_DIR) TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) TOKEN_TABLE_END + + // Declare a few variables necessary for moving data from these settings over to the renderer: + // The values are the same as the defaults set in BaseRenderer. + int loadImageX = 0; + int loadImageY = 0; + int saveImageX = 0; + int saveImageY = 0; + int indicatorX = -1; + int indicatorY = -1; + int indicatorWidth = -1; + int indicatorHeight = 8; + uint32 indicatorColor = BYTETORGBA(255, 0, 0, 128); + Common::String loadImageName = ""; + Common::String saveImageName = ""; byte *params; int cmd; @@ -896,50 +880,50 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &_indicatorX); + parser.scanStr((char *)params, "%d", &indicatorX); break; case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &_indicatorY); + parser.scanStr((char *)params, "%d", &indicatorY); break; case TOKEN_INDICATOR_COLOR: { int r, g, b, a; parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = BYTETORGBA(r, g, b, a); + indicatorColor = BYTETORGBA(r, g, b, a); } break; case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &_indicatorWidth); + parser.scanStr((char *)params, "%d", &indicatorWidth); break; case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &_indicatorHeight); + parser.scanStr((char *)params, "%d", &indicatorHeight); break; case TOKEN_SAVE_IMAGE: - BaseUtils::setString(&_saveImageName, (char *)params); + saveImageName = (char *) params; break; case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &_saveImageX); + parser.scanStr((char *)params, "%d", &saveImageX); break; case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_saveImageY); + parser.scanStr((char *)params, "%d", &saveImageY); break; case TOKEN_LOAD_IMAGE: - BaseUtils::setString(&_loadImageName, (char *)params); + loadImageName = (char *) params; break; case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &_loadImageX); + parser.scanStr((char *)params, "%d", &loadImageX); break; case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_loadImageY); + parser.scanStr((char *)params, "%d", &loadImageY); break; case TOKEN_LOCAL_SAVE_DIR: @@ -952,6 +936,11 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } } + _renderer->setIndicator(indicatorWidth, indicatorHeight, indicatorX, indicatorY, indicatorColor); + _renderer->initIndicator(); // In case we just reset the values. + _renderer->setSaveImage(saveImageName.c_str(), saveImageX, saveImageY); + _renderer->setLoadingScreen(loadImageName.c_str(), loadImageX, loadImageY); + if (!_systemFont) { _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); } @@ -1624,7 +1613,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); int slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(slot)); + stack->pushBool(SaveLoad::isSaveSlotUsed(slot)); return STATUS_OK; } @@ -1636,7 +1625,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int slot = stack->pop()->getInt(); char desc[512]; desc[0] = '\0'; - getSaveSlotDescription(slot, desc); + SaveLoad::getSaveSlotDescription(slot, desc); stack->pushString(desc); return STATUS_OK; } @@ -1647,7 +1636,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "EmptySaveSlot") == 0) { stack->correctParams(1); int slot = stack->pop()->getInt(); - emptySaveSlot(slot); + SaveLoad::emptySaveSlot(slot); stack->pushNULL(); return STATUS_OK; } @@ -1979,14 +1968,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); ScValue *val = stack->pop(); - _loadImageX = stack->pop()->getInt(); - _loadImageY = stack->pop()->getInt(); + int loadImageX = stack->pop()->getInt(); + int loadImageY = stack->pop()->getInt(); if (val->isNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; + _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); } else { - BaseUtils::setString(&_loadImageName, val->getString()); + _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); } stack->pushNULL(); return STATUS_OK; @@ -1998,14 +1986,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); ScValue *val = stack->pop(); - _saveImageX = stack->pop()->getInt(); - _saveImageY = stack->pop()->getInt(); + int saveImageX = stack->pop()->getInt(); + int saveImageY = stack->pop()->getInt(); if (val->isNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; + _renderer->setSaveImage(NULL, saveImageX, saveImageY); } else { - BaseUtils::setString(&_saveImageName, val->getString()); + _renderer->setSaveImage(NULL, saveImageX, saveImageY); } stack->pushNULL(); return STATUS_OK; @@ -3316,48 +3303,7 @@ bool BaseGame::showCursor() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - LOG(0, "Saving game '%s'...", filename); - - _gameRef->applyEvent("BeforeSave", true); - - bool ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(); - if (DID_SUCCEED(ret = pm->initSave(desc))) { - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { - if (DID_SUCCEED(ret = pm->saveFile(filename))) { - ConfMan.setInt("most_recent_saveslot", slot); - } - } - } - } - - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; + return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); } @@ -3368,102 +3314,17 @@ bool BaseGame::loadGame(int slot) { _loading = false; _scheduledLoadSlot = -1; - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); + Common::String filename = SaveLoad::getSaveSlotFilename(slot); - return loadGame(filename); + return loadGame(filename.c_str()); } ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadGame(const char *filename) { - LOG(0, "Loading game '%s'...", filename); - - bool ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(); - if (DID_SUCCEED(ret = pm->initLoad(filename))) { - //if (DID_SUCCEED(ret = cleanup())) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - } - } - } - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::initAfterLoad() { - SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); - - return STATUS_OK; + return SaveLoad::loadGame(filename, _gameRef); } -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadRegion(void *region, void *data) { - ((BaseRegion *)region)->createRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadSubFrame(void *subframe, void *data) { - ((BaseSubFrame *)subframe)->setSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadSound(void *sound, void *data) { - ((BaseSound *)sound)->setSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadFont(void *font, void *data) { - ((BaseFont *)font)->afterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadScript(void *script, void *data) { - ((ScScript *)script)->afterLoad(); -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayWindows(bool inGame) { bool res; @@ -3773,13 +3634,8 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); + + _renderer->persistSaveLoadImages(persistMgr); persistMgr->transfer(TMEMBER_INT(_textEncoding)); persistMgr->transfer(TMEMBER(_textRTL)); @@ -3907,13 +3763,13 @@ void BaseGame::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::handleMouseWheel(int Delta) { +bool BaseGame::handleMouseWheel(int delta) { bool handled = false; if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + handled = _gameRef->_focusedWindow->handleMouseWheel(delta); if (!handled) { - if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + if (delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); handled = true; } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { @@ -3925,7 +3781,7 @@ bool BaseGame::handleMouseWheel(int Delta) { } if (!handled) { - if (Delta < 0) { + if (delta < 0) { applyEvent("MouseWheelDown"); } else { applyEvent("MouseWheelUp"); @@ -3981,61 +3837,6 @@ void BaseGame::setWindowTitle() { } -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - BasePersistenceManager *pm = new BasePersistenceManager(); - Common::String filename = pm->getFilenameForSlot(slot); - delete pm; - strcpy(buffer, filename.c_str()); - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { - buffer[0] = '\0'; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - if (!pm) { - return STATUS_FAILED; - } - - if (DID_FAIL(pm->initLoad(filename))) { - delete pm; - return STATUS_FAILED; - } - - strcpy(buffer, pm->_savedDescription); - delete pm; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - bool ret = pm->getSaveExists(slot); - delete pm; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::emptySaveSlot(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); - delete pm; - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::setActiveObject(BaseObject *obj) { // not-active when game is frozen @@ -4181,35 +3982,8 @@ bool BaseGame::displayContent(bool doUpdate, bool displayAll) { bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); - if (_indicatorDisplay) { - displayIndicator(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayIndicator() { - if (_saveLoadImage) { - Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) { - _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - } else { - _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { - return STATUS_OK; - } - _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) { - _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - } + _renderer->displayIndicator(); - _renderer->setup2D(); return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index fd20608a42..8a587da3e3 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -109,8 +109,6 @@ public: void DEBUG_DumpClassRegistry(); bool setWaitCursor(const char *filename); - int _indicatorProgress; // TODO: Hide - int _thumbnailWidth; int _thumbnailHeight; @@ -204,9 +202,9 @@ public: bool displayWindows(bool inGame = false); bool _useD3D; virtual bool cleanup(); - virtual bool loadGame(int slot); - virtual bool loadGame(const char *filename); - virtual bool saveGame(int slot, const char *desc, bool quickSave = false); + bool loadGame(int slot); + bool loadGame(const char *filename); + bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); BaseObject *_activeObject; @@ -248,7 +246,6 @@ public: BaseSprite *_lastCursor; bool drawCursor(BaseSprite *Cursor); - virtual bool initAfterLoad(); BaseSaveThumbHelper *_cachedThumbnail; void addMem(int bytes); bool _touchInterface; @@ -261,18 +258,10 @@ protected: BaseFader *_fader; - bool _indicatorDisplay; - bool displayIndicator(); - int _freezeLevel; VideoPlayer *_videoPlayer; VideoTheoraPlayer *_theoraPlayer; - static void afterLoadRegion(void *region, void *data); private: - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); bool _mouseRightDown; bool _mouseMidlleDown; bool _settingsRequireAcceleration; @@ -286,26 +275,11 @@ private: virtual bool invalidateDeviceObjects(); virtual bool restoreDeviceObjects(); - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - char *_localSaveDir; bool _saveDirChecked; bool _richSavedGames; char *_savedGameExt; - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - BaseSurface *_saveLoadImage; - bool _reportTextureFormat; // FPS stuff @@ -324,10 +298,6 @@ private: bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); void setWindowTitle(); bool resumeMusic(int channel); diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index cc6167a749..cd065f3436 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { @@ -44,6 +45,22 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _windowed = true; _forceAlphaColor = 0x00; + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + + _loadImageName = ""; + _saveImageName = ""; + _saveLoadImage = NULL; + _loadInProgress = false; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + _width = _height = _bPP = 0; BasePlatform::setRectEmpty(&_monitorRect); @@ -56,6 +73,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { BaseRenderer::~BaseRenderer() { deleteRectList(); unclipCursor(); + delete _saveLoadImage; } @@ -64,6 +82,90 @@ void BaseRenderer::initLoop() { deleteRectList(); } +void BaseRenderer::initIndicator() { + if (_indicatorY == -1) { + _indicatorY = _height - _indicatorHeight; + } + if (_indicatorX == -1) { + _indicatorX = 0; + } + if (_indicatorWidth == -1) { + _indicatorWidth = _width; + } +} + +void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 color) { + _indicatorWidth = width; + _indicatorHeight = height; + _indicatorX = x; + _indicatorY = y; + _indicatorColor = color; +} + +void BaseRenderer::setIndicatorVal(int value) { + _indicatorProgress = value; +} + +void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { + // TODO: Handle NULL + _loadImageName = filename; + _loadImageX = x; + _loadImageY = y; +} + +void BaseRenderer::setSaveImage(const char *filename, int x, int y) { + // TODO: Handle NULL + _saveImageName = filename; + _saveImageX = x; + _saveImageY = y; +} + +void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { + _indicatorDisplay = true; + _indicatorProgress = 0; + + if (isSaving && !quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } else { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + _loadInProgress = true; + } +} + +void BaseRenderer::endSaveLoad() { + _loadInProgress = false; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; +} + +void BaseRenderer::persistSaveLoadImages(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); +} ////////////////////////////////////////////////////////////////////// BaseObject *BaseRenderer::getObjectAt(int x, int y) { @@ -234,4 +336,31 @@ void BaseRenderer::addRectToList(BaseActiveRect *rect) { _rectList.push_back(rect); } +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::displayIndicator() { + if (!_indicatorDisplay) { + return STATUS_OK; + } + if (_saveLoadImage) { + Rect32 rc; + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + return STATUS_OK; + } + setupLines(); + for (int i = 0; i < _indicatorHeight; i++) { + drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + } + + setup2D(); + return STATUS_OK; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 008db69713..a36a3ca9c0 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -40,6 +40,7 @@ class BaseImage; class BaseActiveRect; class BaseObject; class BaseSurface; +class BasePersistenceManager; /** * @class BaseRenderer a common interface for the rendering portion of WME @@ -166,6 +167,35 @@ public: uint32 _forceAlphaColor; void addRectToList(BaseActiveRect *rect); + + // Indicator & Save/Load-related functions + void initIndicator(); + void setIndicatorVal(int value); + void setIndicator(int width, int height, int x, int y, uint32 color); + void persistSaveLoadImages(BasePersistenceManager *persistMgr); + void initSaveLoad(bool isSaving, bool quickSave = false); + void endSaveLoad(); + void setLoadingScreen(const char *filename, int x, int y); + void setSaveImage(const char *filename, int x, int y); + + bool displayIndicator(); +private: + Common::String _loadImageName; + Common::String _saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + BaseSurface *_saveLoadImage; + + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + bool _loadInProgress; + bool _indicatorDisplay; + int _indicatorProgress; protected: uint32 _clipperWindow; diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp new file mode 100644 index 0000000000..aea474fd44 --- /dev/null +++ b/engines/wintermute/base/saveload.cpp @@ -0,0 +1,198 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/saveload.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/base_game.h" // Temporary +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "common/savefile.h" +#include "common/config-manager.h" + +namespace WinterMute { + +bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { + gameRef->LOG(0, "Loading game '%s'...", filename.c_str()); + + bool ret; + + gameRef->_renderer->initSaveLoad(false); + + gameRef->_loadInProgress = true; + BasePersistenceManager *pm = new BasePersistenceManager(); + if (DID_SUCCEED(ret = pm->initLoad(filename))) { + //if (DID_SUCCEED(ret = cleanup())) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(gameRef, pm))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(gameRef, pm))) { + // data initialization after load + SaveLoad::initAfterLoad(); + + gameRef->applyEvent("AfterLoad", true); + + gameRef->displayContent(true, false); + //_renderer->flip(); + } + } + } + + delete pm; + gameRef->_loadInProgress = false; + + gameRef->_renderer->endSaveLoad(); + + //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); + // AdGame: + if (DID_SUCCEED(ret)) { + SystemClassRegistry::getInstance()->enumInstances(SaveLoad::afterLoadRegion, "AdRegion", NULL); + } + return ret; +} + +bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef) { + Common::String filename = SaveLoad::getSaveSlotFilename(slot); + + gameRef->LOG(0, "Saving game '%s'...", filename.c_str()); + + gameRef->applyEvent("BeforeSave", true); + + bool ret; + + BasePersistenceManager *pm = new BasePersistenceManager(); + if (DID_SUCCEED(ret = pm->initSave(desc))) { + gameRef->_renderer->initSaveLoad(true, quickSave); // TODO: The original code inited the indicator before the conditionals + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = pm->saveFile(filename))) { + ConfMan.setInt("most_recent_saveslot", slot); + } + } + } + } + + delete pm; + + gameRef->_renderer->endSaveLoad(); + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool SaveLoad::initAfterLoad() { + SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); + // AdGame: + SystemClassRegistry::getInstance()->enumInstances(afterLoadScene, "AdScene", NULL); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadScene(void *scene, void *data) { + ((AdScene *)scene)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadRegion(void *region, void *data) { + ((BaseRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadSubFrame(void *subframe, void *data) { + ((BaseSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadSound(void *sound, void *data) { + ((BaseSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadFont(void *font, void *data) { + ((BaseFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadScript(void *script, void *data) { + ((ScScript *)script)->afterLoad(); +} + +Common::String SaveLoad::getSaveSlotFilename(int slot) { + BasePersistenceManager *pm = new BasePersistenceManager(); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); + return filename; +} + +bool SaveLoad::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + if (!pm) { + return false; + } + + if (!(pm->initLoad(filename))) { + delete pm; + return false; + } + + strcpy(buffer, pm->_savedDescription); + delete pm; + + return true; +} + +bool SaveLoad::isSaveSlotUsed(int slot) { + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + bool ret = pm->getSaveExists(slot); + delete pm; + return ret; +} + +bool SaveLoad::emptySaveSlot(int slot) { + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return true; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h new file mode 100644 index 0000000000..59cdceb038 --- /dev/null +++ b/engines/wintermute/base/saveload.h @@ -0,0 +1,57 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SAVEGAME_H +#define WINTERMUTE_SAVEGAME_H + +#include "common/str.h" + +namespace WinterMute { +class BaseGame; +class SaveLoad { +public: + static bool emptySaveSlot(int slot); + static bool isSaveSlotUsed(int slot); + static bool getSaveSlotDescription(int slot, char *buffer); + static Common::String getSaveSlotFilename(int slot); + + static bool loadGame(const Common::String &filename, BaseGame *gameRef); + static bool saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef); + static bool initAfterLoad(); + static void afterLoadScene(void *scene, void *data); + static void afterLoadRegion(void *region, void *data); +private: + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 2d253bca84..ee36e4d7a6 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -84,6 +84,7 @@ MODULE_OBJS := \ base/base_surface_storage.o \ base/base_transition_manager.o \ base/base_viewport.o \ + base/saveload.o \ detection.o \ graphics/transparent_surface.o \ graphics/tga.o \ diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index 09e43529e3..e991fb3f07 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -200,7 +200,7 @@ bool SystemClassRegistry::saveTable(BaseGame *gameRef, BasePersistenceManager *p counter++; if (!quickSave) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->_renderer->setIndicatorVal((int)(50.0f / (float)((float)_classes.size() / (float)counter))); gameRef->displayContent(false); gameRef->_renderer->flip(); } @@ -234,7 +234,7 @@ bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *p uint32 numClasses = persistMgr->getDWORD(); for (uint32 i = 0; i < numClasses; i++) { - gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i)); + gameRef->_renderer->setIndicatorVal((int)(50.0f / (float)((float)numClasses / (float)i))); gameRef->displayContentSimple(); gameRef->_renderer->flip(); @@ -270,7 +270,7 @@ bool SystemClassRegistry::saveInstances(BaseGame *gameRef, BasePersistenceManage if (!quickSave) { if (counter % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter)); + gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter))); gameRef->displayContent(false); gameRef->_renderer->flip(); } @@ -290,7 +290,7 @@ bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManage for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { - gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i)); + gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)numInstances / (float)i))); gameRef->displayContentSimple(); gameRef->_renderer->flip(); } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 68a9dd6e13..af0251d01a 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -144,33 +144,6 @@ int WinterMuteEngine::init() { bool windowedMode = !ConfMan.getBool("fullscreen"); - // parse command line - char *saveGame = NULL; - /* for (int i = 0; i < argc; i++) { - strcpy(param, argv[i]); - - if (scumm_stricmp(param, "-project") == 0) { - if (argc > i) strcpy(param, argv[i + 1]); - else param[0] = '\0'; - - if (strcmp(param, "") != 0) { - char *iniDir = BaseUtils::GetPath(param); - char *iniName = BaseUtils::GetFilename(param); - - // switch to ini's dir - warning("TODO: Place ini-files somewhere"); - // chdir(IniDir); - - // set ini name - sprintf(param, "./%s", IniName); - _game->_registry->SetIniName(param); - - delete[] IniDir; - delete[] IniName; - } - } else if (scumm_stricmp(param, "-windowed") == 0) windowedMode = true; - }*/ - if (ConfMan.hasKey("debug_mode")) { if (ConfMan.getBool("debug_mode")) { _game->DEBUG_DebugEnable("./wme.log"); @@ -240,7 +213,7 @@ int WinterMuteEngine::init() { _game = NULL; return false; } - //_game->setWindowTitle(); + _game->_renderer->_ready = true; _game->_miniUpdateEnabled = true; @@ -252,11 +225,6 @@ int WinterMuteEngine::init() { _game->loadGame(slot); } - if (saveGame) { - _game->loadGame(saveGame); - delete[] saveGame; - } - // all set, ready to go return 0; } -- cgit v1.2.3 From 43611724441e880b7283ae195d40f5e63aa6affd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 19:41:44 +0200 Subject: WINTERMUTE: Redraw ONLY the indicator when saving/loading. --- engines/wintermute/base/base_sub_frame.cpp | 7 +------ engines/wintermute/base/gfx/base_renderer.cpp | 14 ++++++++++++-- engines/wintermute/base/gfx/base_renderer.h | 8 +++++++- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 7 ++++++- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 1 + engines/wintermute/system/sys_class_registry.cpp | 8 -------- 6 files changed, 27 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 006f15fa2c..7f527392dc 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -365,12 +365,6 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - if (persistMgr->getIsSaving()) { - getRect(); // To make sure it gets updated if it was never loaded. - } else { - _wantsDefaultRect = false; - } - persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); persistMgr->transfer(TMEMBER(_alpha)); @@ -379,6 +373,7 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_hotspotX)); persistMgr->transfer(TMEMBER(_hotspotY)); persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_wantsDefaultRect)); persistMgr->transfer(TMEMBER(_surfaceFilename)); persistMgr->transfer(TMEMBER(_cKDefault)); diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index cd065f3436..5d81c44c25 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -52,6 +52,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _indicatorY = -1; _indicatorWidth = -1; _indicatorHeight = 8; + _indicatorWidthDrawn = 0; _loadImageName = ""; _saveImageName = ""; @@ -103,7 +104,10 @@ void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 colo } void BaseRenderer::setIndicatorVal(int value) { + bool redisplay = (_indicatorProgress != value); _indicatorProgress = value; + if (redisplay) + displayIndicator(); } void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { @@ -153,6 +157,7 @@ void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { void BaseRenderer::endSaveLoad() { _loadInProgress = false; _indicatorDisplay = false; + _indicatorWidthDrawn = 0; delete _saveLoadImage; _saveLoadImage = NULL; @@ -338,7 +343,7 @@ void BaseRenderer::addRectToList(BaseActiveRect *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::displayIndicator() { - if (!_indicatorDisplay) { + if (!_indicatorDisplay || !_indicatorProgress) { return STATUS_OK; } if (_saveLoadImage) { @@ -355,11 +360,16 @@ bool BaseRenderer::displayIndicator() { return STATUS_OK; } setupLines(); + int curWidth = (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)); for (int i = 0; i < _indicatorHeight; i++) { - drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + drawLine(_indicatorX, _indicatorY + i, _indicatorX + curWidth, _indicatorY + i, _indicatorColor); } setup2D(); + _indicatorWidthDrawn = curWidth; + if (_indicatorWidthDrawn) { + indicatorFlip(); + } return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index a36a3ca9c0..49b5e187eb 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -110,6 +110,11 @@ public: * @return true if successfull, false on error. */ virtual bool flip() = 0; + /** + * Special flip for the indicator drawn during save/load + * essentially, just copies the region defined by the _indicator-variables. + */ + virtual bool indicatorFlip() = 0; virtual void initLoop(); virtual bool setup2D(bool force = false); virtual bool setupLines(); @@ -179,7 +184,7 @@ public: void setSaveImage(const char *filename, int x, int y); bool displayIndicator(); -private: +protected: Common::String _loadImageName; Common::String _saveImageName; int _saveImageX; @@ -188,6 +193,7 @@ private: int _loadImageY; BaseSurface *_saveLoadImage; + int _indicatorWidthDrawn; uint32 _indicatorColor; int _indicatorX; int _indicatorY; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index fa0663dc65..bc952b0b36 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -185,7 +185,12 @@ void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { _colorMod = BS_ARGB(alpha, r, g, b); } -////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::indicatorFlip() { + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_indicatorX, _indicatorY), _renderSurface->pitch, _indicatorX, _indicatorY, _indicatorWidthDrawn, _indicatorHeight); + g_system->updateScreen(); + return STATUS_OK; +} + bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 2b6b5943c2..08fd6cf9ab 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -66,6 +66,7 @@ public: bool initRenderer(int width, int height, bool windowed); bool flip(); + virtual bool indicatorFlip(); bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); Graphics::PixelFormat getPixelFormat() const; void fade(uint16 alpha); diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index e991fb3f07..d9303ea729 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -201,8 +201,6 @@ bool SystemClassRegistry::saveTable(BaseGame *gameRef, BasePersistenceManager *p if (!quickSave) { gameRef->_renderer->setIndicatorVal((int)(50.0f / (float)((float)_classes.size() / (float)counter))); - gameRef->displayContent(false); - gameRef->_renderer->flip(); } (it->_value)->saveTable(gameRef, persistMgr); @@ -235,8 +233,6 @@ bool SystemClassRegistry::loadTable(BaseGame *gameRef, BasePersistenceManager *p for (uint32 i = 0; i < numClasses; i++) { gameRef->_renderer->setIndicatorVal((int)(50.0f / (float)((float)numClasses / (float)i))); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); Common::String className = persistMgr->getStringObj(); NameMap::iterator mapIt = _nameMap.find(className); @@ -271,8 +267,6 @@ bool SystemClassRegistry::saveInstances(BaseGame *gameRef, BasePersistenceManage if (!quickSave) { if (counter % 20 == 0) { gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter))); - gameRef->displayContent(false); - gameRef->_renderer->flip(); } } gameRef->miniUpdate(); @@ -291,8 +285,6 @@ bool SystemClassRegistry::loadInstances(BaseGame *gameRef, BasePersistenceManage for (int i = 0; i < numInstances; i++) { if (i % 20 == 0) { gameRef->_renderer->setIndicatorVal((int)(50.0f + 50.0f / (float)((float)numInstances / (float)i))); - gameRef->displayContentSimple(); - gameRef->_renderer->flip(); } checkHeader("", persistMgr); -- cgit v1.2.3 From 18409fe5c03264ca74902e263f80523692f76a77 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 19:43:55 +0200 Subject: WINTERMUTE: Fix a memory leak in BaseScriptHolder --- engines/wintermute/base/base_script_holder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 19bd82f2b0..b40647dc7b 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -287,9 +287,10 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { - const char *name; + char *name; persistMgr->transfer(TMEMBER(name)); setName(name); + delete[] name; } _scripts.persist(persistMgr); -- cgit v1.2.3 From 6330c1e5fdced523e1e245eac67754cd2b519c32 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 20:39:04 +0200 Subject: WINTERMUTE: Fix a few memory-leaks --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 ++ engines/wintermute/video/video_theora_player.cpp | 5 +++++ engines/wintermute/wintermute.cpp | 1 + 3 files changed, 8 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index c449f6471c..9f0e605f39 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -139,6 +139,7 @@ bool BaseSurfaceOSystem::finishLoad() { // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + _surface->free(); delete _surface; if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); @@ -412,6 +413,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; + _surface->free(); _surface->copyFrom(surface); _hasAlpha = hasAlpha; BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 49ce333b63..fea81bdf9d 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -109,6 +109,9 @@ void VideoTheoraPlayer::cleanup() { } _surface.free(); + if (_theoraDecoder) { + _theoraDecoder->close(); + } delete _theoraDecoder; _theoraDecoder = NULL; delete _alphaImage; @@ -187,6 +190,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _playbackStarted = false; float width, height; if (_theoraDecoder) { + _surface.free(); _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); _state = THEORA_STATE_PLAYING; _looping = looping; @@ -277,6 +281,7 @@ bool VideoTheoraPlayer::update() { } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { + _surface.free(); _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); if (_texture) { writeVideo(); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index af0251d01a..80b02f7db6 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -88,6 +88,7 @@ WinterMuteEngine::~WinterMuteEngine() { deinit(); delete _rnd; delete _game; + delete _console; g_wintermute = NULL; // Remove all of our debug levels here -- cgit v1.2.3 From 5a1fae94fb1e2d9f5caa21b7c9bad1457cbfc807 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 23:46:46 +0200 Subject: WINTERMUTE: Implement load from GMM. --- engines/wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/wintermute.cpp | 11 +++++++++++ engines/wintermute/wintermute.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index b6cd59328d..4236203292 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -89,7 +89,7 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool dele ////////////////////////////////////////////////////////////////////////// BasePersistenceManager::~BasePersistenceManager() { cleanup(); - if (_deleteSingleton) + if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) BaseEngine::destroy(); } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 80b02f7db6..5ee98b8158 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -99,6 +99,8 @@ bool WinterMuteEngine::hasFeature(EngineFeature f) const { switch (f) { case kSupportsRTL: return true; + case kSupportsLoadingDuringRuntime: + return true; default: return false; } @@ -294,6 +296,15 @@ void WinterMuteEngine::deinit() { BaseEngine::destroy(); } +Common::Error WinterMuteEngine::loadGameState(int slot) { + BaseEngine::instance().getGameRef()->loadGame(slot); + return Common::kNoError; +} + +bool WinterMuteEngine::canLoadGameStateCurrently() { + return true; +} + bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { bool retVal = false; caption = name = "(invalid)"; diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 14c2ba2ab5..e9deea91d3 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -53,6 +53,8 @@ public: Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } SystemClassRegistry *getClassRegistry(){ return _classReg; } uint32 randInt(int from, int to); + virtual Common::Error loadGameState(int slot); + virtual bool canLoadGameStateCurrently(); // For detection-purposes: static bool getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption); private: -- cgit v1.2.3 From 2e636f29fbd0a3ca8706cc5a4c57119ed0f9c4bf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 23:55:11 +0200 Subject: WINTERMUTE: Implement GMM-saving. --- engines/wintermute/wintermute.cpp | 11 +++++++++++ engines/wintermute/wintermute.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 5ee98b8158..038c9567ac 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -101,6 +101,8 @@ bool WinterMuteEngine::hasFeature(EngineFeature f) const { return true; case kSupportsLoadingDuringRuntime: return true; + case kSupportsSavingDuringRuntime: + return true; default: return false; } @@ -301,6 +303,15 @@ Common::Error WinterMuteEngine::loadGameState(int slot) { return Common::kNoError; } +Common::Error WinterMuteEngine::saveGameState(int slot, const Common::String &desc) { + BaseEngine::instance().getGameRef()->saveGame(slot, desc.c_str(), false); + return Common::kNoError; +} + +bool WinterMuteEngine::canSaveGameStateCurrently() { + return true; +} + bool WinterMuteEngine::canLoadGameStateCurrently() { return true; } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index e9deea91d3..8dd1b0b98e 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -55,6 +55,8 @@ public: uint32 randInt(int from, int to); virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); + virtual Common::Error saveGameState(int slot, const Common::String &desc); + virtual bool canSaveGameStateCurrently(); // For detection-purposes: static bool getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption); private: -- cgit v1.2.3 From b8b31c86d2b04c9da55cff80205ab25e39de8873 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 31 Jul 2012 00:04:34 +0200 Subject: WINTERMUTE: Clean out some unused code. --- engines/wintermute/wintermute.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 038c9567ac..2dadd51b09 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -269,23 +269,6 @@ int WinterMuteEngine::messageLoop() { } if (_game) { - // remember previous window position - /* - if (_game->_renderer && _game->_renderer->_windowed) - { - if (!::IsIconic(_game->_renderer->_window)) - { - int posX = _game->_renderer->_windowRect.left; - int posY = _game->_renderer->_windowRect.top; - PosX -= _game->_renderer->_monitorRect.left; - PosY -= _game->_renderer->_monitorRect.top; - - _game->_registry->writeInt("Video", "WindowPosX", PosX); - _game->_registry->writeInt("Video", "WindowPosY", PosY); - } - } - */ - delete _game; _game = NULL; } -- cgit v1.2.3 From 9bda50ef48e47160c2788399bf7a4d4b04848aca Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 31 Jul 2012 01:07:19 +0200 Subject: WINTERMUTE: Add a readme.txt for the engine. --- engines/wintermute/readme.txt | 155 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 engines/wintermute/readme.txt (limited to 'engines') diff --git a/engines/wintermute/readme.txt b/engines/wintermute/readme.txt new file mode 100644 index 0000000000..57592dac2a --- /dev/null +++ b/engines/wintermute/readme.txt @@ -0,0 +1,155 @@ +Wintermute Engine - Copyright (c) 2011 Jan Nedoma +ScummVM port by Einar Johan Trøan Sømåen (somaen) + +*************************** +*** General information *** +*************************** +The Wintermute Engine is a game engine mainly aimed at creating adventure +games, it supports both 3D, 2.5D, 2D and First-Person games, and has numerous +games both free, open-source and commercial created with it. This port was +created by somaen as part of Google Summer of Code 2012. + +**************** +*** Features *** +**************** +This port of the Wintermute Engine (WME) is based on WME Lite, which lacks the following functionality +originally found in WME: (from http://res.dead-code.org/doku.php/wmelite:start) + +The following features of WME 1.x are NOT supported by WME Lite: +* 3D characters. WME Lite only supports 2D games. +* Sprite frame mirroring. +* Sprite rotations. +* Sprite blending modes. +* Video playback. +* Plugins. +* Calling external functions from DLL libraries from scripts. +* Game Explorer support. +* 'Directory' script object. + +This port does reimplement a few of these features, currently: +* Sprite frame mirroring - WORKS. +* Video playback - Theora PARTIALLY WORKING. (Slow, and doesn't support seeking) + +In addition, this port removes a few additional features that were never/rarely used: +* 'File' script object - ScummVM doesn't have any easy way to write/read arbitrary files. +* Debugger/Compiler - weren't properly accessible in WME Lite anyhow. +* CD-numbering support in .dcp-files - was never used. +* 'SaveDirectory'-property of 'Game' will not return anything usefull to the game-scripts (saving is handled through SaveFileMan) + +******************************* +*** Additional limitations: *** +******************************* +* Only .OGG and RAW-.WAV sounds are supported at this point +* TTF-fonts might behave a bit differently, owing to both the change to FreeType in WME Lite + and the change in dpi in this port of WME. +* The window-caption-setting in-game will be ignored, for the sake of concistency with ScummVM. +* Most VKey-combinations might still be missing (as they already were in WME Lite) +* Since we don't use FreeImage, some games might use odd files that weren't expected when the + image-decoders in ScummVM were written. One example here is interlaced-PNGs. +* UTF8-support is not ported, which means only games with western charsets will work for now. +* Games that select language by moving .dcp-files around still need a bit more handling on detection/load + adding support for those languages on a language-by-language basis. +* Most games assume the availability of the Windows-fonts (particularly arial.ttf) + at this point no fallback has been put in place for using FreeFonts as replacements, + simply for lack of having them easily accessible to the engines at this point. So, at least + arial.ttf should be put in either the game-folder or made available through the extras-folder + for now, otherwise kGUIBigFont will be used as a replacement. + + +********************************* +*** Advanced engine-features: *** +********************************* +At this point the engine implements the following "advanced engine features": +* RTL ("Return to Launcher") support +* Global options dialog support +* Listing savestates via command line or Launcher +* Loading savestates via command line or Launcher +* Deleting savestates via the Launcher and GMM +* Savestate metadata support +* Loading/Saving during run time + +and NOT the following: +* Enhanced debug/error messages + +***************** +*** Detection *** +***************** +Since Wintermute has authoring tools available, there will at any point in +time be atleast a few games that are works-in-progress, and as the authors +of these games might want to test their games in ScummVM, the engine has +to be able to detect arbitrary Wintermute-games, to this end the detector +code in this engine will check any folder containing "data.dcp", and try to +read "startup.settings" and "default.game" (or optionally any other .game-file +defined in startup.settings), the Name/Caption fields in the .game-file will +be used as gameid/title (prefixing the gameid with "wmefan-" to avoid confusion +with any other WME game that might happen to have taken that id. + +All COMPLETED games should have their md5s and gameid's properly added, IFF +they don't require 3D. + +3D games may also be added, for the purpose of giving the user feedback +as to why their game won't run, but at this point, any such MD5 should +be added as a comment only, to avoid confusion, as no mechanism for giving +the user feedback about 3D-games not being supported is currently added. + +************************************* +*** Games targeted by the engine: *** +************************************* +This engine potentially targets a very large amount of games: +http://res.dead-code.org/doku.php/games:start + +Since the feature-set of WME Lite differs from that of the full Wintermute Engine, +games will need to be targeted on a case-by-case, feature-by-feature basis, this is +a list of the games that are currently known to work (although perhaps with minor +issues) through to completion: + +* Dirty Split (dirtysplit) +* the white chamber (twc) +* Chivalry is NOT dead (chivalry) +* Rosemary (rosemary) +* The Box (thebox) +* J.U.L.I.A. (Demo) (julia) +* Pigeons in the park (pigeons) + +Untested, but starts: +* East Side Story (Demo) (eastside) +* Actual Destination (actualdest) +* Ghost in the sheet (ghostsheet) + +******************************** +*** Games with known issues: *** +******************************** +Certain games will work mostly fine with this engine, but can still +be impossible to complete for various reasons, this is a list of games +that technically qualify (as in they do not require the 3D-parts of the engine) +but have issues that make them problematic or not completable: + +Won't start: +* Five Lethal Demons (5ld) - Requires support for interlaced PNGs +* Five Magical Amulets (5ma) - Requires support for interlaced PNGs +* Kulivoeko - Requires support for interlaced PNGs +* Reversion (reversion) - Requires support for Non-V1.1 JPEGs and interlaced PNGs +* Mirage (mirage) - Tries to seek in a vorbis-stream inside a ZipStream +* Hamlet or the last game without MMORPS features, shaders and product placement (hamlet) + - Requires support for interlaced PNGs + +Gameplay broken: +* J.U.L.I.A. (Full game) (julia) - Requires sprite-rotation for a puzzle. + +Non-critical: +* Ghost in the sheet (ghostsheet) - uses Non-V1.1-JPEGs +* East Side Story (eastside) - wants "framd.ttf" + +***************************** +*** General known issues: *** +***************************** + +Mostly a TODO-section, to not forget fixing outstanding general issues: +* Save/Load-screens are not shown during save/load + this is probably a result of reducing the amount of redrawing done + during save/load, and I'm not sure it should be put back, if that means + making saves slower again. +* Font-sizes are wrong enough to allow Dirty Split to draw text that is hidden in + the original game (most visible on the coin-interface) +* Alpha-masks for Theora-videos are broken on big-endian platforms + -- cgit v1.2.3 From e32b79bff1260f8d2853404f750acc22209a323b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 13:32:26 +0200 Subject: WINTERMUTE: Save the random-seed as well. --- engines/wintermute/ad/ad_actor.cpp | 6 +++--- engines/wintermute/ad/ad_talk_holder.cpp | 4 ++-- engines/wintermute/base/base_engine.cpp | 7 +++++++ engines/wintermute/base/base_engine.h | 9 +++++++-- engines/wintermute/base/saveload.cpp | 5 +++++ engines/wintermute/utils/utils.cpp | 5 +++-- engines/wintermute/wintermute.cpp | 8 -------- engines/wintermute/wintermute.h | 4 ---- 8 files changed, 27 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index b4e9d80a02..aa148c9c85 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -43,7 +43,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/particles/part_emitter.h" -#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/base_engine.h" namespace WinterMute { @@ -1262,7 +1262,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { } if (talkAnims.getSize() > 0) { - int rnd = g_wintermute->randInt(0, talkAnims.getSize() - 1); + int rnd = BaseEngine::instance().randInt(0, talkAnims.getSize() - 1); ret = talkAnims[rnd]->getSprite(_dir); } else { if (_standSprite) { @@ -1307,7 +1307,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { ret = _standSprite->getSprite(_dir); } else { // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + int rnd = BaseEngine::instance().randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]->getSprite(_dir); } } diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 5a2b3df31b..a5ab7f3a6d 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/base_engine.h" #include "common/str.h" namespace WinterMute { @@ -111,7 +111,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { ret = _sprite; } else { // TODO: remember last - int rnd = g_wintermute->randInt(0, _talkSprites.getSize() - 1); + int rnd = BaseEngine::instance().randInt(0, _talkSprites.getSize() - 1); ret = _talkSprites[rnd]; } } diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 8e3e6cf0e0..04088d299e 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -40,11 +40,14 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; _gameRef = NULL; + _rnd = NULL; _gameId = ""; } void BaseEngine::init() { _fileManager = new BaseFileManager(); + // Don't forget to register your random source + _rnd = new Common::RandomSource("WinterMute"); } BaseEngine::~BaseEngine() { @@ -77,4 +80,8 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { } } +uint32 BaseEngine::randInt(int from, int to) { + return _rnd->getRandomNumberRng(from, to); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index b9dcfcb845..253ef048ab 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -29,8 +29,9 @@ #ifndef WINTERMUTE_BASE_ENGINE_H #define WINTERMUTE_BASE_ENGINE_H - #include "common/str.h" - #include "common/singleton.h" +#include "common/str.h" +#include "common/singleton.h" +#include "common/random.h" namespace WinterMute { @@ -42,12 +43,16 @@ class BaseEngine : public Common::Singleton { BaseFileManager *_fileManager; Common::String _gameId; BaseGame *_gameRef; + // We need random numbers + Common::RandomSource *_rnd; public: BaseEngine(); ~BaseEngine(); static void createInstance(const Common::String &gameid); void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } + Common::RandomSource *getRandomSource() { return _rnd; } + uint32 randInt(int from, int to); BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } static void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index aea474fd44..5b51749b43 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/wintermute.h" #include "engines/wintermute/base/saveload.h" #include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" // Temporary #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_sub_frame.h" @@ -54,6 +55,9 @@ bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { //if (DID_SUCCEED(ret = cleanup())) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(gameRef, pm))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(gameRef, pm))) { + // Restore random-seed: + BaseEngine::instance().getRandomSource()->setSeed(pm->getDWORD()); + // data initialization after load SaveLoad::initAfterLoad(); @@ -92,6 +96,7 @@ bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *ga gameRef->_renderer->initSaveLoad(true, quickSave); // TODO: The original code inited the indicator before the conditionals if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(gameRef, pm, quickSave))) { + pm->putDWORD(BaseEngine::instance().getRandomSource()->getSeed()); if (DID_SUCCEED(ret = pm->saveFile(filename))) { ConfMan.setInt("most_recent_saveslot", slot); } diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 6571147a80..f8a7b0e547 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/base_engine.h" namespace WinterMute { @@ -126,14 +127,14 @@ int BaseUtils::randomInt(int from, int to) { to = from; from = i; } - return g_wintermute->randInt(from, to); + return BaseEngine::instance().randInt(from, to); // return (rand() % (to - from + 1)) + from; } ////////////////////////////////////////////////////////////////////////// float BaseUtils::randomFloat(float from, float to) { const uint32 randMax = RAND_MAX; - float randNum = (float)g_wintermute->randInt(0, randMax) / (float)randMax; + float randNum = (float)BaseEngine::instance().randInt(0, randMax) / (float)randMax; return from + (to - from) * randNum; } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 2dadd51b09..b97bb22e6b 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -53,7 +53,6 @@ WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { _classReg->registerClasses(); _game = new AdGame(""); - _rnd = NULL; } WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) @@ -74,8 +73,6 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) DebugMan.addDebugChannel(kWinterMuteDebugFont, "font", "Text-drawing-related messages"); DebugMan.addDebugChannel(kWinterMuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); DebugMan.addDebugChannel(kWinterMuteDebugAudio, "audio", "audio-playback-related issues"); - // Don't forget to register your random source - _rnd = new Common::RandomSource("WinterMute"); _game = NULL; @@ -86,7 +83,6 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) WinterMuteEngine::~WinterMuteEngine() { // Dispose your resources here deinit(); - delete _rnd; delete _game; delete _console; g_wintermute = NULL; @@ -381,8 +377,4 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String return retVal; } -uint32 WinterMuteEngine::randInt(int from, int to) { - return _rnd->getRandomNumberRng(from, to); -} - } // End of namespace WinterMute diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 8dd1b0b98e..fb94fd9175 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -23,7 +23,6 @@ #ifndef WINTERMUTE_H #define WINTERMUTE_H -#include "common/random.h" #include "engines/engine.h" #include "engines/advancedDetector.h" #include "gui/debugger.h" @@ -52,7 +51,6 @@ public: virtual bool hasFeature(EngineFeature f) const; Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } SystemClassRegistry *getClassRegistry(){ return _classReg; } - uint32 randInt(int from, int to); virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); virtual Common::Error saveGameState(int slot, const Common::String &desc); @@ -66,8 +64,6 @@ private: Console *_console; BaseGame *_game; SystemClassRegistry *_classReg; - // We need random numbers - Common::RandomSource *_rnd; const ADGameDescription *_gameDescription; }; -- cgit v1.2.3 From 6b159d71ab212feb4e93bae412a7352ead59241b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 13:51:22 +0200 Subject: WINTERMUTE: Remove g_wintermute. --- engines/wintermute/base/base_engine.cpp | 6 ++++++ engines/wintermute/base/base_engine.h | 4 ++++ engines/wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/saveload.cpp | 2 +- engines/wintermute/base/sound/base_sound_manager.cpp | 2 +- engines/wintermute/system/sys_class_registry.cpp | 5 +++-- engines/wintermute/wintermute.cpp | 14 -------------- engines/wintermute/wintermute.h | 5 ----- 8 files changed, 16 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 04088d299e..c31777c866 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/system/sys_class_registry.h" #include "common/system.h" namespace Common { DECLARE_SINGLETON(WinterMute::BaseEngine); @@ -40,6 +41,7 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; _gameRef = NULL; + _classReg = NULL; _rnd = NULL; _gameId = ""; } @@ -48,10 +50,14 @@ void BaseEngine::init() { _fileManager = new BaseFileManager(); // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); + _classReg = new SystemClassRegistry(); + _classReg->registerClasses(); } BaseEngine::~BaseEngine() { delete _fileManager; + delete _rnd; + delete _classReg; } void BaseEngine::createInstance(const Common::String &gameid) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 253ef048ab..04199715af 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -38,6 +38,7 @@ namespace WinterMute { class BaseFileManager; class BaseRegistry; class BaseGame; +class SystemClassRegistry; class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; @@ -45,6 +46,7 @@ class BaseEngine : public Common::Singleton { BaseGame *_gameRef; // We need random numbers Common::RandomSource *_rnd; + SystemClassRegistry *_classReg; public: BaseEngine(); ~BaseEngine(); @@ -53,6 +55,8 @@ public: Common::RandomSource *getRandomSource() { return _rnd; } uint32 randInt(int from, int to); + + SystemClassRegistry *getClassRegistry(){ return _classReg; } BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } static void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 4236203292..e6ed5cb7e0 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -371,7 +371,7 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::SaveFileManager *saveMan = ((WinterMuteEngine *)g_engine)->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(filename); file->write(prefixBuffer, prefixSize); file->write(buffer, bufferSize); diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index 5b51749b43..fe987c0b2a 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -194,7 +194,7 @@ bool SaveLoad::isSaveSlotUsed(int slot) { bool SaveLoad::emptySaveSlot(int slot) { Common::String filename = getSaveSlotFilename(slot); BasePersistenceManager *pm = new BasePersistenceManager(); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + ((WinterMuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return true; } diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index ed475ec31c..95b7d040ab 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -184,7 +184,7 @@ bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { case Audio::Mixer::kPlainSoundType: error("Plain sound type shouldn't be used in WME"); } - g_wintermute->syncSoundSettings(); + g_engine->syncSoundSettings(); return STATUS_OK; } diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp index d9303ea729..b9e9bc8878 100644 --- a/engines/wintermute/system/sys_class_registry.cpp +++ b/engines/wintermute/system/sys_class_registry.cpp @@ -28,10 +28,11 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/system/sys_instance.h" #include "engines/wintermute/system/sys_class_registry.h" #include "engines/wintermute/system/sys_class.h" +#include "engines/wintermute/wintermute.h" #include "common/stream.h" namespace WinterMute { @@ -50,7 +51,7 @@ SystemClassRegistry::~SystemClassRegistry() { ////////////////////////////////////////////////////////////////////////// SystemClassRegistry *SystemClassRegistry::getInstance() { - return g_wintermute->getClassRegistry(); + return BaseEngine::instance().getClassRegistry(); } void SystemClassRegistry::unregisterClasses() { diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index b97bb22e6b..842a6f0039 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -43,15 +43,9 @@ namespace WinterMute { -WinterMuteEngine *g_wintermute; - // Simple constructor for detection - we need to setup the persistence to avoid special-casing in-engine // This might not be the prettiest solution WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { - g_wintermute = this; - _classReg = new SystemClassRegistry(); - _classReg->registerClasses(); - _game = new AdGame(""); } @@ -75,9 +69,6 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) DebugMan.addDebugChannel(kWinterMuteDebugAudio, "audio", "audio-playback-related issues"); _game = NULL; - - g_wintermute = this; - _classReg = NULL; } WinterMuteEngine::~WinterMuteEngine() { @@ -85,7 +76,6 @@ WinterMuteEngine::~WinterMuteEngine() { deinit(); delete _game; delete _console; - g_wintermute = NULL; // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); @@ -135,8 +125,6 @@ Common::Error WinterMuteEngine::run() { } int WinterMuteEngine::init() { - _classReg = new SystemClassRegistry(); - _classReg->registerClasses(); BaseEngine::createInstance(_targetName); _game = new AdGame(_targetName); if (!_game) return 1; @@ -272,8 +260,6 @@ int WinterMuteEngine::messageLoop() { } void WinterMuteEngine::deinit() { - delete _classReg; - _classReg = NULL; BaseEngine::destroy(); } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index fb94fd9175..a0292c17ec 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -50,7 +50,6 @@ public: virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; } - SystemClassRegistry *getClassRegistry(){ return _classReg; } virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); virtual Common::Error saveGameState(int slot, const Common::String &desc); @@ -63,7 +62,6 @@ private: int messageLoop(); Console *_console; BaseGame *_game; - SystemClassRegistry *_classReg; const ADGameDescription *_gameDescription; }; @@ -74,9 +72,6 @@ public: virtual ~Console(void) {} }; -// Mainly used for randInt() -extern WinterMuteEngine *g_wintermute; - } // End of namespace Wintermute #endif -- cgit v1.2.3 From 52aeaf4ecee11074a3f1fe303aef862f1b6ac028 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 14:06:42 +0200 Subject: WINTERMUTE: Move dcscript.h into the proper folder. --- engines/wintermute/base/scriptables/dcscript.h | 141 +++++++++++++++++++++ engines/wintermute/base/scriptables/script.h | 2 +- engines/wintermute/base/scriptables/script_value.h | 2 +- engines/wintermute/dcscript.h | 141 --------------------- 4 files changed, 143 insertions(+), 143 deletions(-) create mode 100644 engines/wintermute/base/scriptables/dcscript.h delete mode 100644 engines/wintermute/dcscript.h (limited to 'engines') diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h new file mode 100644 index 0000000000..9610ebf94c --- /dev/null +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -0,0 +1,141 @@ +/* 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. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCSCRIPT_H +#define WINTERMUTE_DCSCRIPT_H + +namespace WinterMute { + +#define SCRIPT_MAGIC 0xDEC0ADDE +#define SCRIPT_VERSION 0x0102 + +// value types +typedef enum { + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF +} TValType; + + +// script states +typedef enum { + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED +} TScriptState; + +// opcodes +typedef enum { + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR +} TInstruction; + +// external data types +typedef enum { + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER +} TExternalType; + + +// call types +typedef enum { + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL +} TCallType; + +// element types +typedef enum { + ELEMENT_STRING = 0 +} TElementType; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 1cd5c2dc1e..9f49fac994 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 8fced06972..c8d04168b3 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/dcscript.h b/engines/wintermute/dcscript.h deleted file mode 100644 index 9610ebf94c..0000000000 --- a/engines/wintermute/dcscript.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_DCSCRIPT_H -#define WINTERMUTE_DCSCRIPT_H - -namespace WinterMute { - -#define SCRIPT_MAGIC 0xDEC0ADDE -#define SCRIPT_VERSION 0x0102 - -// value types -typedef enum { - VAL_NULL, - VAL_STRING, - VAL_INT, - VAL_BOOL, - VAL_FLOAT, - VAL_OBJECT, - VAL_NATIVE, - VAL_VARIABLE_REF -} TValType; - - -// script states -typedef enum { - SCRIPT_RUNNING, - SCRIPT_WAITING, - SCRIPT_SLEEPING, - SCRIPT_FINISHED, - SCRIPT_PERSISTENT, - SCRIPT_ERROR, - SCRIPT_PAUSED, - SCRIPT_WAITING_SCRIPT, - SCRIPT_THREAD_FINISHED -} TScriptState; - -// opcodes -typedef enum { - II_DEF_VAR = 0, - II_DEF_GLOB_VAR, - II_RET, - II_RET_EVENT, - II_CALL, - II_CALL_BY_EXP, - II_EXTERNAL_CALL, - II_SCOPE, - II_CORRECT_STACK, - II_CREATE_OBJECT, - II_POP_EMPTY, - II_PUSH_VAR, - II_PUSH_VAR_REF, - II_POP_VAR, - II_PUSH_VAR_THIS, // push current this on stack - II_PUSH_INT, - II_PUSH_BOOL, - II_PUSH_FLOAT, - II_PUSH_STRING, - II_PUSH_NULL, - II_PUSH_THIS_FROM_STACK, - II_PUSH_THIS, - II_POP_THIS, - II_PUSH_BY_EXP, - II_POP_BY_EXP, - II_JMP, - II_JMP_FALSE, - II_ADD, - II_SUB, - II_MUL, - II_DIV, - II_MODULO, - II_NOT, - II_AND, - II_OR, - II_CMP_EQ, - II_CMP_NE, - II_CMP_L, - II_CMP_G, - II_CMP_LE, - II_CMP_GE, - II_CMP_STRICT_EQ, - II_CMP_STRICT_NE, - II_DBG_LINE, - II_POP_REG1, - II_PUSH_REG1, - II_DEF_CONST_VAR -} TInstruction; - -// external data types -typedef enum { - TYPE_VOID = 0, - TYPE_BOOL, - TYPE_LONG, - TYPE_BYTE, - TYPE_STRING, - TYPE_FLOAT, - TYPE_DOUBLE, - TYPE_MEMBUFFER -} TExternalType; - - -// call types -typedef enum { - CALL_STDCALL = 0, - CALL_CDECL, - CALL_THISCALL -} TCallType; - -// element types -typedef enum { - ELEMENT_STRING = 0 -} TElementType; - -} // end of namespace WinterMute - -#endif -- cgit v1.2.3 From 3abccb2e339144191553555756e3ff43222c3a36 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 14:56:06 +0200 Subject: WINTERMUTE: Change PixelFormat to ARGB (same as Sword25) Mainly a workaround for the OpenGL-backend. --- .../wintermute/base/font/base_font_truetype.cpp | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 2 +- .../wintermute/graphics/transparent_surface.cpp | 59 +++++++++++----------- engines/wintermute/wintermute.cpp | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index b80bbdc41d..00b522c826 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -261,7 +261,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); if (_deletableFont) { // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); } else { // We are using a fallback, they can't do 32bpp surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); } @@ -274,7 +274,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, } BaseSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); surface->free(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index bc952b0b36..f12478f7b3 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -153,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _windowed = !ConfMan.getBool("fullscreen"); - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); g_system->beginGFXTransaction(); g_system->initSize(_width, _height, &format); OSystem::TransactionError gfxError = g_system->endGFXTransaction(); diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 59010d5ed3..49deafa7e6 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -47,25 +47,25 @@ void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, in byte *in, *out; #ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else const int aIndex = 3; - const int bIndex = 2; + const int bIndex = 0; const int gIndex = 1; - const int rIndex = 0; + const int rIndex = 2; +#else + const int aIndex = 0; + const int bIndex = 3; + const int gIndex = 2; + const int rIndex = 1; #endif - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; + const int bShift = 0;//img->format.bShift; + const int gShift = 8;//img->format.gShift; + const int rShift = 16;//img->format.rShift; + const int aShift = 24;//img->format.aShift; - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; + const int bShiftTarget = 0;//target.format.bShift; + const int gShiftTarget = 8;//target.format.gShift; + const int rShiftTarget = 16;//target.format.rShift; for (uint32 i = 0; i < height; i++) { out = outo; @@ -226,25 +226,24 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p byte *in, *out; #ifdef SCUMM_LITTLE_ENDIAN - const int aIndex = 0; - const int bIndex = 1; - const int gIndex = 2; - const int rIndex = 3; -#else const int aIndex = 3; - const int bIndex = 2; + const int bIndex = 0; const int gIndex = 1; - const int rIndex = 0; + const int rIndex = 2; +#else + const int aIndex = 0; + const int bIndex = 3; + const int gIndex = 2; + const int rIndex = 1; #endif - - const int bShift = 8;//img->format.bShift; - const int gShift = 16;//img->format.gShift; - const int rShift = 24;//img->format.rShift; - const int aShift = 0;//img->format.aShift; - - const int bShiftTarget = 8;//target.format.bShift; - const int gShiftTarget = 16;//target.format.gShift; - const int rShiftTarget = 24;//target.format.rShift; + const int bShift = 0;//img->format.bShift; + const int gShift = 8;//img->format.gShift; + const int rShift = 16;//img->format.rShift; + const int aShift = 24;//img->format.aShift; + + const int bShiftTarget = 0;//target.format.bShift; + const int gShiftTarget = 8;//target.format.gShift; + const int rShiftTarget = 16;//target.format.rShift; if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { doBlit(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 842a6f0039..9bb567055a 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -97,7 +97,7 @@ bool WinterMuteEngine::hasFeature(EngineFeature f) const { Common::Error WinterMuteEngine::run() { // Initialize graphics using following: - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); initGraphics(800, 600, true, &format); if (g_system->getScreenFormat() != format) { error("Wintermute currently REQUIRES 32bpp"); -- cgit v1.2.3 From 8883a9ffd587de0cfca9a42925d2f1071d4ccb35 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:04:47 +0200 Subject: WINTERMUTE: Optimize blitting (Do opaque blits for opaque images, and do fill with memcpy) --- .../base/gfx/osystem/base_render_osystem.cpp | 40 ++++++++++++++++++---- .../base/gfx/osystem/base_render_osystem.h | 6 ++-- .../base/gfx/osystem/base_surface_osystem.cpp | 6 ++-- .../wintermute/graphics/transparent_surface.cpp | 36 ++++++++++++++++--- engines/wintermute/graphics/transparent_surface.h | 2 ++ 5 files changed, 74 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index f12478f7b3..3ec04b1ab1 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -40,8 +40,8 @@ namespace WinterMute { -RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; if (mirrorX) { @@ -97,6 +97,7 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { ////////////////////////////////////////////////////////////////////////// BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); + _blankSurface = new Graphics::Surface(); _drawNum = 1; _needsFlip = true; @@ -111,6 +112,8 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; + _blankSurface->free(); + delete _blankSurface; } ////////////////////////////////////////////////////////////////////////// @@ -166,6 +169,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { g_system->showMouse(false); _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->fillRect(Common::Rect(0, 0, g_system->getHeight(), g_system->getWidth()), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); _active = true; _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); @@ -217,6 +222,11 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_OK; } if (!rect) { + if (r == 0 && g == 0 && b == 0) { + // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. + memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); + return STATUS_OK; + } rect = &_renderRect; } // TODO: This doesn't work with dirty rects @@ -281,12 +291,12 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { return _renderSurface->format; } -void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); // HINT: The surface-data contains other info than it should. // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + drawFromSurface(&renderTicket, NULL); return; } // Skip rects that are completely outside the screen: @@ -295,7 +305,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S } if (owner) { // Fade-tickets are owner-less - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); compare._colorMod = _colorMod; RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { @@ -306,7 +316,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S } } } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); ticket->_colorMod = _colorMod; drawFromTicket(ticket); } @@ -445,6 +455,22 @@ void BaseRenderOSystem::drawTickets() { } // Replacement for SDL2's SDL_RenderCopy +void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect) { + TransparentSurface src(*ticket->getSurface(), false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(ticket->getSurface()->w); + clipRect->setHeight(ticket->getSurface()->h); + } + + src._enableAlphaBlit = ticket->_hasAlpha; + src.blit(*_renderSurface, ticket->_dstRect.left, ticket->_dstRect.top, ticket->_mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) { + delete clipRect; + } +} void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { TransparentSurface src(*surf, false); bool doDelete = false; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 08fd6cf9ab..070ddf9241 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -39,7 +39,7 @@ class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; public: - RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); const Graphics::Surface *getSurface() { return _surface; } @@ -97,11 +97,12 @@ public: return _ratioY; } - void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false); BaseSurface *createSurface(); private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); + void drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect); void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); typedef Common::List::iterator RenderQueueIterator; Common::Rect *_dirtyRect; @@ -110,6 +111,7 @@ private: uint32 _drawNum; Common::Rect _renderRect; Graphics::Surface *_renderSurface; + Graphics::Surface *_blankSurface; int _borderLeft; int _borderTop; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 9f0e605f39..7845390871 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -396,17 +396,17 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo // But no checking is in place for that yet. // TODO: Optimize by not doing alpha-blits if we lack or disable alpha -/* bool hasAlpha; + bool hasAlpha; if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; - }*/ + } if (alphaDisable) { warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); return STATUS_OK; } diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 49deafa7e6..5faf313207 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -29,9 +29,9 @@ namespace WinterMute { -TransparentSurface::TransparentSurface() : Surface() {} +TransparentSurface::TransparentSurface() : Surface(), _enableAlphaBlit(true) {} -TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface() { +TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _enableAlphaBlit(true) { if (copyData) { copyFrom(surf); } else { @@ -43,7 +43,31 @@ TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Sur } } -void doBlit(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { +void doBlitOpaque(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { + byte *in, *out; + +#ifdef SCUMM_LITTLE_ENDIAN + const int aIndex = 3; +#else + const int aIndex = 0; +#endif + + for (uint32 i = 0; i < height; i++) { + out = outo; + in = ino; + for (uint32 j = 0; j < width; j++) { + uint32 pix = *(uint32 *)in; + in += inStep; + *(uint32*)out = pix; + out[aIndex] = 0xFF; + out += 4; + } + outo += pitch; + ino += inoStep; + } +} + +void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; #ifdef SCUMM_LITTLE_ENDIAN @@ -246,7 +270,11 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p const int rShiftTarget = 16;//target.format.rShift; if (ca == 255 && cb == 255 && cg == 255 && cr == 255) { - doBlit(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + if (_enableAlphaBlit) { + doBlitAlpha(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } else { + doBlitOpaque(ino, outo, img->w, img->h, target.pitch, inStep, inoStep); + } } else { for (int i = 0; i < img->h; i++) { out = outo; diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 79637037db..20fd3c434e 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -66,6 +66,8 @@ struct TransparentSurface : public Graphics::Surface { FLIP_VH = FLIP_H | FLIP_V }; + bool _enableAlphaBlit; + /** @brief renders the surface to another surface @param pDest a pointer to the target image. In most cases this is the framebuffer. -- cgit v1.2.3 From 688f792c9f280a3cf1bb5b30149a05669ba4bfb5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:28:44 +0200 Subject: WINTERMUTE: Cache scaled images, to avoid having to rescale every frame. --- .../base/gfx/osystem/base_render_osystem.cpp | 35 ++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 3ec04b1ab1..9cc94449ff 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -199,6 +199,20 @@ bool BaseRenderOSystem::indicatorFlip() { bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); + } else { + // Clear the scale-buffered tickets that wasn't reused. + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false) { + RenderTicket *ticket = *it; + addDirtyRect((*it)->_dstRect); + it = _renderQueue.erase(it); + delete ticket; + } else { + (*it)->_wantsDraw = false; + it++; + } + } } if (_needsFlip || _disableDirtyRects) { if (_disableDirtyRects) { @@ -292,13 +306,6 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { } void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { - if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(&renderTicket, NULL); - return; - } // Skip rects that are completely outside the screen: if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; @@ -311,14 +318,24 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { (*it)->_colorMod = _colorMod; - drawFromTicket(*it); + if (_disableDirtyRects) { + drawFromSurface(*it, NULL); + } else { + drawFromTicket(*it); + } return; } } } RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); ticket->_colorMod = _colorMod; - drawFromTicket(ticket); + if (!_disableDirtyRects) { + drawFromTicket(ticket); + } else { + ticket->_wantsDraw = true; + _renderQueue.push_back(ticket); + drawFromSurface(ticket, NULL); + } } void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { -- cgit v1.2.3 From d95a2ddef84bb786979affddd95074da79032560 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:49:20 +0200 Subject: WINTERMUTE: Use only one scaler for blitting, the faster one. --- engines/wintermute/base/gfx/base_image.cpp | 4 +- .../wintermute/graphics/transparent_surface.cpp | 62 ++-------------------- engines/wintermute/graphics/transparent_surface.h | 5 +- 3 files changed, 7 insertions(+), 64 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 9203b62734..c1b6636237 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -120,7 +120,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); temp.free(); return true; } @@ -224,7 +224,7 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); return true; } diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 5faf313207..1662ff19af 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -369,14 +369,14 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } -TransparentSurface *TransparentSurface::scaleSafe(uint16 newWidth, uint16 newHeight) const { +TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const { Common::Rect srcRect(0, 0, (int16)w, (int16)h); Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight); - return scaleSafe(srcRect, dstRect); + return scale(srcRect, dstRect); } // Copied from clone2727's https://github.com/clone2727/scummvm/blob/pegasus/engines/pegasus/surface.cpp#L247 -TransparentSurface *TransparentSurface::scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const { +TransparentSurface *TransparentSurface::scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const { // I'm doing simple linear scaling here // dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH); TransparentSurface *target = new TransparentSurface(); @@ -398,37 +398,6 @@ TransparentSurface *TransparentSurface::scaleSafe(const Common::Rect &srcRect, c return target; } -/** - * Scales a passed surface, creating a new surface with the result - * @param xSize target width. - * @param ySize target height. - * @remarks Caller is responsible for freeing the returned surface - */ -TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const { - TransparentSurface *s = new TransparentSurface(); - s->create(xSize, ySize, this->format); - - int *horizUsage = scaleLine(xSize, this->w); - int *vertUsage = scaleLine(ySize, this->h); - - // Loop to create scaled version - for (int yp = 0; yp < ySize; ++yp) { - const byte *srcP = (const byte *)this->getBasePtr(0, vertUsage[yp]); - byte *destP = (byte *)s->getBasePtr(0, yp); - - for (int xp = 0; xp < xSize; ++xp) { - const byte *tempSrcP = srcP + (horizUsage[xp] * this->format.bytesPerPixel); - for (int byteCtr = 0; byteCtr < this->format.bytesPerPixel; ++byteCtr) { - *destP++ = *tempSrcP++; - } - } - } - - // Delete arrays and return surface - delete[] horizUsage; - delete[] vertUsage; - return s; -} /** * Writes a color key to the alpha channel of the surface @@ -455,29 +424,4 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool } } -/** - * Returns an array indicating which pixels of a source image horizontally or vertically get - * included in a scaled image - */ -int *TransparentSurface::scaleLine(int size, int srcSize) { - int scale = 100 * size / srcSize; - assert(scale > 0); - int *v = new int[size]; - Common::fill(v, &v[size], 0); - - int distCtr = 0; - int *destP = v; - for (int distIndex = 0; distIndex < srcSize; ++distIndex) { - distCtr += scale; - while (distCtr >= 100) { - assert(destP < &v[size]); - *destP++ = distIndex; - distCtr -= 100; - } - } - - return v; -} - - } // End of namespace Graphics diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 20fd3c434e..5e70b63218 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -102,10 +102,9 @@ struct TransparentSurface : public Graphics::Surface { uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1); void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); - TransparentSurface *scale(int xSize, int ySize) const; // The following scale-code supports arbitrary scaling (i.e. no repeats of column 0 at the end of lines) - TransparentSurface *scaleSafe(uint16 newWidth, uint16 newHeight) const; - TransparentSurface *scaleSafe(const Common::Rect &srcRect, const Common::Rect &dstRect) const; + TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; + TransparentSurface *scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const; private: static int *scaleLine(int size, int srcSize); }; -- cgit v1.2.3 From c422ae9d8a90aeb63da3e3fdf521323fe6769828 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:30:07 +0200 Subject: WINTERMUTE: Get rid of strncpy+manual termination. --- engines/wintermute/ad/ad_sentence.cpp | 3 +-- engines/wintermute/base/base_parser.cpp | 6 ++---- engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp | 3 +-- engines/wintermute/detection.cpp | 4 ++-- engines/wintermute/utils/utils.cpp | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index d243aaf8e6..60c4519823 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -184,8 +184,7 @@ char *AdSentence::getStance(int stance) { _tempStance = new char [curr - start + 1]; if (_tempStance) { - _tempStance[curr - start] = '\0'; - strncpy(_tempStance, start, curr - start); + Common::strlcpy(_tempStance, start, curr - start + 1); } return _tempStance; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 1b39b55768..75268f6483 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -386,8 +386,7 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { in++; const char *in2 = strchr(in, '\''); if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; + Common::strlcpy(a, in, (int)(in2 - in) + 1); in = in2 + 1; } else { strcpy(a, in); @@ -395,8 +394,7 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { } } else { const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; + Common::strlcpy(a, in, (int)(in2 - in) + 1); in = in2; } in += strspn(in, " \t\n\f"); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index afe5e65467..557d9b9b57 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -261,8 +261,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushNULL(); } else { char *str = new char[length + 1]; - strncpy(str, (const char *)_buffer + start, length); - str[length] = '\0'; + Common::strlcpy(str, (const char *)_buffer + start, length + 1); stack->pushString(str); delete[] str; } diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index af2560fcf2..b3f210d67a 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -124,13 +124,13 @@ public: } // Prefix to avoid collisions with actually known games name = "wmefan-" + name; - strncpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); + Common::strlcpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); s_fallbackDesc.gameid = s_fallbackGameIdBuf; if (caption != name) { caption += " (fangame) "; char *offset = s_fallbackGameIdBuf + name.size() + 1; uint32 remainingLength = (sizeof(s_fallbackGameIdBuf) - 1) - (name.size() + 1); - strncpy(offset, caption.c_str(), remainingLength); + Common::strlcpy(offset, caption.c_str(), remainingLength); s_fallbackDesc.extra = offset; s_fallbackDesc.flags |= ADGF_USEEXTRAASTITLE; } diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index f8a7b0e547..4546750c61 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -112,7 +112,7 @@ char *BaseUtils::strEntry(int entry, const char *str, const char delim) { if (start) { char *ret = new char[len + 1]; memset(ret, 0, len + 1); - strncpy(ret, start, len); + Common::strlcpy(ret, start, len + 1); return ret; } } -- cgit v1.2.3 From 9a5f363972759158a66b5c7c34726db4318b8092 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:34:06 +0200 Subject: WINTERMUTE: Make missing-file warnings a debugC The sound-system attempts to open files in various formats, some of which may not exist, no reason for these to fill the console with output. --- engines/wintermute/base/base_file_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index d5071ccf48..c17a456f11 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -317,7 +317,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + debugC(kWinterMuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } -- cgit v1.2.3 From 089920377f0399dddf2f40b6687dd41276cd75d5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:42:37 +0200 Subject: WINTERMUTE: Make RTL skip any "are you sure?"-dialogs. The user has already quite intentionally opened the GMM and clicked "return to launcher" additionally the GMM can be launched at any time, but the "are you sure"-message can't always be shown, for instance if the user is already in some in-game menu, or a video is playing. --- engines/wintermute/platform_osystem.cpp | 46 ++++++++------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index b2a0b976d4..a23e606931 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -49,7 +49,9 @@ void BasePlatform::handleEvent(Common::Event *event) { case Common::EVENT_LBUTTONDOWN: if (_gameRef) { - if (_gameRef->isLeftDoubleClick()) _gameRef->onMouseLeftDblClick(); + if (_gameRef->isLeftDoubleClick()) { + _gameRef->onMouseLeftDblClick(); + } else _gameRef->onMouseLeftDown(); } break; @@ -81,46 +83,20 @@ void BasePlatform::handleEvent(Common::Event *event) { case Common::EVENT_WHEELDOWN: if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); break; -//TODO: Handle MouseWheel - /* case SDL_MOUSEWHEEL: - if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y); - break; - - case SDL_KEYDOWN: - case SDL_TEXTINPUT: - if (_gameRef) _gameRef->handleKeypress(event); - break; - - case SDL_WINDOWEVENT: - switch (event->window.event) { - case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_RESTORED: - if (_gameRef) _gameRef->OnActivate(true, true); - SDL_ShowCursor(SDL_DISABLE); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - case SDL_WINDOWEVENT_MINIMIZED: - if (_gameRef) _gameRef->OnActivate(false, false); - SDL_ShowCursor(SDL_ENABLE); - break; - - case SDL_WINDOWEVENT_CLOSE: - break; - - } - break; - */ - case Common::EVENT_QUIT: +// Focus-events have been removed (_gameRef->onActivate originally) case Common::EVENT_RTL: + _gameRef->_quitting = true; + break; + case Common::EVENT_QUIT: // Block kept in case we want to support autoSaveOnExit. -//#ifdef __IPHONEOS__ +// Originally this was the behaviour for WME Lite on iOS: // if (_gameRef) { // _gameRef->AutoSaveOnExit(); // _gameRef->_quitting = true; // } -//#else*/ - if (_gameRef) _gameRef->onWindowClose(); -//#endif + if (_gameRef) { + _gameRef->onWindowClose(); + } break; default: // TODO: Do we care about any other events? -- cgit v1.2.3 From 5ecc1fd7f0580a60c6563bfa3fe7ef8f22e212f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:44:12 +0200 Subject: WINTERMUTE: Format platform_osystem.cpp, wintermute.cpp and detection_tables.h --- engines/wintermute/detection_tables.h | 40 ++++++++++++------------- engines/wintermute/platform_osystem.cpp | 46 ++++++++++++++++++++-------- engines/wintermute/wintermute.cpp | 53 +++++++++++++++++++++------------ 3 files changed, 87 insertions(+), 52 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index 0f15d1043e..272daea2d9 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -8,12 +8,12 @@ * 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. @@ -23,23 +23,23 @@ namespace WinterMute { static const PlainGameDescriptor wintermuteGames[] = { - {"5ld", "Five Lethal Demons"}, - {"5ma", "Five Magical Amulets"}, - {"actualdest", "Actual Destination"}, - {"chivalry", "Chivalry is Not Dead"}, - {"deadcity", "Dead City"}, - {"dirtysplit", "Dirty Split"}, - {"eastside", "East Side Story"}, - {"ghostsheet", "Ghost in the Sheet"}, - {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, - {"julia", "J.U.L.I.A."}, - {"mirage", "Mirage"}, - {"pigeons", "Pigeons in the Park"}, - {"reversion", "Reversion"}, - {"rosemary", "Rosemary"}, - {"thebox", "The Box"}, - {"twc", "the white chamber"}, - {"wintermute", "Wintermute engine game"}, + {"5ld", "Five Lethal Demons"}, + {"5ma", "Five Magical Amulets"}, + {"actualdest", "Actual Destination"}, + {"chivalry", "Chivalry is Not Dead"}, + {"deadcity", "Dead City"}, + {"dirtysplit", "Dirty Split"}, + {"eastside", "East Side Story"}, + {"ghostsheet", "Ghost in the Sheet"}, + {"hamlet", "Hamlet or the last game without MMORPS features, shaders and product placement"}, + {"julia", "J.U.L.I.A."}, + {"mirage", "Mirage"}, + {"pigeons", "Pigeons in the Park"}, + {"reversion", "Reversion"}, + {"rosemary", "Rosemary"}, + {"thebox", "The Box"}, + {"twc", "the white chamber"}, + {"wintermute", "Wintermute engine game"}, {0, 0} }; @@ -229,5 +229,5 @@ static const ADGameDescription gameDescriptions[] = { }, AD_TABLE_END_MARKER }; - + } // End of namespace WinterMute diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index a23e606931..a1220cfa45 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -8,12 +8,12 @@ * 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. @@ -51,37 +51,55 @@ void BasePlatform::handleEvent(Common::Event *event) { if (_gameRef) { if (_gameRef->isLeftDoubleClick()) { _gameRef->onMouseLeftDblClick(); + } else { + _gameRef->onMouseLeftDown(); } - else _gameRef->onMouseLeftDown(); } break; case Common::EVENT_RBUTTONDOWN: if (_gameRef) { - if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick(); - else _gameRef->onMouseRightDown(); + if (_gameRef->isRightDoubleClick()) { + _gameRef->onMouseRightDblClick(); + } else { + _gameRef->onMouseRightDown(); + } } break; case Common::EVENT_MBUTTONDOWN: - if (_gameRef) _gameRef->onMouseMiddleDown(); + if (_gameRef) { + _gameRef->onMouseMiddleDown(); + } break; case Common::EVENT_LBUTTONUP: - if (_gameRef) _gameRef->onMouseLeftUp(); + if (_gameRef) { + _gameRef->onMouseLeftUp(); + } break; case Common::EVENT_RBUTTONUP: - if (_gameRef) _gameRef->onMouseRightUp(); + if (_gameRef) { + _gameRef->onMouseRightUp(); + } break; case Common::EVENT_MBUTTONUP: - if (_gameRef) _gameRef->onMouseMiddleUp(); + if (_gameRef) { + _gameRef->onMouseMiddleUp(); + } break; case Common::EVENT_KEYDOWN: - if (_gameRef) _gameRef->handleKeypress(event); + if (_gameRef) { + _gameRef->handleKeypress(event); + } break; case Common::EVENT_KEYUP: - if (_gameRef) _gameRef->handleKeyRelease(event); + if (_gameRef) { + _gameRef->handleKeyRelease(event); + } break; case Common::EVENT_WHEELUP: case Common::EVENT_WHEELDOWN: - if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); + if (_gameRef) { + _gameRef->handleMouseWheel(event->mouse.y); + } break; // Focus-events have been removed (_gameRef->onActivate originally) case Common::EVENT_RTL: @@ -216,7 +234,9 @@ bool BasePlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2 ////////////////////////////////////////////////////////////////////////// bool BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { - if (lprcDst == NULL || lprcSrc == NULL) return false; + if (lprcDst == NULL || lprcSrc == NULL) { + return false; + } *lprcDst = *lprcSrc; return true; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 9bb567055a..e363c7bd54 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -115,7 +115,7 @@ Common::Error WinterMuteEngine::run() { // Additional setup. debugC(kWinterMuteDebugLog, "WinterMuteEngine::init"); ret = init(); - + debugC(kWinterMuteDebugLog, "WinterMuteEngine::messageLoop"); if (ret == 0) { ret = messageLoop(); @@ -127,7 +127,9 @@ Common::Error WinterMuteEngine::run() { int WinterMuteEngine::init() { BaseEngine::createInstance(_targetName); _game = new AdGame(_targetName); - if (!_game) return 1; + if (!_game) { + return 1; + } BaseEngine::instance().setGameRef(_game); BasePlatform::initialize(_game, 0, NULL); @@ -241,15 +243,22 @@ int WinterMuteEngine::messageLoop() { time = _system->getMillis(); diff = time - prevTime; - if (frameTime > diff) // Avoid overflows + if (frameTime > diff) { // Avoid overflows _system->delayMillis(frameTime - diff); + } // ***** flip - if (!_game->_suspendedRendering) _game->_renderer->flip(); - if (_game->_loading) _game->loadGame(_game->_scheduledLoadSlot); + if (!_game->_suspendedRendering) { + _game->_renderer->flip(); + } + if (_game->_loading) { + _game->loadGame(_game->_scheduledLoadSlot); + } prevTime = time; } - if (_game->_quitting) break; + if (_game->_quitting) { + break; + } } if (_game) { @@ -302,21 +311,24 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String Common::String line = stream->readLine(); line.trim(); // Get rid of indentation // Expect "SETTINGS {" or comment, or empty line - if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) + if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) { continue; - else { + } else { // We are looking for "GAME =" Common::StringTokenizer token(line, "="); Common::String key = token.nextToken(); Common::String value = token.nextToken(); - if (value.size() == 0) + if (value.size() == 0) { continue; - if (value[0] == '\"') + } + if (value[0] == '\"') { value.deleteChar(0); - else + } else { continue; - if (value.lastChar() == '\"') + } + if (value.lastChar() == '\"') { value.deleteLastChar(); + } if (key == "GAME") { settingsGameFile = value; break; @@ -333,20 +345,23 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String Common::String line = stream->readLine(); line.trim(); // Get rid of indentation // Expect "GAME {" or comment, or empty line - if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) + if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) { continue; - else { + } else { Common::StringTokenizer token(line, "="); Common::String key = token.nextToken(); Common::String value = token.nextToken(); - if (value.size() == 0) + if (value.size() == 0) { continue; - if (value[0] == '\"') + } + if (value[0] == '\"') { value.deleteChar(0); - else - continue; // not a string - if (value.lastChar() == '\"') + } else { + continue; // not a string + } + if (value.lastChar() == '\"') { value.deleteLastChar(); + } if (key == "NAME") { retVal = true; name = value; -- cgit v1.2.3 From 5b3389672b6442dde3c32978afe912a07ed40c07 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 03:15:51 +0200 Subject: WINTERMUTE: Silence a few float-cast warnings. --- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 9cc94449ff..dbcb329d64 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -573,23 +573,23 @@ Rect32 BaseRenderOSystem::getViewPort() { ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { - rect->left = MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); - rect->top = MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); - rect->setWidth(MathUtil::roundUp(rect->width() * _ratioX)); - rect->setHeight(MathUtil::roundUp(rect->height() * _ratioY)); + rect->left = (int16)MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); + rect->top = (int16)MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); + rect->setWidth((int16)MathUtil::roundUp(rect->width() * _ratioX)); + rect->setHeight((int16)MathUtil::roundUp(rect->height() * _ratioY)); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointFromScreen(Point32 *point) { - point->x = point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left; - point->y = point->y / _ratioY - _borderTop / _ratioY + _renderRect.top; + point->x = (int16)(point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left); + point->y = (int16)(point->y / _ratioY - _borderTop / _ratioY + _renderRect.top); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointToScreen(Point32 *point) { - point->x = MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; - point->y = MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; + point->x = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 2c44f3f5fac5f5bbe5628cf3de61782f975174fd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 01:06:56 +0200 Subject: WINTERMUTE: Make a few noisy warnings into debug-calls. --- engines/wintermute/ad/ad_response_box.cpp | 5 +++-- engines/wintermute/ad/ad_scene.cpp | 3 ++- engines/wintermute/wintermute.cpp | 1 + engines/wintermute/wintermute.h | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index e321f1cd93..5f2a1dc825 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -42,6 +42,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" #include "common/str.h" namespace WinterMute { @@ -610,7 +611,7 @@ bool AdResponseBox::weedResponses() { } break; default: - warning("AdResponseBox::WeedResponses - Unhandled enum"); + debugC(kWinterMuteDebugGeneral, "AdResponseBox::WeedResponses - Unhandled enum"); break; } } @@ -640,7 +641,7 @@ bool AdResponseBox::handleResponse(AdResponse *response) { adGame->addGameResponse(response->_iD); break; default: - warning("AdResponseBox::HandleResponse - Unhandled enum"); + debugC(kWinterMuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index b84c4c2dca..d99b6b7fb8 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -57,6 +57,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/ui/ui_window.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" #include namespace WinterMute { @@ -2936,7 +2937,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOn } break; default: - warning("AdScene::GetSceneObjects - Unhandled enum"); + debugC(kWinterMuteDebugGeneral, "AdScene::GetSceneObjects - Unhandled enum"); break; } } diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index e363c7bd54..186d80d446 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -67,6 +67,7 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) DebugMan.addDebugChannel(kWinterMuteDebugFont, "font", "Text-drawing-related messages"); DebugMan.addDebugChannel(kWinterMuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); DebugMan.addDebugChannel(kWinterMuteDebugAudio, "audio", "audio-playback-related issues"); + DebugMan.addDebugChannel(kWinterMuteDebugGeneral, "general", "various issues not covered by any of the above"); _game = NULL; } diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index a0292c17ec..8607c50e25 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -38,7 +38,8 @@ enum { kWinterMuteDebugSaveGame = 1 << 1, kWinterMuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) kWinterMuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) - kWinterMuteDebugAudio = 1 << 4 + kWinterMuteDebugAudio = 1 << 4, + kWinterMuteDebugGeneral = 1 << 5 }; class WinterMuteEngine : public Engine { -- cgit v1.2.3 From 30f35c4c3fce92cbdad38e5bfdeebc4e282d7b2e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 01:13:16 +0200 Subject: WINTERMUTE: Use 64k-tables for alpha-blitting. --- .../base/gfx/osystem/base_render_osystem.cpp | 1 + .../wintermute/graphics/transparent_surface.cpp | 36 +++++++++++++++++++--- engines/wintermute/graphics/transparent_surface.h | 4 +++ 3 files changed, 36 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index dbcb329d64..ab4e690458 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -114,6 +114,7 @@ BaseRenderOSystem::~BaseRenderOSystem() { delete _renderSurface; _blankSurface->free(); delete _blankSurface; + TransparentSurface::destroyLookup(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 1662ff19af..6bc324dd2b 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -29,6 +29,13 @@ namespace WinterMute { +byte *TransparentSurface::_lookup = NULL; + +void TransparentSurface::destroyLookup() { + delete _lookup; + _lookup = NULL; +} + TransparentSurface::TransparentSurface() : Surface(), _enableAlphaBlit(true) {} TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _enableAlphaBlit(true) { @@ -67,9 +74,22 @@ void doBlitOpaque(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pit } } -void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { +void TransparentSurface::generateLookup() { + _lookup = new byte[256 * 256]; + for (int i = 0; i < 256; i++) { + for (int j = 0; j < 256; j++) { + _lookup[(i << 8) + j] = (i * j) >> 8; + } + } +} + +void TransparentSurface::doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; + if (!_lookup) { + generateLookup(); + } + #ifdef SCUMM_LITTLE_ENDIAN const int aIndex = 3; const int bIndex = 0; @@ -103,10 +123,6 @@ void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitc int a = (pix >> aShift) & 0xff; int outb, outg, outr, outa; in += inStep; - - /* if (ca != 255) { - a = a * ca >> 8; - }*/ switch (a) { case 0: // Full transparency @@ -127,12 +143,22 @@ void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitc default: // alpha blending outa = 255; +//#define USE_LOOKUP_TABLE_FOR_ALPHA +#ifndef USE_LOOKUP_TABLE_FOR_ALPHA outb = (oPix >> bShiftTarget) & 0xff; outg = (oPix >> gShiftTarget) & 0xff; outr = (oPix >> rShiftTarget) & 0xff; outb += ((b - outb) * a) >> 8; outg += ((g - outg) * a) >> 8; outr += ((r - outr) * a) >> 8; +#else + outb = _lookup[(((oPix >> bShiftTarget) & 0xff)) + ((255 - a) << 8)]; + outg = _lookup[(((oPix >> gShiftTarget) & 0xff)) + ((255 - a) << 8)]; + outr = _lookup[(((oPix >> rShiftTarget) & 0xff)) + ((255 - a) << 8)]; + outb += _lookup[b + (a << 8)]; + outg += _lookup[g + (a << 8)]; + outr += _lookup[r + (a << 8)]; +#endif //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); out[aIndex] = outa; out[bIndex] = outb; diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 5e70b63218..761b7ba196 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -105,7 +105,11 @@ struct TransparentSurface : public Graphics::Surface { // The following scale-code supports arbitrary scaling (i.e. no repeats of column 0 at the end of lines) TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; TransparentSurface *scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const; + static byte *_lookup; + static void destroyLookup(); private: + static void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep); + static void generateLookup(); static int *scaleLine(int size, int srcSize); }; -- cgit v1.2.3 From c1b5626bca1e0e08316353f1ead00ed763cd5380 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 01:14:05 +0200 Subject: WINTERMUTE: Apply color-key to RGB-images, and upconvert them to RGBA. --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 7845390871..400bb1de41 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -149,8 +149,12 @@ bool BaseSurfaceOSystem::finishLoad() { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + if (image->getSurface()->format.bytesPerPixel == 3) { + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } } else { _surface = new Graphics::Surface(); _surface->copyFrom(*image->getSurface()); -- cgit v1.2.3 From 61ddc77804279a28f3dc8ebef4c226c78816d689 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 02:13:26 +0200 Subject: WINTERMUTE: Use the correct DPI for TTF-fonts, and don't display overshooting lines. --- engines/wintermute/base/font/base_font_truetype.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 00b522c826..4fa5ac08ce 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -248,6 +248,13 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, Common::Array lines; _font->wordWrapText(text, width, lines); + while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) { + lines.pop_back(); + } + if (lines.size() == 0) { + return NULL; + } + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; if (align == TAL_LEFT) { alignment = Graphics::kTextAlignLeft; @@ -553,7 +560,7 @@ bool BaseFontTT::initFont() { if (file) { #ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). _font = _deletableFont; #endif } -- cgit v1.2.3 From 4168b50fc3951cb716597ed8bf559d883828ff1a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 02:19:41 +0200 Subject: WINTERMUTE: Remove BPkgFile, as wrapCompressedStream can handle that job now. --- engines/wintermute/base/file/base_file_entry.cpp | 32 +----------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index da1bfa7ac8..a08d55db43 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -33,31 +33,6 @@ #include "common/zlib.h" namespace WinterMute { -// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. -class CBPkgFile : public Common::SeekableReadStream { - uint32 _size; - Common::SeekableReadStream *_stream; -public: - CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { - delete _stream; - } - virtual uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } - virtual bool eos() const { - return _stream->eos(); - } - virtual int32 pos() const { - return _stream->pos(); - } - virtual int32 size() const { - return _size; - } - virtual bool seek(int32 offset, int whence = SEEK_SET) { - return _stream->seek(offset, whence); - } -}; Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); @@ -65,18 +40,13 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { return NULL; } - bool compressed = (_compressedLength != 0); if (compressed) { - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); - // file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // TODO: Uncomment on merge + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // } else { file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); } - if (file->size() == 0) { // TODO: Cleanup on next merge (CBPkgFile is just a placeholder for the commented out wrap above. - file = new CBPkgFile(file, _length); - } file->seek(0); -- cgit v1.2.3 From ddfa227b939d922f738f932997b70110453068cf Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 02:24:15 +0200 Subject: WINTERMUTE: Cleanup in TransparentSurface. --- engines/wintermute/graphics/transparent_surface.cpp | 21 ++++----------------- engines/wintermute/graphics/transparent_surface.h | 1 - 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 6bc324dd2b..982399976b 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -62,10 +62,8 @@ void doBlitOpaque(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pit for (uint32 i = 0; i < height; i++) { out = outo; in = ino; + memcpy(out, in, width * 4); for (uint32 j = 0; j < width; j++) { - uint32 pix = *(uint32 *)in; - in += inStep; - *(uint32*)out = pix; out[aIndex] = 0xFF; out += 4; } @@ -133,7 +131,7 @@ void TransparentSurface::doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 outg = g; outr = r; outa = a; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = outa; out[bIndex] = outb; out[gIndex] = outg; @@ -143,23 +141,14 @@ void TransparentSurface::doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 default: // alpha blending outa = 255; -//#define USE_LOOKUP_TABLE_FOR_ALPHA -#ifndef USE_LOOKUP_TABLE_FOR_ALPHA - outb = (oPix >> bShiftTarget) & 0xff; - outg = (oPix >> gShiftTarget) & 0xff; - outr = (oPix >> rShiftTarget) & 0xff; - outb += ((b - outb) * a) >> 8; - outg += ((g - outg) * a) >> 8; - outr += ((r - outr) * a) >> 8; -#else + outb = _lookup[(((oPix >> bShiftTarget) & 0xff)) + ((255 - a) << 8)]; outg = _lookup[(((oPix >> gShiftTarget) & 0xff)) + ((255 - a) << 8)]; outr = _lookup[(((oPix >> rShiftTarget) & 0xff)) + ((255 - a) << 8)]; outb += _lookup[b + (a << 8)]; outg += _lookup[g + (a << 8)]; outr += _lookup[r + (a << 8)]; -#endif - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); + out[aIndex] = outa; out[bIndex] = outb; out[gIndex] = outg; @@ -339,7 +328,6 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p else outr = r; outa = a; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); out[aIndex] = outa; out[bIndex] = outb; out[gIndex] = outg; @@ -370,7 +358,6 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p outr += ((r - outr) * a * cr) >> 16; else outr += ((r - outr) * a) >> 8; - //*(uint32 *)out = target.format.ARGBToColor(o_a, o_r, o_g, o_b); out[aIndex] = outa; out[bIndex] = outb; out[gIndex] = outg; diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 761b7ba196..d9fe00a6d9 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -110,7 +110,6 @@ struct TransparentSurface : public Graphics::Surface { private: static void doBlitAlpha(byte *ino, byte* outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep); static void generateLookup(); - static int *scaleLine(int size, int srcSize); }; /** -- cgit v1.2.3 From fed19cb66ae5b56dd7dc81b90edd5a0d15986678 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 03:42:30 +0200 Subject: WINTERMUTE: WinterMute -> Wintermute --- engines/wintermute/ad/ad_actor.cpp | 4 +- engines/wintermute/ad/ad_actor.h | 4 +- engines/wintermute/ad/ad_entity.cpp | 4 +- engines/wintermute/ad/ad_entity.h | 4 +- engines/wintermute/ad/ad_game.cpp | 4 +- engines/wintermute/ad/ad_game.h | 4 +- engines/wintermute/ad/ad_inventory.cpp | 4 +- engines/wintermute/ad/ad_inventory.h | 4 +- engines/wintermute/ad/ad_inventory_box.cpp | 4 +- engines/wintermute/ad/ad_inventory_box.h | 4 +- engines/wintermute/ad/ad_item.cpp | 4 +- engines/wintermute/ad/ad_item.h | 4 +- engines/wintermute/ad/ad_layer.cpp | 4 +- engines/wintermute/ad/ad_layer.h | 4 +- engines/wintermute/ad/ad_node_state.cpp | 4 +- engines/wintermute/ad/ad_node_state.h | 4 +- engines/wintermute/ad/ad_object.cpp | 4 +- engines/wintermute/ad/ad_object.h | 4 +- engines/wintermute/ad/ad_path.cpp | 4 +- engines/wintermute/ad/ad_path.h | 4 +- engines/wintermute/ad/ad_path_point.cpp | 4 +- engines/wintermute/ad/ad_path_point.h | 4 +- engines/wintermute/ad/ad_region.cpp | 4 +- engines/wintermute/ad/ad_region.h | 4 +- engines/wintermute/ad/ad_response.cpp | 4 +- engines/wintermute/ad/ad_response.h | 4 +- engines/wintermute/ad/ad_response_box.cpp | 8 ++-- engines/wintermute/ad/ad_response_box.h | 4 +- engines/wintermute/ad/ad_response_context.cpp | 4 +- engines/wintermute/ad/ad_response_context.h | 4 +- engines/wintermute/ad/ad_rot_level.cpp | 4 +- engines/wintermute/ad/ad_rot_level.h | 4 +- engines/wintermute/ad/ad_scale_level.cpp | 4 +- engines/wintermute/ad/ad_scale_level.h | 4 +- engines/wintermute/ad/ad_scene.cpp | 6 +-- engines/wintermute/ad/ad_scene.h | 4 +- engines/wintermute/ad/ad_scene_node.cpp | 4 +- engines/wintermute/ad/ad_scene_node.h | 2 +- engines/wintermute/ad/ad_scene_state.cpp | 4 +- engines/wintermute/ad/ad_scene_state.h | 4 +- engines/wintermute/ad/ad_sentence.cpp | 4 +- engines/wintermute/ad/ad_sentence.h | 4 +- engines/wintermute/ad/ad_sprite_set.cpp | 4 +- engines/wintermute/ad/ad_sprite_set.h | 4 +- engines/wintermute/ad/ad_talk_def.cpp | 4 +- engines/wintermute/ad/ad_talk_def.h | 4 +- engines/wintermute/ad/ad_talk_holder.cpp | 4 +- engines/wintermute/ad/ad_talk_holder.h | 4 +- engines/wintermute/ad/ad_talk_node.cpp | 4 +- engines/wintermute/ad/ad_talk_node.h | 4 +- engines/wintermute/ad/ad_types.h | 4 +- engines/wintermute/ad/ad_waypoint_group.cpp | 4 +- engines/wintermute/ad/ad_waypoint_group.h | 4 +- engines/wintermute/base/base.cpp | 4 +- engines/wintermute/base/base.h | 4 +- engines/wintermute/base/base_active_rect.cpp | 4 +- engines/wintermute/base/base_active_rect.h | 4 +- engines/wintermute/base/base_dynamic_buffer.cpp | 4 +- engines/wintermute/base/base_dynamic_buffer.h | 4 +- engines/wintermute/base/base_engine.cpp | 10 ++--- engines/wintermute/base/base_engine.h | 6 +-- engines/wintermute/base/base_fader.cpp | 4 +- engines/wintermute/base/base_fader.h | 4 +- engines/wintermute/base/base_file_manager.cpp | 24 +++++------ engines/wintermute/base/base_file_manager.h | 4 +- engines/wintermute/base/base_frame.cpp | 4 +- engines/wintermute/base/base_frame.h | 4 +- engines/wintermute/base/base_game.cpp | 8 ++-- engines/wintermute/base/base_game.h | 4 +- engines/wintermute/base/base_keyboard_state.cpp | 4 +- engines/wintermute/base/base_keyboard_state.h | 4 +- engines/wintermute/base/base_named_object.cpp | 4 +- engines/wintermute/base/base_named_object.h | 4 +- engines/wintermute/base/base_object.cpp | 4 +- engines/wintermute/base/base_object.h | 4 +- engines/wintermute/base/base_parser.cpp | 4 +- engines/wintermute/base/base_parser.h | 4 +- .../wintermute/base/base_persistence_manager.cpp | 20 ++++----- engines/wintermute/base/base_persistence_manager.h | 4 +- engines/wintermute/base/base_point.cpp | 4 +- engines/wintermute/base/base_point.h | 4 +- engines/wintermute/base/base_quick_msg.cpp | 4 +- engines/wintermute/base/base_quick_msg.h | 4 +- engines/wintermute/base/base_region.cpp | 4 +- engines/wintermute/base/base_region.h | 4 +- engines/wintermute/base/base_save_thumb_helper.cpp | 4 +- engines/wintermute/base/base_save_thumb_helper.h | 4 +- engines/wintermute/base/base_script_holder.cpp | 4 +- engines/wintermute/base/base_script_holder.h | 4 +- engines/wintermute/base/base_scriptable.cpp | 4 +- engines/wintermute/base/base_scriptable.h | 4 +- engines/wintermute/base/base_sprite.cpp | 4 +- engines/wintermute/base/base_sprite.h | 4 +- engines/wintermute/base/base_string_table.cpp | 4 +- engines/wintermute/base/base_string_table.h | 4 +- engines/wintermute/base/base_sub_frame.cpp | 4 +- engines/wintermute/base/base_sub_frame.h | 4 +- engines/wintermute/base/base_surface_storage.cpp | 4 +- engines/wintermute/base/base_surface_storage.h | 4 +- .../wintermute/base/base_transition_manager.cpp | 4 +- engines/wintermute/base/base_transition_manager.h | 4 +- engines/wintermute/base/base_viewport.cpp | 4 +- engines/wintermute/base/base_viewport.h | 4 +- engines/wintermute/base/file/base_disk_file.cpp | 4 +- engines/wintermute/base/file/base_disk_file.h | 4 +- engines/wintermute/base/file/base_file.cpp | 4 +- engines/wintermute/base/file/base_file.h | 4 +- engines/wintermute/base/file/base_file_entry.cpp | 4 +- engines/wintermute/base/file/base_file_entry.h | 4 +- engines/wintermute/base/file/base_package.cpp | 12 +++--- engines/wintermute/base/file/base_package.h | 4 +- engines/wintermute/base/file/base_resources.cpp | 4 +- engines/wintermute/base/file/base_resources.h | 4 +- .../wintermute/base/file/base_save_thumb_file.cpp | 4 +- .../wintermute/base/file/base_save_thumb_file.h | 4 +- engines/wintermute/base/file/dcpackage.h | 4 +- engines/wintermute/base/font/base_font.cpp | 4 +- engines/wintermute/base/font/base_font.h | 4 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 +- engines/wintermute/base/font/base_font_bitmap.h | 4 +- engines/wintermute/base/font/base_font_storage.cpp | 4 +- engines/wintermute/base/font/base_font_storage.h | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 8 ++-- engines/wintermute/base/font/base_font_truetype.h | 4 +- engines/wintermute/base/gfx/base_image.cpp | 6 +-- engines/wintermute/base/gfx/base_image.h | 4 +- engines/wintermute/base/gfx/base_renderer.cpp | 4 +- engines/wintermute/base/gfx/base_renderer.h | 4 +- engines/wintermute/base/gfx/base_surface.cpp | 4 +- engines/wintermute/base/gfx/base_surface.h | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 4 +- .../base/gfx/osystem/base_render_osystem.h | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.h | 4 +- engines/wintermute/base/particles/part_emitter.cpp | 4 +- engines/wintermute/base/particles/part_emitter.h | 4 +- engines/wintermute/base/particles/part_force.cpp | 4 +- engines/wintermute/base/particles/part_force.h | 4 +- .../wintermute/base/particles/part_particle.cpp | 4 +- engines/wintermute/base/particles/part_particle.h | 4 +- engines/wintermute/base/saveload.cpp | 8 ++-- engines/wintermute/base/saveload.h | 4 +- engines/wintermute/base/scriptables/dcscript.h | 4 +- engines/wintermute/base/scriptables/script.cpp | 4 +- engines/wintermute/base/scriptables/script.h | 4 +- .../wintermute/base/scriptables/script_engine.cpp | 4 +- .../wintermute/base/scriptables/script_engine.h | 4 +- .../base/scriptables/script_ext_array.cpp | 4 +- .../wintermute/base/scriptables/script_ext_array.h | 4 +- .../base/scriptables/script_ext_date.cpp | 4 +- .../wintermute/base/scriptables/script_ext_date.h | 4 +- .../base/scriptables/script_ext_file.cpp | 4 +- .../wintermute/base/scriptables/script_ext_file.h | 4 +- .../base/scriptables/script_ext_math.cpp | 4 +- .../wintermute/base/scriptables/script_ext_math.h | 4 +- .../base/scriptables/script_ext_mem_buffer.cpp | 4 +- .../base/scriptables/script_ext_mem_buffer.h | 4 +- .../base/scriptables/script_ext_object.cpp | 4 +- .../base/scriptables/script_ext_object.h | 4 +- .../base/scriptables/script_ext_string.cpp | 4 +- .../base/scriptables/script_ext_string.h | 4 +- .../wintermute/base/scriptables/script_stack.cpp | 4 +- engines/wintermute/base/scriptables/script_stack.h | 4 +- .../wintermute/base/scriptables/script_value.cpp | 4 +- engines/wintermute/base/scriptables/script_value.h | 4 +- engines/wintermute/base/sound/base_sound.cpp | 4 +- engines/wintermute/base/sound/base_sound.h | 4 +- .../wintermute/base/sound/base_sound_buffer.cpp | 6 +-- engines/wintermute/base/sound/base_sound_buffer.h | 4 +- .../wintermute/base/sound/base_sound_manager.cpp | 4 +- engines/wintermute/base/sound/base_sound_manager.h | 4 +- engines/wintermute/coll_templ.h | 4 +- engines/wintermute/dctypes.h | 4 +- engines/wintermute/detection.cpp | 26 +++++------ engines/wintermute/detection_tables.h | 4 +- engines/wintermute/graphics/tga.cpp | 2 +- engines/wintermute/graphics/tga.h | 2 +- .../wintermute/graphics/transparent_surface.cpp | 2 +- engines/wintermute/graphics/transparent_surface.h | 2 +- engines/wintermute/math/math_util.cpp | 4 +- engines/wintermute/math/math_util.h | 4 +- engines/wintermute/math/matrix4.cpp | 4 +- engines/wintermute/math/matrix4.h | 4 +- engines/wintermute/math/rect32.h | 4 +- engines/wintermute/math/vector2.cpp | 4 +- engines/wintermute/math/vector2.h | 4 +- engines/wintermute/persistent.cpp | 4 +- engines/wintermute/persistent.h | 8 ++-- engines/wintermute/platform_osystem.cpp | 4 +- engines/wintermute/platform_osystem.h | 6 +-- engines/wintermute/system/sys_class.cpp | 4 +- engines/wintermute/system/sys_class.h | 10 ++--- engines/wintermute/system/sys_class_registry.cpp | 6 +-- engines/wintermute/system/sys_class_registry.h | 10 ++--- engines/wintermute/system/sys_instance.cpp | 4 +- engines/wintermute/system/sys_instance.h | 4 +- engines/wintermute/ui/ui_button.cpp | 4 +- engines/wintermute/ui/ui_button.h | 4 +- engines/wintermute/ui/ui_edit.cpp | 4 +- engines/wintermute/ui/ui_edit.h | 4 +- engines/wintermute/ui/ui_entity.cpp | 4 +- engines/wintermute/ui/ui_entity.h | 4 +- engines/wintermute/ui/ui_object.cpp | 4 +- engines/wintermute/ui/ui_object.h | 4 +- engines/wintermute/ui/ui_text.cpp | 4 +- engines/wintermute/ui/ui_text.h | 4 +- engines/wintermute/ui/ui_tiled_image.cpp | 4 +- engines/wintermute/ui/ui_tiled_image.h | 4 +- engines/wintermute/ui/ui_window.cpp | 4 +- engines/wintermute/ui/ui_window.h | 4 +- engines/wintermute/utils/crc.cpp | 4 +- engines/wintermute/utils/crc.h | 4 +- engines/wintermute/utils/path_util.cpp | 4 +- engines/wintermute/utils/path_util.h | 4 +- engines/wintermute/utils/string_util.cpp | 4 +- engines/wintermute/utils/string_util.h | 4 +- engines/wintermute/utils/utils.cpp | 4 +- engines/wintermute/utils/utils.h | 4 +- .../wintermute/video/decoders/theora_decoder.cpp | 2 +- engines/wintermute/video/decoders/theora_decoder.h | 2 +- engines/wintermute/video/video_player.cpp | 4 +- engines/wintermute/video/video_player.h | 4 +- engines/wintermute/video/video_theora_player.cpp | 6 +-- engines/wintermute/video/video_theora_player.h | 4 +- engines/wintermute/wintermute.cpp | 50 +++++++++++----------- engines/wintermute/wintermute.h | 24 +++++------ engines/wintermute/wintypes.h | 4 +- 227 files changed, 539 insertions(+), 539 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index aa148c9c85..e180499ee0 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -45,7 +45,7 @@ #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/base_engine.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdActor, false) @@ -1457,4 +1457,4 @@ bool AdActor::playAnim(const char *filename) { return AdTalkHolder::playAnim(filename); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 0c6334ac9d..4bc1bae37f 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -38,7 +38,7 @@ #include "engines/wintermute/persistent.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class AdSpriteSet; class AdPath; @@ -103,6 +103,6 @@ private: int _pFCount; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_ADACTOR_H diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index e6fde43697..5bf03d6062 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -52,7 +52,7 @@ #include "engines/wintermute/base/particles/part_emitter.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdEntity, false) @@ -1120,4 +1120,4 @@ bool AdEntity::setSprite(const char *filename) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h index 9931327916..2178563534 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -31,7 +31,7 @@ #include "engines/wintermute/ad/ad_talk_holder.h" -namespace WinterMute { +namespace Wintermute { class VideoTheoraPlayer; class AdEntity : public AdTalkHolder { public: @@ -63,6 +63,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 3bda534a04..2971cdab00 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -62,7 +62,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdGame, true) @@ -2279,4 +2279,4 @@ bool AdGame::onScriptShutdown(ScScript *script) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 080aea40aa..5707ec48fd 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -31,7 +31,7 @@ #include "engines/wintermute/ad/ad_types.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { class AdItem; class AdInventory; class AdSceneState; @@ -158,6 +158,6 @@ private: AdInventoryBox *_inventoryBox; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 203a18ae32..282c37449b 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdInventory, false) @@ -133,4 +133,4 @@ bool AdInventory::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_inventory.h b/engines/wintermute/ad/ad_inventory.h index 9eff30454c..9a12eb1abe 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class AdItem; @@ -47,6 +47,6 @@ public: int _scrollOffset; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 555fa8e5c2..fd49860a5c 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -41,7 +41,7 @@ #include "common/str.h" #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdInventoryBox, false) @@ -385,4 +385,4 @@ bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h index 1857cd8f19..451ebf9635 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { class UIButton; class UIWindow; @@ -60,6 +60,6 @@ private: int _itemWidth; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index cacafa826b..f5c8b16308 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -43,7 +43,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdItem, false) @@ -810,4 +810,4 @@ bool AdItem::getExtendedFlag(const char *flagName) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index eaa6844fcd..e06266f8b7 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -32,7 +32,7 @@ #include "engines/wintermute/ad/ad_talk_holder.h" -namespace WinterMute { +namespace Wintermute { class AdItem : public AdTalkHolder { public: @@ -64,6 +64,6 @@ private: char *_amountString; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 5742c9fc85..2cec37bec1 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdLayer, false) @@ -563,4 +563,4 @@ bool AdLayer::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index 6d1686e1a6..b01079c091 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADLAYER_H #define WINTERMUTE_ADLAYER_H -namespace WinterMute { +namespace Wintermute { class AdSceneNode; class AdLayer : public BaseObject { public: @@ -53,6 +53,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 4784d6d331..fb2dfed0f5 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdNodeState, false) @@ -193,4 +193,4 @@ bool AdNodeState::transferEntity(AdEntity *entity, bool includingSprites, bool s return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_node_state.h b/engines/wintermute/ad/ad_node_state.h index ce15bc893f..0008d4b3ee 100644 --- a/engines/wintermute/ad/ad_node_state.h +++ b/engines/wintermute/ad/ad_node_state.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADNODESTATE_H #define WINTERMUTE_ADNODESTATE_H -namespace WinterMute { +namespace Wintermute { class AdEntity; @@ -55,6 +55,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index aaf4c6db4a..59781087a3 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -52,7 +52,7 @@ #include "common/str.h" #include "common/util.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdObject, false) @@ -1296,4 +1296,4 @@ bool AdObject::updatePartEmitter() { return _partEmitter->update(); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index 8e4cb80742..9451707445 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -32,7 +32,7 @@ #include "engines/wintermute/ad/ad_types.h" #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class AdWaypointGroup; class AdRegion; @@ -119,6 +119,6 @@ protected: bool getScale(float *scaleX, float *scaleY); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 89eb3f29fa..0c0ec63e0f 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/ad/ad_path.h" #include "engines/wintermute/base/base_point.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdPath, false) @@ -117,4 +117,4 @@ bool AdPath::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h index 8622e6757c..b85e1fce7a 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BasePoint; class AdPath : public BaseClass { public: @@ -51,6 +51,6 @@ public: bool _ready; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp index d5d447eb9a..1fb954c668 100644 --- a/engines/wintermute/ad/ad_path_point.cpp +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/ad/ad_path_point.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdPathPoint, false) @@ -72,4 +72,4 @@ bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_path_point.h b/engines/wintermute/ad/ad_path_point.h index ea0a5795d0..8201750cef 100644 --- a/engines/wintermute/ad/ad_path_point.h +++ b/engines/wintermute/ad/ad_path_point.h @@ -32,7 +32,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base_point.h" -namespace WinterMute { +namespace Wintermute { class AdPathPoint : public BasePoint { public: @@ -45,6 +45,6 @@ public: int _distance; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 5ecb24c5b7..3b9d4fadda 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdRegion, false) @@ -395,4 +395,4 @@ bool AdRegion::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h index 7ee36dc970..5c33291a88 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_region.h" -namespace WinterMute { +namespace Wintermute { class AdRegion : public BaseRegion { public: @@ -53,6 +53,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index 9cfa181b1c..f7886bba5a 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/utils/utils.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdResponse, false) @@ -143,4 +143,4 @@ bool AdResponse::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h index 0cb8f6628b..0678ef5a37 100644 --- a/engines/wintermute/ad/ad_response.h +++ b/engines/wintermute/ad/ad_response.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/ad/ad_types.h" -namespace WinterMute { +namespace Wintermute { class BaseFont; class AdResponse : public BaseObject { public: @@ -56,6 +56,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index 5f2a1dc825..d467509612 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -45,7 +45,7 @@ #include "engines/wintermute/wintermute.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdResponseBox, false) @@ -611,7 +611,7 @@ bool AdResponseBox::weedResponses() { } break; default: - debugC(kWinterMuteDebugGeneral, "AdResponseBox::WeedResponses - Unhandled enum"); + debugC(kWintermuteDebugGeneral, "AdResponseBox::WeedResponses - Unhandled enum"); break; } } @@ -641,7 +641,7 @@ bool AdResponseBox::handleResponse(AdResponse *response) { adGame->addGameResponse(response->_iD); break; default: - debugC(kWinterMuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); + debugC(kWintermuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); } return STATUS_OK; @@ -708,4 +708,4 @@ bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveO return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index c1f60ba6ae..99522f00f6 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class UIButton; class UIWindow; @@ -82,6 +82,6 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index 175a7f8491..0a2eff842d 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/ad/ad_response_context.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdResponseContext, false) @@ -68,4 +68,4 @@ void AdResponseContext::setContext(const char *context) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response_context.h b/engines/wintermute/ad/ad_response_context.h index d5c8bb3fa3..a630f975e4 100644 --- a/engines/wintermute/ad/ad_response_context.h +++ b/engines/wintermute/ad/ad_response_context.h @@ -32,7 +32,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class AdResponseContext : public BaseClass { public: @@ -45,6 +45,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index 28c37b5b81..487e1f7067 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdRotLevel, false) @@ -158,4 +158,4 @@ bool AdRotLevel::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_rot_level.h b/engines/wintermute/ad/ad_rot_level.h index 4339a379a5..7951c7562d 100644 --- a/engines/wintermute/ad/ad_rot_level.h +++ b/engines/wintermute/ad/ad_rot_level.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class AdRotLevel : public BaseObject { public: @@ -44,6 +44,6 @@ public: bool loadBuffer(byte *buffer, bool complete = true); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 430be3559d..f3ec68dd64 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdScaleLevel, false) @@ -156,4 +156,4 @@ bool AdScaleLevel::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scale_level.h b/engines/wintermute/ad/ad_scale_level.h index 5e84f8c9ce..41a2edf8c5 100644 --- a/engines/wintermute/ad/ad_scale_level.h +++ b/engines/wintermute/ad/ad_scale_level.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class AdScaleLevel : public BaseObject { public: @@ -45,6 +45,6 @@ public: bool loadBuffer(byte *buffer, bool complete = true); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index d99b6b7fb8..19968d41dc 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -60,7 +60,7 @@ #include "engines/wintermute/wintermute.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdScene, false) @@ -2937,7 +2937,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOn } break; default: - debugC(kWinterMuteDebugGeneral, "AdScene::GetSceneObjects - Unhandled enum"); + debugC(kWintermuteDebugGeneral, "AdScene::GetSceneObjects - Unhandled enum"); break; } } @@ -2999,4 +2999,4 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index 5c2f505001..20b3f5026d 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_fader.h" -namespace WinterMute { +namespace Wintermute { class UIWindow; class AdObject; @@ -176,6 +176,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index 87b2c25406..4f6acdbc95 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/ad/ad_scene_node.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdSceneNode, false) @@ -79,4 +79,4 @@ bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scene_node.h b/engines/wintermute/ad/ad_scene_node.h index b56c351bc8..8cc50b86c4 100644 --- a/engines/wintermute/ad/ad_scene_node.h +++ b/engines/wintermute/ad/ad_scene_node.h @@ -34,7 +34,7 @@ #include "engines/wintermute/ad/ad_region.h" // Added by ClassView #include "engines/wintermute/ad/ad_entity.h" -namespace WinterMute { +namespace Wintermute { class AdSceneNode : public BaseObject { public: diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index eafb1f96b6..4a85148540 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdSceneState, false) @@ -92,4 +92,4 @@ AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h index 8f1bdb8fd2..8298d23d76 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class AdNodeState; class AdSceneState : public BaseClass { public: @@ -46,6 +46,6 @@ public: BaseArray _nodeStates; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 60c4519823..0c3080c9cd 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdSentence, false) @@ -357,4 +357,4 @@ bool AdSentence::canSkip() { return (_gameRef->_timer - _startTime) > 300; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_sentence.h b/engines/wintermute/ad/ad_sentence.h index ae4ee793d5..85be09094c 100644 --- a/engines/wintermute/ad/ad_sentence.h +++ b/engines/wintermute/ad/ad_sentence.h @@ -36,7 +36,7 @@ #include "engines/wintermute/dctypes.h" // Added by ClassView #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { class AdTalkDef; class BaseFont; class BaseSprite; @@ -80,6 +80,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index df10418d95..5b605d6e32 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_sprite.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdSpriteSet, false) @@ -353,4 +353,4 @@ bool AdSpriteSet::containsSprite(BaseSprite *sprite) { return false; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h index 555ab914cf..3855114850 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BaseSprite; class AdSpriteSet : public BaseObject { public: @@ -48,6 +48,6 @@ public: BaseSprite *_sprites[NUM_DIRECTIONS]; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 71d8d6b1c3..08136d787e 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdTalkDef, false) @@ -282,4 +282,4 @@ BaseSprite *AdTalkDef::getDefaultSprite(TDirection dir) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index 4d28881e97..f748aa4e7a 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -32,7 +32,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class AdTalkNode; class AdSpriteSet; class AdTalkDef : public BaseObject { @@ -53,6 +53,6 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index a5ab7f3a6d..165ee50270 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_engine.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdTalkHolder, false) @@ -399,4 +399,4 @@ bool AdTalkHolder::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h index 2607fdd9da..906c469b32 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -31,7 +31,7 @@ #include "engines/wintermute/ad/ad_object.h" -namespace WinterMute { +namespace Wintermute { class AdTalkHolder : public AdObject { public: @@ -52,6 +52,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index 14c1c3f459..6d793f483c 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/ad/ad_sprite_set.h" #include "engines/wintermute/utils/utils.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdTalkNode, false) @@ -292,4 +292,4 @@ BaseSprite *AdTalkNode::getSprite(TDirection dir) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_talk_node.h b/engines/wintermute/ad/ad_talk_node.h index 9e599b6af2..863f6d0a3b 100644 --- a/engines/wintermute/ad/ad_talk_node.h +++ b/engines/wintermute/ad/ad_talk_node.h @@ -32,7 +32,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class AdSpriteSet; class BaseSprite; class AdTalkNode : public BaseClass { @@ -58,6 +58,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ad/ad_types.h b/engines/wintermute/ad/ad_types.h index 18892919c6..17152ca5e8 100644 --- a/engines/wintermute/ad/ad_types.h +++ b/engines/wintermute/ad/ad_types.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_ADTYPES_H #define WINTERMUTE_ADTYPES_H -namespace WinterMute { +namespace Wintermute { typedef enum { GAME_NORMAL, @@ -102,6 +102,6 @@ typedef enum { GEOM_GENERIC } TGeomNodeType; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_ADTYPES_H diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 0f83c2c50b..1573f5914e 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(AdWaypointGroup, false) @@ -267,4 +267,4 @@ bool AdWaypointGroup::mimic(AdWaypointGroup *wpt, float scale, int argX, int arg return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index 7d69ab8237..a83c942652 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BasePoint; class AdWaypointGroup : public BaseObject { public: @@ -53,6 +53,6 @@ public: virtual bool scSetProperty(const char *name, ScValue *value); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 8fa26f04a6..11f308a522 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseClass::BaseClass(BaseGame *gameOwner) { @@ -182,4 +182,4 @@ bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index dcd186be42..b1b184b2f4 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -35,7 +35,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; class BaseDynamicBuffer; @@ -59,6 +59,6 @@ protected: std::map::iterator _editorPropsIter;*/ }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index a895735725..46870a0d29 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { @@ -107,4 +107,4 @@ void BaseActiveRect::clipRect() { BasePlatform::intersectRect(&_rect, &_rect, &rc); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 0885b0e13e..b446dadcce 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -32,7 +32,7 @@ #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion; class BaseSubFrame; class BaseObject; @@ -55,6 +55,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index d953483be8..0a7a214ba4 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_dynamic_buffer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { @@ -201,4 +201,4 @@ void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { putBytes((byte *)buff, strlen(buff)); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index ff3897e71b..8285b472b2 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseDynamicBuffer { public: @@ -61,6 +61,6 @@ private: void putTextForm(const char *format, va_list argptr); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index c31777c866..3447407866 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -33,10 +33,10 @@ #include "engines/wintermute/system/sys_class_registry.h" #include "common/system.h" namespace Common { -DECLARE_SINGLETON(WinterMute::BaseEngine); +DECLARE_SINGLETON(Wintermute::BaseEngine); } -namespace WinterMute { +namespace Wintermute { BaseEngine::BaseEngine() { _fileManager = NULL; @@ -49,7 +49,7 @@ BaseEngine::BaseEngine() { void BaseEngine::init() { _fileManager = new BaseFileManager(); // Don't forget to register your random source - _rnd = new Common::RandomSource("WinterMute"); + _rnd = new Common::RandomSource("Wintermute"); _classReg = new SystemClassRegistry(); _classReg->registerClasses(); } @@ -82,7 +82,7 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { if (instance()._gameRef) { instance()._gameRef->LOG("%s", buff); } else { - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); } } @@ -90,4 +90,4 @@ uint32 BaseEngine::randInt(int from, int to) { return _rnd->getRandomNumberRng(from, to); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 04199715af..32007ef571 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -33,13 +33,13 @@ #include "common/singleton.h" #include "common/random.h" -namespace WinterMute { +namespace Wintermute { class BaseFileManager; class BaseRegistry; class BaseGame; class SystemClassRegistry; -class BaseEngine : public Common::Singleton { +class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; Common::String _gameId; @@ -63,6 +63,6 @@ public: const char *getGameId() { return _gameId.c_str(); } }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4bc166f841..580a7afeb4 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "common/util.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -191,4 +191,4 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 4401bd0ebd..34d0e7d3da 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BaseFader : public BaseObject { public: @@ -58,6 +58,6 @@ private: uint32 _startTime; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index c17a456f11..f7a3b6a3fb 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -46,7 +46,7 @@ #include "common/savefile.h" #include "common/fs.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -88,20 +88,20 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { if (mustExist) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error opening file '%s'", filename.c_str()); } return NULL; } buffer = new byte[file->size() + 1]; if (buffer == NULL) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); closeFile(file); return NULL; } if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); delete[] buffer; return NULL; @@ -165,7 +165,7 @@ bool BaseFileManager::initPaths() { bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { - debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it))) { addPath(PATH_PACKAGE, (*it)); @@ -177,13 +177,13 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Scanning packages"); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Scanning packages"); // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - debugC(kWinterMuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().hasSuffix(".dcp")) { @@ -198,12 +198,12 @@ bool BaseFileManager::registerPackages() { continue; } } - debugC(kWinterMuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); } } -// debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); +// debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } @@ -263,7 +263,7 @@ Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &file if (strcmp(filename.c_str(), "") == 0) { return NULL; } - debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); + debugC(kWintermuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); if (file && keepTrackOf) { @@ -317,7 +317,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - debugC(kWinterMuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } @@ -328,4 +328,4 @@ BaseFileManager *BaseFileManager::getEngineInstance() { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 23032ca65a..91b1add1c8 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -34,7 +34,7 @@ #include "common/fs.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { class BaseFileManager { public: bool cleanup(); @@ -69,6 +69,6 @@ private: // the detector too, without launching the entire engine: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 5473419f22..1462f1430d 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -39,7 +39,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseFrame, false) @@ -757,4 +757,4 @@ const char *BaseFrame::scToString() { return "[frame]"; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index b019ebf7b6..b1eae6b659 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseSound; class BaseSubFrame; class BaseObject; @@ -68,6 +68,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b92da4c11b..568e6dc6fd 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -72,7 +72,7 @@ #include "common/system.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -307,7 +307,7 @@ BaseGame::~BaseGame() { _stringTable = NULL; DEBUG_DebugDisable(); - debugC(kWinterMuteDebugLog, "--- shutting down normally ---\n"); + debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); } @@ -538,7 +538,7 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { _engineLogCallback(buff, res, _engineLogCallbackData); } - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); //fflush((FILE *)_debugLogFile); @@ -4490,4 +4490,4 @@ AnsiString BaseGame::getDeviceType() const { return "computer"; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8a587da3e3..43efad1482 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -36,7 +36,7 @@ #include "engines/wintermute/math/rect32.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); @@ -357,6 +357,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 01b5cea36d..70d92784a5 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -32,7 +32,7 @@ #include "common/system.h" #include "common/keyboard.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseKeyboardState, false) @@ -309,4 +309,4 @@ Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index 8c4b1afb59..382dd9fbce 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -35,7 +35,7 @@ #include "common/keyboard.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseKeyboardState : public BaseScriptable { public: @@ -70,6 +70,6 @@ private: Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 0873f090d0..d95dd3e25b 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/base/base_named_object.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { @@ -68,4 +68,4 @@ void BaseNamedObject::setName(const char *name) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index 32e4d561d7..cd856bb008 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseNamedObject : public BaseClass { char *_name; @@ -46,6 +46,6 @@ public: void setName(const char *name); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 7d186c7f0a..ff8fcd0bf2 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseObject, false) @@ -1243,4 +1243,4 @@ bool BaseObject::afterMove() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index c1e3172a77..34d9ca89ca 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseSprite; class BaseSound; @@ -142,6 +142,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 75268f6483..bbbb5d69ba 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -35,7 +35,7 @@ #define WHITESPACE " \t\n\r" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -464,4 +464,4 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { return num; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 34266bd5bd..3d63668059 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -54,7 +54,7 @@ #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseParser { public: @@ -83,6 +83,6 @@ private: char *_whiteSpace; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index e6ed5cb7e0..1beaeecdd7 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -43,7 +43,7 @@ #include "common/system.h" #include "common/savefile.h" -namespace WinterMute { +namespace Wintermute { #define SAVE_BUFFER_INIT_SIZE 100000 #define SAVE_BUFFER_GROW_BY 50000 @@ -134,7 +134,7 @@ Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); - debugC(kWinterMuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); + debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); return; @@ -331,7 +331,7 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; } @@ -342,8 +342,8 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); - debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; } @@ -353,8 +353,8 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; @@ -371,7 +371,7 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); - Common::SaveFileManager *saveMan = ((WinterMuteEngine *)g_engine)->getSaveFileMan(); + Common::SaveFileManager *saveMan = ((WintermuteEngine *)g_engine)->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(filename); file->write(prefixBuffer, prefixSize); file->write(buffer, bufferSize); @@ -792,7 +792,7 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { if (_saving) { SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - debugC(kWinterMuteDebugSaveGame, "Warning: invalid instance '%s'", name); + debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(classID); @@ -825,4 +825,4 @@ bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte ver return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 87892b42f3..fea8f231d1 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -38,7 +38,7 @@ #include "common/system.h" #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { class Vector2; class BaseGame; @@ -113,6 +113,6 @@ private: BaseGame *_gameRef; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 99e8c609df..73e7e4690a 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BasePoint, false) @@ -60,4 +60,4 @@ bool BasePoint::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 35d310b8d9..68a37c0110 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -32,7 +32,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BasePoint: public BaseClass { public: @@ -45,6 +45,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index e9f3e430af..dfe25b474b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_quick_msg.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { @@ -54,4 +54,4 @@ char *BaseQuickMsg::getText() { return _text; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index f2f9144bc0..bef81827b0 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseQuickMsg : public BaseClass { public: @@ -43,6 +43,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 82dc359eb0..a781c7eeb7 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/platform_osystem.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseRegion, false) @@ -536,4 +536,4 @@ bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { return createRegion() ? STATUS_OK : STATUS_FAILED; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 7770d345f7..f456eb07fc 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion : public BaseObject { public: @@ -64,6 +64,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 0d580e8db3..8cd15ccf1d 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { @@ -77,4 +77,4 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index d0d0757fbf..4131cf89d4 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseImage; @@ -46,6 +46,6 @@ private: BaseImage *_richThumbnail; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index b40647dc7b..d57638a4a8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseScriptHolder, false) @@ -501,4 +501,4 @@ bool BaseScriptHolder::sendEvent(const char *eventName) { return DID_SUCCEED(applyEvent(eventName)); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 4162936ded..4f3d5f4ef9 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -33,7 +33,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class BaseScriptHolder : public BaseScriptable { public: @@ -71,6 +71,6 @@ public: virtual bool sendEvent(const char *eventName); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 11092427be..6e5b30f7b6 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseScriptable, false) @@ -188,4 +188,4 @@ ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 6227b84649..2501f34561 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_named_object.h" #include "engines/wintermute/persistent.h" -namespace WinterMute { +namespace Wintermute { class ScValue; class ScStack; @@ -78,6 +78,6 @@ BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); BaseScriptable *makeSXStore(BaseGame *inGame); BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6c66b808b7..6fe5be9e11 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -41,7 +41,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSprite, false) @@ -812,4 +812,4 @@ bool BaseSprite::killAllSounds() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 952bff0017..a02e69c63f 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base_script_holder.h" -namespace WinterMute { +namespace Wintermute { class BaseFrame; class BaseSurface; class BaseObject; @@ -85,6 +85,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 2e8774020d..3b5e5e3774 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_string_table.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { @@ -252,4 +252,4 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index 1bc9047f7f..c8df25810e 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -33,7 +33,7 @@ #include "common/hashmap.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseStringTable : public BaseClass { public: @@ -50,6 +50,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 7f527392dc..3ddfd1bb14 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSubFrame, false) @@ -652,4 +652,4 @@ bool BaseSubFrame::setSurfaceSimple() { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index d8027d3ce9..935fb667d4 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class BaseObject; class BaseSurface; class BaseSubFrame : public BaseScriptable { @@ -87,6 +87,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index e3c3692892..0ff325be7d 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { //IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); @@ -204,4 +204,4 @@ int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index c09b0a30ab..f1757b3a32 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface; class BaseSurfaceStorage : public BaseClass { public: @@ -52,6 +52,6 @@ public: Common::Array _surfaces; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 63a13309fb..d71bce1084 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { @@ -133,4 +133,4 @@ bool BaseTransitionMgr::update() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 104f327fb8..412361a543 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseTransitionMgr : public BaseClass { public: @@ -49,6 +49,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index a6c7eea96e..af36a4fdd7 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_viewport.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseViewport, false) @@ -95,4 +95,4 @@ int BaseViewport::getHeight() { return _rect.bottom - _rect.top; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 33e9448082..1080c1d806 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseObject; class BaseViewport : public BaseClass { public: @@ -50,6 +50,6 @@ private: Rect32 _rect; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 93533b4057..2f7450a999 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -37,7 +37,7 @@ #include "common/tokenizer.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { void correctSlashes(char *fileName) { for (size_t i = 0; i < strlen(fileName); i++) { @@ -196,4 +196,4 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 99a9e8b9a3..8be06199de 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -31,11 +31,11 @@ #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { Common::SeekableReadStream *openDiskFile(const Common::String &filename); bool diskFileExists(const Common::String &filename); -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 185a21ad57..f2a347ee0f 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/file/base_file.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -65,4 +65,4 @@ Common::SeekableReadStream *BaseFile::getMemStream() { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 0c1ab2a045..f9947fe64f 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -38,7 +38,7 @@ namespace Common { class SeekableReadStream; } -namespace WinterMute { +namespace Wintermute { class BaseFile { protected: @@ -62,6 +62,6 @@ public: virtual Common::SeekableReadStream *getMemStream(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index a08d55db43..82ddf7c90e 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -32,7 +32,7 @@ #include "common/substream.h" #include "common/zlib.h" -namespace WinterMute { +namespace Wintermute { Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); @@ -70,4 +70,4 @@ BaseFileEntry::~BaseFileEntry() { _package = NULL; // ref only } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index b94a6cd9fc..7e71a486ef 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -33,7 +33,7 @@ #include "common/str.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BasePackage; @@ -55,6 +55,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index ab74810d1d..a9fb7f9a68 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -34,7 +34,7 @@ #include "common/stream.h" #include "common/debug.h" -namespace WinterMute { +namespace Wintermute { BasePackage::BasePackage() { _name = ""; @@ -123,13 +123,13 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool TPackageHeader hdr; hdr.readFromStream(stream); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete stream; return; } if (hdr._packageVersion != PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } _priority = hdr._priority; // new in v2 @@ -181,7 +181,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool ((byte *)name)[k] ^= 'D'; } } - debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); + debugC(kWintermuteDebugFileAccess, "Package contains %s", name); Common::String upcName = name; upcName.toUppercase(); @@ -222,7 +222,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWintermuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); delete stream; } @@ -273,4 +273,4 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common:: return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index a562229f65..676675b041 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -33,7 +33,7 @@ #include "common/stream.h" #include "common/fs.h" -namespace WinterMute { +namespace Wintermute { class BasePackage { public: Common::SeekableReadStream *getFilePointer(); @@ -85,6 +85,6 @@ private: Common::HashMap::iterator _filesIter; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index aac5436071..a8bda164dc 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -30,7 +30,7 @@ #include "common/str.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { unsigned char invalid[] = { 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, @@ -2827,4 +2827,4 @@ bool BaseResources::hasFile(const Common::String &filename) { return false; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 2ccab6996f..596ac64dd7 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -32,7 +32,7 @@ #include "common/stream.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class BaseResources { public: @@ -40,6 +40,6 @@ public: static bool hasFile(const Common::String &filename); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 1f7288a6ff..515d8870d7 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -151,4 +151,4 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index d95958d95f..e68dc06904 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/file/base_file.h" -namespace WinterMute { +namespace Wintermute { //TODO: Get rid of this class BaseSaveThumbFile : public BaseFile { @@ -47,6 +47,6 @@ private: byte *_data; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index ccebc5909c..42c0b75e55 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -37,7 +37,7 @@ #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { struct TPackageHeader { uint32 _magic1; @@ -75,6 +75,6 @@ v2: uint32 TimeDate1 */ -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index fa9242366e..198b1ae308 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -204,4 +204,4 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { return ret; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index f1dc962565..e4413e3410 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -33,7 +33,7 @@ #define NUM_CHARACTERS 256 -namespace WinterMute { +namespace Wintermute { class BaseFont: public BaseObject { public: @@ -56,6 +56,6 @@ private: static bool isTrueType(BaseGame *game, const Common::String &filename); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 6585d7cb0a..0913ac9b53 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -586,4 +586,4 @@ int BaseFontBitmap::getLetterHeight() { return _tileHeight; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index fb992d2e9a..0b873855bb 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/font/base_font.h" -namespace WinterMute { +namespace Wintermute { class BaseSubFrame; class BaseFontBitmap : public BaseFont { public: @@ -66,6 +66,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 0c34a8822a..bc7ab6f22c 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -139,4 +139,4 @@ bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 3a39617c32..498096a5a8 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseFont; @@ -50,6 +50,6 @@ public: bool initLoop(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 4fa5ac08ce..ced279dcc8 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -43,7 +43,7 @@ #include "graphics/fontman.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseFontTT, false) @@ -198,7 +198,7 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, // not found, create one if (!surface) { - debugC(kWinterMuteDebugFont, "Draw text: %s", text); + debugC(kWintermuteDebugFont, "Draw text: %s", text); surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); if (surface) { // write surface to cache @@ -264,7 +264,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, alignment = Graphics::kTextAlignRight; } - debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); + debugC(kWintermuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); if (_deletableFont) { // We actually have a TTF @@ -602,4 +602,4 @@ void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight }*/ } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index a893e70ec0..fc4de30fc5 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -38,7 +38,7 @@ #define NUM_CACHED_TEXTS 30 -namespace WinterMute { +namespace Wintermute { class BaseFontTT : public BaseFont { private: @@ -147,6 +147,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index c1b6636237..ec52e26c00 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -38,7 +38,7 @@ #include "common/stream.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseImage::BaseImage() { @@ -69,7 +69,7 @@ bool BaseImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".tga")) { - _decoder = new WinterMute::TGA(); + _decoder = new Wintermute::TGA(); } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { @@ -228,4 +228,4 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 76a389977d..7bf901fe40 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -36,7 +36,7 @@ #include "common/str.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface; class BaseFileManager; class BaseImage { @@ -67,6 +67,6 @@ private: BaseFileManager *_fileManager; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 5d81c44c25..47a5462452 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { @@ -373,4 +373,4 @@ bool BaseRenderer::displayIndicator() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 49b5e187eb..aa8812254d 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -34,7 +34,7 @@ #include "common/rect.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseImage; class BaseActiveRect; @@ -215,6 +215,6 @@ private: BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 28ac4e6973..cbd665591a 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/base_surface.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { @@ -146,4 +146,4 @@ void BaseSurface::setSize(int width, int height) { _height = height; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 57a51ce3aa..3be61477ba 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -33,7 +33,7 @@ #include "engines/wintermute/math/rect32.h" #include "graphics/surface.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface: public BaseClass { public: @@ -94,6 +94,6 @@ protected: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ab4e690458..201c881122 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -38,7 +38,7 @@ #include "common/queue.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { @@ -602,4 +602,4 @@ BaseSurface *BaseRenderOSystem::createSurface() { return new BaseSurfaceOSystem(_gameRef); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 070ddf9241..5859fec74e 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -34,7 +34,7 @@ #include "graphics/surface.h" #include "common/list.h" -namespace WinterMute { +namespace Wintermute { class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; @@ -125,6 +125,6 @@ private: uint32 _clearColor; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 400bb1de41..5b0f7c94c3 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -43,7 +43,7 @@ #include "common/stream.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { @@ -426,4 +426,4 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index fe1d055026..27f9ad047e 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "common/list.h" -namespace WinterMute { +namespace Wintermute { struct TransparentSurface; class BaseImage; class BaseSurfaceOSystem : public BaseSurface { @@ -94,6 +94,6 @@ private: byte *_alphaMask; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index ced01b7fd9..d6006528a2 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -40,7 +40,7 @@ #include "common/str.h" #include "common/math.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(PartEmitter, false) @@ -1253,4 +1253,4 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 438dfff521..dd02cf7f17 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/particles/part_force.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion; class PartParticle; class PartEmitter : public BaseObject { @@ -135,6 +135,6 @@ private: BaseArray _sprites; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 7b2f117b4f..abbaa2819d 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/particles/part_force.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { @@ -62,4 +62,4 @@ bool PartForce::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h index ec79ab7238..6903a919e9 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/base_named_object.h" #include "engines/wintermute/math/vector2.h" -namespace WinterMute { +namespace Wintermute { class PartForce : public BaseNamedObject { public: @@ -52,6 +52,6 @@ public: bool persist(BasePersistenceManager *PersistMgr); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 1a449a50a5..9247514ac3 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { @@ -266,4 +266,4 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 44da85a559..3c8fc2c68b 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -34,7 +34,7 @@ #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/math/vector2.h" -namespace WinterMute { +namespace Wintermute { class PartEmitter; class BaseSprite; @@ -85,6 +85,6 @@ private: int _fadeStartAlpha; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index fe987c0b2a..06e9fd2565 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -40,7 +40,7 @@ #include "common/savefile.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { gameRef->LOG(0, "Loading game '%s'...", filename.c_str()); @@ -159,7 +159,7 @@ Common::String SaveLoad::getSaveSlotFilename(int slot) { BasePersistenceManager *pm = new BasePersistenceManager(); Common::String filename = pm->getFilenameForSlot(slot); delete pm; - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); + debugC(kWintermuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); return filename; } @@ -194,10 +194,10 @@ bool SaveLoad::isSaveSlotUsed(int slot) { bool SaveLoad::emptySaveSlot(int slot) { Common::String filename = getSaveSlotFilename(slot); BasePersistenceManager *pm = new BasePersistenceManager(); - ((WinterMuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + ((WintermuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h index 59cdceb038..e448cc8814 100644 --- a/engines/wintermute/base/saveload.h +++ b/engines/wintermute/base/saveload.h @@ -31,7 +31,7 @@ #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; class SaveLoad { public: @@ -52,6 +52,6 @@ private: static void afterLoadScript(void *script, void *data); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index 9610ebf94c..db63ad2b87 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_DCSCRIPT_H #define WINTERMUTE_DCSCRIPT_H -namespace WinterMute { +namespace Wintermute { #define SCRIPT_MAGIC 0xDEC0ADDE #define SCRIPT_VERSION 0x0102 @@ -136,6 +136,6 @@ typedef enum { ELEMENT_STRING = 0 } TElementType; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index fb77225700..6c8a88adb0 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScScript, false) @@ -1464,4 +1464,4 @@ void ScScript::afterLoad() { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 9f49fac994..132f1ce6c5 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseScriptHolder; class BaseObject; class ScEngine; @@ -169,6 +169,6 @@ public: virtual const char *dbgGetFilename(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index a1f246c4bc..8765fb9864 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScEngine, true) @@ -608,4 +608,4 @@ void ScEngine::dumpStats() { }*/ } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 9aae8be85b..f526353368 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { #define MAX_CACHED_SCRIPTS 20 class ScScript; @@ -130,6 +130,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index a422d6d8a5..c8d4f64ae9 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/system/sys_instance.h" #include "engines/wintermute/base/scriptables/script_ext_array.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXArray, false) @@ -249,4 +249,4 @@ bool SXArray::push(ScValue *val) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index f2718f4ea2..614f829950 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXArray : public BaseScriptable { public: @@ -51,6 +51,6 @@ private: Common::String _strRep; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 72f41c83cc..b5acc7d389 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_ext_date.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXDate, false) @@ -291,4 +291,4 @@ int SXDate::scCompare(BaseScriptable *Value) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 69fe1f1ae5..521b7a9f8a 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -32,7 +32,7 @@ #include "common/system.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXDate : public BaseScriptable { public: @@ -50,6 +50,6 @@ private: Common::String _strRep; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 50d89921e1..53d551119d 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -40,7 +40,7 @@ // Note: This code is completely untested, as I have yet to find a game that uses SXFile. -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXFile, false) @@ -826,4 +826,4 @@ Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool error("SXFile::openForAppend - WriteFiles not supported"); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index d083f96a4a..389974a48e 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_scriptable.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BaseFile; @@ -61,6 +61,6 @@ private: Common::WriteStream *openForAppend(const Common::String &filename, bool binary); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 6b80da6389..906d807275 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -33,7 +33,7 @@ #include "common/math.h" #include -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -292,4 +292,4 @@ bool SXMath::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index 393342e5ca..b195c0785d 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXMath : public BaseScriptable { public: @@ -48,6 +48,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 557d9b9b57..eef1931d8b 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXMemBuffer, false) @@ -526,4 +526,4 @@ int SXMemBuffer::scCompare(BaseScriptable *val) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index b5428b4bd9..0a16167b58 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXMemBuffer : public BaseScriptable { public: @@ -55,6 +55,6 @@ private: bool checkBounds(ScScript *script, int start, int length); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index ab7296b1ce..40c9b885cd 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -64,4 +64,4 @@ bool SXObject::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index f7d3a7bc0f..32aa00776e 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class SXObject : public BaseObject { public: @@ -41,6 +41,6 @@ public: virtual ~SXObject(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index adbf16611c..9bcfe28bbf 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/utils/string_util.h" #include "common/tokenizer.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXString, false) @@ -433,4 +433,4 @@ int SXString::scCompare(BaseScriptable *val) { return strcmp(_string, ((SXString *)val)->_string); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 9a3bbfc80b..c2de3860ed 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXString : public BaseScriptable { public: @@ -53,6 +53,6 @@ private: int _capacity; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 9b3a0201ac..7e81cdaf17 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScStack, false) @@ -229,4 +229,4 @@ bool ScStack::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 95839cc680..0e2adae518 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -34,7 +34,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/persistent.h" -namespace WinterMute { +namespace Wintermute { class ScValue; class BaseScriptable; @@ -61,6 +61,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index d35f85f9a1..03ca69ac7e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -992,4 +992,4 @@ bool ScValue::setProperty(const char *propName) { return ret; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index c8d04168b3..af31014bac 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -35,7 +35,7 @@ #include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class ScScript; class BaseScriptable; @@ -108,6 +108,6 @@ public: bool setProperty(const char *propName); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 7e32552d08..aac68baccd 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/sound/base_sound_buffer.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSound, false) @@ -289,4 +289,4 @@ bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index cadba77bc8..fcc463ed06 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "audio/mixer.h" -namespace WinterMute { +namespace Wintermute { class BaseSoundBuffer; class BaseSound : public BaseClass { @@ -82,6 +82,6 @@ private: BaseSoundBuffer *_sound; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index ac329704bc..14bbcd9421 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -41,7 +41,7 @@ #include "common/system.h" #include "common/substream.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -93,7 +93,7 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { - debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); + debugC(kWintermuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); @@ -290,4 +290,4 @@ bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float p return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 7aec144283..3ec4d4d28b 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -39,7 +39,7 @@ class SeekableAudioStream; class SoundHandle; } -namespace WinterMute { +namespace Wintermute { class BaseFile; class BaseSoundBuffer : public BaseClass { @@ -95,6 +95,6 @@ private: int _volume; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 95b7d040ab..2bfe0499f9 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -37,7 +37,7 @@ #include "common/config-manager.h" #include "audio/mixer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -279,4 +279,4 @@ float BaseSoundMgr::posToPan(int x, int y) { return minPan + relPos * (maxPan - minPan); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index a2b8f2c9e9..a0b9a4bc4b 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -34,7 +34,7 @@ #include "audio/mixer.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseSoundBuffer; class BaseSoundMgr : public BaseClass { public: @@ -63,6 +63,6 @@ public: void saveSettings(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 51a4120c15..96daaf62ee 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -32,7 +32,7 @@ #include "common/array.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { // Basically Common::Array with peristence-support. template @@ -88,6 +88,6 @@ public: } }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // COLL_TEMPL_H diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index edca18a6ed..9cad244255 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -34,7 +34,7 @@ #include "common/list.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { //typedef std::string AnsiString; //typedef std::string Utf8String; @@ -221,6 +221,6 @@ enum TShadowType { SHADOW_STENCIL = 3 }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // DCTYPES_H diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index b3f210d67a..7e4da68a93 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -33,10 +33,10 @@ #include "engines/wintermute/detection_tables.h" -namespace WinterMute { +namespace Wintermute { /** - * The fallback game descriptor used by the WinterMute engine's fallbackDetector. + * The fallback game descriptor used by the Wintermute engine's fallbackDetector. * Contents of this struct are overwritten by the fallbackDetector. (logic copied partially * from the SCI-engine). */ @@ -51,9 +51,9 @@ static ADGameDescription s_fallbackDesc = { }; static char s_fallbackGameIdBuf[256]; -class WinterMuteMetaEngine : public AdvancedMetaEngine { +class WintermuteMetaEngine : public AdvancedMetaEngine { public: - WinterMuteMetaEngine() : AdvancedMetaEngine(WinterMute::gameDescriptions, sizeof(ADGameDescription), WinterMute::wintermuteGames) { + WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(ADGameDescription), Wintermute::wintermuteGames) { _singleid = "wintermute"; } virtual const char *getName() const { @@ -95,7 +95,7 @@ public: if (0 == scumm_stricmp("data.dcp", gameName)) { // You could check the contents of the file now if you need to. - detectedGames.push_back(WinterMute_setting[0]); + detectedGames.push_back(Wintermute_setting[0]); break; } } @@ -115,7 +115,7 @@ public: if (allFiles.contains("data.dcp")) { Common::String name, caption; - if (WinterMuteEngine::getGameInfo(fslist, name, caption)) { + if (WintermuteEngine::getGameInfo(fslist, name, caption)) { for (uint32 i = 0; i < name.size(); i++) { // Replace spaces (and other non-alphanumerics) with underscores if (!Common::isAlnum(name[(int32)i])) { @@ -144,7 +144,7 @@ public: assert(syst); assert(engine); - *engine = new WinterMute::WinterMuteEngine(syst, desc); + *engine = new Wintermute::WintermuteEngine(syst, desc); return true; } @@ -169,7 +169,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::BasePersistenceManager pm(target, true); + Wintermute::BasePersistenceManager pm(target, true); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -185,12 +185,12 @@ public: } void removeSaveState(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(target, true); + Wintermute::BasePersistenceManager pm(target, true); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::BasePersistenceManager pm(target, true); + Wintermute::BasePersistenceManager pm(target, true); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); @@ -198,10 +198,10 @@ public: } }; -} // end of namespace WinterMute +} // end of namespace Wintermute #if PLUGIN_ENABLED_DYNAMIC(WINTERMUTE) -REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMute::WinterMuteMetaEngine); +REGISTER_PLUGIN_DYNAMIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, Wintermute::WintermuteMetaEngine); #else -REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, WinterMute::WinterMuteMetaEngine); +REGISTER_PLUGIN_STATIC(WINTERMUTE, PLUGIN_TYPE_ENGINE, Wintermute::WintermuteMetaEngine); #endif diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index 272daea2d9..2e7def0d77 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -20,7 +20,7 @@ * */ -namespace WinterMute { +namespace Wintermute { static const PlainGameDescriptor wintermuteGames[] = { {"5ld", "Five Lethal Demons"}, @@ -230,4 +230,4 @@ static const ADGameDescription gameDescriptions[] = { AD_TABLE_END_MARKER }; -} // End of namespace WinterMute +} // End of namespace Wintermute diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp index 1bf4383ccf..8c3868c023 100644 --- a/engines/wintermute/graphics/tga.cpp +++ b/engines/wintermute/graphics/tga.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/graphics/tga.h" -namespace WinterMute { +namespace Wintermute { TGA::TGA() { diff --git a/engines/wintermute/graphics/tga.h b/engines/wintermute/graphics/tga.h index b3b46fb529..5e118f2338 100644 --- a/engines/wintermute/graphics/tga.h +++ b/engines/wintermute/graphics/tga.h @@ -33,7 +33,7 @@ namespace Common { class SeekableReadStream; } -namespace WinterMute { +namespace Wintermute { /** TarGa image. */ class TGA : public Graphics::ImageDecoder { diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 982399976b..47e3591d4d 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -27,7 +27,7 @@ #include "graphics/primitives.h" #include "engines/wintermute/graphics/transparent_surface.h" -namespace WinterMute { +namespace Wintermute { byte *TransparentSurface::_lookup = NULL; diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index d9fe00a6d9..8b00dccbd9 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -37,7 +37,7 @@ #define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B)) #define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B)) -namespace WinterMute { +namespace Wintermute { /** * A transparent graphics surface, which implements alpha blitting. diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index ef5b676662..4a308a914e 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/math/math_util.h" #include -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// float MathUtil::round(float val) { @@ -49,4 +49,4 @@ float MathUtil::roundUp(float val) { return result; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h index 258d9bd67b..506317a2b0 100644 --- a/engines/wintermute/math/math_util.h +++ b/engines/wintermute/math/math_util.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_MATHUTIL_H #define WINTERMUTE_MATHUTIL_H -namespace WinterMute { +namespace Wintermute { class MathUtil { public: @@ -37,6 +37,6 @@ public: static float roundUp(float val); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp index 379c219ec3..e38833d094 100644 --- a/engines/wintermute/math/matrix4.cpp +++ b/engines/wintermute/math/matrix4.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/math/vector2.h" #include -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// Matrix4::Matrix4() { @@ -83,4 +83,4 @@ void Matrix4::transformVector2(Vector2 &vec) { vec.y = y; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h index 4f65fe5779..5891b4c5ec 100644 --- a/engines/wintermute/math/matrix4.h +++ b/engines/wintermute/math/matrix4.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_MATRIX4_H #define WINTERMUTE_MATRIX4_H -namespace WinterMute { +namespace Wintermute { class Vector2; @@ -54,6 +54,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index 428d49290c..51a1be15e4 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -25,7 +25,7 @@ #include "common/system.h" -namespace WinterMute { +namespace Wintermute { struct Point32 { int32 x; @@ -89,6 +89,6 @@ struct Rect32 { } }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp index ecf2f1e8e4..40c2b346d7 100644 --- a/engines/wintermute/math/vector2.cpp +++ b/engines/wintermute/math/vector2.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/math/vector2.h" #include -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// Vector2::Vector2() { @@ -52,4 +52,4 @@ float Vector2::length() const { return (float)sqrt(x * x + y * y); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h index ca4f499794..ce7ebd331e 100644 --- a/engines/wintermute/math/vector2.h +++ b/engines/wintermute/math/vector2.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_VECTOR2_H #define WINTERMUTE_VECTOR2_H -namespace WinterMute { +namespace Wintermute { class Vector2 { public: @@ -70,6 +70,6 @@ public: float y; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp index fc1531ab9b..514fd61d34 100644 --- a/engines/wintermute/persistent.cpp +++ b/engines/wintermute/persistent.cpp @@ -91,9 +91,9 @@ // SystemClass adds these objects to the registry, thus they aren't as leaked as they look #define REGISTER_CLASS(class_name, persistent_class)\ - new WinterMute::SystemClass(class_name::_className, class_name::persistBuild, class_name::persistLoad, persistent_class); + new Wintermute::SystemClass(class_name::_className, class_name::persistBuild, class_name::persistLoad, persistent_class); -namespace WinterMute { +namespace Wintermute { // This is done in a separate file, to avoid including the kitchensink in SystemClassRegistry. void SystemClassRegistry::registerClasses() { diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 0df2f8420b..54b13e8ffe 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_PERSISTENT_H #define WINTERMUTE_PERSISTENT_H -namespace WinterMute { +namespace Wintermute { class BasePersistenceManager; @@ -37,10 +37,10 @@ class BasePersistenceManager; typedef void *(*PERSISTBUILD)(void); typedef bool(*PERSISTLOAD)(void *, BasePersistenceManager *); typedef void (*SYS_INSTANCE_CALLBACK)(void *Instance, void *Data); -} // end of namespace WinterMute +} // end of namespace Wintermute #include "engines/wintermute/system/sys_class_registry.h" -namespace WinterMute { +namespace Wintermute { #define DECLARE_PERSISTENT(class_name, parent_class)\ @@ -84,6 +84,6 @@ namespace WinterMute { #define TMEMBER(member_name) #member_name, &member_name #define TMEMBER_INT(member_name) #member_name, (int*)&member_name -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_PERSISTENT_H diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp index a1220cfa45..c50645df95 100644 --- a/engines/wintermute/platform_osystem.cpp +++ b/engines/wintermute/platform_osystem.cpp @@ -33,7 +33,7 @@ #include "common/textconsole.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { BaseGame *BasePlatform::_gameRef = NULL; @@ -259,4 +259,4 @@ char *BasePlatform::strlwr(char *string) { return string; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h index ffc9933635..9f281c89cd 100644 --- a/engines/wintermute/platform_osystem.h +++ b/engines/wintermute/platform_osystem.h @@ -33,7 +33,7 @@ #include "engines/wintermute/math/rect32.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; @@ -64,10 +64,10 @@ public: static char *strlwr(char *string); private: - // Set by initialize on game-startup, the object referred to is also deleted by deinit in WinterMuteEngine + // Set by initialize on game-startup, the object referred to is also deleted by deinit in WintermuteEngine static BaseGame *_gameRef; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/system/sys_class.cpp b/engines/wintermute/system/sys_class.cpp index ce06e8980e..bce9a04aec 100644 --- a/engines/wintermute/system/sys_class.cpp +++ b/engines/wintermute/system/sys_class.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// SystemClass::SystemClass(const AnsiString &name, PERSISTBUILD build, PERSISTLOAD load, bool persistentClass) { @@ -217,4 +217,4 @@ void SystemClass::instanceCallback(SYS_INSTANCE_CALLBACK lpCallback, void *lpDat } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/system/sys_class.h b/engines/wintermute/system/sys_class.h index 36968e1cc2..28d718bb47 100644 --- a/engines/wintermute/system/sys_class.h +++ b/engines/wintermute/system/sys_class.h @@ -35,7 +35,7 @@ #include "common/func.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class SystemInstance; class BaseGame; class BasePersistenceManager; @@ -52,8 +52,8 @@ template<> struct Hash : public UnaryFunction { } }; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::SystemInstance *val) const { +template<> struct Hash : public UnaryFunction { + uint operator()(Wintermute::SystemInstance *val) const { return (uint)((size_t)val); } }; @@ -61,7 +61,7 @@ template<> struct Hash : public UnaryFunctiongetNumInstances() != 0) { - debugC(WinterMute::kWinterMuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); + debugC(Wintermute::kWintermuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances()); } _classes.erase(it); @@ -332,4 +332,4 @@ void SystemClassRegistry::dumpClasses(Common::WriteStream *stream) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/system/sys_class_registry.h b/engines/wintermute/system/sys_class_registry.h index 65d4fe1f02..e612ab3e82 100644 --- a/engines/wintermute/system/sys_class_registry.h +++ b/engines/wintermute/system/sys_class_registry.h @@ -37,21 +37,21 @@ #include "common/func.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class SystemClass; } namespace Common { template struct Hash; -template<> struct Hash : public UnaryFunction { - uint operator()(WinterMute::SystemClass *val) const { +template<> struct Hash : public UnaryFunction { + uint operator()(Wintermute::SystemClass *val) const { return (uint)((size_t)val); } }; } -namespace WinterMute { +namespace Wintermute { class BaseGame; class BasePersistenceManager; @@ -101,6 +101,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/system/sys_instance.cpp b/engines/wintermute/system/sys_instance.cpp index a5ef69647c..1323382152 100644 --- a/engines/wintermute/system/sys_instance.cpp +++ b/engines/wintermute/system/sys_instance.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/system/sys_class_registry.h" #include "engines/wintermute/system/sys_class.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// SystemInstance::SystemInstance(void *instance, int id, SystemClass *sysClass) { @@ -46,4 +46,4 @@ SystemInstance::SystemInstance(void *instance, int id, SystemClass *sysClass) { SystemInstance::~SystemInstance() { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/system/sys_instance.h b/engines/wintermute/system/sys_instance.h index 90336742f8..78eb27c122 100644 --- a/engines/wintermute/system/sys_instance.h +++ b/engines/wintermute/system/sys_instance.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_SYSINSTANCE_H #define WINTERMUTE_SYSINSTANCE_H -namespace WinterMute { +namespace Wintermute { class SystemClass; @@ -63,6 +63,6 @@ private: SystemClass *_class; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index fb125ef94c..d13ad235bc 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -41,7 +41,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIButton, false) @@ -1205,4 +1205,4 @@ bool UIButton::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 5c034d6113..61cdef476e 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -33,7 +33,7 @@ #include "engines/wintermute/ui/ui_object.h" #include "engines/wintermute/dctypes.h" // Added by ClassView -namespace WinterMute { +namespace Wintermute { class UIButton : public UIObject { public: @@ -74,6 +74,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 88c68a3314..23c783d200 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -47,7 +47,7 @@ #include "common/util.h" #include "common/keyboard.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIEdit, false) @@ -948,4 +948,4 @@ bool UIEdit::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index 221b8aa151..ea943e3d57 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -33,7 +33,7 @@ #include "engines/wintermute/ui/ui_object.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseFont; class UIEdit : public UIObject { public: @@ -67,6 +67,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 8008e96050..038b256c24 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIEntity, false) @@ -363,4 +363,4 @@ bool UIEntity::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index 9c9bffdc4a..bc44c1f112 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -31,7 +31,7 @@ #include "engines/wintermute/ui/ui_object.h" -namespace WinterMute { +namespace Wintermute { class AdEntity; class UIEntity : public UIObject { public: @@ -53,6 +53,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 8f1356020e..31f1b9aa33 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/font/base_font_storage.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIObject, false) @@ -647,4 +647,4 @@ bool UIObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_FAILED; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 50d0a08873..8059207a9a 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/dctypes.h" // Added by ClassView -namespace WinterMute { +namespace Wintermute { class UITiledImage; class BaseFont; @@ -79,6 +79,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 56fea4edf9..038df55c42 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -41,7 +41,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIText, false) @@ -519,4 +519,4 @@ bool UIText::sizeToFit() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index ee2e63c448..54817ccf52 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -32,7 +32,7 @@ #include "engines/wintermute/ui/ui_object.h" -namespace WinterMute { +namespace Wintermute { class UIText : public UIObject { private: @@ -55,6 +55,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 62c07bf1d7..0cf28b81f5 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UITiledImage, false) @@ -390,4 +390,4 @@ bool UITiledImage::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_tiled_image.h b/engines/wintermute/ui/ui_tiled_image.h index 2d7068e7cd..863bf7d1ea 100644 --- a/engines/wintermute/ui/ui_tiled_image.h +++ b/engines/wintermute/ui/ui_tiled_image.h @@ -33,7 +33,7 @@ #include "engines/wintermute/ui/ui_object.h" #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { class BaseSubFrame; class UITiledImage : public BaseObject { public: @@ -58,6 +58,6 @@ public: Rect32 _downRight; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 4f3ee9ff43..d33de9881c 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -47,7 +47,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(UIWindow, false) @@ -1441,4 +1441,4 @@ bool UIWindow::getWindowObjects(BaseArray &objects, bool interactive return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index 556850f6fa..8093e2b8f4 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -33,7 +33,7 @@ #include "engines/wintermute/ui/ui_object.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class UIButton; class BaseViewport; @@ -89,6 +89,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/utils/crc.cpp b/engines/wintermute/utils/crc.cpp index c127d08417..8f608600f3 100644 --- a/engines/wintermute/utils/crc.cpp +++ b/engines/wintermute/utils/crc.cpp @@ -17,7 +17,7 @@ #include "engines/wintermute/utils/crc.h" -namespace WinterMute { +namespace Wintermute { /* * Derive parameters from the standard-specific parameters in crc.h. @@ -234,4 +234,4 @@ crc crc_finalize(crc remainder) { return (REFLECT_REMAINDER(remainder) ^ FINAL_XOR_VALUE); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/crc.h b/engines/wintermute/utils/crc.h index 363340531d..9b9446ce57 100644 --- a/engines/wintermute/utils/crc.h +++ b/engines/wintermute/utils/crc.h @@ -18,7 +18,7 @@ #include "common/system.h" // For types. -namespace WinterMute { +namespace Wintermute { #ifndef TRUE #define FALSE 0 @@ -80,6 +80,6 @@ extern "C" crc crc_initialize(void); extern "C" crc crc_process_byte(unsigned char byteVal, crc remainder); extern "C" crc crc_finalize(crc remainder); -} // End of namespace WinterMute +} // End of namespace Wintermute #endif /* _crc_h */ diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp index dcf35be776..55bf776848 100644 --- a/engines/wintermute/utils/path_util.cpp +++ b/engines/wintermute/utils/path_util.cpp @@ -29,7 +29,7 @@ #include "common/file.h" #include "engines/wintermute/utils/path_util.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// AnsiString PathUtil::unifySeparators(const AnsiString &path) { @@ -98,4 +98,4 @@ AnsiString PathUtil::getExtension(const AnsiString &path) { return Common::lastPathComponent(path, '.'); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index f63c15dcd1..ed8f3e91e8 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -31,7 +31,7 @@ #include "engines/wintermute/dctypes.h" -namespace WinterMute { +namespace Wintermute { class PathUtil { public: @@ -44,6 +44,6 @@ public: static AnsiString getExtension(const AnsiString &path); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_PATHUTILS_H diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index ed1d2094d2..63793f7d0b 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/convert_utf.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { @@ -229,4 +229,4 @@ AnsiString StringUtil::toString(int val) { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h index 582007917d..581ffc2ed4 100644 --- a/engines/wintermute/utils/string_util.h +++ b/engines/wintermute/utils/string_util.h @@ -31,7 +31,7 @@ #include "engines/wintermute/dctypes.h" -namespace WinterMute { +namespace Wintermute { class StringUtil { public: @@ -51,6 +51,6 @@ public: static AnsiString toString(int val); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_STRINGUTIL_H diff --git a/engines/wintermute/utils/utils.cpp b/engines/wintermute/utils/utils.cpp index 4546750c61..f26d60b7cf 100644 --- a/engines/wintermute/utils/utils.cpp +++ b/engines/wintermute/utils/utils.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/wintermute.h" #include "engines/wintermute/base/base_engine.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// static inline unsigned Sqr(int x) { @@ -258,4 +258,4 @@ float BaseUtils::Hue2RGB(float v1, float v2, float vH) { return (v1); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/utils/utils.h b/engines/wintermute/utils/utils.h index 36a7398869..af69bd4523 100644 --- a/engines/wintermute/utils/utils.h +++ b/engines/wintermute/utils/utils.h @@ -32,7 +32,7 @@ #include "engines/wintermute/wintypes.h" #include "engines/wintermute/math/rect32.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; @@ -59,6 +59,6 @@ private: static float Hue2RGB(float v1, float v2, float vH); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/video/decoders/theora_decoder.cpp b/engines/wintermute/video/decoders/theora_decoder.cpp index a8e403c97c..6267e300f9 100644 --- a/engines/wintermute/video/decoders/theora_decoder.cpp +++ b/engines/wintermute/video/decoders/theora_decoder.cpp @@ -45,7 +45,7 @@ #include "common/stream.h" #include "common/debug.h" -namespace WinterMute { +namespace Wintermute { #define AUDIOFD_FRAGSIZE 10240 diff --git a/engines/wintermute/video/decoders/theora_decoder.h b/engines/wintermute/video/decoders/theora_decoder.h index 3844434036..fd94f52142 100644 --- a/engines/wintermute/video/decoders/theora_decoder.h +++ b/engines/wintermute/video/decoders/theora_decoder.h @@ -41,7 +41,7 @@ namespace Common { class SeekableReadStream; } -namespace WinterMute { +namespace Wintermute { /** * diff --git a/engines/wintermute/video/video_player.cpp b/engines/wintermute/video/video_player.cpp index a3eedaa293..2577b8aedc 100644 --- a/engines/wintermute/video/video_player.cpp +++ b/engines/wintermute/video/video_player.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/video/video_player.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -106,4 +106,4 @@ bool VideoPlayer::loadSubtitles(const char *filename, const char *subtitleFile) return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/video/video_player.h b/engines/wintermute/video/video_player.h index 190223c6d1..d5466da679 100644 --- a/engines/wintermute/video/video_player.h +++ b/engines/wintermute/video/video_player.h @@ -36,7 +36,7 @@ #define MAX_VIDEO_STREAMS 5 -namespace WinterMute { +namespace Wintermute { // AVI-Video-player, currently fully stubbed class VideoPlayer : public BaseClass { @@ -85,6 +85,6 @@ public: BaseArray _subtitles;*/ }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index fea81bdf9d..f75c7ba5b6 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -39,7 +39,7 @@ #include "engines/wintermute/wintermute.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(VideoTheoraPlayer, false) @@ -272,7 +272,7 @@ bool VideoTheoraPlayer::update() { warning("Should loop movie %s", _filename.c_str()); _theoraDecoder->rewind(); } else if (_theoraDecoder->endOfVideo() && !_looping) { - debugC(kWinterMuteDebugLog, "Finished movie %s", _filename.c_str()); + debugC(kWintermuteDebugLog, "Finished movie %s", _filename.c_str()); _state = THEORA_STATE_FINISHED; _playbackStarted = false; if (_freezeGame) { @@ -497,4 +497,4 @@ BaseSurface *VideoTheoraPlayer::getTexture() { return _texture; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index fe71ae0f35..cd358381f1 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -35,7 +35,7 @@ #include "common/stream.h" #include "graphics/surface.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface; class BaseImage; class VideoTheoraPlayer : public BaseClass { @@ -144,6 +144,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 186d80d446..6008a92c26 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -41,15 +41,15 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/scriptables/script_engine.h" -namespace WinterMute { +namespace Wintermute { // Simple constructor for detection - we need to setup the persistence to avoid special-casing in-engine // This might not be the prettiest solution -WinterMuteEngine::WinterMuteEngine() : Engine(g_system) { +WintermuteEngine::WintermuteEngine() : Engine(g_system) { _game = new AdGame(""); } -WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) +WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _gameDescription(desc) { // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you @@ -62,17 +62,17 @@ WinterMuteEngine::WinterMuteEngine(OSystem *syst, const ADGameDescription *desc) //SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); // Here is the right place to set up the engine specific debug channels - DebugMan.addDebugChannel(kWinterMuteDebugLog, "enginelog", "Covers the same output as the log-file in WME"); - DebugMan.addDebugChannel(kWinterMuteDebugSaveGame, "savegame", "Savegames"); - DebugMan.addDebugChannel(kWinterMuteDebugFont, "font", "Text-drawing-related messages"); - DebugMan.addDebugChannel(kWinterMuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); - DebugMan.addDebugChannel(kWinterMuteDebugAudio, "audio", "audio-playback-related issues"); - DebugMan.addDebugChannel(kWinterMuteDebugGeneral, "general", "various issues not covered by any of the above"); + DebugMan.addDebugChannel(kWintermuteDebugLog, "enginelog", "Covers the same output as the log-file in WME"); + DebugMan.addDebugChannel(kWintermuteDebugSaveGame, "savegame", "Savegames"); + DebugMan.addDebugChannel(kWintermuteDebugFont, "font", "Text-drawing-related messages"); + DebugMan.addDebugChannel(kWintermuteDebugFileAccess, "file-access", "Non-critical problems like missing files"); + DebugMan.addDebugChannel(kWintermuteDebugAudio, "audio", "audio-playback-related issues"); + DebugMan.addDebugChannel(kWintermuteDebugGeneral, "general", "various issues not covered by any of the above"); _game = NULL; } -WinterMuteEngine::~WinterMuteEngine() { +WintermuteEngine::~WintermuteEngine() { // Dispose your resources here deinit(); delete _game; @@ -82,7 +82,7 @@ WinterMuteEngine::~WinterMuteEngine() { DebugMan.clearAllDebugChannels(); } -bool WinterMuteEngine::hasFeature(EngineFeature f) const { +bool WintermuteEngine::hasFeature(EngineFeature f) const { switch (f) { case kSupportsRTL: return true; @@ -96,7 +96,7 @@ bool WinterMuteEngine::hasFeature(EngineFeature f) const { return false; } -Common::Error WinterMuteEngine::run() { +Common::Error WintermuteEngine::run() { // Initialize graphics using following: Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); initGraphics(800, 600, true, &format); @@ -108,16 +108,16 @@ Common::Error WinterMuteEngine::run() { _console = new Console(this); // DebugMan.enableDebugChannel("enginelog"); - debugC(1, kWinterMuteDebugLog, "Engine Debug-LOG enabled"); - debugC(2, kWinterMuteDebugSaveGame , "Savegame debugging-enabled"); + debugC(1, kWintermuteDebugLog, "Engine Debug-LOG enabled"); + debugC(2, kWintermuteDebugSaveGame , "Savegame debugging-enabled"); int ret = 1; // Additional setup. - debugC(kWinterMuteDebugLog, "WinterMuteEngine::init"); + debugC(kWintermuteDebugLog, "WintermuteEngine::init"); ret = init(); - debugC(kWinterMuteDebugLog, "WinterMuteEngine::messageLoop"); + debugC(kWintermuteDebugLog, "WintermuteEngine::messageLoop"); if (ret == 0) { ret = messageLoop(); } @@ -125,7 +125,7 @@ Common::Error WinterMuteEngine::run() { return Common::kNoError; } -int WinterMuteEngine::init() { +int WintermuteEngine::init() { BaseEngine::createInstance(_targetName); _game = new AdGame(_targetName); if (!_game) { @@ -221,7 +221,7 @@ int WinterMuteEngine::init() { return 0; } -int WinterMuteEngine::messageLoop() { +int WintermuteEngine::messageLoop() { bool done = false; uint32 prevTime = _system->getMillis(); @@ -269,29 +269,29 @@ int WinterMuteEngine::messageLoop() { return 0; } -void WinterMuteEngine::deinit() { +void WintermuteEngine::deinit() { BaseEngine::destroy(); } -Common::Error WinterMuteEngine::loadGameState(int slot) { +Common::Error WintermuteEngine::loadGameState(int slot) { BaseEngine::instance().getGameRef()->loadGame(slot); return Common::kNoError; } -Common::Error WinterMuteEngine::saveGameState(int slot, const Common::String &desc) { +Common::Error WintermuteEngine::saveGameState(int slot, const Common::String &desc) { BaseEngine::instance().getGameRef()->saveGame(slot, desc.c_str(), false); return Common::kNoError; } -bool WinterMuteEngine::canSaveGameStateCurrently() { +bool WintermuteEngine::canSaveGameStateCurrently() { return true; } -bool WinterMuteEngine::canLoadGameStateCurrently() { +bool WintermuteEngine::canLoadGameStateCurrently() { return true; } -bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { +bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) { bool retVal = false; caption = name = "(invalid)"; Common::SeekableReadStream *stream = NULL; @@ -379,4 +379,4 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String return retVal; } -} // End of namespace WinterMute +} // End of namespace Wintermute diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 8607c50e25..730a4e8358 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -27,26 +27,26 @@ #include "engines/advancedDetector.h" #include "gui/debugger.h" -namespace WinterMute { +namespace Wintermute { class Console; class BaseGame; class SystemClassRegistry; // our engine debug channels enum { - kWinterMuteDebugLog = 1 << 0, // The debug-logs from the original engine - kWinterMuteDebugSaveGame = 1 << 1, - kWinterMuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) - kWinterMuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) - kWinterMuteDebugAudio = 1 << 4, - kWinterMuteDebugGeneral = 1 << 5 + kWintermuteDebugLog = 1 << 0, // The debug-logs from the original engine + kWintermuteDebugSaveGame = 1 << 1, + kWintermuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) + kWintermuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) + kWintermuteDebugAudio = 1 << 4, + kWintermuteDebugGeneral = 1 << 5 }; -class WinterMuteEngine : public Engine { +class WintermuteEngine : public Engine { public: - WinterMuteEngine(OSystem *syst, const ADGameDescription *desc); - WinterMuteEngine(); - ~WinterMuteEngine(); + WintermuteEngine(OSystem *syst, const ADGameDescription *desc); + WintermuteEngine(); + ~WintermuteEngine(); virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; @@ -69,7 +69,7 @@ private: // Example console class class Console : public GUI::Debugger { public: - Console(WinterMuteEngine *vm) {} + Console(WintermuteEngine *vm) {} virtual ~Console(void) {} }; diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 4b2fc5bada..7a84dd2810 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -31,7 +31,7 @@ #include "common/scummsys.h" -namespace WinterMute { +namespace Wintermute { #define BYTETORGBA(r,g,b,a) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) @@ -48,6 +48,6 @@ namespace WinterMute { #define MAX_PATH_LENGTH 512 -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_WINTYPES_H -- cgit v1.2.3 From a3703506919a67173b3447115cdc85c0f1711ed6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 03:54:34 +0200 Subject: WINTERMUTE: Readd support for save/load-images. --- engines/wintermute/base/gfx/base_renderer.cpp | 6 +++++- engines/wintermute/base/gfx/base_renderer.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 47a5462452..9e271fc32d 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -58,6 +58,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _saveImageName = ""; _saveLoadImage = NULL; _loadInProgress = false; + _hasDrawnSaveLoadImage = false; _saveImageX = _saveImageY = 0; _loadImageX = _loadImageY = 0; @@ -127,6 +128,7 @@ void BaseRenderer::setSaveImage(const char *filename, int x, int y) { void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; + _hasDrawnSaveLoadImage = false; if (isSaving && !quickSave) { delete _saveLoadImage; @@ -346,7 +348,7 @@ bool BaseRenderer::displayIndicator() { if (!_indicatorDisplay || !_indicatorProgress) { return STATUS_OK; } - if (_saveLoadImage) { + if (_saveLoadImage && !_hasDrawnSaveLoadImage) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) { @@ -354,6 +356,8 @@ bool BaseRenderer::displayIndicator() { } else { _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } + flip(); + _hasDrawnSaveLoadImage = true; } if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index aa8812254d..1b284b044d 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -192,6 +192,7 @@ protected: int _loadImageX; int _loadImageY; BaseSurface *_saveLoadImage; + bool _hasDrawnSaveLoadImage; int _indicatorWidthDrawn; uint32 _indicatorColor; -- cgit v1.2.3 From 101ad689c5063e3eb91a2255ba154348069b14ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 04:37:07 +0200 Subject: WINTERMUTE: Add language-filtering for Czech, Italian, Polish and Russian. No detection-support is added for those languages at this point though. --- engines/wintermute/base/base_engine.cpp | 8 ++++---- engines/wintermute/base/base_engine.h | 5 +++-- engines/wintermute/base/base_file_manager.cpp | 15 ++++++++++++--- engines/wintermute/base/base_file_manager.h | 4 +++- engines/wintermute/wintermute.cpp | 4 ++-- 5 files changed, 24 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 3447407866..2368f8b106 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -46,8 +46,8 @@ BaseEngine::BaseEngine() { _gameId = ""; } -void BaseEngine::init() { - _fileManager = new BaseFileManager(); +void BaseEngine::init(Common::Language lang) { + _fileManager = new BaseFileManager(lang); // Don't forget to register your random source _rnd = new Common::RandomSource("Wintermute"); _classReg = new SystemClassRegistry(); @@ -60,9 +60,9 @@ BaseEngine::~BaseEngine() { delete _classReg; } -void BaseEngine::createInstance(const Common::String &gameid) { +void BaseEngine::createInstance(const Common::String &gameid, Common::Language lang) { instance()._gameId = gameid; - instance().init(); + instance().init(lang); } void BaseEngine::LOG(bool res, const char *fmt, ...) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 32007ef571..1cef7b33ba 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -32,6 +32,7 @@ #include "common/str.h" #include "common/singleton.h" #include "common/random.h" +#include "common/language.h" namespace Wintermute { @@ -40,7 +41,7 @@ class BaseRegistry; class BaseGame; class SystemClassRegistry; class BaseEngine : public Common::Singleton { - void init(); + void init(Common::Language lang); BaseFileManager *_fileManager; Common::String _gameId; BaseGame *_gameRef; @@ -50,7 +51,7 @@ class BaseEngine : public Common::Singleton { public: BaseEngine(); ~BaseEngine(); - static void createInstance(const Common::String &gameid); + static void createInstance(const Common::String &gameid, Common::Language lang); void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } Common::RandomSource *getRandomSource() { return _rnd; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f7a3b6a3fb..01b11352b5 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -53,7 +53,8 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager() { +BaseFileManager::BaseFileManager(Common::Language lang) { + _language = lang; initPaths(); registerPackages(); } @@ -191,10 +192,18 @@ bool BaseFileManager::registerPackages() { } // Avoid registering all the language files // TODO: Select based on the gameDesc. - if (fileIt->getParent().getName() == "language") { + if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { Common::String parentName = fileIt->getParent().getName(); Common::String dcpName = fileIt->getName(); - if (fileIt->getName() != "english.dcp") { + if (_language == Common::EN_ANY && fileIt->getName() != "english.dcp") { + continue; + } else if (_language == Common::CZ_CZE && fileIt->getName() != "czech.dcp") { + continue; + } else if (_language == Common::IT_ITA && fileIt->getName() != "italian.dcp") { + continue; + } else if (_language == Common::PL_POL && fileIt->getName() != "polish.dcp") { + continue; + } else if (_language == Common::RU_RUS && fileIt->getName() != "russian.dcp") { continue; } } diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 91b1add1c8..5e18a95786 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -33,6 +33,7 @@ #include "common/str.h" #include "common/fs.h" #include "common/file.h" +#include "common/language.h" namespace Wintermute { class BaseFileManager { @@ -44,7 +45,7 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(); + BaseFileManager(Common::Language lang); virtual ~BaseFileManager(); // Used only for detection bool registerPackages(const Common::FSList &fslist); @@ -65,6 +66,7 @@ private: bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); Common::SearchSet _packages; Common::Array _openFiles; + Common::Language _language; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: }; diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 6008a92c26..9ada07293f 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -126,7 +126,7 @@ Common::Error WintermuteEngine::run() { } int WintermuteEngine::init() { - BaseEngine::createInstance(_targetName); + BaseEngine::createInstance(_targetName, _gameDescription->language); _game = new AdGame(_targetName); if (!_game) { return 1; @@ -296,7 +296,7 @@ bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String caption = name = "(invalid)"; Common::SeekableReadStream *stream = NULL; // Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it - BaseFileManager *fileMan = new BaseFileManager(); + BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG); fileMan->registerPackages(fslist); stream = fileMan->openFile("startup.settings", false, false); -- cgit v1.2.3 From 589094e63a6c2a093cbca148800ef279d2a0b89d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 04:43:14 +0200 Subject: WINTERMUTE: Clean out commented-out code from detection --- engines/wintermute/detection.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 7e4da68a93..ff46418baa 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -64,46 +64,6 @@ public: return "Copyright (c) 2011 Jan Nedoma"; } - /* virtual GameList getSupportedGames() const { - GameList games; - const PlainGameDescriptor *g = wintermuteGames; - while (g->gameid) { - games.push_back(*g); - g++; - } - - return games; - } - - virtual GameDescriptor findGame(const char *gameid) const { - const PlainGameDescriptor *g = wintermuteGames; - while (g->gameid) { - if (0 == scumm_stricmp(gameid, g->gameid)) - break; - g++; - } - return GameDescriptor(g->gameid, g->description); - }*/ - - /* virtual GameList detectGames(const Common::FSList &fslist) const { - GameList detectedGames; - - // Iterate over all files in the given directory - for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - if (!file->isDirectory()) { - const char *gameName = file->getName().c_str(); - - if (0 == scumm_stricmp("data.dcp", gameName)) { - // You could check the contents of the file now if you need to. - detectedGames.push_back(Wintermute_setting[0]); - break; - } - } - } - return detectedGames; - }*/ - - virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { // Set some defaults s_fallbackDesc.extra = ""; -- cgit v1.2.3 From c96ccaa1c3e130be9185b67dabaecb538924ad96 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 04:59:17 +0200 Subject: WINTERMUTE: Add detection for Italian, English and Russian Dead City. --- engines/wintermute/detection.cpp | 7 +++++++ engines/wintermute/detection_tables.h | 36 +++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index ff46418baa..04f7f3b112 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -51,10 +51,17 @@ static ADGameDescription s_fallbackDesc = { }; static char s_fallbackGameIdBuf[256]; +static const char *directoryGlobs[] = { + "language", // To detect the various languages + 0 +}; + class WintermuteMetaEngine : public AdvancedMetaEngine { public: WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(ADGameDescription), Wintermute::wintermuteGames) { _singleid = "wintermute"; + _maxScanDepth = 2; + _directoryGlobs = directoryGlobs; } virtual const char *getName() const { return "Wintermute"; diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index 2e7def0d77..4f8a962591 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -84,16 +84,48 @@ static const ADGameDescription gameDescriptions[] = { ADGF_UNSTABLE, GUIO0() }, - // Dead City + // Dead City (English) { "deadcity", "", - AD_ENTRY1s("data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), + { + {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0() }, + // Dead City (Italian) + { + "deadcity", + "", + { + {"italian.dcp", 0, "92d8efb94436bec7bd1b7fe0b548192e", 454037}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + // Dead City (Russian) + { + "deadcity", + "", + { + {"russian.dcp", 0, "a0ae71e9e1185596fffb07ad2c951eb9", 653317}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, // Dirty Split (English) { "dirtysplit", -- cgit v1.2.3 From fb566386c74c823f98c089ef088ec997d5ce1371 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 22:28:39 +0200 Subject: WINTERMUTE: Write alpha properly on big-endian platforms. --- engines/wintermute/video/video_theora_player.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index f75c7ba5b6..31e6b1fcb7 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -344,10 +344,18 @@ void VideoTheoraPlayer::writeAlpha() { // TODO: Endian-fix. assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); const byte *alphaData = (byte *)_alphaImage->getSurface()->getBasePtr(0, 0); +#ifdef SCUMM_LITTLE_ENDIAN int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); +#else + int alphaPlace = 3 - (_alphaImage->getSurface()->format.aShift / 8); +#endif alphaData += alphaPlace; byte *imgData = (byte *)_surface.getBasePtr(0, 0); +#ifdef SCUMM_LITTLE_ENDIAN imgData += (_surface.format.aShift / 8); +#else + imgData += 3 - (_surface.format.aShift / 8); +#endif for (int i = 0; i < _surface.w * _surface.h; i++) { *imgData = *alphaData; alphaData += 4; @@ -381,8 +389,6 @@ bool VideoTheoraPlayer::display(uint32 alpha) { ////////////////////////////////////////////////////////////////////////// bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) { - warning("VideoTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); - delete _alphaImage; _alphaImage = new BaseImage(); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { -- cgit v1.2.3 From 209488c6cf87fc9c7f7adf005d7bad5a1f5428a8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 17:26:46 +0200 Subject: WINTERMUTE: Save the loop-state of sounds properly. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 14bbcd9421..b94f0d8215 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -137,10 +137,12 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { delete _handle; _handle = NULL; } + // Store the loop-value for save-games. + setLooping(looping); if (_stream) { _stream->seek(startSample); _handle = new Audio::SoundHandle; - if (looping) { + if (_looping) { Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); } else { -- cgit v1.2.3 From 83344a5aef4d27a75694393be4f9a28266504ae0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 17:27:28 +0200 Subject: WINTERMUTE: Adjust a few warnings. --- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index ced279dcc8..0893f36bc5 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -566,7 +566,7 @@ bool BaseFontTT::initFont() { } if (!_font) { _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BaseFontTT::InitFont - Couldn't load %s", _fontFile); + warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); } _lineHeight = _font->getFontHeight(); return STATUS_OK; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 201c881122..4c8a80028b 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -539,7 +539,6 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { ////////////////////////////////////////////////////////////////////////// BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Clip by viewport. - warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); BaseImage *screenshot = new BaseImage(); screenshot->copyFrom(_renderSurface); return screenshot; -- cgit v1.2.3 From f37e8fbdb12c7bf6479c51ab8dc73a06d162abc1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 18:19:10 +0200 Subject: WINTERMUTE: Clean out some comments in the theora player --- engines/wintermute/video/video_theora_player.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 31e6b1fcb7..d92a74610d 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -93,11 +93,6 @@ void VideoTheoraPlayer::SetDefaults() { ////////////////////////////////////////////////////////////////////////// VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); - - /* SAFE_DELETE_ARRAY(_filename); - SAFE_DELETE_ARRAY(_alphaFilename); - SAFE_DELETE(_texture); - SAFE_DELETE(_alphaImage);*/ // SAFE_DELETE(_subtitler); } @@ -130,7 +125,6 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: return STATUS_FAILED; } - //if (Filename != _filename) BaseUtils::setString(&_filename, filename); #if defined (USE_THEORADEC) _theoraDecoder = new TheoraDecoder(); #else -- cgit v1.2.3 From e01dc47414355937d98b1de11151dde7c1c12a00 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 18:20:12 +0200 Subject: WINTERMUTE: Fill the screen with fillRect for now. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 4c8a80028b..05520ee7a9 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -171,7 +171,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _blankSurface->fillRect(Common::Rect(0, 0, g_system->getHeight(), g_system->getWidth()), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); + _blankSurface->fillRect(Common::Rect(0, 0, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); _active = true; _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); @@ -206,7 +206,6 @@ bool BaseRenderOSystem::flip() { while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false) { RenderTicket *ticket = *it; - addDirtyRect((*it)->_dstRect); it = _renderQueue.erase(it); delete ticket; } else { @@ -237,11 +236,12 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_OK; } if (!rect) { - if (r == 0 && g == 0 && b == 0) { +// TODO: This should speed things up, but for some reason it misses the size by quite a bit. +/* if (r == 0 && g == 0 && b == 0) { // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); return STATUS_OK; - } + }*/ rect = &_renderRect; } // TODO: This doesn't work with dirty rects -- cgit v1.2.3 From 10ca0f136d120677d776981fc58aba548181c033 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 15 Aug 2012 02:35:11 +0200 Subject: WINTERMUTE: Clear out some commented-out code. --- engines/wintermute/base/base_game.cpp | 10 ---------- engines/wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 + engines/wintermute/video/video_theora_player.h | 1 - 4 files changed, 1 insertion(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 568e6dc6fd..acb20b2454 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -477,15 +477,6 @@ bool BaseGame::initialize3() { // renderer is initialized void BaseGame::DEBUG_DebugEnable(const char *filename) { _debugDebugMode = true; - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - #ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #endif*/ int secs = g_system->getMillis() / 1000; int hours = secs / 3600; secs = secs % 3600; @@ -499,7 +490,6 @@ void BaseGame::DEBUG_DebugEnable(const char *filename) { #endif LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); AnsiString platform = BasePlatform::getPlatformName(); LOG(0, "Platform: %s", platform.c_str()); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 8765fb9864..575e24a3a3 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -312,7 +312,6 @@ bool ScEngine::tick() { break; } default: - //warning("ScEngine::Tick - Unhandled enum"); break; } // switch } // for each script diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index b94f0d8215..bb4d5ba375 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -156,6 +156,7 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { if (isPlaying()) { + // This warning is here, to see if this is ever the case. warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO } _looping = looping; diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index cd358381f1..41b45d2289 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -68,7 +68,6 @@ public: bool play(TVideoPlayback type = VID_PLAY_CENTER, int x = 0, int y = 0, bool freezeGame = false, bool freezeMusic = true, bool looping = false, uint32 startTime = 0, float forceZoom = -1.0f, int volume = -1); bool stop(); bool display(uint32 alpha = 0xFFFFFFFF); - //bool renderFrame(BaseSurface *texture, yuv_buffer *yuv); bool pause(); bool resume(); -- cgit v1.2.3 From eacb0b169814345271d9d8e947d3d4fefe06ad7f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 15 Aug 2012 02:36:08 +0200 Subject: WINTERMUTE: Make use of the wday-field in dates, instead of a wrong mday-value. --- engines/wintermute/base/scriptables/script_ext_date.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index b5acc7d389..7726015081 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -127,8 +127,7 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWeekday") == 0) { stack->correctParams(0); - warning("GetWeekday returns a wrong value on purpose"); - stack->pushInt(_tm.tm_mday % 7); + stack->pushInt(_tm.tm_wday); return STATUS_OK; } -- cgit v1.2.3 From 246109839b9c196e9181a6f619c15694456b9aec Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 19 Aug 2012 23:49:29 +0200 Subject: WINTERMUTE: Be case-insensitive when testing for sound-format. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index bb4d5ba375..e2d9c8c13f 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -102,6 +102,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel return STATUS_FAILED; } Common::String strFilename(filename); + strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); } else if (strFilename.hasSuffix(".wav")) { -- cgit v1.2.3 From 16b27090b1c7dc11cdc199b1a98c0f2973db5f45 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 13:49:38 +0200 Subject: WINTERMUTE: Update to use new TGA-decoder and new Video-system --- engines/wintermute/base/gfx/base_image.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/graphics/tga.cpp | 164 ------ engines/wintermute/graphics/tga.h | 59 --- engines/wintermute/module.mk | 2 - .../wintermute/video/decoders/theora_decoder.cpp | 570 --------------------- engines/wintermute/video/decoders/theora_decoder.h | 147 ------ engines/wintermute/video/video_theora_player.cpp | 21 +- engines/wintermute/video/video_theora_player.h | 2 +- 9 files changed, 17 insertions(+), 954 deletions(-) delete mode 100644 engines/wintermute/graphics/tga.cpp delete mode 100644 engines/wintermute/graphics/tga.h delete mode 100644 engines/wintermute/video/decoders/theora_decoder.cpp delete mode 100644 engines/wintermute/video/decoders/theora_decoder.h (limited to 'engines') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index ec52e26c00..1184d2bbf7 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -32,8 +32,8 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" +#include "graphics/decoders/tga.h" #include "graphics/surface.h" -#include "engines/wintermute/graphics/tga.h" #include "common/textconsole.h" #include "common/stream.h" #include "common/system.h" @@ -69,7 +69,7 @@ bool BaseImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".tga")) { - _decoder = new Wintermute::TGA(); + _decoder = new Graphics::TGADecoder(); } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5b0f7c94c3..f0ec41a265 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -36,8 +36,8 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" +#include "graphics/decoders/tga.h" #include "engines/wintermute/graphics/transparent_surface.h" -#include "engines/wintermute/graphics/tga.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/stream.h" diff --git a/engines/wintermute/graphics/tga.cpp b/engines/wintermute/graphics/tga.cpp deleted file mode 100644 index 8c3868c023..0000000000 --- a/engines/wintermute/graphics/tga.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* Based on code from eos https://github.com/DrMcCoy/xoreos/ - * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 - */ - -#include "common/util.h" -#include "common/stream.h" -#include "common/textconsole.h" -#include "common/error.h" - -#include "engines/wintermute/graphics/tga.h" - -namespace Wintermute { - -TGA::TGA() { - -} - -TGA::~TGA() { - destroy(); -} - -void TGA::destroy() { - _surface.free(); -} - -bool TGA::loadStream(Common::SeekableReadStream &tga) { - byte imageType, pixelDepth; - bool success; - success = readHeader(tga, imageType, pixelDepth); - success = readData(tga, imageType, pixelDepth); - - if (tga.err() || !success) { - warning("Failed reading TGA-file"); - return false; - } - return success; -} - -bool TGA::readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth) { - if (!tga.seek(0)) { - warning("Failed reading TGA-file"); - return false; - } - - // TGAs have an optional "id" string in the header - uint32 idLength = tga.readByte(); - - // Number of colors in the color map / palette - if (tga.readByte() != 0) { - warning("Unsupported feature: Color map"); - return false; - } - - // Image type. 2 == unmapped RGB, 3 == Grayscale - imageType = tga.readByte(); - if ((imageType != 2) && (imageType != 3)) { - warning("Unsupported image type: %d", imageType); - return false; - } - - // Color map specifications + X + Y - tga.skip(5 + 2 + 2); - - // Image dimensions - _surface.w = tga.readUint16LE(); - _surface.h = tga.readUint16LE(); - - // Bits per pixel - pixelDepth = tga.readByte(); - _surface.format.bytesPerPixel = pixelDepth / 8; - - if (imageType == 2) { - if (pixelDepth == 24) { - _hasAlpha = false; - _format = Graphics::PixelFormat(pixelDepth / 8, 8, 8, 8, 0, 16, 8, 0, 0); - } else if (pixelDepth == 16 || pixelDepth == 32) { - _hasAlpha = true; - _format = Graphics::PixelFormat(pixelDepth / 8, 8, 8, 8, 8, 24, 16, 8, 0); - } else { - warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); - return false; - } - } else if (imageType == 3) { - if (pixelDepth != 8) { - warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); - return false; - } - - _hasAlpha = false; - _format = Graphics::PixelFormat(1, 0, 0, 0, 0, 0, 0, 0, 0); - } - - // Image descriptor - tga.skip(1); - - // Skip the id string - tga.skip(idLength); - return true; -} - -bool TGA::readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth) { - if (imageType == 2) { - _surface.create(_surface.w, _surface.h, _format); - - if (pixelDepth == 16) { - // Convert from 16bpp to 32bpp - // 16bpp TGA is ARGB1555 - uint16 count = _surface.w * _surface.h; - byte *dst = (byte *)_surface.pixels; - - while (count--) { - uint16 pixel = tga.readUint16LE(); - - *dst++ = (pixel & 0x1F) << 3; - *dst++ = (pixel & 0x3E0) >> 2; - *dst++ = (pixel & 0x7C00) >> 7; - *dst++ = (pixel & 0x8000) ? 0xFF : 0x00; - } - - } else { - // Read it in raw - tga.read(_surface.pixels, _surface.pitch * _surface.w); - } - } else if (imageType == 3) { - _surface.create(_surface.w, _surface.h, _surface.format); - - byte *data = (byte *)_surface.pixels; - uint32 count = _surface.w * _surface.h; - - while (count-- > 0) { - byte g = tga.readByte(); - - memset(data, g, 3); - data[3] = 0xFF; - - data += 4; - } - - } - return true; -} - -} // End of namespace Graphics diff --git a/engines/wintermute/graphics/tga.h b/engines/wintermute/graphics/tga.h deleted file mode 100644 index 5e118f2338..0000000000 --- a/engines/wintermute/graphics/tga.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* Based on code from eos https://github.com/DrMcCoy/xoreos/ - * relicensed under GPLv2+ with permission from DrMcCoy and clone2727 - */ - -#ifndef WINTERMUTE_GRAPHICS_IMAGES_TGA_H -#define WINTERMUTE_GRAPHICS_IMAGES_TGA_H - -#include "graphics/surface.h" -#include "graphics/decoders/image_decoder.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Wintermute { - -/** TarGa image. */ -class TGA : public Graphics::ImageDecoder { -public: - TGA(); - virtual ~TGA(); - virtual void destroy(); - virtual const Graphics::Surface *getSurface() const { - return &_surface; - }; - virtual bool loadStream(Common::SeekableReadStream &stream); -private: - Graphics::PixelFormat _format; - bool _hasAlpha; - Graphics::Surface _surface; - // Loading helpers - bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth); - bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth); -}; - -} // End of namespace Graphics - -#endif // GRAPHICS_IMAGES_TGA_H diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index ee36e4d7a6..7b5b1b1a3a 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -87,7 +87,6 @@ MODULE_OBJS := \ base/saveload.o \ detection.o \ graphics/transparent_surface.o \ - graphics/tga.o \ math/math_util.o \ math/matrix4.o \ math/vector2.o \ @@ -109,7 +108,6 @@ MODULE_OBJS := \ utils/utils.o \ video/video_player.o \ video/video_theora_player.o \ - video/decoders/theora_decoder.o \ wintermute.o \ persistent.o diff --git a/engines/wintermute/video/decoders/theora_decoder.cpp b/engines/wintermute/video/decoders/theora_decoder.cpp deleted file mode 100644 index 6267e300f9..0000000000 --- a/engines/wintermute/video/decoders/theora_decoder.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * Source is based on the player example from libvorbis package, - * available at: http://svn.xiph.org/trunk/theora/examples/player_example.c - * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. - * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ - * - */ - -#include "engines/wintermute/video/decoders/theora_decoder.h" - -#ifdef USE_THEORADEC -#include "common/system.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "graphics/yuv_to_rgb.h" -#include "audio/decoders/raw.h" -#include "common/stream.h" -#include "common/debug.h" - -namespace Wintermute { - -#define AUDIOFD_FRAGSIZE 10240 - -static double rint(double v) { - return floor(v + 0.5); -} - -TheoraDecoder::TheoraDecoder(Audio::Mixer::SoundType soundType) { - _fileStream = 0; - - _theoraPacket = 0; - _vorbisPacket = 0; - _theoraDecode = 0; - _theoraSetup = 0; - _nextFrameStartTime = 0.0; - - _soundType = soundType; - _audStream = 0; - _audHandle = new Audio::SoundHandle(); - - ogg_sync_init(&_oggSync); - - _curFrame = -1; - _audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t)); - - reset(); -} - -TheoraDecoder::~TheoraDecoder() { - close(); - delete _fileStream; - delete _audHandle; - free(_audiobuf); -} - -void TheoraDecoder::queuePage(ogg_page *page) { - if (_theoraPacket) - ogg_stream_pagein(&_theoraOut, page); - - if (_vorbisPacket) - ogg_stream_pagein(&_vorbisOut, page); -} - -int TheoraDecoder::bufferData() { - char *buffer = ogg_sync_buffer(&_oggSync, 4096); - int bytes = _fileStream->read(buffer, 4096); - - ogg_sync_wrote(&_oggSync, bytes); - - return bytes; -} - -bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) { - close(); - - _endOfAudio = false; - _endOfVideo = false; - _fileStream = stream; - - // start up Ogg stream synchronization layer - ogg_sync_init(&_oggSync); - - // init supporting Vorbis structures needed in header parsing - vorbis_info_init(&_vorbisInfo); - vorbis_comment_init(&_vorbisComment); - - // init supporting Theora structures needed in header parsing - th_comment_init(&_theoraComment); - th_info_init(&_theoraInfo); - - // Ogg file open; parse the headers - // Only interested in Vorbis/Theora streams - bool foundHeader = false; - while (!foundHeader) { - int ret = bufferData(); - - if (ret == 0) - break; - - while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) { - ogg_stream_state test; - - // is this a mandated initial header? If not, stop parsing - if (!ogg_page_bos(&_oggPage)) { - // don't leak the page; get it into the appropriate stream - queuePage(&_oggPage); - foundHeader = true; - break; - } - - ogg_stream_init(&test, ogg_page_serialno(&_oggPage)); - ogg_stream_pagein(&test, &_oggPage); - ogg_stream_packetout(&test, &_oggPacket); - - // identify the codec: try theora - if (!_theoraPacket && th_decode_headerin(&_theoraInfo, &_theoraComment, &_theoraSetup, &_oggPacket) >= 0) { - // it is theora - memcpy(&_theoraOut, &test, sizeof(test)); - _theoraPacket = 1; - } else if (!_vorbisPacket && vorbis_synthesis_headerin(&_vorbisInfo, &_vorbisComment, &_oggPacket) >= 0) { - // it is vorbis - memcpy(&_vorbisOut, &test, sizeof(test)); - _vorbisPacket = 1; - } else { - // whatever it is, we don't care about it - ogg_stream_clear(&test); - } - } - // fall through to non-bos page parsing - } - - // we're expecting more header packets. - while ((_theoraPacket && _theoraPacket < 3) || (_vorbisPacket && _vorbisPacket < 3)) { - int ret; - - // look for further theora headers - while (_theoraPacket && (_theoraPacket < 3) && (ret = ogg_stream_packetout(&_theoraOut, &_oggPacket))) { - if (ret < 0) - error("Error parsing Theora stream headers; corrupt stream?"); - - if (!th_decode_headerin(&_theoraInfo, &_theoraComment, &_theoraSetup, &_oggPacket)) - error("Error parsing Theora stream headers; corrupt stream?"); - - _theoraPacket++; - } - - // look for more vorbis header packets - while (_vorbisPacket && (_vorbisPacket < 3) && (ret = ogg_stream_packetout(&_vorbisOut, &_oggPacket))) { - if (ret < 0) - error("Error parsing Vorbis stream headers; corrupt stream?"); - - if (vorbis_synthesis_headerin(&_vorbisInfo, &_vorbisComment, &_oggPacket)) - error("Error parsing Vorbis stream headers; corrupt stream?"); - - _vorbisPacket++; - - if (_vorbisPacket == 3) - break; - } - - // The header pages/packets will arrive before anything else we - // care about, or the stream is not obeying spec - - if (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) { - queuePage(&_oggPage); // demux into the appropriate stream - } else { - ret = bufferData(); // someone needs more data - - if (ret == 0) - error("End of file while searching for codec headers."); - } - } - - // and now we have it all. initialize decoders - if (_theoraPacket) { - _theoraDecode = th_decode_alloc(&_theoraInfo, _theoraSetup); - debugN(1, "Ogg logical stream %lx is Theora %dx%d %.02f fps", - _theoraOut.serialno, _theoraInfo.pic_width, _theoraInfo.pic_height, - (double)_theoraInfo.fps_numerator / _theoraInfo.fps_denominator); - - switch (_theoraInfo.pixel_fmt) { - case TH_PF_420: - debug(1, " 4:2:0 video"); - break; - case TH_PF_422: - debug(1, " 4:2:2 video"); - break; - case TH_PF_444: - debug(1, " 4:4:4 video"); - break; - case TH_PF_RSVD: - default: - debug(1, " video\n (UNKNOWN Chroma sampling!)"); - break; - } - - if (_theoraInfo.pic_width != _theoraInfo.frame_width || _theoraInfo.pic_height != _theoraInfo.frame_height) - debug(1, " Frame content is %dx%d with offset (%d,%d).", - _theoraInfo.frame_width, _theoraInfo.frame_height, _theoraInfo.pic_x, _theoraInfo.pic_y); - - switch (_theoraInfo.colorspace){ - case TH_CS_UNSPECIFIED: - /* nothing to report */ - break; - case TH_CS_ITU_REC_470M: - debug(1, " encoder specified ITU Rec 470M (NTSC) color."); - break; - case TH_CS_ITU_REC_470BG: - debug(1, " encoder specified ITU Rec 470BG (PAL) color."); - break; - default: - debug(1, "warning: encoder specified unknown colorspace (%d).", _theoraInfo.colorspace); - break; - } - - debug(1, "Encoded by %s", _theoraComment.vendor); - if (_theoraComment.comments) { - debug(1, "theora comment header:"); - for (int i = 0; i < _theoraComment.comments; i++) { - if (_theoraComment.user_comments[i]) { - int len = _theoraComment.comment_lengths[i]; - char *value = (char *)malloc(len + 1); - if (value) { - memcpy(value, _theoraComment.user_comments[i], len); - value[len] = '\0'; - debug(1, "\t%s", value); - free(value); - } - } - } - } - - th_decode_ctl(_theoraDecode, TH_DECCTL_GET_PPLEVEL_MAX, &_ppLevelMax, sizeof(_ppLevelMax)); - _ppLevel = _ppLevelMax; - th_decode_ctl(_theoraDecode, TH_DECCTL_SET_PPLEVEL, &_ppLevel, sizeof(_ppLevel)); - _ppInc = 0; - } else { - // tear down the partial theora setup - th_info_clear(&_theoraInfo); - th_comment_clear(&_theoraComment); - } - - th_setup_free(_theoraSetup); - _theoraSetup = 0; - - if (_vorbisPacket) { - vorbis_synthesis_init(&_vorbisDSP, &_vorbisInfo); - vorbis_block_init(&_vorbisDSP, &_vorbisBlock); - debug(3, "Ogg logical stream %lx is Vorbis %d channel %ld Hz audio.", - _vorbisOut.serialno, _vorbisInfo.channels, _vorbisInfo.rate); - - _audStream = Audio::makeQueuingAudioStream(_vorbisInfo.rate, _vorbisInfo.channels); - - // Get enough audio data to start us off - while (_audStream->numQueuedStreams() == 0) { - // Queue more data - bufferData(); - while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) - queuePage(&_oggPage); - - queueAudio(); - } - - if (_audStream) - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _audHandle, _audStream, -1, getVolume(), getBalance()); - } else { - // tear down the partial vorbis setup - vorbis_info_clear(&_vorbisInfo); - vorbis_comment_clear(&_vorbisComment); - _endOfAudio = true; - } - - _surface.create(_theoraInfo.frame_width, _theoraInfo.frame_height, g_system->getScreenFormat()); - - // Set up a display surface - _displaySurface.pixels = _surface.getBasePtr(_theoraInfo.pic_x, _theoraInfo.pic_y); - _displaySurface.w = _theoraInfo.pic_width; - _displaySurface.h = _theoraInfo.pic_height; - _displaySurface.format = _surface.format; - _displaySurface.pitch = _surface.pitch; - - // Set the frame rate - _frameRate = Common::Rational(_theoraInfo.fps_numerator, _theoraInfo.fps_denominator); - - return true; -} - -void TheoraDecoder::close() { - if (_vorbisPacket) { - ogg_stream_clear(&_vorbisOut); - vorbis_block_clear(&_vorbisBlock); - vorbis_dsp_clear(&_vorbisDSP); - vorbis_comment_clear(&_vorbisComment); - vorbis_info_clear(&_vorbisInfo); - - g_system->getMixer()->stopHandle(*_audHandle); - - _audStream = 0; - _vorbisPacket = false; - } - if (_theoraPacket) { - ogg_stream_clear(&_theoraOut); - th_decode_free(_theoraDecode); - th_comment_clear(&_theoraComment); - th_info_clear(&_theoraInfo); - _theoraDecode = 0; - _theoraPacket = false; - } - - if (!_fileStream) - return; - - ogg_sync_clear(&_oggSync); - - delete _fileStream; - _fileStream = 0; - - _surface.free(); - _displaySurface.pixels = 0; - _displaySurface.free(); - - reset(); -} - -const Graphics::Surface *TheoraDecoder::decodeNextFrame() { - // First, let's get our frame - while (_theoraPacket) { - // theora is one in, one out... - if (ogg_stream_packetout(&_theoraOut, &_oggPacket) > 0) { - - if (_ppInc) { - _ppLevel += _ppInc; - th_decode_ctl(_theoraDecode, TH_DECCTL_SET_PPLEVEL, &_ppLevel, sizeof(_ppLevel)); - _ppInc = 0; - } - - if (th_decode_packetin(_theoraDecode, &_oggPacket, NULL) == 0) { - _curFrame++; - - // Convert YUV data to RGB data - th_ycbcr_buffer yuv; - th_decode_ycbcr_out(_theoraDecode, yuv); - translateYUVtoRGBA(yuv); - - if (_curFrame == 0) - _startTime = g_system->getMillis(); - - double time = th_granule_time(_theoraDecode, _oggPacket.granulepos); - - // We need to calculate when the next frame should be shown - // This is all in floating point because that's what the Ogg code gives us - // Ogg is a lossy container format, so it doesn't always list the time to the - // next frame. In such cases, we need to calculate it ourselves. - if (time == -1.0) - _nextFrameStartTime += _frameRate.getInverse().toDouble(); - else - _nextFrameStartTime = time; - - // break out - break; - } - } else { - // If we can't get any more frames, we're done. - if (_theoraOut.e_o_s || _fileStream->eos()) { - _endOfVideo = true; - break; - } - - // Queue more data - bufferData(); - while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) - queuePage(&_oggPage); - } - - // Update audio if we can - queueAudio(); - } - - // Force at least some audio to be buffered - // TODO: 5 is very arbitrary. We probably should do something like QuickTime does. - while (!_endOfAudio && _audStream->numQueuedStreams() < 5) { - bufferData(); - while (ogg_sync_pageout(&_oggSync, &_oggPage) > 0) - queuePage(&_oggPage); - - bool queuedAudio = queueAudio(); - if ((_vorbisOut.e_o_s || _fileStream->eos()) && !queuedAudio) { - _endOfAudio = true; - break; - } - } - - return &_displaySurface; -} - -bool TheoraDecoder::queueAudio() { - if (!_audStream) - return false; - - // An audio buffer should have been allocated (either in the constructor or after queuing the current buffer) - if (!_audiobuf) { - warning("[TheoraDecoder::queueAudio] Invalid audio buffer"); - return false; - } - - bool queuedAudio = false; - - for (;;) { - float **pcm; - - // if there's pending, decoded audio, grab it - int ret = vorbis_synthesis_pcmout(&_vorbisDSP, &pcm); - if (ret > 0) { - int count = _audiobufFill / 2; - int maxsamples = ((AUDIOFD_FRAGSIZE - _audiobufFill) / _vorbisInfo.channels) >> 1; - int i; - for (i = 0; i < ret && i < maxsamples; i++) - for (int j = 0; j < _vorbisInfo.channels; j++) { - int val = CLIP((int)rint(pcm[j][i] * 32767.f), -32768, 32767); - _audiobuf[count++] = val; - } - - vorbis_synthesis_read(&_vorbisDSP, i); - _audiobufFill += (i * _vorbisInfo.channels) << 1; - - if (_audiobufFill == AUDIOFD_FRAGSIZE) { - byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; -#ifdef SCUMM_LITTLE_ENDIAN - flags |= Audio::FLAG_LITTLE_ENDIAN; -#endif - _audStream->queueBuffer((byte *)_audiobuf, AUDIOFD_FRAGSIZE, DisposeAfterUse::YES, flags); - - // The audio mixer is now responsible for the old audio buffer. - // We need to create a new one. - _audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t)); - if (!_audiobuf) { - warning("[TheoraDecoder::queueAudio] Cannot allocate memory for audio buffer"); - return false; - } - - _audiobufFill = 0; - queuedAudio = true; - } - } else { - // no pending audio; is there a pending packet to decode? - if (ogg_stream_packetout(&_vorbisOut, &_oggPacket) > 0) { - if (vorbis_synthesis(&_vorbisBlock, &_oggPacket) == 0) // test for success! - vorbis_synthesis_blockin(&_vorbisDSP, &_vorbisBlock); - } else // we've buffered all we have, break out for now - return queuedAudio; - } - } - - // Unreachable - return false; -} - -void TheoraDecoder::reset() { - VideoDecoder::reset(); - - // FIXME: This does a rewind() instead of a reset()! - - if (_fileStream) - _fileStream->seek(0); - - _audiobufFill = 0; - _audiobufReady = false; - - _curFrame = -1; - - _theoraPacket = 0; - _vorbisPacket = 0; -} - -bool TheoraDecoder::endOfVideo() const { - return !isVideoLoaded() || (_endOfVideo && (!_audStream || (_audStream->endOfData() && _endOfAudio))); -} - -uint32 TheoraDecoder::getTimeToNextFrame() const { - if (endOfVideo() || _curFrame < 0) - return 0; - - uint32 elapsedTime = getTime(); - uint32 nextFrameStartTime = (uint32)(_nextFrameStartTime * 1000); - - if (nextFrameStartTime <= elapsedTime) - return 0; - - return nextFrameStartTime - elapsedTime; -} - -uint32 TheoraDecoder::getTime() const { - if (_audStream) - return g_system->getMixer()->getSoundElapsedTime(*_audHandle); - - return VideoDecoder::getTime(); -} - -void TheoraDecoder::pauseVideoIntern(bool pause) { - if (_audStream) - g_system->getMixer()->pauseHandle(*_audHandle, pause); -} - -enum TheoraYUVBuffers { - kBufferY = 0, - kBufferU = 1, - kBufferV = 2 -}; - -void TheoraDecoder::translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer) { - // Width and height of all buffers have to be divisible by 2. - assert((YUVBuffer[kBufferY].width & 1) == 0); - assert((YUVBuffer[kBufferY].height & 1) == 0); - assert((YUVBuffer[kBufferU].width & 1) == 0); - assert((YUVBuffer[kBufferV].width & 1) == 0); - - // UV images have to have a quarter of the Y image resolution - assert(YUVBuffer[kBufferU].width == YUVBuffer[kBufferY].width >> 1); - assert(YUVBuffer[kBufferV].width == YUVBuffer[kBufferY].width >> 1); - assert(YUVBuffer[kBufferU].height == YUVBuffer[kBufferY].height >> 1); - assert(YUVBuffer[kBufferV].height == YUVBuffer[kBufferY].height >> 1); - - Graphics::convertYUV420ToRGB(&_surface, YUVBuffer[kBufferY].data, YUVBuffer[kBufferU].data, YUVBuffer[kBufferV].data, YUVBuffer[kBufferY].width, YUVBuffer[kBufferY].height, YUVBuffer[kBufferY].stride, YUVBuffer[kBufferU].stride); -} - -void TheoraDecoder::updateVolume() { - if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) - g_system->getMixer()->setChannelVolume(*_audHandle, getVolume()); -} - -void TheoraDecoder::updateBalance() { - if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) - g_system->getMixer()->setChannelBalance(*_audHandle, getBalance()); -} - -void TheoraDecoder::rewind() { - reset(); -} - -} // End of namespace Sword25 - -#endif diff --git a/engines/wintermute/video/decoders/theora_decoder.h b/engines/wintermute/video/decoders/theora_decoder.h deleted file mode 100644 index fd94f52142..0000000000 --- a/engines/wintermute/video/decoders/theora_decoder.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef WINTERMUTE_THEORADECODER_H -#define WINTERMUTE_THEORADECODER_H - -#include "common/scummsys.h" // for USE_THEORADEC - -#ifdef USE_THEORADEC - -#include "common/rational.h" -#include "video/video_decoder.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" - -#include -#include - -namespace Common { -class SeekableReadStream; -} - -namespace Wintermute { - -/** - * - * Decoder for Theora videos. - * Video decoder used in engines: - * - sword25 - * - wintermute - */ -class TheoraDecoder : public Video::RewindableVideoDecoder { -public: - TheoraDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); - virtual ~TheoraDecoder(); - - /** - * Load a video file - * @param stream the stream to load - */ - bool loadStream(Common::SeekableReadStream *stream); - void close(); - void reset(); - - /** - * Decode the next frame and return the frame's surface - * @note the return surface should *not* be freed - * @note this may return 0, in which case the last frame should be kept on screen - */ - const Graphics::Surface *decodeNextFrame(); - - bool isVideoLoaded() const { return _fileStream != 0; } - uint16 getWidth() const { return _displaySurface.w; } - uint16 getHeight() const { return _displaySurface.h; } - - uint32 getFrameCount() const { - // It is not possible to get frame count easily - // I.e. seeking is required - assert(0); - return 0; - } - - Graphics::PixelFormat getPixelFormat() const { return _displaySurface.format; } - uint32 getTime() const; - uint32 getTimeToNextFrame() const; - - bool endOfVideo() const; - - void rewind(); - -protected: - // VideoDecoder API - void updateVolume(); - void updateBalance(); - void pauseVideoIntern(bool pause); - -private: - void queuePage(ogg_page *page); - bool queueAudio(); - int bufferData(); - void translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer); - - Common::SeekableReadStream *_fileStream; - Graphics::Surface _surface; - Graphics::Surface _displaySurface; - Common::Rational _frameRate; - double _nextFrameStartTime; - bool _endOfVideo; - bool _endOfAudio; - - Audio::Mixer::SoundType _soundType; - Audio::SoundHandle *_audHandle; - Audio::QueuingAudioStream *_audStream; - - ogg_sync_state _oggSync; - ogg_page _oggPage; - ogg_packet _oggPacket; - ogg_stream_state _vorbisOut; - ogg_stream_state _theoraOut; - th_info _theoraInfo; - th_comment _theoraComment; - th_dec_ctx *_theoraDecode; - th_setup_info *_theoraSetup; - vorbis_info _vorbisInfo; - vorbis_dsp_state _vorbisDSP; - vorbis_block _vorbisBlock; - vorbis_comment _vorbisComment; - - int _theoraPacket; - int _vorbisPacket; - - int _ppLevelMax; - int _ppLevel; - int _ppInc; - - // single audio fragment audio buffering - int _audiobufFill; - bool _audiobufReady; - ogg_int16_t *_audiobuf; -}; - -} // End of namespace Sword25 - -#endif - -#endif diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index d92a74610d..2804c3d3a9 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/video/decoders/theora_decoder.h" +#include "video/theora_decoder.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" @@ -126,7 +126,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: } #if defined (USE_THEORADEC) - _theoraDecoder = new TheoraDecoder(); + _theoraDecoder = new Video::TheoraDecoder(); #else return STATUS_FAILED; #endif @@ -225,6 +225,8 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _posY = (int)((_gameRef->_renderer->_height - height) / 2); break; } + _theoraDecoder->start(); + return STATUS_OK; #if 0 // Stubbed for now as theora isn't seekable if (StartTime) SeekToTime(StartTime); @@ -274,11 +276,14 @@ bool VideoTheoraPlayer::update() { } } if (_state == THEORA_STATE_PLAYING) { - if (_theoraDecoder->getTimeToNextFrame() == 0) { - _surface.free(); - _surface.copyFrom(*_theoraDecoder->decodeNextFrame()); - if (_texture) { - writeVideo(); + if (!_theoraDecoder->endOfVideo() && _theoraDecoder->getTimeToNextFrame() == 0) { + const Graphics::Surface *decodedFrame = _theoraDecoder->decodeNextFrame(); + if (decodedFrame) { + _surface.free(); + _surface.copyFrom(*decodedFrame); + if (_texture) { + writeVideo(); + } } } return STATUS_OK; @@ -333,7 +338,7 @@ bool VideoTheoraPlayer::writeVideo() { return STATUS_OK; } -void VideoTheoraPlayer::writeAlpha() { // TODO: Endian-fix. +void VideoTheoraPlayer::writeAlpha() { if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 41b45d2289..fd1b7b94b3 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -46,7 +46,7 @@ private: THEORA_STATE_PAUSED = 2, THEORA_STATE_FINISHED = 3 }; - Video::RewindableVideoDecoder *_theoraDecoder; + Video::VideoDecoder *_theoraDecoder; Graphics::Surface _surface; public: DECLARE_PERSISTENT(VideoTheoraPlayer, BaseClass) -- cgit v1.2.3 From 2039ea6b8df36c960ff25ae56930357d40e95d1d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 14:01:18 +0200 Subject: WINTERMUTE: Fix g++ warnings listed by LordHoto --- engines/wintermute/ad/ad_scene.cpp | 4 ++-- engines/wintermute/base/base_dynamic_buffer.cpp | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 2 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font.h | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.h | 4 ++-- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/gfx/base_image.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/graphics/transparent_surface.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 4 ++-- engines/wintermute/ui/ui_edit.h | 2 +- engines/wintermute/video/video_theora_player.cpp | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 19968d41dc..1e5754a778 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1200,8 +1200,8 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { ////////////////////////////////////////////////////////////////////////// int AdScene::compareObjs(const void *obj1, const void *obj2) { - AdObject *object1 = *(AdObject **)obj1; - AdObject *object2 = *(AdObject **)obj2; + const AdObject *object1 = *(AdObject **)obj1; + const AdObject *object2 = *(AdObject **)obj2; if (object1->_posY < object2->_posY) { return -1; diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 0a7a214ba4..b49d4ce150 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -92,7 +92,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { if (!_initialized) { init(); } @@ -152,7 +152,7 @@ void BaseDynamicBuffer::putString(const char *val) { putString("(null)"); } else { putDWORD(strlen(val) + 1); - putBytes((byte *)val, strlen(val) + 1); + putBytes((const byte *)val, strlen(val) + 1); } } diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 8285b472b2..926728baa6 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -44,7 +44,7 @@ public: char *getString(); void putString(const char *val); bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); + bool putBytes(const byte *buffer, uint32 size); uint32 getSize(); bool init(uint32 initSize = 0); void cleanup(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index acb20b2454..5436b4637f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4356,7 +4356,7 @@ bool BaseGame::displayDebugInfo() { _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); if (_activeObject != NULL) { - _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((const byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); } sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0ff325be7d..a829732696 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -176,8 +176,8 @@ bool BaseSurfaceStorage::sortSurfaces() { ////////////////////////////////////////////////////////////////////////// int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - BaseSurface *s1 = *((BaseSurface **)arg1); - BaseSurface *s2 = *((BaseSurface **)arg2); + const BaseSurface *s1 = *((BaseSurface **)arg1); + const BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 198b1ae308..8fb2b2b44a 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -52,7 +52,7 @@ BaseFont::~BaseFont() { ////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { } diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index e4413e3410..aaf5aa2367 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -40,7 +40,7 @@ public: DECLARE_PERSISTENT(BaseFont, BaseObject) virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); virtual void initLoop() {}; diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 0913ac9b53..ff1207b31f 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -69,7 +69,7 @@ BaseFontBitmap::~BaseFontBitmap() { ////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontBitmap::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); } @@ -106,7 +106,7 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { +int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { if (maxLength == 0) { return 0; } diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 0b873855bb..22cd9c6ba8 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -41,7 +41,7 @@ public: bool loadFile(const Common::String &filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); BaseFontBitmap(BaseGame *inGame); @@ -62,7 +62,7 @@ private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); + int textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 0893f36bc5..2c8cd261a9 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -152,7 +152,7 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// -void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { if (text == NULL || strcmp((char *)text, "") == 0) { return; } diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index fc4de30fc5..93431b039c 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -101,7 +101,7 @@ public: virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); bool loadBuffer(byte *buffer); diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 1184d2bbf7..bf11e15307 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -93,7 +93,7 @@ byte BaseImage::getAlphaAt(int x, int y) const { if (!_surface) { return 0xFF; } - uint32 color = *(uint32 *)_surface->getBasePtr(x, y); + uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; _surface->format.colorToARGB(color, a, r, g, b); return a; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index d6006528a2..1a6d4fe1e5 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -373,8 +373,8 @@ bool PartEmitter::sortParticlesByZ() { ////////////////////////////////////////////////////////////////////////// int PartEmitter::compareZ(const void *obj1, const void *obj2) { - PartParticle *p1 = *(PartParticle **)obj1; - PartParticle *p2 = *(PartParticle **)obj2; + const PartParticle *p1 = *(PartParticle **)obj1; + const PartParticle *p2 = *(PartParticle **)obj2; if (p1->_posZ < p2->_posZ) { return -1; diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index 47e3591d4d..da01259b1b 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -403,7 +403,7 @@ TransparentSurface *TransparentSurface::scale(const Common::Rect &srcRect, const for (int y = 0; y < dstH; y++) { for (int x = 0; x < dstW; x++) { - uint32 color = READ_UINT32((byte *)getBasePtr(x * srcW / dstW + srcRect.left, + uint32 color = READ_UINT32((const byte *)getBasePtr(x * srcW / dstW + srcRect.left, y * srcH / dstH + srcRect.top)); WRITE_UINT32((byte *)target->getBasePtr(x + dstRect.left, y + dstRect.top), color); } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 23c783d200..a82a12258f 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -853,7 +853,7 @@ bool UIEdit::handleKeypress(Common::Event *event, bool printable) { //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii); WideString wstr; wstr += (char)event->kbd.ascii; - _selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); + _selEnd += insertChars(_selEnd, (const byte *)StringUtil::wideToAnsi(wstr).c_str(), 1); if (_gameRef->_textRTL) { _selEnd = _selStart; @@ -897,7 +897,7 @@ int UIEdit::deleteChars(int start, int end) { ////////////////////////////////////////////////////////////////////////// -int UIEdit::insertChars(int pos, byte *chars, int num) { +int UIEdit::insertChars(int pos, const byte *chars, int num) { if ((int)strlen(_text) + num > _maxLength) { num -= (strlen(_text) + num - _maxLength); } diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index ea943e3d57..fa760951b0 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -39,7 +39,7 @@ class UIEdit : public UIObject { public: DECLARE_PERSISTENT(UIEdit, UIObject) int _maxLength; - int insertChars(int pos, byte *chars, int num); + int insertChars(int pos, const byte *chars, int num); int deleteChars(int start, int end); bool _cursorVisible; uint32 _lastBlinkTime; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 2804c3d3a9..0d23a04af4 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -342,7 +342,7 @@ void VideoTheoraPlayer::writeAlpha() { if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); assert(_surface.format.bytesPerPixel == 4); - const byte *alphaData = (byte *)_alphaImage->getSurface()->getBasePtr(0, 0); + const byte *alphaData = (const byte *)_alphaImage->getSurface()->getBasePtr(0, 0); #ifdef SCUMM_LITTLE_ENDIAN int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); #else -- cgit v1.2.3 From 764ca7a51a27210ca7a66a6ab2f01714029af09c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 14:21:33 +0200 Subject: WINTERMUTE: Fix some of the clang++ warnings listed by LordHoto --- engines/wintermute/base/base_sprite.cpp | 4 +++- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 1 + engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 4 ++-- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/scriptables/script_ext_date.h | 1 - engines/wintermute/ui/ui_button.h | 3 ++- engines/wintermute/ui/ui_entity.h | 3 ++- engines/wintermute/ui/ui_object.h | 3 ++- 8 files changed, 13 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6fe5be9e11..2fc2096802 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -137,7 +137,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC file = NULL; } - bool ret; + bool ret = STATUS_FAILED; AnsiString filePrefix = filename; AnsiString ext = PathUtil::getExtension(filename); @@ -164,6 +164,8 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); + } else { + ret = STATUS_OK; } delete[] buffer; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 5859fec74e..44acca0267 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -83,6 +83,7 @@ public: void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); + bool setViewport(Rect32 *rect) { return BaseRenderer::setViewport(rect); } Rect32 getViewPort(); void modTargetRect(Common::Rect *rect); void pointFromScreen(Point32 *point); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index f0ec41a265..ea88f19065 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -196,7 +196,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { bool hasTransparency = false; for (int y = 0; y < surface->h; y++) { for (int x = 0; x < surface->w; x++) { - uint32 pixel = getPixel(surface, x, y); + uint32 pixel = getPixelAt(surface, x, y); uint8 r, g, b, a; surface->format.colorToARGB(pixel, a, r, g, b); @@ -220,7 +220,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { +uint32 BaseSurfaceOSystem::getPixelAt(Graphics::Surface *surface, int x, int y) { warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 27f9ad047e..1b7146632e 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -86,7 +86,7 @@ private: bool finishLoad(); bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); - uint32 getPixel(Graphics::Surface *surface, int x, int y); + uint32 getPixelAt(Graphics::Surface *surface, int x, int y); bool _hasAlpha; void *_lockPixels; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 521b7a9f8a..7cdf57e689 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -45,7 +45,6 @@ public: bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); private: - char *_string; TimeDate _tm; Common::String _strRep; }; diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 61cdef476e..88ba8dafc7 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -44,7 +44,8 @@ public: uint32 _oneTimePressTime; DECLARE_PERSISTENT(UIButton, UIObject) void press(); - virtual bool display(int offsetX = 0, int offsetY = 0); + virtual bool display() { return display(0, 0); } + virtual bool display(int offsetX, int offsetY); bool _press; bool _hover; void correctSize(); diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index bc44c1f112..aeb32a6ffb 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -42,7 +42,8 @@ public: bool loadBuffer(byte *buffer, bool complete); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - virtual bool display(int offsetX = 0, int offsetY = 0); + virtual bool display() { return display(0, 0); } + virtual bool display(int offsetX, int offsetY); AdEntity *_entity; bool setEntity(const char *filename); diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 8059207a9a..b0a34fe61e 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -49,7 +49,8 @@ public: DECLARE_PERSISTENT(UIObject, BaseObject) UIObject *_parent; virtual bool display() { return display(0, 0); } - virtual bool display(int offsetX = 0, int offsetY = 0); + virtual bool display(int offsetX) { return display(offsetX, 0); } + virtual bool display(int offsetX, int offsetY); virtual void correctSize(); bool _sharedFonts; bool _sharedImages; -- cgit v1.2.3 From 71981aaecf68b6a0910a18cad67cbba9ac7a1fb1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 16:34:12 +0200 Subject: WINTERMUTE: Simplify getNodeForRelativePath --- engines/wintermute/base/file/base_disk_file.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 2f7450a999..44a8049121 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -71,14 +71,11 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // Get the next path-component by slicing on '\\' Common::String pathPart = path.nextToken(); // Get the next FSNode in the chain, if it exists as a child from the previous. - Common::FSNode nextNode(curNode.getChild(pathPart)); - if (!nextNode.exists()) { + curNode = curNode.getChild(pathPart); + if (!curNode.isReadable()) { // Return an invalid FSNode. return Common::FSNode(); } - if (nextNode.exists() && nextNode.isReadable()) { - curNode = nextNode; - } // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { if (!path.empty()) { -- cgit v1.2.3 From 3dc5d32e8547c0bbccbb20d6a84ca5307d29ca5e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 16:55:17 +0200 Subject: WINTERMUTE: Replace qsort with Common::sort --- engines/wintermute/ad/ad_scene.cpp | 4 ++-- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 2 +- engines/wintermute/coll_templ.h | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 1e5754a778..b04f48f1fc 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1164,7 +1164,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { } // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(AdObject *), AdScene::compareObjs); + Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); // display them for (int i = 0; i < objects.getSize(); i++) { @@ -2994,7 +2994,7 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, } // sort by _posY - qsort(objects.getData(), objects.getSize(), sizeof(AdObject *), AdScene::compareObjs); + Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); return STATUS_OK; } diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index a829732696..0e0976b838 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -169,7 +169,7 @@ bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(BaseSurface *), surfaceSortCB); + Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 1a6d4fe1e5..4fb0eb6637 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -367,7 +367,7 @@ bool PartEmitter::start() { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(PartParticle *), PartEmitter::compareZ); + Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); return STATUS_OK; } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 96daaf62ee..fea203d100 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -83,9 +83,6 @@ public: void copy(const BaseArray &src) { Common::Array::insert_at(0, src); } - void *getData() { // Ugly, should perhaps add a sort-function instead. - return Common::Array::_storage; - } }; } // end of namespace Wintermute -- cgit v1.2.3 From 06caf2da98f0ae7d7776dad30be3a1dbf6da22d8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:10:01 +0200 Subject: WINTERMUTE: Use tabs instead of spaces for indenting dctypes.h --- engines/wintermute/dctypes.h | 183 +++++++++++++++++++++---------------------- 1 file changed, 91 insertions(+), 92 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h index 9cad244255..cab54fd144 100644 --- a/engines/wintermute/dctypes.h +++ b/engines/wintermute/dctypes.h @@ -51,176 +51,175 @@ typedef Common::Array AnsiStringArray; enum TGameState { - GAME_RUNNING, - GAME_FROZEN, - GAME_SEMI_FROZEN + GAME_RUNNING, + GAME_FROZEN, + GAME_SEMI_FROZEN }; enum TImageType { - IMG_PALETTED8, - IMG_TRUECOLOR + IMG_PALETTED8, + IMG_TRUECOLOR }; enum TTextAlign { - TAL_LEFT = 0, - TAL_RIGHT, - TAL_CENTER, - NUM_TEXT_ALIGN + TAL_LEFT = 0, + TAL_RIGHT, + TAL_CENTER, + NUM_TEXT_ALIGN }; enum TVerticalAlign { - VAL_TOP = 0, - VAL_CENTER, - VAL_BOTTOM, - NUM_VERTICAL_ALIGN + VAL_TOP = 0, + VAL_CENTER, + VAL_BOTTOM, + NUM_VERTICAL_ALIGN }; enum TDirection { - DI_UP = 0, - DI_UPRIGHT = 1, - DI_RIGHT = 2, - DI_DOWNRIGHT = 3, - DI_DOWN = 4, - DI_DOWNLEFT = 5, - DI_LEFT = 6, - DI_UPLEFT = 7, - NUM_DIRECTIONS = 8, - DI_NONE = 9 + DI_UP = 0, + DI_UPRIGHT = 1, + DI_RIGHT = 2, + DI_DOWNRIGHT = 3, + DI_DOWN = 4, + DI_DOWNLEFT = 5, + DI_LEFT = 6, + DI_UPLEFT = 7, + NUM_DIRECTIONS = 8, + DI_NONE = 9 }; - enum TEventType { - EVENT_NONE = 0, - EVENT_INIT = 1, - EVENT_SHUTDOWN = 2, - EVENT_LEFT_CLICK = 3, - EVENT_RIGHT_CLICK = 4, - EVENT_MIDDLE_CLICK = 5, - EVENT_LEFT_DBLCLICK = 6, - EVENT_PRESS = 7, - EVENT_IDLE = 8, - EVENT_MOUSE_OVER = 9, - EVENT_LEFT_RELEASE = 10, - EVENT_RIGHT_RELEASE = 11, - EVENT_MIDDLE_RELEASE = 12, - NUM_EVENTS + EVENT_NONE = 0, + EVENT_INIT = 1, + EVENT_SHUTDOWN = 2, + EVENT_LEFT_CLICK = 3, + EVENT_RIGHT_CLICK = 4, + EVENT_MIDDLE_CLICK = 5, + EVENT_LEFT_DBLCLICK = 6, + EVENT_PRESS = 7, + EVENT_IDLE = 8, + EVENT_MOUSE_OVER = 9, + EVENT_LEFT_RELEASE = 10, + EVENT_RIGHT_RELEASE = 11, + EVENT_MIDDLE_RELEASE = 12, + NUM_EVENTS }; - enum TUIObjectType { - UI_UNKNOWN, - UI_BUTTON, - UI_WINDOW, - UI_STATIC, - UI_EDIT, - UI_HTML, - UI_CUSTOM + UI_UNKNOWN, + UI_BUTTON, + UI_WINDOW, + UI_STATIC, + UI_EDIT, + UI_HTML, + UI_CUSTOM }; enum TRendererState { - RSTATE_3D, - RSTATE_2D, - RSTATE_LINES, - RSTATE_NONE + RSTATE_3D, + RSTATE_2D, + RSTATE_LINES, + RSTATE_NONE }; enum TDynamicConstructor { - DYNAMIC_CONSTRUCTOR + DYNAMIC_CONSTRUCTOR }; enum TVideoMode { - VIDEO_WINDOW, - VIDEO_FULLSCREEN, - VIDEO_ANY + VIDEO_WINDOW, + VIDEO_FULLSCREEN, + VIDEO_ANY }; enum TVideoPlayback { - VID_PLAY_POS = 0, - VID_PLAY_STRETCH = 1, - VID_PLAY_CENTER = 2 + VID_PLAY_POS = 0, + VID_PLAY_STRETCH = 1, + VID_PLAY_CENTER = 2 }; enum TMouseEvent { - MOUSE_CLICK, - MOUSE_RELEASE, - MOUSE_DBLCLICK + MOUSE_CLICK, + MOUSE_RELEASE, + MOUSE_DBLCLICK }; enum TMouseButton { - MOUSE_BUTTON_LEFT, - MOUSE_BUTTON_RIGHT, - MOUSE_BUTTON_MIDDLE + MOUSE_BUTTON_LEFT, + MOUSE_BUTTON_RIGHT, + MOUSE_BUTTON_MIDDLE }; enum TTransMgrState { - TRANS_MGR_RUNNING, TRANS_MGR_READY + TRANS_MGR_RUNNING, + TRANS_MGR_READY }; enum TTransitionType { - TRANSITION_NONE = 0, - TRANSITION_FADE_OUT = 1, - TRANSITION_FADE_IN = 2, - NUM_TRANSITION_TYPES + TRANSITION_NONE = 0, + TRANSITION_FADE_OUT = 1, + TRANSITION_FADE_IN = 2, + NUM_TRANSITION_TYPES }; enum TWindowMode { - WINDOW_NORMAL, - WINDOW_EXCLUSIVE, - WINDOW_SYSTEM_EXCLUSIVE + WINDOW_NORMAL, + WINDOW_EXCLUSIVE, + WINDOW_SYSTEM_EXCLUSIVE }; enum TSFXType { - SFX_NONE, - SFX_ECHO, - SFX_REVERB + SFX_NONE, + SFX_ECHO, + SFX_REVERB }; enum TSpriteCacheType { - CACHE_ALL, - CACHE_HALF + CACHE_ALL, + CACHE_HALF }; enum TTextEncoding { - TEXT_ANSI = 0, - TEXT_UTF8 = 1, - NUM_TEXT_ENCODINGS + TEXT_ANSI = 0, + TEXT_UTF8 = 1, + NUM_TEXT_ENCODINGS }; enum TSpriteBlendMode { - BLEND_UNKNOWN = -1, - BLEND_NORMAL = 0, - BLEND_ADDITIVE = 1, - BLEND_SUBTRACTIVE = 2, - NUM_BLEND_MODES + BLEND_UNKNOWN = -1, + BLEND_NORMAL = 0, + BLEND_ADDITIVE = 1, + BLEND_SUBTRACTIVE = 2, + NUM_BLEND_MODES }; enum TTTSType { - TTS_CAPTION = 0, - TTS_TALK, - TTS_KEYPRESS + TTS_CAPTION = 0, + TTS_TALK, + TTS_KEYPRESS }; enum TShadowType { - SHADOW_NONE = 0, - SHADOW_SIMPLE = 1, - SHADOW_FLAT = 2, - SHADOW_STENCIL = 3 + SHADOW_NONE = 0, + SHADOW_SIMPLE = 1, + SHADOW_FLAT = 2, + SHADOW_STENCIL = 3 }; } // end of namespace Wintermute -#endif // DCTYPES_H +#endif -- cgit v1.2.3 From 2d70964e9ca159ffffcd71759d0fbdb2448d0c01 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:15:03 +0200 Subject: WINTERMUTE: Use tabs instead of spaces in ad_types.h --- engines/wintermute/ad/ad_types.h | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_types.h b/engines/wintermute/ad/ad_types.h index 17152ca5e8..b8cae58c6d 100644 --- a/engines/wintermute/ad/ad_types.h +++ b/engines/wintermute/ad/ad_types.h @@ -32,74 +32,74 @@ namespace Wintermute { typedef enum { - GAME_NORMAL, - GAME_WAITING_RESPONSE + GAME_NORMAL, + GAME_WAITING_RESPONSE } TGameStateEx; typedef enum { - OBJECT_ENTITY, - OBJECT_REGION, - OBJECT_ACTOR, - OBJECT_NONE + OBJECT_ENTITY, + OBJECT_REGION, + OBJECT_ACTOR, + OBJECT_NONE } TObjectType; typedef enum { - ENTITY_NORMAL, - ENTITY_SOUND + ENTITY_NORMAL, + ENTITY_SOUND } TEntityType; typedef enum { - STATE_NONE, - STATE_IDLE, - STATE_PLAYING_ANIM, - STATE_READY, - STATE_FOLLOWING_PATH, - STATE_SEARCHING_PATH, - STATE_WAITING_PATH, - STATE_TURNING_LEFT, - STATE_TURNING_RIGHT, - STATE_TURNING, - STATE_TALKING, - STATE_DIRECT_CONTROL, - STATE_PLAYING_ANIM_SET + STATE_NONE, + STATE_IDLE, + STATE_PLAYING_ANIM, + STATE_READY, + STATE_FOLLOWING_PATH, + STATE_SEARCHING_PATH, + STATE_WAITING_PATH, + STATE_TURNING_LEFT, + STATE_TURNING_RIGHT, + STATE_TURNING, + STATE_TALKING, + STATE_DIRECT_CONTROL, + STATE_PLAYING_ANIM_SET } TObjectState; typedef enum { - DIRECT_WALK_NONE, - DIRECT_WALK_FW, - DIRECT_WALK_BK + DIRECT_WALK_NONE, + DIRECT_WALK_FW, + DIRECT_WALK_BK } TDirectWalkMode; typedef enum { - DIRECT_TURN_NONE, - DIRECT_TURN_CW, - DIRECT_TURN_CCW + DIRECT_TURN_NONE, + DIRECT_TURN_CW, + DIRECT_TURN_CCW } TDirectTurnMode; typedef enum { - RESPONSE_TEXT, - RESPONSE_ICON + RESPONSE_TEXT, + RESPONSE_ICON } TResponseStyle; typedef enum { - RESPONSE_ALWAYS, - RESPONSE_ONCE, - RESPONSE_ONCE_GAME + RESPONSE_ALWAYS, + RESPONSE_ONCE, + RESPONSE_ONCE_GAME } TResponseType; typedef enum { - TALK_SKIP_LEFT = 0, - TALK_SKIP_RIGHT = 1, - TALK_SKIP_BOTH = 2, - TALK_SKIP_NONE = 3 + TALK_SKIP_LEFT = 0, + TALK_SKIP_RIGHT = 1, + TALK_SKIP_BOTH = 2, + TALK_SKIP_NONE = 3 } TTalkSkipButton; typedef enum { - GEOM_WAYPOINT, - GEOM_WALKPLANE, - GEOM_BLOCKED, - GEOM_GENERIC + GEOM_WAYPOINT, + GEOM_WALKPLANE, + GEOM_BLOCKED, + GEOM_GENERIC } TGeomNodeType; } // end of namespace Wintermute -- cgit v1.2.3 From d5f92497e6f15fab1c7f09bdf9a3f9c86982d35f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:16:49 +0200 Subject: WINTERMUTE: Correct some endif-comments. --- engines/wintermute/coll_templ.h | 2 +- engines/wintermute/dcgf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index fea203d100..7b1d21f5b0 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -87,4 +87,4 @@ public: } // end of namespace Wintermute -#endif // COLL_TEMPL_H +#endif // WINTERMUTE_COLL_TEMPL_H diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index f8213570e4..c1a67ba4d1 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -48,4 +48,4 @@ #define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP -#endif // _DCGF_H_ +#endif // WINTERMUTE_DCGF_H -- cgit v1.2.3 From b01f09e82fd254823a839a8d4f622dc4d35bde6a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:28:37 +0200 Subject: WINTERMUTE: Use instead of --- engines/wintermute/base/scriptables/script_ext_math.cpp | 2 +- engines/wintermute/math/math_util.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 906d807275..f7d0ba20b9 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/persistent.h" #include "common/math.h" -#include +#include namespace Wintermute { diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index 4a308a914e..434e0e016b 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -27,14 +27,14 @@ */ #include "engines/wintermute/math/math_util.h" -#include +#include namespace Wintermute { ////////////////////////////////////////////////////////////////////////// float MathUtil::round(float val) { float result = floor(val); - if (val - result >= 0.5) { + if (val - result >= 0.5f) { result += 1.0; } return result; -- cgit v1.2.3 From 8a212c3b6cb5100d750fb3025e79af64e4ed86e4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:29:16 +0200 Subject: WINTERMUTE: Add namespacing to the UTF-conversion code --- engines/wintermute/utils/convert_utf.cpp | 9 +++-- engines/wintermute/utils/convert_utf.h | 61 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/convert_utf.cpp b/engines/wintermute/utils/convert_utf.cpp index db0c0fa9f9..7ebc011d01 100644 --- a/engines/wintermute/utils/convert_utf.cpp +++ b/engines/wintermute/utils/convert_utf.cpp @@ -41,9 +41,11 @@ #include "engines/wintermute/utils/convert_utf.h" #ifdef CVTUTF_DEBUG -#include +#include "common/textconsole.h" #endif +namespace Wintermute { + static const int halfShift = 10; /* used for shifting by 10 bits */ static const UTF32 halfBase = 0x0010000UL; @@ -158,8 +160,7 @@ ConversionResult ConvertUTF16toUTF32( *targetStart = target; #ifdef CVTUTF_DEBUG if (result == sourceIllegal) { - fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); - fflush(stderr); + warning("ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); } #endif return result; @@ -610,3 +611,5 @@ ConversionResult ConvertUTF8toUTF32( similarly unrolled loops. --------------------------------------------------------------------- */ + +} // End of namespace Wintermute diff --git a/engines/wintermute/utils/convert_utf.h b/engines/wintermute/utils/convert_utf.h index 03a8bb2bae..171d86343a 100644 --- a/engines/wintermute/utils/convert_utf.h +++ b/engines/wintermute/utils/convert_utf.h @@ -20,6 +20,9 @@ * remains attached. */ +// NOTE: Modifications have been made to the code for inclusion +// into ScummVM. + /* --------------------------------------------------------------------- Conversions between UTF32, UTF-16, and UTF-8. Header file. @@ -86,11 +89,14 @@ All should be unsigned values to avoid sign extension during bit mask & shift operations. ------------------------------------------------------------------------ */ +#include "common/system.h" + +namespace Wintermute { -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ +typedef uint32 UTF32; /* at least 32 bits */ +typedef uint16 UTF16; /* at least 16 bits */ +typedef uint8 UTF8; /* typically 8 bits */ +typedef uint8 Boolean; /* 0 or 1 */ /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD @@ -111,39 +117,32 @@ typedef enum { lenientConversion } ConversionFlags; -/* This is for C++ and does no harm in C */ -#ifdef __cplusplus -extern "C" { -#endif - - ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); -#ifdef __cplusplus -} -#endif +} // End of namespace Wintermute /* --------------------------------------------------------------------- */ -- cgit v1.2.3 From 969f4d5947b6a36d66c12c510b8fe623e1782bbd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:37:25 +0200 Subject: WINTERMUTE: Take int32 as parameters in Rect32. --- engines/wintermute/math/rect32.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index 51a1be15e4..1c959da1cf 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -37,8 +37,8 @@ struct Rect32 { int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). Rect32() : top(0), left(0), bottom(0), right(0) {} - Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} - Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { + Rect32(int32 w, int32 h) : top(0), left(0), bottom(h), right(w) {} + Rect32(int32 x1, int32 y1, int32 x2, int32 y2) : top(y1), left(x1), bottom(y2), right(x2) { assert(isValidRect()); } bool operator==(const Rect32 &rhs) const { @@ -48,18 +48,18 @@ struct Rect32 { return !equals(rhs); } - int16 width() const { + int32 width() const { return right - left; } - int16 height() const { + int32 height() const { return bottom - top; } - void setWidth(int16 aWidth) { + void setWidth(int32 aWidth) { right = left + aWidth; } - void setHeight(int16 aHeight) { + void setHeight(int32 aHeight) { bottom = top + aHeight; } -- cgit v1.2.3 From 2fd38f47e04430b8684502e625f87a04dd968def Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 18:25:24 +0200 Subject: WINTERMUTE: Replace col_templ's getSize with Common::Array::size() --- engines/wintermute/ad/ad_actor.cpp | 26 +-- engines/wintermute/ad/ad_entity.cpp | 4 +- engines/wintermute/ad/ad_game.cpp | 120 +++++++------- engines/wintermute/ad/ad_inventory.cpp | 6 +- engines/wintermute/ad/ad_inventory_box.cpp | 6 +- engines/wintermute/ad/ad_layer.cpp | 22 ++- engines/wintermute/ad/ad_object.cpp | 44 +++--- engines/wintermute/ad/ad_path.cpp | 8 +- engines/wintermute/ad/ad_region.cpp | 7 +- engines/wintermute/ad/ad_response_box.cpp | 35 +++-- engines/wintermute/ad/ad_scene.cpp | 175 ++++++++++----------- engines/wintermute/ad/ad_scene_state.cpp | 4 +- engines/wintermute/ad/ad_sentence.cpp | 2 +- engines/wintermute/ad/ad_talk_def.cpp | 4 +- engines/wintermute/ad/ad_talk_holder.cpp | 24 +-- engines/wintermute/ad/ad_waypoint_group.cpp | 6 +- engines/wintermute/base/base_frame.cpp | 40 ++--- engines/wintermute/base/base_game.cpp | 40 ++--- engines/wintermute/base/base_region.cpp | 38 ++--- engines/wintermute/base/base_script_holder.cpp | 22 ++- engines/wintermute/base/base_sprite.cpp | 45 +++--- engines/wintermute/base/font/base_font_bitmap.cpp | 8 +- engines/wintermute/base/font/base_font_storage.cpp | 8 +- .../wintermute/base/font/base_font_truetype.cpp | 10 +- engines/wintermute/base/particles/part_emitter.cpp | 50 +++--- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 28 ++-- .../wintermute/base/scriptables/script_stack.cpp | 18 +-- engines/wintermute/coll_templ.h | 6 +- engines/wintermute/ui/ui_button.cpp | 2 +- engines/wintermute/ui/ui_edit.cpp | 2 +- engines/wintermute/ui/ui_entity.cpp | 2 +- engines/wintermute/ui/ui_object.cpp | 16 +- engines/wintermute/ui/ui_text.cpp | 2 +- engines/wintermute/ui/ui_window.cpp | 34 ++-- 36 files changed, 420 insertions(+), 448 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index e180499ee0..dd50955b4c 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -98,17 +98,17 @@ AdActor::~AdActor() { _animSprite2 = NULL; // ref only - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { delete _talkSprites[i]; } _talkSprites.clear(); - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { delete _talkSpritesEx[i]; } _talkSpritesEx.clear(); - for (int i = 0; i < _anims.getSize(); i++) { + for (uint32 i = 0; i < _anims.size(); i++) { delete _anims[i]; _anims[i] = NULL; } @@ -1036,7 +1036,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *animName = stack->pop()->getString(); bool found = false; - for (int i = 0; i < _anims.getSize(); i++) { + for (int i = 0; i < _anims.size(); i++) { if (scumm_stricmp(_anims[i]->getName(), animName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) { @@ -1239,7 +1239,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { } // old way - if (_talkSprites.getSize() > 0 || _talkSpritesEx.getSize() > 0) { + if (_talkSprites.size() > 0 || _talkSpritesEx.size() > 0) { return getTalkStanceOld(stance); } @@ -1255,14 +1255,14 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { // not - get a random talk if (!ret) { BaseArray talkAnims; - for (int i = 0; i < _anims.getSize(); i++) { + for (int i = 0; i < _anims.size(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { talkAnims.add(_anims[i]); } } - if (talkAnims.getSize() > 0) { - int rnd = BaseEngine::instance().randInt(0, talkAnims.getSize() - 1); + if (talkAnims.size() > 0) { + int rnd = BaseEngine::instance().randInt(0, talkAnims.size() - 1); ret = talkAnims[rnd]->getSprite(_dir); } else { if (_standSprite) { @@ -1284,7 +1284,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { if (stance != NULL) { // search special stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (int i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { ret = _talkSpritesEx[i]->getSprite(_dir); break; @@ -1292,7 +1292,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { } if (ret == NULL) { // search generic stances - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (int i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { ret = _talkSprites[i]->getSprite(_dir); break; @@ -1303,11 +1303,11 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.getSize() < 1) { + if (_talkSprites.size() < 1) { ret = _standSprite->getSprite(_dir); } else { // TODO: remember last - int rnd = BaseEngine::instance().randInt(0, _talkSprites.getSize() - 1); + int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); ret = _talkSprites[rnd]->getSprite(_dir); } } @@ -1395,7 +1395,7 @@ int AdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { - for (int i = 0; i < _anims.getSize(); i++) { + for (int i = 0; i < _anims.size(); i++) { if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) { return _anims[i]; } diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 5bf03d6062..67a919dd6b 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -993,9 +993,7 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "WALK_TO_DIR=%d\n", (int)_walkToDir); } - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 2971cdab00..f5d865d9f8 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -119,21 +119,19 @@ AdGame::~AdGame() { ////////////////////////////////////////////////////////////////////////// bool AdGame::cleanup() { - int i; - - for (i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { unregisterObject(_objects[i]); _objects[i] = NULL; } _objects.clear(); - for (i = 0; i < _dlgPendingBranches.getSize(); i++) { + for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { delete[] _dlgPendingBranches[i]; } _dlgPendingBranches.clear(); - for (i = 0; i < _speechDirs.getSize(); i++) { + for (uint32 i = 0; i < _speechDirs.size(); i++) { delete[] _speechDirs[i]; } _speechDirs.clear(); @@ -143,7 +141,7 @@ bool AdGame::cleanup() { _scene = NULL; // remove items - for (i = 0; i < _items.getSize(); i++) { + for (uint32 i = 0; i < _items.size(); i++) { _gameRef->unregisterObject(_items[i]); } _items.clear(); @@ -153,7 +151,7 @@ bool AdGame::cleanup() { delete _invObject; _invObject = NULL; - for (i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { delete _inventories[i]; } _inventories.clear(); @@ -184,17 +182,17 @@ bool AdGame::cleanup() { delete _sceneViewport; _sceneViewport = NULL; - for (i = 0; i < _sceneStates.getSize(); i++) { + for (uint32 i = 0; i < _sceneStates.size(); i++) { delete _sceneStates[i]; } _sceneStates.clear(); - for (i = 0; i < _responsesBranch.getSize(); i++) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { delete _responsesBranch[i]; } _responsesBranch.clear(); - for (i = 0; i < _responsesGame.getSize(); i++) { + for (uint32 i = 0; i < _responsesGame.size(); i++) { delete _responsesGame[i]; } _responsesGame.clear(); @@ -247,7 +245,7 @@ bool AdGame::removeObject(AdObject *object) { } } - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i] == object) { _objects.remove_at(i); break; @@ -276,7 +274,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { if (_scene) { // reset objects - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { _objects[i]->reset(); } @@ -296,7 +294,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { if (DID_SUCCEED(ret)) { // invalidate references to the original scene - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { _objects[i]->invalidateCurrRegions(); _objects[i]->_stickRegion = NULL; } @@ -321,7 +319,7 @@ void AdGame::addSentence(AdSentence *sentence) { ////////////////////////////////////////////////////////////////////////// bool AdGame::displaySentences(bool frozen) { - for (int i = 0; i < _sentences.getSize(); i++) { + for (uint32 i = 0; i < _sentences.size(); i++) { if (frozen && _sentences[i]->_freezable) { continue; } else { @@ -334,7 +332,7 @@ bool AdGame::displaySentences(bool frozen) { ////////////////////////////////////////////////////////////////////////// void AdGame::finishSentences() { - for (int i = 0; i < _sentences.getSize(); i++) { + for (uint32 i = 0; i < _sentences.size(); i++) { if (_sentences[i]->canSkip()) { _sentences[i]->_duration = 0; if (_sentences[i]->_sound) { @@ -489,7 +487,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdItem *item = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _items.getSize()) { + if (index >= 0 && index < (int32)_items.size()) { item = _items[index]; } } else { @@ -585,13 +583,13 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (_responseBox) { _responseBox->weedResponses(); - if (_responseBox->_responses.getSize() == 0) { + if (_responseBox->_responses.size() == 0) { stack->pushNULL(); return STATUS_OK; } - if (_responseBox->_responses.getSize() == 1 && autoSelectLast) { + if (_responseBox->_responses.size() == 1 && autoSelectLast) { stack->pushInt(_responseBox->_responses[0]->_iD); _responseBox->handleResponse(_responseBox->_responses[0]); _responseBox->clearResponses(); @@ -618,7 +616,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(0); if (_responseBox) { _responseBox->weedResponses(); - stack->pushInt(_responseBox->_responses.getSize()); + stack->pushInt(_responseBox->_responses.size()); } else { script->runtimeError("Game.GetNumResponses: response box is not defined"); stack->pushNULL(); @@ -670,8 +668,8 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetCurrentDlgBranch") == 0) { stack->correctParams(0); - if (_dlgPendingBranches.getSize() > 0) { - stack->pushString(_dlgPendingBranches[_dlgPendingBranches.getSize() - 1]); + if (_dlgPendingBranches.size() > 0) { + stack->pushString(_dlgPendingBranches[_dlgPendingBranches.size() - 1]); } else { stack->pushNULL(); } @@ -715,10 +713,10 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); if (!val->isNULL()) { - for (int i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { AdInventory *inv = _inventories[i]; - for (int j = 0; j < inv->_takenItems.getSize(); j++) { + for (uint32 j = 0; j < inv->_takenItems.size(); j++) { if (val->getNative() == inv->_takenItems[j]) { stack->pushBool(true); return STATUS_OK; @@ -1021,7 +1019,7 @@ ScValue *AdGame::scGetProperty(const char *name) { // TotalNumItems ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TotalNumItems") == 0) { - _scValue->setInt(_items.getSize()); + _scValue->setInt(_items.size()); return _scValue; } @@ -1071,7 +1069,7 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { } else { if (value->isNative()) { _selectedItem = NULL; - for (int i = 0; i < _items.getSize(); i++) { + for (uint32 i = 0; i < _items.size(); i++) { if (_items[i] == value->getNative()) { _selectedItem = (AdItem *)value->getNative(); break; @@ -1548,7 +1546,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { BaseParser parser; if (!merge) { - while (_items.getSize() > 0) { + while (_items.size() > 0) { deleteItem(_items[0]); } } @@ -1599,7 +1597,7 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { } } - for (int i = 0; i < _sceneStates.getSize(); i++) { + for (uint32 i = 0; i < _sceneStates.size(); i++) { if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { delete[] filenameCor; return _sceneStates[i]; @@ -1692,8 +1690,8 @@ bool AdGame::startDlgBranch(const char *branchName, const char *scriptName, cons bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { char *name = NULL; bool deleteName = false; - if (branchName == NULL && _dlgPendingBranches.getSize() > 0) { - name = _dlgPendingBranches[_dlgPendingBranches.getSize() - 1]; + if (branchName == NULL && _dlgPendingBranches.size() > 0) { + name = _dlgPendingBranches[_dlgPendingBranches.size() - 1]; } else { if (branchName != NULL) { name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; @@ -1710,24 +1708,24 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const int startIndex = -1; - for (int i = _dlgPendingBranches.getSize() - 1; i >= 0; i--) { + for (int i = _dlgPendingBranches.size() - 1; i >= 0; i--) { if (scumm_stricmp(name, _dlgPendingBranches[i]) == 0) { startIndex = i; break; } } if (startIndex >= 0) { - for (int i = startIndex; i < _dlgPendingBranches.getSize(); i++) { + for (uint32 i = startIndex; i < _dlgPendingBranches.size(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); delete[] _dlgPendingBranches[i]; _dlgPendingBranches[i] = NULL; } - _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.getSize() - startIndex); + _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.size() - startIndex); } // dialogue is over, forget selected responses - if (_dlgPendingBranches.getSize() == 0) { - for (int i = 0; i < _responsesBranch.getSize(); i++) { + if (_dlgPendingBranches.size() == 0) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { delete _responsesBranch[i]; } _responsesBranch.clear(); @@ -1743,7 +1741,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const ////////////////////////////////////////////////////////////////////////// bool AdGame::clearBranchResponses(char *name) { - for (int i = 0; i < _responsesBranch.getSize(); i++) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; _responsesBranch.remove_at(i); @@ -1761,7 +1759,7 @@ bool AdGame::addBranchResponse(int id) { } AdResponseContext *r = new AdResponseContext(_gameRef); r->_id = id; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); _responsesBranch.add(r); return STATUS_OK; } @@ -1769,8 +1767,8 @@ bool AdGame::addBranchResponse(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::branchResponseUsed(int id) { - char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesBranch.getSize(); i++) { + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; + for (uint32 i = 0; i < _responsesBranch.size(); i++) { if (_responsesBranch[i]->_id == id) { if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { return true; @@ -1788,7 +1786,7 @@ bool AdGame::addGameResponse(int id) { } AdResponseContext *r = new AdResponseContext(_gameRef); r->_id = id; - r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL); + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); _responsesGame.add(r); return STATUS_OK; } @@ -1796,8 +1794,8 @@ bool AdGame::addGameResponse(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::gameResponseUsed(int id) { - char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; - for (int i = 0; i < _responsesGame.getSize(); i++) { + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; + for (uint32 i = 0; i < _responsesGame.size(); i++) { AdResponseContext *respContext = _responsesGame[i]; if (respContext->_id == id) { if ((context == NULL && respContext->_context == NULL) || ((context != NULL && respContext->_context != NULL) && scumm_stricmp(context, respContext->_context) == 0)) { @@ -1811,9 +1809,9 @@ bool AdGame::gameResponseUsed(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::resetResponse(int id) { - char *context = _dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL; + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; - for (int i = 0; i < _responsesGame.getSize(); i++) { + for (uint32 i = 0; i < _responsesGame.size(); i++) { if (_responsesGame[i]->_id == id) { if ((context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(context, _responsesGame[i]->_context) == 0) { delete _responsesGame[i]; @@ -1823,7 +1821,7 @@ bool AdGame::resetResponse(int id) { } } - for (int i = 0; i < _responsesBranch.getSize(); i++) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { if (_responsesBranch[i]->_id == id) { if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; @@ -1922,7 +1920,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { ////////////////////////////////////////////////////////////////////////// bool AdGame::registerInventory(AdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { if (_inventories[i] == inv) { return STATUS_OK; } @@ -1935,7 +1933,7 @@ bool AdGame::registerInventory(AdInventory *inv) { ////////////////////////////////////////////////////////////////////////// bool AdGame::unregisterInventory(AdInventory *inv) { - for (int i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { if (_inventories[i] == inv) { unregisterObject(_inventories[i]); _inventories.remove_at(i); @@ -1947,11 +1945,11 @@ bool AdGame::unregisterInventory(AdInventory *inv) { ////////////////////////////////////////////////////////////////////////// bool AdGame::isItemTaken(char *itemName) { - for (int i = 0; i < _inventories.getSize(); i++) { - AdInventory *Inv = _inventories[i]; + for (uint32 i = 0; i < _inventories.size(); i++) { + AdInventory *inv = _inventories[i]; - for (int j = 0; j < Inv->_takenItems.getSize(); j++) { - if (scumm_stricmp(itemName, Inv->_takenItems[j]->getName()) == 0) { + for (uint32 j = 0; j < inv->_takenItems.size(); j++) { + if (scumm_stricmp(itemName, inv->_takenItems[j]->getName()) == 0) { return true; } } @@ -1961,7 +1959,7 @@ bool AdGame::isItemTaken(char *itemName) { ////////////////////////////////////////////////////////////////////////// AdItem *AdGame::getItemByName(const char *name) { - for (int i = 0; i < _items.getSize(); i++) { + for (uint32 i = 0; i < _items.size(); i++) { if (scumm_stricmp(_items[i]->getName(), name) == 0) { return _items[i]; } @@ -1980,31 +1978,31 @@ bool AdGame::addItem(AdItem *item) { ////////////////////////////////////////////////////////////////////////// bool AdGame::resetContent() { // clear pending dialogs - for (int i = 0; i < _dlgPendingBranches.getSize(); i++) { + for (uint32 i = 0; i < _dlgPendingBranches.size(); i++) { delete[] _dlgPendingBranches[i]; } _dlgPendingBranches.clear(); // clear inventories - for (int i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { _inventories[i]->_takenItems.clear(); } // clear scene states - for (int i = 0; i < _sceneStates.getSize(); i++) { + for (uint32 i = 0; i < _sceneStates.size(); i++) { delete _sceneStates[i]; } _sceneStates.clear(); // clear once responses - for (int i = 0; i < _responsesBranch.getSize(); i++) { + for (uint32 i = 0; i < _responsesBranch.size(); i++) { delete _responsesBranch[i]; } _responsesBranch.clear(); // clear once game responses - for (int i = 0; i < _responsesGame.getSize(); i++) { + for (uint32 i = 0; i < _responsesGame.size(); i++) { delete _responsesGame[i]; } _responsesGame.clear(); @@ -2032,12 +2030,12 @@ bool AdGame::deleteItem(AdItem *item) { _scene->handleItemAssociations(item->getName(), false); // remove from all inventories - for (int i = 0; i < _inventories.getSize(); i++) { + for (uint32 i = 0; i < _inventories.size(); i++) { _inventories[i]->removeItem(item); } // remove object - for (int i = 0; i < _items.getSize(); i++) { + for (uint32 i = 0; i < _items.size(); i++) { if (_items[i] == item) { unregisterObject(_items[i]); _items.remove_at(i); @@ -2061,7 +2059,7 @@ bool AdGame::addSpeechDir(const char *dir) { strcat(temp, "\\"); } - for (int i = 0; i < _speechDirs.getSize(); i++) { + for (uint32 i = 0; i < _speechDirs.size(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete[] temp; return STATUS_OK; @@ -2086,7 +2084,7 @@ bool AdGame::removeSpeechDir(const char *dir) { } bool found = false; - for (int i = 0; i < _speechDirs.getSize(); i++) { + for (uint32 i = 0; i < _speechDirs.size(); i++) { if (scumm_stricmp(_speechDirs[i], temp) == 0) { delete[] _speechDirs[i]; _speechDirs.remove_at(i); @@ -2104,7 +2102,7 @@ bool AdGame::removeSpeechDir(const char *dir) { char *AdGame::findSpeechFile(char *stringID) { char *ret = new char[MAX_PATH_LENGTH]; - for (int i = 0; i < _speechDirs.getSize(); i++) { + for (uint32 i = 0; i < _speechDirs.size(); i++) { sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID); if (BaseFileManager::getEngineInstance()->hasFile(ret)) { return ret; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 282c37449b..44b2dc0508 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -60,7 +60,7 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { } int insertIndex = -1; - for (int i = 0; i < _takenItems.getSize(); i++) { + for (uint32 i = 0; i < _takenItems.size(); i++) { if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { _takenItems.remove_at(i); i--; @@ -88,7 +88,7 @@ bool AdInventory::removeItem(const char *name) { return STATUS_FAILED; } - for (int i = 0; i < _takenItems.getSize(); i++) { + for (uint32 i = 0; i < _takenItems.size(); i++) { if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { ((AdGame *)_gameRef)->_selectedItem = NULL; @@ -109,7 +109,7 @@ bool AdInventory::removeItem(AdItem *item) { return STATUS_FAILED; } - for (int i = 0; i < _takenItems.getSize(); i++) { + for (uint32 i = 0; i < _takenItems.size(); i++) { if (_takenItems[i] == item) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { ((AdGame *)_gameRef)->_selectedItem = NULL; diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index fd49860a5c..ad679007df 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -113,7 +113,7 @@ bool AdInventoryBox::display() { if (_window) { _window->enableWidget("prev", _scrollOffset > 0); - _window->enableWidget("next", _scrollOffset + itemsX * itemsY < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()); + _window->enableWidget("next", _scrollOffset + itemsX * itemsY < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()); } @@ -142,7 +142,7 @@ bool AdInventoryBox::display() { int xxx = rect.left; for (int i = 0; i < itemsX; i++) { int itemIndex = _scrollOffset + j * itemsX + i; - if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) { + if (itemIndex >= 0 && itemIndex < (int32)adGame->_inventoryOwner->getInventory()->_takenItems.size()) { AdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex]; if (item != ((AdGame *)_gameRef)->_selectedItem || !_hideSelected) { item->update(); @@ -321,7 +321,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { _visible = alwaysVisible; if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { + for (uint32 i = 0; i < _window->_widgets.size(); i++) { if (!_window->_widgets[i]->_listenerObject) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 2cec37bec1..709ab50b58 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -53,7 +53,7 @@ AdLayer::AdLayer(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdLayer::~AdLayer() { - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { delete _nodes[i]; } _nodes.clear(); @@ -243,7 +243,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (val->_type == VAL_INT) { node = val->getInt(); } else { // get by name - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->getName(), val->getString()) == 0) || (_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->getName(), val->getString()) == 0)) { node = i; @@ -252,7 +252,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } - if (node < 0 || node >= _nodes.getSize()) { + if (node < 0 || node >= (int32)_nodes.size()) { stack->pushNULL(); } else { switch (_nodes[node]->_type) { @@ -323,7 +323,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (index < 0) { index = 0; } - if (index <= _nodes.getSize() - 1) { + if (index <= (int32)_nodes.size() - 1) { _nodes.insert_at(index, node); } else { _nodes.add(node); @@ -342,7 +342,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdSceneNode *toDelete = NULL; if (val->isNative()) { BaseScriptable *temp = val->getNative(); - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { if (_nodes[i]->_region == temp || _nodes[i]->_entity == temp) { toDelete = _nodes[i]; break; @@ -350,7 +350,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } else { int index = val->getInt(); - if (index >= 0 && index < _nodes.getSize()) { + if (index >= 0 && index < (int32)_nodes.size()) { toDelete = _nodes[index]; } } @@ -359,7 +359,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { if (_nodes[i] == toDelete) { delete _nodes[i]; _nodes[i] = NULL; @@ -391,7 +391,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumNodes") == 0) { - _scValue->setInt(_nodes.getSize()); + _scValue->setInt(_nodes.size()); return _scValue; } @@ -516,9 +516,7 @@ bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "CLOSE_UP=%s\n", _closeUp ? "TRUE" : "FALSE"); } - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -526,7 +524,7 @@ bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) { _scProp->saveAsText(buffer, indent + 2); } - for (i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { switch (_nodes[i]->_type) { case OBJECT_ENTITY: _nodes[i]->_entity->saveAsText(buffer, indent + 2); diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 59781087a3..a02decebdb 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -143,12 +143,12 @@ AdObject::~AdObject() { } - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { _gameRef->unregisterObject(_attachmentsPre[i]); } _attachmentsPre.clear(); - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { _gameRef->unregisterObject(_attachmentsPost[i]); } _attachmentsPost.clear(); @@ -305,14 +305,14 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack AdLayer *main = ((AdGame *)_gameRef)->_scene->_mainLayer; bool regFound = false; - int i; + uint32 i; ScValue *val = stack->pop(); if (val->isNULL() || !main) { _stickRegion = NULL; regFound = true; } else if (val->isString()) { const char *regionName = val->getString(); - for (i = 0; i < main->_nodes.getSize(); i++) { + for (i = 0; i < main->_nodes.size(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->getName() && scumm_stricmp(main->_nodes[i]->_region->getName(), regionName) == 0) { _stickRegion = main->_nodes[i]->_region; regFound = true; @@ -322,7 +322,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } else if (val->isNative()) { BaseScriptable *obj = val->getNative(); - for (i = 0; i < main->_nodes.getSize(); i++) { + for (i = 0; i < main->_nodes.size(); i++) { if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region == obj) { _stickRegion = main->_nodes[i]->_region; regFound = true; @@ -446,7 +446,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } else { stack->pushNULL(); } - } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize()) { + } else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= (int32)_inventory->_takenItems.size()) { stack->pushNULL(); } else { stack->pushNative(_inventory->_takenItems[val->getInt()], true); @@ -468,7 +468,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (!val->isNULL()) { - for (int i = 0; i < _inventory->_takenItems.getSize(); i++) { + for (uint32 i = 0; i < _inventory->_takenItems.size(); i++) { if (val->getNative() == _inventory->_takenItems[i]) { stack->pushBool(true); return STATUS_OK; @@ -563,7 +563,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool found = false; if (val->isNative()) { BaseScriptable *obj = val->getNative(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); @@ -571,7 +571,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack i--; } } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i] == obj) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); @@ -581,7 +581,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } else { const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPre[i]); @@ -589,7 +589,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack i--; } } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { found = true; _gameRef->unregisterObject(_attachmentsPost[i]); @@ -614,13 +614,13 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (val->isInt()) { int index = val->getInt(); int currIndex = 0; - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (currIndex == index) { ret = _attachmentsPre[i]; } currIndex++; } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (currIndex == index) { ret = _attachmentsPost[i]; } @@ -628,14 +628,14 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } else { const char *attachmentName = val->getString(); - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; } } if (!ret) { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) { ret = _attachmentsPre[i]; break; @@ -737,7 +737,7 @@ ScValue *AdObject::scGetProperty(const char *name) { // NumItems (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumItems") == 0) { - _scValue->setInt(getInventory()->_takenItems.getSize()); + _scValue->setInt(getInventory()->_takenItems.size()); return _scValue; } @@ -758,7 +758,7 @@ ScValue *AdObject::scGetProperty(const char *name) { // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumAttachments") == 0) { - _scValue->setInt(_attachmentsPre.getSize() + _attachmentsPost.getSize()); + _scValue->setInt(_attachmentsPre.size() + _attachmentsPost.size()); return _scValue; } else { return BaseObject::scGetProperty(name); @@ -865,7 +865,7 @@ int AdObject::getHeight() { } else { BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; int ret = 0; - for (int i = 0; i < frame->_subframes.getSize(); i++) { + for (uint32 i = 0; i < frame->_subframes.size(); i++) { ret = MAX(ret, frame->_subframes[i]->_hotspotY); } @@ -1201,10 +1201,10 @@ bool AdObject::getScale(float *scaleX, float *scaleY) { ////////////////////////////////////////////////////////////////////////// bool AdObject::updateSpriteAttachments() { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { _attachmentsPre[i]->update(); } - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { _attachmentsPost[i]->update(); } return STATUS_OK; @@ -1213,11 +1213,11 @@ bool AdObject::updateSpriteAttachments() { ////////////////////////////////////////////////////////////////////////// bool AdObject::displaySpriteAttachments(bool preDisplay) { if (preDisplay) { - for (int i = 0; i < _attachmentsPre.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPre.size(); i++) { displaySpriteAttachment(_attachmentsPre[i]); } } else { - for (int i = 0; i < _attachmentsPost.getSize(); i++) { + for (uint32 i = 0; i < _attachmentsPost.size(); i++) { displaySpriteAttachment(_attachmentsPost[i]); } } diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index 0c0ec63e0f..21b68f4d48 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -48,7 +48,7 @@ AdPath::~AdPath() { ////////////////////////////////////////////////////////////////////////// void AdPath::reset() { - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } @@ -60,7 +60,7 @@ void AdPath::reset() { ////////////////////////////////////////////////////////////////////////// BasePoint *AdPath::getFirst() { - if (_points.getSize() > 0) { + if (_points.size() > 0) { _currIndex = 0; return _points[_currIndex]; } else { @@ -72,7 +72,7 @@ BasePoint *AdPath::getFirst() { ////////////////////////////////////////////////////////////////////////// BasePoint *AdPath::getNext() { _currIndex++; - if (_currIndex < _points.getSize()) { + if (_currIndex < (int32)_points.size()) { return _points[_currIndex]; } else { return NULL; @@ -82,7 +82,7 @@ BasePoint *AdPath::getNext() { ////////////////////////////////////////////////////////////////////////// BasePoint *AdPath::getCurrent() { - if (_currIndex >= 0 && _currIndex < _points.getSize()) { + if (_currIndex >= 0 && _currIndex < (int32)_points.size()) { return _points[_currIndex]; } else { return NULL; diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 3b9d4fadda..3e5f91524d 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -128,7 +128,7 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) { buffer = params; } - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -362,8 +362,7 @@ bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - int i; - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -371,7 +370,7 @@ bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) { _scProp->saveAsText(buffer, indent + 2); } - for (i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index d467509612..76510e2f3e 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -98,7 +98,7 @@ AdResponseBox::~AdResponseBox() { ////////////////////////////////////////////////////////////////////////// void AdResponseBox::clearResponses() { - for (int i = 0; i < _responses.getSize(); i++) { + for (uint32 i = 0; i < _responses.size(); i++) { delete _responses[i]; } _responses.clear(); @@ -107,7 +107,7 @@ void AdResponseBox::clearResponses() { ////////////////////////////////////////////////////////////////////////// void AdResponseBox::clearButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { + for (uint32 i = 0; i < _respButtons.size(); i++) { delete _respButtons[i]; } _respButtons.clear(); @@ -116,7 +116,7 @@ void AdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::invalidateButtons() { - for (int i = 0; i < _respButtons.getSize(); i++) { + for (uint32 i = 0; i < _respButtons.size(); i++) { _respButtons[i]->_image = NULL; _respButtons[i]->_cursor = NULL; _respButtons[i]->_font = NULL; @@ -133,7 +133,7 @@ bool AdResponseBox::createButtons() { clearButtons(); _scrollOffset = 0; - for (int i = 0; i < _responses.getSize(); i++) { + for (uint32 i = 0; i < _responses.size(); i++) { UIButton *btn = new UIButton(_gameRef); if (btn) { btn->_parent = _window; @@ -363,7 +363,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { } if (_window) { - for (int i = 0; i < _window->_widgets.getSize(); i++) { + for (uint32 i = 0; i < _window->_widgets.size(); i++) { if (!_window->_widgets[i]->_listenerObject) { _window->_widgets[i]->setListener(this, _window->_widgets[i], 0); } @@ -447,7 +447,8 @@ bool AdResponseBox::display() { //_window->display(); } - int xxx, yyy, i; + int xxx, yyy; + uint32 i; xxx = rect.left; yyy = rect.top; @@ -455,7 +456,7 @@ bool AdResponseBox::display() { // shift down if needed if (!_horizontal) { int totalHeight = 0; - for (i = 0; i < _respButtons.getSize(); i++) { + for (i = 0; i < _respButtons.size(); i++) { totalHeight += (_respButtons[i]->_height + _spacing); } totalHeight -= _spacing; @@ -481,7 +482,7 @@ bool AdResponseBox::display() { // prepare response buttons bool scrollNeeded = false; - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + for (i = _scrollOffset; i < _respButtons.size(); i++) { if ((_horizontal && xxx + _respButtons[i]->_width > rect.right) || (!_horizontal && yyy + _respButtons[i]->_height > rect.bottom)) { @@ -523,7 +524,7 @@ bool AdResponseBox::display() { // display response buttons - for (i = _scrollOffset; i < _respButtons.getSize(); i++) { + for (i = _scrollOffset; i < _respButtons.size(); i++) { _respButtons[i]->display(); } @@ -593,7 +594,7 @@ bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { bool AdResponseBox::weedResponses() { AdGame *adGame = (AdGame *)_gameRef; - for (int i = 0; i < _responses.getSize(); i++) { + for (uint32 i = 0; i < _responses.size(); i++) { switch (_responses[i]->_responseType) { case RESPONSE_ONCE: if (adGame->branchResponseUsed(_responses[i]->_iD)) { @@ -653,13 +654,13 @@ BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { BaseArray objects; getObjects(objects, true); - if (objects.getSize() == 0) { + if (objects.size() == 0) { return NULL; } else { if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { + for (uint32 i = 0; i < objects.size(); i++) { if (objects[i] == currObject) { - if (i < objects.getSize() - 1) { + if (i < objects.size() - 1) { return objects[i + 1]; } else { break; @@ -677,11 +678,11 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { BaseArray objects; getObjects(objects, true); - if (objects.getSize() == 0) { + if (objects.size() == 0) { return NULL; } else { if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { + for (int i = objects.size() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) { return objects[i - 1]; @@ -691,14 +692,14 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { } } } - return objects[objects.getSize() - 1]; + return objects[objects.size() - 1]; } return NULL; } ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::getObjects(BaseArray &objects, bool interactiveOnly) { - for (int i = 0; i < _respButtons.getSize(); i++) { + for (uint32 i = 0; i < _respButtons.size(); i++) { objects.add(_respButtons[i]); } if (_window) { diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index b04f48f1fc..176604b75f 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -141,43 +141,41 @@ void AdScene::cleanup() { _mainLayer = NULL; // reference only - int i; - delete _shieldWindow; _shieldWindow = NULL; _gameRef->unregisterObject(_fader); _fader = NULL; - for (i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { _gameRef->unregisterObject(_layers[i]); } _layers.clear(); - for (i = 0; i < _waypointGroups.getSize(); i++) { + for (uint32 i = 0; i < _waypointGroups.size(); i++) { _gameRef->unregisterObject(_waypointGroups[i]); } _waypointGroups.clear(); - for (i = 0; i < _scaleLevels.getSize(); i++) { + for (uint32 i = 0; i < _scaleLevels.size(); i++) { _gameRef->unregisterObject(_scaleLevels[i]); } _scaleLevels.clear(); - for (i = 0; i < _rotLevels.getSize(); i++) { + for (uint32 i = 0; i < _rotLevels.size(); i++) { _gameRef->unregisterObject(_rotLevels[i]); } _rotLevels.clear(); - for (i = 0; i < _pfPath.getSize(); i++) { + for (uint32 i = 0; i < _pfPath.size(); i++) { delete _pfPath[i]; } _pfPath.clear(); _pfPointsNum = 0; - for (i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { _gameRef->unregisterObject(_objects[i]); } _objects.clear(); @@ -203,7 +201,6 @@ bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObje _pfTargetPath->setReady(false); // prepare working path - int i; pfPointsStart(); // first point @@ -239,7 +236,7 @@ bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObje pfPointsAdd(target.x, target.y, INT_MAX); // active waypoints - for (i = 0; i < _waypointGroups.getSize(); i++) { + for (uint32 i = 0; i < _waypointGroups.size(); i++) { if (_waypointGroups[i]->_active) { pfAddWaypointGroup(_waypointGroups[i], requester); } @@ -247,13 +244,13 @@ bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObje // free waypoints - for (i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentWptGroup) { pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester); } } AdGame *adGame = (AdGame *)_gameRef; - for (i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) { pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester); } @@ -270,7 +267,7 @@ void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { return; } - for (int i = 0; i < wpt->_points.getSize(); i++) { + for (uint32 i = 0; i < wpt->_points.size(); i++) { if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) { continue; } @@ -287,7 +284,7 @@ float AdScene::getZoomAt(int x, int y) { bool found = false; if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { if (node->_region->_zoom != 0) { @@ -320,7 +317,7 @@ uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) { } if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { if (!node->_region->_blocked) { @@ -338,9 +335,8 @@ uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) { bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *requester) { bool ret = true; - if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { return true; @@ -348,7 +344,7 @@ bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *reque } } AdGame *adGame = (AdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { return true; @@ -359,7 +355,7 @@ bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *reque if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + for (uint32 i = 0; i < _mainLayer->_nodes.size(); i++) { AdSceneNode *node = _mainLayer->_nodes[i]; /* if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->_blocked && Node->_region->PointInRegion(X, Y)) @@ -387,7 +383,7 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ bool ret = false; if (checkFreeObjects) { - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i] != requester && _objects[i]->_currentBlockRegion) { if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { return false; @@ -395,7 +391,7 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ } } AdGame *adGame = (AdGame *)_gameRef; - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) { if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) { return false; @@ -406,7 +402,7 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ if (_mainLayer) { - for (int i = 0; i < _mainLayer->_nodes.getSize(); i++) { + for (uint32 i = 0; i < _mainLayer->_nodes.size(); i++) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { if (node->_region->_blocked) { @@ -907,7 +903,6 @@ bool AdScene::traverseNodes(bool doUpdate) { return STATUS_OK; } - int j, k; AdGame *adGame = (AdGame *)_gameRef; @@ -995,7 +990,7 @@ bool AdScene::traverseNodes(bool doUpdate) { /* int mainOffsetX = 0; */ /* int mainOffsetY = 0; */ - for (j = 0; j < _layers.getSize(); j++) { + for (uint32 j = 0; j < _layers.size(); j++) { if (!_layers[j]->_active) { continue; } @@ -1033,7 +1028,7 @@ bool AdScene::traverseNodes(bool doUpdate) { // for each node - for (k = 0; k < _layers[j]->_nodes.getSize(); k++) { + for (uint32 k = 0; k < _layers[j]->_nodes.size(); k++) { AdSceneNode *node = _layers[j]->_nodes[k]; switch (node->_type) { case OBJECT_ENTITY: @@ -1112,7 +1107,7 @@ bool AdScene::updateFreeObjects() { // *** update all active objects // is3DSet = false; - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { if (!adGame->_objects[i]->_active) { continue; } @@ -1122,7 +1117,7 @@ bool AdScene::updateFreeObjects() { } - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (!_objects[i]->_active) { continue; } @@ -1148,7 +1143,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { AdObject *obj; // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { obj = adGame->_objects[i]; if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { objects.add(obj); @@ -1156,7 +1151,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { } // scene objects - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { obj = _objects[i]; if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { objects.add(obj); @@ -1167,7 +1162,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { Common::sort(objects.begin(), objects.end(), AdScene::compareObjs); // display them - for (int i = 0; i < objects.getSize(); i++) { + for (uint32 i = 0; i < objects.size(); i++) { obj = objects[i]; if (display3DOnly && !obj->_is3D) { @@ -1186,7 +1181,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { // display design only objects if (!display3DOnly) { if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1223,7 +1218,7 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { int minY = INT_MAX; // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { obj = adGame->_objects[i]; minY = adGame->_objects[i]->_posY; @@ -1231,7 +1226,7 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { } // scene objects - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { obj = _objects[i]; minY = _objects[i]->_posY; @@ -1252,7 +1247,7 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { // design only objects if (_gameRef->_editorMode && region == NULL) { - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); _objects[i]->_drawn = true; @@ -1443,7 +1438,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ScValue *val = stack->pop(); if (val->isInt()) { int layer = val->getInt(); - if (layer < 0 || layer >= _layers.getSize()) { + if (layer < 0 || layer >= (int32)_layers.size()) { stack->pushNULL(); } else { stack->pushNative(_layers[layer], true); @@ -1451,7 +1446,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } else { const char *layerName = val->getString(); bool layerFound = false; - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { if (scumm_stricmp(layerName, _layers[i]->getName()) == 0) { stack->pushNative(_layers[i], true); layerFound = true; @@ -1471,7 +1466,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "GetWaypointGroup") == 0) { stack->correctParams(1); int group = stack->pop()->getInt(); - if (group < 0 || group >= _waypointGroups.getSize()) { + if (group < 0 || group >= (int32)_waypointGroups.size()) { stack->pushNULL(); } else { stack->pushNative(_waypointGroups[group], true); @@ -1506,12 +1501,12 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdObject *ret = NULL; if (val->isInt()) { int index = val->getInt(); - if (index >= 0 && index < _objects.getSize()) { + if (index >= 0 && index < (int32)_objects.size()) { ret = _objects[index]; } } else { const char *nodeName = val->getString(); - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i] && _objects[i]->getName() && scumm_stricmp(_objects[i]->getName(), nodeName) == 0) { ret = _objects[i]; break; @@ -1542,7 +1537,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (node->_region->_decoration && !includeDecors) { @@ -1752,7 +1747,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (index < 0) { index = 0; } - if (index <= _layers.getSize() - 1) { + if (index <= (int32)_layers.size() - 1) { _layers.insert_at(index, layer); } else { _layers.add(layer); @@ -1774,7 +1769,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, AdLayer *toDelete = NULL; if (val->isNative()) { BaseScriptable *temp = val->getNative(); - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { if (_layers[i] == temp) { toDelete = _layers[i]; break; @@ -1782,7 +1777,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } } else { int index = val->getInt(); - if (index >= 0 && index < _layers.getSize()) { + if (index >= 0 && index < (int32)_layers.size()) { toDelete = _layers[index]; } } @@ -1797,7 +1792,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { if (_layers[i] == toDelete) { _layers.remove_at(i); _gameRef->unregisterObject(toDelete); @@ -1828,7 +1823,7 @@ ScValue *AdScene::scGetProperty(const char *name) { // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLayers") == 0) { - _scValue->setInt(_layers.getSize()); + _scValue->setInt(_layers.size()); return _scValue; } @@ -1836,7 +1831,7 @@ ScValue *AdScene::scGetProperty(const char *name) { // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWaypointGroups") == 0) { - _scValue->setInt(_waypointGroups.getSize()); + _scValue->setInt(_waypointGroups.size()); return _scValue; } @@ -1857,7 +1852,7 @@ ScValue *AdScene::scGetProperty(const char *name) { // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFreeNodes") == 0) { - _scValue->setInt(_objects.getSize()); + _scValue->setInt(_objects.size()); return _scValue; } @@ -2101,7 +2096,7 @@ bool AdScene::addObject(AdObject *object) { ////////////////////////////////////////////////////////////////////////// bool AdScene::removeObject(AdObject *object) { - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i] == object) { _objects.remove_at(i); return _gameRef->unregisterObject(object); @@ -2113,8 +2108,6 @@ bool AdScene::removeObject(AdObject *object) { ////////////////////////////////////////////////////////////////////////// bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { - int i; - buffer->putTextIndent(indent, "SCENE {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); @@ -2130,7 +2123,7 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // scripts - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -2178,7 +2171,7 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // waypoints buffer->putTextIndent(indent + 2, "; ----- waypoints\n"); - for (i = 0; i < _waypointGroups.getSize(); i++) { + for (uint32 i = 0; i < _waypointGroups.size(); i++) { _waypointGroups[i]->saveAsText(buffer, indent + 2); } @@ -2186,19 +2179,19 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // layers buffer->putTextIndent(indent + 2, "; ----- layers\n"); - for (i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { _layers[i]->saveAsText(buffer, indent + 2); } // scale levels buffer->putTextIndent(indent + 2, "; ----- scale levels\n"); - for (i = 0; i < _scaleLevels.getSize(); i++) { + for (uint32 i = 0; i < _scaleLevels.size(); i++) { _scaleLevels[i]->saveAsText(buffer, indent + 2); } // rotation levels buffer->putTextIndent(indent + 2, "; ----- rotation levels\n"); - for (i = 0; i < _rotLevels.getSize(); i++) { + for (uint32 i = 0; i < _rotLevels.size(); i++) { _rotLevels[i]->saveAsText(buffer, indent + 2); } @@ -2207,15 +2200,13 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // free entities buffer->putTextIndent(indent + 2, "; ----- free entities\n"); - for (i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { _objects[i]->saveAsText(buffer, indent + 2); } } - - buffer->putTextIndent(indent, "}\n"); return STATUS_OK; } @@ -2226,7 +2217,7 @@ bool AdScene::sortScaleLevels() { bool changed; do { changed = false; - for (int i = 0; i < _scaleLevels.getSize() - 1; i++) { + for (uint32 i = 0; i < _scaleLevels.size() - 1; i++) { if (_scaleLevels[i]->_posY > _scaleLevels[i + 1]->_posY) { AdScaleLevel *sl = _scaleLevels[i]; _scaleLevels[i] = _scaleLevels[i + 1]; @@ -2247,7 +2238,7 @@ bool AdScene::sortRotLevels() { bool changed; do { changed = false; - for (int i = 0; i < _rotLevels.getSize() - 1; i++) { + for (uint32 i = 0; i < _rotLevels.size() - 1; i++) { if (_rotLevels[i]->_posX > _rotLevels[i + 1]->_posX) { AdRotLevel *rl = _rotLevels[i]; _rotLevels[i] = _rotLevels[i + 1]; @@ -2268,9 +2259,9 @@ float AdScene::getScaleAt(int Y) { AdScaleLevel *prev = NULL; AdScaleLevel *next = NULL; - for (int i = 0; i < _scaleLevels.getSize(); i++) { + for (uint32 i = 0; i < _scaleLevels.size(); i++) { /* AdScaleLevel *xxx = _scaleLevels[i];*/ - /* int j = _scaleLevels.getSize(); */ + /* int j = _scaleLevels.size(); */ if (_scaleLevels[i]->_posY < Y) { prev = _scaleLevels[i]; } else { @@ -2517,7 +2508,7 @@ void AdScene::pfPointsStart() { ////////////////////////////////////////////////////////////////////////// void AdScene::pfPointsAdd(int x, int y, int distance) { - if (_pfPointsNum >= _pfPath.getSize()) { + if (_pfPointsNum >= (int32)_pfPath.size()) { _pfPath.add(new AdPathPoint(x, y, distance)); } else { _pfPath[_pfPointsNum]->x = x; @@ -2630,9 +2621,9 @@ BaseObject *AdScene::getNodeByName(const char *name) { BaseObject *ret = NULL; // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { AdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { + for (uint32 j = 0; j < layer->_nodes.size(); j++) { AdSceneNode *node = layer->_nodes[j]; if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->getName())) || (node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->getName()))) { @@ -2652,14 +2643,14 @@ BaseObject *AdScene::getNodeByName(const char *name) { } // free entities - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->getName())) { return _objects[i]; } } // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { + for (uint32 i = 0; i < _waypointGroups.size(); i++) { if (!scumm_stricmp(name, _waypointGroups[i]->getName())) { return _waypointGroups[i]; } @@ -2696,9 +2687,9 @@ bool AdScene::persistState(bool saving) { AdNodeState *nodeState; // dependent objects - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { AdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { + for (uint32 j = 0; j < layer->_nodes.size(); j++) { AdSceneNode *node = layer->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: @@ -2733,7 +2724,7 @@ bool AdScene::persistState(bool saving) { } // free entities - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (!_objects[i]->_saveState) { continue; } @@ -2748,7 +2739,7 @@ bool AdScene::persistState(bool saving) { } // waypoint groups - for (int i = 0; i < _waypointGroups.getSize(); i++) { + for (uint32 i = 0; i < _waypointGroups.size(); i++) { nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving); if (nodeState) { if (saving) { @@ -2768,9 +2759,9 @@ float AdScene::getRotationAt(int x, int y) { AdRotLevel *prev = NULL; AdRotLevel *next = NULL; - for (int i = 0; i < _rotLevels.getSize(); i++) { + for (uint32 i = 0; i < _rotLevels.size(); i++) { /* AdRotLevel *xxx = _rotLevels[i]; - int j = _rotLevels.getSize();*/ + int j = _rotLevels.size();*/ if (_rotLevels[i]->_posX < x) { prev = _rotLevels[i]; } else { @@ -2794,9 +2785,9 @@ float AdScene::getRotationAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool AdScene::handleItemAssociations(const char *itemName, bool show) { - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { AdLayer *layer = _layers[i]; - for (int j = 0; j < layer->_nodes.getSize(); j++) { + for (uint32 j = 0; j < layer->_nodes.size(); j++) { if (layer->_nodes[j]->_type == OBJECT_ENTITY) { AdEntity *ent = layer->_nodes[j]->_entity; @@ -2807,7 +2798,7 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { } } - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_type == OBJECT_ENTITY) { AdEntity *ent = (AdEntity *)_objects[i]; if (ent->_item && strcmp(ent->_item, itemName) == 0) { @@ -2824,7 +2815,7 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) { int numUsed = 0; if (_mainLayer) { - for (int i = _mainLayer->_nodes.getSize() - 1; i >= 0; i--) { + for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { if (numUsed < numRegions - 1) { @@ -2854,13 +2845,13 @@ BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { BaseArray objects; getSceneObjects(objects, true); - if (objects.getSize() == 0) { + if (objects.size() == 0) { return NULL; } else { if (currObject != NULL) { - for (int i = 0; i < objects.getSize(); i++) { + for (uint32 i = 0; i < objects.size(); i++) { if (objects[i] == currObject) { - if (i < objects.getSize() - 1) { + if (i < objects.size() - 1) { return objects[i + 1]; } else { break; @@ -2878,11 +2869,11 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { BaseArray objects; getSceneObjects(objects, true); - if (objects.getSize() == 0) { + if (objects.size() == 0) { return NULL; } else { if (currObject != NULL) { - for (int i = objects.getSize() - 1; i >= 0; i--) { + for (int i = objects.size() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) { return objects[i - 1]; @@ -2892,7 +2883,7 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { } } } - return objects[objects.getSize() - 1]; + return objects[objects.size() - 1]; } return NULL; } @@ -2900,14 +2891,14 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { ////////////////////////////////////////////////////////////////////////// bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOnly) { - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { // close-up layer -> remove everything below it if (interactiveOnly && _layers[i]->_closeUp) { objects.clear(); } - for (int j = 0; j < _layers[i]->_nodes.getSize(); j++) { + for (uint32 j = 0; j < _layers[i]->_nodes.size(); j++) { AdSceneNode *node = _layers[i]->_nodes[j]; switch (node->_type) { case OBJECT_ENTITY: { @@ -2921,9 +2912,9 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOn case OBJECT_REGION: { BaseArray regionObj; getRegionObjects(node->_region, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { bool found = false; - for (int old = 0; old < objects.getSize(); old++) { + for (uint32 old = 0; old < objects.size(); old++) { if (objects[old] == regionObj[newIndex]) { found = true; break; @@ -2933,7 +2924,7 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOn objects.add(regionObj[newIndex]); } } - //if (RegionObj.getSize() > 0) Objects.Append(RegionObj); + //if (regionObj.size() > 0) Objects.Append(RegionObj); } break; default: @@ -2946,9 +2937,9 @@ bool AdScene::getSceneObjects(BaseArray &objects, bool interactiveOn // objects outside any region BaseArray regionObj; getRegionObjects(NULL, regionObj, interactiveOnly); - for (int newIndex = 0; newIndex < regionObj.getSize(); newIndex++) { + for (uint32 newIndex = 0; newIndex < regionObj.size(); newIndex++) { bool found = false; - for (int old = 0; old < objects.getSize(); old++) { + for (uint32 old = 0; old < objects.size(); old++) { if (objects[old] == regionObj[newIndex]) { found = true; break; @@ -2970,7 +2961,7 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, AdObject *obj; // global objects - for (int i = 0; i < adGame->_objects.getSize(); i++) { + for (uint32 i = 0; i < adGame->_objects.size(); i++) { obj = adGame->_objects[i]; if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) { @@ -2982,7 +2973,7 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray &objects, } // scene objects - for (int i = 0; i < _objects.getSize(); i++) { + for (uint32 i = 0; i < _objects.size(); i++) { obj = _objects[i]; if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) { diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 4a85148540..04fd52c382 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -47,7 +47,7 @@ AdSceneState::~AdSceneState() { delete[] _filename; _filename = NULL; - for (int i = 0; i < _nodeStates.getSize(); i++) { + for (uint32 i = 0; i < _nodeStates.size(); i++) { delete _nodeStates[i]; } _nodeStates.clear(); @@ -75,7 +75,7 @@ void AdSceneState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { - for (int i = 0; i < _nodeStates.getSize(); i++) { + for (uint32 i = 0; i < _nodeStates.size(); i++) { if (scumm_stricmp(_nodeStates[i]->getName(), name) == 0) { return _nodeStates[i]; } diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index 0c3080c9cd..51765e3fe9 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -318,7 +318,7 @@ bool AdSentence::update(TDirection dir) { currentTime = _gameRef->_timer - _startTime; bool talkNodeFound = false; - for (int i = 0; i < _talkDef->_nodes.getSize(); i++) { + for (uint32 i = 0; i < _talkDef->_nodes.size(); i++) { if (_talkDef->_nodes[i]->isInTimeInterval(currentTime, dir)) { talkNodeFound = true; diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index 08136d787e..cd96345fc8 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -52,7 +52,7 @@ AdTalkDef::AdTalkDef(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdTalkDef::~AdTalkDef() { - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { delete _nodes[i]; } _nodes.clear(); @@ -232,7 +232,7 @@ bool AdTalkDef::saveAsText(BaseDynamicBuffer *buffer, int indent) { _defaultSpriteSet->saveAsText(buffer, indent + 2); } - for (int i = 0; i < _nodes.getSize(); i++) { + for (uint32 i = 0; i < _nodes.size(); i++) { _nodes[i]->saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "\n"); } diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 165ee50270..89d7bd8a46 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -52,12 +52,12 @@ AdTalkHolder::~AdTalkHolder() { delete _sprite; _sprite = NULL; - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { delete _talkSprites[i]; } _talkSprites.clear(); - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { delete _talkSpritesEx[i]; } _talkSpritesEx.clear(); @@ -88,7 +88,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { if (stance != NULL) { // search special talk stances - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { ret = _talkSpritesEx[i]; break; @@ -96,7 +96,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { } if (ret == NULL) { // serach generic talk stances - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { ret = _talkSprites[i]; break; @@ -107,11 +107,11 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { // not a valid stance? get a random one if (ret == NULL) { - if (_talkSprites.getSize() < 1) { + if (_talkSprites.size() < 1) { ret = _sprite; } else { // TODO: remember last - int rnd = BaseEngine::instance().randInt(0, _talkSprites.getSize() - 1); + int rnd = BaseEngine::instance().randInt(0, _talkSprites.size() - 1); ret = _talkSprites[rnd]; } } @@ -228,7 +228,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS bool setTemp2 = false; if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getFilename(), filename) == 0) { if (_currentSprite == _talkSpritesEx[i]) { setCurrent = true; @@ -242,7 +242,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } } } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getFilename(), filename) == 0) { if (_currentSprite == _talkSprites[i]) { setCurrent = true; @@ -288,7 +288,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS // delete current if (ex) { - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (_talkSpritesEx[i] == _currentSprite) { setCurrent = true; } @@ -299,7 +299,7 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } _talkSpritesEx.clear(); } else { - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { if (_talkSprites[i] == _currentSprite) { setCurrent = true; } @@ -372,13 +372,13 @@ const char *AdTalkHolder::scToString() { ////////////////////////////////////////////////////////////////////////// bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { - for (int i = 0; i < _talkSprites.getSize(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { if (_talkSprites[i]->getFilename()) { buffer->putTextIndent(indent + 2, "TALK=\"%s\"\n", _talkSprites[i]->getFilename()); } } - for (int i = 0; i < _talkSpritesEx.getSize(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (_talkSpritesEx[i]->getFilename()) { buffer->putTextIndent(indent + 2, "TALK_SPECIAL=\"%s\"\n", _talkSpritesEx[i]->getFilename()); } diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 1573f5914e..8da62c9115 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -56,7 +56,7 @@ AdWaypointGroup::~AdWaypointGroup() { ////////////////////////////////////////////////////////////////////////// void AdWaypointGroup::cleanup() { - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -179,7 +179,7 @@ bool AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) { } BaseClass::saveAsText(buffer, indent + 2); - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } @@ -253,7 +253,7 @@ bool AdWaypointGroup::mimic(AdWaypointGroup *wpt, float scale, int argX, int arg cleanup(); - for (int i = 0; i < wpt->_points.getSize(); i++) { + for (uint32 i = 0; i < wpt->_points.size(); i++) { int x = (int)((float)wpt->_points[i]->x * scale / 100.0f); int y = (int)((float)wpt->_points[i]->y * scale / 100.0f); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 1462f1430d..eb66661c62 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,12 +61,12 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { delete _subframes[i]; } _subframes.clear(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } @@ -78,7 +78,7 @@ BaseFrame::~BaseFrame() { bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { bool res; - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); if (DID_FAIL(res)) { return res; @@ -102,7 +102,7 @@ bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { */ } if (owner) { - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { owner->applyEvent(_applyEvent[i]); } } @@ -349,7 +349,7 @@ bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float Rect32 subRect; - for (int i = 0; i < _subframes.getSize(); i++) { + for (int i = 0; i < _subframes.size(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); BasePlatform::unionRect(rect, rect, &subRect); } @@ -381,15 +381,15 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); } - if (_subframes.getSize() > 0) { + if (_subframes.size() > 0) { _subframes[0]->saveAsText(buffer, indent, false); } - for (int i = 1; i < _subframes.getSize(); i++) { + for (uint32 i = 1; i < _subframes.size(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); } - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } @@ -469,7 +469,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { + if (index < 0 || index >= _subframes.size()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else { @@ -487,12 +487,12 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { + if (index < 0 || index >= _subframes.size()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; _subframes.remove_at(i); @@ -547,7 +547,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac sub->setSurface(filename); } - if (index >= _subframes.getSize()) { + if (index >= (int32)_subframes.size()) { _subframes.add(sub); } else { _subframes.insert_at(index, sub); @@ -563,7 +563,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.getSize()) { + if (index < 0 || index >= _applyEvent.size()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else { @@ -578,7 +578,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "AddEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { stack->pushNULL(); return STATUS_OK; @@ -595,7 +595,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "DeleteEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { delete[] _applyEvent[i]; _applyEvent.remove_at(i); @@ -608,7 +608,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scCallMethod(script, stack, thisStack, name); } else { return BaseScriptable::scCallMethod(script, stack, thisStack, name); @@ -676,7 +676,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.getSize()); + _scValue->setInt(_subframes.size()); return _scValue; } @@ -684,13 +684,13 @@ ScValue *BaseFrame::scGetProperty(const char *name) { // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.getSize()); + _scValue->setInt(_applyEvent.size()); return _scValue; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scGetProperty(name); } else { return BaseScriptable::scGetProperty(name); @@ -743,7 +743,7 @@ bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scSetProperty(name, value); } else { return BaseScriptable::scSetProperty(name, value); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 5436b4637f..e8aaac6c40 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -328,7 +328,7 @@ bool BaseGame::cleanup() { unregisterObject(_fader); _fader = NULL; - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { delete _regObjects[i]; _regObjects[i] = NULL; } @@ -349,7 +349,7 @@ bool BaseGame::cleanup() { _scValue = NULL; _sFX = NULL; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->_owner = NULL; _scripts[i]->finish(); } @@ -361,7 +361,7 @@ bool BaseGame::cleanup() { _fontStorage->removeFont(_videoFont); _videoFont = NULL; - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { delete _quickMessages[i]; } _quickMessages.clear(); @@ -587,7 +587,7 @@ bool BaseGame::initLoop() { getMousePos(&_mousePos); _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { + for (int i = _windows.size() - 1; i >= 0; i--) { if (_windows[i]->_visible) { _focusedWindow = _windows[i]; break; @@ -1922,7 +1922,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); BaseObject *obj = (BaseObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i] == obj) { unregisterObject(_windows[i]); stack->pushBool(true); @@ -2849,12 +2849,12 @@ const char *BaseGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) { + if (_quickMessages.size() == 0 || !_systemFont) { return STATUS_OK; } // update - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; _quickMessages.remove_at(i); @@ -2865,7 +2865,7 @@ bool BaseGame::displayQuickMsg() { int posY = 20; // display - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } @@ -2876,7 +2876,7 @@ bool BaseGame::displayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// void BaseGame::quickMessage(const char *text) { - if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + if (_quickMessages.size() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.remove_at(0); } @@ -2911,7 +2911,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { } // is it a window? - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if ((BaseObject *)_windows[i] == object) { _windows.remove_at(i); @@ -2935,7 +2935,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { } // destroy object - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { if (_regObjects[i] == object) { _regObjects.remove_at(i); if (!_loadInProgress) { @@ -2973,7 +2973,7 @@ bool BaseGame::validObject(BaseObject *object) { return true; } - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { if (_regObjects[i] == object) { return true; } @@ -3322,7 +3322,7 @@ bool BaseGame::displayWindows(bool inGame) { // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { + for (int i = _windows.size() - 1; i >= 0; i--) { if (_windows[i]->_visible && !_windows[i]->_disable) { _focusedWindow = _windows[i]; break; @@ -3331,7 +3331,7 @@ bool BaseGame::displayWindows(bool inGame) { } // display all windows - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); @@ -3656,9 +3656,9 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { bool BaseGame::focusWindow(UIWindow *window) { UIWindow *prev = _focusedWindow; - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i] == window) { - if (i < _windows.getSize() - 1) { + if (i < _windows.size() - 1) { _windows.remove_at(i); _windows.add(window); @@ -3854,7 +3854,7 @@ bool BaseGame::setActiveObject(BaseObject *obj) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) { + if (_viewportSP >= (int32)_viewportStack.size()) { _viewportStack.add(viewport); } else { _viewportStack[_viewportSP] = viewport; @@ -3873,7 +3873,7 @@ bool BaseGame::popViewport() { _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); } - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) { + if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); } else _renderer->setViewport(_renderer->_drawOffsetX, _renderer->_drawOffsetY, @@ -4065,7 +4065,7 @@ void BaseGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { _regObjects[i]->invalidateDeviceObjects(); } return STATUS_OK; @@ -4074,7 +4074,7 @@ bool BaseGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { _regObjects[i]->restoreDeviceObjects(); } return STATUS_OK; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index a781c7eeb7..4d7f3487f0 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -60,7 +60,7 @@ BaseRegion::~BaseRegion() { ////////////////////////////////////////////////////////////////////////// void BaseRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -78,7 +78,7 @@ bool BaseRegion::createRegion() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) { + if (_points.size() < 3) { return false; } @@ -160,9 +160,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { buffer = params; } - int i; - - for (i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -248,7 +246,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { _points.insert_at(index, new BasePoint(x, y)); createRegion(); @@ -269,7 +267,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { _points[index]->x = x; _points[index]->y = y; createRegion(); @@ -289,7 +287,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { delete _points[index]; _points[index] = NULL; @@ -311,7 +309,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { ScValue *val = stack->getPushValue(); if (val) { val->setProperty("X", _points[index]->x); @@ -360,7 +358,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { // NumPoints ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.getSize()); + _scValue->setInt(_points.size()); return _scValue; } else { return BaseObject::scGetProperty(name); @@ -409,13 +407,11 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } @@ -451,7 +447,7 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) { + if (_points.size() < 3) { return false; } @@ -465,9 +461,9 @@ bool BaseRegion::ptInPolygon(int x, int y) { p1.x = (double)_points[0]->x; p1.y = (double)_points[0]->y; - for (int i = 1; i <= _points.getSize(); i++) { - p2.x = (double)_points[i % _points.getSize()]->x; - p2.y = (double)_points[i % _points.getSize()]->y; + for (uint32 i = 1; i <= _points.size(); i++) { + p2.x = (double)_points[i % _points.size()]->x; + p2.y = (double)_points[i % _points.size()]->y; if (p.y > MIN(p1.y, p2.y)) { if (p.y <= MAX(p1.y, p2.y)) { @@ -494,12 +490,12 @@ bool BaseRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) { + if (_points.size() == 0) { BasePlatform::setRectEmpty(rect); } else { int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { minX = MIN(minX, _points[i]->x); minY = MIN(minY, _points[i]->y); @@ -520,7 +516,7 @@ bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { cleanup(); - for (int i = 0; i < region->_points.getSize(); i++) { + for (uint32 i = 0; i < region->_points.size(); i++) { int xVal, yVal; xVal = (int)((float)region->_points[i]->x * scale / 100.0f); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d57638a4a8..e4132351e0 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -58,9 +58,7 @@ bool BaseScriptHolder::cleanup() { delete[] _filename; _filename = NULL; - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } @@ -90,7 +88,7 @@ bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; bool ret = STATUS_FAILED; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread) { ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { @@ -186,7 +184,7 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t const char *filename = stack->pop()->getString(); bool killThreads = stack->pop()->getBool(false); bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { _scripts[i]->finish(killThreads); ret = true; @@ -205,7 +203,7 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t stack->correctParams(1); const char *filename = stack->pop()->getString(); bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; @@ -300,7 +298,7 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); @@ -334,7 +332,7 @@ bool BaseScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::removeScript(ScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] == script) { _scripts.remove_at(i); break; @@ -345,7 +343,7 @@ bool BaseScriptHolder::removeScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { return true; } @@ -356,7 +354,7 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { return true; } @@ -452,7 +450,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->_freezable = freezable; } @@ -461,7 +459,7 @@ void BaseScriptHolder::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.getSize() - 1; i >= 0; i--) { + for (int i = _scripts.size() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 2fc2096802..ae0e844cb5 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -88,7 +88,7 @@ void BaseSprite::setDefaults() { void BaseSprite::cleanup() { BaseScriptHolder::cleanup(); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { delete _frames[i]; } _frames.clear(); @@ -103,7 +103,7 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { getCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return STATUS_OK; } @@ -334,7 +334,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa ////////////////////////////////////////////////////////////////////// void BaseSprite::reset() { - if (_frames.getSize() > 0) { + if (_frames.size() > 0) { _currentFrame = 0; } else { _currentFrame = -1; @@ -367,10 +367,10 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { // get current frame if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.getSize() - 1) { + if (_currentFrame < (int32)_frames.size() - 1) { _currentFrame++; if (_continuous) { - _canBreak = (_currentFrame == _frames.getSize() - 1); + _canBreak = (_currentFrame == (int32)_frames.size() - 1); } } else { if (_looping) { @@ -385,13 +385,13 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { _lastFrameTime = timer; } - _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); if (_lastFrameTime == 0) { _lastFrameTime = timer; _changed = true; if (_continuous) { - _canBreak = (_currentFrame == _frames.getSize() - 1); + _canBreak = (_currentFrame == (int32)_frames.size() - 1); } } @@ -411,7 +411,7 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return STATUS_OK; } @@ -432,11 +432,11 @@ bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, flo ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return NULL; } BaseFrame *frame = _frames[_currentFrame]; - if (frame && frame->_subframes.getSize() > 0) { + if (frame && frame->_subframes.size() > 0) { BaseSubFrame *subframe = frame->_subframes[0]; if (subframe) { return subframe->_surface; @@ -455,7 +455,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float } BasePlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { Rect32 frame; Rect32 temp; BasePlatform::copyRect(&temp, rect); @@ -493,15 +493,12 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { BaseScriptHolder::saveAsText(buffer, indent + 2); - int i; - // scripts - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - - for (i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { _frames[i]->saveAsText(buffer, indent + 2); } @@ -554,7 +551,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _frames.getSize()) { + if (index < 0 || index >= (int32)_frames.size()) { script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); stack->pushNULL(); } else { @@ -571,14 +568,14 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _frames.getSize()) { + if (index < 0 || index >= (int32)_frames.size()) { script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); } } else { BaseFrame *frame = (BaseFrame *)val->getNative(); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { if (_frames[i] == frame) { - if (i == _currentFrame) { + if (i == (uint32)_currentFrame) { _lastFrameTime = 0; } delete _frames[i]; @@ -654,7 +651,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta } } - if (index >= _frames.getSize()) { + if (index >= (int32)_frames.size()) { _frames.add(frame); } else { _frames.insert_at(index, frame); @@ -704,7 +701,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.getSize()); + _scValue->setInt(_frames.size()); return _scValue; } @@ -771,7 +768,7 @@ bool BaseSprite::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "CurrentFrame") == 0) { _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + if (_currentFrame >= (int32)_frames.size() || _currentFrame < 0) { _currentFrame = -1; } _lastFrameTime = 0; @@ -806,7 +803,7 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { if (_frames[i]->_sound) { _frames[i]->_sound->stop(); } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ff1207b31f..a9d71e0fa1 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -256,8 +256,8 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { bool handled = false; if (_sprite) { _sprite->getCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < (int32)_sprite->_frames.size() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.size() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); } handled = true; @@ -532,8 +532,8 @@ bool BaseFontBitmap::getWidths() { BaseSurface *surf = NULL; if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + if (_widthsFrame >= 0 && _widthsFrame < (int32)_sprite->_frames.size()) { + if (_sprite->_frames[_widthsFrame] && (int32)_sprite->_frames[_widthsFrame]->_subframes.size() > 0) { surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; } } diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index bc7ab6f22c..298417ec32 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -51,7 +51,7 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (warn) { _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); } @@ -64,7 +64,7 @@ bool BaseFontStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { _fonts[i]->initLoop(); } return STATUS_OK; @@ -76,7 +76,7 @@ BaseFont *BaseFontStorage::addFont(const Common::String &filename) { return NULL; } - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { _fonts[i]->_refCount++; return _fonts[i]; @@ -112,7 +112,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { return STATUS_FAILED; } - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (_fonts[i] == font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 2c8cd261a9..19c5cef7ee 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -69,7 +69,7 @@ BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { BaseFontTT::~BaseFontTT(void) { clearCache(); - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { delete _layers[i]; } _layers.clear(); @@ -224,7 +224,7 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign if (surface) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = renderer->_forceAlphaColor; if (renderer->_forceAlphaColor != 0) { @@ -433,7 +433,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { } // create at least one layer - if (_layers.getSize() == 0) { + if (_layers.size() == 0) { BaseTTFontLayer *layer = new BaseTTFontLayer; layer->_color = baseColor; _layers.add(layer); @@ -508,13 +508,13 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { // persist layers int numLayers; if (persistMgr->getIsSaving()) { - numLayers = _layers.getSize(); + numLayers = _layers.size(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { _layers[i]->persist(persistMgr); } } else { - numLayers = _layers.getSize(); + numLayers = _layers.size(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { BaseTTFontLayer *layer = new BaseTTFontLayer; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 4fb0eb6637..f52a1b8c82 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -94,18 +94,18 @@ PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject ////////////////////////////////////////////////////////////////////////// PartEmitter::~PartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { delete _particles[i]; } _particles.clear(); - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { delete _forces[i]; } _forces.clear(); - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { delete[] _sprites[i]; } _sprites.clear(); @@ -121,7 +121,7 @@ bool PartEmitter::addSprite(const char *filename) { } // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { return STATUS_OK; } @@ -145,7 +145,7 @@ bool PartEmitter::addSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete[] _sprites[i]; _sprites.remove_at(i); @@ -160,7 +160,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 if (!particle) { return STATUS_FAILED; } - if (_sprites.getSize() == 0) { + if (_sprites.size() == 0) { return STATUS_FAILED; } @@ -190,7 +190,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 } float angle = BaseUtils::randomAngle(_angle1, _angle2); - int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); + int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); @@ -259,7 +259,7 @@ bool PartEmitter::update() { bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->update(this, currentTime, timerDelta); if (!_particles[i]->_isDead) { @@ -282,7 +282,7 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int toGen = MIN(_genAmount, _maxParticles - numLive); while (toGen > 0) { int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i]->_isDead) { firstDeadIndex = i; break; @@ -319,11 +319,11 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::display(BaseRegion *region) { - if (_sprites.getSize() <= 1) { + if (_sprites.size() <= 1) { _gameRef->_renderer->startSpriteBatch(); } - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (region != NULL && _useRegion) { if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { continue; @@ -333,7 +333,7 @@ bool PartEmitter::display(BaseRegion *region) { _particles[i]->display(this); } - if (_sprites.getSize() <= 1) { + if (_sprites.size() <= 1) { _gameRef->_renderer->endSpriteBatch(); } @@ -342,7 +342,7 @@ bool PartEmitter::display(BaseRegion *region) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->_isDead = true; } _running = true; @@ -406,7 +406,7 @@ bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int PartForce *PartEmitter::addForceByName(const Common::String &name) { PartForce *force = NULL; - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { force = _forces[i]; break; @@ -443,7 +443,7 @@ bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType typ ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeForce(const Common::String &name) { - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { delete _forces[i]; _forces.remove_at(i); @@ -524,7 +524,7 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "Stop") == 0) { stack->correctParams(0); - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { delete _particles[i]; } _particles.clear(); @@ -787,7 +787,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLiveParticles") == 0) { int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i] && !_particles[i]->_isDead) { numAlive++; } @@ -1218,32 +1218,32 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { _sprites.persist(persistMgr); - int numForces; + uint32 numForces; if (persistMgr->getIsSaving()) { - numForces = _forces.getSize(); + numForces = _forces.size(); persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { _forces[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { + for (uint32 i = 0; i < numForces; i++) { PartForce *force = new PartForce(_gameRef); force->persist(persistMgr); _forces.add(force); } } - int numParticles; + uint32 numParticles; if (persistMgr->getIsSaving()) { - numParticles = _particles.getSize(); + numParticles = _particles.size(); persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { + for (uint32 i = 0; i < numParticles; i++) { PartParticle *particle = new PartParticle(_gameRef); particle->persist(persistMgr); _particles.add(particle); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 9247514ac3..5f523612b8 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -148,7 +148,7 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer // update position float elapsedTime = (float)timerDelta / 1000.f; - for (int i = 0; i < emitter->_forces.getSize(); i++) { + for (uint32 i = 0; i < emitter->_forces.size(); i++) { PartForce *force = emitter->_forces[i]; switch (force->_type) { case PartForce::FORCE_GLOBAL: diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 6c8a88adb0..beef4ee9d2 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1423,7 +1423,7 @@ bool ScScript::copyParameters(ScStack *stack) { ////////////////////////////////////////////////////////////////////////// bool ScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.getSize(); i++) { + for (uint32 i = 0; i < _engine->_scripts.size(); i++) { ScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { scr->finish(true); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 575e24a3a3..d518be579f 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -95,7 +95,7 @@ ScEngine::~ScEngine() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::cleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); } @@ -248,19 +248,19 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig ////////////////////////////////////////////////////////////////////////// bool ScEngine::tick() { - if (_scripts.getSize() == 0) { + if (_scripts.size() == 0) { return STATUS_OK; } // resolve waiting scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { switch (_scripts[i]->_state) { case SCRIPT_WAITING: { /* bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + for(int j=0; j<_gameRef->_regObjects.size(); j++) { if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) { @@ -318,7 +318,7 @@ bool ScEngine::tick() { // execute scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { // skip paused scripts if (_scripts[i]->_state == SCRIPT_PAUSED) { @@ -365,7 +365,7 @@ bool ScEngine::tick() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::tickUnbreakable() { // execute unbreakable scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_unbreakable) { continue; } @@ -386,7 +386,7 @@ bool ScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::removeFinishedScripts() { // remove finished scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); @@ -405,7 +405,7 @@ bool ScEngine::removeFinishedScripts() { int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED) { continue; } @@ -456,7 +456,7 @@ bool ScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { if (!_gameRef->_compatKillMethodThreads) { resetScript(_scripts[i]); @@ -472,7 +472,7 @@ bool ScEngine::resetObject(BaseObject *Object) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resetScript(ScScript *script) { // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { _scripts[i]->finish(); } @@ -497,7 +497,7 @@ bool ScEngine::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void ScEngine::editorCleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; _scripts.remove_at(i); @@ -509,7 +509,7 @@ void ScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::pauseAll() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] != _currentScript) { _scripts[i]->pause(); } @@ -521,7 +521,7 @@ bool ScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->resume(); } @@ -531,7 +531,7 @@ bool ScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::isValidScript(ScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] == script) { return true; } diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 7e81cdaf17..d27748abe6 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -44,10 +44,10 @@ ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { ScStack::~ScStack() { #if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); #endif - for (int i = 0; i < _values.getSize(); i++) { + for (uint32 i = 0; i < _values.size(); i++) { delete _values[i]; } _values.clear(); @@ -69,7 +69,7 @@ ScValue *ScStack::pop() { void ScStack::push(ScValue *val) { _sP++; - if (_sP < _values.getSize()) { + if (_sP < (int32)_values.size()) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { @@ -84,7 +84,7 @@ void ScStack::push(ScValue *val) { ScValue *ScStack::getPushValue() { _sP++; - if (_sP >= _values.getSize()) { + if (_sP >= (int32)_values.size()) { ScValue *val = new ScValue(_gameRef); _values.add(val); } @@ -96,7 +96,7 @@ ScValue *ScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) { + if (_sP < 0 || _sP >= (int32)_values.size()) { return NULL; } else { return _values[_sP]; @@ -107,7 +107,7 @@ ScValue *ScStack::getTop() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getAt(int index) { index = _sP - index; - if (index < 0 || index >= _values.getSize()) { + if (index < 0 || index >= (int32)_values.size()) { return NULL; } else { return _values[index]; @@ -136,9 +136,9 @@ void ScStack::correctParams(uint32 expectedParams) { nuParams++; _sP++; - if (_values.getSize() > _sP + 1) { - delete _values[_values.getSize() - 1]; - _values.remove_at(_values.getSize() - 1); + if ((int32)_values.size() > _sP + 1) { + delete _values[_values.size() - 1]; + _values.remove_at(_values.size() - 1); } } } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index 7b1d21f5b0..fbe2da1719 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -60,13 +60,9 @@ public: } return true; } - // TODO: Just here for convenience while verifying that this works. - int getSize() const { - return Common::Array::size(); - } int add(TYPE newElement) { Common::Array::push_back(newElement); - return getSize() - 1; + return Common::Array::size() - 1; } void remove_at(uint32 idx) { Common::Array::remove_at(idx); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index d13ad235bc..c5ca63081c 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -574,7 +574,7 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index a82a12258f..2ea44cd64c 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -360,7 +360,7 @@ bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "PARENT_NOTIFY=%s\n", _parentNotify ? "TRUE" : "FALSE"); // scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index 038b256c24..18a4db124a 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -202,7 +202,7 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 31f1b9aa33..716570fd67 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -251,13 +251,13 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_parent && _parent->_type == UI_WINDOW) { UIWindow *win = (UIWindow *)_parent; - int i; + uint32 i; bool found = false; ScValue *val = stack->pop(); // find directly if (val->isNative()) { UIObject *widget = (UIObject *)val->getNative(); - for (i = 0; i < win->_widgets.getSize(); i++) { + for (i = 0; i < win->_widgets.size(); i++) { if (win->_widgets[i] == widget) { found = true; break; @@ -267,7 +267,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // find by name else { const char *findName = val->getString(); - for (i = 0; i < win->_widgets.getSize(); i++) { + for (i = 0; i < win->_widgets.size(); i++) { if (scumm_stricmp(win->_widgets[i]->getName(), findName) == 0) { found = true; break; @@ -277,7 +277,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (found) { bool done = false; - for (int j = 0; j < win->_widgets.getSize(); j++) { + for (uint32 j = 0; j < win->_widgets.size(); j++) { if (win->_widgets[j] == this) { if (strcmp(name, "MoveAfter") == 0) { i++; @@ -316,7 +316,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_parent && _parent->_type == UI_WINDOW) { UIWindow *win = (UIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { + for (uint32 i = 0; i < win->_widgets.size(); i++) { if (win->_widgets[i] == this) { win->_widgets.remove_at(i); win->_widgets.insert_at(0, this); @@ -339,7 +339,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_parent && _parent->_type == UI_WINDOW) { UIWindow *win = (UIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { + for (uint32 i = 0; i < win->_widgets.size(); i++) { if (win->_widgets[i] == this) { win->_widgets.remove_at(i); win->_widgets.add(this); @@ -441,10 +441,10 @@ ScValue *UIObject::scGetProperty(const char *name) { _scValue->setNULL(); if (_parent && _parent->_type == UI_WINDOW) { UIWindow *win = (UIWindow *)_parent; - for (int i = 0; i < win->_widgets.getSize(); i++) { + for (uint32 i = 0; i < win->_widgets.size(); i++) { if (win->_widgets[i] == this) { if (strcmp(name, "NextSibling") == 0) { - if (i < win->_widgets.getSize() - 1) { + if (i < win->_widgets.size() - 1) { _scValue->setNative(win->_widgets[i + 1], true); } } else { diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 038df55c42..86d5c754f1 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -387,7 +387,7 @@ bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index d33de9881c..ffb7e4dbf8 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -110,7 +110,7 @@ void UIWindow::cleanup() { delete _imageInactive; } - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { delete _widgets[i]; } _widgets.clear(); @@ -220,7 +220,7 @@ bool UIWindow::display(int offsetX, int offsetY) { _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false)); } - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { _widgets[i]->display(_posX + offsetX, _posY + offsetY); } @@ -713,7 +713,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "\n"); // scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } @@ -723,7 +723,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { BaseClass::saveAsText(buffer, indent + 2); // controls - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { _widgets[i]->saveAsText(buffer, indent + 2); } @@ -734,7 +734,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::enableWidget(const char *name, bool enable) { - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { _widgets[i]->_disable = !enable; } @@ -745,7 +745,7 @@ bool UIWindow::enableWidget(const char *name, bool enable) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::showWidget(const char *name, bool visible) { - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { if (scumm_stricmp(_widgets[i]->getName(), name) == 0) { _widgets[i]->_visible = visible; } @@ -766,13 +766,13 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (val->getType() == VAL_INT) { int widget = val->getInt(); - if (widget < 0 || widget >= _widgets.getSize()) { + if (widget < 0 || widget >= (int32)_widgets.size()) { stack->pushNULL(); } else { stack->pushNative(_widgets[widget], true); } } else { - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { if (scumm_stricmp(_widgets[i]->getName(), val->getString()) == 0) { stack->pushNative(_widgets[i], true); return STATUS_OK; @@ -991,7 +991,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); UIObject *obj = (UIObject *)val->getNative(); - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { if (_widgets[i] == obj) { delete _widgets[i]; _widgets.remove_at(i); @@ -1028,7 +1028,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { - _scValue->setInt(_widgets.getSize()); + _scValue->setInt(_widgets.size()); return _scValue; } @@ -1286,7 +1286,7 @@ bool UIWindow::persist(BasePersistenceManager *persistMgr) { bool UIWindow::moveFocus(bool forward) { int i; bool found = false; - for (i = 0; i < _widgets.getSize(); i++) { + for (i = 0; i < (int32)_widgets.size(); i++) { if (_widgets[i] == _focusedWidget) { found = true; break; @@ -1297,7 +1297,7 @@ bool UIWindow::moveFocus(bool forward) { } if (!_focusedWidget) { - if (_widgets.getSize() > 0) { + if (_widgets.size() > 0) { i = 0; } else { return STATUS_OK; @@ -1307,7 +1307,7 @@ bool UIWindow::moveFocus(bool forward) { int numTries = 0; bool done = false; - while (numTries <= _widgets.getSize()) { + while (numTries <= (int32)_widgets.size()) { if (_widgets[i] != _focusedWidget && _widgets[i]->_canFocus && _widgets[i]->_visible && !_widgets[i]->_disable) { _focusedWidget = _widgets[i]; done = true; @@ -1316,13 +1316,13 @@ bool UIWindow::moveFocus(bool forward) { if (forward) { i++; - if (i >= _widgets.getSize()) { + if (i >= (int32)_widgets.size()) { i = 0; } } else { i--; if (i < 0) { - i = _widgets.getSize() - 1; + i = _widgets.size() - 1; } } numTries++; @@ -1406,7 +1406,7 @@ bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// void UIWindow::makeFreezable(bool freezable) { - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { _widgets[i]->makeFreezable(freezable); } @@ -1416,7 +1416,7 @@ void UIWindow::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// bool UIWindow::getWindowObjects(BaseArray &objects, bool interactiveOnly) { - for (int i = 0; i < _widgets.getSize(); i++) { + for (uint32 i = 0; i < _widgets.size(); i++) { UIObject *control = _widgets[i]; if (control->_disable && interactiveOnly) { continue; -- cgit v1.2.3 From 07c27b775c8d3997bf40891c2772ae8859eb534d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:35:49 +0200 Subject: WINTERMUTE: Cleanup the header-guards. --- engines/wintermute/ad/ad_actor.h | 2 +- engines/wintermute/ad/ad_types.h | 2 +- engines/wintermute/base/base.h | 4 ++-- engines/wintermute/base/base_active_rect.h | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 4 ++-- engines/wintermute/base/base_fader.h | 4 ++-- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/base_frame.h | 4 ++-- engines/wintermute/base/base_game.h | 4 ++-- engines/wintermute/base/base_keyboard_state.h | 4 ++-- engines/wintermute/base/base_named_object.h | 4 ++-- engines/wintermute/base/base_object.h | 4 ++-- engines/wintermute/base/base_parser.h | 4 ++-- engines/wintermute/base/base_persistence_manager.h | 4 ++-- engines/wintermute/base/base_point.h | 4 ++-- engines/wintermute/base/base_quick_msg.h | 4 ++-- engines/wintermute/base/base_region.h | 4 ++-- engines/wintermute/base/base_save_thumb_helper.h | 4 ++-- engines/wintermute/base/base_script_holder.h | 4 ++-- engines/wintermute/base/base_scriptable.h | 4 ++-- engines/wintermute/base/base_sprite.h | 4 ++-- engines/wintermute/base/base_string_table.h | 4 ++-- engines/wintermute/base/base_sub_frame.h | 4 ++-- engines/wintermute/base/base_surface_storage.h | 4 ++-- engines/wintermute/base/base_transition_manager.h | 4 ++-- engines/wintermute/base/base_viewport.h | 4 ++-- engines/wintermute/base/file/base_disk_file.h | 4 ++-- engines/wintermute/base/file/base_file.h | 4 ++-- engines/wintermute/base/file/base_file_entry.h | 4 ++-- engines/wintermute/base/file/base_package.h | 4 ++-- engines/wintermute/base/file/base_resources.h | 4 ++-- engines/wintermute/base/file/base_save_thumb_file.h | 4 ++-- engines/wintermute/base/file/dcpackage.h | 2 +- engines/wintermute/base/font/base_font.h | 4 ++-- engines/wintermute/base/font/base_font_bitmap.h | 4 ++-- engines/wintermute/base/font/base_font_storage.h | 4 ++-- engines/wintermute/base/font/base_font_truetype.h | 4 ++-- engines/wintermute/base/gfx/base_image.h | 4 ++-- engines/wintermute/base/gfx/base_renderer.h | 4 ++-- engines/wintermute/base/gfx/base_surface.h | 4 ++-- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 6 +++--- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 6 +++--- engines/wintermute/base/sound/base_sound.h | 4 ++-- engines/wintermute/base/sound/base_sound_buffer.h | 4 ++-- engines/wintermute/base/sound/base_sound_manager.h | 4 ++-- engines/wintermute/coll_templ.h | 2 +- engines/wintermute/dcgf.h | 2 +- engines/wintermute/math/math_util.h | 2 +- engines/wintermute/math/matrix4.h | 2 +- engines/wintermute/math/rect32.h | 2 +- engines/wintermute/math/vector2.h | 2 +- engines/wintermute/persistent.h | 2 +- engines/wintermute/utils/path_util.h | 2 +- engines/wintermute/utils/string_util.h | 2 +- engines/wintermute/wintypes.h | 2 +- 55 files changed, 99 insertions(+), 99 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 4bc1bae37f..370a91cc22 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -105,4 +105,4 @@ private: } // end of namespace Wintermute -#endif // WINTERMUTE_ADACTOR_H +#endif diff --git a/engines/wintermute/ad/ad_types.h b/engines/wintermute/ad/ad_types.h index b8cae58c6d..8db20bfc02 100644 --- a/engines/wintermute/ad/ad_types.h +++ b/engines/wintermute/ad/ad_types.h @@ -104,4 +104,4 @@ typedef enum { } // end of namespace Wintermute -#endif // WINTERMUTE_ADTYPES_H +#endif diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index b1b184b2f4..b07065ec0d 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H +#ifndef WINTERMUTE_BASE_BASE_H +#define WINTERMUTE_BASE_BASE_H #include "engines/wintermute/wintypes.h" #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index b446dadcce..848b77e56e 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H +#ifndef WINTERMUTE_BASE_ACTIVERECT_H +#define WINTERMUTE_BASE_BACTIVERECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 926728baa6..23aebfdf9f 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H +#ifndef WINTERMUTE_BASE_DYNBUFFER_H +#define WINTERMUTE_BASE_DYNBUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 34d0e7d3da..30072babfa 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H +#ifndef WINTERMUTE_BASE_FADER_H +#define WINTERMUTE_BASE_FADER_H #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 5e18a95786..3716dd0581 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H +#ifndef WINTERMUTE_BASE_FILEMANAGER_H +#define WINTERMUTE_BASE_FILEMANAGER_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index b1eae6b659..c89fb49e61 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H +#ifndef WINTERMUTE_BASE_FRAME_H +#define WINTERMUTE_BASE_FRAME_H #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 43efad1482..aecbe31722 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H +#ifndef WINTERMUTE_BASE_GAME_H +#define WINTERMUTE_BASE_GAME_H #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index 382dd9fbce..4b1826d483 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H +#ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H +#define WINTERMUTE_BASE_KEYBOARD_STATE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index cd856bb008..ca71471521 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H +#ifndef WINTERMUTE_BASE_NAMEDOBJECT_H +#define WINTERMUTE_BASE_NAMEDOBJECT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 34d9ca89ca..e1a21e91ba 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H +#ifndef WINTERMUTE_BASE_OBJECT_H +#define WINTERMUTE_BASE_OBJECT_H #include "engines/wintermute/base/base_script_holder.h" diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 3d63668059..6b4f733d74 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H +#ifndef WINTERMUTE_BASE_PARSER_H +#define WINTERMUTE_BASE_PARSER_H #define TOKEN_DEF_START \ diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index fea8f231d1..4de1f84c64 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H +#ifndef WINTERMUTE_BASE_PERSISTMGR_H +#define WINTERMUTE_BASE_PERSISTMGR_H #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 68a37c0110..43f8f960f1 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H +#ifndef WINTERMUTE_BASE_POINT_H +#define WINTERMUTE_BASE_POINT_H #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index bef81827b0..d00b302baf 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H +#ifndef WINTERMUTE_BASE_QUICKMSG_H +#define WINTERMUTE_BASE_QUICKMSG_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index f456eb07fc..e7ae9bda13 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H +#ifndef WINTERMUTE_BASE_REGION_H +#define WINTERMUTE_BASE_REGION_H #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index 4131cf89d4..7c06384aa1 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -25,8 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H +#ifndef WINTERMUTE_BASE_SAVETHUMBHELPER_H +#define WINTERMUTE_BASE_SAVETHUMBHELPER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 4f3d5f4ef9..cab0d4f693 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H +#ifndef WINTERMUTE_BASE_SCRIPTHOLDER_H +#define WINTERMUTE_BASE_SCRIPTHOLDER_H #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 2501f34561..11cb0bcf9f 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H +#ifndef WINTERMUTE_BASE_SCRIPTABLE_H +#define WINTERMUTE_BASE_SCRIPTABLE_H #include "engines/wintermute/base/base_named_object.h" diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index a02e69c63f..db9931c6f3 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H +#ifndef WINTERMUTE_BASE_SPRITE_H +#define WINTERMUTE_BASE_SPRITE_H #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index c8df25810e..46295426fd 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H +#ifndef WINTERMUTE_BASE_STRINGTABLE_H +#define WINTERMUTE_BASE_STRINGTABLE_H #include "common/hashmap.h" diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 935fb667d4..e89a189e2d 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H +#ifndef WINTERMUTE_BASE_SUBFRAME_H +#define WINTERMUTE_BASE_SUBFRAME_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index f1757b3a32..741177ae76 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H +#ifndef WINTERMUTE_BASE_SURFACESTORAGE_H +#define WINTERMUTE_BASE_SURFACESTORAGE_H #include "engines/wintermute/base/base.h" #include "common/array.h" diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 412361a543..daf2299c2f 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H +#ifndef WINTERMUTE_BASE_TRANSITIONMGR_H +#define WINTERMUTE_BASE_TRANSITIONMGR_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 1080c1d806..c94beeb2b1 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H +#ifndef WINTERMUTE_BASE_VIEWPORT_H +#define WINTERMUTE_BASE_VIEWPORT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 8be06199de..69644408d0 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H +#ifndef WINTERMUTE_BASE_DISKFILE_H +#define WINTERMUTE_BASE_DISKFILE_H #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index f9947fe64f..7ae36d5ad1 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H +#ifndef WINTERMUTE_BASE_FILE_H +#define WINTERMUTE_BASE_FILE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 7e71a486ef..6dd4bc08a4 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H +#ifndef WINTERMUTE_BASE_FILEENTRY_H +#define WINTERMUTE_BASE_FILEENTRY_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 676675b041..23d7d7690f 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H +#ifndef WINTERMUTE_BASE_PACKAGE_H +#define WINTERMUTE_BASE_PACKAGE_H #include "common/archive.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 596ac64dd7..48a0f534d0 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H +#ifndef WINTERMUTE_BASE_RESOURCES_H +#define WINTERMUTE_BASE_RESOURCES_H #include "common/stream.h" #include "common/str.h" diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index e68dc06904..377e06f02c 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H +#ifndef WINTERMUTE_BASE_SAVETHUMBFILE_H +#define WINTERMUTE_BASE_SAVETHUMBFILE_H #include "engines/wintermute/base/file/base_file.h" diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 42c0b75e55..82f1998527 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -77,4 +77,4 @@ v2: uint32 TimeDate1 } // end of namespace Wintermute -#endif // _DCPACKAGE_H_ +#endif diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index aaf5aa2367..461a724160 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H +#ifndef WINTERMUTE_BASE_FONT_H +#define WINTERMUTE_BASE_FONT_H #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 22cd9c6ba8..14a6e1cc87 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H +#ifndef WINTERMUTE_BASE_FONTBITMAP_H +#define WINTERMUTE_BASE_FONTBITMAP_H #include "engines/wintermute/base/font/base_font.h" diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 498096a5a8..733e1c5da3 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H +#ifndef WINTERMUTE_BASE_FONTSTORAGE_H +#define WINTERMUTE_BASE_FONTSTORAGE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 93431b039c..a93e4efacb 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H +#ifndef WINTERMUTE_BASE_FONTTT_H +#define WINTERMUTE_BASE_FONTTT_H #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font.h" diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 7bf901fe40..560a5f0d74 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BIMAGE_H -#define WINTERMUTE_BIMAGE_H +#ifndef WINTERMUTE_BASE_IMAGE_H +#define WINTERMUTE_BASE_IMAGE_H #include "graphics/surface.h" #include "graphics/pixelformat.h" diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 1b284b044d..26d7e6db57 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRENDERER_H -#define WINTERMUTE_BRENDERER_H +#ifndef WINTERMUTE_BASE_RENDERER_H +#define WINTERMUTE_BASE_RENDERER_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 3be61477ba..f45856f652 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACE_H -#define WINTERMUTE_BSURFACE_H +#ifndef WINTERMUTE_BASE_SURFACE_H +#define WINTERMUTE_BASE_SURFACE_H #include "engines/wintermute/base/base.h" #include "engines/wintermute/math/rect32.h" diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 44acca0267..aebb4cf888 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRENDERER_SDL_H -#define WINTERMUTE_BRENDERER_SDL_H +#ifndef WINTERMUTE_BASE_RENDERER_SDL_H +#define WINTERMUTE_BASE_RENDERER_SDL_H #include "engines/wintermute/base/gfx/base_renderer.h" #include "common/rect.h" @@ -128,4 +128,4 @@ private: } // end of namespace Wintermute -#endif // WINTERMUTE_BRENDERER_SDL_H +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 1b7146632e..b68fac4e3b 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACESDL_H -#define WINTERMUTE_BSURFACESDL_H +#ifndef WINTERMUTE_BASE_SURFACESDL_H +#define WINTERMUTE_BASE_SURFACESDL_H #include "graphics/surface.h" #include "engines/wintermute/base/gfx/base_surface.h" @@ -96,4 +96,4 @@ private: } // end of namespace Wintermute -#endif // WINTERMUTE_BSURFACESDL_H +#endif diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index fcc463ed06..d65757474a 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H +#ifndef WINTERMUTE_BASE_SOUND_H +#define WINTERMUTE_BASE_SOUND_H #include "engines/wintermute/base/base.h" #include "engines/wintermute/dctypes.h" // Added by ClassView diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 3ec4d4d28b..29402ee76e 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H +#ifndef WINTERMUTE_BASE_SOUNDBUFFER_H +#define WINTERMUTE_BASE_SOUNDBUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index a0b9a4bc4b..d0b782b2b7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H +#ifndef WINTERMUTE_BASE_SOUNDMGR_H +#define WINTERMUTE_BASE_SOUNDMGR_H #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index fbe2da1719..f1bf594769 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -83,4 +83,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_COLL_TEMPL_H +#endif diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h index c1a67ba4d1..867300e2d3 100644 --- a/engines/wintermute/dcgf.h +++ b/engines/wintermute/dcgf.h @@ -48,4 +48,4 @@ #define COMPRESSED_FILE_MAGIC 0x504D435A // ZCMP -#endif // WINTERMUTE_DCGF_H +#endif diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h index 506317a2b0..5f13c416d7 100644 --- a/engines/wintermute/math/math_util.h +++ b/engines/wintermute/math/math_util.h @@ -39,4 +39,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_MATHUTIL_H +#endif diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h index 5891b4c5ec..5b68944397 100644 --- a/engines/wintermute/math/matrix4.h +++ b/engines/wintermute/math/matrix4.h @@ -56,4 +56,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_MATRIX4_H +#endif diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index 1c959da1cf..190c1135cf 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -91,4 +91,4 @@ struct Rect32 { } // end of namespace Wintermute -#endif // WINTERMUTE_RECT32_H +#endif diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h index ce7ebd331e..dfed1824f0 100644 --- a/engines/wintermute/math/vector2.h +++ b/engines/wintermute/math/vector2.h @@ -72,4 +72,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_VECTOR2_H +#endif diff --git a/engines/wintermute/persistent.h b/engines/wintermute/persistent.h index 54b13e8ffe..5bcf30787d 100644 --- a/engines/wintermute/persistent.h +++ b/engines/wintermute/persistent.h @@ -86,4 +86,4 @@ namespace Wintermute { } // end of namespace Wintermute -#endif // WINTERMUTE_PERSISTENT_H +#endif diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h index ed8f3e91e8..92adfd91b8 100644 --- a/engines/wintermute/utils/path_util.h +++ b/engines/wintermute/utils/path_util.h @@ -46,4 +46,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_PATHUTILS_H +#endif diff --git a/engines/wintermute/utils/string_util.h b/engines/wintermute/utils/string_util.h index 581ffc2ed4..87760971a8 100644 --- a/engines/wintermute/utils/string_util.h +++ b/engines/wintermute/utils/string_util.h @@ -53,4 +53,4 @@ public: } // end of namespace Wintermute -#endif // WINTERMUTE_STRINGUTIL_H +#endif diff --git a/engines/wintermute/wintypes.h b/engines/wintermute/wintypes.h index 7a84dd2810..a83a31f2ea 100644 --- a/engines/wintermute/wintypes.h +++ b/engines/wintermute/wintypes.h @@ -50,4 +50,4 @@ namespace Wintermute { } // end of namespace Wintermute -#endif // WINTERMUTE_WINTYPES_H +#endif -- cgit v1.2.3 From 8cf7d765c05bd13fc381e94801b2bbd8c27e1c07 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:38:24 +0200 Subject: WINTERMUTE: General cleanup --- engines/wintermute/ad/ad_path.h | 2 +- engines/wintermute/ad/ad_scene.cpp | 2 +- engines/wintermute/base/base.h | 4 +--- engines/wintermute/base/font/base_font.h | 4 ++-- engines/wintermute/base/gfx/base_renderer.h | 2 +- engines/wintermute/math/matrix4.h | 9 --------- 6 files changed, 6 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h index b85e1fce7a..de115b261a 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -46,7 +46,7 @@ public: void reset(); AdPath(BaseGame *inGame); virtual ~AdPath(); - BaseArray _points; + BaseArray _points; int _currIndex; bool _ready; }; diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 176604b75f..5b96bc0c3a 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -267,7 +267,7 @@ void AdScene::pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester) { return; } - for (uint32 i = 0; i < wpt->_points.size(); i++) { + for (uint32 i = 0; i < wpt->_points.size(); i++) { if (isBlockedAt(wpt->_points[i]->x, wpt->_points[i]->y, true, requester)) { continue; } diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index b07065ec0d..f4c1cf0739 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -45,7 +45,7 @@ public: bool _persistable; bool setEditorProp(const Common::String &propName, const Common::String &propValue); Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); - BaseClass(TDynamicConstructor, TDynamicConstructor) {}; + BaseClass(TDynamicConstructor, TDynamicConstructor) {} bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); BaseClass(); @@ -55,8 +55,6 @@ public: protected: Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 461a724160..acd424ac06 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -43,8 +43,8 @@ public: virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - virtual void initLoop() {}; - virtual void afterLoad() {}; + virtual void initLoop() {} + virtual void afterLoad() {} BaseFont(BaseGame *inGame); virtual ~BaseFont(); diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 26d7e6db57..0ff4e6a3be 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -54,7 +54,7 @@ public: int _drawOffsetX; int _drawOffsetY; - virtual void dumpData(const char *filename) {}; + virtual void dumpData(const char *filename) {} /** * Take a screenshot of the current screenstate * diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h index 5b68944397..c95bd364ff 100644 --- a/engines/wintermute/math/matrix4.h +++ b/engines/wintermute/math/matrix4.h @@ -42,16 +42,7 @@ public: void rotationZ(float angle); void transformVector2(Vector2 &vec); - /* union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - };*/ float m[4][4]; - //}; - }; } // end of namespace Wintermute -- cgit v1.2.3 From 158a2060868eceff254460a89b67d78dc650bc94 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:42:53 +0200 Subject: WINTERMUTE: Use ++it instead of it++ --- engines/wintermute/base/base_file_manager.cpp | 6 +++--- engines/wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 4 ++-- engines/wintermute/base/file/base_package.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.cpp | 4 ++-- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 16 ++++++++-------- engines/wintermute/base/scriptables/script_engine.cpp | 4 ++-- engines/wintermute/coll_templ.h | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 01b11352b5..f139d99146 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -165,7 +165,7 @@ bool BaseFileManager::initPaths() { } bool BaseFileManager::registerPackages(const Common::FSList &fslist) { - for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { + for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); ++it) { debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it))) { @@ -183,10 +183,10 @@ bool BaseFileManager::registerPackages() { // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); ++it) { debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); - for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!fileIt->getName().hasSuffix(".dcp")) { continue; } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 1beaeecdd7..94588eff32 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -169,7 +169,7 @@ uint32 BasePersistenceManager::getMaxUsedSlot() { Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); Common::StringArray::iterator it = saves.begin(); int ret = -1; - for (; it != saves.end(); it++) { + for (; it != saves.end(); ++it) { int num = -1; sscanf(it->c_str(), "save%d", &num); ret = MAX(ret, num); diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 44a8049121..8fff78a32a 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -94,7 +94,7 @@ bool diskFileExists(const Common::String &filename) { Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { return true; } @@ -124,7 +124,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, fixedFilename); - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { file = (*it)->createReadStream(); break; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a9fb7f9a68..c5a62299e2 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -228,7 +228,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } PackageSet::~PackageSet() { - for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); ++it) { delete *it; } _packages.clear(); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 19c5cef7ee..36703ed44f 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -275,7 +275,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { + for (it = lines.begin(); it != lines.end(); ++it) { _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); heightOffset += (int)_lineHeight; } @@ -581,7 +581,7 @@ void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight _font->wordWrapText(text, maxWidth, lines); Common::Array::iterator it; textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { + for (it = lines.begin(); it != lines.end(); ++it) { textWidth = MAX(textWidth, _font->getStringWidth(*it)); } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 05520ee7a9..7a862e4441 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -210,7 +210,7 @@ bool BaseRenderOSystem::flip() { delete ticket; } else { (*it)->_wantsDraw = false; - it++; + ++it; } } } @@ -316,7 +316,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); compare._colorMod = _colorMod; RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { (*it)->_colorMod = _colorMod; if (_disableDirtyRects) { @@ -347,7 +347,7 @@ void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { if ((*it)->_owner == surf) { invalidateTicket(*it); } @@ -375,7 +375,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { Common::List::iterator it; renderTicket->_drawNum = _drawNum++; // Increment the following tickets, so they still are in line - for (it = pos; it != _renderQueue.end(); it++) { + for (it = pos; it != _renderQueue.end(); ++it) { (*it)->_drawNum++; (*it)->_wantsDraw = false; } @@ -393,12 +393,12 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { it = _renderQueue.erase(it); break; } else { - it++; + ++it; } } if (it != _renderQueue.end()) { // Decreement the following tickets. - for (; it != _renderQueue.end(); it++) { + for (; it != _renderQueue.end(); ++it) { (*it)->_drawNum--; } } @@ -431,7 +431,7 @@ void BaseRenderOSystem::drawTickets() { decrement++; } else { (*it)->_drawNum -= decrement; - it++; + ++it; } } if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { @@ -444,7 +444,7 @@ void BaseRenderOSystem::drawTickets() { // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); _drawNum = 1; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { RenderTicket *ticket = *it; assert(ticket->_drawNum == _drawNum++); if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index d518be579f..02f6080958 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -591,7 +591,7 @@ void ScEngine::dumpStats() { TimeVector times; ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); ++it) { times.push_back(std::pair (it->_value, it->_key)); } std::sort(times.begin(), times.end()); @@ -602,7 +602,7 @@ void ScEngine::dumpStats() { _gameRef->LOG(0, "***** Script profiling information: *****"); _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - for (tit = times.rbegin(); tit != times.rend(); tit++) { + for (tit = times.rbegin(); tit != times.rend(); ++tit) { _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); }*/ } diff --git a/engines/wintermute/coll_templ.h b/engines/wintermute/coll_templ.h index f1bf594769..389636cfe6 100644 --- a/engines/wintermute/coll_templ.h +++ b/engines/wintermute/coll_templ.h @@ -45,7 +45,7 @@ public: j = Common::Array::size(); persistMgr->transfer("ArraySize", &j); typename Common::Array::const_iterator it = Common::Array::begin(); - for (; it != Common::Array::end(); it++) { + for (; it != Common::Array::end(); ++it) { TYPE obj = *it; persistMgr->transfer("", &obj); } -- cgit v1.2.3 From 7027741de777f3d1f5e9e93f5a2dd8ade09b6599 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:51:07 +0200 Subject: WINTERMUTE: Fix warnings --- engines/wintermute/ad/ad_actor.cpp | 10 +++++----- engines/wintermute/base/base_frame.cpp | 8 ++++---- engines/wintermute/base/base_surface_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/font/base_font_truetype.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index dd50955b4c..63b1532416 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -1036,7 +1036,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *animName = stack->pop()->getString(); bool found = false; - for (int i = 0; i < _anims.size(); i++) { + for (uint32 i = 0; i < _anims.size(); i++) { if (scumm_stricmp(_anims[i]->getName(), animName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) { @@ -1255,7 +1255,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { // not - get a random talk if (!ret) { BaseArray talkAnims; - for (int i = 0; i < _anims.size(); i++) { + for (uint32 i = 0; i < _anims.size(); i++) { if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0) { talkAnims.add(_anims[i]); } @@ -1284,7 +1284,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { if (stance != NULL) { // search special stances - for (int i = 0; i < _talkSpritesEx.size(); i++) { + for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { ret = _talkSpritesEx[i]->getSprite(_dir); break; @@ -1292,7 +1292,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { } if (ret == NULL) { // search generic stances - for (int i = 0; i < _talkSprites.size(); i++) { + for (uint32 i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { ret = _talkSprites[i]->getSprite(_dir); break; @@ -1395,7 +1395,7 @@ int AdActor::getHeight() { ////////////////////////////////////////////////////////////////////////// AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { - for (int i = 0; i < _anims.size(); i++) { + for (uint32 i = 0; i < _anims.size(); i++) { if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0) { return _anims[i]; } diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index eb66661c62..ed2c7acaca 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -349,7 +349,7 @@ bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float Rect32 subRect; - for (int i = 0; i < _subframes.size(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); BasePlatform::unionRect(rect, rect, &subRect); } @@ -469,7 +469,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.size()) { + if (index < 0 || index >= (int32)_subframes.size()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else { @@ -487,7 +487,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _subframes.size()) { + if (index < 0 || index >= (int32)_subframes.size()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { @@ -563,7 +563,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.size()) { + if (index < 0 || index >= (int32)_applyEvent.size()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0e0976b838..c87da898db 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -176,8 +176,8 @@ bool BaseSurfaceStorage::sortSurfaces() { ////////////////////////////////////////////////////////////////////////// int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - const BaseSurface *s1 = *((BaseSurface **)arg1); - const BaseSurface *s2 = *((BaseSurface **)arg2); + const BaseSurface *s1 = *((const BaseSurface *const *)arg1); + const BaseSurface *s2 = *((const BaseSurface *const *)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index a9d71e0fa1..062f4801cf 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -118,10 +118,10 @@ int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TT AnsiString str; if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); str = StringUtil::wideToAnsi(wstr); } else { - str = AnsiString((char *)text); + str = AnsiString((const char *)text); } if (str.empty()) { return 0; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 36703ed44f..171f33d8ab 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -153,11 +153,11 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) { + if (text == NULL || strcmp((const char *)text, "") == 0) { return; } - WideString textStr = (char *)text; + WideString textStr = (const char *)text; // TODO: Why do we still insist on Widestrings everywhere? /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index f52a1b8c82..7012bef86f 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -373,8 +373,8 @@ bool PartEmitter::sortParticlesByZ() { ////////////////////////////////////////////////////////////////////////// int PartEmitter::compareZ(const void *obj1, const void *obj2) { - const PartParticle *p1 = *(PartParticle **)obj1; - const PartParticle *p2 = *(PartParticle **)obj2; + const PartParticle *p1 = *(const PartParticle *const *)obj1; + const PartParticle *p2 = *(const PartParticle *const *)obj2; if (p1->_posZ < p2->_posZ) { return -1; -- cgit v1.2.3 From 313376c32985c8ce23f148b8a70d0222e2310080 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:54:53 +0200 Subject: WINTERMUTE: Fix a warning I missed in the last commit. --- engines/wintermute/ad/ad_scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 5b96bc0c3a..ddaf4d0adb 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1195,8 +1195,8 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { ////////////////////////////////////////////////////////////////////////// int AdScene::compareObjs(const void *obj1, const void *obj2) { - const AdObject *object1 = *(AdObject **)obj1; - const AdObject *object2 = *(AdObject **)obj2; + const AdObject *object1 = *(const AdObject *const *)obj1; + const AdObject *object2 = *(const AdObject *const *)obj2; if (object1->_posY < object2->_posY) { return -1; -- cgit v1.2.3 From fb367d1ac3517897e7e3c1312fb8ed0c688cd137 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 20:14:34 +0200 Subject: WINTERMUTE: Fix a type in the header-guard-fix for base_active_rect.h --- engines/wintermute/base/base_active_rect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 848b77e56e..651b8530ac 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -27,7 +27,7 @@ */ #ifndef WINTERMUTE_BASE_ACTIVERECT_H -#define WINTERMUTE_BASE_BACTIVERECT_H +#define WINTERMUTE_BASE_ACTIVERECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" -- cgit v1.2.3 From 59b1bbfa158b308d2674ca07efa77dbc7dbefaea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 20:52:23 +0200 Subject: WINTERMUTE: Even more fixes to header-guards. --- engines/wintermute/base/base_active_rect.h | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 4 ++-- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/base_named_object.h | 4 ++-- engines/wintermute/base/base_persistence_manager.h | 4 ++-- engines/wintermute/base/base_save_thumb_helper.h | 4 ++-- engines/wintermute/base/base_string_table.h | 4 ++-- engines/wintermute/base/base_surface_storage.h | 4 ++-- engines/wintermute/base/base_transition_manager.h | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 651b8530ac..3c2cccfeed 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_ACTIVERECT_H -#define WINTERMUTE_BASE_ACTIVERECT_H +#ifndef WINTERMUTE_BASE_ACTIVE_RECT_H +#define WINTERMUTE_BASE_ACTIVE_RECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 23aebfdf9f..df35ad817d 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_DYNBUFFER_H -#define WINTERMUTE_BASE_DYNBUFFER_H +#ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H +#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 3716dd0581..1b93f7dee4 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_FILEMANAGER_H -#define WINTERMUTE_BASE_FILEMANAGER_H +#ifndef WINTERMUTE_BASE_FILE_MANAGER_H +#define WINTERMUTE_BASE_FILE_MANAGER_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index ca71471521..9818708605 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_NAMEDOBJECT_H -#define WINTERMUTE_BASE_NAMEDOBJECT_H +#ifndef WINTERMUTE_BASE_NAMED_OBJECT_H +#define WINTERMUTE_BASE_NAMED_OBJECT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 4de1f84c64..fb5a73d0d3 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_PERSISTMGR_H -#define WINTERMUTE_BASE_PERSISTMGR_H +#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H +#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index 7c06384aa1..0af3103f71 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -25,8 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_SAVETHUMBHELPER_H -#define WINTERMUTE_BASE_SAVETHUMBHELPER_H +#ifndef WINTERMUTE_BASE_SAVE_THUMB_HELPER_H +#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index 46295426fd..09d8aecce4 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_STRINGTABLE_H -#define WINTERMUTE_BASE_STRINGTABLE_H +#ifndef WINTERMUTE_BASE_STRING_TABLE_H +#define WINTERMUTE_BASE_STRING_TABLE_H #include "common/hashmap.h" diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 741177ae76..28c36bebca 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_SURFACESTORAGE_H -#define WINTERMUTE_BASE_SURFACESTORAGE_H +#ifndef WINTERMUTE_BASE_SURFACE_STORAGE_H +#define WINTERMUTE_BASE_SURFACE_STORAGE_H #include "engines/wintermute/base/base.h" #include "common/array.h" diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index daf2299c2f..1a989fbcfd 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_TRANSITIONMGR_H -#define WINTERMUTE_BASE_TRANSITIONMGR_H +#ifndef WINTERMUTE_BASE_TRANSITION_MANAGER_H +#define WINTERMUTE_BASE_TRANSITION_MANAGER_H #include "engines/wintermute/base/base.h" -- cgit v1.2.3 From e067520bb904615ed75217808ba27235eb244336 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 21:01:53 +0200 Subject: WINTERMUTE: Use tabs in enums --- engines/wintermute/ad/ad_response_box.h | 6 +- engines/wintermute/base/base_file_manager.h | 4 +- engines/wintermute/base/scriptables/dcscript.h | 152 ++++++++++++------------- engines/wintermute/utils/convert_utf.h | 12 +- engines/wintermute/video/video_theora_player.h | 8 +- engines/wintermute/wintermute.h | 10 +- 6 files changed, 96 insertions(+), 96 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index 99522f00f6..8c76b561c6 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -52,9 +52,9 @@ public: ScScript *_waitingScript; virtual bool listen(BaseScriptHolder *param1, uint32 param2); typedef enum { - EVENT_PREV, - EVENT_NEXT, - EVENT_RESPONSE + EVENT_PREV, + EVENT_NEXT, + EVENT_RESPONSE } TResponseEvent; bool weedResponses(); diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 1b93f7dee4..3fb4434e9c 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -52,8 +52,8 @@ public: static BaseFileManager *getEngineInstance(); private: typedef enum { - PATH_PACKAGE, - PATH_SINGLE + PATH_PACKAGE, + PATH_SINGLE } TPathType; bool reloadPaths(); bool initPaths(); diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index db63ad2b87..6810fdf665 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -36,104 +36,104 @@ namespace Wintermute { // value types typedef enum { - VAL_NULL, - VAL_STRING, - VAL_INT, - VAL_BOOL, - VAL_FLOAT, - VAL_OBJECT, - VAL_NATIVE, - VAL_VARIABLE_REF + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF } TValType; // script states typedef enum { - SCRIPT_RUNNING, - SCRIPT_WAITING, - SCRIPT_SLEEPING, - SCRIPT_FINISHED, - SCRIPT_PERSISTENT, - SCRIPT_ERROR, - SCRIPT_PAUSED, - SCRIPT_WAITING_SCRIPT, - SCRIPT_THREAD_FINISHED + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED } TScriptState; // opcodes typedef enum { - II_DEF_VAR = 0, - II_DEF_GLOB_VAR, - II_RET, - II_RET_EVENT, - II_CALL, - II_CALL_BY_EXP, - II_EXTERNAL_CALL, - II_SCOPE, - II_CORRECT_STACK, - II_CREATE_OBJECT, - II_POP_EMPTY, - II_PUSH_VAR, - II_PUSH_VAR_REF, - II_POP_VAR, - II_PUSH_VAR_THIS, // push current this on stack - II_PUSH_INT, - II_PUSH_BOOL, - II_PUSH_FLOAT, - II_PUSH_STRING, - II_PUSH_NULL, - II_PUSH_THIS_FROM_STACK, - II_PUSH_THIS, - II_POP_THIS, - II_PUSH_BY_EXP, - II_POP_BY_EXP, - II_JMP, - II_JMP_FALSE, - II_ADD, - II_SUB, - II_MUL, - II_DIV, - II_MODULO, - II_NOT, - II_AND, - II_OR, - II_CMP_EQ, - II_CMP_NE, - II_CMP_L, - II_CMP_G, - II_CMP_LE, - II_CMP_GE, - II_CMP_STRICT_EQ, - II_CMP_STRICT_NE, - II_DBG_LINE, - II_POP_REG1, - II_PUSH_REG1, - II_DEF_CONST_VAR + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR } TInstruction; // external data types typedef enum { - TYPE_VOID = 0, - TYPE_BOOL, - TYPE_LONG, - TYPE_BYTE, - TYPE_STRING, - TYPE_FLOAT, - TYPE_DOUBLE, - TYPE_MEMBUFFER + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER } TExternalType; // call types typedef enum { - CALL_STDCALL = 0, - CALL_CDECL, - CALL_THISCALL + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL } TCallType; // element types typedef enum { - ELEMENT_STRING = 0 + ELEMENT_STRING = 0 } TElementType; } // end of namespace Wintermute diff --git a/engines/wintermute/utils/convert_utf.h b/engines/wintermute/utils/convert_utf.h index 171d86343a..a5f34456f5 100644 --- a/engines/wintermute/utils/convert_utf.h +++ b/engines/wintermute/utils/convert_utf.h @@ -106,15 +106,15 @@ typedef uint8 Boolean; /* 0 or 1 */ #define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF typedef enum { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ } ConversionResult; typedef enum { - strictConversion = 0, - lenientConversion + strictConversion = 0, + lenientConversion } ConversionFlags; ConversionResult ConvertUTF8toUTF16( diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index fd1b7b94b3..593c1b9666 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -41,10 +41,10 @@ class BaseImage; class VideoTheoraPlayer : public BaseClass { private: enum { - THEORA_STATE_NONE = 0, - THEORA_STATE_PLAYING = 1, - THEORA_STATE_PAUSED = 2, - THEORA_STATE_FINISHED = 3 + THEORA_STATE_NONE = 0, + THEORA_STATE_PLAYING = 1, + THEORA_STATE_PAUSED = 2, + THEORA_STATE_FINISHED = 3 }; Video::VideoDecoder *_theoraDecoder; Graphics::Surface _surface; diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 730a4e8358..d24b120658 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -34,11 +34,11 @@ class BaseGame; class SystemClassRegistry; // our engine debug channels enum { - kWintermuteDebugLog = 1 << 0, // The debug-logs from the original engine - kWintermuteDebugSaveGame = 1 << 1, - kWintermuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) - kWintermuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) - kWintermuteDebugAudio = 1 << 4, + kWintermuteDebugLog = 1 << 0, // The debug-logs from the original engine + kWintermuteDebugSaveGame = 1 << 1, + kWintermuteDebugFont = 1 << 2, // next new channel must be 1 << 2 (4) + kWintermuteDebugFileAccess = 1 << 3, // the current limitation is 32 debug channels (1 << 31 is the last one) + kWintermuteDebugAudio = 1 << 4, kWintermuteDebugGeneral = 1 << 5 }; -- cgit v1.2.3 From 4a6c031e3197899d1bd2b745b9b6f3605a72cb65 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 21:50:12 +0200 Subject: WINTERMUTE: Fix a regression from the getSize()->size() change. --- engines/wintermute/ad/ad_scene.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index ddaf4d0adb..76238c1850 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -2214,6 +2214,9 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// bool AdScene::sortScaleLevels() { + if (_scaleLevels.size() == 0) { + return STATUS_OK; + } bool changed; do { changed = false; @@ -2235,6 +2238,9 @@ bool AdScene::sortScaleLevels() { ////////////////////////////////////////////////////////////////////////// bool AdScene::sortRotLevels() { + if (_rotLevels.size() == 0) { + return STATUS_OK; + } bool changed; do { changed = false; -- cgit v1.2.3 From 7b17d8060d5600fe736d0b3af4e24da4e1776ddb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 1 Sep 2012 14:04:23 +0200 Subject: WINTERMUTE: Fix various comments. --- engines/wintermute/ad/ad_scene.cpp | 13 ----- engines/wintermute/base/base_keyboard_state.cpp | 3 - engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 67 ---------------------- engines/wintermute/base/gfx/base_renderer.cpp | 1 + .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- 6 files changed, 4 insertions(+), 86 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 76238c1850..f67252350e 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -2370,13 +2370,6 @@ bool AdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *tar yLength = abs(y2 - y1); if (xLength > yLength) { - /* - if (X1 > X2) - { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ yStep = fabs((double)(y2 - y1) / (double)(x2 - x1)); y = y1; @@ -2390,12 +2383,6 @@ bool AdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *tar y += yStep; } } else { - /* - if (Y1 > Y2) { - Swap(&X1, &X2); - Swap(&Y1, &Y2); - } - */ xStep = fabs((double)(x2 - x1) / (double)(y2 - y1)); x = x1; diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 70d92784a5..63c0a873ce 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -92,9 +92,6 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * vKey = val->getInt(); } - warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); bool isDown = _keyStates[vKeyToKeyCode(vKey)]; stack->pushBool(isDown); diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index bbbb5d69ba..007f93e443 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -79,7 +79,7 @@ int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, ch } // find the token. - // for now just use brute force. Improve later. + // TODO: for now just use brute force. Improve later. while (tokens->id != 0) { if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { // here we could be matching PART of a string diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 8fb2b2b44a..cb70c4add8 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -67,73 +67,6 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { return 0; } -/* -////////////////////////////////////////////////////////////////////// -bool BaseFont::loadFile(const char * Filename) -{ - BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (Buffer==NULL){ - _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete[] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - BaseParser parser; - - if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ ////////////////////////////////////////////////////////////////////////// int BaseFont::getLetterHeight() { diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 9e271fc32d..202c864683 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -296,6 +296,7 @@ bool BaseRenderer::setViewport(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::clipCursor() { + // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) /* if (!_windowed) { Rect32 rc; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index ea88f19065..7724a93481 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -176,7 +176,7 @@ bool BaseSurfaceOSystem::finishLoad() { void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); return; - + // TODO: Reimplement this delete[] _alphaMask; _alphaMask = NULL; if (!surface) { @@ -190,7 +190,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { hasColorKey = true; SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); } else hasColorKey = false; - */ //TODO + */ _alphaMask = new byte[surface->w * surface->h]; bool hasTransparency = false; -- cgit v1.2.3 From 1554596f2458c40c43ff54691e039053e6980777 Mon Sep 17 00:00:00 2001 From: Einar Johan T. Sømåen Date: Mon, 3 Sep 2012 22:26:47 +0200 Subject: WINTERMUTE: Disable Wintermute by default in configure --- engines/configure.engines | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/configure.engines b/engines/configure.engines index 3809aca656..efe1f03ba2 100644 --- a/engines/configure.engines +++ b/engines/configure.engines @@ -45,4 +45,4 @@ add_engine toon "Toonstruck" yes add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes add_engine tsage "TsAGE" yes add_engine tucker "Bud Tucker in Double Trouble" yes -add_engine wintermute "Wintermute" yes +add_engine wintermute "Wintermute" no -- cgit v1.2.3